aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/lib')
-rw-r--r--nx-X11/lib/FS/FS-def.cpp38
-rw-r--r--nx-X11/lib/FS/FSClServ.c93
-rw-r--r--nx-X11/lib/FS/FSCloseFt.c70
-rw-r--r--nx-X11/lib/FS/FSConnServ.c247
-rw-r--r--nx-X11/lib/FS/FSErrDis.c121
-rw-r--r--nx-X11/lib/FS/FSErrHndlr.c84
-rw-r--r--nx-X11/lib/FS/FSFlush.c63
-rw-r--r--nx-X11/lib/FS/FSFontInfo.c346
-rw-r--r--nx-X11/lib/FS/FSFtNames.c131
-rw-r--r--nx-X11/lib/FS/FSGetCats.c114
-rw-r--r--nx-X11/lib/FS/FSListCats.c132
-rw-r--r--nx-X11/lib/FS/FSListExt.c125
-rw-r--r--nx-X11/lib/FS/FSMisc.c64
-rw-r--r--nx-X11/lib/FS/FSNextEv.c79
-rw-r--r--nx-X11/lib/FS/FSOpenFont.c92
-rw-r--r--nx-X11/lib/FS/FSOpenServ.c291
-rw-r--r--nx-X11/lib/FS/FSQGlyphs.c214
-rw-r--r--nx-X11/lib/FS/FSQXExt.c176
-rw-r--r--nx-X11/lib/FS/FSQXInfo.c130
-rw-r--r--nx-X11/lib/FS/FSQuExt.c82
-rw-r--r--nx-X11/lib/FS/FSServName.c73
-rw-r--r--nx-X11/lib/FS/FSSetCats.c94
-rw-r--r--nx-X11/lib/FS/FSSync.c81
-rw-r--r--nx-X11/lib/FS/FSSynchro.c91
-rw-r--r--nx-X11/lib/FS/FSlib.h313
-rw-r--r--nx-X11/lib/FS/FSlibInt.c1360
-rw-r--r--nx-X11/lib/FS/FSlibint.h400
-rw-r--r--nx-X11/lib/FS/FSlibos.h332
-rw-r--r--nx-X11/lib/FS/Imakefile58
-rw-r--r--nx-X11/lib/GL/GL/GL-def.cpp493
-rw-r--r--nx-X11/lib/GL/GL/Imakefile246
-rw-r--r--nx-X11/lib/GL/Imakefile119
-rw-r--r--nx-X11/lib/GL/apple/Imakefile54
-rw-r--r--nx-X11/lib/GL/apple/appledri.c302
-rw-r--r--nx-X11/lib/GL/apple/appledri.h106
-rw-r--r--nx-X11/lib/GL/apple/appledristr.h174
-rwxr-xr-xnx-X11/lib/GL/apple/build-dispatch101
-rw-r--r--nx-X11/lib/GL/apple/dri_dispatch.c153
-rw-r--r--nx-X11/lib/GL/apple/dri_dispatch.defs856
-rw-r--r--nx-X11/lib/GL/apple/dri_dispatch.h3861
-rw-r--r--nx-X11/lib/GL/apple/dri_driver.c1141
-rw-r--r--nx-X11/lib/GL/apple/dri_driver.h188
-rw-r--r--nx-X11/lib/GL/apple/dri_glx.c265
-rw-r--r--nx-X11/lib/GL/apple/dri_glx.h67
-rw-r--r--nx-X11/lib/GL/dri/drm/Imakefile54
-rw-r--r--nx-X11/lib/GL/glx/Imakefile233
-rw-r--r--nx-X11/lib/GL/mesa/Imakefile73
-rw-r--r--nx-X11/lib/GL/mesa/Imakefile.inc57
-rw-r--r--nx-X11/lib/GL/mesa/array_cache/Imakefile91
-rw-r--r--nx-X11/lib/GL/mesa/array_cache/Imakefile.inc34
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/Imakefile21
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/common/Imakefile44
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/common/Imakefile.inc105
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/ffb/Imakefile77
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/ffb/Imakefile.inc151
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/gamma/Imakefile77
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/gamma/Imakefile.inc140
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/i810/Imakefile77
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/i810/Imakefile.inc121
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/i915/Imakefile72
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/i915/Imakefile.inc140
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/mach64/Imakefile77
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/mach64/Imakefile.inc131
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/mga/Imakefile78
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/mga/Imakefile.inc135
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/r128/Imakefile77
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/r128/Imakefile.inc123
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/r200/Imakefile78
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/r200/Imakefile.inc200
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/radeon/Imakefile78
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/radeon/Imakefile.inc193
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/savage/Imakefile78
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/savage/Imakefile.inc105
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/sis/Imakefile80
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/sis/Imakefile.inc156
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/tdfx/Imakefile76
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/tdfx/Imakefile.inc140
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/unichrome/Imakefile80
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/unichrome/Imakefile.inc123
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/via/Imakefile80
-rw-r--r--nx-X11/lib/GL/mesa/drivers/dri/via/Imakefile.inc158
-rw-r--r--nx-X11/lib/GL/mesa/drivers/osmesa/Imakefile111
-rw-r--r--nx-X11/lib/GL/mesa/drivers/osmesa/OSMesa-def.cpp0
-rw-r--r--nx-X11/lib/GL/mesa/drivers/x11/Imakefile70
-rw-r--r--nx-X11/lib/GL/mesa/drivers/x11/Imakefile.inc104
-rw-r--r--nx-X11/lib/GL/mesa/main/Imakefile66
-rw-r--r--nx-X11/lib/GL/mesa/main/Imakefile.inc484
-rw-r--r--nx-X11/lib/GL/mesa/math/Imakefile98
-rw-r--r--nx-X11/lib/GL/mesa/math/Imakefile.inc82
-rw-r--r--nx-X11/lib/GL/mesa/shader/Imakefile107
-rw-r--r--nx-X11/lib/GL/mesa/shader/Imakefile.inc106
-rw-r--r--nx-X11/lib/GL/mesa/shader/grammar/Imakefile98
-rw-r--r--nx-X11/lib/GL/mesa/shader/grammar/Imakefile.inc29
-rw-r--r--nx-X11/lib/GL/mesa/shader/slang/Imakefile108
-rw-r--r--nx-X11/lib/GL/mesa/shader/slang/Imakefile.inc90
-rw-r--r--nx-X11/lib/GL/mesa/shader/slang/library/Imakefile97
-rw-r--r--nx-X11/lib/GL/mesa/shader/slang/library/Imakefile.inc14
-rw-r--r--nx-X11/lib/GL/mesa/sparc/Imakefile68
-rw-r--r--nx-X11/lib/GL/mesa/sparc/Imakefile.inc58
-rw-r--r--nx-X11/lib/GL/mesa/swrast/Imakefile100
-rw-r--r--nx-X11/lib/GL/mesa/swrast/Imakefile.inc218
-rw-r--r--nx-X11/lib/GL/mesa/swrast_setup/Imakefile99
-rw-r--r--nx-X11/lib/GL/mesa/swrast_setup/Imakefile.inc36
-rw-r--r--nx-X11/lib/GL/mesa/tnl/Imakefile101
-rw-r--r--nx-X11/lib/GL/mesa/tnl/Imakefile.inc225
-rw-r--r--nx-X11/lib/GL/mesa/tnl_dd/Imakefile63
-rw-r--r--nx-X11/lib/GL/mesa/tnl_dd/Imakefile.inc40
-rw-r--r--nx-X11/lib/GL/mesa/x86/Imakefile108
-rw-r--r--nx-X11/lib/GL/mesa/x86/Imakefile.inc217
-rw-r--r--nx-X11/lib/GLU/GLU-def.cpp166
-rw-r--r--nx-X11/lib/GLU/Imakefile133
-rw-r--r--nx-X11/lib/GLU/include/Imakefile38
-rw-r--r--nx-X11/lib/GLU/libnurbs/interface/Imakefile107
-rw-r--r--nx-X11/lib/GLU/libnurbs/internals/Imakefile269
-rw-r--r--nx-X11/lib/GLU/libnurbs/nurbtess/Imakefile150
-rw-r--r--nx-X11/lib/GLU/libtess/Imakefile109
-rw-r--r--nx-X11/lib/GLU/libutil/Imakefile84
-rw-r--r--nx-X11/lib/GLw/GLwM1DrawA.c55
-rw-r--r--nx-X11/lib/GLw/GLwM2DrawA.c55
-rw-r--r--nx-X11/lib/GLw/GLwXm/PrimitiveP.h90
-rw-r--r--nx-X11/lib/GLw/GLwXm/Xm.h143
-rw-r--r--nx-X11/lib/GLw/GLwXm/XmP.h67
-rw-r--r--nx-X11/lib/GLw/GLwXm/XmStrDefs.h121
-rw-r--r--nx-X11/lib/GLw/Imakefile87
-rw-r--r--nx-X11/lib/GLw/README.html242
-rw-r--r--nx-X11/lib/GLw/README.txt199
-rw-r--r--nx-X11/lib/ICE/ICE-def.cpp74
-rw-r--r--nx-X11/lib/ICE/ICE.h102
-rw-r--r--nx-X11/lib/ICE/ICEconn.h251
-rw-r--r--nx-X11/lib/ICE/ICElib.h433
-rw-r--r--nx-X11/lib/ICE/ICElibint.h537
-rw-r--r--nx-X11/lib/ICE/ICEmsg.h295
-rw-r--r--nx-X11/lib/ICE/ICEproto.h176
-rw-r--r--nx-X11/lib/ICE/ICEutil.h126
-rw-r--r--nx-X11/lib/ICE/Imakefile92
-rw-r--r--nx-X11/lib/ICE/accept.c188
-rw-r--r--nx-X11/lib/ICE/authutil.c539
-rw-r--r--nx-X11/lib/ICE/connect.c543
-rw-r--r--nx-X11/lib/ICE/error.c641
-rw-r--r--nx-X11/lib/ICE/getauth.c274
-rw-r--r--nx-X11/lib/ICE/globals.h64
-rw-r--r--nx-X11/lib/ICE/iceauth.c278
-rw-r--r--nx-X11/lib/ICE/listen.c283
-rw-r--r--nx-X11/lib/ICE/listenwk.c161
-rw-r--r--nx-X11/lib/ICE/locking.c67
-rw-r--r--nx-X11/lib/ICE/misc.c630
-rw-r--r--nx-X11/lib/ICE/ping.c66
-rw-r--r--nx-X11/lib/ICE/process.c2548
-rw-r--r--nx-X11/lib/ICE/protosetup.c293
-rw-r--r--nx-X11/lib/ICE/register.c256
-rw-r--r--nx-X11/lib/ICE/replywait.c161
-rw-r--r--nx-X11/lib/ICE/setauth.c121
-rw-r--r--nx-X11/lib/ICE/shutdown.c330
-rw-r--r--nx-X11/lib/ICE/watch.c206
-rw-r--r--nx-X11/lib/Imakefile250
-rw-r--r--nx-X11/lib/SM/Imakefile56
-rw-r--r--nx-X11/lib/SM/SM-def.cpp41
-rw-r--r--nx-X11/lib/SM/SM.h130
-rw-r--r--nx-X11/lib/SM/SMlib.h545
-rw-r--r--nx-X11/lib/SM/SMlibint.h517
-rw-r--r--nx-X11/lib/SM/SMproto.h208
-rw-r--r--nx-X11/lib/SM/globals.h68
-rw-r--r--nx-X11/lib/SM/sm_auth.c48
-rw-r--r--nx-X11/lib/SM/sm_client.c633
-rw-r--r--nx-X11/lib/SM/sm_client.c.NX.original633
-rw-r--r--nx-X11/lib/SM/sm_client.c.SM.original631
-rw-r--r--nx-X11/lib/SM/sm_error.c341
-rw-r--r--nx-X11/lib/SM/sm_genid.c215
-rw-r--r--nx-X11/lib/SM/sm_manager.c372
-rw-r--r--nx-X11/lib/SM/sm_misc.c217
-rw-r--r--nx-X11/lib/SM/sm_process.c889
-rw-r--r--nx-X11/lib/X11/AddDIC.c152
-rw-r--r--nx-X11/lib/X11/AddSF.c148
-rw-r--r--nx-X11/lib/X11/AllCells.c66
-rw-r--r--nx-X11/lib/X11/AllPlanes.c74
-rw-r--r--nx-X11/lib/X11/AllowEv.c53
-rw-r--r--nx-X11/lib/X11/AutoRep.c54
-rw-r--r--nx-X11/lib/X11/Backgnd.c51
-rw-r--r--nx-X11/lib/X11/BdrWidth.c55
-rw-r--r--nx-X11/lib/X11/Bell.c48
-rw-r--r--nx-X11/lib/X11/Border.c51
-rw-r--r--nx-X11/lib/X11/CCC.c290
-rw-r--r--nx-X11/lib/X11/ChAccCon.c65
-rw-r--r--nx-X11/lib/X11/ChActPGb.c51
-rw-r--r--nx-X11/lib/X11/ChClMode.c49
-rw-r--r--nx-X11/lib/X11/ChCmap.c51
-rw-r--r--nx-X11/lib/X11/ChGC.c54
-rw-r--r--nx-X11/lib/X11/ChKeyCon.c85
-rw-r--r--nx-X11/lib/X11/ChPntCon.c55
-rw-r--r--nx-X11/lib/X11/ChProp.c101
-rw-r--r--nx-X11/lib/X11/ChSaveSet.c65
-rw-r--r--nx-X11/lib/X11/ChWAttrs.c59
-rw-r--r--nx-X11/lib/X11/ChWindow.c64
-rw-r--r--nx-X11/lib/X11/ChkIfEv.c138
-rw-r--r--nx-X11/lib/X11/ChkIfEv.c.NX.original138
-rw-r--r--nx-X11/lib/X11/ChkIfEv.c.X.original85
-rw-r--r--nx-X11/lib/X11/ChkMaskEv.c89
-rw-r--r--nx-X11/lib/X11/ChkTypEv.c79
-rw-r--r--nx-X11/lib/X11/ChkTypWEv.c81
-rw-r--r--nx-X11/lib/X11/ChkWinEv.c90
-rw-r--r--nx-X11/lib/X11/CirWin.c50
-rw-r--r--nx-X11/lib/X11/CirWinDn.c49
-rw-r--r--nx-X11/lib/X11/CirWinUp.c49
-rw-r--r--nx-X11/lib/X11/ClDisplay.c76
-rw-r--r--nx-X11/lib/X11/Clear.c51
-rw-r--r--nx-X11/lib/X11/ClearArea.c56
-rw-r--r--nx-X11/lib/X11/Cmap.h11
-rw-r--r--nx-X11/lib/X11/ConfWind.c71
-rw-r--r--nx-X11/lib/X11/ConnDis.c1465
-rw-r--r--nx-X11/lib/X11/ConnDis.c.NX.original1465
-rw-r--r--nx-X11/lib/X11/ConnDis.c.X.original1233
-rw-r--r--nx-X11/lib/X11/Context.c311
-rw-r--r--nx-X11/lib/X11/ConvSel.c54
-rw-r--r--nx-X11/lib/X11/CopyArea.c64
-rw-r--r--nx-X11/lib/X11/CopyCmap.c66
-rw-r--r--nx-X11/lib/X11/CopyGC.c139
-rw-r--r--nx-X11/lib/X11/CopyPlane.c66
-rw-r--r--nx-X11/lib/X11/Cr.h28
-rw-r--r--nx-X11/lib/X11/CrBFData.c81
-rw-r--r--nx-X11/lib/X11/CrCmap.c59
-rw-r--r--nx-X11/lib/X11/CrCursor.c78
-rw-r--r--nx-X11/lib/X11/CrGC.c345
-rw-r--r--nx-X11/lib/X11/CrGlCur.c258
-rw-r--r--nx-X11/lib/X11/CrPFBData.c86
-rw-r--r--nx-X11/lib/X11/CrPixmap.c65
-rw-r--r--nx-X11/lib/X11/CrWindow.c77
-rw-r--r--nx-X11/lib/X11/Cursor.c55
-rw-r--r--nx-X11/lib/X11/Cv.h190
-rw-r--r--nx-X11/lib/X11/CvColW.c143
-rw-r--r--nx-X11/lib/X11/CvCols.c1032
-rw-r--r--nx-X11/lib/X11/DefCursor.c51
-rw-r--r--nx-X11/lib/X11/DelProp.c49
-rw-r--r--nx-X11/lib/X11/Depths.c63
-rw-r--r--nx-X11/lib/X11/DestSubs.c47
-rw-r--r--nx-X11/lib/X11/DestWind.c47
-rw-r--r--nx-X11/lib/X11/DisName.c66
-rw-r--r--nx-X11/lib/X11/DrArc.c84
-rw-r--r--nx-X11/lib/X11/DrArcs.c59
-rw-r--r--nx-X11/lib/X11/DrLine.c100
-rw-r--r--nx-X11/lib/X11/DrLines.c59
-rw-r--r--nx-X11/lib/X11/DrPoint.c98
-rw-r--r--nx-X11/lib/X11/DrPoints.c87
-rw-r--r--nx-X11/lib/X11/DrRect.c100
-rw-r--r--nx-X11/lib/X11/DrRects.c67
-rw-r--r--nx-X11/lib/X11/DrSegs.c68
-rw-r--r--nx-X11/lib/X11/ErrDes.c207
-rw-r--r--nx-X11/lib/X11/ErrHndlr.c88
-rw-r--r--nx-X11/lib/X11/EvToWire.c408
-rw-r--r--nx-X11/lib/X11/FSSaver.c67
-rw-r--r--nx-X11/lib/X11/FSWrap.c268
-rw-r--r--nx-X11/lib/X11/FetchName.c96
-rw-r--r--nx-X11/lib/X11/FillArc.c101
-rw-r--r--nx-X11/lib/X11/FillArcs.c69
-rw-r--r--nx-X11/lib/X11/FillPoly.c66
-rw-r--r--nx-X11/lib/X11/FillRct.c97
-rw-r--r--nx-X11/lib/X11/FillRcts.c68
-rw-r--r--nx-X11/lib/X11/FilterEv.c109
-rw-r--r--nx-X11/lib/X11/Flush.c45
-rw-r--r--nx-X11/lib/X11/Font.c734
-rw-r--r--nx-X11/lib/X11/FontInfo.c256
-rw-r--r--nx-X11/lib/X11/FontNames.c117
-rw-r--r--nx-X11/lib/X11/FreeCmap.c51
-rw-r--r--nx-X11/lib/X11/FreeCols.c59
-rw-r--r--nx-X11/lib/X11/FreeCurs.c46
-rw-r--r--nx-X11/lib/X11/FreeEData.c48
-rw-r--r--nx-X11/lib/X11/FreeGC.c52
-rw-r--r--nx-X11/lib/X11/FreePix.c47
-rw-r--r--nx-X11/lib/X11/GCMisc.c112
-rw-r--r--nx-X11/lib/X11/Geom.c91
-rw-r--r--nx-X11/lib/X11/GetAtomNm.c192
-rw-r--r--nx-X11/lib/X11/GetColor.c112
-rw-r--r--nx-X11/lib/X11/GetDflt.c259
-rw-r--r--nx-X11/lib/X11/GetFPath.c95
-rw-r--r--nx-X11/lib/X11/GetFProp.c56
-rw-r--r--nx-X11/lib/X11/GetGCVals.c129
-rw-r--r--nx-X11/lib/X11/GetGeom.c61
-rw-r--r--nx-X11/lib/X11/GetHColor.c60
-rw-r--r--nx-X11/lib/X11/GetHints.c341
-rw-r--r--nx-X11/lib/X11/GetIFocus.c52
-rw-r--r--nx-X11/lib/X11/GetImage.c127
-rw-r--r--nx-X11/lib/X11/GetKCnt.c58
-rw-r--r--nx-X11/lib/X11/GetMoEv.c86
-rw-r--r--nx-X11/lib/X11/GetNrmHint.c128
-rw-r--r--nx-X11/lib/X11/GetPCnt.c54
-rw-r--r--nx-X11/lib/X11/GetPntMap.c126
-rw-r--r--nx-X11/lib/X11/GetProp.c136
-rw-r--r--nx-X11/lib/X11/GetRGBCMap.c136
-rw-r--r--nx-X11/lib/X11/GetSOwner.c47
-rw-r--r--nx-X11/lib/X11/GetSSaver.c57
-rw-r--r--nx-X11/lib/X11/GetStCmap.c118
-rw-r--r--nx-X11/lib/X11/GetTxtProp.c114
-rw-r--r--nx-X11/lib/X11/GetWAttrs.c157
-rw-r--r--nx-X11/lib/X11/GetWMCMapW.c88
-rw-r--r--nx-X11/lib/X11/GetWMProto.c88
-rw-r--r--nx-X11/lib/X11/GrButton.c62
-rw-r--r--nx-X11/lib/X11/GrKey.c60
-rw-r--r--nx-X11/lib/X11/GrKeybd.c59
-rw-r--r--nx-X11/lib/X11/GrPointer.c66
-rw-r--r--nx-X11/lib/X11/GrServer.c45
-rw-r--r--nx-X11/lib/X11/HVC.c611
-rw-r--r--nx-X11/lib/X11/HVCGcC.c151
-rw-r--r--nx-X11/lib/X11/HVCGcV.c203
-rw-r--r--nx-X11/lib/X11/HVCGcVC.c264
-rw-r--r--nx-X11/lib/X11/HVCMnV.c165
-rw-r--r--nx-X11/lib/X11/HVCMxC.c245
-rw-r--r--nx-X11/lib/X11/HVCMxV.c249
-rw-r--r--nx-X11/lib/X11/HVCMxVC.c237
-rw-r--r--nx-X11/lib/X11/HVCMxVs.c163
-rw-r--r--nx-X11/lib/X11/HVCWpAj.c117
-rw-r--r--nx-X11/lib/X11/Host.c145
-rw-r--r--nx-X11/lib/X11/ICWrap.c457
-rw-r--r--nx-X11/lib/X11/IMWrap.c221
-rw-r--r--nx-X11/lib/X11/Iconify.c87
-rw-r--r--nx-X11/lib/X11/IdOfPr.c109
-rw-r--r--nx-X11/lib/X11/IfEvent.c80
-rw-r--r--nx-X11/lib/X11/IfEvent.c.NX.original80
-rw-r--r--nx-X11/lib/X11/IfEvent.c.X.original75
-rw-r--r--nx-X11/lib/X11/ImText.c104
-rw-r--r--nx-X11/lib/X11/ImText16.c106
-rw-r--r--nx-X11/lib/X11/ImUtil.c1032
-rw-r--r--nx-X11/lib/X11/ImUtil.h31
-rw-r--r--nx-X11/lib/X11/Imakefile1237
-rw-r--r--nx-X11/lib/X11/Imakefile.NX.original1237
-rw-r--r--nx-X11/lib/X11/Imakefile.X.original1134
-rw-r--r--nx-X11/lib/X11/InitExt.c371
-rw-r--r--nx-X11/lib/X11/InsCmap.c46
-rw-r--r--nx-X11/lib/X11/IntAtom.c301
-rw-r--r--nx-X11/lib/X11/Key.h18
-rw-r--r--nx-X11/lib/X11/KeyBind.c1081
-rw-r--r--nx-X11/lib/X11/KeysymStr.c154
-rw-r--r--nx-X11/lib/X11/KillCl.c46
-rw-r--r--nx-X11/lib/X11/LRGB.c1832
-rw-r--r--nx-X11/lib/X11/Lab.c416
-rw-r--r--nx-X11/lib/X11/LabGcC.c129
-rw-r--r--nx-X11/lib/X11/LabGcL.c176
-rw-r--r--nx-X11/lib/X11/LabGcLC.c225
-rw-r--r--nx-X11/lib/X11/LabMnL.c218
-rw-r--r--nx-X11/lib/X11/LabMxC.c205
-rw-r--r--nx-X11/lib/X11/LabMxL.c218
-rw-r--r--nx-X11/lib/X11/LabMxLC.c220
-rw-r--r--nx-X11/lib/X11/LabWpAj.c100
-rw-r--r--nx-X11/lib/X11/LiHosts.c140
-rw-r--r--nx-X11/lib/X11/LiICmaps.c74
-rw-r--r--nx-X11/lib/X11/LiProps.c72
-rw-r--r--nx-X11/lib/X11/ListExt.c101
-rw-r--r--nx-X11/lib/X11/LoadFont.c57
-rw-r--r--nx-X11/lib/X11/LockDis.c86
-rw-r--r--nx-X11/lib/X11/LookupCol.c105
-rw-r--r--nx-X11/lib/X11/LowerWin.c51
-rw-r--r--nx-X11/lib/X11/Luv.c386
-rw-r--r--nx-X11/lib/X11/LuvGcC.c129
-rw-r--r--nx-X11/lib/X11/LuvGcL.c176
-rw-r--r--nx-X11/lib/X11/LuvGcLC.c225
-rw-r--r--nx-X11/lib/X11/LuvMnL.c218
-rw-r--r--nx-X11/lib/X11/LuvMxC.c206
-rw-r--r--nx-X11/lib/X11/LuvMxL.c218
-rw-r--r--nx-X11/lib/X11/LuvMxLC.c220
-rw-r--r--nx-X11/lib/X11/LuvWpAj.c99
-rw-r--r--nx-X11/lib/X11/Macros.c259
-rw-r--r--nx-X11/lib/X11/MapRaised.c53
-rw-r--r--nx-X11/lib/X11/MapSubs.c45
-rw-r--r--nx-X11/lib/X11/MapWindow.c46
-rw-r--r--nx-X11/lib/X11/MaskEvent.c84
-rw-r--r--nx-X11/lib/X11/MaskEvent.c.NX.original84
-rw-r--r--nx-X11/lib/X11/MaskEvent.c.X.original79
-rw-r--r--nx-X11/lib/X11/Misc.c72
-rw-r--r--nx-X11/lib/X11/ModMap.c187
-rw-r--r--nx-X11/lib/X11/MoveWin.c66
-rw-r--r--nx-X11/lib/X11/NextEvent.c57
-rw-r--r--nx-X11/lib/X11/OCWrap.c144
-rw-r--r--nx-X11/lib/X11/OMWrap.c134
-rw-r--r--nx-X11/lib/X11/OfCCC.c163
-rw-r--r--nx-X11/lib/X11/OpenDis.c911
-rw-r--r--nx-X11/lib/X11/OpenDis.c.NX.original911
-rw-r--r--nx-X11/lib/X11/OpenDis.c.X.original869
-rw-r--r--nx-X11/lib/X11/ParseCmd.c227
-rw-r--r--nx-X11/lib/X11/ParseCol.c139
-rw-r--r--nx-X11/lib/X11/ParseGeom.c182
-rw-r--r--nx-X11/lib/X11/PeekEvent.c53
-rw-r--r--nx-X11/lib/X11/PeekIfEv.c81
-rw-r--r--nx-X11/lib/X11/PeekIfEv.c.NX.original81
-rw-r--r--nx-X11/lib/X11/PeekIfEv.c.X.original76
-rw-r--r--nx-X11/lib/X11/Pending.c69
-rw-r--r--nx-X11/lib/X11/Pending.c.NX.original69
-rw-r--r--nx-X11/lib/X11/Pending.c.X.original60
-rw-r--r--nx-X11/lib/X11/PixFormats.c63
-rw-r--r--nx-X11/lib/X11/PmapBgnd.c50
-rw-r--r--nx-X11/lib/X11/PmapBord.c50
-rw-r--r--nx-X11/lib/X11/PolyReg.c638
-rw-r--r--nx-X11/lib/X11/PolyTxt.c235
-rw-r--r--nx-X11/lib/X11/PolyTxt16.c269
-rw-r--r--nx-X11/lib/X11/PrOfId.c106
-rw-r--r--nx-X11/lib/X11/PropAlloc.c77
-rw-r--r--nx-X11/lib/X11/PutBEvent.c74
-rw-r--r--nx-X11/lib/X11/PutImage.c1044
-rw-r--r--nx-X11/lib/X11/QBlack.c85
-rw-r--r--nx-X11/lib/X11/QBlue.c85
-rw-r--r--nx-X11/lib/X11/QGreen.c85
-rw-r--r--nx-X11/lib/X11/QRed.c85
-rw-r--r--nx-X11/lib/X11/QWhite.c85
-rw-r--r--nx-X11/lib/X11/QuBest.c61
-rw-r--r--nx-X11/lib/X11/QuCol.c80
-rw-r--r--nx-X11/lib/X11/QuColor.c64
-rw-r--r--nx-X11/lib/X11/QuColors.c80
-rw-r--r--nx-X11/lib/X11/QuCols.c80
-rw-r--r--nx-X11/lib/X11/QuCurShp.c60
-rw-r--r--nx-X11/lib/X11/QuExt.c59
-rw-r--r--nx-X11/lib/X11/QuKeybd.c57
-rw-r--r--nx-X11/lib/X11/QuPntr.c63
-rw-r--r--nx-X11/lib/X11/QuStipShp.c60
-rw-r--r--nx-X11/lib/X11/QuTextE16.c84
-rw-r--r--nx-X11/lib/X11/QuTextExt.c83
-rw-r--r--nx-X11/lib/X11/QuTileShp.c61
-rw-r--r--nx-X11/lib/X11/QuTree.c75
-rw-r--r--nx-X11/lib/X11/Quarks.c417
-rw-r--r--nx-X11/lib/X11/RaiseWin.c51
-rw-r--r--nx-X11/lib/X11/RdBitF.c281
-rw-r--r--nx-X11/lib/X11/RecolorC.c55
-rw-r--r--nx-X11/lib/X11/ReconfWM.c142
-rw-r--r--nx-X11/lib/X11/ReconfWin.c83
-rw-r--r--nx-X11/lib/X11/Region.c1743
-rw-r--r--nx-X11/lib/X11/RegstFlt.c157
-rw-r--r--nx-X11/lib/X11/RepWindow.c52
-rw-r--r--nx-X11/lib/X11/RestackWs.c72
-rw-r--r--nx-X11/lib/X11/RotProp.c65
-rw-r--r--nx-X11/lib/X11/ScrResStr.c57
-rw-r--r--nx-X11/lib/X11/SelInput.c51
-rw-r--r--nx-X11/lib/X11/SendEvent.c79
-rw-r--r--nx-X11/lib/X11/SetBack.c48
-rw-r--r--nx-X11/lib/X11/SetCCC.c140
-rw-r--r--nx-X11/lib/X11/SetCRects.c83
-rw-r--r--nx-X11/lib/X11/SetClMask.c49
-rw-r--r--nx-X11/lib/X11/SetClOrig.c54
-rw-r--r--nx-X11/lib/X11/SetDashes.c57
-rw-r--r--nx-X11/lib/X11/SetFPath.c79
-rw-r--r--nx-X11/lib/X11/SetFont.c49
-rw-r--r--nx-X11/lib/X11/SetFore.c48
-rw-r--r--nx-X11/lib/X11/SetFunc.c48
-rw-r--r--nx-X11/lib/X11/SetGetCols.c303
-rw-r--r--nx-X11/lib/X11/SetHints.c297
-rw-r--r--nx-X11/lib/X11/SetIFocus.c52
-rw-r--r--nx-X11/lib/X11/SetLStyle.c65
-rw-r--r--nx-X11/lib/X11/SetLocale.c257
-rw-r--r--nx-X11/lib/X11/SetNrmHint.c111
-rw-r--r--nx-X11/lib/X11/SetPMask.c48
-rw-r--r--nx-X11/lib/X11/SetPntMap.c83
-rw-r--r--nx-X11/lib/X11/SetRGBCMap.c101
-rw-r--r--nx-X11/lib/X11/SetSOwner.c51
-rw-r--r--nx-X11/lib/X11/SetSSaver.c52
-rw-r--r--nx-X11/lib/X11/SetStCmap.c93
-rw-r--r--nx-X11/lib/X11/SetState.c65
-rw-r--r--nx-X11/lib/X11/SetStip.c48
-rw-r--r--nx-X11/lib/X11/SetTSOrig.c54
-rw-r--r--nx-X11/lib/X11/SetTile.c48
-rw-r--r--nx-X11/lib/X11/SetTxtProp.c94
-rw-r--r--nx-X11/lib/X11/SetWMCMapW.c75
-rw-r--r--nx-X11/lib/X11/SetWMProto.c75
-rw-r--r--nx-X11/lib/X11/StBytes.c106
-rw-r--r--nx-X11/lib/X11/StCol.c84
-rw-r--r--nx-X11/lib/X11/StColor.c72
-rw-r--r--nx-X11/lib/X11/StColors.c67
-rw-r--r--nx-X11/lib/X11/StCols.c115
-rw-r--r--nx-X11/lib/X11/StNColor.c87
-rw-r--r--nx-X11/lib/X11/StName.c55
-rw-r--r--nx-X11/lib/X11/StrKeysym.c158
-rw-r--r--nx-X11/lib/X11/StrToText.c91
-rw-r--r--nx-X11/lib/X11/Sync.c64
-rw-r--r--nx-X11/lib/X11/Synchro.c81
-rw-r--r--nx-X11/lib/X11/Text.c141
-rw-r--r--nx-X11/lib/X11/Text16.c154
-rw-r--r--nx-X11/lib/X11/TextExt.c236
-rw-r--r--nx-X11/lib/X11/TextExt16.c212
-rw-r--r--nx-X11/lib/X11/TextToStr.c121
-rw-r--r--nx-X11/lib/X11/TrCoords.c64
-rw-r--r--nx-X11/lib/X11/UIThrStubs.c160
-rw-r--r--nx-X11/lib/X11/UNDEFINED.c133
-rw-r--r--nx-X11/lib/X11/UndefCurs.c51
-rw-r--r--nx-X11/lib/X11/UngrabBut.c51
-rw-r--r--nx-X11/lib/X11/UngrabKbd.c47
-rw-r--r--nx-X11/lib/X11/UngrabKey.c55
-rw-r--r--nx-X11/lib/X11/UngrabPtr.c46
-rw-r--r--nx-X11/lib/X11/UngrabSvr.c46
-rw-r--r--nx-X11/lib/X11/UninsCmap.c46
-rw-r--r--nx-X11/lib/X11/UnldFont.c47
-rw-r--r--nx-X11/lib/X11/UnmapSubs.c46
-rw-r--r--nx-X11/lib/X11/UnmapWin.c47
-rw-r--r--nx-X11/lib/X11/VisUtil.c256
-rw-r--r--nx-X11/lib/X11/WMGeom.c185
-rw-r--r--nx-X11/lib/X11/WMProps.c149
-rw-r--r--nx-X11/lib/X11/WarpPtr.c59
-rw-r--r--nx-X11/lib/X11/WinEvent.c83
-rw-r--r--nx-X11/lib/X11/Window.c140
-rw-r--r--nx-X11/lib/X11/Withdraw.c84
-rw-r--r--nx-X11/lib/X11/WrBitF.c158
-rw-r--r--nx-X11/lib/X11/X11-def.cpp2013
-rw-r--r--nx-X11/lib/X11/XDefaultIMIF.c456
-rw-r--r--nx-X11/lib/X11/XDefaultOMIF.c1265
-rw-r--r--nx-X11/lib/X11/XErrorDB924
-rw-r--r--nx-X11/lib/X11/XKB.c771
-rw-r--r--nx-X11/lib/X11/XKBAlloc.c504
-rw-r--r--nx-X11/lib/X11/XKBBell.c182
-rw-r--r--nx-X11/lib/X11/XKBBind.c853
-rw-r--r--nx-X11/lib/X11/XKBCompat.c251
-rw-r--r--nx-X11/lib/X11/XKBCtrls.c356
-rw-r--r--nx-X11/lib/X11/XKBCvt.c340
-rw-r--r--nx-X11/lib/X11/XKBExtDev.c823
-rw-r--r--nx-X11/lib/X11/XKBGAlloc.c1021
-rw-r--r--nx-X11/lib/X11/XKBGeom.c670
-rw-r--r--nx-X11/lib/X11/XKBGetByName.c218
-rw-r--r--nx-X11/lib/X11/XKBGetMap.c823
-rw-r--r--nx-X11/lib/X11/XKBList.c251
-rw-r--r--nx-X11/lib/X11/XKBMAlloc.c1023
-rw-r--r--nx-X11/lib/X11/XKBMAlloc.c.NX.original1023
-rw-r--r--nx-X11/lib/X11/XKBMAlloc.c.X.original994
-rw-r--r--nx-X11/lib/X11/XKBMisc.c981
-rw-r--r--nx-X11/lib/X11/XKBNames.c891
-rw-r--r--nx-X11/lib/X11/XKBRdBuf.c234
-rw-r--r--nx-X11/lib/X11/XKBSetGeom.c470
-rw-r--r--nx-X11/lib/X11/XKBSetMap.c595
-rw-r--r--nx-X11/lib/X11/XKBUse.c801
-rw-r--r--nx-X11/lib/X11/XKBleds.c335
-rw-r--r--nx-X11/lib/X11/XKBlib.h1151
-rw-r--r--nx-X11/lib/X11/XKBlibint.h345
-rw-r--r--nx-X11/lib/X11/XKeysymDB354
-rw-r--r--nx-X11/lib/X11/XRGB.c244
-rw-r--r--nx-X11/lib/X11/XYZ.c188
-rw-r--r--nx-X11/lib/X11/Xaixlcint.h54
-rw-r--r--nx-X11/lib/X11/Xatomtype.h134
-rw-r--r--nx-X11/lib/X11/Xcms.h805
-rw-r--r--nx-X11/lib/X11/Xcms.txt45
-rw-r--r--nx-X11/lib/X11/Xcmsint.h262
-rw-r--r--nx-X11/lib/X11/XimImSw.h48
-rw-r--r--nx-X11/lib/X11/XimProto.h227
-rw-r--r--nx-X11/lib/X11/XimThai.h112
-rw-r--r--nx-X11/lib/X11/XimTrInt.h66
-rw-r--r--nx-X11/lib/X11/XimTrX.h66
-rw-r--r--nx-X11/lib/X11/XimTrans.h123
-rw-r--r--nx-X11/lib/X11/Ximint.h1002
-rw-r--r--nx-X11/lib/X11/XimintL.h88
-rw-r--r--nx-X11/lib/X11/XimintP.h293
-rw-r--r--nx-X11/lib/X11/Xintatom.h33
-rw-r--r--nx-X11/lib/X11/Xintconn.h36
-rw-r--r--nx-X11/lib/X11/XlcDL.c632
-rw-r--r--nx-X11/lib/X11/XlcGeneric.h164
-rw-r--r--nx-X11/lib/X11/XlcPubI.h301
-rw-r--r--nx-X11/lib/X11/XlcPublic.h326
-rw-r--r--nx-X11/lib/X11/XlcSL.c79
-rw-r--r--nx-X11/lib/X11/Xlcint.h976
-rw-r--r--nx-X11/lib/X11/Xlib.h4029
-rw-r--r--nx-X11/lib/X11/Xlib.h.NX.original4029
-rw-r--r--nx-X11/lib/X11/Xlib.h.X.original4008
-rw-r--r--nx-X11/lib/X11/XlibAsync.c181
-rw-r--r--nx-X11/lib/X11/XlibAsync.c.NX.original181
-rw-r--r--nx-X11/lib/X11/XlibAsync.c.X.original156
-rw-r--r--nx-X11/lib/X11/XlibConf.h7
-rw-r--r--nx-X11/lib/X11/XlibInt.c4167
-rw-r--r--nx-X11/lib/X11/XlibInt.c.NX.original4167
-rw-r--r--nx-X11/lib/X11/XlibInt.c.X.original3429
-rw-r--r--nx-X11/lib/X11/Xlibint.h1346
-rw-r--r--nx-X11/lib/X11/Xlibint.h.NX.original1346
-rw-r--r--nx-X11/lib/X11/Xlibint.h.X.original1313
-rw-r--r--nx-X11/lib/X11/Xlocale.h61
-rw-r--r--nx-X11/lib/X11/XomGeneric.h318
-rw-r--r--nx-X11/lib/X11/Xregion.h190
-rw-r--r--nx-X11/lib/X11/Xresinternal.h15
-rw-r--r--nx-X11/lib/X11/Xresource.h360
-rw-r--r--nx-X11/lib/X11/Xrm.c2663
-rw-r--r--nx-X11/lib/X11/XrmI.h47
-rw-r--r--nx-X11/lib/X11/Xutil.h827
-rw-r--r--nx-X11/lib/X11/cmsAllCol.c76
-rw-r--r--nx-X11/lib/X11/cmsAllNCol.c201
-rw-r--r--nx-X11/lib/X11/cmsCmap.c497
-rw-r--r--nx-X11/lib/X11/cmsColNm.c1034
-rw-r--r--nx-X11/lib/X11/cmsGlobls.c128
-rw-r--r--nx-X11/lib/X11/cmsInt.c415
-rw-r--r--nx-X11/lib/X11/cmsLkCol.c196
-rw-r--r--nx-X11/lib/X11/cmsMath.c140
-rw-r--r--nx-X11/lib/X11/cmsProp.c152
-rw-r--r--nx-X11/lib/X11/cmsProp.c.X.original148
-rw-r--r--nx-X11/lib/X11/cmsTrig.c597
-rw-r--r--nx-X11/lib/X11/cursorfont.h107
-rw-r--r--nx-X11/lib/X11/evtomask.c76
-rw-r--r--nx-X11/lib/X11/globals.c238
-rw-r--r--nx-X11/lib/X11/imCallbk.c754
-rw-r--r--nx-X11/lib/X11/imConv.c359
-rw-r--r--nx-X11/lib/X11/imDefFlt.c420
-rw-r--r--nx-X11/lib/X11/imDefIc.c1559
-rw-r--r--nx-X11/lib/X11/imDefIm.c2028
-rw-r--r--nx-X11/lib/X11/imDefLkup.c1171
-rw-r--r--nx-X11/lib/X11/imDispch.c108
-rw-r--r--nx-X11/lib/X11/imEvToWire.c792
-rw-r--r--nx-X11/lib/X11/imExten.c579
-rw-r--r--nx-X11/lib/X11/imImSw.c57
-rw-r--r--nx-X11/lib/X11/imInsClbk.c292
-rw-r--r--nx-X11/lib/X11/imInt.c271
-rw-r--r--nx-X11/lib/X11/imKStoUCS.c323
-rw-r--r--nx-X11/lib/X11/imLcFlt.c93
-rw-r--r--nx-X11/lib/X11/imLcGIc.c51
-rw-r--r--nx-X11/lib/X11/imLcIc.c195
-rw-r--r--nx-X11/lib/X11/imLcIm.c340
-rw-r--r--nx-X11/lib/X11/imLcLkup.c383
-rw-r--r--nx-X11/lib/X11/imLcPrs.c667
-rw-r--r--nx-X11/lib/X11/imLcSIc.c57
-rw-r--r--nx-X11/lib/X11/imRm.c3133
-rw-r--r--nx-X11/lib/X11/imRmAttr.c1517
-rw-r--r--nx-X11/lib/X11/imThaiFlt.c1375
-rw-r--r--nx-X11/lib/X11/imThaiIc.c233
-rw-r--r--nx-X11/lib/X11/imThaiIm.c235
-rw-r--r--nx-X11/lib/X11/imTrX.c491
-rw-r--r--nx-X11/lib/X11/imTrans.c301
-rw-r--r--nx-X11/lib/X11/imTransR.c304
-rw-r--r--nx-X11/lib/X11/jump_funcs1467
-rw-r--r--nx-X11/lib/X11/jump_ignore67
-rw-r--r--nx-X11/lib/X11/jump_vars84
-rw-r--r--nx-X11/lib/X11/lcCT.c1303
-rw-r--r--nx-X11/lib/X11/lcCharSet.c228
-rw-r--r--nx-X11/lib/X11/lcConv.c341
-rw-r--r--nx-X11/lib/X11/lcDB.c1308
-rw-r--r--nx-X11/lib/X11/lcDefConv.c793
-rw-r--r--nx-X11/lib/X11/lcDynamic.c80
-rw-r--r--nx-X11/lib/X11/lcEuc.c1539
-rw-r--r--nx-X11/lib/X11/lcFile.c648
-rw-r--r--nx-X11/lib/X11/lcGenConv.c3151
-rw-r--r--nx-X11/lib/X11/lcGeneric.c1194
-rw-r--r--nx-X11/lib/X11/lcInit.c181
-rw-r--r--nx-X11/lib/X11/lcJis.c947
-rw-r--r--nx-X11/lib/X11/lcPrTxt.c292
-rw-r--r--nx-X11/lib/X11/lcPubWrap.c101
-rw-r--r--nx-X11/lib/X11/lcPublic.c319
-rw-r--r--nx-X11/lib/X11/lcRM.c226
-rw-r--r--nx-X11/lib/X11/lcSjis.c1614
-rw-r--r--nx-X11/lib/X11/lcStd.c370
-rw-r--r--nx-X11/lib/X11/lcTxtPr.c256
-rw-r--r--nx-X11/lib/X11/lcUTF8.c1844
-rw-r--r--nx-X11/lib/X11/lcUTF8Load.c64
-rw-r--r--nx-X11/lib/X11/lcUniConv/8bit_tab_to_h.c536
-rw-r--r--nx-X11/lib/X11/lcUniConv/COPYRIGHT39
-rw-r--r--nx-X11/lib/X11/lcUniConv/README12
-rw-r--r--nx-X11/lib/X11/lcUniConv/armscii_8.h98
-rw-r--r--nx-X11/lib/X11/lcUniConv/ascii.h26
-rw-r--r--nx-X11/lib/X11/lcUniConv/big5.h4142
-rw-r--r--nx-X11/lib/X11/lcUniConv/big5_emacs.h164
-rw-r--r--nx-X11/lib/X11/lcUniConv/cjk_tab_to_h.c1025
-rw-r--r--nx-X11/lib/X11/lcUniConv/cp1133.h92
-rw-r--r--nx-X11/lib/X11/lcUniConv/cp1251.h113
-rw-r--r--nx-X11/lib/X11/lcUniConv/cp1255.h121
-rw-r--r--nx-X11/lib/X11/lcUniConv/cp1256.h135
-rw-r--r--nx-X11/lib/X11/lcUniConv/gb2312.h2553
-rw-r--r--nx-X11/lib/X11/lcUniConv/georgian_academy.h88
-rw-r--r--nx-X11/lib/X11/lcUniConv/georgian_ps.h105
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_1.h23
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_10.h88
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_11.h78
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_13.h91
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_14.h109
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_15.h63
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_16.h98
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_2.h94
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_3.h100
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_4.h94
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_5.h77
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_6.h80
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_7.h88
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_8.h89
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_9.h67
-rw-r--r--nx-X11/lib/X11/lcUniConv/iso8859_9e.h103
-rw-r--r--nx-X11/lib/X11/lcUniConv/jisx0201.h48
-rw-r--r--nx-X11/lib/X11/lcUniConv/jisx0208.h2397
-rw-r--r--nx-X11/lib/X11/lcUniConv/jisx0212.h2164
-rw-r--r--nx-X11/lib/X11/lcUniConv/koi8_c.h103
-rw-r--r--nx-X11/lib/X11/lcUniConv/koi8_r.h135
-rw-r--r--nx-X11/lib/X11/lcUniConv/koi8_u.h143
-rw-r--r--nx-X11/lib/X11/lcUniConv/ksc5601.h3003
-rw-r--r--nx-X11/lib/X11/lcUniConv/mulelao.h78
-rw-r--r--nx-X11/lib/X11/lcUniConv/tatar_cyr.h123
-rw-r--r--nx-X11/lib/X11/lcUniConv/tcvn.h134
-rw-r--r--nx-X11/lib/X11/lcUniConv/tis620.h78
-rw-r--r--nx-X11/lib/X11/lcUniConv/ucs2be.h32
-rw-r--r--nx-X11/lib/X11/lcUniConv/utf8.h110
-rw-r--r--nx-X11/lib/X11/lcUniConv/viscii.h123
-rw-r--r--nx-X11/lib/X11/lcUtil.c88
-rw-r--r--nx-X11/lib/X11/lcWrap.c651
-rw-r--r--nx-X11/lib/X11/libX11.elist42
-rw-r--r--nx-X11/lib/X11/locking.c653
-rw-r--r--nx-X11/lib/X11/locking.h156
-rw-r--r--nx-X11/lib/X11/mbWMProps.c71
-rw-r--r--nx-X11/lib/X11/mbWrap.c165
-rw-r--r--nx-X11/lib/X11/omDefault.c451
-rw-r--r--nx-X11/lib/X11/omGeneric.c2187
-rw-r--r--nx-X11/lib/X11/omImText.c92
-rw-r--r--nx-X11/lib/X11/omText.c372
-rw-r--r--nx-X11/lib/X11/omTextEsc.c302
-rw-r--r--nx-X11/lib/X11/omTextExt.c137
-rw-r--r--nx-X11/lib/X11/omTextPer.c204
-rw-r--r--nx-X11/lib/X11/omXChar.c479
-rw-r--r--nx-X11/lib/X11/os2Stubs.c429
-rw-r--r--nx-X11/lib/X11/poly.h295
-rw-r--r--nx-X11/lib/X11/udcInf.c718
-rw-r--r--nx-X11/lib/X11/utf8WMProps.c93
-rw-r--r--nx-X11/lib/X11/utf8Wrap.c187
-rw-r--r--nx-X11/lib/X11/util/makekeys.c274
-rw-r--r--nx-X11/lib/X11/util/mkks.sh11
-rw-r--r--nx-X11/lib/X11/uvY.c408
-rw-r--r--nx-X11/lib/X11/wcWrap.c163
-rw-r--r--nx-X11/lib/X11/xlibi18n/Imakefile9
-rw-r--r--nx-X11/lib/X11/xlibi18n/Xi18nLib.conf105
-rw-r--r--nx-X11/lib/X11/xlibi18n/im/Imakefile10
-rw-r--r--nx-X11/lib/X11/xlibi18n/im/ximcp/Imakefile53
-rw-r--r--nx-X11/lib/X11/xlibi18n/im/ximcp/Ximcp.mapfile6
-rw-r--r--nx-X11/lib/X11/xlibi18n/lc/Imakefile10
-rw-r--r--nx-X11/lib/X11/xlibi18n/lc/Utf8/Imakefile13
-rw-r--r--nx-X11/lib/X11/xlibi18n/lc/def/Imakefile13
-rw-r--r--nx-X11/lib/X11/xlibi18n/lc/def/Xlc.mapfile6
-rw-r--r--nx-X11/lib/X11/xlibi18n/lc/gen/Imakefile13
-rw-r--r--nx-X11/lib/X11/xlibi18n/lc/gen/Xlc.mapfile6
-rw-r--r--nx-X11/lib/X11/xlibi18n/lc/xlocale/Imakefile15
-rw-r--r--nx-X11/lib/X11/xlibi18n/om/Imakefile10
-rw-r--r--nx-X11/lib/X11/xlibi18n/om/generic/Imakefile21
-rw-r--r--nx-X11/lib/X11/xlibi18n/om/generic/Xom.mapfile6
-rw-r--r--nx-X11/lib/X11/xyY.c380
-rw-r--r--nx-X11/lib/XRes/Imakefile34
-rw-r--r--nx-X11/lib/XRes/XRes-def.cpp9
-rw-r--r--nx-X11/lib/XRes/XRes.c233
-rw-r--r--nx-X11/lib/XRes/XRes.man140
-rw-r--r--nx-X11/lib/XTrap/Imakefile30
-rw-r--r--nx-X11/lib/XTrap/XECallBcks.c175
-rw-r--r--nx-X11/lib/XTrap/XEConTxt.c589
-rw-r--r--nx-X11/lib/XTrap/XEDsptch.c111
-rw-r--r--nx-X11/lib/XTrap/XEPrInfo.c274
-rw-r--r--nx-X11/lib/XTrap/XERqsts.c412
-rw-r--r--nx-X11/lib/XTrap/XEStrMap.c284
-rw-r--r--nx-X11/lib/XTrap/XETrapInit.c218
-rw-r--r--nx-X11/lib/XTrap/XEWrappers.c325
-rw-r--r--nx-X11/lib/XTrap/XTrap-def.cpp76
-rw-r--r--nx-X11/lib/Xau/AuDispose.c51
-rw-r--r--nx-X11/lib/Xau/AuFileName.c75
-rw-r--r--nx-X11/lib/Xau/AuGetAddr.c112
-rw-r--r--nx-X11/lib/Xau/AuGetBest.c173
-rw-r--r--nx-X11/lib/Xau/AuLock.c106
-rw-r--r--nx-X11/lib/Xau/AuRead.c137
-rw-r--r--nx-X11/lib/Xau/AuRead.c.NX.original137
-rw-r--r--nx-X11/lib/Xau/AuRead.c.X.original111
-rw-r--r--nx-X11/lib/Xau/AuUnlock.c62
-rw-r--r--nx-X11/lib/Xau/AuWrite.c73
-rw-r--r--nx-X11/lib/Xau/Autest.c71
-rw-r--r--nx-X11/lib/Xau/Imakefile49
-rw-r--r--nx-X11/lib/Xau/README184
-rw-r--r--nx-X11/lib/Xau/Xauth.h162
-rw-r--r--nx-X11/lib/Xau/k5encode.c186
-rw-r--r--nx-X11/lib/Xaw/Actions.c1139
-rw-r--r--nx-X11/lib/Xaw/AllWidgets.c126
-rw-r--r--nx-X11/lib/Xaw/AllWidgets.h38
-rw-r--r--nx-X11/lib/Xaw/AsciiSink.c1951
-rw-r--r--nx-X11/lib/Xaw/AsciiSink.h82
-rw-r--r--nx-X11/lib/Xaw/AsciiSinkP.h101
-rw-r--r--nx-X11/lib/Xaw/AsciiSrc.c1886
-rw-r--r--nx-X11/lib/Xaw/AsciiSrc.h175
-rw-r--r--nx-X11/lib/Xaw/AsciiSrcP.h145
-rw-r--r--nx-X11/lib/Xaw/AsciiText.c360
-rw-r--r--nx-X11/lib/Xaw/AsciiText.h128
-rw-r--r--nx-X11/lib/Xaw/AsciiTextP.h169
-rw-r--r--nx-X11/lib/Xaw/Box.c675
-rw-r--r--nx-X11/lib/Xaw/Box.h108
-rw-r--r--nx-X11/lib/Xaw/BoxP.h103
-rw-r--r--nx-X11/lib/Xaw/CHANGES153
-rw-r--r--nx-X11/lib/Xaw/Cardinals.h43
-rw-r--r--nx-X11/lib/Xaw/Changelog1370
-rw-r--r--nx-X11/lib/Xaw/Command.c660
-rw-r--r--nx-X11/lib/Xaw/Command.h119
-rw-r--r--nx-X11/lib/Xaw/CommandP.h117
-rw-r--r--nx-X11/lib/Xaw/Converters.c701
-rw-r--r--nx-X11/lib/Xaw/Dialog.c463
-rw-r--r--nx-X11/lib/Xaw/Dialog.h101
-rw-r--r--nx-X11/lib/Xaw/DialogP.h104
-rw-r--r--nx-X11/lib/Xaw/DisplayList.c2257
-rw-r--r--nx-X11/lib/Xaw/Form.c1110
-rw-r--r--nx-X11/lib/Xaw/Form.h171
-rw-r--r--nx-X11/lib/Xaw/FormP.h142
-rw-r--r--nx-X11/lib/Xaw/Grip.c188
-rw-r--r--nx-X11/lib/Xaw/Grip.h99
-rw-r--r--nx-X11/lib/Xaw/GripP.h91
-rw-r--r--nx-X11/lib/Xaw/Imakefile209
-rw-r--r--nx-X11/lib/Xaw/Label.c824
-rw-r--r--nx-X11/lib/Xaw/Label.h135
-rw-r--r--nx-X11/lib/Xaw/LabelP.h121
-rw-r--r--nx-X11/lib/Xaw/List.c1273
-rw-r--r--nx-X11/lib/Xaw/List.h237
-rw-r--r--nx-X11/lib/Xaw/ListP.h118
-rw-r--r--nx-X11/lib/Xaw/MenuButtoP.h80
-rw-r--r--nx-X11/lib/Xaw/MenuButton.c276
-rw-r--r--nx-X11/lib/Xaw/MenuButton.h91
-rw-r--r--nx-X11/lib/Xaw/MultiSink.c978
-rw-r--r--nx-X11/lib/Xaw/MultiSink.h113
-rw-r--r--nx-X11/lib/Xaw/MultiSinkP.h141
-rw-r--r--nx-X11/lib/Xaw/MultiSrc.c1620
-rw-r--r--nx-X11/lib/Xaw/MultiSrc.h133
-rw-r--r--nx-X11/lib/Xaw/MultiSrcP.h182
-rw-r--r--nx-X11/lib/Xaw/OS.c64
-rw-r--r--nx-X11/lib/Xaw/Paned.c2067
-rw-r--r--nx-X11/lib/Xaw/Paned.h264
-rw-r--r--nx-X11/lib/Xaw/PanedP.h180
-rw-r--r--nx-X11/lib/Xaw/Panner.c1082
-rw-r--r--nx-X11/lib/Xaw/Panner.h107
-rw-r--r--nx-X11/lib/Xaw/PannerP.h108
-rw-r--r--nx-X11/lib/Xaw/Pixmap.c993
-rw-r--r--nx-X11/lib/Xaw/Porthole.c378
-rw-r--r--nx-X11/lib/Xaw/Porthole.h63
-rw-r--r--nx-X11/lib/Xaw/PortholeP.h64
-rw-r--r--nx-X11/lib/Xaw/Print.h132
-rw-r--r--nx-X11/lib/Xaw/PrintSP.h135
-rw-r--r--nx-X11/lib/Xaw/PrintShell.c750
-rw-r--r--nx-X11/lib/Xaw/Private.h154
-rw-r--r--nx-X11/lib/Xaw/Repeater.c300
-rw-r--r--nx-X11/lib/Xaw/Repeater.h75
-rw-r--r--nx-X11/lib/Xaw/RepeaterP.h84
-rw-r--r--nx-X11/lib/Xaw/Reports.h56
-rw-r--r--nx-X11/lib/Xaw/Scrollbar.c885
-rw-r--r--nx-X11/lib/Xaw/Scrollbar.h137
-rw-r--r--nx-X11/lib/Xaw/ScrollbarP.h109
-rw-r--r--nx-X11/lib/Xaw/Simple.c504
-rw-r--r--nx-X11/lib/Xaw/Simple.h116
-rw-r--r--nx-X11/lib/Xaw/SimpleMenP.h101
-rw-r--r--nx-X11/lib/Xaw/SimpleMenu.c1834
-rw-r--r--nx-X11/lib/Xaw/SimpleMenu.h173
-rw-r--r--nx-X11/lib/Xaw/SimpleP.h102
-rw-r--r--nx-X11/lib/Xaw/Sme.c272
-rw-r--r--nx-X11/lib/Xaw/Sme.h73
-rw-r--r--nx-X11/lib/Xaw/SmeBSB.c774
-rw-r--r--nx-X11/lib/Xaw/SmeBSB.h98
-rw-r--r--nx-X11/lib/Xaw/SmeBSBP.h94
-rw-r--r--nx-X11/lib/Xaw/SmeLine.c267
-rw-r--r--nx-X11/lib/Xaw/SmeLine.h71
-rw-r--r--nx-X11/lib/Xaw/SmeLineP.h75
-rw-r--r--nx-X11/lib/Xaw/SmeP.h90
-rw-r--r--nx-X11/lib/Xaw/StripCharP.h110
-rw-r--r--nx-X11/lib/Xaw/StripChart.c579
-rw-r--r--nx-X11/lib/Xaw/StripChart.h119
-rw-r--r--nx-X11/lib/Xaw/Template.c198
-rw-r--r--nx-X11/lib/Xaw/Template.h70
-rw-r--r--nx-X11/lib/Xaw/TemplateP.h68
-rw-r--r--nx-X11/lib/Xaw/Text.c4164
-rw-r--r--nx-X11/lib/Xaw/Text.h373
-rw-r--r--nx-X11/lib/Xaw/TextAction.c4428
-rw-r--r--nx-X11/lib/Xaw/TextP.h321
-rw-r--r--nx-X11/lib/Xaw/TextPop.c1554
-rw-r--r--nx-X11/lib/Xaw/TextSink.c1829
-rw-r--r--nx-X11/lib/Xaw/TextSink.h364
-rw-r--r--nx-X11/lib/Xaw/TextSinkP.h306
-rw-r--r--nx-X11/lib/Xaw/TextSrc.c1981
-rw-r--r--nx-X11/lib/Xaw/TextSrc.h280
-rw-r--r--nx-X11/lib/Xaw/TextSrcP.h264
-rw-r--r--nx-X11/lib/Xaw/TextTr.c159
-rw-r--r--nx-X11/lib/Xaw/Tip.c638
-rw-r--r--nx-X11/lib/Xaw/Tip.h120
-rw-r--r--nx-X11/lib/Xaw/TipP.h77
-rw-r--r--nx-X11/lib/Xaw/Toggle.c632
-rw-r--r--nx-X11/lib/Xaw/Toggle.h181
-rw-r--r--nx-X11/lib/Xaw/ToggleP.h95
-rw-r--r--nx-X11/lib/Xaw/Tree.c1017
-rw-r--r--nx-X11/lib/Xaw/Tree.h138
-rw-r--r--nx-X11/lib/Xaw/TreeP.h141
-rw-r--r--nx-X11/lib/Xaw/Vendor.c527
-rw-r--r--nx-X11/lib/Xaw/VendorEP.h84
-rw-r--r--nx-X11/lib/Xaw/Viewport.c1102
-rw-r--r--nx-X11/lib/Xaw/Viewport.h121
-rw-r--r--nx-X11/lib/Xaw/ViewportP.h109
-rw-r--r--nx-X11/lib/Xaw/Xaw-def.cpp157
-rw-r--r--nx-X11/lib/Xaw/Xaw.man588
-rw-r--r--nx-X11/lib/Xaw/XawI18n.c104
-rw-r--r--nx-X11/lib/Xaw/XawI18n.h122
-rw-r--r--nx-X11/lib/Xaw/XawIm.c1613
-rw-r--r--nx-X11/lib/Xaw/XawImP.h213
-rw-r--r--nx-X11/lib/Xaw/XawInit.c100
-rw-r--r--nx-X11/lib/Xaw/XawInit.h64
-rw-r--r--nx-X11/lib/Xaw/genlist.sh41
-rw-r--r--nx-X11/lib/Xaw/jump_funcs117
-rw-r--r--nx-X11/lib/Xaw/jump_ignore7
-rw-r--r--nx-X11/lib/Xaw/jump_vars83
-rw-r--r--nx-X11/lib/Xaw/sharedlib.c182
-rw-r--r--nx-X11/lib/Xaw6/Imakefile170
-rw-r--r--nx-X11/lib/Xaw6/Xaw-def.cpp144
-rw-r--r--nx-X11/lib/Xaw7/Imakefile336
-rw-r--r--nx-X11/lib/Xaw7/Xaw-def.cpp156
-rw-r--r--nx-X11/lib/Xbsd/Berklib.c331
-rw-r--r--nx-X11/lib/Xbsd/Imakefile16
-rw-r--r--nx-X11/lib/Xcomposite/.cvsignore24
-rw-r--r--nx-X11/lib/Xcomposite/AUTHORS1
-rw-r--r--nx-X11/lib/Xcomposite/COPYING22
-rw-r--r--nx-X11/lib/Xcomposite/ChangeLog19
-rw-r--r--nx-X11/lib/Xcomposite/INSTALL8
-rw-r--r--nx-X11/lib/Xcomposite/Imakefile68
-rw-r--r--nx-X11/lib/Xcomposite/Makefile.am52
-rw-r--r--nx-X11/lib/Xcomposite/NEWS0
-rw-r--r--nx-X11/lib/Xcomposite/README10
-rw-r--r--nx-X11/lib/Xcomposite/Xcomposite.c333
-rw-r--r--nx-X11/lib/Xcomposite/Xcomposite.h71
-rwxr-xr-xnx-X11/lib/Xcomposite/autogen.sh3
-rw-r--r--nx-X11/lib/Xcomposite/configure.ac102
-rw-r--r--nx-X11/lib/Xcomposite/xcomposite.pc.in10
-rw-r--r--nx-X11/lib/Xcomposite/xcompositeint.h66
-rw-r--r--nx-X11/lib/Xcursor/AUTHORS2
-rw-r--r--nx-X11/lib/Xcursor/COPYING19
-rw-r--r--nx-X11/lib/Xcursor/ChangeLog202
-rw-r--r--nx-X11/lib/Xcursor/INSTALL0
-rw-r--r--nx-X11/lib/Xcursor/Imakefile100
-rw-r--r--nx-X11/lib/Xcursor/Makefile.am45
-rw-r--r--nx-X11/lib/Xcursor/NEWS0
-rw-r--r--nx-X11/lib/Xcursor/README0
-rw-r--r--nx-X11/lib/Xcursor/Xcursor-def.cpp54
-rw-r--r--nx-X11/lib/Xcursor/Xcursor.h501
-rw-r--r--nx-X11/lib/Xcursor/Xcursor.man379
-rwxr-xr-xnx-X11/lib/Xcursor/autogen.sh12
-rw-r--r--nx-X11/lib/Xcursor/config-subst10
-rw-r--r--nx-X11/lib/Xcursor/config.h0
-rw-r--r--nx-X11/lib/Xcursor/configure.ac143
-rw-r--r--nx-X11/lib/Xcursor/cursor.c815
-rw-r--r--nx-X11/lib/Xcursor/display.c382
-rw-r--r--nx-X11/lib/Xcursor/file.c1101
-rw-r--r--nx-X11/lib/Xcursor/library.c495
-rw-r--r--nx-X11/lib/Xcursor/xcursor-config.in95
-rw-r--r--nx-X11/lib/Xcursor/xcursor.pc.in15
-rw-r--r--nx-X11/lib/Xcursor/xcursorint.h109
-rw-r--r--nx-X11/lib/Xcursor/xlib.c422
-rw-r--r--nx-X11/lib/Xdamage/.cvsignore24
-rw-r--r--nx-X11/lib/Xdamage/AUTHORS2
-rw-r--r--nx-X11/lib/Xdamage/COPYING22
-rw-r--r--nx-X11/lib/Xdamage/ChangeLog13
-rw-r--r--nx-X11/lib/Xdamage/INSTALL8
-rw-r--r--nx-X11/lib/Xdamage/Imakefile68
-rw-r--r--nx-X11/lib/Xdamage/Makefile.am52
-rw-r--r--nx-X11/lib/Xdamage/NEWS0
-rw-r--r--nx-X11/lib/Xdamage/README10
-rw-r--r--nx-X11/lib/Xdamage/Xdamage.c365
-rw-r--r--nx-X11/lib/Xdamage/Xdamage.h68
-rwxr-xr-xnx-X11/lib/Xdamage/autogen.sh3
-rw-r--r--nx-X11/lib/Xdamage/configure.ac93
-rw-r--r--nx-X11/lib/Xdamage/xdamage.pc.in10
-rw-r--r--nx-X11/lib/Xdamage/xdamageint.h66
-rw-r--r--nx-X11/lib/Xdmcp/A8Eq.c50
-rw-r--r--nx-X11/lib/Xdmcp/AA16.c51
-rw-r--r--nx-X11/lib/Xdmcp/AA32.c51
-rw-r--r--nx-X11/lib/Xdmcp/AA8.c51
-rw-r--r--nx-X11/lib/Xdmcp/Alloc.c66
-rw-r--r--nx-X11/lib/Xdmcp/AofA8.c51
-rw-r--r--nx-X11/lib/Xdmcp/CA8.c49
-rw-r--r--nx-X11/lib/Xdmcp/CmpKey.c49
-rw-r--r--nx-X11/lib/Xdmcp/DA16.c46
-rw-r--r--nx-X11/lib/Xdmcp/DA32.c45
-rw-r--r--nx-X11/lib/Xdmcp/DA8.c45
-rw-r--r--nx-X11/lib/Xdmcp/DAofA8.c51
-rw-r--r--nx-X11/lib/Xdmcp/DecKey.c49
-rw-r--r--nx-X11/lib/Xdmcp/Fill.c102
-rw-r--r--nx-X11/lib/Xdmcp/Flush.c83
-rw-r--r--nx-X11/lib/Xdmcp/GenKey.c74
-rw-r--r--nx-X11/lib/Xdmcp/Imakefile121
-rw-r--r--nx-X11/lib/Xdmcp/IncKey.c49
-rw-r--r--nx-X11/lib/Xdmcp/RA16.c72
-rw-r--r--nx-X11/lib/Xdmcp/RA32.c72
-rw-r--r--nx-X11/lib/Xdmcp/RA8.c72
-rw-r--r--nx-X11/lib/Xdmcp/RAofA8.c75
-rw-r--r--nx-X11/lib/Xdmcp/RC16.c52
-rw-r--r--nx-X11/lib/Xdmcp/RC32.c56
-rw-r--r--nx-X11/lib/Xdmcp/RC8.c47
-rw-r--r--nx-X11/lib/Xdmcp/RHead.c48
-rw-r--r--nx-X11/lib/Xdmcp/RR.c43
-rw-r--r--nx-X11/lib/Xdmcp/RaA16.c51
-rw-r--r--nx-X11/lib/Xdmcp/RaA32.c51
-rw-r--r--nx-X11/lib/Xdmcp/RaA8.c51
-rw-r--r--nx-X11/lib/Xdmcp/RaAoA8.c51
-rw-r--r--nx-X11/lib/Xdmcp/Unwrap.c95
-rw-r--r--nx-X11/lib/Xdmcp/WA16.c51
-rw-r--r--nx-X11/lib/Xdmcp/WA32.c51
-rw-r--r--nx-X11/lib/Xdmcp/WA8.c51
-rw-r--r--nx-X11/lib/Xdmcp/WAofA8.c51
-rw-r--r--nx-X11/lib/Xdmcp/WC16.c50
-rw-r--r--nx-X11/lib/Xdmcp/WC32.c53
-rw-r--r--nx-X11/lib/Xdmcp/WC8.c49
-rw-r--r--nx-X11/lib/Xdmcp/Whead.c64
-rw-r--r--nx-X11/lib/Xdmcp/Wrap.c133
-rw-r--r--nx-X11/lib/Xdmcp/Wrap.h19
-rw-r--r--nx-X11/lib/Xdmcp/Wraphelp.README.crypto64
-rw-r--r--nx-X11/lib/Xdmcp/Wraphelp.c500
-rw-r--r--nx-X11/lib/Xdmcp/Xdmcp.h190
-rw-r--r--nx-X11/lib/Xevie/AUTHORS1
-rw-r--r--nx-X11/lib/Xevie/Imakefile76
-rw-r--r--nx-X11/lib/Xevie/Xevie.c211
-rw-r--r--nx-X11/lib/Xevie/Xevie.man88
-rw-r--r--nx-X11/lib/Xevie/xevie.pc.in12
-rw-r--r--nx-X11/lib/Xevie/xevieplaceholder.h0
-rw-r--r--nx-X11/lib/Xext/DPMS.c293
-rw-r--r--nx-X11/lib/Xext/Imakefile46
-rw-r--r--nx-X11/lib/Xext/MITMisc.c133
-rw-r--r--nx-X11/lib/Xext/XAppgroup.c391
-rw-r--r--nx-X11/lib/Xext/XEVI.c213
-rw-r--r--nx-X11/lib/Xext/XLbx.c129
-rw-r--r--nx-X11/lib/Xext/XMultibuf.c714
-rw-r--r--nx-X11/lib/Xext/XSecurity.c310
-rw-r--r--nx-X11/lib/Xext/XShape.c490
-rw-r--r--nx-X11/lib/Xext/XShm.c437
-rw-r--r--nx-X11/lib/Xext/XSync.c817
-rw-r--r--nx-X11/lib/Xext/XTestExt1.c1321
-rw-r--r--nx-X11/lib/Xext/Xcup.c265
-rw-r--r--nx-X11/lib/Xext/Xdbe.c474
-rw-r--r--nx-X11/lib/Xext/Xext-def.cpp140
-rw-r--r--nx-X11/lib/Xext/extutil.c273
-rw-r--r--nx-X11/lib/Xext/globals.c90
-rw-r--r--nx-X11/lib/Xfixes/.cvsignore25
-rw-r--r--nx-X11/lib/Xfixes/AUTHORS1
-rw-r--r--nx-X11/lib/Xfixes/COPYING22
-rw-r--r--nx-X11/lib/Xfixes/ChangeLog102
-rw-r--r--nx-X11/lib/Xfixes/Cursor.c220
-rw-r--r--nx-X11/lib/Xfixes/INSTALL8
-rw-r--r--nx-X11/lib/Xfixes/Imakefile75
-rw-r--r--nx-X11/lib/Xfixes/Makefile.am56
-rw-r--r--nx-X11/lib/Xfixes/NEWS0
-rw-r--r--nx-X11/lib/Xfixes/README10
-rw-r--r--nx-X11/lib/Xfixes/Region.c441
-rw-r--r--nx-X11/lib/Xfixes/SaveSet.c48
-rw-r--r--nx-X11/lib/Xfixes/Selection.c50
-rw-r--r--nx-X11/lib/Xfixes/Xfixes-def.cpp10
-rw-r--r--nx-X11/lib/Xfixes/Xfixes.c333
-rw-r--r--nx-X11/lib/Xfixes/Xfixes.h220
-rw-r--r--nx-X11/lib/Xfixes/Xfixes.man76
-rw-r--r--nx-X11/lib/Xfixes/Xfixesint.h68
-rwxr-xr-xnx-X11/lib/Xfixes/autogen.sh3
-rw-r--r--nx-X11/lib/Xfixes/configure.ac99
-rw-r--r--nx-X11/lib/Xfixes/xfixes.pc.in10
-rw-r--r--nx-X11/lib/Xfontcache/FontCache.c209
-rw-r--r--nx-X11/lib/Xfontcache/Imakefile42
-rw-r--r--nx-X11/lib/Xfontcache/Xfontcache-def.cpp9
-rw-r--r--nx-X11/lib/Xfontcache/Xfontcache.man137
-rw-r--r--nx-X11/lib/Xft/AUTHORS10
-rw-r--r--nx-X11/lib/Xft/COPYING22
-rw-r--r--nx-X11/lib/Xft/ChangeLog1216
-rw-r--r--nx-X11/lib/Xft/INSTALL8
-rw-r--r--nx-X11/lib/Xft/Imakefile145
-rw-r--r--nx-X11/lib/Xft/Makefile.am64
-rw-r--r--nx-X11/lib/Xft/Makefile.in780
-rw-r--r--nx-X11/lib/Xft/NEWS0
-rw-r--r--nx-X11/lib/Xft/README65
-rw-r--r--nx-X11/lib/Xft/Xft-def.cpp183
-rw-r--r--nx-X11/lib/Xft/Xft.3.in847
-rw-r--r--nx-X11/lib/Xft/Xft.h642
-rw-r--r--nx-X11/lib/Xft/XftCompat.h165
-rw-r--r--nx-X11/lib/Xft/aclocal.m46858
-rwxr-xr-xnx-X11/lib/Xft/autogen.sh12
-rwxr-xr-xnx-X11/lib/Xft/config.guess1388
-rw-r--r--nx-X11/lib/Xft/config.h.in76
-rwxr-xr-xnx-X11/lib/Xft/config.sub1489
-rw-r--r--nx-X11/lib/Xft/config/config-subst10
-rwxr-xr-xnx-X11/lib/Xft/configure21551
-rw-r--r--nx-X11/lib/Xft/configure.ac133
-rwxr-xr-xnx-X11/lib/Xft/depcomp479
-rwxr-xr-xnx-X11/lib/Xft/install-sh294
-rw-r--r--nx-X11/lib/Xft/ltmain.sh6290
-rwxr-xr-xnx-X11/lib/Xft/missing336
-rwxr-xr-xnx-X11/lib/Xft/mkinstalldirs111
-rw-r--r--nx-X11/lib/Xft/xft-config.1.in120
-rw-r--r--nx-X11/lib/Xft/xft-config.in100
-rw-r--r--nx-X11/lib/Xft/xft.pc.in12
-rw-r--r--nx-X11/lib/Xft/xftcolor.c125
-rw-r--r--nx-X11/lib/Xft/xftcore.c1375
-rw-r--r--nx-X11/lib/Xft/xftdbg.c48
-rw-r--r--nx-X11/lib/Xft/xftdpy.c554
-rw-r--r--nx-X11/lib/Xft/xftdraw.c993
-rw-r--r--nx-X11/lib/Xft/xftextent.c287
-rw-r--r--nx-X11/lib/Xft/xftfont.c208
-rw-r--r--nx-X11/lib/Xft/xftfreetype.c1156
-rw-r--r--nx-X11/lib/Xft/xftglyphs.c825
-rw-r--r--nx-X11/lib/Xft/xftinit.c115
-rw-r--r--nx-X11/lib/Xft/xftint.h459
-rw-r--r--nx-X11/lib/Xft/xftlist.c60
-rw-r--r--nx-X11/lib/Xft/xftname.c83
-rw-r--r--nx-X11/lib/Xft/xftrender.c1009
-rw-r--r--nx-X11/lib/Xft/xftstr.c37
-rw-r--r--nx-X11/lib/Xft/xftswap.c121
-rw-r--r--nx-X11/lib/Xft/xftxlfd.c177
-rw-r--r--nx-X11/lib/Xft1/Imakefile150
-rw-r--r--nx-X11/lib/Xft1/Xft-def.cpp171
-rw-r--r--nx-X11/lib/Xft1/Xft.h486
-rw-r--r--nx-X11/lib/Xft1/Xft.man180
-rw-r--r--nx-X11/lib/Xft1/XftConfig-OBSOLETE2
-rw-r--r--nx-X11/lib/Xft1/XftFreetype.h167
-rw-r--r--nx-X11/lib/Xft1/xftcache.c608
-rw-r--r--nx-X11/lib/Xft1/xftcfg.c36
-rw-r--r--nx-X11/lib/Xft1/xftcolor.c125
-rw-r--r--nx-X11/lib/Xft1/xftcore.c247
-rw-r--r--nx-X11/lib/Xft1/xftdbg.c43
-rw-r--r--nx-X11/lib/Xft1/xftdir.c42
-rw-r--r--nx-X11/lib/Xft1/xftdpy.c436
-rw-r--r--nx-X11/lib/Xft1/xftdraw.c482
-rw-r--r--nx-X11/lib/Xft1/xftextent.c190
-rw-r--r--nx-X11/lib/Xft1/xftfont.c327
-rw-r--r--nx-X11/lib/Xft1/xftfreetype.c678
-rw-r--r--nx-X11/lib/Xft1/xftfs.c44
-rw-r--r--nx-X11/lib/Xft1/xftglyphs.c491
-rw-r--r--nx-X11/lib/Xft1/xftgram.y452
-rw-r--r--nx-X11/lib/Xft1/xftinit.c42
-rw-r--r--nx-X11/lib/Xft1/xftint.h508
-rw-r--r--nx-X11/lib/Xft1/xftlex.l275
-rw-r--r--nx-X11/lib/Xft1/xftlist.c166
-rw-r--r--nx-X11/lib/Xft1/xftmatch.c37
-rw-r--r--nx-X11/lib/Xft1/xftmatrix.c104
-rw-r--r--nx-X11/lib/Xft1/xftname.c59
-rw-r--r--nx-X11/lib/Xft1/xftpat.c243
-rw-r--r--nx-X11/lib/Xft1/xftrender.c527
-rw-r--r--nx-X11/lib/Xft1/xftstr.c259
-rw-r--r--nx-X11/lib/Xft1/xftxlfd.c334
-rw-r--r--nx-X11/lib/Xi/Imakefile107
-rw-r--r--nx-X11/lib/Xi/XAllowDv.c88
-rw-r--r--nx-X11/lib/Xi/XChgDCtl.c130
-rw-r--r--nx-X11/lib/Xi/XChgFCtl.c207
-rw-r--r--nx-X11/lib/Xi/XChgKMap.c94
-rw-r--r--nx-X11/lib/Xi/XChgKbd.c88
-rw-r--r--nx-X11/lib/Xi/XChgPnt.c92
-rw-r--r--nx-X11/lib/Xi/XChgProp.c98
-rw-r--r--nx-X11/lib/Xi/XCloseDev.c85
-rw-r--r--nx-X11/lib/Xi/XDevBell.c89
-rw-r--r--nx-X11/lib/Xi/XExtInt.c663
-rw-r--r--nx-X11/lib/Xi/XExtToWire.c452
-rw-r--r--nx-X11/lib/Xi/XFreeLst.c73
-rw-r--r--nx-X11/lib/Xi/XGMotion.c142
-rw-r--r--nx-X11/lib/Xi/XGetBMap.c108
-rw-r--r--nx-X11/lib/Xi/XGetDCtl.c173
-rw-r--r--nx-X11/lib/Xi/XGetFCtl.c273
-rw-r--r--nx-X11/lib/Xi/XGetKMap.c111
-rw-r--r--nx-X11/lib/Xi/XGetMMap.c104
-rw-r--r--nx-X11/lib/Xi/XGetProp.c120
-rw-r--r--nx-X11/lib/Xi/XGetVers.c115
-rw-r--r--nx-X11/lib/Xi/XGrDvBut.c114
-rw-r--r--nx-X11/lib/Xi/XGrDvKey.c117
-rw-r--r--nx-X11/lib/Xi/XGrabDev.c109
-rw-r--r--nx-X11/lib/Xi/XGtFocus.c92
-rw-r--r--nx-X11/lib/Xi/XGtSelect.c146
-rw-r--r--nx-X11/lib/Xi/XIint.h25
-rw-r--r--nx-X11/lib/Xi/XListDev.c259
-rw-r--r--nx-X11/lib/Xi/XOpenDev.c113
-rw-r--r--nx-X11/lib/Xi/XQueryDv.c198
-rw-r--r--nx-X11/lib/Xi/XSelect.c94
-rw-r--r--nx-X11/lib/Xi/XSetBMap.c93
-rw-r--r--nx-X11/lib/Xi/XSetDVal.c100
-rw-r--r--nx-X11/lib/Xi/XSetMMap.c91
-rw-r--r--nx-X11/lib/Xi/XSetMode.c88
-rw-r--r--nx-X11/lib/Xi/XSndExEv.c123
-rw-r--r--nx-X11/lib/Xi/XStFocus.c87
-rw-r--r--nx-X11/lib/Xi/XUngrDev.c86
-rw-r--r--nx-X11/lib/Xi/XUngrDvB.c93
-rw-r--r--nx-X11/lib/Xi/XUngrDvK.c93
-rw-r--r--nx-X11/lib/Xi/Xi-def.cpp49
-rw-r--r--nx-X11/lib/Xinerama/Imakefile30
-rw-r--r--nx-X11/lib/Xinerama/Xinerama-def.cpp14
-rw-r--r--nx-X11/lib/Xinerama/Xinerama.c319
-rw-r--r--nx-X11/lib/Xmu/AllCmap.c158
-rw-r--r--nx-X11/lib/Xmu/Atoms.c154
-rw-r--r--nx-X11/lib/Xmu/Atoms.h126
-rw-r--r--nx-X11/lib/Xmu/CharSet.h77
-rw-r--r--nx-X11/lib/Xmu/ClientWin.c100
-rw-r--r--nx-X11/lib/Xmu/Clip.c1617
-rw-r--r--nx-X11/lib/Xmu/CloseHook.c297
-rw-r--r--nx-X11/lib/Xmu/CloseHook.h73
-rw-r--r--nx-X11/lib/Xmu/CmapAlloc.c346
-rw-r--r--nx-X11/lib/Xmu/Converters.h281
-rw-r--r--nx-X11/lib/Xmu/CrCmap.c537
-rw-r--r--nx-X11/lib/Xmu/CrPixFBit.c85
-rw-r--r--nx-X11/lib/Xmu/CurUtil.h49
-rw-r--r--nx-X11/lib/Xmu/CursorName.c141
-rw-r--r--nx-X11/lib/Xmu/CvtCache.c136
-rw-r--r--nx-X11/lib/Xmu/CvtCache.h62
-rw-r--r--nx-X11/lib/Xmu/CvtStdSel.c347
-rw-r--r--nx-X11/lib/Xmu/DefErrMsg.c173
-rw-r--r--nx-X11/lib/Xmu/DelCmap.c73
-rw-r--r--nx-X11/lib/Xmu/DisplayQue.c194
-rw-r--r--nx-X11/lib/Xmu/DisplayQue.h155
-rw-r--r--nx-X11/lib/Xmu/Distinct.c92
-rw-r--r--nx-X11/lib/Xmu/DrRndRect.c182
-rw-r--r--nx-X11/lib/Xmu/DrawLogo.c155
-rw-r--r--nx-X11/lib/Xmu/Drawing.h161
-rw-r--r--nx-X11/lib/Xmu/Editres.h42
-rw-r--r--nx-X11/lib/Xmu/EditresCom.c2214
-rw-r--r--nx-X11/lib/Xmu/EditresP.h409
-rw-r--r--nx-X11/lib/Xmu/Error.h59
-rw-r--r--nx-X11/lib/Xmu/ExtAgent.c46
-rw-r--r--nx-X11/lib/Xmu/ExtAgent.h44
-rw-r--r--nx-X11/lib/Xmu/FToCback.c48
-rw-r--r--nx-X11/lib/Xmu/GetHost.c86
-rw-r--r--nx-X11/lib/Xmu/GrayPixmap.c139
-rw-r--r--nx-X11/lib/Xmu/Imakefile176
-rw-r--r--nx-X11/lib/Xmu/Initer.c117
-rw-r--r--nx-X11/lib/Xmu/Initer.h58
-rw-r--r--nx-X11/lib/Xmu/LocBitmap.c272
-rw-r--r--nx-X11/lib/Xmu/Lookup.c279
-rw-r--r--nx-X11/lib/Xmu/Lookup.h128
-rw-r--r--nx-X11/lib/Xmu/LookupCmap.c325
-rw-r--r--nx-X11/lib/Xmu/Lower.c164
-rw-r--r--nx-X11/lib/Xmu/Misc.h65
-rw-r--r--nx-X11/lib/Xmu/README8
-rw-r--r--nx-X11/lib/Xmu/RdBitF.c401
-rw-r--r--nx-X11/lib/Xmu/ScrOfWin.c60
-rw-r--r--nx-X11/lib/Xmu/ShapeWidg.c251
-rw-r--r--nx-X11/lib/Xmu/StdCmap.c236
-rw-r--r--nx-X11/lib/Xmu/StdCmap.h119
-rw-r--r--nx-X11/lib/Xmu/StdSel.h57
-rw-r--r--nx-X11/lib/Xmu/StrToBS.c149
-rw-r--r--nx-X11/lib/Xmu/StrToBmap.c150
-rw-r--r--nx-X11/lib/Xmu/StrToCurs.c351
-rw-r--r--nx-X11/lib/Xmu/StrToGrav.c151
-rw-r--r--nx-X11/lib/Xmu/StrToJust.c140
-rw-r--r--nx-X11/lib/Xmu/StrToLong.c83
-rw-r--r--nx-X11/lib/Xmu/StrToOrnt.c130
-rw-r--r--nx-X11/lib/Xmu/StrToShap.c125
-rw-r--r--nx-X11/lib/Xmu/StrToWidg.c225
-rw-r--r--nx-X11/lib/Xmu/SysUtil.h60
-rw-r--r--nx-X11/lib/Xmu/UpdMapHint.c62
-rw-r--r--nx-X11/lib/Xmu/VisCmap.c183
-rw-r--r--nx-X11/lib/Xmu/WhitePoint.h65
-rw-r--r--nx-X11/lib/Xmu/WidgetNode.c310
-rw-r--r--nx-X11/lib/Xmu/WidgetNode.h98
-rw-r--r--nx-X11/lib/Xmu/WinUtil.h64
-rw-r--r--nx-X11/lib/Xmu/Xct.c687
-rw-r--r--nx-X11/lib/Xmu/Xct.h168
-rw-r--r--nx-X11/lib/Xmu/Xmu-def.cpp145
-rw-r--r--nx-X11/lib/Xmu/Xmu.h128
-rw-r--r--nx-X11/lib/Xmu/sharedlib.c76
-rw-r--r--nx-X11/lib/Xmuu/Imakefile67
-rw-r--r--nx-X11/lib/Xmuu/Xmuu-def.cpp22
-rw-r--r--nx-X11/lib/Xp/Imakefile107
-rw-r--r--nx-X11/lib/Xp/Xp-def.cpp42
-rw-r--r--nx-X11/lib/Xp/XpAttr.c208
-rw-r--r--nx-X11/lib/Xp/XpContext.c250
-rw-r--r--nx-X11/lib/Xp/XpDoc.c159
-rw-r--r--nx-X11/lib/Xp/XpExtUtil.c355
-rw-r--r--nx-X11/lib/Xp/XpExtUtil.h41
-rw-r--r--nx-X11/lib/Xp/XpExtVer.c125
-rw-r--r--nx-X11/lib/Xp/XpGetData.c215
-rw-r--r--nx-X11/lib/Xp/XpImageRes.c118
-rw-r--r--nx-X11/lib/Xp/XpInput.c107
-rw-r--r--nx-X11/lib/Xp/XpJob.c206
-rw-r--r--nx-X11/lib/Xp/XpLocale.c269
-rw-r--r--nx-X11/lib/Xp/XpNotifyPdm.c900
-rw-r--r--nx-X11/lib/Xp/XpPage.c160
-rw-r--r--nx-X11/lib/Xp/XpPageDim.c89
-rw-r--r--nx-X11/lib/Xp/XpPrinter.c248
-rw-r--r--nx-X11/lib/Xp/XpPutData.c100
-rw-r--r--nx-X11/lib/Xp/XpScreens.c128
-rw-r--r--nx-X11/lib/Xpm/Imakefile126
-rw-r--r--nx-X11/lib/Xpm/Imakefile.NX.original126
-rw-r--r--nx-X11/lib/Xpm/Imakefile.X.original122
-rw-r--r--nx-X11/lib/Xpm/Xpm-def.cpp39
-rw-r--r--nx-X11/lib/XprintAppUtil/Imakefile21
-rw-r--r--nx-X11/lib/XprintAppUtil/xpapputil.c550
-rw-r--r--nx-X11/lib/XprintAppUtil/xpapputil.h175
-rw-r--r--nx-X11/lib/XprintUtil/Imakefile21
-rw-r--r--nx-X11/lib/XprintUtil/xprintutil.c2111
-rw-r--r--nx-X11/lib/XprintUtil/xprintutil.h250
-rw-r--r--nx-X11/lib/XprintUtil/xprintutil_printtofile.c498
-rw-r--r--nx-X11/lib/Xrandr/Imakefile42
-rw-r--r--nx-X11/lib/Xrandr/Xrandr-def.cpp36
-rw-r--r--nx-X11/lib/Xrandr/Xrandr.c744
-rw-r--r--nx-X11/lib/Xrandr/Xrandr.h151
-rw-r--r--nx-X11/lib/Xrandr/Xrandr.man351
-rw-r--r--nx-X11/lib/Xrandr/Xrandrint.h87
-rw-r--r--nx-X11/lib/Xrandr/test.c21
-rw-r--r--nx-X11/lib/Xrender/AUTHORS3
-rw-r--r--nx-X11/lib/Xrender/AddTrap.c70
-rw-r--r--nx-X11/lib/Xrender/COPYING22
-rw-r--r--nx-X11/lib/Xrender/ChangeLog456
-rw-r--r--nx-X11/lib/Xrender/Color.c92
-rw-r--r--nx-X11/lib/Xrender/Composite.c67
-rw-r--r--nx-X11/lib/Xrender/Cursor.c79
-rw-r--r--nx-X11/lib/Xrender/FillRect.c106
-rw-r--r--nx-X11/lib/Xrender/FillRects.c79
-rw-r--r--nx-X11/lib/Xrender/Filter.c152
-rw-r--r--nx-X11/lib/Xrender/Glyph.c1169
-rw-r--r--nx-X11/lib/Xrender/Glyph.c.NX.original1169
-rw-r--r--nx-X11/lib/Xrender/Glyph.c.X.original712
-rw-r--r--nx-X11/lib/Xrender/INSTALL8
-rw-r--r--nx-X11/lib/Xrender/Imakefile167
-rw-r--r--nx-X11/lib/Xrender/NEWS0
-rw-r--r--nx-X11/lib/Xrender/Picture.c366
-rw-r--r--nx-X11/lib/Xrender/Poly.c302
-rw-r--r--nx-X11/lib/Xrender/README0
-rw-r--r--nx-X11/lib/Xrender/Trap.c74
-rw-r--r--nx-X11/lib/Xrender/Tri.c169
-rw-r--r--nx-X11/lib/Xrender/Xrender-def.cpp44
-rw-r--r--nx-X11/lib/Xrender/Xrender.c889
-rw-r--r--nx-X11/lib/Xrender/Xrender.h544
-rw-r--r--nx-X11/lib/Xrender/Xrender.h.NX.original544
-rw-r--r--nx-X11/lib/Xrender/Xrender.h.X.original528
-rw-r--r--nx-X11/lib/Xrender/Xrenderint.h114
-rwxr-xr-xnx-X11/lib/Xrender/autogen.sh3
-rw-r--r--nx-X11/lib/Xrender/config.h0
-rw-r--r--nx-X11/lib/Xrender/configure.ac113
-rw-r--r--nx-X11/lib/Xrender/xrender.pc.in11
-rw-r--r--nx-X11/lib/Xss/Imakefile47
-rw-r--r--nx-X11/lib/Xss/XScrnSaver.c442
-rw-r--r--nx-X11/lib/Xss/Xss-def.cpp14
-rw-r--r--nx-X11/lib/Xss/Xss.man328
-rw-r--r--nx-X11/lib/Xt/ActionHook.c135
-rw-r--r--nx-X11/lib/Xt/Alloc.c494
-rw-r--r--nx-X11/lib/Xt/ArgList.c77
-rw-r--r--nx-X11/lib/Xt/Callback.c692
-rw-r--r--nx-X11/lib/Xt/CallbackI.h117
-rw-r--r--nx-X11/lib/Xt/ClickTime.c93
-rw-r--r--nx-X11/lib/Xt/Composite.c284
-rw-r--r--nx-X11/lib/Xt/Composite.h105
-rw-r--r--nx-X11/lib/Xt/CompositeP.h111
-rw-r--r--nx-X11/lib/Xt/ConstrainP.h94
-rw-r--r--nx-X11/lib/Xt/Constraint.c134
-rw-r--r--nx-X11/lib/Xt/Constraint.h60
-rw-r--r--nx-X11/lib/Xt/Convert.c1087
-rw-r--r--nx-X11/lib/Xt/ConvertI.h96
-rw-r--r--nx-X11/lib/Xt/Converters.c1864
-rw-r--r--nx-X11/lib/Xt/Core.c400
-rw-r--r--nx-X11/lib/Xt/Core.h66
-rw-r--r--nx-X11/lib/Xt/CoreP.h171
-rw-r--r--nx-X11/lib/Xt/Create.c779
-rw-r--r--nx-X11/lib/Xt/CreateI.h37
-rw-r--r--nx-X11/lib/Xt/Destroy.c374
-rw-r--r--nx-X11/lib/Xt/Display.c763
-rw-r--r--nx-X11/lib/Xt/Error.c636
-rw-r--r--nx-X11/lib/Xt/Event.c1731
-rw-r--r--nx-X11/lib/Xt/EventI.h134
-rw-r--r--nx-X11/lib/Xt/EventUtil.c221
-rw-r--r--nx-X11/lib/Xt/Functions.c216
-rw-r--r--nx-X11/lib/Xt/GCManager.c353
-rw-r--r--nx-X11/lib/Xt/Geometry.c817
-rw-r--r--nx-X11/lib/Xt/GetActKey.c102
-rw-r--r--nx-X11/lib/Xt/GetResList.c193
-rw-r--r--nx-X11/lib/Xt/GetValues.c251
-rw-r--r--nx-X11/lib/Xt/HookObj.c137
-rw-r--r--nx-X11/lib/Xt/HookObjI.h71
-rw-r--r--nx-X11/lib/Xt/Hooks.c158
-rw-r--r--nx-X11/lib/Xt/Imakefile307
-rw-r--r--nx-X11/lib/Xt/Imakefile.NX.original307
-rw-r--r--nx-X11/lib/Xt/Imakefile.X.original271
-rw-r--r--nx-X11/lib/Xt/InitialI.h429
-rw-r--r--nx-X11/lib/Xt/Initialize.c1044
-rw-r--r--nx-X11/lib/Xt/Intrinsic.c1593
-rw-r--r--nx-X11/lib/Xt/Intrinsic.h2589
-rw-r--r--nx-X11/lib/Xt/IntrinsicI.h261
-rw-r--r--nx-X11/lib/Xt/IntrinsicP.h327
-rw-r--r--nx-X11/lib/Xt/Keyboard.c851
-rw-r--r--nx-X11/lib/Xt/Manage.c491
-rw-r--r--nx-X11/lib/Xt/NextEvent.c1642
-rw-r--r--nx-X11/lib/Xt/NextEvent.c.NX.original1642
-rw-r--r--nx-X11/lib/Xt/NextEvent.c.X.original1616
-rw-r--r--nx-X11/lib/Xt/Object.c297
-rw-r--r--nx-X11/lib/Xt/Object.h60
-rw-r--r--nx-X11/lib/Xt/ObjectP.h139
-rw-r--r--nx-X11/lib/Xt/PassivGraI.h186
-rw-r--r--nx-X11/lib/Xt/PassivGrab.c1053
-rw-r--r--nx-X11/lib/Xt/Pointer.c115
-rw-r--r--nx-X11/lib/Xt/Popup.c198
-rw-r--r--nx-X11/lib/Xt/PopupCB.c84
-rw-r--r--nx-X11/lib/Xt/RectObj.c194
-rw-r--r--nx-X11/lib/Xt/RectObj.h60
-rw-r--r--nx-X11/lib/Xt/RectObjP.h129
-rw-r--r--nx-X11/lib/Xt/ResConfig.c1022
-rw-r--r--nx-X11/lib/Xt/ResConfigP.h78
-rw-r--r--nx-X11/lib/Xt/ResourceI.h100
-rw-r--r--nx-X11/lib/Xt/Resources.c1259
-rw-r--r--nx-X11/lib/Xt/Selection.c2295
-rw-r--r--nx-X11/lib/Xt/SelectionI.h170
-rw-r--r--nx-X11/lib/Xt/SetSens.c128
-rw-r--r--nx-X11/lib/Xt/SetValues.c443
-rw-r--r--nx-X11/lib/Xt/SetWMCW.c173
-rw-r--r--nx-X11/lib/Xt/Shell.c3414
-rw-r--r--nx-X11/lib/Xt/ShellI.h12
-rw-r--r--nx-X11/lib/Xt/ShellP.h428
-rw-r--r--nx-X11/lib/Xt/TMaction.c1056
-rw-r--r--nx-X11/lib/Xt/TMgrab.c336
-rw-r--r--nx-X11/lib/Xt/TMkey.c715
-rw-r--r--nx-X11/lib/Xt/TMparse.c2135
-rw-r--r--nx-X11/lib/Xt/TMprint.c881
-rw-r--r--nx-X11/lib/Xt/TMstate.c2349
-rw-r--r--nx-X11/lib/Xt/Threads.c428
-rw-r--r--nx-X11/lib/Xt/ThreadsI.h130
-rw-r--r--nx-X11/lib/Xt/TranslateI.h606
-rw-r--r--nx-X11/lib/Xt/VarCreate.c399
-rw-r--r--nx-X11/lib/Xt/VarGet.c317
-rw-r--r--nx-X11/lib/Xt/Varargs.c519
-rw-r--r--nx-X11/lib/Xt/VarargsI.h65
-rw-r--r--nx-X11/lib/Xt/Vendor.c159
-rw-r--r--nx-X11/lib/Xt/Vendor.h71
-rw-r--r--nx-X11/lib/Xt/VendorP.h103
-rw-r--r--nx-X11/lib/Xt/Xt-def.cpp352
-rw-r--r--nx-X11/lib/Xt/Xtos.h77
-rw-r--r--nx-X11/lib/Xt/jump_funcs756
-rw-r--r--nx-X11/lib/Xt/jump_ignore15
-rw-r--r--nx-X11/lib/Xt/jump_vars71
-rw-r--r--nx-X11/lib/Xt/libXt.elist42
-rw-r--r--nx-X11/lib/Xt/sharedlib.c236
-rw-r--r--nx-X11/lib/Xt/util/Shell.ht97
-rw-r--r--nx-X11/lib/Xt/util/StrDefs.ct54
-rw-r--r--nx-X11/lib/Xt/util/StrDefs.ht64
-rw-r--r--nx-X11/lib/Xt/util/string.list399
-rw-r--r--nx-X11/lib/Xtst/Imakefile32
-rw-r--r--nx-X11/lib/Xtst/XRecord.c1103
-rw-r--r--nx-X11/lib/Xtst/XTest.c498
-rw-r--r--nx-X11/lib/Xtst/Xtst-def.cpp32
-rw-r--r--nx-X11/lib/Xv/Imakefile30
-rw-r--r--nx-X11/lib/Xv/Xv-def.cpp27
-rw-r--r--nx-X11/lib/Xv/Xv.c1155
-rw-r--r--nx-X11/lib/Xv/Xvlibint.h76
-rw-r--r--nx-X11/lib/XvMC/Imakefile49
-rw-r--r--nx-X11/lib/XvMC/XvMC-def.cpp8
-rw-r--r--nx-X11/lib/XvMC/XvMC.c599
-rw-r--r--nx-X11/lib/XvMC/XvMClibint.h40
-rw-r--r--nx-X11/lib/XvMC/hw/i810/I810XvMC.c4507
-rw-r--r--nx-X11/lib/XvMC/hw/i810/I810XvMC.h469
-rw-r--r--nx-X11/lib/XvMC/hw/i810/Imakefile44
-rw-r--r--nx-X11/lib/XvMC/hw/via/driDrawable.c176
-rw-r--r--nx-X11/lib/XvMC/hw/via/driDrawable.h64
-rw-r--r--nx-X11/lib/XvMC/hw/via/unichrome/Imakefile51
-rw-r--r--nx-X11/lib/XvMC/hw/via/unichrome/viaLowLevel.c1056
-rw-r--r--nx-X11/lib/XvMC/hw/via/unichromeProA/Imakefile50
-rw-r--r--nx-X11/lib/XvMC/hw/via/unichromeProA/viaLowLevelPro.c1465
-rw-r--r--nx-X11/lib/XvMC/hw/via/viaLowLevel.h148
-rw-r--r--nx-X11/lib/XvMC/hw/via/viaXvMC.c1964
-rw-r--r--nx-X11/lib/XvMC/hw/via/viaXvMCPriv.h198
-rw-r--r--nx-X11/lib/XvMC/hw/via/xf86dri.c592
-rw-r--r--nx-X11/lib/XvMC/hw/via/xf86dri.h121
-rw-r--r--nx-X11/lib/XvMC/hw/via/xf86dristr.h343
-rw-r--r--nx-X11/lib/XvMC/wrapper/Imakefile34
-rw-r--r--nx-X11/lib/XvMC/wrapper/XvMCWrapper.c779
-rw-r--r--nx-X11/lib/Xxf86dga/Imakefile63
-rw-r--r--nx-X11/lib/Xxf86dga/XDGA.man673
-rw-r--r--nx-X11/lib/Xxf86dga/XF86DGA.c722
-rw-r--r--nx-X11/lib/Xxf86dga/XF86DGA2.c968
-rw-r--r--nx-X11/lib/Xxf86dga/Xxf86dga-def.cpp16
-rw-r--r--nx-X11/lib/Xxf86misc/Imakefile40
-rw-r--r--nx-X11/lib/Xxf86misc/XF86Misc.c406
-rw-r--r--nx-X11/lib/Xxf86misc/XF86Misc.man217
-rw-r--r--nx-X11/lib/Xxf86misc/Xxf86misc-def.cpp14
-rw-r--r--nx-X11/lib/Xxf86rush/Imakefile30
-rw-r--r--nx-X11/lib/Xxf86rush/XF86Rush.c291
-rw-r--r--nx-X11/lib/Xxf86vm/Imakefile40
-rw-r--r--nx-X11/lib/Xxf86vm/XF86VM.man425
-rw-r--r--nx-X11/lib/Xxf86vm/XF86VMode.c1233
-rw-r--r--nx-X11/lib/Xxf86vm/Xxf86vm-def.cpp16
-rw-r--r--nx-X11/lib/apple/AppleWM.man340
-rw-r--r--nx-X11/lib/apple/Imakefile37
-rw-r--r--nx-X11/lib/apple/applewm.c530
-rw-r--r--nx-X11/lib/apple/applewm.h190
-rw-r--r--nx-X11/lib/apple/applewmstr.h226
-rw-r--r--nx-X11/lib/dmx/Imakefile26
-rw-r--r--nx-X11/lib/dmx/dmx.c802
-rw-r--r--nx-X11/lib/dps/DPSCAP.h77
-rw-r--r--nx-X11/lib/dps/DPSCAPClient.h139
-rw-r--r--nx-X11/lib/dps/DPSCAPproto.h180
-rw-r--r--nx-X11/lib/dps/Imakefile265
-rw-r--r--nx-X11/lib/dps/XDPS.c2235
-rw-r--r--nx-X11/lib/dps/Xlibnet.h284
-rw-r--r--nx-X11/lib/dps/Xstreams.h218
-rw-r--r--nx-X11/lib/dps/csconndi.c839
-rw-r--r--nx-X11/lib/dps/csfindNX.c657
-rw-r--r--nx-X11/lib/dps/csfindNX.h93
-rw-r--r--nx-X11/lib/dps/cslibext.c762
-rw-r--r--nx-X11/lib/dps/cslibint.c1910
-rw-r--r--nx-X11/lib/dps/cslibint.h302
-rw-r--r--nx-X11/lib/dps/csopendi.c567
-rw-r--r--nx-X11/lib/dps/csstartNX.c237
-rw-r--r--nx-X11/lib/dps/csstartNX.h67
-rw-r--r--nx-X11/lib/dps/dps-def.cpp991
-rw-r--r--nx-X11/lib/dps/dpsNXprops.h90
-rw-r--r--nx-X11/lib/dps/dpsXclient.c1134
-rw-r--r--nx-X11/lib/dps/dpsXcmu.c1602
-rw-r--r--nx-X11/lib/dps/dpsXint.h104
-rw-r--r--nx-X11/lib/dps/dpsXops.psw80
-rw-r--r--nx-X11/lib/dps/dpsXpriv.c534
-rw-r--r--nx-X11/lib/dps/dpsXpriv.h187
-rw-r--r--nx-X11/lib/dps/dpsXtdisp.c109
-rw-r--r--nx-X11/lib/dps/dpsabbrev.c360
-rw-r--r--nx-X11/lib/dps/dpsassert.h57
-rw-r--r--nx-X11/lib/dps/dpsclient.c2969
-rw-r--r--nx-X11/lib/dps/dpsclrops.psw81
-rw-r--r--nx-X11/lib/dps/dpsctrlops.psw114
-rw-r--r--nx-X11/lib/dps/dpsctxtops.psw110
-rw-r--r--nx-X11/lib/dps/dpsdataops.psw258
-rw-r--r--nx-X11/lib/dps/dpsdict.c189
-rw-r--r--nx-X11/lib/dps/dpsdict.h78
-rw-r--r--nx-X11/lib/dps/dpsendif.txt5
-rw-r--r--nx-X11/lib/dps/dpsexcept.c73
-rw-r--r--nx-X11/lib/dps/dpsfontops.psw109
-rw-r--r--nx-X11/lib/dps/dpsgsttops.psw213
-rw-r--r--nx-X11/lib/dps/dpsifdef.txt7
-rw-r--r--nx-X11/lib/dps/dpsint.h125
-rw-r--r--nx-X11/lib/dps/dpsioops.psw153
-rw-r--r--nx-X11/lib/dps/dpsl2ops.psw208
-rw-r--r--nx-X11/lib/dps/dpsmathops.psw125
-rw-r--r--nx-X11/lib/dps/dpsmiscops.psw53
-rw-r--r--nx-X11/lib/dps/dpsmtrxops.psw65
-rw-r--r--nx-X11/lib/dps/dpsname.txt4
-rw-r--r--nx-X11/lib/dps/dpsopstack.psw96
-rw-r--r--nx-X11/lib/dps/dpspathops.psw169
-rw-r--r--nx-X11/lib/dps/dpspntops.psw129
-rw-r--r--nx-X11/lib/dps/dpsprintf.c68
-rw-r--r--nx-X11/lib/dps/dpsprivate.h127
-rw-r--r--nx-X11/lib/dps/dpssimpint.h88
-rw-r--r--nx-X11/lib/dps/dpssysnames.c444
-rw-r--r--nx-X11/lib/dps/dpssysops.psw149
-rw-r--r--nx-X11/lib/dps/dpswinops.psw65
-rw-r--r--nx-X11/lib/dps/else.txt6
-rw-r--r--nx-X11/lib/dps/genheader.cmd14
-rw-r--r--nx-X11/lib/dps/header.txt35
-rw-r--r--nx-X11/lib/dps/psXops.psw81
-rw-r--r--nx-X11/lib/dps/psclrops.psw81
-rw-r--r--nx-X11/lib/dps/psctrlops.psw113
-rw-r--r--nx-X11/lib/dps/psctxtops.psw109
-rw-r--r--nx-X11/lib/dps/psdataops.psw257
-rw-r--r--nx-X11/lib/dps/psendif.txt6
-rw-r--r--nx-X11/lib/dps/psfontops.psw109
-rw-r--r--nx-X11/lib/dps/psgsttops.psw213
-rw-r--r--nx-X11/lib/dps/psifdef.txt7
-rw-r--r--nx-X11/lib/dps/psioops.psw153
-rw-r--r--nx-X11/lib/dps/psl2ops.psw208
-rw-r--r--nx-X11/lib/dps/psmathops.psw125
-rw-r--r--nx-X11/lib/dps/psmiscops.psw53
-rw-r--r--nx-X11/lib/dps/psmtrxops.psw65
-rw-r--r--nx-X11/lib/dps/psname.txt3
-rw-r--r--nx-X11/lib/dps/psopstack.psw96
-rw-r--r--nx-X11/lib/dps/pspathops.psw169
-rw-r--r--nx-X11/lib/dps/pspntops.psw129
-rw-r--r--nx-X11/lib/dps/pssysops.psw150
-rw-r--r--nx-X11/lib/dps/pswinops.psw66
-rw-r--r--nx-X11/lib/dps/publictypes.h71
-rw-r--r--nx-X11/lib/dpstk/CSBwraps.psw343
-rw-r--r--nx-X11/lib/dpstk/ColorSB.c3388
-rw-r--r--nx-X11/lib/dpstk/ColorSelect.ad162
-rw-r--r--nx-X11/lib/dpstk/DPSScrollW.c3500
-rw-r--r--nx-X11/lib/dpstk/DSWwraps.psw75
-rw-r--r--nx-X11/lib/dpstk/FSBwraps.psw491
-rw-r--r--nx-X11/lib/dpstk/FontCreato.c1610
-rw-r--r--nx-X11/lib/dpstk/FontSB.c4884
-rw-r--r--nx-X11/lib/dpstk/FontSBI.h57
-rw-r--r--nx-X11/lib/dpstk/FontSample.c1814
-rw-r--r--nx-X11/lib/dpstk/FontSelect.ad415
-rw-r--r--nx-X11/lib/dpstk/Imakefile91
-rw-r--r--nx-X11/lib/dpstk/XDPSpreview.c636
-rw-r--r--nx-X11/lib/dpstk/XDPSpwraps.psw97
-rw-r--r--nx-X11/lib/dpstk/XDPSshare.c727
-rw-r--r--nx-X11/lib/dpstk/XDPSswraps.psw110
-rw-r--r--nx-X11/lib/dpstk/XDPSuserpath.c240
-rw-r--r--nx-X11/lib/dpstk/dpsXcommonI.h73
-rw-r--r--nx-X11/lib/dpstk/dpstk-def.cpp65
-rw-r--r--nx-X11/lib/dpstk/eyedrop16.xbm8
-rw-r--r--nx-X11/lib/dpstk/eyedrop32.xbm16
-rw-r--r--nx-X11/lib/dpstk/eyedropmask16.xbm8
-rw-r--r--nx-X11/lib/dpstk/eyedropmask32.xbm16
-rw-r--r--nx-X11/lib/dpstk/heyedrop.xbm7
-rw-r--r--nx-X11/lib/dpstk/square.xbm8
-rw-r--r--nx-X11/lib/dpstk/squaremask.xbm6
-rw-r--r--nx-X11/lib/expat/Imakefile53
-rw-r--r--nx-X11/lib/expat/expat-def.cpp73
-rw-r--r--nx-X11/lib/expat/expat_config.h65
-rw-r--r--nx-X11/lib/font/FreeType/Imakefile47
-rw-r--r--nx-X11/lib/font/FreeType/ft.h96
-rw-r--r--nx-X11/lib/font/FreeType/ftenc.c242
-rw-r--r--nx-X11/lib/font/FreeType/ftfuncs.c3851
-rw-r--r--nx-X11/lib/font/FreeType/ftfuncs.h189
-rw-r--r--nx-X11/lib/font/FreeType/ftsystem.c332
-rw-r--r--nx-X11/lib/font/FreeType/fttools.c201
-rw-r--r--nx-X11/lib/font/FreeType/module/Imakefile111
-rw-r--r--nx-X11/lib/font/FreeType/module/ft2build.h45
-rw-r--r--nx-X11/lib/font/FreeType/module/ftheader.h550
-rw-r--r--nx-X11/lib/font/FreeType/module/ftmodule.c76
-rw-r--r--nx-X11/lib/font/FreeType/module/ftmodule.h21
-rw-r--r--nx-X11/lib/font/FreeType/module/ftoption.h567
-rw-r--r--nx-X11/lib/font/FreeType/module/ftstdlib.h113
-rw-r--r--nx-X11/lib/font/FreeType/module/fttypes.h571
-rw-r--r--nx-X11/lib/font/FreeType/module/myftstdlib.h82
-rw-r--r--nx-X11/lib/font/FreeType/xttcap.c809
-rw-r--r--nx-X11/lib/font/FreeType/xttcap.h140
-rw-r--r--nx-X11/lib/font/Imakefile178
-rw-r--r--nx-X11/lib/font/Speedo/Imakefile46
-rw-r--r--nx-X11/lib/font/Speedo/adobe-iso.h200
-rw-r--r--nx-X11/lib/font/Speedo/bics-iso.h224
-rw-r--r--nx-X11/lib/font/Speedo/bics-unicode.c138
-rw-r--r--nx-X11/lib/font/Speedo/bics-unicode.h3
-rw-r--r--nx-X11/lib/font/Speedo/do_char.c1016
-rw-r--r--nx-X11/lib/font/Speedo/do_trns.c512
-rw-r--r--nx-X11/lib/font/Speedo/htest.c361
-rw-r--r--nx-X11/lib/font/Speedo/iface.c650
-rw-r--r--nx-X11/lib/font/Speedo/keys.h56
-rw-r--r--nx-X11/lib/font/Speedo/module/Imakefile47
-rw-r--r--nx-X11/lib/font/Speedo/module/speedomod.c72
-rw-r--r--nx-X11/lib/font/Speedo/nsample.c745
-rw-r--r--nx-X11/lib/font/Speedo/out_bl2d.c772
-rw-r--r--nx-X11/lib/font/Speedo/out_blk.c706
-rw-r--r--nx-X11/lib/font/Speedo/out_outl.c290
-rw-r--r--nx-X11/lib/font/Speedo/out_scrn.c1090
-rw-r--r--nx-X11/lib/font/Speedo/out_util.c341
-rw-r--r--nx-X11/lib/font/Speedo/reset.c131
-rw-r--r--nx-X11/lib/font/Speedo/set_spcs.c773
-rw-r--r--nx-X11/lib/font/Speedo/set_trns.c1324
-rw-r--r--nx-X11/lib/font/Speedo/spdo_prv.h421
-rw-r--r--nx-X11/lib/font/Speedo/speedo.h890
-rw-r--r--nx-X11/lib/font/Speedo/spencode.c67
-rw-r--r--nx-X11/lib/font/Speedo/sperr.c127
-rw-r--r--nx-X11/lib/font/Speedo/spfile.c460
-rw-r--r--nx-X11/lib/font/Speedo/spfont.c453
-rw-r--r--nx-X11/lib/font/Speedo/spfuncs.c167
-rw-r--r--nx-X11/lib/font/Speedo/spglyph.c399
-rw-r--r--nx-X11/lib/font/Speedo/spinfo.c462
-rw-r--r--nx-X11/lib/font/Speedo/spint.h180
-rw-r--r--nx-X11/lib/font/Speedo/sptobdf.c678
-rw-r--r--nx-X11/lib/font/Speedo/useropt.h41
-rw-r--r--nx-X11/lib/font/Type1/AFM.h62
-rw-r--r--nx-X11/lib/font/Type1/Imakefile91
-rw-r--r--nx-X11/lib/font/Type1/afm.c200
-rw-r--r--nx-X11/lib/font/Type1/arith.c486
-rw-r--r--nx-X11/lib/font/Type1/arith.h77
-rw-r--r--nx-X11/lib/font/Type1/blues.h95
-rw-r--r--nx-X11/lib/font/Type1/cidchar.c621
-rw-r--r--nx-X11/lib/font/Type1/cluts.h35
-rw-r--r--nx-X11/lib/font/Type1/curves.c228
-rw-r--r--nx-X11/lib/font/Type1/curves.h44
-rw-r--r--nx-X11/lib/font/Type1/digit.h64
-rw-r--r--nx-X11/lib/font/Type1/fontfcn.c709
-rw-r--r--nx-X11/lib/font/Type1/fontfcn.h250
-rw-r--r--nx-X11/lib/font/Type1/fonts.h49
-rw-r--r--nx-X11/lib/font/Type1/hdigit.h94
-rw-r--r--nx-X11/lib/font/Type1/hints.c890
-rw-r--r--nx-X11/lib/font/Type1/hints.h48
-rw-r--r--nx-X11/lib/font/Type1/lines.c189
-rw-r--r--nx-X11/lib/font/Type1/lines.h39
-rw-r--r--nx-X11/lib/font/Type1/minimain.c48
-rw-r--r--nx-X11/lib/font/Type1/module/Imakefile99
-rw-r--r--nx-X11/lib/font/Type1/module/type1mod.c91
-rw-r--r--nx-X11/lib/font/Type1/objects.c1101
-rw-r--r--nx-X11/lib/font/Type1/objects.h354
-rw-r--r--nx-X11/lib/font/Type1/paths.c1406
-rw-r--r--nx-X11/lib/font/Type1/paths.h239
-rw-r--r--nx-X11/lib/font/Type1/pictures.h50
-rw-r--r--nx-X11/lib/font/Type1/range.h48
-rw-r--r--nx-X11/lib/font/Type1/regions.c1651
-rw-r--r--nx-X11/lib/font/Type1/regions.h250
-rw-r--r--nx-X11/lib/font/Type1/scanfont.c2370
-rw-r--r--nx-X11/lib/font/Type1/spaces.c998
-rw-r--r--nx-X11/lib/font/Type1/spaces.h172
-rw-r--r--nx-X11/lib/font/Type1/strokes.h38
-rw-r--r--nx-X11/lib/font/Type1/t1funcs.c1668
-rw-r--r--nx-X11/lib/font/Type1/t1hdigit.h40
-rw-r--r--nx-X11/lib/font/Type1/t1imager.h84
-rw-r--r--nx-X11/lib/font/Type1/t1info.c1096
-rw-r--r--nx-X11/lib/font/Type1/t1intf.h143
-rw-r--r--nx-X11/lib/font/Type1/t1io.c388
-rw-r--r--nx-X11/lib/font/Type1/t1malloc.c759
-rw-r--r--nx-X11/lib/font/Type1/t1snap.c85
-rw-r--r--nx-X11/lib/font/Type1/t1stdio.h101
-rw-r--r--nx-X11/lib/font/Type1/t1stub.c56
-rw-r--r--nx-X11/lib/font/Type1/t1test.c246
-rw-r--r--nx-X11/lib/font/Type1/t1unicode.c251
-rw-r--r--nx-X11/lib/font/Type1/t1unicode.h25
-rw-r--r--nx-X11/lib/font/Type1/token.c1208
-rw-r--r--nx-X11/lib/font/Type1/token.h79
-rw-r--r--nx-X11/lib/font/Type1/tokst.h510
-rw-r--r--nx-X11/lib/font/Type1/trig.h41
-rw-r--r--nx-X11/lib/font/Type1/type1.c1892
-rw-r--r--nx-X11/lib/font/Type1/util.c222
-rw-r--r--nx-X11/lib/font/Type1/util.h217
-rw-r--r--nx-X11/lib/font/bitmap/Imakefile71
-rw-r--r--nx-X11/lib/font/bitmap/bdfint.h90
-rw-r--r--nx-X11/lib/font/bitmap/bdfread.c967
-rw-r--r--nx-X11/lib/font/bitmap/bdfutils.c340
-rw-r--r--nx-X11/lib/font/bitmap/bitmap.c160
-rw-r--r--nx-X11/lib/font/bitmap/bitmapfunc.c240
-rw-r--r--nx-X11/lib/font/bitmap/bitmaputil.c232
-rw-r--r--nx-X11/lib/font/bitmap/bitscale.c1978
-rw-r--r--nx-X11/lib/font/bitmap/fontink.c219
-rw-r--r--nx-X11/lib/font/bitmap/module/Imakefile45
-rw-r--r--nx-X11/lib/font/bitmap/module/bitmapmod.c76
-rw-r--r--nx-X11/lib/font/bitmap/pcf.h100
-rw-r--r--nx-X11/lib/font/bitmap/pcfread.c997
-rw-r--r--nx-X11/lib/font/bitmap/pcfwrite.c468
-rw-r--r--nx-X11/lib/font/bitmap/snfread.c514
-rw-r--r--nx-X11/lib/font/bitmap/snfstr.h185
-rw-r--r--nx-X11/lib/font/builtins/Imakefile17
-rw-r--r--nx-X11/lib/font/builtins/buildfont14
-rw-r--r--nx-X11/lib/font/builtins/builtin.h60
-rw-r--r--nx-X11/lib/font/builtins/dir.c64
-rw-r--r--nx-X11/lib/font/builtins/file.c139
-rw-r--r--nx-X11/lib/font/builtins/fonts.c2438
-rw-r--r--nx-X11/lib/font/builtins/fpe.c98
-rw-r--r--nx-X11/lib/font/builtins/render.c114
-rw-r--r--nx-X11/lib/font/fc/Imakefile31
-rw-r--r--nx-X11/lib/font/fc/fsconvert.c760
-rw-r--r--nx-X11/lib/font/fc/fserve.c3262
-rw-r--r--nx-X11/lib/font/fc/fserve.h96
-rw-r--r--nx-X11/lib/font/fc/fservestr.h211
-rw-r--r--nx-X11/lib/font/fc/fsio.c516
-rw-r--r--nx-X11/lib/font/fc/fsio.h187
-rw-r--r--nx-X11/lib/font/fc/fsio.h.NX.reference191
-rw-r--r--nx-X11/lib/font/fc/fsio.h.XF86.reference187
-rw-r--r--nx-X11/lib/font/fc/fslibos.h220
-rw-r--r--nx-X11/lib/font/fontcache/Imakefile29
-rw-r--r--nx-X11/lib/font/fontcache/fcqueue.h133
-rw-r--r--nx-X11/lib/font/fontcache/fontcache.c1022
-rw-r--r--nx-X11/lib/font/fontcache/fontcache.h121
-rw-r--r--nx-X11/lib/font/fontfile/Imakefile81
-rw-r--r--nx-X11/lib/font/fontfile/bitsource.c174
-rw-r--r--nx-X11/lib/font/fontfile/bufio.c212
-rw-r--r--nx-X11/lib/font/fontfile/decompress.c410
-rw-r--r--nx-X11/lib/font/fontfile/defaults.c77
-rw-r--r--nx-X11/lib/font/fontfile/dirfile.c491
-rw-r--r--nx-X11/lib/font/fontfile/encparse.c966
-rw-r--r--nx-X11/lib/font/fontfile/encparse.c.NX.original966
-rw-r--r--nx-X11/lib/font/fontfile/encparse.c.X.original963
-rw-r--r--nx-X11/lib/font/fontfile/ffcheck.c173
-rw-r--r--nx-X11/lib/font/fontfile/fileio.c90
-rw-r--r--nx-X11/lib/font/fontfile/filewr.c65
-rw-r--r--nx-X11/lib/font/fontfile/fontdir.c827
-rw-r--r--nx-X11/lib/font/fontfile/fontenc.c952
-rw-r--r--nx-X11/lib/font/fontfile/fontencI.h46
-rw-r--r--nx-X11/lib/font/fontfile/fontencc.c77
-rw-r--r--nx-X11/lib/font/fontfile/fontfile.c1147
-rw-r--r--nx-X11/lib/font/fontfile/fontscale.c447
-rw-r--r--nx-X11/lib/font/fontfile/gunzip.c227
-rw-r--r--nx-X11/lib/font/fontfile/module/Imakefile21
-rw-r--r--nx-X11/lib/font/fontfile/printerfont.c178
-rw-r--r--nx-X11/lib/font/fontfile/register.c109
-rw-r--r--nx-X11/lib/font/fontfile/renderers.c117
-rw-r--r--nx-X11/lib/font/include/Imakefile11
-rw-r--r--nx-X11/lib/font/include/bitmap.h116
-rw-r--r--nx-X11/lib/font/include/bufio.h92
-rw-r--r--nx-X11/lib/font/include/fntfil.h178
-rw-r--r--nx-X11/lib/font/include/fntfilio.h56
-rw-r--r--nx-X11/lib/font/include/fntfilst.h198
-rw-r--r--nx-X11/lib/font/include/fontenc.h124
-rw-r--r--nx-X11/lib/font/include/fontencc.h36
-rw-r--r--nx-X11/lib/font/include/fontmisc.h133
-rw-r--r--nx-X11/lib/font/include/fontmod.h16
-rw-r--r--nx-X11/lib/font/include/fontshow.h37
-rw-r--r--nx-X11/lib/font/include/fontutil.h26
-rw-r--r--nx-X11/lib/font/include/fontxlfd.h100
-rw-r--r--nx-X11/lib/font/stubs/Imakefile25
-rw-r--r--nx-X11/lib/font/stubs/cauthgen.c14
-rw-r--r--nx-X11/lib/font/stubs/csignal.c14
-rw-r--r--nx-X11/lib/font/stubs/delfntcid.c13
-rw-r--r--nx-X11/lib/font/stubs/errorf.c13
-rw-r--r--nx-X11/lib/font/stubs/fatalerror.c13
-rw-r--r--nx-X11/lib/font/stubs/findoldfnt.c14
-rw-r--r--nx-X11/lib/font/stubs/getcres.c14
-rw-r--r--nx-X11/lib/font/stubs/getdefptsize.c14
-rw-r--r--nx-X11/lib/font/stubs/getnewfntcid.c14
-rw-r--r--nx-X11/lib/font/stubs/gettime.c14
-rw-r--r--nx-X11/lib/font/stubs/initfshdl.c15
-rw-r--r--nx-X11/lib/font/stubs/regfpefunc.c28
-rw-r--r--nx-X11/lib/font/stubs/rmfshdl.c15
-rw-r--r--nx-X11/lib/font/stubs/servclient.c3
-rw-r--r--nx-X11/lib/font/stubs/setfntauth.c14
-rw-r--r--nx-X11/lib/font/stubs/stfntcfnt.c14
-rw-r--r--nx-X11/lib/font/stubs/stubs.h27
-rw-r--r--nx-X11/lib/font/stubs/xpstubs.c24
-rw-r--r--nx-X11/lib/font/util/Imakefile43
-rw-r--r--nx-X11/lib/font/util/atom.c233
-rw-r--r--nx-X11/lib/font/util/fontaccel.c107
-rw-r--r--nx-X11/lib/font/util/fontnames.c123
-rw-r--r--nx-X11/lib/font/util/fontutil.c443
-rw-r--r--nx-X11/lib/font/util/fontxlfd.c637
-rw-r--r--nx-X11/lib/font/util/format.c126
-rw-r--r--nx-X11/lib/font/util/miscutil.c99
-rw-r--r--nx-X11/lib/font/util/patcache.c221
-rw-r--r--nx-X11/lib/font/util/private.c107
-rw-r--r--nx-X11/lib/font/util/utilbitmap.c188
-rw-r--r--nx-X11/lib/fontconfig/Imakefile464
-rw-r--r--nx-X11/lib/fontconfig/config-subst10
-rw-r--r--nx-X11/lib/fontconfig/fcfreetype.c2847
-rw-r--r--nx-X11/lib/fontenc/Imakefile36
-rw-r--r--nx-X11/lib/fontenc/fontenc-def.cpp19
-rw-r--r--nx-X11/lib/freetype2/Imakefile263
-rw-r--r--nx-X11/lib/freetype2/freetype-def.cpp211
-rw-r--r--nx-X11/lib/freetype2/freetype/Imakefile90
-rw-r--r--nx-X11/lib/freetype2/freetype/cache/Imakefile25
-rw-r--r--nx-X11/lib/freetype2/freetype/config/Imakefile52
-rw-r--r--nx-X11/lib/freetype2/freetype/internal/Imakefile52
-rw-r--r--nx-X11/lib/freetype2/freetype/internal/services/Imakefile31
-rw-r--r--nx-X11/lib/lbxutil/Imakefile31
-rw-r--r--nx-X11/lib/lbxutil/delta/Imakefile17
-rw-r--r--nx-X11/lib/lbxutil/delta/lbxdelta.c255
-rw-r--r--nx-X11/lib/lbxutil/image/Imakefile45
-rw-r--r--nx-X11/lib/lbxutil/image/dfaxg42d.c420
-rw-r--r--nx-X11/lib/lbxutil/image/dpackbits.c100
-rw-r--r--nx-X11/lib/lbxutil/image/efaxg42d.c328
-rw-r--r--nx-X11/lib/lbxutil/image/epackbits.c202
-rw-r--r--nx-X11/lib/lbxutil/image/lbxbwcodes.h269
-rw-r--r--nx-X11/lib/lbxutil/image/lbxfax.h60
-rw-r--r--nx-X11/lib/lbxutil/image/misc.c213
-rw-r--r--nx-X11/lib/lbxutil/image/mkg3states.c761
-rw-r--r--nx-X11/lib/lbxutil/lbx_zlib/Imakefile22
-rw-r--r--nx-X11/lib/lbxutil/lbx_zlib/lbx_zlib.c543
-rw-r--r--nx-X11/lib/lbxutil/lbx_zlib/lbx_zlib.h136
-rw-r--r--nx-X11/lib/lbxutil/lbx_zlib/lbx_zlib_io.c275
-rw-r--r--nx-X11/lib/lbxutil/lbx_zlib/reqstats.c503
-rw-r--r--nx-X11/lib/lbxutil/lbx_zlib/reqstats.h43
-rw-r--r--nx-X11/lib/misc/snprintf.c714
-rw-r--r--nx-X11/lib/misc/snprintf.h35
-rw-r--r--nx-X11/lib/misc/strlcat.c61
-rw-r--r--nx-X11/lib/misc/strlcpy.c56
-rw-r--r--nx-X11/lib/oldX/Imakefile45
-rw-r--r--nx-X11/lib/oldX/X10.h89
-rw-r--r--nx-X11/lib/oldX/XCrAssoc.c75
-rw-r--r--nx-X11/lib/oldX/XDelAssoc.c82
-rw-r--r--nx-X11/lib/oldX/XDestAssoc.c67
-rw-r--r--nx-X11/lib/oldX/XDraw.c710
-rw-r--r--nx-X11/lib/oldX/XLookAssoc.c78
-rw-r--r--nx-X11/lib/oldX/XMakeAssoc.c113
-rw-r--r--nx-X11/lib/oldX/oldX-def.cpp11
-rw-r--r--nx-X11/lib/psres/Imakefile34
-rw-r--r--nx-X11/lib/psres/PSres.c1661
-rw-r--r--nx-X11/lib/psres/psres-def.cpp11
-rw-r--r--nx-X11/lib/regex/Imakefile53
-rw-r--r--nx-X11/lib/windows/Imakefile34
-rwxr-xr-xnx-X11/lib/windows/WindowsWM-def.cpp13
-rw-r--r--nx-X11/lib/windows/WindowsWM.man340
-rwxr-xr-xnx-X11/lib/windows/windowswm.c386
-rwxr-xr-xnx-X11/lib/windows/windowswm.h195
-rwxr-xr-xnx-X11/lib/windows/windowswmstr.h169
-rw-r--r--nx-X11/lib/xkbfile/Imakefile43
-rw-r--r--nx-X11/lib/xkbfile/XKBbells.h143
-rw-r--r--nx-X11/lib/xkbfile/XKBconfig.h280
-rw-r--r--nx-X11/lib/xkbfile/XKBfile.h494
-rw-r--r--nx-X11/lib/xkbfile/XKBfileInt.h79
-rw-r--r--nx-X11/lib/xkbfile/XKBrules.h201
-rw-r--r--nx-X11/lib/xkbfile/XKM.h70
-rw-r--r--nx-X11/lib/xkbfile/XKMformat.h301
-rw-r--r--nx-X11/lib/xkbfile/cout.c1036
-rw-r--r--nx-X11/lib/xkbfile/magic11
-rw-r--r--nx-X11/lib/xkbfile/maprules.c1482
-rw-r--r--nx-X11/lib/xkbfile/srvmisc.c216
-rw-r--r--nx-X11/lib/xkbfile/xkbatom.c245
-rw-r--r--nx-X11/lib/xkbfile/xkbbells.c104
-rw-r--r--nx-X11/lib/xkbfile/xkbconfig.c1355
-rw-r--r--nx-X11/lib/xkbfile/xkbdraw.c135
-rw-r--r--nx-X11/lib/xkbfile/xkberrs.c72
-rw-r--r--nx-X11/lib/xkbfile/xkbfile-def.cpp97
-rw-r--r--nx-X11/lib/xkbfile/xkbmisc.c689
-rw-r--r--nx-X11/lib/xkbfile/xkbout.c1066
-rw-r--r--nx-X11/lib/xkbfile/xkbtext.c1440
-rw-r--r--nx-X11/lib/xkbfile/xkmout.c1389
-rw-r--r--nx-X11/lib/xkbfile/xkmread.c1315
-rw-r--r--nx-X11/lib/xkbui/Imakefile25
-rw-r--r--nx-X11/lib/xkbui/XKBui.c666
-rw-r--r--nx-X11/lib/xkbui/XKBui.h194
-rw-r--r--nx-X11/lib/xkbui/XKBuiPriv.h71
-rw-r--r--nx-X11/lib/xkbui/xkbui-def.cpp16
-rw-r--r--nx-X11/lib/xtrans/Imakefile24
-rw-r--r--nx-X11/lib/xtrans/Xtrans.c1402
-rw-r--r--nx-X11/lib/xtrans/Xtrans.h490
-rw-r--r--nx-X11/lib/xtrans/Xtransdnet.c668
-rw-r--r--nx-X11/lib/xtrans/Xtransint.h485
-rw-r--r--nx-X11/lib/xtrans/Xtranslcl.c2755
-rw-r--r--nx-X11/lib/xtrans/Xtransos2.c887
-rw-r--r--nx-X11/lib/xtrans/Xtranssock.c3417
-rw-r--r--nx-X11/lib/xtrans/Xtranssock.c.NX.original3417
-rw-r--r--nx-X11/lib/xtrans/Xtranssock.c.X.original2504
-rw-r--r--nx-X11/lib/xtrans/Xtranstli.c1422
-rw-r--r--nx-X11/lib/xtrans/Xtransutil.c691
-rw-r--r--nx-X11/lib/xtrans/transport.c86
-rw-r--r--nx-X11/lib/zlib/Imakefile56
1860 files changed, 637715 insertions, 0 deletions
diff --git a/nx-X11/lib/FS/FS-def.cpp b/nx-X11/lib/FS/FS-def.cpp
new file mode 100644
index 000000000..fd1511263
--- /dev/null
+++ b/nx-X11/lib/FS/FS-def.cpp
@@ -0,0 +1,38 @@
+LIBRARY FS
+VERSION LIBRARY_VERSION
+EXPORTS
+ FSErrorList DATA
+ FSErrorListSize DATA
+ FSCloseFont
+ FSCloseServer
+ FSFlush
+ FSFree
+ FSFreeCatalogues
+ FSFreeExtensionList
+ FSFreeFontNames
+ FSGetCatalogues
+ FSGetErrorDatabaseText
+ FSGetErrorText
+ FSListCatalogues
+ FSListExtensions
+ FSListFonts
+ FSListFontsWithXInfo
+ FSMalloc
+ FSMaxRequestSize
+ FSNextEvent
+ FSOpenBitmapFont
+ FSOpenServer
+ FSQueryExtension
+ FSQueryXBitmaps16
+ FSQueryXBitmaps8
+ FSQueryXExtents16
+ FSQueryXExtents8
+ FSQueryXInfo
+ FSServerName
+ FSSetAfterFunction
+ FSSetCatalogues
+ FSSetErrorHandler
+ FSSetIOErrorHandler
+ FSSync
+ FSSynchronize
+/* $XFree86$ */
diff --git a/nx-X11/lib/FS/FSClServ.c b/nx-X11/lib/FS/FSClServ.c
new file mode 100644
index 000000000..1866cfcd5
--- /dev/null
+++ b/nx-X11/lib/FS/FSClServ.c
@@ -0,0 +1,93 @@
+/* $Xorg: FSClServ.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/* @(#)FSClServ.c 4.1 91/05/02
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSClServ.c,v 1.4 2001/01/17 19:41:27 dawes Exp $ */
+
+/*
+
+Copyright 1987, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlib.h"
+#include "FSlibint.h"
+
+extern FSServer *_FSHeadOfServerList;
+
+int
+FSCloseServer(svr)
+ FSServer *svr;
+{
+ _FSExtension *ext;
+ FSServer **sv = &_FSHeadOfServerList;
+ FSServer *s = _FSHeadOfServerList;
+
+ svr->flags |= FSlibServerClosing;
+ (void) FSSync(svr, 1); /* throw out pending events */
+ ext = svr->ext_procs;
+ while (ext) {
+ if (ext->close_server != NULL)
+ (*ext->close_server) (svr, &ext->codes);
+ ext = ext->next;
+ }
+ _FSDisconnectServer(svr->trans_conn);
+ while (s != NULL) {
+ if (s == svr) {
+ *sv = s->next;
+ _FSFreeServerStructure(svr);
+ break;
+ }
+ sv = &(s->next);
+ s = *sv;
+ }
+ if (_FSHeadOfServerList == NULL) {
+ _FSFreeQ();
+ }
+ return 1;
+}
diff --git a/nx-X11/lib/FS/FSCloseFt.c b/nx-X11/lib/FS/FSCloseFt.c
new file mode 100644
index 000000000..38ce7e6b8
--- /dev/null
+++ b/nx-X11/lib/FS/FSCloseFt.c
@@ -0,0 +1,70 @@
+/* $Xorg: FSCloseFt.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/* @(#)FSCloseFt.c 4.1 91/05/02
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+
+int
+FSCloseFont(svr, fid)
+ FSServer *svr;
+ Font fid;
+{
+ fsResourceReq *req;
+
+ GetResReq(CloseFont, fid, req);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/FS/FSConnServ.c b/nx-X11/lib/FS/FSConnServ.c
new file mode 100644
index 000000000..6a66d87a5
--- /dev/null
+++ b/nx-X11/lib/FS/FSConnServ.c
@@ -0,0 +1,247 @@
+/* $Xorg: FSConnServ.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/FS/FSConnServ.c,v 3.10 2001/10/28 03:32:27 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+#include <stdio.h>
+#include "X11/Xpoll.h"
+#ifdef NCD
+#include <fcntl.h>
+#endif
+#ifdef WIN32
+#define ECHECK(err) (WSAGetLastError() == err)
+#else
+#ifdef ISC
+#define ECHECK(err) ((errno == err) || errno == EAGAIN || errno == EWOULDBLOCK)
+#else
+#define ECHECK(err) (errno == err)
+#endif
+#endif
+
+/*
+ * Attempts to connect to server, given server name. Returns transport
+ * connection object or NULL if connection fails.
+ */
+
+#define FS_CONNECTION_RETRIES 5
+
+XtransConnInfo
+_FSConnectServer(server_name)
+ char *server_name;
+{
+ XtransConnInfo trans_conn = NULL; /* transport connection object */
+ int retry, connect_stat;
+ int madeConnection = 0;
+
+ /*
+ * Open the network connection.
+ */
+
+ for (retry = FS_CONNECTION_RETRIES; retry >= 0; retry--)
+ {
+ if ((trans_conn = _FSTransOpenCOTSClient(server_name)) == NULL)
+ {
+ break;
+ }
+
+ if ((connect_stat = _FSTransConnect(trans_conn,server_name)) < 0)
+ {
+ _FSTransClose(trans_conn);
+
+ if (connect_stat == TRANS_TRY_CONNECT_AGAIN)
+ {
+ sleep(1);
+ continue;
+ }
+ else
+ break;
+ }
+ else
+ {
+ madeConnection = 1;
+ break;
+ }
+ }
+
+ if (!madeConnection)
+ return (NULL);
+
+
+ /*
+ * set it non-blocking. This is so we can read data when blocked for
+ * writing in the library.
+ */
+
+ _FSTransSetOption(trans_conn, TRANS_NONBLOCKING, 1);
+
+ return (trans_conn);
+}
+
+/*
+ * Disconnect from server.
+ */
+
+void
+_FSDisconnectServer(trans_conn)
+ XtransConnInfo trans_conn;
+
+{
+ (void) _FSTransClose(trans_conn);
+}
+
+
+/*
+ * This is an OS dependent routine which:
+ * 1) returns as soon as the connection can be written on....
+ * 2) if the connection can be read, must enqueue events and handle errors,
+ * until the connection is writable.
+ */
+void _FSWaitForWritable(svr)
+ FSServer *svr;
+{
+ fd_set r_mask;
+ fd_set w_mask;
+ int nfound;
+
+ FD_ZERO(&r_mask);
+ FD_ZERO(&w_mask);
+
+ while (1) {
+ FD_SET(svr->fd, &r_mask);
+ FD_SET(svr->fd, &w_mask);
+
+ do {
+ nfound = Select(svr->fd + 1, &r_mask, &w_mask, NULL, NULL);
+ if (nfound < 0 && !ECHECK(EINTR))
+ (*_FSIOErrorFunction) (svr);
+ } while (nfound <= 0);
+
+ if (XFD_ANYSET(&r_mask)) {
+ char buf[BUFSIZE];
+ BytesReadable_t pend_not_register;
+ register BytesReadable_t pend;
+ register fsEvent *ev;
+
+ /* find out how much data can be read */
+ if (_FSTransBytesReadable(svr->trans_conn, &pend_not_register) < 0)
+ (*_FSIOErrorFunction) (svr);
+ pend = pend_not_register;
+
+ /*
+ * must read at least one fsEvent; if none is pending, then we'll
+ * just block waiting for it
+ */
+ if (pend < SIZEOF(fsEvent))
+ pend = SIZEOF(fsEvent);
+
+ /* but we won't read more than the max buffer size */
+ if (pend > BUFSIZE)
+ pend = BUFSIZE;
+
+ /* round down to an integral number of FSReps */
+ pend = (pend / SIZEOF(fsEvent)) * SIZEOF(fsEvent);
+
+ _FSRead(svr, buf, pend);
+
+ /* no space between comma and type or else macro will die */
+ STARTITERATE(ev, fsEvent, buf, (pend > 0),
+ (pend -= SIZEOF(fsEvent))) {
+ if (ev->type == FS_Error)
+ _FSError(svr, (fsError *) ev);
+ else /* it's an event packet; enqueue it */
+ _FSEnq(svr, ev);
+ }
+ ENDITERATE
+ }
+ if (XFD_ANYSET(&w_mask))
+ return;
+ }
+}
+
+
+void _FSWaitForReadable(svr)
+ FSServer *svr;
+{
+ fd_set r_mask;
+ int result;
+
+ FD_ZERO(&r_mask);
+ do {
+ FD_SET(svr->fd, &r_mask);
+ result = Select(svr->fd + 1, &r_mask, NULL, NULL, NULL);
+ if (result == -1 && !ECHECK(EINTR))
+ (*_FSIOErrorFunction) (svr);
+ } while (result <= 0);
+}
+
+void _FSSendClientPrefix(svr, client)
+ FSServer *svr;
+ fsConnClientPrefix *client;
+{
+ struct iovec iovarray[5],
+ *iov = iovarray;
+ int niov = 0;
+
+#define add_to_iov(b,l) \
+ { iov->iov_base = (b); iov->iov_len = (l); iov++, niov++; }
+
+ add_to_iov((caddr_t) client, SIZEOF(fsConnClientPrefix));
+
+#undef add_to_iov
+
+ (void) _FSTransWritev(svr->trans_conn, iovarray, niov);
+ return;
+}
diff --git a/nx-X11/lib/FS/FSErrDis.c b/nx-X11/lib/FS/FSErrDis.c
new file mode 100644
index 000000000..cc4abf4b0
--- /dev/null
+++ b/nx-X11/lib/FS/FSErrDis.c
@@ -0,0 +1,121 @@
+/* $Xorg: FSErrDis.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/* @(#)FSErrDis.c 4.1 91/05/02
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "FSlibint.h"
+#include <X11/Xos.h>
+
+char *FSErrorList[] = {
+ /* FSBadRequest */ "BadRequest, invalid request code or no such operation",
+ /* FSBadFormat */ "BadFormat, bad font format mask",
+ /* FSBadFont */ "BadFont, invalid Font parameter",
+ /* FSBadRange */ "BadRange, invalid character range attributes",
+ /* FSBadEventMask */ "BadEventMask, illegal event mask",
+ /* FSBadAccessContext */ "BadAccessContext, insufficient permissions for operation",
+ /* FSBadIDChoice */ "BadIDChoice, invalid resource ID chosen for this connection",
+ /* FSBadName */ "BadName, named font does not exist",
+ /* FSBadResolution */ "BadResolution, improperly formatted resolution",
+ /* FSBadAlloc */ "BadAlloc, insufficient resources for operation",
+ /* FSBadLength */ "BadLength, request too large or internal FSlib length error",
+ /* FSBadImplementation */ "BadImplementation, request unsupported",
+};
+int FSErrorListSize = sizeof(FSErrorList);
+
+
+/* ARGSUSED */
+int FSGetErrorDatabaseText(svr, name, type, defaultp, buffer, nbytes)
+ register char *name,
+ *type;
+ char *defaultp;
+ FSServer *svr;
+ char *buffer;
+ int nbytes;
+{
+ if (nbytes == 0)
+ return 0;
+ (void) strncpy(buffer, (char *) defaultp, nbytes);
+ if ((strlen(defaultp) + 1) > nbytes)
+ buffer[nbytes - 1] = '\0';
+ return 1;
+}
+
+int FSGetErrorText(svr, code, buffer, nbytes)
+ register int code;
+ register FSServer *svr;
+ char *buffer;
+ int nbytes;
+{
+
+ char *defaultp = NULL;
+ char buf[32];
+ register _FSExtension *ext;
+
+ if (nbytes == 0)
+ return 0;
+ sprintf(buf, "%d", code);
+ if (code <= (FSErrorListSize / sizeof(char *)) && code > 0) {
+ defaultp = FSErrorList[code];
+ FSGetErrorDatabaseText(svr, "FSProtoError", buf, defaultp, buffer, nbytes);
+ }
+ ext = svr->ext_procs;
+ while (ext) { /* call out to any extensions interested */
+ if (ext->error_string != NULL)
+ (*ext->error_string) (svr, code, &ext->codes, buffer, nbytes);
+ ext = ext->next;
+ }
+ return 1;
+}
+
diff --git a/nx-X11/lib/FS/FSErrHndlr.c b/nx-X11/lib/FS/FSErrHndlr.c
new file mode 100644
index 000000000..592fa4896
--- /dev/null
+++ b/nx-X11/lib/FS/FSErrHndlr.c
@@ -0,0 +1,84 @@
+/* $Xorg: FSErrHndlr.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/* @(#)FSErrHndlr.c 4.1 91/05/02
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+*/
+/* $XFree86: xc/lib/FS/FSErrHndlr.c,v 1.4 2001/01/17 19:41:28 dawes Exp $ */
+
+/*
+
+Copyright 1987, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+FSErrorHandler
+FSSetErrorHandler(FSErrorHandler handler)
+{
+ FSErrorHandler oldhandler = _FSErrorFunction;
+
+ if (handler != NULL) {
+ _FSErrorFunction = handler;
+ } else {
+ _FSErrorFunction = _FSDefaultError;
+ }
+ return oldhandler;
+}
+
+FSIOErrorHandler
+FSSetIOErrorHandler(FSIOErrorHandler handler)
+{
+ FSIOErrorHandler oldhandler = _FSIOErrorFunction;
+
+ if (handler != NULL) {
+ _FSIOErrorFunction = handler;
+ } else {
+ _FSIOErrorFunction = _FSDefaultIOError;
+ }
+ return oldhandler;
+}
diff --git a/nx-X11/lib/FS/FSFlush.c b/nx-X11/lib/FS/FSFlush.c
new file mode 100644
index 000000000..e4b14390b
--- /dev/null
+++ b/nx-X11/lib/FS/FSFlush.c
@@ -0,0 +1,63 @@
+/* $Xorg: FSFlush.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/* @(#)FSFlush.c 4.1 91/05/02
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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, 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.
+
+*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+int FSFlush(svr)
+ FSServer *svr;
+{
+ _FSFlush(svr);
+ return 1;
+}
diff --git a/nx-X11/lib/FS/FSFontInfo.c b/nx-X11/lib/FS/FSFontInfo.c
new file mode 100644
index 000000000..d79ad9e26
--- /dev/null
+++ b/nx-X11/lib/FS/FSFontInfo.c
@@ -0,0 +1,346 @@
+/* $Xorg: FSFontInfo.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSFontInfo.c,v 1.5tsi 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.
+
+*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+char **
+FSListFontsWithXInfo(svr, pattern, maxNames, count, info, pprops, offsets, prop_data)
+ FSServer *svr;
+ char *pattern;
+ int maxNames;
+ int *count;
+ FSXFontInfoHeader ***info;
+ FSPropInfo ***pprops;
+ FSPropOffset ***offsets;
+ unsigned char ***prop_data;
+{
+ long nbytes;
+ int i,
+ j;
+ size_t size = 0;
+ FSXFontInfoHeader **fhdr = (FSXFontInfoHeader **) 0;
+ FSPropInfo **pi = (FSPropInfo **) 0;
+ FSPropOffset **po = (FSPropOffset **) 0;
+ unsigned char **pd = (unsigned char **) 0;
+ char **flist = NULL;
+ fsListFontsWithXInfoReply reply;
+ fsListFontsWithXInfoReq *req;
+ fsPropInfo local_pi;
+ fsPropOffset local_po;
+ Status status;
+
+ GetReq(ListFontsWithXInfo, req);
+ req->maxNames = maxNames;
+ nbytes = req->nbytes = pattern ? strlen(pattern) : 0;
+ req->length += (nbytes + 3) >> 2;
+ _FSSend(svr, pattern, nbytes);
+
+ for (i = 0;; i++) {
+ if (FSProtocolVersion(svr) > 1)
+ {
+ status = _FSReply(svr, (fsReply *) &reply, 0, fsFalse);
+ if (status != 0 && reply.nameLength == 0) /* got last reply */
+ break;
+ if (status)
+ _FSRead(svr, ((char *) &reply) + SIZEOF(fsGenericReply),
+ SIZEOF(fsListFontsWithXInfoReply) -
+ SIZEOF(fsGenericReply));
+ } else {
+ status = _FSReply(svr, (fsReply *) & reply,
+ ((SIZEOF(fsListFontsWithXInfoReply) -
+ SIZEOF(fsGenericReply)) >> 2), fsFalse);
+ }
+ if (!status) {
+ for (j = (i - 1); j >= 0; j--) {
+ FSfree((char *) fhdr[j]);
+ FSfree((char *) pi[j]);
+ FSfree((char *) po[j]);
+ FSfree((char *) pd[j]);
+ FSfree(flist[j]);
+ }
+ if (flist)
+ FSfree((char *) flist);
+ if (fhdr)
+ FSfree((char *) fhdr);
+ if (pi)
+ FSfree((char *) pi);
+ if (po)
+ FSfree((char *) po);
+ if (pd)
+ FSfree((char *) pd);
+
+ SyncHandle();
+ return (char **) NULL;
+ }
+ if (reply.nameLength == 0) /* got last reply in version 1 */
+ break;
+ if ((i + reply.nReplies) >= size) {
+
+ if (reply.nReplies > SIZE_MAX - i - 1)
+ goto badmem;
+ size = i + reply.nReplies + 1;
+
+ if (size > SIZE_MAX / sizeof(char *))
+ goto badmem;
+
+ if (fhdr) {
+ FSXFontInfoHeader **tmp_fhdr = (FSXFontInfoHeader **)
+ FSrealloc((char *) fhdr,
+ (unsigned) (sizeof(FSXFontInfoHeader *) * size));
+ char **tmp_flist = (char **) FSrealloc((char *) flist,
+ (unsigned) (sizeof(char *) * size));
+ FSPropInfo **tmp_pi = (FSPropInfo **)
+ FSrealloc((char *) pi,
+ (unsigned) (sizeof(FSPropInfo *) * size));
+ FSPropOffset **tmp_po = (FSPropOffset **)
+ FSrealloc((char *) po,
+ (unsigned) (sizeof(FSPropOffset *) * size));
+ unsigned char **tmp_pd = (unsigned char **)
+ FSrealloc((char *) pd,
+ (unsigned) (sizeof(unsigned char *) * size));
+
+ if (!tmp_fhdr || !tmp_flist || !tmp_pi || !tmp_po || !tmp_pd) {
+ for (j = (i - 1); j >= 0; j--) {
+ FSfree((char *) flist[j]);
+ FSfree((char *) fhdr[j]);
+ FSfree((char *) pi[j]);
+ FSfree((char *) po[j]);
+ FSfree((char *) pd[j]);
+ }
+ if (tmp_flist)
+ FSfree((char *) tmp_flist);
+ else
+ FSfree((char *) flist);
+ if (tmp_fhdr)
+ FSfree((char *) tmp_fhdr);
+ else
+ FSfree((char *) fhdr);
+ if (tmp_pi)
+ FSfree((char *) tmp_pi);
+ else
+ FSfree((char *) pi);
+ if (tmp_po)
+ FSfree((char *) tmp_po);
+ else
+ FSfree((char *) po);
+ if (tmp_pd)
+ FSfree((char *) tmp_pd);
+ else
+ FSfree((char *) pd);
+ goto clearwire;
+ }
+ fhdr = tmp_fhdr;
+ flist = tmp_flist;
+ pi = tmp_pi;
+ po = tmp_po;
+ pd = tmp_pd;
+ } else {
+ if (!(fhdr = (FSXFontInfoHeader **)
+ FSmalloc((unsigned) (sizeof(FSXFontInfoHeader *) * size))))
+ goto clearwire;
+ if (!(flist = (char **)
+ FSmalloc((unsigned) (sizeof(char *) * size)))) {
+ FSfree((char *) fhdr);
+ goto clearwire;
+ }
+ if (!(pi = (FSPropInfo **)
+ FSmalloc((unsigned) (sizeof(FSPropInfo *) * size)))) {
+ FSfree((char *) fhdr);
+ FSfree((char *) flist);
+ goto clearwire;
+ }
+ if (!(po = (FSPropOffset **)
+ FSmalloc((unsigned) (sizeof(FSPropOffset *) * size)))) {
+ FSfree((char *) fhdr);
+ FSfree((char *) flist);
+ FSfree((char *) pi);
+ goto clearwire;
+ }
+ if (!(pd = (unsigned char **)
+ FSmalloc((unsigned) (sizeof(unsigned char *) * size)))) {
+ FSfree((char *) fhdr);
+ FSfree((char *) flist);
+ FSfree((char *) pi);
+ FSfree((char *) po);
+ goto clearwire;
+ }
+ }
+ }
+ fhdr[i] = (FSXFontInfoHeader *) FSmalloc(sizeof(FSXFontInfoHeader));
+ if (!fhdr[i]) {
+ goto badmem;
+ }
+ FSUnpack_XFontInfoHeader(&reply, fhdr[i], FSProtocolVersion(svr));
+
+ /* alloc space for the name */
+ flist[i] = (char *) FSmalloc((unsigned int) (reply.nameLength + 1));
+ if (FSProtocolVersion(svr) == 1)
+ {
+ /* get the name */
+ if (!flist[i]) {
+ nbytes = (reply.nameLength + 3) & ~3;
+ _FSEatData(svr, (unsigned long) nbytes);
+ goto badmem;
+ }
+ _FSReadPad(svr, flist[i], (long) reply.nameLength);
+ flist[i][reply.nameLength] = '\0';
+ }
+
+ pi[i] = (FSPropInfo *) FSmalloc(sizeof(FSPropInfo));
+ if (!pi[i]) {
+ FSfree((char *) fhdr[i]);
+ goto badmem;
+ }
+ _FSReadPad(svr, (char *) &local_pi, SIZEOF(fsPropInfo));
+ pi[i]->num_offsets = local_pi.num_offsets;
+ pi[i]->data_len = local_pi.data_len;
+
+#if SIZE_MAX <= UINT_MAX
+ if (pi[i]->num_offsets > SIZE_MAX / sizeof(FSPropOffset))
+ goto badmem;
+#endif
+
+ po[i] = (FSPropOffset *)
+ FSmalloc(pi[i]->num_offsets * sizeof(FSPropOffset));
+ if (!po[i]) {
+ FSfree((char *) fhdr[i]);
+ FSfree((char *) pi[i]);
+ goto badmem;
+ }
+ pd[i] = (unsigned char *) FSmalloc(pi[i]->data_len);
+ if (!pd[i]) {
+ FSfree((char *) fhdr[i]);
+ FSfree((char *) pi[i]);
+ FSfree((char *) po[i]);
+ goto badmem;
+ }
+ /* get offsets */
+ for (j=0; j<pi[i]->num_offsets; j++)
+ {
+ _FSReadPad(svr, (char *) &local_po, SIZEOF(fsPropOffset));
+ po[i][j].name.position = local_po.name.position;
+ po[i][j].name.length = local_po.name.length;
+ po[i][j].value.position = local_po.value.position;
+ po[i][j].value.length = local_po.value.length;
+ po[i][j].type = local_po.type;
+ }
+
+ /* get prop data */
+ if (FSProtocolVersion(svr) == 1)
+ _FSReadPad(svr, (char *) pd[i], pi[i]->data_len);
+ else
+ _FSRead(svr, (char *) pd[i], pi[i]->data_len);
+
+ if (FSProtocolVersion(svr) != 1)
+ {
+ /* get the name */
+ if (!flist[i]) {
+ nbytes = (reply.nameLength + 3) & ~3;
+ _FSEatData(svr, (unsigned long) nbytes);
+ goto badmem;
+ }
+ _FSRead(svr, flist[i], (long) reply.nameLength);
+ flist[i][reply.nameLength] = '\0';
+
+ nbytes = pi[i]->data_len + reply.nameLength;
+ _FSEatData(svr, (unsigned long) (((nbytes+3)&~3) - nbytes));
+ }
+ /* avoid integer overflow */
+ if (i > INT_MAX - 1) {
+ goto badmem;
+ }
+ }
+ *info = fhdr;
+ *count = i;
+ *pprops = pi;
+ *offsets = po;
+ *prop_data = pd;
+ SyncHandle();
+ return flist;
+
+badmem:
+ for (j = (i - 1); j >= 0; j--) {
+ FSfree((char *) pi[j]);
+ FSfree((char *) po[j]);
+ FSfree((char *) pd[j]);
+ FSfree(flist[j]);
+ FSfree((char *) fhdr[j]);
+ }
+ if (flist)
+ FSfree((char *) flist);
+ if (fhdr)
+ FSfree((char *) fhdr);
+ if (pi)
+ FSfree((char *) pi);
+ if (po)
+ FSfree((char *) po);
+ if (pd)
+ FSfree((char *) pd);
+
+
+clearwire:
+ do {
+ fsPropInfo ti;
+
+ _FSEatData(svr, (reply.nameLength + 3) & ~3);
+ _FSReadPad(svr, (char *) &ti, SIZEOF(fsPropInfo));
+ _FSEatData(svr, (SIZEOF(fsPropOffset) * ti.num_offsets));
+ _FSEatData(svr, ti.data_len);
+ } while (_FSReply(svr, (fsReply *) & reply,
+ ((SIZEOF(fsListFontsWithXInfoReply)
+ - SIZEOF(fsGenericReply)) >> 2), fsFalse) && (reply.nameLength != 0));
+ SyncHandle();
+ return (char **) NULL;
+}
diff --git a/nx-X11/lib/FS/FSFtNames.c b/nx-X11/lib/FS/FSFtNames.c
new file mode 100644
index 000000000..2d512e41c
--- /dev/null
+++ b/nx-X11/lib/FS/FSFtNames.c
@@ -0,0 +1,131 @@
+/* $Xorg: FSFtNames.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSFtNames.c,v 1.6tsi Exp $ */
+
+/*
+
+Copyright 1987, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+char **
+FSListFonts(svr, pattern, maxNames, actualCount)
+ FSServer *svr;
+ char *pattern;
+ int maxNames;
+ int *actualCount;
+{
+ long nbytes;
+ int i,
+ length;
+ char **flist;
+ char *c;
+ fsListFontsReply rep;
+ fsListFontsReq *req;
+ long rlen;
+
+ GetReq(ListFonts, req);
+ req->maxNames = maxNames;
+ nbytes = req->nbytes = pattern ? strlen(pattern) : 0;
+ req->length += (nbytes + 3) >> 2;
+ _FSSend(svr, pattern, nbytes);
+ if (!_FSReply(svr, (fsReply *) & rep,
+ (SIZEOF(fsListFontsReply) - SIZEOF(fsGenericReply)) >> 2, fsFalse))
+ return (char **) 0;
+
+ if (rep.nFonts
+#if (SIZE_MAX >> 2) <= UINT_MAX
+ && rep.nFonts <= SIZE_MAX / sizeof(char *)
+ && rep.length <= (SIZE_MAX >> 2)
+#endif
+ ) {
+ flist = (char **) FSmalloc((unsigned) rep.nFonts * sizeof(char *));
+ rlen = (rep.length << 2) - SIZEOF(fsListFontsReply);
+ c = (char *) FSmalloc((unsigned) (rlen + 1));
+
+ if ((!flist) || (!c)) {
+ if (flist)
+ FSfree((char *) flist);
+ if (c)
+ FSfree(c);
+ _FSEatData(svr, (unsigned long) rlen);
+ SyncHandle();
+ return (char **) NULL;
+ }
+ _FSReadPad(svr, c, rlen);
+ /* unpack */
+ length = *(unsigned char *)c;
+ for (i = 0; i < rep.nFonts; i++) {
+ flist[i] = c + 1;
+ c += length + 1;
+ length = *(unsigned char *)c;
+ *c = '\0';
+ }
+ } else {
+
+ flist = (char **) NULL;
+ }
+
+ *actualCount = rep.nFonts;
+ SyncHandle();
+ return flist;
+
+}
+
+int FSFreeFontNames(list)
+ char **list;
+{
+ if (list) {
+ FSfree(list[0] - 1);
+ FSfree((char *) list);
+ }
+ return 1;
+}
diff --git a/nx-X11/lib/FS/FSGetCats.c b/nx-X11/lib/FS/FSGetCats.c
new file mode 100644
index 000000000..39792f696
--- /dev/null
+++ b/nx-X11/lib/FS/FSGetCats.c
@@ -0,0 +1,114 @@
+/* $Xorg: FSGetCats.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSGetCats.c,v 1.6tsi 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+char **
+FSGetCatalogues(svr, num)
+ FSServer *svr;
+ int *num;
+{
+ fsGetCataloguesReply rep;
+ char **list;
+ char *c;
+ int i,
+ length;
+ fsReq *req;
+ long rlen;
+
+ GetEmptyReq(GetCatalogues, req);
+
+ if (!_FSReply(svr, (fsReply *) & rep, 0, fsFalse)) {
+ SyncHandle();
+ return (char **) NULL;
+ }
+ if (rep.num_catalogues
+#if (SIZE_MAX >> 2) <= UINT_MAX
+ && rep.num_catalogues <= SIZE_MAX/sizeof(char *)
+ && rep.length <= (SIZE_MAX >> 2)
+#endif
+ ) {
+ list = (char **)
+ FSmalloc((unsigned) (rep.num_catalogues * sizeof(char *)));
+ rlen = (rep.length << 2) - SIZEOF(fsGetCataloguesReply);
+ c = (char *) FSmalloc((unsigned) rlen + 1);
+ if ((!list) || (!c)) {
+ if (list)
+ FSfree((char *) list);
+ if (c)
+ FSfree(c);
+ _FSEatData(svr, (unsigned long) rlen);
+ SyncHandle();
+ return (char **) NULL;
+ }
+ _FSReadPad(svr, c, rlen);
+ /*
+ * unpack the strings
+ */
+ length = *c;
+ for (i = 0; i < (int)rep.num_catalogues; i++) {
+ list[i] = c + 1; /* skip length */
+ c += length + 1; /* find next length */
+ length = *c;
+ *c = '\0'; /* change length to NULL */
+ }
+ } else {
+ list = (char **) NULL;
+ }
+ SyncHandle();
+ *num = rep.num_catalogues;
+ return list;
+}
diff --git a/nx-X11/lib/FS/FSListCats.c b/nx-X11/lib/FS/FSListCats.c
new file mode 100644
index 000000000..99b540014
--- /dev/null
+++ b/nx-X11/lib/FS/FSListCats.c
@@ -0,0 +1,132 @@
+/* $Xorg: FSListCats.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSListCats.c,v 1.6tsi 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+char **
+FSListCatalogues(svr, pattern, maxNames, actualCount)
+ FSServer *svr;
+ char *pattern;
+ int maxNames;
+ int *actualCount;
+{
+ long nbytes;
+ int i,
+ length;
+ char **clist;
+ char *c;
+ fsListCataloguesReply rep;
+ fsListCataloguesReq *req;
+ long rlen;
+
+ GetReq(ListCatalogues, req);
+ req->maxNames = maxNames;
+ nbytes = req->nbytes = pattern ? strlen(pattern) : 0;
+ req->length += (nbytes + 3) >> 2;
+ _FSSend(svr, pattern, nbytes);
+ if (!_FSReply(svr, (fsReply *) & rep,
+ (SIZEOF(fsListCataloguesReply) - SIZEOF(fsGenericReply)) >> 2, fsFalse))
+ return (char **) 0;
+
+ if (rep.num_catalogues
+#if (SIZE_MAX >> 2) <= UINT_MAX
+ && rep.num_catalogues <= SIZE_MAX/sizeof(char *)
+ && rep.length <= (SIZE_MAX>>2)
+#endif
+ ) {
+ clist = (char **)
+ FSmalloc((unsigned) rep.num_catalogues * sizeof(char *));
+ rlen = (rep.length << 2) - SIZEOF(fsListCataloguesReply);
+ c = (char *) FSmalloc((unsigned) (rlen + 1));
+
+ if ((!clist) || (!c)) {
+ if (clist)
+ FSfree((char *) clist);
+ if (c)
+ FSfree(c);
+ _FSEatData(svr, (unsigned long) rlen);
+ SyncHandle();
+ return (char **) NULL;
+ }
+ _FSReadPad(svr, c, rlen);
+ /* unpack */
+ length = *c;
+ for (i = 0; i < rep.num_catalogues; i++) {
+ clist[i] = c + 1;
+ c += length + 1;
+ length = *c;
+ *c = '\0';
+ }
+ } else {
+
+ clist = (char **) NULL;
+ }
+
+ *actualCount = rep.num_catalogues;
+ SyncHandle();
+ return clist;
+
+}
+
+int FSFreeCatalogues(list)
+ char **list;
+{
+ if (list) {
+ FSfree(list[0] - 1);
+ FSfree((char *) list);
+ }
+ return 1;
+}
diff --git a/nx-X11/lib/FS/FSListExt.c b/nx-X11/lib/FS/FSListExt.c
new file mode 100644
index 000000000..0f42f5968
--- /dev/null
+++ b/nx-X11/lib/FS/FSListExt.c
@@ -0,0 +1,125 @@
+/* $Xorg: FSListExt.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/* @(#)FSListExt.c 4.1 91/05/02
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSListExt.c,v 1.6tsi Exp $ */
+
+/*
+
+Copyright 1987, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+char **
+FSListExtensions(svr, next)
+ FSServer *svr;
+ int *next;
+{
+ fsListExtensionsReply rep;
+ char **list;
+ char *c;
+ int i,
+ length;
+ fsReq *req;
+ long rlen;
+
+ GetEmptyReq(ListExtensions, req);
+
+ if (!_FSReply(svr, (fsReply *) & rep, 0, fsFalse)) {
+ SyncHandle();
+ return (char **) NULL;
+ }
+ if (rep.nExtensions
+#if (SIZE_MAX >> 2) <= UINT_MAX
+ && rep.nExtensions <= SIZE_MAX / sizeof(char *)
+ && rep.length <= (SIZE_MAX>>2)
+#endif
+ ) {
+ list = (char **) FSmalloc((unsigned)(rep.nExtensions * sizeof(char *)));
+ rlen = (rep.length << 2) - SIZEOF(fsListExtensionsReply);
+ c = (char *) FSmalloc((unsigned) rlen + 1);
+ if ((!list) || (!c)) {
+ if (list)
+ FSfree((char *) list);
+ if (c)
+ FSfree(c);
+ _FSEatData(svr, (unsigned long) rlen);
+ SyncHandle();
+ return (char **) NULL;
+ }
+ _FSReadPad(svr, c, rlen);
+ /*
+ * unpack the strings
+ */
+ length = *c;
+ for (i = 0; i < rep.nExtensions; i++) {
+ list[i] = c + 1; /* skip length */
+ c += length + 1; /* find next length */
+ length = *c;
+ *c = '\0'; /* change length to NULL */
+ }
+ } else {
+ list = (char **) NULL;
+ }
+ SyncHandle();
+ *next = rep.nExtensions;
+ return list;
+
+}
+
+int FSFreeExtensionList(list)
+ char **list;
+{
+ if (list != NULL) {
+ FSfree(list[0] - 1);
+ FSfree((char *) list);
+ }
+ return 1;
+}
diff --git a/nx-X11/lib/FS/FSMisc.c b/nx-X11/lib/FS/FSMisc.c
new file mode 100644
index 000000000..af0e78ce1
--- /dev/null
+++ b/nx-X11/lib/FS/FSMisc.c
@@ -0,0 +1,64 @@
+/* $Xorg: FSMisc.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/* @(#)FSMisc.c 4.1 91/05/02
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+long
+FSMaxRequestSize(svr)
+ FSServer *svr;
+{
+ return svr->max_request_size;
+}
diff --git a/nx-X11/lib/FS/FSNextEv.c b/nx-X11/lib/FS/FSNextEv.c
new file mode 100644
index 000000000..69e009db3
--- /dev/null
+++ b/nx-X11/lib/FS/FSNextEv.c
@@ -0,0 +1,79 @@
+/* $Xorg: FSNextEv.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/* @(#)FSNextEv.c 4.1 91/05/02
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+extern _FSQEvent *_FSqfree;
+
+int FSNextEvent(svr, event)
+ FSServer *svr;
+ FSEvent *event;
+{
+ _FSQEvent *qelt;
+
+ if (svr->head == NULL)
+ _FSReadEvents(svr);
+ qelt = svr->head;
+ *event = qelt->event;
+
+ if ((svr->head = qelt->next) == NULL)
+ svr->tail = NULL;
+ qelt->next = _FSqfree;
+ _FSqfree = qelt;
+ svr->qlen--;
+
+ return 1;
+}
diff --git a/nx-X11/lib/FS/FSOpenFont.c b/nx-X11/lib/FS/FSOpenFont.c
new file mode 100644
index 000000000..da6889a53
--- /dev/null
+++ b/nx-X11/lib/FS/FSOpenFont.c
@@ -0,0 +1,92 @@
+/* $Xorg: FSOpenFont.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSOpenFont.c,v 1.6tsi Exp $ */
+
+/*
+
+Copyright 1987, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+Font
+FSOpenBitmapFont(svr, hint, fmask, name, otherid)
+ FSServer *svr;
+ FSBitmapFormat hint;
+ FSBitmapFormatMask fmask;
+ char *name;
+ Font *otherid;
+{
+ unsigned int nbytes;
+ fsOpenBitmapFontReq *req;
+ fsOpenBitmapFontReply reply;
+ Font fid;
+ char buf[256];
+
+ nbytes = name ? strlen(name) : 0;
+ if (nbytes > 255) return 0;
+ GetReq(OpenBitmapFont, req);
+ buf[0] = nbytes;
+ memcpy(&buf[1], name, nbytes);
+ nbytes++;
+ req->fid = fid = svr->resource_id++;
+ req->format_hint = hint;
+ req->format_mask = fmask;
+ req->length += (nbytes + 3) >> 2;
+ _FSSend(svr, buf, (long) nbytes);
+ if (!_FSReply(svr, (fsReply *) & reply,
+ (SIZEOF(fsOpenBitmapFontReply)-SIZEOF(fsGenericReply)) >> 2,
+ fsFalse))
+ return 0;
+ *otherid = reply.otherid;
+ SyncHandle();
+ return fid;
+}
diff --git a/nx-X11/lib/FS/FSOpenServ.c b/nx-X11/lib/FS/FSOpenServ.c
new file mode 100644
index 000000000..662577945
--- /dev/null
+++ b/nx-X11/lib/FS/FSOpenServ.c
@@ -0,0 +1,291 @@
+/* $Xorg: FSOpenServ.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/* @(#)FSOpenServ.c 4.1 91/05/02
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSOpenServ.c,v 1.8tsi Exp $ */
+
+/*
+
+Copyright 1987, 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.
+
+*/
+
+/*
+ * does initial handshake w/ font server
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "FSlibint.h"
+#include <X11/Xtrans/Xtrans.h>
+
+int _FSdebug = 0;
+
+static fsReq _dummy_request = {
+ 0, 0, 0
+};
+
+static void OutOfMemory ( FSServer *svr, char *setup );
+
+FSServer *_FSHeadOfServerList = NULL;
+
+void _FSFreeServerStructure(svr)
+ FSServer *svr;
+{
+ if (svr->server_name)
+ FSfree(svr->server_name);
+ if (svr->vendor)
+ FSfree(svr->vendor);
+
+ if (svr->buffer)
+ FSfree(svr->buffer);
+
+ FSfree((char *) svr);
+}
+
+static
+void OutOfMemory(svr, setup)
+ FSServer *svr;
+ char *setup;
+{
+
+ _FSDisconnectServer(svr->trans_conn);
+ _FSFreeServerStructure(svr);
+ FSfree(setup);
+ errno = ENOMEM;
+}
+
+/*
+ * connects to a server, makes a FSServer object and returns a pointer
+ * to it
+ */
+
+FSServer *
+FSOpenServer(server)
+ char *server;
+{
+ FSServer *svr;
+ int i;
+ int endian;
+ fsConnClientPrefix client;
+ fsConnSetup prefix;
+ char *setup;
+ fsConnSetupAccept conn;
+ char *auth_data;
+ char *alt_data,
+ *ad;
+ AlternateServer *alts;
+ int altlen;
+ char *vendor_string;
+ unsigned long setuplength;
+
+ if (server == NULL || *server == '\0') {
+ if ((server = getenv("FONTSERVER")) == NULL) {
+ return (FSServer *) NULL;
+ }
+ }
+
+ if ((svr = (FSServer *) FScalloc(1, sizeof(FSServer))) == NULL) {
+ errno = ENOMEM;
+ return (FSServer *) NULL;
+ }
+ if ((svr->trans_conn = _FSConnectServer(server)) == NULL) {
+ FSfree((char *) svr);
+ return (FSServer *) NULL;
+ }
+
+ svr->fd = _FSTransGetConnectionNumber (svr->trans_conn);
+
+ endian = 1;
+ if (*(char *) &endian)
+ client.byteOrder = 'l';
+ else
+ client.byteOrder = 'B';
+ client.major_version = FS_PROTOCOL;
+ client.minor_version = FS_PROTOCOL_MINOR;
+/* XXX -- fix this when we have some auths */
+ client.num_auths = 0;
+ client.auth_len = 0;
+ _FSSendClientPrefix(svr, &client);
+
+/* see if connection was accepted */
+ _FSRead(svr, (char *) &prefix, (long) SIZEOF(fsConnSetup));
+
+ setuplength = prefix.alternate_len << 2;
+ if (setuplength > (SIZE_MAX>>2)
+ || (alt_data = (char *)
+ (setup = FSmalloc((unsigned) setuplength))) == NULL) {
+ errno = ENOMEM;
+ FSfree((char *) svr);
+ return (FSServer *) NULL;
+ }
+ _FSRead(svr, (char *) alt_data, setuplength);
+ ad = alt_data;
+
+#if SIZE_MAX <= UINT_MAX
+ if (prefix.num_alternates > SIZE_MAX / sizeof(AlternateServer)) {
+ errno = ENOMEM;
+ FSfree((char *) alt_data);
+ FSfree((char *) svr);
+ return (FSServer *) 0;
+ }
+#endif
+
+ alts = (AlternateServer *)
+ FSmalloc(sizeof(AlternateServer) * prefix.num_alternates);
+ if (!alts) {
+ errno = ENOMEM;
+ FSfree((char *) alt_data);
+ FSfree((char *) svr);
+ return (FSServer *) 0;
+ }
+ for (i = 0; i < prefix.num_alternates; i++) {
+ alts[i].subset = (Bool) *ad++;
+ altlen = (int) *ad++;
+ alts[i].name = (char *) FSmalloc(altlen + 1);
+ if (!alts[i].name) {
+ while (--i) {
+ FSfree((char *) alts[i].name);
+ }
+ FSfree((char *) alts);
+ FSfree((char *) alt_data);
+ FSfree((char *) svr);
+ errno = ENOMEM;
+ return (FSServer *) 0;
+ }
+ bcopy(ad, alts[i].name, altlen);
+ alts[i].name[altlen] = '\0';
+ ad += altlen + ((4 - (altlen + 2)) & 3);
+ }
+ FSfree((char *) alt_data);
+
+ svr->alternate_servers = alts;
+ svr->num_alternates = prefix.num_alternates;
+
+ setuplength = prefix.auth_len << 2;
+ if (setuplength > (SIZE_MAX>>2)
+ || (auth_data = (char *)
+ (setup = FSmalloc((unsigned) setuplength))) == NULL) {
+ errno = ENOMEM;
+ FSfree((char *) alts);
+ FSfree((char *) svr);
+ return (FSServer *) NULL;
+ }
+ _FSRead(svr, (char *) auth_data, setuplength);
+
+ if (prefix.status != AuthSuccess) {
+ fprintf(stderr, "%s: connection to \"%s\" refused by server\r\n%s: ",
+ "FSlib", server, "FSlib");
+ FSfree((char *) alts);
+ FSfree((char *) svr);
+ FSfree(setup);
+ return (FSServer *) NULL;
+ }
+ /* get rest */
+ _FSRead(svr, (char *) &conn, (long) SIZEOF(fsConnSetupAccept));
+
+ if ((vendor_string = (char *)
+ FSmalloc((unsigned) conn.vendor_len + 1)) == NULL) {
+ errno = ENOMEM;
+ FSfree((char *) auth_data);
+ FSfree((char *) alts);
+ FSfree((char *) svr);
+ return (FSServer *) NULL;
+ }
+ _FSReadPad(svr, (char *) vendor_string, conn.vendor_len);
+
+ /* move the data into the FSServer struct */
+ svr->next = (FSServer *) NULL;
+ svr->proto_version = prefix.major_version;
+ svr->release = conn.release_number;
+ svr->max_request_size = conn.max_request_len;
+
+ svr->event_vec[FS_Error] = _FSUnknownWireEvent;
+ svr->event_vec[FS_Reply] = _FSUnknownWireEvent;
+ svr->wire_vec[FS_Error] = _FSUnknownNativeEvent;
+ svr->wire_vec[FS_Reply] = _FSUnknownNativeEvent;
+ for (i = FSLASTEvent; i < 128; i++) {
+ svr->event_vec[i] = _FSUnknownWireEvent;
+ svr->wire_vec[i] = _FSUnknownNativeEvent;
+ }
+ svr->resource_id = 1;
+
+ svr->vendor = vendor_string;
+ svr->vendor[conn.vendor_len] = '\0';
+
+ svr->vnumber = FS_PROTOCOL;
+ svr->request = 0;
+ svr->last_request_read = 0;
+ svr->last_req = (char *) &_dummy_request;
+
+ if ((svr->server_name = FSmalloc((unsigned) (strlen(server) + 1)))
+ == NULL) {
+ OutOfMemory(svr, setup);
+ return (FSServer *) NULL;
+ }
+ (void) strcpy(svr->server_name, server);
+
+ /* setup the output buffers */
+ if ((svr->bufptr = svr->buffer = FSmalloc(BUFSIZE)) == NULL) {
+ OutOfMemory(svr, setup);
+ return (FSServer *) NULL;
+ }
+ svr->bufmax = svr->buffer + BUFSIZE;
+
+ /* set up input event queue */
+ svr->head = svr->tail = NULL;
+ svr->qlen = 0;
+
+ FSfree(setup);
+
+ (void) FSSynchronize(svr, _FSdebug);
+
+ svr->next = _FSHeadOfServerList;
+ _FSHeadOfServerList = svr;
+
+ return (svr);
+}
diff --git a/nx-X11/lib/FS/FSQGlyphs.c b/nx-X11/lib/FS/FSQGlyphs.c
new file mode 100644
index 000000000..5ba2eb0f7
--- /dev/null
+++ b/nx-X11/lib/FS/FSQGlyphs.c
@@ -0,0 +1,214 @@
+/* $Xorg: FSQGlyphs.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSQGlyphs.c,v 1.5tsi 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+int
+FSQueryXBitmaps8(svr, fid, format, range_type, str, str_len, offsets, glyphdata)
+ FSServer *svr;
+ Font fid;
+ FSBitmapFormat format;
+ Bool range_type;
+ unsigned char *str;
+ unsigned long str_len;
+ FSOffset **offsets;
+ unsigned char **glyphdata;
+{
+ fsQueryXBitmaps8Req *req;
+ fsQueryXBitmaps8Reply reply;
+ FSOffset *offs;
+ fsOffset32 local_offs;
+ unsigned char *gd;
+ int left;
+ int i;
+
+ GetReq(QueryXBitmaps8, req);
+ req->fid = fid;
+ req->range = range_type;
+ req->format = format;
+ req->num_ranges = str_len;
+ req->length += (str_len + 3) >> 2;
+ _FSSend(svr, (char *) str, str_len);
+
+ /* get back the info */
+ if (!_FSReply(svr, (fsReply *) & reply,
+ (SIZEOF(fsQueryXBitmaps8Reply) - SIZEOF(fsGenericReply)) >> 2, fsFalse))
+ return FSBadAlloc;
+
+#if SIZE_MAX <= UINT_MAX
+ if (reply.num_chars > SIZE_MAX / sizeof(FSOffset))
+ return FSBadAlloc;
+#endif
+
+ offs = (FSOffset *) FSmalloc(sizeof(FSOffset) * reply.num_chars);
+ *offsets = offs;
+ if (!offs)
+ return FSBadAlloc;
+#if (SIZE_MAX >> 2) <= UINT_MAX
+ /* XXX This thest is incomplete */
+ if (reply.length > (SIZE_MAX >> 2)) {
+ FSfree((char *) offs);
+ return FSBadAlloc;
+ }
+#endif
+ left = (reply.length << 2) - SIZEOF(fsQueryXBitmaps8Reply)
+ - (SIZEOF(fsOffset32) * reply.num_chars);
+ gd = (unsigned char *) FSmalloc(left);
+ *glyphdata = gd;
+ if (!gd) {
+ FSfree((char *) offs);
+ return FSBadAlloc;
+ }
+ for (i=0; i<reply.num_chars; i++)
+ {
+ _FSReadPad(svr, (char *) &local_offs, (SIZEOF(fsOffset32)));
+ offs->position = local_offs.position;
+ offs->length = local_offs.length;
+ offs++;
+ }
+ _FSReadPad(svr, (char *) gd, left);
+
+ SyncHandle();
+ return FSSuccess;
+}
+
+int
+FSQueryXBitmaps16(svr, fid, format, range_type, str, str_len,
+ offsets, glyphdata)
+ FSServer *svr;
+ Font fid;
+ FSBitmapFormat format;
+ Bool range_type;
+ FSChar2b *str;
+ unsigned long str_len;
+ FSOffset **offsets;
+ unsigned char **glyphdata;
+{
+ fsQueryXBitmaps16Req *req;
+ fsQueryXBitmaps16Reply reply;
+ FSOffset *offs;
+ fsOffset32 local_offs;
+ unsigned char *gd;
+ int left;
+ int i;
+
+ GetReq(QueryXBitmaps16, req);
+ req->fid = fid;
+ req->range = range_type;
+ req->format = format;
+ req->num_ranges = str_len;
+ req->length += ((str_len * SIZEOF(fsChar2b)) + 3) >> 2;
+ if (FSProtocolVersion(svr) == 1)
+ {
+ int i;
+ fsChar2b_version1 *swapped_str;
+
+ if (str_len > SIZE_MAX/SIZEOF(fsChar2b_version1))
+ return FSBadAlloc;
+ swapped_str = (fsChar2b_version1 *)
+ FSmalloc(SIZEOF(fsChar2b_version1) * str_len);
+ if (!swapped_str)
+ return FSBadAlloc;
+ for (i = 0; i < str_len; i++) {
+ swapped_str[i].low = str[i].low;
+ swapped_str[i].high = str[i].high;
+ }
+ _FSSend(svr, (char *)swapped_str, (str_len*SIZEOF(fsChar2b_version1)));
+ FSfree(swapped_str);
+ } else
+ _FSSend(svr, (char *) str, (str_len * SIZEOF(fsChar2b)));
+
+ /* get back the info */
+ if (!_FSReply(svr, (fsReply *) & reply,
+ (SIZEOF(fsQueryXBitmaps16Reply) - SIZEOF(fsGenericReply)) >> 2,
+ fsFalse))
+ return FSBadAlloc;
+
+#if SIZE_MAX <= UINT_MAX
+ if(reply.num_chars > SIZE_MAX/sizeof(FSOffset))
+ return FSBadAlloc;
+#endif
+ offs = (FSOffset *) FSmalloc(sizeof(FSOffset) * reply.num_chars);
+ *offsets = offs;
+ if (!offs)
+ return FSBadAlloc;
+#if (SIZE_MAX >> 2) <= UINT_MAX
+ /* XXX - this test is incomplete */
+ if (reply.length > (SIZE_MAX>>2)) {
+ FSfree((char *) offs);
+ return FSBadAlloc;
+ }
+#endif
+ left = (reply.length << 2) - SIZEOF(fsQueryXBitmaps16Reply)
+ - (SIZEOF(fsOffset32) * reply.num_chars);
+ gd = (unsigned char *) FSmalloc(left);
+ *glyphdata = gd;
+ if (!gd) {
+ FSfree((char *) offs);
+ return FSBadAlloc;
+ }
+ for (i=0; i<reply.num_chars; i++)
+ {
+ _FSReadPad(svr, (char *) &local_offs, (SIZEOF(fsOffset32)));
+ offs->position = local_offs.position;
+ offs->length = local_offs.length;
+ offs++;
+ }
+ _FSReadPad(svr, (char *) gd, left);
+
+ SyncHandle();
+ return FSSuccess;
+}
diff --git a/nx-X11/lib/FS/FSQXExt.c b/nx-X11/lib/FS/FSQXExt.c
new file mode 100644
index 000000000..e240d3aeb
--- /dev/null
+++ b/nx-X11/lib/FS/FSQXExt.c
@@ -0,0 +1,176 @@
+/* $Xorg: FSQXExt.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSQXExt.c,v 1.7tsi 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+static void
+_FS_convert_char_info(fsXCharInfo *src, FSXCharInfo *dst)
+{
+ dst->ascent = src->ascent;
+ dst->descent = src->descent;
+ dst->left = src->left;
+ dst->right = src->right;
+ dst->width = src->width;
+ dst->attributes = src->attributes;
+}
+
+int
+FSQueryXExtents8(svr, fid, range_type, str, str_len, extents)
+ FSServer *svr;
+ Font fid;
+ Bool range_type;
+ unsigned char *str;
+ unsigned long str_len;
+ FSXCharInfo **extents;
+{
+ fsQueryXExtents8Req *req;
+ fsQueryXExtents8Reply reply;
+ FSXCharInfo *ext;
+ fsXCharInfo local_exts;
+ int i;
+
+ GetReq(QueryXExtents8, req);
+ req->fid = fid;
+ req->range = range_type;
+ req->num_ranges = str_len;
+ req->length += (str_len + 3) >> 2;
+ _FSSend(svr, (char *) str, str_len);
+
+ /* get back the info */
+ if (!_FSReply(svr, (fsReply *) & reply,
+ (SIZEOF(fsQueryXExtents8Reply) - SIZEOF(fsGenericReply)) >> 2,
+ fsFalse))
+ return FSBadAlloc;
+
+#if SIZE_MAX <= UINT_MAX
+ if (reply.num_extents > SIZE_MAX / sizeof(FSXCharInfo))
+ return FSBadAlloc;
+#endif
+
+ ext = (FSXCharInfo *) FSmalloc(sizeof(FSXCharInfo) * reply.num_extents);
+ *extents = ext;
+ if (!ext)
+ return FSBadAlloc;
+ for (i = 0; i < reply.num_extents; i++) {
+ _FSReadPad(svr, (char *) &local_exts, SIZEOF(fsXCharInfo));
+ _FS_convert_char_info(&local_exts, &ext[i]);
+ }
+
+ SyncHandle();
+ return FSSuccess;
+}
+
+int
+FSQueryXExtents16(svr, fid, range_type, str, str_len, extents)
+ FSServer *svr;
+ Font fid;
+ Bool range_type;
+ FSChar2b *str;
+ unsigned long str_len;
+ FSXCharInfo **extents;
+{
+ fsQueryXExtents16Req *req;
+ fsQueryXExtents16Reply reply;
+ FSXCharInfo *ext;
+ fsXCharInfo local_exts;
+ int i;
+
+ GetReq(QueryXExtents16, req);
+ req->fid = fid;
+ req->range = range_type;
+ req->num_ranges = str_len;
+ req->length += ((str_len * SIZEOF(fsChar2b)) + 3) >> 2;
+ if (FSProtocolVersion(svr) == 1)
+ {
+ fsChar2b_version1 *swapped_str;
+
+ swapped_str = (fsChar2b_version1 *)
+ FSmalloc(SIZEOF(fsChar2b_version1) * str_len);
+ if (!swapped_str)
+ return FSBadAlloc;
+ for (i = 0; i < str_len; i++) {
+ swapped_str[i].low = str[i].low;
+ swapped_str[i].high = str[i].high;
+ }
+ _FSSend(svr, (char *)swapped_str, (str_len*SIZEOF(fsChar2b_version1)));
+ FSfree(swapped_str);
+ } else
+ _FSSend(svr, (char *) str, (str_len * SIZEOF(fsChar2b)));
+
+ /* get back the info */
+ if (!_FSReply(svr, (fsReply *) & reply,
+ (SIZEOF(fsQueryXExtents16Reply) - SIZEOF(fsGenericReply)) >> 2,
+ fsFalse))
+ return FSBadAlloc;
+
+#if SIZE_MAX <= UINT_MAX
+ if (reply.num_extents > SIZE_MAX/sizeof(FSXCharInfo))
+ return FSBadAlloc;
+#endif
+
+ ext = (FSXCharInfo *) FSmalloc(sizeof(FSXCharInfo) * reply.num_extents);
+ *extents = ext;
+ if (!ext)
+ return FSBadAlloc;
+ for (i = 0; i < reply.num_extents; i++) {
+ _FSReadPad(svr, (char *) &local_exts, SIZEOF(fsXCharInfo));
+ _FS_convert_char_info(&local_exts, &ext[i]);
+ }
+
+ SyncHandle();
+ return FSSuccess;
+}
diff --git a/nx-X11/lib/FS/FSQXInfo.c b/nx-X11/lib/FS/FSQXInfo.c
new file mode 100644
index 000000000..083f95dce
--- /dev/null
+++ b/nx-X11/lib/FS/FSQXInfo.c
@@ -0,0 +1,130 @@
+/* $Xorg: FSQXInfo.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSQXInfo.c,v 1.5tsi 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+/*
+ * Note: only the range in the first FSQuery is sent to the server.
+ * the others exist as return values only.
+ */
+
+int
+FSQueryXInfo(svr, fid, info, props, offsets, prop_data)
+ FSServer *svr;
+ Font fid;
+ FSXFontInfoHeader *info;
+ FSPropInfo *props;
+ FSPropOffset **offsets;
+ unsigned char **prop_data;
+{
+ fsQueryXInfoReq *req;
+ fsQueryXInfoReply reply;
+ FSPropOffset *offset_data;
+ unsigned char *pdata;
+ fsPropInfo local_pi;
+ fsPropOffset local_po;
+ int j;
+
+ GetReq(QueryXInfo, req);
+ req->id = fid;
+
+ /* get back the info */
+ if (!_FSReply(svr, (fsReply *) & reply, ((SIZEOF(fsQueryXInfoReply) -
+ SIZEOF(fsGenericReply)) >> 2), fsFalse)) {
+ return FSBadAlloc;
+ }
+
+ FSUnpack_XFontInfoHeader(&reply, info, FSProtocolVersion(svr));
+
+ /* get the prop header */
+ _FSReadPad(svr, (char *) &local_pi, SIZEOF(fsPropInfo));
+ props->num_offsets = local_pi.num_offsets;
+ props->data_len = local_pi.data_len;
+
+#if SIZE_MAX <= UINT_MAX
+ if (props->num_offsets > SIZE_MAX / sizeof(FSPropOffset))
+ return FSBadAlloc;
+#endif
+
+ /* prepare for prop data */
+ offset_data = (FSPropOffset *)
+ FSmalloc(props->num_offsets * sizeof(FSPropOffset));
+ if (!offset_data)
+ return FSBadAlloc;
+ pdata = (unsigned char *) FSmalloc(props->data_len);
+ if (!pdata) {
+ FSfree((char *) offset_data);
+ return FSBadAlloc;
+ }
+ /* get offsets */
+ for (j=0; j<props->num_offsets; j++)
+ {
+ _FSReadPad(svr, (char *) &local_po, SIZEOF(fsPropOffset));
+ offset_data[j].name.position = local_po.name.position;
+ offset_data[j].name.length = local_po.name.length;
+ offset_data[j].value.position = local_po.value.position;
+ offset_data[j].value.length = local_po.value.length;
+ offset_data[j].type = local_po.type;
+ }
+
+ /* get data */
+ _FSReadPad(svr, (char *) pdata, props->data_len);
+ *offsets = offset_data;
+ *prop_data = pdata;
+
+ SyncHandle();
+ return FSSuccess;
+}
diff --git a/nx-X11/lib/FS/FSQuExt.c b/nx-X11/lib/FS/FSQuExt.c
new file mode 100644
index 000000000..198bcee9f
--- /dev/null
+++ b/nx-X11/lib/FS/FSQuExt.c
@@ -0,0 +1,82 @@
+/* $Xorg: FSQuExt.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+Bool
+FSQueryExtension(svr, name, major_opcode, first_event, first_error)
+ FSServer *svr;
+ char *name;
+ int *major_opcode;
+ int *first_event;
+ int *first_error;
+{
+ fsQueryExtensionReply rep;
+ fsQueryExtensionReq *req;
+
+ GetReq(QueryExtension, req);
+ req->nbytes = name ? strlen(name) : 0;
+ req->length += (req->nbytes + 3) >> 2;
+ _FSSend(svr, name, (long) req->nbytes);
+ if (!_FSReply(svr, (fsReply *) & rep,
+ (SIZEOF(fsQueryExtensionReply) - SIZEOF(fsGenericReply)) >> 2, fsFalse))
+ return FSBadAlloc;
+ *major_opcode = rep.major_opcode;
+ *first_event = rep.first_event;
+ *first_error = rep.first_error;
+ SyncHandle();
+ return (rep.present);
+}
diff --git a/nx-X11/lib/FS/FSServName.c b/nx-X11/lib/FS/FSServName.c
new file mode 100644
index 000000000..886ffa589
--- /dev/null
+++ b/nx-X11/lib/FS/FSServName.c
@@ -0,0 +1,73 @@
+/* $Xorg: FSServName.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/* @(#)FSServName.c 4.1 91/05/02
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSServName.c,v 1.3 2001/07/29 05:01:11 tsi Exp $ */
+
+/*
+
+Copyright 1987, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xosdefs.h>
+#include <stdlib.h>
+
+char *
+FSServerName(server)
+ char *server;
+{
+ char *s;
+
+ if (server != NULL && *server != '\0')
+ return server;
+ if ((s = getenv("FONTSERVER")) != NULL)
+ return s;
+ return NULL;
+}
diff --git a/nx-X11/lib/FS/FSSetCats.c b/nx-X11/lib/FS/FSSetCats.c
new file mode 100644
index 000000000..194ce457b
--- /dev/null
+++ b/nx-X11/lib/FS/FSSetCats.c
@@ -0,0 +1,94 @@
+/* $Xorg: FSSetCats.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/* @(#)FSFlush.c 4.1 91/05/02
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSSetCats.c,v 1.4 2001/01/17 19:41:28 dawes Exp $ */
+
+/*
+
+Copyright 1987, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+int
+FSSetCatalogues(svr, num, cats)
+ FSServer *svr;
+ int num;
+ char **cats;
+{
+ int nbytes;
+ fsSetCataloguesReq *req;
+ char buf[256];
+ int i;
+ int len, tlen, tnum;
+
+ for (i = 0, tnum = 0, len = 0; i < num; i++) {
+ if ((tlen = strlen(cats[i])) < 256) {
+ len += tlen;
+ tnum++;
+ }
+ }
+
+ GetReq(SetCatalogues, req);
+ req->num_catalogues = tnum;
+ req->length += (len + 3) >> 2;
+
+ for (i = 0; i < num; i++) {
+ nbytes = strlen(cats[i]);
+ if (nbytes < 256) {
+ buf[0] = nbytes;
+ memcpy(&buf[1], cats[i], nbytes);
+ nbytes++;
+ _FSSend(svr, buf, (long) nbytes);
+ }
+ }
+ SyncHandle();
+ return FSSuccess;
+}
diff --git a/nx-X11/lib/FS/FSSync.c b/nx-X11/lib/FS/FSSync.c
new file mode 100644
index 000000000..eefd0318c
--- /dev/null
+++ b/nx-X11/lib/FS/FSSync.c
@@ -0,0 +1,81 @@
+/* $Xorg: FSSync.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlibint.h"
+
+extern _FSQEvent *_FSqfree;
+
+/* synchronize with errors and events */
+
+int FSSync(svr, discard)
+ FSServer *svr;
+ Bool discard;
+{
+ fsListExtensionsReply rep;
+ fsReq *req;
+
+ GetEmptyReq(ListExtensions, req);
+ (void) _FSReply(svr, (fsReply *) & rep, 0, fsTrue);
+
+ if (discard && svr->head) {
+ ((_FSQEvent *) svr->tail)->next = _FSqfree;
+ _FSqfree = (_FSQEvent *) svr->head;
+ svr->head = svr->tail = NULL;
+ svr->qlen = 0;
+ }
+
+ return 1;
+}
diff --git a/nx-X11/lib/FS/FSSynchro.c b/nx-X11/lib/FS/FSSynchro.c
new file mode 100644
index 000000000..c1c2d31a4
--- /dev/null
+++ b/nx-X11/lib/FS/FSSynchro.c
@@ -0,0 +1,91 @@
+/* $Xorg: FSSynchro.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/* @(#)FSSynchro.c 4.1 91/05/02
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSSynchro.c,v 1.4 2001/01/17 19:41:28 dawes Exp $ */
+
+/*
+
+Copyright 1987, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "FSlib.h"
+#include "FSlibint.h"
+
+static int
+_FSSyncFunction(FSServer *svr)
+{
+
+ return FSSync(svr, 0);
+}
+
+FSSyncHandler
+FSSynchronize(FSServer *svr, int onoff)
+{
+ FSSyncHandler temp;
+
+ temp = svr->synchandler;
+ if (onoff)
+ svr->synchandler = _FSSyncFunction;
+ else
+ svr->synchandler = NULL;
+ return temp;
+}
+
+FSSyncHandler
+FSSetAfterFunction(svr, func)
+ FSServer *svr;
+ FSSyncHandler func;
+{
+ FSSyncHandler temp;
+
+ temp = svr->synchandler;
+ svr->synchandler = func;
+ return temp;
+}
diff --git a/nx-X11/lib/FS/FSlib.h b/nx-X11/lib/FS/FSlib.h
new file mode 100644
index 000000000..c2719f803
--- /dev/null
+++ b/nx-X11/lib/FS/FSlib.h
@@ -0,0 +1,313 @@
+/* $Xorg: FSlib.h,v 1.5 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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.
+ */
+/* $XFree86: xc/lib/FS/FSlib.h,v 1.6 2001/12/14 19:53:33 dawes Exp $ */
+
+/*
+
+Copyright 1987, 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.
+
+*/
+
+/*
+ * Font server C interface library
+ */
+
+#ifndef _FSLIB_H_
+#define _FSLIB_H_
+
+#include <X11/Xfuncproto.h>
+
+#include <X11/fonts/FS.h>
+#include <X11/fonts/FSproto.h>
+
+#define Bool int
+#define Status int
+#define True 1
+#define False 0
+
+#define QueuedAlready 0
+#define QueuedAfterReading 1
+#define QueuedAfterFlush 2
+
+#define FSServerString(svr) ((svr)->server_name)
+#define FSVendorRelease(svr) ((svr)->release)
+#define FSProtocolVersion(svr) ((svr)->proto_version)
+#define FSServerVendor(svr) ((svr)->vendor)
+#define FSAuthorizationData(svr) ((svr)->auth_data)
+#define FSAlternateServers(svr) ((svr)->alternate_servers)
+#define FSNumAlternateServers(svr) ((svr)->num_alternates)
+#define FSQLength(svr) ((svr)->qlen)
+#define FSNextRequest(svr) ((svr)->request + 1)
+#define FSLastKnownRequestProcessed(svr) ((svr)->last_request_read)
+
+#define FSAllocID(svr) ((*(svr)->resource_alloc)((svr)))
+
+typedef struct _alternate {
+ Bool subset;
+ char *name;
+} AlternateServer;
+
+/* extension stuff */
+typedef struct _FSExtData {
+ int number; /* number returned by FSRegisterExtension */
+ struct _FSExtData *next; /* next item on list of data for structure */
+ int (*free_private) (char *); /* called to free private storage */
+ char *private_data; /* data private to this extension. */
+} FSExtData;
+
+
+typedef struct { /* public to extension, cannot be changed */
+ int extension; /* extension number */
+ int major_opcode; /* major op-code assigned by server */
+ int first_event; /* first event number for the extension */
+ int first_error; /* first error number for the extension */
+} FSExtCodes;
+
+typedef struct _FSServer FSServer;
+typedef union _FSEvent FSEvent;
+
+typedef struct _FSExtent {
+ struct _FSExtent *next; /* next in list */
+ FSExtCodes codes; /* public information, all extension told */
+ int (*close_server) (FSServer *, FSExtCodes *); /* routine to call when connection
+ * closed */
+ int (*error) (FSServer *, fsError *, FSExtCodes *, int *); /* who to call when an error occurs */
+ int (*error_string) (FSServer *, int, FSExtCodes *, char *, int); /* routine to supply error string */
+ char *name;
+} _FSExtension;
+
+typedef int (*FSSyncHandler)(FSServer *);
+
+/* server data structure */
+struct _FSServer {
+ struct _FSServer *next;
+ int fd;
+ int proto_version;
+ char *vendor;
+ int byte_order;
+ int vnumber;
+ int release;
+ int resource_id;
+ struct _FSQEvent *head,
+ *tail;
+ int qlen;
+ unsigned long last_request_read;
+ unsigned long request;
+ char *last_req;
+ char *buffer;
+ char *bufptr;
+ char *bufmax;
+ unsigned max_request_size;
+ char *server_name;
+ char *auth_data;
+ AlternateServer *alternate_servers;
+ int num_alternates;
+ FSExtData *ext_data;
+ _FSExtension *ext_procs;
+ int ext_number;
+ Bool (*event_vec[132]) (FSServer *, FSEvent *, fsEvent *);
+ Status (*wire_vec[132]) (FSServer *, FSEvent *, fsEvent *);
+ char *scratch_buffer;
+ unsigned long scratch_length;
+ FSSyncHandler synchandler;
+ unsigned long flags;
+ struct _XtransConnInfo *trans_conn; /* transport connection object */
+};
+
+typedef struct {
+ int type;
+ unsigned long serial;
+ Bool send_event;
+ FSServer *server;
+} FSAnyEvent;
+
+typedef struct {
+ int type;
+ FSServer *server;
+ FSID resourceid;
+ unsigned long serial;
+ unsigned char error_code;
+ unsigned char request_code;
+ unsigned char minor_code;
+} FSErrorEvent;
+
+union _FSEvent {
+ int type;
+ FSAnyEvent fsany;
+};
+
+typedef struct _FSQEvent {
+ struct _FSQEvent *next;
+ FSEvent event;
+} _FSQEvent;
+
+
+/* protocol-related stuctures */
+
+typedef unsigned long FSBitmapFormat;
+typedef unsigned long FSBitmapFormatMask;
+
+typedef struct _FSChar2b {
+ unsigned char high;
+ unsigned char low;
+} FSChar2b;
+
+typedef struct _FSRange {
+ FSChar2b min_char;
+ FSChar2b max_char;
+} FSRange;
+
+typedef struct _FSOffset {
+ unsigned int position;
+ unsigned int length;
+} FSOffset;
+
+/* use names as in xCharInfo? */
+typedef struct _FSXCharInfo {
+ short left;
+ short right;
+ short width;
+ short ascent;
+ short descent;
+ unsigned short attributes;
+} FSXCharInfo;
+
+typedef struct _FSPropOffset {
+ FSOffset name;
+ FSOffset value;
+ unsigned char type;
+} FSPropOffset;
+
+typedef struct _FSPropInfo {
+ unsigned int num_offsets;
+ unsigned int data_len;
+} FSPropInfo;
+
+/* should names match FontInfoRec? */
+typedef struct _FSXFontInfoHeader {
+ int flags;
+ FSRange char_range;
+ unsigned draw_direction;
+ FSChar2b default_char;
+ FSXCharInfo min_bounds;
+ FSXCharInfo max_bounds;
+ short font_ascent;
+ short font_descent;
+} FSXFontInfoHeader;
+
+
+
+/* function decls */
+
+_XFUNCPROTOBEGIN
+
+extern FSServer * FSOpenServer ( char *server );
+
+extern FSSyncHandler FSSynchronize(FSServer *, int);
+extern FSSyncHandler FSSetAfterFunction(FSServer *, FSSyncHandler);
+
+extern char * FSServerName ( char *server );
+extern char ** FSListExtensions ( FSServer *svr, int *next );
+extern int FSQueryExtension ( FSServer *svr, char *name, int *major_opcode,
+ int *first_event, int *first_error );
+
+extern char ** FSListCatalogues ( FSServer *svr, char *pattern,
+ int maxNames, int *actualCount );
+extern char ** FSGetCatalogues ( FSServer *svr, int *num );
+
+extern long FSMaxRequestSize ( FSServer *svr );
+
+extern char ** FSListFonts ( FSServer *svr, char *pattern, int maxNames,
+ int *actualCount );
+extern char ** FSListFontsWithXInfo ( FSServer *svr, char *pattern,
+ int maxNames, int *count,
+ FSXFontInfoHeader ***info,
+ FSPropInfo ***pprops,
+ FSPropOffset ***offsets,
+ unsigned char ***prop_data );
+extern Font FSOpenBitmapFont ( FSServer *svr, FSBitmapFormat hint,
+ FSBitmapFormatMask fmask, char *name,
+ Font *otherid );
+
+extern int FSSync ( FSServer *svr, Bool discard );
+
+extern int FSCloseServer ( FSServer *svr );
+extern int FSCloseFont ( FSServer *svr, Font fid );
+extern int FSGetErrorDatabaseText ( FSServer *svr, char *name, char *type,
+ char *defaultp, char *buffer, int nbytes );
+extern int FSGetErrorText ( FSServer *svr, int code, char *buffer,
+
+ int nbytes );
+extern int FSFlush ( FSServer *svr );
+extern int FSFreeFontNames ( char **list );
+extern int FSFreeCatalogues ( char **list );
+extern int FSFreeExtensionList ( char **list );
+extern int FSNextEvent ( FSServer *svr, FSEvent *event );
+extern int FSQueryXBitmaps8 ( FSServer *svr, Font fid, FSBitmapFormat format,
+ int range_type, unsigned char *str,
+ unsigned long str_len, FSOffset **offsets,
+ unsigned char **glyphdata );
+extern int FSQueryXBitmaps16 ( FSServer *svr, Font fid, FSBitmapFormat format,
+ int range_type, FSChar2b *str,
+ unsigned long str_len, FSOffset **offsets,
+ unsigned char **glyphdata );
+extern int FSQueryXExtents8 ( FSServer *svr, Font fid, int range_type,
+ unsigned char *str, unsigned long str_len,
+ FSXCharInfo **extents );
+extern int FSQueryXExtents16 ( FSServer *svr, Font fid, int range_type,
+ FSChar2b *str, unsigned long str_len,
+ FSXCharInfo **extents );
+extern int FSQueryXInfo ( FSServer *svr, Font fid, FSXFontInfoHeader *info,
+ FSPropInfo *props, FSPropOffset **offsets,
+ unsigned char **prop_data );
+extern int FSSetCatalogues ( FSServer *svr, int num, char **cats );
+extern int FSFree ( char *data );
+extern unsigned char * FSMalloc ( unsigned size );
+
+_XFUNCPROTOEND
+
+#endif /* _FSLIB_H_ */
diff --git a/nx-X11/lib/FS/FSlibInt.c b/nx-X11/lib/FS/FSlibInt.c
new file mode 100644
index 000000000..3e1ac54d0
--- /dev/null
+++ b/nx-X11/lib/FS/FSlibInt.c
@@ -0,0 +1,1360 @@
+/* $Xorg: FSlibInt.c,v 1.5 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/FS/FSlibInt.c,v 3.10tsi Exp $ */
+
+/*
+ * FSlibInt.c - Internal support routines for the C subroutine
+ * interface library (FSlib).
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "FSlibint.h"
+#include <X11/Xos.h>
+
+static void _EatData32 ( FSServer *svr, unsigned long n );
+static char * _SysErrorMsg ( int n );
+
+/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ */
+#ifdef WIN32
+#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK)
+#else
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define ETEST() (errno == EAGAIN)
+#else
+#define ETEST() (errno == EWOULDBLOCK)
+#endif
+#endif
+#endif
+#ifdef WIN32
+#define ECHECK(err) (WSAGetLastError() == err)
+#define ESET(val) WSASetLastError(val)
+#else
+#ifdef ISC
+#define ECHECK(err) ((errno == err) || ETEST())
+#else
+#define ECHECK(err) (errno == err)
+#endif
+#define ESET(val) errno = val
+#endif
+
+/*
+ * The following routines are internal routines used by FSlib for protocol
+ * packet transmission and reception.
+ *
+ * FSIOError(FSServer *) will be called if any sort of system call error occurs.
+ * This is assumed to be a fatal condition, i.e., FSIOError should not return.
+ *
+ * FSError(FSServer *, FSErrorEvent *) will be called whenever an FS_Error event is
+ * received. This is not assumed to be a fatal condition, i.e., it is
+ * acceptable for this procedure to return. However, FSError should NOT
+ * perform any operations (directly or indirectly) on the DISPLAY.
+ *
+ * Routines declared with a return type of 'Status' return 0 on failure,
+ * and non 0 on success. Routines with no declared return type don't
+ * return anything. Whenever possible routines that create objects return
+ * the object they have created.
+ */
+
+_FSQEvent *_FSqfree = NULL; /* NULL _FSQEvent. */
+
+static int padlength[4] = {0, 3, 2, 1};
+
+ /*
+ * lookup table for adding padding bytes to data that is read from or written
+ * to the FS socket.
+ */
+
+static fsReq _dummy_request = {
+ 0, 0, 0
+};
+
+/*
+ * _FSFlush - Flush the FS request buffer. If the buffer is empty, no
+ * action is taken. This routine correctly handles incremental writes.
+ * This routine may have to be reworked if int < long.
+ */
+void
+_FSFlush(svr)
+ register FSServer *svr;
+{
+ register long size,
+ todo;
+ register int write_stat;
+ register char *bufindex;
+
+ size = todo = svr->bufptr - svr->buffer;
+ bufindex = svr->bufptr = svr->buffer;
+ /*
+ * While write has not written the entire buffer, keep looping until the
+ * entire buffer is written. bufindex will be incremented and size
+ * decremented as buffer is written out.
+ */
+ while (size) {
+ ESET(0);
+ write_stat = _FSTransWrite(svr->trans_conn, bufindex, (int) todo);
+ if (write_stat >= 0) {
+ size -= write_stat;
+ todo = size;
+ bufindex += write_stat;
+ } else if (ETEST()) {
+ _FSWaitForWritable(svr);
+#ifdef SUNSYSV
+ } else if (ECHECK(0)) {
+ _FSWaitForWritable(svr);
+#endif
+
+#ifdef EMSGSIZE
+ } else if (ECHECK(EMSGSIZE)) {
+ if (todo > 1)
+ todo >>= 1;
+ else
+ _FSWaitForWritable(svr);
+#endif
+ } else {
+ /* Write failed! */
+ /* errno set by write system call. */
+ (*_FSIOErrorFunction) (svr);
+ }
+ }
+ svr->last_req = (char *) &_dummy_request;
+}
+
+int
+_FSEventsQueued(svr, mode)
+ register FSServer *svr;
+ int mode;
+{
+ register BytesReadable_t len;
+ BytesReadable_t pend;
+ char buf[BUFSIZE];
+ register fsReply *rep;
+
+ if (mode == QueuedAfterFlush) {
+ _FSFlush(svr);
+ if (svr->qlen)
+ return (svr->qlen);
+ }
+ if (_FSTransBytesReadable(svr->trans_conn, &pend) < 0)
+ (*_FSIOErrorFunction) (svr);
+ if ((len = pend) < SIZEOF(fsReply))
+ return (svr->qlen); /* _FSFlush can enqueue events */
+ else if (len > BUFSIZE)
+ len = BUFSIZE;
+ len /= SIZEOF(fsReply);
+ pend = len * SIZEOF(fsReply);
+ _FSRead(svr, buf, (long) pend);
+
+ /* no space between comma and type or else macro will die */
+ STARTITERATE(rep, fsReply, buf, (len > 0), len--) {
+ if (rep->generic.type == FS_Error)
+ _FSError(svr, (fsError *) rep);
+ else /* must be an event packet */
+ _FSEnq(svr, (fsEvent *) rep);
+ }
+ ENDITERATE
+ return (svr->qlen);
+}
+
+/* _FSReadEvents - Flush the output queue,
+ * then read as many events as possible (but at least 1) and enqueue them
+ */
+void
+_FSReadEvents(svr)
+ register FSServer *svr;
+{
+ char buf[BUFSIZE];
+ BytesReadable_t pend_not_register; /* because can't "&" a register
+ * variable */
+ register BytesReadable_t pend;
+ register fsEvent *ev;
+ Bool not_yet_flushed = True;
+
+ do {
+ /* find out how much data can be read */
+ if (_FSTransBytesReadable(svr->trans_conn, &pend_not_register) < 0)
+ (*_FSIOErrorFunction) (svr);
+ pend = pend_not_register;
+
+ /*
+ * must read at least one fsEvent; if none is pending, then we'll just
+ * flush and block waiting for it
+ */
+ if (pend < SIZEOF(fsEvent)) {
+ pend = SIZEOF(fsEvent);
+ /* don't flush until we block the first time */
+ if (not_yet_flushed) {
+ int qlen = svr->qlen;
+
+ _FSFlush(svr);
+ if (qlen != svr->qlen)
+ return;
+ not_yet_flushed = False;
+ }
+ }
+ /* but we won't read more than the max buffer size */
+ if (pend > BUFSIZE)
+ pend = BUFSIZE;
+
+ /* round down to an integral number of XReps */
+ pend = (pend / SIZEOF(fsEvent)) * SIZEOF(fsEvent);
+
+ _FSRead(svr, buf, (long)pend);
+
+ /* no space between comma and type or else macro will die */
+ STARTITERATE(ev, fsEvent, buf, (pend > 0),
+ pend -= SIZEOF(fsEvent)) {
+ if (ev->type == FS_Error)
+ _FSError(svr, (fsError *) ev);
+ else /* it's an event packet; enqueue it */
+ _FSEnq(svr, ev);
+ }
+ ENDITERATE
+ } while (svr->head == NULL);
+}
+
+/*
+ * _FSRead - Read bytes from the socket taking into account incomplete
+ * reads. This routine may have to be reworked if int < long.
+ */
+void
+_FSRead(svr, data, size)
+ register FSServer *svr;
+ register char *data;
+ register long size;
+{
+ register long bytes_read;
+#if defined(SVR4) && defined(i386)
+ int num_failed_reads = 0;
+#endif
+
+ if (size == 0)
+ return;
+ ESET(0);
+ /*
+ * For SVR4 with a unix-domain connection, ETEST() after selecting
+ * readable means the server has died. To do this here, we look for
+ * two consecutive reads returning ETEST().
+ */
+ while ((bytes_read = _FSTransRead(svr->trans_conn, data, (int) size))
+ != size) {
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ data += bytes_read;
+#if defined(SVR4) && defined(i386)
+ num_failed_reads = 0;
+#endif
+ }
+ else if (ETEST()) {
+ _FSWaitForReadable(svr);
+#if defined(SVR4) && defined(i386)
+ num_failed_reads++;
+ if (num_failed_reads > 1) {
+ ESET(EPIPE);
+ (*_FSIOErrorFunction) (svr);
+ }
+#endif
+ ESET(0);
+ }
+#ifdef SUNSYSV
+ else if (ECHECK(0)) {
+ _FSWaitForReadable(svr);
+ }
+#endif
+
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ ESET(EPIPE);
+ (*_FSIOErrorFunction) (svr);
+ } else { /* bytes_read is less than 0; presumably -1 */
+ /* If it's a system call interrupt, it's not an error. */
+ if (!ECHECK(EINTR))
+ (*_FSIOErrorFunction) (svr);
+#if defined(SVR4) && defined(i386)
+ else
+ num_failed_reads = 0;
+#endif
+ }
+ }
+}
+
+#ifdef WORD64
+/*
+ * XXX This is a *really* stupid way of doing this....
+ */
+
+#define PACKBUFFERSIZE 4096
+
+
+/*
+ * _FSRead32 - Read bytes from the socket unpacking each 32 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static void
+_doFSRead32(svr, data, size, packbuffer)
+ register FSServer *svr;
+ register long *data;
+ register long size;
+ register char *packbuffer;
+{
+ long *lpack,
+ *lp;
+ long mask32 = 0x00000000ffffffff;
+ long maskw,
+ nwords,
+ i,
+ bits;
+
+ _FSReadPad(svr, packbuffer, size);
+
+ lp = data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 2;
+ bits = 32;
+
+ for (i = 0; i < nwords; i++) {
+ maskw = mask32 << bits;
+ *lp++ = (*lpack & maskw) >> bits;
+ bits = bits ^ 32;
+ if (bits) {
+ lpack++;
+ }
+ }
+}
+
+void
+_FSRead32(svr, data, len)
+ FSServer *svr;
+ long *data;
+ long len;
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nwords = (PACKBUFFERSIZE >> 2); /* bytes to CARD32 */
+
+ for (; len > nwords; len -= nwords, data += nwords) {
+ _doFSRead32(svr, data, nwords, packbuffer);
+ }
+ _doFSRead32(svr, data, len, packbuffer);
+}
+
+
+
+/*
+ * _FSRead16 - Read bytes from the socket unpacking each 16 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static void
+_doFSRead16(svr, data, size, packbuffer)
+ register FSServer *svr;
+ register short *data;
+ register long size;
+ char *packbuffer;
+{
+ long *lpack,
+ *lp;
+ long mask16 = 0x000000000000ffff;
+ long maskw,
+ nwords,
+ i,
+ bits;
+
+ _FSRead(svr, packbuffer, size); /* don't do a padded read... */
+
+ lp = (long *) data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 1; /* number of 16 bit words to be unpacked */
+ bits = 48;
+ for (i = 0; i < nwords; i++) {
+ maskw = mask16 << bits;
+ *lp++ = (*lpack & maskw) >> bits;
+ bits -= 16;
+ if (bits < 0) {
+ lpack++;
+ bits = 48;
+ }
+ }
+}
+
+void
+_FSRead16(svr, data, len)
+ FSServer *svr;
+ short *data;
+ long len;
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nwords = (PACKBUFFERSIZE >> 1); /* bytes to CARD16 */
+
+ for (; len > nwords; len -= nwords, data += nwords) {
+ _doFSRead16(svr, data, nwords, packbuffer);
+ }
+ _doFSRead16(svr, data, len, packbuffer);
+}
+
+void
+_FSRead16Pad(svr, data, size)
+ FSServer *svr;
+ short *data;
+ long size;
+{
+ int slop = (size & 3);
+ short slopbuf[3];
+
+ _FSRead16(svr, data, size);
+ if (slop > 0) {
+ _FSRead16(svr, slopbuf, 4 - slop);
+ }
+}
+
+#endif /* WORD64 */
+
+
+/*
+ * _FSReadPad - Read bytes from the socket taking into account incomplete
+ * reads. If the number of bytes is not 0 mod 32, read additional pad
+ * bytes. This routine may have to be reworked if int < long.
+ */
+void
+_FSReadPad(svr, data, size)
+ register FSServer *svr;
+ register char *data;
+ register long size;
+{
+ register long bytes_read;
+ struct iovec iov[2];
+ char pad[3];
+
+ if (size == 0)
+ return;
+ iov[0].iov_len = (int) size;
+ iov[0].iov_base = data;
+ /*
+ * The following hack is used to provide 32 bit long-word aligned padding.
+ * The [1] vector is of length 0, 1, 2, or 3, whatever is needed.
+ */
+
+ iov[1].iov_len = padlength[size & 3];
+ iov[1].iov_base = pad;
+ size += iov[1].iov_len;
+
+ ESET(0);
+ while ((bytes_read = _FSTransReadv(svr->trans_conn, iov, 2)) != size) {
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ if (iov[0].iov_len < bytes_read) {
+ int pad_bytes_read = bytes_read - iov[0].iov_len;
+ iov[1].iov_len -= pad_bytes_read;
+ iov[1].iov_base =
+ (char *)iov[1].iov_base + pad_bytes_read;
+ iov[0].iov_len = 0;
+ } else {
+ iov[0].iov_len -= bytes_read;
+ iov[0].iov_base = (char *)iov[0].iov_base + bytes_read;
+ }
+ }
+ else if (ETEST()) {
+ _FSWaitForReadable(svr);
+ ESET(0);
+ }
+#ifdef SUNSYSV
+ else if (ECHECK(0)) {
+ _FSWaitForReadable(svr);
+ }
+#endif
+
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ ESET(EPIPE);
+ (*_FSIOErrorFunction) (svr);
+ } else { /* bytes_read is less than 0; presumably -1 */
+ /* If it's a system call interrupt, it's not an error. */
+ if (!ECHECK(EINTR))
+ (*_FSIOErrorFunction) (svr);
+ }
+ }
+}
+
+/*
+ * _FSSend - Flush the buffer and send the client data. 32 bit word aligned
+ * transmission is used, if size is not 0 mod 4, extra bytes are transmitted.
+ * This routine may have to be reworked if int < long;
+ */
+void
+_FSSend(svr, data, size)
+ register FSServer *svr;
+ char *data;
+ register long size;
+{
+ struct iovec iov[3];
+ static char pad[3] = {0, 0, 0};
+
+ long skip = 0;
+ long svrbufsize = (svr->bufptr - svr->buffer);
+ long padsize = padlength[size & 3];
+ long total = svrbufsize + size + padsize;
+ long todo = total;
+
+ /*
+ * There are 3 pieces that may need to be written out:
+ *
+ * o whatever is in the display buffer o the data passed in by the user o
+ * any padding needed to 32bit align the whole mess
+ *
+ * This loop looks at all 3 pieces each time through. It uses skip to figure
+ * out whether or not a given piece is needed.
+ */
+ while (total) {
+ long before = skip; /* amount of whole thing written */
+ long remain = todo; /* amount to try this time, <= total */
+ int i = 0;
+ long len;
+
+ /*
+ * You could be very general here and have "in" and "out" iovecs and
+ * write a loop without using a macro, but what the heck. This
+ * translates to:
+ *
+ * how much of this piece is new? if more new then we are trying this
+ * time, clamp if nothing new then bump down amount already written,
+ * for next piece else put new stuff in iovec, will need all of next
+ * piece
+ *
+ * Note that todo had better be at least 1 or else we'll end up writing 0
+ * iovecs.
+ */
+#define InsertIOV(pointer, length) \
+ len = (length) - before; \
+ if (len > remain) \
+ len = remain; \
+ if (len <= 0) { \
+ before = (-len); \
+ } else { \
+ iov[i].iov_len = len; \
+ iov[i].iov_base = (pointer) + before; \
+ i++; \
+ remain -= len; \
+ before = 0; \
+ }
+
+ InsertIOV(svr->buffer, svrbufsize)
+ InsertIOV(data, size)
+ InsertIOV(pad, padsize)
+
+ ESET(0);
+ if ((len = _FSTransWritev(svr->trans_conn, iov, i)) >= 0) {
+ skip += len;
+ total -= len;
+ todo = total;
+ } else if (ETEST()) {
+ _FSWaitForWritable(svr);
+#ifdef SUNSYSV
+ } else if (ECHECK(0)) {
+ _FSWaitForWritable(svr);
+#endif
+
+#ifdef EMSGSIZE
+ } else if (ECHECK(EMSGSIZE)) {
+ if (todo > 1)
+ todo >>= 1;
+ else
+ _FSWaitForWritable(svr);
+#endif
+ } else {
+ (*_FSIOErrorFunction) (svr);
+ }
+ }
+
+ svr->bufptr = svr->buffer;
+ svr->last_req = (char *) &_dummy_request;
+}
+
+#ifdef undef
+/*
+ * _FSAllocID - normal resource ID allocation routine. A client
+ * can roll his own and instatantiate it if he wants, but must
+ * follow the rules.
+ */
+FSID
+_FSAllocID(svr)
+ register FSServer *svr;
+{
+ return (svr->resource_base + (svr->resource_id++ << svr->resource_shift));
+}
+
+#endif
+
+/*
+ * The hard part about this is that we only get 16 bits from a reply. Well,
+ * then, we have three values that will march along, with the following
+ * invariant:
+ * svr->last_request_read <= rep->sequenceNumber <= svr->request
+ * The right choice for rep->sequenceNumber is the largest that
+ * still meets these constraints.
+ */
+
+unsigned long
+_FSSetLastRequestRead(svr, rep)
+ register FSServer *svr;
+ register fsGenericReply *rep;
+{
+ register unsigned long newseq,
+ lastseq;
+
+ newseq = (svr->last_request_read & ~((unsigned long) 0xffff)) |
+ rep->sequenceNumber;
+ lastseq = svr->last_request_read;
+ while (newseq < lastseq) {
+ newseq += 0x10000;
+ if (newseq > svr->request) {
+ (void) fprintf(stderr,
+ "FSlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
+ newseq, svr->request,
+ (unsigned int) rep->type);
+ newseq -= 0x10000;
+ break;
+ }
+ }
+
+ svr->last_request_read = newseq;
+ return (newseq);
+}
+
+/*
+ * _FSReply - Wait for a reply packet and copy its contents into the
+ * specified rep. Mean while we must handle error and event packets that
+ * we may encounter.
+ */
+Status
+_FSReply(svr, rep, extra, discard)
+ register FSServer *svr;
+ register fsReply *rep;
+ int extra; /* number of 32-bit words expected after the
+ * reply */
+ Bool discard; /* should I discard data followind "extra"
+ * words? */
+{
+ /*
+ * Pull out the serial number now, so that (currently illegal) requests
+ * generated by an error handler don't confuse us.
+ */
+ unsigned long cur_request = svr->request;
+ long rem_length;
+
+ _FSFlush(svr);
+ while (1) {
+ _FSRead(svr, (char *) rep, (long) SIZEOF(fsReply));
+ switch ((int) rep->generic.type) {
+
+ case FS_Reply:
+ /*
+ * Reply received. Fast update for synchronous replies, but deal
+ * with multiple outstanding replies.
+ */
+ if (rep->generic.sequenceNumber == (cur_request & 0xffff))
+ svr->last_request_read = cur_request;
+ else
+ (void) _FSSetLastRequestRead(svr, &rep->generic);
+ rem_length = rep->generic.length - (SIZEOF(fsReply) >> 2);
+ if (rem_length < 0) rem_length = 0;
+ if (extra == 0) {
+ if (discard && rem_length)
+ /* unexpectedly long reply! */
+ _EatData32(svr, rem_length);
+ return (1);
+ }
+ if (extra == rem_length) {
+ /*
+ * Read the extra data into storage immediately following the
+ * GenericReply structure.
+ */
+ _FSRead(svr, (char *) NEXTPTR(rep, fsReply), ((long) extra) << 2);
+ return (1);
+ }
+ if (extra < rem_length) {
+ /* Actual reply is longer than "extra" */
+ _FSRead(svr, (char *) NEXTPTR(rep, fsReply), ((long) extra) << 2);
+ if (discard)
+ _EatData32(svr, rem_length - extra);
+ return (1);
+ }
+ /*
+ * if we get here, then extra > rem_length -- meaning we
+ * read a reply that's shorter than we expected. This is an
+ * error, but we still need to figure out how to handle it...
+ */
+ _FSRead(svr, (char *) NEXTPTR(rep, fsReply), rem_length << 2);
+ (*_FSIOErrorFunction) (svr);
+ return (0);
+
+ case FS_Error:
+ {
+ register _FSExtension *ext;
+ register Bool ret = False;
+ int ret_code;
+ fsError err;
+ unsigned long serial;
+ long err_data;
+
+ err = *(fsError *) rep;
+ /* read the rest of the error */
+ _FSRead(svr, (char *) &err + SIZEOF(fsReply),
+ (long) (SIZEOF(fsError) - SIZEOF(fsReply)));
+ serial = _FSSetLastRequestRead(svr, (fsGenericReply *) rep);
+ if (serial == cur_request)
+ /* do not die on certain failures */
+ switch ((int) err.request) {
+ /* suck in any extra error info */
+ case FSBadResolution:
+ case FSBadLength:
+ case FSBadIDChoice:
+ case FSBadRange:
+ case FSBadFont:
+ case FSBadFormat:
+ _FSRead(svr, (char *) &err_data, 4);
+ break;
+ case FSBadAccessContext:
+ _FSRead(svr, (char *) &err_data, 4);
+ return 0;
+ case FSBadAlloc:
+ return (0);
+ /*
+ * we better see if there is an extension who may want
+ * to suppress the error.
+ */
+ default:
+ ext = svr->ext_procs;
+ while (ext) {
+ if (ext->error != NULL)
+ ret = (*ext->error)
+ (svr, &err, &ext->codes, &ret_code);
+ ext = ext->next;
+ }
+ if (ret)
+ return (ret_code);
+ break;
+ }
+ _FSError(svr, &err);
+ if (serial == cur_request)
+ return (0);
+ }
+ break;
+ default:
+ _FSEnq(svr, (fsEvent *) rep);
+ break;
+ }
+ }
+}
+
+
+/* Read and discard "n" 8-bit bytes of data */
+
+void
+_FSEatData(svr, n)
+ FSServer *svr;
+ register unsigned long n;
+{
+#define SCRATCHSIZE 2048
+ char buf[SCRATCHSIZE];
+
+ while (n > 0) {
+ register long bytes_read = (n > SCRATCHSIZE) ? SCRATCHSIZE : n;
+
+ _FSRead(svr, buf, bytes_read);
+ n -= bytes_read;
+ }
+#undef SCRATCHSIZE
+}
+
+
+/* Read and discard "n" 32-bit words. */
+
+static void
+_EatData32(svr, n)
+ FSServer *svr;
+ unsigned long n;
+{
+ _FSEatData(svr, n << 2);
+}
+
+
+/*
+ * _FSEnq - Place event packets on the display's queue.
+ * note that no squishing of move events in V11, since there
+ * is pointer motion hints....
+ */
+void
+_FSEnq(svr, event)
+ register FSServer *svr;
+ register fsEvent *event;
+{
+ register _FSQEvent *qelt;
+
+/*NOSTRICT*/
+ if ((qelt = _FSqfree) != NULL) {
+ /* If _FSqfree is non-NULL do this, else malloc a new one. */
+ _FSqfree = qelt->next;
+ } else if ((qelt =
+ (_FSQEvent *) FSmalloc((unsigned) sizeof(_FSQEvent))) == NULL) {
+ /* Malloc call failed! */
+ ESET(ENOMEM);
+ (*_FSIOErrorFunction) (svr);
+ }
+ qelt->next = NULL;
+ /* go call through display to find proper event reformatter */
+ if ((*svr->event_vec[event->type & 0177]) (svr, &qelt->event, event)) {
+ if (svr->tail)
+ svr->tail->next = qelt;
+ else
+ svr->head = qelt;
+
+ svr->tail = qelt;
+ svr->qlen++;
+ } else {
+ /* ignored, or stashed away for many-to-one compression */
+ qelt->next = _FSqfree;
+ _FSqfree = qelt;
+ }
+}
+
+/*
+ * EventToWire in seperate file in that often not needed.
+ */
+
+/*ARGSUSED*/
+Bool
+_FSUnknownWireEvent(svr, re, event)
+ register FSServer *svr; /* pointer to display structure */
+ register FSEvent *re; /* pointer to where event should be
+ * reformatted */
+ register fsEvent *event; /* wire protocol event */
+{
+
+#ifdef notdef
+ (void) fprintf(stderr,
+ "FSlib: unhandled wire event! event number = %d, display = %x\n.",
+ event->type, svr);
+#endif
+
+ return (False);
+}
+
+/*ARGSUSED*/
+Status
+_FSUnknownNativeEvent(svr, re, event)
+ register FSServer *svr; /* pointer to display structure */
+ register FSEvent *re; /* pointer to where event should be
+ * reformatted */
+ register fsEvent *event; /* wire protocol event */
+{
+
+#ifdef notdef
+ (void) fprintf(stderr,
+ "FSlib: unhandled native event! event number = %d, display = %x\n.",
+ re->type, svr);
+#endif
+
+ return (0);
+}
+
+/*
+ * reformat a wire event into an FSEvent structure of the right type.
+ */
+Bool
+_FSWireToEvent(svr, re, event)
+ register FSServer *svr; /* pointer to display structure */
+ register FSEvent *re; /* pointer to where event should be
+ * reformatted */
+ register fsEvent *event; /* wire protocol event */
+{
+
+ re->type = event->type & 0x7f;
+ ((FSAnyEvent *) re)->serial = _FSSetLastRequestRead(svr,
+ (fsGenericReply *) event);
+ ((FSAnyEvent *) re)->send_event = ((event->type & 0x80) != 0);
+ ((FSAnyEvent *) re)->server = svr;
+
+ /*
+ * Ignore the leading bit of the event type since it is set when a client
+ * sends an event rather than the server.
+ */
+
+ switch (event->type & 0177) {
+ default:
+ return (_FSUnknownWireEvent(svr, re, event));
+ }
+}
+
+
+static char *
+_SysErrorMsg(n)
+ int n;
+{
+ char *s = strerror(n);
+
+ return (s ? s : "no such error");
+}
+
+/*
+ * _FSDefaultIOError - Default fatal system error reporting routine. Called
+ * when an X internal system error is encountered.
+ */
+int
+_FSDefaultIOError(svr)
+ FSServer *svr;
+{
+ (void) fprintf(stderr,
+ "FSIO: fatal IO error %d (%s) on font server \"%s\"\r\n",
+#ifdef WIN32
+ WSAGetLastError(), strerror(WSAGetLastError()),
+#else
+
+ errno, _SysErrorMsg(errno),
+#endif
+ FSServerString(svr));
+ (void) fprintf(stderr,
+ " after %lu requests (%lu known processed) with %d events remaining.\r\n",
+ FSNextRequest(svr) - 1, FSLastKnownRequestProcessed(svr),
+ FSQLength(svr));
+
+ if (ECHECK(EPIPE)) {
+ (void) fprintf(stderr,
+ " The connection was probably broken by a server shutdown.\r\n");
+ }
+ exit(1);
+ /* NOTREACHED */
+}
+
+/*
+ * _FSError - Default non-fatal error reporting routine. Called when an
+ * FS_Error packet is encountered in the input stream.
+ */
+int
+_FSError(svr, rep)
+ FSServer *svr;
+ fsError *rep;
+{
+ FSErrorEvent event;
+
+ /*
+ * FS_Error packet encountered! We need to unpack the error before giving
+ * it to the user.
+ */
+
+ event.server = svr;
+ event.type = FS_Error;
+ event.serial = _FSSetLastRequestRead(svr, (fsGenericReply *) rep);
+ event.error_code = rep->request;
+ event.request_code = rep->major_opcode;
+ event.minor_code = rep->minor_opcode;
+ if (_FSErrorFunction != NULL) {
+ return ((*_FSErrorFunction) (svr, &event));
+ }
+ exit(1);
+ /* NOTREACHED */
+}
+
+int
+_FSPrintDefaultError(svr, event, fp)
+ FSServer *svr;
+ FSErrorEvent *event;
+ FILE *fp;
+{
+ char buffer[BUFSIZ];
+ char mesg[BUFSIZ];
+ char number[32];
+ char *mtype = "FSlibMessage";
+ register _FSExtension *ext = (_FSExtension *) NULL;
+
+ (void) FSGetErrorText(svr, event->error_code, buffer, BUFSIZ);
+ (void) FSGetErrorDatabaseText(svr, mtype, "FSError", "FS Error", mesg,
+ BUFSIZ);
+ (void) fprintf(fp, "%s: %s\n ", mesg, buffer);
+ (void) FSGetErrorDatabaseText(svr, mtype, "MajorCode",
+ "Request Major code %d", mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->request_code);
+ if (event->request_code < 128) {
+ sprintf(number, "%d", event->request_code);
+ (void) FSGetErrorDatabaseText(svr, "FSRequest", number, "", buffer,
+ BUFSIZ);
+ } else {
+ for (ext = svr->ext_procs;
+ ext && (ext->codes.major_opcode != event->request_code);
+ ext = ext->next);
+ if (ext)
+ strcpy(buffer, ext->name);
+ else
+ buffer[0] = '\0';
+ }
+ (void) fprintf(fp, " (%s)\n ", buffer);
+ (void) FSGetErrorDatabaseText(svr, mtype, "MinorCode",
+ "Request Minor code %d", mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->minor_code);
+ if (ext) {
+ sprintf(mesg, "%s.%d", ext->name, event->minor_code);
+ (void) FSGetErrorDatabaseText(svr, "FSRequest", mesg, "", buffer,
+ BUFSIZ);
+ (void) fprintf(fp, " (%s)", buffer);
+ }
+ fputs("\n ", fp);
+ (void) FSGetErrorDatabaseText(svr, mtype, "ResourceID", "ResourceID 0x%x",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n ", fp);
+ (void) FSGetErrorDatabaseText(svr, mtype, "ErrorSerial", "Error Serial #%d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->serial);
+ fputs("\n ", fp);
+ (void) FSGetErrorDatabaseText(svr, mtype, "CurrentSerial",
+ "Current Serial #%d", mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, svr->request);
+ fputs("\n", fp);
+ return 1;
+}
+
+int
+_FSDefaultError(svr, event)
+ FSServer *svr;
+ FSErrorEvent *event;
+{
+ if (_FSPrintDefaultError(svr, event, stderr) == 0)
+ return 0;
+ exit(1);
+ /* NOTREACHED */
+}
+
+
+FSIOErrorHandler _FSIOErrorFunction = _FSDefaultIOError;
+FSErrorHandler _FSErrorFunction = _FSDefaultError;
+
+/*
+ * This routine can be used to (cheaply) get some memory within a single
+ * Xlib routine for scratch space. It is reallocated from the same place
+ * each time, unless the library needs a large scratch space.
+ */
+char *
+_FSAllocScratch(svr, nbytes)
+ register FSServer *svr;
+ unsigned long nbytes;
+{
+ if (nbytes > svr->scratch_length) {
+ if (svr->scratch_buffer != NULL)
+ FSfree(svr->scratch_buffer);
+ return (svr->scratch_length = nbytes,
+ svr->scratch_buffer = FSmalloc((unsigned) nbytes));
+ }
+ return (svr->scratch_buffer);
+}
+
+int
+FSFree(data)
+ char *data;
+{
+ FSfree(data);
+ return 1;
+}
+
+unsigned char *
+FSMalloc(size)
+ unsigned size;
+{
+ return (unsigned char *) FSmalloc(size);
+}
+
+#ifdef DataRoutineIsProcedure
+void
+Data(svr, data, len)
+ FSServer *svr;
+ char *data;
+ long len;
+{
+ if (svr->bufptr + (len) <= svr->bufmax) {
+ bcopy(data, svr->bufptr, (int) len);
+ svr->bufptr += ((len) + 3) & ~3;
+ } else {
+ _FSSend(svr, data, len);
+ }
+}
+
+#endif /* DataRoutineIsProcedure */
+
+
+#ifdef WORD64
+/*
+ * XXX This is a *really* stupid way of doing this. It should just use
+ * svr->bufptr directly, taking into account where in the word it is.
+ */
+
+/*
+ * Data16 - Place 16 bit data in the buffer.
+ *
+ * "svr" is a pointer to a FSServer.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static void
+doData16(svr, data, len, packbuffer)
+ register FSServer *svr;
+ short *data;
+ unsigned len;
+ char *packbuffer;
+{
+ long *lp,
+ *lpack;
+ long i,
+ nwords,
+ bits;
+ long mask16 = 0x000000000000ffff;
+
+ lp = (long *) data;
+ lpack = (long *) packbuffer;
+ *lpack = 0;
+
+/* nwords is the number of 16 bit values to be packed,
+ * the low order 16 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 1;
+ bits = 48;
+
+ for (i = 0; i < nwords; i++) {
+ *lpack ^= (*lp & mask16) << bits;
+ bits -= 16;
+ lp++;
+ if (bits < 0) {
+ lpack++;
+ *lpack = 0;
+ bits = 48;
+ }
+ }
+ Data(svr, packbuffer, len);
+}
+
+void
+Data16(svr, data, len)
+ FSServer *svr;
+ short *data;
+ unsigned len;
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nwords = (PACKBUFFERSIZE >> 1); /* bytes to CARD16 */
+
+ for (; len > nwords; len -= nwords, data += nwords) {
+ doData16(svr, data, nwords, packbuffer);
+ }
+ doData16(svr, data, len, packbuffer);
+}
+
+/*
+ * Data32 - Place 32 bit data in the buffer.
+ *
+ * "svr" is a pointer to a FSServer.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static
+doData32(svr, data, len, packbuffer)
+ register FSServer *svr;
+ long *data;
+ unsigned len;
+ char *packbuffer;
+{
+ long *lp,
+ *lpack;
+ long i,
+ bits,
+ nwords;
+ long mask32 = 0x00000000ffffffff;
+
+ lpack = (long *) packbuffer;
+ lp = data;
+
+ *lpack = 0;
+
+/* nwords is the number of 32 bit values to be packed
+ * the low order 32 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 2;
+ bits = 32;
+
+ for (i = 0; i < nwords; i++) {
+ *lpack ^= (*lp & mask32) << bits;
+ bits = bits ^ 32;
+ lp++;
+ if (bits) {
+ lpack++;
+ *lpack = 0;
+ }
+ }
+ Data(svr, packbuffer, len);
+}
+
+void
+Data32(svr, data, len)
+ FSServer *svr;
+ short *data;
+ unsigned len;
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nwords = (PACKBUFFERSIZE >> 2); /* bytes to CARD32 */
+
+ for (; len > nwords; len -= nwords, data += nwords) {
+ doData32(svr, data, nwords, packbuffer);
+ }
+ doData32(svr, data, len, packbuffer);
+}
+
+#endif /* WORD64 */
+
+
+
+/*
+ * _FSFreeQ - free the queue of events, called by XCloseServer when there are
+ * no more displays left on the display list
+ */
+
+void
+_FSFreeQ()
+{
+ register _FSQEvent *qelt = _FSqfree;
+
+ while (qelt) {
+ register _FSQEvent *qnext = qelt->next;
+
+ FSfree(qelt);
+ qelt = qnext;
+ }
+ _FSqfree = NULL;
+ return;
+}
+
+#ifdef _POSIX_SOURCE /* stupid makedepend [need if] */
+#ifndef __QNX__ /* QNX's uname nodename entry is not same as tcpip hostname */
+#define NEED_UTSNAME
+#endif
+#endif
+#ifdef hpux
+#define NEED_UTSNAME
+#endif
+#ifdef USG
+#define NEED_UTSNAME
+#endif
+#ifdef SVR4
+#ifndef _SEQUENT_
+#define NEED_UTSNAME
+#endif
+#endif
+
+#ifdef NEED_UTSNAME
+#include <sys/utsname.h>
+#endif
+
+
+/*
+ * _FSGetHostname - similar to gethostname but allows special processing.
+ */
+int
+_FSGetHostname(buf, maxlen)
+ char *buf;
+ int maxlen;
+{
+ int len;
+
+#ifdef NEED_UTSNAME
+ /*
+ * same host name crock as in server and xinit.
+ */
+ struct utsname name;
+
+ uname(&name);
+ len = strlen(name.nodename);
+ if (len >= maxlen)
+ len = maxlen - 1;
+ strncpy(buf, name.nodename, len);
+ buf[len] = '\0';
+#else
+ buf[0] = '\0';
+ (void) gethostname(buf, maxlen);
+ buf[maxlen - 1] = '\0';
+ len = strlen(buf);
+#endif /* NEED_UTSNAME */
+
+ return len;
+}
+
+#ifndef _FSANYSET
+/*
+ * This is not always a macro.
+ */
+_FSANYSET(src)
+ long *src;
+{
+ int i;
+
+ for (i=0; i<MSKCNT; i++)
+ if (src[ i ])
+ return (1);
+ return (0);
+}
+#endif
diff --git a/nx-X11/lib/FS/FSlibint.h b/nx-X11/lib/FS/FSlibint.h
new file mode 100644
index 000000000..f042d2af0
--- /dev/null
+++ b/nx-X11/lib/FS/FSlibint.h
@@ -0,0 +1,400 @@
+/* $Xorg: FSlibint.h,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/FS/FSlibint.h,v 3.8 2003/08/29 18:01:12 herrb Exp $ */
+
+/*
+ * FSlib internal decls
+ */
+#include <X11/Xos.h>
+#include <stdio.h>
+
+/* This is all probably superfluous given Xos.h above */
+#ifdef USG
+#ifndef __TYPES__
+#include <sys/types.h> /* forgot to protect it... */
+#define __TYPES__
+#endif /* __TYPES__ */
+#else
+#if defined(_POSIX_SOURCE) && defined(MOTOROLA)
+#undef _POSIX_SOURCE
+#include <sys/types.h>
+#define _POSIX_SOURCE
+#else
+#include <sys/types.h>
+#endif
+#endif /* USG */
+
+#include "FSlib.h"
+#include "FSlibos.h"
+#include <errno.h>
+#include <stddef.h>
+
+typedef int (* FSIOErrorHandler)(FSServer *);
+typedef int (* FSErrorHandler)(FSServer *, FSErrorEvent *);
+
+extern FSIOErrorHandler _FSIOErrorFunction;
+extern FSErrorHandler _FSErrorFunction;
+
+extern void _FSEatData ( FSServer *svr, unsigned long n );
+extern void _FSWaitForWritable ( FSServer *svr );
+extern void _FSWaitForReadable ( FSServer *svr );
+extern void _FSFlush ( FSServer *svr );
+extern void _FSRead ( FSServer *svr, char *data, long size );
+extern void _FSReadEvents ( FSServer *svr );
+extern void _FSReadPad ( FSServer *svr, char *data, long size );
+extern void _FSSend ( FSServer *svr, char *data, long size );
+extern void _FSEnq ( FSServer *svr, fsEvent *event );
+extern void _FSFreeServerStructure ( FSServer *svr );
+extern int _FSError ( FSServer *svr, fsError *rep );
+extern int _FSReply ( FSServer *svr, fsReply *rep, int extra, int discard );
+extern XtransConnInfo _FSConnectServer ( char *server_name );
+extern void _FSDisconnectServer ( XtransConnInfo trans_conn );
+extern void _FSSendClientPrefix ( FSServer *svr, fsConnClientPrefix *client );
+extern int _FSEventsQueued ( FSServer *svr, int mode );
+extern unsigned long _FSSetLastRequestRead ( FSServer *svr,
+ fsGenericReply *rep );
+extern int _FSUnknownWireEvent ( FSServer *svr, FSEvent *re, fsEvent *event );
+extern int _FSUnknownNativeEvent ( FSServer *svr, FSEvent *re,
+ fsEvent *event );
+extern int _FSWireToEvent ( FSServer *svr, FSEvent *re, fsEvent *event );
+extern int _FSDefaultIOError ( FSServer *svr );
+extern int _FSPrintDefaultError ( FSServer *svr, FSErrorEvent *event,
+ FILE *fp );
+extern int _FSDefaultError ( FSServer *svr, FSErrorEvent *event );
+extern char * _FSAllocScratch ( FSServer *svr, unsigned long nbytes );
+extern void _FSFreeQ ( void );
+extern int _FSGetHostname ( char *buf, int maxlen );
+
+extern FSErrorHandler FSSetErrorHandler ( FSErrorHandler handler );
+extern FSIOErrorHandler FSSetIOErrorHandler ( FSIOErrorHandler handler );
+
+#ifndef BUFSIZE
+#define BUFSIZE 2048 /* FS output buffer size. */
+#endif
+
+/*
+ * server flags
+ */
+#define FSlibServerIOError (1L << 0)
+#define FSlibServerClosing (1L << 1)
+
+/* Need to start requests on 64 bit word boundries
+ * on a CRAY computer so add a NoOp (127) if needed.
+ * A character pointer on a CRAY computer will be non-zero
+ * after shifting right 61 bits of it is not pointing to
+ * a word boundary.
+ */
+
+#ifdef WORD64
+#define WORD64ALIGN if ((long)svr->bufptr >> 61) {\
+ svr->last_req = svr->bufptr;\
+ *(svr->bufptr) = FS_Noop;\
+ *(svr->bufptr+1) = 0;\
+ *(svr->bufptr+2) = 0;\
+ *(svr->bufptr+3) = 1;\
+ svr->request += 1;\
+ svr->bufptr += 4;\
+ }
+#else /* else does not require alignment on 64-bit
+ * boundaries */
+#define WORD64ALIGN
+#endif /* WORD64 */
+
+/*
+ * GetReq - Get the next avilable FS request packet in the buffer and
+ * return it.
+ *
+ * "name" is the name of the request, e.g. InternAtom, OpenFont, etc.
+ * "req" is the name of the request pointer.
+ *
+ */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetReq(name, req) \
+ WORD64ALIGN\
+ if ((svr->bufptr + SIZEOF(fs##name##Req)) > svr->bufmax)\
+ _FSFlush(svr);\
+ req = (fs##name##Req *)(svr->last_req = svr->bufptr);\
+ req->reqType = FS_##name;\
+ req->length = (SIZEOF(fs##name##Req))>>2;\
+ svr->bufptr += SIZEOF(fs##name##Req);\
+ svr->request++
+
+#else /* non-ANSI C uses empty comment instead of
+ * "##" for token concatenation */
+#define GetReq(name, req) \
+ WORD64ALIGN\
+ if ((svr->bufptr + SIZEOF(fs/**/name/**/Req)) > svr->bufmax)\
+ _FSFlush(svr);\
+ req = (fs/**/name/**/Req *)(svr->last_req = svr->bufptr);\
+ req->reqType = FS_/**/name;\
+ req->length = (SIZEOF(fs/**/name/**/Req))>>2;\
+ svr->bufptr += SIZEOF(fs/**/name/**/Req);\
+ svr->request++
+#endif
+
+/* GetReqExtra is the same as GetReq, but allocates "n" additional
+ bytes after the request. "n" must be a multiple of 4! */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetReqExtra(name, n, req) \
+ WORD64ALIGN\
+ if ((svr->bufptr + SIZEOF(fs##name##Req) + n) > svr->bufmax)\
+ _FSFlush(svr);\
+ req = (fs##name##Req *)(svr->last_req = svr->bufptr);\
+ req->reqType = FS_##name;\
+ req->length = (SIZEOF(fs##name##Req) + n)>>2;\
+ svr->bufptr += SIZEOF(fs##name##Req) + n;\
+ svr->request++
+#else
+#define GetReqExtra(name, n, req) \
+ WORD64ALIGN\
+ if ((svr->bufptr + SIZEOF(fs/**/name/**/Req) + n) > svr->bufmax)\
+ _FSFlush(svr);\
+ req = (fs/**/name/**/Req *)(svr->last_req = svr->bufptr);\
+ req->reqType = FS_/**/name;\
+ req->length = (SIZEOF(fs/**/name/**/Req) + n)>>2;\
+ svr->bufptr += SIZEOF(fs/**/name/**/Req) + n;\
+ svr->request++
+#endif
+
+
+/*
+ * GetResReq is for those requests that have a resource ID
+ * (Window, Pixmap, GContext, etc.) as their single argument.
+ * "rid" is the name of the resource.
+ */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetResReq(name, rid, req) \
+ WORD64ALIGN\
+ if ((svr->bufptr + SIZEOF(fsResourceReq)) > svr->bufmax)\
+ _FSFlush(svr);\
+ req = (fsResourceReq *) (svr->last_req = svr->bufptr);\
+ req->reqType = FS_##name;\
+ req->length = 2;\
+ req->id = (rid);\
+ svr->bufptr += SIZEOF(fsResourceReq);\
+ svr->request++
+#else
+#define GetResReq(name, rid, req) \
+ WORD64ALIGN\
+ if ((svr->bufptr + SIZEOF(fsResourceReq)) > svr->bufmax)\
+ _FSFlush(svr);\
+ req = (fsResourceReq *) (svr->last_req = svr->bufptr);\
+ req->reqType = FS_/**/name;\
+ req->length = 2;\
+ req->id = (rid);\
+ svr->bufptr += SIZEOF(fsResourceReq);\
+ svr->request++
+#endif
+
+/*
+ * GetEmptyReq is for those requests that have no arguments
+ * at all.
+ */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetEmptyReq(name, req) \
+ WORD64ALIGN\
+ if ((svr->bufptr + SIZEOF(fsReq)) > svr->bufmax)\
+ _FSFlush(svr);\
+ req = (fsReq *) (svr->last_req = svr->bufptr);\
+ req->reqType = FS_##name;\
+ req->length = 1;\
+ svr->bufptr += SIZEOF(fsReq);\
+ svr->request++
+#else
+#define GetEmptyReq(name, req) \
+ WORD64ALIGN\
+ if ((svr->bufptr + SIZEOF(fsReq)) > svr->bufmax)\
+ _FSFlush(svr);\
+ req = (fsReq *) (svr->last_req = svr->bufptr);\
+ req->reqType = FS_/**/name;\
+ req->length = 1;\
+ svr->bufptr += SIZEOF(fsReq);\
+ svr->request++
+#endif
+
+#define SyncHandle() \
+ if (svr->synchandler) (*svr->synchandler)(svr)
+
+/*
+ * Data - Place data in the buffer and pad the end to provide
+ * 32 bit word alignment. Transmit if the buffer fills.
+ *
+ * "svr" is a pointer to a Display.
+ * "data" is a pinter to a data buffer.
+ * "len" is the length of the data buffer.
+ * we can presume buffer less than 2^16 bytes, so bcopy can be used safely.
+ */
+
+#ifdef DataRoutineIsProcedure
+extern void Data();
+
+#else
+#define Data(svr, data, len) \
+ if (svr->bufptr + (len) <= svr->bufmax) {\
+ bcopy(data, svr->bufptr, (int)len);\
+ svr->bufptr += ((len) + 3) & ~3;\
+ } else\
+ _FSSend(svr, data, len)
+#endif /* DataRoutineIsProcedure */
+
+
+/* Allocate bytes from the buffer. No padding is done, so if
+ * the length is not a multiple of 4, the caller must be
+ * careful to leave the buffer aligned after sending the
+ * current request.
+ *
+ * "type" is the type of the pointer being assigned to.
+ * "ptr" is the pointer being assigned to.
+ * "n" is the number of bytes to allocate.
+ *
+ * Example:
+ * xTextElt *elt;
+ * BufAlloc (xTextElt *, elt, nbytes)
+ */
+
+#define BufAlloc(type, ptr, n) \
+ if (svr->bufptr + (n) > svr->bufmax) \
+ _FSFlush (svr); \
+ ptr = (type) svr->bufptr; \
+ svr->bufptr += (n);
+
+/*
+ * provide emulation routines for smaller architectures
+ */
+#ifndef WORD64
+#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define _FSRead16Pad(dpy, data, len) _FSReadPad((dpy), (char *)(data), (len))
+#define _FSRead16(dpy, data, len) _FSRead((dpy), (char *)(data), (len))
+#define _FSRead32(dpy, data, len) _FSRead((dpy), (char *)(data), (len))
+#endif /* not WORD64 */
+
+#define PackData16(dpy,data,len) Data16 (dpy, data, len)
+#define PackData32(dpy,data,len) Data32 (dpy, data, len)
+
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+
+#ifdef MUSTCOPY
+/* a little bit of magic */
+#define OneDataCard32(svr,dstaddr,srcvar) \
+ { svr->bufptr -= 4; Data32 (svr, (char *) &(srcvar), 4); }
+
+#define STARTITERATE(tpvar,type,start,endcond,decr) \
+ { register char *cpvar; \
+ for (cpvar = (char *) start; endcond; cpvar = NEXTPTR(cpvar,type), decr) { \
+ type dummy; bcopy (cpvar, (char *) &dummy, SIZEOF(type)); \
+ tpvar = (type *) cpvar;
+#define ENDITERATE }}
+
+#else
+
+/* srcvar must be a variable for large architecture version */
+#define OneDataCard32(svr,dstaddr,srcvar) \
+ { *(unsigned long *)(dstaddr) = (srcvar); }
+
+#define STARTITERATE(tpvar,type,start,endcond,decr) \
+ for (tpvar = (type *) start; endcond; tpvar++, decr) {
+#define ENDITERATE }
+#endif /* MUSTCOPY - used machines whose C structs
+ * don't line up with proto */
+
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define FSCat(x,y) x##_##y
+#else
+#define FSCat(x,y) x/**/_/**/y
+#endif
+
+/* copy XCharInfo parts of a protocol reply into a FSXCharInfo */
+
+#define FSUnpack_XCharInfo(packet, structure) \
+ (structure)->left = FSCat(packet,left); \
+ (structure)->right = FSCat(packet,right); \
+ (structure)->width = FSCat(packet,width); \
+ (structure)->ascent = FSCat(packet,ascent); \
+ (structure)->descent = FSCat(packet,descent); \
+ (structure)->attributes = FSCat(packet,attributes)
+
+
+/* copy XFontInfoHeader parts of a protocol reply into a FSXFontInfoHeader */
+
+#define FSUnpack_XFontInfoHeader(packet, structure, serverversion) \
+ (structure)->flags = (packet)->font_header_flags; \
+ (structure)->draw_direction = (packet)->font_header_draw_direction; \
+ \
+ if (serverversion > 1) { \
+ (structure)->char_range.min_char.high = (packet)->font_hdr_char_range_min_char_high; \
+ (structure)->char_range.min_char.low = (packet)->font_hdr_char_range_min_char_low; \
+ (structure)->char_range.max_char.high = (packet)->font_hdr_char_range_max_char_high; \
+ (structure)->char_range.max_char.low = (packet)->font_hdr_char_range_max_char_low; \
+ (structure)->default_char.high = (packet)->font_header_default_char_high; \
+ (structure)->default_char.low = (packet)->font_header_default_char_low; \
+ } else { \
+ (structure)->char_range.min_char.high = (packet)->font_hdr_char_range_min_char_low; \
+ (structure)->char_range.min_char.low = (packet)->font_hdr_char_range_min_char_high; \
+ (structure)->char_range.max_char.high = (packet)->font_hdr_char_range_max_char_low; \
+ (structure)->char_range.max_char.low = (packet)->font_hdr_char_range_max_char_high; \
+ (structure)->default_char.high = (packet)->font_header_default_char_low; \
+ (structure)->default_char.low = (packet)->font_header_default_char_high; \
+ } \
+ \
+ (structure)->font_ascent = (packet)->font_header_font_ascent; \
+ (structure)->font_descent = (packet)->font_header_font_descent; \
+ \
+ FSUnpack_XCharInfo((packet)->font_header_min_bounds, &(structure)->min_bounds); \
+ FSUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->max_bounds)
diff --git a/nx-X11/lib/FS/FSlibos.h b/nx-X11/lib/FS/FSlibos.h
new file mode 100644
index 000000000..d14ee8ef8
--- /dev/null
+++ b/nx-X11/lib/FS/FSlibos.h
@@ -0,0 +1,332 @@
+/* $XdotOrg: xc/lib/FS/FSlibos.h,v 1.5 2005/11/08 06:33:25 jkj Exp $ */
+/* $Xorg: FSlibos.h,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
+
+/* @(#)FSlibos.h 4.1 91/05/02
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing
+ * Devices or Digital not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Network Computing Devices or Digital make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
+ * OR 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, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/FS/FSlibos.h,v 3.10 2003/09/01 20:50:10 herrb Exp $ */
+
+/*
+ * FSlib networking & os include file
+ */
+
+#include <X11/Xfuncs.h>
+#include <X11/Xosdefs.h>
+
+#ifndef WIN32
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#include <stdint.h> /* For SIZE_MAX */
+#endif
+
+/*
+ * makedepend screws up on #undef OPEN_MAX, so we define a new symbol
+ */
+
+#ifndef FS_OPEN_MAX
+
+#ifndef X_NOT_POSIX
+#ifdef _POSIX_SOURCE
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif
+#endif
+#ifndef SIZE_MAX
+# ifdef ULONG_MAX
+# define SIZE_MAX ULONG_MAX
+# else
+# define SIZE_MAX UINT_MAX
+# endif
+#endif
+#ifndef OPEN_MAX
+#ifdef SVR4
+#define OPEN_MAX 256
+#else
+#include <sys/param.h>
+#ifndef OPEN_MAX
+#ifdef __OSF1__
+#define OPEN_MAX 256
+#else
+#ifdef NOFILE
+#define OPEN_MAX NOFILE
+#else
+#if !defined(__UNIXOS2__) && !defined(__QNX__)
+#ifdef __GNU__
+#define OPEN_MAX (sysconf(_SC_OPEN_MAX))
+#else /* !__GNU__ */
+#define OPEN_MAX NOFILES_MAX
+#endif /* __GNU__ */
+#else /* !__UNIXOS2__ && !__QNX__ */
+#define OPEN_MAX 256
+#endif /* __UNIXOS2__ */
+#endif
+#endif
+#endif
+#endif
+#endif
+
+#ifdef __GNU__
+#define FS_OPEN_MAX 256
+#else /*!__GNU__*/
+#if OPEN_MAX > 256
+#define FS_OPEN_MAX 256
+#else
+#define FS_OPEN_MAX OPEN_MAX
+#endif
+#endif /*__GNU__*/
+
+#endif /* FS_OPEN_MAX */
+
+/* Utek leaves kernel macros around in include files (bleah) */
+
+#ifdef dirty
+#undef dirty
+#endif
+
+#ifdef WORD64
+#define NMSKBITS 64
+#else
+#define NMSKBITS 32
+#endif
+
+#define MSKCNT ((FS_OPEN_MAX + NMSKBITS - 1) / NMSKBITS)
+
+#ifdef LONG64
+typedef unsigned int FdSet[MSKCNT];
+#else
+typedef unsigned long FdSet[MSKCNT];
+#endif
+
+#if (MSKCNT==1)
+#define BITMASK(i) (1 << (i))
+#define MASKIDX(i) 0
+#endif
+
+#if (MSKCNT>1)
+#define BITMASK(i) (1 << ((i) & (NMSKBITS - 1)))
+#define MASKIDX(i) ((i) / NMSKBITS)
+#endif
+
+#define MASKWORD(buf, i) buf[MASKIDX(i)]
+#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
+#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
+#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
+
+#if (MSKCNT==1)
+#define COPYBITS(src, dst) dst[0] = src[0]
+#define CLEARBITS(buf) buf[0] = 0
+#define MASKANDSETBITS(dst, b1, b2) dst[0] = (b1[0] & b2[0])
+#define ORBITS(dst, b1, b2) dst[0] = (b1[0] | b2[0])
+#define UNSETBITS(dst, b1) (dst[0] &= ~b1[0])
+#define _FSANYSET(src) (src[0])
+#endif
+
+#if (MSKCNT==2)
+#define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; }
+#define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; }
+#define MASKANDSETBITS(dst, b1, b2) {\
+ dst[0] = (b1[0] & b2[0]);\
+ dst[1] = (b1[1] & b2[1]); }
+#define ORBITS(dst, b1, b2) {\
+ dst[0] = (b1[0] | b2[0]);\
+ dst[1] = (b1[1] | b2[1]); }
+#define UNSETBITS(dst, b1) {\
+ dst[0] &= ~b1[0]; \
+ dst[1] &= ~b1[1]; }
+#define _FSANYSET(src) (src[0] || src[1])
+#endif
+
+#if (MSKCNT==3)
+#define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; \
+ dst[2] = src[2]; }
+#define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; buf[2] = 0; }
+#define MASKANDSETBITS(dst, b1, b2) {\
+ dst[0] = (b1[0] & b2[0]);\
+ dst[1] = (b1[1] & b2[1]);\
+ dst[2] = (b1[2] & b2[2]); }
+#define ORBITS(dst, b1, b2) {\
+ dst[0] = (b1[0] | b2[0]);\
+ dst[1] = (b1[1] | b2[1]);\
+ dst[2] = (b1[2] | b2[2]); }
+#define UNSETBITS(dst, b1) {\
+ dst[0] &= ~b1[0]; \
+ dst[1] &= ~b1[1]; \
+ dst[2] &= ~b1[2]; }
+#define _FSANYSET(src) (src[0] || src[1] || src[2])
+#endif
+
+#if (MSKCNT==4)
+#define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; \
+ dst[2] = src[2]; dst[3] = src[3]
+#define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0
+#define MASKANDSETBITS(dst, b1, b2) \
+ dst[0] = (b1[0] & b2[0]);\
+ dst[1] = (b1[1] & b2[1]);\
+ dst[2] = (b1[2] & b2[2]);\
+ dst[3] = (b1[3] & b2[3])
+#define ORBITS(dst, b1, b2) \
+ dst[0] = (b1[0] | b2[0]);\
+ dst[1] = (b1[1] | b2[1]);\
+ dst[2] = (b1[2] | b2[2]);\
+ dst[3] = (b1[3] | b2[3])
+#define UNSETBITS(dst, b1) \
+ dst[0] &= ~b1[0]; \
+ dst[1] &= ~b1[1]; \
+ dst[2] &= ~b1[2]; \
+ dst[3] &= ~b1[3]
+#define _FSANYSET(src) (src[0] || src[1] || src[2] || src[3])
+#endif
+
+#if (MSKCNT>4)
+#define COPYBITS(src, dst) bcopy((caddr_t) src, (caddr_t) dst, sizeof(FdSet))
+#define CLEARBITS(buf) bzero((caddr_t) buf, sizeof(FdSet))
+#define MASKANDSETBITS(dst, b1, b2) \
+ { int cri; \
+ for (cri=0; cri<MSKCNT; cri++) \
+ dst[cri] = (b1[cri] & b2[cri]) }
+#define ORBITS(dst, b1, b2) \
+ { int cri; \
+ for (cri=0; cri<MSKCNT; cri++) \
+ dst[cri] = (b1[cri] | b2[cri]) }
+#define UNSETBITS(dst, b1) \
+ { int cri; \
+ for (cri=0; cri<MSKCNT; cri++) \
+ dst[cri] &= ~b1[cri]; }
+#if (MSKCNT==8)
+#define _FSANYSET(src) (src[0] || src[1] || src[2] || src[3] || \
+ src[4] || src[5] || src[6] || src[7])
+#endif
+/*
+ * If MSKCNT>4 and not 8, then _FSANYSET is a routine defined in FSlibInt.c.
+ *
+ * #define _FSANYSET(src) (src[0] || src[1] || src[2] || src[3] || src[4] ...)
+ */
+#endif
+
+
+#else
+
+#include <X11/Xwinsock.h>
+#include <X11/Xw32defs.h>
+
+typedef fd_set FdSet;
+
+#define CLEARBITS(set) FD_ZERO(&set)
+#define BITSET(set,s) FD_SET(s,&set)
+#define _FSANYSET(set) set.fd_count
+
+#endif
+
+#include <X11/Xtrans/Xtrans.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+ * The following definitions can be used for locking requests in multi-threaded
+ * address spaces.
+ */
+#define LockDisplay(dis)
+#define LockMutex(mutex)
+#define UnlockMutex(mutex)
+#define UnlockDisplay(dis)
+#define FSfree(ptr) free((ptr))
+
+
+/*
+ * Note that some machines do not return a valid pointer for malloc(0), in
+ * which case we provide an alternate under the control of the
+ * define MALLOC_0_RETURNS_NULL. This is necessary because some
+ * FSlib code expects malloc(0) to return a valid pointer to storage.
+ */
+
+#ifdef MALLOC_0_RETURNS_NULL
+#define FSmalloc(size) malloc(((size) > 0 ? (size) : 1))
+#define FSrealloc(ptr, size) realloc((ptr), ((size) > 0 ? (size) : 1))
+#define FScalloc(nelem, elsize) calloc(((nelem) > 0 ? (nelem) : 1), (elsize))
+
+#else
+
+#define FSmalloc(size) malloc((size))
+#define FSrealloc(ptr, size) realloc((ptr), (size))
+#define FScalloc(nelem, elsize) calloc((nelem), (elsize))
+#endif
+
+/*
+ * ReadvFromServer and WritevToSever use struct iovec, normally found
+ * in Berkeley systems in <sys/uio.h>. See the readv(2) and writev(2)
+ * manual pages for details.
+ *
+ * struct iovec {
+ * caddr_t iov_base;
+ * int iov_len;
+ * };
+ */
+
+#ifdef USG
+
+#if defined(USG) && !defined(CRAY) && !defined(umips) && !defined(MOTOROLA)
+#ifndef __TIMEVAL__
+#define __TIMEVAL__
+struct timeval { /* BSD has in <sys/time.h> */
+ long tv_sec;
+ long tv_usec;
+};
+
+#endif /* __TIMEVAL__ */
+
+#endif /* not CRAY or umips */
+
+#endif /* USG */
+
+
+#define SearchString(string, char) index((string), (char))
diff --git a/nx-X11/lib/FS/Imakefile b/nx-X11/lib/FS/Imakefile
new file mode 100644
index 000000000..a1c616363
--- /dev/null
+++ b/nx-X11/lib/FS/Imakefile
@@ -0,0 +1,58 @@
+XCOMM $Xorg: Imakefile,v 1.4 2000/08/17 19:44:07 cpqbld Exp $
+XCOMM $XdotOrg: xc/lib/FS/Imakefile,v 1.4 2004/08/27 22:47:45 eich Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/FS/Imakefile,v 3.5 2001/01/17 19:41:28 dawes Exp $
+
+#define DoNormalLib NormalLibFS
+#define DoSharedLib SharedLibFS
+#define DoExtraLib SharedLibFS
+#define DoDebugLib DebugLibFS
+#define DoProfileLib ProfileLibFS
+#define LibName FS
+#define SoRev SOFSREV
+#define IncSubdir X11
+#define IncSubSubdir fonts
+
+#if Malloc0ReturnsNull
+ DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#ifdef SharedFSReqs
+REQUIREDLIBS = SharedFSReqs
+#endif
+
+DEPEND_DEFINES = $(TRANS_INCLUDES) $(CONN_DEFINES) DependDefines
+
+HEADERS = FSlib.h
+
+INCLUDES = -I$(FONTINCSRC)
+
+SRCS = FSClServ.c FSCloseFt.c FSConnServ.c FSErrDis.c FSErrHndlr.c \
+ FSFlush.c FSFontInfo.c FSFtNames.c FSGetCats.c FSListCats.c \
+ FSListExt.c FSMisc.c FSNextEv.c FSOpenFont.c FSOpenServ.c \
+ FSQGlyphs.c FSQXExt.c FSQXInfo.c FSQuExt.c FSServName.c \
+ FSSetCats.c FSSync.c FSSynchro.c FSlibInt.c transport.c
+
+OBJS = FSClServ.o FSCloseFt.o FSConnServ.o FSErrDis.o FSErrHndlr.o \
+ FSFlush.o FSFontInfo.o FSFtNames.o FSGetCats.o FSListCats.o \
+ FSListExt.o FSMisc.o FSNextEv.o FSOpenFont.o FSOpenServ.o \
+ FSQGlyphs.o FSQXExt.o FSQXInfo.o FSQuExt.o FSServName.o \
+ FSSetCats.o FSSync.o FSSynchro.o FSlibInt.o transport.o
+
+CONN_DEFINES = $(CONNECTION_FLAGS) -DFS_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES)
+#if HasBSD44Sockets
+SOCK_DEFINES = -DBSD44SOCKETS
+#endif
+
+#include <Library.tmpl>
+
+SpecialCLibObjectRule(FSlibInt,$(ICONFIGFILES),$(CONN_DEFINES))
+SpecialCLibObjectRule(FSOpenServ,$(ICONFIGFILES),$(CONN_DEFINES))
+SpecialCLibObjectRule(FSConnServ,$(ICONFIGFILES),$(CONN_DEFINES) $(SOCK_DEFINES))
+SpecialCLibObjectRule(transport,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES))
+LinkSourceFile(transport.c,$(TRANSCOMMSRC))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/GL/GL-def.cpp b/nx-X11/lib/GL/GL/GL-def.cpp
new file mode 100644
index 000000000..74549ebed
--- /dev/null
+++ b/nx-X11/lib/GL/GL/GL-def.cpp
@@ -0,0 +1,493 @@
+LIBRARY libGL
+VERSION LIBRARY_VERSION
+EXPORTS
+ glClearIndex @ 1
+ glClearColor @ 2
+ glClear @ 3
+ glIndexMask @ 4
+ glColorMask @ 5
+ glAlphaFunc @ 6
+ glBlendFunc @ 7
+ glLogicOp @ 8
+ glCullFace @ 9
+ glFrontFace @ 10
+ glPointSize @ 11
+ glLineWidth @ 12
+ glLineStipple @ 13
+ glPolygonMode @ 14
+ glPolygonStipple @ 15
+ glGetPolygonStipple @ 16
+ glEdgeFlag @ 17
+ glEdgeFlagv @ 18
+ glScissor @ 19
+ glClipPlane @ 20
+ glGetClipPlane @ 21
+ glDrawBuffer @ 22
+ glReadBuffer @ 23
+ glEnable @ 24
+ glDisable @ 25
+ glIsEnabled @ 26
+ glGetBooleanv @ 27
+ glGetDoublev @ 28
+ glGetFloatv @ 29
+ glGetIntegerv @ 30
+ glPushAttrib @ 31
+ glPopAttrib @ 32
+ glRenderMode @ 33
+ glGetError @ 34
+ glGetString @ 35
+ glFinish @ 36
+ glFlush @ 37
+ glHint @ 38
+ glClearDepth @ 39
+ glDepthFunc @ 40
+ glDepthMask @ 41
+ glDepthRange @ 42
+ glClearAccum @ 43
+ glAccum @ 44
+ glMatrixMode @ 45
+ glOrtho @ 46
+ glFrustum @ 47
+ glViewport @ 48
+ glPushMatrix @ 49
+ glPopMatrix @ 50
+ glLoadIdentity @ 51
+ glLoadMatrixd @ 52
+ glLoadMatrixf @ 53
+ glMultMatrixd @ 54
+ glMultMatrixf @ 55
+ glRotated @ 56
+ glRotatef @ 57
+ glScaled @ 58
+ glScalef @ 59
+ glTranslated @ 60
+ glTranslatef @ 61
+ glIsList @ 62
+ glDeleteLists @ 63
+ glGenLists @ 64
+ glNewList @ 65
+ glEndList @ 66
+ glCallList @ 67
+ glCallLists @ 68
+ glListBase @ 69
+ glBegin @ 70
+ glEnd @ 71
+ glVertex2d @ 72
+ glVertex2f @ 73
+ glVertex2i @ 74
+ glVertex2s @ 75
+ glVertex3d @ 76
+ glVertex3f @ 77
+ glVertex3i @ 78
+ glVertex3s @ 79
+ glVertex4d @ 80
+ glVertex4f @ 81
+ glVertex4i @ 82
+ glVertex4s @ 83
+ glVertex2dv @ 84
+ glVertex2fv @ 85
+ glVertex2iv @ 86
+ glVertex2sv @ 87
+ glVertex3dv @ 88
+ glVertex3fv @ 89
+ glVertex3iv @ 90
+ glVertex3sv @ 91
+ glVertex4dv @ 92
+ glVertex4fv @ 93
+ glVertex4iv @ 94
+ glVertex4sv @ 95
+ glNormal3b @ 96
+ glNormal3d @ 97
+ glNormal3f @ 98
+ glNormal3i @ 99
+ glNormal3s @ 100
+ glNormal3bv @ 101
+ glNormal3dv @ 102
+ glNormal3fv @ 103
+ glNormal3iv @ 104
+ glNormal3sv @ 105
+ glIndexd @ 106
+ glIndexf @ 107
+ glIndexi @ 108
+ glIndexs @ 109
+ glIndexdv @ 110
+ glIndexfv @ 111
+ glIndexiv @ 112
+ glIndexsv @ 113
+ glColor3b @ 114
+ glColor3d @ 115
+ glColor3f @ 116
+ glColor3i @ 117
+ glColor3s @ 118
+ glColor3ub @ 119
+ glColor3ui @ 120
+ glColor3us @ 121
+ glColor4b @ 122
+ glColor4d @ 123
+ glColor4f @ 124
+ glColor4i @ 125
+ glColor4s @ 126
+ glColor4ub @ 127
+ glColor4ui @ 128
+ glColor4us @ 129
+ glColor3bv @ 130
+ glColor3dv @ 131
+ glColor3fv @ 132
+ glColor3iv @ 133
+ glColor3sv @ 134
+ glColor3ubv @ 135
+ glColor3uiv @ 136
+ glColor3usv @ 137
+ glColor4bv @ 138
+ glColor4dv @ 139
+ glColor4fv @ 140
+ glColor4iv @ 141
+ glColor4sv @ 142
+ glColor4ubv @ 143
+ glColor4uiv @ 144
+ glColor4usv @ 145
+ glTexCoord1d @ 146
+ glTexCoord1f @ 147
+ glTexCoord1i @ 148
+ glTexCoord1s @ 149
+ glTexCoord2d @ 150
+ glTexCoord2f @ 151
+ glTexCoord2i @ 152
+ glTexCoord2s @ 153
+ glTexCoord3d @ 154
+ glTexCoord3f @ 155
+ glTexCoord3i @ 156
+ glTexCoord3s @ 157
+ glTexCoord4d @ 158
+ glTexCoord4f @ 159
+ glTexCoord4i @ 160
+ glTexCoord4s @ 161
+ glTexCoord1dv @ 162
+ glTexCoord1fv @ 163
+ glTexCoord1iv @ 164
+ glTexCoord1sv @ 165
+ glTexCoord2dv @ 166
+ glTexCoord2fv @ 167
+ glTexCoord2iv @ 168
+ glTexCoord2sv @ 169
+ glTexCoord3dv @ 170
+ glTexCoord3fv @ 171
+ glTexCoord3iv @ 172
+ glTexCoord3sv @ 173
+ glTexCoord4dv @ 174
+ glTexCoord4fv @ 175
+ glTexCoord4iv @ 176
+ glTexCoord4sv @ 177
+ glRasterPos2d @ 178
+ glRasterPos2f @ 179
+ glRasterPos2i @ 180
+ glRasterPos2s @ 181
+ glRasterPos3d @ 182
+ glRasterPos3f @ 183
+ glRasterPos3i @ 184
+ glRasterPos3s @ 185
+ glRasterPos4d @ 186
+ glRasterPos4f @ 187
+ glRasterPos4i @ 188
+ glRasterPos4s @ 189
+ glRasterPos2dv @ 190
+ glRasterPos2fv @ 191
+ glRasterPos2iv @ 192
+ glRasterPos2sv @ 193
+ glRasterPos3dv @ 194
+ glRasterPos3fv @ 195
+ glRasterPos3iv @ 196
+ glRasterPos3sv @ 197
+ glRasterPos4dv @ 198
+ glRasterPos4fv @ 199
+ glRasterPos4iv @ 200
+ glRasterPos4sv @ 201
+ glRectd @ 202
+ glRectf @ 203
+ glRecti @ 204
+ glRects @ 205
+ glRectdv @ 206
+ glRectfv @ 207
+ glRectiv @ 208
+ glRectsv @ 209
+ glShadeModel @ 210
+ glLightf @ 211
+ glLighti @ 212
+ glLightfv @ 213
+ glLightiv @ 214
+ glGetLightfv @ 215
+ glGetLightiv @ 216
+ glLightModelf @ 217
+ glLightModeli @ 218
+ glLightModelfv @ 219
+ glLightModeliv @ 220
+ glMaterialf @ 221
+ glMateriali @ 222
+ glMaterialfv @ 223
+ glMaterialiv @ 224
+ glGetMaterialfv @ 225
+ glGetMaterialiv @ 226
+ glColorMaterial @ 227
+ glPixelZoom @ 228
+ glPixelStoref @ 229
+ glPixelStorei @ 230
+ glPixelTransferf @ 231
+ glPixelTransferi @ 232
+ glPixelMapfv @ 233
+ glPixelMapuiv @ 234
+ glPixelMapusv @ 235
+ glGetPixelMapfv @ 236
+ glGetPixelMapuiv @ 237
+ glGetPixelMapusv @ 238
+ glBitmap @ 239
+ glReadPixels @ 240
+ glDrawPixels @ 241
+ glCopyPixels @ 242
+ glStencilFunc @ 243
+ glStencilMask @ 244
+ glStencilOp @ 245
+ glClearStencil @ 246
+ glTexGend @ 247
+ glTexGenf @ 248
+ glTexGeni @ 249
+ glTexGendv @ 250
+ glTexGenfv @ 251
+ glTexGeniv @ 252
+ glGetTexGendv @ 253
+ glGetTexGenfv @ 254
+ glGetTexGeniv @ 255
+ glTexEnvf @ 256
+ glTexEnvi @ 257
+ glTexEnvfv @ 258
+ glTexEnviv @ 259
+ glGetTexEnvfv @ 260
+ glGetTexEnviv @ 261
+ glTexParameterf @ 262
+ glTexParameteri @ 263
+ glTexParameterfv @ 264
+ glTexParameteriv @ 265
+ glGetTexParameterfv @ 266
+ glGetTexParameteriv @ 267
+ glGetTexLevelParameterfv @ 268
+ glGetTexLevelParameteriv @ 269
+ glTexImage1D @ 270
+ glTexImage2D @ 271
+ glGetTexImage @ 272
+ glMap1d @ 273
+ glMap1f @ 274
+ glMap2d @ 275
+ glMap2f @ 276
+ glGetMapdv @ 277
+ glGetMapfv @ 278
+ glGetMapiv @ 279
+ glEvalCoord1d @ 280
+ glEvalCoord1f @ 281
+ glEvalCoord1dv @ 282
+ glEvalCoord1fv @ 283
+ glEvalCoord2d @ 284
+ glEvalCoord2f @ 285
+ glEvalCoord2dv @ 286
+ glEvalCoord2fv @ 287
+ glMapGrid1d @ 288
+ glMapGrid1f @ 289
+ glMapGrid2d @ 290
+ glMapGrid2f @ 291
+ glEvalPoint1 @ 292
+ glEvalPoint2 @ 293
+ glEvalMesh1 @ 294
+ glEvalMesh2 @ 295
+ glFogf @ 296
+ glFogi @ 297
+ glFogfv @ 298
+ glFogiv @ 299
+ glFeedbackBuffer @ 300
+ glPassThrough @ 301
+ glSelectBuffer @ 302
+ glInitNames @ 303
+ glLoadName @ 304
+ glPushName @ 305
+ glPopName @ 306
+; glBlendEquationEXT @ 307
+; glBlendColorEXT @ 308
+ glPolygonOffset @ 309
+#ifndef __UNIXOS2__
+; glVertexPointerEXT @ 310
+; glNormalPointerEXT @ 311
+#else
+ glVertexPointerEXT @ 310
+ glNormalPointerEXT @ 311
+#endif
+; glColorPointerEXT @ 312
+; glIndexPointerEXT @ 313
+; glTexCoordPointerEXT @ 314
+; glEdgeFlagPointerEXT @ 315
+; glGetPointervEXT @ 316
+; glArrayElementEXT @ 317
+#ifndef __UNIXOS2__
+; glDrawArraysEXT @ 318
+#else
+ glDrawArraysEXT @ 318
+#endif
+; OSMesaCreateContext @ 319
+; OSMesaDestroyContext @ 320
+; OSMesaMakeCurrent @ 321
+; XMesaCreateContext @ 322
+; XMesaDestroyContext @ 323
+; XMesaMakeCurrent @ 326
+; XMesaGetCurrentContext @ 327
+; XMesaSwapBuffers @ 328
+; XMesaGetBackBuffer @ 329
+ glXChooseVisual @ 330
+ glXCreateContext @ 331
+ glXDestroyContext @ 332
+ glXMakeCurrent @ 333
+ glXCopyContext @ 334
+ glXSwapBuffers @ 335
+ glXCreateGLXPixmap @ 336
+ glXDestroyGLXPixmap @ 337
+ glXQueryExtension @ 338
+ glXQueryVersion @ 339
+ glXIsDirect @ 340
+ glXGetConfig @ 341
+ glXGetCurrentContext @ 342
+ glXGetCurrentDrawable @ 343
+ glXWaitGL @ 344
+ glXWaitX @ 345
+ glXUseXFont @ 346
+ glXQueryExtensionsString @ 347
+ glXQueryServerString @ 348
+ glXGetClientString @ 349
+ glPushClientAttrib @ 350
+ glPopClientAttrib @ 351
+ glIndexub @ 352
+ glIndexubv @ 353
+ glVertexPointer @ 354
+ glNormalPointer @ 355
+ glColorPointer @ 356
+ glIndexPointer @ 357
+ glTexCoordPointer @ 358
+ glEdgeFlagPointer @ 359
+ glGetPointerv @ 360
+ glArrayElement @ 361
+ glDrawArrays @ 362
+ glDrawElements @ 363
+ glInterleavedArrays @ 364
+ glGenTextures @ 365
+ glDeleteTextures @ 366
+ glBindTexture @ 367
+ glPrioritizeTextures @ 368
+ glAreTexturesResident @ 369
+ glIsTexture @ 370
+ glTexSubImage1D @ 371
+ glTexSubImage2D @ 372
+ glCopyTexImage1D @ 373
+ glCopyTexImage2D @ 374
+ glCopyTexSubImage1D @ 375
+ glCopyTexSubImage2D @ 376
+; glWindowPos2iMESA @ 377
+; glWindowPos2sMESA @ 378
+#ifndef __UNIXOS2__
+; glWindowPos2fMESA @ 379
+#else
+ glWindowPos2fMESA @ 379
+#endif
+; glWindowPos2dMESA @ 380
+; glWindowPos2ivMESA @ 381
+; glWindowPos2svMESA @ 382
+; glWindowPos2fvMESA @ 383
+; glWindowPos2dvMESA @ 384
+; glWindowPos3iMESA @ 385
+; glWindowPos3sMESA @ 386
+; glWindowPos3fMESA @ 387
+; glWindowPos3dMESA @ 388
+; glWindowPos3ivMESA @ 389
+; glWindowPos3svMESA @ 390
+; glWindowPos3fvMESA @ 391
+; glWindowPos3dvMESA @ 392
+; glWindowPos4iMESA @ 393
+; glWindowPos4sMESA @ 394
+; glWindowPos4fMESA @ 395
+; glWindowPos4dMESA @ 396
+; glWindowPos4ivMESA @ 397
+; glWindowPos4svMESA @ 398
+; glWindowPos4fvMESA @ 399
+; glWindowPos4dvMESA @ 400
+#ifndef __UNIXOS2__
+; glXCreateGLXPixmapMESA @ 401
+#else
+ glXCreateGLXPixmapMESA @ 401
+#endif
+; glXReleaseBuffersMESA @ 402
+; OSMesaGetCurrentContext @ 403
+; OSMesaPixelStore @ 404
+; OSMesaGetIntegerv @ 405
+; XMesaCreateVisual @ 406
+; XMesaDestroyVisual @ 407
+; XMesaCreateWindowBuffer @ 408
+; XMesaCreatePixmapBuffer @ 409
+; XMesaDestroyBuffer @ 410
+; XMesaGetCurrentBuffer @ 411
+; XMesaFlush @ 412
+; XMesaGetString @ 413
+; glPolygonOffsetEXT @ 414
+ glDisableClientState @ 450
+ glEnableClientState @ 451
+ glXFreeContextEXT @ 452
+ glXGetContextIDEXT @ 453
+ glXGetCurrentDisplay @ 454
+ glXImportContextEXT @ 455
+ glXQueryContextInfoEXT @ 456
+#ifndef __UNIXOS2__
+ glXGetCurrentDrawableEXT @ 457
+#endif
+ glCopyTexSubImage3D @ 458
+ glDrawRangeElements @ 459
+ glTexSubImage3D @ 460
+ glBlendColorEXT @ 461
+ glBlendEquationEXT @ 462
+ glTexImage3D @ 463
+#ifdef __UNIXOS2__
+ _glapi_Context @ 500
+ _glapi_Dispatch @ 501
+ glMultiTexCoord1svARB @ 502
+ glMultiTexCoord1ivARB @ 503
+ glMultiTexCoord1fvARB @ 504
+ glMultiTexCoord1dvARB @ 505
+ glMultiTexCoord2svARB @ 506
+ glMultiTexCoord2ivARB @ 507
+ glMultiTexCoord2fvARB @ 508
+ glMultiTexCoord2dvARB @ 509
+ glMultiTexCoord3svARB @ 510
+ glMultiTexCoord3ivARB @ 511
+ glMultiTexCoord3fvARB @ 512
+ glMultiTexCoord3dvARB @ 513
+ glMultiTexCoord4svARB @ 514
+ glMultiTexCoord4ivARB @ 515
+ glMultiTexCoord4fvARB @ 516
+ glMultiTexCoord4dvARB @ 517
+ glMultiTexCoord1fARB @ 518
+ glMultiTexCoord2fARB @ 519
+ glMultiTexCoord3fARB @ 520
+ glMultiTexCoord4fARB @ 521
+ _glapi_set_dispatch @ 522
+ _glapi_noop_enable_warnings @ 523
+ _glapi_add_entrypoint @ 524
+ _glapi_get_dispatch_table_size @ 525
+ _glapi_check_multithread @ 526
+ _glapi_set_context @ 527
+ _glapi_get_context @ 528
+ glColorTable @ 529
+ glColorSubTable @ 530
+ glConvolutionFilter1D @ 531
+ glConvolutionFilter2D @ 532
+ glXGetProcAddressARB @ 533
+ glLockArraysEXT @ 534
+ glUnlockArraysEXT @ 535
+ glActiveTextureARB @ 536
+ glColorTableEXT @ 537
+ glPointParameterfEXT @ 538
+ glPointParameterfvEXT @ 539
+ glXMakeContextCurrent @ 540
+#endif
+
+/* $XFree86: xc/lib/GL/GL/GL-def.cpp,v 1.2 2003/03/25 04:18:07 dawes Exp $ */
diff --git a/nx-X11/lib/GL/GL/Imakefile b/nx-X11/lib/GL/GL/Imakefile
new file mode 100644
index 000000000..336f3d5b7
--- /dev/null
+++ b/nx-X11/lib/GL/GL/Imakefile
@@ -0,0 +1,246 @@
+XCOMM $XFree86: xc/lib/GL/GL/Imakefile,v 1.23 2003/11/17 03:10:41 dawes Exp $
+
+#include <Threads.tmpl>
+
+#define DoNormalLib NormalLibGlx
+#define DoSharedLib SharedLibGlx
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+
+#ifndef ShLibBindGlobals
+#if !HasGcc2 || (GccMajorVersion > 2) || (GccMinorVersion > 7)
+#define ShlibBindGlobals YES
+#endif
+#endif
+
+ LIBNAME = GL
+ SOREV = $(SOGLREV)
+
+#ifdef SharedGLReqs
+BASEREQUIREDLIBS = SharedGLReqs
+#endif
+
+#include "../mesa/array_cache/Imakefile.inc"
+#include "../mesa/math/Imakefile.inc"
+#include "../mesa/swrast/Imakefile.inc"
+#include "../mesa/swrast_setup/Imakefile.inc"
+#include "../mesa/tnl/Imakefile.inc"
+#include "../mesa/tnl_dd/Imakefile.inc"
+#include "../mesa/Imakefile.inc"
+#ifdef i386Architecture
+#include "../mesa/x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../mesa/sparc/Imakefile.inc"
+#endif
+
+
+#if BuildXF86DRI && defined(i386Architecture) && MesaUseX86Asm
+ GLAPI_OBJ = $(GLXLIBSRC)/glx/glapi_x86.o
+#endif
+
+ GLXOBJS = $(GLXLIBSRC)/glx/?*.o
+ GLXUOBJS = $(GLXLIBSRC)/glx/unshared/?*.o $(GLAPI_OBJ)
+ GLXDOBJS = $(GLXLIBSRC)/glx/debugger/?*.o $(GLAPI_OBJ)
+ GLXPOBJS = $(GLXLIBSRC)/glx/profiled/?*.o $(GLAPI_OBJ)
+
+#if BuildXF86DRI
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/?*.o
+ DRMUOBJS = $(GLXLIBSRC)/dri/drm/unshared/?*.o
+ DRMDOBJS = $(GLXLIBSRC)/dri/drm/debugger/?*.o
+ DRMPOBJS = $(GLXLIBSRC)/dri/drm/profiled/?*.o
+
+ MESAOBJS = $(COREMESAOBJS) $(MESA_ASM_OBJS)
+ MESAUOBJS = $(COREMESAUOBJS) $(MESA_ASM_UOBJS)
+ MESADOBJS = $(COREMESADOBJS) $(MESA_ASM_DOBJS)
+ MESAPOBJS = $(COREMESAPOBJS) $(MESA_ASM_POBJS)
+
+#if GlxUseBuiltInDRIDriver
+#include "../mesa/drivers/dri/common/Imakefile.inc"
+#endif
+
+
+#if GlxUseSGISI
+
+XCOMM nothing
+
+#elif GlxBuiltInGamma
+
+#define MesaDrvGammaBuildDir $(GLXLIBSRC)/mesa/drivers/dri/gamma/
+#include "../mesa/drivers/dri/gamma/Imakefile.inc"
+
+ DRVOBJS = $(GAMMAOBJS) $(MESAOBJS)
+ DRVUOBJS = $(GAMMAUOBJS) $(MESAUOBJS)
+ DRVDOBJS = $(GAMMADOBJS) $(MESADOBJS)
+ DRVPOBJS = $(GAMMAPOBJS) $(MESAPOBJS)
+
+#elif GlxBuiltInTdfx
+
+#define MesaDrvTdfxBuildDir $(GLXLIBSRC)/mesa/drivers/dri/tdfx/
+#include "../mesa/drivers/dri/tdfx/Imakefile.inc"
+
+ DRVOBJS = $(TDFXOBJS) $(MESAOBJS)
+ DRVUOBJS = $(TDFXUOBJS) $(MESAUOBJS)
+ DRVDOBJS = $(TDFXDOBJS) $(MESADOBJS)
+ DRVPOBJS = $(TDFXPOBJS) $(MESAPOBJS)
+
+OTHERREQUIREDLIBS = -lglide3 -ldl
+
+#elif GlxBuiltInI810
+
+#define MesaDrvI810BuildDir $(GLXLIBSRC)/mesa/drivers/dri/i810/
+#include "../mesa/drivers/dri/i810/Imakefile.inc"
+
+ DRVOBJS = $(I810OBJS) $(COMMONOBJS) $(MESAOBJS)
+ DRVUOBJS = $(I810UOBJS) $(COMMONUOBJS) $(MESAUOBJS)
+ DRVDOBJS = $(I810DOBJS) $(COMMONDOBJS) $(MESADOBJS)
+ DRVPOBJS = $(I810POBJS) $(COMMONPOBJS) $(MESAPOBJS)
+
+#elif GlxBuiltInI915
+#define MesaDrvI915BuildDir $(GLXLIBSRC)/mesa/drivers/dri/i915/
+#include "../mesa/drivers/dri/i915/Imakefile.inc"
+
+ DRVOBJS = $(I915OBJS) $(COMMONOBJS) $(MESAOBJS)
+ DRVUOBJS = $(I915UOBJS) $(COMMONUOBJS) $(MESAUOBJS)
+ DRVDOBJS = $(I915DOBJS) $(COMMONDOBJS) $(MESADOBJS)
+ DRVPOBJS = $(I915POBJS) $(COMMONPOBJS) $(MESAPOBJS)
+
+#elif GlxBuiltInMga
+
+#define MesaDrvMgaBuildDir $(GLXLIBSRC)/mesa/drivers/dri/mga/
+#include "../mesa/drivers/dri/mga/Imakefile.inc"
+
+ DRVOBJS = $(MGAOBJS) $(COMMONOBJS) $(MESAOBJS)
+ DRVUOBJS = $(MGAUOBJS) $(COMMONUOBJS) $(MESAUOBJS)
+ DRVDOBJS = $(MGADOBJS) $(COMMONDOBJS) $(MESADOBJS)
+ DRVPOBJS = $(MGAPOBJS) $(COMMONPOBJS) $(MESAPOBJS)
+
+#elif GlxBuiltInR128
+
+#define MesaDrvR128BuildDir $(GLXLIBSRC)/mesa/drivers/dri/r128/
+#include "../mesa/drivers/dri/r128/Imakefile.inc"
+
+ DRVOBJS = $(R128OBJS) $(COMMONOBJS) $(MESAOBJS)
+ DRVUOBJS = $(R128UOBJS) $(COMMONUOBJS) $(MESAUOBJS)
+ DRVDOBJS = $(R128DOBJS) $(COMMONDOBJS) $(MESADOBJS)
+ DRVPOBJS = $(R128POBJS) $(COMMONPOBJS) $(MESAPOBJS)
+
+#elif GlxBuiltInRadeon
+
+#define MesaDrvRadeonBuildDir $(GLXLIBSRC)/mesa/drivers/dri/radeon/
+#include "../mesa/drivers/dri/radeon/Imakefile.inc"
+
+ DRVOBJS = $(RADEONOBJS) $(COMMONOBJS) $(MESAOBJS)
+ DRVUOBJS = $(RADEONUOBJS) $(COMMONUOBJS) $(MESAUOBJS)
+ DRVDOBJS = $(RADEONDOBJS) $(COMMONDOBJS) $(MESADOBJS)
+ DRVPOBJS = $(RADEONPOBJS) $(COMMONPOBJS) $(MESAPOBJS)
+
+#elif GlxBuiltInFfb
+
+#define MesaDrvFfbBuildDir $(GLXLIBSRC)/mesa/drivers/dri/ffb/
+#include "../mesa/drivers/dri/ffb/Imakefile.inc"
+
+ DRVOBJS = $(FFBOBJS) $(MESAOBJS)
+ DRVUOBJS = $(FFBUOBJS) $(MESAUOBJS)
+ DRVDOBJS = $(FFBDOBJS) $(MESADOBJS)
+ DRVPOBJS = $(FFBPOBJS) $(MESAPOBJS)
+
+#elif GlxBuiltInSIS
+
+#define MesaDrvSisBuildDir $(GLXLIBSRC)/mesa/drivers/dri/sis/
+#include "../mesa/drivers/dri/sis/Imakefile.inc"
+
+ DRVOBJS = $(SISOBJS) $(MESAOBJS)
+ DRVUOBJS = $(SISUOBJS) $(MESAUOBJS)
+ DRVDOBJS = $(SISDOBJS) $(MESADOBJS)
+ DRVPOBJS = $(SISPOBJS) $(MESAPOBJS)
+
+#elif GlxBuiltInXMesa
+
+#include "../mesa/drivers/x11/Imakefile.inc"
+
+ DRVOBJS = $(MESAOBJS) $(XMESA_OBJS)
+ DRVUOBJS = $(MESAUOBJS) $(XMESA_UOBJS)
+ DRVDOBJS = $(MESADOBJS) $(XMESA_DOBJS)
+ DRVPOBJS = $(MESAPOBJS) $(XMESA_POBJS)
+
+#else
+
+XCOMM No built-in drivers. This is the usual case.
+
+#endif
+
+#endif /* BuildXF86DRI */
+
+#if defined(DarwinArchitecture) && BuildAppleDRI
+ APPLEOBJS = appledri.o dri_dispatch.o dri_driver.o dri_glx.o x-list.o x-hash.o
+ DRIOBJS = $(APPLEOBJS:%.o=$(GLXLIBSRC)/apple/%.o)
+ DRIUOBJS = $(APPLEOBJS:%.o=$(GLXLIBSRC)/apple/unshared/%.o)
+ DRIDOBJS = $(APPLEOBJS:%.o=$(GLXLIBSRC)/apple/debugger/%.o)
+ DRIPOBJS = $(APPLEOBJS:%.o=$(GLXLIBSRC)/apple/profiled/%.o)
+
+NATIVE_GL = /System/Library/Frameworks/OpenGL.framework
+
+OTHERREQUIREDLIBS = \
+ XpluginLibrary $(NATIVE_GL)/Libraries/libGL.dylib -sub_library libGL \
+ -framework ApplicationServices -framework CoreFoundation \
+ -framework OpenGL
+#endif
+
+#if BuildXF86DRI && BuildXF86VidModeExt
+VMODEREQUIREDLIBS = $(LDPRELIBS) $(XXF86VMLIB)
+#endif
+
+/*
+ * Note: DRIDIRS is empty for !BuildXF86DRI, and DRVSUBDIRS is empty
+ * for no built-in drivers.
+ */
+
+REQUIREDLIBS = $(OTHERREQUIREDLIBS) $(VMODEREQUIREDLIBS) $(BASEREQUIREDLIBS)
+
+ OBJS = $(GLXOBJS) $(DRIOBJS) $(DRVOBJS) $(DRMOBJS)
+#if HasSharedLibraries && !SharedLibGlxWithoutPIC
+ UOBJS = $(GLXUOBJS) $(DRIUOBJS) $(DRVUOBJS) $(DRMUOBJS)
+#else
+ UOBJS = $(OBJS)
+#endif
+ DOBJS = $(GLXDOBJS) $(DRIDOBJS) $(DRVDOBJS) $(DRMDOBJS)
+ POBJS = $(GLXPOBJS) $(DRIPOBJS) $(DRVPOBJS) $(DRMPOBJS)
+
+#if LocalThreads
+ THREADOBJS = $(THREADS_LIBS)
+#endif
+
+#include <Library.tmpl>
+
+#undef _LinkBuildLibrary
+#define _LinkBuildLibrary(lib) LinkBuildLibrary(lib)
+
+
+#if NormalLibGlx
+NormalLibraryTarget($(LIBNAME),$(UOBJS))
+InstallLibrary($(LIBNAME),$(USRLIBDIR))
+#endif
+#if SharedLibGlx
+SharedDepLibraryTarget($(LIBNAME),$(SOREV),$(OBJS),$(OBJS) $(THREADOBJS),.,.)
+InstallSharedLibrary($(LIBNAME),$(SOREV),$(SHLIBDIR))
+#if LinkGLToUsrLib && AlternateUsrLibDir
+install::
+ MakeDir($(DESTDIR)$(SYSTEMUSRLIBDIR))
+ $(RM) $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so
+ $(LN) $(SHLIBDIR)/lib$(LIBNAME).so $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so || true
+ $(RM) $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so.1
+ $(LN) $(SHLIBDIR)/lib$(LIBNAME).so.1 $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so.1 || true
+#endif
+#endif
+#if DebugLibGlx
+DebuggedLibraryTarget($(LIBNAME),$(DOBJS))
+InstallLibrary($(LIBNAME)_d,$(USRLIBDIR))
+#endif
+#if ProfileLibGlx
+ProfiledLibraryTarget($(LIBNAME),$(POBJS))
+InstallLibrary($(LIBNAME)_p,$(USRLIBDIR))
+#endif
+
+
diff --git a/nx-X11/lib/GL/Imakefile b/nx-X11/lib/GL/Imakefile
new file mode 100644
index 000000000..b53a71f4c
--- /dev/null
+++ b/nx-X11/lib/GL/Imakefile
@@ -0,0 +1,119 @@
+XCOMM $XFree86: xc/lib/GL/Imakefile,v 1.43 2003/06/30 01:45:10 torrey Exp $
+
+XCOMM
+XCOMM Imake tokens which are significant to building libGL:
+XCOMM
+XCOMM BuildGLXLibrary - if defined, build libs in xc/lib/GL and xc/lib/GLw
+XCOMM
+XCOMM BuildXF86DRI - if defined, build libGL with DRI capability
+XCOMM
+XCOMM Only zero or one of the following can be defined at once:
+XCOMM GlxBuiltInGamma - if defined, build gamma_dri.so driver into libGL
+XCOMM GlxBuiltInTdfx - if defined, build tdfx_dri.so driver into libGL
+XCOMM GlxBuiltInMga - if defined, build mga_dri.so driver into libGL
+XCOMM GlxBuiltInI810 - if defined, build i810_dri.so driver into libGL
+XCOMM GlxBuiltInR128 - if defined, build r128_dri.so driver into libGL
+XCOMM GlxBuiltInRadeon - if defined, build radeon_dri.so driver into libGL
+XCOMM GlxBuiltInR200 - if defined, build r200_dri.so driver into libGL
+XCOMM GlxBuiltInFfb - if defined, build ffb_dri.so driver into libGL
+XCOMM GlxBuiltInSIS - if defined, build sis_dri.so driver into libGL
+XCOMM
+XCOMM GlxUseBuiltInDRIDriver - automatically defined if any of the
+XCOMM GlxBuiltIn[Gamma,Tdfx,Mga,I810,R128,Radeon,R200,Ffb,SIS] tokens is
+XCOMM defined
+XCOMM
+XCOMM GlxBuiltInXMesa - if defined, build XMesa (Xlib Mesa driver) into libGL
+XCOMM to enable rendering to displays that lack the GLX extension.
+XCOMM
+XCOMM GlxDriverUsesMesa - will be defined if building a DRI driver into
+XCOMM libGL and it uses Mesa.
+XCOMM
+XCOMM GlxUseSGISI - if defined, use the SGI OpenGL Sample Implementation
+XCOMM to build the GLX server extension (not fully implemented yet).
+XCOMM
+XCOMM NormalLibGlx - if defined, build static libGL.a library
+XCOMM
+XCOMM SharedLibGlx - if defined, build dynamic libGL.so library
+XCOMM
+XCOMM DebugLibGlx - if defined, build libGL with debug info
+XCOMM
+XCOMM ProfileLibGlx - if defined, build libGL with profiling info
+XCOMM
+XCOMM SharedGlxRev - dynamic library version, currently defined to be "1.2"
+XCOMM
+XCOMM GlxSoProf - if defined, build dynamic libGL for profiling with soprof
+XCOMM
+XCOMM GlxStubLib - purpose???
+XCOMM
+XCOMM
+XCOMM Server-side tokens:
+XCOMM BuildGlxExt
+XCOMM GlxUseSGISI
+
+
+
+#include <Threads.tmpl>
+
+#define IHaveSubdirs
+
+#define PassCDebugFlags
+
+LIBGLBUILDDIR = GL
+ GLXDIRS = glx
+
+/*
+ * Need to build the Mesa + XMesa source in the following cases:
+ * BuildXF86DRI && defined(DriDrivers)
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ */
+#if BuildOSMesaLib || \
+ (BuildXF86DRI && \
+ (defined(DriDrivers) || GlxDriverUsesMesa || GlxBuiltInXMesa))
+ MESADIRS = mesa
+#endif
+
+/*
+ * Only need the OSmesa code in the following case:
+ * BuildOSMesaLib
+ */
+#if BuildOSMesaLib
+ OSMESADIRS = mesa/drivers/osmesa
+#endif
+
+/*
+ * Need to build the DRI code in the following cases:
+ * BuildXF86DRI
+ */
+#if BuildXF86DRI
+ DRIDIRS = dri/drm
+#endif
+
+/*
+ * Need to build the DRI drivers in the following cases:
+ * BuildXF86DRI && defined(DriDrivers)
+ */
+#if BuildXF86DRI && defined(DriDrivers)
+ DRIVERDIRS = mesa/drivers/dri
+#endif
+
+#if defined(DarwinArchitecture) && BuildAppleDRI
+ DRIDIRS = apple
+#endif
+
+/*
+ * The build order depends on whether the drivers are loaded into libGL or
+ * built-in to libGL. In the former case, libGL needs to be built before
+ * the drivers, and in the latter case, it needs to be built after the driver.
+ */
+#if BuildXF86DRI && GlxUseBuiltInDRIDriver
+SUBDIRS = $(MESADIRS) $(DRIDIRS) $(DRIVERDIRS) $(GLXDIRS) $(LIBGLBUILDDIR) $(OSMESADIRS)
+#else
+SUBDIRS = $(MESADIRS) $(GLXDIRS) $(DRIDIRS) $(LIBGLBUILDDIR) $(OSMESADIRS) $(DRIVERDIRS)
+#endif
+
+MakeSubdirs($(SUBDIRS))
+
+DependSubdirs($(SUBDIRS))
+
diff --git a/nx-X11/lib/GL/apple/Imakefile b/nx-X11/lib/GL/apple/Imakefile
new file mode 100644
index 000000000..0a593e63e
--- /dev/null
+++ b/nx-X11/lib/GL/apple/Imakefile
@@ -0,0 +1,54 @@
+XCOMM $XFree86: xc/lib/GL/apple/Imakefile,v 1.2 2003/10/09 23:42:32 torrey Exp $
+
+#include <Threads.tmpl>
+
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+
+ XPRDIR = $(SERVERSRC)/hw/darwin/quartz/xpr
+
+LinkSourceFile(x-list.c,$(XPRDIR))
+LinkSourceFile(x-list.h,$(XPRDIR))
+LinkSourceFile(x-hash.c,$(XPRDIR))
+LinkSourceFile(x-hash.h,$(XPRDIR))
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DRI_SRCS = dri_glx.c dri_driver.c dri_dispatch.c x-hash.c x-list.c
+ DRI_OBJS = dri_glx.o dri_driver.o dri_dispatch.o x-hash.o x-list.o
+ DRI_INCS = -I. -I$(GLXLIBSRC)/glx -I$(INCLUDESRC) -I$(INCLUDESRC)/GL \
+ -I$(XINCLUDESRC) -I$(SERVERSRC)/GL/dri -I$(XPINCDIR) \
+ -I$(MESASRCDIR)/include -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(GLXLIBSRC)/include
+
+ AS = /System/Library/Frameworks/ApplicationServices.framework
+
+ DEFINES = $(ALLOC_DEFINES) GlxDefines $(GLX_DEFS) -DXP_NO_X_HEADERS=1 \
+ -DOSVERSION=OSMajorVersion*100+OSMinorVersion
+ INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core -I$(DRI_INCS) -F$(AS)/Frameworks
+ SRCS = appledri.c $(DRI_SRCS)
+ OBJS = appledri.o $(DRI_OBJS)
+
+/* We won't require this to run when building normally, just for updating.
+ Also, don't give it any dependences so make doesn't attempt to rebuild
+ it if the dates get screwed up. (It actually depends on build-dispatch
+ and dri_dispatch.defs) */
+dri_dispatch.h :
+ ./build-dispatch <dri_dispatch.defs >$@
+
+LinkSourceFile(drm.h,$(DRMSRCDIR)/shared-core)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/apple/appledri.c b/nx-X11/lib/GL/apple/appledri.c
new file mode 100644
index 000000000..ed48fcb0c
--- /dev/null
+++ b/nx-X11/lib/GL/apple/appledri.c
@@ -0,0 +1,302 @@
+/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.12 2001/08/27 17:40:57 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Jens Owen <jens@valinux.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include "appledristr.h"
+#include <X11/extensions/Xext.h>
+#include "extutil.h"
+#include <stdio.h>
+
+static XExtensionInfo _appledri_info_data;
+static XExtensionInfo *appledri_info = &_appledri_info_data;
+static char *appledri_extension_name = APPLEDRINAME;
+
+#define AppleDRICheckExtension(dpy,i,val) \
+ XextCheckExtension(dpy, i, appledri_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *extCodes);
+static Bool wire_to_event();
+
+static /* const */ XExtensionHooks appledri_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY(find_display, appledri_info,
+ appledri_extension_name,
+ &appledri_extension_hooks,
+ AppleDRINumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY(close_display, appledri_info)
+
+static void (*surface_notify_handler)();
+
+void *
+XAppleDRISetSurfaceNotifyHandler(void (*fun)())
+{
+ void *old = surface_notify_handler;
+ surface_notify_handler = fun;
+ return old;
+}
+
+static Bool wire_to_event(dpy, re, event)
+ Display *dpy;
+ XEvent *re;
+ xEvent *event;
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xAppleDRINotifyEvent *sevent;
+
+ AppleDRICheckExtension(dpy, info, False);
+
+ switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
+ case AppleDRISurfaceNotify:
+ sevent = (xAppleDRINotifyEvent *) event;
+ if (surface_notify_handler != NULL) {
+ (*surface_notify_handler)(dpy, (unsigned int) sevent->arg,
+ (int) sevent->kind);
+ }
+ return False;
+ }
+ return False;
+}
+
+/*****************************************************************************
+ * *
+ * public Apple-DRI Extension routines *
+ * *
+ *****************************************************************************/
+
+#if 0
+#include <stdio.h>
+#define TRACE(msg) fprintf(stderr, "AppleDRI%s\n", msg);
+#else
+#define TRACE(msg)
+#endif
+
+
+Bool XAppleDRIQueryExtension(dpy, event_basep, error_basep)
+ Display *dpy;
+ int *event_basep, *error_basep;
+{
+ XExtDisplayInfo *info = find_display(dpy);
+
+ TRACE("QueryExtension...");
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ TRACE("QueryExtension... return True");
+ return True;
+ } else {
+ TRACE("QueryExtension... return False");
+ return False;
+ }
+}
+
+Bool XAppleDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
+ Display* dpy;
+ int* majorVersion;
+ int* minorVersion;
+ int* patchVersion;
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xAppleDRIQueryVersionReply rep;
+ xAppleDRIQueryVersionReq *req;
+
+ TRACE("QueryVersion...");
+ AppleDRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleDRIQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_AppleDRIQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return False");
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ *patchVersion = rep.patchVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return True");
+ return True;
+}
+
+Bool XAppleDRIQueryDirectRenderingCapable(dpy, screen, isCapable)
+ Display* dpy;
+ int screen;
+ Bool* isCapable;
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xAppleDRIQueryDirectRenderingCapableReply rep;
+ xAppleDRIQueryDirectRenderingCapableReq *req;
+
+ TRACE("QueryDirectRenderingCapable...");
+ AppleDRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleDRIQueryDirectRenderingCapable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_AppleDRIQueryDirectRenderingCapable;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryDirectRenderingCapable... return False");
+ return False;
+ }
+ *isCapable = rep.isCapable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryDirectRenderingCapable... return True");
+ return True;
+}
+
+Bool XAppleDRIAuthConnection(dpy, screen, magic)
+ Display* dpy;
+ int screen;
+ unsigned int magic;
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xAppleDRIAuthConnectionReq *req;
+ xAppleDRIAuthConnectionReply rep;
+
+ TRACE("AuthConnection...");
+ AppleDRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleDRIAuthConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_AppleDRIAuthConnection;
+ req->screen = screen;
+ req->magic = magic;
+ rep.authenticated = 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("AuthConnection... return False");
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("AuthConnection... return True");
+ return True;
+}
+
+Bool XAppleDRICreateSurface(dpy, screen, drawable, client_id, key, uid)
+ Display* dpy;
+ int screen;
+ Drawable drawable;
+ unsigned int client_id;
+ unsigned int *key;
+ unsigned int *uid;
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xAppleDRICreateSurfaceReply rep;
+ xAppleDRICreateSurfaceReq *req;
+
+ TRACE("CreateSurface...");
+ AppleDRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleDRICreateSurface, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_AppleDRICreateSurface;
+ req->screen = screen;
+ req->drawable = drawable;
+ req->client_id = client_id;
+ rep.key_0 = rep.key_1 = rep.uid = 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.key_0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateSurface... return False");
+ return False;
+ }
+ key[0] = rep.key_0;
+ key[1] = rep.key_1;
+ *uid = rep.uid;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateSurface... return True");
+ return True;
+}
+
+Bool XAppleDRIDestroySurface(dpy, screen, drawable)
+ Display* dpy;
+ int screen;
+ Drawable drawable;
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xAppleDRIDestroySurfaceReq *req;
+
+ TRACE("DestroySurface...");
+ AppleDRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleDRIDestroySurface, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_AppleDRIDestroySurface;
+ req->screen = screen;
+ req->drawable = drawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("DestroySurface... return True");
+ return True;
+}
diff --git a/nx-X11/lib/GL/apple/appledri.h b/nx-X11/lib/GL/apple/appledri.h
new file mode 100644
index 000000000..fafdc236c
--- /dev/null
+++ b/nx-X11/lib/GL/apple/appledri.h
@@ -0,0 +1,106 @@
+/* $XFree86: xc/lib/GL/apple/appledri.h,v 1.1 2003/06/30 01:45:10 torrey Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Jens Owen <jens@valinux.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#ifndef _APPLEDRI_H_
+#define _APPLEDRI_H_
+
+#include <X11/Xfuncproto.h>
+
+#define X_AppleDRIQueryVersion 0
+#define X_AppleDRIQueryDirectRenderingCapable 1
+#define X_AppleDRICreateSurface 2
+#define X_AppleDRIDestroySurface 3
+#define X_AppleDRIAuthConnection 4
+/* Requests up to and including 18 were used in a previous version */
+
+/* Events */
+#define AppleDRIObsoleteEvent1 0
+#define AppleDRIObsoleteEvent2 1
+#define AppleDRIObsoleteEvent3 2
+#define AppleDRISurfaceNotify 3
+#define AppleDRINumberEvents 4
+
+/* Errors */
+#define AppleDRIClientNotLocal 0
+#define AppleDRIOperationNotSupported 1
+#define AppleDRINumberErrors (AppleDRIOperationNotSupported + 1)
+
+/* Kinds of SurfaceNotify events: */
+#define AppleDRISurfaceNotifyChanged 0
+#define AppleDRISurfaceNotifyDestroyed 1
+
+#ifndef _APPLEDRI_SERVER_
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came frome a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* window of event */
+ Time time; /* server timestamp when event happened */
+ int kind; /* subtype of event */
+ int arg;
+} XAppleDRINotifyEvent;
+
+_XFUNCPROTOBEGIN
+
+Bool XAppleDRIQueryExtension (Display *dpy, int *event_base, int *error_base);
+
+Bool XAppleDRIQueryVersion (Display *dpy, int *majorVersion,
+ int *minorVersion, int *patchVersion);
+
+Bool XAppleDRIQueryDirectRenderingCapable (Display *dpy, int screen,
+ Bool *isCapable);
+
+void *XAppleDRISetSurfaceNotifyHandler (void (*fun) (Display *dpy,
+ unsigned uid, int kind));
+
+Bool XAppleDRIAuthConnection (Display *dpy, int screen, unsigned int magic);
+
+Bool XAppleDRICreateSurface (Display *dpy, int screen, Drawable drawable,
+ unsigned int client_id, unsigned int key[2],
+ unsigned int* uid);
+
+Bool XAppleDRIDestroySurface (Display *dpy, int screen, Drawable drawable);
+
+Bool XAppleDRISynchronizeSurfaces (Display *dpy);
+
+_XFUNCPROTOEND
+
+#endif /* _APPLEDRI_SERVER_ */
+#endif /* _APPLEDRI_H_ */
diff --git a/nx-X11/lib/GL/apple/appledristr.h b/nx-X11/lib/GL/apple/appledristr.h
new file mode 100644
index 000000000..ec4158391
--- /dev/null
+++ b/nx-X11/lib/GL/apple/appledristr.h
@@ -0,0 +1,174 @@
+/* $XFree86: xc/lib/GL/apple/appledristr.h,v 1.1 2003/06/30 01:45:10 torrey Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Jens Owen <jens@valinux.com>
+ * Rickard E. (Rik) Fiath <faith@valinux.com>
+ *
+ */
+
+#ifndef _APPLEDRISTR_H_
+#define _APPLEDRISTR_H_
+
+#include "appledri.h"
+
+#define APPLEDRINAME "Apple-DRI"
+
+#define APPLE_DRI_MAJOR_VERSION 1 /* current version numbers */
+#define APPLE_DRI_MINOR_VERSION 0
+#define APPLE_DRI_PATCH_VERSION 0
+
+typedef struct _AppleDRIQueryVersion {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIQueryVersion */
+ CARD16 length B16;
+} xAppleDRIQueryVersionReq;
+#define sz_xAppleDRIQueryVersionReq 4
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD16 majorVersion B16; /* major version of DRI protocol */
+ CARD16 minorVersion B16; /* minor version of DRI protocol */
+ CARD32 patchVersion B32; /* patch version of DRI protocol */
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xAppleDRIQueryVersionReply;
+#define sz_xAppleDRIQueryVersionReply 32
+
+typedef struct _AppleDRIQueryDirectRenderingCapable {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xAppleDRIQueryDirectRenderingCapableReq;
+#define sz_xAppleDRIQueryDirectRenderingCapableReq 8
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ BOOL isCapable;
+ BOOL pad2;
+ BOOL pad3;
+ BOOL pad4;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+ CARD32 pad8 B32;
+ CARD32 pad9 B32;
+} xAppleDRIQueryDirectRenderingCapableReply;
+#define sz_xAppleDRIQueryDirectRenderingCapableReply 32
+
+typedef struct _AppleDRIAuthConnection {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 magic B32;
+} xAppleDRIAuthConnectionReq;
+#define sz_xAppleDRIAuthConnectionReq 12
+
+typedef struct {
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 authenticated B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xAppleDRIAuthConnectionReply;
+#define zx_xAppleDRIAuthConnectionReply 32
+
+typedef struct _AppleDRICreateSurface {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICreateSurface */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+ CARD32 client_id B32;
+} xAppleDRICreateSurfaceReq;
+#define sz_xAppleDRICreateSurfaceReq 16
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 key_0 B32;
+ CARD32 key_1 B32;
+ CARD32 uid B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xAppleDRICreateSurfaceReply;
+#define sz_xAppleDRICreateSurfaceReply 32
+
+typedef struct _AppleDRIDestroySurface {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIDestroySurface */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xAppleDRIDestroySurfaceReq;
+#define sz_xAppleDRIDestroySurfaceReq 12
+
+typedef struct _AppleDRINotify {
+ BYTE type; /* always eventBase + event type */
+ BYTE kind;
+ CARD16 sequenceNumber B16;
+ Time time B32; /* time of change */
+ CARD16 pad1 B16;
+ CARD32 arg B32;
+ CARD32 pad3 B32;
+} xAppleDRINotifyEvent;
+#define sz_xAppleDRINotifyEvent 20
+
+#ifdef _APPLEDRI_SERVER_
+
+void AppleDRISendEvent (
+ int /* type */,
+ unsigned int /* mask */,
+ int /* which */,
+ int /* arg */
+);
+
+#endif /* _APPLEDRI_SERVER_ */
+#endif /* _APPLEDRISTR_H_ */
diff --git a/nx-X11/lib/GL/apple/build-dispatch b/nx-X11/lib/GL/apple/build-dispatch
new file mode 100755
index 000000000..862e10c0d
--- /dev/null
+++ b/nx-X11/lib/GL/apple/build-dispatch
@@ -0,0 +1,101 @@
+#!/bin/sh
+exec rep "$0" "$@"
+!#
+
+;; build-dispatch
+
+;; $Id: build-dispatch,v 1.2 2004/04/23 18:43:09 eich Exp $
+;; $XFree86: $
+
+;; Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+
+;; Permission is hereby granted, free of charge, to any person
+;; obtaining a copy of this software and associated documentation files
+;; (the "Software"), to deal in the Software without restriction,
+;; including without limitation the rights to use, copy, modify, merge,
+;; publish, distribute, sublicense, and/or sell copies of the Software,
+;; and to permit persons to whom the Software is furnished to do so,
+;; subject to the following conditions:
+
+;; 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 THE ABOVE LISTED COPYRIGHT
+;; HOLDER(S) 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(s) of the above
+;; copyright holders shall not be used in advertising or otherwise to
+;; promote the sale, use or other dealings in this Software without
+;; prior written authorization.
+
+;; This lisp script is used to build the C dispatch table from the
+;; .defs file. It currently uses my (jsh's) rep interpreter. The
+;; created file is checked into cvs, so it only needs to be run when
+;; the .defs file is touched
+
+(structure ()
+
+ (open rep
+ rep.regexp)
+
+ (defmacro @ args `(format standard-output ,@args))
+
+ (define stubs '())
+
+ (define (strip-args s)
+ (mapcar (lambda (x)
+ (and (string-match "[ \t\n*]+([a-zA-Z0-9_]+)$" x)
+ (expand-last-match "\\1")))
+ (string-split "," s)))
+
+ (@ "/* dri_dispatch.h -- built automatically, DO NOT EDIT\n $%s$\n $%s$ */\n\n" "Id" "XFree86: ")
+
+ (condition-case nil
+ (while t
+ (let* ((form (read standard-input))
+ (args (unless (string= (nth 3 form) "void")
+ (strip-args (nth 3 form))))
+ (internal (>= (nth 2 form) 0))
+ (alias (nth 4 form))
+ (prefix (if (eq (nth 0 form) 'void)
+ "_VOID \("
+ (format nil " \(%s, " (nth 0 form)))))
+ (when (or internal (not alias))
+ (@ "DEFUN_%s%s%s,\n (%s),\n (%s)\)\n\n"
+ (if internal "LOCAL" "EXTERN")
+ prefix
+ (nth 1 form)
+ (if (string= (nth 3 form) "void")
+ (if internal "void *rend" "")
+ (if internal (format nil "void *rend, %s" (nth 3 form)) (nth 3 form)))
+ (mapconcat identity args ", ")))
+ (when alias
+ (@ "DEFUN_ALIAS%s%s, %s,\n (%s),\n (%s)\)\n\n"
+ prefix (nth 1 form) alias (nth 3 form)
+ (mapconcat identity args ", ")))
+ (when internal
+ (setq stubs (cons form stubs)))))
+
+ (end-of-stream))
+
+ (setq stubs (nreverse stubs))
+
+ (@ "#define INDIRECT_DISPATCH_INIT(d,p) \\\n")
+ (@ "do { \\\n")
+
+ (setq stubs (sort stubs (lambda (a b)
+ (< (nth 2 a) (nth 2 b)))))
+
+ (let loop ((rest stubs))
+ (when rest
+ (let ((form (car rest)))
+ (@ " (d)[%s] = (void *) &p ## %s; \\\n" (nth 2 form) (nth 1 form)))
+ (loop (cdr rest))))
+
+ (@ "} while (0)\n"))
diff --git a/nx-X11/lib/GL/apple/dri_dispatch.c b/nx-X11/lib/GL/apple/dri_dispatch.c
new file mode 100644
index 000000000..8e5c4ddfd
--- /dev/null
+++ b/nx-X11/lib/GL/apple/dri_dispatch.c
@@ -0,0 +1,153 @@
+/* dri_dispatch.c
+ $Id: dri_dispatch.c,v 1.5 2005/07/03 07:00:55 daniels Exp $
+
+ Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ Copyright (c) Torrey T. Lyons. All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ 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 THE ABOVE LISTED COPYRIGHT
+ HOLDER(S) 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(s) of the above
+ copyright holders shall not be used in advertising or otherwise to
+ promote the sale, use or other dealings in this Software without
+ prior written authorization. */
+/* $XFree86: xc/lib/GL/apple/dri_dispatch.c,v 1.4 2004/04/21 04:59:40 torrey Exp $ */
+
+#include <OpenGL/OpenGL.h>
+#include <OpenGL/CGLContext.h>
+
+/* We use Apple's GL headers, but as of Panther its glext.h
+ did not define the following. */
+#ifndef GL_ARB_vertex_buffer_object
+#include <stddef.h>
+typedef ptrdiff_t GLintptrARB;
+typedef ptrdiff_t GLsizeiptrARB;
+#endif
+
+#define GLAPIENTRYP *
+#include "glapi.h"
+#include "glapitable.h"
+#include "glxclient.h"
+
+#include <Xlibint.h>
+#include <stdio.h>
+
+#ifdef __GNUC__
+# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
+#else
+# define GCC_VERSION 0
+#endif
+
+#if GCC_VERSION < 3000
+# define __builtin_expect(a, b) a
+#endif
+
+static int indirect_noop (void)
+{
+ return 0;
+}
+
+/* Macro used for gl functions that exist in OpenGL.framework. We'll
+ use the existing stub for the initial dispatch, but need this
+ function to handle indirect contexts. */
+#define DEFUN_LOCAL_1(ret, return, gn, proto, args) \
+static ret indirect__ ## gn proto \
+{ \
+ struct _glapi_table *disp; \
+ \
+ disp = _glapi_Dispatch; \
+ if (__builtin_expect (disp == NULL, 0)) \
+ disp = _glapi_get_dispatch (); \
+ \
+ return (*disp->gn) args; \
+}
+
+/* Macro used for gl functions that don't exist in OpenGL.framework.
+ We drop them on the floor in direct rendering mode, but pass them
+ over the wire normally for indirect contexts. */
+#define DEFUN_EXTERN_1(ret, return, gn, proto, args) \
+ret gl ## gn proto \
+{ \
+ __GLXcontext *gc; \
+ struct _glapi_table *disp; \
+ \
+ gc = __glXGetCurrentContext (); \
+ if (!gc->isDirect) { \
+ disp = _glapi_Dispatch; \
+ if (__builtin_expect (disp == NULL, 0)) \
+ disp = _glapi_get_dispatch (); \
+ \
+ return (*disp->gn) args; \
+ } else { \
+ int a = 0; return (ret) a; \
+ } \
+}
+
+/* Macro for functions that already exist, but with a different name. */
+#define DEFUN_ALIAS_1(ret, return, gn, on, proto, args) \
+ret gl ## gn proto \
+{ \
+ return gl ## on args; \
+}
+
+#define DEFUN_LOCAL(r, gn, p, a) \
+ DEFUN_LOCAL_1 (r, return, gn, p, a)
+#define DEFUN_LOCAL_VOID(gn, p, a) \
+ DEFUN_LOCAL_1 (void, , gn, p, a)
+
+#define DEFUN_EXTERN(r, gn, p, a) \
+ DEFUN_EXTERN_1 (r, return, gn, p, a)
+#define DEFUN_EXTERN_VOID(gn, p, a) \
+ DEFUN_EXTERN_1 (void, , gn, p, a)
+
+#define DEFUN_ALIAS(r, gn, on, p, a) \
+ DEFUN_ALIAS_1 (r, return, gn, on, p, a)
+#define DEFUN_ALIAS_VOID(gn, on, p, a) \
+ DEFUN_ALIAS_1 (void, , gn, on, p, a)
+
+#include "dri_dispatch.h"
+
+__private_extern__ const CGLContextObj
+XAppleDRIGetIndirectContext (void)
+{
+ static CGLContextObj ctx;
+ void **t;
+ int i;
+
+ if (ctx != NULL)
+ return ctx;
+
+ /* initialize gl */
+ CGLSetOption (kCGLGOResetLibrary, 0);
+
+ /* Create an empty "context" for dispatching purposes. Add some slop
+ in case the dispatch table grows in future updates. */
+ ctx = Xcalloc (1, sizeof (struct _CGLContextObject) + 1024);
+
+ /* fill it with no-op vectors */
+ t = (void **) &ctx->disp;
+ for (i = 0; i < (int) (sizeof (ctx->disp) / sizeof (t[0])); i++)
+ t[i] = &indirect_noop;
+
+ /* then install the functions we actually support */
+ INDIRECT_DISPATCH_INIT (((void **) (&ctx->disp)), indirect__);
+
+ return ctx;
+}
diff --git a/nx-X11/lib/GL/apple/dri_dispatch.defs b/nx-X11/lib/GL/apple/dri_dispatch.defs
new file mode 100644
index 000000000..7d268e929
--- /dev/null
+++ b/nx-X11/lib/GL/apple/dri_dispatch.defs
@@ -0,0 +1,856 @@
+;; -*- lisp -*-
+
+;; dri_dispatch.defs
+
+;; $Id: dri_dispatch.defs,v 1.5 2004/08/18 23:12:49 kem Exp $
+;; $XFree86: xc/lib/GL/apple/dri_dispatch.defs,v 1.6 2004/04/21 04:59:40 torrey Exp $
+
+;; Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+;; Copyright (c) 2003-2004 Torrey T. Lyons. All rights reserved.
+
+;; Permission is hereby granted, free of charge, to any person
+;; obtaining a copy of this software and associated documentation files
+;; (the "Software"), to deal in the Software without restriction,
+;; including without limitation the rights to use, copy, modify, merge,
+;; publish, distribute, sublicense, and/or sell copies of the Software,
+;; and to permit persons to whom the Software is furnished to do so,
+;; subject to the following conditions:
+
+;; 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 THE ABOVE LISTED COPYRIGHT
+;; HOLDER(S) 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(s) of the above
+;; copyright holders shall not be used in advertising or otherwise to
+;; promote the sale, use or other dealings in this Software without
+;; prior written authorization.
+
+;; This file maps the Mesa GL api that X uses to the Apple CGL entry
+;; points. It's used to automatically generate the CGL dispatch table
+;; that's installed when an indirect context is current
+
+;; The format is (RETURN-TYPE MESA-NAME CGL-INDEX "ARGS" [ALIAS])
+
+;; For the script to work, ARGS must be either the string "void" or a
+;; comma separated list of parameters. Each parameter name _must_ be
+;; the last non-whitespace token in the field (i.e. inline function
+;; declarations won't work)
+
+;; CGL-INDEX is an index into the function vector table defined in
+;; <OpenGL/gliDispatch.h>. The names of the entries in this table
+;; aren't guaranteed to remain the same, but the table is guaranteed to
+;; be binary-compatible in future revisions, so we use indices.
+
+;; If CGL-INDEX is -1, it denotes that OpenGL.framework doesn't
+;; implement that function. We'll generate our own stub and make
+;; it work in indirect mode (unless it has an alias).
+
+;; ALIAS is the name of the function that should be used to define an
+;; external entry point for the function (because it doesn't exist in
+;; OpenGL.framework)
+
+;; The ordering matches the Mesa api table, but that's not important
+
+;; This table has some dependencies on the version of Mac OS X.
+;; Currently the script used to process this table does not handle
+;; these dependencies appropriately, so they must be added by hand.
+;; They are indicated by MAC_OS_X_VERSION in the comments below.
+
+(void NewList 177 "GLuint list, GLenum mode")
+(void EndList 75 "void")
+(void CallList 8 "GLuint list")
+(void CallLists 9 "GLsizei n, GLenum type, const GLvoid * lists")
+(void DeleteLists 58 "GLuint list, GLsizei range")
+(GLuint GenLists 97 "GLsizei range")
+(void ListBase 156 "GLuint base")
+(void Begin 4 "GLenum mode")
+(void Bitmap 6 "GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap")
+(void Color3b 17 "GLbyte red, GLbyte green, GLbyte blue")
+(void Color3bv 18 "const GLbyte * v")
+(void Color3d 19 "GLdouble red, GLdouble green, GLdouble blue")
+(void Color3dv 20 "const GLdouble * v")
+(void Color3f 21 "GLfloat red, GLfloat green, GLfloat blue")
+(void Color3fv 22 "const GLfloat * v")
+(void Color3i 23 "GLint red, GLint green, GLint blue")
+(void Color3iv 24 "const GLint * v")
+(void Color3s 25 "GLshort red, GLshort green, GLshort blue")
+(void Color3sv 26 "const GLshort * v")
+(void Color3ub 27 "GLubyte red, GLubyte green, GLubyte blue")
+(void Color3ubv 28 "const GLubyte * v")
+(void Color3ui 29 "GLuint red, GLuint green, GLuint blue")
+(void Color3uiv 30 "const GLuint * v")
+(void Color3us 31 "GLushort red, GLushort green, GLushort blue")
+(void Color3usv 32 "const GLushort * v")
+(void Color4b 33 "GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha")
+(void Color4bv 34 "const GLbyte * v")
+(void Color4d 35 "GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha")
+(void Color4dv 36 "const GLdouble * v")
+(void Color4f 37 "GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha")
+(void Color4fv 38 "const GLfloat * v")
+(void Color4i 39 "GLint red, GLint green, GLint blue, GLint alpha")
+(void Color4iv 40 "const GLint * v")
+(void Color4s 41 "GLshort red, GLshort green, GLshort blue, GLshort alpha")
+(void Color4sv 42 "const GLshort * v")
+(void Color4ub 43 "GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha")
+(void Color4ubv 44 "const GLubyte * v")
+(void Color4ui 45 "GLuint red, GLuint green, GLuint blue, GLuint alpha")
+(void Color4uiv 46 "const GLuint * v")
+(void Color4us 47 "GLushort red, GLushort green, GLushort blue, GLushort alpha")
+(void Color4usv 48 "const GLushort * v")
+(void EdgeFlag 69 "GLboolean flag")
+(void EdgeFlagv 71 "const GLboolean * flag")
+(void End 74 "void")
+(void Indexd 131 "GLdouble c")
+(void Indexdv 132 "const GLdouble * c")
+(void Indexf 133 "GLfloat c")
+(void Indexfv 134 "const GLfloat * c")
+(void Indexi 135 "GLint c")
+(void Indexiv 136 "const GLint * c")
+(void Indexs 137 "GLshort c")
+(void Indexsv 138 "const GLshort * c")
+(void Normal3b 178 "GLbyte nx, GLbyte ny, GLbyte nz")
+(void Normal3bv 179 "const GLbyte * v")
+(void Normal3d 180 "GLdouble nx, GLdouble ny, GLdouble nz")
+(void Normal3dv 181 "const GLdouble * v")
+(void Normal3f 182 "GLfloat nx, GLfloat ny, GLfloat nz")
+(void Normal3fv 183 "const GLfloat * v")
+(void Normal3i 184 "GLint nx, GLint ny, GLint nz")
+(void Normal3iv 185 "const GLint * v")
+(void Normal3s 186 "GLshort nx, GLshort ny, GLshort nz")
+(void Normal3sv 187 "const GLshort * v")
+(void RasterPos2d 212 "GLdouble x, GLdouble y")
+(void RasterPos2dv 213 "const GLdouble * v")
+(void RasterPos2f 214 "GLfloat x, GLfloat y")
+(void RasterPos2fv 215 "const GLfloat * v")
+(void RasterPos2i 216 "GLint x, GLint y")
+(void RasterPos2iv 217 "const GLint * v")
+(void RasterPos2s 218 "GLshort x, GLshort y")
+(void RasterPos2sv 219 "const GLshort * v")
+(void RasterPos3d 220 "GLdouble x, GLdouble y, GLdouble z")
+(void RasterPos3dv 221 "const GLdouble * v")
+(void RasterPos3f 222 "GLfloat x, GLfloat y, GLfloat z")
+(void RasterPos3fv 223 "const GLfloat * v")
+(void RasterPos3i 224 "GLint x, GLint y, GLint z")
+(void RasterPos3iv 225 "const GLint * v")
+(void RasterPos3s 226 "GLshort x, GLshort y, GLshort z")
+(void RasterPos3sv 227 "const GLshort * v")
+(void RasterPos4d 228 "GLdouble x, GLdouble y, GLdouble z, GLdouble w")
+(void RasterPos4dv 229 "const GLdouble * v")
+(void RasterPos4f 230 "GLfloat x, GLfloat y, GLfloat z, GLfloat w")
+(void RasterPos4fv 231 "const GLfloat * v")
+(void RasterPos4i 232 "GLint x, GLint y, GLint z, GLint w")
+(void RasterPos4iv 233 "const GLint * v")
+(void RasterPos4s 234 "GLshort x, GLshort y, GLshort z, GLshort w")
+(void RasterPos4sv 235 "const GLshort * v")
+(void Rectd 238 "GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2")
+(void Rectdv 239 "const GLdouble * v1, const GLdouble * v2")
+(void Rectf 240 "GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2")
+(void Rectfv 241 "const GLfloat * v1, const GLfloat * v2")
+(void Recti 242 "GLint x1, GLint y1, GLint x2, GLint y2")
+(void Rectiv 243 "const GLint * v1, const GLint * v2")
+(void Rects 244 "GLshort x1, GLshort y1, GLshort x2, GLshort y2")
+(void Rectsv 245 "const GLshort * v1, const GLshort * v2")
+(void TexCoord1d 257 "GLdouble s")
+(void TexCoord1dv 258 "const GLdouble * v")
+(void TexCoord1f 259 "GLfloat s")
+(void TexCoord1fv 260 "const GLfloat * v")
+(void TexCoord1i 261 "GLint s")
+(void TexCoord1iv 262 "const GLint * v")
+(void TexCoord1s 263 "GLshort s")
+(void TexCoord1sv 264 "const GLshort * v")
+(void TexCoord2d 265 "GLdouble s, GLdouble t")
+(void TexCoord2dv 266 "const GLdouble * v")
+(void TexCoord2f 267 "GLfloat s, GLfloat t")
+(void TexCoord2fv 268 "const GLfloat * v")
+(void TexCoord2i 269 "GLint s, GLint t")
+(void TexCoord2iv 270 "const GLint * v")
+(void TexCoord2s 271 "GLshort s, GLshort t")
+(void TexCoord2sv 272 "const GLshort * v")
+(void TexCoord3d 273 "GLdouble s, GLdouble t, GLdouble r")
+(void TexCoord3dv 274 "const GLdouble * v")
+(void TexCoord3f 275 "GLfloat s, GLfloat t, GLfloat r")
+(void TexCoord3fv 276 "const GLfloat * v")
+(void TexCoord3i 277 "GLint s, GLint t, GLint r")
+(void TexCoord3iv 278 "const GLint * v")
+(void TexCoord3s 279 "GLshort s, GLshort t, GLshort r")
+(void TexCoord3sv 280 "const GLshort * v")
+(void TexCoord4d 281 "GLdouble s, GLdouble t, GLdouble r, GLdouble q")
+(void TexCoord4dv 282 "const GLdouble * v")
+(void TexCoord4f 283 "GLfloat s, GLfloat t, GLfloat r, GLfloat q")
+(void TexCoord4fv 284 "const GLfloat * v")
+(void TexCoord4i 285 "GLint s, GLint t, GLint r, GLint q")
+(void TexCoord4iv 286 "const GLint * v")
+(void TexCoord4s 287 "GLshort s, GLshort t, GLshort r, GLshort q")
+(void TexCoord4sv 288 "const GLshort * v")
+(void Vertex2d 310 "GLdouble x, GLdouble y")
+(void Vertex2dv 311 "const GLdouble * v")
+(void Vertex2f 312 "GLfloat x, GLfloat y")
+(void Vertex2fv 313 "const GLfloat * v")
+(void Vertex2i 314 "GLint x, GLint y")
+(void Vertex2iv 315 "const GLint * v")
+(void Vertex2s 316 "GLshort x, GLshort y")
+(void Vertex2sv 317 "const GLshort * v")
+(void Vertex3d 318 "GLdouble x, GLdouble y, GLdouble z")
+(void Vertex3dv 319 "const GLdouble * v")
+(void Vertex3f 320 "GLfloat x, GLfloat y, GLfloat z")
+(void Vertex3fv 321 "const GLfloat * v")
+(void Vertex3i 322 "GLint x, GLint y, GLint z")
+(void Vertex3iv 323 "const GLint * v")
+(void Vertex3s 324 "GLshort x, GLshort y, GLshort z")
+(void Vertex3sv 325 "const GLshort * v")
+(void Vertex4d 326 "GLdouble x, GLdouble y, GLdouble z, GLdouble w")
+(void Vertex4dv 327 "const GLdouble * v")
+(void Vertex4f 328 "GLfloat x, GLfloat y, GLfloat z, GLfloat w")
+(void Vertex4fv 329 "const GLfloat * v")
+(void Vertex4i 330 "GLint x, GLint y, GLint z, GLint w")
+(void Vertex4iv 331 "const GLint * v")
+(void Vertex4s 332 "GLshort x, GLshort y, GLshort z, GLshort w")
+(void Vertex4sv 333 "const GLshort * v")
+(void ClipPlane 16 "GLenum plane, const GLdouble * equation")
+(void ColorMaterial 50 "GLenum face, GLenum mode")
+(void CullFace 57 "GLenum mode")
+(void Fogf 91 "GLenum pname, GLfloat param")
+(void Fogfv 92 "GLenum pname, const GLfloat * params")
+(void Fogi 93 "GLenum pname, GLint param")
+(void Fogiv 94 "GLenum pname, const GLint * params")
+(void FrontFace 95 "GLenum mode")
+(void Hint 128 "GLenum target, GLenum mode")
+(void Lightf 150 "GLenum light, GLenum pname, GLfloat param")
+(void Lightfv 151 "GLenum light, GLenum pname, const GLfloat * params")
+(void Lighti 152 "GLenum light, GLenum pname, GLint param")
+(void Lightiv 153 "GLenum light, GLenum pname, const GLint * params")
+(void LightModelf 146 "GLenum pname, GLfloat param")
+(void LightModelfv 147 "GLenum pname, const GLfloat * params")
+(void LightModeli 148 "GLenum pname, GLint param")
+(void LightModeliv 149 "GLenum pname, const GLint * params")
+(void LineStipple 154 "GLint factor, GLushort pattern")
+(void LineWidth 155 "GLfloat width")
+(void Materialf 170 "GLenum face, GLenum pname, GLfloat param")
+(void Materialfv 171 "GLenum face, GLenum pname, const GLfloat * params")
+(void Materiali 172 "GLenum face, GLenum pname, GLint param")
+(void Materialiv 173 "GLenum face, GLenum pname, const GLint * params")
+(void PointSize 199 "GLfloat size")
+(void PolygonMode 200 "GLenum face, GLenum mode")
+(void PolygonStipple 202 "const GLubyte * mask")
+(void Scissor 251 "GLint x, GLint y, GLsizei width, GLsizei height")
+(void ShadeModel 253 "GLenum mode")
+(void TexParameterf 302 "GLenum target, GLenum pname, GLfloat param")
+(void TexParameterfv 303 "GLenum target, GLenum pname, const GLfloat * params")
+(void TexParameteri 304 "GLenum target, GLenum pname, GLint param")
+(void TexParameteriv 305 "GLenum target, GLenum pname, const GLint * params")
+(void TexImage1D 300 "GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid * pixels")
+(void TexImage2D 301 "GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels")
+(void TexEnvf 290 "GLenum target, GLenum pname, GLfloat param")
+(void TexEnvfv 291 "GLenum target, GLenum pname, const GLfloat * params")
+(void TexEnvi 292 "GLenum target, GLenum pname, GLint param")
+(void TexEnviv 293 "GLenum target, GLenum pname, const GLint * params")
+(void TexGend 294 "GLenum coord, GLenum pname, GLdouble param")
+(void TexGendv 295 "GLenum coord, GLenum pname, const GLdouble * params")
+(void TexGenf 296 "GLenum coord, GLenum pname, GLfloat param")
+(void TexGenfv 297 "GLenum coord, GLenum pname, const GLfloat * params")
+(void TexGeni 298 "GLenum coord, GLenum pname, GLint param")
+(void TexGeniv 299 "GLenum coord, GLenum pname, const GLint * params")
+(void FeedbackBuffer 88 "GLsizei size, GLenum type, GLfloat * buffer")
+(void SelectBuffer 252 "GLsizei size, GLuint * buffer")
+(GLint RenderMode 246 "GLenum mode")
+(void InitNames 141 "void")
+(void LoadName 160 "GLuint name")
+(void PassThrough 190 "GLfloat token")
+(void PopName 206 "void")
+(void PushName 211 "GLuint name")
+(void DrawBuffer 66 "GLenum mode")
+(void Clear 10 "GLbitfield mask")
+(void ClearAccum 11 "GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha")
+(void ClearIndex 14 "GLfloat c")
+(void ClearColor 12 "GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha")
+(void ClearStencil 15 "GLint s")
+(void ClearDepth 13 "GLclampd depth")
+(void StencilMask 255 "GLuint mask")
+(void ColorMask 49 "GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha")
+(void DepthMask 61 "GLboolean flag")
+(void IndexMask 129 "GLuint mask")
+(void Accum 0 "GLenum op, GLfloat value")
+(void Disable 63 "GLenum cap")
+(void Enable 72 "GLenum cap")
+(void Finish 89 "void")
+(void Flush 90 "void")
+(void PopAttrib 203 "void")
+(void PushAttrib 208 "GLbitfield mask")
+(void Map1d 162 "GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points")
+(void Map1f 163 "GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points")
+(void Map2d 164 "GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points")
+(void Map2f 165 "GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points")
+(void MapGrid1d 166 "GLint un, GLdouble u1, GLdouble u2")
+(void MapGrid1f 167 "GLint un, GLfloat u1, GLfloat u2")
+(void MapGrid2d 168 "GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2")
+(void MapGrid2f 169 "GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2")
+(void EvalCoord1d 76 "GLdouble u")
+(void EvalCoord1dv 77 "const GLdouble * u")
+(void EvalCoord1f 78 "GLfloat u")
+(void EvalCoord1fv 79 "const GLfloat * u")
+(void EvalCoord2d 80 "GLdouble u, GLdouble v")
+(void EvalCoord2dv 81 "const GLdouble * u")
+(void EvalCoord2f 82 "GLfloat u, GLfloat v")
+(void EvalCoord2fv 83 "const GLfloat * u")
+(void EvalMesh1 84 "GLenum mode, GLint i1, GLint i2")
+(void EvalPoint1 86 "GLint i")
+(void EvalMesh2 85 "GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2")
+(void EvalPoint2 87 "GLint i, GLint j")
+(void AlphaFunc 1 "GLenum func, GLclampf ref")
+(void BlendFunc 7 "GLenum sfactor, GLenum dfactor")
+(void LogicOp 161 "GLenum opcode")
+(void StencilFunc 254 "GLenum func, GLint ref, GLuint mask")
+(void StencilOp 256 "GLenum fail, GLenum zfail, GLenum zpass")
+(void DepthFunc 60 "GLenum func")
+(void PixelZoom 198 "GLfloat xfactor, GLfloat yfactor")
+(void PixelTransferf 196 "GLenum pname, GLfloat param")
+(void PixelTransferi 197 "GLenum pname, GLint param")
+(void PixelStoref 194 "GLenum pname, GLfloat param")
+(void PixelStorei 195 "GLenum pname, GLint param")
+(void PixelMapfv 191 "GLenum map, GLint mapsize, const GLfloat * values")
+(void PixelMapuiv 192 "GLenum map, GLint mapsize, const GLuint * values")
+(void PixelMapusv 193 "GLenum map, GLint mapsize, const GLushort * values")
+(void ReadBuffer 236 "GLenum mode")
+(void CopyPixels 52 "GLint x, GLint y, GLsizei width, GLsizei height, GLenum type")
+(void ReadPixels 237 "GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * pixels")
+(void DrawPixels 68 "GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels")
+(void GetBooleanv 99 "GLenum pname, GLboolean * params")
+(void GetClipPlane 100 "GLenum plane, GLdouble * equation")
+(void GetDoublev 101 "GLenum pname, GLdouble * params")
+(GLenum GetError 102 "void")
+(void GetFloatv 103 "GLenum pname, GLfloat * params")
+(void GetIntegerv 104 "GLenum pname, GLint * params")
+(void GetLightfv 105 "GLenum light, GLenum pname, GLfloat * params")
+(void GetLightiv 106 "GLenum light, GLenum pname, GLint * params")
+(void GetMapdv 107 "GLenum target, GLenum query, GLdouble * v")
+(void GetMapfv 108 "GLenum target, GLenum query, GLfloat * v")
+(void GetMapiv 109 "GLenum target, GLenum query, GLint * v")
+(void GetMaterialfv 110 "GLenum face, GLenum pname, GLfloat * params")
+(void GetMaterialiv 111 "GLenum face, GLenum pname, GLint * params")
+(void GetPixelMapfv 112 "GLenum map, GLfloat * values")
+(void GetPixelMapuiv 113 "GLenum map, GLuint * values")
+(void GetPixelMapusv 114 "GLenum map, GLushort * values")
+(void GetPolygonStipple 116 "GLubyte * mask")
+(|const GLubyte *| GetString 117 "GLenum name")
+(void GetTexEnvfv 118 "GLenum target, GLenum pname, GLfloat * params")
+(void GetTexEnviv 119 "GLenum target, GLenum pname, GLint * params")
+(void GetTexGendv 120 "GLenum coord, GLenum pname, GLdouble * params")
+(void GetTexGenfv 121 "GLenum coord, GLenum pname, GLfloat * params")
+(void GetTexGeniv 122 "GLenum coord, GLenum pname, GLint * params")
+(void GetTexImage 123 "GLenum target, GLint level, GLenum format, GLenum type, GLvoid * pixels")
+(void GetTexParameterfv 126 "GLenum target, GLenum pname, GLfloat * params")
+(void GetTexParameteriv 127 "GLenum target, GLenum pname, GLint * params")
+(void GetTexLevelParameterfv 124 "GLenum target, GLint level, GLenum pname, GLfloat * params")
+(void GetTexLevelParameteriv 125 "GLenum target, GLint level, GLenum pname, GLint * params")
+(GLboolean IsEnabled 143 "GLenum cap")
+(GLboolean IsList 144 "GLuint list")
+(void DepthRange 62 "GLclampd zNear, GLclampd zFar")
+(void Frustum 96 "GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar")
+(void LoadIdentity 157 "void")
+(void LoadMatrixf 159 "const GLfloat * m")
+(void LoadMatrixd 158 "const GLdouble * m")
+(void MatrixMode 174 "GLenum mode")
+(void MultMatrixf 176 "const GLfloat * m")
+(void MultMatrixd 175 "const GLdouble * m")
+(void Ortho 189 "GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar")
+(void PopMatrix 205 "void")
+(void PushMatrix 210 "void")
+(void Rotated 247 "GLdouble angle, GLdouble x, GLdouble y, GLdouble z")
+(void Rotatef 248 "GLfloat angle, GLfloat x, GLfloat y, GLfloat z")
+(void Scaled 249 "GLdouble x, GLdouble y, GLdouble z")
+(void Scalef 250 "GLfloat x, GLfloat y, GLfloat z")
+(void Translated 308 "GLdouble x, GLdouble y, GLdouble z")
+(void Translatef 309 "GLfloat x, GLfloat y, GLfloat z")
+(void Viewport 335 "GLint x, GLint y, GLsizei width, GLsizei height")
+(void ArrayElement 3 "GLint i")
+(void BindTexture 5 "GLenum target, GLenum texture")
+(void ColorPointer 51 "GLint size, GLenum type, GLsizei stride, const GLvoid * pointer")
+(void DisableClientState 64 "GLenum array")
+(void DrawArrays 65 "GLenum mode, GLint first, GLsizei count")
+(void DrawElements 67 "GLenum mode, GLsizei count, GLenum type, const GLvoid * indices")
+(void EdgeFlagPointer 70 "GLsizei stride, const GLvoid * pointer")
+(void EnableClientState 73 "GLenum array")
+(void IndexPointer 130 "GLenum type, GLsizei stride, const GLvoid * pointer")
+(void Indexub 139 "GLubyte c")
+(void Indexubv 140 "const GLubyte * c")
+(void InterleavedArrays 142 "GLenum format, GLsizei stride, const GLvoid * pointer")
+(void NormalPointer 188 "GLenum type, GLsizei stride, const GLvoid * pointer")
+(void PolygonOffset 201 "GLfloat factor, GLfloat units")
+(void TexCoordPointer 289 "GLint size, GLenum type, GLsizei stride, const GLvoid * pointer")
+(void VertexPointer 334 "GLint size, GLenum type, GLsizei stride, const GLvoid * pointer")
+(GLboolean AreTexturesResident 2 "GLsizei n, const GLenum * textures, GLboolean * residences")
+(void CopyTexImage1D 53 "GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border")
+(void CopyTexImage2D 54 "GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border")
+(void CopyTexSubImage1D 55 "GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width")
+(void CopyTexSubImage2D 56 "GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height")
+(void DeleteTextures 59 "GLsizei n, const GLenum * textures")
+(void GenTextures 98 "GLsizei n, GLenum * textures")
+(void GetPointerv 115 "GLenum pname, GLvoid * * params")
+(GLboolean IsTexture 145 "GLenum texture")
+(void PrioritizeTextures 207 "GLsizei n, const GLenum * textures, const GLclampf * priorities")
+(void TexSubImage1D 306 "GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid * pixels")
+(void TexSubImage2D 307 "GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels")
+(void PopClientAttrib 204 "void")
+(void PushClientAttrib 209 "GLbitfield mask")
+(void BlendColor 337 "GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha")
+(void BlendEquation 338 "GLenum mode")
+(void DrawRangeElements 405 "GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices")
+(void ColorTable 406 "GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table")
+(void ColorTableParameterfv 407 "GLenum target, GLenum pname, const GLfloat * params")
+(void ColorTableParameteriv 408 "GLenum target, GLenum pname, const GLint * params")
+(void CopyColorTable 409 "GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width")
+(void GetColorTable 410 "GLenum target, GLenum format, GLenum type, GLvoid * table")
+(void GetColorTableParameterfv 411 "GLenum target, GLenum pname, GLfloat * params")
+(void GetColorTableParameteriv 412 "GLenum target, GLenum pname, GLint * params")
+(void ColorSubTable 413 "GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid * data")
+(void CopyColorSubTable 414 "GLenum target, GLsizei start, GLint x, GLint y, GLsizei width")
+(void ConvolutionFilter1D 415 "GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * image")
+(void ConvolutionFilter2D 416 "GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * image")
+(void ConvolutionParameterf 417 "GLenum target, GLenum pname, GLfloat params")
+(void ConvolutionParameterfv 418 "GLenum target, GLenum pname, const GLfloat * params")
+(void ConvolutionParameteri 419 "GLenum target, GLenum pname, GLint params")
+(void ConvolutionParameteriv 420 "GLenum target, GLenum pname, const GLint * params")
+(void CopyConvolutionFilter1D 421 "GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width")
+(void CopyConvolutionFilter2D 422 "GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height")
+(void GetConvolutionFilter 423 "GLenum target, GLenum format, GLenum type, GLvoid * image")
+(void GetConvolutionParameterfv 424 "GLenum target, GLenum pname, GLfloat * params")
+(void GetConvolutionParameteriv 425 "GLenum target, GLenum pname, GLint * params")
+(void GetSeparableFilter 426 "GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span")
+(void SeparableFilter2D 427 "GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * row, const GLvoid * column")
+(void GetHistogram 428 "GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values")
+(void GetHistogramParameterfv 429 "GLenum target, GLenum pname, GLfloat * params")
+(void GetHistogramParameteriv 430 "GLenum target, GLenum pname, GLint * params")
+(void GetMinmax 431 "GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values")
+(void GetMinmaxParameterfv 432 "GLenum target, GLenum pname, GLfloat * params")
+(void GetMinmaxParameteriv 433 "GLenum target, GLenum pname, GLint * params")
+(void Histogram 434 "GLenum target, GLsizei width, GLenum internalformat, GLboolean sink")
+(void Minmax 435 "GLenum target, GLenum internalformat, GLboolean sink")
+(void ResetHistogram 436 "GLenum target")
+(void ResetMinmax 437 "GLenum target")
+(void TexImage3D 438 "GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels")
+(void TexSubImage3D 439 "GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels")
+(void CopyTexSubImage3D 440 "GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height")
+(void ActiveTextureARB 342 "GLenum texture")
+(void ClientActiveTextureARB 341 "GLenum texture")
+(void MultiTexCoord1dARB 343 "GLenum target, GLdouble s")
+(void MultiTexCoord1dvARB 344 "GLenum target, const GLdouble * v")
+(void MultiTexCoord1fARB 345 "GLenum target, GLfloat s")
+(void MultiTexCoord1fvARB 346 "GLenum target, const GLfloat * v")
+(void MultiTexCoord1iARB 347 "GLenum target, GLint s")
+(void MultiTexCoord1ivARB 348 "GLenum target, const GLint * v")
+(void MultiTexCoord1sARB 349 "GLenum target, GLshort s")
+(void MultiTexCoord1svARB 350 "GLenum target, const GLshort * v")
+(void MultiTexCoord2dARB 351 "GLenum target, GLdouble s, GLdouble t")
+(void MultiTexCoord2dvARB 352 "GLenum target, const GLdouble * v")
+(void MultiTexCoord2fARB 353 "GLenum target, GLfloat s, GLfloat t")
+(void MultiTexCoord2fvARB 354 "GLenum target, const GLfloat * v")
+(void MultiTexCoord2iARB 355 "GLenum target, GLint s, GLint t")
+(void MultiTexCoord2ivARB 356 "GLenum target, const GLint * v")
+(void MultiTexCoord2sARB 357 "GLenum target, GLshort s, GLshort t")
+(void MultiTexCoord2svARB 358 "GLenum target, const GLshort * v")
+(void MultiTexCoord3dARB 359 "GLenum target, GLdouble s, GLdouble t, GLdouble r")
+(void MultiTexCoord3dvARB 360 "GLenum target, const GLdouble * v")
+(void MultiTexCoord3fARB 361 "GLenum target, GLfloat s, GLfloat t, GLfloat r")
+(void MultiTexCoord3fvARB 362 "GLenum target, const GLfloat * v")
+(void MultiTexCoord3iARB 363 "GLenum target, GLint s, GLint t, GLint r")
+(void MultiTexCoord3ivARB 364 "GLenum target, const GLint * v")
+(void MultiTexCoord3sARB 365 "GLenum target, GLshort s, GLshort t, GLshort r")
+(void MultiTexCoord3svARB 366 "GLenum target, const GLshort * v")
+(void MultiTexCoord4dARB 367 "GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q")
+(void MultiTexCoord4dvARB 368 "GLenum target, const GLdouble * v")
+(void MultiTexCoord4fARB 369 "GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q")
+(void MultiTexCoord4fvARB 370 "GLenum target, const GLfloat * v")
+(void MultiTexCoord4iARB 371 "GLenum target, GLint s, GLint t, GLint r, GLint q")
+(void MultiTexCoord4ivARB 372 "GLenum target, const GLint * v")
+(void MultiTexCoord4sARB 373 "GLenum target, GLshort s, GLshort t, GLshort r, GLshort q")
+(void MultiTexCoord4svARB 374 "GLenum target, const GLshort * v")
+(void LoadTransposeMatrixfARB 376 "const GLfloat * m")
+(void LoadTransposeMatrixdARB 375 "const GLdouble * m")
+(void MultTransposeMatrixfARB 378 "const GLfloat * m")
+(void MultTransposeMatrixdARB 377 "const GLdouble * m")
+(void SampleCoverageARB 459 "GLclampf value, GLboolean invert")
+(void __unused413 -1 "void")
+(void PolygonOffsetEXT -1 "GLfloat factor, GLfloat bias" PolygonOffset)
+(void GetTexFilterFuncSGIS -1 "GLenum target, GLenum filter, GLfloat * weights")
+(void TexFilterFuncSGIS -1 "GLenum target, GLenum filter, GLsizei n, const GLfloat * weights")
+(void GetHistogramEXT -1 "GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values" GetHistogram)
+(void GetHistogramParameterfvEXT -1 "GLenum target, GLenum pname, GLfloat * params" GetHistogramParameterfv)
+(void GetHistogramParameterivEXT -1 "GLenum target, GLenum pname, GLint * params" GetHistogramParameteriv)
+(void GetMinmaxEXT -1 "GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values" GetMinmax)
+(void GetMinmaxParameterfvEXT -1 "GLenum target, GLenum pname, GLfloat * params" GetMinmaxParameterfv)
+(void GetMinmaxParameterivEXT -1 "GLenum target, GLenum pname, GLint * params" GetMinmaxParameteriv)
+(void GetConvolutionFilterEXT -1 "GLenum target, GLenum format, GLenum type, GLvoid * image" GetConvolutionFilter)
+(void GetConvolutionParameterfvEXT -1 "GLenum target, GLenum pname, GLfloat * params" GetConvolutionParameterfv)
+(void GetConvolutionParameterivEXT -1 "GLenum target, GLenum pname, GLint * params" GetConvolutionParameteriv)
+(void GetSeparableFilterEXT -1 "GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span" GetSeparableFilter)
+(void GetColorTableSGI -1 "GLenum target, GLenum format, GLenum type, GLvoid * table" GetColorTable)
+(void GetColorTableParameterfvSGI -1 "GLenum target, GLenum pname, GLfloat * params" GetColorTableParameterfv)
+(void GetColorTableParameterivSGI -1 "GLenum target, GLenum pname, GLint * params" GetColorTableParameteriv)
+(void PixelTexGenSGIX -1 "GLenum mode")
+(void PixelTexGenParameteriSGIS -1 "GLenum pname, GLint param")
+(void PixelTexGenParameterivSGIS -1 "GLenum pname, const GLint * params")
+(void PixelTexGenParameterfSGIS -1 "GLenum pname, GLfloat param")
+(void PixelTexGenParameterfvSGIS -1 "GLenum pname, const GLfloat * params")
+(void GetPixelTexGenParameterivSGIS -1 "GLenum pname, GLint * params")
+(void GetPixelTexGenParameterfvSGIS -1 "GLenum pname, GLfloat * params")
+(void TexImage4DSGIS -1 "GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid * pixels")
+(void TexSubImage4DSGIS -1 "GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid * pixels")
+(GLboolean AreTexturesResidentEXT -1 "GLsizei n, const GLenum * textures, GLboolean * residences" AreTexturesResident)
+(void GenTexturesEXT -1 "GLsizei n, GLenum * textures" GenTextures)
+(GLboolean IsTextureEXT -1 "GLenum texture")
+(void DetailTexFuncSGIS -1 "GLenum target, GLsizei n, const GLfloat * points")
+(void GetDetailTexFuncSGIS -1 "GLenum target, GLfloat * points")
+(void SharpenTexFuncSGIS -1 "GLenum target, GLsizei n, const GLfloat * points")
+(void GetSharpenTexFuncSGIS -1 "GLenum target, GLfloat * points")
+(void SampleMaskSGIS -1 "GLclampf value, GLboolean invert")
+(void SamplePatternSGIS -1 "GLenum pattern")
+(void ColorPointerEXT -1 "GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer")
+(void EdgeFlagPointerEXT -1 "GLsizei stride, GLsizei count, const GLboolean * pointer")
+(void IndexPointerEXT -1 "GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer")
+(void NormalPointerEXT -1 "GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer")
+(void TexCoordPointerEXT -1 "GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer")
+(void VertexPointerEXT -1 "GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer")
+(void SpriteParameterfSGIX -1 "GLenum pname, GLfloat param")
+(void SpriteParameterfvSGIX -1 "GLenum pname, const GLfloat * params")
+(void SpriteParameteriSGIX -1 "GLenum pname, GLint param")
+(void SpriteParameterivSGIX -1 "GLenum pname, const GLint * params")
+(void PointParameterfEXT 540 "GLenum pname, GLfloat param" PointParameterf)
+(void PointParameterfvEXT 541 "GLenum pname, const GLfloat * params" PointParameterfv)
+(GLint GetInstrumentsSGIX -1 "void")
+(void InstrumentsBufferSGIX -1 "GLsizei size, GLint * buffer")
+(GLint PollInstrumentsSGIX -1 "GLint * marker_p")
+(void ReadInstrumentsSGIX -1 "GLint marker")
+(void StartInstrumentsSGIX -1 "void")
+(void StopInstrumentsSGIX -1 "GLint marker")
+(void FrameZoomSGIX -1 "GLint factor")
+(void TagSampleBufferSGIX -1 "void")
+(void ReferencePlaneSGIX -1 "const GLdouble * equation")
+(void FlushRasterSGIX -1 "void")
+(void GetListParameterfvSGIX -1 "GLuint list, GLenum pname, GLfloat * params")
+(void GetListParameterivSGIX -1 "GLuint list, GLenum pname, GLint * params")
+(void ListParameterfSGIX -1 "GLuint list, GLenum pname, GLfloat param")
+(void ListParameterfvSGIX -1 "GLuint list, GLenum pname, const GLfloat * params")
+(void ListParameteriSGIX -1 "GLuint list, GLenum pname, GLint param")
+(void ListParameterivSGIX -1 "GLuint list, GLenum pname, const GLint * params")
+(void FragmentColorMaterialSGIX -1 "GLenum face, GLenum mode")
+(void FragmentLightfSGIX -1 "GLenum light, GLenum pname, GLfloat param")
+(void FragmentLightfvSGIX -1 "GLenum light, GLenum pname, const GLfloat * params")
+(void FragmentLightiSGIX -1 "GLenum light, GLenum pname, GLint param")
+(void FragmentLightivSGIX -1 "GLenum light, GLenum pname, const GLint * params")
+(void FragmentLightModelfSGIX -1 "GLenum pname, GLfloat param")
+(void FragmentLightModelfvSGIX -1 "GLenum pname, const GLfloat * params")
+(void FragmentLightModeliSGIX -1 "GLenum pname, GLint param")
+(void FragmentLightModelivSGIX -1 "GLenum pname, const GLint * params")
+(void FragmentMaterialfSGIX -1 "GLenum face, GLenum pname, GLfloat param")
+(void FragmentMaterialfvSGIX -1 "GLenum face, GLenum pname, const GLfloat * params")
+(void FragmentMaterialiSGIX -1 "GLenum face, GLenum pname, GLint param")
+(void FragmentMaterialivSGIX -1 "GLenum face, GLenum pname, const GLint * params")
+(void GetFragmentLightfvSGIX -1 "GLenum light, GLenum pname, GLfloat * params")
+(void GetFragmentLightivSGIX -1 "GLenum light, GLenum pname, GLint * params")
+(void GetFragmentMaterialfvSGIX -1 "GLenum face, GLenum pname, GLfloat * params")
+(void GetFragmentMaterialivSGIX -1 "GLenum face, GLenum pname, GLint * params")
+(void LightEnviSGIX -1 "GLenum pname, GLint param")
+(void VertexWeightfEXT -1 "GLfloat weight")
+(void VertexWeightfvEXT -1 "const GLfloat * weight")
+(void VertexWeightPointerEXT -1 "GLsizei size, GLenum type, GLsizei stride, const GLvoid * pointer")
+(void FlushVertexArrayRangeNV -1 "void")
+(void VertexArrayRangeNV 403 "GLsizei length, const GLvoid * pointer" VertexArrayRangeAPPLE)
+(void CombinerParameterfvNV 441 "GLenum pname, const GLfloat * params")
+(void CombinerParameterfNV 442 "GLenum pname, GLfloat param")
+(void CombinerParameterivNV 443 "GLenum pname, const GLint * params")
+(void CombinerParameteriNV 444 "GLenum pname, GLint param")
+(void CombinerInputNV 445 "GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage")
+(void CombinerOutputNV 446 "GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum")
+(void FinalCombinerInputNV 447 "GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage")
+(void GetCombinerInputParameterfvNV 448 "GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat * params")
+(void GetCombinerInputParameterivNV 449 "GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint * params")
+(void GetCombinerOutputParameterfvNV 450 "GLenum stage, GLenum portion, GLenum pname, GLfloat * params")
+(void GetCombinerOutputParameterivNV 451 "GLenum stage, GLenum portion, GLenum pname, GLint * params")
+(void GetFinalCombinerInputParameterfvNV 452 "GLenum variable, GLenum pname, GLfloat * params")
+(void GetFinalCombinerInputParameterivNV 453 "GLenum variable, GLenum pname, GLint * params")
+(void ResizeBuffersMESA -1 "void")
+(void WindowPos2dMESA 569 "GLdouble x, GLdouble y" WindowPos2d)
+(void WindowPos2dvMESA 570 "const GLdouble * v" WindowPos2dv)
+(void WindowPos2fMESA 571 "GLfloat x, GLfloat y" WindowPos2f)
+(void WindowPos2fvMESA 572 "const GLfloat * v" WindowPos2fv)
+(void WindowPos2iMESA 573 "GLint x, GLint y" WindowPos2i)
+(void WindowPos2ivMESA 574 "const GLint * v" WindowPos2iv)
+(void WindowPos2sMESA 575 "GLshort x, GLshort y" WindowPos2s)
+(void WindowPos2svMESA 576 "const GLshort * v" WindowPos2sv)
+(void WindowPos3dMESA 577 "GLdouble x, GLdouble y, GLdouble z" WindowPos3d)
+(void WindowPos3dvMESA 578 "const GLdouble * v" WindowPos3dv)
+(void WindowPos3fMESA 579 "GLfloat x, GLfloat y, GLfloat z" WindowPos3f)
+(void WindowPos3fvMESA 580 "const GLfloat * v" WindowPos3fv)
+(void WindowPos3iMESA 581 "GLint x, GLint y, GLint z" WindowPos3i)
+(void WindowPos3ivMESA 582 "const GLint * v" WindowPos3iv)
+(void WindowPos3sMESA 583 "GLshort x, GLshort y, GLshort z" WindowPos3s)
+(void WindowPos3svMESA 584 "const GLshort * v" WindowPos3sv)
+(void WindowPos4dMESA -1 "GLdouble x, GLdouble y, GLdouble z, GLdouble w")
+(void WindowPos4dvMESA -1 "const GLdouble * v")
+(void WindowPos4fMESA -1 "GLfloat x, GLfloat y, GLfloat z, GLfloat w")
+(void WindowPos4fvMESA -1 "const GLfloat * v")
+(void WindowPos4iMESA -1 "GLint x, GLint y, GLint z, GLint w")
+(void WindowPos4ivMESA -1 "const GLint * v")
+(void WindowPos4sMESA -1 "GLshort x, GLshort y, GLshort z, GLshort w")
+(void WindowPos4svMESA -1 "const GLshort * v")
+(void BlendFuncSeparateEXT 336 "GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha")
+(void IndexMaterialEXT -1 "GLenum face, GLenum mode")
+(void IndexFuncEXT -1 "GLenum func, GLclampf ref")
+(void LockArraysEXT 339 "GLint first, GLsizei count")
+(void UnlockArraysEXT 340 "void")
+(void CullParameterdvEXT -1 "GLenum pname, GLdouble * params")
+(void CullParameterfvEXT -1 "GLenum pname, GLfloat * params")
+(void HintPGI -1 "GLenum target, GLint mode")
+(void FogCoordfEXT 544 "GLfloat coord")
+(void FogCoordfvEXT 545 "const GLfloat * coord")
+(void FogCoorddEXT 546 "GLdouble coord")
+(void FogCoorddvEXT 547 "const GLdouble * coord")
+(void FogCoordPointerEXT 548 "GLenum type, GLsizei stride, const GLvoid * pointer")
+;; OpenGL.framework defines these, but doesn't have dispatch slots for them
+;; (void GetColorTableEXT -1 "GLenum target, GLenum format, GLenum type, GLvoid * data" GetColorTable)
+;; (void GetColorTableParameterivEXT -1 "GLenum target, GLenum pname, GLint * params" GetColorTableParameteriv)
+;; (void GetColorTableParameterfvEXT -1 "GLenum target, GLenum pname, GLfloat * params" GetColorTableParameterfv)
+(void TbufferMask3DFX -1 "GLuint mask")
+(void CompressedTexImage3DARB 379 "GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid * data")
+(void CompressedTexImage2DARB 380 "GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data")
+(void CompressedTexImage1DARB 381 "GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid * data")
+(void CompressedTexSubImage3DARB 382 "GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid * data")
+(void CompressedTexSubImage2DARB 383 "GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid * data")
+(void CompressedTexSubImage1DARB 384 "GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid * data")
+(void GetCompressedTexImageARB 385 "GLenum target, GLint level, void * img")
+(void SecondaryColor3bEXT 386 "GLbyte red, GLbyte green, GLbyte blue")
+(void SecondaryColor3bvEXT 387 "const GLbyte * v")
+(void SecondaryColor3dEXT 388 "GLdouble red, GLdouble green, GLdouble blue")
+(void SecondaryColor3dvEXT 389 "const GLdouble * v")
+(void SecondaryColor3fEXT 390 "GLfloat red, GLfloat green, GLfloat blue")
+(void SecondaryColor3fvEXT 391 "const GLfloat * v")
+(void SecondaryColor3iEXT 392 "GLint red, GLint green, GLint blue")
+(void SecondaryColor3ivEXT 393 "const GLint * v")
+(void SecondaryColor3sEXT 394 "GLshort red, GLshort green, GLshort blue")
+(void SecondaryColor3svEXT 395 "const GLshort * v")
+(void SecondaryColor3ubEXT 396 "GLubyte red, GLubyte green, GLubyte blue")
+(void SecondaryColor3ubvEXT 397 "const GLubyte * v")
+(void SecondaryColor3uiEXT 398 "GLuint red, GLuint green, GLuint blue")
+(void SecondaryColor3uivEXT 399 "const GLuint * v")
+(void SecondaryColor3usEXT 400 "GLushort red, GLushort green, GLushort blue")
+(void SecondaryColor3usvEXT 401 "const GLushort * v")
+(void SecondaryColorPointerEXT 402 "GLint size, GLenum type, GLsizei stride, const GLvoid * pointer")
+(GLboolean AreProgramsResidentNV -1 "GLsizei n, const GLuint * ids, GLboolean * residences")
+(void BindProgramNV 471 "GLenum target, GLuint id" BindProgramARB)
+(void DeleteProgramsNV 472 "GLsizei n, const GLuint * ids" DeleteProgramsARB)
+(void ExecuteProgramNV -1 "GLenum target, GLuint id, const GLfloat * params")
+(void GenProgramsNV 473 "GLsizei n, GLuint * ids" GenProgramsARB)
+(void GetProgramParameterdvNV -1 "GLenum target, GLuint index, GLenum pname, GLdouble * params")
+(void GetProgramParameterfvNV -1 "GLenum target, GLuint index, GLenum pname, GLfloat * params")
+(void GetProgramivNV -1 "GLuint id, GLenum pname, GLint * params")
+(void GetProgramStringNV -1 "GLuint id, GLenum pname, GLubyte * program")
+(void GetTrackMatrixivNV -1 "GLenum target, GLuint address, GLenum pname, GLint * params")
+(void GetVertexAttribdvNV 514 "GLuint index, GLenum pname, GLdouble * params" GetVertexAttribdvARB)
+(void GetVertexAttribfvNV 515 "GLuint index, GLenum pname, GLfloat * params" GetVertexAttribfvARB)
+(void GetVertexAttribivNV 516 "GLuint index, GLenum pname, GLint * params" GetVertexAttribivNV)
+(void GetVertexAttribPointervNV 517 "GLuint index, GLenum pname, GLvoid ** pointer" GetVertexAttribPointervARB)
+(GLboolean IsProgramNV 474 "GLuint id" IsProgramARB)
+(void LoadProgramNV -1 "GLenum target, GLuint id, GLsizei len, const GLubyte * program")
+(void ProgramParameter4dNV -1 "GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w")
+(void ProgramParameter4dvNV -1 "GLenum target, GLuint index, const GLdouble * params")
+(void ProgramParameter4fNV -1 "GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w")
+(void ProgramParameter4fvNV -1 "GLenum target, GLuint index, const GLfloat * params")
+(void ProgramParameters4dvNV -1 "GLenum target, GLuint index, GLuint num, const GLdouble * params")
+(void ProgramParameters4fvNV -1 "GLenum target, GLuint index, GLuint num, const GLfloat * params")
+(void RequestResidentProgramsNV -1 "GLsizei n, const GLuint * ids")
+(void TrackMatrixNV -1 "GLenum target, GLuint address, GLenum matrix, GLenum transform")
+(void VertexAttribPointerNV -1 "GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer")
+(void VertexAttrib1dNV 477 "GLuint index, GLdouble x" VertexAttrib1dARB)
+(void VertexAttrib1dvNV 490 "GLuint index, const GLdouble * v" VertexAttrib1dvARB)
+(void VertexAttrib1fNV 476 "GLuint index, GLfloat x" VertexAttrib1fARB)
+(void VertexAttrib1fvNV 489 "GLuint index, const GLfloat * v" VertexAttrib1fvARB)
+(void VertexAttrib1sNV 475 "GLuint index, GLshort x" VertexAttrib1sARB)
+(void VertexAttrib1svNV 488 "GLuint index, const GLshort * v" VertexAttrib1svARB)
+(void VertexAttrib2dNV 480 "GLuint index, GLdouble x, GLdouble y" VertexAttrib2dARB)
+(void VertexAttrib2dvNV 493 "GLuint index, const GLdouble * v" VertexAttrib2dvARB)
+(void VertexAttrib2fNV 479 "GLuint index, GLfloat x, GLfloat y" VertexAttrib2fARB)
+(void VertexAttrib2fvNV 492 "GLuint index, const GLfloat * v" VertexAttrib2fvARB)
+(void VertexAttrib2sNV 478 "GLuint index, GLshort x, GLshort y" VertexAttrib2sARB)
+(void VertexAttrib2svNV 491 "GLuint index, const GLshort * v" VertexAttrib2svARB)
+(void VertexAttrib3dNV 483 "GLuint index, GLdouble x, GLdouble y, GLdouble z" VertexAttrib3dARB)
+(void VertexAttrib3dvNV 496 "GLuint index, const GLdouble * v" VertexAttrib3dvARB)
+(void VertexAttrib3fNV 482 "GLuint index, GLfloat x, GLfloat y, GLfloat z" VertexAttrib3fARB)
+(void VertexAttrib3fvNV 495 "GLuint index, const GLfloat * v" VertexAttrib3fvARB)
+(void VertexAttrib3sNV 481 "GLuint index, GLshort x, GLshort y, GLshort z" VertexAttrib3sARB)
+(void VertexAttrib3svNV 494 "GLuint index, const GLshort * v" VertexAttrib3svARB)
+(void VertexAttrib4dNV 486 "GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w" VertexAttrib4dARB)
+(void VertexAttrib4dvNV 504 "GLuint index, const GLdouble * v" VertexAttrib4dvARB)
+(void VertexAttrib4fNV 485 "GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w" VertexAttrib4fARB)
+(void VertexAttrib4fvNV 503 "GLuint index, const GLfloat * v" VertexAttrib4fvARB)
+(void VertexAttrib4sNV 484 "GLuint index, GLshort x, GLshort y, GLshort z, GLshort w" VertexAttrib4sARB)
+(void VertexAttrib4svNV 498 "GLuint index, const GLshort * v" VertexAttrib4svARB)
+(void VertexAttrib4ubNV 487 "GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w" VertexAttrib4NubARB)
+(void VertexAttrib4ubvNV 500 "GLuint index, const GLubyte * v" VertexAttrib4ubvARB)
+(void VertexAttribs1dvNV -1 "GLuint index, GLsizei n, const GLdouble * v")
+(void VertexAttribs1fvNV -1 "GLuint index, GLsizei n, const GLfloat * v")
+(void VertexAttribs1svNV -1 "GLuint index, GLsizei n, const GLshort * v")
+(void VertexAttribs2dvNV -1 "GLuint index, GLsizei n, const GLdouble * v")
+(void VertexAttribs2fvNV -1 "GLuint index, GLsizei n, const GLfloat * v")
+(void VertexAttribs2svNV -1 "GLuint index, GLsizei n, const GLshort * v")
+(void VertexAttribs3dvNV -1 "GLuint index, GLsizei n, const GLdouble * v")
+(void VertexAttribs3fvNV -1 "GLuint index, GLsizei n, const GLfloat * v")
+(void VertexAttribs3svNV -1 "GLuint index, GLsizei n, const GLshort * v")
+(void VertexAttribs4dvNV -1 "GLuint index, GLsizei n, const GLdouble * v")
+(void VertexAttribs4fvNV -1 "GLuint index, GLsizei n, const GLfloat * v")
+(void VertexAttribs4svNV -1 "GLuint index, GLsizei n, const GLshort * v")
+(void VertexAttribs4ubvNV -1 "GLuint index, GLsizei n, const GLubyte * v")
+(void PointParameteriNV 542 "GLenum pname, GLint params")
+(void PointParameterivNV 543 "GLenum pname, const GLint * params")
+(void MultiDrawArraysEXT 567 "GLenum mode, GLint * first, GLsizei * count, GLsizei primcount")
+(void MultiDrawElementsEXT 568 "GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount")
+(void ActiveStencilFaceEXT 585 "GLenum face")
+(void DeleteFencesNV -1 "GLsizei n, const GLuint * fences")
+(void GenFencesNV -1 "GLsizei n, GLuint * fences")
+(GLboolean IsFenceNV -1 "GLuint fence")
+(GLboolean TestFenceNV -1 "GLuint fence")
+(void GetFenceivNV -1 "GLuint fence, GLenum pname, GLint * params")
+(void FinishFenceNV -1 "GLuint fence")
+(void SetFenceNV -1 "GLuint fence, GLenum condition")
+(void VertexAttrib4bvARB 497 "GLuint index, const GLbyte * v")
+(void VertexAttrib4ivARB 499 "GLuint index, const GLint * v")
+(void VertexAttrib4ubvARB 500 "GLuint index, const GLubyte * v")
+(void VertexAttrib4usvARB 501 "GLuint index, const GLushort * v")
+(void VertexAttrib4uivARB 502 "GLuint index, const GLuint * v")
+(void VertexAttrib4NbvARB 505 "GLuint index, const GLbyte * v")
+(void VertexAttrib4NsvARB 498 "GLuint index, const GLshort * v")
+(void VertexAttrib4NivARB 507 "GLuint index, const GLint * v")
+(void VertexAttrib4NusvARB 509 "GLuint index, const GLushort * v")
+(void VertexAttrib4NuivARB 510 "GLuint index, const GLuint * v")
+(void VertexAttribPointerARB 511 "GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer")
+(void EnableVertexAttribArrayARB 512 "GLuint index")
+(void DisableVertexAttribArrayARB 513 "GLuint index")
+(void ProgramStringARB 530 "GLenum target, GLenum format, GLsizei len, const GLvoid * string")
+(void ProgramEnvParameter4dARB 518 "GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w")
+(void ProgramEnvParameter4dvARB 519 "GLenum target, GLuint index, const GLdouble * params")
+(void ProgramEnvParameter4fARB 520 "GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w")
+(void ProgramEnvParameter4fvARB 521 "GLenum target, GLuint index, const GLfloat * params")
+(void ProgramLocalParameter4dARB 522 "GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w")
+(void ProgramLocalParameter4dvARB 523 "GLenum target, GLuint index, const GLdouble * params")
+(void ProgramLocalParameter4fARB 524 "GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w")
+(void ProgramLocalParameter4fvARB 525 "GLenum target, GLuint index, const GLfloat * params")
+(void GetProgramEnvParameterdvARB 526 "GLenum target, GLuint index, GLdouble * params")
+(void GetProgramEnvParameterfvARB 527 "GLenum target, GLuint index, GLfloat * params")
+(void GetProgramLocalParameterdvARB 528 "GLenum target, GLuint index, GLdouble * params")
+(void GetProgramLocalParameterfvARB 529 "GLenum target, GLuint index, GLfloat * params")
+(void GetProgramivARB 532 "GLenum target, GLenum pname, GLint * params")
+(void GetProgramStringARB 531 "GLenum target, GLenum pname, GLvoid * string")
+(void ProgramNamedParameter4fNV -1 "GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w")
+(void ProgramNamedParameter4dNV -1 "GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w")
+(void ProgramNamedParameter4fvNV -1 "GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v")
+(void ProgramNamedParameter4dvNV -1 "GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v")
+(void GetProgramNamedParameterfvNV -1 "GLuint id, GLsizei len, const GLubyte * name, GLfloat * params")
+(void GetProgramNamedParameterdvNV -1 "GLuint id, GLsizei len, const GLubyte * name, GLdouble * params")
+;; On newer versions of Mac OS X, OpenGL.framework defines these but
+;; doesn't have dispatch slots for them. On earlier versions, they are
+;; not defined.
+;; if MAC_OS_X_VERSION < 10.3.4
+;; (void BindBufferARB -1 "GLenum target, GLuint buffer")
+;; (void BufferDataARB -1 "GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage")
+;; (void BufferSubDataARB -1 "GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data")
+;; (void DeleteBuffersARB -1 "GLsizei n, const GLuint * buffer")
+;; (void GenBuffersARB -1 "GLsizei n, GLuint * buffer")
+;; (void GetBufferParameterivARB -1 "GLenum target, GLenum pname, GLint * params")
+;; (void GetBufferPointervARB -1 "GLenum target, GLenum pname, GLvoid ** params")
+;; (void GetBufferSubDataARB -1 "GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data")
+;; (GLboolean IsBufferARB -1 "GLuint buffer")
+;; (void* MapBufferARB -1 "GLenum target, GLenum access")
+;; (GLboolean UnmapBufferARB -1 "GLenum target")
+;; (void DepthBoundsEXT -1 "GLclampd zmin, GLclampd zmax")
+;; endif
+;; if MAC_OS_X_VERSION < 10.3.0
+;; (void GenQueriesARB -1 "GLsizei n, GLuint * ids")
+;; (void DeleteQueriesARB -1 "GLsizei n, const GLuint * ids")
+;; (GLboolean IsQueryARB -1 "GLuint id")
+;; (void BeginQueryARB -1 "GLenum target, GLuint id")
+;; (void EndQueryARB -1 "GLenum target")
+;; (void GetQueryivARB -1 "GLenum target, GLenum pname, GLint * params")
+;; (void GetQueryObjectivARB -1 "GLuint id, GLenum pname, GLint * params")
+;; (void GetQueryObjectuivARB -1 "GLuint id, GLenum pname, GLuint * params")
+;; endif
+(void MultiModeDrawArraysIBM -1 "const GLenum * mode, const GLint * first, const GLsizei * count, GLsizei primcount, GLint modestride")
+(void MultiModeDrawElementsIBM -1 "const GLenum * mode, const GLsizei * count, GLenum type, const GLvoid * const * indices, GLsizei primcount, GLint modestride")
+;; if MAC_OS_X_VERSION < 10.3.4
+;; (void BlendEquationSeparateEXT 458 "GLenum modeRGB, GLenum modeA" BlendEquationSeparateATI)
+;; else
+(void BlendEquationSeparateEXT 458 "GLenum modeRGB, GLenum modeA")
+;; endif
+
+;; Entry points that exist in standard XFree86 libGL, but aren't in the
+;; Mesa dispatch table, and aren't in OpenGL.framework
+
+(void ArrayElementEXT -1 "GLint i" ArrayElement)
+(void BindTextureEXT -1 "GLenum target, GLuint texture" BindTexture)
+(void BlendFuncSeparateINGR -1 "GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha" BlendFuncSeparateEXT)
+(void ColorTableParameterfvSGI -1 "GLenum target, GLenum pname, const GLfloat * params" ColorTableParameterfv)
+(void ColorTableParameterivSGI -1 "GLenum target, GLenum pname, const GLint * params" ColorTableParameteriv)
+(void ColorTableSGI -1 "GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table" ColorTable)
+(void ConvolutionFilter1DEXT -1 "GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * image" ConvolutionFilter1D)
+(void ConvolutionFilter2DEXT -1 "GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * image" ConvolutionFilter2D)
+(void ConvolutionParameterfEXT -1 "GLenum target, GLenum pname, GLfloat params" ConvolutionParameterf)
+(void ConvolutionParameterfvEXT -1 "GLenum target, GLenum pname, const GLfloat * params" ConvolutionParameterfv)
+(void ConvolutionParameteriEXT -1 "GLenum target, GLenum pname, GLint params" ConvolutionParameteri)
+(void ConvolutionParameterivEXT -1 "GLenum target, GLenum pname, const GLint * params" ConvolutionParameteriv)
+(void CopyColorSubTableEXT -1 "GLenum target, GLsizei start, GLint x, GLint y, GLsizei width" CopyColorSubTable)
+(void CopyColorTableSGI -1 "GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width" CopyColorTable)
+(void CopyConvolutionFilter1DEXT -1 "GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width" CopyConvolutionFilter1D)
+(void CopyConvolutionFilter2DEXT -1 "GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height" CopyConvolutionFilter2D)
+(void CopyTexImage1DEXT -1 "GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border" CopyTexImage1D)
+(void CopyTexImage2DEXT -1 "GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border" CopyTexImage2D)
+(void CopyTexSubImage1DEXT -1 "GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width" CopyTexSubImage1D)
+(void CopyTexSubImage2DEXT -1 "GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height" CopyTexSubImage2D)
+(void CopyTexSubImage3DEXT -1 "GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height" CopyTexSubImage3D)
+(void DeleteTexturesEXT -1 "GLsizei n, const GLuint *textures" DeleteTextures)
+(void DrawArraysEXT -1 "GLenum mode, GLint first, GLsizei count" DrawArrays)
+(void GetPointervEXT -1 "GLenum pname, GLvoid * * params" GetPointerv)
+(void HistogramEXT -1 "GLenum target, GLsizei width, GLenum internalformat, GLboolean sink" Histogram)
+(void MinmaxEXT -1 "GLenum target, GLenum internalformat, GLboolean sink" Minmax)
+(void PointParameterfSGIS -1 "GLenum pname, GLfloat param" PointParameterf)
+(void PointParameterfvSGIS -1 "GLenum pname, const GLfloat * params" PointParameterfv)
+(void PointParameteri -1 "GLenum pname, GLint params" PointParameteriNV)
+(void PointParameteriv -1 "GLenum pname, const GLint * params" PointParameterivNV)
+(void PrioritizeTexturesEXT -1 "GLsizei n, const GLenum * textures, const GLclampf * priorities" PrioritizeTextures)
+(void ResetHistogramEXT -1 "GLenum target" ResetHistogram)
+(void ResetMinmaxEXT -1 "GLenum target" ResetMinmax)
+(void SampleMaskEXT -1 "GLclampf value, GLboolean invert" SampleMaskSGIS)
+(void SamplePatternEXT -1 "GLenum pattern" SamplePatternSGIS)
+(void SeparableFilter2DEXT -1 "GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * row, const GLvoid * column" SeparableFilter2D)
+(void TexImage3DEXT -1 "GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels" TexImage3D)
+(void TexSubImage1DEXT -1 "GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid * pixels" TexSubImage1D)
+(void TexSubImage2DEXT -1 "GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels" TexSubImage2D)
+(void TexSubImage3DEXT -1 "GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels" TexSubImage3D)
+;; if MAC_OS_X_VERSION < 10.3.4
+;; (void BindBuffer -1 "GLenum target, GLuint buffer" BindBufferARB)
+;; (void BufferData -1 "GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage" BufferDataARB)
+;; (void BufferSubData -1 "GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data" BufferSubDataARB)
+;; (void DeleteBuffers -1 "GLsizei n, const GLuint * buffer" DeleteBuffersARB)
+;; (void GenBuffers -1 "GLsizei n, GLuint * buffer" GenBuffersARB)
+;; (void GetBufferParameteriv -1 "GLenum target, GLenum pname, GLint * params" GetBufferParameterivARB)
+;; (void GetBufferPointerv -1 "GLenum target, GLenum pname, GLvoid ** params" GetBufferPointervARB)
+;; (void GetBufferSubData -1 "GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data" GetBufferSubDataARB)
+;; (GLboolean IsBuffer -1 "GLuint buffer" IsBufferARB)
+;; (void* MapBuffer -1 "GLenum target, GLenum access" MapBufferARB)
+;; (GLboolean UnmapBuffer -1 "GLenum target" UnmapBufferARB)
+;; endif
+;; if MAC_OS_X_VERSION < 10.3.0
+;; (void GenQueries -1 "GLsizei n, GLuint * ids" GenQueriesARB)
+;; (void DeleteQueries -1 "GLsizei n, const GLuint * ids" DeleteQueriesARB)
+;; (GLboolean IsQuery -1 "GLuint id" IsQueryARB)
+;; (void BeginQuery -1 "GLenum target, GLuint id" BeginQueryARB)
+;; (void EndQuery -1 "GLenum target" EndQueryARB)
+;; (void GetQueryiv -1 "GLenum target, GLenum pname, GLint * params" GetQueryivARB)
+;; (void GetQueryObjectiv -1 "GLuint id, GLenum pname, GLint * params" GetQueryObjectivARB)
+;; (void GetQueryObjectuiv -1 "GLuint id, GLenum pname, GLuint * params" GetQueryObjectuivARB)
+;; endif
diff --git a/nx-X11/lib/GL/apple/dri_dispatch.h b/nx-X11/lib/GL/apple/dri_dispatch.h
new file mode 100644
index 000000000..854bbc302
--- /dev/null
+++ b/nx-X11/lib/GL/apple/dri_dispatch.h
@@ -0,0 +1,3861 @@
+/* dri_dispatch.h -- built automatically, DO NOT EDIT
+ $Id: dri_dispatch.h,v 1.6 2005/07/03 07:00:55 daniels Exp $
+ $XFree86: $ */
+/*
+ Actually, this file has been edited to add necessary
+ dependencies on the version of Mac OS X. Someday the
+ automatic script should handle this.
+ */
+
+DEFUN_LOCAL_VOID (NewList,
+ (void *rend, GLuint list, GLenum mode),
+ (list, mode))
+
+DEFUN_LOCAL_VOID (EndList,
+ (void *rend),
+ ())
+
+DEFUN_LOCAL_VOID (CallList,
+ (void *rend, GLuint list),
+ (list))
+
+DEFUN_LOCAL_VOID (CallLists,
+ (void *rend, GLsizei n, GLenum type, const GLvoid * lists),
+ (n, type, lists))
+
+DEFUN_LOCAL_VOID (DeleteLists,
+ (void *rend, GLuint list, GLsizei range),
+ (list, range))
+
+DEFUN_LOCAL (GLuint, GenLists,
+ (void *rend, GLsizei range),
+ (range))
+
+DEFUN_LOCAL_VOID (ListBase,
+ (void *rend, GLuint base),
+ (base))
+
+DEFUN_LOCAL_VOID (Begin,
+ (void *rend, GLenum mode),
+ (mode))
+
+DEFUN_LOCAL_VOID (Bitmap,
+ (void *rend, GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap),
+ (width, height, xorig, yorig, xmove, ymove, bitmap))
+
+DEFUN_LOCAL_VOID (Color3b,
+ (void *rend, GLbyte red, GLbyte green, GLbyte blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (Color3bv,
+ (void *rend, const GLbyte * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color3d,
+ (void *rend, GLdouble red, GLdouble green, GLdouble blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (Color3dv,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color3f,
+ (void *rend, GLfloat red, GLfloat green, GLfloat blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (Color3fv,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color3i,
+ (void *rend, GLint red, GLint green, GLint blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (Color3iv,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color3s,
+ (void *rend, GLshort red, GLshort green, GLshort blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (Color3sv,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color3ub,
+ (void *rend, GLubyte red, GLubyte green, GLubyte blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (Color3ubv,
+ (void *rend, const GLubyte * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color3ui,
+ (void *rend, GLuint red, GLuint green, GLuint blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (Color3uiv,
+ (void *rend, const GLuint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color3us,
+ (void *rend, GLushort red, GLushort green, GLushort blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (Color3usv,
+ (void *rend, const GLushort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color4b,
+ (void *rend, GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha),
+ (red, green, blue, alpha))
+
+DEFUN_LOCAL_VOID (Color4bv,
+ (void *rend, const GLbyte * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color4d,
+ (void *rend, GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha),
+ (red, green, blue, alpha))
+
+DEFUN_LOCAL_VOID (Color4dv,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color4f,
+ (void *rend, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha),
+ (red, green, blue, alpha))
+
+DEFUN_LOCAL_VOID (Color4fv,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color4i,
+ (void *rend, GLint red, GLint green, GLint blue, GLint alpha),
+ (red, green, blue, alpha))
+
+DEFUN_LOCAL_VOID (Color4iv,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color4s,
+ (void *rend, GLshort red, GLshort green, GLshort blue, GLshort alpha),
+ (red, green, blue, alpha))
+
+DEFUN_LOCAL_VOID (Color4sv,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color4ub,
+ (void *rend, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha),
+ (red, green, blue, alpha))
+
+DEFUN_LOCAL_VOID (Color4ubv,
+ (void *rend, const GLubyte * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color4ui,
+ (void *rend, GLuint red, GLuint green, GLuint blue, GLuint alpha),
+ (red, green, blue, alpha))
+
+DEFUN_LOCAL_VOID (Color4uiv,
+ (void *rend, const GLuint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Color4us,
+ (void *rend, GLushort red, GLushort green, GLushort blue, GLushort alpha),
+ (red, green, blue, alpha))
+
+DEFUN_LOCAL_VOID (Color4usv,
+ (void *rend, const GLushort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (EdgeFlag,
+ (void *rend, GLboolean flag),
+ (flag))
+
+DEFUN_LOCAL_VOID (EdgeFlagv,
+ (void *rend, const GLboolean * flag),
+ (flag))
+
+DEFUN_LOCAL_VOID (End,
+ (void *rend),
+ ())
+
+DEFUN_LOCAL_VOID (Indexd,
+ (void *rend, GLdouble c),
+ (c))
+
+DEFUN_LOCAL_VOID (Indexdv,
+ (void *rend, const GLdouble * c),
+ (c))
+
+DEFUN_LOCAL_VOID (Indexf,
+ (void *rend, GLfloat c),
+ (c))
+
+DEFUN_LOCAL_VOID (Indexfv,
+ (void *rend, const GLfloat * c),
+ (c))
+
+DEFUN_LOCAL_VOID (Indexi,
+ (void *rend, GLint c),
+ (c))
+
+DEFUN_LOCAL_VOID (Indexiv,
+ (void *rend, const GLint * c),
+ (c))
+
+DEFUN_LOCAL_VOID (Indexs,
+ (void *rend, GLshort c),
+ (c))
+
+DEFUN_LOCAL_VOID (Indexsv,
+ (void *rend, const GLshort * c),
+ (c))
+
+DEFUN_LOCAL_VOID (Normal3b,
+ (void *rend, GLbyte nx, GLbyte ny, GLbyte nz),
+ (nx, ny, nz))
+
+DEFUN_LOCAL_VOID (Normal3bv,
+ (void *rend, const GLbyte * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Normal3d,
+ (void *rend, GLdouble nx, GLdouble ny, GLdouble nz),
+ (nx, ny, nz))
+
+DEFUN_LOCAL_VOID (Normal3dv,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Normal3f,
+ (void *rend, GLfloat nx, GLfloat ny, GLfloat nz),
+ (nx, ny, nz))
+
+DEFUN_LOCAL_VOID (Normal3fv,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Normal3i,
+ (void *rend, GLint nx, GLint ny, GLint nz),
+ (nx, ny, nz))
+
+DEFUN_LOCAL_VOID (Normal3iv,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Normal3s,
+ (void *rend, GLshort nx, GLshort ny, GLshort nz),
+ (nx, ny, nz))
+
+DEFUN_LOCAL_VOID (Normal3sv,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (RasterPos2d,
+ (void *rend, GLdouble x, GLdouble y),
+ (x, y))
+
+DEFUN_LOCAL_VOID (RasterPos2dv,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (RasterPos2f,
+ (void *rend, GLfloat x, GLfloat y),
+ (x, y))
+
+DEFUN_LOCAL_VOID (RasterPos2fv,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (RasterPos2i,
+ (void *rend, GLint x, GLint y),
+ (x, y))
+
+DEFUN_LOCAL_VOID (RasterPos2iv,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (RasterPos2s,
+ (void *rend, GLshort x, GLshort y),
+ (x, y))
+
+DEFUN_LOCAL_VOID (RasterPos2sv,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (RasterPos3d,
+ (void *rend, GLdouble x, GLdouble y, GLdouble z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (RasterPos3dv,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (RasterPos3f,
+ (void *rend, GLfloat x, GLfloat y, GLfloat z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (RasterPos3fv,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (RasterPos3i,
+ (void *rend, GLint x, GLint y, GLint z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (RasterPos3iv,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (RasterPos3s,
+ (void *rend, GLshort x, GLshort y, GLshort z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (RasterPos3sv,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (RasterPos4d,
+ (void *rend, GLdouble x, GLdouble y, GLdouble z, GLdouble w),
+ (x, y, z, w))
+
+DEFUN_LOCAL_VOID (RasterPos4dv,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (RasterPos4f,
+ (void *rend, GLfloat x, GLfloat y, GLfloat z, GLfloat w),
+ (x, y, z, w))
+
+DEFUN_LOCAL_VOID (RasterPos4fv,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (RasterPos4i,
+ (void *rend, GLint x, GLint y, GLint z, GLint w),
+ (x, y, z, w))
+
+DEFUN_LOCAL_VOID (RasterPos4iv,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (RasterPos4s,
+ (void *rend, GLshort x, GLshort y, GLshort z, GLshort w),
+ (x, y, z, w))
+
+DEFUN_LOCAL_VOID (RasterPos4sv,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Rectd,
+ (void *rend, GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2),
+ (x1, y1, x2, y2))
+
+DEFUN_LOCAL_VOID (Rectdv,
+ (void *rend, const GLdouble * v1, const GLdouble * v2),
+ (v1, v2))
+
+DEFUN_LOCAL_VOID (Rectf,
+ (void *rend, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2),
+ (x1, y1, x2, y2))
+
+DEFUN_LOCAL_VOID (Rectfv,
+ (void *rend, const GLfloat * v1, const GLfloat * v2),
+ (v1, v2))
+
+DEFUN_LOCAL_VOID (Recti,
+ (void *rend, GLint x1, GLint y1, GLint x2, GLint y2),
+ (x1, y1, x2, y2))
+
+DEFUN_LOCAL_VOID (Rectiv,
+ (void *rend, const GLint * v1, const GLint * v2),
+ (v1, v2))
+
+DEFUN_LOCAL_VOID (Rects,
+ (void *rend, GLshort x1, GLshort y1, GLshort x2, GLshort y2),
+ (x1, y1, x2, y2))
+
+DEFUN_LOCAL_VOID (Rectsv,
+ (void *rend, const GLshort * v1, const GLshort * v2),
+ (v1, v2))
+
+DEFUN_LOCAL_VOID (TexCoord1d,
+ (void *rend, GLdouble s),
+ (s))
+
+DEFUN_LOCAL_VOID (TexCoord1dv,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord1f,
+ (void *rend, GLfloat s),
+ (s))
+
+DEFUN_LOCAL_VOID (TexCoord1fv,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord1i,
+ (void *rend, GLint s),
+ (s))
+
+DEFUN_LOCAL_VOID (TexCoord1iv,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord1s,
+ (void *rend, GLshort s),
+ (s))
+
+DEFUN_LOCAL_VOID (TexCoord1sv,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord2d,
+ (void *rend, GLdouble s, GLdouble t),
+ (s, t))
+
+DEFUN_LOCAL_VOID (TexCoord2dv,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord2f,
+ (void *rend, GLfloat s, GLfloat t),
+ (s, t))
+
+DEFUN_LOCAL_VOID (TexCoord2fv,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord2i,
+ (void *rend, GLint s, GLint t),
+ (s, t))
+
+DEFUN_LOCAL_VOID (TexCoord2iv,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord2s,
+ (void *rend, GLshort s, GLshort t),
+ (s, t))
+
+DEFUN_LOCAL_VOID (TexCoord2sv,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord3d,
+ (void *rend, GLdouble s, GLdouble t, GLdouble r),
+ (s, t, r))
+
+DEFUN_LOCAL_VOID (TexCoord3dv,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord3f,
+ (void *rend, GLfloat s, GLfloat t, GLfloat r),
+ (s, t, r))
+
+DEFUN_LOCAL_VOID (TexCoord3fv,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord3i,
+ (void *rend, GLint s, GLint t, GLint r),
+ (s, t, r))
+
+DEFUN_LOCAL_VOID (TexCoord3iv,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord3s,
+ (void *rend, GLshort s, GLshort t, GLshort r),
+ (s, t, r))
+
+DEFUN_LOCAL_VOID (TexCoord3sv,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord4d,
+ (void *rend, GLdouble s, GLdouble t, GLdouble r, GLdouble q),
+ (s, t, r, q))
+
+DEFUN_LOCAL_VOID (TexCoord4dv,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord4f,
+ (void *rend, GLfloat s, GLfloat t, GLfloat r, GLfloat q),
+ (s, t, r, q))
+
+DEFUN_LOCAL_VOID (TexCoord4fv,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord4i,
+ (void *rend, GLint s, GLint t, GLint r, GLint q),
+ (s, t, r, q))
+
+DEFUN_LOCAL_VOID (TexCoord4iv,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (TexCoord4s,
+ (void *rend, GLshort s, GLshort t, GLshort r, GLshort q),
+ (s, t, r, q))
+
+DEFUN_LOCAL_VOID (TexCoord4sv,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Vertex2d,
+ (void *rend, GLdouble x, GLdouble y),
+ (x, y))
+
+DEFUN_LOCAL_VOID (Vertex2dv,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Vertex2f,
+ (void *rend, GLfloat x, GLfloat y),
+ (x, y))
+
+DEFUN_LOCAL_VOID (Vertex2fv,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Vertex2i,
+ (void *rend, GLint x, GLint y),
+ (x, y))
+
+DEFUN_LOCAL_VOID (Vertex2iv,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Vertex2s,
+ (void *rend, GLshort x, GLshort y),
+ (x, y))
+
+DEFUN_LOCAL_VOID (Vertex2sv,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Vertex3d,
+ (void *rend, GLdouble x, GLdouble y, GLdouble z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (Vertex3dv,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Vertex3f,
+ (void *rend, GLfloat x, GLfloat y, GLfloat z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (Vertex3fv,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Vertex3i,
+ (void *rend, GLint x, GLint y, GLint z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (Vertex3iv,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Vertex3s,
+ (void *rend, GLshort x, GLshort y, GLshort z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (Vertex3sv,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Vertex4d,
+ (void *rend, GLdouble x, GLdouble y, GLdouble z, GLdouble w),
+ (x, y, z, w))
+
+DEFUN_LOCAL_VOID (Vertex4dv,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Vertex4f,
+ (void *rend, GLfloat x, GLfloat y, GLfloat z, GLfloat w),
+ (x, y, z, w))
+
+DEFUN_LOCAL_VOID (Vertex4fv,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Vertex4i,
+ (void *rend, GLint x, GLint y, GLint z, GLint w),
+ (x, y, z, w))
+
+DEFUN_LOCAL_VOID (Vertex4iv,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (Vertex4s,
+ (void *rend, GLshort x, GLshort y, GLshort z, GLshort w),
+ (x, y, z, w))
+
+DEFUN_LOCAL_VOID (Vertex4sv,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (ClipPlane,
+ (void *rend, GLenum plane, const GLdouble * equation),
+ (plane, equation))
+
+DEFUN_LOCAL_VOID (ColorMaterial,
+ (void *rend, GLenum face, GLenum mode),
+ (face, mode))
+
+DEFUN_LOCAL_VOID (CullFace,
+ (void *rend, GLenum mode),
+ (mode))
+
+DEFUN_LOCAL_VOID (Fogf,
+ (void *rend, GLenum pname, GLfloat param),
+ (pname, param))
+
+DEFUN_LOCAL_VOID (Fogfv,
+ (void *rend, GLenum pname, const GLfloat * params),
+ (pname, params))
+
+DEFUN_LOCAL_VOID (Fogi,
+ (void *rend, GLenum pname, GLint param),
+ (pname, param))
+
+DEFUN_LOCAL_VOID (Fogiv,
+ (void *rend, GLenum pname, const GLint * params),
+ (pname, params))
+
+DEFUN_LOCAL_VOID (FrontFace,
+ (void *rend, GLenum mode),
+ (mode))
+
+DEFUN_LOCAL_VOID (Hint,
+ (void *rend, GLenum target, GLenum mode),
+ (target, mode))
+
+DEFUN_LOCAL_VOID (Lightf,
+ (void *rend, GLenum light, GLenum pname, GLfloat param),
+ (light, pname, param))
+
+DEFUN_LOCAL_VOID (Lightfv,
+ (void *rend, GLenum light, GLenum pname, const GLfloat * params),
+ (light, pname, params))
+
+DEFUN_LOCAL_VOID (Lighti,
+ (void *rend, GLenum light, GLenum pname, GLint param),
+ (light, pname, param))
+
+DEFUN_LOCAL_VOID (Lightiv,
+ (void *rend, GLenum light, GLenum pname, const GLint * params),
+ (light, pname, params))
+
+DEFUN_LOCAL_VOID (LightModelf,
+ (void *rend, GLenum pname, GLfloat param),
+ (pname, param))
+
+DEFUN_LOCAL_VOID (LightModelfv,
+ (void *rend, GLenum pname, const GLfloat * params),
+ (pname, params))
+
+DEFUN_LOCAL_VOID (LightModeli,
+ (void *rend, GLenum pname, GLint param),
+ (pname, param))
+
+DEFUN_LOCAL_VOID (LightModeliv,
+ (void *rend, GLenum pname, const GLint * params),
+ (pname, params))
+
+DEFUN_LOCAL_VOID (LineStipple,
+ (void *rend, GLint factor, GLushort pattern),
+ (factor, pattern))
+
+DEFUN_LOCAL_VOID (LineWidth,
+ (void *rend, GLfloat width),
+ (width))
+
+DEFUN_LOCAL_VOID (Materialf,
+ (void *rend, GLenum face, GLenum pname, GLfloat param),
+ (face, pname, param))
+
+DEFUN_LOCAL_VOID (Materialfv,
+ (void *rend, GLenum face, GLenum pname, const GLfloat * params),
+ (face, pname, params))
+
+DEFUN_LOCAL_VOID (Materiali,
+ (void *rend, GLenum face, GLenum pname, GLint param),
+ (face, pname, param))
+
+DEFUN_LOCAL_VOID (Materialiv,
+ (void *rend, GLenum face, GLenum pname, const GLint * params),
+ (face, pname, params))
+
+DEFUN_LOCAL_VOID (PointSize,
+ (void *rend, GLfloat size),
+ (size))
+
+DEFUN_LOCAL_VOID (PolygonMode,
+ (void *rend, GLenum face, GLenum mode),
+ (face, mode))
+
+DEFUN_LOCAL_VOID (PolygonStipple,
+ (void *rend, const GLubyte * mask),
+ (mask))
+
+DEFUN_LOCAL_VOID (Scissor,
+ (void *rend, GLint x, GLint y, GLsizei width, GLsizei height),
+ (x, y, width, height))
+
+DEFUN_LOCAL_VOID (ShadeModel,
+ (void *rend, GLenum mode),
+ (mode))
+
+DEFUN_LOCAL_VOID (TexParameterf,
+ (void *rend, GLenum target, GLenum pname, GLfloat param),
+ (target, pname, param))
+
+DEFUN_LOCAL_VOID (TexParameterfv,
+ (void *rend, GLenum target, GLenum pname, const GLfloat * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (TexParameteri,
+ (void *rend, GLenum target, GLenum pname, GLint param),
+ (target, pname, param))
+
+DEFUN_LOCAL_VOID (TexParameteriv,
+ (void *rend, GLenum target, GLenum pname, const GLint * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (TexImage1D,
+ (void *rend, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid * pixels),
+ (target, level, internalformat, width, border, format, type, pixels))
+
+DEFUN_LOCAL_VOID (TexImage2D,
+ (void *rend, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels),
+ (target, level, internalformat, width, height, border, format, type, pixels))
+
+DEFUN_LOCAL_VOID (TexEnvf,
+ (void *rend, GLenum target, GLenum pname, GLfloat param),
+ (target, pname, param))
+
+DEFUN_LOCAL_VOID (TexEnvfv,
+ (void *rend, GLenum target, GLenum pname, const GLfloat * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (TexEnvi,
+ (void *rend, GLenum target, GLenum pname, GLint param),
+ (target, pname, param))
+
+DEFUN_LOCAL_VOID (TexEnviv,
+ (void *rend, GLenum target, GLenum pname, const GLint * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (TexGend,
+ (void *rend, GLenum coord, GLenum pname, GLdouble param),
+ (coord, pname, param))
+
+DEFUN_LOCAL_VOID (TexGendv,
+ (void *rend, GLenum coord, GLenum pname, const GLdouble * params),
+ (coord, pname, params))
+
+DEFUN_LOCAL_VOID (TexGenf,
+ (void *rend, GLenum coord, GLenum pname, GLfloat param),
+ (coord, pname, param))
+
+DEFUN_LOCAL_VOID (TexGenfv,
+ (void *rend, GLenum coord, GLenum pname, const GLfloat * params),
+ (coord, pname, params))
+
+DEFUN_LOCAL_VOID (TexGeni,
+ (void *rend, GLenum coord, GLenum pname, GLint param),
+ (coord, pname, param))
+
+DEFUN_LOCAL_VOID (TexGeniv,
+ (void *rend, GLenum coord, GLenum pname, const GLint * params),
+ (coord, pname, params))
+
+DEFUN_LOCAL_VOID (FeedbackBuffer,
+ (void *rend, GLsizei size, GLenum type, GLfloat * buffer),
+ (size, type, buffer))
+
+DEFUN_LOCAL_VOID (SelectBuffer,
+ (void *rend, GLsizei size, GLuint * buffer),
+ (size, buffer))
+
+DEFUN_LOCAL (GLint, RenderMode,
+ (void *rend, GLenum mode),
+ (mode))
+
+DEFUN_LOCAL_VOID (InitNames,
+ (void *rend),
+ ())
+
+DEFUN_LOCAL_VOID (LoadName,
+ (void *rend, GLuint name),
+ (name))
+
+DEFUN_LOCAL_VOID (PassThrough,
+ (void *rend, GLfloat token),
+ (token))
+
+DEFUN_LOCAL_VOID (PopName,
+ (void *rend),
+ ())
+
+DEFUN_LOCAL_VOID (PushName,
+ (void *rend, GLuint name),
+ (name))
+
+DEFUN_LOCAL_VOID (DrawBuffer,
+ (void *rend, GLenum mode),
+ (mode))
+
+DEFUN_LOCAL_VOID (Clear,
+ (void *rend, GLbitfield mask),
+ (mask))
+
+DEFUN_LOCAL_VOID (ClearAccum,
+ (void *rend, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha),
+ (red, green, blue, alpha))
+
+DEFUN_LOCAL_VOID (ClearIndex,
+ (void *rend, GLfloat c),
+ (c))
+
+DEFUN_LOCAL_VOID (ClearColor,
+ (void *rend, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha),
+ (red, green, blue, alpha))
+
+DEFUN_LOCAL_VOID (ClearStencil,
+ (void *rend, GLint s),
+ (s))
+
+DEFUN_LOCAL_VOID (ClearDepth,
+ (void *rend, GLclampd depth),
+ (depth))
+
+DEFUN_LOCAL_VOID (StencilMask,
+ (void *rend, GLuint mask),
+ (mask))
+
+DEFUN_LOCAL_VOID (ColorMask,
+ (void *rend, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha),
+ (red, green, blue, alpha))
+
+DEFUN_LOCAL_VOID (DepthMask,
+ (void *rend, GLboolean flag),
+ (flag))
+
+DEFUN_LOCAL_VOID (IndexMask,
+ (void *rend, GLuint mask),
+ (mask))
+
+DEFUN_LOCAL_VOID (Accum,
+ (void *rend, GLenum op, GLfloat value),
+ (op, value))
+
+DEFUN_LOCAL_VOID (Disable,
+ (void *rend, GLenum cap),
+ (cap))
+
+DEFUN_LOCAL_VOID (Enable,
+ (void *rend, GLenum cap),
+ (cap))
+
+DEFUN_LOCAL_VOID (Finish,
+ (void *rend),
+ ())
+
+DEFUN_LOCAL_VOID (Flush,
+ (void *rend),
+ ())
+
+DEFUN_LOCAL_VOID (PopAttrib,
+ (void *rend),
+ ())
+
+DEFUN_LOCAL_VOID (PushAttrib,
+ (void *rend, GLbitfield mask),
+ (mask))
+
+DEFUN_LOCAL_VOID (Map1d,
+ (void *rend, GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points),
+ (target, u1, u2, stride, order, points))
+
+DEFUN_LOCAL_VOID (Map1f,
+ (void *rend, GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points),
+ (target, u1, u2, stride, order, points))
+
+DEFUN_LOCAL_VOID (Map2d,
+ (void *rend, GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points),
+ (target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points))
+
+DEFUN_LOCAL_VOID (Map2f,
+ (void *rend, GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points),
+ (target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points))
+
+DEFUN_LOCAL_VOID (MapGrid1d,
+ (void *rend, GLint un, GLdouble u1, GLdouble u2),
+ (un, u1, u2))
+
+DEFUN_LOCAL_VOID (MapGrid1f,
+ (void *rend, GLint un, GLfloat u1, GLfloat u2),
+ (un, u1, u2))
+
+DEFUN_LOCAL_VOID (MapGrid2d,
+ (void *rend, GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2),
+ (un, u1, u2, vn, v1, v2))
+
+DEFUN_LOCAL_VOID (MapGrid2f,
+ (void *rend, GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2),
+ (un, u1, u2, vn, v1, v2))
+
+DEFUN_LOCAL_VOID (EvalCoord1d,
+ (void *rend, GLdouble u),
+ (u))
+
+DEFUN_LOCAL_VOID (EvalCoord1dv,
+ (void *rend, const GLdouble * u),
+ (u))
+
+DEFUN_LOCAL_VOID (EvalCoord1f,
+ (void *rend, GLfloat u),
+ (u))
+
+DEFUN_LOCAL_VOID (EvalCoord1fv,
+ (void *rend, const GLfloat * u),
+ (u))
+
+DEFUN_LOCAL_VOID (EvalCoord2d,
+ (void *rend, GLdouble u, GLdouble v),
+ (u, v))
+
+DEFUN_LOCAL_VOID (EvalCoord2dv,
+ (void *rend, const GLdouble * u),
+ (u))
+
+DEFUN_LOCAL_VOID (EvalCoord2f,
+ (void *rend, GLfloat u, GLfloat v),
+ (u, v))
+
+DEFUN_LOCAL_VOID (EvalCoord2fv,
+ (void *rend, const GLfloat * u),
+ (u))
+
+DEFUN_LOCAL_VOID (EvalMesh1,
+ (void *rend, GLenum mode, GLint i1, GLint i2),
+ (mode, i1, i2))
+
+DEFUN_LOCAL_VOID (EvalPoint1,
+ (void *rend, GLint i),
+ (i))
+
+DEFUN_LOCAL_VOID (EvalMesh2,
+ (void *rend, GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2),
+ (mode, i1, i2, j1, j2))
+
+DEFUN_LOCAL_VOID (EvalPoint2,
+ (void *rend, GLint i, GLint j),
+ (i, j))
+
+DEFUN_LOCAL_VOID (AlphaFunc,
+ (void *rend, GLenum func, GLclampf ref),
+ (func, ref))
+
+DEFUN_LOCAL_VOID (BlendFunc,
+ (void *rend, GLenum sfactor, GLenum dfactor),
+ (sfactor, dfactor))
+
+DEFUN_LOCAL_VOID (LogicOp,
+ (void *rend, GLenum opcode),
+ (opcode))
+
+DEFUN_LOCAL_VOID (StencilFunc,
+ (void *rend, GLenum func, GLint ref, GLuint mask),
+ (func, ref, mask))
+
+DEFUN_LOCAL_VOID (StencilOp,
+ (void *rend, GLenum fail, GLenum zfail, GLenum zpass),
+ (fail, zfail, zpass))
+
+DEFUN_LOCAL_VOID (DepthFunc,
+ (void *rend, GLenum func),
+ (func))
+
+DEFUN_LOCAL_VOID (PixelZoom,
+ (void *rend, GLfloat xfactor, GLfloat yfactor),
+ (xfactor, yfactor))
+
+DEFUN_LOCAL_VOID (PixelTransferf,
+ (void *rend, GLenum pname, GLfloat param),
+ (pname, param))
+
+DEFUN_LOCAL_VOID (PixelTransferi,
+ (void *rend, GLenum pname, GLint param),
+ (pname, param))
+
+DEFUN_LOCAL_VOID (PixelStoref,
+ (void *rend, GLenum pname, GLfloat param),
+ (pname, param))
+
+DEFUN_LOCAL_VOID (PixelStorei,
+ (void *rend, GLenum pname, GLint param),
+ (pname, param))
+
+DEFUN_LOCAL_VOID (PixelMapfv,
+ (void *rend, GLenum map, GLint mapsize, const GLfloat * values),
+ (map, mapsize, values))
+
+DEFUN_LOCAL_VOID (PixelMapuiv,
+ (void *rend, GLenum map, GLint mapsize, const GLuint * values),
+ (map, mapsize, values))
+
+DEFUN_LOCAL_VOID (PixelMapusv,
+ (void *rend, GLenum map, GLint mapsize, const GLushort * values),
+ (map, mapsize, values))
+
+DEFUN_LOCAL_VOID (ReadBuffer,
+ (void *rend, GLenum mode),
+ (mode))
+
+DEFUN_LOCAL_VOID (CopyPixels,
+ (void *rend, GLint x, GLint y, GLsizei width, GLsizei height, GLenum type),
+ (x, y, width, height, type))
+
+DEFUN_LOCAL_VOID (ReadPixels,
+ (void *rend, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * pixels),
+ (x, y, width, height, format, type, pixels))
+
+DEFUN_LOCAL_VOID (DrawPixels,
+ (void *rend, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels),
+ (width, height, format, type, pixels))
+
+DEFUN_LOCAL_VOID (GetBooleanv,
+ (void *rend, GLenum pname, GLboolean * params),
+ (pname, params))
+
+DEFUN_LOCAL_VOID (GetClipPlane,
+ (void *rend, GLenum plane, GLdouble * equation),
+ (plane, equation))
+
+DEFUN_LOCAL_VOID (GetDoublev,
+ (void *rend, GLenum pname, GLdouble * params),
+ (pname, params))
+
+DEFUN_LOCAL (GLenum, GetError,
+ (void *rend),
+ ())
+
+DEFUN_LOCAL_VOID (GetFloatv,
+ (void *rend, GLenum pname, GLfloat * params),
+ (pname, params))
+
+DEFUN_LOCAL_VOID (GetIntegerv,
+ (void *rend, GLenum pname, GLint * params),
+ (pname, params))
+
+DEFUN_LOCAL_VOID (GetLightfv,
+ (void *rend, GLenum light, GLenum pname, GLfloat * params),
+ (light, pname, params))
+
+DEFUN_LOCAL_VOID (GetLightiv,
+ (void *rend, GLenum light, GLenum pname, GLint * params),
+ (light, pname, params))
+
+DEFUN_LOCAL_VOID (GetMapdv,
+ (void *rend, GLenum target, GLenum query, GLdouble * v),
+ (target, query, v))
+
+DEFUN_LOCAL_VOID (GetMapfv,
+ (void *rend, GLenum target, GLenum query, GLfloat * v),
+ (target, query, v))
+
+DEFUN_LOCAL_VOID (GetMapiv,
+ (void *rend, GLenum target, GLenum query, GLint * v),
+ (target, query, v))
+
+DEFUN_LOCAL_VOID (GetMaterialfv,
+ (void *rend, GLenum face, GLenum pname, GLfloat * params),
+ (face, pname, params))
+
+DEFUN_LOCAL_VOID (GetMaterialiv,
+ (void *rend, GLenum face, GLenum pname, GLint * params),
+ (face, pname, params))
+
+DEFUN_LOCAL_VOID (GetPixelMapfv,
+ (void *rend, GLenum map, GLfloat * values),
+ (map, values))
+
+DEFUN_LOCAL_VOID (GetPixelMapuiv,
+ (void *rend, GLenum map, GLuint * values),
+ (map, values))
+
+DEFUN_LOCAL_VOID (GetPixelMapusv,
+ (void *rend, GLenum map, GLushort * values),
+ (map, values))
+
+DEFUN_LOCAL_VOID (GetPolygonStipple,
+ (void *rend, GLubyte * mask),
+ (mask))
+
+DEFUN_LOCAL (const GLubyte *, GetString,
+ (void *rend, GLenum name),
+ (name))
+
+DEFUN_LOCAL_VOID (GetTexEnvfv,
+ (void *rend, GLenum target, GLenum pname, GLfloat * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (GetTexEnviv,
+ (void *rend, GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (GetTexGendv,
+ (void *rend, GLenum coord, GLenum pname, GLdouble * params),
+ (coord, pname, params))
+
+DEFUN_LOCAL_VOID (GetTexGenfv,
+ (void *rend, GLenum coord, GLenum pname, GLfloat * params),
+ (coord, pname, params))
+
+DEFUN_LOCAL_VOID (GetTexGeniv,
+ (void *rend, GLenum coord, GLenum pname, GLint * params),
+ (coord, pname, params))
+
+DEFUN_LOCAL_VOID (GetTexImage,
+ (void *rend, GLenum target, GLint level, GLenum format, GLenum type, GLvoid * pixels),
+ (target, level, format, type, pixels))
+
+DEFUN_LOCAL_VOID (GetTexParameterfv,
+ (void *rend, GLenum target, GLenum pname, GLfloat * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (GetTexParameteriv,
+ (void *rend, GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (GetTexLevelParameterfv,
+ (void *rend, GLenum target, GLint level, GLenum pname, GLfloat * params),
+ (target, level, pname, params))
+
+DEFUN_LOCAL_VOID (GetTexLevelParameteriv,
+ (void *rend, GLenum target, GLint level, GLenum pname, GLint * params),
+ (target, level, pname, params))
+
+DEFUN_LOCAL (GLboolean, IsEnabled,
+ (void *rend, GLenum cap),
+ (cap))
+
+DEFUN_LOCAL (GLboolean, IsList,
+ (void *rend, GLuint list),
+ (list))
+
+DEFUN_LOCAL_VOID (DepthRange,
+ (void *rend, GLclampd zNear, GLclampd zFar),
+ (zNear, zFar))
+
+DEFUN_LOCAL_VOID (Frustum,
+ (void *rend, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar),
+ (left, right, bottom, top, zNear, zFar))
+
+DEFUN_LOCAL_VOID (LoadIdentity,
+ (void *rend),
+ ())
+
+DEFUN_LOCAL_VOID (LoadMatrixf,
+ (void *rend, const GLfloat * m),
+ (m))
+
+DEFUN_LOCAL_VOID (LoadMatrixd,
+ (void *rend, const GLdouble * m),
+ (m))
+
+DEFUN_LOCAL_VOID (MatrixMode,
+ (void *rend, GLenum mode),
+ (mode))
+
+DEFUN_LOCAL_VOID (MultMatrixf,
+ (void *rend, const GLfloat * m),
+ (m))
+
+DEFUN_LOCAL_VOID (MultMatrixd,
+ (void *rend, const GLdouble * m),
+ (m))
+
+DEFUN_LOCAL_VOID (Ortho,
+ (void *rend, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar),
+ (left, right, bottom, top, zNear, zFar))
+
+DEFUN_LOCAL_VOID (PopMatrix,
+ (void *rend),
+ ())
+
+DEFUN_LOCAL_VOID (PushMatrix,
+ (void *rend),
+ ())
+
+DEFUN_LOCAL_VOID (Rotated,
+ (void *rend, GLdouble angle, GLdouble x, GLdouble y, GLdouble z),
+ (angle, x, y, z))
+
+DEFUN_LOCAL_VOID (Rotatef,
+ (void *rend, GLfloat angle, GLfloat x, GLfloat y, GLfloat z),
+ (angle, x, y, z))
+
+DEFUN_LOCAL_VOID (Scaled,
+ (void *rend, GLdouble x, GLdouble y, GLdouble z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (Scalef,
+ (void *rend, GLfloat x, GLfloat y, GLfloat z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (Translated,
+ (void *rend, GLdouble x, GLdouble y, GLdouble z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (Translatef,
+ (void *rend, GLfloat x, GLfloat y, GLfloat z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (Viewport,
+ (void *rend, GLint x, GLint y, GLsizei width, GLsizei height),
+ (x, y, width, height))
+
+DEFUN_LOCAL_VOID (ArrayElement,
+ (void *rend, GLint i),
+ (i))
+
+DEFUN_LOCAL_VOID (BindTexture,
+ (void *rend, GLenum target, GLenum texture),
+ (target, texture))
+
+DEFUN_LOCAL_VOID (ColorPointer,
+ (void *rend, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer),
+ (size, type, stride, pointer))
+
+DEFUN_LOCAL_VOID (DisableClientState,
+ (void *rend, GLenum array),
+ (array))
+
+DEFUN_LOCAL_VOID (DrawArrays,
+ (void *rend, GLenum mode, GLint first, GLsizei count),
+ (mode, first, count))
+
+DEFUN_LOCAL_VOID (DrawElements,
+ (void *rend, GLenum mode, GLsizei count, GLenum type, const GLvoid * indices),
+ (mode, count, type, indices))
+
+DEFUN_LOCAL_VOID (EdgeFlagPointer,
+ (void *rend, GLsizei stride, const GLvoid * pointer),
+ (stride, pointer))
+
+DEFUN_LOCAL_VOID (EnableClientState,
+ (void *rend, GLenum array),
+ (array))
+
+DEFUN_LOCAL_VOID (IndexPointer,
+ (void *rend, GLenum type, GLsizei stride, const GLvoid * pointer),
+ (type, stride, pointer))
+
+DEFUN_LOCAL_VOID (Indexub,
+ (void *rend, GLubyte c),
+ (c))
+
+DEFUN_LOCAL_VOID (Indexubv,
+ (void *rend, const GLubyte * c),
+ (c))
+
+DEFUN_LOCAL_VOID (InterleavedArrays,
+ (void *rend, GLenum format, GLsizei stride, const GLvoid * pointer),
+ (format, stride, pointer))
+
+DEFUN_LOCAL_VOID (NormalPointer,
+ (void *rend, GLenum type, GLsizei stride, const GLvoid * pointer),
+ (type, stride, pointer))
+
+DEFUN_LOCAL_VOID (PolygonOffset,
+ (void *rend, GLfloat factor, GLfloat units),
+ (factor, units))
+
+DEFUN_LOCAL_VOID (TexCoordPointer,
+ (void *rend, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer),
+ (size, type, stride, pointer))
+
+DEFUN_LOCAL_VOID (VertexPointer,
+ (void *rend, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer),
+ (size, type, stride, pointer))
+
+DEFUN_LOCAL (GLboolean, AreTexturesResident,
+ (void *rend, GLsizei n, const GLenum * textures, GLboolean * residences),
+ (n, textures, residences))
+
+DEFUN_LOCAL_VOID (CopyTexImage1D,
+ (void *rend, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border),
+ (target, level, internalformat, x, y, width, border))
+
+DEFUN_LOCAL_VOID (CopyTexImage2D,
+ (void *rend, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border),
+ (target, level, internalformat, x, y, width, height, border))
+
+DEFUN_LOCAL_VOID (CopyTexSubImage1D,
+ (void *rend, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width),
+ (target, level, xoffset, x, y, width))
+
+DEFUN_LOCAL_VOID (CopyTexSubImage2D,
+ (void *rend, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height),
+ (target, level, xoffset, yoffset, x, y, width, height))
+
+DEFUN_LOCAL_VOID (DeleteTextures,
+ (void *rend, GLsizei n, const GLenum * textures),
+ (n, textures))
+
+DEFUN_LOCAL_VOID (GenTextures,
+ (void *rend, GLsizei n, GLenum * textures),
+ (n, textures))
+
+DEFUN_LOCAL_VOID (GetPointerv,
+ (void *rend, GLenum pname, GLvoid * * params),
+ (pname, params))
+
+DEFUN_LOCAL (GLboolean, IsTexture,
+ (void *rend, GLenum texture),
+ (texture))
+
+DEFUN_LOCAL_VOID (PrioritizeTextures,
+ (void *rend, GLsizei n, const GLenum * textures, const GLclampf * priorities),
+ (n, textures, priorities))
+
+DEFUN_LOCAL_VOID (TexSubImage1D,
+ (void *rend, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid * pixels),
+ (target, level, xoffset, width, format, type, pixels))
+
+DEFUN_LOCAL_VOID (TexSubImage2D,
+ (void *rend, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels),
+ (target, level, xoffset, yoffset, width, height, format, type, pixels))
+
+DEFUN_LOCAL_VOID (PopClientAttrib,
+ (void *rend),
+ ())
+
+DEFUN_LOCAL_VOID (PushClientAttrib,
+ (void *rend, GLbitfield mask),
+ (mask))
+
+DEFUN_LOCAL_VOID (BlendColor,
+ (void *rend, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha),
+ (red, green, blue, alpha))
+
+DEFUN_LOCAL_VOID (BlendEquation,
+ (void *rend, GLenum mode),
+ (mode))
+
+DEFUN_LOCAL_VOID (DrawRangeElements,
+ (void *rend, GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices),
+ (mode, start, end, count, type, indices))
+
+DEFUN_LOCAL_VOID (ColorTable,
+ (void *rend, GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table),
+ (target, internalformat, width, format, type, table))
+
+DEFUN_LOCAL_VOID (ColorTableParameterfv,
+ (void *rend, GLenum target, GLenum pname, const GLfloat * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (ColorTableParameteriv,
+ (void *rend, GLenum target, GLenum pname, const GLint * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (CopyColorTable,
+ (void *rend, GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width),
+ (target, internalformat, x, y, width))
+
+DEFUN_LOCAL_VOID (GetColorTable,
+ (void *rend, GLenum target, GLenum format, GLenum type, GLvoid * table),
+ (target, format, type, table))
+
+DEFUN_LOCAL_VOID (GetColorTableParameterfv,
+ (void *rend, GLenum target, GLenum pname, GLfloat * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (GetColorTableParameteriv,
+ (void *rend, GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (ColorSubTable,
+ (void *rend, GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid * data),
+ (target, start, count, format, type, data))
+
+DEFUN_LOCAL_VOID (CopyColorSubTable,
+ (void *rend, GLenum target, GLsizei start, GLint x, GLint y, GLsizei width),
+ (target, start, x, y, width))
+
+DEFUN_LOCAL_VOID (ConvolutionFilter1D,
+ (void *rend, GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * image),
+ (target, internalformat, width, format, type, image))
+
+DEFUN_LOCAL_VOID (ConvolutionFilter2D,
+ (void *rend, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * image),
+ (target, internalformat, width, height, format, type, image))
+
+DEFUN_LOCAL_VOID (ConvolutionParameterf,
+ (void *rend, GLenum target, GLenum pname, GLfloat params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (ConvolutionParameterfv,
+ (void *rend, GLenum target, GLenum pname, const GLfloat * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (ConvolutionParameteri,
+ (void *rend, GLenum target, GLenum pname, GLint params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (ConvolutionParameteriv,
+ (void *rend, GLenum target, GLenum pname, const GLint * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (CopyConvolutionFilter1D,
+ (void *rend, GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width),
+ (target, internalformat, x, y, width))
+
+DEFUN_LOCAL_VOID (CopyConvolutionFilter2D,
+ (void *rend, GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height),
+ (target, internalformat, x, y, width, height))
+
+DEFUN_LOCAL_VOID (GetConvolutionFilter,
+ (void *rend, GLenum target, GLenum format, GLenum type, GLvoid * image),
+ (target, format, type, image))
+
+DEFUN_LOCAL_VOID (GetConvolutionParameterfv,
+ (void *rend, GLenum target, GLenum pname, GLfloat * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (GetConvolutionParameteriv,
+ (void *rend, GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (GetSeparableFilter,
+ (void *rend, GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span),
+ (target, format, type, row, column, span))
+
+DEFUN_LOCAL_VOID (SeparableFilter2D,
+ (void *rend, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * row, const GLvoid * column),
+ (target, internalformat, width, height, format, type, row, column))
+
+DEFUN_LOCAL_VOID (GetHistogram,
+ (void *rend, GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values),
+ (target, reset, format, type, values))
+
+DEFUN_LOCAL_VOID (GetHistogramParameterfv,
+ (void *rend, GLenum target, GLenum pname, GLfloat * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (GetHistogramParameteriv,
+ (void *rend, GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (GetMinmax,
+ (void *rend, GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values),
+ (target, reset, format, type, values))
+
+DEFUN_LOCAL_VOID (GetMinmaxParameterfv,
+ (void *rend, GLenum target, GLenum pname, GLfloat * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (GetMinmaxParameteriv,
+ (void *rend, GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (Histogram,
+ (void *rend, GLenum target, GLsizei width, GLenum internalformat, GLboolean sink),
+ (target, width, internalformat, sink))
+
+DEFUN_LOCAL_VOID (Minmax,
+ (void *rend, GLenum target, GLenum internalformat, GLboolean sink),
+ (target, internalformat, sink))
+
+DEFUN_LOCAL_VOID (ResetHistogram,
+ (void *rend, GLenum target),
+ (target))
+
+DEFUN_LOCAL_VOID (ResetMinmax,
+ (void *rend, GLenum target),
+ (target))
+
+DEFUN_LOCAL_VOID (TexImage3D,
+ (void *rend, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels),
+ (target, level, internalformat, width, height, depth, border, format, type, pixels))
+
+DEFUN_LOCAL_VOID (TexSubImage3D,
+ (void *rend, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels),
+ (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels))
+
+DEFUN_LOCAL_VOID (CopyTexSubImage3D,
+ (void *rend, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height),
+ (target, level, xoffset, yoffset, zoffset, x, y, width, height))
+
+DEFUN_LOCAL_VOID (ActiveTextureARB,
+ (void *rend, GLenum texture),
+ (texture))
+
+DEFUN_LOCAL_VOID (ClientActiveTextureARB,
+ (void *rend, GLenum texture),
+ (texture))
+
+DEFUN_LOCAL_VOID (MultiTexCoord1dARB,
+ (void *rend, GLenum target, GLdouble s),
+ (target, s))
+
+DEFUN_LOCAL_VOID (MultiTexCoord1dvARB,
+ (void *rend, GLenum target, const GLdouble * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord1fARB,
+ (void *rend, GLenum target, GLfloat s),
+ (target, s))
+
+DEFUN_LOCAL_VOID (MultiTexCoord1fvARB,
+ (void *rend, GLenum target, const GLfloat * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord1iARB,
+ (void *rend, GLenum target, GLint s),
+ (target, s))
+
+DEFUN_LOCAL_VOID (MultiTexCoord1ivARB,
+ (void *rend, GLenum target, const GLint * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord1sARB,
+ (void *rend, GLenum target, GLshort s),
+ (target, s))
+
+DEFUN_LOCAL_VOID (MultiTexCoord1svARB,
+ (void *rend, GLenum target, const GLshort * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord2dARB,
+ (void *rend, GLenum target, GLdouble s, GLdouble t),
+ (target, s, t))
+
+DEFUN_LOCAL_VOID (MultiTexCoord2dvARB,
+ (void *rend, GLenum target, const GLdouble * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord2fARB,
+ (void *rend, GLenum target, GLfloat s, GLfloat t),
+ (target, s, t))
+
+DEFUN_LOCAL_VOID (MultiTexCoord2fvARB,
+ (void *rend, GLenum target, const GLfloat * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord2iARB,
+ (void *rend, GLenum target, GLint s, GLint t),
+ (target, s, t))
+
+DEFUN_LOCAL_VOID (MultiTexCoord2ivARB,
+ (void *rend, GLenum target, const GLint * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord2sARB,
+ (void *rend, GLenum target, GLshort s, GLshort t),
+ (target, s, t))
+
+DEFUN_LOCAL_VOID (MultiTexCoord2svARB,
+ (void *rend, GLenum target, const GLshort * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord3dARB,
+ (void *rend, GLenum target, GLdouble s, GLdouble t, GLdouble r),
+ (target, s, t, r))
+
+DEFUN_LOCAL_VOID (MultiTexCoord3dvARB,
+ (void *rend, GLenum target, const GLdouble * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord3fARB,
+ (void *rend, GLenum target, GLfloat s, GLfloat t, GLfloat r),
+ (target, s, t, r))
+
+DEFUN_LOCAL_VOID (MultiTexCoord3fvARB,
+ (void *rend, GLenum target, const GLfloat * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord3iARB,
+ (void *rend, GLenum target, GLint s, GLint t, GLint r),
+ (target, s, t, r))
+
+DEFUN_LOCAL_VOID (MultiTexCoord3ivARB,
+ (void *rend, GLenum target, const GLint * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord3sARB,
+ (void *rend, GLenum target, GLshort s, GLshort t, GLshort r),
+ (target, s, t, r))
+
+DEFUN_LOCAL_VOID (MultiTexCoord3svARB,
+ (void *rend, GLenum target, const GLshort * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord4dARB,
+ (void *rend, GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q),
+ (target, s, t, r, q))
+
+DEFUN_LOCAL_VOID (MultiTexCoord4dvARB,
+ (void *rend, GLenum target, const GLdouble * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord4fARB,
+ (void *rend, GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q),
+ (target, s, t, r, q))
+
+DEFUN_LOCAL_VOID (MultiTexCoord4fvARB,
+ (void *rend, GLenum target, const GLfloat * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord4iARB,
+ (void *rend, GLenum target, GLint s, GLint t, GLint r, GLint q),
+ (target, s, t, r, q))
+
+DEFUN_LOCAL_VOID (MultiTexCoord4ivARB,
+ (void *rend, GLenum target, const GLint * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (MultiTexCoord4sARB,
+ (void *rend, GLenum target, GLshort s, GLshort t, GLshort r, GLshort q),
+ (target, s, t, r, q))
+
+DEFUN_LOCAL_VOID (MultiTexCoord4svARB,
+ (void *rend, GLenum target, const GLshort * v),
+ (target, v))
+
+DEFUN_LOCAL_VOID (LoadTransposeMatrixfARB,
+ (void *rend, const GLfloat * m),
+ (m))
+
+DEFUN_LOCAL_VOID (LoadTransposeMatrixdARB,
+ (void *rend, const GLdouble * m),
+ (m))
+
+DEFUN_LOCAL_VOID (MultTransposeMatrixfARB,
+ (void *rend, const GLfloat * m),
+ (m))
+
+DEFUN_LOCAL_VOID (MultTransposeMatrixdARB,
+ (void *rend, const GLdouble * m),
+ (m))
+
+DEFUN_LOCAL_VOID (SampleCoverageARB,
+ (void *rend, GLclampf value, GLboolean invert),
+ (value, invert))
+
+DEFUN_EXTERN_VOID (__unused413,
+ (),
+ ())
+
+DEFUN_ALIAS_VOID (PolygonOffsetEXT, PolygonOffset,
+ (GLfloat factor, GLfloat bias),
+ (factor, bias))
+
+DEFUN_EXTERN_VOID (GetTexFilterFuncSGIS,
+ (GLenum target, GLenum filter, GLfloat * weights),
+ (target, filter, weights))
+
+DEFUN_EXTERN_VOID (TexFilterFuncSGIS,
+ (GLenum target, GLenum filter, GLsizei n, const GLfloat * weights),
+ (target, filter, n, weights))
+
+DEFUN_ALIAS_VOID (GetHistogramEXT, GetHistogram,
+ (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values),
+ (target, reset, format, type, values))
+
+DEFUN_ALIAS_VOID (GetHistogramParameterfvEXT, GetHistogramParameterfv,
+ (GLenum target, GLenum pname, GLfloat * params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (GetHistogramParameterivEXT, GetHistogramParameteriv,
+ (GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (GetMinmaxEXT, GetMinmax,
+ (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values),
+ (target, reset, format, type, values))
+
+DEFUN_ALIAS_VOID (GetMinmaxParameterfvEXT, GetMinmaxParameterfv,
+ (GLenum target, GLenum pname, GLfloat * params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (GetMinmaxParameterivEXT, GetMinmaxParameteriv,
+ (GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (GetConvolutionFilterEXT, GetConvolutionFilter,
+ (GLenum target, GLenum format, GLenum type, GLvoid * image),
+ (target, format, type, image))
+
+DEFUN_ALIAS_VOID (GetConvolutionParameterfvEXT, GetConvolutionParameterfv,
+ (GLenum target, GLenum pname, GLfloat * params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (GetConvolutionParameterivEXT, GetConvolutionParameteriv,
+ (GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (GetSeparableFilterEXT, GetSeparableFilter,
+ (GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span),
+ (target, format, type, row, column, span))
+
+DEFUN_ALIAS_VOID (GetColorTableSGI, GetColorTable,
+ (GLenum target, GLenum format, GLenum type, GLvoid * table),
+ (target, format, type, table))
+
+DEFUN_ALIAS_VOID (GetColorTableParameterfvSGI, GetColorTableParameterfv,
+ (GLenum target, GLenum pname, GLfloat * params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (GetColorTableParameterivSGI, GetColorTableParameteriv,
+ (GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_EXTERN_VOID (PixelTexGenSGIX,
+ (GLenum mode),
+ (mode))
+
+DEFUN_EXTERN_VOID (PixelTexGenParameteriSGIS,
+ (GLenum pname, GLint param),
+ (pname, param))
+
+DEFUN_EXTERN_VOID (PixelTexGenParameterivSGIS,
+ (GLenum pname, const GLint * params),
+ (pname, params))
+
+DEFUN_EXTERN_VOID (PixelTexGenParameterfSGIS,
+ (GLenum pname, GLfloat param),
+ (pname, param))
+
+DEFUN_EXTERN_VOID (PixelTexGenParameterfvSGIS,
+ (GLenum pname, const GLfloat * params),
+ (pname, params))
+
+DEFUN_EXTERN_VOID (GetPixelTexGenParameterivSGIS,
+ (GLenum pname, GLint * params),
+ (pname, params))
+
+DEFUN_EXTERN_VOID (GetPixelTexGenParameterfvSGIS,
+ (GLenum pname, GLfloat * params),
+ (pname, params))
+
+DEFUN_EXTERN_VOID (TexImage4DSGIS,
+ (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid * pixels),
+ (target, level, internalformat, width, height, depth, size4d, border, format, type, pixels))
+
+DEFUN_EXTERN_VOID (TexSubImage4DSGIS,
+ (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid * pixels),
+ (target, level, xoffset, yoffset, zoffset, woffset, width, height, depth, size4d, format, type, pixels))
+
+DEFUN_ALIAS (GLboolean, AreTexturesResidentEXT, AreTexturesResident,
+ (GLsizei n, const GLenum * textures, GLboolean * residences),
+ (n, textures, residences))
+
+DEFUN_ALIAS_VOID (GenTexturesEXT, GenTextures,
+ (GLsizei n, GLenum * textures),
+ (n, textures))
+
+DEFUN_EXTERN (GLboolean, IsTextureEXT,
+ (GLenum texture),
+ (texture))
+
+DEFUN_EXTERN_VOID (DetailTexFuncSGIS,
+ (GLenum target, GLsizei n, const GLfloat * points),
+ (target, n, points))
+
+DEFUN_EXTERN_VOID (GetDetailTexFuncSGIS,
+ (GLenum target, GLfloat * points),
+ (target, points))
+
+DEFUN_EXTERN_VOID (SharpenTexFuncSGIS,
+ (GLenum target, GLsizei n, const GLfloat * points),
+ (target, n, points))
+
+DEFUN_EXTERN_VOID (GetSharpenTexFuncSGIS,
+ (GLenum target, GLfloat * points),
+ (target, points))
+
+DEFUN_EXTERN_VOID (SampleMaskSGIS,
+ (GLclampf value, GLboolean invert),
+ (value, invert))
+
+DEFUN_EXTERN_VOID (SamplePatternSGIS,
+ (GLenum pattern),
+ (pattern))
+
+DEFUN_EXTERN_VOID (ColorPointerEXT,
+ (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer),
+ (size, type, stride, count, pointer))
+
+DEFUN_EXTERN_VOID (EdgeFlagPointerEXT,
+ (GLsizei stride, GLsizei count, const GLboolean * pointer),
+ (stride, count, pointer))
+
+DEFUN_EXTERN_VOID (IndexPointerEXT,
+ (GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer),
+ (type, stride, count, pointer))
+
+DEFUN_EXTERN_VOID (NormalPointerEXT,
+ (GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer),
+ (type, stride, count, pointer))
+
+DEFUN_EXTERN_VOID (TexCoordPointerEXT,
+ (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer),
+ (size, type, stride, count, pointer))
+
+DEFUN_EXTERN_VOID (VertexPointerEXT,
+ (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer),
+ (size, type, stride, count, pointer))
+
+DEFUN_EXTERN_VOID (SpriteParameterfSGIX,
+ (GLenum pname, GLfloat param),
+ (pname, param))
+
+DEFUN_EXTERN_VOID (SpriteParameterfvSGIX,
+ (GLenum pname, const GLfloat * params),
+ (pname, params))
+
+DEFUN_EXTERN_VOID (SpriteParameteriSGIX,
+ (GLenum pname, GLint param),
+ (pname, param))
+
+DEFUN_EXTERN_VOID (SpriteParameterivSGIX,
+ (GLenum pname, const GLint * params),
+ (pname, params))
+
+DEFUN_LOCAL_VOID (PointParameterfEXT,
+ (void *rend, GLenum pname, GLfloat param),
+ (pname, param))
+
+DEFUN_ALIAS_VOID (PointParameterfEXT, PointParameterf,
+ (GLenum pname, GLfloat param),
+ (pname, param))
+
+DEFUN_LOCAL_VOID (PointParameterfvEXT,
+ (void *rend, GLenum pname, const GLfloat * params),
+ (pname, params))
+
+DEFUN_ALIAS_VOID (PointParameterfvEXT, PointParameterfv,
+ (GLenum pname, const GLfloat * params),
+ (pname, params))
+
+DEFUN_EXTERN (GLint, GetInstrumentsSGIX,
+ (),
+ ())
+
+DEFUN_EXTERN_VOID (InstrumentsBufferSGIX,
+ (GLsizei size, GLint * buffer),
+ (size, buffer))
+
+DEFUN_EXTERN (GLint, PollInstrumentsSGIX,
+ (GLint * marker_p),
+ (marker_p))
+
+DEFUN_EXTERN_VOID (ReadInstrumentsSGIX,
+ (GLint marker),
+ (marker))
+
+DEFUN_EXTERN_VOID (StartInstrumentsSGIX,
+ (),
+ ())
+
+DEFUN_EXTERN_VOID (StopInstrumentsSGIX,
+ (GLint marker),
+ (marker))
+
+DEFUN_EXTERN_VOID (FrameZoomSGIX,
+ (GLint factor),
+ (factor))
+
+DEFUN_EXTERN_VOID (TagSampleBufferSGIX,
+ (),
+ ())
+
+DEFUN_EXTERN_VOID (ReferencePlaneSGIX,
+ (const GLdouble * equation),
+ (equation))
+
+DEFUN_EXTERN_VOID (FlushRasterSGIX,
+ (),
+ ())
+
+DEFUN_EXTERN_VOID (GetListParameterfvSGIX,
+ (GLuint list, GLenum pname, GLfloat * params),
+ (list, pname, params))
+
+DEFUN_EXTERN_VOID (GetListParameterivSGIX,
+ (GLuint list, GLenum pname, GLint * params),
+ (list, pname, params))
+
+DEFUN_EXTERN_VOID (ListParameterfSGIX,
+ (GLuint list, GLenum pname, GLfloat param),
+ (list, pname, param))
+
+DEFUN_EXTERN_VOID (ListParameterfvSGIX,
+ (GLuint list, GLenum pname, const GLfloat * params),
+ (list, pname, params))
+
+DEFUN_EXTERN_VOID (ListParameteriSGIX,
+ (GLuint list, GLenum pname, GLint param),
+ (list, pname, param))
+
+DEFUN_EXTERN_VOID (ListParameterivSGIX,
+ (GLuint list, GLenum pname, const GLint * params),
+ (list, pname, params))
+
+DEFUN_EXTERN_VOID (FragmentColorMaterialSGIX,
+ (GLenum face, GLenum mode),
+ (face, mode))
+
+DEFUN_EXTERN_VOID (FragmentLightfSGIX,
+ (GLenum light, GLenum pname, GLfloat param),
+ (light, pname, param))
+
+DEFUN_EXTERN_VOID (FragmentLightfvSGIX,
+ (GLenum light, GLenum pname, const GLfloat * params),
+ (light, pname, params))
+
+DEFUN_EXTERN_VOID (FragmentLightiSGIX,
+ (GLenum light, GLenum pname, GLint param),
+ (light, pname, param))
+
+DEFUN_EXTERN_VOID (FragmentLightivSGIX,
+ (GLenum light, GLenum pname, const GLint * params),
+ (light, pname, params))
+
+DEFUN_EXTERN_VOID (FragmentLightModelfSGIX,
+ (GLenum pname, GLfloat param),
+ (pname, param))
+
+DEFUN_EXTERN_VOID (FragmentLightModelfvSGIX,
+ (GLenum pname, const GLfloat * params),
+ (pname, params))
+
+DEFUN_EXTERN_VOID (FragmentLightModeliSGIX,
+ (GLenum pname, GLint param),
+ (pname, param))
+
+DEFUN_EXTERN_VOID (FragmentLightModelivSGIX,
+ (GLenum pname, const GLint * params),
+ (pname, params))
+
+DEFUN_EXTERN_VOID (FragmentMaterialfSGIX,
+ (GLenum face, GLenum pname, GLfloat param),
+ (face, pname, param))
+
+DEFUN_EXTERN_VOID (FragmentMaterialfvSGIX,
+ (GLenum face, GLenum pname, const GLfloat * params),
+ (face, pname, params))
+
+DEFUN_EXTERN_VOID (FragmentMaterialiSGIX,
+ (GLenum face, GLenum pname, GLint param),
+ (face, pname, param))
+
+DEFUN_EXTERN_VOID (FragmentMaterialivSGIX,
+ (GLenum face, GLenum pname, const GLint * params),
+ (face, pname, params))
+
+DEFUN_EXTERN_VOID (GetFragmentLightfvSGIX,
+ (GLenum light, GLenum pname, GLfloat * params),
+ (light, pname, params))
+
+DEFUN_EXTERN_VOID (GetFragmentLightivSGIX,
+ (GLenum light, GLenum pname, GLint * params),
+ (light, pname, params))
+
+DEFUN_EXTERN_VOID (GetFragmentMaterialfvSGIX,
+ (GLenum face, GLenum pname, GLfloat * params),
+ (face, pname, params))
+
+DEFUN_EXTERN_VOID (GetFragmentMaterialivSGIX,
+ (GLenum face, GLenum pname, GLint * params),
+ (face, pname, params))
+
+DEFUN_EXTERN_VOID (LightEnviSGIX,
+ (GLenum pname, GLint param),
+ (pname, param))
+
+DEFUN_EXTERN_VOID (VertexWeightfEXT,
+ (GLfloat weight),
+ (weight))
+
+DEFUN_EXTERN_VOID (VertexWeightfvEXT,
+ (const GLfloat * weight),
+ (weight))
+
+DEFUN_EXTERN_VOID (VertexWeightPointerEXT,
+ (GLsizei size, GLenum type, GLsizei stride, const GLvoid * pointer),
+ (size, type, stride, pointer))
+
+DEFUN_EXTERN_VOID (FlushVertexArrayRangeNV,
+ (),
+ ())
+
+DEFUN_LOCAL_VOID (VertexArrayRangeNV,
+ (void *rend, GLsizei length, const GLvoid * pointer),
+ (length, pointer))
+
+DEFUN_ALIAS_VOID (VertexArrayRangeNV, VertexArrayRangeAPPLE,
+ (GLsizei length, const GLvoid * pointer),
+ (length, pointer))
+
+DEFUN_LOCAL_VOID (CombinerParameterfvNV,
+ (void *rend, GLenum pname, const GLfloat * params),
+ (pname, params))
+
+DEFUN_LOCAL_VOID (CombinerParameterfNV,
+ (void *rend, GLenum pname, GLfloat param),
+ (pname, param))
+
+DEFUN_LOCAL_VOID (CombinerParameterivNV,
+ (void *rend, GLenum pname, const GLint * params),
+ (pname, params))
+
+DEFUN_LOCAL_VOID (CombinerParameteriNV,
+ (void *rend, GLenum pname, GLint param),
+ (pname, param))
+
+DEFUN_LOCAL_VOID (CombinerInputNV,
+ (void *rend, GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage),
+ (stage, portion, variable, input, mapping, componentUsage))
+
+DEFUN_LOCAL_VOID (CombinerOutputNV,
+ (void *rend, GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum),
+ (stage, portion, abOutput, cdOutput, sumOutput, scale, bias, abDotProduct, cdDotProduct, muxSum))
+
+DEFUN_LOCAL_VOID (FinalCombinerInputNV,
+ (void *rend, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage),
+ (variable, input, mapping, componentUsage))
+
+DEFUN_LOCAL_VOID (GetCombinerInputParameterfvNV,
+ (void *rend, GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat * params),
+ (stage, portion, variable, pname, params))
+
+DEFUN_LOCAL_VOID (GetCombinerInputParameterivNV,
+ (void *rend, GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint * params),
+ (stage, portion, variable, pname, params))
+
+DEFUN_LOCAL_VOID (GetCombinerOutputParameterfvNV,
+ (void *rend, GLenum stage, GLenum portion, GLenum pname, GLfloat * params),
+ (stage, portion, pname, params))
+
+DEFUN_LOCAL_VOID (GetCombinerOutputParameterivNV,
+ (void *rend, GLenum stage, GLenum portion, GLenum pname, GLint * params),
+ (stage, portion, pname, params))
+
+DEFUN_LOCAL_VOID (GetFinalCombinerInputParameterfvNV,
+ (void *rend, GLenum variable, GLenum pname, GLfloat * params),
+ (variable, pname, params))
+
+DEFUN_LOCAL_VOID (GetFinalCombinerInputParameterivNV,
+ (void *rend, GLenum variable, GLenum pname, GLint * params),
+ (variable, pname, params))
+
+DEFUN_EXTERN_VOID (ResizeBuffersMESA,
+ (),
+ ())
+
+DEFUN_LOCAL_VOID (WindowPos2dMESA,
+ (void *rend, GLdouble x, GLdouble y),
+ (x, y))
+
+DEFUN_ALIAS_VOID (WindowPos2dMESA, WindowPos2d,
+ (GLdouble x, GLdouble y),
+ (x, y))
+
+DEFUN_LOCAL_VOID (WindowPos2dvMESA,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_ALIAS_VOID (WindowPos2dvMESA, WindowPos2dv,
+ (const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (WindowPos2fMESA,
+ (void *rend, GLfloat x, GLfloat y),
+ (x, y))
+
+DEFUN_ALIAS_VOID (WindowPos2fMESA, WindowPos2f,
+ (GLfloat x, GLfloat y),
+ (x, y))
+
+DEFUN_LOCAL_VOID (WindowPos2fvMESA,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_ALIAS_VOID (WindowPos2fvMESA, WindowPos2fv,
+ (const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (WindowPos2iMESA,
+ (void *rend, GLint x, GLint y),
+ (x, y))
+
+DEFUN_ALIAS_VOID (WindowPos2iMESA, WindowPos2i,
+ (GLint x, GLint y),
+ (x, y))
+
+DEFUN_LOCAL_VOID (WindowPos2ivMESA,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_ALIAS_VOID (WindowPos2ivMESA, WindowPos2iv,
+ (const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (WindowPos2sMESA,
+ (void *rend, GLshort x, GLshort y),
+ (x, y))
+
+DEFUN_ALIAS_VOID (WindowPos2sMESA, WindowPos2s,
+ (GLshort x, GLshort y),
+ (x, y))
+
+DEFUN_LOCAL_VOID (WindowPos2svMESA,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_ALIAS_VOID (WindowPos2svMESA, WindowPos2sv,
+ (const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (WindowPos3dMESA,
+ (void *rend, GLdouble x, GLdouble y, GLdouble z),
+ (x, y, z))
+
+DEFUN_ALIAS_VOID (WindowPos3dMESA, WindowPos3d,
+ (GLdouble x, GLdouble y, GLdouble z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (WindowPos3dvMESA,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_ALIAS_VOID (WindowPos3dvMESA, WindowPos3dv,
+ (const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (WindowPos3fMESA,
+ (void *rend, GLfloat x, GLfloat y, GLfloat z),
+ (x, y, z))
+
+DEFUN_ALIAS_VOID (WindowPos3fMESA, WindowPos3f,
+ (GLfloat x, GLfloat y, GLfloat z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (WindowPos3fvMESA,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_ALIAS_VOID (WindowPos3fvMESA, WindowPos3fv,
+ (const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (WindowPos3iMESA,
+ (void *rend, GLint x, GLint y, GLint z),
+ (x, y, z))
+
+DEFUN_ALIAS_VOID (WindowPos3iMESA, WindowPos3i,
+ (GLint x, GLint y, GLint z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (WindowPos3ivMESA,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_ALIAS_VOID (WindowPos3ivMESA, WindowPos3iv,
+ (const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (WindowPos3sMESA,
+ (void *rend, GLshort x, GLshort y, GLshort z),
+ (x, y, z))
+
+DEFUN_ALIAS_VOID (WindowPos3sMESA, WindowPos3s,
+ (GLshort x, GLshort y, GLshort z),
+ (x, y, z))
+
+DEFUN_LOCAL_VOID (WindowPos3svMESA,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_ALIAS_VOID (WindowPos3svMESA, WindowPos3sv,
+ (const GLshort * v),
+ (v))
+
+DEFUN_EXTERN_VOID (WindowPos4dMESA,
+ (GLdouble x, GLdouble y, GLdouble z, GLdouble w),
+ (x, y, z, w))
+
+DEFUN_EXTERN_VOID (WindowPos4dvMESA,
+ (const GLdouble * v),
+ (v))
+
+DEFUN_EXTERN_VOID (WindowPos4fMESA,
+ (GLfloat x, GLfloat y, GLfloat z, GLfloat w),
+ (x, y, z, w))
+
+DEFUN_EXTERN_VOID (WindowPos4fvMESA,
+ (const GLfloat * v),
+ (v))
+
+DEFUN_EXTERN_VOID (WindowPos4iMESA,
+ (GLint x, GLint y, GLint z, GLint w),
+ (x, y, z, w))
+
+DEFUN_EXTERN_VOID (WindowPos4ivMESA,
+ (const GLint * v),
+ (v))
+
+DEFUN_EXTERN_VOID (WindowPos4sMESA,
+ (GLshort x, GLshort y, GLshort z, GLshort w),
+ (x, y, z, w))
+
+DEFUN_EXTERN_VOID (WindowPos4svMESA,
+ (const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (BlendFuncSeparateEXT,
+ (void *rend, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha),
+ (sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha))
+
+DEFUN_EXTERN_VOID (IndexMaterialEXT,
+ (GLenum face, GLenum mode),
+ (face, mode))
+
+DEFUN_EXTERN_VOID (IndexFuncEXT,
+ (GLenum func, GLclampf ref),
+ (func, ref))
+
+DEFUN_LOCAL_VOID (LockArraysEXT,
+ (void *rend, GLint first, GLsizei count),
+ (first, count))
+
+DEFUN_LOCAL_VOID (UnlockArraysEXT,
+ (void *rend),
+ ())
+
+DEFUN_EXTERN_VOID (CullParameterdvEXT,
+ (GLenum pname, GLdouble * params),
+ (pname, params))
+
+DEFUN_EXTERN_VOID (CullParameterfvEXT,
+ (GLenum pname, GLfloat * params),
+ (pname, params))
+
+DEFUN_EXTERN_VOID (HintPGI,
+ (GLenum target, GLint mode),
+ (target, mode))
+
+DEFUN_LOCAL_VOID (FogCoordfEXT,
+ (void *rend, GLfloat coord),
+ (coord))
+
+DEFUN_LOCAL_VOID (FogCoordfvEXT,
+ (void *rend, const GLfloat * coord),
+ (coord))
+
+DEFUN_LOCAL_VOID (FogCoorddEXT,
+ (void *rend, GLdouble coord),
+ (coord))
+
+DEFUN_LOCAL_VOID (FogCoorddvEXT,
+ (void *rend, const GLdouble * coord),
+ (coord))
+
+DEFUN_LOCAL_VOID (FogCoordPointerEXT,
+ (void *rend, GLenum type, GLsizei stride, const GLvoid * pointer),
+ (type, stride, pointer))
+
+DEFUN_EXTERN_VOID (TbufferMask3DFX,
+ (GLuint mask),
+ (mask))
+
+DEFUN_LOCAL_VOID (CompressedTexImage3DARB,
+ (void *rend, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid * data),
+ (target, level, internalformat, width, height, depth, border, imageSize, data))
+
+DEFUN_LOCAL_VOID (CompressedTexImage2DARB,
+ (void *rend, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data),
+ (target, level, internalformat, width, height, border, imageSize, data))
+
+DEFUN_LOCAL_VOID (CompressedTexImage1DARB,
+ (void *rend, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid * data),
+ (target, level, internalformat, width, border, imageSize, data))
+
+DEFUN_LOCAL_VOID (CompressedTexSubImage3DARB,
+ (void *rend, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid * data),
+ (target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data))
+
+DEFUN_LOCAL_VOID (CompressedTexSubImage2DARB,
+ (void *rend, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid * data),
+ (target, level, xoffset, yoffset, width, height, format, imageSize, data))
+
+DEFUN_LOCAL_VOID (CompressedTexSubImage1DARB,
+ (void *rend, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid * data),
+ (target, level, xoffset, width, format, imageSize, data))
+
+DEFUN_LOCAL_VOID (GetCompressedTexImageARB,
+ (void *rend, GLenum target, GLint level, void * img),
+ (target, level, img))
+
+DEFUN_LOCAL_VOID (SecondaryColor3bEXT,
+ (void *rend, GLbyte red, GLbyte green, GLbyte blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (SecondaryColor3bvEXT,
+ (void *rend, const GLbyte * v),
+ (v))
+
+DEFUN_LOCAL_VOID (SecondaryColor3dEXT,
+ (void *rend, GLdouble red, GLdouble green, GLdouble blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (SecondaryColor3dvEXT,
+ (void *rend, const GLdouble * v),
+ (v))
+
+DEFUN_LOCAL_VOID (SecondaryColor3fEXT,
+ (void *rend, GLfloat red, GLfloat green, GLfloat blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (SecondaryColor3fvEXT,
+ (void *rend, const GLfloat * v),
+ (v))
+
+DEFUN_LOCAL_VOID (SecondaryColor3iEXT,
+ (void *rend, GLint red, GLint green, GLint blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (SecondaryColor3ivEXT,
+ (void *rend, const GLint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (SecondaryColor3sEXT,
+ (void *rend, GLshort red, GLshort green, GLshort blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (SecondaryColor3svEXT,
+ (void *rend, const GLshort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (SecondaryColor3ubEXT,
+ (void *rend, GLubyte red, GLubyte green, GLubyte blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (SecondaryColor3ubvEXT,
+ (void *rend, const GLubyte * v),
+ (v))
+
+DEFUN_LOCAL_VOID (SecondaryColor3uiEXT,
+ (void *rend, GLuint red, GLuint green, GLuint blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (SecondaryColor3uivEXT,
+ (void *rend, const GLuint * v),
+ (v))
+
+DEFUN_LOCAL_VOID (SecondaryColor3usEXT,
+ (void *rend, GLushort red, GLushort green, GLushort blue),
+ (red, green, blue))
+
+DEFUN_LOCAL_VOID (SecondaryColor3usvEXT,
+ (void *rend, const GLushort * v),
+ (v))
+
+DEFUN_LOCAL_VOID (SecondaryColorPointerEXT,
+ (void *rend, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer),
+ (size, type, stride, pointer))
+
+DEFUN_EXTERN (GLboolean, AreProgramsResidentNV,
+ (GLsizei n, const GLuint * ids, GLboolean * residences),
+ (n, ids, residences))
+
+DEFUN_LOCAL_VOID (BindProgramNV,
+ (void *rend, GLenum target, GLuint id),
+ (target, id))
+
+DEFUN_ALIAS_VOID (BindProgramNV, BindProgramARB,
+ (GLenum target, GLuint id),
+ (target, id))
+
+DEFUN_LOCAL_VOID (DeleteProgramsNV,
+ (void *rend, GLsizei n, const GLuint * ids),
+ (n, ids))
+
+DEFUN_ALIAS_VOID (DeleteProgramsNV, DeleteProgramsARB,
+ (GLsizei n, const GLuint * ids),
+ (n, ids))
+
+DEFUN_EXTERN_VOID (ExecuteProgramNV,
+ (GLenum target, GLuint id, const GLfloat * params),
+ (target, id, params))
+
+DEFUN_LOCAL_VOID (GenProgramsNV,
+ (void *rend, GLsizei n, GLuint * ids),
+ (n, ids))
+
+DEFUN_ALIAS_VOID (GenProgramsNV, GenProgramsARB,
+ (GLsizei n, GLuint * ids),
+ (n, ids))
+
+DEFUN_EXTERN_VOID (GetProgramParameterdvNV,
+ (GLenum target, GLuint index, GLenum pname, GLdouble * params),
+ (target, index, pname, params))
+
+DEFUN_EXTERN_VOID (GetProgramParameterfvNV,
+ (GLenum target, GLuint index, GLenum pname, GLfloat * params),
+ (target, index, pname, params))
+
+DEFUN_EXTERN_VOID (GetProgramivNV,
+ (GLuint id, GLenum pname, GLint * params),
+ (id, pname, params))
+
+DEFUN_EXTERN_VOID (GetProgramStringNV,
+ (GLuint id, GLenum pname, GLubyte * program),
+ (id, pname, program))
+
+DEFUN_EXTERN_VOID (GetTrackMatrixivNV,
+ (GLenum target, GLuint address, GLenum pname, GLint * params),
+ (target, address, pname, params))
+
+DEFUN_LOCAL_VOID (GetVertexAttribdvNV,
+ (void *rend, GLuint index, GLenum pname, GLdouble * params),
+ (index, pname, params))
+
+DEFUN_ALIAS_VOID (GetVertexAttribdvNV, GetVertexAttribdvARB,
+ (GLuint index, GLenum pname, GLdouble * params),
+ (index, pname, params))
+
+DEFUN_LOCAL_VOID (GetVertexAttribfvNV,
+ (void *rend, GLuint index, GLenum pname, GLfloat * params),
+ (index, pname, params))
+
+DEFUN_ALIAS_VOID (GetVertexAttribfvNV, GetVertexAttribfvARB,
+ (GLuint index, GLenum pname, GLfloat * params),
+ (index, pname, params))
+
+DEFUN_LOCAL_VOID (GetVertexAttribivNV,
+ (void *rend, GLuint index, GLenum pname, GLint * params),
+ (index, pname, params))
+
+DEFUN_ALIAS_VOID (GetVertexAttribivNV, GetVertexAttribivNV,
+ (GLuint index, GLenum pname, GLint * params),
+ (index, pname, params))
+
+DEFUN_LOCAL_VOID (GetVertexAttribPointervNV,
+ (void *rend, GLuint index, GLenum pname, GLvoid ** pointer),
+ (index, pname, pointer))
+
+DEFUN_ALIAS_VOID (GetVertexAttribPointervNV, GetVertexAttribPointervARB,
+ (GLuint index, GLenum pname, GLvoid ** pointer),
+ (index, pname, pointer))
+
+DEFUN_LOCAL (GLboolean, IsProgramNV,
+ (void *rend, GLuint id),
+ (id))
+
+DEFUN_ALIAS (GLboolean, IsProgramNV, IsProgramARB,
+ (GLuint id),
+ (id))
+
+DEFUN_EXTERN_VOID (LoadProgramNV,
+ (GLenum target, GLuint id, GLsizei len, const GLubyte * program),
+ (target, id, len, program))
+
+DEFUN_EXTERN_VOID (ProgramParameter4dNV,
+ (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w),
+ (target, index, x, y, z, w))
+
+DEFUN_EXTERN_VOID (ProgramParameter4dvNV,
+ (GLenum target, GLuint index, const GLdouble * params),
+ (target, index, params))
+
+DEFUN_EXTERN_VOID (ProgramParameter4fNV,
+ (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w),
+ (target, index, x, y, z, w))
+
+DEFUN_EXTERN_VOID (ProgramParameter4fvNV,
+ (GLenum target, GLuint index, const GLfloat * params),
+ (target, index, params))
+
+DEFUN_EXTERN_VOID (ProgramParameters4dvNV,
+ (GLenum target, GLuint index, GLuint num, const GLdouble * params),
+ (target, index, num, params))
+
+DEFUN_EXTERN_VOID (ProgramParameters4fvNV,
+ (GLenum target, GLuint index, GLuint num, const GLfloat * params),
+ (target, index, num, params))
+
+DEFUN_EXTERN_VOID (RequestResidentProgramsNV,
+ (GLsizei n, const GLuint * ids),
+ (n, ids))
+
+DEFUN_EXTERN_VOID (TrackMatrixNV,
+ (GLenum target, GLuint address, GLenum matrix, GLenum transform),
+ (target, address, matrix, transform))
+
+DEFUN_EXTERN_VOID (VertexAttribPointerNV,
+ (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer),
+ (index, size, type, stride, pointer))
+
+DEFUN_LOCAL_VOID (VertexAttrib1dNV,
+ (void *rend, GLuint index, GLdouble x),
+ (index, x))
+
+DEFUN_ALIAS_VOID (VertexAttrib1dNV, VertexAttrib1dARB,
+ (GLuint index, GLdouble x),
+ (index, x))
+
+DEFUN_LOCAL_VOID (VertexAttrib1dvNV,
+ (void *rend, GLuint index, const GLdouble * v),
+ (index, v))
+
+DEFUN_ALIAS_VOID (VertexAttrib1dvNV, VertexAttrib1dvARB,
+ (GLuint index, const GLdouble * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib1fNV,
+ (void *rend, GLuint index, GLfloat x),
+ (index, x))
+
+DEFUN_ALIAS_VOID (VertexAttrib1fNV, VertexAttrib1fARB,
+ (GLuint index, GLfloat x),
+ (index, x))
+
+DEFUN_LOCAL_VOID (VertexAttrib1fvNV,
+ (void *rend, GLuint index, const GLfloat * v),
+ (index, v))
+
+DEFUN_ALIAS_VOID (VertexAttrib1fvNV, VertexAttrib1fvARB,
+ (GLuint index, const GLfloat * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib1sNV,
+ (void *rend, GLuint index, GLshort x),
+ (index, x))
+
+DEFUN_ALIAS_VOID (VertexAttrib1sNV, VertexAttrib1sARB,
+ (GLuint index, GLshort x),
+ (index, x))
+
+DEFUN_LOCAL_VOID (VertexAttrib1svNV,
+ (void *rend, GLuint index, const GLshort * v),
+ (index, v))
+
+DEFUN_ALIAS_VOID (VertexAttrib1svNV, VertexAttrib1svARB,
+ (GLuint index, const GLshort * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib2dNV,
+ (void *rend, GLuint index, GLdouble x, GLdouble y),
+ (index, x, y))
+
+DEFUN_ALIAS_VOID (VertexAttrib2dNV, VertexAttrib2dARB,
+ (GLuint index, GLdouble x, GLdouble y),
+ (index, x, y))
+
+DEFUN_LOCAL_VOID (VertexAttrib2dvNV,
+ (void *rend, GLuint index, const GLdouble * v),
+ (index, v))
+
+DEFUN_ALIAS_VOID (VertexAttrib2dvNV, VertexAttrib2dvARB,
+ (GLuint index, const GLdouble * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib2fNV,
+ (void *rend, GLuint index, GLfloat x, GLfloat y),
+ (index, x, y))
+
+DEFUN_ALIAS_VOID (VertexAttrib2fNV, VertexAttrib2fARB,
+ (GLuint index, GLfloat x, GLfloat y),
+ (index, x, y))
+
+DEFUN_LOCAL_VOID (VertexAttrib2fvNV,
+ (void *rend, GLuint index, const GLfloat * v),
+ (index, v))
+
+DEFUN_ALIAS_VOID (VertexAttrib2fvNV, VertexAttrib2fvARB,
+ (GLuint index, const GLfloat * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib2sNV,
+ (void *rend, GLuint index, GLshort x, GLshort y),
+ (index, x, y))
+
+DEFUN_ALIAS_VOID (VertexAttrib2sNV, VertexAttrib2sARB,
+ (GLuint index, GLshort x, GLshort y),
+ (index, x, y))
+
+DEFUN_LOCAL_VOID (VertexAttrib2svNV,
+ (void *rend, GLuint index, const GLshort * v),
+ (index, v))
+
+DEFUN_ALIAS_VOID (VertexAttrib2svNV, VertexAttrib2svARB,
+ (GLuint index, const GLshort * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib3dNV,
+ (void *rend, GLuint index, GLdouble x, GLdouble y, GLdouble z),
+ (index, x, y, z))
+
+DEFUN_ALIAS_VOID (VertexAttrib3dNV, VertexAttrib3dARB,
+ (GLuint index, GLdouble x, GLdouble y, GLdouble z),
+ (index, x, y, z))
+
+DEFUN_LOCAL_VOID (VertexAttrib3dvNV,
+ (void *rend, GLuint index, const GLdouble * v),
+ (index, v))
+
+DEFUN_ALIAS_VOID (VertexAttrib3dvNV, VertexAttrib3dvARB,
+ (GLuint index, const GLdouble * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib3fNV,
+ (void *rend, GLuint index, GLfloat x, GLfloat y, GLfloat z),
+ (index, x, y, z))
+
+DEFUN_ALIAS_VOID (VertexAttrib3fNV, VertexAttrib3fARB,
+ (GLuint index, GLfloat x, GLfloat y, GLfloat z),
+ (index, x, y, z))
+
+DEFUN_LOCAL_VOID (VertexAttrib3fvNV,
+ (void *rend, GLuint index, const GLfloat * v),
+ (index, v))
+
+DEFUN_ALIAS_VOID (VertexAttrib3fvNV, VertexAttrib3fvARB,
+ (GLuint index, const GLfloat * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib3sNV,
+ (void *rend, GLuint index, GLshort x, GLshort y, GLshort z),
+ (index, x, y, z))
+
+DEFUN_ALIAS_VOID (VertexAttrib3sNV, VertexAttrib3sARB,
+ (GLuint index, GLshort x, GLshort y, GLshort z),
+ (index, x, y, z))
+
+DEFUN_LOCAL_VOID (VertexAttrib3svNV,
+ (void *rend, GLuint index, const GLshort * v),
+ (index, v))
+
+DEFUN_ALIAS_VOID (VertexAttrib3svNV, VertexAttrib3svARB,
+ (GLuint index, const GLshort * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib4dNV,
+ (void *rend, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w),
+ (index, x, y, z, w))
+
+DEFUN_ALIAS_VOID (VertexAttrib4dNV, VertexAttrib4dARB,
+ (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w),
+ (index, x, y, z, w))
+
+DEFUN_LOCAL_VOID (VertexAttrib4dvNV,
+ (void *rend, GLuint index, const GLdouble * v),
+ (index, v))
+
+DEFUN_ALIAS_VOID (VertexAttrib4dvNV, VertexAttrib4dvARB,
+ (GLuint index, const GLdouble * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib4fNV,
+ (void *rend, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w),
+ (index, x, y, z, w))
+
+DEFUN_ALIAS_VOID (VertexAttrib4fNV, VertexAttrib4fARB,
+ (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w),
+ (index, x, y, z, w))
+
+DEFUN_LOCAL_VOID (VertexAttrib4fvNV,
+ (void *rend, GLuint index, const GLfloat * v),
+ (index, v))
+
+DEFUN_ALIAS_VOID (VertexAttrib4fvNV, VertexAttrib4fvARB,
+ (GLuint index, const GLfloat * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib4sNV,
+ (void *rend, GLuint index, GLshort x, GLshort y, GLshort z, GLshort w),
+ (index, x, y, z, w))
+
+DEFUN_ALIAS_VOID (VertexAttrib4sNV, VertexAttrib4sARB,
+ (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w),
+ (index, x, y, z, w))
+
+DEFUN_LOCAL_VOID (VertexAttrib4svNV,
+ (void *rend, GLuint index, const GLshort * v),
+ (index, v))
+
+DEFUN_ALIAS_VOID (VertexAttrib4svNV, VertexAttrib4svARB,
+ (GLuint index, const GLshort * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib4ubNV,
+ (void *rend, GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w),
+ (index, x, y, z, w))
+
+DEFUN_ALIAS_VOID (VertexAttrib4ubNV, VertexAttrib4NubARB,
+ (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w),
+ (index, x, y, z, w))
+
+DEFUN_LOCAL_VOID (VertexAttrib4ubvNV,
+ (void *rend, GLuint index, const GLubyte * v),
+ (index, v))
+
+DEFUN_ALIAS_VOID (VertexAttrib4ubvNV, VertexAttrib4ubvARB,
+ (GLuint index, const GLubyte * v),
+ (index, v))
+
+DEFUN_EXTERN_VOID (VertexAttribs1dvNV,
+ (GLuint index, GLsizei n, const GLdouble * v),
+ (index, n, v))
+
+DEFUN_EXTERN_VOID (VertexAttribs1fvNV,
+ (GLuint index, GLsizei n, const GLfloat * v),
+ (index, n, v))
+
+DEFUN_EXTERN_VOID (VertexAttribs1svNV,
+ (GLuint index, GLsizei n, const GLshort * v),
+ (index, n, v))
+
+DEFUN_EXTERN_VOID (VertexAttribs2dvNV,
+ (GLuint index, GLsizei n, const GLdouble * v),
+ (index, n, v))
+
+DEFUN_EXTERN_VOID (VertexAttribs2fvNV,
+ (GLuint index, GLsizei n, const GLfloat * v),
+ (index, n, v))
+
+DEFUN_EXTERN_VOID (VertexAttribs2svNV,
+ (GLuint index, GLsizei n, const GLshort * v),
+ (index, n, v))
+
+DEFUN_EXTERN_VOID (VertexAttribs3dvNV,
+ (GLuint index, GLsizei n, const GLdouble * v),
+ (index, n, v))
+
+DEFUN_EXTERN_VOID (VertexAttribs3fvNV,
+ (GLuint index, GLsizei n, const GLfloat * v),
+ (index, n, v))
+
+DEFUN_EXTERN_VOID (VertexAttribs3svNV,
+ (GLuint index, GLsizei n, const GLshort * v),
+ (index, n, v))
+
+DEFUN_EXTERN_VOID (VertexAttribs4dvNV,
+ (GLuint index, GLsizei n, const GLdouble * v),
+ (index, n, v))
+
+DEFUN_EXTERN_VOID (VertexAttribs4fvNV,
+ (GLuint index, GLsizei n, const GLfloat * v),
+ (index, n, v))
+
+DEFUN_EXTERN_VOID (VertexAttribs4svNV,
+ (GLuint index, GLsizei n, const GLshort * v),
+ (index, n, v))
+
+DEFUN_EXTERN_VOID (VertexAttribs4ubvNV,
+ (GLuint index, GLsizei n, const GLubyte * v),
+ (index, n, v))
+
+DEFUN_LOCAL_VOID (PointParameteriNV,
+ (void *rend, GLenum pname, GLint params),
+ (pname, params))
+
+DEFUN_LOCAL_VOID (PointParameterivNV,
+ (void *rend, GLenum pname, const GLint * params),
+ (pname, params))
+
+DEFUN_LOCAL_VOID (MultiDrawArraysEXT,
+ (void *rend, GLenum mode, GLint * first, GLsizei * count, GLsizei primcount),
+ (mode, first, count, primcount))
+
+DEFUN_LOCAL_VOID (MultiDrawElementsEXT,
+ (void *rend, GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount),
+ (mode, count, type, indices, primcount))
+
+DEFUN_LOCAL_VOID (ActiveStencilFaceEXT,
+ (void *rend, GLenum face),
+ (face))
+
+DEFUN_EXTERN_VOID (DeleteFencesNV,
+ (GLsizei n, const GLuint * fences),
+ (n, fences))
+
+DEFUN_EXTERN_VOID (GenFencesNV,
+ (GLsizei n, GLuint * fences),
+ (n, fences))
+
+DEFUN_EXTERN (GLboolean, IsFenceNV,
+ (GLuint fence),
+ (fence))
+
+DEFUN_EXTERN (GLboolean, TestFenceNV,
+ (GLuint fence),
+ (fence))
+
+DEFUN_EXTERN_VOID (GetFenceivNV,
+ (GLuint fence, GLenum pname, GLint * params),
+ (fence, pname, params))
+
+DEFUN_EXTERN_VOID (FinishFenceNV,
+ (GLuint fence),
+ (fence))
+
+DEFUN_EXTERN_VOID (SetFenceNV,
+ (GLuint fence, GLenum condition),
+ (fence, condition))
+
+DEFUN_LOCAL_VOID (VertexAttrib4bvARB,
+ (void *rend, GLuint index, const GLbyte * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib4ivARB,
+ (void *rend, GLuint index, const GLint * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib4ubvARB,
+ (void *rend, GLuint index, const GLubyte * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib4usvARB,
+ (void *rend, GLuint index, const GLushort * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib4uivARB,
+ (void *rend, GLuint index, const GLuint * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib4NbvARB,
+ (void *rend, GLuint index, const GLbyte * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib4NsvARB,
+ (void *rend, GLuint index, const GLshort * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib4NivARB,
+ (void *rend, GLuint index, const GLint * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib4NusvARB,
+ (void *rend, GLuint index, const GLushort * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttrib4NuivARB,
+ (void *rend, GLuint index, const GLuint * v),
+ (index, v))
+
+DEFUN_LOCAL_VOID (VertexAttribPointerARB,
+ (void *rend, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer),
+ (index, size, type, normalized, stride, pointer))
+
+DEFUN_LOCAL_VOID (EnableVertexAttribArrayARB,
+ (void *rend, GLuint index),
+ (index))
+
+DEFUN_LOCAL_VOID (DisableVertexAttribArrayARB,
+ (void *rend, GLuint index),
+ (index))
+
+DEFUN_LOCAL_VOID (ProgramStringARB,
+ (void *rend, GLenum target, GLenum format, GLsizei len, const GLvoid * string),
+ (target, format, len, string))
+
+DEFUN_LOCAL_VOID (ProgramEnvParameter4dARB,
+ (void *rend, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w),
+ (target, index, x, y, z, w))
+
+DEFUN_LOCAL_VOID (ProgramEnvParameter4dvARB,
+ (void *rend, GLenum target, GLuint index, const GLdouble * params),
+ (target, index, params))
+
+DEFUN_LOCAL_VOID (ProgramEnvParameter4fARB,
+ (void *rend, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w),
+ (target, index, x, y, z, w))
+
+DEFUN_LOCAL_VOID (ProgramEnvParameter4fvARB,
+ (void *rend, GLenum target, GLuint index, const GLfloat * params),
+ (target, index, params))
+
+DEFUN_LOCAL_VOID (ProgramLocalParameter4dARB,
+ (void *rend, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w),
+ (target, index, x, y, z, w))
+
+DEFUN_LOCAL_VOID (ProgramLocalParameter4dvARB,
+ (void *rend, GLenum target, GLuint index, const GLdouble * params),
+ (target, index, params))
+
+DEFUN_LOCAL_VOID (ProgramLocalParameter4fARB,
+ (void *rend, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w),
+ (target, index, x, y, z, w))
+
+DEFUN_LOCAL_VOID (ProgramLocalParameter4fvARB,
+ (void *rend, GLenum target, GLuint index, const GLfloat * params),
+ (target, index, params))
+
+DEFUN_LOCAL_VOID (GetProgramEnvParameterdvARB,
+ (void *rend, GLenum target, GLuint index, GLdouble * params),
+ (target, index, params))
+
+DEFUN_LOCAL_VOID (GetProgramEnvParameterfvARB,
+ (void *rend, GLenum target, GLuint index, GLfloat * params),
+ (target, index, params))
+
+DEFUN_LOCAL_VOID (GetProgramLocalParameterdvARB,
+ (void *rend, GLenum target, GLuint index, GLdouble * params),
+ (target, index, params))
+
+DEFUN_LOCAL_VOID (GetProgramLocalParameterfvARB,
+ (void *rend, GLenum target, GLuint index, GLfloat * params),
+ (target, index, params))
+
+DEFUN_LOCAL_VOID (GetProgramivARB,
+ (void *rend, GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_LOCAL_VOID (GetProgramStringARB,
+ (void *rend, GLenum target, GLenum pname, GLvoid * string),
+ (target, pname, string))
+
+DEFUN_EXTERN_VOID (ProgramNamedParameter4fNV,
+ (GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w),
+ (id, len, name, x, y, z, w))
+
+DEFUN_EXTERN_VOID (ProgramNamedParameter4dNV,
+ (GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w),
+ (id, len, name, x, y, z, w))
+
+DEFUN_EXTERN_VOID (ProgramNamedParameter4fvNV,
+ (GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v),
+ (id, len, name, v))
+
+DEFUN_EXTERN_VOID (ProgramNamedParameter4dvNV,
+ (GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v),
+ (id, len, name, v))
+
+DEFUN_EXTERN_VOID (GetProgramNamedParameterfvNV,
+ (GLuint id, GLsizei len, const GLubyte * name, GLfloat * params),
+ (id, len, name, params))
+
+DEFUN_EXTERN_VOID (GetProgramNamedParameterdvNV,
+ (GLuint id, GLsizei len, const GLubyte * name, GLdouble * params),
+ (id, len, name, params))
+
+#if OSVERSION < 704 /* Mac OS X 10.3.4 */
+
+DEFUN_EXTERN_VOID (BindBufferARB,
+ (GLenum target, GLuint buffer),
+ (target, buffer))
+
+DEFUN_EXTERN_VOID (BufferDataARB,
+ (GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage),
+ (target, size, data, usage))
+
+DEFUN_EXTERN_VOID (BufferSubDataARB,
+ (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data),
+ (target, offset, size, data))
+
+DEFUN_EXTERN_VOID (DeleteBuffersARB,
+ (GLsizei n, const GLuint * buffer),
+ (n, buffer))
+
+DEFUN_EXTERN_VOID (GenBuffersARB,
+ (GLsizei n, GLuint * buffer),
+ (n, buffer))
+
+DEFUN_EXTERN_VOID (GetBufferParameterivARB,
+ (GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_EXTERN_VOID (GetBufferPointervARB,
+ (GLenum target, GLenum pname, GLvoid ** params),
+ (target, pname, params))
+
+DEFUN_EXTERN_VOID (GetBufferSubDataARB,
+ (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data),
+ (target, offset, size, data))
+
+DEFUN_EXTERN (GLboolean, IsBufferARB,
+ (GLuint buffer),
+ (buffer))
+
+DEFUN_EXTERN (void*, MapBufferARB,
+ (GLenum target, GLenum access),
+ (target, access))
+
+DEFUN_EXTERN (GLboolean, UnmapBufferARB,
+ (GLenum target),
+ (target))
+
+DEFUN_EXTERN_VOID (DepthBoundsEXT,
+ (GLclampd zmin, GLclampd zmax),
+ (zmin, zmax))
+
+#endif /* OSVERSION < 704 */
+
+#if OSVERSION < 700 /* Mac OS X 10.3.0 */
+
+DEFUN_EXTERN_VOID (GenQueriesARB,
+ (GLsizei n, GLuint * ids),
+ (n, ids))
+
+DEFUN_EXTERN_VOID (DeleteQueriesARB,
+ (GLsizei n, const GLuint * ids),
+ (n, ids))
+
+DEFUN_EXTERN (GLboolean, IsQueryARB,
+ (GLuint id),
+ (id))
+
+DEFUN_EXTERN_VOID (BeginQueryARB,
+ (GLenum target, GLuint id),
+ (target, id))
+
+DEFUN_EXTERN_VOID (EndQueryARB,
+ (GLenum target),
+ (target))
+
+DEFUN_EXTERN_VOID (GetQueryivARB,
+ (GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_EXTERN_VOID (GetQueryObjectivARB,
+ (GLuint id, GLenum pname, GLint * params),
+ (id, pname, params))
+
+DEFUN_EXTERN_VOID (GetQueryObjectuivARB,
+ (GLuint id, GLenum pname, GLuint * params),
+ (id, pname, params))
+
+#endif /* OSVERSION < 700 */
+
+DEFUN_EXTERN_VOID (MultiModeDrawArraysIBM,
+ (const GLenum * mode, const GLint * first, const GLsizei * count, GLsizei primcount, GLint modestride),
+ (mode, first, count, primcount, modestride))
+
+DEFUN_EXTERN_VOID (MultiModeDrawElementsIBM,
+ (const GLenum * mode, const GLsizei * count, GLenum type, const GLvoid * const * indices, GLsizei primcount, GLint modestride),
+ (mode, count, type, indices, primcount, modestride))
+
+DEFUN_LOCAL_VOID (BlendEquationSeparateEXT,
+ (void *rend, GLenum modeRGB, GLenum modeA),
+ (modeRGB, modeA))
+
+#if OSVERSION < 704
+
+DEFUN_ALIAS_VOID (BlendEquationSeparateEXT, BlendEquationSeparateATI,
+ (GLenum modeRGB, GLenum modeA),
+ (modeRGB, modeA))
+
+#endif /* OSVERSION < 704 */
+
+DEFUN_ALIAS_VOID (ArrayElementEXT, ArrayElement,
+ (GLint i),
+ (i))
+
+DEFUN_ALIAS_VOID (BindTextureEXT, BindTexture,
+ (GLenum target, GLuint texture),
+ (target, texture))
+
+DEFUN_ALIAS_VOID (BlendFuncSeparateINGR, BlendFuncSeparateEXT,
+ (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha),
+ (sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha))
+
+DEFUN_ALIAS_VOID (ColorTableParameterfvSGI, ColorTableParameterfv,
+ (GLenum target, GLenum pname, const GLfloat * params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (ColorTableParameterivSGI, ColorTableParameteriv,
+ (GLenum target, GLenum pname, const GLint * params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (ColorTableSGI, ColorTable,
+ (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table),
+ (target, internalformat, width, format, type, table))
+
+DEFUN_ALIAS_VOID (ConvolutionFilter1DEXT, ConvolutionFilter1D,
+ (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * image),
+ (target, internalformat, width, format, type, image))
+
+DEFUN_ALIAS_VOID (ConvolutionFilter2DEXT, ConvolutionFilter2D,
+ (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * image),
+ (target, internalformat, width, height, format, type, image))
+
+DEFUN_ALIAS_VOID (ConvolutionParameterfEXT, ConvolutionParameterf,
+ (GLenum target, GLenum pname, GLfloat params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (ConvolutionParameterfvEXT, ConvolutionParameterfv,
+ (GLenum target, GLenum pname, const GLfloat * params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (ConvolutionParameteriEXT, ConvolutionParameteri,
+ (GLenum target, GLenum pname, GLint params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (ConvolutionParameterivEXT, ConvolutionParameteriv,
+ (GLenum target, GLenum pname, const GLint * params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (CopyColorSubTableEXT, CopyColorSubTable,
+ (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width),
+ (target, start, x, y, width))
+
+DEFUN_ALIAS_VOID (CopyColorTableSGI, CopyColorTable,
+ (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width),
+ (target, internalformat, x, y, width))
+
+DEFUN_ALIAS_VOID (CopyConvolutionFilter1DEXT, CopyConvolutionFilter1D,
+ (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width),
+ (target, internalformat, x, y, width))
+
+DEFUN_ALIAS_VOID (CopyConvolutionFilter2DEXT, CopyConvolutionFilter2D,
+ (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height),
+ (target, internalformat, x, y, width, height))
+
+DEFUN_ALIAS_VOID (CopyTexImage1DEXT, CopyTexImage1D,
+ (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border),
+ (target, level, internalformat, x, y, width, border))
+
+DEFUN_ALIAS_VOID (CopyTexImage2DEXT, CopyTexImage2D,
+ (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border),
+ (target, level, internalformat, x, y, width, height, border))
+
+DEFUN_ALIAS_VOID (CopyTexSubImage1DEXT, CopyTexSubImage1D,
+ (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width),
+ (target, level, xoffset, x, y, width))
+
+DEFUN_ALIAS_VOID (CopyTexSubImage2DEXT, CopyTexSubImage2D,
+ (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height),
+ (target, level, xoffset, yoffset, x, y, width, height))
+
+DEFUN_ALIAS_VOID (CopyTexSubImage3DEXT, CopyTexSubImage3D,
+ (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height),
+ (target, level, xoffset, yoffset, zoffset, x, y, width, height))
+
+DEFUN_ALIAS_VOID (DeleteTexturesEXT, DeleteTextures,
+ (GLsizei n, const GLuint *textures),
+ (n, textures))
+
+DEFUN_ALIAS_VOID (DrawArraysEXT, DrawArrays,
+ (GLenum mode, GLint first, GLsizei count),
+ (mode, first, count))
+
+DEFUN_ALIAS_VOID (GetPointervEXT, GetPointerv,
+ (GLenum pname, GLvoid * * params),
+ (pname, params))
+
+DEFUN_ALIAS_VOID (HistogramEXT, Histogram,
+ (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink),
+ (target, width, internalformat, sink))
+
+DEFUN_ALIAS_VOID (MinmaxEXT, Minmax,
+ (GLenum target, GLenum internalformat, GLboolean sink),
+ (target, internalformat, sink))
+
+DEFUN_ALIAS_VOID (PointParameterfSGIS, PointParameterf,
+ (GLenum pname, GLfloat param),
+ (pname, param))
+
+DEFUN_ALIAS_VOID (PointParameterfvSGIS, PointParameterfv,
+ (GLenum pname, const GLfloat * params),
+ (pname, params))
+
+DEFUN_ALIAS_VOID (PointParameteri, PointParameteriNV,
+ (GLenum pname, GLint params),
+ (pname, params))
+
+DEFUN_ALIAS_VOID (PointParameteriv, PointParameterivNV,
+ (GLenum pname, const GLint * params),
+ (pname, params))
+
+DEFUN_ALIAS_VOID (PrioritizeTexturesEXT, PrioritizeTextures,
+ (GLsizei n, const GLenum * textures, const GLclampf * priorities),
+ (n, textures, priorities))
+
+DEFUN_ALIAS_VOID (ResetHistogramEXT, ResetHistogram,
+ (GLenum target),
+ (target))
+
+DEFUN_ALIAS_VOID (ResetMinmaxEXT, ResetMinmax,
+ (GLenum target),
+ (target))
+
+DEFUN_ALIAS_VOID (SampleMaskEXT, SampleMaskSGIS,
+ (GLclampf value, GLboolean invert),
+ (value, invert))
+
+DEFUN_ALIAS_VOID (SamplePatternEXT, SamplePatternSGIS,
+ (GLenum pattern),
+ (pattern))
+
+DEFUN_ALIAS_VOID (SeparableFilter2DEXT, SeparableFilter2D,
+ (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * row, const GLvoid * column),
+ (target, internalformat, width, height, format, type, row, column))
+
+DEFUN_ALIAS_VOID (TexImage3DEXT, TexImage3D,
+ (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels),
+ (target, level, internalformat, width, height, depth, border, format, type, pixels))
+
+DEFUN_ALIAS_VOID (TexSubImage1DEXT, TexSubImage1D,
+ (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid * pixels),
+ (target, level, xoffset, width, format, type, pixels))
+
+DEFUN_ALIAS_VOID (TexSubImage2DEXT, TexSubImage2D,
+ (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels),
+ (target, level, xoffset, yoffset, width, height, format, type, pixels))
+
+DEFUN_ALIAS_VOID (TexSubImage3DEXT, TexSubImage3D,
+ (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels),
+ (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels))
+
+#if OSVERSION < 704
+
+DEFUN_ALIAS_VOID (BindBuffer, BindBufferARB,
+ (GLenum target, GLuint buffer),
+ (target, buffer))
+
+DEFUN_ALIAS_VOID (BufferData, BufferDataARB,
+ (GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage),
+ (target, size, data, usage))
+
+DEFUN_ALIAS_VOID (BufferSubData, BufferSubDataARB,
+ (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data),
+ (target, offset, size, data))
+
+DEFUN_ALIAS_VOID (DeleteBuffers, DeleteBuffersARB,
+ (GLsizei n, const GLuint * buffer),
+ (n, buffer))
+
+DEFUN_ALIAS_VOID (GenBuffers, GenBuffersARB,
+ (GLsizei n, GLuint * buffer),
+ (n, buffer))
+
+DEFUN_ALIAS_VOID (GetBufferParameteriv, GetBufferParameterivARB,
+ (GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (GetBufferPointerv, GetBufferPointervARB,
+ (GLenum target, GLenum pname, GLvoid ** params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (GetBufferSubData, GetBufferSubDataARB,
+ (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data),
+ (target, offset, size, data))
+
+DEFUN_ALIAS (GLboolean, IsBuffer, IsBufferARB,
+ (GLuint buffer),
+ (buffer))
+
+DEFUN_ALIAS (void*, MapBuffer, MapBufferARB,
+ (GLenum target, GLenum access),
+ (target, access))
+
+DEFUN_ALIAS (GLboolean, UnmapBuffer, UnmapBufferARB,
+ (GLenum target),
+ (target))
+
+#endif /* OSVERSION < 704 */
+
+#if OSVERSION < 700 /* Mac OS X 10.3.0 */
+
+DEFUN_ALIAS_VOID (GenQueries, GenQueriesARB,
+ (GLsizei n, GLuint * ids),
+ (n, ids))
+
+DEFUN_ALIAS_VOID (DeleteQueries, DeleteQueriesARB,
+ (GLsizei n, const GLuint * ids),
+ (n, ids))
+
+DEFUN_ALIAS (GLboolean, IsQuery, IsQueryARB,
+ (GLuint id),
+ (id))
+
+DEFUN_ALIAS_VOID (BeginQuery, BeginQueryARB,
+ (GLenum target, GLuint id),
+ (target, id))
+
+DEFUN_ALIAS_VOID (EndQuery, EndQueryARB,
+ (GLenum target),
+ (target))
+
+DEFUN_ALIAS_VOID (GetQueryiv, GetQueryivARB,
+ (GLenum target, GLenum pname, GLint * params),
+ (target, pname, params))
+
+DEFUN_ALIAS_VOID (GetQueryObjectiv, GetQueryObjectivARB,
+ (GLuint id, GLenum pname, GLint * params),
+ (id, pname, params))
+
+DEFUN_ALIAS_VOID (GetQueryObjectuiv, GetQueryObjectuivARB,
+ (GLuint id, GLenum pname, GLuint * params),
+ (id, pname, params))
+
+#endif /* OSVERSION < 700 */
+
+#define INDIRECT_DISPATCH_INIT(d,p) \
+do { \
+ (d)[0] = (void *) &p ## Accum; \
+ (d)[1] = (void *) &p ## AlphaFunc; \
+ (d)[2] = (void *) &p ## AreTexturesResident; \
+ (d)[3] = (void *) &p ## ArrayElement; \
+ (d)[4] = (void *) &p ## Begin; \
+ (d)[5] = (void *) &p ## BindTexture; \
+ (d)[6] = (void *) &p ## Bitmap; \
+ (d)[7] = (void *) &p ## BlendFunc; \
+ (d)[8] = (void *) &p ## CallList; \
+ (d)[9] = (void *) &p ## CallLists; \
+ (d)[10] = (void *) &p ## Clear; \
+ (d)[11] = (void *) &p ## ClearAccum; \
+ (d)[12] = (void *) &p ## ClearColor; \
+ (d)[13] = (void *) &p ## ClearDepth; \
+ (d)[14] = (void *) &p ## ClearIndex; \
+ (d)[15] = (void *) &p ## ClearStencil; \
+ (d)[16] = (void *) &p ## ClipPlane; \
+ (d)[17] = (void *) &p ## Color3b; \
+ (d)[18] = (void *) &p ## Color3bv; \
+ (d)[19] = (void *) &p ## Color3d; \
+ (d)[20] = (void *) &p ## Color3dv; \
+ (d)[21] = (void *) &p ## Color3f; \
+ (d)[22] = (void *) &p ## Color3fv; \
+ (d)[23] = (void *) &p ## Color3i; \
+ (d)[24] = (void *) &p ## Color3iv; \
+ (d)[25] = (void *) &p ## Color3s; \
+ (d)[26] = (void *) &p ## Color3sv; \
+ (d)[27] = (void *) &p ## Color3ub; \
+ (d)[28] = (void *) &p ## Color3ubv; \
+ (d)[29] = (void *) &p ## Color3ui; \
+ (d)[30] = (void *) &p ## Color3uiv; \
+ (d)[31] = (void *) &p ## Color3us; \
+ (d)[32] = (void *) &p ## Color3usv; \
+ (d)[33] = (void *) &p ## Color4b; \
+ (d)[34] = (void *) &p ## Color4bv; \
+ (d)[35] = (void *) &p ## Color4d; \
+ (d)[36] = (void *) &p ## Color4dv; \
+ (d)[37] = (void *) &p ## Color4f; \
+ (d)[38] = (void *) &p ## Color4fv; \
+ (d)[39] = (void *) &p ## Color4i; \
+ (d)[40] = (void *) &p ## Color4iv; \
+ (d)[41] = (void *) &p ## Color4s; \
+ (d)[42] = (void *) &p ## Color4sv; \
+ (d)[43] = (void *) &p ## Color4ub; \
+ (d)[44] = (void *) &p ## Color4ubv; \
+ (d)[45] = (void *) &p ## Color4ui; \
+ (d)[46] = (void *) &p ## Color4uiv; \
+ (d)[47] = (void *) &p ## Color4us; \
+ (d)[48] = (void *) &p ## Color4usv; \
+ (d)[49] = (void *) &p ## ColorMask; \
+ (d)[50] = (void *) &p ## ColorMaterial; \
+ (d)[51] = (void *) &p ## ColorPointer; \
+ (d)[52] = (void *) &p ## CopyPixels; \
+ (d)[53] = (void *) &p ## CopyTexImage1D; \
+ (d)[54] = (void *) &p ## CopyTexImage2D; \
+ (d)[55] = (void *) &p ## CopyTexSubImage1D; \
+ (d)[56] = (void *) &p ## CopyTexSubImage2D; \
+ (d)[57] = (void *) &p ## CullFace; \
+ (d)[58] = (void *) &p ## DeleteLists; \
+ (d)[59] = (void *) &p ## DeleteTextures; \
+ (d)[60] = (void *) &p ## DepthFunc; \
+ (d)[61] = (void *) &p ## DepthMask; \
+ (d)[62] = (void *) &p ## DepthRange; \
+ (d)[63] = (void *) &p ## Disable; \
+ (d)[64] = (void *) &p ## DisableClientState; \
+ (d)[65] = (void *) &p ## DrawArrays; \
+ (d)[66] = (void *) &p ## DrawBuffer; \
+ (d)[67] = (void *) &p ## DrawElements; \
+ (d)[68] = (void *) &p ## DrawPixels; \
+ (d)[69] = (void *) &p ## EdgeFlag; \
+ (d)[70] = (void *) &p ## EdgeFlagPointer; \
+ (d)[71] = (void *) &p ## EdgeFlagv; \
+ (d)[72] = (void *) &p ## Enable; \
+ (d)[73] = (void *) &p ## EnableClientState; \
+ (d)[74] = (void *) &p ## End; \
+ (d)[75] = (void *) &p ## EndList; \
+ (d)[76] = (void *) &p ## EvalCoord1d; \
+ (d)[77] = (void *) &p ## EvalCoord1dv; \
+ (d)[78] = (void *) &p ## EvalCoord1f; \
+ (d)[79] = (void *) &p ## EvalCoord1fv; \
+ (d)[80] = (void *) &p ## EvalCoord2d; \
+ (d)[81] = (void *) &p ## EvalCoord2dv; \
+ (d)[82] = (void *) &p ## EvalCoord2f; \
+ (d)[83] = (void *) &p ## EvalCoord2fv; \
+ (d)[84] = (void *) &p ## EvalMesh1; \
+ (d)[85] = (void *) &p ## EvalMesh2; \
+ (d)[86] = (void *) &p ## EvalPoint1; \
+ (d)[87] = (void *) &p ## EvalPoint2; \
+ (d)[88] = (void *) &p ## FeedbackBuffer; \
+ (d)[89] = (void *) &p ## Finish; \
+ (d)[90] = (void *) &p ## Flush; \
+ (d)[91] = (void *) &p ## Fogf; \
+ (d)[92] = (void *) &p ## Fogfv; \
+ (d)[93] = (void *) &p ## Fogi; \
+ (d)[94] = (void *) &p ## Fogiv; \
+ (d)[95] = (void *) &p ## FrontFace; \
+ (d)[96] = (void *) &p ## Frustum; \
+ (d)[97] = (void *) &p ## GenLists; \
+ (d)[98] = (void *) &p ## GenTextures; \
+ (d)[99] = (void *) &p ## GetBooleanv; \
+ (d)[100] = (void *) &p ## GetClipPlane; \
+ (d)[101] = (void *) &p ## GetDoublev; \
+ (d)[102] = (void *) &p ## GetError; \
+ (d)[103] = (void *) &p ## GetFloatv; \
+ (d)[104] = (void *) &p ## GetIntegerv; \
+ (d)[105] = (void *) &p ## GetLightfv; \
+ (d)[106] = (void *) &p ## GetLightiv; \
+ (d)[107] = (void *) &p ## GetMapdv; \
+ (d)[108] = (void *) &p ## GetMapfv; \
+ (d)[109] = (void *) &p ## GetMapiv; \
+ (d)[110] = (void *) &p ## GetMaterialfv; \
+ (d)[111] = (void *) &p ## GetMaterialiv; \
+ (d)[112] = (void *) &p ## GetPixelMapfv; \
+ (d)[113] = (void *) &p ## GetPixelMapuiv; \
+ (d)[114] = (void *) &p ## GetPixelMapusv; \
+ (d)[115] = (void *) &p ## GetPointerv; \
+ (d)[116] = (void *) &p ## GetPolygonStipple; \
+ (d)[117] = (void *) &p ## GetString; \
+ (d)[118] = (void *) &p ## GetTexEnvfv; \
+ (d)[119] = (void *) &p ## GetTexEnviv; \
+ (d)[120] = (void *) &p ## GetTexGendv; \
+ (d)[121] = (void *) &p ## GetTexGenfv; \
+ (d)[122] = (void *) &p ## GetTexGeniv; \
+ (d)[123] = (void *) &p ## GetTexImage; \
+ (d)[124] = (void *) &p ## GetTexLevelParameterfv; \
+ (d)[125] = (void *) &p ## GetTexLevelParameteriv; \
+ (d)[126] = (void *) &p ## GetTexParameterfv; \
+ (d)[127] = (void *) &p ## GetTexParameteriv; \
+ (d)[128] = (void *) &p ## Hint; \
+ (d)[129] = (void *) &p ## IndexMask; \
+ (d)[130] = (void *) &p ## IndexPointer; \
+ (d)[131] = (void *) &p ## Indexd; \
+ (d)[132] = (void *) &p ## Indexdv; \
+ (d)[133] = (void *) &p ## Indexf; \
+ (d)[134] = (void *) &p ## Indexfv; \
+ (d)[135] = (void *) &p ## Indexi; \
+ (d)[136] = (void *) &p ## Indexiv; \
+ (d)[137] = (void *) &p ## Indexs; \
+ (d)[138] = (void *) &p ## Indexsv; \
+ (d)[139] = (void *) &p ## Indexub; \
+ (d)[140] = (void *) &p ## Indexubv; \
+ (d)[141] = (void *) &p ## InitNames; \
+ (d)[142] = (void *) &p ## InterleavedArrays; \
+ (d)[143] = (void *) &p ## IsEnabled; \
+ (d)[144] = (void *) &p ## IsList; \
+ (d)[145] = (void *) &p ## IsTexture; \
+ (d)[146] = (void *) &p ## LightModelf; \
+ (d)[147] = (void *) &p ## LightModelfv; \
+ (d)[148] = (void *) &p ## LightModeli; \
+ (d)[149] = (void *) &p ## LightModeliv; \
+ (d)[150] = (void *) &p ## Lightf; \
+ (d)[151] = (void *) &p ## Lightfv; \
+ (d)[152] = (void *) &p ## Lighti; \
+ (d)[153] = (void *) &p ## Lightiv; \
+ (d)[154] = (void *) &p ## LineStipple; \
+ (d)[155] = (void *) &p ## LineWidth; \
+ (d)[156] = (void *) &p ## ListBase; \
+ (d)[157] = (void *) &p ## LoadIdentity; \
+ (d)[158] = (void *) &p ## LoadMatrixd; \
+ (d)[159] = (void *) &p ## LoadMatrixf; \
+ (d)[160] = (void *) &p ## LoadName; \
+ (d)[161] = (void *) &p ## LogicOp; \
+ (d)[162] = (void *) &p ## Map1d; \
+ (d)[163] = (void *) &p ## Map1f; \
+ (d)[164] = (void *) &p ## Map2d; \
+ (d)[165] = (void *) &p ## Map2f; \
+ (d)[166] = (void *) &p ## MapGrid1d; \
+ (d)[167] = (void *) &p ## MapGrid1f; \
+ (d)[168] = (void *) &p ## MapGrid2d; \
+ (d)[169] = (void *) &p ## MapGrid2f; \
+ (d)[170] = (void *) &p ## Materialf; \
+ (d)[171] = (void *) &p ## Materialfv; \
+ (d)[172] = (void *) &p ## Materiali; \
+ (d)[173] = (void *) &p ## Materialiv; \
+ (d)[174] = (void *) &p ## MatrixMode; \
+ (d)[175] = (void *) &p ## MultMatrixd; \
+ (d)[176] = (void *) &p ## MultMatrixf; \
+ (d)[177] = (void *) &p ## NewList; \
+ (d)[178] = (void *) &p ## Normal3b; \
+ (d)[179] = (void *) &p ## Normal3bv; \
+ (d)[180] = (void *) &p ## Normal3d; \
+ (d)[181] = (void *) &p ## Normal3dv; \
+ (d)[182] = (void *) &p ## Normal3f; \
+ (d)[183] = (void *) &p ## Normal3fv; \
+ (d)[184] = (void *) &p ## Normal3i; \
+ (d)[185] = (void *) &p ## Normal3iv; \
+ (d)[186] = (void *) &p ## Normal3s; \
+ (d)[187] = (void *) &p ## Normal3sv; \
+ (d)[188] = (void *) &p ## NormalPointer; \
+ (d)[189] = (void *) &p ## Ortho; \
+ (d)[190] = (void *) &p ## PassThrough; \
+ (d)[191] = (void *) &p ## PixelMapfv; \
+ (d)[192] = (void *) &p ## PixelMapuiv; \
+ (d)[193] = (void *) &p ## PixelMapusv; \
+ (d)[194] = (void *) &p ## PixelStoref; \
+ (d)[195] = (void *) &p ## PixelStorei; \
+ (d)[196] = (void *) &p ## PixelTransferf; \
+ (d)[197] = (void *) &p ## PixelTransferi; \
+ (d)[198] = (void *) &p ## PixelZoom; \
+ (d)[199] = (void *) &p ## PointSize; \
+ (d)[200] = (void *) &p ## PolygonMode; \
+ (d)[201] = (void *) &p ## PolygonOffset; \
+ (d)[202] = (void *) &p ## PolygonStipple; \
+ (d)[203] = (void *) &p ## PopAttrib; \
+ (d)[204] = (void *) &p ## PopClientAttrib; \
+ (d)[205] = (void *) &p ## PopMatrix; \
+ (d)[206] = (void *) &p ## PopName; \
+ (d)[207] = (void *) &p ## PrioritizeTextures; \
+ (d)[208] = (void *) &p ## PushAttrib; \
+ (d)[209] = (void *) &p ## PushClientAttrib; \
+ (d)[210] = (void *) &p ## PushMatrix; \
+ (d)[211] = (void *) &p ## PushName; \
+ (d)[212] = (void *) &p ## RasterPos2d; \
+ (d)[213] = (void *) &p ## RasterPos2dv; \
+ (d)[214] = (void *) &p ## RasterPos2f; \
+ (d)[215] = (void *) &p ## RasterPos2fv; \
+ (d)[216] = (void *) &p ## RasterPos2i; \
+ (d)[217] = (void *) &p ## RasterPos2iv; \
+ (d)[218] = (void *) &p ## RasterPos2s; \
+ (d)[219] = (void *) &p ## RasterPos2sv; \
+ (d)[220] = (void *) &p ## RasterPos3d; \
+ (d)[221] = (void *) &p ## RasterPos3dv; \
+ (d)[222] = (void *) &p ## RasterPos3f; \
+ (d)[223] = (void *) &p ## RasterPos3fv; \
+ (d)[224] = (void *) &p ## RasterPos3i; \
+ (d)[225] = (void *) &p ## RasterPos3iv; \
+ (d)[226] = (void *) &p ## RasterPos3s; \
+ (d)[227] = (void *) &p ## RasterPos3sv; \
+ (d)[228] = (void *) &p ## RasterPos4d; \
+ (d)[229] = (void *) &p ## RasterPos4dv; \
+ (d)[230] = (void *) &p ## RasterPos4f; \
+ (d)[231] = (void *) &p ## RasterPos4fv; \
+ (d)[232] = (void *) &p ## RasterPos4i; \
+ (d)[233] = (void *) &p ## RasterPos4iv; \
+ (d)[234] = (void *) &p ## RasterPos4s; \
+ (d)[235] = (void *) &p ## RasterPos4sv; \
+ (d)[236] = (void *) &p ## ReadBuffer; \
+ (d)[237] = (void *) &p ## ReadPixels; \
+ (d)[238] = (void *) &p ## Rectd; \
+ (d)[239] = (void *) &p ## Rectdv; \
+ (d)[240] = (void *) &p ## Rectf; \
+ (d)[241] = (void *) &p ## Rectfv; \
+ (d)[242] = (void *) &p ## Recti; \
+ (d)[243] = (void *) &p ## Rectiv; \
+ (d)[244] = (void *) &p ## Rects; \
+ (d)[245] = (void *) &p ## Rectsv; \
+ (d)[246] = (void *) &p ## RenderMode; \
+ (d)[247] = (void *) &p ## Rotated; \
+ (d)[248] = (void *) &p ## Rotatef; \
+ (d)[249] = (void *) &p ## Scaled; \
+ (d)[250] = (void *) &p ## Scalef; \
+ (d)[251] = (void *) &p ## Scissor; \
+ (d)[252] = (void *) &p ## SelectBuffer; \
+ (d)[253] = (void *) &p ## ShadeModel; \
+ (d)[254] = (void *) &p ## StencilFunc; \
+ (d)[255] = (void *) &p ## StencilMask; \
+ (d)[256] = (void *) &p ## StencilOp; \
+ (d)[257] = (void *) &p ## TexCoord1d; \
+ (d)[258] = (void *) &p ## TexCoord1dv; \
+ (d)[259] = (void *) &p ## TexCoord1f; \
+ (d)[260] = (void *) &p ## TexCoord1fv; \
+ (d)[261] = (void *) &p ## TexCoord1i; \
+ (d)[262] = (void *) &p ## TexCoord1iv; \
+ (d)[263] = (void *) &p ## TexCoord1s; \
+ (d)[264] = (void *) &p ## TexCoord1sv; \
+ (d)[265] = (void *) &p ## TexCoord2d; \
+ (d)[266] = (void *) &p ## TexCoord2dv; \
+ (d)[267] = (void *) &p ## TexCoord2f; \
+ (d)[268] = (void *) &p ## TexCoord2fv; \
+ (d)[269] = (void *) &p ## TexCoord2i; \
+ (d)[270] = (void *) &p ## TexCoord2iv; \
+ (d)[271] = (void *) &p ## TexCoord2s; \
+ (d)[272] = (void *) &p ## TexCoord2sv; \
+ (d)[273] = (void *) &p ## TexCoord3d; \
+ (d)[274] = (void *) &p ## TexCoord3dv; \
+ (d)[275] = (void *) &p ## TexCoord3f; \
+ (d)[276] = (void *) &p ## TexCoord3fv; \
+ (d)[277] = (void *) &p ## TexCoord3i; \
+ (d)[278] = (void *) &p ## TexCoord3iv; \
+ (d)[279] = (void *) &p ## TexCoord3s; \
+ (d)[280] = (void *) &p ## TexCoord3sv; \
+ (d)[281] = (void *) &p ## TexCoord4d; \
+ (d)[282] = (void *) &p ## TexCoord4dv; \
+ (d)[283] = (void *) &p ## TexCoord4f; \
+ (d)[284] = (void *) &p ## TexCoord4fv; \
+ (d)[285] = (void *) &p ## TexCoord4i; \
+ (d)[286] = (void *) &p ## TexCoord4iv; \
+ (d)[287] = (void *) &p ## TexCoord4s; \
+ (d)[288] = (void *) &p ## TexCoord4sv; \
+ (d)[289] = (void *) &p ## TexCoordPointer; \
+ (d)[290] = (void *) &p ## TexEnvf; \
+ (d)[291] = (void *) &p ## TexEnvfv; \
+ (d)[292] = (void *) &p ## TexEnvi; \
+ (d)[293] = (void *) &p ## TexEnviv; \
+ (d)[294] = (void *) &p ## TexGend; \
+ (d)[295] = (void *) &p ## TexGendv; \
+ (d)[296] = (void *) &p ## TexGenf; \
+ (d)[297] = (void *) &p ## TexGenfv; \
+ (d)[298] = (void *) &p ## TexGeni; \
+ (d)[299] = (void *) &p ## TexGeniv; \
+ (d)[300] = (void *) &p ## TexImage1D; \
+ (d)[301] = (void *) &p ## TexImage2D; \
+ (d)[302] = (void *) &p ## TexParameterf; \
+ (d)[303] = (void *) &p ## TexParameterfv; \
+ (d)[304] = (void *) &p ## TexParameteri; \
+ (d)[305] = (void *) &p ## TexParameteriv; \
+ (d)[306] = (void *) &p ## TexSubImage1D; \
+ (d)[307] = (void *) &p ## TexSubImage2D; \
+ (d)[308] = (void *) &p ## Translated; \
+ (d)[309] = (void *) &p ## Translatef; \
+ (d)[310] = (void *) &p ## Vertex2d; \
+ (d)[311] = (void *) &p ## Vertex2dv; \
+ (d)[312] = (void *) &p ## Vertex2f; \
+ (d)[313] = (void *) &p ## Vertex2fv; \
+ (d)[314] = (void *) &p ## Vertex2i; \
+ (d)[315] = (void *) &p ## Vertex2iv; \
+ (d)[316] = (void *) &p ## Vertex2s; \
+ (d)[317] = (void *) &p ## Vertex2sv; \
+ (d)[318] = (void *) &p ## Vertex3d; \
+ (d)[319] = (void *) &p ## Vertex3dv; \
+ (d)[320] = (void *) &p ## Vertex3f; \
+ (d)[321] = (void *) &p ## Vertex3fv; \
+ (d)[322] = (void *) &p ## Vertex3i; \
+ (d)[323] = (void *) &p ## Vertex3iv; \
+ (d)[324] = (void *) &p ## Vertex3s; \
+ (d)[325] = (void *) &p ## Vertex3sv; \
+ (d)[326] = (void *) &p ## Vertex4d; \
+ (d)[327] = (void *) &p ## Vertex4dv; \
+ (d)[328] = (void *) &p ## Vertex4f; \
+ (d)[329] = (void *) &p ## Vertex4fv; \
+ (d)[330] = (void *) &p ## Vertex4i; \
+ (d)[331] = (void *) &p ## Vertex4iv; \
+ (d)[332] = (void *) &p ## Vertex4s; \
+ (d)[333] = (void *) &p ## Vertex4sv; \
+ (d)[334] = (void *) &p ## VertexPointer; \
+ (d)[335] = (void *) &p ## Viewport; \
+ (d)[336] = (void *) &p ## BlendFuncSeparateEXT; \
+ (d)[337] = (void *) &p ## BlendColor; \
+ (d)[338] = (void *) &p ## BlendEquation; \
+ (d)[339] = (void *) &p ## LockArraysEXT; \
+ (d)[340] = (void *) &p ## UnlockArraysEXT; \
+ (d)[341] = (void *) &p ## ClientActiveTextureARB; \
+ (d)[342] = (void *) &p ## ActiveTextureARB; \
+ (d)[343] = (void *) &p ## MultiTexCoord1dARB; \
+ (d)[344] = (void *) &p ## MultiTexCoord1dvARB; \
+ (d)[345] = (void *) &p ## MultiTexCoord1fARB; \
+ (d)[346] = (void *) &p ## MultiTexCoord1fvARB; \
+ (d)[347] = (void *) &p ## MultiTexCoord1iARB; \
+ (d)[348] = (void *) &p ## MultiTexCoord1ivARB; \
+ (d)[349] = (void *) &p ## MultiTexCoord1sARB; \
+ (d)[350] = (void *) &p ## MultiTexCoord1svARB; \
+ (d)[351] = (void *) &p ## MultiTexCoord2dARB; \
+ (d)[352] = (void *) &p ## MultiTexCoord2dvARB; \
+ (d)[353] = (void *) &p ## MultiTexCoord2fARB; \
+ (d)[354] = (void *) &p ## MultiTexCoord2fvARB; \
+ (d)[355] = (void *) &p ## MultiTexCoord2iARB; \
+ (d)[356] = (void *) &p ## MultiTexCoord2ivARB; \
+ (d)[357] = (void *) &p ## MultiTexCoord2sARB; \
+ (d)[358] = (void *) &p ## MultiTexCoord2svARB; \
+ (d)[359] = (void *) &p ## MultiTexCoord3dARB; \
+ (d)[360] = (void *) &p ## MultiTexCoord3dvARB; \
+ (d)[361] = (void *) &p ## MultiTexCoord3fARB; \
+ (d)[362] = (void *) &p ## MultiTexCoord3fvARB; \
+ (d)[363] = (void *) &p ## MultiTexCoord3iARB; \
+ (d)[364] = (void *) &p ## MultiTexCoord3ivARB; \
+ (d)[365] = (void *) &p ## MultiTexCoord3sARB; \
+ (d)[366] = (void *) &p ## MultiTexCoord3svARB; \
+ (d)[367] = (void *) &p ## MultiTexCoord4dARB; \
+ (d)[368] = (void *) &p ## MultiTexCoord4dvARB; \
+ (d)[369] = (void *) &p ## MultiTexCoord4fARB; \
+ (d)[370] = (void *) &p ## MultiTexCoord4fvARB; \
+ (d)[371] = (void *) &p ## MultiTexCoord4iARB; \
+ (d)[372] = (void *) &p ## MultiTexCoord4ivARB; \
+ (d)[373] = (void *) &p ## MultiTexCoord4sARB; \
+ (d)[374] = (void *) &p ## MultiTexCoord4svARB; \
+ (d)[375] = (void *) &p ## LoadTransposeMatrixdARB; \
+ (d)[376] = (void *) &p ## LoadTransposeMatrixfARB; \
+ (d)[377] = (void *) &p ## MultTransposeMatrixdARB; \
+ (d)[378] = (void *) &p ## MultTransposeMatrixfARB; \
+ (d)[379] = (void *) &p ## CompressedTexImage3DARB; \
+ (d)[380] = (void *) &p ## CompressedTexImage2DARB; \
+ (d)[381] = (void *) &p ## CompressedTexImage1DARB; \
+ (d)[382] = (void *) &p ## CompressedTexSubImage3DARB; \
+ (d)[383] = (void *) &p ## CompressedTexSubImage2DARB; \
+ (d)[384] = (void *) &p ## CompressedTexSubImage1DARB; \
+ (d)[385] = (void *) &p ## GetCompressedTexImageARB; \
+ (d)[386] = (void *) &p ## SecondaryColor3bEXT; \
+ (d)[387] = (void *) &p ## SecondaryColor3bvEXT; \
+ (d)[388] = (void *) &p ## SecondaryColor3dEXT; \
+ (d)[389] = (void *) &p ## SecondaryColor3dvEXT; \
+ (d)[390] = (void *) &p ## SecondaryColor3fEXT; \
+ (d)[391] = (void *) &p ## SecondaryColor3fvEXT; \
+ (d)[392] = (void *) &p ## SecondaryColor3iEXT; \
+ (d)[393] = (void *) &p ## SecondaryColor3ivEXT; \
+ (d)[394] = (void *) &p ## SecondaryColor3sEXT; \
+ (d)[395] = (void *) &p ## SecondaryColor3svEXT; \
+ (d)[396] = (void *) &p ## SecondaryColor3ubEXT; \
+ (d)[397] = (void *) &p ## SecondaryColor3ubvEXT; \
+ (d)[398] = (void *) &p ## SecondaryColor3uiEXT; \
+ (d)[399] = (void *) &p ## SecondaryColor3uivEXT; \
+ (d)[400] = (void *) &p ## SecondaryColor3usEXT; \
+ (d)[401] = (void *) &p ## SecondaryColor3usvEXT; \
+ (d)[402] = (void *) &p ## SecondaryColorPointerEXT; \
+ (d)[403] = (void *) &p ## VertexArrayRangeNV; \
+ (d)[405] = (void *) &p ## DrawRangeElements; \
+ (d)[406] = (void *) &p ## ColorTable; \
+ (d)[407] = (void *) &p ## ColorTableParameterfv; \
+ (d)[408] = (void *) &p ## ColorTableParameteriv; \
+ (d)[409] = (void *) &p ## CopyColorTable; \
+ (d)[410] = (void *) &p ## GetColorTable; \
+ (d)[411] = (void *) &p ## GetColorTableParameterfv; \
+ (d)[412] = (void *) &p ## GetColorTableParameteriv; \
+ (d)[413] = (void *) &p ## ColorSubTable; \
+ (d)[414] = (void *) &p ## CopyColorSubTable; \
+ (d)[415] = (void *) &p ## ConvolutionFilter1D; \
+ (d)[416] = (void *) &p ## ConvolutionFilter2D; \
+ (d)[417] = (void *) &p ## ConvolutionParameterf; \
+ (d)[418] = (void *) &p ## ConvolutionParameterfv; \
+ (d)[419] = (void *) &p ## ConvolutionParameteri; \
+ (d)[420] = (void *) &p ## ConvolutionParameteriv; \
+ (d)[421] = (void *) &p ## CopyConvolutionFilter1D; \
+ (d)[422] = (void *) &p ## CopyConvolutionFilter2D; \
+ (d)[423] = (void *) &p ## GetConvolutionFilter; \
+ (d)[424] = (void *) &p ## GetConvolutionParameterfv; \
+ (d)[425] = (void *) &p ## GetConvolutionParameteriv; \
+ (d)[426] = (void *) &p ## GetSeparableFilter; \
+ (d)[427] = (void *) &p ## SeparableFilter2D; \
+ (d)[428] = (void *) &p ## GetHistogram; \
+ (d)[429] = (void *) &p ## GetHistogramParameterfv; \
+ (d)[430] = (void *) &p ## GetHistogramParameteriv; \
+ (d)[431] = (void *) &p ## GetMinmax; \
+ (d)[432] = (void *) &p ## GetMinmaxParameterfv; \
+ (d)[433] = (void *) &p ## GetMinmaxParameteriv; \
+ (d)[434] = (void *) &p ## Histogram; \
+ (d)[435] = (void *) &p ## Minmax; \
+ (d)[436] = (void *) &p ## ResetHistogram; \
+ (d)[437] = (void *) &p ## ResetMinmax; \
+ (d)[438] = (void *) &p ## TexImage3D; \
+ (d)[439] = (void *) &p ## TexSubImage3D; \
+ (d)[440] = (void *) &p ## CopyTexSubImage3D; \
+ (d)[441] = (void *) &p ## CombinerParameterfvNV; \
+ (d)[442] = (void *) &p ## CombinerParameterfNV; \
+ (d)[443] = (void *) &p ## CombinerParameterivNV; \
+ (d)[444] = (void *) &p ## CombinerParameteriNV; \
+ (d)[445] = (void *) &p ## CombinerInputNV; \
+ (d)[446] = (void *) &p ## CombinerOutputNV; \
+ (d)[447] = (void *) &p ## FinalCombinerInputNV; \
+ (d)[448] = (void *) &p ## GetCombinerInputParameterfvNV; \
+ (d)[449] = (void *) &p ## GetCombinerInputParameterivNV; \
+ (d)[450] = (void *) &p ## GetCombinerOutputParameterfvNV; \
+ (d)[451] = (void *) &p ## GetCombinerOutputParameterivNV; \
+ (d)[452] = (void *) &p ## GetFinalCombinerInputParameterfvNV; \
+ (d)[453] = (void *) &p ## GetFinalCombinerInputParameterivNV; \
+ (d)[458] = (void *) &p ## BlendEquationSeparateEXT; \
+ (d)[459] = (void *) &p ## SampleCoverageARB; \
+ (d)[471] = (void *) &p ## BindProgramNV; \
+ (d)[472] = (void *) &p ## DeleteProgramsNV; \
+ (d)[473] = (void *) &p ## GenProgramsNV; \
+ (d)[474] = (void *) &p ## IsProgramNV; \
+ (d)[475] = (void *) &p ## VertexAttrib1sNV; \
+ (d)[476] = (void *) &p ## VertexAttrib1fNV; \
+ (d)[477] = (void *) &p ## VertexAttrib1dNV; \
+ (d)[478] = (void *) &p ## VertexAttrib2sNV; \
+ (d)[479] = (void *) &p ## VertexAttrib2fNV; \
+ (d)[480] = (void *) &p ## VertexAttrib2dNV; \
+ (d)[481] = (void *) &p ## VertexAttrib3sNV; \
+ (d)[482] = (void *) &p ## VertexAttrib3fNV; \
+ (d)[483] = (void *) &p ## VertexAttrib3dNV; \
+ (d)[484] = (void *) &p ## VertexAttrib4sNV; \
+ (d)[485] = (void *) &p ## VertexAttrib4fNV; \
+ (d)[486] = (void *) &p ## VertexAttrib4dNV; \
+ (d)[487] = (void *) &p ## VertexAttrib4ubNV; \
+ (d)[488] = (void *) &p ## VertexAttrib1svNV; \
+ (d)[489] = (void *) &p ## VertexAttrib1fvNV; \
+ (d)[490] = (void *) &p ## VertexAttrib1dvNV; \
+ (d)[491] = (void *) &p ## VertexAttrib2svNV; \
+ (d)[492] = (void *) &p ## VertexAttrib2fvNV; \
+ (d)[493] = (void *) &p ## VertexAttrib2dvNV; \
+ (d)[494] = (void *) &p ## VertexAttrib3svNV; \
+ (d)[495] = (void *) &p ## VertexAttrib3fvNV; \
+ (d)[496] = (void *) &p ## VertexAttrib3dvNV; \
+ (d)[497] = (void *) &p ## VertexAttrib4bvARB; \
+ (d)[498] = (void *) &p ## VertexAttrib4svNV; \
+ (d)[498] = (void *) &p ## VertexAttrib4NsvARB; \
+ (d)[499] = (void *) &p ## VertexAttrib4ivARB; \
+ (d)[500] = (void *) &p ## VertexAttrib4ubvNV; \
+ (d)[500] = (void *) &p ## VertexAttrib4ubvARB; \
+ (d)[501] = (void *) &p ## VertexAttrib4usvARB; \
+ (d)[502] = (void *) &p ## VertexAttrib4uivARB; \
+ (d)[503] = (void *) &p ## VertexAttrib4fvNV; \
+ (d)[504] = (void *) &p ## VertexAttrib4dvNV; \
+ (d)[505] = (void *) &p ## VertexAttrib4NbvARB; \
+ (d)[507] = (void *) &p ## VertexAttrib4NivARB; \
+ (d)[509] = (void *) &p ## VertexAttrib4NusvARB; \
+ (d)[510] = (void *) &p ## VertexAttrib4NuivARB; \
+ (d)[511] = (void *) &p ## VertexAttribPointerARB; \
+ (d)[512] = (void *) &p ## EnableVertexAttribArrayARB; \
+ (d)[513] = (void *) &p ## DisableVertexAttribArrayARB; \
+ (d)[514] = (void *) &p ## GetVertexAttribdvNV; \
+ (d)[515] = (void *) &p ## GetVertexAttribfvNV; \
+ (d)[516] = (void *) &p ## GetVertexAttribivNV; \
+ (d)[517] = (void *) &p ## GetVertexAttribPointervNV; \
+ (d)[518] = (void *) &p ## ProgramEnvParameter4dARB; \
+ (d)[519] = (void *) &p ## ProgramEnvParameter4dvARB; \
+ (d)[520] = (void *) &p ## ProgramEnvParameter4fARB; \
+ (d)[521] = (void *) &p ## ProgramEnvParameter4fvARB; \
+ (d)[522] = (void *) &p ## ProgramLocalParameter4dARB; \
+ (d)[523] = (void *) &p ## ProgramLocalParameter4dvARB; \
+ (d)[524] = (void *) &p ## ProgramLocalParameter4fARB; \
+ (d)[525] = (void *) &p ## ProgramLocalParameter4fvARB; \
+ (d)[526] = (void *) &p ## GetProgramEnvParameterdvARB; \
+ (d)[527] = (void *) &p ## GetProgramEnvParameterfvARB; \
+ (d)[528] = (void *) &p ## GetProgramLocalParameterdvARB; \
+ (d)[529] = (void *) &p ## GetProgramLocalParameterfvARB; \
+ (d)[530] = (void *) &p ## ProgramStringARB; \
+ (d)[531] = (void *) &p ## GetProgramStringARB; \
+ (d)[532] = (void *) &p ## GetProgramivARB; \
+ (d)[540] = (void *) &p ## PointParameterfEXT; \
+ (d)[541] = (void *) &p ## PointParameterfvEXT; \
+ (d)[542] = (void *) &p ## PointParameteriNV; \
+ (d)[543] = (void *) &p ## PointParameterivNV; \
+ (d)[544] = (void *) &p ## FogCoordfEXT; \
+ (d)[545] = (void *) &p ## FogCoordfvEXT; \
+ (d)[546] = (void *) &p ## FogCoorddEXT; \
+ (d)[547] = (void *) &p ## FogCoorddvEXT; \
+ (d)[548] = (void *) &p ## FogCoordPointerEXT; \
+ (d)[567] = (void *) &p ## MultiDrawArraysEXT; \
+ (d)[568] = (void *) &p ## MultiDrawElementsEXT; \
+ (d)[569] = (void *) &p ## WindowPos2dMESA; \
+ (d)[570] = (void *) &p ## WindowPos2dvMESA; \
+ (d)[571] = (void *) &p ## WindowPos2fMESA; \
+ (d)[572] = (void *) &p ## WindowPos2fvMESA; \
+ (d)[573] = (void *) &p ## WindowPos2iMESA; \
+ (d)[574] = (void *) &p ## WindowPos2ivMESA; \
+ (d)[575] = (void *) &p ## WindowPos2sMESA; \
+ (d)[576] = (void *) &p ## WindowPos2svMESA; \
+ (d)[577] = (void *) &p ## WindowPos3dMESA; \
+ (d)[578] = (void *) &p ## WindowPos3dvMESA; \
+ (d)[579] = (void *) &p ## WindowPos3fMESA; \
+ (d)[580] = (void *) &p ## WindowPos3fvMESA; \
+ (d)[581] = (void *) &p ## WindowPos3iMESA; \
+ (d)[582] = (void *) &p ## WindowPos3ivMESA; \
+ (d)[583] = (void *) &p ## WindowPos3sMESA; \
+ (d)[584] = (void *) &p ## WindowPos3svMESA; \
+ (d)[585] = (void *) &p ## ActiveStencilFaceEXT; \
+} while (0)
diff --git a/nx-X11/lib/GL/apple/dri_driver.c b/nx-X11/lib/GL/apple/dri_driver.c
new file mode 100644
index 000000000..ce8b0736a
--- /dev/null
+++ b/nx-X11/lib/GL/apple/dri_driver.c
@@ -0,0 +1,1141 @@
+/* $XFree86: xc/lib/GL/apple/dri_driver.c,v 1.2 2003/10/31 02:22:12 torrey Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright (c) 2002 Apple Computer, Inc.
+Copyright (c) 2004 Torrey T. Lyons
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Original Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Brian E. Paul <brian@precisioninsight.com>
+ */
+
+/*
+ * This file follows Mesa's dri_util.c closely. The code in dri_util.c
+ * gets compiled into each of the DRI 3D drivers. A typical DRI driver,
+ * is loaded dynamically by libGL, so libGL knows nothing about the
+ * internal functions here. On Mac OS X the AppleDRI driver code is
+ * statically linked into libGL, but otherwise it tries to behave like
+ * a standard DRI driver.
+ *
+ * The functions defined here are called from the GL library via function
+ * pointers in the __DRIdisplayRec, __DRIscreenRec, __DRIcontextRec,
+ * __DRIdrawableRec structures defined in glxclient.h. Those function
+ * pointers are initialized by code in this file. The process starts when
+ * libGL calls the __driCreateScreen() function at the end of this file.
+ *
+ * The above-mentioned DRI structures have no dependencies on Mesa.
+ * Each structure instead has a generic (void *) private pointer that
+ * points to a private structure. For Mesa drivers, these private
+ * structures are the __DRIdrawablePrivateRec, __DRIcontextPrivateRec,
+ * __DRIscreenPrivateRec, and __DRIvisualPrivateRec structures defined
+ * in dri_mesaint.h. We allocate and attach those structs here in
+ * this file.
+ */
+
+
+#ifdef GLX_DIRECT_RENDERING
+
+/* These are first to ensure that Apple's GL headers are used. */
+#include <OpenGL/OpenGL.h>
+#include <OpenGL/CGLContext.h>
+
+#include <unistd.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+
+#define GLAPIENTRYP *
+#include "extutil.h"
+#include "glxclient.h"
+#include "appledri.h"
+#include "dri_driver.h"
+#include "x-list.h"
+#include "x-hash.h"
+
+/**
+ * This is used in a couple of places that call \c driMesaCreateNewDrawable.
+ */
+static const int empty_attribute_list[1] = { None };
+
+/* Context binding */
+static Bool driMesaBindContext(Display *dpy, int scrn,
+ GLXDrawable draw, GLXContext gc);
+static Bool driMesaUnbindContext(Display *dpy, int scrn,
+ GLXDrawable draw, GLXContext gc,
+ int will_rebind);
+
+/* Drawable methods */
+static void *driMesaCreateNewDrawable(__DRInativeDisplay *dpy,
+ const __GLcontextModes *modes,
+ __DRIid draw, __DRIdrawable *pdraw,
+ int renderType, const int *attrs);
+static __DRIdrawable *driMesaGetDrawable(__DRInativeDisplay *dpy,
+ GLXDrawable draw,
+ void *screenPrivate);
+static void driMesaSwapBuffers(__DRInativeDisplay *dpy, void *drawPrivate);
+static void driMesaDestroyDrawable(__DRInativeDisplay *dpy, void *drawPrivate);
+
+/* Context methods */
+static void *driMesaCreateContext(Display *dpy, XVisualInfo *vis, void *shared,
+ __DRIcontext *pctx);
+static void driMesaDestroyContext(__DRInativeDisplay *dpy, int scrn,
+ void *screenPrivate);
+
+/* Screen methods */
+static void *driMesaCreateScreen(__DRInativeDisplay *dpy, int scrn,
+ __DRIscreen *psc, int numConfigs,
+ __GLXvisualConfig *config);
+static void driMesaDestroyScreen(__DRInativeDisplay *dpy, int scrn,
+ void *screenPrivate);
+
+static void driMesaCreateSurface(Display *dpy, int scrn,
+ __DRIdrawablePrivate *pdp);
+
+static void unwrap_context(__DRIcontextPrivate *pcp);
+static void wrap_context(__DRIcontextPrivate *pcp);
+
+extern const CGLContextObj XAppleDRIGetIndirectContext(void);
+
+/*****************************************************************/
+
+/* Maintain a list of drawables */
+
+static inline Bool
+__driMesaAddDrawable(x_hash_table *drawHash, __DRIdrawable *pdraw)
+{
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
+
+ assert(drawHash != NULL);
+
+ x_hash_table_insert(drawHash, (void *) pdp->draw, pdraw);
+
+ return GL_TRUE;
+}
+
+static inline __DRIdrawable *
+__driMesaFindDrawable(x_hash_table *drawHash, GLXDrawable draw)
+{
+ if (drawHash == NULL)
+ return NULL;
+
+ return x_hash_table_lookup(drawHash, (void *) draw, NULL);
+}
+
+struct find_by_uid_closure {
+ unsigned int uid;
+ __DRIdrawable *ret;
+};
+
+static void
+find_by_uid_cb(void *k, void *v, void *data)
+{
+ __DRIdrawable *pdraw = v;
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
+ struct find_by_uid_closure *c = data;
+
+ if (pdp->uid == c->uid)
+ c->ret = pdraw;
+}
+
+static __DRIdrawable *
+__driMesaFindDrawableByUID(x_hash_table *drawHash, unsigned int uid)
+{
+ struct find_by_uid_closure c;
+
+ c.uid = uid;
+ c.ret = NULL;
+ x_hash_table_foreach(drawHash, find_by_uid_cb, &c);
+
+ return c.ret;
+}
+
+static inline void
+__driMesaRemoveDrawable(x_hash_table *drawHash, __DRIdrawable *pdraw)
+{
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
+
+ if (drawHash == NULL)
+ return;
+
+ x_hash_table_remove(drawHash, (void *) pdp->draw);
+}
+
+static Bool __driMesaWindowExistsFlag;
+
+static int __driMesaWindowExistsErrorHandler(Display *dpy, XErrorEvent *xerr)
+{
+ if (xerr->error_code == BadWindow) {
+ __driMesaWindowExistsFlag = GL_FALSE;
+ }
+ return 0;
+}
+
+static Bool __driMesaWindowExists(Display *dpy, GLXDrawable draw)
+{
+ XWindowAttributes xwa;
+ int (*oldXErrorHandler)(Display *, XErrorEvent *);
+
+ __driMesaWindowExistsFlag = GL_TRUE;
+ oldXErrorHandler = XSetErrorHandler(__driMesaWindowExistsErrorHandler);
+ XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */
+ XSetErrorHandler(oldXErrorHandler);
+ return __driMesaWindowExistsFlag;
+}
+
+static void __driMesaCollectCallback(void *k, void *v, void *data)
+{
+ GLXDrawable draw = (GLXDrawable) k;
+ __DRIdrawable *pdraw = v;
+ x_list **todelete = data;
+
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
+ Display *dpy;
+
+ dpy = pdp->driScreenPriv->display;
+ XSync(dpy, GL_FALSE);
+ if (!pdp->destroyed && !__driMesaWindowExists(dpy, draw)) {
+ /* Destroy the local drawable data in the hash table, if the
+ drawable no longer exists in the Xserver */
+ pdp->destroyed = TRUE;
+ *todelete = x_list_prepend(*todelete, pdraw);
+ }
+}
+
+/* pdp->mutex is held. */
+static void __driMesaGarbageCollectDrawables(void *drawHash)
+{
+ __DRIdrawable *pdraw;
+ __DRIdrawablePrivate *pdp;
+ Display *dpy;
+ x_list *todelete = NULL, *node;
+
+ x_hash_table_foreach(drawHash, __driMesaCollectCallback, &todelete);
+
+ for (node = todelete; node != NULL; node = node->next)
+ {
+ pdraw = node->data;
+ pdp = (__DRIdrawablePrivate *)pdraw->private;
+ dpy = pdp->driScreenPriv->display;
+
+ /* Destroy the local drawable data in the hash table, if the
+ drawable no longer exists in the Xserver */
+
+ __driMesaRemoveDrawable(drawHash, pdraw);
+ (*pdraw->destroyDrawable)(dpy, pdraw->private);
+ Xfree(pdraw);
+ }
+
+ x_list_free(todelete);
+}
+
+/*****************************************************************/
+
+/* returns with psp->mutex locked if successful. */
+static Bool
+driMesaFindDrawableByUID(Display *dpy,unsigned int uid,
+ __DRIscreenPrivate **psp_ret,
+ __DRIdrawablePrivate **pdp_ret)
+{
+ __DRIscreen *pDRIScreen;
+ __DRIscreenPrivate *psp;
+ __DRIdrawable *pdraw;
+ int scrn;
+
+ for (scrn = 0; scrn < ScreenCount(dpy); scrn++)
+ {
+ if (!(pDRIScreen = __glXFindDRIScreen(dpy, scrn))) {
+ /* ERROR!!! */
+ return FALSE;
+ } else if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
+ /* ERROR!!! */
+ return FALSE;
+ }
+
+ xmutex_lock(psp->mutex);
+
+ pdraw = __driMesaFindDrawableByUID(psp->drawHash, uid);
+ if (pdraw != NULL) {
+ *psp_ret = psp;
+ *pdp_ret = pdraw->private;
+ return TRUE;
+ };
+
+ xmutex_unlock(psp->mutex);
+ }
+
+ return FALSE;
+}
+
+static void
+unbind_context(__DRIcontextPrivate *pcp)
+{
+ /* Unbind the context from its old drawable. */
+
+ if (pcp->driDrawablePriv != NULL)
+ {
+ if (pcp->next != NULL)
+ pcp->next->prev = pcp->prev;
+ if (pcp->prev != NULL)
+ pcp->prev->next = pcp->next;
+
+ if (pcp->driDrawablePriv->driContextPriv == pcp)
+ pcp->driDrawablePriv->driContextPriv = pcp->next;
+
+ pcp->driDrawablePriv = NULL;
+ pcp->prev = pcp->next = NULL;
+ }
+
+ if (pcp->surface_id != 0)
+ {
+ pcp->surface_id = 0;
+ pcp->pending_clear = TRUE;
+ }
+}
+
+static void
+unbind_drawable(__DRIdrawablePrivate *pdp)
+{
+ __DRIcontextPrivate *pcp, *next;
+
+ for (pcp = pdp->driContextPriv; pcp != NULL; pcp = next)
+ {
+ next = pcp->next;
+ unbind_context(pcp);
+ }
+}
+
+static void
+update_context(__DRIcontextPrivate *pcp)
+{
+ if (pcp->pending_clear)
+ {
+ CGLClearDrawable(pcp->ctx);
+ pcp->pending_clear = FALSE;
+ }
+
+ if (pcp->pending_update && pcp->surface_id != 0)
+ {
+ xp_update_gl_context(pcp->ctx);
+ pcp->pending_update = FALSE;
+ }
+}
+
+static Bool driMesaUnbindContext(Display *dpy, int scrn,
+ GLXDrawable draw, GLXContext gc,
+ int will_rebind)
+{
+ __DRIscreen *pDRIScreen;
+// __DRIdrawable *pdraw;
+ __DRIcontextPrivate *pcp;
+ __DRIscreenPrivate *psp;
+ __DRIdrawablePrivate *pdp;
+
+ /*
+ ** Assume error checking is done properly in glXMakeCurrent before
+ ** calling driMesaUnbindContext.
+ */
+
+ if (gc == NULL || draw == None) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ if (!(pDRIScreen = __glXFindDRIScreen(dpy, scrn))) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ } else if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ xmutex_lock(psp->mutex);
+
+ pcp = (__DRIcontextPrivate *)gc->driContext.private;
+
+ pdp = pcp->driDrawablePriv;
+ if (pdp == NULL) {
+ /* ERROR!!! */
+ xmutex_unlock(psp->mutex);
+ return GL_FALSE;
+ }
+
+ /* Put this thread back into normal (indirect) dispatch mode. */
+ CGLSetCurrentContext(XAppleDRIGetIndirectContext());
+ pcp->thread_id = 0;
+
+ /* Lazily unbind the drawable from the context */
+ unbind_context(pcp);
+
+ if (pdp->refcount == 0) {
+ /* ERROR!!! */
+ xmutex_unlock(psp->mutex);
+ return GL_FALSE;
+ } else if (--pdp->refcount == 0) {
+#if 0
+ /*
+ ** NOT_DONE: When a drawable is unbound from one direct
+ ** rendering context and then bound to another, we do not want
+ ** to destroy the drawable data structure each time only to
+ ** recreate it immediatly afterwards when binding to the next
+ ** context. This also causes conflicts with caching of the
+ ** drawable stamp.
+ **
+ ** In addition, we don't destroy the drawable here since Mesa
+ ** keeps private data internally (e.g., software accumulation
+ ** buffers) that should not be destroyed unless the client
+ ** explicitly requests that the window be destroyed.
+ **
+ ** When GLX 1.3 is integrated, the create and destroy drawable
+ ** functions will have user level counterparts and the memory
+ ** will be able to be recovered.
+ **
+ ** Below is an example of what needs to go into the destroy
+ ** drawable routine to support GLX 1.3.
+ */
+ __driMesaRemoveDrawable(psp->drawHash, pdraw);
+ (*pdraw->destroyDrawable)(dpy, pdraw->private);
+ Xfree(pdraw);
+#endif
+ }
+
+ xmutex_unlock(psp->mutex);
+ return GL_TRUE;
+}
+
+static Bool driMesaBindContext(Display *dpy, int scrn,
+ GLXDrawable draw, GLXContext gc)
+{
+ __DRIscreen *pDRIScreen;
+ const __GLcontextModes *modes;
+ __DRIdrawable *pdraw;
+ __DRIdrawablePrivate *pdp;
+ __DRIscreenPrivate *psp;
+ __DRIcontextPrivate *pcp;
+
+ /*
+ ** Assume error checking is done properly in glXMakeCurrent before
+ ** calling driMesaBindContext.
+ */
+
+ if (gc == NULL || draw == None) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ if (!(pDRIScreen = __glXFindDRIScreen(dpy, scrn))) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ } else if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ modes = gc->driContext.mode;
+
+ if ( modes == NULL ) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ xmutex_lock(psp->mutex);
+
+ pdraw = __driMesaFindDrawable(psp->drawHash, draw);
+ if (!pdraw) {
+ /* Allocate a new drawable */
+ pdraw = (__DRIdrawable *)Xmalloc(sizeof(__DRIdrawable));
+ if (!pdraw) {
+ /* ERROR!!! */
+ xmutex_unlock(psp->mutex);
+ return GL_FALSE;
+ }
+
+ /* Create a new drawable */
+ pdraw->private = driMesaCreateNewDrawable(dpy, modes, draw, pdraw,
+ GLX_WINDOW_BIT,
+ empty_attribute_list);
+ if (!pdraw->private) {
+ /* ERROR!!! */
+ Xfree(pdraw);
+ xmutex_unlock(psp->mutex);
+ return GL_FALSE;
+ }
+
+ /* Add pdraw to drawable list */
+ if (!__driMesaAddDrawable(psp->drawHash, pdraw)) {
+ /* ERROR!!! */
+ (*pdraw->destroyDrawable)(dpy, pdraw->private);
+ Xfree(pdraw);
+ xmutex_unlock(psp->mutex);
+ return GL_FALSE;
+ }
+ }
+
+ pdp = (__DRIdrawablePrivate *)pdraw->private;
+ pcp = (__DRIcontextPrivate *)gc->driContext.private;
+
+ if (pdp->surface_id == 0)
+ {
+ /* Surface got destroyed. Try to create a new one. */
+
+ driMesaCreateSurface(dpy, scrn, pdp);
+ }
+
+ unbind_context(pcp);
+
+ /* Bind the drawable to the context */
+ pcp->driDrawablePriv = pdp;
+ pcp->prev = NULL;
+ pcp->next = pdp->driContextPriv;
+ pdp->driContextPriv = pcp;
+ pdp->refcount++;
+
+ /* And the physical surface to the physical context */
+ if (pcp->surface_id != pdp->surface_id)
+ {
+ pcp->surface_id = 0;
+
+ /* Attaching the drawable sets the default viewport. But we don't
+ want to catch that call to glViewport in our wrappers. */
+ unwrap_context(pcp);
+
+ if (pdp->surface_id == 0)
+ CGLClearDrawable(pcp->ctx);
+ else if (xp_attach_gl_context(pcp->ctx, pdp->surface_id) == Success)
+ pcp->surface_id = pdp->surface_id;
+ else
+ fprintf(stderr, "failed to bind to surface\n");
+
+ wrap_context(pcp);
+
+ pcp->pending_clear = FALSE;
+ pcp->pending_update = FALSE;
+ }
+ else if (pcp->pending_clear)
+ {
+ CGLClearDrawable(pcp->ctx);
+ pcp->pending_clear = FALSE;
+ }
+
+ /* Activate the CGL context and remember which thread it's current for. */
+ CGLSetCurrentContext(pcp->ctx);
+ pcp->thread_id = xthread_self();
+
+ xmutex_unlock(psp->mutex);
+ return GL_TRUE;
+}
+
+/*****************************************************************/
+
+static xp_client_id
+get_client_id(void)
+{
+ static xp_client_id id;
+
+ if (id == 0)
+ {
+ if (xp_init(XP_IN_BACKGROUND) != Success
+ || xp_get_client_id(&id) != Success)
+ {
+ return 0;
+ }
+ }
+
+ return id;
+}
+
+static void driMesaCreateSurface(Display *dpy, int scrn,
+ __DRIdrawablePrivate *pdp)
+{
+ xp_client_id client_id;
+ unsigned int key[2];
+
+ pdp->surface_id = 0;
+ pdp->uid = 0;
+
+ client_id = get_client_id();
+ if (client_id == 0)
+ return;
+
+ if (XAppleDRICreateSurface(dpy, scrn, pdp->draw,
+ client_id, key, &pdp->uid))
+ {
+ xp_import_surface(key, &pdp->surface_id);
+ }
+}
+
+/**
+ * This is called via __DRIscreenRec's createNewDrawable pointer.
+ */
+static void *driMesaCreateNewDrawable(__DRInativeDisplay *dpy,
+ const __GLcontextModes *modes,
+ __DRIid draw,
+ __DRIdrawable *pdraw,
+ int renderType,
+ const int *attrs)
+{
+ __DRIscreen * const pDRIScreen = __glXFindDRIScreen(dpy, modes->screen);
+ __DRIscreenPrivate *psp;
+ __DRIdrawablePrivate *pdp;
+
+
+ pdraw->private = NULL;
+
+ /* Since pbuffers are not yet supported, no drawable attributes are
+ * supported either.
+ */
+ (void) attrs;
+
+ if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
+ return NULL;
+ }
+
+ pdp = (__DRIdrawablePrivate *)Xmalloc(sizeof(__DRIdrawablePrivate));
+ if (!pdp) {
+ return NULL;
+ }
+
+ pdp->draw = draw;
+ pdp->refcount = 0;
+ pdp->surface_id = 0;
+ pdp->uid = 0;
+ pdp->destroyed = FALSE;
+
+ psp = (__DRIscreenPrivate *)pDRIScreen->private;
+ pdp->driScreenPriv = psp;
+ pdp->driContextPriv = NULL;
+
+ driMesaCreateSurface(dpy, modes->screen, pdp);
+ if (pdp->surface_id == 0) {
+ Xfree(pdp);
+ return NULL;
+ }
+
+ pdraw->private = pdp;
+ pdraw->destroyDrawable = driMesaDestroyDrawable;
+ pdraw->swapBuffers = driMesaSwapBuffers; /* called by glXSwapBuffers() */
+
+#if 0
+ /* We don't support these yet. */
+ if ( driCompareGLXAPIVersion( 20030317 ) >= 0 ) {
+ pdraw->getSBC = driGetSBC;
+ pdraw->waitForSBC = driWaitForSBC;
+ pdraw->waitForMSC = driWaitForMSC;
+ pdraw->swapBuffersMSC = driSwapBuffersMSC;
+ pdraw->frameTracking = NULL;
+ pdraw->queryFrameTracking = driQueryFrameTracking;
+
+ /* This special default value is replaced with the configured
+ * default value when the drawable is first bound to a direct
+ * rendering context. */
+ pdraw->swap_interval = (unsigned)-1;
+ }
+#endif
+
+ return (void *) pdp;
+}
+
+static __DRIdrawable *driMesaGetDrawable(__DRInativeDisplay *dpy,
+ GLXDrawable draw,
+ void *screenPrivate)
+{
+ __DRIscreenPrivate *psp = (__DRIscreenPrivate *) screenPrivate;
+ __DRIdrawable *dri_draw;
+
+ xmutex_lock(psp->mutex);
+
+ /*
+ ** Make sure this routine returns NULL if the drawable is not bound
+ ** to a direct rendering context!
+ */
+ dri_draw = __driMesaFindDrawable(psp->drawHash, draw);
+
+ xmutex_unlock(psp->mutex);
+ return dri_draw;
+}
+
+static void driMesaSwapBuffers(__DRInativeDisplay *dpy, void *drawPrivate)
+{
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *) drawPrivate;
+ __DRIcontextPrivate *pcp;
+ xthread_t self = xthread_self();
+ static Bool warned;
+
+ xmutex_lock(pdp->driScreenPriv->mutex);
+
+ /* FIXME: this is sub-optimal, since we may not always find a context
+ bound to the given drawable on this thread. */
+
+ for (pcp = pdp->driContextPriv; pcp != NULL; pcp = pcp->next)
+ {
+ if (pcp->thread_id == self || pcp->thread_id == 0)
+ break;
+ }
+
+ if (pcp != NULL)
+ {
+ CGLFlushDrawable(pcp->ctx);
+ }
+ else
+ {
+ if (!warned) {
+ fprintf(stderr, "glXSwapBuffers: no context for this drawable\n");
+ warned = TRUE;
+ }
+ }
+
+ xmutex_unlock(pdp->driScreenPriv->mutex);
+}
+
+/* pdp->mutex is held. */
+static void driMesaDestroyDrawable(__DRInativeDisplay *dpy, void *drawPrivate)
+{
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)drawPrivate;
+
+ if (pdp) {
+ unbind_drawable(pdp);
+ if (pdp->surface_id != 0) {
+ xp_destroy_surface(pdp->surface_id);
+ pdp->surface_id = 0;
+ }
+ if (!pdp->destroyed) {
+ /* don't try to destroy an already destroyed surface. */
+ XAppleDRIDestroySurface(dpy, pdp->driScreenPriv->myNum, pdp->draw);
+ }
+ Xfree(pdp);
+ }
+}
+
+/*****************************************************************/
+
+static CGLPixelFormatObj
+driCreatePixelFormat(Display *dpy, __DRIscreenPrivate *psp,
+ XVisualInfo *visinfo, __GLXvisualConfig *config)
+{
+ int i;
+ CGLPixelFormatAttribute attr[64]; // currently uses max of 30
+ CGLPixelFormatObj result;
+ long n_formats;
+
+ i = 0;
+
+ if (!config->rgba)
+ return NULL;
+
+ if (config->stereo)
+ attr[i++] = kCGLPFAStereo;
+
+ if (config->doubleBuffer)
+ attr[i++] = kCGLPFADoubleBuffer;
+
+ attr[i++] = kCGLPFAColorSize;
+ attr[i++] = config->redSize + config->greenSize + config->blueSize;
+ attr[i++] = kCGLPFAAlphaSize;
+ attr[i++] = 1; /* FIXME: ignoring config->alphaSize which is always 0 */
+
+ if (config->accumRedSize + config->accumGreenSize
+ + config->accumBlueSize + config->accumAlphaSize > 0)
+ {
+ attr[i++] = kCGLPFAAccumSize;
+ attr[i++] = (config->accumRedSize + config->accumGreenSize
+ + config->accumBlueSize + config->accumAlphaSize);
+ }
+
+ if (config->depthSize > 0) {
+ attr[i++] = kCGLPFADepthSize;
+ attr[i++] = config->depthSize;
+ }
+
+ if (config->stencilSize > 0) {
+ attr[i++] = kCGLPFAStencilSize;
+ attr[i++] = config->stencilSize;
+ }
+
+ if (config->auxBuffers > 0) {
+ attr[i++] = kCGLPFAAuxBuffers;
+ attr[i++] = config->auxBuffers;
+ }
+
+ /* FIXME: things we don't handle: color/alpha masks, level,
+ visualrating, transparentFoo */
+
+ attr[i++] = 0;
+
+ result = NULL;
+ CGLChoosePixelFormat(attr, &result, &n_formats);
+
+ return result;
+}
+
+static void *driMesaCreateContext(Display *dpy, XVisualInfo *vis, void *shared,
+ __DRIcontext *pctx)
+{
+ __DRIscreen *pDRIScreen;
+ __DRIcontextPrivate *pcp;
+ __DRIcontextPrivate *pshare = (__DRIcontextPrivate *)shared;
+ __DRIscreenPrivate *psp;
+ int i;
+
+ if (!(pDRIScreen = __glXFindDRIScreen(dpy, vis->screen))) {
+ /* ERROR!!! */
+ return NULL;
+ } else if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
+ /* ERROR!!! */
+ return NULL;
+ }
+
+ /* Create the hash table */
+ if (!psp->drawHash) {
+ xmutex_lock(psp->mutex);
+ if (!psp->drawHash)
+ psp->drawHash = x_hash_table_new(NULL, NULL, NULL, NULL);
+ xmutex_unlock(psp->mutex);
+ }
+
+ pcp = (__DRIcontextPrivate *)Xmalloc(sizeof(__DRIcontextPrivate));
+ if (!pcp) {
+ return NULL;
+ }
+
+ pcp->display = dpy;
+ pcp->driScreenPriv = psp;
+ pcp->driDrawablePriv = NULL;
+
+ pcp->ctx = NULL;
+ pcp->surface_id = 0;
+
+ pcp->pending_clear = FALSE;
+ pcp->pending_update = FALSE;
+
+ pcp->ctx = NULL;
+ for (i = 0; pcp->ctx == NULL && i < psp->numVisuals; i++) {
+ if (psp->visuals[i].vid == vis->visualid) {
+ CGLCreateContext(psp->visuals[i].pixel_format,
+ pshare ? pshare->ctx : NULL, &pcp->ctx);
+ }
+ }
+
+ if (!pcp->ctx) {
+ Xfree(pcp);
+ return NULL;
+ }
+
+ pctx->destroyContext = driMesaDestroyContext;
+ pctx->bindContext = driMesaBindContext;
+ pctx->unbindContext = driMesaUnbindContext;
+
+ wrap_context(pcp);
+
+ xmutex_lock(psp->mutex);
+ __driMesaGarbageCollectDrawables(pcp->driScreenPriv->drawHash);
+ xmutex_unlock(psp->mutex);
+
+ return pcp;
+}
+
+static void driMesaDestroyContext(__DRInativeDisplay *dpy, int scrn,
+ void *contextPrivate)
+{
+ __DRIcontextPrivate *pcp = (__DRIcontextPrivate *) contextPrivate;
+
+ if (pcp) {
+ xmutex_lock(pcp->driScreenPriv->mutex);
+ unbind_context(pcp);
+ __driMesaGarbageCollectDrawables(pcp->driScreenPriv->drawHash);
+ xmutex_unlock(pcp->driScreenPriv->mutex);
+ CGLDestroyContext(pcp->ctx);
+ Xfree(pcp);
+ }
+}
+
+/*****************************************************************/
+
+static void *driMesaCreateScreen(__DRInativeDisplay *dpy, int scrn,
+ __DRIscreen *psc, int numConfigs,
+ __GLXvisualConfig *config)
+{
+ int directCapable, i, n;
+ __DRIscreenPrivate *psp;
+ XVisualInfo visTmpl, *visinfo;
+
+ if (!XAppleDRIQueryDirectRenderingCapable(dpy, scrn, &directCapable)) {
+ return NULL;
+ }
+
+ if (!directCapable) {
+ return NULL;
+ }
+
+ psp = (__DRIscreenPrivate *)Xmalloc(sizeof(__DRIscreenPrivate));
+ if (!psp) {
+ return NULL;
+ }
+
+ psp->mutex = xmutex_malloc();
+ if (psp->mutex != NULL) {
+ xmutex_init (psp->mutex);
+ xmutex_set_name (psp->mutex, "AppleDRI");
+ }
+ psp->display = dpy;
+ psp->myNum = scrn;
+
+#if 0
+ if (!XAppleDRIAuthConnection(dpy, scrn, magic)) {
+ Xfree(psp);
+ (void)XAppleDRICloseConnection(dpy, scrn);
+ return NULL;
+ }
+#endif
+
+ /*
+ * Allocate space for an array of visual records and initialize them.
+ */
+ psp->visuals = (__DRIvisualPrivate *)Xmalloc(numConfigs *
+ sizeof(__DRIvisualPrivate));
+ if (!psp->visuals) {
+ Xfree(psp);
+ return NULL;
+ }
+
+ visTmpl.screen = scrn;
+ visinfo = XGetVisualInfo(dpy, VisualScreenMask, &visTmpl, &n);
+ if (n != numConfigs) {
+ Xfree(psp);
+ return NULL;
+ }
+
+ psp->numVisuals = 0;
+ for (i = 0; i < numConfigs; i++, config++) {
+ psp->visuals[psp->numVisuals].vid = visinfo[i].visualid;
+ psp->visuals[psp->numVisuals].pixel_format =
+ driCreatePixelFormat(dpy, psp, &visinfo[i], config);
+ if (psp->visuals[psp->numVisuals].pixel_format != NULL) {
+ psp->numVisuals++;
+ }
+ }
+
+ XFree(visinfo);
+
+ if (psp->numVisuals == 0) {
+ /* Couldn't create any pixel formats. */
+ Xfree(psp->visuals);
+ Xfree(psp);
+ return NULL;
+ }
+
+ /* Initialize the drawHash when the first context is created */
+ psp->drawHash = NULL;
+
+ psc->destroyScreen = driMesaDestroyScreen;
+ psc->createContext = driMesaCreateContext;
+ psc->createNewDrawable = driMesaCreateNewDrawable;
+ psc->getDrawable = driMesaGetDrawable;
+
+ return (void *)psp;
+}
+
+static void driMesaDestroyScreen(__DRInativeDisplay *dpy, int scrn,
+ void *screenPrivate)
+{
+ __DRIscreenPrivate *psp = (__DRIscreenPrivate *) screenPrivate;
+
+ if (psp) {
+ //FIXME resetDriver ?
+ Xfree(psp->visuals);
+ Xfree(psp);
+ }
+}
+
+/* Note: definitely can't make any X protocol requests here. */
+static void driAppleSurfaceNotify(Display *dpy, unsigned int uid, int kind)
+{
+ __DRIscreenPrivate *psp;
+ __DRIdrawablePrivate *pdp;
+ __DRIcontextPrivate *pcp;
+
+ /* locks psp->mutex if successful. */
+ if (driMesaFindDrawableByUID(dpy, uid, &psp, &pdp))
+ {
+ xthread_t self = xthread_self();
+
+ switch (kind)
+ {
+ Bool all_safe;
+
+ case AppleDRISurfaceNotifyDestroyed:
+ xp_destroy_surface(pdp->surface_id);
+ pdp->surface_id = 0;
+
+ for (pcp = pdp->driContextPriv; pcp != NULL; pcp = pcp->next)
+ {
+ pcp->surface_id = 0;
+
+ if (pcp->thread_id == self || pcp->thread_id == 0) {
+ CGLClearDrawable(pcp->ctx);
+ pcp->pending_clear = FALSE;
+ } else
+ pcp->pending_clear = TRUE;
+ }
+ break;
+
+ case AppleDRISurfaceNotifyChanged:
+ all_safe = TRUE;
+ for (pcp = pdp->driContextPriv; pcp != NULL; pcp = pcp->next)
+ {
+ if (pcp->thread_id != 0 && pcp->thread_id != self) {
+ all_safe = FALSE;
+ break;
+ }
+ }
+ for (pcp = pdp->driContextPriv; pcp != NULL; pcp = pcp->next)
+ {
+ if (all_safe) {
+ xp_update_gl_context(pcp->ctx);
+ pcp->pending_update = FALSE;
+ } else
+ pcp->pending_update = TRUE;
+ }
+ break;
+ }
+
+ xmutex_unlock(psp->mutex);
+ }
+}
+
+/**
+ * Entrypoint function used to create a new driver-private screen structure.
+ *
+ * \param dpy Display pointer.
+ * \param scrn Index of the screen.
+ * \param psc DRI screen data (not driver private)
+ * \param numConfigs Number of visual configs pointed to by \c configs.
+ * \param config Array of GLXvisualConfigs exported by the 2D driver.
+ *
+ * \deprecated
+ * In dynamically linked drivers, this function has been replaced by
+ * \c __driCreateNewScreen.
+ */
+void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config)
+{
+ static int here_before;
+
+ if (!here_before)
+ {
+ XAppleDRISetSurfaceNotifyHandler(driAppleSurfaceNotify);
+ here_before = True;
+ }
+
+ return driMesaCreateScreen(dpy, scrn, psc, numConfigs, config);
+}
+
+void __driRegisterExtensions(void)
+{
+}
+
+__private_extern__ void XAppleDRIUseIndirectDispatch(void)
+{
+ CGLSetCurrentContext(XAppleDRIGetIndirectContext());
+}
+
+/*****************************************************************/
+
+/*
+ * Currently (Mac OS X 10.3) the only way we have of regaining control
+ * from threads calling GL and nothing else is by patching the dispatch
+ * table of the CGLContext, so that glViewport, glFlush and glFinish
+ * call us back.
+ *
+ * Since glNewList and glEndList overwrite the entire dispatch table we
+ * also need to patch those so we can restore the others.
+ *
+ * WARNING: This is not expected to work on future OS releases.
+ */
+
+#define WRAP_CGL(context, vec, fun) \
+ do { \
+ (context)->disp.vec = (context)->ctx->disp.vec; \
+ (context)->ctx->disp.vec = (fun); \
+ } while (0)
+
+#define UNWRAP_CGL(context, vec) \
+ do { \
+ (context)->ctx->disp.vec = (context)->disp.vec; \
+ } while (0)
+
+#define WRAP_BOILERPLATE \
+ GLXContext gc; \
+ __DRIcontextPrivate *pcp; \
+ gc = __glXGetCurrentContext(); \
+ if (gc == NULL || !gc->isDirect) return; \
+ pcp = (__DRIcontextPrivate *) gc->driContext.private; \
+ if (pcp == NULL) return;
+
+static void viewport_callback(GLIContext ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ WRAP_BOILERPLATE
+
+ xmutex_lock(pcp->driScreenPriv->mutex);
+ update_context(pcp);
+ xmutex_unlock(pcp->driScreenPriv->mutex);
+
+ (*pcp->disp.viewport)(ctx, x, y, width, height);
+}
+
+static void new_list_callback(GLIContext ctx, GLuint list, GLenum mode)
+{
+ WRAP_BOILERPLATE
+
+ unwrap_context(pcp);
+ (*pcp->ctx->disp.new_list)(ctx, list, mode);
+ wrap_context(pcp);
+}
+
+static void end_list_callback(GLIContext ctx)
+{
+ WRAP_BOILERPLATE
+
+ unwrap_context(pcp);
+ (*pcp->ctx->disp.end_list)(ctx);
+ wrap_context(pcp);
+}
+
+static void unwrap_context(__DRIcontextPrivate *pcp)
+{
+ UNWRAP_CGL(pcp, viewport);
+ UNWRAP_CGL(pcp, new_list);
+ UNWRAP_CGL(pcp, end_list);
+}
+
+static void wrap_context(__DRIcontextPrivate *pcp)
+{
+ WRAP_CGL(pcp, new_list, new_list_callback);
+ WRAP_CGL(pcp, end_list, end_list_callback);
+ WRAP_CGL(pcp, viewport, viewport_callback);
+}
+
+#endif /* GLX_DIRECT_RENDERING */
diff --git a/nx-X11/lib/GL/apple/dri_driver.h b/nx-X11/lib/GL/apple/dri_driver.h
new file mode 100644
index 000000000..84965786f
--- /dev/null
+++ b/nx-X11/lib/GL/apple/dri_driver.h
@@ -0,0 +1,188 @@
+/* $XFree86: xc/lib/GL/apple/dri_driver.h,v 1.1 2003/06/30 01:45:10 torrey Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Brian Paul <brian@precisioninsight.com>
+ */
+
+#ifndef _DRI_DRIVER_H_
+#define _DRI_DRIVER_H_
+
+#include "Xplugin.h"
+#include "Xthreads.h"
+#include <CoreGraphics/CoreGraphics.h>
+#include <OpenGL/OpenGL.h>
+#include <OpenGL/CGLContext.h>
+
+#ifdef GLX_DIRECT_RENDERING
+
+typedef struct __DRIdisplayPrivateRec __DRIdisplayPrivate;
+typedef struct __DRIscreenPrivateRec __DRIscreenPrivate;
+typedef struct __DRIvisualPrivateRec __DRIvisualPrivate;
+typedef struct __DRIcontextPrivateRec __DRIcontextPrivate;
+typedef struct __DRIdrawablePrivateRec __DRIdrawablePrivate;
+
+#endif /* GLX_DIRECT_RENDERING */
+
+#define DRI_MESA_VALIDATE_DRAWABLE_INFO(dpy,scrn,pDrawPriv) \
+ do { \
+ if (*(pDrawPriv->pStamp) != pDrawPriv->lastStamp) { \
+ driMesaUpdateDrawableInfo(dpy,scrn,pDrawPriv); \
+ } \
+ } while (0)
+
+struct __DRIdrawablePrivateRec {
+ /*
+ ** X's drawable ID associated with this private drawable.
+ */
+ GLXDrawable draw;
+
+ /*
+ ** Reference count for number of context's currently bound to this
+ ** drawable. Once the refcount reaches 0, the drawable can be
+ ** destroyed. This behavior will change with GLX 1.3.
+ */
+ int refcount;
+
+ xp_surface_id surface_id;
+ unsigned int uid;
+
+ /*
+ ** Pointer to contexts to which this drawable is currently bound.
+ */
+ __DRIcontextPrivate *driContextPriv;
+
+ /*
+ ** Pointer to screen on which this drawable was created.
+ */
+ __DRIscreenPrivate *driScreenPriv;
+
+ /*
+ ** Set when the drawable on the server is known to have gone away
+ */
+ unsigned int destroyed :1;
+};
+
+struct __DRIcontextPrivateRec {
+ /*
+ ** Other contexts bound to the same drawable.
+ */
+ __DRIcontextPrivate *next, *prev;
+
+ /*
+ ** Kernel context handle used to access the device lock.
+ */
+ XID contextID;
+
+ CGLContextObj ctx;
+
+ /*
+ ** Set when attached
+ */
+ xp_surface_id surface_id;
+ xthread_t thread_id;
+
+ /*
+ ** This context's display pointer.
+ */
+ Display *display;
+
+ /*
+ ** Pointer to drawable currently bound to this context.
+ */
+ __DRIdrawablePrivate *driDrawablePriv;
+
+ /*
+ ** Pointer to screen on which this context was created.
+ */
+ __DRIscreenPrivate *driScreenPriv;
+
+ /*
+ ** wrapped CGL vectors
+ */
+ struct {
+ void (*viewport)(GLIContext ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height);
+ void (*new_list)(GLIContext ctx, GLuint list, GLenum mode);
+ void (*end_list)(GLIContext ctx);
+ } disp;
+
+ unsigned int pending_update :1;
+ unsigned int pending_clear :1;
+};
+
+struct __DRIvisualPrivateRec {
+ /*
+ ** X's visual ID associated with this private visual.
+ */
+ VisualID vid;
+
+ /*
+ ** CGL object representing the visual
+ */
+ CGLPixelFormatObj pixel_format;
+};
+
+struct __DRIscreenPrivateRec {
+ /*
+ ** Display for this screen
+ */
+ Display *display;
+
+ /*
+ ** Mutex for this screen
+ */
+ xmutex_t mutex;
+
+ /*
+ ** Current screen's number
+ */
+ int myNum;
+
+ /*
+ ** Core rendering library's visuals associated with the current
+ ** screen.
+ */
+ __DRIvisualPrivate *visuals;
+ int numVisuals;
+
+ /*
+ ** Hash table to hold the drawable information for this screen.
+ */
+ void *drawHash;
+};
+
+
+extern void driMesaUpdateDrawableInfo(Display *dpy, int scrn,
+ __DRIdrawablePrivate *pdp);
+
+
+#endif /* _DRI_DRIVER_H_ */
diff --git a/nx-X11/lib/GL/apple/dri_glx.c b/nx-X11/lib/GL/apple/dri_glx.c
new file mode 100644
index 000000000..c2adc868f
--- /dev/null
+++ b/nx-X11/lib/GL/apple/dri_glx.c
@@ -0,0 +1,265 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright (c) 2002 Apple Computer, Inc.
+Copyright (c) 2004 Torrey T. Lyons
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/apple/dri_glx.c,v 1.2 2004/04/21 04:59:40 torrey Exp $ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Brian Paul <brian@precisioninsight.com>
+ *
+ */
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include <unistd.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include "extutil.h"
+#include "glxclient.h"
+#include "appledri.h"
+#include <stdio.h>
+#include "dri_glx.h"
+#include <sys/types.h>
+#include <stdarg.h>
+
+
+/* Apple OpenGL "driver" information. */
+static const char *__driAppleDriverName = "apple";
+static const int __driAppleDriverMajor = 1;
+static const int __driAppleDriverMinor = 0;
+static const int __driAppleDriverPatch = 0;
+
+
+/*
+ * printf wrappers
+ */
+
+static void InfoMessageF(const char *f, ...)
+{
+ va_list args;
+ const char *env;
+
+ if ((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) {
+ fprintf(stderr, "libGL: ");
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+ }
+}
+
+static void ErrorMessageF(const char *f, ...)
+{
+ va_list args;
+
+ if (getenv("LIBGL_DEBUG")) {
+ fprintf(stderr, "libGL error: ");
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+ }
+}
+
+
+/*
+ * Given a display pointer and screen number, determine the name of
+ * the DRI driver for the screen. (I.e. "r128", "tdfx", etc).
+ * Return True for success, False for failure.
+ */
+static Bool GetDriverName(Display *dpy, int scrNum, char **driverName)
+{
+ int directCapable;
+
+ *driverName = NULL;
+
+ if (!XAppleDRIQueryDirectRenderingCapable(dpy, scrNum, &directCapable)) {
+ ErrorMessageF("XAppleDRIQueryDirectRenderingCapable failed\n");
+ return False;
+ }
+ if (!directCapable) {
+ ErrorMessageF("XAppleDRIQueryDirectRenderingCapable returned false\n");
+ return False;
+ }
+
+ *driverName = (char *) __driAppleDriverName;
+
+ InfoMessageF("XF86DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
+ __driAppleDriverMajor, __driAppleDriverMinor,
+ __driAppleDriverPatch, *driverName, scrNum);
+
+ return True;
+}
+
+
+/*
+ * Exported function for querying the DRI driver for a given screen.
+ *
+ * The returned char pointer points to a static array that will be
+ * overwritten by subsequent calls.
+ */
+const char *glXGetScreenDriver (Display *dpy, int scrNum) {
+ static char ret[32];
+ char *driverName;
+ if (GetDriverName(dpy, scrNum, &driverName)) {
+ int len;
+ if (!driverName)
+ return NULL;
+ len = strlen (driverName);
+ if (len >= 31)
+ return NULL;
+ memcpy (ret, driverName, len+1);
+ Xfree(driverName);
+ return ret;
+ }
+ return NULL;
+}
+
+
+/*
+ * Exported function for obtaining a driver's option list (UTF-8 encoded XML).
+ *
+ * The returned char pointer points directly into the driver. Therefore
+ * it should be treated as a constant.
+ *
+ * If the driver was not found or does not support configuration NULL is
+ * returned.
+ *
+ * Note: In a standard GLX imlementation the driver remains opened after
+ * this function returns.
+ */
+const char *glXGetDriverConfig(const char *driverName) {
+ /* the apple stub driver does not support configuration */
+ return NULL;
+}
+
+
+static void driDestroyDisplay(Display *dpy, void *private)
+{
+ __DRIdisplayPrivate *pdpyp = (__DRIdisplayPrivate *)private;
+
+ if (pdpyp) {
+ Xfree(pdpyp->libraryHandles);
+ Xfree(pdpyp);
+ }
+}
+
+
+void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp)
+{
+ const int numScreens = ScreenCount(dpy);
+ __DRIdisplayPrivate *pdpyp;
+ int eventBase, errorBase;
+ int major, minor, patch;
+ int scrn;
+
+ /* Initialize these fields to NULL in case we fail.
+ * If we don't do this we may later get segfaults trying to free random
+ * addresses when the display is closed.
+ */
+ pdisp->private = NULL;
+ pdisp->destroyDisplay = NULL;
+ pdisp->createScreen = NULL;
+
+ if (!XAppleDRIQueryExtension(dpy, &eventBase, &errorBase)) {
+ return NULL;
+ }
+
+ if (!XAppleDRIQueryVersion(dpy, &major, &minor, &patch)) {
+ return NULL;
+ }
+
+ pdpyp = (__DRIdisplayPrivate *)Xmalloc(sizeof(__DRIdisplayPrivate));
+ if (!pdpyp) {
+ return NULL;
+ }
+
+ pdpyp->driMajor = major;
+ pdpyp->driMinor = minor;
+ pdpyp->driPatch = patch;
+
+ pdisp->destroyDisplay = driDestroyDisplay;
+
+ /* allocate array of pointers to createScreen funcs */
+ pdisp->createScreen = (CreateScreenFunc *) Xmalloc(numScreens * sizeof(void *));
+ if (!pdisp->createScreen)
+ return NULL;
+
+ /* allocate array of pointers to createScreen funcs */
+ pdisp->createNewScreen = (CreateNewScreenFunc *) Xmalloc(numScreens * sizeof(void *));
+ if (!pdisp->createNewScreen) {
+ Xfree(pdisp->createScreen);
+ Xfree(pdpyp);
+ return NULL;
+ }
+
+ /* allocate array of library handles */
+ pdpyp->libraryHandles = (void **) Xmalloc(numScreens * sizeof(void*));
+ if (!pdpyp->libraryHandles) {
+ Xfree(pdisp->createNewScreen);
+ Xfree(pdisp->createScreen);
+ Xfree(pdpyp);
+ return NULL;
+ }
+
+ /* we'll statically bind to the __driCreateScreen function */
+ for (scrn = 0; scrn < numScreens; scrn++) {
+ pdisp->createScreen[scrn] = __driCreateScreen;
+ pdisp->createNewScreen[scrn] = NULL;
+ pdpyp->libraryHandles[scrn] = NULL;
+ }
+
+ return (void *)pdpyp;
+}
+
+
+/*
+** Here we'll query the DRI driver for each screen and let each
+** driver register its GL extension functions. We only have to
+** do this once. But it MUST be done before we create any contexts
+** (i.e. before any dispatch tables are created) and before
+** glXGetProcAddressARB() returns.
+**
+** Currently called by glXGetProcAddress(), __glXInitialize(), and
+** __glXNewIndirectAPI().
+*/
+void
+__glXRegisterExtensions(void)
+{
+ static GLboolean alreadyCalled = GL_FALSE;
+
+ if (alreadyCalled) {
+ return;
+ }
+
+ __driRegisterExtensions ();
+
+ alreadyCalled = GL_TRUE;
+}
+
+
+#endif /* GLX_DIRECT_RENDERING */
diff --git a/nx-X11/lib/GL/apple/dri_glx.h b/nx-X11/lib/GL/apple/dri_glx.h
new file mode 100644
index 000000000..6d01b35a5
--- /dev/null
+++ b/nx-X11/lib/GL/apple/dri_glx.h
@@ -0,0 +1,67 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+/* $XFree86$ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Brian Paul <brian@precisioninsight.com>
+ *
+ */
+
+#ifndef _DRI_GLX_H_
+#define _DRI_GLX_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+struct __DRIdisplayPrivateRec {
+ /*
+ ** XFree86-DRI version information
+ */
+ int driMajor;
+ int driMinor;
+ int driPatch;
+
+ /*
+ ** Array of library handles [indexed by screen number]
+ */
+ void **libraryHandles;
+};
+
+typedef struct __DRIdisplayPrivateRec __DRIdisplayPrivate;
+typedef struct __DRIscreenPrivateRec __DRIscreenPrivate;
+typedef struct __DRIvisualPrivateRec __DRIvisualPrivate;
+typedef struct __DRIcontextPrivateRec __DRIcontextPrivate;
+typedef struct __DRIdrawablePrivateRec __DRIdrawablePrivate;
+
+extern void *__driCreateScreen (Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config);
+extern void __driRegisterExtensions (void);
+
+#endif /* GLX_DIRECT_RENDERING */
+#endif /* _DRI_GLX_H_ */
diff --git a/nx-X11/lib/GL/dri/drm/Imakefile b/nx-X11/lib/GL/dri/drm/Imakefile
new file mode 100644
index 000000000..cfc4247dd
--- /dev/null
+++ b/nx-X11/lib/GL/dri/drm/Imakefile
@@ -0,0 +1,54 @@
+XCOMM $XdotOrg: xc/lib/GL/dri/drm/Imakefile,v 1.6 2005/12/01 02:15:37 ajax Exp $
+XCOMM $XFree86: xc/lib/GL/dri/drm/Imakefile,v 1.22 2003/09/28 20:15:00 alanh Exp $
+
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ -I$(XF86OSSRC)/$(OS_SUBDIR)/drm \
+ -I$(DRMSRCDIR)/$(OS_SUBDIR)-core \
+ -I$(DRMSRCDIR)/$(OS_SUBDIR2)-core \
+ -I$(XF86OSSRC) -I$(DRMSRCDIR)/shared-core
+ SRCS = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c
+ OBJS = xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o
+
+#if defined(LinuxArchitecture)
+OS_SUBDIR = linux
+OS_SUBDIR2 = linux
+OS_SUBDIR3 = shared-core
+#endif
+#if defined(FreeBSDArchitecture) || defined(BSDOSArchitecture) || \
+ defined(NetBSDArchitecture) || defined(OpenBSDArchitecture)
+OS_SUBDIR = bsd
+OS_SUBDIR2 = linux
+OS_SUBDIR3 = shared-core
+#endif
+
+LIBDRM_DIR = ../../../../extras/drm/libdrm
+
+LinkSourceFile(xf86drm.c,$(LIBDRM_DIR))
+
+LinkSourceFile(xf86drmHash.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmRandom.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmSL.c,$(LIBDRM_DIR))
+
+LinkSourceFile(drm.h,$(LIBDRM_DIR)/../shared-core)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+InstallDriverSDKNonExecFile(drm.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/lib/GL/glx/Imakefile b/nx-X11/lib/GL/glx/Imakefile
new file mode 100644
index 000000000..97d3b3224
--- /dev/null
+++ b/nx-X11/lib/GL/glx/Imakefile
@@ -0,0 +1,233 @@
+XCOMM $XFree86: xc/lib/GL/glx/Imakefile,v 1.22 2003/11/12 00:10:24 dawes Exp $
+XCOMM The contents of this file are subject to the GLX Public License Version 1.0
+XCOMM (the "License"). You may not use this file except in compliance with the
+XCOMM License. You may obtain a copy of the License at Silicon Graphics, Inc.,
+XCOMM attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA 94043
+XCOMM or at http://www.sgi.com/software/opensource/glx/license.html.
+XCOMM
+XCOMM Software distributed under the License is distributed on an "AS IS"
+XCOMM basis. ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY
+XCOMM IMPLIED WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
+XCOMM PURPOSE OR OF NON- INFRINGEMENT. See the License for the specific
+XCOMM language governing rights and limitations under the License.
+XCOMM
+XCOMM The Original Software is GLX version 1.2 source code, released February,
+XCOMM 1999. The developer of the Original Software is Silicon Graphics, Inc.
+XCOMM Those portions of the Subject Software created by Silicon Graphics, Inc.
+XCOMM are Copyright (c) 1991-9 Silicon Graphics, Inc. All Rights Reserved.
+
+XCOMM $XdotOrg: xc/lib/GL/glx/Imakefile,v 1.12 2005/08/23 04:03:51 airlied Exp $
+
+#include <Threads.tmpl>
+
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+
+/* Large PIC tables needed for Solaris SPARC builds */
+#if (defined(SunArchitecture) && defined(SparcArchitecture))
+# define LargePICTable YES
+#endif
+
+XCOMM #define IHaveSubdirs
+XCOMM #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
+XCOMM
+XCOMM SUBDIRS = \
+XCOMM glu \
+XCOMM glw
+
+/* Files from Mesa */
+
+LinkSourceFile(glapi.c, $(MESASRCDIR)/src/mesa/glapi)
+LinkSourceFile(glthread.c, $(MESASRCDIR)/src/mesa/glapi)
+LinkSourceFile(glcontextmodes.c, $(MESASRCDIR)/src/mesa/drivers/dri/common)
+LinkSourceFile(glcontextmodes.h, $(MESASRCDIR)/src/mesa/drivers/dri/common)
+LinkSourceFile(dispatch.c, $(MESASRCDIR)/src/mesa/main)
+
+#ifdef i386Architecture
+LinkSourceFile(glapi_x86.S, $(MESASRCDIR)/src/mesa/x86)
+#endif
+#ifdef SparcArchitecture
+LinkSourceFile(glapi_sparc.S, $(MESASRCDIR)/src/mesa/sparc)
+#endif
+
+LinkSourceFile(XF86dri.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(clientattrib.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(compsize.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(dri_glx.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(dri_glx.h, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(eval.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(glx_pbuffer.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(glx_query.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(glx_texture_compression.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(glxclient.h, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(glxcmds.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(glxext.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(glxextensions.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(glxextensions.h, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(indirect.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(indirect.h, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(indirect_init.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(indirect_init.h, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(indirect_size.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(indirect_size.h, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(indirect_transpose_matrix.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(indirect_va_private.h, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(indirect_vertex_array.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(indirect_vertex_array.h, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(indirect_vertex_program.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(indirect_window_pos.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(packrender.h, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(packsingle.h, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(pixel.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(pixelstore.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(render2.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(renderpix.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(single2.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(singlepix.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(vertarr.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(xf86dri.h, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(xf86dristr.h, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(xfont.c, $(MESASRCDIR)/src/glx/x11)
+
+/*
+ * Maybe some of these could come from
+ * xc/extras/ogl-sample/main/glx/lib at some point.
+ */
+ GLX_SRCS = \
+ clientattrib.c \
+ compsize.c \
+ dispatch.c \
+ eval.c \
+ glapi.c \
+ glthread.c \
+ glx_pbuffer.c \
+ glx_query.c \
+ glx_texture_compression.c \
+ glxcmds.c \
+ glxext.c \
+ glxextensions.c \
+ glcontextmodes.c \
+ indirect.c \
+ indirect_init.c \
+ indirect_size.c \
+ indirect_transpose_matrix.c \
+ indirect_vertex_array.c \
+ indirect_vertex_program.c \
+ indirect_window_pos.c \
+ pixel.c \
+ pixelstore.c \
+ render2.c \
+ renderpix.c \
+ single2.c \
+ singlepix.c \
+ vertarr.c \
+ xfont.c
+
+ GLX_OBJS = \
+ clientattrib.o \
+ compsize.o \
+ eval.o \
+ dispatch.o \
+ glapi.o \
+ glthread.o \
+ glx_pbuffer.o \
+ glx_query.o \
+ glx_texture_compression.o \
+ glxcmds.o \
+ glxext.o \
+ glxextensions.o \
+ glcontextmodes.o \
+ indirect.o \
+ indirect_init.o \
+ indirect_size.o \
+ indirect_transpose_matrix.o \
+ indirect_vertex_array.o \
+ indirect_vertex_program.o \
+ indirect_window_pos.o \
+ pixel.o \
+ pixelstore.o \
+ render2.o \
+ renderpix.o \
+ single2.o \
+ singlepix.o \
+ vertarr.o \
+ xfont.o
+
+ GLX_DEFS = GlxDefines VidModeExtensionDefines \
+ -DDEFAULT_DRIVER_DIR=\"$(MODULEDIR)/dri\"
+
+#ifdef i386Architecture
+ ASM_DIR = x86
+#endif
+#ifdef SparcArchitecture
+ ASM_DIR = sparc
+#endif
+
+#if BuildXF86DRI
+ DRI_SRCS = dri_glx.c XF86dri.c
+ DRI_OBJS = dri_glx.o XF86dri.o
+
+ DRI_INCS = -I$(SERVERSRC)/GL/dri
+#if defined(i386Architecture) && MesaUseX86Asm
+ ASM_SRCS = glapi_x86.S
+ ASM_OBJS = glapi_x86.o
+ ASM_DEFS = -DUSE_X86_ASM
+#endif
+#if defined(SparcArchitecture)
+ ASM_SRCS = glapi_sparc.S
+ ASM_OBJS = glapi_sparc.o
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#if GlxBuiltInXMesa
+ XMESA_DEFINES = -DGLX_BUILT_IN_XMESA
+#endif
+#endif
+
+#if defined(DarwinArchitecture) || defined(OS2Architecture) || \
+defined(LynxOSArchitecture)
+ALIAS_DEFINES = -DGLX_ALIAS_UNSUPPORTED
+#endif
+#if defined(DarwinArchitecture) && BuildAppleDRI
+ DRI_SRCS = XF86dri.c
+ DRI_OBJS = XF86dri.o
+
+ DRI_INCS = -I$(SERVERSRC)/GL/dri
+#endif
+
+ SRCS = $(GLX_SRCS) $(ASM_SRCS) $(DRI_SRCS)
+ OBJS = $(GLX_OBJS) $(ASM_OBJS) $(DRI_OBJS)
+ DEFINES = $(GLX_DEFS) $(ASM_DEFS) $(XMESA_DEFINES) $(ALIAS_DEFINES) \
+ $(THREADS_DEFINES)
+
+ INCLUDES = -I$(XINCLUDESRC) \
+ -I$(MESASRCDIR)/include \
+ -I$(EXTINCSRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/drivers/x11 \
+ -I$(MESASRCDIR)/src/mesa/$(ASM_DIR) \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ $(DRI_INCS)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+#if BuildXF86DRI && defined(i386Architecture) && MesaUseX86Asm
+ObjectFromAsmSource(glapi_x86, NullParameter)
+#endif
+#if BuildXF86DRI && defined(SparcArchitecture)
+STD_CPP_DEFINES = StandardDefines $(PROJECT_DEFINES)
+ObjectFromAsmSource(glapi_sparc, NullParameter)
+#endif
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/Imakefile b/nx-X11/lib/GL/mesa/Imakefile
new file mode 100644
index 000000000..523123ae8
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/Imakefile
@@ -0,0 +1,73 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/Imakefile,v 1.30tsi Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if BuildOSMesaLib || (BuildXF86DRI && (GlxDriverUsesMesa || GlxBuiltInXMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+/* Large PIC tables needed for Solaris SPARC builds */
+#if (defined(SunArchitecture) && defined(SparcArchitecture))
+# define LargePICTable YES
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if defined(i386Architecture) && MesaUseX86Asm
+#define MesaX86BuildDir /**/
+ASM_SUBDIRS = x86
+#endif
+#ifdef SparcArchitecture
+#define MesaSparcBuildDir /**/
+ASM_SUBDIRS = sparc
+#endif
+#define MesaBuildDir /**/
+#define NeedToLinkMesaSrc
+
+#ifdef UseCompaqMathLibrary
+ MATH_DEFINES = -DCCPML
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) GlxDefines \
+ $(MESA_ASM_DEFINES) $(MATH_DEFINES)
+ INCLUDES = -I$(INCLUDESRC) -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ -I$(GLXLIBSRC)/dri \
+ -I$(MESASRCDIR)/include -I$(GLXLIBSRC)/include
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+#define IHaveSubdirs
+#define PassCDebugFlags
+
+SUBDIRS = $(ASM_SUBDIRS) array_cache main math swrast swrast_setup tnl tnl_dd shader
+
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/Imakefile.inc b/nx-X11/lib/GL/mesa/Imakefile.inc
new file mode 100644
index 000000000..03a7971f8
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/Imakefile.inc
@@ -0,0 +1,57 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/Imakefile.inc,v 1.7tsi Exp $
+
+#ifndef MesaBuildDir
+#define MesaBuildDir $(GLXLIBSRC)/mesa/
+#endif
+
+MESABUILDDIR = MesaBuildDir
+
+COREMESASRCS = $(COREMESABASESRCS) \
+ $(MESA_AC_SRCS) \
+ $(MESA_MATH_SRCS) \
+ $(MESA_SWRAST_SRCS) \
+ $(MESA_SWR_SETUP_SRCS) \
+ $(MESA_TNL_SRCS) \
+ $(MESA_SHADER_SRCS) \
+ $(MESA_GRAMMAR_SRCS) \
+ $(MESA_SLANG_SRCS)
+
+COREMESAOBJS = $(COREMESABASEOBJS) \
+ $(MESA_AC_OBJS) \
+ $(MESA_MATH_OBJS) \
+ $(MESA_SWRAST_OBJS) \
+ $(MESA_SWR_SETUP_OBJS) \
+ $(MESA_TNL_OBJS) \
+ $(MESA_SHADER_OBJS) \
+ $(MESA_GRAMMAR_OBJS) \
+ $(MESA_SLANG_OBJS)
+
+COREMESAUOBJS = $(COREMESABASEUOBJS) \
+ $(MESA_AC_UOBJS) \
+ $(MESA_MATH_UOBJS) \
+ $(MESA_SWRAST_UOBJS) \
+ $(MESA_SWR_SETUP_UOBJS) \
+ $(MESA_TNL_UOBJS) \
+ $(MESA_SHADER_UOBJS) \
+ $(MESA_GRAMMAR_UOBJS) \
+ $(MESA_SLANG_UOBJS)
+
+COREMESADOBJS = $(COREMESABASEDOBJS) \
+ $(MESA_AC_DOBJS) \
+ $(MESA_MATH_DOBJS) \
+ $(MESA_SWRAST_DOBJS) \
+ $(MESA_SWR_SETUP_DOBJS) \
+ $(MESA_TNL_DOBJS) \
+ $(MESA_SHADER_DOBJS) \
+ $(MESA_GRAMMAR_DOBJS) \
+ $(MESA_SLANG_DOBJS)
+
+COREMESAPOBJS = $(COREMESABASEPOBJS) \
+ $(MESA_AC_POBJS) \
+ $(MESA_MATH_POBJS) \
+ $(MESA_SWRAST_POBJS) \
+ $(MESA_SWR_SETUP_POBJS) \
+ $(MESA_TNL_POBJS) \
+ $(MESA_SHADER_POBJS) \
+ $(MESA_GRAMMAR_POBJS) \
+ $(MESA_SLANG_POBJS)
diff --git a/nx-X11/lib/GL/mesa/array_cache/Imakefile b/nx-X11/lib/GL/mesa/array_cache/Imakefile
new file mode 100644
index 000000000..40c9c6b52
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/array_cache/Imakefile
@@ -0,0 +1,91 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/array_cache/Imakefile,v 1.8 2002/11/25 12:58:55 tsi Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if BuildOSMesaLib || (BuildXF86DRI && (GlxDriverUsesMesa || GlxBuiltInXMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+
+#define MesaACBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I../../../include \
+ -I$(INCLUDESRC)/GL -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/array_cache \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/math \
+ -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/include \
+ -I../../../include -I$(XINCLUDESRC)
+
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = $(MESA_AC_SRCS)
+ OBJS = $(MESA_AC_OBJS)
+
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/array_cache/Imakefile.inc b/nx-X11/lib/GL/mesa/array_cache/Imakefile.inc
new file mode 100644
index 000000000..9a5044791
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/array_cache/Imakefile.inc
@@ -0,0 +1,34 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/array_cache/Imakefile.inc,v 1.1tsi Exp $
+
+#ifndef MesaACBuildDir
+#define MesaACBuildDir $(GLXLIBSRC)/mesa/array_cache/
+#endif
+
+MESAACBUILDDIR = MesaACBuildDir
+
+ MESA_AC_SRCS = $(MESAACBUILDDIR)ac_context.c \
+ $(MESAACBUILDDIR)ac_import.c
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(acache.h, $(MESASRCDIR)/src/mesa/array_cache)
+LinkSourceFile(ac_context.c, $(MESASRCDIR)/src/mesa/array_cache)
+LinkSourceFile(ac_context.h, $(MESASRCDIR)/src/mesa/array_cache)
+LinkSourceFile(ac_import.c, $(MESASRCDIR)/src/mesa/array_cache)
+#endif
+
+ MESA_AC_OBJS = $(MESAACBUILDDIR)ac_context.o \
+ $(MESAACBUILDDIR)ac_import.o
+
+#if defined(DoSharedLib) && DoSharedLib
+ MESA_AC_UOBJS = $(MESAACBUILDDIR)unshared/ac_context.o \
+ $(MESAACBUILDDIR)unshared/ac_import.o
+#else
+ MESA_AC_UOBJS = $(MESA_AC_OBJS)
+#endif
+
+ MESA_AC_DOBJS = $(MESAACBUILDDIR)debugger/ac_context.o \
+ $(MESAACBUILDDIR)debugger/ac_import.o
+
+ MESA_AC_POBJS = $(MESAACBUILDDIR)profiled/ac_context.o \
+ $(MESAACBUILDDIR)profiled/ac_import.o
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/Imakefile
new file mode 100644
index 000000000..eba13848b
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/Imakefile
@@ -0,0 +1,21 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/Imakefile,v 1.18 2001/03/23 19:18:38 dawes Exp $
+
+#ifdef DriDrivers
+
+#define IHaveSubdirs
+#define PassCDebugFlags
+
+DRI_DRIVERS = DriDrivers
+
+#if BuildDevelDRIDrivers
+DEVEL_DRI_DRIVERS = DevelDRIDrivers
+#endif
+
+SUBDIRS = common $(DRI_DRIVERS) $(DEVEL_DRI_DRIVERS)
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
+DependTarget()
+
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/common/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/common/Imakefile
new file mode 100644
index 000000000..d5c8dc7fa
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/common/Imakefile
@@ -0,0 +1,44 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/common/Imakefile,v 1.6 2001/04/03 02:29:34 dawes Exp $
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+
+#define NeedToLinkMesaSrc
+#define MesaDrvCommonBuildDir /**/
+#include "Imakefile.inc"
+
+ DEFINES = $(ALLOC_DEFINES) $(COMMON_DRI_DEFINES) $(MESA_ASM_DEFINES)
+ INCLUDES = $(COMMON_X_INCLUDES) $(COMMON_MESA_INCLUDES) \
+ $(COMMON_DRI_INCLUDES) $(EXPATINCLUDES)
+
+ SRCS = $(COMMONSRCS)
+ OBJS = $(COMMONOBJS)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/common/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/common/Imakefile.inc
new file mode 100644
index 000000000..388b724b2
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/common/Imakefile.inc
@@ -0,0 +1,105 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/common/Imakefile.inc,v 1.3 2003/05/27 16:34:32 tsi Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvCommonBuildDir
+#define MesaDrvCommonBuildDir $(MESADRVSRCDIR)/common/
+#endif
+
+MESADRVCOMMONBUILDDIR = MesaDrvCommonBuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ COMMON_DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=$(X_BYTE_ORDER) -DIN_DRI_DRIVER
+ COMMON_DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86OSSRC) \
+ -I$(XF86COMSRC) \
+ -I$(GLXLIBSRC)/dri/drm \
+ -I$(GLXLIBSRC)/include \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(MESASRCDIR)/include/GL/internal
+#endif
+
+COMMON_MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/../common \
+ -I$(MESASRCDIR)/include
+ COMMON_X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+ COMMONSRCS = $(MESADRVCOMMONBUILDDIR)utils.c \
+ $(MESADRVCOMMONBUILDDIR)vblank.c \
+ $(MESADRVCOMMONBUILDDIR)texmem.c \
+ $(MESADRVCOMMONBUILDDIR)xmlconfig.c \
+ $(MESADRVCOMMONBUILDDIR)driverfuncs.c \
+ $(MESADRVCOMMONBUILDDIR)dri_util.c \
+ $(MESADRVCOMMONBUILDDIR)glcontextmodes.c \
+ $(MESADRVCOMMONBUILDDIR)drirenderbuffer.c
+
+ COMMONOBJS = $(MESADRVCOMMONBUILDDIR)utils.o \
+ $(MESADRVCOMMONBUILDDIR)vblank.o \
+ $(MESADRVCOMMONBUILDDIR)texmem.o \
+ $(MESADRVCOMMONBUILDDIR)xmlconfig.o \
+ $(MESADRVCOMMONBUILDDIR)driverfuncs.o \
+ $(MESADRVCOMMONBUILDDIR)dri_util.o \
+ $(MESADRVCOMMONBUILDDIR)glcontextmodes.o \
+ $(MESADRVCOMMONBUILDDIR)drirenderbuffer.o
+
+ COMMONUOBJS = $(MESADRVCOMMONBUILDDIR)unshared/utils.o \
+ $(MESADRVCOMMONBUILDDIR)unshared/vblank.o \
+ $(MESADRVCOMMONBUILDDIR)unshared/texmem.o \
+ $(MESADRVCOMMONBUILDDIR)unshared/xmlconfig.o \
+ $(MESADRVCOMMONBUILDDIR)unshared/driverfuncs.o \
+ $(MESADRVCOMMONBUILDDIR)unshared/dri_util.o \
+ $(MESADRVCOMMONBUILDDIR)unshared/glcontextmodes.o \
+ $(MESADRVCOMMONBUILDDIR)unshared/drirenderbuffer.o
+
+ COMMONDOBJS = $(MESADRVCOMMONBUILDDIR)debugger/utils.o \
+ $(MESADRVCOMMONBUILDDIR)debugger/vblank.o \
+ $(MESADRVCOMMONBUILDDIR)debugger/texmem.o \
+ $(MESADRVCOMMONBUILDDIR)debugger/xmlconfig.o \
+ $(MESADRVCOMMONBUILDDIR)debugger/driverfuncs.o \
+ $(MESADRVCOMMONBUILDDIR)debugger/dri_util.o \
+ $(MESADRVCOMMONBUILDDIR)debugger/glcontextmodes.o \
+ $(MESADRVCOMMONBUILDDIR)debugger/drirenderbuffer.o
+
+ COMMONPOBJS = $(MESADRVCOMMONBUILDDIR)profiled/utils.o \
+ $(MESADRVCOMMONBUILDDIR)profiled/vblank.o \
+ $(MESADRVCOMMONBUILDDIR)profiled/texmem.o \
+ $(MESADRVCOMMONBUILDDIR)profiled/xmlconfig.o \
+ $(MESADRVCOMMONBUILDDIR)profiled/driverfuncs.o \
+ $(MESADRVCOMMONBUILDDIR)profiled/dri_util.o \
+ $(MESADRVCOMMONBUILDDIR)profiled/glcontextmodes.o \
+ $(MESADRVCOMMONBUILDDIR)profiled/drirenderbuffer.o
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(texmem.c, $(MESADRVSRCDIR)/common)
+LinkSourceFile(texmem.h, $(MESADRVSRCDIR)/common)
+LinkSourceFile(utils.c, $(MESADRVSRCDIR)/common)
+LinkSourceFile(utils.h, $(MESADRVSRCDIR)/common)
+LinkSourceFile(vblank.c, $(MESADRVSRCDIR)/common)
+LinkSourceFile(vblank.h, $(MESADRVSRCDIR)/common)
+LinkSourceFile(xmlconfig.c, $(MESADRVSRCDIR)/common)
+LinkSourceFile(xmlconfig.h, $(MESADRVSRCDIR)/common)
+LinkSourceFile(driverfuncs.c, $(MESADRVSRCDIR)/../common)
+LinkSourceFile(driverfuncs.h, $(MESADRVSRCDIR)/../common)
+LinkSourceFile(dri_util.c, $(MESADRVSRCDIR)/common)
+LinkSourceFile(dri_util.h, $(MESADRVSRCDIR)/common)
+LinkSourceFile(glcontextmodes.c, $(MESADRVSRCDIR)/common)
+LinkSourceFile(glcontextmodes.h, $(MESADRVSRCDIR)/common)
+LinkSourceFile(drirenderbuffer.c, $(MESADRVSRCDIR)/common)
+LinkSourceFile(drirenderbuffer.h, $(MESADRVSRCDIR)/common)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/ffb/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/ffb/Imakefile
new file mode 100644
index 000000000..7d98c1912
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/ffb/Imakefile
@@ -0,0 +1,77 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/ffb/Imakefile,v 1.15 2002/02/23 00:45:48 dawes Exp $
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES) \
+ -I$(XF86DRIVERSRC)/sunffb
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(FFBSRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(FFBOBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(FFBOBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = ffb_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _ffb_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/ffb/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/ffb/Imakefile.inc
new file mode 100644
index 000000000..3ef08a64a
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/ffb/Imakefile.inc
@@ -0,0 +1,151 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/ffb/Imakefile.inc,v 1.3 2002/02/22 21:32:58 dawes Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvFfbBuildDir
+#define MesaDrvFfbBuildDir /**/
+#endif
+MESADRVFFBBUILDDIR = MesaDrvFfbBuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/ffb
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+ FFBSRCS = $(MESADRVFFBBUILDDIR)ffb_bitmap.c \
+ $(MESADRVFFBBUILDDIR)ffb_clear.c \
+ $(MESADRVFFBBUILDDIR)ffb_dd.c \
+ $(MESADRVFFBBUILDDIR)ffb_depth.c \
+ /* $(MESADRVFFBBUILDDIR)ffb_fog.c */ \
+ $(MESADRVFFBBUILDDIR)ffb_lines.c \
+ $(MESADRVFFBBUILDDIR)ffb_points.c \
+ $(MESADRVFFBBUILDDIR)ffb_span.c \
+ $(MESADRVFFBBUILDDIR)ffb_state.c \
+ $(MESADRVFFBBUILDDIR)ffb_stencil.c \
+ $(MESADRVFFBBUILDDIR)ffb_tex.c \
+ $(MESADRVFFBBUILDDIR)ffb_tris.c \
+ $(MESADRVFFBBUILDDIR)ffb_vb.c \
+ $(MESADRVFFBBUILDDIR)ffb_xmesa.c
+
+ FFBOBJS = $(MESADRVFFBBUILDDIR)ffb_bitmap.o \
+ $(MESADRVFFBBUILDDIR)ffb_clear.o \
+ $(MESADRVFFBBUILDDIR)ffb_dd.o \
+ $(MESADRVFFBBUILDDIR)ffb_depth.o \
+ /* $(MESADRVFFBBUILDDIR)ffb_fog.o */ \
+ $(MESADRVFFBBUILDDIR)ffb_lines.o \
+ $(MESADRVFFBBUILDDIR)ffb_points.o \
+ $(MESADRVFFBBUILDDIR)ffb_span.o \
+ $(MESADRVFFBBUILDDIR)ffb_state.o \
+ $(MESADRVFFBBUILDDIR)ffb_stencil.o \
+ $(MESADRVFFBBUILDDIR)ffb_tex.o \
+ $(MESADRVFFBBUILDDIR)ffb_tris.o \
+ $(MESADRVFFBBUILDDIR)ffb_vb.o \
+ $(MESADRVFFBBUILDDIR)ffb_xmesa.o
+
+ FFBUOBJS = $(MESADRVFFBBUILDDIR)unshared/ffb_bitmap.o \
+ $(MESADRVFFBBUILDDIR)unshared/ffb_clear.o \
+ $(MESADRVFFBBUILDDIR)unshared/ffb_dd.o \
+ $(MESADRVFFBBUILDDIR)unshared/ffb_depth.o \
+ /* $(MESADRVFFBBUILDDIR)unshared/ffb_fog.o */ \
+ $(MESADRVFFBBUILDDIR)unshared/ffb_lines.o \
+ $(MESADRVFFBBUILDDIR)unshared/ffb_points.o \
+ $(MESADRVFFBBUILDDIR)unshared/ffb_span.o \
+ $(MESADRVFFBBUILDDIR)unshared/ffb_state.o \
+ $(MESADRVFFBBUILDDIR)unshared/ffb_stencil.o \
+ $(MESADRVFFBBUILDDIR)unshared/ffb_tex.o \
+ $(MESADRVFFBBUILDDIR)unshared/ffb_tris.o \
+ $(MESADRVFFBBUILDDIR)unshared/ffb_vb.o \
+ $(MESADRVFFBBUILDDIR)unshared/ffb_xmesa.o
+
+ FFBDOBJS = $(MESADRVFFBBUILDDIR)debugger/ffb_bitmap.o \
+ $(MESADRVFFBBUILDDIR)debugger/ffb_clear.o \
+ $(MESADRVFFBBUILDDIR)debugger/ffb_dd.o \
+ $(MESADRVFFBBUILDDIR)debugger/ffb_depth.o \
+ /* $(MESADRVFFBBUILDDIR)debugger/ffb_fog.o */ \
+ $(MESADRVFFBBUILDDIR)debugger/ffb_lines.o \
+ $(MESADRVFFBBUILDDIR)debugger/ffb_points.o \
+ $(MESADRVFFBBUILDDIR)debugger/ffb_span.o \
+ $(MESADRVFFBBUILDDIR)debugger/ffb_state.o \
+ $(MESADRVFFBBUILDDIR)debugger/ffb_stencil.o \
+ $(MESADRVFFBBUILDDIR)debugger/ffb_tex.o \
+ $(MESADRVFFBBUILDDIR)debugger/ffb_tris.o \
+ $(MESADRVFFBBUILDDIR)debugger/ffb_vb.o \
+ $(MESADRVFFBBUILDDIR)debugger/ffb_xmesa.o
+
+ FFBPOBJS = $(MESADRVFFBBUILDDIR)profiled/ffb_bitmap.o \
+ $(MESADRVFFBBUILDDIR)profiled/ffb_clear.o \
+ $(MESADRVFFBBUILDDIR)profiled/ffb_dd.o \
+ $(MESADRVFFBBUILDDIR)profiled/ffb_depth.o \
+ /* $(MESADRVFFBBUILDDIR)profiled/ffb_fog.o */ \
+ $(MESADRVFFBBUILDDIR)profiled/ffb_lines.o \
+ $(MESADRVFFBBUILDDIR)profiled/ffb_points.o \
+ $(MESADRVFFBBUILDDIR)profiled/ffb_span.o \
+ $(MESADRVFFBBUILDDIR)profiled/ffb_state.o \
+ $(MESADRVFFBBUILDDIR)profiled/ffb_stencil.o \
+ $(MESADRVFFBBUILDDIR)profiled/ffb_tex.o \
+ $(MESADRVFFBBUILDDIR)profiled/ffb_tris.o \
+ $(MESADRVFFBBUILDDIR)profiled/ffb_vb.o \
+ $(MESADRVFFBBUILDDIR)profiled/ffb_xmesa.o
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(ffb_bitmap.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_bitmap.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_clear.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_clear.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_context.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_dd.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_dd.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_depth.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_depth.h, $(MESADRVSRCDIR)/ffb)
+/* LinkSourceFile(ffb_fog.c, $(MESADRVSRCDIR)/ffb) */
+LinkSourceFile(ffb_fifo.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_lines.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_lines.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_linetmp.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_lock.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_points.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_points.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_pointtmp.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_rendertmp.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_span.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_span.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_state.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_state.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_stencil.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_stencil.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_tex.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_tex.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_tris.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_tris.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_tritmp.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_vb.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_vb.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_vbtmp.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_vtxfmt.h, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_xmesa.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_xmesa.h, $(MESADRVSRCDIR)/ffb)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/gamma/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/gamma/Imakefile
new file mode 100644
index 000000000..490f8ccec
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/gamma/Imakefile
@@ -0,0 +1,77 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/gamma/Imakefile,v 1.25 2002/02/23 00:45:49 dawes Exp $
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(GAMMASRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(GAMMAOBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(GAMMAOBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = gamma_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _gamma_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/gamma/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/gamma/Imakefile.inc
new file mode 100644
index 000000000..e42cc5ce6
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/gamma/Imakefile.inc
@@ -0,0 +1,140 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/gamma/Imakefile.inc,v 1.2 2001/05/02 15:06:03 dawes Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvGammaBuildDir
+#define MesaDrvGammaBuildDir /**/
+#endif
+MESADRVGAMMABUILDDIR = MesaDrvGammaBuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86DRIVERSRC)/glint \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/gamma
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+
+ GAMMASRCS = $(MESADRVGAMMABUILDDIR)gamma_context.c \
+ $(MESADRVGAMMABUILDDIR)gamma_dd.c \
+ $(MESADRVGAMMABUILDDIR)gamma_inithw.c \
+ $(MESADRVGAMMABUILDDIR)gamma_lock.c \
+ $(MESADRVGAMMABUILDDIR)gamma_render.c \
+ $(MESADRVGAMMABUILDDIR)gamma_screen.c \
+ $(MESADRVGAMMABUILDDIR)gamma_span.c \
+ $(MESADRVGAMMABUILDDIR)gamma_state.c \
+ $(MESADRVGAMMABUILDDIR)gamma_tex.c \
+ $(MESADRVGAMMABUILDDIR)gamma_texmem.c \
+ $(MESADRVGAMMABUILDDIR)gamma_texstate.c \
+ $(MESADRVGAMMABUILDDIR)gamma_tris.c \
+ $(MESADRVGAMMABUILDDIR)gamma_vb.c \
+ $(MESADRVGAMMABUILDDIR)gamma_xmesa.c
+
+ GAMMAOBJS = $(MESADRVGAMMABUILDDIR)gamma_context.o \
+ $(MESADRVGAMMABUILDDIR)gamma_dd.o \
+ $(MESADRVGAMMABUILDDIR)gamma_inithw.o \
+ $(MESADRVGAMMABUILDDIR)gamma_lock.o \
+ $(MESADRVGAMMABUILDDIR)gamma_render.o \
+ $(MESADRVGAMMABUILDDIR)gamma_screen.o \
+ $(MESADRVGAMMABUILDDIR)gamma_span.o \
+ $(MESADRVGAMMABUILDDIR)gamma_state.o \
+ $(MESADRVGAMMABUILDDIR)gamma_tex.o \
+ $(MESADRVGAMMABUILDDIR)gamma_texmem.o \
+ $(MESADRVGAMMABUILDDIR)gamma_texstate.o \
+ $(MESADRVGAMMABUILDDIR)gamma_tris.o \
+ $(MESADRVGAMMABUILDDIR)gamma_vb.o \
+ $(MESADRVGAMMABUILDDIR)gamma_xmesa.o
+
+ GAMMAUOBJS = $(MESADRVGAMMABUILDDIR)unshared/gamma_context.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_dd.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_inithw.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_lock.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_render.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_screen.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_span.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_state.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_tex.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_texmem.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_texstate.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_tris.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_vb.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_xmesa.o
+
+ GAMMADOBJS = $(MESADRVGAMMABUILDDIR)debugger/gamma_context.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_dd.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_inithw.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_lock.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_render.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_screen.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_span.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_state.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_tex.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_texmem.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_texstate.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_tris.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_vb.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_xmesa.o
+
+ GAMMAPOBJS = $(MESADRVGAMMABUILDDIR)profiled/gamma_context.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_dd.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_inithw.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_lock.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_render.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_screen.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_span.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_state.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_tex.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_texmem.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_texstate.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_tris.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_vb.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_xmesa.o
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(gamma_context.c, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_context.h, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_client.h, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_dd.c, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_inithw.c, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_lock.c, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_lock.h, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_macros.h, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_render.c, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_regs.h, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_screen.c, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_screen.h, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_span.c, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_state.c, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_tex.c, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_texmem.c, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_texstate.c, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_tris.c, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_tris.h, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_tritmp.h, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_vb.c, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_vb.h, $(MESADRVSRCDIR)/gamma)
+LinkSourceFile(gamma_xmesa.c, $(MESADRVSRCDIR)/gamma)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/i810/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/i810/Imakefile
new file mode 100644
index 000000000..5d16f0108
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/i810/Imakefile
@@ -0,0 +1,77 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/i810/Imakefile,v 1.23tsi Exp $
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
+
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(I810SRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(I810OBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(I810OBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = i810_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _i810_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/i810/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/i810/Imakefile.inc
new file mode 100644
index 000000000..f540da75b
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/i810/Imakefile.inc
@@ -0,0 +1,121 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/i810/Imakefile.inc,v 1.2 2001/05/02 15:06:03 dawes Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvI810BuildDir
+#define MesaDrvI810BuildDir /**/
+#endif
+MESADRVI810BUILDDIR = MesaDrvI810BuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder -DUSE_NEW_INTERFACE -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86DRIVERSRC)/i810 \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/i810
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+ I810SRCS = $(MESADRVI810BUILDDIR)i810context.c \
+ $(MESADRVI810BUILDDIR)i810ioctl.c \
+ $(MESADRVI810BUILDDIR)i810render.c \
+ $(MESADRVI810BUILDDIR)i810screen.c \
+ $(MESADRVI810BUILDDIR)i810span.c \
+ $(MESADRVI810BUILDDIR)i810state.c \
+ $(MESADRVI810BUILDDIR)i810tex.c \
+ $(MESADRVI810BUILDDIR)i810texmem.c \
+ $(MESADRVI810BUILDDIR)i810texstate.c \
+ $(MESADRVI810BUILDDIR)i810tris.c \
+ $(MESADRVI810BUILDDIR)i810vb.c
+
+ I810OBJS = $(MESADRVI810BUILDDIR)i810context.o \
+ $(MESADRVI810BUILDDIR)i810ioctl.o \
+ $(MESADRVI810BUILDDIR)i810render.o \
+ $(MESADRVI810BUILDDIR)i810screen.o \
+ $(MESADRVI810BUILDDIR)i810span.o \
+ $(MESADRVI810BUILDDIR)i810state.o \
+ $(MESADRVI810BUILDDIR)i810tex.o \
+ $(MESADRVI810BUILDDIR)i810texmem.o \
+ $(MESADRVI810BUILDDIR)i810texstate.o \
+ $(MESADRVI810BUILDDIR)i810tris.o \
+ $(MESADRVI810BUILDDIR)i810vb.o
+
+ I810UOBJS = $(MESADRVI810BUILDDIR)unshared/i810context.o \
+ $(MESADRVI810BUILDDIR)unshared/i810ioctl.o \
+ $(MESADRVI810BUILDDIR)unshared/i810render.o \
+ $(MESADRVI810BUILDDIR)unshared/i810screen.o \
+ $(MESADRVI810BUILDDIR)unshared/i810span.o \
+ $(MESADRVI810BUILDDIR)unshared/i810state.o \
+ $(MESADRVI810BUILDDIR)unshared/i810tex.o \
+ $(MESADRVI810BUILDDIR)unshared/i810texmem.o \
+ $(MESADRVI810BUILDDIR)unshared/i810texstate.o \
+ $(MESADRVI810BUILDDIR)unshared/i810tris.o \
+ $(MESADRVI810BUILDDIR)unshared/i810vb.o
+
+ I810DOBJS = $(MESADRVI810BUILDDIR)debugger/i810context.o \
+ $(MESADRVI810BUILDDIR)debugger/i810ioctl.o \
+ $(MESADRVI810BUILDDIR)debugger/i810render.o \
+ $(MESADRVI810BUILDDIR)debugger/i810screen.o \
+ $(MESADRVI810BUILDDIR)debugger/i810span.o \
+ $(MESADRVI810BUILDDIR)debugger/i810state.o \
+ $(MESADRVI810BUILDDIR)debugger/i810tex.o \
+ $(MESADRVI810BUILDDIR)debugger/i810texmem.o \
+ $(MESADRVI810BUILDDIR)debugger/i810texstate.o \
+ $(MESADRVI810BUILDDIR)debugger/i810tris.o \
+ $(MESADRVI810BUILDDIR)debugger/i810vb.o
+
+ I810POBJS = $(MESADRVI810BUILDDIR)profiled/i810context.o \
+ $(MESADRVI810BUILDDIR)profiled/i810ioctl.o \
+ $(MESADRVI810BUILDDIR)profiled/i810render.o \
+ $(MESADRVI810BUILDDIR)profiled/i810screen.o \
+ $(MESADRVI810BUILDDIR)profiled/i810span.o \
+ $(MESADRVI810BUILDDIR)profiled/i810state.o \
+ $(MESADRVI810BUILDDIR)profiled/i810tex.o \
+ $(MESADRVI810BUILDDIR)profiled/i810texmem.o \
+ $(MESADRVI810BUILDDIR)profiled/i810texstate.o \
+ $(MESADRVI810BUILDDIR)profiled/i810tris.o \
+ $(MESADRVI810BUILDDIR)profiled/i810vb.o
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(i810_3d_reg.h, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810context.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810context.h, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810ioctl.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810ioctl.h, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810render.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810screen.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810screen.h, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810span.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810span.h, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810state.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810state.h, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810tex.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810tex.h, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810texmem.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810texstate.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810tris.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810tris.h, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810vb.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810vb.h, $(MESADRVSRCDIR)/i810)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/i915/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/i915/Imakefile
new file mode 100644
index 000000000..6aba077ba
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/i915/Imakefile
@@ -0,0 +1,72 @@
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
+
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(I915SRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(I915OBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(I915OBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = i915_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _i915_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/i915/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/i915/Imakefile.inc
new file mode 100644
index 000000000..56e7e3d93
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/i915/Imakefile.inc
@@ -0,0 +1,140 @@
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvI915BuildDir
+#define MesaDrvI915BuildDir /**/
+#endif
+MESADRVI915BUILDDIR = MesaDrvI915BuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86DRIVERSRC)/i810 \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+ I915SRCS = $(MESADRVI915BUILDDIR)i830_metaops.c \
+ $(MESADRVI915BUILDDIR)i830_context.c \
+ $(MESADRVI915BUILDDIR)i830_state.c \
+ $(MESADRVI915BUILDDIR)i830_tex.c \
+ $(MESADRVI915BUILDDIR)i830_texstate.c \
+ $(MESADRVI915BUILDDIR)i830_texblend.c \
+ $(MESADRVI915BUILDDIR)i830_vtbl.c \
+ $(MESADRVI915BUILDDIR)i915_metaops.c \
+ $(MESADRVI915BUILDDIR)i915_context.c \
+ $(MESADRVI915BUILDDIR)i915_debug.c \
+ $(MESADRVI915BUILDDIR)i915_fragprog.c \
+ $(MESADRVI915BUILDDIR)i915_state.c \
+ $(MESADRVI915BUILDDIR)i915_tex.c \
+ $(MESADRVI915BUILDDIR)i915_texprog.c \
+ $(MESADRVI915BUILDDIR)i915_texstate.c \
+ $(MESADRVI915BUILDDIR)i915_program.c \
+ $(MESADRVI915BUILDDIR)i915_vtbl.c \
+ $(MESADRVI915BUILDDIR)intel_batchbuffer.c \
+ $(MESADRVI915BUILDDIR)intel_context.c \
+ $(MESADRVI915BUILDDIR)intel_ioctl.c \
+ $(MESADRVI915BUILDDIR)intel_pixel.c \
+ $(MESADRVI915BUILDDIR)intel_render.c \
+ $(MESADRVI915BUILDDIR)intel_screen.c \
+ $(MESADRVI915BUILDDIR)intel_span.c \
+ $(MESADRVI915BUILDDIR)intel_state.c \
+ $(MESADRVI915BUILDDIR)intel_tex.c \
+ $(MESADRVI915BUILDDIR)intel_tris.c
+
+
+
+ I915OBJS = $(MESADRVI915BUILDDIR)i830_metaops.o \
+ $(MESADRVI915BUILDDIR)i830_context.o \
+ $(MESADRVI915BUILDDIR)i830_state.o \
+ $(MESADRVI915BUILDDIR)i830_tex.o \
+ $(MESADRVI915BUILDDIR)i830_texstate.o \
+ $(MESADRVI915BUILDDIR)i830_texblend.o \
+ $(MESADRVI915BUILDDIR)i830_vtbl.o \
+ $(MESADRVI915BUILDDIR)i915_metaops.o \
+ $(MESADRVI915BUILDDIR)i915_context.o \
+ $(MESADRVI915BUILDDIR)i915_debug.o \
+ $(MESADRVI915BUILDDIR)i915_fragprog.o \
+ $(MESADRVI915BUILDDIR)i915_state.o \
+ $(MESADRVI915BUILDDIR)i915_tex.o \
+ $(MESADRVI915BUILDDIR)i915_texprog.o \
+ $(MESADRVI915BUILDDIR)i915_texstate.o \
+ $(MESADRVI915BUILDDIR)i915_program.o \
+ $(MESADRVI915BUILDDIR)i915_vtbl.o \
+ $(MESADRVI915BUILDDIR)intel_batchbuffer.o \
+ $(MESADRVI915BUILDDIR)intel_context.o \
+ $(MESADRVI915BUILDDIR)intel_ioctl.o \
+ $(MESADRVI915BUILDDIR)intel_pixel.o \
+ $(MESADRVI915BUILDDIR)intel_render.o \
+ $(MESADRVI915BUILDDIR)intel_screen.o \
+ $(MESADRVI915BUILDDIR)intel_span.o \
+ $(MESADRVI915BUILDDIR)intel_state.o \
+ $(MESADRVI915BUILDDIR)intel_tex.o \
+ $(MESADRVI915BUILDDIR)intel_tris.o
+
+ I915UOBJS =
+ I915DOBJS =
+ I915POBJS =
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(i830_metaops.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i830_context.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i830_context.h, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i830_state.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i830_reg.h, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i830_tex.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i830_texstate.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i830_texblend.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i830_vtbl.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i915_metaops.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i915_context.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i915_context.h, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i915_debug.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i915_fragprog.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i915_state.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i915_tex.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i915_texprog.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i915_texstate.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i915_program.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i915_program.h, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i915_reg.h, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(i915_vtbl.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_batchbuffer.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_batchbuffer.h, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_context.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_context.h, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_ioctl.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_ioctl.h, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_pixel.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_reg.h, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_render.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_screen.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_screen.h, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_span.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_span.h, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_state.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_tex.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_tex.h, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_tris.c, $(MESADRVSRCDIR)/i915)
+LinkSourceFile(intel_tris.h, $(MESADRVSRCDIR)/i915)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/mach64/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/mach64/Imakefile
new file mode 100644
index 000000000..342ffd248
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/mach64/Imakefile
@@ -0,0 +1,77 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/mach64/Imakefile,v 1.23tsi Exp $
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
+
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(Mach64SRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(Mach64OBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(Mach64OBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = mach64_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _mach64_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/mach64/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/mach64/Imakefile.inc
new file mode 100644
index 000000000..b0074f170
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/mach64/Imakefile.inc
@@ -0,0 +1,131 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/mach64/Imakefile.inc,v 1.2 2001/05/02 15:06:03 dawes Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvMach64BuildDir
+#define MesaDrvMach64BuildDir /**/
+#endif
+MESADRVMach64BUILDDIR = MesaDrvMach64BuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder -DUSE_NEW_INTERFACE -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core/ \
+ -I$(XF86DRIVERSRC)/ati \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/mach64
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+ Mach64SRCS = $(MESADRVMach64BUILDDIR)mach64_context.c \
+ $(MESADRVMach64BUILDDIR)mach64_dd.c \
+ $(MESADRVMach64BUILDDIR)mach64_ioctl.c \
+ $(MESADRVMach64BUILDDIR)mach64_lock.c \
+ $(MESADRVMach64BUILDDIR)mach64_screen.c \
+ $(MESADRVMach64BUILDDIR)mach64_span.c \
+ $(MESADRVMach64BUILDDIR)mach64_state.c \
+ $(MESADRVMach64BUILDDIR)mach64_tex.c \
+ $(MESADRVMach64BUILDDIR)mach64_texmem.c \
+ $(MESADRVMach64BUILDDIR)mach64_texstate.c \
+ $(MESADRVMach64BUILDDIR)mach64_tris.c \
+ $(MESADRVMach64BUILDDIR)mach64_vb.c
+
+ Mach64OBJS = $(MESADRVMach64BUILDDIR)mach64_context.o \
+ $(MESADRVMach64BUILDDIR)mach64_dd.o \
+ $(MESADRVMach64BUILDDIR)mach64_ioctl.o \
+ $(MESADRVMach64BUILDDIR)mach64_lock.o \
+ $(MESADRVMach64BUILDDIR)mach64_screen.o \
+ $(MESADRVMach64BUILDDIR)mach64_span.o \
+ $(MESADRVMach64BUILDDIR)mach64_state.o \
+ $(MESADRVMach64BUILDDIR)mach64_tex.o \
+ $(MESADRVMach64BUILDDIR)mach64_texmem.o \
+ $(MESADRVMach64BUILDDIR)mach64_texstate.o \
+ $(MESADRVMach64BUILDDIR)mach64_tris.o \
+ $(MESADRVMach64BUILDDIR)mach64_vb.o
+
+ Mach64UOBJS = $(MESADRVMach64BUILDDIR)unshared/mach64_context.o \
+ $(MESADRVMach64BUILDDIR)unshared/mach64_dd.o \
+ $(MESADRVMach64BUILDDIR)unshared/mach64_ioctl.o \
+ $(MESADRVMach64BUILDDIR)unshared/mach64_lock.o \
+ $(MESADRVMach64BUILDDIR)unshared/mach64_screen.o \
+ $(MESADRVMach64BUILDDIR)unshared/mach64_span.o \
+ $(MESADRVMach64BUILDDIR)unshared/mach64_state.o \
+ $(MESADRVMach64BUILDDIR)unshared/mach64_tex.o \
+ $(MESADRVMach64BUILDDIR)unshared/mach64_texmem.o \
+ $(MESADRVMach64BUILDDIR)unshared/mach64_texstate.o \
+ $(MESADRVMach64BUILDDIR)unshared/mach64_tris.o \
+ $(MESADRVMach64BUILDDIR)unshared/mach64_vb.o
+
+ Mach64DOBJS = $(MESADRVMach64BUILDDIR)debugger/mach64_context.o \
+ $(MESADRVMach64BUILDDIR)debugger/mach64_dd.o \
+ $(MESADRVMach64BUILDDIR)debugger/mach64_ioctl.o \
+ $(MESADRVMach64BUILDDIR)debugger/mach64_lock.o \
+ $(MESADRVMach64BUILDDIR)debugger/mach64_screen.o \
+ $(MESADRVMach64BUILDDIR)debugger/mach64_span.o \
+ $(MESADRVMach64BUILDDIR)debugger/mach64_state.o \
+ $(MESADRVMach64BUILDDIR)debugger/mach64_tex.o \
+ $(MESADRVMach64BUILDDIR)debugger/mach64_texmem.o \
+ $(MESADRVMach64BUILDDIR)debugger/mach64_texstate.o \
+ $(MESADRVMach64BUILDDIR)debugger/mach64_tris.o \
+ $(MESADRVMach64BUILDDIR)debugger/mach64_vb.o
+
+ Mach64POBJS = $(MESADRVMach64BUILDDIR)profiled/mach64_context.o \
+ $(MESADRVMach64BUILDDIR)profiled/mach64_dd.o \
+ $(MESADRVMach64BUILDDIR)profiled/mach64_ioctl.o \
+ $(MESADRVMach64BUILDDIR)profiled/mach64_lock.o \
+ $(MESADRVMach64BUILDDIR)profiled/mach64_screen.o \
+ $(MESADRVMach64BUILDDIR)profiled/mach64_span.o \
+ $(MESADRVMach64BUILDDIR)profiled/mach64_state.o \
+ $(MESADRVMach64BUILDDIR)profiled/mach64_tex.o \
+ $(MESADRVMach64BUILDDIR)profiled/mach64_texmem.o \
+ $(MESADRVMach64BUILDDIR)profiled/mach64_texstate.o \
+ $(MESADRVMach64BUILDDIR)profiled/mach64_tris.o \
+ $(MESADRVMach64BUILDDIR)profiled/mach64_vb.o
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(mach64_reg.h, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_context.c, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_context.h, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_dd.c, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_dd.h, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_ioctl.c, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_ioctl.h, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_lock.c, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_lock.h, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_native_vb.c, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_native_vbtmp.h, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_screen.c, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_screen.h, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_span.c, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_span.h, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_state.c, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_state.h, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_tex.c, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_tex.h, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_texmem.c, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_texstate.c, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_tris.c, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_tris.h, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_vb.c, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_vb.h, $(MESADRVSRCDIR)/mach64)
+LinkSourceFile(mach64_vbtmp.h, $(MESADRVSRCDIR)/mach64)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/mga/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/mga/Imakefile
new file mode 100644
index 000000000..5df7b681d
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/mga/Imakefile
@@ -0,0 +1,78 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/mga/Imakefile,v 1.22 2002/02/23 00:45:50 dawes Exp $
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(MGASRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(MGAOBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(MGAOBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = mga_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _mga_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/mga/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/mga/Imakefile.inc
new file mode 100644
index 000000000..a21278779
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/mga/Imakefile.inc
@@ -0,0 +1,135 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/mga/Imakefile.inc,v 1.2 2001/05/02 15:06:03 dawes Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/src/drv
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvMgaBuildDir
+#define MesaDrvMgaBuildDir /**/
+#endif
+MESADRVMGABUILDDIR = MesaDrvMgaBuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder -DUSE_NEW_INTERFACE -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86DRIVERSRC)/mga \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/mga
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+ MGASRCS = $(MESADRVMGABUILDDIR)mgadd.c \
+ $(MESADRVMGABUILDDIR)mgarender.c \
+ $(MESADRVMGABUILDDIR)mgaioctl.c \
+ $(MESADRVMGABUILDDIR)mgapixel.c \
+ $(MESADRVMGABUILDDIR)mgaspan.c \
+ $(MESADRVMGABUILDDIR)mgastate.c \
+ $(MESADRVMGABUILDDIR)mgatex.c \
+ $(MESADRVMGABUILDDIR)mga_texcombine.c \
+ $(MESADRVMGABUILDDIR)mgatexmem.c \
+ $(MESADRVMGABUILDDIR)mga_texstate.c \
+ $(MESADRVMGABUILDDIR)mgatris.c \
+ $(MESADRVMGABUILDDIR)mgavb.c \
+ $(MESADRVMGABUILDDIR)mga_xmesa.c \
+
+ MGAOBJS = $(MESADRVMGABUILDDIR)mgadd.o \
+ $(MESADRVMGABUILDDIR)mgarender.o \
+ $(MESADRVMGABUILDDIR)mgaioctl.o \
+ $(MESADRVMGABUILDDIR)mgapixel.o \
+ $(MESADRVMGABUILDDIR)mgaspan.o \
+ $(MESADRVMGABUILDDIR)mgastate.o \
+ $(MESADRVMGABUILDDIR)mgatex.o \
+ $(MESADRVMGABUILDDIR)mga_texcombine.o \
+ $(MESADRVMGABUILDDIR)mgatexmem.o \
+ $(MESADRVMGABUILDDIR)mga_texstate.o \
+ $(MESADRVMGABUILDDIR)mgatris.o \
+ $(MESADRVMGABUILDDIR)mgavb.o \
+ $(MESADRVMGABUILDDIR)mga_xmesa.o
+
+ MGAUOBJS = $(MESADRVMGABUILDDIR)unshared/mgadd.o \
+ $(MESADRVMGABUILDDIR)unshared/mgarender.o \
+ $(MESADRVMGABUILDDIR)unshared/mgaioctl.o \
+ $(MESADRVMGABUILDDIR)unshared/mgapixel.o \
+ $(MESADRVMGABUILDDIR)unshared/mgaspan.o \
+ $(MESADRVMGABUILDDIR)unshared/mgastate.o \
+ $(MESADRVMGABUILDDIR)unshared/mgatex.o \
+ $(MESADRVMGABUILDDIR)unshared/mga_texcombine.o \
+ $(MESADRVMGABUILDDIR)unshared/mgatexmem.o \
+ $(MESADRVMGABUILDDIR)unshared/mga_texstate.o \
+ $(MESADRVMGABUILDDIR)unshared/mgatris.o \
+ $(MESADRVMGABUILDDIR)unshared/mgavb.o \
+ $(MESADRVMGABUILDDIR)unshared/mga_xmesa.o
+
+ MGADOBJS = $(MESADRVMGABUILDDIR)debugger/mgadd.o \
+ $(MESADRVMGABUILDDIR)debugger/mgarender.o \
+ $(MESADRVMGABUILDDIR)debugger/mgaioctl.o \
+ $(MESADRVMGABUILDDIR)debugger/mgapixel.o \
+ $(MESADRVMGABUILDDIR)debugger/mgaspan.o \
+ $(MESADRVMGABUILDDIR)debugger/mgastate.o \
+ $(MESADRVMGABUILDDIR)debugger/mgatex.o \
+ $(MESADRVMGABUILDDIR)debugger/mga_texcombine.o \
+ $(MESADRVMGABUILDDIR)debugger/mgatexmem.o \
+ $(MESADRVMGABUILDDIR)debugger/mga_texstate.o \
+ $(MESADRVMGABUILDDIR)debugger/mgatris.o \
+ $(MESADRVMGABUILDDIR)debugger/mgavb.o \
+ $(MESADRVMGABUILDDIR)debugger/mga_xmesa.o
+
+ MGAPOBJS = $(MESADRVMGABUILDDIR)profiled/mgadd.o \
+ $(MESADRVMGABUILDDIR)profiled/mgarender.o \
+ $(MESADRVMGABUILDDIR)profiled/mgaioctl.o \
+ $(MESADRVMGABUILDDIR)profiled/mgapixel.o \
+ $(MESADRVMGABUILDDIR)profiled/mgaspan.o \
+ $(MESADRVMGABUILDDIR)profiled/mgastate.o \
+ $(MESADRVMGABUILDDIR)profiled/mgatex.o \
+ $(MESADRVMGABUILDDIR)profiled/mga_texcombine.o \
+ $(MESADRVMGABUILDDIR)profiled/mgatexmem.o \
+ $(MESADRVMGABUILDDIR)profiled/mga_texstate.o \
+ $(MESADRVMGABUILDDIR)profiled/mgatris.o \
+ $(MESADRVMGABUILDDIR)profiled/mgavb.o \
+ $(MESADRVMGABUILDDIR)profiled/mga_xmesa.o
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(mgacontext.h, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgadd.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgadd.h, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgaioctl.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgaioctl.h, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgapixel.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgapixel.h, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgarender.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgaregs.h, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgaspan.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgaspan.h, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgastate.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgastate.h, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgatex.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgatex.h, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mga_texcombine.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgatexmem.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mga_texstate.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgatris.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgatris.h, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgavb.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgavb.h, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mga_xmesa.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mga_xmesa.h, $(MESADRVSRCDIR)/mga)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/r128/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/r128/Imakefile
new file mode 100644
index 000000000..d7ad07895
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/r128/Imakefile
@@ -0,0 +1,77 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/r128/Imakefile,v 1.19 2002/02/23 00:45:50 dawes Exp $
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(R128SRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(R128OBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(R128OBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = r128_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _r128_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/r128/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/r128/Imakefile.inc
new file mode 100644
index 000000000..35d7761e8
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/r128/Imakefile.inc
@@ -0,0 +1,123 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/r128/Imakefile.inc,v 1.3 2001/05/02 15:06:04 dawes Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvR128BuildDir
+#define MesaDrvR128BuildDir /**/
+#endif
+MESADRVR128BUILDDIR = MesaDrvR128BuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder -DUSE_NEW_INTERFACE -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86OSSRC) \
+ -I$(XF86COMSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86DRIVERSRC)/ati \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/r128
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+ R128SRCS = $(MESADRVR128BUILDDIR)r128_context.c \
+ $(MESADRVR128BUILDDIR)r128_dd.c \
+ $(MESADRVR128BUILDDIR)r128_ioctl.c \
+ $(MESADRVR128BUILDDIR)r128_lock.c \
+ $(MESADRVR128BUILDDIR)r128_screen.c \
+ $(MESADRVR128BUILDDIR)r128_span.c \
+ $(MESADRVR128BUILDDIR)r128_state.c \
+ $(MESADRVR128BUILDDIR)r128_tex.c \
+ $(MESADRVR128BUILDDIR)r128_texmem.c \
+ $(MESADRVR128BUILDDIR)r128_texstate.c \
+ $(MESADRVR128BUILDDIR)r128_tris.c
+
+ R128OBJS = $(MESADRVR128BUILDDIR)r128_context.o \
+ $(MESADRVR128BUILDDIR)r128_dd.o \
+ $(MESADRVR128BUILDDIR)r128_ioctl.o \
+ $(MESADRVR128BUILDDIR)r128_lock.o \
+ $(MESADRVR128BUILDDIR)r128_screen.o \
+ $(MESADRVR128BUILDDIR)r128_span.o \
+ $(MESADRVR128BUILDDIR)r128_state.o \
+ $(MESADRVR128BUILDDIR)r128_tex.o \
+ $(MESADRVR128BUILDDIR)r128_texmem.o \
+ $(MESADRVR128BUILDDIR)r128_texstate.o \
+ $(MESADRVR128BUILDDIR)r128_tris.o
+
+ R128UOBJS = $(MESADRVR128BUILDDIR)unshared/r128_context.o \
+ $(MESADRVR128BUILDDIR)unshared/r128_dd.o \
+ $(MESADRVR128BUILDDIR)unshared/r128_ioctl.o \
+ $(MESADRVR128BUILDDIR)unshared/r128_lock.o \
+ $(MESADRVR128BUILDDIR)unshared/r128_screen.o \
+ $(MESADRVR128BUILDDIR)unshared/r128_span.o \
+ $(MESADRVR128BUILDDIR)unshared/r128_state.o \
+ $(MESADRVR128BUILDDIR)unshared/r128_tex.o \
+ $(MESADRVR128BUILDDIR)unshared/r128_texmem.o \
+ $(MESADRVR128BUILDDIR)unshared/r128_texstate.o \
+ $(MESADRVR128BUILDDIR)unshared/r128_tris.o
+
+ R128DOBJS = $(MESADRVR128BUILDDIR)debugger/r128_context.o \
+ $(MESADRVR128BUILDDIR)debugger/r128_dd.o \
+ $(MESADRVR128BUILDDIR)debugger/r128_ioctl.o \
+ $(MESADRVR128BUILDDIR)debugger/r128_lock.o \
+ $(MESADRVR128BUILDDIR)debugger/r128_screen.o \
+ $(MESADRVR128BUILDDIR)debugger/r128_span.o \
+ $(MESADRVR128BUILDDIR)debugger/r128_state.o \
+ $(MESADRVR128BUILDDIR)debugger/r128_tex.o \
+ $(MESADRVR128BUILDDIR)debugger/r128_texmem.o \
+ $(MESADRVR128BUILDDIR)debugger/r128_texstate.o \
+ $(MESADRVR128BUILDDIR)debugger/r128_tris.o
+
+ R128POBJS = $(MESADRVR128BUILDDIR)profiled/r128_context.o \
+ $(MESADRVR128BUILDDIR)profiled/r128_dd.o \
+ $(MESADRVR128BUILDDIR)profiled/r128_ioctl.o \
+ $(MESADRVR128BUILDDIR)profiled/r128_lock.o \
+ $(MESADRVR128BUILDDIR)profiled/r128_screen.o \
+ $(MESADRVR128BUILDDIR)profiled/r128_span.o \
+ $(MESADRVR128BUILDDIR)profiled/r128_state.o \
+ $(MESADRVR128BUILDDIR)profiled/r128_tex.o \
+ $(MESADRVR128BUILDDIR)profiled/r128_texmem.o \
+ $(MESADRVR128BUILDDIR)profiled/r128_texstate.o \
+ $(MESADRVR128BUILDDIR)profiled/r128_tris.o
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(r128_context.c, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_context.h, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_dd.c, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_dd.h, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_ioctl.c, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_ioctl.h, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_lock.c, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_lock.h, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_screen.c, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_screen.h, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_span.c, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_span.h, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_state.c, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_state.h, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_tex.c, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_tex.h, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_texmem.c, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_texobj.h, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_texstate.c, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_tris.c, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_tris.h, $(MESADRVSRCDIR)/r128)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/r200/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/r200/Imakefile
new file mode 100644
index 000000000..5f8bb3846
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/r200/Imakefile
@@ -0,0 +1,78 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/r200/Imakefile,v 1.9 2002/02/23 00:45:50 dawes Exp $
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(R200SRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(R200OBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(R200OBJS))
+NormalLintTarget($(SRCS))
+
+ObjectFromAsmSource(r200_vtxtmp_x86, NullParameter)
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = r200_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _r200_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/r200/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/r200/Imakefile.inc
new file mode 100644
index 000000000..fa635e4ba
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/r200/Imakefile.inc
@@ -0,0 +1,200 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/r200/Imakefile.inc,v 1.2 2001/05/02 15:06:04 dawes Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvR200BuildDir
+#define MesaDrvR200BuildDir /**/
+#endif
+MESADRVR200BUILDDIR = MesaDrvR200BuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder -DUSE_NEW_INTERFACE -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86COMSRC) \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86DRIVERSRC)/ati \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/r200 \
+ -I$(MESADRVSRCDIR)/radeon/server
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+ R200SRCS = $(MESADRVR200BUILDDIR)r200_context.c \
+ $(MESADRVR200BUILDDIR)r200_sanity.c \
+ $(MESADRVR200BUILDDIR)r200_state.c \
+ $(MESADRVR200BUILDDIR)r200_state_init.c \
+ $(MESADRVR200BUILDDIR)r200_swtcl.c \
+ $(MESADRVR200BUILDDIR)r200_cmdbuf.c \
+ $(MESADRVR200BUILDDIR)r200_ioctl.c \
+ $(MESADRVR200BUILDDIR)r200_lock.c \
+ $(MESADRVR200BUILDDIR)r200_maos.c \
+ $(MESADRVR200BUILDDIR)r200_pixel.c \
+ $(MESADRVR200BUILDDIR)r200_screen.c \
+ $(MESADRVR200BUILDDIR)r200_span.c \
+ $(MESADRVR200BUILDDIR)r200_tcl.c \
+ $(MESADRVR200BUILDDIR)r200_tex.c \
+ $(MESADRVR200BUILDDIR)r200_texmem.c \
+ $(MESADRVR200BUILDDIR)r200_texstate.c \
+ $(MESADRVR200BUILDDIR)r200_vtxfmt.c \
+ $(MESADRVR200BUILDDIR)r200_vtxfmt_x86.c \
+ $(MESADRVR200BUILDDIR)r200_vtxtmp_x86.S \
+ $(MESADRVR200BUILDDIR)r200_vtxfmt_sse.c \
+ $(MESADRVR200BUILDDIR)r200_vtxfmt_c.c
+
+ R200OBJS = $(MESADRVR200BUILDDIR)r200_context.o \
+ $(MESADRVR200BUILDDIR)r200_sanity.o \
+ $(MESADRVR200BUILDDIR)r200_state.o \
+ $(MESADRVR200BUILDDIR)r200_state_init.o \
+ $(MESADRVR200BUILDDIR)r200_swtcl.o \
+ $(MESADRVR200BUILDDIR)r200_cmdbuf.o \
+ $(MESADRVR200BUILDDIR)r200_ioctl.o \
+ $(MESADRVR200BUILDDIR)r200_lock.o \
+ $(MESADRVR200BUILDDIR)r200_maos.o \
+ $(MESADRVR200BUILDDIR)r200_pixel.o \
+ $(MESADRVR200BUILDDIR)r200_screen.o \
+ $(MESADRVR200BUILDDIR)r200_span.o \
+ $(MESADRVR200BUILDDIR)r200_tcl.o \
+ $(MESADRVR200BUILDDIR)r200_tex.o \
+ $(MESADRVR200BUILDDIR)r200_texmem.o \
+ $(MESADRVR200BUILDDIR)r200_texstate.o \
+ $(MESADRVR200BUILDDIR)r200_vtxfmt.o \
+ $(MESADRVR200BUILDDIR)r200_vtxfmt_c.o
+
+#ifdef i386Architecture
+ R200OBJS += $(MESADRVR200BUILDDIR)r200_vtxfmt_x86.o \
+ $(MESADRVR200BUILDDIR)r200_vtxtmp_x86.o \
+ $(MESADRVR200BUILDDIR)r200_vtxfmt_sse.o
+#endif
+
+ R200UOBJS = $(MESADRVR200BUILDDIR)unshared/r200_context.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_sanity.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_cmdbuf.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_ioctl.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_lock.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_maos.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_pixel.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_screen.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_span.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_state.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_state_init.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_swtcl.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_tcl.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_tex.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_texmem.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_texstate.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_vtxfmt.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_vtxfmt_c.o
+
+#ifdef i386Architecture
+ R200UOBJS += $(MESADRVR200BUILDDIR)unshared/r200_vtxfmt_x86.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_vtxtmp_x86.o \
+ $(MESADRVR200BUILDDIR)unshared/r200_vtxfmt_sse.o
+#endif
+
+ R200DOBJS = $(MESADRVR200BUILDDIR)debugger/r200_context.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_sanity.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_cmdbuf.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_ioctl.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_lock.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_maos.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_pixel.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_screen.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_span.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_state.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_state_init.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_swtcl.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_tcl.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_tex.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_texmem.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_texstate.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_vtxfmt.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_vtxfmt_c.o
+
+#ifdef i386Architecture
+ R200DOBJS += $(MESADRVR200BUILDDIR)debugger/r200_vtxfmt_x86.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_vtxtmp_x86.o \
+ $(MESADRVR200BUILDDIR)debugger/r200_vtxfmt_sse.o
+#endif
+
+ R200POBJS = $(MESADRVR200BUILDDIR)profiled/r200_context.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_sanity.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_cmdbuf.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_ioctl.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_lock.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_maos.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_pixel.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_screen.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_span.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_state.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_state_init.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_swtcl.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_tcl.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_tex.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_texmem.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_texstate.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_vtxfmt.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_vtxfmt_c.o
+
+#ifdef i386Architecture
+ R200POBJS += $(MESADRVR200BUILDDIR)profiled/r200_vtxfmt_x86.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_vtxtmp_x86.o \
+ $(MESADRVR200BUILDDIR)profiled/r200_vtxfmt_sse.o
+#endif
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(r200_context.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_context.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_cmdbuf.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_ioctl.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_ioctl.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_lock.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_lock.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_maos.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_maos.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_pixel.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_pixel.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_reg.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_screen.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_screen.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_span.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_span.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_sanity.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_sanity.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_state.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_state.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_state_init.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_swtcl.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_swtcl.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_tcl.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_tcl.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_tex.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_tex.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_texmem.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_texstate.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_vtxfmt.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_vtxfmt.h, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_vtxfmt_c.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_vtxfmt_x86.c, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_vtxtmp_x86.S, $(MESADRVSRCDIR)/r200)
+LinkSourceFile(r200_vtxfmt_sse.c, $(MESADRVSRCDIR)/r200)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/radeon/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/radeon/Imakefile
new file mode 100644
index 000000000..69d28b248
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/radeon/Imakefile
@@ -0,0 +1,78 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/radeon/Imakefile,v 1.9 2002/02/23 00:45:50 dawes Exp $
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(RADEONSRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(RADEONOBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(RADEONOBJS))
+NormalLintTarget($(SRCS))
+
+ObjectFromAsmSource(radeon_vtxtmp_x86, NullParameter)
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = radeon_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _radeon_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/radeon/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/radeon/Imakefile.inc
new file mode 100644
index 000000000..9c95c5463
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/radeon/Imakefile.inc
@@ -0,0 +1,193 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/radeon/Imakefile.inc,v 1.3 2002/02/22 21:45:00 dawes Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvRadeonBuildDir
+#define MesaDrvRadeonBuildDir /**/
+#endif
+MESADRVRADEONBUILDDIR = MesaDrvRadeonBuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder -DUSE_NEW_INTERFACE -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86OSSRC) \
+ -I$(XF86COMSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86DRIVERSRC)/ati \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/radeon \
+ -I$(MESADRVSRCDIR)/radeon/server
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+ RADEONSRCS = $(MESADRVRADEONBUILDDIR)radeon_context.c \
+ $(MESADRVRADEONBUILDDIR)radeon_compat.c \
+ $(MESADRVRADEONBUILDDIR)radeon_ioctl.c \
+ $(MESADRVRADEONBUILDDIR)radeon_lock.c \
+ $(MESADRVRADEONBUILDDIR)radeon_maos.c \
+ $(MESADRVRADEONBUILDDIR)radeon_sanity.c \
+ $(MESADRVRADEONBUILDDIR)radeon_screen.c \
+ $(MESADRVRADEONBUILDDIR)radeon_span.c \
+ $(MESADRVRADEONBUILDDIR)radeon_state.c \
+ $(MESADRVRADEONBUILDDIR)radeon_state_init.c \
+ $(MESADRVRADEONBUILDDIR)radeon_swtcl.c \
+ $(MESADRVRADEONBUILDDIR)radeon_tcl.c \
+ $(MESADRVRADEONBUILDDIR)radeon_tex.c \
+ $(MESADRVRADEONBUILDDIR)radeon_texmem.c \
+ $(MESADRVRADEONBUILDDIR)radeon_texstate.c \
+ $(MESADRVRADEONBUILDDIR)radeon_vtxfmt.c \
+ $(MESADRVRADEONBUILDDIR)radeon_vtxfmt_x86.c \
+ $(MESADRVRADEONBUILDDIR)radeon_vtxtmp_x86.S \
+ $(MESADRVRADEONBUILDDIR)radeon_vtxfmt_sse.c \
+ $(MESADRVRADEONBUILDDIR)radeon_vtxfmt_c.c
+
+ RADEONOBJS = $(MESADRVRADEONBUILDDIR)radeon_context.o \
+ $(MESADRVRADEONBUILDDIR)radeon_compat.o \
+ $(MESADRVRADEONBUILDDIR)radeon_ioctl.o \
+ $(MESADRVRADEONBUILDDIR)radeon_lock.o \
+ $(MESADRVRADEONBUILDDIR)radeon_maos.o \
+ $(MESADRVRADEONBUILDDIR)radeon_sanity.o \
+ $(MESADRVRADEONBUILDDIR)radeon_screen.o \
+ $(MESADRVRADEONBUILDDIR)radeon_span.o \
+ $(MESADRVRADEONBUILDDIR)radeon_state.o \
+ $(MESADRVRADEONBUILDDIR)radeon_state_init.o \
+ $(MESADRVRADEONBUILDDIR)radeon_swtcl.o \
+ $(MESADRVRADEONBUILDDIR)radeon_tcl.o \
+ $(MESADRVRADEONBUILDDIR)radeon_tex.o \
+ $(MESADRVRADEONBUILDDIR)radeon_texmem.o \
+ $(MESADRVRADEONBUILDDIR)radeon_texstate.o \
+ $(MESADRVRADEONBUILDDIR)radeon_vtxfmt.o \
+ $(MESADRVRADEONBUILDDIR)radeon_vtxfmt_c.o
+
+#ifdef i386Architecture
+ RADEONOBJS += $(MESADRVRADEONBUILDDIR)radeon_vtxfmt_x86.o \
+ $(MESADRVRADEONBUILDDIR)radeon_vtxtmp_x86.o \
+ $(MESADRVRADEONBUILDDIR)radeon_vtxfmt_sse.o
+#endif
+
+ RADEONUOBJS = $(MESADRVRADEONBUILDDIR)unshared/radeon_context.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_compat.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_ioctl.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_lock.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_maos.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_sanity.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_screen.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_span.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_state.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_state_init.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_swtcl.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_tcl.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_tex.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_texmem.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_texstate.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_vtxfmt.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_vtxfmt_c.o
+
+#ifdef i386Architecture
+ RADEONUOBJS += $(MESADRVRADEONBUILDDIR)unshared/radeon_vtxfmt_x86.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_vtxtmp_x86.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_vtxfmt_sse.o
+#endif
+
+ RADEONDOBJS = $(MESADRVRADEONBUILDDIR)debugger/radeon_context.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_compat.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_ioctl.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_lock.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_maos.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_sanity.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_screen.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_span.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_state.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_state_init.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_swtcl.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_tcl.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_tex.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_texmem.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_texstate.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_vtxfmt.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_vtxfmt_c.o
+
+#ifdef i386Architecture
+ RADEONDOBJS += $(MESADRVRADEONBUILDDIR)debugger/radeon_vtxfmt_x86.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_vtxtmp_x86.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_vtxfmt_sse.o
+#endif
+
+ RADEONPOBJS = $(MESADRVRADEONBUILDDIR)profiled/radeon_context.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_compat.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_ioctl.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_lock.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_maos.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_sanity.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_screen.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_span.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_state.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_state_init.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_swtcl.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_tcl.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_tex.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_texmem.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_texstate.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_vtxfmt.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_vtxfmt_c.o
+
+#ifdef i386Architecture
+ RADEONPOBJS += $(MESADRVRADEONBUILDDIR)profiled/radeon_vtxfmt_x86.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_vtxtmp_x86.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_vtxfmt_sse.o
+#endif
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(radeon_context.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_context.h, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_compat.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_ioctl.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_ioctl.h, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_lock.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_lock.h, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_maos.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_maos.h, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_maos_vbtmp.h, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_sanity.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_sanity.h, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_screen.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_screen.h, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_span.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_span.h, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_state.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_state.h, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_state_init.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_swtcl.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_swtcl.h, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_tcl.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_tcl.h, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_tex.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_tex.h, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_texmem.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_texstate.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_vtxfmt.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_vtxfmt.h, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_vtxfmt_c.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_vtxfmt_x86.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_vtxtmp_x86.S, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_vtxfmt_sse.c, $(MESADRVSRCDIR)/radeon)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/savage/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/savage/Imakefile
new file mode 100644
index 000000000..8a8c8338b
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/savage/Imakefile
@@ -0,0 +1,78 @@
+XCOMM $XFree86$
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(SAVAGESRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(SAVAGEOBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(SAVAGEOBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = savage_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _savage_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/savage/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/savage/Imakefile.inc
new file mode 100644
index 000000000..4548f3d29
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/savage/Imakefile.inc
@@ -0,0 +1,105 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/mga/Imakefile.inc,v 1.2 2001/05/02 15:06:03 dawes Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/src/drv
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvSavageBuildDir
+#define MesaDrvSavageBuildDir /**/
+#endif
+MESADRVSAVAGEBUILDDIR = MesaDrvSavageBuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86COMSRC) \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86DRIVERSRC)/savage \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/savage
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+ SAVAGESRCS = $(MESADRVMGABUILDDIR)savagedd.c \
+ $(MESADRVMGABUILDDIR)savageioctl.c \
+ $(MESADRVMGABUILDDIR)savagerender.c \
+ $(MESADRVMGABUILDDIR)savagespan.c \
+ $(MESADRVMGABUILDDIR)savagestate.c \
+ $(MESADRVMGABUILDDIR)savagetex.c \
+ $(MESADRVMGABUILDDIR)savagetris.c \
+ $(MESADRVMGABUILDDIR)savage_xmesa.c
+
+ SAVAGEOBJS = $(MESADRVMGABUILDDIR)savagedd.o \
+ $(MESADRVMGABUILDDIR)savageioctl.o \
+ $(MESADRVMGABUILDDIR)savagerender.o \
+ $(MESADRVMGABUILDDIR)savagespan.o \
+ $(MESADRVMGABUILDDIR)savagestate.o \
+ $(MESADRVMGABUILDDIR)savagetex.o \
+ $(MESADRVMGABUILDDIR)savagetris.o \
+ $(MESADRVMGABUILDDIR)savage_xmesa.o
+
+ SAVAGEUOBJS = $(MESADRVMGABUILDDIR)unshared/savagedd.o \
+ $(MESADRVMGABUILDDIR)unshared/savageioctl.o \
+ $(MESADRVMGABUILDDIR)unshared/savagerender.o \
+ $(MESADRVMGABUILDDIR)unshared/savagespan.o \
+ $(MESADRVMGABUILDDIR)unshared/savagestate.o \
+ $(MESADRVMGABUILDDIR)unshared/savagetex.o \
+ $(MESADRVMGABUILDDIR)unshared/savagetris.o \
+ $(MESADRVMGABUILDDIR)unshared/savage_xmesa.o
+
+ SAVAGEDOBJS = $(MESADRVMGABUILDDIR)debugger/savagedd.o \
+ $(MESADRVMGABUILDDIR)debugger/savageioctl.o \
+ $(MESADRVMGABUILDDIR)debugger/savagerender.o \
+ $(MESADRVMGABUILDDIR)debugger/savagespan.o \
+ $(MESADRVMGABUILDDIR)debugger/savagestate.o \
+ $(MESADRVMGABUILDDIR)debugger/savagetex.o \
+ $(MESADRVMGABUILDDIR)debugger/savagetris.o \
+ $(MESADRVMGABUILDDIR)debugger/savage_xmesa.o
+
+ SAVAGEPOBJS = $(MESADRVMGABUILDDIR)profiled/savagedd.o \
+ $(MESADRVMGABUILDDIR)profiled/savageioctl.o \
+ $(MESADRVMGABUILDDIR)profiled/savagerender.o \
+ $(MESADRVMGABUILDDIR)profiled/savagespan.o \
+ $(MESADRVMGABUILDDIR)profiled/savagestate.o \
+ $(MESADRVMGABUILDDIR)profiled/savagetex.o \
+ $(MESADRVMGABUILDDIR)profiled/savagetris.o \
+ $(MESADRVMGABUILDDIR)profiled/savage_xmesa.o
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(savage_3d_reg.h, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savage_bci.h, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savagecontext.h, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savagedd.c, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savagedd.h, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savage_init.h, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savageioctl.c, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savageioctl.h, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savagerender.c, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savagespan.c, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savagespan.h, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savagestate.c, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savagestate.h, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savagetex.c, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savagetex.h, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savagetris.c, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savagetris.h, $(MESADRVSRCDIR)/savage)
+LinkSourceFile(savage_xmesa.c, $(MESADRVSRCDIR)/savage)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/sis/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/sis/Imakefile
new file mode 100644
index 000000000..c06601de1
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/sis/Imakefile
@@ -0,0 +1,80 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/sis/Imakefile,v 1.22 2002/11/25 14:04:52 eich Exp $
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+XCOMM DEBUG_DEFINES = -DDEBUG_LOCKING
+XCOMM DEBUG_DEFINES = -DSIS_DEBUG
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES) \
+ $(DEBUG_DEFINES)
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(SISSRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(SISOBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(SISOBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = sis_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _sis_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/sis/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/sis/Imakefile.inc
new file mode 100644
index 000000000..8aa776f08
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/sis/Imakefile.inc
@@ -0,0 +1,156 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/sis/Imakefile.inc,v 1.1 2001/03/23 19:18:43 dawes Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvSisBuildDir
+#define MesaDrvSisBuildDir /**/
+#endif
+MESADRVSISBUILDDIR = MesaDrvSisBuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines $(SIS_DEFINES) -DX_BYTE_ORDER=$(X_BYTE_ORDER) -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86DRIVERSRC)/sis \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/sis
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+#if 0
+ DEBUG_SRC = $(MESADRVSISBUILDDIR)sis_debug.c
+ DEBUG_OBJ = $(MESADRVSISBUILDDIR)sis_debug.o
+ DEBUG_UOBJ = $(MESADRVSISBUILDDIR)unshared/sis_debug.o
+ DEBUG_DOBJ = $(MESADRVSISBUILDDIR)debugger/sis_debug.o
+ DEBUG_POBJ = $(MESADRVSISBUILDDIR)profiled/sis_debug.o
+ DEBUG_DEFINES += -DSIS_DUMP
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(sis_debug.c, $(MESADRVSRCDIR)/sis)
+#endif
+#endif
+
+ SISSRCS = $(MESADRVSISBUILDDIR)sis_alloc.c \
+ $(MESADRVSISBUILDDIR)sis_dd.c \
+ $(MESADRVSISBUILDDIR)sis_lock.c \
+ $(MESADRVSISBUILDDIR)sis_context.c \
+ $(MESADRVSISBUILDDIR)sis_fog.c \
+ $(MESADRVSISBUILDDIR)sis_clear.c \
+ $(MESADRVSISBUILDDIR)sis_screen.c \
+ $(MESADRVSISBUILDDIR)sis_state.c \
+ $(MESADRVSISBUILDDIR)sis_stencil.c \
+ $(MESADRVSISBUILDDIR)sis_span.c \
+ $(MESADRVSISBUILDDIR)sis_tex.c \
+ $(MESADRVSISBUILDDIR)sis_texstate.c \
+ $(MESADRVSISBUILDDIR)sis_tris.c \
+ $(DEBUG_SRC)
+
+ SISOBJS = $(MESADRVSISBUILDDIR)sis_alloc.o \
+ $(MESADRVSISBUILDDIR)sis_dd.o \
+ $(MESADRVSISBUILDDIR)sis_lock.o \
+ $(MESADRVSISBUILDDIR)sis_context.o \
+ $(MESADRVSISBUILDDIR)sis_fog.o \
+ $(MESADRVSISBUILDDIR)sis_clear.o \
+ $(MESADRVSISBUILDDIR)sis_screen.o \
+ $(MESADRVSISBUILDDIR)sis_state.o \
+ $(MESADRVSISBUILDDIR)sis_stencil.o \
+ $(MESADRVSISBUILDDIR)sis_span.o \
+ $(MESADRVSISBUILDDIR)sis_tex.o \
+ $(MESADRVSISBUILDDIR)sis_texstate.o \
+ $(MESADRVSISBUILDDIR)sis_tris.o \
+ $(DEBUG_OBJ)
+
+ SISUOBJS = $(MESADRVSISBUILDDIR)unshared/sis_alloc.o \
+ $(MESADRVSISBUILDDIR)unshared/sis_dd.o \
+ $(MESADRVSISBUILDDIR)unshared/sis_lock.o \
+ $(MESADRVSISBUILDDIR)unshared/sis_context.o \
+ $(MESADRVSISBUILDDIR)unshared/sis_fog.o \
+ $(MESADRVSISBUILDDIR)unshared/sis_clear.o \
+ $(MESADRVSISBUILDDIR)unshared/sis_screen.o \
+ $(MESADRVSISBUILDDIR)unshared/sis_state.o \
+ $(MESADRVSISBUILDDIR)unshared/sis_stencil.o \
+ $(MESADRVSISBUILDDIR)unshared/sis_span.o \
+ $(MESADRVSISBUILDDIR)unshared/sis_tex.o \
+ $(MESADRVSISBUILDDIR)unshared/sis_texstate.o \
+ $(MESADRVSISBUILDDIR)unshared/sis_tris.o \
+ $(DEBUG_UOBJ)
+
+ SISDOBJS = $(MESADRVSISBUILDDIR)debugger/sis_alloc.o \
+ $(MESADRVSISBUILDDIR)debugger/sis_dd.o \
+ $(MESADRVSISBUILDDIR)debugger/sis_lock.o \
+ $(MESADRVSISBUILDDIR)debugger/sis_context.o \
+ $(MESADRVSISBUILDDIR)debugger/sis_fog.o \
+ $(MESADRVSISBUILDDIR)debugger/sis_clear.o \
+ $(MESADRVSISBUILDDIR)debugger/sis_screen.o \
+ $(MESADRVSISBUILDDIR)debugger/sis_state.o \
+ $(MESADRVSISBUILDDIR)debugger/sis_stencil.o \
+ $(MESADRVSISBUILDDIR)debugger/sis_span.o \
+ $(MESADRVSISBUILDDIR)debugger/sis_tex.o \
+ $(MESADRVSISBUILDDIR)debugger/sis_texstate.o \
+ $(MESADRVSISBUILDDIR)debugger/sis_tris.o \
+ $(DEBUG_DOBJ)
+
+ SISPOBJS = $(MESADRVSISBUILDDIR)profiled/sis_alloc.o \
+ $(MESADRVSISBUILDDIR)profiled/sis_dd.o \
+ $(MESADRVSISBUILDDIR)profiled/sis_lock.o \
+ $(MESADRVSISBUILDDIR)profiled/sis_context.o \
+ $(MESADRVSISBUILDDIR)profiled/sis_fog.o \
+ $(MESADRVSISBUILDDIR)profiled/sis_clear.o \
+ $(MESADRVSISBUILDDIR)profiled/sis_screen.o \
+ $(MESADRVSISBUILDDIR)profiled/sis_state.o \
+ $(MESADRVSISBUILDDIR)profiled/sis_stencil.o \
+ $(MESADRVSISBUILDDIR)profiled/sis_span.o \
+ $(MESADRVSISBUILDDIR)profiled/sis_tex.o \
+ $(MESADRVSISBUILDDIR)profiled/sis_texstate.o \
+ $(MESADRVSISBUILDDIR)profiled/sis_tris.o \
+ $(DEBUG_POBJ)
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(sis_alloc.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_alloc.h, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_common2.h, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_context.h, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_dd.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_dd.h, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_debug.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_debug.h, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_lock.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_lock.h, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_context.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_fog.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_clear.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_reg.h, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_screen.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_screen.h, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_state.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_state.h, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_stencil.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_stencil.h, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_span.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_span.h, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_tex.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_tex.h, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_texstate.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_tris.c, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_tris.h, $(MESADRVSRCDIR)/sis)
+LinkSourceFile(sis_tritmp.h, $(MESADRVSRCDIR)/sis)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/tdfx/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/tdfx/Imakefile
new file mode 100644
index 000000000..2e4c457e2
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/tdfx/Imakefile
@@ -0,0 +1,76 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/tdfx/Imakefile,v 1.30 2002/02/23 00:45:51 dawes Exp $
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(TDFXSRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(TDFXOBJS) $(COMMONOBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(TDFXOBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = tdfx_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _tdfx_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/tdfx/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/tdfx/Imakefile.inc
new file mode 100644
index 000000000..87d31fc31
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/tdfx/Imakefile.inc
@@ -0,0 +1,140 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/tdfx/Imakefile.inc,v 1.1 2001/03/23 19:18:44 dawes Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvTdfxBuildDir
+#define MesaDrvTdfxBuildDir /**/
+#endif
+MESADRVTDFXBUILDDIR = MesaDrvTdfxBuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder -DUSE_NEW_INTERFACE -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86DRIVERSRC)/tdfx \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/tdfx
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+ TDFXSRCS = $(MESADRVTDFXBUILDDIR)tdfx_context.c \
+ $(MESADRVTDFXBUILDDIR)tdfx_dd.c \
+ $(MESADRVTDFXBUILDDIR)tdfx_lock.c \
+ $(MESADRVTDFXBUILDDIR)tdfx_pixels.c \
+ $(MESADRVTDFXBUILDDIR)tdfx_render.c \
+ $(MESADRVTDFXBUILDDIR)tdfx_screen.c \
+ $(MESADRVTDFXBUILDDIR)tdfx_span.c \
+ $(MESADRVTDFXBUILDDIR)tdfx_state.c \
+ $(MESADRVTDFXBUILDDIR)tdfx_tex.c \
+ $(MESADRVTDFXBUILDDIR)tdfx_texman.c \
+ $(MESADRVTDFXBUILDDIR)tdfx_texstate.c \
+ $(MESADRVTDFXBUILDDIR)tdfx_tris.c \
+ $(MESADRVTDFXBUILDDIR)tdfx_vb.c
+
+ TDFXOBJS = $(MESADRVTDFXBUILDDIR)tdfx_context.o \
+ $(MESADRVTDFXBUILDDIR)tdfx_dd.o \
+ $(MESADRVTDFXBUILDDIR)tdfx_lock.o \
+ $(MESADRVTDFXBUILDDIR)tdfx_pixels.o \
+ $(MESADRVTDFXBUILDDIR)tdfx_render.o \
+ $(MESADRVTDFXBUILDDIR)tdfx_screen.o \
+ $(MESADRVTDFXBUILDDIR)tdfx_span.o \
+ $(MESADRVTDFXBUILDDIR)tdfx_state.o \
+ $(MESADRVTDFXBUILDDIR)tdfx_tex.o \
+ $(MESADRVTDFXBUILDDIR)tdfx_texman.o \
+ $(MESADRVTDFXBUILDDIR)tdfx_texstate.o \
+ $(MESADRVTDFXBUILDDIR)tdfx_tris.o \
+ $(MESADRVTDFXBUILDDIR)tdfx_vb.o
+
+ TDFXUOBJS = $(MESADRVTDFXBUILDDIR)unshared/tdfx_context.o \
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_dd.o \
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_lock.o \
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_pixels.o \
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_render.o \
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_screen.o \
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_span.o \
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_state.o \
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_tex.o \
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_texman.o \
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_texstate.o \
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_tris.o \
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_vb.o
+
+ TDFXDOBJS = $(MESADRVTDFXBUILDDIR)debugger/tdfx_context.o \
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_dd.o \
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_lock.o \
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_pixels.o \
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_render.o \
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_screen.o \
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_span.o \
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_state.o \
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_tex.o \
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_texman.o \
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_texstate.o \
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_tris.o \
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_vb.o
+
+ TDFXPOBJS = $(MESADRVTDFXBUILDDIR)profiled/tdfx_context.o \
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_dd.o \
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_lock.o \
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_pixels.o \
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_render.o \
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_screen.o \
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_span.o \
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_state.o \
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_tex.o \
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_texman.o \
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_texstate.o \
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_tris.o \
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_vb.o
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(dri_glide.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_context.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_context.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_dd.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_dd.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_glide.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_lock.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_lock.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_pixels.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_pixels.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_render.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_render.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_screen.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_screen.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_span.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_span.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_state.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_state.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_tex.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_tex.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_texman.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_texman.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_texstate.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_texstate.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_tris.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_tris.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_vb.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_vb.h, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_vbtmp.h, $(MESADRVSRCDIR)/tdfx)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/unichrome/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/unichrome/Imakefile
new file mode 100644
index 000000000..273e2ca6f
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/unichrome/Imakefile
@@ -0,0 +1,80 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/via/Imakefile,v 1.22 2002/11/25 14:04:52 eich Exp $
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+XCOMM DEBUG_DEFINES = -DDEBUG_LOCKING
+XCOMM DEBUG_DEFINES = -DVIA_DEBUG
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES) \
+ $(DEBUG_DEFINES)
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(VIASRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(VIAOBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(VIAOBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = unichrome_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _unichrome_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/unichrome/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/unichrome/Imakefile.inc
new file mode 100644
index 000000000..02916ee93
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/unichrome/Imakefile.inc
@@ -0,0 +1,123 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/via/Imakefile.inc,v 1.1 2001/03/23 19:18:43 dawes Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvViaBuildDir
+#define MesaDrvViaBuildDir /**/
+#endif
+MESADRVVIABUILDDIR = MesaDrvViaBuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines $(VIA_DEFINES) -DX_BYTE_ORDER=$(X_BYTE_ORDER) -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86COMSRC) \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86DRIVERSRC)/via \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/unichrome
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+
+ VIASRCS = $(MESADRVVIABUILDDIR)via_context.c \
+ $(MESADRVVIABUILDDIR)via_fb.c \
+ $(MESADRVVIABUILDDIR)via_ioctl.c \
+ $(MESADRVVIABUILDDIR)via_memcpy.c \
+ $(MESADRVVIABUILDDIR)via_render.c \
+ $(MESADRVVIABUILDDIR)via_screen.c \
+ $(MESADRVVIABUILDDIR)via_span.c \
+ $(MESADRVVIABUILDDIR)via_state.c \
+ $(MESADRVVIABUILDDIR)via_tex.c \
+ $(MESADRVVIABUILDDIR)via_texcombine.c \
+ $(MESADRVVIABUILDDIR)via_tris.c
+
+ VIAOBJS =$(MESADRVVIABUILDDIR)via_context.o \
+ $(MESADRVVIABUILDDIR)via_fb.o \
+ $(MESADRVVIABUILDDIR)via_ioctl.o \
+ $(MESADRVVIABUILDDIR)via_memcpy.o \
+ $(MESADRVVIABUILDDIR)via_render.o \
+ $(MESADRVVIABUILDDIR)via_screen.o \
+ $(MESADRVVIABUILDDIR)via_span.o \
+ $(MESADRVVIABUILDDIR)via_state.o \
+ $(MESADRVVIABUILDDIR)via_tex.o \
+ $(MESADRVVIABUILDDIR)via_texcombine.o \
+ $(MESADRVVIABUILDDIR)via_tris.o
+
+ VIAUOBJS =$(MESADRVVIABUILDDIR)/unshared/via_context.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_fb.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_ioctl.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_memcpy.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_render.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_screen.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_span.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_state.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_tex.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_texcombine.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_tris.o
+
+ VIADOBJS =$(MESADRVVIABUILDDIR)/debugger/via_context.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_fb.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_ioctl.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_memcpy.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_render.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_screen.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_span.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_state.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_tex.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_texcombine.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_tris.o
+
+ VIAPOBJS =$(MESADRVVIABUILDDIR)/profiled/via_context.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_fb.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_ioctl.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_memcpy.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_render.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_screen.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_span.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_state.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_tex.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_texcombine.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_tris.o
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(via_3d_reg.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_context.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_context.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_fb.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_fb.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_ioctl.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_ioctl.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_memcpy.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_render.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_screen.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_screen.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_span.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_span.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_state.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_state.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_tex.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_texcombine.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_tex.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_tris.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_tris.h, $(MESADRVSRCDIR)/unichrome)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/via/Imakefile b/nx-X11/lib/GL/mesa/drivers/dri/via/Imakefile
new file mode 100644
index 000000000..f92da2401
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/via/Imakefile
@@ -0,0 +1,80 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/via/Imakefile,v 1.22 2002/11/25 14:04:52 eich Exp $
+
+#include <Threads.tmpl>
+
+#if GlxUseBuiltInDRIDriver
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtrasLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#define MesaDrvCommonBuildDir ../common/
+#include "../common/Imakefile.inc"
+#include "../../../array_cache/Imakefile.inc"
+#include "../../../main/Imakefile.inc"
+#include "../../../math/Imakefile.inc"
+#include "../../../shader/Imakefile.inc"
+#include "../../../shader/grammar/Imakefile.inc"
+#include "../../../shader/slang/Imakefile.inc"
+#include "../../../shader/slang/library/Imakefile.inc"
+#include "../../../swrast/Imakefile.inc"
+#include "../../../swrast_setup/Imakefile.inc"
+#include "../../../tnl/Imakefile.inc"
+#include "../../../tnl_dd/Imakefile.inc"
+#include "../../../Imakefile.inc"
+#if defined(i386Architecture) && MesaUseX86Asm
+#include "../../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../../sparc/Imakefile.inc"
+#endif
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+XCOMM DEBUG_DEFINES = -DDEBUG_LOCKING
+XCOMM DEBUG_DEFINES = -DVIA_DEBUG
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES) \
+ $(DEBUG_DEFINES)
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
+
+ SRCS = $(VIASRCS)
+ OBJS = $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(VIAOBJS)
+
+REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) $(EXPATLIB)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(VIAOBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = via_dri.so
+SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _via_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/dri/via/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/dri/via/Imakefile.inc
new file mode 100644
index 000000000..9cfe68a75
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/dri/via/Imakefile.inc
@@ -0,0 +1,158 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/via/Imakefile.inc,v 1.1 2001/03/23 19:18:43 dawes Exp $
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+#ifndef MesaDrvViaBuildDir
+#define MesaDrvViaBuildDir /**/
+#endif
+MESADRVVIABUILDDIR = MesaDrvViaBuildDir
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines $(VIA_DEFINES) -DX_BYTE_ORDER=$(X_BYTE_ORDER) -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(XINCLUDESRC) \
+ -I$(GLXLIBSRC)/glx \
+ -I$(GLXLIBSRC)/include \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86DRIVERSRC)/via \
+ -I$(GLXLIBSRC)/dri/drm
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/unichrome
+ X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+#if 0
+ DEBUG_SRC = $(MESADRVVIABUILDDIR)via_debug.c
+ DEBUG_OBJ = $(MESADRVVIABUILDDIR)via_debug.o
+ DEBUG_UOBJ = $(MESADRVVIABUILDDIR)unshared/via_debug.o
+ DEBUG_DOBJ = $(MESADRVVIABUILDDIR)debugger/via_debug.o
+ DEBUG_POBJ = $(MESADRVVIABUILDDIR)profiled/via_debug.o
+ DEBUG_DEFINES += -DVIA_DUMP
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(via_debug.c, $(MESADRVSRCDIR)/unichrome)
+#endif
+#endif
+
+ VIASRCS = $(MESADRVVIABUILDDIR)via_context.c \
+ $(MESADRVVIABUILDDIR)via_fb.c \
+ $(MESADRVVIABUILDDIR)via_ioctl.c \
+ $(MESADRVVIABUILDDIR)via_render.c \
+ $(MESADRVVIABUILDDIR)via_screen.c \
+ $(MESADRVVIABUILDDIR)via_span.c \
+ $(MESADRVVIABUILDDIR)via_state.c \
+ $(MESADRVVIABUILDDIR)via_tex.c \
+ $(MESADRVVIABUILDDIR)via_texmem.c \
+ $(MESADRVVIABUILDDIR)via_texstate.c \
+ $(MESADRVVIABUILDDIR)via_tris.c \
+ $(MESADRVVIABUILDDIR)via_vb.c \
+ $(MESADRVVIABUILDDIR)xf86drmVIA.c \
+ $(DEBUG_SRC)
+
+ VIAOBJS =$(MESADRVVIABUILDDIR)via_context.o \
+ $(MESADRVVIABUILDDIR)via_fb.o \
+ $(MESADRVVIABUILDDIR)via_ioctl.o \
+ $(MESADRVVIABUILDDIR)via_render.o \
+ $(MESADRVVIABUILDDIR)via_screen.o \
+ $(MESADRVVIABUILDDIR)via_span.o \
+ $(MESADRVVIABUILDDIR)via_state.o \
+ $(MESADRVVIABUILDDIR)via_tex.o \
+ $(MESADRVVIABUILDDIR)via_texmem.o \
+ $(MESADRVVIABUILDDIR)via_texstate.o \
+ $(MESADRVVIABUILDDIR)via_tris.o \
+ $(MESADRVVIABUILDDIR)via_vb.o \
+ $(MESADRVVIABUILDDIR)xf86drmVIA.o \
+ $(DEBUG_OBJ)
+
+
+ VIAUOBJS =$(MESADRVVIABUILDDIR)/unshared/via_context.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_fb.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_ioctl.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_render.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_screen.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_span.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_state.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_tex.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_texmem.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_texstate.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_tris.o \
+ $(MESADRVVIABUILDDIR)/unshared/via_vb.o \
+ $(MESADRVVIABUILDDIR)/unshared/xf86drmVIA.o \
+ $(DEBUG_UOBJ)
+
+ VIADOBJS =$(MESADRVVIABUILDDIR)/debugger/via_context.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_fb.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_ioctl.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_render.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_screen.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_span.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_state.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_tex.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_texmem.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_texstate.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_tris.o \
+ $(MESADRVVIABUILDDIR)/debugger/via_vb.o \
+ $(MESADRVVIABUILDDIR)/debugger/xf86drmVIA.o \
+ $(DEBUG_DOBJ)
+
+ VIAPOBJS =$(MESADRVVIABUILDDIR)/profiled/via_context.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_fb.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_ioctl.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_render.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_screen.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_span.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_state.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_tex.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_texmem.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_texstate.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_tris.o \
+ $(MESADRVVIABUILDDIR)/profiled/via_vb.o \
+ $(MESADRVVIABUILDDIR)/profiled/xf86drmVIA.o \
+ $(DEBUG_POBJ)
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(via_3d_reg.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_context.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_dd_tritmp.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_dd_vbtmp.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_dmatmp.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_dri.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_fb.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_fb.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_ioctl.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_ioctl.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_render.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_screen.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_screen.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_span.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_span.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_state.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_state.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_tex.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_tex.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_texmem.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_texstate.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_tris.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_tris.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_vb.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_vb_cliptmp.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_vb.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(via_vb_rendertmp.h, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(xf86drmVIA.c, $(MESADRVSRCDIR)/unichrome)
+LinkSourceFile(xf86drmVIA.h, $(MESADRVSRCDIR)/unichrome)
+#endif
diff --git a/nx-X11/lib/GL/mesa/drivers/osmesa/Imakefile b/nx-X11/lib/GL/mesa/drivers/osmesa/Imakefile
new file mode 100644
index 000000000..014945699
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/osmesa/Imakefile
@@ -0,0 +1,111 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/OSmesa/Imakefile,v 1.16 2002/11/25 14:04:50 eich Exp $
+
+#include <Threads.tmpl>
+
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+
+/* Large PIC tables needed for Solaris SPARC builds */
+#if (defined(SunArchitecture) && defined(SparcArchitecture))
+# define LargePICTable YES
+#endif
+
+#include "../../array_cache/Imakefile.inc"
+#include "../../math/Imakefile.inc"
+#include "../../main/Imakefile.inc"
+#include "../../shader/Imakefile.inc"
+#include "../../shader/grammar/Imakefile.inc"
+#include "../../shader/slang/Imakefile.inc"
+#include "../../swrast/Imakefile.inc"
+#include "../../swrast_setup/Imakefile.inc"
+#include "../../tnl/Imakefile.inc"
+#include "../../tnl_dd/Imakefile.inc"
+#include "../../Imakefile.inc"
+#if defined(i386Architecture) && !SystemV4 && MesaUseX86Asm
+#include "../../x86/Imakefile.inc"
+#endif
+#ifdef SparcArchitecture
+#include "../../sparc/Imakefile.inc"
+#endif
+
+LinkSourceFile(osmesa.c, $(MESASRCDIR)/src/mesa/drivers/osmesa)
+LinkSourceFile(driverfuncs.c, $(MESASRCDIR)/src/mesa/drivers/common)
+LinkSourceFile(driverfuncs.h, $(MESASRCDIR)/src/mesa/drivers/common)
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/include
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES)
+ INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC) $(MESA_INCLUDES) \
+ $(DRI_INCLUDES) -I$(GLXLIBSRC)/include
+
+ MESAOBJS = $(COREMESAOBJS) $(MESA_ASM_OBJS)
+ MESAUOBJS = $(COREMESAUOBJS) $(MESA_ASM_UOBJS)
+ MESADOBJS = $(COREMESADOBJS) $(MESA_ASM_DOBJS)
+ MESAPOBJS = $(COREMESAPOBJS) $(MESA_ASM_POBJS)
+
+ SRCS = osmesa.c driverfuncs.c
+ OBJS = osmesa.o driverfuncs.o $(MESAOBJS)
+#if DoSharedLib
+ UOBJS = unshared/osmesa.o unshared/driverfuncs.o $(MESAUOBJS)
+#else
+ UOBJS = $(OBJS)
+#endif
+ DOBJS = debugger/osmesa.o debugger/driverfuncs.o $(MESADOBJS)
+ POBJS = profiled/osmesa.o profiled/driverfuncs.o $(MESAPOBJS)
+
+#if LocalThreads
+ THREADOBJS = $(THREADS_LIBS)
+#endif
+
+#if !GlxUseBuiltInDRIDriver
+# ifdef SharedOSMesaReqs
+ REQUIREDLIBS = SharedOSMesaReqs
+# else
+ REQUIREDLIBS = MathLibrary $(LDPRELIB) $(XLIB) $(GLXLIB)
+# endif
+#endif
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+LIBNAME = OSMesa
+SOREV = 4.0
+
+
+#if DoNormalLib
+NormalLibraryTarget($(LIBNAME), $(UOBJS))
+InstallLibrary($(LIBNAME),$(USRLIBDIR))
+#endif
+
+#if SharedLibGlx
+SharedLibraryTarget($(LIBNAME),$(SOREV), $(OBJS), ., .)
+InstallSharedLibrary($(LIBNAME),$(SOREV),$(SHLIBDIR))
+#endif
+
+#if DoDebugLib
+DebuggedLibraryTarget($(LIBNAME),$(DOBJS))
+InstallLibrary($(LIBNAME_d,$(USRLIBDIR))
+#endif
+
+#if DoProfileLib
+ProfiledLibraryTarget($(LIBNAME), $(POBJS))
+InstallLibrary($(LIBNAME)_p,$(USRLIBDIR))
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/GL/mesa/drivers/osmesa/OSMesa-def.cpp b/nx-X11/lib/GL/mesa/drivers/osmesa/OSMesa-def.cpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/osmesa/OSMesa-def.cpp
diff --git a/nx-X11/lib/GL/mesa/drivers/x11/Imakefile b/nx-X11/lib/GL/mesa/drivers/x11/Imakefile
new file mode 100644
index 000000000..ab9a91970
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/x11/Imakefile
@@ -0,0 +1,70 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/X/Imakefile,v 1.12tsi Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if BuildOSMesaLib || (BuildXF86DRI && (GlxDriverUsesMesa || GlxBuiltInXMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+
+#define MesaXBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I.. \
+ -I$(INCLUDESRC)/GL -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESASRCDIR)/src/X \
+ -I$(MESASRCDIR)/include \
+ -I../../../include -I$(XINCLUDESRC)
+
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+#if BuildXF86DRI && GlxBuiltInXMesa
+ XMESA_DEFINES = -DGLX_BUILT_IN_XMESA
+#endif
+
+ SRCS = $(XMESA_SRCS)
+ OBJS = $(XMESA_OBJS)
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MATHDEF) $(XMESA_DEFINES)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(XMESA_OBJS))
+NormalLintTarget($(XMESA_SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/drivers/x11/Imakefile.inc b/nx-X11/lib/GL/mesa/drivers/x11/Imakefile.inc
new file mode 100644
index 000000000..d62800e7d
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/drivers/x11/Imakefile.inc
@@ -0,0 +1,104 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/X/Imakefile.inc,v 1.3tsi Exp $
+
+#ifndef MesaXBuildDir
+#define MesaXBuildDir $(GLXLIBSRC)/src/mesa/drivers/x11/
+#endif
+
+MESAXBUILDDIR = MesaXBuildDir
+
+#ifndef MesaInXServer
+XMESA_GLX_SRCS = $(MESAXBUILDDIR)fakeglx.c \
+ $(MESAXBUILDDIR)glxapi.c \
+ $(MESAXBUILDDIR)realglx.c \
+ $(MESAXBUILDDIR)xfonts.c
+#endif
+
+ XMESA_SRCS = $(XMESA_GLX_SRCS) \
+ $(MESAXBUILDDIR)xm_api.c \
+ $(MESAXBUILDDIR)xm_buffer.c \
+ $(MESAXBUILDDIR)xm_dd.c \
+ $(MESAXBUILDDIR)xm_line.c \
+ $(MESAXBUILDDIR)xm_span.c \
+ $(MESAXBUILDDIR)xm_tri.c
+
+#ifdef NeedToLinkMesaSrc
+#ifndef MesaInXServer
+LinkSourceFile(fakeglx.c, $(MESASRCDIR)/src/mesa/drivers/x11)
+LinkSourceFile(glxapi.c, $(MESASRCDIR)/src/mesa/drivers/x11)
+LinkSourceFile(glxapi.h, $(MESASRCDIR)/src/mesa/drivers/x11)
+LinkSourceFile(realglx.c, $(MESASRCDIR)/src/mesa/drivers/x11)
+LinkSourceFile(xfonts.c, $(MESASRCDIR)/src/mesa/drivers/x11)
+#endif
+LinkSourceFile(xm_api.c, $(MESASRCDIR)/src/mesa/drivers/x11)
+LinkSourceFile(xm_buffer.c, $(MESASRCDIR)/src/mesa/drivers/x11)
+LinkSourceFile(xm_dd.c, $(MESASRCDIR)/src/mesa/drivers/x11)
+LinkSourceFile(xm_line.c, $(MESASRCDIR)/src/mesa/drivers/x11)
+LinkSourceFile(xm_span.c, $(MESASRCDIR)/src/mesa/drivers/x11)
+LinkSourceFile(xm_tri.c, $(MESASRCDIR)/src/mesa/drivers/x11)
+#endif
+
+#ifndef MesaInXServer
+XMESA_GLX_OBJS = $(MESAXBUILDDIR)fakeglx.o \
+ $(MESAXBUILDDIR)glxapi.o \
+ $(MESAXBUILDDIR)realglx.o \
+ $(MESAXBUILDDIR)xfonts.o
+#endif
+
+ XMESA_OBJS = $(XMESA_GLX_OBJS) \
+ $(MESAXBUILDDIR)xm_api.o \
+ $(MESAXBUILDDIR)xm_buffer.o \
+ $(MESAXBUILDDIR)xm_dd.o \
+ $(MESAXBUILDDIR)xm_line.o \
+ $(MESAXBUILDDIR)xm_span.o \
+ $(MESAXBUILDDIR)xm_tri.o
+
+#if defined(DoSharedLib) && DoSharedLib
+#ifndef MesaInXServer
+XMESA_GLX_UOBJS = $(MESAXBUILDDIR)unshared/fakeglx.o \
+ $(MESAXBUILDDIR)unshared/glxapi.o \
+ $(MESAXBUILDDIR)unshared/realglx.o \
+ $(MESAXBUILDDIR)unshared/xfonts.o
+#endif
+
+ XMESA_UOBJS = $(XMESA_GLX_UOBJS) \
+ $(MESAXBUILDDIR)unshared/xm_api.o \
+ $(MESAXBUILDDIR)unshared/xm_buffer.o \
+ $(MESAXBUILDDIR)unshared/xm_dd.o \
+ $(MESAXBUILDDIR)unshared/xm_line.o \
+ $(MESAXBUILDDIR)unshared/xm_span.o \
+ $(MESAXBUILDDIR)unshared/xm_tri.o
+#else
+XMESA_GLX_UOBJS = $(XMESA_GLX_OBJS)
+ XMESA_UOBJS = $(XMESA_OBJS)
+#endif
+
+#ifndef MesaInXServer
+XMESA_GLX_DOBJS = $(MESAXBUILDDIR)debugger/fakeglx.o \
+ $(MESAXBUILDDIR)debugger/glxapi.o \
+ $(MESAXBUILDDIR)debugger/realglx.o \
+ $(MESAXBUILDDIR)debugger/xfonts.o
+#endif
+
+ XMESA_DOBJS = $(XMESA_GLX_DOBJS) \
+ $(MESAXBUILDDIR)debugger/xm_api.o \
+ $(MESAXBUILDDIR)debugger/xm_buffer.o \
+ $(MESAXBUILDDIR)debugger/xm_dd.o \
+ $(MESAXBUILDDIR)debugger/xm_line.o \
+ $(MESAXBUILDDIR)debugger/xm_span.o \
+ $(MESAXBUILDDIR)debugger/xm_tri.o
+
+#ifndef MesaInXServer
+XMESA_GLX_POBJS = $(MESAXBUILDDIR)profiled/fakeglx.o \
+ $(MESAXBUILDDIR)profiled/glxapi.o \
+ $(MESAXBUILDDIR)profiled/realglx.o \
+ $(MESAXBUILDDIR)profiled/xfonts.o
+#endif
+
+ XMESA_POBJS = $(XMESA_GLX_POBJS) \
+ $(MESAXBUILDDIR)profiled/xm_api.o \
+ $(MESAXBUILDDIR)profiled/xm_buffer.o \
+ $(MESAXBUILDDIR)profiled/xm_dd.o \
+ $(MESAXBUILDDIR)profiled/xm_line.o \
+ $(MESAXBUILDDIR)profiled/xm_span.o \
+ $(MESAXBUILDDIR)profiled/xm_tri.o
+
diff --git a/nx-X11/lib/GL/mesa/main/Imakefile b/nx-X11/lib/GL/mesa/main/Imakefile
new file mode 100644
index 000000000..3093cedd1
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/main/Imakefile
@@ -0,0 +1,66 @@
+XCOMM $XdotOrg: xc/lib/GL/mesa/main/Imakefile,v 1.3 2005/12/20 22:30:49 alanc Exp $
+XCOMM $XFree86: xc/lib/GL/mesa/src/Imakefile,v 1.30tsi Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if BuildOSMesaLib || (BuildXF86DRI && (GlxDriverUsesMesa || GlxBuiltInXMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+/* Large PIC tables needed for Solaris/SPARC builds */
+#if defined(SunArchitecture) && defined(SparcArchitecture) && defined(LargePositionIndependentCFlags)
+# define LargePICTable YES
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#define MesaBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+#ifdef UseCompaqMathLibrary
+ MATH_DEFINES = -DCCPML
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) GlxDefines -DIN_DRI_DRIVER \
+ $(MESA_ASM_DEFINES) $(MATH_DEFINES)
+ INCLUDES = /*-I$(INCLUDESRC) -I$(EXTINCSRC) */ -I$(XINCLUDESRC) \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/math \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa -I$(GLXLIBSRC)/dri \
+ -I$(MESASRCDIR)/include -I$(GLXLIBSRC)/include
+ SRCS = $(COREMESABASESRCS)
+ OBJS = $(COREMESABASEOBJS)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/main/Imakefile.inc b/nx-X11/lib/GL/mesa/main/Imakefile.inc
new file mode 100644
index 000000000..5deaf1038
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/main/Imakefile.inc
@@ -0,0 +1,484 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/Imakefile.inc,v 1.7tsi Exp $
+
+#ifndef MesaBuildDir
+#define MesaBuildDir $(GLXLIBSRC)/mesa/main/
+#endif
+
+MESABUILDDIR = MesaBuildDir
+
+#ifdef NeedAllMesaSrc
+ DISPATCHSRCS = $(MESABUILDDIR)dispatch.c
+ GLAPISRCS = $(MESABUILDDIR)glapi.c
+ GLTHREADSRCS = $(MESABUILDDIR)glthread.c
+#endif
+
+MESA_CORE_INCLUDES = -I$(MESASRCDIR)/src/array_cache \
+ -I$(MESASRCDIR)/src/math -I$(MESASRCDIR)/src/shader \
+ -I$(MESASRCDIR)/src/swrast -I$(MESASRCDIR)/src/swrast_setup \
+ -I$(MESASRCDIR)/src/tnl -I$(MESASRCDIR)/src/tnl_dd
+
+COREMESABASESRCS = \
+ $(MESABUILDDIR)api_arrayelt.c \
+ $(MESABUILDDIR)api_loopback.c \
+ $(MESABUILDDIR)api_noop.c \
+ $(MESABUILDDIR)api_validate.c \
+ $(MESABUILDDIR)accum.c \
+ $(MESABUILDDIR)attrib.c \
+ $(MESABUILDDIR)blend.c \
+ $(MESABUILDDIR)bufferobj.c \
+ $(MESABUILDDIR)buffers.c \
+ $(MESABUILDDIR)clip.c \
+ $(MESABUILDDIR)colortab.c \
+ $(MESABUILDDIR)context.c \
+ $(MESABUILDDIR)convolve.c \
+ $(MESABUILDDIR)debug.c \
+ $(MESABUILDDIR)depth.c \
+ $(MESABUILDDIR)dlist.c \
+ $(MESABUILDDIR)drawpix.c \
+ $(MESABUILDDIR)enable.c \
+ $(MESABUILDDIR)enums.c \
+ $(MESABUILDDIR)eval.c \
+ $(MESABUILDDIR)execmem.c \
+ $(MESABUILDDIR)extensions.c \
+ $(MESABUILDDIR)feedback.c \
+ $(MESABUILDDIR)fbobject.c \
+ $(MESABUILDDIR)fog.c \
+ $(MESABUILDDIR)framebuffer.c \
+ $(MESABUILDDIR)get.c \
+ $(MESABUILDDIR)getstring.c \
+ $(MESABUILDDIR)hash.c \
+ $(MESABUILDDIR)hint.c \
+ $(MESABUILDDIR)histogram.c \
+ $(MESABUILDDIR)image.c \
+ $(MESABUILDDIR)imports.c \
+ $(MESABUILDDIR)light.c \
+ $(MESABUILDDIR)lines.c \
+ $(MESABUILDDIR)matrix.c \
+ $(MESABUILDDIR)mm.c \
+ $(MESABUILDDIR)occlude.c \
+ $(MESABUILDDIR)pixel.c \
+ $(MESABUILDDIR)points.c \
+ $(MESABUILDDIR)polygon.c \
+ $(MESABUILDDIR)rastpos.c \
+ $(MESABUILDDIR)renderbuffer.c \
+ $(MESABUILDDIR)state.c \
+ $(MESABUILDDIR)stencil.c \
+ $(MESABUILDDIR)texcompress.c \
+ $(MESABUILDDIR)texcompress_fxt1.c \
+ $(MESABUILDDIR)texcompress_s3tc.c \
+ $(MESABUILDDIR)texenvprogram.c \
+ $(MESABUILDDIR)texformat.c \
+ $(MESABUILDDIR)teximage.c \
+ $(MESABUILDDIR)texobj.c \
+ $(MESABUILDDIR)texrender.c \
+ $(MESABUILDDIR)texstate.c \
+ $(MESABUILDDIR)texstore.c \
+ $(MESABUILDDIR)varray.c \
+ $(MESABUILDDIR)vtxfmt.c
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(api_arrayelt.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(api_arrayelt.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(api_eval.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(api_loopback.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(api_loopback.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(api_noop.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(api_noop.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(api_validate.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(api_validate.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(accum.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(accum.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(attrib.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(attrib.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(blend.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(blend.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(bufferobj.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(bufferobj.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(buffers.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(buffers.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(clip.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(clip.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(colormac.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(colortab.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(colortab.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(config.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(context.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(context.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(convolve.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(convolve.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(dd.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(debug.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(debug.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(depth.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(depth.h, $(MESASRCDIR)/src/mesa/main)
+#ifdef NeedAllMesaSrc
+LinkSourceFile(dispatch.c, $(MESASRCDIR)/src/mesa/main)
+#endif
+LinkSourceFile(dlist.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(dlist.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(drawpix.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(drawpix.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(enable.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(enable.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(enums.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(enums.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(eval.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(eval.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(execmem.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(extensions.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(extensions.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(fbobject.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(fbobject.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(feedback.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(feedback.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(fog.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(fog.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(framebuffer.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(framebuffer.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(get.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(get.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(getstring.c, $(MESASRCDIR)/src/mesa/main)
+#ifdef NeedAllMesaSrc
+LinkSourceFile(glapi.c, $(MESASRCDIR)/src/mesa/glapi)
+LinkSourceFile(glthread.c, $(MESASRCDIR)/src/mesa/glapi)
+#endif
+LinkSourceFile(glheader.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(hash.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(hash.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(hint.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(hint.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(histogram.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(histogram.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(image.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(image.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(imports.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(imports.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(light.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(light.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(lines.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(lines.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(macros.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(matrix.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(matrix.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(mm.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(mm.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(mtypes.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(occlude.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(occlude.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(pixel.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(pixel.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(points.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(points.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(polygon.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(polygon.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(rastpos.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(rastpos.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(renderbuffer.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(renderbuffer.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(simple_list.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(state.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(state.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(stencil.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(stencil.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texcompress.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texcompress_fxt1.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texcompress_s3tc.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texcompress.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texenvprogram.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texenvprogram.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texformat.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texformat.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texformat_tmp.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(teximage.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(teximage.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texobj.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texobj.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texrender.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texrender.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texstate.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texstate.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texstore.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(texstore.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(varray.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(varray.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(version.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(vtxfmt.c, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(vtxfmt.h, $(MESASRCDIR)/src/mesa/main)
+LinkSourceFile(vtxfmt_tmp.h, $(MESASRCDIR)/src/mesa/main)
+#endif
+
+#ifdef NeedAllMesaSrc
+ DISPATCHOBJS = $(MESABUILDDIR)dispatch.o
+ GLAPIOBJS = $(MESABUILDDIR)glapi.o
+ GLTHREADOBJS = $(MESABUILDDIR)glthread.o
+#endif
+
+COREMESABASEOBJS = \
+ $(DISPATCHOBJS) \
+ $(GLAPIOBJS) \
+ $(GLTHREADOBJS) \
+ $(MESABUILDDIR)api_arrayelt.o \
+ $(MESABUILDDIR)api_loopback.o \
+ $(MESABUILDDIR)api_noop.o \
+ $(MESABUILDDIR)api_validate.o \
+ $(MESABUILDDIR)accum.o \
+ $(MESABUILDDIR)attrib.o \
+ $(MESABUILDDIR)blend.o \
+ $(MESABUILDDIR)bufferobj.o \
+ $(MESABUILDDIR)buffers.o \
+ $(MESABUILDDIR)clip.o \
+ $(MESABUILDDIR)colortab.o \
+ $(MESABUILDDIR)context.o \
+ $(MESABUILDDIR)convolve.o \
+ $(MESABUILDDIR)debug.o \
+ $(MESABUILDDIR)depth.o \
+ $(MESABUILDDIR)dlist.o \
+ $(MESABUILDDIR)drawpix.o \
+ $(MESABUILDDIR)enable.o \
+ $(MESABUILDDIR)enums.o \
+ $(MESABUILDDIR)eval.o \
+ $(MESABUILDDIR)execmem.o \
+ $(MESABUILDDIR)extensions.o \
+ $(MESABUILDDIR)fbobject.o \
+ $(MESABUILDDIR)feedback.o \
+ $(MESABUILDDIR)fog.o \
+ $(MESABUILDDIR)framebuffer.o \
+ $(MESABUILDDIR)get.o \
+ $(MESABUILDDIR)getstring.o \
+ $(MESABUILDDIR)hash.o \
+ $(MESABUILDDIR)hint.o \
+ $(MESABUILDDIR)histogram.o \
+ $(MESABUILDDIR)image.o \
+ $(MESABUILDDIR)imports.o \
+ $(MESABUILDDIR)light.o \
+ $(MESABUILDDIR)lines.o \
+ $(MESABUILDDIR)matrix.o \
+ $(MESABUILDDIR)mm.o \
+ $(MESABUILDDIR)occlude.o \
+ $(MESABUILDDIR)pixel.o \
+ $(MESABUILDDIR)points.o \
+ $(MESABUILDDIR)polygon.o \
+ $(MESABUILDDIR)rastpos.o \
+ $(MESABUILDDIR)renderbuffer.o \
+ $(MESABUILDDIR)state.o \
+ $(MESABUILDDIR)stencil.o \
+ $(MESABUILDDIR)texcompress.o \
+ $(MESABUILDDIR)texcompress_fxt1.o \
+ $(MESABUILDDIR)texcompress_s3tc.o \
+ $(MESABUILDDIR)texenvprogram.o \
+ $(MESABUILDDIR)texformat.o \
+ $(MESABUILDDIR)teximage.o \
+ $(MESABUILDDIR)texrender.o \
+ $(MESABUILDDIR)texobj.o \
+ $(MESABUILDDIR)texstate.o \
+ $(MESABUILDDIR)texstore.o \
+ $(MESABUILDDIR)varray.o \
+ $(MESABUILDDIR)vtxfmt.o
+
+#ifdef NeedAllMesaSrc
+ DISPATCHUOBJS = $(MESABUILDDIR)unshared/dispatch.o
+ GLAPIUOBJS = $(MESABUILDDIR)unshared/glapi.o
+ GLTHREADUOBJS = $(MESABUILDDIR)unshared/glthread.o
+#endif
+
+#if defined(DoSharedLib) && DoSharedLib
+COREMESABASEUOBJS = \
+ $(DISPATCHUOBJS) \
+ $(GLAPIUOBJS) \
+ $(GLTHREADUOBJS) \
+ $(MESABUILDDIR)unshared/api_arrayelt.o \
+ $(MESABUILDDIR)unshared/api_loopback.o \
+ $(MESABUILDDIR)unshared/api_noop.o \
+ $(MESABUILDDIR)unshared/api_validate.o \
+ $(MESABUILDDIR)unshared/accum.o \
+ $(MESABUILDDIR)unshared/attrib.o \
+ $(MESABUILDDIR)unshared/blend.o \
+ $(MESABUILDDIR)unshared/bufferobj.o \
+ $(MESABUILDDIR)unshared/buffers.o \
+ $(MESABUILDDIR)unshared/clip.o \
+ $(MESABUILDDIR)unshared/colortab.o \
+ $(MESABUILDDIR)unshared/context.o \
+ $(MESABUILDDIR)unshared/convolve.o \
+ $(MESABUILDDIR)unshared/debug.o \
+ $(MESABUILDDIR)unshared/depth.o \
+ $(MESABUILDDIR)unshared/dlist.o \
+ $(MESABUILDDIR)unshared/drawpix.o \
+ $(MESABUILDDIR)unshared/enable.o \
+ $(MESABUILDDIR)unshared/enums.o \
+ $(MESABUILDDIR)unshared/eval.o \
+ $(MESABUILDDIR)unshared/execmem.o \
+ $(MESABUILDDIR)unshared/extensions.o \
+ $(MESABUILDDIR)unshared/fbobject.o \
+ $(MESABUILDDIR)unshared/feedback.o \
+ $(MESABUILDDIR)unshared/fog.o \
+ $(MESABUILDDIR)unshared/framebuffer.o \
+ $(MESABUILDDIR)unshared/get.o \
+ $(MESABUILDDIR)unshared/getstring.o \
+ $(MESABUILDDIR)unshared/hash.o \
+ $(MESABUILDDIR)unshared/hint.o \
+ $(MESABUILDDIR)unshared/histogram.o \
+ $(MESABUILDDIR)unshared/image.o \
+ $(MESABUILDDIR)unshared/imports.o \
+ $(MESABUILDDIR)unshared/light.o \
+ $(MESABUILDDIR)unshared/lines.o \
+ $(MESABUILDDIR)unshared/matrix.o \
+ $(MESABUILDDIR)unshared/mm.o \
+ $(MESABUILDDIR)unshared/occlude.o \
+ $(MESABUILDDIR)unshared/pixel.o \
+ $(MESABUILDDIR)unshared/points.o \
+ $(MESABUILDDIR)unshared/polygon.o \
+ $(MESABUILDDIR)unshared/rastpos.o \
+ $(MESABUILDDIR)unshared/renderbuffer.o \
+ $(MESABUILDDIR)unshared/state.o \
+ $(MESABUILDDIR)unshared/stencil.o \
+ $(MESABUILDDIR)unshared/texcompress.o \
+ $(MESABUILDDIR)unshared/texcompress_fxt1.o \
+ $(MESABUILDDIR)unshared/texcompress_s3tc.o \
+ $(MESABUILDDIR)unshared/texenvprogram.o \
+ $(MESABUILDDIR)unshared/texformat.o \
+ $(MESABUILDDIR)unshared/teximage.o \
+ $(MESABUILDDIR)unshared/texobj.o \
+ $(MESABUILDDIR)unshared/texrender.o \
+ $(MESABUILDDIR)unshared/texstate.o \
+ $(MESABUILDDIR)unshared/texstore.o \
+ $(MESABUILDDIR)unshared/varray.o \
+ $(MESABUILDDIR)unshared/vtxfmt.o
+#else
+COREMESABASEUOBJS = $(COREMESABASEOBJS)
+#endif
+
+#ifdef NeedAllMesaSrc
+ DISPATCHDOBJS = $(MESABUILDDIR)debugger/dispatch.o
+ GLAPIDOBJS = $(MESABUILDDIR)debugger/glapi.o
+ GLTHREADDOBJS = $(MESABUILDDIR)debugger/glthread.o
+#endif
+
+COREMESABASEDOBJS = \
+ $(DISPATCHDOBJS) \
+ $(GLAPIDOBJS) \
+ $(GLTHREADDOBJS) \
+ $(MESABUILDDIR)debugger/api_arrayelt.o \
+ $(MESABUILDDIR)debugger/api_loopback.o \
+ $(MESABUILDDIR)debugger/api_noop.o \
+ $(MESABUILDDIR)debugger/api_validate.o \
+ $(MESABUILDDIR)debugger/accum.o \
+ $(MESABUILDDIR)debugger/attrib.o \
+ $(MESABUILDDIR)debugger/blend.o \
+ $(MESABUILDDIR)debugger/bufferobj.o \
+ $(MESABUILDDIR)debugger/buffers.o \
+ $(MESABUILDDIR)debugger/clip.o \
+ $(MESABUILDDIR)debugger/colortab.o \
+ $(MESABUILDDIR)debugger/context.o \
+ $(MESABUILDDIR)debugger/convolve.o \
+ $(MESABUILDDIR)debugger/debug.o \
+ $(MESABUILDDIR)debugger/depth.o \
+ $(MESABUILDDIR)debugger/dlist.o \
+ $(MESABUILDDIR)debugger/drawpix.o \
+ $(MESABUILDDIR)debugger/enable.o \
+ $(MESABUILDDIR)debugger/enums.o \
+ $(MESABUILDDIR)debugger/eval.o \
+ $(MESABUILDDIR)debugger/execmem.o \
+ $(MESABUILDDIR)debugger/extensions.o \
+ $(MESABUILDDIR)debugger/fbobject.o \
+ $(MESABUILDDIR)debugger/feedback.o \
+ $(MESABUILDDIR)debugger/fog.o \
+ $(MESABUILDDIR)debugger/framebuffer.o \
+ $(MESABUILDDIR)debugger/get.o \
+ $(MESABUILDDIR)debugger/getstring.o \
+ $(MESABUILDDIR)debugger/hash.o \
+ $(MESABUILDDIR)debugger/hint.o \
+ $(MESABUILDDIR)debugger/histogram.o \
+ $(MESABUILDDIR)debugger/image.o \
+ $(MESABUILDDIR)debugger/imports.o \
+ $(MESABUILDDIR)debugger/light.o \
+ $(MESABUILDDIR)debugger/lines.o \
+ $(MESABUILDDIR)debugger/matrix.o \
+ $(MESABUILDDIR)debugger/mm.o \
+ $(MESABUILDDIR)debugger/occlude.o \
+ $(MESABUILDDIR)debugger/pixel.o \
+ $(MESABUILDDIR)debugger/points.o \
+ $(MESABUILDDIR)debugger/polygon.o \
+ $(MESABUILDDIR)debugger/rastpos.o \
+ $(MESABUILDDIR)debugger/renderbuffer.o \
+ $(MESABUILDDIR)debugger/state.o \
+ $(MESABUILDDIR)debugger/stencil.o \
+ $(MESABUILDDIR)debugger/texcompress.o \
+ $(MESABUILDDIR)debugger/texcompress_fxt1.o \
+ $(MESABUILDDIR)debugger/texcompress_s3tc.o \
+ $(MESABUILDDIR)debugger/texenvprogram.o \
+ $(MESABUILDDIR)debugger/texformat.o \
+ $(MESABUILDDIR)debugger/teximage.o \
+ $(MESABUILDDIR)debugger/texobj.o \
+ $(MESABUILDDIR)debugger/texrender.o \
+ $(MESABUILDDIR)debugger/texstate.o \
+ $(MESABUILDDIR)debugger/texstore.o \
+ $(MESABUILDDIR)debugger/varray.o \
+ $(MESABUILDDIR)debugger/vtxfmt.o
+
+#ifdef NeedAllMesaSrc
+ DISPATCHPOBJS = $(MESABUILDDIR)profiled/dispatch.o
+ GLAPIPOBJS = $(MESABUILDDIR)profiled/glapi.o
+ GLTHREADPOBJS = $(MESABUILDDIR)profiled/glthread.o
+#endif
+
+COREMESABASEPOBJS = \
+ $(DISPATCHPOBJS) \
+ $(GLAPIPOBJS) \
+ $(GLTHREADPOBJS) \
+ $(MESABUILDDIR)profiled/api_arrayelt.o \
+ $(MESABUILDDIR)profiled/api_loopback.o \
+ $(MESABUILDDIR)profiled/api_noop.o \
+ $(MESABUILDDIR)profiled/api_validate.o \
+ $(MESABUILDDIR)profiled/accum.o \
+ $(MESABUILDDIR)profiled/attrib.o \
+ $(MESABUILDDIR)profiled/blend.o \
+ $(MESABUILDDIR)profiled/bufferobj.o \
+ $(MESABUILDDIR)profiled/buffers.o \
+ $(MESABUILDDIR)profiled/clip.o \
+ $(MESABUILDDIR)profiled/colortab.o \
+ $(MESABUILDDIR)profiled/context.o \
+ $(MESABUILDDIR)profiled/convolve.o \
+ $(MESABUILDDIR)profiled/debug.o \
+ $(MESABUILDDIR)profiled/depth.o \
+ $(MESABUILDDIR)profiled/dlist.o \
+ $(MESABUILDDIR)profiled/drawpix.o \
+ $(MESABUILDDIR)profiled/enable.o \
+ $(MESABUILDDIR)profiled/enums.o \
+ $(MESABUILDDIR)profiled/eval.o \
+ $(MESABUILDDIR)profiled/execmem.o \
+ $(MESABUILDDIR)profiled/extensions.o \
+ $(MESABUILDDIR)profiled/fbobject.o \
+ $(MESABUILDDIR)profiled/feedback.o \
+ $(MESABUILDDIR)profiled/fog.o \
+ $(MESABUILDDIR)profiled/framebuffer.o \
+ $(MESABUILDDIR)profiled/get.o \
+ $(MESABUILDDIR)profiled/getstring.o \
+ $(MESABUILDDIR)profiled/hash.o \
+ $(MESABUILDDIR)profiled/hint.o \
+ $(MESABUILDDIR)profiled/histogram.o \
+ $(MESABUILDDIR)profiled/image.o \
+ $(MESABUILDDIR)profiled/imports.o \
+ $(MESABUILDDIR)profiled/light.o \
+ $(MESABUILDDIR)profiled/lines.o \
+ $(MESABUILDDIR)profiled/matrix.o \
+ $(MESABUILDDIR)profiled/mm.o \
+ $(MESABUILDDIR)profiled/occlude.o \
+ $(MESABUILDDIR)profiled/pixel.o \
+ $(MESABUILDDIR)profiled/points.o \
+ $(MESABUILDDIR)profiled/polygon.o \
+ $(MESABUILDDIR)profiled/rastpos.o \
+ $(MESABUILDDIR)profiled/renderbuffer.o \
+ $(MESABUILDDIR)profiled/state.o \
+ $(MESABUILDDIR)profiled/stencil.o \
+ $(MESABUILDDIR)profiled/texcompress.o \
+ $(MESABUILDDIR)profiled/texcompress_fxt1.o \
+ $(MESABUILDDIR)profiled/texcompress_s3tc.o \
+ $(MESABUILDDIR)profiled/texenvprogram.o \
+ $(MESABUILDDIR)profiled/texformat.o \
+ $(MESABUILDDIR)profiled/teximage.o \
+ $(MESABUILDDIR)profiled/texobj.o \
+ $(MESABUILDDIR)profiled/texrender.o \
+ $(MESABUILDDIR)profiled/texstate.o \
+ $(MESABUILDDIR)profiled/texstore.o \
+ $(MESABUILDDIR)profiled/varray.o \
+ $(MESABUILDDIR)profiled/vtxfmt.o
diff --git a/nx-X11/lib/GL/mesa/math/Imakefile b/nx-X11/lib/GL/mesa/math/Imakefile
new file mode 100644
index 000000000..ab00ae76f
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/math/Imakefile
@@ -0,0 +1,98 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/math/Imakefile,v 1.8 2002/11/25 12:58:55 tsi Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if BuildOSMesaLib || (BuildXF86DRI && (GlxDriverUsesMesa || GlxBuiltInXMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+/* Large PIC tables needed for Solaris SPARC builds */
+#if (defined(SunArchitecture) && defined(SparcArchitecture))
+# define LargePICTable YES
+#endif
+
+
+#define MesaMathBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I.. \
+ -I$(INCLUDESRC)/GL -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ ASM_DIR = x86
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_DIR = sparc
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/math \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/$(ASM_DIR) \
+ -I$(MESASRCDIR)/include \
+ -I../../../include -I$(XINCLUDESRC)
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = $(MESA_MATH_SRCS)
+ OBJS = $(MESA_MATH_OBJS)
+
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/math/Imakefile.inc b/nx-X11/lib/GL/mesa/math/Imakefile.inc
new file mode 100644
index 000000000..cd1dcc427
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/math/Imakefile.inc
@@ -0,0 +1,82 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/math/Imakefile.inc,v 1.1tsi Exp $
+
+#ifndef MesaMathBuildDir
+#define MesaMathBuildDir $(GLXLIBSRC)/mesa/math/
+#endif
+
+MESAMATHBUILDDIR = MesaMathBuildDir
+
+ MESA_MATH_SRCS = $(MESAMATHBUILDDIR)m_debug_clip.c \
+ $(MESAMATHBUILDDIR)m_debug_norm.c \
+ $(MESAMATHBUILDDIR)m_debug_xform.c \
+ $(MESAMATHBUILDDIR)m_eval.c \
+ $(MESAMATHBUILDDIR)m_matrix.c \
+ $(MESAMATHBUILDDIR)m_translate.c \
+ $(MESAMATHBUILDDIR)m_vector.c \
+ $(MESAMATHBUILDDIR)m_xform.c
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(mathmod.h, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_clip_tmp.h, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_copy_tmp.h, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_debug_clip.c, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_debug.h, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_debug_util.h, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_debug_norm.c, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_debug_xform.c, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_dotprod_tmp.h, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_eval.c, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_eval.h, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_matrix.c, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_matrix.h, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_norm_tmp.h, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_translate.c, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_translate.h, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_trans_tmp.h, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_vector.c, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_vector.h, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_xform.c, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_xform.h, $(MESASRCDIR)/src/mesa/math)
+LinkSourceFile(m_xform_tmp.h, $(MESASRCDIR)/src/mesa/math)
+#endif
+
+ MESA_MATH_OBJS = $(MESAMATHBUILDDIR)m_debug_clip.o \
+ $(MESAMATHBUILDDIR)m_debug_norm.o \
+ $(MESAMATHBUILDDIR)m_debug_xform.o \
+ $(MESAMATHBUILDDIR)m_eval.o \
+ $(MESAMATHBUILDDIR)m_matrix.o \
+ $(MESAMATHBUILDDIR)m_translate.o \
+ $(MESAMATHBUILDDIR)m_vector.o \
+ $(MESAMATHBUILDDIR)m_xform.o
+
+#if defined(DoSharedLib) && DoSharedLib
+ MESA_MATH_UOBJS = $(MESAMATHBUILDDIR)unshared/m_debug_clip.o \
+ $(MESAMATHBUILDDIR)unshared/m_debug_norm.o \
+ $(MESAMATHBUILDDIR)unshared/m_debug_xform.o \
+ $(MESAMATHBUILDDIR)unshared/m_eval.o \
+ $(MESAMATHBUILDDIR)unshared/m_matrix.o \
+ $(MESAMATHBUILDDIR)unshared/m_translate.o \
+ $(MESAMATHBUILDDIR)unshared/m_vector.o \
+ $(MESAMATHBUILDDIR)unshared/m_xform.o
+#else
+ MATH_MESA_UOBJS = $(MESA_MATH_OBJS)
+#endif
+
+ MESA_MATH_DOBJS = $(MESAMATHBUILDDIR)debugger/m_debug_clip.o \
+ $(MESAMATHBUILDDIR)debugger/m_debug_norm.o \
+ $(MESAMATHBUILDDIR)debugger/m_debug_xform.o \
+ $(MESAMATHBUILDDIR)debugger/m_eval.o \
+ $(MESAMATHBUILDDIR)debugger/m_matrix.o \
+ $(MESAMATHBUILDDIR)debugger/m_translate.o \
+ $(MESAMATHBUILDDIR)debugger/m_vector.o \
+ $(MESAMATHBUILDDIR)debugger/m_xform.o
+
+ MESA_MATH_POBJS = $(MESAMATHBUILDDIR)profiled/m_debug_clip.o \
+ $(MESAMATHBUILDDIR)profiled/m_debug_norm.o \
+ $(MESAMATHBUILDDIR)profiled/m_debug_xform.o \
+ $(MESAMATHBUILDDIR)profiled/m_eval.o \
+ $(MESAMATHBUILDDIR)profiled/m_matrix.o \
+ $(MESAMATHBUILDDIR)profiled/m_translate.o \
+ $(MESAMATHBUILDDIR)profiled/m_vector.o \
+ $(MESAMATHBUILDDIR)profiled/m_xform.o
+
diff --git a/nx-X11/lib/GL/mesa/shader/Imakefile b/nx-X11/lib/GL/mesa/shader/Imakefile
new file mode 100644
index 000000000..d46834740
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/shader/Imakefile
@@ -0,0 +1,107 @@
+XCOMM $XFree86$
+
+#include <Threads.tmpl>
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if BuildOSMesaLib || (BuildXF86DRI && (GlxDriverUsesMesa || GlxBuiltInXMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+/* Large PIC tables needed for Solaris SPARC builds */
+#if (defined(SunArchitecture) && defined(SparcArchitecture))
+# define LargePICTable YES
+#endif
+
+#define MesaShaderBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I.. \
+ -I$(INCLUDESRC)/GL -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ ASM_DIR = x86
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_DIR = sparc
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/math \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader/grammar \
+ -I$(MESASRCDIR)/src/mesa/shader/slang \
+ -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/$(ASM_DIR) \
+ -I$(MESASRCDIR)/include \
+ -I../../../include -I$(XINCLUDESRC)
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = $(MESA_SHADER_SRCS)
+ OBJS = $(MESA_SHADER_OBJS)
+
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+#define IHaveSubdirs
+#define PassCDebugFlags
+
+SUBDIRS = grammar slang
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/shader/Imakefile.inc b/nx-X11/lib/GL/mesa/shader/Imakefile.inc
new file mode 100644
index 000000000..7d0032e56
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/shader/Imakefile.inc
@@ -0,0 +1,106 @@
+XCOMM $XFree86:$
+
+#ifndef MesaShaderBuildDir
+#define MesaShaderBuildDir $(GLXLIBSRC)/mesa/shader/
+#endif
+
+MESASHADERBUILDDIR = MesaShaderBuildDir
+
+ MESA_SHADER_SRCS = $(MESASHADERBUILDDIR)arbprogparse.c \
+ $(MESASHADERBUILDDIR)arbprogram.c \
+ $(MESASHADERBUILDDIR)arbfragparse.c \
+ $(MESASHADERBUILDDIR)arbvertparse.c \
+ $(MESASHADERBUILDDIR)atifragshader.c \
+ $(MESASHADERBUILDDIR)nvprogram.c \
+ $(MESASHADERBUILDDIR)nvfragparse.c \
+ $(MESASHADERBUILDDIR)nvvertexec.c \
+ $(MESASHADERBUILDDIR)nvvertparse.c \
+ $(MESASHADERBUILDDIR)program.c \
+ $(MESASHADERBUILDDIR)shaderobjects.c \
+ $(MESASHADERBUILDDIR)shaderobjects_3dlabs.c
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(arbprogparse.c, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(arbprogram.c, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(arbfragparse.c, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(arbvertparse.c, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(arbfragparse.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(arbprogparse.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(arbprogram.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(arbprogram_syn.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(arbvertparse.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(atifragshader.c, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(atifragshader.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(nvfragparse.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(nvfragprog.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(nvprogram.c, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(nvprogram.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(nvfragparse.c, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(nvvertexec.c, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(nvvertexec.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(nvvertparse.c, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(nvvertparse.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(nvvertprog.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(program.c, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(program.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(shaderobjects.c, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(shaderobjects.h, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(shaderobjects_3dlabs.c, $(MESASRCDIR)/src/mesa/shader)
+LinkSourceFile(shaderobjects_3dlabs.h, $(MESASRCDIR)/src/mesa/shader)
+#endif
+
+ MESA_SHADER_OBJS = $(MESASHADERBUILDDIR)arbprogparse.o \
+ $(MESASHADERBUILDDIR)arbprogram.o \
+ $(MESASHADERBUILDDIR)arbfragparse.o \
+ $(MESASHADERBUILDDIR)arbvertparse.o \
+ $(MESASHADERBUILDDIR)atifragshader.o \
+ $(MESASHADERBUILDDIR)nvprogram.o \
+ $(MESASHADERBUILDDIR)nvfragparse.o \
+ $(MESASHADERBUILDDIR)nvvertexec.o \
+ $(MESASHADERBUILDDIR)nvvertparse.o \
+ $(MESASHADERBUILDDIR)program.o \
+ $(MESASHADERBUILDDIR)shaderobjects.o \
+ $(MESASHADERBUILDDIR)shaderobjects_3dlabs.o
+
+#if defined(DoSharedLib) && DoSharedLib
+ MESA_SHADER_UOBJS = $(MESASHADERBUILDDIR)unshared/arbprogparse.o \
+ $(MESASHADERBUILDDIR)unshared/arbprogram.o \
+ $(MESASHADERBUILDDIR)unshared/arbfragparse.o \
+ $(MESASHADERBUILDDIR)unshared/arbvertparse.o \
+ $(MESASHADERBUILDDIR)unshared/atifragshader.o \
+ $(MESASHADERBUILDDIR)unshared/nvprogram.o \
+ $(MESASHADERBUILDDIR)unshared/nvfragparse.o \
+ $(MESASHADERBUILDDIR)unshared/nvvertexec.o \
+ $(MESASHADERBUILDDIR)unshared/nvvertparse.o \
+ $(MESASHADERBUILDDIR)unshared/program.o \
+ $(MESASHADERBUILDDIR)unshared/shaderobjects.o \
+ $(MESASHADERBUILDDIR)unshared/shaderobjects_3dlabs.o
+#else
+ MESA_SHADER_UOBJS = $(MESA_SHADER_OBJS)
+#endif
+
+ MESA_SHADER_DOBJS = $(MESASHADERBUILDDIR)debugger/arbprogparse.o \
+ $(MESASHADERBUILDDIR)debugger/arbprogram.o \
+ $(MESASHADERBUILDDIR)debugger/arbfragparse.o \
+ $(MESASHADERBUILDDIR)debugger/arbvertparse.o \
+ $(MESASHADERBUILDDIR)debugger/atifragshader.o \
+ $(MESASHADERBUILDDIR)debugger/nvprogram.o \
+ $(MESASHADERBUILDDIR)debugger/nvfragparse.o \
+ $(MESASHADERBUILDDIR)debugger/nvvertexec.o \
+ $(MESASHADERBUILDDIR)debugger/nvvertparse.o \
+ $(MESASHADERBUILDDIR)debugger/program.o \
+ $(MESASHADERBUILDDIR)debugger/shaderobjects.o \
+ $(MESASHADERBUILDDIR)debugger/shaderobjects_3dlabs.o
+
+ MESA_SHADER_POBJS = $(MESASHADERBUILDDIR)profiled/arbprogparse.o \
+ $(MESASHADERBUILDDIR)profiled/arbprogram.o \
+ $(MESASHADERBUILDDIR)profiled/arbfragparse.o \
+ $(MESASHADERBUILDDIR)profiled/arbvertparse.o \
+ $(MESASHADERBUILDDIR)profiled/atifragshader.o \
+ $(MESASHADERBUILDDIR)profiled/nvprogram.o \
+ $(MESASHADERBUILDDIR)profiled/nvfragparse.o \
+ $(MESASHADERBUILDDIR)profiled/nvvertexec.o \
+ $(MESASHADERBUILDDIR)profiled/nvvertparse.o \
+ $(MESASHADERBUILDDIR)profiled/program.o \
+ $(MESASHADERBUILDDIR)profiled/shaderobjects.o \
+ $(MESASHADERBUILDDIR)profiled/shaderobjects_3dlabs.o
diff --git a/nx-X11/lib/GL/mesa/shader/grammar/Imakefile b/nx-X11/lib/GL/mesa/shader/grammar/Imakefile
new file mode 100644
index 000000000..bbdec9764
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/shader/grammar/Imakefile
@@ -0,0 +1,98 @@
+XCOMM $XFree86$
+
+#include <Threads.tmpl>
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if BuildOSMesaLib || (BuildXF86DRI && (GlxDriverUsesMesa || GlxBuiltInXMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+/* Large PIC tables needed for Solaris SPARC builds */
+#if (defined(SunArchitecture) && defined(SparcArchitecture))
+# define LargePICTable YES
+#endif
+
+#define MesaGrammarBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I.. \
+ -I$(INCLUDESRC)/GL -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ ASM_DIR = x86
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_DIR = sparc
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/math \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader/grammar \
+ -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/$(ASM_DIR) \
+ -I$(MESASRCDIR)/include \
+ -I../../../include -I$(XINCLUDESRC)
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = $(MESA_GRAMMAR_SRCS)
+ OBJS = $(MESA_GRAMMAR_OBJS)
+
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/shader/grammar/Imakefile.inc b/nx-X11/lib/GL/mesa/shader/grammar/Imakefile.inc
new file mode 100644
index 000000000..b2e885f89
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/shader/grammar/Imakefile.inc
@@ -0,0 +1,29 @@
+XCOMM $XFree86$
+
+#ifndef MesaGrammarBuildDir
+#define MesaGrammarBuildDir $(GLXLIBSRC)/mesa/shader/grammar/
+#endif
+
+MESAGRAMMARBUILDDIR=MesaGrammarBuildDir
+
+ MESA_GRAMMAR_SRCS = $(MESAGRAMMARBUILDDIR)grammar_mesa.c
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(grammar.c, $(MESASRCDIR)/src/mesa/shader/grammar)
+LinkSourceFile(grammar.h, $(MESASRCDIR)/src/mesa/shader/grammar)
+LinkSourceFile(grammar_syn.h, $(MESASRCDIR)/src/mesa/shader/grammar)
+LinkSourceFile(grammar_mesa.c, $(MESASRCDIR)/src/mesa/shader/grammar)
+LinkSourceFile(grammar_mesa.h, $(MESASRCDIR)/src/mesa/shader/grammar)
+#endif
+
+ MESA_GRAMMAR_OBJS = $(MESAGRAMMARBUILDDIR)grammar_mesa.o
+
+#if defined(DoSharedLib) && DoSharedLib
+ MESA_GRAMMAR_UOBJS = $(MESAGRAMMARBUILDDIR)unshared/grammar_mesa.o
+#else
+ MESA_GRAMMAR_UOBJS = $(MESA_GRAMMAR_OBJS)
+#endif
+
+ MESA_GRAMMAR_DOBJS = $(MESAGRAMMARBUILDDIR)debugger/grammar_mesa.o
+
+ MESA_GRAMMAR_POBJS = $(MESAGRAMMARBUILDDIR)profiled/grammar_mesa.o
diff --git a/nx-X11/lib/GL/mesa/shader/slang/Imakefile b/nx-X11/lib/GL/mesa/shader/slang/Imakefile
new file mode 100644
index 000000000..096a8ea63
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/shader/slang/Imakefile
@@ -0,0 +1,108 @@
+XCOMM $XFree86$
+
+#include <Threads.tmpl>
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if BuildOSMesaLib || (BuildXF86DRI && (GlxDriverUsesMesa || GlxBuiltInXMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+/* Large PIC tables needed for Solaris SPARC builds */
+#if (defined(SunArchitecture) && defined(SparcArchitecture))
+# define LargePICTable YES
+#endif
+
+#define MesaSlangBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I.. \
+ -I$(INCLUDESRC)/GL -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ ASM_DIR = x86
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_DIR = sparc
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/math \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader/grammar \
+ -I$(MESASRCDIR)/src/mesa/shader/slang \
+ -I$(MESASRCDIR)/src/mesa/shader/slang/library \
+ -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/$(ASM_DIR) \
+ -I$(MESASRCDIR)/include \
+ -I../../../include -I$(XINCLUDESRC)
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = $(MESA_SLANG_SRCS)
+ OBJS = $(MESA_SLANG_OBJS)
+
+
+#include <Library.tmpl>
+
+#define IHaveSubdirs
+#define PassCDebugFlags
+
+SUBDIRS = library
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/shader/slang/Imakefile.inc b/nx-X11/lib/GL/mesa/shader/slang/Imakefile.inc
new file mode 100644
index 000000000..d824ca797
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/shader/slang/Imakefile.inc
@@ -0,0 +1,90 @@
+XCOMM $XFree86$
+
+#ifndef MesaSlangBuildDir
+#define MesaSlangBuildDir $(GLXLIBSRC)/mesa/shader/slang/
+#endif
+
+MESASLANGBUILDDIR=MesaSlangBuildDir
+
+ MESA_SLANG_SRCS = $(MESASLANGBUILDDIR)slang_assemble_assignment.c \
+ $(MESASLANGBUILDDIR)slang_assemble.c \
+ $(MESASLANGBUILDDIR)slang_assemble_conditional.c \
+ $(MESASLANGBUILDDIR)slang_assemble_constructor.c \
+ $(MESASLANGBUILDDIR)slang_assemble_typeinfo.c \
+ $(MESASLANGBUILDDIR)slang_compile.c \
+ $(MESASLANGBUILDDIR)slang_execute.c \
+ $(MESASLANGBUILDDIR)slang_preprocess.c \
+ $(MESASLANGBUILDDIR)slang_storage.c \
+ $(MESASLANGBUILDDIR)slang_utility.c
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(slang_assemble_assignment.c, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_assemble_assignment.h, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_assemble.c, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_assemble.h, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_assemble_conditional.c, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_assemble_conditional.h, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_assemble_constructor.c, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_assemble_constructor.h, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_assemble_typeinfo.c, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_assemble_typeinfo.h, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_compile.c, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_compile.h, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_execute.c, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_execute.h, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_preprocess.c, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_preprocess.h, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_storage.c, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_storage.h, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_utility.c, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(slang_utility.h, $(MESASRCDIR)/src/mesa/shader/slang)
+LinkSourceFile(traverse_wrap.h, $(MESASRCDIR)/src/mesa/shader/slang)
+#endif
+
+ MESA_SLANG_OBJS = $(MESASLANGBUILDDIR)slang_assemble_assignment.o \
+ $(MESASLANGBUILDDIR)slang_assemble.o \
+ $(MESASLANGBUILDDIR)slang_assemble_conditional.o \
+ $(MESASLANGBUILDDIR)slang_assemble_constructor.o \
+ $(MESASLANGBUILDDIR)slang_assemble_typeinfo.o \
+ $(MESASLANGBUILDDIR)slang_compile.o \
+ $(MESASLANGBUILDDIR)slang_execute.o \
+ $(MESASLANGBUILDDIR)slang_preprocess.o \
+ $(MESASLANGBUILDDIR)slang_storage.o \
+ $(MESASLANGBUILDDIR)slang_utility.o
+
+#if defined(DoSharedLib) && DoSharedLib
+ MESA_SLANG_UOBJS = $(MESASLANGBUILDDIR)unshared/slang_assemble_assignment.o \
+ $(MESASLANGBUILDDIR)unshared/slang_assemble.o \
+ $(MESASLANGBUILDDIR)unshared/slang_assemble_conditional.o \
+ $(MESASLANGBUILDDIR)unshared/slang_assemble_constructor.o \
+ $(MESASLANGBUILDDIR)unshared/slang_assemble_typeinfo.o \
+ $(MESASLANGBUILDDIR)unshared/slang_compile.o \
+ $(MESASLANGBUILDDIR)unshared/slang_execute.o \
+ $(MESASLANGBUILDDIR)unshared/slang_preprocess.o \
+ $(MESASLANGBUILDDIR)unshared/slang_storage.o \
+ $(MESASLANGBUILDDIR)unshared/slang_utility.o
+#else
+ MESA_SLANG_UOBJS = $(MESA_SLANG_OBJS)
+#endif
+
+ MESA_SLANG_DOBJS = $(MESASLANGBUILDDIR)debuggerslang_assemble_assignment.o \
+ $(MESASLANGBUILDDIR)debuggerslang_assemble.o \
+ $(MESASLANGBUILDDIR)debuggerslang_assemble_conditional.o \
+ $(MESASLANGBUILDDIR)debuggerslang_assemble_constructor.o \
+ $(MESASLANGBUILDDIR)debuggerslang_assemble_typeinfo.o \
+ $(MESASLANGBUILDDIR)debuggerslang_compile.o \
+ $(MESASLANGBUILDDIR)debuggerslang_execute.o \
+ $(MESASLANGBUILDDIR)debuggerslang_preprocess.o \
+ $(MESASLANGBUILDDIR)debuggerslang_storage.o \
+ $(MESASLANGBUILDDIR)debuggerslang_utility.o
+
+ MESA_SLANG_POBJS = $(MESASLANGBUILDDIR)profiled/slang_assemble_assignment.o \
+ $(MESASLANGBUILDDIR)profiled/slang_assemble.o \
+ $(MESASLANGBUILDDIR)profiled/slang_assemble_conditional.o \
+ $(MESASLANGBUILDDIR)profiled/slang_assemble_constructor.o \
+ $(MESASLANGBUILDDIR)profiled/slang_assemble_typeinfo.o \
+ $(MESASLANGBUILDDIR)profiled/slang_compile.o \
+ $(MESASLANGBUILDDIR)profiled/slang_execute.o \
+ $(MESASLANGBUILDDIR)profiled/slang_preprocess.o \
+ $(MESASLANGBUILDDIR)profiled/slang_storage.o \
+ $(MESASLANGBUILDDIR)profiled/slang_utility.o
diff --git a/nx-X11/lib/GL/mesa/shader/slang/library/Imakefile b/nx-X11/lib/GL/mesa/shader/slang/library/Imakefile
new file mode 100644
index 000000000..de32171ae
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/shader/slang/library/Imakefile
@@ -0,0 +1,97 @@
+XCOMM $XFree86$
+
+#include <Threads.tmpl>
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if BuildOSMesaLib || (BuildXF86DRI && (GlxDriverUsesMesa || GlxBuiltInXMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+/* Large PIC tables needed for Solaris SPARC builds */
+#if (defined(SunArchitecture) && defined(SparcArchitecture))
+# define LargePICTable YES
+#endif
+
+#define MesaShaderBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I.. \
+ -I$(INCLUDESRC)/GL -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ ASM_DIR = x86
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_DIR = sparc
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/math \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader/slang \
+ -I$(MESASRCDIR)/src/mesa/shader/slang/library \
+ -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/$(ASM_DIR) \
+ -I$(MESASRCDIR)/include \
+ -I../../../include -I$(XINCLUDESRC)
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = $(MESA_SLANG_SRCS)
+ OBJS = $(MESA_SLANG_OBJS)
+
+
+#include <Library.tmpl>
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/shader/slang/library/Imakefile.inc b/nx-X11/lib/GL/mesa/shader/slang/library/Imakefile.inc
new file mode 100644
index 000000000..3489b7a28
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/shader/slang/library/Imakefile.inc
@@ -0,0 +1,14 @@
+XCOMM $XFree86:$
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(slang_common_builtin_gc_bin.h, $(MESASRCDIR)/src/mesa/shader/slang/library)
+LinkSourceFile(slang_common_builtin_gc.h, $(MESASRCDIR)/src/mesa/shader/slang/library)
+LinkSourceFile(slang_core_gc_bin.h, $(MESASRCDIR)/src/mesa/shader/slang/library)
+LinkSourceFile(slang_core_gc.h, $(MESASRCDIR)/src/mesa/shader/slang/library)
+LinkSourceFile(slang_fragment_builtin_gc_bin.h, $(MESASRCDIR)/src/mesa/shader/slang/library)
+LinkSourceFile(slang_fragment_builtin_gc.h, $(MESASRCDIR)/src/mesa/shader/slang/library)
+LinkSourceFile(slang_shader_syn.h, $(MESASRCDIR)/src/mesa/shader/slang/library)
+LinkSourceFile(slang_version_syn.h, $(MESASRCDIR)/src/mesa/shader/slang/library)
+LinkSourceFile(slang_vertex_builtin_gc_bin.h, $(MESASRCDIR)/src/mesa/shader/slang/library)
+LinkSourceFile(slang_vertex_builtin_gc.h, $(MESASRCDIR)/src/mesa/shader/slang/library)
+#endif
diff --git a/nx-X11/lib/GL/mesa/sparc/Imakefile b/nx-X11/lib/GL/mesa/sparc/Imakefile
new file mode 100644
index 000000000..8cd9c9f8b
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/sparc/Imakefile
@@ -0,0 +1,68 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/SPARC/Imakefile,v 1.3 2002/11/22 22:55:58 tsi Exp $
+XCOMM $XdotOrg: xc/lib/GL/mesa/sparc/Imakefile,v 1.3 2004/11/13 04:39:16 gisburn Exp $
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if BuildOSMesaLib || (BuildXF86DRI && (GlxDriverUsesMesa || GlxBuiltInXMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+/* Large PIC tables needed for Solaris SPARC builds */
+#if (defined(SunArchitecture) && defined(SparcArchitecture))
+# define LargePICTable YES
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#define MesaSPARCBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+ DEFINES = $(ALLOC_DEFINES) GlxDefines $(MESA_ASM_DEFINES)
+ INCLUDES = -I$(INCLUDESRC) -I$(EXTINCSRC) -I$(MESASRCDIR)/src \
+ -I$(MESASRCDIR)/src/SPARC \
+ -I../../../include \
+ -I$(MESASRCDIR)/include \
+ -I$(GLXLIBSRC)/include \
+ -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/sparc \
+ -I$(MESASRCDIR)/src/mesa/glapi
+
+ SRCS = $(MESA_ASM_SRCS)
+ OBJS = $(MESA_ASM_OBJS)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+STD_CPP_DEFINES = StandardDefines $(PROJECT_DEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+ObjectFromAsmSource(xform, NullParameter)
+ObjectFromAsmSource(clip, NullParameter)
+ObjectFromAsmSource(norm, NullParameter)
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/sparc/Imakefile.inc b/nx-X11/lib/GL/mesa/sparc/Imakefile.inc
new file mode 100644
index 000000000..6bd006749
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/sparc/Imakefile.inc
@@ -0,0 +1,58 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/SPARC/Imakefile.inc,v 1.2 2002/11/14 21:01:16 tsi Exp $
+
+#ifndef MesaSPARCBuildDir
+#define MesaSPARCBuildDir $(GLXLIBSRC)/mesa/sparc/
+#endif
+
+MESASPARCBUILDDIR = MesaSPARCBuildDir
+
+MESA_SPARC_SRCS = $(MESASPARCBUILDDIR)sparc.c \
+ $(MESASPARCBUILDDIR)xform.S \
+ $(MESASPARCBUILDDIR)clip.S
+
+#ifdef NeedToLinkMesaSrc
+/* If $(MESASRCDIR)/src/mesa/sparc isn't in the INCLUDES, it should be. */
+LinkSourceFile(sparc.c, $(MESASRCDIR)/src/mesa/sparc)
+LinkSourceFile(xform.S, $(MESASRCDIR)/src/mesa/sparc)
+LinkSourceFile(clip.S, $(MESASRCDIR)/src/mesa/sparc)
+LinkSourceFile(norm.S, $(MESASRCDIR)/src/mesa/sparc)
+#endif
+
+MESA_SPARC_OBJS = $(MESASPARCBUILDDIR)sparc.o \
+ $(MESASPARCBUILDDIR)xform.o \
+ $(MESASPARCBUILDDIR)clip.o \
+ $(MESASPARCBUILDDIR)norm.o
+
+#if defined(DoSharedLib) && DoSharedLib
+MESA_SPARC_UOBJS = $(MESASPARCBUILDDIR)unshared/sparc.o \
+ $(MESASPARCBUILDDIR)xform.o \
+ $(MESASPARCBUILDDIR)clip.o \
+ $(MESASPARCBUILDDIR)norm.o
+#else
+MESA_SPARC_UOBJS = $(MESA_SPARC_OBJS)
+#endif
+
+MESA_SPARC_DOBJS = $(MESASPARCBUILDDIR)debugger/sparc.o \
+ $(MESASPARCBUILDDIR)xform.o \
+ $(MESASPARCBUILDDIR)clip.o \
+ $(MESASPARCBUILDDIR)norm.o
+
+MESA_SPARC_POBJS = $(MESAX86BUILDDIR)profiled/sparc.o \
+ $(MESAX86BUILDDIR)xform.o \
+ $(MESAX86BUILDDIR)clip.o \
+ $(MESAX86BUILDDIR)norm.o
+
+MESA_SPARC_DEFS = -DUSE_SPARC_ASM
+
+MESA_ASM_SRCS = $(MESA_SPARC_SRCS)
+
+MESA_ASM_OBJS = $(MESA_SPARC_OBJS)
+
+MESA_ASM_UOBJS = $(MESA_SPARC_UOBJS)
+
+MESA_ASM_DOBJS = $(MESA_SPARC_DOBJS)
+
+MESA_ASM_POBJS = $(MESA_SPARC_POBJS)
+
+MESA_ASM_DEFINES = $(MESA_SPARC_DEFS)
+
diff --git a/nx-X11/lib/GL/mesa/swrast/Imakefile b/nx-X11/lib/GL/mesa/swrast/Imakefile
new file mode 100644
index 000000000..105615b82
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/swrast/Imakefile
@@ -0,0 +1,100 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/swrast/Imakefile,v 1.8 2002/11/25 12:58:55 tsi Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if BuildOSMesaLib || (BuildXF86DRI && (GlxDriverUsesMesa || GlxBuiltInXMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+/* Large PIC tables needed for Solaris SPARC builds */
+#if (defined(SunArchitecture) && defined(SparcArchitecture))
+# define LargePICTable YES
+#endif
+
+#define MesaSwrastBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I../../../include \
+ -I$(INCLUDESRC)/GL -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ ASM_DIR = x86
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_DIR = sparc
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/array_cache \
+ -I$(MESASRCDIR)/src/mesa/math \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/swrast \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/src/mesa/$(ASM_DIR) \
+ -I$(MESASRCDIR)/include \
+ -I../../../include -I$(XINCLUDESRC)
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = $(MESA_SWRAST_SRCS)
+ OBJS = $(MESA_SWRAST_OBJS)
+
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/swrast/Imakefile.inc b/nx-X11/lib/GL/mesa/swrast/Imakefile.inc
new file mode 100644
index 000000000..683b8f0a7
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/swrast/Imakefile.inc
@@ -0,0 +1,218 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/swrast/Imakefile.inc,v 1.1tsi Exp $
+
+#ifndef MesaSwrastBuildDir
+#define MesaSwrastBuildDir $(GLXLIBSRC)/mesa/swrast/
+#endif
+
+MESASWRASTBUILDDIR = MesaSwrastBuildDir
+
+ MESA_SWRAST_SRCS = $(MESASWRASTBUILDDIR)s_aaline.c \
+ $(MESASWRASTBUILDDIR)s_aatriangle.c \
+ $(MESASWRASTBUILDDIR)s_accum.c \
+ $(MESASWRASTBUILDDIR)s_alpha.c \
+ $(MESASWRASTBUILDDIR)s_atifragshader.c \
+ $(MESASWRASTBUILDDIR)s_bitmap.c \
+ $(MESASWRASTBUILDDIR)s_blend.c \
+ $(MESASWRASTBUILDDIR)s_buffers.c \
+ $(MESASWRASTBUILDDIR)s_context.c \
+ $(MESASWRASTBUILDDIR)s_copypix.c \
+ $(MESASWRASTBUILDDIR)s_depth.c \
+ $(MESASWRASTBUILDDIR)s_drawpix.c \
+ $(MESASWRASTBUILDDIR)s_feedback.c \
+ $(MESASWRASTBUILDDIR)s_fog.c \
+ $(MESASWRASTBUILDDIR)s_imaging.c \
+ $(MESASWRASTBUILDDIR)s_lines.c \
+ $(MESASWRASTBUILDDIR)s_logic.c \
+ $(MESASWRASTBUILDDIR)s_masking.c \
+ $(MESASWRASTBUILDDIR)s_nvfragprog.c \
+ $(MESASWRASTBUILDDIR)s_pixeltex.c \
+ $(MESASWRASTBUILDDIR)s_points.c \
+ $(MESASWRASTBUILDDIR)s_readpix.c \
+ $(MESASWRASTBUILDDIR)s_span.c \
+ $(MESASWRASTBUILDDIR)s_stencil.c \
+ $(MESASWRASTBUILDDIR)s_texstore.c \
+ $(MESASWRASTBUILDDIR)s_texture.c \
+ $(MESASWRASTBUILDDIR)s_triangle.c \
+ $(MESASWRASTBUILDDIR)s_zoom.c
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(s_aaline.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_aaline.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_aalinetemp.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_aatriangle.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_aatriangle.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_aatritemp.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_accum.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_accum.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_alpha.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_alpha.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_atifragshader.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_atifragshader.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_bitmap.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_blend.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_blend.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_buffers.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_context.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_context.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_copypix.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_depth.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_depth.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_drawpix.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_drawpix.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_feedback.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_feedback.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_fog.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_fog.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_imaging.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_lines.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_lines.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_linetemp.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_logic.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_logic.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_masking.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_masking.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_nvfragprog.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_nvfragprog.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_pixeltex.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_pixeltex.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_points.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_points.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_pointtemp.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_readpix.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_span.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_span.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_spantemp.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_stencil.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_stencil.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_texstore.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_texture.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_texture.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_triangle.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_triangle.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_trispan.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_tritemp.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_zoom.c, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(s_zoom.h, $(MESASRCDIR)/src/mesa/swrast)
+LinkSourceFile(swrast.h, $(MESASRCDIR)/src/mesa/swrast)
+#endif
+
+ MESA_SWRAST_OBJS = $(MESASWRASTBUILDDIR)s_aaline.o \
+ $(MESASWRASTBUILDDIR)s_aatriangle.o \
+ $(MESASWRASTBUILDDIR)s_accum.o \
+ $(MESASWRASTBUILDDIR)s_alpha.o \
+ $(MESASWRASTBUILDDIR)s_atifragshader.o \
+ $(MESASWRASTBUILDDIR)s_bitmap.o \
+ $(MESASWRASTBUILDDIR)s_blend.o \
+ $(MESASWRASTBUILDDIR)s_buffers.o \
+ $(MESASWRASTBUILDDIR)s_context.o \
+ $(MESASWRASTBUILDDIR)s_copypix.o \
+ $(MESASWRASTBUILDDIR)s_depth.o \
+ $(MESASWRASTBUILDDIR)s_drawpix.o \
+ $(MESASWRASTBUILDDIR)s_feedback.o \
+ $(MESASWRASTBUILDDIR)s_fog.o \
+ $(MESASWRASTBUILDDIR)s_imaging.o \
+ $(MESASWRASTBUILDDIR)s_lines.o \
+ $(MESASWRASTBUILDDIR)s_logic.o \
+ $(MESASWRASTBUILDDIR)s_masking.o \
+ $(MESASWRASTBUILDDIR)s_nvfragprog.o \
+ $(MESASWRASTBUILDDIR)s_pixeltex.o \
+ $(MESASWRASTBUILDDIR)s_points.o \
+ $(MESASWRASTBUILDDIR)s_readpix.o \
+ $(MESASWRASTBUILDDIR)s_span.o \
+ $(MESASWRASTBUILDDIR)s_stencil.o \
+ $(MESASWRASTBUILDDIR)s_texstore.o \
+ $(MESASWRASTBUILDDIR)s_texture.o \
+ $(MESASWRASTBUILDDIR)s_triangle.o \
+ $(MESASWRASTBUILDDIR)s_zoom.o
+
+#if defined(DoSharedLib) && DoSharedLib
+ MESA_SWRAST_UOBJS = $(MESASWRASTBUILDDIR)unshared/s_aaline.o \
+ $(MESASWRASTBUILDDIR)unshared/s_aatriangle.o \
+ $(MESASWRASTBUILDDIR)unshared/s_accum.o \
+ $(MESASWRASTBUILDDIR)unshared/s_alpha.o \
+ $(MESASWRASTBUILDDIR)unshared/s_atifragshader.o \
+ $(MESASWRASTBUILDDIR)unshared/s_bitmap.o \
+ $(MESASWRASTBUILDDIR)unshared/s_blend.o \
+ $(MESASWRASTBUILDDIR)unshared/s_buffers.o \
+ $(MESASWRASTBUILDDIR)unshared/s_context.o \
+ $(MESASWRASTBUILDDIR)unshared/s_copypix.o \
+ $(MESASWRASTBUILDDIR)unshared/s_depth.o \
+ $(MESASWRASTBUILDDIR)unshared/s_drawpix.o \
+ $(MESASWRASTBUILDDIR)unshared/s_feedback.o \
+ $(MESASWRASTBUILDDIR)unshared/s_fog.o \
+ $(MESASWRASTBUILDDIR)unshared/s_imaging.o \
+ $(MESASWRASTBUILDDIR)unshared/s_lines.o \
+ $(MESASWRASTBUILDDIR)unshared/s_logic.o \
+ $(MESASWRASTBUILDDIR)unshared/s_masking.o \
+ $(MESASWRASTBUILDDIR)unshared/s_nvfragprog.o \
+ $(MESASWRASTBUILDDIR)unshared/s_pixeltex.o \
+ $(MESASWRASTBUILDDIR)unshared/s_points.o \
+ $(MESASWRASTBUILDDIR)unshared/s_readpix.o \
+ $(MESASWRASTBUILDDIR)unshared/s_span.o \
+ $(MESASWRASTBUILDDIR)unshared/s_stencil.o \
+ $(MESASWRASTBUILDDIR)unshared/s_texstore.o \
+ $(MESASWRASTBUILDDIR)unshared/s_texture.o \
+ $(MESASWRASTBUILDDIR)unshared/s_triangle.o \
+ $(MESASWRASTBUILDDIR)unshared/s_zoom.o
+#else
+ MESA_SWRAST_UOBJS = $(MESA_SWRAST_OBJS)
+#endif
+
+ MESA_SWRAST_DOBJS = $(MESASWRASTBUILDDIR)debugger/s_aaline.o \
+ $(MESASWRASTBUILDDIR)debugger/s_aatriangle.o \
+ $(MESASWRASTBUILDDIR)debugger/s_accum.o \
+ $(MESASWRASTBUILDDIR)debugger/s_alpha.o \
+ $(MESASWRASTBUILDDIR)debugger/s_atifragshader.o \
+ $(MESASWRASTBUILDDIR)debugger/s_bitmap.o \
+ $(MESASWRASTBUILDDIR)debugger/s_blend.o \
+ $(MESASWRASTBUILDDIR)debugger/s_buffers.o \
+ $(MESASWRASTBUILDDIR)debugger/s_context.o \
+ $(MESASWRASTBUILDDIR)debugger/s_copypix.o \
+ $(MESASWRASTBUILDDIR)debugger/s_depth.o \
+ $(MESASWRASTBUILDDIR)debugger/s_drawpix.o \
+ $(MESASWRASTBUILDDIR)debugger/s_feedback.o \
+ $(MESASWRASTBUILDDIR)debugger/s_fog.o \
+ $(MESASWRASTBUILDDIR)debugger/s_imaging.o \
+ $(MESASWRASTBUILDDIR)debugger/s_lines.o \
+ $(MESASWRASTBUILDDIR)debugger/s_logic.o \
+ $(MESASWRASTBUILDDIR)debugger/s_masking.o \
+ $(MESASWRASTBUILDDIR)debugger/s_nvfragprog.o \
+ $(MESASWRASTBUILDDIR)debugger/s_pixeltex.o \
+ $(MESASWRASTBUILDDIR)debugger/s_points.o \
+ $(MESASWRASTBUILDDIR)debugger/s_readpix.o \
+ $(MESASWRASTBUILDDIR)debugger/s_span.o \
+ $(MESASWRASTBUILDDIR)debugger/s_stencil.o \
+ $(MESASWRASTBUILDDIR)debugger/s_texstore.o \
+ $(MESASWRASTBUILDDIR)debugger/s_texture.o \
+ $(MESASWRASTBUILDDIR)debugger/s_triangle.o \
+ $(MESASWRASTBUILDDIR)debugger/s_zoom.o
+
+ MESA_SWRAST_POBJS = $(MESASWRASTBUILDDIR)profiled/s_aaline.o \
+ $(MESASWRASTBUILDDIR)profiled/s_aatriangle.o \
+ $(MESASWRASTBUILDDIR)profiled/s_accum.o \
+ $(MESASWRASTBUILDDIR)profiled/s_alpha.o \
+ $(MESASWRASTBUILDDIR)profiled/s_atifragshader.o \
+ $(MESASWRASTBUILDDIR)profiled/s_bitmap.o \
+ $(MESASWRASTBUILDDIR)profiled/s_blend.o \
+ $(MESASWRASTBUILDDIR)profiled/s_buffers.o \
+ $(MESASWRASTBUILDDIR)profiled/s_context.o \
+ $(MESASWRASTBUILDDIR)profiled/s_copypix.o \
+ $(MESASWRASTBUILDDIR)profiled/s_depth.o \
+ $(MESASWRASTBUILDDIR)profiled/s_drawpix.o \
+ $(MESASWRASTBUILDDIR)profiled/s_feedback.o \
+ $(MESASWRASTBUILDDIR)profiled/s_fog.o \
+ $(MESASWRASTBUILDDIR)profiled/s_imaging.o \
+ $(MESASWRASTBUILDDIR)profiled/s_lines.o \
+ $(MESASWRASTBUILDDIR)profiled/s_logic.o \
+ $(MESASWRASTBUILDDIR)profiled/s_masking.o \
+ $(MESASWRASTBUILDDIR)profiled/s_nvfragprog.o \
+ $(MESASWRASTBUILDDIR)profiled/s_pixeltex.o \
+ $(MESASWRASTBUILDDIR)profiled/s_points.o \
+ $(MESASWRASTBUILDDIR)profiled/s_readpix.o \
+ $(MESASWRASTBUILDDIR)profiled/s_span.o \
+ $(MESASWRASTBUILDDIR)profiled/s_stencil.o \
+ $(MESASWRASTBUILDDIR)profiled/s_texstore.o \
+ $(MESASWRASTBUILDDIR)profiled/s_texture.o \
+ $(MESASWRASTBUILDDIR)profiled/s_triangle.o \
+ $(MESASWRASTBUILDDIR)profiled/s_zoom.o
+
diff --git a/nx-X11/lib/GL/mesa/swrast_setup/Imakefile b/nx-X11/lib/GL/mesa/swrast_setup/Imakefile
new file mode 100644
index 000000000..58766149d
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/swrast_setup/Imakefile
@@ -0,0 +1,99 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/swrast_setup/Imakefile,v 1.8 2002/11/25 12:58:55 tsi Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if BuildOSMesaLib || (BuildXF86DRI && (GlxDriverUsesMesa || GlxBuiltInXMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+/* Large PIC tables needed for Solaris SPARC builds */
+#if (defined(SunArchitecture) && defined(SparcArchitecture))
+# define LargePICTable YES
+#endif
+
+
+#define MesaSwrastSetupBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I../../../include \
+ -I$(INCLUDESRC)/GL -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ ASM_DIR = x86
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_DIR = sparc
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/$(ASM_DIR) \
+ -I$(MESASRCDIR)/src/mesa/math \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/swrast_setup \
+ -I$(MESASRCDIR)/src/mesa/tnl \
+ -I$(MESASRCDIR)/include \
+ -I../../../include -I$(XINCLUDESRC)
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = $(MESA_SWR_SETUP_SRCS)
+ OBJS = $(MESA_SWR_SETUP_OBJS)
+
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/swrast_setup/Imakefile.inc b/nx-X11/lib/GL/mesa/swrast_setup/Imakefile.inc
new file mode 100644
index 000000000..8d32aedb3
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/swrast_setup/Imakefile.inc
@@ -0,0 +1,36 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/swrast_setup/Imakefile.inc,v 1.1tsi Exp $
+
+#ifndef MesaSwrastSetupBuildDir
+#define MesaSwrastSetupBuildDir $(GLXLIBSRC)/mesa/swrast_setup/
+#endif
+
+MESASWRSETUPDIR = MesaSwrastSetupBuildDir
+
+ MESA_SWR_SETUP_SRCS = $(MESASWRSETUPDIR)ss_context.c \
+ $(MESASWRSETUPDIR)ss_triangle.c
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(ss_context.c, $(MESASRCDIR)/src/mesa/swrast_setup)
+LinkSourceFile(ss_context.h, $(MESASRCDIR)/src/mesa/swrast_setup)
+LinkSourceFile(ss_triangle.c, $(MESASRCDIR)/src/mesa/swrast_setup)
+LinkSourceFile(ss_triangle.h, $(MESASRCDIR)/src/mesa/swrast_setup)
+LinkSourceFile(ss_tritmp.h, $(MESASRCDIR)/src/mesa/swrast_setup)
+LinkSourceFile(swrast_setup.h, $(MESASRCDIR)/src/mesa/swrast_setup)
+#endif
+
+ MESA_SWR_SETUP_OBJS = $(MESASWRSETUPDIR)ss_context.o \
+ $(MESASWRSETUPDIR)ss_triangle.o
+
+#if defined(DoSharedLib) && DoSharedLib
+MESA_SWR_SETUP_UOBJS = $(MESASWRSETUPDIR)unshared/ss_context.o \
+ $(MESASWRSETUPDIR)unshared/ss_triangle.o
+#else
+MESA_SWR_SETUP_UOBJS = $(MESA_SWR_SETUP_OBJS)
+#endif
+
+MESA_SWR_SETUP_DOBJS = $(MESASWRSETUPDIR)debugger/ss_context.o \
+ $(MESASWRSETUPDIR)debugger/ss_triangle.o
+
+MESA_SWR_SETUP_POBJS = $(MESASWRSETUPDIR)profiled/ss_context.o \
+ $(MESASWRSETUPDIR)profiled/ss_triangle.o
+
diff --git a/nx-X11/lib/GL/mesa/tnl/Imakefile b/nx-X11/lib/GL/mesa/tnl/Imakefile
new file mode 100644
index 000000000..99ec7525c
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/tnl/Imakefile
@@ -0,0 +1,101 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/tnl/Imakefile,v 1.8 2002/11/25 12:58:55 tsi Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if BuildOSMesaLib || (BuildXF86DRI && (GlxDriverUsesMesa || GlxBuiltInXMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+/* Large PIC tables needed for Solaris SPARC builds */
+#if (defined(SunArchitecture) && defined(SparcArchitecture))
+# define LargePICTable YES
+#endif
+
+#define MesaTnlBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I../../../include \
+ -I$(INCLUDESRC)/GL -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ ASM_DIR = x86
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_DIR = sparc
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/$(ASM_DIR) \
+ -I$(MESASRCDIR)/src/mesa/array_cache \
+ -I$(MESASRCDIR)/src/mesa/math \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/swrast_setup \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/src/mesa/tnl \
+ -I$(MESASRCDIR)/include \
+ -I../../../include -I$(XINCLUDESRC)
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = $(MESA_TNL_SRCS)
+ OBJS = $(MESA_TNL_OBJS)
+
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/tnl/Imakefile.inc b/nx-X11/lib/GL/mesa/tnl/Imakefile.inc
new file mode 100644
index 000000000..a294a6fbf
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/tnl/Imakefile.inc
@@ -0,0 +1,225 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/tnl/Imakefile.inc,v 1.1tsi Exp $
+
+#ifndef MesaTnlBuildDir
+#define MesaTnlBuildDir $(GLXLIBSRC)/mesa/tnl/
+#endif
+
+MESATNLBUILDDIR = MesaTnlBuildDir
+
+ MESA_TNL_SRCS = $(MESATNLBUILDDIR)t_array_api.c \
+ $(MESATNLBUILDDIR)t_array_import.c \
+ $(MESATNLBUILDDIR)t_context.c \
+ $(MESATNLBUILDDIR)t_pipeline.c \
+ $(MESATNLBUILDDIR)t_save_api.c \
+ $(MESATNLBUILDDIR)t_save_loopback.c \
+ $(MESATNLBUILDDIR)t_save_playback.c \
+ $(MESATNLBUILDDIR)t_vb_arbprogram.c \
+ $(MESATNLBUILDDIR)t_vb_arbprogram_sse.c \
+ $(MESATNLBUILDDIR)t_vb_fog.c \
+ $(MESATNLBUILDDIR)t_vb_cull.c \
+ $(MESATNLBUILDDIR)t_vb_light.c \
+ $(MESATNLBUILDDIR)t_vb_normals.c \
+ $(MESATNLBUILDDIR)t_vb_points.c \
+ $(MESATNLBUILDDIR)t_vb_program.c \
+ $(MESATNLBUILDDIR)t_vb_render.c \
+ $(MESATNLBUILDDIR)t_vb_texgen.c \
+ $(MESATNLBUILDDIR)t_vb_texmat.c \
+ $(MESATNLBUILDDIR)t_vb_vertex.c \
+ $(MESATNLBUILDDIR)t_vertex.c \
+ $(MESATNLBUILDDIR)t_vertex_generic.c \
+ $(MESATNLBUILDDIR)t_vertex_sse.c \
+ $(MESATNLBUILDDIR)t_vp_build.c \
+ $(MESATNLBUILDDIR)t_vtx_api.c \
+ $(MESATNLBUILDDIR)t_vtx_eval.c \
+ $(MESATNLBUILDDIR)t_vtx_exec.c \
+ $(MESATNLBUILDDIR)t_vtx_generic.c
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ MESA_TNL_SRCS += MesaTnlAsmSrcs $(MESATNLBUILDDIR)t_vtx_x86.c \
+ $(MESATNLBUILDDIR)t_vtx_x86_gcc.S
+#endif
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(t_array_api.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_array_api.h, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_array_import.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_array_import.h, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_context.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_context.h, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(tnl.h, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_pipeline.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_pipeline.h, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_save_api.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_save_api.h, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_save_loopback.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_save_playback.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_arbprogram.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_arbprogram.h, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_arbprogram_sse.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_cliptmp.h, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_fog.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_cull.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_light.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_lighttmp.h, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_normals.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_points.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_program.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_render.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_rendertmp.h, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_texgen.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_texmat.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vb_vertex.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vertex.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vertex.h, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vertex_generic.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vertex_sse.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vp_build.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vp_build.h, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vtx_api.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vtx_api.h, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vtx_eval.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vtx_exec.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vtx_generic.c, $(MESASRCDIR)/src/mesa/tnl)
+#if defined(i386Architecture) && MesaUseX86Asm
+LinkSourceFile(t_vtx_x86.c, $(MESASRCDIR)/src/mesa/tnl)
+LinkSourceFile(t_vtx_x86_gcc.S, $(MESASRCDIR)/src/mesa/tnl)
+#endif
+#endif
+
+ MESA_TNL_OBJS = $(MESATNLBUILDDIR)t_array_api.o \
+ $(MESATNLBUILDDIR)t_array_import.o \
+ $(MESATNLBUILDDIR)t_context.o \
+ $(MESATNLBUILDDIR)t_pipeline.o \
+ $(MESATNLBUILDDIR)t_save_api.o \
+ $(MESATNLBUILDDIR)t_save_loopback.o \
+ $(MESATNLBUILDDIR)t_save_playback.o \
+ $(MESATNLBUILDDIR)t_vb_arbprogram.o \
+ $(MESATNLBUILDDIR)t_vb_arbprogram_sse.o \
+ $(MESATNLBUILDDIR)t_vb_fog.o \
+ $(MESATNLBUILDDIR)t_vb_cull.o \
+ $(MESATNLBUILDDIR)t_vb_light.o \
+ $(MESATNLBUILDDIR)t_vb_normals.o \
+ $(MESATNLBUILDDIR)t_vb_points.o \
+ $(MESATNLBUILDDIR)t_vb_program.o \
+ $(MESATNLBUILDDIR)t_vb_render.o \
+ $(MESATNLBUILDDIR)t_vb_texgen.o \
+ $(MESATNLBUILDDIR)t_vb_texmat.o \
+ $(MESATNLBUILDDIR)t_vb_vertex.o \
+ $(MESATNLBUILDDIR)t_vertex.o \
+ $(MESATNLBUILDDIR)t_vertex_generic.o \
+ $(MESATNLBUILDDIR)t_vertex_sse.o \
+ $(MESATNLBUILDDIR)t_vp_build.o \
+ $(MESATNLBUILDDIR)t_vtx_api.o \
+ $(MESATNLBUILDDIR)t_vtx_eval.o \
+ $(MESATNLBUILDDIR)t_vtx_exec.o \
+ $(MESATNLBUILDDIR)t_vtx_generic.o
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ MESA_TNL_OBJS += $(MESATNLBUILDDIR)t_vtx_x86.o \
+ $(MESATNLBUILDDIR)t_vtx_x86_gcc.o
+#endif
+
+#if defined(DoSharedLib) && DoSharedLib
+ MESA_TNL_UOBJS = $(MESATNLBUILDDIR)unshared/t_array_api.o \
+ $(MESATNLBUILDDIR)unshared/t_array_import.o \
+ $(MESATNLBUILDDIR)unshared/t_context.o \
+ $(MESATNLBUILDDIR)unshared/t_pipeline.o \
+ $(MESATNLBUILDDIR)unshared/t_save_api.o \
+ $(MESATNLBUILDDIR)unshared/t_save_loopback.o \
+ $(MESATNLBUILDDIR)unshared/t_save_playback.o \
+ $(MESATNLBUILDDIR)unshared/t_vb_arbprogram.o \
+ $(MESATNLBUILDDIR)unshared/t_vb_arbprogram_sse.o \
+ $(MESATNLBUILDDIR)unshared/t_vb_fog.o \
+ $(MESATNLBUILDDIR)unshared/t_vb_cull.o \
+ $(MESATNLBUILDDIR)unshared/t_vb_light.o \
+ $(MESATNLBUILDDIR)unshared/t_vb_normals.o \
+ $(MESATNLBUILDDIR)unshared/t_vb_points.o \
+ $(MESATNLBUILDDIR)unshared/t_vb_program.o \
+ $(MESATNLBUILDDIR)unshared/t_vb_render.o \
+ $(MESATNLBUILDDIR)unshared/t_vb_texgen.o \
+ $(MESATNLBUILDDIR)unshared/t_vb_texmat.o \
+ $(MESATNLBUILDDIR)unshared/t_vb_vertex.o \
+ $(MESATNLBUILDDIR)unshared/t_vertex.o \
+ $(MESATNLBUILDDIR)unshared/t_vertex_generic.o \
+ $(MESATNLBUILDDIR)unshared/t_vertex_sse.o \
+ $(MESATNLBUILDDIR)unshared/t_vp_build.o \
+ $(MESATNLBUILDDIR)unshared/t_vtx_api.o \
+ $(MESATNLBUILDDIR)unshared/t_vtx_eval.o \
+ $(MESATNLBUILDDIR)unshared/t_vtx_exec.o \
+ $(MESATNLBUILDDIR)unshared/t_vtx_generic.o
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ MESA_TNL_UOBJS += $(MESATNLBUILDDIR)unshared/t_vtx_x86.o \
+ $(MESATNLBUILDDIR)t_vtx_x86_gcc.o
+#endif
+
+#else
+ MESA_TNL_UOBJS = $(MESA_TNL_OBJS)
+#endif
+
+ MESA_TNL_DOBJS = $(MESATNLBUILDDIR)debugger/t_array_api.o \
+ $(MESATNLBUILDDIR)debugger/t_array_import.o \
+ $(MESATNLBUILDDIR)debugger/t_context.o \
+ $(MESATNLBUILDDIR)debugger/t_pipeline.o \
+ $(MESATNLBUILDDIR)debugger/t_save_api.o \
+ $(MESATNLBUILDDIR)debugger/t_save_loopback.o \
+ $(MESATNLBUILDDIR)debugger/t_save_playback.o \
+ $(MESATNLBUILDDIR)debugger/t_vb_arbprogram.o \
+ $(MESATNLBUILDDIR)debugger/t_vb_arbprogram_sse.o \
+ $(MESATNLBUILDDIR)debugger/t_vb_fog.o \
+ $(MESATNLBUILDDIR)debugger/t_vb_cull.o \
+ $(MESATNLBUILDDIR)debugger/t_vb_light.o \
+ $(MESATNLBUILDDIR)debugger/t_vb_normals.o \
+ $(MESATNLBUILDDIR)debugger/t_vb_points.o \
+ $(MESATNLBUILDDIR)debugger/t_vb_program.o \
+ $(MESATNLBUILDDIR)debugger/t_vb_render.o \
+ $(MESATNLBUILDDIR)debugger/t_vb_texgen.o \
+ $(MESATNLBUILDDIR)debugger/t_vb_texmat.o \
+ $(MESATNLBUILDDIR)debugger/t_vb_vertex.o \
+ $(MESATNLBUILDDIR)debugger/t_vertex.o \
+ $(MESATNLBUILDDIR)debugger/t_vertex_generic.o \
+ $(MESATNLBUILDDIR)debugger/t_vertex_sse.o \
+ $(MESATNLBUILDDIR)debugger/t_vp_build.o \
+ $(MESATNLBUILDDIR)debugger/t_vtx_api.o \
+ $(MESATNLBUILDDIR)debugger/t_vtx_eval.o \
+ $(MESATNLBUILDDIR)debugger/t_vtx_exec.o \
+ $(MESATNLBUILDDIR)debugger/t_vtx_generic.o
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ MESA_TNL_DOBJS += $(MESATNLBUILDDIR)debugger/t_vtx_x86.o \
+ $(MESATNLBUILDDIR)debugger/t_vtx_x86_gcc.o
+#endif
+
+ MESA_TNL_POBJS = $(MESATNLBUILDDIR)profiled/t_array_api.o \
+ $(MESATNLBUILDDIR)profiled/t_array_import.o \
+ $(MESATNLBUILDDIR)profiled/t_context.o \
+ $(MESATNLBUILDDIR)profiled/t_pipeline.o \
+ $(MESATNLBUILDDIR)profiled/t_save_api.o \
+ $(MESATNLBUILDDIR)profiled/t_save_loopback.o \
+ $(MESATNLBUILDDIR)profiled/t_save_playback.o \
+ $(MESATNLBUILDDIR)profiled/t_vb_arbprogram.o \
+ $(MESATNLBUILDDIR)profiled/t_vb_arbprogram_sse.o \
+ $(MESATNLBUILDDIR)profiled/t_vb_fog.o \
+ $(MESATNLBUILDDIR)profiled/t_vb_cull.o \
+ $(MESATNLBUILDDIR)profiled/t_vb_light.o \
+ $(MESATNLBUILDDIR)profiled/t_vb_normals.o \
+ $(MESATNLBUILDDIR)profiled/t_vb_points.o \
+ $(MESATNLBUILDDIR)profiled/t_vb_program.o \
+ $(MESATNLBUILDDIR)profiled/t_vb_render.o \
+ $(MESATNLBUILDDIR)profiled/t_vb_texgen.o \
+ $(MESATNLBUILDDIR)profiled/t_vb_texmat.o \
+ $(MESATNLBUILDDIR)profiled/t_vb_vertex.o \
+ $(MESATNLBUILDDIR)profiled/t_vertex.o \
+ $(MESATNLBUILDDIR)profiled/t_vertex_generic.o \
+ $(MESATNLBUILDDIR)profiled/t_vertex_sse.o \
+ $(MESATNLBUILDDIR)profiled/t_vp_build.o \
+ $(MESATNLBUILDDIR)profiled/t_vtx_api.o \
+ $(MESATNLBUILDDIR)profiled/t_vtx_eval.o \
+ $(MESATNLBUILDDIR)profiled/t_vtx_exec.o \
+ $(MESATNLBUILDDIR)profiled/t_vtx_generic.o
+
+#if defined(i386Architecture) && MesaUseX86Asm
+ MESA_TNL_POBJS += $(MESATNLBUILDDIR)profiled/t_vtx_x86.o \
+ $(MESATNLBUILDDIR)profiled/t_vtx_x86_gcc.o
+#endif
+
diff --git a/nx-X11/lib/GL/mesa/tnl_dd/Imakefile b/nx-X11/lib/GL/mesa/tnl_dd/Imakefile
new file mode 100644
index 000000000..93b8c8877
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/tnl_dd/Imakefile
@@ -0,0 +1,63 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/tnl_dd/Imakefile,v 1.6 2002/11/25 12:58:55 tsi Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if GlxDriverUsesMesa || GlxBuiltInXMesa || BuildOSMesaLib
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+/* Large PIC tables needed for Solaris SPARC builds */
+#if (defined(SunArchitecture) && defined(SparcArchitecture))
+# define LargePICTable YES
+#endif
+
+#define MesaTnlDdBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DIN_DRI_DRIVER
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I../../../include \
+ -I$(XINCLUDESRC) -I$(INCLUDESRC)/GL \
+ -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESASRCDIR)/src/math \
+ -I$(MESASRCDIR)/src/tnl_dd \
+ -I$(MESASRCDIR)/include \
+ -I../../../include
+
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/tnl_dd/Imakefile.inc b/nx-X11/lib/GL/mesa/tnl_dd/Imakefile.inc
new file mode 100644
index 000000000..8d5d3da2d
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/tnl_dd/Imakefile.inc
@@ -0,0 +1,40 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/tnl_dd/Imakefile.inc,v 1.1tsi Exp $
+
+#ifndef MesaTnlDdBuildDir
+#define MesaTnlDdBuildDir $(GLXLIBSRC)/mesa/tnl_dd/
+#endif
+
+MESATNLDDBUILDDIR = MesaTnlDdBuildDir
+
+ MESA_TNL_DD_SRCS = $(MESATNLDDBUILDDIR)t_dd.c \
+ $(MESATNLDDBUILDDIR)t_dd_vb.c
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(t_dd.c, $(MESASRCDIR)/src/mesa/tnl_dd)
+LinkSourceFile(t_dd_vb.c, $(MESASRCDIR)/src/mesa/tnl_dd)
+LinkSourceFile(t_dd_dmatmp2.h, $(MESASRCDIR)/src/mesa/tnl_dd)
+LinkSourceFile(t_dd_dmatmp.h, $(MESASRCDIR)/src/mesa/tnl_dd)
+LinkSourceFile(t_dd_rendertmp.h, $(MESASRCDIR)/src/mesa/tnl_dd)
+LinkSourceFile(t_dd_triemit.h, $(MESASRCDIR)/src/mesa/tnl_dd)
+LinkSourceFile(t_dd_tritmp.h, $(MESASRCDIR)/src/mesa/tnl_dd)
+LinkSourceFile(t_dd_unfilled.h, $(MESASRCDIR)/src/mesa/tnl_dd)
+LinkSourceFile(t_dd_vbtmp.h, $(MESASRCDIR)/src/mesa/tnl_dd)
+LinkSourceFile(t_dd_vertex.h, $(MESASRCDIR)/src/mesa/tnl_dd)
+#endif
+
+ MESA_TNL_DD_OBJS = $(MESATNLDDBUILDDIR)t_dd.o \
+ $(MESATNLDDBUILDDIR)t_dd_vb.o
+
+#if defined(DoSharedLib) && DoSharedLib
+MESA_TNL_DD_UOBJS = $(MESATNLDDBUILDDIR)unshared/t_dd.o \
+ $(MESATNLDDBUILDDIR)unshared/t_dd_vb.o
+#else
+MESA_TNL_DD_UOBJS = $(MESA_TNL_DD_OBJS)
+#endif
+
+MESA_TNL_DD_DOBJS = $(MESATNLDDBUILDDIR)debugger/t_dd.o \
+ $(MESATNLDDBUILDDIR)debugger/t_dd_vb.o
+
+MESA_TNL_DD_POBJS = $(MESATNLDDBUILDDIR)profiled/t_dd.o \
+ $(MESATNLDDBUILDDIR)profiled/t_dd_vb.o
+
diff --git a/nx-X11/lib/GL/mesa/x86/Imakefile b/nx-X11/lib/GL/mesa/x86/Imakefile
new file mode 100644
index 000000000..543c05143
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/x86/Imakefile
@@ -0,0 +1,108 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/X86/Imakefile,v 1.23 2002/07/14 17:08:16 alanh Exp $
+
+/*
+ * Need both shared and unshared Mesa objects in the following cases:
+ * GlxDriverUsesMesa
+ * GlxBuiltInXMesa
+ * BuildOSMesaLib
+ *
+ * In other cases, only the shared version is needed to link in to loadable
+ * driver modules.
+ */
+
+#if GlxDriverUsesMesa || GlxBuiltInXMesa || BuildOSMesaLib
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#define MesaX86BuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+ DEFINES = $(ALLOC_DEFINES) GlxDefines -DIN_DRI_DRIVER $(MESA_ASM_DEFINES)
+ INCLUDES = /*-I$(INCLUDESRC) -I$(EXTINCSRC)*/ -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/include \
+ -I$(GLXLIBSRC)/include \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/x86 \
+ -I$(MESASRCDIR)/src/mesa/glapi
+
+ SRCS = $(MESA_ASM_SRCS) gen_matypes.c
+ OBJS = $(MESA_ASM_OBJS)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+STD_CPP_DEFINES = StandardDefines $(PROJECT_DEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+ObjectFromAsmSource(common_x86_asm, NullParameter)
+ObjectFromAsmSource(read_rgba_span_x86, NullParameter)
+ObjectFromAsmSource(x86_cliptest, NullParameter)
+ObjectFromAsmSource(x86_xform2, NullParameter)
+ObjectFromAsmSource(x86_xform3, NullParameter)
+ObjectFromAsmSource(x86_xform4, NullParameter)
+
+#if MesaUseMMX
+ObjectFromAsmSource(mmx_blend, NullParameter)
+#endif
+
+#if MesaUse3DNow
+ObjectFromAsmSource(3dnow_normal, NullParameter)
+ObjectFromAsmSource(3dnow_xform1, NullParameter)
+ObjectFromAsmSource(3dnow_xform2, NullParameter)
+ObjectFromAsmSource(3dnow_xform3, NullParameter)
+ObjectFromAsmSource(3dnow_xform4, NullParameter)
+#endif
+
+#if MesaUseSSE
+ObjectFromAsmSource(sse_normal, NullParameter)
+ObjectFromAsmSource(sse_xform1, NullParameter)
+ObjectFromAsmSource(sse_xform2, NullParameter)
+ObjectFromAsmSource(sse_xform3, NullParameter)
+ObjectFromAsmSource(sse_xform4, NullParameter)
+#endif
+
+LinkSourceFile(gen_matypes.c, $(MESASRCDIR)/src/mesa/x86)
+
+#if CrossCompiling
+HOST_CFLAGS=$(TOP_INCLUDES) $(INCLUDES) $(BOOTSTRAPCFLAGS) \
+ $(CROSSCOMPILEDEFINES) $(CROSSCOMPILEBOOTSTRAPDEFINES)
+#else
+HOST_CFLAGS=$(CFLAGS)
+#endif
+
+MATYPES = ./gen_matypes
+
+matypes.h: gen_matypes.c
+ RemoveFiles($@ HostProgramTargetName(gen_matypes))
+ -HostLinkRule(HostProgramTargetName(gen_matypes),$(HOST_CFLAGS) $(LOCAL_LDFLAGS),gen_matypes.c,$(LDLIBS))
+ RunProgram(MATYPES,> matypes_h)
+ $(MV) matypes_h $@
+ RemoveFiles(HostProgramTargetName(gen_matypes))
+
+includes:: matypes.h
+
+depend:: matypes.h
+
+clean::
+ RemoveFiles(matypes.h HostProgramTargetName(gen_matypes))
+
+DependTarget()
diff --git a/nx-X11/lib/GL/mesa/x86/Imakefile.inc b/nx-X11/lib/GL/mesa/x86/Imakefile.inc
new file mode 100644
index 000000000..b21c6f659
--- /dev/null
+++ b/nx-X11/lib/GL/mesa/x86/Imakefile.inc
@@ -0,0 +1,217 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/X86/Imakefile.inc,v 1.5 2002/11/14 21:01:16 tsi Exp $
+
+#ifndef MesaX86BuildDir
+#define MesaX86BuildDir $(GLXLIBSRC)/mesa/x86/
+#endif
+
+MESAX86BUILDDIR = MesaX86BuildDir
+
+MESA_X86_SRCS = $(MESAX86BUILDDIR)common_x86.c \
+ $(MESAX86BUILDDIR)common_x86_asm.S \
+ $(MESAX86BUILDDIR)glapi_x86.S \
+ $(MESAX86BUILDDIR)read_rgba_span_x86.S \
+ $(MESAX86BUILDDIR)x86.c \
+ $(MESAX86BUILDDIR)x86_cliptest.S \
+ $(MESAX86BUILDDIR)x86_xform2.S \
+ $(MESAX86BUILDDIR)x86_xform3.S \
+ $(MESAX86BUILDDIR)x86_xform4.S \
+ $(MESAX86BUILDDIR)x86sse.c
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(common_x86.c, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(common_x86_asm.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(glapi_x86.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(read_rgba_span_x86.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(read_rgba_span_x86.h, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(x86.c, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(x86_cliptest.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(x86_xform2.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(x86_xform3.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(x86_xform4.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(x86sse.c, $(MESASRCDIR)/src/mesa/x86/rtasm)
+LinkSourceFile(x86sse.h, $(MESASRCDIR)/src/mesa/x86/rtasm)
+#endif
+
+MESA_X86_OBJS = $(MESAX86BUILDDIR)common_x86.o \
+ $(MESAX86BUILDDIR)common_x86_asm.o \
+ $(MESAX86BUILDDIR)read_rgba_span_x86.o \
+ $(MESAX86BUILDDIR)x86.o \
+ $(MESAX86BUILDDIR)x86_cliptest.o \
+ $(MESAX86BUILDDIR)x86_xform2.o \
+ $(MESAX86BUILDDIR)x86_xform3.o \
+ $(MESAX86BUILDDIR)x86_xform4.o \
+ $(MESAX86BUILDDIR)x86sse.o
+
+#if defined(DoSharedLib) && DoSharedLib
+MESA_X86_UOBJS = $(MESAX86BUILDDIR)unshared/common_x86.o \
+ $(MESAX86BUILDDIR)common_x86_asm.o \
+ $(MESAX86BUILDDIR)read_rgba_span_x86.o \
+ $(MESAX86BUILDDIR)unshared/x86.o \
+ $(MESAX86BUILDDIR)x86_cliptest.o \
+ $(MESAX86BUILDDIR)x86_xform2.o \
+ $(MESAX86BUILDDIR)x86_xform3.o \
+ $(MESAX86BUILDDIR)x86_xform4.o \
+ $(MESAX86BUILDDIR)x86sse.o
+#else
+MESA_X86_UOBJS = $(MESA_X86_OBJS)
+#endif
+
+MESA_X86_DOBJS = $(MESAX86BUILDDIR)debugger/common_x86.o \
+ $(MESAX86BUILDDIR)common_x86_asm.o \
+ $(MESAX86BUILDDIR)read_rgba_span_x86.o \
+ $(MESAX86BUILDDIR)debugger/x86.o \
+ $(MESAX86BUILDDIR)x86_cliptest.o \
+ $(MESAX86BUILDDIR)x86_xform2.o \
+ $(MESAX86BUILDDIR)x86_xform3.o \
+ $(MESAX86BUILDDIR)x86_xform4.o \
+ $(MESAX86BUILDDIR)x86sse.o
+
+MESA_X86_POBJS = $(MESAX86BUILDDIR)profiled/common_x86.o \
+ $(MESAX86BUILDDIR)common_x86_asm.o \
+ $(MESAX86BUILDDIR)read_rgba_span_x86.o \
+ $(MESAX86BUILDDIR)profiled/x86.o \
+ $(MESAX86BUILDDIR)x86_cliptest.o \
+ $(MESAX86BUILDDIR)x86_xform2.o \
+ $(MESAX86BUILDDIR)x86_xform3.o \
+ $(MESAX86BUILDDIR)x86_xform4.o \
+ $(MESAX86BUILDDIR)x86sse.o
+
+MESA_X86_DEFS = -DUSE_X86_ASM
+
+
+#if MesaUseMMX
+MESA_MMX_SRCS = $(MESAX86BUILDDIR)mmx_blend.S
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(mmx_blend.S, $(MESASRCDIR)/src/mesa/x86)
+#endif
+
+MESA_MMX_OBJS = $(MESAX86BUILDDIR)mmx_blend.o
+
+MESA_MMX_UOBJS = $(MESA_MMX_OBJS)
+MESA_MMX_DOBJS = $(MESA_MMX_OBJS)
+MESA_MMX_POBJS = $(MESA_MMX_OBJS)
+
+MESA_MMX_DEFS = -DUSE_MMX_ASM
+#endif
+
+#if MesaUse3DNow
+MESA_3DNOW_SRCS = $(MESAX86BUILDDIR)3dnow.c \
+ $(MESAX86BUILDDIR)3dnow_normal.S \
+ $(MESAX86BUILDDIR)3dnow_xform1.S \
+ $(MESAX86BUILDDIR)3dnow_xform2.S \
+ $(MESAX86BUILDDIR)3dnow_xform3.S \
+ $(MESAX86BUILDDIR)3dnow_xform4.S
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(3dnow.c, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(3dnow_normal.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(3dnow_xform1.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(3dnow_xform2.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(3dnow_xform3.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(3dnow_xform4.S, $(MESASRCDIR)/src/mesa/x86)
+#endif
+MESA_3DNOW_OBJS = $(MESAX86BUILDDIR)3dnow.o \
+ $(MESAX86BUILDDIR)3dnow_normal.o \
+ $(MESAX86BUILDDIR)3dnow_xform1.o \
+ $(MESAX86BUILDDIR)3dnow_xform2.o \
+ $(MESAX86BUILDDIR)3dnow_xform3.o \
+ $(MESAX86BUILDDIR)3dnow_xform4.o
+
+#if defined(DoSharedLib) && DoSharedLib
+MESA_3DNOW_UOBJS = $(MESAX86BUILDDIR)unshared/3dnow.o \
+ $(MESAX86BUILDDIR)3dnow_normal.o \
+ $(MESAX86BUILDDIR)3dnow_xform1.o \
+ $(MESAX86BUILDDIR)3dnow_xform2.o \
+ $(MESAX86BUILDDIR)3dnow_xform3.o \
+ $(MESAX86BUILDDIR)3dnow_xform4.o
+#else
+MESA_3DNOW_UOBJS = $(MESA_3DNOW_OBJS)
+#endif
+
+MESA_3DNOW_DOBJS = $(MESAX86BUILDDIR)debugger/3dnow.o \
+ $(MESAX86BUILDDIR)3dnow_normal.o \
+ $(MESAX86BUILDDIR)3dnow_xform1.o \
+ $(MESAX86BUILDDIR)3dnow_xform2.o \
+ $(MESAX86BUILDDIR)3dnow_xform3.o \
+ $(MESAX86BUILDDIR)3dnow_xform4.o
+
+MESA_3DNOW_POBJS = $(MESAX86BUILDDIR)profiled/3dnow.o \
+ $(MESAX86BUILDDIR)3dnow_normal.o \
+ $(MESAX86BUILDDIR)3dnow_xform1.o \
+ $(MESAX86BUILDDIR)3dnow_xform2.o \
+ $(MESAX86BUILDDIR)3dnow_xform3.o \
+ $(MESAX86BUILDDIR)3dnow_xform4.o
+
+MESA_3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+
+#if MesaUseSSE
+MESA_SSE_SRCS = $(MESAX86BUILDDIR)sse.c \
+ $(MESAX86BUILDDIR)sse_normal.S \
+ $(MESAX86BUILDDIR)sse_xform1.S \
+ $(MESAX86BUILDDIR)sse_xform2.S \
+ $(MESAX86BUILDDIR)sse_xform3.S \
+ $(MESAX86BUILDDIR)sse_xform4.S
+
+#ifdef NeedToLinkMesaSrc
+LinkSourceFile(sse.c, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(sse_normal.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(sse_xform1.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(sse_xform2.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(sse_xform3.S, $(MESASRCDIR)/src/mesa/x86)
+LinkSourceFile(sse_xform4.S, $(MESASRCDIR)/src/mesa/x86)
+#endif
+
+MESA_SSE_OBJS = $(MESAX86BUILDDIR)sse.o \
+ $(MESAX86BUILDDIR)sse_normal.o \
+ $(MESAX86BUILDDIR)sse_xform1.o \
+ $(MESAX86BUILDDIR)sse_xform2.o \
+ $(MESAX86BUILDDIR)sse_xform3.o \
+ $(MESAX86BUILDDIR)sse_xform4.o
+
+#if defined(DoSharedLib) && DoSharedLib
+MESA_SSE_UOBJS = $(MESAX86BUILDDIR)unshared/sse.o \
+ $(MESAX86BUILDDIR)sse_normal.o \
+ $(MESAX86BUILDDIR)sse_xform1.o \
+ $(MESAX86BUILDDIR)sse_xform2.o \
+ $(MESAX86BUILDDIR)sse_xform3.o \
+ $(MESAX86BUILDDIR)sse_xform4.o
+#else
+MESA_SSE_UOBJS = $(MESA_SSE_OBJS)
+#endif
+
+MESA_SSE_DOBJS = $(MESAX86BUILDDIR)debugger/sse.o \
+ $(MESAX86BUILDDIR)sse_normal.o \
+ $(MESAX86BUILDDIR)sse_xform1.o \
+ $(MESAX86BUILDDIR)sse_xform2.o \
+ $(MESAX86BUILDDIR)sse_xform3.o \
+ $(MESAX86BUILDDIR)sse_xform4.o
+
+MESA_SSE_POBJS = $(MESAX86BUILDDIR)profiled/sse.o \
+ $(MESAX86BUILDDIR)sse_normal.o \
+ $(MESAX86BUILDDIR)sse_xform1.o \
+ $(MESAX86BUILDDIR)sse_xform2.o \
+ $(MESAX86BUILDDIR)sse_xform3.o \
+ $(MESAX86BUILDDIR)sse_xform4.o
+
+MESA_SSE_DEFS = -DUSE_SSE_ASM
+#endif
+
+MESA_ASM_SRCS = $(MESA_X86_SRCS) $(MESA_MMX_SRCS) $(MESA_3DNOW_SRCS) \
+ $(MESA_SSE_SRCS)
+
+MESA_ASM_OBJS = $(MESA_X86_OBJS) $(MESA_MMX_OBJS) $(MESA_3DNOW_OBJS) \
+ $(MESA_SSE_OBJS)
+
+MESA_ASM_UOBJS = $(MESA_X86_UOBJS) $(MESA_MMX_UOBJS) $(MESA_3DNOW_UOBJS) \
+ $(MESA_SSE_UOBJS)
+
+MESA_ASM_DOBJS = $(MESA_X86_DOBJS) $(MESA_MMX_DOBJS) $(MESA_3DNOW_DOBJS) \
+ $(MESA_SSE_DOBJS)
+
+MESA_ASM_POBJS = $(MESA_X86_POBJS) $(MESA_MMX_POBJS) $(MESA_3DNOW_POBJS) \
+ $(MESA_SSE_POBJS)
+
+MESA_ASM_DEFINES = $(MESA_X86_DEFS) $(MESA_MMX_DEFS) $(MESA_3DNOW_DEFS) $(MESA_SSE_DEFS)
+
diff --git a/nx-X11/lib/GLU/GLU-def.cpp b/nx-X11/lib/GLU/GLU-def.cpp
new file mode 100644
index 000000000..75997430d
--- /dev/null
+++ b/nx-X11/lib/GLU/GLU-def.cpp
@@ -0,0 +1,166 @@
+LIBRARY GLU
+VERSION LIBRARY_VERSION
+EXPORTS
+
+bezierPatchDelete
+bezierPatchDeleteList
+bezierPatchDraw
+bezierPatchEval
+bezierPatchEvalNormal
+bezierPatchInsert
+bezierPatchListDraw
+bezierPatchMake
+bezierPatchMake2
+bezierPatchPrint
+bezierPatchPrintList
+bezierPatchMeshBeginStrip
+bezierPatchMeshDelDeg
+bezierPatchMeshDelete
+bezierPatchMeshDraw
+bezierPatchMeshEndStrip
+bezierPatchMeshEval
+bezierPatchMeshInsertUV
+bezierPatchMeshListCollect
+bezierPatchMeshListDelDeg
+bezierPatchMeshListDelete
+bezierPatchMeshListDraw
+bezierPatchMeshListEval
+bezierPatchMeshListInsert
+bezierPatchMeshListNumTriangles
+bezierPatchMeshListPrint
+bezierPatchMeshListReverse
+bezierPatchMeshListTotalStrips
+bezierPatchMeshListTotalVert
+bezierPatchMeshMake
+bezierPatchMeshMake2
+bezierPatchMeshNumTriangles
+bezierPatchMeshPrint
+bezierPatchMeshPutPatch
+drawStrips
+gluBeginCurve
+gluBeginSurface
+gluBeginTrim
+gluDeleteNurbsRenderer
+gluDeleteNurbsTessellatorEXT
+gluEndCurve
+gluEndSurface
+gluEndTrim
+gluGetNurbsProperty
+gluLoadSamplingMatrices
+gluNewNurbsRenderer
+gluNurbsCallback
+gluNurbsCallbackData
+gluNurbsCallbackDataEXT
+gluNurbsCurve
+gluNurbsProperty
+gluNurbsSurface
+gluPwlCurve
+glu_LOD_eval_list
+__gl_dictListDelete
+__gl_dictListDeleteDict
+__gl_dictListInsertBefore
+__gl_dictListNewDict
+__gl_dictListSearch
+__gl_edgeEval
+__gl_edgeIntersect
+__gl_edgeSign
+__gl_transEval
+__gl_transSign
+__gl_vertCCW
+__gl_vertLeq
+__gl_memInit
+__gl_meshAddEdgeVertex
+; __gl_meshCheckMesh
+__gl_meshConnect
+__gl_meshDelete
+__gl_meshDeleteMesh
+__gl_meshMakeEdge
+__gl_meshNewMesh
+__gl_meshSplice
+__gl_meshSplitEdge
+__gl_meshUnion
+__gl_meshZapFace
+__gl_projectPolygon
+__gl_pqHeapDelete
+__gl_pqHeapDeletePriorityQ
+__gl_pqHeapExtractMin
+__gl_pqHeapInit
+__gl_pqHeapInsert
+__gl_pqHeapNewPriorityQ
+__gl_pqSortDelete
+__gl_pqSortDeletePriorityQ
+__gl_pqSortExtractMin
+__gl_pqSortInit
+__gl_pqSortInsert
+__gl_pqSortIsEmpty
+__gl_pqSortMinimum
+__gl_pqSortNewPriorityQ
+__gl_renderBoundary
+__gl_renderCache
+__gl_renderMesh
+__gl_computeInterior
+__gl_noBeginData
+__gl_noCombineData
+__gl_noEdgeFlagData
+__gl_noEndData
+__gl_noErrorData
+__gl_noVertexData
+gluBeginPolygon
+; gluDeleteMesh
+gluDeleteTess
+gluEndPolygon
+gluGetTessProperty
+gluNewTess
+gluNextContour
+gluTessBeginContour
+gluTessBeginPolygon
+gluTessCallback
+gluTessEndContour
+gluTessEndPolygon
+gluTessNormal
+gluTessProperty
+gluTessVertex
+__gl_meshDiscardExterior
+__gl_meshSetWindingNumber
+__gl_meshTessellateInterior
+__gl_meshTessellateMonoRegion
+gluErrorString
+; __glNURBSErrorString
+; __glTessErrorString
+; bitmapBuild2DMipmaps
+; fastBuild2DMipmaps
+gluBuild1DMipmapLevels
+gluBuild1DMipmaps
+gluBuild2DMipmapLevels
+gluBuild2DMipmaps
+gluBuild3DMipmapLevels
+gluBuild3DMipmaps
+gluScaleImage
+gluScaleImage3D
+; __gluInvertMatrixd
+; __gluMakeIdentityd
+; __gluMakeIdentityf
+; __gluMultMatricesd
+; __gluMultMatrixVecd
+gluLookAt
+gluOrtho2D
+gluPerspective
+gluPickMatrix
+gluProject
+gluUnProject
+gluUnProject4
+gluCylinder
+gluDeleteQuadric
+gluDisk
+gluNewQuadric
+gluPartialDisk
+gluQuadricCallback
+gluQuadricDrawStyle
+gluQuadricNormals
+gluQuadricOrientation
+gluQuadricTexture
+gluSphere
+gluCheckExtension
+gluGetString
+
+/* $XFree86$ */
diff --git a/nx-X11/lib/GLU/Imakefile b/nx-X11/lib/GLU/Imakefile
new file mode 100644
index 000000000..5e6ae3139
--- /dev/null
+++ b/nx-X11/lib/GLU/Imakefile
@@ -0,0 +1,133 @@
+XCOMM $XFree86: xc/lib/GLU/Imakefile,v 1.5 2001/06/05 23:03:20 dawes Exp $
+
+XCOMM License Applicability. Except to the extent portions of this file are
+XCOMM made subject to an alternative license as permitted in the SGI Free
+XCOMM Software License B, Version 1.1 (the "License"), the contents of this
+XCOMM file are subject only to the provisions of the License. You may not use
+XCOMM this file except in compliance with the License. You may obtain a copy
+XCOMM of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+XCOMM Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+XCOMM
+XCOMM http://oss.sgi.com/projects/FreeB
+XCOMM
+XCOMM Note that, as provided in the License, the Software is distributed on an
+XCOMM "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+XCOMM DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+XCOMM CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+XCOMM PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+XCOMM
+XCOMM Original Code. The Original Code is: OpenGL Sample Implementation,
+XCOMM Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+XCOMM Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+XCOMM Copyright in any portions created by third parties is as indicated
+XCOMM elsewhere herein. All Rights Reserved.
+XCOMM
+XCOMM Additional Notice Provisions: The application programming interfaces
+XCOMM established by SGI in conjunction with the Original Code are The
+XCOMM OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+XCOMM April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+XCOMM 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+XCOMM Window System(R) (Version 1.3), released October 19, 1998. This software
+XCOMM was created using the OpenGL(R) version 1.2.1 Sample Implementation
+XCOMM published by SGI, but has not been independently verified as being
+XCOMM compliant with the OpenGL(R) version 1.2.1 Specification.
+XCOMM
+
+#define IHaveSubdirs
+
+#define DoNormalLib NormalLibGlu
+#define DoSharedLib SharedLibGlu
+#define DoDebugLib DebugLibGlu
+#define DoProfileLib ProfileLibGlu
+#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
+
+LIBNAME = GLU
+SOREV = $(SOGLUREV)
+
+#define CplusplusSource
+
+#ifdef SharedGLUReqs
+REQUIREDLIBS = SharedGLUReqs
+#endif
+
+#ifndef SeparateSharedCompile
+#define SeparateSharedCompile YES
+#endif
+#if NormalLibGlu && SharedLibGlu && SeparateSharedCompile
+STATIC_OBJSDIR = unshared/
+#endif
+
+SUBDIRS = \
+ include \
+ libutil \
+ libtess \
+ libnurbs/internals \
+ libnurbs/interface \
+ libnurbs/nurbtess
+
+ SHARED_OBJS = libutil/?*.o libtess/?*.o \
+ libnurbs/internals/?*.o \
+ libnurbs/interface/?*.o \
+ libnurbs/nurbtess/?*.o
+
+ STATIC_OBJS = libutil/$(STATIC_OBJSDIR)?*.o libtess/$(STATIC_OBJSDIR)?*.o \
+ libnurbs/internals/$(STATIC_OBJSDIR)?*.o \
+ libnurbs/interface/$(STATIC_OBJSDIR)?*.o \
+ libnurbs/nurbtess/$(STATIC_OBJSDIR)?*.o
+
+ DEBUG_OBJS = libutil/debugger/?*.o libtess/debugger/?*.o \
+ libnurbs/internals/debugger/?*.o \
+ libnurbs/interface/debugger/?*.o \
+ libnurbs/nurbtess/debugger/?*.o
+
+ PROFILE_OBJS = libutil/profiled/?*.o libtess/profiled/?*.o \
+ libnurbs/internals/profiled/?*.o \
+ libnurbs/interface/profiled/?*.o \
+ libnurbs/nurbtess/profiled/?*.o
+
+ DONES = libutil/DONE libtess/DONE \
+ libnurbs/internals/DONE \
+ libnurbs/interface/DONE \
+ libnurbs/nurbtess/DONE
+
+#if HasParallelMake
+MakeMutex($(SUBDIRS) $(DONES))
+#endif
+
+#if HasGnuMake || HasBsdMake
+$(DONES): $(SUBDIRS)
+#endif
+
+#include <Library.tmpl>
+
+#undef _LinkBuildLibrary
+#define _LinkBuildLibrary(lib) LinkBuildLibrary(lib)
+
+#if NormalLibGlu
+NormalDepLibraryTarget($(LIBNAME),$(SUBDIRS) $(DONES),$(STATIC_OBJS))
+InstallLibrary($(LIBNAME),$(USRLIBDIR))
+#endif
+
+#if SharedLibGlu
+#ifdef SharedDepCplusplusLibraryTarget
+SharedDepCplusplusLibraryTarget($(LIBNAME),$(SOREV),$(SUBDIRS) $(DONES),$(SHARED_OBJS),.,.)
+#else
+SharedDepLibraryTarget($(LIBNAME),$(SOREV),$(SUBDIRS) $(DONES),$(SHARED_OBJS),.,.)
+#endif
+InstallSharedLibrary($(LIBNAME),$(SOREV),$(SHLIBDIR))
+#endif
+
+#if DebugLibGlu
+DebuggedDepLibraryTarget($(LIBNAME),$(SUBDIRS) $(DONES),$(DEBUG_OBJS))
+InstallLibrary($(LIBNAME)_d,$(USRLIBDIR))
+#endif /* DebugLibGlu */
+
+#if ProfileLibGlu
+ProfiledDepLibraryTarget($(LIBNAME),$(SUBDIRS) $(DONES),$(PROFILE_OBJS))
+InstallLibrary($(LIBNAME)_p,$(USRLIBDIR))
+#endif /* ProfileLibGlu */
+
+
+ForceSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
diff --git a/nx-X11/lib/GLU/include/Imakefile b/nx-X11/lib/GLU/include/Imakefile
new file mode 100644
index 000000000..68f1b1b06
--- /dev/null
+++ b/nx-X11/lib/GLU/include/Imakefile
@@ -0,0 +1,38 @@
+XCOMM $XFree86$
+
+XCOMM License Applicability. Except to the extent portions of this file are
+XCOMM made subject to an alternative license as permitted in the SGI Free
+XCOMM Software License B, Version 1.1 (the "License"), the contents of this
+XCOMM file are subject only to the provisions of the License. You may not use
+XCOMM this file except in compliance with the License. You may obtain a copy
+XCOMM of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+XCOMM Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+XCOMM
+XCOMM http://oss.sgi.com/projects/FreeB
+XCOMM
+XCOMM Note that, as provided in the License, the Software is distributed on an
+XCOMM "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+XCOMM DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+XCOMM CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+XCOMM PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+XCOMM
+XCOMM Original Code. The Original Code is: OpenGL Sample Implementation,
+XCOMM Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+XCOMM Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+XCOMM Copyright in any portions created by third parties is as indicated
+XCOMM elsewhere herein. All Rights Reserved.
+XCOMM
+XCOMM Additional Notice Provisions: The application programming interfaces
+XCOMM established by SGI in conjunction with the Original Code are The
+XCOMM OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+XCOMM April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+XCOMM 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+XCOMM Window System(R) (Version 1.3), released October 19, 1998. This software
+XCOMM was created using the OpenGL(R) version 1.2.1 Sample Implementation
+XCOMM published by SGI, but has not been independently verified as being
+XCOMM compliant with the OpenGL(R) version 1.2.1 Specification.
+XCOMM
+
+GLUSRCDIR = $(OGLSAMPLESRCDIR)/main/gfx/lib/glu
+
+LinkSourceFile(gluos.h, $(GLUSRCDIR)/include)
diff --git a/nx-X11/lib/GLU/libnurbs/interface/Imakefile b/nx-X11/lib/GLU/libnurbs/interface/Imakefile
new file mode 100644
index 000000000..a56489f68
--- /dev/null
+++ b/nx-X11/lib/GLU/libnurbs/interface/Imakefile
@@ -0,0 +1,107 @@
+XCOMM $XFree86: xc/lib/GLU/libnurbs/interface/Imakefile,v 1.2 2001/01/15 22:25:09 dawes Exp $
+
+XCOMM License Applicability. Except to the extent portions of this file are
+XCOMM made subject to an alternative license as permitted in the SGI Free
+XCOMM Software License B, Version 1.1 (the "License"), the contents of this
+XCOMM file are subject only to the provisions of the License. You may not use
+XCOMM this file except in compliance with the License. You may obtain a copy
+XCOMM of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+XCOMM Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+XCOMM
+XCOMM http://oss.sgi.com/projects/FreeB
+XCOMM
+XCOMM Note that, as provided in the License, the Software is distributed on an
+XCOMM "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+XCOMM DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+XCOMM CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+XCOMM PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+XCOMM
+XCOMM Original Code. The Original Code is: OpenGL Sample Implementation,
+XCOMM Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+XCOMM Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+XCOMM Copyright in any portions created by third parties is as indicated
+XCOMM elsewhere herein. All Rights Reserved.
+XCOMM
+XCOMM Additional Notice Provisions: The application programming interfaces
+XCOMM established by SGI in conjunction with the Original Code are The
+XCOMM OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+XCOMM April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+XCOMM 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+XCOMM Window System(R) (Version 1.3), released October 19, 1998. This software
+XCOMM was created using the OpenGL(R) version 1.2.1 Sample Implementation
+XCOMM published by SGI, but has not been independently verified as being
+XCOMM compliant with the OpenGL(R) version 1.2.1 Specification.
+XCOMM
+
+#define DoNormalLib NormalLibGlu
+#define DoSharedLib SharedLibGlu
+#define DoDebugLib DebugLibGlu
+#define DoProfileLib ProfileLibGlu
+
+#define CplusplusSource
+
+#include <Library.tmpl>
+
+SRCS = \
+ bezierEval.cc \
+ bezierPatch.cc \
+ bezierPatchMesh.cc \
+ glcurveval.cc \
+ glinterface.cc \
+ glrenderer.cc \
+ glsurfeval.cc \
+ incurveeval.cc \
+ insurfeval.cc
+
+OBJS = \
+ bezierEval.o \
+ bezierPatch.o \
+ bezierPatchMesh.o \
+ glcurveval.o \
+ glinterface.o \
+ glrenderer.o \
+ glsurfeval.o \
+ incurveeval.o \
+ insurfeval.o
+
+INCLUDES = \
+ -I. \
+ -I../internals \
+ -I../nurbtess \
+ -I../../include \
+ -I$(TOP)/include \
+ -I$(TOP)/include/GL
+
+DEFINES = \
+ -DLIBRARYBUILD \
+ -DNDEBUG
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+GLUSRCDIR = $(OGLSAMPLESRCDIR)/main/gfx/lib/glu
+
+LinkSourceFile(bezierEval.cc, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(bezierPatch.cc, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(bezierPatchMesh.cc, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(glcurveval.cc, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(glinterface.cc, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(glrenderer.cc, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(glsurfeval.cc, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(incurveeval.cc, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(insurfeval.cc, $(GLUSRCDIR)/libnurbs/interface)
+
+LinkSourceFile(bezierEval.h, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(bezierPatch.h, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(bezierPatchMesh.h, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(glcurveval.h, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(glimports.h, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(glrenderer.h, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(glsurfeval.h, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(mystdio.h, $(GLUSRCDIR)/libnurbs/interface)
+LinkSourceFile(mystdlib.h, $(GLUSRCDIR)/libnurbs/interface)
+
+DependTarget()
+CleanTarget()
diff --git a/nx-X11/lib/GLU/libnurbs/internals/Imakefile b/nx-X11/lib/GLU/libnurbs/internals/Imakefile
new file mode 100644
index 000000000..5706b03f7
--- /dev/null
+++ b/nx-X11/lib/GLU/libnurbs/internals/Imakefile
@@ -0,0 +1,269 @@
+XCOMM $XFree86: xc/lib/GLU/libnurbs/internals/Imakefile,v 1.11tsi Exp $
+
+XCOMM License Applicability. Except to the extent portions of this file are
+XCOMM made subject to an alternative license as permitted in the SGI Free
+XCOMM Software License B, Version 1.1 (the "License"), the contents of this
+XCOMM file are subject only to the provisions of the License. You may not use
+XCOMM this file except in compliance with the License. You may obtain a copy
+XCOMM of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+XCOMM Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+XCOMM
+XCOMM http://oss.sgi.com/projects/FreeB
+XCOMM
+XCOMM Note that, as provided in the License, the Software is distributed on an
+XCOMM "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+XCOMM DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+XCOMM CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+XCOMM PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+XCOMM
+XCOMM Original Code. The Original Code is: OpenGL Sample Implementation,
+XCOMM Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+XCOMM Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+XCOMM Copyright in any portions created by third parties is as indicated
+XCOMM elsewhere herein. All Rights Reserved.
+XCOMM
+XCOMM Additional Notice Provisions: The application programming interfaces
+XCOMM established by SGI in conjunction with the Original Code are The
+XCOMM OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+XCOMM April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+XCOMM 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+XCOMM Window System(R) (Version 1.3), released October 19, 1998. This software
+XCOMM was created using the OpenGL(R) version 1.2.1 Sample Implementation
+XCOMM published by SGI, but has not been independently verified as being
+XCOMM compliant with the OpenGL(R) version 1.2.1 Specification.
+XCOMM
+
+#define DoNormalLib NormalLibGlu
+#define DoSharedLib SharedLibGlu
+#define DoDebugLib DebugLibGlu
+#define DoProfileLib ProfileLibGlu
+
+#define CplusplusSource
+
+#include <Library.tmpl>
+
+SRCS = \
+ arc.cc \
+ arcsorter.cc \
+ arctess.cc \
+ backend.cc \
+ basiccrveval.cc \
+ basicsurfeval.cc \
+ bin.cc \
+ bufpool.cc \
+ cachingeval.cc \
+ ccw.cc \
+ coveandtiler.cc \
+ curve.cc \
+ curvelist.cc \
+ curvesub.cc \
+ dataTransform.cc \
+ displaylist.cc \
+ flist.cc \
+ flistsorter.cc \
+ hull.cc \
+ intersect.cc \
+ knotvector.cc \
+ mapdesc.cc \
+ mapdescv.cc \
+ maplist.cc \
+ mesher.cc \
+ monoTriangulationBackend.cc \
+ monotonizer.cc \
+ mycode.cc \
+ nurbsinterfac.cc \
+ nurbstess.cc \
+ patch.cc \
+ patchlist.cc \
+ quilt.cc \
+ reader.cc \
+ renderhints.cc \
+ slicer.cc \
+ sorter.cc \
+ splitarcs.cc \
+ subdivider.cc \
+ tobezier.cc \
+ trimline.cc \
+ trimregion.cc \
+ trimvertpool.cc \
+ uarray.cc \
+ varray.cc
+
+OBJS = \
+ arc.o \
+ arcsorter.o \
+ arctess.o \
+ backend.o \
+ basiccrveval.o \
+ basicsurfeval.o \
+ bin.o \
+ bufpool.o \
+ cachingeval.o \
+ ccw.o \
+ coveandtiler.o \
+ curve.o \
+ curvelist.o \
+ curvesub.o \
+ dataTransform.o \
+ displaylist.o \
+ flist.o \
+ flistsorter.o \
+ hull.o \
+ intersect.o \
+ knotvector.o \
+ mapdesc.o \
+ mapdescv.o \
+ maplist.o \
+ mesher.o \
+ monoTriangulationBackend.o \
+ monotonizer.o \
+ mycode.o \
+ nurbsinterfac.o \
+ nurbstess.o \
+ patch.o \
+ patchlist.o \
+ quilt.o \
+ reader.o \
+ renderhints.o \
+ slicer.o \
+ sorter.o \
+ splitarcs.o \
+ subdivider.o \
+ tobezier.o \
+ trimline.o \
+ trimregion.o \
+ trimvertpool.o \
+ uarray.o \
+ varray.o
+
+INCLUDES = \
+ -I../nurbtess \
+ -I../../libutil \
+ -I../../include \
+ -I$(TOP)/include \
+ -I$(TOP)/include/GL
+
+#if defined(SGIArchitecture)
+OSDEFINES = -D_SCO_DS
+#elif SystemV4 || defined(LynxOSArchitecture) || defined(OS2Architecture)
+OSDEFINES = -DNEEDCEILF
+#elif defined(DarwinArchitecture)
+# if OSMajorVersion <= 5
+OSDEFINES = -DNEEDCEILF
+# endif
+#elif defined(LinuxArchitecture) && (LinuxCLibMajorVersion < 6)
+OSDEFINES = -DNEEDCEILF
+#else
+OSDEFINES = -D_EXTENSIONS_
+#endif
+
+DEFINES = $(OSDEFINES) -DLIBRARYBUILD -DNDEBUG
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+GLUSRCDIR = $(OGLSAMPLESRCDIR)/main/gfx/lib/glu
+
+LinkSourceFile(arc.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(arcsorter.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(arctess.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(backend.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(basiccrveval.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(basicsurfeval.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(bin.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(bufpool.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(cachingeval.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(ccw.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(coveandtiler.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(curve.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(curvelist.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(curvesub.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(dataTransform.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(displaylist.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(flist.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(flistsorter.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(hull.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(intersect.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(knotvector.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(mapdesc.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(mapdescv.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(maplist.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(mesher.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(monoTriangulationBackend.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(monotonizer.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(mycode.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(nurbsinterfac.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(nurbstess.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(patch.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(patchlist.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(quilt.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(reader.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(renderhints.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(slicer.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(sorter.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(splitarcs.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(subdivider.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(tobezier.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(trimline.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(trimregion.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(trimvertpool.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(uarray.cc, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(varray.cc, $(GLUSRCDIR)/libnurbs/internals)
+
+LinkSourceFile(arc.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(arcsorter.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(arctess.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(backend.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(basiccrveval.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(basicsurfeval.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(bezierarc.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(bin.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(bufpool.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(cachingeval.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(coveandtiler.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(curve.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(curvelist.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(dataTransform.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(defines.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(displaylist.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(displaymode.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(flist.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(flistsorter.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(gridline.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(gridtrimvertex.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(gridvertex.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(hull.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(jarcloc.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(knotvector.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(mapdesc.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(maplist.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(mesher.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(monotonizer.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(myassert.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(mymath.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(mysetjmp.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(mystring.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(nurbsconsts.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(nurbstess.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(patch.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(patchlist.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(pwlarc.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(quilt.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(reader.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(renderhints.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(simplemath.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(slicer.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(sorter.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(subdivider.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(trimline.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(trimregion.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(trimvertex.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(trimvertpool.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(types.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(uarray.h, $(GLUSRCDIR)/libnurbs/internals)
+LinkSourceFile(varray.h, $(GLUSRCDIR)/libnurbs/internals)
+
+DependTarget()
+CleanTarget()
diff --git a/nx-X11/lib/GLU/libnurbs/nurbtess/Imakefile b/nx-X11/lib/GLU/libnurbs/nurbtess/Imakefile
new file mode 100644
index 000000000..43b0266a1
--- /dev/null
+++ b/nx-X11/lib/GLU/libnurbs/nurbtess/Imakefile
@@ -0,0 +1,150 @@
+XCOMM $XFree86: xc/lib/GLU/libnurbs/nurbtess/Imakefile,v 1.2 2001/01/15 22:25:10 dawes Exp $
+
+XCOMM License Applicability. Except to the extent portions of this file are
+XCOMM made subject to an alternative license as permitted in the SGI Free
+XCOMM Software License B, Version 1.1 (the "License"), the contents of this
+XCOMM file are subject only to the provisions of the License. You may not use
+XCOMM this file except in compliance with the License. You may obtain a copy
+XCOMM of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+XCOMM Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+XCOMM
+XCOMM http://oss.sgi.com/projects/FreeB
+XCOMM
+XCOMM Note that, as provided in the License, the Software is distributed on an
+XCOMM "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+XCOMM DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+XCOMM CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+XCOMM PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+XCOMM
+XCOMM Original Code. The Original Code is: OpenGL Sample Implementation,
+XCOMM Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+XCOMM Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+XCOMM Copyright in any portions created by third parties is as indicated
+XCOMM elsewhere herein. All Rights Reserved.
+XCOMM
+XCOMM Additional Notice Provisions: The application programming interfaces
+XCOMM established by SGI in conjunction with the Original Code are The
+XCOMM OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+XCOMM April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+XCOMM 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+XCOMM Window System(R) (Version 1.3), released October 19, 1998. This software
+XCOMM was created using the OpenGL(R) version 1.2.1 Sample Implementation
+XCOMM published by SGI, but has not been independently verified as being
+XCOMM compliant with the OpenGL(R) version 1.2.1 Specification.
+XCOMM
+
+#define DoNormalLib NormalLibGlu
+#define DoSharedLib SharedLibGlu
+#define DoDebugLib DebugLibGlu
+#define DoProfileLib ProfileLibGlu
+
+#define CplusplusSource
+
+#include <Library.tmpl>
+
+SRCS = \
+ directedLine.cc \
+ gridWrap.cc \
+ monoChain.cc \
+ monoTriangulation.cc \
+ partitionX.cc \
+ partitionY.cc \
+ polyDBG.cc \
+ polyUtil.cc \
+ primitiveStream.cc \
+ quicksort.cc \
+ rectBlock.cc \
+ sampleComp.cc \
+ sampleCompBot.cc \
+ sampleCompRight.cc \
+ sampleCompTop.cc \
+ sampleMonoPoly.cc \
+ sampledLine.cc \
+ searchTree.cc \
+ monoPolyPart.cc
+
+OBJS = \
+ directedLine.o \
+ gridWrap.o \
+ monoChain.o \
+ monoTriangulation.o \
+ partitionX.o \
+ partitionY.o \
+ polyDBG.o \
+ polyUtil.o \
+ primitiveStream.o \
+ quicksort.o \
+ rectBlock.o \
+ sampleComp.o \
+ sampleCompBot.o \
+ sampleCompRight.o \
+ sampleCompTop.o \
+ sampleMonoPoly.o \
+ sampledLine.o \
+ searchTree.o \
+ monoPolyPart.o
+
+INCLUDES = \
+ -I../internals \
+ -I../../include \
+ -I$(TOP)/include \
+ -I$(TOP)/include/GL
+
+DEFINES = \
+ -DLIBRARYBUILD \
+ -DNDEBUG
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+GLUSRCDIR = $(OGLSAMPLESRCDIR)/main/gfx/lib/glu
+
+LinkSourceFile(directedLine.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(gridWrap.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(monoChain.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(monoTriangulation.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(partitionX.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(partitionY.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(polyDBG.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(polyUtil.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(primitiveStream.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(quicksort.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(rectBlock.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(sampleComp.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(sampleCompBot.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(sampleCompRight.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(sampleCompTop.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(sampleMonoPoly.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(sampledLine.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(searchTree.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(monoPolyPart.cc, $(GLUSRCDIR)/libnurbs/nurbtess)
+
+LinkSourceFile(definitions.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(directedLine.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(glimports.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(gridWrap.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(monoChain.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(monoPolyPart.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(monoTriangulation.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(mystdio.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(mystdlib.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(partitionX.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(partitionY.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(polyDBG.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(polyUtil.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(primitiveStream.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(quicksort.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(rectBlock.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(sampleComp.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(sampleCompBot.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(sampleCompRight.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(sampleCompTop.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(sampleMonoPoly.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(sampledLine.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(searchTree.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+LinkSourceFile(zlassert.h, $(GLUSRCDIR)/libnurbs/nurbtess)
+
+DependTarget()
+CleanTarget()
diff --git a/nx-X11/lib/GLU/libtess/Imakefile b/nx-X11/lib/GLU/libtess/Imakefile
new file mode 100644
index 000000000..4b50cb549
--- /dev/null
+++ b/nx-X11/lib/GLU/libtess/Imakefile
@@ -0,0 +1,109 @@
+XCOMM $XFree86: xc/lib/GLU/libtess/Imakefile,v 1.1 2001/01/15 22:18:06 dawes Exp $
+
+XCOMM License Applicability. Except to the extent portions of this file are
+XCOMM made subject to an alternative license as permitted in the SGI Free
+XCOMM Software License B, Version 1.1 (the "License"), the contents of this
+XCOMM file are subject only to the provisions of the License. You may not use
+XCOMM this file except in compliance with the License. You may obtain a copy
+XCOMM of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+XCOMM Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+XCOMM
+XCOMM http://oss.sgi.com/projects/FreeB
+XCOMM
+XCOMM Note that, as provided in the License, the Software is distributed on an
+XCOMM "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+XCOMM DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+XCOMM CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+XCOMM PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+XCOMM
+XCOMM Original Code. The Original Code is: OpenGL Sample Implementation,
+XCOMM Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+XCOMM Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+XCOMM Copyright in any portions created by third parties is as indicated
+XCOMM elsewhere herein. All Rights Reserved.
+XCOMM
+XCOMM Additional Notice Provisions: The application programming interfaces
+XCOMM established by SGI in conjunction with the Original Code are The
+XCOMM OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+XCOMM April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+XCOMM 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+XCOMM Window System(R) (Version 1.3), released October 19, 1998. This software
+XCOMM was created using the OpenGL(R) version 1.2.1 Sample Implementation
+XCOMM published by SGI, but has not been independently verified as being
+XCOMM compliant with the OpenGL(R) version 1.2.1 Specification.
+XCOMM
+
+#define DoNormalLib NormalLibGlu
+#define DoSharedLib SharedLibGlu
+#define DoDebugLib DebugLibGlu
+#define DoProfileLib ProfileLibGlu
+
+#include <Library.tmpl>
+
+SRCS = \
+ dict.c \
+ geom.c \
+ memalloc.c \
+ mesh.c \
+ normal.c \
+ priorityq.c \
+ render.c \
+ sweep.c \
+ tess.c \
+ tessmono.c
+
+OBJS = \
+ dict.o \
+ geom.o \
+ memalloc.o \
+ mesh.o \
+ normal.o \
+ priorityq.o \
+ render.o \
+ sweep.o \
+ tess.o \
+ tessmono.o
+
+INCLUDES = \
+ -I../include \
+ -I$(TOP)/include \
+ -I$(TOP)/include/GL
+
+DEFINES = \
+ -DNDEBUG
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+GLUSRCDIR = $(OGLSAMPLESRCDIR)/main/gfx/lib/glu
+
+LinkSourceFile(dict.c, $(GLUSRCDIR)/libtess)
+LinkSourceFile(geom.c, $(GLUSRCDIR)/libtess)
+LinkSourceFile(memalloc.c, $(GLUSRCDIR)/libtess)
+LinkSourceFile(mesh.c, $(GLUSRCDIR)/libtess)
+LinkSourceFile(normal.c, $(GLUSRCDIR)/libtess)
+LinkSourceFile(priorityq-heap.c, $(GLUSRCDIR)/libtess)
+LinkSourceFile(priorityq.c, $(GLUSRCDIR)/libtess)
+LinkSourceFile(render.c, $(GLUSRCDIR)/libtess)
+LinkSourceFile(sweep.c, $(GLUSRCDIR)/libtess)
+LinkSourceFile(tess.c, $(GLUSRCDIR)/libtess)
+LinkSourceFile(tessmono.c, $(GLUSRCDIR)/libtess)
+
+LinkSourceFile(dict-list.h, $(GLUSRCDIR)/libtess)
+LinkSourceFile(dict.h, $(GLUSRCDIR)/libtess)
+LinkSourceFile(geom.h, $(GLUSRCDIR)/libtess)
+LinkSourceFile(memalloc.h, $(GLUSRCDIR)/libtess)
+LinkSourceFile(mesh.h, $(GLUSRCDIR)/libtess)
+LinkSourceFile(normal.h, $(GLUSRCDIR)/libtess)
+LinkSourceFile(priorityq-heap.h, $(GLUSRCDIR)/libtess)
+LinkSourceFile(priorityq-sort.h, $(GLUSRCDIR)/libtess)
+LinkSourceFile(priorityq.h, $(GLUSRCDIR)/libtess)
+LinkSourceFile(render.h, $(GLUSRCDIR)/libtess)
+LinkSourceFile(sweep.h, $(GLUSRCDIR)/libtess)
+LinkSourceFile(tess.h, $(GLUSRCDIR)/libtess)
+LinkSourceFile(tessmono.h, $(GLUSRCDIR)/libtess)
+
+DependTarget()
+CleanTarget()
diff --git a/nx-X11/lib/GLU/libutil/Imakefile b/nx-X11/lib/GLU/libutil/Imakefile
new file mode 100644
index 000000000..393fa96ff
--- /dev/null
+++ b/nx-X11/lib/GLU/libutil/Imakefile
@@ -0,0 +1,84 @@
+XCOMM $XFree86: xc/lib/GLU/libutil/Imakefile,v 1.1 2001/01/15 22:18:08 dawes Exp $
+
+XCOMM License Applicability. Except to the extent portions of this file are
+XCOMM made subject to an alternative license as permitted in the SGI Free
+XCOMM Software License B, Version 1.1 (the "License"), the contents of this
+XCOMM file are subject only to the provisions of the License. You may not use
+XCOMM this file except in compliance with the License. You may obtain a copy
+XCOMM of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+XCOMM Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+XCOMM
+XCOMM http://oss.sgi.com/projects/FreeB
+XCOMM
+XCOMM Note that, as provided in the License, the Software is distributed on an
+XCOMM "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+XCOMM DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+XCOMM CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+XCOMM PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+XCOMM
+XCOMM Original Code. The Original Code is: OpenGL Sample Implementation,
+XCOMM Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+XCOMM Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+XCOMM Copyright in any portions created by third parties is as indicated
+XCOMM elsewhere herein. All Rights Reserved.
+XCOMM
+XCOMM Additional Notice Provisions: The application programming interfaces
+XCOMM established by SGI in conjunction with the Original Code are The
+XCOMM OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+XCOMM April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+XCOMM 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+XCOMM Window System(R) (Version 1.3), released October 19, 1998. This software
+XCOMM was created using the OpenGL(R) version 1.2.1 Sample Implementation
+XCOMM published by SGI, but has not been independently verified as being
+XCOMM compliant with the OpenGL(R) version 1.2.1 Specification.
+XCOMM
+
+#define DoNormalLib NormalLibGlu
+#define DoSharedLib SharedLibGlu
+#define DoDebugLib DebugLibGlu
+#define DoProfileLib ProfileLibGlu
+
+#include <Library.tmpl>
+
+SRCS = \
+ error.c \
+ glue.c \
+ mipmap.c \
+ project.c \
+ quad.c \
+ registry.c
+
+OBJS = \
+ error.o \
+ glue.o \
+ mipmap.o \
+ project.o \
+ quad.o \
+ registry.o
+
+INCLUDES = \
+ -I../include \
+ -I$(TOP)/include \
+ -I$(TOP)/include/GL
+
+DEFINES = \
+ -DNDEBUG
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+GLUSRCDIR = $(OGLSAMPLESRCDIR)/main/gfx/lib/glu
+
+LinkSourceFile(error.c, $(GLUSRCDIR)/libutil)
+LinkSourceFile(glue.c, $(GLUSRCDIR)/libutil)
+LinkSourceFile(mipmap.c, $(GLUSRCDIR)/libutil)
+LinkSourceFile(project.c, $(GLUSRCDIR)/libutil)
+LinkSourceFile(quad.c, $(GLUSRCDIR)/libutil)
+LinkSourceFile(registry.c, $(GLUSRCDIR)/libutil)
+
+LinkSourceFile(gluint.h, $(GLUSRCDIR)/libutil)
+
+DependTarget()
+CleanTarget()
diff --git a/nx-X11/lib/GLw/GLwM1DrawA.c b/nx-X11/lib/GLw/GLwM1DrawA.c
new file mode 100644
index 000000000..4301c817f
--- /dev/null
+++ b/nx-X11/lib/GLw/GLwM1DrawA.c
@@ -0,0 +1,55 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+/* $XFree86$ */
+
+#define __GLX_MOTIF 1
+
+#define XmVERSION 1
+#define XmREVISION 2
+#define XmVersion (XmVERSION * 1000 + XmREVISION)
+#define XmVERSION_STRING "GLwDrawingArea fake M*tif 1.X"
+#define XmUPDATE_LEVEL 0
+
+/* Include our fake Motif headers */
+#include "GLwXm/Xm.h"
+#include "GLwXm/PrimitiveP.h"
+
+#define __GLX_INCLUDE_XM_H
+#define __GLX_INCLUDE_PRIMITIVE_P_H
+
+#include "GLwDrawA.c"
diff --git a/nx-X11/lib/GLw/GLwM2DrawA.c b/nx-X11/lib/GLw/GLwM2DrawA.c
new file mode 100644
index 000000000..bd93260f9
--- /dev/null
+++ b/nx-X11/lib/GLw/GLwM2DrawA.c
@@ -0,0 +1,55 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+/* $XFree86$ */
+
+#define __GLX_MOTIF 2
+
+#define XmVERSION 2
+#define XmREVISION 0
+#define XmVersion (XmVERSION * 1000 + XmREVISION)
+#define XmVERSION_STRING "GLwDrawingArea fake M*tif 2.X"
+#define XmUPDATE_LEVEL 0
+
+/* Include our fake Motif headers */
+#include "GLwXm/Xm.h"
+#include "GLwXm/PrimitiveP.h"
+
+#define __GLX_INCLUDE_XM_H
+#define __GLX_INCLUDE_PRIMITIVE_P_H
+
+#include "GLwDrawA.c"
diff --git a/nx-X11/lib/GLw/GLwXm/PrimitiveP.h b/nx-X11/lib/GLw/GLwXm/PrimitiveP.h
new file mode 100644
index 000000000..d38d0d165
--- /dev/null
+++ b/nx-X11/lib/GLw/GLwXm/PrimitiveP.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+/* $XFree86$ */
+
+/*
+ * This file is a fake Motif(TM) header intended to allow the compilation of
+ * libGLw without having a real Motif. Do not use this file to compile any
+ * application because it declares only a small subset of the API!
+ */
+
+#ifndef GLWXM_PRIMITIVE_P_H
+#define GLWXM_PRIMITIVE_P_H
+
+#include "GLwXm/XmP.h"
+
+/* primitive instance part */
+typedef struct {
+ Pixel foreground;
+ Dimension shadow_thickness;
+ Pixel top_shadow_color;
+ Pixmap top_shadow_pixmap;
+ Pixel bottom_shadow_color;
+ Pixmap bottom_shadow_pixmap;
+ Dimension highlight_thickness;
+ Pixel highlight_color;
+ Pixmap highlight_pixmap;
+ XtCallbackList help_callback;
+ XtPointer user_data;
+ Boolean traversal_on;
+ Boolean highlight_on_enter;
+ Boolean have_traversal;
+ unsigned char unit_type;
+ XmNavigationType navigation_type;
+ Boolean highlight_drawn;
+ Boolean highlighted;
+ GC highlight_GC;
+ GC top_shadow_GC;
+ GC bottom_shadow_GC;
+#if XmVERSION > 1
+ XtCallbackList convert_callback;
+ XtCallbackList popup_handler_callback;
+ XmDirection layout_direction;
+#endif
+} XmPrimitivePart;
+
+/* primitive class part */
+typedef struct {
+ XtWidgetProc border_highlight;
+ XtWidgetProc border_unhighlight;
+ String translations;
+ XtActionProc arm_and_activate;
+ XmSyntheticResource *syn_resources;
+ int num_syn_resources;
+ XtPointer extension;
+} XmPrimitiveClassPart;
+
+/* class record */
+typedef struct _XmPrimitiveClassRec {
+ CoreClassPart core_class;
+ XmPrimitiveClassPart primitive_class;
+} XmPrimitiveClassRec;
+
+/* declare class record */
+extern XmPrimitiveClassRec xmPrimitiveClassRec;
+
+#endif /* GLWXM_PRIMITIVE_P_H */
diff --git a/nx-X11/lib/GLw/GLwXm/Xm.h b/nx-X11/lib/GLw/GLwXm/Xm.h
new file mode 100644
index 000000000..f344eec50
--- /dev/null
+++ b/nx-X11/lib/GLw/GLwXm/Xm.h
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+/* $XFree86$ */
+
+/*
+ * This file is a fake Motif(TM) header intended to allow the compilation of
+ * libGLw without having a real Motif. Do not use this file to compile any
+ * application because it declares only a small subset of the API!
+ */
+
+#ifndef GLWXM_H
+#define GLWXM_H
+
+#include <X11/Intrinsic.h>
+#include <X11/Shell.h>
+#include <X11/Xatom.h>
+#include "GLwXm/XmStrDefs.h"
+
+enum {
+ XmATTACH_NONE,
+ XmATTACH_FORM,
+ XmATTACH_OPPOSITE_FORM,
+ XmATTACH_WIDGET,
+ XmATTACH_OPPOSITE_WIDGET,
+ XmATTACH_POSITION,
+ XmATTACH_SELF
+};
+
+enum {
+ XmCR_NONE,
+ XmCR_HELP,
+ XmCR_VALUE_CHANGED,
+ XmCR_INCREMENT,
+ XmCR_DECREMENT,
+ XmCR_PAGE_INCREMENT,
+ XmCR_PAGE_DECREMENT,
+ XmCR_TO_TOP,
+ XmCR_TO_BOTTOM,
+ XmCR_DRAG,
+ XmCR_ACTIVATE,
+ XmCR_ARM,
+ XmCR_DISARM,
+ XmCR_DUMMY13,
+ XmCR_DUMMY14,
+ XmCR_DUMMY15,
+ XmCR_MAP,
+ XmCR_UNMAP,
+ XmCR_FOCUS,
+ XmCR_LOSING_FOCUS,
+ XmCR_MODIFYING_TEXT_VALUE,
+ XmCR_MOVING_INSERT_CURSOR,
+ XmCR_EXECUTE,
+ XmCR_SINGLE_SELECT,
+ XmCR_MULTIPLE_SELECT,
+ XmCR_EXTENDED_SELECT,
+ XmCR_BROWSE_SELECT,
+ XmCR_DEFAULT_ACTION,
+ XmCR_CLIPBOARD_DATA_REQUEST,
+ XmCR_CLIPBOARD_DATA_DELETE,
+ XmCR_CASCADING,
+ XmCR_OK,
+ XmCR_CANCEL,
+ XmCR_DUMMY33,
+ XmCR_APPLY,
+ XmCR_NO_MATCH,
+ XmCR_COMMAND_ENTERED,
+ XmCR_COMMAND_CHANGED,
+ XmCR_EXPOSE,
+ XmCR_RESIZE,
+ XmCR_INPUT,
+ XmCR_GAIN_PRIMARY,
+ XmCR_LOSE_PRIMARY,
+ XmCR_CREATE,
+ XmCR_TEAR_OFF_ACTIVATE,
+ XmCR_TEAR_OFF_DEACTIVATE,
+ XmCR_OBSCURED_TRAVERSAL,
+#if XmVERSION < 2
+ XmCR_PROTOCOLS
+#else
+ XmCR_FOCUS_MOVED,
+ XmCR_DUMMY48,
+ XmCR_DUMMY49,
+ XmCR_DUMMY50,
+ XmCR_DUMMY51,
+ XmCR_DUMMY52,
+ XmCR_DUMMY53,
+ XmCR_REPOST,
+ XmCR_COLLAPSED,
+ XmCR_EXPANDED,
+ XmCR_SELECT,
+ XmCR_DRAG_START,
+ XmCR_NO_FONT,
+ XmCR_NO_RENDITION,
+ XmCR_POST,
+ XmCR_SPIN_NEXT,
+ XmCR_SPIN_PRIOR,
+ XmCR_SPIN_FIRST,
+ XmCR_SPIN_LAST,
+ XmCR_PAGE_SCROLLER_INCREMENT,
+ XmCR_PAGE_SCROLLER_DECREMENT,
+ XmCR_MAJOR_TAB,
+ XmCR_MINOR_TAB,
+ XmCR_PROTOCOLS = 6666
+#endif
+};
+
+typedef unsigned char XmDirection;
+
+typedef struct {
+ int reason;
+ XEvent *event;
+ Window window;
+} XmDrawingAreaCallbackStruct;
+
+#define XmUNSPECIFIED_PIXMAP 2
+
+typedef unsigned char XmNavigationType;
+
+#endif /* GLWXM_H */
diff --git a/nx-X11/lib/GLw/GLwXm/XmP.h b/nx-X11/lib/GLw/GLwXm/XmP.h
new file mode 100644
index 000000000..d54cbc37f
--- /dev/null
+++ b/nx-X11/lib/GLw/GLwXm/XmP.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+/* $XFree86$ */
+
+/*
+ * This file is a fake Motif(TM) header intended to allow the compilation of
+ * libGLw without having a real Motif. Do not use this file to compile any
+ * application because it declares only a small subset of the API!
+ */
+
+#ifndef GLWXM_P_H
+#define GLWXM_P_H
+
+#include "GLwXm/Xm.h"
+#include <X11/IntrinsicP.h>
+
+#define XmInheritBorderHighlight ((XtWidgetProc) _XtInherit)
+#define XmInheritBorderUnhighlight ((XtWidgetProc) _XtInherit)
+
+void _XmBackgroundColorDefault(Widget widget, int offset, XrmValue *value);
+void _XmForegroundColorDefault(Widget widget, int offset, XrmValue *value);
+void _XmHighlightColorDefault(Widget widget, int offset, XrmValue *value);
+void _XmPrimitiveHighlightPixmapDefault(Widget widget, int offset,
+ XrmValue *value);
+
+typedef enum {
+ XmSYNTHETIC_NONE,
+ XmSYNTHETIC_LOAD
+} XmImportOperator;
+
+typedef void (*XmExportProc)(Widget, int, XtArgVal *);
+
+typedef XmImportOperator (*XmImportProc)(Widget, int, XtArgVal*);
+
+typedef struct _XmSyntheticResource {
+ String resource_name;
+ Cardinal resource_size;
+ Cardinal resource_offset;
+ XmExportProc export_proc;
+ XmImportProc import_proc;
+} XmSyntheticResource;
+
+#endif /* GLWXM_P_H */
diff --git a/nx-X11/lib/GLw/GLwXm/XmStrDefs.h b/nx-X11/lib/GLw/GLwXm/XmStrDefs.h
new file mode 100644
index 000000000..1e42c5ec4
--- /dev/null
+++ b/nx-X11/lib/GLw/GLwXm/XmStrDefs.h
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+/* $XFree86$ */
+
+/*
+ * This file is a fake Motif(TM) header intended to allow the compilation of
+ * libGLw without having a real Motif. Do not use this file to compile any
+ * application because it declares only a small subset of the API!
+ */
+
+#ifndef GLWXM_STRDEFS_H
+#define GLWXM_STRDEFS_H
+
+#ifndef _XmConst
+#define _XmConst /**/
+#endif
+
+#ifdef XMSTRINGDEFINES
+
+#define XmCBackgroundPixmap "BackgroundPixmap"
+#define XmRBackgroundPixmap "BackgroundPixmap"
+#define XmRBooleanDimension "BooleanDimension"
+#define XmNbottomAttachment "bottomAttachment"
+#define XmNbottomWidget "bottomWidget"
+#define XmCForegroundThreshold "ForegroundThreshold"
+#define XmNforegroundThreshold "foregroundThreshold"
+#define XmCHighlightColor "HighlightColor"
+#define XmNhighlightColor "highlightColor"
+#define XmCHighlightOnEnter "HighlightOnEnter"
+#define XmNhighlightOnEnter "highlightOnEnter"
+#define XmCHighlightThickness "HighlightThickness"
+#define XmNhighlightThickness "highlightThickness"
+#define XmCHighlightPixmap "HighlightPixmap"
+#define XmNhighlightPixmap "highlightPixmap"
+#define XmRHighlightPixmap "HighlightPixmap"
+#define XmRHorizontalDimension "HorizontalDimension"
+#define XmNleftAttachment "leftAttachment"
+#define XmNrightAttachment "rightAttachment"
+#define XmRStringDirection "StringDirection"
+#define XmNtopAttachment "topAttachment"
+#define XmCTraversalOn "TraversalOn"
+#define XmNtraversalOn "traversalOn"
+#define XmRXmBackgroundPixmap "XmBackgroundPixmap"
+
+#else /* XMSTRINGDEFINES */
+
+extern _XmConst char _XmStrings[];
+
+#define XmCBackgroundPixmap ((char *)&_XmStrings[299])
+#define XmRBackgroundPixmap ((char *)&_XmStrings[10844])
+#define XmRBooleanDimension ((char *)&_XmStrings[10872])
+#define XmNbottomAttachment ((char *)&_XmStrings[5017])
+#define XmNbottomWidget ((char *)&_XmStrings[5099])
+#define XmCHighlightColor ((char *)&_XmStrings[1844])
+#define XmNhighlightColor ((char *)&_XmStrings[6996])
+#define XmCHighlightOnEnter ((char *)&_XmStrings[1859])
+#define XmNhighlightOnEnter ((char *)&_XmStrings[7011])
+#define XmCHighlightThickness ((char *)&_XmStrings[1892])
+#define XmNhighlightThickness ((char *)&_XmStrings[7044])
+#define XmCForegroundThreshold ((char *)&_XmStrings[1808])
+#define XmNforegroundThreshold ((char *)&_XmStrings[6914])
+#define XmCHighlightPixmap ((char *)&_XmStrings[1876])
+#define XmNhighlightPixmap ((char *)&_XmStrings[7028])
+#define XmRHighlightPixmap ((char *)&_XmStrings[11299])
+#define XmRHorizontalDimension ((char *)&_XmStrings[11315])
+#define XmNleftAttachment ((char *)&_XmStrings[7523])
+#define XmNrightAttachment ((char *)&_XmStrings[9077])
+#define XmRStringDirection ((char *)&_XmStrings[11981])
+#define XmNtopAttachment ((char *)&_XmStrings[10165])
+#define XmCTraversalOn ((char *)&_XmStrings[4318])
+#define XmNtraversalOn ((char *)&_XmStrings[10361])
+#define XmRXmBackgroundPixmap ((char *)&_XmStrings[12210])
+
+#endif /* XMSTRINGDEFINES */
+
+/* copy Xt constant definitions */
+#include <X11/StringDefs.h>
+
+#define XmCBackground XtCBackground
+#define XmNbackground XtNbackground
+#define XmNbackgroundPixmap XtNbackgroundPixmap
+#define XmCBoolean XtCBoolean
+#define XmRBoolean XtRBoolean
+#define XmRCallProc XtRCallProc
+#define XmCForeground XtCForeground
+#define XmNforeground XtNforeground
+#define XmRImmediate XtRImmediate
+#define XmRPixel XtRPixel
+#define XmCPixmap XtCPixmap
+#define XmNpixmap XtNpixmap
+#define XmRPixmap XtRPixmap
+#define XmRPrimHighlightPixmap XmRHighlightPixmap
+#define XmRString XtRString
+#define XmRStringArray XtRStringArray
+#define XmRStringTable XtRStringTable
+
+#endif /* GLWXM_STRDEFS_H */
diff --git a/nx-X11/lib/GLw/Imakefile b/nx-X11/lib/GLw/Imakefile
new file mode 100644
index 000000000..3eb0503fe
--- /dev/null
+++ b/nx-X11/lib/GLw/Imakefile
@@ -0,0 +1,87 @@
+XCOMM $XdotOrg: xc/lib/GLw/Imakefile,v 1.2 2005/08/24 16:27:26 alanc Exp $
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+
+XCOMM $XFree86: xc/lib/GLw/Imakefile,v 1.3 2002/04/06 18:24:46 tsi Exp $
+
+XCOMM
+XCOMM Imakefile for GLw library - lots of modifications for XFree86 by
+XCOMM Carlos A. M. dos Santos <casantos@cpmet.ufpel.tche.br>
+XCOMM
+
+XCOMM Uncomment this and set the correct values if your Motif installation
+XCOMM is out of the standard X tree and your Imake configuration is not
+XCOMM correct (unfortunatelly, a common mistake).
+
+XCOMM MOTIF_INCLUDES = -I/usr/local/include
+XCOMM MOTIF_LDFLAGS = -L/usr/local/lib
+
+#define DoNormalLib NormalLibGLw
+#define DoSharedLib SharedLibGLw
+#define DoDebugLib DebugLibGLw
+#define DoProfileLib ProfileLibGLw
+
+#define HasSharedData NO
+#define LibName GLw
+#define SoRev SOGLWREV
+#define IncSubdir GL
+
+#ifdef SharedGLwReqs
+REQUIREDLIBS = SharedGLwReqs
+#else
+REQUIREDLIBS = $(LDPRELIBS) $(XTOOLLIB) $(XLIB)
+#endif
+
+DEFINES =
+
+#if GLwUseXmStubs
+SHAREDCODEDEF = SharedCodeDef -DUSE_XM_STUBS
+#endif
+
+GLWSRCDIR = $(OGLSAMPLESRCDIR)/main/gfx/lib/glw
+
+INCLUDES = $(MOTIF_INCLUDES) -I.
+
+LOCAL_LDFLAGS = $(MOTIF_LDFLAGS)
+
+LINTLIBS = $(LINTXLIB) $(LINTXTOOL)
+
+HEADERS = GLwDrawA.h GLwDrawAP.h GLwMDrawA.h GLwMDrawAP.h
+SRCS = GLwDrawA.c GLwM1DrawA.c GLwM2DrawA.c GLwDAUtil.c
+OBJS = GLwDrawA.o GLwM1DrawA.o GLwM2DrawA.o GLwDAUtil.o
+
+#include <Library.tmpl>
+
+LinkSourceFile(GLwDAUtil.c,$(GLWSRCDIR))
+LinkSourceFile(GLwDrawA.c,$(GLWSRCDIR))
+LinkSourceFile(GLwMDrawA.c,$(GLWSRCDIR))
+LinkSourceFile(GLwDrawA.h,$(GLWSRCDIR))
+LinkSourceFile(GLwDrawAP.h,$(GLWSRCDIR))
+LinkSourceFile(GLwMDrawA.h,$(GLWSRCDIR))
+LinkSourceFile(GLwMDrawAP.h,$(GLWSRCDIR))
+
+DependTarget()
diff --git a/nx-X11/lib/GLw/README.html b/nx-X11/lib/GLw/README.html
new file mode 100644
index 000000000..973ba9cf0
--- /dev/null
+++ b/nx-X11/lib/GLw/README.html
@@ -0,0 +1,242 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+<TITLE>GL widgets for Xt/Motif - XFree86 implementation</TITLE>
+<META NAME="generator" CONTENT="Only VIM and me.">
+</HEAD>
+<BODY BGCOLOR="#FFFFFF">
+
+<!-- $XFree86$ -->
+
+<H1 ALIGN=CENTER>GL widgets for Xt/Motif</H1>
+<H2 ALIGN=CENTER>XFree86 implementation</H1>
+<P ALIGN=CENTER>by Carlos A. M. dos Santos<BR>casantos@cpmet.ufpel.tche.br</P>
+
+<HR NOSHADE>
+
+<H3>1. Introduction</H3>
+<P>
+This directory contains the source code for SGI's OpenGL Xt/Motif(TM) widgets,
+slightly modified to generate both Motif 1.x and 2.x versions of
+the widget even if Motif is not available, as in the XFree86 distribution of
+the X Window System. This code is based on that distributed by Silicon
+Graphics as part of it's OpenGL Sample Implementation, not on the modified version
+distributed with Mesa.
+
+
+<H3>2. Installation</H3>
+<P>
+This code is intended to be compiled as part of the normal XFree86 building
+process, under the xc/lib/GLw directory. To compile the library out of the X
+source tree, follow instructions below.
+
+<H3>2.1. Requirements</H3>
+<P>
+Gzip and tar are needed to extract the files from the distribution <A
+HREF="http://www.inf.ufrgs.br/~casantos/libGLw/GLw.tar.gz">archive</A>. Tar is
+a standard UNIX utility but if you don't have it use GNU tar, available in
+source form at <A
+HREF="ftp://ftp.gnu.org/pub/gnu/">ftp://ftp.gnu.org/pub/gnu/</A>. Gzip is not
+a standard UNIX utility, though available in many systems. You may obtain it
+(also source form) at the same FTP server as GNU tar.
+
+<P>
+You need xmkmf and imake too. Depending on your operating system you may need
+to install some kind of X Window System development kit, so check the vendor
+documentation first. I was told that some UNIX systems don't have imake:
+report this as a bug (to your vendor, not me).
+
+<P>
+Of course you will need a C compiler.
+
+<H3>2.2. Steps</H3>
+<P>
+<OL>
+ <LI>Extract the source code from the distribution archive.
+ <P>
+ <CODE>
+ gzip -dc GLw.tar.gz | tar xf -
+ </CODE>
+ <P>
+ <LI>Go to the surce code directory and generate the makefile.
+ <P>
+ <CODE>
+ cd GLw<BR>
+ xmkmf
+ </CODE>
+ <P>For LessTif, use "mxmkmf" instead of "xmkmf". Imake support
+ is much better in recent versions of LessTif (since late july 2000).
+ If your Motif or OpenGL libraries and/or include files are installed in
+ non-standard locations (some UNIX vendors seem to be very creative :-)
+ then edit the file named Imakefile, remove the leading XCOMM of the
+ lines containing MOTIF_INCLUDES and MOTIF_LDFLAGS and set the
+ appropriate values.
+ <P>
+ <LI>Compile the code with
+ <P>
+ <CODE>
+ make includes<BR>
+ make standalone
+ </CODE>
+ <P>
+ <LI>Install the library and manual pages with
+ <P>
+ <CODE>
+ make install<BR>
+ make install.man
+ </CODE>
+ <P>
+ <LI>Optionally, you may compile two test programs: xmdemo and xtdemo. You need OpenGL
+ (or Mesa) for both and Motif (or LessTif) for xmdemo. There are four
+ extra make targers for these programs: demos, stand-demos, stand-xmdemo
+ and stand-xtdemo. You may use them with:
+ <P>
+ <CODE>
+ make stand-demos<BR>
+ ./xmdemo
+ ./xtdemo
+ </CODE>
+</OL>
+
+<H3>2.3. Creating a shared library</H3>
+<P>
+By default only a static library is created because most of the UNIX loaders,
+if not all, complain about unresolved symbols even if the application doesn't
+use the modules in which such symbols are referenced. However, if your system
+supports libraries with weak symbols (e.g. Solaris, FreeBSD and Linux) it is
+possible to fool the loader. All you have to do is edit the Imakefile,
+changing "#define SharedLibGLw" and "#define GLwUseXmStubs" to YES, then
+repeat the compilation process starting from step 2 in the previous section.
+
+<H3>2.4. Problems</H3>
+<P>
+If you have trouble, ask for help in the XFree86 "xperts" mailing list. Look
+at <A HREF="http://www.xfree86.org">http://www.xfree86.org</A> for
+instructions on how to subscribe. In desperation, send an email to <A
+HREF="mailto:casantos@cpmet.ufpel.tche.br">casantos@cpmet.ufpel.tche.br</A>.
+
+<P>
+PLEASE DO NOT SEND ME EMAIL ASKING HOW TO INSTALL OR CONFIGURE YOUR OPERATING
+SYSTEM, MODEM, NETWORK CARD, BREAD TOASTER, COFEE MAKER OR WHATEVER ELSE!
+
+
+<H3>3. Copyrights</H3>
+<P>
+Most of the code is covered by the following license terms:
+<BLOCKQUOTE>
+<P>
+License Applicability. Except to the extent portions of this file are
+made subject to an alternative license as permitted in the SGI Free
+Software License B, Version 1.1 (the "License"), the contents of this
+file are subject only to the provisions of the License. You may not use
+this file except in compliance with the License. You may obtain a copy
+of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+<P>
+<A
+HREF="http://oss.sgi.com/projects/FreeB">http://oss.sgi.com/projects/FreeB</A>
+<P>
+Note that, as provided in the License, the Software is distributed on an
+"AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+<P>
+Original Code. The Original Code is: OpenGL Sample Implementation,
+Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+Inc. The Original Code is Copyright &copy; 1991-2000 Silicon Graphics, Inc.
+Copyright in any portions created by third parties is as indicated
+elsewhere herein. All Rights Reserved.
+<P>
+Additional Notice Provisions: The application programming interfaces
+established by SGI in conjunction with the Original Code are The
+OpenGL&reg; Graphics System: A Specification (Version 1.2.1), released
+April 1, 1999; The OpenGL&reg; Graphics System Utility Library (Version
+1.3), released November 4, 1998; and OpenGL&reg; Graphics with the X
+Window System&reg; (Version 1.3), released October 19, 1998. This software
+was created using the OpenGL&reg; version 1.2.1 Sample Implementation
+published by SGI, but has not been independently verified as being
+compliant with the OpenGL&reg; version 1.2.1 Specification.
+</BLOCKQUOTE>
+
+<P>
+The demonstration programs are covered by the following license terms:
+
+<BLOCKQUOTE>
+<P>
+Copyright &copy; Mark J. Kilgard, 1995, 1996.
+
+<P>
+NOTICE: This source code distribution contains source code contained in
+the book "Programming OpenGL for the X Window System" (ISBN:
+0-201-48359-9) published by Addison-Wesley. The programs and associated
+files contained in the distribution were developed by Mark J. Kilgard and
+are Copyright 1994, 1995, 1996 by Mark J. Kilgard (unless otherwise
+noted). The programs are not in the public domain, but they are freely
+distributable without licensing fees. These programs are provided without
+guarantee or warrantee expressed or implied.
+</BLOCKQUOTE>
+
+<P>
+The files contained in directory GLwXm are fake Motif headers, covered by
+the XFree86 license, they permit us to generate both Motif 1.x and 2.x
+versions of the widget without having Motif. Notice that they are NOT part of
+a standard Motif distribution and shall not be used to compile any other code.
+
+
+<H3>4. Thanks</H3>
+
+<P>
+Many thanks to Silicon Graphics and Mark J. Kilgard for making their
+software free.
+
+
+<H3>5. No thanks</H3>
+
+<BLOCKQUOTE>
+<P>
+<STRONG>
+THIS SECTION CONTAINS MY PERSONAL OPINIONS AND
+DOESN'T REPRESENT AN OFFICIAL POSITION OF THE XFree86 PROJECT.
+</STRONG>
+</BLOCKQUOTE>
+
+<P>
+The first incarnation of this version of libGLw used eight header files from
+<A HREF="http://www.lesstif.org/">LessTif</A>, four for each Motif version.
+LessTif is covered by the GNU Library General Public License (LGPL) whose
+terms are not compatible with the XFree86 licensing policy. Since the
+copyright holder of LessTif is the <A HREF="http://www.fsf.org/">Free Software
+Foundation</A> (FSF), I asked Richard Stallman, president of FSF and so called
+"leader of the Free Software movement", permission to redistribute a copy of
+those eight headers under XFree86 terms, still maintaining the FSF copyright.
+
+<P>
+Observe that I was not asking him to change the license of LessTif as a whole,
+but only to allow me to distribute copies of some header files containing
+function prototypes, variable declarations and data type definitions. Even so,
+Stallman said no because the files contained "more than 6000 lines of code".
+Which code? The LessTif headers are mostly copies of the Motif ones and don't
+contain any original GNU "code"! I can't still imagine a reason for Stallman's
+negative answer except for paranoia. He seems to ignore what Motif is and
+that LessTif's API is simply a copy of Motif's one.
+
+<P>
+After spending some time, I made my own headers, that became much smaller than
+the previous ones because I included only a subset of the Motif API and merged
+everything into four files: 417 lines instead 6000. Humm, perhaps I should be
+grateful to Sallman too :-).
+
+
+<H3>6. Trademarks</H3>
+
+<P>
+<UL>
+ <LI>OpenGL is a trademark of Silicon Graphics, Inc.
+ <LI>Motif is a trademark of the Open Group.
+</UL>
+
+<HR NOSHADE>
+
+</BODY>
+</HTML>
diff --git a/nx-X11/lib/GLw/README.txt b/nx-X11/lib/GLw/README.txt
new file mode 100644
index 000000000..4892f1e78
--- /dev/null
+++ b/nx-X11/lib/GLw/README.txt
@@ -0,0 +1,199 @@
+ GL widgets for Xt/Motif
+
+ XFree86 implementation
+
+ by Carlos A. M. dos Santos
+ casantos@cpmet.ufpel.tche.br
+
+ ------------------------------------------------------------------------
+
+1. Introduction
+
+This directory contains the source code for SGI's OpenGL Xt/Motif(TM)
+widgets, slightly modified to generate both Motif 1.x and 2.x versions of
+the widget even if Motif is not available, as in the XFree86 distribution of
+the X Window System. This code is based on that distributed by Silicon
+Graphics as part of it's OpenGL Sample Implementation, not on the modified
+version distributed with Mesa.
+
+2. Installation
+
+This code is intended to be compiled as part of the normal XFree86 building
+process, under the xc/lib/GLw directory. To compile the library out of the X
+source tree, follow instructions below.
+
+2.1. Requirements
+
+Gzip and tar are needed to extract the files from the distribution archive.
+Tar is a standard UNIX utility but if you don't have it use GNU tar,
+available in source form at ftp://ftp.gnu.org/pub/gnu/. Gzip is not a
+standard UNIX utility, though available in many systems. You may obtain it
+(also source form) at the same FTP server as GNU tar.
+
+You need xmkmf and imake too. Depending on your operating system you may
+need to install some kind of X Window System development kit, so check the
+vendor documentation first. I was told that some UNIX systems don't have
+imake: report this as a bug (to your vendor, not me).
+
+Of course you will need a C compiler.
+
+2.2. Steps
+
+ 1. Extract the source code from the distribution archive.
+
+ gzip -dc GLw.tar.gz | tar xf -
+
+ 2. Go to the surce code directory and generate the makefile.
+
+ cd GLw
+ xmkmf
+
+ For LessTif, use "mxmkmf" instead of "xmkmf". Imake support is much
+ better in recent versions of LessTif (since late july 2000). If your
+ Motif or OpenGL libraries and/or include files are installed in
+ non-standard locations (some UNIX vendors seem to be very creative :-)
+ then edit the file named Imakefile, remove the leading XCOMM of the
+ lines containing MOTIF_INCLUDES and MOTIF_LDFLAGS and set the
+ appropriate values.
+
+ 3. Compile the code with
+
+ make includes
+ make standalone
+
+ 4. Install the library and manual pages with
+
+ make install
+ make install.man
+
+ 5. Optionally, you may compile two test programs: xmdemo and xtdemo. You
+ need OpenGL (or Mesa) for both and Motif (or LessTif) for xmdemo. There
+ are four extra make targers for these programs: demos, stand-demos,
+ stand-xmdemo and stand-xtdemo. You may use them with:
+
+ make stand-demos
+ ./xmdemo ./xtdemo
+
+2.3. Creating a shared library
+
+By default only a static library is created because most of the UNIX
+loaders, if not all, complain about unresolved symbols even if the
+application doesn't use the modules in which such symbols are referenced.
+However, if your system supports libraries with weak symbols (e.g. Solaris,
+FreeBSD and Linux) it is possible to fool the loader. All you have to do is
+edit the Imakefile, changing "#define SharedLibGLw" and "#define
+GLwUseXmStubs" to YES, then repeat the compilation process starting from
+step 2 in the previous section.
+
+2.4. Problems
+
+If you have trouble, ask for help in the XFree86 "xperts" mailing list. Look
+at http://www.xfree86.org for instructions on how to subscribe. In
+desperation, send an email to casantos@cpmet.ufpel.tche.br.
+
+PLEASE DO NOT SEND ME EMAIL ASKING HOW TO INSTALL OR CONFIGURE YOUR
+OPERATING SYSTEM, MODEM, NETWORK CARD, BREAD TOASTER, COFEE MAKER OR
+WHATEVER ELSE!
+
+3. Copyrights
+
+Most of the code is covered by the following license terms:
+
+ License Applicability. Except to the extent portions of this file
+ are made subject to an alternative license as permitted in the SGI
+ Free Software License B, Version 1.1 (the "License"), the contents
+ of this file are subject only to the provisions of the License.
+ You may not use this file except in compliance with the License.
+ You may obtain a copy of the License at Silicon Graphics, Inc.,
+ attn: Legal Services, 1600 Amphitheatre Parkway, Mountain View, CA
+ 94043-1351, or at:
+
+ http://oss.sgi.com/projects/FreeB
+
+ Note that, as provided in the License, the Software is distributed
+ on an "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND
+ CONDITIONS DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ WARRANTIES AND CONDITIONS OF MERCHANTABILITY, SATISFACTORY
+ QUALITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+
+ Original Code. The Original Code is: OpenGL Sample Implementation,
+ Version 1.2.1, released January 26, 2000, developed by Silicon
+ Graphics, Inc. The Original Code is Copyright © 1991-2000 Silicon
+ Graphics, Inc. Copyright in any portions created by third parties
+ is as indicated elsewhere herein. All Rights Reserved.
+
+ Additional Notice Provisions: The application programming
+ interfaces established by SGI in conjunction with the Original
+ Code are The OpenGL® Graphics System: A Specification (Version
+ 1.2.1), released April 1, 1999; The OpenGL® Graphics System
+ Utility Library (Version 1.3), released November 4, 1998; and
+ OpenGL® Graphics with the X Window System® (Version 1.3), released
+ October 19, 1998. This software was created using the OpenGL®
+ version 1.2.1 Sample Implementation published by SGI, but has not
+ been independently verified as being compliant with the OpenGL®
+ version 1.2.1 Specification.
+
+The demonstration programs are covered by the following license terms:
+
+ Copyright © Mark J. Kilgard, 1995, 1996.
+
+ NOTICE: This source code distribution contains source code
+ contained in the book "Programming OpenGL for the X Window System"
+ (ISBN: 0-201-48359-9) published by Addison-Wesley. The programs
+ and associated files contained in the distribution were developed
+ by Mark J. Kilgard and are Copyright 1994, 1995, 1996 by Mark J.
+ Kilgard (unless otherwise noted). The programs are not in the
+ public domain, but they are freely distributable without licensing
+ fees. These programs are provided without guarantee or warrantee
+ expressed or implied.
+
+The files contained in directory GLwXm are fake Motif headers, covered by
+the XFree86 license, they permit us to generate both Motif 1.x and 2.x
+versions of the widget without having Motif. Notice that they are NOT part
+of a standard Motif distribution and shall not be used to compile any other
+code.
+
+4. Thanks
+
+Many thanks to Silicon Graphics and Mark J. Kilgard for making their
+software free.
+
+5. No thanks
+
+ THIS SECTION CONTAINS MY PERSONAL OPINIONS AND DOESN'T REPRESENT
+ AN OFFICIAL POSITION OF THE XFree86 PROJECT.
+
+The first incarnation of this version of libGLw used eight header files from
+LessTif, four for each Motif version. LessTif is covered by the GNU Library
+General Public License (LGPL) whose terms are not compatible with the
+XFree86 licensing policy. Since the copyright holder of LessTif is the Free
+Software Foundation (FSF), I asked Richard Stallman, president of FSF and so
+called "leader of the Free Software movement", permission to redistribute a
+copy of those eight headers under XFree86 terms, still maintaining the FSF
+copyright.
+
+Observe that I was not asking him to change the license of LessTif as a
+whole, but only to allow me to distribute copies of some header files
+containing function prototypes, variable declarations and data type
+definitions. Even so, Stallman said no because the files contained "more
+than 6000 lines of code". Which code? The LessTif headers are mostly copies
+of the Motif ones and don't contain any original GNU "code"! I can't still
+imagine a reason for Stallman's negative answer except for paranoia. He
+seems to ignore what Motif is and that LessTif's API is simply a copy of
+Motif's one.
+
+After spending some time, I made my own headers, that became much smaller
+than the previous ones because I included only a subset of the Motif API and
+merged everything into four files: 417 lines instead 6000. Humm, perhaps I
+should be grateful to Sallman too :-).
+
+6. Trademarks
+
+ * OpenGL is a trademark of Silicon Graphics, Inc.
+ * Motif is a trademark of the Open Group.
+
+ ------------------------------------------------------------------------
+
+
+
+$XFree86$
diff --git a/nx-X11/lib/ICE/ICE-def.cpp b/nx-X11/lib/ICE/ICE-def.cpp
new file mode 100644
index 000000000..cb9a27d7b
--- /dev/null
+++ b/nx-X11/lib/ICE/ICE-def.cpp
@@ -0,0 +1,74 @@
+LIBRARY ICE
+VERSION LIBRARY_VERSION
+EXPORTS
+ IceAcceptConnection
+ IceAddConnectionWatch
+ IceAllocScratch
+ IceAppLockConn
+ IceAppUnlockConn
+ IceAuthFileName
+ IceCheckShutdownNegotiation
+ IceCloseConnection
+ IceComposeNetworkIdList
+ IceConnectionNumber
+ IceConnectionStatus
+ IceConnectionString
+ IceFlush
+ IceFreeAuthFileEntry
+ IceFreeListenObjs
+ IceGenerateMagicCookie
+ IceGetAuthFileEntry
+ IceGetConnectionContext
+ IceGetInBufSize
+ IceGetListenConnectionNumber
+ IceGetListenConnectionString
+ IceGetOutBufSize
+ IceInitThreads
+ IceLastReceivedSequenceNumber
+ IceLastSentSequenceNumber
+ IceListenForConnections
+ IceLockAuthFile
+ IceOpenConnection
+ IcePing
+ IceProcessMessages
+ IceProtocolRevision
+ IceProtocolSetup
+ IceProtocolShutdown
+ IceProtocolVersion
+ IceReadAuthFileEntry
+ IceRegisterForProtocolReply
+ IceRegisterForProtocolSetup
+ IceRelease
+ IceRemoveConnectionWatch
+ IceSetErrorHandler
+ IceSetHostBasedAuthProc
+ IceSetIOErrorHandler
+ IceSetPaAuthData
+ IceSetShutdownNegotiation
+ IceSwapping
+ IceUnlockAuthFile
+ IceVendor
+ IceWriteAuthFileEntry
+ _IceTransGetPeerAddr
+ _IceTransGetPeerNetworkId
+ _IceErrorBadMinor
+ _IceErrorBadLength
+ _IceErrorBadState
+ _IceErrorBadValue
+ _IcePaMagicCookie1Proc
+ _IcePoMagicCookie1Proc
+ _IceRead
+ _IceReadSkip
+ _IceWrite
+ IceListenForWellKnownConnections
+ _IceTransGetHostname
+ _IceTransSetOption
+ _IceTransConnect
+ _IceTransClose
+ _IceTransOpenCOTSClient
+ _IceTransGetConnectionNumber
+ _IceTransRead
+ _IceTransWrite
+
+/* $Xorg: ICE-def.cpp,v 1.3 2000/08/21 16:42:31 coskrey Exp $ */
+/* $XFree86: xc/lib/ICE/ICE-def.cpp,v 1.4 2001/01/17 19:41:29 dawes Exp $ */
diff --git a/nx-X11/lib/ICE/ICE.h b/nx-X11/lib/ICE/ICE.h
new file mode 100644
index 000000000..e2924f1ab
--- /dev/null
+++ b/nx-X11/lib/ICE/ICE.h
@@ -0,0 +1,102 @@
+/* $Xorg: ICE.h,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+
+******************************************************************************/
+
+#ifndef _ICE_H_
+#define _ICE_H_
+
+/*
+ * Protocol Version
+ */
+
+#define IceProtoMajor 1
+#define IceProtoMinor 0
+
+
+/*
+ * Byte Order
+ */
+
+#define IceLSBfirst 0
+#define IceMSBfirst 1
+
+
+/*
+ * ICE minor opcodes
+ */
+
+#define ICE_Error 0
+#define ICE_ByteOrder 1
+#define ICE_ConnectionSetup 2
+#define ICE_AuthRequired 3
+#define ICE_AuthReply 4
+#define ICE_AuthNextPhase 5
+#define ICE_ConnectionReply 6
+#define ICE_ProtocolSetup 7
+#define ICE_ProtocolReply 8
+#define ICE_Ping 9
+#define ICE_PingReply 10
+#define ICE_WantToClose 11
+#define ICE_NoClose 12
+
+
+/*
+ * Error severity
+ */
+
+#define IceCanContinue 0
+#define IceFatalToProtocol 1
+#define IceFatalToConnection 2
+
+
+/*
+ * ICE error classes that are common to all protocols
+ */
+
+#define IceBadMinor 0x8000
+#define IceBadState 0x8001
+#define IceBadLength 0x8002
+#define IceBadValue 0x8003
+
+
+/*
+ * ICE error classes that are specific to the ICE protocol
+ */
+
+#define IceBadMajor 0
+#define IceNoAuth 1
+#define IceNoVersion 2
+#define IceSetupFailed 3
+#define IceAuthRejected 4
+#define IceAuthFailed 5
+#define IceProtocolDuplicate 6
+#define IceMajorOpcodeDuplicate 7
+#define IceUnknownProtocol 8
+
+#endif /* _ICE_H_ */
diff --git a/nx-X11/lib/ICE/ICEconn.h b/nx-X11/lib/ICE/ICEconn.h
new file mode 100644
index 000000000..cdfaccaea
--- /dev/null
+++ b/nx-X11/lib/ICE/ICEconn.h
@@ -0,0 +1,251 @@
+/* $Xorg: ICEconn.h,v 1.5 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+
+#ifndef _ICECONN_H_
+#define _ICECONN_H_
+
+#include <X11/ICE/ICElib.h>
+
+/*
+ * Data structures for ICE connection object
+ */
+
+typedef struct _IceSavedReplyWait {
+ IceReplyWaitInfo *reply_wait;
+ Bool reply_ready;
+ struct _IceSavedReplyWait *next;
+} _IceSavedReplyWait;
+
+typedef struct _IcePingWait {
+ IcePingReplyProc ping_reply_proc;
+ IcePointer client_data;
+ struct _IcePingWait *next;
+} _IcePingWait;
+
+typedef struct {
+ char *vendor;
+ char *release;
+ int version_count;
+ IcePoVersionRec *version_recs;
+ int auth_count;
+ char **auth_names;
+ IcePoAuthProc *auth_procs;
+ IceIOErrorProc io_error_proc;
+} _IcePoProtocol;
+
+typedef struct {
+ char *vendor;
+ char *release;
+ int version_count;
+ IcePaVersionRec *version_recs;
+ IceProtocolSetupProc protocol_setup_proc;
+ IceProtocolActivateProc protocol_activate_proc;
+ int auth_count;
+ char **auth_names;
+ IcePaAuthProc *auth_procs;
+ IceHostBasedAuthProc host_based_auth_proc;
+ IceIOErrorProc io_error_proc;
+} _IcePaProtocol;
+
+typedef struct {
+ char *protocol_name;
+ _IcePoProtocol *orig_client;
+ _IcePaProtocol *accept_client;
+} _IceProtocol;
+
+typedef struct {
+ Bool in_use;
+ int my_opcode;
+ _IceProtocol *protocol;
+ IcePointer client_data;
+ Bool accept_flag;
+ union {
+ IcePaProcessMsgProc accept_client;
+ IcePoProcessMsgProc orig_client;
+ } process_msg_proc;
+} _IceProcessMsgInfo;
+
+typedef struct {
+ int his_version_index;
+ int my_version_index;
+ char *his_vendor;
+ char *his_release;
+ char my_auth_index;
+ IcePointer my_auth_state;
+ Bool must_authenticate;
+} _IceConnectToMeInfo;
+
+typedef struct {
+ int his_opcode;
+ int my_opcode;
+ int his_version_index;
+ int my_version_index;
+ char *his_vendor;
+ char *his_release;
+ char my_auth_index;
+ IcePointer my_auth_state;
+ Bool must_authenticate;
+} _IceProtoSetupToMeInfo;
+
+typedef struct {
+ Bool auth_active;
+ char my_auth_index;
+ IcePointer my_auth_state;
+} _IceConnectToYouInfo;
+
+typedef struct {
+ int my_opcode;
+ int my_auth_count;
+ int *my_auth_indices;
+ Bool auth_active;
+ char my_auth_index;
+ IcePointer my_auth_state;
+} _IceProtoSetupToYouInfo;
+
+
+struct _IceConn {
+
+ unsigned int io_ok : 1; /* did an IO error occur? */
+ unsigned int swap : 1; /* do we need to swap on reads? */
+ unsigned int waiting_for_byteorder : 1; /* waiting for a ByteOrder msg? */
+ unsigned int skip_want_to_close : 1; /* avoid shutdown negotiation? */
+ unsigned int want_to_close : 1; /* did we send a WantToClose? */
+ unsigned int free_asap : 1; /* free as soon as possible */
+ unsigned int unused1 : 2; /* future use */
+ unsigned int unused2 : 8; /* future use */
+
+ IceConnectStatus connection_status; /* pending, accepted, rejected */
+
+ unsigned char my_ice_version_index; /* which version are we using? */
+
+ struct _XtransConnInfo *trans_conn; /* transport connection object */
+ unsigned long send_sequence; /* Sequence # of last msg sent */
+ unsigned long receive_sequence; /* Sequence # of last msg received */
+
+ char *connection_string; /* network connection string */
+ char *vendor; /* other client's vendor */
+ char *release; /* other client's release */
+
+ char *inbuf; /* Input buffer starting address */
+ char *inbufptr; /* Input buffer index pointer */
+ char *inbufmax; /* Input buffer maximum+1 address */
+
+ char *outbuf; /* Output buffer starting address */
+ char *outbufptr; /* Output buffer index pointer */
+ char *outbufmax; /* Output buffer maximum+1 address */
+
+ char *scratch; /* scratch buffer */
+ unsigned long scratch_size; /* scratch size */
+
+ int dispatch_level; /* IceProcessMessages dispatch level */
+
+ IcePointer context; /* context associated with caller
+ of IceOpenConnection */
+
+ /*
+ * Before we read a message, the major opcode of the message must be
+ * mapped to our corresponding major opcode (the two clients can use
+ * different opcodes for the same protocol). In order to save space,
+ * we keep track of the mininum and maximum major opcodes used by the
+ * other client. To get the information on how to process this message,
+ * we do the following...
+ *
+ * processMsgInfo = iceConn->process_msg_info[
+ * message->majorOpcode - iceConn->his_min_opcode]
+ *
+ * Note that the number of elements in the iceConn->process_msg_info
+ * array is always (iceConn->his_max_opcode - iceConn->his_min_opcode + 1).
+ * We check process_msg_info->in_use to see if the opcode is being used.
+ */
+
+ _IceProcessMsgInfo *process_msg_info;
+ char his_min_opcode; /* [1..255] */
+ char his_max_opcode; /* [1..255] */
+
+
+ /*
+ * Number of times this iceConn was returned in IceOpenConnection
+ * or IceAcceptConnection.
+ */
+
+ unsigned char open_ref_count;
+
+
+ /*
+ * Number of active protocols.
+ */
+
+ unsigned char proto_ref_count;
+
+
+ /*
+ * If this ICE connection was created with IceAcceptConnection,
+ * the listen_obj field is set to the listen object. Otherwise,
+ * the listen_obj field is NULL.
+ */
+
+ IceListenObj listen_obj;
+
+
+
+
+ /*
+ * We need to keep track of all the replies we're waiting for.
+ * Check the comments in process.c for how this works.
+ */
+
+ _IceSavedReplyWait *saved_reply_waits;
+
+
+ /*
+ * We keep track of all Pings sent from the client. When the Ping reply
+ * arrives, we remove it from the list.
+ */
+
+ _IcePingWait *ping_waits;
+
+
+ /*
+ * Some state for a client doing a Connection/Protocol Setup
+ */
+
+ _IceConnectToYouInfo *connect_to_you;
+ _IceProtoSetupToYouInfo *protosetup_to_you;
+
+
+ /*
+ * Some state for a client receiving a Connection/Protocol Setup
+ */
+
+ _IceConnectToMeInfo *connect_to_me;
+ _IceProtoSetupToMeInfo *protosetup_to_me;
+
+};
+
+#endif /* _ICECONN_H_ */
diff --git a/nx-X11/lib/ICE/ICElib.h b/nx-X11/lib/ICE/ICElib.h
new file mode 100644
index 000000000..eb7a3aa32
--- /dev/null
+++ b/nx-X11/lib/ICE/ICElib.h
@@ -0,0 +1,433 @@
+/* $Xorg: ICElib.h,v 1.5 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/ICElib.h,v 3.4 2001/12/14 19:53:35 dawes Exp $ */
+
+#ifndef _ICELIB_H_
+#define _ICELIB_H_
+
+#include <X11/ICE/ICE.h>
+#include <X11/Xfuncproto.h>
+
+#define Bool int
+#define Status int
+#define True 1
+#define False 0
+
+typedef void *IcePointer;
+
+typedef enum {
+ IcePoAuthHaveReply,
+ IcePoAuthRejected,
+ IcePoAuthFailed,
+ IcePoAuthDoneCleanup
+} IcePoAuthStatus;
+
+typedef enum {
+ IcePaAuthContinue,
+ IcePaAuthAccepted,
+ IcePaAuthRejected,
+ IcePaAuthFailed
+} IcePaAuthStatus;
+
+typedef enum {
+ IceConnectPending,
+ IceConnectAccepted,
+ IceConnectRejected,
+ IceConnectIOError
+} IceConnectStatus;
+
+typedef enum {
+ IceProtocolSetupSuccess,
+ IceProtocolSetupFailure,
+ IceProtocolSetupIOError,
+ IceProtocolAlreadyActive
+} IceProtocolSetupStatus;
+
+typedef enum {
+ IceAcceptSuccess,
+ IceAcceptFailure,
+ IceAcceptBadMalloc
+} IceAcceptStatus;
+
+typedef enum {
+ IceClosedNow,
+ IceClosedASAP,
+ IceConnectionInUse,
+ IceStartedShutdownNegotiation
+} IceCloseStatus;
+
+typedef enum {
+ IceProcessMessagesSuccess,
+ IceProcessMessagesIOError,
+ IceProcessMessagesConnectionClosed
+} IceProcessMessagesStatus;
+
+typedef struct {
+ unsigned long sequence_of_request;
+ int major_opcode_of_request;
+ int minor_opcode_of_request;
+ IcePointer reply;
+} IceReplyWaitInfo;
+
+typedef struct _IceConn *IceConn;
+typedef struct _IceListenObj *IceListenObj;
+
+typedef void (*IceWatchProc) (
+ IceConn /* iceConn */,
+ IcePointer /* clientData */,
+ Bool /* opening */,
+ IcePointer * /* watchData */
+);
+
+typedef void (*IcePoProcessMsgProc) (
+ IceConn /* iceConn */,
+ IcePointer /* clientData */,
+ int /* opcode */,
+ unsigned long /* length */,
+ Bool /* swap */,
+ IceReplyWaitInfo * /* replyWait */,
+ Bool * /* replyReadyRet */
+);
+
+typedef void (*IcePaProcessMsgProc) (
+ IceConn /* iceConn */,
+ IcePointer /* clientData */,
+ int /* opcode */,
+ unsigned long /* length */,
+ Bool /* swap */
+);
+
+typedef struct {
+ int major_version;
+ int minor_version;
+ IcePoProcessMsgProc process_msg_proc;
+} IcePoVersionRec;
+
+typedef struct {
+ int major_version;
+ int minor_version;
+ IcePaProcessMsgProc process_msg_proc;
+} IcePaVersionRec;
+
+typedef IcePoAuthStatus (*IcePoAuthProc) (
+ IceConn /* iceConn */,
+ IcePointer * /* authStatePtr */,
+ Bool /* cleanUp */,
+ Bool /* swap */,
+ int /* authDataLen */,
+ IcePointer /* authData */,
+ int * /* replyDataLenRet */,
+ IcePointer * /* replyDataRet */,
+ char ** /* errorStringRet */
+);
+
+typedef IcePaAuthStatus (*IcePaAuthProc) (
+ IceConn /* iceConn */,
+ IcePointer * /* authStatePtr */,
+ Bool /* swap */,
+ int /* authDataLen */,
+ IcePointer /* authData */,
+ int * /* replyDataLenRet */,
+ IcePointer * /* replyDataRet */,
+ char ** /* errorStringRet */
+);
+
+typedef Bool (*IceHostBasedAuthProc) (
+ char * /* hostName */
+);
+
+typedef Status (*IceProtocolSetupProc) (
+ IceConn /* iceConn */,
+ int /* majorVersion */,
+ int /* minorVersion */,
+ char * /* vendor */,
+ char * /* release */,
+ IcePointer * /* clientDataRet */,
+ char ** /* failureReasonRet */
+);
+
+typedef void (*IceProtocolActivateProc) (
+ IceConn /* iceConn */,
+ IcePointer /* clientData */
+);
+
+typedef void (*IceIOErrorProc) (
+ IceConn /* iceConn */
+);
+
+typedef void (*IcePingReplyProc) (
+ IceConn /* iceConn */,
+ IcePointer /* clientData */
+);
+
+typedef void (*IceErrorHandler) (
+ IceConn /* iceConn */,
+ Bool /* swap */,
+ int /* offendingMinorOpcode */,
+ unsigned long /* offendingSequence */,
+ int /* errorClass */,
+ int /* severity */,
+ IcePointer /* values */
+);
+
+typedef void (*IceIOErrorHandler) (
+ IceConn /* iceConn */
+);
+
+
+/*
+ * Function prototypes
+ */
+
+_XFUNCPROTOBEGIN
+
+extern int IceRegisterForProtocolSetup (
+ char * /* protocolName */,
+ char * /* vendor */,
+ char * /* release */,
+ int /* versionCount */,
+ IcePoVersionRec * /* versionRecs */,
+ int /* authCount */,
+ char ** /* authNames */,
+ IcePoAuthProc * /* authProcs */,
+ IceIOErrorProc /* IOErrorProc */
+);
+
+extern int IceRegisterForProtocolReply (
+ char * /* protocolName */,
+ char * /* vendor */,
+ char * /* release */,
+ int /* versionCount */,
+ IcePaVersionRec * /* versionRecs */,
+ int /* authCount */,
+ char ** /* authNames */,
+ IcePaAuthProc * /* authProcs */,
+ IceHostBasedAuthProc /* hostBasedAuthProc */,
+ IceProtocolSetupProc /* protocolSetupProc */,
+ IceProtocolActivateProc /* protocolActivateProc */,
+ IceIOErrorProc /* IOErrorProc */
+);
+
+extern IceConn IceOpenConnection (
+ char * /* networkIdsList */,
+ IcePointer /* context */,
+ Bool /* mustAuthenticate */,
+ int /* majorOpcodeCheck */,
+ int /* errorLength */,
+ char * /* errorStringRet */
+);
+
+extern IcePointer IceGetConnectionContext (
+ IceConn /* iceConn */
+);
+
+extern Status IceListenForConnections (
+ int * /* countRet */,
+ IceListenObj ** /* listenObjsRet */,
+ int /* errorLength */,
+ char * /* errorStringRet */
+);
+
+extern Status IceListenForWellKnownConnections (
+ char * /* port */,
+ int * /* countRet */,
+ IceListenObj ** /* listenObjsRet */,
+ int /* errorLength */,
+ char * /* errorStringRet */
+);
+
+extern int IceGetListenConnectionNumber (
+ IceListenObj /* listenObj */
+);
+
+extern char *IceGetListenConnectionString (
+ IceListenObj /* listenObj */
+);
+
+extern char *IceComposeNetworkIdList (
+ int /* count */,
+ IceListenObj * /* listenObjs */
+);
+
+extern void IceFreeListenObjs (
+ int /* count */,
+ IceListenObj * /* listenObjs */
+);
+
+extern void IceSetHostBasedAuthProc (
+ IceListenObj /* listenObj */,
+ IceHostBasedAuthProc /* hostBasedAuthProc */
+);
+
+extern IceConn IceAcceptConnection (
+ IceListenObj /* listenObj */,
+ IceAcceptStatus * /* statusRet */
+);
+
+extern void IceSetShutdownNegotiation (
+ IceConn /* iceConn */,
+ Bool /* negotiate */
+);
+
+extern Bool IceCheckShutdownNegotiation (
+ IceConn /* iceConn */
+);
+
+extern IceCloseStatus IceCloseConnection (
+ IceConn /* iceConn */
+);
+
+extern Status IceAddConnectionWatch (
+ IceWatchProc /* watchProc */,
+ IcePointer /* clientData */
+);
+
+extern void IceRemoveConnectionWatch (
+ IceWatchProc /* watchProc */,
+ IcePointer /* clientData */
+);
+
+extern IceProtocolSetupStatus IceProtocolSetup (
+ IceConn /* iceConn */,
+ int /* myOpcode */,
+ IcePointer /* clientData */,
+ Bool /* mustAuthenticate */,
+ int * /* majorVersionRet */,
+ int * /* minorVersionRet */,
+ char ** /* vendorRet */,
+ char ** /* releaseRet */,
+ int /* errorLength */,
+ char * /* errorStringRet */
+);
+
+extern Status IceProtocolShutdown (
+ IceConn /* iceConn */,
+ int /* majorOpcode */
+);
+
+extern IceProcessMessagesStatus IceProcessMessages (
+ IceConn /* iceConn */,
+ IceReplyWaitInfo * /* replyWait */,
+ Bool * /* replyReadyRet */
+);
+
+extern Status IcePing (
+ IceConn /* iceConn */,
+ IcePingReplyProc /* pingReplyProc */,
+ IcePointer /* clientData */
+);
+
+extern char *IceAllocScratch (
+ IceConn /* iceConn */,
+ unsigned long /* size */
+);
+
+extern int IceFlush (
+ IceConn /* iceConn */
+);
+
+extern int IceGetOutBufSize (
+ IceConn /* iceConn */
+);
+
+extern int IceGetInBufSize (
+ IceConn /* iceConn */
+);
+
+extern IceConnectStatus IceConnectionStatus (
+ IceConn /* iceConn */
+);
+
+extern char *IceVendor (
+ IceConn /* iceConn */
+);
+
+extern char *IceRelease (
+ IceConn /* iceConn */
+);
+
+extern int IceProtocolVersion (
+ IceConn /* iceConn */
+);
+
+extern int IceProtocolRevision (
+ IceConn /* iceConn */
+);
+
+extern int IceConnectionNumber (
+ IceConn /* iceConn */
+);
+
+extern char *IceConnectionString (
+ IceConn /* iceConn */
+);
+
+extern unsigned long IceLastSentSequenceNumber (
+ IceConn /* iceConn */
+);
+
+extern unsigned long IceLastReceivedSequenceNumber (
+ IceConn /* iceConn */
+);
+
+extern Bool IceSwapping (
+ IceConn /* iceConn */
+);
+
+extern IceErrorHandler IceSetErrorHandler (
+ IceErrorHandler /* handler */
+);
+
+extern IceIOErrorHandler IceSetIOErrorHandler (
+ IceIOErrorHandler /* handler */
+);
+
+extern char *IceGetPeerName (
+ IceConn /* iceConn */
+);
+
+/*
+ * Multithread Routines
+ */
+
+extern Status IceInitThreads (
+ void
+);
+
+extern void IceAppLockConn (
+ IceConn /* iceConn */
+);
+
+extern void IceAppUnlockConn (
+ IceConn /* iceConn */
+);
+
+_XFUNCPROTOEND
+
+#endif /* _ICELIB_H_ */
diff --git a/nx-X11/lib/ICE/ICElibint.h b/nx-X11/lib/ICE/ICElibint.h
new file mode 100644
index 000000000..fd84fdebf
--- /dev/null
+++ b/nx-X11/lib/ICE/ICElibint.h
@@ -0,0 +1,537 @@
+/* $Xorg: ICElibint.h,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/ICElibint.h,v 1.6 2001/12/14 19:53:35 dawes Exp $ */
+
+#ifndef _ICELIBINT_H_
+#define _ICELIBINT_H_
+
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xmd.h>
+#include <X11/ICE/ICEproto.h>
+#include <X11/ICE/ICEconn.h>
+#include <X11/ICE/ICEmsg.h>
+
+#include <stdlib.h>
+#include <stddef.h>
+
+
+/*
+ * Vendor & Release
+ */
+
+#define IceVendorString "MIT"
+#define IceReleaseString "1.0"
+
+
+/*
+ * Pad to a 64 bit boundary
+ */
+
+#define PAD64(_bytes) ((8 - ((unsigned int) (_bytes) % 8)) % 8)
+
+#define PADDED_BYTES64(_bytes) (_bytes + PAD64 (_bytes))
+
+
+/*
+ * Pad to 32 bit boundary
+ */
+
+#define PAD32(_bytes) ((4 - ((unsigned int) (_bytes) % 4)) % 4)
+
+#define PADDED_BYTES32(_bytes) (_bytes + PAD32 (_bytes))
+
+
+/*
+ * Number of 8 byte units in _bytes.
+ */
+
+#define WORD64COUNT(_bytes) (((unsigned int) ((_bytes) + 7)) >> 3)
+
+
+/*
+ * Number of 4 byte units in _bytes.
+ */
+
+#define WORD32COUNT(_bytes) (((unsigned int) ((_bytes) + 3)) >> 2)
+
+
+/*
+ * Given a string, compute the number of bytes for the STRING representation
+ */
+
+#define STRING_BYTES(_string) \
+ (2 + strlen (_string) + PAD32 (2 + strlen (_string)))
+
+
+/*
+ * Size of ICE input/output buffers
+ */
+
+#define ICE_INBUFSIZE 1024
+
+#define ICE_OUTBUFSIZE 1024
+
+
+/*
+ * Maxium number of ICE authentication methods allowed, and maxiumum
+ * number of authentication data entries allowed to be set in the
+ * IceSetPaAuthData function.
+ *
+ * We should use linked lists, but this is easier and should suffice.
+ */
+
+#define MAX_ICE_AUTH_NAMES 32
+#define ICE_MAX_AUTH_DATA_ENTRIES 100
+
+
+/*
+ * ICE listen object
+ */
+
+struct _IceListenObj {
+ struct _XtransConnInfo *trans_conn; /* transport connection object */
+ char *network_id;
+ IceHostBasedAuthProc host_based_auth_proc;
+};
+
+
+/*
+ * Some internal data structures for processing ICE messages.
+ */
+
+typedef void (*_IceProcessCoreMsgProc) (
+ IceConn /* iceConn */,
+ int /* opcode */,
+ unsigned long /* length */,
+ Bool /* swap */,
+ IceReplyWaitInfo * /* replyWait */,
+ Bool * /* replyReadyRet */,
+ Bool * /* connectionClosedRet */
+);
+
+typedef struct {
+ int major_version;
+ int minor_version;
+ _IceProcessCoreMsgProc process_core_msg_proc;
+} _IceVersion;
+
+
+/*
+ * STORE FOO
+ */
+
+#define STORE_CARD8(_pBuf, _val) \
+{ \
+ *((CARD8 *) _pBuf) = _val; \
+ _pBuf += 1; \
+}
+
+#ifndef WORD64
+
+#define STORE_CARD16(_pBuf, _val) \
+{ \
+ *((CARD16 *) _pBuf) = _val; \
+ _pBuf += 2; \
+}
+
+#define STORE_CARD32(_pBuf, _val) \
+{ \
+ *((CARD32 *) _pBuf) = _val; \
+ _pBuf += 4; \
+}
+
+#else /* WORD64 */
+
+#define STORE_CARD16(_pBuf, _val) \
+{ \
+ struct { \
+ int value :16; \
+ int pad :16; \
+ } _d; \
+ _d.value = _val; \
+ memcpy (_pBuf, &_d, 2); \
+ _pBuf += 2; \
+}
+
+#define STORE_CARD32(_pBuf, _val) \
+{ \
+ struct { \
+ int value :32; \
+ } _d; \
+ _d.value = _val; \
+ memcpy (_pBuf, &_d, 4); \
+ _pBuf += 4; \
+}
+
+#endif /* WORD64 */
+
+#define STORE_STRING(_pBuf, _string) \
+{ \
+ CARD16 _len = strlen (_string); \
+ STORE_CARD16 (_pBuf, _len); \
+ memcpy (_pBuf, _string, _len); \
+ _pBuf += _len; \
+ if (PAD32 (2 + _len)) \
+ _pBuf += PAD32 (2 + _len); \
+}
+
+
+/*
+ * EXTRACT FOO
+ */
+
+#define EXTRACT_CARD8(_pBuf, _val) \
+{ \
+ _val = *((CARD8 *) _pBuf); \
+ _pBuf += 1; \
+}
+
+#ifndef WORD64
+
+#define EXTRACT_CARD16(_pBuf, _swap, _val) \
+{ \
+ _val = *((CARD16 *) _pBuf); \
+ _pBuf += 2; \
+ if (_swap) \
+ _val = lswaps (_val); \
+}
+
+#define EXTRACT_CARD32(_pBuf, _swap, _val) \
+{ \
+ _val = *((CARD32 *) _pBuf); \
+ _pBuf += 4; \
+ if (_swap) \
+ _val = lswapl (_val); \
+}
+
+#else /* WORD64 */
+
+#define EXTRACT_CARD16(_pBuf, _swap, _val) \
+{ \
+ _val = *(_pBuf + 0) & 0xff; /* 0xff incase _pBuf is signed */ \
+ _val <<= 8; \
+ _val |= *(_pBuf + 1) & 0xff;\
+ _pBuf += 2; \
+ if (_swap) \
+ _val = lswaps (_val); \
+}
+
+#define EXTRACT_CARD32(_pBuf, _swap, _val) \
+{ \
+ _val = *(_pBuf + 0) & 0xff; /* 0xff incase _pBuf is signed */ \
+ _val <<= 8; \
+ _val |= *(_pBuf + 1) & 0xff;\
+ _val <<= 8; \
+ _val |= *(_pBuf + 2) & 0xff;\
+ _val <<= 8; \
+ _val |= *(_pBuf + 3) & 0xff;\
+ _pBuf += 4; \
+ if (_swap) \
+ _val = lswapl (_val); \
+}
+
+#endif /* WORD64 */
+
+#define EXTRACT_STRING(_pBuf, _swap, _string) \
+{ \
+ CARD16 _len; \
+ EXTRACT_CARD16 (_pBuf, _swap, _len); \
+ _string = (char *) malloc (_len + 1); \
+ memcpy (_string, _pBuf, _len); \
+ _pBuf += _len; \
+ _string[_len] = '\0'; \
+ if (PAD32 (2 + _len)) \
+ _pBuf += PAD32 (2 + _len); \
+}
+
+#define EXTRACT_LISTOF_STRING(_pBuf, _swap, _count, _strings) \
+{ \
+ int _i; \
+ for (_i = 0; _i < _count; _i++) \
+ EXTRACT_STRING (_pBuf, _swap, _strings[_i]); \
+}
+
+
+#define SKIP_STRING(_pBuf, _swap, _end, _bail) \
+{ \
+ CARD16 _len; \
+ EXTRACT_CARD16 (_pBuf, _swap, _len); \
+ _pBuf += _len + PAD32(2+_len); \
+ if (_pBuf > _end) { \
+ _bail; \
+ } \
+}
+
+#define SKIP_LISTOF_STRING(_pBuf, _swap, _count, _end, _bail) \
+{ \
+ int _i; \
+ for (_i = 0; _i < _count; _i++) \
+ SKIP_STRING (_pBuf, _swap, _end, _bail); \
+}
+
+
+
+/*
+ * Byte swapping
+ */
+
+/* byte swap a long literal */
+#define lswapl(_val) ((((_val) & 0xff) << 24) |\
+ (((_val) & 0xff00) << 8) |\
+ (((_val) & 0xff0000) >> 8) |\
+ (((_val) >> 24) & 0xff))
+
+/* byte swap a short literal */
+#define lswaps(_val) ((((_val) & 0xff) << 8) | (((_val) >> 8) & 0xff))
+
+
+
+/*
+ * ICE replies (not processed via callbacks because we block)
+ */
+
+#define ICE_CONNECTION_REPLY 1
+#define ICE_CONNECTION_ERROR 2
+#define ICE_PROTOCOL_REPLY 3
+#define ICE_PROTOCOL_ERROR 4
+
+typedef struct {
+ int type;
+ int version_index;
+ char *vendor;
+ char *release;
+} _IceConnectionReply;
+
+typedef struct {
+ int type;
+ char *error_message;
+} _IceConnectionError;
+
+typedef struct {
+ int type;
+ int major_opcode;
+ int version_index;
+ char *vendor;
+ char *release;
+} _IceProtocolReply;
+
+typedef struct {
+ int type;
+ char *error_message;
+} _IceProtocolError;
+
+
+typedef union {
+ int type;
+ _IceConnectionReply connection_reply;
+ _IceConnectionError connection_error;
+ _IceProtocolReply protocol_reply;
+ _IceProtocolError protocol_error;
+} _IceReply;
+
+
+/*
+ * Watch for ICE connection create/destroy.
+ */
+
+typedef struct _IceWatchedConnection {
+ IceConn iceConn;
+ IcePointer watch_data;
+ struct _IceWatchedConnection *next;
+} _IceWatchedConnection;
+
+typedef struct _IceWatchProc {
+ IceWatchProc watch_proc;
+ IcePointer client_data;
+ _IceWatchedConnection *watched_connections;
+ struct _IceWatchProc *next;
+} _IceWatchProc;
+
+
+/*
+ * Locking
+ */
+
+#define IceLockConn(_iceConn)
+#define IceUnlockConn(_iceConn)
+
+
+/*
+ * Extern declarations
+ */
+
+extern IceConn _IceConnectionObjs[];
+extern char *_IceConnectionStrings[];
+extern int _IceConnectionCount;
+
+extern _IceProtocol _IceProtocols[];
+extern int _IceLastMajorOpcode;
+
+extern int _IceAuthCount;
+extern char *_IceAuthNames[];
+extern IcePoAuthProc _IcePoAuthProcs[];
+extern IcePaAuthProc _IcePaAuthProcs[];
+
+extern int _IceVersionCount;
+extern _IceVersion _IceVersions[];
+
+extern _IceWatchProc *_IceWatchProcs;
+
+extern IceErrorHandler _IceErrorHandler;
+extern IceIOErrorHandler _IceIOErrorHandler;
+
+
+extern void _IceErrorBadMajor (
+ IceConn /* iceConn */,
+ int /* offendingMajor */,
+ int /* offendingMinor */,
+ int /* severity */
+);
+
+extern void _IceErrorNoAuthentication (
+ IceConn /* iceConn */,
+ int /* offendingMinor */
+);
+
+extern void _IceErrorNoVersion (
+ IceConn /* iceConn */,
+ int /* offendingMinor */
+);
+
+extern void _IceErrorSetupFailed (
+ IceConn /* iceConn */,
+ int /* offendingMinor */,
+ char * /* reason */
+);
+
+extern void _IceErrorAuthenticationRejected (
+ IceConn /* iceConn */,
+ int /* offendingMinor */,
+ char * /* reason */
+);
+
+extern void _IceErrorAuthenticationFailed (
+ IceConn /* iceConn */,
+ int /* offendingMinor */,
+ char * /* reason */
+);
+
+extern void _IceErrorProtocolDuplicate (
+ IceConn /* iceConn */,
+ char * /* protocolName */
+);
+
+extern void _IceErrorMajorOpcodeDuplicate (
+ IceConn /* iceConn */,
+ int /* majorOpcode */
+);
+
+extern void _IceErrorUnknownProtocol (
+ IceConn /* iceConn */,
+ char * /* protocolName */
+);
+
+extern void _IceAddOpcodeMapping (
+ IceConn /* iceConn */,
+ int /* hisOpcode */,
+ int /* myOpcode */
+);
+
+extern char *_IceGetPeerName (
+ IceConn /* iceConn */
+);
+
+extern void _IceFreeConnection (
+ IceConn /* iceConn */
+);
+
+extern void _IceAddReplyWait (
+ IceConn /* iceConn */,
+ IceReplyWaitInfo * /* replyWait */
+);
+
+extern IceReplyWaitInfo *_IceSearchReplyWaits (
+ IceConn /* iceConn */,
+ int /* majorOpcode */
+);
+
+extern void _IceSetReplyReady (
+ IceConn /* iceConn */,
+ IceReplyWaitInfo * /* replyWait */
+);
+
+extern Bool _IceCheckReplyReady (
+ IceConn /* iceConn */,
+ IceReplyWaitInfo * /* replyWait */
+);
+
+extern void _IceConnectionOpened (
+ IceConn /* iceConn */
+);
+
+extern void _IceConnectionClosed (
+ IceConn /* iceConn */
+);
+
+extern void _IceGetPoAuthData (
+ char * /* protocol_name */,
+ char * /* address */,
+ char * /* auth_name */,
+ unsigned short * /* auth_data_length_ret */,
+ char ** /* auth_data_ret */
+);
+
+extern void _IceGetPaAuthData (
+ char * /* protocol_name */,
+ char * /* address */,
+ char * /* auth_name */,
+ unsigned short * /* auth_data_length_ret */,
+ char ** /* auth_data_ret */
+);
+
+extern void _IceGetPoValidAuthIndices (
+ char * /* protocol_name */,
+ char * /* address */,
+ int /* num_auth_names */,
+ char ** /* auth_names */,
+ int * /* num_indices_ret */,
+ int * /* indices_ret */
+);
+
+extern void _IceGetPaValidAuthIndices (
+ char * /* protocol_name */,
+ char * /* address */,
+ int /* num_auth_names */,
+ char ** /* auth_names */,
+ int * /* num_indices_ret */,
+ int * /* indices_ret */
+);
+
+#endif /* _ICELIBINT_H_ */
diff --git a/nx-X11/lib/ICE/ICEmsg.h b/nx-X11/lib/ICE/ICEmsg.h
new file mode 100644
index 000000000..ddae02784
--- /dev/null
+++ b/nx-X11/lib/ICE/ICEmsg.h
@@ -0,0 +1,295 @@
+/* $Xorg: ICEmsg.h,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/ICEmsg.h,v 1.4 2001/12/20 19:40:59 tsi Exp $ */
+
+#ifndef _ICEMSG_H_
+#define _ICEMSG_H_
+
+#include <X11/Xfuncproto.h>
+
+#include <X11/ICE/ICEconn.h>
+
+_XFUNCPROTOBEGIN
+
+/*
+ * Function prototypes for internal ICElib functions
+ */
+
+extern Status _IceRead (
+ IceConn /* iceConn */,
+ unsigned long /* nbytes */,
+ char * /* ptr */
+);
+
+extern void _IceReadSkip (
+ IceConn /* iceConn */,
+ unsigned long /* nbytes */
+);
+
+extern void _IceWrite (
+ IceConn /* iceConn */,
+ unsigned long /* nbytes */,
+ char * /* ptr */
+);
+
+
+extern void _IceErrorBadMinor (
+ IceConn /* iceConn */,
+ int /* majorOpcode */,
+ int /* offendingMinor */,
+ int /* severity */
+);
+
+extern void _IceErrorBadState (
+ IceConn /* iceConn */,
+ int /* majorOpcode */,
+ int /* offendingMinor */,
+ int /* severity */
+);
+
+extern void _IceErrorBadLength (
+ IceConn /* iceConn */,
+ int /* majorOpcode */,
+ int /* offendingMinor */,
+ int /* severity */
+);
+
+extern void _IceErrorBadValue (
+ IceConn /* iceConn */,
+ int /* majorOpcode */,
+ int /* offendingMinor */,
+ int /* offset */,
+ int /* length */,
+ IcePointer /* value */
+);
+
+
+/*
+ * Macro to check if IO operations are valid on an ICE connection.
+ */
+
+#define IceValidIO(_iceConn) _iceConn->io_ok
+
+
+/*
+ * Macros for writing messages.
+ */
+
+#define IceGetHeader(_iceConn, _major, _minor, _headerSize, _msgType, _pMsg) \
+ if ((_iceConn->outbufptr + _headerSize) > _iceConn->outbufmax) \
+ IceFlush (_iceConn); \
+ _pMsg = (_msgType *) _iceConn->outbufptr; \
+ _pMsg->majorOpcode = _major; \
+ _pMsg->minorOpcode = _minor; \
+ _pMsg->length = (_headerSize - SIZEOF (iceMsg)) >> 3; \
+ _iceConn->outbufptr += _headerSize; \
+ _iceConn->send_sequence++
+
+#define IceGetHeaderExtra(_iceConn, _major, _minor, _headerSize, _extra, _msgType, _pMsg, _pData) \
+ if ((_iceConn->outbufptr + \
+ _headerSize + ((_extra) << 3)) > _iceConn->outbufmax) \
+ IceFlush (_iceConn); \
+ _pMsg = (_msgType *) _iceConn->outbufptr; \
+ if ((_iceConn->outbufptr + \
+ _headerSize + ((_extra) << 3)) <= _iceConn->outbufmax) \
+ _pData = (char *) _pMsg + _headerSize; \
+ else \
+ _pData = NULL; \
+ _pMsg->majorOpcode = _major; \
+ _pMsg->minorOpcode = _minor; \
+ _pMsg->length = ((_headerSize - SIZEOF (iceMsg)) >> 3) + (_extra); \
+ _iceConn->outbufptr += (_headerSize + ((_extra) << 3)); \
+ _iceConn->send_sequence++
+
+#define IceSimpleMessage(_iceConn, _major, _minor) \
+{ \
+ iceMsg *_pMsg; \
+ IceGetHeader (_iceConn, _major, _minor, SIZEOF (iceMsg), iceMsg, _pMsg); \
+}
+
+#define IceErrorHeader(_iceConn, _offendingMajorOpcode, _offendingMinorOpcode, _offendingSequenceNum, _severity, _errorClass, _dataLength) \
+{ \
+ iceErrorMsg *_pMsg; \
+\
+ IceGetHeader (_iceConn, _offendingMajorOpcode, ICE_Error, \
+ SIZEOF (iceErrorMsg), iceErrorMsg, _pMsg); \
+ _pMsg->length += (_dataLength); \
+ _pMsg->offendingMinorOpcode = _offendingMinorOpcode; \
+ _pMsg->severity = _severity; \
+ _pMsg->offendingSequenceNum = _offendingSequenceNum; \
+ _pMsg->errorClass = _errorClass; \
+}
+
+
+/*
+ * Write data into the ICE output buffer.
+ */
+
+#define IceWriteData(_iceConn, _bytes, _data) \
+{ \
+ if ((_iceConn->outbufptr + (_bytes)) > _iceConn->outbufmax) \
+ { \
+ IceFlush (_iceConn); \
+ _IceWrite (_iceConn, (unsigned long) (_bytes), _data); \
+ } \
+ else \
+ { \
+ memcpy (_iceConn->outbufptr, _data, _bytes); \
+ _iceConn->outbufptr += (_bytes); \
+ } \
+}
+
+#ifndef WORD64
+
+#define IceWriteData16(_iceConn, _bytes, _data) \
+ IceWriteData (_iceConn, _bytes, (char *) _data)
+
+#define IceWriteData32(_iceConn, _bytes, _data) \
+ IceWriteData (_iceConn, _bytes, (char *) _data)
+
+#else /* WORD64 */
+
+/* IceWriteData16 and IceWriteData32 defined in misc.c for WORD64 */
+
+#endif /* WORD64 */
+
+
+/*
+ * The IceSendData macro bypasses copying the data to the
+ * ICE connection buffer and sends the data directly. If necessary,
+ * the ICE connection buffer is first flushed.
+ */
+
+#define IceSendData(_iceConn, _bytes, _data) \
+{ \
+ if (_iceConn->outbufptr > _iceConn->outbuf) \
+ IceFlush (_iceConn); \
+ _IceWrite (_iceConn, (unsigned long) (_bytes), _data); \
+}
+
+
+/*
+ * Write pad bytes. Used to force 32 or 64 bit alignment.
+ * A maxium of 7 pad bytes can be specified.
+ */
+
+#define IceWritePad(_iceConn, _bytes) \
+{ \
+ if ((_iceConn->outbufptr + (_bytes)) > _iceConn->outbufmax) \
+ { \
+ char _dummy[7]; \
+ IceFlush (_iceConn); \
+ _IceWrite (_iceConn, (unsigned long) (_bytes), _dummy); \
+ } \
+ else \
+ { \
+ _iceConn->outbufptr += (_bytes); \
+ } \
+}
+
+
+/*
+ * Macros for reading messages.
+ */
+
+#define IceReadCompleteMessage(_iceConn, _headerSize, _msgType, _pMsg, _pData)\
+{ \
+ unsigned long _bytes; \
+ IceReadMessageHeader (_iceConn, _headerSize, _msgType, _pMsg); \
+ _bytes = (_pMsg->length << 3) - (_headerSize - SIZEOF (iceMsg)); \
+ if ((_iceConn->inbufmax - _iceConn->inbufptr) >= _bytes) \
+ { \
+ _IceRead (_iceConn, _bytes, _iceConn->inbufptr); \
+ _pData = _iceConn->inbufptr; \
+ _iceConn->inbufptr += _bytes; \
+ } \
+ else \
+ { \
+ _pData = (char *) malloc ((unsigned) _bytes); \
+ if (_pData) \
+ _IceRead (_iceConn, _bytes, _pData); \
+ else \
+ _IceReadSkip (_iceConn, _bytes); \
+ } \
+}
+
+#define IceDisposeCompleteMessage(_iceConn, _pData) \
+ if ((char *) _pData < _iceConn->inbuf || \
+ (char *) _pData >= _iceConn->inbufmax) \
+ free ((char *) _pData);
+
+
+#define IceReadSimpleMessage(_iceConn, _msgType, _pMsg) \
+ _pMsg = (_msgType *) (_iceConn->inbuf);
+
+#define IceReadMessageHeader(_iceConn, _headerSize, _msgType, _pMsg) \
+{ \
+ _IceRead (_iceConn, \
+ (unsigned long) (_headerSize - SIZEOF (iceMsg)), \
+ _iceConn->inbufptr); \
+ _pMsg = (_msgType *) (_iceConn->inbuf); \
+ _iceConn->inbufptr += (_headerSize - SIZEOF (iceMsg)); \
+}
+
+#define IceReadData(_iceConn, _bytes, _pData) \
+ _IceRead (_iceConn, (unsigned long) (_bytes), (char *) _pData); \
+
+#ifndef WORD64
+
+#define IceReadData16(_iceConn, _swap, _bytes, _pData) \
+{ \
+ _IceRead (_iceConn, (unsigned long) (_bytes), (char *) _pData); \
+}
+
+#define IceReadData32(_iceConn, _swap, _bytes, _pData) \
+{ \
+ _IceRead (_iceConn, (unsigned long) (_bytes), (char *) _pData); \
+}
+
+#else /* WORD64 */
+
+/* IceReadData16 and IceReadData32 defined in misc.c for WORD64 */
+
+#endif /* WORD64 */
+
+
+/*
+ * Read pad bytes (for 32 or 64 bit alignment).
+ * A maxium of 7 pad bytes can be specified.
+ */
+
+#define IceReadPad(_iceConn, _bytes) \
+{ \
+ char _dummy[7]; \
+ _IceRead (_iceConn, (unsigned long) (_bytes), _dummy); \
+}
+
+_XFUNCPROTOEND
+
+#endif /* _ICEMSG_H_ */
diff --git a/nx-X11/lib/ICE/ICEproto.h b/nx-X11/lib/ICE/ICEproto.h
new file mode 100644
index 000000000..9ca7c44ce
--- /dev/null
+++ b/nx-X11/lib/ICE/ICEproto.h
@@ -0,0 +1,176 @@
+/* $Xorg: ICEproto.h,v 1.5 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+
+#ifndef _ICEPROTO_H_
+#define _ICEPROTO_H_
+
+#include <X11/Xmd.h>
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 data[2];
+ CARD32 length B32;
+} iceMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD16 errorClass B16;
+ CARD32 length B32;
+ CARD8 offendingMinorOpcode;
+ CARD8 severity;
+ CARD16 unused B16;
+ CARD32 offendingSequenceNum B32;
+ /* n varying values */
+ /* p p = pad (n, 8) */
+} iceErrorMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 byteOrder;
+ CARD8 unused;
+ CARD32 length B32;
+} iceByteOrderMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 versionCount;
+ CARD8 authCount;
+ CARD32 length B32;
+ CARD8 mustAuthenticate;
+ CARD8 unused[7];
+ /* i STRING vendor */
+ /* j STRING release */
+ /* k LIST of STRING authentication-protocol-names */
+ /* m LIST of VERSION version-list */
+ /* p p = pad (i+j+k+m, 8) */
+} iceConnectionSetupMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 authIndex;
+ CARD8 unused1;
+ CARD32 length B32;
+ CARD16 authDataLength B16;
+ CARD8 unused2[6];
+ /* n varying data */
+ /* p p = pad (n, 8) */
+} iceAuthRequiredMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused1[2];
+ CARD32 length B32;
+ CARD16 authDataLength B16;
+ CARD8 unused2[6];
+ /* n varying data */
+ /* p p = pad (n, 8) */
+} iceAuthReplyMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused1[2];
+ CARD32 length B32;
+ CARD16 authDataLength B16;
+ CARD8 unused2[6];
+ /* n varying data */
+ /* p p = pad (n, 8) */
+} iceAuthNextPhaseMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 versionIndex;
+ CARD8 unused;
+ CARD32 length B32;
+ /* i STRING vendor */
+ /* j STRING release */
+ /* p p = pad (i+j, 8) */
+} iceConnectionReplyMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 protocolOpcode;
+ CARD8 mustAuthenticate;
+ CARD32 length B32;
+ CARD8 versionCount;
+ CARD8 authCount;
+ CARD8 unused[6];
+ /* i STRING protocol-name */
+ /* j STRING vendor */
+ /* k STRING release */
+ /* m LIST of STRING authentication-protocol-names */
+ /* n LIST of VERSION version-list */
+ /* p p = pad (i+j+k+m+n, 8) */
+} iceProtocolSetupMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 versionIndex;
+ CARD8 protocolOpcode;
+ CARD32 length B32;
+ /* i STRING vendor */
+ /* j STRING release */
+ /* p p = pad (i+j, 8) */
+} iceProtocolReplyMsg;
+
+typedef iceMsg icePingMsg;
+typedef iceMsg icePingReplyMsg;
+typedef iceMsg iceWantToCloseMsg;
+typedef iceMsg iceNoCloseMsg;
+
+
+/*
+ * SIZEOF values. These better be multiples of 8.
+ */
+
+#define sz_iceMsg 8
+#define sz_iceErrorMsg 16
+#define sz_iceByteOrderMsg 8
+#define sz_iceConnectionSetupMsg 16
+#define sz_iceAuthRequiredMsg 16
+#define sz_iceAuthReplyMsg 16
+#define sz_iceAuthNextPhaseMsg 16
+#define sz_iceConnectionReplyMsg 8
+#define sz_iceProtocolSetupMsg 16
+#define sz_iceProtocolReplyMsg 8
+#define sz_icePingMsg 8
+#define sz_icePingReplyMsg 8
+#define sz_iceWantToCloseMsg 8
+#define sz_iceNoCloseMsg 8
+
+#endif /* _ICEPROTO_H_ */
diff --git a/nx-X11/lib/ICE/ICEutil.h b/nx-X11/lib/ICE/ICEutil.h
new file mode 100644
index 000000000..8651d94eb
--- /dev/null
+++ b/nx-X11/lib/ICE/ICEutil.h
@@ -0,0 +1,126 @@
+/* $Xorg: ICEutil.h,v 1.5 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/ICEutil.h,v 1.4 2001/12/20 19:40:59 tsi Exp $ */
+
+#ifndef _ICEUTIL_H_
+#define _ICEUTIL_H_
+
+#include <X11/Xfuncproto.h>
+
+#include <stdio.h>
+
+_XFUNCPROTOBEGIN
+
+/*
+ * Data structure for entry in ICE authority file
+ */
+
+typedef struct {
+ char *protocol_name;
+ unsigned short protocol_data_length;
+ char *protocol_data;
+ char *network_id;
+ char *auth_name;
+ unsigned short auth_data_length;
+ char *auth_data;
+} IceAuthFileEntry;
+
+
+/*
+ * Authentication data maintained in memory.
+ */
+
+typedef struct {
+ char *protocol_name;
+ char *network_id;
+ char *auth_name;
+ unsigned short auth_data_length;
+ char *auth_data;
+} IceAuthDataEntry;
+
+
+/*
+ * Return values from IceLockAuthFile
+ */
+
+#define IceAuthLockSuccess 0 /* lock succeeded */
+#define IceAuthLockError 1 /* lock unexpectely failed, check errno */
+#define IceAuthLockTimeout 2 /* lock failed, timeouts expired */
+
+
+/*
+ * Function Prototypes
+ */
+
+extern char *IceAuthFileName (
+ void
+);
+
+extern int IceLockAuthFile (
+ char * /* file_name */,
+ int /* retries */,
+ int /* timeout */,
+ long /* dead */
+);
+
+extern void IceUnlockAuthFile (
+ char * /* file_name */
+);
+
+extern IceAuthFileEntry *IceReadAuthFileEntry (
+ FILE * /* auth_file */
+);
+
+extern void IceFreeAuthFileEntry (
+ IceAuthFileEntry * /* auth */
+);
+
+extern Status IceWriteAuthFileEntry (
+ FILE * /* auth_file */,
+ IceAuthFileEntry * /* auth */
+);
+
+extern IceAuthFileEntry *IceGetAuthFileEntry (
+ char * /* protocol_name */,
+ char * /* network_id */,
+ char * /* auth_name */
+);
+
+extern char *IceGenerateMagicCookie (
+ int /* len */
+);
+
+extern void IceSetPaAuthData (
+ int /* numEntries */,
+ IceAuthDataEntry * /* entries */
+);
+
+_XFUNCPROTOEND
+
+#endif /* _ICEUTIL_H_ */
diff --git a/nx-X11/lib/ICE/Imakefile b/nx-X11/lib/ICE/Imakefile
new file mode 100644
index 000000000..0dce0c7b4
--- /dev/null
+++ b/nx-X11/lib/ICE/Imakefile
@@ -0,0 +1,92 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:44:11 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/ICE/Imakefile,v 3.5 2001/04/23 16:17:06 tsi Exp $
+
+#define DoNormalLib NormalLibICE
+#define DoSharedLib SharedLibICE
+#define DoExtraLib SharedLibICE
+#define DoDebugLib DebugLibICE
+#define DoProfileLib ProfileLibICE
+#define LibName ICE
+#define SoRev SOICEREV
+#define IncSubdir X11
+#define IncSubSubdir ICE
+
+#ifdef SharedICEReqs
+REQUIREDLIBS = SharedICEReqs
+#endif
+
+#if (SystemV || SystemV4) && !HasSockets
+CONN_DEFINES = -DTCPCONN -DICE_t -DTRANS_CLIENT -DTRANS_SERVER $(XTRANS_FAILDEFINES)
+#else
+CONN_DEFINES = $(CONNECTION_FLAGS) -DICE_t -DTRANS_CLIENT -DTRANS_SERVER $(XTRANS_FAILDEFINES)
+#endif
+
+#if HasBSD44Sockets
+SOCK_DEFINES = -DBSD44SOCKETS
+#endif
+
+DEPEND_DEFINES = $(TRANS_INCLUDES) $(CONN_DEFINES) DependDefines
+
+HEADERS = ICE.h \
+ ICEconn.h \
+ ICEproto.h \
+ ICElib.h \
+ ICEmsg.h \
+ ICEutil.h
+
+SRCS = accept.c \
+ authutil.c \
+ connect.c \
+ error.c \
+ getauth.c \
+ iceauth.c \
+ listen.c \
+ listenwk.c \
+ locking.c \
+ misc.c \
+ ping.c \
+ process.c \
+ protosetup.c \
+ register.c \
+ replywait.c \
+ setauth.c \
+ shutdown.c \
+ transport.c \
+ watch.c
+
+OBJS = accept.o \
+ authutil.o \
+ connect.o \
+ error.o \
+ getauth.o \
+ iceauth.o \
+ listen.o \
+ listenwk.o \
+ locking.o \
+ misc.o \
+ ping.o \
+ process.o \
+ protosetup.o \
+ register.o \
+ replywait.o \
+ setauth.o \
+ shutdown.o \
+ transport.o \
+ watch.o
+
+#include <Library.tmpl>
+
+SpecialCLibObjectRule(accept,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES))
+SpecialCLibObjectRule(connect,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES))
+SpecialCLibObjectRule(listen,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES))
+SpecialCLibObjectRule(listenwk,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES))
+SpecialCLibObjectRule(misc,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES))
+SpecialCLibObjectRule(shutdown,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES))
+SpecialCLibObjectRule(transport,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES))
+LinkSourceFile(transport.c,$(TRANSCOMMSRC))
+
+DependTarget()
diff --git a/nx-X11/lib/ICE/accept.c b/nx-X11/lib/ICE/accept.c
new file mode 100644
index 000000000..df2b258c5
--- /dev/null
+++ b/nx-X11/lib/ICE/accept.c
@@ -0,0 +1,188 @@
+/* $Xorg: accept.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+#include <X11/Xtrans/Xtrans.h>
+
+
+IceConn
+IceAcceptConnection (listenObj, statusRet)
+
+IceListenObj listenObj;
+IceAcceptStatus *statusRet;
+
+{
+ IceConn iceConn;
+ XtransConnInfo newconn;
+ iceByteOrderMsg *pMsg;
+ int endian, status;
+
+ /*
+ * Accept the connection.
+ */
+
+ if ((newconn = _IceTransAccept (listenObj->trans_conn, &status)) == 0)
+ {
+ if (status == TRANS_ACCEPT_BAD_MALLOC)
+ *statusRet = IceAcceptBadMalloc;
+ else
+ *statusRet = IceAcceptFailure;
+ return (NULL);
+ }
+
+
+ /*
+ * Set close-on-exec so that programs that fork() don't get confused.
+ */
+
+ _IceTransSetOption (newconn, TRANS_CLOSEONEXEC, 1);
+
+
+ /*
+ * Create an ICE object for this connection.
+ */
+
+ if ((iceConn = (IceConn) malloc (sizeof (struct _IceConn))) == NULL)
+ {
+ _IceTransClose (newconn);
+ *statusRet = IceAcceptBadMalloc;
+ return (NULL);
+ }
+
+ iceConn->listen_obj = listenObj;
+
+ iceConn->waiting_for_byteorder = True;
+ iceConn->connection_status = IceConnectPending;
+ iceConn->io_ok = True;
+ iceConn->dispatch_level = 0;
+ iceConn->context = NULL;
+ iceConn->my_ice_version_index = 0;
+
+ iceConn->trans_conn = newconn;
+ iceConn->send_sequence = 0;
+ iceConn->receive_sequence = 0;
+
+ iceConn->connection_string = (char *) malloc (
+ strlen (listenObj->network_id) + 1);
+
+ if (iceConn->connection_string == NULL)
+ {
+ _IceTransClose (newconn);
+ free ((char *) iceConn);
+ *statusRet = IceAcceptBadMalloc;
+ return (NULL);
+ }
+ else
+ strcpy (iceConn->connection_string, listenObj->network_id);
+
+ iceConn->vendor = NULL;
+ iceConn->release = NULL;
+
+ if ((iceConn->inbuf = iceConn->inbufptr =
+ (char *) malloc (ICE_INBUFSIZE)) != NULL)
+ {
+ iceConn->inbufmax = iceConn->inbuf + ICE_INBUFSIZE;
+ }
+ else
+ {
+ _IceTransClose (newconn);
+ free ((char *) iceConn);
+ *statusRet = IceAcceptBadMalloc;
+ return (NULL);
+ }
+
+ if ((iceConn->outbuf = iceConn->outbufptr =
+ (char *) malloc (ICE_OUTBUFSIZE)) != NULL)
+ {
+ iceConn->outbufmax = iceConn->outbuf + ICE_OUTBUFSIZE;
+ }
+ else
+ {
+ _IceTransClose (newconn);
+ free (iceConn->inbuf);
+ free ((char *) iceConn);
+ *statusRet = IceAcceptBadMalloc;
+ return (NULL);
+ }
+
+ iceConn->scratch = NULL;
+ iceConn->scratch_size = 0;
+
+ iceConn->open_ref_count = 1;
+ iceConn->proto_ref_count = 0;
+
+ iceConn->skip_want_to_close = False;
+ iceConn->want_to_close = False;
+ iceConn->free_asap = False;
+
+ iceConn->saved_reply_waits = NULL;
+ iceConn->ping_waits = NULL;
+
+ iceConn->process_msg_info = NULL;
+
+ iceConn->connect_to_you = NULL;
+ iceConn->protosetup_to_you = NULL;
+
+ iceConn->connect_to_me = NULL;
+ iceConn->protosetup_to_me = NULL;
+
+
+ /*
+ * Send our byte order.
+ */
+
+ IceGetHeader (iceConn, 0, ICE_ByteOrder,
+ SIZEOF (iceByteOrderMsg), iceByteOrderMsg, pMsg);
+
+ endian = 1;
+ if (*(char *) &endian)
+ pMsg->byteOrder = IceLSBfirst;
+ else
+ pMsg->byteOrder = IceMSBfirst;
+
+ IceFlush (iceConn);
+
+
+ if (_IceWatchProcs)
+ {
+ /*
+ * Notify the watch procedures that an iceConn was opened.
+ */
+
+ _IceConnectionOpened (iceConn);
+ }
+
+ *statusRet = IceAcceptSuccess;
+
+ return (iceConn);
+}
diff --git a/nx-X11/lib/ICE/authutil.c b/nx-X11/lib/ICE/authutil.c
new file mode 100644
index 000000000..7b620732e
--- /dev/null
+++ b/nx-X11/lib/ICE/authutil.c
@@ -0,0 +1,539 @@
+/* $Xorg: authutil.c,v 1.5 2001/02/09 02:03:26 xorgcvs Exp $ */
+/* $XdotOrg: xc/lib/ICE/authutil.c,v 1.4 2005/07/03 07:00:55 daniels 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: authutil.c,v 3.9 2002/05/31 18:45:41 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+#include <X11/ICE/ICEutil.h>
+#include <X11/Xos.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include <time.h>
+#define Time_t time_t
+#ifdef __UNIXOS2__
+extern char* getenv(const char*);
+#define link rename
+#endif
+#ifndef X_NOT_POSIX
+#include <unistd.h>
+#else
+#ifndef WIN32
+extern unsigned sleep ();
+#else
+#define link rename
+#endif
+#endif
+
+static Status read_short ();
+static Status read_string ();
+static Status read_counted_string ();
+static Status write_short ();
+static Status write_string ();
+static Status write_counted_string ();
+
+
+
+/*
+ * The following routines are for manipulating the .ICEauthority file
+ * These are utility functions - they are not part of the standard
+ * ICE library specification.
+ */
+
+char *
+IceAuthFileName ()
+
+{
+ static char slashDotICEauthority[] = "/.ICEauthority";
+ char *name;
+ static char *buf;
+ static int bsize;
+ int size;
+#if defined(WIN32) || defined(__UNIXOS2__)
+#ifndef PATH_MAX
+#define PATH_MAX 512
+#endif
+ char dir[PATH_MAX];
+#endif
+
+ if ((name = getenv ("ICEAUTHORITY")))
+ return (name);
+
+ name = getenv ("HOME");
+
+ if (!name)
+ {
+#ifdef WIN32
+ register char *ptr1;
+ register char *ptr2;
+ int len1 = 0, len2 = 0;
+
+ 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) < PATH_MAX) {
+ sprintf (dir, "%s%s", ptr1, (ptr2) ? ptr2 : "");
+ name = dir;
+ }
+ if (!name)
+#endif
+#ifdef __UNIXOS2__
+ strcpy (dir,"c:");
+ name = dir;
+ if (!name)
+#endif
+ return (NULL);
+ }
+
+ size = strlen (name) + strlen (&slashDotICEauthority[1]) + 2;
+
+ if (size > bsize)
+ {
+ if (buf)
+ free (buf);
+ buf = malloc ((unsigned) size);
+ if (!buf)
+ return (NULL);
+ bsize = size;
+ }
+
+ strcpy (buf, name);
+ strcat (buf, slashDotICEauthority + (name[1] == '\0' ? 1 : 0));
+
+ return (buf);
+}
+
+
+
+int
+IceLockAuthFile (file_name, retries, timeout, dead)
+
+char *file_name;
+int retries;
+int timeout;
+long dead;
+
+{
+ char creat_name[1025], link_name[1025];
+ struct stat statb;
+ Time_t now;
+ int creat_fd = -1;
+
+ if ((int) strlen (file_name) > 1022)
+ return (IceAuthLockError);
+
+ strcpy (creat_name, file_name);
+ strcat (creat_name, "-c");
+ strcpy (link_name, file_name);
+ strcat (link_name, "-l");
+
+ if (stat (creat_name, &statb) != -1)
+ {
+ now = time ((Time_t *) 0);
+
+ /*
+ * NFS may cause ctime to be before now, special
+ * case a 0 deadtime to force lock removal
+ */
+
+ if (dead == 0 || now - statb.st_ctime > dead)
+ {
+ unlink (creat_name);
+ unlink (link_name);
+ }
+ }
+
+ while (retries > 0)
+ {
+ if (creat_fd == -1)
+ {
+ creat_fd = creat (creat_name, 0666);
+
+ if (creat_fd == -1)
+ {
+ if (errno != EACCES)
+ return (IceAuthLockError);
+ }
+ else
+ close (creat_fd);
+ }
+
+ if (creat_fd != -1)
+ {
+ if (link (creat_name, link_name) != -1)
+ return (IceAuthLockSuccess);
+
+ if (errno == ENOENT)
+ {
+ creat_fd = -1; /* force re-creat next time around */
+ continue;
+ }
+
+ if (errno != EEXIST)
+ return (IceAuthLockError);
+ }
+
+ sleep ((unsigned) timeout);
+ --retries;
+ }
+
+ return (IceAuthLockTimeout);
+}
+
+
+
+void
+IceUnlockAuthFile (file_name)
+
+char *file_name;
+
+{
+#ifndef WIN32
+ char creat_name[1025];
+#endif
+ char link_name[1025];
+
+ if ((int) strlen (file_name) > 1022)
+ return;
+
+#ifndef WIN32
+ strcpy (creat_name, file_name);
+ strcat (creat_name, "-c");
+#endif
+ strcpy (link_name, file_name);
+ strcat (link_name, "-l");
+
+#ifndef WIN32
+ unlink (creat_name);
+#endif
+ unlink (link_name);
+}
+
+
+
+IceAuthFileEntry *
+IceReadAuthFileEntry (auth_file)
+
+FILE *auth_file;
+
+{
+ IceAuthFileEntry local;
+ IceAuthFileEntry *ret;
+
+ local.protocol_name = NULL;
+ local.protocol_data = NULL;
+ local.network_id = NULL;
+ local.auth_name = NULL;
+ local.auth_data = NULL;
+
+ if (!read_string (auth_file, &local.protocol_name))
+ return (NULL);
+
+ if (!read_counted_string (auth_file,
+ &local.protocol_data_length, &local.protocol_data))
+ goto bad;
+
+ if (!read_string (auth_file, &local.network_id))
+ goto bad;
+
+ if (!read_string (auth_file, &local.auth_name))
+ goto bad;
+
+ if (!read_counted_string (auth_file,
+ &local.auth_data_length, &local.auth_data))
+ goto bad;
+
+ if (!(ret = (IceAuthFileEntry *) malloc (sizeof (IceAuthFileEntry))))
+ goto bad;
+
+ *ret = local;
+
+ return (ret);
+
+ bad:
+
+ if (local.protocol_name) free (local.protocol_name);
+ if (local.protocol_data) free (local.protocol_data);
+ if (local.network_id) free (local.network_id);
+ if (local.auth_name) free (local.auth_name);
+ if (local.auth_data) free (local.auth_data);
+
+ return (NULL);
+}
+
+
+
+void
+IceFreeAuthFileEntry (auth)
+
+IceAuthFileEntry *auth;
+
+{
+ if (auth)
+ {
+ if (auth->protocol_name) free (auth->protocol_name);
+ if (auth->protocol_data) free (auth->protocol_data);
+ if (auth->network_id) free (auth->network_id);
+ if (auth->auth_name) free (auth->auth_name);
+ if (auth->auth_data) free (auth->auth_data);
+ free ((char *) auth);
+ }
+}
+
+
+
+Status
+IceWriteAuthFileEntry (auth_file, auth)
+
+FILE *auth_file;
+IceAuthFileEntry *auth;
+
+{
+ if (!write_string (auth_file, auth->protocol_name))
+ return (0);
+
+ if (!write_counted_string (auth_file,
+ auth->protocol_data_length, auth->protocol_data))
+ return (0);
+
+ if (!write_string (auth_file, auth->network_id))
+ return (0);
+
+ if (!write_string (auth_file, auth->auth_name))
+ return (0);
+
+ if (!write_counted_string (auth_file,
+ auth->auth_data_length, auth->auth_data))
+ return (0);
+
+ return (1);
+}
+
+
+
+IceAuthFileEntry *
+IceGetAuthFileEntry (protocol_name, network_id, auth_name)
+
+char *protocol_name;
+char *network_id;
+char *auth_name;
+
+{
+ FILE *auth_file;
+ char *filename;
+ IceAuthFileEntry *entry;
+
+ if (!(filename = IceAuthFileName ()))
+ return (NULL);
+
+ if (access (filename, R_OK) != 0) /* checks REAL id */
+ return (NULL);
+
+ if (!(auth_file = fopen (filename, "rb")))
+ return (NULL);
+
+ for (;;)
+ {
+ if (!(entry = IceReadAuthFileEntry (auth_file)))
+ break;
+
+ if (strcmp (protocol_name, entry->protocol_name) == 0 &&
+ strcmp (network_id, entry->network_id) == 0 &&
+ strcmp (auth_name, entry->auth_name) == 0)
+ {
+ break;
+ }
+
+ IceFreeAuthFileEntry (entry);
+ }
+
+ fclose (auth_file);
+
+ return (entry);
+}
+
+
+
+/*
+ * local routines
+ */
+
+static Status
+read_short (file, shortp)
+
+FILE *file;
+unsigned short *shortp;
+
+{
+ unsigned char file_short[2];
+
+ if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1)
+ return (0);
+
+ *shortp = file_short[0] * 256 + file_short[1];
+ return (1);
+}
+
+
+static Status
+read_string (file, stringp)
+
+FILE *file;
+char **stringp;
+
+{
+ unsigned short len;
+ char *data;
+
+ if (!read_short (file, &len))
+ return (0);
+
+ data = malloc ((unsigned) len + 1);
+
+ if (!data)
+ return (0);
+
+ if (len != 0)
+ {
+ if (fread (data, (int) sizeof (char), (int) len, file) != len)
+ {
+ free (data);
+ return (0);
+ }
+
+ }
+ data[len] = '\0';
+
+ *stringp = data;
+
+ return (1);
+}
+
+
+static Status
+read_counted_string (file, countp, stringp)
+
+FILE *file;
+unsigned short *countp;
+char **stringp;
+
+{
+ unsigned short len;
+ char *data;
+
+ if (!read_short (file, &len))
+ return (0);
+
+ if (len == 0)
+ {
+ data = 0;
+ }
+ else
+ {
+ data = malloc ((unsigned) len);
+
+ if (!data)
+ return (0);
+
+ if (fread (data, (int) sizeof (char), (int) len, file) != len)
+ {
+ free (data);
+ return (0);
+ }
+ }
+
+ *stringp = data;
+ *countp = len;
+
+ return (1);
+}
+
+
+static Status
+write_short (file, s)
+
+FILE *file;
+unsigned short s;
+
+{
+ unsigned char file_short[2];
+
+ file_short[0] = (s & (unsigned) 0xff00) >> 8;
+ file_short[1] = s & 0xff;
+
+ if (fwrite ((char *) file_short, (int) sizeof (file_short), 1, file) != 1)
+ return (0);
+
+ return (1);
+}
+
+
+static Status
+write_string (file, string)
+
+FILE *file;
+char *string;
+
+{
+ unsigned short count = strlen (string);
+
+ if (!write_short (file, count))
+ return (0);
+
+ if (fwrite (string, (int) sizeof (char), (int) count, file) != count)
+ return (0);
+
+ return (1);
+}
+
+
+static Status
+write_counted_string (file, count, string)
+
+FILE *file;
+unsigned short count;
+char *string;
+
+{
+ if (!write_short (file, count))
+ return (0);
+
+ if (fwrite (string, (int) sizeof (char), (int) count, file) != count)
+ return (0);
+
+ return (1);
+}
diff --git a/nx-X11/lib/ICE/connect.c b/nx-X11/lib/ICE/connect.c
new file mode 100644
index 000000000..e06aa04bc
--- /dev/null
+++ b/nx-X11/lib/ICE/connect.c
@@ -0,0 +1,543 @@
+/* $Xorg: connect.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/connect.c,v 3.9 2001/12/14 19:53:35 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+#include <X11/Xtrans/Xtrans.h>
+#include "globals.h"
+
+static XtransConnInfo ConnectToPeer();
+
+#define Strstr strstr
+
+IceConn
+IceOpenConnection (networkIdsList, context, mustAuthenticate, majorOpcodeCheck,
+ errorLength, errorStringRet)
+
+char *networkIdsList;
+IcePointer context;
+Bool mustAuthenticate;
+int majorOpcodeCheck;
+int errorLength;
+char *errorStringRet;
+
+{
+ IceConn iceConn;
+ int extra, i, j;
+ int endian;
+ Bool gotReply, ioErrorOccured;
+ unsigned long setup_sequence;
+ iceByteOrderMsg *pByteOrderMsg;
+ iceConnectionSetupMsg *pSetupMsg;
+ char *pData;
+ IceReplyWaitInfo replyWait;
+ _IceReply reply;
+ int authUsableCount;
+ int authUsableFlags[MAX_ICE_AUTH_NAMES];
+ int authIndices[MAX_ICE_AUTH_NAMES];
+
+ if (errorStringRet && errorLength > 0)
+ *errorStringRet = '\0';
+
+ if (networkIdsList == NULL || *networkIdsList == '\0')
+ {
+ strncpy (errorStringRet,
+ "networkIdsList argument is NULL", errorLength);
+ return (NULL);
+ }
+
+ /*
+ * Check to see if we can use a previously created ICE connection.
+ *
+ * If iceConn->want_to_close is True, or iceConn->free_asap is True,
+ * we can not use the iceConn.
+ *
+ * If 'context' is non-NULL, we will only use a previously opened ICE
+ * connection if the specified 'context' is equal to the context
+ * associated with the ICE connection, or if the context associated
+ * with the ICE connection is NULL.
+ *
+ * If 'majorOpcodeCheck' is non-zero, it will contain a protocol major
+ * opcode that we should make sure is not already active on the ICE
+ * connection. Some clients will want two seperate connections for the
+ * same protocol to the same destination client.
+ */
+
+ for (i = 0; i < _IceConnectionCount; i++)
+ {
+ char *strptr;
+ if ((strptr = (char *) Strstr (
+ networkIdsList, _IceConnectionStrings[i])) != NULL)
+ {
+ char ch = *(strptr + strlen (_IceConnectionStrings[i]));
+ if (ch == ',' || ch == '\0')
+ {
+ /*
+ * OK, we found a connection. Make sure we can reuse it.
+ */
+
+ IceConn iceConn = _IceConnectionObjs[i];
+
+ if (iceConn->want_to_close || iceConn->free_asap ||
+ (context && iceConn->context &&
+ iceConn->context != context))
+ {
+ /* force a new connection to be created */
+ break;
+ }
+
+ if (majorOpcodeCheck)
+ {
+ for (j = iceConn->his_min_opcode;
+ j <= iceConn->his_max_opcode; j++)
+ {
+ if (iceConn->process_msg_info[
+ j - iceConn->his_min_opcode].in_use &&
+ iceConn->process_msg_info[
+ j - iceConn->his_min_opcode].my_opcode ==
+ majorOpcodeCheck)
+ break;
+ }
+
+ if (j <= iceConn->his_max_opcode ||
+ (iceConn->protosetup_to_you &&
+ iceConn->protosetup_to_you->my_opcode ==
+ majorOpcodeCheck))
+ {
+ /* force a new connection to be created */
+ break;
+ }
+ }
+
+ iceConn->open_ref_count++;
+ if (context && !iceConn->context)
+ iceConn->context = context;
+ return (iceConn);
+ }
+ }
+ }
+
+ if ((iceConn = (IceConn) malloc (sizeof (struct _IceConn))) == NULL)
+ {
+ strncpy (errorStringRet, "Can't malloc", errorLength);
+ return (NULL);
+ }
+
+
+ /*
+ * Open a network connection with the peer client.
+ */
+
+ if ((iceConn->trans_conn = ConnectToPeer (networkIdsList,
+ &iceConn->connection_string)) == NULL)
+ {
+ free ((char *) iceConn);
+ strncpy (errorStringRet, "Could not open network socket", errorLength);
+ return (NULL);
+ }
+
+ /*
+ * Set close-on-exec so that programs that fork() don't get confused.
+ */
+
+ _IceTransSetOption (iceConn->trans_conn, TRANS_CLOSEONEXEC, 1);
+
+ iceConn->listen_obj = NULL;
+
+ iceConn->connection_status = IceConnectPending;
+ iceConn->io_ok = True;
+ iceConn->dispatch_level = 0;
+ iceConn->context = context;
+ iceConn->my_ice_version_index = 0;
+ iceConn->send_sequence = 0;
+ iceConn->receive_sequence = 0;
+
+ iceConn->vendor = NULL;
+ iceConn->release = NULL;
+ iceConn->outbuf = NULL;
+
+ iceConn->scratch = NULL;
+ iceConn->scratch_size = 0;
+
+ iceConn->process_msg_info = NULL;
+
+ iceConn->connect_to_you = NULL;
+ iceConn->protosetup_to_you = NULL;
+
+ iceConn->connect_to_me = NULL;
+ iceConn->protosetup_to_me = NULL;
+
+ if ((iceConn->inbuf = iceConn->inbufptr =
+ (char *) malloc (ICE_INBUFSIZE)) == NULL)
+ {
+ _IceFreeConnection (iceConn);
+ strncpy (errorStringRet, "Can't malloc", errorLength);
+ return (NULL);
+ }
+
+ iceConn->inbufmax = iceConn->inbuf + ICE_INBUFSIZE;
+
+ if ((iceConn->outbuf = iceConn->outbufptr =
+ (char *) calloc (1, ICE_OUTBUFSIZE)) == NULL)
+ {
+ _IceFreeConnection (iceConn);
+ strncpy (errorStringRet, "Can't malloc", errorLength);
+ return (NULL);
+ }
+
+ iceConn->outbufmax = iceConn->outbuf + ICE_OUTBUFSIZE;
+
+ iceConn->open_ref_count = 1;
+ iceConn->proto_ref_count = 0;
+
+ iceConn->skip_want_to_close = False;
+ iceConn->want_to_close = False;
+ iceConn->free_asap = False;
+
+ iceConn->saved_reply_waits = NULL;
+ iceConn->ping_waits = NULL;
+
+ iceConn->connect_to_you = (_IceConnectToYouInfo *) malloc (
+ sizeof (_IceConnectToYouInfo));
+ iceConn->connect_to_you->auth_active = 0;
+
+ /*
+ * Send our byte order.
+ */
+
+ IceGetHeader (iceConn, 0, ICE_ByteOrder,
+ SIZEOF (iceByteOrderMsg), iceByteOrderMsg, pByteOrderMsg);
+
+ endian = 1;
+ if (*(char *) &endian)
+ pByteOrderMsg->byteOrder = IceLSBfirst;
+ else
+ pByteOrderMsg->byteOrder = IceMSBfirst;
+
+ IceFlush (iceConn);
+
+
+ /*
+ * Now read the ByteOrder message from the other client.
+ * iceConn->swap should be set to the appropriate boolean
+ * value after the call to IceProcessMessages.
+ */
+
+ iceConn->waiting_for_byteorder = True;
+
+ ioErrorOccured = False;
+ while (iceConn->waiting_for_byteorder == True && !ioErrorOccured)
+ {
+ ioErrorOccured = (IceProcessMessages (
+ iceConn, NULL, NULL) == IceProcessMessagesIOError);
+ }
+
+ if (ioErrorOccured)
+ {
+ _IceFreeConnection (iceConn);
+ strncpy (errorStringRet, "IO error occured opening connection",
+ errorLength);
+ return (NULL);
+ }
+
+ if (iceConn->connection_status == IceConnectRejected)
+ {
+ /*
+ * We failed to get the required ByteOrder message.
+ */
+
+ _IceFreeConnection (iceConn);
+ strncpy (errorStringRet,
+ "Internal error - did not receive the expected ByteOrder message",
+ errorLength);
+ return (NULL);
+ }
+
+
+ /*
+ * Determine which authentication methods are available for
+ * the Connection Setup authentication.
+ */
+
+ _IceGetPoValidAuthIndices (
+ "ICE", iceConn->connection_string,
+ _IceAuthCount, _IceAuthNames, &authUsableCount, authIndices);
+
+ for (i = 0; i < _IceAuthCount; i++)
+ {
+ authUsableFlags[i] = 0;
+ for (j = 0; j < authUsableCount && !authUsableFlags[i]; j++)
+ authUsableFlags[i] = (authIndices[j] == i);
+ }
+
+
+ /*
+ * Now send a Connection Setup message.
+ */
+
+ extra = STRING_BYTES (IceVendorString) + STRING_BYTES (IceReleaseString);
+
+ for (i = 0; i < _IceAuthCount; i++)
+ if (authUsableFlags[i])
+ {
+ extra += STRING_BYTES (_IceAuthNames[i]);
+ }
+
+ extra += (_IceVersionCount * 4);
+
+ IceGetHeaderExtra (iceConn, 0, ICE_ConnectionSetup,
+ SIZEOF (iceConnectionSetupMsg), WORD64COUNT (extra),
+ iceConnectionSetupMsg, pSetupMsg, pData);
+
+ setup_sequence = iceConn->send_sequence;
+
+ pSetupMsg->versionCount = _IceVersionCount;
+ pSetupMsg->authCount = authUsableCount;
+ pSetupMsg->mustAuthenticate = mustAuthenticate;
+
+ STORE_STRING (pData, IceVendorString);
+ STORE_STRING (pData, IceReleaseString);
+
+ for (i = 0; i < _IceAuthCount; i++)
+ if (authUsableFlags[i])
+ {
+ STORE_STRING (pData, _IceAuthNames[i]);
+ }
+
+ for (i = 0; i < _IceVersionCount; i++)
+ {
+ STORE_CARD16 (pData, _IceVersions[i].major_version);
+ STORE_CARD16 (pData, _IceVersions[i].minor_version);
+ }
+
+ IceFlush (iceConn);
+
+
+ /*
+ * Process messages until we get a Connection Reply or an Error Message.
+ * Authentication will take place behind the scenes.
+ */
+
+ replyWait.sequence_of_request = setup_sequence;
+ replyWait.major_opcode_of_request = 0;
+ replyWait.minor_opcode_of_request = ICE_ConnectionSetup;
+ replyWait.reply = (IcePointer) &reply;
+
+ gotReply = False;
+ ioErrorOccured = False;
+
+ while (!gotReply && !ioErrorOccured)
+ {
+ ioErrorOccured = (IceProcessMessages (
+ iceConn, &replyWait, &gotReply) == IceProcessMessagesIOError);
+
+ if (ioErrorOccured)
+ {
+ strncpy (errorStringRet, "IO error occured opening connection",
+ errorLength);
+ _IceFreeConnection (iceConn);
+ iceConn = NULL;
+ }
+ else if (gotReply)
+ {
+ if (reply.type == ICE_CONNECTION_REPLY)
+ {
+ if (reply.connection_reply.version_index >= _IceVersionCount)
+ {
+ strncpy (errorStringRet,
+ "Got a bad version index in the Connection Reply",
+ errorLength);
+
+ free (reply.connection_reply.vendor);
+ free (reply.connection_reply.release);
+ _IceFreeConnection (iceConn);
+ iceConn = NULL;
+ }
+ else
+ {
+ iceConn->my_ice_version_index =
+ reply.connection_reply.version_index;
+ iceConn->vendor = reply.connection_reply.vendor;
+ iceConn->release = reply.connection_reply.release;
+
+ _IceConnectionObjs[_IceConnectionCount] = iceConn;
+ _IceConnectionStrings[_IceConnectionCount] =
+ iceConn->connection_string;
+ _IceConnectionCount++;
+
+ free ((char *) iceConn->connect_to_you);
+ iceConn->connect_to_you = NULL;
+
+ iceConn->connection_status = IceConnectAccepted;
+ }
+ }
+ else /* reply.type == ICE_CONNECTION_ERROR */
+ {
+ /* Connection failed */
+
+ strncpy (errorStringRet, reply.connection_error.error_message,
+ errorLength);
+
+ free (reply.connection_error.error_message);
+
+ _IceFreeConnection (iceConn);
+ iceConn = NULL;
+ }
+ }
+ }
+
+ if (iceConn && _IceWatchProcs)
+ {
+ /*
+ * Notify the watch procedures that an iceConn was opened.
+ */
+
+ _IceConnectionOpened (iceConn);
+ }
+
+ return (iceConn);
+}
+
+
+
+IcePointer
+IceGetConnectionContext (iceConn)
+
+IceConn iceConn;
+
+{
+ return (iceConn->context);
+}
+
+
+
+/* ------------------------------------------------------------------------- *
+ * local routines *
+ * ------------------------------------------------------------------------- */
+
+#define ICE_CONNECTION_RETRIES 5
+
+
+static XtransConnInfo
+ConnectToPeer (networkIdsList, actualConnectionRet)
+
+char *networkIdsList;
+char **actualConnectionRet;
+
+{
+ char addrbuf[256];
+ char* address;
+ char *ptr, *endptr, *delim;
+ int madeConnection = 0;
+ int len, retry;
+ int connect_stat;
+ int address_size;
+ XtransConnInfo trans_conn = NULL;
+
+ *actualConnectionRet = NULL;
+
+ ptr = networkIdsList;
+ len = strlen (networkIdsList);
+ endptr = networkIdsList + len;
+
+ if (len < sizeof addrbuf)
+ {
+ address = addrbuf;
+ address_size = 256;
+ }
+ else
+ {
+ address = malloc (len + 1);
+ address_size = len;
+ }
+
+ while (ptr < endptr && !madeConnection)
+ {
+ if ((delim = (char *) strchr (ptr, ',')) == NULL)
+ delim = endptr;
+
+ len = delim - ptr;
+ if (len > address_size - 1)
+ len = address_size - 1;
+ strncpy (address, ptr, len);
+ address[len] = '\0';
+
+ ptr = delim + 1;
+
+ for (retry = ICE_CONNECTION_RETRIES; retry >= 0; retry--)
+ {
+ if ((trans_conn = _IceTransOpenCOTSClient (address)) == NULL)
+ {
+ break;
+ }
+
+ if ((connect_stat = _IceTransConnect (trans_conn, address)) < 0)
+ {
+ _IceTransClose (trans_conn);
+
+ if (connect_stat == TRANS_TRY_CONNECT_AGAIN)
+ {
+ sleep(1);
+ continue;
+ }
+ else
+ break;
+ }
+ else
+ {
+ madeConnection = 1;
+ break;
+ }
+ }
+ }
+
+ if (madeConnection)
+ {
+ /*
+ * We need to return the actual network connection string
+ */
+
+ *actualConnectionRet = (char *) malloc (strlen (address) + 1);
+ strcpy (*actualConnectionRet, address);
+
+
+ /*
+ * Return the file descriptor
+ */
+ }
+ else trans_conn = NULL;
+
+ if (address != addrbuf) free (address);
+
+ return trans_conn;
+}
diff --git a/nx-X11/lib/ICE/error.c b/nx-X11/lib/ICE/error.c
new file mode 100644
index 000000000..49b164bcc
--- /dev/null
+++ b/nx-X11/lib/ICE/error.c
@@ -0,0 +1,641 @@
+/* $Xorg: error.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/error.c,v 1.5 2001/10/28 03:32:28 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+#include <stdio.h>
+
+#include <errno.h>
+
+
+void
+_IceErrorBadMinor (iceConn, majorOpcode, offendingMinor, severity)
+
+IceConn iceConn;
+int majorOpcode;
+int offendingMinor;
+int severity;
+
+{
+ IceErrorHeader (iceConn,
+ majorOpcode, offendingMinor,
+ iceConn->receive_sequence,
+ severity,
+ IceBadMinor,
+ 0);
+
+ IceFlush (iceConn);
+}
+
+
+void
+_IceErrorBadState (iceConn, majorOpcode, offendingMinor, severity)
+
+IceConn iceConn;
+int majorOpcode;
+int offendingMinor;
+int severity;
+
+{
+ IceErrorHeader (iceConn,
+ majorOpcode, offendingMinor,
+ iceConn->receive_sequence,
+ severity,
+ IceBadState,
+ 0);
+
+ IceFlush (iceConn);
+}
+
+
+void
+_IceErrorBadLength (iceConn, majorOpcode, offendingMinor, severity)
+
+IceConn iceConn;
+int majorOpcode;
+int offendingMinor;
+int severity;
+
+{
+ IceErrorHeader (iceConn,
+ majorOpcode, offendingMinor,
+ iceConn->receive_sequence,
+ severity,
+ IceBadLength,
+ 0);
+
+ IceFlush (iceConn);
+}
+
+
+void
+_IceErrorBadValue (iceConn, majorOpcode, offendingMinor, offset, length, value)
+
+IceConn iceConn;
+int majorOpcode;
+int offendingMinor;
+int offset;
+int length; /* in bytes */
+IcePointer value;
+
+{
+ IceErrorHeader (iceConn,
+ majorOpcode, offendingMinor,
+ iceConn->receive_sequence,
+ IceCanContinue,
+ IceBadValue,
+ WORD64COUNT (8 + length));
+
+ IceWriteData32 (iceConn, 4, &offset);
+ IceWriteData32 (iceConn, 4, &length);
+ IceWriteData (iceConn, length, (char *) value);
+
+ if (PAD64 (length))
+ IceWritePad (iceConn, PAD64 (length));
+
+ IceFlush (iceConn);
+}
+
+
+void
+_IceErrorNoAuthentication (iceConn, offendingMinor)
+
+IceConn iceConn;
+int offendingMinor;
+
+{
+ int severity = (offendingMinor == ICE_ConnectionSetup) ?
+ IceFatalToConnection : IceFatalToProtocol;
+
+ IceErrorHeader (iceConn,
+ 0, offendingMinor,
+ iceConn->receive_sequence,
+ severity,
+ IceNoAuth,
+ 0);
+
+ IceFlush (iceConn);
+}
+
+
+void
+_IceErrorNoVersion (iceConn, offendingMinor)
+
+IceConn iceConn;
+int offendingMinor;
+
+{
+ int severity = (offendingMinor == ICE_ConnectionSetup) ?
+ IceFatalToConnection : IceFatalToProtocol;
+
+ IceErrorHeader (iceConn,
+ 0, offendingMinor,
+ iceConn->receive_sequence,
+ severity,
+ IceNoVersion,
+ 0);
+
+ IceFlush (iceConn);
+}
+
+
+void
+_IceErrorSetupFailed (iceConn, offendingMinor, reason)
+
+IceConn iceConn;
+int offendingMinor;
+char *reason;
+
+{
+ char *pBuf, *pStart;
+ int bytes;
+ int severity = (offendingMinor == ICE_ConnectionSetup) ?
+ IceFatalToConnection : IceFatalToProtocol;
+
+ if (!reason)
+ reason = "";
+ bytes = STRING_BYTES (reason);
+
+ IceErrorHeader (iceConn,
+ 0, offendingMinor,
+ iceConn->receive_sequence,
+ severity,
+ IceSetupFailed,
+ WORD64COUNT (bytes));
+
+ pBuf = pStart = IceAllocScratch (iceConn, PADDED_BYTES64 (bytes));
+ STORE_STRING (pBuf, reason);
+
+ IceWriteData (iceConn, PADDED_BYTES64 (bytes), pStart);
+ IceFlush (iceConn);
+}
+
+
+void
+_IceErrorAuthenticationRejected (iceConn, offendingMinor, reason)
+
+IceConn iceConn;
+int offendingMinor;
+char *reason;
+
+{
+ char *pBuf, *pStart;
+ int bytes;
+
+ if (!reason)
+ reason = "";
+ bytes = STRING_BYTES (reason);
+
+ IceErrorHeader (iceConn,
+ 0, offendingMinor,
+ iceConn->receive_sequence,
+ IceFatalToProtocol,
+ IceAuthRejected,
+ WORD64COUNT (bytes));
+
+ pBuf = pStart = IceAllocScratch (iceConn, PADDED_BYTES64 (bytes));
+ STORE_STRING (pBuf, reason);
+
+ IceWriteData (iceConn, PADDED_BYTES64 (bytes), pStart);
+ IceFlush (iceConn);
+}
+
+
+void
+_IceErrorAuthenticationFailed (iceConn, offendingMinor, reason)
+
+IceConn iceConn;
+int offendingMinor;
+char *reason;
+
+{
+ char *pBuf, *pStart;
+ int bytes;
+
+ if (!reason)
+ reason = "";
+ bytes = STRING_BYTES (reason);
+
+ IceErrorHeader (iceConn,
+ 0, offendingMinor,
+ iceConn->receive_sequence,
+ IceFatalToProtocol,
+ IceAuthFailed,
+ WORD64COUNT (bytes));
+
+ pBuf = pStart = IceAllocScratch (iceConn, PADDED_BYTES64 (bytes));
+ STORE_STRING (pBuf, reason);
+
+ IceWriteData (iceConn, PADDED_BYTES64 (bytes), pStart);
+ IceFlush (iceConn);
+}
+
+
+void
+_IceErrorProtocolDuplicate (iceConn, protocolName)
+
+IceConn iceConn;
+char *protocolName;
+
+{
+ char *pBuf, *pStart;
+ int bytes;
+
+ if (!protocolName)
+ protocolName = "";
+ bytes = STRING_BYTES (protocolName);
+
+ IceErrorHeader (iceConn,
+ 0, ICE_ProtocolSetup,
+ iceConn->receive_sequence,
+ IceFatalToProtocol,
+ IceProtocolDuplicate,
+ WORD64COUNT (bytes));
+
+ pBuf = pStart = IceAllocScratch (iceConn, PADDED_BYTES64 (bytes));
+ STORE_STRING (pBuf, protocolName);
+
+ IceWriteData (iceConn, PADDED_BYTES64 (bytes), pStart);
+ IceFlush (iceConn);
+}
+
+
+void
+_IceErrorMajorOpcodeDuplicate (iceConn, majorOpcode)
+
+IceConn iceConn;
+int majorOpcode;
+
+{
+ char mOp = (char) majorOpcode;
+
+ IceErrorHeader (iceConn,
+ 0, ICE_ProtocolSetup,
+ iceConn->receive_sequence,
+ IceFatalToProtocol,
+ IceMajorOpcodeDuplicate,
+ 1 /* length */);
+
+ IceWriteData (iceConn, 8, &mOp);
+ IceFlush (iceConn);
+}
+
+
+void
+_IceErrorUnknownProtocol (iceConn, protocolName)
+
+IceConn iceConn;
+char *protocolName;
+
+{
+ char *pBuf, *pStart;
+ int bytes;
+
+ if (!protocolName)
+ protocolName = "";
+ bytes = STRING_BYTES (protocolName);
+
+ IceErrorHeader (iceConn,
+ 0, ICE_ProtocolSetup,
+ iceConn->receive_sequence,
+ IceFatalToProtocol,
+ IceUnknownProtocol,
+ WORD64COUNT (bytes));
+
+ pBuf = pStart = IceAllocScratch (iceConn, PADDED_BYTES64 (bytes));
+ STORE_STRING (pBuf, protocolName);
+
+ IceWriteData (iceConn, PADDED_BYTES64 (bytes), pStart);
+ IceFlush (iceConn);
+}
+
+
+void
+_IceErrorBadMajor (iceConn, offendingMajor, offendingMinor, severity)
+
+IceConn iceConn;
+int offendingMajor;
+int offendingMinor;
+int severity;
+
+{
+ char maj = (char) offendingMajor;
+
+ IceErrorHeader (iceConn,
+ 0, offendingMinor,
+ iceConn->receive_sequence,
+ severity,
+ IceBadMajor,
+ 1 /* length */);
+
+ IceWriteData (iceConn, 8, &maj);
+ IceFlush (iceConn);
+}
+
+
+
+/*
+ * Default error handler.
+ */
+
+void
+_IceDefaultErrorHandler (iceConn, swap,
+ offendingMinorOpcode, offendingSequence, errorClass, severity, values)
+
+IceConn iceConn;
+Bool swap;
+int offendingMinorOpcode;
+unsigned long offendingSequence;
+int errorClass;
+int severity;
+IcePointer values;
+
+{
+ char *str;
+ char *pData = (char *) values;
+
+ switch (offendingMinorOpcode)
+ {
+ case ICE_ConnectionSetup:
+ str = "ConnectionSetup";
+ break;
+ case ICE_AuthRequired:
+ str = "AuthRequired";
+ break;
+ case ICE_AuthReply:
+ str = "AuthReply";
+ break;
+ case ICE_AuthNextPhase:
+ str = "AuthNextPhase";
+ break;
+ case ICE_ConnectionReply:
+ str = "ConnectionReply";
+ break;
+ case ICE_ProtocolSetup:
+ str = "ProtocolSetup";
+ break;
+ case ICE_ProtocolReply:
+ str = "ProtocolReply";
+ break;
+ case ICE_Ping:
+ str = "Ping";
+ break;
+ case ICE_PingReply:
+ str = "PingReply";
+ break;
+ case ICE_WantToClose:
+ str = "WantToClose";
+ break;
+ case ICE_NoClose:
+ str = "NoClose";
+ break;
+ default:
+ str = "";
+ }
+
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "ICE error: Offending minor opcode = %d (%s)\n",
+ offendingMinorOpcode, str);
+
+ fprintf (stderr, " Offending sequence number = %lu\n",
+ offendingSequence);
+
+ switch (errorClass)
+ {
+ case IceBadMinor:
+ str = "BadMinor";
+ break;
+ case IceBadState:
+ str = "BadState";
+ break;
+ case IceBadLength:
+ str = "BadLength";
+ break;
+ case IceBadValue:
+ str = "BadValue";
+ break;
+ case IceBadMajor:
+ str = "BadMajor";
+ break;
+ case IceNoAuth:
+ str = "NoAuthentication";
+ break;
+ case IceNoVersion:
+ str = "NoVersion";
+ break;
+ case IceSetupFailed:
+ str = "SetupFailed";
+ break;
+ case IceAuthRejected:
+ str = "AuthenticationRejected";
+ break;
+ case IceAuthFailed:
+ str = "AuthenticationFailed";
+ break;
+ case IceProtocolDuplicate:
+ str = "ProtocolDuplicate";
+ break;
+ case IceMajorOpcodeDuplicate:
+ str = "MajorOpcodeDuplicate";
+ break;
+ case IceUnknownProtocol:
+ str = "UnknownProtocol";
+ break;
+ default:
+ str = "???";
+ }
+
+ fprintf (stderr, " Error class = %s\n", str);
+
+ if (severity == IceCanContinue)
+ str = "CanContinue";
+ else if (severity == IceFatalToProtocol)
+ str = "FatalToProtocol";
+ else if (severity == IceFatalToConnection)
+ str = "FatalToConnection";
+ else
+ str = "???";
+
+ fprintf (stderr, " Severity = %s\n", str);
+
+ switch (errorClass)
+ {
+ case IceBadValue:
+ {
+ int offset, length, val;
+
+ EXTRACT_CARD32 (pData, swap, offset);
+ EXTRACT_CARD32 (pData, swap, length);
+
+ fprintf (stderr,
+ " BadValue Offset = %d\n", offset);
+ fprintf (stderr,
+ " BadValue Length = %d\n", length);
+
+ if (length <= 4)
+ {
+ if (length == 1)
+ val = (int) *pData;
+ else if (length == 2)
+ {
+ EXTRACT_CARD16 (pData, swap, val);
+ }
+ else
+ {
+ EXTRACT_CARD32 (pData, swap, val);
+ }
+
+ fprintf (stderr,
+ " BadValue = %d\n", val);
+ }
+ break;
+ }
+
+ case IceBadMajor:
+
+ fprintf (stderr, "Major opcode : %d\n", (int) *pData);
+ break;
+
+ case IceSetupFailed:
+
+ EXTRACT_STRING (pData, swap, str);
+ fprintf (stderr, "Reason : %s\n", str);
+ break;
+
+ case IceAuthRejected:
+
+ EXTRACT_STRING (pData, swap, str);
+ fprintf (stderr, "Reason : %s\n", str);
+ break;
+
+ case IceAuthFailed:
+
+ EXTRACT_STRING (pData, swap, str);
+ fprintf (stderr, "Reason : %s\n", str);
+ break;
+
+ case IceProtocolDuplicate:
+
+ EXTRACT_STRING (pData, swap, str);
+ fprintf (stderr, "Protocol name : %s\n", str);
+ break;
+
+ case IceMajorOpcodeDuplicate:
+
+ fprintf (stderr, "Major opcode : %d\n", (int) *pData);
+ break;
+
+ case IceUnknownProtocol:
+
+ EXTRACT_STRING (pData, swap, str);
+ fprintf (stderr, "Protocol name : %s\n", str);
+ break;
+
+ default:
+ break;
+ }
+
+ fprintf (stderr, "\n");
+
+ if (severity != IceCanContinue)
+ exit (1);
+}
+
+
+
+/*
+ * This procedure sets the ICE error handler to be the specified
+ * routine. If NULL is passed in the default error handler is restored.
+ * The function's return value is the previous error handler.
+ */
+
+IceErrorHandler
+IceSetErrorHandler (handler)
+
+IceErrorHandler handler;
+
+{
+ IceErrorHandler oldHandler = _IceErrorHandler;
+
+ if (handler != NULL)
+ _IceErrorHandler = handler;
+ else
+ _IceErrorHandler = _IceDefaultErrorHandler;
+
+ return (oldHandler);
+}
+
+
+
+/*
+ * Default IO error handler.
+ */
+
+void
+_IceDefaultIOErrorHandler (iceConn)
+
+IceConn iceConn;
+
+{
+ fprintf (stderr,
+ "ICE default IO error handler doing an exit(), pid = %ld, errno = %d\n",
+ (long)getpid(), errno);
+
+ exit (1);
+}
+
+
+
+/*
+ * This procedure sets the ICE fatal I/O error handler to be the
+ * specified routine. If NULL is passed in the default error
+ * handler is restored. The function's return value is the
+ * previous error handler.
+ */
+
+IceIOErrorHandler
+IceSetIOErrorHandler (handler)
+
+IceIOErrorHandler handler;
+
+{
+ IceIOErrorHandler oldHandler = _IceIOErrorHandler;
+
+ if (handler != NULL)
+ _IceIOErrorHandler = handler;
+ else
+ _IceIOErrorHandler = _IceDefaultIOErrorHandler;
+
+ return (oldHandler);
+}
diff --git a/nx-X11/lib/ICE/getauth.c b/nx-X11/lib/ICE/getauth.c
new file mode 100644
index 000000000..73fcd8aec
--- /dev/null
+++ b/nx-X11/lib/ICE/getauth.c
@@ -0,0 +1,274 @@
+/* $Xorg: getauth.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/getauth.c,v 1.2 2001/10/28 03:32:28 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+#include <X11/ICE/ICEutil.h>
+
+static Bool auth_valid ();
+
+extern int _IcePaAuthDataEntryCount;
+extern IceAuthDataEntry _IcePaAuthDataEntries[];
+
+
+/*
+ * The functions in this file are not a standard part of ICElib.
+ *
+ * The sample implementation uses an .ICEauthority to manipulate
+ * authentication data.
+ *
+ * For the client that initiates a Protocol Setup, we look in the
+ * .ICEauthority file to get the data.
+ *
+ * For the client accepting the Protocol Setup, we get the data
+ * from an in-memory database of authentication data (set by the
+ * application calling IceSetPaAuthData). We have to get the data
+ * from memory because getting it directly from the .ICEauthority
+ * file is not secure - someone can just modify the contents of the
+ * .ICEauthority file behind our back.
+ */
+
+void
+_IceGetPoAuthData (protocolName, networkId, authName,
+ authDataLenRet, authDataRet)
+
+char *protocolName;
+char *networkId;
+char *authName;
+unsigned short *authDataLenRet;
+char **authDataRet;
+
+{
+ IceAuthFileEntry *entry;
+
+ entry = IceGetAuthFileEntry (protocolName, networkId, authName);
+
+ if (entry)
+ {
+ *authDataLenRet = entry->auth_data_length;
+
+ if ((*authDataRet = (char *) malloc (entry->auth_data_length)) != NULL)
+ memcpy (*authDataRet, entry->auth_data, entry->auth_data_length);
+ }
+ else
+ {
+ *authDataLenRet = 0;
+ *authDataRet = NULL;
+ }
+
+ IceFreeAuthFileEntry (entry);
+}
+
+
+
+void
+_IceGetPaAuthData (protocolName, networkId, authName,
+ authDataLenRet, authDataRet)
+
+char *protocolName;
+char *networkId;
+char *authName;
+unsigned short *authDataLenRet;
+char **authDataRet;
+
+{
+ IceAuthDataEntry *entry = NULL;
+ int found = 0;
+ int i;
+
+ for (i = 0; i < _IcePaAuthDataEntryCount && !found; i++)
+ {
+ entry = &_IcePaAuthDataEntries[i];
+
+ found =
+ strcmp (protocolName, entry->protocol_name) == 0 &&
+ strcmp (networkId, entry->network_id) == 0 &&
+ strcmp (authName, entry->auth_name) == 0;
+ }
+
+ if (found)
+ {
+ *authDataLenRet = entry->auth_data_length;
+
+ if ((*authDataRet = (char *) malloc (entry->auth_data_length)) != NULL)
+ memcpy (*authDataRet, entry->auth_data, entry->auth_data_length);
+ }
+ else
+ {
+ *authDataLenRet = 0;
+ *authDataRet = NULL;
+ }
+}
+
+
+
+void
+_IceGetPoValidAuthIndices (protocol_name, network_id,
+ num_auth_names, auth_names, num_indices_ret, indices_ret)
+
+char *protocol_name;
+char *network_id;
+int num_auth_names;
+char **auth_names;
+int *num_indices_ret;
+int *indices_ret; /* in/out arg */
+
+{
+ FILE *auth_file;
+ char *filename;
+ IceAuthFileEntry *entry;
+ int index_ret, i;
+
+ *num_indices_ret = 0;
+
+ if (!(filename = IceAuthFileName ()))
+ return;
+
+ if (access (filename, R_OK) != 0) /* checks REAL id */
+ return;
+
+ if (!(auth_file = fopen (filename, "rb")))
+ return;
+
+ for (;;)
+ {
+ if (!(entry = IceReadAuthFileEntry (auth_file)))
+ break;
+
+ if (strcmp (protocol_name, entry->protocol_name) == 0 &&
+ strcmp (network_id, entry->network_id) == 0 &&
+ auth_valid (entry->auth_name, num_auth_names,
+ auth_names, &index_ret))
+ {
+ /*
+ * Make sure we didn't store this index already.
+ */
+
+ for (i = 0; i < *num_indices_ret; i++)
+ if (index_ret == indices_ret[i])
+ break;
+
+ if (i >= *num_indices_ret)
+ {
+ indices_ret[*num_indices_ret] = index_ret;
+ *num_indices_ret += 1;
+ }
+ }
+
+ IceFreeAuthFileEntry (entry);
+ }
+
+ fclose (auth_file);
+}
+
+
+
+void
+_IceGetPaValidAuthIndices (protocol_name, network_id,
+ num_auth_names, auth_names, num_indices_ret, indices_ret)
+
+char *protocol_name;
+char *network_id;
+int num_auth_names;
+char **auth_names;
+int *num_indices_ret;
+int *indices_ret; /* in/out arg */
+
+{
+ int index_ret;
+ int i, j;
+ IceAuthDataEntry *entry;
+
+ *num_indices_ret = 0;
+
+ for (i = 0; i < _IcePaAuthDataEntryCount; i++)
+ {
+ entry = &_IcePaAuthDataEntries[i];
+
+ if (strcmp (protocol_name, entry->protocol_name) == 0 &&
+ strcmp (network_id, entry->network_id) == 0 &&
+ auth_valid (entry->auth_name, num_auth_names,
+ auth_names, &index_ret))
+ {
+ /*
+ * Make sure we didn't store this index already.
+ */
+
+ for (j = 0; j < *num_indices_ret; j++)
+ if (index_ret == indices_ret[j])
+ break;
+
+ if (j >= *num_indices_ret)
+ {
+ indices_ret[*num_indices_ret] = index_ret;
+ *num_indices_ret += 1;
+ }
+ }
+ }
+}
+
+
+
+/*
+ * local routines
+ */
+
+static Bool
+auth_valid (auth_name, num_auth_names, auth_names, index_ret)
+
+char *auth_name;
+int num_auth_names;
+char **auth_names;
+int *index_ret;
+
+{
+ /*
+ * Check if auth_name is in auth_names. Return index.
+ */
+
+ int i;
+
+ for (i = 0; i < num_auth_names; i++)
+ if (strcmp (auth_name, auth_names[i]) == 0)
+ {
+ break;
+ }
+
+ if (i < num_auth_names)
+ {
+ *index_ret = i;
+ return (1);
+ }
+ else
+ return (0);
+}
diff --git a/nx-X11/lib/ICE/globals.h b/nx-X11/lib/ICE/globals.h
new file mode 100644
index 000000000..0532f5565
--- /dev/null
+++ b/nx-X11/lib/ICE/globals.h
@@ -0,0 +1,64 @@
+/* $Xorg: globals.h,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/globals.h,v 1.4 2001/12/14 19:53:35 dawes Exp $ */
+
+extern void _IceDefaultErrorHandler ();
+extern void _IceDefaultIOErrorHandler ();
+
+extern IcePoAuthStatus _IcePoMagicCookie1Proc ();
+extern IcePaAuthStatus _IcePaMagicCookie1Proc ();
+
+extern void _IceProcessCoreMessage ();
+
+#ifndef __UNIXOS2__
+IceConn _IceConnectionObjs[256];
+char *_IceConnectionStrings[256];
+_IceProtocol _IceProtocols[255];
+#else
+IceConn _IceConnectionObjs[256] = {0};
+char *_IceConnectionStrings[256] = {0};
+_IceProtocol _IceProtocols[255] = {0};
+#endif
+int _IceConnectionCount = 0;
+
+int _IceLastMajorOpcode = 0;
+
+int _IceAuthCount = 1;
+char *_IceAuthNames[] = {"MIT-MAGIC-COOKIE-1"};
+IcePoAuthProc _IcePoAuthProcs[] = {_IcePoMagicCookie1Proc};
+IcePaAuthProc _IcePaAuthProcs[] = {_IcePaMagicCookie1Proc};
+
+int _IceVersionCount = 1;
+_IceVersion _IceVersions[] = {
+ {IceProtoMajor, IceProtoMinor, _IceProcessCoreMessage}};
+
+_IceWatchProc *_IceWatchProcs = NULL;
+
+IceErrorHandler _IceErrorHandler = _IceDefaultErrorHandler;
+IceIOErrorHandler _IceIOErrorHandler = _IceDefaultIOErrorHandler;
diff --git a/nx-X11/lib/ICE/iceauth.c b/nx-X11/lib/ICE/iceauth.c
new file mode 100644
index 000000000..01c73ced3
--- /dev/null
+++ b/nx-X11/lib/ICE/iceauth.c
@@ -0,0 +1,278 @@
+/* $Xorg: iceauth.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/iceauth.c,v 3.5 2001/12/14 19:53:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+#include <X11/ICE/ICEutil.h>
+
+#include <time.h>
+#define Time_t time_t
+
+static int binaryEqual ();
+
+static int was_called_state;
+
+/*
+ * MIT-MAGIC-COOKIE-1 is a sample authentication method implemented by
+ * the SI. It is not part of standard ICElib.
+ */
+
+
+char *
+IceGenerateMagicCookie (len)
+
+int len;
+
+{
+ char *auth;
+ long ldata[2];
+ int seed;
+ int value;
+ int i;
+
+ if ((auth = (char *) malloc (len + 1)) == NULL)
+ return (NULL);
+
+#ifdef ITIMER_REAL
+ {
+ struct timeval now;
+ X_GETTIMEOFDAY (&now);
+ ldata[0] = now.tv_sec;
+ ldata[1] = now.tv_usec;
+ }
+#else
+ {
+#ifndef __UNIXOS2__
+ long time ();
+#endif
+ ldata[0] = time ((long *) 0);
+ ldata[1] = getpid ();
+ }
+#endif
+ seed = (ldata[0]) + (ldata[1] << 16);
+ srand (seed);
+ for (i = 0; i < len; i++)
+ {
+ value = rand ();
+ auth[i] = value & 0xff;
+ }
+ auth[len] = '\0';
+
+ return (auth);
+}
+
+
+
+IcePoAuthStatus
+_IcePoMagicCookie1Proc (iceConn, authStatePtr, cleanUp, swap,
+ authDataLen, authData, replyDataLenRet, replyDataRet, errorStringRet)
+
+IceConn iceConn;
+IcePointer *authStatePtr;
+Bool cleanUp;
+Bool swap;
+int authDataLen;
+IcePointer authData;
+int *replyDataLenRet;
+IcePointer *replyDataRet;
+char **errorStringRet;
+
+{
+ if (cleanUp)
+ {
+ /*
+ * We didn't allocate any state. We're done.
+ */
+
+ return (IcePoAuthDoneCleanup);
+ }
+
+ *errorStringRet = NULL;
+
+ if (*authStatePtr == NULL)
+ {
+ /*
+ * This is the first time we're being called. Search the
+ * authentication data for the first occurence of
+ * MIT-MAGIC-COOKIE-1 that matches iceConn->connection_string.
+ */
+
+ unsigned short length;
+ char *data;
+
+ _IceGetPoAuthData ("ICE", iceConn->connection_string,
+ "MIT-MAGIC-COOKIE-1", &length, &data);
+
+ if (!data)
+ {
+ char *tempstr =
+ "Could not find correct MIT-MAGIC-COOKIE-1 authentication";
+
+ *errorStringRet = (char *) malloc (strlen (tempstr) + 1);
+ if (*errorStringRet)
+ strcpy (*errorStringRet, tempstr);
+
+ return (IcePoAuthFailed);
+ }
+ else
+ {
+ *authStatePtr = (IcePointer) &was_called_state;
+
+ *replyDataLenRet = length;
+ *replyDataRet = data;
+
+ return (IcePoAuthHaveReply);
+ }
+ }
+ else
+ {
+ /*
+ * We should never get here for MIT-MAGIC-COOKIE-1 since it is
+ * a single pass authentication method.
+ */
+
+ char *tempstr = "MIT-MAGIC-COOKIE-1 authentication internal error";
+
+ *errorStringRet = (char *) malloc (strlen (tempstr) + 1);
+ if (*errorStringRet)
+ strcpy (*errorStringRet, tempstr);
+
+ return (IcePoAuthFailed);
+ }
+}
+
+
+
+IcePaAuthStatus
+_IcePaMagicCookie1Proc (iceConn, authStatePtr, swap,
+ authDataLen, authData, replyDataLenRet, replyDataRet, errorStringRet)
+
+IceConn iceConn;
+IcePointer *authStatePtr;
+Bool swap;
+int authDataLen;
+IcePointer authData;
+int *replyDataLenRet;
+IcePointer *replyDataRet;
+char **errorStringRet;
+
+{
+ *errorStringRet = NULL;
+ *replyDataLenRet = 0;
+ *replyDataRet = NULL;
+
+ if (*authStatePtr == NULL)
+ {
+ /*
+ * This is the first time we're being called. We don't have
+ * any data to pass to the other client.
+ */
+
+ *authStatePtr = (IcePointer) &was_called_state;
+
+ return (IcePaAuthContinue);
+ }
+ else
+ {
+ /*
+ * Search the authentication data for the first occurence of
+ * MIT-MAGIC-COOKIE-1 that matches iceConn->connection_string.
+ */
+
+ unsigned short length;
+ char *data;
+
+ _IceGetPaAuthData ("ICE", iceConn->connection_string,
+ "MIT-MAGIC-COOKIE-1", &length, &data);
+
+ if (data)
+ {
+ IcePaAuthStatus stat;
+
+ if (authDataLen == length &&
+ binaryEqual ((char *) authData, data, authDataLen))
+ {
+ stat = IcePaAuthAccepted;
+ }
+ else
+ {
+ char *tempstr = "MIT-MAGIC-COOKIE-1 authentication rejected";
+
+ *errorStringRet = (char *) malloc (strlen (tempstr) + 1);
+ if (*errorStringRet)
+ strcpy (*errorStringRet, tempstr);
+
+ stat = IcePaAuthRejected;
+ }
+
+ free (data);
+ return (stat);
+ }
+ else
+ {
+ /*
+ * We should never get here because in the ConnectionReply
+ * we should have passed all the valid methods. So we should
+ * always find a valid entry.
+ */
+
+ char *tempstr =
+ "MIT-MAGIC-COOKIE-1 authentication internal error";
+
+ *errorStringRet = (char *) malloc (strlen (tempstr) + 1);
+ if (*errorStringRet)
+ strcpy (*errorStringRet, tempstr);
+
+ return (IcePaAuthFailed);
+ }
+ }
+}
+
+
+
+/*
+ * local routines
+ */
+
+static int
+binaryEqual (a, b, len)
+
+register char *a, *b;
+register unsigned len;
+
+{
+ while (len--)
+ if (*a++ != *b++)
+ return 0;
+ return 1;
+}
diff --git a/nx-X11/lib/ICE/listen.c b/nx-X11/lib/ICE/listen.c
new file mode 100644
index 000000000..7708cfe02
--- /dev/null
+++ b/nx-X11/lib/ICE/listen.c
@@ -0,0 +1,283 @@
+/* $Xorg: listen.c,v 1.5 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+#include <X11/Xtrans/Xtrans.h>
+#include <stdio.h>
+
+
+Status
+IceListenForConnections (countRet, listenObjsRet, errorLength, errorStringRet)
+
+int *countRet;
+IceListenObj **listenObjsRet;
+int errorLength;
+char *errorStringRet;
+
+{
+ struct _IceListenObj *listenObjs;
+ char *networkId;
+ int transCount, partial, i, j;
+ Status status = 1;
+ XtransConnInfo *transConns = NULL;
+
+
+ if ((_IceTransMakeAllCOTSServerListeners (NULL, &partial,
+ &transCount, &transConns) < 0) || (transCount < 1))
+ {
+ *listenObjsRet = NULL;
+ *countRet = 0;
+
+ strncpy (errorStringRet,
+ "Cannot establish any listening sockets", errorLength);
+
+ return (0);
+ }
+
+ if ((listenObjs = (struct _IceListenObj *) malloc (
+ transCount * sizeof (struct _IceListenObj))) == NULL)
+ {
+ for (i = 0; i < transCount; i++)
+ _IceTransClose (transConns[i]);
+ free ((char *) transConns);
+ return (0);
+ }
+
+ *countRet = 0;
+
+ for (i = 0; i < transCount; i++)
+ {
+ networkId = _IceTransGetMyNetworkId (transConns[i]);
+
+ if (networkId)
+ {
+ listenObjs[*countRet].trans_conn = transConns[i];
+ listenObjs[*countRet].network_id = networkId;
+
+ (*countRet)++;
+ }
+ }
+
+ if (*countRet == 0)
+ {
+ *listenObjsRet = NULL;
+
+ strncpy (errorStringRet,
+ "Cannot establish any listening sockets", errorLength);
+
+ status = 0;
+ }
+ else
+ {
+ *listenObjsRet = (IceListenObj *) malloc (
+ *countRet * sizeof (IceListenObj));
+
+ if (*listenObjsRet == NULL)
+ {
+ strncpy (errorStringRet, "Malloc failed", errorLength);
+
+ status = 0;
+ }
+ else
+ {
+ for (i = 0; i < *countRet; i++)
+ {
+ (*listenObjsRet)[i] = (IceListenObj) malloc (
+ sizeof (struct _IceListenObj));
+
+ if ((*listenObjsRet)[i] == NULL)
+ {
+ strncpy (errorStringRet, "Malloc failed", errorLength);
+
+ for (j = 0; j < i; j++)
+ free ((char *) (*listenObjsRet)[j]);
+
+ free ((char *) *listenObjsRet);
+
+ status = 0;
+ }
+ else
+ {
+ *((*listenObjsRet)[i]) = listenObjs[i];
+ }
+ }
+ }
+ }
+
+ if (status == 1)
+ {
+ if (errorStringRet && errorLength > 0)
+ *errorStringRet = '\0';
+
+ for (i = 0; i < *countRet; i++)
+ {
+ (*listenObjsRet)[i]->host_based_auth_proc = NULL;
+ }
+ }
+ else
+ {
+ for (i = 0; i < transCount; i++)
+ _IceTransClose (transConns[i]);
+ }
+
+ free ((char *) listenObjs);
+ free ((char *) transConns);
+
+ return (status);
+}
+
+
+
+int
+IceGetListenConnectionNumber (listenObj)
+
+IceListenObj listenObj;
+
+{
+ return (_IceTransGetConnectionNumber (listenObj->trans_conn));
+}
+
+
+
+char *
+IceGetListenConnectionString (listenObj)
+
+IceListenObj listenObj;
+
+{
+ char *networkId;
+
+ networkId = (char *) malloc (strlen (listenObj->network_id) + 1);
+
+ if (networkId)
+ strcpy (networkId, listenObj->network_id);
+
+ return (networkId);
+}
+
+
+
+char *
+IceComposeNetworkIdList (count, listenObjs)
+
+int count;
+IceListenObj *listenObjs;
+
+{
+ char *list;
+ int len = 0;
+ int i;
+
+ if (count < 1 || listenObjs == NULL)
+ return (NULL);
+
+ for (i = 0; i < count; i++)
+ len += (strlen (listenObjs[i]->network_id) + 1);
+
+ list = (char *) malloc (len);
+
+ if (list == NULL)
+ return (NULL);
+ else
+ {
+ int doneCount = 0;
+
+ list[0] = '\0';
+
+ for (i = 0; i < count; i++)
+ {
+ if (_IceTransIsLocal (listenObjs[i]->trans_conn))
+ {
+ strcat (list, listenObjs[i]->network_id);
+ doneCount++;
+ if (doneCount < count)
+ strcat (list, ",");
+ }
+ }
+
+ if (doneCount < count)
+ {
+ for (i = 0; i < count; i++)
+ {
+ if (!_IceTransIsLocal (listenObjs[i]->trans_conn))
+ {
+ strcat (list, listenObjs[i]->network_id);
+ doneCount++;
+ if (doneCount < count)
+ strcat (list, ",");
+ }
+ }
+ }
+
+ return (list);
+ }
+}
+
+
+
+void
+IceFreeListenObjs (count, listenObjs)
+
+int count;
+IceListenObj *listenObjs;
+
+{
+ int i;
+
+ for (i = 0; i < count; i++)
+ {
+ free (listenObjs[i]->network_id);
+ _IceTransClose (listenObjs[i]->trans_conn);
+ free ((char *) listenObjs[i]);
+ }
+
+ free ((char *) listenObjs);
+}
+
+
+
+/*
+ * Allow host based authentication for the ICE Connection Setup.
+ * Do not confuse with the host based authentication callbacks that
+ * can be set up in IceRegisterForProtocolReply.
+ */
+
+void
+IceSetHostBasedAuthProc (listenObj, hostBasedAuthProc)
+
+IceListenObj listenObj;
+IceHostBasedAuthProc hostBasedAuthProc;
+
+{
+ listenObj->host_based_auth_proc = hostBasedAuthProc;
+}
diff --git a/nx-X11/lib/ICE/listenwk.c b/nx-X11/lib/ICE/listenwk.c
new file mode 100644
index 000000000..f97aa44af
--- /dev/null
+++ b/nx-X11/lib/ICE/listenwk.c
@@ -0,0 +1,161 @@
+/* $Xorg: listenwk.c,v 1.5 2001/02/09 02:03:26 xorgcvs Exp $ */
+
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/ICE/listenwk.c,v 1.3 2001/01/17 19:41:29 dawes Exp $ */
+
+
+/* Author: Ralph Mor, X Consortium */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+#include <X11/Xtrans/Xtrans.h>
+#include <stdio.h>
+
+
+Status
+IceListenForWellKnownConnections (port, countRet, listenObjsRet, errorLength, errorStringRet)
+
+char *port;
+int *countRet;
+IceListenObj **listenObjsRet;
+int errorLength;
+char *errorStringRet;
+
+{
+ struct _IceListenObj *listenObjs;
+ char *networkId;
+ int transCount, partial, i, j;
+ Status status = 1;
+ XtransConnInfo *transConns = NULL;
+
+
+ if ((_IceTransMakeAllCOTSServerListeners (port, &partial,
+ &transCount, &transConns) < 0) || (transCount < 1))
+ {
+ *listenObjsRet = NULL;
+ *countRet = 0;
+
+ strncpy (errorStringRet,
+ "Cannot establish any listening sockets", errorLength);
+
+ return (0);
+ }
+
+ if ((listenObjs = (struct _IceListenObj *) malloc (
+ transCount * sizeof (struct _IceListenObj))) == NULL)
+ {
+ for (i = 0; i < transCount; i++)
+ _IceTransClose (transConns[i]);
+ free ((char *) transConns);
+ return (0);
+ }
+
+ *countRet = 0;
+
+ for (i = 0; i < transCount; i++)
+ {
+ networkId = (char *)_IceTransGetMyNetworkId (transConns[i]);
+
+ if (networkId)
+ {
+ listenObjs[*countRet].trans_conn = transConns[i];
+ listenObjs[*countRet].network_id = networkId;
+
+ (*countRet)++;
+ }
+ }
+
+ if (*countRet == 0)
+ {
+ *listenObjsRet = NULL;
+
+ strncpy (errorStringRet,
+ "Cannot establish any listening sockets", errorLength);
+
+ status = 0;
+ }
+ else
+ {
+ *listenObjsRet = (IceListenObj *) malloc (
+ *countRet * sizeof (IceListenObj));
+
+ if (*listenObjsRet == NULL)
+ {
+ strncpy (errorStringRet, "Malloc failed", errorLength);
+
+ status = 0;
+ }
+ else
+ {
+ for (i = 0; i < *countRet; i++)
+ {
+ (*listenObjsRet)[i] = (IceListenObj) malloc (
+ sizeof (struct _IceListenObj));
+
+ if ((*listenObjsRet)[i] == NULL)
+ {
+ strncpy (errorStringRet, "Malloc failed", errorLength);
+
+ for (j = 0; j < i; j++)
+ free ((char *) (*listenObjsRet)[j]);
+
+ free ((char *) *listenObjsRet);
+
+ status = 0;
+ }
+ else
+ {
+ *((*listenObjsRet)[i]) = listenObjs[i];
+ }
+ }
+ }
+ }
+
+ if (status == 1)
+ {
+ if (errorStringRet && errorLength > 0)
+ *errorStringRet = '\0';
+
+ for (i = 0; i < *countRet; i++)
+ {
+ (*listenObjsRet)[i]->host_based_auth_proc = NULL;
+ }
+ }
+ else
+ {
+ for (i = 0; i < transCount; i++)
+ _IceTransClose (transConns[i]);
+ }
+
+ free ((char *) listenObjs);
+ free ((char *) transConns);
+
+ return (status);
+}
diff --git a/nx-X11/lib/ICE/locking.c b/nx-X11/lib/ICE/locking.c
new file mode 100644
index 000000000..510803030
--- /dev/null
+++ b/nx-X11/lib/ICE/locking.c
@@ -0,0 +1,67 @@
+/* $Xorg: locking.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+
+
+/*
+ * NOT IMPLEMENTED YET
+ */
+
+
+Status
+IceInitThreads ()
+
+{
+ return (0);
+}
+
+
+void
+IceAppLockConn (iceConn)
+
+IceConn iceConn;
+
+{
+ IceLockConn (iceConn);
+}
+
+
+void
+IceAppUnlockConn (iceConn)
+
+IceConn iceConn;
+
+{
+ IceUnlockConn (iceConn);
+}
diff --git a/nx-X11/lib/ICE/misc.c b/nx-X11/lib/ICE/misc.c
new file mode 100644
index 000000000..a6e91c65a
--- /dev/null
+++ b/nx-X11/lib/ICE/misc.c
@@ -0,0 +1,630 @@
+/* $Xorg: misc.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/misc.c,v 1.3 2001/01/17 19:41:29 dawes Exp $ */
+
+#ifdef WIN32
+#define _WILLWINSOCK_
+#endif
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+#include <X11/Xtrans/Xtrans.h>
+#include <stdio.h>
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#include <X11/Xw32defs.h>
+#endif
+
+
+/*
+ * scratch buffer
+ */
+
+char *
+IceAllocScratch (iceConn, size)
+
+IceConn iceConn;
+unsigned long size;
+
+{
+ if (!iceConn->scratch || size > iceConn->scratch_size)
+ {
+ if (iceConn->scratch)
+ free (iceConn->scratch);
+
+ iceConn->scratch = (char *) malloc ((unsigned) size);
+ iceConn->scratch_size = size;
+ }
+
+ return (iceConn->scratch);
+}
+
+
+
+/*
+ * Output/Input buffer functions
+ */
+
+int
+IceFlush (iceConn)
+
+IceConn iceConn;
+
+{
+ _IceWrite (iceConn,
+ (unsigned long) (iceConn->outbufptr - iceConn->outbuf),
+ iceConn->outbuf);
+
+ iceConn->outbufptr = iceConn->outbuf;
+ return 1;
+}
+
+
+int
+IceGetOutBufSize (iceConn)
+
+IceConn iceConn;
+
+{
+ return (iceConn->outbufmax - iceConn->outbuf);
+}
+
+
+int
+IceGetInBufSize (iceConn)
+
+IceConn iceConn;
+
+{
+ return (iceConn->inbufmax - iceConn->inbuf);
+}
+
+
+
+/*
+ * informational functions
+ */
+
+IceConnectStatus
+IceConnectionStatus (iceConn)
+
+IceConn iceConn;
+
+{
+ return (iceConn->connection_status);
+}
+
+
+char *
+IceVendor (iceConn)
+
+IceConn iceConn;
+
+{
+ char *string = (char *) malloc (strlen (iceConn->vendor) + 1);
+
+ if (string)
+ strcpy (string, iceConn->vendor);
+
+ return (string);
+}
+
+
+char *
+IceRelease (iceConn)
+
+IceConn iceConn;
+
+{
+ char *string = (char *) malloc (strlen (iceConn->release) + 1);
+
+ if (string)
+ strcpy (string, iceConn->release);
+
+ return (string);
+}
+
+
+int
+IceProtocolVersion (iceConn)
+
+IceConn iceConn;
+
+{
+ return (_IceVersions[iceConn->my_ice_version_index].major_version);
+}
+
+
+int
+IceProtocolRevision (iceConn)
+
+IceConn iceConn;
+
+{
+ return (_IceVersions[iceConn->my_ice_version_index].minor_version);
+}
+
+
+int
+IceConnectionNumber (iceConn)
+
+IceConn iceConn;
+
+{
+ return (_IceTransGetConnectionNumber (iceConn->trans_conn));
+}
+
+
+char *
+IceConnectionString (iceConn)
+
+IceConn iceConn;
+
+{
+ if (iceConn->connection_string)
+ {
+ char *string = (char *) malloc (
+ strlen (iceConn->connection_string) + 1);
+
+ if (string)
+ strcpy (string, iceConn->connection_string);
+
+ return (string);
+ }
+ else
+ return (NULL);
+}
+
+
+unsigned long
+IceLastSentSequenceNumber (iceConn)
+
+IceConn iceConn;
+
+{
+ return (iceConn->send_sequence);
+}
+
+
+unsigned long
+IceLastReceivedSequenceNumber (iceConn)
+
+IceConn iceConn;
+
+{
+ return (iceConn->receive_sequence);
+}
+
+
+Bool
+IceSwapping (iceConn)
+
+IceConn iceConn;
+
+{
+ return (iceConn->swap);
+}
+
+
+
+/*
+ * Read "n" bytes from a connection.
+ *
+ * Return Status 0 if we detected an EXPECTED closed connection.
+ *
+ */
+
+Status
+_IceRead (iceConn, nbytes, ptr)
+
+register IceConn iceConn;
+unsigned long nbytes;
+register char *ptr;
+
+{
+ register unsigned long nleft;
+
+ nleft = nbytes;
+ while (nleft > 0)
+ {
+ int nread;
+
+ if (iceConn->io_ok)
+ nread = _IceTransRead (iceConn->trans_conn, ptr, (int) nleft);
+ else
+ return (1);
+
+ if (nread <= 0)
+ {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ if (iceConn->want_to_close)
+ {
+ /*
+ * We sent a WantToClose message and now we detected that
+ * the other side closed the connection.
+ */
+
+ _IceConnectionClosed (iceConn); /* invoke watch procs */
+ _IceFreeConnection (iceConn);
+
+ return (0);
+ }
+ else
+ {
+ /*
+ * Fatal IO error. First notify each protocol's IceIOErrorProc
+ * callback, then invoke the application IO error handler.
+ */
+
+ iceConn->io_ok = False;
+
+ if (iceConn->connection_status == IceConnectPending)
+ {
+ /*
+ * Don't invoke IO error handler if we are in the
+ * middle of a connection setup.
+ */
+
+ return (1);
+ }
+
+ if (iceConn->process_msg_info)
+ {
+ int i;
+
+ for (i = iceConn->his_min_opcode;
+ i <= iceConn->his_max_opcode; i++)
+ {
+ _IceProcessMsgInfo *process;
+
+ process = &iceConn->process_msg_info[
+ i - iceConn->his_min_opcode];
+
+ if (process->in_use)
+ {
+ IceIOErrorProc IOErrProc = process->accept_flag ?
+ process->protocol->accept_client->io_error_proc :
+ process->protocol->orig_client->io_error_proc;
+
+ if (IOErrProc)
+ (*IOErrProc) (iceConn);
+ }
+ }
+ }
+
+ (*_IceIOErrorHandler) (iceConn);
+ return (1);
+ }
+ }
+
+ nleft -= nread;
+ ptr += nread;
+ }
+
+ return (1);
+}
+
+
+
+/*
+ * If we read a message header with a bad major or minor opcode,
+ * we need to advance to the end of the message. This way, the next
+ * message can be processed correctly.
+ */
+
+void
+_IceReadSkip (iceConn, nbytes)
+
+register IceConn iceConn;
+register unsigned long nbytes;
+
+{
+ char temp[512];
+
+ while (nbytes > 0)
+ {
+ unsigned long rbytes = nbytes > 512 ? 512 : nbytes;
+
+ _IceRead (iceConn, rbytes, temp);
+ nbytes -= rbytes;
+ }
+}
+
+
+
+/*
+ * Write "n" bytes to a connection.
+ */
+
+void
+_IceWrite (iceConn, nbytes, ptr)
+
+register IceConn iceConn;
+unsigned long nbytes;
+register char *ptr;
+
+{
+ register unsigned long nleft;
+
+ nleft = nbytes;
+ while (nleft > 0)
+ {
+ int nwritten;
+
+ if (iceConn->io_ok)
+ nwritten = _IceTransWrite (iceConn->trans_conn, ptr, (int) nleft);
+ else
+ return;
+
+ if (nwritten <= 0)
+ {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ /*
+ * Fatal IO error. First notify each protocol's IceIOErrorProc
+ * callback, then invoke the application IO error handler.
+ */
+
+ iceConn->io_ok = False;
+
+ if (iceConn->connection_status == IceConnectPending)
+ {
+ /*
+ * Don't invoke IO error handler if we are in the
+ * middle of a connection setup.
+ */
+
+ return;
+ }
+
+ if (iceConn->process_msg_info)
+ {
+ int i;
+
+ for (i = iceConn->his_min_opcode;
+ i <= iceConn->his_max_opcode; i++)
+ {
+ _IceProcessMsgInfo *process;
+
+ process = &iceConn->process_msg_info[
+ i - iceConn->his_min_opcode];
+
+ if (process->in_use)
+ {
+ IceIOErrorProc IOErrProc = process->accept_flag ?
+ process->protocol->accept_client->io_error_proc :
+ process->protocol->orig_client->io_error_proc;
+
+ if (IOErrProc)
+ (*IOErrProc) (iceConn);
+ }
+ }
+ }
+
+ (*_IceIOErrorHandler) (iceConn);
+ return;
+ }
+
+ nleft -= nwritten;
+ ptr += nwritten;
+ }
+}
+
+#ifdef WORD64
+
+IceWriteData16 (iceConn, nbytes, data)
+
+IceConn iceConn;
+unsigned long nbytes;
+short *data;
+
+{
+ int numShorts = nbytes / 2;
+ int index = 0;
+
+ while (index < numShorts)
+ {
+ int spaceLeft, count, i;
+ int shortsLeft = numShorts - index;
+
+ spaceLeft = iceConn->outbufmax - iceConn->outbufptr - 1;
+
+ if (spaceLeft < 2)
+ {
+ IceFlush (iceConn);
+ spaceLeft = iceConn->outbufmax - iceConn->outbufptr - 1;
+ }
+
+ count = (shortsLeft < spaceLeft / 2) ? shortsLeft : spaceLeft / 2;
+
+ for (i = 0; i < count; i++)
+ STORE_CARD16 (iceConn->outbufptr, data[index++]);
+ }
+}
+
+
+IceWriteData32 (iceConn, nbytes, data)
+
+IceConn iceConn;
+unsigned long nbytes;
+int *data;
+
+{
+ int numLongs = nbytes / 4;
+ int index = 0;
+
+ while (index < numLongs)
+ {
+ int spaceLeft, count, i;
+ int longsLeft = numLongs - index;
+
+ spaceLeft = iceConn->outbufmax - iceConn->outbufptr - 1;
+
+ if (spaceLeft < 4)
+ {
+ IceFlush (iceConn);
+ spaceLeft = iceConn->outbufmax - iceConn->outbufptr - 1;
+ }
+
+ count = (longsLeft < spaceLeft / 4) ? longsLeft : spaceLeft / 4;
+
+ for (i = 0; i < count; i++)
+ STORE_CARD32 (iceConn->outbufptr, data[index++]);
+ }
+}
+
+
+IceReadData16 (iceConn, swap, nbytes, data)
+
+IceConn iceConn;
+Bool swap;
+unsigned long nbytes;
+short *data;
+
+{
+ /* NOT IMPLEMENTED YET */
+}
+
+
+IceReadData32 (iceConn, swap, nbytes, data)
+
+IceConn iceConn;
+Bool swap;
+unsigned long nbytes;
+int *data;
+
+{
+ /* NOT IMPLEMENTED YET */
+}
+
+#endif /* WORD64 */
+
+
+
+void
+_IceAddOpcodeMapping (iceConn, hisOpcode, myOpcode)
+
+IceConn iceConn;
+int hisOpcode;
+int myOpcode;
+
+{
+ if (hisOpcode <= 0 || hisOpcode > 255)
+ {
+ return;
+ }
+ else if (iceConn->process_msg_info == NULL)
+ {
+ iceConn->process_msg_info = (_IceProcessMsgInfo *) malloc (
+ sizeof (_IceProcessMsgInfo));
+ iceConn->his_min_opcode = iceConn->his_max_opcode = hisOpcode;
+ }
+ else if (hisOpcode < iceConn->his_min_opcode)
+ {
+ _IceProcessMsgInfo *oldVec = iceConn->process_msg_info;
+ int oldsize = iceConn->his_max_opcode - iceConn->his_min_opcode + 1;
+ int newsize = iceConn->his_max_opcode - hisOpcode + 1;
+ int i;
+
+ iceConn->process_msg_info = (_IceProcessMsgInfo *) malloc (
+ newsize * sizeof (_IceProcessMsgInfo));
+
+ memcpy (&iceConn->process_msg_info[
+ iceConn->his_min_opcode - hisOpcode], oldVec,
+ oldsize * sizeof (_IceProcessMsgInfo));
+
+ free ((char *) oldVec);
+
+ for (i = hisOpcode + 1; i < iceConn->his_min_opcode; i++)
+ {
+ iceConn->process_msg_info[i -
+ iceConn->his_min_opcode].in_use = False;
+
+ iceConn->process_msg_info[i -
+ iceConn->his_min_opcode].protocol = NULL;
+ }
+
+ iceConn->his_min_opcode = hisOpcode;
+ }
+ else if (hisOpcode > iceConn->his_max_opcode)
+ {
+ _IceProcessMsgInfo *oldVec = iceConn->process_msg_info;
+ int oldsize = iceConn->his_max_opcode - iceConn->his_min_opcode + 1;
+ int newsize = hisOpcode - iceConn->his_min_opcode + 1;
+ int i;
+
+ iceConn->process_msg_info = (_IceProcessMsgInfo *) malloc (
+ newsize * sizeof (_IceProcessMsgInfo));
+
+ memcpy (iceConn->process_msg_info, oldVec,
+ oldsize * sizeof (_IceProcessMsgInfo));
+
+ free ((char *) oldVec);
+
+ for (i = iceConn->his_max_opcode + 1; i < hisOpcode; i++)
+ {
+ iceConn->process_msg_info[i -
+ iceConn->his_min_opcode].in_use = False;
+
+ iceConn->process_msg_info[i -
+ iceConn->his_min_opcode].protocol = NULL;
+ }
+
+ iceConn->his_max_opcode = hisOpcode;
+ }
+
+ iceConn->process_msg_info[hisOpcode -
+ iceConn->his_min_opcode].in_use = True;
+
+ iceConn->process_msg_info[hisOpcode -
+ iceConn->his_min_opcode].my_opcode = myOpcode;
+
+ iceConn->process_msg_info[hisOpcode -
+ iceConn->his_min_opcode].protocol = &_IceProtocols[myOpcode - 1];
+}
+
+
+
+char *
+IceGetPeerName (IceConn iceConn)
+{
+ return (_IceTransGetPeerNetworkId (iceConn->trans_conn));
+}
+
+
+char *
+_IceGetPeerName (IceConn iceConn)
+{
+ return (IceGetPeerName(iceConn));
+}
diff --git a/nx-X11/lib/ICE/ping.c b/nx-X11/lib/ICE/ping.c
new file mode 100644
index 000000000..45329b6f5
--- /dev/null
+++ b/nx-X11/lib/ICE/ping.c
@@ -0,0 +1,66 @@
+/* $Xorg: ping.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+
+Status
+IcePing (iceConn, pingReplyProc, clientData)
+
+IceConn iceConn;
+IcePingReplyProc pingReplyProc;
+IcePointer clientData;
+
+{
+ _IcePingWait *newping = (_IcePingWait *) malloc (sizeof (_IcePingWait));
+ _IcePingWait *ptr = iceConn->ping_waits;
+
+ if (newping == NULL)
+ return (0);
+
+ newping->ping_reply_proc = pingReplyProc;
+ newping->client_data = clientData;
+ newping->next = NULL;
+
+ while (ptr && ptr->next)
+ ptr = ptr->next;
+
+ if (ptr == NULL)
+ iceConn->ping_waits = newping;
+ else
+ ptr->next = newping;
+
+ IceSimpleMessage (iceConn, 0, ICE_Ping);
+ IceFlush (iceConn);
+
+ return (1);
+}
diff --git a/nx-X11/lib/ICE/process.c b/nx-X11/lib/ICE/process.c
new file mode 100644
index 000000000..2a97dcbe8
--- /dev/null
+++ b/nx-X11/lib/ICE/process.c
@@ -0,0 +1,2548 @@
+/* $Xorg: process.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/process.c,v 3.9tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+
+#include <stdio.h> /* sprintf */
+
+/*
+ * Check for bad length
+ */
+
+#define CHECK_SIZE_MATCH(_iceConn, _opcode, _expected_len, _actual_len, _severity, _return) \
+ if ((((_actual_len) - SIZEOF (iceMsg)) >> 3) != _expected_len) \
+ { \
+ _IceErrorBadLength (_iceConn, 0, _opcode, _severity); \
+ return (_return); \
+ }
+
+#define CHECK_AT_LEAST_SIZE(_iceConn, _opcode, _expected_len, _actual_len, _severity) \
+ if ((((_actual_len) - SIZEOF (iceMsg)) >> 3) > _expected_len) \
+ { \
+ _IceErrorBadLength (_iceConn, 0, _opcode, _severity); \
+ return (0); \
+ }
+
+#define CHECK_COMPLETE_SIZE(_iceConn, _opcode, _expected_len, _actual_len, _pStart, _severity) \
+ if (((PADDED_BYTES64((_actual_len)) - SIZEOF (iceMsg)) >> 3) \
+ != _expected_len) \
+ { \
+ _IceErrorBadLength (_iceConn, 0, _opcode, _severity); \
+ IceDisposeCompleteMessage (iceConn, _pStart); \
+ return (0); \
+ }
+
+#define BAIL_STRING(_iceConn, _opcode, _pStart) {\
+ _IceErrorBadLength (_iceConn, 0, _opcode, IceFatalToConnection);\
+ IceDisposeCompleteMessage (_iceConn, _pStart);\
+ return (0);\
+}
+
+/*
+ * IceProcessMessages:
+ *
+ * If replyWait == NULL, the client is not waiting for a reply.
+ *
+ * If replyWait != NULL, the client is waiting for a reply...
+ *
+ * - replyWait->sequence_of_request is the sequence number of the
+ * message for which the client is waiting a reply. This is needed
+ * to determine if an error matches a replyWait.
+ *
+ * - replyWait->major_opcode_of_request is the major opcode of the
+ * message for which we are waiting a reply.
+ *
+ * - replyWait->minor_opcode_of_request is the minor opcode of the
+ * message for which we are waiting a reply.
+ *
+ * - replyWait->reply is a pointer to the reply message which will be
+ * filled in when the reply is ready (the protocol library should
+ * cast this IcePointer to the appropriate reply type). In most cases,
+ * the reply will have some fixed-size part, and the sender function
+ * will have provided a pointer to a structure (e.g.) to hold this
+ * fixed-size data. If there is variable-length data, it would be
+ * expected that the reply function will have to allocate additional
+ * memory and store pointer(s) to that memory in the fixed-size
+ * structure. If the entire data is variable length (e.g., a single
+ * variable-length string), then the sender function would probably
+ * just pass a pointer to fixed-size space to hold a pointer, and the
+ * reply function would allocate the storage and store the pointer.
+ * It is the responsibility of the client receiving the reply to
+ * free up any memory allocated on it's behalf.
+ *
+ * We might be waiting for several different replies (a function can wait
+ * for a reply, and while calling IceProcessMessages, a callback can be
+ * invoked which will wait for another reply). We take advantage of the
+ * fact that for a given protocol, we are guaranteed that messages are
+ * processed in the order we sent them. So, everytime we have a new
+ * replyWait, we add it to the END of the 'saved_reply_waits' list. When
+ * we read a message and want to see if it matches a replyWait, we use the
+ * FIRST replyWait in the list with the major opcode of the message. If the
+ * reply is ready, we remove that replyWait from the list.
+ *
+ * If the reply/error is ready for the replyWait passed in to
+ * IceProcessMessages, *replyReadyRet is set to True.
+ *
+ * The return value of IceProcessMessages is one of the following:
+ *
+ * IceProcessMessagesSuccess - the message was processed successfully.
+ * IceProcessMessagesIOError - an IO error occured. The caller should
+ * invoked IceCloseConnection.
+ * IceProcessMessagesConnectionClosed - the connection was closed as a
+ * result of shutdown negotiation.
+ */
+
+IceProcessMessagesStatus
+IceProcessMessages (iceConn, replyWait, replyReadyRet)
+
+IceConn iceConn;
+IceReplyWaitInfo *replyWait;
+Bool *replyReadyRet;
+
+{
+ iceMsg *header;
+ Bool replyReady = False;
+ IceReplyWaitInfo *useThisReplyWait = NULL;
+ IceProcessMessagesStatus retStatus = IceProcessMessagesSuccess;
+
+ if (replyWait)
+ *replyReadyRet = False;
+
+ /*
+ * Each time IceProcessMessages is entered, we increment the dispatch
+ * level. Each time we leave it, we decrement the dispatch level.
+ */
+
+ iceConn->dispatch_level++;
+
+
+ /*
+ * Read the ICE message header.
+ */
+
+ if (!_IceRead (iceConn, (unsigned long) SIZEOF (iceMsg), iceConn->inbuf))
+ {
+ /*
+ * If we previously sent a WantToClose and now we detected
+ * that the connection was closed, _IceRead returns status 0.
+ * Since the connection was closed, we just want to return here.
+ */
+
+ return (IceProcessMessagesConnectionClosed);
+ }
+
+ if (!iceConn->io_ok)
+ {
+ /*
+ * An unexpected IO error occured. The caller of IceProcessMessages
+ * should call IceCloseConnection which will cause the watch procedures
+ * to be invoked and the ICE connection to be freed.
+ */
+
+ iceConn->dispatch_level--;
+ iceConn->connection_status = IceConnectIOError;
+ return (IceProcessMessagesIOError);
+ }
+
+ header = (iceMsg *) iceConn->inbuf;
+ iceConn->inbufptr = iceConn->inbuf + SIZEOF (iceMsg);
+
+ iceConn->receive_sequence++;
+
+ if (iceConn->waiting_for_byteorder)
+ {
+ if (header->majorOpcode == 0 &&
+ header->minorOpcode == ICE_ByteOrder)
+ {
+ char byteOrder = ((iceByteOrderMsg *) header)->byteOrder;
+ int endian = 1;
+
+ CHECK_SIZE_MATCH (iceConn, ICE_ByteOrder,
+ header->length, SIZEOF (iceByteOrderMsg),
+ IceFatalToConnection, IceProcessMessagesIOError);
+
+ if (byteOrder != IceMSBfirst && byteOrder != IceLSBfirst)
+ {
+ _IceErrorBadValue (iceConn, 0,
+ ICE_ByteOrder, 2, 1, &byteOrder);
+
+ iceConn->connection_status = IceConnectRejected;
+ }
+ else
+ {
+ iceConn->swap =
+ (((*(char *) &endian) && byteOrder == IceMSBfirst) ||
+ (!(*(char *) &endian) && byteOrder == IceLSBfirst));
+
+ iceConn->waiting_for_byteorder = 0;
+ }
+ }
+ else
+ {
+ if (header->majorOpcode != 0)
+ {
+ _IceErrorBadMajor (iceConn, header->majorOpcode,
+ header->minorOpcode, IceFatalToConnection);
+ }
+ else
+ {
+ _IceErrorBadState (iceConn, 0,
+ header->minorOpcode, IceFatalToConnection);
+ }
+
+ iceConn->connection_status = IceConnectRejected;
+ }
+
+ iceConn->dispatch_level--;
+ if (!iceConn->io_ok)
+ {
+ iceConn->connection_status = IceConnectIOError;
+ retStatus = IceProcessMessagesIOError;
+ }
+
+ return (retStatus);
+ }
+
+ if (iceConn->swap)
+ {
+ /* swap the length field */
+
+ header->length = lswapl (header->length);
+ }
+
+ if (replyWait)
+ {
+ /*
+ * Add to the list of replyWaits (only if it doesn't exist
+ * in the list already.
+ */
+
+ _IceAddReplyWait (iceConn, replyWait);
+
+ /*
+ * Note that there are two different replyWaits. The first is
+ * the one passed into IceProcessMessages, and is the replyWait
+ * for the message the client is blocking on. The second is
+ * the replyWait for the message currently being processed
+ * by IceProcessMessages. We call it "useThisReplyWait".
+ *
+ * Also, when two hosts communicate over an ICE connection and use
+ * different major opcodes for a subprotocol, it is impossible
+ * to use message replies unless we translate opcodes before
+ * comparing them.
+ */
+
+ {
+ int op;
+
+ if (header->majorOpcode == 0)
+ {
+ op = 0;
+ }
+ else
+ {
+ int idx = header->majorOpcode - iceConn->his_min_opcode;
+ op = iceConn->process_msg_info[idx].my_opcode;
+ }
+ useThisReplyWait = _IceSearchReplyWaits (iceConn, op);
+ }
+ }
+
+ if (header->majorOpcode == 0)
+ {
+ /*
+ * ICE protocol
+ */
+
+ Bool connectionClosed;
+
+ _IceProcessCoreMsgProc processIce =
+ _IceVersions[iceConn->my_ice_version_index].process_core_msg_proc;
+
+ (*processIce) (iceConn, header->minorOpcode,
+ header->length, iceConn->swap,
+ useThisReplyWait, &replyReady, &connectionClosed);
+
+ if (connectionClosed)
+ {
+ /*
+ * As a result of shutdown negotiation, the connection was closed.
+ */
+
+ return (IceProcessMessagesConnectionClosed);
+ }
+ }
+ else
+ {
+ /*
+ * Sub protocol
+ */
+
+ if ((int) header->majorOpcode < iceConn->his_min_opcode ||
+ (int) header->majorOpcode > iceConn->his_max_opcode ||
+ !(iceConn->process_msg_info[header->majorOpcode -
+ iceConn->his_min_opcode].in_use))
+ {
+ /*
+ * The protocol of the message we just read is not supported.
+ */
+
+ _IceErrorBadMajor (iceConn, header->majorOpcode,
+ header->minorOpcode, IceCanContinue);
+
+ _IceReadSkip (iceConn, header->length << 3);
+ }
+ else
+ {
+ _IceProcessMsgInfo *processMsgInfo = &iceConn->process_msg_info[
+ header->majorOpcode - iceConn->his_min_opcode];
+
+ if (processMsgInfo->accept_flag)
+ {
+ IcePaProcessMsgProc processProc =
+ processMsgInfo->process_msg_proc.accept_client;
+
+ (*processProc) (iceConn, processMsgInfo->client_data,
+ header->minorOpcode, header->length, iceConn->swap);
+ }
+ else
+ {
+ IcePoProcessMsgProc processProc =
+ processMsgInfo->process_msg_proc.orig_client;
+
+ (*processProc) (iceConn,
+ processMsgInfo->client_data, header->minorOpcode,
+ header->length, iceConn->swap,
+ useThisReplyWait, &replyReady);
+ }
+ }
+ }
+
+ if (replyReady)
+ {
+ _IceSetReplyReady (iceConn, useThisReplyWait);
+ }
+
+
+ /*
+ * Now we check if the reply is ready for the replyWait passed
+ * into IceProcessMessages. The replyWait is removed from the
+ * replyWait list if it is ready.
+ */
+
+ if (replyWait)
+ *replyReadyRet = _IceCheckReplyReady (iceConn, replyWait);
+
+
+ /*
+ * Decrement the dispatch level. If we reach level 0, and the
+ * free_asap bit is set, free the connection now. Also check for
+ * possible bad IO status.
+ */
+
+ iceConn->dispatch_level--;
+
+ if (iceConn->dispatch_level == 0 && iceConn->free_asap)
+ {
+ _IceFreeConnection (iceConn);
+ retStatus = IceProcessMessagesConnectionClosed;
+ }
+ else if (!iceConn->io_ok)
+ {
+ iceConn->connection_status = IceConnectIOError;
+ retStatus = IceProcessMessagesIOError;
+ }
+
+ return (retStatus);
+}
+
+
+
+static void
+AuthRequired (iceConn, authIndex, authDataLen, authData)
+
+IceConn iceConn;
+int authIndex;
+int authDataLen;
+IcePointer authData;
+
+{
+ iceAuthRequiredMsg *pMsg;
+
+ IceGetHeader (iceConn, 0, ICE_AuthRequired,
+ SIZEOF (iceAuthRequiredMsg), iceAuthRequiredMsg, pMsg);
+
+ pMsg->authIndex = authIndex;
+ pMsg->authDataLength = authDataLen;
+ pMsg->length += WORD64COUNT (authDataLen);
+
+ IceWriteData (iceConn, authDataLen, (char *) authData);
+
+ if (PAD64 (authDataLen))
+ IceWritePad (iceConn, PAD64 (authDataLen));
+
+ IceFlush (iceConn);
+}
+
+
+
+static void
+AuthReply (iceConn, authDataLen, authData)
+
+IceConn iceConn;
+int authDataLen;
+IcePointer authData;
+
+{
+ iceAuthReplyMsg *pMsg;
+
+ IceGetHeader (iceConn, 0, ICE_AuthReply,
+ SIZEOF (iceAuthReplyMsg), iceAuthReplyMsg, pMsg);
+
+ pMsg->authDataLength = authDataLen;
+ pMsg->length += WORD64COUNT (authDataLen);
+
+ IceWriteData (iceConn, authDataLen, (char *) authData);
+
+ if (PAD64 (authDataLen))
+ IceWritePad (iceConn, PAD64 (authDataLen));
+
+ IceFlush (iceConn);
+}
+
+
+
+static void
+AuthNextPhase (iceConn, authDataLen, authData)
+
+IceConn iceConn;
+int authDataLen;
+IcePointer authData;
+
+{
+ iceAuthNextPhaseMsg *pMsg;
+
+ IceGetHeader (iceConn, 0, ICE_AuthNextPhase,
+ SIZEOF (iceAuthNextPhaseMsg), iceAuthNextPhaseMsg, pMsg);
+
+ pMsg->authDataLength = authDataLen;
+ pMsg->length += WORD64COUNT (authDataLen);
+
+ IceWriteData (iceConn, authDataLen, (char *) authData);
+
+ if (PAD64 (authDataLen))
+ IceWritePad (iceConn, PAD64 (authDataLen));
+
+ IceFlush (iceConn);
+}
+
+
+
+static void
+AcceptConnection (iceConn, versionIndex)
+
+IceConn iceConn;
+int versionIndex;
+
+{
+ iceConnectionReplyMsg *pMsg;
+ char *pData;
+ int extra;
+
+ extra = STRING_BYTES (IceVendorString) + STRING_BYTES (IceReleaseString);
+
+ IceGetHeaderExtra (iceConn, 0, ICE_ConnectionReply,
+ SIZEOF (iceConnectionReplyMsg), WORD64COUNT (extra),
+ iceConnectionReplyMsg, pMsg, pData);
+
+ pMsg->versionIndex = versionIndex;
+
+ STORE_STRING (pData, IceVendorString);
+ STORE_STRING (pData, IceReleaseString);
+
+ IceFlush (iceConn);
+
+ iceConn->connection_status = IceConnectAccepted;
+}
+
+
+
+static void
+AcceptProtocol (iceConn, hisOpcode, myOpcode, versionIndex, vendor, release)
+
+IceConn iceConn;
+int hisOpcode;
+int myOpcode;
+int versionIndex;
+char *vendor;
+char *release;
+
+{
+ iceProtocolReplyMsg *pMsg;
+ char *pData;
+ int extra;
+
+ extra = STRING_BYTES (vendor) + STRING_BYTES (release);
+
+ IceGetHeaderExtra (iceConn, 0, ICE_ProtocolReply,
+ SIZEOF (iceProtocolReplyMsg), WORD64COUNT (extra),
+ iceProtocolReplyMsg, pMsg, pData);
+
+ pMsg->protocolOpcode = myOpcode;
+ pMsg->versionIndex = versionIndex;
+
+ STORE_STRING (pData, vendor);
+ STORE_STRING (pData, release);
+
+ IceFlush (iceConn);
+
+
+ /*
+ * We may be using a different major opcode for this protocol
+ * than the other client. Whenever we get a message, we must
+ * map to our own major opcode.
+ */
+
+ _IceAddOpcodeMapping (iceConn, hisOpcode, myOpcode);
+}
+
+
+
+static void
+PingReply (iceConn)
+
+IceConn iceConn;
+
+{
+ IceSimpleMessage (iceConn, 0, ICE_PingReply);
+ IceFlush (iceConn);
+}
+
+
+
+static Bool
+ProcessError (iceConn, length, swap, replyWait)
+
+IceConn iceConn;
+unsigned long length;
+Bool swap;
+IceReplyWaitInfo *replyWait;
+
+{
+ int invokeHandler = 0;
+ Bool errorReturned = False;
+ iceErrorMsg *message;
+ char *pData, *pStart;
+ char severity;
+
+ CHECK_AT_LEAST_SIZE (iceConn, ICE_Error,
+ length, SIZEOF (iceErrorMsg),
+ (iceConn->connect_to_you || iceConn->connect_to_me) ?
+ IceFatalToConnection : IceFatalToProtocol);
+
+ IceReadCompleteMessage (iceConn, SIZEOF (iceErrorMsg),
+ iceErrorMsg, message, pStart);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+ }
+
+ severity = message->severity;
+
+ if (severity != IceCanContinue && severity != IceFatalToProtocol &&
+ severity != IceFatalToConnection)
+ {
+ _IceErrorBadValue (iceConn, 0,
+ ICE_Error, 9, 1, &severity);
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+ }
+
+ pData = pStart;
+
+ if (swap)
+ {
+ message->errorClass = lswaps (message->errorClass);
+ message->offendingSequenceNum = lswapl (message->offendingSequenceNum);
+ }
+
+ if (!replyWait ||
+ message->offendingSequenceNum != replyWait->sequence_of_request)
+ {
+ invokeHandler = 1;
+ }
+ else
+ {
+ if (iceConn->connect_to_you &&
+ ((!iceConn->connect_to_you->auth_active &&
+ message->offendingMinorOpcode == ICE_ConnectionSetup) ||
+ (iceConn->connect_to_you->auth_active &&
+ message->offendingMinorOpcode == ICE_AuthReply)))
+ {
+ _IceConnectionError *errorReply =
+ &(((_IceReply *) (replyWait->reply))->connection_error);
+ char *errorStr = NULL;
+ char *tempstr;
+ char *prefix, *temp;
+
+ invokeHandler = 0;
+ errorReturned = True;
+
+ switch (message->errorClass)
+ {
+ case IceNoVersion:
+
+ tempstr =
+ "None of the ICE versions specified are supported";
+ errorStr = (char *) malloc (strlen (tempstr) + 1);
+ strcpy (errorStr, tempstr);
+ break;
+
+ case IceNoAuth:
+
+ tempstr =
+ "None of the authentication protocols specified are supported";
+ errorStr = (char *) malloc (strlen (tempstr) + 1);
+ strcpy (errorStr, tempstr);
+ break;
+
+ case IceSetupFailed:
+
+ prefix = "Connection Setup Failed, reason : ";
+
+ EXTRACT_STRING (pData, swap, temp);
+ errorStr = (char *) malloc (
+ strlen (prefix) + strlen (temp) + 1);
+ sprintf (errorStr, "%s%s", prefix, temp);
+ free (temp);
+ break;
+
+ case IceAuthRejected:
+
+ prefix = "Authentication Rejected, reason : ";
+ EXTRACT_STRING (pData, swap, temp);
+ errorStr = (char *) malloc (
+ strlen (prefix) + strlen (temp) + 1);
+ sprintf (errorStr, "%s%s", prefix, temp);
+ free (temp);
+ break;
+
+ case IceAuthFailed:
+
+ prefix = "Authentication Failed, reason : ";
+ EXTRACT_STRING (pData, swap, temp);
+ errorStr = (char *) malloc (
+ strlen (prefix) + strlen (temp) + 1);
+ sprintf (errorStr, "%s%s", prefix, temp);
+ free (temp);
+ break;
+
+ default:
+ invokeHandler = 1;
+ }
+
+ errorReply->type = ICE_CONNECTION_ERROR;
+ errorReply->error_message = errorStr;
+ }
+ else if (iceConn->protosetup_to_you &&
+ ((!iceConn->protosetup_to_you->auth_active &&
+ message->offendingMinorOpcode == ICE_ProtocolSetup) ||
+ (iceConn->protosetup_to_you->auth_active &&
+ message->offendingMinorOpcode == ICE_AuthReply)))
+ {
+ _IceProtocolError *errorReply =
+ &(((_IceReply *) (replyWait->reply))->protocol_error);
+ char *errorStr = "";
+ char *prefix, *temp;
+
+ invokeHandler = 0;
+ errorReturned = True;
+
+ switch (message->errorClass)
+ {
+ case IceNoVersion:
+
+ temp =
+ "None of the protocol versions specified are supported";
+ errorStr = (char *) malloc (strlen (temp) + 1);
+ strcpy (errorStr, temp);
+ break;
+
+ case IceNoAuth:
+
+ temp =
+ "None of the authentication protocols specified are supported";
+ errorStr = (char *) malloc (strlen (temp) + 1);
+ strcpy (errorStr, temp);
+ break;
+
+ case IceSetupFailed:
+
+ prefix = "Protocol Setup Failed, reason : ";
+
+ EXTRACT_STRING (pData, swap, temp);
+ errorStr = (char *) malloc (
+ strlen (prefix) + strlen (temp) + 1);
+ sprintf (errorStr, "%s%s", prefix, temp);
+ free (temp);
+ break;
+
+ case IceAuthRejected:
+
+ prefix = "Authentication Rejected, reason : ";
+ EXTRACT_STRING (pData, swap, temp);
+ errorStr = (char *) malloc (
+ strlen (prefix) + strlen (temp) + 1);
+ sprintf (errorStr, "%s%s", prefix, temp);
+ free (temp);
+ break;
+
+ case IceAuthFailed:
+
+ prefix = "Authentication Failed, reason : ";
+ EXTRACT_STRING (pData, swap, temp);
+ errorStr = (char *) malloc (
+ strlen (prefix) + strlen (temp) + 1);
+ sprintf (errorStr, "%s%s", prefix, temp);
+ free (temp);
+ break;
+
+ case IceProtocolDuplicate:
+
+ prefix = "Protocol was already registered : ";
+ EXTRACT_STRING (pData, swap, temp);
+ errorStr = (char *) malloc (
+ strlen (prefix) + strlen (temp) + 1);
+ sprintf (errorStr, "%s%s", prefix, temp);
+ free (temp);
+ break;
+
+ case IceMajorOpcodeDuplicate:
+
+ prefix = "The major opcode was already used : ";
+ errorStr = (char *) malloc (strlen (prefix) + 2);
+ sprintf (errorStr, "%s%d", prefix, (int) *pData);
+ break;
+
+ case IceUnknownProtocol:
+
+ prefix = "Unknown Protocol : ";
+ EXTRACT_STRING (pData, swap, temp);
+ errorStr = (char *) malloc (
+ strlen (prefix) + strlen (temp) + 1);
+ sprintf (errorStr, "%s%s", prefix, temp);
+ free (temp);
+ break;
+
+ default:
+ invokeHandler = 1;
+ }
+
+ errorReply->type = ICE_PROTOCOL_ERROR;
+ errorReply->error_message = errorStr;
+ }
+
+ if (errorReturned == True)
+ {
+ /*
+ * If we tried to authenticate, tell the authentication
+ * procedure to clean up.
+ */
+
+ IcePoAuthProc authProc;
+
+ if (iceConn->connect_to_you &&
+ iceConn->connect_to_you->auth_active)
+ {
+ authProc = _IcePoAuthProcs[(int)
+ (iceConn->connect_to_you->my_auth_index)];
+
+ (*authProc) (iceConn, &iceConn->connect_to_you->my_auth_state,
+ True /* clean up */, False /* swap */,
+ 0, NULL, NULL, NULL, NULL);
+ }
+ else if (iceConn->protosetup_to_you &&
+ iceConn->protosetup_to_you->auth_active)
+ {
+ _IcePoProtocol *protocol = _IceProtocols[
+ iceConn->protosetup_to_you->my_opcode - 1].orig_client;
+
+ authProc = protocol->auth_procs[(int)(iceConn->
+ protosetup_to_you->my_auth_index)];
+
+ (*authProc) (iceConn,
+ &iceConn->protosetup_to_you->my_auth_state,
+ True /* clean up */, False /* swap */,
+ 0, NULL, NULL, NULL, NULL);
+ }
+ }
+ }
+
+ if (invokeHandler)
+ {
+ (*_IceErrorHandler) (iceConn, swap, message->offendingMinorOpcode,
+ message->offendingSequenceNum, message->errorClass,
+ message->severity, (IcePointer) pData);
+ }
+
+ IceDisposeCompleteMessage (iceConn, pStart);
+
+ return (errorReturned);
+}
+
+
+
+static int
+ProcessConnectionSetup (iceConn, length, swap)
+
+IceConn iceConn;
+unsigned long length;
+Bool swap;
+
+{
+ iceConnectionSetupMsg *message;
+ int myVersionCount, hisVersionCount;
+ int myVersionIndex, hisVersionIndex;
+ int hisMajorVersion, hisMinorVersion;
+ int myAuthCount, hisAuthCount;
+ int found, i, j;
+ char *myAuthName, **hisAuthNames = NULL;
+ char *pData, *pStart, *pEnd;
+ char *vendor = NULL;
+ char *release = NULL;
+ int myAuthIndex = 0;
+ int hisAuthIndex = 0;
+ int accept_setup_now = 0;
+ char mustAuthenticate;
+ int authUsableCount;
+ int authUsableFlags[MAX_ICE_AUTH_NAMES];
+ int authIndices[MAX_ICE_AUTH_NAMES];
+
+ CHECK_AT_LEAST_SIZE (iceConn, ICE_ConnectionSetup,
+ length, SIZEOF (iceConnectionSetupMsg), IceFatalToConnection);
+
+ IceReadCompleteMessage (iceConn, SIZEOF (iceConnectionSetupMsg),
+ iceConnectionSetupMsg, message, pStart);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+ }
+
+ pData = pStart;
+ pEnd = pStart + (length << 3);
+
+ SKIP_STRING (pData, swap, pEnd,
+ BAIL_STRING(iceConn, ICE_ConnectionSetup,
+ pStart)); /* vendor */
+ SKIP_STRING (pData, swap, pEnd,
+ BAIL_STRING(iceConn, ICE_ConnectionSetup,
+ pStart)); /* release */
+ SKIP_LISTOF_STRING (pData, swap, (int) message->authCount, pEnd,
+ BAIL_STRING(iceConn, ICE_ConnectionSetup,
+ pStart)); /* auth names */
+
+ pData += (message->versionCount * 4); /* versions */
+
+ CHECK_COMPLETE_SIZE (iceConn, ICE_ConnectionSetup,
+ length, pData - pStart + SIZEOF (iceConnectionSetupMsg),
+ pStart, IceFatalToConnection);
+
+ mustAuthenticate = message->mustAuthenticate;
+ if (mustAuthenticate != 0 && mustAuthenticate != 1)
+ {
+ _IceErrorBadValue (iceConn, 0,
+ ICE_ConnectionSetup, 8, 1, &mustAuthenticate);
+ iceConn->connection_status = IceConnectRejected;
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+ }
+
+ pData = pStart;
+
+ EXTRACT_STRING (pData, swap, vendor);
+ EXTRACT_STRING (pData, swap, release);
+
+ if ((hisAuthCount = message->authCount) > 0)
+ {
+ hisAuthNames = (char **) malloc (hisAuthCount * sizeof (char *));
+ EXTRACT_LISTOF_STRING (pData, swap, hisAuthCount, hisAuthNames);
+ }
+
+ hisVersionCount = message->versionCount;
+ myVersionCount = _IceVersionCount;
+
+ hisVersionIndex = myVersionIndex = found = 0;
+
+ for (i = 0; i < hisVersionCount && !found; i++)
+ {
+ EXTRACT_CARD16 (pData, swap, hisMajorVersion);
+ EXTRACT_CARD16 (pData, swap, hisMinorVersion);
+
+ for (j = 0; j < myVersionCount && !found; j++)
+ {
+ if (_IceVersions[j].major_version == hisMajorVersion &&
+ _IceVersions[j].minor_version == hisMinorVersion)
+ {
+ hisVersionIndex = i;
+ myVersionIndex = j;
+ found = 1;
+ }
+ }
+ }
+
+ if (!found)
+ {
+ _IceErrorNoVersion (iceConn, ICE_ConnectionSetup);
+ iceConn->connection_status = IceConnectRejected;
+
+ free (vendor);
+ free (release);
+
+ if (hisAuthCount > 0)
+ {
+ for (i = 0; i < hisAuthCount; i++)
+ free (hisAuthNames[i]);
+
+ free ((char *) hisAuthNames);
+ }
+
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+ }
+
+ _IceGetPaValidAuthIndices ("ICE", iceConn->connection_string,
+ _IceAuthCount, _IceAuthNames, &authUsableCount, authIndices);
+
+ for (i = 0; i < _IceAuthCount; i++)
+ {
+ authUsableFlags[i] = 0;
+ for (j = 0; j < authUsableCount && !authUsableFlags[i]; j++)
+ authUsableFlags[i] = (authIndices[j] == i);
+ }
+
+ myAuthCount = _IceAuthCount;
+
+ for (i = found = 0; i < myAuthCount && !found; i++)
+ {
+ if (authUsableFlags[i])
+ {
+ myAuthName = _IceAuthNames[i];
+
+ for (j = 0; j < hisAuthCount && !found; j++)
+ if (strcmp (myAuthName, hisAuthNames[j]) == 0)
+ {
+ myAuthIndex = i;
+ hisAuthIndex = j;
+ found = 1;
+ }
+ }
+ }
+
+ if (!found)
+ {
+ /*
+ * None of the authentication methods specified by the
+ * other client is supported. If the other client requires
+ * authentication, we must reject the connection now.
+ * Otherwise, we can invoke the host-based authentication callback
+ * to see if we can accept this connection.
+ */
+
+ if (mustAuthenticate || !iceConn->listen_obj->host_based_auth_proc)
+ {
+ _IceErrorNoAuthentication (iceConn, ICE_ConnectionSetup);
+ iceConn->connection_status = IceConnectRejected;
+ }
+ else
+ {
+ char *hostname = _IceGetPeerName (iceConn);
+
+ if ((*iceConn->listen_obj->host_based_auth_proc) (hostname))
+ {
+ accept_setup_now = 1;
+ }
+ else
+ {
+ _IceErrorAuthenticationRejected (iceConn,
+ ICE_ConnectionSetup, "None of the authentication protocols specified are supported and host-based authentication failed");
+
+ iceConn->connection_status = IceConnectRejected;
+ }
+
+ if (hostname)
+ free (hostname);
+ }
+
+ if (iceConn->connection_status == IceConnectRejected)
+ {
+ free (vendor);
+ free (release);
+ }
+ }
+ else
+ {
+ IcePaAuthStatus status;
+ int authDataLen;
+ IcePointer authData = NULL;
+ IcePointer authState;
+ char *errorString = NULL;
+ IcePaAuthProc authProc = _IcePaAuthProcs[myAuthIndex];
+
+ authState = NULL;
+
+ status = (*authProc) (iceConn, &authState,
+ swap, 0, NULL, &authDataLen, &authData, &errorString);
+
+ if (status == IcePaAuthContinue)
+ {
+ _IceConnectToMeInfo *setupInfo;
+
+ AuthRequired (iceConn, hisAuthIndex, authDataLen, authData);
+
+ iceConn->connect_to_me = setupInfo = (_IceConnectToMeInfo *)
+ malloc (sizeof (_IceConnectToMeInfo));
+
+ setupInfo->my_version_index = myVersionIndex;
+ setupInfo->his_version_index = hisVersionIndex;
+ setupInfo->his_vendor = vendor;
+ setupInfo->his_release = release;
+ setupInfo->my_auth_index = myAuthIndex;
+ setupInfo->my_auth_state = authState;
+ setupInfo->must_authenticate = mustAuthenticate;
+ }
+ else if (status == IcePaAuthAccepted)
+ {
+ accept_setup_now = 1;
+ }
+
+ if (authData && authDataLen > 0)
+ free ((char *) authData);
+
+ if (errorString)
+ free (errorString);
+ }
+
+ if (accept_setup_now)
+ {
+ AcceptConnection (iceConn, hisVersionIndex);
+
+ iceConn->vendor = vendor;
+ iceConn->release = release;
+ iceConn->my_ice_version_index = myVersionIndex;
+ }
+
+ if (hisAuthCount > 0)
+ {
+ for (i = 0; i < hisAuthCount; i++)
+ free (hisAuthNames[i]);
+
+ free ((char *) hisAuthNames);
+ }
+
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+}
+
+
+
+static Bool
+ProcessAuthRequired (iceConn, length, swap, replyWait)
+
+IceConn iceConn;
+unsigned long length;
+Bool swap;
+IceReplyWaitInfo *replyWait;
+
+{
+ iceAuthRequiredMsg *message;
+ int authDataLen;
+ IcePointer authData;
+ int replyDataLen;
+ IcePointer replyData = NULL;
+ char *errorString = NULL;
+ IcePoAuthProc authProc;
+ IcePoAuthStatus status;
+ IcePointer authState;
+ int realAuthIndex = 0;
+
+ CHECK_AT_LEAST_SIZE (iceConn, ICE_AuthRequired,
+ length, SIZEOF (iceAuthRequiredMsg),
+ iceConn->connect_to_you ? IceFatalToConnection : IceFatalToProtocol);
+
+ IceReadCompleteMessage (iceConn, SIZEOF (iceAuthRequiredMsg),
+ iceAuthRequiredMsg, message, authData);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, authData);
+ return (0);
+ }
+
+ if (swap)
+ {
+ message->authDataLength = lswaps (message->authDataLength);
+ }
+
+ CHECK_COMPLETE_SIZE (iceConn, ICE_AuthRequired, length,
+ message->authDataLength + SIZEOF (iceAuthRequiredMsg), authData,
+ iceConn->connect_to_you ? IceFatalToConnection : IceFatalToProtocol);
+
+ if (iceConn->connect_to_you)
+ {
+ if ((int) message->authIndex >= _IceAuthCount)
+ {
+ _IceConnectionError *errorReply =
+ &(((_IceReply *) (replyWait->reply))->connection_error);
+
+ char *tempstr = "Received bad authIndex in the AuthRequired message";
+ char errIndex = (int) message->authIndex;
+
+ errorString = (char *) malloc (strlen (tempstr) + 1);
+ strcpy (errorString, tempstr);
+
+ errorReply->type = ICE_CONNECTION_ERROR;
+ errorReply->error_message = errorString;
+
+ _IceErrorBadValue (iceConn, 0,
+ ICE_AuthRequired, 2, 1, &errIndex);
+
+ IceDisposeCompleteMessage (iceConn, authData);
+ return (1);
+ }
+ else
+ {
+ authProc = _IcePoAuthProcs[message->authIndex];
+
+ iceConn->connect_to_you->auth_active = 1;
+ }
+ }
+ else if (iceConn->protosetup_to_you)
+ {
+ if ((int) message->authIndex >=
+ iceConn->protosetup_to_you->my_auth_count)
+ {
+ _IceProtocolError *errorReply =
+ &(((_IceReply *) (replyWait->reply))->protocol_error);
+
+ char *tempstr = "Received bad authIndex in the AuthRequired message";
+ char errIndex = (int) message->authIndex;
+
+ errorString = (char *) malloc (strlen (tempstr) + 1);
+ strcpy (errorString, tempstr);
+
+ errorReply->type = ICE_PROTOCOL_ERROR;
+ errorReply->error_message = errorString;
+
+ _IceErrorBadValue (iceConn, 0,
+ ICE_AuthRequired, 2, 1, &errIndex);
+
+ IceDisposeCompleteMessage (iceConn, authData);
+ return (1);
+ }
+ else
+ {
+ _IcePoProtocol *myProtocol = _IceProtocols[
+ iceConn->protosetup_to_you->my_opcode - 1].orig_client;
+
+ realAuthIndex = iceConn->protosetup_to_you->
+ my_auth_indices[message->authIndex];
+
+ authProc = myProtocol->auth_procs[realAuthIndex];
+
+ iceConn->protosetup_to_you->auth_active = 1;
+ }
+ }
+ else
+ {
+ /*
+ * Unexpected message
+ */
+
+ _IceErrorBadState (iceConn, 0, ICE_AuthRequired, IceCanContinue);
+
+ IceDisposeCompleteMessage (iceConn, authData);
+ return (0);
+ }
+
+ authState = NULL;
+ authDataLen = message->authDataLength;
+
+ status = (*authProc) (iceConn, &authState, False /* don't clean up */,
+ swap, authDataLen, authData, &replyDataLen, &replyData, &errorString);
+
+ if (status == IcePoAuthHaveReply)
+ {
+ AuthReply (iceConn, replyDataLen, replyData);
+
+ replyWait->sequence_of_request = iceConn->send_sequence;
+ replyWait->minor_opcode_of_request = ICE_AuthReply;
+
+ if (iceConn->connect_to_you)
+ {
+ iceConn->connect_to_you->my_auth_state = authState;
+ iceConn->connect_to_you->my_auth_index = message->authIndex;
+ }
+ else if (iceConn->protosetup_to_you)
+ {
+ iceConn->protosetup_to_you->my_auth_state = authState;
+ iceConn->protosetup_to_you->my_auth_index = realAuthIndex;
+ }
+ }
+ else if (status == IcePoAuthRejected || status == IcePoAuthFailed)
+ {
+ char *prefix, *returnErrorString;
+
+ if (status == IcePoAuthRejected)
+ {
+ _IceErrorAuthenticationRejected (iceConn,
+ ICE_AuthRequired, errorString);
+
+ prefix = "Authentication Rejected, reason : ";
+ }
+ else
+ {
+ _IceErrorAuthenticationFailed (iceConn,
+ ICE_AuthRequired, errorString);
+
+ prefix = "Authentication Failed, reason : ";
+ }
+
+ returnErrorString = (char *) malloc (strlen (prefix) +
+ strlen (errorString) + 1);
+ sprintf (returnErrorString, "%s%s", prefix, errorString);
+ free (errorString);
+
+ if (iceConn->connect_to_you)
+ {
+ _IceConnectionError *errorReply =
+ &(((_IceReply *) (replyWait->reply))->connection_error);
+
+ errorReply->type = ICE_CONNECTION_ERROR;
+ errorReply->error_message = returnErrorString;
+ }
+ else
+ {
+ _IceProtocolError *errorReply =
+ &(((_IceReply *) (replyWait->reply))->protocol_error);
+
+ errorReply->type = ICE_PROTOCOL_ERROR;
+ errorReply->error_message = returnErrorString;
+ }
+ }
+
+ if (replyData && replyDataLen > 0)
+ free ((char *) replyData);
+
+ IceDisposeCompleteMessage (iceConn, authData);
+
+ return (status != IcePoAuthHaveReply);
+}
+
+
+
+static int
+ProcessAuthReply (iceConn, length, swap)
+
+IceConn iceConn;
+unsigned long length;
+Bool swap;
+
+{
+ iceAuthReplyMsg *message;
+ int replyDataLen;
+ IcePointer replyData;
+ int authDataLen;
+ IcePointer authData = NULL;
+ char *errorString = NULL;
+
+ CHECK_AT_LEAST_SIZE (iceConn, ICE_AuthReply,
+ length, SIZEOF (iceAuthReplyMsg),
+ iceConn->connect_to_me ? IceFatalToConnection : IceFatalToProtocol);
+
+ IceReadCompleteMessage (iceConn, SIZEOF (iceAuthReplyMsg),
+ iceAuthReplyMsg, message, replyData);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, replyData);
+ return (0);
+ }
+
+ if (swap)
+ {
+ message->authDataLength = lswaps (message->authDataLength);
+ }
+
+ CHECK_COMPLETE_SIZE (iceConn, ICE_AuthReply, length,
+ message->authDataLength + SIZEOF (iceAuthReplyMsg), replyData,
+ iceConn->connect_to_me ? IceFatalToConnection : IceFatalToProtocol);
+
+ replyDataLen = message->authDataLength;
+
+ if (iceConn->connect_to_me)
+ {
+ IcePaAuthProc authProc = _IcePaAuthProcs[(int)
+ (iceConn->connect_to_me->my_auth_index)];
+ IcePaAuthStatus status =
+ (*authProc) (iceConn, &iceConn->connect_to_me->my_auth_state, swap,
+ replyDataLen, replyData, &authDataLen, &authData, &errorString);
+
+ if (status == IcePaAuthContinue)
+ {
+ AuthNextPhase (iceConn, authDataLen, authData);
+ }
+ else if (status == IcePaAuthRejected || status == IcePaAuthFailed)
+ {
+ /*
+ * Before we reject, invoke host-based authentication callback
+ * and give it a chance to accept the connection (only if the
+ * other client doesn't require authentication).
+ */
+
+ if (!iceConn->connect_to_me->must_authenticate &&
+ iceConn->listen_obj->host_based_auth_proc)
+ {
+ char *hostname = _IceGetPeerName (iceConn);
+
+ if ((*iceConn->listen_obj->host_based_auth_proc) (hostname))
+ {
+ status = IcePaAuthAccepted;
+ }
+
+ if (hostname)
+ free (hostname);
+ }
+
+ if (status != IcePaAuthAccepted)
+ {
+ free (iceConn->connect_to_me->his_vendor);
+ free (iceConn->connect_to_me->his_release);
+ free ((char *) iceConn->connect_to_me);
+ iceConn->connect_to_me = NULL;
+
+ iceConn->connection_status = IceConnectRejected;
+
+ if (status == IcePaAuthRejected)
+ {
+ _IceErrorAuthenticationRejected (iceConn,
+ ICE_AuthReply, errorString);
+ }
+ else
+ {
+ _IceErrorAuthenticationFailed (iceConn,
+ ICE_AuthReply, errorString);
+ }
+ }
+ }
+
+ if (status == IcePaAuthAccepted)
+ {
+ AcceptConnection (iceConn,
+ iceConn->connect_to_me->his_version_index);
+
+ iceConn->vendor = iceConn->connect_to_me->his_vendor;
+ iceConn->release = iceConn->connect_to_me->his_release;
+ iceConn->my_ice_version_index =
+ iceConn->connect_to_me->my_version_index;
+
+ free ((char *) iceConn->connect_to_me);
+ iceConn->connect_to_me = NULL;
+ }
+ }
+ else if (iceConn->protosetup_to_me)
+ {
+ _IcePaProtocol *myProtocol = _IceProtocols[iceConn->protosetup_to_me->
+ my_opcode - 1].accept_client;
+ IcePaAuthProc authProc = myProtocol->auth_procs[(int)
+ (iceConn->protosetup_to_me->my_auth_index)];
+ IcePaAuthStatus status =
+ (*authProc) (iceConn, &iceConn->protosetup_to_me->my_auth_state,
+ swap, replyDataLen, replyData,
+ &authDataLen, &authData, &errorString);
+ int free_setup_info = 1;
+
+ if (status == IcePaAuthContinue)
+ {
+ AuthNextPhase (iceConn, authDataLen, authData);
+ free_setup_info = 0;
+ }
+ else if (status == IcePaAuthRejected || status == IcePaAuthFailed)
+ {
+ /*
+ * Before we reject, invoke host-based authentication callback
+ * and give it a chance to accept the Protocol Setup (only if the
+ * other client doesn't require authentication).
+ */
+
+ if (!iceConn->protosetup_to_me->must_authenticate &&
+ myProtocol->host_based_auth_proc)
+ {
+ char *hostname = _IceGetPeerName (iceConn);
+
+ if ((*myProtocol->host_based_auth_proc) (hostname))
+ {
+ status = IcePaAuthAccepted;
+ }
+
+ if (hostname)
+ free (hostname);
+ }
+
+ if (status == IcePaAuthRejected)
+ {
+ _IceErrorAuthenticationRejected (iceConn,
+ ICE_AuthReply, errorString);
+ }
+ else
+ {
+ _IceErrorAuthenticationFailed (iceConn,
+ ICE_AuthReply, errorString);
+ }
+ }
+
+ if (status == IcePaAuthAccepted)
+ {
+ IcePaProcessMsgProc processMsgProc;
+ IceProtocolSetupProc protocolSetupProc;
+ IceProtocolActivateProc protocolActivateProc;
+ _IceProcessMsgInfo *process_msg_info;
+ IcePointer clientData = NULL;
+ char *failureReason = NULL;
+ Status status = 1;
+
+ protocolSetupProc = myProtocol->protocol_setup_proc;
+ protocolActivateProc = myProtocol->protocol_activate_proc;
+
+ if (protocolSetupProc)
+ {
+ /*
+ * Notify the client of the Protocol Setup.
+ */
+
+ status = (*protocolSetupProc) (iceConn,
+ myProtocol->version_recs[iceConn->protosetup_to_me->
+ my_version_index].major_version,
+ myProtocol->version_recs[iceConn->protosetup_to_me->
+ my_version_index].minor_version,
+ iceConn->protosetup_to_me->his_vendor,
+ iceConn->protosetup_to_me->his_release,
+ &clientData, &failureReason);
+
+ /*
+ * Set vendor and release pointers to NULL, so it won't
+ * get freed below. The ProtocolSetupProc should
+ * free it.
+ */
+
+ iceConn->protosetup_to_me->his_vendor = NULL;
+ iceConn->protosetup_to_me->his_release = NULL;
+ }
+
+ if (status != 0)
+ {
+ /*
+ * Send the Protocol Reply
+ */
+
+ AcceptProtocol (iceConn,
+ iceConn->protosetup_to_me->his_opcode,
+ iceConn->protosetup_to_me->my_opcode,
+ iceConn->protosetup_to_me->his_version_index,
+ myProtocol->vendor, myProtocol->release);
+
+
+ /*
+ * Set info for this protocol.
+ */
+
+ processMsgProc = myProtocol->version_recs[
+ iceConn->protosetup_to_me->
+ my_version_index].process_msg_proc;
+
+ process_msg_info = &iceConn->process_msg_info[
+ iceConn->protosetup_to_me->
+ his_opcode -iceConn->his_min_opcode];
+
+ process_msg_info->client_data = clientData;
+ process_msg_info->accept_flag = 1;
+ process_msg_info->process_msg_proc.
+ accept_client = processMsgProc;
+
+
+ /*
+ * Increase the reference count for the number
+ * of active protocols.
+ */
+
+ iceConn->proto_ref_count++;
+
+
+ /*
+ * Notify the client that the protocol is active. The reason
+ * we have this 2nd callback invoked is because the client
+ * may wish to immediately generate a message for this
+ * protocol, but it must wait until we send the Protocol Reply.
+ */
+
+ if (protocolActivateProc)
+ {
+ (*protocolActivateProc) (iceConn,
+ process_msg_info->client_data);
+ }
+ }
+ else
+ {
+ /*
+ * An error was encountered.
+ */
+
+ _IceErrorSetupFailed (iceConn, ICE_ProtocolSetup,
+ failureReason);
+
+ if (failureReason)
+ free (failureReason);
+ }
+ }
+
+
+ if (free_setup_info)
+ {
+ if (iceConn->protosetup_to_me->his_vendor)
+ free (iceConn->protosetup_to_me->his_vendor);
+ if (iceConn->protosetup_to_me->his_release)
+ free (iceConn->protosetup_to_me->his_release);
+ free ((char *) iceConn->protosetup_to_me);
+ iceConn->protosetup_to_me = NULL;
+ }
+ }
+ else
+ {
+ /*
+ * Unexpected message
+ */
+
+ _IceErrorBadState (iceConn, 0, ICE_AuthReply, IceCanContinue);
+ }
+
+ if (authData && authDataLen > 0)
+ free ((char *) authData);
+
+ if (errorString)
+ free (errorString);
+
+ IceDisposeCompleteMessage (iceConn, replyData);
+ return (0);
+}
+
+
+
+static Bool
+ProcessAuthNextPhase (iceConn, length, swap, replyWait)
+
+IceConn iceConn;
+unsigned long length;
+Bool swap;
+IceReplyWaitInfo *replyWait;
+
+{
+ iceAuthNextPhaseMsg *message;
+ int authDataLen;
+ IcePointer authData;
+ int replyDataLen;
+ IcePointer replyData = NULL;
+ char *errorString = NULL;
+ IcePoAuthProc authProc;
+ IcePoAuthStatus status;
+ IcePointer *authState;
+
+ CHECK_AT_LEAST_SIZE (iceConn, ICE_AuthNextPhase,
+ length, SIZEOF (iceAuthNextPhaseMsg),
+ iceConn->connect_to_you ? IceFatalToConnection : IceFatalToProtocol);
+
+ IceReadCompleteMessage (iceConn, SIZEOF (iceAuthNextPhaseMsg),
+ iceAuthNextPhaseMsg, message, authData);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, authData);
+ return (0);
+ }
+
+ if (swap)
+ {
+ message->authDataLength = lswaps (message->authDataLength);
+ }
+
+ CHECK_COMPLETE_SIZE (iceConn, ICE_AuthNextPhase, length,
+ message->authDataLength + SIZEOF (iceAuthNextPhaseMsg), authData,
+ iceConn->connect_to_you ? IceFatalToConnection : IceFatalToProtocol);
+
+ if (iceConn->connect_to_you)
+ {
+ authProc = _IcePoAuthProcs[(int)
+ (iceConn->connect_to_you->my_auth_index)];
+
+ authState = &iceConn->connect_to_you->my_auth_state;
+ }
+ else if (iceConn->protosetup_to_you)
+ {
+ _IcePoProtocol *myProtocol =
+ _IceProtocols[iceConn->protosetup_to_you->my_opcode - 1].orig_client;
+
+ authProc = myProtocol->auth_procs[(int)
+ (iceConn->protosetup_to_you->my_auth_index)];
+
+ authState = &iceConn->protosetup_to_you->my_auth_state;
+ }
+ else
+ {
+ /*
+ * Unexpected message
+ */
+
+ _IceErrorBadState (iceConn, 0, ICE_AuthNextPhase, IceCanContinue);
+
+ IceDisposeCompleteMessage (iceConn, authData);
+ return (0);
+ }
+
+ authDataLen = message->authDataLength;
+
+ status = (*authProc) (iceConn, authState, False /* don't clean up */,
+ swap, authDataLen, authData, &replyDataLen, &replyData, &errorString);
+
+ if (status == IcePoAuthHaveReply)
+ {
+ AuthReply (iceConn, replyDataLen, replyData);
+
+ replyWait->sequence_of_request = iceConn->send_sequence;
+ }
+ else if (status == IcePoAuthRejected || status == IcePoAuthFailed)
+ {
+ char *prefix = NULL, *returnErrorString;
+
+ if (status == IcePoAuthRejected)
+ {
+ _IceErrorAuthenticationRejected (iceConn,
+ ICE_AuthNextPhase, errorString);
+
+ prefix = "Authentication Rejected, reason : ";
+ }
+ else if (status == IcePoAuthFailed)
+ {
+ _IceErrorAuthenticationFailed (iceConn,
+ ICE_AuthNextPhase, errorString);
+
+ prefix = "Authentication Failed, reason : ";
+ }
+
+ returnErrorString = (char *) malloc (strlen (prefix) +
+ strlen (errorString) + 1);
+ sprintf (returnErrorString, "%s%s", prefix, errorString);
+ free (errorString);
+
+ if (iceConn->connect_to_you)
+ {
+ _IceConnectionError *errorReply =
+ &(((_IceReply *) (replyWait->reply))->connection_error);
+
+ errorReply->type = ICE_CONNECTION_ERROR;
+ errorReply->error_message = returnErrorString;
+ }
+ else
+ {
+ _IceProtocolError *errorReply =
+ &(((_IceReply *) (replyWait->reply))->protocol_error);
+
+ errorReply->type = ICE_PROTOCOL_ERROR;
+ errorReply->error_message = returnErrorString;
+ }
+ }
+
+ if (replyData && replyDataLen > 0)
+ free ((char *) replyData);
+
+ IceDisposeCompleteMessage (iceConn, authData);
+
+ return (status != IcePoAuthHaveReply);
+}
+
+
+
+static Bool
+ProcessConnectionReply (iceConn, length, swap, replyWait)
+
+IceConn iceConn;
+unsigned long length;
+Bool swap;
+IceReplyWaitInfo *replyWait;
+
+{
+ iceConnectionReplyMsg *message;
+ char *pData, *pStart, *pEnd;
+ Bool replyReady;
+
+#if 0 /* No-op */
+ CHECK_AT_LEAST_SIZE (iceConn, ICE_ConnectionReply,
+ length, SIZEOF (iceConnectionReplyMsg), IceFatalToConnection);
+#endif
+
+ IceReadCompleteMessage (iceConn, SIZEOF (iceConnectionReplyMsg),
+ iceConnectionReplyMsg, message, pStart);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+ }
+
+ pData = pStart;
+ pEnd = pStart + (length << 3);
+
+ SKIP_STRING (pData, swap, pEnd,
+ BAIL_STRING (iceConn, ICE_ConnectionReply,
+ pStart)); /* vendor */
+ SKIP_STRING (pData, swap, pEnd,
+ BAIL_STRING (iceConn, ICE_ConnectionReply,
+ pStart)); /* release */
+
+ CHECK_COMPLETE_SIZE (iceConn, ICE_ConnectionReply,
+ length, pData - pStart + SIZEOF (iceConnectionReplyMsg),
+ pStart, IceFatalToConnection);
+
+ pData = pStart;
+
+ if (iceConn->connect_to_you)
+ {
+ if (iceConn->connect_to_you->auth_active)
+ {
+ /*
+ * Tell the authentication procedure to clean up.
+ */
+
+ IcePoAuthProc authProc = _IcePoAuthProcs[(int)
+ (iceConn->connect_to_you->my_auth_index)];
+
+ (*authProc) (iceConn, &iceConn->connect_to_you->my_auth_state,
+ True /* clean up */, False /* swap */,
+ 0, NULL, NULL, NULL, NULL);
+ }
+
+ if ((int) message->versionIndex >= _IceVersionCount)
+ {
+ _IceConnectionError *errorReply =
+ &(((_IceReply *) (replyWait->reply))->connection_error);
+ char errIndex = message->versionIndex;
+
+ _IceErrorBadValue (iceConn, 0,
+ ICE_ConnectionReply, 2, 1, &errIndex);
+
+ errorReply->type = ICE_CONNECTION_ERROR;
+ errorReply->error_message =
+ "Received bad version index in Connection Reply";
+ }
+ else
+ {
+ _IceReply *reply = (_IceReply *) (replyWait->reply);
+
+ reply->type = ICE_CONNECTION_REPLY;
+ reply->connection_reply.version_index = message->versionIndex;
+
+ EXTRACT_STRING (pData, swap, reply->connection_reply.vendor);
+ EXTRACT_STRING (pData, swap, reply->connection_reply.release);
+ }
+
+ replyReady = True;
+ }
+ else
+ {
+ /*
+ * Unexpected message
+ */
+
+ _IceErrorBadState (iceConn, 0, ICE_ConnectionReply, IceCanContinue);
+
+ replyReady = False;
+ }
+
+ IceDisposeCompleteMessage (iceConn, pStart);
+
+ return (replyReady);
+}
+
+
+
+static int
+ProcessProtocolSetup (iceConn, length, swap)
+
+IceConn iceConn;
+unsigned long length;
+Bool swap;
+
+{
+ iceProtocolSetupMsg *message;
+ _IcePaProtocol *myProtocol;
+ int myVersionCount, hisVersionCount;
+ int myVersionIndex, hisVersionIndex;
+ int hisMajorVersion, hisMinorVersion;
+ int myAuthCount, hisAuthCount;
+ int myOpcode, hisOpcode;
+ int found, i, j;
+ char *myAuthName, **hisAuthNames = NULL;
+ char *protocolName;
+ char *pData, *pStart, *pEnd;
+ char *vendor = NULL;
+ char *release = NULL;
+ int accept_setup_now = 0;
+ int myAuthIndex = 0;
+ int hisAuthIndex = 0;
+ char mustAuthenticate;
+ int authUsableCount;
+ int authUsableFlags[MAX_ICE_AUTH_NAMES];
+ int authIndices[MAX_ICE_AUTH_NAMES];
+
+ CHECK_AT_LEAST_SIZE (iceConn, ICE_ProtocolSetup,
+ length, SIZEOF (iceProtocolSetupMsg), IceFatalToProtocol);
+
+ if (iceConn->want_to_close)
+ {
+ /*
+ * If we sent a WantToClose message, but just got a ProtocolSetup,
+ * we must cancel our WantToClose. It is the responsiblity of the
+ * other client to send a WantToClose later on.
+ */
+
+ iceConn->want_to_close = 0;
+ }
+
+ IceReadCompleteMessage (iceConn, SIZEOF (iceProtocolSetupMsg),
+ iceProtocolSetupMsg, message, pStart);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+ }
+
+ pData = pStart;
+ pEnd = pStart + (length << 3);
+
+ SKIP_STRING (pData, swap, pEnd,
+ BAIL_STRING(iceConn, ICE_ProtocolSetup,
+ pStart)); /* proto name */
+ SKIP_STRING (pData, swap, pEnd,
+ BAIL_STRING(iceConn, ICE_ProtocolSetup,
+ pStart)); /* vendor */
+ SKIP_STRING (pData, swap, pEnd,
+ BAIL_STRING(iceConn, ICE_ProtocolSetup,
+ pStart)); /* release */
+ SKIP_LISTOF_STRING (pData, swap, (int) message->authCount, pEnd,
+ BAIL_STRING(iceConn, ICE_ProtocolSetup,
+ pStart)); /* auth names */
+ pData += (message->versionCount * 4); /* versions */
+
+ CHECK_COMPLETE_SIZE (iceConn, ICE_ProtocolSetup,
+ length, pData - pStart + SIZEOF (iceProtocolSetupMsg),
+ pStart, IceFatalToProtocol);
+
+ mustAuthenticate = message->mustAuthenticate;
+
+ if (mustAuthenticate != 0 && mustAuthenticate != 1)
+ {
+ _IceErrorBadValue (iceConn, 0,
+ ICE_ProtocolSetup, 4, 1, &mustAuthenticate);
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+ }
+
+ pData = pStart;
+
+ if (iceConn->process_msg_info &&
+ (int) message->protocolOpcode >= iceConn->his_min_opcode &&
+ (int) message->protocolOpcode <= iceConn->his_max_opcode &&
+ iceConn->process_msg_info[
+ message->protocolOpcode - iceConn->his_min_opcode].in_use)
+ {
+ _IceErrorMajorOpcodeDuplicate (iceConn, message->protocolOpcode);
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+ }
+
+ EXTRACT_STRING (pData, swap, protocolName);
+
+ if (iceConn->process_msg_info)
+ {
+ for (i = 0;
+ i <= (iceConn->his_max_opcode - iceConn->his_min_opcode); i++)
+ {
+ if (iceConn->process_msg_info[i].in_use && strcmp (protocolName,
+ iceConn->process_msg_info[i].protocol->protocol_name) == 0)
+ {
+ _IceErrorProtocolDuplicate (iceConn, protocolName);
+ free (protocolName);
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+ }
+ }
+ }
+
+ for (i = 0; i < _IceLastMajorOpcode; i++)
+ if (strcmp (protocolName, _IceProtocols[i].protocol_name) == 0)
+ break;
+
+ if (i < _IceLastMajorOpcode &&
+ (myProtocol = _IceProtocols[i].accept_client) != NULL)
+ {
+ hisOpcode = message->protocolOpcode;
+ myOpcode = i + 1;
+ free (protocolName);
+ }
+ else
+ {
+ _IceErrorUnknownProtocol (iceConn, protocolName);
+ free (protocolName);
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+ }
+
+ EXTRACT_STRING (pData, swap, vendor);
+ EXTRACT_STRING (pData, swap, release);
+
+ if ((hisAuthCount = message->authCount) > 0)
+ {
+ hisAuthNames = (char **) malloc (hisAuthCount * sizeof (char *));
+ EXTRACT_LISTOF_STRING (pData, swap, hisAuthCount, hisAuthNames);
+ }
+
+ hisVersionCount = message->versionCount;
+ myVersionCount = myProtocol->version_count;
+
+ hisVersionIndex = myVersionIndex = found = 0;
+
+ for (i = 0; i < hisVersionCount && !found; i++)
+ {
+ EXTRACT_CARD16 (pData, swap, hisMajorVersion);
+ EXTRACT_CARD16 (pData, swap, hisMinorVersion);
+
+ for (j = 0; j < myVersionCount && !found; j++)
+ {
+ if (myProtocol->version_recs[j].major_version == hisMajorVersion &&
+ myProtocol->version_recs[j].minor_version == hisMinorVersion)
+ {
+ hisVersionIndex = i;
+ myVersionIndex = j;
+ found = 1;
+ }
+ }
+ }
+
+ if (!found)
+ {
+ _IceErrorNoVersion (iceConn, ICE_ProtocolSetup);
+
+ free (vendor);
+ free (release);
+
+ if (hisAuthCount > 0)
+ {
+ for (i = 0; i < hisAuthCount; i++)
+ free (hisAuthNames[i]);
+
+ free ((char *) hisAuthNames);
+ }
+
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+ }
+
+ myAuthCount = myProtocol->auth_count;
+
+ _IceGetPaValidAuthIndices (
+ _IceProtocols[myOpcode - 1].protocol_name,
+ iceConn->connection_string, myAuthCount, myProtocol->auth_names,
+ &authUsableCount, authIndices);
+
+ for (i = 0; i < myAuthCount; i++)
+ {
+ authUsableFlags[i] = 0;
+ for (j = 0; j < authUsableCount && !authUsableFlags[i]; j++)
+ authUsableFlags[i] = (authIndices[j] == i);
+ }
+
+ for (i = found = 0; i < myAuthCount && !found; i++)
+ {
+ if (authUsableFlags[i])
+ {
+ myAuthName = myProtocol->auth_names[i];
+
+ for (j = 0; j < hisAuthCount && !found; j++)
+ if (strcmp (myAuthName, hisAuthNames[j]) == 0)
+ {
+ myAuthIndex = i;
+ hisAuthIndex = j;
+ found = 1;
+ }
+ }
+ }
+
+ if (!found)
+ {
+ /*
+ * None of the authentication methods specified by the
+ * other client is supported. If the other client requires
+ * authentication, we must reject the Protocol Setup now.
+ * Otherwise, we can invoke the host-based authentication callback
+ * to see if we can accept this Protocol Setup.
+ */
+
+ if (mustAuthenticate || !myProtocol->host_based_auth_proc)
+ {
+ _IceErrorNoAuthentication (iceConn, ICE_ProtocolSetup);
+ }
+ else
+ {
+ char *hostname = _IceGetPeerName (iceConn);
+
+ if ((*myProtocol->host_based_auth_proc) (hostname))
+ {
+ accept_setup_now = 1;
+ }
+ else
+ {
+ _IceErrorAuthenticationRejected (iceConn,
+ ICE_ProtocolSetup, "None of the authentication protocols specified are supported and host-based authentication failed");
+ }
+
+ if (hostname)
+ free (hostname);
+ }
+ }
+ else
+ {
+ IcePaAuthStatus status;
+ int authDataLen;
+ IcePointer authData = NULL;
+ IcePointer authState;
+ char *errorString = NULL;
+ IcePaAuthProc authProc =
+ myProtocol->auth_procs[myAuthIndex];
+
+ authState = NULL;
+
+ status = (*authProc) (iceConn, &authState, swap, 0, NULL,
+ &authDataLen, &authData, &errorString);
+
+ if (status == IcePaAuthContinue)
+ {
+ _IceProtoSetupToMeInfo *setupInfo;
+
+ AuthRequired (iceConn, hisAuthIndex, authDataLen, authData);
+
+ iceConn->protosetup_to_me = setupInfo =
+ (_IceProtoSetupToMeInfo *) malloc (
+ sizeof (_IceProtoSetupToMeInfo));
+
+ setupInfo->his_opcode = hisOpcode;
+ setupInfo->my_opcode = myOpcode;
+ setupInfo->my_version_index = myVersionIndex;
+ setupInfo->his_version_index = hisVersionIndex;
+ setupInfo->his_vendor = vendor;
+ setupInfo->his_release = release;
+ vendor = release = NULL; /* so we don't free it */
+ setupInfo->my_auth_index = myAuthIndex;
+ setupInfo->my_auth_state = authState;
+ setupInfo->must_authenticate = mustAuthenticate;
+ }
+ else if (status == IcePaAuthAccepted)
+ {
+ accept_setup_now = 1;
+ }
+
+ if (authData && authDataLen > 0)
+ free ((char *) authData);
+
+ if (errorString)
+ free (errorString);
+ }
+
+ if (accept_setup_now)
+ {
+ IcePaProcessMsgProc processMsgProc;
+ IceProtocolSetupProc protocolSetupProc;
+ IceProtocolActivateProc protocolActivateProc;
+ _IceProcessMsgInfo *process_msg_info;
+ IcePointer clientData = NULL;
+ char *failureReason = NULL;
+ Status status = 1;
+
+ protocolSetupProc = myProtocol->protocol_setup_proc;
+ protocolActivateProc = myProtocol->protocol_activate_proc;
+
+ if (protocolSetupProc)
+ {
+ /*
+ * Notify the client of the Protocol Setup.
+ */
+
+ status = (*protocolSetupProc) (iceConn,
+ myProtocol->version_recs[myVersionIndex].major_version,
+ myProtocol->version_recs[myVersionIndex].minor_version,
+ vendor, release, &clientData, &failureReason);
+
+ vendor = release = NULL; /* so we don't free it */
+ }
+
+ if (status != 0)
+ {
+ /*
+ * Send the Protocol Reply
+ */
+
+ AcceptProtocol (iceConn, hisOpcode, myOpcode, hisVersionIndex,
+ myProtocol->vendor, myProtocol->release);
+
+
+ /*
+ * Set info for this protocol.
+ */
+
+ processMsgProc = myProtocol->version_recs[
+ myVersionIndex].process_msg_proc;
+
+ process_msg_info = &iceConn->process_msg_info[hisOpcode -
+ iceConn->his_min_opcode];
+
+ process_msg_info->client_data = clientData;
+ process_msg_info->accept_flag = 1;
+ process_msg_info->process_msg_proc.accept_client = processMsgProc;
+
+
+ /*
+ * Increase the reference count for the number of active protocols.
+ */
+
+ iceConn->proto_ref_count++;
+
+
+ /*
+ * Notify the client that the protocol is active. The reason
+ * we have this 2nd callback invoked is because the client
+ * may wish to immediately generate a message for this
+ * protocol, but it must wait until we send the Protocol Reply.
+ */
+
+ if (protocolActivateProc)
+ {
+ (*protocolActivateProc) (iceConn,
+ process_msg_info->client_data);
+ }
+ }
+ else
+ {
+ /*
+ * An error was encountered.
+ */
+
+ _IceErrorSetupFailed (iceConn, ICE_ProtocolSetup, failureReason);
+
+ if (failureReason)
+ free (failureReason);
+ }
+ }
+
+ if (vendor)
+ free (vendor);
+
+ if (release)
+ free (release);
+
+ if (hisAuthCount > 0)
+ {
+ for (i = 0; i < hisAuthCount; i++)
+ free (hisAuthNames[i]);
+
+ free ((char *) hisAuthNames);
+ }
+
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+}
+
+
+
+static Bool
+ProcessProtocolReply (iceConn, length, swap, replyWait)
+
+IceConn iceConn;
+unsigned long length;
+Bool swap;
+IceReplyWaitInfo *replyWait;
+
+{
+ iceProtocolReplyMsg *message;
+ char *pData, *pStart, *pEnd;
+ Bool replyReady;
+
+#if 0 /* No-op */
+ CHECK_AT_LEAST_SIZE (iceConn, ICE_ProtocolReply,
+ length, SIZEOF (iceProtocolReplyMsg), IceFatalToProtocol);
+#endif
+
+ IceReadCompleteMessage (iceConn, SIZEOF (iceProtocolReplyMsg),
+ iceProtocolReplyMsg, message, pStart);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return (0);
+ }
+
+ pData = pStart;
+ pEnd = pStart + (length << 3);
+
+ SKIP_STRING (pData, swap, pEnd,
+ BAIL_STRING(iceConn, ICE_ProtocolReply,
+ pStart)); /* vendor */
+ SKIP_STRING (pData, swap, pEnd,
+ BAIL_STRING(iceConn, ICE_ProtocolReply,
+ pStart)); /* release */
+
+ CHECK_COMPLETE_SIZE (iceConn, ICE_ProtocolReply,
+ length, pData - pStart + SIZEOF (iceProtocolReplyMsg),
+ pStart, IceFatalToProtocol);
+
+ pData = pStart;
+
+ if (iceConn->protosetup_to_you)
+ {
+ if (iceConn->protosetup_to_you->auth_active)
+ {
+ /*
+ * Tell the authentication procedure to clean up.
+ */
+
+ _IcePoProtocol *myProtocol = _IceProtocols[
+ iceConn->protosetup_to_you->my_opcode - 1].orig_client;
+
+ IcePoAuthProc authProc = myProtocol->auth_procs[(int)
+ (iceConn->protosetup_to_you->my_auth_index)];
+
+#ifdef SVR4
+
+/*
+ * authProc is never NULL, but the cc compiler on UNIX System V/386
+ * Release 4.2 Version 1 screws up an optimization. Unless there is
+ * some sort of reference to authProc before the function call, the
+ * function call will seg fault.
+ */
+ if (authProc)
+#endif
+ (*authProc) (iceConn,
+ &iceConn->protosetup_to_you->my_auth_state,
+ True /* clean up */, False /* swap */,
+ 0, NULL, NULL, NULL, NULL);
+ }
+
+ if ((int) message->versionIndex >= _IceVersionCount)
+ {
+ _IceProtocolError *errorReply =
+ &(((_IceReply *) (replyWait->reply))->protocol_error);
+ char errIndex = message->versionIndex;
+
+ _IceErrorBadValue (iceConn, 0,
+ ICE_ProtocolReply, 2, 1, &errIndex);
+
+ errorReply->type = ICE_PROTOCOL_ERROR;
+ errorReply->error_message =
+ "Received bad version index in Protocol Reply";
+ }
+ else
+ {
+ _IceProtocolReply *reply =
+ &(((_IceReply *) (replyWait->reply))->protocol_reply);
+
+ reply->type = ICE_PROTOCOL_REPLY;
+ reply->major_opcode = message->protocolOpcode;
+ reply->version_index = message->versionIndex;
+
+ EXTRACT_STRING (pData, swap, reply->vendor);
+ EXTRACT_STRING (pData, swap, reply->release);
+ }
+
+ replyReady = True;
+ }
+ else
+ {
+ _IceErrorBadState (iceConn, 0, ICE_ProtocolReply, IceCanContinue);
+
+ replyReady = False;
+ }
+
+ IceDisposeCompleteMessage (iceConn, pStart);
+
+ return (replyReady);
+}
+
+
+
+static int
+ProcessPing (iceConn, length)
+
+IceConn iceConn;
+unsigned long length;
+
+{
+ CHECK_SIZE_MATCH (iceConn, ICE_Ping,
+ length, SIZEOF (icePingMsg), IceFatalToConnection, 0);
+
+ PingReply (iceConn);
+
+ return (0);
+}
+
+
+
+static int
+ProcessPingReply (iceConn, length)
+
+IceConn iceConn;
+unsigned long length;
+
+{
+ CHECK_SIZE_MATCH (iceConn, ICE_PingReply,
+ length, SIZEOF (icePingReplyMsg), IceFatalToConnection, 0);
+
+ if (iceConn->ping_waits)
+ {
+ _IcePingWait *next = iceConn->ping_waits->next;
+
+ (*iceConn->ping_waits->ping_reply_proc) (iceConn,
+ iceConn->ping_waits->client_data);
+
+ free ((char *) iceConn->ping_waits);
+ iceConn->ping_waits = next;
+ }
+ else
+ {
+ _IceErrorBadState (iceConn, 0, ICE_PingReply, IceCanContinue);
+ }
+
+ return (0);
+}
+
+
+
+static int
+ProcessWantToClose (iceConn, length, connectionClosedRet)
+
+IceConn iceConn;
+unsigned long length;
+Bool *connectionClosedRet;
+
+{
+ *connectionClosedRet = False;
+
+ CHECK_SIZE_MATCH (iceConn, ICE_WantToClose,
+ length, SIZEOF (iceWantToCloseMsg), IceFatalToConnection, 0);
+
+ if (iceConn->want_to_close || iceConn->open_ref_count == 0)
+ {
+ /*
+ * We just received a WantToClose. Either we also sent a
+ * WantToClose, so we close the connection, or the iceConn
+ * is not being used, so we close the connection. This
+ * second case is possible if we sent a WantToClose because
+ * the iceConn->open_ref_count reached zero, but then we
+ * received a NoClose.
+ */
+
+ _IceConnectionClosed (iceConn); /* invoke watch procs */
+ _IceFreeConnection (iceConn);
+ *connectionClosedRet = True;
+ }
+ else if (iceConn->proto_ref_count > 0)
+ {
+ /*
+ * We haven't shut down all of our protocols yet. We send a NoClose,
+ * and it's up to us to generate a WantToClose later on.
+ */
+
+ IceSimpleMessage (iceConn, 0, ICE_NoClose);
+ IceFlush (iceConn);
+ }
+ else
+ {
+ /*
+ * The reference count on this iceConn is zero. This means that
+ * there are no active protocols, but the client didn't explicitly
+ * close the connection yet. If we didn't just send a Protocol Setup,
+ * we send a NoClose, and it's up to us to generate a WantToClose
+ * later on.
+ */
+
+ if (!iceConn->protosetup_to_you)
+ {
+ IceSimpleMessage (iceConn, 0, ICE_NoClose);
+ IceFlush (iceConn);
+ }
+ }
+
+ return (0);
+}
+
+
+
+static int
+ProcessNoClose (iceConn, length)
+
+IceConn iceConn;
+unsigned long length;
+
+{
+ CHECK_SIZE_MATCH (iceConn, ICE_NoClose,
+ length, SIZEOF (iceNoCloseMsg), IceFatalToConnection, 0);
+
+ if (iceConn->want_to_close)
+ {
+ /*
+ * The other side can't close now. We cancel our WantToClose,
+ * and we can expect a WantToClose from the other side.
+ */
+
+ iceConn->want_to_close = 0;
+ }
+ else
+ {
+ _IceErrorBadState (iceConn, 0, ICE_NoClose, IceCanContinue);
+ }
+
+ return (0);
+}
+
+
+
+void
+_IceProcessCoreMessage (iceConn, opcode, length, swap,
+ replyWait, replyReadyRet, connectionClosedRet)
+
+IceConn iceConn;
+int opcode;
+unsigned long length;
+Bool swap;
+IceReplyWaitInfo *replyWait;
+Bool *replyReadyRet;
+Bool *connectionClosedRet;
+
+{
+ Bool replyReady = False;
+
+ *connectionClosedRet = False;
+
+ switch (opcode)
+ {
+ case ICE_Error:
+
+ replyReady = ProcessError (iceConn, length, swap, replyWait);
+ break;
+
+ case ICE_ConnectionSetup:
+
+ ProcessConnectionSetup (iceConn, length, swap);
+ break;
+
+ case ICE_AuthRequired:
+
+ replyReady = ProcessAuthRequired (iceConn, length, swap, replyWait);
+ break;
+
+ case ICE_AuthReply:
+
+ ProcessAuthReply (iceConn, length, swap);
+ break;
+
+ case ICE_AuthNextPhase:
+
+ replyReady = ProcessAuthNextPhase (iceConn, length, swap, replyWait);
+ break;
+
+ case ICE_ConnectionReply:
+
+ replyReady = ProcessConnectionReply (iceConn, length, swap, replyWait);
+ break;
+
+ case ICE_ProtocolSetup:
+
+ ProcessProtocolSetup (iceConn, length, swap);
+ break;
+
+ case ICE_ProtocolReply:
+
+ replyReady = ProcessProtocolReply (iceConn, length, swap, replyWait);
+ break;
+
+ case ICE_Ping:
+
+ ProcessPing (iceConn, length);
+ break;
+
+ case ICE_PingReply:
+
+ ProcessPingReply (iceConn, length);
+ break;
+
+ case ICE_WantToClose:
+
+ ProcessWantToClose (iceConn, length, connectionClosedRet);
+ break;
+
+ case ICE_NoClose:
+
+ ProcessNoClose (iceConn, length);
+ break;
+
+ default:
+
+ _IceErrorBadMinor (iceConn, 0, opcode, IceCanContinue);
+ _IceReadSkip (iceConn, length << 3);
+ break;
+ }
+
+ if (replyWait)
+ *replyReadyRet = replyReady;
+}
+
diff --git a/nx-X11/lib/ICE/protosetup.c b/nx-X11/lib/ICE/protosetup.c
new file mode 100644
index 000000000..7a21e2e1d
--- /dev/null
+++ b/nx-X11/lib/ICE/protosetup.c
@@ -0,0 +1,293 @@
+/* $Xorg: protosetup.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/protosetup.c,v 1.2 2001/10/28 03:32:28 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+
+
+IceProtocolSetupStatus
+IceProtocolSetup (iceConn, myOpcode, clientData, mustAuthenticate,
+ majorVersionRet, minorVersionRet, vendorRet, releaseRet,
+ errorLength, errorStringRet)
+
+IceConn iceConn;
+int myOpcode;
+IcePointer clientData;
+Bool mustAuthenticate;
+int *majorVersionRet;
+int *minorVersionRet;
+char **vendorRet;
+char **releaseRet;
+int errorLength;
+char *errorStringRet;
+
+{
+ iceProtocolSetupMsg *pMsg;
+ char *pData;
+ _IceProtocol *myProtocol;
+ int extra;
+ Bool gotReply, ioErrorOccured;
+ int accepted, i;
+ int hisOpcode;
+ unsigned long setup_sequence;
+ IceReplyWaitInfo replyWait;
+ _IceReply reply;
+ IcePoVersionRec *versionRec = NULL;
+ int authCount;
+ int *authIndices;
+
+ if (errorStringRet && errorLength > 0)
+ *errorStringRet = '\0';
+
+ *majorVersionRet = 0;
+ *minorVersionRet = 0;
+ *vendorRet = NULL;
+ *releaseRet = NULL;
+
+ if (myOpcode < 1 || myOpcode > _IceLastMajorOpcode)
+ {
+ strncpy (errorStringRet, "myOpcode out of range", errorLength);
+ return (IceProtocolSetupFailure);
+ }
+
+ myProtocol = &_IceProtocols[myOpcode - 1];
+
+ if (myProtocol->orig_client == NULL)
+ {
+ strncpy (errorStringRet,
+ "IceRegisterForProtocolSetup was not called", errorLength);
+ return (IceProtocolSetupFailure);
+ }
+
+
+ /*
+ * Make sure this protocol hasn't been activated already.
+ */
+
+ if (iceConn->process_msg_info)
+ {
+ for (i = iceConn->his_min_opcode; i <= iceConn->his_max_opcode; i++)
+ {
+ if (iceConn->process_msg_info[
+ i - iceConn->his_min_opcode].in_use &&
+ iceConn->process_msg_info[
+ i - iceConn->his_min_opcode ].my_opcode == myOpcode)
+ break;
+ }
+
+ if (i <= iceConn->his_max_opcode)
+ {
+ return (IceProtocolAlreadyActive);
+ }
+ }
+
+ /*
+ * Generate the message.
+ */
+
+ if (myProtocol->orig_client->auth_count > 0)
+ {
+ authIndices = (int *) malloc (
+ myProtocol->orig_client->auth_count * sizeof (int));
+
+ _IceGetPoValidAuthIndices (myProtocol->protocol_name,
+ iceConn->connection_string,
+ myProtocol->orig_client->auth_count,
+ myProtocol->orig_client->auth_names,
+ &authCount, authIndices);
+
+ }
+ else
+ {
+ authCount = 0;
+ authIndices = NULL;
+ }
+
+ extra = STRING_BYTES (myProtocol->protocol_name) +
+ STRING_BYTES (myProtocol->orig_client->vendor) +
+ STRING_BYTES (myProtocol->orig_client->release);
+
+ for (i = 0; i < authCount; i++)
+ {
+ extra += STRING_BYTES (myProtocol->orig_client->auth_names[
+ authIndices[i]]);
+ }
+
+ extra += (myProtocol->orig_client->version_count * 4);
+
+ IceGetHeaderExtra (iceConn, 0, ICE_ProtocolSetup,
+ SIZEOF (iceProtocolSetupMsg), WORD64COUNT (extra),
+ iceProtocolSetupMsg, pMsg, pData);
+
+ setup_sequence = iceConn->send_sequence;
+
+ pMsg->protocolOpcode = myOpcode;
+ pMsg->versionCount = myProtocol->orig_client->version_count;
+ pMsg->authCount = authCount;
+ pMsg->mustAuthenticate = mustAuthenticate;
+
+ STORE_STRING (pData, myProtocol->protocol_name);
+ STORE_STRING (pData, myProtocol->orig_client->vendor);
+ STORE_STRING (pData, myProtocol->orig_client->release);
+
+ for (i = 0; i < authCount; i++)
+ {
+ STORE_STRING (pData, myProtocol->orig_client->auth_names[
+ authIndices[i]]);
+ }
+
+ for (i = 0; i < myProtocol->orig_client->version_count; i++)
+ {
+ STORE_CARD16 (pData,
+ myProtocol->orig_client->version_recs[i].major_version);
+ STORE_CARD16 (pData,
+ myProtocol->orig_client->version_recs[i].minor_version);
+ }
+
+ IceFlush (iceConn);
+
+
+ /*
+ * Process messages until we get a Protocol Reply.
+ */
+
+ replyWait.sequence_of_request = setup_sequence;
+ replyWait.major_opcode_of_request = 0;
+ replyWait.minor_opcode_of_request = ICE_ProtocolSetup;
+ replyWait.reply = (IcePointer) &reply;
+
+ iceConn->protosetup_to_you = (_IceProtoSetupToYouInfo *) malloc (
+ sizeof (_IceProtoSetupToYouInfo));
+ iceConn->protosetup_to_you->my_opcode = myOpcode;
+ iceConn->protosetup_to_you->my_auth_count = authCount;
+ iceConn->protosetup_to_you->auth_active = 0;
+ iceConn->protosetup_to_you->my_auth_indices = authIndices;
+
+ gotReply = False;
+ ioErrorOccured = False;
+ accepted = 0;
+
+ while (!gotReply && !ioErrorOccured)
+ {
+ ioErrorOccured = (IceProcessMessages (
+ iceConn, &replyWait, &gotReply) == IceProcessMessagesIOError);
+
+ if (ioErrorOccured)
+ {
+ strncpy (errorStringRet,
+ "IO error occured doing Protocol Setup on connection",
+ errorLength);
+ return (IceProtocolSetupIOError);
+ }
+ else if (gotReply)
+ {
+ if (reply.type == ICE_PROTOCOL_REPLY)
+ {
+ if (reply.protocol_reply.version_index >=
+ myProtocol->orig_client->version_count)
+ {
+ strncpy (errorStringRet,
+ "Got a bad version index in the Protocol Reply",
+ errorLength);
+
+ free (reply.protocol_reply.vendor);
+ free (reply.protocol_reply.release);
+ }
+ else
+ {
+ versionRec = &(myProtocol->orig_client->version_recs[
+ reply.protocol_reply.version_index]);
+
+ accepted = 1;
+ }
+ }
+ else /* reply.type == ICE_PROTOCOL_ERROR */
+ {
+ /* Protocol Setup failed */
+
+ strncpy (errorStringRet, reply.protocol_error.error_message,
+ errorLength);
+
+ free (reply.protocol_error.error_message);
+ }
+
+ if (iceConn->protosetup_to_you->my_auth_indices)
+ free ((char *) iceConn->protosetup_to_you->my_auth_indices);
+ free ((char *) iceConn->protosetup_to_you);
+ iceConn->protosetup_to_you = NULL;
+ }
+ }
+
+ if (accepted)
+ {
+ _IceProcessMsgInfo *process_msg_info;
+
+ *majorVersionRet = versionRec->major_version;
+ *minorVersionRet = versionRec->minor_version;
+ *vendorRet = reply.protocol_reply.vendor;
+ *releaseRet = reply.protocol_reply.release;
+
+
+ /*
+ * Increase the reference count for the number of active protocols.
+ */
+
+ iceConn->proto_ref_count++;
+
+
+ /*
+ * We may be using a different major opcode for this protocol
+ * than the other client. Whenever we get a message, we must
+ * map to our own major opcode.
+ */
+
+ hisOpcode = reply.protocol_reply.major_opcode;
+
+ _IceAddOpcodeMapping (iceConn, hisOpcode, myOpcode);
+
+ process_msg_info = &iceConn->process_msg_info[hisOpcode -
+ iceConn->his_min_opcode];
+
+ process_msg_info->client_data = clientData;
+ process_msg_info->accept_flag = 0;
+
+ process_msg_info->process_msg_proc.orig_client =
+ versionRec->process_msg_proc;
+
+ return (IceProtocolSetupSuccess);
+ }
+ else
+ {
+ return (IceProtocolSetupFailure);
+ }
+}
diff --git a/nx-X11/lib/ICE/register.c b/nx-X11/lib/ICE/register.c
new file mode 100644
index 000000000..20e60dfdf
--- /dev/null
+++ b/nx-X11/lib/ICE/register.c
@@ -0,0 +1,256 @@
+/* $Xorg: register.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+
+int
+IceRegisterForProtocolSetup (protocolName, vendor, release,
+ versionCount, versionRecs, authCount, authNames, authProcs, IOErrorProc)
+
+char *protocolName;
+char *vendor;
+char *release;
+int versionCount;
+IcePoVersionRec *versionRecs;
+int authCount;
+char **authNames;
+IcePoAuthProc *authProcs;
+IceIOErrorProc IOErrorProc;
+
+{
+ _IcePoProtocol *p;
+ int opcodeRet, i;
+
+ for (i = 1; i <= _IceLastMajorOpcode; i++)
+ if (strcmp (protocolName, _IceProtocols[i - 1].protocol_name) == 0)
+ {
+ if (_IceProtocols[i - 1].orig_client != NULL)
+ {
+ /*
+ * We've already registered this protocol.
+ */
+
+ return (i);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ if (i <= _IceLastMajorOpcode)
+ {
+ p = _IceProtocols[i - 1].orig_client =
+ (_IcePoProtocol *) malloc (sizeof (_IcePoProtocol));
+ opcodeRet = i;
+ }
+ else if (_IceLastMajorOpcode == 255 ||
+ versionCount < 1 ||
+ strlen (protocolName) == 0)
+ {
+ return (-1);
+ }
+ else
+ {
+ char *name;
+
+ _IceProtocols[_IceLastMajorOpcode].protocol_name = name =
+ (char *) malloc (strlen (protocolName) + 1);
+ strcpy (name, protocolName);
+
+ p = _IceProtocols[_IceLastMajorOpcode].orig_client =
+ (_IcePoProtocol *) malloc (sizeof (_IcePoProtocol));
+
+ _IceProtocols[_IceLastMajorOpcode].accept_client = NULL;
+
+ opcodeRet = ++_IceLastMajorOpcode;
+ }
+
+ p->vendor = (char *) malloc (strlen (vendor) + 1);
+ strcpy (p->vendor, vendor);
+
+ p->release = (char *) malloc (strlen (release) + 1);
+ strcpy (p->release, release);
+
+ p->version_count = versionCount;
+
+ p->version_recs = (IcePoVersionRec *) malloc (
+ versionCount * sizeof (IcePoVersionRec));
+ memcpy (p->version_recs, versionRecs,
+ versionCount * sizeof (IcePoVersionRec));
+
+ if ((p->auth_count = authCount) > 0)
+ {
+ p->auth_names = (char **) malloc (
+ authCount * sizeof (char *));
+
+ p->auth_procs = (IcePoAuthProc *) malloc (
+ authCount * sizeof (IcePoAuthProc));
+
+ for (i = 0; i < authCount; i++)
+ {
+ p->auth_names[i] =
+ (char *) malloc (strlen (authNames[i]) + 1);
+ strcpy (p->auth_names[i], authNames[i]);
+
+ p->auth_procs[i] = authProcs[i];
+ }
+ }
+ else
+ {
+ p->auth_names = NULL;
+ p->auth_procs = NULL;
+ }
+
+ p->io_error_proc = IOErrorProc;
+
+ return (opcodeRet);
+}
+
+
+
+int
+IceRegisterForProtocolReply (protocolName, vendor, release,
+ versionCount, versionRecs, authCount, authNames, authProcs,
+ hostBasedAuthProc, protocolSetupProc, protocolActivateProc,
+ IOErrorProc)
+
+char *protocolName;
+char *vendor;
+char *release;
+int versionCount;
+IcePaVersionRec *versionRecs;
+int authCount;
+char **authNames;
+IcePaAuthProc *authProcs;
+IceHostBasedAuthProc hostBasedAuthProc;
+IceProtocolSetupProc protocolSetupProc;
+IceProtocolActivateProc protocolActivateProc;
+IceIOErrorProc IOErrorProc;
+
+{
+ _IcePaProtocol *p;
+ int opcodeRet, i;
+
+ for (i = 1; i <= _IceLastMajorOpcode; i++)
+ if (strcmp (protocolName, _IceProtocols[i - 1].protocol_name) == 0)
+ {
+ if (_IceProtocols[i - 1].accept_client != NULL)
+ {
+ /*
+ * We've already registered this protocol.
+ */
+
+ return (i);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+
+ if (i <= _IceLastMajorOpcode)
+ {
+ p = _IceProtocols[i - 1].accept_client =
+ (_IcePaProtocol *) malloc (sizeof (_IcePaProtocol));
+ opcodeRet = i;
+ }
+ else if (_IceLastMajorOpcode == 255 ||
+ versionCount < 1 ||
+ strlen (protocolName) == 0)
+ {
+ return (-1);
+ }
+ else
+ {
+ char *name;
+
+ _IceProtocols[_IceLastMajorOpcode].protocol_name = name =
+ (char *) malloc (strlen (protocolName) + 1);
+ strcpy (name, protocolName);
+
+ _IceProtocols[_IceLastMajorOpcode].orig_client = NULL;
+
+ p = _IceProtocols[_IceLastMajorOpcode].accept_client =
+ (_IcePaProtocol *) malloc (sizeof (_IcePaProtocol));
+
+ opcodeRet = ++_IceLastMajorOpcode;
+ }
+
+ p->vendor = (char *) malloc (strlen (vendor) + 1);
+ strcpy (p->vendor, vendor);
+
+ p->release = (char *) malloc (strlen (release) + 1);
+ strcpy (p->release, release);
+
+ p->version_count = versionCount;
+
+ p->version_recs = (IcePaVersionRec *) malloc (
+ versionCount * sizeof (IcePaVersionRec));
+ memcpy (p->version_recs, versionRecs,
+ versionCount * sizeof (IcePaVersionRec));
+
+ p->protocol_setup_proc = protocolSetupProc;
+ p->protocol_activate_proc = protocolActivateProc;
+
+ if ((p->auth_count = authCount) > 0)
+ {
+ p->auth_names = (char **) malloc (
+ authCount * sizeof (char *));
+
+ p->auth_procs = (IcePaAuthProc *) malloc (
+ authCount * sizeof (IcePaAuthProc));
+
+ for (i = 0; i < authCount; i++)
+ {
+ p->auth_names[i] =
+ (char *) malloc (strlen (authNames[i]) + 1);
+ strcpy (p->auth_names[i], authNames[i]);
+
+ p->auth_procs[i] = authProcs[i];
+ }
+ }
+ else
+ {
+ p->auth_names = NULL;
+ p->auth_procs = NULL;
+ }
+
+ p->host_based_auth_proc = hostBasedAuthProc;
+
+ p->io_error_proc = IOErrorProc;
+
+ return (opcodeRet);
+}
+
diff --git a/nx-X11/lib/ICE/replywait.c b/nx-X11/lib/ICE/replywait.c
new file mode 100644
index 000000000..e00eb9285
--- /dev/null
+++ b/nx-X11/lib/ICE/replywait.c
@@ -0,0 +1,161 @@
+/* $Xorg: replywait.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+
+
+void
+_IceAddReplyWait (iceConn, replyWait)
+
+IceConn iceConn;
+IceReplyWaitInfo *replyWait;
+
+{
+ /*
+ * Add this replyWait to the end of the list (only if the
+ * replyWait is not already in the list).
+ */
+
+ _IceSavedReplyWait *savedReplyWait;
+ _IceSavedReplyWait *prev, *last;
+
+ prev = NULL;
+ last = iceConn->saved_reply_waits;
+
+ while (last)
+ {
+ if (last->reply_wait == replyWait)
+ return;
+
+ prev = last;
+ last = last->next;
+ }
+
+ savedReplyWait = (_IceSavedReplyWait *) malloc (
+ sizeof (_IceSavedReplyWait));
+
+ savedReplyWait->reply_wait = replyWait;
+ savedReplyWait->reply_ready = False;
+ savedReplyWait->next = NULL;
+
+ if (prev == NULL)
+ iceConn->saved_reply_waits = savedReplyWait;
+ else
+ prev->next = savedReplyWait;
+}
+
+
+
+IceReplyWaitInfo *
+_IceSearchReplyWaits (iceConn, majorOpcode)
+
+IceConn iceConn;
+int majorOpcode;
+
+{
+ /*
+ * Return the first replyWait in the list with the given majorOpcode
+ */
+
+ _IceSavedReplyWait *savedReplyWait = iceConn->saved_reply_waits;
+
+ while (savedReplyWait && !savedReplyWait->reply_ready &&
+ savedReplyWait->reply_wait->major_opcode_of_request != majorOpcode)
+ {
+ savedReplyWait = savedReplyWait->next;
+ }
+
+ return (savedReplyWait ? savedReplyWait->reply_wait : NULL);
+}
+
+
+
+void
+_IceSetReplyReady (iceConn, replyWait)
+
+IceConn iceConn;
+IceReplyWaitInfo *replyWait;
+
+{
+ /*
+ * The replyWait specified has a reply ready.
+ */
+
+ _IceSavedReplyWait *savedReplyWait = iceConn->saved_reply_waits;
+
+ while (savedReplyWait && savedReplyWait->reply_wait != replyWait)
+ savedReplyWait = savedReplyWait->next;
+
+ if (savedReplyWait)
+ savedReplyWait->reply_ready = True;
+}
+
+
+
+Bool
+_IceCheckReplyReady (iceConn, replyWait)
+
+IceConn iceConn;
+IceReplyWaitInfo *replyWait;
+
+{
+ _IceSavedReplyWait *savedReplyWait = iceConn->saved_reply_waits;
+ _IceSavedReplyWait *prev = NULL;
+ Bool found = False;
+ Bool ready;
+
+ while (savedReplyWait && !found)
+ {
+ if (savedReplyWait->reply_wait == replyWait)
+ found = True;
+ else
+ {
+ prev = savedReplyWait;
+ savedReplyWait = savedReplyWait->next;
+ }
+ }
+
+ ready = found && savedReplyWait->reply_ready;
+
+ if (ready)
+ {
+ if (prev == NULL)
+ iceConn->saved_reply_waits = savedReplyWait->next;
+ else
+ prev->next = savedReplyWait->next;
+
+ free ((char *) savedReplyWait);
+ }
+
+ return (ready);
+}
diff --git a/nx-X11/lib/ICE/setauth.c b/nx-X11/lib/ICE/setauth.c
new file mode 100644
index 000000000..4fd77182a
--- /dev/null
+++ b/nx-X11/lib/ICE/setauth.c
@@ -0,0 +1,121 @@
+/* $Xorg: setauth.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/setauth.c,v 1.4 2001/12/14 19:53:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+#include <X11/ICE/ICEutil.h>
+
+
+/*
+ * IceSetPaAuthData is not a standard part of ICElib, it is specific
+ * to the sample implementation.
+ *
+ * For the client that initiates a Protocol Setup, we look in the
+ * .ICEauthority file to get authentication data.
+ *
+ * For the client accepting the Protocol Setup, we get the data
+ * from an in-memory database of authentication data (set by the
+ * application calling IceSetPaAuthData). We have to get the data
+ * from memory because getting it directly from the .ICEauthority
+ * file is not secure - someone can just modify the contents of the
+ * .ICEauthority file behind our back.
+ */
+
+int _IcePaAuthDataEntryCount = 0;
+#ifndef __UNIXOS2__
+IceAuthDataEntry _IcePaAuthDataEntries[ICE_MAX_AUTH_DATA_ENTRIES];
+#else
+IceAuthDataEntry _IcePaAuthDataEntries[ICE_MAX_AUTH_DATA_ENTRIES] = {0};
+#endif
+
+
+void
+IceSetPaAuthData (numEntries, entries)
+
+int numEntries;
+IceAuthDataEntry *entries;
+
+{
+ /*
+ * _IcePaAuthDataEntries should really be a linked list.
+ * On my list of TO DO stuff.
+ */
+
+ int i, j;
+
+ for (i = 0; i < numEntries; i++)
+ {
+ for (j = 0; j < _IcePaAuthDataEntryCount; j++)
+ if (strcmp (entries[i].protocol_name,
+ _IcePaAuthDataEntries[j].protocol_name) == 0 &&
+ strcmp (entries[i].network_id,
+ _IcePaAuthDataEntries[j].network_id) == 0 &&
+ strcmp (entries[i].auth_name,
+ _IcePaAuthDataEntries[j].auth_name) == 0)
+ break;
+
+ if (j < _IcePaAuthDataEntryCount)
+ {
+ free (_IcePaAuthDataEntries[j].protocol_name);
+ free (_IcePaAuthDataEntries[j].network_id);
+ free (_IcePaAuthDataEntries[j].auth_name);
+ free (_IcePaAuthDataEntries[j].auth_data);
+ }
+ else
+ {
+ _IcePaAuthDataEntryCount++;
+ }
+
+ _IcePaAuthDataEntries[j].protocol_name = (char *) malloc (
+ strlen (entries[i].protocol_name) + 1);
+ strcpy (_IcePaAuthDataEntries[j].protocol_name,
+ entries[i].protocol_name);
+
+ _IcePaAuthDataEntries[j].network_id = (char *) malloc (
+ strlen (entries[i].network_id) + 1);
+ strcpy (_IcePaAuthDataEntries[j].network_id,
+ entries[i].network_id);
+
+ _IcePaAuthDataEntries[j].auth_name = (char *) malloc (
+ strlen (entries[i].auth_name) + 1);
+ strcpy (_IcePaAuthDataEntries[j].auth_name,
+ entries[i].auth_name);
+
+ _IcePaAuthDataEntries[j].auth_data_length =
+ entries[i].auth_data_length;
+ _IcePaAuthDataEntries[j].auth_data = (char *) malloc (
+ entries[i].auth_data_length);
+ memcpy (_IcePaAuthDataEntries[j].auth_data,
+ entries[i].auth_data, entries[i].auth_data_length);
+ }
+}
diff --git a/nx-X11/lib/ICE/shutdown.c b/nx-X11/lib/ICE/shutdown.c
new file mode 100644
index 000000000..5c957c7bb
--- /dev/null
+++ b/nx-X11/lib/ICE/shutdown.c
@@ -0,0 +1,330 @@
+/* $Xorg: shutdown.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+/* $XFree86: xc/lib/ICE/shutdown.c,v 3.3 2001/08/01 00:44:37 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+#include <X11/Xtrans/Xtrans.h>
+
+
+Status
+IceProtocolShutdown (iceConn, majorOpcode)
+
+IceConn iceConn;
+int majorOpcode;
+
+{
+ if (iceConn->proto_ref_count == 0 || iceConn->process_msg_info == NULL ||
+ majorOpcode < 1 || majorOpcode > _IceLastMajorOpcode)
+ {
+ return (0);
+ }
+ else
+ {
+ /*
+ * Make sure this majorOpcode is really being used.
+ */
+
+ int i;
+
+ for (i = iceConn->his_min_opcode; i <= iceConn->his_max_opcode; i++)
+ {
+ if (iceConn->process_msg_info[
+ i - iceConn->his_min_opcode].in_use &&
+ iceConn->process_msg_info[
+ i - iceConn->his_min_opcode].my_opcode == majorOpcode)
+ break;
+ }
+
+ if (i > iceConn->his_max_opcode)
+ {
+ return (0);
+ }
+ else
+ {
+ /*
+ * OK, we can shut down the protocol.
+ */
+
+ iceConn->process_msg_info[
+ i - iceConn->his_min_opcode].in_use = False;
+ iceConn->proto_ref_count--;
+
+ return (1);
+ }
+ }
+}
+
+
+
+void
+IceSetShutdownNegotiation (iceConn, negotiate)
+
+IceConn iceConn;
+Bool negotiate;
+
+{
+ iceConn->skip_want_to_close = negotiate ? False : True;
+}
+
+
+
+Bool
+IceCheckShutdownNegotiation (iceConn)
+
+IceConn iceConn;
+
+{
+ return (iceConn->skip_want_to_close ? False : True);
+}
+
+
+
+IceCloseStatus
+IceCloseConnection (iceConn)
+
+IceConn iceConn;
+
+{
+ int refCountReachedZero;
+ IceCloseStatus status;
+
+ /*
+ * If this connection object was never valid, we can close
+ * it right now. This happens if IceAcceptConnection was
+ * called, but after calling IceProcessMessages several times
+ * the connection was rejected (because of authentication or
+ * some other reason).
+ */
+
+ if (iceConn->listen_obj &&
+ iceConn->connection_status != IceConnectAccepted)
+ {
+ _IceConnectionClosed (iceConn); /* invoke watch procs */
+ _IceFreeConnection (iceConn);
+ return (IceClosedNow);
+ }
+
+
+ /*---------------------------------------------------------------
+
+ ACTIONS:
+
+ A = Invoke Watch Procedures
+ B = Set free-asap bit
+ C = Free connection
+ D = Initialize shutdown negotiation
+ N = do nothing
+
+
+ ACTION TABLE:
+
+ IO free- dispatch protocol shutdown
+ error asap bit level refcount negotiation ACTION
+ occured set reached 0 reached 0
+
+ 0 0 0 0 0 N
+ 0 0 0 0 1 N
+ 0 0 0 1 0 AB
+ 0 0 0 1 1 N
+ 0 0 1 0 0 N
+ 0 0 1 0 1 N
+ 0 0 1 1 0 AC
+ 0 0 1 1 1 D
+ 0 1 0 0 0 N
+ 0 1 0 0 1 N
+ 0 1 0 1 0 N
+ 0 1 0 1 1 N
+ 0 1 1 0 0 C
+ 0 1 1 0 1 D
+ 0 1 1 1 0 C
+ 0 1 1 1 1 D
+ 1 0 0 0 0 AB
+ 1 0 0 0 1 AB
+ 1 0 0 1 0 AB
+ 1 0 0 1 1 AB
+ 1 0 1 0 0 AC
+ 1 0 1 0 1 AC
+ 1 0 1 1 0 AC
+ 1 0 1 1 1 AC
+ 1 1 0 0 0 N
+ 1 1 0 0 1 N
+ 1 1 0 1 0 N
+ 1 1 0 1 1 N
+ 1 1 1 0 0 C
+ 1 1 1 0 1 C
+ 1 1 1 1 0 C
+ 1 1 1 1 1 C
+
+ ---------------------------------------------------------------*/
+
+ if (iceConn->open_ref_count > 0)
+ iceConn->open_ref_count--;
+
+ refCountReachedZero = iceConn->open_ref_count == 0 &&
+ iceConn->proto_ref_count == 0;
+
+ status = IceConnectionInUse;
+
+ if (!iceConn->free_asap && (!iceConn->io_ok ||
+ (iceConn->io_ok && refCountReachedZero &&
+ iceConn->skip_want_to_close)))
+ {
+ /*
+ * Invoke the watch procedures now.
+ */
+
+ _IceConnectionClosed (iceConn);
+ status = IceClosedNow; /* may be overwritten by IceClosedASAP */
+ }
+
+ if (!iceConn->free_asap && iceConn->dispatch_level != 0 &&
+ (!iceConn->io_ok ||
+ (iceConn->io_ok && refCountReachedZero &&
+ iceConn->skip_want_to_close)))
+ {
+ /*
+ * Set flag so we free the connection as soon as possible.
+ */
+
+ iceConn->free_asap = True;
+ status = IceClosedASAP;
+ }
+
+ if (iceConn->io_ok && iceConn->dispatch_level == 0 &&
+ !iceConn->skip_want_to_close && refCountReachedZero)
+ {
+ /*
+ * Initiate shutdown negotiation.
+ */
+
+ IceSimpleMessage (iceConn, 0, ICE_WantToClose);
+ IceFlush (iceConn);
+
+ iceConn->want_to_close = 1;
+
+ status = IceStartedShutdownNegotiation;
+ }
+ else if (iceConn->dispatch_level == 0 &&
+ (!iceConn->io_ok || (iceConn->io_ok && iceConn->skip_want_to_close &&
+ (iceConn->free_asap || (!iceConn->free_asap && refCountReachedZero)))))
+ {
+ /*
+ * Free the connection.
+ */
+
+ _IceFreeConnection (iceConn);
+
+ status = IceClosedNow;
+ }
+
+ return (status);
+}
+
+
+
+void
+_IceFreeConnection (iceConn)
+
+IceConn iceConn;
+
+{
+ if (iceConn->listen_obj == NULL)
+ {
+ /*
+ * This iceConn was created with IceOpenConnection.
+ * We keep track of all open IceConn's, so we need
+ * to remove it from the list.
+ */
+
+ int i;
+
+ for (i = 0; i < _IceConnectionCount; i++)
+ if (_IceConnectionObjs[i] == iceConn)
+ break;
+
+ if (i < _IceConnectionCount)
+ {
+ if (i < _IceConnectionCount - 1)
+ {
+ _IceConnectionObjs[i] =
+ _IceConnectionObjs[_IceConnectionCount - 1];
+ _IceConnectionStrings[i] =
+ _IceConnectionStrings[_IceConnectionCount - 1];
+ }
+
+ _IceConnectionCount--;
+ }
+ }
+
+ if (iceConn->trans_conn)
+ _IceTransClose (iceConn->trans_conn);
+
+ if (iceConn->connection_string)
+ free (iceConn->connection_string);
+
+ if (iceConn->vendor)
+ free (iceConn->vendor);
+
+ if (iceConn->release)
+ free (iceConn->release);
+
+ if (iceConn->inbuf)
+ free (iceConn->inbuf);
+
+ if (iceConn->outbuf)
+ free (iceConn->outbuf);
+
+ if (iceConn->scratch)
+ free (iceConn->scratch);
+
+ if (iceConn->process_msg_info)
+ free ((char *) iceConn->process_msg_info);
+
+ if (iceConn->connect_to_you)
+ free ((char *) iceConn->connect_to_you);
+
+ if (iceConn->protosetup_to_you)
+ free ((char *) iceConn->protosetup_to_you);
+
+ if (iceConn->connect_to_me)
+ free ((char *) iceConn->connect_to_me);
+
+ if (iceConn->protosetup_to_me)
+ free ((char *) iceConn->protosetup_to_me);
+
+ free ((char *) iceConn);
+}
+
+
+
+
diff --git a/nx-X11/lib/ICE/watch.c b/nx-X11/lib/ICE/watch.c
new file mode 100644
index 000000000..ec90d78e4
--- /dev/null
+++ b/nx-X11/lib/ICE/watch.c
@@ -0,0 +1,206 @@
+/* $Xorg: watch.c,v 1.4 2001/02/09 02:03:26 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: Ralph Mor, X Consortium
+******************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/ICE/ICElib.h>
+#include "ICElibint.h"
+
+
+Status
+IceAddConnectionWatch (watchProc, clientData)
+
+IceWatchProc watchProc;
+IcePointer clientData;
+
+{
+ /*
+ * watchProc will be called each time an ICE connection is
+ * created/destroyed by ICElib.
+ */
+
+ _IceWatchProc *ptr = _IceWatchProcs;
+ _IceWatchProc *newWatchProc;
+ int i;
+
+ if ((newWatchProc = (_IceWatchProc *) malloc (
+ sizeof (_IceWatchProc))) == NULL)
+ {
+ return (0);
+ }
+
+ newWatchProc->watch_proc = watchProc;
+ newWatchProc->client_data = clientData;
+ newWatchProc->watched_connections = NULL;
+ newWatchProc->next = NULL;
+
+ while (ptr && ptr->next)
+ ptr = ptr->next;
+
+ if (ptr == NULL)
+ _IceWatchProcs = newWatchProc;
+ else
+ ptr->next = newWatchProc;
+
+
+ /*
+ * Invoke the watch proc with any previously opened ICE connections.
+ */
+
+ for (i = 0; i < _IceConnectionCount; i++)
+ {
+ _IceWatchedConnection *newWatchedConn = (_IceWatchedConnection *)
+ malloc (sizeof (_IceWatchedConnection));
+
+ newWatchedConn->iceConn = _IceConnectionObjs[i];
+ newWatchedConn->next = NULL;
+
+ newWatchProc->watched_connections = newWatchedConn;
+
+ (*newWatchProc->watch_proc) (_IceConnectionObjs[i],
+ newWatchProc->client_data, True, &newWatchedConn->watch_data);
+ }
+
+ return (1);
+}
+
+
+
+void
+IceRemoveConnectionWatch (watchProc, clientData)
+
+IceWatchProc watchProc;
+IcePointer clientData;
+
+{
+ _IceWatchProc *currWatchProc = _IceWatchProcs;
+ _IceWatchProc *prevWatchProc = NULL;
+
+ while (currWatchProc && (currWatchProc->watch_proc != watchProc ||
+ currWatchProc->client_data != clientData))
+ {
+ prevWatchProc = currWatchProc;
+ currWatchProc = currWatchProc->next;
+ }
+
+ if (currWatchProc)
+ {
+ _IceWatchProc *nextWatchProc = currWatchProc->next;
+ _IceWatchedConnection *watchedConn;
+
+ watchedConn = currWatchProc->watched_connections;
+ while (watchedConn)
+ {
+ _IceWatchedConnection *nextWatchedConn = watchedConn->next;
+ free ((char *) watchedConn);
+ watchedConn = nextWatchedConn;
+ }
+
+ if (prevWatchProc == NULL)
+ _IceWatchProcs = nextWatchProc;
+ else
+ prevWatchProc->next = nextWatchProc;
+
+ free ((char *) currWatchProc);
+ }
+}
+
+
+
+void
+_IceConnectionOpened (iceConn)
+
+IceConn iceConn;
+
+{
+ _IceWatchProc *watchProc = _IceWatchProcs;
+
+ while (watchProc)
+ {
+ _IceWatchedConnection *newWatchedConn = (_IceWatchedConnection *)
+ malloc (sizeof (_IceWatchedConnection));
+ _IceWatchedConnection *watchedConn;
+
+ watchedConn = watchProc->watched_connections;
+ while (watchedConn && watchedConn->next)
+ watchedConn = watchedConn->next;
+
+ newWatchedConn->iceConn = iceConn;
+ newWatchedConn->next = NULL;
+
+ if (watchedConn == NULL)
+ watchProc->watched_connections = newWatchedConn;
+ else
+ watchedConn->next = newWatchedConn;
+
+ (*watchProc->watch_proc) (iceConn,
+ watchProc->client_data, True, &newWatchedConn->watch_data);
+
+ watchProc = watchProc->next;
+ }
+}
+
+
+
+void
+_IceConnectionClosed (iceConn)
+
+IceConn iceConn;
+
+{
+ _IceWatchProc *watchProc = _IceWatchProcs;
+
+ while (watchProc)
+ {
+ _IceWatchedConnection *watchedConn = watchProc->watched_connections;
+ _IceWatchedConnection *prev = NULL;
+
+ while (watchedConn && watchedConn->iceConn != iceConn)
+ {
+ prev = watchedConn;
+ watchedConn = watchedConn->next;
+ }
+
+ if (watchedConn)
+ {
+ (*watchProc->watch_proc) (iceConn,
+ watchProc->client_data, False, &watchedConn->watch_data);
+
+ if (prev == NULL)
+ watchProc->watched_connections = watchedConn->next;
+ else
+ prev->next = watchedConn->next;
+
+ free ((char *) watchedConn);
+ }
+
+ watchProc = watchProc->next;
+ }
+}
diff --git a/nx-X11/lib/Imakefile b/nx-X11/lib/Imakefile
new file mode 100644
index 000000000..240e8b330
--- /dev/null
+++ b/nx-X11/lib/Imakefile
@@ -0,0 +1,250 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:44:00 cpqbld Exp $
+XCOMM $XdotOrg: xc/lib/Imakefile,v 1.12 2005/10/10 04:18:08 alanc Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/Imakefile,v 3.74 2003/04/14 20:37:07 herrb Exp $
+
+#define IHaveSubdirs
+#define PassCDebugFlags
+
+#if BuildXaw6 && BuildLibraries
+XAW6LIBDIR = Xaw6
+#endif
+
+#if BuildXaw7 && BuildLibraries
+XAW7LIBDIR = Xaw7
+#endif
+
+#if BuildXaw && BuildLibraries
+XAWLIBDIR = Xaw
+#endif
+
+#ifndef NeedBerklib
+#define NeedBerklib NO
+#endif
+
+#if NeedBerklib
+BERKDIR = Xbsd
+#endif
+
+#if BuildXKBfilelib || BuildXKB
+XKBLIBDIR = xkbfile
+#endif
+
+#if BuildXKBuilib
+XKBUILIBDIR = xkbui
+#endif
+
+#if BuildXInputLib
+XINPUTLIBDIR = Xi
+#endif
+
+#if BuildScreenSaverLibrary
+SSLIBDIR = Xss
+#endif
+
+#if BuildXF86MiscLibrary
+XF86MISCLIBDIR = Xxf86misc
+#endif
+
+#if BuildXF86VidModeLibrary
+XF86VMLIBDIR = Xxf86vm
+#endif
+
+#if BuildXF86DGALibrary
+XF86DGALIBDIR = Xxf86dga
+#endif
+
+#if BuildXF86RushLibrary
+XF86RUSHLIBDIR = Xxf86rush
+#endif
+
+#if BuildXvLibrary
+XVLIBDIR = Xv
+XVMCLIBDIR = XvMC
+#endif
+
+#if BuildXineramaLibrary
+XINERAMADIR=Xinerama
+#endif
+
+#if BuildXResLibrary
+XRESLIBDIR = XRes
+#endif
+
+#if BuildDmxLibrary
+DMXLIBDIR = dmx
+#endif
+
+#if BuildGLXLibrary
+GLXLIBDIR = GL
+#endif
+
+#if BuildGLwLibrary
+GLWLIBDIR = GLw
+#endif
+
+#if BuildGLULibrary
+GLULIBDIR = GLU
+#endif
+
+#if BuildDPSLibrary
+DPSLIBDIR = dps
+#endif
+
+#if BuildDPSTkLibrary
+DPSTKLIBDIR = dpstk
+#endif
+
+#if BuildPSResLibrary
+PSRESLIBDIR = psres
+#endif
+
+#if BuildRenderLibrary
+RENDERLIBDIR = Xrender
+#endif
+
+#if BuildExpatLibrary
+EXPATBUILDDIR = expat
+#endif
+
+#if BuildFreetype2Library
+FREETYPE2BUILDDIR = freetype2
+#endif
+
+#if BuildFontconfigLibrary
+FONTCONFIGBUILDDIR = fontconfig
+#endif
+
+#if BuildXftLibrary
+XFTLIBDIR = Xft
+#endif
+
+#if BuildXft1Library
+XFT1LIBDIR = Xft1
+#endif
+
+#if BuildRandRLibrary
+RANDRLIBDIR = Xrandr
+#endif
+
+#if BuildXevieLibrary
+XEVIELIBDIR = Xevie
+#endif
+
+#if BuildXfixesLibrary
+XFIXESLIBDIR = Xfixes
+#endif
+
+#if BuildDamageLibrary
+DAMAGELIBDIR = Xdamage
+#endif
+
+#if BuildCompositeLibrary
+COMPOSITELIBDIR = Xcomposite
+#endif
+
+#if BuildXcursorLibrary
+XCURSORLIBDIR = Xcursor
+#endif
+
+#if BuildXTrapLibrary
+XTRAPLIBDIR = XTrap
+#endif
+
+#if BuildAppleWMLibrary
+APPLELIBDIR = apple
+#endif
+
+#if BuildWindowsWMLibrary
+WINDOWSLIBDIR = windows
+#endif
+
+XF86EXTLIBS = $(XF86MISCLIBDIR) $(XF86VMLIBDIR) \
+ $(XF86DGALIBDIR) $(XF86RUSHLIBDIR)
+
+#if BuildLBX
+LBXUTILDIR = lbxutil
+#endif
+
+#if (BuildLBX || GzipFontCompression) && !HasZlib
+ZLIBDIR = zlib
+#endif
+
+#if (defined(XFree86Version) || defined(XorgVersion)) && !HasPosixRegex
+REGEXDIR = regex
+#endif
+
+#if BuildXAudio
+XALIBDIR = Xa
+#endif
+
+#if BuildXprintLib
+XPRINTLIBDIRS = Xp XprintUtil XprintAppUtil
+#endif
+
+#if BuildFontCacheLib
+FONTCACHELIBDIR = Xfontcache
+#endif
+
+FONTSUBDIR = font
+
+#if BuildFontEncLib
+FONTENCSUBDIR = fontenc
+#endif
+
+#if BuildXauLib
+XAULIBDIR = Xau
+#endif
+
+#if BuildXdmcpLib
+XDMCPLIBDIR = Xdmcp
+#endif
+
+#if BuildX11Lib
+X11LIBDIR = X11
+#endif
+
+#if BuildXextLib
+XEXTLIBDIR = Xext
+#endif
+
+#if BuildLibraries
+OLDXLIBDIR = oldX
+ICELIBDIR = ICE
+SMLIBDIR = SM
+XTLIBDIR = Xt
+XMULIBDIR = Xmu
+XMUULIBDIR = Xmuu
+XPMLIBDIR = Xpm
+XTSTLIBDIR = Xtst
+FSLIBDIR = FS
+#endif
+
+
+LINTSUBDIRS = $(XAULIBDIR) $(XDMCPLIBDIR) $(X11LIBDIR) \
+ $(OLDXLIBDIR) $(ICELIBDIR) $(SMLIBDIR) $(XEXTLIBDIR) $(XTLIBDIR) \
+ $(SSLIBDIR) $(XF86MISCLIBDIR) $(XF86VMLIBDIR) $(XF86DGALIBDIR) \
+ $(XF86RUSHLIBDIR) $(XMULIBDIR) $(XMUULIBDIR) $(XPMLIBDIR) \
+ $(XPRINTLIBDIRS) $(XAW6LIBDIR) $(XAW7LIBDIR) $(XAWLIBDIR) \
+ $(XINPUTLIBDIR) $(XTSTLIBDIR) $(FSLIBDIR) $(XKBLIBDIR) \
+ $(XKBUILIBDIR) $(LBXUTILDIR) $(XALIBDIR) $(EXPATBUILDDIR) \
+ $(XVLIBDIR) $(GLXLIBDIR) $(GLULIBDIR) $(GLWLIBDIR) \
+ $(DPSLIBDIR) $(PSRESLIBDIR) $(DPSTKLIBDIR) $(XINERAMADIR) \
+ $(ZLIBDIR) $(REGEXDIR) $(RENDERLIBDIR) $(FREETYPE2BUILDDIR) \
+ $(FONTCONFIGBUILDDIR) $(XFT1LIBDIR) \
+ $(XFTLIBDIR) $(XVMCLIBDIR) $(RANDRLIBDIR) $(XTRAPLIBDIR) \
+ $(XRESLIBDIR) $(APPLELIBDIR) $(DMXLIBDIR) $(WINDOWSLIBDIR) \
+ $(XEVIELIBDIR) $(XFIXESLIBDIR) $(DAMAGELIBDIR) \
+ $(XCURSORLIBDIR) $(COMPOSITELIBDIR)
+
+SUBDIRS = $(BERKDIR) xtrans $(LINTSUBDIRS) $(FONTSUBDIR) $(FONTENCSUBDIR) \
+ $(FONTCACHELIBDIR)
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(LINTSUBDIRS))
+MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln)
+
diff --git a/nx-X11/lib/SM/Imakefile b/nx-X11/lib/SM/Imakefile
new file mode 100644
index 000000000..d2687bb64
--- /dev/null
+++ b/nx-X11/lib/SM/Imakefile
@@ -0,0 +1,56 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:44:28 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/SM/Imakefile,v 1.3 2001/01/17 19:41:31 dawes Exp $
+
+#define DoNormalLib NormalLibSM
+#define DoSharedLib SharedLibSM
+#define DoExtraLib SharedLibSM
+#define DoDebugLib DebugLibSM
+#define DoProfileLib ProfileLibSM
+#define LibName SM
+#define SoRev SOSMREV
+#define IncSubdir X11
+#define IncSubSubdir SM
+
+#include <Threads.tmpl>
+
+#ifdef SharedSMReqs
+REQUIREDLIBS = SharedSMReqs
+#endif
+
+#if (SystemV || SystemV4) && !HasSockets
+CONN_DEFINES = -DTCPCONN -DICE_t
+#else
+CONN_DEFINES = $(CONNECTION_FLAGS) -DICE_t
+#endif
+DEPEND_DEFINES = $(CONN_DEFINES) DependDefines
+
+HEADERS = SM.h \
+ SMproto.h \
+ SMlib.h
+
+SRCS = sm_client.c \
+ sm_genid.c \
+ sm_manager.c \
+ sm_process.c \
+ sm_error.c \
+ sm_misc.c \
+ sm_auth.c
+
+OBJS = sm_client.o \
+ sm_genid.o \
+ sm_manager.o \
+ sm_process.o \
+ sm_error.o \
+ sm_misc.o \
+ sm_auth.o
+
+#include <Library.tmpl>
+
+SpecialCLibObjectRule(sm_manager,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES))
+SpecialCLibObjectRule(sm_genid,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES))
+
+DependTarget()
diff --git a/nx-X11/lib/SM/SM-def.cpp b/nx-X11/lib/SM/SM-def.cpp
new file mode 100644
index 000000000..9a59704e2
--- /dev/null
+++ b/nx-X11/lib/SM/SM-def.cpp
@@ -0,0 +1,41 @@
+LIBRARY SM
+VERSION LIBRARY_VERSION
+EXPORTS
+ SmFreeProperty
+ SmFreeReasons
+ SmcClientID
+ SmcCloseConnection
+ SmcDeleteProperties
+ SmcGetIceConnection
+ SmcGetProperties
+ SmcInteractDone
+ SmcInteractRequest
+ SmcModifyCallbacks
+ SmcOpenConnection
+ SmcProtocolRevision
+ SmcProtocolVersion
+ SmcRelease
+ SmcRequestSaveYourself
+ SmcRequestSaveYourselfPhase2
+ SmcSaveYourselfDone
+ SmcSetErrorHandler
+ SmcSetProperties
+ SmcVendor
+ SmsCleanUp
+ SmsClientHostName
+ SmsClientID
+ SmsDie
+ SmsGenerateClientID
+ SmsGetIceConnection
+ SmsInitialize
+ SmsInteract
+ SmsProtocolRevision
+ SmsProtocolVersion
+ SmsRegisterClientReply
+ SmsReturnProperties
+ SmsSaveComplete
+ SmsSaveYourself
+ SmsSaveYourselfPhase2
+ SmsSetErrorHandler
+ SmsShutdownCancelled
+/* $Xorg: SM-def.cpp,v 1.3 2000/08/17 19:44:28 cpqbld Exp $ */
diff --git a/nx-X11/lib/SM/SM.h b/nx-X11/lib/SM/SM.h
new file mode 100644
index 000000000..0621b4918
--- /dev/null
+++ b/nx-X11/lib/SM/SM.h
@@ -0,0 +1,130 @@
+/* $Xorg: SM.h,v 1.4 2001/02/09 02:03:30 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: Ralph Mor, X Consortium
+ */
+
+#ifndef _SM_H_
+#define _SM_H_
+
+/*
+ * Protocol Version
+ */
+
+#define SmProtoMajor 1
+#define SmProtoMinor 0
+
+
+/*
+ * Interact Style
+ */
+
+#define SmInteractStyleNone 0
+#define SmInteractStyleErrors 1
+#define SmInteractStyleAny 2
+
+
+/*
+ * Dialog Type
+ */
+
+#define SmDialogError 0
+#define SmDialogNormal 1
+
+
+/*
+ * Save Type
+ */
+
+#define SmSaveGlobal 0
+#define SmSaveLocal 1
+#define SmSaveBoth 2
+
+
+/*
+ * Restart Style Hints
+ */
+
+#define SmRestartIfRunning 0
+#define SmRestartAnyway 1
+#define SmRestartImmediately 2
+#define SmRestartNever 3
+
+
+/*
+ * Property names
+ */
+
+#define SmCloneCommand "CloneCommand"
+#define SmCurrentDirectory "CurrentDirectory"
+#define SmDiscardCommand "DiscardCommand"
+#define SmEnvironment "Environment"
+#define SmProcessID "ProcessID"
+#define SmProgram "Program"
+#define SmRestartCommand "RestartCommand"
+#define SmResignCommand "ResignCommand"
+#define SmRestartStyleHint "RestartStyleHint"
+#define SmShutdownCommand "ShutdownCommand"
+#define SmUserID "UserID"
+
+
+/*
+ * Property types
+ */
+
+#define SmCARD8 "CARD8"
+#define SmARRAY8 "ARRAY8"
+#define SmLISTofARRAY8 "LISTofARRAY8"
+
+
+/*
+ * SM minor opcodes
+ */
+
+#define SM_Error 0
+#define SM_RegisterClient 1
+#define SM_RegisterClientReply 2
+#define SM_SaveYourself 3
+#define SM_SaveYourselfRequest 4
+#define SM_InteractRequest 5
+#define SM_Interact 6
+#define SM_InteractDone 7
+#define SM_SaveYourselfDone 8
+#define SM_Die 9
+#define SM_ShutdownCancelled 10
+#define SM_CloseConnection 11
+#define SM_SetProperties 12
+#define SM_DeleteProperties 13
+#define SM_GetProperties 14
+#define SM_PropertiesReply 15
+#define SM_SaveYourselfPhase2Request 16
+#define SM_SaveYourselfPhase2 17
+#define SM_SaveComplete 18
+
+#endif /* _SM_H_ */
diff --git a/nx-X11/lib/SM/SMlib.h b/nx-X11/lib/SM/SMlib.h
new file mode 100644
index 000000000..92418c148
--- /dev/null
+++ b/nx-X11/lib/SM/SMlib.h
@@ -0,0 +1,545 @@
+/* $Xorg: SMlib.h,v 1.4 2001/02/09 02:03:30 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: Ralph Mor, X Consortium
+ */
+
+#ifndef _SMLIB_H_
+#define _SMLIB_H_
+
+#include <X11/SM/SM.h>
+#include <X11/ICE/ICElib.h>
+
+
+/*
+ * Generic SM pointer
+ */
+
+typedef IcePointer SmPointer;
+
+
+/*
+ * Connection objects. Defined in SMlibint.h
+ */
+
+typedef struct _SmcConn *SmcConn;
+typedef struct _SmsConn *SmsConn;
+
+
+/*
+ * Session Management property
+ */
+
+typedef struct {
+ int length; /* length (in bytes) of the value */
+ SmPointer value; /* the value */
+} SmPropValue;
+
+typedef struct {
+ char *name; /* name of property */
+ char *type; /* type of property */
+ int num_vals; /* number of values in property */
+ SmPropValue *vals; /* the values */
+} SmProp;
+
+
+
+/*
+ * SmcCloseConnection status return
+ */
+
+typedef enum {
+ SmcClosedNow,
+ SmcClosedASAP,
+ SmcConnectionInUse
+} SmcCloseStatus;
+
+
+
+/*
+ * Client callbacks
+ */
+
+typedef void (*SmcSaveYourselfProc) (
+ SmcConn /* smcConn */,
+ SmPointer /* clientData */,
+ int /* saveType */,
+ Bool /* shutdown */,
+ int /* interactStyle */,
+ Bool /* fast */
+);
+
+typedef void (*SmcSaveYourselfPhase2Proc) (
+ SmcConn /* smcConn */,
+ SmPointer /* clientData */
+);
+
+typedef void (*SmcInteractProc) (
+ SmcConn /* smcConn */,
+ SmPointer /* clientData */
+);
+
+typedef void (*SmcDieProc) (
+ SmcConn /* smcConn */,
+ SmPointer /* clientData */
+);
+
+typedef void (*SmcShutdownCancelledProc) (
+ SmcConn /* smcConn */,
+ SmPointer /* clientData */
+);
+
+typedef void (*SmcSaveCompleteProc) (
+ SmcConn /* smcConn */,
+ SmPointer /* clientData */
+);
+
+typedef void (*SmcPropReplyProc) (
+ SmcConn /* smcConn */,
+ SmPointer /* clientData */,
+ int /* numProps */,
+ SmProp ** /* props */
+);
+
+
+/*
+ * Callbacks set up at SmcOpenConnection time
+ */
+
+typedef struct {
+
+ struct {
+ SmcSaveYourselfProc callback;
+ SmPointer client_data;
+ } save_yourself;
+
+ struct {
+ SmcDieProc callback;
+ SmPointer client_data;
+ } die;
+
+ struct {
+ SmcSaveCompleteProc callback;
+ SmPointer client_data;
+ } save_complete;
+
+ struct {
+ SmcShutdownCancelledProc callback;
+ SmPointer client_data;
+ } shutdown_cancelled;
+
+} SmcCallbacks;
+
+#define SmcSaveYourselfProcMask (1L << 0)
+#define SmcDieProcMask (1L << 1)
+#define SmcSaveCompleteProcMask (1L << 2)
+#define SmcShutdownCancelledProcMask (1L << 3)
+
+
+
+/*
+ * Session manager callbacks
+ */
+
+typedef Status (*SmsRegisterClientProc) (
+ SmsConn /* smsConn */,
+ SmPointer /* managerData */,
+ char * /* previousId */
+);
+
+typedef void (*SmsInteractRequestProc) (
+ SmsConn /* smsConn */,
+ SmPointer /* managerData */,
+ int /* dialogType */
+);
+
+typedef void (*SmsInteractDoneProc) (
+ SmsConn /* smsConn */,
+ SmPointer /* managerData */,
+ Bool /* cancelShutdown */
+);
+
+typedef void (*SmsSaveYourselfRequestProc) (
+ SmsConn /* smsConn */,
+ SmPointer /* managerData */,
+ int /* saveType */,
+ Bool /* shutdown */,
+ int /* interactStyle */,
+ Bool /* fast */,
+ Bool /* global */
+);
+
+typedef void (*SmsSaveYourselfPhase2RequestProc) (
+ SmsConn /* smsConn */,
+ SmPointer /* managerData */
+);
+
+typedef void (*SmsSaveYourselfDoneProc) (
+ SmsConn /* smsConn */,
+ SmPointer /* managerData */,
+ Bool /* success */
+);
+
+typedef void (*SmsCloseConnectionProc) (
+ SmsConn /* smsConn */,
+ SmPointer /* managerData */,
+ int /* count */,
+ char ** /* reasonMsgs */
+);
+
+typedef void (*SmsSetPropertiesProc) (
+ SmsConn /* smsConn */,
+ SmPointer /* managerData */,
+ int /* numProps */,
+ SmProp ** /* props */
+);
+
+typedef void (*SmsDeletePropertiesProc) (
+ SmsConn /* smsConn */,
+ SmPointer /* managerData */,
+ int /* numProps */,
+ char ** /* propNames */
+);
+
+typedef void (*SmsGetPropertiesProc) (
+ SmsConn /* smsConn */,
+ SmPointer /* managerData */
+);
+
+
+/*
+ * Callbacks set up by a session manager when a new client connects.
+ */
+
+typedef struct {
+
+ struct {
+ SmsRegisterClientProc callback;
+ SmPointer manager_data;
+ } register_client;
+
+ struct {
+ SmsInteractRequestProc callback;
+ SmPointer manager_data;
+ } interact_request;
+
+ struct {
+ SmsInteractDoneProc callback;
+ SmPointer manager_data;
+ } interact_done;
+
+ struct {
+ SmsSaveYourselfRequestProc callback;
+ SmPointer manager_data;
+ } save_yourself_request;
+
+ struct {
+ SmsSaveYourselfPhase2RequestProc callback;
+ SmPointer manager_data;
+ } save_yourself_phase2_request;
+
+ struct {
+ SmsSaveYourselfDoneProc callback;
+ SmPointer manager_data;
+ } save_yourself_done;
+
+ struct {
+ SmsCloseConnectionProc callback;
+ SmPointer manager_data;
+ } close_connection;
+
+ struct {
+ SmsSetPropertiesProc callback;
+ SmPointer manager_data;
+ } set_properties;
+
+ struct {
+ SmsDeletePropertiesProc callback;
+ SmPointer manager_data;
+ } delete_properties;
+
+ struct {
+ SmsGetPropertiesProc callback;
+ SmPointer manager_data;
+ } get_properties;
+
+} SmsCallbacks;
+
+
+#define SmsRegisterClientProcMask (1L << 0)
+#define SmsInteractRequestProcMask (1L << 1)
+#define SmsInteractDoneProcMask (1L << 2)
+#define SmsSaveYourselfRequestProcMask (1L << 3)
+#define SmsSaveYourselfP2RequestProcMask (1L << 4)
+#define SmsSaveYourselfDoneProcMask (1L << 5)
+#define SmsCloseConnectionProcMask (1L << 6)
+#define SmsSetPropertiesProcMask (1L << 7)
+#define SmsDeletePropertiesProcMask (1L << 8)
+#define SmsGetPropertiesProcMask (1L << 9)
+
+
+
+typedef Status (*SmsNewClientProc) (
+ SmsConn /* smsConn */,
+ SmPointer /* managerData */,
+ unsigned long * /* maskRet */,
+ SmsCallbacks * /* callbacksRet */,
+ char ** /* failureReasonRet */
+);
+
+
+
+/*
+ * Error handlers
+ */
+
+typedef void (*SmcErrorHandler) (
+ SmcConn /* smcConn */,
+ Bool /* swap */,
+ int /* offendingMinorOpcode */,
+ unsigned long /* offendingSequence */,
+ int /* errorClass */,
+ int /* severity */,
+ SmPointer /* values */
+);
+
+typedef void (*SmsErrorHandler) (
+ SmsConn /* smsConn */,
+ Bool /* swap */,
+ int /* offendingMinorOpcode */,
+ unsigned long /* offendingSequence */,
+ int /* errorClass */,
+ int /* severity */,
+ SmPointer /* values */
+);
+
+
+
+/*
+ * Function Prototypes
+ */
+
+_XFUNCPROTOBEGIN
+
+extern SmcConn SmcOpenConnection (
+ char * /* networkIdsList */,
+ SmPointer /* context */,
+ int /* xsmpMajorRev */,
+ int /* xsmpMinorRev */,
+ unsigned long /* mask */,
+ SmcCallbacks * /* callbacks */,
+ char * /* previousId */,
+ char ** /* clientIdRet */,
+ int /* errorLength */,
+ char * /* errorStringRet */
+);
+
+extern SmcCloseStatus SmcCloseConnection (
+ SmcConn /* smcConn */,
+ int /* count */,
+ char ** /* reasonMsgs */
+);
+
+extern void SmcModifyCallbacks (
+ SmcConn /* smcConn */,
+ unsigned long /* mask */,
+ SmcCallbacks * /* callbacks */
+);
+
+extern void SmcSetProperties (
+ SmcConn /* smcConn */,
+ int /* numProps */,
+ SmProp ** /* props */
+);
+
+extern void SmcDeleteProperties (
+ SmcConn /* smcConn */,
+ int /* numProps */,
+ char ** /* propNames */
+);
+
+extern Status SmcGetProperties (
+ SmcConn /* smcConn */,
+ SmcPropReplyProc /* propReplyProc */,
+ SmPointer /* clientData */
+);
+
+extern Status SmcInteractRequest (
+ SmcConn /* smcConn */,
+ int /* dialogType */,
+ SmcInteractProc /* interactProc */,
+ SmPointer /* clientData */
+);
+
+extern void SmcInteractDone (
+ SmcConn /* smcConn */,
+ Bool /* cancelShutdown */
+);
+
+extern void SmcRequestSaveYourself (
+ SmcConn /* smcConn */,
+ int /* saveType */,
+ Bool /* shutdown */,
+ int /* interactStyle */,
+ Bool /* fast */,
+ Bool /* global */
+);
+
+extern Status SmcRequestSaveYourselfPhase2 (
+ SmcConn /* smcConn */,
+ SmcSaveYourselfPhase2Proc /* saveYourselfPhase2Proc */,
+ SmPointer /* clientData */
+);
+
+extern void SmcSaveYourselfDone (
+ SmcConn /* smcConn */,
+ Bool /* success */
+);
+
+extern int SmcProtocolVersion (
+ SmcConn /* smcConn */
+);
+
+extern int SmcProtocolRevision (
+ SmcConn /* smcConn */
+);
+
+extern char *SmcVendor (
+ SmcConn /* smcConn */
+);
+
+extern char *SmcRelease (
+ SmcConn /* smcConn */
+);
+
+extern char *SmcClientID (
+ SmcConn /* smcConn */
+);
+
+extern IceConn SmcGetIceConnection (
+ SmcConn /* smcConn */
+);
+
+extern Status SmsInitialize (
+ char * /* vendor */,
+ char * /* release */,
+ SmsNewClientProc /* newClientProc */,
+ SmPointer /* managerData */,
+ IceHostBasedAuthProc /* hostBasedAuthProc */,
+ int /* errorLength */,
+ char * /* errorStringRet */
+);
+
+extern char *SmsClientHostName (
+ SmsConn /* smsConn */
+);
+
+extern char *SmsGenerateClientID (
+ SmsConn /* smsConn */
+);
+
+extern Status SmsRegisterClientReply (
+ SmsConn /* smsConn */,
+ char * /* clientId */
+);
+
+extern void SmsSaveYourself (
+ SmsConn /* smsConn */,
+ int /* saveType */,
+ Bool /* shutdown */,
+ int /* interactStyle */,
+ Bool /* fast */
+);
+
+extern void SmsSaveYourselfPhase2 (
+ SmsConn /* smsConn */
+);
+
+extern void SmsInteract (
+ SmsConn /* smsConn */
+);
+
+extern void SmsDie (
+ SmsConn /* smsConn */
+);
+
+extern void SmsSaveComplete (
+ SmsConn /* smsConn */
+);
+
+extern void SmsShutdownCancelled (
+ SmsConn /* smsConn */
+);
+
+extern void SmsReturnProperties (
+ SmsConn /* smsConn */,
+ int /* numProps */,
+ SmProp ** /* props */
+);
+
+extern void SmsCleanUp (
+ SmsConn /* smsConn */
+);
+
+extern int SmsProtocolVersion (
+ SmsConn /* smsConn */
+);
+
+extern int SmsProtocolRevision (
+ SmsConn /* smsConn */
+);
+
+extern char *SmsClientID (
+ SmsConn /* smsConn */
+);
+
+extern IceConn SmsGetIceConnection (
+ SmsConn /* smsConn */
+);
+
+extern SmcErrorHandler SmcSetErrorHandler (
+ SmcErrorHandler /* handler */
+);
+
+extern SmsErrorHandler SmsSetErrorHandler (
+ SmsErrorHandler /* handler */
+);
+
+extern void SmFreeProperty (
+ SmProp * /* prop */
+);
+
+extern void SmFreeReasons (
+ int /* count */,
+ char ** /* reasonMsgs */
+);
+
+_XFUNCPROTOEND
+
+#endif /* _SMLIB_H_ */
diff --git a/nx-X11/lib/SM/SMlibint.h b/nx-X11/lib/SM/SMlibint.h
new file mode 100644
index 000000000..e9fa9cd96
--- /dev/null
+++ b/nx-X11/lib/SM/SMlibint.h
@@ -0,0 +1,517 @@
+/* $Xorg: SMlibint.h,v 1.4 2001/02/09 02:03:30 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.
+
+*/
+/* $XFree86: xc/lib/SM/SMlibint.h,v 1.3 2001/07/29 05:01:11 tsi Exp $ */
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifndef _SMLIBINT_H_
+#define _SMLIBINT_H_
+
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xmd.h>
+#include <X11/ICE/ICEmsg.h>
+#include <X11/ICE/ICEproto.h>
+#include <X11/SM/SMproto.h>
+
+#include <stdlib.h>
+
+#ifndef NULL
+#include <stddef.h>
+#endif
+
+
+/*
+ * Vendor & Release
+ */
+
+#define SmVendorString "MIT"
+#define SmReleaseString "1.0"
+
+
+/*
+ * Pad to a 64 bit boundary
+ */
+
+#define PAD64(_bytes) ((8 - ((unsigned int) (_bytes) % 8)) % 8)
+
+#define PADDED_BYTES64(_bytes) (_bytes + PAD64 (_bytes))
+
+
+/*
+ * Pad to 32 bit boundary
+ */
+
+#define PAD32(_bytes) ((4 - ((unsigned int) (_bytes) % 4)) % 4)
+
+#define PADDED_BYTES32(_bytes) (_bytes + PAD32 (_bytes))
+
+
+/*
+ * Number of 8 byte units in _bytes.
+ */
+
+#define WORD64COUNT(_bytes) (((unsigned int) ((_bytes) + 7)) >> 3)
+
+
+/*
+ * Compute the number of bytes for an ARRAY8 representation
+ */
+
+#define ARRAY8_BYTES(_len) (4 + _len + PAD64 (4 + _len))
+
+
+
+/*
+ * Byte swapping
+ */
+
+/* byte swap a long literal */
+#define lswapl(_val) ((((_val) & 0xff) << 24) |\
+ (((_val) & 0xff00) << 8) |\
+ (((_val) & 0xff0000) >> 8) |\
+ (((_val) >> 24) & 0xff))
+
+/* byte swap a short literal */
+#define lswaps(_val) ((((_val) & 0xff) << 8) | (((_val) >> 8) & 0xff))
+
+
+/*
+ * STORE macros
+ */
+
+#ifndef WORD64
+
+#define STORE_CARD32(_pBuf, _val) \
+{ \
+ *((CARD32 *) _pBuf) = _val; \
+ _pBuf += 4; \
+}
+
+#else /* WORD64 */
+
+#define STORE_CARD32(_pBuf, _val) \
+{ \
+ struct { \
+ int value :32; \
+ } _d; \
+ _d.value = _val; \
+ memcpy (_pBuf, &_d, 4); \
+ _pBuf += 4; \
+}
+
+#endif /* WORD64 */
+
+
+/*
+ * EXTRACT macros
+ */
+
+#ifndef WORD64
+
+#define EXTRACT_CARD16(_pBuf, _swap, _val) \
+{ \
+ _val = *((CARD16 *) _pBuf); \
+ _pBuf += 2; \
+ if (_swap) \
+ _val = lswaps (_val); \
+}
+
+#define EXTRACT_CARD32(_pBuf, _swap, _val) \
+{ \
+ _val = *((CARD32 *) _pBuf); \
+ _pBuf += 4; \
+ if (_swap) \
+ _val = lswapl (_val); \
+}
+
+#else /* WORD64 */
+
+#define EXTRACT_CARD16(_pBuf, _swap, _val) \
+{ \
+ _val = *(_pBuf + 0) & 0xff; /* 0xff incase _pBuf is signed */ \
+ _val <<= 8; \
+ _val |= *(_pBuf + 1) & 0xff;\
+ _pBuf += 2; \
+ if (_swap) \
+ _val = lswaps (_val); \
+}
+
+#define EXTRACT_CARD32(_pBuf, _swap, _val) \
+{ \
+ _val = *(_pBuf + 0) & 0xff; /* 0xff incase _pBuf is signed */ \
+ _val <<= 8; \
+ _val |= *(_pBuf + 1) & 0xff;\
+ _val <<= 8; \
+ _val |= *(_pBuf + 2) & 0xff;\
+ _val <<= 8; \
+ _val |= *(_pBuf + 3) & 0xff;\
+ _pBuf += 4; \
+ if (_swap) \
+ _val = lswapl (_val); \
+}
+
+#endif /* WORD64 */
+
+
+/*
+ * Compute the number of bytes for a LISTofPROPERTY representation
+ */
+
+#define LISTOF_PROP_BYTES(_numProps, _props, _bytes) \
+{ \
+ int _i, _j; \
+ _bytes = 8; \
+ for (_i = 0; _i < _numProps; _i++) \
+ { \
+ _bytes += (8 + ARRAY8_BYTES (strlen (_props[_i]->name)) + \
+ ARRAY8_BYTES (strlen (_props[_i]->type))); \
+\
+ for (_j = 0; _j < _props[_i]->num_vals; _j++) \
+ _bytes += ARRAY8_BYTES (_props[_i]->vals[_j].length); \
+ } \
+}
+
+
+/*
+ * STORE FOO
+ */
+
+#define STORE_ARRAY8(_pBuf, _len, _array8) \
+{ \
+ STORE_CARD32 (_pBuf, _len); \
+ memcpy (_pBuf, _array8, _len); \
+ _pBuf += _len; \
+ if (PAD64 (4 + _len)) \
+ _pBuf += PAD64 (4 + _len); \
+}
+
+#define STORE_LISTOF_PROPERTY(_pBuf, _count, _props) \
+{ \
+ int _i, _j; \
+ STORE_CARD32 (_pBuf, _count); \
+ _pBuf += 4; \
+ for (_i = 0; _i < _count; _i++) \
+ { \
+ STORE_ARRAY8 (_pBuf, strlen (_props[_i]->name), _props[_i]->name); \
+ STORE_ARRAY8 (_pBuf, strlen (_props[_i]->type), _props[_i]->type); \
+ STORE_CARD32 (_pBuf, _props[_i]->num_vals); \
+ _pBuf += 4; \
+ for (_j = 0; _j < _props[_i]->num_vals; _j++) \
+ { \
+ STORE_ARRAY8 (_pBuf, _props[_i]->vals[_j].length, \
+ (char *) _props[_i]->vals[_j].value); \
+ } \
+ } \
+}
+
+
+/*
+ * EXTRACT FOO
+ */
+
+#define EXTRACT_ARRAY8(_pBuf, _swap, _len, _array8) \
+{ \
+ EXTRACT_CARD32 (_pBuf, _swap, _len); \
+ _array8 = (char *) malloc (_len + 1); \
+ memcpy (_array8, _pBuf, _len); \
+ _array8[_len] = '\0'; \
+ _pBuf += _len; \
+ if (PAD64 (4 + _len)) \
+ _pBuf += PAD64 (4 + _len); \
+}
+
+#define EXTRACT_ARRAY8_AS_STRING(_pBuf, _swap, _string) \
+{ \
+ CARD32 _len; \
+ EXTRACT_CARD32 (_pBuf, _swap, _len); \
+ _string = (char *) malloc (_len + 1); \
+ memcpy (_string, _pBuf, _len); \
+ _string[_len] = '\0'; \
+ _pBuf += _len; \
+ if (PAD64 (4 + _len)) \
+ _pBuf += PAD64 (4 + _len); \
+}
+
+#define EXTRACT_LISTOF_PROPERTY(_pBuf, _swap, _count, _props) \
+{ \
+ int _i, _j; \
+ EXTRACT_CARD32 (_pBuf, _swap, _count); \
+ _pBuf += 4; \
+ _props = (SmProp **) malloc (_count * sizeof (SmProp *)); \
+ for (_i = 0; _i < _count; _i++) \
+ { \
+ _props[_i] = (SmProp *) malloc (sizeof (SmProp)); \
+ EXTRACT_ARRAY8_AS_STRING (_pBuf, _swap, _props[_i]->name); \
+ EXTRACT_ARRAY8_AS_STRING (_pBuf, _swap, _props[_i]->type); \
+ EXTRACT_CARD32 (_pBuf, _swap, _props[_i]->num_vals); \
+ _pBuf += 4; \
+ _props[_i]->vals = (SmPropValue *) malloc ( \
+ _props[_i]->num_vals * sizeof (SmPropValue)); \
+ for (_j = 0; _j < _props[_i]->num_vals; _j++) \
+ { \
+ char *_temp; \
+ EXTRACT_ARRAY8 (_pBuf, _swap, _props[_i]->vals[_j].length, _temp);\
+ _props[_i]->vals[_j].value = (SmPointer) _temp; \
+ } \
+ } \
+}
+
+
+#define SKIP_ARRAY8(_pBuf, _swap) \
+{ \
+ CARD32 _len; \
+ EXTRACT_CARD32 (_pBuf, _swap, _len); \
+ _pBuf += _len; \
+ if (PAD64 (4 + _len)) \
+ _pBuf += PAD64 (4 + _len); \
+}
+
+#define SKIP_LISTOF_PROPERTY(_pBuf, _swap) \
+{ \
+ int _i, _j; \
+ CARD32 _count; \
+ EXTRACT_CARD32 (_pBuf, _swap, _count); \
+ _pBuf += 4; \
+ for (_i = 0; _i < _count; _i++) \
+ { \
+ CARD32 _numvals; \
+ SKIP_ARRAY8 (_pBuf, _swap); \
+ SKIP_ARRAY8 (_pBuf, _swap); \
+ EXTRACT_CARD32 (_pBuf, _swap, _numvals); \
+ _pBuf += 4; \
+ for (_j = 0; _j < _numvals; _j++) \
+ SKIP_ARRAY8 (_pBuf, _swap);\
+ } \
+}
+
+
+/*
+ * Client replies not processed by callbacks (we block for them).
+ */
+
+typedef struct {
+ Status status; /* if 1, client successfully registered */
+ char *client_id;
+} _SmcRegisterClientReply;
+
+
+/*
+ * Waiting for Interact
+ */
+
+typedef struct _SmcInteractWait {
+ SmcInteractProc interact_proc;
+ SmPointer client_data;
+ struct _SmcInteractWait *next;
+} _SmcInteractWait;
+
+
+/*
+ * Waiting for SaveYourselfPhase2
+ */
+
+typedef struct _SmcPhase2Wait {
+ SmcSaveYourselfPhase2Proc phase2_proc;
+ SmPointer client_data;
+} _SmcPhase2Wait;
+
+
+/*
+ * Waiting for Properties Reply
+ */
+
+typedef struct _SmcPropReplyWait {
+ SmcPropReplyProc prop_reply_proc;
+ SmPointer client_data;
+ struct _SmcPropReplyWait *next;
+} _SmcPropReplyWait;
+
+
+
+/*
+ * Client connection object
+ */
+
+struct _SmcConn {
+
+ /*
+ * Some state.
+ */
+
+ unsigned int save_yourself_in_progress : 1;
+ unsigned int shutdown_in_progress : 1;
+ unsigned int unused1 : 6; /* future use */
+ unsigned int unused2 : 8; /* future use */
+
+
+ /*
+ * We use ICE to esablish a connection with the SM.
+ */
+
+ IceConn iceConn;
+
+
+ /*
+ * Major and minor versions of the XSMP.
+ */
+
+ int proto_major_version;
+ int proto_minor_version;
+
+
+ /*
+ * The session manager vendor and release number.
+ */
+
+ char *vendor;
+ char *release;
+
+
+ /*
+ * The Client Id uniquely identifies this client to the session manager.
+ */
+
+ char *client_id;
+
+
+ /*
+ * Callbacks to be invoked when messages arrive from the session manager.
+ * These callbacks are specified at SmcOpenConnection time.
+ */
+
+ SmcCallbacks callbacks;
+
+
+ /*
+ * We keep track of all Interact Requests sent by the client. When the
+ * Interact message arrives, we remove it from the list (a FIFO list
+ * is maintained).
+ */
+
+ _SmcInteractWait *interact_waits;
+
+
+ /*
+ * If we send a SaveYourselfPhase2Request, we wait for SaveYourselfPhase2.
+ */
+
+ _SmcPhase2Wait *phase2_wait;
+
+
+ /*
+ * We keep track of all Get Properties sent by the client. When the
+ * Properties Reply arrives, we remove it from the list (a FIFO list
+ * is maintained).
+ */
+
+ _SmcPropReplyWait *prop_reply_waits;
+};
+
+
+
+/*
+ * Session manager connection object
+ */
+
+struct _SmsConn {
+
+ /*
+ * Some state.
+ */
+
+ unsigned int save_yourself_in_progress : 1;
+ unsigned int can_cancel_shutdown : 1;
+ unsigned int interact_in_progress : 1;
+ unsigned int unused1 : 5; /* future use */
+ unsigned int unused2 : 8; /* future use */
+
+
+ /*
+ * We use ICE to esablish a connection with the client.
+ */
+
+ IceConn iceConn;
+
+
+ /*
+ * Major and minor versions of the XSMP.
+ */
+
+ int proto_major_version;
+ int proto_minor_version;
+
+
+ /*
+ * The Client Id uniquely identifies this client to the session manager.
+ */
+
+ char *client_id;
+
+
+ /*
+ * Callbacks to be invoked when messages arrive from the client.
+ */
+
+ SmsCallbacks callbacks;
+
+
+ /*
+ * What type of interaction is allowed - SmInteractStyle{None,Errors,Any}
+ */
+
+ char interaction_allowed;
+};
+
+
+
+/*
+ * Extern declarations
+ */
+
+extern int _SmcOpcode;
+extern int _SmsOpcode;
+
+extern int _SmVersionCount;
+extern IcePoVersionRec _SmcVersions[];
+extern IcePaVersionRec _SmsVersions[];
+
+extern int _SmAuthCount;
+extern char *_SmAuthNames[];
+extern IcePoAuthProc _SmcAuthProcs[];
+extern IcePaAuthProc _SmsAuthProcs[];
+
+extern SmsNewClientProc _SmsNewClientProc;
+extern SmPointer _SmsNewClientData;
+
+extern SmcErrorHandler _SmcErrorHandler;
+extern SmsErrorHandler _SmsErrorHandler;
+
+#endif /* _SMLIBINT_H_ */
diff --git a/nx-X11/lib/SM/SMproto.h b/nx-X11/lib/SM/SMproto.h
new file mode 100644
index 000000000..f60ab3e4a
--- /dev/null
+++ b/nx-X11/lib/SM/SMproto.h
@@ -0,0 +1,208 @@
+/* $Xorg: SMproto.h,v 1.5 2001/02/09 02:03:30 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: Ralph Mor, X Consortium
+ */
+
+#ifndef _SMPROTO_H_
+#define _SMPROTO_H_
+
+#include <X11/Xmd.h>
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused[2];
+ CARD32 length B32;
+ /* n ARRAY8 previousId */
+} smRegisterClientMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused[2];
+ CARD32 length B32;
+ /* n ARRAY8 clientId */
+} smRegisterClientReplyMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused1[2];
+ CARD32 length B32;
+ CARD8 saveType;
+ CARD8 shutdown;
+ CARD8 interactStyle;
+ CARD8 fast;
+ CARD8 unused2[4];
+} smSaveYourselfMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused1[2];
+ CARD32 length B32;
+ CARD8 saveType;
+ CARD8 shutdown;
+ CARD8 interactStyle;
+ CARD8 fast;
+ CARD8 global;
+ CARD8 unused2[3];
+} smSaveYourselfRequestMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 dialogType;
+ CARD8 unused;
+ CARD32 length B32;
+} smInteractRequestMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused[2];
+ CARD32 length B32;
+} smInteractMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 cancelShutdown;
+ CARD8 unused;
+ CARD32 length B32;
+} smInteractDoneMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 success;
+ CARD8 unused;
+ CARD32 length B32;
+} smSaveYourselfDoneMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused[2];
+ CARD32 length B32;
+} smDieMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused[2];
+ CARD32 length B32;
+} smShutdownCancelledMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused[2];
+ CARD32 length B32;
+ /* b LISTofARRAY8 reasons */
+} smCloseConnectionMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused[2];
+ CARD32 length B32;
+ /* a LISTofPROPERTY properties */
+} smSetPropertiesMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused[2];
+ CARD32 length B32;
+ /* a LISTofARRAY8 property names */
+} smDeletePropertiesMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused[2];
+ CARD32 length B32;
+} smGetPropertiesMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused[2];
+ CARD32 length B32;
+ /* a LISTofPROPERTY properties */
+} smPropertiesReplyMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused[2];
+ CARD32 length B32;
+} smSaveYourselfPhase2RequestMsg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused[2];
+ CARD32 length B32;
+} smSaveYourselfPhase2Msg;
+
+typedef struct {
+ CARD8 majorOpcode;
+ CARD8 minorOpcode;
+ CARD8 unused[2];
+ CARD32 length B32;
+} smSaveCompleteMsg;
+
+
+/*
+ * SIZEOF values. These better be multiples of 8.
+ */
+
+#define sz_smRegisterClientMsg 8
+#define sz_smRegisterClientReplyMsg 8
+#define sz_smSaveYourselfMsg 16
+#define sz_smSaveYourselfRequestMsg 16
+#define sz_smInteractRequestMsg 8
+#define sz_smInteractMsg 8
+#define sz_smInteractDoneMsg 8
+#define sz_smSaveYourselfDoneMsg 8
+#define sz_smDieMsg 8
+#define sz_smShutdownCancelledMsg 8
+#define sz_smCloseConnectionMsg 8
+#define sz_smSetPropertiesMsg 8
+#define sz_smDeletePropertiesMsg 8
+#define sz_smGetPropertiesMsg 8
+#define sz_smPropertiesReplyMsg 8
+#define sz_smSaveYourselfPhase2RequestMsg 8
+#define sz_smSaveYourselfPhase2Msg 8
+#define sz_smSaveCompleteMsg 8
+
+#endif /* _SMPROTO_H_ */
diff --git a/nx-X11/lib/SM/globals.h b/nx-X11/lib/SM/globals.h
new file mode 100644
index 000000000..2f26a78e9
--- /dev/null
+++ b/nx-X11/lib/SM/globals.h
@@ -0,0 +1,68 @@
+/* $Xorg: globals.h,v 1.4 2001/02/09 02:03:30 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.
+
+*/
+/* $XFree86: xc/lib/SM/globals.h,v 1.4 2001/12/14 19:53:55 dawes Exp $ */
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+extern void _SmcDefaultErrorHandler ();
+extern void _SmsDefaultErrorHandler ();
+
+extern IcePoAuthStatus _IcePoMagicCookie1Proc ();
+extern IcePaAuthStatus _IcePaMagicCookie1Proc ();
+
+extern void _SmcProcessMessage ();
+extern void _SmsProcessMessage ();
+
+int _SmcOpcode = 0;
+int _SmsOpcode = 0;
+
+int _SmVersionCount = 1;
+
+IcePoVersionRec _SmcVersions[] = {
+ {SmProtoMajor, SmProtoMinor, _SmcProcessMessage}};
+
+IcePaVersionRec _SmsVersions[] = {
+ {SmProtoMajor, SmProtoMinor, _SmsProcessMessage}};
+
+int _SmAuthCount = 1;
+char *_SmAuthNames[] = {"MIT-MAGIC-COOKIE-1"};
+IcePoAuthProc _SmcAuthProcs[] = {_IcePoMagicCookie1Proc};
+IcePaAuthProc _SmsAuthProcs[] = {_IcePaMagicCookie1Proc};
+
+#ifndef __UNIXOS2__
+SmsNewClientProc _SmsNewClientProc;
+SmPointer _SmsNewClientData;
+#else
+SmsNewClientProc _SmsNewClientProc = 0;
+SmPointer _SmsNewClientData = 0;
+#endif
+
+SmcErrorHandler _SmcErrorHandler = _SmcDefaultErrorHandler;
+SmsErrorHandler _SmsErrorHandler = _SmsDefaultErrorHandler;
diff --git a/nx-X11/lib/SM/sm_auth.c b/nx-X11/lib/SM/sm_auth.c
new file mode 100644
index 000000000..9acd371ce
--- /dev/null
+++ b/nx-X11/lib/SM/sm_auth.c
@@ -0,0 +1,48 @@
+/* $Xorg: sm_auth.c,v 1.4 2001/02/09 02:03:30 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.
+
+*/
+/* $XFree86$ */
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+
+#ifdef __UNIXOS2__
+static char dummy;
+#endif
+
+/*
+ * For now, SMlib just supports MIT-MAGIC-COOKIE-1 (defined in ICElib).
+ */
+
+
diff --git a/nx-X11/lib/SM/sm_client.c b/nx-X11/lib/SM/sm_client.c
new file mode 100644
index 000000000..499be5e3d
--- /dev/null
+++ b/nx-X11/lib/SM/sm_client.c
@@ -0,0 +1,633 @@
+/* $Xorg: sm_client.c,v 1.4 2001/02/09 02:03:30 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: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+#include "globals.h"
+
+static void set_callbacks();
+
+
+SmcConn
+SmcOpenConnection (networkIdsList, context,
+ xsmpMajorRev, xsmpMinorRev, mask, callbacks,
+ previousId, clientIdRet, errorLength, errorStringRet)
+
+char *networkIdsList;
+SmPointer context;
+int xsmpMajorRev;
+int xsmpMinorRev;
+unsigned long mask;
+SmcCallbacks *callbacks;
+char *previousId;
+char **clientIdRet;
+int errorLength;
+char *errorStringRet;
+
+{
+ SmcConn smcConn;
+ IceConn iceConn;
+ char *ids;
+ IceProtocolSetupStatus setupstat;
+ int majorVersion;
+ int minorVersion;
+ char *vendor = NULL;
+ char *release = NULL;
+ smRegisterClientMsg *pMsg;
+ char *pData;
+ int extra, len;
+ IceReplyWaitInfo replyWait;
+ _SmcRegisterClientReply reply;
+ Bool gotReply, ioErrorOccured;
+
+ *clientIdRet = NULL;
+
+ if (errorStringRet && errorLength > 0)
+ *errorStringRet = '\0';
+
+ if (!_SmcOpcode)
+ {
+ /*
+ * For now, there is only one version of XSMP, so we don't
+ * have to check {xsmpMajorRev, xsmpMinorRev}. In the future,
+ * we will check against _SmcVersions and generate the list
+ * of versions the application actually supports.
+ */
+
+ if ((_SmcOpcode = IceRegisterForProtocolSetup ("XSMP",
+ SmVendorString, SmReleaseString, _SmVersionCount, _SmcVersions,
+ _SmAuthCount, _SmAuthNames, _SmcAuthProcs, NULL)) < 0)
+ {
+ strncpy (errorStringRet,
+ "Could not register XSMP protocol with ICE", errorLength);
+
+ return (NULL);
+ }
+ }
+
+ if (networkIdsList == NULL || *networkIdsList == '\0')
+ {
+ if ((ids = (char *) getenv ("SESSION_MANAGER")) == NULL)
+ {
+ strncpy (errorStringRet,
+ "SESSION_MANAGER environment variable not defined",
+ errorLength);
+
+ return (NULL);
+ }
+ }
+ else
+ {
+ ids = networkIdsList;
+ }
+
+ if ((iceConn = IceOpenConnection (
+ ids, context, 0, _SmcOpcode, errorLength, errorStringRet)) == NULL)
+ {
+ return (NULL);
+ }
+
+ if ((smcConn = (SmcConn) malloc (sizeof (struct _SmcConn))) == NULL)
+ {
+ strncpy (errorStringRet, "Can't malloc", errorLength);
+ IceCloseConnection (iceConn);
+ return (NULL);
+ }
+
+ setupstat = IceProtocolSetup (iceConn, _SmcOpcode,
+ (IcePointer) smcConn,
+ False /* mustAuthenticate */,
+ &majorVersion, &minorVersion,
+ &vendor, &release, errorLength, errorStringRet);
+
+ if (setupstat == IceProtocolSetupFailure ||
+ setupstat == IceProtocolSetupIOError)
+ {
+ IceCloseConnection (iceConn);
+ free ((char *) smcConn);
+ return (NULL);
+ }
+ else if (setupstat == IceProtocolAlreadyActive)
+ {
+ /*
+ * This case should never happen, because when we called
+ * IceOpenConnection, we required that the ICE connection
+ * may not already have XSMP active on it.
+ */
+
+ free ((char *) smcConn);
+ strncpy (errorStringRet, "Internal error in IceOpenConnection",
+ errorLength);
+ return (NULL);
+ }
+
+ smcConn->iceConn = iceConn;
+ smcConn->proto_major_version = majorVersion;
+ smcConn->proto_minor_version = minorVersion;
+ smcConn->vendor = vendor;
+ smcConn->release = release;
+ smcConn->client_id = NULL;
+
+ bzero ((char *) &smcConn->callbacks, sizeof (SmcCallbacks));
+ set_callbacks (smcConn, mask, callbacks);
+
+ smcConn->interact_waits = NULL;
+ smcConn->phase2_wait = NULL;
+ smcConn->prop_reply_waits = NULL;
+
+ smcConn->save_yourself_in_progress = False;
+ smcConn->shutdown_in_progress = False;
+
+
+ /*
+ * Now register the client
+ */
+
+ len = previousId ? strlen (previousId) : 0;
+ extra = ARRAY8_BYTES (len);
+
+ IceGetHeaderExtra (iceConn, _SmcOpcode, SM_RegisterClient,
+ SIZEOF (smRegisterClientMsg), WORD64COUNT (extra),
+ smRegisterClientMsg, pMsg, pData);
+
+ STORE_ARRAY8 (pData, len, previousId);
+
+ IceFlush (iceConn);
+
+ replyWait.sequence_of_request = IceLastSentSequenceNumber (iceConn);
+ replyWait.major_opcode_of_request = _SmcOpcode;
+ replyWait.minor_opcode_of_request = SM_RegisterClient;
+ replyWait.reply = (IcePointer) &reply;
+
+ gotReply = False;
+ ioErrorOccured = False;
+
+ while (!gotReply && !ioErrorOccured)
+ {
+ ioErrorOccured = (IceProcessMessages (
+ iceConn, &replyWait, &gotReply) == IceProcessMessagesIOError);
+
+ if (ioErrorOccured)
+ {
+ strncpy (errorStringRet, "IO error occured opening connection",
+ errorLength);
+
+ free (smcConn->vendor);
+ free (smcConn->release);
+ free ((char *) smcConn);
+
+ return (NULL);
+ }
+ else if (gotReply)
+ {
+ if (reply.status == 1)
+ {
+ /*
+ * The client successfully registered.
+ */
+
+ *clientIdRet = reply.client_id;
+
+ smcConn->client_id = (char *) malloc (
+ strlen (*clientIdRet) + 1);
+
+ strcpy (smcConn->client_id, *clientIdRet);
+ }
+ else
+ {
+ /*
+ * Could not register the client because the previous ID
+ * was bad. So now we register the client with the
+ * previous ID set to NULL.
+ */
+
+ extra = ARRAY8_BYTES (0);
+
+ IceGetHeaderExtra (iceConn, _SmcOpcode, SM_RegisterClient,
+ SIZEOF (smRegisterClientMsg), WORD64COUNT (extra),
+ smRegisterClientMsg, pMsg, pData);
+
+ previousId = NULL;
+
+ STORE_ARRAY8 (pData, 0, previousId);
+
+ IceFlush (iceConn);
+
+ replyWait.sequence_of_request =
+ IceLastSentSequenceNumber (iceConn);
+
+ gotReply = False;
+ }
+ }
+ }
+
+ return (smcConn);
+}
+
+
+
+SmcCloseStatus
+SmcCloseConnection (smcConn, count, reasonMsgs)
+
+SmcConn smcConn;
+int count;
+char **reasonMsgs;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smCloseConnectionMsg *pMsg;
+ char *pData;
+ int extra, i;
+ IceCloseStatus closeStatus;
+ SmcCloseStatus statusRet;
+
+ extra = 8;
+
+ for (i = 0; i < count; i++)
+ extra += ARRAY8_BYTES (strlen (reasonMsgs[i]));
+
+ IceGetHeaderExtra (iceConn, _SmcOpcode, SM_CloseConnection,
+ SIZEOF (smCloseConnectionMsg), WORD64COUNT (extra),
+ smCloseConnectionMsg, pMsg, pData);
+
+ STORE_CARD32 (pData, count);
+ pData += 4;
+
+ for (i = 0; i < count; i++)
+ STORE_ARRAY8 (pData, strlen (reasonMsgs[i]), reasonMsgs[i]);
+
+ IceFlush (iceConn);
+
+ IceProtocolShutdown (iceConn, _SmcOpcode);
+ IceSetShutdownNegotiation (iceConn, False);
+ closeStatus = IceCloseConnection (iceConn);
+
+ if (smcConn->vendor)
+ free (smcConn->vendor);
+
+ if (smcConn->release)
+ free (smcConn->release);
+
+ if (smcConn->client_id)
+ free (smcConn->client_id);
+
+ if (smcConn->prop_reply_waits)
+ {
+ _SmcPropReplyWait *ptr = smcConn->prop_reply_waits;
+ _SmcPropReplyWait *next;
+
+ while (ptr)
+ {
+ next = ptr->next;
+ free ((char *) ptr);
+ ptr = next;
+ }
+
+ }
+
+ free ((char *) smcConn);
+
+ if (closeStatus == IceClosedNow)
+ statusRet = SmcClosedNow;
+ else if (closeStatus == IceClosedASAP)
+ statusRet = SmcClosedASAP;
+ else
+ statusRet = SmcConnectionInUse;
+
+ return (statusRet);
+}
+
+
+
+void
+SmcModifyCallbacks (smcConn, mask, callbacks)
+
+SmcConn smcConn;
+unsigned long mask;
+SmcCallbacks *callbacks;
+
+{
+ set_callbacks (smcConn, mask, callbacks);
+}
+
+
+
+void
+SmcSetProperties (smcConn, numProps, props)
+
+SmcConn smcConn;
+int numProps;
+SmProp **props;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smSetPropertiesMsg *pMsg;
+ char *pBuf;
+ char *pStart;
+ int bytes;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_SetProperties,
+ SIZEOF (smSetPropertiesMsg), smSetPropertiesMsg, pMsg);
+
+ LISTOF_PROP_BYTES (numProps, props, bytes);
+ pMsg->length += WORD64COUNT (bytes);
+
+ pBuf = pStart = IceAllocScratch (iceConn, bytes);
+
+ STORE_LISTOF_PROPERTY (pBuf, numProps, props);
+
+ IceWriteData (iceConn, bytes, pStart);
+ IceFlush (iceConn);
+}
+
+
+
+void
+SmcDeleteProperties (smcConn, numProps, propNames)
+
+SmcConn smcConn;
+int numProps;
+char **propNames;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smDeletePropertiesMsg *pMsg;
+ char *pData;
+ int extra, i;
+
+ extra = 8;
+
+ for (i = 0; i < numProps; i++)
+ extra += ARRAY8_BYTES (strlen (propNames[i]));
+
+ IceGetHeaderExtra (iceConn, _SmcOpcode, SM_DeleteProperties,
+ SIZEOF (smDeletePropertiesMsg), WORD64COUNT (extra),
+ smDeletePropertiesMsg, pMsg, pData);
+
+ STORE_CARD32 (pData, numProps);
+ pData += 4;
+
+ for (i = 0; i < numProps; i++)
+ STORE_ARRAY8 (pData, strlen (propNames[i]), propNames[i]);
+
+ IceFlush (iceConn);
+}
+
+
+
+Status
+SmcGetProperties (smcConn, propReplyProc, clientData)
+
+SmcConn smcConn;
+SmcPropReplyProc propReplyProc;
+SmPointer clientData;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ _SmcPropReplyWait *wait, *ptr;
+
+ if ((wait = (_SmcPropReplyWait *) malloc (
+ sizeof (_SmcPropReplyWait))) == NULL)
+ {
+ return (0);
+ }
+
+ wait->prop_reply_proc = propReplyProc;
+ wait->client_data = clientData;
+ wait->next = NULL;
+
+ ptr = smcConn->prop_reply_waits;
+ while (ptr && ptr->next)
+ ptr = ptr->next;
+
+ if (ptr == NULL)
+ smcConn->prop_reply_waits = wait;
+ else
+ ptr->next = wait;
+
+ IceSimpleMessage (iceConn, _SmcOpcode, SM_GetProperties);
+ IceFlush (iceConn);
+
+ return (1);
+}
+
+
+
+Status
+SmcInteractRequest (smcConn, dialogType, interactProc, clientData)
+
+SmcConn smcConn;
+int dialogType;
+SmcInteractProc interactProc;
+SmPointer clientData;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smInteractRequestMsg *pMsg;
+ _SmcInteractWait *wait, *ptr;
+
+ if ((wait = (_SmcInteractWait *) malloc (
+ sizeof (_SmcInteractWait))) == NULL)
+ {
+ return (0);
+ }
+
+ wait->interact_proc = interactProc;
+ wait->client_data = clientData;
+ wait->next = NULL;
+
+ ptr = smcConn->interact_waits;
+ while (ptr && ptr->next)
+ ptr = ptr->next;
+
+ if (ptr == NULL)
+ smcConn->interact_waits = wait;
+ else
+ ptr->next = wait;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_InteractRequest,
+ SIZEOF (smInteractRequestMsg), smInteractRequestMsg, pMsg);
+
+ pMsg->dialogType = dialogType;
+
+ IceFlush (iceConn);
+
+ return (1);
+}
+
+
+
+void
+SmcInteractDone (smcConn, cancelShutdown)
+
+SmcConn smcConn;
+Bool cancelShutdown;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smInteractDoneMsg *pMsg;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_InteractDone,
+ SIZEOF (smInteractDoneMsg), smInteractDoneMsg, pMsg);
+
+ pMsg->cancelShutdown = cancelShutdown;
+
+ IceFlush (iceConn);
+}
+
+
+
+void
+SmcRequestSaveYourself (smcConn, saveType, shutdown, interactStyle,
+ fast, global)
+
+SmcConn smcConn;
+int saveType;
+Bool shutdown;
+int interactStyle;
+Bool fast;
+Bool global;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smSaveYourselfRequestMsg *pMsg;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfRequest,
+ SIZEOF (smSaveYourselfRequestMsg), smSaveYourselfRequestMsg, pMsg);
+
+ pMsg->saveType = saveType;
+ pMsg->shutdown = shutdown;
+ pMsg->interactStyle = interactStyle;
+ pMsg->fast = fast;
+ pMsg->global = global;
+
+ IceFlush (iceConn);
+}
+
+
+
+Status
+SmcRequestSaveYourselfPhase2 (smcConn, saveYourselfPhase2Proc, clientData)
+
+SmcConn smcConn;
+SmcSaveYourselfPhase2Proc saveYourselfPhase2Proc;
+SmPointer clientData;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ _SmcPhase2Wait *wait;
+
+ if (smcConn->phase2_wait)
+ wait = smcConn->phase2_wait;
+ else
+ {
+ if ((wait = (_SmcPhase2Wait *) malloc (
+ sizeof (_SmcPhase2Wait))) == NULL)
+ {
+ return (0);
+ }
+ }
+
+ wait->phase2_proc = saveYourselfPhase2Proc;
+ wait->client_data = clientData;
+
+ smcConn->phase2_wait = wait;
+
+ IceSimpleMessage (iceConn, _SmcOpcode, SM_SaveYourselfPhase2Request);
+ IceFlush (iceConn);
+
+ return (1);
+}
+
+
+
+void
+SmcSaveYourselfDone (smcConn, success)
+
+SmcConn smcConn;
+Bool success;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smSaveYourselfDoneMsg *pMsg;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfDone,
+ SIZEOF (smSaveYourselfDoneMsg), smSaveYourselfDoneMsg, pMsg);
+
+ pMsg->success = success;
+
+ IceFlush (iceConn);
+}
+
+
+
+static void
+set_callbacks (smcConn, mask, callbacks)
+
+SmcConn smcConn;
+unsigned long mask;
+SmcCallbacks *callbacks;
+
+{
+ if (mask & SmcSaveYourselfProcMask)
+ {
+ smcConn->callbacks.save_yourself.callback =
+ callbacks->save_yourself.callback;
+ smcConn->callbacks.save_yourself.client_data =
+ callbacks->save_yourself.client_data;
+ }
+
+ if (mask & SmcDieProcMask)
+ {
+ smcConn->callbacks.die.callback = callbacks->die.callback;
+ smcConn->callbacks.die.client_data = callbacks->die.client_data;
+ }
+
+ if (mask & SmcSaveCompleteProcMask)
+ {
+ smcConn->callbacks.save_complete.callback =
+ callbacks->save_complete.callback;
+ smcConn->callbacks.save_complete.client_data =
+ callbacks->save_complete.client_data;
+ }
+
+ if (mask & SmcShutdownCancelledProcMask)
+ {
+ smcConn->callbacks.shutdown_cancelled.callback =
+ callbacks->shutdown_cancelled.callback;
+ smcConn->callbacks.shutdown_cancelled.client_data =
+ callbacks->shutdown_cancelled.client_data;
+ }
+}
diff --git a/nx-X11/lib/SM/sm_client.c.NX.original b/nx-X11/lib/SM/sm_client.c.NX.original
new file mode 100644
index 000000000..499be5e3d
--- /dev/null
+++ b/nx-X11/lib/SM/sm_client.c.NX.original
@@ -0,0 +1,633 @@
+/* $Xorg: sm_client.c,v 1.4 2001/02/09 02:03:30 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: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+#include "globals.h"
+
+static void set_callbacks();
+
+
+SmcConn
+SmcOpenConnection (networkIdsList, context,
+ xsmpMajorRev, xsmpMinorRev, mask, callbacks,
+ previousId, clientIdRet, errorLength, errorStringRet)
+
+char *networkIdsList;
+SmPointer context;
+int xsmpMajorRev;
+int xsmpMinorRev;
+unsigned long mask;
+SmcCallbacks *callbacks;
+char *previousId;
+char **clientIdRet;
+int errorLength;
+char *errorStringRet;
+
+{
+ SmcConn smcConn;
+ IceConn iceConn;
+ char *ids;
+ IceProtocolSetupStatus setupstat;
+ int majorVersion;
+ int minorVersion;
+ char *vendor = NULL;
+ char *release = NULL;
+ smRegisterClientMsg *pMsg;
+ char *pData;
+ int extra, len;
+ IceReplyWaitInfo replyWait;
+ _SmcRegisterClientReply reply;
+ Bool gotReply, ioErrorOccured;
+
+ *clientIdRet = NULL;
+
+ if (errorStringRet && errorLength > 0)
+ *errorStringRet = '\0';
+
+ if (!_SmcOpcode)
+ {
+ /*
+ * For now, there is only one version of XSMP, so we don't
+ * have to check {xsmpMajorRev, xsmpMinorRev}. In the future,
+ * we will check against _SmcVersions and generate the list
+ * of versions the application actually supports.
+ */
+
+ if ((_SmcOpcode = IceRegisterForProtocolSetup ("XSMP",
+ SmVendorString, SmReleaseString, _SmVersionCount, _SmcVersions,
+ _SmAuthCount, _SmAuthNames, _SmcAuthProcs, NULL)) < 0)
+ {
+ strncpy (errorStringRet,
+ "Could not register XSMP protocol with ICE", errorLength);
+
+ return (NULL);
+ }
+ }
+
+ if (networkIdsList == NULL || *networkIdsList == '\0')
+ {
+ if ((ids = (char *) getenv ("SESSION_MANAGER")) == NULL)
+ {
+ strncpy (errorStringRet,
+ "SESSION_MANAGER environment variable not defined",
+ errorLength);
+
+ return (NULL);
+ }
+ }
+ else
+ {
+ ids = networkIdsList;
+ }
+
+ if ((iceConn = IceOpenConnection (
+ ids, context, 0, _SmcOpcode, errorLength, errorStringRet)) == NULL)
+ {
+ return (NULL);
+ }
+
+ if ((smcConn = (SmcConn) malloc (sizeof (struct _SmcConn))) == NULL)
+ {
+ strncpy (errorStringRet, "Can't malloc", errorLength);
+ IceCloseConnection (iceConn);
+ return (NULL);
+ }
+
+ setupstat = IceProtocolSetup (iceConn, _SmcOpcode,
+ (IcePointer) smcConn,
+ False /* mustAuthenticate */,
+ &majorVersion, &minorVersion,
+ &vendor, &release, errorLength, errorStringRet);
+
+ if (setupstat == IceProtocolSetupFailure ||
+ setupstat == IceProtocolSetupIOError)
+ {
+ IceCloseConnection (iceConn);
+ free ((char *) smcConn);
+ return (NULL);
+ }
+ else if (setupstat == IceProtocolAlreadyActive)
+ {
+ /*
+ * This case should never happen, because when we called
+ * IceOpenConnection, we required that the ICE connection
+ * may not already have XSMP active on it.
+ */
+
+ free ((char *) smcConn);
+ strncpy (errorStringRet, "Internal error in IceOpenConnection",
+ errorLength);
+ return (NULL);
+ }
+
+ smcConn->iceConn = iceConn;
+ smcConn->proto_major_version = majorVersion;
+ smcConn->proto_minor_version = minorVersion;
+ smcConn->vendor = vendor;
+ smcConn->release = release;
+ smcConn->client_id = NULL;
+
+ bzero ((char *) &smcConn->callbacks, sizeof (SmcCallbacks));
+ set_callbacks (smcConn, mask, callbacks);
+
+ smcConn->interact_waits = NULL;
+ smcConn->phase2_wait = NULL;
+ smcConn->prop_reply_waits = NULL;
+
+ smcConn->save_yourself_in_progress = False;
+ smcConn->shutdown_in_progress = False;
+
+
+ /*
+ * Now register the client
+ */
+
+ len = previousId ? strlen (previousId) : 0;
+ extra = ARRAY8_BYTES (len);
+
+ IceGetHeaderExtra (iceConn, _SmcOpcode, SM_RegisterClient,
+ SIZEOF (smRegisterClientMsg), WORD64COUNT (extra),
+ smRegisterClientMsg, pMsg, pData);
+
+ STORE_ARRAY8 (pData, len, previousId);
+
+ IceFlush (iceConn);
+
+ replyWait.sequence_of_request = IceLastSentSequenceNumber (iceConn);
+ replyWait.major_opcode_of_request = _SmcOpcode;
+ replyWait.minor_opcode_of_request = SM_RegisterClient;
+ replyWait.reply = (IcePointer) &reply;
+
+ gotReply = False;
+ ioErrorOccured = False;
+
+ while (!gotReply && !ioErrorOccured)
+ {
+ ioErrorOccured = (IceProcessMessages (
+ iceConn, &replyWait, &gotReply) == IceProcessMessagesIOError);
+
+ if (ioErrorOccured)
+ {
+ strncpy (errorStringRet, "IO error occured opening connection",
+ errorLength);
+
+ free (smcConn->vendor);
+ free (smcConn->release);
+ free ((char *) smcConn);
+
+ return (NULL);
+ }
+ else if (gotReply)
+ {
+ if (reply.status == 1)
+ {
+ /*
+ * The client successfully registered.
+ */
+
+ *clientIdRet = reply.client_id;
+
+ smcConn->client_id = (char *) malloc (
+ strlen (*clientIdRet) + 1);
+
+ strcpy (smcConn->client_id, *clientIdRet);
+ }
+ else
+ {
+ /*
+ * Could not register the client because the previous ID
+ * was bad. So now we register the client with the
+ * previous ID set to NULL.
+ */
+
+ extra = ARRAY8_BYTES (0);
+
+ IceGetHeaderExtra (iceConn, _SmcOpcode, SM_RegisterClient,
+ SIZEOF (smRegisterClientMsg), WORD64COUNT (extra),
+ smRegisterClientMsg, pMsg, pData);
+
+ previousId = NULL;
+
+ STORE_ARRAY8 (pData, 0, previousId);
+
+ IceFlush (iceConn);
+
+ replyWait.sequence_of_request =
+ IceLastSentSequenceNumber (iceConn);
+
+ gotReply = False;
+ }
+ }
+ }
+
+ return (smcConn);
+}
+
+
+
+SmcCloseStatus
+SmcCloseConnection (smcConn, count, reasonMsgs)
+
+SmcConn smcConn;
+int count;
+char **reasonMsgs;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smCloseConnectionMsg *pMsg;
+ char *pData;
+ int extra, i;
+ IceCloseStatus closeStatus;
+ SmcCloseStatus statusRet;
+
+ extra = 8;
+
+ for (i = 0; i < count; i++)
+ extra += ARRAY8_BYTES (strlen (reasonMsgs[i]));
+
+ IceGetHeaderExtra (iceConn, _SmcOpcode, SM_CloseConnection,
+ SIZEOF (smCloseConnectionMsg), WORD64COUNT (extra),
+ smCloseConnectionMsg, pMsg, pData);
+
+ STORE_CARD32 (pData, count);
+ pData += 4;
+
+ for (i = 0; i < count; i++)
+ STORE_ARRAY8 (pData, strlen (reasonMsgs[i]), reasonMsgs[i]);
+
+ IceFlush (iceConn);
+
+ IceProtocolShutdown (iceConn, _SmcOpcode);
+ IceSetShutdownNegotiation (iceConn, False);
+ closeStatus = IceCloseConnection (iceConn);
+
+ if (smcConn->vendor)
+ free (smcConn->vendor);
+
+ if (smcConn->release)
+ free (smcConn->release);
+
+ if (smcConn->client_id)
+ free (smcConn->client_id);
+
+ if (smcConn->prop_reply_waits)
+ {
+ _SmcPropReplyWait *ptr = smcConn->prop_reply_waits;
+ _SmcPropReplyWait *next;
+
+ while (ptr)
+ {
+ next = ptr->next;
+ free ((char *) ptr);
+ ptr = next;
+ }
+
+ }
+
+ free ((char *) smcConn);
+
+ if (closeStatus == IceClosedNow)
+ statusRet = SmcClosedNow;
+ else if (closeStatus == IceClosedASAP)
+ statusRet = SmcClosedASAP;
+ else
+ statusRet = SmcConnectionInUse;
+
+ return (statusRet);
+}
+
+
+
+void
+SmcModifyCallbacks (smcConn, mask, callbacks)
+
+SmcConn smcConn;
+unsigned long mask;
+SmcCallbacks *callbacks;
+
+{
+ set_callbacks (smcConn, mask, callbacks);
+}
+
+
+
+void
+SmcSetProperties (smcConn, numProps, props)
+
+SmcConn smcConn;
+int numProps;
+SmProp **props;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smSetPropertiesMsg *pMsg;
+ char *pBuf;
+ char *pStart;
+ int bytes;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_SetProperties,
+ SIZEOF (smSetPropertiesMsg), smSetPropertiesMsg, pMsg);
+
+ LISTOF_PROP_BYTES (numProps, props, bytes);
+ pMsg->length += WORD64COUNT (bytes);
+
+ pBuf = pStart = IceAllocScratch (iceConn, bytes);
+
+ STORE_LISTOF_PROPERTY (pBuf, numProps, props);
+
+ IceWriteData (iceConn, bytes, pStart);
+ IceFlush (iceConn);
+}
+
+
+
+void
+SmcDeleteProperties (smcConn, numProps, propNames)
+
+SmcConn smcConn;
+int numProps;
+char **propNames;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smDeletePropertiesMsg *pMsg;
+ char *pData;
+ int extra, i;
+
+ extra = 8;
+
+ for (i = 0; i < numProps; i++)
+ extra += ARRAY8_BYTES (strlen (propNames[i]));
+
+ IceGetHeaderExtra (iceConn, _SmcOpcode, SM_DeleteProperties,
+ SIZEOF (smDeletePropertiesMsg), WORD64COUNT (extra),
+ smDeletePropertiesMsg, pMsg, pData);
+
+ STORE_CARD32 (pData, numProps);
+ pData += 4;
+
+ for (i = 0; i < numProps; i++)
+ STORE_ARRAY8 (pData, strlen (propNames[i]), propNames[i]);
+
+ IceFlush (iceConn);
+}
+
+
+
+Status
+SmcGetProperties (smcConn, propReplyProc, clientData)
+
+SmcConn smcConn;
+SmcPropReplyProc propReplyProc;
+SmPointer clientData;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ _SmcPropReplyWait *wait, *ptr;
+
+ if ((wait = (_SmcPropReplyWait *) malloc (
+ sizeof (_SmcPropReplyWait))) == NULL)
+ {
+ return (0);
+ }
+
+ wait->prop_reply_proc = propReplyProc;
+ wait->client_data = clientData;
+ wait->next = NULL;
+
+ ptr = smcConn->prop_reply_waits;
+ while (ptr && ptr->next)
+ ptr = ptr->next;
+
+ if (ptr == NULL)
+ smcConn->prop_reply_waits = wait;
+ else
+ ptr->next = wait;
+
+ IceSimpleMessage (iceConn, _SmcOpcode, SM_GetProperties);
+ IceFlush (iceConn);
+
+ return (1);
+}
+
+
+
+Status
+SmcInteractRequest (smcConn, dialogType, interactProc, clientData)
+
+SmcConn smcConn;
+int dialogType;
+SmcInteractProc interactProc;
+SmPointer clientData;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smInteractRequestMsg *pMsg;
+ _SmcInteractWait *wait, *ptr;
+
+ if ((wait = (_SmcInteractWait *) malloc (
+ sizeof (_SmcInteractWait))) == NULL)
+ {
+ return (0);
+ }
+
+ wait->interact_proc = interactProc;
+ wait->client_data = clientData;
+ wait->next = NULL;
+
+ ptr = smcConn->interact_waits;
+ while (ptr && ptr->next)
+ ptr = ptr->next;
+
+ if (ptr == NULL)
+ smcConn->interact_waits = wait;
+ else
+ ptr->next = wait;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_InteractRequest,
+ SIZEOF (smInteractRequestMsg), smInteractRequestMsg, pMsg);
+
+ pMsg->dialogType = dialogType;
+
+ IceFlush (iceConn);
+
+ return (1);
+}
+
+
+
+void
+SmcInteractDone (smcConn, cancelShutdown)
+
+SmcConn smcConn;
+Bool cancelShutdown;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smInteractDoneMsg *pMsg;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_InteractDone,
+ SIZEOF (smInteractDoneMsg), smInteractDoneMsg, pMsg);
+
+ pMsg->cancelShutdown = cancelShutdown;
+
+ IceFlush (iceConn);
+}
+
+
+
+void
+SmcRequestSaveYourself (smcConn, saveType, shutdown, interactStyle,
+ fast, global)
+
+SmcConn smcConn;
+int saveType;
+Bool shutdown;
+int interactStyle;
+Bool fast;
+Bool global;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smSaveYourselfRequestMsg *pMsg;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfRequest,
+ SIZEOF (smSaveYourselfRequestMsg), smSaveYourselfRequestMsg, pMsg);
+
+ pMsg->saveType = saveType;
+ pMsg->shutdown = shutdown;
+ pMsg->interactStyle = interactStyle;
+ pMsg->fast = fast;
+ pMsg->global = global;
+
+ IceFlush (iceConn);
+}
+
+
+
+Status
+SmcRequestSaveYourselfPhase2 (smcConn, saveYourselfPhase2Proc, clientData)
+
+SmcConn smcConn;
+SmcSaveYourselfPhase2Proc saveYourselfPhase2Proc;
+SmPointer clientData;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ _SmcPhase2Wait *wait;
+
+ if (smcConn->phase2_wait)
+ wait = smcConn->phase2_wait;
+ else
+ {
+ if ((wait = (_SmcPhase2Wait *) malloc (
+ sizeof (_SmcPhase2Wait))) == NULL)
+ {
+ return (0);
+ }
+ }
+
+ wait->phase2_proc = saveYourselfPhase2Proc;
+ wait->client_data = clientData;
+
+ smcConn->phase2_wait = wait;
+
+ IceSimpleMessage (iceConn, _SmcOpcode, SM_SaveYourselfPhase2Request);
+ IceFlush (iceConn);
+
+ return (1);
+}
+
+
+
+void
+SmcSaveYourselfDone (smcConn, success)
+
+SmcConn smcConn;
+Bool success;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smSaveYourselfDoneMsg *pMsg;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfDone,
+ SIZEOF (smSaveYourselfDoneMsg), smSaveYourselfDoneMsg, pMsg);
+
+ pMsg->success = success;
+
+ IceFlush (iceConn);
+}
+
+
+
+static void
+set_callbacks (smcConn, mask, callbacks)
+
+SmcConn smcConn;
+unsigned long mask;
+SmcCallbacks *callbacks;
+
+{
+ if (mask & SmcSaveYourselfProcMask)
+ {
+ smcConn->callbacks.save_yourself.callback =
+ callbacks->save_yourself.callback;
+ smcConn->callbacks.save_yourself.client_data =
+ callbacks->save_yourself.client_data;
+ }
+
+ if (mask & SmcDieProcMask)
+ {
+ smcConn->callbacks.die.callback = callbacks->die.callback;
+ smcConn->callbacks.die.client_data = callbacks->die.client_data;
+ }
+
+ if (mask & SmcSaveCompleteProcMask)
+ {
+ smcConn->callbacks.save_complete.callback =
+ callbacks->save_complete.callback;
+ smcConn->callbacks.save_complete.client_data =
+ callbacks->save_complete.client_data;
+ }
+
+ if (mask & SmcShutdownCancelledProcMask)
+ {
+ smcConn->callbacks.shutdown_cancelled.callback =
+ callbacks->shutdown_cancelled.callback;
+ smcConn->callbacks.shutdown_cancelled.client_data =
+ callbacks->shutdown_cancelled.client_data;
+ }
+}
diff --git a/nx-X11/lib/SM/sm_client.c.SM.original b/nx-X11/lib/SM/sm_client.c.SM.original
new file mode 100644
index 000000000..02f9ccdf6
--- /dev/null
+++ b/nx-X11/lib/SM/sm_client.c.SM.original
@@ -0,0 +1,631 @@
+/* $Xorg: sm_client.c,v 1.4 2001/02/09 02:03:30 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: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+#include "globals.h"
+
+static void set_callbacks();
+
+
+SmcConn
+SmcOpenConnection (networkIdsList, context,
+ xsmpMajorRev, xsmpMinorRev, mask, callbacks,
+ previousId, clientIdRet, errorLength, errorStringRet)
+
+char *networkIdsList;
+SmPointer context;
+int xsmpMajorRev;
+int xsmpMinorRev;
+unsigned long mask;
+SmcCallbacks *callbacks;
+char *previousId;
+char **clientIdRet;
+int errorLength;
+char *errorStringRet;
+
+{
+ SmcConn smcConn;
+ IceConn iceConn;
+ char *ids;
+ IceProtocolSetupStatus setupstat;
+ int majorVersion;
+ int minorVersion;
+ char *vendor = NULL;
+ char *release = NULL;
+ smRegisterClientMsg *pMsg;
+ char *pData;
+ int extra, len;
+ IceReplyWaitInfo replyWait;
+ _SmcRegisterClientReply reply;
+ Bool gotReply, ioErrorOccured;
+
+ *clientIdRet = NULL;
+
+ if (errorStringRet && errorLength > 0)
+ *errorStringRet = '\0';
+
+ if (!_SmcOpcode)
+ {
+ /*
+ * For now, there is only one version of XSMP, so we don't
+ * have to check {xsmpMajorRev, xsmpMinorRev}. In the future,
+ * we will check against _SmcVersions and generate the list
+ * of versions the application actually supports.
+ */
+
+ if ((_SmcOpcode = IceRegisterForProtocolSetup ("XSMP",
+ SmVendorString, SmReleaseString, _SmVersionCount, _SmcVersions,
+ _SmAuthCount, _SmAuthNames, _SmcAuthProcs, NULL)) < 0)
+ {
+ strncpy (errorStringRet,
+ "Could not register XSMP protocol with ICE", errorLength);
+
+ return (NULL);
+ }
+ }
+
+ if (networkIdsList == NULL || *networkIdsList == '\0')
+ {
+ if ((ids = (char *) getenv ("SESSION_MANAGER")) == NULL)
+ {
+ strncpy (errorStringRet,
+ "SESSION_MANAGER environment variable not defined",
+ errorLength);
+
+ return (NULL);
+ }
+ }
+ else
+ {
+ ids = networkIdsList;
+ }
+
+ if ((iceConn = IceOpenConnection (
+ ids, context, 0, _SmcOpcode, errorLength, errorStringRet)) == NULL)
+ {
+ return (NULL);
+ }
+
+ if ((smcConn = (SmcConn) malloc (sizeof (struct _SmcConn))) == NULL)
+ {
+ strncpy (errorStringRet, "Can't malloc", errorLength);
+ IceCloseConnection (iceConn);
+ return (NULL);
+ }
+
+ setupstat = IceProtocolSetup (iceConn, _SmcOpcode,
+ (IcePointer) smcConn,
+ False /* mustAuthenticate */,
+ &majorVersion, &minorVersion,
+ &vendor, &release, errorLength, errorStringRet);
+
+ if (setupstat == IceProtocolSetupFailure ||
+ setupstat == IceProtocolSetupIOError)
+ {
+ IceCloseConnection (iceConn);
+ free ((char *) smcConn);
+ return (NULL);
+ }
+ else if (setupstat == IceProtocolAlreadyActive)
+ {
+ /*
+ * This case should never happen, because when we called
+ * IceOpenConnection, we required that the ICE connection
+ * may not already have XSMP active on it.
+ */
+
+ free ((char *) smcConn);
+ strncpy (errorStringRet, "Internal error in IceOpenConnection",
+ errorLength);
+ return (NULL);
+ }
+
+ smcConn->iceConn = iceConn;
+ smcConn->proto_major_version = majorVersion;
+ smcConn->proto_minor_version = minorVersion;
+ smcConn->vendor = vendor;
+ smcConn->release = release;
+ smcConn->client_id = NULL;
+
+ bzero ((char *) &smcConn->callbacks, sizeof (SmcCallbacks));
+ set_callbacks (smcConn, mask, callbacks);
+
+ smcConn->interact_waits = NULL;
+ smcConn->phase2_wait = NULL;
+ smcConn->prop_reply_waits = NULL;
+
+ smcConn->save_yourself_in_progress = False;
+ smcConn->shutdown_in_progress = False;
+
+
+ /*
+ * Now register the client
+ */
+
+ len = previousId ? strlen (previousId) : 0;
+ extra = ARRAY8_BYTES (len);
+
+ IceGetHeaderExtra (iceConn, _SmcOpcode, SM_RegisterClient,
+ SIZEOF (smRegisterClientMsg), WORD64COUNT (extra),
+ smRegisterClientMsg, pMsg, pData);
+
+ STORE_ARRAY8 (pData, len, previousId);
+
+ IceFlush (iceConn);
+
+ replyWait.sequence_of_request = IceLastSentSequenceNumber (iceConn);
+ replyWait.major_opcode_of_request = _SmcOpcode;
+ replyWait.minor_opcode_of_request = SM_RegisterClient;
+ replyWait.reply = (IcePointer) &reply;
+
+ gotReply = False;
+ ioErrorOccured = False;
+
+ while (!gotReply && !ioErrorOccured)
+ {
+ ioErrorOccured = (IceProcessMessages (
+ iceConn, &replyWait, &gotReply) == IceProcessMessagesIOError);
+
+ if (ioErrorOccured)
+ {
+ strncpy (errorStringRet, "IO error occured opening connection",
+ errorLength);
+
+ free (smcConn->vendor);
+ free (smcConn->release);
+ free ((char *) smcConn);
+
+ return (NULL);
+ }
+ else if (gotReply)
+ {
+ if (reply.status == 1)
+ {
+ /*
+ * The client successfully registered.
+ */
+
+ *clientIdRet = reply.client_id;
+
+ smcConn->client_id = (char *) malloc (
+ strlen (*clientIdRet) + 1);
+
+ strcpy (smcConn->client_id, *clientIdRet);
+ }
+ else
+ {
+ /*
+ * Could not register the client because the previous ID
+ * was bad. So now we register the client with the
+ * previous ID set to NULL.
+ */
+
+ extra = ARRAY8_BYTES (0);
+
+ IceGetHeaderExtra (iceConn, _SmcOpcode, SM_RegisterClient,
+ SIZEOF (smRegisterClientMsg), WORD64COUNT (extra),
+ smRegisterClientMsg, pMsg, pData);
+
+ STORE_ARRAY8 (pData, 0, NULL);
+
+ IceFlush (iceConn);
+
+ replyWait.sequence_of_request =
+ IceLastSentSequenceNumber (iceConn);
+
+ gotReply = False;
+ }
+ }
+ }
+
+ return (smcConn);
+}
+
+
+
+SmcCloseStatus
+SmcCloseConnection (smcConn, count, reasonMsgs)
+
+SmcConn smcConn;
+int count;
+char **reasonMsgs;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smCloseConnectionMsg *pMsg;
+ char *pData;
+ int extra, i;
+ IceCloseStatus closeStatus;
+ SmcCloseStatus statusRet;
+
+ extra = 8;
+
+ for (i = 0; i < count; i++)
+ extra += ARRAY8_BYTES (strlen (reasonMsgs[i]));
+
+ IceGetHeaderExtra (iceConn, _SmcOpcode, SM_CloseConnection,
+ SIZEOF (smCloseConnectionMsg), WORD64COUNT (extra),
+ smCloseConnectionMsg, pMsg, pData);
+
+ STORE_CARD32 (pData, count);
+ pData += 4;
+
+ for (i = 0; i < count; i++)
+ STORE_ARRAY8 (pData, strlen (reasonMsgs[i]), reasonMsgs[i]);
+
+ IceFlush (iceConn);
+
+ IceProtocolShutdown (iceConn, _SmcOpcode);
+ IceSetShutdownNegotiation (iceConn, False);
+ closeStatus = IceCloseConnection (iceConn);
+
+ if (smcConn->vendor)
+ free (smcConn->vendor);
+
+ if (smcConn->release)
+ free (smcConn->release);
+
+ if (smcConn->client_id)
+ free (smcConn->client_id);
+
+ if (smcConn->prop_reply_waits)
+ {
+ _SmcPropReplyWait *ptr = smcConn->prop_reply_waits;
+ _SmcPropReplyWait *next;
+
+ while (ptr)
+ {
+ next = ptr->next;
+ free ((char *) ptr);
+ ptr = next;
+ }
+
+ }
+
+ free ((char *) smcConn);
+
+ if (closeStatus == IceClosedNow)
+ statusRet = SmcClosedNow;
+ else if (closeStatus == IceClosedASAP)
+ statusRet = SmcClosedASAP;
+ else
+ statusRet = SmcConnectionInUse;
+
+ return (statusRet);
+}
+
+
+
+void
+SmcModifyCallbacks (smcConn, mask, callbacks)
+
+SmcConn smcConn;
+unsigned long mask;
+SmcCallbacks *callbacks;
+
+{
+ set_callbacks (smcConn, mask, callbacks);
+}
+
+
+
+void
+SmcSetProperties (smcConn, numProps, props)
+
+SmcConn smcConn;
+int numProps;
+SmProp **props;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smSetPropertiesMsg *pMsg;
+ char *pBuf;
+ char *pStart;
+ int bytes;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_SetProperties,
+ SIZEOF (smSetPropertiesMsg), smSetPropertiesMsg, pMsg);
+
+ LISTOF_PROP_BYTES (numProps, props, bytes);
+ pMsg->length += WORD64COUNT (bytes);
+
+ pBuf = pStart = IceAllocScratch (iceConn, bytes);
+
+ STORE_LISTOF_PROPERTY (pBuf, numProps, props);
+
+ IceWriteData (iceConn, bytes, pStart);
+ IceFlush (iceConn);
+}
+
+
+
+void
+SmcDeleteProperties (smcConn, numProps, propNames)
+
+SmcConn smcConn;
+int numProps;
+char **propNames;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smDeletePropertiesMsg *pMsg;
+ char *pData;
+ int extra, i;
+
+ extra = 8;
+
+ for (i = 0; i < numProps; i++)
+ extra += ARRAY8_BYTES (strlen (propNames[i]));
+
+ IceGetHeaderExtra (iceConn, _SmcOpcode, SM_DeleteProperties,
+ SIZEOF (smDeletePropertiesMsg), WORD64COUNT (extra),
+ smDeletePropertiesMsg, pMsg, pData);
+
+ STORE_CARD32 (pData, numProps);
+ pData += 4;
+
+ for (i = 0; i < numProps; i++)
+ STORE_ARRAY8 (pData, strlen (propNames[i]), propNames[i]);
+
+ IceFlush (iceConn);
+}
+
+
+
+Status
+SmcGetProperties (smcConn, propReplyProc, clientData)
+
+SmcConn smcConn;
+SmcPropReplyProc propReplyProc;
+SmPointer clientData;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ _SmcPropReplyWait *wait, *ptr;
+
+ if ((wait = (_SmcPropReplyWait *) malloc (
+ sizeof (_SmcPropReplyWait))) == NULL)
+ {
+ return (0);
+ }
+
+ wait->prop_reply_proc = propReplyProc;
+ wait->client_data = clientData;
+ wait->next = NULL;
+
+ ptr = smcConn->prop_reply_waits;
+ while (ptr && ptr->next)
+ ptr = ptr->next;
+
+ if (ptr == NULL)
+ smcConn->prop_reply_waits = wait;
+ else
+ ptr->next = wait;
+
+ IceSimpleMessage (iceConn, _SmcOpcode, SM_GetProperties);
+ IceFlush (iceConn);
+
+ return (1);
+}
+
+
+
+Status
+SmcInteractRequest (smcConn, dialogType, interactProc, clientData)
+
+SmcConn smcConn;
+int dialogType;
+SmcInteractProc interactProc;
+SmPointer clientData;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smInteractRequestMsg *pMsg;
+ _SmcInteractWait *wait, *ptr;
+
+ if ((wait = (_SmcInteractWait *) malloc (
+ sizeof (_SmcInteractWait))) == NULL)
+ {
+ return (0);
+ }
+
+ wait->interact_proc = interactProc;
+ wait->client_data = clientData;
+ wait->next = NULL;
+
+ ptr = smcConn->interact_waits;
+ while (ptr && ptr->next)
+ ptr = ptr->next;
+
+ if (ptr == NULL)
+ smcConn->interact_waits = wait;
+ else
+ ptr->next = wait;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_InteractRequest,
+ SIZEOF (smInteractRequestMsg), smInteractRequestMsg, pMsg);
+
+ pMsg->dialogType = dialogType;
+
+ IceFlush (iceConn);
+
+ return (1);
+}
+
+
+
+void
+SmcInteractDone (smcConn, cancelShutdown)
+
+SmcConn smcConn;
+Bool cancelShutdown;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smInteractDoneMsg *pMsg;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_InteractDone,
+ SIZEOF (smInteractDoneMsg), smInteractDoneMsg, pMsg);
+
+ pMsg->cancelShutdown = cancelShutdown;
+
+ IceFlush (iceConn);
+}
+
+
+
+void
+SmcRequestSaveYourself (smcConn, saveType, shutdown, interactStyle,
+ fast, global)
+
+SmcConn smcConn;
+int saveType;
+Bool shutdown;
+int interactStyle;
+Bool fast;
+Bool global;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smSaveYourselfRequestMsg *pMsg;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfRequest,
+ SIZEOF (smSaveYourselfRequestMsg), smSaveYourselfRequestMsg, pMsg);
+
+ pMsg->saveType = saveType;
+ pMsg->shutdown = shutdown;
+ pMsg->interactStyle = interactStyle;
+ pMsg->fast = fast;
+ pMsg->global = global;
+
+ IceFlush (iceConn);
+}
+
+
+
+Status
+SmcRequestSaveYourselfPhase2 (smcConn, saveYourselfPhase2Proc, clientData)
+
+SmcConn smcConn;
+SmcSaveYourselfPhase2Proc saveYourselfPhase2Proc;
+SmPointer clientData;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ _SmcPhase2Wait *wait;
+
+ if (smcConn->phase2_wait)
+ wait = smcConn->phase2_wait;
+ else
+ {
+ if ((wait = (_SmcPhase2Wait *) malloc (
+ sizeof (_SmcPhase2Wait))) == NULL)
+ {
+ return (0);
+ }
+ }
+
+ wait->phase2_proc = saveYourselfPhase2Proc;
+ wait->client_data = clientData;
+
+ smcConn->phase2_wait = wait;
+
+ IceSimpleMessage (iceConn, _SmcOpcode, SM_SaveYourselfPhase2Request);
+ IceFlush (iceConn);
+
+ return (1);
+}
+
+
+
+void
+SmcSaveYourselfDone (smcConn, success)
+
+SmcConn smcConn;
+Bool success;
+
+{
+ IceConn iceConn = smcConn->iceConn;
+ smSaveYourselfDoneMsg *pMsg;
+
+ IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfDone,
+ SIZEOF (smSaveYourselfDoneMsg), smSaveYourselfDoneMsg, pMsg);
+
+ pMsg->success = success;
+
+ IceFlush (iceConn);
+}
+
+
+
+static void
+set_callbacks (smcConn, mask, callbacks)
+
+SmcConn smcConn;
+unsigned long mask;
+SmcCallbacks *callbacks;
+
+{
+ if (mask & SmcSaveYourselfProcMask)
+ {
+ smcConn->callbacks.save_yourself.callback =
+ callbacks->save_yourself.callback;
+ smcConn->callbacks.save_yourself.client_data =
+ callbacks->save_yourself.client_data;
+ }
+
+ if (mask & SmcDieProcMask)
+ {
+ smcConn->callbacks.die.callback = callbacks->die.callback;
+ smcConn->callbacks.die.client_data = callbacks->die.client_data;
+ }
+
+ if (mask & SmcSaveCompleteProcMask)
+ {
+ smcConn->callbacks.save_complete.callback =
+ callbacks->save_complete.callback;
+ smcConn->callbacks.save_complete.client_data =
+ callbacks->save_complete.client_data;
+ }
+
+ if (mask & SmcShutdownCancelledProcMask)
+ {
+ smcConn->callbacks.shutdown_cancelled.callback =
+ callbacks->shutdown_cancelled.callback;
+ smcConn->callbacks.shutdown_cancelled.client_data =
+ callbacks->shutdown_cancelled.client_data;
+ }
+}
diff --git a/nx-X11/lib/SM/sm_error.c b/nx-X11/lib/SM/sm_error.c
new file mode 100644
index 000000000..50a476e59
--- /dev/null
+++ b/nx-X11/lib/SM/sm_error.c
@@ -0,0 +1,341 @@
+/* $Xorg: sm_error.c,v 1.4 2001/02/09 02:03:30 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.
+
+*/
+/* $XFree86: xc/lib/SM/sm_error.c,v 1.2 2001/10/28 03:32:29 tsi Exp $ */
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+#include <stdio.h>
+
+
+
+/*
+ * Default Smc error handler.
+ */
+
+void
+_SmcDefaultErrorHandler (smcConn, swap,
+ offendingMinorOpcode, offendingSequence,
+ errorClass, severity, values)
+
+SmcConn smcConn;
+Bool swap;
+int offendingMinorOpcode;
+unsigned long offendingSequence;
+int errorClass;
+int severity;
+SmPointer values;
+
+{
+ char *pData = (char *) values;
+ char *str;
+
+ switch (offendingMinorOpcode)
+ {
+ case SM_RegisterClient:
+ str = "RegisterClient";
+ break;
+ case SM_InteractRequest:
+ str = "InteractRequest";
+ break;
+ case SM_InteractDone:
+ str = "InteractDone";
+ break;
+ case SM_SaveYourselfDone:
+ str = "SaveYourselfDone";
+ break;
+ case SM_CloseConnection:
+ str = "CloseConnection";
+ break;
+ case SM_SetProperties:
+ str = "SetProperties";
+ break;
+ case SM_GetProperties:
+ str = "GetProperties";
+ break;
+ default:
+ str = "";
+ }
+
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "XSMP error: Offending minor opcode = %d (%s)\n",
+ offendingMinorOpcode, str);
+
+ fprintf (stderr, " Offending sequence number = %ld\n",
+ offendingSequence);
+
+ switch (errorClass)
+ {
+ case IceBadMinor:
+ str = "BadMinor";
+ break;
+ case IceBadState:
+ str = "BadState";
+ break;
+ case IceBadLength:
+ str = "BadLength";
+ break;
+ case IceBadValue:
+ str = "BadValue";
+ break;
+ default:
+ str = "???";
+ }
+
+ fprintf (stderr, " Error class = %s\n", str);
+
+ if (severity == IceCanContinue)
+ str = "CanContinue";
+ else if (severity == IceFatalToProtocol)
+ str = "FatalToProtocol";
+ else if (severity == IceFatalToConnection)
+ str = "FatalToConnection";
+ else
+ str = "???";
+
+ fprintf (stderr, " Severity = %s\n", str);
+
+ switch (errorClass)
+ {
+ case IceBadValue:
+ {
+ int offset, length, val;
+
+ EXTRACT_CARD32 (pData, swap, offset);
+ EXTRACT_CARD32 (pData, swap, length);
+
+ fprintf (stderr,
+ " BadValue Offset = %d\n", offset);
+ fprintf (stderr,
+ " BadValue Length = %d\n", length);
+
+ if (length <= 4)
+ {
+ if (length == 1)
+ val = (int) *pData;
+ else if (length == 2)
+ {
+ EXTRACT_CARD16 (pData, swap, val);
+ }
+ else
+ {
+ EXTRACT_CARD32 (pData, swap, val);
+ }
+
+ fprintf (stderr,
+ " BadValue = %d\n", val);
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ fprintf (stderr, "\n");
+
+ if (severity != IceCanContinue)
+ exit (1);
+}
+
+
+
+/*
+ * Default Sms error handler.
+ */
+
+void
+_SmsDefaultErrorHandler (smsConn, swap,
+ offendingMinorOpcode, offendingSequence,
+ errorClass, severity, values)
+
+SmsConn smsConn;
+Bool swap;
+int offendingMinorOpcode;
+unsigned long offendingSequence;
+int errorClass;
+int severity;
+SmPointer values;
+
+{
+ char *pData = (char *) values;
+ char *str;
+
+ switch (offendingMinorOpcode)
+ {
+ case SM_SaveYourself:
+ str = "SaveYourself";
+ break;
+ case SM_Interact:
+ str = "Interact";
+ break;
+ case SM_Die:
+ str = "Die";
+ break;
+ case SM_ShutdownCancelled:
+ str = "ShutdownCancelled";
+ break;
+ default:
+ str = "";
+ }
+
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "XSMP error: Offending minor opcode = %d (%s)\n",
+ offendingMinorOpcode, str);
+
+ fprintf (stderr, " Offending sequence number = %ld\n",
+ offendingSequence);
+
+ switch (errorClass)
+ {
+ case IceBadMinor:
+ str = "BadMinor";
+ break;
+ case IceBadState:
+ str = "BadState";
+ break;
+ case IceBadLength:
+ str = "BadLength";
+ break;
+ case IceBadValue:
+ str = "BadValue";
+ break;
+ default:
+ str = "???";
+ }
+
+ fprintf (stderr, " Error class = %s\n", str);
+
+ if (severity == IceCanContinue)
+ str = "CanContinue";
+ else if (severity == IceFatalToProtocol)
+ str = "FatalToProtocol";
+ else if (severity == IceFatalToConnection)
+ str = "FatalToConnection";
+ else
+ str = "???";
+
+ fprintf (stderr, " Severity = %s\n", str);
+
+ switch (errorClass)
+ {
+ case IceBadValue:
+ {
+ int offset, length, val;
+
+ EXTRACT_CARD32 (pData, swap, offset);
+ EXTRACT_CARD32 (pData, swap, length);
+
+ fprintf (stderr,
+ " BadValue Offset = %d\n", offset);
+ fprintf (stderr,
+ " BadValue Length = %d\n", length);
+
+ if (length <= 4)
+ {
+ if (length == 1)
+ val = (int) *pData;
+ else if (length == 2)
+ {
+ EXTRACT_CARD16 (pData, swap, val);
+ }
+ else
+ {
+ EXTRACT_CARD32 (pData, swap, val);
+ }
+
+ fprintf (stderr,
+ " BadValue = %d\n", val);
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ fprintf (stderr, "\n\n");
+
+ /* don't exit() - that would kill the SM - pretty devastating */
+}
+
+
+
+/*
+ * This procedure sets the Smc error handler to be the specified
+ * routine. If NULL is passed in the default error handler is restored.
+ * The function's return value is the previous error handler.
+ */
+
+SmcErrorHandler
+SmcSetErrorHandler (handler)
+
+SmcErrorHandler handler;
+
+{
+ SmcErrorHandler oldHandler = _SmcErrorHandler;
+
+ if (handler != NULL)
+ _SmcErrorHandler = handler;
+ else
+ _SmcErrorHandler = _SmcDefaultErrorHandler;
+
+ return (oldHandler);
+}
+
+
+
+/*
+ * This procedure sets the Sms error handler to be the specified
+ * routine. If NULL is passed in the default error handler is restored.
+ * The function's return value is the previous error handler.
+ */
+
+SmsErrorHandler
+SmsSetErrorHandler (handler)
+
+SmsErrorHandler handler;
+
+{
+ SmsErrorHandler oldHandler = _SmsErrorHandler;
+
+ if (handler != NULL)
+ _SmsErrorHandler = handler;
+ else
+ _SmsErrorHandler = _SmsDefaultErrorHandler;
+
+ return (oldHandler);
+}
diff --git a/nx-X11/lib/SM/sm_genid.c b/nx-X11/lib/SM/sm_genid.c
new file mode 100644
index 000000000..76e1350ab
--- /dev/null
+++ b/nx-X11/lib/SM/sm_genid.c
@@ -0,0 +1,215 @@
+/* $Xorg: sm_genid.c,v 1.4 2001/02/09 02:03:30 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1998 The Open Group
+Copyright 2002 Sun Microsystems, Inc.
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/SM/sm_genid.c,v 3.17 2003/07/09 15:27:28 tsi Exp $ */
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifdef WIN32
+#define _WILLWINSOCK_
+#endif
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+#include <stdio.h>
+
+#include <time.h>
+#define Time_t time_t
+
+#ifndef WIN32
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#define XOS_USE_NO_LOCKING
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+#endif
+
+#else /* WIN32 */
+
+#include <X11/Xwinsock.h>
+#include <X11/Xw32defs.h>
+#define X_INCLUDE_NETDB_H
+#define XOS_USE_MTSAFE_NETDBAPI
+#include <X11/Xos_r.h>
+
+#endif /* WIN32 */
+
+#ifdef MNX_TCPCONN
+#include <net/gen/netdb.h>
+
+#define TCPCONN
+#endif
+
+
+static char *hex_table[] = { /* for generating client IDs */
+ "00", "01", "02", "03", "04", "05", "06", "07",
+ "08", "09", "0a", "0b", "0c", "0d", "0e", "0f",
+ "10", "11", "12", "13", "14", "15", "16", "17",
+ "18", "19", "1a", "1b", "1c", "1d", "1e", "1f",
+ "20", "21", "22", "23", "24", "25", "26", "27",
+ "28", "29", "2a", "2b", "2c", "2d", "2e", "2f",
+ "30", "31", "32", "33", "34", "35", "36", "37",
+ "38", "39", "3a", "3b", "3c", "3d", "3e", "3f",
+ "40", "41", "42", "43", "44", "45", "46", "47",
+ "48", "49", "4a", "4b", "4c", "4d", "4e", "4f",
+ "50", "51", "52", "53", "54", "55", "56", "57",
+ "58", "59", "5a", "5b", "5c", "5d", "5e", "5f",
+ "60", "61", "62", "63", "64", "65", "66", "67",
+ "68", "69", "6a", "6b", "6c", "6d", "6e", "6f",
+ "70", "71", "72", "73", "74", "75", "76", "77",
+ "78", "79", "7a", "7b", "7c", "7d", "7e", "7f",
+ "80", "81", "82", "83", "84", "85", "86", "87",
+ "88", "89", "8a", "8b", "8c", "8d", "8e", "8f",
+ "90", "91", "92", "93", "94", "95", "96", "97",
+ "98", "99", "9a", "9b", "9c", "9d", "9e", "9f",
+ "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
+ "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af",
+ "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7",
+ "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf",
+ "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7",
+ "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf",
+ "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
+ "d8", "d9", "da", "db", "dc", "dd", "de", "df",
+ "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7",
+ "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef",
+ "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
+ "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff",
+};
+
+
+
+char *
+SmsGenerateClientID (smsConn)
+ SmsConn smsConn;
+{
+#if defined(TCPCONN) || defined(STREAMSCONN)
+ char hostname[256];
+ char address[64];
+ char temp[256];
+ char *id;
+ static int sequence = 0;
+
+ if (gethostname (hostname, sizeof (hostname)))
+ return (NULL);
+
+ {
+ char* inet_addr;
+ char temp[4], *ptr1, *ptr2;
+ unsigned char decimal[4];
+ int i, len;
+ struct in_addr *haddr = NULL;
+#if defined(IPv6) && defined(AF_INET6)
+ struct addrinfo *ai, *first_ai;
+ if (getaddrinfo(hostname,NULL,NULL,&ai) != 0)
+ return NULL;
+
+ for (first_ai = ai; ai != NULL; ai = ai->ai_next) {
+ if ( (ai->ai_family == AF_INET) || (ai->ai_family == AF_INET6) )
+ break;
+ }
+ if (ai == NULL) {
+ freeaddrinfo(first_ai);
+ return NULL;
+ }
+
+ if (ai->ai_family == AF_INET6) {
+ unsigned char *cp = (unsigned char *) &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr.s6_addr;
+
+ address[0] = '6'; /* IPv6 address code */
+ address[1] = '\0';
+
+ for (i = 0 ; i < 16 ; i++) {
+ strcat(address, hex_table[cp[i]]);
+ }
+
+ } else { /* Fall through to IPv4 address handling */
+ haddr = &((struct sockaddr_in *)ai->ai_addr)->sin_addr;
+#else
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ struct hostent *hostp;
+
+ if ((hostp = _XGethostbyname (hostname,hparams)) != NULL)
+ haddr = (struct in_addr *)(hostp->h_addr);
+ else
+ return NULL;
+#endif
+
+ inet_addr = inet_ntoa (*haddr);
+ for (i = 0, ptr1 = inet_addr; i < 3; i++)
+ {
+ ptr2 = strchr (ptr1, '.');
+ len = ptr2 - ptr1;
+ if (!ptr2 || len > 3)
+ return (NULL);
+ strncpy (temp, ptr1, len);
+ temp[len] = '\0';
+ decimal[i] = atoi (temp);
+ ptr1 = ptr2 + 1;
+ }
+
+ decimal[3] = atoi (ptr1);
+
+ address[0] = '1';
+ address[1] = '\0';
+ for (i = 0; i < 4; i++)
+ strcat (address, hex_table[decimal[i]]);
+#if defined(IPv6) && defined(AF_INET6)
+ }
+ freeaddrinfo(first_ai);
+#endif
+ }
+
+ sprintf (temp, "1%s%.13ld%.10ld%.4d", address, (long)time((Time_t*)0),
+ (long)getpid(), sequence);
+
+ if (++sequence > 9999)
+ sequence = 0;
+
+ if ((id = malloc (strlen (temp) + 1)) != NULL)
+ strcpy (id, temp);
+
+ return (id);
+#else
+ return (NULL);
+#endif
+}
diff --git a/nx-X11/lib/SM/sm_manager.c b/nx-X11/lib/SM/sm_manager.c
new file mode 100644
index 000000000..68cabcdce
--- /dev/null
+++ b/nx-X11/lib/SM/sm_manager.c
@@ -0,0 +1,372 @@
+/* $Xorg: sm_manager.c,v 1.4 2001/02/09 02:03:30 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: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+#include <X11/Xtrans/Xtrans.h>
+
+#ifdef __UNIXWARE__
+#undef shutdown
+#endif
+
+
+
+static Status
+_SmsProtocolSetupProc (IceConn iceConn,
+ int majorVersion,
+ int minorVersion,
+ char *vendor,
+ char *release,
+ IcePointer *clientDataRet,
+ char **failureReasonRet)
+{
+ SmsConn smsConn;
+ unsigned long mask;
+ Status status;
+
+ /*
+ * vendor/release are undefined for ProtocolSetup in XSMP.
+ */
+
+ if (vendor)
+ free (vendor);
+ if (release)
+ free (release);
+
+
+ /*
+ * Allocate new SmsConn.
+ */
+
+ if ((smsConn = (SmsConn) malloc (sizeof (struct _SmsConn))) == NULL)
+ {
+ char *str = "Memory allocation failed";
+
+ if ((*failureReasonRet = (char *) malloc (strlen (str) + 1)) != NULL)
+ strcpy (*failureReasonRet, str);
+
+ return (0);
+ }
+
+ smsConn->iceConn = iceConn;
+ smsConn->proto_major_version = majorVersion;
+ smsConn->proto_minor_version = minorVersion;
+ smsConn->client_id = NULL;
+
+ smsConn->save_yourself_in_progress = False;
+ smsConn->interaction_allowed = SmInteractStyleNone;
+ smsConn->can_cancel_shutdown = False;
+ smsConn->interact_in_progress = False;
+
+ *clientDataRet = (IcePointer) smsConn;
+
+
+ /*
+ * Now give the session manager the new smsConn and get back the
+ * callbacks to invoke when messages arrive from the client.
+ *
+ * In the future, we can use the mask return value to check
+ * if the SM is expecting an older rev of SMlib.
+ */
+
+ bzero ((char *) &smsConn->callbacks, sizeof (SmsCallbacks));
+
+ status = (*_SmsNewClientProc) (smsConn, _SmsNewClientData,
+ &mask, &smsConn->callbacks, failureReasonRet);
+
+ return (status);
+}
+
+
+
+
+Status
+SmsInitialize (vendor, release, newClientProc, managerData,
+ hostBasedAuthProc, errorLength, errorStringRet)
+
+char *vendor;
+char *release;
+SmsNewClientProc newClientProc;
+SmPointer managerData;
+IceHostBasedAuthProc hostBasedAuthProc;
+int errorLength;
+char *errorStringRet;
+
+{
+ if (errorStringRet && errorLength > 0)
+ *errorStringRet = '\0';
+
+ if (!newClientProc)
+ {
+ strncpy (errorStringRet,
+ "The SmsNewClientProc callback can't be NULL", errorLength);
+
+ return (0);
+ }
+
+ if (!_SmsOpcode)
+ {
+
+ if ((_SmsOpcode = IceRegisterForProtocolReply ("XSMP",
+ vendor, release, _SmVersionCount, _SmsVersions,
+ _SmAuthCount, _SmAuthNames, _SmsAuthProcs, hostBasedAuthProc,
+ _SmsProtocolSetupProc,
+ NULL, /* IceProtocolActivateProc - we don't care about
+ when the Protocol Reply is sent, because the
+ session manager can not immediately send a
+ message - it must wait for RegisterClient. */
+ NULL /* IceIOErrorProc */
+ )) < 0)
+ {
+ strncpy (errorStringRet,
+ "Could not register XSMP protocol with ICE", errorLength);
+
+ return (0);
+ }
+ }
+
+ _SmsNewClientProc = newClientProc;
+ _SmsNewClientData = managerData;
+
+ return (1);
+}
+
+
+
+char *
+SmsClientHostName (smsConn)
+
+SmsConn smsConn;
+
+{
+ return (IceGetPeerName (smsConn->iceConn));
+}
+
+
+
+Status
+SmsRegisterClientReply (smsConn, clientId)
+
+SmsConn smsConn;
+char *clientId;
+
+{
+ IceConn iceConn = smsConn->iceConn;
+ int extra;
+ smRegisterClientReplyMsg *pMsg;
+ char *pData;
+
+ if ((smsConn->client_id = (char *) malloc (strlen (clientId) + 1)) == NULL)
+ {
+ return (0);
+ }
+
+ strcpy (smsConn->client_id, clientId);
+
+ extra = ARRAY8_BYTES (strlen (clientId));
+
+ IceGetHeaderExtra (iceConn, _SmsOpcode, SM_RegisterClientReply,
+ SIZEOF (smRegisterClientReplyMsg), WORD64COUNT (extra),
+ smRegisterClientReplyMsg, pMsg, pData);
+
+ STORE_ARRAY8 (pData, strlen (clientId), clientId);
+
+ IceFlush (iceConn);
+
+ return (1);
+}
+
+
+
+void
+SmsSaveYourself (smsConn, saveType, shutdown, interactStyle, fast)
+
+SmsConn smsConn;
+int saveType;
+Bool shutdown;
+int interactStyle;
+Bool fast;
+
+{
+ IceConn iceConn = smsConn->iceConn;
+ smSaveYourselfMsg *pMsg;
+
+ IceGetHeader (iceConn, _SmsOpcode, SM_SaveYourself,
+ SIZEOF (smSaveYourselfMsg), smSaveYourselfMsg, pMsg);
+
+ pMsg->saveType = saveType;
+ pMsg->shutdown = shutdown;
+ pMsg->interactStyle = interactStyle;
+ pMsg->fast = fast;
+
+ IceFlush (iceConn);
+
+ smsConn->save_yourself_in_progress = True;
+
+ if (interactStyle == SmInteractStyleNone ||
+ interactStyle == SmInteractStyleErrors ||
+ interactStyle == SmInteractStyleAny)
+ {
+ smsConn->interaction_allowed = interactStyle;
+ }
+ else
+ {
+ smsConn->interaction_allowed = SmInteractStyleNone;
+ }
+
+ smsConn->can_cancel_shutdown = shutdown &&
+ (interactStyle == SmInteractStyleAny ||
+ interactStyle == SmInteractStyleErrors);
+}
+
+
+
+void
+SmsSaveYourselfPhase2 (smsConn)
+
+SmsConn smsConn;
+
+{
+ IceConn iceConn = smsConn->iceConn;
+
+ IceSimpleMessage (iceConn, _SmsOpcode, SM_SaveYourselfPhase2);
+ IceFlush (iceConn);
+}
+
+
+
+void
+SmsInteract (smsConn)
+
+SmsConn smsConn;
+
+{
+ IceConn iceConn = smsConn->iceConn;
+
+ IceSimpleMessage (iceConn, _SmsOpcode, SM_Interact);
+ IceFlush (iceConn);
+
+ smsConn->interact_in_progress = True;
+}
+
+
+
+void
+SmsDie (smsConn)
+
+SmsConn smsConn;
+
+{
+ IceConn iceConn = smsConn->iceConn;
+
+ IceSimpleMessage (iceConn, _SmsOpcode, SM_Die);
+ IceFlush (iceConn);
+}
+
+
+
+void
+SmsSaveComplete (smsConn)
+
+SmsConn smsConn;
+
+{
+ IceConn iceConn = smsConn->iceConn;
+
+ IceSimpleMessage (iceConn, _SmsOpcode, SM_SaveComplete);
+ IceFlush (iceConn);
+}
+
+
+
+void
+SmsShutdownCancelled (smsConn)
+
+SmsConn smsConn;
+
+{
+ IceConn iceConn = smsConn->iceConn;
+
+ IceSimpleMessage (iceConn, _SmsOpcode, SM_ShutdownCancelled);
+ IceFlush (iceConn);
+
+ smsConn->can_cancel_shutdown = False;
+}
+
+
+
+void
+SmsReturnProperties (smsConn, numProps, props)
+
+SmsConn smsConn;
+int numProps;
+SmProp **props;
+
+{
+ IceConn iceConn = smsConn->iceConn;
+ int bytes;
+ smPropertiesReplyMsg *pMsg;
+ char *pBuf;
+ char *pStart;
+
+ IceGetHeader (iceConn, _SmsOpcode, SM_PropertiesReply,
+ SIZEOF (smPropertiesReplyMsg), smPropertiesReplyMsg, pMsg);
+
+ LISTOF_PROP_BYTES (numProps, props, bytes);
+ pMsg->length += WORD64COUNT (bytes);
+
+ pBuf = pStart = IceAllocScratch (iceConn, bytes);
+
+ STORE_LISTOF_PROPERTY (pBuf, numProps, props);
+
+ IceWriteData (iceConn, bytes, pStart);
+ IceFlush (iceConn);
+}
+
+
+
+void
+SmsCleanUp (smsConn)
+
+SmsConn smsConn;
+
+{
+ IceProtocolShutdown (smsConn->iceConn, _SmsOpcode);
+
+ if (smsConn->client_id)
+ free (smsConn->client_id);
+
+ free ((char *) smsConn);
+}
diff --git a/nx-X11/lib/SM/sm_misc.c b/nx-X11/lib/SM/sm_misc.c
new file mode 100644
index 000000000..30c2c2d18
--- /dev/null
+++ b/nx-X11/lib/SM/sm_misc.c
@@ -0,0 +1,217 @@
+/* $Xorg: sm_misc.c,v 1.4 2001/02/09 02:03:30 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: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+#include <stdio.h>
+
+/*
+ * Free property
+ */
+
+void
+SmFreeProperty (prop)
+
+SmProp *prop;
+
+{
+ if (prop)
+ {
+ int i;
+
+ if (prop->name)
+ free (prop->name);
+ if (prop->type)
+ free (prop->type);
+ if (prop->vals)
+ {
+ for (i = 0; i < prop->num_vals; i++)
+ if (prop->vals[i].value)
+ free ((char *) prop->vals[i].value);
+ free ((char *) prop->vals);
+ }
+
+ free ((char *) prop);
+ }
+}
+
+
+/*
+ * Free reason messages
+ */
+
+void
+SmFreeReasons (count, reasonMsgs)
+
+int count;
+char **reasonMsgs;
+
+{
+ if (reasonMsgs)
+ {
+ int i;
+
+ for (i = 0; i < count; i++)
+ free (reasonMsgs[i]);
+
+ free ((char *) reasonMsgs);
+ }
+}
+
+
+
+/*
+ * Smc informational functions
+ */
+
+int
+SmcProtocolVersion (smcConn)
+
+SmcConn smcConn;
+
+{
+ return (smcConn->proto_major_version);
+}
+
+
+int
+SmcProtocolRevision (smcConn)
+
+SmcConn smcConn;
+
+{
+ return (smcConn->proto_minor_version);
+}
+
+
+char *
+SmcVendor (smcConn)
+
+SmcConn smcConn;
+
+{
+ char *string = (char *) malloc (strlen (smcConn->vendor) + 1);
+
+ strcpy (string, smcConn->vendor);
+
+ return (string);
+}
+
+
+char *
+SmcRelease (smcConn)
+
+SmcConn smcConn;
+
+{
+ char *string = (char *) malloc (strlen (smcConn->release) + 1);
+
+ strcpy (string, smcConn->release);
+
+ return (string);
+}
+
+
+char *
+SmcClientID (smcConn)
+
+SmcConn smcConn;
+
+{
+ char *clientId = (char *) malloc (strlen (smcConn->client_id) + 1);
+
+ strcpy (clientId, smcConn->client_id);
+
+ return (clientId);
+}
+
+
+IceConn
+SmcGetIceConnection (smcConn)
+
+SmcConn smcConn;
+
+{
+ return (smcConn->iceConn);
+}
+
+
+
+/*
+ * Sms informational functions
+ */
+
+int
+SmsProtocolVersion (smsConn)
+
+SmsConn smsConn;
+
+{
+ return (smsConn->proto_major_version);
+}
+
+
+int
+SmsProtocolRevision (smsConn)
+
+SmsConn smsConn;
+
+{
+ return (smsConn->proto_minor_version);
+}
+
+
+char *
+SmsClientID (smsConn)
+
+SmsConn smsConn;
+
+{
+ char *clientId = (char *) malloc (strlen (smsConn->client_id) + 1);
+
+ strcpy (clientId, smsConn->client_id);
+
+ return (clientId);
+}
+
+
+IceConn
+SmsGetIceConnection (smsConn)
+
+SmsConn smsConn;
+
+{
+ return (smsConn->iceConn);
+}
diff --git a/nx-X11/lib/SM/sm_process.c b/nx-X11/lib/SM/sm_process.c
new file mode 100644
index 000000000..ab3ec0ba4
--- /dev/null
+++ b/nx-X11/lib/SM/sm_process.c
@@ -0,0 +1,889 @@
+/* $Xorg: sm_process.c,v 1.4 2001/02/09 02:03:30 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.
+
+*/
+/* $XFree86$ */
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+
+
+/*
+ * Check for bad length
+ */
+
+#define CHECK_SIZE_MATCH(_iceConn, _majorOp, _minorOp, _expected_len, _actual_len, _severity) \
+ if ((((_actual_len) - SIZEOF (iceMsg)) >> 3) != _expected_len) \
+ { \
+ _IceErrorBadLength (_iceConn, _majorOp, _minorOp, _severity); \
+ return; \
+ }
+
+#define CHECK_AT_LEAST_SIZE(_iceConn, _majorOp, _minorOp, _expected_len, _actual_len, _severity) \
+ if ((((_actual_len) - SIZEOF (iceMsg)) >> 3) > _expected_len) \
+ { \
+ _IceErrorBadLength (_iceConn, _majorOp, _minorOp, _severity); \
+ return; \
+ }
+
+#define CHECK_COMPLETE_SIZE(_iceConn, _majorOp, _minorOp, _expected_len, _actual_len, _pStart, _severity) \
+ if (((PADDED_BYTES64((_actual_len)) - SIZEOF (iceMsg)) >> 3) \
+ != _expected_len) \
+ { \
+ _IceErrorBadLength (_iceConn, _majorOp, _minorOp, _severity); \
+ IceDisposeCompleteMessage (iceConn, _pStart); \
+ return; \
+ }
+
+
+
+void
+_SmcProcessMessage (iceConn, clientData, opcode,
+ length, swap, replyWait, replyReadyRet)
+
+IceConn iceConn;
+IcePointer clientData;
+int opcode;
+unsigned long length;
+Bool swap;
+IceReplyWaitInfo *replyWait;
+Bool *replyReadyRet;
+
+{
+ SmcConn smcConn = (SmcConn) clientData;
+
+ if (replyWait)
+ *replyReadyRet = False;
+
+ if (!smcConn->client_id &&
+ opcode != SM_RegisterClientReply && opcode != SM_Error)
+ {
+ _IceReadSkip (iceConn, length << 3);
+
+ _IceErrorBadState (iceConn, _SmcOpcode, opcode, IceFatalToProtocol);
+ return;
+ }
+
+ switch (opcode)
+ {
+ case SM_Error:
+ {
+ iceErrorMsg *pMsg;
+ char *pData;
+
+ CHECK_AT_LEAST_SIZE (iceConn, _SmcOpcode, opcode,
+ length, SIZEOF (iceErrorMsg), IceFatalToProtocol);
+
+ IceReadCompleteMessage (iceConn, SIZEOF (iceErrorMsg),
+ iceErrorMsg, pMsg, pData);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pData);
+ return;
+ }
+
+ if (swap)
+ {
+ pMsg->errorClass = lswaps (pMsg->errorClass);
+ pMsg->offendingSequenceNum = lswapl (pMsg->offendingSequenceNum);
+ }
+
+ if (replyWait &&
+ replyWait->minor_opcode_of_request == SM_RegisterClient &&
+ pMsg->errorClass == IceBadValue &&
+ pMsg->offendingMinorOpcode == SM_RegisterClient &&
+ pMsg->offendingSequenceNum == replyWait->sequence_of_request)
+ {
+ /*
+ * For Register Client, the previous ID was bad.
+ */
+
+ _SmcRegisterClientReply *reply =
+ (_SmcRegisterClientReply *) (replyWait->reply);
+
+ reply->status = 0;
+
+ *replyReadyRet = True;
+ }
+ else
+ {
+ (*_SmcErrorHandler) (smcConn, swap,
+ pMsg->offendingMinorOpcode,
+ pMsg->offendingSequenceNum,
+ pMsg->errorClass, pMsg->severity,
+ (SmPointer) pData);
+ }
+
+ IceDisposeCompleteMessage (iceConn, pData);
+ break;
+ }
+
+ case SM_RegisterClientReply:
+
+ if (!replyWait ||
+ replyWait->minor_opcode_of_request != SM_RegisterClient)
+ {
+ _IceReadSkip (iceConn, length << 3);
+
+ _IceErrorBadState (iceConn, _SmcOpcode,
+ SM_RegisterClientReply, IceFatalToProtocol);
+ }
+ else
+ {
+ smRegisterClientReplyMsg *pMsg;
+ char *pData, *pStart;
+ _SmcRegisterClientReply *reply =
+ (_SmcRegisterClientReply *) (replyWait->reply);
+
+#if 0 /* No-op */
+ CHECK_AT_LEAST_SIZE (iceConn, _SmcOpcode, opcode,
+ length, SIZEOF (smRegisterClientReplyMsg), IceFatalToProtocol);
+#endif
+
+ IceReadCompleteMessage (iceConn, SIZEOF (smRegisterClientReplyMsg),
+ smRegisterClientReplyMsg, pMsg, pStart);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return;
+ }
+
+ pData = pStart;
+
+ SKIP_ARRAY8 (pData, swap); /* client id */
+
+ CHECK_COMPLETE_SIZE (iceConn, _SmcOpcode, opcode,
+ length, pData - pStart + SIZEOF (smRegisterClientReplyMsg),
+ pStart, IceFatalToProtocol);
+
+ pData = pStart;
+
+ EXTRACT_ARRAY8_AS_STRING (pData, swap, reply->client_id);
+
+ reply->status = 1;
+ *replyReadyRet = True;
+
+ IceDisposeCompleteMessage (iceConn, pStart);
+ }
+ break;
+
+ case SM_SaveYourself:
+ {
+ smSaveYourselfMsg *pMsg;
+ unsigned char errVal;
+ int errOffset = -1;
+
+ CHECK_SIZE_MATCH (iceConn, _SmcOpcode, opcode,
+ length, SIZEOF (smSaveYourselfMsg),
+ IceFatalToProtocol);
+
+ IceReadMessageHeader (iceConn, SIZEOF (smSaveYourselfMsg),
+ smSaveYourselfMsg, pMsg);
+
+ if (!IceValidIO (iceConn))
+ {
+ return;
+ }
+
+ if (pMsg->saveType != SmSaveGlobal &&
+ pMsg->saveType != SmSaveLocal &&
+ pMsg->saveType != SmSaveBoth)
+ {
+ errVal = pMsg->saveType;
+ errOffset = 8;
+ }
+ else if (pMsg->shutdown != 1 && pMsg->shutdown != 0)
+ {
+ errVal = pMsg->shutdown;
+ errOffset = 9;
+ }
+ else if (pMsg->interactStyle != SmInteractStyleNone &&
+ pMsg->interactStyle != SmInteractStyleErrors &&
+ pMsg->interactStyle != SmInteractStyleAny)
+ {
+ errVal = pMsg->interactStyle;
+ errOffset = 10;
+ }
+ else if (pMsg->fast != 1 && pMsg->fast != 0)
+ {
+ errVal = pMsg->fast;
+ errOffset = 11;
+ }
+
+ if (errOffset >= 0)
+ {
+ _IceErrorBadValue (iceConn, _SmcOpcode,
+ SM_SaveYourself, errOffset, 1, (IcePointer) &errVal);
+ }
+ else
+ {
+ (*smcConn->callbacks.save_yourself.callback) (smcConn,
+ smcConn->callbacks.save_yourself.client_data,
+ pMsg->saveType, pMsg->shutdown,
+ pMsg->interactStyle, pMsg->fast);
+
+ smcConn->save_yourself_in_progress = True;
+
+ if (pMsg->shutdown)
+ smcConn->shutdown_in_progress = True;
+ }
+ break;
+ }
+
+ case SM_SaveYourselfPhase2:
+
+ if (!smcConn->phase2_wait)
+ {
+ _IceErrorBadState (iceConn, _SmcOpcode,
+ SM_SaveYourselfPhase2, IceCanContinue);
+ }
+ else
+ {
+ CHECK_SIZE_MATCH (iceConn, _SmcOpcode, opcode,
+ length, SIZEOF (smSaveYourselfPhase2Msg),
+ IceFatalToProtocol);
+
+ (*smcConn->phase2_wait->phase2_proc) (smcConn,
+ smcConn->phase2_wait->client_data);
+
+ free ((char *) smcConn->phase2_wait);
+ smcConn->phase2_wait = NULL;
+ }
+ break;
+
+ case SM_Interact:
+
+ if (!smcConn->interact_waits)
+ {
+ _IceErrorBadState (iceConn, _SmcOpcode,
+ SM_Interact, IceCanContinue);
+ }
+ else
+ {
+ _SmcInteractWait *next = smcConn->interact_waits->next;
+
+ CHECK_SIZE_MATCH (iceConn, _SmcOpcode, opcode,
+ length, SIZEOF (smInteractMsg),
+ IceFatalToProtocol);
+
+ (*smcConn->interact_waits->interact_proc) (smcConn,
+ smcConn->interact_waits->client_data);
+
+ free ((char *) smcConn->interact_waits);
+ smcConn->interact_waits = next;
+ }
+ break;
+
+ case SM_SaveComplete:
+
+ if (!smcConn->save_yourself_in_progress)
+ {
+ _IceErrorBadState (iceConn, _SmcOpcode,
+ SM_SaveComplete, IceCanContinue);
+ }
+ else
+ {
+ CHECK_SIZE_MATCH (iceConn, _SmcOpcode, opcode,
+ length, SIZEOF (smSaveCompleteMsg),
+ IceFatalToProtocol);
+
+ smcConn->save_yourself_in_progress = False;
+
+ (*smcConn->callbacks.save_complete.callback) (smcConn,
+ smcConn->callbacks.save_complete.client_data);
+ }
+ break;
+
+ case SM_Die:
+
+ CHECK_SIZE_MATCH (iceConn, _SmcOpcode, opcode,
+ length, SIZEOF (smDieMsg),
+ IceFatalToProtocol);
+
+ (*smcConn->callbacks.die.callback) (smcConn,
+ smcConn->callbacks.die.client_data);
+ break;
+
+ case SM_ShutdownCancelled:
+
+ if (!smcConn->shutdown_in_progress)
+ {
+ _IceErrorBadState (iceConn, _SmcOpcode,
+ SM_ShutdownCancelled, IceCanContinue);
+ }
+ else
+ {
+ CHECK_SIZE_MATCH (iceConn, _SmcOpcode, opcode,
+ length, SIZEOF (smShutdownCancelledMsg),
+ IceFatalToProtocol);
+
+ smcConn->shutdown_in_progress = False;
+
+ (*smcConn->callbacks.shutdown_cancelled.callback) (smcConn,
+ smcConn->callbacks.shutdown_cancelled.client_data);
+ }
+ break;
+
+ case SM_PropertiesReply:
+
+ if (!smcConn->prop_reply_waits)
+ {
+ _IceReadSkip (iceConn, length << 3);
+
+ _IceErrorBadState (iceConn, _SmcOpcode,
+ SM_PropertiesReply, IceCanContinue);
+ }
+ else
+ {
+ smPropertiesReplyMsg *pMsg;
+ char *pData, *pStart;
+ int numProps;
+ SmProp **props = NULL;
+ _SmcPropReplyWait *next;
+
+#if 0 /* No-op */
+ CHECK_AT_LEAST_SIZE (iceConn, _SmcOpcode, opcode,
+ length, SIZEOF (smPropertiesReplyMsg), IceFatalToProtocol);
+#endif
+
+ IceReadCompleteMessage (iceConn, SIZEOF (smPropertiesReplyMsg),
+ smPropertiesReplyMsg, pMsg, pStart);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return;
+ }
+
+ pData = pStart;
+
+ SKIP_LISTOF_PROPERTY (pData, swap);
+
+ CHECK_COMPLETE_SIZE (iceConn, _SmcOpcode, opcode,
+ length, pData - pStart + SIZEOF (smPropertiesReplyMsg),
+ pStart, IceFatalToProtocol);
+
+ pData = pStart;
+
+ EXTRACT_LISTOF_PROPERTY (pData, swap, numProps, props);
+
+ next = smcConn->prop_reply_waits->next;
+
+ (*smcConn->prop_reply_waits->prop_reply_proc) (smcConn,
+ smcConn->prop_reply_waits->client_data, numProps, props);
+
+ free ((char *) smcConn->prop_reply_waits);
+ smcConn->prop_reply_waits = next;
+
+ IceDisposeCompleteMessage (iceConn, pStart);
+ }
+ break;
+
+ default:
+ {
+ _IceErrorBadMinor (iceConn, _SmcOpcode, opcode, IceCanContinue);
+ _IceReadSkip (iceConn, length << 3);
+ break;
+ }
+ }
+}
+
+
+
+void
+_SmsProcessMessage (iceConn, clientData, opcode, length, swap)
+
+IceConn iceConn;
+IcePointer clientData;
+int opcode;
+unsigned long length;
+Bool swap;
+
+{
+ SmsConn smsConn = (SmsConn) clientData;
+
+ if (!smsConn->client_id &&
+ opcode != SM_RegisterClient && opcode != SM_Error)
+ {
+ _IceReadSkip (iceConn, length << 3);
+
+ _IceErrorBadState (iceConn, _SmsOpcode, opcode, IceFatalToProtocol);
+
+ return;
+ }
+
+ switch (opcode)
+ {
+ case SM_Error:
+ {
+ iceErrorMsg *pMsg;
+ char *pData;
+
+ CHECK_AT_LEAST_SIZE (iceConn, _SmsOpcode, opcode,
+ length, SIZEOF (iceErrorMsg), IceFatalToProtocol);
+
+ IceReadCompleteMessage (iceConn, SIZEOF (iceErrorMsg),
+ iceErrorMsg, pMsg, pData);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pData);
+ return;
+ }
+
+ if (swap)
+ {
+ pMsg->errorClass = lswaps (pMsg->errorClass);
+ pMsg->offendingSequenceNum = lswapl (pMsg->offendingSequenceNum);
+ }
+
+ (*_SmsErrorHandler) (smsConn, swap,
+ pMsg->offendingMinorOpcode,
+ pMsg->offendingSequenceNum,
+ pMsg->errorClass, pMsg->severity,
+ (SmPointer) pData);
+
+ IceDisposeCompleteMessage (iceConn, pData);
+ break;
+ }
+
+ case SM_RegisterClient:
+ {
+ smRegisterClientMsg *pMsg;
+ char *pData, *pStart;
+ char *previousId;
+ int idLen;
+
+#if 0 /* No-op */
+ CHECK_AT_LEAST_SIZE (iceConn, _SmsOpcode, opcode,
+ length, SIZEOF (smRegisterClientMsg), IceFatalToProtocol);
+#endif
+
+ IceReadCompleteMessage (iceConn, SIZEOF (smRegisterClientMsg),
+ smRegisterClientMsg, pMsg, pStart);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return;
+ }
+
+ pData = pStart;
+
+ SKIP_ARRAY8 (pData, swap); /* previous id */
+
+ CHECK_COMPLETE_SIZE (iceConn, _SmsOpcode, opcode,
+ length, pData - pStart + SIZEOF (smRegisterClientMsg),
+ pStart, IceFatalToProtocol);
+
+ pData = pStart;
+
+ EXTRACT_ARRAY8 (pData, swap, idLen, previousId);
+
+ if (*previousId == '\0')
+ {
+ free (previousId);
+ previousId = NULL;
+ }
+
+ if (!(*smsConn->callbacks.register_client.callback) (smsConn,
+ smsConn->callbacks.register_client.manager_data, previousId))
+ {
+ /*
+ * The previoudId was bad. Generate BadValue error.
+ */
+
+ _IceErrorBadValue (smsConn->iceConn, _SmsOpcode, SM_RegisterClient,
+ 8, ARRAY8_BYTES (idLen), (IcePointer) pStart);
+ }
+
+ IceDisposeCompleteMessage (iceConn, pStart);
+ break;
+ }
+
+ case SM_InteractRequest:
+
+ if (!smsConn->save_yourself_in_progress ||
+ smsConn->interaction_allowed == SmInteractStyleNone)
+ {
+ _IceErrorBadState (iceConn, _SmsOpcode,
+ SM_InteractRequest, IceCanContinue);
+ }
+ else
+ {
+ smInteractRequestMsg *pMsg;
+
+ CHECK_SIZE_MATCH (iceConn, _SmsOpcode, opcode,
+ length, SIZEOF (smInteractRequestMsg),
+ IceFatalToProtocol);
+
+ IceReadSimpleMessage (iceConn, smInteractRequestMsg, pMsg);
+
+ if (pMsg->dialogType != SmDialogNormal &&
+ pMsg->dialogType != SmDialogError)
+ {
+ unsigned char errVal = pMsg->dialogType;
+
+ _IceErrorBadValue (iceConn, _SmsOpcode,
+ SM_InteractRequest, 2, 1, (IcePointer) &errVal);
+ }
+ else if (pMsg->dialogType == SmDialogNormal &&
+ smsConn->interaction_allowed != SmInteractStyleAny)
+ {
+ _IceErrorBadState (iceConn, _SmsOpcode,
+ SM_InteractRequest, IceCanContinue);
+ }
+ else
+ {
+ (*smsConn->callbacks.interact_request.callback) (smsConn,
+ smsConn->callbacks.interact_request.manager_data,
+ pMsg->dialogType);
+ }
+ }
+ break;
+
+ case SM_InteractDone:
+
+ if (!smsConn->interact_in_progress)
+ {
+ _IceErrorBadState (iceConn, _SmsOpcode,
+ SM_InteractDone, IceCanContinue);
+ }
+ else
+ {
+ smInteractDoneMsg *pMsg;
+
+ CHECK_SIZE_MATCH (iceConn, _SmsOpcode, opcode,
+ length, SIZEOF (smInteractDoneMsg),
+ IceFatalToProtocol);
+
+ IceReadSimpleMessage (iceConn, smInteractDoneMsg, pMsg);
+
+ if (pMsg->cancelShutdown != 1 &&
+ pMsg->cancelShutdown != 0)
+ {
+ unsigned char errVal = pMsg->cancelShutdown;
+
+ _IceErrorBadValue (iceConn, _SmsOpcode,
+ SM_InteractDone, 2, 1, (IcePointer) &errVal);
+ }
+ else if (pMsg->cancelShutdown && !smsConn->can_cancel_shutdown)
+ {
+ _IceErrorBadState (iceConn, _SmsOpcode,
+ SM_InteractDone, IceCanContinue);
+ }
+ else
+ {
+ smsConn->interact_in_progress = False;
+
+ (*smsConn->callbacks.interact_done.callback) (smsConn,
+ smsConn->callbacks.interact_done.manager_data,
+ pMsg->cancelShutdown);
+ }
+ }
+ break;
+
+ case SM_SaveYourselfRequest:
+ {
+ smSaveYourselfRequestMsg *pMsg;
+ unsigned char errVal;
+ int errOffset = -1;
+
+ CHECK_SIZE_MATCH (iceConn, _SmsOpcode, opcode,
+ length, SIZEOF (smSaveYourselfRequestMsg),
+ IceFatalToProtocol);
+
+ IceReadMessageHeader (iceConn, SIZEOF (smSaveYourselfRequestMsg),
+ smSaveYourselfRequestMsg, pMsg);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pMsg);
+ return;
+ }
+
+ if (pMsg->saveType != SmSaveGlobal &&
+ pMsg->saveType != SmSaveLocal &&
+ pMsg->saveType != SmSaveBoth)
+ {
+ errVal = pMsg->saveType;
+ errOffset = 8;
+ }
+ else if (pMsg->shutdown != 1 && pMsg->shutdown != 0)
+ {
+ errVal = pMsg->shutdown;
+ errOffset = 9;
+ }
+ else if (pMsg->interactStyle != SmInteractStyleNone &&
+ pMsg->interactStyle != SmInteractStyleErrors &&
+ pMsg->interactStyle != SmInteractStyleAny)
+ {
+ errVal = pMsg->interactStyle;
+ errOffset = 10;
+ }
+ else if (pMsg->fast != 1 && pMsg->fast != 0)
+ {
+ errVal = pMsg->fast;
+ errOffset = 11;
+ }
+ else if (pMsg->global != 1 && pMsg->global != 0)
+ {
+ errVal = pMsg->fast;
+ errOffset = 11;
+ }
+
+ if (errOffset >= 0)
+ {
+ _IceErrorBadValue (iceConn, _SmsOpcode,
+ SM_SaveYourselfRequest, errOffset, 1, (IcePointer) &errVal);
+ }
+ else
+ {
+ (*smsConn->callbacks.save_yourself_request.callback) (smsConn,
+ smsConn->callbacks.save_yourself_request.manager_data,
+ pMsg->saveType, pMsg->shutdown, pMsg->interactStyle,
+ pMsg->fast, pMsg->global);
+ }
+ break;
+ }
+
+ case SM_SaveYourselfPhase2Request:
+
+ if (!smsConn->save_yourself_in_progress)
+ {
+ _IceErrorBadState (iceConn, _SmsOpcode,
+ SM_SaveYourselfPhase2Request, IceCanContinue);
+ }
+ else
+ {
+ CHECK_SIZE_MATCH (iceConn, _SmsOpcode, opcode,
+ length, SIZEOF (smSaveYourselfPhase2RequestMsg),
+ IceFatalToProtocol);
+
+ (*smsConn->callbacks.save_yourself_phase2_request.callback) (
+ smsConn, smsConn->callbacks.
+ save_yourself_phase2_request.manager_data);
+ }
+ break;
+
+ case SM_SaveYourselfDone:
+
+ if (!smsConn->save_yourself_in_progress)
+ {
+ _IceErrorBadState (iceConn, _SmsOpcode,
+ SM_SaveYourselfDone, IceCanContinue);
+ }
+ else
+ {
+ smSaveYourselfDoneMsg *pMsg;
+
+ CHECK_SIZE_MATCH (iceConn, _SmsOpcode, opcode,
+ length, SIZEOF (smSaveYourselfDoneMsg),
+ IceFatalToProtocol);
+
+ IceReadSimpleMessage (iceConn, smSaveYourselfDoneMsg, pMsg);
+
+ if (pMsg->success != 1 && pMsg->success != 0)
+ {
+ unsigned char errVal = pMsg->success;
+
+ _IceErrorBadValue (iceConn, _SmsOpcode,
+ SM_SaveYourselfDone, 2, 1, (IcePointer) &errVal);
+ }
+ else
+ {
+ smsConn->save_yourself_in_progress = False;
+ smsConn->interaction_allowed = SmInteractStyleNone;
+
+ (*smsConn->callbacks.save_yourself_done.callback) (smsConn,
+ smsConn->callbacks.save_yourself_done.manager_data,
+ pMsg->success);
+ }
+ }
+ break;
+
+ case SM_CloseConnection:
+ {
+ smCloseConnectionMsg *pMsg;
+ char *pData, *pStart;
+ int count, i;
+ char **reasonMsgs = NULL;
+
+#if 0 /* No-op */
+ CHECK_AT_LEAST_SIZE (iceConn, _SmsOpcode, opcode,
+ length, SIZEOF (smCloseConnectionMsg), IceFatalToProtocol);
+#endif
+
+ IceReadCompleteMessage (iceConn, SIZEOF (smCloseConnectionMsg),
+ smCloseConnectionMsg, pMsg, pStart);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return;
+ }
+
+ pData = pStart;
+
+ EXTRACT_CARD32 (pData, swap, count);
+ pData += 4;
+
+ for (i = 0; i < count; i++)
+ SKIP_ARRAY8 (pData, swap);
+
+ CHECK_COMPLETE_SIZE (iceConn, _SmsOpcode, opcode,
+ length, pData - pStart + SIZEOF (smCloseConnectionMsg),
+ pStart, IceFatalToProtocol);
+
+ pData = pStart + 8;
+
+ reasonMsgs = (char **) malloc (count * sizeof (char *));
+ for (i = 0; i < count; i++)
+ EXTRACT_ARRAY8_AS_STRING (pData, swap, reasonMsgs[i]);
+
+ IceDisposeCompleteMessage (iceConn, pStart);
+
+ (*smsConn->callbacks.close_connection.callback) (smsConn,
+ smsConn->callbacks.close_connection.manager_data,
+ count, reasonMsgs);
+ break;
+ }
+
+ case SM_SetProperties:
+ {
+ smSetPropertiesMsg *pMsg;
+ char *pData, *pStart;
+ SmProp **props = NULL;
+ int numProps;
+
+#if 0 /* No-op */
+ CHECK_AT_LEAST_SIZE (iceConn, _SmsOpcode, opcode,
+ length, SIZEOF (smSetPropertiesMsg), IceFatalToProtocol);
+#endif
+
+ IceReadCompleteMessage (iceConn, SIZEOF (smSetPropertiesMsg),
+ smSetPropertiesMsg, pMsg, pStart);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return;
+ }
+
+ pData = pStart;
+
+ SKIP_LISTOF_PROPERTY (pData, swap);
+
+ CHECK_COMPLETE_SIZE (iceConn, _SmsOpcode, opcode,
+ length, pData - pStart + SIZEOF (smSetPropertiesMsg),
+ pStart, IceFatalToProtocol);
+
+ pData = pStart;
+
+ EXTRACT_LISTOF_PROPERTY (pData, swap, numProps, props);
+
+ (*smsConn->callbacks.set_properties.callback) (smsConn,
+ smsConn->callbacks.set_properties.manager_data, numProps, props);
+
+ IceDisposeCompleteMessage (iceConn, pStart);
+ break;
+ }
+
+ case SM_DeleteProperties:
+ {
+ smDeletePropertiesMsg *pMsg;
+ char *pData, *pStart;
+ int count, i;
+ char **propNames = NULL;
+
+#if 0 /* No-op */
+ CHECK_AT_LEAST_SIZE (iceConn, _SmsOpcode, opcode,
+ length, SIZEOF (smDeletePropertiesMsg), IceFatalToProtocol);
+#endif
+
+ IceReadCompleteMessage (iceConn, SIZEOF (smDeletePropertiesMsg),
+ smDeletePropertiesMsg, pMsg, pStart);
+
+ if (!IceValidIO (iceConn))
+ {
+ IceDisposeCompleteMessage (iceConn, pStart);
+ return;
+ }
+
+ pData = pStart;
+
+ EXTRACT_CARD32 (pData, swap, count);
+ pData += 4;
+
+ for (i = 0; i < count; i++)
+ SKIP_ARRAY8 (pData, swap); /* prop names */
+
+ CHECK_COMPLETE_SIZE (iceConn, _SmsOpcode, opcode,
+ length, pData - pStart + SIZEOF (smDeletePropertiesMsg),
+ pStart, IceFatalToProtocol);
+
+ pData = pStart + 8;
+
+ propNames = (char **) malloc (count * sizeof (char *));
+ for (i = 0; i < count; i++)
+ EXTRACT_ARRAY8_AS_STRING (pData, swap, propNames[i]);
+
+ IceDisposeCompleteMessage (iceConn, pStart);
+
+ (*smsConn->callbacks.delete_properties.callback) (smsConn,
+ smsConn->callbacks.delete_properties.manager_data,
+ count, propNames);
+
+ break;
+ }
+
+ case SM_GetProperties:
+
+ CHECK_SIZE_MATCH (iceConn, _SmsOpcode, opcode,
+ length, SIZEOF (smGetPropertiesMsg),
+ IceFatalToProtocol);
+
+ (*smsConn->callbacks.get_properties.callback) (smsConn,
+ smsConn->callbacks.get_properties.manager_data);
+ break;
+
+ default:
+ {
+ _IceErrorBadMinor (iceConn, _SmsOpcode, opcode, IceCanContinue);
+ _IceReadSkip (iceConn, length << 3);
+ break;
+ }
+ }
+}
diff --git a/nx-X11/lib/X11/AddDIC.c b/nx-X11/lib/X11/AddDIC.c
new file mode 100644
index 000000000..d2638b1f9
--- /dev/null
+++ b/nx-X11/lib/X11/AddDIC.c
@@ -0,0 +1,152 @@
+/* $Xorg: AddDIC.c,v 1.3 2000/08/17 19:44:29 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsAddDIC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsAddColorSpace
+ *
+ *
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/*
+ * DEFINES
+ */
+#define NextUnregDiCsID(lastid) \
+ (XCMS_UNREG_ID(lastid) ? ++lastid : XCMS_FIRST_UNREG_DI_ID)
+#define MAX(x,y) ((x) < (y) ? (y) : (x))
+
+
+/*
+ * NAME
+ * XcmsAddColorSpace - Add a Device-Independent Color Space
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsAddColorSpace(pCS)
+ XcmsColorSpace *pCS;
+/*
+ * DESCRIPTION
+ * DI Color Spaces are managed on a global basis.
+ * This means that with exception of the provided DI color spaces:
+ * CIEXYZ, CIExyY, CIELab, CIEuvY, CIELuv, and TekHVC
+ * DI color spaces may have different XcmsColorFormat IDs between
+ * clients. So, you must be careful when using XcmsColor
+ * structures between clients! Use the routines XcmsFormatOfPrefix()
+ * and XcmsPrefixOfFormat() appropriately.
+ *
+ * RETURNS
+ * XcmsSuccess if succeeded, otherwise XcmsFailure
+ */
+{
+ XcmsColorSpace **papColorSpaces;
+ XcmsColorSpace *ptmpCS;
+ XcmsColorFormat lastID = 0;
+
+ if ((pCS->id = _XcmsRegFormatOfPrefix(pCS->prefix)) != 0) {
+ if (XCMS_DD_ID(pCS->id)) {
+ /* This is a Device-Dependent Color Space */
+ return(XcmsFailure);
+ }
+ /*
+ * REGISTERED DI Color Space
+ * then see if the color space has already been added to the
+ * system:
+ * a. If the same ID/prefix and same XcmsColorSpec is found,
+ * then its a duplicate, so return success.
+ * b. If same ID/prefix but different XcmsColorSpec is
+ * found, then add the color space to the front of the
+ * list using the same ID. This allows one to override
+ * an existing DI Color Space.
+ * c. Otherwise none found so just add the color space.
+ */
+ if ((papColorSpaces = _XcmsDIColorSpaces) != NULL) {
+ while ((ptmpCS = *papColorSpaces++) != NULL) {
+ if (pCS->id == ptmpCS->id) {
+ if (pCS == ptmpCS) {
+ /* a. duplicate*/
+ return(XcmsSuccess);
+ }
+ /* b. same ID/prefix but different XcmsColorSpace */
+ break;
+ }
+ }
+ }
+ /* c. None found */
+ } else {
+ /*
+ * UNREGISTERED DI Color Space
+ * then see if the color space has already been added to the
+ * system:
+ * a. If same prefix and XcmsColorSpec, then
+ * its a duplicate ... return success.
+ * b. If same prefix but different XcmsColorSpec, then
+ * add the color space to the front of the list using
+ * the same ID. This allows one to override an existing
+ * DI Color Space.
+ * c. Otherwise none found so, add the color space using the
+ * next unregistered ID for the connection.
+ */
+ if ((papColorSpaces = _XcmsDIColorSpaces) != NULL) {
+ while ((ptmpCS = *papColorSpaces++) != NULL) {
+ lastID = MAX(lastID, ptmpCS->id);
+ if (strcmp(pCS->prefix, ptmpCS->prefix) == 0) {
+ if (pCS == ptmpCS) {
+ /* a. duplicate */
+ return(XcmsSuccess);
+ }
+ /* b. same prefix but different XcmsColorSpec */
+ pCS->id = ptmpCS->id;
+ goto AddColorSpace;
+ }
+ }
+ }
+ /* c. None found */
+ pCS->id = NextUnregDiCsID(lastID);
+ }
+
+
+AddColorSpace:
+ if ((papColorSpaces = (XcmsColorSpace **)
+ _XcmsPushPointerArray((XPointer *)_XcmsDIColorSpaces,
+ (XPointer)pCS,
+ (XPointer *)_XcmsDIColorSpacesInit)) == NULL) {
+ return(XcmsFailure);
+ }
+ _XcmsDIColorSpaces = papColorSpaces;
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/AddSF.c b/nx-X11/lib/X11/AddSF.c
new file mode 100644
index 000000000..3ab0514a6
--- /dev/null
+++ b/nx-X11/lib/X11/AddSF.c
@@ -0,0 +1,148 @@
+/* $Xorg: AddSF.c,v 1.3 2000/08/17 19:44:29 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsAddSF.c
+ *
+ * DESCRIPTION
+ * Source for XcmsAddFunctionSet
+ *
+ *
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define NextUnregDdCsID(lastid) \
+ (XCMS_UNREG_ID(lastid) ? ++lastid : XCMS_FIRST_UNREG_DD_ID)
+#define MIN(x,y) ((x) > (y) ? (y) : (x))
+
+
+/*
+ * NAME
+ * XcmsAddFunctionSet - Add an Screen Color Characterization
+ * Function Set
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsAddFunctionSet(pNewFS)
+ XcmsFunctionSet *pNewFS;
+/*
+ * DESCRIPTION
+ * Additional Screen Color Characterization Function Sets are
+ * managed on a global basis. This means that with exception
+ * of the provided DD color spaces:
+ * RGB and RGBi
+ * DD color spaces may have different XcmsColorFormat IDs between
+ * clients. So, you must be careful when using XcmsColorFormat
+ * across clients! Use the routines XcmsFormatOfPrefix()
+ * and XcmsPrefixOfFormat() appropriately.
+ *
+ * RETURNS
+ * XcmsSuccess if succeeded, otherwise XcmsFailure
+ *
+ * CAVEATS
+ * Additional Screen Color Characterization Function Sets
+ * should be added prior to any use of the routine
+ * XcmsCreateCCC(). If not, XcmsCCC structures created
+ * prior to the call of this routines will not have had
+ * a chance to initialize using the added Screen Color
+ * Characterization Function Set.
+ */
+{
+ XcmsFunctionSet **papSCCFuncSets = _XcmsSCCFuncSets;
+ XcmsColorSpace **papNewCSs;
+ XcmsColorSpace *pNewCS, **paptmpCS;
+ XcmsColorFormat lastID = 0;
+
+
+ if (papSCCFuncSets != NULL) {
+ if ((papNewCSs = pNewFS->DDColorSpaces) == NULL) {
+ /*
+ * Error, new Screen Color Characterization Function Set
+ * missing color spaces
+ */
+ return(XcmsFailure);
+ }
+ while ((pNewCS = *papNewCSs++) != NULL) {
+ if ((pNewCS->id = _XcmsRegFormatOfPrefix(pNewCS->prefix)) != 0) {
+ if (XCMS_DI_ID(pNewCS->id)) {
+ /* This is a Device-Independent Color Space */
+ return(XcmsFailure);
+ }
+ /*
+ * REGISTERED DD Color Space
+ * therefore use the registered ID.
+ */
+ } else {
+ /*
+ * UNREGISTERED DD Color Space
+ * then see if the color space is already in
+ * _XcmsDDColorSpaces.
+ * a. If same prefix, then use the same ID.
+ * b. Otherwise, use a new ID.
+ */
+ for (paptmpCS = _XcmsDDColorSpaces; *paptmpCS != NULL;
+ paptmpCS++){
+ lastID = MIN(lastID, (*paptmpCS)->id);
+ if (strcmp(pNewCS->prefix, (*paptmpCS)->prefix) == 0) {
+ pNewCS->id = (*paptmpCS)->id;
+ break;
+ }
+ }
+ if (pNewCS->id == 0) {
+ /* still haven't found one */
+ pNewCS->id = NextUnregDdCsID(lastID);
+ if ((paptmpCS = (XcmsColorSpace **)_XcmsPushPointerArray(
+ (XPointer *) _XcmsDDColorSpaces,
+ (XPointer) pNewCS,
+ (XPointer *) _XcmsDDColorSpacesInit)) == NULL) {
+ return(XcmsFailure);
+ }
+ _XcmsDDColorSpaces = paptmpCS;
+ }
+ }
+ }
+ }
+ if ((papSCCFuncSets = (XcmsFunctionSet **)
+ _XcmsPushPointerArray((XPointer *) _XcmsSCCFuncSets,
+ (XPointer) pNewFS,
+ (XPointer *)_XcmsSCCFuncSetsInit)) == NULL) {
+ return(XcmsFailure);
+ }
+ _XcmsSCCFuncSets = papSCCFuncSets;
+
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/AllCells.c b/nx-X11/lib/X11/AllCells.c
new file mode 100644
index 000000000..ed7bc8453
--- /dev/null
+++ b/nx-X11/lib/X11/AllCells.c
@@ -0,0 +1,66 @@
+/* $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
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/AllPlanes.c b/nx-X11/lib/X11/AllPlanes.c
new file mode 100644
index 000000000..079422bee
--- /dev/null
+++ b/nx-X11/lib/X11/AllPlanes.c
@@ -0,0 +1,74 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/AllPlanes.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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, (long *) pixels, (long)(ncolors * 4));
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(status);
+}
diff --git a/nx-X11/lib/X11/AllowEv.c b/nx-X11/lib/X11/AllowEv.c
new file mode 100644
index 000000000..c5905b99f
--- /dev/null
+++ b/nx-X11/lib/X11/AllowEv.c
@@ -0,0 +1,53 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/AllowEv.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/AutoRep.c b/nx-X11/lib/X11/AutoRep.c
new file mode 100644
index 000000000..404d520b9
--- /dev/null
+++ b/nx-X11/lib/X11/AutoRep.c
@@ -0,0 +1,54 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/AutoRep.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XAutoRepeatOn (dpy)
+register Display *dpy;
+{
+ XKeyboardControl values;
+ values.auto_repeat_mode = AutoRepeatModeOn;
+ XChangeKeyboardControl (dpy, KBAutoRepeatMode, &values);
+ return 1;
+}
+
+int
+XAutoRepeatOff (dpy)
+register Display *dpy;
+{
+ XKeyboardControl values;
+ values.auto_repeat_mode = AutoRepeatModeOff;
+ XChangeKeyboardControl (dpy, KBAutoRepeatMode, &values);
+ return 1;
+}
+
+
diff --git a/nx-X11/lib/X11/Backgnd.c b/nx-X11/lib/X11/Backgnd.c
new file mode 100644
index 000000000..dbb92425c
--- /dev/null
+++ b/nx-X11/lib/X11/Backgnd.c
@@ -0,0 +1,51 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/Backgnd.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/BdrWidth.c b/nx-X11/lib/X11/BdrWidth.c
new file mode 100644
index 000000000..db6df0135
--- /dev/null
+++ b/nx-X11/lib/X11/BdrWidth.c
@@ -0,0 +1,55 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/BdrWidth.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/Bell.c b/nx-X11/lib/X11/Bell.c
new file mode 100644
index 000000000..8eebc6b08
--- /dev/null
+++ b/nx-X11/lib/X11/Bell.c
@@ -0,0 +1,48 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/Bell.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/Border.c b/nx-X11/lib/X11/Border.c
new file mode 100644
index 000000000..8f0bdb683
--- /dev/null
+++ b/nx-X11/lib/X11/Border.c
@@ -0,0 +1,51 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/Border.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/CCC.c b/nx-X11/lib/X11/CCC.c
new file mode 100644
index 000000000..7d4a9b1a2
--- /dev/null
+++ b/nx-X11/lib/X11/CCC.c
@@ -0,0 +1,290 @@
+/* $Xorg: CCC.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsCCC.c - Color Conversion Context Routines
+ *
+ * DESCRIPTION
+ * Routines to create, access, and free Color Conversion
+ * Context structures.
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/CCC.c,v 1.4 2001/12/14 19:53:56 dawes 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCreateCCC
+ *
+ * SYNOPSIS
+ */
+
+XcmsCCC
+XcmsCreateCCC(dpy, screenNumber, visual, clientWhitePt, gamutCompProc,
+ gamutCompClientData, whitePtAdjProc, whitePtAdjClientData)
+ Display *dpy;
+ int screenNumber;
+ Visual *visual;
+ XcmsColor *clientWhitePt;
+ XcmsCompressionProc gamutCompProc;
+ XPointer gamutCompClientData;
+ XcmsWhiteAdjustProc whitePtAdjProc;
+ XPointer whitePtAdjClientData;
+/*
+ * DESCRIPTION
+ * Given a Display, Screen, Visual, etc., this routine creates
+ * an appropriate Color Conversion Context.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise address of the newly
+ * created XcmsCCC.
+ *
+ */
+{
+ XcmsCCC pDefaultCCC = XcmsDefaultCCC(dpy, screenNumber);
+ XcmsCCC newccc;
+ XcmsIntensityMap *pIMap;
+ XcmsPerScrnInfo *pNewScrnInfo;
+
+ if (pDefaultCCC == NULL ||
+ !(newccc = (XcmsCCC) Xcalloc(1, (unsigned) sizeof(XcmsCCCRec)))) {
+ return(NULL);
+ }
+
+ /*
+ * Should inherit the following as result of a memmove():
+ * dpy
+ * screenNumber
+ * pPerScrnInfo
+ */
+ memcpy((char *)newccc, (char *)pDefaultCCC, sizeof(XcmsCCCRec));
+ if (clientWhitePt) {
+ memcpy((char *)&newccc->clientWhitePt, (char *)clientWhitePt,
+ sizeof(XcmsColor));
+ }
+ if (gamutCompProc) {
+ newccc->gamutCompProc = gamutCompProc;
+ }
+ if (gamutCompClientData) {
+ newccc->gamutCompClientData = gamutCompClientData;
+ }
+ if (whitePtAdjProc) {
+ newccc->whitePtAdjProc = whitePtAdjProc;
+ }
+ if (whitePtAdjClientData) {
+ newccc->whitePtAdjClientData = whitePtAdjClientData;
+ }
+
+ /*
+ * Now check our list of per-Visual Intensity tables.
+ * If one exists replace the pPerScrnInfo.
+ */
+ if ((pIMap = _XcmsGetIntensityMap(dpy, visual)) != NULL) {
+ if (!(pNewScrnInfo = (XcmsPerScrnInfo *)
+ Xcalloc(1, (unsigned) sizeof(XcmsPerScrnInfo)))) {
+ Xfree(newccc);
+ return(NULL);
+ }
+ memcpy((char *)pNewScrnInfo, (char *)newccc->pPerScrnInfo,
+ sizeof(XcmsPerScrnInfo));
+ pNewScrnInfo->screenData = pIMap->screenData;
+ newccc->pPerScrnInfo = pNewScrnInfo;
+ }
+
+ /*
+ * Set visual component
+ */
+ newccc->visual = visual;
+
+ return(newccc);
+}
+
+
+/*
+ * NAME
+ * XcmsDefaultCCC
+ *
+ * SYNOPSIS
+ */
+XcmsCCC
+XcmsDefaultCCC(dpy, screenNumber)
+ Display *dpy;
+ int screenNumber;
+/*
+ * DESCRIPTION
+ * Given a Display and Screen, this routine creates
+ * returns the Screen's default Color Conversion Context.
+ * Note that a Screen's default CCC is built with the
+ * screen default visual.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise address of the
+ * XcmsCCC for the Screen's default CCC.
+ *
+ */
+{
+ XcmsCCC ccc;
+
+
+ if ((screenNumber < 0) || (screenNumber >= ScreenCount(dpy))) {
+ return((XcmsCCC)NULL);
+ }
+
+ /*
+ * Check if the XcmsCCC's for each screen has been created
+ */
+ if ((XcmsCCC)dpy->cms.defaultCCCs == NULL) {
+ if (!_XcmsInitDefaultCCCs(dpy)) {
+ return((XcmsCCC)NULL);
+ }
+ }
+
+ ccc = (XcmsCCC)dpy->cms.defaultCCCs + screenNumber;
+
+ if (!ccc->pPerScrnInfo) {
+ /*
+ * Need to create the XcmsPerScrnInfo structure. The
+ * _XcmsInitScrnInfo routine will create the XcmsPerScrnInfo
+ * structure as well as initialize its functionSet and pScreenData
+ * components.
+ */
+ if (!_XcmsInitScrnInfo(dpy, screenNumber)) {
+ return((XcmsCCC)NULL);
+ }
+ return(ccc);
+ } else {
+ /*
+ * If ccc->pPerScrnInfo->state == XcmsInitSuccess,
+ * then the pPerScrnInfo component has already been initialized
+ * therefore, just return ccc.
+ * If ccc->pPerScrnInfo->state == XcmsInitFailure,
+ * then this means that we already attempted to initialize
+ * the pPerScrnInfo component but failed therefore stuffing
+ * the pPerScrnInfo component with defaults. Just return ccc.
+ * If ccc->pPerScrnInfo->state == XcmsInitNone,
+ * then attempt to initialize the pPerScrnInfo component.
+ */
+ switch (ccc->pPerScrnInfo->state) {
+ case XcmsInitFailure :
+ /* fall through */
+ case XcmsInitSuccess :
+ return(ccc);
+ case XcmsInitNone :
+ /* XcmsPerScreenInfo has not been initialized */
+ if (!_XcmsInitScrnInfo(dpy, screenNumber)) {
+ return((XcmsCCC)NULL);
+ }
+ return(ccc);
+ default :
+ return((XcmsCCC)NULL);
+ }
+ }
+}
+
+
+/*
+ * NAME
+ * XcmsFreeCCC
+ *
+ * SYNOPSIS
+ */
+void
+XcmsFreeCCC(ccc)
+ XcmsCCC ccc;
+/*
+ * DESCRIPTION
+ * Frees memory associated with a Color Conversion Context
+ * that was created with XcmsCreateCCC().
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ if (ccc->dpy->cms.defaultCCCs &&
+ ccc == ((XcmsCCC)ccc->dpy->cms.defaultCCCs) + ccc->screenNumber) {
+ /* do not allow clients to free DefaultCCC's */
+ return;
+ }
+
+ /*
+ * Note that XcmsPerScrnInfo sub-structures are freed here only if
+ * they are for visuals that have per-Visual intensity tables.
+ * Otherwise the XcmsPerScrnInfo structure is being shared!
+ * For the latter, there is only one allocated per Screen and it just
+ * so happens * that we place its initial reference is placed in the
+ * default CCC. The routine _XcmsFreeDefaultCCCs frees them.
+ */
+ if (_XcmsGetIntensityMap(ccc->dpy, ccc->visual) != NULL) {
+ Xfree(ccc->pPerScrnInfo);
+ }
+
+ Xfree(ccc);
+}
diff --git a/nx-X11/lib/X11/ChAccCon.c b/nx-X11/lib/X11/ChAccCon.c
new file mode 100644
index 000000000..eef3bb016
--- /dev/null
+++ b/nx-X11/lib/X11/ChAccCon.c
@@ -0,0 +1,65 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChAccCon.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XEnableAccessControl(dpy)
+ register Display *dpy;
+
+{
+ return XSetAccessControl(dpy, EnableAccess);
+}
+
+int
+XDisableAccessControl(dpy)
+ register Display *dpy;
+
+{
+ return XSetAccessControl(dpy, DisableAccess);
+}
+
+int
+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/nx-X11/lib/X11/ChActPGb.c b/nx-X11/lib/X11/ChActPGb.c
new file mode 100644
index 000000000..42ec3305b
--- /dev/null
+++ b/nx-X11/lib/X11/ChActPGb.c
@@ -0,0 +1,51 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChActPGb.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/ChClMode.c b/nx-X11/lib/X11/ChClMode.c
new file mode 100644
index 000000000..1b22f68b6
--- /dev/null
+++ b/nx-X11/lib/X11/ChClMode.c
@@ -0,0 +1,49 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChClMode.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/ChCmap.c b/nx-X11/lib/X11/ChCmap.c
new file mode 100644
index 000000000..112c944b2
--- /dev/null
+++ b/nx-X11/lib/X11/ChCmap.c
@@ -0,0 +1,51 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChCmap.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/ChGC.c b/nx-X11/lib/X11/ChGC.c
new file mode 100644
index 000000000..bafa1d496
--- /dev/null
+++ b/nx-X11/lib/X11/ChGC.c
@@ -0,0 +1,54 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChGC.c,v 1.4 2001/12/14 19:53:57 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Cr.h"
+
+int
+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/nx-X11/lib/X11/ChKeyCon.c b/nx-X11/lib/X11/ChKeyCon.c
new file mode 100644
index 000000000..831f6f0eb
--- /dev/null
+++ b/nx-X11/lib/X11/ChKeyCon.c
@@ -0,0 +1,85 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChKeyCon.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/ChPntCon.c b/nx-X11/lib/X11/ChPntCon.c
new file mode 100644
index 000000000..225d031c6
--- /dev/null
+++ b/nx-X11/lib/X11/ChPntCon.c
@@ -0,0 +1,55 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChPntCon.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/ChProp.c b/nx-X11/lib/X11/ChProp.c
new file mode 100644
index 000000000..8c524cafe
--- /dev/null
+++ b/nx-X11/lib/X11/ChProp.c
@@ -0,0 +1,101 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChProp.c,v 1.4 2001/12/14 19:53:57 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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)
+ {
+ 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/nx-X11/lib/X11/ChSaveSet.c b/nx-X11/lib/X11/ChSaveSet.c
new file mode 100644
index 000000000..9862db72d
--- /dev/null
+++ b/nx-X11/lib/X11/ChSaveSet.c
@@ -0,0 +1,65 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChSaveSet.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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;
+}
+
+int
+XAddToSaveSet(dpy, win)
+ register Display *dpy;
+ Window win;
+{
+ return XChangeSaveSet(dpy,win,SetModeInsert);
+}
+
+int
+XRemoveFromSaveSet (dpy, win)
+ register Display *dpy;
+ Window win;
+{
+ return XChangeSaveSet(dpy,win,SetModeDelete);
+}
diff --git a/nx-X11/lib/X11/ChWAttrs.c b/nx-X11/lib/X11/ChWAttrs.c
new file mode 100644
index 000000000..57b81ab15
--- /dev/null
+++ b/nx-X11/lib/X11/ChWAttrs.c
@@ -0,0 +1,59 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChWAttrs.c,v 1.4 2001/12/14 19:53:57 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+#define AllMaskBits (CWBackPixmap|CWBackPixel|CWBorderPixmap|\
+ CWBorderPixel|CWBitGravity|CWWinGravity|\
+ CWBackingStore|CWBackingPlanes|CWBackingPixel|\
+ CWOverrideRedirect|CWSaveUnder|CWEventMask|\
+ CWDontPropagate|CWColormap|CWCursor)
+
+int
+XChangeWindowAttributes (dpy, w, valuemask, attributes)
+ register Display *dpy;
+ Window w;
+ unsigned long valuemask;
+ XSetWindowAttributes *attributes;
+{
+ register xChangeWindowAttributesReq *req;
+
+ 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/nx-X11/lib/X11/ChWindow.c b/nx-X11/lib/X11/ChWindow.c
new file mode 100644
index 000000000..a403d76d8
--- /dev/null
+++ b/nx-X11/lib/X11/ChWindow.c
@@ -0,0 +1,64 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChWindow.c,v 1.5 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/ChkIfEv.c b/nx-X11/lib/X11/ChkIfEv.c
new file mode 100644
index 000000000..0217af830
--- /dev/null
+++ b/nx-X11/lib/X11/ChkIfEv.c
@@ -0,0 +1,138 @@
+/* $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.
+
+*/
+/* $XFree86$ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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)(
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+ ); /* 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;
+}
+
+#ifdef NX_TRANS_SOCKET
+
+/*
+ * This is just like XCheckIfEvent() but doesn't
+ * flush the output buffer if it can't read new
+ * events.
+ */
+
+Bool XCheckIfEventNoFlush (dpy, event, predicate, arg)
+ register Display *dpy;
+ Bool (*predicate)(
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+ ); /* 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 = 2; --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 1:
+ _XEventsQueued(dpy, QueuedAfterReading);
+ break;
+ }
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+ UnlockDisplay(dpy);
+ return False;
+}
+
+#endif
diff --git a/nx-X11/lib/X11/ChkIfEv.c.NX.original b/nx-X11/lib/X11/ChkIfEv.c.NX.original
new file mode 100644
index 000000000..0217af830
--- /dev/null
+++ b/nx-X11/lib/X11/ChkIfEv.c.NX.original
@@ -0,0 +1,138 @@
+/* $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.
+
+*/
+/* $XFree86$ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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)(
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+ ); /* 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;
+}
+
+#ifdef NX_TRANS_SOCKET
+
+/*
+ * This is just like XCheckIfEvent() but doesn't
+ * flush the output buffer if it can't read new
+ * events.
+ */
+
+Bool XCheckIfEventNoFlush (dpy, event, predicate, arg)
+ register Display *dpy;
+ Bool (*predicate)(
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+ ); /* 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 = 2; --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 1:
+ _XEventsQueued(dpy, QueuedAfterReading);
+ break;
+ }
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+ UnlockDisplay(dpy);
+ return False;
+}
+
+#endif
diff --git a/nx-X11/lib/X11/ChkIfEv.c.X.original b/nx-X11/lib/X11/ChkIfEv.c.X.original
new file mode 100644
index 000000000..ff74bcd73
--- /dev/null
+++ b/nx-X11/lib/X11/ChkIfEv.c.X.original
@@ -0,0 +1,85 @@
+/* $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.
+
+*/
+/* $XFree86$ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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)(
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+ ); /* 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/nx-X11/lib/X11/ChkMaskEv.c b/nx-X11/lib/X11/ChkMaskEv.c
new file mode 100644
index 000000000..92b569f72
--- /dev/null
+++ b/nx-X11/lib/X11/ChkMaskEv.c
@@ -0,0 +1,89 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChkMaskEv.c,v 3.5 2001/10/28 03:32:29 tsi Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+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 = 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->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/nx-X11/lib/X11/ChkTypEv.c b/nx-X11/lib/X11/ChkTypEv.c
new file mode 100644
index 000000000..8fd879d1a
--- /dev/null
+++ b/nx-X11/lib/X11/ChkTypEv.c
@@ -0,0 +1,79 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChkTypEv.c,v 1.2 2001/10/28 03:32:29 tsi Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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 = 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->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/nx-X11/lib/X11/ChkTypWEv.c b/nx-X11/lib/X11/ChkTypWEv.c
new file mode 100644
index 000000000..83b6244df
--- /dev/null
+++ b/nx-X11/lib/X11/ChkTypWEv.c
@@ -0,0 +1,81 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChkTypWEv.c,v 1.2 2001/10/28 03:32:29 tsi Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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 = 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->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/nx-X11/lib/X11/ChkWinEv.c b/nx-X11/lib/X11/ChkWinEv.c
new file mode 100644
index 000000000..91d9b30ed
--- /dev/null
+++ b/nx-X11/lib/X11/ChkWinEv.c
@@ -0,0 +1,90 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ChkWinEv.c,v 3.5 2001/10/28 03:32:30 tsi Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+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 = 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->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/nx-X11/lib/X11/CirWin.c b/nx-X11/lib/X11/CirWin.c
new file mode 100644
index 000000000..100cbbe63
--- /dev/null
+++ b/nx-X11/lib/X11/CirWin.c
@@ -0,0 +1,50 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/CirWin.c,v 1.3 2001/01/17 19:41:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/CirWinDn.c b/nx-X11/lib/X11/CirWinDn.c
new file mode 100644
index 000000000..83a5966db
--- /dev/null
+++ b/nx-X11/lib/X11/CirWinDn.c
@@ -0,0 +1,49 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/CirWinDn.c,v 1.3 2001/01/17 19:41:33 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/CirWinUp.c b/nx-X11/lib/X11/CirWinUp.c
new file mode 100644
index 000000000..42a264171
--- /dev/null
+++ b/nx-X11/lib/X11/CirWinUp.c
@@ -0,0 +1,49 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/CirWinUp.c,v 1.3 2001/01/17 19:41:33 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/ClDisplay.c b/nx-X11/lib/X11/ClDisplay.c
new file mode 100644
index 000000000..b7a58751e
--- /dev/null
+++ b/nx-X11/lib/X11/ClDisplay.c
@@ -0,0 +1,76 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ClDisplay.c,v 1.4 2001/12/14 19:53:58 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xtrans/Xtrans.h>
+#include "Xlib.h"
+#include "Xlibint.h"
+#include "Xintconn.h"
+
+/*
+ * 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.
+ */
+
+int
+XCloseDisplay (
+ 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/nx-X11/lib/X11/Clear.c b/nx-X11/lib/X11/Clear.c
new file mode 100644
index 000000000..314d25947
--- /dev/null
+++ b/nx-X11/lib/X11/Clear.c
@@ -0,0 +1,51 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/Clear.c,v 1.3 2001/01/17 19:41:33 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/ClearArea.c b/nx-X11/lib/X11/ClearArea.c
new file mode 100644
index 000000000..194a6a2d4
--- /dev/null
+++ b/nx-X11/lib/X11/ClearArea.c
@@ -0,0 +1,56 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ClearArea.c,v 1.3 2001/01/17 19:41:33 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/Cmap.h b/nx-X11/lib/X11/Cmap.h
new file mode 100644
index 000000000..b4312be78
--- /dev/null
+++ b/nx-X11/lib/X11/Cmap.h
@@ -0,0 +1,11 @@
+/* $XFree86$ */
+
+#ifndef _CMAP_H_
+#define _CMAP_H_
+
+extern void
+_XcmsDeleteCmapRec(
+ Display *dpy,
+ Colormap cmap);
+
+#endif /* _CMAP_H_ */
diff --git a/nx-X11/lib/X11/ConfWind.c b/nx-X11/lib/X11/ConfWind.c
new file mode 100644
index 000000000..fddd28319
--- /dev/null
+++ b/nx-X11/lib/X11/ConfWind.c
@@ -0,0 +1,71 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ConfWind.c,v 1.3 2001/01/17 19:41:33 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/ConnDis.c b/nx-X11/lib/X11/ConnDis.c
new file mode 100644
index 000000000..30146a9f1
--- /dev/null
+++ b/nx-X11/lib/X11/ConnDis.c
@@ -0,0 +1,1465 @@
+/* $XdotOrg: xc/lib/X11/ConnDis.c,v 1.10 2005/07/03 07:00:55 daniels Exp $ */
+/* $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.
+
+*/
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/* $XFree86: xc/lib/X11/ConnDis.c,v 3.28 2003/12/02 23:33:17 herrb Exp $ */
+
+/*
+ * This file contains operating system dependencies.
+ */
+
+#define NEED_EVENTS
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/Xauth.h>
+#include <X11/Xdmcp.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#if !defined(WIN32)
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
+#else
+#include <X11/Xwindows.h>
+#endif
+
+#ifndef X_CONNECTION_RETRIES /* number retries on ECONNREFUSED */
+#define X_CONNECTION_RETRIES 5
+#endif
+
+#ifdef LOCALCONN
+#include <sys/utsname.h>
+#endif
+
+#include "Xintconn.h"
+
+/* prototypes */
+static void GetAuthorization(
+ XtransConnInfo trans_conn,
+ int family,
+ char *saddr,
+ int saddrlen,
+ int idisplay,
+ char **auth_namep,
+ int *auth_namelenp,
+ char **auth_datap,
+ int *auth_datalenp);
+
+/* functions */
+static char *copystring (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]
+ *
+ * A string with exactly two colons seperating hostname from the display
+ * indicates a DECnet style name. Colons in the hostname may occur if an
+ * IPv6 numeric address is used as the hostname. An IPv6 numeric address
+ * may also end in a double colon, so three colons in a row indicates an
+ * IPv6 address ending in :: followed by :display. To make it easier for
+ * people to read, an IPv6 numeric address hostname may be surrounded by
+ * [ ] in a similar fashion to the IPv6 numeric address URL syntax defined
+ * by IETF RFC 2732.
+ *
+ * If no hostname and no protocol is specified, the string is interpreted
+ * 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 (
+ 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 = 0; /* 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;
+#endif
+#ifdef TCPCONN
+ char *tcphostname = NULL; /* A place to save hostname pointer */
+#endif
+
+ p = display_name;
+
+ saddrlen = 0; /* set so that we can clear later */
+ saddr = NULL;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Called with display_name [%s].\n", display_name);
+#endif
+
+#ifdef NX_TRANS_SOCKET
+
+ /*
+ * Check if user selected the "nx"
+ * protocol or an "nx" hostname.
+ */
+
+ if (!strncasecmp(p, "nx/", 3) || !strcasecmp(p, "nx") ||
+ !strncasecmp(p, "nx:", 3) || !strncasecmp(p, "nx,", 3))
+ {
+ if (*(display_name + 2) == '/')
+ {
+ p += 3;
+ }
+
+ pprotocol = copystring ("nx", 2);
+
+ if (!pprotocol) goto bad;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_X11TransConnectDisplay: Forced protocol to [%s].\n", pprotocol);
+#endif
+
+ }
+ else
+ {
+
+#endif
+
+ /*
+ * 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 */
+#ifdef NX_TRANS_SOCKET
+
+ } /* End of step 0. */
+
+ /*
+ * Check if user specified the "nx" protocol or
+ * hostname is "nx" or in the form "nx,...".
+ */
+
+ if (pprotocol && !strcasecmp(pprotocol, "nx"))
+ {
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_X11TransConnectDisplay: Checking hostname [%s].\n", p);
+#endif
+
+ /*
+ * Options can include a "display=" tuple so
+ * need to scan right to left.
+ */
+
+ lastp = p;
+ lastc = NULL;
+
+ for (; *p; p++)
+ if (*p == ':')
+ lastc = p;
+
+ /*
+ * Don't complain if no screen was provided.
+ */
+
+ if (lastc)
+ {
+ phostname = copystring (lastp, lastc - lastp);
+
+ p = lastc;
+ }
+ else
+ {
+ phostname = copystring (lastp, strlen(lastp));
+ }
+
+ if (!phostname) goto bad;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_X11TransConnectDisplay: Forced hostname [%s].\n", phostname);
+#endif
+
+ }
+ else
+ {
+
+#endif
+
+ /*
+ * 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). (See note above regarding IPv6 numeric
+ * addresses with triple colons or [] brackets.)
+ */
+
+ lastp = p;
+ lastc = NULL;
+ for (; *p; p++)
+ if (*p == ':')
+ lastc = p;
+
+ if (!lastc) return NULL; /* must have a colon */
+
+ if ((lastp != lastc) && (*(lastc - 1) == ':')
+#if defined(IPv6) && defined(AF_INET6)
+ && ( ((lastc - 1) == lastp) || (*(lastc - 2) != ':'))
+#endif
+ ) {
+ /* 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
+
+#ifdef NX_TRANS_SOCKET
+
+ } /* End of step 1. */
+
+ /*
+ * Check if no display was specified. In this case
+ * search the "port=n" option in NX host string.
+ */
+
+ if (*p)
+ {
+
+#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);
+
+#ifdef NX_TRANS_SOCKET
+
+ }
+ else
+ {
+ char *host = NULL;
+ char *name = NULL;
+ char *value = NULL;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_X11TransConnectDisplay: Searching port in port [%s].\n", phostname);
+#endif
+
+ if (!strncasecmp(phostname, "nx,", 3))
+ {
+ host = copystring(phostname + 3, strlen(phostname) - 3);
+ }
+
+ if (!host) goto bad;
+
+ idisplay = -1;
+
+ name = strtok(host, "=");
+
+ while (name)
+ {
+ value = strtok(NULL, ",");
+
+ if (value == NULL || strstr(value, "=") != NULL ||
+ strstr(name, ",") != NULL || strlen(value) >= 128)
+ {
+ Xfree(host);
+
+ goto bad;
+ }
+ else if (strcasecmp(name, "port") == 0)
+ {
+ idisplay = atoi(value);
+
+ pdpynum = copystring(value, strlen(value));
+
+ if (!pdpynum) goto bad;
+
+ break;
+ }
+
+ name = strtok(NULL, "=");
+ }
+
+ Xfree(host);
+
+ if (idisplay == -1)
+ {
+ goto bad;
+ }
+
+ } /* End of step 2. */
+
+#endif
+
+
+ /*
+ * 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).
+ */
+
+#ifdef NX_TRANS_SOCKET
+
+ /*
+ * If user selected the "nx" protocol
+ * force "local" transport.
+ */
+
+ if (pprotocol && !strcasecmp(pprotocol, "nx"))
+ {
+ pprotocol = copystring ("local", 5);
+
+ if (!pprotocol) goto bad;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_X11TransConnectDisplay: Converted protocol to [%s].\n", pprotocol);
+#endif
+
+ }
+
+#endif
+
+#if defined(TCPCONN) || defined(UNIXCONN) || defined(LOCALCONN) || defined(MNX_TCPCONN) || defined(OS2PIPECONN)
+ if (!pprotocol) {
+ if (!phostname) {
+#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ pprotocol = copystring ("local", 5);
+#if defined(TCPCONN)
+ tcphostname = copystring("localhost", 9);
+#endif
+ }
+ else
+ {
+#endif
+ pprotocol = copystring ("tcp", 3);
+ }
+ }
+#endif
+
+#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ /*
+ * 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
+
+#if defined(TCPCONN)
+ connect:
+#endif
+ /*
+ * 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);
+ }
+ if (!address) goto bad;
+
+ sprintf(address,"%s/%s:%d",
+ pprotocol ? pprotocol : "",
+ phostname ? phostname : "",
+ idisplay );
+
+ /*
+ * 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).
+ */
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Entering connection loop.\n");
+#endif
+ for(retry=X_CONNECTION_RETRIES; retry>=0; retry-- )
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransOpenCOTSClient(address) with address [%s].\n", address);
+#endif
+ if ( (trans_conn = _X11TransOpenCOTSClient(address)) == NULL )
+ {
+ break;
+ }
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransConnect(trans_conn,address).\n");
+#endif
+ if ((connect_stat = _X11TransConnect(trans_conn,address)) < 0 )
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransClose(trans_conn).\n");
+#endif
+ _X11TransClose(trans_conn);
+ trans_conn = NULL;
+
+ if (connect_stat == TRANS_TRY_CONNECT_AGAIN)
+ {
+ sleep(1);
+ continue;
+ }
+ else
+ break;
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransGetPeerAddr(trans_conn, &family, &saddrlen, &saddr).\n");
+#endif
+ _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 defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransConvertAddress(&family, &saddrlen, &saddr).\n");
+#endif
+ if( _X11TransConvertAddress(&family, &saddrlen, &saddr) < 0 )
+ {
+ _X11TransClose(trans_conn);
+ trans_conn = NULL;
+ sleep(1);
+ if (saddr)
+ {
+ free ((char *) saddr);
+ saddr = NULL;
+ }
+ continue;
+ }
+
+ break;
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Out of connection loop.\n");
+#endif
+ if (address != addrbuf) Xfree (address);
+ address = addrbuf;
+
+ 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);
+#ifdef TCPCONN
+ if (tcphostname) Xfree (tcphostname);
+#endif
+
+ 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 (address && address != addrbuf) { Xfree(address); address = addrbuf; }
+
+#if 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 (
+ 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;
+}
+
+
+
+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;
+ static 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 = -auth_length & 3; /* pad auth_length to a multiple of 4 */
+ if (pad) add_to_iov (padbuf, pad);
+ }
+ if (auth_strlen > 0) {
+ add_to_iov (auth_string, auth_strlen);
+ pad = -auth_strlen & 3; /* pad auth_strlen to a multiple of 4 */
+ 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 NX_TRANS_SOCKET
+ if (_NXDisplayWriteFunction != NULL) {
+ (*_NXDisplayWriteFunction)(dpy, len);
+ }
+#ifdef NX_TRANS_CHANGE
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+#endif
+#endif
+
+#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
+#include <time.h>
+#define Time_t time_t
+#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 _Xconst 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 _Xconst 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;
+
+#if defined(SVR4) && defined(sun)
+ a = authdes_seccreate(servername, window, NULL, NULL);
+#else
+ a = (AUTH *)authdes_create(servername, window, NULL, NULL);
+#endif
+ 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(
+ XtransConnInfo trans_conn,
+ int family,
+ char *saddr,
+ int saddrlen,
+ int idisplay,
+ 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
+ unsigned char xdmcp_data[192/8];
+#endif
+ char *auth_name;
+ int auth_namelen;
+ unsigned 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 = (unsigned char *) 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 = (unsigned 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 */
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6:
+ /* XXX This should probably never happen */
+ {
+ unsigned char ipv4mappedprefix[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
+
+ /* In the case of v4 mapped addresses send the v4
+ part of the address - addr is already in network byte order */
+ if (memcmp(addr+8, ipv4mappedprefix, 12) == 0) {
+ for (i = 20 ; i < 24; i++)
+ xdmcp_data[j++] = ((char *)addr)[i];
+
+ /* Port number */
+ for (i=2; i<4; i++)
+ xdmcp_data[j++] = ((char *)addr)[i];
+ } else {
+ /* Fake data to keep the data aligned. Otherwise the
+ the server will bail about incorrect timing data */
+ for (i = 0; i < 6; i++) {
+ xdmcp_data[j++] = 0;
+ }
+ }
+ break;
+ }
+#endif /* AF_INET6 */
+#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;
+ unsigned long the_utime;
+ struct timeval tp;
+
+ X_GETTIMEOFDAY(&tp);
+ _XLockMutex(_Xglobal_lock);
+ the_addr = unix_addr--;
+ _XUnlockMutex(_Xglobal_lock);
+ the_utime = (unsigned long) tp.tv_usec;
+ the_port = getpid ();
+
+ xdmcp_data[j++] = (the_utime >> 24) & 0xFF;
+ xdmcp_data[j++] = (the_utime >> 16) & 0xFF;
+ xdmcp_data[j++] = ((the_utime >> 8) & 0xF0)
+ | ((the_addr >> 8) & 0x0F);
+ 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 = (unsigned char *) 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/nx-X11/lib/X11/ConnDis.c.NX.original b/nx-X11/lib/X11/ConnDis.c.NX.original
new file mode 100644
index 000000000..30146a9f1
--- /dev/null
+++ b/nx-X11/lib/X11/ConnDis.c.NX.original
@@ -0,0 +1,1465 @@
+/* $XdotOrg: xc/lib/X11/ConnDis.c,v 1.10 2005/07/03 07:00:55 daniels Exp $ */
+/* $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.
+
+*/
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/* $XFree86: xc/lib/X11/ConnDis.c,v 3.28 2003/12/02 23:33:17 herrb Exp $ */
+
+/*
+ * This file contains operating system dependencies.
+ */
+
+#define NEED_EVENTS
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/Xauth.h>
+#include <X11/Xdmcp.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#if !defined(WIN32)
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
+#else
+#include <X11/Xwindows.h>
+#endif
+
+#ifndef X_CONNECTION_RETRIES /* number retries on ECONNREFUSED */
+#define X_CONNECTION_RETRIES 5
+#endif
+
+#ifdef LOCALCONN
+#include <sys/utsname.h>
+#endif
+
+#include "Xintconn.h"
+
+/* prototypes */
+static void GetAuthorization(
+ XtransConnInfo trans_conn,
+ int family,
+ char *saddr,
+ int saddrlen,
+ int idisplay,
+ char **auth_namep,
+ int *auth_namelenp,
+ char **auth_datap,
+ int *auth_datalenp);
+
+/* functions */
+static char *copystring (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]
+ *
+ * A string with exactly two colons seperating hostname from the display
+ * indicates a DECnet style name. Colons in the hostname may occur if an
+ * IPv6 numeric address is used as the hostname. An IPv6 numeric address
+ * may also end in a double colon, so three colons in a row indicates an
+ * IPv6 address ending in :: followed by :display. To make it easier for
+ * people to read, an IPv6 numeric address hostname may be surrounded by
+ * [ ] in a similar fashion to the IPv6 numeric address URL syntax defined
+ * by IETF RFC 2732.
+ *
+ * If no hostname and no protocol is specified, the string is interpreted
+ * 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 (
+ 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 = 0; /* 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;
+#endif
+#ifdef TCPCONN
+ char *tcphostname = NULL; /* A place to save hostname pointer */
+#endif
+
+ p = display_name;
+
+ saddrlen = 0; /* set so that we can clear later */
+ saddr = NULL;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Called with display_name [%s].\n", display_name);
+#endif
+
+#ifdef NX_TRANS_SOCKET
+
+ /*
+ * Check if user selected the "nx"
+ * protocol or an "nx" hostname.
+ */
+
+ if (!strncasecmp(p, "nx/", 3) || !strcasecmp(p, "nx") ||
+ !strncasecmp(p, "nx:", 3) || !strncasecmp(p, "nx,", 3))
+ {
+ if (*(display_name + 2) == '/')
+ {
+ p += 3;
+ }
+
+ pprotocol = copystring ("nx", 2);
+
+ if (!pprotocol) goto bad;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_X11TransConnectDisplay: Forced protocol to [%s].\n", pprotocol);
+#endif
+
+ }
+ else
+ {
+
+#endif
+
+ /*
+ * 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 */
+#ifdef NX_TRANS_SOCKET
+
+ } /* End of step 0. */
+
+ /*
+ * Check if user specified the "nx" protocol or
+ * hostname is "nx" or in the form "nx,...".
+ */
+
+ if (pprotocol && !strcasecmp(pprotocol, "nx"))
+ {
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_X11TransConnectDisplay: Checking hostname [%s].\n", p);
+#endif
+
+ /*
+ * Options can include a "display=" tuple so
+ * need to scan right to left.
+ */
+
+ lastp = p;
+ lastc = NULL;
+
+ for (; *p; p++)
+ if (*p == ':')
+ lastc = p;
+
+ /*
+ * Don't complain if no screen was provided.
+ */
+
+ if (lastc)
+ {
+ phostname = copystring (lastp, lastc - lastp);
+
+ p = lastc;
+ }
+ else
+ {
+ phostname = copystring (lastp, strlen(lastp));
+ }
+
+ if (!phostname) goto bad;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_X11TransConnectDisplay: Forced hostname [%s].\n", phostname);
+#endif
+
+ }
+ else
+ {
+
+#endif
+
+ /*
+ * 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). (See note above regarding IPv6 numeric
+ * addresses with triple colons or [] brackets.)
+ */
+
+ lastp = p;
+ lastc = NULL;
+ for (; *p; p++)
+ if (*p == ':')
+ lastc = p;
+
+ if (!lastc) return NULL; /* must have a colon */
+
+ if ((lastp != lastc) && (*(lastc - 1) == ':')
+#if defined(IPv6) && defined(AF_INET6)
+ && ( ((lastc - 1) == lastp) || (*(lastc - 2) != ':'))
+#endif
+ ) {
+ /* 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
+
+#ifdef NX_TRANS_SOCKET
+
+ } /* End of step 1. */
+
+ /*
+ * Check if no display was specified. In this case
+ * search the "port=n" option in NX host string.
+ */
+
+ if (*p)
+ {
+
+#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);
+
+#ifdef NX_TRANS_SOCKET
+
+ }
+ else
+ {
+ char *host = NULL;
+ char *name = NULL;
+ char *value = NULL;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_X11TransConnectDisplay: Searching port in port [%s].\n", phostname);
+#endif
+
+ if (!strncasecmp(phostname, "nx,", 3))
+ {
+ host = copystring(phostname + 3, strlen(phostname) - 3);
+ }
+
+ if (!host) goto bad;
+
+ idisplay = -1;
+
+ name = strtok(host, "=");
+
+ while (name)
+ {
+ value = strtok(NULL, ",");
+
+ if (value == NULL || strstr(value, "=") != NULL ||
+ strstr(name, ",") != NULL || strlen(value) >= 128)
+ {
+ Xfree(host);
+
+ goto bad;
+ }
+ else if (strcasecmp(name, "port") == 0)
+ {
+ idisplay = atoi(value);
+
+ pdpynum = copystring(value, strlen(value));
+
+ if (!pdpynum) goto bad;
+
+ break;
+ }
+
+ name = strtok(NULL, "=");
+ }
+
+ Xfree(host);
+
+ if (idisplay == -1)
+ {
+ goto bad;
+ }
+
+ } /* End of step 2. */
+
+#endif
+
+
+ /*
+ * 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).
+ */
+
+#ifdef NX_TRANS_SOCKET
+
+ /*
+ * If user selected the "nx" protocol
+ * force "local" transport.
+ */
+
+ if (pprotocol && !strcasecmp(pprotocol, "nx"))
+ {
+ pprotocol = copystring ("local", 5);
+
+ if (!pprotocol) goto bad;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_X11TransConnectDisplay: Converted protocol to [%s].\n", pprotocol);
+#endif
+
+ }
+
+#endif
+
+#if defined(TCPCONN) || defined(UNIXCONN) || defined(LOCALCONN) || defined(MNX_TCPCONN) || defined(OS2PIPECONN)
+ if (!pprotocol) {
+ if (!phostname) {
+#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ pprotocol = copystring ("local", 5);
+#if defined(TCPCONN)
+ tcphostname = copystring("localhost", 9);
+#endif
+ }
+ else
+ {
+#endif
+ pprotocol = copystring ("tcp", 3);
+ }
+ }
+#endif
+
+#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ /*
+ * 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
+
+#if defined(TCPCONN)
+ connect:
+#endif
+ /*
+ * 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);
+ }
+ if (!address) goto bad;
+
+ sprintf(address,"%s/%s:%d",
+ pprotocol ? pprotocol : "",
+ phostname ? phostname : "",
+ idisplay );
+
+ /*
+ * 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).
+ */
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Entering connection loop.\n");
+#endif
+ for(retry=X_CONNECTION_RETRIES; retry>=0; retry-- )
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransOpenCOTSClient(address) with address [%s].\n", address);
+#endif
+ if ( (trans_conn = _X11TransOpenCOTSClient(address)) == NULL )
+ {
+ break;
+ }
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransConnect(trans_conn,address).\n");
+#endif
+ if ((connect_stat = _X11TransConnect(trans_conn,address)) < 0 )
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransClose(trans_conn).\n");
+#endif
+ _X11TransClose(trans_conn);
+ trans_conn = NULL;
+
+ if (connect_stat == TRANS_TRY_CONNECT_AGAIN)
+ {
+ sleep(1);
+ continue;
+ }
+ else
+ break;
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransGetPeerAddr(trans_conn, &family, &saddrlen, &saddr).\n");
+#endif
+ _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 defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransConvertAddress(&family, &saddrlen, &saddr).\n");
+#endif
+ if( _X11TransConvertAddress(&family, &saddrlen, &saddr) < 0 )
+ {
+ _X11TransClose(trans_conn);
+ trans_conn = NULL;
+ sleep(1);
+ if (saddr)
+ {
+ free ((char *) saddr);
+ saddr = NULL;
+ }
+ continue;
+ }
+
+ break;
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "_X11TransConnectDisplay: Out of connection loop.\n");
+#endif
+ if (address != addrbuf) Xfree (address);
+ address = addrbuf;
+
+ 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);
+#ifdef TCPCONN
+ if (tcphostname) Xfree (tcphostname);
+#endif
+
+ 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 (address && address != addrbuf) { Xfree(address); address = addrbuf; }
+
+#if 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 (
+ 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;
+}
+
+
+
+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;
+ static 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 = -auth_length & 3; /* pad auth_length to a multiple of 4 */
+ if (pad) add_to_iov (padbuf, pad);
+ }
+ if (auth_strlen > 0) {
+ add_to_iov (auth_string, auth_strlen);
+ pad = -auth_strlen & 3; /* pad auth_strlen to a multiple of 4 */
+ 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 NX_TRANS_SOCKET
+ if (_NXDisplayWriteFunction != NULL) {
+ (*_NXDisplayWriteFunction)(dpy, len);
+ }
+#ifdef NX_TRANS_CHANGE
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+#endif
+#endif
+
+#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
+#include <time.h>
+#define Time_t time_t
+#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 _Xconst 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 _Xconst 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;
+
+#if defined(SVR4) && defined(sun)
+ a = authdes_seccreate(servername, window, NULL, NULL);
+#else
+ a = (AUTH *)authdes_create(servername, window, NULL, NULL);
+#endif
+ 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(
+ XtransConnInfo trans_conn,
+ int family,
+ char *saddr,
+ int saddrlen,
+ int idisplay,
+ 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
+ unsigned char xdmcp_data[192/8];
+#endif
+ char *auth_name;
+ int auth_namelen;
+ unsigned 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 = (unsigned char *) 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 = (unsigned 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 */
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6:
+ /* XXX This should probably never happen */
+ {
+ unsigned char ipv4mappedprefix[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
+
+ /* In the case of v4 mapped addresses send the v4
+ part of the address - addr is already in network byte order */
+ if (memcmp(addr+8, ipv4mappedprefix, 12) == 0) {
+ for (i = 20 ; i < 24; i++)
+ xdmcp_data[j++] = ((char *)addr)[i];
+
+ /* Port number */
+ for (i=2; i<4; i++)
+ xdmcp_data[j++] = ((char *)addr)[i];
+ } else {
+ /* Fake data to keep the data aligned. Otherwise the
+ the server will bail about incorrect timing data */
+ for (i = 0; i < 6; i++) {
+ xdmcp_data[j++] = 0;
+ }
+ }
+ break;
+ }
+#endif /* AF_INET6 */
+#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;
+ unsigned long the_utime;
+ struct timeval tp;
+
+ X_GETTIMEOFDAY(&tp);
+ _XLockMutex(_Xglobal_lock);
+ the_addr = unix_addr--;
+ _XUnlockMutex(_Xglobal_lock);
+ the_utime = (unsigned long) tp.tv_usec;
+ the_port = getpid ();
+
+ xdmcp_data[j++] = (the_utime >> 24) & 0xFF;
+ xdmcp_data[j++] = (the_utime >> 16) & 0xFF;
+ xdmcp_data[j++] = ((the_utime >> 8) & 0xF0)
+ | ((the_addr >> 8) & 0x0F);
+ 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 = (unsigned char *) 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/nx-X11/lib/X11/ConnDis.c.X.original b/nx-X11/lib/X11/ConnDis.c.X.original
new file mode 100644
index 000000000..30616d207
--- /dev/null
+++ b/nx-X11/lib/X11/ConnDis.c.X.original
@@ -0,0 +1,1233 @@
+/* $XdotOrg: xc/lib/X11/ConnDis.c,v 1.10 2005/07/03 07:00:55 daniels Exp $ */
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ConnDis.c,v 3.28 2003/12/02 23:33:17 herrb Exp $ */
+
+/*
+ * This file contains operating system dependencies.
+ */
+
+#define NEED_EVENTS
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/Xauth.h>
+#include <X11/Xdmcp.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#if !defined(WIN32)
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
+#else
+#include <X11/Xwindows.h>
+#endif
+
+#ifndef X_CONNECTION_RETRIES /* number retries on ECONNREFUSED */
+#define X_CONNECTION_RETRIES 5
+#endif
+
+#ifdef LOCALCONN
+#include <sys/utsname.h>
+#endif
+
+#include "Xintconn.h"
+
+/* prototypes */
+static void GetAuthorization(
+ XtransConnInfo trans_conn,
+ int family,
+ char *saddr,
+ int saddrlen,
+ int idisplay,
+ char **auth_namep,
+ int *auth_namelenp,
+ char **auth_datap,
+ int *auth_datalenp);
+
+/* functions */
+static char *copystring (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]
+ *
+ * A string with exactly two colons seperating hostname from the display
+ * indicates a DECnet style name. Colons in the hostname may occur if an
+ * IPv6 numeric address is used as the hostname. An IPv6 numeric address
+ * may also end in a double colon, so three colons in a row indicates an
+ * IPv6 address ending in :: followed by :display. To make it easier for
+ * people to read, an IPv6 numeric address hostname may be surrounded by
+ * [ ] in a similar fashion to the IPv6 numeric address URL syntax defined
+ * by IETF RFC 2732.
+ *
+ * If no hostname and no protocol is specified, the string is interpreted
+ * 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 (
+ 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 = 0; /* 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;
+#endif
+#ifdef TCPCONN
+ char *tcphostname = NULL; /* A place to save hostname pointer */
+#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). (See note above regarding IPv6 numeric
+ * addresses with triple colons or [] brackets.)
+ */
+
+ lastp = p;
+ lastc = NULL;
+ for (; *p; p++)
+ if (*p == ':')
+ lastc = p;
+
+ if (!lastc) return NULL; /* must have a colon */
+
+ if ((lastp != lastc) && (*(lastc - 1) == ':')
+#if defined(IPv6) && defined(AF_INET6)
+ && ( ((lastc - 1) == lastp) || (*(lastc - 2) != ':'))
+#endif
+ ) {
+ /* 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) || defined(MNX_TCPCONN) || defined(OS2PIPECONN)
+ if (!pprotocol) {
+ if (!phostname) {
+#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ pprotocol = copystring ("local", 5);
+#if defined(TCPCONN)
+ tcphostname = copystring("localhost", 9);
+#endif
+ }
+ else
+ {
+#endif
+ pprotocol = copystring ("tcp", 3);
+ }
+ }
+#endif
+
+#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ /*
+ * 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
+
+#if defined(TCPCONN)
+ connect:
+#endif
+ /*
+ * 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);
+ }
+ if (!address) goto bad;
+
+ sprintf(address,"%s/%s:%d",
+ pprotocol ? pprotocol : "",
+ phostname ? phostname : "",
+ idisplay );
+
+ /*
+ * 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);
+ address = addrbuf;
+
+ 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);
+#ifdef TCPCONN
+ if (tcphostname) Xfree (tcphostname);
+#endif
+
+ 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 (address && address != addrbuf) { Xfree(address); address = addrbuf; }
+
+#if 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 (
+ 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;
+}
+
+
+
+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;
+ static 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 = -auth_length & 3; /* pad auth_length to a multiple of 4 */
+ if (pad) add_to_iov (padbuf, pad);
+ }
+ if (auth_strlen > 0) {
+ add_to_iov (auth_string, auth_strlen);
+ pad = -auth_strlen & 3; /* pad auth_strlen to a multiple of 4 */
+ 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
+#include <time.h>
+#define Time_t time_t
+#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 _Xconst 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 _Xconst 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;
+
+#if defined(SVR4) && defined(sun)
+ a = authdes_seccreate(servername, window, NULL, NULL);
+#else
+ a = (AUTH *)authdes_create(servername, window, NULL, NULL);
+#endif
+ 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(
+ XtransConnInfo trans_conn,
+ int family,
+ char *saddr,
+ int saddrlen,
+ int idisplay,
+ 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
+ unsigned char xdmcp_data[192/8];
+#endif
+ char *auth_name;
+ int auth_namelen;
+ unsigned 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 = (unsigned char *) 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 = (unsigned 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 */
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6:
+ /* XXX This should probably never happen */
+ {
+ unsigned char ipv4mappedprefix[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
+
+ /* In the case of v4 mapped addresses send the v4
+ part of the address - addr is already in network byte order */
+ if (memcmp(addr+8, ipv4mappedprefix, 12) == 0) {
+ for (i = 20 ; i < 24; i++)
+ xdmcp_data[j++] = ((char *)addr)[i];
+
+ /* Port number */
+ for (i=2; i<4; i++)
+ xdmcp_data[j++] = ((char *)addr)[i];
+ } else {
+ /* Fake data to keep the data aligned. Otherwise the
+ the server will bail about incorrect timing data */
+ for (i = 0; i < 6; i++) {
+ xdmcp_data[j++] = 0;
+ }
+ }
+ break;
+ }
+#endif /* AF_INET6 */
+#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;
+ unsigned long the_utime;
+ struct timeval tp;
+
+ X_GETTIMEOFDAY(&tp);
+ _XLockMutex(_Xglobal_lock);
+ the_addr = unix_addr--;
+ _XUnlockMutex(_Xglobal_lock);
+ the_utime = (unsigned long) tp.tv_usec;
+ the_port = getpid ();
+
+ xdmcp_data[j++] = (the_utime >> 24) & 0xFF;
+ xdmcp_data[j++] = (the_utime >> 16) & 0xFF;
+ xdmcp_data[j++] = ((the_utime >> 8) & 0xF0)
+ | ((the_addr >> 8) & 0x0F);
+ 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 = (unsigned char *) 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/nx-X11/lib/X11/Context.c b/nx-X11/lib/X11/Context.c
new file mode 100644
index 000000000..747bb6be7
--- /dev/null
+++ b/nx-X11/lib/X11/Context.c
@@ -0,0 +1,311 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/Context.c,v 1.5 2001/12/14 19:53:58 dawes Exp $ */
+
+/* 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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 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)
+{
+ 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.
+*/
+
+int XSaveContext(
+ Display *display,
+ register XID rid,
+ register XContext context,
+ _Xconst char* data)
+{
+ 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/nx-X11/lib/X11/ConvSel.c b/nx-X11/lib/X11/ConvSel.c
new file mode 100644
index 000000000..64739b240
--- /dev/null
+++ b/nx-X11/lib/X11/ConvSel.c
@@ -0,0 +1,54 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ConvSel.c,v 1.3 2001/01/17 19:41:33 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/CopyArea.c b/nx-X11/lib/X11/CopyArea.c
new file mode 100644
index 000000000..f27bfef25
--- /dev/null
+++ b/nx-X11/lib/X11/CopyArea.c
@@ -0,0 +1,64 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/CopyArea.c,v 1.3 2001/01/17 19:41:33 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/CopyCmap.c b/nx-X11/lib/X11/CopyCmap.c
new file mode 100644
index 000000000..cdfc78c9f
--- /dev/null
+++ b/nx-X11/lib/X11/CopyCmap.c
@@ -0,0 +1,66 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/CopyCmap.c,v 1.3 2001/01/17 19:41:33 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#else
+#define XCMS 1
+#endif
+#include "Xlibint.h"
+
+#if XCMS
+#include "Xcmsint.h"
+
+/* cmsCmap.c */
+extern XcmsCmapRec * _XcmsCopyCmapRecAndFree(Display *dpy,
+ Colormap src_cmap,
+ Colormap copy_cmap);
+#endif
+
+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();
+
+#if XCMS
+ _XcmsCopyCmapRecAndFree(dpy, src_cmap, mid);
+#endif
+
+ return(mid);
+}
diff --git a/nx-X11/lib/X11/CopyGC.c b/nx-X11/lib/X11/CopyGC.c
new file mode 100644
index 000000000..7ca5f388c
--- /dev/null
+++ b/nx-X11/lib/X11/CopyGC.c
@@ -0,0 +1,139 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/CopyGC.c,v 1.3 2001/01/17 19:41:33 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/CopyPlane.c b/nx-X11/lib/X11/CopyPlane.c
new file mode 100644
index 000000000..b81388887
--- /dev/null
+++ b/nx-X11/lib/X11/CopyPlane.c
@@ -0,0 +1,66 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/CopyPlane.c,v 1.3 2001/01/17 19:41:33 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/Cr.h b/nx-X11/lib/X11/Cr.h
new file mode 100644
index 000000000..101817175
--- /dev/null
+++ b/nx-X11/lib/X11/Cr.h
@@ -0,0 +1,28 @@
+/* $XFree86$ */
+
+#ifndef _CR_H_
+#define _CR_H_
+
+extern int _XUpdateGCCache(
+ register GC gc,
+ register unsigned long mask,
+ register XGCValues *attr);
+extern void _XNoticeCreateBitmap(
+ Display *dpy,
+ Pixmap pid,
+ unsigned int width,
+ unsigned int height);
+extern void _XNoticePutBitmap(
+ Display *dpy,
+ Drawable draw,
+ XImage *image);
+extern Cursor _XTryShapeBitmapCursor(
+ Display *dpy,
+ Pixmap source,
+ Pixmap mask,
+ XColor *foreground,
+ XColor *background,
+ unsigned int x,
+ unsigned int y);
+
+#endif /* _CR_H_ */
diff --git a/nx-X11/lib/X11/CrBFData.c b/nx-X11/lib/X11/CrBFData.c
new file mode 100644
index 000000000..2e665dfe7
--- /dev/null
+++ b/nx-X11/lib/X11/CrBFData.c
@@ -0,0 +1,81 @@
+/* $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.
+
+*/
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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
+ */
+Pixmap XCreateBitmapFromData(
+ Display *display,
+ Drawable d,
+ _Xconst char *data,
+ unsigned int width,
+ unsigned int height)
+{
+ 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/nx-X11/lib/X11/CrCmap.c b/nx-X11/lib/X11/CrCmap.c
new file mode 100644
index 000000000..c53faeb86
--- /dev/null
+++ b/nx-X11/lib/X11/CrCmap.c
@@ -0,0 +1,59 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/CrCmap.c,v 1.4 2001/12/14 19:53:59 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.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/nx-X11/lib/X11/CrCursor.c b/nx-X11/lib/X11/CrCursor.c
new file mode 100644
index 000000000..917349f08
--- /dev/null
+++ b/nx-X11/lib/X11/CrCursor.c
@@ -0,0 +1,78 @@
+/* $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.
+
+*/
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+#ifdef USE_DYNAMIC_XCURSOR
+Cursor
+_XTryShapeBitmapCursor (Display *dpy,
+ Pixmap source,
+ Pixmap mask,
+ XColor *foreground,
+ XColor *background,
+ unsigned int x,
+ unsigned int y);
+#endif
+
+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;
+
+#ifdef USE_DYNAMIC_XCURSOR
+ cid = _XTryShapeBitmapCursor (dpy, source, mask,
+ foreground, background, x, y);
+ if (cid)
+ return cid;
+#endif
+ 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/nx-X11/lib/X11/CrGC.c b/nx-X11/lib/X11/CrGC.c
new file mode 100644
index 000000000..2cc09e24e
--- /dev/null
+++ b/nx-X11/lib/X11/CrGC.c
@@ -0,0 +1,345 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/CrGC.c,v 3.6 2001/12/14 19:53:59 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Cr.h"
+
+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(
+ register Display *dpy,
+ GC gc,
+ xReq *req);
+
+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 (
+ register Display *dpy,
+ GC gc,
+ xReq *req)
+ {
+ 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);
+
+ }
+
+
+int
+_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/nx-X11/lib/X11/CrGlCur.c b/nx-X11/lib/X11/CrGlCur.c
new file mode 100644
index 000000000..2d34a7549
--- /dev/null
+++ b/nx-X11/lib/X11/CrGlCur.c
@@ -0,0 +1,258 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/CrGlCur.c,v 1.7 2003/04/13 19:22:15 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+#ifdef USE_DYNAMIC_XCURSOR
+
+#ifdef __UNIXOS2__
+#define RTLD_LAZY 1
+#define LIBXCURSOR "Xcursor.dll"
+#endif
+#include <stdio.h>
+#include <string.h>
+#if defined(hpux)
+#include <dl.h>
+#else
+#include <dlfcn.h>
+#endif
+#include "Cr.h"
+
+#if defined(hpux)
+typedef shl_dt XModuleType;
+#else
+typedef void *XModuleType;
+#endif
+
+#ifndef LIBXCURSOR
+#define LIBXCURSOR "libXcursor.so"
+#endif
+
+static char libraryName[] = LIBXCURSOR;
+
+static XModuleType
+open_library (void)
+{
+ char *library = libraryName;
+ char *dot;
+ XModuleType module;
+ for (;;)
+ {
+#if defined(hpux)
+ module = shl_load(library, BIND_DEFERRED, 0L);
+#else
+ module = dlopen(library, RTLD_LAZY);
+#endif
+ if (module)
+ return module;
+ dot = strrchr (library, '.');
+ if (!dot)
+ break;
+ *dot = '\0';
+ }
+ return 0;
+}
+
+static void *
+fetch_symbol (XModuleType module, char *under_symbol)
+{
+ void *result = NULL;
+ char *symbol = under_symbol + 1;
+#if defined(hpux)
+ int getsyms_cnt, i;
+ struct shl_symbol *symbols;
+
+ getsyms_cnt = shl_getsymbols(module, TYPE_PROCEDURE,
+ EXPORT_SYMBOLS, malloc, &symbols);
+
+ for(i=0; i<getsyms_cnt; i++) {
+ if(!strcmp(symbols[i].name, symbol)) {
+ result = symbols[i].value;
+ break;
+ }
+ }
+
+ if(getsyms_cnt > 0) {
+ free(symbols);
+ }
+#else
+ result = dlsym (module, symbol);
+ if (!result)
+ result = dlsym (module, under_symbol);
+#endif
+ return result;
+}
+
+typedef void (*NoticeCreateBitmapFunc) (Display *dpy,
+ Pixmap pid,
+ unsigned int width,
+ unsigned int height);
+
+typedef void (*NoticePutBitmapFunc) (Display *dpy,
+ Drawable draw,
+ XImage *image);
+
+typedef Cursor (*TryShapeBitmapCursorFunc) (Display *dpy,
+ Pixmap source,
+ Pixmap mask,
+ XColor *foreground,
+ XColor *background,
+ unsigned int x,
+ unsigned int y);
+
+typedef Cursor (*TryShapeCursorFunc) (Display *dpy,
+ Font source_font,
+ Font mask_font,
+ unsigned int source_char,
+ unsigned int mask_char,
+ XColor _Xconst *foreground,
+ XColor _Xconst *background);
+
+static XModuleType _XcursorModule;
+static Bool _XcursorModuleTried;
+
+#define GetFunc(type,name,ret) {\
+ static Bool been_here; \
+ static type staticFunc; \
+ \
+ _XLockMutex (_Xglobal_lock); \
+ if (!been_here) \
+ { \
+ been_here = True; \
+ if (!_XcursorModuleTried) \
+ { \
+ _XcursorModuleTried = True; \
+ _XcursorModule = open_library (); \
+ } \
+ if (_XcursorModule) \
+ staticFunc = (type) fetch_symbol (_XcursorModule, "_" name); \
+ } \
+ ret = staticFunc; \
+ _XUnlockMutex (_Xglobal_lock); \
+}
+
+static Cursor
+_XTryShapeCursor (Display *dpy,
+ Font source_font,
+ Font mask_font,
+ unsigned int source_char,
+ unsigned int mask_char,
+ XColor _Xconst *foreground,
+ XColor _Xconst *background)
+{
+ TryShapeCursorFunc func;
+
+ GetFunc (TryShapeCursorFunc, "XcursorTryShapeCursor", func);
+ if (func)
+ return (*func) (dpy, source_font, mask_font, source_char, mask_char,
+ foreground, background);
+ return None;
+}
+
+void
+_XNoticeCreateBitmap (Display *dpy,
+ Pixmap pid,
+ unsigned int width,
+ unsigned int height)
+{
+ NoticeCreateBitmapFunc func;
+
+ GetFunc (NoticeCreateBitmapFunc, "XcursorNoticeCreateBitmap", func);
+ if (func)
+ (*func) (dpy, pid, width, height);
+}
+
+void
+_XNoticePutBitmap (Display *dpy,
+ Drawable draw,
+ XImage *image)
+{
+ NoticePutBitmapFunc func;
+
+ GetFunc (NoticePutBitmapFunc, "XcursorNoticePutBitmap", func);
+ if (func)
+ (*func) (dpy, draw, image);
+}
+
+Cursor
+_XTryShapeBitmapCursor (Display *dpy,
+ Pixmap source,
+ Pixmap mask,
+ XColor *foreground,
+ XColor *background,
+ unsigned int x,
+ unsigned int y)
+{
+ TryShapeBitmapCursorFunc func;
+
+ GetFunc (TryShapeBitmapCursorFunc, "XcursorTryShapeBitmapCursor", func);
+ if (func)
+ return (*func) (dpy, source, mask, foreground, background, x, y);
+ return None;
+}
+#endif
+
+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 _Xconst *foreground, *background;
+
+{
+ Cursor cid;
+ register xCreateGlyphCursorReq *req;
+
+#ifdef USE_DYNAMIC_XCURSOR
+ cid = _XTryShapeCursor (dpy, source_font, mask_font,
+ source_char, mask_char, foreground, background);
+ if (cid)
+ return cid;
+#endif
+ 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/nx-X11/lib/X11/CrPFBData.c b/nx-X11/lib/X11/CrPFBData.c
new file mode 100644
index 000000000..b65e32fcb
--- /dev/null
+++ b/nx-X11/lib/X11/CrPFBData.c
@@ -0,0 +1,86 @@
+/* $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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/CrPixmap.c b/nx-X11/lib/X11/CrPixmap.c
new file mode 100644
index 000000000..72ef6960f
--- /dev/null
+++ b/nx-X11/lib/X11/CrPixmap.c
@@ -0,0 +1,65 @@
+/* $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.
+
+*/
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+#ifdef USE_DYNAMIC_XCURSOR
+void
+_XNoticeCreateBitmap (Display *dpy,
+ Pixmap pid,
+ unsigned int width,
+ unsigned int height);
+#endif
+
+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();
+#ifdef USE_DYNAMIC_XCURSOR
+ if (depth == 1)
+ _XNoticeCreateBitmap (dpy, pid, width, height);
+#endif
+ return (pid);
+}
+
diff --git a/nx-X11/lib/X11/CrWindow.c b/nx-X11/lib/X11/CrWindow.c
new file mode 100644
index 000000000..9a15f2ec1
--- /dev/null
+++ b/nx-X11/lib/X11/CrWindow.c
@@ -0,0 +1,77 @@
+/* $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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/Cursor.c b/nx-X11/lib/X11/Cursor.c
new file mode 100644
index 000000000..98ac36bbd
--- /dev/null
+++ b/nx-X11/lib/X11/Cursor.c
@@ -0,0 +1,55 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/Cursor.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+static XColor _Xconst foreground = { 0, 0, 0, 0 }; /* black */
+static XColor _Xconst 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/nx-X11/lib/X11/Cv.h b/nx-X11/lib/X11/Cv.h
new file mode 100644
index 000000000..a887e9d2b
--- /dev/null
+++ b/nx-X11/lib/X11/Cv.h
@@ -0,0 +1,190 @@
+/* $XFree86: xc/lib/X11/Cv.h,v 1.1 2003/04/13 19:22:15 dawes Exp $ */
+
+#ifndef _CV_H_
+#define _CV_H_
+
+/* variables */
+extern const char _XcmsCIEXYZ_prefix[];
+extern const char _XcmsCIEuvY_prefix[];
+extern const char _XcmsCIExyY_prefix[];
+extern const char _XcmsCIELab_prefix[];
+extern const char _XcmsCIELuv_prefix[];
+extern const char _XcmsTekHVC_prefix[];
+extern const char _XcmsRGBi_prefix[];
+extern const char _XcmsRGB_prefix[];
+
+extern XcmsColorSpace XcmsUNDEFINEDColorSpace;
+extern XcmsColorSpace XcmsTekHVCColorSpace;
+extern XcmsColorSpace XcmsCIEXYZColorSpace;
+extern XcmsColorSpace XcmsCIEuvYColorSpace;
+extern XcmsColorSpace XcmsCIExyYColorSpace;
+extern XcmsColorSpace XcmsCIELabColorSpace;
+extern XcmsColorSpace XcmsCIELuvColorSpace;
+extern XcmsColorSpace XcmsRGBColorSpace;
+extern XcmsColorSpace XcmsRGBiColorSpace;
+
+extern XcmsColorSpace *_XcmsDIColorSpacesInit[];
+extern XcmsColorSpace **_XcmsDIColorSpaces;
+
+extern XcmsColorSpace *_XcmsDDColorSpacesInit[];
+extern XcmsColorSpace **_XcmsDDColorSpaces;
+
+extern XcmsFunctionSet XcmsLinearRGBFunctionSet;
+
+extern XcmsFunctionSet *_XcmsSCCFuncSetsInit[];
+extern XcmsFunctionSet **_XcmsSCCFuncSets;
+
+extern XcmsRegColorSpaceEntry _XcmsRegColorSpaces[];
+
+/* functions */
+extern XPointer *
+_XcmsCopyPointerArray(
+ XPointer *pap);
+extern void
+_XcmsFreePointerArray(
+ XPointer *pap);
+extern XPointer *
+_XcmsPushPointerArray(
+ XPointer *pap,
+ XPointer p,
+ XPointer *papNoFree);
+extern Status
+_XcmsCIEXYZ_ValidSpec(
+ XcmsColor *pColor);
+extern Status
+_XcmsCIEuvY_ValidSpec(
+ XcmsColor *pColor);
+extern int
+_XcmsTekHVC_CheckModify(
+ XcmsColor *pColor);
+
+extern Status
+_XcmsTekHVCQueryMaxVCRGB(
+ XcmsCCC ccc,
+ XcmsFloat hue,
+ XcmsColor *pColor_return,
+ XcmsRGBi *pRGB_return);
+extern Status
+_XcmsCIELabQueryMaxLCRGB(
+ XcmsCCC ccc,
+ XcmsFloat hue, /* hue in radians */
+ XcmsColor *pColor_return,
+ XcmsRGBi *pRGB_return);
+extern Status
+_XcmsConvertColorsWithWhitePt(
+ XcmsCCC ccc,
+ XcmsColor *pColors_in_out,
+ XcmsColor *pWhitePt,
+ unsigned int nColors,
+ XcmsColorFormat newFormat,
+ Bool *pCompressed);
+
+extern Status
+_XcmsDIConvertColors(
+ XcmsCCC ccc,
+ XcmsColor *pColors_in_out,
+ XcmsColor *pWhitePt,
+ unsigned int nColors,
+ XcmsColorFormat newFormat);
+extern Status
+_XcmsDDConvertColors(
+ XcmsCCC ccc,
+ XcmsColor *pColors_in_out,
+ unsigned int nColors,
+ XcmsColorFormat newFormat,
+ Bool *pCompressed);
+extern XcmsColorFormat
+_XcmsRegFormatOfPrefix(
+ _Xconst char *prefix);
+extern void
+_XColor_to_XcmsRGB(
+ XcmsCCC ccc,
+ XColor *pXColors,
+ XcmsColor *pColors,
+ unsigned int nColors);
+extern Status
+_XcmsSetGetColor(
+ Status (*xColorProc)(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* screen_in_out */),
+ Display *dpy,
+ Colormap cmap,
+ XcmsColor *pColors_in_out,
+ XcmsColorFormat result_format,
+ Bool *pCompressed);
+extern Status
+_XcmsSetGetColors(
+ Status (*xColorProc)(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* screen_in_out */,
+ int /* nColors */),
+ Display *dpy,
+ Colormap cmap,
+ XcmsColor *pColors_in_out,
+ int nColors,
+ XcmsColorFormat result_format,
+ Bool *pCompressed);
+extern Status
+_XcmsCIELuvQueryMaxLCRGB(
+ XcmsCCC ccc,
+ XcmsFloat hue, /* hue in radians */
+ XcmsColor *pColor_return,
+ XcmsRGBi *pRGB_return);
+
+extern XcmsIntensityMap *
+_XcmsGetIntensityMap(
+ Display *dpy,
+ Visual *visual);
+extern int
+_XcmsInitDefaultCCCs(
+ Display *dpy);
+extern int
+_XcmsInitScrnInfo(
+ register Display *dpy,
+ int screenNumber);
+extern XcmsCmapRec *
+_XcmsCopyCmapRecAndFree(
+ Display *dpy,
+ Colormap src_cmap,
+ Colormap copy_cmap);
+extern void
+_XcmsCopyISOLatin1Lowered(
+ char *dst,
+ const char *src);
+extern int
+_XcmsEqualWhitePts(
+ XcmsCCC ccc, XcmsColor *pWhitePt1, XcmsColor *pWhitePt2);
+extern int
+_XcmsLRGB_InitScrnDefault(
+ Display *dpy,
+ int screenNumber,
+ XcmsPerScrnInfo *pPerScrnInfo);
+extern void
+_XcmsFreeIntensityMaps(
+ Display *dpy);
+extern int
+_XcmsGetProperty(
+ Display *pDpy,
+ Window w,
+ Atom property,
+ int *pFormat,
+ unsigned long *pNItems,
+ unsigned long *pNBytes,
+ char **pValue);
+extern unsigned long
+_XcmsGetElement(
+ int format,
+ char **pValue,
+ unsigned long *pCount);
+extern void
+_XcmsUnresolveColor(
+ XcmsCCC ccc,
+ XcmsColor *pColor);
+extern void
+_XcmsResolveColor(
+ XcmsCCC ccc,
+ XcmsColor *pXcmsColor);
+
+#endif /* _CV_H_ */
diff --git a/nx-X11/lib/X11/CvColW.c b/nx-X11/lib/X11/CvColW.c
new file mode 100644
index 000000000..d57a7666f
--- /dev/null
+++ b/nx-X11/lib/X11/CvColW.c
@@ -0,0 +1,143 @@
+/* $Xorg: CvColW.c,v 1.3 2000/08/17 19:44:32 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * XcmsCvColW.c
+ *
+ * DESCRIPTION
+ * <overall description of what the package does>
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/CvColW.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+
+/*
+ * NAME
+ * _XcmsConvertColorsWithWhitePt - Convert XcmsColor structures
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsConvertColorsWithWhitePt(
+ XcmsCCC ccc,
+ XcmsColor *pColors_in_out,
+ XcmsColor *pWhitePt,
+ unsigned int nColors,
+ XcmsColorFormat newFormat,
+ Bool *pCompressed)
+/*
+ * DESCRIPTION
+ * Convert XcmsColor structures between device-independent
+ * and/or device-dependent formats but allowing the calling
+ * routine to specify the white point to be associated
+ * with the color specifications (overriding
+ * ccc->clientWhitePt).
+ *
+ * This routine has been provided for use in white point
+ * adjustment routines.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression,
+ * XcmsSuccessWithCompression if succeeded with gamut
+ * compression.
+ *
+ */
+{
+ if (ccc == NULL || pColors_in_out == NULL ||
+ pColors_in_out->format == XcmsUndefinedFormat) {
+ return(XcmsFailure);
+ }
+
+ if (nColors == 0 || pColors_in_out->format == newFormat) {
+ /* do nothing */
+ return(XcmsSuccess);
+ }
+
+ if (XCMS_DI_ID(pColors_in_out->format) && XCMS_DI_ID(newFormat)) {
+ /*
+ * Device-Independent to Device-Independent Conversion
+ */
+ return(_XcmsDIConvertColors(ccc, pColors_in_out, pWhitePt, nColors,
+ newFormat));
+ }
+ if (XCMS_DD_ID(pColors_in_out->format) && XCMS_DD_ID(newFormat)) {
+ /*
+ * Device-Dependent to Device-Dependent Conversion
+ */
+ return(_XcmsDDConvertColors(ccc, pColors_in_out, nColors, newFormat,
+ pCompressed));
+ }
+
+ /*
+ * Otherwise we have:
+ * 1. Device-Independent to Device-Dependent Conversion
+ * OR
+ * 2. Device-Dependent to Device-Independent Conversion
+ */
+
+ if (XCMS_DI_ID(pColors_in_out->format)) {
+ /*
+ * 1. Device-Independent to Device-Dependent Conversion
+ */
+ /* First convert to CIEXYZ */
+ if (_XcmsDIConvertColors(ccc, pColors_in_out, pWhitePt, nColors,
+ XcmsCIEXYZFormat) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ /* Then convert to DD Format */
+ return(_XcmsDDConvertColors(ccc, pColors_in_out, nColors, newFormat,
+ pCompressed));
+ } else {
+ /*
+ * 2. Device-Dependent to Device-Independent Conversion
+ */
+ /* First convert to CIEXYZ */
+ if (_XcmsDDConvertColors(ccc, pColors_in_out, nColors,
+ XcmsCIEXYZFormat, pCompressed) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ /* Then convert to DI Format */
+ return(_XcmsDIConvertColors(ccc, pColors_in_out, pWhitePt, nColors,
+ newFormat));
+ }
+}
diff --git a/nx-X11/lib/X11/CvCols.c b/nx-X11/lib/X11/CvCols.c
new file mode 100644
index 000000000..fc343cda8
--- /dev/null
+++ b/nx-X11/lib/X11/CvCols.c
@@ -0,0 +1,1032 @@
+/* $Xorg: CvCols.c,v 1.3 2000/08/17 19:44:32 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsCvCols.c
+ *
+ * DESCRIPTION
+ * Xcms API routine that converts between the
+ * device-independent color spaces.
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/CvCols.c,v 1.4 2003/04/13 19:22:15 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+/*
+ * LOCAL DEFINES
+ */
+#define DD_FORMAT 0x01
+#define DI_FORMAT 0x02
+#define MIX_FORMAT 0x04
+#ifndef MAX
+# define MAX(x,y) ((x) > (y) ? (x) : (y))
+#endif
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * EqualCIEXYZ
+ *
+ * SYNOPSIS
+ */
+static int
+EqualCIEXYZ(
+ XcmsColor *p1, XcmsColor *p2)
+/*
+ * DESCRIPTION
+ * Compares two XcmsColor structures that are in XcmsCIEXYZFormat
+ *
+ * RETURNS
+ * Returns 1 if equal; 0 otherwise.
+ *
+ */
+{
+ if (p1->format != XcmsCIEXYZFormat || p2->format != XcmsCIEXYZFormat) {
+ return(0);
+ }
+ if ((p1->spec.CIEXYZ.X != p2->spec.CIEXYZ.X)
+ || (p1->spec.CIEXYZ.Y != p2->spec.CIEXYZ.Y)
+ || (p1->spec.CIEXYZ.Z != p2->spec.CIEXYZ.Z)) {
+ return(0);
+ }
+ return(1);
+}
+
+
+/*
+ * NAME
+ * XcmsColorSpace
+ *
+ * SYNOPSIS
+ */
+static XcmsColorSpace *
+ColorSpaceOfID(
+ XcmsCCC ccc,
+ XcmsColorFormat id)
+/*
+ * DESCRIPTION
+ * Returns a pointer to the color space structure
+ * (XcmsColorSpace) associated with the specified color space
+ * ID.
+ *
+ * RETURNS
+ * Pointer to matching XcmsColorSpace structure if found;
+ * otherwise NULL.
+ */
+{
+ XcmsColorSpace **papColorSpaces;
+
+ if (ccc == NULL) {
+ return(NULL);
+ }
+
+ /*
+ * First try Device-Independent color spaces
+ */
+ papColorSpaces = _XcmsDIColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if ((*papColorSpaces)->id == id) {
+ return(*papColorSpaces);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ /*
+ * Next try Device-Dependent color spaces
+ */
+ papColorSpaces = ((XcmsFunctionSet *)ccc->pPerScrnInfo->functionSet)->DDColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if ((*papColorSpaces)->id == id) {
+ return(*papColorSpaces);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ return(NULL);
+}
+
+
+/*
+ * NAME
+ * ValidDIColorSpaceID
+ *
+ * SYNOPSIS
+ */
+static int
+ValidDIColorSpaceID(
+ XcmsColorFormat id)
+/*
+ * DESCRIPTION
+ * Determines if the specified color space ID is a valid
+ * Device-Independent color space in the specified Color
+ * Conversion Context.
+ *
+ * RETURNS
+ * Returns zero if not valid; otherwise non-zero.
+ */
+{
+ XcmsColorSpace **papRec;
+ papRec = _XcmsDIColorSpaces;
+ if (papRec != NULL) {
+ while (*papRec != NULL) {
+ if ((*papRec)->id == id) {
+ return(1);
+ }
+ papRec++;
+ }
+ }
+ return(0);
+}
+
+
+/*
+ * NAME
+ * ValidDDColorSpaceID
+ *
+ * SYNOPSIS
+ */
+static int
+ValidDDColorSpaceID(
+ XcmsCCC ccc,
+ XcmsColorFormat id)
+/*
+ * DESCRIPTION
+ * Determines if the specified color space ID is a valid
+ * Device-Dependent color space in the specified Color
+ * Conversion Context.
+ *
+ * RETURNS
+ * Returns zero if not valid; otherwise non-zero.
+ */
+{
+ XcmsColorSpace **papRec;
+
+ if (ccc->pPerScrnInfo->state != XcmsInitNone) {
+ papRec = ((XcmsFunctionSet *)ccc->pPerScrnInfo->functionSet)->DDColorSpaces;
+ while (*papRec != NULL) {
+ if ((*papRec)->id == id) {
+ return(1);
+ }
+ papRec++;
+ }
+ }
+ return(0);
+}
+
+
+/*
+ * NAME
+ * ConvertMixedColors - Convert XcmsColor structures
+ *
+ * SYNOPSIS
+ */
+static Status
+ConvertMixedColors(
+ XcmsCCC ccc,
+ XcmsColor *pColors_in_out,
+ XcmsColor *pWhitePt,
+ unsigned int nColors,
+ XcmsColorFormat targetFormat,
+ unsigned char format_flag)
+/*
+ * DESCRIPTION
+ * This routine will only convert the following types of
+ * batches:
+ * DI to DI
+ * DD to DD
+ * DD to CIEXYZ
+ * In other words, it will not convert the following types of
+ * batches:
+ * DI to DD
+ * DD to DI(not CIEXYZ)
+ *
+ * format_flag:
+ * 0x01 : convert Device-Dependent only specifications to the
+ * target format.
+ * 0x02 : convert Device-Independent only specifications to the
+ * target format.
+ * 0x03 : convert all specifications to the target format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if none of the color specifications were
+ * compressed in the conversion process
+ * XcmsSuccessWithCompression if at least one of the
+ * color specifications were compressed in the
+ * conversion process.
+ *
+ */
+{
+ XcmsColor *pColor, *pColors_start;
+ XcmsColorFormat format;
+ Status retval_tmp;
+ Status retval = XcmsSuccess;
+ unsigned int iColors;
+ unsigned int nBatch;
+
+ /*
+ * Convert array of mixed color specifications in batches of
+ * contiguous formats to the target format
+ */
+ iColors = 0;
+ while (iColors < nColors) {
+ /*
+ * Find contiguous array of color specifications with the
+ * same format
+ */
+ pColor = pColors_start = pColors_in_out + iColors;
+ format = pColors_start->format;
+ nBatch = 0;
+ while (iColors < nColors && pColor->format == format) {
+ pColor++;
+ nBatch++;
+ iColors++;
+ }
+ if (format != targetFormat) {
+ /*
+ * Need to convert this batch from current format to target format.
+ */
+ if (XCMS_DI_ID(format) && (format_flag & DI_FORMAT) &&
+ XCMS_DI_ID(targetFormat)) {
+ /*
+ * DI->DI
+ *
+ * Format of interest is Device-Independent,
+ * This batch contains Device-Independent specifications, and
+ * the Target format is Device-Independent.
+ */
+ retval_tmp = _XcmsDIConvertColors(ccc, pColors_start, pWhitePt,
+ nBatch, targetFormat);
+ } else if (XCMS_DD_ID(format) && (format_flag & DD_FORMAT) &&
+ (targetFormat == XcmsCIEXYZFormat)) {
+ /*
+ * DD->CIEXYZ
+ *
+ * Format of interest is Device-Dependent,
+ * This batch contains Device-Dependent specifications, and
+ * the Target format is CIEXYZ.
+ *
+ * Since DD->CIEXYZ we can use NULL instead of pCompressed.
+ */
+ if ((ccc->whitePtAdjProc != NULL) && !_XcmsEqualWhitePts(ccc,
+ pWhitePt, ScreenWhitePointOfCCC(ccc))) {
+ /*
+ * Need to call WhiteAdjustProc (Screen White Point to
+ * White Point).
+ */
+ retval_tmp = (*ccc->whitePtAdjProc)(ccc,
+ ScreenWhitePointOfCCC(ccc), pWhitePt,
+ XcmsCIEXYZFormat, pColors_start, nBatch,
+ (Bool *)NULL);
+ } else {
+ retval_tmp = _XcmsDDConvertColors(ccc, pColors_start,
+ nBatch, XcmsCIEXYZFormat, (Bool *)NULL);
+ }
+ } else if (XCMS_DD_ID(format) && (format_flag & DD_FORMAT) &&
+ XCMS_DD_ID(targetFormat)) {
+ /*
+ * DD->DD(not CIEXYZ)
+ *
+ * Format of interest is Device-Dependent,
+ * This batch contains Device-Dependent specifications, and
+ * the Target format is Device-Dependent and not CIEXYZ.
+ */
+ retval_tmp = _XcmsDDConvertColors(ccc, pColors_start, nBatch,
+ targetFormat, (Bool *)NULL);
+ } else {
+ /*
+ * This routine is called for the wrong reason.
+ */
+ return(XcmsFailure);
+ }
+ if (retval_tmp == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ retval = MAX(retval, retval_tmp);
+ }
+ }
+ return(retval);
+}
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsEqualWhitePts
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsEqualWhitePts(XcmsCCC ccc, XcmsColor *pWhitePt1, XcmsColor *pWhitePt2)
+/*
+ * DESCRIPTION
+ *
+ * RETURNS
+ * Returns 0 if not equal; otherwise 1.
+ *
+ */
+{
+ XcmsColor tmp1, tmp2;
+
+ memcpy((char *)&tmp1, (char *)pWhitePt1, sizeof(XcmsColor));
+ memcpy((char *)&tmp2, (char *)pWhitePt2, sizeof(XcmsColor));
+
+ if (tmp1.format != XcmsCIEXYZFormat) {
+ if (_XcmsDIConvertColors(ccc, &tmp1, (XcmsColor *) NULL, 1,
+ XcmsCIEXYZFormat)==0) {
+ return(0);
+ }
+ }
+
+ if (tmp2.format != XcmsCIEXYZFormat) {
+ if (_XcmsDIConvertColors(ccc, &tmp2, (XcmsColor *) NULL, 1,
+ XcmsCIEXYZFormat)==0) {
+ return(0);
+ }
+ }
+
+ return (EqualCIEXYZ(&tmp1, &tmp2));
+}
+
+
+/*
+ * NAME
+ * _XcmsDIConvertColors - Convert XcmsColor structures
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsDIConvertColors(
+ XcmsCCC ccc,
+ XcmsColor *pColors_in_out,
+ XcmsColor *pWhitePt,
+ unsigned int nColors,
+ XcmsColorFormat newFormat)
+/*
+ * DESCRIPTION
+ * Convert XcmsColor structures to another Device-Independent
+ * form.
+ *
+ * Here are some assumptions that this routine makes:
+ * 1. The calling routine has already checked if
+ * pColors_in_out->format == newFormat, therefore
+ * there is no need to check again here.
+ * 2. The calling routine has already checked nColors,
+ * therefore this routine assumes nColors > 0.
+ * 3. The calling routine may want to convert only between
+ * CIExyY <-> CIEXYZ <-> CIEuvY
+ * therefore, this routine allows pWhitePt to equal NULL.
+ *
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsColorSpace *pFrom, *pTo;
+ XcmsDIConversionProc *src_to_CIEXYZ, *src_from_CIEXYZ;
+ XcmsDIConversionProc *dest_to_CIEXYZ, *dest_from_CIEXYZ;
+ XcmsDIConversionProc *to_CIEXYZ_stop, *from_CIEXYZ_start;
+ XcmsDIConversionProc *tmp;
+
+ /*
+ * Allow pWhitePt to equal NULL. This appropriate when converting
+ * anywhere between:
+ * CIExyY <-> CIEXYZ <-> CIEuvY
+ */
+
+ if (pColors_in_out == NULL ||
+ !ValidDIColorSpaceID(pColors_in_out->format) ||
+ !ValidDIColorSpaceID(newFormat)) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Get a handle on the function list for the current specification format
+ */
+ if ((pFrom = ColorSpaceOfID(ccc, pColors_in_out->format))
+ == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Get a handle on the function list for the new specification format
+ */
+ if ((pTo = ColorSpaceOfID(ccc, newFormat)) == NULL) {
+ return(XcmsFailure);
+ }
+
+ src_to_CIEXYZ = pFrom->to_CIEXYZ;
+ src_from_CIEXYZ = pFrom->from_CIEXYZ;
+ dest_to_CIEXYZ = pTo->to_CIEXYZ;
+ dest_from_CIEXYZ = pTo->from_CIEXYZ;
+
+ if (pTo->inverse_flag && pFrom->inverse_flag) {
+ /*
+ * Find common function pointers
+ */
+ for (to_CIEXYZ_stop = src_to_CIEXYZ; *to_CIEXYZ_stop; to_CIEXYZ_stop++){
+ for (tmp = dest_to_CIEXYZ; *tmp; tmp++) {
+ if (*to_CIEXYZ_stop == *tmp) {
+ goto Continue;
+ }
+ }
+ }
+
+Continue:
+
+ /*
+ * Execute the functions to CIEXYZ, stopping short as necessary
+ */
+ while (src_to_CIEXYZ != to_CIEXYZ_stop) {
+ if ((*src_to_CIEXYZ++)(ccc, pWhitePt, pColors_in_out,
+ nColors) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ /*
+ * Determine where to start on the from_CIEXYZ path.
+ */
+ from_CIEXYZ_start = dest_from_CIEXYZ;
+ tmp = src_from_CIEXYZ;
+ while ((*from_CIEXYZ_start == *tmp) && (*from_CIEXYZ_start != NULL)) {
+ from_CIEXYZ_start++;
+ tmp++;
+ }
+
+ } else {
+ /*
+ * The function in at least one of the Color Spaces are not
+ * complementary, i.e.,
+ * for an i, 0 <= i < n elements
+ * from_CIEXYZ[i] is not the inverse of to_CIEXYZ[i]
+ *
+ * Execute the functions all the way to CIEXYZ
+ */
+ while (*src_to_CIEXYZ) {
+ if ((*src_to_CIEXYZ++)(ccc, pWhitePt, pColors_in_out,
+ nColors) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ /*
+ * Determine where to start on the from_CIEXYZ path.
+ */
+ from_CIEXYZ_start = dest_from_CIEXYZ;
+ }
+
+
+ /*
+ * Execute the functions from CIEXYZ.
+ */
+ while (*from_CIEXYZ_start) {
+ if ((*from_CIEXYZ_start++)(ccc, pWhitePt, pColors_in_out,
+ nColors) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * _XcmsDDConvertColors - Convert XcmsColor structures
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsDDConvertColors(
+ XcmsCCC ccc,
+ XcmsColor *pColors_in_out,
+ unsigned int nColors,
+ XcmsColorFormat newFormat,
+ Bool *pCompressed)
+/*
+ * DESCRIPTION
+ * Convert XcmsColor structures:
+ *
+ * 1. From CIEXYZ to Device-Dependent formats (typically RGB and
+ * RGBi),
+ * or
+ * 2. Between Device-Dependent formats (typically RGB and RGBi).
+ *
+ * Assumes that these specifications have already been white point
+ * adjusted if necessary from Client White Point to Screen
+ * White Point. Therefore, the white point now associated
+ * with the specifications is the Screen White Point.
+ *
+ * pCompressed may be NULL. If so this indicates that the
+ * calling routine is not interested in knowing exactly which
+ * color was compressed, if any.
+ *
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if none of the color specifications were
+ * compressed in the conversion process
+ * XcmsSuccessWithCompression if at least one of the
+ * color specifications were compressed in the
+ * conversion process.
+ *
+ */
+{
+ XcmsColorSpace *pFrom, *pTo;
+ XcmsDDConversionProc *src_to_CIEXYZ, *src_from_CIEXYZ;
+ XcmsDDConversionProc *dest_to_CIEXYZ, *dest_from_CIEXYZ;
+ XcmsDDConversionProc *from_CIEXYZ_start, *to_CIEXYZ_stop;
+ XcmsDDConversionProc *tmp;
+ int retval;
+ int hasCompressed = 0;
+
+ if (ccc == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ if (nColors == 0 || pColors_in_out->format == newFormat) {
+ /* do nothing */
+ return(XcmsSuccess);
+ }
+
+ if (((XcmsFunctionSet *)ccc->pPerScrnInfo->functionSet) == NULL) {
+ return(XcmsFailure); /* hmm, an internal error? */
+ }
+
+ /*
+ * Its ok if pColors_in_out->format == XcmsCIEXYZFormat
+ * or
+ * if newFormat == XcmsCIEXYZFormat
+ */
+ if ( !( ValidDDColorSpaceID(ccc, pColors_in_out->format)
+ ||
+ (pColors_in_out->format == XcmsCIEXYZFormat))
+ ||
+ !(ValidDDColorSpaceID(ccc, newFormat)
+ ||
+ newFormat == XcmsCIEXYZFormat)) {
+ return(XcmsFailure);
+ }
+
+ if ((pFrom = ColorSpaceOfID(ccc, pColors_in_out->format)) == NULL){
+ return(XcmsFailure);
+ }
+
+ if ((pTo = ColorSpaceOfID(ccc, newFormat)) == NULL) {
+ return(XcmsFailure);
+ }
+
+ src_to_CIEXYZ = (XcmsDDConversionProc *)pFrom->to_CIEXYZ;
+ src_from_CIEXYZ = (XcmsDDConversionProc *)pFrom->from_CIEXYZ;
+ dest_to_CIEXYZ = (XcmsDDConversionProc *)pTo->to_CIEXYZ;
+ dest_from_CIEXYZ = (XcmsDDConversionProc *)pTo->from_CIEXYZ;
+
+ if (pTo->inverse_flag && pFrom->inverse_flag) {
+ /*
+ * Find common function pointers
+ */
+ for (to_CIEXYZ_stop = src_to_CIEXYZ; *to_CIEXYZ_stop; to_CIEXYZ_stop++){
+ for (tmp = dest_to_CIEXYZ; *tmp; tmp++) {
+ if (*to_CIEXYZ_stop == *tmp) {
+ goto Continue;
+ }
+ }
+ }
+Continue:
+
+ /*
+ * Execute the functions
+ */
+ while (src_to_CIEXYZ != to_CIEXYZ_stop) {
+ retval = (*src_to_CIEXYZ++)(ccc, pColors_in_out, nColors,
+ pCompressed);
+ if (retval == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ hasCompressed |= (retval == XcmsSuccessWithCompression);
+ }
+
+ /*
+ * Determine where to start on the from_CIEXYZ path.
+ */
+ from_CIEXYZ_start = dest_from_CIEXYZ;
+ tmp = src_from_CIEXYZ;
+ while ((*from_CIEXYZ_start == *tmp) && (*from_CIEXYZ_start != NULL)) {
+ from_CIEXYZ_start++;
+ tmp++;
+ }
+
+ } else {
+ /*
+ * The function in at least one of the Color Spaces are not
+ * complementary, i.e.,
+ * for an i, 0 <= i < n elements
+ * from_CIEXYZ[i] is not the inverse of to_CIEXYZ[i]
+ *
+ * Execute the functions all the way to CIEXYZ
+ */
+ while (*src_to_CIEXYZ) {
+ retval = (*src_to_CIEXYZ++)(ccc, pColors_in_out, nColors,
+ pCompressed);
+ if (retval == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ hasCompressed |= (retval == XcmsSuccessWithCompression);
+ }
+
+ /*
+ * Determine where to start on the from_CIEXYZ path.
+ */
+ from_CIEXYZ_start = dest_from_CIEXYZ;
+ }
+
+ while (*from_CIEXYZ_start) {
+ retval = (*from_CIEXYZ_start++)(ccc, pColors_in_out, nColors,
+ pCompressed);
+ if (retval == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ hasCompressed |= (retval == XcmsSuccessWithCompression);
+ }
+
+ return(hasCompressed ? XcmsSuccessWithCompression : XcmsSuccess);
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsConvertColors - Convert XcmsColor structures
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsConvertColors(ccc, pColors_in_out, nColors, targetFormat, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ XcmsColorFormat targetFormat;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Convert XcmsColor structures to another format
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression,
+ * XcmsSuccessWithCompression if succeeded with gamut
+ * compression.
+ *
+ */
+{
+ XcmsColor clientWhitePt;
+ XcmsColor Color1;
+ XcmsColor *pColors_tmp;
+ int callWhiteAdjustProc = 0;
+ XcmsColorFormat format;
+ Status retval;
+ unsigned char contents_flag = 0x00;
+ unsigned int iColors;
+
+ if (ccc == NULL || pColors_in_out == NULL ||
+ !(ValidDIColorSpaceID(targetFormat) ||
+ ValidDDColorSpaceID(ccc, targetFormat))) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Check formats in color specification array
+ */
+ format = pColors_in_out->format;
+ for (pColors_tmp = pColors_in_out, iColors = nColors; iColors; pColors_tmp++, iColors--) {
+ if (!(ValidDIColorSpaceID(pColors_tmp->format) ||
+ ValidDDColorSpaceID(ccc, pColors_tmp->format))) {
+ return(XcmsFailure);
+ }
+ if (XCMS_DI_ID(pColors_tmp->format)) {
+ contents_flag |= DI_FORMAT;
+ } else {
+ contents_flag |= DD_FORMAT;
+ }
+ if (pColors_tmp->format != format) {
+ contents_flag |= MIX_FORMAT;
+ }
+ }
+
+ /*
+ * Check if we need the Client White Point.
+ */
+ if ((contents_flag & DI_FORMAT) || XCMS_DI_ID(targetFormat)) {
+ /* To proceed, we need to get the Client White Point */
+ memcpy((char *)&clientWhitePt, (char *)&ccc->clientWhitePt,
+ sizeof(XcmsColor));
+ if (clientWhitePt.format == XcmsUndefinedFormat) {
+ /*
+ * Client White Point is undefined, therefore set to the Screen
+ * White Point.
+ * Since Client White Point == Screen White Point, WhiteAdjustProc
+ * is not called.
+ */
+ memcpy((char *)&clientWhitePt,
+ (char *)&ccc->pPerScrnInfo->screenWhitePt,
+ sizeof(XcmsColor));
+ } else if ((ccc->whitePtAdjProc != NULL) && !_XcmsEqualWhitePts(ccc,
+ &clientWhitePt, ScreenWhitePointOfCCC(ccc))) {
+ /*
+ * Client White Point != Screen White Point, and WhiteAdjustProc
+ * is not NULL, therefore, will need to call it when
+ * converting between DI and DD specifications.
+ */
+ callWhiteAdjustProc = 1;
+ }
+ }
+
+ /*
+ * Make copy of array of color specifications
+ */
+ if (nColors > 1) {
+ pColors_tmp = (XcmsColor *) Xmalloc(nColors * sizeof(XcmsColor));
+ } else {
+ pColors_tmp = &Color1;
+ }
+ memcpy((char *)pColors_tmp, (char *)pColors_in_out,
+ nColors * sizeof(XcmsColor));
+
+ /*
+ * zero out pCompressed
+ */
+ if (pCompressed) {
+ bzero((char *)pCompressed, nColors * sizeof(Bool));
+ }
+
+ if (contents_flag == DD_FORMAT || contents_flag == DI_FORMAT) {
+ /*
+ * ENTIRE ARRAY IS IN ONE FORMAT.
+ */
+ if (XCMS_DI_ID(format) && XCMS_DI_ID(targetFormat)) {
+ /*
+ * DI-to-DI only conversion
+ */
+ retval = _XcmsDIConvertColors(ccc, pColors_tmp,
+ &clientWhitePt, nColors, targetFormat);
+ } else if (XCMS_DD_ID(format) && XCMS_DD_ID(targetFormat)) {
+ /*
+ * DD-to-DD only conversion
+ * Since DD->DD there will be no compressed thus we can
+ * pass NULL instead of pCompressed.
+ */
+ retval = _XcmsDDConvertColors(ccc, pColors_tmp, nColors,
+ targetFormat, (Bool *)NULL);
+ } else {
+ /*
+ * Otherwise we have:
+ * 1. Device-Independent to Device-Dependent Conversion
+ * OR
+ * 2. Device-Dependent to Device-Independent Conversion
+ *
+ * We need to go from oldFormat -> CIEXYZ -> targetFormat
+ * adjusting for white points as necessary.
+ */
+
+ if (XCMS_DI_ID(format)) {
+ /*
+ * 1. Device-Independent to Device-Dependent Conversion
+ */
+ if (callWhiteAdjustProc) {
+ /*
+ * White Point Adjustment
+ * Client White Point to Screen White Point
+ */
+ retval = (*ccc->whitePtAdjProc)(ccc, &clientWhitePt,
+ ScreenWhitePointOfCCC(ccc), targetFormat,
+ pColors_tmp, nColors, pCompressed);
+ } else {
+ if (_XcmsDIConvertColors(ccc, pColors_tmp,
+ &clientWhitePt, nColors, XcmsCIEXYZFormat)
+ == XcmsFailure) {
+ goto Failure;
+ }
+ retval = _XcmsDDConvertColors(ccc, pColors_tmp, nColors,
+ targetFormat, pCompressed);
+ }
+ } else {
+ /*
+ * 2. Device-Dependent to Device-Independent Conversion
+ */
+ if (callWhiteAdjustProc) {
+ /*
+ * White Point Adjustment
+ * Screen White Point to Client White Point
+ */
+ retval = (*ccc->whitePtAdjProc)(ccc,
+ ScreenWhitePointOfCCC(ccc), &clientWhitePt,
+ targetFormat, pColors_tmp, nColors, pCompressed);
+ } else {
+ /*
+ * Since DD->CIEXYZ, no compression takes place therefore
+ * we can pass NULL instead of pCompressed.
+ */
+ if (_XcmsDDConvertColors(ccc, pColors_tmp, nColors,
+ XcmsCIEXYZFormat, (Bool *)NULL) == XcmsFailure) {
+ goto Failure;
+ }
+ retval = _XcmsDIConvertColors(ccc, pColors_tmp,
+ &clientWhitePt, nColors, targetFormat);
+ }
+ }
+ }
+ } else {
+ /*
+ * ARRAY HAS MIXED FORMATS.
+ */
+ if ((contents_flag == (DI_FORMAT | MIX_FORMAT)) &&
+ XCMS_DI_ID(targetFormat)) {
+ /*
+ * Convert from DI to DI in batches of contiguous formats
+ *
+ * Because DI->DI, WhiteAdjustProc not called.
+ */
+ retval = ConvertMixedColors(ccc, pColors_tmp, &clientWhitePt,
+ nColors, targetFormat, (unsigned char)DI_FORMAT);
+ } else if ((contents_flag == (DD_FORMAT | MIX_FORMAT)) &&
+ XCMS_DD_ID(targetFormat)) {
+ /*
+ * Convert from DD to DD in batches of contiguous formats
+ *
+ * Because DD->DD, WhiteAdjustProc not called.
+ */
+ retval = ConvertMixedColors(ccc, pColors_tmp,
+ (XcmsColor *)NULL, nColors, targetFormat,
+ (unsigned char)DD_FORMAT);
+ } else if (XCMS_DI_ID(targetFormat)) {
+ /*
+ * We need to convert from DI-to-DI and DD-to-DI, therefore
+ * 1. convert DD specifications to CIEXYZ, then
+ * 2. convert all in batches to the target DI format.
+ *
+ * Note that ConvertMixedColors will call WhiteAdjustProc
+ * as necessary.
+ */
+
+ /*
+ * Convert only DD specifications in batches of contiguous formats
+ * to CIEXYZ
+ *
+ * Since DD->CIEXYZ, ConvertMixedColors will apply WhiteAdjustProc
+ * if required.
+ */
+ retval = ConvertMixedColors(ccc, pColors_tmp, &clientWhitePt,
+ nColors, XcmsCIEXYZFormat, (unsigned char)DD_FORMAT);
+
+ /*
+ * Because at this point we may have a mix of DI formats
+ * (e.g., CIEXYZ, CIELuv) we must convert the specs to the
+ * target DI format in batches of contiguous source formats.
+ */
+ retval = ConvertMixedColors(ccc, pColors_tmp, &clientWhitePt,
+ nColors, targetFormat, (unsigned char)DI_FORMAT);
+ } else {
+ /*
+ * We need to convert from DI-to-DD and DD-to-DD, therefore
+ * 1. convert DI specifications to CIEXYZ, then
+ * 2. convert all to the DD target format.
+ *
+ * This allows white point adjustment and gamut compression
+ * to be applied to all the color specifications in one
+ * swoop if those functions do in fact modify the entire
+ * group of color specifications.
+ */
+
+ /*
+ * Convert in batches to CIEXYZ
+ *
+ * If DD->CIEXYZ, ConvertMixedColors will apply WhiteAdjustProc
+ * if required.
+ */
+ if ((retval = ConvertMixedColors(ccc, pColors_tmp, &clientWhitePt,
+ nColors, XcmsCIEXYZFormat,
+ (unsigned char)(DI_FORMAT | DD_FORMAT))) == XcmsFailure) {
+ goto Failure;
+ }
+
+ /*
+ * Convert all specifications (now in CIEXYZ format) to
+ * the target DD format.
+ * Since CIEXYZ->DD, compression MAY take place therefore
+ * we must pass pCompressed.
+ * Note that WhiteAdjustProc must be used if necessary.
+ */
+ if (callWhiteAdjustProc) {
+ /*
+ * White Point Adjustment
+ * Client White Point to Screen White Point
+ */
+ retval = (*ccc->whitePtAdjProc)(ccc,
+ &clientWhitePt, ScreenWhitePointOfCCC(ccc),
+ targetFormat, pColors_tmp, nColors, pCompressed);
+ } else {
+ retval = _XcmsDDConvertColors(ccc, pColors_tmp, nColors,
+ targetFormat, pCompressed);
+ }
+ }
+ }
+
+ if (retval != XcmsFailure) {
+ memcpy((char *)pColors_in_out, (char *)pColors_tmp,
+ nColors * sizeof(XcmsColor));
+ }
+ if (nColors > 1) {
+ Xfree((char *)pColors_tmp);
+ }
+ return(retval);
+
+Failure:
+ if (nColors > 1) {
+ Xfree((char *)pColors_tmp);
+ }
+ return(XcmsFailure);
+}
+
+
+/*
+ * NAME
+ * XcmsRegFormatOfPrefix
+ *
+ * SYNOPSIS
+ */
+XcmsColorFormat
+_XcmsRegFormatOfPrefix(
+ _Xconst char *prefix)
+/*
+ * DESCRIPTION
+ * Returns a color space ID associated with the specified
+ * X Consortium registered color space prefix.
+ *
+ * RETURNS
+ * The color space ID if found;
+ * otherwise NULL.
+ */
+{
+ XcmsRegColorSpaceEntry *pEntry = _XcmsRegColorSpaces;
+
+ while (pEntry->prefix != NULL) {
+ if (strcmp(prefix, pEntry->prefix) == 0) {
+ return(pEntry->id);
+ }
+ pEntry++;
+ }
+ return(XcmsUndefinedFormat);
+}
diff --git a/nx-X11/lib/X11/DefCursor.c b/nx-X11/lib/X11/DefCursor.c
new file mode 100644
index 000000000..053afbada
--- /dev/null
+++ b/nx-X11/lib/X11/DefCursor.c
@@ -0,0 +1,51 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/DefCursor.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/DelProp.c b/nx-X11/lib/X11/DelProp.c
new file mode 100644
index 000000000..fd40b7542
--- /dev/null
+++ b/nx-X11/lib/X11/DelProp.c
@@ -0,0 +1,49 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/DelProp.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/Depths.c b/nx-X11/lib/X11/Depths.c
new file mode 100644
index 000000000..82ce2c89f
--- /dev/null
+++ b/nx-X11/lib/X11/Depths.c
@@ -0,0 +1,63 @@
+/* $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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/DestSubs.c b/nx-X11/lib/X11/DestSubs.c
new file mode 100644
index 000000000..3d5f48d4f
--- /dev/null
+++ b/nx-X11/lib/X11/DestSubs.c
@@ -0,0 +1,47 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/DestSubs.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/DestWind.c b/nx-X11/lib/X11/DestWind.c
new file mode 100644
index 000000000..a079d448e
--- /dev/null
+++ b/nx-X11/lib/X11/DestWind.c
@@ -0,0 +1,47 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/DestWind.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/DisName.c b/nx-X11/lib/X11/DisName.c
new file mode 100644
index 000000000..59b5b3e1f
--- /dev/null
+++ b/nx-X11/lib/X11/DisName.c
@@ -0,0 +1,66 @@
+/* $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.
+
+*/
+/* $XFree86$ */
+
+/* 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 */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include "Xlib.h"
+
+char *
+XDisplayName(
+ _Xconst char *display)
+{
+ char *d;
+ if ( display != (char *)NULL && *display != '\0' )
+ return( (char *)display );
+ if ( (d = getenv( "DISPLAY" )) != (char *)NULL )
+ return( d );
+ return( "" );
+}
diff --git a/nx-X11/lib/X11/DrArc.c b/nx-X11/lib/X11/DrArc.c
new file mode 100644
index 000000000..311167647
--- /dev/null
+++ b/nx-X11/lib/X11/DrArc.c
@@ -0,0 +1,84 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/DrArc.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+/* 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. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/DrArcs.c b/nx-X11/lib/X11/DrArcs.c
new file mode 100644
index 000000000..8e028633c
--- /dev/null
+++ b/nx-X11/lib/X11/DrArcs.c
@@ -0,0 +1,59 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/DrArcs.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+#define arc_scale (SIZEOF(xArc) / 4)
+
+int
+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/nx-X11/lib/X11/DrLine.c b/nx-X11/lib/X11/DrLine.c
new file mode 100644
index 000000000..59095069b
--- /dev/null
+++ b/nx-X11/lib/X11/DrLine.c
@@ -0,0 +1,100 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/DrLine.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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))
+
+int
+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/nx-X11/lib/X11/DrLines.c b/nx-X11/lib/X11/DrLines.c
new file mode 100644
index 000000000..ea8bf82b8
--- /dev/null
+++ b/nx-X11/lib/X11/DrLines.c
@@ -0,0 +1,59 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/DrLines.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/DrPoint.c b/nx-X11/lib/X11/DrPoint.c
new file mode 100644
index 000000000..3cd6b7f57
--- /dev/null
+++ b/nx-X11/lib/X11/DrPoint.c
@@ -0,0 +1,98 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/DrPoint.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define size (SIZEOF(xPolyPointReq) + PTSPERBATCH * SIZEOF(xPoint))
+
+int
+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/nx-X11/lib/X11/DrPoints.c b/nx-X11/lib/X11/DrPoints.c
new file mode 100644
index 000000000..1637aa896
--- /dev/null
+++ b/nx-X11/lib/X11/DrPoints.c
@@ -0,0 +1,87 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/DrPoints.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/DrRect.c b/nx-X11/lib/X11/DrRect.c
new file mode 100644
index 000000000..984e291c6
--- /dev/null
+++ b/nx-X11/lib/X11/DrRect.c
@@ -0,0 +1,100 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/DrRect.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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))
+
+int
+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/nx-X11/lib/X11/DrRects.c b/nx-X11/lib/X11/DrRects.c
new file mode 100644
index 000000000..b300f2fe5
--- /dev/null
+++ b/nx-X11/lib/X11/DrRects.c
@@ -0,0 +1,67 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/DrRects.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/DrSegs.c b/nx-X11/lib/X11/DrSegs.c
new file mode 100644
index 000000000..e7e61b891
--- /dev/null
+++ b/nx-X11/lib/X11/DrSegs.c
@@ -0,0 +1,68 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/DrSegs.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/ErrDes.c b/nx-X11/lib/X11/ErrDes.c
new file mode 100644
index 000000000..16183e85e
--- /dev/null
+++ b/nx-X11/lib/X11/ErrDes.c
@@ -0,0 +1,207 @@
+/*
+ * $Xorg: ErrDes.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $
+ * $XdotOrg: xc/lib/X11/ErrDes.c,v 1.8 2005/08/26 05:16:46 daniels 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/ErrDes.c,v 3.11 2003/08/06 14:03:59 eich Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xos.h>
+#include "Xresource.h"
+#include <stdio.h>
+
+#ifndef ERRORDB
+#ifndef XERRORDB
+#define ERRORDB "/usr/lib/X11/XErrorDB"
+#else
+#define ERRORDB XERRORDB
+#endif
+#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",
+};
+
+
+int
+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;
+}
+
+int
+/*ARGSUSED*/
+XGetErrorDatabaseText(
+ Display *dpy,
+ register _Xconst char *name,
+ register _Xconst char *type,
+ _Xconst char *defaultp,
+ char *buffer,
+ int nbytes)
+{
+
+ 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;
+ const char *dbname;
+
+ XrmInitialize();
+#ifdef WIN32
+ dbname = getenv("XERRORDB");
+ if (!dbname)
+ dbname = ERRORDB;
+#else
+ dbname = ERRORDB;
+#endif
+ temp_db = XrmGetFileDatabase(dbname);
+
+ _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 <= sizeof(temp))
+ tptr = temp;
+ else
+ tptr = Xmalloc (tlen);
+ if (tptr) {
+ sprintf(tptr, "%s.%s", name, type);
+ XrmGetResource(db, tptr, "ErrorType.ErrorNumber",
+ &type_str, &result);
+ if (tptr != temp)
+ Xfree (tptr);
+ } else {
+ result.addr = (XPointer) NULL;
+ }
+ }
+ 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/nx-X11/lib/X11/ErrHndlr.c b/nx-X11/lib/X11/ErrHndlr.c
new file mode 100644
index 000000000..b3c2ce5a0
--- /dev/null
+++ b/nx-X11/lib/X11/ErrHndlr.c
@@ -0,0 +1,88 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ErrHndlr.c,v 1.6 2003/04/13 19:22:15 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/*
+ * 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.
+ */
+
+XErrorHandler
+XSetErrorHandler(XErrorHandler handler)
+{
+ int (*oldhandler)(Display *dpy, XErrorEvent *event);
+
+ _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.
+ */
+
+XIOErrorHandler
+XSetIOErrorHandler(XIOErrorHandler handler)
+{
+ int (*oldhandler)(Display *dpy);
+
+ _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/nx-X11/lib/X11/EvToWire.c b/nx-X11/lib/X11/EvToWire.c
new file mode 100644
index 000000000..143352791
--- /dev/null
+++ b/nx-X11/lib/X11/EvToWire.c
@@ -0,0 +1,408 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/EvToWire.c,v 1.4 2001/08/18 02:41:28 dawes Exp $ */
+
+/*
+ * 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
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/*
+ * reformat a wire event into an XEvent structure of the right type.
+ */
+Status
+_XEventToWire(
+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/nx-X11/lib/X11/FSSaver.c b/nx-X11/lib/X11/FSSaver.c
new file mode 100644
index 000000000..8ffa9593c
--- /dev/null
+++ b/nx-X11/lib/X11/FSSaver.c
@@ -0,0 +1,67 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FSSaver.c,v 1.3 2001/01/17 19:41:35 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XActivateScreenSaver(dpy)
+ register Display *dpy;
+
+{
+ XForceScreenSaver (dpy, ScreenSaverActive);
+ return 1;
+}
+
+int
+XResetScreenSaver(dpy)
+ register Display *dpy;
+
+{
+ XForceScreenSaver (dpy, ScreenSaverReset);
+ return 1;
+}
+
+int
+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/nx-X11/lib/X11/FSWrap.c b/nx-X11/lib/X11/FSWrap.c
new file mode 100644
index 000000000..d40f3b035
--- /dev/null
+++ b/nx-X11/lib/X11/FSWrap.c
@@ -0,0 +1,268 @@
+/* $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.
+
+*/
+
+/* $XFree86: xc/lib/X11/FSWrap.c,v 1.8 2003/08/22 19:27:24 eich Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include <ctype.h>
+#include <X11/Xos.h>
+
+
+#define XMAXLIST 256
+
+char **
+_XParseBaseFontNameList(
+ char *str,
+ int *num)
+{
+ char *plist[XMAXLIST];
+ char **list;
+ char *ptr, *psave;
+
+ *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);
+
+ psave = ptr;
+ /* 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(psave);
+ return (char **)NULL;
+ }
+ memcpy((char *)list, (char *)plist, sizeof(char *) * (*num));
+ *(list + *num) = NULL;
+
+ return list;
+}
+
+static char **
+copy_string_list(
+ 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;
+}
+
+XFontSet
+XCreateFontSet (
+ Display *dpy,
+ _Xconst char *base_font_name_list,
+ char ***missing_charset_list,
+ int *missing_charset_count,
+ char **def_string)
+{
+ 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/nx-X11/lib/X11/FetchName.c b/nx-X11/lib/X11/FetchName.c
new file mode 100644
index 000000000..3d41472f3
--- /dev/null
+++ b/nx-X11/lib/X11/FetchName.c
@@ -0,0 +1,96 @@
+/* $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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/FillArc.c b/nx-X11/lib/X11/FillArc.c
new file mode 100644
index 000000000..2aa88d8fd
--- /dev/null
+++ b/nx-X11/lib/X11/FillArc.c
@@ -0,0 +1,101 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FillArc.c,v 1.3 2001/01/17 19:41:35 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define size (SIZEOF(xPolyFillArcReq) + FARCSPERBATCH * SIZEOF(xArc))
+
+int
+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/nx-X11/lib/X11/FillArcs.c b/nx-X11/lib/X11/FillArcs.c
new file mode 100644
index 000000000..27f0b8ffa
--- /dev/null
+++ b/nx-X11/lib/X11/FillArcs.c
@@ -0,0 +1,69 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FillArcs.c,v 1.3 2001/01/17 19:41:35 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+#define arc_scale (SIZEOF(xArc) / 4)
+
+int
+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/nx-X11/lib/X11/FillPoly.c b/nx-X11/lib/X11/FillPoly.c
new file mode 100644
index 000000000..93884d793
--- /dev/null
+++ b/nx-X11/lib/X11/FillPoly.c
@@ -0,0 +1,66 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FillPoly.c,v 1.3 2001/01/17 19:41:35 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/FillRct.c b/nx-X11/lib/X11/FillRct.c
new file mode 100644
index 000000000..d4a362af7
--- /dev/null
+++ b/nx-X11/lib/X11/FillRct.c
@@ -0,0 +1,97 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FillRct.c,v 1.3 2001/01/17 19:41:35 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define size (SIZEOF(xPolyFillRectangleReq) + FRCTSPERBATCH * SIZEOF(xRectangle))
+
+int
+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/nx-X11/lib/X11/FillRcts.c b/nx-X11/lib/X11/FillRcts.c
new file mode 100644
index 000000000..0c234f018
--- /dev/null
+++ b/nx-X11/lib/X11/FillRcts.c
@@ -0,0 +1,68 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FillRcts.c,v 1.3 2001/01/17 19:41:35 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/FilterEv.c b/nx-X11/lib/X11/FilterEv.c
new file mode 100644
index 000000000..0117291b2
--- /dev/null
+++ b/nx-X11/lib/X11/FilterEv.c
@@ -0,0 +1,109 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FilterEv.c,v 3.4 2001/07/29 05:01:11 tsi Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#else
+#define XLOCALE 1
+#endif
+#include "Xlibint.h"
+#if XLOCALE
+#include "Xlcint.h"
+#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;
+{
+#if XLOCALE
+ 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);
+#endif
+ return(False);
+}
diff --git a/nx-X11/lib/X11/Flush.c b/nx-X11/lib/X11/Flush.c
new file mode 100644
index 000000000..3df8731ba
--- /dev/null
+++ b/nx-X11/lib/X11/Flush.c
@@ -0,0 +1,45 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/Flush.c,v 1.3 2001/01/17 19:41:35 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/* Flush all buffered output requests. */
+/* NOTE: NOT necessary when calling any of the Xlib routines. */
+
+int
+XFlush (dpy)
+ register Display *dpy;
+ {
+ LockDisplay(dpy);
+ _XFlush (dpy);
+ UnlockDisplay(dpy);
+ return 1;
+ }
diff --git a/nx-X11/lib/X11/Font.c b/nx-X11/lib/X11/Font.c
new file mode 100644
index 000000000..c37617cf9
--- /dev/null
+++ b/nx-X11/lib/X11/Font.c
@@ -0,0 +1,734 @@
+/* $Xorg: Font.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+Copyright (c) 2000 The XFree86 Project, Inc.
+
+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
+X CONSORTIUM OR THE XFREE86 PROJECT 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 X Consortium or of the
+XFree86 Project 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 X Consortium and the XFree86 Project.
+
+*/
+/* $XFree86: xc/lib/X11/Font.c,v 1.17 2003/04/13 19:22:16 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+#if defined(XF86BIGFONT) && !defined(MUSTCOPY)
+#define USE_XF86BIGFONT
+#endif
+#ifdef USE_XF86BIGFONT
+#include <sys/types.h>
+#ifdef HAS_SHM
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/extensions/xf86bigfstr.h>
+#endif
+
+#include "Xlcint.h"
+#include "XlcPubI.h"
+
+
+static XFontStruct *_XQueryFont(
+ Display* /* dpy */,
+ Font /* fid */,
+ unsigned long /* seq */
+);
+
+#ifdef USE_XF86BIGFONT
+
+/* Private data for this extension. */
+typedef struct {
+ XExtCodes *codes;
+ CARD32 serverSignature;
+ CARD32 serverCapabilities;
+} XF86BigfontCodes;
+
+/* Additional bit masks that can be set in serverCapabilities */
+#define CAP_VerifiedLocal 256
+
+static XF86BigfontCodes *_XF86BigfontCodes(
+ Display* /* dpy */
+);
+
+static XFontStruct *_XF86BigfontQueryFont(
+ Display* /* dpy */,
+ XF86BigfontCodes* /* extcodes */,
+ Font /* fid */,
+ unsigned long /* seq */
+);
+
+void _XF86BigfontFreeFontMetrics(
+ XFontStruct* /* fs */
+);
+
+#endif /* USE_XF86BIGFONT */
+
+
+XFontStruct *XLoadQueryFont(
+ register Display *dpy,
+ _Xconst char *name)
+{
+ XFontStruct *font_result;
+ register long nbytes;
+ Font fid;
+ xOpenFontReq *req;
+ unsigned long seq;
+#ifdef USE_XF86BIGFONT
+ XF86BigfontCodes *extcodes = _XF86BigfontCodes(dpy);
+#endif
+
+ if (_XF86LoadQueryLocaleFont(dpy, name, &font_result, (Font *)0))
+ return font_result;
+ 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 = NULL;
+#ifdef USE_XF86BIGFONT
+ if (extcodes) {
+ font_result = _XF86BigfontQueryFont(dpy, extcodes, fid, seq);
+ seq = 0;
+ }
+#endif
+ if (!font_result)
+ font_result = _XQueryFont(dpy, fid, seq);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return font_result;
+}
+
+XFontStruct *XQueryFont (dpy, fid)
+ register Display *dpy;
+ Font fid;
+{
+ XFontStruct *font_result;
+#ifdef USE_XF86BIGFONT
+ XF86BigfontCodes *extcodes = _XF86BigfontCodes(dpy);
+#endif
+
+ LockDisplay(dpy);
+ font_result = NULL;
+#ifdef USE_XF86BIGFONT
+ if (extcodes) {
+ font_result = _XF86BigfontQueryFont(dpy, extcodes, fid, 0L);
+ }
+#endif
+ if (!font_result)
+ font_result = _XQueryFont(dpy, fid, 0L);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return font_result;
+}
+
+int
+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();
+ if (fs->per_char) {
+#ifdef USE_XF86BIGFONT
+ _XF86BigfontFreeFontMetrics(fs);
+#else
+ Xfree ((char *) fs->per_char);
+#endif
+ }
+ _XFreeExtData(fs->ext_data);
+ 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, (long *)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;
+}
+
+#ifdef USE_XF86BIGFONT
+
+/* Magic cookie for finding the right XExtData structure on the display's
+ extension list. */
+static int XF86BigfontNumber = 1040697125;
+
+static int
+_XF86BigfontFreeCodes (
+ XExtData *extension)
+{
+ /* Don't Xfree(extension->private_data) because it is on the same malloc
+ chunk as extension. */
+ /* Don't Xfree(extension->private_data->codes) because this is shared with
+ the display's ext_procs list. */
+ return 0;
+}
+
+static XF86BigfontCodes *
+_XF86BigfontCodes (
+ register Display *dpy)
+{
+ XEDataObject dpy_union;
+ XExtData *pData;
+ XF86BigfontCodes *pCodes;
+ char *envval;
+
+ dpy_union.display = dpy;
+
+ /* If the server is known to support the XF86Bigfont extension,
+ * return the extension codes. If the server is known to not support
+ * the extension, don't bother checking again.
+ */
+ pData = XFindOnExtensionList(XEHeadOfExtensionList(dpy_union),
+ XF86BigfontNumber);
+ if (pData)
+ return (XF86BigfontCodes *) pData->private_data;
+
+ pData = (XExtData *) Xmalloc(sizeof(XExtData) + sizeof(XF86BigfontCodes));
+ if (!pData) {
+ /* Out of luck. */
+ return (XF86BigfontCodes *) NULL;
+ }
+
+ /* See if the server supports the XF86Bigfont extension. */
+ envval = getenv("XF86BIGFONT_DISABLE"); /* Let the user disable it. */
+ if (envval != NULL && envval[0] != '\0')
+ pCodes = NULL;
+ else {
+ XExtCodes *codes = XInitExtension(dpy, XF86BIGFONTNAME);
+ if (codes == NULL)
+ pCodes = NULL;
+ else {
+ pCodes = (XF86BigfontCodes *) &pData[1];
+ pCodes->codes = codes;
+ }
+ }
+ pData->number = XF86BigfontNumber;
+ pData->private_data = (XPointer) pCodes;
+ pData->free_private = _XF86BigfontFreeCodes;
+ XAddToExtensionList(XEHeadOfExtensionList(dpy_union), pData);
+ if (pCodes) {
+ int result;
+
+ /* See if the server supports the XF86BigfontQueryFont request. */
+ xXF86BigfontQueryVersionReply reply;
+ register xXF86BigfontQueryVersionReq *req;
+
+ LockDisplay(dpy);
+
+ GetReq(XF86BigfontQueryVersion, req);
+ req->reqType = pCodes->codes->major_opcode;
+ req->xf86bigfontReqType = X_XF86BigfontQueryVersion;
+
+ result = _XReply (dpy, (xReply *) &reply,
+ (SIZEOF(xXF86BigfontQueryVersionReply) - SIZEOF(xReply)) >> 2,
+ xFalse);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if(!result)
+ goto ignore_extension;
+
+ /* No need to provide backward compatibility with version 1.0. It
+ was never widely distributed. */
+ if (!(reply.majorVersion > 1
+ || (reply.majorVersion == 1 && reply.minorVersion >= 1)))
+ goto ignore_extension;
+
+ pCodes->serverSignature = reply.signature;
+ pCodes->serverCapabilities = reply.capabilities;
+ }
+ return pCodes;
+
+ ignore_extension:
+ /* No need to Xfree(pCodes) or Xfree(pCodes->codes), see
+ _XF86BigfontFreeCodes comment. */
+ pCodes = (XF86BigfontCodes *) NULL;
+ pData->private_data = (XPointer) pCodes;
+ return pCodes;
+}
+
+static int
+_XF86BigfontFreeNop (
+ XExtData *extension)
+{
+ return 0;
+}
+
+static XFontStruct *
+_XF86BigfontQueryFont (dpy, extcodes, fid, seq)
+ register Display *dpy;
+ XF86BigfontCodes *extcodes;
+ Font fid;
+ unsigned long seq;
+{
+ register XFontStruct *fs;
+ register long nbytes;
+ xXF86BigfontQueryFontReply reply;
+ register xXF86BigfontQueryFontReq *req;
+ register _XExtension *ext;
+ _XAsyncHandler async1;
+ _XAsyncErrorState async1_state;
+ _XAsyncHandler async2;
+ _XAsyncErrorState async2_state;
+
+ if (seq) {
+ async1_state.min_sequence_number = seq;
+ async1_state.max_sequence_number = seq;
+ async1_state.error_code = BadName;
+ async1_state.major_opcode = X_OpenFont;
+ async1_state.minor_opcode = 0;
+ async1_state.error_count = 0;
+ async1.next = dpy->async_handlers;
+ async1.handler = _XAsyncErrorHandler;
+ async1.data = (XPointer)&async1_state;
+ dpy->async_handlers = &async1;
+ }
+
+ GetReq(XF86BigfontQueryFont, req);
+ req->reqType = extcodes->codes->major_opcode;
+ req->xf86bigfontReqType = X_XF86BigfontQueryFont;
+ req->id = fid;
+ req->flags = (extcodes->serverCapabilities & XF86Bigfont_CAP_LocalShm
+ ? XF86Bigfont_FLAGS_Shm : 0);
+
+ /* The function _XQueryFont benefits from a "magic" error handler for
+ BadFont coming from a X_QueryFont request. (See function _XReply.)
+ We have to establish an error handler ourselves. */
+ async2_state.min_sequence_number = dpy->request;
+ async2_state.max_sequence_number = dpy->request;
+ async2_state.error_code = BadFont;
+ async2_state.major_opcode = extcodes->codes->major_opcode;
+ async2_state.minor_opcode = X_XF86BigfontQueryFont;
+ async2_state.error_count = 0;
+ async2.next = dpy->async_handlers;
+ async2.handler = _XAsyncErrorHandler;
+ async2.data = (XPointer)&async2_state;
+ dpy->async_handlers = &async2;
+
+ if (!_XReply (dpy, (xReply *) &reply,
+ ((SIZEOF(xXF86BigfontQueryFontReply) - SIZEOF(xReply)) >> 2), xFalse)) {
+ DeqAsyncHandler(dpy, &async2);
+ if (seq)
+ DeqAsyncHandler(dpy, &async1);
+ return (XFontStruct *)NULL;
+ }
+ DeqAsyncHandler(dpy, &async2);
+ if (seq)
+ DeqAsyncHandler(dpy, &async1);
+ if (! (fs = (XFontStruct *) Xmalloc (sizeof (XFontStruct)))) {
+ _XEatData(dpy,
+ reply.nFontProps * SIZEOF(xFontProp)
+ + (reply.nCharInfos > 0 && reply.shmid == (CARD32)(-1)
+ ? reply.nUniqCharInfos * SIZEOF(xCharInfo)
+ + (reply.nCharInfos+1)/2 * 2 * sizeof(CARD16)
+ : 0));
+ 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);
+
+ /* 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;
+
+ 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,
+ nbytes
+ + (reply.nCharInfos > 0 && reply.shmid == (CARD32)(-1)
+ ? reply.nUniqCharInfos * SIZEOF(xCharInfo)
+ + (reply.nCharInfos+1)/2 * 2 * sizeof(CARD16)
+ : 0));
+ return (XFontStruct *)NULL;
+ }
+ _XRead32 (dpy, (long *)fs->properties, nbytes);
+ }
+
+ fs->per_char = NULL;
+ if (reply.nCharInfos > 0) {
+ /* fprintf(stderr, "received font metrics, nCharInfos = %d, nUniqCharInfos = %d, shmid = %d\n", reply.nCharInfos, reply.nUniqCharInfos, reply.shmid); */
+ if (reply.shmid == (CARD32)(-1)) {
+ xCharInfo* pUniqCI;
+ CARD16* pIndex2UniqIndex;
+ int i;
+
+ nbytes = reply.nUniqCharInfos * SIZEOF(xCharInfo)
+ + (reply.nCharInfos+1)/2 * 2 * sizeof(CARD16);
+ pUniqCI = (xCharInfo *) Xmalloc (nbytes);
+ if (!pUniqCI) {
+ if (fs->properties) Xfree((char *) fs->properties);
+ Xfree((char *) fs);
+ _XEatData(dpy, nbytes);
+ return (XFontStruct *)NULL;
+ }
+ if (! (fs->per_char = (XCharStruct *) Xmalloc (reply.nCharInfos * sizeof(XCharStruct)))) {
+ Xfree((char *) pUniqCI);
+ if (fs->properties) Xfree((char *) fs->properties);
+ Xfree((char *) fs);
+ _XEatData(dpy, nbytes);
+ return (XFontStruct *)NULL;
+ }
+ _XRead16 (dpy, (char *) pUniqCI, nbytes);
+ pIndex2UniqIndex = (CARD16*) (pUniqCI + reply.nUniqCharInfos);
+ for (i = 0; i < reply.nCharInfos; i++) {
+ if (pIndex2UniqIndex[i] >= reply.nUniqCharInfos) {
+ fprintf(stderr, "_XF86BigfontQueryFont: server returned wrong data\n");
+ Xfree((char *) pUniqCI);
+ if (fs->properties) Xfree((char *) fs->properties);
+ Xfree((char *) fs);
+ return (XFontStruct *)NULL;
+ }
+ /* XXX the next statement won't work if short isn't 16 bits */
+ fs->per_char[i] = * (XCharStruct *) &pUniqCI[pIndex2UniqIndex[i]];
+ }
+ Xfree((char *) pUniqCI);
+ } else {
+#ifdef HAS_SHM
+ XExtData *pData;
+ XEDataObject fs_union;
+ char *addr;
+
+ pData = (XExtData *) Xmalloc(sizeof(XExtData));
+ if (!pData) {
+ if (fs->properties) Xfree((char *) fs->properties);
+ Xfree((char *) fs);
+ return (XFontStruct *)NULL;
+ }
+
+ /* In some cases (e.g. an ssh daemon forwarding an X session to
+ a remote machine) it is possible that the X server thinks we
+ are running on the same machine (because getpeername() and
+ LocalClient() cannot know about the forwarding) but we are
+ not really local. Therefore, when we attach the first shared
+ memory segment, we verify that we are on the same machine as
+ the X server by checking that 1. shmat() succeeds, 2. the
+ segment has a sufficient size, 3. it contains the X server's
+ signature. Then we set the CAP_VerifiedLocal bit to indicate
+ the verification was successful. */
+
+ if ((addr = shmat(reply.shmid, 0, SHM_RDONLY)) == (char *)-1) {
+ if (extcodes->serverCapabilities & CAP_VerifiedLocal)
+ fprintf(stderr, "_XF86BigfontQueryFont: could not attach shm segment\n");
+ Xfree((char *) pData);
+ if (fs->properties) Xfree((char *) fs->properties);
+ Xfree((char *) fs);
+ /* Stop requesting shared memory transport from now on. */
+ extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm;
+ return (XFontStruct *)NULL;
+ }
+
+ if (!(extcodes->serverCapabilities & CAP_VerifiedLocal)) {
+ struct shmid_ds buf;
+ if (!(shmctl(reply.shmid, IPC_STAT, &buf) >= 0
+ && buf.shm_segsz >= reply.shmsegoffset + reply.nCharInfos * sizeof(XCharStruct) + sizeof(CARD32)
+ && *(CARD32 *)(addr + reply.shmsegoffset + reply.nCharInfos * sizeof(XCharStruct)) == extcodes->serverSignature)) {
+ shmdt(addr);
+ Xfree((char *) pData);
+ if (fs->properties) Xfree((char *) fs->properties);
+ Xfree((char *) fs);
+ /* Stop requesting shared memory transport from now on. */
+ extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm;
+ return (XFontStruct *)NULL;
+ }
+ extcodes->serverCapabilities |= CAP_VerifiedLocal;
+ }
+
+ pData->number = XF86BigfontNumber;
+ pData->private_data = (XPointer) addr;
+ pData->free_private = _XF86BigfontFreeNop;
+ fs_union.font = fs;
+ XAddToExtensionList(XEHeadOfExtensionList(fs_union), pData);
+
+ fs->per_char = (XCharStruct *) (addr + reply.shmsegoffset);
+#else
+ fprintf(stderr, "_XF86BigfontQueryFont: try recompiling libX11 with HasShm, Xserver has shm support\n");
+ if (fs->properties) Xfree((char *) fs->properties);
+ Xfree((char *) fs);
+ /* Stop requesting shared memory transport from now on. */
+ extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm;
+ return (XFontStruct *)NULL;
+#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;
+}
+
+void
+_XF86BigfontFreeFontMetrics (fs)
+ XFontStruct *fs;
+{
+#ifdef HAS_SHM
+ XExtData *pData;
+ XEDataObject fs_union;
+
+ fs_union.font = fs;
+ if ((pData = XFindOnExtensionList(XEHeadOfExtensionList(fs_union),
+ XF86BigfontNumber)))
+ shmdt ((char *) pData->private_data);
+ else
+ Xfree ((char *) fs->per_char);
+#else
+ Xfree ((char *) fs->per_char);
+#endif
+}
+
+#endif /* USE_XF86BIGFONT */
+
+int _XF86LoadQueryLocaleFont(
+ Display *dpy,
+ _Xconst char *name,
+ XFontStruct **xfp,
+ Font *fidp)
+{
+ int l;
+ char *charset, *p;
+ char buf[256];
+ XFontStruct *fs;
+ XLCd lcd;
+
+ if (!name)
+ return 0;
+ l = strlen(name);
+ if (l < 2 || name[l - 1] != '*' || name[l - 2] != '-')
+ return 0;
+ charset = 0;
+ /* next three lines stolen from _XkbGetCharset() */
+ lcd = _XlcCurrentLC();
+ if ((lcd = _XlcCurrentLC()) != 0)
+ charset = XLC_PUBLIC(lcd, encoding_name);
+ if (!charset || (p = strrchr(charset, '-')) == 0 || p == charset || p[1] == 0 || (p[1] == '*' && p[2] == 0)) {
+ /* prefer latin1 if no encoding found */
+ charset = "ISO8859-1";
+ p = charset + 7;
+ }
+ if (l - 2 - (p - charset) < 0)
+ return 0;
+ if (_XlcNCompareISOLatin1(name + l - 2 - (p - charset), charset, p - charset))
+ return 0;
+ if (strlen(p + 1) + l - 1 >= sizeof(buf) - 1)
+ return 0;
+ strcpy(buf, name);
+ strcpy(buf + l - 1, p + 1);
+ fs = XLoadQueryFont(dpy, buf);
+ if (!fs)
+ return 0;
+ if (xfp) {
+ *xfp = fs;
+ if (fidp)
+ *fidp = fs->fid;
+ } else if (fidp) {
+ if (fs->per_char) {
+#ifdef USE_XF86BIGFONT
+ _XF86BigfontFreeFontMetrics(fs);
+#else
+ Xfree ((char *) fs->per_char);
+#endif
+ }
+ _XFreeExtData(fs->ext_data);
+ if (fs->properties)
+ Xfree ((char *) fs->properties);
+ *fidp = fs->fid;
+ Xfree ((char *) fs);
+ } else {
+ XFreeFont(dpy, fs);
+ }
+ return 1;
+}
diff --git a/nx-X11/lib/X11/FontInfo.c b/nx-X11/lib/X11/FontInfo.c
new file mode 100644
index 000000000..f92375853
--- /dev/null
+++ b/nx-X11/lib/X11/FontInfo.c
@@ -0,0 +1,256 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FontInfo.c,v 1.6 2001/12/14 19:54:00 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+#if defined(XF86BIGFONT) && !defined(MUSTCOPY)
+#define USE_XF86BIGFONT
+#endif
+#ifdef USE_XF86BIGFONT
+extern void _XF86BigfontFreeFontMetrics(
+ XFontStruct* /* fs */
+);
+#endif
+
+char **XListFontsWithInfo(
+register Display *dpy,
+_Xconst char *pattern, /* null-terminated */
+int maxNames,
+int *actualCount, /* RETURN */
+XFontStruct **info) /* RETURN */
+{
+ 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, (long *)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;
+}
+
+int
+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)
+#ifdef USE_XF86BIGFONT
+ _XF86BigfontFreeFontMetrics(&info[i]);
+#else
+ Xfree ((char *) info[i].per_char);
+#endif
+ if (info[i].properties)
+ Xfree ((char *) info[i].properties);
+ }
+ Xfree((char *) info);
+ }
+ return 1;
+}
diff --git a/nx-X11/lib/X11/FontNames.c b/nx-X11/lib/X11/FontNames.c
new file mode 100644
index 000000000..0db27a222
--- /dev/null
+++ b/nx-X11/lib/X11/FontNames.c
@@ -0,0 +1,117 @@
+/* $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.
+
+*/
+
+/* $XFree86: xc/lib/X11/FontNames.c,v 1.6 2001/12/14 19:54:00 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+char **
+XListFonts(
+register Display *dpy,
+_Xconst char *pattern, /* null-terminated */
+int maxNames,
+int *actualCount) /* RETURN */
+{
+ 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);
+}
+
+int
+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/nx-X11/lib/X11/FreeCmap.c b/nx-X11/lib/X11/FreeCmap.c
new file mode 100644
index 000000000..c399c1f27
--- /dev/null
+++ b/nx-X11/lib/X11/FreeCmap.c
@@ -0,0 +1,51 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FreeCmap.c,v 1.4 2001/12/14 19:54:00 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlib.h"
+#include "Xlibint.h"
+#include "Cmap.h"
+
+int
+XFreeColormap(
+ 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/nx-X11/lib/X11/FreeCols.c b/nx-X11/lib/X11/FreeCols.c
new file mode 100644
index 000000000..1ae525862
--- /dev/null
+++ b/nx-X11/lib/X11/FreeCols.c
@@ -0,0 +1,59 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FreeCols.c,v 1.3 2001/01/17 19:41:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/FreeCurs.c b/nx-X11/lib/X11/FreeCurs.c
new file mode 100644
index 000000000..45f5d0440
--- /dev/null
+++ b/nx-X11/lib/X11/FreeCurs.c
@@ -0,0 +1,46 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FreeCurs.c,v 1.3 2001/01/17 19:41:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/FreeEData.c b/nx-X11/lib/X11/FreeEData.c
new file mode 100644
index 000000000..d8278cbaf
--- /dev/null
+++ b/nx-X11/lib/X11/FreeEData.c
@@ -0,0 +1,48 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FreeEData.c,v 1.3 2001/01/17 19:41:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+_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/nx-X11/lib/X11/FreeGC.c b/nx-X11/lib/X11/FreeGC.c
new file mode 100644
index 000000000..ccfbba5d4
--- /dev/null
+++ b/nx-X11/lib/X11/FreeGC.c
@@ -0,0 +1,52 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FreeGC.c,v 1.4 2001/08/18 02:41:28 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/FreePix.c b/nx-X11/lib/X11/FreePix.c
new file mode 100644
index 000000000..5fe65babb
--- /dev/null
+++ b/nx-X11/lib/X11/FreePix.c
@@ -0,0 +1,47 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/FreePix.c,v 1.3 2001/01/17 19:41:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/GCMisc.c b/nx-X11/lib/X11/GCMisc.c
new file mode 100644
index 000000000..5a8233bea
--- /dev/null
+++ b/nx-X11/lib/X11/GCMisc.c
@@ -0,0 +1,112 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/GCMisc.c,v 1.3 2001/01/17 19:41:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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;
+}
+
+int
+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;
+}
+
+int
+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;
+}
+
+int
+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;
+}
+
+int
+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/nx-X11/lib/X11/Geom.c b/nx-X11/lib/X11/Geom.c
new file mode 100644
index 000000000..498c4455e
--- /dev/null
+++ b/nx-X11/lib/X11/Geom.c
@@ -0,0 +1,91 @@
+/* $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.
+
+*/
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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.
+ */
+
+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 */
+{
+ 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/nx-X11/lib/X11/GetAtomNm.c b/nx-X11/lib/X11/GetAtomNm.c
new file mode 100644
index 000000000..1bba975d3
--- /dev/null
+++ b/nx-X11/lib/X11/GetAtomNm.c
@@ -0,0 +1,192 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/GetAtomNm.c,v 3.4 2001/08/18 02:41:28 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xintatom.h"
+
+static
+char *_XGetAtomName(
+ 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(
+ 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/nx-X11/lib/X11/GetColor.c b/nx-X11/lib/X11/GetColor.c
new file mode 100644
index 000000000..530f479db
--- /dev/null
+++ b/nx-X11/lib/X11/GetColor.c
@@ -0,0 +1,112 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/GetColor.c,v 1.6 2003/04/13 19:22:16 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+Status
+XAllocNamedColor(
+register Display *dpy,
+Colormap cmap,
+_Xconst char *colorname, /* STRING8 */
+XColor *hard_def, /* RETURN */
+XColor *exact_def) /* RETURN */
+{
+
+ 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
+ */
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
+ const char *tmpName = colorname;
+
+ switch (_XcmsResolveColorString(ccc, &tmpName, &cmsColor_exact,
+ XcmsRGBFormat)) {
+ case XcmsSuccess:
+ case XcmsSuccessWithCompression:
+ _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);
+ case XcmsFailure:
+ case _XCMS_NEWNAME:
+ /*
+ * if the result was _XCMS_NEWNAME tmpName points to
+ * a string in cmsColNm.c:pairs table, for example,
+ * gray70 would become tekhvc:0.0/70.0/0.0
+ */
+ break;
+ }
+ }
+
+ /*
+ * 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/nx-X11/lib/X11/GetDflt.c b/nx-X11/lib/X11/GetDflt.c
new file mode 100644
index 000000000..8a8563379
--- /dev/null
+++ b/nx-X11/lib/X11/GetDflt.c
@@ -0,0 +1,259 @@
+/* $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.
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/GetDflt.c,v 3.22 2003/04/13 19:22:16 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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>
+
+
+/*ARGSUSED*/
+static char *
+GetHomeDir(
+ 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
+#ifdef X_NEEDS_PWPARAMS
+ _Xgetpwparams pwparams;
+#endif
+ struct passwd *pw;
+ register char *ptr;
+
+ if (len <= 0 || dest == NULL)
+ return NULL;
+
+ if ((ptr = getenv("HOME"))) {
+ (void) strncpy(dest, ptr, len-1);
+ 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-1);
+ dest[len-1] = '\0';
+ } else
+ *dest = '\0';
+ }
+#endif
+ return dest;
+}
+
+
+static XrmDatabase
+InitDefaults(
+ 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
+}
+
+char *
+XGetDefault(
+ Display *dpy, /* display for defaults.... */
+ char _Xconst *prog, /* name of program for option */
+ register _Xconst char *name) /* name of option program wants */
+{ /* to get, for example, "font" */
+ XrmName names[3];
+ XrmClass classes[3];
+ XrmRepresentation fromType;
+ XrmValue result;
+ char *progname;
+#ifdef WIN32
+ char *progname2;
+#endif
+#ifdef __UNIXOS2__
+ char *progname2;
+ char *dotpos;
+#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
+#ifdef __UNIXOS2__ /* Very similar to WIN32 */
+ progname2 = strrchr (prog, '\\');
+ if (progname2 && (!progname || progname < progname2))
+ progname = progname2;
+ dotpos = strrchr (prog, '.');
+ if (dotpos && (dotpos>progname2)) *dotpos='\0';
+#endif /* We take out the .exe suffix */
+
+ 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);
+ dpy->flags |= XlibDisplayDfltRMDB;
+ }
+ 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/nx-X11/lib/X11/GetFPath.c b/nx-X11/lib/X11/GetFPath.c
new file mode 100644
index 000000000..03ad5daf9
--- /dev/null
+++ b/nx-X11/lib/X11/GetFPath.c
@@ -0,0 +1,95 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/GetFPath.c,v 1.3 2001/01/17 19:41:36 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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);
+}
+
+int
+XFreeFontPath (list)
+char **list;
+{
+ if (list != NULL) {
+ Xfree (list[0]-1);
+ Xfree ((char *)list);
+ }
+ return 1;
+}
diff --git a/nx-X11/lib/X11/GetFProp.c b/nx-X11/lib/X11/GetFProp.c
new file mode 100644
index 000000000..1360ca10d
--- /dev/null
+++ b/nx-X11/lib/X11/GetFProp.c
@@ -0,0 +1,56 @@
+/* $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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GetGCVals.c b/nx-X11/lib/X11/GetGCVals.c
new file mode 100644
index 000000000..a7fbd7430
--- /dev/null
+++ b/nx-X11/lib/X11/GetGCVals.c
@@ -0,0 +1,129 @@
+/* $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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GetGeom.c b/nx-X11/lib/X11/GetGeom.c
new file mode 100644
index 000000000..842df3350
--- /dev/null
+++ b/nx-X11/lib/X11/GetGeom.c
@@ -0,0 +1,61 @@
+/* $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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GetHColor.c b/nx-X11/lib/X11/GetHColor.c
new file mode 100644
index 000000000..647cc11c9
--- /dev/null
+++ b/nx-X11/lib/X11/GetHColor.c
@@ -0,0 +1,60 @@
+/* $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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GetHints.c b/nx-X11/lib/X11/GetHints.c
new file mode 100644
index 000000000..4faccb624
--- /dev/null
+++ b/nx-X11/lib/X11/GetHints.c
@@ -0,0 +1,341 @@
+/* $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.
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/GetHints.c,v 1.3 2001/01/17 19:41:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GetIFocus.c b/nx-X11/lib/X11/GetIFocus.c
new file mode 100644
index 000000000..13cab18a9
--- /dev/null
+++ b/nx-X11/lib/X11/GetIFocus.c
@@ -0,0 +1,52 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/GetIFocus.c,v 1.3 2001/01/17 19:41:36 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/GetImage.c b/nx-X11/lib/X11/GetImage.c
new file mode 100644
index 000000000..ffe9d226f
--- /dev/null
+++ b/nx-X11/lib/X11/GetImage.c
@@ -0,0 +1,127 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/GetImage.c,v 1.4 2001/12/14 19:54:00 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xutil.h> /* for XDestroyImage */
+#include "ImUtil.h"
+
+#define ROUNDUP(nbytes, pad) (((((nbytes) - 1) + (pad)) / (pad)) * (pad))
+
+static unsigned int Ones( /* 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/nx-X11/lib/X11/GetKCnt.c b/nx-X11/lib/X11/GetKCnt.c
new file mode 100644
index 000000000..47f806472
--- /dev/null
+++ b/nx-X11/lib/X11/GetKCnt.c
@@ -0,0 +1,58 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/GetKCnt.c,v 1.5 2001/01/17 19:41:36 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/GetMoEv.c b/nx-X11/lib/X11/GetMoEv.c
new file mode 100644
index 000000000..e332ecfeb
--- /dev/null
+++ b/nx-X11/lib/X11/GetMoEv.c
@@ -0,0 +1,86 @@
+/* $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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GetNrmHint.c b/nx-X11/lib/X11/GetNrmHint.c
new file mode 100644
index 000000000..9dcb7c403
--- /dev/null
+++ b/nx-X11/lib/X11/GetNrmHint.c
@@ -0,0 +1,128 @@
+/* $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.
+
+*/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GetPCnt.c b/nx-X11/lib/X11/GetPCnt.c
new file mode 100644
index 000000000..0883abada
--- /dev/null
+++ b/nx-X11/lib/X11/GetPCnt.c
@@ -0,0 +1,54 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/GetPCnt.c,v 1.3 2001/01/17 19:41:36 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/GetPntMap.c b/nx-X11/lib/X11/GetPntMap.c
new file mode 100644
index 000000000..7a93ad794
--- /dev/null
+++ b/nx-X11/lib/X11/GetPntMap.c
@@ -0,0 +1,126 @@
+/* $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.
+
+*/
+
+/* $XFree86: xc/lib/X11/GetPntMap.c,v 1.6 2001/12/14 19:54:01 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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;
+
+ /* Don't count on the server returning a valid value */
+ 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);
+}
+
+KeySym *
+XGetKeyboardMapping (Display *dpy,
+#if NeedWidePrototypes
+ unsigned int first_keycode,
+#else
+ KeyCode first_keycode,
+#endif
+ int count,
+ int *keysyms_per_keycode)
+{
+ 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, (long *) mapping, nbytes);
+ }
+ *keysyms_per_keycode = rep.keySymsPerKeyCode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (mapping);
+}
+
diff --git a/nx-X11/lib/X11/GetProp.c b/nx-X11/lib/X11/GetProp.c
new file mode 100644
index 000000000..af5525702
--- /dev/null
+++ b/nx-X11/lib/X11/GetProp.c
@@ -0,0 +1,136 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/GetProp.c,v 1.5 2001/10/28 03:32:30 tsi Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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 (nbytes + 1 > 0 &&
+ (*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 (nbytes + 1 > 0 &&
+ (*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 (nbytes + 1 > 0 &&
+ (*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);
+ }
+ nbytes = 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/nx-X11/lib/X11/GetRGBCMap.c b/nx-X11/lib/X11/GetRGBCMap.c
new file mode 100644
index 000000000..6657c539a
--- /dev/null
+++ b/nx-X11/lib/X11/GetRGBCMap.c
@@ -0,0 +1,136 @@
+/* $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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GetSOwner.c b/nx-X11/lib/X11/GetSOwner.c
new file mode 100644
index 000000000..30d57023d
--- /dev/null
+++ b/nx-X11/lib/X11/GetSOwner.c
@@ -0,0 +1,47 @@
+/* $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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GetSSaver.c b/nx-X11/lib/X11/GetSSaver.c
new file mode 100644
index 000000000..fc124eb55
--- /dev/null
+++ b/nx-X11/lib/X11/GetSSaver.c
@@ -0,0 +1,57 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/GetSSaver.c,v 1.3 2001/01/17 19:41:37 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/GetStCmap.c b/nx-X11/lib/X11/GetStCmap.c
new file mode 100644
index 000000000..5c8c37e78
--- /dev/null
+++ b/nx-X11/lib/X11/GetStCmap.c
@@ -0,0 +1,118 @@
+/* $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.
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GetTxtProp.c b/nx-X11/lib/X11/GetTxtProp.c
new file mode 100644
index 000000000..0d4474253
--- /dev/null
+++ b/nx-X11/lib/X11/GetTxtProp.c
@@ -0,0 +1,114 @@
+/* $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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GetWAttrs.c b/nx-X11/lib/X11/GetWAttrs.c
new file mode 100644
index 000000000..05f1c1124
--- /dev/null
+++ b/nx-X11/lib/X11/GetWAttrs.c
@@ -0,0 +1,157 @@
+/* $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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+typedef struct _WAttrsState {
+ unsigned long attr_seq;
+ unsigned long geom_seq;
+ XWindowAttributes *attr;
+} _XWAttrsState;
+
+static Bool
+_XWAttrsHandler(
+ 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(
+ register Display *dpy,
+ Window w,
+ XWindowAttributes *attr)
+{
+ xGetGeometryReply rep;
+ register xResourceReq *req;
+ register int i;
+ register Screen *sp;
+ _XAsyncHandler async;
+ _XWAttrsState async_state;
+
+ 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);
+ return (0);
+ }
+ DeqAsyncHandler(dpy, &async);
+ if (!async_state.attr) {
+ 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;
+ }
+ }
+ return(1);
+}
+
+Status
+XGetWindowAttributes(
+ Display *dpy,
+ Window w,
+ XWindowAttributes *attr)
+{
+ Status ret;
+
+ LockDisplay(dpy);
+ ret = _XGetWindowAttributes(dpy, w, attr);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return ret;
+}
+
diff --git a/nx-X11/lib/X11/GetWMCMapW.c b/nx-X11/lib/X11/GetWMCMapW.c
new file mode 100644
index 000000000..6d5c73c85
--- /dev/null
+++ b/nx-X11/lib/X11/GetWMCMapW.c
@@ -0,0 +1,88 @@
+/* $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.
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GetWMProto.c b/nx-X11/lib/X11/GetWMProto.c
new file mode 100644
index 000000000..9b244ce6a
--- /dev/null
+++ b/nx-X11/lib/X11/GetWMProto.c
@@ -0,0 +1,88 @@
+/* $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.
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GrButton.c b/nx-X11/lib/X11/GrButton.c
new file mode 100644
index 000000000..9bb8b853b
--- /dev/null
+++ b/nx-X11/lib/X11/GrButton.c
@@ -0,0 +1,62 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/GrButton.c,v 1.3 2001/01/17 19:41:37 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/GrKey.c b/nx-X11/lib/X11/GrKey.c
new file mode 100644
index 000000000..ea6366199
--- /dev/null
+++ b/nx-X11/lib/X11/GrKey.c
@@ -0,0 +1,60 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/GrKey.c,v 1.3 2001/01/17 19:41:37 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/GrKeybd.c b/nx-X11/lib/X11/GrKeybd.c
new file mode 100644
index 000000000..af587926a
--- /dev/null
+++ b/nx-X11/lib/X11/GrKeybd.c
@@ -0,0 +1,59 @@
+/* $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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GrPointer.c b/nx-X11/lib/X11/GrPointer.c
new file mode 100644
index 000000000..39351f424
--- /dev/null
+++ b/nx-X11/lib/X11/GrPointer.c
@@ -0,0 +1,66 @@
+/* $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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/GrServer.c b/nx-X11/lib/X11/GrServer.c
new file mode 100644
index 000000000..bdb505137
--- /dev/null
+++ b/nx-X11/lib/X11/GrServer.c
@@ -0,0 +1,45 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/GrServer.c,v 1.3 2001/01/17 19:41:37 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XGrabServer (dpy)
+register Display *dpy;
+{
+ register xReq *req;
+ LockDisplay(dpy);
+ GetEmptyReq(GrabServer, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/HVC.c b/nx-X11/lib/X11/HVC.c
new file mode 100644
index 000000000..79241fb7a
--- /dev/null
+++ b/nx-X11/lib/X11/HVC.c
@@ -0,0 +1,611 @@
+/* $XdotOrg: xc/lib/X11/HVC.c,v 1.4 2005/07/03 07:00:55 daniels Exp $ */
+/* $Xorg: HVC.c,v 1.3 2000/08/17 19:44:36 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVC.c
+ *
+ * DESCRIPTION
+ * This file contains routines that support the TekHVC
+ * color space to include conversions to and from the CIE
+ * XYZ space.
+ *
+ * DOCUMENTATION
+ * "TekColor Color Management System, System Implementor's Manual"
+ */
+/* $XFree86: xc/lib/X11/HVC.c,v 1.3 2001/01/17 19:41:37 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <X11/Xos.h>
+#include <math.h>
+#include "Cv.h"
+
+#include <stdio.h>
+
+/*
+ * DEFINES
+ */
+#define u_BR 0.7127 /* u' Best Red */
+#define v_BR 0.4931 /* v' Best Red */
+#define EPS 0.001
+#define CHROMA_SCALE_FACTOR 7.50725
+#ifndef PI
+# ifdef M_PI
+# define PI M_PI
+# else
+# define PI 3.14159265358979323846264338327950
+# endif
+#endif
+#ifndef degrees
+# define degrees(r) ((XcmsFloat)(r) * 180.0 / PI)
+#endif /* degrees */
+#ifndef radians
+# define radians(d) ((XcmsFloat)(d) * PI / 180.0)
+#endif /* radians */
+
+/*************************************************************************
+ * Note: The DBL_EPSILON for ANSI is 1e-5 so my checks need to take
+ * this into account. If your DBL_EPSILON is different then
+ * adjust this define.
+ *
+ * Also note that EPS is the error factor in the calculations
+ * This may need to be the same as XMY_DBL_EPSILON in
+ * some implementations.
+ **************************************************************************/
+#ifdef DBL_EPSILON
+# define XMY_DBL_EPSILON DBL_EPSILON
+#else
+# define XMY_DBL_EPSILON 0.00001
+#endif
+
+/*
+ * FORWARD DECLARATIONS
+ */
+static int TekHVC_ParseString(register char *spec, XcmsColor *pColor);
+static Status XcmsTekHVC_ValidSpec(XcmsColor *pColor);
+
+/*
+ * LOCAL VARIABLES
+ */
+
+ /*
+ * NULL terminated list of functions applied to get from TekHVC to CIEXYZ
+ */
+static XcmsConversionProc Fl_TekHVC_to_CIEXYZ[] = {
+ XcmsTekHVCToCIEuvY,
+ XcmsCIEuvYToCIEXYZ,
+ NULL
+};
+
+ /*
+ * NULL terminated list of functions applied to get from CIEXYZ to TekHVC
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_TekHVC[] = {
+ XcmsCIEXYZToCIEuvY,
+ XcmsCIEuvYToTekHVC,
+ NULL
+};
+
+/*
+ * GLOBALS
+ */
+
+ /*
+ * TekHVC Color Space
+ */
+XcmsColorSpace XcmsTekHVCColorSpace =
+ {
+ _XcmsTekHVC_prefix, /* prefix */
+ XcmsTekHVCFormat, /* id */
+ TekHVC_ParseString, /* parseString */
+ Fl_TekHVC_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_TekHVC, /* from_CIEXYZ */
+ 1
+ };
+
+
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * TekHVC_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+TekHVC_ParseString(
+ register char *spec,
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsTekHVCFormat.
+ * The assumed TekHVC string syntax is:
+ * TekHVC:<H>/<V>/<C>
+ * Where H, V, and C are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ * XcmsFailure if invalid;
+ * XcmsSuccess if valid.
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsTekHVC_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.TekHVC.H,
+ &pColor->spec.TekHVC.V,
+ &pColor->spec.TekHVC.C) != 3) {
+ return(XcmsFailure);
+ }
+ pColor->format = XcmsTekHVCFormat;
+ pColor->pixel = 0;
+ return(XcmsTekHVC_ValidSpec(pColor));
+}
+
+
+/*
+ * NAME
+ * ThetaOffset -- compute thetaOffset
+ *
+ * SYNOPSIS
+ */
+static int
+ThetaOffset(
+ XcmsColor *pWhitePt,
+ XcmsFloat *pThetaOffset)
+/*
+ * DESCRIPTION
+ * This routine computes the theta offset of a given
+ * white point, i.e. XcmsColor. It is used in both this
+ * conversion and the printer conversions.
+ *
+ * RETURNS
+ * 0 if failed.
+ * 1 if succeeded with no modifications.
+ *
+ * ASSUMPTIONS
+ * Assumes:
+ * pWhitePt != NULL
+ * pWhitePt->format == XcmsCIEuvYFormat
+ *
+ */
+{
+ double div, slopeuv;
+
+ if (pWhitePt == NULL || pWhitePt->format != XcmsCIEuvYFormat) {
+ return(0);
+ }
+
+ if ((div = u_BR - pWhitePt->spec.CIEuvY.u_prime) == 0.0) {
+ return(0);
+ }
+ slopeuv = (v_BR - pWhitePt->spec.CIEuvY.v_prime) / div;
+ *pThetaOffset = degrees(XCMS_ATAN(slopeuv));
+ return(1);
+}
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVC_ValidSpec()
+ *
+ * SYNOPSIS
+ */
+static int
+XcmsTekHVC_ValidSpec(
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * Checks if values in the color specification are valid.
+ * Also brings hue into the range 0.0 <= Hue < 360.0
+ *
+ * RETURNS
+ * 0 if not valid.
+ * 1 if valid.
+ *
+ */
+{
+ if (pColor->format != XcmsTekHVCFormat) {
+ return(XcmsFailure);
+ }
+ if (pColor->spec.TekHVC.V < (0.0 - XMY_DBL_EPSILON)
+ || pColor->spec.TekHVC.V > (100.0 + XMY_DBL_EPSILON)
+ || (pColor->spec.TekHVC.C < 0.0 - XMY_DBL_EPSILON)) {
+ return(XcmsFailure);
+ }
+
+ if (pColor->spec.TekHVC.V < 0.0) {
+ pColor->spec.TekHVC.V = 0.0 + XMY_DBL_EPSILON;
+ } else if (pColor->spec.TekHVC.V > 100.0) {
+ pColor->spec.TekHVC.V = 100.0 - XMY_DBL_EPSILON;
+ }
+
+ if (pColor->spec.TekHVC.C < 0.0) {
+ pColor->spec.TekHVC.C = 0.0 - XMY_DBL_EPSILON;
+ }
+
+ while (pColor->spec.TekHVC.H < 0.0) {
+ pColor->spec.TekHVC.H += 360.0;
+ }
+ while (pColor->spec.TekHVC.H >= 360.0) {
+ pColor->spec.TekHVC.H -= 360.0;
+ }
+ return(XcmsSuccess);
+}
+
+/*
+ * NAME
+ * XcmsTekHVCToCIEuvY - convert TekHVC to CIEuvY
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCToCIEuvY(ccc, pHVC_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pHVC_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Transforms an array of TekHVC color specifications, given
+ * their associated white point, to CIECIEuvY.color
+ * specifications.
+ *
+ * RETURNS
+ * XcmsFailure if failed, XcmsSuccess otherwise.
+ *
+ */
+{
+ XcmsFloat thetaOffset;
+ XcmsColor *pColor = pColors_in_out;
+ XcmsColor whitePt;
+ XcmsCIEuvY uvY_return;
+ XcmsFloat tempHue, u, v;
+ XcmsFloat tmpVal;
+ register int i;
+
+ /*
+ * Check arguments
+ */
+ if (pHVC_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Make sure white point is in CIEuvY form
+ */
+ if (pHVC_WhitePt->format != XcmsCIEuvYFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pHVC_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL, 1,
+ XcmsCIEuvYFormat)) {
+ return(XcmsFailure);
+ }
+ pHVC_WhitePt = &whitePt;
+ }
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (pHVC_WhitePt->spec.CIEuvY.Y != 1.0) {
+ return(XcmsFailure);
+ }
+
+ /* Get the thetaOffset */
+ if (!ThetaOffset(pHVC_WhitePt, &thetaOffset)) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ /* Make sure original format is TekHVC and is valid */
+ if (!XcmsTekHVC_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ if (pColor->spec.TekHVC.V == 0.0 || pColor->spec.TekHVC.V == 100.0) {
+ if (pColor->spec.TekHVC.V == 100.0) {
+ uvY_return.Y = 1.0;
+ } else { /* pColor->spec.TekHVC.V == 0.0 */
+ uvY_return.Y = 0.0;
+ }
+ uvY_return.u_prime = pHVC_WhitePt->spec.CIEuvY.u_prime;
+ uvY_return.v_prime = pHVC_WhitePt->spec.CIEuvY.v_prime;
+ } else {
+
+ /* Find the hue based on the white point offset */
+ tempHue = pColor->spec.TekHVC.H + thetaOffset;
+
+ while (tempHue < 0.0) {
+ tempHue += 360.0;
+ }
+ while (tempHue >= 360.0) {
+ tempHue -= 360.0;
+ }
+
+ tempHue = radians(tempHue);
+
+ /* Calculate u'v' for the obtained hue */
+ u = (XcmsFloat) ((XCMS_COS(tempHue) * pColor->spec.TekHVC.C) /
+ (pColor->spec.TekHVC.V * (double)CHROMA_SCALE_FACTOR));
+ v = (XcmsFloat) ((XCMS_SIN(tempHue) * pColor->spec.TekHVC.C) /
+ (pColor->spec.TekHVC.V * (double)CHROMA_SCALE_FACTOR));
+
+ /* Based on the white point get the offset from best red */
+ uvY_return.u_prime = u + pHVC_WhitePt->spec.CIEuvY.u_prime;
+ uvY_return.v_prime = v + pHVC_WhitePt->spec.CIEuvY.v_prime;
+
+ /* Calculate the Y value based on the L* = V. */
+ if (pColor->spec.TekHVC.V < 7.99953624) {
+ uvY_return.Y = pColor->spec.TekHVC.V / 903.29;
+ } else {
+ tmpVal = (pColor->spec.TekHVC.V + 16.0) / 116.0;
+ uvY_return.Y = tmpVal * tmpVal * tmpVal; /* tmpVal ** 3 */
+ }
+ }
+
+ /* Copy result to pColor */
+ memcpy((char *)&pColor->spec, (char *)&uvY_return, sizeof(XcmsCIEuvY));
+
+ /* Identify that the format is now CIEuvY */
+ pColor->format = XcmsCIEuvYFormat;
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEuvYToTekHVC - convert CIEuvY to TekHVC
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIEuvYToTekHVC(ccc, pHVC_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pHVC_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Transforms an array of CIECIEuvY.color specifications, given
+ * their assiciated white point, to TekHVC specifications.
+ *
+ * RETURNS
+ * XcmsFailure if failed, XcmsSuccess otherwise.
+ *
+ */
+{
+ XcmsFloat theta, L2, u, v, nThetaLow, nThetaHigh;
+ XcmsFloat thetaOffset;
+ XcmsColor *pColor = pColors_in_out;
+ XcmsColor whitePt;
+ XcmsTekHVC HVC_return;
+ register int i;
+
+ /*
+ * Check arguments
+ */
+ if (pHVC_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Make sure white point is in CIEuvY form
+ */
+ if (pHVC_WhitePt->format != XcmsCIEuvYFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pHVC_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL, 1,
+ XcmsCIEuvYFormat)) {
+ return(XcmsFailure);
+ }
+ pHVC_WhitePt = &whitePt;
+ }
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (pHVC_WhitePt->spec.CIEuvY.Y != 1.0) {
+ return(XcmsFailure);
+ }
+ if (!ThetaOffset(pHVC_WhitePt, &thetaOffset)) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+ if (!_XcmsCIEuvY_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ /* Use the white point offset to determine HVC */
+ u = pColor->spec.CIEuvY.u_prime - pHVC_WhitePt->spec.CIEuvY.u_prime;
+ v = pColor->spec.CIEuvY.v_prime - pHVC_WhitePt->spec.CIEuvY.v_prime;
+
+ /* Calculate the offset */
+ if (u == 0.0) {
+ theta = 0.0;
+ } else {
+ theta = v / u;
+ theta = (XcmsFloat) XCMS_ATAN((double)theta);
+ theta = degrees(theta);
+ }
+
+ nThetaLow = 0.0;
+ nThetaHigh = 360.0;
+ if (u > 0.0 && v > 0.0) {
+ nThetaLow = 0.0;
+ nThetaHigh = 90.0;
+ } else if (u < 0.0 && v > 0.0) {
+ nThetaLow = 90.0;
+ nThetaHigh = 180.0;
+ } else if (u < 0.0 && v < 0.0) {
+ nThetaLow = 180.0;
+ nThetaHigh = 270.0;
+ } else if (u > 0.0 && v < 0.0) {
+ nThetaLow = 270.0;
+ nThetaHigh = 360.0;
+ }
+ while (theta < nThetaLow) {
+ theta += 90.0;
+ }
+ while (theta >= nThetaHigh) {
+ theta -= 90.0;
+ }
+
+ /* calculate the L value from the given Y */
+ L2 = (pColor->spec.CIEuvY.Y < 0.008856)
+ ?
+ (pColor->spec.CIEuvY.Y * 903.29)
+ :
+ ((XcmsFloat)(XCMS_CUBEROOT(pColor->spec.CIEuvY.Y) * 116.0) - 16.0);
+ HVC_return.C = L2 * CHROMA_SCALE_FACTOR * XCMS_SQRT((double) ((u * u) + (v * v)));
+ if (HVC_return.C < 0.0) {
+ theta = 0.0;
+ }
+ HVC_return.V = L2;
+ HVC_return.H = theta - thetaOffset;
+
+ /*
+ * If this is within the error margin let some other routine later
+ * in the chain worry about the slop in the calculations.
+ */
+ while (HVC_return.H < -EPS) {
+ HVC_return.H += 360.0;
+ }
+ while (HVC_return.H >= 360.0 + EPS) {
+ HVC_return.H -= 360.0;
+ }
+
+ /* Copy result to pColor */
+ memcpy((char *)&pColor->spec, (char *)&HVC_return, sizeof(XcmsTekHVC));
+
+ /* Identify that the format is now CIEuvY */
+ pColor->format = XcmsTekHVCFormat;
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * _XcmsTekHVC_CheckModify
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsTekHVC_CheckModify(
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * Checks if values in the color specification are valid.
+ * If they are not it modifies the values.
+ * Also brings hue into the range 0.0 <= Hue < 360.0
+ *
+ * RETURNS
+ * 0 if not valid.
+ * 1 if valid.
+ *
+ */
+{
+ int n;
+
+ /* For now only use the TekHVC numbers as inputs */
+ if (pColor->format != XcmsTekHVCFormat) {
+ return(0);
+ }
+
+ if (pColor->spec.TekHVC.V < 0.0) {
+ pColor->spec.TekHVC.V = 0.0 + XMY_DBL_EPSILON;
+ } else if (pColor->spec.TekHVC.V > 100.0) {
+ pColor->spec.TekHVC.V = 100.0 - XMY_DBL_EPSILON;
+ }
+
+ if (pColor->spec.TekHVC.C < 0.0) {
+ pColor->spec.TekHVC.C = 0.0 - XMY_DBL_EPSILON;
+ }
+
+ if (pColor->spec.TekHVC.H < 0.0) {
+ n = -pColor->spec.TekHVC.H / 360.0;
+ pColor->spec.TekHVC.H += (n + 1) * 360.0;
+ if (pColor->spec.TekHVC.H >= 360.0)
+ pColor->spec.TekHVC.H -= 360.0;
+ } else if (pColor->spec.TekHVC.H >= 360.0) {
+ n = pColor->spec.TekHVC.H / 360.0;
+ pColor->spec.TekHVC.H -= n * 360.0;
+ }
+ return(1);
+}
diff --git a/nx-X11/lib/X11/HVCGcC.c b/nx-X11/lib/X11/HVCGcC.c
new file mode 100644
index 000000000..10e0d487d
--- /dev/null
+++ b/nx-X11/lib/X11/HVCGcC.c
@@ -0,0 +1,151 @@
+/* $Xorg: HVCGcC.c,v 1.3 2000/08/17 19:44:36 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCGcC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsTekHVCClipC() gamut compression routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/HVCGcC.c,v 1.3 2001/01/17 19:41:37 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCClipC - Reduce the chroma for a hue and value
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsTekHVCClipC (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Reduce the Chroma for a specific hue and value to
+ * to bring the given color into the gamut of the
+ * specified device. As required of gamut compression
+ * functions in Xcms, this routine returns pColor_in_out
+ * in XcmsCIEXYZFormat on successful completion.
+ *
+ * Since this routine works with the value within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ Status retval;
+ XcmsColor *pColor;
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor &&
+ FunctionSetOfCCC(ccc) != (XPointer) &XcmsLinearRGBFunctionSet) {
+ /*
+ * GRAY !
+ */
+ _XcmsDIConvertColors(ccc, pColor, &ccc->pPerScrnInfo->screenWhitePt,
+ 1, XcmsTekHVCFormat);
+ pColor->spec.TekHVC.H = pColor->spec.TekHVC.C = 0.0;
+ _XcmsDIConvertColors(ccc, pColor, &ccc->pPerScrnInfo->screenWhitePt,
+ 1, XcmsCIEXYZFormat);
+ if (pCompressed) {
+ *(pCompressed + i) = True;
+ }
+ return(XcmsSuccess);
+ } else {
+ if (pColor->format != XcmsTekHVCFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsTekHVCQueryMaxC(ccc,
+ pColor->spec.TekHVC.H,
+ pColor->spec.TekHVC.V,
+ pColor)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/nx-X11/lib/X11/HVCGcV.c b/nx-X11/lib/X11/HVCGcV.c
new file mode 100644
index 000000000..4e2c63688
--- /dev/null
+++ b/nx-X11/lib/X11/HVCGcV.c
@@ -0,0 +1,203 @@
+/* $Xorg: HVCGcV.c,v 1.3 2000/08/17 19:44:36 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCGcV.c
+ *
+ * DESCRIPTION
+ * Source for XcmsTekHVCClipV() gamut compression routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/HVCGcV.c,v 1.3 2001/01/17 19:41:37 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCClipV - Return the closest value
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsTekHVCClipV (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Return the closest value for a specific hue and chroma.
+ * This routine takes any color as input and outputs
+ * a CIE XYZ color.
+ *
+ * Since this routine works with the value within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsColor *pColor;
+ XcmsColor hvc_max;
+ XcmsCCCRec myCCC;
+ Status retval;
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* Inherit Screen WP */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut compression */
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor &&
+ FunctionSetOfCCC(ccc) != (XPointer) &XcmsLinearRGBFunctionSet) {
+ /*
+ * GRAY !
+ */
+ return(XcmsFailure);
+ } else {
+ /* Convert from CIEXYZ to TekHVC format */
+ if (_XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* check to make sure we have a valid TekHVC number */
+ if (!_XcmsTekHVC_CheckModify (pColor)) {
+ return (XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum value and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ memcpy((char *)&hvc_max, (char *)pColor, sizeof(XcmsColor));
+ if (_XcmsTekHVCQueryMaxVCRGB (&myCCC, hvc_max.spec.TekHVC.H, &hvc_max,
+ (XcmsRGBi *)NULL) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+
+ /* Now check and return the appropriate value */
+ if (pColor->spec.TekHVC.C == hvc_max.spec.TekHVC.C) {
+ /* When the chroma input is equal to the maximum chroma */
+ /* merely return the value for that chroma. */
+ pColor->spec.TekHVC.V = hvc_max.spec.TekHVC.V;
+ if (!_XcmsTekHVC_CheckModify (pColor)) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ } else if (pColor->spec.TekHVC.C > hvc_max.spec.TekHVC.C) {
+ /* When the chroma input is greater than the maximum chroma */
+ /* merely return the value and chroma for the given hue. */
+ pColor->spec.TekHVC.C = hvc_max.spec.TekHVC.C;
+ pColor->spec.TekHVC.V = hvc_max.spec.TekHVC.V;
+ return (XcmsFailure);
+ } else if (pColor->spec.TekHVC.V < hvc_max.spec.TekHVC.V) {
+ /* When the value input is less than the maximum value point */
+ /* compute the intersection of the line from 0,0 to max_V, max_C */
+ /* using the chroma input. */
+ pColor->spec.TekHVC.V = pColor->spec.TekHVC.C *
+ hvc_max.spec.TekHVC.V / hvc_max.spec.TekHVC.C;
+ if (pColor->spec.TekHVC.V >= hvc_max.spec.TekHVC.V) {
+ pColor->spec.TekHVC.C = hvc_max.spec.TekHVC.C;
+ pColor->spec.TekHVC.V = hvc_max.spec.TekHVC.V;
+ }
+ if (!_XcmsTekHVC_CheckModify (pColor)) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ } else {
+ /* When the value input is greater than the maximum value point */
+ /* use HvcMaxValue to find the maximum value for the given chroma. */
+ if (pColor->format != XcmsTekHVCFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsTekHVCQueryMaxV(&myCCC,
+ pColor->spec.TekHVC.H,
+ pColor->spec.TekHVC.C,
+ pColor)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ }
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/nx-X11/lib/X11/HVCGcVC.c b/nx-X11/lib/X11/HVCGcVC.c
new file mode 100644
index 000000000..eef20ae81
--- /dev/null
+++ b/nx-X11/lib/X11/HVCGcVC.c
@@ -0,0 +1,264 @@
+/* $Xorg: HVCGcVC.c,v 1.3 2000/08/17 19:44:36 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCGcVC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsTekHVCClipVC() gamut
+ * compression function.
+ */
+/* $XFree86: xc/lib/X11/HVCGcVC.c,v 1.3 2001/01/17 19:41:37 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+#include "Cv.h"
+
+/*
+ * INTERNALS
+ * Internal defines that need NOT be exported to any package or
+ * program using this package.
+ */
+#define MAXBISECTCOUNT 100
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCClipVC - Return the closest value and chroma
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsTekHVCClipVC (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * This routine will find the closest value and chroma
+ * for a specific hue. The color input is converted to
+ * HVC format and returned as CIE XYZ format.
+ *
+ * Since this routine works with the value within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ Status retval;
+ XcmsCCCRec myCCC;
+ XcmsColor *pColor;
+ XcmsColor hvc_max;
+ XcmsRGBi rgb_max;
+ int nCount, nMaxCount, nI, nILast;
+ XcmsFloat Chroma, Value, bestChroma, bestValue, nT, saveDist, tmpDist;
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* inherit screen white pt */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut compression func */
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor &&
+ FunctionSetOfCCC(ccc) != (XPointer) &XcmsLinearRGBFunctionSet) {
+ /*
+ * GRAY !
+ */
+ _XcmsDIConvertColors(ccc, pColor, &ccc->pPerScrnInfo->screenWhitePt,
+ 1, XcmsTekHVCFormat);
+ pColor->spec.TekHVC.H = pColor->spec.TekHVC.C = 0.0;
+ _XcmsDIConvertColors(ccc, pColor, &ccc->pPerScrnInfo->screenWhitePt,
+ 1, XcmsCIEXYZFormat);
+ if (pCompressed) {
+ *(pCompressed + i) = True;
+ }
+ return(XcmsSuccess);
+ } else {
+ /* Convert from CIEXYZ to TekHVC format */
+ if (_XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ if (!_XcmsTekHVC_CheckModify(pColor)) {
+ return (XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum value and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ memcpy((char *)&hvc_max, (char *)pColor, sizeof(XcmsColor));
+ if (_XcmsTekHVCQueryMaxVCRGB (&myCCC, hvc_max.spec.TekHVC.H, &hvc_max,
+ &rgb_max) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+
+ /* Now check and return the appropriate value */
+ if (pColor->spec.TekHVC.V == hvc_max.spec.TekHVC.V) {
+ /* When the value input is equal to the maximum value */
+ /* merely return the chroma for that value. */
+ pColor->spec.TekHVC.C = hvc_max.spec.TekHVC.C;
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ }
+
+ if (pColor->spec.TekHVC.V < hvc_max.spec.TekHVC.V) {
+ /* return the intersection of the perpindicular line through */
+ /* the value and chroma given and the line from 0,0 and hvc_max. */
+ Chroma = pColor->spec.TekHVC.C;
+ Value = pColor->spec.TekHVC.V;
+ pColor->spec.TekHVC.C =
+ (Value + (hvc_max.spec.TekHVC.C / hvc_max.spec.TekHVC.V * Chroma)) /
+ ((hvc_max.spec.TekHVC.V / hvc_max.spec.TekHVC.C) +
+ (hvc_max.spec.TekHVC.C / hvc_max.spec.TekHVC.V));
+ if (pColor->spec.TekHVC.C >= hvc_max.spec.TekHVC.C) {
+ pColor->spec.TekHVC.C = hvc_max.spec.TekHVC.C;
+ pColor->spec.TekHVC.V = hvc_max.spec.TekHVC.V;
+ } else {
+ pColor->spec.TekHVC.V = pColor->spec.TekHVC.C *
+ hvc_max.spec.TekHVC.V / hvc_max.spec.TekHVC.C;
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return (retval);
+ }
+
+ /* return the closest point on the upper part of the hue leaf. */
+ /* must do a bisection here to compute the delta e. */
+ nMaxCount = MAXBISECTCOUNT;
+ nI = nMaxCount / 2;
+ bestValue = Value = pColor->spec.TekHVC.V;
+ bestChroma = Chroma = pColor->spec.TekHVC.C;
+ saveDist = (XcmsFloat) XCMS_SQRT ((double) (((Chroma - hvc_max.spec.TekHVC.C) *
+ (Chroma - hvc_max.spec.TekHVC.C)) +
+ ((Value - hvc_max.spec.TekHVC.V) *
+ (Value - hvc_max.spec.TekHVC.V))));
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ nT = (XcmsFloat) nI / (XcmsFloat) nMaxCount;
+ pColor->spec.RGBi.red = rgb_max.red * (1.0 - nT) + nT;
+ pColor->spec.RGBi.green = rgb_max.green * (1.0 - nT) + nT;
+ pColor->spec.RGBi.blue = rgb_max.blue * (1.0 - nT) + nT;
+ pColor->format = XcmsRGBiFormat;
+
+ /* Convert from RGBi to HVC */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat,
+ (Bool *) NULL)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ if (!_XcmsTekHVC_CheckModify(pColor)) {
+ return (XcmsFailure);
+ }
+ tmpDist = (XcmsFloat) XCMS_SQRT ((double)
+ (((Chroma - pColor->spec.TekHVC.C) *
+ (Chroma - pColor->spec.TekHVC.C)) +
+ ((Value - pColor->spec.TekHVC.V) *
+ (Value - pColor->spec.TekHVC.V))));
+ nILast = nI;
+ if (tmpDist > saveDist) {
+ nI /= 2;
+ } else {
+ nI = (nMaxCount + nI) / 2;
+ saveDist = tmpDist;
+ bestValue = pColor->spec.TekHVC.V;
+ bestChroma = pColor->spec.TekHVC.C;
+ }
+ if (nI == nILast || nI == 0) {
+ break;
+ }
+
+ }
+
+ if (bestChroma >= hvc_max.spec.TekHVC.C) {
+ pColor->spec.TekHVC.C = hvc_max.spec.TekHVC.C;
+ pColor->spec.TekHVC.V = hvc_max.spec.TekHVC.V;
+ } else {
+ pColor->spec.TekHVC.C = bestChroma;
+ pColor->spec.TekHVC.V = bestValue;
+ }
+ if (!_XcmsTekHVC_CheckModify(pColor)) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/nx-X11/lib/X11/HVCMnV.c b/nx-X11/lib/X11/HVCMnV.c
new file mode 100644
index 000000000..63a510888
--- /dev/null
+++ b/nx-X11/lib/X11/HVCMnV.c
@@ -0,0 +1,165 @@
+/* $Xorg: HVCMnV.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCMnV.c
+ *
+ * DESCRIPTION
+ * Source for XcmsTekHVCQueryMinV gamut boundary querying routine.
+ *
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define EPS 0.001
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCQueryMinV - Compute minimum value for hue and chroma
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCQueryMinV (ccc, hue, chroma, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue;
+ XcmsFloat chroma;
+ XcmsColor *pColor_return;
+
+/*
+ * DESCRIPTION
+ * Return the minimum value for a specific hue, and the
+ * corresponding chroma. The input color specification
+ * may be in any format, however output is in XcmsTekHVCFormat.
+ *
+ * Since this routine works with the value within
+ * pColor_return intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded with no modifications
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor tmp;
+ XcmsColor max_vc;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* inherit screen white pt */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut comp func */
+
+ tmp.spec.TekHVC.H = hue;
+ tmp.spec.TekHVC.V = 100.0;
+ tmp.spec.TekHVC.C = chroma;
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsTekHVCFormat;
+
+
+ /* Check for a valid HVC */
+ if (!_XcmsTekHVC_CheckModify (&tmp)) {
+ return(XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum value and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ memcpy((char *)&max_vc, (char *)&tmp, sizeof(XcmsColor));
+ if (_XcmsTekHVCQueryMaxVCRGB (&myCCC, max_vc.spec.TekHVC.H, &max_vc,
+ (XcmsRGBi *)NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Step 2: find the intersection with the maximum hvc and chroma line. */
+ if (tmp.spec.TekHVC.C > max_vc.spec.TekHVC.C + EPS) {
+ /* If the chroma is to large then return maximum hvc. */
+ tmp.spec.TekHVC.C = max_vc.spec.TekHVC.C;
+ tmp.spec.TekHVC.V = max_vc.spec.TekHVC.V;
+ } else {
+ tmp.spec.TekHVC.V = tmp.spec.TekHVC.C *
+ max_vc.spec.TekHVC.V / max_vc.spec.TekHVC.C;
+ if (tmp.spec.TekHVC.V > max_vc.spec.TekHVC.V) {
+ tmp.spec.TekHVC.V = max_vc.spec.TekHVC.V;
+ } else if (tmp.spec.TekHVC.V < 0.0) {
+ tmp.spec.TekHVC.V = tmp.spec.TekHVC.C = 0.0;
+ }
+ }
+ if (_XcmsTekHVC_CheckModify (&tmp)) {
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ } else {
+ return(XcmsFailure);
+ }
+}
diff --git a/nx-X11/lib/X11/HVCMxC.c b/nx-X11/lib/X11/HVCMxC.c
new file mode 100644
index 000000000..64e7713e4
--- /dev/null
+++ b/nx-X11/lib/X11/HVCMxC.c
@@ -0,0 +1,245 @@
+/* $Xorg: HVCMxC.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCMxC.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsTekHVCQueryMaxC() gamut boudary
+ * querying routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/HVCMxC.c,v 1.4 2003/04/13 19:22:16 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS 0.001
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCQueryMaxC - Compute the maximum chroma for a hue and value
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCQueryMaxC(ccc, hue, value, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue;
+ XcmsFloat value;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum chroma for a specific hue and value.
+ * The returned format is in XcmsTekHVCFormat.
+ *
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor tmp;
+ XcmsColor max_vc;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+ XcmsFloat nValue, savedValue, lastValue, lastChroma, prevValue;
+ XcmsFloat maxDist, nT, rFactor;
+ XcmsFloat ftmp1, ftmp2;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat; /* inherit screen white Pt */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut comp func */
+
+ tmp.spec.TekHVC.H = hue;
+ tmp.spec.TekHVC.V = value;
+ tmp.spec.TekHVC.C = 100.0;
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsTekHVCFormat;
+
+ /* check to make sure we have a valid TekHVC number */
+ if (!_XcmsTekHVC_CheckModify(&tmp)) {
+ return(XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum value and chroma for this hue. */
+ memcpy((char *)&max_vc, (char *)&tmp, sizeof(XcmsColor));
+ if (_XcmsTekHVCQueryMaxVCRGB(&myCCC, hue, &max_vc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Step 2: If the value is less than the value for the maximum */
+ /* value, chroma point then the chroma is on the line */
+ /* from max_vc to 0,0. */
+ if (value <= max_vc.spec.TekHVC.V) {
+ tmp.spec.TekHVC.C = value
+ * max_vc.spec.TekHVC.C / max_vc.spec.TekHVC.V;
+ if (_XcmsTekHVC_CheckModify (&tmp)) {
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+ } else {
+ return(XcmsFailure);
+ }
+ } else {
+ /* must do a bisection here to compute the maximum chroma */
+ /* save the structure input so that any elements that */
+ /* are not touched are recopied later in the routine. */
+ nValue = savedValue = value;
+ lastChroma = -1.0;
+ lastValue = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ maxDist = 100.0 - max_vc.spec.TekHVC.V;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prevValue = lastValue;
+ lastValue = tmp.spec.TekHVC.V;
+ lastChroma = tmp.spec.TekHVC.C;
+ nT = (nValue - max_vc.spec.TekHVC.V) / maxDist * rFactor;
+ tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to HVC */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Now check the return against what is expected */
+ if (tmp.spec.TekHVC.V <= savedValue + EPS &&
+ tmp.spec.TekHVC.V >= savedValue - EPS) {
+ /* make sure to return the input hue */
+ tmp.spec.TekHVC.H = hue;
+ if (_XcmsTekHVC_CheckModify (&tmp)) {
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+ } else {
+ return(XcmsFailure);
+ }
+ }
+ nValue += savedValue - tmp.spec.TekHVC.V;
+ if (nValue < max_vc.spec.TekHVC.V) {
+ nValue = max_vc.spec.TekHVC.V;
+ rFactor *= 0.5; /* selective relaxation employed */
+ } else if (nValue > 100.0) {
+ /* make sure to return the input hue */
+ tmp.spec.TekHVC.H = hue;
+ /* avoid using fabs */
+ ftmp1 = lastValue - savedValue;
+ if (ftmp1 < 0.0)
+ ftmp1 = -ftmp1;
+ ftmp2 = tmp.spec.TekHVC.V - savedValue;
+ if (ftmp2 < 0.0)
+ ftmp2 = -ftmp2;
+ if (ftmp1 < ftmp2) {
+ tmp.spec.TekHVC.V = lastValue;
+ tmp.spec.TekHVC.C = lastChroma;
+ }
+ if (_XcmsTekHVC_CheckModify (&tmp)) {
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+ } else {
+ return(XcmsFailure);
+ }
+ } else if (tmp.spec.TekHVC.V <= prevValue + EPS &&
+ tmp.spec.TekHVC.V >= prevValue - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ }
+ }
+ if (nCount >= nMaxCount) {
+ /* avoid using fabs */
+ ftmp1 = lastValue - savedValue;
+ if (ftmp1 < 0.0)
+ ftmp1 = -ftmp1;
+ ftmp2 = tmp.spec.TekHVC.V - savedValue;
+ if (ftmp2 < 0.0)
+ ftmp2 = -ftmp2;
+ if (ftmp1 < ftmp2) {
+ tmp.spec.TekHVC.V = lastValue;
+ tmp.spec.TekHVC.C = lastChroma;
+ }
+ }
+ }
+ /* make sure to return the input hue */
+ tmp.spec.TekHVC.H = hue;
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/HVCMxV.c b/nx-X11/lib/X11/HVCMxV.c
new file mode 100644
index 000000000..34acdade0
--- /dev/null
+++ b/nx-X11/lib/X11/HVCMxV.c
@@ -0,0 +1,249 @@
+/* $Xorg: HVCMxV.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCMxV.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsTekHVCQueryMaxV() gamut boundary
+ * querying routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/HVCMxV.c,v 1.4 2003/04/13 19:22:16 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS 0.001
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCQueryMaxV - Compute maximum value for a hue and chroma
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCQueryMaxV(ccc, hue, chroma, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue;
+ XcmsFloat chroma;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum value for a specified hue and chroma.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded with no modifications
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor tmp;
+ XcmsColor max_vc;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+ XcmsFloat nT, nChroma, savedChroma, lastValue, lastChroma, prevChroma;
+ XcmsFloat rFactor;
+ XcmsFloat ftmp1, ftmp2;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* setup the CCC to use for the conversions. */
+ memcpy ((char *) &myCCC, (char *) ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc) NULL;
+
+ tmp.spec.TekHVC.H = hue;
+ tmp.spec.TekHVC.V = 0.0;
+ tmp.spec.TekHVC.C = chroma;
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsTekHVCFormat;
+
+ if (!_XcmsTekHVC_CheckModify (&tmp)) {
+ return(XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum value and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ memcpy((char *)&max_vc, (char *)&tmp, sizeof(XcmsColor));
+ hue = max_vc.spec.TekHVC.H;
+ if (_XcmsTekHVCQueryMaxVCRGB(&myCCC, max_vc.spec.TekHVC.H, &max_vc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ if (max_vc.spec.TekHVC.C < tmp.spec.TekHVC.C) {
+ /*
+ * If the chroma is greater than the chroma for the
+ * maximum value/chroma point then the value is the
+ * the value for the maximum value, chroma point.
+ * This is an error but it I return the best approximation I can.
+ * Thus the inconsistency.
+ */
+ tmp.spec.TekHVC.C = max_vc.spec.TekHVC.C;
+ tmp.spec.TekHVC.V = max_vc.spec.TekHVC.V;
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ } else if (max_vc.spec.TekHVC.C == tmp.spec.TekHVC.C) {
+ /*
+ * If the chroma is equal to the chroma for the
+ * maximum value/chroma point then the value is the
+ * the value for the maximum value, chroma point.
+ */
+ tmp.spec.TekHVC.V = max_vc.spec.TekHVC.V;
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ } else {
+ /* must do a bisection here to compute the maximum value */
+ /* save the structure input so that any elements that */
+ /* are not touched are recopied later in the routine. */
+ nChroma = savedChroma = tmp.spec.TekHVC.C;
+ tmp.spec.TekHVC.C = max_vc.spec.TekHVC.C;
+ tmp.spec.TekHVC.V = max_vc.spec.TekHVC.V;
+ lastChroma = -1.0;
+ lastValue = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prevChroma = lastChroma;
+ lastValue = tmp.spec.TekHVC.V;
+ lastChroma = tmp.spec.TekHVC.C;
+ nT = (1.0 - (nChroma / max_vc.spec.TekHVC.C)) * rFactor;
+ tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to HVC */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Now check the return against what is expected */
+ if (tmp.spec.TekHVC.C <= savedChroma + EPS &&
+ tmp.spec.TekHVC.C >= savedChroma - EPS) {
+ tmp.spec.TekHVC.H = hue; /* use the saved hue */
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+ nChroma += savedChroma - tmp.spec.TekHVC.C;
+ if (nChroma > max_vc.spec.TekHVC.C) {
+ nChroma = max_vc.spec.TekHVC.C;
+ rFactor *= 0.5; /* selective relaxation employed */
+ } else if (nChroma < 0.0) {
+ /* avoid using fabs */
+ ftmp1 = lastChroma - savedChroma;
+ if (ftmp1 < 0.0)
+ ftmp1 = -ftmp1;
+ ftmp2 = tmp.spec.TekHVC.C - savedChroma;
+ if (ftmp2 < 0.0)
+ ftmp2 = -ftmp2;
+ if (ftmp1 < ftmp2) {
+ tmp.spec.TekHVC.V = lastValue;
+ tmp.spec.TekHVC.C = lastChroma;
+ }
+ /* make sure to return the input hue */
+ tmp.spec.TekHVC.H = hue;
+ if (!_XcmsTekHVC_CheckModify(&tmp)) {
+ return(XcmsFailure);
+ }
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ } else if (tmp.spec.TekHVC.C <= prevChroma + EPS &&
+ tmp.spec.TekHVC.C >= prevChroma - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ }
+ }
+ if (nCount >= nMaxCount) {
+ /* avoid using fabs */
+ ftmp1 = lastChroma - savedChroma;
+ if (ftmp1 < 0.0)
+ ftmp1 = -ftmp1;
+ ftmp2 = tmp.spec.TekHVC.C - savedChroma;
+ if (ftmp2 < 0.0)
+ ftmp2 = -ftmp2;
+ if (ftmp1 < ftmp2) {
+ tmp.spec.TekHVC.V = lastValue;
+ tmp.spec.TekHVC.C = lastChroma;
+ }
+ }
+ }
+
+ /* make sure to return the input hue */
+ tmp.spec.TekHVC.H = hue;
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/HVCMxVC.c b/nx-X11/lib/X11/HVCMxVC.c
new file mode 100644
index 000000000..74183fcf5
--- /dev/null
+++ b/nx-X11/lib/X11/HVCMxVC.c
@@ -0,0 +1,237 @@
+/* $Xorg: HVCMxVC.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCMxVC.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsTekHVCQueryMaxVC() gamut boundary
+ * querying routine.
+ *
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define MIN(x,y) ((x) > (y) ? (y) : (x))
+#define MIN3(x,y,z) ((x) > (MIN((y), (z))) ? (MIN((y), (z))) : (x))
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+#define MAX3(x,y,z) ((x) > (MAX((y), (z))) ? (x) : (MAX((y), (z))))
+#define START_V 40.0
+#define START_C 120.0
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsTekHVCQueryMaxVCRGB - Compute maximum value/chroma.
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsTekHVCQueryMaxVCRGB(
+ XcmsCCC ccc,
+ XcmsFloat hue,
+ XcmsColor *pColor_return,
+ XcmsRGBi *pRGB_return)
+
+/*
+ * DESCRIPTION
+ * Return the maximum chroma for a specified hue, and the
+ * corresponding value. This is computed by a binary search of
+ * all possible chromas. An assumption is made that there are
+ * no local maxima. Use the unrounded Max Chroma because
+ * the difference check can be small.
+ *
+ * NOTE: No local CCC is used because this is a private
+ * routine and all routines that call it are expected
+ * to behave properly, i.e. send a local CCC with
+ * no white adjust function and no gamut compression
+ * function.
+ *
+ * This routine only accepts hue as input and outputs
+ * HVC's and RGBi's.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XCMS_SUCCUSS - Succeeded
+ *
+ */
+{
+ XcmsFloat nSmall, nLarge;
+ XcmsColor tmp;
+
+ tmp.format = XcmsTekHVCFormat;
+ tmp.spec.TekHVC.H = hue;
+ /* Use some unreachable color on the given hue */
+ tmp.spec.TekHVC.V = START_V;
+ tmp.spec.TekHVC.C = START_C;
+
+
+ /*
+ * Convert from HVC to RGB
+ *
+ * Note that the CIEXYZ to RGBi conversion routine must stuff the
+ * out of bounds RGBi values in tmp when the ccc->gamutCompProc
+ * is NULL.
+ */
+ if ((_XcmsConvertColorsWithWhitePt(ccc, &tmp,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsRGBiFormat, (Bool *) NULL)
+ == XcmsFailure) && tmp.format != XcmsRGBiFormat) {
+ return (XcmsFailure);
+ }
+
+ /* Now pick the smallest RGB */
+ nSmall = MIN3(tmp.spec.RGBi.red,
+ tmp.spec.RGBi.green,
+ tmp.spec.RGBi.blue);
+ /* Make the smallest RGB equal to zero */
+ tmp.spec.RGBi.red -= nSmall;
+ tmp.spec.RGBi.green -= nSmall;
+ tmp.spec.RGBi.blue -= nSmall;
+
+ /* Now pick the largest RGB */
+ nLarge = MAX3(tmp.spec.RGBi.red,
+ tmp.spec.RGBi.green,
+ tmp.spec.RGBi.blue);
+ /* Scale the RGB values based on the largest one */
+ tmp.spec.RGBi.red /= nLarge;
+ tmp.spec.RGBi.green /= nLarge;
+ tmp.spec.RGBi.blue /= nLarge;
+ tmp.format = XcmsRGBiFormat;
+
+ /* If the calling routine wants RGB value give them the ones used. */
+ if (pRGB_return) {
+ pRGB_return->red = tmp.spec.RGBi.red;
+ pRGB_return->green = tmp.spec.RGBi.green;
+ pRGB_return->blue = tmp.spec.RGBi.blue;
+ }
+
+ /* Convert from RGBi to HVC */
+ if (_XcmsConvertColorsWithWhitePt(ccc, &tmp,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat, (Bool *) NULL)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+
+ /* make sure to return the input hue */
+ tmp.spec.TekHVC.H = hue;
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return (XcmsSuccess);
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCQueryMaxVC - Compute maximum value and chroma.
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCQueryMaxVC (ccc, hue, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue;
+ XcmsColor *pColor_return;
+
+/*
+ * DESCRIPTION
+ * Return the maximum chroma for the specified hue, and the
+ * corresponding value.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;
+
+ while (hue < 0.0) {
+ hue += 360.0;
+ }
+ while (hue >= 360.0) {
+ hue -= 360.0;
+ }
+
+ return(_XcmsTekHVCQueryMaxVCRGB (&myCCC, hue, pColor_return,
+ (XcmsRGBi *)NULL));
+}
diff --git a/nx-X11/lib/X11/HVCMxVs.c b/nx-X11/lib/X11/HVCMxVs.c
new file mode 100644
index 000000000..d90afa8be
--- /dev/null
+++ b/nx-X11/lib/X11/HVCMxVs.c
@@ -0,0 +1,163 @@
+/* $Xorg: HVCMxVs.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCMxVs.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsTekHVCQueryMaxVSamples() gamut boundary
+ * querying routine.
+ */
+/* $XFree86: xc/lib/X11/HVCMxVs.c,v 1.3 2001/01/17 19:41:37 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCQueryMaxVSamples - Compute a set of value/chroma
+ * pairs.
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCQueryMaxVSamples(ccc, hue, pColor_in_out, nSamples)
+ XcmsCCC ccc;
+ XcmsFloat hue;
+ XcmsColor *pColor_in_out;
+ unsigned int nSamples;
+
+/*
+ * DESCRIPTION
+ * Return a set of values and chromas for the input Hue.
+ * This routine will take any color as input.
+ * It returns TekHVC colors.
+ *
+ * Since this routine works with the value within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor *pHVC;
+ XcmsRGBi rgb_saved;
+ unsigned short nI;
+ XcmsFloat nT;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_in_out == NULL || nSamples == 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* setup the CCC to use for the conversions. */
+ memcpy ((char *) &myCCC, (char *) ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc) NULL;
+
+ /* Step 1: compute the maximum value and chroma for this hue. */
+
+
+ /* save the Hue for use later. */
+ while (hue < 0.0) {
+ hue += 360.0;
+ }
+ while (hue > 360.0) {
+ hue -= 360.0;
+ }
+ pColor_in_out->spec.TekHVC.H = hue;
+ pColor_in_out->format = XcmsTekHVCFormat;
+
+ /* Get the maximum value and chroma point for this hue */
+ if (_XcmsTekHVCQueryMaxVCRGB(&myCCC, pColor_in_out->spec.TekHVC.H,
+ pColor_in_out, (XcmsRGBi *)&rgb_saved) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+
+ /* Step 2: Convert each of the RGBi's to HVC's */
+ pHVC = pColor_in_out;
+ for (nI = 0; nI < nSamples; nI++, pHVC++) {
+ nT = (XcmsFloat) nI / (XcmsFloat) nSamples;
+ pHVC->spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ pHVC->spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ pHVC->spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ pHVC->format = XcmsRGBiFormat;
+ pHVC->pixel = pColor_in_out->pixel;
+ /* convert from RGB to HVC */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, pHVC,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* make sure to return the input hue */
+ pHVC->spec.TekHVC.H = hue;
+ }
+
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/HVCWpAj.c b/nx-X11/lib/X11/HVCWpAj.c
new file mode 100644
index 000000000..558e90bc3
--- /dev/null
+++ b/nx-X11/lib/X11/HVCWpAj.c
@@ -0,0 +1,117 @@
+/* $Xorg: HVCWpAj.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * DESCRIPTION
+ * TekHVCWpAj.c
+ *
+ * DESCRIPTION
+ * This file contains routine(s) that support white point
+ * adjustment of color specifications in the TekHVC color
+ * space.
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCWhiteShiftColors
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCWhiteShiftColors(ccc, pWhitePtFrom, pWhitePtTo, destSpecFmt,
+ pColors_in_out, nColors, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pWhitePtFrom;
+ XcmsColor *pWhitePtTo;
+ XcmsColorFormat destSpecFmt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Convert color specifications in an array of XcmsColor structures
+ * for differences in white points.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression,
+ * XcmsSuccessWithCompression if succeeded with
+ * gamut compression.
+ */
+{
+ if (pWhitePtFrom == NULL || pWhitePtTo == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Convert to TekHVC using pWhitePtFrom
+ * We can ignore return value for compression because we are converting
+ * to XcmsTekHVCFormat which is device-independent, not device-dependent.
+ */
+ if (_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out, pWhitePtFrom,
+ nColors, XcmsTekHVCFormat, pCompressed) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Convert from TekHVC to destSpecFmt using pWhitePtTo
+ */
+ return(_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out, pWhitePtTo,
+ nColors, destSpecFmt, pCompressed));
+}
diff --git a/nx-X11/lib/X11/Host.c b/nx-X11/lib/X11/Host.c
new file mode 100644
index 000000000..58e9e4a1c
--- /dev/null
+++ b/nx-X11/lib/X11/Host.c
@@ -0,0 +1,145 @@
+/* $Xorg: Host.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/* $XdotOrg: xc/lib/X11/Host.c,v 1.4 2005/07/03 07:00:55 daniels Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+Copyright 2004 Sun Microsystems, Inc.
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+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
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of The Open Group.
+
+*/
+/* $XFree86: xc/lib/X11/Host.c,v 1.3 2001/01/17 19:41:37 dawes Exp $ */
+
+/* this might be rightly regarded an os dependent file */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XAddHost (
+ register Display *dpy,
+ XHostAddress *host)
+{
+ register xChangeHostsReq *req;
+ register int length;
+ XServerInterpretedAddress *siAddr;
+ int addrlen;
+
+ if (host->family == FamilyServerInterpreted) {
+ siAddr = (XServerInterpretedAddress *) host->address;
+ addrlen = siAddr->typelength + siAddr->valuelength + 1;
+ } else {
+ addrlen = host->length;
+ }
+
+ length = (addrlen + 3) & ~0x3; /* round up */
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeHosts, length, req);
+ req->mode = HostInsert;
+ req->hostFamily = host->family;
+ req->hostLength = addrlen;
+ if (host->family == FamilyServerInterpreted) {
+ char *dest = (char *) NEXTPTR(req,xChangeHostsReq);
+ memcpy(dest, siAddr->type, siAddr->typelength);
+ dest[siAddr->typelength] = '\0';
+ memcpy(dest + siAddr->typelength + 1,siAddr->value,siAddr->valuelength);
+ } else {
+ memcpy((char *) NEXTPTR(req,xChangeHostsReq), host->address, addrlen);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+int
+XRemoveHost (
+ register Display *dpy,
+ XHostAddress *host)
+{
+ register xChangeHostsReq *req;
+ register int length;
+ XServerInterpretedAddress *siAddr;
+ int addrlen;
+
+ if (host->family == FamilyServerInterpreted) {
+ siAddr = (XServerInterpretedAddress *) host->address;
+ addrlen = siAddr->typelength + siAddr->valuelength + 1;
+ } else {
+ addrlen = host->length;
+ }
+
+ length = (addrlen + 3) & ~0x3; /* round up */
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeHosts, length, req);
+ req->mode = HostDelete;
+ req->hostFamily = host->family;
+ req->hostLength = addrlen;
+ if (host->family == FamilyServerInterpreted) {
+ char *dest = (char *) NEXTPTR(req,xChangeHostsReq);
+ memcpy(dest, siAddr->type, siAddr->typelength);
+ dest[siAddr->typelength] = '\0';
+ memcpy(dest + siAddr->typelength + 1,siAddr->value,siAddr->valuelength);
+ } else {
+ memcpy((char *) NEXTPTR(req,xChangeHostsReq), host->address, addrlen);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+int
+XAddHosts (
+ register Display *dpy,
+ XHostAddress *hosts,
+ int n)
+{
+ register int i;
+ for (i = 0; i < n; i++) {
+ (void) XAddHost(dpy, &hosts[i]);
+ }
+ return 1;
+}
+
+int
+XRemoveHosts (
+ 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/nx-X11/lib/X11/ICWrap.c b/nx-X11/lib/X11/ICWrap.c
new file mode 100644
index 000000000..b51da6f41
--- /dev/null
+++ b/nx-X11/lib/X11/ICWrap.c
@@ -0,0 +1,457 @@
+/*
+ * $Xorg: ICWrap.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $
+ */
+
+/*
+ * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
+ * and Nippon Telegraph and Telephone Corporation
+ * Copyright 1991 by the Open Software Foundation
+ * Copyright 1993 by the FUJITSU LIMITED
+ *
+ * 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 names of OMRON, NTT Software, NTT, and
+ * Open Software Foundation not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. OMRON, NTT Software, NTT, and Open Software
+ * Foundation make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OMRON, NTT SOFTWARE, NTT, AND OPEN SOFTWARE FOUNDATION
+ * DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+ * SHALL OMRON, NTT SOFTWARE, NTT, OR OPEN SOFTWARE FOUNDATION 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.
+ *
+ * Authors: Li Yuhong OMRON Corporation
+ * Tatsuya Kato NTT Software Corporation
+ * Hiroshi Kuribayashi OMRON Coproration
+ * Muneiyoshi Suzuki Nippon Telegraph and Telephone Co.
+ *
+ * M. Collins OSF
+ * Takashi Fujiwara FUJITSU LIMITED
+ */
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/X11/ICWrap.c,v 1.10 2003/04/25 14:12:38 tsi Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+static int
+_XIMNestedListToNestedList(
+ XIMArg *nlist, /* This is the new list */
+ XIMArg *list) /* The original list */
+{
+ register XIMArg *ptr = list;
+
+ while (ptr->name) {
+ if (!strcmp(ptr->name, XNVaNestedList)) {
+ nlist += _XIMNestedListToNestedList(nlist, (XIMArg *)ptr->value);
+ } else {
+ nlist->name = ptr->name;
+ nlist->value = ptr->value;
+ ptr++;
+ nlist++;
+ }
+ }
+ return ptr - list;
+}
+
+static void
+_XIMCountNestedList(
+ XIMArg *args,
+ int *total_count)
+{
+ for (; args->name; args++) {
+ if (!strcmp(args->name, XNVaNestedList))
+ _XIMCountNestedList((XIMArg *)args->value, total_count);
+ else
+ ++(*total_count);
+ }
+}
+
+static void
+_XIMCountVaList(va_list var, int *total_count)
+{
+ char *attr;
+
+ *total_count = 0;
+
+ for (attr = va_arg(var, char*); attr; attr = va_arg(var, char*)) {
+ if (!strcmp(attr, XNVaNestedList)) {
+ _XIMCountNestedList(va_arg(var, XIMArg*), total_count);
+ } else {
+ (void)va_arg(var, XIMArg*);
+ ++(*total_count);
+ }
+ }
+}
+
+static void
+_XIMVaToNestedList(va_list var, int max_count, XIMArg **args_return)
+{
+ XIMArg *args;
+ char *attr;
+
+ if (max_count <= 0) {
+ *args_return = (XIMArg *)NULL;
+ return;
+ }
+
+ args = (XIMArg *)Xmalloc((unsigned)(max_count + 1) * sizeof(XIMArg));
+ *args_return = args;
+ if (!args) return;
+
+ for (attr = va_arg(var, char*); attr; attr = va_arg(var, char*)) {
+ if (!strcmp(attr, XNVaNestedList)) {
+ args += _XIMNestedListToNestedList(args, va_arg(var, XIMArg*));
+ } else {
+ args->name = attr;
+ args->value = va_arg(var, XPointer);
+ args++;
+ }
+ }
+ args->name = (char*)NULL;
+}
+
+/*ARGSUSED*/
+XVaNestedList
+XVaCreateNestedList(int dummy, ...)
+{
+ va_list var;
+ XIMArg *args = NULL;
+ int total_count;
+
+ va_start(var, dummy);
+ _XIMCountVaList(var, &total_count);
+ va_end(var);
+
+ va_start(var, dummy);
+ _XIMVaToNestedList(var, total_count, &args);
+ va_end(var);
+
+ return (XVaNestedList)args;
+}
+
+char *
+XSetIMValues(XIM im, ...)
+{
+ va_list var;
+ int total_count;
+ XIMArg *args;
+ char *ret;
+
+ /*
+ * so count the stuff dangling here
+ */
+ va_start(var, im);
+ _XIMCountVaList(var, &total_count);
+ va_end(var);
+
+ /*
+ * now package it up so we can send it along
+ */
+ va_start(var, im);
+ _XIMVaToNestedList(var, total_count, &args);
+ va_end(var);
+
+ ret = (*im->methods->set_values) (im, args);
+ if (args) Xfree((char *)args);
+ return ret;
+}
+
+char *
+XGetIMValues(XIM im, ...)
+{
+ va_list var;
+ int total_count;
+ XIMArg *args;
+ char *ret;
+
+ /*
+ * so count the stuff dangling here
+ */
+ va_start(var, im);
+ _XIMCountVaList(var, &total_count);
+ va_end(var);
+
+ /*
+ * now package it up so we can send it along
+ */
+ va_start(var, im);
+ _XIMVaToNestedList(var, total_count, &args);
+ va_end(var);
+
+ ret = (*im->methods->get_values) (im, args);
+ if (args) Xfree((char *)args);
+ return ret;
+}
+
+/*
+ * Create an input context within the input method,
+ * and return a pointer to the input context.
+ */
+
+XIC
+XCreateIC(XIM im, ...)
+{
+ va_list var;
+ int total_count;
+ XIMArg *args;
+ XIC ic;
+
+ /*
+ * so count the stuff dangling here
+ */
+ va_start(var, im);
+ _XIMCountVaList(var, &total_count);
+ va_end(var);
+
+ /*
+ * now package it up so we can send it along
+ */
+ va_start(var, im);
+ _XIMVaToNestedList(var, total_count, &args);
+ va_end(var);
+
+ ic = (XIC) (*im->methods->create_ic) (im, args);
+ if (args) Xfree((char *)args);
+ if (ic) {
+ ic->core.next = im->core.ic_chain;
+ im->core.ic_chain = ic;
+ }
+ return ic;
+}
+
+/*
+ * Free the input context.
+ */
+void
+XDestroyIC(ic)
+ XIC ic;
+{
+ XIM im = ic->core.im;
+ XIC *prev;
+
+ (*ic->methods->destroy) (ic);
+ if (im) {
+ for (prev = &im->core.ic_chain; *prev; prev = &(*prev)->core.next) {
+ if (*prev == ic) {
+ *prev = ic->core.next;
+ break;
+ }
+ }
+ }
+ Xfree ((char *) ic);
+}
+
+char *
+XGetICValues(XIC ic, ...)
+{
+ va_list var;
+ int total_count;
+ XIMArg *args;
+ char *ret;
+
+ if (!ic->core.im)
+ return (char *) NULL;
+
+ /*
+ * so count the stuff dangling here
+ */
+ va_start(var, ic);
+ _XIMCountVaList(var, &total_count);
+ va_end(var);
+
+ /*
+ * now package it up so we can send it along
+ */
+ va_start(var, ic);
+ _XIMVaToNestedList(var, total_count, &args);
+ va_end(var);
+
+ ret = (*ic->methods->get_values) (ic, args);
+ if (args) Xfree((char *)args);
+ return ret;
+}
+
+char *
+XSetICValues(XIC ic, ...)
+{
+ va_list var;
+ int total_count;
+ XIMArg *args;
+ char *ret;
+
+ if (!ic->core.im)
+ return (char *) NULL;
+
+ /*
+ * so count the stuff dangling here
+ */
+ va_start(var, ic);
+ _XIMCountVaList(var, &total_count);
+ va_end(var);
+
+ /*
+ * now package it up so we can send it along
+ */
+ va_start(var, ic);
+ _XIMVaToNestedList(var, total_count, &args);
+ va_end(var);
+
+ ret = (*ic->methods->set_values) (ic, args);
+ if (args) Xfree((char *)args);
+ return ret;
+}
+
+/*
+ * Require the input manager to focus the focus window attached to the ic
+ * argument.
+ */
+void
+XSetICFocus(ic)
+ XIC ic;
+{
+ if (ic && ic->core.im)
+ (*ic->methods->set_focus) (ic);
+}
+
+/*
+ * Require the input manager to unfocus the focus window attached to the ic
+ * argument.
+ */
+void
+XUnsetICFocus(ic)
+ XIC ic;
+{
+ if (ic->core.im)
+ (*ic->methods->unset_focus) (ic);
+}
+
+/*
+ * Return the XIM associated with the input context.
+ */
+XIM
+XIMOfIC(ic)
+ XIC ic;
+{
+ return ic->core.im;
+}
+
+char *
+XmbResetIC(ic)
+ XIC ic;
+{
+ if (ic->core.im)
+ return (*ic->methods->mb_reset)(ic);
+ return (char *)NULL;
+}
+
+wchar_t *
+XwcResetIC(ic)
+ XIC ic;
+{
+ if (ic->core.im)
+ return (*ic->methods->wc_reset)(ic);
+ return (wchar_t *)NULL;
+}
+
+char *
+Xutf8ResetIC(ic)
+ XIC ic;
+{
+ if (ic->core.im) {
+ if (ic->methods->utf8_reset)
+ return (*ic->methods->utf8_reset)(ic);
+ else if (ic->methods->mb_reset)
+ return (*ic->methods->mb_reset)(ic);
+ }
+ return (char *)NULL;
+}
+
+int
+XmbLookupString(ic, ev, buffer, nbytes, keysym, status)
+ XIC ic;
+ register XKeyEvent *ev;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ Status *status;
+{
+ if (ic->core.im)
+ return (*ic->methods->mb_lookup_string) (ic, ev, buffer, nbytes,
+ keysym, status);
+ return XLookupNone;
+}
+
+int
+XwcLookupString(ic, ev, buffer, nchars, keysym, status)
+ XIC ic;
+ register XKeyEvent *ev;
+ wchar_t *buffer;
+ int nchars;
+ KeySym *keysym;
+ Status *status;
+{
+ if (ic->core.im)
+ return (*ic->methods->wc_lookup_string) (ic, ev, buffer, nchars,
+ keysym, status);
+ return XLookupNone;
+}
+
+int
+Xutf8LookupString(ic, ev, buffer, nbytes, keysym, status)
+ XIC ic;
+ register XKeyEvent *ev;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ Status *status;
+{
+ if (ic->core.im) {
+ if (ic->methods->utf8_lookup_string)
+ return (*ic->methods->utf8_lookup_string) (ic, ev, buffer, nbytes,
+ keysym, status);
+ else if (ic->methods->mb_lookup_string)
+ return (*ic->methods->mb_lookup_string) (ic, ev, buffer, nbytes,
+ keysym, status);
+ }
+ return XLookupNone;
+}
diff --git a/nx-X11/lib/X11/IMWrap.c b/nx-X11/lib/X11/IMWrap.c
new file mode 100644
index 000000000..a90b40675
--- /dev/null
+++ b/nx-X11/lib/X11/IMWrap.c
@@ -0,0 +1,221 @@
+/*
+ * $Xorg: IMWrap.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $
+ */
+
+/*
+ * Copyright 1991 by the Open Software Foundation
+ * Copyright 1993, 1994 by the Sony 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 names of Open Software Foundation and
+ * Sony Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Open Software Foundation and Sony Corporation make no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * OPEN SOFTWARE FOUNDATION AND SONY CORPORATION DISCLAIM ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL OPEN
+ * SOFTWARE FOUNDATIONN OR SONY CORPORATION 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
+ * Makoto Wakamatsu Sony Corporation
+ */
+/*
+
+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.
+
+*/
+
+/* $XFree86: xc/lib/X11/IMWrap.c,v 3.8 2001/12/14 19:54:01 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+/*
+ * Compile the resource name. (resource_name ---> xrm_name)
+ */
+void
+_XIMCompileResourceList(res, num_res)
+ register XIMResourceList res;
+ unsigned int num_res;
+{
+ register unsigned int count;
+
+ for (count = 0; count < num_res; res++, count++) {
+ res->xrm_name = XrmStringToQuark(res->resource_name);
+ }
+}
+
+void
+_XCopyToArg(src, dst, size)
+ XPointer src;
+ XPointer *dst;
+ register unsigned int size;
+{
+ if (!*dst) {
+ union {
+ long longval;
+#ifdef LONG64
+ int intval;
+#endif
+ short shortval;
+ char charval;
+ char* charptr;
+ XPointer ptr;
+ } u;
+ if (size <= sizeof(XPointer)) {
+ memcpy((char *)&u, (char *)src, (int)size);
+ if (size == sizeof(long)) *dst = (XPointer)u.longval;
+#ifdef LONG64
+ else if (size == sizeof(int)) *dst = (XPointer)(long)u.intval;
+#endif
+ else if (size == sizeof(short)) *dst = (XPointer)(long)u.shortval;
+ else if (size == sizeof(char)) *dst = (XPointer)(long)u.charval;
+ else if (size == sizeof(char*)) *dst = (XPointer)u.charptr;
+ else if (size == sizeof(XPointer)) *dst = (XPointer)u.ptr;
+ else memcpy( (char*)dst, (char*)src, (int)size );
+ } else {
+ memcpy( (char*)dst, (char*)src, (int)size );
+ }
+ } else {
+ memcpy( (char*)*dst, (char*)src, (int)size );
+ }
+}
+
+/*
+ * Connects to an input method matching current locale specification, creates
+ * a XIM object and return a pointer the newly created XIM back to the caller.
+ */
+
+XIM
+XOpenIM( display, rdb, res_name, res_class )
+ Display *display;
+ XrmDatabase rdb;
+ char *res_name;
+ char *res_class;
+{
+ XLCd lcd = _XOpenLC( (char *)NULL );
+
+ if( !lcd )
+ return( (XIM)NULL );
+ return (*lcd->methods->open_im) (lcd, display, rdb, res_name, res_class);
+}
+
+/*
+ * Close the connection to the input manager, and free the XIM structure
+ */
+Status
+XCloseIM(im)
+ XIM im;
+{
+ Status s;
+ XIC ic;
+ XLCd lcd = im->core.lcd;
+
+ s = (im->methods->close) (im);
+ for (ic = im->core.ic_chain; ic; ic = ic->core.next)
+ ic->core.im = (XIM)NULL;
+ Xfree ((char *) im);
+ _XCloseLC (lcd);
+ return (s);
+}
+
+/*
+ * Return the Display associated with the input method.
+ */
+Display *
+XDisplayOfIM(im)
+ XIM im;
+{
+ return im->core.display;
+}
+
+/*
+ * Return the Locale associated with the input method.
+ */
+char *
+XLocaleOfIM(im)
+ XIM im;
+{
+ return im->core.lcd->core->name;
+}
+
+/*
+ * Register to a input method instantiation callback to prepare the
+ * on-demand input method instantiation.
+ */
+Bool
+XRegisterIMInstantiateCallback(
+ Display *display,
+ XrmDatabase rdb,
+ char *res_name,
+ char *res_class,
+ XIDProc callback,
+ XPointer client_data)
+{
+ XLCd lcd = _XOpenLC( (char *)NULL );
+
+ if( !lcd )
+ return( False );
+ return( (*lcd->methods->register_callback)( lcd, display, rdb, res_name,
+ res_class, callback,
+ client_data ) );
+}
+
+/*
+ * Unregister to a input method instantiation callback.
+ */
+Bool
+XUnregisterIMInstantiateCallback(
+ Display *display,
+ XrmDatabase rdb,
+ char *res_name,
+ char *res_class,
+ XIDProc callback,
+ XPointer client_data)
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if( !lcd )
+ return( False );
+ if( lcd->methods->unregister_callback == NULL )
+ return( False );
+ return( (*lcd->methods->unregister_callback)( lcd, display, rdb, res_name,
+ res_class, callback,
+ client_data ) );
+}
+
diff --git a/nx-X11/lib/X11/Iconify.c b/nx-X11/lib/X11/Iconify.c
new file mode 100644
index 000000000..62e57b84e
--- /dev/null
+++ b/nx-X11/lib/X11/Iconify.c
@@ -0,0 +1,87 @@
+/* $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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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/nx-X11/lib/X11/IdOfPr.c b/nx-X11/lib/X11/IdOfPr.c
new file mode 100644
index 000000000..a8eda895e
--- /dev/null
+++ b/nx-X11/lib/X11/IdOfPr.c
@@ -0,0 +1,109 @@
+/* $Xorg: IdOfPr.c,v 1.3 2000/08/17 19:44:38 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsIdOfPr.c
+ *
+ * DESCRIPTION
+ * Source for XcmsFormatOfPrefix()
+ *
+ *
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/*
+ * NAME
+ * XcmsFormatOfPrefix
+ *
+ * SYNOPSIS
+ */
+XcmsColorFormat
+XcmsFormatOfPrefix(prefix)
+ char *prefix;
+/*
+ * DESCRIPTION
+ * Returns the Color Space ID for the specified prefix
+ * if the color space is found in the Color Conversion
+ * Context.
+ *
+ * RETURNS
+ * Color Space ID if found; zero otherwise.
+ */
+{
+ XcmsColorSpace **papColorSpaces;
+ char string_buf[64];
+ char *string_lowered;
+ int len;
+
+ /*
+ * While copying prefix to string_lowered, convert to lowercase
+ */
+ if ((len = strlen(prefix)) >= sizeof(string_buf)) {
+ string_lowered = (char *) Xmalloc(len+1);
+ } else {
+ string_lowered = string_buf;
+ }
+ _XcmsCopyISOLatin1Lowered(string_lowered, prefix);
+
+ /*
+ * First try Device-Independent color spaces
+ */
+ papColorSpaces = _XcmsDIColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if (strcmp((*papColorSpaces)->prefix, string_lowered) == 0) {
+ if (len >= sizeof(string_buf)) Xfree(string_lowered);
+ return((*papColorSpaces)->id);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ /*
+ * Next try Device-Dependent color spaces
+ */
+ papColorSpaces = _XcmsDDColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if (strcmp((*papColorSpaces)->prefix, string_lowered) == 0) {
+ if (len >= sizeof(string_buf)) Xfree(string_lowered);
+ return((*papColorSpaces)->id);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ if (len >= sizeof(string_buf)) Xfree(string_lowered);
+ return(XcmsUndefinedFormat);
+}
diff --git a/nx-X11/lib/X11/IfEvent.c b/nx-X11/lib/X11/IfEvent.c
new file mode 100644
index 000000000..a7c0cb188
--- /dev/null
+++ b/nx-X11/lib/X11/IfEvent.c
@@ -0,0 +1,80 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/IfEvent.c,v 1.4 2001/12/14 19:54:01 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/*
+ * Flush output and (wait for and) return the next event matching the
+ * predicate in the queue.
+ */
+
+int
+XIfEvent (dpy, event, predicate, arg)
+ register Display *dpy;
+ Bool (*predicate)(
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+ ); /* 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;
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return 0;
+ }
+#endif
+ }
+}
diff --git a/nx-X11/lib/X11/IfEvent.c.NX.original b/nx-X11/lib/X11/IfEvent.c.NX.original
new file mode 100644
index 000000000..a7c0cb188
--- /dev/null
+++ b/nx-X11/lib/X11/IfEvent.c.NX.original
@@ -0,0 +1,80 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/IfEvent.c,v 1.4 2001/12/14 19:54:01 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/*
+ * Flush output and (wait for and) return the next event matching the
+ * predicate in the queue.
+ */
+
+int
+XIfEvent (dpy, event, predicate, arg)
+ register Display *dpy;
+ Bool (*predicate)(
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+ ); /* 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;
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return 0;
+ }
+#endif
+ }
+}
diff --git a/nx-X11/lib/X11/IfEvent.c.X.original b/nx-X11/lib/X11/IfEvent.c.X.original
new file mode 100644
index 000000000..55e7829ca
--- /dev/null
+++ b/nx-X11/lib/X11/IfEvent.c.X.original
@@ -0,0 +1,75 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/IfEvent.c,v 1.4 2001/12/14 19:54:01 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/*
+ * Flush output and (wait for and) return the next event matching the
+ * predicate in the queue.
+ */
+
+int
+XIfEvent (dpy, event, predicate, arg)
+ register Display *dpy;
+ Bool (*predicate)(
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+ ); /* 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/nx-X11/lib/X11/ImText.c b/nx-X11/lib/X11/ImText.c
new file mode 100644
index 000000000..4d2f147dc
--- /dev/null
+++ b/nx-X11/lib/X11/ImText.c
@@ -0,0 +1,104 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ImText.c,v 1.4 2001/12/14 19:54:02 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XDrawImageString(
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ int x,
+ int y,
+ _Xconst char *string,
+ int length)
+{
+ 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/nx-X11/lib/X11/ImText16.c b/nx-X11/lib/X11/ImText16.c
new file mode 100644
index 000000000..d0b5e9bca
--- /dev/null
+++ b/nx-X11/lib/X11/ImText16.c
@@ -0,0 +1,106 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ImText16.c,v 1.4 2001/12/14 19:54:02 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XDrawImageString16(
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ int x,
+ int y,
+ _Xconst XChar2b *string,
+ int length)
+{
+ 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/nx-X11/lib/X11/ImUtil.c b/nx-X11/lib/X11/ImUtil.c
new file mode 100644
index 000000000..9e667bb9c
--- /dev/null
+++ b/nx-X11/lib/X11/ImUtil.c
@@ -0,0 +1,1032 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ImUtil.c,v 3.12 2003/04/15 22:10:06 herrb Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+#include "ImUtil.h"
+
+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);
+
+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. */
+
+int
+_XGetScanlinePad(
+ 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);
+ }
+
+int
+_XGetBitsPerPixel(
+ 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 (
+ 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 (
+ 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(
+ 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.
+ *
+ */
+
+#if defined(Lynx) && defined(ROUNDUP)
+#undef ROUNDUP
+#endif
+
+#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 (
+ 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;
+ int min_bytes_per_line;
+
+ if (depth == 0 || depth > 32 ||
+ (format != XYBitmap && format != XYPixmap && format != ZPixmap) ||
+ (format == XYBitmap && depth != 1) ||
+ (xpad != 8 && xpad != 16 && xpad != 32) ||
+ offset < 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 (format == ZPixmap)
+ min_bytes_per_line =
+ ROUNDUP((bits_per_pixel * width), image->bitmap_pad);
+ else
+ min_bytes_per_line =
+ ROUNDUP((width + offset), image->bitmap_pad);
+ }
+ if (image_bytes_per_line == 0) {
+ image->bytes_per_line = min_bytes_per_line;
+ } else if (image_bytes_per_line < min_bytes_per_line) {
+ return 0;
+ } 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;
+{
+ int min_bytes_per_line;
+
+ if (image->depth == 0 || image->depth > 32 ||
+ image->bits_per_pixel > 32 || image->bitmap_unit > 32 ||
+ image->bits_per_pixel < 0 || image->bitmap_unit < 0 ||
+ (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)
+ return 0;
+
+ /*
+ * compute per line accelerator.
+ */
+ if (image->format == ZPixmap)
+ min_bytes_per_line =
+ ROUNDUP((image->bits_per_pixel * image->width),
+ image->bitmap_pad);
+ else
+ min_bytes_per_line =
+ ROUNDUP((image->width + image->xoffset), image->bitmap_pad);
+
+ if (image->bytes_per_line == 0) {
+ image->bytes_per_line = min_bytes_per_line;
+ } else if (image->bytes_per_line < min_bytes_per_line) {
+ return 0;
+ }
+
+ _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 CARD32 const 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 (*((const 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 (*((const 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(
+ 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 int
+_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) &&
+ (*((const 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) &&
+ (*((const 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/nx-X11/lib/X11/ImUtil.h b/nx-X11/lib/X11/ImUtil.h
new file mode 100644
index 000000000..89f038117
--- /dev/null
+++ b/nx-X11/lib/X11/ImUtil.h
@@ -0,0 +1,31 @@
+/* $XFree86: xc/lib/X11/ImUtil.h,v 1.2 2003/04/15 22:10:07 herrb Exp $ */
+
+#ifndef _IMUTIL_H_
+#define _IMUTIL_H_
+
+extern int
+_XGetScanlinePad(
+ Display *dpy,
+ int depth);
+
+extern int
+_XGetBitsPerPixel(
+ Display *dpy,
+ int depth);
+
+extern int
+_XSetImage(
+ XImage *srcimg,
+ register XImage *dstimg,
+ register int x,
+ register int y);
+
+extern int
+_XReverse_Bytes(
+ register unsigned char *bpt,
+ register int nb);
+extern void
+_XInitImageFuncPtrs(
+ register XImage *image);
+
+#endif /* _IMUTIL_H_ */
diff --git a/nx-X11/lib/X11/Imakefile b/nx-X11/lib/X11/Imakefile
new file mode 100644
index 000000000..d8d0601b8
--- /dev/null
+++ b/nx-X11/lib/X11/Imakefile
@@ -0,0 +1,1237 @@
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:44:38 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/X11/Imakefile,v 3.52 2003/05/27 16:53:15 tsi Exp $
+
+
+
+ HEADERS = Xlib.h Xresource.h Xutil.h cursorfont.h Xlibint.h \
+ Xcms.h Xlocale.h XKBlib.h XlibConf.h Xregion.h ImUtil.h
+
+#if BuildServersOnly && !XWinServer && !XnestServer && !BuildGLXLibrary && !BuildClients && !XdmxServer && !NXAgentServer
+all::
+
+BuildIncludes($(HEADERS),IncSubdir,..)
+
+#else
+
+#if NXLibraries
+
+#ifdef SunArchitecture
+NX_INCLUDES = -I../../../nxcomp -I/usr/sfw/include
+#else
+NX_INCLUDES = -I../../../nxcomp
+#endif
+
+NX_DEFINES = -DNX_TRANS_SOCKET \
+ -DNX_TRANS_EXIT
+
+# -DNX_TRANS_CHANGE \
+# -DNX_TRANS_WARN \
+# -DNX_TRANS_INFO \
+# -DNX_TRANS_TEST \
+# -DNX_TRANS_DEBUG \
+
+#ifdef cygwinArchitecture
+NX_XCOMPLIBNAME = cygXcomp.dll
+NX_XCOMPEXTLIBNAME = cygXcompext.dll
+#else
+NX_XCOMPLIBNAME = libXcomp.so
+NX_XCOMPEXTLIBNAME = libXcompext.so
+#endif
+
+NX_XCOMPLIBDIR = $(XTOP)/../nxcomp
+NX_XCOMPLIBLINK = Xcomp
+NX_XCOMPLIBTARGET = $(NX_XCOMPLIBDIR)/$(NX_XCOMPLIBNAME)
+NX_REQUIREDLIBS = -L$(NX_XCOMPLIBDIR) -l$(NX_XCOMPLIBLINK)
+NX_XCOMPDEPTARGET = $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME)
+NX_XCOMPCONFIGTARGET = $(NX_XCOMPLIBDIR)/config.status
+
+NX_XCOMPEXTLIBDIR = $(XTOP)/../nxcompext
+NX_XCOMPEXTLIBTARGET = $(NX_XCOMPEXTLIBDIR)/$(NX_XCOMPEXTLIBNAME)
+NX_XCOMPEXTCONFIGTARGET = $(NX_XCOMPEXTLIBDIR)/config.status
+
+#endif
+
+#if BuildLoadableXlibI18n
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+#define NoLibSubdirs
+#endif
+
+#define DoNormalLib NormalLibX11
+#define DoSharedLib SharedLibX11
+#define DoExtraLib SharedLibX11
+#define DoDebugLib DebugLibX11
+#define DoProfileLib ProfileLibX11
+#define LibName X11
+#define SoRev SOXLIBREV
+#define HugeLibrary YES
+#define IncSubdir X11
+
+#if BuildLoadableXlibI18n
+SUBDIRS = xlibi18n
+#endif
+
+#include <Threads.tmpl>
+
+#ifndef MotifBC
+#define MotifBC NO
+#endif
+
+#ifdef SharedX11Reqs
+REQUIREDX11LIBS = SharedX11Reqs
+#endif
+#if BuildLoadableXlibI18n
+REQUIREDI18NLIBS = DlLibrary
+#endif
+#ifdef cygwinArchitecture
+EXCLUDE_SYMBOL = -Wl,--exclude-symbol,XdmcpWrap:_XdmcpWrapperToOddParity
+#endif
+
+REQUIREDLIBS=$(REQUIREDX11LIBS) $(REQUIREDI18NLIBS) $(EXCLUDE_SYMBOL) $(NX_REQUIREDLIBS)
+
+#if defined(MacIIArchitecture) || defined(SequentArchitecture) || defined(i386ScoArchitecture)
+XBSDLIB = /**/
+#endif
+#if defined(LunaArchitecture) && defined(Mc88000Architecture)
+EXTRA_LIBRARIES = /**/
+#endif
+#if Malloc0ReturnsNull
+ MALLOC_DEFINES = XMalloc0ReturnsNullDefines
+#endif
+#if HasXdmAuth
+ XDMAUTHDEFS = -DHASXDMAUTH
+ XDMAUTHOBJS = Wrap.o Wraphelp.o
+ XDMAUTHSRCS = Wrap.c Wraphelp.c
+#endif
+#if BuildXKBlib
+ XKB_DEFINES = -DXKB
+ XKBSRCS = XKB.c XKBBind.c XKBCompat.c XKBCtrls.c XKBCvt.c XKBGetMap.c \
+ XKBGetByName.c XKBNames.c XKBRdBuf.c XKBSetMap.c XKBUse.c \
+ XKBleds.c XKBBell.c XKBGeom.c XKBSetGeom.c XKBExtDev.c \
+ XKBList.c XKBMisc.c \
+ XKBMAlloc.c XKBGAlloc.c XKBAlloc.c
+ XKBOBJS = XKB.o XKBBind.o XKBCompat.o XKBCtrls.o XKBCvt.o XKBGetMap.o \
+ XKBGetByName.o XKBNames.o XKBRdBuf.o XKBSetMap.o XKBUse.o \
+ XKBleds.o XKBBell.o XKBGeom.o XKBSetGeom.o XKBExtDev.o \
+ XKBList.o XKBMisc.o \
+ XKBMAlloc.o XKBGAlloc.o XKBAlloc.o
+#endif
+#if HasSecureRPC
+ RPCDEFS = -DSECURE_RPC
+#endif
+#if HasPoll
+ POLL_DEFINES = -DUSE_POLL
+#endif
+ CONN_DEFINES = $(CONNECTION_FLAGS)
+ XTRANS_X_DEFINES = -DX11_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES)
+ XTRANS_XIM_DEFINES = -DXIM_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES)
+#if HasBSD44Sockets
+ SOCK_DEFINES = -DBSD44SOCKETS
+#endif
+#if HasShm
+ SHM_DEFINES = -DHAS_SHM
+#endif
+
+ XF86BIGFONT_DEFINES = XF86BigfontExtensionDefines
+
+ EDB_DEFINES = -DERRORDB=\"$(LIBDIR)/XErrorDB\"
+ KDB_DEFINES = -DKEYSYMDB=\"$(LIBDIR)/XKeysymDB\"
+ CMS_DEFINES = -DXCMSDB=\"$(LIBDIR)/Xcms.txt\"
+#if HasSnprintf
+ MISC_DEFINES = -DHAS_SNPRINTF -DLIBX11
+#endif
+#if MotifBC
+ BC_DEFINES = -DMOTIFBC
+#endif
+#if NoRConst
+ RCONST_DEFINES = -DNORCONST
+#endif
+#if DisableXLocaleDirEnv
+ SETID_DEFINES = -DNO_XLOCALEDIR
+#elif HasIssetugid
+ SETID_DEFINES = -DHASSETUGID
+#elif HasGetresuid
+ SETID_DEFINES = -DHASGETRESUID
+#endif
+ XLC_DEFINES = -DXLOCALEDIR=\"$(XLOCALEDIR)\"
+#if HasKrb5
+ K5OBJS = k5encode.o
+ K5SRCS = k5encode.c
+ K5INCL = Krb5Includes
+ K5DEFS = Krb5Defines
+#endif
+#if (defined(FreeBSDArchitecture) && OSRelVersion < 500016) || \
+ defined(OpenBSDArchitecture)
+THRSTUBSRCS = UIThrStubs.c
+THRSTUBOBJS = UIThrStubs.o
+#endif
+#if BuildLoadableXlibXcursor
+XCURSOR_DEFINES = -DUSE_DYNAMIC_XCURSOR -DLIBXCURSOR=\"libXcursor.so.$(SOXCURSORREV)\"
+#endif
+#if NeedLibInsideFlag
+ LIB_DEFINES = -D_XLIBINT_
+#endif
+#if defined(LibDirName)
+ POSTLOCALELIBDIR = LibDirName
+ POSTLOCALELIBDEFINES = -DPOSTLOCALELIBDIR=\"$(POSTLOCALELIBDIR)\"
+#endif
+ DEFINES = $(MALLOC_DEFINES) $(LIB_DEFINES) $(MISC_DEFINES)\
+ $(POSTLOCALELIBDEFINES) $(NX_INCLUDES) $(NX_DEFINES)
+ OPEN_DEFINES = -I$(EXTINCSRC) $(K5INCL) $(K5DEFS)
+ DEPEND_DEFINES = $(OPEN_DEFINES) $(TRANS_INCLUDES) $(CONN_DEFINES) $(THREADS_DEFINES) DependDefines
+ AUTHOBJS = AuDispose.o AuGetBest.o AuFileName.o AuRead.o
+ AUTHSRCS = AuDispose.c AuGetBest.c AuFileName.c AuRead.c
+ SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(EXTRASRCS) /* try *.c if you have trouble */
+ LINTLIBS =
+
+#if BuildLoadableXlibI18n && DoSharedLib
+EXTRASHAREDSRC = $(SHAREDLCSRCS)
+#endif
+#if !BuildLoadableXlibI18n || DoNormalLib
+EXTRASTATICSRC = $(STATICLCSRCS)
+#endif
+
+EXTRASRCS = $(EXTRASHAREDSRC) $(EXTRASTATICSRC)
+
+SRCS1 = \
+ Context.c \
+ Depths.c \
+ ParseCmd.c \
+ Quarks.c \
+ AllCells.c \
+ AllPlanes.c \
+ AllowEv.c \
+ AutoRep.c \
+ Backgnd.c \
+ BdrWidth.c \
+ Bell.c \
+ Border.c \
+ ChAccCon.c \
+ ChClMode.c \
+ ChActPGb.c \
+ ChCmap.c \
+ ChGC.c \
+ ChKeyCon.c \
+ ChPntCon.c \
+ ChProp.c \
+ ChSaveSet.c \
+ ChWAttrs.c \
+ ChWindow.c \
+ ChkIfEv.c \
+ ChkMaskEv.c \
+ ChkWinEv.c \
+ ChkTypEv.c \
+ ChkTypWEv.c \
+ CirWin.c \
+ CirWinDn.c \
+ CirWinUp.c \
+ ClDisplay.c \
+ Clear.c \
+ ClearArea.c \
+ ConfWind.c \
+ ConnDis.c \
+ ConvSel.c \
+ CopyArea.c \
+ CopyCmap.c \
+ CopyGC.c \
+ CopyPlane.c \
+ CrBFData.c \
+ CrCmap.c \
+ CrCursor.c \
+ CrGC.c \
+ CrGlCur.c \
+ CrPFBData.c \
+ CrPixmap.c \
+ CrWindow.c \
+ Cursor.c \
+ DefCursor.c \
+ DelProp.c \
+ DestSubs.c \
+ DestWind.c \
+ DisName.c \
+ DrArc.c \
+ DrArcs.c \
+ DrLine.c \
+ DrLines.c \
+ DrPoint.c \
+ DrPoints.c \
+ DrRect.c \
+ DrRects.c \
+ DrSegs.c \
+ ErrDes.c \
+ ErrHndlr.c \
+ EvToWire.c \
+ FetchName.c \
+ FillArc.c \
+ FillArcs.c \
+ FillPoly.c \
+ FillRct.c \
+ FillRcts.c \
+ Flush.c \
+ Font.c \
+ FontNames.c \
+ FontInfo.c \
+ FreeCmap.c \
+ FreeCols.c \
+ FreeCurs.c \
+ FreeEData.c \
+ FreeGC.c \
+ FreePix.c \
+ FSSaver.c \
+ GCMisc.c \
+ Geom.c \
+ GetAtomNm.c \
+ GetColor.c \
+ GetDflt.c \
+ GetFPath.c \
+ GetFProp.c \
+ GetGeom.c \
+ GetHColor.c \
+ GetHints.c \
+ GetIFocus.c \
+ GetImage.c \
+ GetKCnt.c \
+ GetMoEv.c \
+ GetPCnt.c \
+ GetPntMap.c \
+ GetProp.c \
+ GetSOwner.c \
+ GetSSaver.c \
+ GetStCmap.c \
+ GetWAttrs.c \
+ GrButton.c \
+ GrKey.c \
+ GrKeybd.c \
+ GrPointer.c \
+ GrServer.c \
+ Host.c \
+ IfEvent.c \
+ ImUtil.c \
+ ImText.c \
+ ImText16.c \
+ InitExt.c \
+ InsCmap.c \
+ IntAtom.c \
+ KeyBind.c \
+ KeysymStr.c \
+ KillCl.c \
+ LiHosts.c \
+ LiICmaps.c \
+ LiProps.c \
+ ListExt.c \
+ LoadFont.c \
+ LookupCol.c \
+ LowerWin.c
+
+OBJS1 = \
+ Context.o \
+ Depths.o \
+ ParseCmd.o \
+ Quarks.o \
+ AllCells.o \
+ AllPlanes.o \
+ AllowEv.o \
+ AutoRep.o \
+ Backgnd.o \
+ BdrWidth.o \
+ Bell.o \
+ Border.o \
+ ChAccCon.o \
+ ChClMode.o \
+ ChActPGb.o \
+ ChCmap.o \
+ ChGC.o \
+ ChKeyCon.o \
+ ChPntCon.o \
+ ChProp.o \
+ ChSaveSet.o \
+ ChWAttrs.o \
+ ChWindow.o \
+ ChkIfEv.o \
+ ChkMaskEv.o \
+ ChkWinEv.o \
+ ChkTypEv.o \
+ ChkTypWEv.o \
+ CirWin.o \
+ CirWinDn.o \
+ CirWinUp.o \
+ ClDisplay.o \
+ Clear.o \
+ ClearArea.o \
+ ConfWind.o \
+ ConnDis.o \
+ ConvSel.o \
+ CopyArea.o \
+ CopyCmap.o \
+ CopyGC.o \
+ CopyPlane.o \
+ CrBFData.o \
+ CrCmap.o \
+ CrCursor.o \
+ CrGC.o \
+ CrGlCur.o \
+ CrPFBData.o \
+ CrPixmap.o \
+ CrWindow.o \
+ Cursor.o \
+ DefCursor.o \
+ DelProp.o \
+ DestSubs.o \
+ DestWind.o \
+ DisName.o \
+ DrArc.o \
+ DrArcs.o \
+ DrLine.o \
+ DrLines.o \
+ DrPoint.o \
+ DrPoints.o \
+ DrRect.o \
+ DrRects.o \
+ DrSegs.o \
+ ErrDes.o \
+ ErrHndlr.o \
+ EvToWire.o \
+ FetchName.o \
+ FillArc.o \
+ FillArcs.o \
+ FillPoly.o \
+ FillRct.o \
+ FillRcts.o \
+ Flush.o \
+ Font.o \
+ FontNames.o \
+ FontInfo.o \
+ FreeCmap.o \
+ FreeCols.o \
+ FreeCurs.o \
+ FreeEData.o \
+ FreeGC.o \
+ FreePix.o \
+ FSSaver.o \
+ GCMisc.o \
+ Geom.o \
+ GetAtomNm.o \
+ GetColor.o \
+ GetDflt.o \
+ GetFPath.o \
+ GetFProp.o \
+ GetGeom.o \
+ GetHColor.o \
+ GetHints.o \
+ GetIFocus.o \
+ GetImage.o \
+ GetKCnt.o \
+ GetMoEv.o \
+ GetPCnt.o \
+ GetPntMap.o \
+ GetProp.o \
+ GetSOwner.o \
+ GetSSaver.o \
+ GetStCmap.o \
+ GetWAttrs.o \
+ GrButton.o \
+ GrKey.o \
+ GrKeybd.o \
+ GrPointer.o \
+ GrServer.o \
+ Host.o \
+ IfEvent.o \
+ ImUtil.o \
+ ImText.o \
+ ImText16.o \
+ InitExt.o \
+ InsCmap.o \
+ IntAtom.o \
+ KeyBind.o \
+ KeysymStr.o \
+ KillCl.o \
+ LiHosts.o \
+ LiICmaps.o \
+ LiProps.o \
+ ListExt.o \
+ LoadFont.o \
+ LookupCol.o \
+ LowerWin.o
+
+SRCS2 = \
+ Macros.c \
+ MapRaised.c \
+ MapSubs.c \
+ MapWindow.c \
+ MaskEvent.c \
+ Misc.c \
+ ModMap.c \
+ MoveWin.c \
+ NextEvent.c \
+ OpenDis.c \
+ ParseCol.c \
+ ParseGeom.c \
+ PeekEvent.c \
+ PeekIfEv.c \
+ Pending.c \
+ PmapBgnd.c \
+ PmapBord.c \
+ PolyReg.c \
+ PolyTxt.c \
+ PolyTxt16.c \
+ PutBEvent.c \
+ PutImage.c \
+ QuBest.c \
+ QuColor.c \
+ QuColors.c \
+ QuCurShp.c \
+ QuExt.c \
+ QuKeybd.c \
+ QuPntr.c \
+ QuStipShp.c \
+ QuTextE16.c \
+ QuTextExt.c \
+ QuTileShp.c \
+ QuTree.c \
+ RaiseWin.c \
+ RdBitF.c \
+ RecolorC.c \
+ ReconfWin.c \
+ Region.c \
+ RepWindow.c \
+ RestackWs.c \
+ RotProp.c \
+ ScrResStr.c \
+ SelInput.c \
+ SendEvent.c \
+ SetBack.c \
+ SetCRects.c \
+ SetClMask.c \
+ SetClOrig.c \
+ SetDashes.c \
+ SetFPath.c \
+ SetFont.c \
+ SetFore.c \
+ SetFunc.c \
+ SetHints.c \
+ SetIFocus.c \
+ SetLStyle.c \
+ SetPMask.c \
+ SetPntMap.c \
+ SetSOwner.c \
+ SetSSaver.c \
+ SetState.c \
+ SetStip.c \
+ SetStCmap.c \
+ SetTile.c \
+ SetTSOrig.c \
+ StBytes.c \
+ StColor.c \
+ StColors.c \
+ StNColor.c \
+ StName.c \
+ StrKeysym.c \
+ Sync.c \
+ Synchro.c \
+ Text.c \
+ Text16.c \
+ TextExt.c \
+ TextExt16.c \
+ TrCoords.c \
+ UndefCurs.c \
+ UngrabBut.c \
+ UngrabKbd.c \
+ UngrabKey.c \
+ UngrabPtr.c \
+ UngrabSvr.c \
+ UninsCmap.c \
+ UnldFont.c \
+ UnmapSubs.c \
+ UnmapWin.c \
+ VisUtil.c \
+ WarpPtr.c \
+ WinEvent.c \
+ Window.c \
+ WrBitF.c \
+ XlibAsync.c \
+ XlibInt.c \
+ Xrm.c \
+ evtomask.c \
+ globals.c \
+ GetGCVals.c \
+ GetNrmHint.c \
+ GetRGBCMap.c \
+ GetTxtProp.c \
+ GetWMCMapW.c \
+ GetWMProto.c \
+ Iconify.c \
+ PixFormats.c \
+ PropAlloc.c \
+ ReconfWM.c \
+ SetNrmHint.c \
+ SetRGBCMap.c \
+ SetTxtProp.c \
+ SetWMCMapW.c \
+ SetWMProto.c \
+ StrToText.c \
+ TextToStr.c \
+ Withdraw.c \
+ WMGeom.c \
+ WMProps.c \
+ $(AUTHSRCS) $(XDMAUTHSRCS) $(K5SRCS) $(THRSTUBSRCS)
+
+OBJS2 = \
+ Macros.o \
+ MapRaised.o \
+ MapSubs.o \
+ MapWindow.o \
+ MaskEvent.o \
+ Misc.o \
+ ModMap.o \
+ MoveWin.o \
+ NextEvent.o \
+ OpenDis.o \
+ ParseCol.o \
+ ParseGeom.o \
+ PeekEvent.o \
+ PeekIfEv.o \
+ Pending.o \
+ PmapBgnd.o \
+ PmapBord.o \
+ PolyReg.o \
+ PolyTxt.o \
+ PolyTxt16.o \
+ PutBEvent.o \
+ PutImage.o \
+ QuBest.o \
+ QuColor.o \
+ QuColors.o \
+ QuCurShp.o \
+ QuExt.o \
+ QuKeybd.o \
+ QuPntr.o \
+ QuStipShp.o \
+ QuTextE16.o \
+ QuTextExt.o \
+ QuTileShp.o \
+ QuTree.o \
+ RaiseWin.o \
+ RdBitF.o \
+ RecolorC.o \
+ ReconfWin.o \
+ Region.o \
+ RepWindow.o \
+ RestackWs.o \
+ RotProp.o \
+ ScrResStr.o \
+ SelInput.o \
+ SendEvent.o \
+ SetBack.o \
+ SetCRects.o \
+ SetClMask.o \
+ SetClOrig.o \
+ SetDashes.o \
+ SetFPath.o \
+ SetFont.o \
+ SetFore.o \
+ SetFunc.o \
+ SetHints.o \
+ SetIFocus.o \
+ SetLStyle.o \
+ SetPMask.o \
+ SetPntMap.o \
+ SetSOwner.o \
+ SetSSaver.o \
+ SetState.o \
+ SetStip.o \
+ SetStCmap.o \
+ SetTile.o \
+ SetTSOrig.o \
+ StBytes.o \
+ StColor.o \
+ StColors.o \
+ StNColor.o \
+ StName.o \
+ StrKeysym.o \
+ Sync.o \
+ Synchro.o \
+ Text.o \
+ Text16.o \
+ TextExt.o \
+ TextExt16.o \
+ TrCoords.o \
+ UndefCurs.o \
+ UngrabBut.o \
+ UngrabKbd.o \
+ UngrabKey.o \
+ UngrabPtr.o \
+ UngrabSvr.o \
+ UninsCmap.o \
+ UnldFont.o \
+ UnmapSubs.o \
+ UnmapWin.o \
+ VisUtil.o \
+ WarpPtr.o \
+ WinEvent.o \
+ Window.o \
+ WrBitF.o \
+ XlibAsync.o \
+ XlibInt.o \
+ Xrm.o \
+ evtomask.o \
+ globals.o \
+ GetGCVals.o \
+ GetNrmHint.o \
+ GetRGBCMap.o \
+ GetTxtProp.o \
+ GetWMCMapW.o \
+ GetWMProto.o \
+ Iconify.o \
+ PixFormats.o \
+ PropAlloc.o \
+ ReconfWM.o \
+ SetNrmHint.o \
+ SetRGBCMap.o \
+ SetTxtProp.o \
+ SetWMCMapW.o \
+ SetWMProto.o \
+ StrToText.o \
+ TextToStr.o \
+ Withdraw.o \
+ WMGeom.o \
+ WMProps.o \
+ $(AUTHOBJS) \
+ $(XDMAUTHOBJS) \
+ $(K5OBJS) \
+ $(THRSTUBOBJS)
+
+SRCS3 = \
+ Lab.c \
+ LabGcC.c \
+ LabGcL.c \
+ LabGcLC.c \
+ LabMnL.c \
+ LabMxC.c \
+ LabMxL.c \
+ LabMxLC.c \
+ LabWpAj.c \
+ Luv.c \
+ LuvGcC.c \
+ LuvGcL.c \
+ LuvGcLC.c \
+ LuvMnL.c \
+ LuvMxC.c \
+ LuvMxL.c \
+ LuvMxLC.c \
+ LuvWpAj.c \
+ XYZ.c \
+ uvY.c \
+ xyY.c \
+ HVC.c \
+ HVCGcC.c \
+ HVCGcV.c \
+ HVCGcVC.c \
+ HVCMnV.c \
+ HVCMxC.c \
+ HVCMxV.c \
+ HVCMxVC.c \
+ HVCMxVs.c \
+ HVCWpAj.c \
+ UNDEFINED.c \
+ AddDIC.c \
+ AddSF.c \
+ cmsAllNCol.c \
+ cmsAllCol.c \
+ CCC.c \
+ cmsCmap.c \
+ cmsColNm.c \
+ CvColW.c \
+ CvCols.c \
+ cmsGlobls.c \
+ IdOfPr.c \
+ cmsInt.c \
+ LRGB.c \
+ cmsLkCol.c \
+ cmsMath.c \
+ OfCCC.c \
+ PrOfId.c \
+ cmsProp.c \
+ QBlack.c \
+ QBlue.c \
+ QGreen.c \
+ QRed.c \
+ QWhite.c \
+ QuCol.c \
+ QuCols.c \
+ SetCCC.c \
+ SetGetCols.c \
+ StCol.c \
+ StCols.c \
+ cmsTrig.c \
+ XRGB.c \
+ FSWrap.c \
+ ICWrap.c \
+ IMWrap.c \
+ OCWrap.c \
+ OMWrap.c \
+ lcWrap.c \
+ mbWMProps.c \
+ utf8WMProps.c \
+ mbWrap.c \
+ wcWrap.c \
+ utf8Wrap.c \
+ FilterEv.c \
+ RegstFlt.c \
+ locking.c \
+ LockDis.c \
+ x11trans.c \
+ ximtrans.c \
+ $(XKBSRCS) $(LCSRCS) $(MISCSRCS)
+
+OBJS3 = \
+ Lab.o \
+ LabGcC.o \
+ LabGcL.o \
+ LabGcLC.o \
+ LabMnL.o \
+ LabMxC.o \
+ LabMxL.o \
+ LabMxLC.o \
+ LabWpAj.o \
+ Luv.o \
+ LuvGcC.o \
+ LuvGcL.o \
+ LuvGcLC.o \
+ LuvMnL.o \
+ LuvMxC.o \
+ LuvMxL.o \
+ LuvMxLC.o \
+ LuvWpAj.o \
+ XYZ.o \
+ uvY.o \
+ xyY.o \
+ HVC.o \
+ HVCGcC.o \
+ HVCGcV.o \
+ HVCGcVC.o \
+ HVCMnV.o \
+ HVCMxC.o \
+ HVCMxV.o \
+ HVCMxVC.o \
+ HVCMxVs.o \
+ HVCWpAj.o \
+ UNDEFINED.o \
+ AddDIC.o \
+ AddSF.o \
+ cmsAllNCol.o \
+ cmsAllCol.o \
+ CCC.o \
+ cmsCmap.o \
+ cmsColNm.o \
+ CvColW.o \
+ CvCols.o \
+ cmsGlobls.o \
+ IdOfPr.o \
+ cmsInt.o \
+ LRGB.o \
+ cmsLkCol.o \
+ cmsMath.o \
+ OfCCC.o \
+ PrOfId.o \
+ cmsProp.o \
+ QBlack.o \
+ QBlue.o \
+ QGreen.o \
+ QRed.o \
+ QWhite.o \
+ QuCol.o \
+ QuCols.o \
+ SetCCC.o \
+ SetGetCols.o \
+ StCol.o \
+ StCols.o \
+ cmsTrig.o \
+ XRGB.o \
+ FSWrap.o \
+ ICWrap.o \
+ IMWrap.o \
+ OCWrap.o \
+ OMWrap.o \
+ lcWrap.o \
+ mbWMProps.o \
+ utf8WMProps.o \
+ mbWrap.o \
+ wcWrap.o \
+ utf8Wrap.o \
+ FilterEv.o \
+ RegstFlt.o \
+ locking.o \
+ LockDis.o \
+ x11trans.o \
+ ximtrans.o \
+ $(XKBOBJS) $(LCOBJS) $(MISCOBJS)
+
+#if BuildLoadableXlibI18n
+LC_DYNDEFINES = -DUSE_DYNAMIC_LC
+#endif
+
+SHAREDLCDEPSYMSRCS = XlcDL.c XlcSL.c
+
+SHAREDI18NSTATICSRCS = \
+ XDefaultIMIF.c XDefaultOMIF.c
+
+STATICLCDEPSYMSRCS =
+
+STATICI18NSTATICSRCS = \
+ imCallbk.c \
+ imDefFlt.c \
+ imDefIc.c \
+ imDefIm.c \
+ imDefLkup.c \
+ imDispch.c \
+ imEvToWire.c \
+ imExten.c \
+ imImSw.c \
+ imInsClbk.c \
+ imInt.c \
+ imLcFlt.c \
+ imLcGIc.c \
+ imLcIc.c \
+ imLcIm.c \
+ imLcLkup.c \
+ imLcPrs.c \
+ imLcSIc.c \
+ imRm.c \
+ imRmAttr.c \
+ imThaiFlt.c \
+ imThaiIc.c \
+ imThaiIm.c \
+ imTrX.c \
+ imTransR.c \
+ imTrans.c \
+ lcEuc.c \
+ lcGenConv.c \
+ lcJis.c \
+ lcSjis.c \
+ lcUTF8Load.c \
+ omDefault.c \
+ omGeneric.c \
+ omImText.c \
+ omText.c \
+ omTextEsc.c \
+ omTextExt.c \
+ omTextPer.c \
+ omXChar.c
+
+LCSRCS = \
+ SetLocale.c \
+ imConv.c \
+ imKStoUCS.c \
+ lcCT.c \
+ lcCharSet.c \
+ lcConv.c \
+ lcDB.c \
+ lcDefConv.c \
+ lcFile.c \
+ lcGeneric.c \
+ lcInit.c \
+ lcPrTxt.c \
+ lcPubWrap.c \
+ lcPublic.c \
+ lcRM.c \
+ lcStd.c \
+ lcTxtPr.c \
+ lcUtil.c \
+ lcUTF8.c
+
+STATICLCSRCS = \
+ $(STATICLCDEPSYMSRCS) \
+ $(STATICI18NSTATICSRCS)
+
+SHAREDLCSRCS = \
+ $(SHAREDLCDEPSYMSRCS) \
+ $(SHAREDI18NSTATICSRCS)
+
+SHAREDLCDEPOBJS = XlcDL.o XlcSL.o
+SHAREDI18NSTATICOBJS = \
+ XDefaultIMIF.o XDefaultOMIF.o
+STATICLCDEPOBJS =
+STATICI18NSTATICOBJS = \
+ imCallbk.o \
+ imDefFlt.o \
+ imDefIc.o \
+ imDefIm.o \
+ imDefLkup.o \
+ imDispch.o \
+ imEvToWire.o \
+ imExten.o \
+ imImSw.o \
+ imInsClbk.o \
+ imInt.o \
+ imLcFlt.o \
+ imLcGIc.o \
+ imLcIc.o \
+ imLcIm.o \
+ imLcLkup.o \
+ imLcPrs.o \
+ imLcSIc.o \
+ imRm.o \
+ imRmAttr.o \
+ imThaiFlt.o \
+ imThaiIc.o \
+ imThaiIm.o \
+ imTrX.o \
+ imTransR.o \
+ imTrans.o \
+ lcEuc.o \
+ lcGenConv.o \
+ lcJis.o \
+ lcSjis.o \
+ lcUTF8Load.o \
+ omDefault.o \
+ omGeneric.o \
+ omImText.o \
+ omText.o \
+ omTextEsc.o \
+ omTextExt.o \
+ omTextPer.o \
+ omXChar.o
+
+LCOBJS = \
+ SetLocale.o \
+ imConv.o \
+ imKStoUCS.o \
+ lcCT.o \
+ lcCharSet.o \
+ lcConv.o \
+ lcDB.o \
+ lcDefConv.o \
+ lcFile.o \
+ lcGeneric.o \
+ lcInit.o \
+ lcPrTxt.o \
+ lcPubWrap.o \
+ lcPublic.o \
+ lcRM.o \
+ lcStd.o \
+ lcTxtPr.o \
+ lcUtil.o \
+ lcUTF8.o
+
+STATICLCOBJS = \
+ $(STATICLCDEPOBJS) \
+ $(STATICI18NSTATICOBJS)
+
+SHAREDLCOBJS = \
+ $(SHAREDLCDEPOBJS) \
+ $(SHAREDI18NSTATICOBJS)
+
+#ifdef OS2Architecture
+MISCSRCS = os2Stubs.c
+#endif
+
+#ifdef OS2Architecture
+MISCOBJS = os2Stubs.o
+#endif
+
+OBJS = $(OBJS1) $(OBJS2) $(OBJS3)
+
+EXTRAUNSHAREDOBJS = $(STATICLCOBJS)
+
+#if BuildLoadableXlibI18n
+EXTRASHAREDOBJS = $(SHAREDLCOBJS)
+# else
+EXTRASHAREDOBJS = $(STATICLCOBJS)
+#endif
+
+#include <Library.tmpl>
+
+SpecialCLibObjectRule(ErrDes,$(ICONFIGFILES),$(EDB_DEFINES))
+SpecialCLibObjectRule(StrKeysym,$(ICONFIGFILES),$(KDB_DEFINES))
+SpecialCLibObjectRule(ConnDis,$(ICONFIGFILES),$(XDMAUTHDEFS) $(RPCDEFS) $(CONN_DEFINES) $(SOCK_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES) $(K5INCL) $(K5DEFS))
+SpecialCLibObjectRule(x11trans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_X_DEFINES) $(POLL_DEFINES))
+LinkFile(x11trans.c,$(TRANSCOMMSRC)/transport.c)
+SpecialCLibObjectRule(ximtrans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_XIM_DEFINES) $(POLL_DEFINES))
+LinkFile(ximtrans.c,$(TRANSCOMMSRC)/transport.c)
+SpecialCLibObjectRule(OpenDis,$(ICONFIGFILES),$(BC_DEFINES) $(OPEN_DEFINES) $(XTRANS_X_DEFINES) $(XKB_DEFINES))
+SpecialCLibObjectRule(Wrap,$(ICONFIGFILES),$(XDMAUTHDEFS))
+SpecialCLibObjectRule(XlibInt,$(ICONFIGFILES),$(CONN_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES))
+SpecialCLibObjectRule(Font,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES))
+SpecialCLibObjectRule(FontInfo,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES))
+SpecialCLibObjectRule(cmsColNm,$(ICONFIGFILES),$(CMS_DEFINES))
+SpecialCLibObjectRule(globals,$(ICONFIGFILES),$(CONN_DEFINES))
+SpecialCLibObjectRule(Context,$(ICONFIGFILES),$(BC_DEFINES))
+SpecialCLibObjectRule(Xrm,$(_NOOP_),$(RCONST_DEFINES))
+SpecialCLibObjectRule(imTransR,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES))
+SpecialCLibObjectRule(imTrans,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES))
+SpecialCLibObjectRule(lcFile,$(ICONFIGFILES),$(XLC_DEFINES) $(SETID_DEFINES))
+#if BuildXKBlib
+SpecialCLibObjectRule(XKBCvt,$(_NOOP_),$(RCONST_DEFINES))
+SpecialCLibObjectRule(KeyBind,$(ICONFIGFILES),$(XKB_DEFINES))
+SpecialCLibObjectRule(XKBBind,$(ICONFIGFILES),$(XKB_DEFINES))
+SpecialCLibObjectRule(imConv,$(ICONFIGFILES),$(XKB_DEFINES))
+#endif
+#if HasKrb5
+SpecialCLibObjectRule(k5encode,$(_NOOP_),$(K5INCL))
+#endif
+#if BuildLoadableXlibI18n
+SpecialCLibObjectRuleSeparateOpts(lcInit,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES))
+SpecialCLibObjectRuleSeparateOpts(lcGeneric,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES))
+SpecialCLibObjectRuleSeparateOpts(lcPublic,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES))
+#endif
+#if BuildLoadableXlibXcursor
+SpecialCLibObjectRuleSeparateOpts(CrCursor,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES))
+SpecialCLibObjectRuleSeparateOpts(CrGlCur,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES))
+SpecialCLibObjectRuleSeparateOpts(CrPixmap,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES))
+SpecialCLibObjectRuleSeparateOpts(PutImage,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES))
+#endif
+
+#if InstallXcmsTxt
+InstallNonExecFile(Xcms.txt,$(LIBDIR))
+#endif
+InstallNonExecFile(XErrorDB,$(LIBDIR))
+InstallNonExecFile(XKeysymDB,$(LIBDIR))
+InstallLintLibrary(X11,$(LINTLIBDIR))
+
+
+LinkSourceFile(AuDispose.c,$(XAUTHSRC))
+LinkSourceFile(AuGetBest.c,$(XAUTHSRC))
+LinkSourceFile(AuFileName.c,$(XAUTHSRC))
+LinkSourceFile(AuRead.c,$(XAUTHSRC))
+#if HasKrb5
+LinkSourceFile(k5encode.c,$(XAUTHSRC))
+#endif
+#if HasXdmAuth
+LinkSourceFile(Wrap.h,$(XDMCPLIBSRC))
+LinkSourceFile(Wrap.c,$(XDMCPLIBSRC))
+LinkSourceFile(Wraphelp.c,$(XDMCPLIBSRC))
+#endif
+
+#ifdef QNX4Architecture
+LOCAL_LDFLAGS=-F
+#endif
+
+MAKEKEYS = ./makekeys
+
+#if CrossCompiling
+HOST_LDLIBS=
+HOST_CFLAGS=$(TOP_INCLUDES) $(INCLUDES) $(BOOTSTRAPCFLAGS) \
+ $(CROSSCOMPILEDEFINES) $(CROSSCOMPILEBOOTSTRAPDEFINES)
+#else
+HOST_LDLIBS=$(LDLIBS)
+HOST_CFLAGS=$(CFLAGS)
+#endif
+
+ks_tables.h: $(XINCLUDESRC)/keysymdef.h util/makekeys.c
+ RemoveFiles($@ HostProgramTargetName(makekeys) makekeys.Osuf)
+ -HostLinkRule(HostProgramTargetName(makekeys),$(HOST_CFLAGS) $(LOCAL_LDFLAGS),util/makekeys.c,$(HOST_LDLIBS))
+ RunProgram(MAKEKEYS,< $(XINCLUDESRC)/keysymdef.h > ks_tables_h)
+ $(MV) ks_tables_h $@
+ RemoveFiles(HostProgramTargetName(makekeys) makekeys.Osuf ks_tables_h)
+
+includes:: ks_tables.h
+
+#if NXLibraries
+
+$(NX_XCOMPCONFIGTARGET):
+ cd ../../../nxcomp && \
+ ./configure
+
+$(NX_XCOMPEXTCONFIGTARGET):
+ cd ../../../nxcompext && \
+ ./configure
+
+#ifdef SunArchitecture
+$(NX_XCOMPLIBTARGET): $(NX_XCOMPCONFIGTARGET)
+ cd $(NX_XCOMPLIBDIR) && \
+ gmake
+
+$(NX_XCOMPEXTLIBTARGET): $(NX_XCOMPEXTCONFIGTARGET)
+ cd ../../../nxcompext && \
+ gmake
+
+#else
+$(NX_XCOMPLIBTARGET): $(NX_XCOMPCONFIGTARGET)
+ cd $(NX_XCOMPLIBDIR) && \
+ make
+
+$(NX_XCOMPEXTLIBTARGET): $(NX_XCOMPEXTCONFIGTARGET)
+ cd ../../../nxcompext && \
+ make
+
+#endif
+
+depend:: $(NX_XCOMPLIBTARGET)
+
+all:: $(NX_XCOMPLIBTARGET)
+
+$(NX_XCOMPDEPTARGET):
+ ln -s $(NX_XCOMPLIBDIR)/$(NX_XCOMPLIBNAME) $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME)
+ ln -s $(NX_XCOMPLIBDIR)/$(NX_XCOMPLIBNAME).1 $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME).1
+
+depend:: $(NX_XCOMPLIBTARGET)
+
+all:: $(NX_XCOMPDEPTARGET) $(NX_XCOMPEXTLIBTARGET)
+
+clean::
+ rm -f $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME)
+ rm -f $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME).1
+
+#endif
+
+depend:: ks_tables.h
+
+clean::
+ RemoveFiles(ks_tables_h ks_tables.h HostProgramTargetName(makekeys))
+
+
+DependTarget3($(SRCS1),$(SRCS2),$(SRCS3) $(EXTRASRCS))
+
+#if BuildLoadableXlibI18n
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(LINTSUBDIRS))
+MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln)
+#endif
+#endif
+
+includes:: XlibConf.h
+
+#include <Threads.tmpl>
+
+#if ThreadedProject
+#define XThreadsDefine echo '#ifndef XTHREADS' >> $@ @@\
+ echo '#define XTHREADS' >> $@ @@\
+ echo '#endif' >> $@
+#else
+#define XThreadsDefine echo '#undef XTHREADS' >> $@
+#endif
+
+#if HasThreadSafeAPI
+#define MTSafeAPIDefine echo '#ifndef XUSE_MTSAFE_API' >> $@ @@\
+ echo '#define XUSE_MTSAFE_API' >> $@ @@\
+ echo '#endif' >> $@
+#else
+#define MTSafeAPIDefine echo '#undef XUSE_MTSAFE_API' >> $@
+#endif
+
+XlibConf.h:
+ echo '/* Defines needed to use Xlib from non-imake projects */' > $@
+ XThreadsDefine
+ MTSafeAPIDefine
diff --git a/nx-X11/lib/X11/Imakefile.NX.original b/nx-X11/lib/X11/Imakefile.NX.original
new file mode 100644
index 000000000..d8d0601b8
--- /dev/null
+++ b/nx-X11/lib/X11/Imakefile.NX.original
@@ -0,0 +1,1237 @@
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:44:38 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/X11/Imakefile,v 3.52 2003/05/27 16:53:15 tsi Exp $
+
+
+
+ HEADERS = Xlib.h Xresource.h Xutil.h cursorfont.h Xlibint.h \
+ Xcms.h Xlocale.h XKBlib.h XlibConf.h Xregion.h ImUtil.h
+
+#if BuildServersOnly && !XWinServer && !XnestServer && !BuildGLXLibrary && !BuildClients && !XdmxServer && !NXAgentServer
+all::
+
+BuildIncludes($(HEADERS),IncSubdir,..)
+
+#else
+
+#if NXLibraries
+
+#ifdef SunArchitecture
+NX_INCLUDES = -I../../../nxcomp -I/usr/sfw/include
+#else
+NX_INCLUDES = -I../../../nxcomp
+#endif
+
+NX_DEFINES = -DNX_TRANS_SOCKET \
+ -DNX_TRANS_EXIT
+
+# -DNX_TRANS_CHANGE \
+# -DNX_TRANS_WARN \
+# -DNX_TRANS_INFO \
+# -DNX_TRANS_TEST \
+# -DNX_TRANS_DEBUG \
+
+#ifdef cygwinArchitecture
+NX_XCOMPLIBNAME = cygXcomp.dll
+NX_XCOMPEXTLIBNAME = cygXcompext.dll
+#else
+NX_XCOMPLIBNAME = libXcomp.so
+NX_XCOMPEXTLIBNAME = libXcompext.so
+#endif
+
+NX_XCOMPLIBDIR = $(XTOP)/../nxcomp
+NX_XCOMPLIBLINK = Xcomp
+NX_XCOMPLIBTARGET = $(NX_XCOMPLIBDIR)/$(NX_XCOMPLIBNAME)
+NX_REQUIREDLIBS = -L$(NX_XCOMPLIBDIR) -l$(NX_XCOMPLIBLINK)
+NX_XCOMPDEPTARGET = $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME)
+NX_XCOMPCONFIGTARGET = $(NX_XCOMPLIBDIR)/config.status
+
+NX_XCOMPEXTLIBDIR = $(XTOP)/../nxcompext
+NX_XCOMPEXTLIBTARGET = $(NX_XCOMPEXTLIBDIR)/$(NX_XCOMPEXTLIBNAME)
+NX_XCOMPEXTCONFIGTARGET = $(NX_XCOMPEXTLIBDIR)/config.status
+
+#endif
+
+#if BuildLoadableXlibI18n
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+#define NoLibSubdirs
+#endif
+
+#define DoNormalLib NormalLibX11
+#define DoSharedLib SharedLibX11
+#define DoExtraLib SharedLibX11
+#define DoDebugLib DebugLibX11
+#define DoProfileLib ProfileLibX11
+#define LibName X11
+#define SoRev SOXLIBREV
+#define HugeLibrary YES
+#define IncSubdir X11
+
+#if BuildLoadableXlibI18n
+SUBDIRS = xlibi18n
+#endif
+
+#include <Threads.tmpl>
+
+#ifndef MotifBC
+#define MotifBC NO
+#endif
+
+#ifdef SharedX11Reqs
+REQUIREDX11LIBS = SharedX11Reqs
+#endif
+#if BuildLoadableXlibI18n
+REQUIREDI18NLIBS = DlLibrary
+#endif
+#ifdef cygwinArchitecture
+EXCLUDE_SYMBOL = -Wl,--exclude-symbol,XdmcpWrap:_XdmcpWrapperToOddParity
+#endif
+
+REQUIREDLIBS=$(REQUIREDX11LIBS) $(REQUIREDI18NLIBS) $(EXCLUDE_SYMBOL) $(NX_REQUIREDLIBS)
+
+#if defined(MacIIArchitecture) || defined(SequentArchitecture) || defined(i386ScoArchitecture)
+XBSDLIB = /**/
+#endif
+#if defined(LunaArchitecture) && defined(Mc88000Architecture)
+EXTRA_LIBRARIES = /**/
+#endif
+#if Malloc0ReturnsNull
+ MALLOC_DEFINES = XMalloc0ReturnsNullDefines
+#endif
+#if HasXdmAuth
+ XDMAUTHDEFS = -DHASXDMAUTH
+ XDMAUTHOBJS = Wrap.o Wraphelp.o
+ XDMAUTHSRCS = Wrap.c Wraphelp.c
+#endif
+#if BuildXKBlib
+ XKB_DEFINES = -DXKB
+ XKBSRCS = XKB.c XKBBind.c XKBCompat.c XKBCtrls.c XKBCvt.c XKBGetMap.c \
+ XKBGetByName.c XKBNames.c XKBRdBuf.c XKBSetMap.c XKBUse.c \
+ XKBleds.c XKBBell.c XKBGeom.c XKBSetGeom.c XKBExtDev.c \
+ XKBList.c XKBMisc.c \
+ XKBMAlloc.c XKBGAlloc.c XKBAlloc.c
+ XKBOBJS = XKB.o XKBBind.o XKBCompat.o XKBCtrls.o XKBCvt.o XKBGetMap.o \
+ XKBGetByName.o XKBNames.o XKBRdBuf.o XKBSetMap.o XKBUse.o \
+ XKBleds.o XKBBell.o XKBGeom.o XKBSetGeom.o XKBExtDev.o \
+ XKBList.o XKBMisc.o \
+ XKBMAlloc.o XKBGAlloc.o XKBAlloc.o
+#endif
+#if HasSecureRPC
+ RPCDEFS = -DSECURE_RPC
+#endif
+#if HasPoll
+ POLL_DEFINES = -DUSE_POLL
+#endif
+ CONN_DEFINES = $(CONNECTION_FLAGS)
+ XTRANS_X_DEFINES = -DX11_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES)
+ XTRANS_XIM_DEFINES = -DXIM_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES)
+#if HasBSD44Sockets
+ SOCK_DEFINES = -DBSD44SOCKETS
+#endif
+#if HasShm
+ SHM_DEFINES = -DHAS_SHM
+#endif
+
+ XF86BIGFONT_DEFINES = XF86BigfontExtensionDefines
+
+ EDB_DEFINES = -DERRORDB=\"$(LIBDIR)/XErrorDB\"
+ KDB_DEFINES = -DKEYSYMDB=\"$(LIBDIR)/XKeysymDB\"
+ CMS_DEFINES = -DXCMSDB=\"$(LIBDIR)/Xcms.txt\"
+#if HasSnprintf
+ MISC_DEFINES = -DHAS_SNPRINTF -DLIBX11
+#endif
+#if MotifBC
+ BC_DEFINES = -DMOTIFBC
+#endif
+#if NoRConst
+ RCONST_DEFINES = -DNORCONST
+#endif
+#if DisableXLocaleDirEnv
+ SETID_DEFINES = -DNO_XLOCALEDIR
+#elif HasIssetugid
+ SETID_DEFINES = -DHASSETUGID
+#elif HasGetresuid
+ SETID_DEFINES = -DHASGETRESUID
+#endif
+ XLC_DEFINES = -DXLOCALEDIR=\"$(XLOCALEDIR)\"
+#if HasKrb5
+ K5OBJS = k5encode.o
+ K5SRCS = k5encode.c
+ K5INCL = Krb5Includes
+ K5DEFS = Krb5Defines
+#endif
+#if (defined(FreeBSDArchitecture) && OSRelVersion < 500016) || \
+ defined(OpenBSDArchitecture)
+THRSTUBSRCS = UIThrStubs.c
+THRSTUBOBJS = UIThrStubs.o
+#endif
+#if BuildLoadableXlibXcursor
+XCURSOR_DEFINES = -DUSE_DYNAMIC_XCURSOR -DLIBXCURSOR=\"libXcursor.so.$(SOXCURSORREV)\"
+#endif
+#if NeedLibInsideFlag
+ LIB_DEFINES = -D_XLIBINT_
+#endif
+#if defined(LibDirName)
+ POSTLOCALELIBDIR = LibDirName
+ POSTLOCALELIBDEFINES = -DPOSTLOCALELIBDIR=\"$(POSTLOCALELIBDIR)\"
+#endif
+ DEFINES = $(MALLOC_DEFINES) $(LIB_DEFINES) $(MISC_DEFINES)\
+ $(POSTLOCALELIBDEFINES) $(NX_INCLUDES) $(NX_DEFINES)
+ OPEN_DEFINES = -I$(EXTINCSRC) $(K5INCL) $(K5DEFS)
+ DEPEND_DEFINES = $(OPEN_DEFINES) $(TRANS_INCLUDES) $(CONN_DEFINES) $(THREADS_DEFINES) DependDefines
+ AUTHOBJS = AuDispose.o AuGetBest.o AuFileName.o AuRead.o
+ AUTHSRCS = AuDispose.c AuGetBest.c AuFileName.c AuRead.c
+ SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(EXTRASRCS) /* try *.c if you have trouble */
+ LINTLIBS =
+
+#if BuildLoadableXlibI18n && DoSharedLib
+EXTRASHAREDSRC = $(SHAREDLCSRCS)
+#endif
+#if !BuildLoadableXlibI18n || DoNormalLib
+EXTRASTATICSRC = $(STATICLCSRCS)
+#endif
+
+EXTRASRCS = $(EXTRASHAREDSRC) $(EXTRASTATICSRC)
+
+SRCS1 = \
+ Context.c \
+ Depths.c \
+ ParseCmd.c \
+ Quarks.c \
+ AllCells.c \
+ AllPlanes.c \
+ AllowEv.c \
+ AutoRep.c \
+ Backgnd.c \
+ BdrWidth.c \
+ Bell.c \
+ Border.c \
+ ChAccCon.c \
+ ChClMode.c \
+ ChActPGb.c \
+ ChCmap.c \
+ ChGC.c \
+ ChKeyCon.c \
+ ChPntCon.c \
+ ChProp.c \
+ ChSaveSet.c \
+ ChWAttrs.c \
+ ChWindow.c \
+ ChkIfEv.c \
+ ChkMaskEv.c \
+ ChkWinEv.c \
+ ChkTypEv.c \
+ ChkTypWEv.c \
+ CirWin.c \
+ CirWinDn.c \
+ CirWinUp.c \
+ ClDisplay.c \
+ Clear.c \
+ ClearArea.c \
+ ConfWind.c \
+ ConnDis.c \
+ ConvSel.c \
+ CopyArea.c \
+ CopyCmap.c \
+ CopyGC.c \
+ CopyPlane.c \
+ CrBFData.c \
+ CrCmap.c \
+ CrCursor.c \
+ CrGC.c \
+ CrGlCur.c \
+ CrPFBData.c \
+ CrPixmap.c \
+ CrWindow.c \
+ Cursor.c \
+ DefCursor.c \
+ DelProp.c \
+ DestSubs.c \
+ DestWind.c \
+ DisName.c \
+ DrArc.c \
+ DrArcs.c \
+ DrLine.c \
+ DrLines.c \
+ DrPoint.c \
+ DrPoints.c \
+ DrRect.c \
+ DrRects.c \
+ DrSegs.c \
+ ErrDes.c \
+ ErrHndlr.c \
+ EvToWire.c \
+ FetchName.c \
+ FillArc.c \
+ FillArcs.c \
+ FillPoly.c \
+ FillRct.c \
+ FillRcts.c \
+ Flush.c \
+ Font.c \
+ FontNames.c \
+ FontInfo.c \
+ FreeCmap.c \
+ FreeCols.c \
+ FreeCurs.c \
+ FreeEData.c \
+ FreeGC.c \
+ FreePix.c \
+ FSSaver.c \
+ GCMisc.c \
+ Geom.c \
+ GetAtomNm.c \
+ GetColor.c \
+ GetDflt.c \
+ GetFPath.c \
+ GetFProp.c \
+ GetGeom.c \
+ GetHColor.c \
+ GetHints.c \
+ GetIFocus.c \
+ GetImage.c \
+ GetKCnt.c \
+ GetMoEv.c \
+ GetPCnt.c \
+ GetPntMap.c \
+ GetProp.c \
+ GetSOwner.c \
+ GetSSaver.c \
+ GetStCmap.c \
+ GetWAttrs.c \
+ GrButton.c \
+ GrKey.c \
+ GrKeybd.c \
+ GrPointer.c \
+ GrServer.c \
+ Host.c \
+ IfEvent.c \
+ ImUtil.c \
+ ImText.c \
+ ImText16.c \
+ InitExt.c \
+ InsCmap.c \
+ IntAtom.c \
+ KeyBind.c \
+ KeysymStr.c \
+ KillCl.c \
+ LiHosts.c \
+ LiICmaps.c \
+ LiProps.c \
+ ListExt.c \
+ LoadFont.c \
+ LookupCol.c \
+ LowerWin.c
+
+OBJS1 = \
+ Context.o \
+ Depths.o \
+ ParseCmd.o \
+ Quarks.o \
+ AllCells.o \
+ AllPlanes.o \
+ AllowEv.o \
+ AutoRep.o \
+ Backgnd.o \
+ BdrWidth.o \
+ Bell.o \
+ Border.o \
+ ChAccCon.o \
+ ChClMode.o \
+ ChActPGb.o \
+ ChCmap.o \
+ ChGC.o \
+ ChKeyCon.o \
+ ChPntCon.o \
+ ChProp.o \
+ ChSaveSet.o \
+ ChWAttrs.o \
+ ChWindow.o \
+ ChkIfEv.o \
+ ChkMaskEv.o \
+ ChkWinEv.o \
+ ChkTypEv.o \
+ ChkTypWEv.o \
+ CirWin.o \
+ CirWinDn.o \
+ CirWinUp.o \
+ ClDisplay.o \
+ Clear.o \
+ ClearArea.o \
+ ConfWind.o \
+ ConnDis.o \
+ ConvSel.o \
+ CopyArea.o \
+ CopyCmap.o \
+ CopyGC.o \
+ CopyPlane.o \
+ CrBFData.o \
+ CrCmap.o \
+ CrCursor.o \
+ CrGC.o \
+ CrGlCur.o \
+ CrPFBData.o \
+ CrPixmap.o \
+ CrWindow.o \
+ Cursor.o \
+ DefCursor.o \
+ DelProp.o \
+ DestSubs.o \
+ DestWind.o \
+ DisName.o \
+ DrArc.o \
+ DrArcs.o \
+ DrLine.o \
+ DrLines.o \
+ DrPoint.o \
+ DrPoints.o \
+ DrRect.o \
+ DrRects.o \
+ DrSegs.o \
+ ErrDes.o \
+ ErrHndlr.o \
+ EvToWire.o \
+ FetchName.o \
+ FillArc.o \
+ FillArcs.o \
+ FillPoly.o \
+ FillRct.o \
+ FillRcts.o \
+ Flush.o \
+ Font.o \
+ FontNames.o \
+ FontInfo.o \
+ FreeCmap.o \
+ FreeCols.o \
+ FreeCurs.o \
+ FreeEData.o \
+ FreeGC.o \
+ FreePix.o \
+ FSSaver.o \
+ GCMisc.o \
+ Geom.o \
+ GetAtomNm.o \
+ GetColor.o \
+ GetDflt.o \
+ GetFPath.o \
+ GetFProp.o \
+ GetGeom.o \
+ GetHColor.o \
+ GetHints.o \
+ GetIFocus.o \
+ GetImage.o \
+ GetKCnt.o \
+ GetMoEv.o \
+ GetPCnt.o \
+ GetPntMap.o \
+ GetProp.o \
+ GetSOwner.o \
+ GetSSaver.o \
+ GetStCmap.o \
+ GetWAttrs.o \
+ GrButton.o \
+ GrKey.o \
+ GrKeybd.o \
+ GrPointer.o \
+ GrServer.o \
+ Host.o \
+ IfEvent.o \
+ ImUtil.o \
+ ImText.o \
+ ImText16.o \
+ InitExt.o \
+ InsCmap.o \
+ IntAtom.o \
+ KeyBind.o \
+ KeysymStr.o \
+ KillCl.o \
+ LiHosts.o \
+ LiICmaps.o \
+ LiProps.o \
+ ListExt.o \
+ LoadFont.o \
+ LookupCol.o \
+ LowerWin.o
+
+SRCS2 = \
+ Macros.c \
+ MapRaised.c \
+ MapSubs.c \
+ MapWindow.c \
+ MaskEvent.c \
+ Misc.c \
+ ModMap.c \
+ MoveWin.c \
+ NextEvent.c \
+ OpenDis.c \
+ ParseCol.c \
+ ParseGeom.c \
+ PeekEvent.c \
+ PeekIfEv.c \
+ Pending.c \
+ PmapBgnd.c \
+ PmapBord.c \
+ PolyReg.c \
+ PolyTxt.c \
+ PolyTxt16.c \
+ PutBEvent.c \
+ PutImage.c \
+ QuBest.c \
+ QuColor.c \
+ QuColors.c \
+ QuCurShp.c \
+ QuExt.c \
+ QuKeybd.c \
+ QuPntr.c \
+ QuStipShp.c \
+ QuTextE16.c \
+ QuTextExt.c \
+ QuTileShp.c \
+ QuTree.c \
+ RaiseWin.c \
+ RdBitF.c \
+ RecolorC.c \
+ ReconfWin.c \
+ Region.c \
+ RepWindow.c \
+ RestackWs.c \
+ RotProp.c \
+ ScrResStr.c \
+ SelInput.c \
+ SendEvent.c \
+ SetBack.c \
+ SetCRects.c \
+ SetClMask.c \
+ SetClOrig.c \
+ SetDashes.c \
+ SetFPath.c \
+ SetFont.c \
+ SetFore.c \
+ SetFunc.c \
+ SetHints.c \
+ SetIFocus.c \
+ SetLStyle.c \
+ SetPMask.c \
+ SetPntMap.c \
+ SetSOwner.c \
+ SetSSaver.c \
+ SetState.c \
+ SetStip.c \
+ SetStCmap.c \
+ SetTile.c \
+ SetTSOrig.c \
+ StBytes.c \
+ StColor.c \
+ StColors.c \
+ StNColor.c \
+ StName.c \
+ StrKeysym.c \
+ Sync.c \
+ Synchro.c \
+ Text.c \
+ Text16.c \
+ TextExt.c \
+ TextExt16.c \
+ TrCoords.c \
+ UndefCurs.c \
+ UngrabBut.c \
+ UngrabKbd.c \
+ UngrabKey.c \
+ UngrabPtr.c \
+ UngrabSvr.c \
+ UninsCmap.c \
+ UnldFont.c \
+ UnmapSubs.c \
+ UnmapWin.c \
+ VisUtil.c \
+ WarpPtr.c \
+ WinEvent.c \
+ Window.c \
+ WrBitF.c \
+ XlibAsync.c \
+ XlibInt.c \
+ Xrm.c \
+ evtomask.c \
+ globals.c \
+ GetGCVals.c \
+ GetNrmHint.c \
+ GetRGBCMap.c \
+ GetTxtProp.c \
+ GetWMCMapW.c \
+ GetWMProto.c \
+ Iconify.c \
+ PixFormats.c \
+ PropAlloc.c \
+ ReconfWM.c \
+ SetNrmHint.c \
+ SetRGBCMap.c \
+ SetTxtProp.c \
+ SetWMCMapW.c \
+ SetWMProto.c \
+ StrToText.c \
+ TextToStr.c \
+ Withdraw.c \
+ WMGeom.c \
+ WMProps.c \
+ $(AUTHSRCS) $(XDMAUTHSRCS) $(K5SRCS) $(THRSTUBSRCS)
+
+OBJS2 = \
+ Macros.o \
+ MapRaised.o \
+ MapSubs.o \
+ MapWindow.o \
+ MaskEvent.o \
+ Misc.o \
+ ModMap.o \
+ MoveWin.o \
+ NextEvent.o \
+ OpenDis.o \
+ ParseCol.o \
+ ParseGeom.o \
+ PeekEvent.o \
+ PeekIfEv.o \
+ Pending.o \
+ PmapBgnd.o \
+ PmapBord.o \
+ PolyReg.o \
+ PolyTxt.o \
+ PolyTxt16.o \
+ PutBEvent.o \
+ PutImage.o \
+ QuBest.o \
+ QuColor.o \
+ QuColors.o \
+ QuCurShp.o \
+ QuExt.o \
+ QuKeybd.o \
+ QuPntr.o \
+ QuStipShp.o \
+ QuTextE16.o \
+ QuTextExt.o \
+ QuTileShp.o \
+ QuTree.o \
+ RaiseWin.o \
+ RdBitF.o \
+ RecolorC.o \
+ ReconfWin.o \
+ Region.o \
+ RepWindow.o \
+ RestackWs.o \
+ RotProp.o \
+ ScrResStr.o \
+ SelInput.o \
+ SendEvent.o \
+ SetBack.o \
+ SetCRects.o \
+ SetClMask.o \
+ SetClOrig.o \
+ SetDashes.o \
+ SetFPath.o \
+ SetFont.o \
+ SetFore.o \
+ SetFunc.o \
+ SetHints.o \
+ SetIFocus.o \
+ SetLStyle.o \
+ SetPMask.o \
+ SetPntMap.o \
+ SetSOwner.o \
+ SetSSaver.o \
+ SetState.o \
+ SetStip.o \
+ SetStCmap.o \
+ SetTile.o \
+ SetTSOrig.o \
+ StBytes.o \
+ StColor.o \
+ StColors.o \
+ StNColor.o \
+ StName.o \
+ StrKeysym.o \
+ Sync.o \
+ Synchro.o \
+ Text.o \
+ Text16.o \
+ TextExt.o \
+ TextExt16.o \
+ TrCoords.o \
+ UndefCurs.o \
+ UngrabBut.o \
+ UngrabKbd.o \
+ UngrabKey.o \
+ UngrabPtr.o \
+ UngrabSvr.o \
+ UninsCmap.o \
+ UnldFont.o \
+ UnmapSubs.o \
+ UnmapWin.o \
+ VisUtil.o \
+ WarpPtr.o \
+ WinEvent.o \
+ Window.o \
+ WrBitF.o \
+ XlibAsync.o \
+ XlibInt.o \
+ Xrm.o \
+ evtomask.o \
+ globals.o \
+ GetGCVals.o \
+ GetNrmHint.o \
+ GetRGBCMap.o \
+ GetTxtProp.o \
+ GetWMCMapW.o \
+ GetWMProto.o \
+ Iconify.o \
+ PixFormats.o \
+ PropAlloc.o \
+ ReconfWM.o \
+ SetNrmHint.o \
+ SetRGBCMap.o \
+ SetTxtProp.o \
+ SetWMCMapW.o \
+ SetWMProto.o \
+ StrToText.o \
+ TextToStr.o \
+ Withdraw.o \
+ WMGeom.o \
+ WMProps.o \
+ $(AUTHOBJS) \
+ $(XDMAUTHOBJS) \
+ $(K5OBJS) \
+ $(THRSTUBOBJS)
+
+SRCS3 = \
+ Lab.c \
+ LabGcC.c \
+ LabGcL.c \
+ LabGcLC.c \
+ LabMnL.c \
+ LabMxC.c \
+ LabMxL.c \
+ LabMxLC.c \
+ LabWpAj.c \
+ Luv.c \
+ LuvGcC.c \
+ LuvGcL.c \
+ LuvGcLC.c \
+ LuvMnL.c \
+ LuvMxC.c \
+ LuvMxL.c \
+ LuvMxLC.c \
+ LuvWpAj.c \
+ XYZ.c \
+ uvY.c \
+ xyY.c \
+ HVC.c \
+ HVCGcC.c \
+ HVCGcV.c \
+ HVCGcVC.c \
+ HVCMnV.c \
+ HVCMxC.c \
+ HVCMxV.c \
+ HVCMxVC.c \
+ HVCMxVs.c \
+ HVCWpAj.c \
+ UNDEFINED.c \
+ AddDIC.c \
+ AddSF.c \
+ cmsAllNCol.c \
+ cmsAllCol.c \
+ CCC.c \
+ cmsCmap.c \
+ cmsColNm.c \
+ CvColW.c \
+ CvCols.c \
+ cmsGlobls.c \
+ IdOfPr.c \
+ cmsInt.c \
+ LRGB.c \
+ cmsLkCol.c \
+ cmsMath.c \
+ OfCCC.c \
+ PrOfId.c \
+ cmsProp.c \
+ QBlack.c \
+ QBlue.c \
+ QGreen.c \
+ QRed.c \
+ QWhite.c \
+ QuCol.c \
+ QuCols.c \
+ SetCCC.c \
+ SetGetCols.c \
+ StCol.c \
+ StCols.c \
+ cmsTrig.c \
+ XRGB.c \
+ FSWrap.c \
+ ICWrap.c \
+ IMWrap.c \
+ OCWrap.c \
+ OMWrap.c \
+ lcWrap.c \
+ mbWMProps.c \
+ utf8WMProps.c \
+ mbWrap.c \
+ wcWrap.c \
+ utf8Wrap.c \
+ FilterEv.c \
+ RegstFlt.c \
+ locking.c \
+ LockDis.c \
+ x11trans.c \
+ ximtrans.c \
+ $(XKBSRCS) $(LCSRCS) $(MISCSRCS)
+
+OBJS3 = \
+ Lab.o \
+ LabGcC.o \
+ LabGcL.o \
+ LabGcLC.o \
+ LabMnL.o \
+ LabMxC.o \
+ LabMxL.o \
+ LabMxLC.o \
+ LabWpAj.o \
+ Luv.o \
+ LuvGcC.o \
+ LuvGcL.o \
+ LuvGcLC.o \
+ LuvMnL.o \
+ LuvMxC.o \
+ LuvMxL.o \
+ LuvMxLC.o \
+ LuvWpAj.o \
+ XYZ.o \
+ uvY.o \
+ xyY.o \
+ HVC.o \
+ HVCGcC.o \
+ HVCGcV.o \
+ HVCGcVC.o \
+ HVCMnV.o \
+ HVCMxC.o \
+ HVCMxV.o \
+ HVCMxVC.o \
+ HVCMxVs.o \
+ HVCWpAj.o \
+ UNDEFINED.o \
+ AddDIC.o \
+ AddSF.o \
+ cmsAllNCol.o \
+ cmsAllCol.o \
+ CCC.o \
+ cmsCmap.o \
+ cmsColNm.o \
+ CvColW.o \
+ CvCols.o \
+ cmsGlobls.o \
+ IdOfPr.o \
+ cmsInt.o \
+ LRGB.o \
+ cmsLkCol.o \
+ cmsMath.o \
+ OfCCC.o \
+ PrOfId.o \
+ cmsProp.o \
+ QBlack.o \
+ QBlue.o \
+ QGreen.o \
+ QRed.o \
+ QWhite.o \
+ QuCol.o \
+ QuCols.o \
+ SetCCC.o \
+ SetGetCols.o \
+ StCol.o \
+ StCols.o \
+ cmsTrig.o \
+ XRGB.o \
+ FSWrap.o \
+ ICWrap.o \
+ IMWrap.o \
+ OCWrap.o \
+ OMWrap.o \
+ lcWrap.o \
+ mbWMProps.o \
+ utf8WMProps.o \
+ mbWrap.o \
+ wcWrap.o \
+ utf8Wrap.o \
+ FilterEv.o \
+ RegstFlt.o \
+ locking.o \
+ LockDis.o \
+ x11trans.o \
+ ximtrans.o \
+ $(XKBOBJS) $(LCOBJS) $(MISCOBJS)
+
+#if BuildLoadableXlibI18n
+LC_DYNDEFINES = -DUSE_DYNAMIC_LC
+#endif
+
+SHAREDLCDEPSYMSRCS = XlcDL.c XlcSL.c
+
+SHAREDI18NSTATICSRCS = \
+ XDefaultIMIF.c XDefaultOMIF.c
+
+STATICLCDEPSYMSRCS =
+
+STATICI18NSTATICSRCS = \
+ imCallbk.c \
+ imDefFlt.c \
+ imDefIc.c \
+ imDefIm.c \
+ imDefLkup.c \
+ imDispch.c \
+ imEvToWire.c \
+ imExten.c \
+ imImSw.c \
+ imInsClbk.c \
+ imInt.c \
+ imLcFlt.c \
+ imLcGIc.c \
+ imLcIc.c \
+ imLcIm.c \
+ imLcLkup.c \
+ imLcPrs.c \
+ imLcSIc.c \
+ imRm.c \
+ imRmAttr.c \
+ imThaiFlt.c \
+ imThaiIc.c \
+ imThaiIm.c \
+ imTrX.c \
+ imTransR.c \
+ imTrans.c \
+ lcEuc.c \
+ lcGenConv.c \
+ lcJis.c \
+ lcSjis.c \
+ lcUTF8Load.c \
+ omDefault.c \
+ omGeneric.c \
+ omImText.c \
+ omText.c \
+ omTextEsc.c \
+ omTextExt.c \
+ omTextPer.c \
+ omXChar.c
+
+LCSRCS = \
+ SetLocale.c \
+ imConv.c \
+ imKStoUCS.c \
+ lcCT.c \
+ lcCharSet.c \
+ lcConv.c \
+ lcDB.c \
+ lcDefConv.c \
+ lcFile.c \
+ lcGeneric.c \
+ lcInit.c \
+ lcPrTxt.c \
+ lcPubWrap.c \
+ lcPublic.c \
+ lcRM.c \
+ lcStd.c \
+ lcTxtPr.c \
+ lcUtil.c \
+ lcUTF8.c
+
+STATICLCSRCS = \
+ $(STATICLCDEPSYMSRCS) \
+ $(STATICI18NSTATICSRCS)
+
+SHAREDLCSRCS = \
+ $(SHAREDLCDEPSYMSRCS) \
+ $(SHAREDI18NSTATICSRCS)
+
+SHAREDLCDEPOBJS = XlcDL.o XlcSL.o
+SHAREDI18NSTATICOBJS = \
+ XDefaultIMIF.o XDefaultOMIF.o
+STATICLCDEPOBJS =
+STATICI18NSTATICOBJS = \
+ imCallbk.o \
+ imDefFlt.o \
+ imDefIc.o \
+ imDefIm.o \
+ imDefLkup.o \
+ imDispch.o \
+ imEvToWire.o \
+ imExten.o \
+ imImSw.o \
+ imInsClbk.o \
+ imInt.o \
+ imLcFlt.o \
+ imLcGIc.o \
+ imLcIc.o \
+ imLcIm.o \
+ imLcLkup.o \
+ imLcPrs.o \
+ imLcSIc.o \
+ imRm.o \
+ imRmAttr.o \
+ imThaiFlt.o \
+ imThaiIc.o \
+ imThaiIm.o \
+ imTrX.o \
+ imTransR.o \
+ imTrans.o \
+ lcEuc.o \
+ lcGenConv.o \
+ lcJis.o \
+ lcSjis.o \
+ lcUTF8Load.o \
+ omDefault.o \
+ omGeneric.o \
+ omImText.o \
+ omText.o \
+ omTextEsc.o \
+ omTextExt.o \
+ omTextPer.o \
+ omXChar.o
+
+LCOBJS = \
+ SetLocale.o \
+ imConv.o \
+ imKStoUCS.o \
+ lcCT.o \
+ lcCharSet.o \
+ lcConv.o \
+ lcDB.o \
+ lcDefConv.o \
+ lcFile.o \
+ lcGeneric.o \
+ lcInit.o \
+ lcPrTxt.o \
+ lcPubWrap.o \
+ lcPublic.o \
+ lcRM.o \
+ lcStd.o \
+ lcTxtPr.o \
+ lcUtil.o \
+ lcUTF8.o
+
+STATICLCOBJS = \
+ $(STATICLCDEPOBJS) \
+ $(STATICI18NSTATICOBJS)
+
+SHAREDLCOBJS = \
+ $(SHAREDLCDEPOBJS) \
+ $(SHAREDI18NSTATICOBJS)
+
+#ifdef OS2Architecture
+MISCSRCS = os2Stubs.c
+#endif
+
+#ifdef OS2Architecture
+MISCOBJS = os2Stubs.o
+#endif
+
+OBJS = $(OBJS1) $(OBJS2) $(OBJS3)
+
+EXTRAUNSHAREDOBJS = $(STATICLCOBJS)
+
+#if BuildLoadableXlibI18n
+EXTRASHAREDOBJS = $(SHAREDLCOBJS)
+# else
+EXTRASHAREDOBJS = $(STATICLCOBJS)
+#endif
+
+#include <Library.tmpl>
+
+SpecialCLibObjectRule(ErrDes,$(ICONFIGFILES),$(EDB_DEFINES))
+SpecialCLibObjectRule(StrKeysym,$(ICONFIGFILES),$(KDB_DEFINES))
+SpecialCLibObjectRule(ConnDis,$(ICONFIGFILES),$(XDMAUTHDEFS) $(RPCDEFS) $(CONN_DEFINES) $(SOCK_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES) $(K5INCL) $(K5DEFS))
+SpecialCLibObjectRule(x11trans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_X_DEFINES) $(POLL_DEFINES))
+LinkFile(x11trans.c,$(TRANSCOMMSRC)/transport.c)
+SpecialCLibObjectRule(ximtrans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_XIM_DEFINES) $(POLL_DEFINES))
+LinkFile(ximtrans.c,$(TRANSCOMMSRC)/transport.c)
+SpecialCLibObjectRule(OpenDis,$(ICONFIGFILES),$(BC_DEFINES) $(OPEN_DEFINES) $(XTRANS_X_DEFINES) $(XKB_DEFINES))
+SpecialCLibObjectRule(Wrap,$(ICONFIGFILES),$(XDMAUTHDEFS))
+SpecialCLibObjectRule(XlibInt,$(ICONFIGFILES),$(CONN_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES))
+SpecialCLibObjectRule(Font,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES))
+SpecialCLibObjectRule(FontInfo,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES))
+SpecialCLibObjectRule(cmsColNm,$(ICONFIGFILES),$(CMS_DEFINES))
+SpecialCLibObjectRule(globals,$(ICONFIGFILES),$(CONN_DEFINES))
+SpecialCLibObjectRule(Context,$(ICONFIGFILES),$(BC_DEFINES))
+SpecialCLibObjectRule(Xrm,$(_NOOP_),$(RCONST_DEFINES))
+SpecialCLibObjectRule(imTransR,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES))
+SpecialCLibObjectRule(imTrans,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES))
+SpecialCLibObjectRule(lcFile,$(ICONFIGFILES),$(XLC_DEFINES) $(SETID_DEFINES))
+#if BuildXKBlib
+SpecialCLibObjectRule(XKBCvt,$(_NOOP_),$(RCONST_DEFINES))
+SpecialCLibObjectRule(KeyBind,$(ICONFIGFILES),$(XKB_DEFINES))
+SpecialCLibObjectRule(XKBBind,$(ICONFIGFILES),$(XKB_DEFINES))
+SpecialCLibObjectRule(imConv,$(ICONFIGFILES),$(XKB_DEFINES))
+#endif
+#if HasKrb5
+SpecialCLibObjectRule(k5encode,$(_NOOP_),$(K5INCL))
+#endif
+#if BuildLoadableXlibI18n
+SpecialCLibObjectRuleSeparateOpts(lcInit,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES))
+SpecialCLibObjectRuleSeparateOpts(lcGeneric,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES))
+SpecialCLibObjectRuleSeparateOpts(lcPublic,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES))
+#endif
+#if BuildLoadableXlibXcursor
+SpecialCLibObjectRuleSeparateOpts(CrCursor,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES))
+SpecialCLibObjectRuleSeparateOpts(CrGlCur,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES))
+SpecialCLibObjectRuleSeparateOpts(CrPixmap,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES))
+SpecialCLibObjectRuleSeparateOpts(PutImage,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES))
+#endif
+
+#if InstallXcmsTxt
+InstallNonExecFile(Xcms.txt,$(LIBDIR))
+#endif
+InstallNonExecFile(XErrorDB,$(LIBDIR))
+InstallNonExecFile(XKeysymDB,$(LIBDIR))
+InstallLintLibrary(X11,$(LINTLIBDIR))
+
+
+LinkSourceFile(AuDispose.c,$(XAUTHSRC))
+LinkSourceFile(AuGetBest.c,$(XAUTHSRC))
+LinkSourceFile(AuFileName.c,$(XAUTHSRC))
+LinkSourceFile(AuRead.c,$(XAUTHSRC))
+#if HasKrb5
+LinkSourceFile(k5encode.c,$(XAUTHSRC))
+#endif
+#if HasXdmAuth
+LinkSourceFile(Wrap.h,$(XDMCPLIBSRC))
+LinkSourceFile(Wrap.c,$(XDMCPLIBSRC))
+LinkSourceFile(Wraphelp.c,$(XDMCPLIBSRC))
+#endif
+
+#ifdef QNX4Architecture
+LOCAL_LDFLAGS=-F
+#endif
+
+MAKEKEYS = ./makekeys
+
+#if CrossCompiling
+HOST_LDLIBS=
+HOST_CFLAGS=$(TOP_INCLUDES) $(INCLUDES) $(BOOTSTRAPCFLAGS) \
+ $(CROSSCOMPILEDEFINES) $(CROSSCOMPILEBOOTSTRAPDEFINES)
+#else
+HOST_LDLIBS=$(LDLIBS)
+HOST_CFLAGS=$(CFLAGS)
+#endif
+
+ks_tables.h: $(XINCLUDESRC)/keysymdef.h util/makekeys.c
+ RemoveFiles($@ HostProgramTargetName(makekeys) makekeys.Osuf)
+ -HostLinkRule(HostProgramTargetName(makekeys),$(HOST_CFLAGS) $(LOCAL_LDFLAGS),util/makekeys.c,$(HOST_LDLIBS))
+ RunProgram(MAKEKEYS,< $(XINCLUDESRC)/keysymdef.h > ks_tables_h)
+ $(MV) ks_tables_h $@
+ RemoveFiles(HostProgramTargetName(makekeys) makekeys.Osuf ks_tables_h)
+
+includes:: ks_tables.h
+
+#if NXLibraries
+
+$(NX_XCOMPCONFIGTARGET):
+ cd ../../../nxcomp && \
+ ./configure
+
+$(NX_XCOMPEXTCONFIGTARGET):
+ cd ../../../nxcompext && \
+ ./configure
+
+#ifdef SunArchitecture
+$(NX_XCOMPLIBTARGET): $(NX_XCOMPCONFIGTARGET)
+ cd $(NX_XCOMPLIBDIR) && \
+ gmake
+
+$(NX_XCOMPEXTLIBTARGET): $(NX_XCOMPEXTCONFIGTARGET)
+ cd ../../../nxcompext && \
+ gmake
+
+#else
+$(NX_XCOMPLIBTARGET): $(NX_XCOMPCONFIGTARGET)
+ cd $(NX_XCOMPLIBDIR) && \
+ make
+
+$(NX_XCOMPEXTLIBTARGET): $(NX_XCOMPEXTCONFIGTARGET)
+ cd ../../../nxcompext && \
+ make
+
+#endif
+
+depend:: $(NX_XCOMPLIBTARGET)
+
+all:: $(NX_XCOMPLIBTARGET)
+
+$(NX_XCOMPDEPTARGET):
+ ln -s $(NX_XCOMPLIBDIR)/$(NX_XCOMPLIBNAME) $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME)
+ ln -s $(NX_XCOMPLIBDIR)/$(NX_XCOMPLIBNAME).1 $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME).1
+
+depend:: $(NX_XCOMPLIBTARGET)
+
+all:: $(NX_XCOMPDEPTARGET) $(NX_XCOMPEXTLIBTARGET)
+
+clean::
+ rm -f $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME)
+ rm -f $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME).1
+
+#endif
+
+depend:: ks_tables.h
+
+clean::
+ RemoveFiles(ks_tables_h ks_tables.h HostProgramTargetName(makekeys))
+
+
+DependTarget3($(SRCS1),$(SRCS2),$(SRCS3) $(EXTRASRCS))
+
+#if BuildLoadableXlibI18n
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(LINTSUBDIRS))
+MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln)
+#endif
+#endif
+
+includes:: XlibConf.h
+
+#include <Threads.tmpl>
+
+#if ThreadedProject
+#define XThreadsDefine echo '#ifndef XTHREADS' >> $@ @@\
+ echo '#define XTHREADS' >> $@ @@\
+ echo '#endif' >> $@
+#else
+#define XThreadsDefine echo '#undef XTHREADS' >> $@
+#endif
+
+#if HasThreadSafeAPI
+#define MTSafeAPIDefine echo '#ifndef XUSE_MTSAFE_API' >> $@ @@\
+ echo '#define XUSE_MTSAFE_API' >> $@ @@\
+ echo '#endif' >> $@
+#else
+#define MTSafeAPIDefine echo '#undef XUSE_MTSAFE_API' >> $@
+#endif
+
+XlibConf.h:
+ echo '/* Defines needed to use Xlib from non-imake projects */' > $@
+ XThreadsDefine
+ MTSafeAPIDefine
diff --git a/nx-X11/lib/X11/Imakefile.X.original b/nx-X11/lib/X11/Imakefile.X.original
new file mode 100644
index 000000000..1f2c9b2bc
--- /dev/null
+++ b/nx-X11/lib/X11/Imakefile.X.original
@@ -0,0 +1,1134 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:44:38 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/X11/Imakefile,v 3.52 2003/05/27 16:53:15 tsi Exp $
+
+
+
+ HEADERS = Xlib.h Xresource.h Xutil.h cursorfont.h Xlibint.h \
+ Xcms.h Xlocale.h XKBlib.h XlibConf.h Xregion.h ImUtil.h
+
+#if BuildServersOnly && !XWinServer && !XnestServer && !BuildGLXLibrary && !BuildClients && !XdmxServer
+all::
+
+BuildIncludes($(HEADERS),IncSubdir,..)
+
+#else
+
+#if BuildLoadableXlibI18n
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+#define NoLibSubdirs
+#endif
+
+#define DoNormalLib NormalLibX11
+#define DoSharedLib SharedLibX11
+#define DoExtraLib SharedLibX11
+#define DoDebugLib DebugLibX11
+#define DoProfileLib ProfileLibX11
+#define LibName X11
+#define SoRev SOXLIBREV
+#define HugeLibrary YES
+#define IncSubdir X11
+
+#if BuildLoadableXlibI18n
+SUBDIRS = xlibi18n
+#endif
+
+#include <Threads.tmpl>
+
+#ifndef MotifBC
+#define MotifBC NO
+#endif
+
+#ifdef SharedX11Reqs
+REQUIREDX11LIBS = SharedX11Reqs
+#endif
+#if BuildLoadableXlibI18n
+REQUIREDI18NLIBS = DlLibrary
+#endif
+#ifdef cygwinArchitecture
+EXCLUDE_SYMBOL = -Wl,--exclude-symbol,XdmcpWrap:_XdmcpWrapperToOddParity
+#endif
+
+REQUIREDLIBS=$(REQUIREDX11LIBS) $(REQUIREDI18NLIBS) $(EXCLUDE_SYMBOL)
+
+#if defined(MacIIArchitecture) || defined(SequentArchitecture) || defined(i386ScoArchitecture)
+XBSDLIB = /**/
+#endif
+#if defined(LunaArchitecture) && defined(Mc88000Architecture)
+EXTRA_LIBRARIES = /**/
+#endif
+#if Malloc0ReturnsNull
+ MALLOC_DEFINES = XMalloc0ReturnsNullDefines
+#endif
+#if HasXdmAuth
+ XDMAUTHDEFS = -DHASXDMAUTH
+ XDMAUTHOBJS = Wrap.o Wraphelp.o
+ XDMAUTHSRCS = Wrap.c Wraphelp.c
+#endif
+#if BuildXKBlib
+ XKB_DEFINES = -DXKB
+ XKBSRCS = XKB.c XKBBind.c XKBCompat.c XKBCtrls.c XKBCvt.c XKBGetMap.c \
+ XKBGetByName.c XKBNames.c XKBRdBuf.c XKBSetMap.c XKBUse.c \
+ XKBleds.c XKBBell.c XKBGeom.c XKBSetGeom.c XKBExtDev.c \
+ XKBList.c XKBMisc.c \
+ XKBMAlloc.c XKBGAlloc.c XKBAlloc.c
+ XKBOBJS = XKB.o XKBBind.o XKBCompat.o XKBCtrls.o XKBCvt.o XKBGetMap.o \
+ XKBGetByName.o XKBNames.o XKBRdBuf.o XKBSetMap.o XKBUse.o \
+ XKBleds.o XKBBell.o XKBGeom.o XKBSetGeom.o XKBExtDev.o \
+ XKBList.o XKBMisc.o \
+ XKBMAlloc.o XKBGAlloc.o XKBAlloc.o
+#endif
+#if HasSecureRPC
+ RPCDEFS = -DSECURE_RPC
+#endif
+#if HasPoll
+ POLL_DEFINES = -DUSE_POLL
+#endif
+ CONN_DEFINES = $(CONNECTION_FLAGS)
+ XTRANS_X_DEFINES = -DX11_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES)
+ XTRANS_XIM_DEFINES = -DXIM_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES)
+#if HasBSD44Sockets
+ SOCK_DEFINES = -DBSD44SOCKETS
+#endif
+#if HasShm
+ SHM_DEFINES = -DHAS_SHM
+#endif
+
+ XF86BIGFONT_DEFINES = XF86BigfontExtensionDefines
+
+ EDB_DEFINES = -DERRORDB=\"$(LIBDIR)/XErrorDB\"
+ KDB_DEFINES = -DKEYSYMDB=\"$(LIBDIR)/XKeysymDB\"
+ CMS_DEFINES = -DXCMSDB=\"$(LIBDIR)/Xcms.txt\"
+#if HasSnprintf
+ MISC_DEFINES = -DHAS_SNPRINTF -DLIBX11
+#endif
+#if MotifBC
+ BC_DEFINES = -DMOTIFBC
+#endif
+#if NoRConst
+ RCONST_DEFINES = -DNORCONST
+#endif
+#if DisableXLocaleDirEnv
+ SETID_DEFINES = -DNO_XLOCALEDIR
+#elif HasIssetugid
+ SETID_DEFINES = -DHASSETUGID
+#elif HasGetresuid
+ SETID_DEFINES = -DHASGETRESUID
+#endif
+ XLC_DEFINES = -DXLOCALEDIR=\"$(XLOCALEDIR)\"
+#if HasKrb5
+ K5OBJS = k5encode.o
+ K5SRCS = k5encode.c
+ K5INCL = Krb5Includes
+ K5DEFS = Krb5Defines
+#endif
+#if (defined(FreeBSDArchitecture) && OSRelVersion < 500016) || \
+ defined(OpenBSDArchitecture)
+THRSTUBSRCS = UIThrStubs.c
+THRSTUBOBJS = UIThrStubs.o
+#endif
+#if BuildLoadableXlibXcursor
+XCURSOR_DEFINES = -DUSE_DYNAMIC_XCURSOR -DLIBXCURSOR=\"libXcursor.so.$(SOXCURSORREV)\"
+#endif
+#if NeedLibInsideFlag
+ LIB_DEFINES = -D_XLIBINT_
+#endif
+#if defined(LibDirName)
+ POSTLOCALELIBDIR = LibDirName
+ POSTLOCALELIBDEFINES = -DPOSTLOCALELIBDIR=\"$(POSTLOCALELIBDIR)\"
+#endif
+ DEFINES = $(MALLOC_DEFINES) $(LIB_DEFINES) $(MISC_DEFINES)\
+ $(POSTLOCALELIBDEFINES)
+ OPEN_DEFINES = -I$(EXTINCSRC) $(K5INCL) $(K5DEFS)
+ DEPEND_DEFINES = $(OPEN_DEFINES) $(TRANS_INCLUDES) $(CONN_DEFINES) $(THREADS_DEFINES) DependDefines
+ AUTHOBJS = AuDispose.o AuGetBest.o AuFileName.o AuRead.o
+ AUTHSRCS = AuDispose.c AuGetBest.c AuFileName.c AuRead.c
+ SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(EXTRASRCS) /* try *.c if you have trouble */
+ LINTLIBS =
+
+#if BuildLoadableXlibI18n && DoSharedLib
+EXTRASHAREDSRC = $(SHAREDLCSRCS)
+#endif
+#if !BuildLoadableXlibI18n || DoNormalLib
+EXTRASTATICSRC = $(STATICLCSRCS)
+#endif
+
+EXTRASRCS = $(EXTRASHAREDSRC) $(EXTRASTATICSRC)
+
+SRCS1 = \
+ Context.c \
+ Depths.c \
+ ParseCmd.c \
+ Quarks.c \
+ AllCells.c \
+ AllPlanes.c \
+ AllowEv.c \
+ AutoRep.c \
+ Backgnd.c \
+ BdrWidth.c \
+ Bell.c \
+ Border.c \
+ ChAccCon.c \
+ ChClMode.c \
+ ChActPGb.c \
+ ChCmap.c \
+ ChGC.c \
+ ChKeyCon.c \
+ ChPntCon.c \
+ ChProp.c \
+ ChSaveSet.c \
+ ChWAttrs.c \
+ ChWindow.c \
+ ChkIfEv.c \
+ ChkMaskEv.c \
+ ChkWinEv.c \
+ ChkTypEv.c \
+ ChkTypWEv.c \
+ CirWin.c \
+ CirWinDn.c \
+ CirWinUp.c \
+ ClDisplay.c \
+ Clear.c \
+ ClearArea.c \
+ ConfWind.c \
+ ConnDis.c \
+ ConvSel.c \
+ CopyArea.c \
+ CopyCmap.c \
+ CopyGC.c \
+ CopyPlane.c \
+ CrBFData.c \
+ CrCmap.c \
+ CrCursor.c \
+ CrGC.c \
+ CrGlCur.c \
+ CrPFBData.c \
+ CrPixmap.c \
+ CrWindow.c \
+ Cursor.c \
+ DefCursor.c \
+ DelProp.c \
+ DestSubs.c \
+ DestWind.c \
+ DisName.c \
+ DrArc.c \
+ DrArcs.c \
+ DrLine.c \
+ DrLines.c \
+ DrPoint.c \
+ DrPoints.c \
+ DrRect.c \
+ DrRects.c \
+ DrSegs.c \
+ ErrDes.c \
+ ErrHndlr.c \
+ EvToWire.c \
+ FetchName.c \
+ FillArc.c \
+ FillArcs.c \
+ FillPoly.c \
+ FillRct.c \
+ FillRcts.c \
+ Flush.c \
+ Font.c \
+ FontNames.c \
+ FontInfo.c \
+ FreeCmap.c \
+ FreeCols.c \
+ FreeCurs.c \
+ FreeEData.c \
+ FreeGC.c \
+ FreePix.c \
+ FSSaver.c \
+ GCMisc.c \
+ Geom.c \
+ GetAtomNm.c \
+ GetColor.c \
+ GetDflt.c \
+ GetFPath.c \
+ GetFProp.c \
+ GetGeom.c \
+ GetHColor.c \
+ GetHints.c \
+ GetIFocus.c \
+ GetImage.c \
+ GetKCnt.c \
+ GetMoEv.c \
+ GetPCnt.c \
+ GetPntMap.c \
+ GetProp.c \
+ GetSOwner.c \
+ GetSSaver.c \
+ GetStCmap.c \
+ GetWAttrs.c \
+ GrButton.c \
+ GrKey.c \
+ GrKeybd.c \
+ GrPointer.c \
+ GrServer.c \
+ Host.c \
+ IfEvent.c \
+ ImUtil.c \
+ ImText.c \
+ ImText16.c \
+ InitExt.c \
+ InsCmap.c \
+ IntAtom.c \
+ KeyBind.c \
+ KeysymStr.c \
+ KillCl.c \
+ LiHosts.c \
+ LiICmaps.c \
+ LiProps.c \
+ ListExt.c \
+ LoadFont.c \
+ LookupCol.c \
+ LowerWin.c
+
+OBJS1 = \
+ Context.o \
+ Depths.o \
+ ParseCmd.o \
+ Quarks.o \
+ AllCells.o \
+ AllPlanes.o \
+ AllowEv.o \
+ AutoRep.o \
+ Backgnd.o \
+ BdrWidth.o \
+ Bell.o \
+ Border.o \
+ ChAccCon.o \
+ ChClMode.o \
+ ChActPGb.o \
+ ChCmap.o \
+ ChGC.o \
+ ChKeyCon.o \
+ ChPntCon.o \
+ ChProp.o \
+ ChSaveSet.o \
+ ChWAttrs.o \
+ ChWindow.o \
+ ChkIfEv.o \
+ ChkMaskEv.o \
+ ChkWinEv.o \
+ ChkTypEv.o \
+ ChkTypWEv.o \
+ CirWin.o \
+ CirWinDn.o \
+ CirWinUp.o \
+ ClDisplay.o \
+ Clear.o \
+ ClearArea.o \
+ ConfWind.o \
+ ConnDis.o \
+ ConvSel.o \
+ CopyArea.o \
+ CopyCmap.o \
+ CopyGC.o \
+ CopyPlane.o \
+ CrBFData.o \
+ CrCmap.o \
+ CrCursor.o \
+ CrGC.o \
+ CrGlCur.o \
+ CrPFBData.o \
+ CrPixmap.o \
+ CrWindow.o \
+ Cursor.o \
+ DefCursor.o \
+ DelProp.o \
+ DestSubs.o \
+ DestWind.o \
+ DisName.o \
+ DrArc.o \
+ DrArcs.o \
+ DrLine.o \
+ DrLines.o \
+ DrPoint.o \
+ DrPoints.o \
+ DrRect.o \
+ DrRects.o \
+ DrSegs.o \
+ ErrDes.o \
+ ErrHndlr.o \
+ EvToWire.o \
+ FetchName.o \
+ FillArc.o \
+ FillArcs.o \
+ FillPoly.o \
+ FillRct.o \
+ FillRcts.o \
+ Flush.o \
+ Font.o \
+ FontNames.o \
+ FontInfo.o \
+ FreeCmap.o \
+ FreeCols.o \
+ FreeCurs.o \
+ FreeEData.o \
+ FreeGC.o \
+ FreePix.o \
+ FSSaver.o \
+ GCMisc.o \
+ Geom.o \
+ GetAtomNm.o \
+ GetColor.o \
+ GetDflt.o \
+ GetFPath.o \
+ GetFProp.o \
+ GetGeom.o \
+ GetHColor.o \
+ GetHints.o \
+ GetIFocus.o \
+ GetImage.o \
+ GetKCnt.o \
+ GetMoEv.o \
+ GetPCnt.o \
+ GetPntMap.o \
+ GetProp.o \
+ GetSOwner.o \
+ GetSSaver.o \
+ GetStCmap.o \
+ GetWAttrs.o \
+ GrButton.o \
+ GrKey.o \
+ GrKeybd.o \
+ GrPointer.o \
+ GrServer.o \
+ Host.o \
+ IfEvent.o \
+ ImUtil.o \
+ ImText.o \
+ ImText16.o \
+ InitExt.o \
+ InsCmap.o \
+ IntAtom.o \
+ KeyBind.o \
+ KeysymStr.o \
+ KillCl.o \
+ LiHosts.o \
+ LiICmaps.o \
+ LiProps.o \
+ ListExt.o \
+ LoadFont.o \
+ LookupCol.o \
+ LowerWin.o
+
+SRCS2 = \
+ Macros.c \
+ MapRaised.c \
+ MapSubs.c \
+ MapWindow.c \
+ MaskEvent.c \
+ Misc.c \
+ ModMap.c \
+ MoveWin.c \
+ NextEvent.c \
+ OpenDis.c \
+ ParseCol.c \
+ ParseGeom.c \
+ PeekEvent.c \
+ PeekIfEv.c \
+ Pending.c \
+ PmapBgnd.c \
+ PmapBord.c \
+ PolyReg.c \
+ PolyTxt.c \
+ PolyTxt16.c \
+ PutBEvent.c \
+ PutImage.c \
+ QuBest.c \
+ QuColor.c \
+ QuColors.c \
+ QuCurShp.c \
+ QuExt.c \
+ QuKeybd.c \
+ QuPntr.c \
+ QuStipShp.c \
+ QuTextE16.c \
+ QuTextExt.c \
+ QuTileShp.c \
+ QuTree.c \
+ RaiseWin.c \
+ RdBitF.c \
+ RecolorC.c \
+ ReconfWin.c \
+ Region.c \
+ RepWindow.c \
+ RestackWs.c \
+ RotProp.c \
+ ScrResStr.c \
+ SelInput.c \
+ SendEvent.c \
+ SetBack.c \
+ SetCRects.c \
+ SetClMask.c \
+ SetClOrig.c \
+ SetDashes.c \
+ SetFPath.c \
+ SetFont.c \
+ SetFore.c \
+ SetFunc.c \
+ SetHints.c \
+ SetIFocus.c \
+ SetLStyle.c \
+ SetPMask.c \
+ SetPntMap.c \
+ SetSOwner.c \
+ SetSSaver.c \
+ SetState.c \
+ SetStip.c \
+ SetStCmap.c \
+ SetTile.c \
+ SetTSOrig.c \
+ StBytes.c \
+ StColor.c \
+ StColors.c \
+ StNColor.c \
+ StName.c \
+ StrKeysym.c \
+ Sync.c \
+ Synchro.c \
+ Text.c \
+ Text16.c \
+ TextExt.c \
+ TextExt16.c \
+ TrCoords.c \
+ UndefCurs.c \
+ UngrabBut.c \
+ UngrabKbd.c \
+ UngrabKey.c \
+ UngrabPtr.c \
+ UngrabSvr.c \
+ UninsCmap.c \
+ UnldFont.c \
+ UnmapSubs.c \
+ UnmapWin.c \
+ VisUtil.c \
+ WarpPtr.c \
+ WinEvent.c \
+ Window.c \
+ WrBitF.c \
+ XlibAsync.c \
+ XlibInt.c \
+ Xrm.c \
+ evtomask.c \
+ globals.c \
+ GetGCVals.c \
+ GetNrmHint.c \
+ GetRGBCMap.c \
+ GetTxtProp.c \
+ GetWMCMapW.c \
+ GetWMProto.c \
+ Iconify.c \
+ PixFormats.c \
+ PropAlloc.c \
+ ReconfWM.c \
+ SetNrmHint.c \
+ SetRGBCMap.c \
+ SetTxtProp.c \
+ SetWMCMapW.c \
+ SetWMProto.c \
+ StrToText.c \
+ TextToStr.c \
+ Withdraw.c \
+ WMGeom.c \
+ WMProps.c \
+ $(AUTHSRCS) $(XDMAUTHSRCS) $(K5SRCS) $(THRSTUBSRCS)
+
+OBJS2 = \
+ Macros.o \
+ MapRaised.o \
+ MapSubs.o \
+ MapWindow.o \
+ MaskEvent.o \
+ Misc.o \
+ ModMap.o \
+ MoveWin.o \
+ NextEvent.o \
+ OpenDis.o \
+ ParseCol.o \
+ ParseGeom.o \
+ PeekEvent.o \
+ PeekIfEv.o \
+ Pending.o \
+ PmapBgnd.o \
+ PmapBord.o \
+ PolyReg.o \
+ PolyTxt.o \
+ PolyTxt16.o \
+ PutBEvent.o \
+ PutImage.o \
+ QuBest.o \
+ QuColor.o \
+ QuColors.o \
+ QuCurShp.o \
+ QuExt.o \
+ QuKeybd.o \
+ QuPntr.o \
+ QuStipShp.o \
+ QuTextE16.o \
+ QuTextExt.o \
+ QuTileShp.o \
+ QuTree.o \
+ RaiseWin.o \
+ RdBitF.o \
+ RecolorC.o \
+ ReconfWin.o \
+ Region.o \
+ RepWindow.o \
+ RestackWs.o \
+ RotProp.o \
+ ScrResStr.o \
+ SelInput.o \
+ SendEvent.o \
+ SetBack.o \
+ SetCRects.o \
+ SetClMask.o \
+ SetClOrig.o \
+ SetDashes.o \
+ SetFPath.o \
+ SetFont.o \
+ SetFore.o \
+ SetFunc.o \
+ SetHints.o \
+ SetIFocus.o \
+ SetLStyle.o \
+ SetPMask.o \
+ SetPntMap.o \
+ SetSOwner.o \
+ SetSSaver.o \
+ SetState.o \
+ SetStip.o \
+ SetStCmap.o \
+ SetTile.o \
+ SetTSOrig.o \
+ StBytes.o \
+ StColor.o \
+ StColors.o \
+ StNColor.o \
+ StName.o \
+ StrKeysym.o \
+ Sync.o \
+ Synchro.o \
+ Text.o \
+ Text16.o \
+ TextExt.o \
+ TextExt16.o \
+ TrCoords.o \
+ UndefCurs.o \
+ UngrabBut.o \
+ UngrabKbd.o \
+ UngrabKey.o \
+ UngrabPtr.o \
+ UngrabSvr.o \
+ UninsCmap.o \
+ UnldFont.o \
+ UnmapSubs.o \
+ UnmapWin.o \
+ VisUtil.o \
+ WarpPtr.o \
+ WinEvent.o \
+ Window.o \
+ WrBitF.o \
+ XlibAsync.o \
+ XlibInt.o \
+ Xrm.o \
+ evtomask.o \
+ globals.o \
+ GetGCVals.o \
+ GetNrmHint.o \
+ GetRGBCMap.o \
+ GetTxtProp.o \
+ GetWMCMapW.o \
+ GetWMProto.o \
+ Iconify.o \
+ PixFormats.o \
+ PropAlloc.o \
+ ReconfWM.o \
+ SetNrmHint.o \
+ SetRGBCMap.o \
+ SetTxtProp.o \
+ SetWMCMapW.o \
+ SetWMProto.o \
+ StrToText.o \
+ TextToStr.o \
+ Withdraw.o \
+ WMGeom.o \
+ WMProps.o \
+ $(AUTHOBJS) \
+ $(XDMAUTHOBJS) \
+ $(K5OBJS) \
+ $(THRSTUBOBJS)
+
+SRCS3 = \
+ Lab.c \
+ LabGcC.c \
+ LabGcL.c \
+ LabGcLC.c \
+ LabMnL.c \
+ LabMxC.c \
+ LabMxL.c \
+ LabMxLC.c \
+ LabWpAj.c \
+ Luv.c \
+ LuvGcC.c \
+ LuvGcL.c \
+ LuvGcLC.c \
+ LuvMnL.c \
+ LuvMxC.c \
+ LuvMxL.c \
+ LuvMxLC.c \
+ LuvWpAj.c \
+ XYZ.c \
+ uvY.c \
+ xyY.c \
+ HVC.c \
+ HVCGcC.c \
+ HVCGcV.c \
+ HVCGcVC.c \
+ HVCMnV.c \
+ HVCMxC.c \
+ HVCMxV.c \
+ HVCMxVC.c \
+ HVCMxVs.c \
+ HVCWpAj.c \
+ UNDEFINED.c \
+ AddDIC.c \
+ AddSF.c \
+ cmsAllNCol.c \
+ cmsAllCol.c \
+ CCC.c \
+ cmsCmap.c \
+ cmsColNm.c \
+ CvColW.c \
+ CvCols.c \
+ cmsGlobls.c \
+ IdOfPr.c \
+ cmsInt.c \
+ LRGB.c \
+ cmsLkCol.c \
+ cmsMath.c \
+ OfCCC.c \
+ PrOfId.c \
+ cmsProp.c \
+ QBlack.c \
+ QBlue.c \
+ QGreen.c \
+ QRed.c \
+ QWhite.c \
+ QuCol.c \
+ QuCols.c \
+ SetCCC.c \
+ SetGetCols.c \
+ StCol.c \
+ StCols.c \
+ cmsTrig.c \
+ XRGB.c \
+ FSWrap.c \
+ ICWrap.c \
+ IMWrap.c \
+ OCWrap.c \
+ OMWrap.c \
+ lcWrap.c \
+ mbWMProps.c \
+ utf8WMProps.c \
+ mbWrap.c \
+ wcWrap.c \
+ utf8Wrap.c \
+ FilterEv.c \
+ RegstFlt.c \
+ locking.c \
+ LockDis.c \
+ x11trans.c \
+ ximtrans.c \
+ $(XKBSRCS) $(LCSRCS) $(MISCSRCS)
+
+OBJS3 = \
+ Lab.o \
+ LabGcC.o \
+ LabGcL.o \
+ LabGcLC.o \
+ LabMnL.o \
+ LabMxC.o \
+ LabMxL.o \
+ LabMxLC.o \
+ LabWpAj.o \
+ Luv.o \
+ LuvGcC.o \
+ LuvGcL.o \
+ LuvGcLC.o \
+ LuvMnL.o \
+ LuvMxC.o \
+ LuvMxL.o \
+ LuvMxLC.o \
+ LuvWpAj.o \
+ XYZ.o \
+ uvY.o \
+ xyY.o \
+ HVC.o \
+ HVCGcC.o \
+ HVCGcV.o \
+ HVCGcVC.o \
+ HVCMnV.o \
+ HVCMxC.o \
+ HVCMxV.o \
+ HVCMxVC.o \
+ HVCMxVs.o \
+ HVCWpAj.o \
+ UNDEFINED.o \
+ AddDIC.o \
+ AddSF.o \
+ cmsAllNCol.o \
+ cmsAllCol.o \
+ CCC.o \
+ cmsCmap.o \
+ cmsColNm.o \
+ CvColW.o \
+ CvCols.o \
+ cmsGlobls.o \
+ IdOfPr.o \
+ cmsInt.o \
+ LRGB.o \
+ cmsLkCol.o \
+ cmsMath.o \
+ OfCCC.o \
+ PrOfId.o \
+ cmsProp.o \
+ QBlack.o \
+ QBlue.o \
+ QGreen.o \
+ QRed.o \
+ QWhite.o \
+ QuCol.o \
+ QuCols.o \
+ SetCCC.o \
+ SetGetCols.o \
+ StCol.o \
+ StCols.o \
+ cmsTrig.o \
+ XRGB.o \
+ FSWrap.o \
+ ICWrap.o \
+ IMWrap.o \
+ OCWrap.o \
+ OMWrap.o \
+ lcWrap.o \
+ mbWMProps.o \
+ utf8WMProps.o \
+ mbWrap.o \
+ wcWrap.o \
+ utf8Wrap.o \
+ FilterEv.o \
+ RegstFlt.o \
+ locking.o \
+ LockDis.o \
+ x11trans.o \
+ ximtrans.o \
+ $(XKBOBJS) $(LCOBJS) $(MISCOBJS)
+
+#if BuildLoadableXlibI18n
+LC_DYNDEFINES = -DUSE_DYNAMIC_LC
+#endif
+
+SHAREDLCDEPSYMSRCS = XlcDL.c XlcSL.c
+
+SHAREDI18NSTATICSRCS = \
+ XDefaultIMIF.c XDefaultOMIF.c
+
+STATICLCDEPSYMSRCS =
+
+STATICI18NSTATICSRCS = \
+ imCallbk.c \
+ imDefFlt.c \
+ imDefIc.c \
+ imDefIm.c \
+ imDefLkup.c \
+ imDispch.c \
+ imEvToWire.c \
+ imExten.c \
+ imImSw.c \
+ imInsClbk.c \
+ imInt.c \
+ imLcFlt.c \
+ imLcGIc.c \
+ imLcIc.c \
+ imLcIm.c \
+ imLcLkup.c \
+ imLcPrs.c \
+ imLcSIc.c \
+ imRm.c \
+ imRmAttr.c \
+ imThaiFlt.c \
+ imThaiIc.c \
+ imThaiIm.c \
+ imTrX.c \
+ imTransR.c \
+ imTrans.c \
+ lcEuc.c \
+ lcGenConv.c \
+ lcJis.c \
+ lcSjis.c \
+ lcUTF8Load.c \
+ omDefault.c \
+ omGeneric.c \
+ omImText.c \
+ omText.c \
+ omTextEsc.c \
+ omTextExt.c \
+ omTextPer.c \
+ omXChar.c
+
+LCSRCS = \
+ SetLocale.c \
+ imConv.c \
+ imKStoUCS.c \
+ lcCT.c \
+ lcCharSet.c \
+ lcConv.c \
+ lcDB.c \
+ lcDefConv.c \
+ lcFile.c \
+ lcGeneric.c \
+ lcInit.c \
+ lcPrTxt.c \
+ lcPubWrap.c \
+ lcPublic.c \
+ lcRM.c \
+ lcStd.c \
+ lcTxtPr.c \
+ lcUtil.c \
+ lcUTF8.c
+
+STATICLCSRCS = \
+ $(STATICLCDEPSYMSRCS) \
+ $(STATICI18NSTATICSRCS)
+
+SHAREDLCSRCS = \
+ $(SHAREDLCDEPSYMSRCS) \
+ $(SHAREDI18NSTATICSRCS)
+
+SHAREDLCDEPOBJS = XlcDL.o XlcSL.o
+SHAREDI18NSTATICOBJS = \
+ XDefaultIMIF.o XDefaultOMIF.o
+STATICLCDEPOBJS =
+STATICI18NSTATICOBJS = \
+ imCallbk.o \
+ imDefFlt.o \
+ imDefIc.o \
+ imDefIm.o \
+ imDefLkup.o \
+ imDispch.o \
+ imEvToWire.o \
+ imExten.o \
+ imImSw.o \
+ imInsClbk.o \
+ imInt.o \
+ imLcFlt.o \
+ imLcGIc.o \
+ imLcIc.o \
+ imLcIm.o \
+ imLcLkup.o \
+ imLcPrs.o \
+ imLcSIc.o \
+ imRm.o \
+ imRmAttr.o \
+ imThaiFlt.o \
+ imThaiIc.o \
+ imThaiIm.o \
+ imTrX.o \
+ imTransR.o \
+ imTrans.o \
+ lcEuc.o \
+ lcGenConv.o \
+ lcJis.o \
+ lcSjis.o \
+ lcUTF8Load.o \
+ omDefault.o \
+ omGeneric.o \
+ omImText.o \
+ omText.o \
+ omTextEsc.o \
+ omTextExt.o \
+ omTextPer.o \
+ omXChar.o
+
+LCOBJS = \
+ SetLocale.o \
+ imConv.o \
+ imKStoUCS.o \
+ lcCT.o \
+ lcCharSet.o \
+ lcConv.o \
+ lcDB.o \
+ lcDefConv.o \
+ lcFile.o \
+ lcGeneric.o \
+ lcInit.o \
+ lcPrTxt.o \
+ lcPubWrap.o \
+ lcPublic.o \
+ lcRM.o \
+ lcStd.o \
+ lcTxtPr.o \
+ lcUtil.o \
+ lcUTF8.o
+
+STATICLCOBJS = \
+ $(STATICLCDEPOBJS) \
+ $(STATICI18NSTATICOBJS)
+
+SHAREDLCOBJS = \
+ $(SHAREDLCDEPOBJS) \
+ $(SHAREDI18NSTATICOBJS)
+
+#ifdef OS2Architecture
+MISCSRCS = os2Stubs.c
+#endif
+
+#ifdef OS2Architecture
+MISCOBJS = os2Stubs.o
+#endif
+
+OBJS = $(OBJS1) $(OBJS2) $(OBJS3)
+
+EXTRAUNSHAREDOBJS = $(STATICLCOBJS)
+
+#if BuildLoadableXlibI18n
+EXTRASHAREDOBJS = $(SHAREDLCOBJS)
+# else
+EXTRASHAREDOBJS = $(STATICLCOBJS)
+#endif
+
+#include <Library.tmpl>
+
+SpecialCLibObjectRule(ErrDes,$(ICONFIGFILES),$(EDB_DEFINES))
+SpecialCLibObjectRule(StrKeysym,$(ICONFIGFILES),$(KDB_DEFINES))
+SpecialCLibObjectRule(ConnDis,$(ICONFIGFILES),$(XDMAUTHDEFS) $(RPCDEFS) $(CONN_DEFINES) $(SOCK_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES) $(K5INCL) $(K5DEFS))
+SpecialCLibObjectRule(x11trans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_X_DEFINES) $(POLL_DEFINES))
+LinkFile(x11trans.c,$(TRANSCOMMSRC)/transport.c)
+SpecialCLibObjectRule(ximtrans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_XIM_DEFINES) $(POLL_DEFINES))
+LinkFile(ximtrans.c,$(TRANSCOMMSRC)/transport.c)
+SpecialCLibObjectRule(OpenDis,$(ICONFIGFILES),$(BC_DEFINES) $(OPEN_DEFINES) $(XTRANS_X_DEFINES) $(XKB_DEFINES))
+SpecialCLibObjectRule(Wrap,$(ICONFIGFILES),$(XDMAUTHDEFS))
+SpecialCLibObjectRule(XlibInt,$(ICONFIGFILES),$(CONN_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES))
+SpecialCLibObjectRule(Font,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES))
+SpecialCLibObjectRule(FontInfo,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES))
+SpecialCLibObjectRule(cmsColNm,$(ICONFIGFILES),$(CMS_DEFINES))
+SpecialCLibObjectRule(globals,$(ICONFIGFILES),$(CONN_DEFINES))
+SpecialCLibObjectRule(Context,$(ICONFIGFILES),$(BC_DEFINES))
+SpecialCLibObjectRule(Xrm,$(_NOOP_),$(RCONST_DEFINES))
+SpecialCLibObjectRule(imTransR,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES))
+SpecialCLibObjectRule(imTrans,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES))
+SpecialCLibObjectRule(lcFile,$(ICONFIGFILES),$(XLC_DEFINES) $(SETID_DEFINES))
+#if BuildXKBlib
+SpecialCLibObjectRule(XKBCvt,$(_NOOP_),$(RCONST_DEFINES))
+SpecialCLibObjectRule(KeyBind,$(ICONFIGFILES),$(XKB_DEFINES))
+SpecialCLibObjectRule(XKBBind,$(ICONFIGFILES),$(XKB_DEFINES))
+SpecialCLibObjectRule(imConv,$(ICONFIGFILES),$(XKB_DEFINES))
+#endif
+#if HasKrb5
+SpecialCLibObjectRule(k5encode,$(_NOOP_),$(K5INCL))
+#endif
+#if BuildLoadableXlibI18n
+SpecialCLibObjectRuleSeparateOpts(lcInit,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES))
+SpecialCLibObjectRuleSeparateOpts(lcGeneric,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES))
+SpecialCLibObjectRuleSeparateOpts(lcPublic,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES))
+#endif
+#if BuildLoadableXlibXcursor
+SpecialCLibObjectRuleSeparateOpts(CrCursor,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES))
+SpecialCLibObjectRuleSeparateOpts(CrGlCur,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES))
+SpecialCLibObjectRuleSeparateOpts(CrPixmap,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES))
+SpecialCLibObjectRuleSeparateOpts(PutImage,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES))
+#endif
+
+#if InstallXcmsTxt
+InstallNonExecFile(Xcms.txt,$(LIBDIR))
+#endif
+InstallNonExecFile(XErrorDB,$(LIBDIR))
+InstallNonExecFile(XKeysymDB,$(LIBDIR))
+InstallLintLibrary(X11,$(LINTLIBDIR))
+
+
+LinkSourceFile(AuDispose.c,$(XAUTHSRC))
+LinkSourceFile(AuGetBest.c,$(XAUTHSRC))
+LinkSourceFile(AuFileName.c,$(XAUTHSRC))
+LinkSourceFile(AuRead.c,$(XAUTHSRC))
+#if HasKrb5
+LinkSourceFile(k5encode.c,$(XAUTHSRC))
+#endif
+#if HasXdmAuth
+LinkSourceFile(Wrap.h,$(XDMCPLIBSRC))
+LinkSourceFile(Wrap.c,$(XDMCPLIBSRC))
+LinkSourceFile(Wraphelp.c,$(XDMCPLIBSRC))
+#endif
+
+#ifdef QNX4Architecture
+LOCAL_LDFLAGS=-F
+#endif
+
+MAKEKEYS = ./makekeys
+
+#if CrossCompiling
+HOST_LDLIBS=
+HOST_CFLAGS=$(TOP_INCLUDES) $(INCLUDES) $(BOOTSTRAPCFLAGS) \
+ $(CROSSCOMPILEDEFINES) $(CROSSCOMPILEBOOTSTRAPDEFINES)
+#else
+HOST_LDLIBS=$(LDLIBS)
+HOST_CFLAGS=$(CFLAGS)
+#endif
+
+ks_tables.h: $(XINCLUDESRC)/keysymdef.h util/makekeys.c
+ RemoveFiles($@ HostProgramTargetName(makekeys) makekeys.Osuf)
+ -HostLinkRule(HostProgramTargetName(makekeys),$(HOST_CFLAGS) $(LOCAL_LDFLAGS),util/makekeys.c,$(HOST_LDLIBS))
+ RunProgram(MAKEKEYS,< $(XINCLUDESRC)/keysymdef.h > ks_tables_h)
+ $(MV) ks_tables_h $@
+ RemoveFiles(HostProgramTargetName(makekeys) makekeys.Osuf ks_tables_h)
+
+includes:: ks_tables.h
+
+depend:: ks_tables.h
+
+clean::
+ RemoveFiles(ks_tables_h ks_tables.h HostProgramTargetName(makekeys))
+
+
+DependTarget3($(SRCS1),$(SRCS2),$(SRCS3) $(EXTRASRCS))
+
+#if BuildLoadableXlibI18n
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(LINTSUBDIRS))
+MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln)
+#endif
+#endif
+
+includes:: XlibConf.h
+
+#include <Threads.tmpl>
+
+#if ThreadedProject
+#define XThreadsDefine echo '#ifndef XTHREADS' >> $@ @@\
+ echo '#define XTHREADS' >> $@ @@\
+ echo '#endif' >> $@
+#else
+#define XThreadsDefine echo '#undef XTHREADS' >> $@
+#endif
+
+#if HasThreadSafeAPI
+#define MTSafeAPIDefine echo '#ifndef XUSE_MTSAFE_API' >> $@ @@\
+ echo '#define XUSE_MTSAFE_API' >> $@ @@\
+ echo '#endif' >> $@
+#else
+#define MTSafeAPIDefine echo '#undef XUSE_MTSAFE_API' >> $@
+#endif
+
+XlibConf.h:
+ echo '/* Defines needed to use Xlib from non-imake projects */' > $@
+ XThreadsDefine
+ MTSafeAPIDefine
diff --git a/nx-X11/lib/X11/InitExt.c b/nx-X11/lib/X11/InitExt.c
new file mode 100644
index 000000000..67c865787
--- /dev/null
+++ b/nx-X11/lib/X11/InitExt.c
@@ -0,0 +1,371 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/InitExt.c,v 1.7 2001/12/14 19:54:02 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xos.h>
+#include <stdio.h>
+
+/*
+ * This routine is used to link a extension in so it will be called
+ * at appropriate times.
+ */
+
+XExtCodes *XInitExtension (
+ Display *dpy,
+ _Xconst char *name)
+{
+ 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 (
+ 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;
+}
+
+int
+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;
+}
+
+/*
+ * 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 CreateGCType oldproc;
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->create_GC;
+ e->create_GC = proc;
+ UnlockDisplay(dpy);
+ return (CreateGCType)oldproc;
+}
+
+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 CopyGCType oldproc;
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->copy_GC;
+ e->copy_GC = proc;
+ UnlockDisplay(dpy);
+ return (CopyGCType)oldproc;
+}
+
+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 FlushGCType oldproc;
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->flush_GC;
+ e->flush_GC = proc;
+ UnlockDisplay(dpy);
+ return (FlushGCType)oldproc;
+}
+
+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 FreeGCType oldproc;
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->free_GC;
+ e->free_GC = proc;
+ UnlockDisplay(dpy);
+ return (FreeGCType)oldproc;
+}
+
+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 CreateFontType oldproc;
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->create_Font;
+ e->create_Font = proc;
+ UnlockDisplay(dpy);
+ return (CreateFontType)oldproc;
+}
+
+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 FreeFontType oldproc;
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->free_Font;
+ e->free_Font = proc;
+ UnlockDisplay(dpy);
+ return (FreeFontType)oldproc;
+}
+
+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 CloseDisplayType 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) (
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+);
+
+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 WireToEventType 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) (
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+);
+
+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 EventToWireType 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) (
+ Display* /* display */,
+ XErrorEvent* /* he */,
+ xError* /* we */
+);
+
+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 WireToErrorType oldproc = NULL;
+ if (proc == NULL) proc = (WireToErrorType)_XDefaultWireError;
+ LockDisplay (dpy);
+ if (!dpy->error_vec) {
+ int i;
+ dpy->error_vec = 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;
+}
+
+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 ErrorType oldproc;
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->error;
+ e->error = proc;
+ UnlockDisplay(dpy);
+ return (ErrorType)oldproc;
+}
+
+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 ErrorStringType oldproc;
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->error_string;
+ e->error_string = proc;
+ UnlockDisplay(dpy);
+ return (ErrorStringType)oldproc;
+}
+
+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 PrintErrorType oldproc;
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->error_values;
+ e->error_values = proc;
+ UnlockDisplay(dpy);
+ return (PrintErrorType)oldproc;
+}
+
+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 BeforeFlushType 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/nx-X11/lib/X11/InsCmap.c b/nx-X11/lib/X11/InsCmap.c
new file mode 100644
index 000000000..26a86446f
--- /dev/null
+++ b/nx-X11/lib/X11/InsCmap.c
@@ -0,0 +1,46 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/InsCmap.c,v 1.3 2001/01/17 19:41:38 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/IntAtom.c b/nx-X11/lib/X11/IntAtom.c
new file mode 100644
index 000000000..8161c7f73
--- /dev/null
+++ b/nx-X11/lib/X11/IntAtom.c
@@ -0,0 +1,301 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/IntAtom.c,v 1.6 2001/12/14 19:54:02 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xintatom.h"
+
+#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(
+ Display *dpy,
+ _Xconst 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 = 0, i;
+ Entry e;
+ int n, firstidx, rehash = 0;
+ 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;
+ const 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;
+ }
+}
+
+Atom
+XInternAtom (
+ Display *dpy,
+ const char *name,
+ Bool onlyIfExists)
+{
+ 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(
+ register Display *dpy,
+ register xReply *rep,
+ char *buf,
+ int len,
+ XPointer data)
+{
+ register _XIntAtomState *state;
+ register int i, idx = 0;
+ 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/nx-X11/lib/X11/Key.h b/nx-X11/lib/X11/Key.h
new file mode 100644
index 000000000..a0ca795d9
--- /dev/null
+++ b/nx-X11/lib/X11/Key.h
@@ -0,0 +1,18 @@
+/* $XFree86$ */
+
+#ifndef _KEY_H_
+#define _KEY_H_
+
+#ifndef NEEDKTABLE
+extern const unsigned char _XkeyTable[];
+#endif
+
+extern int
+_XKeyInitialize(
+ Display *dpy);
+
+extern XrmDatabase
+_XInitKeysymDB(
+ void);
+
+#endif /* _KEY_H_ */
diff --git a/nx-X11/lib/X11/KeyBind.c b/nx-X11/lib/X11/KeyBind.c
new file mode 100644
index 000000000..fab9eeacd
--- /dev/null
+++ b/nx-X11/lib/X11/KeyBind.c
@@ -0,0 +1,1081 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/KeyBind.c,v 1.8 2003/05/27 22:26:25 tsi Exp $ */
+
+/* Beware, here be monsters (still under construction... - JG */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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_LATIN8
+#define XK_LATIN9
+#define XK_CYRILLIC
+#define XK_GREEK
+#define XK_ARMENIAN
+#define XK_CAUCASUS
+#define XK_VIETNAMESE
+#define XK_XKB_KEYS
+#include <X11/keysymdef.h>
+#include <stdio.h>
+
+#ifdef USE_OWN_COMPOSE
+#include "imComp.h"
+
+#endif
+
+#include "Xresource.h"
+#include "Key.h"
+
+#ifdef XKB
+#include "XKBlib.h"
+#include "XKBlibint.h"
+#define XKeycodeToKeysym _XKeycodeToKeysym
+#define XKeysymToKeycode _XKeysymToKeycode
+#define XLookupKeysym _XLookupKeysym
+#define XRefreshKeyboardMapping _XRefreshKeyboardMapping
+#define XLookupString _XLookupString
+/* XKBBind.c */
+#else
+#define XkbKeysymToModifiers _XKeysymToModifiers
+#endif
+
+#define AllMods (ShiftMask|LockMask|ControlMask| \
+ Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)
+
+static void
+ComputeMaskFromKeytrans(
+ Display *dpy,
+ register struct _XKeytrans *p);
+
+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
+KeyCodetoKeySym(register Display *dpy, KeyCode keycode, int col)
+{
+ 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];
+}
+
+KeySym
+XKeycodeToKeysym(Display *dpy,
+#if NeedWidePrototypes
+ unsigned int kc,
+#else
+ KeyCode kc,
+#endif
+ int col)
+{
+ 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(
+ 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(
+ 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;
+}
+
+int
+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(
+ 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;
+}
+
+static void
+UCSConvertCase( register unsigned code,
+ KeySym *lower,
+ KeySym *upper )
+{
+ /* Case conversion for UCS, as in Unicode Data version 4.0.0 */
+ /* NB: Only converts simple one-to-one mappings. */
+
+ /* Tables are used where they take less space than */
+ /* the code to work out the mappings. Zero values mean */
+ /* undefined code points. */
+
+ static unsigned short const IPAExt_upper_mapping[] = { /* part only */
+ 0x0181, 0x0186, 0x0255, 0x0189, 0x018A,
+ 0x0258, 0x018F, 0x025A, 0x0190, 0x025C, 0x025D, 0x025E, 0x025F,
+ 0x0193, 0x0261, 0x0262, 0x0194, 0x0264, 0x0265, 0x0266, 0x0267,
+ 0x0197, 0x0196, 0x026A, 0x026B, 0x026C, 0x026D, 0x026E, 0x019C,
+ 0x0270, 0x0271, 0x019D, 0x0273, 0x0274, 0x019F, 0x0276, 0x0277,
+ 0x0278, 0x0279, 0x027A, 0x027B, 0x027C, 0x027D, 0x027E, 0x027F,
+ 0x01A6, 0x0281, 0x0282, 0x01A9, 0x0284, 0x0285, 0x0286, 0x0287,
+ 0x01AE, 0x0289, 0x01B1, 0x01B2, 0x028C, 0x028D, 0x028E, 0x028F,
+ 0x0290, 0x0291, 0x01B7
+ };
+
+ static unsigned short const LatinExtB_upper_mapping[] = { /* first part only */
+ 0x0180, 0x0181, 0x0182, 0x0182, 0x0184, 0x0184, 0x0186, 0x0187,
+ 0x0187, 0x0189, 0x018A, 0x018B, 0x018B, 0x018D, 0x018E, 0x018F,
+ 0x0190, 0x0191, 0x0191, 0x0193, 0x0194, 0x01F6, 0x0196, 0x0197,
+ 0x0198, 0x0198, 0x019A, 0x019B, 0x019C, 0x019D, 0x0220, 0x019F,
+ 0x01A0, 0x01A0, 0x01A2, 0x01A2, 0x01A4, 0x01A4, 0x01A6, 0x01A7,
+ 0x01A7, 0x01A9, 0x01AA, 0x01AB, 0x01AC, 0x01AC, 0x01AE, 0x01AF,
+ 0x01AF, 0x01B1, 0x01B2, 0x01B3, 0x01B3, 0x01B5, 0x01B5, 0x01B7,
+ 0x01B8, 0x01B8, 0x01BA, 0x01BB, 0x01BC, 0x01BC, 0x01BE, 0x01F7,
+ 0x01C0, 0x01C1, 0x01C2, 0x01C3, 0x01C4, 0x01C4, 0x01C4, 0x01C7,
+ 0x01C7, 0x01C7, 0x01CA, 0x01CA, 0x01CA
+ };
+
+ static unsigned short const LatinExtB_lower_mapping[] = { /* first part only */
+ 0x0180, 0x0253, 0x0183, 0x0183, 0x0185, 0x0185, 0x0254, 0x0188,
+ 0x0188, 0x0256, 0x0257, 0x018C, 0x018C, 0x018D, 0x01DD, 0x0259,
+ 0x025B, 0x0192, 0x0192, 0x0260, 0x0263, 0x0195, 0x0269, 0x0268,
+ 0x0199, 0x0199, 0x019A, 0x019B, 0x026F, 0x0272, 0x019E, 0x0275,
+ 0x01A1, 0x01A1, 0x01A3, 0x01A3, 0x01A5, 0x01A5, 0x0280, 0x01A8,
+ 0x01A8, 0x0283, 0x01AA, 0x01AB, 0x01AD, 0x01AD, 0x0288, 0x01B0,
+ 0x01B0, 0x028A, 0x028B, 0x01B4, 0x01B4, 0x01B6, 0x01B6, 0x0292,
+ 0x01B9, 0x01B9, 0x01BA, 0x01BB, 0x01BD, 0x01BD, 0x01BE, 0x01BF,
+ 0x01C0, 0x01C1, 0x01C2, 0x01C3, 0x01C6, 0x01C6, 0x01C6, 0x01C9,
+ 0x01C9, 0x01C9, 0x01CC, 0x01CC, 0x01CC
+ };
+
+ static unsigned short const Greek_upper_mapping[] = {
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0374, 0x0375, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x037A, 0x0000, 0x0000, 0x0000, 0x037E, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0384, 0x0385, 0x0386, 0x0387,
+ 0x0388, 0x0389, 0x038A, 0x0000, 0x038C, 0x0000, 0x038E, 0x038F,
+ 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+ 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
+ 0x03A0, 0x03A1, 0x0000, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7,
+ 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x0386, 0x0388, 0x0389, 0x038A,
+ 0x03B0, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+ 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
+ 0x03A0, 0x03A1, 0x03A3, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7,
+ 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x038C, 0x038E, 0x038F, 0x0000,
+ 0x0392, 0x0398, 0x03D2, 0x03D3, 0x03D4, 0x03A6, 0x03A0, 0x03D7,
+ 0x03D8, 0x03D8, 0x03DA, 0x03DA, 0x03DC, 0x03DC, 0x03DE, 0x03DE,
+ 0x03E0, 0x03E0, 0x03E2, 0x03E2, 0x03E4, 0x03E4, 0x03E6, 0x03E6,
+ 0x03E8, 0x03E8, 0x03EA, 0x03EA, 0x03EC, 0x03EC, 0x03EE, 0x03EE,
+ 0x039A, 0x03A1, 0x03F9, 0x03F3, 0x03F4, 0x0395, 0x03F6, 0x03F7,
+ 0x03F7, 0x03F9, 0x03FA, 0x03FA, 0x0000, 0x0000, 0x0000, 0x0000
+ };
+
+ static unsigned short const Greek_lower_mapping[] = {
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0374, 0x0375, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x037A, 0x0000, 0x0000, 0x0000, 0x037E, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0384, 0x0385, 0x03AC, 0x0387,
+ 0x03AD, 0x03AE, 0x03AF, 0x0000, 0x03CC, 0x0000, 0x03CD, 0x03CE,
+ 0x0390, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
+ 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
+ 0x03C0, 0x03C1, 0x0000, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7,
+ 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03AC, 0x03AD, 0x03AE, 0x03AF,
+ 0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
+ 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
+ 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7,
+ 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0x0000,
+ 0x03D0, 0x03D1, 0x03D2, 0x03D3, 0x03D4, 0x03D5, 0x03D6, 0x03D7,
+ 0x03D9, 0x03D9, 0x03DB, 0x03DB, 0x03DD, 0x03DD, 0x03DF, 0x03DF,
+ 0x03E1, 0x03E1, 0x03E3, 0x03E3, 0x03E5, 0x03E5, 0x03E7, 0x03E7,
+ 0x03E9, 0x03E9, 0x03EB, 0x03EB, 0x03ED, 0x03ED, 0x03EF, 0x03EF,
+ 0x03F0, 0x03F1, 0x03F2, 0x03F3, 0x03B8, 0x03F5, 0x03F6, 0x03F8,
+ 0x03F8, 0x03F2, 0x03FB, 0x03FB, 0x0000, 0x0000, 0x0000, 0x0000
+ };
+
+ static unsigned short const GreekExt_lower_mapping[] = {
+ 0x1F00, 0x1F01, 0x1F02, 0x1F03, 0x1F04, 0x1F05, 0x1F06, 0x1F07,
+ 0x1F00, 0x1F01, 0x1F02, 0x1F03, 0x1F04, 0x1F05, 0x1F06, 0x1F07,
+ 0x1F10, 0x1F11, 0x1F12, 0x1F13, 0x1F14, 0x1F15, 0x0000, 0x0000,
+ 0x1F10, 0x1F11, 0x1F12, 0x1F13, 0x1F14, 0x1F15, 0x0000, 0x0000,
+ 0x1F20, 0x1F21, 0x1F22, 0x1F23, 0x1F24, 0x1F25, 0x1F26, 0x1F27,
+ 0x1F20, 0x1F21, 0x1F22, 0x1F23, 0x1F24, 0x1F25, 0x1F26, 0x1F27,
+ 0x1F30, 0x1F31, 0x1F32, 0x1F33, 0x1F34, 0x1F35, 0x1F36, 0x1F37,
+ 0x1F30, 0x1F31, 0x1F32, 0x1F33, 0x1F34, 0x1F35, 0x1F36, 0x1F37,
+ 0x1F40, 0x1F41, 0x1F42, 0x1F43, 0x1F44, 0x1F45, 0x0000, 0x0000,
+ 0x1F40, 0x1F41, 0x1F42, 0x1F43, 0x1F44, 0x1F45, 0x0000, 0x0000,
+ 0x1F50, 0x1F51, 0x1F52, 0x1F53, 0x1F54, 0x1F55, 0x1F56, 0x1F57,
+ 0x0000, 0x1F51, 0x0000, 0x1F53, 0x0000, 0x1F55, 0x0000, 0x1F57,
+ 0x1F60, 0x1F61, 0x1F62, 0x1F63, 0x1F64, 0x1F65, 0x1F66, 0x1F67,
+ 0x1F60, 0x1F61, 0x1F62, 0x1F63, 0x1F64, 0x1F65, 0x1F66, 0x1F67,
+ 0x1F70, 0x1F71, 0x1F72, 0x1F73, 0x1F74, 0x1F75, 0x1F76, 0x1F77,
+ 0x1F78, 0x1F79, 0x1F7A, 0x1F7B, 0x1F7C, 0x1F7D, 0x0000, 0x0000,
+ 0x1F80, 0x1F81, 0x1F82, 0x1F83, 0x1F84, 0x1F85, 0x1F86, 0x1F87,
+ 0x1F80, 0x1F81, 0x1F82, 0x1F83, 0x1F84, 0x1F85, 0x1F86, 0x1F87,
+ 0x1F90, 0x1F91, 0x1F92, 0x1F93, 0x1F94, 0x1F95, 0x1F96, 0x1F97,
+ 0x1F90, 0x1F91, 0x1F92, 0x1F93, 0x1F94, 0x1F95, 0x1F96, 0x1F97,
+ 0x1FA0, 0x1FA1, 0x1FA2, 0x1FA3, 0x1FA4, 0x1FA5, 0x1FA6, 0x1FA7,
+ 0x1FA0, 0x1FA1, 0x1FA2, 0x1FA3, 0x1FA4, 0x1FA5, 0x1FA6, 0x1FA7,
+ 0x1FB0, 0x1FB1, 0x1FB2, 0x1FB3, 0x1FB4, 0x0000, 0x1FB6, 0x1FB7,
+ 0x1FB0, 0x1FB1, 0x1F70, 0x1F71, 0x1FB3, 0x1FBD, 0x1FBE, 0x1FBF,
+ 0x1FC0, 0x1FC1, 0x1FC2, 0x1FC3, 0x1FC4, 0x0000, 0x1FC6, 0x1FC7,
+ 0x1F72, 0x1F73, 0x1F74, 0x1F75, 0x1FC3, 0x1FCD, 0x1FCE, 0x1FCF,
+ 0x1FD0, 0x1FD1, 0x1FD2, 0x1FD3, 0x0000, 0x0000, 0x1FD6, 0x1FD7,
+ 0x1FD0, 0x1FD1, 0x1F76, 0x1F77, 0x0000, 0x1FDD, 0x1FDE, 0x1FDF,
+ 0x1FE0, 0x1FE1, 0x1FE2, 0x1FE3, 0x1FE4, 0x1FE5, 0x1FE6, 0x1FE7,
+ 0x1FE0, 0x1FE1, 0x1F7A, 0x1F7B, 0x1FE5, 0x1FED, 0x1FEE, 0x1FEF,
+ 0x0000, 0x0000, 0x1FF2, 0x1FF3, 0x1FF4, 0x0000, 0x1FF6, 0x1FF7,
+ 0x1F78, 0x1F79, 0x1F7C, 0x1F7D, 0x1FF3, 0x1FFD, 0x1FFE, 0x0000
+ };
+
+ static unsigned short const GreekExt_upper_mapping[] = {
+ 0x1F08, 0x1F09, 0x1F0A, 0x1F0B, 0x1F0C, 0x1F0D, 0x1F0E, 0x1F0F,
+ 0x1F08, 0x1F09, 0x1F0A, 0x1F0B, 0x1F0C, 0x1F0D, 0x1F0E, 0x1F0F,
+ 0x1F18, 0x1F19, 0x1F1A, 0x1F1B, 0x1F1C, 0x1F1D, 0x0000, 0x0000,
+ 0x1F18, 0x1F19, 0x1F1A, 0x1F1B, 0x1F1C, 0x1F1D, 0x0000, 0x0000,
+ 0x1F28, 0x1F29, 0x1F2A, 0x1F2B, 0x1F2C, 0x1F2D, 0x1F2E, 0x1F2F,
+ 0x1F28, 0x1F29, 0x1F2A, 0x1F2B, 0x1F2C, 0x1F2D, 0x1F2E, 0x1F2F,
+ 0x1F38, 0x1F39, 0x1F3A, 0x1F3B, 0x1F3C, 0x1F3D, 0x1F3E, 0x1F3F,
+ 0x1F38, 0x1F39, 0x1F3A, 0x1F3B, 0x1F3C, 0x1F3D, 0x1F3E, 0x1F3F,
+ 0x1F48, 0x1F49, 0x1F4A, 0x1F4B, 0x1F4C, 0x1F4D, 0x0000, 0x0000,
+ 0x1F48, 0x1F49, 0x1F4A, 0x1F4B, 0x1F4C, 0x1F4D, 0x0000, 0x0000,
+ 0x1F50, 0x1F59, 0x1F52, 0x1F5B, 0x1F54, 0x1F5D, 0x1F56, 0x1F5F,
+ 0x0000, 0x1F59, 0x0000, 0x1F5B, 0x0000, 0x1F5D, 0x0000, 0x1F5F,
+ 0x1F68, 0x1F69, 0x1F6A, 0x1F6B, 0x1F6C, 0x1F6D, 0x1F6E, 0x1F6F,
+ 0x1F68, 0x1F69, 0x1F6A, 0x1F6B, 0x1F6C, 0x1F6D, 0x1F6E, 0x1F6F,
+ 0x1FBA, 0x1FBB, 0x1FC8, 0x1FC9, 0x1FCA, 0x1FCB, 0x1FDA, 0x1FDB,
+ 0x1FF8, 0x1FF9, 0x1FEA, 0x1FEB, 0x1FFA, 0x1FFB, 0x0000, 0x0000,
+ 0x1F88, 0x1F89, 0x1F8A, 0x1F8B, 0x1F8C, 0x1F8D, 0x1F8E, 0x1F8F,
+ 0x1F88, 0x1F89, 0x1F8A, 0x1F8B, 0x1F8C, 0x1F8D, 0x1F8E, 0x1F8F,
+ 0x1F98, 0x1F99, 0x1F9A, 0x1F9B, 0x1F9C, 0x1F9D, 0x1F9E, 0x1F9F,
+ 0x1F98, 0x1F99, 0x1F9A, 0x1F9B, 0x1F9C, 0x1F9D, 0x1F9E, 0x1F9F,
+ 0x1FA8, 0x1FA9, 0x1FAA, 0x1FAB, 0x1FAC, 0x1FAD, 0x1FAE, 0x1FAF,
+ 0x1FA8, 0x1FA9, 0x1FAA, 0x1FAB, 0x1FAC, 0x1FAD, 0x1FAE, 0x1FAF,
+ 0x1FB8, 0x1FB9, 0x1FB2, 0x1FBC, 0x1FB4, 0x0000, 0x1FB6, 0x1FB7,
+ 0x1FB8, 0x1FB9, 0x1FBA, 0x1FBB, 0x1FBC, 0x1FBD, 0x0399, 0x1FBF,
+ 0x1FC0, 0x1FC1, 0x1FC2, 0x1FCC, 0x1FC4, 0x0000, 0x1FC6, 0x1FC7,
+ 0x1FC8, 0x1FC9, 0x1FCA, 0x1FCB, 0x1FCC, 0x1FCD, 0x1FCE, 0x1FCF,
+ 0x1FD8, 0x1FD9, 0x1FD2, 0x1FD3, 0x0000, 0x0000, 0x1FD6, 0x1FD7,
+ 0x1FD8, 0x1FD9, 0x1FDA, 0x1FDB, 0x0000, 0x1FDD, 0x1FDE, 0x1FDF,
+ 0x1FE8, 0x1FE9, 0x1FE2, 0x1FE3, 0x1FE4, 0x1FEC, 0x1FE6, 0x1FE7,
+ 0x1FE8, 0x1FE9, 0x1FEA, 0x1FEB, 0x1FEC, 0x1FED, 0x1FEE, 0x1FEF,
+ 0x0000, 0x0000, 0x1FF2, 0x1FFC, 0x1FF4, 0x0000, 0x1FF6, 0x1FF7,
+ 0x1FF8, 0x1FF9, 0x1FFA, 0x1FFB, 0x1FFC, 0x1FFD, 0x1FFE, 0x0000
+ };
+
+ *lower = code;
+ *upper = code;
+
+ /* Basic Latin and Latin-1 Supplement, U+0000 to U+00FF */
+ if (code <= 0x00ff) {
+ if (code >= 0x0041 && code <= 0x005a) /* A-Z */
+ *lower += 0x20;
+ else if (code >= 0x0061 && code <= 0x007a) /* a-z */
+ *upper -= 0x20;
+ else if ( (code >= 0x00c0 && code <= 0x00d6) ||
+ (code >= 0x00d8 && code <= 0x00de) )
+ *lower += 0x20;
+ else if ( (code >= 0x00e0 && code <= 0x00f6) ||
+ (code >= 0x00f8 && code <= 0x00fe) )
+ *upper -= 0x20;
+ else if (code == 0x00ff) /* y with diaeresis */
+ *upper = 0x0178;
+ else if (code == 0x00b5) /* micro sign */
+ *upper = 0x039c;
+ return;
+ }
+
+ /* Latin Extended-A, U+0100 to U+017F */
+ if (code >= 0x0100 && code <= 0x017f) {
+ if ( (code >= 0x0100 && code <= 0x012f) ||
+ (code >= 0x0132 && code <= 0x0137) ||
+ (code >= 0x014a && code <= 0x0177) ) {
+ *upper = code & ~1;
+ *lower = code | 1;
+ }
+ else if ( (code >= 0x0139 && code <= 0x0148) ||
+ (code >= 0x0179 && code <= 0x017e) ) {
+ if (code & 1)
+ *lower += 1;
+ else
+ *upper -= 1;
+ }
+ else if (code == 0x0130)
+ *lower = 0x0069;
+ else if (code == 0x0131)
+ *upper = 0x0049;
+ else if (code == 0x0178)
+ *lower = 0x00ff;
+ else if (code == 0x017f)
+ *upper = 0x0053;
+ return;
+ }
+
+ /* Latin Extended-B, U+0180 to U+024F */
+ if (code >= 0x0180 && code <= 0x024f) {
+ if (code >= 0x01cd && code <= 0x01dc) {
+ if (code & 1)
+ *lower += 1;
+ else
+ *upper -= 1;
+ }
+ else if ( (code >= 0x01de && code <= 0x01ef) ||
+ (code >= 0x01f4 && code <= 0x01f5) ||
+ (code >= 0x01f8 && code <= 0x021f) ||
+ (code >= 0x0222 && code <= 0x0233) ) {
+ *lower |= 1;
+ *upper &= ~1;
+ }
+ else if (code >= 0x0180 && code <= 0x01cc) {
+ *lower = LatinExtB_lower_mapping[code - 0x0180];
+ *upper = LatinExtB_upper_mapping[code - 0x0180];
+ }
+ else if (code == 0x01dd)
+ *upper = 0x018e;
+ else if (code == 0x01f1 || code == 0x01f2) {
+ *lower = 0x01f3;
+ *upper = 0x01f1;
+ }
+ else if (code == 0x01f3)
+ *upper = 0x01f1;
+ else if (code == 0x01f6)
+ *lower = 0x0195;
+ else if (code == 0x01f7)
+ *lower = 0x01bf;
+ else if (code == 0x0220)
+ *lower = 0x019e;
+ return;
+ }
+
+ /* IPA Extensions, U+0250 to U+02AF */
+ if (code >= 0x0253 && code <= 0x0292) {
+ *upper = IPAExt_upper_mapping[code - 0x0253];
+ }
+
+ /* Combining Diacritical Marks, U+0300 to U+036F */
+ if (code == 0x0345) {
+ *upper = 0x0399;
+ }
+
+ /* Greek and Coptic, U+0370 to U+03FF */
+ if (code >= 0x0370 && code <= 0x03ff) {
+ *lower = Greek_lower_mapping[code - 0x0370];
+ *upper = Greek_upper_mapping[code - 0x0370];
+ if (*upper == 0)
+ *upper = code;
+ if (*lower == 0)
+ *lower = code;
+ }
+
+ /* Cyrillic and Cyrillic Supplementary, U+0400 to U+052F */
+ if ( (code >= 0x0400 && code <= 0x04ff) ||
+ (code >= 0x0500 && code <= 0x052f) ) {
+ if (code >= 0x0400 && code <= 0x040f)
+ *lower += 0x50;
+ else if (code >= 0x0410 && code <= 0x042f)
+ *lower += 0x20;
+ else if (code >= 0x0430 && code <= 0x044f)
+ *upper -= 0x20;
+ else if (code >= 0x0450 && code <= 0x045f)
+ *upper -= 0x50;
+ else if ( (code >= 0x0460 && code <= 0x0481) ||
+ (code >= 0x048a && code <= 0x04bf) ||
+ (code >= 0x04d0 && code <= 0x04f5) ||
+ (code >= 0x04f8 && code <= 0x04f9) ||
+ (code >= 0x0500 && code <= 0x050f) ) {
+ *upper &= ~1;
+ *lower |= 1;
+ }
+ else if (code >= 0x04c1 && code <= 0x04ce) {
+ if (code & 1)
+ *lower += 1;
+ else
+ *upper -= 1;
+ }
+ }
+
+ /* Armenian, U+0530 to U+058F */
+ if (code >= 0x0530 && code <= 0x058f) {
+ if (code >= 0x0531 && code <= 0x0556)
+ *lower += 0x30;
+ else if (code >=0x0561 && code <= 0x0586)
+ *upper -= 0x30;
+ }
+
+ /* Latin Extended Additional, U+1E00 to U+1EFF */
+ if (code >= 0x1e00 && code <= 0x1eff) {
+ if ( (code >= 0x1e00 && code <= 0x1e95) ||
+ (code >= 0x1ea0 && code <= 0x1ef9) ) {
+ *upper &= ~1;
+ *lower |= 1;
+ }
+ else if (code == 0x1e9b)
+ *upper = 0x1e60;
+ }
+
+ /* Greek Extended, U+1F00 to U+1FFF */
+ if (code >= 0x1f00 && code <= 0x1fff) {
+ *lower = GreekExt_lower_mapping[code - 0x1f00];
+ *upper = GreekExt_upper_mapping[code - 0x1f00];
+ if (*upper == 0)
+ *upper = code;
+ if (*lower == 0)
+ *lower = code;
+ }
+
+ /* Letterlike Symbols, U+2100 to U+214F */
+ if (code >= 0x2100 && code <= 0x214f) {
+ switch (code) {
+ case 0x2126: *lower = 0x03c9; break;
+ case 0x212a: *lower = 0x006b; break;
+ case 0x212b: *lower = 0x00e5; break;
+ }
+ }
+ /* Number Forms, U+2150 to U+218F */
+ else if (code >= 0x2160 && code <= 0x216f)
+ *lower += 0x10;
+ else if (code >= 0x2170 && code <= 0x217f)
+ *upper -= 0x10;
+ /* Enclosed Alphanumerics, U+2460 to U+24FF */
+ else if (code >= 0x24b6 && code <= 0x24cf)
+ *lower += 0x1a;
+ else if (code >= 0x24d0 && code <= 0x24e9)
+ *upper -= 0x1a;
+ /* Halfwidth and Fullwidth Forms, U+FF00 to U+FFEF */
+ else if (code >= 0xff21 && code <= 0xff3a)
+ *lower += 0x20;
+ else if (code >= 0xff41 && code <= 0xff5a)
+ *upper -= 0x20;
+ /* Deseret, U+10400 to U+104FF */
+ else if (code >= 0x10400 && code <= 0x10427)
+ *lower += 0x28;
+ else if (code >= 0x10428 && code <= 0x1044f)
+ *upper -= 0x28;
+}
+
+void
+XConvertCase(sym, lower, upper)
+ register KeySym sym;
+ KeySym *lower;
+ KeySym *upper;
+{
+ /* Latin 1 keysym */
+ if (sym < 0x100) {
+ UCSConvertCase(sym, lower, upper);
+ return;
+ }
+
+ /* Unicode keysym */
+ if ((sym & 0xff000000) == 0x01000000) {
+ UCSConvertCase((sym & 0x00ffffff), lower, upper);
+ *upper |= 0x01000000;
+ *lower |= 0x01000000;
+ return;
+ }
+
+ /* Legacy keysym */
+
+ *lower = sym;
+ *upper = sym;
+
+ switch(sym >> 8) {
+ 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;
+ case 0x13: /* Latin 9 */
+ if (sym == XK_OE)
+ *lower = XK_oe;
+ else if (sym == XK_oe)
+ *upper = XK_OE;
+ else if (sym == XK_Ydiaeresis)
+ *lower = XK_ydiaeresis;
+ break;
+ }
+}
+
+int
+_XTranslateKey( register Display *dpy,
+ KeyCode keycode,
+ register unsigned int modifiers,
+ unsigned int *modifiers_return,
+ KeySym *keysym_return)
+{
+ 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(
+ 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);
+ }
+}
+
+int
+XRebindKeysym (
+ Display *dpy,
+ KeySym keysym,
+ KeySym *mlist,
+ int nm, /* number of modifiers in mlist */
+ _Xconst unsigned char *str,
+ int nbytes)
+{
+ 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(
+ 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(
+ 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/nx-X11/lib/X11/KeysymStr.c b/nx-X11/lib/X11/KeysymStr.c
new file mode 100644
index 000000000..59aa3f32c
--- /dev/null
+++ b/nx-X11/lib/X11/KeysymStr.c
@@ -0,0 +1,154 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/KeysymStr.c,v 3.9 2003/04/13 19:22:16 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xresource.h>
+#include <X11/keysymdef.h>
+
+#include <stdio.h> /* sprintf */
+
+typedef unsigned long Signature;
+
+#define NEEDVTABLE
+#include "ks_tables.h"
+#include "Key.h"
+
+
+typedef struct _GRNData {
+ char *name;
+ XrmRepresentation type;
+ XrmValuePtr value;
+} GRNData;
+
+/*ARGSUSED*/
+static Bool
+SameValue(
+ XrmDatabase* db,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ XrmRepresentation* type,
+ XrmValuePtr value,
+ XPointer data
+)
+{
+ 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, val3, val4;
+ XrmDatabase keysymdb;
+
+ if (!ks || (ks & ((unsigned long) ~0x1fffffff)) != 0)
+ return ((char *)NULL);
+ if (ks == XK_VoidSymbol)
+ ks = 0;
+ if (ks <= 0x1fffffff)
+ {
+ val1 = ks >> 24;
+ val2 = (ks >> 16) & 0xff;
+ val3 = (ks >> 8) & 0xff;
+ val4 = ks & 0xff;
+ i = ks % VTABLESIZE;
+ h = i + 1;
+ n = VMAXHASH;
+ while ((idx = hashKeysym[i]))
+ {
+ entry = &_XkeyTable[idx];
+ if ((entry[0] == val1) && (entry[1] == val2) &&
+ (entry[2] == val3) && (entry[3] == val4))
+ return ((char *)entry + 4);
+ 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);
+ if (data.name)
+ return data.name;
+ }
+ if (ks >= 0x01000100 && ks <= 0x0110ffff) {
+ KeySym val = ks & 0xffffff;
+ char *s;
+ int i;
+ if (val & 0xff0000)
+ i = 10;
+ else
+ i = 6;
+ s = Xmalloc(i);
+ if (s == NULL)
+ return s;
+ i--;
+ s[i--] = '\0';
+ for (; i; i--){
+ val1 = val & 0xf;
+ val >>= 4;
+ if (val1 < 10)
+ s[i] = '0'+ val1;
+ else
+ s[i] = 'A'+ val1 - 10;
+ }
+ s[i] = 'U';
+ return s;
+ }
+ return ((char *) NULL);
+}
diff --git a/nx-X11/lib/X11/KillCl.c b/nx-X11/lib/X11/KillCl.c
new file mode 100644
index 000000000..4c2ddcfe6
--- /dev/null
+++ b/nx-X11/lib/X11/KillCl.c
@@ -0,0 +1,46 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/KillCl.c,v 1.3 2001/01/17 19:41:38 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/LRGB.c b/nx-X11/lib/X11/LRGB.c
new file mode 100644
index 000000000..e4bc0b500
--- /dev/null
+++ b/nx-X11/lib/X11/LRGB.c
@@ -0,0 +1,1832 @@
+/* $Xorg: LRGB.c,v 1.3 2000/08/17 19:44:39 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsLRGB.c
+ *
+ * DESCRIPTION
+ * This file contains the conversion routines:
+ * 1. CIE XYZ to RGB intensity
+ * 2. RGB intensity to device RGB
+ * 3. device RGB to RGB intensity
+ * 4. RGB intensity to CIE XYZ
+ *
+ */
+/* $XFree86: xc/lib/X11/LRGB.c,v 3.6 2003/04/13 19:22:16 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xos.h>
+#include <X11/Xatom.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+/*
+ * LOCAL DEFINES
+ * #define declarations local to this package.
+ */
+#define EPS 0.001
+#ifndef MIN
+#define MIN(x,y) ((x) > (y) ? (y) : (x))
+#endif /* MIN */
+#ifndef MAX
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+#endif /* MAX */
+#ifndef MIN3
+#define MIN3(x,y,z) ((x) > (MIN((y), (z))) ? (MIN((y), (z))) : (x))
+#endif /* MIN3 */
+#ifndef MAX3
+#define MAX3(x,y,z) ((x) > (MAX((y), (z))) ? (x) : (MAX((y), (z))))
+#endif /* MAX3 */
+
+/*
+ * LOCAL TYPEDEFS
+ * typedefs local to this package (for use with local vars).
+ *
+ */
+
+/*
+ * FORWARD DECLARATIONS
+ */
+static void LINEAR_RGB_FreeSCCData(XPointer pScreenDataTemp);
+static int LINEAR_RGB_InitSCCData(Display *dpy,
+ int screenNumber, XcmsPerScrnInfo *pPerScrnInfo);
+static int XcmsLRGB_RGB_ParseString(register char *spec, XcmsColor *pColor);
+static int XcmsLRGB_RGBi_ParseString(register char *spec, XcmsColor *pColor);
+static Status
+_XcmsGetTableType0(
+ IntensityTbl *pTbl,
+ int format,
+ char **pChar,
+ unsigned long *pCount);
+static Status
+_XcmsGetTableType1(
+ IntensityTbl *pTbl,
+ int format,
+ char **pChar,
+ unsigned long *pCount);
+
+/*
+ * LOCALS VARIABLES
+ * Variables local to this package.
+ * Usage example:
+ * static int ExampleLocalVar;
+ */
+
+static unsigned short const MASK[17] = {
+ 0x0000, /* 0 bitsPerRGB */
+ 0x8000, /* 1 bitsPerRGB */
+ 0xc000, /* 2 bitsPerRGB */
+ 0xe000, /* 3 bitsPerRGB */
+ 0xf000, /* 4 bitsPerRGB */
+ 0xf800, /* 5 bitsPerRGB */
+ 0xfc00, /* 6 bitsPerRGB */
+ 0xfe00, /* 7 bitsPerRGB */
+ 0xff00, /* 8 bitsPerRGB */
+ 0xff80, /* 9 bitsPerRGB */
+ 0xffc0, /* 10 bitsPerRGB */
+ 0xffe0, /* 11 bitsPerRGB */
+ 0xfff0, /* 12 bitsPerRGB */
+ 0xfff8, /* 13 bitsPerRGB */
+ 0xfffc, /* 14 bitsPerRGB */
+ 0xfffe, /* 15 bitsPerRGB */
+ 0xffff /* 16 bitsPerRGB */
+};
+
+
+ /*
+ * A NULL terminated array of function pointers that when applied
+ * in series will convert an XcmsColor structure from XcmsRGBFormat
+ * to XcmsCIEXYZFormat.
+ */
+static XcmsConversionProc Fl_RGB_to_CIEXYZ[] = {
+ (XcmsConversionProc)XcmsRGBToRGBi,
+ (XcmsConversionProc)XcmsRGBiToCIEXYZ,
+ NULL
+};
+
+ /*
+ * A NULL terminated array of function pointers that when applied
+ * in series will convert an XcmsColor structure from XcmsCIEXYZFormat
+ * to XcmsRGBFormat.
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_RGB[] = {
+ (XcmsConversionProc)XcmsCIEXYZToRGBi,
+ (XcmsConversionProc)XcmsRGBiToRGB,
+ NULL
+};
+
+ /*
+ * A NULL terminated array of function pointers that when applied
+ * in series will convert an XcmsColor structure from XcmsRGBiFormat
+ * to XcmsCIEXYZFormat.
+ */
+static XcmsConversionProc Fl_RGBi_to_CIEXYZ[] = {
+ (XcmsConversionProc)XcmsRGBiToCIEXYZ,
+ NULL
+};
+
+ /*
+ * A NULL terminated array of function pointers that when applied
+ * in series will convert an XcmsColor structure from XcmsCIEXYZFormat
+ * to XcmsRGBiFormat.
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_RGBi[] = {
+ (XcmsConversionProc)XcmsCIEXYZToRGBi,
+ NULL
+};
+
+ /*
+ * RGBi Color Spaces
+ */
+XcmsColorSpace XcmsRGBiColorSpace =
+ {
+ _XcmsRGBi_prefix, /* prefix */
+ XcmsRGBiFormat, /* id */
+ XcmsLRGB_RGBi_ParseString, /* parseString */
+ Fl_RGBi_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_RGBi, /* from_CIEXYZ */
+ 1
+ };
+
+ /*
+ * RGB Color Spaces
+ */
+XcmsColorSpace XcmsRGBColorSpace =
+ {
+ _XcmsRGB_prefix, /* prefix */
+ XcmsRGBFormat, /* id */
+ XcmsLRGB_RGB_ParseString, /* parseString */
+ Fl_RGB_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_RGB, /* from_CIEXYZ */
+ 1
+ };
+
+ /*
+ * Device-Independent Color Spaces known to the
+ * LINEAR_RGB Screen Color Characteristics Function Set.
+ */
+static XcmsColorSpace *DDColorSpaces[] = {
+ &XcmsRGBColorSpace,
+ &XcmsRGBiColorSpace,
+ NULL
+};
+
+
+/*
+ * GLOBALS
+ * Variables declared in this package that are allowed
+ * to be used globally.
+ */
+
+ /*
+ * LINEAR_RGB Screen Color Characteristics Function Set.
+ */
+XcmsFunctionSet XcmsLinearRGBFunctionSet =
+ {
+ &DDColorSpaces[0], /* pDDColorSpaces */
+ LINEAR_RGB_InitSCCData, /* pInitScrnFunc */
+ LINEAR_RGB_FreeSCCData /* pFreeSCCData */
+ };
+
+/*
+ * DESCRIPTION
+ * Contents of Default SCCData should be replaced if other
+ * data should be used as default.
+ *
+ *
+ */
+
+/*
+ * NAME Tektronix 19" (Sony) CRT
+ * PART_NUMBER 119-2451-00
+ * MODEL Tek4300, Tek4800
+ */
+
+static IntensityRec const Default_RGB_RedTuples[] = {
+ /* {unsigned short value, XcmsFloat intensity} */
+ { 0x0000, 0.000000 },
+ { 0x0909, 0.000000 },
+ { 0x0a0a, 0.000936 },
+ { 0x0f0f, 0.001481 },
+ { 0x1414, 0.002329 },
+ { 0x1919, 0.003529 },
+ { 0x1e1e, 0.005127 },
+ { 0x2323, 0.007169 },
+ { 0x2828, 0.009699 },
+ { 0x2d2d, 0.012759 },
+ { 0x3232, 0.016392 },
+ { 0x3737, 0.020637 },
+ { 0x3c3c, 0.025533 },
+ { 0x4141, 0.031119 },
+ { 0x4646, 0.037431 },
+ { 0x4b4b, 0.044504 },
+ { 0x5050, 0.052373 },
+ { 0x5555, 0.061069 },
+ { 0x5a5a, 0.070624 },
+ { 0x5f5f, 0.081070 },
+ { 0x6464, 0.092433 },
+ { 0x6969, 0.104744 },
+ { 0x6e6e, 0.118026 },
+ { 0x7373, 0.132307 },
+ { 0x7878, 0.147610 },
+ { 0x7d7d, 0.163958 },
+ { 0x8282, 0.181371 },
+ { 0x8787, 0.199871 },
+ { 0x8c8c, 0.219475 },
+ { 0x9191, 0.240202 },
+ { 0x9696, 0.262069 },
+ { 0x9b9b, 0.285089 },
+ { 0xa0a0, 0.309278 },
+ { 0xa5a5, 0.334647 },
+ { 0xaaaa, 0.361208 },
+ { 0xafaf, 0.388971 },
+ { 0xb4b4, 0.417945 },
+ { 0xb9b9, 0.448138 },
+ { 0xbebe, 0.479555 },
+ { 0xc3c3, 0.512202 },
+ { 0xc8c8, 0.546082 },
+ { 0xcdcd, 0.581199 },
+ { 0xd2d2, 0.617552 },
+ { 0xd7d7, 0.655144 },
+ { 0xdcdc, 0.693971 },
+ { 0xe1e1, 0.734031 },
+ { 0xe6e6, 0.775322 },
+ { 0xebeb, 0.817837 },
+ { 0xf0f0, 0.861571 },
+ { 0xf5f5, 0.906515 },
+ { 0xfafa, 0.952662 },
+ { 0xffff, 1.000000 }
+};
+
+static IntensityRec const Default_RGB_GreenTuples[] = {
+ /* {unsigned short value, XcmsFloat intensity} */
+ { 0x0000, 0.000000 },
+ { 0x1313, 0.000000 },
+ { 0x1414, 0.000832 },
+ { 0x1919, 0.001998 },
+ { 0x1e1e, 0.003612 },
+ { 0x2323, 0.005736 },
+ { 0x2828, 0.008428 },
+ { 0x2d2d, 0.011745 },
+ { 0x3232, 0.015740 },
+ { 0x3737, 0.020463 },
+ { 0x3c3c, 0.025960 },
+ { 0x4141, 0.032275 },
+ { 0x4646, 0.039449 },
+ { 0x4b4b, 0.047519 },
+ { 0x5050, 0.056520 },
+ { 0x5555, 0.066484 },
+ { 0x5a5a, 0.077439 },
+ { 0x5f5f, 0.089409 },
+ { 0x6464, 0.102418 },
+ { 0x6969, 0.116485 },
+ { 0x6e6e, 0.131625 },
+ { 0x7373, 0.147853 },
+ { 0x7878, 0.165176 },
+ { 0x7d7d, 0.183604 },
+ { 0x8282, 0.203140 },
+ { 0x8787, 0.223783 },
+ { 0x8c8c, 0.245533 },
+ { 0x9191, 0.268384 },
+ { 0x9696, 0.292327 },
+ { 0x9b9b, 0.317351 },
+ { 0xa0a0, 0.343441 },
+ { 0xa5a5, 0.370580 },
+ { 0xaaaa, 0.398747 },
+ { 0xafaf, 0.427919 },
+ { 0xb4b4, 0.458068 },
+ { 0xb9b9, 0.489165 },
+ { 0xbebe, 0.521176 },
+ { 0xc3c3, 0.554067 },
+ { 0xc8c8, 0.587797 },
+ { 0xcdcd, 0.622324 },
+ { 0xd2d2, 0.657604 },
+ { 0xd7d7, 0.693588 },
+ { 0xdcdc, 0.730225 },
+ { 0xe1e1, 0.767459 },
+ { 0xe6e6, 0.805235 },
+ { 0xebeb, 0.843491 },
+ { 0xf0f0, 0.882164 },
+ { 0xf5f5, 0.921187 },
+ { 0xfafa, 0.960490 },
+ { 0xffff, 1.000000 }
+};
+
+static IntensityRec const Default_RGB_BlueTuples[] = {
+ /* {unsigned short value, XcmsFloat intensity} */
+ { 0x0000, 0.000000 },
+ { 0x0e0e, 0.000000 },
+ { 0x0f0f, 0.001341 },
+ { 0x1414, 0.002080 },
+ { 0x1919, 0.003188 },
+ { 0x1e1e, 0.004729 },
+ { 0x2323, 0.006766 },
+ { 0x2828, 0.009357 },
+ { 0x2d2d, 0.012559 },
+ { 0x3232, 0.016424 },
+ { 0x3737, 0.021004 },
+ { 0x3c3c, 0.026344 },
+ { 0x4141, 0.032489 },
+ { 0x4646, 0.039481 },
+ { 0x4b4b, 0.047357 },
+ { 0x5050, 0.056154 },
+ { 0x5555, 0.065903 },
+ { 0x5a5a, 0.076634 },
+ { 0x5f5f, 0.088373 },
+ { 0x6464, 0.101145 },
+ { 0x6969, 0.114968 },
+ { 0x6e6e, 0.129862 },
+ { 0x7373, 0.145841 },
+ { 0x7878, 0.162915 },
+ { 0x7d7d, 0.181095 },
+ { 0x8282, 0.200386 },
+ { 0x8787, 0.220791 },
+ { 0x8c8c, 0.242309 },
+ { 0x9191, 0.264937 },
+ { 0x9696, 0.288670 },
+ { 0x9b9b, 0.313499 },
+ { 0xa0a0, 0.339410 },
+ { 0xa5a5, 0.366390 },
+ { 0xaaaa, 0.394421 },
+ { 0xafaf, 0.423481 },
+ { 0xb4b4, 0.453547 },
+ { 0xb9b9, 0.484592 },
+ { 0xbebe, 0.516587 },
+ { 0xc3c3, 0.549498 },
+ { 0xc8c8, 0.583291 },
+ { 0xcdcd, 0.617925 },
+ { 0xd2d2, 0.653361 },
+ { 0xd7d7, 0.689553 },
+ { 0xdcdc, 0.726454 },
+ { 0xe1e1, 0.764013 },
+ { 0xe6e6, 0.802178 },
+ { 0xebeb, 0.840891 },
+ { 0xf0f0, 0.880093 },
+ { 0xf5f5, 0.919723 },
+ { 0xfafa, 0.959715 },
+ { 0xffff, 1.00000 }
+};
+
+static IntensityTbl Default_RGB_RedTbl = {
+ /* IntensityRec *pBase */
+ (IntensityRec *) Default_RGB_RedTuples,
+ /* unsigned int nEntries */
+ 52
+};
+
+static IntensityTbl Default_RGB_GreenTbl = {
+ /* IntensityRec *pBase */
+ (IntensityRec *)Default_RGB_GreenTuples,
+ /* unsigned int nEntries */
+ 50
+};
+
+static IntensityTbl Default_RGB_BlueTbl = {
+ /* IntensityRec *pBase */
+ (IntensityRec *)Default_RGB_BlueTuples,
+ /* unsigned int nEntries */
+ 51
+};
+
+static LINEAR_RGB_SCCData Default_RGB_SCCData = {
+ /* XcmsFloat XYZtoRGBmatrix[3][3] */
+ {
+ { 3.48340481253539000, -1.52176374927285200, -0.55923133354049780 },
+ {-1.07152751306193600, 1.96593795204372400, 0.03673691339553462 },
+ { 0.06351179790497788, -0.20020501000496480, 0.81070942031648220 }
+ },
+
+ /* XcmsFloat RGBtoXYZmatrix[3][3] */
+ {
+ { 0.38106149108714790, 0.32025712365352110, 0.24834578525933100 },
+ { 0.20729745115140850, 0.68054638776373240, 0.11215616108485920 },
+ { 0.02133944350088028, 0.14297193020246480, 1.24172892629665500 }
+ },
+
+ /* IntensityTbl *pRedTbl */
+ &Default_RGB_RedTbl,
+
+ /* IntensityTbl *pGreenTbl */
+ &Default_RGB_GreenTbl,
+
+ /* IntensityTbl *pBlueTbl */
+ &Default_RGB_BlueTbl
+};
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * LINEAR_RGB_InitSCCData()
+ *
+ * SYNOPSIS
+ */
+static Status
+LINEAR_RGB_InitSCCData(
+ Display *dpy,
+ int screenNumber,
+ XcmsPerScrnInfo *pPerScrnInfo)
+/*
+ * DESCRIPTION
+ *
+ * RETURNS
+ * XcmsFailure if failed.
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ Atom CorrectAtom = XInternAtom (dpy, XDCCC_CORRECT_ATOM_NAME, True);
+ Atom MatrixAtom = XInternAtom (dpy, XDCCC_MATRIX_ATOM_NAME, True);
+ int format_return, count, cType, nTables;
+ unsigned long nitems, nbytes_return;
+ char *property_return, *pChar;
+ XcmsFloat *pValue;
+#ifdef ALLDEBUG
+ IntensityRec *pIRec;
+#endif /* ALLDEBUG */
+ VisualID visualID;
+
+ LINEAR_RGB_SCCData *pScreenData, *pScreenDefaultData;
+ XcmsIntensityMap *pNewMap;
+
+ /*
+ * Allocate memory for pScreenData
+ */
+ if (!(pScreenData = pScreenDefaultData = (LINEAR_RGB_SCCData *)
+ Xcalloc (1, sizeof(LINEAR_RGB_SCCData)))) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * 1. Get the XYZ->RGB and RGB->XYZ matrices
+ */
+
+ if (MatrixAtom == None ||
+ !_XcmsGetProperty (dpy, RootWindow(dpy, screenNumber), MatrixAtom,
+ &format_return, &nitems, &nbytes_return, &property_return) ||
+ nitems != 18 || format_return != 32) {
+ /*
+ * As per the XDCCC, there must be 18 data items and each must be
+ * in 32 bits !
+ */
+ goto FreeSCCData;
+
+ } else {
+
+ /*
+ * RGBtoXYZ and XYZtoRGB matrices
+ */
+ pValue = (XcmsFloat *) pScreenData;
+ pChar = property_return;
+ for (count = 0; count < 18; count++) {
+ *pValue++ = (long)_XcmsGetElement(format_return, &pChar,
+ &nitems) / (XcmsFloat)XDCCC_NUMBER;
+ }
+ Xfree ((char *)property_return);
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.X =
+ pScreenData->RGBtoXYZmatrix[0][0] +
+ pScreenData->RGBtoXYZmatrix[0][1] +
+ pScreenData->RGBtoXYZmatrix[0][2];
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y =
+ pScreenData->RGBtoXYZmatrix[1][0] +
+ pScreenData->RGBtoXYZmatrix[1][1] +
+ pScreenData->RGBtoXYZmatrix[1][2];
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Z =
+ pScreenData->RGBtoXYZmatrix[2][0] +
+ pScreenData->RGBtoXYZmatrix[2][1] +
+ pScreenData->RGBtoXYZmatrix[2][2];
+
+ /*
+ * Compute the Screen White Point
+ */
+ if ((pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y < (1.0 - EPS) )
+ || (pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y > (1.0 + EPS))) {
+ goto FreeSCCData;
+ } else {
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y = 1.0;
+ }
+ pPerScrnInfo->screenWhitePt.format = XcmsCIEXYZFormat;
+ pPerScrnInfo->screenWhitePt.pixel = 0;
+
+#ifdef PDEBUG
+ printf ("RGB to XYZ Matrix values:\n");
+ printf (" %f %f %f\n %f %f %f\n %f %f %f\n",
+ pScreenData->RGBtoXYZmatrix[0][0],
+ pScreenData->RGBtoXYZmatrix[0][1],
+ pScreenData->RGBtoXYZmatrix[0][2],
+ pScreenData->RGBtoXYZmatrix[1][0],
+ pScreenData->RGBtoXYZmatrix[1][1],
+ pScreenData->RGBtoXYZmatrix[1][2],
+ pScreenData->RGBtoXYZmatrix[2][0],
+ pScreenData->RGBtoXYZmatrix[2][1],
+ pScreenData->RGBtoXYZmatrix[2][2]);
+ printf ("XYZ to RGB Matrix values:\n");
+ printf (" %f %f %f\n %f %f %f\n %f %f %f\n",
+ pScreenData->XYZtoRGBmatrix[0][0],
+ pScreenData->XYZtoRGBmatrix[0][1],
+ pScreenData->XYZtoRGBmatrix[0][2],
+ pScreenData->XYZtoRGBmatrix[1][0],
+ pScreenData->XYZtoRGBmatrix[1][1],
+ pScreenData->XYZtoRGBmatrix[1][2],
+ pScreenData->XYZtoRGBmatrix[2][0],
+ pScreenData->XYZtoRGBmatrix[2][1],
+ pScreenData->XYZtoRGBmatrix[2][2]);
+ printf ("Screen White Pt value: %f %f %f\n",
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.X,
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y,
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Z);
+#endif /* PDEBUG */
+ }
+
+ /*
+ * 2. Get the Intensity Profile
+ */
+ if (CorrectAtom == None ||
+ !_XcmsGetProperty (dpy, RootWindow(dpy, screenNumber), CorrectAtom,
+ &format_return, &nitems, &nbytes_return, &property_return)) {
+ Xfree ((char *)property_return);
+ goto FreeSCCData;
+ }
+
+ pChar = property_return;
+
+ while (nitems) {
+ switch (format_return) {
+ case 8:
+ /*
+ * Must have at least:
+ * VisualID0
+ * VisualID1
+ * VisualID2
+ * VisualID3
+ * type
+ * count
+ * length
+ * intensity1
+ * intensity2
+ */
+ if (nitems < 9) {
+ Xfree ((char *)property_return);
+ goto FreeSCCData;
+ }
+ count = 3;
+ break;
+ case 16:
+ /*
+ * Must have at least:
+ * VisualID0
+ * VisualID3
+ * type
+ * count
+ * length
+ * intensity1
+ * intensity2
+ */
+ if (nitems < 7) {
+ Xfree ((char *)property_return);
+ goto FreeSCCData;
+ }
+ count = 1;
+ break;
+ case 32:
+ /*
+ * Must have at least:
+ * VisualID0
+ * type
+ * count
+ * length
+ * intensity1
+ * intensity2
+ */
+ if (nitems < 6) {
+ Xfree ((char *)property_return);
+ goto FreeSCCData;
+ }
+ count = 0;
+ break;
+ default:
+ Xfree ((char *)property_return);
+ goto FreeSCCData;
+ }
+
+ /*
+ * Get VisualID
+ */
+ visualID = _XcmsGetElement(format_return, &pChar, &nitems);
+ while (count--) {
+ visualID = visualID << format_return;
+ visualID |= _XcmsGetElement(format_return, &pChar, &nitems);
+ }
+
+ if (visualID == 0) {
+ /*
+ * This is a shared intensity table
+ */
+ pScreenData = pScreenDefaultData;
+ } else {
+ /*
+ * This is a per-Visual intensity table
+ */
+ if (!(pScreenData = (LINEAR_RGB_SCCData *)
+ Xcalloc (1, sizeof(LINEAR_RGB_SCCData)))) {
+ return(XcmsFailure);
+ }
+ /* copy matrices */
+ memcpy((char *)pScreenData, (char *)pScreenDefaultData,
+ 18 * sizeof(XcmsFloat));
+
+ /* Create, initialize, and add map */
+ if (!(pNewMap = (XcmsIntensityMap *)
+ Xcalloc (1, sizeof(XcmsIntensityMap)))) {
+ Xfree((char *)pScreenData);
+ return(XcmsFailure);
+ }
+ pNewMap->visualID = visualID;
+ pNewMap->screenData = (XPointer)pScreenData;
+ pNewMap->pFreeScreenData = LINEAR_RGB_FreeSCCData;
+ pNewMap->pNext =
+ (XcmsIntensityMap *)dpy->cms.perVisualIntensityMaps;
+ dpy->cms.perVisualIntensityMaps = (XPointer)pNewMap;
+ dpy->free_funcs->intensityMaps = _XcmsFreeIntensityMaps;
+ }
+
+ cType = _XcmsGetElement(format_return, &pChar, &nitems);
+ nTables = _XcmsGetElement(format_return, &pChar, &nitems);
+
+ if (cType == 0) {
+
+ /* Red Intensity Table */
+ if (!(pScreenData->pRedTbl = (IntensityTbl *)
+ Xcalloc (1, sizeof(IntensityTbl)))) {
+ goto FreeSCCData;
+ }
+ if (_XcmsGetTableType0(pScreenData->pRedTbl, format_return, &pChar,
+ &nitems) == XcmsFailure) {
+ goto FreeRedTbl;
+ }
+
+ if (nTables == 1) {
+ /* Green Intensity Table */
+ pScreenData->pGreenTbl = pScreenData->pRedTbl;
+ /* Blue Intensity Table */
+ pScreenData->pBlueTbl = pScreenData->pRedTbl;
+ } else {
+ /* Green Intensity Table */
+ if (!(pScreenData->pGreenTbl = (IntensityTbl *)
+ Xcalloc (1, sizeof(IntensityTbl)))) {
+ goto FreeRedTblElements;
+ }
+ if (_XcmsGetTableType0(pScreenData->pGreenTbl, format_return, &pChar,
+ &nitems) == XcmsFailure) {
+ goto FreeGreenTbl;
+ }
+
+ /* Blue Intensity Table */
+ if (!(pScreenData->pBlueTbl = (IntensityTbl *)
+ Xcalloc (1, sizeof(IntensityTbl)))) {
+ goto FreeGreenTblElements;
+ }
+ if (_XcmsGetTableType0(pScreenData->pBlueTbl, format_return, &pChar,
+ &nitems) == XcmsFailure) {
+ goto FreeBlueTbl;
+ }
+ }
+ } else if (cType == 1) {
+ /* Red Intensity Table */
+ if (!(pScreenData->pRedTbl = (IntensityTbl *)
+ Xcalloc (1, sizeof(IntensityTbl)))) {
+ goto FreeSCCData;
+ }
+ if (_XcmsGetTableType1(pScreenData->pRedTbl, format_return, &pChar,
+ &nitems) == XcmsFailure) {
+ goto FreeRedTbl;
+ }
+
+ if (nTables == 1) {
+
+ /* Green Intensity Table */
+ pScreenData->pGreenTbl = pScreenData->pRedTbl;
+ /* Blue Intensity Table */
+ pScreenData->pBlueTbl = pScreenData->pRedTbl;
+
+ } else {
+
+ /* Green Intensity Table */
+ if (!(pScreenData->pGreenTbl = (IntensityTbl *)
+ Xcalloc (1, sizeof(IntensityTbl)))) {
+ goto FreeRedTblElements;
+ }
+ if (_XcmsGetTableType1(pScreenData->pGreenTbl, format_return, &pChar,
+ &nitems) == XcmsFailure) {
+ goto FreeGreenTbl;
+ }
+
+ /* Blue Intensity Table */
+ if (!(pScreenData->pBlueTbl = (IntensityTbl *)
+ Xcalloc (1, sizeof(IntensityTbl)))) {
+ goto FreeBlueTblElements;
+ }
+ if (_XcmsGetTableType1(pScreenData->pBlueTbl, format_return, &pChar,
+ &nitems) == XcmsFailure) {
+ goto FreeBlueTbl;
+ }
+ }
+ } else {
+ Xfree ((char *)property_return);
+ goto FreeSCCData;
+ }
+
+#ifdef ALLDEBUG
+ printf ("Intensity Table RED %d\n", pScreenData->pRedTbl->nEntries);
+ pIRec = (IntensityRec *) pScreenData->pRedTbl->pBase;
+ for (count = 0; count < pScreenData->pRedTbl->nEntries; count++, pIRec++) {
+ printf ("\t0x%4x\t%f\n", pIRec->value, pIRec->intensity);
+ }
+ if (pScreenData->pGreenTbl->pBase != pScreenData->pRedTbl->pBase) {
+ printf ("Intensity Table GREEN %d\n", pScreenData->pGreenTbl->nEntries);
+ pIRec = (IntensityRec *)pScreenData->pGreenTbl->pBase;
+ for (count = 0; count < pScreenData->pGreenTbl->nEntries; count++, pIRec++) {
+ printf ("\t0x%4x\t%f\n", pIRec->value, pIRec->intensity);
+ }
+ }
+ if (pScreenData->pBlueTbl->pBase != pScreenData->pRedTbl->pBase) {
+ printf ("Intensity Table BLUE %d\n", pScreenData->pBlueTbl->nEntries);
+ pIRec = (IntensityRec *) pScreenData->pBlueTbl->pBase;
+ for (count = 0; count < pScreenData->pBlueTbl->nEntries; count++, pIRec++) {
+ printf ("\t0x%4x\t%f\n", pIRec->value, pIRec->intensity);
+ }
+ }
+#endif /* ALLDEBUG */
+ }
+
+ Xfree ((char *)property_return);
+
+ /* Free the old memory and use the new structure created. */
+ LINEAR_RGB_FreeSCCData(pPerScrnInfo->screenData);
+
+ pPerScrnInfo->functionSet = (XPointer) &XcmsLinearRGBFunctionSet;
+
+ pPerScrnInfo->screenData = (XPointer) pScreenData;
+
+ pPerScrnInfo->state = XcmsInitSuccess;
+
+ return(XcmsSuccess);
+
+FreeBlueTblElements:
+ Xfree((char *)pScreenData->pBlueTbl->pBase);
+
+FreeBlueTbl:
+ Xfree((char *)pScreenData->pBlueTbl);
+
+FreeGreenTblElements:
+ Xfree((char *)pScreenData->pBlueTbl->pBase);
+
+FreeGreenTbl:
+ Xfree((char *)pScreenData->pGreenTbl);
+
+FreeRedTblElements:
+ Xfree((char *)pScreenData->pRedTbl->pBase);
+
+FreeRedTbl:
+ Xfree((char *)pScreenData->pRedTbl);
+
+FreeSCCData:
+ Xfree((char *)pScreenData);
+ pPerScrnInfo->state = XcmsInitNone;
+ return(XcmsFailure);
+}
+
+
+/*
+ * NAME
+ * LINEAR_RGB_FreeSCCData()
+ *
+ * SYNOPSIS
+ */
+static void
+LINEAR_RGB_FreeSCCData(
+ XPointer pScreenDataTemp)
+/*
+ * DESCRIPTION
+ *
+ * RETURNS
+ * 0 if failed.
+ * 1 if succeeded with no modifications.
+ *
+ */
+{
+ LINEAR_RGB_SCCData *pScreenData = (LINEAR_RGB_SCCData *) pScreenDataTemp;
+
+ if (pScreenData && pScreenData != &Default_RGB_SCCData) {
+ if (pScreenData->pRedTbl) {
+ if (pScreenData->pGreenTbl) {
+ if (pScreenData->pRedTbl->pBase !=
+ pScreenData->pGreenTbl->pBase) {
+ if (pScreenData->pGreenTbl->pBase) {
+ Xfree ((char *)pScreenData->pGreenTbl->pBase);
+ }
+ }
+ if (pScreenData->pGreenTbl != pScreenData->pRedTbl) {
+ Xfree ((char *)pScreenData->pGreenTbl);
+ }
+ }
+ if (pScreenData->pBlueTbl) {
+ if (pScreenData->pRedTbl->pBase !=
+ pScreenData->pBlueTbl->pBase) {
+ if (pScreenData->pBlueTbl->pBase) {
+ Xfree ((char *)pScreenData->pBlueTbl->pBase);
+ }
+ }
+ if (pScreenData->pBlueTbl != pScreenData->pRedTbl) {
+ Xfree ((char *)pScreenData->pBlueTbl);
+ }
+ }
+ if (pScreenData->pRedTbl->pBase) {
+ Xfree ((char *)pScreenData->pRedTbl->pBase);
+ }
+ Xfree ((char *)pScreenData->pRedTbl);
+ }
+ Xfree ((char *)pScreenData);
+ }
+}
+
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsGetTableType0
+ *
+ * SYNOPSIS
+ */
+static Status
+_XcmsGetTableType0(
+ IntensityTbl *pTbl,
+ int format,
+ char **pChar,
+ unsigned long *pCount)
+/*
+ * DESCRIPTION
+ *
+ * RETURNS
+ * XcmsFailure if failed.
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ unsigned int nElements;
+ IntensityRec *pIRec;
+
+ nElements = pTbl->nEntries =
+ _XcmsGetElement(format, pChar, pCount) + 1;
+ if (!(pIRec = pTbl->pBase = (IntensityRec *)
+ Xcalloc (nElements, sizeof(IntensityRec)))) {
+ return(XcmsFailure);
+ }
+
+ switch (format) {
+ case 8:
+ for (; nElements--; pIRec++) {
+ /* 0xFFFF/0xFF = 0x101 */
+ pIRec->value = _XcmsGetElement (format, pChar, pCount) * 0x101;
+ pIRec->intensity =
+ _XcmsGetElement (format, pChar, pCount) / (XcmsFloat)255.0;
+ }
+ break;
+ case 16:
+ for (; nElements--; pIRec++) {
+ pIRec->value = _XcmsGetElement (format, pChar, pCount);
+ pIRec->intensity = _XcmsGetElement (format, pChar, pCount)
+ / (XcmsFloat)65535.0;
+ }
+ break;
+ case 32:
+ for (; nElements--; pIRec++) {
+ pIRec->value = _XcmsGetElement (format, pChar, pCount);
+ pIRec->intensity = _XcmsGetElement (format, pChar, pCount)
+ / (XcmsFloat)4294967295.0;
+ }
+ break;
+ default:
+ return(XcmsFailure);
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * _XcmsGetTableType1
+ *
+ * SYNOPSIS
+ */
+static Status
+_XcmsGetTableType1(
+ IntensityTbl *pTbl,
+ int format,
+ char **pChar,
+ unsigned long *pCount)
+/*
+ * DESCRIPTION
+ *
+ * RETURNS
+ * XcmsFailure if failed.
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ int count;
+ unsigned int max_index;
+ IntensityRec *pIRec;
+
+ max_index = _XcmsGetElement(format, pChar, pCount);
+ pTbl->nEntries = max_index + 1;
+ if (!(pIRec = pTbl->pBase = (IntensityRec *)
+ Xcalloc (max_index+1, sizeof(IntensityRec)))) {
+ return(XcmsFailure);
+ }
+
+ switch (format) {
+ case 8:
+ for (count = 0; count < max_index+1; count++, pIRec++) {
+ pIRec->value = (count * 65535) / max_index;
+ pIRec->intensity = _XcmsGetElement (format, pChar, pCount)
+ / (XcmsFloat)255.0;
+ }
+ break;
+ case 16:
+ for (count = 0; count < max_index+1; count++, pIRec++) {
+ pIRec->value = (count * 65535) / max_index;
+ pIRec->intensity = _XcmsGetElement (format, pChar, pCount)
+ / (XcmsFloat)65535.0;
+ }
+ break;
+ case 32:
+ for (count = 0; count < max_index+1; count++, pIRec++) {
+ pIRec->value = (count * 65535) / max_index;
+ pIRec->intensity = _XcmsGetElement (format, pChar, pCount)
+ / (XcmsFloat)4294967295.0;
+ }
+ break;
+ default:
+ return(XcmsFailure);
+ }
+
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * ValueCmp
+ *
+ * SYNOPSIS
+ */
+static int
+_XcmsValueCmp(
+ IntensityRec *p1, IntensityRec *p2)
+/*
+ * DESCRIPTION
+ * Compares the value component of two IntensityRec
+ * structures.
+ *
+ * RETURNS
+ * 0 if p1->value is equal to p2->value
+ * < 0 if p1->value is less than p2->value
+ * > 0 if p1->value is greater than p2->value
+ *
+ */
+{
+ return (p1->value - p2->value);
+}
+
+
+/*
+ * NAME
+ * IntensityCmp
+ *
+ * SYNOPSIS
+ */
+static int
+_XcmsIntensityCmp(
+ IntensityRec *p1, IntensityRec *p2)
+/*
+ * DESCRIPTION
+ * Compares the intensity component of two IntensityRec
+ * structures.
+ *
+ * RETURNS
+ * 0 if equal;
+ * < 0 if first precedes second
+ * > 0 if first succeeds second
+ *
+ */
+{
+ if (p1->intensity < p2->intensity) {
+ return (-1);
+ }
+ if (p1->intensity > p2->intensity) {
+ return (XcmsSuccess);
+ }
+ return (XcmsFailure);
+}
+
+/*
+ * NAME
+ * ValueInterpolation
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+static int
+_XcmsValueInterpolation(
+ IntensityRec *key, IntensityRec *lo, IntensityRec *hi, IntensityRec *answer,
+ int bitsPerRGB)
+/*
+ * DESCRIPTION
+ * Based on a given value, performs a linear interpolation
+ * on the intensities between two IntensityRec structures.
+ * Note that the bitsPerRGB parameter is ignored.
+ *
+ * RETURNS
+ * Returns 0 if failed; otherwise non-zero.
+ */
+{
+ XcmsFloat ratio;
+
+ ratio = ((XcmsFloat)key->value - (XcmsFloat)lo->value) /
+ ((XcmsFloat)hi->value - (XcmsFloat)lo->value);
+ answer->value = key->value;
+ answer->intensity = (hi->intensity - lo->intensity) * ratio;
+ answer->intensity += lo->intensity;
+ return (XcmsSuccess);
+}
+
+/*
+ * NAME
+ * IntensityInterpolation
+ *
+ * SYNOPSIS
+ */
+static int
+_XcmsIntensityInterpolation(
+ IntensityRec *key, IntensityRec *lo, IntensityRec *hi, IntensityRec *answer,
+ int bitsPerRGB)
+/*
+ * DESCRIPTION
+ * Based on a given intensity, performs a linear interpolation
+ * on the values between two IntensityRec structures.
+ * The bitsPerRGB parameter is necessary to perform rounding
+ * to the correct number of significant bits.
+ *
+ * RETURNS
+ * Returns 0 if failed; otherwise non-zero.
+ */
+{
+ XcmsFloat ratio;
+ long target, up, down;
+ int shift = 16 - bitsPerRGB;
+ int max_color = (1 << bitsPerRGB) - 1;
+
+ ratio = (key->intensity - lo->intensity) / (hi->intensity - lo->intensity);
+ answer->intensity = key->intensity;
+ target = hi->value - lo->value;
+ target *= ratio;
+ target += lo->value;
+
+ /*
+ * Ok now, lets find the closest in respects to bits per RGB
+ */
+ up = ((target >> shift) * 0xFFFF) / max_color;
+ if (up < target) {
+ down = up;
+ up = (MIN((down >> shift) + 1, max_color) * 0xFFFF) / max_color;
+ } else {
+ down = (MAX((up >> shift) - 1, 0) * 0xFFFF) / max_color;
+ }
+ answer->value = ((up - target) < (target - down) ? up : down);
+ answer->value &= MASK[bitsPerRGB];
+ return (XcmsSuccess);
+}
+
+
+
+typedef int (*comparProcp)(
+ char *p1,
+ char *p2);
+typedef int (*interpolProcp)(
+ char *key,
+ char *lo,
+ char *hi,
+ char *answer,
+ int bitsPerRGB);
+
+/*
+ * NAME
+ * _XcmsTableSearch
+ *
+ * SYNOPSIS
+ */
+static int
+_XcmsTableSearch(
+ char *key,
+ int bitsPerRGB,
+ char *base,
+ unsigned nel,
+ unsigned nKeyPtrSize,
+ int (*compar)(
+ char *p1,
+ char *p2),
+ int (*interpol)(
+ char *key,
+ char *lo,
+ char *hi,
+ char *answer,
+ int bitsPerRGB),
+ char *answer)
+
+/*
+ * DESCRIPTION
+ * A binary search through the specificied table.
+ *
+ * RETURNS
+ * Returns 0 if failed; otherwise non-zero.
+ *
+ */
+{
+ char *hi, *lo, *mid, *last;
+ int result;
+
+ last = hi = base + ((nel - 1) * nKeyPtrSize);
+ mid = lo = base;
+
+ /* use only the significants bits, then scale into 16 bits */
+ ((IntensityRec *)key)->value = ((unsigned long)
+ (((IntensityRec *)key)->value >> (16 - bitsPerRGB)) * 0xFFFF)
+ / ((1 << bitsPerRGB) - 1);
+
+ /* Special case so that zero intensity always maps to zero value */
+ if ((*compar) (key,lo) <= 0) {
+ memcpy (answer, lo, nKeyPtrSize);
+ ((IntensityRec *)answer)->value &= MASK[bitsPerRGB];
+ return XcmsSuccess;
+ }
+ while (mid != last) {
+ last = mid;
+ mid = lo + (((unsigned)(hi - lo) / nKeyPtrSize) / 2) * nKeyPtrSize;
+ result = (*compar) (key, mid);
+ if (result == 0) {
+
+ memcpy(answer, mid, nKeyPtrSize);
+ ((IntensityRec *)answer)->value &= MASK[bitsPerRGB];
+ return (XcmsSuccess);
+ } else if (result < 0) {
+ hi = mid;
+ } else {
+ lo = mid;
+ }
+ }
+
+ /*
+ * If we got to here, we didn't find a solution, so we
+ * need to apply interpolation.
+ */
+ return ((*interpol)(key, lo, hi, answer, bitsPerRGB));
+}
+
+
+/*
+ * NAME
+ * _XcmsMatVec - multiply a 3 x 3 by a 3 x 1 vector
+ *
+ * SYNOPSIS
+ */
+static void _XcmsMatVec(
+ XcmsFloat *pMat, XcmsFloat *pIn, XcmsFloat *pOut)
+/*
+ * DESCRIPTION
+ * Multiply the passed vector by the passed matrix to return a
+ * vector. Matrix is 3x3, vectors are of length 3.
+ *
+ * RETURNS
+ * void
+ */
+{
+ int i, j;
+
+ for (i = 0; i < 3; i++) {
+ pOut[i] = 0.0;
+ for (j = 0; j < 3; j++)
+ pOut[i] += *(pMat+(i*3)+j) * pIn[j];
+ }
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+
+/*
+ * NAME
+ * XcmsLRGB_RGB_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+XcmsLRGB_RGB_ParseString(
+ register char *spec,
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsRGBFormat.
+ *
+ * RETURNS
+ * 0 if failed, non-zero otherwise.
+ */
+{
+ register int n, i;
+ unsigned short r, g, b;
+ char c;
+ char *pchar;
+ unsigned short *pShort;
+
+ /*
+ * Check for old # format
+ */
+ if (*spec == '#') {
+ /*
+ * Attempt to parse the value portion.
+ */
+ spec++;
+ n = strlen(spec);
+ if (n != 3 && n != 6 && n != 9 && n != 12) {
+ return(XcmsFailure);
+ }
+
+ n /= 3;
+ g = b = 0;
+ do {
+ r = g;
+ g = b;
+ b = 0;
+ for (i = n; --i >= 0; ) {
+ c = *spec++;
+ b <<= 4;
+ if (c >= '0' && c <= '9')
+ b |= c - '0';
+ /* assume string in lowercase
+ else if (c >= 'A' && c <= 'F')
+ b |= c - ('A' - 10);
+ */
+ else if (c >= 'a' && c <= 'f')
+ b |= c - ('a' - 10);
+ else return (XcmsFailure);
+ }
+ } while (*spec != '\0');
+
+ /*
+ * Succeeded !
+ */
+ n <<= 2;
+ n = 16 - n;
+ /* shift instead of scale, to match old broken semantics */
+ pColor->spec.RGB.red = r << n;
+ pColor->spec.RGB.green = g << n;
+ pColor->spec.RGB.blue = b << n;
+ } else {
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsRGB_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ spec += (n + 1);
+ pShort = &pColor->spec.RGB.red;
+ for (i = 0; i < 3; i++, pShort++, spec++) {
+ n = 0;
+ *pShort = 0;
+ while (*spec != '/' && *spec != '\0') {
+ if (++n > 4) {
+ return(XcmsFailure);
+ }
+ c = *spec++;
+ *pShort <<= 4;
+ if (c >= '0' && c <= '9')
+ *pShort |= c - '0';
+ /* assume string in lowercase
+ else if (c >= 'A' && c <= 'F')
+ *pShort |= c - ('A' - 10);
+ */
+ else if (c >= 'a' && c <= 'f')
+ *pShort |= c - ('a' - 10);
+ else return (XcmsFailure);
+ }
+ if (n == 0)
+ return (XcmsFailure);
+ if (n < 4) {
+ *pShort = ((unsigned long)*pShort * 0xFFFF) / ((1 << n*4) - 1);
+ }
+ }
+ }
+ pColor->format = XcmsRGBFormat;
+ pColor->pixel = 0;
+ return (XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsLRGB_RGBi_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+XcmsLRGB_RGBi_ParseString(
+ register char *spec,
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsRGBiFormat.
+ * The assumed RGBi string syntax is:
+ * RGBi:<r>/<g>/<b>
+ * Where r, g, and b are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ * 0 if failed, non-zero otherwise.
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsRGBi_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.RGBi.red,
+ &pColor->spec.RGBi.green,
+ &pColor->spec.RGBi.blue) != 3) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Succeeded !
+ */
+ pColor->format = XcmsRGBiFormat;
+ pColor->pixel = 0;
+ return (XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEXYZToRGBi - convert CIE XYZ to RGB
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIEXYZToRGBi(ccc, pXcmsColors_in_out, nColors, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pXcmsColors_in_out;/* pointer to XcmsColors to convert */
+ unsigned int nColors; /* Number of colors */
+ Bool *pCompressed; /* pointer to an array of Bool */
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from RGB format to RGBi format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression.
+ * XcmsSuccessWithCompression if succeeded with gamut
+ * compression.
+ */
+{
+ LINEAR_RGB_SCCData *pScreenData;
+ XcmsFloat tmp[3];
+ int hasCompressed = 0;
+ unsigned int i;
+ XcmsColor *pColor = pXcmsColors_in_out;
+
+ if (ccc == NULL) {
+ return(XcmsFailure);
+ }
+
+ pScreenData = (LINEAR_RGB_SCCData *)ccc->pPerScrnInfo->screenData;
+
+ /*
+ * XcmsColors should be White Point Adjusted, if necessary, by now!
+ */
+
+ /*
+ * NEW!!! for extended gamut compression
+ *
+ * 1. Need to zero out pCompressed
+ *
+ * 2. Need to save initial address of pColor
+ *
+ * 3. Need to save initial address of pCompressed
+ */
+
+ for (i = 0; i < nColors; i++) {
+
+ /* Make sure format is XcmsCIEXYZFormat */
+ if (pColor->format != XcmsCIEXYZFormat) {
+ return(XcmsFailure);
+ }
+
+ /* Multiply [A]-1 * [XYZ] to get RGB intensity */
+ _XcmsMatVec((XcmsFloat *) pScreenData->XYZtoRGBmatrix,
+ (XcmsFloat *) &pColor->spec, tmp);
+
+ if ((MIN3 (tmp[0], tmp[1], tmp[2]) < -EPS) ||
+ (MAX3 (tmp[0], tmp[1], tmp[2]) > (1.0 + EPS))) {
+
+ /*
+ * RGBi out of screen's gamut
+ */
+
+ if (ccc->gamutCompProc == NULL) {
+ /*
+ * Aha!! Here's that little trick that will allow
+ * gamut compression routines to get the out of bound
+ * RGBi.
+ */
+ memcpy((char *)&pColor->spec, (char *)tmp, sizeof(tmp));
+ pColor->format = XcmsRGBiFormat;
+ return(XcmsFailure);
+ } else if ((*ccc->gamutCompProc)(ccc, pXcmsColors_in_out, nColors,
+ i, pCompressed) == 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * The gamut compression function should return colors in CIEXYZ
+ * Also check again to if the new color is within gamut.
+ */
+ if (pColor->format != XcmsCIEXYZFormat) {
+ return(XcmsFailure);
+ }
+ _XcmsMatVec((XcmsFloat *) pScreenData->XYZtoRGBmatrix,
+ (XcmsFloat *) &pColor->spec, tmp);
+ if ((MIN3 (tmp[0], tmp[1], tmp[2]) < -EPS) ||
+ (MAX3 (tmp[0], tmp[1], tmp[2]) > (1.0 + EPS))) {
+ return(XcmsFailure);
+ }
+ hasCompressed++;
+ }
+ memcpy((char *)&pColor->spec, (char *)tmp, sizeof(tmp));
+ /* These if statements are done to ensure the fudge factor is */
+ /* is taken into account. */
+ if (pColor->spec.RGBi.red < 0.0) {
+ pColor->spec.RGBi.red = 0.0;
+ } else if (pColor->spec.RGBi.red > 1.0) {
+ pColor->spec.RGBi.red = 1.0;
+ }
+ if (pColor->spec.RGBi.green < 0.0) {
+ pColor->spec.RGBi.green = 0.0;
+ } else if (pColor->spec.RGBi.green > 1.0) {
+ pColor->spec.RGBi.green = 1.0;
+ }
+ if (pColor->spec.RGBi.blue < 0.0) {
+ pColor->spec.RGBi.blue = 0.0;
+ } else if (pColor->spec.RGBi.blue > 1.0) {
+ pColor->spec.RGBi.blue = 1.0;
+ }
+ (pColor++)->format = XcmsRGBiFormat;
+ }
+ return (hasCompressed ? XcmsSuccessWithCompression : XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * LINEAR_RGBi_to_CIEXYZ - convert RGBi to CIEXYZ
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsRGBiToCIEXYZ(ccc, pXcmsColors_in_out, nColors, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pXcmsColors_in_out;/* pointer to XcmsColors to convert */
+ unsigned int nColors; /* Number of colors */
+ Bool *pCompressed; /* pointer to a bit array */
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from RGBi format to CIEXYZ format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ */
+{
+ LINEAR_RGB_SCCData *pScreenData;
+ XcmsFloat tmp[3];
+
+ /*
+ * pCompressed ignored in this function.
+ */
+
+ if (ccc == NULL) {
+ return(XcmsFailure);
+ }
+
+ pScreenData = (LINEAR_RGB_SCCData *)ccc->pPerScrnInfo->screenData;
+
+ /*
+ * XcmsColors should be White Point Adjusted, if necessary, by now!
+ */
+
+ while (nColors--) {
+
+ /* Multiply [A]-1 * [XYZ] to get RGB intensity */
+ _XcmsMatVec((XcmsFloat *) pScreenData->RGBtoXYZmatrix,
+ (XcmsFloat *) &pXcmsColors_in_out->spec, tmp);
+
+ memcpy((char *)&pXcmsColors_in_out->spec, (char *)tmp, sizeof(tmp));
+ (pXcmsColors_in_out++)->format = XcmsCIEXYZFormat;
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsRGBiToRGB
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsRGBiToRGB(ccc, pXcmsColors_in_out, nColors, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pXcmsColors_in_out;/* pointer to XcmsColors to convert */
+ unsigned int nColors; /* Number of colors */
+ Bool *pCompressed; /* pointer to a bit array */
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from RGBi format to RGB format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression.
+ * XcmsSuccessWithCompression if succeeded with gamut
+ * compression.
+ */
+{
+ LINEAR_RGB_SCCData *pScreenData;
+ XcmsRGB tmpRGB;
+ IntensityRec keyIRec, answerIRec;
+
+ /*
+ * pCompressed ignored in this function.
+ */
+
+ if (ccc == NULL) {
+ return(XcmsFailure);
+ }
+
+ pScreenData = (LINEAR_RGB_SCCData *)ccc->pPerScrnInfo->screenData;
+
+ while (nColors--) {
+
+ /* Make sure format is XcmsRGBiFormat */
+ if (pXcmsColors_in_out->format != XcmsRGBiFormat) {
+ return(XcmsFailure);
+ }
+
+ keyIRec.intensity = pXcmsColors_in_out->spec.RGBi.red;
+ if (!_XcmsTableSearch((char *)&keyIRec, ccc->visual->bits_per_rgb,
+ (char *)pScreenData->pRedTbl->pBase,
+ (unsigned)pScreenData->pRedTbl->nEntries,
+ (unsigned)sizeof(IntensityRec),
+ (comparProcp)_XcmsIntensityCmp, (interpolProcp)_XcmsIntensityInterpolation, (char *)&answerIRec)) {
+ return(XcmsFailure);
+ }
+ tmpRGB.red = answerIRec.value;
+
+ keyIRec.intensity = pXcmsColors_in_out->spec.RGBi.green;
+ if (!_XcmsTableSearch((char *)&keyIRec, ccc->visual->bits_per_rgb,
+ (char *)pScreenData->pGreenTbl->pBase,
+ (unsigned)pScreenData->pGreenTbl->nEntries,
+ (unsigned)sizeof(IntensityRec),
+ (comparProcp)_XcmsIntensityCmp, (interpolProcp)_XcmsIntensityInterpolation, (char *)&answerIRec)) {
+ return(XcmsFailure);
+ }
+ tmpRGB.green = answerIRec.value;
+
+ keyIRec.intensity = pXcmsColors_in_out->spec.RGBi.blue;
+ if (!_XcmsTableSearch((char *)&keyIRec, ccc->visual->bits_per_rgb,
+ (char *)pScreenData->pBlueTbl->pBase,
+ (unsigned)pScreenData->pBlueTbl->nEntries,
+ (unsigned)sizeof(IntensityRec),
+ (comparProcp)_XcmsIntensityCmp, (interpolProcp)_XcmsIntensityInterpolation, (char *)&answerIRec)) {
+ return(XcmsFailure);
+ }
+ tmpRGB.blue = answerIRec.value;
+
+ memcpy((char *)&pXcmsColors_in_out->spec, (char *)&tmpRGB, sizeof(XcmsRGB));
+ (pXcmsColors_in_out++)->format = XcmsRGBFormat;
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsRGBToRGBi
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsRGBToRGBi(
+ XcmsCCC ccc,
+ XcmsColor *pXcmsColors_in_out,/* pointer to XcmsColors to convert */
+ unsigned int nColors, /* Number of colors */
+ Bool *pCompressed) /* pointer to a bit array */
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from RGB format to RGBi format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ */
+{
+ LINEAR_RGB_SCCData *pScreenData;
+ XcmsRGBi tmpRGBi;
+ IntensityRec keyIRec, answerIRec;
+
+ /*
+ * pCompressed ignored in this function.
+ */
+
+ if (ccc == NULL) {
+ return(XcmsFailure);
+ }
+
+ pScreenData = (LINEAR_RGB_SCCData *)ccc->pPerScrnInfo->screenData;
+
+ while (nColors--) {
+
+ /* Make sure format is XcmsRGBFormat */
+ if (pXcmsColors_in_out->format != XcmsRGBFormat) {
+ return(XcmsFailure);
+ }
+
+ keyIRec.value = pXcmsColors_in_out->spec.RGB.red;
+ if (!_XcmsTableSearch((char *)&keyIRec, ccc->visual->bits_per_rgb,
+ (char *)pScreenData->pRedTbl->pBase,
+ (unsigned)pScreenData->pRedTbl->nEntries,
+ (unsigned)sizeof(IntensityRec),
+ (comparProcp)_XcmsValueCmp, (interpolProcp)_XcmsValueInterpolation, (char *)&answerIRec)) {
+ return(XcmsFailure);
+ }
+ tmpRGBi.red = answerIRec.intensity;
+
+ keyIRec.value = pXcmsColors_in_out->spec.RGB.green;
+ if (!_XcmsTableSearch((char *)&keyIRec, ccc->visual->bits_per_rgb,
+ (char *)pScreenData->pGreenTbl->pBase,
+ (unsigned)pScreenData->pGreenTbl->nEntries,
+ (unsigned)sizeof(IntensityRec),
+ (comparProcp)_XcmsValueCmp, (interpolProcp)_XcmsValueInterpolation, (char *)&answerIRec)) {
+ return(XcmsFailure);
+ }
+ tmpRGBi.green = answerIRec.intensity;
+
+ keyIRec.value = pXcmsColors_in_out->spec.RGB.blue;
+ if (!_XcmsTableSearch((char *)&keyIRec, ccc->visual->bits_per_rgb,
+ (char *)pScreenData->pBlueTbl->pBase,
+ (unsigned)pScreenData->pBlueTbl->nEntries,
+ (unsigned)sizeof(IntensityRec),
+ (comparProcp)_XcmsValueCmp, (interpolProcp)_XcmsValueInterpolation, (char *)&answerIRec)) {
+ return(XcmsFailure);
+ }
+ tmpRGBi.blue = answerIRec.intensity;
+
+ memcpy((char *)&pXcmsColors_in_out->spec, (char *)&tmpRGBi, sizeof(XcmsRGBi));
+ (pXcmsColors_in_out++)->format = XcmsRGBiFormat;
+ }
+ return(XcmsSuccess);
+}
+
+/*
+ * NAME
+ * _XcmsInitScrnDefaultInfo
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+int
+_XcmsLRGB_InitScrnDefault(
+ Display *dpy,
+ int screenNumber,
+ XcmsPerScrnInfo *pPerScrnInfo)
+/*
+ * DESCRIPTION
+ * Given a display and screen number, this routine attempts
+ * to initialize the Xcms per Screen Info structure
+ * (XcmsPerScrnInfo) with defaults.
+ *
+ * RETURNS
+ * Returns zero if initialization failed; non-zero otherwise.
+ */
+{
+ pPerScrnInfo->screenData = (XPointer)&Default_RGB_SCCData;
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.X =
+ Default_RGB_SCCData.RGBtoXYZmatrix[0][0] +
+ Default_RGB_SCCData.RGBtoXYZmatrix[0][1] +
+ Default_RGB_SCCData.RGBtoXYZmatrix[0][2];
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y =
+ Default_RGB_SCCData.RGBtoXYZmatrix[1][0] +
+ Default_RGB_SCCData.RGBtoXYZmatrix[1][1] +
+ Default_RGB_SCCData.RGBtoXYZmatrix[1][2];
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Z =
+ Default_RGB_SCCData.RGBtoXYZmatrix[2][0] +
+ Default_RGB_SCCData.RGBtoXYZmatrix[2][1] +
+ Default_RGB_SCCData.RGBtoXYZmatrix[2][2];
+ if ((pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y < (1.0 - EPS) )
+ || (pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y > (1.0 + EPS))) {
+ pPerScrnInfo->screenData = (XPointer)NULL;
+ pPerScrnInfo->state = XcmsInitNone;
+ return(0);
+ }
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y = 1.0;
+ pPerScrnInfo->screenWhitePt.format = XcmsCIEXYZFormat;
+ pPerScrnInfo->screenWhitePt.pixel = 0;
+ pPerScrnInfo->functionSet = (XPointer)&XcmsLinearRGBFunctionSet;
+ pPerScrnInfo->state = XcmsInitFailure; /* default initialization */
+ return(1);
+}
diff --git a/nx-X11/lib/X11/Lab.c b/nx-X11/lib/X11/Lab.c
new file mode 100644
index 000000000..596c137f8
--- /dev/null
+++ b/nx-X11/lib/X11/Lab.c
@@ -0,0 +1,416 @@
+/* $Xorg: Lab.c,v 1.3 2000/08/17 19:44:39 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * CIELab.c
+ *
+ * DESCRIPTION
+ * This file contains routines that support the CIE L*a*b*
+ * color space to include conversions to and from the CIE
+ * XYZ space. These conversions are from Principles of
+ * Color Technology Second Edition, Fred W. Billmeyer, Jr.
+ * and Max Saltzman, John Wiley & Sons, Inc., 1981.
+ *
+ * Note that the range for L* is 0 to 1.
+ */
+/* $XFree86: xc/lib/X11/Lab.c,v 1.3 2001/01/17 19:41:38 dawes Exp $ */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <stdio.h> /* sscanf */
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+/*
+ * DEFINES
+ * Internal definitions that need NOT be exported to any package
+ * or program using this package.
+ */
+#ifdef DBL_EPSILON
+# define XMY_DBL_EPSILON DBL_EPSILON
+#else
+# define XMY_DBL_EPSILON 0.00001
+#endif
+#define DIV16BY116 0.137931
+
+/*
+ * FORWARD DECLARATIONS
+ */
+
+static int CIELab_ParseString(register char *spec, XcmsColor *pColor);
+static Status XcmsCIELab_ValidSpec(XcmsColor *pColor);
+
+
+/*
+ * LOCAL VARIABLES
+ */
+
+
+ /*
+ * NULL terminated list of functions applied to get from CIELab to CIEXYZ
+ */
+static XcmsConversionProc Fl_CIELab_to_CIEXYZ[] = {
+ XcmsCIELabToCIEXYZ,
+ NULL
+};
+
+ /*
+ * NULL terminated list of functions applied to get from CIEXYZ to CIELab
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_CIELab[] = {
+ XcmsCIEXYZToCIELab,
+ NULL
+};
+
+
+/*
+ * GLOBALS
+ */
+ /*
+ * CIE Lab Color Space
+ */
+XcmsColorSpace XcmsCIELabColorSpace =
+ {
+ _XcmsCIELab_prefix, /* prefix */
+ XcmsCIELabFormat, /* id */
+ CIELab_ParseString, /* parseString */
+ Fl_CIELab_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_CIELab, /* from_CIEXYZ */
+ 1
+ };
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CIELab_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+CIELab_ParseString(
+ register char *spec,
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsCIELabFormat.
+ * The assumed CIELab string syntax is:
+ * CIELab:<L>/<a>/<b>
+ * Where L, a, and b are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ * 0 if failed, non-zero otherwise.
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsCIELab_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.CIELab.L_star,
+ &pColor->spec.CIELab.a_star,
+ &pColor->spec.CIELab.b_star) != 3) {
+ return(XcmsFailure);
+ }
+ pColor->format = XcmsCIELabFormat;
+ pColor->pixel = 0;
+
+ return(XcmsCIELab_ValidSpec(pColor));
+}
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELab_ValidSpec
+ *
+ * SYNOPSIS
+ */
+static Status
+XcmsCIELab_ValidSpec(
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * Checks if color specification valid for CIE L*a*b*.
+ *
+ * RETURNS
+ * XcmsFailure if invalid,
+ * XcmsSuccess if valid.
+ *
+ */
+{
+ if (pColor->format != XcmsCIELabFormat
+ ||
+ (pColor->spec.CIELab.L_star < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIELab.L_star > 100.0 + XMY_DBL_EPSILON)) {
+ return(XcmsFailure);
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIELabToCIEXYZ - convert CIELab to CIEXYZ
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELabToCIEXYZ(ccc, pLab_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pLab_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIELab format to CIEXYZ format.
+ *
+ * WARNING: This routine assumes that Yn = 1.0;
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsCIEXYZ XYZ_return;
+ XcmsFloat tmpFloat, tmpL;
+ XcmsColor whitePt;
+ int i;
+ XcmsColor *pColor = pColors_in_out;
+
+ /*
+ * Check arguments
+ */
+ if (pLab_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Make sure white point is in CIEXYZ form, if not, convert it.
+ */
+ if (pLab_WhitePt->format != XcmsCIEXYZFormat) {
+ /* Make a copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pLab_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt,
+ (XcmsColor *)NULL, 1, XcmsCIEXYZFormat)) {
+ return(XcmsFailure);
+ }
+ pLab_WhitePt = &whitePt;
+ }
+
+ /*
+ * Make sure it is a white point, i.e., Y == 1.0
+ */
+ if (pLab_WhitePt->spec.CIEXYZ.Y != 1.0) {
+ return (0);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ /* Make sure original format is CIELab */
+ if (!XcmsCIELab_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ /* Calculate Y: assume that Yn = 1.0 */
+ tmpL = (pColor->spec.CIELab.L_star + 16.0) / 116.0;
+ XYZ_return.Y = tmpL * tmpL * tmpL;
+
+ if (XYZ_return.Y < 0.008856) {
+ /* Calculate Y: assume that Yn = 1.0 */
+ tmpL = pColor->spec.CIELab.L_star / 9.03292;
+
+ /* Calculate X */
+ XYZ_return.X = pLab_WhitePt->spec.CIEXYZ.X *
+ ((pColor->spec.CIELab.a_star / 3893.5) + tmpL);
+ /* Calculate Y */
+ XYZ_return.Y = tmpL;
+ /* Calculate Z */
+ XYZ_return.Z = pLab_WhitePt->spec.CIEXYZ.Z *
+ (tmpL - (pColor->spec.CIELab.b_star / 1557.4));
+ } else {
+ /* Calculate X */
+ tmpFloat = tmpL + (pColor->spec.CIELab.a_star / 5.0);
+ XYZ_return.X = pLab_WhitePt->spec.CIEXYZ.X * tmpFloat * tmpFloat * tmpFloat;
+
+ /* Calculate Z */
+ tmpFloat = tmpL - (pColor->spec.CIELab.b_star / 2.0);
+ XYZ_return.Z = pLab_WhitePt->spec.CIEXYZ.Z * tmpFloat * tmpFloat * tmpFloat;
+ }
+
+ memcpy((char *)&pColor->spec.CIEXYZ, (char *)&XYZ_return,
+ sizeof(XcmsCIEXYZ));
+ pColor->format = XcmsCIEXYZFormat;
+ }
+
+ return (1);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEXYZToCIELab - convert CIEXYZ to CIELab
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIEXYZToCIELab(ccc, pLab_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pLab_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIEXYZ format to CIELab format.
+ *
+ * WARNING: This routine assumes that Yn = 1.0;
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsCIELab Lab_return;
+ XcmsFloat fX_Xn, fY_Yn, fZ_Zn;
+ XcmsColor whitePt;
+ int i;
+ XcmsColor *pColor = pColors_in_out;
+
+ /*
+ * Check arguments
+ */
+ if (pLab_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Make sure white point is in CIEXYZ form, if not, convert it.
+ */
+ if (pLab_WhitePt->format != XcmsCIEXYZFormat) {
+ /* Make a copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pLab_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL,
+ 1, XcmsCIEXYZFormat)) {
+ return(XcmsFailure);
+ }
+ pLab_WhitePt = &whitePt;
+ }
+
+ /*
+ * Make sure it is a white point, i.e., Y == 1.0
+ */
+ if (pLab_WhitePt->spec.CIEXYZ.Y != 1.0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ /* Make sure original format is CIELab */
+ if (!_XcmsCIEXYZ_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ /* Calculate L*: assume Yn = 1.0 */
+ if (pColor->spec.CIEXYZ.Y < 0.008856) {
+ fY_Yn = (0.07787 * pColor->spec.CIEXYZ.Y) + DIV16BY116;
+ /* note fY_Yn used to compute Lab_return.a below */
+ Lab_return.L_star = 116.0 * (fY_Yn - DIV16BY116);
+ } else {
+ fY_Yn = (XcmsFloat)XCMS_CUBEROOT(pColor->spec.CIEXYZ.Y);
+ /* note fY_Yn used to compute Lab_return.a_star below */
+ Lab_return.L_star = (116.0 * fY_Yn) - 16.0;
+ }
+
+ /* Calculate f(X/Xn) */
+ if ((fX_Xn = pColor->spec.CIEXYZ.X / pLab_WhitePt->spec.CIEXYZ.X) < 0.008856) {
+ fX_Xn = (0.07787 * fX_Xn) + DIV16BY116;
+ } else {
+ fX_Xn = (XcmsFloat) XCMS_CUBEROOT(fX_Xn);
+ }
+
+ /* Calculate f(Z/Zn) */
+ if ((fZ_Zn = pColor->spec.CIEXYZ.Z / pLab_WhitePt->spec.CIEXYZ.Z) < 0.008856) {
+ fZ_Zn = (0.07787 * fZ_Zn) + DIV16BY116;
+ } else {
+ fZ_Zn = (XcmsFloat) XCMS_CUBEROOT(fZ_Zn);
+ }
+
+ Lab_return.a_star = 5.0 * (fX_Xn - fY_Yn);
+ Lab_return.b_star = 2.0 * (fY_Yn - fZ_Zn);
+
+ memcpy((char *)&pColor->spec.CIELab, (char *)&Lab_return,
+ sizeof(XcmsCIELab));
+ pColor->format = XcmsCIELabFormat;
+ }
+
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/LabGcC.c b/nx-X11/lib/X11/LabGcC.c
new file mode 100644
index 000000000..e210cd235
--- /dev/null
+++ b/nx-X11/lib/X11/LabGcC.c
@@ -0,0 +1,129 @@
+/* $Xorg: LabGcC.c,v 1.3 2000/08/17 19:44:39 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELabGcC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsCIELabClipuv() gamut compression routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/LabGcC.c,v 1.3 2001/01/17 19:41:38 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabClipab - Reduce the chroma for a hue and L*
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIELabClipab (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Reduce the Chroma for a specific hue and chroma to
+ * to bring the given color into the gamut of the
+ * specified device. As required of gamut compression
+ * functions, this routine returns pColor_in_out
+ * in XcmsCIEXYZFormat on successful completion.
+ *
+ * Since this routine works with the L* within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ Status retval;
+ XcmsColor *pColor;
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < PseudoColor) {
+ /*
+ * GRAY !
+ */
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIELabFormat);
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIEXYZFormat);
+ if (pCompressed) {
+ *(pCompressed + i) = True;
+ }
+ return(XcmsSuccess);
+ } else {
+ if (pColor->format != XcmsCIELabFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIELabFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsCIELabQueryMaxC(ccc,
+ degrees(XCMS_CIELAB_PMETRIC_HUE(pColor->spec.CIELab.a_star,
+ pColor->spec.CIELab.b_star)),
+ pColor->spec.CIELab.L_star,
+ pColor) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/nx-X11/lib/X11/LabGcL.c b/nx-X11/lib/X11/LabGcL.c
new file mode 100644
index 000000000..445e4da59
--- /dev/null
+++ b/nx-X11/lib/X11/LabGcL.c
@@ -0,0 +1,176 @@
+/* $Xorg: LabGcL.c,v 1.3 2000/08/17 19:44:39 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELabGcL.c
+ *
+ * DESCRIPTION
+ * Source for XcmsCIELabClipL() gamut compression routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/LabGcL.c,v 1.3 2001/01/17 19:41:38 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabClipL - Return the closest L*
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIELabClipL (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Return the closest L* for a specific hue and chroma.
+ * This routine takes any color as input and outputs
+ * a CIE XYZ color.
+ *
+ * Since this routine works with the L* within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor *pColor;
+ XcmsColor Lab_max;
+ XcmsFloat hue, chroma, maxChroma;
+ Status retval;
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* Inherit Screen WP */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut compression */
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor) {
+ /*
+ * GRAY !
+ */
+ return(XcmsFailure);
+ } else {
+ /* Convert from CIEXYZ to CIE L*u*v* format */
+ if (_XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ hue = XCMS_CIELAB_PMETRIC_HUE(pColor->spec.CIELab.a_star,
+ pColor->spec.CIELab.b_star);
+ chroma = XCMS_CIELAB_PMETRIC_CHROMA(pColor->spec.CIELab.a_star,
+ pColor->spec.CIELab.b_star);
+ /* Step 1: compute the maximum L* and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ memcpy((char *)&Lab_max, (char *)pColor, sizeof(XcmsColor));
+ if (_XcmsCIELabQueryMaxLCRGB (&myCCC, hue, &Lab_max,
+ (XcmsRGBi *)NULL) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ maxChroma = XCMS_CIELAB_PMETRIC_CHROMA(Lab_max.spec.CIELab.a_star,
+ Lab_max.spec.CIELab.b_star);
+
+ /* Now check and return the appropriate L* */
+ if (chroma == maxChroma) {
+ /* When the chroma input is equal to the maximum chroma */
+ /* merely return the L* for that chroma. */
+ memcpy((char *)pColor, (char *)&Lab_max, sizeof(XcmsColor));
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ } else if (chroma > maxChroma) {
+ /* When the chroma input is greater than the maximum chroma */
+ /* merely return the L* and chroma for the given hue. */
+ memcpy((char *)pColor, (char *)&Lab_max, sizeof(XcmsColor));
+ return (XcmsFailure);
+ } else if (pColor->spec.CIELab.L_star < Lab_max.spec.CIELab.L_star) {
+ /* Find the minimum lightness for the given chroma. */
+ if (pColor->format != XcmsCIELabFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ ScreenWhitePointOfCCC(ccc), 1, XcmsCIELabFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsCIELabQueryMinL(&myCCC, degrees(hue), chroma, pColor)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ } else {
+ /* Find the maximum lightness for the given chroma. */
+ if (pColor->format != XcmsCIELabFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ ScreenWhitePointOfCCC(ccc), 1, XcmsCIELabFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsCIELabQueryMaxL(&myCCC, degrees(hue), chroma, pColor)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ }
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/nx-X11/lib/X11/LabGcLC.c b/nx-X11/lib/X11/LabGcLC.c
new file mode 100644
index 000000000..f0726d936
--- /dev/null
+++ b/nx-X11/lib/X11/LabGcLC.c
@@ -0,0 +1,225 @@
+/* $Xorg: LabGcLC.c,v 1.3 2000/08/17 19:44:39 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELabGcLC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsCIELabClipLab() gamut
+ * compression function.
+ */
+/* $XFree86: xc/lib/X11/LabGcLC.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+#include "Cv.h"
+
+/*
+ * INTERNALS
+ * Internal defines that need NOT be exported to any package or
+ * program using this package.
+ */
+#define MAXBISECTCOUNT 100
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabClipLab - Return the closest L* and chroma
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIELabClipLab (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * This routine will find the closest L* and chroma
+ * for a specific hue. The color input is converted to
+ * CIE L*u*v* format and returned as CIE XYZ format.
+ *
+ * Since this routine works with the L* within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ Status retval;
+ XcmsCCCRec myCCC;
+ XcmsColor *pColor;
+ XcmsColor Lab_max;
+ XcmsFloat hue, chroma, maxChroma;
+ XcmsFloat Chroma, bestChroma, Lstar, maxLstar, saveLstar;
+ XcmsFloat bestLstar, bestastar, bestbstar;
+ XcmsFloat nT, saveDist, tmpDist;
+ XcmsRGBi rgb_max;
+ int nCount, nMaxCount, nI, nILast;
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* inherit screen white */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut compression func */
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor) {
+ /*
+ * GRAY !
+ */
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIELabFormat);
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIEXYZFormat);
+ if (pCompressed) {
+ *(pCompressed + i) = True;
+ }
+ return(XcmsSuccess);
+ }
+
+ /* Convert from CIEXYZ to CIELab format */
+ if (_XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum L* and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ saveLstar = pColor->spec.CIELab.L_star;
+ hue = XCMS_CIELAB_PMETRIC_HUE(pColor->spec.CIELab.a_star,
+ pColor->spec.CIELab.b_star);
+ chroma = XCMS_CIELAB_PMETRIC_CHROMA(pColor->spec.CIELab.a_star,
+ pColor->spec.CIELab.b_star);
+ memcpy((char *)&Lab_max, (char *)pColor, sizeof(XcmsColor));
+ if (_XcmsCIELabQueryMaxLCRGB (&myCCC, hue, &Lab_max, &rgb_max)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ maxLstar = Lab_max.spec.CIELab.L_star;
+
+ /* Now check and return the appropriate L* */
+ if (saveLstar == maxLstar) {
+ /* When the L* input is equal to the maximum L* */
+ /* merely return the maximum Lab point. */
+ memcpy((char *)pColor, (char *)&Lab_max, sizeof(XcmsColor));
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ } else {
+ /* return the closest point on the hue leaf. */
+ /* must do a bisection here to compute the delta e. */
+ maxChroma = XCMS_CIELAB_PMETRIC_CHROMA(Lab_max.spec.CIELab.a_star,
+ Lab_max.spec.CIELab.b_star);
+ nMaxCount = MAXBISECTCOUNT;
+ nI = nMaxCount / 2;
+ bestLstar = Lstar = pColor->spec.CIELab.L_star;
+ bestastar = pColor->spec.CIELab.a_star;
+ bestbstar = pColor->spec.CIELab.b_star;
+ bestChroma = Chroma = chroma;
+ saveDist = XCMS_SQRT(((Chroma - maxChroma) * (Chroma - maxChroma)) +
+ ((Lstar - maxLstar) * (Lstar - maxLstar)));
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ nT = (XcmsFloat) nI / (XcmsFloat) nMaxCount;
+ if (saveLstar > maxLstar) {
+ pColor->spec.RGBi.red = rgb_max.red * (1.0 - nT) + nT;
+ pColor->spec.RGBi.green = rgb_max.green * (1.0 - nT) + nT;
+ pColor->spec.RGBi.blue = rgb_max.blue * (1.0 - nT) + nT;
+ } else {
+ pColor->spec.RGBi.red = rgb_max.red - (rgb_max.red * nT);
+ pColor->spec.RGBi.green = rgb_max.green - (rgb_max.green * nT);
+ pColor->spec.RGBi.blue = rgb_max.blue - (rgb_max.blue * nT);
+ }
+ pColor->format = XcmsRGBiFormat;
+
+ /* Convert from RGBi to CIE Lab */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ chroma = XCMS_CIELAB_PMETRIC_CHROMA(pColor->spec.CIELab.a_star,
+ pColor->spec.CIELab.b_star);
+ tmpDist = XCMS_SQRT(((Chroma - chroma) * (Chroma - chroma)) +
+ ((Lstar - pColor->spec.CIELab.L_star) *
+ (Lstar - pColor->spec.CIELab.L_star)));
+ nILast = nI;
+ if (tmpDist > saveDist) {
+ nI /= 2;
+ } else {
+ nI = (nMaxCount + nI) / 2;
+ saveDist = tmpDist;
+ bestLstar = pColor->spec.CIELab.L_star;
+ bestastar = pColor->spec.CIELab.a_star;
+ bestbstar = pColor->spec.CIELab.b_star;
+ bestChroma = chroma;
+ }
+ if (nI == nILast || nI == 0) {
+ break;
+ }
+ }
+ if (bestChroma >= maxChroma) {
+ pColor->spec.CIELab.L_star = maxLstar;
+ pColor->spec.CIELab.a_star = Lab_max.spec.CIELab.a_star;
+ pColor->spec.CIELab.b_star = Lab_max.spec.CIELab.b_star;
+ } else {
+ pColor->spec.CIELab.L_star = bestLstar;
+ pColor->spec.CIELab.a_star = bestastar;
+ pColor->spec.CIELab.b_star = bestbstar;
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ }
+ return(retval);
+}
diff --git a/nx-X11/lib/X11/LabMnL.c b/nx-X11/lib/X11/LabMnL.c
new file mode 100644
index 000000000..8016c4e6a
--- /dev/null
+++ b/nx-X11/lib/X11/LabMnL.c
@@ -0,0 +1,218 @@
+/* $Xorg: LabMnL.c,v 1.3 2000/08/17 19:44:39 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELabMnL.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELabQueryMinL() gamut boundary
+ * querying routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/LabMnL.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS (XcmsFloat)0.001
+#define START_L_STAR (XcmsFloat)40.0
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabQueryMinL - Compute max Lstar for a hue and chroma
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELabQueryMinL(ccc, hue_angle, chroma, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue angle in degrees */
+ XcmsFloat chroma;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum Lstar for a specified hue_angle and chroma.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded with no modifications
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor max_lc, tmp, prev;
+ XcmsFloat max_chroma, tmp_chroma;
+ XcmsFloat hue, nT, nChroma, lastChroma, prevChroma;
+ XcmsFloat rFactor;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* setup the CCC to use for the conversions. */
+ memcpy ((char *) &myCCC, (char *) ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc) NULL;
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ hue = radians(hue_angle);
+ tmp.spec.CIELab.L_star = START_L_STAR;
+ tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, chroma);
+ tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, chroma);
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsCIELabFormat;
+
+ /* Step 1: Obtain the maximum L_star and chroma for this hue. */
+ if (_XcmsCIELabQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ max_chroma = XCMS_CIELAB_PMETRIC_CHROMA(max_lc.spec.CIELab.a_star,
+ max_lc.spec.CIELab.b_star);
+
+ if (max_chroma <= chroma) {
+ /*
+ * If the chroma is greater than the chroma for the
+ * maximum L/chroma point then the L_star is the
+ * the L_star for the maximum L_star/chroma point.
+ * This is an error but I return the best approximation I can.
+ * Thus the inconsistency.
+ */
+ memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+
+ /*
+ * If the chroma is equal to the chroma for the
+ * maximum L_star/chroma point then the L_star is the
+ * the L_star for the maximum L* and chroma point.
+ */
+ /* if (max_chroma == chroma) {
+ * memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ * return(XcmsSuccess);
+ * }
+ */
+
+ /* must do a bisection here to compute the maximum L* */
+ /* save the structure input so that any elements that */
+ /* are not touched are recopied later in the routine. */
+ nChroma = chroma;
+ tmp_chroma = max_chroma;
+ lastChroma = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prevChroma = lastChroma;
+ lastChroma = tmp_chroma;
+ nT = (nChroma - max_chroma) / max_chroma * rFactor;
+ memcpy ((char *)&prev, (char *)&tmp, sizeof(XcmsColor));
+ tmp.spec.RGBi.red = rgb_saved.red + (rgb_saved.red * nT);
+ tmp.spec.RGBi.green = rgb_saved.green + (rgb_saved.green * nT);
+ tmp.spec.RGBi.blue = rgb_saved.blue + (rgb_saved.blue * nT);
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to CIELab */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Now check the return against what is expected */
+ tmp_chroma = XCMS_CIELAB_PMETRIC_CHROMA(tmp.spec.CIELab.a_star,
+ tmp.spec.CIELab.b_star);
+ if (tmp_chroma <= chroma + EPS && tmp_chroma >= chroma - EPS) {
+ /* Found It! */
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+ nChroma += chroma - tmp_chroma;
+ if (nChroma > max_chroma) {
+ nChroma = max_chroma;
+ rFactor *= 0.5; /* selective relaxation employed */
+ } else if (nChroma < 0.0) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ return(XcmsSuccess);
+ } else if (tmp_chroma <= prevChroma + EPS &&
+ tmp_chroma >= prevChroma - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ }
+ }
+
+ if (nCount >= nMaxCount) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ }
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/LabMxC.c b/nx-X11/lib/X11/LabMxC.c
new file mode 100644
index 000000000..c57125b33
--- /dev/null
+++ b/nx-X11/lib/X11/LabMxC.c
@@ -0,0 +1,205 @@
+/* $Xorg: LabMxC.c,v 1.3 2000/08/17 19:44:40 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * CIELabMxC.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELabQueryMaxC() gamut boundary
+ * querying routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/LabMxC.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS (XcmsFloat)0.001
+#define START_CHROMA (XcmsFloat)3.6
+#define TOPL (XcmsFloat)100.0
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabQueryMaxC - max chroma for a hue_angle and L_star
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELabQueryMaxC(ccc, hue_angle, L_star, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue angle in degrees */
+ XcmsFloat L_star;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum chroma for a specific hue_angle and L_star.
+ * The returned format is in XcmsCIELabFormat.
+ *
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor tmp;
+ XcmsColor max_lc;
+ XcmsFloat n_L_star, last_L_star, prev_L_star;
+ XcmsFloat hue, lastaStar, lastbStar, /*lastChroma,*/ maxDist, nT, rFactor;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC and inherit screen white Pt */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut comp func */
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ hue = radians(hue_angle);
+ tmp.spec.CIELab.L_star = L_star;
+ tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, START_CHROMA);
+ tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, START_CHROMA);
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsCIELabFormat;
+
+ /* Step 1: compute the maximum L_star and chroma for this hue. */
+ memcpy((char *)&max_lc, (char *)&tmp, sizeof(XcmsColor));
+ if (_XcmsCIELabQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Step 2: Do a bisection here to compute the maximum chroma
+ * Note the differences between when the point to be found
+ * is above the maximum LC point and when it is below.
+ */
+ if (L_star <= max_lc.spec.CIELab.L_star) {
+ maxDist = max_lc.spec.CIELab.L_star;
+ } else {
+ maxDist = TOPL - max_lc.spec.CIELab.L_star;
+ }
+
+ n_L_star = L_star;
+ last_L_star = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prev_L_star = last_L_star;
+ last_L_star = tmp.spec.CIELab.L_star;
+/* lastChroma = XCMS_CIELAB_PMETRIC_CHROMA(tmp.spec.CIELab.a_star, */
+/* tmp.spec.CIELab.b_star); */
+ lastaStar = tmp.spec.CIELab.a_star;
+ lastbStar = tmp.spec.CIELab.b_star;
+ nT = (n_L_star - max_lc.spec.CIELab.L_star) / maxDist * rFactor;
+ if (nT > 0) {
+ tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ } else {
+ tmp.spec.RGBi.red = rgb_saved.red + (rgb_saved.red * nT);
+ tmp.spec.RGBi.green = rgb_saved.green + (rgb_saved.green * nT);
+ tmp.spec.RGBi.blue = rgb_saved.blue + (rgb_saved.blue * nT);
+ }
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to CIELab */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now check if we've reached the target L_star
+ */
+ /* printf("result Lstar = %lf\n", tmp.spec.CIELab.L_star); */
+ if (tmp.spec.CIELab.L_star <= L_star + EPS &&
+ tmp.spec.CIELab.L_star >= L_star - EPS) {
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+ }
+ if (nT > 0) {
+ n_L_star += ((TOPL - n_L_star) *
+ (L_star - tmp.spec.CIELab.L_star)) / (TOPL - L_star);
+ } else {
+ n_L_star *= L_star / tmp.spec.CIELuv.L_star;
+ }
+ if (tmp.spec.CIELab.L_star <= prev_L_star + EPS &&
+ tmp.spec.CIELab.L_star >= prev_L_star - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ /* printf("rFactor = %lf\n", rFactor); */
+ }
+ }
+ if (XCMS_FABS(last_L_star - L_star) <
+ XCMS_FABS(tmp.spec.CIELab.L_star - L_star)) {
+ tmp.spec.CIELab.a_star = lastaStar;
+ tmp.spec.CIELab.b_star = lastbStar;
+/* tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, lastChroma); */
+/* tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, lastChroma); */
+ }
+ tmp.spec.CIELab.L_star = L_star;
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/LabMxL.c b/nx-X11/lib/X11/LabMxL.c
new file mode 100644
index 000000000..91b3f559c
--- /dev/null
+++ b/nx-X11/lib/X11/LabMxL.c
@@ -0,0 +1,218 @@
+/* $Xorg: LabMxL.c,v 1.3 2000/08/17 19:44:40 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELabMxL.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELabQueryMaxL() gamut boundary
+ * querying routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/LabMxL.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS (XcmsFloat)0.001
+#define START_L_STAR (XcmsFloat)40
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabQueryMaxL - Compute max Lstar for a hue and chroma
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELabQueryMaxL(ccc, hue_angle, chroma, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue in degrees */
+ XcmsFloat chroma;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum Lstar for a specified hue_angle and chroma.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded with no modifications
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor max_lc, tmp, prev;
+ XcmsFloat max_chroma, tmp_chroma;
+ XcmsFloat hue, nT, nChroma, lastChroma, prevChroma;
+ XcmsFloat rFactor;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* setup the CCC to use for the conversions. */
+ memcpy ((char *) &myCCC, (char *) ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc) NULL;
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ hue = radians(hue_angle);
+ tmp.spec.CIELab.L_star = START_L_STAR;
+ tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, chroma);
+ tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, chroma);
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsCIELabFormat;
+
+ /* Step 1: Obtain the maximum L_star and chroma for this hue. */
+ if (_XcmsCIELabQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ max_chroma = XCMS_CIELAB_PMETRIC_CHROMA(max_lc.spec.CIELab.a_star,
+ max_lc.spec.CIELab.b_star);
+
+ if (max_chroma <= chroma) {
+ /*
+ * If the chroma is greater than the chroma for the
+ * maximum L/chroma point then the L_star is the
+ * the L_star for the maximum L_star/chroma point.
+ * This is an error but I return the best approximation I can.
+ * Thus the inconsistency.
+ */
+ memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+
+ /*
+ * If the chroma is equal to the chroma for the
+ * maximum L_star/chroma point then the L_star is the
+ * the L_star for the maximum L* and chroma point.
+ */
+ /* if (max_chroma == chroma) {
+ * memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ * return(XcmsSuccess);
+ * }
+ */
+
+ /* must do a bisection here to compute the maximum L* */
+ /* save the structure input so that any elements that */
+ /* are not touched are recopied later in the routine. */
+ nChroma = chroma;
+ tmp_chroma = max_chroma;
+ lastChroma = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prevChroma = lastChroma;
+ lastChroma = tmp_chroma;
+ nT = (1.0 - (nChroma / max_chroma)) * rFactor;
+ memcpy ((char *)&prev, (char *)&tmp, sizeof(XcmsColor));
+ tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to CIELab */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Now check the return against what is expected */
+ tmp_chroma = XCMS_CIELAB_PMETRIC_CHROMA(tmp.spec.CIELab.a_star,
+ tmp.spec.CIELab.b_star);
+ if (tmp_chroma <= chroma + EPS && tmp_chroma >= chroma - EPS) {
+ /* Found It! */
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+ nChroma += chroma - tmp_chroma;
+ if (nChroma > max_chroma) {
+ nChroma = max_chroma;
+ rFactor *= 0.5; /* selective relaxation employed */
+ } else if (nChroma < 0.0) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ return(XcmsSuccess);
+ } else if (tmp_chroma <= prevChroma + EPS &&
+ tmp_chroma >= prevChroma - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ }
+ }
+
+ if (nCount >= nMaxCount) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ }
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/LabMxLC.c b/nx-X11/lib/X11/LabMxLC.c
new file mode 100644
index 000000000..d4efba34c
--- /dev/null
+++ b/nx-X11/lib/X11/LabMxLC.c
@@ -0,0 +1,220 @@
+/* $Xorg: LabMxLC.c,v 1.3 2000/08/17 19:44:40 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * CIELabMxVC.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELabQueryMaxLC() gamut boundary
+ * querying routine.
+ *
+ * DOCUMENTATION
+ * "TekColor Color Management System, System Implementor's Manual"
+ * and
+ * Fred W. Billmeyer & Max Saltzman, "Principles of Color
+ * Technology", John Wily & Sons, Inc, 1981.
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define MIN(x,y) ((x) > (y) ? (y) : (x))
+#define MIN3(x,y,z) ((x) > (MIN((y), (z))) ? (MIN((y), (z))) : (x))
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+#define MAX3(x,y,z) ((x) > (MAX((y), (z))) ? (x) : (MAX((y), (z))))
+#define START_LSTAR (XcmsFloat)40.0
+#define START_CHROMA (XcmsFloat)3.6
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsCIELabQueryMaxLCRGB - Compute maximum L* and chroma.
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsCIELabQueryMaxLCRGB(
+ XcmsCCC ccc,
+ XcmsFloat hue, /* hue in radians */
+ XcmsColor *pColor_return,
+ XcmsRGBi *pRGB_return)
+/*
+ * DESCRIPTION
+ * Return the maximum psychometric chroma for a specified
+ * hue, and the corresponding L*. This is computed
+ * by a binary search of all possible chromas. An assumption
+ * is made that there are no local maxima. Use the unrounded
+ * Max psychometric chroma because the difference check can be
+ * small.
+ *
+ * NOTE: No local CCC is used because this is a private
+ * routine and all routines that call it are expected
+ * to behave properly, i.e. send a local CCC with
+ * no white adjust function and no gamut compression
+ * function.
+ *
+ * This routine only accepts hue in radians as input and outputs
+ * Lab and RGBi.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsFloat nSmall, nLarge;
+ XcmsColor tmp;
+
+ tmp.format = XcmsCIELabFormat;
+ /* Use some unreachable color on the given hue */
+ tmp.spec.CIELab.L_star = START_LSTAR;
+ tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, START_CHROMA);
+ tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, START_CHROMA);
+ /*
+ * Convert from Lab to RGB
+ *
+ * Note that the CIEXYZ to RGBi conversion routine must stuff the
+ * out of bounds RGBi values in tmp when the ccc->gamutCompProc
+ * is NULL.
+ */
+ if ((_XcmsConvertColorsWithWhitePt(ccc, &tmp, ScreenWhitePointOfCCC(ccc),
+ (unsigned int)1, XcmsRGBiFormat, (Bool *) NULL)
+ == XcmsFailure) && tmp.format != XcmsRGBiFormat) {
+ return (XcmsFailure);
+ }
+
+ /* Now pick the smallest RGB */
+ nSmall = MIN3(tmp.spec.RGBi.red,
+ tmp.spec.RGBi.green,
+ tmp.spec.RGBi.blue);
+ /* Make the smallest RGB equal to zero */
+ tmp.spec.RGBi.red -= nSmall;
+ tmp.spec.RGBi.green -= nSmall;
+ tmp.spec.RGBi.blue -= nSmall;
+
+ /* Now pick the largest RGB */
+ nLarge = MAX3(tmp.spec.RGBi.red,
+ tmp.spec.RGBi.green,
+ tmp.spec.RGBi.blue);
+ /* Scale the RGB values based on the largest one */
+ tmp.spec.RGBi.red /= nLarge;
+ tmp.spec.RGBi.green /= nLarge;
+ tmp.spec.RGBi.blue /= nLarge;
+ tmp.format = XcmsRGBiFormat;
+
+ /* If the calling routine wants RGB value give them the ones used. */
+ if (pRGB_return) {
+ pRGB_return->red = tmp.spec.RGBi.red;
+ pRGB_return->green = tmp.spec.RGBi.green;
+ pRGB_return->blue = tmp.spec.RGBi.blue;
+ }
+
+ /* Convert from RGBi to Lab */
+ if (_XcmsConvertColorsWithWhitePt(ccc, &tmp,
+ ScreenWhitePointOfCCC(ccc), 1, XcmsCIELabFormat, (Bool *) NULL)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return (XcmsSuccess);
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabQueryMaxLC - Compute maximum L* and chroma.
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELabQueryMaxLC (ccc, hue_angle, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue_angle in degrees */
+ XcmsColor *pColor_return;
+
+/*
+ * DESCRIPTION
+ * Return the point of maximum chroma for the specified
+ * hue_angle.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ return(_XcmsCIELabQueryMaxLCRGB (&myCCC, radians(hue_angle), pColor_return,
+ (XcmsRGBi *)NULL));
+}
diff --git a/nx-X11/lib/X11/LabWpAj.c b/nx-X11/lib/X11/LabWpAj.c
new file mode 100644
index 000000000..38c57d260
--- /dev/null
+++ b/nx-X11/lib/X11/LabWpAj.c
@@ -0,0 +1,100 @@
+/* $Xorg: LabWpAj.c,v 1.3 2000/08/17 19:44:40 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * CIELabWpAj.c
+ *
+ * DESCRIPTION
+ * This file contains routine(s) that support white point
+ * adjustment of color specifications in the CIE L*a*b* color
+ * space.
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+/*
+ * EXTERNS
+ */
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabWhiteShiftColors
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELabWhiteShiftColors(ccc, pWhitePtFrom, pWhitePtTo, destSpecFmt,
+ pColors_in_out, nColors, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pWhitePtFrom;
+ XcmsColor *pWhitePtTo;
+ XcmsColorFormat destSpecFmt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Adjust color specifications in XcmsColor structures for
+ * differences in white points.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression,
+ * XcmsSuccessWithCompression if succeeded with gamut
+ * compression.
+ */
+{
+ if (pWhitePtFrom == NULL || pWhitePtTo == NULL || pColors_in_out == NULL) {
+ return(0);
+ }
+
+ /*
+ * Convert to CIELab using pWhitePtFrom
+ */
+ if (_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out, pWhitePtFrom,
+ nColors, XcmsCIELabFormat, pCompressed) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Convert from CIELab to destSpecFmt using pWhitePtTo
+ */
+ return(_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out,
+ pWhitePtTo, nColors, destSpecFmt, pCompressed));
+}
diff --git a/nx-X11/lib/X11/LiHosts.c b/nx-X11/lib/X11/LiHosts.c
new file mode 100644
index 000000000..01cfadb13
--- /dev/null
+++ b/nx-X11/lib/X11/LiHosts.c
@@ -0,0 +1,140 @@
+/* $Xorg: LiHosts.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/* $XdotOrg: xc/lib/X11/LiHosts.c,v 1.4 2005/07/03 07:00:55 daniels Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+Copyright 2004 Sun Microsystems, Inc.
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+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
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of The Open Group.
+
+*/
+
+/* This can really be considered an os dependent routine */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+/*
+ * can be freed using XFree.
+ */
+
+XHostAddress *XListHosts (
+ 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;
+ XServerInterpretedAddress *sip;
+
+ *nhosts = 0;
+ LockDisplay(dpy);
+ GetReq (ListHosts, req);
+
+ if (!_XReply (dpy, (xReply *) &reply, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XHostAddress *) NULL;
+ }
+
+ if (reply.nHosts) {
+ unsigned int l;
+ nbytes = reply.length << 2; /* compute number of bytes in reply */
+ l = (unsigned) (nbytes +
+ (reply.nHosts * sizeof(XHostAddress)) +
+ (reply.nHosts * sizeof(XServerInterpretedAddress)));
+ op = outbuf = (XHostAddress *)
+ Xmalloc((unsigned) (nbytes +
+ (reply.nHosts * sizeof(XHostAddress)) +
+ (reply.nHosts * sizeof(XServerInterpretedAddress))));
+
+ if (! outbuf) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XHostAddress *) NULL;
+ }
+ sip = (XServerInterpretedAddress *)
+ (((unsigned char *) outbuf) + (reply.nHosts * sizeof(XHostAddress)));
+ bp = buf = ((unsigned char *) sip)
+ + (reply.nHosts * sizeof(XServerInterpretedAddress));
+
+ _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
+ if (op->family == FamilyServerInterpreted) {
+ char *tp = (char *) (bp + SIZEOF(xHostEntry));
+ char *vp = memchr(tp, 0, op->length);
+
+ if (vp != NULL) {
+ sip->type = tp;
+ sip->typelength = vp - tp;
+ sip->value = vp + 1;
+ sip->valuelength = op->length - (sip->typelength + 1);
+ } else {
+ sip->type = sip->value = NULL;
+ sip->typelength = sip->valuelength = 0;
+ }
+ op->address = (char *) sip;
+ sip++;
+ } else {
+ 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/nx-X11/lib/X11/LiICmaps.c b/nx-X11/lib/X11/LiICmaps.c
new file mode 100644
index 000000000..c36fe55a6
--- /dev/null
+++ b/nx-X11/lib/X11/LiICmaps.c
@@ -0,0 +1,74 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/LiICmaps.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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, (long *) cmaps, nbytes);
+ }
+ else cmaps = (Colormap *) NULL;
+
+ *n = rep.nColormaps;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(cmaps);
+}
+
diff --git a/nx-X11/lib/X11/LiProps.c b/nx-X11/lib/X11/LiProps.c
new file mode 100644
index 000000000..5e3aba8c0
--- /dev/null
+++ b/nx-X11/lib/X11/LiProps.c
@@ -0,0 +1,72 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/LiProps.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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, (long *) properties, nbytes);
+ }
+ else properties = (Atom *) NULL;
+
+ *n_props = rep.nProperties;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (properties);
+}
diff --git a/nx-X11/lib/X11/ListExt.c b/nx-X11/lib/X11/ListExt.c
new file mode 100644
index 000000000..1140082e5
--- /dev/null
+++ b/nx-X11/lib/X11/ListExt.c
@@ -0,0 +1,101 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/ListExt.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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);
+}
+
+int
+XFreeExtensionList (list)
+char **list;
+{
+ if (list != NULL) {
+ Xfree (list[0]-1);
+ Xfree ((char *)list);
+ }
+ return 1;
+}
diff --git a/nx-X11/lib/X11/LoadFont.c b/nx-X11/lib/X11/LoadFont.c
new file mode 100644
index 000000000..de5f5cee4
--- /dev/null
+++ b/nx-X11/lib/X11/LoadFont.c
@@ -0,0 +1,57 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/LoadFont.c,v 1.4 2001/12/14 19:54:02 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+Font
+XLoadFont (
+ register Display *dpy,
+ _Xconst char *name)
+{
+ register long nbytes;
+ Font fid;
+ register xOpenFontReq *req;
+
+ if (_XF86LoadQueryLocaleFont(dpy, name, (XFontStruct **)0, &fid))
+ return fid;
+
+ 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/nx-X11/lib/X11/LockDis.c b/nx-X11/lib/X11/LockDis.c
new file mode 100644
index 000000000..d99d3bb68
--- /dev/null
+++ b/nx-X11/lib/X11/LockDis.c
@@ -0,0 +1,86 @@
+/* $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.
+
+*/
+/* $XFree86$ */
+
+/*
+ * Author: Stephen Gildea, MIT X Consortium
+ *
+ * XLockDis.c - multi-thread application-level locking routines
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#ifdef XTHREADS
+#include "locking.h"
+#endif
+
+void
+XLockDisplay(
+ register Display* dpy)
+{
+#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
+}
+
+void
+XUnlockDisplay(
+ register Display* dpy)
+{
+#ifdef XTHREADS
+ LockDisplay(dpy);
+ if (dpy->lock)
+ (*dpy->lock->user_unlock_display)(dpy);
+ UnlockDisplay(dpy);
+#endif
+}
diff --git a/nx-X11/lib/X11/LookupCol.c b/nx-X11/lib/X11/LookupCol.c
new file mode 100644
index 000000000..02f831a6c
--- /dev/null
+++ b/nx-X11/lib/X11/LookupCol.c
@@ -0,0 +1,105 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/LookupCol.c,v 1.6 2003/04/13 19:22:16 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+Status
+XLookupColor (
+ register Display *dpy,
+ Colormap cmap,
+ _Xconst char *spec,
+ XColor *def,
+ XColor *scr)
+{
+ 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
+ */
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
+ const char *tmpName = spec;
+
+ switch (_XcmsResolveColorString(ccc, &tmpName, &cmsColor_exact,
+ XcmsRGBFormat)) {
+ case XcmsSuccess:
+ case XcmsSuccessWithCompression:
+ _XcmsRGB_to_XColor(&cmsColor_exact, def, 1);
+ memcpy((char *)scr, (char *)def, sizeof(XColor));
+ _XUnresolveColor(ccc, scr);
+ return(1);
+ case XcmsFailure:
+ case _XCMS_NEWNAME:
+ /*
+ * if the result was _XCMS_NEWNAME tmpName points to
+ * a string in cmsColNm.c:pairs table, for example,
+ * gray70 would become tekhvc:0.0/70.0/0.0
+ */
+ break;
+ }
+ }
+
+ /*
+ * 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/nx-X11/lib/X11/LowerWin.c b/nx-X11/lib/X11/LowerWin.c
new file mode 100644
index 000000000..2db1e8abd
--- /dev/null
+++ b/nx-X11/lib/X11/LowerWin.c
@@ -0,0 +1,51 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/LowerWin.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/Luv.c b/nx-X11/lib/X11/Luv.c
new file mode 100644
index 000000000..ec94c9e56
--- /dev/null
+++ b/nx-X11/lib/X11/Luv.c
@@ -0,0 +1,386 @@
+/* $Xorg: Luv.c,v 1.3 2000/08/17 19:44:41 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * CIELuv.c
+ *
+ * DESCRIPTION
+ * This file contains routines that support the CIE L*u*v*
+ * color space to include conversions to and from the CIE
+ * XYZ space.
+ *
+ * DOCUMENTATION
+ * "TekColor Color Management System, System Implementor's Manual"
+ * and
+ * Fred W. Billmeyer & Max Saltzman, "Principles of Color
+ * Technology", John Wily & Sons, Inc, 1981.
+ */
+/* $XFree86: xc/lib/X11/Luv.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+#include <stdio.h> /* sscanf */
+
+
+/*
+ * FORWARD DECLARATIONS
+ */
+
+static int CIELuv_ParseString(register char *spec, XcmsColor *pColor);
+static Status XcmsCIELuv_ValidSpec(XcmsColor *pColor);
+
+/*
+ * DEFINES
+ * Internal definitions that need NOT be exported to any package
+ * or program using this package.
+ */
+#ifdef DBL_EPSILON
+# define XMY_DBL_EPSILON DBL_EPSILON
+#else
+# define XMY_DBL_EPSILON 0.00001
+#endif
+
+
+/*
+ * LOCAL VARIABLES
+ */
+
+ /*
+ * NULL terminated list of functions applied to get from CIELuv to CIEXYZ
+ */
+static XcmsConversionProc Fl_CIELuv_to_CIEXYZ[] = {
+ XcmsCIELuvToCIEuvY,
+ XcmsCIEuvYToCIEXYZ,
+ NULL
+};
+
+ /*
+ * NULL terminated list of functions applied to get from CIEXYZ to CIELuv
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_CIELuv[] = {
+ XcmsCIEXYZToCIEuvY,
+ XcmsCIEuvYToCIELuv,
+ NULL
+};
+
+/*
+ * GLOBALS
+ */
+
+ /*
+ * CIE Luv Color Space
+ */
+XcmsColorSpace XcmsCIELuvColorSpace =
+ {
+ _XcmsCIELuv_prefix, /* prefix */
+ XcmsCIELuvFormat, /* id */
+ CIELuv_ParseString, /* parseString */
+ Fl_CIELuv_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_CIELuv, /* from_CIEXYZ */
+ 1
+ };
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CIELuv_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+CIELuv_ParseString(
+ register char *spec,
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsCIELuvFormat.
+ * The assumed CIELuv string syntax is:
+ * CIELuv:<L>/<u>/<v>
+ * Where L, u, and v are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ * 0 if failed, non-zero otherwise.
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsCIELuv_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.CIELuv.L_star,
+ &pColor->spec.CIELuv.u_star,
+ &pColor->spec.CIELuv.v_star) != 3) {
+ return(XcmsFailure);
+ }
+ pColor->format = XcmsCIELuvFormat;
+ pColor->pixel = 0;
+ return(XcmsCIELuv_ValidSpec(pColor));
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuv_ValidSpec
+ *
+ * SYNOPSIS
+ */
+static Status
+XcmsCIELuv_ValidSpec(
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * Checks if color specification valid for CIE L*u*v*.
+ *
+ * RETURNS
+ * XcmsFailure if invalid,
+ * XcmsSuccess if valid.
+ *
+ */
+{
+ if (pColor->format != XcmsCIELuvFormat
+ ||
+ (pColor->spec.CIELuv.L_star < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIELuv.L_star > 100.0 + XMY_DBL_EPSILON)) {
+ return(XcmsFailure);
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIELuvToCIEuvY - convert CIELuv to CIEuvY
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELuvToCIEuvY(ccc, pLuv_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pLuv_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIELuv format to CIEuvY format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsColor *pColor = pColors_in_out;
+ XcmsColor whitePt;
+ XcmsCIEuvY uvY_return;
+ XcmsFloat tmpVal;
+ register int i;
+
+ /*
+ * Check arguments
+ */
+ if (pLuv_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Make sure white point is in CIEuvY form
+ */
+ if (pLuv_WhitePt->format != XcmsCIEuvYFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pLuv_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL,
+ 1, XcmsCIEuvYFormat)) {
+ return(XcmsFailure);
+ }
+ pLuv_WhitePt = &whitePt;
+ }
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (pLuv_WhitePt->spec.CIEuvY.Y != 1.0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ /* Make sure original format is CIELuv and is valid */
+ if (!XcmsCIELuv_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ if (pColor->spec.CIELuv.L_star < 7.99953624) {
+ uvY_return.Y = pColor->spec.CIELuv.L_star / 903.29;
+ } else {
+ tmpVal = (pColor->spec.CIELuv.L_star + 16.0) / 116.0;
+ uvY_return.Y = tmpVal * tmpVal * tmpVal; /* tmpVal ** 3 */
+ }
+
+
+
+ if (pColor->spec.CIELuv.L_star == 0.0) {
+ uvY_return.u_prime = pLuv_WhitePt->spec.CIEuvY.u_prime;
+ uvY_return.v_prime = pLuv_WhitePt->spec.CIEuvY.v_prime;
+ } else {
+ tmpVal = 13.0 * (pColor->spec.CIELuv.L_star / 100.0);
+ uvY_return.u_prime = pColor->spec.CIELuv.u_star/tmpVal +
+ pLuv_WhitePt->spec.CIEuvY.u_prime;
+ uvY_return.v_prime = pColor->spec.CIELuv.v_star/tmpVal +
+ pLuv_WhitePt->spec.CIEuvY.v_prime;
+ }
+ /* Copy result to pColor */
+ memcpy((char *)&pColor->spec, (char *)&uvY_return, sizeof(XcmsCIEuvY));
+
+ /* Identify that the format is now CIEuvY */
+ pColor->format = XcmsCIEuvYFormat;
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEuvYToCIELuv - convert CIEuvY to CIELuv
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIEuvYToCIELuv(ccc, pLuv_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pLuv_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIEuvY format to CIELab format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsColor *pColor = pColors_in_out;
+ XcmsColor whitePt;
+ XcmsCIELuv Luv_return;
+ XcmsFloat tmpVal;
+ register int i;
+
+ /*
+ * Check arguments
+ */
+ if (pLuv_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Make sure white point is in CIEuvY form
+ */
+ if (pLuv_WhitePt->format != XcmsCIEuvYFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pLuv_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt,
+ (XcmsColor *)NULL, 1, XcmsCIEuvYFormat)) {
+ return(XcmsFailure);
+ }
+ pLuv_WhitePt = &whitePt;
+ }
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (pLuv_WhitePt->spec.CIEuvY.Y != 1.0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ if (!_XcmsCIEuvY_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ /* Now convert the uvY to Luv */
+ Luv_return.L_star =
+ (pColor->spec.CIEuvY.Y < 0.008856)
+ ?
+ (pColor->spec.CIEuvY.Y * 903.29)
+ :
+ ((XcmsFloat)(XCMS_CUBEROOT(pColor->spec.CIEuvY.Y) * 116.0) - 16.0);
+ tmpVal = 13.0 * (Luv_return.L_star / 100.0);
+ Luv_return.u_star = tmpVal *
+ (pColor->spec.CIEuvY.u_prime - pLuv_WhitePt->spec.CIEuvY.u_prime);
+ Luv_return.v_star = tmpVal *
+ (pColor->spec.CIEuvY.v_prime - pLuv_WhitePt->spec.CIEuvY.v_prime);
+
+ /* Copy result to pColor */
+ memcpy((char *)&pColor->spec, (char *)&Luv_return, sizeof(XcmsCIELuv));
+
+ /* Identify that the format is now CIEuvY */
+ pColor->format = XcmsCIELuvFormat;
+ }
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/LuvGcC.c b/nx-X11/lib/X11/LuvGcC.c
new file mode 100644
index 000000000..ecae0fe6d
--- /dev/null
+++ b/nx-X11/lib/X11/LuvGcC.c
@@ -0,0 +1,129 @@
+/* $Xorg: LuvGcC.c,v 1.3 2000/08/17 19:44:41 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELuvGcC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsCIELuvClipuv() gamut compression routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/LuvGcC.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvClipuv - Reduce the chroma for a hue and L*
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIELuvClipuv (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Reduce the Chroma for a specific hue and chroma to
+ * to bring the given color into the gamut of the
+ * specified device. As required of gamut compression
+ * functions, this routine returns pColor_in_out
+ * in XcmsCIEXYZFormat on successful completion.
+ *
+ * Since this routine works with the L* within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ Status retval;
+ XcmsColor *pColor;
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < PseudoColor) {
+ /*
+ * GRAY !
+ */
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIELuvFormat);
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIEXYZFormat);
+ if (pCompressed) {
+ *(pCompressed + i) = True;
+ }
+ return(XcmsSuccess);
+ } else {
+ if (pColor->format != XcmsCIELuvFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIELuvFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsCIELuvQueryMaxC(ccc,
+ degrees(XCMS_CIELUV_PMETRIC_HUE(pColor->spec.CIELuv.u_star,
+ pColor->spec.CIELuv.v_star)),
+ pColor->spec.CIELuv.L_star,
+ pColor) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/nx-X11/lib/X11/LuvGcL.c b/nx-X11/lib/X11/LuvGcL.c
new file mode 100644
index 000000000..81a553d3f
--- /dev/null
+++ b/nx-X11/lib/X11/LuvGcL.c
@@ -0,0 +1,176 @@
+/* $Xorg: LuvGcL.c,v 1.3 2000/08/17 19:44:41 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELuvGcL.c
+ *
+ * DESCRIPTION
+ * Source for XcmsCIELuvClipL() gamut compression routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/LuvGcL.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvClipL - Return the closest L*
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIELuvClipL (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Return the closest L* for a specific hue and chroma.
+ * This routine takes any color as input and outputs
+ * a CIE XYZ color.
+ *
+ * Since this routine works with the L* within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor *pColor;
+ XcmsColor Luv_max;
+ XcmsFloat hue, chroma, maxChroma;
+ Status retval;
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* Inherit Screen WP */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut compression */
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor) {
+ /*
+ * GRAY !
+ */
+ return(XcmsFailure);
+ } else {
+ /* Convert from CIEXYZ to CIE L*u*v* format */
+ if (_XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ hue = XCMS_CIELUV_PMETRIC_HUE(pColor->spec.CIELuv.u_star,
+ pColor->spec.CIELuv.v_star);
+ chroma = XCMS_CIELUV_PMETRIC_CHROMA(pColor->spec.CIELuv.u_star,
+ pColor->spec.CIELuv.v_star);
+ /* Step 1: compute the maximum L* and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ memcpy((char *)&Luv_max, (char *)pColor, sizeof(XcmsColor));
+ if (_XcmsCIELuvQueryMaxLCRGB (&myCCC, hue, &Luv_max,
+ (XcmsRGBi *)NULL) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ maxChroma = XCMS_CIELUV_PMETRIC_CHROMA(Luv_max.spec.CIELuv.u_star,
+ Luv_max.spec.CIELuv.v_star);
+
+ /* Now check and return the appropriate L* */
+ if (chroma == maxChroma) {
+ /* When the chroma input is equal to the maximum chroma */
+ /* merely return the L* for that chroma. */
+ memcpy((char *)pColor, (char *)&Luv_max, sizeof(XcmsColor));
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ } else if (chroma > maxChroma) {
+ /* When the chroma input is greater than the maximum chroma */
+ /* merely return the L* and chroma for the given hue. */
+ memcpy((char *)pColor, (char *)&Luv_max, sizeof(XcmsColor));
+ return (XcmsFailure);
+ } else if (pColor->spec.CIELuv.L_star < Luv_max.spec.CIELuv.L_star) {
+ /* Find the minimum lightness for the given chroma. */
+ if (pColor->format != XcmsCIELuvFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ ScreenWhitePointOfCCC(ccc), 1, XcmsCIELuvFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsCIELuvQueryMinL(&myCCC, degrees(hue), chroma, pColor)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ } else {
+ /* Find the maximum lightness for the given chroma. */
+ if (pColor->format != XcmsCIELuvFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ ScreenWhitePointOfCCC(ccc), 1, XcmsCIELuvFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsCIELuvQueryMaxL(&myCCC, degrees(hue), chroma, pColor)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ }
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/nx-X11/lib/X11/LuvGcLC.c b/nx-X11/lib/X11/LuvGcLC.c
new file mode 100644
index 000000000..a3cc0f68b
--- /dev/null
+++ b/nx-X11/lib/X11/LuvGcLC.c
@@ -0,0 +1,225 @@
+/* $Xorg: LuvGcLC.c,v 1.3 2000/08/17 19:44:41 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELuvGcLC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsCIELuvClipLuv() gamut
+ * compression function.
+ */
+/* $XFree86: xc/lib/X11/LuvGcLC.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+#include "Cv.h"
+
+/*
+ * INTERNALS
+ * Internal defines that need NOT be exported to any package or
+ * program using this package.
+ */
+#define MAXBISECTCOUNT 100
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvClipLuv - Return the closest L* and chroma
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIELuvClipLuv (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * This routine will find the closest L* and chroma
+ * for a specific hue. The color input is converted to
+ * CIE L*u*v* format and returned as CIE XYZ format.
+ *
+ * Since this routine works with the L* within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ Status retval;
+ XcmsCCCRec myCCC;
+ XcmsColor *pColor;
+ XcmsColor Luv_max;
+ XcmsFloat hue, chroma, maxChroma;
+ XcmsFloat Chroma, bestChroma, Lstar, maxLstar, saveLstar;
+ XcmsFloat bestLstar, bestustar, bestvstar;
+ XcmsFloat nT, saveDist, tmpDist;
+ XcmsRGBi rgb_max;
+ int nCount, nMaxCount, nI, nILast;
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* inherit screen white */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut compression func */
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor) {
+ /*
+ * GRAY !
+ */
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIELuvFormat);
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIEXYZFormat);
+ if (pCompressed) {
+ *(pCompressed + i) = True;
+ }
+ return(XcmsSuccess);
+ }
+
+ /* Convert from CIEXYZ to CIELuv format */
+ if (_XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum L* and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ saveLstar = pColor->spec.CIELuv.L_star;
+ hue = XCMS_CIELUV_PMETRIC_HUE(pColor->spec.CIELuv.u_star,
+ pColor->spec.CIELuv.v_star);
+ chroma = XCMS_CIELUV_PMETRIC_CHROMA(pColor->spec.CIELuv.u_star,
+ pColor->spec.CIELuv.v_star);
+ memcpy((char *)&Luv_max, (char *)pColor, sizeof(XcmsColor));
+ if (_XcmsCIELuvQueryMaxLCRGB (&myCCC, hue, &Luv_max, &rgb_max)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ maxLstar = Luv_max.spec.CIELuv.L_star;
+
+ /* Now check and return the appropriate L* */
+ if (saveLstar == maxLstar) {
+ /* When the L* input is equal to the maximum L* */
+ /* merely return the maximum Luv point. */
+ memcpy((char *)pColor, (char *)&Luv_max, sizeof(XcmsColor));
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ } else {
+ /* return the closest point on the hue leaf. */
+ /* must do a bisection here to compute the delta e. */
+ maxChroma = XCMS_CIELUV_PMETRIC_CHROMA(Luv_max.spec.CIELuv.u_star,
+ Luv_max.spec.CIELuv.v_star);
+ nMaxCount = MAXBISECTCOUNT;
+ nI = nMaxCount / 2;
+ bestLstar = Lstar = pColor->spec.CIELuv.L_star;
+ bestustar = pColor->spec.CIELuv.u_star;
+ bestvstar = pColor->spec.CIELuv.v_star;
+ bestChroma = Chroma = chroma;
+ saveDist = XCMS_SQRT(((Chroma - maxChroma) * (Chroma - maxChroma)) +
+ ((Lstar - maxLstar) * (Lstar - maxLstar)));
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ nT = (XcmsFloat) nI / (XcmsFloat) nMaxCount;
+ if (saveLstar > maxLstar) {
+ pColor->spec.RGBi.red = rgb_max.red * (1.0 - nT) + nT;
+ pColor->spec.RGBi.green = rgb_max.green * (1.0 - nT) + nT;
+ pColor->spec.RGBi.blue = rgb_max.blue * (1.0 - nT) + nT;
+ } else {
+ pColor->spec.RGBi.red = rgb_max.red - (rgb_max.red * nT);
+ pColor->spec.RGBi.green = rgb_max.green - (rgb_max.green * nT);
+ pColor->spec.RGBi.blue = rgb_max.blue - (rgb_max.blue * nT);
+ }
+ pColor->format = XcmsRGBiFormat;
+
+ /* Convert from RGBi to CIE Luv */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ chroma = XCMS_CIELUV_PMETRIC_CHROMA(pColor->spec.CIELuv.u_star,
+ pColor->spec.CIELuv.v_star);
+ tmpDist = XCMS_SQRT(((Chroma - chroma) * (Chroma - chroma)) +
+ ((Lstar - pColor->spec.CIELuv.L_star) *
+ (Lstar - pColor->spec.CIELuv.L_star)));
+ nILast = nI;
+ if (tmpDist > saveDist) {
+ nI /= 2;
+ } else {
+ nI = (nMaxCount + nI) / 2;
+ saveDist = tmpDist;
+ bestLstar = pColor->spec.CIELuv.L_star;
+ bestustar = pColor->spec.CIELuv.u_star;
+ bestvstar = pColor->spec.CIELuv.v_star;
+ bestChroma = chroma;
+ }
+ if (nI == nILast || nI == 0) {
+ break;
+ }
+ }
+ if (bestChroma >= maxChroma) {
+ pColor->spec.CIELuv.L_star = maxLstar;
+ pColor->spec.CIELuv.u_star = Luv_max.spec.CIELuv.u_star;
+ pColor->spec.CIELuv.v_star = Luv_max.spec.CIELuv.v_star;
+ } else {
+ pColor->spec.CIELuv.L_star = bestLstar;
+ pColor->spec.CIELuv.u_star = bestustar;
+ pColor->spec.CIELuv.v_star = bestvstar;
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ }
+ return(retval);
+}
diff --git a/nx-X11/lib/X11/LuvMnL.c b/nx-X11/lib/X11/LuvMnL.c
new file mode 100644
index 000000000..9938ab495
--- /dev/null
+++ b/nx-X11/lib/X11/LuvMnL.c
@@ -0,0 +1,218 @@
+/* $Xorg: LuvMnL.c,v 1.3 2000/08/17 19:44:41 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELuvMnL.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELuvQueryMinL() gamut boundary
+ * querying routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/LuvMnL.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS (XcmsFloat)0.001
+#define START_L_STAR (XcmsFloat)40.0
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvQueryMinL - Compute max Lstar for a hue and chroma
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELuvQueryMinL(ccc, hue_angle, chroma, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue angle in degrees */
+ XcmsFloat chroma;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum Lstar for a specified hue_angle and chroma.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded with no modifications
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor max_lc, tmp, prev;
+ XcmsFloat max_chroma, tmp_chroma;
+ XcmsFloat hue, nT, nChroma, lastChroma, prevChroma;
+ XcmsFloat rFactor;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* setup the CCC to use for the conversions. */
+ memcpy ((char *) &myCCC, (char *) ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc) NULL;
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ hue = radians(hue_angle);
+ tmp.spec.CIELuv.L_star = START_L_STAR;
+ tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, chroma);
+ tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, chroma);
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsCIELuvFormat;
+
+ /* Step 1: Obtain the maximum L_star and chroma for this hue. */
+ if (_XcmsCIELuvQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ max_chroma = XCMS_CIELUV_PMETRIC_CHROMA(max_lc.spec.CIELuv.u_star,
+ max_lc.spec.CIELuv.v_star);
+
+ if (max_chroma <= chroma) {
+ /*
+ * If the chroma is greater than the chroma for the
+ * maximum L/chroma point then the L_star is the
+ * the L_star for the maximum L_star/chroma point.
+ * This is an error but I return the best approximation I can.
+ * Thus the inconsistency.
+ */
+ memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+
+ /*
+ * If the chroma is equal to the chroma for the
+ * maximum L_star/chroma point then the L_star is the
+ * the L_star for the maximum L* and chroma point.
+ */
+ /* if (max_chroma == chroma) {
+ * memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ * return(XcmsSuccess);
+ * }
+ */
+
+ /* must do a bisection here to compute the maximum L* */
+ /* save the structure input so that any elements that */
+ /* are not touched are recopied later in the routine. */
+ nChroma = chroma;
+ tmp_chroma = max_chroma;
+ lastChroma = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prevChroma = lastChroma;
+ lastChroma = tmp_chroma;
+ nT = (nChroma - max_chroma) / max_chroma * rFactor;
+ memcpy ((char *)&prev, (char *)&tmp, sizeof(XcmsColor));
+ tmp.spec.RGBi.red = rgb_saved.red + (rgb_saved.red * nT);
+ tmp.spec.RGBi.green = rgb_saved.green + (rgb_saved.green * nT);
+ tmp.spec.RGBi.blue = rgb_saved.blue + (rgb_saved.blue * nT);
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to CIELuv */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Now check the return against what is expected */
+ tmp_chroma = XCMS_CIELUV_PMETRIC_CHROMA(tmp.spec.CIELuv.u_star,
+ tmp.spec.CIELuv.v_star);
+ if (tmp_chroma <= chroma + EPS && tmp_chroma >= chroma - EPS) {
+ /* Found It! */
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+ nChroma += chroma - tmp_chroma;
+ if (nChroma > max_chroma) {
+ nChroma = max_chroma;
+ rFactor *= 0.5; /* selective relaxation employed */
+ } else if (nChroma < 0.0) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ return(XcmsSuccess);
+ } else if (tmp_chroma <= prevChroma + EPS &&
+ tmp_chroma >= prevChroma - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ }
+ }
+
+ if (nCount >= nMaxCount) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ }
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/LuvMxC.c b/nx-X11/lib/X11/LuvMxC.c
new file mode 100644
index 000000000..c77319d1f
--- /dev/null
+++ b/nx-X11/lib/X11/LuvMxC.c
@@ -0,0 +1,206 @@
+/* $Xorg: LuvMxC.c,v 1.3 2000/08/17 19:44:41 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * CIELuvMxC.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELuvQueryMaxC() gamut boundary
+ * querying routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/LuvMxC.c,v 1.3 2001/01/17 19:41:39 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS (XcmsFloat)0.001
+#define START_CHROMA (XcmsFloat)2.2
+#define TOPL (XcmsFloat)100.0
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvQueryMaxC - max chroma for a hue_angle and L_star
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELuvQueryMaxC(ccc, hue_angle, L_star, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue angle in degrees */
+ XcmsFloat L_star;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum chroma for a specific hue_angle and L_star.
+ * The returned format is in XcmsCIELuvFormat.
+ *
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor tmp;
+ XcmsColor max_lc;
+ XcmsFloat n_L_star, last_L_star, prev_L_star;
+ XcmsFloat hue, lastuStar, lastvStar, /*lastChroma,*/ maxDist, nT, rFactor;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC and inherit screen white Pt */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut comp func */
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ hue = radians(hue_angle);
+ tmp.spec.CIELuv.L_star = L_star;
+ tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, START_CHROMA);
+ tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, START_CHROMA);
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsCIELuvFormat;
+
+ /* Step 1: compute the maximum L_star and chroma for this hue. */
+ memcpy((char *)&max_lc, (char *)&tmp, sizeof(XcmsColor));
+ if (_XcmsCIELuvQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Step 2: Do a bisection here to compute the maximum chroma
+ * Note the differences between when the point to be found
+ * is above the maximum LC point and when it is below.
+ */
+ if (L_star <= max_lc.spec.CIELuv.L_star) {
+ maxDist = max_lc.spec.CIELuv.L_star;
+ } else {
+ maxDist = TOPL - max_lc.spec.CIELuv.L_star;
+ }
+
+ n_L_star = L_star;
+ last_L_star = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prev_L_star = last_L_star;
+ last_L_star = tmp.spec.CIELuv.L_star;
+/* lastChroma = XCMS_CIELUV_PMETRIC_CHROMA(tmp.spec.CIELuv.u_star, */
+/* tmp.spec.CIELuv.v_star); */
+ lastuStar = tmp.spec.CIELuv.u_star;
+ lastvStar = tmp.spec.CIELuv.v_star;
+ nT = (n_L_star - max_lc.spec.CIELuv.L_star) / maxDist * rFactor;
+ /* printf("(n_L_star, nT) = %lf %lf ", n_L_star, nT); */
+ if (nT > 0) {
+ tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ } else {
+ tmp.spec.RGBi.red = rgb_saved.red + (rgb_saved.red * nT);
+ tmp.spec.RGBi.green = rgb_saved.green + (rgb_saved.green * nT);
+ tmp.spec.RGBi.blue = rgb_saved.blue + (rgb_saved.blue * nT);
+ }
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to CIELuv */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now check if we've reached the target L_star
+ */
+ /* printf("result Lstar = %lf\n", tmp.spec.CIELuv.L_star); */
+ if (tmp.spec.CIELuv.L_star <= L_star + EPS &&
+ tmp.spec.CIELuv.L_star >= L_star - EPS) {
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+ }
+ if (nT > 0) {
+ n_L_star += ((TOPL - n_L_star) *
+ (L_star - tmp.spec.CIELuv.L_star)) / (TOPL - L_star);
+ } else {
+ n_L_star *= L_star / tmp.spec.CIELuv.L_star;
+ }
+ if (tmp.spec.CIELuv.L_star <= prev_L_star + EPS &&
+ tmp.spec.CIELuv.L_star >= prev_L_star - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ /* printf("rFactor = %lf\n", rFactor); */
+ }
+ }
+ if (XCMS_FABS(last_L_star - L_star) <
+ XCMS_FABS(tmp.spec.CIELuv.L_star - L_star)) {
+ tmp.spec.CIELuv.u_star = lastuStar;
+ tmp.spec.CIELuv.v_star = lastvStar;
+/* tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, lastChroma); */
+/* tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, lastChroma); */
+ }
+ tmp.spec.CIELuv.L_star = L_star;
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/LuvMxL.c b/nx-X11/lib/X11/LuvMxL.c
new file mode 100644
index 000000000..d364078ac
--- /dev/null
+++ b/nx-X11/lib/X11/LuvMxL.c
@@ -0,0 +1,218 @@
+/* $Xorg: LuvMxL.c,v 1.3 2000/08/17 19:44:45 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELuvMxL.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELuvQueryMaxL() gamut boundary
+ * querying routine.
+ *
+ */
+/* $XFree86: xc/lib/X11/LuvMxL.c,v 1.3 2001/01/17 19:41:40 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS (XcmsFloat)0.001
+#define START_L_STAR (XcmsFloat)40.0
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvQueryMaxL - Compute max Lstar for a hue and chroma
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELuvQueryMaxL(ccc, hue_angle, chroma, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue angle in degrees */
+ XcmsFloat chroma;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum Lstar for a specified hue_angle and chroma.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded with no modifications
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor max_lc, tmp, prev;
+ XcmsFloat max_chroma, tmp_chroma;
+ XcmsFloat hue, nT, nChroma, lastChroma, prevChroma;
+ XcmsFloat rFactor;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* setup the CCC to use for the conversions. */
+ memcpy ((char *) &myCCC, (char *) ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc) NULL;
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ hue = radians(hue_angle);
+ tmp.spec.CIELuv.L_star = START_L_STAR;
+ tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, chroma);
+ tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, chroma);
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsCIELuvFormat;
+
+ /* Step 1: Obtain the maximum L_star and chroma for this hue. */
+ if (_XcmsCIELuvQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ max_chroma = XCMS_CIELUV_PMETRIC_CHROMA(max_lc.spec.CIELuv.u_star,
+ max_lc.spec.CIELuv.v_star);
+
+ if (max_chroma <= chroma) {
+ /*
+ * If the chroma is greater than the chroma for the
+ * maximum L/chroma point then the L_star is the
+ * the L_star for the maximum L_star/chroma point.
+ * This is an error but I return the best approximation I can.
+ * Thus the inconsistency.
+ */
+ memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+
+ /*
+ * If the chroma is equal to the chroma for the
+ * maximum L_star/chroma point then the L_star is the
+ * the L_star for the maximum L* and chroma point.
+ */
+ /* if (max_chroma == chroma) {
+ * memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ * return(XcmsSuccess);
+ * }
+ */
+
+ /* must do a bisection here to compute the maximum L* */
+ /* save the structure input so that any elements that */
+ /* are not touched are recopied later in the routine. */
+ nChroma = chroma;
+ tmp_chroma = max_chroma;
+ lastChroma = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prevChroma = lastChroma;
+ lastChroma = tmp_chroma;
+ nT = (1.0 - (nChroma / max_chroma)) * rFactor;
+ memcpy ((char *)&prev, (char *)&tmp, sizeof(XcmsColor));
+ tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to CIELuv */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Now check the return against what is expected */
+ tmp_chroma = XCMS_CIELUV_PMETRIC_CHROMA(tmp.spec.CIELuv.u_star,
+ tmp.spec.CIELuv.v_star);
+ if (tmp_chroma <= chroma + EPS && tmp_chroma >= chroma - EPS) {
+ /* Found It! */
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+ nChroma += chroma - tmp_chroma;
+ if (nChroma > max_chroma) {
+ nChroma = max_chroma;
+ rFactor *= 0.5; /* selective relaxation employed */
+ } else if (nChroma < 0.0) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ return(XcmsSuccess);
+ } else if (tmp_chroma <= prevChroma + EPS &&
+ tmp_chroma >= prevChroma - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ }
+ }
+
+ if (nCount >= nMaxCount) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ }
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/LuvMxLC.c b/nx-X11/lib/X11/LuvMxLC.c
new file mode 100644
index 000000000..3f4c22943
--- /dev/null
+++ b/nx-X11/lib/X11/LuvMxLC.c
@@ -0,0 +1,220 @@
+/* $Xorg: LuvMxLC.c,v 1.3 2000/08/17 19:44:45 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * CIELuvMxVC.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELuvQueryMaxLC() gamut boundary
+ * querying routine.
+ *
+ * DOCUMENTATION
+ * "TekColor Color Management System, System Implementor's Manual"
+ * and
+ * Fred W. Billmeyer & Max Saltzman, "Principles of Color
+ * Technology", John Wily & Sons, Inc, 1981.
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define MIN(x,y) ((x) > (y) ? (y) : (x))
+#define MIN3(x,y,z) ((x) > (MIN((y), (z))) ? (MIN((y), (z))) : (x))
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+#define MAX3(x,y,z) ((x) > (MAX((y), (z))) ? (x) : (MAX((y), (z))))
+#define START_LSTAR (XcmsFloat)40.0
+#define START_CHROMA (XcmsFloat)2.2
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsCIELuvQueryMaxLCRGB - Compute maximum L* and chroma.
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsCIELuvQueryMaxLCRGB(
+ XcmsCCC ccc,
+ XcmsFloat hue, /* hue in radians */
+ XcmsColor *pColor_return,
+ XcmsRGBi *pRGB_return)
+/*
+ * DESCRIPTION
+ * Return the maximum psychometric chroma for a specified
+ * hue angle(radians), and the corresponding L*. This is computed
+ * by a binary search of all possible chromas. An assumption
+ * is made that there are no local maxima. Use the unrounded
+ * Max psychometric chroma because the difference check can be
+ * small.
+ *
+ * NOTE: No local CCC is used because this is a private
+ * routine and all routines that call it are expected
+ * to behave properly, i.e. send a local CCC with
+ * no white adjust function and no gamut compression
+ * function.
+ *
+ * This routine only accepts hue as input and outputs
+ * Luv and RGBi.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsFloat nSmall, nLarge;
+ XcmsColor tmp;
+
+ tmp.format = XcmsCIELuvFormat;
+ /* Use some unreachable color on the given hue angle */
+ tmp.spec.CIELuv.L_star = START_LSTAR;
+ tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, START_CHROMA);
+ tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, START_CHROMA);
+ /*
+ * Convert from Luv to RGB
+ *
+ * Note that the CIEXYZ to RGBi conversion routine must stuff the
+ * out of bounds RGBi values in tmp when the ccc->gamutCompProc
+ * is NULL.
+ */
+ if ((_XcmsConvertColorsWithWhitePt(ccc, &tmp, ScreenWhitePointOfCCC(ccc),
+ (unsigned int)1, XcmsRGBiFormat, (Bool *) NULL)
+ == XcmsFailure) && tmp.format != XcmsRGBiFormat) {
+ return (XcmsFailure);
+ }
+
+ /* Now pick the smallest RGB */
+ nSmall = MIN3(tmp.spec.RGBi.red,
+ tmp.spec.RGBi.green,
+ tmp.spec.RGBi.blue);
+ /* Make the smallest RGB equal to zero */
+ tmp.spec.RGBi.red -= nSmall;
+ tmp.spec.RGBi.green -= nSmall;
+ tmp.spec.RGBi.blue -= nSmall;
+
+ /* Now pick the largest RGB */
+ nLarge = MAX3(tmp.spec.RGBi.red,
+ tmp.spec.RGBi.green,
+ tmp.spec.RGBi.blue);
+ /* Scale the RGB values based on the largest one */
+ tmp.spec.RGBi.red /= nLarge;
+ tmp.spec.RGBi.green /= nLarge;
+ tmp.spec.RGBi.blue /= nLarge;
+ tmp.format = XcmsRGBiFormat;
+
+ /* If the calling routine wants RGB value give them the ones used. */
+ if (pRGB_return) {
+ pRGB_return->red = tmp.spec.RGBi.red;
+ pRGB_return->green = tmp.spec.RGBi.green;
+ pRGB_return->blue = tmp.spec.RGBi.blue;
+ }
+
+ /* Convert from RGBi to Luv */
+ if (_XcmsConvertColorsWithWhitePt(ccc, &tmp,
+ ScreenWhitePointOfCCC(ccc), 1, XcmsCIELuvFormat, (Bool *) NULL)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return (XcmsSuccess);
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvQueryMaxLC - Compute maximum L* and chroma.
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELuvQueryMaxLC (ccc, hue_angle, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue angle in degrees */
+ XcmsColor *pColor_return;
+
+/*
+ * DESCRIPTION
+ * Return the point of maximum chroma for the specified
+ * hue angle.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ return(_XcmsCIELuvQueryMaxLCRGB (&myCCC, radians(hue_angle), pColor_return,
+ (XcmsRGBi *)NULL));
+}
diff --git a/nx-X11/lib/X11/LuvWpAj.c b/nx-X11/lib/X11/LuvWpAj.c
new file mode 100644
index 000000000..c48531a50
--- /dev/null
+++ b/nx-X11/lib/X11/LuvWpAj.c
@@ -0,0 +1,99 @@
+/* $Xorg: LuvWpAj.c,v 1.3 2000/08/17 19:44:45 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * CIELuvWpAj.c
+ *
+ * DESCRIPTION
+ * This file contains routine(s) that support white point
+ * adjustment of color specifications in the CIE CIELuv.color
+ * space.
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvWhiteShiftColors
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELuvWhiteShiftColors(ccc, pWhitePtFrom, pWhitePtTo, destSpecFmt,
+ pColors_in_out, nColors, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pWhitePtFrom;
+ XcmsColor *pWhitePtTo;
+ XcmsColorFormat destSpecFmt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Adjusts color specifications in an array of XcmsColor
+ * structures for white point differences.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression,
+ * XcmsSuccessWithCompression if succeeded with
+ * gamut compression.
+ */
+{
+ if (pWhitePtFrom == NULL || pWhitePtTo == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Convert to CIELuv using pWhitePtFrom
+ * We can ignore return value for compression because we are converting
+ * to XcmsCIELuvFormat which is device-independent, not device-dependent.
+ */
+ if (_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out, pWhitePtFrom,
+ nColors, XcmsCIELuvFormat, pCompressed) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Convert from CIELuv to destSpecFmt using pWhitePtTo
+ */
+ return(_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out, pWhitePtTo,
+ nColors, destSpecFmt, pCompressed));
+}
diff --git a/nx-X11/lib/X11/Macros.c b/nx-X11/lib/X11/Macros.c
new file mode 100644
index 000000000..34d11feaf
--- /dev/null
+++ b/nx-X11/lib/X11/Macros.c
@@ -0,0 +1,259 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/Macros.c,v 1.4 2001/12/14 19:54:02 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#define XUTIL_DEFINE_FUNCTIONS
+#include "Xutil.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
+int
+XDestroyImage(
+ XImage *ximage)
+{
+ return((*((ximage)->f.destroy_image))((ximage)));
+}
+#undef XGetPixel
+unsigned long XGetPixel(
+ XImage *ximage,
+ int x, int y)
+{
+ return ((*((ximage)->f.get_pixel))((ximage), (x), (y)));
+}
+#undef XPutPixel
+int XPutPixel(
+ XImage *ximage,
+ int x, int y,
+ unsigned long pixel)
+{
+ return((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)));
+}
+#undef XSubImage
+XImage *XSubImage(
+ XImage *ximage,
+ int x, int y,
+ unsigned int width, unsigned int height)
+{
+ return((*((ximage)->f.sub_image))((ximage), (x),
+ (y), (width), (height)));
+}
+#undef XAddPixel
+int XAddPixel(
+ XImage *ximage,
+ long value)
+{
+ return((*((ximage)->f.add_pixel))((ximage), (value)));
+}
+
+
+int
+XNoOp (dpy)
+ register Display *dpy;
+{
+ register xReq *req;
+
+ LockDisplay(dpy);
+ GetEmptyReq(NoOperation, req);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/MapRaised.c b/nx-X11/lib/X11/MapRaised.c
new file mode 100644
index 000000000..444c99d18
--- /dev/null
+++ b/nx-X11/lib/X11/MapRaised.c
@@ -0,0 +1,53 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/MapRaised.c,v 1.3 2001/01/17 19:41:40 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/MapSubs.c b/nx-X11/lib/X11/MapSubs.c
new file mode 100644
index 000000000..f3e11ebd9
--- /dev/null
+++ b/nx-X11/lib/X11/MapSubs.c
@@ -0,0 +1,45 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/MapSubs.c,v 1.3 2001/01/17 19:41:40 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+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/nx-X11/lib/X11/MapWindow.c b/nx-X11/lib/X11/MapWindow.c
new file mode 100644
index 000000000..d40bff2b7
--- /dev/null
+++ b/nx-X11/lib/X11/MapWindow.c
@@ -0,0 +1,46 @@
+/* $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.
+
+*/
+/* $XFree86: xc/lib/X11/MapWindow.c,v 1.3 2001/01/17 19:41:40 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XMapWindow (dpy, w)
+ Window w;
+ register Display *dpy;
+{
+ register xResourceReq *req;
+ LockDisplay (dpy);
+ GetResReq(MapWindow, w, req);
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/MaskEvent.c b/nx-X11/lib/X11/MaskEvent.c
new file mode 100644
index 000000000..c48a960d2
--- /dev/null
+++ b/nx-X11/lib/X11/MaskEvent.c
@@ -0,0 +1,84 @@
+/* $Xorg: MaskEvent.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.
+
+*/
+/* $XFree86: xc/lib/X11/MaskEvent.c,v 3.5 2001/10/28 03:32:30 tsi Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+extern long const _Xevent_to_mask[];
+#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask)
+#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
+ Button4MotionMask|Button5MotionMask)
+
+/*
+ * return the next event in the queue matching one of the events in the mask.
+ * If no event, flush output, and wait until match succeeds.
+ * Events earlier in the queue are not discarded.
+ */
+
+int
+XMaskEvent (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 = 0;
+
+ LockDisplay(dpy);
+ prev = NULL;
+ while (1) {
+ 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 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;
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return 0;
+ }
+#endif
+ }
+}
diff --git a/nx-X11/lib/X11/MaskEvent.c.NX.original b/nx-X11/lib/X11/MaskEvent.c.NX.original
new file mode 100644
index 000000000..c48a960d2
--- /dev/null
+++ b/nx-X11/lib/X11/MaskEvent.c.NX.original
@@ -0,0 +1,84 @@
+/* $Xorg: MaskEvent.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.
+
+*/
+/* $XFree86: xc/lib/X11/MaskEvent.c,v 3.5 2001/10/28 03:32:30 tsi Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+extern long const _Xevent_to_mask[];
+#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask)
+#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
+ Button4MotionMask|Button5MotionMask)
+
+/*
+ * return the next event in the queue matching one of the events in the mask.
+ * If no event, flush output, and wait until match succeeds.
+ * Events earlier in the queue are not discarded.
+ */
+
+int
+XMaskEvent (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 = 0;
+
+ LockDisplay(dpy);
+ prev = NULL;
+ while (1) {
+ 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 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;
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return 0;
+ }
+#endif
+ }
+}
diff --git a/nx-X11/lib/X11/MaskEvent.c.X.original b/nx-X11/lib/X11/MaskEvent.c.X.original
new file mode 100644
index 000000000..c5f41b54d
--- /dev/null
+++ b/nx-X11/lib/X11/MaskEvent.c.X.original
@@ -0,0 +1,79 @@
+/* $Xorg: MaskEvent.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.
+
+*/
+/* $XFree86: xc/lib/X11/MaskEvent.c,v 3.5 2001/10/28 03:32:30 tsi Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+extern long const _Xevent_to_mask[];
+#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask)
+#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
+ Button4MotionMask|Button5MotionMask)
+
+/*
+ * return the next event in the queue matching one of the events in the mask.
+ * If no event, flush output, and wait until match succeeds.
+ * Events earlier in the queue are not discarded.
+ */
+
+int
+XMaskEvent (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 = 0;
+
+ LockDisplay(dpy);
+ prev = NULL;
+ while (1) {
+ 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 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/nx-X11/lib/X11/Misc.c b/nx-X11/lib/X11/Misc.c
new file mode 100644
index 000000000..5c3499a50
--- /dev/null
+++ b/nx-X11/lib/X11/Misc.c
@@ -0,0 +1,72 @@
+/* $Xorg: Misc.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/X11/Misc.c,v 1.3 2001/01/17 19:41:40 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+long XMaxRequestSize(dpy)
+ Display *dpy;
+{
+ return dpy->max_request_size;
+}
+
+char *XResourceManagerString(dpy)
+ Display *dpy;
+{
+ return dpy->xdefaults;
+}
+
+unsigned long XDisplayMotionBufferSize(dpy)
+ Display *dpy;
+{
+ return dpy->motion_buffer;
+}
+
+int
+XDisplayKeycodes(dpy, min_keycode_return, max_keycode_return)
+ Display *dpy;
+ int *min_keycode_return, *max_keycode_return;
+{
+ *min_keycode_return = dpy->min_keycode;
+ *max_keycode_return = dpy->max_keycode;
+ return 1;
+}
+
+VisualID XVisualIDFromVisual(visual)
+ Visual *visual;
+{
+ return visual->visualid;
+}
+
+long XExtendedMaxRequestSize(dpy)
+ Display *dpy;
+{
+ return dpy->bigreq_size;
+}
diff --git a/nx-X11/lib/X11/ModMap.c b/nx-X11/lib/X11/ModMap.c
new file mode 100644
index 000000000..f321c81bb
--- /dev/null
+++ b/nx-X11/lib/X11/ModMap.c
@@ -0,0 +1,187 @@
+/* $Xorg: ModMap.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.
+
+*/
+/* $XFree86: xc/lib/X11/ModMap.c,v 1.4 2001/12/14 19:54:03 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+XModifierKeymap *
+XGetModifierMapping(dpy)
+ register Display *dpy;
+{
+ xGetModifierMappingReply rep;
+ register xReq *req;
+ unsigned long nbytes;
+ XModifierKeymap *res;
+
+ LockDisplay(dpy);
+ GetEmptyReq(GetModifierMapping, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xFalse);
+
+ nbytes = (unsigned long)rep.length << 2;
+ res = (XModifierKeymap *) Xmalloc(sizeof (XModifierKeymap));
+ if (res) res->modifiermap = (KeyCode *) Xmalloc ((unsigned) nbytes);
+ if ((! res) || (! res->modifiermap)) {
+ if (res) Xfree((char *) res);
+ res = (XModifierKeymap *) NULL;
+ _XEatData(dpy, nbytes);
+ } else {
+ _XReadPad(dpy, (char *) res->modifiermap, (long) nbytes);
+ res->max_keypermod = rep.numKeyPerModifier;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (res);
+}
+
+/*
+ * Returns:
+ * 0 Success
+ * 1 Busy - one or more old or new modifiers are down
+ * 2 Failed - one or more new modifiers unacceptable
+ */
+int
+XSetModifierMapping(dpy, modifier_map)
+ register Display *dpy;
+ register XModifierKeymap *modifier_map;
+{
+ register xSetModifierMappingReq *req;
+ xSetModifierMappingReply rep;
+ int mapSize = modifier_map->max_keypermod << 3; /* 8 modifiers */
+
+ LockDisplay(dpy);
+ GetReqExtra(SetModifierMapping, mapSize, req);
+
+ req->numKeyPerModifier = modifier_map->max_keypermod;
+
+ memcpy((char *) NEXTPTR(req,xSetModifierMappingReq),
+ (char *) modifier_map->modifiermap,
+ mapSize);
+
+ (void) _XReply(dpy, (xReply *) & rep,
+ (SIZEOF(xSetModifierMappingReply) - SIZEOF(xReply)) >> 2, xTrue);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.success);
+}
+
+XModifierKeymap *
+XNewModifiermap(keyspermodifier)
+ int keyspermodifier;
+{
+ XModifierKeymap *res = (XModifierKeymap *) Xmalloc((sizeof (XModifierKeymap)));
+ if (res) {
+ res->max_keypermod = keyspermodifier;
+ res->modifiermap = (keyspermodifier > 0 ?
+ (KeyCode *) Xmalloc((unsigned) (8 * keyspermodifier))
+ : (KeyCode *) NULL);
+ if (keyspermodifier && (res->modifiermap == NULL)) {
+ Xfree((char *) res);
+ return (XModifierKeymap *) NULL;
+ }
+ }
+ return (res);
+}
+
+
+int
+XFreeModifiermap(map)
+ XModifierKeymap *map;
+{
+ if (map) {
+ if (map->modifiermap)
+ Xfree((char *) map->modifiermap);
+ Xfree((char *) map);
+ }
+ return 1;
+}
+
+XModifierKeymap *
+XInsertModifiermapEntry(XModifierKeymap *map,
+#if NeedWidePrototypes
+ unsigned int keycode,
+#else
+ KeyCode keycode,
+#endif
+ int modifier)
+{
+ XModifierKeymap *newmap;
+ int i,
+ row = modifier * map->max_keypermod,
+ newrow,
+ lastrow;
+
+ for (i=0; i<map->max_keypermod; i++) {
+ if (map->modifiermap[ row+i ] == keycode)
+ return(map); /* already in the map */
+ if (map->modifiermap[ row+i ] == 0) {
+ map->modifiermap[ row+i ] = keycode;
+ return(map); /* we added it without stretching the map */
+ }
+ }
+
+ /* stretch the map */
+ if ((newmap = XNewModifiermap(map->max_keypermod+1)) == NULL)
+ return (XModifierKeymap *) NULL;
+ newrow = row = 0;
+ lastrow = newmap->max_keypermod * 8;
+ while (newrow < lastrow) {
+ for (i=0; i<map->max_keypermod; i++)
+ newmap->modifiermap[ newrow+i ] = map->modifiermap[ row+i ];
+ newmap->modifiermap[ newrow+i ] = 0;
+ row += map->max_keypermod;
+ newrow += newmap->max_keypermod;
+ }
+ (void) XFreeModifiermap(map);
+ newrow = newmap->max_keypermod * modifier + newmap->max_keypermod - 1;
+ newmap->modifiermap[ newrow ] = keycode;
+ return(newmap);
+}
+
+XModifierKeymap *
+XDeleteModifiermapEntry(XModifierKeymap *map,
+#if NeedWidePrototypes
+ unsigned int keycode,
+#else
+ KeyCode keycode,
+#endif
+ int modifier)
+{
+ int i,
+ row = modifier * map->max_keypermod;
+
+ for (i=0; i<map->max_keypermod; i++) {
+ if (map->modifiermap[ row+i ] == keycode)
+ map->modifiermap[ row+i ] = 0;
+ }
+ /* should we shrink the map?? */
+ return (map);
+}
diff --git a/nx-X11/lib/X11/MoveWin.c b/nx-X11/lib/X11/MoveWin.c
new file mode 100644
index 000000000..d3c4f8821
--- /dev/null
+++ b/nx-X11/lib/X11/MoveWin.c
@@ -0,0 +1,66 @@
+/* $Xorg: MoveWin.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.
+
+*/
+/* $XFree86: xc/lib/X11/MoveWin.c,v 1.3 2001/01/17 19:41:40 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XMoveWindow (dpy, w, x, y)
+ register Display *dpy;
+ Window w;
+ int x, y;
+{
+ register xConfigureWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra(ConfigureWindow, 8, req);
+
+ req->window = w;
+ req->mask = CWX | CWY;
+
+#ifdef MUSTCOPY
+ {
+ long lx = (long) x, ly = (long) y;
+ dpy->bufptr -= 8;
+ Data32 (dpy, (long *) &lx, 4); /* order dictated by CWX and CWY */
+ Data32 (dpy, (long *) &ly, 4);
+ }
+#else
+ {
+ CARD32 *valuePtr = (CARD32 *) NEXTPTR(req,xConfigureWindowReq);
+ *valuePtr++ = x;
+ *valuePtr = y;
+ }
+#endif /* MUSTCOPY */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/NextEvent.c b/nx-X11/lib/X11/NextEvent.c
new file mode 100644
index 000000000..1c9080651
--- /dev/null
+++ b/nx-X11/lib/X11/NextEvent.c
@@ -0,0 +1,57 @@
+/* $Xorg: NextEvent.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.
+
+*/
+/* $XFree86: xc/lib/X11/NextEvent.c,v 1.3 2001/01/17 19:41:40 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/*
+ * Return next event in queue, or if none, flush output and wait for
+ * events.
+ */
+
+int
+XNextEvent (dpy, event)
+ register Display *dpy;
+ register XEvent *event;
+{
+ register _XQEvent *qelt;
+
+ LockDisplay(dpy);
+
+ if (dpy->head == NULL)
+ _XReadEvents(dpy);
+ qelt = dpy->head;
+ *event = qelt->event;
+ _XDeq(dpy, NULL, qelt);
+ UnlockDisplay(dpy);
+ return 0;
+}
+
diff --git a/nx-X11/lib/X11/OCWrap.c b/nx-X11/lib/X11/OCWrap.c
new file mode 100644
index 000000000..63ffc421b
--- /dev/null
+++ b/nx-X11/lib/X11/OCWrap.c
@@ -0,0 +1,144 @@
+/* $Xorg: OCWrap.c,v 1.4 2000/08/17 19:44:47 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/OCWrap.c,v 1.3 2001/01/17 19:41:40 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+XOC
+XCreateOC(XOM om, ...)
+{
+ va_list var;
+ XlcArgList args;
+ XOC oc;
+ int num_args;
+
+ va_start(var, om);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ va_start(var, om);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (XOC) NULL;
+
+ oc = (*om->methods->create_oc)(om, args, num_args);
+
+ Xfree(args);
+
+ if (oc) {
+ oc->core.next = om->core.oc_list;
+ om->core.oc_list = oc;
+ }
+
+ return oc;
+}
+
+void
+XDestroyOC(oc)
+ XOC oc;
+{
+ XOC prev, oc_list;
+
+ prev = oc_list = oc->core.om->core.oc_list;
+ if (oc_list == oc)
+ oc->core.om->core.oc_list = oc_list->core.next;
+ else {
+ while ((oc_list = oc_list->core.next)) {
+ if (oc_list == oc) {
+ prev->core.next = oc_list->core.next;
+ break;
+ }
+ prev = oc_list;
+ }
+ }
+
+ (*oc->methods->destroy)(oc);
+}
+
+XOM
+XOMOfOC(oc)
+ XOC oc;
+{
+ return oc->core.om;
+}
+
+char *
+XSetOCValues(XOC oc, ...)
+{
+ va_list var;
+ XlcArgList args;
+ char *ret;
+ int num_args;
+
+ va_start(var, oc);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ va_start(var, oc);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (char *) NULL;
+
+ ret = (*oc->methods->set_values)(oc, args, num_args);
+
+ Xfree(args);
+
+ return ret;
+}
+
+char *
+XGetOCValues(XOC oc, ...)
+{
+ va_list var;
+ XlcArgList args;
+ char *ret;
+ int num_args;
+
+ va_start(var, oc);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ va_start(var, oc);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (char *) NULL;
+
+ ret = (*oc->methods->get_values)(oc, args, num_args);
+
+ Xfree(args);
+
+ return ret;
+}
diff --git a/nx-X11/lib/X11/OMWrap.c b/nx-X11/lib/X11/OMWrap.c
new file mode 100644
index 000000000..8f8a1fd9b
--- /dev/null
+++ b/nx-X11/lib/X11/OMWrap.c
@@ -0,0 +1,134 @@
+/* $Xorg: OMWrap.c,v 1.4 2000/08/17 19:44:47 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/OMWrap.c,v 1.4 2001/07/25 15:04:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+XOM
+XOpenOM(Display *dpy, XrmDatabase rdb, _Xconst char *res_name,
+ _Xconst char *res_class)
+{
+ XLCd lcd = _XOpenLC((char *) NULL);
+
+ if (lcd == NULL)
+ return (XOM) NULL;
+
+ if (lcd->methods->open_om)
+ return (*lcd->methods->open_om)(lcd, dpy, rdb, res_name, res_class);
+
+ return (XOM) NULL;
+}
+
+Status
+XCloseOM(om)
+ XOM om;
+{
+ XOC oc, next;
+ XLCd lcd = om->core.lcd;
+
+ next = om->core.oc_list;
+
+ while ((oc = next)) {
+ next = oc->core.next;
+ (*oc->methods->destroy)(oc);
+ }
+
+ om->core.oc_list = NULL;
+
+ _XCloseLC(lcd);
+
+ return (*om->methods->close)(om);
+}
+
+char *
+XSetOMValues(XOM om, ...)
+{
+ va_list var;
+ XlcArgList args;
+ char *ret;
+ int num_args;
+
+ va_start(var, om);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ va_start(var, om);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (char *) NULL;
+
+ ret = (*om->methods->set_values)(om, args, num_args);
+
+ Xfree(args);
+
+ return ret;
+}
+
+char *
+XGetOMValues(XOM om, ...)
+{
+ va_list var;
+ XlcArgList args;
+ char *ret;
+ int num_args;
+
+ va_start(var, om);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ va_start(var, om);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (char *) NULL;
+
+ ret = (*om->methods->get_values)(om, args, num_args);
+
+ Xfree(args);
+
+ return ret;
+}
+
+Display *
+XDisplayOfOM(om)
+ XOM om;
+{
+ return om->core.display;
+}
+
+char *
+XLocaleOfOM(om)
+ XOM om;
+{
+ return om->core.lcd->core->name;
+}
diff --git a/nx-X11/lib/X11/OfCCC.c b/nx-X11/lib/X11/OfCCC.c
new file mode 100644
index 000000000..1f9631683
--- /dev/null
+++ b/nx-X11/lib/X11/OfCCC.c
@@ -0,0 +1,163 @@
+/* $Xorg: OfCCC.c,v 1.3 2000/08/17 19:44:47 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsOfCCC.c - Color Conversion Context Querying Routines
+ *
+ * DESCRIPTION
+ * Routines to query components of a Color Conversion
+ * Context structure.
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlib.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsDisplayOfCCC
+ *
+ * SYNOPSIS
+ */
+
+Display *
+XcmsDisplayOfCCC(ccc)
+ XcmsCCC ccc;
+/*
+ * DESCRIPTION
+ * Queries the Display of the specified CCC.
+ *
+ * RETURNS
+ * Pointer to the Display.
+ *
+ */
+{
+ return(ccc->dpy);
+}
+
+
+/*
+ * NAME
+ * XcmsVisualOfCCC
+ *
+ * SYNOPSIS
+ */
+
+Visual *
+XcmsVisualOfCCC(ccc)
+ XcmsCCC ccc;
+/*
+ * DESCRIPTION
+ * Queries the Visual of the specified CCC.
+ *
+ * RETURNS
+ * Pointer to the Visual.
+ *
+ */
+{
+ return(ccc->visual);
+}
+
+
+/*
+ * NAME
+ * XcmsScreenNumberOfCCC
+ *
+ * SYNOPSIS
+ */
+
+int
+XcmsScreenNumberOfCCC(ccc)
+ XcmsCCC ccc;
+/*
+ * DESCRIPTION
+ * Queries the screen number of the specified CCC.
+ *
+ * RETURNS
+ * screen number.
+ *
+ */
+{
+ return(ccc->screenNumber);
+}
+
+
+/*
+ * NAME
+ * XcmsScreenWhitePointOfCCC
+ *
+ * SYNOPSIS
+ */
+
+XcmsColor *
+XcmsScreenWhitePointOfCCC(ccc)
+ XcmsCCC ccc;
+/*
+ * DESCRIPTION
+ * Queries the screen white point of the specified CCC.
+ *
+ * RETURNS
+ * Pointer to the XcmsColor containing the screen white point.
+ *
+ */
+{
+ return(&ccc->pPerScrnInfo->screenWhitePt);
+}
+
+
+/*
+ * NAME
+ * XcmsClientWhitePointOfCCC
+ *
+ * SYNOPSIS
+ */
+
+XcmsColor *
+XcmsClientWhitePointOfCCC(ccc)
+ XcmsCCC ccc;
+/*
+ * DESCRIPTION
+ * Queries the client white point of the specified CCC.
+ *
+ * RETURNS
+ * Pointer to the XcmsColor containing the client white point.
+ *
+ */
+{
+ return(&ccc->clientWhitePt);
+}
diff --git a/nx-X11/lib/X11/OpenDis.c b/nx-X11/lib/X11/OpenDis.c
new file mode 100644
index 000000000..e9d019723
--- /dev/null
+++ b/nx-X11/lib/X11/OpenDis.c
@@ -0,0 +1,911 @@
+/* $Xorg: OpenDis.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 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.
+
+*/
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/* $XFree86: xc/lib/X11/OpenDis.c,v 3.16 2003/07/04 16:24:23 eich Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/Xatom.h>
+#include <X11/Xresource.h>
+#include <X11/extensions/bigreqstr.h>
+#include <stdio.h>
+#include "Xintconn.h"
+
+#ifdef XKB
+#include "XKBlib.h"
+#endif /* XKB */
+
+#ifdef NX_TRANS_SOCKET
+extern void *_X11TransSocketProxyConnInfo(XtransConnInfo);
+#endif
+
+#ifdef X_NOT_POSIX
+#define Size_t unsigned int
+#else
+#define Size_t size_t
+#endif
+
+#define bignamelen (sizeof(XBigReqExtensionName) - 1)
+
+typedef struct {
+ unsigned long seq;
+ int opcode;
+} _XBigReqState;
+
+#ifdef XTHREADS
+#include "locking.h"
+int (*_XInitDisplayLock_fn)(Display *dpy) = NULL;
+void (*_XFreeDisplayLock_fn)(Display *dpy) = NULL;
+
+#define InitDisplayLock(d) (_XInitDisplayLock_fn ? (*_XInitDisplayLock_fn)(d) : Success)
+#define FreeDisplayLock(d) if (_XFreeDisplayLock_fn) (*_XFreeDisplayLock_fn)(d)
+#else
+#define InitDisplayLock(dis) Success
+#define FreeDisplayLock(dis)
+#endif /* XTHREADS */
+
+static xReq _dummy_request = {
+ 0, 0, 0
+};
+
+static void OutOfMemory(Display *dpy, char *setup);
+static Bool _XBigReqHandler(Display *dpy, xReply *rep, char *buf, int len,
+ XPointer data);
+
+/*
+ * Connects to a server, creates a Display object and returns a pointer to
+ * the newly created Display back to the caller.
+ */
+Display *
+XOpenDisplay (
+ register _Xconst char *display)
+{
+ register Display *dpy; /* New Display object being created. */
+ register int i;
+ int j, k; /* random iterator indexes */
+ char *display_name; /* pointer to display name */
+ int endian; /* to determine which endian. */
+ xConnClientPrefix client; /* client information */
+ xConnSetupPrefix prefix; /* prefix information */
+ int vendorlen; /* length of vendor string */
+ char *setup = NULL; /* memory allocated at startup */
+ char *fullname = NULL; /* expanded name of display */
+ int idisplay; /* display number */
+ int iscreen; /* screen number */
+ int prefixread = 0; /* setup prefix already read? */
+ union {
+ xConnSetup *setup;
+ char *failure;
+ char *vendor;
+ xPixmapFormat *sf;
+ xWindowRoot *rp;
+ xDepth *dp;
+ xVisualType *vp;
+ } u; /* proto data returned from server */
+ long setuplength; /* number of bytes in setup message */
+ long usedbytes = 0; /* number of bytes we have processed */
+ char *conn_auth_name, *conn_auth_data;
+ int conn_auth_namelen, conn_auth_datalen;
+ unsigned long mask;
+ long int conn_buf_size;
+ char *xlib_buffer_size;
+
+ bzero((char *) &client, sizeof(client));
+ bzero((char *) &prefix, sizeof(prefix));
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "\nXOpenDisplay: Called with display [%s].\n", display);
+#endif
+ /*
+ * If the display specifier string supplied as an argument to this
+ * routine is NULL or a pointer to NULL, read the DISPLAY variable.
+ */
+ if (display == NULL || *display == '\0') {
+ if ((display_name = getenv("DISPLAY")) == NULL) {
+ /* Oops! No DISPLAY environment variable - error. */
+ return(NULL);
+ }
+ }
+ else {
+ /* Display is non-NULL, copy the pointer */
+ display_name = (char *)display;
+ }
+/*
+ * Set the default error handlers. This allows the global variables to
+ * default to NULL for use with shared libraries.
+ */
+ if (_XErrorFunction == NULL) (void) XSetErrorHandler (NULL);
+ if (_XIOErrorFunction == NULL) (void) XSetIOErrorHandler (NULL);
+
+/*
+ * Attempt to allocate a display structure. Return NULL if allocation fails.
+ */
+ if ((dpy = (Display *)Xcalloc(1, sizeof(Display))) == NULL) {
+ return(NULL);
+ }
+
+/*
+ * Call the Connect routine to get the transport connection object.
+ * If NULL is returned, the connection failed. The connect routine
+ * will set fullname to point to the expanded name.
+ */
+
+ if ((dpy->trans_conn = _X11TransConnectDisplay (
+ display_name, &fullname, &idisplay,
+ &iscreen, &conn_auth_name,
+ &conn_auth_namelen, &conn_auth_data,
+ &conn_auth_datalen)) == NULL) {
+ Xfree ((char *) dpy);
+ return(NULL);
+ }
+
+ dpy->fd = _X11TransGetConnectionNumber (dpy->trans_conn);
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "\nXOpenDisplay: Connected display with dpy->fd = [%d].\n", dpy->fd);
+#endif
+ /* Initialize as much of the display structure as we can.
+ * Initialize pointers to NULL so that XFreeDisplayStructure will
+ * work if we run out of memory before we finish initializing.
+ */
+ dpy->display_name = fullname;
+ dpy->keysyms = (KeySym *) NULL;
+ dpy->modifiermap = NULL;
+ dpy->lock_meaning = NoSymbol;
+ dpy->keysyms_per_keycode = 0;
+ dpy->xdefaults = (char *)NULL;
+ dpy->scratch_length = 0L;
+ dpy->scratch_buffer = NULL;
+ dpy->key_bindings = NULL;
+ dpy->ext_procs = (_XExtension *)NULL;
+ dpy->ext_data = (XExtData *)NULL;
+ dpy->ext_number = 0;
+ dpy->event_vec[X_Error] = _XUnknownWireEvent;
+ dpy->event_vec[X_Reply] = _XUnknownWireEvent;
+ dpy->wire_vec[X_Error] = _XUnknownNativeEvent;
+ dpy->wire_vec[X_Reply] = _XUnknownNativeEvent;
+ for (i = KeyPress; i < LASTEvent; i++) {
+ dpy->event_vec[i] = _XWireToEvent;
+ dpy->wire_vec[i] = NULL;
+ }
+ for (i = LASTEvent; i < 128; i++) {
+ dpy->event_vec[i] = _XUnknownWireEvent;
+ dpy->wire_vec[i] = _XUnknownNativeEvent;
+ }
+ dpy->resource_id = 0;
+ dpy->db = (struct _XrmHashBucketRec *)NULL;
+ dpy->cursor_font = None;
+ dpy->flags = 0;
+ dpy->async_handlers = NULL;
+ dpy->screens = NULL;
+ dpy->vendor = NULL;
+ dpy->buffer = NULL;
+ dpy->atoms = NULL;
+ dpy->error_vec = NULL;
+ dpy->context_db = NULL;
+ dpy->free_funcs = NULL;
+ dpy->pixmap_format = NULL;
+ dpy->cms.clientCmaps = NULL;
+ dpy->cms.defaultCCCs = NULL;
+ dpy->cms.perVisualIntensityMaps = NULL;
+ dpy->im_filters = NULL;
+ dpy->bigreq_size = 0;
+ dpy->lock = NULL;
+ dpy->lock_fns = NULL;
+ dpy->qfree = NULL;
+ dpy->next_event_serial_num = 1;
+ dpy->im_fd_info = NULL;
+ dpy->im_fd_length = 0;
+ dpy->conn_watchers = NULL;
+ dpy->watcher_count = 0;
+ dpy->filedes = NULL;
+ dpy->flushes = NULL;
+ dpy->xcmisc_opcode = 0;
+ dpy->xkb_info = NULL;
+
+/*
+ * Setup other information in this display structure.
+ */
+ dpy->vnumber = X_PROTOCOL;
+ dpy->resource_alloc = _XAllocID;
+ dpy->idlist_alloc = _XAllocIDs;
+ dpy->synchandler = NULL;
+ dpy->savedsynchandler = NULL;
+ dpy->request = 0;
+ dpy->last_request_read = 0;
+ dpy->default_screen = iscreen; /* Value returned by ConnectDisplay */
+ dpy->last_req = (char *)&_dummy_request;
+
+ /* Initialize the display lock */
+ if (InitDisplayLock(dpy) != 0) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ if (!_XPollfdCacheInit(dpy)) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ /* Set up the output buffers. */
+#ifndef XLIBDEFAULTBUFSIZE
+#define XLIBDEFAULTBUFSIZE 16384 /* 16k */
+#endif
+#ifndef XLIBMINBUFSIZE
+#define XLIBMINBUFSIZE BUFSIZE /* old default buffer size */
+#endif
+ if ((xlib_buffer_size = getenv("XLIBBUFFERSIZE")) == NULL)
+ conn_buf_size = XLIBDEFAULTBUFSIZE;
+ else
+ conn_buf_size = 1024 * strtol(xlib_buffer_size, NULL, 10);
+ if (conn_buf_size < XLIBMINBUFSIZE)
+ conn_buf_size = XLIBMINBUFSIZE;
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf (stderr, "Xlib: Running with XLIBBUFFERSIZE [%d] XLIBMINBUFSIZE [%d] "
+ "buffer size [%ld].\n", XLIBDEFAULTBUFSIZE, XLIBMINBUFSIZE, conn_buf_size);
+#endif
+
+ if ((dpy->bufptr = dpy->buffer = Xcalloc(1, conn_buf_size)) == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ dpy->bufmax = dpy->buffer + conn_buf_size;
+
+ /* Set up the input event queue and input event queue parameters. */
+ dpy->head = dpy->tail = NULL;
+ dpy->qlen = 0;
+
+ /* Set up free-function record */
+ if ((dpy->free_funcs = (_XFreeFuncRec *)Xcalloc(1,
+ sizeof(_XFreeFuncRec)))
+ == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+/*
+ * The xConnClientPrefix describes the initial connection setup information
+ * and is followed by the authorization information. Sites that are interested
+ * in security are strongly encouraged to use an authentication and
+ * authorization system such as Kerberos.
+ */
+ endian = 1;
+ if (*(char *) &endian)
+ client.byteOrder = '\154'; /* 'l' */
+ else
+ client.byteOrder = '\102'; /* 'B' */
+ client.majorVersion = X_PROTOCOL;
+ client.minorVersion = X_PROTOCOL_REVISION;
+ client.nbytesAuthProto = conn_auth_namelen;
+ client.nbytesAuthString = conn_auth_datalen;
+ prefixread = _XSendClientPrefix(dpy, &client,
+ conn_auth_name, conn_auth_data,
+ &prefix);
+ if (prefixread < 0)
+ {
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+ if (conn_auth_name) Xfree(conn_auth_name);
+ if (conn_auth_data) Xfree(conn_auth_data);
+/*
+ * Now see if connection was accepted...
+ */
+ /* these internal functions expect the display to be locked */
+ LockDisplay(dpy);
+
+ if (prefixread == 0)
+ _XRead (dpy, (char *)&prefix,(long)SIZEOF(xConnSetupPrefix));
+
+ /* an Authenticate reply we weren't expecting? */
+ if (prefix.success != xTrue && prefix.success != xFalse) {
+ fprintf (stderr,
+ "Xlib: unexpected connection setup reply from server, type %d.\r\n",
+ prefix.success);
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+
+ if (prefix.majorVersion != X_PROTOCOL) {
+ /* XXX - printing messages marks a bad programming interface */
+#ifdef NX_TRANS_SOCKET
+ if (_X11TransSocketProxyConnInfo(dpy->trans_conn) == NULL) {
+ fprintf (stderr, "Xlib: client uses different protocol version (%d) "
+ "than server (%d)!\r\n", X_PROTOCOL, prefix.majorVersion);
+ }
+#else
+ fprintf (stderr,
+ "Xlib: client uses different protocol version (%d) than server (%d)!\r\n",
+ X_PROTOCOL, prefix.majorVersion);
+#endif
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+
+ setuplength = prefix.length << 2;
+ if ( (u.setup = (xConnSetup *)
+ (setup = Xmalloc ((unsigned) setuplength))) == NULL) {
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+ _XRead (dpy, (char *)u.setup, setuplength);
+
+/*
+ * If the connection was not accepted by the server due to problems,
+ * give error message to the user....
+ */
+ if (prefix.success != xTrue) {
+ /* XXX - printing messages marks a bad programming interface */
+ fprintf (stderr,
+ "Xlib: connection to \"%s\" refused by server\r\nXlib: ",
+ fullname);
+
+ if (prefix.lengthReason > setuplength) {
+ fprintf (stderr, "Xlib: Broken initial reply: length of reason > length of packet\r\n");
+ }else{
+ (void) fwrite (u.failure, (Size_t)sizeof(char),
+ (Size_t)prefix.lengthReason, stderr);
+ (void) fwrite ("\r\n", sizeof(char), 2, stderr);
+ }
+
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+/*
+ * Check if the reply was long enough to get any information out of it.
+ */
+ usedbytes = sz_xConnSetup;
+ if (setuplength < usedbytes ) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+/*
+ * We succeeded at authorization, so let us move the data into
+ * the display structure.
+ */
+ dpy->proto_major_version= prefix.majorVersion;
+ dpy->proto_minor_version= prefix.minorVersion;
+ dpy->release = u.setup->release;
+ dpy->resource_base = u.setup->ridBase;
+ dpy->resource_mask = u.setup->ridMask;
+ dpy->min_keycode = u.setup->minKeyCode;
+ dpy->max_keycode = u.setup->maxKeyCode;
+ dpy->motion_buffer = u.setup->motionBufferSize;
+ dpy->nformats = u.setup->numFormats;
+ dpy->nscreens = u.setup->numRoots;
+ dpy->byte_order = u.setup->imageByteOrder;
+ dpy->bitmap_unit = u.setup->bitmapScanlineUnit;
+ dpy->bitmap_pad = u.setup->bitmapScanlinePad;
+ dpy->bitmap_bit_order = u.setup->bitmapBitOrder;
+ dpy->max_request_size = u.setup->maxRequestSize;
+ mask = dpy->resource_mask;
+ dpy->resource_shift = 0;
+ if (!mask)
+ {
+ fprintf (stderr, "Xlib: connection to \"%s\" invalid setup\n",
+ fullname);
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+ while (!(mask & 1)) {
+ dpy->resource_shift++;
+ mask = mask >> 1;
+ }
+ dpy->resource_max = (dpy->resource_mask >> dpy->resource_shift) - 5;
+/*
+ * now extract the vendor string... String must be null terminated,
+ * padded to multiple of 4 bytes.
+ */
+ /* Check for a sane vendor string length */
+ if (u.setup->nbytesVendor > 256) {
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+ dpy->vendor = (char *) Xmalloc((unsigned) (u.setup->nbytesVendor + 1));
+ if (dpy->vendor == NULL) {
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+ vendorlen = u.setup->nbytesVendor;
+
+/*
+ * validate setup length
+ */
+ usedbytes += (vendorlen + 3) & ~3;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+ u.setup = (xConnSetup *) (((char *) u.setup) + sz_xConnSetup);
+ (void) strncpy(dpy->vendor, u.vendor, vendorlen);
+ dpy->vendor[vendorlen] = '\0';
+ vendorlen = (vendorlen + 3) & ~3; /* round up */
+
+
+ memmove (setup, u.vendor + vendorlen,
+ (int) setuplength - sz_xConnSetup - vendorlen);
+ u.vendor = setup;
+/*
+ * Now iterate down setup information.....
+ */
+ dpy->pixmap_format =
+ (ScreenFormat *)Xmalloc(
+ (unsigned) (dpy->nformats *sizeof(ScreenFormat)));
+ if (dpy->pixmap_format == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+/*
+ * First decode the Z axis Screen format information.
+ */
+ usedbytes += dpy->nformats * sz_xPixmapFormat;
+
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ for (i = 0; i < dpy->nformats; i++) {
+ register ScreenFormat *fmt = &dpy->pixmap_format[i];
+ fmt->depth = u.sf->depth;
+ fmt->bits_per_pixel = u.sf->bitsPerPixel;
+ fmt->scanline_pad = u.sf->scanLinePad;
+ fmt->ext_data = NULL;
+ u.sf = (xPixmapFormat *) (((char *) u.sf) + sz_xPixmapFormat);
+ }
+
+/*
+ * next the Screen structures.
+ */
+ dpy->screens =
+ (Screen *)Xmalloc((unsigned) dpy->nscreens*sizeof(Screen));
+ if (dpy->screens == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+/*
+ * Now go deal with each screen structure.
+ */
+ for (i = 0; i < dpy->nscreens; i++) {
+ register Screen *sp = &dpy->screens[i];
+ VisualID root_visualID;
+
+ usedbytes += sz_xWindowRoot;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ root_visualID = u.rp->rootVisualID;
+ sp->display = dpy;
+ sp->root = u.rp->windowId;
+ sp->cmap = u.rp->defaultColormap;
+ sp->white_pixel = u.rp->whitePixel;
+ sp->black_pixel = u.rp->blackPixel;
+ sp->root_input_mask = u.rp->currentInputMask;
+ sp->width = u.rp->pixWidth;
+ sp->height = u.rp->pixHeight;
+ sp->mwidth = u.rp->mmWidth;
+ sp->mheight = u.rp->mmHeight;
+ sp->min_maps = u.rp->minInstalledMaps;
+ sp->max_maps = u.rp->maxInstalledMaps;
+ sp->backing_store= u.rp->backingStore;
+ sp->save_unders = u.rp->saveUnders;
+ sp->root_depth = u.rp->rootDepth;
+ sp->ndepths = u.rp->nDepths;
+ sp->ext_data = NULL;
+ u.rp = (xWindowRoot *) (((char *) u.rp) + sz_xWindowRoot);
+/*
+ * lets set up the depth structures.
+ */
+ sp->depths = (Depth *)Xmalloc(
+ (unsigned)sp->ndepths*sizeof(Depth));
+ if (sp->depths == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ /*
+ * for all depths on this screen.
+ */
+ for (j = 0; j < sp->ndepths; j++) {
+ Depth *dp = &sp->depths[j];
+
+ usedbytes += sz_xDepth;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ dp->depth = u.dp->depth;
+ dp->nvisuals = u.dp->nVisuals;
+ u.dp = (xDepth *) (((char *) u.dp) + sz_xDepth);
+ if (dp->nvisuals > 0) {
+ dp->visuals =
+ (Visual *)Xmalloc((unsigned)dp->nvisuals*sizeof(Visual));
+ if (dp->visuals == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ for (k = 0; k < dp->nvisuals; k++) {
+ register Visual *vp = &dp->visuals[k];
+
+ usedbytes += sz_xVisualType;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ vp->visualid = u.vp->visualID;
+ vp->class = u.vp->class;
+ vp->bits_per_rgb= u.vp->bitsPerRGB;
+ vp->map_entries = u.vp->colormapEntries;
+ vp->red_mask = u.vp->redMask;
+ vp->green_mask = u.vp->greenMask;
+ vp->blue_mask = u.vp->blueMask;
+ vp->ext_data = NULL;
+ u.vp = (xVisualType *) (((char *) u.vp) +
+ sz_xVisualType);
+ }
+ if (dp->depth == 32 && getenv ("XLIB_SKIP_ARGB_VISUALS"))
+ {
+ Xfree (dp->visuals);
+ dp->visuals = NULL;
+ dp->nvisuals = 0;
+ }
+ } else {
+ dp->visuals = (Visual *) NULL;
+ }
+ }
+ sp->root_visual = _XVIDtoVisual(dpy, root_visualID);
+ }
+
+ if(usedbytes != setuplength){
+ /* Sanity check, shouldn't happen. */
+ fprintf(stderr, "Xlib: Did not parse entire setup message: "
+ "parsed: %ld, message: %ld\n",
+ usedbytes, setuplength);
+ OutOfMemory(dpy, setup);
+ return(NULL);
+ }
+
+/*
+ * Now start talking to the server to setup all other information...
+ */
+
+ Xfree (setup); /* all finished with setup information */
+
+/*
+ * Make sure default screen is legal.
+ */
+ if (iscreen >= dpy->nscreens) {
+ OutOfMemory(dpy, (char *) NULL);
+ return(NULL);
+ }
+
+/*
+ * finished calling internal routines, now unlock for external routines
+ */
+ UnlockDisplay(dpy);
+
+/*
+ * Set up other stuff clients are always going to use.
+ */
+ for (i = 0; i < dpy->nscreens; i++) {
+ register Screen *sp = &dpy->screens[i];
+ XGCValues values;
+ values.foreground = sp->black_pixel;
+ values.background = sp->white_pixel;
+ if ((sp->default_gc = XCreateGC (dpy, sp->root,
+ GCForeground|GCBackground,
+ &values)) == NULL) {
+ OutOfMemory(dpy, (char *) NULL);
+ return (NULL);
+ }
+ }
+/*
+ * call into synchronization routine so that all programs can be
+ * forced synchronous
+ */
+ (void) XSynchronize(dpy, _Xdebug);
+
+/*
+ * get availability of large requests, and
+ * get the resource manager database off the root window.
+ */
+ LockDisplay(dpy);
+ {
+ _XAsyncHandler async;
+ _XBigReqState async_state;
+ xQueryExtensionReq *qreq;
+ xGetPropertyReply reply;
+ xGetPropertyReq *req;
+ xBigReqEnableReq *breq;
+ xBigReqEnableReply brep;
+
+ GetReq(QueryExtension, qreq);
+ async_state.seq = dpy->request;
+ async_state.opcode = 0;
+ async.next = dpy->async_handlers;
+ async.handler = _XBigReqHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+ qreq->nbytes = bignamelen;
+ qreq->length += (bignamelen+3)>>2;
+ Data(dpy, XBigReqExtensionName, bignamelen);
+
+ GetReq (GetProperty, req);
+ req->window = RootWindow(dpy, 0);
+ req->property = XA_RESOURCE_MANAGER;
+ req->type = XA_STRING;
+ req->delete = False;
+ req->longOffset = 0;
+ req->longLength = 100000000L;
+
+ if (_XReply (dpy, (xReply *) &reply, 0, xFalse)) {
+ if (reply.format == 8 && reply.propertyType == XA_STRING &&
+ (reply.nItems + 1 > 0) &&
+ (reply.nItems <= req->longLength * 4) &&
+ (dpy->xdefaults = Xmalloc (reply.nItems + 1))) {
+ _XReadPad (dpy, dpy->xdefaults, reply.nItems);
+ dpy->xdefaults[reply.nItems] = '\0';
+ }
+ else if (reply.propertyType != None)
+ _XEatData(dpy, reply.nItems * (reply.format >> 3));
+ }
+ DeqAsyncHandler(dpy, &async);
+ if (async_state.opcode) {
+ GetReq(BigReqEnable, breq);
+ breq->reqType = async_state.opcode;
+ breq->brReqType = X_BigReqEnable;
+ if (_XReply(dpy, (xReply *)&brep, 0, xFalse))
+ dpy->bigreq_size = brep.max_request_size;
+ }
+ }
+ UnlockDisplay(dpy);
+
+#ifdef MOTIFBC
+ {
+ extern Display *_XHeadOfDisplayList;
+ _XHeadOfDisplayList = dpy;
+ }
+#endif
+#ifdef XKB
+ XkbUseExtension(dpy,NULL,NULL);
+#endif
+/*
+ * and return successfully
+ */
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "XOpenDisplay: Returning display at [%p].\n", dpy);
+#endif
+ return(dpy);
+}
+
+static Bool
+_XBigReqHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ _XBigReqState *state;
+ xQueryExtensionReply replbuf;
+ xQueryExtensionReply *repl;
+
+ state = (_XBigReqState *)data;
+ if (dpy->last_request_read != state->seq)
+ return False;
+ if (rep->generic.type == X_Error)
+ return True;
+ repl = (xQueryExtensionReply *)
+ _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
+ (SIZEOF(xQueryExtensionReply) - SIZEOF(xReply)) >> 2,
+ True);
+ if (repl->present)
+ state->opcode = repl->major_opcode;
+ return True;
+}
+
+
+/* XFreeDisplayStructure frees all the storage associated with a
+ * Display. It is used by XOpenDisplay if it runs out of memory,
+ * and also by XCloseDisplay. It needs to check whether all pointers
+ * are non-NULL before dereferencing them, since it may be called
+ * by XOpenDisplay before the Display structure is fully formed.
+ * XOpenDisplay must be sure to initialize all the pointers to NULL
+ * before the first possible call on this.
+ */
+
+void _XFreeDisplayStructure(dpy)
+ register Display *dpy;
+{
+ while (dpy->ext_procs) {
+ _XExtension *ext = dpy->ext_procs;
+ dpy->ext_procs = ext->next;
+ if (ext->name)
+ Xfree (ext->name);
+ Xfree ((char *)ext);
+ }
+ if (dpy->im_filters)
+ (*dpy->free_funcs->im_filters)(dpy);
+ if (dpy->cms.clientCmaps)
+ (*dpy->free_funcs->clientCmaps)(dpy);
+ if (dpy->cms.defaultCCCs)
+ (*dpy->free_funcs->defaultCCCs)(dpy);
+ if (dpy->cms.perVisualIntensityMaps)
+ (*dpy->free_funcs->intensityMaps)(dpy);
+ if (dpy->atoms)
+ (*dpy->free_funcs->atoms)(dpy);
+ if (dpy->modifiermap)
+ (*dpy->free_funcs->modifiermap)(dpy->modifiermap);
+ if (dpy->key_bindings)
+ (*dpy->free_funcs->key_bindings)(dpy);
+ if (dpy->context_db)
+ (*dpy->free_funcs->context_db)(dpy);
+ if (dpy->xkb_info)
+ (*dpy->free_funcs->xkb)(dpy);
+
+ /* if RM database was allocated by XGetDefault() free it */
+ if (dpy->db && (dpy->flags & XlibDisplayDfltRMDB))
+ XrmDestroyDatabase(dpy->db);
+
+ if (dpy->screens) {
+ register int i;
+
+ for (i = 0; i < dpy->nscreens; i++) {
+ Screen *sp = &dpy->screens[i];
+
+ if (sp->depths) {
+ register int j;
+
+ for (j = 0; j < sp->ndepths; j++) {
+ Depth *dp = &sp->depths[j];
+
+ if (dp->visuals) {
+ register int k;
+
+ for (k = 0; k < dp->nvisuals; k++)
+ _XFreeExtData (dp->visuals[k].ext_data);
+ Xfree ((char *) dp->visuals);
+ }
+ }
+
+ Xfree ((char *) sp->depths);
+ }
+
+ _XFreeExtData (sp->ext_data);
+ }
+
+ Xfree ((char *)dpy->screens);
+ }
+
+ if (dpy->pixmap_format) {
+ register int i;
+
+ for (i = 0; i < dpy->nformats; i++)
+ _XFreeExtData (dpy->pixmap_format[i].ext_data);
+ Xfree ((char *)dpy->pixmap_format);
+ }
+
+ if (dpy->display_name)
+ Xfree (dpy->display_name);
+ if (dpy->vendor)
+ Xfree (dpy->vendor);
+
+ if (dpy->buffer)
+ Xfree (dpy->buffer);
+ if (dpy->keysyms)
+ Xfree ((char *) dpy->keysyms);
+ if (dpy->xdefaults)
+ Xfree (dpy->xdefaults);
+ if (dpy->error_vec)
+ Xfree ((char *)dpy->error_vec);
+
+ _XFreeExtData (dpy->ext_data);
+ if (dpy->free_funcs)
+ Xfree ((char *)dpy->free_funcs);
+ if (dpy->scratch_buffer)
+ Xfree (dpy->scratch_buffer);
+ FreeDisplayLock(dpy);
+
+ if (dpy->qfree) {
+ register _XQEvent *qelt = dpy->qfree;
+
+ while (qelt) {
+ register _XQEvent *qnxt = qelt->next;
+ Xfree ((char *) qelt);
+ qelt = qnxt;
+ }
+ }
+ while (dpy->im_fd_info) {
+ struct _XConnectionInfo *conni = dpy->im_fd_info;
+ dpy->im_fd_info = conni->next;
+ if (conni->watch_data)
+ Xfree (conni->watch_data);
+ Xfree (conni);
+ }
+ if (dpy->conn_watchers) {
+ struct _XConnWatchInfo *watcher = dpy->conn_watchers;
+ dpy->conn_watchers = watcher->next;
+ Xfree (watcher);
+ }
+ if (dpy->filedes)
+ Xfree (dpy->filedes);
+
+ Xfree ((char *)dpy);
+}
+
+/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL
+ after this returns. */
+
+static void OutOfMemory (dpy, setup)
+ Display *dpy;
+ char *setup;
+{
+ _XDisconnectDisplay (dpy->trans_conn);
+ _XFreeDisplayStructure (dpy);
+ if (setup) Xfree (setup);
+}
diff --git a/nx-X11/lib/X11/OpenDis.c.NX.original b/nx-X11/lib/X11/OpenDis.c.NX.original
new file mode 100644
index 000000000..e9d019723
--- /dev/null
+++ b/nx-X11/lib/X11/OpenDis.c.NX.original
@@ -0,0 +1,911 @@
+/* $Xorg: OpenDis.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 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.
+
+*/
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/* $XFree86: xc/lib/X11/OpenDis.c,v 3.16 2003/07/04 16:24:23 eich Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/Xatom.h>
+#include <X11/Xresource.h>
+#include <X11/extensions/bigreqstr.h>
+#include <stdio.h>
+#include "Xintconn.h"
+
+#ifdef XKB
+#include "XKBlib.h"
+#endif /* XKB */
+
+#ifdef NX_TRANS_SOCKET
+extern void *_X11TransSocketProxyConnInfo(XtransConnInfo);
+#endif
+
+#ifdef X_NOT_POSIX
+#define Size_t unsigned int
+#else
+#define Size_t size_t
+#endif
+
+#define bignamelen (sizeof(XBigReqExtensionName) - 1)
+
+typedef struct {
+ unsigned long seq;
+ int opcode;
+} _XBigReqState;
+
+#ifdef XTHREADS
+#include "locking.h"
+int (*_XInitDisplayLock_fn)(Display *dpy) = NULL;
+void (*_XFreeDisplayLock_fn)(Display *dpy) = NULL;
+
+#define InitDisplayLock(d) (_XInitDisplayLock_fn ? (*_XInitDisplayLock_fn)(d) : Success)
+#define FreeDisplayLock(d) if (_XFreeDisplayLock_fn) (*_XFreeDisplayLock_fn)(d)
+#else
+#define InitDisplayLock(dis) Success
+#define FreeDisplayLock(dis)
+#endif /* XTHREADS */
+
+static xReq _dummy_request = {
+ 0, 0, 0
+};
+
+static void OutOfMemory(Display *dpy, char *setup);
+static Bool _XBigReqHandler(Display *dpy, xReply *rep, char *buf, int len,
+ XPointer data);
+
+/*
+ * Connects to a server, creates a Display object and returns a pointer to
+ * the newly created Display back to the caller.
+ */
+Display *
+XOpenDisplay (
+ register _Xconst char *display)
+{
+ register Display *dpy; /* New Display object being created. */
+ register int i;
+ int j, k; /* random iterator indexes */
+ char *display_name; /* pointer to display name */
+ int endian; /* to determine which endian. */
+ xConnClientPrefix client; /* client information */
+ xConnSetupPrefix prefix; /* prefix information */
+ int vendorlen; /* length of vendor string */
+ char *setup = NULL; /* memory allocated at startup */
+ char *fullname = NULL; /* expanded name of display */
+ int idisplay; /* display number */
+ int iscreen; /* screen number */
+ int prefixread = 0; /* setup prefix already read? */
+ union {
+ xConnSetup *setup;
+ char *failure;
+ char *vendor;
+ xPixmapFormat *sf;
+ xWindowRoot *rp;
+ xDepth *dp;
+ xVisualType *vp;
+ } u; /* proto data returned from server */
+ long setuplength; /* number of bytes in setup message */
+ long usedbytes = 0; /* number of bytes we have processed */
+ char *conn_auth_name, *conn_auth_data;
+ int conn_auth_namelen, conn_auth_datalen;
+ unsigned long mask;
+ long int conn_buf_size;
+ char *xlib_buffer_size;
+
+ bzero((char *) &client, sizeof(client));
+ bzero((char *) &prefix, sizeof(prefix));
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "\nXOpenDisplay: Called with display [%s].\n", display);
+#endif
+ /*
+ * If the display specifier string supplied as an argument to this
+ * routine is NULL or a pointer to NULL, read the DISPLAY variable.
+ */
+ if (display == NULL || *display == '\0') {
+ if ((display_name = getenv("DISPLAY")) == NULL) {
+ /* Oops! No DISPLAY environment variable - error. */
+ return(NULL);
+ }
+ }
+ else {
+ /* Display is non-NULL, copy the pointer */
+ display_name = (char *)display;
+ }
+/*
+ * Set the default error handlers. This allows the global variables to
+ * default to NULL for use with shared libraries.
+ */
+ if (_XErrorFunction == NULL) (void) XSetErrorHandler (NULL);
+ if (_XIOErrorFunction == NULL) (void) XSetIOErrorHandler (NULL);
+
+/*
+ * Attempt to allocate a display structure. Return NULL if allocation fails.
+ */
+ if ((dpy = (Display *)Xcalloc(1, sizeof(Display))) == NULL) {
+ return(NULL);
+ }
+
+/*
+ * Call the Connect routine to get the transport connection object.
+ * If NULL is returned, the connection failed. The connect routine
+ * will set fullname to point to the expanded name.
+ */
+
+ if ((dpy->trans_conn = _X11TransConnectDisplay (
+ display_name, &fullname, &idisplay,
+ &iscreen, &conn_auth_name,
+ &conn_auth_namelen, &conn_auth_data,
+ &conn_auth_datalen)) == NULL) {
+ Xfree ((char *) dpy);
+ return(NULL);
+ }
+
+ dpy->fd = _X11TransGetConnectionNumber (dpy->trans_conn);
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "\nXOpenDisplay: Connected display with dpy->fd = [%d].\n", dpy->fd);
+#endif
+ /* Initialize as much of the display structure as we can.
+ * Initialize pointers to NULL so that XFreeDisplayStructure will
+ * work if we run out of memory before we finish initializing.
+ */
+ dpy->display_name = fullname;
+ dpy->keysyms = (KeySym *) NULL;
+ dpy->modifiermap = NULL;
+ dpy->lock_meaning = NoSymbol;
+ dpy->keysyms_per_keycode = 0;
+ dpy->xdefaults = (char *)NULL;
+ dpy->scratch_length = 0L;
+ dpy->scratch_buffer = NULL;
+ dpy->key_bindings = NULL;
+ dpy->ext_procs = (_XExtension *)NULL;
+ dpy->ext_data = (XExtData *)NULL;
+ dpy->ext_number = 0;
+ dpy->event_vec[X_Error] = _XUnknownWireEvent;
+ dpy->event_vec[X_Reply] = _XUnknownWireEvent;
+ dpy->wire_vec[X_Error] = _XUnknownNativeEvent;
+ dpy->wire_vec[X_Reply] = _XUnknownNativeEvent;
+ for (i = KeyPress; i < LASTEvent; i++) {
+ dpy->event_vec[i] = _XWireToEvent;
+ dpy->wire_vec[i] = NULL;
+ }
+ for (i = LASTEvent; i < 128; i++) {
+ dpy->event_vec[i] = _XUnknownWireEvent;
+ dpy->wire_vec[i] = _XUnknownNativeEvent;
+ }
+ dpy->resource_id = 0;
+ dpy->db = (struct _XrmHashBucketRec *)NULL;
+ dpy->cursor_font = None;
+ dpy->flags = 0;
+ dpy->async_handlers = NULL;
+ dpy->screens = NULL;
+ dpy->vendor = NULL;
+ dpy->buffer = NULL;
+ dpy->atoms = NULL;
+ dpy->error_vec = NULL;
+ dpy->context_db = NULL;
+ dpy->free_funcs = NULL;
+ dpy->pixmap_format = NULL;
+ dpy->cms.clientCmaps = NULL;
+ dpy->cms.defaultCCCs = NULL;
+ dpy->cms.perVisualIntensityMaps = NULL;
+ dpy->im_filters = NULL;
+ dpy->bigreq_size = 0;
+ dpy->lock = NULL;
+ dpy->lock_fns = NULL;
+ dpy->qfree = NULL;
+ dpy->next_event_serial_num = 1;
+ dpy->im_fd_info = NULL;
+ dpy->im_fd_length = 0;
+ dpy->conn_watchers = NULL;
+ dpy->watcher_count = 0;
+ dpy->filedes = NULL;
+ dpy->flushes = NULL;
+ dpy->xcmisc_opcode = 0;
+ dpy->xkb_info = NULL;
+
+/*
+ * Setup other information in this display structure.
+ */
+ dpy->vnumber = X_PROTOCOL;
+ dpy->resource_alloc = _XAllocID;
+ dpy->idlist_alloc = _XAllocIDs;
+ dpy->synchandler = NULL;
+ dpy->savedsynchandler = NULL;
+ dpy->request = 0;
+ dpy->last_request_read = 0;
+ dpy->default_screen = iscreen; /* Value returned by ConnectDisplay */
+ dpy->last_req = (char *)&_dummy_request;
+
+ /* Initialize the display lock */
+ if (InitDisplayLock(dpy) != 0) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ if (!_XPollfdCacheInit(dpy)) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ /* Set up the output buffers. */
+#ifndef XLIBDEFAULTBUFSIZE
+#define XLIBDEFAULTBUFSIZE 16384 /* 16k */
+#endif
+#ifndef XLIBMINBUFSIZE
+#define XLIBMINBUFSIZE BUFSIZE /* old default buffer size */
+#endif
+ if ((xlib_buffer_size = getenv("XLIBBUFFERSIZE")) == NULL)
+ conn_buf_size = XLIBDEFAULTBUFSIZE;
+ else
+ conn_buf_size = 1024 * strtol(xlib_buffer_size, NULL, 10);
+ if (conn_buf_size < XLIBMINBUFSIZE)
+ conn_buf_size = XLIBMINBUFSIZE;
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf (stderr, "Xlib: Running with XLIBBUFFERSIZE [%d] XLIBMINBUFSIZE [%d] "
+ "buffer size [%ld].\n", XLIBDEFAULTBUFSIZE, XLIBMINBUFSIZE, conn_buf_size);
+#endif
+
+ if ((dpy->bufptr = dpy->buffer = Xcalloc(1, conn_buf_size)) == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ dpy->bufmax = dpy->buffer + conn_buf_size;
+
+ /* Set up the input event queue and input event queue parameters. */
+ dpy->head = dpy->tail = NULL;
+ dpy->qlen = 0;
+
+ /* Set up free-function record */
+ if ((dpy->free_funcs = (_XFreeFuncRec *)Xcalloc(1,
+ sizeof(_XFreeFuncRec)))
+ == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+/*
+ * The xConnClientPrefix describes the initial connection setup information
+ * and is followed by the authorization information. Sites that are interested
+ * in security are strongly encouraged to use an authentication and
+ * authorization system such as Kerberos.
+ */
+ endian = 1;
+ if (*(char *) &endian)
+ client.byteOrder = '\154'; /* 'l' */
+ else
+ client.byteOrder = '\102'; /* 'B' */
+ client.majorVersion = X_PROTOCOL;
+ client.minorVersion = X_PROTOCOL_REVISION;
+ client.nbytesAuthProto = conn_auth_namelen;
+ client.nbytesAuthString = conn_auth_datalen;
+ prefixread = _XSendClientPrefix(dpy, &client,
+ conn_auth_name, conn_auth_data,
+ &prefix);
+ if (prefixread < 0)
+ {
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+ if (conn_auth_name) Xfree(conn_auth_name);
+ if (conn_auth_data) Xfree(conn_auth_data);
+/*
+ * Now see if connection was accepted...
+ */
+ /* these internal functions expect the display to be locked */
+ LockDisplay(dpy);
+
+ if (prefixread == 0)
+ _XRead (dpy, (char *)&prefix,(long)SIZEOF(xConnSetupPrefix));
+
+ /* an Authenticate reply we weren't expecting? */
+ if (prefix.success != xTrue && prefix.success != xFalse) {
+ fprintf (stderr,
+ "Xlib: unexpected connection setup reply from server, type %d.\r\n",
+ prefix.success);
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+
+ if (prefix.majorVersion != X_PROTOCOL) {
+ /* XXX - printing messages marks a bad programming interface */
+#ifdef NX_TRANS_SOCKET
+ if (_X11TransSocketProxyConnInfo(dpy->trans_conn) == NULL) {
+ fprintf (stderr, "Xlib: client uses different protocol version (%d) "
+ "than server (%d)!\r\n", X_PROTOCOL, prefix.majorVersion);
+ }
+#else
+ fprintf (stderr,
+ "Xlib: client uses different protocol version (%d) than server (%d)!\r\n",
+ X_PROTOCOL, prefix.majorVersion);
+#endif
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+
+ setuplength = prefix.length << 2;
+ if ( (u.setup = (xConnSetup *)
+ (setup = Xmalloc ((unsigned) setuplength))) == NULL) {
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+ _XRead (dpy, (char *)u.setup, setuplength);
+
+/*
+ * If the connection was not accepted by the server due to problems,
+ * give error message to the user....
+ */
+ if (prefix.success != xTrue) {
+ /* XXX - printing messages marks a bad programming interface */
+ fprintf (stderr,
+ "Xlib: connection to \"%s\" refused by server\r\nXlib: ",
+ fullname);
+
+ if (prefix.lengthReason > setuplength) {
+ fprintf (stderr, "Xlib: Broken initial reply: length of reason > length of packet\r\n");
+ }else{
+ (void) fwrite (u.failure, (Size_t)sizeof(char),
+ (Size_t)prefix.lengthReason, stderr);
+ (void) fwrite ("\r\n", sizeof(char), 2, stderr);
+ }
+
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+/*
+ * Check if the reply was long enough to get any information out of it.
+ */
+ usedbytes = sz_xConnSetup;
+ if (setuplength < usedbytes ) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+/*
+ * We succeeded at authorization, so let us move the data into
+ * the display structure.
+ */
+ dpy->proto_major_version= prefix.majorVersion;
+ dpy->proto_minor_version= prefix.minorVersion;
+ dpy->release = u.setup->release;
+ dpy->resource_base = u.setup->ridBase;
+ dpy->resource_mask = u.setup->ridMask;
+ dpy->min_keycode = u.setup->minKeyCode;
+ dpy->max_keycode = u.setup->maxKeyCode;
+ dpy->motion_buffer = u.setup->motionBufferSize;
+ dpy->nformats = u.setup->numFormats;
+ dpy->nscreens = u.setup->numRoots;
+ dpy->byte_order = u.setup->imageByteOrder;
+ dpy->bitmap_unit = u.setup->bitmapScanlineUnit;
+ dpy->bitmap_pad = u.setup->bitmapScanlinePad;
+ dpy->bitmap_bit_order = u.setup->bitmapBitOrder;
+ dpy->max_request_size = u.setup->maxRequestSize;
+ mask = dpy->resource_mask;
+ dpy->resource_shift = 0;
+ if (!mask)
+ {
+ fprintf (stderr, "Xlib: connection to \"%s\" invalid setup\n",
+ fullname);
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+ while (!(mask & 1)) {
+ dpy->resource_shift++;
+ mask = mask >> 1;
+ }
+ dpy->resource_max = (dpy->resource_mask >> dpy->resource_shift) - 5;
+/*
+ * now extract the vendor string... String must be null terminated,
+ * padded to multiple of 4 bytes.
+ */
+ /* Check for a sane vendor string length */
+ if (u.setup->nbytesVendor > 256) {
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+ dpy->vendor = (char *) Xmalloc((unsigned) (u.setup->nbytesVendor + 1));
+ if (dpy->vendor == NULL) {
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+ vendorlen = u.setup->nbytesVendor;
+
+/*
+ * validate setup length
+ */
+ usedbytes += (vendorlen + 3) & ~3;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+ u.setup = (xConnSetup *) (((char *) u.setup) + sz_xConnSetup);
+ (void) strncpy(dpy->vendor, u.vendor, vendorlen);
+ dpy->vendor[vendorlen] = '\0';
+ vendorlen = (vendorlen + 3) & ~3; /* round up */
+
+
+ memmove (setup, u.vendor + vendorlen,
+ (int) setuplength - sz_xConnSetup - vendorlen);
+ u.vendor = setup;
+/*
+ * Now iterate down setup information.....
+ */
+ dpy->pixmap_format =
+ (ScreenFormat *)Xmalloc(
+ (unsigned) (dpy->nformats *sizeof(ScreenFormat)));
+ if (dpy->pixmap_format == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+/*
+ * First decode the Z axis Screen format information.
+ */
+ usedbytes += dpy->nformats * sz_xPixmapFormat;
+
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ for (i = 0; i < dpy->nformats; i++) {
+ register ScreenFormat *fmt = &dpy->pixmap_format[i];
+ fmt->depth = u.sf->depth;
+ fmt->bits_per_pixel = u.sf->bitsPerPixel;
+ fmt->scanline_pad = u.sf->scanLinePad;
+ fmt->ext_data = NULL;
+ u.sf = (xPixmapFormat *) (((char *) u.sf) + sz_xPixmapFormat);
+ }
+
+/*
+ * next the Screen structures.
+ */
+ dpy->screens =
+ (Screen *)Xmalloc((unsigned) dpy->nscreens*sizeof(Screen));
+ if (dpy->screens == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+/*
+ * Now go deal with each screen structure.
+ */
+ for (i = 0; i < dpy->nscreens; i++) {
+ register Screen *sp = &dpy->screens[i];
+ VisualID root_visualID;
+
+ usedbytes += sz_xWindowRoot;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ root_visualID = u.rp->rootVisualID;
+ sp->display = dpy;
+ sp->root = u.rp->windowId;
+ sp->cmap = u.rp->defaultColormap;
+ sp->white_pixel = u.rp->whitePixel;
+ sp->black_pixel = u.rp->blackPixel;
+ sp->root_input_mask = u.rp->currentInputMask;
+ sp->width = u.rp->pixWidth;
+ sp->height = u.rp->pixHeight;
+ sp->mwidth = u.rp->mmWidth;
+ sp->mheight = u.rp->mmHeight;
+ sp->min_maps = u.rp->minInstalledMaps;
+ sp->max_maps = u.rp->maxInstalledMaps;
+ sp->backing_store= u.rp->backingStore;
+ sp->save_unders = u.rp->saveUnders;
+ sp->root_depth = u.rp->rootDepth;
+ sp->ndepths = u.rp->nDepths;
+ sp->ext_data = NULL;
+ u.rp = (xWindowRoot *) (((char *) u.rp) + sz_xWindowRoot);
+/*
+ * lets set up the depth structures.
+ */
+ sp->depths = (Depth *)Xmalloc(
+ (unsigned)sp->ndepths*sizeof(Depth));
+ if (sp->depths == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ /*
+ * for all depths on this screen.
+ */
+ for (j = 0; j < sp->ndepths; j++) {
+ Depth *dp = &sp->depths[j];
+
+ usedbytes += sz_xDepth;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ dp->depth = u.dp->depth;
+ dp->nvisuals = u.dp->nVisuals;
+ u.dp = (xDepth *) (((char *) u.dp) + sz_xDepth);
+ if (dp->nvisuals > 0) {
+ dp->visuals =
+ (Visual *)Xmalloc((unsigned)dp->nvisuals*sizeof(Visual));
+ if (dp->visuals == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ for (k = 0; k < dp->nvisuals; k++) {
+ register Visual *vp = &dp->visuals[k];
+
+ usedbytes += sz_xVisualType;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ vp->visualid = u.vp->visualID;
+ vp->class = u.vp->class;
+ vp->bits_per_rgb= u.vp->bitsPerRGB;
+ vp->map_entries = u.vp->colormapEntries;
+ vp->red_mask = u.vp->redMask;
+ vp->green_mask = u.vp->greenMask;
+ vp->blue_mask = u.vp->blueMask;
+ vp->ext_data = NULL;
+ u.vp = (xVisualType *) (((char *) u.vp) +
+ sz_xVisualType);
+ }
+ if (dp->depth == 32 && getenv ("XLIB_SKIP_ARGB_VISUALS"))
+ {
+ Xfree (dp->visuals);
+ dp->visuals = NULL;
+ dp->nvisuals = 0;
+ }
+ } else {
+ dp->visuals = (Visual *) NULL;
+ }
+ }
+ sp->root_visual = _XVIDtoVisual(dpy, root_visualID);
+ }
+
+ if(usedbytes != setuplength){
+ /* Sanity check, shouldn't happen. */
+ fprintf(stderr, "Xlib: Did not parse entire setup message: "
+ "parsed: %ld, message: %ld\n",
+ usedbytes, setuplength);
+ OutOfMemory(dpy, setup);
+ return(NULL);
+ }
+
+/*
+ * Now start talking to the server to setup all other information...
+ */
+
+ Xfree (setup); /* all finished with setup information */
+
+/*
+ * Make sure default screen is legal.
+ */
+ if (iscreen >= dpy->nscreens) {
+ OutOfMemory(dpy, (char *) NULL);
+ return(NULL);
+ }
+
+/*
+ * finished calling internal routines, now unlock for external routines
+ */
+ UnlockDisplay(dpy);
+
+/*
+ * Set up other stuff clients are always going to use.
+ */
+ for (i = 0; i < dpy->nscreens; i++) {
+ register Screen *sp = &dpy->screens[i];
+ XGCValues values;
+ values.foreground = sp->black_pixel;
+ values.background = sp->white_pixel;
+ if ((sp->default_gc = XCreateGC (dpy, sp->root,
+ GCForeground|GCBackground,
+ &values)) == NULL) {
+ OutOfMemory(dpy, (char *) NULL);
+ return (NULL);
+ }
+ }
+/*
+ * call into synchronization routine so that all programs can be
+ * forced synchronous
+ */
+ (void) XSynchronize(dpy, _Xdebug);
+
+/*
+ * get availability of large requests, and
+ * get the resource manager database off the root window.
+ */
+ LockDisplay(dpy);
+ {
+ _XAsyncHandler async;
+ _XBigReqState async_state;
+ xQueryExtensionReq *qreq;
+ xGetPropertyReply reply;
+ xGetPropertyReq *req;
+ xBigReqEnableReq *breq;
+ xBigReqEnableReply brep;
+
+ GetReq(QueryExtension, qreq);
+ async_state.seq = dpy->request;
+ async_state.opcode = 0;
+ async.next = dpy->async_handlers;
+ async.handler = _XBigReqHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+ qreq->nbytes = bignamelen;
+ qreq->length += (bignamelen+3)>>2;
+ Data(dpy, XBigReqExtensionName, bignamelen);
+
+ GetReq (GetProperty, req);
+ req->window = RootWindow(dpy, 0);
+ req->property = XA_RESOURCE_MANAGER;
+ req->type = XA_STRING;
+ req->delete = False;
+ req->longOffset = 0;
+ req->longLength = 100000000L;
+
+ if (_XReply (dpy, (xReply *) &reply, 0, xFalse)) {
+ if (reply.format == 8 && reply.propertyType == XA_STRING &&
+ (reply.nItems + 1 > 0) &&
+ (reply.nItems <= req->longLength * 4) &&
+ (dpy->xdefaults = Xmalloc (reply.nItems + 1))) {
+ _XReadPad (dpy, dpy->xdefaults, reply.nItems);
+ dpy->xdefaults[reply.nItems] = '\0';
+ }
+ else if (reply.propertyType != None)
+ _XEatData(dpy, reply.nItems * (reply.format >> 3));
+ }
+ DeqAsyncHandler(dpy, &async);
+ if (async_state.opcode) {
+ GetReq(BigReqEnable, breq);
+ breq->reqType = async_state.opcode;
+ breq->brReqType = X_BigReqEnable;
+ if (_XReply(dpy, (xReply *)&brep, 0, xFalse))
+ dpy->bigreq_size = brep.max_request_size;
+ }
+ }
+ UnlockDisplay(dpy);
+
+#ifdef MOTIFBC
+ {
+ extern Display *_XHeadOfDisplayList;
+ _XHeadOfDisplayList = dpy;
+ }
+#endif
+#ifdef XKB
+ XkbUseExtension(dpy,NULL,NULL);
+#endif
+/*
+ * and return successfully
+ */
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "XOpenDisplay: Returning display at [%p].\n", dpy);
+#endif
+ return(dpy);
+}
+
+static Bool
+_XBigReqHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ _XBigReqState *state;
+ xQueryExtensionReply replbuf;
+ xQueryExtensionReply *repl;
+
+ state = (_XBigReqState *)data;
+ if (dpy->last_request_read != state->seq)
+ return False;
+ if (rep->generic.type == X_Error)
+ return True;
+ repl = (xQueryExtensionReply *)
+ _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
+ (SIZEOF(xQueryExtensionReply) - SIZEOF(xReply)) >> 2,
+ True);
+ if (repl->present)
+ state->opcode = repl->major_opcode;
+ return True;
+}
+
+
+/* XFreeDisplayStructure frees all the storage associated with a
+ * Display. It is used by XOpenDisplay if it runs out of memory,
+ * and also by XCloseDisplay. It needs to check whether all pointers
+ * are non-NULL before dereferencing them, since it may be called
+ * by XOpenDisplay before the Display structure is fully formed.
+ * XOpenDisplay must be sure to initialize all the pointers to NULL
+ * before the first possible call on this.
+ */
+
+void _XFreeDisplayStructure(dpy)
+ register Display *dpy;
+{
+ while (dpy->ext_procs) {
+ _XExtension *ext = dpy->ext_procs;
+ dpy->ext_procs = ext->next;
+ if (ext->name)
+ Xfree (ext->name);
+ Xfree ((char *)ext);
+ }
+ if (dpy->im_filters)
+ (*dpy->free_funcs->im_filters)(dpy);
+ if (dpy->cms.clientCmaps)
+ (*dpy->free_funcs->clientCmaps)(dpy);
+ if (dpy->cms.defaultCCCs)
+ (*dpy->free_funcs->defaultCCCs)(dpy);
+ if (dpy->cms.perVisualIntensityMaps)
+ (*dpy->free_funcs->intensityMaps)(dpy);
+ if (dpy->atoms)
+ (*dpy->free_funcs->atoms)(dpy);
+ if (dpy->modifiermap)
+ (*dpy->free_funcs->modifiermap)(dpy->modifiermap);
+ if (dpy->key_bindings)
+ (*dpy->free_funcs->key_bindings)(dpy);
+ if (dpy->context_db)
+ (*dpy->free_funcs->context_db)(dpy);
+ if (dpy->xkb_info)
+ (*dpy->free_funcs->xkb)(dpy);
+
+ /* if RM database was allocated by XGetDefault() free it */
+ if (dpy->db && (dpy->flags & XlibDisplayDfltRMDB))
+ XrmDestroyDatabase(dpy->db);
+
+ if (dpy->screens) {
+ register int i;
+
+ for (i = 0; i < dpy->nscreens; i++) {
+ Screen *sp = &dpy->screens[i];
+
+ if (sp->depths) {
+ register int j;
+
+ for (j = 0; j < sp->ndepths; j++) {
+ Depth *dp = &sp->depths[j];
+
+ if (dp->visuals) {
+ register int k;
+
+ for (k = 0; k < dp->nvisuals; k++)
+ _XFreeExtData (dp->visuals[k].ext_data);
+ Xfree ((char *) dp->visuals);
+ }
+ }
+
+ Xfree ((char *) sp->depths);
+ }
+
+ _XFreeExtData (sp->ext_data);
+ }
+
+ Xfree ((char *)dpy->screens);
+ }
+
+ if (dpy->pixmap_format) {
+ register int i;
+
+ for (i = 0; i < dpy->nformats; i++)
+ _XFreeExtData (dpy->pixmap_format[i].ext_data);
+ Xfree ((char *)dpy->pixmap_format);
+ }
+
+ if (dpy->display_name)
+ Xfree (dpy->display_name);
+ if (dpy->vendor)
+ Xfree (dpy->vendor);
+
+ if (dpy->buffer)
+ Xfree (dpy->buffer);
+ if (dpy->keysyms)
+ Xfree ((char *) dpy->keysyms);
+ if (dpy->xdefaults)
+ Xfree (dpy->xdefaults);
+ if (dpy->error_vec)
+ Xfree ((char *)dpy->error_vec);
+
+ _XFreeExtData (dpy->ext_data);
+ if (dpy->free_funcs)
+ Xfree ((char *)dpy->free_funcs);
+ if (dpy->scratch_buffer)
+ Xfree (dpy->scratch_buffer);
+ FreeDisplayLock(dpy);
+
+ if (dpy->qfree) {
+ register _XQEvent *qelt = dpy->qfree;
+
+ while (qelt) {
+ register _XQEvent *qnxt = qelt->next;
+ Xfree ((char *) qelt);
+ qelt = qnxt;
+ }
+ }
+ while (dpy->im_fd_info) {
+ struct _XConnectionInfo *conni = dpy->im_fd_info;
+ dpy->im_fd_info = conni->next;
+ if (conni->watch_data)
+ Xfree (conni->watch_data);
+ Xfree (conni);
+ }
+ if (dpy->conn_watchers) {
+ struct _XConnWatchInfo *watcher = dpy->conn_watchers;
+ dpy->conn_watchers = watcher->next;
+ Xfree (watcher);
+ }
+ if (dpy->filedes)
+ Xfree (dpy->filedes);
+
+ Xfree ((char *)dpy);
+}
+
+/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL
+ after this returns. */
+
+static void OutOfMemory (dpy, setup)
+ Display *dpy;
+ char *setup;
+{
+ _XDisconnectDisplay (dpy->trans_conn);
+ _XFreeDisplayStructure (dpy);
+ if (setup) Xfree (setup);
+}
diff --git a/nx-X11/lib/X11/OpenDis.c.X.original b/nx-X11/lib/X11/OpenDis.c.X.original
new file mode 100644
index 000000000..121291b5f
--- /dev/null
+++ b/nx-X11/lib/X11/OpenDis.c.X.original
@@ -0,0 +1,869 @@
+/* $Xorg: OpenDis.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 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.
+
+*/
+/* $XFree86: xc/lib/X11/OpenDis.c,v 3.16 2003/07/04 16:24:23 eich Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/Xatom.h>
+#include <X11/Xresource.h>
+#include <X11/extensions/bigreqstr.h>
+#include <stdio.h>
+#include "Xintconn.h"
+
+#ifdef XKB
+#include "XKBlib.h"
+#endif /* XKB */
+
+#ifdef X_NOT_POSIX
+#define Size_t unsigned int
+#else
+#define Size_t size_t
+#endif
+
+#define bignamelen (sizeof(XBigReqExtensionName) - 1)
+
+typedef struct {
+ unsigned long seq;
+ int opcode;
+} _XBigReqState;
+
+#ifdef XTHREADS
+#include "locking.h"
+int (*_XInitDisplayLock_fn)(Display *dpy) = NULL;
+void (*_XFreeDisplayLock_fn)(Display *dpy) = NULL;
+
+#define InitDisplayLock(d) (_XInitDisplayLock_fn ? (*_XInitDisplayLock_fn)(d) : Success)
+#define FreeDisplayLock(d) if (_XFreeDisplayLock_fn) (*_XFreeDisplayLock_fn)(d)
+#else
+#define InitDisplayLock(dis) Success
+#define FreeDisplayLock(dis)
+#endif /* XTHREADS */
+
+static xReq _dummy_request = {
+ 0, 0, 0
+};
+
+static void OutOfMemory(Display *dpy, char *setup);
+static Bool _XBigReqHandler(Display *dpy, xReply *rep, char *buf, int len,
+ XPointer data);
+
+/*
+ * Connects to a server, creates a Display object and returns a pointer to
+ * the newly created Display back to the caller.
+ */
+Display *
+XOpenDisplay (
+ register _Xconst char *display)
+{
+ register Display *dpy; /* New Display object being created. */
+ register int i;
+ int j, k; /* random iterator indexes */
+ char *display_name; /* pointer to display name */
+ int endian; /* to determine which endian. */
+ xConnClientPrefix client; /* client information */
+ xConnSetupPrefix prefix; /* prefix information */
+ int vendorlen; /* length of vendor string */
+ char *setup = NULL; /* memory allocated at startup */
+ char *fullname = NULL; /* expanded name of display */
+ int idisplay; /* display number */
+ int iscreen; /* screen number */
+ int prefixread = 0; /* setup prefix already read? */
+ union {
+ xConnSetup *setup;
+ char *failure;
+ char *vendor;
+ xPixmapFormat *sf;
+ xWindowRoot *rp;
+ xDepth *dp;
+ xVisualType *vp;
+ } u; /* proto data returned from server */
+ long setuplength; /* number of bytes in setup message */
+ long usedbytes = 0; /* number of bytes we have processed */
+ char *conn_auth_name, *conn_auth_data;
+ int conn_auth_namelen, conn_auth_datalen;
+ unsigned long mask;
+ long int conn_buf_size;
+ char *xlib_buffer_size;
+
+ bzero((char *) &client, sizeof(client));
+ bzero((char *) &prefix, sizeof(prefix));
+
+ /*
+ * If the display specifier string supplied as an argument to this
+ * routine is NULL or a pointer to NULL, read the DISPLAY variable.
+ */
+ if (display == NULL || *display == '\0') {
+ if ((display_name = getenv("DISPLAY")) == NULL) {
+ /* Oops! No DISPLAY environment variable - error. */
+ return(NULL);
+ }
+ }
+ else {
+ /* Display is non-NULL, copy the pointer */
+ display_name = (char *)display;
+ }
+/*
+ * Set the default error handlers. This allows the global variables to
+ * default to NULL for use with shared libraries.
+ */
+ if (_XErrorFunction == NULL) (void) XSetErrorHandler (NULL);
+ if (_XIOErrorFunction == NULL) (void) XSetIOErrorHandler (NULL);
+
+/*
+ * Attempt to allocate a display structure. Return NULL if allocation fails.
+ */
+ if ((dpy = (Display *)Xcalloc(1, sizeof(Display))) == NULL) {
+ return(NULL);
+ }
+
+/*
+ * Call the Connect routine to get the transport connection object.
+ * If NULL is returned, the connection failed. The connect routine
+ * will set fullname to point to the expanded name.
+ */
+
+ if ((dpy->trans_conn = _X11TransConnectDisplay (
+ display_name, &fullname, &idisplay,
+ &iscreen, &conn_auth_name,
+ &conn_auth_namelen, &conn_auth_data,
+ &conn_auth_datalen)) == NULL) {
+ Xfree ((char *) dpy);
+ return(NULL);
+ }
+
+ dpy->fd = _X11TransGetConnectionNumber (dpy->trans_conn);
+
+ /* Initialize as much of the display structure as we can.
+ * Initialize pointers to NULL so that XFreeDisplayStructure will
+ * work if we run out of memory before we finish initializing.
+ */
+ dpy->display_name = fullname;
+ dpy->keysyms = (KeySym *) NULL;
+ dpy->modifiermap = NULL;
+ dpy->lock_meaning = NoSymbol;
+ dpy->keysyms_per_keycode = 0;
+ dpy->xdefaults = (char *)NULL;
+ dpy->scratch_length = 0L;
+ dpy->scratch_buffer = NULL;
+ dpy->key_bindings = NULL;
+ dpy->ext_procs = (_XExtension *)NULL;
+ dpy->ext_data = (XExtData *)NULL;
+ dpy->ext_number = 0;
+ dpy->event_vec[X_Error] = _XUnknownWireEvent;
+ dpy->event_vec[X_Reply] = _XUnknownWireEvent;
+ dpy->wire_vec[X_Error] = _XUnknownNativeEvent;
+ dpy->wire_vec[X_Reply] = _XUnknownNativeEvent;
+ for (i = KeyPress; i < LASTEvent; i++) {
+ dpy->event_vec[i] = _XWireToEvent;
+ dpy->wire_vec[i] = NULL;
+ }
+ for (i = LASTEvent; i < 128; i++) {
+ dpy->event_vec[i] = _XUnknownWireEvent;
+ dpy->wire_vec[i] = _XUnknownNativeEvent;
+ }
+ dpy->resource_id = 0;
+ dpy->db = (struct _XrmHashBucketRec *)NULL;
+ dpy->cursor_font = None;
+ dpy->flags = 0;
+ dpy->async_handlers = NULL;
+ dpy->screens = NULL;
+ dpy->vendor = NULL;
+ dpy->buffer = NULL;
+ dpy->atoms = NULL;
+ dpy->error_vec = NULL;
+ dpy->context_db = NULL;
+ dpy->free_funcs = NULL;
+ dpy->pixmap_format = NULL;
+ dpy->cms.clientCmaps = NULL;
+ dpy->cms.defaultCCCs = NULL;
+ dpy->cms.perVisualIntensityMaps = NULL;
+ dpy->im_filters = NULL;
+ dpy->bigreq_size = 0;
+ dpy->lock = NULL;
+ dpy->lock_fns = NULL;
+ dpy->qfree = NULL;
+ dpy->next_event_serial_num = 1;
+ dpy->im_fd_info = NULL;
+ dpy->im_fd_length = 0;
+ dpy->conn_watchers = NULL;
+ dpy->watcher_count = 0;
+ dpy->filedes = NULL;
+ dpy->flushes = NULL;
+ dpy->xcmisc_opcode = 0;
+ dpy->xkb_info = NULL;
+
+/*
+ * Setup other information in this display structure.
+ */
+ dpy->vnumber = X_PROTOCOL;
+ dpy->resource_alloc = _XAllocID;
+ dpy->idlist_alloc = _XAllocIDs;
+ dpy->synchandler = NULL;
+ dpy->savedsynchandler = NULL;
+ dpy->request = 0;
+ dpy->last_request_read = 0;
+ dpy->default_screen = iscreen; /* Value returned by ConnectDisplay */
+ dpy->last_req = (char *)&_dummy_request;
+
+ /* Initialize the display lock */
+ if (InitDisplayLock(dpy) != 0) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ if (!_XPollfdCacheInit(dpy)) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ /* Set up the output buffers. */
+#ifndef XLIBDEFAULTBUFSIZE
+#define XLIBDEFAULTBUFSIZE 16384 /* 16k */
+#endif
+#ifndef XLIBMINBUFSIZE
+#define XLIBMINBUFSIZE BUFSIZE /* old default buffer size */
+#endif
+ if ((xlib_buffer_size = getenv("XLIBBUFFERSIZE")) == NULL)
+ conn_buf_size = XLIBDEFAULTBUFSIZE;
+ else
+ conn_buf_size = 1024 * strtol(xlib_buffer_size, NULL, 10);
+ if (conn_buf_size < XLIBMINBUFSIZE)
+ conn_buf_size = XLIBMINBUFSIZE;
+
+ if ((dpy->bufptr = dpy->buffer = Xcalloc(1, conn_buf_size)) == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ dpy->bufmax = dpy->buffer + conn_buf_size;
+
+ /* Set up the input event queue and input event queue parameters. */
+ dpy->head = dpy->tail = NULL;
+ dpy->qlen = 0;
+
+ /* Set up free-function record */
+ if ((dpy->free_funcs = (_XFreeFuncRec *)Xcalloc(1,
+ sizeof(_XFreeFuncRec)))
+ == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+/*
+ * The xConnClientPrefix describes the initial connection setup information
+ * and is followed by the authorization information. Sites that are interested
+ * in security are strongly encouraged to use an authentication and
+ * authorization system such as Kerberos.
+ */
+ endian = 1;
+ if (*(char *) &endian)
+ client.byteOrder = '\154'; /* 'l' */
+ else
+ client.byteOrder = '\102'; /* 'B' */
+ client.majorVersion = X_PROTOCOL;
+ client.minorVersion = X_PROTOCOL_REVISION;
+ client.nbytesAuthProto = conn_auth_namelen;
+ client.nbytesAuthString = conn_auth_datalen;
+ prefixread = _XSendClientPrefix(dpy, &client,
+ conn_auth_name, conn_auth_data,
+ &prefix);
+ if (prefixread < 0)
+ {
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+ if (conn_auth_name) Xfree(conn_auth_name);
+ if (conn_auth_data) Xfree(conn_auth_data);
+/*
+ * Now see if connection was accepted...
+ */
+ /* these internal functions expect the display to be locked */
+ LockDisplay(dpy);
+
+ if (prefixread == 0)
+ _XRead (dpy, (char *)&prefix,(long)SIZEOF(xConnSetupPrefix));
+
+ /* an Authenticate reply we weren't expecting? */
+ if (prefix.success != xTrue && prefix.success != xFalse) {
+ fprintf (stderr,
+ "Xlib: unexpected connection setup reply from server, type %d.\r\n",
+ prefix.success);
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+
+ if (prefix.majorVersion != X_PROTOCOL) {
+ /* XXX - printing messages marks a bad programming interface */
+ fprintf (stderr,
+ "Xlib: client uses different protocol version (%d) than server (%d)!\r\n",
+ X_PROTOCOL, prefix.majorVersion);
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+
+ setuplength = prefix.length << 2;
+ if ( (u.setup = (xConnSetup *)
+ (setup = Xmalloc ((unsigned) setuplength))) == NULL) {
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+ _XRead (dpy, (char *)u.setup, setuplength);
+
+/*
+ * If the connection was not accepted by the server due to problems,
+ * give error message to the user....
+ */
+ if (prefix.success != xTrue) {
+ /* XXX - printing messages marks a bad programming interface */
+ fprintf (stderr,
+ "Xlib: connection to \"%s\" refused by server\r\nXlib: ",
+ fullname);
+
+ if (prefix.lengthReason > setuplength) {
+ fprintf (stderr, "Xlib: Broken initial reply: length of reason > length of packet\r\n");
+ }else{
+ (void) fwrite (u.failure, (Size_t)sizeof(char),
+ (Size_t)prefix.lengthReason, stderr);
+ (void) fwrite ("\r\n", sizeof(char), 2, stderr);
+ }
+
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+/*
+ * Check if the reply was long enough to get any information out of it.
+ */
+ usedbytes = sz_xConnSetup;
+ if (setuplength < usedbytes ) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+/*
+ * We succeeded at authorization, so let us move the data into
+ * the display structure.
+ */
+ dpy->proto_major_version= prefix.majorVersion;
+ dpy->proto_minor_version= prefix.minorVersion;
+ dpy->release = u.setup->release;
+ dpy->resource_base = u.setup->ridBase;
+ dpy->resource_mask = u.setup->ridMask;
+ dpy->min_keycode = u.setup->minKeyCode;
+ dpy->max_keycode = u.setup->maxKeyCode;
+ dpy->motion_buffer = u.setup->motionBufferSize;
+ dpy->nformats = u.setup->numFormats;
+ dpy->nscreens = u.setup->numRoots;
+ dpy->byte_order = u.setup->imageByteOrder;
+ dpy->bitmap_unit = u.setup->bitmapScanlineUnit;
+ dpy->bitmap_pad = u.setup->bitmapScanlinePad;
+ dpy->bitmap_bit_order = u.setup->bitmapBitOrder;
+ dpy->max_request_size = u.setup->maxRequestSize;
+ mask = dpy->resource_mask;
+ dpy->resource_shift = 0;
+ if (!mask)
+ {
+ fprintf (stderr, "Xlib: connection to \"%s\" invalid setup\n",
+ fullname);
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+ while (!(mask & 1)) {
+ dpy->resource_shift++;
+ mask = mask >> 1;
+ }
+ dpy->resource_max = (dpy->resource_mask >> dpy->resource_shift) - 5;
+/*
+ * now extract the vendor string... String must be null terminated,
+ * padded to multiple of 4 bytes.
+ */
+ /* Check for a sane vendor string length */
+ if (u.setup->nbytesVendor > 256) {
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+ dpy->vendor = (char *) Xmalloc((unsigned) (u.setup->nbytesVendor + 1));
+ if (dpy->vendor == NULL) {
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+ vendorlen = u.setup->nbytesVendor;
+
+/*
+ * validate setup length
+ */
+ usedbytes += (vendorlen + 3) & ~3;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+ u.setup = (xConnSetup *) (((char *) u.setup) + sz_xConnSetup);
+ (void) strncpy(dpy->vendor, u.vendor, vendorlen);
+ dpy->vendor[vendorlen] = '\0';
+ vendorlen = (vendorlen + 3) & ~3; /* round up */
+
+
+ memmove (setup, u.vendor + vendorlen,
+ (int) setuplength - sz_xConnSetup - vendorlen);
+ u.vendor = setup;
+/*
+ * Now iterate down setup information.....
+ */
+ dpy->pixmap_format =
+ (ScreenFormat *)Xmalloc(
+ (unsigned) (dpy->nformats *sizeof(ScreenFormat)));
+ if (dpy->pixmap_format == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+/*
+ * First decode the Z axis Screen format information.
+ */
+ usedbytes += dpy->nformats * sz_xPixmapFormat;
+
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ for (i = 0; i < dpy->nformats; i++) {
+ register ScreenFormat *fmt = &dpy->pixmap_format[i];
+ fmt->depth = u.sf->depth;
+ fmt->bits_per_pixel = u.sf->bitsPerPixel;
+ fmt->scanline_pad = u.sf->scanLinePad;
+ fmt->ext_data = NULL;
+ u.sf = (xPixmapFormat *) (((char *) u.sf) + sz_xPixmapFormat);
+ }
+
+/*
+ * next the Screen structures.
+ */
+ dpy->screens =
+ (Screen *)Xmalloc((unsigned) dpy->nscreens*sizeof(Screen));
+ if (dpy->screens == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+/*
+ * Now go deal with each screen structure.
+ */
+ for (i = 0; i < dpy->nscreens; i++) {
+ register Screen *sp = &dpy->screens[i];
+ VisualID root_visualID;
+
+ usedbytes += sz_xWindowRoot;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ root_visualID = u.rp->rootVisualID;
+ sp->display = dpy;
+ sp->root = u.rp->windowId;
+ sp->cmap = u.rp->defaultColormap;
+ sp->white_pixel = u.rp->whitePixel;
+ sp->black_pixel = u.rp->blackPixel;
+ sp->root_input_mask = u.rp->currentInputMask;
+ sp->width = u.rp->pixWidth;
+ sp->height = u.rp->pixHeight;
+ sp->mwidth = u.rp->mmWidth;
+ sp->mheight = u.rp->mmHeight;
+ sp->min_maps = u.rp->minInstalledMaps;
+ sp->max_maps = u.rp->maxInstalledMaps;
+ sp->backing_store= u.rp->backingStore;
+ sp->save_unders = u.rp->saveUnders;
+ sp->root_depth = u.rp->rootDepth;
+ sp->ndepths = u.rp->nDepths;
+ sp->ext_data = NULL;
+ u.rp = (xWindowRoot *) (((char *) u.rp) + sz_xWindowRoot);
+/*
+ * lets set up the depth structures.
+ */
+ sp->depths = (Depth *)Xmalloc(
+ (unsigned)sp->ndepths*sizeof(Depth));
+ if (sp->depths == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ /*
+ * for all depths on this screen.
+ */
+ for (j = 0; j < sp->ndepths; j++) {
+ Depth *dp = &sp->depths[j];
+
+ usedbytes += sz_xDepth;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ dp->depth = u.dp->depth;
+ dp->nvisuals = u.dp->nVisuals;
+ u.dp = (xDepth *) (((char *) u.dp) + sz_xDepth);
+ if (dp->nvisuals > 0) {
+ dp->visuals =
+ (Visual *)Xmalloc((unsigned)dp->nvisuals*sizeof(Visual));
+ if (dp->visuals == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ for (k = 0; k < dp->nvisuals; k++) {
+ register Visual *vp = &dp->visuals[k];
+
+ usedbytes += sz_xVisualType;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ vp->visualid = u.vp->visualID;
+ vp->class = u.vp->class;
+ vp->bits_per_rgb= u.vp->bitsPerRGB;
+ vp->map_entries = u.vp->colormapEntries;
+ vp->red_mask = u.vp->redMask;
+ vp->green_mask = u.vp->greenMask;
+ vp->blue_mask = u.vp->blueMask;
+ vp->ext_data = NULL;
+ u.vp = (xVisualType *) (((char *) u.vp) +
+ sz_xVisualType);
+ }
+ if (dp->depth == 32 && getenv ("XLIB_SKIP_ARGB_VISUALS"))
+ {
+ Xfree (dp->visuals);
+ dp->visuals = NULL;
+ dp->nvisuals = 0;
+ }
+ } else {
+ dp->visuals = (Visual *) NULL;
+ }
+ }
+ sp->root_visual = _XVIDtoVisual(dpy, root_visualID);
+ }
+
+ if(usedbytes != setuplength){
+ /* Sanity check, shouldn't happen. */
+ fprintf(stderr, "Xlib: Did not parse entire setup message: "
+ "parsed: %ld, message: %ld\n",
+ usedbytes, setuplength);
+ OutOfMemory(dpy, setup);
+ return(NULL);
+ }
+
+/*
+ * Now start talking to the server to setup all other information...
+ */
+
+ Xfree (setup); /* all finished with setup information */
+
+/*
+ * Make sure default screen is legal.
+ */
+ if (iscreen >= dpy->nscreens) {
+ OutOfMemory(dpy, (char *) NULL);
+ return(NULL);
+ }
+
+/*
+ * finished calling internal routines, now unlock for external routines
+ */
+ UnlockDisplay(dpy);
+
+/*
+ * Set up other stuff clients are always going to use.
+ */
+ for (i = 0; i < dpy->nscreens; i++) {
+ register Screen *sp = &dpy->screens[i];
+ XGCValues values;
+ values.foreground = sp->black_pixel;
+ values.background = sp->white_pixel;
+ if ((sp->default_gc = XCreateGC (dpy, sp->root,
+ GCForeground|GCBackground,
+ &values)) == NULL) {
+ OutOfMemory(dpy, (char *) NULL);
+ return (NULL);
+ }
+ }
+/*
+ * call into synchronization routine so that all programs can be
+ * forced synchronous
+ */
+ (void) XSynchronize(dpy, _Xdebug);
+
+/*
+ * get availability of large requests, and
+ * get the resource manager database off the root window.
+ */
+ LockDisplay(dpy);
+ {
+ _XAsyncHandler async;
+ _XBigReqState async_state;
+ xQueryExtensionReq *qreq;
+ xGetPropertyReply reply;
+ xGetPropertyReq *req;
+ xBigReqEnableReq *breq;
+ xBigReqEnableReply brep;
+
+ GetReq(QueryExtension, qreq);
+ async_state.seq = dpy->request;
+ async_state.opcode = 0;
+ async.next = dpy->async_handlers;
+ async.handler = _XBigReqHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+ qreq->nbytes = bignamelen;
+ qreq->length += (bignamelen+3)>>2;
+ Data(dpy, XBigReqExtensionName, bignamelen);
+
+ GetReq (GetProperty, req);
+ req->window = RootWindow(dpy, 0);
+ req->property = XA_RESOURCE_MANAGER;
+ req->type = XA_STRING;
+ req->delete = False;
+ req->longOffset = 0;
+ req->longLength = 100000000L;
+
+ if (_XReply (dpy, (xReply *) &reply, 0, xFalse)) {
+ if (reply.format == 8 && reply.propertyType == XA_STRING &&
+ (reply.nItems + 1 > 0) &&
+ (reply.nItems <= req->longLength * 4) &&
+ (dpy->xdefaults = Xmalloc (reply.nItems + 1))) {
+ _XReadPad (dpy, dpy->xdefaults, reply.nItems);
+ dpy->xdefaults[reply.nItems] = '\0';
+ }
+ else if (reply.propertyType != None)
+ _XEatData(dpy, reply.nItems * (reply.format >> 3));
+ }
+ DeqAsyncHandler(dpy, &async);
+ if (async_state.opcode) {
+ GetReq(BigReqEnable, breq);
+ breq->reqType = async_state.opcode;
+ breq->brReqType = X_BigReqEnable;
+ if (_XReply(dpy, (xReply *)&brep, 0, xFalse))
+ dpy->bigreq_size = brep.max_request_size;
+ }
+ }
+ UnlockDisplay(dpy);
+
+#ifdef MOTIFBC
+ {
+ extern Display *_XHeadOfDisplayList;
+ _XHeadOfDisplayList = dpy;
+ }
+#endif
+#ifdef XKB
+ XkbUseExtension(dpy,NULL,NULL);
+#endif
+/*
+ * and return successfully
+ */
+ return(dpy);
+}
+
+static Bool
+_XBigReqHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ _XBigReqState *state;
+ xQueryExtensionReply replbuf;
+ xQueryExtensionReply *repl;
+
+ state = (_XBigReqState *)data;
+ if (dpy->last_request_read != state->seq)
+ return False;
+ if (rep->generic.type == X_Error)
+ return True;
+ repl = (xQueryExtensionReply *)
+ _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
+ (SIZEOF(xQueryExtensionReply) - SIZEOF(xReply)) >> 2,
+ True);
+ if (repl->present)
+ state->opcode = repl->major_opcode;
+ return True;
+}
+
+
+/* XFreeDisplayStructure frees all the storage associated with a
+ * Display. It is used by XOpenDisplay if it runs out of memory,
+ * and also by XCloseDisplay. It needs to check whether all pointers
+ * are non-NULL before dereferencing them, since it may be called
+ * by XOpenDisplay before the Display structure is fully formed.
+ * XOpenDisplay must be sure to initialize all the pointers to NULL
+ * before the first possible call on this.
+ */
+
+void _XFreeDisplayStructure(dpy)
+ register Display *dpy;
+{
+ while (dpy->ext_procs) {
+ _XExtension *ext = dpy->ext_procs;
+ dpy->ext_procs = ext->next;
+ if (ext->name)
+ Xfree (ext->name);
+ Xfree ((char *)ext);
+ }
+ if (dpy->im_filters)
+ (*dpy->free_funcs->im_filters)(dpy);
+ if (dpy->cms.clientCmaps)
+ (*dpy->free_funcs->clientCmaps)(dpy);
+ if (dpy->cms.defaultCCCs)
+ (*dpy->free_funcs->defaultCCCs)(dpy);
+ if (dpy->cms.perVisualIntensityMaps)
+ (*dpy->free_funcs->intensityMaps)(dpy);
+ if (dpy->atoms)
+ (*dpy->free_funcs->atoms)(dpy);
+ if (dpy->modifiermap)
+ (*dpy->free_funcs->modifiermap)(dpy->modifiermap);
+ if (dpy->key_bindings)
+ (*dpy->free_funcs->key_bindings)(dpy);
+ if (dpy->context_db)
+ (*dpy->free_funcs->context_db)(dpy);
+ if (dpy->xkb_info)
+ (*dpy->free_funcs->xkb)(dpy);
+
+ /* if RM database was allocated by XGetDefault() free it */
+ if (dpy->db && (dpy->flags & XlibDisplayDfltRMDB))
+ XrmDestroyDatabase(dpy->db);
+
+ if (dpy->screens) {
+ register int i;
+
+ for (i = 0; i < dpy->nscreens; i++) {
+ Screen *sp = &dpy->screens[i];
+
+ if (sp->depths) {
+ register int j;
+
+ for (j = 0; j < sp->ndepths; j++) {
+ Depth *dp = &sp->depths[j];
+
+ if (dp->visuals) {
+ register int k;
+
+ for (k = 0; k < dp->nvisuals; k++)
+ _XFreeExtData (dp->visuals[k].ext_data);
+ Xfree ((char *) dp->visuals);
+ }
+ }
+
+ Xfree ((char *) sp->depths);
+ }
+
+ _XFreeExtData (sp->ext_data);
+ }
+
+ Xfree ((char *)dpy->screens);
+ }
+
+ if (dpy->pixmap_format) {
+ register int i;
+
+ for (i = 0; i < dpy->nformats; i++)
+ _XFreeExtData (dpy->pixmap_format[i].ext_data);
+ Xfree ((char *)dpy->pixmap_format);
+ }
+
+ if (dpy->display_name)
+ Xfree (dpy->display_name);
+ if (dpy->vendor)
+ Xfree (dpy->vendor);
+
+ if (dpy->buffer)
+ Xfree (dpy->buffer);
+ if (dpy->keysyms)
+ Xfree ((char *) dpy->keysyms);
+ if (dpy->xdefaults)
+ Xfree (dpy->xdefaults);
+ if (dpy->error_vec)
+ Xfree ((char *)dpy->error_vec);
+
+ _XFreeExtData (dpy->ext_data);
+ if (dpy->free_funcs)
+ Xfree ((char *)dpy->free_funcs);
+ if (dpy->scratch_buffer)
+ Xfree (dpy->scratch_buffer);
+ FreeDisplayLock(dpy);
+
+ if (dpy->qfree) {
+ register _XQEvent *qelt = dpy->qfree;
+
+ while (qelt) {
+ register _XQEvent *qnxt = qelt->next;
+ Xfree ((char *) qelt);
+ qelt = qnxt;
+ }
+ }
+ while (dpy->im_fd_info) {
+ struct _XConnectionInfo *conni = dpy->im_fd_info;
+ dpy->im_fd_info = conni->next;
+ if (conni->watch_data)
+ Xfree (conni->watch_data);
+ Xfree (conni);
+ }
+ if (dpy->conn_watchers) {
+ struct _XConnWatchInfo *watcher = dpy->conn_watchers;
+ dpy->conn_watchers = watcher->next;
+ Xfree (watcher);
+ }
+ if (dpy->filedes)
+ Xfree (dpy->filedes);
+
+ Xfree ((char *)dpy);
+}
+
+/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL
+ after this returns. */
+
+static void OutOfMemory (dpy, setup)
+ Display *dpy;
+ char *setup;
+{
+ _XDisconnectDisplay (dpy->trans_conn);
+ _XFreeDisplayStructure (dpy);
+ if (setup) Xfree (setup);
+}
diff --git a/nx-X11/lib/X11/ParseCmd.c b/nx-X11/lib/X11/ParseCmd.c
new file mode 100644
index 000000000..ddcbf7846
--- /dev/null
+++ b/nx-X11/lib/X11/ParseCmd.c
@@ -0,0 +1,227 @@
+/* $Xorg: ParseCmd.c,v 1.4 2001/02/09 02:03:35 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/ParseCmd.c,v 1.5 2001/12/14 19:54:03 dawes Exp $ */
+
+/* XrmParseCommand()
+
+ Parse command line and store argument values into resource database
+
+ Allows any un-ambiguous abbreviation for an option name, but requires
+ that the table be ordered with any options that are prefixes of
+ other options appearing before the longer version in the table.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xresource.h>
+#include <stdio.h>
+
+
+static void _XReportParseError(XrmOptionDescRec *arg, char *msg)
+{
+ (void) fprintf(stderr, "Error parsing argument \"%s\" (%s); %s\n",
+ arg->option, arg->specifier, msg);
+ exit(1);
+}
+
+void
+XrmParseCommand(
+ XrmDatabase *pdb, /* data base */
+ register XrmOptionDescList options, /* pointer to table of valid options */
+ int num_options, /* number of options */
+ _Xconst char *prefix, /* name to prefix resources with */
+ int *argc, /* address of argument count */
+ char **argv) /* argument list (command line) */
+{
+ int foundOption;
+ char **argsave;
+ register int i, myargc;
+ XrmBinding bindings[100];
+ XrmQuark quarks[100];
+ XrmBinding *start_bindings;
+ XrmQuark *start_quarks;
+ char *optP, *argP = NULL, optchar, argchar = 0;
+ int matches;
+ enum {DontCare, Check, NotSorted, Sorted} table_is_sorted;
+ char **argend;
+
+#define PutCommandResource(value_str) \
+ { \
+ XrmStringToBindingQuarkList( \
+ options[i].specifier, start_bindings, start_quarks); \
+ XrmQPutStringResource(pdb, bindings, quarks, value_str); \
+ } /* PutCommandResource */
+
+ myargc = (*argc);
+ argend = argv + myargc;
+ argsave = ++argv;
+
+ /* Initialize bindings/quark list with prefix (typically app name). */
+ quarks[0] = XrmStringToName(prefix);
+ bindings[0] = XrmBindTightly;
+ start_quarks = quarks+1;
+ start_bindings = bindings+1;
+
+ table_is_sorted = (myargc > 2) ? Check : DontCare;
+ for (--myargc; myargc > 0; --myargc, ++argv) {
+ foundOption = False;
+ matches = 0;
+ for (i=0; i < num_options; ++i) {
+ /* checking the sort order first insures we don't have to
+ re-do the check if the arg hits on the last entry in
+ the table. Useful because usually '=' is the last entry
+ and users frequently specify geometry early in the command */
+ if (table_is_sorted == Check && i > 0 &&
+ strcmp(options[i].option, options[i-1].option) < 0) {
+ table_is_sorted = NotSorted;
+ }
+ for (argP = *argv, optP = options[i].option;
+ (optchar = *optP++) &&
+ (argchar = *argP++) &&
+ argchar == optchar;);
+ if (!optchar) {
+ if (!*argP ||
+ options[i].argKind == XrmoptionStickyArg ||
+ options[i].argKind == XrmoptionIsArg) {
+ /* give preference to exact matches, StickyArg and IsArg */
+ matches = 1;
+ foundOption = i;
+ break;
+ }
+ }
+ else if (!argchar) {
+ /* may be an abbreviation for this option */
+ matches++;
+ foundOption = i;
+ }
+ else if (table_is_sorted == Sorted && optchar > argchar) {
+ break;
+ }
+ if (table_is_sorted == Check && i > 0 &&
+ strcmp(options[i].option, options[i-1].option) < 0) {
+ table_is_sorted = NotSorted;
+ }
+ }
+ if (table_is_sorted == Check && i >= (num_options-1))
+ table_is_sorted = Sorted;
+ if (matches == 1) {
+ i = foundOption;
+ switch (options[i].argKind){
+ case XrmoptionNoArg:
+ --(*argc);
+ PutCommandResource(options[i].value);
+ break;
+
+ case XrmoptionIsArg:
+ --(*argc);
+ PutCommandResource(*argv);
+ break;
+
+ case XrmoptionStickyArg:
+ --(*argc);
+ PutCommandResource(argP);
+ break;
+
+ case XrmoptionSepArg:
+ if (myargc > 1) {
+ ++argv; --myargc; --(*argc); --(*argc);
+ PutCommandResource(*argv);
+ } else
+ (*argsave++) = (*argv);
+ break;
+
+ case XrmoptionResArg:
+ if (myargc > 1) {
+ ++argv; --myargc; --(*argc); --(*argc);
+ XrmPutLineResource(pdb, *argv);
+ } else
+ (*argsave++) = (*argv);
+ break;
+
+ case XrmoptionSkipArg:
+ if (myargc > 1) {
+ --myargc;
+ (*argsave++) = (*argv++);
+ }
+ (*argsave++) = (*argv);
+ break;
+
+ case XrmoptionSkipLine:
+ for (; myargc > 0; myargc--)
+ (*argsave++) = (*argv++);
+ break;
+
+ case XrmoptionSkipNArgs:
+ {
+ register int j = 1 + (long) options[i].value;
+
+ if (j > myargc) j = myargc;
+ for (; j > 0; j--) {
+ (*argsave++) = (*argv++);
+ myargc--;
+ }
+ argv--; /* went one too far before */
+ myargc++;
+ }
+ break;
+
+ default:
+ _XReportParseError (&options[i], "unknown kind");
+ break;
+ }
+ }
+ else
+ (*argsave++) = (*argv); /*compress arglist*/
+ }
+
+ if (argsave < argend)
+ (*argsave)=NULL; /* put NULL terminator on compressed argv */
+}
diff --git a/nx-X11/lib/X11/ParseCol.c b/nx-X11/lib/X11/ParseCol.c
new file mode 100644
index 000000000..3736fada2
--- /dev/null
+++ b/nx-X11/lib/X11/ParseCol.c
@@ -0,0 +1,139 @@
+/* $Xorg: ParseCol.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/ParseCol.c,v 1.6 2003/04/13 19:22:17 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+Status
+XParseColor (
+ register Display *dpy,
+ Colormap cmap,
+ _Xconst char *spec,
+ XColor *def)
+{
+ register int n, i;
+ int r, g, b;
+ char c;
+ XcmsCCC ccc;
+ XcmsColor cmsColor;
+
+ if (!spec) return(0);
+ n = strlen (spec);
+ if (*spec == '#') {
+ /*
+ * RGB
+ */
+ spec++;
+ n--;
+ if (n != 3 && n != 6 && n != 9 && n != 12)
+ return (0);
+ n /= 3;
+ g = b = 0;
+ do {
+ r = g;
+ g = b;
+ b = 0;
+ for (i = n; --i >= 0; ) {
+ c = *spec++;
+ b <<= 4;
+ if (c >= '0' && c <= '9')
+ b |= c - '0';
+ else if (c >= 'A' && c <= 'F')
+ b |= c - ('A' - 10);
+ else if (c >= 'a' && c <= 'f')
+ b |= c - ('a' - 10);
+ else return (0);
+ }
+ } while (*spec != '\0');
+ n <<= 2;
+ n = 16 - n;
+ def->red = r << n;
+ def->green = g << n;
+ def->blue = b << n;
+ def->flags = DoRed | DoGreen | DoBlue;
+ return (1);
+ }
+
+
+ /*
+ * Let's Attempt to use Xcms and i18n approach to Parse Color
+ */
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
+ const char *tmpName = spec;
+
+ switch (_XcmsResolveColorString(ccc, &tmpName, &cmsColor,
+ XcmsRGBFormat)) {
+ case XcmsSuccess:
+ case XcmsSuccessWithCompression:
+ cmsColor.pixel = def->pixel;
+ _XcmsRGB_to_XColor(&cmsColor, def, 1);
+ return(1);
+ case XcmsFailure:
+ case _XCMS_NEWNAME:
+ /*
+ * if the result was _XCMS_NEWNAME tmpName points to
+ * a string in cmsColNm.c:pairs table, for example,
+ * gray70 would become tekhvc:0.0/70.0/0.0
+ */
+ break;
+ }
+ }
+
+ /*
+ * Xcms and i18n methods failed, so lets pass it to the server
+ * for parsing.
+ */
+ {
+ xLookupColorReply reply;
+ register xLookupColorReq *req;
+ LockDisplay(dpy);
+ GetReq (LookupColor, req);
+ req->cmap = cmap;
+ req->nbytes = n = strlen(spec);
+ 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;
+ def->flags = DoRed | DoGreen | DoBlue;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (1);
+ }
+}
diff --git a/nx-X11/lib/X11/ParseGeom.c b/nx-X11/lib/X11/ParseGeom.c
new file mode 100644
index 000000000..6aaaccf07
--- /dev/null
+++ b/nx-X11/lib/X11/ParseGeom.c
@@ -0,0 +1,182 @@
+/* $Xorg: ParseGeom.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/ParseGeom.c,v 1.3 2001/12/14 19:54:03 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xutil.h"
+
+#ifdef notdef
+/*
+ *Returns pointer to first char ins search which is also in what, else NULL.
+ */
+static char *strscan (search, what)
+char *search, *what;
+{
+ int i, len = strlen (what);
+ char c;
+
+ while ((c = *(search++)) != NULL)
+ for (i = 0; i < len; i++)
+ if (c == what [i])
+ return (--search);
+ return (NULL);
+}
+#endif
+
+/*
+ * XParseGeometry parses strings of the form
+ * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
+ * width, height, xoffset, and yoffset are unsigned integers.
+ * Example: "=80x24+300-49"
+ * The equal sign is optional.
+ * It returns a bitmask that indicates which of the four values
+ * were actually found in the string. For each value found,
+ * the corresponding argument is updated; for each value
+ * not found, the corresponding argument is left unchanged.
+ */
+
+static int
+ReadInteger(char *string, char **NextString)
+{
+ register int Result = 0;
+ int Sign = 1;
+
+ if (*string == '+')
+ string++;
+ else if (*string == '-')
+ {
+ string++;
+ Sign = -1;
+ }
+ for (; (*string >= '0') && (*string <= '9'); string++)
+ {
+ Result = (Result * 10) + (*string - '0');
+ }
+ *NextString = string;
+ if (Sign >= 0)
+ return (Result);
+ else
+ return (-Result);
+}
+
+int
+XParseGeometry (
+_Xconst char *string,
+int *x,
+int *y,
+unsigned int *width, /* RETURN */
+unsigned int *height) /* RETURN */
+{
+ int mask = NoValue;
+ register char *strind;
+ unsigned int tempWidth = 0, tempHeight = 0;
+ int tempX = 0, tempY = 0;
+ char *nextCharacter;
+
+ if ( (string == NULL) || (*string == '\0')) return(mask);
+ if (*string == '=')
+ string++; /* ignore possible '=' at beg of geometry spec */
+
+ strind = (char *)string;
+ if (*strind != '+' && *strind != '-' && *strind != 'x') {
+ tempWidth = ReadInteger(strind, &nextCharacter);
+ if (strind == nextCharacter)
+ return (0);
+ strind = nextCharacter;
+ mask |= WidthValue;
+ }
+
+ if (*strind == 'x' || *strind == 'X') {
+ strind++;
+ tempHeight = ReadInteger(strind, &nextCharacter);
+ if (strind == nextCharacter)
+ return (0);
+ strind = nextCharacter;
+ mask |= HeightValue;
+ }
+
+ if ((*strind == '+') || (*strind == '-')) {
+ if (*strind == '-') {
+ strind++;
+ tempX = -ReadInteger(strind, &nextCharacter);
+ if (strind == nextCharacter)
+ return (0);
+ strind = nextCharacter;
+ mask |= XNegative;
+
+ }
+ else
+ { strind++;
+ tempX = ReadInteger(strind, &nextCharacter);
+ if (strind == nextCharacter)
+ return(0);
+ strind = nextCharacter;
+ }
+ mask |= XValue;
+ if ((*strind == '+') || (*strind == '-')) {
+ if (*strind == '-') {
+ strind++;
+ tempY = -ReadInteger(strind, &nextCharacter);
+ if (strind == nextCharacter)
+ return(0);
+ strind = nextCharacter;
+ mask |= YNegative;
+
+ }
+ else
+ {
+ strind++;
+ tempY = ReadInteger(strind, &nextCharacter);
+ if (strind == nextCharacter)
+ return(0);
+ strind = nextCharacter;
+ }
+ mask |= YValue;
+ }
+ }
+
+ /* If strind isn't at the end of the string the it's an invalid
+ geometry specification. */
+
+ if (*strind != '\0') return (0);
+
+ if (mask & XValue)
+ *x = tempX;
+ if (mask & YValue)
+ *y = tempY;
+ if (mask & WidthValue)
+ *width = tempWidth;
+ if (mask & HeightValue)
+ *height = tempHeight;
+ return (mask);
+}
diff --git a/nx-X11/lib/X11/PeekEvent.c b/nx-X11/lib/X11/PeekEvent.c
new file mode 100644
index 000000000..b89c6c95e
--- /dev/null
+++ b/nx-X11/lib/X11/PeekEvent.c
@@ -0,0 +1,53 @@
+/* $Xorg: PeekEvent.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/PeekEvent.c,v 1.3 2001/01/17 19:41:41 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/*
+ * Return the next event in the queue,
+ * BUT do not remove it from the queue.
+ * If none found, flush and wait until there is an event to peek.
+ */
+
+int
+XPeekEvent (dpy, event)
+ register Display *dpy;
+ register XEvent *event;
+{
+ LockDisplay(dpy);
+ if (dpy->head == NULL)
+ _XReadEvents(dpy);
+ *event = (dpy->head)->event;
+ UnlockDisplay(dpy);
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/PeekIfEv.c b/nx-X11/lib/X11/PeekIfEv.c
new file mode 100644
index 000000000..a8da27932
--- /dev/null
+++ b/nx-X11/lib/X11/PeekIfEv.c
@@ -0,0 +1,81 @@
+/* $Xorg: PeekIfEv.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/PeekIfEv.c,v 1.4 2001/12/14 19:54:03 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/*
+ * return the next event in the queue that satisfies the predicate.
+ * BUT do not remove it from the queue.
+ * If none found, flush, and then wait until one satisfies the predicate.
+ */
+
+int
+XPeekIfEvent (dpy, event, predicate, arg)
+ register Display *dpy;
+ register XEvent *event;
+ Bool (*predicate)(
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+ );
+ char *arg;
+{
+ register _XQEvent *prev, *qelt;
+ 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;
+ 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;
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return 0;
+ }
+#endif
+ }
+}
+
diff --git a/nx-X11/lib/X11/PeekIfEv.c.NX.original b/nx-X11/lib/X11/PeekIfEv.c.NX.original
new file mode 100644
index 000000000..a8da27932
--- /dev/null
+++ b/nx-X11/lib/X11/PeekIfEv.c.NX.original
@@ -0,0 +1,81 @@
+/* $Xorg: PeekIfEv.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/PeekIfEv.c,v 1.4 2001/12/14 19:54:03 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/*
+ * return the next event in the queue that satisfies the predicate.
+ * BUT do not remove it from the queue.
+ * If none found, flush, and then wait until one satisfies the predicate.
+ */
+
+int
+XPeekIfEvent (dpy, event, predicate, arg)
+ register Display *dpy;
+ register XEvent *event;
+ Bool (*predicate)(
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+ );
+ char *arg;
+{
+ register _XQEvent *prev, *qelt;
+ 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;
+ 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;
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return 0;
+ }
+#endif
+ }
+}
+
diff --git a/nx-X11/lib/X11/PeekIfEv.c.X.original b/nx-X11/lib/X11/PeekIfEv.c.X.original
new file mode 100644
index 000000000..beb991a07
--- /dev/null
+++ b/nx-X11/lib/X11/PeekIfEv.c.X.original
@@ -0,0 +1,76 @@
+/* $Xorg: PeekIfEv.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/PeekIfEv.c,v 1.4 2001/12/14 19:54:03 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/*
+ * return the next event in the queue that satisfies the predicate.
+ * BUT do not remove it from the queue.
+ * If none found, flush, and then wait until one satisfies the predicate.
+ */
+
+int
+XPeekIfEvent (dpy, event, predicate, arg)
+ register Display *dpy;
+ register XEvent *event;
+ Bool (*predicate)(
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+ );
+ char *arg;
+{
+ register _XQEvent *prev, *qelt;
+ 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;
+ 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/nx-X11/lib/X11/Pending.c b/nx-X11/lib/X11/Pending.c
new file mode 100644
index 000000000..34e7cf6ca
--- /dev/null
+++ b/nx-X11/lib/X11/Pending.c
@@ -0,0 +1,69 @@
+/* $Xorg: Pending.c,v 1.4 2001/02/09 02:03:35 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 <stdio.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/* Read in pending events if needed and return the number of queued events. */
+
+int XEventsQueued (dpy, mode)
+ register Display *dpy;
+ int mode;
+{
+ int ret_val;
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "\nXEventsQueued: Called with a display at [%p].\n", dpy);
+#endif
+
+ LockDisplay(dpy);
+ if (dpy->qlen || (mode == QueuedAlready))
+ ret_val = dpy->qlen;
+ else
+ ret_val = _XEventsQueued (dpy, mode);
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "\nXEventsQueued: Going to unlock the display at [%p].\n", dpy);
+#endif
+ UnlockDisplay(dpy);
+ return ret_val;
+}
+
+int XPending (dpy)
+ register Display *dpy;
+{
+ int ret_val;
+ LockDisplay(dpy);
+ if (dpy->qlen)
+ ret_val = dpy->qlen;
+ else
+ ret_val = _XEventsQueued (dpy, QueuedAfterFlush);
+ UnlockDisplay(dpy);
+ return ret_val;
+}
diff --git a/nx-X11/lib/X11/Pending.c.NX.original b/nx-X11/lib/X11/Pending.c.NX.original
new file mode 100644
index 000000000..34e7cf6ca
--- /dev/null
+++ b/nx-X11/lib/X11/Pending.c.NX.original
@@ -0,0 +1,69 @@
+/* $Xorg: Pending.c,v 1.4 2001/02/09 02:03:35 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 <stdio.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/* Read in pending events if needed and return the number of queued events. */
+
+int XEventsQueued (dpy, mode)
+ register Display *dpy;
+ int mode;
+{
+ int ret_val;
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "\nXEventsQueued: Called with a display at [%p].\n", dpy);
+#endif
+
+ LockDisplay(dpy);
+ if (dpy->qlen || (mode == QueuedAlready))
+ ret_val = dpy->qlen;
+ else
+ ret_val = _XEventsQueued (dpy, mode);
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "\nXEventsQueued: Going to unlock the display at [%p].\n", dpy);
+#endif
+ UnlockDisplay(dpy);
+ return ret_val;
+}
+
+int XPending (dpy)
+ register Display *dpy;
+{
+ int ret_val;
+ LockDisplay(dpy);
+ if (dpy->qlen)
+ ret_val = dpy->qlen;
+ else
+ ret_val = _XEventsQueued (dpy, QueuedAfterFlush);
+ UnlockDisplay(dpy);
+ return ret_val;
+}
diff --git a/nx-X11/lib/X11/Pending.c.X.original b/nx-X11/lib/X11/Pending.c.X.original
new file mode 100644
index 000000000..480ec6cf0
--- /dev/null
+++ b/nx-X11/lib/X11/Pending.c.X.original
@@ -0,0 +1,60 @@
+/* $Xorg: Pending.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/* Read in pending events if needed and return the number of queued events. */
+
+int XEventsQueued (dpy, mode)
+ register Display *dpy;
+ int mode;
+{
+ int ret_val;
+ LockDisplay(dpy);
+ if (dpy->qlen || (mode == QueuedAlready))
+ ret_val = dpy->qlen;
+ else
+ ret_val = _XEventsQueued (dpy, mode);
+ UnlockDisplay(dpy);
+ return ret_val;
+}
+
+int XPending (dpy)
+ register Display *dpy;
+{
+ int ret_val;
+ LockDisplay(dpy);
+ if (dpy->qlen)
+ ret_val = dpy->qlen;
+ else
+ ret_val = _XEventsQueued (dpy, QueuedAfterFlush);
+ UnlockDisplay(dpy);
+ return ret_val;
+}
diff --git a/nx-X11/lib/X11/PixFormats.c b/nx-X11/lib/X11/PixFormats.c
new file mode 100644
index 000000000..dc3a23879
--- /dev/null
+++ b/nx-X11/lib/X11/PixFormats.c
@@ -0,0 +1,63 @@
+/* $Xorg: PixFormats.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <stdio.h>
+
+/*
+ * XListPixmapFormats - return info from connection setup
+ */
+
+XPixmapFormatValues *XListPixmapFormats (dpy, count)
+ Display *dpy;
+ int *count; /* RETURN */
+{
+ XPixmapFormatValues *formats = (XPixmapFormatValues *)
+ Xmalloc((unsigned) (dpy->nformats * sizeof (XPixmapFormatValues)));
+
+ if (formats) {
+ register int i;
+ register XPixmapFormatValues *f;
+ register ScreenFormat *sf;
+
+ /*
+ * copy data from internal Xlib data structure in display
+ */
+ for (i = dpy->nformats, f = formats, sf = dpy->pixmap_format; i > 0;
+ i--, f++, sf++) {
+ f->depth = sf->depth;
+ f->bits_per_pixel = sf->bits_per_pixel;
+ f->scanline_pad = sf->scanline_pad;
+ }
+
+ *count = dpy->nformats;
+ }
+ return formats;
+}
diff --git a/nx-X11/lib/X11/PmapBgnd.c b/nx-X11/lib/X11/PmapBgnd.c
new file mode 100644
index 000000000..3333cd966
--- /dev/null
+++ b/nx-X11/lib/X11/PmapBgnd.c
@@ -0,0 +1,50 @@
+/* $Xorg: PmapBgnd.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/PmapBgnd.c,v 1.3 2001/01/17 19:41:41 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetWindowBackgroundPixmap(dpy, w, pixmap)
+ register Display *dpy;
+ Window w;
+ Pixmap pixmap;
+{
+ register xChangeWindowAttributesReq *req;
+ LockDisplay (dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWBackPixmap;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), pixmap);
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/PmapBord.c b/nx-X11/lib/X11/PmapBord.c
new file mode 100644
index 000000000..a81adc13e
--- /dev/null
+++ b/nx-X11/lib/X11/PmapBord.c
@@ -0,0 +1,50 @@
+/* $Xorg: PmapBord.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/PmapBord.c,v 1.3 2001/01/17 19:41:41 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetWindowBorderPixmap(dpy, w, pixmap)
+ register Display *dpy;
+ Window w;
+ Pixmap pixmap;
+{
+ register xChangeWindowAttributesReq *req;
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWBorderPixmap;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), pixmap);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/PolyReg.c b/nx-X11/lib/X11/PolyReg.c
new file mode 100644
index 000000000..4b17ec5c5
--- /dev/null
+++ b/nx-X11/lib/X11/PolyReg.c
@@ -0,0 +1,638 @@
+/* $Xorg: PolyReg.c,v 1.5 2001/02/09 02:03:35 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.
+
+************************************************************************/
+/* $XFree86: xc/lib/X11/PolyReg.c,v 1.6 2001/12/14 19:54:03 dawes Exp $ */
+
+#define LARGE_COORDINATE 1000000
+#define SMALL_COORDINATE -LARGE_COORDINATE
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xutil.h"
+#include <X11/Xregion.h>
+#include "poly.h"
+
+/*
+ * InsertEdgeInET
+ *
+ * Insert the given edge into the edge table.
+ * First we must find the correct bucket in the
+ * Edge table, then find the right slot in the
+ * bucket. Finally, we can insert it.
+ *
+ */
+static void
+InsertEdgeInET(
+ EdgeTable *ET,
+ EdgeTableEntry *ETE,
+ int scanline,
+ ScanLineListBlock **SLLBlock,
+ int *iSLLBlock)
+{
+ register EdgeTableEntry *start, *prev;
+ register ScanLineList *pSLL, *pPrevSLL;
+ ScanLineListBlock *tmpSLLBlock;
+
+ /*
+ * find the right bucket to put the edge into
+ */
+ pPrevSLL = &ET->scanlines;
+ pSLL = pPrevSLL->next;
+ while (pSLL && (pSLL->scanline < scanline))
+ {
+ pPrevSLL = pSLL;
+ pSLL = pSLL->next;
+ }
+
+ /*
+ * reassign pSLL (pointer to ScanLineList) if necessary
+ */
+ if ((!pSLL) || (pSLL->scanline > scanline))
+ {
+ if (*iSLLBlock > SLLSPERBLOCK-1)
+ {
+ tmpSLLBlock =
+ (ScanLineListBlock *)Xmalloc(sizeof(ScanLineListBlock));
+ (*SLLBlock)->next = tmpSLLBlock;
+ tmpSLLBlock->next = (ScanLineListBlock *)NULL;
+ *SLLBlock = tmpSLLBlock;
+ *iSLLBlock = 0;
+ }
+ pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]);
+
+ pSLL->next = pPrevSLL->next;
+ pSLL->edgelist = (EdgeTableEntry *)NULL;
+ pPrevSLL->next = pSLL;
+ }
+ pSLL->scanline = scanline;
+
+ /*
+ * now insert the edge in the right bucket
+ */
+ prev = (EdgeTableEntry *)NULL;
+ start = pSLL->edgelist;
+ while (start && (start->bres.minor_axis < ETE->bres.minor_axis))
+ {
+ prev = start;
+ start = start->next;
+ }
+ ETE->next = start;
+
+ if (prev)
+ prev->next = ETE;
+ else
+ pSLL->edgelist = ETE;
+}
+
+/*
+ * CreateEdgeTable
+ *
+ * This routine creates the edge table for
+ * scan converting polygons.
+ * The Edge Table (ET) looks like:
+ *
+ * EdgeTable
+ * --------
+ * | ymax | ScanLineLists
+ * |scanline|-->------------>-------------->...
+ * -------- |scanline| |scanline|
+ * |edgelist| |edgelist|
+ * --------- ---------
+ * | |
+ * | |
+ * V V
+ * list of ETEs list of ETEs
+ *
+ * where ETE is an EdgeTableEntry data structure,
+ * and there is one ScanLineList per scanline at
+ * which an edge is initially entered.
+ *
+ */
+
+static void
+CreateETandAET(
+ register int count,
+ register XPoint *pts,
+ EdgeTable *ET,
+ EdgeTableEntry *AET,
+ register EdgeTableEntry *pETEs,
+ ScanLineListBlock *pSLLBlock)
+{
+ register XPoint *top, *bottom;
+ register XPoint *PrevPt, *CurrPt;
+ int iSLLBlock = 0;
+ int dy;
+
+ if (count < 2) return;
+
+ /*
+ * initialize the Active Edge Table
+ */
+ AET->next = (EdgeTableEntry *)NULL;
+ AET->back = (EdgeTableEntry *)NULL;
+ AET->nextWETE = (EdgeTableEntry *)NULL;
+ AET->bres.minor_axis = SMALL_COORDINATE;
+
+ /*
+ * initialize the Edge Table.
+ */
+ ET->scanlines.next = (ScanLineList *)NULL;
+ ET->ymax = SMALL_COORDINATE;
+ ET->ymin = LARGE_COORDINATE;
+ pSLLBlock->next = (ScanLineListBlock *)NULL;
+
+ PrevPt = &pts[count-1];
+
+ /*
+ * for each vertex in the array of points.
+ * In this loop we are dealing with two vertices at
+ * a time -- these make up one edge of the polygon.
+ */
+ while (count--)
+ {
+ CurrPt = pts++;
+
+ /*
+ * find out which point is above and which is below.
+ */
+ if (PrevPt->y > CurrPt->y)
+ {
+ bottom = PrevPt, top = CurrPt;
+ pETEs->ClockWise = 0;
+ }
+ else
+ {
+ bottom = CurrPt, top = PrevPt;
+ pETEs->ClockWise = 1;
+ }
+
+ /*
+ * don't add horizontal edges to the Edge table.
+ */
+ if (bottom->y != top->y)
+ {
+ pETEs->ymax = bottom->y-1; /* -1 so we don't get last scanline */
+
+ /*
+ * initialize integer edge algorithm
+ */
+ dy = bottom->y - top->y;
+ BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres);
+
+ InsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock);
+
+ if (PrevPt->y > ET->ymax)
+ ET->ymax = PrevPt->y;
+ if (PrevPt->y < ET->ymin)
+ ET->ymin = PrevPt->y;
+ pETEs++;
+ }
+
+ PrevPt = CurrPt;
+ }
+}
+
+/*
+ * loadAET
+ *
+ * This routine moves EdgeTableEntries from the
+ * EdgeTable into the Active Edge Table,
+ * leaving them sorted by smaller x coordinate.
+ *
+ */
+
+static void
+loadAET(
+ register EdgeTableEntry *AET,
+ register EdgeTableEntry *ETEs)
+{
+ register EdgeTableEntry *pPrevAET;
+ register EdgeTableEntry *tmp;
+
+ pPrevAET = AET;
+ AET = AET->next;
+ while (ETEs)
+ {
+ while (AET && (AET->bres.minor_axis < ETEs->bres.minor_axis))
+ {
+ pPrevAET = AET;
+ AET = AET->next;
+ }
+ tmp = ETEs->next;
+ ETEs->next = AET;
+ if (AET)
+ AET->back = ETEs;
+ ETEs->back = pPrevAET;
+ pPrevAET->next = ETEs;
+ pPrevAET = ETEs;
+
+ ETEs = tmp;
+ }
+}
+
+/*
+ * computeWAET
+ *
+ * This routine links the AET by the
+ * nextWETE (winding EdgeTableEntry) link for
+ * use by the winding number rule. The final
+ * Active Edge Table (AET) might look something
+ * like:
+ *
+ * AET
+ * ---------- --------- ---------
+ * |ymax | |ymax | |ymax |
+ * | ... | |... | |... |
+ * |next |->|next |->|next |->...
+ * |nextWETE| |nextWETE| |nextWETE|
+ * --------- --------- ^--------
+ * | | |
+ * V-------------------> V---> ...
+ *
+ */
+static void
+computeWAET(
+ register EdgeTableEntry *AET)
+{
+ register EdgeTableEntry *pWETE;
+ register int inside = 1;
+ register int isInside = 0;
+
+ AET->nextWETE = (EdgeTableEntry *)NULL;
+ pWETE = AET;
+ AET = AET->next;
+ while (AET)
+ {
+ if (AET->ClockWise)
+ isInside++;
+ else
+ isInside--;
+
+ if ((!inside && !isInside) ||
+ ( inside && isInside))
+ {
+ pWETE->nextWETE = AET;
+ pWETE = AET;
+ inside = !inside;
+ }
+ AET = AET->next;
+ }
+ pWETE->nextWETE = (EdgeTableEntry *)NULL;
+}
+
+/*
+ * InsertionSort
+ *
+ * Just a simple insertion sort using
+ * pointers and back pointers to sort the Active
+ * Edge Table.
+ *
+ */
+
+static int
+InsertionSort(
+ register EdgeTableEntry *AET)
+{
+ register EdgeTableEntry *pETEchase;
+ register EdgeTableEntry *pETEinsert;
+ register EdgeTableEntry *pETEchaseBackTMP;
+ register int changed = 0;
+
+ AET = AET->next;
+ while (AET)
+ {
+ pETEinsert = AET;
+ pETEchase = AET;
+ while (pETEchase->back->bres.minor_axis > AET->bres.minor_axis)
+ pETEchase = pETEchase->back;
+
+ AET = AET->next;
+ if (pETEchase != pETEinsert)
+ {
+ pETEchaseBackTMP = pETEchase->back;
+ pETEinsert->back->next = AET;
+ if (AET)
+ AET->back = pETEinsert->back;
+ pETEinsert->next = pETEchase;
+ pETEchase->back->next = pETEinsert;
+ pETEchase->back = pETEinsert;
+ pETEinsert->back = pETEchaseBackTMP;
+ changed = 1;
+ }
+ }
+ return(changed);
+}
+
+/*
+ * Clean up our act.
+ */
+static void
+FreeStorage(
+ register ScanLineListBlock *pSLLBlock)
+{
+ register ScanLineListBlock *tmpSLLBlock;
+
+ while (pSLLBlock)
+ {
+ tmpSLLBlock = pSLLBlock->next;
+ Xfree((char *)pSLLBlock);
+ pSLLBlock = tmpSLLBlock;
+ }
+}
+
+/*
+ * Create an array of rectangles from a list of points.
+ * If indeed these things (POINTS, RECTS) are the same,
+ * then this proc is still needed, because it allocates
+ * storage for the array, which was allocated on the
+ * stack by the calling procedure.
+ *
+ */
+static int PtsToRegion(
+ register int numFullPtBlocks,
+ register int iCurPtBlock,
+ POINTBLOCK *FirstPtBlock,
+ REGION *reg)
+{
+ register BOX *rects;
+ register XPoint *pts;
+ register POINTBLOCK *CurPtBlock;
+ register int i;
+ register BOX *extents;
+ register int numRects;
+ BOX *prevRects = reg->rects;
+
+ extents = &reg->extents;
+
+ numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1;
+
+ if (!(reg->rects = (BOX *)Xrealloc((char *)reg->rects,
+ (unsigned) (sizeof(BOX) * numRects)))) {
+ Xfree(prevRects);
+ return(0);
+ }
+
+ reg->size = numRects;
+ CurPtBlock = FirstPtBlock;
+ rects = reg->rects - 1;
+ numRects = 0;
+ extents->x1 = MAXSHORT, extents->x2 = MINSHORT;
+
+ for ( ; numFullPtBlocks >= 0; numFullPtBlocks--) {
+ /* the loop uses 2 points per iteration */
+ i = NUMPTSTOBUFFER >> 1;
+ if (!numFullPtBlocks)
+ i = iCurPtBlock >> 1;
+ for (pts = CurPtBlock->pts; i--; pts += 2) {
+ if (pts->x == pts[1].x)
+ continue;
+ if (numRects && pts->x == rects->x1 && pts->y == rects->y2 &&
+ pts[1].x == rects->x2 &&
+ (numRects == 1 || rects[-1].y1 != rects->y1) &&
+ (i && pts[2].y > pts[1].y)) {
+ rects->y2 = pts[1].y + 1;
+ continue;
+ }
+ numRects++;
+ rects++;
+ rects->x1 = pts->x; rects->y1 = pts->y;
+ rects->x2 = pts[1].x; rects->y2 = pts[1].y + 1;
+ if (rects->x1 < extents->x1)
+ extents->x1 = rects->x1;
+ if (rects->x2 > extents->x2)
+ extents->x2 = rects->x2;
+ }
+ CurPtBlock = CurPtBlock->next;
+ }
+
+ if (numRects) {
+ extents->y1 = reg->rects->y1;
+ extents->y2 = rects->y2;
+ } else {
+ extents->x1 = 0;
+ extents->y1 = 0;
+ extents->x2 = 0;
+ extents->y2 = 0;
+ }
+ reg->numRects = numRects;
+
+ return(TRUE);
+}
+
+/*
+ * polytoregion
+ *
+ * Scan converts a polygon by returning a run-length
+ * encoding of the resultant bitmap -- the run-length
+ * encoding is in the form of an array of rectangles.
+ */
+Region
+XPolygonRegion(Pts, Count, rule)
+ int Count; /* number of pts */
+ XPoint *Pts; /* the pts */
+ int rule; /* winding rule */
+{
+ Region region;
+ register EdgeTableEntry *pAET; /* Active Edge Table */
+ register int y; /* current scanline */
+ register int iPts = 0; /* number of pts in buffer */
+ register EdgeTableEntry *pWETE; /* Winding Edge Table Entry*/
+ register ScanLineList *pSLL; /* current scanLineList */
+ register XPoint *pts; /* output buffer */
+ EdgeTableEntry *pPrevAET; /* ptr to previous AET */
+ EdgeTable ET; /* header node for ET */
+ EdgeTableEntry AET; /* header node for AET */
+ EdgeTableEntry *pETEs; /* EdgeTableEntries pool */
+ ScanLineListBlock SLLBlock; /* header for scanlinelist */
+ int fixWAET = FALSE;
+ POINTBLOCK FirstPtBlock, *curPtBlock; /* PtBlock buffers */
+ POINTBLOCK *tmpPtBlock;
+ int numFullPtBlocks = 0;
+
+ if (! (region = XCreateRegion())) return (Region) NULL;
+
+ /* special case a rectangle */
+ pts = Pts;
+ if (((Count == 4) ||
+ ((Count == 5) && (pts[4].x == pts[0].x) && (pts[4].y == pts[0].y))) &&
+ (((pts[0].y == pts[1].y) &&
+ (pts[1].x == pts[2].x) &&
+ (pts[2].y == pts[3].y) &&
+ (pts[3].x == pts[0].x)) ||
+ ((pts[0].x == pts[1].x) &&
+ (pts[1].y == pts[2].y) &&
+ (pts[2].x == pts[3].x) &&
+ (pts[3].y == pts[0].y)))) {
+ region->extents.x1 = min(pts[0].x, pts[2].x);
+ region->extents.y1 = min(pts[0].y, pts[2].y);
+ region->extents.x2 = max(pts[0].x, pts[2].x);
+ region->extents.y2 = max(pts[0].y, pts[2].y);
+ if ((region->extents.x1 != region->extents.x2) &&
+ (region->extents.y1 != region->extents.y2)) {
+ region->numRects = 1;
+ *(region->rects) = region->extents;
+ }
+ return(region);
+ }
+
+ if (Count < 2) return region;
+
+ if (! (pETEs = (EdgeTableEntry *)
+ Xmalloc((unsigned) (sizeof(EdgeTableEntry) * Count))))
+ return (Region) NULL;
+
+ pts = FirstPtBlock.pts;
+ CreateETandAET(Count, Pts, &ET, &AET, pETEs, &SLLBlock);
+ pSLL = ET.scanlines.next;
+ curPtBlock = &FirstPtBlock;
+
+ if (rule == EvenOddRule) {
+ /*
+ * for each scanline
+ */
+ for (y = ET.ymin; y < ET.ymax; y++) {
+ /*
+ * Add a new edge to the active edge table when we
+ * get to the next edge.
+ */
+ if (pSLL != NULL && y == pSLL->scanline) {
+ loadAET(&AET, pSLL->edgelist);
+ pSLL = pSLL->next;
+ }
+ pPrevAET = &AET;
+ pAET = AET.next;
+
+ /*
+ * for each active edge
+ */
+ while (pAET) {
+ pts->x = pAET->bres.minor_axis, pts->y = y;
+ pts++, iPts++;
+
+ /*
+ * send out the buffer
+ */
+ if (iPts == NUMPTSTOBUFFER) {
+ tmpPtBlock = (POINTBLOCK *)Xmalloc(sizeof(POINTBLOCK));
+ curPtBlock->next = tmpPtBlock;
+ curPtBlock = tmpPtBlock;
+ pts = curPtBlock->pts;
+ numFullPtBlocks++;
+ iPts = 0;
+ }
+ EVALUATEEDGEEVENODD(pAET, pPrevAET, y);
+ }
+ (void) InsertionSort(&AET);
+ }
+ }
+ else {
+ /*
+ * for each scanline
+ */
+ for (y = ET.ymin; y < ET.ymax; y++) {
+ /*
+ * Add a new edge to the active edge table when we
+ * get to the next edge.
+ */
+ if (pSLL != NULL && y == pSLL->scanline) {
+ loadAET(&AET, pSLL->edgelist);
+ computeWAET(&AET);
+ pSLL = pSLL->next;
+ }
+ pPrevAET = &AET;
+ pAET = AET.next;
+ pWETE = pAET;
+
+ /*
+ * for each active edge
+ */
+ while (pAET) {
+ /*
+ * add to the buffer only those edges that
+ * are in the Winding active edge table.
+ */
+ if (pWETE == pAET) {
+ pts->x = pAET->bres.minor_axis, pts->y = y;
+ pts++, iPts++;
+
+ /*
+ * send out the buffer
+ */
+ if (iPts == NUMPTSTOBUFFER) {
+ tmpPtBlock = (POINTBLOCK *)Xmalloc(sizeof(POINTBLOCK));
+ curPtBlock->next = tmpPtBlock;
+ curPtBlock = tmpPtBlock;
+ pts = curPtBlock->pts;
+ numFullPtBlocks++; iPts = 0;
+ }
+ pWETE = pWETE->nextWETE;
+ }
+ EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
+ }
+
+ /*
+ * recompute the winding active edge table if
+ * we just resorted or have exited an edge.
+ */
+ if (InsertionSort(&AET) || fixWAET) {
+ computeWAET(&AET);
+ fixWAET = FALSE;
+ }
+ }
+ }
+ FreeStorage(SLLBlock.next);
+ (void) PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
+ for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
+ tmpPtBlock = curPtBlock->next;
+ Xfree((char *)curPtBlock);
+ curPtBlock = tmpPtBlock;
+ }
+ Xfree((char *)pETEs);
+ return(region);
+}
diff --git a/nx-X11/lib/X11/PolyTxt.c b/nx-X11/lib/X11/PolyTxt.c
new file mode 100644
index 000000000..f66b10463
--- /dev/null
+++ b/nx-X11/lib/X11/PolyTxt.c
@@ -0,0 +1,235 @@
+/* $Xorg: PolyTxt.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/PolyTxt.c,v 3.5 2001/10/28 03:32:30 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XDrawText(dpy, d, gc, x, y, items, nitems)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y;
+ XTextItem *items;
+ int nitems;
+{
+ register int i;
+ register XTextItem *item;
+ int length = 0;
+ register xPolyText8Req *req;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq (PolyText8, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->x = x;
+ req->y = y;
+
+ item = items;
+ for (i=0; i < nitems; i++) {
+ if (item->font)
+ length += 5; /* a 255 byte, plus size of Font id */
+ if (item->delta)
+ {
+ if (item->delta > 0)
+ {
+ length += SIZEOF(xTextElt) * ((item->delta + 126) / 127);
+ }
+ else
+ {
+ length += SIZEOF(xTextElt) * ((-item->delta + 127) / 128);
+ }
+ }
+ if (item->nchars > 0)
+ {
+ length += SIZEOF(xTextElt) * ((item->nchars + 253) / 254 - 1);
+ if (!item->delta) length += SIZEOF(xTextElt);
+ length += item->nchars;
+ }
+ item++;
+ }
+
+ req->length += (length + 3)>>2; /* convert to number of 32-bit words */
+
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first. If the request does fit into the
+ * empty buffer, then we won't have to flush it at the end to keep
+ * the buffer 32-bit aligned.
+ */
+
+ if (dpy->bufptr + length > dpy->bufmax)
+ _XFlush (dpy);
+
+ item = items;
+ for (i=0; i< nitems; i++) {
+
+ if (item->font) {
+ /* to mark a font shift, write a 255 byte followed by
+ the 4 bytes of font ID, big-end first */
+ register unsigned char *f;
+ BufAlloc (unsigned char *, f, 5);
+
+ f[0] = 255;
+ f[1] = (item->font & 0xff000000) >> 24;
+ f[2] = (item->font & 0x00ff0000) >> 16;
+ f[3] = (item->font & 0x0000ff00) >> 8;
+ f[4] = item->font & 0x000000ff;
+
+ /* update GC shadow */
+ gc->values.font = item->font;
+ }
+
+ {
+ int nbytes = SIZEOF(xTextElt);
+ int PartialNChars = item->nchars;
+ int PartialDelta = item->delta;
+ /* register xTextElt *elt; */
+ int FirstTimeThrough = True;
+ char *CharacterOffset = item->chars;
+ char *tbuf = NULL;
+
+ while((PartialDelta < -128) || (PartialDelta > 127))
+ {
+ int nb = SIZEOF(xTextElt);
+
+ BufAlloc (char *, tbuf, nb);
+ *tbuf = 0; /* elt->len */
+ if (PartialDelta > 0 )
+ {
+ *(tbuf+1) = 127; /* elt->delta */
+ PartialDelta = PartialDelta - 127;
+ }
+ else
+ {
+ /* -128 = 0x8, need to be careful of signed chars... */
+ *((unsigned char *)(tbuf+1)) = 0x80; /* elt->delta */
+ PartialDelta = PartialDelta + 128;
+ }
+ }
+ if (PartialDelta)
+ {
+ BufAlloc (char *, tbuf , nbytes);
+ *tbuf = 0; /* elt->len */
+ *(tbuf+1) = PartialDelta; /* elt->delta */
+ }
+ while(PartialNChars > 254)
+ {
+ nbytes = 254;
+ if (FirstTimeThrough)
+ {
+ FirstTimeThrough = False;
+ if (!item->delta)
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (char *, tbuf, nbytes);
+ *(tbuf+1) = 0; /* elt->delta */
+ }
+ else
+ {
+ char *DummyChar;
+ BufAlloc(char *, DummyChar, nbytes);
+ }
+ }
+ else
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (char *, tbuf, nbytes);
+ *(tbuf+1) = 0; /* elt->delta */
+ }
+ /* watch out for signs on chars */
+ *(unsigned char *)tbuf = 254; /* elt->len */
+ memcpy (tbuf+2 , CharacterOffset, 254);
+ PartialNChars = PartialNChars - 254;
+ CharacterOffset += 254;
+
+ }
+ if (PartialNChars)
+ {
+ nbytes = PartialNChars;
+ if (FirstTimeThrough)
+ {
+ FirstTimeThrough = False;
+ if (!item->delta)
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (char *, tbuf, nbytes);
+ *(tbuf+1) = 0; /* elt->delta */
+ }
+ else
+ {
+ char *DummyChar;
+ BufAlloc(char *, DummyChar, nbytes);
+ }
+ }
+ else
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (char *, tbuf, nbytes);
+ *(tbuf+1) = 0; /* elt->delta */
+ }
+ *tbuf = PartialNChars; /* elt->len */
+ memcpy (tbuf+2 , CharacterOffset, PartialNChars);
+ }
+ }
+ item++;
+ }
+
+ /* Pad request out to a 32-bit boundary */
+
+ if (length &= 3) {
+ char *pad;
+ /*
+ * BufAlloc is a macro that uses its last argument more than
+ * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)"
+ */
+ length = 4 - length;
+ BufAlloc (char *, pad, length);
+ /*
+ * if there are 3 bytes of padding, the first byte MUST be 0
+ * so the pad bytes aren't mistaken for a final xTextElt
+ */
+ *pad = 0;
+ }
+
+ /*
+ * If the buffer pointer is not now pointing to a 32-bit boundary,
+ * we must flush the buffer so that it does point to a 32-bit boundary
+ * at the end of this routine.
+ */
+
+ if ((dpy->bufptr - dpy->buffer) & 3)
+ _XFlush (dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
diff --git a/nx-X11/lib/X11/PolyTxt16.c b/nx-X11/lib/X11/PolyTxt16.c
new file mode 100644
index 000000000..ddaa62d08
--- /dev/null
+++ b/nx-X11/lib/X11/PolyTxt16.c
@@ -0,0 +1,269 @@
+/* $Xorg: PolyTxt16.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/PolyTxt16.c,v 1.4 2001/10/28 03:32:31 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XDrawText16(dpy, d, gc, x, y, items, nitems)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y;
+ XTextItem16 *items;
+ int nitems;
+{
+ register int i;
+ register XTextItem16 *item;
+ int length = 0;
+ register xPolyText16Req *req;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq (PolyText16, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->x = x;
+ req->y = y;
+
+ item = items;
+ for (i=0; i < nitems; i++) {
+ if (item->font)
+ length += 5; /* a 255 byte, plus size of Font id */
+ if (item->delta)
+ {
+ if (item->delta > 0)
+ {
+ length += SIZEOF(xTextElt) * ((item->delta + 126) / 127);
+ }
+ else
+ {
+ length += SIZEOF(xTextElt) * ((-item->delta + 127) / 128);
+ }
+ }
+ if (item->nchars > 0)
+ {
+ length += SIZEOF(xTextElt) * ((item->nchars + 253) / 254 - 1);
+ if (!item->delta) length += SIZEOF(xTextElt);
+ length += item->nchars << 1;
+ }
+ item++;
+ }
+
+ req->length += (length + 3)>>2; /* convert to number of 32-bit words */
+
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first. If the request does fit into the
+ * empty buffer, then we won't have to flush it at the end to keep
+ * the buffer 32-bit aligned.
+ */
+
+ if (dpy->bufptr + length > dpy->bufmax)
+ _XFlush (dpy);
+
+ item = items;
+ for (i=0; i< nitems; i++) {
+
+ if (item->font) {
+ /* to mark a font shift, write a 255 byte followed by
+ the 4 bytes of font ID, big-end first */
+ register unsigned char *f;
+ BufAlloc (unsigned char *, f, 5);
+
+ f[0] = 255;
+ f[1] = (item->font & 0xff000000) >> 24;
+ f[2] = (item->font & 0x00ff0000) >> 16;
+ f[3] = (item->font & 0x0000ff00) >> 8;
+ f[4] = item->font & 0x000000ff;
+
+ /* update GC shadow */
+ gc->values.font = item->font;
+ }
+
+ {
+ int nbytes = SIZEOF(xTextElt);
+ int PartialNChars = item->nchars;
+ int PartialDelta = item->delta;
+ register xTextElt *elt = NULL;
+ int FirstTimeThrough = True;
+ XChar2b *CharacterOffset = item->chars;
+
+ while((PartialDelta < -128) || (PartialDelta > 127))
+ {
+ int nb = SIZEOF(xTextElt);
+
+ BufAlloc (xTextElt *, elt, nb);
+ elt->len = 0;
+ if (PartialDelta > 0 )
+ {
+ elt->delta = 127;
+ PartialDelta = PartialDelta - 127;
+ }
+ else
+ {
+ elt->delta = -128;
+ PartialDelta = PartialDelta + 128;
+ }
+ }
+ if (PartialDelta)
+ {
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->len = 0;
+ elt->delta = PartialDelta;
+ }
+ while(PartialNChars > 254)
+ {
+ nbytes = 254 * 2;
+ if (FirstTimeThrough)
+ {
+ FirstTimeThrough = False;
+ if (!item->delta)
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->delta = 0;
+ }
+ else
+ {
+ char *DummyChar;
+ BufAlloc(char *, DummyChar, nbytes);
+#ifdef lint
+ DummyChar = DummyChar;
+#endif
+ }
+ }
+ else
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->delta = 0;
+ }
+ elt->len = 254;
+
+#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
+ {
+ register int i;
+ register unsigned char *cp;
+ for (i = 0, cp = ((unsigned char *)elt) + 2; i < 254; i++) {
+ *cp++ = CharacterOffset[i].byte1;
+ *cp++ = CharacterOffset[i].byte2;
+ }
+ }
+#else
+ memcpy ((char *) (elt + 1), (char *)CharacterOffset, 254 * 2);
+#endif
+ PartialNChars = PartialNChars - 254;
+ CharacterOffset += 254;
+
+ }
+ if (PartialNChars)
+ {
+ nbytes = PartialNChars * 2;
+ if (FirstTimeThrough)
+ {
+ FirstTimeThrough = False;
+ if (!item->delta)
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->delta = 0;
+ }
+ else
+ {
+ char *DummyChar;
+ BufAlloc(char *, DummyChar, nbytes);
+#ifdef lint
+ DummyChar = DummyChar;
+#endif
+ }
+ }
+ else
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->delta = 0;
+ }
+ elt->len = PartialNChars;
+
+#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
+ {
+ register int i;
+ register unsigned char *cp;
+ for (i = 0, cp = ((unsigned char *)elt) + 2; i < PartialNChars;
+ i++) {
+ *cp++ = CharacterOffset[i].byte1;
+ *cp++ = CharacterOffset[i].byte2;
+ }
+ }
+#else
+ memcpy ((char *) (elt + 1), (char *)CharacterOffset,
+ PartialNChars *
+2);
+#endif
+ }
+ }
+ item++;
+ }
+
+ /* Pad request out to a 32-bit boundary */
+
+ if (length &= 3) {
+ char *pad;
+ /*
+ * BufAlloc is a macro that uses its last argument more than
+ * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)"
+ */
+ length = 4 - length;
+ BufAlloc (char *, pad, length);
+ /*
+ * if there are 3 bytes of padding, the first byte MUST be 0
+ * so the pad bytes aren't mistaken for a final xTextElt
+ */
+ *pad = 0;
+ }
+
+ /*
+ * If the buffer pointer is not now pointing to a 32-bit boundary,
+ * we must flush the buffer so that it does point to a 32-bit boundary
+ * at the end of this routine.
+ */
+
+ if ((dpy->bufptr - dpy->buffer) & 3)
+ _XFlush (dpy);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
+
+
diff --git a/nx-X11/lib/X11/PrOfId.c b/nx-X11/lib/X11/PrOfId.c
new file mode 100644
index 000000000..d8fe6e9f3
--- /dev/null
+++ b/nx-X11/lib/X11/PrOfId.c
@@ -0,0 +1,106 @@
+/* $Xorg: PrOfId.c,v 1.3 2000/08/17 19:44:48 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsPrOfId.c
+ *
+ * DESCRIPTION
+ * Source for XcmsPrefixOfFormat()
+ *
+ *
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/*
+ * NAME
+ * XcmsPrefixOfId
+ *
+ * SYNOPSIS
+ */
+char *
+XcmsPrefixOfFormat(id)
+ XcmsColorFormat id;
+/*
+ * DESCRIPTION
+ * Returns the color space prefix for the specified color
+ * space ID if the color space is found in the Color
+ * Conversion Context.
+ *
+ * RETURNS
+ * Returns a color space prefix.
+ *
+ * CAVEATS
+ * Space is allocated for the returned string, therefore,
+ * the application is responsible for freeing (using XFree)
+ * the space.
+ *
+ */
+{
+ XcmsColorSpace **papColorSpaces;
+ char *prefix;
+
+ /*
+ * First try Device-Independent color spaces
+ */
+ papColorSpaces = _XcmsDIColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if ((*papColorSpaces)->id == id) {
+ prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) +
+ 1) * sizeof(char));
+ strcpy(prefix, (*papColorSpaces)->prefix);
+ return(prefix);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ /*
+ * Next try Device-Dependent color spaces
+ */
+ papColorSpaces = _XcmsDDColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if ((*papColorSpaces)->id == id) {
+ prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) +
+ 1) * sizeof(char));
+ strcpy(prefix, (*papColorSpaces)->prefix);
+ return(prefix);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ return(NULL);
+}
diff --git a/nx-X11/lib/X11/PropAlloc.c b/nx-X11/lib/X11/PropAlloc.c
new file mode 100644
index 000000000..9005a24ff
--- /dev/null
+++ b/nx-X11/lib/X11/PropAlloc.c
@@ -0,0 +1,77 @@
+/* $Xorg: PropAlloc.c,v 1.5 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/PropAlloc.c,v 1.3 2001/01/17 19:41:41 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xutil.h"
+#include <stdio.h>
+
+
+/*
+ * Routines for allocating space for structures that are expected to get
+ * longer at some point.
+ */
+
+XSizeHints *XAllocSizeHints ()
+{
+ return ((XSizeHints *) Xcalloc (1, (unsigned) sizeof (XSizeHints)));
+}
+
+
+XStandardColormap *XAllocStandardColormap ()
+{
+ return ((XStandardColormap *)
+ Xcalloc (1, (unsigned) sizeof (XStandardColormap)));
+}
+
+
+XWMHints *XAllocWMHints ()
+{
+ return ((XWMHints *) Xcalloc (1, (unsigned) sizeof (XWMHints)));
+}
+
+
+XClassHint *XAllocClassHint ()
+{
+ register XClassHint *h;
+
+ if ((h = (XClassHint *) Xcalloc (1, (unsigned) sizeof (XClassHint))))
+ h->res_name = h->res_class = NULL;
+
+ return h;
+}
+
+
+XIconSize *XAllocIconSize ()
+{
+ return ((XIconSize *) Xcalloc (1, (unsigned) sizeof (XIconSize)));
+}
+
+
diff --git a/nx-X11/lib/X11/PutBEvent.c b/nx-X11/lib/X11/PutBEvent.c
new file mode 100644
index 000000000..8c1db72a7
--- /dev/null
+++ b/nx-X11/lib/X11/PutBEvent.c
@@ -0,0 +1,74 @@
+/* $Xorg: PutBEvent.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/PutBEvent.c,v 1.3 2001/01/17 19:41:41 dawes Exp $ */
+
+/* XPutBackEvent puts an event back at the head of the queue. */
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+_XPutBackEvent (
+ register Display *dpy,
+ register XEvent *event)
+ {
+ register _XQEvent *qelt;
+
+ if (!dpy->qfree) {
+ if ((dpy->qfree = (_XQEvent *) Xmalloc (sizeof (_XQEvent))) == NULL) {
+ return 0;
+ }
+ dpy->qfree->next = NULL;
+ }
+ qelt = dpy->qfree;
+ dpy->qfree = qelt->next;
+ qelt->qserial_num = dpy->next_event_serial_num++;
+ qelt->next = dpy->head;
+ qelt->event = *event;
+ dpy->head = qelt;
+ if (dpy->tail == NULL)
+ dpy->tail = qelt;
+ dpy->qlen++;
+ return 0;
+ }
+
+int
+XPutBackEvent (
+ register Display * dpy,
+ register XEvent *event)
+ {
+ int ret;
+
+ LockDisplay(dpy);
+ ret = _XPutBackEvent(dpy, event);
+ UnlockDisplay(dpy);
+ return ret;
+ }
diff --git a/nx-X11/lib/X11/PutImage.c b/nx-X11/lib/X11/PutImage.c
new file mode 100644
index 000000000..b44029409
--- /dev/null
+++ b/nx-X11/lib/X11/PutImage.c
@@ -0,0 +1,1044 @@
+/* $Xorg: PutImage.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/PutImage.c,v 3.11 2002/12/09 04:10:56 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xutil.h"
+#include <stdio.h>
+#include "Cr.h"
+#include "ImUtil.h"
+
+#if defined(__STDC__) && ((defined(sun) && defined(SVR4)) || defined(WIN32))
+#define RConst /**/
+#else
+#define RConst const
+#endif
+
+#if defined(Lynx) && defined(ROUNDUP)
+#undef ROUNDUP
+#endif
+
+/* assumes pad is a power of 2 */
+#define ROUNDUP(nbytes, pad) (((nbytes) + ((pad) - 1)) & ~(long)((pad) - 1))
+
+static unsigned char const _reverse_byte[0x100] = {
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
+};
+
+static unsigned char const _reverse_nibs[0x100] = {
+ 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
+ 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0,
+ 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
+ 0x81, 0x91, 0xa1, 0xb1, 0xc1, 0xd1, 0xe1, 0xf1,
+ 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72,
+ 0x82, 0x92, 0xa2, 0xb2, 0xc2, 0xd2, 0xe2, 0xf2,
+ 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73,
+ 0x83, 0x93, 0xa3, 0xb3, 0xc3, 0xd3, 0xe3, 0xf3,
+ 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74,
+ 0x84, 0x94, 0xa4, 0xb4, 0xc4, 0xd4, 0xe4, 0xf4,
+ 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75,
+ 0x85, 0x95, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5,
+ 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76,
+ 0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6,
+ 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77,
+ 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7,
+ 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78,
+ 0x88, 0x98, 0xa8, 0xb8, 0xc8, 0xd8, 0xe8, 0xf8,
+ 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79,
+ 0x89, 0x99, 0xa9, 0xb9, 0xc9, 0xd9, 0xe9, 0xf9,
+ 0x0a, 0x1a, 0x2a, 0x3a, 0x4a, 0x5a, 0x6a, 0x7a,
+ 0x8a, 0x9a, 0xaa, 0xba, 0xca, 0xda, 0xea, 0xfa,
+ 0x0b, 0x1b, 0x2b, 0x3b, 0x4b, 0x5b, 0x6b, 0x7b,
+ 0x8b, 0x9b, 0xab, 0xbb, 0xcb, 0xdb, 0xeb, 0xfb,
+ 0x0c, 0x1c, 0x2c, 0x3c, 0x4c, 0x5c, 0x6c, 0x7c,
+ 0x8c, 0x9c, 0xac, 0xbc, 0xcc, 0xdc, 0xec, 0xfc,
+ 0x0d, 0x1d, 0x2d, 0x3d, 0x4d, 0x5d, 0x6d, 0x7d,
+ 0x8d, 0x9d, 0xad, 0xbd, 0xcd, 0xdd, 0xed, 0xfd,
+ 0x0e, 0x1e, 0x2e, 0x3e, 0x4e, 0x5e, 0x6e, 0x7e,
+ 0x8e, 0x9e, 0xae, 0xbe, 0xce, 0xde, 0xee, 0xfe,
+ 0x0f, 0x1f, 0x2f, 0x3f, 0x4f, 0x5f, 0x6f, 0x7f,
+ 0x8f, 0x9f, 0xaf, 0xbf, 0xcf, 0xdf, 0xef, 0xff
+};
+
+int
+_XReverse_Bytes(
+ register unsigned char *bpt,
+ register int nb)
+{
+ do {
+ *bpt = _reverse_byte[*bpt];
+ bpt++;
+ } while (--nb > 0);
+ return 0;
+}
+
+
+/* XXX the following functions are declared int instead of void because various
+ * compilers and lints complain about later initialization of SwapFunc and/or
+ * (swapfunc == NoSwap) when void is used.
+ */
+
+/*ARGSUSED*/
+static void
+NoSwap (
+ register unsigned char *src,
+ register unsigned char *dest,
+ long srclen,
+ long srcinc,
+ long destinc,
+ unsigned int height,
+ int half_order)
+{
+ long h = height;
+
+ if (srcinc == destinc)
+ memcpy((char *)dest, (char *)src, (int)(srcinc * (h - 1) + srclen));
+ else
+ for (; --h >= 0; src += srcinc, dest += destinc)
+ memcpy((char *)dest, (char *)src, (int)srclen);
+}
+
+static void
+SwapTwoBytes (
+ register unsigned char *src,
+ register unsigned char *dest,
+ long srclen, long srcinc, long destinc,
+ unsigned int height,
+ int half_order)
+{
+ long length = ROUNDUP(srclen, 2);
+ register long h, n;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 2;
+ if (half_order == MSBFirst)
+ *(dest + length) = *(src + length + 1);
+ else
+ *(dest + length + 1) = *(src + length);
+ }
+ for (n = length; n > 0; n -= 2, src += 2) {
+ *dest++ = *(src + 1);
+ *dest++ = *src;
+ }
+ }
+}
+
+static void
+SwapThreeBytes (
+ register unsigned char *src,
+ register unsigned char *dest,
+ long srclen, long srcinc, long destinc,
+ unsigned int height,
+ int byte_order)
+{
+ long length = ((srclen + 2) / 3) * 3;
+ register long h, n;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 3;
+ if ((srclen - length) == 2)
+ *(dest + length + 1) = *(src + length + 1);
+ if (byte_order == MSBFirst)
+ *(dest + length) = *(src + length + 2);
+ else
+ *(dest + length + 2) = *(src + length);
+ }
+ for (n = length; n > 0; n -= 3, src += 3) {
+ *dest++ = *(src + 2);
+ *dest++ = *(src + 1);
+ *dest++ = *src;
+ }
+ }
+}
+
+static void
+SwapFourBytes (
+ register unsigned char *src,
+ register unsigned char *dest,
+ long srclen, long srcinc, long destinc,
+ unsigned int height,
+ int half_order)
+{
+ long length = ROUNDUP(srclen, 4);
+ register long h, n;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 4;
+ if (half_order == MSBFirst)
+ *(dest + length) = *(src + length + 3);
+ if (((half_order == LSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == MSBFirst) && (srclen & 2)))
+ *(dest + length + 1) = *(src + length + 2);
+ if (((half_order == MSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == LSBFirst) && (srclen & 2)))
+ *(dest + length + 2) = *(src + length + 1);
+ if (half_order == LSBFirst)
+ *(dest + length + 3) = *(src + length);
+ }
+ for (n = length; n > 0; n -= 4, src += 4) {
+ *dest++ = *(src + 3);
+ *dest++ = *(src + 2);
+ *dest++ = *(src + 1);
+ *dest++ = *src;
+ }
+ }
+}
+
+static void
+SwapWords (
+ register unsigned char *src,
+ register unsigned char *dest,
+ long srclen, long srcinc, long destinc,
+ unsigned int height,
+ int half_order)
+{
+ long length = ROUNDUP(srclen, 4);
+ register long h, n;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 4;
+ if (half_order == MSBFirst)
+ *(dest + length + 1) = *(src + length + 3);
+ if (((half_order == LSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == MSBFirst) && (srclen & 2)))
+ *(dest + length) = *(src + length + 2);
+ if (((half_order == MSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == LSBFirst) && (srclen & 2)))
+ *(dest + length + 3) = *(src + length + 1);
+ if (half_order == LSBFirst)
+ *(dest + length + 2) = *(src + length);
+ }
+ for (n = length; n > 0; n -= 4, src += 2) {
+ *dest++ = *(src + 2);
+ *dest++ = *(src + 3);
+ *dest++ = *src++;
+ *dest++ = *src++;
+ }
+ }
+}
+
+static void
+SwapNibbles(
+ register unsigned char *src,
+ register unsigned char *dest,
+ long srclen, long srcinc, long destinc,
+ unsigned int height)
+{
+ register long h, n;
+ register const unsigned char *rev = _reverse_nibs;
+
+ srcinc -= srclen;
+ destinc -= srclen;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc)
+ for (n = srclen; --n >= 0; )
+ *dest++ = rev[*src++];
+}
+
+static void
+ShiftNibblesLeft (
+ register unsigned char *src,
+ register unsigned char *dest,
+ long srclen, long srcinc, long destinc,
+ unsigned int height,
+ int nibble_order)
+{
+ register long h, n;
+ register unsigned char c1, c2;
+
+ srcinc -= srclen;
+ destinc -= srclen;
+ if (nibble_order == MSBFirst) {
+ for (h = height; --h >= 0; src += srcinc, dest += destinc)
+ for (n = srclen; --n >= 0; ) {
+ c1 = *src++;
+ c2 = *src;
+ *dest++ = ((c1 & 0x0f) << 4) | ((c2 & (unsigned)0xf0) >> 4);
+ }
+ } else {
+ for (h = height; --h >= 0; src += srcinc, dest += destinc)
+ for (n = srclen; --n >= 0; ) {
+ c1 = *src++;
+ c2 = *src;
+ *dest++ = ((c2 & 0x0f) << 4) | ((c1 & (unsigned)0xf0) >> 4);
+ }
+ }
+}
+
+/*ARGSUSED*/
+static void
+SwapBits(
+ register unsigned char *src,
+ register unsigned char *dest,
+ long srclen, long srcinc, long destinc,
+ unsigned int height,
+ int half_order)
+{
+ register long h, n;
+ register const unsigned char *rev = _reverse_byte;
+
+ srcinc -= srclen;
+ destinc -= srclen;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc)
+ for (n = srclen; --n >= 0; )
+ *dest++ = rev[*src++];
+}
+
+static void
+SwapBitsAndTwoBytes(
+ register unsigned char *src,
+ register unsigned char *dest,
+ long srclen, long srcinc, long destinc,
+ unsigned int height,
+ int half_order)
+{
+ long length = ROUNDUP(srclen, 2);
+ register long h, n;
+ register const unsigned char *rev = _reverse_byte;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 2;
+ if (half_order == MSBFirst)
+ *(dest + length) = rev[*(src + length + 1)];
+ else
+ *(dest + length + 1) = rev[*(src + length)];
+ }
+ for (n = length; n > 0; n -= 2, src += 2) {
+ *dest++ = rev[*(src + 1)];
+ *dest++ = rev[*src];
+ }
+ }
+}
+
+static void
+SwapBitsAndFourBytes(
+ register unsigned char *src,
+ register unsigned char *dest,
+ long srclen, long srcinc, long destinc,
+ unsigned int height,
+ int half_order)
+{
+ long length = ROUNDUP(srclen, 4);
+ register long h, n;
+ register const unsigned char *rev = _reverse_byte;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 4;
+ if (half_order == MSBFirst)
+ *(dest + length) = rev[*(src + length + 3)];
+ if (((half_order == LSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == MSBFirst) && (srclen & 2)))
+ *(dest + length + 1) = rev[*(src + length + 2)];
+ if (((half_order == MSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == LSBFirst) && (srclen & 2)))
+ *(dest + length + 2) = rev[*(src + length + 1)];
+ if (half_order == LSBFirst)
+ *(dest + length + 3) = rev[*(src + length)];
+ }
+ for (n = length; n > 0; n -= 4, src += 4) {
+ *dest++ = rev[*(src + 3)];
+ *dest++ = rev[*(src + 2)];
+ *dest++ = rev[*(src + 1)];
+ *dest++ = rev[*src];
+ }
+ }
+}
+
+static void
+SwapBitsAndWords(
+ register unsigned char *src,
+ register unsigned char *dest,
+ long srclen, long srcinc, long destinc,
+ unsigned int height,
+ int half_order)
+{
+ long length = ROUNDUP(srclen, 4);
+ register long h, n;
+ register const unsigned char *rev = _reverse_byte;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 4;
+ if (half_order == MSBFirst)
+ *(dest + length + 1) = rev[*(src + length + 3)];
+ if (((half_order == LSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == MSBFirst) && (srclen & 2)))
+ *(dest + length) = rev[*(src + length + 2)];
+ if (((half_order == MSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == LSBFirst) && (srclen & 2)))
+ *(dest + length + 3) = rev[*(src + length + 1)];
+ if (half_order == LSBFirst)
+ *(dest + length + 2) = rev[*(src + length)];
+ }
+ for (n = length; n > 0; n -= 4, src += 2) {
+ *dest++ = rev[*(src + 2)];
+ *dest++ = rev[*(src + 3)];
+ *dest++ = rev[*src++];
+ *dest++ = rev[*src++];
+ }
+ }
+}
+
+/*
+
+The following table gives the bit ordering within bytes (when accessed
+sequentially) for a scanline containing 32 bits, with bits numbered 0 to
+31, where bit 0 should be leftmost on the display. For a given byte
+labelled A-B, A is for the most significant bit of the byte, and B is
+for the least significant bit.
+
+legend:
+ 1 scanline-unit = 8
+ 2 scanline-unit = 16
+ 4 scanline-unit = 32
+ M byte-order = MostSignificant
+ L byte-order = LeastSignificant
+ m bit-order = MostSignificant
+ l bit-order = LeastSignificant
+
+
+format ordering
+
+1Mm 00-07 08-15 16-23 24-31
+2Mm 00-07 08-15 16-23 24-31
+4Mm 00-07 08-15 16-23 24-31
+1Ml 07-00 15-08 23-16 31-24
+2Ml 15-08 07-00 31-24 23-16
+4Ml 31-24 23-16 15-08 07-00
+1Lm 00-07 08-15 16-23 24-31
+2Lm 08-15 00-07 24-31 16-23
+4Lm 24-31 16-23 08-15 00-07
+1Ll 07-00 15-08 23-16 31-24
+2Ll 07-00 15-08 23-16 31-24
+4Ll 07-00 15-08 23-16 31-24
+
+
+The following table gives the required conversion between any two
+formats. It is based strictly on the table above. If you believe one,
+you should believe the other.
+
+legend:
+ n no changes
+ s reverse 8-bit units within 16-bit units
+ l reverse 8-bit units within 32-bit units
+ w reverse 16-bit units within 32-bit units
+ R reverse bits within 8-bit units
+ S s+R
+ L l+R
+ W w+R
+
+*/
+
+static void (* RConst (SwapFunction[12][12]))(
+ register unsigned char *src,
+ register unsigned char *dest,
+ long srclen,
+ long srcinc,
+ long destinc,
+ unsigned int height,
+ int half_order) = {
+#define n NoSwap,
+#define s SwapTwoBytes,
+#define l SwapFourBytes,
+#define w SwapWords,
+#define R SwapBits,
+#define S SwapBitsAndTwoBytes,
+#define L SwapBitsAndFourBytes,
+#define W SwapBitsAndWords,
+
+/* 1Mm 2Mm 4Mm 1Ml 2Ml 4Ml 1Lm 2Lm 4Lm 1Ll 2Ll 4Ll */
+/* 1Mm */ { n n n R S L n s l R R R },
+/* 2Mm */ { n n n R S L n s l R R R },
+/* 4Mm */ { n n n R S L n s l R R R },
+/* 1Ml */ { R R R n s l R S L n n n },
+/* 2Ml */ { S S S s n w S R W s s s },
+/* 4Ml */ { L L L l w n L W R l l l },
+/* 1Lm */ { n n n R S L n s l R R R },
+/* 2Lm */ { s s s S R W s n w S S S },
+/* 4Lm */ { l l l L W R l w n L L L },
+/* 1Ll */ { R R R n s l R S L n n n },
+/* 2Ll */ { R R R n s l R S L n n n },
+/* 4Ll */ { R R R n s l R S L n n n }
+
+#undef n
+#undef s
+#undef l
+#undef w
+#undef R
+#undef S
+#undef L
+#undef W
+
+};
+
+/* Of course, the table above is a lie. We also need to factor in the
+ * order of the source data to cope with swapping half of a unit at the
+ * end of a scanline, since we are trying to avoid de-ref'ing off the
+ * end of the source.
+ *
+ * Defines whether the first half of a unit has the first half of the data
+ */
+static int const HalfOrder[12] = {
+ LSBFirst, /* 1Mm */
+ LSBFirst, /* 2Mm */
+ LSBFirst, /* 4Mm */
+ LSBFirst, /* 1Ml */
+ MSBFirst, /* 2Ml */
+ MSBFirst, /* 4Ml */
+ LSBFirst, /* 1Lm */
+ MSBFirst, /* 2Lm */
+ MSBFirst, /* 4Lm */
+ LSBFirst, /* 1Ll */
+ LSBFirst, /* 2Ll */
+ LSBFirst /* 4Ll */
+ };
+
+/* Finally, for SwapWords cases, the half order depends not just on the source
+ * but also on the destination scanline unit. Use of this table changes some
+ * MSBFirsts to LSBFirsts that are "do not care" (because the function will be
+ * NoSwap or SwapBits) in addition to changing the desired ones.
+ */
+
+static int const HalfOrderWord[12] = {
+ MSBFirst, /* 1Mm */
+ MSBFirst, /* 2Mm */
+ MSBFirst, /* 4Mm */
+ MSBFirst, /* 1Ml */
+ MSBFirst, /* 2Ml */
+ LSBFirst, /* 4Ml */
+ MSBFirst, /* 1Lm */
+ MSBFirst, /* 2Lm */
+ LSBFirst, /* 4Lm */
+ MSBFirst, /* 1Ll */
+ MSBFirst, /* 2Ll */
+ MSBFirst /* 4Ll */
+ };
+
+/*
+ * This macro creates a value from 0 to 11 suitable for indexing
+ * into the table above.
+ */
+#define ComposeIndex(bitmap_unit, bitmap_bit_order, byte_order) \
+ (((bitmap_unit == 32) ? 2 : ((bitmap_unit == 16) ? 1 : 0)) \
+ + (((bitmap_bit_order == MSBFirst) ? 0 : 3) \
+ + ((byte_order == MSBFirst) ? 0 : 6)))
+
+/* Cancel a GetReq operation, before doing _XSend or Data */
+
+#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#define UnGetReq(name)\
+ dpy->bufptr -= SIZEOF(x##name##Req);\
+ dpy->request--
+#else
+#define UnGetReq(name)\
+ dpy->bufptr -= SIZEOF(x/**/name/**/Req);\
+ dpy->request--
+#endif
+
+static void
+SendXYImage(
+ register Display *dpy,
+ register xPutImageReq *req,
+ register XImage *image,
+ int req_xoffset, int req_yoffset)
+{
+ register int j;
+ long total_xoffset, bytes_per_src, bytes_per_dest, length;
+ long bytes_per_line, bytes_per_src_plane, bytes_per_dest_plane;
+ char *src, *dest, *buf;
+ char *extra = (char *)NULL;
+ register void (*swapfunc)(
+ register unsigned char *src,
+ register unsigned char *dest,
+ long srclen,
+ long srcinc,
+ long destinc,
+ unsigned int height,
+ int half_order);
+ int half_order;
+
+ total_xoffset = image->xoffset + req_xoffset;
+ req->leftPad = total_xoffset & (dpy->bitmap_unit - 1);
+ total_xoffset = (unsigned)(total_xoffset - req->leftPad) >> 3;
+ /* The protocol requires left-pad of zero on all ZPixmap, even
+ * though the 1-bit case is identical to bitmap format. This is a
+ * bug in the protocol, caused because 1-bit ZPixmap was added late
+ * in the game. Hairy shifting code compensation isn't worth it,
+ * just use XYPixmap format instead.
+ */
+ if ((req->leftPad != 0) && (req->format == ZPixmap))
+ req->format = XYPixmap;
+ bytes_per_dest = (unsigned long)ROUNDUP((long)req->width + req->leftPad,
+ dpy->bitmap_pad) >> 3;
+ bytes_per_dest_plane = bytes_per_dest * req->height;
+ length = bytes_per_dest_plane * image->depth;
+ req->length += (length + 3) >> 2;
+
+ swapfunc = SwapFunction[ComposeIndex(image->bitmap_unit,
+ image->bitmap_bit_order,
+ image->byte_order)]
+ [ComposeIndex(dpy->bitmap_unit,
+ dpy->bitmap_bit_order,
+ dpy->byte_order)];
+ half_order = HalfOrder[ComposeIndex(image->bitmap_unit,
+ image->bitmap_bit_order,
+ image->byte_order)];
+ if (half_order == MSBFirst)
+ half_order = HalfOrderWord[ComposeIndex(dpy->bitmap_unit,
+ dpy->bitmap_bit_order,
+ dpy->byte_order)];
+
+ src = image->data + (image->bytes_per_line * req_yoffset) + total_xoffset;
+
+ /* when total_xoffset > 0, we have to worry about stepping off the
+ * end of image->data.
+ */
+ if ((swapfunc == NoSwap) &&
+ (image->bytes_per_line == bytes_per_dest) &&
+ (((total_xoffset == 0) &&
+ ((image->depth == 1) || (image->height == req->height))) ||
+ ((image->depth == 1) &&
+ ((req_yoffset + req->height) < (unsigned)image->height)))) {
+ Data(dpy, src, length);
+ return;
+ }
+
+ length = ROUNDUP(length, 4);
+ if ((dpy->bufptr + length) > dpy->bufmax) {
+ if ((buf = _XAllocScratch(dpy, (unsigned long) (length))) == NULL) {
+ UnGetReq(PutImage);
+ return;
+ }
+ }
+ else
+ buf = dpy->bufptr;
+
+ bytes_per_src = (req->width + req->leftPad + (unsigned)7) >> 3;
+ bytes_per_line = image->bytes_per_line;
+ bytes_per_src_plane = bytes_per_line * image->height;
+ total_xoffset &= (image->bitmap_unit - 1) >> 3;
+
+ if ((total_xoffset > 0) &&
+ (image->byte_order != image->bitmap_bit_order)) {
+ char *temp;
+ long bytes_per_temp_plane, temp_length;
+
+ bytes_per_line = bytes_per_src + total_xoffset;
+ src -= total_xoffset;
+ bytes_per_temp_plane = bytes_per_line * req->height;
+ temp_length = ROUNDUP(bytes_per_temp_plane * image->depth, 4);
+ if (buf == dpy->bufptr) {
+ if (! (temp = _XAllocScratch(dpy, (unsigned long) temp_length))) {
+ UnGetReq(PutImage);
+ return;
+ }
+ }
+ else
+ if ((extra = temp = Xmalloc((unsigned) temp_length)) == NULL) {
+ UnGetReq(PutImage);
+ return;
+ }
+
+ swapfunc = SwapFunction[ComposeIndex(image->bitmap_unit,
+ image->bitmap_bit_order,
+ image->byte_order)]
+ [ComposeIndex(image->bitmap_unit,
+ dpy->byte_order,
+ dpy->byte_order)];
+ for (dest = temp, j = image->depth;
+ --j >= 0;
+ src += bytes_per_src_plane, dest += bytes_per_temp_plane)
+ (*swapfunc)((unsigned char *)src, (unsigned char *)dest,
+ bytes_per_line, (long)image->bytes_per_line,
+ bytes_per_line, req->height, half_order);
+ swapfunc = SwapFunction[ComposeIndex(image->bitmap_unit,
+ dpy->byte_order,
+ dpy->byte_order)]
+ [ComposeIndex(dpy->bitmap_unit,
+ dpy->bitmap_bit_order,
+ dpy->byte_order)];
+ half_order = HalfOrder[ComposeIndex(image->bitmap_unit,
+ dpy->byte_order,
+ dpy->byte_order)];
+ src = temp + total_xoffset;
+ bytes_per_src_plane = bytes_per_temp_plane;
+ }
+
+ for (dest = buf, j = image->depth;
+ --j >= 0;
+ src += bytes_per_src_plane, dest += bytes_per_dest_plane)
+ (*swapfunc)((unsigned char *)src, (unsigned char *)dest,
+ bytes_per_src, bytes_per_line,
+ bytes_per_dest, req->height, half_order);
+
+ if (extra)
+ Xfree(extra);
+
+ if (buf == dpy->bufptr)
+ dpy->bufptr += length;
+ else
+ _XSend(dpy, buf, length);
+ }
+
+static void
+SendZImage(
+ register Display *dpy,
+ register xPutImageReq *req,
+ register XImage *image,
+ int req_xoffset, int req_yoffset,
+ int dest_bits_per_pixel, int dest_scanline_pad)
+{
+ long bytes_per_src, bytes_per_dest, length;
+ unsigned char *src, *dest;
+ unsigned char *shifted_src = NULL;
+
+ req->leftPad = 0;
+ bytes_per_src = ROUNDUP((long)req->width * image->bits_per_pixel, 8) >> 3;
+ bytes_per_dest = ROUNDUP((long)req->width * dest_bits_per_pixel,
+ dest_scanline_pad) >> 3;
+ length = bytes_per_dest * req->height;
+ req->length += (length + 3) >> 2;
+
+ src = (unsigned char *)image->data +
+ (req_yoffset * image->bytes_per_line) +
+ ((req_xoffset * image->bits_per_pixel) >> 3);
+ if ((image->bits_per_pixel == 4) && ((unsigned int) req_xoffset & 0x01)) {
+ if (! (shifted_src = (unsigned char *)
+ Xmalloc((unsigned) (req->height * image->bytes_per_line)))) {
+ UnGetReq(PutImage);
+ return;
+ }
+
+ ShiftNibblesLeft(src, shifted_src, bytes_per_src,
+ (long) image->bytes_per_line,
+ (long) image->bytes_per_line, req->height,
+ image->byte_order);
+ src = shifted_src;
+ }
+
+ /* when req_xoffset > 0, we have to worry about stepping off the
+ * end of image->data.
+ */
+ if (((image->byte_order == dpy->byte_order) ||
+ (image->bits_per_pixel == 8)) &&
+ ((long)image->bytes_per_line == bytes_per_dest) &&
+ ((req_xoffset == 0) ||
+ ((req_yoffset + req->height) < (unsigned)image->height))) {
+ Data(dpy, (char *)src, length);
+ if (shifted_src)
+ Xfree((char *)shifted_src);
+ return;
+ }
+
+ length = ROUNDUP(length, 4);
+ if ((dpy->bufptr + length) <= dpy->bufmax)
+ dest = (unsigned char *)dpy->bufptr;
+ else
+ if ((dest = (unsigned char *)
+ _XAllocScratch(dpy, (unsigned long)(length))) == NULL) {
+ if (shifted_src) Xfree((char *) shifted_src);
+ UnGetReq(PutImage);
+ return;
+ }
+
+ if ((image->byte_order == dpy->byte_order) ||
+ (image->bits_per_pixel == 8))
+ NoSwap(src, dest, bytes_per_src, (long)image->bytes_per_line,
+ bytes_per_dest, req->height, image->byte_order);
+ else if (image->bits_per_pixel == 32)
+ SwapFourBytes(src, dest, bytes_per_src, (long)image->bytes_per_line,
+ bytes_per_dest, req->height, image->byte_order);
+ else if (image->bits_per_pixel == 24)
+ SwapThreeBytes(src, dest, bytes_per_src, (long)image->bytes_per_line,
+ bytes_per_dest, req->height, image->byte_order);
+ else if (image->bits_per_pixel == 16)
+ SwapTwoBytes(src, dest, bytes_per_src, (long)image->bytes_per_line,
+ bytes_per_dest, req->height, image->byte_order);
+ else
+ SwapNibbles(src, dest, bytes_per_src, (long)image->bytes_per_line,
+ bytes_per_dest, req->height);
+
+ if (dest == (unsigned char *)dpy->bufptr)
+ dpy->bufptr += length;
+ else
+ _XSend(dpy, (char *)dest, length);
+
+ if (shifted_src)
+ Xfree((char *)shifted_src);
+}
+
+static void
+PutImageRequest(
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ register XImage *image,
+ int req_xoffset, int req_yoffset,
+ int x, int y,
+ unsigned int req_width, unsigned int req_height,
+ int dest_bits_per_pixel, int dest_scanline_pad)
+{
+ register xPutImageReq *req;
+
+ GetReq(PutImage, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->dstX = x;
+ req->dstY = y;
+ req->width = req_width;
+ req->height = req_height;
+ req->depth = image->depth;
+ req->format = image->format;
+ if ((image->bits_per_pixel == 1) || (image->format != ZPixmap))
+ SendXYImage(dpy, req, image, req_xoffset, req_yoffset);
+ else
+ SendZImage(dpy, req, image, req_xoffset, req_yoffset,
+ dest_bits_per_pixel, dest_scanline_pad);
+}
+
+static void
+PutSubImage (
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ register XImage *image,
+ int req_xoffset,
+ int req_yoffset,
+ int x, int y,
+ unsigned int req_width,
+ unsigned int req_height,
+ int dest_bits_per_pixel,
+ int dest_scanline_pad)
+{
+ int left_pad, BytesPerRow, Available;
+
+ if ((req_width == 0) || (req_height == 0))
+ return;
+
+ Available = ((65536 < dpy->max_request_size) ? (65536 << 2)
+ : (dpy->max_request_size << 2))
+ - SIZEOF(xPutImageReq);
+
+ if ((image->bits_per_pixel == 1) || (image->format != ZPixmap)) {
+ left_pad = (image->xoffset + req_xoffset) & (dpy->bitmap_unit - 1);
+ BytesPerRow = (ROUNDUP((long)req_width + left_pad,
+ dpy->bitmap_pad) >> 3) * image->depth;
+ } else {
+ left_pad = 0;
+ BytesPerRow = ROUNDUP((long)req_width * dest_bits_per_pixel,
+ dest_scanline_pad) >> 3;
+ }
+
+ if ((BytesPerRow * req_height) <= Available) {
+ PutImageRequest(dpy, d, gc, image, req_xoffset, req_yoffset, x, y,
+ req_width, req_height,
+ dest_bits_per_pixel, dest_scanline_pad);
+ } else if (req_height > 1) {
+ int SubImageHeight = Available / BytesPerRow;
+
+ if (SubImageHeight == 0)
+ SubImageHeight = 1;
+
+ PutSubImage(dpy, d, gc, image, req_xoffset, req_yoffset, x, y,
+ req_width, (unsigned int) SubImageHeight,
+ dest_bits_per_pixel, dest_scanline_pad);
+
+ PutSubImage(dpy, d, gc, image, req_xoffset,
+ req_yoffset + SubImageHeight, x, y + SubImageHeight,
+ req_width, req_height - SubImageHeight,
+ dest_bits_per_pixel, dest_scanline_pad);
+ } else {
+ int SubImageWidth = (((Available << 3) / dest_scanline_pad)
+ * dest_scanline_pad) - left_pad;
+
+ PutSubImage(dpy, d, gc, image, req_xoffset, req_yoffset, x, y,
+ (unsigned int) SubImageWidth, 1,
+ dest_bits_per_pixel, dest_scanline_pad);
+
+ PutSubImage(dpy, d, gc, image, req_xoffset + SubImageWidth,
+ req_yoffset, x + SubImageWidth, y,
+ req_width - SubImageWidth, 1,
+ dest_bits_per_pixel, dest_scanline_pad);
+ }
+}
+
+
+int
+XPutImage (dpy, d, gc, image, req_xoffset, req_yoffset, x, y, req_width,
+ req_height)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ register XImage *image;
+ int x, y;
+ unsigned int req_width, req_height;
+ int req_xoffset, req_yoffset;
+
+{
+ long width = req_width;
+ long height = req_height;
+ int dest_bits_per_pixel, dest_scanline_pad;
+
+ if (req_xoffset < 0) {
+ width += req_xoffset;
+ req_xoffset = 0;
+ }
+ if (req_yoffset < 0) {
+ height += req_yoffset;
+ req_yoffset = 0;
+ }
+ if ((req_xoffset + width) > image->width)
+ width = image->width - req_xoffset;
+ if ((req_yoffset + height) > image->height)
+ height = image->height - req_yoffset;
+ if ((width <= 0) || (height <= 0))
+ return 0;
+
+ if ((image->bits_per_pixel == 1) || (image->format != ZPixmap)) {
+ dest_bits_per_pixel = 1;
+ dest_scanline_pad = dpy->bitmap_pad;
+ } else {
+ register int n;
+ register ScreenFormat *format;
+
+ dest_bits_per_pixel = image->bits_per_pixel;
+ dest_scanline_pad = image->bitmap_pad;
+ for (n = dpy->nformats, format = dpy->pixmap_format; --n >= 0; format++)
+ if (format->depth == image->depth) {
+ dest_bits_per_pixel = format->bits_per_pixel;
+ dest_scanline_pad = format->scanline_pad;
+ }
+ if (dest_bits_per_pixel != image->bits_per_pixel) {
+ XImage img;
+ register long i, j;
+ /* XXX slow, but works */
+ img.width = width;
+ img.height = height;
+ img.xoffset = 0;
+ img.format = ZPixmap;
+ img.byte_order = dpy->byte_order;
+ img.bitmap_unit = dpy->bitmap_unit;
+ img.bitmap_bit_order = dpy->bitmap_bit_order;
+ img.bitmap_pad = dest_scanline_pad;
+ img.depth = image->depth;
+ img.bits_per_pixel = dest_bits_per_pixel;
+ img.bytes_per_line = ROUNDUP((dest_bits_per_pixel * width),
+ dest_scanline_pad) >> 3;
+ img.data = Xmalloc((unsigned) (img.bytes_per_line * height));
+ if (img.data == NULL)
+ return 0;
+ _XInitImageFuncPtrs(&img);
+ for (j = height; --j >= 0; )
+ for (i = width; --i >= 0; )
+ XPutPixel(&img, i, j, XGetPixel(image, req_xoffset + i,
+ req_yoffset + j));
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ PutSubImage(dpy, d, gc, &img, 0, 0, x, y,
+ (unsigned int) width, (unsigned int) height,
+ dest_bits_per_pixel, dest_scanline_pad);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ Xfree(img.data);
+ return 0;
+ }
+ }
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ PutSubImage(dpy, d, gc, image, req_xoffset, req_yoffset, x, y,
+ (unsigned int) width, (unsigned int) height,
+ dest_bits_per_pixel, dest_scanline_pad);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+#ifdef USE_DYNAMIC_XCURSOR
+ if (image->bits_per_pixel == 1 &&
+ x == 0 && y == 0 &&
+ width == image->width && height == image->height &&
+ gc->values.function == GXcopy &&
+ (gc->values.plane_mask & 1))
+ {
+ _XNoticePutBitmap (dpy, d, image);
+ }
+#endif
+ return 0;
+}
diff --git a/nx-X11/lib/X11/QBlack.c b/nx-X11/lib/X11/QBlack.c
new file mode 100644
index 000000000..ec0449405
--- /dev/null
+++ b/nx-X11/lib/X11/QBlack.c
@@ -0,0 +1,85 @@
+/* $Xorg: QBlack.c,v 1.3 2000/08/17 19:44:49 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQBlack.c - Query Black
+ *
+ * DESCRIPTION
+ * Routine to obtain a color specification for zero
+ * red, green, and blue intensities.
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsQueryBlack
+ *
+ * SYNOPSIS
+ */
+
+Status
+XcmsQueryBlack(ccc, target_format, pColor_ret)
+ XcmsCCC ccc;
+ XcmsColorFormat target_format;
+ XcmsColor *pColor_ret;
+/*
+ * DESCRIPTION
+ * Returns the color specification in the target format for
+ * zero intensity red, green, and blue.
+ *
+ * RETURNS
+ * Returns XcmsSuccess, if failed; otherwise XcmsFailure
+ *
+ */
+{
+ XcmsColor tmp;
+
+ tmp.format = XcmsRGBiFormat;
+ tmp.pixel = 0;
+ tmp.spec.RGBi.red = 0.0;
+ tmp.spec.RGBi.green = 0.0;
+ tmp.spec.RGBi.blue = 0.0;
+ if (XcmsConvertColors(ccc, &tmp, 1, target_format, NULL) != XcmsSuccess) {
+ return(XcmsFailure);
+ }
+ memcpy((char *)pColor_ret, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/QBlue.c b/nx-X11/lib/X11/QBlue.c
new file mode 100644
index 000000000..602685190
--- /dev/null
+++ b/nx-X11/lib/X11/QBlue.c
@@ -0,0 +1,85 @@
+/* $Xorg: QBlue.c,v 1.3 2000/08/17 19:44:49 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQBlue.c - Query Blue
+ *
+ * DESCRIPTION
+ * Routine to obtain a color specification for full
+ * blue intensity and zero red and green intensities.
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsQueryBlue
+ *
+ * SYNOPSIS
+ */
+
+Status
+XcmsQueryBlue(ccc, target_format, pColor_ret)
+ XcmsCCC ccc;
+ XcmsColorFormat target_format;
+ XcmsColor *pColor_ret;
+/*
+ * DESCRIPTION
+ * Returns the color specification in the target format for
+ * full intensity blue and zero intensity red and green.
+ *
+ * RETURNS
+ * Returns XcmsSuccess, if failed; otherwise XcmsFailure
+ *
+ */
+{
+ XcmsColor tmp;
+
+ tmp.format = XcmsRGBiFormat;
+ tmp.pixel = 0;
+ tmp.spec.RGBi.red = 0.0;
+ tmp.spec.RGBi.green = 0.0;
+ tmp.spec.RGBi.blue = 1.0;
+ if (XcmsConvertColors(ccc, &tmp, 1, target_format, NULL) != XcmsSuccess) {
+ return(XcmsFailure);
+ }
+ memcpy((char *)pColor_ret, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/QGreen.c b/nx-X11/lib/X11/QGreen.c
new file mode 100644
index 000000000..59bbbd5f9
--- /dev/null
+++ b/nx-X11/lib/X11/QGreen.c
@@ -0,0 +1,85 @@
+/* $Xorg: QGreen.c,v 1.3 2000/08/17 19:44:49 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQGreen.c - Query Green
+ *
+ * DESCRIPTION
+ * Routine to obtain a color specification for full
+ * green intensity and zero red and blue intensities.
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsQueryGreen
+ *
+ * SYNOPSIS
+ */
+
+Status
+XcmsQueryGreen(ccc, target_format, pColor_ret)
+ XcmsCCC ccc;
+ XcmsColorFormat target_format;
+ XcmsColor *pColor_ret;
+/*
+ * DESCRIPTION
+ * Returns the color specification in the target format for
+ * full intensity green and zero intensity red and blue.
+ *
+ * RETURNS
+ * Returns XcmsSuccess, if failed; otherwise XcmsFailure
+ *
+ */
+{
+ XcmsColor tmp;
+
+ tmp.format = XcmsRGBiFormat;
+ tmp.pixel = 0;
+ tmp.spec.RGBi.red = 0.0;
+ tmp.spec.RGBi.green = 1.0;
+ tmp.spec.RGBi.blue = 0.0;
+ if (XcmsConvertColors(ccc, &tmp, 1, target_format, NULL) != XcmsSuccess) {
+ return(XcmsFailure);
+ }
+ memcpy((char *)pColor_ret, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/QRed.c b/nx-X11/lib/X11/QRed.c
new file mode 100644
index 000000000..bcd276c24
--- /dev/null
+++ b/nx-X11/lib/X11/QRed.c
@@ -0,0 +1,85 @@
+/* $Xorg: QRed.c,v 1.3 2000/08/17 19:44:49 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQRed.c - Query Red
+ *
+ * DESCRIPTION
+ * Routine to obtain a color specification for full
+ * red intensity and zero green and blue intensities.
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsQueryRed
+ *
+ * SYNOPSIS
+ */
+
+Status
+XcmsQueryRed(ccc, target_format, pColor_ret)
+ XcmsCCC ccc;
+ XcmsColorFormat target_format;
+ XcmsColor *pColor_ret;
+/*
+ * DESCRIPTION
+ * Returns the color specification in the target format for
+ * full intensity red and zero intensity green and blue.
+ *
+ * RETURNS
+ * Returns XcmsSuccess, if failed; otherwise XcmsFailure
+ *
+ */
+{
+ XcmsColor tmp;
+
+ tmp.format = XcmsRGBiFormat;
+ tmp.pixel = 0;
+ tmp.spec.RGBi.red = 1.0;
+ tmp.spec.RGBi.green = 0.0;
+ tmp.spec.RGBi.blue = 0.0;
+ if (XcmsConvertColors(ccc, &tmp, 1, target_format, NULL) != XcmsSuccess) {
+ return(XcmsFailure);
+ }
+ memcpy((char *)pColor_ret, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/QWhite.c b/nx-X11/lib/X11/QWhite.c
new file mode 100644
index 000000000..7e58db658
--- /dev/null
+++ b/nx-X11/lib/X11/QWhite.c
@@ -0,0 +1,85 @@
+/* $Xorg: QWhite.c,v 1.3 2000/08/17 19:44:49 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQWhite.c - Query White
+ *
+ * DESCRIPTION
+ * Routine to obtain a color specification for full
+ * red, green, and blue intensities.
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsQueryWhite
+ *
+ * SYNOPSIS
+ */
+
+Status
+XcmsQueryWhite(ccc, target_format, pColor_ret)
+ XcmsCCC ccc;
+ XcmsColorFormat target_format;
+ XcmsColor *pColor_ret;
+/*
+ * DESCRIPTION
+ * Returns the color specification in the target format for
+ * full intensity red, green, and blue.
+ *
+ * RETURNS
+ * Returns XcmsSuccess, if failed; otherwise XcmsFailure
+ *
+ */
+{
+ XcmsColor tmp;
+
+ tmp.format = XcmsRGBiFormat;
+ tmp.pixel = 0;
+ tmp.spec.RGBi.red = 1.0;
+ tmp.spec.RGBi.green = 1.0;
+ tmp.spec.RGBi.blue = 1.0;
+ if (XcmsConvertColors(ccc, &tmp, 1, target_format, NULL) != XcmsSuccess) {
+ return(XcmsFailure);
+ }
+ memcpy((char *)pColor_ret, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/QuBest.c b/nx-X11/lib/X11/QuBest.c
new file mode 100644
index 000000000..7fe218147
--- /dev/null
+++ b/nx-X11/lib/X11/QuBest.c
@@ -0,0 +1,61 @@
+/* $Xorg: QuBest.c,v 1.4 2001/02/09 02:03:35 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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+Status XQueryBestSize(dpy, class, drawable, width, height, ret_width, ret_height)
+ register Display *dpy;
+ int class;
+ Drawable drawable;
+ unsigned int width, height;
+ unsigned int *ret_width, *ret_height;
+{
+ xQueryBestSizeReply rep;
+ register xQueryBestSizeReq *req;
+
+ LockDisplay(dpy);
+ GetReq(QueryBestSize, req);
+ req->class = class;
+ req->drawable = drawable;
+ req->width = width;
+ req->height = height;
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ *ret_width = rep.width;
+ *ret_height = rep.height;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/QuCol.c b/nx-X11/lib/X11/QuCol.c
new file mode 100644
index 000000000..0864bc8a1
--- /dev/null
+++ b/nx-X11/lib/X11/QuCol.c
@@ -0,0 +1,80 @@
+/* $Xorg: QuCol.c,v 1.3 2000/08/17 19:44:50 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQuCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsQueryColors
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/QuCol.c,v 1.3 2001/01/17 19:41:42 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsQueryColor - Query Color
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsQueryColor(dpy, colormap, pXcmsColor_in_out, result_format)
+ Display *dpy;
+ Colormap colormap;
+ XcmsColor *pXcmsColor_in_out;
+ XcmsColorFormat result_format;
+/*
+ * DESCRIPTION
+ * This routine uses XQueryColor to obtain the X RGB values
+ * stored in the specified colormap for the specified pixel.
+ * The X RGB values are then converted to the target format as
+ * specified by the format component of the XcmsColor structure.
+ *
+ * RETURNS
+ * XcmsFailure if failed;
+ * XcmsSuccess if it succeeded.
+ *
+ * Returns a color specification of the color stored in the
+ * specified pixel.
+ */
+{
+ return(_XcmsSetGetColor(XQueryColor, dpy, colormap,
+ pXcmsColor_in_out, result_format, (Bool *) NULL));
+}
diff --git a/nx-X11/lib/X11/QuColor.c b/nx-X11/lib/X11/QuColor.c
new file mode 100644
index 000000000..9b6901e8d
--- /dev/null
+++ b/nx-X11/lib/X11/QuColor.c
@@ -0,0 +1,64 @@
+/* $Xorg: QuColor.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/QuColor.c,v 1.3 2001/01/17 19:41:42 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XQueryColor(dpy, cmap, def)
+ register Display *dpy;
+ Colormap cmap;
+ XColor *def; /* RETURN */
+{
+ xrgb color;
+ xQueryColorsReply rep;
+ register xQueryColorsReq *req;
+ unsigned long val = def->pixel; /* needed for macro below */
+
+ LockDisplay(dpy);
+ GetReqExtra(QueryColors, 4, req); /* a pixel (CARD32) is 4 bytes */
+ req->cmap = cmap;
+
+ OneDataCard32 (dpy, NEXTPTR(req,xQueryColorsReq), val);
+
+ if (_XReply(dpy, (xReply *) &rep, 0, xFalse) != 0) {
+
+ _XRead(dpy, (char *)&color, (long) SIZEOF(xrgb));
+
+ def->red = color.red;
+ def->blue = color.blue;
+ def->green = color.green;
+ def->flags = DoRed | DoGreen | DoBlue;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/QuColors.c b/nx-X11/lib/X11/QuColors.c
new file mode 100644
index 000000000..74a1de85d
--- /dev/null
+++ b/nx-X11/lib/X11/QuColors.c
@@ -0,0 +1,80 @@
+/* $Xorg: QuColors.c,v 1.5 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/QuColors.c,v 1.3 2001/01/17 19:41:42 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XQueryColors(dpy, cmap, defs, ncolors)
+ register Display *dpy;
+ Colormap cmap;
+ XColor *defs; /* RETURN */
+ int ncolors;
+{
+ register int i;
+ xrgb *color;
+ xQueryColorsReply rep;
+ long nbytes;
+ register xQueryColorsReq *req;
+
+ LockDisplay(dpy);
+ GetReq(QueryColors, req);
+
+ req->cmap = cmap;
+ req->length += ncolors; /* each pixel is a CARD32 */
+
+ for (i = 0; i < ncolors; i++)
+ Data32 (dpy, (long *)&defs[i].pixel, 4L);
+ /* XXX this isn't very efficient */
+
+ if (_XReply(dpy, (xReply *) &rep, 0, xFalse) != 0) {
+ if ((color = (xrgb *)
+ Xmalloc((unsigned) (nbytes = (long) ncolors * SIZEOF(xrgb))))) {
+
+ _XRead(dpy, (char *) color, nbytes);
+
+ for (i = 0; i < ncolors; i++) {
+ register XColor *def = &defs[i];
+ register xrgb *rgb = &color[i];
+ def->red = rgb->red;
+ def->green = rgb->green;
+ def->blue = rgb->blue;
+ def->flags = DoRed | DoGreen | DoBlue;
+ }
+ Xfree((char *)color);
+ }
+ else _XEatData(dpy, (unsigned long) nbytes);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/QuCols.c b/nx-X11/lib/X11/QuCols.c
new file mode 100644
index 000000000..d6c4890e6
--- /dev/null
+++ b/nx-X11/lib/X11/QuCols.c
@@ -0,0 +1,80 @@
+/* $Xorg: QuCols.c,v 1.3 2000/08/17 19:44:50 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQuCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsQueryColors
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/QuCols.c,v 1.3 2001/01/17 19:41:42 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+/*
+ * NAME
+ * XcmsQueryColors - Query Colors
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsQueryColors(dpy, colormap, pXcmsColors_in_out, nColors, result_format)
+ Display *dpy;
+ Colormap colormap;
+ XcmsColor *pXcmsColors_in_out;
+ unsigned int nColors;
+ XcmsColorFormat result_format;
+/*
+ * DESCRIPTION
+ * This routine uses XQueryColors to obtain the X RGB values
+ * stored in the specified colormap for the specified pixels.
+ * The X RGB values are then converted to the target format as
+ * specified by the format component of the XcmsColor structure.
+ *
+ * RETURNS
+ * XcmsFailure if failed;
+ * XcmsSuccess if it succeeded.
+ *
+ * Returns the color specifications of the colors stored in the
+ * specified pixels.
+ */
+{
+ return(_XcmsSetGetColors(XQueryColors, dpy, colormap,
+ pXcmsColors_in_out, nColors, result_format, (Bool *) NULL));
+}
diff --git a/nx-X11/lib/X11/QuCurShp.c b/nx-X11/lib/X11/QuCurShp.c
new file mode 100644
index 000000000..b2667231d
--- /dev/null
+++ b/nx-X11/lib/X11/QuCurShp.c
@@ -0,0 +1,60 @@
+/* $Xorg: QuCurShp.c,v 1.4 2001/02/09 02:03:35 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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+Status XQueryBestCursor(dpy, drawable, width, height, ret_width, ret_height)
+ register Display *dpy;
+ Drawable drawable;
+ unsigned int width, height;
+ unsigned int *ret_width, *ret_height;
+{
+ xQueryBestSizeReply rep;
+ register xQueryBestSizeReq *req;
+
+ LockDisplay(dpy);
+ GetReq(QueryBestSize, req);
+ req->class = CursorShape;
+ req->drawable = drawable;
+ req->width = width;
+ req->height = height;
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ *ret_width = rep.width;
+ *ret_height = rep.height;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/QuExt.c b/nx-X11/lib/X11/QuExt.c
new file mode 100644
index 000000000..19d8be5d5
--- /dev/null
+++ b/nx-X11/lib/X11/QuExt.c
@@ -0,0 +1,59 @@
+/* $Xorg: QuExt.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86$ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+Bool
+XQueryExtension(
+ register Display *dpy,
+ _Xconst char *name,
+ int *major_opcode, /* RETURN */
+ int *first_event, /* RETURN */
+ int *first_error) /* RETURN */
+{
+ xQueryExtensionReply rep;
+ register xQueryExtensionReq *req;
+
+ LockDisplay(dpy);
+ GetReq(QueryExtension, req);
+ req->nbytes = name ? strlen(name) : 0;
+ req->length += (req->nbytes+(unsigned)3)>>2;
+ _XSend(dpy, name, (long)req->nbytes);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ *major_opcode = rep.major_opcode;
+ *first_event = rep.first_event;
+ *first_error = rep.first_error;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.present);
+}
+
diff --git a/nx-X11/lib/X11/QuKeybd.c b/nx-X11/lib/X11/QuKeybd.c
new file mode 100644
index 000000000..62691c043
--- /dev/null
+++ b/nx-X11/lib/X11/QuKeybd.c
@@ -0,0 +1,57 @@
+/* $Xorg: QuKeybd.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/QuKeybd.c,v 1.3 2001/01/17 19:41:42 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+struct kmap {
+ char map[32];
+};
+
+int
+XQueryKeymap(dpy, keys)
+ register Display *dpy;
+ char keys[32];
+
+{
+ xQueryKeymapReply rep;
+ register xReq *req;
+
+ LockDisplay(dpy);
+ GetEmptyReq(QueryKeymap, req);
+ (void) _XReply(dpy, (xReply *)&rep,
+ (SIZEOF(xQueryKeymapReply) - SIZEOF(xReply)) >> 2, xTrue);
+ *(struct kmap *) keys = *(struct kmap *)rep.map; /* faster than memcpy */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/QuPntr.c b/nx-X11/lib/X11/QuPntr.c
new file mode 100644
index 000000000..006553d71
--- /dev/null
+++ b/nx-X11/lib/X11/QuPntr.c
@@ -0,0 +1,63 @@
+/* $Xorg: QuPntr.c,v 1.4 2001/02/09 02:03:35 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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+Bool XQueryPointer(dpy, w, root, child, root_x, root_y, win_x, win_y, mask)
+ register Display *dpy;
+ Window w, *root, *child;
+ int *root_x, *root_y, *win_x, *win_y;
+ unsigned int *mask;
+
+{
+ xQueryPointerReply rep;
+ xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(QueryPointer, w, req);
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(False);
+ }
+
+ *root = rep.root;
+ *child = rep.child;
+ *root_x = cvtINT16toInt (rep.rootX);
+ *root_y = cvtINT16toInt (rep.rootY);
+ *win_x = cvtINT16toInt (rep.winX);
+ *win_y = cvtINT16toInt (rep.winY);
+ *mask = rep.mask;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.sameScreen);
+}
+
diff --git a/nx-X11/lib/X11/QuStipShp.c b/nx-X11/lib/X11/QuStipShp.c
new file mode 100644
index 000000000..0d7c00d78
--- /dev/null
+++ b/nx-X11/lib/X11/QuStipShp.c
@@ -0,0 +1,60 @@
+/* $Xorg: QuStipShp.c,v 1.4 2001/02/09 02:03:35 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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+Status XQueryBestStipple(dpy, drawable, width, height, ret_width, ret_height)
+ register Display *dpy;
+ Drawable drawable;
+ unsigned int width, height;
+ unsigned int *ret_width, *ret_height;
+{
+ xQueryBestSizeReply rep;
+ register xQueryBestSizeReq *req;
+
+ LockDisplay(dpy);
+ GetReq(QueryBestSize, req);
+ req->class = StippleShape;
+ req->drawable = drawable;
+ req->width = width;
+ req->height = height;
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ *ret_width = rep.width;
+ *ret_height = rep.height;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/QuTextE16.c b/nx-X11/lib/X11/QuTextE16.c
new file mode 100644
index 000000000..ee3817272
--- /dev/null
+++ b/nx-X11/lib/X11/QuTextE16.c
@@ -0,0 +1,84 @@
+/* $Xorg: QuTextE16.c,v 1.5 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 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.
+
+*/
+/* $XFree86: xc/lib/X11/QuTextE16.c,v 1.4 2001/12/14 19:54:04 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XQueryTextExtents16 (
+ register Display *dpy,
+ Font fid,
+ _Xconst XChar2b *string,
+ register int nchars,
+ int *dir,
+ int *font_ascent,
+ int *font_descent,
+ register XCharStruct *overall)
+{
+ register long i;
+ register unsigned char *ptr;
+ char *buf;
+ xQueryTextExtentsReply rep;
+ long nbytes;
+ register xQueryTextExtentsReq *req;
+
+ LockDisplay(dpy);
+ nbytes = nchars << 1;
+ GetReq(QueryTextExtents, req);
+ req->fid = fid;
+ if ((buf = _XAllocScratch (dpy, (unsigned long) nbytes))) {
+ req->length += (nbytes + 3)>>2;
+ req->oddLength = nchars & 1;
+ for (ptr = (unsigned char *)buf, i = nchars; --i >= 0; string++) {
+ *ptr++ = string->byte1;
+ *ptr++ = string->byte2;
+ }
+ Data (dpy, buf, nbytes);
+ }
+ if (!_XReply (dpy, (xReply *)&rep, 0, xTrue) || !buf) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ *dir = rep.drawDirection;
+ *font_ascent = cvtINT16toInt (rep.fontAscent);
+ *font_descent = cvtINT16toInt (rep.fontDescent);
+ overall->ascent = (short) cvtINT16toShort (rep.overallAscent);
+ overall->descent = (short) cvtINT16toShort (rep.overallDescent);
+ /* XXX bogus - we're throwing away information!!! */
+ overall->width = (short) cvtINT32toInt (rep.overallWidth);
+ overall->lbearing = (short) cvtINT32toInt (rep.overallLeft);
+ overall->rbearing = (short) cvtINT32toInt (rep.overallRight);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/QuTextExt.c b/nx-X11/lib/X11/QuTextExt.c
new file mode 100644
index 000000000..a144865c3
--- /dev/null
+++ b/nx-X11/lib/X11/QuTextExt.c
@@ -0,0 +1,83 @@
+/* $Xorg: QuTextExt.c,v 1.5 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 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.
+
+*/
+/* $XFree86: xc/lib/X11/QuTextExt.c,v 1.4 2001/12/14 19:54:04 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XQueryTextExtents (
+ register Display *dpy,
+ Font fid,
+ register _Xconst char *string,
+ register int nchars,
+ int *dir,
+ int *font_ascent,
+ int *font_descent,
+ register XCharStruct *overall)
+{
+ register int i;
+ register char *ptr;
+ char *buf;
+ xQueryTextExtentsReply rep;
+ long nbytes;
+ register xQueryTextExtentsReq *req;
+
+ LockDisplay(dpy);
+ nbytes = nchars << 1;
+ GetReq(QueryTextExtents, req);
+ req->fid = fid;
+ if ((buf = _XAllocScratch (dpy, (unsigned long) nbytes))) {
+ req->length += (nbytes + 3)>>2;
+ req->oddLength = nchars & 1;
+ for (ptr = buf, i = nchars; --i >= 0;) {
+ *ptr++ = 0;
+ *ptr++ = *string++;
+ }
+ Data (dpy, buf, nbytes);
+ }
+ if (!_XReply (dpy, (xReply *)&rep, 0, xTrue) || !buf) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ *dir = rep.drawDirection;
+ *font_ascent = cvtINT16toInt (rep.fontAscent);
+ *font_descent = cvtINT16toInt (rep.fontDescent);
+ overall->ascent = (short) cvtINT16toShort (rep.overallAscent);
+ overall->descent = (short) cvtINT16toShort (rep.overallDescent);
+ /* XXX bogus - we're throwing away information!!! */
+ overall->width = (short) cvtINT32toInt (rep.overallWidth);
+ overall->lbearing = (short) cvtINT32toInt (rep.overallLeft);
+ overall->rbearing = (short) cvtINT32toInt (rep.overallRight);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/QuTileShp.c b/nx-X11/lib/X11/QuTileShp.c
new file mode 100644
index 000000000..5e23ae2ff
--- /dev/null
+++ b/nx-X11/lib/X11/QuTileShp.c
@@ -0,0 +1,61 @@
+/* $Xorg: QuTileShp.c,v 1.4 2001/02/09 02:03:35 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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+Status XQueryBestTile(dpy, drawable, width, height, ret_width, ret_height)
+ register Display *dpy;
+ Drawable drawable;
+ unsigned int width, height;
+ unsigned int *ret_width, *ret_height;
+{
+ xQueryBestSizeReply rep;
+ register xQueryBestSizeReq *req;
+
+ LockDisplay(dpy);
+ GetReq(QueryBestSize, req);
+ req->class = TileShape;
+ req->drawable = drawable;
+ req->width = width;
+ req->height = height;
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(0);
+ }
+
+ *ret_width = rep.width;
+ *ret_height = rep.height;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/QuTree.c b/nx-X11/lib/X11/QuTree.c
new file mode 100644
index 000000000..1a743284d
--- /dev/null
+++ b/nx-X11/lib/X11/QuTree.c
@@ -0,0 +1,75 @@
+/* $Xorg: QuTree.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/QuTree.c,v 1.5 2001/01/17 19:41:42 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+Status XQueryTree (dpy, w, root, parent, children, nchildren)
+ register Display *dpy;
+ Window w;
+ Window *root; /* RETURN */
+ Window *parent; /* RETURN */
+ Window **children; /* RETURN */
+ unsigned int *nchildren; /* RETURN */
+{
+ long nbytes;
+ xQueryTreeReply rep;
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(QueryTree, w, req);
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+
+ *children = (Window *) NULL;
+ if (rep.nChildren != 0) {
+ nbytes = rep.nChildren * sizeof(Window);
+ *children = (Window *) Xmalloc((unsigned) nbytes);
+ nbytes = rep.nChildren << 2;
+ if (! *children) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+ _XRead32 (dpy, (long *) *children, nbytes);
+ }
+ *parent = rep.parent;
+ *root = rep.root;
+ *nchildren = rep.nChildren;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (1);
+}
+
diff --git a/nx-X11/lib/X11/Quarks.c b/nx-X11/lib/X11/Quarks.c
new file mode 100644
index 000000000..a5ffa8ac1
--- /dev/null
+++ b/nx-X11/lib/X11/Quarks.c
@@ -0,0 +1,417 @@
+/* $Xorg: Quarks.c,v 1.5 2001/02/09 02:03:35 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, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/X11/Quarks.c,v 1.6 2003/04/13 19:22:17 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xresource.h>
+#include "Xresinternal.h"
+
+/* Not cost effective, at least for vanilla MIT clients */
+/* #define PERMQ */
+
+#ifdef PERMQ
+typedef unsigned char Bits;
+#endif
+typedef unsigned long Entry; /* dont confuse with EntryRec from Xintatom.h */
+
+static XrmQuark nextQuark = 1; /* next available quark number */
+static unsigned long quarkMask = 0;
+static Entry zero = 0;
+static Entry *quarkTable = &zero; /* crock */
+static unsigned long quarkRehash;
+static XrmString **stringTable = NULL;
+#ifdef PERMQ
+static Bits **permTable = NULL;
+#endif
+static XrmQuark nextUniq = -1; /* next quark from XrmUniqueQuark */
+
+#define QUANTUMSHIFT 8
+#define QUANTUMMASK ((1 << QUANTUMSHIFT) - 1)
+#define CHUNKPER 8
+#define CHUNKMASK ((CHUNKPER << QUANTUMSHIFT) - 1)
+
+#define LARGEQUARK ((Entry)0x80000000L)
+#define QUARKSHIFT 18
+#define QUARKMASK ((LARGEQUARK - 1) >> QUARKSHIFT)
+#define XSIGMASK ((1L << QUARKSHIFT) - 1)
+
+#define STRQUANTSIZE (sizeof(XrmString) * (QUANTUMMASK + 1))
+#ifdef PERMQ
+#define QUANTSIZE (STRQUANTSIZE + \
+ (sizeof(Bits) * ((QUANTUMMASK + 1) >> 3))
+#else
+#define QUANTSIZE STRQUANTSIZE
+#endif
+
+#define HASH(sig) ((sig) & quarkMask)
+#define REHASHVAL(sig) ((((sig) % quarkRehash) + 2) | 1)
+#define REHASH(idx,rehash) ((idx + rehash) & quarkMask)
+#define NAME(q) stringTable[(q) >> QUANTUMSHIFT][(q) & QUANTUMMASK]
+#ifdef PERMQ
+#define BYTEREF(q) permTable[(q) >> QUANTUMSHIFT][((q) & QUANTUMMASK) >> 3]
+#define ISPERM(q) (BYTEREF(q) & (1 << ((q) & 7)))
+#define SETPERM(q) BYTEREF(q) |= (1 << ((q) & 7))
+#define CLEARPERM(q) BYTEREF(q) &= ~(1 << ((q) & 7))
+#endif
+
+/* Permanent memory allocation */
+
+#define WALIGN sizeof(unsigned long)
+#define DALIGN sizeof(double)
+
+#define NEVERFREETABLESIZE ((8192-12) & ~(DALIGN-1))
+static char *neverFreeTable = NULL;
+static int neverFreeTableSize = 0;
+
+static char *permalloc(unsigned int length)
+{
+ char *ret;
+
+ if (neverFreeTableSize < length) {
+ if (length >= NEVERFREETABLESIZE)
+ return Xmalloc(length);
+ if (! (ret = Xmalloc(NEVERFREETABLESIZE)))
+ return (char *) NULL;
+ neverFreeTableSize = NEVERFREETABLESIZE;
+ neverFreeTable = ret;
+ }
+ ret = neverFreeTable;
+ neverFreeTable += length;
+ neverFreeTableSize -= length;
+ return(ret);
+}
+
+#ifndef WORD64
+typedef struct {char a; double b;} TestType1;
+typedef struct {char a; unsigned long b;} TestType2;
+#endif
+
+#ifdef XTHREADS
+static char *_Xpermalloc(unsigned int length);
+
+char *Xpermalloc(unsigned int length)
+{
+ char *p;
+
+ _XLockMutex(_Xglobal_lock);
+ p = _Xpermalloc(length);
+ _XUnlockMutex(_Xglobal_lock);
+ return p;
+}
+#define Xpermalloc _Xpermalloc
+
+static
+#endif /* XTHREADS */
+char *Xpermalloc(unsigned int length)
+{
+ int i;
+
+ if (neverFreeTableSize && length < NEVERFREETABLESIZE) {
+#ifndef WORD64
+ if ((sizeof(TestType1) !=
+ (sizeof(TestType2) - sizeof(unsigned long) + sizeof(double))) &&
+ !(length & (DALIGN-1)) &&
+ ((i = (NEVERFREETABLESIZE - neverFreeTableSize) & (DALIGN-1)))) {
+ neverFreeTableSize -= DALIGN - i;
+ neverFreeTable += DALIGN - i;
+ } else
+#endif
+ if ((i = (NEVERFREETABLESIZE - neverFreeTableSize) & (WALIGN-1))) {
+ neverFreeTableSize -= WALIGN - i;
+ neverFreeTable += WALIGN - i;
+ }
+ }
+ return permalloc(length);
+}
+
+static Bool
+ExpandQuarkTable(void)
+{
+ unsigned long oldmask, newmask;
+ register char c, *s;
+ register Entry *oldentries, *entries;
+ register Entry entry;
+ register int oldidx, newidx, rehash;
+ Signature sig;
+ XrmQuark q;
+
+ oldentries = quarkTable;
+ if ((oldmask = quarkMask))
+ newmask = (oldmask << 1) + 1;
+ else {
+ if (!stringTable) {
+ stringTable = (XrmString **)Xmalloc(sizeof(XrmString *) *
+ CHUNKPER);
+ if (!stringTable)
+ return False;
+ stringTable[0] = (XrmString *)NULL;
+ }
+#ifdef PERMQ
+ if (!permTable)
+ permTable = (Bits **)Xmalloc(sizeof(Bits *) * CHUNKPER);
+ if (!permTable)
+ return False;
+#endif
+ stringTable[0] = (XrmString *)Xpermalloc(QUANTSIZE);
+ if (!stringTable[0])
+ return False;
+#ifdef PERMQ
+ permTable[0] = (Bits *)((char *)stringTable[0] + STRQUANTSIZE);
+#endif
+ newmask = 0x1ff;
+ }
+ entries = (Entry *)Xmalloc(sizeof(Entry) * (newmask + 1));
+ if (!entries)
+ return False;
+ bzero((char *)entries, sizeof(Entry) * (newmask + 1));
+ quarkTable = entries;
+ quarkMask = newmask;
+ quarkRehash = quarkMask - 2;
+ for (oldidx = 0; oldidx <= oldmask; oldidx++) {
+ if ((entry = oldentries[oldidx])) {
+ if (entry & LARGEQUARK)
+ q = entry & (LARGEQUARK-1);
+ else
+ q = (entry >> QUARKSHIFT) & QUARKMASK;
+ for (sig = 0, s = NAME(q); (c = *s++); )
+ sig = (sig << 1) + c;
+ newidx = HASH(sig);
+ if (entries[newidx]) {
+ rehash = REHASHVAL(sig);
+ do {
+ newidx = REHASH(newidx, rehash);
+ } while (entries[newidx]);
+ }
+ entries[newidx] = entry;
+ }
+ }
+ if (oldmask)
+ Xfree((char *)oldentries);
+ return True;
+}
+
+XrmQuark
+_XrmInternalStringToQuark(
+ register _Xconst char *name, register int len, register Signature sig,
+ Bool permstring)
+{
+ register XrmQuark q;
+ register Entry entry;
+ register int idx, rehash;
+ register int i;
+ register char *s1, *s2;
+ char *new;
+
+ rehash = 0;
+ idx = HASH(sig);
+ _XLockMutex(_Xglobal_lock);
+ while ((entry = quarkTable[idx])) {
+ if (entry & LARGEQUARK)
+ q = entry & (LARGEQUARK-1);
+ else {
+ if ((entry - sig) & XSIGMASK)
+ goto nomatch;
+ q = (entry >> QUARKSHIFT) & QUARKMASK;
+ }
+ for (i = len, s1 = (char *)name, s2 = NAME(q); --i >= 0; ) {
+ if (*s1++ != *s2++)
+ goto nomatch;
+ }
+ if (*s2) {
+nomatch: if (!rehash)
+ rehash = REHASHVAL(sig);
+ idx = REHASH(idx, rehash);
+ continue;
+ }
+#ifdef PERMQ
+ if (permstring && !ISPERM(q)) {
+ Xfree(NAME(q));
+ NAME(q) = (char *)name;
+ SETPERM(q);
+ }
+#endif
+ _XUnlockMutex(_Xglobal_lock);
+ return q;
+ }
+ if (nextUniq == nextQuark)
+ goto fail;
+ if ((nextQuark + (nextQuark >> 2)) > quarkMask) {
+ if (!ExpandQuarkTable())
+ goto fail;
+ _XUnlockMutex(_Xglobal_lock);
+ return _XrmInternalStringToQuark(name, len, sig, permstring);
+ }
+ q = nextQuark;
+ if (!(q & QUANTUMMASK)) {
+ if (!(q & CHUNKMASK)) {
+ if (!(new = Xrealloc((char *)stringTable,
+ sizeof(XrmString *) *
+ ((q >> QUANTUMSHIFT) + CHUNKPER))))
+ goto fail;
+ stringTable = (XrmString **)new;
+#ifdef PERMQ
+ if (!(new = Xrealloc((char *)permTable,
+ sizeof(Bits *) *
+ ((q >> QUANTUMSHIFT) + CHUNKPER))))
+ goto fail;
+ permTable = (Bits **)new;
+#endif
+ }
+ new = Xpermalloc(QUANTSIZE);
+ if (!new)
+ goto fail;
+ stringTable[q >> QUANTUMSHIFT] = (XrmString *)new;
+#ifdef PERMQ
+ permTable[q >> QUANTUMSHIFT] = (Bits *)(new + STRQUANTSIZE);
+#endif
+ }
+ if (!permstring) {
+ s2 = (char *)name;
+#ifdef PERMQ
+ name = Xmalloc(len+1);
+#else
+ name = permalloc(len+1);
+#endif
+ if (!name)
+ goto fail;
+ for (i = len, s1 = (char *)name; --i >= 0; )
+ *s1++ = *s2++;
+ *s1++ = '\0';
+#ifdef PERMQ
+ CLEARPERM(q);
+ }
+ else {
+ SETPERM(q);
+#endif
+ }
+ NAME(q) = (char *)name;
+ if (q <= QUARKMASK)
+ entry = (q << QUARKSHIFT) | (sig & XSIGMASK);
+ else
+ entry = q | LARGEQUARK;
+ quarkTable[idx] = entry;
+ nextQuark++;
+ _XUnlockMutex(_Xglobal_lock);
+ return q;
+ fail:
+ _XUnlockMutex(_Xglobal_lock);
+ return NULLQUARK;
+}
+
+XrmQuark
+XrmStringToQuark(
+ _Xconst char *name)
+{
+ register char c, *tname;
+ register Signature sig = 0;
+
+ if (!name)
+ return (NULLQUARK);
+
+ for (tname = (char *)name; (c = *tname++); )
+ sig = (sig << 1) + c;
+
+ return _XrmInternalStringToQuark(name, tname-(char *)name-1, sig, False);
+}
+
+XrmQuark
+XrmPermStringToQuark(
+ _Xconst char *name)
+{
+ register char c, *tname;
+ register Signature sig = 0;
+
+ if (!name)
+ return (NULLQUARK);
+
+ for (tname = (char *)name; (c = *tname++); )
+ sig = (sig << 1) + c;
+
+ return _XrmInternalStringToQuark(name, tname-(char *)name-1, sig, True);
+}
+
+XrmQuark XrmUniqueQuark()
+{
+ XrmQuark q;
+
+ _XLockMutex(_Xglobal_lock);
+ if (nextUniq == nextQuark)
+ q = NULLQUARK;
+ else
+ q = nextUniq--;
+ _XUnlockMutex(_Xglobal_lock);
+ return q;
+}
+
+XrmString XrmQuarkToString(quark)
+ register XrmQuark quark;
+{
+ XrmString s;
+
+ _XLockMutex(_Xglobal_lock);
+ if (quark <= 0 || quark >= nextQuark)
+ s = NULLSTRING;
+ else {
+#ifdef PERMQ
+ /* We have to mark the quark as permanent, since the caller might hold
+ * onto the string pointer forver.
+ */
+ SETPERM(quark);
+#endif
+ s = NAME(quark);
+ }
+ _XUnlockMutex(_Xglobal_lock);
+ return s;
+}
diff --git a/nx-X11/lib/X11/RaiseWin.c b/nx-X11/lib/X11/RaiseWin.c
new file mode 100644
index 000000000..15d03facb
--- /dev/null
+++ b/nx-X11/lib/X11/RaiseWin.c
@@ -0,0 +1,51 @@
+/* $Xorg: RaiseWin.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/RaiseWin.c,v 1.3 2001/01/17 19:41:42 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XRaiseWindow (dpy, w)
+ register Display *dpy;
+ Window w;
+{
+ register xConfigureWindowReq *req;
+ unsigned long val = Above; /* needed for macro below */
+
+ 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/nx-X11/lib/X11/RdBitF.c b/nx-X11/lib/X11/RdBitF.c
new file mode 100644
index 000000000..198e0e4a5
--- /dev/null
+++ b/nx-X11/lib/X11/RdBitF.c
@@ -0,0 +1,281 @@
+/* $Xorg: RdBitF.c,v 1.5 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/RdBitF.c,v 3.6 2003/04/13 19:22:17 dawes Exp $ */
+
+/*
+ * Code to read bitmaps from disk files. Interprets
+ * data from X10 and X11 bitmap files and creates
+ * Pixmap representations of files. Returns Pixmap
+ * ID and specifics about image.
+ *
+ * Modified for speedup by Jim Becker, changed image
+ * data parsing logic (removed some fscanf()s).
+ * Aug 5, 1988
+ *
+ * Note that this file and ../Xmu/RdBitF.c look very similar.... Keep them
+ * that way (but don't use common source code so that people can have one
+ * without the other).
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xos.h>
+#include "Xutil.h"
+#include <stdio.h>
+#include <ctype.h>
+
+
+#define MAX_SIZE 255
+
+/* shared data for the image read/parse logic */
+static short hexTable[256]; /* conversion value */
+static Bool initialized = False; /* easier to fill in at run time */
+
+
+/*
+ * Table index for the hex values. Initialized once, first time.
+ * Used for translation value or delimiter significance lookup.
+ */
+static void initHexTable(void)
+{
+ /*
+ * We build the table at run time for several reasons:
+ *
+ * 1. portable to non-ASCII machines.
+ * 2. still reentrant since we set the init flag after setting table.
+ * 3. easier to extend.
+ * 4. less prone to bugs.
+ */
+ hexTable['0'] = 0; hexTable['1'] = 1;
+ hexTable['2'] = 2; hexTable['3'] = 3;
+ hexTable['4'] = 4; hexTable['5'] = 5;
+ hexTable['6'] = 6; hexTable['7'] = 7;
+ hexTable['8'] = 8; hexTable['9'] = 9;
+ hexTable['A'] = 10; hexTable['B'] = 11;
+ hexTable['C'] = 12; hexTable['D'] = 13;
+ hexTable['E'] = 14; hexTable['F'] = 15;
+ hexTable['a'] = 10; hexTable['b'] = 11;
+ hexTable['c'] = 12; hexTable['d'] = 13;
+ hexTable['e'] = 14; hexTable['f'] = 15;
+
+ /* delimiters of significance are flagged w/ negative value */
+ hexTable[' '] = -1; hexTable[','] = -1;
+ hexTable['}'] = -1; hexTable['\n'] = -1;
+ hexTable['\t'] = -1;
+
+ initialized = True;
+}
+
+/*
+ * read next hex value in the input stream, return -1 if EOF
+ */
+static int
+NextInt (
+ FILE *fstream)
+{
+ int ch;
+ int value = 0;
+ int gotone = 0;
+ int done = 0;
+
+ /* loop, accumulate hex value until find delimiter */
+ /* skip any initial delimiters found in read stream */
+
+ while (!done) {
+ ch = getc(fstream);
+ if (ch == EOF) {
+ value = -1;
+ done++;
+ } else {
+ /* trim high bits, check type and accumulate */
+ ch &= 0xff;
+ if (isascii(ch) && isxdigit(ch)) {
+ value = (value << 4) + hexTable[ch];
+ gotone++;
+ } else if ((hexTable[ch]) < 0 && gotone)
+ done++;
+ }
+ }
+ return value;
+}
+
+int
+XReadBitmapFileData (
+ _Xconst char *filename,
+ unsigned int *width, /* RETURNED */
+ unsigned int *height, /* RETURNED */
+ unsigned char **data, /* RETURNED */
+ int *x_hot, /* RETURNED */
+ int *y_hot) /* RETURNED */
+{
+ FILE *fstream; /* handle on file */
+ unsigned char *bits = NULL; /* working variable */
+ char line[MAX_SIZE]; /* input line from file */
+ int size; /* number of bytes of data */
+ char name_and_type[MAX_SIZE]; /* an input line */
+ char *type; /* for parsing */
+ int value; /* from an input line */
+ int version10p; /* boolean, old format */
+ int padding; /* to handle alignment */
+ int bytes_per_line; /* per scanline of data */
+ unsigned int ww = 0; /* width */
+ unsigned int hh = 0; /* height */
+ int hx = -1; /* x hotspot */
+ int hy = -1; /* y hotspot */
+
+ /* first time initialization */
+ if (initialized == False) initHexTable();
+
+#ifdef __UNIXOS2__
+ filename = __XOS2RedirRoot(filename);
+#endif
+ if (!(fstream = fopen(filename, "r")))
+ return BitmapOpenFailed;
+
+ /* error cleanup and return macro */
+#define RETURN(code) \
+{ if (bits) Xfree ((char *)bits); fclose (fstream); return code; }
+
+ while (fgets(line, MAX_SIZE, fstream)) {
+ if (strlen(line) == MAX_SIZE-1)
+ RETURN (BitmapFileInvalid);
+ if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) {
+ if (!(type = strrchr(name_and_type, '_')))
+ type = name_and_type;
+ else
+ type++;
+
+ if (!strcmp("width", type))
+ ww = (unsigned int) value;
+ if (!strcmp("height", type))
+ hh = (unsigned int) value;
+ if (!strcmp("hot", type)) {
+ if (type-- == name_and_type || type-- == name_and_type)
+ continue;
+ if (!strcmp("x_hot", type))
+ hx = value;
+ if (!strcmp("y_hot", type))
+ hy = value;
+ }
+ continue;
+ }
+
+ if (sscanf(line, "static short %s = {", name_and_type) == 1)
+ version10p = 1;
+ else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1)
+ version10p = 0;
+ else if (sscanf(line, "static char %s = {", name_and_type) == 1)
+ version10p = 0;
+ else
+ continue;
+
+ if (!(type = strrchr(name_and_type, '_')))
+ type = name_and_type;
+ else
+ type++;
+
+ if (strcmp("bits[]", type))
+ continue;
+
+ if (!ww || !hh)
+ RETURN (BitmapFileInvalid);
+
+ if ((ww % 16) && ((ww % 16) < 9) && version10p)
+ padding = 1;
+ else
+ padding = 0;
+
+ bytes_per_line = (ww+7)/8 + padding;
+
+ size = bytes_per_line * hh;
+ bits = (unsigned char *) Xmalloc ((unsigned int) size);
+ if (!bits)
+ RETURN (BitmapNoMemory);
+
+ if (version10p) {
+ unsigned char *ptr;
+ int bytes;
+
+ for (bytes=0, ptr=bits; bytes<size; (bytes += 2)) {
+ if ((value = NextInt(fstream)) < 0)
+ RETURN (BitmapFileInvalid);
+ *(ptr++) = value;
+ if (!padding || ((bytes+2) % bytes_per_line))
+ *(ptr++) = value >> 8;
+ }
+ } else {
+ unsigned char *ptr;
+ int bytes;
+
+ for (bytes=0, ptr=bits; bytes<size; bytes++, ptr++) {
+ if ((value = NextInt(fstream)) < 0)
+ RETURN (BitmapFileInvalid);
+ *ptr=value;
+ }
+ }
+ } /* end while */
+
+ fclose(fstream);
+ if (!bits)
+ return (BitmapFileInvalid);
+
+ *data = bits;
+ *width = ww;
+ *height = hh;
+ if (x_hot) *x_hot = hx;
+ if (y_hot) *y_hot = hy;
+
+ return (BitmapSuccess);
+}
+
+int
+XReadBitmapFile (
+ Display *display,
+ Drawable d,
+ _Xconst char *filename,
+ unsigned int *width, /* RETURNED */
+ unsigned int *height, /* RETURNED */
+ Pixmap *pixmap, /* RETURNED */
+ int *x_hot, /* RETURNED */
+ int *y_hot) /* RETURNED */
+{
+ unsigned char *data;
+ int res;
+
+ res = XReadBitmapFileData(filename, width, height, &data, x_hot, y_hot);
+ if (res != BitmapSuccess)
+ return res;
+ *pixmap = XCreateBitmapFromData(display, d, (char *)data, *width, *height);
+ Xfree((char *)data);
+ if (*pixmap == None)
+ return (BitmapNoMemory);
+ return (BitmapSuccess);
+}
diff --git a/nx-X11/lib/X11/RecolorC.c b/nx-X11/lib/X11/RecolorC.c
new file mode 100644
index 000000000..0bd46d619
--- /dev/null
+++ b/nx-X11/lib/X11/RecolorC.c
@@ -0,0 +1,55 @@
+/* $Xorg: RecolorC.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/RecolorC.c,v 1.3 2001/01/17 19:41:42 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XRecolorCursor(dpy, cursor, foreground, background)
+ register Display *dpy;
+ Cursor cursor;
+ XColor *foreground, *background;
+{
+ register xRecolorCursorReq *req;
+
+ LockDisplay(dpy);
+ GetReq(RecolorCursor, req);
+ req->cursor = cursor;
+ 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 1;
+}
+
diff --git a/nx-X11/lib/X11/ReconfWM.c b/nx-X11/lib/X11/ReconfWM.c
new file mode 100644
index 000000000..ecb5f6a89
--- /dev/null
+++ b/nx-X11/lib/X11/ReconfWM.c
@@ -0,0 +1,142 @@
+/* $Xorg: ReconfWM.c,v 1.4 2001/02/09 02:03:35 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
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+#define AllMaskBits (CWX|CWY|CWWidth|CWHeight|\
+ CWBorderWidth|CWSibling|CWStackMode)
+
+Status XReconfigureWMWindow (dpy, w, screen, mask, changes)
+ register Display *dpy;
+ Window w;
+ int screen;
+ unsigned int mask;
+ XWindowChanges *changes;
+{
+ XConfigureRequestEvent ev;
+ Window root = RootWindow (dpy, screen);
+ _XAsyncHandler async;
+ _XAsyncErrorState async_state;
+
+ /*
+ * Only need to go through the trouble if we are actually changing the
+ * stacking mode.
+ */
+ if (!(mask & CWStackMode)) {
+ XConfigureWindow (dpy, w, mask, changes);
+ return True;
+ }
+
+
+ /*
+ * We need to inline XConfigureWindow and XSync so that everything is done
+ * while the display is locked.
+ */
+
+ LockDisplay(dpy);
+
+ /*
+ * XConfigureWindow (dpy, w, mask, changes);
+ */
+ {
+ unsigned long values[7];
+ register unsigned long *value = values;
+ long nvalues;
+ register xConfigureWindowReq *req;
+
+ GetReq(ConfigureWindow, req);
+
+ async_state.min_sequence_number = dpy->request;
+ async_state.max_sequence_number = dpy->request;
+ async_state.error_code = BadMatch;
+ async_state.major_opcode = X_ConfigureWindow;
+ 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;
+
+ req->window = w;
+ mask &= AllMaskBits;
+ req->mask = mask;
+
+ if (mask & CWX) *value++ = changes->x;
+ if (mask & CWY) *value++ = changes->y;
+ if (mask & CWWidth) *value++ = changes->width;
+ if (mask & CWHeight) *value++ = changes->height;
+ if (mask & CWBorderWidth) *value++ = changes->border_width;
+ if (mask & CWSibling) *value++ = changes->sibling;
+ if (mask & CWStackMode) *value++ = changes->stack_mode;
+ req->length += (nvalues = value - values);
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, nvalues);
+ }
+
+ /*
+ * XSync (dpy, 0)
+ */
+ {
+ xGetInputFocusReply rep;
+ register xReq *req;
+
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ }
+
+ DeqAsyncHandler(dpy, &async);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+
+ /*
+ * If the request succeeded, then everything is okay; otherwise, send event
+ */
+ if (!async_state.error_count) return True;
+
+ ev.type = ConfigureRequest;
+ ev.window = w;
+ ev.parent = root;
+ ev.value_mask = (mask & AllMaskBits);
+ ev.x = changes->x;
+ ev.y = changes->y;
+ ev.width = changes->width;
+ ev.height = changes->height;
+ ev.border_width = changes->border_width;
+ ev.above = changes->sibling;
+ ev.detail = changes->stack_mode;
+ return (XSendEvent (dpy, root, False,
+ SubstructureRedirectMask|SubstructureNotifyMask,
+ (XEvent *)&ev));
+}
diff --git a/nx-X11/lib/X11/ReconfWin.c b/nx-X11/lib/X11/ReconfWin.c
new file mode 100644
index 000000000..1aaa652d1
--- /dev/null
+++ b/nx-X11/lib/X11/ReconfWin.c
@@ -0,0 +1,83 @@
+/* $Xorg: ReconfWin.c,v 1.4 2001/02/09 02:03:35 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.
+
+*/
+/* $XFree86: xc/lib/X11/ReconfWin.c,v 1.3 2001/01/17 19:41:42 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+#define AllMaskBits (CWX|CWY|CWWidth|CWHeight|\
+ CWBorderWidth|CWSibling|CWStackMode)
+
+int
+XConfigureWindow(dpy, w, mask, changes)
+ register Display *dpy;
+ Window w;
+ unsigned int mask;
+ XWindowChanges *changes;
+ {
+ unsigned long values[7];
+ register unsigned long *value = values;
+ long nvalues;
+ register xConfigureWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ConfigureWindow, req);
+ req->window = w;
+ mask &= AllMaskBits;
+ req->mask = mask;
+
+ if (mask & CWX)
+ *value++ = changes->x;
+
+ if (mask & CWY)
+ *value++ = changes->y;
+
+ if (mask & CWWidth)
+ *value++ = changes->width;
+
+ if (mask & CWHeight)
+ *value++ = changes->height;
+
+ if (mask & CWBorderWidth)
+ *value++ = changes->border_width;
+
+ if (mask & CWSibling)
+ *value++ = changes->sibling;
+
+ if (mask & CWStackMode)
+ *value++ = changes->stack_mode;
+
+ req->length += (nvalues = value - values);
+
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, nvalues);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
diff --git a/nx-X11/lib/X11/Region.c b/nx-X11/lib/X11/Region.c
new file mode 100644
index 000000000..cdd223b25
--- /dev/null
+++ b/nx-X11/lib/X11/Region.c
@@ -0,0 +1,1743 @@
+/* $Xorg: Region.c,v 1.6 2001/02/09 02:03:35 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.
+
+************************************************************************/
+/* $XFree86: xc/lib/X11/Region.c,v 1.9 2002/06/04 22:19:57 dawes Exp $ */
+/*
+ * The functions in this file implement the Region abstraction, similar to one
+ * used in the X11 sample server. A Region is simply an area, as the name
+ * implies, and is implemented as a "y-x-banded" array of rectangles. To
+ * explain: Each Region is made up of a certain number of rectangles sorted
+ * by y coordinate first, and then by x coordinate.
+ *
+ * Furthermore, the rectangles are banded such that every rectangle with a
+ * given upper-left y coordinate (y1) will have the same lower-right y
+ * coordinate (y2) and vice versa. If a rectangle has scanlines in a band, it
+ * will span the entire vertical distance of the band. This means that some
+ * areas that could be merged into a taller rectangle will be represented as
+ * several shorter rectangles to account for shorter rectangles to its left
+ * or right but within its "vertical scope".
+ *
+ * An added constraint on the rectangles is that they must cover as much
+ * horizontal area as possible. E.g. no two rectangles in a band are allowed
+ * to touch.
+ *
+ * Whenever possible, bands will be merged together to cover a greater vertical
+ * distance (and thus reduce the number of rectangles). Two bands can be merged
+ * only if the bottom of one touches the top of the other and they have
+ * rectangles in the same places (of the same width, of course). This maintains
+ * the y-x-banding that's so nice to have...
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xutil.h"
+#include <X11/Xregion.h>
+#include "poly.h"
+
+#ifdef DEBUG
+#include <stdio.h>
+#define assert(expr) {if (!(expr)) fprintf(stderr,\
+"Assertion failed file %s, line %d: expr\n", __FILE__, __LINE__); }
+#else
+#define assert(expr)
+#endif
+
+typedef int (*overlapProcp)(
+ register Region pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ short y1,
+ short y2);
+
+typedef int (*nonOverlapProcp)(
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2);
+
+static void miRegionOp(
+ register Region newReg, /* Place to store result */
+ Region reg1, /* First region in operation */
+ Region reg2, /* 2d region in operation */
+ int (*overlapFunc)(
+ register Region pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ short y1,
+ short y2), /* Function to call for over-
+ * lapping bands */
+ int (*nonOverlap1Func)(
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2), /* Function to call for non-
+ * overlapping bands in region
+ * 1 */
+ int (*nonOverlap2Func)(
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2)); /* Function to call for non-
+ * overlapping bands in region
+ * 2 */
+
+
+/* Create a new empty region */
+Region
+XCreateRegion(void)
+{
+ Region temp;
+
+ if (! (temp = ( Region )Xmalloc( (unsigned) sizeof( REGION ))))
+ return (Region) NULL;
+ if (! (temp->rects = ( BOX * )Xmalloc( (unsigned) sizeof( BOX )))) {
+ Xfree((char *) temp);
+ return (Region) NULL;
+ }
+ temp->numRects = 0;
+ temp->extents.x1 = 0;
+ temp->extents.y1 = 0;
+ temp->extents.x2 = 0;
+ temp->extents.y2 = 0;
+ temp->size = 1;
+ return( temp );
+}
+
+int
+XClipBox(
+ Region r,
+ XRectangle *rect)
+{
+ rect->x = r->extents.x1;
+ rect->y = r->extents.y1;
+ rect->width = r->extents.x2 - r->extents.x1;
+ rect->height = r->extents.y2 - r->extents.y1;
+ return 1;
+}
+
+int
+XUnionRectWithRegion(
+ register XRectangle *rect,
+ Region source, Region dest)
+{
+ REGION region;
+
+ if (!rect->width || !rect->height)
+ return 0;
+ region.rects = &region.extents;
+ region.numRects = 1;
+ region.extents.x1 = rect->x;
+ region.extents.y1 = rect->y;
+ region.extents.x2 = rect->x + rect->width;
+ region.extents.y2 = rect->y + rect->height;
+ region.size = 1;
+
+ return XUnionRegion(&region, source, dest);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miSetExtents --
+ * Reset the extents of a region to what they should be. Called by
+ * miSubtract and miIntersect b/c they can't figure it out along the
+ * way or do so easily, as miUnion can.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * The region's 'extents' structure is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miSetExtents (
+ Region pReg)
+{
+ register BoxPtr pBox,
+ pBoxEnd,
+ pExtents;
+
+ if (pReg->numRects == 0)
+ {
+ pReg->extents.x1 = 0;
+ pReg->extents.y1 = 0;
+ pReg->extents.x2 = 0;
+ pReg->extents.y2 = 0;
+ return;
+ }
+
+ pExtents = &pReg->extents;
+ pBox = pReg->rects;
+ pBoxEnd = &pBox[pReg->numRects - 1];
+
+ /*
+ * Since pBox is the first rectangle in the region, it must have the
+ * smallest y1 and since pBoxEnd is the last rectangle in the region,
+ * it must have the largest y2, because of banding. Initialize x1 and
+ * x2 from pBox and pBoxEnd, resp., as good things to initialize them
+ * to...
+ */
+ pExtents->x1 = pBox->x1;
+ pExtents->y1 = pBox->y1;
+ pExtents->x2 = pBoxEnd->x2;
+ pExtents->y2 = pBoxEnd->y2;
+
+ assert(pExtents->y1 < pExtents->y2);
+ while (pBox <= pBoxEnd)
+ {
+ if (pBox->x1 < pExtents->x1)
+ {
+ pExtents->x1 = pBox->x1;
+ }
+ if (pBox->x2 > pExtents->x2)
+ {
+ pExtents->x2 = pBox->x2;
+ }
+ pBox++;
+ }
+ assert(pExtents->x1 < pExtents->x2);
+}
+
+int
+XSetRegion(
+ Display *dpy,
+ GC gc,
+ register Region r)
+{
+ register int i;
+ register XRectangle *xr, *pr;
+ register BOX *pb;
+ unsigned long total;
+
+ LockDisplay (dpy);
+ total = r->numRects * sizeof (XRectangle);
+ if ((xr = (XRectangle *) _XAllocTemp(dpy, total))) {
+ for (pr = xr, pb = r->rects, i = r->numRects; --i >= 0; pr++, pb++) {
+ pr->x = pb->x1;
+ pr->y = pb->y1;
+ pr->width = pb->x2 - pb->x1;
+ pr->height = pb->y2 - pb->y1;
+ }
+ }
+ if (xr || !r->numRects)
+ _XSetClipRectangles(dpy, gc, 0, 0, xr, r->numRects, YXBanded);
+ if (xr)
+ _XFreeTemp(dpy, (char *)xr, total);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+int
+XDestroyRegion(
+ Region r)
+{
+ Xfree( (char *) r->rects );
+ Xfree( (char *) r );
+ return 1;
+}
+
+
+/* TranslateRegion(pRegion, x, y)
+ translates in place
+ added by raymond
+*/
+
+int
+XOffsetRegion(
+ register Region pRegion,
+ register int x,
+ register int y)
+{
+ register int nbox;
+ register BOX *pbox;
+
+ pbox = pRegion->rects;
+ nbox = pRegion->numRects;
+
+ while(nbox--)
+ {
+ pbox->x1 += x;
+ pbox->x2 += x;
+ pbox->y1 += y;
+ pbox->y2 += y;
+ pbox++;
+ }
+ pRegion->extents.x1 += x;
+ pRegion->extents.x2 += x;
+ pRegion->extents.y1 += y;
+ pRegion->extents.y2 += y;
+ return 1;
+}
+
+/*
+ Utility procedure Compress:
+ Replace r by the region r', where
+ p in r' iff (Quantifer m <= dx) (p + m in r), and
+ Quantifier is Exists if grow is TRUE, For all if grow is FALSE, and
+ (x,y) + m = (x+m,y) if xdir is TRUE; (x,y+m) if xdir is FALSE.
+
+ Thus, if xdir is TRUE and grow is FALSE, r is replaced by the region
+ of all points p such that p and the next dx points on the same
+ horizontal scan line are all in r. We do this using by noting
+ that p is the head of a run of length 2^i + k iff p is the head
+ of a run of length 2^i and p+2^i is the head of a run of length
+ k. Thus, the loop invariant: s contains the region corresponding
+ to the runs of length shift. r contains the region corresponding
+ to the runs of length 1 + dxo & (shift-1), where dxo is the original
+ value of dx. dx = dxo & ~(shift-1). As parameters, s and t are
+ scratch regions, so that we don't have to allocate them on every
+ call.
+*/
+
+#define ZOpRegion(a,b,c) if (grow) XUnionRegion(a,b,c); \
+ else XIntersectRegion(a,b,c)
+#define ZShiftRegion(a,b) if (xdir) XOffsetRegion(a,b,0); \
+ else XOffsetRegion(a,0,b)
+#define ZCopyRegion(a,b) XUnionRegion(a,a,b)
+
+static void
+Compress(
+ Region r, Region s, Region t,
+ register unsigned dx,
+ register int xdir, register int grow)
+{
+ register unsigned shift = 1;
+
+ ZCopyRegion(r, s);
+ while (dx) {
+ if (dx & shift) {
+ ZShiftRegion(r, -(int)shift);
+ ZOpRegion(r, s, r);
+ dx -= shift;
+ if (!dx) break;
+ }
+ ZCopyRegion(s, t);
+ ZShiftRegion(s, -(int)shift);
+ ZOpRegion(s, t, s);
+ shift <<= 1;
+ }
+}
+
+#undef ZOpRegion
+#undef ZShiftRegion
+#undef ZCopyRegion
+
+int
+XShrinkRegion(
+ Region r,
+ int dx, int dy)
+{
+ Region s, t;
+ int grow;
+
+ if (!dx && !dy) return 0;
+ if ((! (s = XCreateRegion())) || (! (t = XCreateRegion()))) return 0;
+ if ((grow = (dx < 0))) dx = -dx;
+ if (dx) Compress(r, s, t, (unsigned) 2*dx, TRUE, grow);
+ if ((grow = (dy < 0))) dy = -dy;
+ if (dy) Compress(r, s, t, (unsigned) 2*dy, FALSE, grow);
+ XOffsetRegion(r, dx, dy);
+ XDestroyRegion(s);
+ XDestroyRegion(t);
+ return 0;
+}
+
+#ifdef notdef
+/***********************************************************
+ * Bop down the array of rects until we have passed
+ * scanline y. numRects is the size of the array.
+ ***********************************************************/
+
+static BOX
+*IndexRects(
+ register BOX *rects,
+ register int numRects,
+ register int y)
+{
+ while ((numRects--) && (rects->y2 <= y))
+ rects++;
+ return(rects);
+}
+#endif
+
+/*======================================================================
+ * Region Intersection
+ *====================================================================*/
+/*-
+ *-----------------------------------------------------------------------
+ * miIntersectO --
+ * Handle an overlapping band for miIntersect.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Rectangles may be added to the region.
+ *
+ *-----------------------------------------------------------------------
+ */
+/* static void*/
+static int
+miIntersectO (
+ register Region pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ short y1,
+ short y2)
+{
+ register short x1;
+ register short x2;
+ register BoxPtr pNextRect;
+
+ pNextRect = &pReg->rects[pReg->numRects];
+
+ while ((r1 != r1End) && (r2 != r2End))
+ {
+ x1 = max(r1->x1,r2->x1);
+ x2 = min(r1->x2,r2->x2);
+
+ /*
+ * If there's any overlap between the two rectangles, add that
+ * overlap to the new region.
+ * There's no need to check for subsumption because the only way
+ * such a need could arise is if some region has two rectangles
+ * right next to each other. Since that should never happen...
+ */
+ if (x1 < x2)
+ {
+ assert(y1<y2);
+
+ MEMCHECK(pReg, pNextRect, pReg->rects);
+ pNextRect->x1 = x1;
+ pNextRect->y1 = y1;
+ pNextRect->x2 = x2;
+ pNextRect->y2 = y2;
+ pReg->numRects += 1;
+ pNextRect++;
+ assert(pReg->numRects <= pReg->size);
+ }
+
+ /*
+ * Need to advance the pointers. Shift the one that extends
+ * to the right the least, since the other still has a chance to
+ * overlap with that region's next rectangle, if you see what I mean.
+ */
+ if (r1->x2 < r2->x2)
+ {
+ r1++;
+ }
+ else if (r2->x2 < r1->x2)
+ {
+ r2++;
+ }
+ else
+ {
+ r1++;
+ r2++;
+ }
+ }
+ return 0; /* lint */
+}
+
+int
+XIntersectRegion(
+ Region reg1,
+ Region reg2, /* source regions */
+ register Region newReg) /* destination Region */
+{
+ /* check for trivial reject */
+ if ( (!(reg1->numRects)) || (!(reg2->numRects)) ||
+ (!EXTENTCHECK(&reg1->extents, &reg2->extents)))
+ newReg->numRects = 0;
+ else
+ miRegionOp (newReg, reg1, reg2,
+ miIntersectO, NULL, NULL);
+
+ /*
+ * Can't alter newReg's extents before we call miRegionOp because
+ * it might be one of the source regions and miRegionOp depends
+ * on the extents of those regions being the same. Besides, this
+ * way there's no checking against rectangles that will be nuked
+ * due to coalescing, so we have to examine fewer rectangles.
+ */
+ miSetExtents(newReg);
+ return 1;
+}
+
+static void
+miRegionCopy(
+ register Region dstrgn,
+ register Region rgn)
+
+{
+ if (dstrgn != rgn) /* don't want to copy to itself */
+ {
+ if (dstrgn->size < rgn->numRects)
+ {
+ if (dstrgn->rects)
+ {
+ BOX *prevRects = dstrgn->rects;
+
+ if (! (dstrgn->rects = (BOX *)
+ Xrealloc((char *) dstrgn->rects,
+ (unsigned) rgn->numRects * (sizeof(BOX))))) {
+ Xfree(prevRects);
+ return;
+ }
+ }
+ dstrgn->size = rgn->numRects;
+ }
+ dstrgn->numRects = rgn->numRects;
+ dstrgn->extents.x1 = rgn->extents.x1;
+ dstrgn->extents.y1 = rgn->extents.y1;
+ dstrgn->extents.x2 = rgn->extents.x2;
+ dstrgn->extents.y2 = rgn->extents.y2;
+
+ memcpy((char *) dstrgn->rects, (char *) rgn->rects,
+ (int) (rgn->numRects * sizeof(BOX)));
+ }
+}
+
+#ifdef notdef
+
+/*
+ * combinRegs(newReg, reg1, reg2)
+ * if one region is above or below the other.
+*/
+
+static void
+combineRegs(
+ register Region newReg,
+ Region reg1,
+ Region reg2)
+{
+ register Region tempReg;
+ register BOX *rects;
+ register BOX *rects1;
+ register BOX *rects2;
+ register int total;
+
+ rects1 = reg1->rects;
+ rects2 = reg2->rects;
+
+ total = reg1->numRects + reg2->numRects;
+ if (! (tempReg = XCreateRegion()))
+ return;
+ tempReg->size = total;
+ /* region 1 is below region 2 */
+ if (reg1->extents.y1 > reg2->extents.y1)
+ {
+ miRegionCopy(tempReg, reg2);
+ rects = &tempReg->rects[tempReg->numRects];
+ total -= tempReg->numRects;
+ while (total--)
+ *rects++ = *rects1++;
+ }
+ else
+ {
+ miRegionCopy(tempReg, reg1);
+ rects = &tempReg->rects[tempReg->numRects];
+ total -= tempReg->numRects;
+ while (total--)
+ *rects++ = *rects2++;
+ }
+ tempReg->extents = reg1->extents;
+ tempReg->numRects = reg1->numRects + reg2->numRects;
+ EXTENTS(&reg2->extents, tempReg);
+ miRegionCopy(newReg, tempReg);
+ Xfree((char *)tempReg);
+}
+
+/*
+ * QuickCheck checks to see if it does not have to go through all the
+ * the ugly code for the region call. It returns 1 if it did all
+ * the work for Union, otherwise 0 - still work to be done.
+*/
+
+static int
+QuickCheck(Region newReg, Region reg1, Region reg2)
+{
+
+ /* if unioning with itself or no rects to union with */
+ if ( (reg1 == reg2) || (!(reg1->numRects)) )
+ {
+ miRegionCopy(newReg, reg2);
+ return TRUE;
+ }
+
+ /* if nothing to union */
+ if (!(reg2->numRects))
+ {
+ miRegionCopy(newReg, reg1);
+ return TRUE;
+ }
+
+ /* could put an extent check to see if add above or below */
+
+ if ((reg1->extents.y1 >= reg2->extents.y2) ||
+ (reg2->extents.y1 >= reg1->extents.y2) )
+ {
+ combineRegs(newReg, reg1, reg2);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/* TopRects(rects, reg1, reg2)
+ * N.B. We now assume that reg1 and reg2 intersect. Therefore we are
+ * NOT checking in the two while loops for stepping off the end of the
+ * region.
+ */
+
+static int
+TopRects(
+ register Region newReg,
+ register BOX *rects,
+ register Region reg1,
+ register Region reg2,
+ BOX *FirstRect)
+{
+ register BOX *tempRects;
+
+ /* need to add some rects from region 1 */
+ if (reg1->extents.y1 < reg2->extents.y1)
+ {
+ tempRects = reg1->rects;
+ while(tempRects->y1 < reg2->extents.y1)
+ {
+ MEMCHECK(newReg, rects, FirstRect);
+ ADDRECTNOX(newReg,rects, tempRects->x1, tempRects->y1,
+ tempRects->x2, MIN(tempRects->y2, reg2->extents.y1));
+ tempRects++;
+ }
+ }
+ /* need to add some rects from region 2 */
+ if (reg2->extents.y1 < reg1->extents.y1)
+ {
+ tempRects = reg2->rects;
+ while (tempRects->y1 < reg1->extents.y1)
+ {
+ MEMCHECK(newReg, rects, FirstRect);
+ ADDRECTNOX(newReg, rects, tempRects->x1,tempRects->y1,
+ tempRects->x2, MIN(tempRects->y2, reg1->extents.y1));
+ tempRects++;
+ }
+ }
+ return 1;
+}
+#endif
+
+/*======================================================================
+ * Generic Region Operator
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * miCoalesce --
+ * Attempt to merge the boxes in the current band with those in the
+ * previous one. Used only by miRegionOp.
+ *
+ * Results:
+ * The new index for the previous band.
+ *
+ * Side Effects:
+ * If coalescing takes place:
+ * - rectangles in the previous band will have their y2 fields
+ * altered.
+ * - pReg->numRects will be decreased.
+ *
+ *-----------------------------------------------------------------------
+ */
+/* static int*/
+static int
+miCoalesce(
+ register Region pReg, /* Region to coalesce */
+ int prevStart, /* Index of start of previous band */
+ int curStart) /* Index of start of current band */
+{
+ register BoxPtr pPrevBox; /* Current box in previous band */
+ register BoxPtr pCurBox; /* Current box in current band */
+ register BoxPtr pRegEnd; /* End of region */
+ int curNumRects; /* Number of rectangles in current
+ * band */
+ int prevNumRects; /* Number of rectangles in previous
+ * band */
+ int bandY1; /* Y1 coordinate for current band */
+
+ pRegEnd = &pReg->rects[pReg->numRects];
+
+ pPrevBox = &pReg->rects[prevStart];
+ prevNumRects = curStart - prevStart;
+
+ /*
+ * Figure out how many rectangles are in the current band. Have to do
+ * this because multiple bands could have been added in miRegionOp
+ * at the end when one region has been exhausted.
+ */
+ pCurBox = &pReg->rects[curStart];
+ bandY1 = pCurBox->y1;
+ for (curNumRects = 0;
+ (pCurBox != pRegEnd) && (pCurBox->y1 == bandY1);
+ curNumRects++)
+ {
+ pCurBox++;
+ }
+
+ if (pCurBox != pRegEnd)
+ {
+ /*
+ * If more than one band was added, we have to find the start
+ * of the last band added so the next coalescing job can start
+ * at the right place... (given when multiple bands are added,
+ * this may be pointless -- see above).
+ */
+ pRegEnd--;
+ while (pRegEnd[-1].y1 == pRegEnd->y1)
+ {
+ pRegEnd--;
+ }
+ curStart = pRegEnd - pReg->rects;
+ pRegEnd = pReg->rects + pReg->numRects;
+ }
+
+ if ((curNumRects == prevNumRects) && (curNumRects != 0)) {
+ pCurBox -= curNumRects;
+ /*
+ * The bands may only be coalesced if the bottom of the previous
+ * matches the top scanline of the current.
+ */
+ if (pPrevBox->y2 == pCurBox->y1)
+ {
+ /*
+ * Make sure the bands have boxes in the same places. This
+ * assumes that boxes have been added in such a way that they
+ * cover the most area possible. I.e. two boxes in a band must
+ * have some horizontal space between them.
+ */
+ do
+ {
+ if ((pPrevBox->x1 != pCurBox->x1) ||
+ (pPrevBox->x2 != pCurBox->x2))
+ {
+ /*
+ * The bands don't line up so they can't be coalesced.
+ */
+ return (curStart);
+ }
+ pPrevBox++;
+ pCurBox++;
+ prevNumRects -= 1;
+ } while (prevNumRects != 0);
+
+ pReg->numRects -= curNumRects;
+ pCurBox -= curNumRects;
+ pPrevBox -= curNumRects;
+
+ /*
+ * The bands may be merged, so set the bottom y of each box
+ * in the previous band to that of the corresponding box in
+ * the current band.
+ */
+ do
+ {
+ pPrevBox->y2 = pCurBox->y2;
+ pPrevBox++;
+ pCurBox++;
+ curNumRects -= 1;
+ } while (curNumRects != 0);
+
+ /*
+ * If only one band was added to the region, we have to backup
+ * curStart to the start of the previous band.
+ *
+ * If more than one band was added to the region, copy the
+ * other bands down. The assumption here is that the other bands
+ * came from the same region as the current one and no further
+ * coalescing can be done on them since it's all been done
+ * already... curStart is already in the right place.
+ */
+ if (pCurBox == pRegEnd)
+ {
+ curStart = prevStart;
+ }
+ else
+ {
+ do
+ {
+ *pPrevBox++ = *pCurBox++;
+ } while (pCurBox != pRegEnd);
+ }
+
+ }
+ }
+ return (curStart);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miRegionOp --
+ * Apply an operation to two regions. Called by miUnion, miInverse,
+ * miSubtract, miIntersect...
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * The new region is overwritten.
+ *
+ * Notes:
+ * The idea behind this function is to view the two regions as sets.
+ * Together they cover a rectangle of area that this function divides
+ * into horizontal bands where points are covered only by one region
+ * or by both. For the first case, the nonOverlapFunc is called with
+ * each the band and the band's upper and lower extents. For the
+ * second, the overlapFunc is called to process the entire band. It
+ * is responsible for clipping the rectangles in the band, though
+ * this function provides the boundaries.
+ * At the end of each band, the new region is coalesced, if possible,
+ * to reduce the number of rectangles in the region.
+ *
+ *-----------------------------------------------------------------------
+ */
+/* static void*/
+static void
+miRegionOp(
+ register Region newReg, /* Place to store result */
+ Region reg1, /* First region in operation */
+ Region reg2, /* 2d region in operation */
+ int (*overlapFunc)(
+ register Region pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ short y1,
+ short y2), /* Function to call for over-
+ * lapping bands */
+ int (*nonOverlap1Func)(
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2), /* Function to call for non-
+ * overlapping bands in region
+ * 1 */
+ int (*nonOverlap2Func)(
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2)) /* Function to call for non-
+ * overlapping bands in region
+ * 2 */
+{
+ register BoxPtr r1; /* Pointer into first region */
+ register BoxPtr r2; /* Pointer into 2d region */
+ BoxPtr r1End; /* End of 1st region */
+ BoxPtr r2End; /* End of 2d region */
+ register short ybot; /* Bottom of intersection */
+ register short ytop; /* Top of intersection */
+ BoxPtr oldRects; /* Old rects for newReg */
+ int prevBand; /* Index of start of
+ * previous band in newReg */
+ int curBand; /* Index of start of current
+ * band in newReg */
+ register BoxPtr r1BandEnd; /* End of current band in r1 */
+ register BoxPtr r2BandEnd; /* End of current band in r2 */
+ short top; /* Top of non-overlapping
+ * band */
+ short bot; /* Bottom of non-overlapping
+ * band */
+
+ /*
+ * Initialization:
+ * set r1, r2, r1End and r2End appropriately, preserve the important
+ * parts of the destination region until the end in case it's one of
+ * the two source regions, then mark the "new" region empty, allocating
+ * another array of rectangles for it to use.
+ */
+ r1 = reg1->rects;
+ r2 = reg2->rects;
+ r1End = r1 + reg1->numRects;
+ r2End = r2 + reg2->numRects;
+
+ oldRects = newReg->rects;
+
+ EMPTY_REGION(newReg);
+
+ /*
+ * Allocate a reasonable number of rectangles for the new region. The idea
+ * is to allocate enough so the individual functions don't need to
+ * reallocate and copy the array, which is time consuming, yet we don't
+ * have to worry about using too much memory. I hope to be able to
+ * nuke the Xrealloc() at the end of this function eventually.
+ */
+ newReg->size = max(reg1->numRects,reg2->numRects) * 2;
+
+ if (! (newReg->rects = (BoxPtr)
+ Xmalloc ((unsigned) (sizeof(BoxRec) * newReg->size)))) {
+ newReg->size = 0;
+ return;
+ }
+
+ /*
+ * Initialize ybot and ytop.
+ * In the upcoming loop, ybot and ytop serve different functions depending
+ * on whether the band being handled is an overlapping or non-overlapping
+ * band.
+ * In the case of a non-overlapping band (only one of the regions
+ * has points in the band), ybot is the bottom of the most recent
+ * intersection and thus clips the top of the rectangles in that band.
+ * ytop is the top of the next intersection between the two regions and
+ * serves to clip the bottom of the rectangles in the current band.
+ * For an overlapping band (where the two regions intersect), ytop clips
+ * the top of the rectangles of both regions and ybot clips the bottoms.
+ */
+ if (reg1->extents.y1 < reg2->extents.y1)
+ ybot = reg1->extents.y1;
+ else
+ ybot = reg2->extents.y1;
+
+ /*
+ * prevBand serves to mark the start of the previous band so rectangles
+ * can be coalesced into larger rectangles. qv. miCoalesce, above.
+ * In the beginning, there is no previous band, so prevBand == curBand
+ * (curBand is set later on, of course, but the first band will always
+ * start at index 0). prevBand and curBand must be indices because of
+ * the possible expansion, and resultant moving, of the new region's
+ * array of rectangles.
+ */
+ prevBand = 0;
+
+ do
+ {
+ curBand = newReg->numRects;
+
+ /*
+ * This algorithm proceeds one source-band (as opposed to a
+ * destination band, which is determined by where the two regions
+ * intersect) at a time. r1BandEnd and r2BandEnd serve to mark the
+ * rectangle after the last one in the current band for their
+ * respective regions.
+ */
+ r1BandEnd = r1;
+ while ((r1BandEnd != r1End) && (r1BandEnd->y1 == r1->y1))
+ {
+ r1BandEnd++;
+ }
+
+ r2BandEnd = r2;
+ while ((r2BandEnd != r2End) && (r2BandEnd->y1 == r2->y1))
+ {
+ r2BandEnd++;
+ }
+
+ /*
+ * First handle the band that doesn't intersect, if any.
+ *
+ * Note that attention is restricted to one band in the
+ * non-intersecting region at once, so if a region has n
+ * bands between the current position and the next place it overlaps
+ * the other, this entire loop will be passed through n times.
+ */
+ if (r1->y1 < r2->y1)
+ {
+ top = max(r1->y1,ybot);
+ bot = min(r1->y2,r2->y1);
+
+ if ((top != bot) && (nonOverlap1Func != NULL))
+ {
+ (* nonOverlap1Func) (newReg, r1, r1BandEnd, top, bot);
+ }
+
+ ytop = r2->y1;
+ }
+ else if (r2->y1 < r1->y1)
+ {
+ top = max(r2->y1,ybot);
+ bot = min(r2->y2,r1->y1);
+
+ if ((top != bot) && (nonOverlap2Func != NULL))
+ {
+ (* nonOverlap2Func) (newReg, r2, r2BandEnd, top, bot);
+ }
+
+ ytop = r1->y1;
+ }
+ else
+ {
+ ytop = r1->y1;
+ }
+
+ /*
+ * If any rectangles got added to the region, try and coalesce them
+ * with rectangles from the previous band. Note we could just do
+ * this test in miCoalesce, but some machines incur a not
+ * inconsiderable cost for function calls, so...
+ */
+ if (newReg->numRects != curBand)
+ {
+ prevBand = miCoalesce (newReg, prevBand, curBand);
+ }
+
+ /*
+ * Now see if we've hit an intersecting band. The two bands only
+ * intersect if ybot > ytop
+ */
+ ybot = min(r1->y2, r2->y2);
+ curBand = newReg->numRects;
+ if (ybot > ytop)
+ {
+ (* overlapFunc) (newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot);
+
+ }
+
+ if (newReg->numRects != curBand)
+ {
+ prevBand = miCoalesce (newReg, prevBand, curBand);
+ }
+
+ /*
+ * If we've finished with a band (y2 == ybot) we skip forward
+ * in the region to the next band.
+ */
+ if (r1->y2 == ybot)
+ {
+ r1 = r1BandEnd;
+ }
+ if (r2->y2 == ybot)
+ {
+ r2 = r2BandEnd;
+ }
+ } while ((r1 != r1End) && (r2 != r2End));
+
+ /*
+ * Deal with whichever region still has rectangles left.
+ */
+ curBand = newReg->numRects;
+ if (r1 != r1End)
+ {
+ if (nonOverlap1Func != NULL)
+ {
+ do
+ {
+ r1BandEnd = r1;
+ while ((r1BandEnd < r1End) && (r1BandEnd->y1 == r1->y1))
+ {
+ r1BandEnd++;
+ }
+ (* nonOverlap1Func) (newReg, r1, r1BandEnd,
+ max(r1->y1,ybot), r1->y2);
+ r1 = r1BandEnd;
+ } while (r1 != r1End);
+ }
+ }
+ else if ((r2 != r2End) && (nonOverlap2Func != NULL))
+ {
+ do
+ {
+ r2BandEnd = r2;
+ while ((r2BandEnd < r2End) && (r2BandEnd->y1 == r2->y1))
+ {
+ r2BandEnd++;
+ }
+ (* nonOverlap2Func) (newReg, r2, r2BandEnd,
+ max(r2->y1,ybot), r2->y2);
+ r2 = r2BandEnd;
+ } while (r2 != r2End);
+ }
+
+ if (newReg->numRects != curBand)
+ {
+ (void) miCoalesce (newReg, prevBand, curBand);
+ }
+
+ /*
+ * A bit of cleanup. To keep regions from growing without bound,
+ * we shrink the array of rectangles to match the new number of
+ * rectangles in the region. This never goes to 0, however...
+ *
+ * Only do this stuff if the number of rectangles allocated is more than
+ * twice the number of rectangles in the region (a simple optimization...).
+ */
+ if (newReg->numRects < (newReg->size >> 1))
+ {
+ if (REGION_NOT_EMPTY(newReg))
+ {
+ BoxPtr prev_rects = newReg->rects;
+ newReg->size = newReg->numRects;
+ newReg->rects = (BoxPtr) Xrealloc ((char *) newReg->rects,
+ (unsigned) (sizeof(BoxRec) * newReg->size));
+ if (! newReg->rects)
+ newReg->rects = prev_rects;
+ }
+ else
+ {
+ /*
+ * No point in doing the extra work involved in an Xrealloc if
+ * the region is empty
+ */
+ newReg->size = 1;
+ Xfree((char *) newReg->rects);
+ newReg->rects = (BoxPtr) Xmalloc(sizeof(BoxRec));
+ }
+ }
+ Xfree ((char *) oldRects);
+ return;
+}
+
+
+/*======================================================================
+ * Region Union
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * miUnionNonO --
+ * Handle a non-overlapping band for the union operation. Just
+ * Adds the rectangles into the region. Doesn't have to check for
+ * subsumption or anything.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * pReg->numRects is incremented and the final rectangles overwritten
+ * with the rectangles we're passed.
+ *
+ *-----------------------------------------------------------------------
+ */
+/* static void*/
+static int
+miUnionNonO (
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2)
+{
+ register BoxPtr pNextRect;
+
+ pNextRect = &pReg->rects[pReg->numRects];
+
+ assert(y1 < y2);
+
+ while (r != rEnd)
+ {
+ assert(r->x1 < r->x2);
+ MEMCHECK(pReg, pNextRect, pReg->rects);
+ pNextRect->x1 = r->x1;
+ pNextRect->y1 = y1;
+ pNextRect->x2 = r->x2;
+ pNextRect->y2 = y2;
+ pReg->numRects += 1;
+ pNextRect++;
+
+ assert(pReg->numRects<=pReg->size);
+ r++;
+ }
+ return 0; /* lint */
+}
+
+
+/*-
+ *-----------------------------------------------------------------------
+ * miUnionO --
+ * Handle an overlapping band for the union operation. Picks the
+ * left-most rectangle each time and merges it into the region.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Rectangles are overwritten in pReg->rects and pReg->numRects will
+ * be changed.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+/* static void*/
+static int
+miUnionO (
+ register Region pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ register short y1,
+ register short y2)
+{
+ register BoxPtr pNextRect;
+
+ pNextRect = &pReg->rects[pReg->numRects];
+
+#define MERGERECT(r) \
+ if ((pReg->numRects != 0) && \
+ (pNextRect[-1].y1 == y1) && \
+ (pNextRect[-1].y2 == y2) && \
+ (pNextRect[-1].x2 >= r->x1)) \
+ { \
+ if (pNextRect[-1].x2 < r->x2) \
+ { \
+ pNextRect[-1].x2 = r->x2; \
+ assert(pNextRect[-1].x1<pNextRect[-1].x2); \
+ } \
+ } \
+ else \
+ { \
+ MEMCHECK(pReg, pNextRect, pReg->rects); \
+ pNextRect->y1 = y1; \
+ pNextRect->y2 = y2; \
+ pNextRect->x1 = r->x1; \
+ pNextRect->x2 = r->x2; \
+ pReg->numRects += 1; \
+ pNextRect += 1; \
+ } \
+ assert(pReg->numRects<=pReg->size);\
+ r++;
+
+ assert (y1<y2);
+ while ((r1 != r1End) && (r2 != r2End))
+ {
+ if (r1->x1 < r2->x1)
+ {
+ MERGERECT(r1);
+ }
+ else
+ {
+ MERGERECT(r2);
+ }
+ }
+
+ if (r1 != r1End)
+ {
+ do
+ {
+ MERGERECT(r1);
+ } while (r1 != r1End);
+ }
+ else while (r2 != r2End)
+ {
+ MERGERECT(r2);
+ }
+ return 0; /* lint */
+}
+
+int
+XUnionRegion(
+ Region reg1,
+ Region reg2, /* source regions */
+ Region newReg) /* destination Region */
+{
+ /* checks all the simple cases */
+
+ /*
+ * Region 1 and 2 are the same or region 1 is empty
+ */
+ if ( (reg1 == reg2) || (!(reg1->numRects)) )
+ {
+ if (newReg != reg2)
+ miRegionCopy(newReg, reg2);
+ return 1;
+ }
+
+ /*
+ * if nothing to union (region 2 empty)
+ */
+ if (!(reg2->numRects))
+ {
+ if (newReg != reg1)
+ miRegionCopy(newReg, reg1);
+ return 1;
+ }
+
+ /*
+ * Region 1 completely subsumes region 2
+ */
+ if ((reg1->numRects == 1) &&
+ (reg1->extents.x1 <= reg2->extents.x1) &&
+ (reg1->extents.y1 <= reg2->extents.y1) &&
+ (reg1->extents.x2 >= reg2->extents.x2) &&
+ (reg1->extents.y2 >= reg2->extents.y2))
+ {
+ if (newReg != reg1)
+ miRegionCopy(newReg, reg1);
+ return 1;
+ }
+
+ /*
+ * Region 2 completely subsumes region 1
+ */
+ if ((reg2->numRects == 1) &&
+ (reg2->extents.x1 <= reg1->extents.x1) &&
+ (reg2->extents.y1 <= reg1->extents.y1) &&
+ (reg2->extents.x2 >= reg1->extents.x2) &&
+ (reg2->extents.y2 >= reg1->extents.y2))
+ {
+ if (newReg != reg2)
+ miRegionCopy(newReg, reg2);
+ return 1;
+ }
+
+ miRegionOp (newReg, reg1, reg2, miUnionO,
+ miUnionNonO, miUnionNonO);
+
+ newReg->extents.x1 = min(reg1->extents.x1, reg2->extents.x1);
+ newReg->extents.y1 = min(reg1->extents.y1, reg2->extents.y1);
+ newReg->extents.x2 = max(reg1->extents.x2, reg2->extents.x2);
+ newReg->extents.y2 = max(reg1->extents.y2, reg2->extents.y2);
+
+ return 1;
+}
+
+
+/*======================================================================
+ * Region Subtraction
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * miSubtractNonO --
+ * Deal with non-overlapping band for subtraction. Any parts from
+ * region 2 we discard. Anything from region 1 we add to the region.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * pReg may be affected.
+ *
+ *-----------------------------------------------------------------------
+ */
+/* static void*/
+static int
+miSubtractNonO1 (
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2)
+{
+ register BoxPtr pNextRect;
+
+ pNextRect = &pReg->rects[pReg->numRects];
+
+ assert(y1<y2);
+
+ while (r != rEnd)
+ {
+ assert(r->x1<r->x2);
+ MEMCHECK(pReg, pNextRect, pReg->rects);
+ pNextRect->x1 = r->x1;
+ pNextRect->y1 = y1;
+ pNextRect->x2 = r->x2;
+ pNextRect->y2 = y2;
+ pReg->numRects += 1;
+ pNextRect++;
+
+ assert(pReg->numRects <= pReg->size);
+
+ r++;
+ }
+ return 0; /* lint */
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miSubtractO --
+ * Overlapping band subtraction. x1 is the left-most point not yet
+ * checked.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * pReg may have rectangles added to it.
+ *
+ *-----------------------------------------------------------------------
+ */
+/* static void*/
+static int
+miSubtractO (
+ register Region pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ register short y1,
+ register short y2)
+{
+ register BoxPtr pNextRect;
+ register int x1;
+
+ x1 = r1->x1;
+
+ assert(y1<y2);
+ pNextRect = &pReg->rects[pReg->numRects];
+
+ while ((r1 != r1End) && (r2 != r2End))
+ {
+ if (r2->x2 <= x1)
+ {
+ /*
+ * Subtrahend missed the boat: go to next subtrahend.
+ */
+ r2++;
+ }
+ else if (r2->x1 <= x1)
+ {
+ /*
+ * Subtrahend preceeds minuend: nuke left edge of minuend.
+ */
+ x1 = r2->x2;
+ if (x1 >= r1->x2)
+ {
+ /*
+ * Minuend completely covered: advance to next minuend and
+ * reset left fence to edge of new minuend.
+ */
+ r1++;
+ if (r1 != r1End)
+ x1 = r1->x1;
+ }
+ else
+ {
+ /*
+ * Subtrahend now used up since it doesn't extend beyond
+ * minuend
+ */
+ r2++;
+ }
+ }
+ else if (r2->x1 < r1->x2)
+ {
+ /*
+ * Left part of subtrahend covers part of minuend: add uncovered
+ * part of minuend to region and skip to next subtrahend.
+ */
+ assert(x1<r2->x1);
+ MEMCHECK(pReg, pNextRect, pReg->rects);
+ pNextRect->x1 = x1;
+ pNextRect->y1 = y1;
+ pNextRect->x2 = r2->x1;
+ pNextRect->y2 = y2;
+ pReg->numRects += 1;
+ pNextRect++;
+
+ assert(pReg->numRects<=pReg->size);
+
+ x1 = r2->x2;
+ if (x1 >= r1->x2)
+ {
+ /*
+ * Minuend used up: advance to new...
+ */
+ r1++;
+ if (r1 != r1End)
+ x1 = r1->x1;
+ }
+ else
+ {
+ /*
+ * Subtrahend used up
+ */
+ r2++;
+ }
+ }
+ else
+ {
+ /*
+ * Minuend used up: add any remaining piece before advancing.
+ */
+ if (r1->x2 > x1)
+ {
+ MEMCHECK(pReg, pNextRect, pReg->rects);
+ pNextRect->x1 = x1;
+ pNextRect->y1 = y1;
+ pNextRect->x2 = r1->x2;
+ pNextRect->y2 = y2;
+ pReg->numRects += 1;
+ pNextRect++;
+ assert(pReg->numRects<=pReg->size);
+ }
+ r1++;
+ if (r1 != r1End)
+ x1 = r1->x1;
+ }
+ }
+
+ /*
+ * Add remaining minuend rectangles to region.
+ */
+ while (r1 != r1End)
+ {
+ assert(x1<r1->x2);
+ MEMCHECK(pReg, pNextRect, pReg->rects);
+ pNextRect->x1 = x1;
+ pNextRect->y1 = y1;
+ pNextRect->x2 = r1->x2;
+ pNextRect->y2 = y2;
+ pReg->numRects += 1;
+ pNextRect++;
+
+ assert(pReg->numRects<=pReg->size);
+
+ r1++;
+ if (r1 != r1End)
+ {
+ x1 = r1->x1;
+ }
+ }
+ return 0; /* lint */
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miSubtract --
+ * Subtract regS from regM and leave the result in regD.
+ * S stands for subtrahend, M for minuend and D for difference.
+ *
+ * Results:
+ * TRUE.
+ *
+ * Side Effects:
+ * regD is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+int
+XSubtractRegion(
+ Region regM,
+ Region regS,
+ register Region regD)
+{
+ /* check for trivial reject */
+ if ( (!(regM->numRects)) || (!(regS->numRects)) ||
+ (!EXTENTCHECK(&regM->extents, &regS->extents)) )
+ {
+ miRegionCopy(regD, regM);
+ return 1;
+ }
+
+ miRegionOp (regD, regM, regS, miSubtractO,
+ miSubtractNonO1, NULL);
+
+ /*
+ * Can't alter newReg's extents before we call miRegionOp because
+ * it might be one of the source regions and miRegionOp depends
+ * on the extents of those regions being the unaltered. Besides, this
+ * way there's no checking against rectangles that will be nuked
+ * due to coalescing, so we have to examine fewer rectangles.
+ */
+ miSetExtents (regD);
+ return 1;
+}
+
+int
+XXorRegion(Region sra, Region srb, Region dr)
+{
+ Region tra, trb;
+
+ if ((! (tra = XCreateRegion())) || (! (trb = XCreateRegion())))
+ return 0;
+ (void) XSubtractRegion(sra,srb,tra);
+ (void) XSubtractRegion(srb,sra,trb);
+ (void) XUnionRegion(tra,trb,dr);
+ XDestroyRegion(tra);
+ XDestroyRegion(trb);
+ return 0;
+}
+
+/*
+ * Check to see if the region is empty. Assumes a region is passed
+ * as a parameter
+ */
+int
+XEmptyRegion(
+ Region r)
+{
+ if( r->numRects == 0 ) return TRUE;
+ else return FALSE;
+}
+
+/*
+ * Check to see if two regions are equal
+ */
+int
+XEqualRegion(Region r1, Region r2)
+{
+ int i;
+
+ if( r1->numRects != r2->numRects ) return FALSE;
+ else if( r1->numRects == 0 ) return TRUE;
+ else if ( r1->extents.x1 != r2->extents.x1 ) return FALSE;
+ else if ( r1->extents.x2 != r2->extents.x2 ) return FALSE;
+ else if ( r1->extents.y1 != r2->extents.y1 ) return FALSE;
+ else if ( r1->extents.y2 != r2->extents.y2 ) return FALSE;
+ else for( i=0; i < r1->numRects; i++ ) {
+ if ( r1->rects[i].x1 != r2->rects[i].x1 ) return FALSE;
+ else if ( r1->rects[i].x2 != r2->rects[i].x2 ) return FALSE;
+ else if ( r1->rects[i].y1 != r2->rects[i].y1 ) return FALSE;
+ else if ( r1->rects[i].y2 != r2->rects[i].y2 ) return FALSE;
+ }
+ return TRUE;
+}
+
+int
+XPointInRegion(
+ Region pRegion,
+ int x, int y)
+{
+ int i;
+
+ if (pRegion->numRects == 0)
+ return FALSE;
+ if (!INBOX(pRegion->extents, x, y))
+ return FALSE;
+ for (i=0; i<pRegion->numRects; i++)
+ {
+ if (INBOX (pRegion->rects[i], x, y))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int
+XRectInRegion(
+ register Region region,
+ int rx, int ry,
+ unsigned int rwidth, unsigned int rheight)
+{
+ register BoxPtr pbox;
+ register BoxPtr pboxEnd;
+ Box rect;
+ register BoxPtr prect = &rect;
+ int partIn, partOut;
+
+ prect->x1 = rx;
+ prect->y1 = ry;
+ prect->x2 = rwidth + rx;
+ prect->y2 = rheight + ry;
+
+ /* this is (just) a useful optimization */
+ if ((region->numRects == 0) || !EXTENTCHECK(&region->extents, prect))
+ return(RectangleOut);
+
+ partOut = FALSE;
+ partIn = FALSE;
+
+ /* can stop when both partOut and partIn are TRUE, or we reach prect->y2 */
+ for (pbox = region->rects, pboxEnd = pbox + region->numRects;
+ pbox < pboxEnd;
+ pbox++)
+ {
+
+ if (pbox->y2 <= ry)
+ continue; /* getting up to speed or skipping remainder of band */
+
+ if (pbox->y1 > ry)
+ {
+ partOut = TRUE; /* missed part of rectangle above */
+ if (partIn || (pbox->y1 >= prect->y2))
+ break;
+ ry = pbox->y1; /* x guaranteed to be == prect->x1 */
+ }
+
+ if (pbox->x2 <= rx)
+ continue; /* not far enough over yet */
+
+ if (pbox->x1 > rx)
+ {
+ partOut = TRUE; /* missed part of rectangle to left */
+ if (partIn)
+ break;
+ }
+
+ if (pbox->x1 < prect->x2)
+ {
+ partIn = TRUE; /* definitely overlap */
+ if (partOut)
+ break;
+ }
+
+ if (pbox->x2 >= prect->x2)
+ {
+ ry = pbox->y2; /* finished with this band */
+ if (ry >= prect->y2)
+ break;
+ rx = prect->x1; /* reset x out to left again */
+ } else
+ {
+ /*
+ * Because boxes in a band are maximal width, if the first box
+ * to overlap the rectangle doesn't completely cover it in that
+ * band, the rectangle must be partially out, since some of it
+ * will be uncovered in that band. partIn will have been set true
+ * by now...
+ */
+ break;
+ }
+
+ }
+
+ return(partIn ? ((ry < prect->y2) ? RectanglePart : RectangleIn) :
+ RectangleOut);
+}
diff --git a/nx-X11/lib/X11/RegstFlt.c b/nx-X11/lib/X11/RegstFlt.c
new file mode 100644
index 000000000..0648a54d1
--- /dev/null
+++ b/nx-X11/lib/X11/RegstFlt.c
@@ -0,0 +1,157 @@
+/* $Xorg: RegstFlt.c,v 1.5 2001/02/09 02:03:35 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 1990, 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.
+
+*/
+/* $XFree86: xc/lib/X11/RegstFlt.c,v 1.5 2003/04/13 19:22:17 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+static void
+_XFreeIMFilters(
+ Display *display)
+{
+ register XFilterEventList fl;
+
+ while ((fl = display->im_filters)) {
+ display->im_filters = fl->next;
+ Xfree((char *)fl);
+ }
+}
+
+/*
+ * Register a filter with the filter machinery by event mask.
+ */
+void
+_XRegisterFilterByMask(
+ Display *display,
+ Window window,
+ unsigned long event_mask,
+ Bool (*filter)(
+ Display*, Window, XEvent*, XPointer
+ ),
+ XPointer client_data)
+{
+ XFilterEventRec *rec;
+
+ rec = (XFilterEventList)Xmalloc(sizeof(XFilterEventRec));
+ if (!rec)
+ return;
+ rec->window = window;
+ rec->event_mask = event_mask;
+ rec->start_type = 0;
+ rec->end_type = 0;
+ rec->filter = filter;
+ rec->client_data = client_data;
+ LockDisplay(display);
+ rec->next = display->im_filters;
+ display->im_filters = rec;
+ display->free_funcs->im_filters = _XFreeIMFilters;
+ UnlockDisplay(display);
+}
+
+/*
+ * Register a filter with the filter machinery by type code.
+ */
+void
+_XRegisterFilterByType(
+ Display *display,
+ Window window,
+ int start_type,
+ int end_type,
+ Bool (*filter)(
+ Display*, Window, XEvent*, XPointer
+ ),
+ XPointer client_data)
+{
+ XFilterEventRec *rec;
+
+ rec = (XFilterEventList)Xmalloc(sizeof(XFilterEventRec));
+ if (!rec)
+ return;
+ rec->window = window;
+ rec->event_mask = 0;
+ rec->start_type = start_type;
+ rec->end_type = end_type;
+ rec->filter = filter;
+ rec->client_data = client_data;
+ LockDisplay(display);
+ rec->next = display->im_filters;
+ display->im_filters = rec;
+ display->free_funcs->im_filters = _XFreeIMFilters;
+ UnlockDisplay(display);
+}
+
+void
+_XUnregisterFilter(
+ Display *display,
+ Window window,
+ Bool (*filter)(
+ Display*, Window, XEvent*, XPointer
+ ),
+ XPointer client_data)
+{
+ register XFilterEventList *prev, fl;
+
+ for (prev = &display->im_filters; (fl = *prev); ) {
+ if (fl->window == window &&
+ fl->filter == filter && fl->client_data == client_data) {
+ *prev = fl->next;
+ Xfree((char *)fl);
+ } else
+ prev = &fl->next;
+ }
+}
diff --git a/nx-X11/lib/X11/RepWindow.c b/nx-X11/lib/X11/RepWindow.c
new file mode 100644
index 000000000..b30340e01
--- /dev/null
+++ b/nx-X11/lib/X11/RepWindow.c
@@ -0,0 +1,52 @@
+/* $Xorg: RepWindow.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/RepWindow.c,v 1.3 2001/01/17 19:41:42 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XReparentWindow(dpy, w, p, x, y)
+ register Display *dpy;
+ Window w, p;
+ int x, y;
+{
+ register xReparentWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ReparentWindow, req);
+ req->window = w;
+ req->parent = p;
+ req->x = x;
+ req->y = y;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/RestackWs.c b/nx-X11/lib/X11/RestackWs.c
new file mode 100644
index 000000000..1887e7c73
--- /dev/null
+++ b/nx-X11/lib/X11/RestackWs.c
@@ -0,0 +1,72 @@
+/* $Xorg: RestackWs.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/RestackWs.c,v 1.3 2001/01/17 19:41:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XRestackWindows (dpy, windows, n)
+ register Display *dpy;
+ register Window *windows;
+ int n;
+ {
+ int i = 0;
+#ifdef MUSTCOPY
+ unsigned long val = Below; /* needed for macro below */
+#endif
+
+ LockDisplay(dpy);
+ while (windows++, ++i < n) {
+ register xConfigureWindowReq *req;
+
+ GetReqExtra (ConfigureWindow, 8, req);
+ req->window = *windows;
+ req->mask = CWSibling | CWStackMode;
+#ifdef MUSTCOPY
+ dpy->bufptr -= 8;
+ Data32 (dpy, (long *)(windows-1), 4);
+ Data32 (dpy, (long *)&val, 4);
+#else
+ {
+ register CARD32 *values = (CARD32 *)
+ NEXTPTR(req,xConfigureWindowReq);
+ *values++ = *(windows-1);
+ *values = Below;
+ }
+#endif /* MUSTCOPY */
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
+
+
+
diff --git a/nx-X11/lib/X11/RotProp.c b/nx-X11/lib/X11/RotProp.c
new file mode 100644
index 000000000..a8f811957
--- /dev/null
+++ b/nx-X11/lib/X11/RotProp.c
@@ -0,0 +1,65 @@
+/* $Xorg: RotProp.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/RotProp.c,v 1.3 2001/01/17 19:41:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XRotateWindowProperties(dpy, w, properties, nprops, npositions)
+ register Display *dpy;
+ Window w;
+ Atom *properties;
+ register int nprops;
+ int npositions;
+ {
+ register long nbytes;
+ register xRotatePropertiesReq *req;
+
+ LockDisplay(dpy);
+ GetReq (RotateProperties, req);
+ req->window = w;
+ req->nAtoms = nprops;
+ req->nPositions = npositions;
+
+ req->length += nprops;
+ nbytes = nprops << 2;
+/* XXX Cray needs packing here.... */
+ Data32 (dpy, (long *) properties, nbytes);
+
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
+
+
+
+
diff --git a/nx-X11/lib/X11/ScrResStr.c b/nx-X11/lib/X11/ScrResStr.c
new file mode 100644
index 000000000..89f771784
--- /dev/null
+++ b/nx-X11/lib/X11/ScrResStr.c
@@ -0,0 +1,57 @@
+/* $Xorg: ScrResStr.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xatom.h>
+
+char *XScreenResourceString(screen)
+ Screen *screen;
+{
+ Atom prop_name;
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long leftover;
+ char *val = NULL;
+
+ prop_name = XInternAtom(screen->display, "SCREEN_RESOURCES", True);
+ if (prop_name &&
+ XGetWindowProperty(screen->display, screen->root, prop_name,
+ 0L, 100000000L, False,
+ XA_STRING, &actual_type, &actual_format,
+ &nitems, &leftover,
+ (unsigned char **) &val) == Success) {
+ if ((actual_type == XA_STRING) && (actual_format == 8))
+ return val;
+ if (val)
+ Xfree(val);
+ }
+ return (char *)NULL;
+}
diff --git a/nx-X11/lib/X11/SelInput.c b/nx-X11/lib/X11/SelInput.c
new file mode 100644
index 000000000..e517a5c6b
--- /dev/null
+++ b/nx-X11/lib/X11/SelInput.c
@@ -0,0 +1,51 @@
+/* $Xorg: SelInput.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SelInput.c,v 1.3 2001/01/17 19:41:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSelectInput (dpy, w, mask)
+ register Display *dpy;
+ Window w;
+ long mask;
+{
+ register xChangeWindowAttributesReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWEventMask;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), mask);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/SendEvent.c b/nx-X11/lib/X11/SendEvent.c
new file mode 100644
index 000000000..06e23a5c9
--- /dev/null
+++ b/nx-X11/lib/X11/SendEvent.c
@@ -0,0 +1,79 @@
+/* $Xorg: SendEvent.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SendEvent.c,v 1.4 2001/12/14 19:54:05 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/*
+ * In order to avoid all images requiring _XEventToWire, we install the
+ * event converter here if it has never been installed.
+ */
+Status
+XSendEvent(dpy, w, propagate, event_mask, event)
+ register Display *dpy;
+ Window w;
+ Bool propagate;
+ long event_mask;
+ XEvent *event;
+{
+ register xSendEventReq *req;
+ xEvent ev;
+ register Status (**fp)(
+ Display * /* dpy */,
+ XEvent * /* re */,
+ xEvent * /* event */);
+ Status status;
+
+ LockDisplay (dpy);
+
+ /* call through display to find proper conversion routine */
+
+ fp = &dpy->wire_vec[event->type & 0177];
+ if (*fp == NULL) *fp = _XEventToWire;
+ status = (**fp)(dpy, event, &ev);
+
+ if (status) {
+ GetReq(SendEvent, req);
+ req->destination = w;
+ req->propagate = propagate;
+ req->eventMask = event_mask;
+#ifdef WORD64
+ /* avoid quad-alignment problems */
+ memcpy ((char *) req->eventdata, (char *) &ev, SIZEOF(xEvent));
+#else
+ req->event = ev;
+#endif /* WORD64 */
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(status);
+}
diff --git a/nx-X11/lib/X11/SetBack.c b/nx-X11/lib/X11/SetBack.c
new file mode 100644
index 000000000..037933f1d
--- /dev/null
+++ b/nx-X11/lib/X11/SetBack.c
@@ -0,0 +1,48 @@
+/* $Xorg: SetBack.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetBack.c,v 1.3 2001/01/17 19:41:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetBackground (dpy, gc, background)
+register Display *dpy;
+GC gc;
+unsigned long background; /* CARD32 */
+{
+ LockDisplay(dpy);
+ if (gc->values.background != background) {
+ gc->values.background = background;
+ gc->dirty |= GCBackground;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetCCC.c b/nx-X11/lib/X11/SetCCC.c
new file mode 100644
index 000000000..8ab0464dd
--- /dev/null
+++ b/nx-X11/lib/X11/SetCCC.c
@@ -0,0 +1,140 @@
+/* $Xorg: SetCCC.c,v 1.3 2000/08/17 19:44:52 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsSetCCC.c - Color Conversion Context Setting Routines
+ *
+ * DESCRIPTION
+ * Routines to set components of a Color Conversion
+ * Context structure.
+ *
+ *
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsSetWhitePoint
+ *
+ * SYNOPSIS
+ */
+
+Status
+XcmsSetWhitePoint(ccc, pColor)
+ XcmsCCC ccc;
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * Sets the Client White Point in the specified CCC.
+ *
+ * RETURNS
+ * Returns XcmsSuccess if succeeded; otherwise XcmsFailure.
+ *
+ */
+{
+ if (pColor == NULL || pColor->format == XcmsUndefinedFormat) {
+ ccc->clientWhitePt.format = XcmsUndefinedFormat;
+ } else if (pColor->format != XcmsCIEXYZFormat &&
+ pColor->format != XcmsCIEuvYFormat &&
+ pColor->format != XcmsCIExyYFormat) {
+ return(XcmsFailure);
+ } else {
+ memcpy((char *)&ccc->clientWhitePt, (char *)pColor, sizeof(XcmsColor));
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsSetCompressionProc
+ *
+ * SYNOPSIS
+ */
+
+XcmsCompressionProc
+XcmsSetCompressionProc(
+ XcmsCCC ccc,
+ XcmsCompressionProc compression_proc,
+ XPointer client_data)
+/*
+ * DESCRIPTION
+ * Set the specified CCC's compression function and client data.
+ *
+ * RETURNS
+ * Returns the old compression function.
+ *
+ */
+{
+ XcmsCompressionProc old = ccc->gamutCompProc;
+
+ ccc->gamutCompProc = compression_proc;
+ ccc->gamutCompClientData = client_data;
+ return(old);
+}
+
+
+/*
+ * NAME
+ * XcmsSetWhiteAdjustProc
+ *
+ * SYNOPSIS
+ */
+
+XcmsWhiteAdjustProc
+XcmsSetWhiteAdjustProc(
+ XcmsCCC ccc,
+ XcmsWhiteAdjustProc white_adjust_proc,
+ XPointer client_data )
+/*
+ * DESCRIPTION
+ * Set the specified CCC's white_adjust function and client data.
+ *
+ * RETURNS
+ * Returns the old white_adjust function.
+ *
+ */
+{
+ XcmsWhiteAdjustProc old = ccc->whitePtAdjProc;
+
+ ccc->whitePtAdjProc = white_adjust_proc;
+ ccc->whitePtAdjClientData = client_data;
+ return(old);
+}
diff --git a/nx-X11/lib/X11/SetCRects.c b/nx-X11/lib/X11/SetCRects.c
new file mode 100644
index 000000000..a8dcf6643
--- /dev/null
+++ b/nx-X11/lib/X11/SetCRects.c
@@ -0,0 +1,83 @@
+/* $Xorg: SetCRects.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetCRects.c,v 1.4 2001/12/14 19:54:06 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/* can only call when display is locked. */
+void _XSetClipRectangles (
+ register Display *dpy,
+ GC gc,
+ int clip_x_origin, int clip_y_origin,
+ XRectangle *rectangles,
+ int n,
+ int ordering)
+{
+ register xSetClipRectanglesReq *req;
+ register long len;
+ unsigned long dirty;
+ register _XExtension *ext;
+
+ GetReq (SetClipRectangles, req);
+ req->gc = gc->gid;
+ req->xOrigin = gc->values.clip_x_origin = clip_x_origin;
+ req->yOrigin = gc->values.clip_y_origin = clip_y_origin;
+ req->ordering = ordering;
+ len = ((long)n) << 1;
+ SetReqLen(req, len, 1);
+ len <<= 2;
+ Data16 (dpy, (short *) rectangles, len);
+ gc->rects = 1;
+ dirty = gc->dirty & ~(GCClipMask | GCClipXOrigin | GCClipYOrigin);
+ gc->dirty = GCClipMask | GCClipXOrigin | GCClipYOrigin;
+ /* 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 = dirty;
+}
+
+int
+XSetClipRectangles (dpy, gc, clip_x_origin, clip_y_origin, rectangles, n,
+ ordering)
+ register Display *dpy;
+ GC gc;
+ int clip_x_origin, clip_y_origin;
+ XRectangle *rectangles;
+ int n;
+ int ordering;
+{
+ LockDisplay(dpy);
+ _XSetClipRectangles (dpy, gc, clip_x_origin, clip_y_origin, rectangles, n,
+ ordering);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/SetClMask.c b/nx-X11/lib/X11/SetClMask.c
new file mode 100644
index 000000000..f9fb051f0
--- /dev/null
+++ b/nx-X11/lib/X11/SetClMask.c
@@ -0,0 +1,49 @@
+/* $Xorg: SetClMask.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetClMask.c,v 1.3 2001/01/17 19:41:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetClipMask (dpy, gc, mask)
+register Display *dpy;
+GC gc;
+Pixmap mask;
+{
+ LockDisplay(dpy);
+ /* always update, since client may have changed pixmap contents */
+ gc->values.clip_mask = mask;
+ gc->dirty |= GCClipMask;
+ gc->rects = 0;
+ _XFlushGCCache(dpy, gc);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetClOrig.c b/nx-X11/lib/X11/SetClOrig.c
new file mode 100644
index 000000000..60f0346eb
--- /dev/null
+++ b/nx-X11/lib/X11/SetClOrig.c
@@ -0,0 +1,54 @@
+/* $Xorg: SetClOrig.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetClOrig.c,v 1.3 2001/01/17 19:41:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetClipOrigin (dpy, gc, xorig, yorig)
+register Display *dpy;
+GC gc;
+int xorig, yorig;
+{
+ XGCValues *gv = &gc->values;
+
+ LockDisplay(dpy);
+ if (xorig != gv->clip_x_origin) {
+ gv->clip_x_origin = xorig;
+ gc->dirty |= GCClipXOrigin;
+ }
+ if (yorig != gv->clip_y_origin) {
+ gv->clip_y_origin = yorig;
+ gc->dirty |= GCClipYOrigin;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetDashes.c b/nx-X11/lib/X11/SetDashes.c
new file mode 100644
index 000000000..6ecf955d1
--- /dev/null
+++ b/nx-X11/lib/X11/SetDashes.c
@@ -0,0 +1,57 @@
+/* $Xorg: SetDashes.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetDashes.c,v 1.4 2001/12/14 19:54:06 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetDashes (
+ register Display *dpy,
+ GC gc,
+ int dash_offset,
+ _Xconst char *list,
+ int n)
+ {
+ register xSetDashesReq *req;
+
+ LockDisplay(dpy);
+ GetReq (SetDashes,req);
+ req->gc = gc->gid;
+ req->dashOffset = gc->values.dash_offset = dash_offset;
+ req->nDashes = n;
+ req->length += (n+3)>>2;
+ gc->dashes = 1;
+ gc->dirty &= ~(GCDashList | GCDashOffset);
+ Data (dpy, list, (long)n);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
diff --git a/nx-X11/lib/X11/SetFPath.c b/nx-X11/lib/X11/SetFPath.c
new file mode 100644
index 000000000..086c657df
--- /dev/null
+++ b/nx-X11/lib/X11/SetFPath.c
@@ -0,0 +1,79 @@
+/* $Xorg: SetFPath.c,v 1.5 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetFPath.c,v 1.5 2001/01/17 19:41:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+#define safestrlen(s) ((s) ? strlen(s) : 0)
+
+int
+XSetFontPath (dpy, directories, ndirs)
+register Display *dpy;
+char **directories;
+int ndirs;
+{
+ register int n = 0;
+ register int i;
+ register int nbytes;
+ char *p;
+ register xSetFontPathReq *req;
+ int retCode;
+
+ LockDisplay(dpy);
+ GetReq (SetFontPath, req);
+ req->nFonts = ndirs;
+ for (i = 0; i < ndirs; i++) {
+ n += safestrlen (directories[i]) + 1;
+ }
+ nbytes = (n + 3) & ~3;
+ req->length += nbytes >> 2;
+ if ((p = (char *) Xmalloc ((unsigned) nbytes))) {
+ /*
+ * pack into counted strings.
+ */
+ char *tmp = p;
+
+ for (i = 0; i < ndirs; i++) {
+ register int length = safestrlen (directories[i]);
+ *p = length;
+ memcpy (p + 1, directories[i], length);
+ p += length + 1;
+ }
+ Data (dpy, tmp, nbytes);
+ Xfree ((char *) tmp);
+ retCode = 1;
+ }
+ else
+ retCode = 0;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (retCode);
+}
diff --git a/nx-X11/lib/X11/SetFont.c b/nx-X11/lib/X11/SetFont.c
new file mode 100644
index 000000000..089960d7c
--- /dev/null
+++ b/nx-X11/lib/X11/SetFont.c
@@ -0,0 +1,49 @@
+/* $Xorg: SetFont.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetFont.c,v 1.3 2001/01/17 19:41:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetFont (dpy, gc, font)
+register Display *dpy;
+GC gc;
+Font font;
+{
+ LockDisplay(dpy);
+ if (gc->values.font != font) {
+ gc->values.font = font;
+ gc->dirty |= GCFont;
+ _XFlushGCCache(dpy, gc);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetFore.c b/nx-X11/lib/X11/SetFore.c
new file mode 100644
index 000000000..62ffb8fd3
--- /dev/null
+++ b/nx-X11/lib/X11/SetFore.c
@@ -0,0 +1,48 @@
+/* $Xorg: SetFore.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetFore.c,v 1.3 2001/01/17 19:41:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetForeground (dpy, gc, foreground)
+register Display *dpy;
+GC gc;
+unsigned long foreground; /* CARD32 */
+{
+ LockDisplay(dpy);
+ if (gc->values.foreground != foreground) {
+ gc->values.foreground = foreground;
+ gc->dirty |= GCForeground;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetFunc.c b/nx-X11/lib/X11/SetFunc.c
new file mode 100644
index 000000000..a253266da
--- /dev/null
+++ b/nx-X11/lib/X11/SetFunc.c
@@ -0,0 +1,48 @@
+/* $Xorg: SetFunc.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetFunc.c,v 1.3 2001/01/17 19:41:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetFunction (dpy, gc, function)
+register Display *dpy;
+GC gc;
+int function;
+{
+ LockDisplay(dpy);
+ if (gc->values.function != function) {
+ gc->values.function = function;
+ gc->dirty |= GCFunction;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetGetCols.c b/nx-X11/lib/X11/SetGetCols.c
new file mode 100644
index 000000000..03f7a2f72
--- /dev/null
+++ b/nx-X11/lib/X11/SetGetCols.c
@@ -0,0 +1,303 @@
+/* $Xorg: SetGetCols.c,v 1.3 2000/08/17 19:44:54 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsSetGet.c
+ *
+ * DESCRIPTION
+ * Source for _XcmsSetGetColors()
+ *
+ *
+ */
+/* $XFree86$ */
+
+/*
+ * EXTERNAL INCLUDES
+ * Include files that must be exported to any package or
+ * program using this package.
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsSetColor -
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsSetGetColor(
+ Status (*xColorProc)(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* screen_in_out */),
+ Display *dpy,
+ Colormap cmap,
+ XcmsColor *pColors_in_out,
+ XcmsColorFormat result_format,
+ Bool *pCompressed)
+/*
+ * DESCRIPTION
+ * Routine containing code common to:
+ * XcmsAllocColor
+ * XcmsQueryColor
+ * XcmsStoreColor
+ *
+ * RETURNS
+ * XcmsFailure if failed;
+ * XcmsSuccess if it succeeded without gamut compression;
+ * XcmsSuccessWithCompression if it succeeded with gamut
+ * compression;
+ */
+{
+ XcmsCCC ccc;
+ XColor XColors_in_out;
+ Status retval = XcmsSuccess;
+
+ /*
+ * Argument Checking
+ * 1. Assume xColorProc is correct
+ * 2. Insure ccc not NULL
+ * 3. Assume cmap correct (should be checked by Server)
+ * 4. Insure pColors_in_out valid
+ * 5. Assume method_in is valid (should be checked by Server)
+ */
+
+ if (dpy == NULL) {
+ return(XcmsFailure);
+ }
+
+ if (result_format == XcmsUndefinedFormat) {
+ return(XcmsFailure);
+ }
+
+ if ( !((*xColorProc == XAllocColor) || (*xColorProc == XStoreColor)
+ || (*xColorProc == XQueryColor)) ) {
+ return(XcmsFailure);
+ }
+
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) == (XcmsCCC)NULL) {
+ return(XcmsFailure);
+ }
+
+ if (*xColorProc == XQueryColor) {
+ goto Query;
+ }
+
+ /*
+ * Convert to RGB, adjusting for white point differences if necessary.
+ */
+ if ((retval = XcmsConvertColors(ccc, pColors_in_out, 1, XcmsRGBFormat,
+ pCompressed)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+Query:
+ /*
+ * Convert XcmsColor to XColor structures
+ */
+ _XcmsRGB_to_XColor(pColors_in_out, &XColors_in_out, 1);
+
+ /*
+ * Now make appropriate X Call
+ */
+ if (*xColorProc == XAllocColor) {
+ if ((*xColorProc)(ccc->dpy, cmap, &XColors_in_out) == 0) {
+ return(XcmsFailure);
+ }
+ } else if ((*xColorProc == XQueryColor) || (*xColorProc == XStoreColor)) {
+ /* Note: XQueryColor and XStoreColor do not return any Status */
+ (*xColorProc)(ccc->dpy, cmap, &XColors_in_out);
+ } else {
+ return(XcmsFailure);
+ }
+
+ if ((*xColorProc == XStoreColor)) {
+ return(retval);
+ }
+
+ /*
+ * Now, convert the returned XColor (i.e., rgb) to XcmsColor structures
+ */
+ _XColor_to_XcmsRGB(ccc, &XColors_in_out, pColors_in_out, 1);
+
+ /*
+ * Then, convert XcmsColor structures to the original specification
+ * format. Note that we must use NULL instead of passing
+ * pCompressed.
+ */
+
+ if (result_format != XcmsRGBFormat) {
+ if (XcmsConvertColors(ccc, pColors_in_out, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ return(retval);
+}
+
+/*
+ * NAME
+ * XcmsSetColors -
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsSetGetColors(
+ Status (*xColorProc)(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* screen_in_out */,
+ int /* nColors */),
+ Display *dpy,
+ Colormap cmap,
+ XcmsColor *pColors_in_out,
+ int nColors,
+ XcmsColorFormat result_format,
+ Bool *pCompressed)
+/*
+ * DESCRIPTION
+ * Routine containing code common to:
+ * XcmsQueryColors
+ * XcmsStoreColors
+ *
+ * RETURNS
+ * XcmsFailure if failed;
+ * XcmsSuccess if it succeeded without gamut compression;
+ * XcmsSuccessWithCompression if it succeeded with gamut
+ * compression;
+ */
+{
+ XcmsCCC ccc;
+ XColor *pXColors_in_out;
+ Status retval = XcmsSuccess;
+
+ /*
+ * Argument Checking
+ * 1. Assume xColorProc is correct
+ * 2. Insure ccc not NULL
+ * 3. Assume cmap correct (should be checked by Server)
+ * 4. Insure pColors_in_out valid
+ * 5. Assume method_in is valid (should be checked by Server)
+ * 6. Insure nColors > 0
+ */
+
+ if (dpy == NULL) {
+ return(XcmsFailure);
+ }
+
+ if (nColors == 0) {
+ return(XcmsSuccess);
+ }
+
+ if (result_format == XcmsUndefinedFormat) {
+ return(XcmsFailure);
+ }
+
+ if ( !((*xColorProc == XStoreColors) || (*xColorProc == XQueryColors)) ) {
+ return(XcmsFailure);
+ }
+
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) == (XcmsCCC)NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Allocate space for XColors
+ */
+ if ((pXColors_in_out = (XColor *)Xcalloc(nColors, sizeof(XColor))) ==
+ NULL) {
+ return(XcmsFailure);
+ }
+
+ if (*xColorProc == XQueryColors) {
+ goto Query;
+ }
+
+ /*
+ * Convert to RGB, adjusting for white point differences if necessary.
+ */
+ if ((retval = XcmsConvertColors(ccc, pColors_in_out, nColors, XcmsRGBFormat,
+ pCompressed)) == XcmsFailure) {
+ Xfree((char *)pXColors_in_out);
+ return(XcmsFailure);
+ }
+
+Query:
+ /*
+ * Convert XcmsColor to XColor structures
+ */
+ _XcmsRGB_to_XColor(pColors_in_out, pXColors_in_out, nColors);
+
+ /*
+ * Now make appropriate X Call
+ */
+ if ((*xColorProc == XQueryColors) || (*xColorProc == XStoreColors)){
+ /* Note: XQueryColors and XStoreColors do not return any Status */
+ (*xColorProc)(ccc->dpy, cmap, pXColors_in_out, nColors);
+ } else {
+ Xfree((char *)pXColors_in_out);
+ return(XcmsFailure);
+ }
+
+ if (*xColorProc == XStoreColors) {
+ Xfree((char *)pXColors_in_out);
+ return(retval);
+ }
+
+ /*
+ * Now, convert the returned XColor (i.e., rgb) to XcmsColor structures
+ */
+ _XColor_to_XcmsRGB(ccc, pXColors_in_out, pColors_in_out, nColors);
+ Xfree((char *)pXColors_in_out);
+
+ /*
+ * Then, convert XcmsColor structures to the original specification
+ * format. Note that we must use NULL instead of passing
+ * pCompressed.
+ */
+ if (result_format != XcmsRGBFormat) {
+ if (XcmsConvertColors(ccc, pColors_in_out, nColors, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(retval);
+}
+
+/* ### EOF ### */
diff --git a/nx-X11/lib/X11/SetHints.c b/nx-X11/lib/X11/SetHints.c
new file mode 100644
index 000000000..5ee34435d
--- /dev/null
+++ b/nx-X11/lib/X11/SetHints.c
@@ -0,0 +1,297 @@
+/* $Xorg: SetHints.c,v 1.5 2001/02/09 02:03:36 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/SetHints.c,v 1.4 2001/12/14 19:54:06 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "Xatomtype.h"
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+
+#define safestrlen(s) ((s) ? strlen(s) : 0)
+
+int
+XSetSizeHints(dpy, w, hints, property) /* old routine */
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+ Atom property;
+{
+ xPropSizeHints prop;
+ prop.flags = (hints->flags & (USPosition|USSize|PAllHints));
+ prop.x = hints->x;
+ prop.y = hints->y;
+ prop.width = hints->width;
+ prop.height = hints->height;
+ prop.minWidth = hints->min_width;
+ prop.minHeight = hints->min_height;
+ prop.maxWidth = hints->max_width;
+ prop.maxHeight = hints->max_height;
+ prop.widthInc = hints->width_inc;
+ prop.heightInc = hints->height_inc;
+ prop.minAspectX = hints->min_aspect.x;
+ prop.minAspectY = hints->min_aspect.y;
+ prop.maxAspectX = hints->max_aspect.x;
+ prop.maxAspectY = hints->max_aspect.y;
+ return XChangeProperty (dpy, w, property, XA_WM_SIZE_HINTS, 32,
+ PropModeReplace, (unsigned char *) &prop,
+ OldNumPropSizeElements);
+}
+
+/*
+ * XSetWMHints sets the property
+ * WM_HINTS type: WM_HINTS format:32
+ */
+
+int
+XSetWMHints (dpy, w, wmhints)
+ Display *dpy;
+ Window w;
+ XWMHints *wmhints;
+{
+ xPropWMHints prop;
+ prop.flags = wmhints->flags;
+ prop.input = (wmhints->input == True ? 1 : 0);
+ prop.initialState = wmhints->initial_state;
+ prop.iconPixmap = wmhints->icon_pixmap;
+ prop.iconWindow = wmhints->icon_window;
+ prop.iconX = wmhints->icon_x;
+ prop.iconY = wmhints->icon_y;
+ prop.iconMask = wmhints->icon_mask;
+ prop.windowGroup = wmhints->window_group;
+ return XChangeProperty (dpy, w, XA_WM_HINTS, XA_WM_HINTS, 32,
+ PropModeReplace, (unsigned char *) &prop,
+ NumPropWMHintsElements);
+}
+
+
+
+/*
+ * XSetZoomHints sets the property
+ * WM_ZOOM_HINTS type: WM_SIZE_HINTS format: 32
+ */
+
+int
+XSetZoomHints (dpy, w, zhints)
+ Display *dpy;
+ Window w;
+ XSizeHints *zhints;
+{
+ return XSetSizeHints (dpy, w, zhints, XA_WM_ZOOM_HINTS);
+}
+
+
+/*
+ * XSetNormalHints sets the property
+ * WM_NORMAL_HINTS type: WM_SIZE_HINTS format: 32
+ */
+
+int
+XSetNormalHints (dpy, w, hints) /* old routine */
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+{
+ return XSetSizeHints (dpy, w, hints, XA_WM_NORMAL_HINTS);
+}
+
+
+
+/*
+ * Note, the following is one of the few cases were we really do want sizeof
+ * when examining a protocol structure. This is because the XChangeProperty
+ * routine will take care of converting to host to network data structures.
+ */
+
+int
+XSetIconSizes (dpy, w, list, count)
+ Display *dpy;
+ Window w; /* typically, root */
+ XIconSize *list;
+ int count; /* number of items on the list */
+{
+ register int i;
+ xPropIconSize *pp, *prop;
+#define size_of_the_real_thing sizeof /* avoid grepping screwups */
+ unsigned nbytes = count * size_of_the_real_thing(xPropIconSize);
+#undef size_of_the_real_thing
+ if ((prop = pp = (xPropIconSize *) Xmalloc (nbytes))) {
+ for (i = 0; i < count; i++) {
+ pp->minWidth = list->min_width;
+ pp->minHeight = list->min_height;
+ pp->maxWidth = list->max_width;
+ pp->maxHeight = list->max_height;
+ pp->widthInc = list->width_inc;
+ pp->heightInc = list->height_inc;
+ pp += 1;
+ list += 1;
+ }
+ XChangeProperty (dpy, w, XA_WM_ICON_SIZE, XA_WM_ICON_SIZE, 32,
+ PropModeReplace, (unsigned char *) prop,
+ count * NumPropIconSizeElements);
+ Xfree ((char *)prop);
+ }
+ return 1;
+}
+
+int
+XSetCommand (dpy, w, argv, argc)
+ Display *dpy;
+ Window w;
+ char **argv;
+ int argc;
+{
+ register int i;
+ register int nbytes;
+ register char *buf, *bp;
+ for (i = 0, nbytes = 0; i < argc; i++) {
+ nbytes += safestrlen(argv[i]) + 1;
+ }
+ if ((bp = buf = Xmalloc((unsigned) nbytes))) {
+ /* copy arguments into single buffer */
+ for (i = 0; i < argc; i++) {
+ if (argv[i]) {
+ (void) strcpy(bp, argv[i]);
+ bp += strlen(argv[i]) + 1;
+ }
+ else
+ *bp++ = '\0';
+ }
+ XChangeProperty (dpy, w, XA_WM_COMMAND, XA_STRING, 8,
+ PropModeReplace, (unsigned char *)buf, nbytes);
+ Xfree(buf);
+ }
+ return 1;
+}
+/*
+ * XSetStandardProperties sets the following properties:
+ * WM_NAME type: STRING format: 8
+ * WM_ICON_NAME type: STRING format: 8
+ * WM_HINTS type: WM_HINTS format: 32
+ * WM_COMMAND type: STRING
+ * WM_NORMAL_HINTS type: WM_SIZE_HINTS format: 32
+ */
+
+int
+XSetStandardProperties (
+ Display *dpy,
+ Window w, /* window to decorate */
+ _Xconst char *name, /* name of application */
+ _Xconst char *icon_string,/* name string for icon */
+ Pixmap icon_pixmap, /* pixmap to use as icon, or None */
+ char **argv, /* command to be used to restart application */
+ int argc, /* count of arguments */
+ XSizeHints *hints) /* size hints for window in its normal state */
+{
+ XWMHints phints;
+ phints.flags = 0;
+
+ if (name != NULL) XStoreName (dpy, w, name);
+
+ if (icon_string != NULL) {
+ XChangeProperty (dpy, w, XA_WM_ICON_NAME, XA_STRING, 8,
+ PropModeReplace, (unsigned char *)icon_string, safestrlen(icon_string));
+ }
+
+ if (icon_pixmap != None) {
+ phints.icon_pixmap = icon_pixmap;
+ phints.flags |= IconPixmapHint;
+ }
+ if (argv != NULL) XSetCommand(dpy, w, argv, argc);
+
+ if (hints != NULL) XSetNormalHints(dpy, w, hints);
+
+ if (phints.flags != 0) XSetWMHints(dpy, w, &phints);
+
+ return 1;
+}
+
+int
+XSetTransientForHint(dpy, w, propWindow)
+ Display *dpy;
+ Window w;
+ Window propWindow;
+{
+ return XChangeProperty(dpy, w, XA_WM_TRANSIENT_FOR, XA_WINDOW, 32,
+ PropModeReplace, (unsigned char *) &propWindow, 1);
+}
+
+int
+XSetClassHint(dpy, w, classhint)
+ Display *dpy;
+ Window w;
+ XClassHint *classhint;
+{
+ char *class_string;
+ char *s;
+ int len_nm, len_cl;
+
+ len_nm = safestrlen(classhint->res_name);
+ len_cl = safestrlen(classhint->res_class);
+ if ((class_string = s = Xmalloc((unsigned) (len_nm + len_cl + 2)))) {
+ if (len_nm) {
+ strcpy(s, classhint->res_name);
+ s += len_nm + 1;
+ }
+ else
+ *s++ = '\0';
+ if (len_cl)
+ strcpy(s, classhint->res_class);
+ else
+ *s = '\0';
+ XChangeProperty(dpy, w, XA_WM_CLASS, XA_STRING, 8,
+ PropModeReplace, (unsigned char *) class_string,
+ len_nm+len_cl+2);
+ Xfree(class_string);
+ }
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetIFocus.c b/nx-X11/lib/X11/SetIFocus.c
new file mode 100644
index 000000000..4f42908f2
--- /dev/null
+++ b/nx-X11/lib/X11/SetIFocus.c
@@ -0,0 +1,52 @@
+/* $Xorg: SetIFocus.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetIFocus.c,v 1.3 2001/01/17 19:41:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetInputFocus(dpy, focus, revert_to, time)
+ register Display *dpy;
+ Window focus;
+ int revert_to;
+ Time time;
+{
+ register xSetInputFocusReq *req;
+
+ LockDisplay(dpy);
+ GetReq(SetInputFocus, req);
+ req->focus = focus;
+ req->revertTo = revert_to;
+ req->time = time;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/SetLStyle.c b/nx-X11/lib/X11/SetLStyle.c
new file mode 100644
index 000000000..74233d0b2
--- /dev/null
+++ b/nx-X11/lib/X11/SetLStyle.c
@@ -0,0 +1,65 @@
+/* $Xorg: SetLStyle.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetLStyle.c,v 1.3 2001/01/17 19:41:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetLineAttributes(dpy, gc, linewidth, linestyle, capstyle, joinstyle)
+register Display *dpy;
+GC gc;
+unsigned int linewidth; /* CARD16 */
+int linestyle;
+int capstyle;
+int joinstyle;
+{
+ XGCValues *gv = &gc->values;
+
+ LockDisplay(dpy);
+ if (linewidth != gv->line_width) {
+ gv->line_width = linewidth;
+ gc->dirty |= GCLineWidth;
+ }
+ if (linestyle != gv->line_style) {
+ gv->line_style = linestyle;
+ gc->dirty |= GCLineStyle;
+ }
+ if (capstyle != gv->cap_style) {
+ gv->cap_style = capstyle;
+ gc->dirty |= GCCapStyle;
+ }
+ if (joinstyle != gv->join_style) {
+ gv->join_style = joinstyle;
+ gc->dirty |= GCJoinStyle;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetLocale.c b/nx-X11/lib/X11/SetLocale.c
new file mode 100644
index 000000000..bb4f850e3
--- /dev/null
+++ b/nx-X11/lib/X11/SetLocale.c
@@ -0,0 +1,257 @@
+/* $XdotOrg: xc/lib/X11/SetLocale.c,v 1.4 2005/07/03 07:00:55 daniels Exp $ */
+/* $Xorg: SetLocale.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+
+/*
+ * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
+ * and Nippon Telegraph and Telephone 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 names of OMRON, NTT Software, and NTT
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. OMRON, NTT Software,
+ * and NTT make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OMRON, NTT SOFTWARE, AND NTT, DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL OMRON, NTT SOFTWARE, OR NTT, 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.
+ *
+ * Authors: Li Yuhong OMRON Corporation
+ * Tetsuya Kato NTT Software Corporation
+ * Hiroshi Kuribayashi OMRON Corporation
+ *
+ */
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/X11/SetLocale.c,v 3.20 2003/11/17 22:20:08 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include <X11/Xlocale.h>
+#include <X11/Xos.h>
+#include "XlcPubI.h"
+
+#define MAXLOCALE 64 /* buffer size of locale name */
+
+#ifdef X_LOCALE
+
+/* alternative setlocale() for when the OS does not provide one */
+
+char *
+_Xsetlocale(
+ int category,
+ _Xconst char *name
+)
+{
+ static char *xsl_name;
+ char *old_name;
+ XrmMethods methods;
+ XPointer state;
+
+ if (category != LC_CTYPE && category != LC_ALL)
+ return NULL;
+ if (!name) {
+ if (xsl_name)
+ return xsl_name;
+ return "C";
+ }
+ if (!*name)
+ name = getenv("LC_CTYPE");
+ if (!name || !*name)
+ name = getenv("LANG");
+ if (name && strlen(name) >= MAXLOCALE)
+ name = NULL;
+ if (!name || !*name || !_XOpenLC((char *) name))
+ name = "C";
+ old_name = xsl_name;
+ xsl_name = (char *)name;
+ methods = _XrmInitParseInfo(&state);
+ xsl_name = old_name;
+ if (!methods)
+ return NULL;
+ name = (*methods->lcname)(state);
+ xsl_name = Xmalloc(strlen(name) + 1);
+ if (!xsl_name) {
+ xsl_name = old_name;
+ (*methods->destroy)(state);
+ return NULL;
+ }
+ strcpy(xsl_name, name);
+ if (old_name)
+ Xfree(old_name);
+ (*methods->destroy)(state);
+ return xsl_name;
+}
+
+#else /* X_LOCALE */
+
+#ifdef __DARWIN__
+char *
+_Xsetlocale(
+ int category,
+ _Xconst char *name
+)
+{
+ return setlocale(category, name);
+}
+#endif /* __DARWIN__ */
+
+/*
+ * _XlcMapOSLocaleName is an implementation dependent routine that derives
+ * the LC_CTYPE locale name as used in the sample implementation from that
+ * returned by setlocale.
+ *
+ * Should match the code in Xt ExtractLocaleName.
+ *
+ * This function name is a bit of a misnomer. Even the siname parameter
+ * name is a misnomer. On most modern operating systems this function is
+ * a no-op, simply returning the osname; but on older operating systems
+ * like Ultrix, or HPUX 9.x and earlier, when you set LANG=german.88591
+ * then the string returned by setlocale(LC_ALL, "") will look something
+ * like: "german.88591 german.88591 ... german.88591". Then this function
+ * will pick out the LC_CTYPE component and return a pointer to that.
+ */
+
+char *
+_XlcMapOSLocaleName(
+ char *osname,
+ char *siname)
+{
+#if defined(hpux) || defined(CSRG_BASED) || defined(sun) || defined(SVR4) || defined(sgi) || defined(__osf__) || defined(AIXV3) || defined(ultrix) || defined(WIN32) || defined(__UNIXOS2__) || defined(linux)
+# ifdef hpux
+# ifndef _LastCategory
+ /* HPUX 9 and earlier */
+# define SKIPCOUNT 2
+# define STARTCHAR ':'
+# define ENDCHAR ';'
+# else
+ /* HPUX 10 */
+# define ENDCHAR ' '
+# endif
+# else
+# ifdef ultrix
+# define SKIPCOUNT 2
+# define STARTCHAR '\001'
+# define ENDCHAR '\001'
+# else
+# if defined(WIN32) || defined(__UNIXOS2__)
+# define SKIPCOUNT 1
+# define STARTCHAR '='
+# define ENDCHAR ';'
+# define WHITEFILL
+# else
+# if defined(__osf__) || (defined(AIXV3) && !defined(AIXV4))
+# define STARTCHAR ' '
+# define ENDCHAR ' '
+# else
+# if defined(linux)
+# define STARTSTR "LC_CTYPE="
+# define ENDCHAR ';'
+# else
+# if !defined(sun) || defined(SVR4)
+# define STARTCHAR '/'
+# define ENDCHAR '/'
+# endif
+# endif
+# endif
+# endif
+# endif
+# endif
+
+ char *start;
+ char *end;
+ int len;
+# ifdef SKIPCOUNT
+ int n;
+# endif
+
+ start = osname;
+# ifdef SKIPCOUNT
+ for (n = SKIPCOUNT;
+ --n >= 0 && start && (start = strchr (start, STARTCHAR));
+ start++)
+ ;
+ if (!start)
+ start = osname;
+# endif
+# ifdef STARTCHAR
+ if (start && (start = strchr (start, STARTCHAR)))
+# elif defined (STARTSTR)
+ if (start && (start = strstr (start,STARTSTR)))
+# endif
+ {
+# ifdef STARTCHAR
+ start++;
+# elif defined (STARTSTR)
+ start += strlen(STARTSTR);
+# endif
+ if ((end = strchr (start, ENDCHAR))) {
+ len = end - start;
+ if (len >= MAXLOCALE)
+ len = MAXLOCALE - 1;
+ strncpy(siname, start, len);
+ *(siname + len) = '\0';
+# ifdef WHITEFILL
+ for (start = siname; start = strchr(start, ' '); )
+ *start++ = '-';
+# endif
+ return siname;
+ } else /* if no ENDCHAR is found we are at the end of the line */
+ return start;
+ }
+# ifdef WHITEFILL
+ if (strchr(osname, ' ')) {
+ len = strlen(osname);
+ if (len >= MAXLOCALE - 1)
+ len = MAXLOCALE - 1;
+ strncpy(siname, osname, len);
+ *(siname + len) = '\0';
+ for (start = siname; start = strchr(start, ' '); )
+ *start++ = '-';
+ return siname;
+ }
+# endif
+# undef STARTCHAR
+# undef ENDCHAR
+# undef WHITEFILL
+#endif
+ return osname;
+}
+
+#endif /* X_LOCALE */
diff --git a/nx-X11/lib/X11/SetNrmHint.c b/nx-X11/lib/X11/SetNrmHint.c
new file mode 100644
index 000000000..64b0ef7f3
--- /dev/null
+++ b/nx-X11/lib/X11/SetNrmHint.c
@@ -0,0 +1,111 @@
+/* $Xorg: SetNrmHint.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "Xatomtype.h"
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+
+void XSetWMSizeHints (dpy, w, hints, prop)
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+ Atom prop;
+{
+ xPropSizeHints data;
+
+ data.flags = (hints->flags &
+ (USPosition|USSize|PPosition|PSize|PMinSize|PMaxSize|
+ PResizeInc|PAspect|PBaseSize|PWinGravity));
+
+ /*
+ * The x, y, width, and height fields are obsolete; but, applications
+ * that want to work with old window managers might set them.
+ */
+ data.x = hints->x;
+ data.y = hints->y;
+ data.width = hints->width;
+ data.height = hints->height;
+
+ data.minWidth = hints->min_width;
+ data.minHeight = hints->min_height;
+ data.maxWidth = hints->max_width;
+ data.maxHeight = hints->max_height;
+ data.widthInc = hints->width_inc;
+ data.heightInc = hints->height_inc;
+ data.minAspectX = hints->min_aspect.x;
+ data.minAspectY = hints->min_aspect.y;
+ data.maxAspectX = hints->max_aspect.x;
+ data.maxAspectY = hints->max_aspect.y;
+ data.baseWidth = hints->base_width;
+ data.baseHeight = hints->base_height;
+ data.winGravity = hints->win_gravity;
+
+ XChangeProperty (dpy, w, prop, XA_WM_SIZE_HINTS, 32,
+ PropModeReplace, (unsigned char *) &data,
+ NumPropSizeElements);
+}
+
+
+void XSetWMNormalHints (dpy, w, hints)
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+{
+ XSetWMSizeHints (dpy, w, hints, XA_WM_NORMAL_HINTS);
+}
+
diff --git a/nx-X11/lib/X11/SetPMask.c b/nx-X11/lib/X11/SetPMask.c
new file mode 100644
index 000000000..268ef4fd0
--- /dev/null
+++ b/nx-X11/lib/X11/SetPMask.c
@@ -0,0 +1,48 @@
+/* $Xorg: SetPMask.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetPMask.c,v 1.3 2001/01/17 19:41:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetPlaneMask (dpy, gc, planemask)
+register Display *dpy;
+GC gc;
+unsigned long planemask; /* CARD32 */
+{
+ LockDisplay(dpy);
+ if (gc->values.plane_mask != planemask) {
+ gc->values.plane_mask = planemask;
+ gc->dirty |= GCPlaneMask;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetPntMap.c b/nx-X11/lib/X11/SetPntMap.c
new file mode 100644
index 000000000..4a98ad48c
--- /dev/null
+++ b/nx-X11/lib/X11/SetPntMap.c
@@ -0,0 +1,83 @@
+/* $Xorg: SetPntMap.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetPntMap.c,v 1.4 2001/12/14 19:54:06 dawes Exp $ */
+
+#define NEED_REPLIES
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+/* returns either DeviceMappingSuccess or DeviceMappingBusy */
+
+int
+XSetPointerMapping (
+ register Display *dpy,
+ _Xconst unsigned char *map,
+ int nmaps)
+ {
+ register xSetPointerMappingReq *req;
+ xSetPointerMappingReply rep;
+
+ LockDisplay(dpy);
+ GetReq (SetPointerMapping, req);
+ req->nElts = nmaps;
+ req->length += (nmaps + 3)>>2;
+ Data (dpy, (char *)map, (long) nmaps);
+ if (_XReply (dpy, (xReply *)&rep, 0, xFalse) == 0)
+ rep.success = MappingSuccess;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((int) rep.success);
+ }
+
+int
+XChangeKeyboardMapping (dpy, first_keycode, keysyms_per_keycode,
+ keysyms, nkeycodes)
+ register Display *dpy;
+ int first_keycode;
+ int keysyms_per_keycode;
+ KeySym *keysyms;
+ int nkeycodes;
+ {
+ register long nbytes;
+ register xChangeKeyboardMappingReq *req;
+
+ LockDisplay(dpy);
+ GetReq (ChangeKeyboardMapping, req);
+ req->firstKeyCode = first_keycode;
+ req->keyCodes = nkeycodes;
+ req->keySymsPerKeyCode = keysyms_per_keycode;
+ req->firstKeyCode = first_keycode;
+ req->length += nkeycodes * keysyms_per_keycode;
+ nbytes = keysyms_per_keycode * nkeycodes * 4;
+ Data32 (dpy, (long *)keysyms, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+
diff --git a/nx-X11/lib/X11/SetRGBCMap.c b/nx-X11/lib/X11/SetRGBCMap.c
new file mode 100644
index 000000000..4be840b75
--- /dev/null
+++ b/nx-X11/lib/X11/SetRGBCMap.c
@@ -0,0 +1,101 @@
+/* $Xorg: SetRGBCMap.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "Xatomtype.h"
+#include <X11/Xatom.h>
+
+void XSetRGBColormaps (dpy, w, cmaps, count, property)
+ Display *dpy;
+ Window w;
+ XStandardColormap *cmaps;
+ int count;
+ Atom property; /* XA_RGB_BEST_MAP, etc. */
+{
+ register int i; /* iterator variable */
+ register xPropStandardColormap *map; /* tmp variable, data in prop */
+ register XStandardColormap *cmap; /* tmp variable, user data */
+ xPropStandardColormap *data, tmpdata; /* scratch data */
+ int mode = PropModeReplace; /* for partial writes */
+ Bool alloced_scratch_space; /* do we need to free? */
+
+
+ if (count < 1) return;
+
+ /*
+ * if doing more than one, allocate scratch space for it
+ */
+ if ((count > 1) && ((data = ((xPropStandardColormap *)
+ Xmalloc(count*sizeof(xPropStandardColormap))))
+ != NULL)) {
+ alloced_scratch_space = True;
+ } else {
+ data = &tmpdata;
+ alloced_scratch_space = False;
+ }
+
+
+ /*
+ * Do the iteration. If using temp space put out each part of the prop;
+ * otherwise, wait until the end and blast it all at once.
+ */
+ for (i = count, map = data, cmap = cmaps; i > 0; i--, cmap++) {
+ map->colormap = cmap->colormap;
+ map->red_max = cmap->red_max;
+ map->red_mult = cmap->red_mult;
+ map->green_max = cmap->green_max;
+ map->green_mult = cmap->green_mult;
+ map->blue_max = cmap->blue_max;
+ map->blue_mult = cmap->blue_mult;
+ map->base_pixel = cmap->base_pixel;
+ map->visualid = cmap->visualid;
+ map->killid = cmap->killid;
+
+ if (alloced_scratch_space) {
+ map++;
+ } else {
+ XChangeProperty (dpy, w, property, XA_RGB_COLOR_MAP, 32, mode,
+ (unsigned char *) data,
+ NumPropStandardColormapElements);
+ mode = PropModeAppend;
+ }
+ }
+
+ if (alloced_scratch_space) {
+ XChangeProperty (dpy, w, property, XA_RGB_COLOR_MAP, 32,
+ PropModeReplace, (unsigned char *) data,
+ (int) (count * NumPropStandardColormapElements));
+ Xfree ((char *) data);
+ }
+}
diff --git a/nx-X11/lib/X11/SetSOwner.c b/nx-X11/lib/X11/SetSOwner.c
new file mode 100644
index 000000000..f692cce73
--- /dev/null
+++ b/nx-X11/lib/X11/SetSOwner.c
@@ -0,0 +1,51 @@
+/* $Xorg: SetSOwner.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetSOwner.c,v 1.3 2001/01/17 19:41:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetSelectionOwner(dpy, selection, owner, time)
+register Display *dpy;
+Atom selection;
+Window owner;
+Time time;
+{
+ register xSetSelectionOwnerReq *req;
+
+ LockDisplay(dpy);
+ GetReq(SetSelectionOwner,req);
+ req->selection = selection;
+ req->window = owner;
+ req->time = time;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetSSaver.c b/nx-X11/lib/X11/SetSSaver.c
new file mode 100644
index 000000000..43fd4dfa0
--- /dev/null
+++ b/nx-X11/lib/X11/SetSSaver.c
@@ -0,0 +1,52 @@
+/* $Xorg: SetSSaver.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetSSaver.c,v 1.3 2001/01/17 19:41:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetScreenSaver(dpy, timeout, interval, prefer_blank, allow_exp)
+ register Display *dpy;
+ int timeout, interval, prefer_blank, allow_exp;
+
+{
+ register xSetScreenSaverReq *req;
+
+ LockDisplay(dpy);
+ GetReq(SetScreenSaver, req);
+ req->timeout = timeout;
+ req->interval = interval;
+ req->preferBlank = prefer_blank;
+ req->allowExpose = allow_exp;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/SetStCmap.c b/nx-X11/lib/X11/SetStCmap.c
new file mode 100644
index 000000000..b5a93e36e
--- /dev/null
+++ b/nx-X11/lib/X11/SetStCmap.c
@@ -0,0 +1,93 @@
+/* $Xorg: SetStCmap.c,v 1.4 2001/02/09 02:03:36 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.
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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.
+ */
+
+void XSetStandardColormap(dpy, w, cmap, property)
+ Display *dpy;
+ Window w;
+ XStandardColormap *cmap;
+ Atom property; /* XA_RGB_BEST_MAP, etc. */
+{
+ Screen *sp;
+ XStandardColormap stdcmap;
+
+ sp = _XScreenOfWindow (dpy, w);
+ if (!sp) {
+ /* already caught the XGetGeometry error in _XScreenOfWindow */
+ return;
+ }
+
+ stdcmap.colormap = cmap->colormap;
+ stdcmap.red_max = cmap->red_max;
+ stdcmap.red_mult = cmap->red_mult;
+ stdcmap.green_max = cmap->green_max;
+ stdcmap.green_mult = cmap->green_mult;
+ stdcmap.blue_max = cmap->blue_max;
+ stdcmap.blue_mult = cmap->blue_mult;
+ stdcmap.base_pixel = cmap->base_pixel;
+ stdcmap.visualid = sp->root_visual->visualid;
+ stdcmap.killid = None; /* don't know how to kill this one */
+
+ XSetRGBColormaps (dpy, w, &stdcmap, 1, property);
+ return;
+}
diff --git a/nx-X11/lib/X11/SetState.c b/nx-X11/lib/X11/SetState.c
new file mode 100644
index 000000000..a13f11bfc
--- /dev/null
+++ b/nx-X11/lib/X11/SetState.c
@@ -0,0 +1,65 @@
+/* $Xorg: SetState.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetState.c,v 1.3 2001/01/17 19:41:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetState(dpy, gc, foreground, background, function, planemask)
+register Display *dpy;
+GC gc;
+int function;
+unsigned long planemask;
+unsigned long foreground, background;
+{
+ XGCValues *gv = &gc->values;
+
+ LockDisplay(dpy);
+
+ if (function != gv->function) {
+ gv->function = function;
+ gc->dirty |= GCFunction;
+ }
+ if (planemask != gv->plane_mask) {
+ gv->plane_mask = planemask;
+ gc->dirty |= GCPlaneMask;
+ }
+ if (foreground != gv->foreground) {
+ gv->foreground = foreground;
+ gc->dirty |= GCForeground;
+ }
+ if (background != gv->background) {
+ gv->background = background;
+ gc->dirty |= GCBackground;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetStip.c b/nx-X11/lib/X11/SetStip.c
new file mode 100644
index 000000000..41ebdad25
--- /dev/null
+++ b/nx-X11/lib/X11/SetStip.c
@@ -0,0 +1,48 @@
+/* $Xorg: SetStip.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetStip.c,v 1.3 2001/01/17 19:41:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetStipple (dpy, gc, stipple)
+register Display *dpy;
+GC gc;
+Pixmap stipple;
+{
+ LockDisplay(dpy);
+ /* always update, since client may have changed pixmap contents */
+ gc->values.stipple = stipple;
+ gc->dirty |= GCStipple;
+ _XFlushGCCache(dpy, gc);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetTSOrig.c b/nx-X11/lib/X11/SetTSOrig.c
new file mode 100644
index 000000000..c75707ede
--- /dev/null
+++ b/nx-X11/lib/X11/SetTSOrig.c
@@ -0,0 +1,54 @@
+/* $Xorg: SetTSOrig.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetTSOrig.c,v 1.3 2001/01/17 19:41:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetTSOrigin (dpy, gc, x, y)
+register Display *dpy;
+GC gc;
+int x, y;
+{
+ XGCValues *gv = &gc->values;
+
+ LockDisplay(dpy);
+ if (x != gv->ts_x_origin) {
+ gv->ts_x_origin = x;
+ gc->dirty |= GCTileStipXOrigin;
+ }
+ if (y != gv->ts_y_origin) {
+ gv->ts_y_origin = y;
+ gc->dirty |= GCTileStipYOrigin;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetTile.c b/nx-X11/lib/X11/SetTile.c
new file mode 100644
index 000000000..d9ca81152
--- /dev/null
+++ b/nx-X11/lib/X11/SetTile.c
@@ -0,0 +1,48 @@
+/* $Xorg: SetTile.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/SetTile.c,v 1.3 2001/01/17 19:41:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XSetTile (dpy, gc, tile)
+register Display *dpy;
+GC gc;
+Pixmap tile;
+{
+ LockDisplay(dpy);
+ /* always update, since client may have changed pixmap contents */
+ gc->values.tile = tile;
+ gc->dirty |= GCTile;
+ _XFlushGCCache(dpy, gc);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/SetTxtProp.c b/nx-X11/lib/X11/SetTxtProp.c
new file mode 100644
index 000000000..a82d9b3e3
--- /dev/null
+++ b/nx-X11/lib/X11/SetTxtProp.c
@@ -0,0 +1,94 @@
+/* $Xorg: SetTxtProp.c,v 1.4 2001/02/09 02:03:36 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 of 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <stdio.h>
+
+void XSetTextProperty (dpy, w, tp, property)
+ Display *dpy;
+ Window w;
+ Atom property;
+ XTextProperty *tp;
+{
+ XChangeProperty (dpy, w, property, tp->encoding, tp->format,
+ PropModeReplace, tp->value, tp->nitems);
+}
+
+void XSetWMName (dpy, w, tp)
+ Display *dpy;
+ Window w;
+ XTextProperty *tp;
+{
+ XSetTextProperty (dpy, w, tp, XA_WM_NAME);
+}
+
+void XSetWMIconName (dpy, w, tp)
+ Display *dpy;
+ Window w;
+ XTextProperty *tp;
+{
+ XSetTextProperty (dpy, w, tp, XA_WM_ICON_NAME);
+}
+
+void XSetWMClientMachine (dpy, w, tp)
+ Display *dpy;
+ Window w;
+ XTextProperty *tp;
+{
+ XSetTextProperty (dpy, w, tp, XA_WM_CLIENT_MACHINE);
+}
+
diff --git a/nx-X11/lib/X11/SetWMCMapW.c b/nx-X11/lib/X11/SetWMCMapW.c
new file mode 100644
index 000000000..dd88061da
--- /dev/null
+++ b/nx-X11/lib/X11/SetWMCMapW.c
@@ -0,0 +1,75 @@
+/* $Xorg: SetWMCMapW.c,v 1.4 2001/02/09 02:03:36 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.
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xatom.h>
+
+/*
+ * XSetWMProtocols sets the property
+ * WM_COLORMAP_WINDOWS type: WINDOW format:32
+ */
+
+Status XSetWMColormapWindows (dpy, w, windows, count)
+ Display *dpy;
+ Window w;
+ Window *windows;
+ int count;
+{
+ Atom prop;
+
+ prop = XInternAtom (dpy, "WM_COLORMAP_WINDOWS", False);
+ if (prop == None) return False;
+
+ XChangeProperty (dpy, w, prop, XA_WINDOW, 32,
+ PropModeReplace, (unsigned char *) windows, count);
+ return True;
+}
diff --git a/nx-X11/lib/X11/SetWMProto.c b/nx-X11/lib/X11/SetWMProto.c
new file mode 100644
index 000000000..8640e5060
--- /dev/null
+++ b/nx-X11/lib/X11/SetWMProto.c
@@ -0,0 +1,75 @@
+/* $Xorg: SetWMProto.c,v 1.4 2001/02/09 02:03:36 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.
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xatom.h>
+
+/*
+ * XSetWMProtocols sets the property
+ * WM_PROTOCOLS type: ATOM format: 32
+ */
+
+Status XSetWMProtocols (dpy, w, protocols, count)
+ Display *dpy;
+ Window w;
+ Atom *protocols;
+ int count;
+{
+ Atom prop;
+
+ prop = XInternAtom (dpy, "WM_PROTOCOLS", False);
+ if (prop == None) return False;
+
+ XChangeProperty (dpy, w, prop, XA_ATOM, 32,
+ PropModeReplace, (unsigned char *) protocols, count);
+ return True;
+}
diff --git a/nx-X11/lib/X11/StBytes.c b/nx-X11/lib/X11/StBytes.c
new file mode 100644
index 000000000..b23902581
--- /dev/null
+++ b/nx-X11/lib/X11/StBytes.c
@@ -0,0 +1,106 @@
+/* $Xorg: StBytes.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/StBytes.c,v 1.4 2001/12/14 19:54:07 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+
+/* insulate predefined atom numbers from cut routines */
+static Atom n_to_atom[8] = {
+ XA_CUT_BUFFER0,
+ XA_CUT_BUFFER1,
+ XA_CUT_BUFFER2,
+ XA_CUT_BUFFER3,
+ XA_CUT_BUFFER4,
+ XA_CUT_BUFFER5,
+ XA_CUT_BUFFER6,
+ XA_CUT_BUFFER7};
+
+int
+XRotateBuffers (dpy, rotate)
+ register Display *dpy;
+ int rotate;
+{
+ return XRotateWindowProperties(dpy, RootWindow(dpy, 0), n_to_atom, 8, rotate);
+}
+
+char *XFetchBuffer (dpy, nbytes, buffer)
+ register Display *dpy;
+ int *nbytes;
+ register int buffer;
+{
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long leftover;
+ unsigned char *data;
+ *nbytes = 0;
+ if ((buffer < 0) || (buffer > 7)) return (NULL);
+/* XXX should be (sizeof (maxint) - 1)/4 */
+ if (XGetWindowProperty(dpy, RootWindow(dpy, 0), n_to_atom[buffer],
+ 0L, 10000000L, False, XA_STRING,
+ &actual_type, &actual_format, &nitems, &leftover, &data) != Success) {
+ return (NULL);
+ }
+ if ( (actual_type == XA_STRING) && (actual_format != 32) ) {
+ *nbytes = nitems;
+ return((char *)data);
+ }
+ if ((char *) data != NULL) Xfree ((char *)data);
+ return(NULL);
+}
+
+char *XFetchBytes (dpy, nbytes)
+ register Display *dpy;
+ int *nbytes;
+{
+ return (XFetchBuffer (dpy, nbytes, 0));
+}
+
+int
+XStoreBuffer (
+ register Display *dpy,
+ _Xconst char *bytes,
+ int nbytes,
+ register int buffer)
+{
+ if ((buffer < 0) || (buffer > 7)) return 0;
+ return XChangeProperty(dpy, RootWindow(dpy, 0), n_to_atom[buffer],
+ XA_STRING, 8, PropModeReplace, (unsigned char *) bytes, nbytes);
+}
+
+int
+XStoreBytes (
+ register Display *dpy,
+ _Xconst char *bytes,
+ int nbytes)
+{
+ return XStoreBuffer (dpy, bytes, nbytes, 0);
+}
diff --git a/nx-X11/lib/X11/StCol.c b/nx-X11/lib/X11/StCol.c
new file mode 100644
index 000000000..80c3f7d96
--- /dev/null
+++ b/nx-X11/lib/X11/StCol.c
@@ -0,0 +1,84 @@
+/* $Xorg: StCol.c,v 1.3 2000/08/17 19:44:55 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsStCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsStoreColor
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/StCol.c,v 1.3 2001/01/17 19:41:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsStoreColor - Store Color
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsStoreColor(dpy, colormap, pColor_in)
+ Display *dpy;
+ Colormap colormap;
+ XcmsColor *pColor_in;
+/*
+ * DESCRIPTION
+ * Given a device-dependent or device-independent color
+ * specification, this routine will convert it to X RGB
+ * values then use it in a call to XStoreColor.
+ *
+ * RETURNS
+ * XcmsFailure if failed;
+ * XcmsSuccess if it succeeded without gamut compression;
+ * XcmsSuccessWithCompression if it succeeded with gamut
+ * compression;
+ *
+ * Since XStoreColor has no return value this routine
+ * does not return the color specification of the color actually
+ * stored.
+ */
+{
+ XcmsColor tmpColor;
+
+ tmpColor = *pColor_in;
+ return(_XcmsSetGetColor(XStoreColor, dpy, colormap,
+ &tmpColor, XcmsRGBFormat, (Bool *) NULL));
+}
diff --git a/nx-X11/lib/X11/StColor.c b/nx-X11/lib/X11/StColor.c
new file mode 100644
index 000000000..b2b197a99
--- /dev/null
+++ b/nx-X11/lib/X11/StColor.c
@@ -0,0 +1,72 @@
+/* $Xorg: StColor.c,v 1.4 2001/02/09 02:03:36 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.
+
+*/
+/* $XFree86: xc/lib/X11/StColor.c,v 1.3 2001/01/17 19:41:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XStoreColor(dpy, cmap, def)
+register Display *dpy;
+Colormap cmap;
+XColor *def;
+{
+ xColorItem *citem;
+ register xStoreColorsReq *req;
+#ifdef MUSTCOPY
+ xColorItem citemdata;
+ long len = SIZEOF(xColorItem);
+
+ citem = &citemdata;
+#endif /* MUSTCOPY */
+
+ LockDisplay(dpy);
+ GetReqExtra(StoreColors, SIZEOF(xColorItem), req); /* assume size is 4*n */
+
+ req->cmap = cmap;
+
+#ifndef MUSTCOPY
+ citem = (xColorItem *) NEXTPTR(req,xStoreColorsReq);
+#endif /* not MUSTCOPY */
+
+ citem->pixel = def->pixel;
+ citem->red = def->red;
+ citem->green = def->green;
+ citem->blue = def->blue;
+ citem->flags = def->flags; /* do_red, do_green, do_blue */
+
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xColorItem); /* adjust for GetReqExtra */
+ Data (dpy, (char *) citem, len);
+#endif /* MUSTCOPY */
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/StColors.c b/nx-X11/lib/X11/StColors.c
new file mode 100644
index 000000000..16d634bfe
--- /dev/null
+++ b/nx-X11/lib/X11/StColors.c
@@ -0,0 +1,67 @@
+/* $Xorg: StColors.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/StColors.c,v 1.3 2001/01/17 19:41:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XStoreColors(dpy, cmap, defs, ncolors)
+register Display *dpy;
+Colormap cmap;
+XColor *defs;
+int ncolors;
+{
+ register int i;
+ xColorItem citem;
+ register xStoreColorsReq *req;
+
+ LockDisplay(dpy);
+ GetReq(StoreColors, req);
+
+ req->cmap = cmap;
+
+ req->length += (ncolors * SIZEOF(xColorItem)) >> 2; /* assume size is 4*n */
+
+ for (i = 0; i < ncolors; i++) {
+ citem.pixel = defs[i].pixel;
+ citem.red = defs[i].red;
+ citem.green = defs[i].green;
+ citem.blue = defs[i].blue;
+ citem.flags = defs[i].flags;
+
+ /* note that xColorItem doesn't contain all 16-bit quantities, so
+ we can't use Data16 */
+ Data(dpy, (char *)&citem, (long) SIZEOF(xColorItem));
+ /* assume size is 4*n */
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/StCols.c b/nx-X11/lib/X11/StCols.c
new file mode 100644
index 000000000..cff6cc344
--- /dev/null
+++ b/nx-X11/lib/X11/StCols.c
@@ -0,0 +1,115 @@
+/* $Xorg: StCols.c,v 1.3 2000/08/17 19:44:56 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsStCols.c
+ *
+ * DESCRIPTION
+ * Source for XcmsStoreColors
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/StCols.c,v 1.3 2001/01/17 19:41:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsStoreColors - Store Colors
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsStoreColors(dpy, colormap, pColors_in,
+ nColors, pCompressed)
+ Display *dpy;
+ Colormap colormap;
+ XcmsColor *pColors_in;
+ unsigned int nColors;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Given device-dependent or device-independent color
+ * specifications, this routine will convert them to X RGB
+ * values then use it in a call to XStoreColors.
+ *
+ * RETURNS
+ * XcmsFailure if failed;
+ * XcmsSuccess if it succeeded without gamut compression;
+ * XcmsSuccessWithCompression if it succeeded with gamut
+ * compression;
+ *
+ * Since XStoreColors has no return value, this routine
+ * does not return color specifications of the colors actually
+ * stored.
+ */
+{
+ XcmsColor Color1;
+ XcmsColor *pColors_tmp;
+ Status retval;
+
+ /*
+ * Make copy of array of color specifications so we don't
+ * overwrite the contents.
+ */
+ if (nColors > 1) {
+ pColors_tmp = (XcmsColor *) Xmalloc(nColors * sizeof(XcmsColor));
+ } else {
+ pColors_tmp = &Color1;
+ }
+ memcpy((char *)pColors_tmp, (char *)pColors_in,
+ nColors * sizeof(XcmsColor));
+
+ /*
+ * Call routine to store colors using the copied color structures
+ */
+ retval = _XcmsSetGetColors (XStoreColors, dpy, colormap,
+ pColors_tmp, nColors, XcmsRGBFormat, pCompressed);
+
+ /*
+ * Free copies as needed.
+ */
+ if (nColors > 1) {
+ Xfree((char *)pColors_tmp);
+ }
+
+ /*
+ * Ah, finally return.
+ */
+ return(retval);
+}
diff --git a/nx-X11/lib/X11/StNColor.c b/nx-X11/lib/X11/StNColor.c
new file mode 100644
index 000000000..f7dbcb065
--- /dev/null
+++ b/nx-X11/lib/X11/StNColor.c
@@ -0,0 +1,87 @@
+/* $Xorg: StNColor.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/StNColor.c,v 1.5 2003/04/13 19:22:18 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+int
+XStoreNamedColor(
+register Display *dpy,
+Colormap cmap,
+_Xconst char *name, /* STRING8 */
+unsigned long pixel, /* CARD32 */
+int flags) /* DoRed, DoGreen, DoBlue */
+{
+ unsigned int nbytes;
+ register xStoreNamedColorReq *req;
+ XcmsCCC ccc;
+ XcmsColor cmsColor_exact;
+ XColor scr_def;
+
+ /*
+ * Let's Attempt to use Xcms approach to Parse Color
+ */
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
+ if (_XcmsResolveColorString(ccc, &name, &cmsColor_exact,
+ XcmsRGBFormat) >= XcmsSuccess) {
+ _XcmsRGB_to_XColor(&cmsColor_exact, &scr_def, 1);
+ scr_def.pixel = pixel;
+ scr_def.flags = flags;
+ return XStoreColor(dpy, cmap, &scr_def);
+ }
+ /*
+ * Otherwise we failed; or name was changed with yet another
+ * name. Thus pass name to the X Server.
+ */
+ }
+
+ /*
+ * The Xcms and i18n methods failed, so lets pass it to the server
+ * for parsing.
+ */
+
+ LockDisplay(dpy);
+ GetReq(StoreNamedColor, req);
+
+ req->cmap = cmap;
+ req->flags = flags;
+ req->pixel = pixel;
+ req->nbytes = nbytes = strlen(name);
+ req->length += (nbytes + 3) >> 2; /* round up to multiple of 4 */
+ Data(dpy, name, (long)nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
+
diff --git a/nx-X11/lib/X11/StName.c b/nx-X11/lib/X11/StName.c
new file mode 100644
index 000000000..ba01ffb0c
--- /dev/null
+++ b/nx-X11/lib/X11/StName.c
@@ -0,0 +1,55 @@
+/* $Xorg: StName.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/StName.c,v 1.4 2001/12/14 19:54:07 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+
+int
+XStoreName (
+ register Display *dpy,
+ Window w,
+ _Xconst char *name)
+{
+ return XChangeProperty(dpy, w, XA_WM_NAME, XA_STRING,
+ 8, PropModeReplace, (unsigned char *)name,
+ name ? strlen(name) : 0);
+}
+
+int
+XSetIconName (
+ register Display *dpy,
+ Window w,
+ _Xconst char *icon_name)
+{
+ return XChangeProperty(dpy, w, XA_WM_ICON_NAME, XA_STRING,
+ 8, PropModeReplace, (unsigned char *)icon_name,
+ icon_name ? strlen(icon_name) : 0);
+}
diff --git a/nx-X11/lib/X11/StrKeysym.c b/nx-X11/lib/X11/StrKeysym.c
new file mode 100644
index 000000000..74ccecbcd
--- /dev/null
+++ b/nx-X11/lib/X11/StrKeysym.c
@@ -0,0 +1,158 @@
+/* $Xorg: StrKeysym.c,v 1.5 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 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.
+
+*/
+/* $XFree86: xc/lib/X11/StrKeysym.c,v 3.7 2003/04/13 19:22:18 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xresource.h>
+#include <X11/keysymdef.h>
+#include "Xresinternal.h"
+
+#define NEEDKTABLE
+#include "ks_tables.h"
+#include "Key.h"
+
+#ifndef KEYSYMDB
+#ifndef XKEYSYMDB
+#define KEYSYMDB "/usr/lib/X11/XKeysymDB"
+#else
+#define KEYSYMDB XKEYSYMDB
+#endif
+#endif
+
+static Bool initialized;
+static XrmDatabase keysymdb;
+static XrmQuark Qkeysym[2];
+
+XrmDatabase
+_XInitKeysymDB(void)
+{
+ if (!initialized)
+ {
+ char *dbname;
+
+ XrmInitialize();
+ /* use and name of this env var is not part of the standard */
+ /* implementation-dependent feature */
+ dbname = getenv("XKEYSYMDB");
+ if (!dbname)
+ dbname = KEYSYMDB;
+ keysymdb = XrmGetFileDatabase(dbname);
+ if (keysymdb)
+ Qkeysym[0] = XrmStringToQuark("Keysym");
+ initialized = True;
+ }
+ return keysymdb;
+}
+
+KeySym
+XStringToKeysym(_Xconst char *s)
+{
+ register int i, n;
+ int h;
+ register Signature sig = 0;
+ register const char *p = s;
+ register int c;
+ register int idx;
+ const unsigned char *entry;
+ unsigned char sig1, sig2;
+ KeySym val;
+
+ while ((c = *p++))
+ sig = (sig << 1) + c;
+ i = sig % KTABLESIZE;
+ h = i + 1;
+ sig1 = (sig >> 8) & 0xff;
+ sig2 = sig & 0xff;
+ n = KMAXHASH;
+ while ((idx = hashString[i]))
+ {
+ entry = &_XkeyTable[idx];
+ if ((entry[0] == sig1) && (entry[1] == sig2) &&
+ !strcmp(s, (char *)entry + 6))
+ {
+ val = (entry[2] << 24) | (entry[3] << 16) |
+ (entry[4] << 8) | entry[5];
+ if (!val)
+ val = XK_VoidSymbol;
+ return val;
+ }
+ if (!--n)
+ break;
+ i += h;
+ if (i >= KTABLESIZE)
+ i -= KTABLESIZE;
+ }
+
+ if (!initialized)
+ (void)_XInitKeysymDB();
+ if (keysymdb)
+ {
+ XrmValue result;
+ XrmRepresentation from_type;
+ char c;
+ XrmQuark names[2];
+
+ names[0] = _XrmInternalStringToQuark(s, p - s - 1, sig, False);
+ names[1] = NULLQUARK;
+ (void)XrmQGetResource(keysymdb, names, Qkeysym, &from_type, &result);
+ if (result.addr && (result.size > 1))
+ {
+ val = 0;
+ for (i = 0; i < result.size - 1; i++)
+ {
+ c = ((char *)result.addr)[i];
+ if ('0' <= c && c <= '9') val = (val<<4)+c-'0';
+ else if ('a' <= c && c <= 'f') val = (val<<4)+c-'a'+10;
+ else if ('A' <= c && c <= 'F') val = (val<<4)+c-'A'+10;
+ else return NoSymbol;
+ }
+ return val;
+ }
+ }
+
+ if (*s == 'U') {
+ val = 0;
+ for (p = &s[1]; *p; p++) {
+ c = *p;
+ if ('0' <= c && c <= '9') val = (val<<4)+c-'0';
+ else if ('a' <= c && c <= 'f') val = (val<<4)+c-'a'+10;
+ else if ('A' <= c && c <= 'F') val = (val<<4)+c-'A'+10;
+ else return NoSymbol;
+ if (val > 0x10ffff)
+ return NoSymbol;
+ }
+ if (val < 0x20 || (val > 0x7e && val < 0xa0))
+ return NoSymbol;
+ if (val < 0x100)
+ return val;
+ return val | 0x01000000;
+ }
+ return NoSymbol;
+}
diff --git a/nx-X11/lib/X11/StrToText.c b/nx-X11/lib/X11/StrToText.c
new file mode 100644
index 000000000..ba894e16f
--- /dev/null
+++ b/nx-X11/lib/X11/StrToText.c
@@ -0,0 +1,91 @@
+/* $Xorg: StrToText.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+
+/*
+ * XStringListToTextProperty - fill in TextProperty structure with
+ * concatenated list of null-separated strings. Return True if successful
+ * else False. Allocate room on end for trailing NULL, but don't include in
+ * count.
+ */
+
+Status XStringListToTextProperty (argv, argc, textprop)
+ char **argv;
+ int argc;
+ XTextProperty *textprop;
+{
+ register int i;
+ register unsigned int nbytes;
+ XTextProperty proto;
+
+ /* figure out how much space we'll need for this list */
+ for (i = 0, nbytes = 0; i < argc; i++) {
+ nbytes += (unsigned) ((argv[i] ? strlen (argv[i]) : 0) + 1);
+ }
+
+ /* fill in a prototype containing results so far */
+ proto.encoding = XA_STRING;
+ proto.format = 8;
+ if (nbytes)
+ proto.nitems = nbytes - 1; /* subtract one for trailing <NUL> */
+ else
+ proto.nitems = 0;
+ proto.value = NULL;
+
+ /* build concatenated list of strings */
+ if (nbytes > 0) {
+ register char *buf = Xmalloc (nbytes);
+ if (!buf) return False;
+
+ proto.value = (unsigned char *) buf;
+ for (i = 0; i < argc; i++) {
+ char *arg = argv[i];
+
+ if (arg) {
+ (void) strcpy (buf, arg);
+ buf += (strlen (arg) + 1);
+ } else {
+ *buf++ = '\0';
+ }
+ }
+ } else {
+ proto.value = (unsigned char *) Xmalloc (1); /* easier for client */
+ if (!proto.value) return False;
+
+ proto.value[0] = '\0';
+ }
+
+ /* we were successful, so set return value */
+ *textprop = proto;
+ return True;
+}
diff --git a/nx-X11/lib/X11/Sync.c b/nx-X11/lib/X11/Sync.c
new file mode 100644
index 000000000..6e9f300d8
--- /dev/null
+++ b/nx-X11/lib/X11/Sync.c
@@ -0,0 +1,64 @@
+/* $Xorg: Sync.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/Sync.c,v 1.3 2001/01/17 19:41:44 dawes Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+/* Synchronize with errors and events, optionally discarding pending events */
+
+int
+XSync (dpy, discard)
+ register Display *dpy;
+ Bool discard;
+{
+ xGetInputFocusReply rep;
+ register xReq *req;
+
+ LockDisplay(dpy);
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+
+ if (discard && dpy->head) {
+ _XQEvent *qelt;
+
+ for (qelt=dpy->head; qelt; qelt=qelt->next)
+ qelt->qserial_num = 0;
+
+ ((_XQEvent *)dpy->tail)->next = dpy->qfree;
+ dpy->qfree = (_XQEvent *)dpy->head;
+ dpy->head = dpy->tail = NULL;
+ dpy->qlen = 0;
+ }
+ UnlockDisplay(dpy);
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/Synchro.c b/nx-X11/lib/X11/Synchro.c
new file mode 100644
index 000000000..2688e79cc
--- /dev/null
+++ b/nx-X11/lib/X11/Synchro.c
@@ -0,0 +1,81 @@
+/* $Xorg: Synchro.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/Synchro.c,v 1.3 2003/04/13 19:22:18 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+
+static int _XSyncFunction(register Display *dpy)
+{
+ XSync(dpy,0);
+ return 0;
+}
+
+int (*XSynchronize(Display *dpy, int onoff))(Display *)
+{
+ int (*temp)(Display *);
+ int (*func)(Display *) = NULL;
+
+ if (onoff)
+ func = _XSyncFunction;
+
+ LockDisplay(dpy);
+ if (dpy->flags & XlibDisplayPrivSync) {
+ temp = dpy->savedsynchandler;
+ dpy->savedsynchandler = func;
+ } else {
+ temp = dpy->synchandler;
+ dpy->synchandler = func;
+ }
+ UnlockDisplay(dpy);
+ return (temp);
+}
+
+int (*XSetAfterFunction(
+ Display *dpy,
+ int (*func)(
+ Display*
+ )
+ ))(Display *)
+{
+ int (*temp)(Display *);
+
+ LockDisplay(dpy);
+ if (dpy->flags & XlibDisplayPrivSync) {
+ temp = dpy->savedsynchandler;
+ dpy->savedsynchandler = func;
+ } else {
+ temp = dpy->synchandler;
+ dpy->synchandler = func;
+ }
+ UnlockDisplay(dpy);
+ return (temp);
+}
+
diff --git a/nx-X11/lib/X11/Text.c b/nx-X11/lib/X11/Text.c
new file mode 100644
index 000000000..95ad0d9df
--- /dev/null
+++ b/nx-X11/lib/X11/Text.c
@@ -0,0 +1,141 @@
+/* $Xorg: Text.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/Text.c,v 1.4 2001/12/14 19:54:07 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XDrawString(
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ int x,
+ int y,
+ _Xconst char *string,
+ int length)
+{
+ int Datalength = 0;
+ register xPolyText8Req *req;
+
+ if (length <= 0)
+ return 0;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq (PolyText8, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->x = x;
+ req->y = y;
+
+
+ Datalength += SIZEOF(xTextElt) * ((length + 253) / 254) + length;
+
+
+ req->length += (Datalength + 3)>>2; /* convert to number of 32-bit words */
+
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first. If the request does fit into the
+ * empty buffer, then we won't have to flush it at the end to keep
+ * the buffer 32-bit aligned.
+ */
+
+ if (dpy->bufptr + Datalength > dpy->bufmax)
+ _XFlush (dpy);
+
+ {
+ int nbytes;
+ int PartialNChars = length;
+ /* register xTextElt *elt; */
+ char *CharacterOffset = (char *)string;
+ unsigned char *tbuf;
+
+ while(PartialNChars > 254)
+ {
+ nbytes = 254 + SIZEOF(xTextElt);
+ BufAlloc (unsigned char *, tbuf, nbytes);
+/* elt->delta = 0;
+ * elt->len = 254;
+ */
+ *(unsigned char *)tbuf = 254;
+ *(tbuf+1) = 0;
+/* memcpy ((char *) (elt + 1), CharacterOffset, 254);
+ */
+ memcpy ((char *)tbuf+2, CharacterOffset, 254);
+ PartialNChars = PartialNChars - 254;
+ CharacterOffset += 254;
+ }
+
+ if (PartialNChars)
+ {
+ nbytes = PartialNChars + SIZEOF(xTextElt);
+ BufAlloc (unsigned char *, tbuf, nbytes);
+/* elt->delta = 0;
+ * elt->len = PartialNChars;
+ */
+ *(unsigned char *)tbuf = PartialNChars;
+ *(tbuf+1) = 0;
+/* memcpy ((char *) (elt + 1), CharacterOffset, PartialNChars);
+ */
+ memcpy ((char *)tbuf+2, CharacterOffset, PartialNChars);
+ }
+ }
+
+ /* Pad request out to a 32-bit boundary */
+
+ if (Datalength &= 3) {
+ char *pad;
+ /*
+ * BufAlloc is a macro that uses its last argument more than
+ * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)"
+ */
+ length = 4 - Datalength;
+ BufAlloc (char *, pad, length);
+ /*
+ * if there are 3 bytes of padding, the first byte MUST be 0
+ * so the pad bytes aren't mistaken for a final xTextElt
+ */
+ *pad = 0;
+ }
+
+ /*
+ * If the buffer pointer is not now pointing to a 32-bit boundary,
+ * we must flush the buffer so that it does point to a 32-bit boundary
+ * at the end of this routine.
+ */
+
+ if ((dpy->bufptr - dpy->buffer) & 3)
+ _XFlush (dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
diff --git a/nx-X11/lib/X11/Text16.c b/nx-X11/lib/X11/Text16.c
new file mode 100644
index 000000000..96d5911d6
--- /dev/null
+++ b/nx-X11/lib/X11/Text16.c
@@ -0,0 +1,154 @@
+/* $Xorg: Text16.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/Text16.c,v 1.5 2001/12/14 19:54:07 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XDrawString16(
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ int x,
+ int y,
+ _Xconst XChar2b *string,
+ int length)
+{
+ int Datalength = 0;
+ register xPolyText16Req *req;
+
+ if (length <= 0)
+ return 0;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq (PolyText16, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->x = x;
+ req->y = y;
+
+
+ Datalength += SIZEOF(xTextElt) * ((length + 253) / 254) + (length << 1);
+
+
+ req->length += (Datalength + 3)>>2; /* convert to number of 32-bit words */
+
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first. If the request does fit into the
+ * empty buffer, then we won't have to flush it at the end to keep
+ * the buffer 32-bit aligned.
+ */
+
+ if (dpy->bufptr + Datalength > dpy->bufmax)
+ _XFlush (dpy);
+
+ {
+ int nbytes;
+ int PartialNChars = length;
+ register xTextElt *elt;
+ XChar2b *CharacterOffset = (XChar2b *)string;
+
+ while(PartialNChars > 254)
+ {
+ nbytes = 254 * 2 + SIZEOF(xTextElt);
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->delta = 0;
+ elt->len = 254;
+#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
+ {
+ register int i;
+ register unsigned char *cp;
+ for (i = 0, cp = ((unsigned char *)elt) + 2; i < 254; i++) {
+ *cp++ = CharacterOffset[i].byte1;
+ *cp++ = CharacterOffset[i].byte2;
+ }
+ }
+#else
+ memcpy (((char *) elt) + 2, (char *)CharacterOffset, 254 * 2);
+#endif
+ PartialNChars = PartialNChars - 254;
+ CharacterOffset += 254;
+ }
+
+ if (PartialNChars)
+ {
+ nbytes = PartialNChars * 2 + SIZEOF(xTextElt);
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->delta = 0;
+ elt->len = PartialNChars;
+#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
+ {
+ register int i;
+ register unsigned char *cp;
+ for (i = 0, cp = ((unsigned char *)elt) + 2; i < PartialNChars;
+ i++) {
+ *cp++ = CharacterOffset[i].byte1;
+ *cp++ = CharacterOffset[i].byte2;
+ }
+ }
+#else
+ memcpy(((char *)elt) + 2, (char *)CharacterOffset, PartialNChars * 2);
+#endif
+ }
+ }
+
+ /* Pad request out to a 32-bit boundary */
+
+ if (Datalength &= 3) {
+ char *pad;
+ /*
+ * BufAlloc is a macro that uses its last argument more than
+ * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)"
+ */
+ length = 4 - Datalength;
+ BufAlloc (char *, pad, length);
+ /*
+ * if there are 3 bytes of padding, the first byte MUST be 0
+ * so the pad bytes aren't mistaken for a final xTextElt
+ */
+ *pad = 0;
+ }
+
+ /*
+ * If the buffer pointer is not now pointing to a 32-bit boundary,
+ * we must flush the buffer so that it does point to a 32-bit boundary
+ * at the end of this routine.
+ */
+
+ if ((dpy->bufptr - dpy->buffer) & 3)
+ _XFlush (dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
diff --git a/nx-X11/lib/X11/TextExt.c b/nx-X11/lib/X11/TextExt.c
new file mode 100644
index 000000000..fc703011f
--- /dev/null
+++ b/nx-X11/lib/X11/TextExt.c
@@ -0,0 +1,236 @@
+/* $Xorg: TextExt.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/TextExt.c,v 1.4 2001/12/14 19:54:07 dawes Exp $ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+#define min_byte2 min_char_or_byte2
+#define max_byte2 max_char_or_byte2
+
+
+/*
+ * CI_GET_ROWZERO_CHAR_INFO_2D - do the same thing as CI_GET_CHAR_INFO_1D,
+ * except that the font has more than one row. This is special case of more
+ * general version used in XTextExt16.c since row == 0. This is used when
+ * max_byte2 is not zero. A further optimization would do the check for
+ * min_byte1 being zero ahead of time.
+ */
+
+#define CI_GET_ROWZERO_CHAR_INFO_2D(fs,col,def,cs) \
+{ \
+ cs = def; \
+ if (fs->min_byte1 == 0 && \
+ col >= fs->min_byte2 && col <= fs->max_byte2) { \
+ if (fs->per_char == NULL) { \
+ cs = &fs->min_bounds; \
+ } else { \
+ cs = &fs->per_char[(col - fs->min_byte2)]; \
+ if (CI_NONEXISTCHAR(cs)) cs = def; \
+ } \
+ } \
+}
+
+
+/*
+ * XTextExtents - compute the extents of string given as a sequences of eight
+ * bit bytes. Since we know that the input characters will always be from the
+ * first row of the font (i.e. byte1 == 0), we can do some optimizations beyond
+ * what is done in XTextExtents16.
+ */
+int
+XTextExtents (
+ XFontStruct *fs,
+ _Xconst char *string,
+ int nchars,
+ int *dir, /* RETURN font information */
+ int *font_ascent, /* RETURN font information */
+ int *font_descent, /* RETURN font information */
+ register XCharStruct *overall) /* RETURN character information */
+{
+ int i; /* iterator */
+ Bool singlerow = (fs->max_byte1 == 0); /* optimization */
+ int nfound = 0; /* number of characters found */
+ XCharStruct *def; /* info about default char */
+ unsigned char *us; /* be 8bit clean */
+
+ if (singlerow) { /* optimization */
+ CI_GET_DEFAULT_INFO_1D (fs, def);
+ } else {
+ CI_GET_DEFAULT_INFO_2D (fs, def);
+ }
+
+ *dir = fs->direction;
+ *font_ascent = fs->ascent;
+ *font_descent = fs->descent;
+
+ /*
+ * Iterate over the input string getting the appropriate * char struct.
+ * The default (which may be null if there is no def_char) will be returned
+ * if the character doesn't exist. On the first time * through the loop,
+ * assign the values to overall; otherwise, compute * the new values.
+ */
+
+ for (i = 0, us = (unsigned char *) string; i < nchars; i++, us++) {
+ register unsigned uc = (unsigned) *us; /* since about to do macro */
+ register XCharStruct *cs;
+
+ if (singlerow) { /* optimization */
+ CI_GET_CHAR_INFO_1D (fs, uc, def, cs);
+ } else {
+ CI_GET_ROWZERO_CHAR_INFO_2D (fs, uc, def, cs);
+ }
+
+ if (cs) {
+ if (nfound++ == 0) {
+ *overall = *cs;
+ } else {
+ overall->ascent = max (overall->ascent, cs->ascent);
+ overall->descent = max (overall->descent, cs->descent);
+ overall->lbearing = min (overall->lbearing,
+ overall->width + cs->lbearing);
+ overall->rbearing = max (overall->rbearing,
+ overall->width + cs->rbearing);
+ overall->width += cs->width;
+ }
+ }
+ }
+
+ /*
+ * if there were no characters, then set everything to 0
+ */
+ if (nfound == 0) {
+ overall->width = overall->ascent = overall->descent =
+ overall->lbearing = overall->rbearing = 0;
+ }
+
+ return 0;
+}
+
+
+/*
+ * XTextWidth - compute the width of a string of eightbit bytes. This is a
+ * subset of XTextExtents.
+ */
+int
+XTextWidth (
+ XFontStruct *fs,
+ _Xconst char *string,
+ int count)
+{
+ int i; /* iterator */
+ Bool singlerow = (fs->max_byte1 == 0); /* optimization */
+ XCharStruct *def; /* info about default char */
+ unsigned char *us; /* be 8bit clean */
+ int width = 0; /* RETURN value */
+
+ if (singlerow) { /* optimization */
+ CI_GET_DEFAULT_INFO_1D (fs, def);
+ } else {
+ CI_GET_DEFAULT_INFO_2D (fs, def);
+ }
+
+ if (def && fs->min_bounds.width == fs->max_bounds.width)
+ return (fs->min_bounds.width * count);
+
+ /*
+ * Iterate over all character in the input string; only consider characters
+ * that exist.
+ */
+ for (i = 0, us = (unsigned char *) string; i < count; i++, us++) {
+ register unsigned uc = (unsigned) *us; /* since about to do macro */
+ register XCharStruct *cs;
+
+ if (singlerow) { /* optimization */
+ CI_GET_CHAR_INFO_1D (fs, uc, def, cs);
+ } else {
+ CI_GET_ROWZERO_CHAR_INFO_2D (fs, uc, def, cs);
+ }
+
+ if (cs) width += cs->width;
+ }
+
+ return width;
+}
+
+
+
+/*
+ * _XTextHeight - compute the height of a string of eightbit bytes.
+ */
+int
+_XTextHeight (
+ XFontStruct *fs,
+ _Xconst char *string,
+ int count)
+{
+ int i; /* iterator */
+ Bool singlerow = (fs->max_byte1 == 0); /* optimization */
+ XCharStruct *def; /* info about default char */
+ unsigned char *us; /* be 8bit clean */
+ int height = 0; /* RETURN value */
+
+ if (singlerow) { /* optimization */
+ CI_GET_DEFAULT_INFO_1D (fs, def);
+ } else {
+ CI_GET_DEFAULT_INFO_2D (fs, def);
+ }
+
+ if (def && (fs->min_bounds.ascent == fs->max_bounds.ascent)
+ && (fs->min_bounds.descent == fs->max_bounds.descent))
+ return ((fs->min_bounds.ascent + fs->min_bounds.descent) * count);
+
+ /*
+ * Iterate over all character in the input string; only consider characters
+ * that exist.
+ */
+ for (i = 0, us = (unsigned char *) string; i < count; i++, us++) {
+ register unsigned uc = (unsigned) *us; /* since about to do macro */
+ register XCharStruct *cs;
+
+ if (singlerow) { /* optimization */
+ CI_GET_CHAR_INFO_1D (fs, uc, def, cs);
+ } else {
+ CI_GET_ROWZERO_CHAR_INFO_2D (fs, uc, def, cs);
+ }
+
+ if (cs) height += (cs->ascent + cs->descent);
+ }
+
+ return height;
+}
+
diff --git a/nx-X11/lib/X11/TextExt16.c b/nx-X11/lib/X11/TextExt16.c
new file mode 100644
index 000000000..763350a10
--- /dev/null
+++ b/nx-X11/lib/X11/TextExt16.c
@@ -0,0 +1,212 @@
+/* $Xorg: TextExt16.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/TextExt16.c,v 1.4 2001/12/14 19:54:07 dawes Exp $ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+#define min_byte2 min_char_or_byte2
+#define max_byte2 max_char_or_byte2
+
+/*
+ * XTextExtents16 - compute the extents of string given as a sequence of
+ * XChar2bs.
+ */
+int
+XTextExtents16 (
+ XFontStruct *fs,
+ _Xconst XChar2b *string,
+ int nchars,
+ int *dir, /* RETURN font information */
+ int *font_ascent, /* RETURN font information */
+ int *font_descent, /* RETURN font information */
+ register XCharStruct *overall) /* RETURN character information */
+{
+ int i; /* iterator */
+ Bool singlerow = (fs->max_byte1 == 0); /* optimization */
+ int nfound = 0; /* number of characters found */
+ XCharStruct *def; /* info about default char */
+
+ if (singlerow) {
+ CI_GET_DEFAULT_INFO_1D (fs, def);
+ } else {
+ CI_GET_DEFAULT_INFO_2D (fs, def);
+ }
+
+ *dir = fs->direction;
+ *font_ascent = fs->ascent;
+ *font_descent = fs->descent;
+
+ /*
+ * Iterate over the input string getting the appropriate * char struct.
+ * The default (which may be null if there is no def_char) will be returned
+ * if the character doesn't exist. On the first time * through the loop,
+ * assign the values to overall; otherwise, compute * the new values.
+ */
+
+ for (i = 0; i < nchars; i++, string++) {
+ register XCharStruct *cs;
+ unsigned int r = (unsigned int) string->byte1; /* watch for macros */
+ unsigned int c = (unsigned int) string->byte2; /* watch for macros */
+
+ if (singlerow) {
+ unsigned int ind = ((r << 8) | c); /* watch for macros */
+ CI_GET_CHAR_INFO_1D (fs, ind, def, cs);
+ } else {
+ CI_GET_CHAR_INFO_2D (fs, r, c, def, cs);
+ }
+
+ if (cs) {
+ if (nfound++ == 0) {
+ *overall = *cs;
+ } else {
+ overall->ascent = max (overall->ascent, cs->ascent);
+ overall->descent = max (overall->descent, cs->descent);
+ overall->lbearing = min (overall->lbearing,
+ overall->width + cs->lbearing);
+ overall->rbearing = max (overall->rbearing,
+ overall->width + cs->rbearing);
+ overall->width += cs->width;
+ }
+ }
+ }
+
+ /*
+ * if there were no characters, then set everything to 0
+ */
+ if (nfound == 0) {
+ overall->width = overall->ascent = overall->descent =
+ overall->lbearing = overall->rbearing = 0;
+ }
+
+ return 0;
+}
+
+
+/*
+ * XTextWidth16 - compute the width of sequence of XChar2bs. This is a
+ * subset of XTextExtents16.
+ */
+int
+XTextWidth16 (
+ XFontStruct *fs,
+ _Xconst XChar2b *string,
+ int count)
+{
+ int i; /* iterator */
+ Bool singlerow = (fs->max_byte1 == 0); /* optimization */
+ XCharStruct *def; /* info about default char */
+ int width = 0; /* RETURN value */
+
+ if (singlerow) {
+ CI_GET_DEFAULT_INFO_1D (fs, def);
+ } else {
+ CI_GET_DEFAULT_INFO_2D (fs, def);
+ }
+
+ if (def && fs->min_bounds.width == fs->max_bounds.width)
+ return (fs->min_bounds.width * count);
+
+ /*
+ * Iterate over all character in the input string; only consider characters
+ * that exist.
+ */
+ for (i = 0; i < count; i++, string++) {
+ register XCharStruct *cs;
+ unsigned int r = (unsigned int) string->byte1; /* watch for macros */
+ unsigned int c = (unsigned int) string->byte2; /* watch for macros */
+
+ if (singlerow) {
+ unsigned int ind = ((r << 8) | c); /* watch for macros */
+ CI_GET_CHAR_INFO_1D (fs, ind, def, cs);
+ } else {
+ CI_GET_CHAR_INFO_2D (fs, r, c, def, cs);
+ }
+
+ if (cs) width += cs->width;
+ }
+
+ return width;
+}
+
+
+/*
+ * _XTextHeight16 - compute the height of sequence of XChar2bs.
+ */
+int
+_XTextHeight16 (
+ XFontStruct *fs,
+ _Xconst XChar2b *string,
+ int count)
+{
+ int i; /* iterator */
+ Bool singlerow = (fs->max_byte1 == 0); /* optimization */
+ XCharStruct *def; /* info about default char */
+ int height = 0; /* RETURN value */
+
+ if (singlerow) {
+ CI_GET_DEFAULT_INFO_1D (fs, def);
+ } else {
+ CI_GET_DEFAULT_INFO_2D (fs, def);
+ }
+
+ if (def && (fs->min_bounds.ascent == fs->max_bounds.ascent)
+ && (fs->min_bounds.descent == fs->max_bounds.descent))
+ return ((fs->min_bounds.ascent + fs->min_bounds.descent) * count);
+
+ /*
+ * Iterate over all character in the input string; only consider characters
+ * that exist.
+ */
+ for (i = 0; i < count; i++, string++) {
+ register XCharStruct *cs;
+ unsigned int r = (unsigned int) string->byte1; /* watch for macros */
+ unsigned int c = (unsigned int) string->byte2; /* watch for macros */
+
+ if (singlerow) {
+ unsigned int ind = ((r << 8) | c); /* watch for macros */
+ CI_GET_CHAR_INFO_1D (fs, ind, def, cs);
+ } else {
+ CI_GET_CHAR_INFO_2D (fs, r, c, def, cs);
+ }
+
+ if (cs) height += (cs->ascent + cs->descent);
+ }
+
+ return height;
+}
+
diff --git a/nx-X11/lib/X11/TextToStr.c b/nx-X11/lib/X11/TextToStr.c
new file mode 100644
index 000000000..0bea8096d
--- /dev/null
+++ b/nx-X11/lib/X11/TextToStr.c
@@ -0,0 +1,121 @@
+/* $Xorg: TextToStr.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+
+/* $XFree86: xc/lib/X11/TextToStr.c,v 1.4 2001/01/17 19:41:45 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+
+
+/*
+ * XTextPropertyToStringList - set list and count to contain data stored in
+ * null-separated STRING property.
+ */
+
+Status XTextPropertyToStringList (tp, list_return, count_return)
+ XTextProperty *tp;
+ char ***list_return;
+ int *count_return;
+{
+ char **list; /* return value */
+ int nelements; /* return value */
+ register char *cp; /* temp variable */
+ char *start; /* start of thing to copy */
+ int i, j; /* iterator variables */
+ int datalen = (int) tp->nitems; /* for convenience */
+
+ /*
+ * make sure we understand how to do it
+ */
+ if (tp->encoding != XA_STRING || tp->format != 8) return False;
+
+ if (datalen == 0) {
+ *list_return = NULL;
+ *count_return = 0;
+ return True;
+ }
+
+ /*
+ * walk the list to figure out how many elements there are
+ */
+ nelements = 1; /* since null-separated */
+ for (cp = (char *) tp->value, i = datalen; i > 0; cp++, i--) {
+ if (*cp == '\0') nelements++;
+ }
+
+ /*
+ * allocate list and duplicate
+ */
+ list = (char **) Xmalloc (nelements * sizeof (char *));
+ if (!list) return False;
+
+ start = (char *) Xmalloc ((datalen + 1) * sizeof (char)); /* for <NUL> */
+ if (!start) {
+ Xfree ((char *) list);
+ return False;
+ }
+
+ /*
+ * copy data
+ */
+ memcpy (start, (char *) tp->value, tp->nitems);
+ start[datalen] = '\0';
+
+ /*
+ * walk down list setting value
+ */
+ for (cp = start, i = datalen + 1, j = 0; i > 0; cp++, i--) {
+ if (*cp == '\0') {
+ list[j] = start;
+ start = (cp + 1);
+ j++;
+ }
+ }
+
+ /*
+ * append final null pointer and then return data
+ */
+ *list_return = list;
+ *count_return = nelements;
+ return True;
+}
+
+
+void XFreeStringList (list)
+ char **list;
+{
+ if (list) {
+ if (list[0]) Xfree (list[0]);
+ Xfree ((char *) list);
+ list = NULL;
+ }
+}
+
diff --git a/nx-X11/lib/X11/TrCoords.c b/nx-X11/lib/X11/TrCoords.c
new file mode 100644
index 000000000..87ae4ae4a
--- /dev/null
+++ b/nx-X11/lib/X11/TrCoords.c
@@ -0,0 +1,64 @@
+/* $Xorg: TrCoords.c,v 1.4 2001/02/09 02:03:37 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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+Bool XTranslateCoordinates(dpy, src_win, dest_win, src_x, src_y,
+ dst_x, dst_y, child)
+ register Display *dpy;
+ Window src_win, dest_win;
+ int src_x, src_y;
+ int *dst_x, *dst_y;
+ Window *child;
+{
+ register xTranslateCoordsReq *req;
+ xTranslateCoordsReply rep;
+
+ LockDisplay(dpy);
+ GetReq(TranslateCoords, req);
+ req->srcWid = src_win;
+ req->dstWid = dest_win;
+ req->srcX = src_x;
+ req->srcY = src_y;
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(False);
+ }
+
+ *child = rep.child;
+ *dst_x = cvtINT16toInt (rep.dstX);
+ *dst_y = cvtINT16toInt (rep.dstY);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((int)rep.sameScreen);
+}
+
diff --git a/nx-X11/lib/X11/UIThrStubs.c b/nx-X11/lib/X11/UIThrStubs.c
new file mode 100644
index 000000000..13df9e7ce
--- /dev/null
+++ b/nx-X11/lib/X11/UIThrStubs.c
@@ -0,0 +1,160 @@
+/*
+ * $XFree86: xc/lib/XThrStub/UIThrStubs.c,v 3.3 2001/11/18 21:13:26 herrb Exp $
+ *
+ * Copyright (c) 1995 David E. Wexelblat. All rights reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * 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 DAVID E. WEXELBLAT 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 David E. Wexelblat shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization
+ * from David E. Wexelblat.
+ *
+ */
+
+/*
+ * Stubs for thread functions needed by the X library. Supports
+ * UnixWare 2.x threads; may support Solaris 2 threads as well, but not
+ * tested. Defining things this way removes the dependency of the X
+ * library on the threads library, but still supports threads if the user
+ * specificies the thread library on the link line.
+ */
+
+/*
+ * Modifications by Carlos A M dos Santos, XFree86 Project, November 1999.
+ *
+ * Explanation from <X11/Xos_r.h>:
+ * The structure below is complicated, mostly because P1003.1c (the
+ * IEEE POSIX Threads spec) went through lots of drafts, and some
+ * vendors shipped systems based on draft API that were changed later.
+ * Unfortunately POSIX did not provide a feature-test macro for
+ * distinguishing each of the drafts.
+ */
+
+#ifdef CTHREADS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <cthreads.h>
+typedef cthread_t xthread_t;
+#define xthread_self cthread_self
+#pragma weak cthread_self = _Xthr_self_stub_
+#define xmutex_init mutex_init
+#pragma weak mutex_init = _Xthr_zero_stub_
+#pragma weak mutex_clear = _Xthr_zero_stub_
+#pragma weak mutex_lock = _Xthr_zero_stub_
+#pragma weak mutex_unlock = _Xthr_zero_stub_
+#pragma weak condition_init = _Xthr_zero_stub_
+#pragma weak condition_clear = _Xthr_zero_stub_
+#pragma weak condition_wait = _Xthr_zero_stub_
+#pragma weak condition_signal = _Xthr_zero_stub_
+#pragma weak condition_broadcast = _Xthr_zero_stub_
+#else /* !CTHREADS */
+#if defined(SVR4) && !defined(__sgi)
+#include <thread.h>
+typedef thread_t xthread_t;
+#pragma weak thr_self = _Xthr_self_stub_
+#pragma weak mutex_init = _Xthr_zero_stub_
+#pragma weak mutex_destroy = _Xthr_zero_stub_
+#pragma weak mutex_lock = _Xthr_zero_stub_
+#pragma weak mutex_unlock = _Xthr_zero_stub_
+#pragma weak cond_init = _Xthr_zero_stub_
+#pragma weak cond_destroy = _Xthr_zero_stub_
+#pragma weak cond_wait = _Xthr_zero_stub_
+#pragma weak cond_signal = _Xthr_zero_stub_
+#pragma weak cond_broadcast = _Xthr_zero_stub_
+#else /* !SVR4 */
+#ifdef WIN32
+ /*
+ * Don't know what to do here. Is there something do be done at all?
+ */
+#else /* !WIN32 */
+#ifdef USE_TIS_SUPPORT
+#include <tis.h>
+typedef pthread_t xthread_t;
+#pragma weak tis_self = _Xthr_self_stub_
+#pragma weak tis_mutex_init = _Xthr_zero_stub_
+#pragma weak tis_mutex_destroy = _Xthr_zero_stub_
+#pragma weak tis_mutex_lock = _Xthr_zero_stub_
+#pragma weak tis_mutex_unlock = _Xthr_zero_stub_
+#pragma weak tis_cond_init = _Xthr_zero_stub_
+#pragma weak tis_cond_destroy = _Xthr_zero_stub_
+#pragma weak tis_cond_wait = _Xthr_zero_stub_
+#pragma weak tis_cond_signal = _Xthr_zero_stub_
+#pragma weak tis_cond_broadcast = _Xthr_zero_stub_
+#else
+#include <pthread.h>
+typedef pthread_t xthread_t;
+#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
+xthread_t pthread_self() __attribute__ ((weak, alias ("_Xthr_self_stub_")));
+int pthread_mutex_init() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
+int pthread_mutex_destroy() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
+int pthread_mutex_lock() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
+int pthread_mutex_unlock() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
+int pthread_cond_init() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
+int pthread_cond_destroy() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
+int pthread_cond_wait() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
+int pthread_cond_signal() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
+int pthread_cond_broadcast() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
+int pthread_key_create() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
+void *pthread_getspecific() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
+int pthread_setspecific() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
+#else /* __GNUC__ */
+#pragma weak pthread_self = _Xthr_self_stub_
+#pragma weak pthread_mutex_init = _Xthr_zero_stub_
+#pragma weak pthread_mutex_destroy = _Xthr_zero_stub_
+#pragma weak pthread_mutex_lock = _Xthr_zero_stub_
+#pragma weak pthread_mutex_unlock = _Xthr_zero_stub_
+#pragma weak pthread_cond_init = _Xthr_zero_stub_
+#pragma weak pthread_cond_destroy = _Xthr_zero_stub_
+#pragma weak pthread_cond_wait = _Xthr_zero_stub_
+#pragma weak pthread_cond_signal = _Xthr_zero_stub_
+#pragma weak pthread_cond_broadcast = _Xthr_zero_stub_
+/* These are added for libGL */
+#pragma weak pthread_key_create = _Xthr_zero_stub_
+#pragma weak pthread_getspecific = _Xthr_zero_stub_
+#pragma weak pthread_setspecific = _Xthr_zero_stub_
+#endif /* __GNUC__ */
+#if defined(_DECTHREADS_) || defined(linux)
+#pragma weak pthread_equal = _Xthr_equal_stub_ /* See Xthreads.h! */
+int
+_Xthr_equal_stub_()
+{
+ return(1);
+}
+#endif /* _DECTHREADS_ || linux */
+#endif /* USE_TIS_SUPPORT */
+#endif /* WIN32 */
+#endif /* SVR4 */
+#endif /* CTHREADS */
+
+static xthread_t
+_Xthr_self_stub_()
+{
+ static xthread_t _X_no_thread_id;
+
+ return(_X_no_thread_id); /* defined by <X11/Xthreads.h> */
+}
+
+static int
+_Xthr_zero_stub_()
+{
+ return(0);
+}
diff --git a/nx-X11/lib/X11/UNDEFINED.c b/nx-X11/lib/X11/UNDEFINED.c
new file mode 100644
index 000000000..2c0563077
--- /dev/null
+++ b/nx-X11/lib/X11/UNDEFINED.c
@@ -0,0 +1,133 @@
+/* $Xorg: UNDEFINED.c,v 1.3 2000/08/17 19:44:57 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * UNDEFINED.c
+ *
+ * DESCRIPTION
+ * UNDEFINED Color Space
+ *
+ *
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * FORWARD DECLARATIONS
+ */
+static int DummyParseStringProc(
+ char* /* color_string */,
+ XcmsColor* /* color_return */
+ );
+static Status ReturnZero(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+ );
+
+
+/*
+ * LOCALS VARIABLES
+ */
+
+static Status (*(Fl_ReturnZero[]))(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+ ) = {
+ ReturnZero,
+ NULL
+};
+
+
+/*
+ * GLOBALS
+ * Variables declared in this package that are allowed
+ * to be used globally.
+ */
+ /*
+ * UNDEFINED Color Space
+ */
+XcmsColorSpace XcmsUNDEFINEDColorSpace =
+ {
+ "undefined", /* prefix */
+ XcmsUndefinedFormat, /* id */
+ &DummyParseStringProc, /* parseString */
+ Fl_ReturnZero, /* to_CIEXYZ */
+ Fl_ReturnZero /* from_CIEXYZ */
+ };
+
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * ReturnZero
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+static Status
+ReturnZero(
+ XcmsCCC ccc /* ccc */,
+ XcmsColor* white /* white_point */,
+ XcmsColor* colors /* colors */,
+ unsigned int ncolors /* ncolors */
+ )
+/*
+ * DESCRIPTION
+ * Does nothing.
+ *
+ * RETURNS
+ * 0
+ *
+ */
+{
+ return(0);
+}
+
+static int DummyParseStringProc(
+ char* color_string /* color_string */,
+ XcmsColor* color_return /* color_return */
+ )
+{
+ return(0);
+}
+
+/* ### EOF ### */
diff --git a/nx-X11/lib/X11/UndefCurs.c b/nx-X11/lib/X11/UndefCurs.c
new file mode 100644
index 000000000..6382a833a
--- /dev/null
+++ b/nx-X11/lib/X11/UndefCurs.c
@@ -0,0 +1,51 @@
+/* $Xorg: UndefCurs.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/UndefCurs.c,v 1.3 2001/01/17 19:41:45 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XUndefineCursor (dpy,w)
+ register Display *dpy;
+ Window w;
+{
+ register xChangeWindowAttributesReq *req;
+ unsigned long defcurs = None;
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWCursor;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), defcurs);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/UngrabBut.c b/nx-X11/lib/X11/UngrabBut.c
new file mode 100644
index 000000000..82b179106
--- /dev/null
+++ b/nx-X11/lib/X11/UngrabBut.c
@@ -0,0 +1,51 @@
+/* $Xorg: UngrabBut.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/UngrabBut.c,v 1.3 2001/01/17 19:41:45 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XUngrabButton(dpy, button, modifiers, grab_window)
+register Display *dpy;
+unsigned int button; /* CARD8 */
+unsigned int modifiers; /* CARD16 */
+Window grab_window;
+{
+ register xUngrabButtonReq *req;
+
+ LockDisplay(dpy);
+ GetReq(UngrabButton, req);
+ req->button = button;
+ req->modifiers = modifiers;
+ req->grabWindow = grab_window;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/UngrabKbd.c b/nx-X11/lib/X11/UngrabKbd.c
new file mode 100644
index 000000000..03d24b93c
--- /dev/null
+++ b/nx-X11/lib/X11/UngrabKbd.c
@@ -0,0 +1,47 @@
+/* $Xorg: UngrabKbd.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/UngrabKbd.c,v 1.3 2001/01/17 19:41:45 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XUngrabKeyboard (dpy, time)
+ register Display *dpy;
+ Time time;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(UngrabKeyboard, time, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/UngrabKey.c b/nx-X11/lib/X11/UngrabKey.c
new file mode 100644
index 000000000..66c691f97
--- /dev/null
+++ b/nx-X11/lib/X11/UngrabKey.c
@@ -0,0 +1,55 @@
+/* $Xorg: UngrabKey.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/UngrabKey.c,v 1.3 2001/01/17 19:41:45 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XUngrabKey(dpy, key, modifiers, grab_window)
+ register Display *dpy;
+ int key;
+ unsigned int modifiers;
+ Window grab_window;
+
+{
+ register xUngrabKeyReq *req;
+
+ LockDisplay(dpy);
+ GetReq(UngrabKey, req);
+ req->grabWindow = grab_window;
+ req->modifiers = modifiers;
+ req->key = key;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+
diff --git a/nx-X11/lib/X11/UngrabPtr.c b/nx-X11/lib/X11/UngrabPtr.c
new file mode 100644
index 000000000..42890ff8c
--- /dev/null
+++ b/nx-X11/lib/X11/UngrabPtr.c
@@ -0,0 +1,46 @@
+/* $Xorg: UngrabPtr.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/UngrabPtr.c,v 1.3 2001/01/17 19:41:45 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XUngrabPointer(dpy, time)
+register Display *dpy;
+Time time;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(UngrabPointer, time, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/UngrabSvr.c b/nx-X11/lib/X11/UngrabSvr.c
new file mode 100644
index 000000000..19764f651
--- /dev/null
+++ b/nx-X11/lib/X11/UngrabSvr.c
@@ -0,0 +1,46 @@
+/* $Xorg: UngrabSvr.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/UngrabSvr.c,v 1.3 2001/01/17 19:41:45 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XUngrabServer (dpy)
+register Display *dpy;
+{
+ register xReq *req;
+
+ LockDisplay(dpy);
+ GetEmptyReq(UngrabServer, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/UninsCmap.c b/nx-X11/lib/X11/UninsCmap.c
new file mode 100644
index 000000000..9a3d998b5
--- /dev/null
+++ b/nx-X11/lib/X11/UninsCmap.c
@@ -0,0 +1,46 @@
+/* $Xorg: UninsCmap.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/UninsCmap.c,v 1.3 2001/01/17 19:41:45 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XUninstallColormap(dpy, cmap)
+register Display *dpy;
+Colormap cmap;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(UninstallColormap, cmap, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/UnldFont.c b/nx-X11/lib/X11/UnldFont.c
new file mode 100644
index 000000000..f90291e6b
--- /dev/null
+++ b/nx-X11/lib/X11/UnldFont.c
@@ -0,0 +1,47 @@
+/* $Xorg: UnldFont.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/UnldFont.c,v 1.5 2001/12/14 19:54:07 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XUnloadFont(dpy, font)
+ register Display *dpy;
+ Font font;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(CloseFont, font, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/UnmapSubs.c b/nx-X11/lib/X11/UnmapSubs.c
new file mode 100644
index 000000000..503a6c9e9
--- /dev/null
+++ b/nx-X11/lib/X11/UnmapSubs.c
@@ -0,0 +1,46 @@
+/* $Xorg: UnmapSubs.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/UnmapSubs.c,v 1.3 2001/01/17 19:41:45 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XUnmapSubwindows(dpy, win)
+register Display *dpy;
+Window win;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(UnmapSubwindows,win, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/X11/UnmapWin.c b/nx-X11/lib/X11/UnmapWin.c
new file mode 100644
index 000000000..1a9cc0c29
--- /dev/null
+++ b/nx-X11/lib/X11/UnmapWin.c
@@ -0,0 +1,47 @@
+/* $Xorg: UnmapWin.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/UnmapWin.c,v 1.3 2001/01/17 19:41:45 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XUnmapWindow (dpy, w)
+ register Display *dpy;
+ Window w;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(UnmapWindow, w, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/VisUtil.c b/nx-X11/lib/X11/VisUtil.c
new file mode 100644
index 000000000..304317aee
--- /dev/null
+++ b/nx-X11/lib/X11/VisUtil.c
@@ -0,0 +1,256 @@
+/* $Xorg: VisUtil.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xutil.h"
+#include <stdio.h>
+/*
+ * This procedure returns a list of visual information structures
+ * that match the specified attributes given in the visual information
+ * template.
+ *
+ * If no visuals exist that match the specified attributes, a NULL is
+ * returned.
+ *
+ * The choices for visual_info_mask are:
+ *
+ * VisualNoMask
+ * VisualIDMask
+ * VisualScreenMask
+ * VisualDepthMask
+ * VisualClassMask
+ * VisualRedMaskMask
+ * VisualGreenMaskMask
+ * VisualBlueMaskMask
+ * VisualColormapSizeMask
+ * VisualBitsPerRGBMask
+ * VisualAllMask
+ */
+
+XVisualInfo *XGetVisualInfo( dpy, visual_info_mask,
+ visual_info_template, nitems)
+Display *dpy;
+register long visual_info_mask;
+register XVisualInfo *visual_info_template;
+int *nitems; /* RETURN */
+{
+
+ register Visual *vp;
+ register Depth *dp;
+ Screen *sp;
+ int ii,screen_s,screen_e,total,count;
+ register XVisualInfo *vip,*vip_base;
+
+ /* NOTE: NO HIGH PERFORMING CODE TO BE FOUND HERE */
+
+ LockDisplay(dpy);
+
+ /* ALLOCATE THE ORIGINAL BUFFER; REALLOCED LATER IF OVERFLOW OCCURS;
+ FREED AT END IF NO VISUALS ARE FOUND */
+
+ count = 0;
+ total = 10;
+ if (! (vip_base = vip = (XVisualInfo *)
+ Xmalloc((unsigned) (sizeof(XVisualInfo) * total)))) {
+ UnlockDisplay(dpy);
+ return (XVisualInfo *) NULL;
+ }
+
+ /* DETERMINE IF WE DO ALL SCREENS OR ONLY ONE */
+
+ screen_s = 0;
+ screen_e = dpy->nscreens;
+ if (visual_info_mask & VisualScreenMask)
+ {
+ screen_s = visual_info_template->screen;
+ if (screen_s < 0 || screen_s >= screen_e)
+ screen_e = screen_s;
+ else
+ screen_e = screen_s + 1;
+ }
+
+ /* LOOP THROUGH SCREENS */
+
+ for (ii=screen_s; ii<screen_e; ii++)
+ {
+ sp = (Screen *)(&dpy->screens[ii]);
+
+ /* LOOP THROUGH DEPTHS */
+
+ for (dp=sp->depths; dp < (sp->depths + sp->ndepths); dp++)
+ {
+ if ((visual_info_mask & VisualDepthMask) &&
+ (dp->depth != visual_info_template->depth)) continue;
+
+ /* LOOP THROUGH VISUALS */
+
+ if (dp->visuals) {
+ for (vp=dp->visuals; vp<(dp->visuals + dp->nvisuals); vp++) {
+ if ((visual_info_mask & VisualIDMask) &&
+ (vp->visualid != visual_info_template->visualid)) continue;
+ if ((visual_info_mask & VisualClassMask) &&
+ (vp->class != visual_info_template->class)) continue;
+ if ((visual_info_mask & VisualRedMaskMask) &&
+ (vp->red_mask != visual_info_template->red_mask)) continue;
+ if ((visual_info_mask & VisualGreenMaskMask) &&
+ (vp->green_mask != visual_info_template->green_mask)) continue;
+ if ((visual_info_mask & VisualBlueMaskMask) &&
+ (vp->blue_mask != visual_info_template->blue_mask)) continue;
+ if ((visual_info_mask & VisualColormapSizeMask) &&
+ (vp->map_entries != visual_info_template->colormap_size)) continue;
+ if ((visual_info_mask & VisualBitsPerRGBMask) &&
+ (vp->bits_per_rgb != visual_info_template->bits_per_rgb)) continue;
+
+ /* YEA!!! WE FOUND A GOOD ONE */
+
+ if (count+1 > total)
+ {
+ XVisualInfo *old_vip_base = vip_base;
+ total += 10;
+ if (! (vip_base = (XVisualInfo *)
+ Xrealloc((char *) vip_base,
+ (unsigned) (sizeof(XVisualInfo) * total)))) {
+ Xfree((char *) old_vip_base);
+ UnlockDisplay(dpy);
+ return (XVisualInfo *) NULL;
+ }
+ vip = &vip_base[count];
+ }
+
+ count++;
+
+ vip->visual = _XVIDtoVisual(dpy, vp->visualid);
+ vip->visualid = vp->visualid;
+ vip->screen = ii;
+ vip->depth = dp->depth;
+ vip->class = vp->class;
+ vip->red_mask = vp->red_mask;
+ vip->green_mask = vp->green_mask;
+ vip->blue_mask = vp->blue_mask;
+ vip->colormap_size = vp->map_entries;
+ vip->bits_per_rgb = vp->bits_per_rgb;
+
+ vip++;
+
+ } /* END OF LOOP ON VISUALS */
+ } /* END OF IF THERE ARE ANY VISUALS AT THIS DEPTH */
+
+ } /* END OF LOOP ON DEPTHS */
+
+ } /* END OF LOOP ON SCREENS */
+
+ UnlockDisplay(dpy);
+
+ if (count)
+ {
+ *nitems = count;
+ return vip_base;
+ }
+
+ Xfree((char *) vip_base);
+ *nitems = 0;
+ return NULL;
+}
+
+
+/*
+ * This procedure will return the visual information for a visual
+ * that matches the specified depth and class for a screen. Since
+ * multiple visuals may exist that match the specified depth and
+ * class, which visual chosen is undefined.
+ *
+ * If a visual is found, True is returned as the function value,
+ * otherwise False is returned.
+ */
+
+Status XMatchVisualInfo( dpy, screen, depth, class, visual_info)
+ Display *dpy;
+ int screen;
+ int depth;
+ int class;
+ XVisualInfo *visual_info; /* RETURNED */
+{
+
+ Visual *vp;
+ Depth *dp;
+ Screen *sp;
+ int ii,jj;
+
+ if (screen < 0 || screen >= dpy->nscreens)
+ return False;
+
+ LockDisplay(dpy);
+
+ sp = (Screen *)(&dpy->screens[screen]);
+
+ dp = sp->depths;
+
+ for (ii=0; ii < sp->ndepths; ii++)
+ {
+
+ /* LOOK THROUGH DEPTHS FOR THE WANTED DEPTH */
+
+ if (dp->depth == depth)
+ {
+ vp = dp->visuals;
+
+ /* LOOK THROUGH VISUALS FOR THE WANTED CLASS */
+
+ /* if nvisuals == 0 then vp will be NULL */
+ for (jj=0; jj<dp->nvisuals; jj++)
+ {
+ if (vp->class == class)
+ {
+ visual_info->visual = _XVIDtoVisual(dpy, vp->visualid);
+ visual_info->visualid = vp->visualid;
+ visual_info->screen = screen;
+ visual_info->depth = depth;
+ visual_info->class = vp->class;
+ visual_info->red_mask = vp->red_mask;
+ visual_info->green_mask = vp->green_mask;
+ visual_info->blue_mask = vp->blue_mask;
+ visual_info->colormap_size = vp->map_entries;
+ visual_info->bits_per_rgb = vp->bits_per_rgb;
+ UnlockDisplay(dpy);
+ return True;
+ }
+ vp++;
+ }
+ }
+
+ dp++;
+
+ }
+
+ UnlockDisplay(dpy);
+
+ return False;
+
+}
diff --git a/nx-X11/lib/X11/WMGeom.c b/nx-X11/lib/X11/WMGeom.c
new file mode 100644
index 000000000..59041a9fa
--- /dev/null
+++ b/nx-X11/lib/X11/WMGeom.c
@@ -0,0 +1,185 @@
+/* $Xorg: WMGeom.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/WMGeom.c,v 1.3 2003/04/13 19:22:18 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xutil.h"
+
+static int _GeometryMaskToGravity(
+ int mask);
+
+/*
+ * This routine given a user supplied positional argument and a default
+ * argument (fully qualified) will return the position the window should take
+ * as well as the gravity to be set in the WM_NORMAL_HINTS size hints.
+ * Always sets all return values and returns a mask describing which fields
+ * were set by the user or'ed with whether or not the x and y values should
+ * be considered "negative".
+ */
+
+int
+XWMGeometry (
+ Display *dpy, /* user's display connection */
+ int screen, /* screen on which to do computation */
+ _Xconst char *user_geom, /* user provided geometry spec */
+ _Xconst char *def_geom, /* default geometry spec for window */
+ unsigned int bwidth, /* border width */
+ XSizeHints *hints, /* usually WM_NORMAL_HINTS */
+ int *x_return, /* location of window */
+ int *y_return, /* location of window */
+ int *width_return, /* size of window */
+ int *height_return, /* size of window */
+ int *gravity_return) /* gravity of window */
+{
+ int ux, uy; /* returned values from parse */
+ unsigned int uwidth, uheight; /* returned values from parse */
+ int umask; /* parse mask of returned values */
+ int dx, dy; /* default values from parse */
+ unsigned int dwidth, dheight; /* default values from parse */
+ int dmask; /* parse mask of returned values */
+ int base_width, base_height; /* valid amounts */
+ int min_width, min_height; /* valid amounts */
+ int width_inc, height_inc; /* valid amounts */
+ int rx, ry, rwidth, rheight; /* return values */
+ int rmask; /* return mask */
+
+ /*
+ * Get the base sizes and increments. Section 4.1.2.3 of the ICCCM
+ * states that the base and minimum sizes are defaults for each other.
+ * If neither is given, then the base sizes should be 0. These parameters
+ * control the sets of sizes that window managers should allow for the
+ * window according to the following formulae:
+ *
+ * width = base_width + (i * width_inc)
+ * height = base_height + (j * height_inc)
+ */
+ base_width = ((hints->flags & PBaseSize) ? hints->base_width :
+ ((hints->flags & PMinSize) ? hints->min_width : 0));
+ base_height = ((hints->flags & PBaseSize) ? hints->base_height :
+ ((hints->flags & PMinSize) ? hints->min_height : 0));
+ min_width = ((hints->flags & PMinSize) ? hints->min_width : base_width);
+ min_height = ((hints->flags & PMinSize) ? hints->min_height : base_height);
+ width_inc = (hints->flags & PResizeInc) ? hints->width_inc : 1;
+ height_inc = (hints->flags & PResizeInc) ? hints->height_inc : 1;
+
+
+ /*
+ * parse the two geometry masks
+ */
+ rmask = umask = XParseGeometry (user_geom, &ux, &uy, &uwidth, &uheight);
+ dmask = XParseGeometry (def_geom, &dx, &dy, &dwidth, &dheight);
+
+
+ /*
+ * get the width and height:
+ * 1. if user-specified, then take that value
+ * 2. else, if program-specified, then take that value
+ * 3. else, take 1
+ * 4. multiply by the size increment
+ * 5. and add to the base size
+ */
+ rwidth = ((((umask & WidthValue) ? uwidth :
+ ((dmask & WidthValue) ? dwidth : 1)) * width_inc) +
+ base_width);
+ rheight = ((((umask & HeightValue) ? uheight :
+ ((dmask & HeightValue) ? dheight : 1)) * height_inc) +
+ base_height);
+
+ /*
+ * Make sure computed size is within limits. Note that we always do the
+ * lower bounds check since the base size (which defaults to 0) should
+ * be used if a minimum size isn't specified.
+ */
+ if (rwidth < min_width) rwidth = min_width;
+ if (rheight < min_height) rheight = min_height;
+
+ if (hints->flags & PMaxSize) {
+ if (rwidth > hints->max_width) rwidth = hints->max_width;
+ if (rheight > hints->max_height) rheight = hints->max_height;
+ }
+
+
+ /*
+ * Compute the location. Set the negative flags in the return mask
+ * (and watch out for borders), if necessary.
+ */
+ if (umask & XValue) {
+ rx = ((umask & XNegative) ?
+ (DisplayWidth (dpy, screen) + ux - rwidth - 2 * bwidth) : ux);
+ } else if (dmask & XValue) {
+ if (dmask & XNegative) {
+ rx = (DisplayWidth (dpy, screen) + dx - rwidth - 2 * bwidth);
+ rmask |= XNegative;
+ } else
+ rx = dx;
+ } else {
+ rx = 0; /* gotta choose something... */
+ }
+
+ if (umask & YValue) {
+ ry = ((umask & YNegative) ?
+ (DisplayHeight(dpy, screen) + uy - rheight - 2 * bwidth) : uy);
+ } else if (dmask & YValue) {
+ if (dmask & YNegative) {
+ ry = (DisplayHeight(dpy, screen) + dy - rheight - 2 * bwidth);
+ rmask |= YNegative;
+ } else
+ ry = dy;
+ } else {
+ ry = 0; /* gotta choose something... */
+ }
+
+
+ /*
+ * All finished, so set the return variables.
+ */
+ *x_return = rx;
+ *y_return = ry;
+ *width_return = rwidth;
+ *height_return = rheight;
+ *gravity_return = _GeometryMaskToGravity (rmask);
+ return rmask;
+}
+
+
+static int _GeometryMaskToGravity(
+ int mask)
+{
+ switch (mask & (XNegative|YNegative)) {
+ case 0:
+ return NorthWestGravity;
+ case XNegative:
+ return NorthEastGravity;
+ case YNegative:
+ return SouthWestGravity;
+ default:
+ return SouthEastGravity;
+ }
+}
diff --git a/nx-X11/lib/X11/WMProps.c b/nx-X11/lib/X11/WMProps.c
new file mode 100644
index 000000000..62c6a8d12
--- /dev/null
+++ b/nx-X11/lib/X11/WMProps.c
@@ -0,0 +1,149 @@
+/* $Xorg: WMProps.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1988, 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.
+
+*/
+/* $XFree86: xc/lib/X11/WMProps.c,v 3.6 2001/12/14 19:54:07 dawes 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 of 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.
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <X11/Xlocale.h>
+
+
+/*
+ * XSetWMProperties sets the following properties:
+ * WM_NAME type: TEXT format: varies?
+ * WM_ICON_NAME type: TEXT format: varies?
+ * WM_HINTS type: WM_HINTS format: 32
+ * WM_COMMAND type: TEXT format: varies?
+ * WM_CLIENT_MACHINE type: TEXT format: varies?
+ * WM_NORMAL_HINTS type: WM_SIZE_HINTS format: 32
+ * WM_CLASS type: STRING/STRING format: 8
+ */
+
+void XSetWMProperties (dpy, w, windowName, iconName, argv, argc, sizeHints,
+ wmHints, classHints)
+ Display *dpy;
+ Window w; /* window to decorate */
+ XTextProperty *windowName; /* name of application */
+ XTextProperty *iconName; /* name string for icon */
+ char **argv; /* command line */
+ int argc; /* size of command line */
+ XSizeHints *sizeHints; /* size hints for window in its normal state */
+ XWMHints *wmHints; /* miscelaneous window manager hints */
+ XClassHint *classHints; /* resource name and class */
+{
+ XTextProperty textprop;
+ char hostName[256];
+ int len = _XGetHostname (hostName, sizeof hostName);
+ char *locale;
+
+ /* set names of window and icon */
+ if (windowName) XSetWMName (dpy, w, windowName);
+ if (iconName) XSetWMIconName (dpy, w, iconName);
+
+ /* set the command if given */
+ if (argv) {
+ /*
+ * for UNIX and other operating systems which use nul-terminated
+ * arrays of STRINGs.
+ */
+ XSetCommand (dpy, w, argv, argc);
+ }
+
+ /* set the name of the machine on which this application is running */
+ textprop.value = (unsigned char *) hostName;
+ textprop.encoding = XA_STRING;
+ textprop.format = 8;
+ textprop.nitems = len;
+ XSetWMClientMachine (dpy, w, &textprop);
+
+ /* set hints about how geometry and window manager interaction */
+ if (sizeHints) XSetWMNormalHints (dpy, w, sizeHints);
+ if (wmHints) XSetWMHints (dpy, w, wmHints);
+ if (classHints) {
+ XClassHint tmp;
+
+ if (!classHints->res_name) {
+ tmp.res_name = getenv ("RESOURCE_NAME");
+ if (!tmp.res_name && argv && argv[0]) {
+ /*
+ * UNIX uses /dir/subdir/.../basename; other operating
+ * systems will have to change this.
+ */
+ char *cp = strrchr (argv[0], '/');
+#ifdef __UNIXOS2__
+ char *os2_cp = strrchr (argv[0],'\\');
+ char *dot_cp = strrchr (argv[0],'.');
+ if (os2_cp && (os2_cp > cp)) {
+ if(dot_cp && (dot_cp > os2_cp)) *dot_cp = '\0';
+ cp=os2_cp;
+ }
+#endif
+ tmp.res_name = (cp ? cp + 1 : argv[0]);
+ }
+ tmp.res_class = classHints->res_class;
+ classHints = &tmp;
+ }
+ XSetClassHint (dpy, w, classHints);
+ }
+
+ locale = setlocale(LC_CTYPE, (char *)NULL);
+ if (locale)
+ XChangeProperty (dpy, w, XInternAtom(dpy, "WM_LOCALE_NAME", False),
+ XA_STRING, 8, PropModeReplace,
+ (unsigned char *)locale, strlen(locale));
+}
+
diff --git a/nx-X11/lib/X11/WarpPtr.c b/nx-X11/lib/X11/WarpPtr.c
new file mode 100644
index 000000000..545cc064e
--- /dev/null
+++ b/nx-X11/lib/X11/WarpPtr.c
@@ -0,0 +1,59 @@
+/* $Xorg: WarpPtr.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/WarpPtr.c,v 1.3 2001/01/17 19:41:47 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+int
+XWarpPointer(dpy, src_win, dest_win, src_x, src_y, src_width, src_height,
+ dest_x, dest_y)
+ register Display *dpy;
+ Window src_win, dest_win;
+ int src_x, src_y;
+ unsigned int src_width, src_height;
+ int dest_x, dest_y;
+{
+ register xWarpPointerReq *req;
+
+ LockDisplay(dpy);
+ GetReq(WarpPointer, req);
+ req->srcWid = src_win;
+ req->dstWid = dest_win;
+ req->srcX = src_x;
+ req->srcY = src_y;
+ req->srcWidth = src_width;
+ req->srcHeight = src_height;
+ req->dstX = dest_x;
+ req->dstY = dest_y;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/nx-X11/lib/X11/WinEvent.c b/nx-X11/lib/X11/WinEvent.c
new file mode 100644
index 000000000..67e825cb5
--- /dev/null
+++ b/nx-X11/lib/X11/WinEvent.c
@@ -0,0 +1,83 @@
+/* $Xorg: WinEvent.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/WinEvent.c,v 3.5 2001/10/28 03:32:32 tsi Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+extern long const _Xevent_to_mask[];
+#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask)
+#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
+ Button4MotionMask|Button5MotionMask)
+
+/*
+ * Return the next event in the queue
+ * for the given window matching one of the events in the mask.
+ * Events earlier in the queue are not discarded.
+ * If none found, flush, and then wait until an event arrives which
+ * matches.
+ */
+
+int
+XWindowEvent (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 = 0;
+
+ LockDisplay(dpy);
+ prev = NULL;
+ while (1) {
+ 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 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/nx-X11/lib/X11/Window.c b/nx-X11/lib/X11/Window.c
new file mode 100644
index 000000000..10d1b95f7
--- /dev/null
+++ b/nx-X11/lib/X11/Window.c
@@ -0,0 +1,140 @@
+/* $Xorg: Window.c,v 1.5 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/Window.c,v 1.4 2001/12/14 19:54:08 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+void _XProcessWindowAttributes (
+ register Display *dpy,
+ xChangeWindowAttributesReq *req,
+ register unsigned long valuemask,
+ register XSetWindowAttributes *attributes)
+{
+ unsigned long values[32];
+ register unsigned long *value = values;
+ unsigned int nvalues;
+
+ if (valuemask & CWBackPixmap)
+ *value++ = attributes->background_pixmap;
+
+ if (valuemask & CWBackPixel)
+ *value++ = attributes->background_pixel;
+
+ if (valuemask & CWBorderPixmap)
+ *value++ = attributes->border_pixmap;
+
+ if (valuemask & CWBorderPixel)
+ *value++ = attributes->border_pixel;
+
+ if (valuemask & CWBitGravity)
+ *value++ = attributes->bit_gravity;
+
+ if (valuemask & CWWinGravity)
+ *value++ = attributes->win_gravity;
+
+ if (valuemask & CWBackingStore)
+ *value++ = attributes->backing_store;
+
+ if (valuemask & CWBackingPlanes)
+ *value++ = attributes->backing_planes;
+
+ if (valuemask & CWBackingPixel)
+ *value++ = attributes->backing_pixel;
+
+ if (valuemask & CWOverrideRedirect)
+ *value++ = attributes->override_redirect;
+
+ if (valuemask & CWSaveUnder)
+ *value++ = attributes->save_under;
+
+ if (valuemask & CWEventMask)
+ *value++ = attributes->event_mask;
+
+ if (valuemask & CWDontPropagate)
+ *value++ = attributes->do_not_propagate_mask;
+
+ if (valuemask & CWColormap)
+ *value++ = attributes->colormap;
+
+ if (valuemask & CWCursor)
+ *value++ = attributes->cursor;
+
+ req->length += (nvalues = value - values);
+
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, (long)nvalues);
+
+}
+
+#define AllMaskBits (CWBackPixmap|CWBackPixel|CWBorderPixmap|\
+ CWBorderPixel|CWBitGravity|CWWinGravity|\
+ CWBackingStore|CWBackingPlanes|CWBackingPixel|\
+ CWOverrideRedirect|CWSaveUnder|CWEventMask|\
+ CWDontPropagate|CWColormap|CWCursor)
+
+Window XCreateWindow(dpy, parent, x, y, width, height,
+ borderWidth, depth, class, visual, valuemask, attributes)
+ register Display *dpy;
+ Window parent;
+ int x, y;
+ unsigned int width, height, borderWidth;
+ int depth;
+ unsigned int class;
+ Visual *visual;
+ unsigned long valuemask;
+ XSetWindowAttributes *attributes;
+{
+ Window wid;
+ register xCreateWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CreateWindow, req);
+ req->parent = parent;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->borderWidth = borderWidth;
+ req->depth = depth;
+ req->class = class;
+ if (visual == CopyFromParent)
+ req->visual = CopyFromParent;
+ else
+ req->visual = visual->visualid;
+ wid = req->wid = XAllocID(dpy);
+ valuemask &= AllMaskBits;
+ if ((req->mask = valuemask))
+ _XProcessWindowAttributes (dpy, (xChangeWindowAttributesReq *)req,
+ valuemask, attributes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (wid);
+ }
+
diff --git a/nx-X11/lib/X11/Withdraw.c b/nx-X11/lib/X11/Withdraw.c
new file mode 100644
index 000000000..1b771c286
--- /dev/null
+++ b/nx-X11/lib/X11/Withdraw.c
@@ -0,0 +1,84 @@
+/* $Xorg: Withdraw.c,v 1.4 2001/02/09 02:03:37 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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#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 or IconicState to Withdrawn.
+ */
+Status XWithdrawWindow (dpy, w, screen)
+ Display *dpy;
+ Window w;
+ int screen;
+{
+ XUnmapEvent ev;
+ Window root = RootWindow (dpy, screen);
+
+ XUnmapWindow (dpy, w);
+
+ ev.type = UnmapNotify;
+ ev.event = root;
+ ev.window = w;
+ ev.from_configure = False;
+ return (XSendEvent (dpy, root, False,
+ SubstructureRedirectMask|SubstructureNotifyMask,
+ (XEvent *)&ev));
+}
diff --git a/nx-X11/lib/X11/WrBitF.c b/nx-X11/lib/X11/WrBitF.c
new file mode 100644
index 000000000..d8c9f18fa
--- /dev/null
+++ b/nx-X11/lib/X11/WrBitF.c
@@ -0,0 +1,158 @@
+/* $Xorg: WrBitF.c,v 1.4 2001/02/09 02:03:37 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.
+
+*/
+/* $XFree86: xc/lib/X11/WrBitF.c,v 3.6 2003/04/13 19:22:18 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xos.h>
+#include "Xutil.h"
+#include <stdio.h>
+
+#define ERR_RETURN 0
+
+static char *Format_Image(
+ XImage *image,
+ int *resultsize)
+{
+ register int x, c, b;
+ register char *ptr;
+ int y;
+ char *data;
+ int width, height;
+ int bytes_per_line;
+
+ width = image->width;
+ height = image->height;
+
+ bytes_per_line = (width+7)/8;
+ *resultsize = bytes_per_line * height; /* Calculate size of data */
+
+ data = (char *) Xmalloc( *resultsize ); /* Get space for data */
+ if (!data)
+ return(ERR_RETURN);
+
+ /*
+ * The slow but robust brute force method of converting the image:
+ */
+ ptr = data;
+ c = 0; b=1;
+ for (y=0; y<height; y++) {
+ for (x=0; x<width;) {
+ if (XGetPixel(image, x, y))
+ c |= b;
+ b <<= 1;
+ if (!(++x & 7)) {
+ *(ptr++)=c;
+ c=0; b=1;
+ }
+ }
+ if (x & 7) {
+ *(ptr++)=c;
+ c=0; b=1;
+ }
+ }
+
+ return(data);
+}
+
+#define BYTES_PER_OUTPUT_LINE 12
+
+int
+XWriteBitmapFile(
+ Display *display,
+ _Xconst char *filename,
+ Pixmap bitmap,
+ unsigned int width,
+ unsigned int height,
+ int x_hot,
+ int y_hot)
+{
+ char *data, *ptr;
+ int size, byte;
+ int c;
+ XImage *image;
+ FILE *stream;
+ char *name;
+
+ if (!(name = strrchr(filename, '/')))
+ name = (char *)filename;
+ else
+ name++;
+
+#ifdef __UNIXOS2__
+ filename = (char*)__XOS2RedirRoot(filename);
+#endif
+ if (!(stream = fopen(filename, "w")))
+ return(BitmapOpenFailed);
+
+ /* Convert bitmap to an image */
+ image = XGetImage(display, bitmap, 0,0,width, height, 1L, XYPixmap);
+ if (!image) {
+ fclose(stream);
+ return(4); /* XXX spec does not say what to return */
+ }
+
+ /* Get standard format for data */
+ data = Format_Image(image, &size);
+ XDestroyImage(image);
+ if (!data) {
+ fclose(stream);
+ return(BitmapNoMemory);
+ }
+
+ /* Write out standard header */
+ fprintf(stream, "#define %s_width %d\n", name, width);
+ fprintf(stream, "#define %s_height %d\n", name, height);
+ if (x_hot != -1) {
+ fprintf(stream, "#define %s_x_hot %d\n", name, x_hot);
+ fprintf(stream, "#define %s_y_hot %d\n", name, y_hot);
+ }
+
+ /* Print out the data itself */
+ fprintf(stream, "static unsigned char %s_bits[] = {", name);
+ for (byte=0, ptr=data; byte<size; byte++, ptr++) {
+ if (!byte)
+ fprintf(stream, "\n ");
+ else if (!(byte % BYTES_PER_OUTPUT_LINE))
+ fprintf(stream, ",\n ");
+ else
+ fprintf(stream, ", ");
+ c = *ptr;
+ if (c<0)
+ c += 256;
+ fprintf(stream, "0x%02x", c);
+ }
+ fprintf(stream, "};\n");
+
+ Xfree(data);
+ fclose(stream);
+ return(BitmapSuccess);
+}
diff --git a/nx-X11/lib/X11/X11-def.cpp b/nx-X11/lib/X11/X11-def.cpp
new file mode 100644
index 000000000..ea466ebbe
--- /dev/null
+++ b/nx-X11/lib/X11/X11-def.cpp
@@ -0,0 +1,2013 @@
+#ifndef __CYGWIN__
+LIBRARY X11
+#else
+LIBRARY libX11
+#endif
+VERSION LIBRARY_VERSION
+EXPORTS
+#if !defined(__CYGWIN__) && !defined(__UNIXOS2__)
+ _Xdebug_p=_Xdebug CONSTANT
+ _XCreateMutex_fn_p=_XCreateMutex_fn CONSTANT
+ _XFreeMutex_fn_p=_XFreeMutex_fn CONSTANT
+ _XLockMutex_fn_p=_XLockMutex_fn CONSTANT
+ _XUnlockMutex_fn_p=_XUnlockMutex_fn CONSTANT
+ _Xglobal_lock_p=_Xglobal_lock CONSTANT
+ _XFlushIt
+ XActivateScreenSaver
+ XAddConnectionWatch
+ XAddExtension
+ XAddHost
+ XAddHosts
+ XAddPixel
+ XAddToExtensionList
+ XAddToSaveSet
+ XAllPlanes
+ XAllocClassHint
+ XAllocColor
+ XAllocColorCells
+ XAllocColorPlanes
+ XAllocIconSize
+ XAllocNamedColor
+ XAllocSizeHints
+ XAllocStandardColormap
+ XAllocWMHints
+ XAllowEvents
+ XAutoRepeatOff
+ XAutoRepeatOn
+ XBaseFontNameListOfFontSet
+ XBell
+ XBitmapBitOrder
+ XBitmapPad
+ XBitmapUnit
+ XBlackPixel
+ XBlackPixelOfScreen
+ XCellsOfScreen
+ XChangeActivePointerGrab
+ XChangeGC
+ XChangeKeyboardControl
+ XChangeKeyboardMapping
+ XChangePointerControl
+ XChangeProperty
+ XChangeSaveSet
+ XChangeWindowAttributes
+ XCheckIfEvent
+ XCheckMaskEvent
+ XCheckTypedEvent
+ XCheckTypedWindowEvent
+ XCheckWindowEvent
+ XCirculateSubwindows
+ XCirculateSubwindowsDown
+ XCirculateSubwindowsUp
+ XClearArea
+ XClearWindow
+ XClipBox
+ XCloseDisplay
+ XCloseIM
+ XCloseOM
+ XConfigureWindow
+ XConnectionNumber
+ XContextDependentDrawing
+ XContextualDrawing
+ XConvertCase
+ XConvertSelection
+ XCopyArea
+ XCopyColormapAndFree
+ XCopyGC
+ XCopyPlane
+ XCreateBitmapFromData
+ XCreateColormap
+ XCreateFontCursor
+ XCreateFontSet
+ XCreateGC
+ XCreateGlyphCursor
+ XCreateIC
+ XCreateImage
+ XCreateOC
+ XCreatePixmap
+ XCreatePixmapCursor
+ XCreatePixmapFromBitmapData
+ XCreateRegion
+ XCreateSimpleWindow
+ XCreateWindow
+ XDefaultColormap
+ XDefaultColormapOfScreen
+ XDefaultDepth
+ XDefaultDepthOfScreen
+ XDefaultGC
+ XDefaultGCOfScreen
+ XDefaultRootWindow
+ XDefaultScreen
+ XDefaultScreenOfDisplay
+ XDefaultString
+ XDefaultVisual
+ XDefaultVisualOfScreen
+ XDefineCursor
+ XDeleteContext
+ XDeleteModifiermapEntry
+ XDeleteProperty
+ XDestroyIC
+ XDestroyImage
+ XDestroyOC
+ XDestroyRegion
+ XDestroySubwindows
+ XDestroyWindow
+ XDirectionalDependentDrawing
+ XDisableAccessControl
+ XDisplayCells
+ XDisplayHeight
+ XDisplayHeightMM
+ XDisplayKeycodes
+ XDisplayMotionBufferSize
+ XDisplayName
+ XDisplayOfIM
+ XDisplayOfOM
+ XDisplayOfScreen
+ XDisplayPlanes
+ XDisplayString
+ XDisplayWidth
+ XDisplayWidthMM
+ XDoesBackingStore
+ XDoesSaveUnders
+ XDrawArc
+ XDrawArcs
+ XDrawImageString
+ XDrawImageString16
+ XDrawLine
+ XDrawLines
+ XDrawPoint
+ XDrawPoints
+ XDrawRectangle
+ XDrawRectangles
+ XDrawSegments
+ XDrawString
+ XDrawString16
+ XDrawText
+ XDrawText16
+ XEHeadOfExtensionList
+ XESetBeforeFlush
+ XESetCloseDisplay
+ XESetCopyGC
+ XESetCreateFont
+ XESetCreateGC
+ XESetError
+ XESetErrorString
+ XESetEventToWire
+ XESetFlushGC
+ XESetFreeFont
+ XESetFreeGC
+ XESetPrintErrorValues
+ XESetWireToError
+ XESetWireToEvent
+ XEmptyRegion
+ XEnableAccessControl
+ XEqualRegion
+ XEventMaskOfScreen
+ XEventsQueued
+ XExtendedMaxRequestSize
+ XExtentsOfFontSet
+ XFetchBuffer
+ XFetchBytes
+ XFetchName
+ XFillArc
+ XFillArcs
+ XFillPolygon
+ XFillRectangle
+ XFillRectangles
+ XFilterEvent
+ XFindContext
+ XFindOnExtensionList
+ XFlush
+ XFlushGC
+ XFontsOfFontSet
+ XForceScreenSaver
+ XFree
+ XFreeColormap
+ XFreeColors
+ XFreeCursor
+ XFreeExtensionList
+ XFreeFont
+ XFreeFontInfo
+ XFreeFontNames
+ XFreeFontPath
+ XFreeFontSet
+ XFreeGC
+ XFreeModifiermap
+ XFreePixmap
+ XFreeStringList
+ XGContextFromGC
+ XGeometry
+ XGetAtomName
+ XGetAtomNames
+ XGetClassHint
+ XGetCommand
+ XGetDefault
+ XGetErrorDatabaseText
+ XGetErrorText
+ XGetFontPath
+ XGetFontProperty
+ XGetGCValues
+ XGetGeometry
+ XGetICValues
+ XGetIMValues
+ XGetIconName
+ XGetIconSizes
+ XGetImage
+ XGetInputFocus
+ XGetKeyboardControl
+ XGetKeyboardMapping
+ XGetModifierMapping
+ XGetMotionEvents
+ XGetNormalHints
+ XGetOCValues
+ XGetOMValues
+ XGetPixel
+ XGetPointerControl
+ XGetPointerMapping
+ XGetRGBColormaps
+ XGetScreenSaver
+ XGetSelectionOwner
+ XGetSizeHints
+ XGetStandardColormap
+ XGetSubImage
+ XGetTextProperty
+ XGetTransientForHint
+ XGetVisualInfo
+ XGetWMClientMachine
+ XGetWMColormapWindows
+ XGetWMHints
+ XGetWMIconName
+ XGetWMName
+ XGetWMNormalHints
+ XGetWMProtocols
+ XGetWMSizeHints
+ XGetWindowAttributes
+ XGetWindowProperty
+ XGetZoomHints
+ XGrabButton
+ XGrabKey
+ XGrabKeyboard
+ XGrabPointer
+ XGrabServer
+ XHeightMMOfScreen
+ XHeightOfScreen
+ XIMOfIC
+ XIconifyWindow
+ XIfEvent
+ XImageByteOrder
+ XInitExtension
+ XInitImage
+ XInitThreads
+ XInsertModifiermapEntry
+ XInstallColormap
+ XInternAtom
+ XInternAtoms
+ XInternalConnectionNumbers
+ XIntersectRegion
+ XKeycodeToKeysym
+ XKeysymToKeycode
+ XKeysymToString
+ XKillClient
+ XLastKnownRequestProcessed
+ XListDepths
+ XListExtensions
+ XListFonts
+ XListFontsWithInfo
+ XListHosts
+ XListInstalledColormaps
+ XListPixmapFormats
+ XListProperties
+ XLoadFont
+ XLoadQueryFont
+ XLocaleOfFontSet
+ XLocaleOfIM
+ XLocaleOfOM
+ XLockDisplay
+ XLookupColor
+ XLookupKeysym
+ XLookupString
+ XLowerWindow
+ XMapRaised
+ XMapSubwindows
+ XMapWindow
+ XMaskEvent
+ XMatchVisualInfo
+ XMaxCmapsOfScreen
+ XMaxRequestSize
+ XMinCmapsOfScreen
+ XMoveResizeWindow
+ XMoveWindow
+ XNewModifiermap
+ XNextEvent
+ XNextRequest
+ XNoOp
+ XOMOfOC
+ XOffsetRegion
+ XOpenDisplay
+ XOpenIM
+ XOpenOM
+ XParseColor
+ XParseGeometry
+ XPeekEvent
+ XPeekIfEvent
+ XPending
+ XPlanesOfScreen
+ XPointInRegion
+ XPolygonRegion
+ XProcessInternalConnection
+ XProtocolRevision
+ XProtocolVersion
+ XPutBackEvent
+ XPutImage
+ XPutPixel
+ XQLength
+ XQueryBestCursor
+ XQueryBestSize
+ XQueryBestStipple
+ XQueryBestTile
+ XQueryColor
+ XQueryColors
+ XQueryExtension
+ XQueryFont
+ XQueryKeymap
+ XQueryPointer
+ XQueryTextExtents
+ XQueryTextExtents16
+ XQueryTree
+ XRaiseWindow
+ XReadBitmapFile
+ XReadBitmapFileData
+ XRebindKeysym
+ XRecolorCursor
+ XReconfigureWMWindow
+ XRectInRegion
+ XRefreshKeyboardMapping
+ XRegisterIMInstantiateCallback
+ XRemoveConnectionWatch
+ XRemoveFromSaveSet
+ XRemoveHost
+ XRemoveHosts
+ XReparentWindow
+ XResetScreenSaver
+ XResizeWindow
+ XResourceManagerString
+ XRestackWindows
+ XRootWindow
+ XRootWindowOfScreen
+ XRotateBuffers
+ XRotateWindowProperties
+ XSaveContext
+ XScreenCount
+ XScreenNumberOfScreen
+ XScreenOfDisplay
+ XScreenResourceString
+ XSelectInput
+ XSendEvent
+ XServerVendor
+ XSetAccessControl
+ XSetAfterFunction
+ XSetArcMode
+ XSetAuthorization
+ XSetBackground
+ XSetClassHint
+ XSetClipMask
+ XSetClipOrigin
+ XSetClipRectangles
+ XSetCloseDownMode
+ XSetCommand
+ XSetDashes
+ XSetErrorHandler
+ XSetFillRule
+ XSetFillStyle
+ XSetFont
+ XSetFontPath
+ XSetForeground
+ XSetFunction
+ XSetGraphicsExposures
+ XSetICFocus
+ XSetICValues
+ XSetIMValues
+ XSetIOErrorHandler
+ XSetIconName
+ XSetIconSizes
+ XSetInputFocus
+ XSetLineAttributes
+ XSetLocaleModifiers
+ XSetModifierMapping
+ XSetNormalHints
+ XSetOCValues
+ XSetOMValues
+ XSetPlaneMask
+ XSetPointerMapping
+ XSetRGBColormaps
+ XSetRegion
+ XSetScreenSaver
+ XSetSelectionOwner
+ XSetSizeHints
+ XSetStandardColormap
+ XSetStandardProperties
+ XSetState
+ XSetStipple
+ XSetSubwindowMode
+ XSetTSOrigin
+ XSetTextProperty
+ XSetTile
+ XSetTransientForHint
+ XSetWMClientMachine
+ XSetWMColormapWindows
+ XSetWMHints
+ XSetWMIconName
+ XSetWMName
+ XSetWMNormalHints
+ XSetWMProperties
+ XSetWMProtocols
+ XSetWMSizeHints
+ XSetWindowBackground
+ XSetWindowBackgroundPixmap
+ XSetWindowBorder
+ XSetWindowBorderPixmap
+ XSetWindowBorderWidth
+ XSetWindowColormap
+ XSetZoomHints
+ XShrinkRegion
+ XStoreBuffer
+ XStoreBytes
+ XStoreColor
+ XStoreColors
+ XStoreName
+ XStoreNamedColor
+ XStringListToTextProperty
+ XStringToKeysym
+ XSubImage
+ XSubtractRegion
+ XSupportsLocale
+ XSync
+ XSynchronize
+ XTextExtents
+ XTextExtents16
+ XTextPropertyToStringList
+ XTextWidth
+ XTextWidth16
+ XTranslateCoordinates
+ XUndefineCursor
+ XUngrabButton
+ XUngrabKey
+ XUngrabKeyboard
+ XUngrabPointer
+ XUngrabServer
+ XUninstallColormap
+ XUnionRectWithRegion
+ XUnionRegion
+ XUnloadFont
+ XUnlockDisplay
+ XUnmapSubwindows
+ XUnmapWindow
+ XUnregisterIMInstantiateCallback
+ XUnsetICFocus
+ XVaCreateNestedList
+ XVendorRelease
+ XVisualIDFromVisual
+ XWMGeometry
+ XWarpPointer
+ XWhitePixel
+ XWhitePixelOfScreen
+ XWidthMMOfScreen
+ XWidthOfScreen
+ XWindowEvent
+ XWithdrawWindow
+ XWriteBitmapFile
+ XXorRegion
+ XcmsAddColorSpace
+ XcmsAddFunctionSet
+ XcmsAllocColor
+ XcmsAllocNamedColor
+ XcmsCCCOfColormap
+ XcmsCIELabClipL
+ XcmsCIELabClipLab
+ XcmsCIELabClipab
+ XcmsCIELabQueryMaxC
+ XcmsCIELabQueryMaxL
+ XcmsCIELabQueryMaxLC
+ XcmsCIELabQueryMinL
+ XcmsCIELabToCIEXYZ
+ XcmsCIELabWhiteShiftColors
+ XcmsCIELuvClipL
+ XcmsCIELuvClipLuv
+ XcmsCIELuvClipuv
+ XcmsCIELuvQueryMaxC
+ XcmsCIELuvQueryMaxL
+ XcmsCIELuvQueryMaxLC
+ XcmsCIELuvQueryMinL
+ XcmsCIELuvToCIEuvY
+ XcmsCIELuvWhiteShiftColors
+ XcmsCIEXYZToCIELab
+ XcmsCIEXYZToCIEuvY
+ XcmsCIEXYZToCIExyY
+ XcmsCIEXYZToRGBi
+ XcmsCIEuvYToCIELuv
+ XcmsCIEuvYToCIEXYZ
+ XcmsCIEuvYToTekHVC
+ XcmsCIExyYToCIEXYZ
+ XcmsClientWhitePointOfCCC
+ XcmsConvertColors
+ XcmsCreateCCC
+ XcmsDefaultCCC
+ XcmsDisplayOfCCC
+ XcmsFormatOfPrefix
+ XcmsFreeCCC
+ XcmsLookupColor
+ XcmsPrefixOfFormat
+ XcmsQueryBlack
+ XcmsQueryBlue
+ XcmsQueryColor
+ XcmsQueryColors
+ XcmsQueryGreen
+ XcmsQueryRed
+ XcmsQueryWhite
+ XcmsRGBToRGBi
+ XcmsRGBiToCIEXYZ
+ XcmsRGBiToRGB
+ XcmsScreenNumberOfCCC
+ XcmsScreenWhitePointOfCCC
+ XcmsSetCCCOfColormap
+ XcmsSetCompressionProc
+ XcmsSetWhiteAdjustProc
+ XcmsSetWhitePoint
+ XcmsStoreColor
+ XcmsStoreColors
+ XcmsTekHVCClipC
+ XcmsTekHVCClipV
+ XcmsTekHVCClipVC
+ XcmsTekHVCQueryMaxC
+ XcmsTekHVCQueryMaxV
+ XcmsTekHVCQueryMaxVC
+ XcmsTekHVCQueryMaxVSamples
+ XcmsTekHVCQueryMinV
+ XcmsTekHVCToCIEuvY
+ XcmsTekHVCWhiteShiftColors
+ XcmsVisualOfCCC
+ XmbDrawImageString
+ XmbDrawString
+ XmbDrawText
+ XmbLookupString
+ XmbResetIC
+ XmbSetWMProperties
+ XmbTextEscapement
+ XmbTextExtents
+ XmbTextListToTextProperty
+ XmbTextPerCharExtents
+ XmbTextPropertyToTextList
+ Xpermalloc
+ XrmCombineDatabase
+ XrmCombineFileDatabase
+ XrmDestroyDatabase
+ XrmEnumerateDatabase
+ XrmGetDatabase
+ XrmGetFileDatabase
+ XrmGetResource
+ XrmGetStringDatabase
+ XrmInitialize
+ XrmLocaleOfDatabase
+ XrmMergeDatabases
+ XrmParseCommand
+ XrmPermStringToQuark
+ XrmPutFileDatabase
+ XrmPutLineResource
+ XrmPutResource
+ XrmPutStringResource
+ XrmQGetResource
+ XrmQGetSearchList
+ XrmQGetSearchResource
+ XrmQPutResource
+ XrmQPutStringResource
+ XrmQuarkToString
+ XrmSetDatabase
+ XrmStringToBindingQuarkList
+ XrmStringToQuark
+ XrmStringToQuarkList
+ XrmUniqueQuark
+ XwcDrawImageString
+ XwcDrawString
+ XwcDrawText
+ XwcFreeStringList
+ XwcLookupString
+ XwcResetIC
+ XwcTextEscapement
+ XwcTextExtents
+ XwcTextListToTextProperty
+ XwcTextPerCharExtents
+ XwcTextPropertyToTextList
+ _XAllocID
+ _XAllocIDs
+ _XAllocScratch
+ _XAllocTemp
+ _XAsyncErrorHandler
+ _XConnectDisplay
+ _XDeqAsyncHandler
+ _XEatData
+ _XError
+#ifndef __UNIXOS2__
+ _XFlushIt
+#endif
+ _XFlushGCCache
+ _XFreeTemp
+ _XGetAsyncData
+ _XGetAsyncReply
+ _XIOError
+ _XInitImageFuncPtrs
+ _XRead
+;_XReadEvents
+ _XReadPad
+ _XRegisterFilterByMask
+ _XRegisterFilterByType
+ _XRegisterInternalConnection
+ _XReply
+ _XSend
+ _XSetLastRequestRead
+ _XUnknownNativeEvent
+ _XUnregisterFilter
+ _XUnregisterInternalConnection
+ _XVIDtoVisual
+#ifndef __UNIXOS2__
+ _Xthread_init
+ _Xthread_waiter
+#endif
+ XkbIgnoreExtension
+ XkbOpenDisplay
+ XkbQueryExtension
+ XkbUseExtension
+ XkbLibraryVersion
+ XkbSetXlibControls
+ XkbGetXlibControls
+ XkbSetAtomFuncs
+ XkbKeycodeToKeysym
+ XkbKeysymToModifiers
+ XkbLookupKeySym
+ XkbLookupKeyBinding
+ XkbTranslateKeyCode
+ XkbTranslateKeySym
+ XkbSetAutoRepeatRate
+ XkbGetAutoRepeatRate
+ XkbChangeEnabledControls
+ XkbDeviceBell
+ XkbForceDeviceBell
+ XkbDeviceBellEvent
+ XkbBell
+ XkbForceBell
+ XkbBellEvent
+ XkbSelectEvents
+ XkbSelectEventDetails
+ XkbNoteMapChanges
+ XkbNoteNameChanges
+ XkbGetIndicatorState
+ XkbGetIndicatorMap
+ XkbSetIndicatorMap
+ XkbGetNamedIndicator
+ XkbGetNamedDeviceIndicator
+ XkbSetNamedIndicator
+ XkbSetNamedDeviceIndicator
+ XkbLockModifiers
+ XkbLatchModifiers
+ XkbLockGroup
+ XkbLatchGroup
+ XkbSetServerInternalMods
+ XkbSetIgnoreLockMods
+ XkbVirtualModsToReal
+ XkbComputeEffectiveMap
+ XkbInitCanonicalKeyTypes
+ XkbAllocKeyboard
+ XkbFreeKeyboard
+ XkbAllocClientMap
+ XkbAllocServerMap
+ XkbFreeClientMap
+ XkbFreeServerMap
+ XkbAddKeyType
+ XkbAllocIndicatorMaps
+ XkbFreeIndicatorMaps
+ XkbGetMap
+ XkbGetUpdatedMap
+ XkbGetMapChanges
+ XkbRefreshKeyboardMapping
+ XkbGetKeyTypes
+ XkbGetKeySyms
+ XkbGetKeyActions
+ XkbGetKeyBehaviors
+ XkbGetVirtualMods
+ XkbGetKeyExplicitComponents
+ XkbGetKeyModifierMap
+ XkbAllocControls
+ XkbFreeControls
+ XkbGetControls
+ XkbSetControls
+ XkbAllocCompatMap
+ XkbFreeCompatMap
+ XkbGetCompatMap
+ XkbSetCompatMap
+ XkbAllocNames
+ XkbGetNames
+ XkbSetNames
+ XkbChangeNames
+ XkbFreeNames
+ XkbGetState
+ XkbSetMap
+ XkbChangeMap
+ XkbSetDetectableAutoRepeat
+ XkbGetDetectableAutoRepeat
+ XkbSetAutoResetControls
+ XkbGetAutoResetControls
+ XkbCopyKeyType
+ XkbCopyKeyTypes
+ XkbResizeKeyType
+ XkbResizeKeySyms
+ XkbResizeKeyActions
+ XkbChangeTypesOfKey
+ XkbListComponents
+ XkbFreeComponentList
+ XkbGetKeyboard
+ XkbGetKeyboardByName
+ XkbAddDeviceLedInfo
+ XkbResizeDeviceButtonActions
+ XkbAllocDeviceInfo
+ XkbFreeDeviceInfo
+ XkbNoteDeviceChanges
+ XkbGetDeviceInfo
+ XkbGetDeviceInfoChanges
+ XkbGetDeviceButtonActions
+ XkbGetDeviceLedInfo
+ XkbSetDeviceInfo
+ XkbChangeDeviceInfo
+ XkbSetDeviceLedInfo
+ XkbSetDeviceButtonActions
+ XkbToControl
+ XkbSetDebuggingFlags
+ XkbGetPerClientControls
+ XkbSetPerClientControls
+ XauDisposeAuth
+ XauFileName
+ XauGetBestAuthByAddr
+ XauReadAuth
+ XcmsCIELabColorSpace
+ XcmsCIELuvColorSpace
+ XcmsCIEuvYColorSpace
+ XcmsCIExyYColorSpace
+ XcmsCIEXYZColorSpace
+ XcmsLinearRGBFunctionSet
+ XcmsRGBColorSpace
+ XcmsRGBiColorSpace
+ XcmsTekHVCColorSpace
+ XcmsUNDEFINEDColorSpace
+ _XimParseStringFile /* unspecified, retain slot for binary compat */
+ XkbAddGeomColor
+ XkbAddGeomDoodad
+ XkbAddGeomKey
+ XkbAddGeomKeyAlias
+ XkbAddGeomOutline
+ XkbAddGeomOverlay
+ XkbAddGeomOverlayKey
+ XkbAddGeomOverlayRow
+ XkbAddGeomProperty
+ XkbAddGeomRow
+ XkbAddGeomSection
+ XkbAddGeomShape
+ XkbAllocGeomColors
+ XkbAllocGeomDoodads
+ XkbAllocGeometry
+ XkbAllocGeomKeyAliases
+ XkbAllocGeomKeys
+ XkbAllocGeomOutlines
+ XkbAllocGeomOverlayKeys
+ XkbAllocGeomOverlayRows
+ XkbAllocGeomOverlays
+ XkbAllocGeomPoints
+ XkbAllocGeomProps
+ XkbAllocGeomRows
+ XkbAllocGeomSectionDoodads
+ XkbAllocGeomSections
+ XkbAllocGeomShapes
+ XkbApplyCompatMapToKey
+ XkbApplyVirtualModChanges
+ XkbComputeRowBounds
+ XkbComputeSectionBounds
+ XkbComputeShapeBounds
+ XkbComputeShapeTop
+ XkbFindOverlayForKey
+ XkbFreeGeomColors
+ XkbFreeGeomDoodads
+ XkbFreeGeometry
+ XkbFreeGeomKeyAliases
+ XkbFreeGeomKeys
+ XkbFreeGeomOutlines
+ XkbFreeGeomOverlayKeys
+ XkbFreeGeomOverlayRows
+ XkbFreeGeomOverlays
+ XkbFreeGeomPoints
+ XkbFreeGeomProperties
+ XkbFreeGeomRows
+ XkbFreeGeomSections
+ XkbFreeGeomShapes
+ XkbGetGeometry
+ XkbGetKeyVirtualModMap
+ XkbGetNamedGeometry
+ XkbKeyTypesForCoreSymbols
+ XkbNoteControlsChanges
+ XkbSetGeometry
+ XkbTranslateKey
+ XkbUpdateActionVirtualMods
+ XkbUpdateKeyTypeVirtualMods
+ XkbUpdateMapFromCore
+ XkbXlibControlsImplemented
+ Xutf8TextPropertyToTextList
+ Xutf8TextListToTextProperty
+#else
+ XSaveContext
+ XFindContext
+ XDeleteContext
+ XListDepths
+ XrmParseCommand
+ Xpermalloc
+ _XrmInternalStringToQuark
+ XrmStringToQuark
+ XrmPermStringToQuark
+ XrmUniqueQuark
+ XrmQuarkToString
+ XAllocColorCells
+ XAllocColorPlanes
+ XAllowEvents
+ XAutoRepeatOn
+ XAutoRepeatOff
+ XSetWindowBackground
+ XSetWindowBorderWidth
+ XBell
+ XSetWindowBorder
+ XEnableAccessControl
+ XDisableAccessControl
+ XSetAccessControl
+ XSetCloseDownMode
+ XChangeActivePointerGrab
+ XSetWindowColormap
+ XChangeGC
+ XChangeKeyboardControl
+ XChangePointerControl
+ XChangeProperty
+ XChangeSaveSet
+ XAddToSaveSet
+ XRemoveFromSaveSet
+ XChangeWindowAttributes
+ XResizeWindow
+ XCheckIfEvent
+ XCheckMaskEvent
+ XCheckWindowEvent
+ XCheckTypedEvent
+ XCheckTypedWindowEvent
+ XCirculateSubwindows
+ XCirculateSubwindowsDown
+ XCirculateSubwindowsUp
+ XCloseDisplay
+ XClearWindow
+ XClearArea
+ XMoveResizeWindow
+ _XConnectDisplay
+ _XDisconnectDisplay
+ _XSendClientPrefix
+ XSetAuthorization
+ XConvertSelection
+ XCopyArea
+ XCopyColormapAndFree
+ XCopyGC
+ XCopyPlane
+ XCreateBitmapFromData
+ XCreateColormap
+ XCreatePixmapCursor
+ XCreateGC
+ _XUpdateGCCache
+ _XFlushGCCache
+ XFlushGC
+ XGContextFromGC
+ XCreateGlyphCursor
+ XCreatePixmapFromBitmapData
+ XCreatePixmap
+ XCreateSimpleWindow
+ XCreateFontCursor
+ XDefineCursor
+ XDeleteProperty
+ XDestroySubwindows
+ XDestroyWindow
+ XDisplayName
+ XDrawArc
+ XDrawArcs
+ XDrawLine
+ XDrawLines
+ XDrawPoint
+ XDrawPoints
+ XDrawRectangle
+ XDrawRectangles
+ XDrawSegments
+ XGetErrorText
+ XGetErrorDatabaseText
+ XSetErrorHandler
+ XSetIOErrorHandler
+ _XEventToWire
+ XFetchName
+ XGetIconName
+ XFillArc
+ XFillArcs
+ XFillPolygon
+ XFillRectangle
+ XFillRectangles
+ XFlush
+ XLoadQueryFont
+ XFreeFont
+ XQueryFont
+ XListFonts
+ XFreeFontNames
+ XListFontsWithInfo
+ XFreeFontInfo
+ XFreeColormap
+ XFreeColors
+ XFreeCursor
+ _XFreeExtData
+ XFreeGC
+ XFreePixmap
+ XActivateScreenSaver
+ XResetScreenSaver
+ XForceScreenSaver
+ XSetArcMode
+ XSetFillRule
+ XSetFillStyle
+ XSetGraphicsExposures
+ XSetSubwindowMode
+ XGeometry
+ XGetAtomName
+ XAllocNamedColor
+ XGetDefault
+ XGetFontPath
+ XFreeFontPath
+ XGetFontProperty
+ XGetGeometry
+ XAllocColor
+ XGetSizeHints
+ XGetWMHints
+ XGetZoomHints
+ XGetNormalHints
+ XGetIconSizes
+ XGetCommand
+ XGetTransientForHint
+ XGetClassHint
+ XGetInputFocus
+ XGetImage
+ XGetSubImage
+ XGetKeyboardControl
+ XGetMotionEvents
+ XGetPointerControl
+ XGetPointerMapping
+ XGetKeyboardMapping
+ XGetWindowProperty
+ XGetSelectionOwner
+ XGetScreenSaver
+ XGetStandardColormap
+ XGetWindowAttributes
+ XGrabButton
+ XGrabKey
+ XGrabKeyboard
+ XGrabPointer
+ XGrabServer
+ XAddHost
+ XRemoveHost
+ XAddHosts
+ XRemoveHosts
+ XIfEvent
+ XCreateImage
+ _XSetImage
+ _XInitImageFuncPtrs
+ XDrawImageString
+ XDrawImageString16
+ XInitExtension
+ XAddExtension
+ XEHeadOfExtensionList
+ XAddToExtensionList
+ XFindOnExtensionList
+ XESetCreateGC
+ XESetCopyGC
+ XESetFlushGC
+ XESetFreeGC
+ XESetCreateFont
+ XESetFreeFont
+ XESetCloseDisplay
+ XESetWireToEvent
+ XESetEventToWire
+ XESetWireToError
+ XESetError
+ XESetErrorString
+ XESetPrintErrorValues
+ XInstallColormap
+ XInternAtom
+ XKeycodeToKeysym
+ XKeysymToKeycode
+ XLookupKeysym
+ XRefreshKeyboardMapping
+ XLookupString
+ XRebindKeysym
+ XKeysymToString
+ XKillClient
+ XListHosts
+ XListInstalledColormaps
+ XListProperties
+ XListExtensions
+ XFreeExtensionList
+ XLoadFont
+ XLookupColor
+ XLowerWindow
+ XConnectionNumber
+ XRootWindow
+ XDefaultScreen
+ XDefaultRootWindow
+ XDefaultVisual
+ XDefaultGC
+ XBlackPixel
+ XWhitePixel
+ XAllPlanes
+ XQLength
+ XDisplayWidth
+ XDisplayHeight
+ XDisplayWidthMM
+ XDisplayHeightMM
+ XDisplayPlanes
+ XDisplayCells
+ XScreenCount
+ XServerVendor
+ XProtocolVersion
+ XProtocolRevision
+ XVendorRelease
+ XDisplayString
+ XDefaultDepth
+ XDefaultColormap
+ XBitmapUnit
+ XBitmapBitOrder
+ XBitmapPad
+ XImageByteOrder
+ XNextRequest
+ XLastKnownRequestProcessed
+ XScreenOfDisplay
+ XDefaultScreenOfDisplay
+ XDisplayOfScreen
+ XRootWindowOfScreen
+ XBlackPixelOfScreen
+ XWhitePixelOfScreen
+ XDefaultColormapOfScreen
+ XDefaultDepthOfScreen
+ XDefaultGCOfScreen
+ XDefaultVisualOfScreen
+ XWidthOfScreen
+ XHeightOfScreen
+ XWidthMMOfScreen
+ XHeightMMOfScreen
+ XPlanesOfScreen
+ XCellsOfScreen
+ XMinCmapsOfScreen
+ XMaxCmapsOfScreen
+ XDoesSaveUnders
+ XDoesBackingStore
+ XEventMaskOfScreen
+ XScreenNumberOfScreen
+ XDestroyImage
+ XGetPixel
+ XPutPixel
+ XSubImage
+ XAddPixel
+ XNoOp
+ XMapRaised
+ XMapSubwindows
+ XMapWindow
+ XMaskEvent
+ XMaxRequestSize
+ XResourceManagerString
+ XDisplayMotionBufferSize
+ XDisplayKeycodes
+ XVisualIDFromVisual
+ XGetModifierMapping
+ XSetModifierMapping
+ XNewModifiermap
+ XFreeModifiermap
+ XInsertModifiermapEntry
+ XDeleteModifiermapEntry
+ XMoveWindow
+ XNextEvent
+ XOpenDisplay
+ _XFreeDisplayStructure
+ XParseColor
+ XParseGeometry
+ XPeekEvent
+ XPeekIfEvent
+ XEventsQueued
+ XPending
+ XSetWindowBackgroundPixmap
+ XSetWindowBorderPixmap
+ XPolygonRegion
+ XDrawText
+ XDrawText16
+ XPutBackEvent
+ _XReverse_Bytes
+ XPutImage
+ XQueryBestSize
+ XQueryColor
+ XQueryColors
+ XQueryBestCursor
+ XQueryExtension
+ XQueryKeymap
+ XQueryPointer
+ XQueryBestStipple
+ XQueryTextExtents16
+ XQueryTextExtents
+ XQueryBestTile
+ XQueryTree
+ XRaiseWindow
+ XReadBitmapFile
+ XRecolorCursor
+ XConfigureWindow
+ XCreateRegion
+ XClipBox
+ XUnionRectWithRegion
+ XSetRegion
+ XDestroyRegion
+ XOffsetRegion
+ XShrinkRegion
+ XIntersectRegion
+ XUnionRegion
+ XSubtractRegion
+ XXorRegion
+ XEmptyRegion
+ XEqualRegion
+ XPointInRegion
+ XRectInRegion
+ XReparentWindow
+ XRestackWindows
+ XRotateWindowProperties
+ XScreenResourceString
+ XSelectInput
+ XSendEvent
+ XSetBackground
+ XSetClipRectangles
+ _XSetClipRectangles
+ XSetClipMask
+ XSetClipOrigin
+ XSetDashes
+ XSetFontPath
+ XSetFont
+ XSetForeground
+ XSetFunction
+ XSetSizeHints
+ XSetWMHints
+ XSetZoomHints
+ XSetNormalHints
+ XSetIconSizes
+ XSetCommand
+ XSetStandardProperties
+ XSetTransientForHint
+ XSetClassHint
+ XSetInputFocus
+ XSetLineAttributes
+ XSetPlaneMask
+ XSetPointerMapping
+ XChangeKeyboardMapping
+ XSetSelectionOwner
+ XSetScreenSaver
+ XSetState
+ XSetStipple
+ XSetStandardColormap
+ XSetTile
+ XSetTSOrigin
+ XRotateBuffers
+ XFetchBuffer
+ XFetchBytes
+ XStoreBuffer
+ XStoreBytes
+ XStoreColor
+ XStoreColors
+ XStoreNamedColor
+ XStoreName
+ XSetIconName
+ _XInitKeysymDB
+ XStringToKeysym
+ XSync
+ _XSyncFunction
+ XSynchronize
+ XSetAfterFunction
+ XDrawString
+ XDrawString16
+ XTextExtents
+ XTextWidth
+ XTextExtents16
+ XTextWidth16
+ XTranslateCoordinates
+ XUndefineCursor
+ XUngrabButton
+ XUngrabKeyboard
+ XUngrabKey
+ XUngrabPointer
+ XUngrabServer
+ XUninstallColormap
+ XUnloadFont
+ XUnmapSubwindows
+ XUnmapWindow
+ XGetVisualInfo
+ XMatchVisualInfo
+ XWarpPointer
+ XWindowEvent
+ XCreateWindow
+ _XProcessWindowAttributes
+ XWriteBitmapFile
+ _XFlush
+ _XEventsQueued
+ _XReadEvents
+ _XRead
+ _XReadPad
+ _XSend
+ _XAllocID
+ _XSetLastRequestRead
+ _XReply
+ _XEatData
+ _XEnq
+ _XUnknownWireEvent
+ _XUnknownNativeEvent
+ _XWireToEvent
+ _XDefaultIOError
+ _XDefaultError
+ _XDefaultWireError
+ _XError
+ _XIOError
+ _XAllocScratch
+ _XVIDtoVisual
+ XFree
+ _XGetHostname
+ _XScreenOfWindow
+ _XAllocIDs
+ _XAllocTemp
+ _XFreeTemp
+ XrmInitialize
+ XrmGetDatabase
+ XrmSetDatabase
+ XrmStringToQuarkList
+ XrmStringToBindingQuarkList
+ XrmCombineDatabase
+ XrmMergeDatabases
+ XrmQPutResource
+ XrmPutResource
+ XrmQPutStringResource
+ XrmPutStringResource
+ XrmPutLineResource
+ XrmGetStringDatabase
+ XrmGetFileDatabase
+ XrmCombineFileDatabase
+ XrmEnumerateDatabase
+ XrmPutFileDatabase
+ XrmQGetSearchList
+ XrmQGetSearchResource
+ XrmQGetResource
+ XrmGetResource
+ XrmLocaleOfDatabase
+ XrmDestroyDatabase
+ XGetGCValues
+ XGetWMSizeHints
+ XGetWMNormalHints
+ XGetRGBColormaps
+ XGetTextProperty
+ XGetWMName
+ XGetWMIconName
+ XGetWMClientMachine
+ XGetWMColormapWindows
+ XGetWMProtocols
+ XIconifyWindow
+ XListPixmapFormats
+ XAllocSizeHints
+ XAllocStandardColormap
+ XAllocWMHints
+ XAllocClassHint
+ XAllocIconSize
+ XReconfigureWMWindow
+ XSetWMSizeHints
+ XSetWMNormalHints
+ XSetRGBColormaps
+ XSetTextProperty
+ XSetWMName
+ XSetWMIconName
+ XSetWMClientMachine
+ XSetWMColormapWindows
+ XSetWMProperties
+ XSetWMProtocols
+ XStringListToTextProperty
+ XTextPropertyToStringList
+ XFreeStringList
+ XWMGeometry
+ XWithdrawWindow
+ XauDisposeAuth
+ XauGetBestAuthByAddr
+ XauFileName
+ XauReadAuth
+ XcmsCIELabToCIEXYZ
+ XcmsCIEXYZToCIELab
+ XcmsCIELabClipab
+ XcmsCIELabClipL
+ XcmsCIELabClipLab
+ XcmsCIELabQueryMinL
+ XcmsCIELabQueryMaxC
+ XcmsCIELabQueryMaxL
+ _XcmsCIELabQueryMaxLCRGB
+ XcmsCIELabQueryMaxLC
+ XcmsCIELabWhiteShiftColors
+ XcmsCIELuvToCIEuvY
+ XcmsCIEuvYToCIELuv
+ XcmsCIELuvClipuv
+ XcmsCIELuvClipL
+ XcmsCIELuvClipLuv
+ XcmsCIELuvQueryMinL
+ XcmsCIELuvQueryMaxC
+ XcmsCIELuvQueryMaxL
+ _XcmsCIELuvQueryMaxLCRGB
+ XcmsCIELuvQueryMaxLC
+ XcmsCIELuvWhiteShiftColors
+ XcmsCIEuvYToCIEXYZ
+ XcmsCIEXYZToCIEuvY
+ XcmsCIExyYToCIEXYZ
+ XcmsCIEXYZToCIExyY
+ XcmsTekHVCToCIEuvY
+ XcmsCIEuvYToTekHVC
+ _XcmsTekHVC_CheckModify
+ XcmsTekHVCClipC
+ XcmsTekHVCClipV
+ XcmsTekHVCClipVC
+ XcmsTekHVCQueryMinV
+ XcmsTekHVCQueryMaxC
+ XcmsTekHVCQueryMaxV
+ _XcmsTekHVCQueryMaxVCRGB
+ XcmsTekHVCQueryMaxVC
+ XcmsTekHVCQueryMaxVSamples
+ XcmsTekHVCWhiteShiftColors
+ XcmsAddColorSpace
+ XcmsAddFunctionSet
+ XcmsAllocNamedColor
+ XcmsAllocColor
+ XcmsCreateCCC
+ XcmsDefaultCCC
+ XcmsFreeCCC
+ _XcmsAddCmapRec
+ _XcmsCopyCmapRecAndFree
+ _XcmsDeleteCmapRec
+ XcmsCCCOfColormap
+ _XcmsCopyISOLatin1Lowered
+ _XcmsResolveColorString
+ _XcmsConvertColorsWithWhitePt
+ _XcmsEqualWhitePts
+ _XcmsDIConvertColors
+ _XcmsDDConvertColors
+ XcmsConvertColors
+ _XcmsRegFormatOfPrefix
+ XcmsFormatOfPrefix
+ _XcmsCopyPointerArray
+ _XcmsFreePointerArray
+ _XcmsPushPointerArray
+ _XcmsInitDefaultCCCs
+ _XcmsInitScrnInfo
+ _XcmsFreeIntensityMaps
+ _XcmsGetIntensityMap
+ _XcmsGetTableType0
+ _XcmsGetTableType1
+ _XcmsValueCmp
+ _XcmsIntensityCmp
+ _XcmsValueInterpolation
+ _XcmsIntensityInterpolation
+ _XcmsTableSearch
+ _XcmsMatVec
+ XcmsCIEXYZToRGBi
+ XcmsRGBiToCIEXYZ
+ XcmsRGBiToRGB
+ XcmsRGBToRGBi
+ _XcmsLRGB_InitScrnDefault
+ XcmsLookupColor
+ _XcmsCubeRoot
+ _XcmsSquareRoot
+ XcmsDisplayOfCCC
+ XcmsVisualOfCCC
+ XcmsScreenNumberOfCCC
+ XcmsScreenWhitePointOfCCC
+ XcmsClientWhitePointOfCCC
+ XcmsPrefixOfFormat
+ _XcmsGetElement
+ _XcmsGetProperty
+ XcmsQueryBlack
+ XcmsQueryBlue
+ XcmsQueryGreen
+ XcmsQueryRed
+ XcmsQueryWhite
+ XcmsQueryColor
+ XcmsQueryColors
+ XcmsSetWhitePoint
+ XcmsSetCompressionProc
+ XcmsSetWhiteAdjustProc
+ _XcmsSetGetColors
+ XcmsStoreColor
+ XcmsStoreColors
+ _XcmsCosine
+ _XcmsSine
+ _XcmsArcTangent
+ _XcmsRGB_to_XColor
+ _XColor_to_XcmsRGB
+ _XcmsResolveColor
+ _XcmsUnresolveColor
+ _XUnresolveColor
+ _XParseBaseFontNameList
+ XCreateFontSet
+ XFontsOfFontSet
+ XBaseFontNameListOfFontSet
+ XLocaleOfFontSet
+ XContextDependentDrawing
+ XExtentsOfFontSet
+ XFreeFontSet
+ XVaCreateNestedList
+ XGetIMValues
+ XCreateIC
+ XDestroyIC
+ XGetICValues
+ XSetICValues
+ XSetICFocus
+ XUnsetICFocus
+ XIMOfIC
+ XmbResetIC
+ XwcResetIC
+ XmbLookupString
+ XwcLookupString
+ _XIMCompileResourceList
+ _XCopyToArg
+ XOpenIM
+ XCloseIM
+ XDisplayOfIM
+ XLocaleOfIM
+ XSetLocaleModifiers
+ XSupportsLocale
+ _XlcValidModSyntax
+ _XlcDefaultMapModifiers
+ _XlcAddLoader
+ _XlcCurrentLC
+ XmbSetWMProperties
+ XmbDrawText
+ XmbDrawString
+ XmbDrawImageString
+ XmbTextEscapement
+ XmbTextExtents
+ XmbTextPerCharExtents
+ XwcDrawText
+ XwcDrawString
+ XwcDrawImageString
+ XwcTextEscapement
+ XwcTextExtents
+ XwcTextPerCharExtents
+ XFilterEvent
+ _XRegisterFilterByMask
+ _XRegisterFilterByType
+ _XUnregisterFilter
+ XDefaultString
+ _XlcDefaultLoader
+ _XrmInitParseInfo
+ XmbTextPropertyToTextList
+ XmbTextListToTextProperty
+ XwcTextPropertyToTextList
+ XwcFreeStringList
+ XwcTextListToTextProperty
+ _X11TransConnectDisplay
+ XGetAtomNames
+ XInitImage
+ XESetBeforeFlush
+ _XFreeAtomTable
+ _XUpdateAtomCache
+ XInternAtoms
+ _XKeyInitialize
+ XConvertCase
+ _XTranslateKey
+ _XTranslateKeySym
+ _XKeysymToModifiers
+ XExtendedMaxRequestSize
+ XReadBitmapFileData
+ _XAsyncErrorHandler
+ _XDeqAsyncHandler
+ _XGetAsyncReply
+ _XGetAsyncData
+ _XPollfdCacheInit
+ _XPollfdCacheAdd
+ _XPollfdCacheDel
+ _XRegisterInternalConnection
+ _XUnregisterInternalConnection
+ XInternalConnectionNumbers
+ XProcessInternalConnection
+ XAddConnectionWatch
+ XRemoveConnectionWatch
+ _XDeq
+ _XcmsCIEXYZ_ValidSpec
+ _XcmsCIEuvY_ValidSpec
+ XcmsSetCCCOfColormap
+ XDirectionalDependentDrawing
+ XContextualDrawing
+ XSetIMValues
+ XRegisterIMInstantiateCallback
+ XUnregisterIMInstantiateCallback
+ XCreateOC
+ XDestroyOC
+ XOMOfOC
+ XSetOCValues
+ XGetOCValues
+ XOpenOM
+ XCloseOM
+ XSetOMValues
+ XGetOMValues
+ XDisplayOfOM
+ XLocaleOfOM
+ _XlcRemoveLoader
+ _XOpenLC
+ _XCloseLC
+ _XlcCopyFromArg
+ _XlcCopyToArg
+ _XlcCountVaList
+ _XlcVaToArgList
+ _XlcCompileResourceList
+ _XlcGetValues
+ _XlcSetValues
+ XInitThreads
+ XLockDisplay
+ XUnlockDisplay
+ _X11TransFreeConnInfo
+ _X11TransOpenCOTSClient
+ _X11TransOpenCLTSClient
+ _X11TransSetOption
+ _X11TransConnect
+ _X11TransBytesReadable
+ _X11TransRead
+ _X11TransWrite
+ _X11TransReadv
+ _X11TransWritev
+ _X11TransDisconnect
+ _X11TransClose
+ _X11TransCloseForCloning
+ _X11TransIsLocal
+ _X11TransGetMyAddr
+ _X11TransGetPeerAddr
+ _X11TransGetConnectionNumber
+ _X11TransGetHostname
+ _X11TransConvertAddress
+ _XimCbDispatch
+ _XimLookupMBText
+ _XimLookupWCText
+ _XimRegisterFilter
+ _XimUnregisterFilter
+ _XimReregisterFilter
+ _XimRegisterServerFilter
+ _XimUnregisterServerFilter
+ _XimProtoCreateIC
+ _XimCheckDataSize
+ _XimSetHeader
+ _XimProtoIMFree
+ _XimProtoOpenIM
+ _XimICOfXICID
+ _XimSetEventMaskCallback
+ _XimSync
+ _XimProcSyncReply
+ _XimRespSyncReply
+ _XimSyncCallback
+ _XimForwardEvent
+ _XimForwardEventCallback
+ _XimRegisterTriggerKeysCallback
+ _XimGetWindowEventmask
+ _XimTriggerNotify
+ _XimFreeCommitInfo
+ _XimCommitCallback
+ _XimProcError
+ _XimErrorCallback
+ _XimError
+ _Ximctstombs
+ _Ximctstowcs
+ _XimProtoMbLookupString
+ _XimProtoWcLookupString
+ _XimRegProtoIntrCallback
+ _XimFreeProtoIntrCallback
+ _XimDispatchInit
+ _XimProtoEventToWire
+ _XimProtoWireToEvent
+ _XimExtension
+ _XimRegisterIMInstantiateCallback
+ _XimUnRegisterIMInstantiateCallback
+ _XimResetIMInstantiateCallback
+ _XimDestroyIMStructureList
+ _XimServerDestroy
+ _XInitIM
+ _XimLocalFilter
+ _XimLocalGetICValues
+ _XimLocalCreateIC
+ _XimCheckIfLocalProcessing
+ _XimLocalIMFree
+ _XimLocalGetIMValues
+ _XimLocalSetIMValues
+ _XimLocalOpenIM
+ _XimLocalMbLookupString
+ _XimLocalWcLookupString
+ _XimParseStringFile
+ _XimSetICValueData
+ _XimLocalSetICValues
+ _XimSetIMResourceList
+ _XimSetICResourceList
+ _XimSetInnerIMResourceList
+ _XimSetInnerICResourceList
+ _XimCheckCreateICValues
+ _XimGetResourceListRec
+ _XimSetIMMode
+ _XimCheckIMMode
+ _XimSetICMode
+ _XimCheckICMode
+ _XimSetLocalIMDefaults
+ _XimSetICDefaults
+ _XimDecodeLocalIMAttr
+ _XimDecodeLocalICAttr
+ _XimCheckLocalInputStyle
+ _XimEncodeLocalIMAttr
+ _XimEncodeLocalICAttr
+ _XimGetCurrentIMValues
+ _XimSetCurrentIMValues
+ _XimGetCurrentICValues
+ _XimSetCurrentICValues
+ _XimInitialResourceInfo
+ _XimDecodeIMATTRIBUTE
+ _XimDecodeICATTRIBUTE
+ _XimEncodeIMATTRIBUTE
+ _XimEncodeICATTRIBUTE
+ _XimGetAttributeID
+ _XimThaiFilter
+ _XimThaiCreateIC
+ _XimCheckIfThaiProcessing
+ _XimThaiOpenIM
+ _XimThaiIMFree
+ _XimThaiCloseIM
+ _XimXConf
+ _XimConnect
+ _XimShutdown
+ _XimFlush
+ _XimFilterWaitEvent
+ _XimFreeTransIntrCallback
+ _XimTransFilterWaitEvent
+ _XimTransInternalConnection
+ _XimTransFlush
+ _XimTransConf
+ _XlcParseCharSet
+ _XlcInitCTInfo
+ _XlcGetCSValues
+ _XlcGetCharSet
+ _XlcAddCharSet
+ _XlcCreateDefaultCharSet
+ _XlcSetConverter
+ _XlcOpenConverter
+ _XlcCloseConverter
+ _XlcConvert
+ _XlcResetConverter
+ _XlcGetResource
+ _XlcGetLocaleDataBase
+ _XlcDestroyLocaleDataBase
+ _XlcCreateLocaleDataBase
+ _XlcEucLoader
+ _XlcFileName
+ _XlcResolveLocaleName
+;REMOVED _XlcResolveDBName
+ _XlcResolveI18NPath
+ _XlcGenericLoader
+ _XlcInitLoader
+ _XmbTextPropertyToTextList
+ _XwcTextPropertyToTextList
+ _XwcFreeStringList
+ _XGetLCValues
+ _XlcDestroyLC
+ _XlcCreateLC
+ _XrmDefaultInitParseInfo
+ _XlcSjisLoader
+ _Xlcmbtowc
+ _Xlcwctomb
+ _Xlcmbstowcs
+ _Xlcwcstombs
+ _Xmbtowc
+ _Xwctomb
+ _Xmbstowcs
+ _Xwcstombs
+ _Xwcscpy
+ _Xwcsncpy
+ _Xwcslen
+ _Xwcscmp
+ _Xwcsncmp
+ _XmbTextListToTextProperty
+ _XwcTextListToTextProperty
+; _XlcUtfLoader
+ _XlcCompareISOLatin1
+ _XlcNCompareISOLatin1
+ _XmbDefaultTextEscapement
+ _XwcDefaultTextEscapement
+ _XmbDefaultTextExtents
+ _XwcDefaultTextExtents
+ _XmbDefaultTextPerCharExtents
+ _XwcDefaultTextPerCharExtents
+ _XmbDefaultDrawString
+ _XwcDefaultDrawString
+ _XmbDefaultDrawImageString
+ _XwcDefaultDrawImageString
+ _XomGenericOpenOM
+ _XInitOM
+ _XmbGenericDrawImageString
+ _XwcGenericDrawImageString
+ _XomGenericDrawString
+ _XmbGenericDrawString
+ _XwcGenericDrawString
+ _XmbGenericTextEscapement
+ _XwcGenericTextEscapement
+ _XomGenericTextExtents
+ _XmbGenericTextExtents
+ _XwcGenericTextExtents
+ _XmbGenericTextPerCharExtents
+ _XwcGenericTextPerCharExtents
+ _XomConvert
+ _XomInitConverter
+ _Xmblen
+ _XimGetResourceListRecByQuark
+ _XimSetIMValueData
+ _XimGetIMValueData
+ _XimGetICValueData
+ _XimMakeIMAttrIDList
+ _XimMakeICAttrIDList
+ _XimWrite
+ _XimRead
+ _XimRegisterDispatcher
+ _XimTransRegisterDispatcher
+ _XimTransCallDispatcher
+ _XimTransWrite
+ _XimTransRead
+ _XimXTransFreeConnInfo
+ _XimXTransOpenCOTSClient
+ _XimXTransOpenCLTSClient
+ _XimXTransSetOption
+ _XimXTransConnect
+ _XimXTransBytesReadable
+ _XimXTransRead
+ _XimXTransWrite
+ _XimXTransReadv
+ _XimXTransWritev
+ _XimXTransDisconnect
+ _XimXTransClose
+ _XimXTransCloseForCloning
+ _XimXTransIsLocal
+ _XimXTransGetMyAddr
+ _XimXTransGetPeerAddr
+ _XimXTransGetConnectionNumber
+ _XimXTransGetHostname
+ _Xdebug DATA
+ Xutf8TextPropertyToTextList
+ Xutf8TextListToTextProperty
+ Xutf8LookupString
+ XkbIgnoreExtension
+ XkbOpenDisplay
+ XkbQueryExtension
+ XkbUseExtension
+ XkbLibraryVersion
+ XkbSetXlibControls
+ XkbGetXlibControls
+ XkbSetAtomFuncs
+ XkbKeycodeToKeysym
+ XkbKeysymToModifiers
+ XkbLookupKeySym
+ XkbLookupKeyBinding
+ XkbTranslateKeyCode
+ XkbTranslateKeySym
+ XkbSetAutoRepeatRate
+ XkbGetAutoRepeatRate
+ XkbChangeEnabledControls
+ XkbDeviceBell
+ XkbForceDeviceBell
+ XkbDeviceBellEvent
+ XkbBell
+ XkbForceBell
+ XkbBellEvent
+ XkbSelectEvents
+ XkbSelectEventDetails
+ XkbNoteMapChanges
+ XkbNoteNameChanges
+ XkbGetIndicatorState
+ XkbGetIndicatorMap
+ XkbSetIndicatorMap
+ XkbGetNamedIndicator
+ XkbGetNamedDeviceIndicator
+ XkbSetNamedIndicator
+ XkbSetNamedDeviceIndicator
+ XkbLockModifiers
+ XkbLatchModifiers
+ XkbLockGroup
+ XkbLatchGroup
+ XkbSetServerInternalMods
+ XkbSetIgnoreLockMods
+ XkbVirtualModsToReal
+ XkbComputeEffectiveMap
+ XkbInitCanonicalKeyTypes
+ XkbAllocKeyboard
+ XkbFreeKeyboard
+ XkbAllocClientMap
+ XkbAllocServerMap
+ XkbFreeClientMap
+ XkbFreeServerMap
+ XkbAddKeyType
+ XkbAllocIndicatorMaps
+ XkbFreeIndicatorMaps
+ XkbGetMap
+ XkbGetUpdatedMap
+ XkbGetMapChanges
+ XkbRefreshKeyboardMapping
+ XkbGetKeyTypes
+ XkbGetKeySyms
+ XkbGetKeyActions
+ XkbGetKeyBehaviors
+ XkbGetVirtualMods
+ XkbGetKeyExplicitComponents
+ XkbGetKeyModifierMap
+ XkbAllocControls
+ XkbFreeControls
+ XkbGetControls
+ XkbSetControls
+ XkbAllocCompatMap
+ XkbFreeCompatMap
+ XkbGetCompatMap
+ XkbSetCompatMap
+ XkbAllocNames
+ XkbGetNames
+ XkbSetNames
+ XkbChangeNames
+ XkbFreeNames
+ XkbGetState
+ XkbSetMap
+ XkbChangeMap
+ XkbSetDetectableAutoRepeat
+ XkbGetDetectableAutoRepeat
+ XkbSetAutoResetControls
+ XkbGetAutoResetControls
+ XkbCopyKeyType
+ XkbCopyKeyTypes
+ XkbResizeKeyType
+ XkbResizeKeySyms
+ XkbResizeKeyActions
+ XkbChangeTypesOfKey
+ XkbListComponents
+ XkbFreeComponentList
+ XkbGetKeyboard
+ XkbGetKeyboardByName
+ XkbAddDeviceLedInfo
+ XkbResizeDeviceButtonActions
+ XkbAllocDeviceInfo
+ XkbFreeDeviceInfo
+ XkbNoteDeviceChanges
+ XkbGetDeviceInfo
+ XkbGetDeviceInfoChanges
+ XkbGetDeviceButtonActions
+ XkbGetDeviceLedInfo
+ XkbSetDeviceInfo
+ XkbChangeDeviceInfo
+ XkbSetDeviceLedInfo
+ XkbSetDeviceButtonActions
+ XkbToControl
+ XkbSetDebuggingFlags
+ _XkbInternAtomFunc
+ _XkbGetAtomNameFunc
+ _XkbReloadDpy
+ _XKeycodeToKeysym
+ _XKeysymToKeycode
+ _XLookupKeysym
+ _XRefreshKeyboardMapping
+ _XLookupString
+ _XkbNoteCoreMapChanges
+ _XkbInitReadBuffer
+ _XkbSkipReadBufferData
+ _XkbCopyFromReadBuffer
+ _XkbReadCopyKeySyms
+ _XkbWriteCopyKeySyms
+ _XkbReadBufferCopyKeySyms
+ _XkbPeekAtReadBuffer
+ _XkbGetReadBufferPtr
+ _XkbFreeReadBuffer
+ _XkbGetReadBufferCountedString
+ _XkbGetCharset
+ _XkbGetConverters
+ XkbGetGeometry
+ XkbAddGeomShape
+ XkbAddGeomOutline
+ XkbComputeShapeBounds
+ XkbAddGeomDoodad
+ XkbAddGeomColor
+ XkbAddGeomOverlayRow
+ XkbAddGeomSection
+ XkbAddGeomRow
+ XkbAddGeomKey
+ XkbComputeSectionBounds
+ XkbAllocGeometry
+ XkbAddGeomProperty
+ XkbAddGeomOverlay
+ XkbComputeShapeTop
+ XkbFindOverlayForKey
+ XkbAllocGeomKeyAliases
+ XkbSetGeometry
+ XkbXlibControlsImplemented
+ XkbTranslateKey
+ XkbAddGeomOverlayKey
+ XkbNoteControlsChanges
+ XkbGetKeyVirtualModMap
+ XkbComputeRowBounds
+ XkbGetNamedGeometry
+ XkbKeyTypesForCoreSymbols
+ XkbApplyCompatMapToKey
+ XkbUpdateMapFromCore
+ XkbUpdateActionVirtualMods
+ XkbUpdateKeyTypeVirtualMods
+ XkbApplyVirtualModChanges
+ XkbFreeGeomProperties
+ XkbFreeGeomKeyAliases
+ XkbFreeGeomColors
+ XkbFreeGeomPoints
+ XkbFreeGeomOutlines
+ XkbFreeGeomShapes
+ XkbFreeGeomOverlayKeys
+ XkbFreeGeomOverlayRows
+ XkbFreeGeomOverlays
+ XkbFreeGeomKeys
+ XkbFreeGeomRows
+ XkbFreeGeomSections
+ XkbFreeGeomDoodads
+ XkbFreeGeometry
+ XkbAllocGeomProps
+ XkbAllocGeomColors
+ XkbAllocGeomShapes
+ XkbAllocGeomSections
+ XkbAllocGeomOverlays
+ XkbAllocGeomOverlayRows
+ XkbAllocGeomOverlayKeys
+ XkbAllocGeomDoodads
+ XkbAllocGeomSectionDoodads
+ XkbAllocGeomOutlines
+ XkbAllocGeomRows
+ XkbAllocGeomPoints
+ XkbAllocGeomKeys
+ XkbAddGeomKeyAlias
+ _XkeyTable
+ _Xevent_to_mask
+ _qfree
+ _XIOErrorFunction
+ _XErrorFunction
+ _XHeadOfDisplayList
+ XcmsCIELabColorSpace
+ XcmsCIELuvColorSpace
+ XcmsCIEXYZColorSpace
+ XcmsCIEuvYColorSpace
+ XcmsCIExyYColorSpace
+ XcmsTekHVCColorSpace
+ XcmsUNDEFINEDColorSpace
+ _XcmsDIColorSpacesInit
+ _XcmsDIColorSpaces
+ _XcmsDDColorSpacesInit
+ _XcmsDDColorSpaces
+ _XcmsSCCFuncSetsInit
+ _XcmsSCCFuncSets
+ _XcmsCIEXYZ_prefix
+ _XcmsCIEuvY_prefix
+ _XcmsCIExyY_prefix
+ _XcmsCIELab_prefix
+ _XcmsCIELuv_prefix
+ _XcmsTekHVC_prefix
+ _XcmsRGBi_prefix
+ _XcmsRGB_prefix
+ _XcmsRegColorSpaces
+ XcmsRGBiColorSpace
+ XcmsRGBColorSpace
+ XcmsLinearRGBFunctionSet
+ _X11TransSocketINETFuncs
+ _X11TransSocketTCPFuncs
+ _XimXTransSocketINETFuncs
+ _XimXTransSocketTCPFuncs
+ _XimImSportRec
+ _XimTransportRec
+ _XlcGenericMethods
+ _XlcPublicMethods
+#ifdef HAS_THREADS
+ _XCreateMutex_fn DATA
+ _XFreeMutex_fn DATA
+ _XLockMutex_fn DATA
+ _XUnlockMutex_fn DATA
+ _Xglobal_lock DATA
+#endif
+#ifdef __UNIXOS2__
+; OS/2 specific exports
+ __XOS2RedirRoot
+ __XOS2RedirRoot1
+ _XGetScanlinePad
+ _XGetBitsPerPixel
+ _Xsetlocale
+ XkbGetPerClientControls
+ XkbSetPerClientControls
+ Xutf8DrawString
+ Xutf8TextExtents
+#endif
+#endif
+
+/* $Xorg: X11-def.cpp,v 1.3 2000/08/17 19:44:59 cpqbld Exp $ */
+/* $XFree86: xc/lib/X11/X11-def.cpp,v 1.14 2003/03/25 04:18:09 dawes Exp $ */
diff --git a/nx-X11/lib/X11/XDefaultIMIF.c b/nx-X11/lib/X11/XDefaultIMIF.c
new file mode 100644
index 000000000..41bd43c15
--- /dev/null
+++ b/nx-X11/lib/X11/XDefaultIMIF.c
@@ -0,0 +1,456 @@
+/*
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Portions Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions: 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 OR SUN MICROSYSTEMS, INC. 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 EVEN IF
+ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Except as contained in this notice, the names of The Open Group and/or
+Sun Microsystems, Inc. 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 and/or Sun Microsystems,
+Inc., as applicable.
+
+
+X Window System is a trademark of The Open Group
+
+OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
+logo, LBX, X Window System, and Xinerama are trademarks of the Open
+Group. All other trademarks and registered trademarks mentioned herein
+are the property of their respective owners. No right, title or
+interest in or to any trademark, service mark, logo or trade name of
+Sun Microsystems, Inc. or its licensors is granted.
+
+*/
+/* $XFree86: xc/lib/X11/XDefaultIMIF.c,v 1.3 2003/04/13 19:22:18 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcGeneric.h"
+
+#ifndef MAXINT
+#define MAXINT (~((unsigned int)1 << (8 * sizeof(int)) - 1))
+#endif /* !MAXINT */
+
+typedef struct _StaticXIM *StaticXIM;
+
+typedef struct _XIMStaticXIMRec {
+ /* for CT => MB,WC converter */
+ XlcConv ctom_conv;
+ XlcConv ctow_conv;
+} XIMStaticXIMRec;
+
+typedef enum {
+ CREATE_IC = 1,
+ SET_ICVAL = 2,
+ GET_ICVAL = 3
+} XICOp_t;
+
+typedef struct _StaticXIM {
+ XIMMethods methods;
+ XIMCoreRec core;
+ XIMStaticXIMRec *private;
+} StaticXIMRec;
+
+static Status _CloseIM(
+ XIM
+);
+
+static char *_SetIMValues(
+ XIM, XIMArg *
+);
+
+static char *_GetIMValues(
+ XIM, XIMArg*
+);
+
+static XIC _CreateIC(
+ XIM, XIMArg*
+);
+
+static _Xconst XIMMethodsRec local_im_methods = {
+ _CloseIM, /* close */
+ _SetIMValues, /* set_values */
+ _GetIMValues, /* get_values */
+ _CreateIC, /* create_ic */
+ NULL, /* ctstombs */
+ NULL /* ctstowcs */
+};
+
+static void _DestroyIC(
+ XIC
+);
+static void _SetFocus(
+ XIC
+);
+static void _UnsetFocus(
+ XIC
+);
+static char* _SetICValues(
+ XIC, XIMArg *
+);
+static char* _GetICValues(
+ XIC, XIMArg *
+);
+static char *_MbReset(
+ XIC
+);
+static wchar_t *_WcReset(
+ XIC
+);
+static int _MbLookupString(
+ XIC, XKeyEvent *, char *, int, KeySym *, Status *
+);
+static int _WcLookupString(
+ XIC, XKeyEvent *, wchar_t *, int, KeySym *, Status *
+);
+
+static _Xconst XICMethodsRec local_ic_methods = {
+ _DestroyIC, /* destroy */
+ _SetFocus, /* set_focus */
+ _UnsetFocus, /* unset_focus */
+ _SetICValues, /* set_values */
+ _GetICValues, /* get_values */
+ _MbReset, /* mb_reset */
+ _WcReset, /* wc_reset */
+ NULL, /* utf8_reset */ /* ??? */
+ _MbLookupString, /* mb_lookup_string */
+ _WcLookupString, /* wc_lookup_string */
+ NULL /* utf8_lookup_string */ /* ??? */
+};
+
+XIM
+_XDefaultOpenIM(
+ XLCd lcd,
+ Display *dpy,
+ XrmDatabase rdb,
+ char *res_name,
+ char *res_class)
+{
+ StaticXIM im;
+ XIMStaticXIMRec *local_impart;
+ XlcConv ctom_conv, ctow_conv;
+ int i;
+ char *mod;
+ char buf[BUFSIZ];
+
+ if (!(ctom_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNMultiByte))) {
+ return((XIM)NULL);
+ }
+
+ if (!(ctow_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNWideChar))) {
+ return((XIM)NULL);
+ }
+
+ if ((im = (StaticXIM)Xmalloc(sizeof(StaticXIMRec))) == (StaticXIM)NULL) {
+ return((XIM)NULL);
+ }
+ if ((local_impart = (XIMStaticXIMRec*)Xmalloc(sizeof(XIMStaticXIMRec)))
+ == (XIMStaticXIMRec *)NULL) {
+ Xfree(im);
+ return((XIM)NULL);
+ }
+ memset(im, 0, sizeof(StaticXIMRec));
+ memset(local_impart, 0, sizeof(XIMStaticXIMRec));
+
+ buf[0] = '\0';
+ i = 0;
+ if ((lcd->core->modifiers) && (*lcd->core->modifiers)) {
+#define MODIFIER "@im="
+ mod = strstr(lcd->core->modifiers, MODIFIER);
+ if (mod) {
+ mod += strlen(MODIFIER);
+ while (*mod && *mod != '@' && i < BUFSIZ - 1) {
+ buf[i++] = *mod++;
+ }
+ buf[i] = '\0';
+ }
+ }
+#undef MODIFIER
+ if ((im->core.im_name = Xmalloc(i+1)) == NULL)
+ goto Error2;
+ strcpy(im->core.im_name, buf);
+
+ im->private = local_impart;
+ im->methods = (XIMMethods)&local_im_methods;
+ im->core.lcd = lcd;
+ im->core.ic_chain = (XIC)NULL;
+ im->core.display = dpy;
+ im->core.rdb = rdb;
+ im->core.res_name = NULL;
+ im->core.res_class = NULL;
+
+ local_impart->ctom_conv = ctom_conv;
+ local_impart->ctow_conv = ctow_conv;
+
+ if ((res_name != NULL) && (*res_name != '\0')){
+ im->core.res_name = (char *)Xmalloc(strlen(res_name)+1);
+ strcpy(im->core.res_name,res_name);
+ }
+ if ((res_class != NULL) && (*res_class != '\0')){
+ im->core.res_class = (char *)Xmalloc(strlen(res_class)+1);
+ strcpy(im->core.res_class,res_class);
+ }
+
+ return (XIM)im;
+Error2 :
+ Xfree(im->private);
+ Xfree(im->core.im_name);
+ Xfree(im);
+ _XlcCloseConverter(ctom_conv);
+ _XlcCloseConverter(ctow_conv);
+ return(NULL);
+}
+
+static Status
+_CloseIM(XIM xim)
+{
+ StaticXIM im = (StaticXIM)xim;
+ _XlcCloseConverter(im->private->ctom_conv);
+ _XlcCloseConverter(im->private->ctow_conv);
+ XFree(im->private);
+ XFree(im->core.im_name);
+ if (im->core.res_name) XFree(im->core.res_name);
+ if (im->core.res_class) XFree(im->core.res_class);
+ return 1; /*bugID 4163122*/
+}
+
+static char *
+_SetIMValues(xim, arg)
+XIM xim;
+XIMArg *arg;
+{
+ return(arg->name); /* evil */
+}
+
+static char *
+_GetIMValues(xim, values)
+XIM xim;
+XIMArg *values;
+{
+ XIMArg *p;
+ XIMStyles *styles;
+
+ for (p = values; p->name != NULL; p++) {
+ if (strcmp(p->name, XNQueryInputStyle) == 0) {
+ styles = (XIMStyles *)Xmalloc(sizeof(XIMStyles));
+ *(XIMStyles **)p->value = styles;
+ styles->count_styles = 1;
+ styles->supported_styles =
+ (XIMStyle*)Xmalloc(styles->count_styles * sizeof(XIMStyle));
+ styles->supported_styles[0] = (XIMPreeditNone | XIMStatusNone);
+ } else {
+ break;
+ }
+ }
+ return (p->name);
+}
+
+static char*
+_SetICValueData(XIC ic, XIMArg *values, XICOp_t mode)
+{
+ XIMArg *p;
+ char *return_name = NULL;
+
+ for (p = values; p != NULL && p->name != NULL; p++) {
+ if(strcmp(p->name, XNInputStyle) == 0) {
+ if (mode == CREATE_IC)
+ ic->core.input_style = (XIMStyle)p->value;
+ } else if (strcmp(p->name, XNClientWindow) == 0) {
+ ic->core.client_window = (Window)p->value ;
+ } else if (strcmp(p->name, XNFocusWindow) == 0) {
+ ic->core.focus_window = (Window)p->value ;
+ } else if (strcmp(p->name, XNPreeditAttributes) == 0
+ || strcmp(p->name, XNStatusAttributes) == 0) {
+ return_name = _SetICValueData(ic, (XIMArg*)p->value, mode);
+ if (return_name) break;
+ } else {
+ return_name = p->name;
+ break;
+ }
+ }
+ return(return_name);
+}
+
+static char*
+_GetICValueData(XIC ic, XIMArg *values, XICOp_t mode)
+{
+ XIMArg *p;
+ char *return_name = NULL;
+
+ for (p = values; p->name != NULL; p++) {
+ if(strcmp(p->name, XNInputStyle) == 0) {
+ *((XIMStyle *)(p->value)) = ic->core.input_style;
+ } else if (strcmp(p->name, XNClientWindow) == 0) {
+ *((Window *)(p->value)) = ic->core.client_window;
+ } else if (strcmp(p->name, XNFocusWindow) == 0) {
+ *((Window *)(p->value)) = ic->core.focus_window;
+ } else if (strcmp(p->name, XNFilterEvents) == 0) {
+ *((unsigned long *)(p->value))= ic->core.filter_events;
+ } else if (strcmp(p->name, XNPreeditAttributes) == 0
+ || strcmp(p->name, XNStatusAttributes) == 0) {
+ return_name = _GetICValueData(ic, (XIMArg*)p->value, mode);
+ if (return_name) break;
+ } else {
+ return_name = p->name;
+ break;
+ }
+ }
+ return(return_name);
+}
+
+static XIC
+_CreateIC(XIM im, XIMArg *arg)
+{
+ XIC ic;
+
+ if ((ic = (XIC)Xmalloc(sizeof(XICRec))) == (XIC)NULL) {
+ return ((XIC)NULL);
+ }
+ memset(ic, 0, sizeof(XICRec));
+
+ ic->methods = (XICMethods)&local_ic_methods;
+ ic->core.im = im;
+ ic->core.filter_events = KeyPressMask;
+
+ if (_SetICValueData(ic, arg, CREATE_IC) != NULL)
+ goto err_return;
+ if (!(ic->core.input_style))
+ goto err_return;
+
+ return (XIC)ic;
+err_return:
+ XFree(ic);
+ return ((XIC)NULL);
+}
+
+static void
+_DestroyIC(XIC ic)
+{
+/*BugId4255571. This Xfree() should be removed because XDestroyIC() still need ic after invoking _DestroyIC() and there is a XFree(ic) at the end of XDestroyIC() already.
+ if(ic)
+ XFree(ic); */
+}
+
+static void
+_SetFocus(ic)
+XIC ic;
+{
+}
+
+static void
+_UnsetFocus(XIC ic)
+{
+}
+
+static char*
+_SetICValues(XIC ic, XIMArg *args)
+{
+ char *ret = NULL;
+ if (!ic) {
+ return (args->name);
+ }
+ ret = _SetICValueData(ic, args, SET_ICVAL);
+ return(ret);
+}
+
+static char*
+_GetICValues(XIC ic, XIMArg *args)
+{
+ char *ret = NULL;
+ if (!ic) {
+ return (args->name);
+ }
+ ret = _GetICValueData(ic, args, GET_ICVAL);
+ return(ret);
+}
+
+static char *
+_MbReset(XIC xic)
+{
+ return(NULL);
+}
+
+static wchar_t *
+_WcReset(XIC xic)
+{
+ return(NULL);
+}
+
+static int
+_MbLookupString(
+ XIC xic,
+ XKeyEvent *ev,
+ char * buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *status)
+{
+ XComposeStatus NotSupportedYet ;
+ int length;
+
+ length = XLookupString(ev, buffer, bytes, keysym, &NotSupportedYet);
+
+ if (keysym && *keysym == NoSymbol){
+ *status = XLookupNone;
+ } else if (length > 0) {
+ *status = XLookupBoth;
+ } else {
+ *status = XLookupKeySym;
+ }
+ return(length);
+}
+
+static int
+_WcLookupString(
+ XIC xic,
+ XKeyEvent *ev,
+ wchar_t * buffer,
+ int wlen,
+ KeySym *keysym,
+ Status *status)
+{
+ XComposeStatus NotSupportedYet ;
+ int length;
+ /* In single-byte, mb_len = wc_len */
+ char *mb_buf = (char *)Xmalloc(wlen);
+
+ length = XLookupString(ev, mb_buf, wlen, keysym, &NotSupportedYet);
+
+ if (keysym && *keysym == NoSymbol){
+ *status = XLookupNone;
+ } else if (length > 0) {
+ *status = XLookupBoth;
+ } else {
+ *status = XLookupKeySym;
+ }
+ mbstowcs(buffer, mb_buf, length);
+ XFree(mb_buf);
+ return(length);
+}
diff --git a/nx-X11/lib/X11/XDefaultOMIF.c b/nx-X11/lib/X11/XDefaultOMIF.c
new file mode 100644
index 000000000..13f0d9cff
--- /dev/null
+++ b/nx-X11/lib/X11/XDefaultOMIF.c
@@ -0,0 +1,1265 @@
+/*
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Portions Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions: 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 OR SUN MICROSYSTEMS, INC. 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 EVEN IF
+ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Except as contained in this notice, the names of The Open Group and/or
+Sun Microsystems, Inc. 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 and/or Sun Microsystems,
+Inc., as applicable.
+
+
+X Window System is a trademark of The Open Group
+
+OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
+logo, LBX, X Window System, and Xinerama are trademarks of the Open
+Group. All other trademarks and registered trademarks mentioned herein
+are the property of their respective owners. No right, title or
+interest in or to any trademark, service mark, logo or trade name of
+Sun Microsystems, Inc. or its licensors is granted.
+
+*/
+/* $XFree86: xc/lib/X11/XDefaultOMIF.c,v 1.5 2003/04/17 02:39:56 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcPublic.h"
+#include <X11/Xos.h>
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+#define MAXFONTS 100
+
+#define XOM_GENERIC(om) (&((XOMGeneric) om)->gen)
+#define XOC_GENERIC(font_set) (&((XOCGeneric) font_set)->gen)
+
+#define DefineLocalBuf char local_buf[BUFSIZ]
+#define AllocLocalBuf(length) (length > BUFSIZ ? (char *)Xmalloc(length) : local_buf)
+#define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr)
+
+typedef struct _FontDataRec {
+ char *name;
+} FontDataRec, *FontData;
+
+typedef struct _OMDataRec {
+ int font_data_count;
+ FontData font_data;
+} OMDataRec, *OMData;
+
+typedef struct _XOMGenericPart {
+ OMData data;
+} XOMGenericPart;
+
+typedef struct _XOMGenericRec {
+ XOMMethods methods;
+ XOMCoreRec core;
+ XOMGenericPart gen;
+} XOMGenericRec, *XOMGeneric;
+
+typedef struct _FontSetRec {
+ int id;
+ int font_data_count;
+ FontData font_data;
+ char *font_name;
+ XFontStruct *info;
+ XFontStruct *font;
+} FontSetRec, *FontSet;
+
+typedef struct _XOCGenericPart {
+ XlcConv wcs_to_cs;
+ FontSet font_set;
+} XOCGenericPart;
+
+typedef struct _XOCGenericRec {
+ XOCMethods methods;
+ XOCCoreRec core;
+ XOCGenericPart gen;
+} XOCGenericRec, *XOCGeneric;
+
+static Bool
+init_fontset(
+ XOC oc)
+{
+ XOCGenericPart *gen;
+ FontSet font_set;
+ OMData data;
+
+ data = XOM_GENERIC(oc->core.om)->data;
+
+ font_set = (FontSet) Xmalloc(sizeof(FontSetRec));
+ if (font_set == NULL)
+ return False;
+ bzero((char *) font_set, sizeof(FontSetRec));
+
+ gen = XOC_GENERIC(oc);
+ gen->font_set = font_set;
+
+ font_set->font_data_count = data->font_data_count;
+ font_set->font_data = data->font_data;
+
+ return True;
+}
+
+static char *
+get_prop_name(
+ Display *dpy,
+ XFontStruct *fs)
+{
+ unsigned long fp;
+
+ if (XGetFontProperty(fs, XA_FONT, &fp))
+ return XGetAtomName(dpy, fp);
+
+ return (char *) NULL;
+}
+
+static FontData
+check_charset(
+ FontSet font_set,
+ char *font_name)
+{
+ FontData font_data;
+ char *last;
+ int count;
+ ssize_t length, name_len;
+
+ name_len = strlen(font_name);
+ last = font_name + name_len;
+
+ count = font_set->font_data_count;
+ font_data = font_set->font_data;
+
+ for ( ; count-- > 0; font_data++) {
+ length = strlen(font_data->name);
+
+ if (length > name_len)
+ return(NULL);
+
+ if (_XlcCompareISOLatin1(last - length, font_data->name) == 0)
+ return font_data;
+ }
+ return (FontData) NULL;
+}
+
+#if 0 /* Unused */
+static int
+check_fontname(
+ XOC oc,
+ char *name)
+{
+ Display *dpy = oc->core.om->core.display;
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontData data;
+ FontSet font_set;
+ XFontStruct *fs_list;
+ char **fn_list, *fname, *prop_fname = NULL;
+ int list_num, i;
+ int list2_num;
+ char **fn2_list = NULL;
+ int found_num = 0;
+
+ fn_list = XListFonts(dpy, name, MAXFONTS, &list_num);
+ if (fn_list == NULL)
+ return found_num;
+
+ for (i = 0; i < list_num; i++) {
+ fname = fn_list[i];
+
+ font_set = gen->font_set;
+
+ if ((data = check_charset(font_set, fname)) == NULL) {
+ if ((fn2_list = XListFontsWithInfo(dpy, name, MAXFONTS,
+ &list2_num, &fs_list))
+ && (prop_fname = get_prop_name(dpy, fs_list))
+ && (data = check_charset(font_set, prop_fname)))
+ fname = prop_fname;
+ }
+ if (data) {
+ font_set->font_name = (char *) Xmalloc(strlen(fname) + 1);
+ if (font_set->font_name) {
+ strcpy(font_set->font_name, fname);
+ found_num++;
+ }
+ }
+ if (fn2_list) {
+ XFreeFontInfo(fn2_list, fs_list, list2_num);
+ fn2_list = NULL;
+ if (prop_fname) {
+ Xfree(prop_fname);
+ prop_fname = NULL;
+ }
+ }
+ if (found_num == 1)
+ break;
+ }
+ XFreeFontNames(fn_list);
+ return found_num;
+}
+#endif
+
+static Bool
+load_font(
+ XOC oc)
+{
+ Display *dpy = oc->core.om->core.display;
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set = gen->font_set;
+
+ if (font_set->font_name == NULL)
+ return False;
+
+ if (font_set->font == NULL) {
+ font_set->font = XLoadQueryFont(dpy, font_set->font_name);
+ if (font_set->font == NULL)
+ return False;
+ }
+ return True;
+}
+
+#if 0
+static Bool
+load_font_info(
+ XOC oc)
+{
+ Display *dpy = oc->core.om->core.display;
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set = gen->font_set;
+ char **fn_list;
+ int fn_num;
+
+ if (font_set->font_name == NULL)
+ return False;
+
+ if (font_set->info == NULL) {
+ fn_list = XListFontsWithInfo(dpy, font_set->font_name, 1, &fn_num,
+ &font_set->info);
+ if (font_set->info == NULL)
+ return False;
+ if (fn_num > 0)
+ font_set->info->fid = XLoadFont(dpy, font_set->font_name);
+
+ if (fn_list) XFreeFontNames(fn_list);
+ }
+ return True;
+}
+#endif
+
+static void
+set_fontset_extents(
+ XOC oc)
+{
+ XRectangle *ink = &oc->core.font_set_extents.max_ink_extent;
+ XRectangle *logical = &oc->core.font_set_extents.max_logical_extent;
+ XFontStruct **font_list, *font;
+ XCharStruct overall;
+ int logical_ascent, logical_descent;
+
+ font_list = oc->core.font_info.font_struct_list;
+ font = *font_list++;
+ overall = font->max_bounds;
+ overall.lbearing = font->min_bounds.lbearing;
+ logical_ascent = font->ascent;
+ logical_descent = font->descent;
+
+ ink->x = overall.lbearing;
+ ink->y = -(overall.ascent);
+ ink->width = overall.rbearing - overall.lbearing;
+ ink->height = overall.ascent + overall.descent;
+
+ logical->x = 0;
+ logical->y = -(logical_ascent);
+ logical->width = overall.width;
+ logical->height = logical_ascent + logical_descent;
+}
+
+static Bool
+init_core_part(
+ XOC oc)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ XFontStruct **font_struct_list;
+ char **font_name_list, *font_name_buf;
+ int count, length;
+
+ font_set = gen->font_set;
+ count = length = 0;
+
+ if (font_set->font_name != NULL) {
+ length += strlen(font_set->font_name) + 1;
+ count++;
+ }
+ if (count == 0)
+ return False;
+
+ font_struct_list = (XFontStruct **) Xmalloc(sizeof(XFontStruct *));
+ if (font_struct_list == NULL)
+ return False;
+
+ font_name_list = (char **) Xmalloc(sizeof(char *));
+ if (font_name_list == NULL)
+ goto err;
+
+ font_name_buf = (char *) Xmalloc(length);
+ if (font_name_buf == NULL)
+ goto err;
+
+ oc->core.font_info.num_font = 1;
+ oc->core.font_info.font_name_list = font_name_list;
+ oc->core.font_info.font_struct_list = font_struct_list;
+
+ font_set = gen->font_set;
+
+ if (font_set->font_name != NULL) {
+ font_set->id = 1;
+ if (font_set->font)
+ *font_struct_list++ = font_set->font;
+ else
+ *font_struct_list++ = font_set->info;
+ strcpy(font_name_buf, font_set->font_name);
+ Xfree(font_set->font_name);
+ *font_name_list++ = font_set->font_name = font_name_buf;
+ font_name_buf += strlen(font_name_buf) + 1;
+ }
+
+ set_fontset_extents(oc);
+
+ return True;
+
+err:
+ if (font_name_list)
+ Xfree(font_name_list);
+ Xfree(font_struct_list);
+
+ return False;
+}
+
+static char *
+get_font_name(
+ XOC oc,
+ char *pattern)
+{
+ char **list, *name, *prop_name;
+ int count;
+ XFontStruct *fs;
+ Display *dpy = oc->core.om->core.display;
+
+ list = XListFonts(dpy, pattern, 1, &count);
+ if (list != NULL) {
+ name = (char *) Xmalloc(strlen(*list) + 1);
+ if (name)
+ strcpy(name, *list);
+
+ XFreeFontNames(list);
+ } else {
+ fs = XLoadQueryFont(dpy, pattern);
+ if (fs == NULL) return NULL;
+
+ prop_name = get_prop_name(dpy, fs);
+ if (prop_name == NULL) return NULL;
+
+ name = (char*) Xmalloc(strlen(prop_name) + 1);
+ if (name)
+ strcpy(name, prop_name);
+
+ XFreeFont(dpy, fs);
+ }
+ return name;
+}
+
+static int
+parse_fontname(
+ XOC oc)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ FontData font_data;
+ char *pattern, *last, buf[BUFSIZ];
+ int font_data_count, found_num = 0;
+ ssize_t length;
+ int count, num_fields;
+ char *base_name, *font_name, **name_list, **cur_name_list;
+ char *charset_p = NULL;
+ Bool append_charset;
+ /*
+ append_charset flag should be set to True when the XLFD fontname
+ doesn't contain a chaset part.
+ */
+
+ name_list = _XParseBaseFontNameList(oc->core.base_name_list, &count);
+ if (name_list == NULL)
+ return -1;
+ cur_name_list = name_list;
+
+ while (count-- > 0) {
+ pattern = *cur_name_list++;
+ if (pattern == NULL || *pattern == '\0')
+ continue;
+
+ append_charset = False;
+
+ if (strchr(pattern, '*') == NULL &&
+ (font_name = get_font_name(oc, pattern))) {
+
+ font_set = gen->font_set;
+
+ font_data = check_charset(font_set, font_name);
+ if (font_data == NULL) {
+ Display *dpy = oc->core.om->core.display;
+ char **fn_list = NULL, *prop_fname = NULL;
+ int list_num;
+ XFontStruct *fs_list;
+ if ((fn_list = XListFontsWithInfo(dpy, font_name,
+ MAXFONTS,
+ &list_num, &fs_list))
+ && (prop_fname = get_prop_name(dpy, fs_list))
+ && (font_data = check_charset(font_set, prop_fname))) {
+ if (fn_list) {
+ XFreeFontInfo(fn_list, fs_list, list_num);
+ fn_list = NULL;
+ }
+ font_name = prop_fname;
+ }
+ }
+ if (font_data == NULL)
+ continue;
+
+ font_set->font_name = (char *) Xmalloc(strlen(font_name) + 1);
+ if (font_set->font_name == NULL) {
+ Xfree(font_name);
+ goto err;
+ }
+ strcpy(font_set->font_name, font_name);
+ Xfree(font_name);
+ found_num++;
+ goto found;
+ }
+/*
+1266793
+Limit the length of the string copy to prevent stack corruption.
+ strcpy(buf, pattern);
+*/
+ strncpy(buf, pattern, BUFSIZ);
+ buf[BUFSIZ-1] = '\0';
+ length = strlen(buf);
+ last = buf + length - 1;
+
+ for (num_fields = 0, base_name = buf; *base_name != '\0'; base_name++)
+ if (*base_name == '-') num_fields++;
+ if (strchr(pattern, '*') == NULL) {
+ if (num_fields == 12) {
+ append_charset = True;
+ *++last = '-';
+ last++;
+ } else
+ continue;
+ } else {
+ if (num_fields == 13 || num_fields == 14) {
+ /*
+ * There are 14 fields in an XLFD name -- make certain the
+ * charset (& encoding) is placed in the correct field.
+ */
+ append_charset = True;
+ last = strrchr (buf, '-');
+ if (num_fields == 14) {
+ *last = '\0';
+ last = strrchr (buf, '-');
+ }
+ last++;
+ } else if (*last == '*') {
+ append_charset = True;
+ if (length > 3 && *(last-3) == '-' && *(last-2) == '*'
+ && *(last-1) == '-') {
+ last -= 2;
+ }
+ *++last = '-';
+ last++;
+ } else {
+ last = strrchr (buf, '-');
+ charset_p = last;
+ charset_p = strrchr (buf, '-');
+ while (*(--charset_p) != '-');
+ charset_p++;
+ }
+ }
+
+ font_set = gen->font_set;
+
+ font_data = font_set->font_data;
+ font_data_count = font_set->font_data_count;
+ for ( ; font_data_count-- > 0; font_data++) {
+ if (append_charset)
+ {
+/*
+1266793
+Limit the length of the string copy to prevent stack corruption.
+ strcpy(last, font_data->name);
+*/
+ strncpy(last, font_data->name, BUFSIZ - length);
+ buf[BUFSIZ-1] = '\0';
+ }
+ else {
+ if (_XlcCompareISOLatin1(charset_p,
+ font_data->name)) {
+ continue;
+ }
+ }
+ if ((font_set->font_name = get_font_name(oc, buf)))
+ break;
+ }
+ if (font_set->font_name != NULL) {
+ found_num++;
+ goto found;
+ }
+ }
+ found:
+ base_name = (char *) Xmalloc(strlen(oc->core.base_name_list) + 1);
+ if (base_name == NULL)
+ goto err;
+
+ strcpy(base_name, oc->core.base_name_list);
+ oc->core.base_name_list = base_name;
+
+ XFreeStringList(name_list);
+
+ return found_num;
+err:
+ XFreeStringList(name_list);
+
+ return -1;
+}
+
+static Bool
+set_missing_list(
+ XOC oc)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ char **charset_list, *charset_buf;
+ int count, length;
+
+ font_set = gen->font_set;
+ count = length = 0;
+
+ if (!font_set->info && !font_set->font) {
+ length += strlen(font_set->font_data->name) + 1;
+ count++;
+ }
+
+ if (count == 0)
+ return True;
+
+ charset_list = (char **) Xmalloc(sizeof(char *));
+ if (charset_list == NULL)
+ return False;
+
+ charset_buf = (char *) Xmalloc(length);
+ if (charset_buf == NULL) {
+ Xfree(charset_list);
+ return False;
+ }
+
+ oc->core.missing_list.charset_list = charset_list;
+
+ font_set = gen->font_set;
+
+ if (!font_set->info && !font_set->font) {
+ strcpy(charset_buf, font_set->font_data->name);
+ *charset_list++ = charset_buf;
+ charset_buf += strlen(charset_buf) + 1;
+ }
+ return True;
+}
+
+static Bool
+create_fontset(
+ XOC oc)
+{
+ int found_num;
+
+ if (init_fontset(oc) == False)
+ return False;
+
+ found_num = parse_fontname(oc);
+ if (found_num <= 0) {
+ if (found_num == 0)
+ set_missing_list(oc);
+ return False;
+ }
+
+ if (load_font(oc) == False)
+ return False;
+
+ if (init_core_part(oc) == False)
+ return False;
+
+ if (set_missing_list(oc) == False)
+ return False;
+
+ return True;
+}
+
+static void
+destroy_oc(
+ XOC oc)
+{
+ Display *dpy = oc->core.om->core.display;
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ XFontStruct **font_list, *font;
+
+ if (gen->font_set)
+ Xfree(gen->font_set);
+
+ if (oc->core.base_name_list)
+ Xfree(oc->core.base_name_list);
+
+ if (oc->core.font_info.font_name_list)
+ XFreeStringList(oc->core.font_info.font_name_list);
+
+ if ((font_list = oc->core.font_info.font_struct_list)) {
+ if ((font = *font_list)) {
+ if (font->fid)
+ XFreeFont(dpy, font);
+ else
+ XFreeFontInfo(NULL, font, 1);
+ }
+ Xfree(oc->core.font_info.font_struct_list);
+ }
+
+ if (oc->core.missing_list.charset_list)
+ XFreeStringList(oc->core.missing_list.charset_list);
+
+#ifdef notdef
+ if (oc->core.res_name)
+ Xfree(oc->core.res_name);
+ if (oc->core.res_class)
+ Xfree(oc->core.res_class);
+#endif
+
+ Xfree(oc);
+}
+
+static char *
+set_oc_values(
+ XOC oc,
+ XlcArgList args,
+ int num_args)
+{
+ if (oc->core.resources == NULL)
+ return NULL;
+
+ return _XlcSetValues((XPointer) oc, oc->core.resources,
+ oc->core.num_resources, args, num_args, XlcSetMask);
+}
+
+static char *
+get_oc_values(
+ XOC oc,
+ XlcArgList args,
+ int num_args)
+{
+ if (oc->core.resources == NULL)
+ return NULL;
+
+ return _XlcGetValues((XPointer) oc, oc->core.resources,
+ oc->core.num_resources, args, num_args, XlcGetMask);
+}
+
+static Bool
+wcs_to_mbs(
+ XOC oc,
+ char *to,
+ _Xconst wchar_t *from,
+ int length)
+{
+ XlcConv conv = XOC_GENERIC(oc)->wcs_to_cs;
+ XLCd lcd;
+ int ret, to_left = length;
+
+ if (conv == NULL) {
+ lcd = oc->core.om->core.lcd;
+ conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
+ if (conv == NULL)
+ return False;
+ XOC_GENERIC(oc)->wcs_to_cs = conv;
+ } else
+ _XlcResetConverter(conv);
+
+ ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to,
+ &to_left, NULL, 0);
+ if (ret != 0 || length > 0)
+ return False;
+
+ return True;
+}
+
+static int
+_XmbDefaultTextEscapement(XOC oc, _Xconst char *text, int length)
+{
+ return XTextWidth(*oc->core.font_info.font_struct_list, text, length);
+}
+
+static int
+_XwcDefaultTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret = 0;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ ret = _XmbDefaultTextEscapement(oc, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+static int
+_XmbDefaultTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ int direction, logical_ascent, logical_descent;
+ XCharStruct overall;
+
+ XTextExtents(*oc->core.font_info.font_struct_list, text, length, &direction,
+ &logical_ascent, &logical_descent, &overall);
+
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(logical_ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = logical_ascent + logical_descent;
+ }
+
+ return overall.width;
+}
+
+static int
+_XwcDefaultTextExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret = 0;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+static Status
+_XmbDefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ XFontStruct *font = *oc->core.font_info.font_struct_list;
+ XCharStruct *def, *cs, overall;
+ Bool first = True;
+
+ if (buf_size < length)
+ return 0;
+
+ bzero((char *) &overall, sizeof(XCharStruct));
+ *num_chars = 0;
+
+ CI_GET_DEFAULT_INFO_1D(font, def)
+
+ while (length-- > 0) {
+ CI_GET_CHAR_INFO_1D(font, *text, def, cs)
+ text++;
+ if (cs == NULL)
+ continue;
+
+ ink_buf->x = overall.width + cs->lbearing;
+ ink_buf->y = -(cs->ascent);
+ ink_buf->width = cs->rbearing - cs->lbearing;
+ ink_buf->height = cs->ascent + cs->descent;
+ ink_buf++;
+
+ logical_buf->x = overall.width;
+ logical_buf->y = -(font->ascent);
+ logical_buf->width = cs->width;
+ logical_buf->height = font->ascent + font->descent;
+ logical_buf++;
+
+ if (first) {
+ overall = *cs;
+ first = False;
+ } else {
+ overall.ascent = max(overall.ascent, cs->ascent);
+ overall.descent = max(overall.descent, cs->descent);
+ overall.lbearing = min(overall.lbearing, overall.width +
+ cs->lbearing);
+ overall.rbearing = max(overall.rbearing, overall.width +
+ cs->rbearing);
+ overall.width += cs->width;
+ }
+ (*num_chars)++;
+ }
+
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(font->ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = font->ascent + font->descent;
+ }
+
+ return 1;
+}
+
+static Status
+_XwcDefaultTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ Status ret = 0;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf,
+ buf_size, num_chars, overall_ink,
+ overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+static int
+_XmbDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length)
+{
+ XFontStruct *font = *oc->core.font_info.font_struct_list;
+
+ XSetFont(dpy, gc, font->fid);
+ XDrawString(dpy, d, gc, x, y, text, length);
+
+ return XTextWidth(font, text, length);
+}
+
+static int
+_XwcDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst wchar_t *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret = 0;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+static void
+_XmbDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length)
+{
+ XSetFont(dpy, gc, (*oc->core.font_info.font_struct_list)->fid);
+ XDrawImageString(dpy, d, gc, x, y, text, length);
+}
+
+static void
+_XwcDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst wchar_t *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+
+ if (buf == NULL)
+ return;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+}
+
+static _Xconst XOCMethodsRec oc_default_methods = {
+ destroy_oc,
+ set_oc_values,
+ get_oc_values,
+ _XmbDefaultTextEscapement,
+ _XmbDefaultTextExtents,
+ _XmbDefaultTextPerCharExtents,
+ _XmbDefaultDrawString,
+ _XmbDefaultDrawImageString,
+ _XwcDefaultTextEscapement,
+ _XwcDefaultTextExtents,
+ _XwcDefaultTextPerCharExtents,
+ _XwcDefaultDrawString,
+ _XwcDefaultDrawImageString
+};
+
+static XlcResource oc_resources[] = {
+ { XNBaseFontName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.base_name_list), XlcCreateMask | XlcGetMask },
+ { XNOMAutomatic, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XOCRec, core.om_automatic), XlcGetMask },
+ { XNMissingCharSet, NULLQUARK, sizeof(XOMCharSetList),
+ XOffsetOf(XOCRec, core.missing_list), XlcGetMask },
+ { XNDefaultString, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.default_string), XlcGetMask },
+ { XNOrientation, NULLQUARK, sizeof(XOrientation),
+ XOffsetOf(XOCRec, core.orientation), XlcSetMask | XlcGetMask },
+ { XNResourceName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.res_name), XlcSetMask | XlcGetMask },
+ { XNResourceClass, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.res_class), XlcSetMask | XlcGetMask },
+ { XNFontInfo, NULLQUARK, sizeof(XOMFontInfo),
+ XOffsetOf(XOCRec, core.font_info), XlcGetMask }
+};
+
+static XOC
+create_oc(
+ XOM om,
+ XlcArgList args,
+ int num_args)
+{
+ XOC oc;
+
+ oc = (XOC) Xmalloc(sizeof(XOCGenericRec));
+ if (oc == NULL)
+ return (XOC) NULL;
+ bzero((char *) oc, sizeof(XOCGenericRec));
+
+ oc->core.om = om;
+
+ if (oc_resources[0].xrm_name == NULLQUARK)
+ _XlcCompileResourceList(oc_resources, XlcNumber(oc_resources));
+
+ if (_XlcSetValues((XPointer) oc, oc_resources, XlcNumber(oc_resources),
+ args, num_args, XlcCreateMask | XlcDefaultMask))
+ goto err;
+
+ if (oc->core.base_name_list == NULL)
+ goto err;
+
+ oc->core.resources = oc_resources;
+ oc->core.num_resources = XlcNumber(oc_resources);
+
+ if (create_fontset(oc) == False)
+ goto err;
+
+ oc->methods = (XOCMethods)&oc_default_methods;
+
+ return oc;
+
+err:
+ destroy_oc(oc);
+
+ return (XOC) NULL;
+}
+
+static Status
+close_om(
+ XOM om)
+{
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ OMData data;
+ FontData font_data;
+ int count;
+
+ if ((data = gen->data)) {
+ if (data->font_data) {
+ for (font_data = data->font_data, count = data->font_data_count;
+ count-- > 0 ; font_data++) {
+ if (font_data->name)
+ Xfree(font_data->name);
+ }
+ Xfree(data->font_data);
+ }
+ Xfree(gen->data);
+ }
+
+ if (om->core.res_name)
+ Xfree(om->core.res_name);
+ if (om->core.res_class)
+ Xfree(om->core.res_class);
+ if (om->core.required_charset.charset_list)
+ XFreeStringList(om->core.required_charset.charset_list);
+ else
+ Xfree((char*)om->core.required_charset.charset_list);
+ if (om->core.orientation_list.orientation)
+ Xfree(om->core.orientation_list.orientation);
+
+ Xfree(om);
+
+ return 1;
+}
+
+static char *
+set_om_values(
+ XOM om,
+ XlcArgList args,
+ int num_args)
+{
+ if (om->core.resources == NULL)
+ return NULL;
+
+ return _XlcSetValues((XPointer) om, om->core.resources,
+ om->core.num_resources, args, num_args, XlcSetMask);
+}
+
+static char *
+get_om_values(
+ XOM om,
+ XlcArgList args,
+ int num_args)
+{
+ if (om->core.resources == NULL)
+ return NULL;
+
+ return _XlcGetValues((XPointer) om, om->core.resources,
+ om->core.num_resources, args, num_args, XlcGetMask);
+}
+
+static _Xconst XOMMethodsRec methods = {
+ close_om,
+ set_om_values,
+ get_om_values,
+ create_oc
+};
+
+static XlcResource om_resources[] = {
+ { XNRequiredCharSet, NULLQUARK, sizeof(XOMCharSetList),
+ XOffsetOf(XOMRec, core.required_charset), XlcGetMask },
+ { XNQueryOrientation, NULLQUARK, sizeof(XOMOrientation),
+ XOffsetOf(XOMRec, core.orientation_list), XlcGetMask },
+ { XNDirectionalDependentDrawing, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XOMRec, core.directional_dependent), XlcGetMask },
+ { XNContextualDrawing, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XOMRec, core.contextual_drawing), XlcGetMask }
+};
+
+static OMData
+add_data(
+ XOM om)
+{
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ OMData new;
+
+ new = (OMData) Xmalloc(sizeof(OMDataRec));
+
+ if (new == NULL)
+ return NULL;
+
+ gen->data = new;
+
+ bzero((char *) new, sizeof(OMDataRec));
+
+ return new;
+}
+
+static _Xconst char *supported_charset_list[] = {
+ "ISO8859-1",
+/* fix for bug4332979 */
+ "adobe-fontspecific",
+/* fix for bug4237353: "JISX0201.1976-0" entry should be removed from
+ supported_charset_list because it is not a supported_charset for C locale
+ "JISX0201.1976-0", */
+ "SUNOLCURSOR-1",
+ "SUNOLGLYPH-1"
+};
+
+static Bool
+init_om(
+ XOM om)
+{
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ OMData data;
+ FontData font_data;
+ char **required_list;
+ XOrientation *orientation;
+ char **value, buf[BUFSIZ], *bufptr;
+ int count, length = 0;
+
+ value = (char**)supported_charset_list;
+ count = XlcNumber(supported_charset_list);
+
+ data = add_data(om);
+ if (data == NULL)
+ return False;
+
+ font_data = (FontData) Xmalloc(sizeof(FontDataRec) * count);
+ if (font_data == NULL)
+ return False;
+ bzero((char *) font_data, sizeof(FontDataRec) * count);
+ data->font_data = font_data;
+ data->font_data_count = count;
+
+ for ( ; count-- > 0; font_data++) {
+/*
+1266793
+This one is fine. *value points to one of the local strings in
+supported_charset_list[].
+*/
+ strcpy(buf, *value++);
+ font_data->name = (char *) Xmalloc(strlen(buf) + 1);
+ if (font_data->name == NULL)
+ return False;
+ strcpy(font_data->name, buf);
+ }
+
+ length += strlen(data->font_data->name) + 1;
+
+ /* required charset list */
+ required_list = (char **) Xmalloc(sizeof(char *));
+ if (required_list == NULL)
+ return False;
+
+ bufptr = (char *) Xmalloc(length);
+ if (bufptr == NULL) {
+ Xfree(required_list);
+ return False;
+ }
+
+ om->core.required_charset.charset_list = required_list;
+ om->core.required_charset.charset_count = 1; /* always 1 */
+
+ data = gen->data;
+
+ strcpy(bufptr, data->font_data->name);
+ *required_list++ = bufptr;
+ bufptr += strlen(bufptr) + 1;
+
+ /* orientation list */
+ orientation = (XOrientation *) Xmalloc(sizeof(XOrientation));
+ if (orientation == NULL)
+ return False;
+
+ *orientation = XOMOrientation_LTR_TTB;
+ om->core.orientation_list.orientation = orientation;
+ om->core.orientation_list.num_orientation = 1;
+
+ /* directional dependent drawing */
+ om->core.directional_dependent = False;
+
+ /* contexual drawing */
+ om->core.contextual_drawing = False;
+
+ /* context dependent */
+ om->core.context_dependent = False;
+
+ return True;
+}
+
+XOM
+_XDefaultOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb,
+ _Xconst char *res_name, _Xconst char *res_class)
+{
+ XOM om;
+
+ om = (XOM) Xmalloc(sizeof(XOMGenericRec));
+ if (om == NULL)
+ return (XOM) NULL;
+ bzero((char *) om, sizeof(XOMGenericRec));
+
+ om->methods = (XOMMethods)&methods;
+ om->core.lcd = lcd;
+ om->core.display = dpy;
+ om->core.rdb = rdb;
+ if (res_name) {
+ om->core.res_name = (char *)Xmalloc(strlen(res_name) + 1);
+ if (om->core.res_name == NULL)
+ goto err;
+ strcpy(om->core.res_name, res_name);
+ }
+ if (res_class) {
+ om->core.res_class = (char *)Xmalloc(strlen(res_class) + 1);
+ if (om->core.res_class == NULL)
+ goto err;
+ strcpy(om->core.res_class, res_class);
+ }
+
+ if (om_resources[0].xrm_name == NULLQUARK)
+ _XlcCompileResourceList(om_resources, XlcNumber(om_resources));
+
+ om->core.resources = om_resources;
+ om->core.num_resources = XlcNumber(om_resources);
+
+ if (init_om(om) == False)
+ goto err;
+
+ return om;
+err:
+ close_om(om);
+
+ return (XOM) NULL;
+}
diff --git a/nx-X11/lib/X11/XErrorDB b/nx-X11/lib/X11/XErrorDB
new file mode 100644
index 000000000..80a3310b2
--- /dev/null
+++ b/nx-X11/lib/X11/XErrorDB
@@ -0,0 +1,924 @@
+! $Xorg: XErrorDB,v 1.3 2000/08/17 19:44:59 cpqbld Exp $
+! $XdotOrg: xc/lib/X11/XErrorDB,v 1.4 2005/10/21 18:44:24 ajax Exp $
+!
+! Copyright 1993, 1995, 1998 The Open Group
+
+! Permission to use, copy, modify, distribute, and sell this software and its
+! documentation for any purpose is hereby granted without fee, provided that
+! the above copyright notice appear in all copies and that both that
+! copyright notice and this permission notice appear in supporting
+! documentation.
+!
+! The above copyright notice and this permission notice shall be
+! included in all copies or substantial portions of the Software.
+!
+! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+! IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+! OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+! ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+! OTHER DEALINGS IN THE SOFTWARE.
+!
+! Except as contained in this notice, the name of The Open Group shall
+! not be used in advertising or otherwise to promote the sale, use or
+! other dealings in this Software without prior written authorization
+! from The Open Group.
+!
+! $XFree86: xc/lib/X11/XErrorDB,v 3.40 2002/12/21 17:51:42 dawes Exp $
+!
+! these are used in XGetErrorMessage.
+XlibMessage.XError: X Error of failed request
+XlibMessage.MajorCode: Major opcode of failed request: %d
+XlibMessage.MinorCode: Minor opcode of failed request: %d
+XlibMessage.ResourceID: Resource id in failed request: 0x%lx
+XlibMessage.Value: Value in failed request: 0x%lx
+XlibMessage.AtomID: Atom id in failed request: 0x%lx
+XlibMessage.ErrorSerial: Serial number of failed request: %lu
+XlibMessage.CurrentSerial: Current serial number in output stream: %lu
+! X request codes.
+XRequest.1:X_CreateWindow
+XRequest.2:X_ChangeWindowAttributes
+XRequest.3:X_GetWindowAttributes
+XRequest.4:X_DestroyWindow
+XRequest.5:X_DestroySubwindows
+XRequest.6:X_ChangeSaveSet
+XRequest.7:X_ReparentWindow
+XRequest.8:X_MapWindow
+XRequest.9:X_MapSubwindows
+XRequest.10:X_UnmapWindow
+XRequest.11:X_UnmapSubwindows
+XRequest.12:X_ConfigureWindow
+XRequest.13:X_CirculateWindow
+XRequest.14:X_GetGeometry
+XRequest.15:X_QueryTree
+XRequest.16:X_InternAtom
+XRequest.17:X_GetAtomName
+XRequest.18:X_ChangeProperty
+XRequest.19:X_DeleteProperty
+XRequest.20:X_GetProperty
+XRequest.21:X_ListProperties
+XRequest.22:X_SetSelectionOwner
+XRequest.23:X_GetSelectionOwner
+XRequest.24:X_ConvertSelection
+XRequest.25:X_SendEvent
+XRequest.26:X_GrabPointer
+XRequest.27:X_UngrabPointer
+XRequest.28:X_GrabButton
+XRequest.29:X_UngrabButton
+XRequest.30:X_ChangeActivePointerGrab
+XRequest.31:X_GrabKeyboard
+XRequest.32:X_UngrabKeyboard
+XRequest.33:X_GrabKey
+XRequest.34:X_UngrabKey
+XRequest.35:X_AllowEvents
+XRequest.36:X_GrabServer
+XRequest.37:X_UngrabServer
+XRequest.38:X_QueryPointer
+XRequest.39:X_GetMotionEvents
+XRequest.40:X_TranslateCoords
+XRequest.41:X_WarpPointer
+XRequest.42:X_SetInputFocus
+XRequest.43:X_GetInputFocus
+XRequest.44:X_QueryKeymap
+XRequest.45:X_OpenFont
+XRequest.46:X_CloseFont
+XRequest.47:X_QueryFont
+XRequest.48:X_QueryTextExtents
+XRequest.49:X_ListFonts
+XRequest.50:X_ListFontsWithInfo
+XRequest.51:X_SetFontPath
+XRequest.52:X_GetFontPath
+XRequest.53:X_CreatePixmap
+XRequest.54:X_FreePixmap
+XRequest.55:X_CreateGC
+XRequest.56:X_ChangeGC
+XRequest.57:X_CopyGC
+XRequest.58:X_SetDashes
+XRequest.59:X_SetClipRectangles
+XRequest.60:X_FreeGC
+XRequest.61:X_ClearArea
+XRequest.62:X_CopyArea
+XRequest.63:X_CopyPlane
+XRequest.64:X_PolyPoint
+XRequest.65:X_PolyLine
+XRequest.66:X_PolySegment
+XRequest.67:X_PolyRectangle
+XRequest.68:X_PolyArc
+XRequest.69:X_FillPoly
+XRequest.70:X_PolyFillRectangle
+XRequest.71:X_PolyFillArc
+XRequest.72:X_PutImage
+XRequest.73:X_GetImage
+XRequest.74:X_PolyText8
+XRequest.75:X_PolyText16
+XRequest.76:X_ImageText8
+XRequest.77:X_ImageText16
+XRequest.78:X_CreateColormap
+XRequest.79:X_FreeColormap
+XRequest.80:X_CopyColormapAndFree
+XRequest.81:X_InstallColormap
+XRequest.82:X_UninstallColormap
+XRequest.83:X_ListInstalledColormaps
+XRequest.84:X_AllocColor
+XRequest.85:X_AllocNamedColor
+XRequest.86:X_AllocColorCells
+XRequest.87:X_AllocColorPlanes
+XRequest.88:X_FreeColors
+XRequest.89:X_StoreColors
+XRequest.90:X_StoreNamedColor
+XRequest.91:X_QueryColors
+XRequest.92:X_LookupColor
+XRequest.93:X_CreateCursor
+XRequest.94:X_CreateGlyphCursor
+XRequest.95:X_FreeCursor
+XRequest.96:X_RecolorCursor
+XRequest.97:X_QueryBestSize
+XRequest.98:X_QueryExtension
+XRequest.99:X_ListExtensions
+XRequest.100:X_ChangeKeyboardMapping
+XRequest.101:X_GetKeyboardMapping
+XRequest.102:X_ChangeKeyboardControl
+XRequest.103:X_GetKeyboardControl
+XRequest.104:X_Bell
+XRequest.105:X_ChangePointerControl
+XRequest.106:X_GetPointerControl
+XRequest.107:X_SetScreenSaver
+XRequest.108:X_GetScreenSaver
+XRequest.109:X_ChangeHosts
+XRequest.110:X_ListHosts
+XRequest.111:X_SetAccessControl
+XRequest.112:X_SetCloseDownMode
+XRequest.113:X_KillClient
+XRequest.114:X_RotateProperties
+XRequest.115:X_ForceScreenSaver
+XRequest.116:X_SetPointerMapping
+XRequest.117:X_GetPointerMapping
+XRequest.118:X_SetModifierMapping
+XRequest.119:X_GetModifierMapping
+XRequest.127:X_NoOperation
+! X Error Codes
+XProtoError.0: unknown error code 0
+XProtoError.1: BadRequest (invalid request code or no such operation)
+XProtoError.2: BadValue (integer parameter out of range for operation)
+XProtoError.3: BadWindow (invalid Window parameter)
+XProtoError.4: BadPixmap (invalid Pixmap parameter)
+XProtoError.5: BadAtom (invalid Atom parameter)
+XProtoError.6: BadCursor (invalid Cursor parameter)
+XProtoError.7: BadFont (invalid Font parameter)
+XProtoError.8: BadMatch (invalid parameter attributes)
+XProtoError.9: BadDrawable (invalid Pixmap or Window parameter)
+XProtoError.10: BadAccess (attempt to access private resource denied)
+XProtoError.11: BadAlloc (insufficient resources for operation)
+XProtoError.12: BadColor (invalid Colormap parameter)
+XProtoError.13: BadGC (invalid GC parameter)
+XProtoError.14: BadIDChoice (invalid resource ID chosen for this connection)
+XProtoError.15: BadName (named color or font does not exist)
+XProtoError.16: BadLength (poly request too large or internal Xlib length error)
+XProtoError.17: BadImplementation (server does not implement operation)
+! Multi-Buffering extension, not an X Consortium standard
+XRequest.Multi-Buffering.0: X_MbufGetBufferVersion
+XRequest.Multi-Buffering.1: X_MbufCreateImageBuffers
+XRequest.Multi-Buffering.2: X_MbufDestroyImageBuffers
+XRequest.Multi-Buffering.3: X_MbufDisplayImageBuffers
+XRequest.Multi-Buffering.4: X_MbufSetMultiBufferAttributes
+XRequest.Multi-Buffering.5: X_MbufGetMultiBufferAttributes
+XRequest.Multi-Buffering.6: X_MbufSetBufferAttributes
+XRequest.Multi-Buffering.7: X_MbufGetBufferAttributes
+XRequest.Multi-Buffering.8: X_MbufGetBufferInfo
+XRequest.Multi-Buffering.9: X_MbufCreateStereoWindow
+XProtoError.Multi-Buffering.0: BadBuffer (invalid Buffer parameter)
+XlibMessage.Multi-Buffering.0: Buffer id in failed request: 0x%lx
+! SHAPE extension, an X Consortium standard
+XRequest.SHAPE.0: X_ShapeQueryVersion
+XRequest.SHAPE.1: X_ShapeRectangles
+XRequest.SHAPE.2: X_ShapeMask
+XRequest.SHAPE.3: X_ShapeCombine
+XRequest.SHAPE.4: X_ShapeOffset
+XRequest.SHAPE.5: X_ShapeQueryExtents
+XRequest.SHAPE.6: X_ShapeSelectInput
+XRequest.SHAPE.7: X_ShapeInputSelected
+XRequest.SHAPE.8: X_ShapeGetRectangles
+! Input extension, an X Consortium standard
+XRequest.XInputExtension.1:X_GetExtensionVersion
+XRequest.XInputExtension.2:X_ListInputDevices
+XRequest.XInputExtension.3:X_OpenDevice
+XRequest.XInputExtension.4:X_CloseDevice
+XRequest.XInputExtension.5:X_SetDeviceMode
+XRequest.XInputExtension.6:X_SelectExtensionEvent
+XRequest.XInputExtension.7:X_GetSelectedExtensionEvents
+XRequest.XInputExtension.8:X_ChangeDeviceDontPropagateList
+XRequest.XInputExtension.9:X_GetDeviceDontPropagateList
+XRequest.XInputExtension.10:X_GetDeviceMotionEvents
+XRequest.XInputExtension.11:X_ChangeKeyboardDevice
+XRequest.XInputExtension.12:X_ChangePointerDevice
+XRequest.XInputExtension.13:X_GrabDevice
+XRequest.XInputExtension.14:X_UngrabDevice
+XRequest.XInputExtension.15:X_GrabDeviceKey
+XRequest.XInputExtension.16:X_UngrabDeviceKey
+XRequest.XInputExtension.17:X_GrabDeviceButton
+XRequest.XInputExtension.18:X_UngrabDeviceButton
+XRequest.XInputExtension.19:X_AllowDeviceEvents
+XRequest.XInputExtension.20:X_GetDeviceFocus
+XRequest.XInputExtension.21:X_SetDeviceFocus
+XRequest.XInputExtension.22:X_GetFeedbackControl
+XRequest.XInputExtension.23:X_ChangeFeedbackControl
+XRequest.XInputExtension.24:X_GetDeviceKeyMapping
+XRequest.XInputExtension.25:X_ChangeDeviceKeyMapping
+XRequest.XInputExtension.26:X_GetDeviceModifierMapping
+XRequest.XInputExtension.27:X_SetDeviceModifierMapping
+XRequest.XInputExtension.28:X_GetDeviceButtonMapping
+XRequest.XInputExtension.29:X_SetDeviceButtonMapping
+XRequest.XInputExtension.30:X_QueryDeviceState
+XRequest.XInputExtension.31:X_SendExtensionEvent
+XRequest.XInputExtension.32:X_DeviceBell
+XRequest.XInputExtension.33:X_SetDeviceValuators
+XRequest.XInputExtension.34:X_GetDeviceControl
+XRequest.XInputExtension.35:X_ChangeDeviceControl
+! MIT-SHM extension, experimental, not an X Consortium standard
+XRequest.MIT-SHM.0: X_ShmQueryVersion
+XRequest.MIT-SHM.1: X_ShmAttach
+XRequest.MIT-SHM.2: X_ShmDetach
+XRequest.MIT-SHM.3: X_ShmPutImage
+XRequest.MIT-SHM.4: X_ShmGetImage
+XRequest.MIT-SHM.5: X_ShmCreatePixmap
+XProtoError.MIT-SHM.0: BadShmSeg (invalid shared segment parameter)
+XlibMessage.MIT-SHM.0: Segment id in failed request: 0x%lx
+! MIT-SUNDRY-NONSTANDARD extension, definitely not an X Consortium standard
+XRequest.MIT-SUNDRY-NONSTANDARD.0: X_MITSetBugMode
+XRequest.MIT-SUNDRY-NONSTANDARD.1: X_MITGetBugMode
+! X3D-PEX extension
+XRequest.X3D-PEX.1: PEX_GetExtensionInfo
+XRequest.X3D-PEX.2: PEX_GetEnumeratedTypeInfo
+XRequest.X3D-PEX.3: PEX_GetImpDepConstants
+XRequest.X3D-PEX.4: PEX_CreateLookupTable
+XRequest.X3D-PEX.5: PEX_CopyLookupTable
+XRequest.X3D-PEX.6: PEX_FreeLookupTable
+XRequest.X3D-PEX.7: PEX_GetTableInfo
+XRequest.X3D-PEX.8: PEX_GetPredefinedEntries
+XRequest.X3D-PEX.9: PEX_GetDefinedIndices
+XRequest.X3D-PEX.10: PEX_GetTableEntry
+XRequest.X3D-PEX.11: PEX_GetTableEntries
+XRequest.X3D-PEX.12: PEX_SetTableEntries
+XRequest.X3D-PEX.13: PEX_DeleteTableEntries
+XRequest.X3D-PEX.14: PEX_CreatePipelineContext
+XRequest.X3D-PEX.15: PEX_CopyPipelineContext
+XRequest.X3D-PEX.16: PEX_FreePipelineContext
+XRequest.X3D-PEX.17: PEX_GetPipelineContext
+XRequest.X3D-PEX.18: PEX_ChangePipelineContext
+XRequest.X3D-PEX.19: PEX_CreateRenderer
+XRequest.X3D-PEX.20: PEX_FreeRenderer
+XRequest.X3D-PEX.21: PEX_ChangeRenderer
+XRequest.X3D-PEX.22: PEX_GetRendererAttributes
+XRequest.X3D-PEX.23: PEX_GetRendererDynamics
+XRequest.X3D-PEX.24: PEX_BeginRendering
+XRequest.X3D-PEX.25: PEX_EndRendering
+XRequest.X3D-PEX.26: PEX_BeginStructure
+XRequest.X3D-PEX.27: PEX_EndStructure
+XRequest.X3D-PEX.28: PEX_RenderOutputCommands
+XRequest.X3D-PEX.29: PEX_RenderNetwork
+XRequest.X3D-PEX.30: PEX_CreateStructure
+XRequest.X3D-PEX.31: PEX_CopyStructure
+XRequest.X3D-PEX.32: PEX_DestroyStructures
+XRequest.X3D-PEX.33: PEX_GetStructureInfo
+XRequest.X3D-PEX.34: PEX_GetElementInfo
+XRequest.X3D-PEX.35: PEX_GetStructuresInNetwork
+XRequest.X3D-PEX.36: PEX_GetAncestors
+XRequest.X3D-PEX.37: PEX_GetDescendants
+XRequest.X3D-PEX.38: PEX_FetchElements
+XRequest.X3D-PEX.39: PEX_SetEditingMode
+XRequest.X3D-PEX.40: PEX_SetElementPointer
+XRequest.X3D-PEX.41: PEX_SetElementPointerAtLabel
+XRequest.X3D-PEX.42: PEX_ElementSearch
+XRequest.X3D-PEX.43: PEX_StoreElements
+XRequest.X3D-PEX.44: PEX_DeleteElements
+XRequest.X3D-PEX.45: PEX_DeleteElementsToLabel
+XRequest.X3D-PEX.46: PEX_DeleteBetweenLabels
+XRequest.X3D-PEX.47: PEX_CopyElements
+XRequest.X3D-PEX.48: PEX_ChangeStructureRefs
+XRequest.X3D-PEX.49: PEX_CreateNameSet
+XRequest.X3D-PEX.50: PEX_CopyNameSet
+XRequest.X3D-PEX.51: PEX_FreeNameSet
+XRequest.X3D-PEX.52: PEX_GetNameSet
+XRequest.X3D-PEX.53: PEX_ChangeNameSet
+XRequest.X3D-PEX.54: PEX_CreateSearchContext
+XRequest.X3D-PEX.55: PEX_CopySearchContext
+XRequest.X3D-PEX.56: PEX_FreeSearchContext
+XRequest.X3D-PEX.57: PEX_GetSearchContext
+XRequest.X3D-PEX.58: PEX_ChangeSearchContext
+XRequest.X3D-PEX.59: PEX_SearchNetwork
+XRequest.X3D-PEX.60: PEX_CreatePhigsWks
+XRequest.X3D-PEX.61: PEX_FreePhigsWks
+XRequest.X3D-PEX.62: PEX_GetWksInfo
+XRequest.X3D-PEX.63: PEX_GetDynamics
+XRequest.X3D-PEX.64: PEX_GetViewRep
+XRequest.X3D-PEX.65: PEX_RedrawAllStructures
+XRequest.X3D-PEX.66: PEX_UpdateWorkstation
+XRequest.X3D-PEX.67: PEX_RedrawClipRegion
+XRequest.X3D-PEX.68: PEX_ExecuteDeferredActions
+XRequest.X3D-PEX.69: PEX_SetViewPriority
+XRequest.X3D-PEX.70: PEX_SetDisplayUpdateMode
+XRequest.X3D-PEX.71: PEX_MapDCtoWC
+XRequest.X3D-PEX.72: PEX_MapWCtoDC
+XRequest.X3D-PEX.73: PEX_SetViewRep
+XRequest.X3D-PEX.74: PEX_SetWksWindow
+XRequest.X3D-PEX.75: PEX_SetWksViewport
+XRequest.X3D-PEX.76: PEX_SetHlhsrMode
+XRequest.X3D-PEX.77: PEX_SetWksBufferMode
+XRequest.X3D-PEX.78: PEX_PostStructure
+XRequest.X3D-PEX.79: PEX_UnpostStructure
+XRequest.X3D-PEX.80: PEX_UnpostAllStructures
+XRequest.X3D-PEX.81: PEX_GetWksPostings
+XRequest.X3D-PEX.82: PEX_GetPickDevice
+XRequest.X3D-PEX.83: PEX_ChangePickDevice
+XRequest.X3D-PEX.84: PEX_CreatePickMeasure
+XRequest.X3D-PEX.85: PEX_FreePickMeasure
+XRequest.X3D-PEX.86: PEX_GetPickMeasure
+XRequest.X3D-PEX.87: PEX_UpdatePickMeasure
+XRequest.X3D-PEX.88: PEX_OpenFont
+XRequest.X3D-PEX.89: PEX_CloseFont
+XRequest.X3D-PEX.90: PEX_QueryFont
+XRequest.X3D-PEX.91: PEX_ListFonts
+XRequest.X3D-PEX.92: PEX_ListFontsWithInfo
+XRequest.X3D-PEX.93: PEX_QueryTextExtents
+XRequest.X3D-PEX.94: PEX_MatchRenderingTargets
+XRequest.X3D-PEX.95: PEX_Escape
+XRequest.X3D-PEX.96: PEX_EscapeWithReply
+XRequest.X3D-PEX.97: PEX_RenderElements
+XRequest.X3D-PEX.98: PEX_AccumulateState
+XRequest.X3D-PEX.99: PEX_BeginPickOne
+XRequest.X3D-PEX.100: PEX_EndPickOne
+XRequest.X3D-PEX.101: PEX_PickOne
+XRequest.X3D-PEX.102: PEX_BeginPickAll
+XRequest.X3D-PEX.103: PEX_EndPickAll
+XRequest.X3D-PEX.104: PEX_PickAll
+XProtoError.X3D-PEX.0: PEXColorTypeError
+XlibMessage.X3D-PEX.0: Color type in failed request: 0x%lx
+XProtoError.X3D-PEX.1: PEXRendererStateError
+XlibMessage.X3D-PEX.1: Renderer id in failed request: 0x%lx
+XProtoError.X3D-PEX.2: PEXFloatingPointFormatError
+XlibMessage.X3D-PEX.2: Format in failed request: 0x%lx
+XProtoError.X3D-PEX.3: PEXLabelError
+XlibMessage.X3D-PEX.3: Label in failed request: 0x%lx
+XProtoError.X3D-PEX.4: PEXLookupTableError
+XlibMessage.X3D-PEX.4: Table id in failed request: 0x%lx
+XProtoError.X3D-PEX.5: PEXNameSetError
+XlibMessage.X3D-PEX.5: Nameset in failed request: 0x%lx
+XProtoError.X3D-PEX.6: PEXPathError
+XlibMessage.X3D-PEX.6: Path id in failed request: 0x%lx
+XProtoError.X3D-PEX.7: PEXFontError
+XlibMessage.X3D-PEX.7: Font id in failed request: 0x%lx
+XProtoError.X3D-PEX.8: PEXPhigsWksError
+XlibMessage.X3D-PEX.8: Workstation id in failed request: 0x%lx
+XProtoError.X3D-PEX.9: PEXPickMeasureError
+XlibMessage.X3D-PEX.9: Device id in failed request: 0x%lx
+XProtoError.X3D-PEX.10: PEXPipelineContextError
+XlibMessage.X3D-PEX.10: Context id in failed request: 0x%lx
+XProtoError.X3D-PEX.11: PEXRendererError
+XlibMessage.X3D-PEX.11: Renderer id in failed request: 0x%lx
+XProtoError.X3D-PEX.12: PEXSearchContextError
+XlibMessage.X3D-PEX.12: Context id in failed request: 0x%lx
+XProtoError.X3D-PEX.13: PEXStructureError
+XlibMessage.X3D-PEX.13: Structure id in failed request: 0x%lx
+XProtoError.X3D-PEX.14: PEXOutputCommandError
+XlibMessage.X3D-PEX.14: Resource id in failed request: 0x%lx
+! XTEST extension, an X Consortium standard
+XRequest.XTEST.0: X_XTestGetVersion
+XRequest.XTEST.1: X_XTestCompareCursor
+XRequest.XTEST.2: X_XTestFakeInput
+! BIG-REQUESTS extension, an X Consortium standard
+XRequest.BIG-REQUESTS.0: X_BigReqEnable
+! XIE extension, an X Consortium standard
+XRequest.XIE.1: XIE_QueryImageExtension
+XRequest.XIE.2: XIE_QueryTechniques
+XRequest.XIE.3: XIE_CreateColorList
+XRequest.XIE.4: XIE_DestroyColorList
+XRequest.XIE.5: XIE_PurgeColorList
+XRequest.XIE.6: XIE_QueryColorList
+XRequest.XIE.7: XIE_CreateLUT
+XRequest.XIE.8: XIE_DestroyLUT
+XRequest.XIE.9: XIE_CreatePhotomap
+XRequest.XIE.10: XIE_DestroyPhotomap
+XRequest.XIE.11: XIE_QueryPhotomap
+XRequest.XIE.12: XIE_CreateROI
+XRequest.XIE.13: XIE_DestroyROI
+XRequest.XIE.14: XIE_CreatePhotospace
+XRequest.XIE.15: XIE_DestroyPhotospace
+XRequest.XIE.16: XIE_ExecuteImmediate
+XRequest.XIE.17: XIE_CreatePhotoflo
+XRequest.XIE.18: XIE_DestroyPhotoflo
+XRequest.XIE.19: XIE_ExecutePhotoflo
+XRequest.XIE.20: XIE_ModifyPhotoflo
+XRequest.XIE.21: XIE_RedefinePhotoflo
+XRequest.XIE.22: XIE_PutClientData
+XRequest.XIE.23: XIE_GetClientData
+XRequest.XIE.24: XIE_QueryPhotoflo
+XRequest.XIE.25: XIE_Await
+XRequest.XIE.26: XIE_Abort
+XProtoError.XIE.0: XIE_ColorListError
+XlibMessage.XIE.0: ColorList in failed request: 0x%lx
+XProtoError.XIE.1: XIE_LUTError
+XlibMessage.XIE.1: LUT in failed request: 0x%lx
+XProtoError.XIE.2: XIE_PhotofloError
+XlibMessage.XIE.2: Photoflo in failed request: 0x%lx
+XProtoError.XIE.3: XIE_PhotomapError
+XlibMessage.XIE.3: Photomap in failed request: 0x%lx
+XProtoError.XIE.4: XIE_PhotospaceError
+XlibMessage.XIE.4: Photospace in failed request: 0x%lx
+XProtoError.XIE.5: XIE_ROIError
+XlibMessage.XIE.5: ROI in failed request: 0x%lx
+XProtoError.XIE.6: XIE_FloError
+XlibMessage.XIE.6: Photoflo in failed request: 0x%lx
+! SYNC extension, an X Consortium standard
+XRequest.SYNC.0: X_SyncInitialize
+XRequest.SYNC.1: X_SyncListSystemCounters
+XRequest.SYNC.2: X_SyncCreateCounter
+XRequest.SYNC.3: X_SyncSetCounter
+XRequest.SYNC.4: X_SyncChangeCounter
+XRequest.SYNC.5: X_SyncQueryCounter
+XRequest.SYNC.6: X_SyncDestroyCounter
+XRequest.SYNC.7: X_SyncAwait
+XRequest.SYNC.8: X_SyncCreateAlarm
+XRequest.SYNC.9: X_SyncChangeAlarm
+XRequest.SYNC.10: X_SyncQueryAlarm
+XRequest.SYNC.11: X_SyncDestroyAlarm
+XRequest.SYNC.12: X_SyncSetPriority
+XRequest.SYNC.13: X_SyncGetPriority
+XProtoError.SYNC.0: XSyncBadCounter
+XlibMessage.SYNC.0: Counter in failed request: 0x%lx
+XProtoError.SYNC.1: XSyncBadAlarm
+XlibMessage.SYNC.1: Alarm in failed request: 0x%lx
+! XKB extension
+XRequest.XKEYBOARD.0: XkbUseExtension
+XRequest.XKEYBOARD.1: XkbSelectEvents
+XRequest.XKEYBOARD.2: OBSOLETE
+XRequest.XKEYBOARD.3: XkbBell
+XRequest.XKEYBOARD.4: XkbGetState
+XRequest.XKEYBOARD.5: XkbLatchLockState
+XRequest.XKEYBOARD.6: XkbGetControls
+XRequest.XKEYBOARD.7: XkbSetControls
+XRequest.XKEYBOARD.8: XkbGetMap
+XRequest.XKEYBOARD.9: XkbSetMap
+XRequest.XKEYBOARD.10: XkbGetCompatMap
+XRequest.XKEYBOARD.11: XkbSetCompatMap
+XRequest.XKEYBOARD.12: XkbGetIndicatorState
+XRequest.XKEYBOARD.13: XkbGetIndicatorMap
+XRequest.XKEYBOARD.14: XkbSetIndicatorMap
+XRequest.XKEYBOARD.15: XkbGetNamedIndicator
+XRequest.XKEYBOARD.16: XkbSetNamedIndicator
+XRequest.XKEYBOARD.17: XkbGetNames
+XRequest.XKEYBOARD.18: XkbSetNames
+XRequest.XKEYBOARD.19: XkbGetGeometry
+XRequest.XKEYBOARD.20: XkbSetGeometry
+XRequest.XKEYBOARD.21: XkbPerClientFlags
+XRequest.XKEYBOARD.22: XkbListComponents
+XRequest.XKEYBOARD.23: XkbGetKbdByName
+XRequest.XKEYBOARD.24: XkbGetDeviceInfo
+XRequest.XKEYBOARD.25: XkbSetDeviceInfo
+XRequest.XKEYBOARD.101: XkbSetDebuggingFlags
+XProtoError.XKEYBOARD.0: XkbBadKeyboard
+XlibMessage.XKEYBOARD.0: Device id in failed request: 0x%lx
+! GLX extension for OpenGL, an OpenGL Architectural Review Board standard
+! GLX Commands
+XRequest.GLX.7: X_GLXQueryVersion
+XRequest.GLX.3: X_GLXCreateContext
+XRequest.GLX.4: X_GLXDestroyContext
+XRequest.GLX.5: X_GLXMakeCurrent
+XRequest.GLX.6: X_GLXIsDirect
+XRequest.GLX.10: X_GLXCopyContext
+XRequest.GLX.8: X_GLXWaitGL
+XRequest.GLX.9: X_GLXWaitX
+XRequest.GLX.11: X_GLXSwapBuffers
+XRequest.GLX.12: X_GLXUseXFont
+XRequest.GLX.13: X_GLXCreateGLXPixmap
+XRequest.GLX.15: X_GLXDestroyGLXPixmap
+XRequest.GLX.14: X_GLXGetVisualConfigs
+XRequest.GLX.16: X_GLXVendorPrivate
+XRequest.GLX.17: X_GLXVendorPrivateWithReply
+XRequest.GLX.18: X_GLXQueryExtensionsString
+XRequest.GLX.19: X_GLXQueryServerString
+XRequest.GLX.20: X_GLXClientInfo
+! GL Non-rendering Commands
+XRequest.GLX.103: X_GLXDeleteLists
+XRequest.GLX.102: X_GLXEndList
+XRequest.GLX.105: X_GLXFeedbackBuffer
+XRequest.GLX.108: X_GLXFinish
+XRequest.GLX.142: X_GLXFlush
+XRequest.GLX.104: X_GLXGenLists
+XRequest.GLX.112: X_GLXGetBooleanv
+XRequest.GLX.113: X_GLXGetClipPlane
+XRequest.GLX.114: X_GLXGetDoublev
+XRequest.GLX.115: X_GLXGetError
+XRequest.GLX.116: X_GLXGetFloatv
+XRequest.GLX.117: X_GLXGetIntegerv
+XRequest.GLX.118: X_GLXGetLightfv
+XRequest.GLX.119: X_GLXGetLightiv
+XRequest.GLX.120: X_GLXGetMapdv
+XRequest.GLX.121: X_GLXGetMapfv
+XRequest.GLX.122: X_GLXGetMapiv
+XRequest.GLX.123: X_GLXGetMaterialfv
+XRequest.GLX.124: X_GLXGetMaterialiv
+XRequest.GLX.125: X_GLXGetPixelfv
+XRequest.GLX.126: X_GLXGetPixelMapuiv
+XRequest.GLX.127: X_GLXGetPixelMapusv
+XRequest.GLX.129: X_GLXGetString
+XRequest.GLX.130: X_GLXGetTexEnvfv
+XRequest.GLX.131: X_GLXGetTexEnviv
+XRequest.GLX.132: X_GLXGetTexGendv
+XRequest.GLX.133: X_GLXGetTexGenfv
+XRequest.GLX.134: X_GLXGetTexGeniv
+XRequest.GLX.138: X_GLXGetTexLevelParameterfv
+XRequest.GLX.139: X_GLXGetTexLevelParameteriv
+XRequest.GLX.136: X_GLXGetTexParameterfv
+XRequest.GLX.137: X_GLXGetTexParameteriv
+XRequest.GLX.140: X_GLXIsEnabled
+XRequest.GLX.141: X_GLXIsList
+XRequest.GLX.101: X_GLXNewList
+XRequest.GLX.109: X_GLXPixelStoref
+XRequest.GLX.110: X_GLXPixelStorei
+XRequest.GLX.107: X_GLXRenderMode
+XRequest.GLX.106: X_GLXSelectBuffer
+! GL Non-rendering Commands That Return Pixel Data
+XRequest.GLX.128: X_GLXGetPolygonStipple
+XRequest.GLX.135: X_GLXGetTexImage
+XRequest.GLX.111: X_GLXReadPixels
+! GL Rendering Commands
+XRequest.GLX.1: X_GLXRender
+XRequest.GLX.2: X_GLXRenderLarge
+! GLX Errors
+XProtoError.GLX.0: GLXBadContext
+XProtoError.GLX.1: GLXBadContextState
+XProtoError.GLX.2: GLXBadDrawable
+XProtoError.GLX.3: GLXBadPixmap
+XProtoError.GLX.4: GLXBadContextTag
+XProtoError.GLX.5: GLXBadCurrentWindow
+XProtoError.GLX.6: GLXBadRenderRequest
+XProtoError.GLX.7: GLXBadLargeRequest
+XProtoError.GLX.8: GLXUnsupportedPrivateRequest
+! XC-MISC extension, an X Consortium standard
+XRequest.XC-MISC.0: XCMiscGetVersion
+XRequest.XC-MISC.1: XCMiscGetXIDRange
+! RECORD extension
+XRequest.RECORD.0: XRecordQueryVersion
+XRequest.RECORD.1: XRecordCreateContext
+XRequest.RECORD.2: XRecordRegisterClients
+XRequest.RECORD.3: XRecordUnregisterClients
+XRequest.RECORD.4: XRecordGetContext
+XRequest.RECORD.5: XRecordEnableContext
+XRequest.RECORD.6: XRecordDisableContext
+XRequest.RECORD.7: XRecordFreeContext
+XProtoError.RECORD.0: XRecordBadContext
+XlibMessage.RECORD.0: Context in failed request: 0x%lx
+! XFree86-VidModeExtension -- not an X Consortium standard
+XRequest.XFree86-VidModeExtension.0: XF86VidModeQueryVersion
+XRequest.XFree86-VidModeExtension.1: XF86VidModeGetModeLine
+XRequest.XFree86-VidModeExtension.2: XF86VidModeModModeLine
+XRequest.XFree86-VidModeExtension.3: XF86VidModeSwitchMode
+XRequest.XFree86-VidModeExtension.4: XF86VidModeGetMonitor
+XRequest.XFree86-VidModeExtension.5: XF86VidModeLockModeSwitch
+XRequest.XFree86-VidModeExtension.6: XF86VidModeGetAllModeLines
+XRequest.XFree86-VidModeExtension.7: XF86VidModeAddModeLine
+XRequest.XFree86-VidModeExtension.8: XF86VidModeDeleteModeLine
+XRequest.XFree86-VidModeExtension.9: XF86VidModeValidateModeLine
+XRequest.XFree86-VidModeExtension.10: XF86VidModeSwitchToMode
+XRequest.XFree86-VidModeExtension.11: XF86VidModeGetViewPort
+XRequest.XFree86-VidModeExtension.12: XF86VidModeSetViewPort
+XRequest.XFree86-VidModeExtension.13: XF86VidModeGetDotClocks
+XRequest.XFree86-VidModeExtension.14: XF86VidModeSetClientVersion
+XRequest.XFree86-VidModeExtension.15: XF86VidModeSetGamma
+XRequest.XFree86-VidModeExtension.16: XF86VidModeGetGamma
+XRequest.XFree86-VidModeExtension.17: XF86VidModeGetGammaRamp
+XRequest.XFree86-VidModeExtension.18: XF86VidModeSetGammaRamp
+XRequest.XFree86-VidModeExtension.19: XF86VidModeGetGammaRampSize
+XRequest.XFree86-VidModeExtension.20: XF86VidModeGetPermissions
+XProtoError.XFree86-VidModeExtension.0: XF86VidModeBadClock
+XProtoError.XFree86-VidModeExtension.1: XF86VidModeBadHTimings
+XProtoError.XFree86-VidModeExtension.2: XF86VidModeBadVTimings
+XProtoError.XFree86-VidModeExtension.3: XF86VidModeModeUnsuitable
+XProtoError.XFree86-VidModeExtension.4: XF86VidModeExtensionDisabled
+XProtoError.XFree86-VidModeExtension.5: XF86VidModeClientNotLocal
+XProtoError.XFree86-VidModeExtension.6: XF86VidModeZoomLocked
+! XFree86-Misc -- not an X Consortium standard
+XRequest.XFree86-Misc.0: XF86MiscQueryVersion
+XRequest.XFree86-Misc.1: XF86MiscGetSaver
+XRequest.XFree86-Misc.2: XF86MiscSetSaver
+XRequest.XFree86-Misc.3: XF86MiscGetMouseSettings
+XRequest.XFree86-Misc.4: XF86MiscGetKbdSettings
+XRequest.XFree86-Misc.5: XF86MiscSetMouseSettings
+XRequest.XFree86-Misc.6: XF86MiscSetKbdSettings
+XRequest.XFree86-Misc.7: XF86MiscSetGrabKeysState
+XRequest.XFree86-Misc.8: XF86MiscSetClientVersion
+XRequest.XFree86-Misc.9: XF86MiscGetFilePaths
+XProtoError.XFree86-Misc.0: XF86MiscBadMouseProtocol
+XProtoError.XFree86-Misc.1: XF86MiscBadMouseBaudRate
+XProtoError.XFree86-Misc.2: XF86MiscBadMouseFlags
+XProtoError.XFree86-Misc.3: XF86MiscBadMouseCombo
+XProtoError.XFree86-Misc.4: XF86MiscBadKbdType
+XProtoError.XFree86-Misc.5: XF86MiscModInDevDisabled
+XProtoError.XFree86-Misc.6: XF86MiscModInDevClientNotLocal
+XProtoError.XFree86-Misc.7: XF86MiscNoModule
+! XFree86-DGA -- not an X Consortium standard
+XRequest.XFree86-DGA.0: XDGAQueryVersion
+XRequest.XFree86-DGA.1: XF86DGAGetVideoLL
+XRequest.XFree86-DGA.2: XF86DGADirectVideo
+XRequest.XFree86-DGA.3: XF86DGAGetViewPortSize
+XRequest.XFree86-DGA.4: XF86DGASetViewPort
+XRequest.XFree86-DGA.5: XF86DGAGetVidPage
+XRequest.XFree86-DGA.6: XF86DGASetVidPage
+XRequest.XFree86-DGA.7: XF86DGAInstallColormap
+XRequest.XFree86-DGA.8: XF86DGAQueryDirectVideo
+XRequest.XFree86-DGA.9: XF86DGAViewPortChanged
+XRequest.XFree86-DGA.10: XF86DGAObsolete1
+XRequest.XFree86-DGA.11: XF86DGAObsolete2
+XRequest.XFree86-DGA.12: XDGAQueryModes
+XRequest.XFree86-DGA.13: XDGASetMode
+XRequest.XFree86-DGA.14: XDGASetViewport
+XRequest.XFree86-DGA.15: XDGAInstallColormap
+XRequest.XFree86-DGA.16: XDGASelectInput
+XRequest.XFree86-DGA.17: XDGAFillRectangle
+XRequest.XFree86-DGA.18: XDGACopyArea
+XRequest.XFree86-DGA.19: XDGACopyTransparentArea
+XRequest.XFree86-DGA.20: XDGAGetViewportStatus
+XRequest.XFree86-DGA.21: XDGASync
+XRequest.XFree86-DGA.22: XDGAOpenFramebuffer
+XRequest.XFree86-DGA.23: XDGACloseFramebuffer
+XRequest.XFree86-DGA.24: XDGASetClientVersion
+XRequest.XFree86-DGA.25: XDGAChangePixmapMode
+XRequest.XFree86-DGA.26: XDGACreateColormap
+XProtoError.XFree86-DGA.0: XF86DGAClientNotLocal
+XProtoError.XFree86-DGA.1: XF86DGANoDirectVideoMode
+XProtoError.XFree86-DGA.2: XF86DGAScreenNotActive
+XProtoError.XFree86-DGA.3: XF86DGADirectNotActivated
+XProtoError.XFree86-DGA.4: XF86DGAOperationNotSupported
+! DOUBLE-BUFFER (DBE), an X Consortium standard
+XRequest.DOUBLE-BUFFER.0: DBEGetVersion
+XRequest.DOUBLE-BUFFER.1: DBEAllocateBackBufferName
+XRequest.DOUBLE-BUFFER.2: DBEDeallocateBackBufferName
+XRequest.DOUBLE-BUFFER.3: DBESwapBuffers
+XRequest.DOUBLE-BUFFER.4: DBEBeginIdiom
+XRequest.DOUBLE-BUFFER.5: DBEEndIdiom
+XRequest.DOUBLE-BUFFER.6: DBEGetVisualInfo
+XRequest.DOUBLE-BUFFER.7: DBEGetBackBufferAttributes
+XProtoError.DOUBLE-BUFFER.0: DBEBadBuffer (invalid BackBuffer parameter)
+XlibMessage.DOUBLE-BUFFER.0: BackBuffer in failed request: 0x%lx
+! SECURITY
+XRequest.SECURITY.0: SecurityQueryVersion
+XRequest.SECURITY.1: SecurityGenerateAuthorization
+XProtoError.SECURITY.0: SecurityBadAuthorization (invalid authorization id)
+XProtoError.SECURITY.1: SecurityBadAuthorizationProtocol (invalid authorization name or data)
+XlibMessage.SECURITY.1: authorization id in failed request: 0x%lx
+! AppGroup
+XRequest.APPGROUP.0: XagQueryVersion
+XRequest.APPGROUP.1: XagCreate
+XRequest.APPGROUP.2: XagDestroy
+XRequest.APPGROUP.3: XagGetAttr
+XRequest.APPGROUP.4: XagQuery
+XRequest.APPGROUP.5: XagCreateAssoc
+XRequest.APPGROUP.6: XagDestroyAssoc
+XProtoError.APPGROUP.0: XagBadAppGroup (invalid AppGroup parameter)
+! LBX
+XRequest.LBX.0: LbxQueryVersion
+XRequest.LBX.1: LbxStartProxy
+XRequest.LBX.2: LbxStopProxy
+XRequest.LBX.3: LbxSwitch
+XRequest.LBX.4: LbxNewClient
+XRequest.LBX.5: LbxCloseClient
+XRequest.LBX.6: LbxModifySequence
+XRequest.LBX.7: LbxAllowMotion
+XRequest.LBX.8: LbxIncrementPixel
+XRequest.LBX.9: LbxDelta
+XRequest.LBX.10: LbxGetModifierMapping
+XRequest.LBX.11: LbxQueryTag
+XRequest.LBX.12: LbxInvalidateTag
+XRequest.LBX.13: LbxPolyPoint
+XRequest.LBX.14: LbxPolyLine
+XRequest.LBX.15: LbxPolySegment
+XRequest.LBX.16: LbxPolyRectangle
+XRequest.LBX.17: LbxPolyArc
+XRequest.LBX.18: LbxFillPoly
+XRequest.LBX.19: LbxPolyFillRectangle
+XRequest.LBX.20: LbxPolyFillArc
+XRequest.LBX.21: LbxGetKeyboardMapping
+XRequest.LBX.22: LbxQueryFont
+XRequest.LBX.23: LbxChangeProperty
+XRequest.LBX.24: LbxGetProperty
+XRequest.LBX.25: LbxTagData
+XRequest.LBX.26: LbxCopyArea
+XRequest.LBX.27: LbxCopyPlane
+XRequest.LBX.28: LbxPolyText8
+XRequest.LBX.29: LbxPolyText16
+XRequest.LBX.30: LbxImageText8
+XRequest.LBX.31: LbxImageText16
+XRequest.LBX.32: LbxQueryExtension
+XRequest.LBX.33: LbxPutImage
+XRequest.LBX.34: LbxGetImage
+XRequest.LBX.35: LbxBeginLargeRequest
+XRequest.LBX.36: LbxLargeRequestData
+XRequest.LBX.37: LbxEndLargeRequest
+XRequest.LBX.38: LbxInternAtoms
+XRequest.LBX.39: LbxGetWinAttrAndGeom
+XRequest.LBX.40: LbxGrabCmap
+XRequest.LBX.41: LbxReleaseCmap
+XRequest.LBX.42: LbxAllocColor
+XRequest.LBX.43: LbxSync
+XProtoError.LBX.0: BadLbxClient
+! XpExtension
+XRequest.XpExtension.0: PrintQueryVersion
+XRequest.XpExtension.1: PrintGetPrinterList
+XRequest.XpExtension.2: PrintCreateContext
+XRequest.XpExtension.3: PrintSetContext
+XRequest.XpExtension.4: PrintGetContext
+XRequest.XpExtension.5: PrintDestroyContext
+XRequest.XpExtension.6: PrintGetContextScreen
+XRequest.XpExtension.7: PrintStartJob
+XRequest.XpExtension.8: PrintEndJob
+XRequest.XpExtension.9: PrintStartDoc
+XRequest.XpExtension.10: PrintEndDoc
+XRequest.XpExtension.11: PrintPutDocumentData
+XRequest.XpExtension.12: PrintGetDocumentData
+XRequest.XpExtension.13: PrintStartPage
+XRequest.XpExtension.14: PrintEndPage
+XRequest.XpExtension.15: PrintSelectInput
+XRequest.XpExtension.16: PrintInputSelected
+XRequest.XpExtension.17: PrintGetAttributes
+XRequest.XpExtension.18: PrintSetAttributes
+XRequest.XpExtension.19: PrintGetOneAttribute
+XRequest.XpExtension.20: PrintRehashPrinterList
+XRequest.XpExtension.21: PrintGetPageDimensions
+XRequest.XpExtension.22: PrintQueryScreens
+XRequest.XpExtension.23: PrintSetImageResolution
+XRequest.XpExtension.24: PrintGetImageResolution
+XProtoError.XpExtension.0: XPBadContext (Print Context invalid or missing)
+XlibMessage.XpExtension.0: Context in failed request: 0x%lx
+XProtoError.XpExtension.1: XPBadSequence (Illegal sequence of XP operations)
+XProtoError.XpExtension.2: XPBadResourceID (X resource not valid)
+! TOG-CUP, an X Project Team specification
+XRequest.TOG-CUP.0: CUPQueryVersion
+XRequest.TOG-CUP.1: CUPGetReservedColormapEntries
+XRequest.TOG-CUP.2: CUPStoreColors
+! Extended-Visual-Information, an X Project Team specification
+XRequest.Extended-Visual-Information.0: EVIQueryVersion
+XRequest.Extended-Visual-Information.1: EVIGetVisualInfo
+! DPMS (Display Power Management Signaling), an X Project Team specification
+XRequest.DPMS.0: DPMSGetVersion
+XRequest.DPMS.1: DPMSCapable
+XRequest.DPMS.2: DPMSGetTimeouts
+XRequest.DPMS.3: DPMSSetTimeouts
+XRequest.DPMS.4: DPMSEnable
+XRequest.DPMS.5: DPMSDisable
+XRequest.DPMS.6: DPMSForceLevel
+XRequest.DPMS.7: DPMSInfo
+! XINERAMA, not an X Project Team specification
+XRequest.XINERAMA.0: XINERAMAQueryVersion
+XRequest.XINERAMA.1: XINERAMAGetState
+XRequest.XINERAMA.2: XINERAMAGetScreenCount
+XRequest.XINERAMA.3: XINERAMAGetScreenSize
+XRequest.XINERAMA.4: XINERAMAIsActive
+XRequest.XINERAMA.5: XINERAMAQueryScreens
+! XF86Rush extension, not a standard spec
+Xrequest.XFree86-Rush.0: XF86RushQueryVersion
+Xrequest.XFree86-Rush.1: XF86RushLockPixmap
+Xrequest.XFree86-Rush.2: XF86RushUnlockPixmap
+Xrequest.XFree86-Rush.3: XF86RushUnlockAllPixmaps
+Xrequest.XFree86-Rush.4: XF86RushGetCopyMode
+Xrequest.XFree86-Rush.5: XF86RushSetCopyMode
+Xrequest.XFree86-Rush.6: XF86RushGetPixelStride
+Xrequest.XFree86-Rush.7: XF86RushSetPixelStride
+Xrequest.XFree86-Rush.8: XF86RushOverlayPixmap
+Xrequest.XFree86-Rush.9: XF86RushStatusRegOffset
+Xrequest.XFree86-Rush.10: XF86RushAT3DEnableRegs
+Xrequest.XFree86-Rush.11: XF86RushAT3DDisableRegs
+! XVideo
+Xrequest.XVideo.0: XvQueryExtension
+Xrequest.XVideo.1: XvQueryAdaptors
+Xrequest.XVideo.2: XvQueryEncodings
+Xrequest.XVideo.3: XvGrabPort
+Xrequest.XVideo.4: XvUngrabPort
+Xrequest.XVideo.5: XvPutVideo
+Xrequest.XVideo.6: XvPutStill
+Xrequest.XVideo.7: XvGetVideo
+Xrequest.XVideo.8: XvGetStill
+Xrequest.XVideo.9: XvStopVideo
+Xrequest.XVideo.10: XvSelectVideoNotify
+Xrequest.XVideo.11: XvSelectPortNotify
+Xrequest.XVideo.12: XvQueryBestSize
+Xrequest.XVideo.13: XvSetPortAttribute
+Xrequest.XVideo.14: XvGetPortAttribute
+Xrequest.XVideo.15: XvQueryPortAttributes
+Xrequest.XVideo.16: XvListImageFormats
+Xrequest.XVideo.17: XvQueryImageAttributes
+Xrequest.XVideo.18: XvPutImage
+Xrequest.XVideo.19: XvShmPutImage
+XProtoError.XVideo.0: XvBadPort
+XProtoError.XVideo.1: XvBadEncoding
+XProtoError.XVideo.2: XvBadControl
+! XFree86-Bigfont
+Xrequest.XFree86-Bigfont.0: XF86BigfontQueryVersion
+Xrequest.XFree86-Bigfont.1: XF86BigfontQueryFont
+! Adobe-DPS-Extension, not a standard
+XRequest.Adobe-DPS-Extension.1: PSInit
+XRequest.Adobe-DPS-Extension.2: PSCreateContext
+XRequest.Adobe-DPS-Extension.3: PSCreateSpace
+XRequest.Adobe-DPS-Extension.4: PSGiveInput
+XRequest.Adobe-DPS-Extension.5: PSGetStatus
+XRequest.Adobe-DPS-Extension.6: PSDestroySpace
+XRequest.Adobe-DPS-Extension.7: PSReset
+XRequest.Adobe-DPS-Extension.8: PSNotifyContext
+XRequest.Adobe-DPS-Extension.9: PSCreateContextFromID
+XRequest.Adobe-DPS-Extension.10: PSXIDFromContext
+XRequest.Adobe-DPS-Extension.11: PSContextFromXID
+XRequest.Adobe-DPS-Extension.12: PSSetStatusMask
+XRequest.Adobe-DPS-Extension.13: PSCreateSecureContext
+XRequest.Adobe-DPS-Extension.14: PSNotifyWhenReady
+XProtoError.Adobe-DPS-Extension.0: PSErrorBadContext (invalid Context parameter)
+XlibMessage.Adobe-DPS-Extension.0: Context id in failed request: 0x%lx
+XProtoError.Adobe-DPS-Extension.1: PSErrorBadSpace (invalid Space parameter)
+XlibMessage.Adobe-DPS-Extension.1: Space id in failed request: 0x%lx
+XProtoError.Adobe-DPS-Extension.2: PSErrorAbort (interpreter aborted)
+XlibMessage.Adobe-DPS-Extension.2: Value in failed request: 0x%lx
+! RANDR
+XRequest.RANDR.0: RRQueryVersion
+XRequest.RANDR.1: RROldGetScreenInfo
+XRequest.RANDR.2: RRSetScreenConfig
+XRequest.RANDR.3: RROldScreenChangeSelectInput
+XRequest.RANDR.4: RRSelectInput
+XRequest.RANDR.5: RRGetScreenInfo
+! RENDER
+XRequest.RENDER.0: RenderQueryVersion
+XRequest.RENDER.1: RenderQueryPictFormats
+XRequest.RENDER.2: RenderQueryPictIndexValues
+XRequest.RENDER.3: RenderQueryDithers
+XRequest.RENDER.4: RenderCreatePicture
+XRequest.RENDER.5: RenderChangePicture
+XRequest.RENDER.6: RenderSetPictureClipRectangles
+XRequest.RENDER.7: RenderFreePicture
+XRequest.RENDER.8: RenderComposite
+XRequest.RENDER.9: RenderScale
+XRequest.RENDER.10: RenderTrapezoids
+XRequest.RENDER.11: RenderTriangles
+XRequest.RENDER.12: RenderTriStrip
+XRequest.RENDER.13: RenderTriFan
+XRequest.RENDER.14: RenderColorTrapezoids
+XRequest.RENDER.15: RenderColorTriangles
+XRequest.RENDER.16: RenderTransform
+XRequest.RENDER.17: RenderCreateGlyphSet
+XRequest.RENDER.18: RenderReferenceGlyphSet
+XRequest.RENDER.19: RenderFreeGlyphSet
+XRequest.RENDER.20: RenderAddGlyphs
+XRequest.RENDER.21: RenderAddGlyphsFromPicture
+XRequest.RENDER.22: RenderFreeGlyphs
+XRequest.RENDER.23: RenderCompositeGlyphs8
+XRequest.RENDER.24: RenderCompositeGlyphs16
+XRequest.RENDER.25: RenderCompositeGlyphs32
+XRequest.RENDER.26: RenderFillRectangles
+XRequest.RENDER.27: RenderCreateCursor
+XRequest.RENDER.28: RenderSetPictureTransform
+XRequest.RENDER.29: RenderQueryFilters
+XRequest.RENDER.30: RenderSetPictureFilter
+XProtoError.RENDER.0: RenderBadFormat (invalid PictFormat parameter)
+XlibMessage.RENDER.0: PictFormat id in failed request: 0x%lx
+XProtoError.RENDER.1: RenderBadPicture (invalid Picture parameter)
+XlibMessage.RENDER.1: Picture id in failed request: 0x%lx
+XProtoError.RENDER.2: RenderBadPictOp (invalid PictOp parameter)
+XlibMessage.RENDER.2: PictOp in failed request: 0x%lx
+XProtoError.RENDER.3: RenderBadGlyphSet (invalid GlyphSet parameter)
+XlibMessage.RENDER.3: GlyphSet id in failed request: 0x%lx
+XProtoError.RENDER.4: RenderBadGlyph (invalid Glyph parameter)
+XlibMessage.RENDER.4: Glyph in failed request: 0x%lx
+! XFixes
+XRequest.XFIXES.0: XFixesQueryVersion
+XRequest.XFIXES.1: XFixesChangeSaveSet
+XRequest.XFIXES.2: XFixesSelectSelectionInput
+XRequest.XFIXES.3: XFixesSelectCursorInput
+XRequest.XFIXES.4: XFixesGetCursorImage
+XRequest.XFIXES.5: XFixesCreateRegion
+XRequest.XFIXES.6: XFixesCreateRegionFromBitmap
+XRequest.XFIXES.7: XFixesCreateRegionFromWindow
+XRequest.XFIXES.8: XFixesCreateRegionFromGC
+XRequest.XFIXES.9: XFixesCreateRegionFromPicture
+XRequest.XFIXES.10: XFixesDestroyRegion
+XRequest.XFIXES.11: XFixesSetRegion
+XRequest.XFIXES.12: XFixesCopyRegion
+XRequest.XFIXES.13: XFixesUnionRegion
+XRequest.XFIXES.14: XFixesIntersectRegion
+XRequest.XFIXES.15: XFixesSubtractRegion
+XRequest.XFIXES.16: XFixesInvertRegion
+XRequest.XFIXES.17: XFixesTranslateRegion
+XRequest.XFIXES.18: XFixesRegionExtents
+XRequest.XFIXES.19: XFixesFetchRegion
+XRequest.XFIXES.20: XFixesSetGCClipRegion
+XRequest.XFIXES.21: XFixesSetWindowShapeRegion
+XRequest.XFIXES.22: XFixesSetPictureClipRegion
+XRequest.XFIXES.23: XFixesSetCursorName
+XRequest.XFIXES.24: XFixesGetCursorName
+XRequest.XFIXES.25: XFixesGetCursorImageAndName
+XRequest.XFIXES.26: XFixesChangeCursor
+XRequest.XFIXES.27: XFixesChangeCursorByName
+XRequest.XFIXES.28: XFixesExpandRegion
+XProtoError.XFIXES.0: BadRegion (invalid Region parameter)
+XlibMessage.XFIXES.0: Region id in failed request: 0x%lx
+! DAMAGE extension
+XRequest.DAMAGE.0: XDamageQueryVersion
+XRequest.DAMAGE.1: XDamageCreate
+XRequest.DAMAGE.2: XDamageDestroy
+XRequest.DAMAGE.3: XDamageSubtract
diff --git a/nx-X11/lib/X11/XKB.c b/nx-X11/lib/X11/XKB.c
new file mode 100644
index 000000000..ecc5ddf0a
--- /dev/null
+++ b/nx-X11/lib/X11/XKB.c
@@ -0,0 +1,771 @@
+/* $Xorg: XKB.c,v 1.3 2000/08/17 19:44:59 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKB.c,v 1.9 2003/04/17 02:06:31 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+XkbInternAtomFunc _XkbInternAtomFunc= XInternAtom;
+XkbGetAtomNameFunc _XkbGetAtomNameFunc= XGetAtomName;
+
+Bool
+XkbQueryExtension( Display *dpy,
+ int * opcodeReturn,
+ int * eventBaseReturn,
+ int * errorBaseReturn,
+ int * majorReturn,
+ int * minorReturn)
+{
+ if (!XkbUseExtension(dpy,majorReturn,minorReturn))
+ return False;
+ if (opcodeReturn)
+ *opcodeReturn = dpy->xkb_info->codes->major_opcode;
+ if (eventBaseReturn)
+ *eventBaseReturn = dpy->xkb_info->codes->first_event;
+ if (errorBaseReturn)
+ *errorBaseReturn = dpy->xkb_info->codes->first_error;
+ if (majorReturn)
+ *majorReturn = dpy->xkb_info->srv_major;
+ if (minorReturn)
+ *minorReturn = dpy->xkb_info->srv_minor;
+ return True;
+}
+
+Bool
+XkbLibraryVersion(int *libMajorRtrn,int *libMinorRtrn)
+{
+int supported;
+
+ if (*libMajorRtrn != XkbMajorVersion) {
+ /* version 0.65 is (almost) compatible with 1.00 */
+ if ((XkbMajorVersion==1)&&(((*libMajorRtrn)==0)&&((*libMinorRtrn)==65)))
+ supported= True;
+ else supported= False;
+ }
+ else {
+ supported = True;
+ }
+
+ *libMajorRtrn = XkbMajorVersion;
+ *libMinorRtrn = XkbMinorVersion;
+ return supported;
+}
+
+Bool
+XkbSelectEvents( Display * dpy,
+ unsigned int deviceSpec,
+ unsigned int affect,
+ unsigned int selectAll)
+{
+ register xkbSelectEventsReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ xkbi->selected_events&= ~affect;
+ xkbi->selected_events|= (affect&selectAll);
+ GetReq(kbSelectEvents, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSelectEvents;
+ req->deviceSpec = deviceSpec;
+ req->affectWhich = (CARD16)affect;
+ req->clear = affect&(~selectAll);
+ req->selectAll = affect&selectAll;
+ if (affect&XkbMapNotifyMask) {
+ req->affectMap= XkbAllMapComponentsMask;
+ /* the implicit support needs the client info */
+ /* even if the client itself doesn't want it */
+ if (selectAll&XkbMapNotifyMask)
+ req->map= XkbAllMapEventsMask;
+ else req->map= XkbAllClientInfoMask;
+ if (selectAll&XkbMapNotifyMask)
+ xkbi->selected_map_details= XkbAllMapEventsMask;
+ else xkbi->selected_map_details= 0;
+ }
+ if (affect&XkbNewKeyboardNotifyMask) {
+ if (selectAll&XkbNewKeyboardNotifyMask)
+ xkbi->selected_nkn_details= XkbAllNewKeyboardEventsMask;
+ else xkbi->selected_nkn_details= 0;
+ if (!(xkbi->xlib_ctrls&XkbLC_IgnoreNewKeyboards)) {
+ /* we want it, even if the client doesn't. Don't mess */
+ /* around with details -- ask for all of them and throw */
+ /* away the ones we don't need */
+ req->selectAll|= XkbNewKeyboardNotifyMask;
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbSelectEventDetails( Display * dpy,
+ unsigned deviceSpec,
+ unsigned eventType,
+ unsigned long int affect,
+ unsigned long int details)
+{
+ register xkbSelectEventsReq *req;
+ XkbInfoPtr xkbi;
+ int size = 0;
+ char *out;
+ union {
+ CARD8 *c8;
+ CARD16 *c16;
+ CARD32 *c32;
+ } u;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ if (affect&details) xkbi->selected_events|= (1<<eventType);
+ else xkbi->selected_events&= ~(1<<eventType);
+ GetReq(kbSelectEvents, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSelectEvents;
+ req->deviceSpec = deviceSpec;
+ req->clear= req->selectAll= 0;
+ if (eventType==XkbMapNotify) {
+ /* we need all of the client info, even if the application */
+ /* doesn't. Make sure that we always request the stuff */
+ /* that the implicit support needs, and just filter out anything */
+ /* the client doesn't want later */
+ req->affectWhich = 0;
+ req->selectAll = 0;
+ req->clear = 0;
+ req->affectMap = (CARD16)affect;
+ req->map = (CARD16)details|(XkbAllClientInfoMask&affect);
+ req->affectWhich = XkbMapNotifyMask;
+ xkbi->selected_map_details&= ~affect;
+ xkbi->selected_map_details|= (details&affect);
+ }
+ else {
+ req->affectMap = req->map = 0;
+ req->affectWhich= (1<<eventType);
+ switch (eventType) {
+ case XkbNewKeyboardNotify:
+ xkbi->selected_nkn_details&= ~affect;
+ xkbi->selected_nkn_details|= (details&affect);
+ if (!(xkbi->xlib_ctrls&XkbLC_IgnoreNewKeyboards))
+ details= (affect&XkbAllNewKeyboardEventsMask);
+ case XkbStateNotify:
+ case XkbNamesNotify:
+ case XkbAccessXNotify:
+ case XkbExtensionDeviceNotify:
+ size= 2;
+ req->length+= 1;
+ break;
+ case XkbControlsNotify:
+ case XkbIndicatorStateNotify:
+ case XkbIndicatorMapNotify:
+ size= 4;
+ req->length+= 2;
+ break;
+ case XkbBellNotify:
+ case XkbActionMessage:
+ case XkbCompatMapNotify:
+ size= 1;
+ req->length+= 1;
+ break;
+ }
+ BufAlloc(char *,out,(((size*2)+(unsigned)3)/4)*4);
+ u.c8= (CARD8 *)out;
+ if (size==2) {
+ u.c16[0]= (CARD16)affect;
+ u.c16[1]= (CARD16)details;
+ }
+ else if (size==4) {
+ u.c32[0]= (CARD32)affect;
+ u.c32[1]= (CARD32)details;
+ }
+ else {
+ u.c8[0]= (CARD8)affect;
+ u.c8[1]= (CARD8)details;
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbLockModifiers( Display * dpy,
+ unsigned int deviceSpec,
+ unsigned int affect,
+ unsigned int values)
+{
+ register xkbLatchLockStateReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbLatchLockState, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbLatchLockState;
+ req->deviceSpec = deviceSpec;
+ req->affectModLocks= affect;
+ req->modLocks = values;
+ req->lockGroup = False;
+ req->groupLock = 0;
+
+ req->affectModLatches = req->modLatches = 0;
+ req->latchGroup = False;
+ req->groupLatch = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbLatchModifiers( Display * dpy,
+ unsigned int deviceSpec,
+ unsigned int affect,
+ unsigned int values)
+{
+ register xkbLatchLockStateReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbLatchLockState, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbLatchLockState;
+ req->deviceSpec = deviceSpec;
+
+ req->affectModLatches= affect;
+ req->modLatches = values;
+ req->latchGroup = False;
+ req->groupLatch = 0;
+
+ req->affectModLocks = req->modLocks = 0;
+ req->lockGroup = False;
+ req->groupLock = 0;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbLockGroup(Display *dpy,unsigned int deviceSpec,unsigned int group)
+{
+ register xkbLatchLockStateReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbLatchLockState, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbLatchLockState;
+ req->deviceSpec = deviceSpec;
+ req->affectModLocks= 0;
+ req->modLocks = 0;
+ req->lockGroup = True;
+ req->groupLock = group;
+
+ req->affectModLatches = req->modLatches = 0;
+ req->latchGroup = False;
+ req->groupLatch = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbLatchGroup(Display *dpy,unsigned int deviceSpec,unsigned int group)
+{
+ register xkbLatchLockStateReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbLatchLockState, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbLatchLockState;
+ req->deviceSpec = deviceSpec;
+
+ req->affectModLatches= 0;
+ req->modLatches = 0;
+ req->latchGroup = True;
+ req->groupLatch = group;
+
+ req->affectModLocks = req->modLocks = 0;
+ req->lockGroup = False;
+ req->groupLock = 0;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+unsigned
+XkbSetXlibControls(Display *dpy,unsigned affect,unsigned values)
+{
+ if (!dpy->xkb_info)
+ XkbUseExtension(dpy,NULL,NULL);
+ if (!dpy->xkb_info)
+ return 0;
+ affect&= XkbLC_AllControls;
+ dpy->xkb_info->xlib_ctrls&= ~affect;
+ dpy->xkb_info->xlib_ctrls|= (affect&values);
+ return dpy->xkb_info->xlib_ctrls;
+}
+
+unsigned
+XkbGetXlibControls(Display *dpy)
+{
+ if (!dpy->xkb_info)
+ XkbUseExtension(dpy,NULL,NULL);
+ if (!dpy->xkb_info)
+ return 0;
+ return dpy->xkb_info->xlib_ctrls;
+}
+
+unsigned int
+XkbXlibControlsImplemented(void)
+{
+#ifdef __sgi
+ return XkbLC_AllControls;
+#else
+ return XkbLC_AllControls&~XkbLC_AllComposeControls;
+#endif
+}
+
+Bool
+XkbSetDebuggingFlags( Display * dpy,
+ unsigned int mask,
+ unsigned int flags,
+ char * msg,
+ unsigned int ctrls_mask,
+ unsigned int ctrls,
+ unsigned int * rtrn_flags,
+ unsigned int * rtrn_ctrls)
+{
+ register xkbSetDebuggingFlagsReq *req;
+ xkbSetDebuggingFlagsReply rep;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetDebuggingFlags, req);
+ req->reqType= xkbi->codes->major_opcode;
+ req->xkbReqType= X_kbSetDebuggingFlags;
+ req->affectFlags= mask;
+ req->flags= flags;
+ req->affectCtrls= ctrls_mask;
+ req->ctrls= ctrls;
+
+ if (msg) {
+ char *out;
+ req->msgLength= (unsigned short)strlen(msg)+1;
+ req->length+= (req->msgLength+(unsigned)3)>>2;
+ BufAlloc(char *,out,((req->msgLength+(unsigned)3)/4)*4);
+ memcpy(out,msg,req->msgLength);
+ }
+ else req->msgLength= 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ if (rtrn_flags)
+ *rtrn_flags= rep.currentFlags;
+ if (rtrn_ctrls)
+ *rtrn_ctrls= rep.currentCtrls;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbComputeEffectiveMap( XkbDescPtr xkb,
+ XkbKeyTypePtr type,
+ unsigned char * map_rtrn)
+{
+register int i;
+unsigned tmp;
+XkbKTMapEntryPtr entry = NULL;
+
+ if ((!xkb)||(!type)||(!xkb->server))
+ return False;
+
+ if (type->mods.vmods!=0) {
+ if (!XkbVirtualModsToReal(xkb,type->mods.vmods,&tmp))
+ return False;
+
+ type->mods.mask= tmp|type->mods.real_mods;
+ entry= type->map;
+ for (i=0;i<type->map_count;i++,entry++) {
+ tmp= 0;
+ if (entry->mods.vmods!=0) {
+ if (!XkbVirtualModsToReal(xkb,entry->mods.vmods,&tmp))
+ return False;
+ if (tmp==0) {
+ entry->active= False;
+ continue;
+ }
+ }
+ entry->active= True;
+ entry->mods.mask= (entry->mods.real_mods|tmp)&type->mods.mask;
+ }
+ }
+ else {
+ type->mods.mask= type->mods.real_mods;
+ }
+ if (map_rtrn!=NULL) {
+ bzero(map_rtrn,type->mods.mask+1);
+ for (i=0;i<type->map_count;i++) {
+ if (entry->active) {
+ map_rtrn[type->map[i].mods.mask]= type->map[i].level;
+ }
+ }
+ }
+ return True;
+}
+
+Status
+XkbGetState(Display *dpy,unsigned deviceSpec,XkbStatePtr rtrn)
+{
+ register xkbGetStateReq *req;
+ xkbGetStateReply rep;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbGetState, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetState;
+ req->deviceSpec = deviceSpec;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadImplementation;
+ }
+ rtrn->mods= rep.mods;
+ rtrn->base_mods= rep.baseMods;
+ rtrn->latched_mods= rep.latchedMods;
+ rtrn->locked_mods= rep.lockedMods;
+ rtrn->group= rep.group;
+ rtrn->base_group= rep.baseGroup;
+ rtrn->latched_group= rep.latchedGroup;
+ rtrn->locked_group= rep.lockedGroup;
+ rtrn->compat_state= rep.compatState;
+ rtrn->grab_mods= rep.grabMods;
+ rtrn->compat_grab_mods= rep.compatGrabMods;
+ rtrn->lookup_mods= rep.lookupMods;
+ rtrn->compat_lookup_mods= rep.compatLookupMods;
+ rtrn->ptr_buttons= rep.ptrBtnState;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return Success;
+}
+
+Bool
+XkbSetDetectableAutoRepeat(Display *dpy,Bool detectable,Bool *supported)
+{
+register xkbPerClientFlagsReq * req;
+xkbPerClientFlagsReply rep;
+XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbPerClientFlags, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbPerClientFlags;
+ req->deviceSpec = XkbUseCoreKbd;
+ req->change = XkbPCF_DetectableAutoRepeatMask;
+ if (detectable)
+ req->value = XkbPCF_DetectableAutoRepeatMask;
+ else req->value = 0;
+ req->ctrlsToChange = req->autoCtrls= req->autoCtrlValues= 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (supported!=NULL)
+ *supported= ((rep.supported&XkbPCF_DetectableAutoRepeatMask)!=0);
+ return ((rep.value&XkbPCF_DetectableAutoRepeatMask)!=0);
+}
+
+Bool
+XkbGetDetectableAutoRepeat(Display *dpy,Bool *supported)
+{
+register xkbPerClientFlagsReq * req;
+xkbPerClientFlagsReply rep;
+XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbPerClientFlags, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbPerClientFlags;
+ req->deviceSpec = XkbUseCoreKbd;
+ req->change = 0;
+ req->value = 0;
+ req->ctrlsToChange = req->autoCtrls= req->autoCtrlValues= 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (supported!=NULL)
+ *supported= ((rep.supported&XkbPCF_DetectableAutoRepeatMask)!=0);
+ return ((rep.value&XkbPCF_DetectableAutoRepeatMask)!=0);
+}
+
+Bool
+XkbSetAutoResetControls( Display * dpy,
+ unsigned changes,
+ unsigned * auto_ctrls,
+ unsigned * auto_values)
+{
+register xkbPerClientFlagsReq * req;
+xkbPerClientFlagsReply rep;
+XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbPerClientFlags, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbPerClientFlags;
+ req->change = XkbPCF_AutoResetControlsMask;
+ req->deviceSpec = XkbUseCoreKbd;
+ req->value = XkbPCF_AutoResetControlsMask;
+ req->ctrlsToChange= changes;
+ req->autoCtrls= *auto_ctrls;
+ req->autoCtrlValues= *auto_values;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *auto_ctrls= rep.autoCtrls;
+ *auto_values= rep.autoCtrlValues;
+ return ((rep.value&XkbPCF_AutoResetControlsMask)!=0);
+}
+
+Bool
+XkbGetAutoResetControls( Display * dpy,
+ unsigned * auto_ctrls,
+ unsigned * auto_ctrl_values)
+{
+register xkbPerClientFlagsReq * req;
+xkbPerClientFlagsReply rep;
+XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbPerClientFlags, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbPerClientFlags;
+ req->deviceSpec = XkbUseCoreKbd;
+ req->change = 0;
+ req->value = 0;
+ req->ctrlsToChange = req->autoCtrls= req->autoCtrlValues= 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (auto_ctrls)
+ *auto_ctrls= rep.autoCtrls;
+ if (auto_ctrl_values)
+ *auto_ctrl_values= rep.autoCtrlValues;
+ return ((rep.value&XkbPCF_AutoResetControlsMask)!=0);
+}
+
+Bool
+XkbSetPerClientControls( Display * dpy,
+ unsigned change,
+ unsigned * values)
+{
+register xkbPerClientFlagsReq * req;
+xkbPerClientFlagsReply rep;
+XkbInfoPtr xkbi;
+unsigned value_hold = *values;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) ||
+ (change & ~(XkbPCF_GrabsUseXKBStateMask|XkbPCF_LookupStateWhenGrabbed|XkbPCF_SendEventUsesXKBState)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbPerClientFlags, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbPerClientFlags;
+ req->change = change;
+ req->deviceSpec = XkbUseCoreKbd;
+ req->value = *values;
+ req->ctrlsToChange = req->autoCtrls = req->autoCtrlValues= 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *values = rep.value;
+ return ((rep.value&value_hold)!=0);
+}
+
+Bool
+XkbGetPerClientControls( Display * dpy,
+ unsigned * ctrls)
+{
+register xkbPerClientFlagsReq * req;
+xkbPerClientFlagsReply rep;
+XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) ||
+ (*ctrls & ~(XkbPCF_GrabsUseXKBStateMask|XkbPCF_LookupStateWhenGrabbed|XkbPCF_SendEventUsesXKBState)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbPerClientFlags, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbPerClientFlags;
+ req->deviceSpec = XkbUseCoreKbd;
+ req->change = 0;
+ req->value = 0;
+ req->ctrlsToChange = req->autoCtrls= req->autoCtrlValues= 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (ctrls)
+ *ctrls= (rep.value & (XkbPCF_GrabsUseXKBStateMask |
+ XkbPCF_LookupStateWhenGrabbed |
+ XkbPCF_SendEventUsesXKBState));
+ return (True);
+}
+
+Display *
+XkbOpenDisplay( char * name,
+ int * ev_rtrn,
+ int * err_rtrn,
+ int * major_rtrn,
+ int * minor_rtrn,
+ int * reason)
+{
+ Display* dpy;
+ int major_num,minor_num;
+
+ if ((major_rtrn!=NULL) && (minor_rtrn!=NULL)) {
+ if (!XkbLibraryVersion(major_rtrn,minor_rtrn)) {
+ if (reason!=NULL)
+ *reason= XkbOD_BadLibraryVersion;
+ return NULL;
+ }
+ }
+ else {
+ major_num= XkbMajorVersion;
+ minor_num= XkbMinorVersion;
+ major_rtrn= &major_num;
+ minor_rtrn= &minor_num;
+ }
+ dpy= XOpenDisplay(name);
+ if (dpy==NULL) {
+ if (reason!=NULL)
+ *reason= XkbOD_ConnectionRefused;
+ return NULL;
+ }
+ if (!XkbQueryExtension(dpy,NULL,ev_rtrn,err_rtrn,major_rtrn,minor_rtrn)) {
+ if (reason!=NULL) {
+ if ((*major_rtrn!=0)||(*minor_rtrn!=0))
+ *reason= XkbOD_BadServerVersion;
+ else *reason= XkbOD_NonXkbServer;
+ }
+ XCloseDisplay(dpy);
+ return NULL;
+ }
+ if (reason!=NULL)
+ *reason= XkbOD_Success;
+ return dpy;
+}
+
+void
+XkbSetAtomFuncs(XkbInternAtomFunc getAtom,XkbGetAtomNameFunc getName)
+{
+ _XkbInternAtomFunc= (getAtom?getAtom:XInternAtom);
+ _XkbGetAtomNameFunc= (getName?getName:XGetAtomName);
+ return;
+}
diff --git a/nx-X11/lib/X11/XKBAlloc.c b/nx-X11/lib/X11/XKBAlloc.c
new file mode 100644
index 000000000..9430ac0ed
--- /dev/null
+++ b/nx-X11/lib/X11/XKBAlloc.c
@@ -0,0 +1,504 @@
+/* $Xorg: XKBAlloc.c,v 1.4 2000/08/17 19:44:59 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBAlloc.c,v 3.5 2001/01/17 19:41:48 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#elif defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#ifndef XKB_IN_SERVER
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "XKBlibint.h"
+#include <X11/extensions/XKBgeom.h>
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+#else
+
+#include <stdio.h>
+#include <X11/X.h>
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XKBgeom.h>
+
+#endif /* XKB_IN_SERVER */
+
+/***===================================================================***/
+
+/*ARGSUSED*/
+Status
+XkbAllocCompatMap(XkbDescPtr xkb,unsigned which,unsigned nSI)
+{
+XkbCompatMapPtr compat;
+XkbSymInterpretRec *prev_interpret;
+
+ if (!xkb)
+ return BadMatch;
+ if (xkb->compat) {
+ if (xkb->compat->size_si>=nSI)
+ return Success;
+ compat= xkb->compat;
+ compat->size_si= nSI;
+ if (compat->sym_interpret==NULL)
+ compat->num_si= 0;
+ prev_interpret = compat->sym_interpret;
+ compat->sym_interpret= _XkbTypedRealloc(compat->sym_interpret,
+ nSI,XkbSymInterpretRec);
+ if (compat->sym_interpret==NULL) {
+ _XkbFree(prev_interpret);
+ compat->size_si= compat->num_si= 0;
+ return BadAlloc;
+ }
+ if (compat->num_si!=0) {
+ _XkbClearElems(compat->sym_interpret,compat->num_si,
+ compat->size_si-1,XkbSymInterpretRec);
+ }
+ return Success;
+ }
+ compat= _XkbTypedCalloc(1,XkbCompatMapRec);
+ if (compat==NULL)
+ return BadAlloc;
+ if (nSI>0) {
+ compat->sym_interpret= _XkbTypedCalloc(nSI,XkbSymInterpretRec);
+ if (!compat->sym_interpret) {
+ _XkbFree(compat);
+ return BadAlloc;
+ }
+ }
+ compat->size_si= nSI;
+ compat->num_si= 0;
+ bzero((char *)&compat->groups[0],XkbNumKbdGroups*sizeof(XkbModsRec));
+ xkb->compat= compat;
+ return Success;
+}
+
+
+void
+XkbFreeCompatMap(XkbDescPtr xkb,unsigned which,Bool freeMap)
+{
+register XkbCompatMapPtr compat;
+
+ if ((xkb==NULL)||(xkb->compat==NULL))
+ return;
+ compat= xkb->compat;
+ if (freeMap)
+ which= XkbAllCompatMask;
+ if (which&XkbGroupCompatMask)
+ bzero((char *)&compat->groups[0],XkbNumKbdGroups*sizeof(XkbModsRec));
+ if (which&XkbSymInterpMask) {
+ if ((compat->sym_interpret)&&(compat->size_si>0))
+ _XkbFree(compat->sym_interpret);
+ compat->size_si= compat->num_si= 0;
+ compat->sym_interpret= NULL;
+ }
+ if (freeMap) {
+ _XkbFree(compat);
+ xkb->compat= NULL;
+ }
+ return;
+}
+
+/***===================================================================***/
+
+Status
+XkbAllocNames(XkbDescPtr xkb,unsigned which,int nTotalRG,int nTotalAliases)
+{
+XkbNamesPtr names;
+
+ if (xkb==NULL)
+ return BadMatch;
+ if (xkb->names==NULL) {
+ xkb->names = _XkbTypedCalloc(1,XkbNamesRec);
+ if (xkb->names==NULL)
+ return BadAlloc;
+ }
+ names= xkb->names;
+ if ((which&XkbKTLevelNamesMask)&&(xkb->map!=NULL)&&(xkb->map->types!=NULL)){
+ register int i;
+ XkbKeyTypePtr type;
+
+ type= xkb->map->types;
+ for (i=0;i<xkb->map->num_types;i++,type++) {
+ if (type->level_names==NULL) {
+ type->level_names= _XkbTypedCalloc(type->num_levels,Atom);
+ if (type->level_names==NULL)
+ return BadAlloc;
+ }
+ }
+ }
+ if ((which&XkbKeyNamesMask)&&(names->keys==NULL)) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadValue;
+ names->keys= _XkbTypedCalloc((xkb->max_key_code+1),XkbKeyNameRec);
+ if (names->keys==NULL)
+ return BadAlloc;
+ }
+ if ((which&XkbKeyAliasesMask)&&(nTotalAliases>0)) {
+ if (names->key_aliases==NULL) {
+ names->key_aliases= _XkbTypedCalloc(nTotalAliases,XkbKeyAliasRec);
+ }
+ else if (nTotalAliases>names->num_key_aliases) {
+ XkbKeyAliasRec *prev_aliases = names->key_aliases;
+
+ names->key_aliases= _XkbTypedRealloc(names->key_aliases,
+ nTotalAliases,XkbKeyAliasRec);
+ if (names->key_aliases!=NULL) {
+ _XkbClearElems(names->key_aliases,names->num_key_aliases,
+ nTotalAliases-1,XkbKeyAliasRec);
+ } else {
+ _XkbFree(prev_aliases);
+ }
+ }
+ if (names->key_aliases==NULL) {
+ names->num_key_aliases= 0;
+ return BadAlloc;
+ }
+ names->num_key_aliases= nTotalAliases;
+ }
+ if ((which&XkbRGNamesMask)&&(nTotalRG>0)) {
+ if (names->radio_groups==NULL) {
+ names->radio_groups= _XkbTypedCalloc(nTotalRG,Atom);
+ }
+ else if (nTotalRG>names->num_rg) {
+ Atom *prev_radio_groups = names->radio_groups;
+
+ names->radio_groups= _XkbTypedRealloc(names->radio_groups,nTotalRG,
+ Atom);
+ if (names->radio_groups!=NULL) {
+ _XkbClearElems(names->radio_groups,names->num_rg,nTotalRG-1,
+ Atom);
+ } else {
+ _XkbFree(prev_radio_groups);
+ }
+ }
+ if (names->radio_groups==NULL)
+ return BadAlloc;
+ names->num_rg= nTotalRG;
+ }
+ return Success;
+}
+
+void
+XkbFreeNames(XkbDescPtr xkb,unsigned which,Bool freeMap)
+{
+XkbNamesPtr names;
+
+ if ((xkb==NULL)||(xkb->names==NULL))
+ return;
+ names= xkb->names;
+ if (freeMap)
+ which= XkbAllNamesMask;
+ if (which&XkbKTLevelNamesMask) {
+ XkbClientMapPtr map= xkb->map;
+ if ((map!=NULL)&&(map->types!=NULL)) {
+ register int i;
+ register XkbKeyTypePtr type;
+ type= map->types;
+ for (i=0;i<map->num_types;i++,type++) {
+ if (type->level_names!=NULL) {
+ _XkbFree(type->level_names);
+ type->level_names= NULL;
+ }
+ }
+ }
+ }
+ if ((which&XkbKeyNamesMask)&&(names->keys!=NULL)) {
+ _XkbFree(names->keys);
+ names->keys= NULL;
+ names->num_keys= 0;
+ }
+ if ((which&XkbKeyAliasesMask)&&(names->key_aliases)){
+ _XkbFree(names->key_aliases);
+ names->key_aliases=NULL;
+ names->num_key_aliases=0;
+ }
+ if ((which&XkbRGNamesMask)&&(names->radio_groups)) {
+ _XkbFree(names->radio_groups);
+ names->radio_groups= NULL;
+ names->num_rg= 0;
+ }
+ if (freeMap) {
+ _XkbFree(names);
+ xkb->names= NULL;
+ }
+ return;
+}
+
+/***===================================================================***/
+
+/*ARGSUSED*/
+Status
+XkbAllocControls(XkbDescPtr xkb,unsigned which)
+{
+ if (xkb==NULL)
+ return BadMatch;
+
+ if (xkb->ctrls==NULL) {
+ xkb->ctrls= _XkbTypedCalloc(1,XkbControlsRec);
+ if (!xkb->ctrls)
+ return BadAlloc;
+ }
+ return Success;
+}
+
+/*ARGSUSED*/
+void
+XkbFreeControls(XkbDescPtr xkb,unsigned which,Bool freeMap)
+{
+ if (freeMap && (xkb!=NULL) && (xkb->ctrls!=NULL)) {
+ _XkbFree(xkb->ctrls);
+ xkb->ctrls= NULL;
+ }
+ return;
+}
+
+/***===================================================================***/
+
+Status
+XkbAllocIndicatorMaps(XkbDescPtr xkb)
+{
+ if (xkb==NULL)
+ return BadMatch;
+ if (xkb->indicators==NULL) {
+ xkb->indicators= _XkbTypedCalloc(1,XkbIndicatorRec);
+ if (!xkb->indicators)
+ return BadAlloc;
+ }
+ return Success;
+}
+
+void
+XkbFreeIndicatorMaps(XkbDescPtr xkb)
+{
+ if ((xkb!=NULL)&&(xkb->indicators!=NULL)) {
+ _XkbFree(xkb->indicators);
+ xkb->indicators= NULL;
+ }
+ return;
+}
+
+/***====================================================================***/
+
+XkbDescRec *
+XkbAllocKeyboard(void)
+{
+XkbDescRec *xkb;
+
+ xkb = _XkbTypedCalloc(1,XkbDescRec);
+ if (xkb)
+ xkb->device_spec= XkbUseCoreKbd;
+ return xkb;
+}
+
+void
+XkbFreeKeyboard(XkbDescPtr xkb,unsigned which,Bool freeAll)
+{
+ if (xkb==NULL)
+ return;
+ if (freeAll)
+ which= XkbAllComponentsMask;
+ if (which&XkbClientMapMask)
+ XkbFreeClientMap(xkb,XkbAllClientInfoMask,True);
+ if (which&XkbServerMapMask)
+ XkbFreeServerMap(xkb,XkbAllServerInfoMask,True);
+ if (which&XkbCompatMapMask)
+ XkbFreeCompatMap(xkb,XkbAllCompatMask,True);
+ if (which&XkbIndicatorMapMask)
+ XkbFreeIndicatorMaps(xkb);
+ if (which&XkbNamesMask)
+ XkbFreeNames(xkb,XkbAllNamesMask,True);
+ if ((which&XkbGeometryMask) && (xkb->geom!=NULL))
+ XkbFreeGeometry(xkb->geom,XkbGeomAllMask,True);
+ if (which&XkbControlsMask)
+ XkbFreeControls(xkb,XkbAllControlsMask,True);
+ if (freeAll)
+ _XkbFree(xkb);
+ return;
+}
+
+/***====================================================================***/
+
+XkbDeviceLedInfoPtr
+XkbAddDeviceLedInfo(XkbDeviceInfoPtr devi,unsigned ledClass,unsigned ledId)
+{
+XkbDeviceLedInfoPtr devli;
+register int i;
+
+ if ((!devi)||(!XkbSingleXIClass(ledClass))||(!XkbSingleXIId(ledId)))
+ return NULL;
+ for (i=0,devli=devi->leds;i<devi->num_leds;i++,devli++) {
+ if ((devli->led_class==ledClass)&&(devli->led_id==ledId))
+ return devli;
+ }
+ if (devi->num_leds>=devi->sz_leds) {
+ XkbDeviceLedInfoRec *prev_leds = devi->leds;
+
+ if (devi->sz_leds>0) devi->sz_leds*= 2;
+ else devi->sz_leds= 1;
+ devi->leds= _XkbTypedRealloc(devi->leds,devi->sz_leds,
+ XkbDeviceLedInfoRec);
+ if (!devi->leds) {
+ _XkbFree(prev_leds);
+ devi->sz_leds= devi->num_leds= 0;
+ return NULL;
+ }
+ i= devi->num_leds;
+ for (devli=&devi->leds[i];i<devi->sz_leds;i++,devli++) {
+ bzero(devli,sizeof(XkbDeviceLedInfoRec));
+ devli->led_class= XkbXINone;
+ devli->led_id= XkbXINone;
+ }
+ }
+ devli= &devi->leds[devi->num_leds++];
+ bzero(devli,sizeof(XkbDeviceLedInfoRec));
+ devli->led_class= ledClass;
+ devli->led_id= ledId;
+ return devli;
+}
+
+Status
+XkbResizeDeviceButtonActions(XkbDeviceInfoPtr devi,unsigned newTotal)
+{
+ XkbAction *prev_btn_acts;
+
+ if ((!devi)||(newTotal>255))
+ return BadValue;
+ if ((devi->btn_acts!=NULL)&&(newTotal==devi->num_btns))
+ return Success;
+ if (newTotal==0) {
+ if (devi->btn_acts!=NULL) {
+ _XkbFree(devi->btn_acts);
+ devi->btn_acts= NULL;
+ }
+ devi->num_btns= 0;
+ return Success;
+ }
+ prev_btn_acts = devi->btn_acts;
+ devi->btn_acts= _XkbTypedRealloc(devi->btn_acts,newTotal,XkbAction);
+ if (devi->btn_acts==NULL) {
+ _XkbFree(prev_btn_acts);
+ devi->num_btns= 0;
+ return BadAlloc;
+ }
+ if (newTotal>devi->num_btns) {
+ XkbAction *act;
+ act= &devi->btn_acts[devi->num_btns];
+ bzero((char *)act,(newTotal-devi->num_btns)*sizeof(XkbAction));
+ }
+ devi->num_btns= newTotal;
+ return Success;
+}
+
+/*ARGSUSED*/
+XkbDeviceInfoPtr
+XkbAllocDeviceInfo(unsigned deviceSpec,unsigned nButtons,unsigned szLeds)
+{
+XkbDeviceInfoPtr devi;
+
+ devi= _XkbTypedCalloc(1,XkbDeviceInfoRec);
+ if (devi!=NULL) {
+ devi->device_spec= deviceSpec;
+ devi->has_own_state= False;
+ devi->num_btns= 0;
+ devi->btn_acts= NULL;
+ if (nButtons>0) {
+ devi->num_btns= nButtons;
+ devi->btn_acts= _XkbTypedCalloc(nButtons,XkbAction);
+ if (!devi->btn_acts) {
+ _XkbFree(devi);
+ return NULL;
+ }
+ }
+ devi->dflt_kbd_fb= XkbXINone;
+ devi->dflt_led_fb= XkbXINone;
+ devi->num_leds= 0;
+ devi->sz_leds= 0;
+ devi->leds= NULL;
+ if (szLeds>0) {
+ devi->sz_leds= szLeds;
+ devi->leds= _XkbTypedCalloc(szLeds,XkbDeviceLedInfoRec);
+ if (!devi->leds) {
+ if (devi->btn_acts)
+ _XkbFree(devi->btn_acts);
+ _XkbFree(devi);
+ return NULL;
+ }
+ }
+ }
+ return devi;
+}
+
+
+void
+XkbFreeDeviceInfo(XkbDeviceInfoPtr devi,unsigned which,Bool freeDevI)
+{
+ if (devi) {
+ if (freeDevI) {
+ which= XkbXI_AllDeviceFeaturesMask;
+ if (devi->name) {
+ _XkbFree(devi->name);
+ devi->name= NULL;
+ }
+ }
+ if ((which&XkbXI_ButtonActionsMask)&&(devi->btn_acts)) {
+ _XkbFree(devi->btn_acts);
+ devi->num_btns= 0;
+ devi->btn_acts= NULL;
+ }
+ if ((which&XkbXI_IndicatorsMask)&&(devi->leds)) {
+ register int i;
+ if ((which&XkbXI_IndicatorsMask)==XkbXI_IndicatorsMask) {
+ _XkbFree(devi->leds);
+ devi->sz_leds= devi->num_leds= 0;
+ devi->leds= NULL;
+ }
+ else {
+ XkbDeviceLedInfoPtr devli;
+ for (i=0,devli=devi->leds;i<devi->num_leds;i++,devli++) {
+ if (which&XkbXI_IndicatorMapsMask)
+ bzero((char *)&devli->maps[0],sizeof(devli->maps));
+ else bzero((char *)&devli->names[0],sizeof(devli->names));
+ }
+ }
+ }
+ if (freeDevI)
+ _XkbFree(devi);
+ }
+ return;
+}
diff --git a/nx-X11/lib/X11/XKBBell.c b/nx-X11/lib/X11/XKBBell.c
new file mode 100644
index 000000000..6ea30855e
--- /dev/null
+++ b/nx-X11/lib/X11/XKBBell.c
@@ -0,0 +1,182 @@
+/* $Xorg: XKBBell.c,v 1.3 2000/08/17 19:45:00 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+
+Bool
+XkbDeviceBell( Display * dpy,
+ Window window,
+ int deviceID,
+ int bellClass,
+ int bellID,
+ int percent,
+ Atom name)
+{
+ register xkbBellReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbBell,req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbBell;
+ req->deviceSpec = deviceID;
+ req->window = (CARD32)window;
+ req->bellClass = (CARD16)bellClass;
+ req->bellID = (CARD16)bellID;
+ req->percent = percent;
+ req->forceSound = False;
+ req->eventOnly = False;
+ req->pitch = 0;
+ req->duration = 0;
+ req->name = (CARD32)name;
+ req->pad1= 0; req->pad2= 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbForceDeviceBell( Display * dpy,
+ int deviceID,
+ int bellClass,
+ int bellID,
+ int percent)
+{
+ register xkbBellReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbBell,req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbBell;
+ req->deviceSpec = deviceID;
+ req->window = (CARD32)None;
+ req->bellClass = (CARD16)bellClass;
+ req->bellID = (CARD16)bellID;
+ req->percent = percent;
+ req->forceSound = True;
+ req->eventOnly = False;
+ req->pitch = 0;
+ req->duration = 0;
+ req->name = None;
+ req->pad1= 0; req->pad2= 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbDeviceBellEvent( Display * dpy,
+ Window window,
+ int deviceID,
+ int bellClass,
+ int bellID,
+ int percent,
+ Atom name)
+{
+ register xkbBellReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbBell,req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbBell;
+ req->deviceSpec = deviceID;
+ req->window = (CARD32)window;
+ req->bellClass = (CARD16)bellClass;
+ req->bellID = (CARD16)bellID;
+ req->percent = percent;
+ req->forceSound = False;
+ req->eventOnly = True;
+ req->pitch = 0;
+ req->duration = 0;
+ req->name = (CARD32)name;
+ req->pad1= 0; req->pad2= 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbBell(Display *dpy,Window window,int percent,Atom name)
+{
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) {
+ XBell(dpy,percent);
+ return False;
+ }
+ return XkbDeviceBell(dpy,window,XkbUseCoreKbd,XkbDfltXIClass,XkbDfltXIId,
+ percent,name);
+}
+
+Bool
+XkbForceBell(Display *dpy,int percent)
+{
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) {
+ XBell(dpy,percent);
+ return False;
+ }
+ return XkbForceDeviceBell(dpy,XkbUseCoreKbd,XkbDfltXIClass,XkbDfltXIId,
+ percent);
+}
+
+Bool
+XkbBellEvent(Display *dpy,Window window,int percent,Atom name)
+{
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) {
+ return False;
+ }
+ /* class 0 = KbdFeedbackClass (X Input Extension) */
+ return XkbDeviceBellEvent(dpy,window,XkbUseCoreKbd,
+ XkbDfltXIClass,XkbDfltXIId,
+ percent,name);
+}
+
diff --git a/nx-X11/lib/X11/XKBBind.c b/nx-X11/lib/X11/XKBBind.c
new file mode 100644
index 000000000..e190d0052
--- /dev/null
+++ b/nx-X11/lib/X11/XKBBind.c
@@ -0,0 +1,853 @@
+/* $Xorg: XKBBind.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/X11/XKBBind.c,v 3.19 2003/05/27 22:26:25 tsi Exp $ */
+
+ /* the new monsters ate the old ones */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "XKBlib.h"
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/keysym.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+#ifdef USE_OWN_COMPOSE
+#define COMPOSE_NO_CONST_MEMBERS
+#include "imComp.h"
+#endif
+
+#define AllMods (ShiftMask|LockMask|ControlMask| \
+ Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)
+
+static int _XkbLoadDpy(
+ Display *dpy
+);
+
+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 */
+};
+
+KeySym
+XkbKeycodeToKeysym(Display *dpy,
+#if NeedWidePrototypes
+ unsigned int kc,
+#else
+ KeyCode kc,
+#endif
+ int group,
+ int level)
+{
+ XkbDescRec *xkb;
+
+ if (_XkbUnavailable(dpy))
+ return NoSymbol;
+
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+
+ xkb = dpy->xkb_info->desc;
+ if ((kc<xkb->min_key_code)||(kc>xkb->max_key_code))
+ return NoSymbol;
+
+ if ((group<0)||(level<0)||(group>=XkbKeyNumGroups(xkb,kc)))
+ return NoSymbol;
+ if (level>=XkbKeyGroupWidth(xkb,kc,group)) {
+ /* for compatibility with the core protocol, _always_ allow */
+ /* two symbols in the first two groups. If either of the */
+ /* two is of type ONE_LEVEL, just replicate the first symbol */
+ if ((group>XkbGroup2Index)||(XkbKeyGroupWidth(xkb,kc,group)!=1)||
+ (level!=1)) {
+ return NoSymbol;
+ }
+ level= 0;
+ }
+ return XkbKeySymEntry(xkb,kc,level,group);
+}
+
+KeySym
+XKeycodeToKeysym(Display *dpy,
+#if NeedWidePrototypes
+ unsigned int kc,
+#else
+ KeyCode kc,
+#endif
+ int col)
+{
+ XkbDescRec *xkb;
+
+ if (_XkbUnavailable(dpy))
+ return _XKeycodeToKeysym(dpy, kc, col);
+
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+
+ xkb = dpy->xkb_info->desc;
+ if ((kc<xkb->min_key_code)||(kc>xkb->max_key_code))
+ return NoSymbol;
+
+ if (col>3) {
+ int lastSym,tmp,nGrp;
+
+ lastSym= 3;
+ nGrp= XkbKeyNumGroups(xkb,kc);
+ if ((nGrp>0)&&((tmp=XkbKeyGroupWidth(xkb,kc,XkbGroup1Index))>2)) {
+ if (col<=(lastSym+tmp-2))
+ return XkbKeycodeToKeysym(dpy,kc,XkbGroup1Index,col-lastSym+2);
+ lastSym+= tmp-2;
+ }
+ if ((nGrp>1)&&((tmp=XkbKeyGroupWidth(xkb,kc,XkbGroup2Index))>2)) {
+ if (col<=(lastSym+tmp-2))
+ return XkbKeycodeToKeysym(dpy,kc,XkbGroup2Index,col-lastSym+2);
+ lastSym+= tmp-2;
+ }
+ if (nGrp>2) {
+ tmp= XkbKeyGroupWidth(xkb,kc,XkbGroup3Index);
+ if (col<=lastSym+tmp)
+ return XkbKeycodeToKeysym(dpy,kc,XkbGroup3Index,col-lastSym);
+ lastSym+= tmp;
+ }
+ if (nGrp>3) {
+ tmp= XkbKeyGroupWidth(xkb,kc,XkbGroup4Index);
+ if (col<=lastSym+tmp)
+ return XkbKeycodeToKeysym(dpy,kc,XkbGroup4Index,col-lastSym);
+ }
+ return NoSymbol;
+ }
+ return XkbKeycodeToKeysym(dpy,kc,(col>>1),(col&1));
+}
+
+KeyCode
+XKeysymToKeycode(Display *dpy, KeySym ks)
+{
+ register int i, j, gotOne;
+
+ if (_XkbUnavailable(dpy))
+ return _XKeysymToKeycode(dpy,ks);
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+
+ j= 0;
+ do {
+ register XkbDescRec *xkb = dpy->xkb_info->desc;
+ gotOne= 0;
+ for (i = dpy->min_keycode; i <= dpy->max_keycode; i++) {
+ if ( j<(int)XkbKeyNumSyms(xkb,i) ) {
+ gotOne = 1;
+ if ((XkbKeySym(xkb,i,j)==ks))
+ return i;
+ }
+ }
+ j++;
+ } while (gotOne);
+ return 0;
+}
+
+static int
+_XkbComputeModmap(Display *dpy)
+{
+register XkbDescPtr xkb;
+
+ xkb= dpy->xkb_info->desc;
+ if (XkbGetUpdatedMap(dpy,XkbModifierMapMask,xkb)==Success)
+ return 1;
+ return 0;
+}
+
+unsigned
+XkbKeysymToModifiers(Display *dpy,KeySym ks)
+{
+ XkbDescRec *xkb;
+ register int i,j;
+ register KeySym *pSyms;
+ CARD8 mods;
+
+ if (_XkbUnavailable(dpy))
+ return _XKeysymToModifiers(dpy,ks);
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+
+ if (_XkbNeedModmap(dpy->xkb_info)&&(!_XkbComputeModmap(dpy)))
+ return _XKeysymToModifiers(dpy,ks);
+
+ xkb= dpy->xkb_info->desc;
+ mods= 0;
+ for (i = xkb->min_key_code; i <= (int)xkb->max_key_code; i++) {
+ pSyms= XkbKeySymsPtr(xkb,i);
+ for (j=XkbKeyNumSyms(xkb,i)-1;j>=0;j--) {
+ if (pSyms[j]==ks) {
+ mods|= xkb->map->modmap[i];
+ break;
+ }
+ }
+ }
+ return mods;
+}
+
+KeySym
+XLookupKeysym(register XKeyEvent *event, int col)
+{
+ Display *dpy = event->display;
+ if (_XkbUnavailable(dpy))
+ return _XLookupKeysym(event, col);
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+ return XKeycodeToKeysym(dpy, event->keycode, col);
+}
+
+ /*
+ * Not a public entry point -- XkbTranslateKey is an obsolete name
+ * that is preserved here so that functions linked against the old
+ * version will continue to work in a shared library environment.
+ */
+int
+XkbTranslateKey( register Display * dpy,
+ KeyCode key,
+ register unsigned int mods,
+ unsigned int * mods_rtrn,
+ KeySym * keysym_rtrn);
+int
+XkbTranslateKey( register Display * dpy,
+ KeyCode key,
+ register unsigned int mods,
+ unsigned int * mods_rtrn,
+ KeySym * keysym_rtrn)
+{
+ return XkbLookupKeySym(dpy,key,mods,mods_rtrn,keysym_rtrn);
+}
+
+Bool
+XkbLookupKeySym( register Display * dpy,
+ KeyCode key,
+ register unsigned int mods,
+ unsigned int * mods_rtrn,
+ KeySym * keysym_rtrn)
+{
+ if (_XkbUnavailable(dpy))
+ return _XTranslateKey(dpy, key, mods, mods_rtrn, keysym_rtrn);
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+ return XkbTranslateKeyCode(dpy->xkb_info->desc,key,mods,mods_rtrn,
+ keysym_rtrn);
+}
+
+Bool
+XkbTranslateKeyCode( register XkbDescPtr xkb,
+ KeyCode key,
+ register unsigned int mods,
+ unsigned int * mods_rtrn,
+ KeySym * keysym_rtrn)
+{
+ XkbKeyTypeRec *type;
+ int col,nKeyGroups;
+ unsigned preserve,effectiveGroup;
+ KeySym *syms;
+
+ if (mods_rtrn!=NULL)
+ *mods_rtrn = 0;
+
+ nKeyGroups= XkbKeyNumGroups(xkb,key);
+ if ((!XkbKeycodeInRange(xkb,key))||(nKeyGroups==0)) {
+ if (keysym_rtrn!=NULL)
+ *keysym_rtrn = NoSymbol;
+ return False;
+ }
+
+ syms = XkbKeySymsPtr(xkb,key);
+
+ /* find the offset of the effective group */
+ col = 0;
+ effectiveGroup= XkbGroupForCoreState(mods);
+ if ( effectiveGroup>=nKeyGroups ) {
+ unsigned groupInfo= XkbKeyGroupInfo(xkb,key);
+ switch (XkbOutOfRangeGroupAction(groupInfo)) {
+ default:
+ effectiveGroup %= nKeyGroups;
+ break;
+ case XkbClampIntoRange:
+ effectiveGroup = nKeyGroups-1;
+ break;
+ case XkbRedirectIntoRange:
+ effectiveGroup = XkbOutOfRangeGroupNumber(groupInfo);
+ if (effectiveGroup>=nKeyGroups)
+ effectiveGroup= 0;
+ break;
+ }
+ }
+ col= effectiveGroup*XkbKeyGroupsWidth(xkb,key);
+ type = XkbKeyKeyType(xkb,key,effectiveGroup);
+
+ preserve= 0;
+ if (type->map) { /* find the column (shift level) within the group */
+ register int i;
+ register XkbKTMapEntryPtr entry;
+ for (i=0,entry=type->map;i<type->map_count;i++,entry++) {
+ if ((entry->active)&&((mods&type->mods.mask)==entry->mods.mask)) {
+ col+= entry->level;
+ if (type->preserve)
+ preserve= type->preserve[i].mask;
+ break;
+ }
+ }
+ }
+
+ if (keysym_rtrn!=NULL)
+ *keysym_rtrn= syms[col];
+ if (mods_rtrn) {
+ *mods_rtrn= type->mods.mask&(~preserve);
+ /* The Motif VTS doesn't get the help callback called if help
+ * is bound to Shift+<whatever>, and it appears as though it
+ * is XkbTranslateKeyCode that is causing the problem. The
+ * core X version of XTranslateKey always OR's in ShiftMask
+ * and LockMask for mods_rtrn, so this "fix" keeps this behavior
+ * and solves the VTS problem.
+ */
+ if ((xkb->dpy)&&(xkb->dpy->xkb_info)&&
+ (xkb->dpy->xkb_info->xlib_ctrls&XkbLC_AlwaysConsumeShiftAndLock)) {
+ *mods_rtrn|= (ShiftMask|LockMask);
+ }
+ }
+ return (syms[col]!=NoSymbol);
+}
+
+Status
+XkbRefreshKeyboardMapping(register XkbMapNotifyEvent *event)
+{
+ Display *dpy = event->display;
+ XkbInfoPtr xkbi;
+
+ if (_XkbUnavailable(dpy)) {
+ _XRefreshKeyboardMapping((XMappingEvent *)event);
+ return Success;
+ }
+ xkbi= dpy->xkb_info;
+
+ if (((event->type&0x7f)-xkbi->codes->first_event)!=XkbEventCode)
+ return BadMatch;
+ if (event->xkb_type==XkbNewKeyboardNotify) {
+ _XkbReloadDpy(dpy);
+ return Success;
+ }
+ if (event->xkb_type==XkbMapNotify) {
+ XkbMapChangesRec changes;
+ Status rtrn;
+
+ if (xkbi->flags&XkbMapPending)
+ changes= xkbi->changes;
+ else bzero(&changes,sizeof(changes));
+ XkbNoteMapChanges(&changes,event,XKB_XLIB_MAP_MASK);
+ LockDisplay(dpy);
+ if ((rtrn=XkbGetMapChanges(dpy,xkbi->desc,&changes))!=Success) {
+#ifdef DEBUG
+ fprintf(stderr,"Internal Error! XkbGetMapChanges failed:\n");
+#endif
+ xkbi->changes= changes;
+ }
+ else if (xkbi->flags&XkbMapPending) {
+ xkbi->flags&= ~XkbMapPending;
+ bzero(&xkbi->changes,sizeof(XkbMapChangesRec));
+ }
+ UnlockDisplay(dpy);
+ return rtrn;
+ }
+ return BadMatch;
+}
+
+int
+XRefreshKeyboardMapping(register XMappingEvent *event)
+{
+ XkbEvent *xkbevent = (XkbEvent *)event;
+ Display *dpy = event->display;
+ XkbMapChangesRec changes;
+ XkbInfoPtr xkbi;
+
+ /* always do this for input methods, which still use the old keymap */
+ (void) _XRefreshKeyboardMapping(event);
+
+ if (_XkbUnavailable(dpy))
+ return 1;
+
+ xkbi = dpy->xkb_info;
+
+ if (((event->type&0x7f)-xkbi->codes->first_event)==XkbEventCode)
+ return XkbRefreshKeyboardMapping(&xkbevent->map);
+
+ if (xkbi->flags&XkbXlibNewKeyboard) {
+ _XkbReloadDpy(dpy);
+ return 1;
+ }
+
+ if ((xkbi->flags&XkbMapPending)||(event->request==MappingKeyboard)) {
+ if (xkbi->flags&XkbMapPending) {
+ changes= xkbi->changes;
+ _XkbNoteCoreMapChanges(&changes,event,XKB_XLIB_MAP_MASK);
+ }
+ else {
+ bzero(&changes,sizeof(changes));
+ changes.changed= XkbKeySymsMask;
+ if (xkbi->desc->min_key_code<xkbi->desc->max_key_code) {
+ changes.first_key_sym= xkbi->desc->min_key_code;
+ changes.num_key_syms= xkbi->desc->max_key_code-
+ xkbi->desc->min_key_code+1;
+ }
+ else {
+ changes.first_key_sym= event->first_keycode;
+ changes.num_key_syms= event->count;
+ }
+ }
+
+ if (XkbGetMapChanges(dpy,xkbi->desc, &changes)!=Success) {
+#ifdef DEBUG
+ fprintf(stderr,"Internal Error! XkbGetMapChanges failed:\n");
+ if (changes.changed&XkbKeyTypesMask) {
+ int first= changes.first_type;
+ int last= changes.first_type+changes.num_types-1;
+ fprintf(stderr," types: %d..%d\n",first,last);
+ }
+ if (changes.changed&XkbKeySymsMask) {
+ int first= changes.first_key_sym;
+ int last= changes.first_key_sym+changes.num_key_syms-1;
+ fprintf(stderr," symbols: %d..%d\n",first,last);
+ }
+ if (changes.changed&XkbKeyActionsMask) {
+ int last,first= changes.first_key_act;
+ last= changes.first_key_act+changes.num_key_acts-1;
+ fprintf(stderr," acts: %d..%d\n",first,last);
+ }
+ if (changes.changed&XkbKeyBehaviorsMask) {
+ int last,first= changes.first_key_behavior;
+ last= first+changes.num_key_behaviors-1;
+ fprintf(stderr," behaviors: %d..%d\n",first,last);
+ }
+ if (changes.changed&XkbVirtualModsMask) {
+ fprintf(stderr,"virtual mods: 0x%04x\n",
+ changes.vmods);
+ }
+ if (changes.changed&XkbExplicitComponentsMask) {
+ int last,first= changes.first_key_explicit;
+ last= first+changes.num_key_explicit-1;
+ fprintf(stderr," explicit: %d..%d\n",first,last);
+ }
+#endif
+ }
+ LockDisplay(dpy);
+ if (xkbi->flags&XkbMapPending) {
+ xkbi->flags&= ~XkbMapPending;
+ bzero(&xkbi->changes,sizeof(XkbMapChangesRec));
+ }
+ UnlockDisplay(dpy);
+ }
+ if (event->request==MappingModifier) {
+ LockDisplay(dpy);
+ if (xkbi->desc->map->modmap) {
+ _XkbFree(xkbi->desc->map->modmap);
+ xkbi->desc->map->modmap= NULL;
+ }
+ if (dpy->key_bindings) {
+ register struct _XKeytrans *p;
+ for (p = dpy->key_bindings; p; p = p->next) {
+ register int i;
+ p->state= 0;
+ if (p->mlen>0) {
+ for (i = 0; i < p->mlen; i++) {
+ p->state|= XkbKeysymToModifiers(dpy,p->modifiers[i]);
+ }
+ if (p->state) p->state &= AllMods;
+ else p->state = AnyModifier;
+ }
+ }
+ }
+ UnlockDisplay(dpy);
+ }
+ return 1;
+}
+
+static int
+_XkbLoadDpy(Display *dpy)
+{
+ XkbInfoPtr xkbi;
+ unsigned query,oldEvents;
+ XkbDescRec *desc;
+
+ if (!XkbUseExtension(dpy,NULL,NULL))
+ return 0;
+
+ xkbi = dpy->xkb_info;
+ query = XkbAllClientInfoMask;
+ desc = XkbGetMap(dpy,query,XkbUseCoreKbd);
+ if (!desc) {
+#ifdef DEBUG
+ fprintf(stderr,"Warning! XkbGetMap failed!\n");
+#endif
+ return 0;
+ }
+ LockDisplay(dpy);
+ xkbi->desc = desc;
+
+ UnlockDisplay(dpy);
+ oldEvents= xkbi->selected_events;
+ if (!(xkbi->xlib_ctrls&XkbLC_IgnoreNewKeyboards)) {
+ XkbSelectEventDetails(dpy,xkbi->desc->device_spec,XkbNewKeyboardNotify,
+ XkbNKN_KeycodesMask|XkbNKN_DeviceIDMask,
+ XkbNKN_KeycodesMask|XkbNKN_DeviceIDMask);
+ }
+ XkbSelectEventDetails(dpy,xkbi->desc->device_spec,XkbMapNotify,
+ XkbAllClientInfoMask,XkbAllClientInfoMask);
+ LockDisplay(dpy);
+ xkbi->selected_events= oldEvents;
+ UnlockDisplay(dpy);
+ return 1;
+}
+
+void
+_XkbReloadDpy(Display *dpy)
+{
+ XkbInfoPtr xkbi;
+ XkbDescRec *desc;
+ unsigned oldDeviceID;
+
+ if (_XkbUnavailable(dpy))
+ return;
+
+ xkbi = dpy->xkb_info;
+ LockDisplay(dpy);
+ if (xkbi->desc) {
+ oldDeviceID= xkbi->desc->device_spec;
+ XkbFreeKeyboard(xkbi->desc,XkbAllComponentsMask,True);
+ xkbi->desc= NULL;
+ xkbi->flags&= ~(XkbMapPending|XkbXlibNewKeyboard);
+ xkbi->changes.changed= 0;
+ }
+ else oldDeviceID= XkbUseCoreKbd;
+ UnlockDisplay(dpy);
+ desc = XkbGetMap(dpy,XkbAllClientInfoMask,XkbUseCoreKbd);
+ if (!desc)
+ return;
+ LockDisplay(dpy);
+ xkbi->desc = desc;
+ UnlockDisplay(dpy);
+
+ if (desc->device_spec!=oldDeviceID) {
+ /* transfer(?) event masks here */
+#ifdef NOTYET
+ unsigned oldEvents;
+ oldEvents= xkbi->selected_events;
+ XkbSelectEventDetails(dpy,xkbi->desc->device_spec,XkbMapNotify,
+ XkbAllMapComponentsMask,XkbAllClientInfoMask);
+ LockDisplay(dpy);
+ xkbi->selected_events= oldEvents;
+ UnlockDisplay(dpy);
+#endif
+ }
+ return;
+}
+
+int
+XkbTranslateKeySym( register Display * dpy,
+ register KeySym * sym_rtrn,
+ unsigned int mods,
+ char * buffer,
+ int nbytes,
+ int * extra_rtrn)
+{
+ register XkbInfoPtr xkb;
+ XkbKSToMBFunc cvtr;
+ XPointer priv;
+ char tmp[4];
+ int n;
+
+ xkb= dpy->xkb_info;
+ if (!xkb->cvt.KSToMB) {
+ _XkbGetConverters(_XkbGetCharset(),&xkb->cvt);
+ _XkbGetConverters("ISO8859-1",&xkb->latin1cvt);
+ }
+
+ if (extra_rtrn)
+ *extra_rtrn= 0;
+
+ if ((buffer==NULL)||(nbytes==0)) {
+ buffer= tmp;
+ nbytes= 4;
+ }
+
+ /* see if symbol rebound, if so, return that string. */
+ n = XkbLookupKeyBinding(dpy,*sym_rtrn,mods,buffer,nbytes,extra_rtrn);
+ if (n)
+ return n;
+
+ if ( nbytes>0 )
+ buffer[0]= '\0';
+
+ if ( xkb->cvt.KSToUpper && (mods&LockMask) ) {
+ *sym_rtrn = (*xkb->cvt.KSToUpper)(*sym_rtrn);
+ }
+ if (xkb->xlib_ctrls & XkbLC_ForceLatin1Lookup) {
+ cvtr = xkb->latin1cvt.KSToMB;
+ priv = xkb->latin1cvt.KSToMBPriv;
+ } else {
+ cvtr = xkb->cvt.KSToMB;
+ priv = xkb->cvt.KSToMBPriv;
+ }
+
+ n = (*cvtr)(priv,*sym_rtrn,buffer,nbytes,extra_rtrn);
+
+ if ((!xkb->cvt.KSToUpper)&&( mods&LockMask )) {
+ register int i;
+ int change;
+ char ch;
+ for (i=change=0;i<n;i++) {
+ ch= toupper(buffer[i]);
+ change= (change||(buffer[i]!=ch));
+ buffer[i] = ch;
+ }
+ if (change) {
+ if (n==1)
+ *sym_rtrn=(*xkb->cvt.MBToKS)(xkb->cvt.MBToKSPriv,buffer,n,0);
+ else *sym_rtrn= NoSymbol;
+ }
+ }
+
+ if ( mods&ControlMask ) {
+ if ( n==1 ) {
+ buffer[0]= XkbToControl(buffer[0]);
+ if ( nbytes>1 )
+ buffer[1]= '\0';
+ return 1;
+ }
+ if ( nbytes > 0 )
+ buffer[0]= '\0';
+ return 0;
+ }
+ return n;
+}
+
+int
+XLookupString ( register XKeyEvent * event,
+ char * buffer,
+ int nbytes,
+ KeySym * keysym,
+ XComposeStatus * status)
+{
+ KeySym dummy;
+ int rtrnLen;
+ unsigned int new_mods;
+ Display *dpy = event->display;
+
+ if (keysym==NULL)
+ keysym= &dummy;
+ if (!XkbLookupKeySym(dpy,event->keycode,event->state, &new_mods,keysym))
+ return 0;
+ new_mods= (event->state&(~new_mods));
+
+ /* find the group where a symbol can be converted to control one */
+ if (new_mods&ControlMask && *keysym > 0x7F &&
+ (dpy->xkb_info->xlib_ctrls & XkbLC_ControlFallback)) {
+ XKeyEvent tmp_ev = *event;
+ KeySym tmp_keysym;
+ unsigned int tmp_new_mods;
+ if (_XkbUnavailable(dpy)) {
+ tmp_ev.state= event->state ^ dpy->mode_switch;
+ if (XkbLookupKeySym(dpy, tmp_ev.keycode, tmp_ev.state,
+ &tmp_new_mods, &tmp_keysym) &&
+ tmp_keysym != NoSymbol && tmp_keysym < 0x80 ) {
+ *keysym = tmp_keysym;
+ }
+ } else {
+ int n = XkbKeyNumGroups(dpy->xkb_info->desc, tmp_ev.keycode);
+ int i;
+ for (i = 0; i < n; i++) {
+ if (XkbGroupForCoreState(event->state) == i)
+ continue;
+ tmp_ev.state= XkbBuildCoreState(tmp_ev.state, i);
+ if (XkbLookupKeySym(dpy, tmp_ev.keycode, tmp_ev.state,
+ &tmp_new_mods, &tmp_keysym) &&
+ tmp_keysym != NoSymbol && tmp_keysym < 0x80 ) {
+ *keysym = tmp_keysym;
+ new_mods= (event->state&(~tmp_new_mods));
+ break;
+ }
+ }
+ }
+ }
+
+#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(*keysym,event->keycode,status) ) {
+ XimCompRtrn rtrn;
+
+ switch (XimCompProcessSym(status,*keysym,&rtrn)) {
+ case XIM_COMP_IGNORE:
+ break;
+ case XIM_COMP_IN_PROGRESS:
+ if ( keysym!=NULL )
+ *keysym = NoSymbol;
+#ifndef NO_COMPOSE_LED
+ if ( dpy->xkb_info->xlib_ctrls&XkbLC_ComposeLED ) {
+ XkbSetNamedIndicator(dpy,dpy->xkb_info->composeLED,
+ True,True,False,NULL);
+ }
+#endif
+ return 0;
+ case XIM_COMP_FAIL:
+ {
+ static Atom _ComposeFail= None;
+ int n = 0, len= 0;
+#ifndef NO_COMPOSE_LED
+ if ( dpy->xkb_info->xlib_ctrls&XkbLC_ComposeLED ) {
+ XkbSetNamedIndicator(dpy,dpy->xkb_info->composeLED,
+ True,False,False,NULL);
+ }
+#endif
+#ifndef NO_BELL_ON_COMPOSE_FAIL
+ if (dpy->xkb_info->xlib_ctrls&XkbLC_BeepOnComposeFail) {
+ if (_ComposeFail==None)
+ _ComposeFail= XInternAtom(dpy,"ComposeFail",0);
+ XkbBell(dpy,event->window,0,_ComposeFail);
+ }
+#endif
+ for (n=len=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
+ if ( nbytes-len > 0 ) {
+ len+= XkbTranslateKeySym(dpy,&rtrn.sym[n],new_mods,
+ buffer+len,nbytes-len,
+ NULL);
+ }
+ }
+ if ( keysym!=NULL ) {
+ if ( n==1 ) *keysym = rtrn.sym[0];
+ else *keysym = NoSymbol;
+ }
+ return len;
+ }
+ case XIM_COMP_SUCCEED:
+ {
+ int len,n = 0;
+
+#ifndef NO_COMPOSE_LED
+ if ( dpy->xkb_info->xlib_ctrls&XkbLC_ComposeLED ) {
+ XkbSetNamedIndicator(dpy,dpy->xkb_info->composeLED,
+ True,False,False,NULL);
+ }
+#endif
+ *keysym = rtrn.matchSym;
+ if ( rtrn.str[0]!='\0' ) {
+ strncpy(buffer,rtrn.str,nbytes-1);
+ buffer[nbytes-1]= '\0';
+ len = (int)strlen(buffer);
+ }
+ else {
+ len = XkbTranslateKeySym(dpy,keysym,new_mods,
+ buffer,nbytes,
+ NULL);
+ }
+ for (n=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
+ if ( nbytes-len > 0 ) {
+ len+= XkbTranslateKeySym(dpy,&rtrn.sym[n],
+ event->state,
+ buffer+len,nbytes-len,
+ NULL);
+ }
+ }
+ return len;
+ }
+ }
+ }
+ }
+#endif
+
+ /* We *should* use the new_mods (which does not contain any modifiers */
+ /* that were used to compute the symbol here, but pre-XKB XLookupString */
+ /* did not and we have to remain compatible. Sigh. */
+ if (_XkbUnavailable(dpy) ||
+ (dpy->xkb_info->xlib_ctrls&XkbLC_ConsumeLookupMods)==0)
+ new_mods= event->state;
+
+ rtrnLen= XkbLookupKeyBinding(dpy,*keysym,new_mods,buffer,nbytes,NULL);
+ if (rtrnLen>0)
+ return rtrnLen;
+
+ return XkbTranslateKeySym(dpy,keysym,new_mods,buffer,nbytes,NULL);
+}
+
+
+int
+XkbLookupKeyBinding( Display * dpy,
+ register KeySym sym,
+ unsigned int mods,
+ char * buffer,
+ int nbytes,
+ int * extra_rtrn)
+{
+ register struct _XKeytrans *p;
+
+ if (extra_rtrn)
+ *extra_rtrn= 0;
+ for (p = dpy->key_bindings; p; p = p->next) {
+ if (((mods & AllMods) == p->state) && (sym == p->key)) {
+ int tmp = p->len;
+ if (tmp > nbytes) {
+ if (extra_rtrn)
+ *extra_rtrn= (tmp-nbytes);
+ tmp = nbytes;
+ }
+ memcpy (buffer, p->string, tmp);
+ if (tmp < nbytes) buffer[tmp]= '\0';
+ return tmp;
+ }
+ }
+ return 0;
+}
+
+char
+XkbToControl( char ch )
+{
+ register char c = ch;
+
+ 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;
+ return c;
+}
diff --git a/nx-X11/lib/X11/XKBCompat.c b/nx-X11/lib/X11/XKBCompat.c
new file mode 100644
index 000000000..5886e4d26
--- /dev/null
+++ b/nx-X11/lib/X11/XKBCompat.c
@@ -0,0 +1,251 @@
+/* $Xorg: XKBCompat.c,v 1.3 2000/08/17 19:45:00 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#define NEED_MAP_READERS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+Status
+_XkbReadGetCompatMapReply( Display * dpy,
+ xkbGetCompatMapReply * rep,
+ XkbDescPtr xkb,
+ int * nread_rtrn)
+{
+register int i;
+XkbReadBufferRec buf;
+
+ if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
+ return BadAlloc;
+
+ if (nread_rtrn)
+ *nread_rtrn= (int)rep->length*4;
+
+ i= rep->firstSI+rep->nSI;
+ if ((!xkb->compat)&&
+ (XkbAllocCompatMap(xkb,XkbAllCompatMask,i)!=Success))
+ return BadAlloc;
+
+ if (rep->nSI!=0) {
+ XkbSymInterpretRec *syms;
+ xkbSymInterpretWireDesc *wire;
+
+ wire= (xkbSymInterpretWireDesc *)_XkbGetReadBufferPtr(&buf,
+ rep->nSI*SIZEOF(xkbSymInterpretWireDesc));
+ if (wire==NULL)
+ goto BAILOUT;
+ syms= &xkb->compat->sym_interpret[rep->firstSI];
+
+ for (i=0;i<rep->nSI;i++,syms++,wire++) {
+ syms->sym= wire->sym;
+ syms->mods= wire->mods;
+ syms->match= wire->match;
+ syms->virtual_mod= wire->virtualMod;
+ syms->flags= wire->flags;
+ syms->act= *((XkbAnyAction *)&wire->act);
+ }
+ xkb->compat->num_si+= rep->nSI;
+ }
+
+ if (rep->groups&XkbAllGroupsMask) {
+ register unsigned bit,nGroups;
+ xkbModsWireDesc * wire;
+ for (i=0,nGroups=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if (rep->groups&bit)
+ nGroups++;
+ }
+ wire= (xkbModsWireDesc *)_XkbGetReadBufferPtr(&buf,
+ nGroups*SIZEOF(xkbModsWireDesc));
+ if (wire==NULL)
+ goto BAILOUT;
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if ((rep->groups&bit)==0)
+ continue;
+ xkb->compat->groups[i].mask= wire->mask;
+ xkb->compat->groups[i].real_mods= wire->realMods;
+ xkb->compat->groups[i].vmods= wire->virtualMods;
+ wire++;
+ }
+ }
+ i= _XkbFreeReadBuffer(&buf);
+ if (i)
+ fprintf(stderr,"CompatMapReply! Bad length (%d extra bytes)\n",i);
+ if (i || buf.error)
+ return BadLength;
+ return Success;
+BAILOUT:
+ _XkbFreeReadBuffer(&buf);
+ return BadLength;
+}
+
+Status
+XkbGetCompatMap(Display *dpy,unsigned which,XkbDescPtr xkb)
+{
+ register xkbGetCompatMapReq *req;
+ xkbGetCompatMapReply rep;
+ Status status;
+ XkbInfoPtr xkbi;
+
+ if ( (!dpy) || (!xkb) || (dpy->flags & XlibDisplayNoXkb) ||
+ ((xkb->dpy!=NULL)&&(xkb->dpy!=dpy)) ||
+ (!dpy->xkb_info && (!XkbUseExtension(dpy,NULL,NULL))))
+ return BadAccess;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbGetCompatMap, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetCompatMap;
+ req->deviceSpec = xkb->device_spec;
+ if (which&XkbSymInterpMask)
+ req->getAllSI= True;
+ else req->getAllSI= False;
+ req->firstSI= req->nSI= 0;
+
+ if (which&XkbGroupCompatMask)
+ req->groups= XkbAllGroupsMask;
+ else req->groups= 0;
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadLength;
+ }
+ if (xkb->dpy==NULL)
+ xkb->dpy= dpy;
+ if (xkb->device_spec==XkbUseCoreKbd)
+ xkb->device_spec= rep.deviceID;
+
+ status = _XkbReadGetCompatMapReply(dpy,&rep,xkb,NULL);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+static Bool
+_XkbWriteSetCompatMap(Display *dpy,xkbSetCompatMapReq *req,XkbDescPtr xkb)
+{
+CARD16 firstSI;
+CARD16 nSI;
+int size;
+register int i,nGroups;
+register unsigned bit;
+unsigned groups;
+char * buf;
+
+ firstSI = req->firstSI;
+ nSI = req->nSI;
+ size= nSI*SIZEOF(xkbSymInterpretWireDesc);
+ nGroups= 0;
+ groups= req->groups;
+ if (groups&XkbAllGroupsMask) {
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if (groups&bit)
+ nGroups++;
+ }
+ size+= SIZEOF(xkbModsWireDesc)*nGroups;
+ }
+ req->length+= size/4;
+ BufAlloc(char *,buf,size);
+ if (!buf)
+ return False;
+
+ if (nSI) {
+ XkbSymInterpretPtr sym= &xkb->compat->sym_interpret[firstSI];
+ xkbSymInterpretWireDesc *wire= (xkbSymInterpretWireDesc *)buf;
+ for (i=0;i<nSI;i++,wire++,sym++) {
+ wire->sym= (CARD32)sym->sym;
+ wire->mods= sym->mods;
+ wire->match= sym->match;
+ wire->flags= sym->flags;
+ wire->virtualMod= sym->virtual_mod;
+ memcpy(&wire->act,&sym->act,sz_xkbActionWireDesc);
+ }
+ buf+= nSI*SIZEOF(xkbSymInterpretWireDesc);
+ }
+ if (groups&XkbAllGroupsMask) {
+ xkbModsWireDesc * out;
+
+ out= (xkbModsWireDesc *)buf;
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if ((groups&bit)!=0) {
+ out->mask= xkb->compat->groups[i].mask;
+ out->realMods= xkb->compat->groups[i].real_mods;
+ out->virtualMods= xkb->compat->groups[i].vmods;
+ out++;
+ }
+ }
+ buf+= nGroups*SIZEOF(xkbModsWireDesc);
+ }
+ return True;
+}
+
+Bool
+XkbSetCompatMap(Display *dpy,unsigned which,XkbDescPtr xkb,Bool updateActions)
+{
+ register xkbSetCompatMapReq *req;
+ Status ok;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) || (dpy!=xkb->dpy) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!xkb->compat) ||
+ ((which&XkbSymInterpMask)&&(!xkb->compat->sym_interpret)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetCompatMap, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetCompatMap;
+ req->deviceSpec = xkb->device_spec;
+ req->recomputeActions = updateActions;
+ if (which&XkbSymInterpMask) {
+ req->truncateSI = True;
+ req->firstSI= 0;
+ req->nSI= xkb->compat->num_si;
+ }
+ else {
+ req->truncateSI = False;
+ req->firstSI= 0;
+ req->nSI= 0;
+ }
+ if (which&XkbGroupCompatMask)
+ req->groups= XkbAllGroupsMask;
+ else req->groups= 0;
+ ok= _XkbWriteSetCompatMap(dpy,req,xkb);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ok;
+}
+
diff --git a/nx-X11/lib/X11/XKBCtrls.c b/nx-X11/lib/X11/XKBCtrls.c
new file mode 100644
index 000000000..0ea131aa0
--- /dev/null
+++ b/nx-X11/lib/X11/XKBCtrls.c
@@ -0,0 +1,356 @@
+/* $Xorg: XKBCtrls.c,v 1.3 2000/08/17 19:45:00 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBCtrls.c,v 1.4 2002/12/10 04:33:48 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+
+static xkbSetControlsReq *
+_XkbGetSetControlsReq(Display *dpy,XkbInfoPtr xkbi,unsigned int deviceSpec)
+{
+xkbSetControlsReq *req;
+
+ GetReq(kbSetControls,req);
+ bzero(req,SIZEOF(xkbSetControlsReq));
+ req->reqType = xkbi->codes->major_opcode;
+ req->length = (SIZEOF(xkbSetControlsReq)>>2);
+ req->xkbReqType = X_kbSetControls;
+ req->deviceSpec = deviceSpec;
+ return req;
+}
+
+Bool
+XkbSetAutoRepeatRate( Display *dpy,
+ unsigned int deviceSpec,
+ unsigned int timeout,
+ unsigned int interval)
+{
+ register xkbSetControlsReq *req;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,deviceSpec);
+ req->changeCtrls = XkbRepeatKeysMask;
+ req->repeatDelay = timeout;
+ req->repeatInterval = interval;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbGetAutoRepeatRate( Display * dpy,
+ unsigned int deviceSpec,
+ unsigned int * timeoutp,
+ unsigned int * intervalp)
+{
+ register xkbGetControlsReq *req;
+ xkbGetControlsReply rep;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbGetControls, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetControls;
+ req->deviceSpec = deviceSpec;
+ if (!_XReply(dpy, (xReply *)&rep,
+ (SIZEOF(xkbGetControlsReply)-SIZEOF(xReply))>>2, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *timeoutp = rep.repeatDelay;
+ *intervalp = rep.repeatInterval;
+ return True;
+}
+
+Bool
+XkbSetServerInternalMods( Display * dpy,
+ unsigned deviceSpec,
+ unsigned affectReal,
+ unsigned realValues,
+ unsigned affectVirtual,
+ unsigned virtualValues)
+{
+ register xkbSetControlsReq *req;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,deviceSpec);
+ req->affectInternalMods = affectReal;
+ req->internalMods = realValues;
+ req->affectInternalVMods= affectVirtual;
+ req->internalVMods= virtualValues;
+ req->changeCtrls = XkbInternalModsMask;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbSetIgnoreLockMods( Display * dpy,
+ unsigned int deviceSpec,
+ unsigned affectReal,
+ unsigned realValues,
+ unsigned affectVirtual,
+ unsigned virtualValues)
+{
+ register xkbSetControlsReq *req;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,deviceSpec);
+ req->affectIgnoreLockMods= affectReal;
+ req->ignoreLockMods = realValues;
+ req->affectIgnoreLockVMods= affectVirtual;
+ req->ignoreLockVMods= virtualValues;
+ req->changeCtrls = XkbIgnoreLockModsMask;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbChangeEnabledControls( Display * dpy,
+ unsigned deviceSpec,
+ unsigned affect,
+ unsigned values)
+{
+ register xkbSetControlsReq *req;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,deviceSpec);
+ req->affectEnabledCtrls= affect;
+ req->enabledCtrls= (affect&values);
+ req->changeCtrls = XkbControlsEnabledMask;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XkbGetControls(Display *dpy, unsigned long which, XkbDescPtr xkb)
+{
+ register xkbGetControlsReq *req;
+ xkbGetControlsReply rep;
+ XkbControlsPtr ctrls;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ if ((!xkb) || (!which))
+ return BadMatch;
+
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbGetControls, req);
+ if (!xkb->ctrls) {
+ xkb->ctrls = _XkbTypedCalloc(1,XkbControlsRec);
+ if (!xkb->ctrls) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadAlloc;
+ }
+ }
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetControls;
+ req->deviceSpec = xkb->device_spec;
+ if (!_XReply(dpy, (xReply *)&rep,
+ (SIZEOF(xkbGetControlsReply)-SIZEOF(xReply))>>2, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadImplementation;
+ }
+ if (xkb->device_spec==XkbUseCoreKbd)
+ xkb->device_spec= rep.deviceID;
+ ctrls= xkb->ctrls;
+ if (which&XkbControlsEnabledMask)
+ ctrls->enabled_ctrls = rep.enabledCtrls;
+ ctrls->num_groups= rep.numGroups;
+ if (which&XkbGroupsWrapMask)
+ ctrls->groups_wrap= rep.groupsWrap;
+ if (which&XkbInternalModsMask) {
+ ctrls->internal.mask = rep.internalMods;
+ ctrls->internal.real_mods = rep.internalRealMods;
+ ctrls->internal.vmods = rep.internalVMods;
+ }
+ if (which&XkbIgnoreLockModsMask) {
+ ctrls->ignore_lock.mask = rep.ignoreLockMods;
+ ctrls->ignore_lock.real_mods = rep.ignoreLockRealMods;
+ ctrls->ignore_lock.vmods = rep.ignoreLockVMods;
+ }
+ if (which&XkbRepeatKeysMask) {
+ ctrls->repeat_delay = rep.repeatDelay;
+ ctrls->repeat_interval = rep.repeatInterval;
+ }
+ if (which&XkbSlowKeysMask)
+ ctrls->slow_keys_delay = rep.slowKeysDelay;
+ if (which&XkbBounceKeysMask)
+ ctrls->debounce_delay = rep.debounceDelay;
+ if (which&XkbMouseKeysMask) {
+ ctrls->mk_dflt_btn = rep.mkDfltBtn;
+ }
+ if (which&XkbMouseKeysAccelMask) {
+ ctrls->mk_delay = rep.mkDelay;
+ ctrls->mk_interval = rep.mkInterval;
+ ctrls->mk_time_to_max = rep.mkTimeToMax;
+ ctrls->mk_max_speed = rep.mkMaxSpeed;
+ ctrls->mk_curve = rep.mkCurve;
+ }
+ if (which&XkbAccessXKeysMask)
+ ctrls->ax_options= rep.axOptions;
+ if (which&XkbStickyKeysMask) {
+ ctrls->ax_options &= ~XkbAX_SKOptionsMask;
+ ctrls->ax_options |= rep.axOptions & XkbAX_SKOptionsMask;
+ }
+ if (which&XkbAccessXFeedbackMask) {
+ ctrls->ax_options &= ~XkbAX_FBOptionsMask;
+ ctrls->ax_options |= rep.axOptions & XkbAX_FBOptionsMask;
+ }
+ if (which&XkbAccessXTimeoutMask) {
+ ctrls->ax_timeout = rep.axTimeout;
+ ctrls->axt_ctrls_mask = rep.axtCtrlsMask;
+ ctrls->axt_ctrls_values = rep.axtCtrlsValues;
+ ctrls->axt_opts_mask = rep.axtOptsMask;
+ ctrls->axt_opts_values= rep.axtOptsValues;
+ }
+ if (which&XkbPerKeyRepeatMask) {
+ memcpy(ctrls->per_key_repeat,rep.perKeyRepeat,
+ XkbPerKeyBitArraySize);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return Success;
+}
+
+Bool
+XkbSetControls(Display *dpy, unsigned long which, XkbDescPtr xkb)
+{
+ register xkbSetControlsReq *req;
+ XkbControlsPtr ctrls;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!xkb)||(!xkb->ctrls))
+ return False;
+
+ ctrls= xkb->ctrls;
+ LockDisplay(dpy);
+ req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,xkb->device_spec);
+ req->changeCtrls = (CARD32)which;
+ if (which&XkbInternalModsMask) {
+ req->affectInternalMods= ~0;
+ req->internalMods= ctrls->internal.real_mods;
+ req->affectInternalVMods = ~0;
+ req->internalVMods= ctrls->internal.vmods;
+ }
+ if (which&XkbIgnoreLockModsMask) {
+ req->affectIgnoreLockMods= ~0;
+ req->ignoreLockMods= ctrls->ignore_lock.real_mods;
+ req->affectIgnoreLockVMods= ~0;
+ req->ignoreLockVMods= ctrls->ignore_lock.vmods;
+ }
+ if (which&XkbControlsEnabledMask) {
+ req->affectEnabledCtrls= XkbAllBooleanCtrlsMask;
+ req->enabledCtrls= ctrls->enabled_ctrls;
+ }
+ if (which&XkbRepeatKeysMask) {
+ req->repeatDelay = ctrls->repeat_delay;
+ req->repeatInterval = ctrls->repeat_interval;
+ }
+ if (which&XkbSlowKeysMask)
+ req->slowKeysDelay = ctrls->slow_keys_delay;
+ if (which&XkbBounceKeysMask)
+ req->debounceDelay = ctrls->debounce_delay;
+ if (which&XkbMouseKeysMask) {
+ req->mkDfltBtn = ctrls->mk_dflt_btn;
+ }
+ if (which&XkbGroupsWrapMask)
+ req->groupsWrap= ctrls->groups_wrap;
+ if (which&(XkbAccessXKeysMask|XkbStickyKeysMask|XkbAccessXFeedbackMask))
+ req->axOptions= ctrls->ax_options;
+ if (which&XkbMouseKeysAccelMask) {
+ req->mkDelay = ctrls->mk_delay;
+ req->mkInterval = ctrls->mk_interval;
+ req->mkTimeToMax = ctrls->mk_time_to_max;
+ req->mkMaxSpeed = ctrls->mk_max_speed;
+ req->mkCurve = ctrls->mk_curve;
+ }
+ if (which&XkbAccessXTimeoutMask) {
+ req->axTimeout = ctrls->ax_timeout;
+ req->axtCtrlsMask = ctrls->axt_ctrls_mask;
+ req->axtCtrlsValues = ctrls->axt_ctrls_values;
+ req->axtOptsMask = ctrls->axt_opts_mask;
+ req->axtOptsValues=ctrls->axt_opts_values;
+ }
+ if (which&XkbPerKeyRepeatMask) {
+ memcpy(req->perKeyRepeat,ctrls->per_key_repeat,
+ XkbPerKeyBitArraySize);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/***====================================================================***/
+
+void
+XkbNoteControlsChanges( XkbControlsChangesPtr old,
+ XkbControlsNotifyEvent * new,
+ unsigned int wanted)
+{
+ old->changed_ctrls|= (new->changed_ctrls&wanted);
+ if (new->changed_ctrls&XkbControlsEnabledMask&wanted)
+ old->enabled_ctrls_changes^= new->enabled_ctrl_changes;
+ /* num_groups_changed?? */
+ return;
+}
diff --git a/nx-X11/lib/X11/XKBCvt.c b/nx-X11/lib/X11/XKBCvt.c
new file mode 100644
index 000000000..1bdf81cd4
--- /dev/null
+++ b/nx-X11/lib/X11/XKBCvt.c
@@ -0,0 +1,340 @@
+/* $Xorg: XKBCvt.c,v 1.5 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+Copyright 1988, 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.
+
+*/
+/* $XFree86: xc/lib/X11/XKBCvt.c,v 3.34 2002/10/08 23:31:35 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcPubI.h"
+#include "Ximint.h"
+#include <X11/Xutil.h>
+#include <X11/Xmd.h>
+#define XK_LATIN1
+#define XK_PUBLISHING
+#include <X11/keysym.h>
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+#include <X11/Xlocale.h>
+#include <ctype.h>
+#include <X11/Xos.h>
+
+#ifdef __sgi_not_xconsortium
+#define XKB_EXTEND_LOOKUP_STRING
+#endif
+
+static int
+_XkbHandleSpecialSym(KeySym keysym, char *buffer, int nbytes, int *extra_rtrn)
+{
+
+ /* try to convert to Latin-1, handling ctrl */
+ if (!(((keysym >= XK_BackSpace) && (keysym <= XK_Clear)) ||
+ (keysym == XK_Return) || (keysym == XK_Escape) ||
+ (keysym == XK_KP_Space) || (keysym == XK_KP_Tab) ||
+ (keysym == XK_KP_Enter) ||
+ ((keysym >= XK_KP_Multiply) && (keysym <= XK_KP_9)) ||
+ (keysym == XK_KP_Equal) ||
+ (keysym == XK_Delete)))
+ return 0;
+
+ if (nbytes<1) {
+ if (extra_rtrn)
+ *extra_rtrn= 1;
+ return 0;
+ }
+ /* if X keysym, convert to ascii by grabbing low 7 bits */
+ if (keysym == XK_KP_Space)
+ buffer[0] = XK_space & 0x7F; /* patch encoding botch */
+ else if (keysym == XK_hyphen)
+ buffer[0] = (char)(XK_minus & 0xFF); /* map to equiv character */
+ else buffer[0] = (char)(keysym & 0x7F);
+ return 1;
+}
+
+/*ARGSUSED*/
+static int
+_XkbKSToKnownSet ( XPointer priv,
+ KeySym keysym,
+ char * buffer,
+ int nbytes,
+ int * extra_rtrn)
+{
+ char tbuf[8],*buf;
+
+ if (extra_rtrn)
+ *extra_rtrn= 0;
+
+ /* convert "dead" diacriticals for dumb applications */
+ if ( (keysym&0xffffff00)== 0xfe00 ) {
+ switch ( keysym ) {
+ case XK_dead_grave: keysym = XK_grave; break;
+ case XK_dead_acute: keysym = XK_acute; break;
+ case XK_dead_circumflex: keysym = XK_asciicircum; break;
+ case XK_dead_tilde: keysym = XK_asciitilde; break;
+ case XK_dead_macron: keysym = XK_macron; break;
+ case XK_dead_breve: keysym = XK_breve; break;
+ case XK_dead_abovedot: keysym = XK_abovedot; break;
+ case XK_dead_diaeresis: keysym = XK_diaeresis; break;
+ case XK_dead_abovering: keysym = XK_degree; break;
+ case XK_dead_doubleacute: keysym = XK_doubleacute; break;
+ case XK_dead_caron: keysym = XK_caron; break;
+ case XK_dead_cedilla: keysym = XK_cedilla; break;
+ case XK_dead_ogonek : keysym = XK_ogonek; break;
+ case XK_dead_iota: keysym = XK_Greek_iota; break;
+#ifdef XK_KATAKANA
+ case XK_dead_voiced_sound: keysym = XK_voicedsound; break;
+ case XK_dead_semivoiced_sound:keysym = XK_semivoicedsound; break;
+#endif
+ }
+ }
+
+ if (nbytes<1) buf= tbuf;
+ else buf= buffer;
+
+ if ((keysym&0xffffff00)==0xff00) {
+ return _XkbHandleSpecialSym(keysym, buf, nbytes, extra_rtrn);
+ }
+ return _XimGetCharCode (priv, keysym, (unsigned char *)buf, nbytes);
+}
+
+typedef struct _XkbToKS {
+ unsigned prefix;
+ char *map;
+} XkbToKS;
+
+/*ARGSUSED*/
+static KeySym
+_XkbKnownSetToKS(XPointer priv,char *buffer,int nbytes,Status *status)
+{
+ if (nbytes!=1)
+ return NoSymbol;
+ if (((buffer[0]&0x80)==0)&&(buffer[0]>=32))
+ return buffer[0];
+ else if ((buffer[0]&0x7f)>=32) {
+ XkbToKS *map= (XkbToKS *)priv;
+ if ( map ) {
+ if ( map->map ) return map->prefix|map->map[buffer[0]&0x7f];
+ else return map->prefix|buffer[0];
+ }
+ return buffer[0];
+ }
+ return NoSymbol;
+}
+
+static KeySym
+__XkbDefaultToUpper(KeySym sym)
+{
+ KeySym lower,upper;
+
+ XConvertCase(sym, &lower, &upper);
+ return upper;
+}
+
+#ifdef XKB_EXTEND_LOOKUP_STRING
+static int
+Strcmp(char *str1, char *str2)
+{
+ char str[256];
+ char c, *s;
+
+ /*
+ * unchecked strings from the environment can end up here, so check
+ * the length before copying.
+ */
+ if (strlen(str1) >= sizeof(str)) /* almost certain it's a mismatch */
+ return 1;
+
+ for (s = str; (c = *str1++); ) {
+ if (isupper(c))
+ c = tolower(c);
+ *s++ = c;
+ }
+ *s = '\0';
+ return (strcmp(str, str2));
+}
+#endif
+
+int
+_XkbGetConverters(char *encoding_name, XkbConverters *cvt_rtrn)
+{
+ if ( !cvt_rtrn ) return 0;
+
+ cvt_rtrn->KSToMB = _XkbKSToKnownSet;
+ cvt_rtrn->KSToMBPriv = _XimGetLocaleCode(encoding_name);
+ cvt_rtrn->MBToKS = _XkbKnownSetToKS;
+ cvt_rtrn->MBToKSPriv = NULL;
+ cvt_rtrn->KSToUpper = __XkbDefaultToUpper;
+ return 1;
+}
+
+/***====================================================================***/
+
+/*
+ * The function _XkbGetCharset seems to be missnamed as what it seems to
+ * be used for is to determine the encoding-name for the locale. ???
+ */
+
+#ifdef XKB_EXTEND_LOOKUP_STRING
+
+/*
+ * XKB_EXTEND_LOOKUP_STRING is not used by the SI. It is used by various
+ * X Consortium/X Project Team members, so we leave it in the source as
+ * an simplify integration by these companies.
+ */
+
+#define CHARSET_FILE "/usr/lib/X11/input/charsets"
+static char *_XkbKnownLanguages = "c=ascii:da,de,en,es,fr,is,it,nl,no,pt,sv=iso8859-1:hu,pl,cs=iso8859-2:eo=iso8859-3:sp=iso8859-5:ar,ara=iso8859-6:el=iso8859-7:he=iso8859-8:tr=iso8859-9:lt,lv=iso8859-13:et,fi=iso8859-15:ru=koi8-r:uk=koi8-u:th,th_TH,th_TH.iso8859-11=iso8859-11:th_TH.TIS620=tis620:hy=armscii-8:vi=tcvn-5712:ka=georgian-academy:be,bg=microsoft-cp1251";
+
+char *
+_XkbGetCharset()
+{
+ /*
+ * PAGE USAGE TUNING: explicitly initialize to move these to data
+ * instead of bss
+ */
+ static char buf[100] = { 0 };
+ char lang[256];
+ char *start,*tmp,*end,*next,*set;
+ char *country,*charset;
+ char *locale;
+
+ tmp = getenv( "_XKB_CHARSET" );
+ if ( tmp )
+ return tmp;
+ locale = setlocale(LC_CTYPE,NULL);
+
+ if ( locale == NULL )
+ return NULL;
+
+ if (strlen(locale) >= sizeof(lang))
+ return NULL;
+
+ for (tmp = lang; *tmp = *locale++; tmp++) {
+ if (isupper(*tmp))
+ *tmp = tolower(*tmp);
+ }
+ country = strchr( lang, '_');
+ if ( country ) {
+ *country++ = '\0';
+ charset = strchr( country, '.' );
+ if ( charset ) *charset++ = '\0';
+ if ( charset ) {
+ strncpy(buf,charset,99);
+ buf[99] = '\0';
+ return buf;
+ }
+ }
+ else {
+ charset = NULL;
+ }
+
+ if ((tmp = getenv("_XKB_LOCALE_CHARSETS"))!=NULL) {
+ start = _XkbAlloc(strlen(tmp) + 1);
+ strcpy(start, tmp);
+ tmp = start;
+ } else {
+ struct stat sbuf;
+ FILE *file;
+#ifndef __UNIXOS2__
+ char *cf = CHARSET_FILE;
+#else
+ char *cf = __XOS2RedirRoot(CHARSET_FILE);
+#endif
+
+#ifndef S_ISREG
+# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
+#endif
+
+ if ( (stat(cf,&sbuf)==0) && S_ISREG(sbuf.st_mode) &&
+ (file = fopen(cf,"r")) ) {
+ tmp = _XkbAlloc(sbuf.st_size+1);
+ if (tmp!=NULL) {
+ sbuf.st_size = (long)fread(tmp,1,sbuf.st_size,file);
+ tmp[sbuf.st_size] = '\0';
+ }
+ fclose(file);
+ }
+ }
+
+ if ( tmp == NULL ) {
+ tmp = _XkbAlloc(strlen(_XkbKnownLanguages) + 1);
+ if (!tmp)
+ return NULL;
+ strcpy(tmp, _XkbKnownLanguages);
+ }
+ start = tmp;
+ do {
+ if ( (set=strchr(tmp,'=')) == NULL )
+ break;
+ *set++ = '\0';
+ if ( (next=strchr(set,':')) != NULL )
+ *next++ = '\0';
+ while ( tmp && *tmp ) {
+ if ( (end=strchr(tmp,',')) != NULL )
+ *end++ = '\0';
+ if ( Strcmp( tmp, lang ) == 0 ) {
+ strncpy(buf,set,100);
+ buf[99] = '\0';
+ Xfree(start);
+ return buf;
+ }
+ tmp = end;
+ }
+ tmp = next;
+ } while ( tmp && *tmp );
+ Xfree(start);
+ return NULL;
+}
+#else
+char *
+_XkbGetCharset()
+{
+ char *tmp;
+ XLCd lcd;
+
+ tmp = getenv( "_XKB_CHARSET" );
+ if ( tmp )
+ return tmp;
+
+ lcd = _XlcCurrentLC();
+ if ( lcd )
+ return XLC_PUBLIC(lcd,encoding_name);
+
+ return NULL;
+}
+#endif
+
diff --git a/nx-X11/lib/X11/XKBExtDev.c b/nx-X11/lib/X11/XKBExtDev.c
new file mode 100644
index 000000000..34558e476
--- /dev/null
+++ b/nx-X11/lib/X11/XKBExtDev.c
@@ -0,0 +1,823 @@
+/* $Xorg: XKBExtDev.c,v 1.3 2000/08/17 19:45:01 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBExtDev.c,v 3.4 2001/10/28 03:32:33 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#define NEED_MAP_READERS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+#include <X11/extensions/XI.h>
+
+/***====================================================================***/
+
+extern void
+XkbNoteDeviceChanges( XkbDeviceChangesPtr old,
+ XkbExtensionDeviceNotifyEvent * new,
+ unsigned int wanted)
+{
+ if ((!old)||(!new)||(!wanted)||((new->reason&wanted)==0))
+ return;
+ if ((wanted&new->reason)&XkbXI_ButtonActionsMask) {
+ if (old->changed&XkbXI_ButtonActionsMask) {
+ int first,last,newLast;
+ if (new->first_btn<old->first_btn)
+ first= new->first_btn;
+ else first= old->first_btn;
+ last= old->first_btn+old->num_btns-1;
+ newLast= new->first_btn+new->num_btns-1;
+ if (newLast>last)
+ last= newLast;
+ old->first_btn= first;
+ old->num_btns= (last-first)+1;
+ }
+ else {
+ old->changed|= XkbXI_ButtonActionsMask;
+ old->first_btn= new->first_btn;
+ old->num_btns= new->num_btns;
+ }
+ }
+ if ((wanted&new->reason)&XkbXI_IndicatorsMask) {
+ XkbDeviceLedChangesPtr this;
+ if (old->changed&XkbXI_IndicatorsMask) {
+ XkbDeviceLedChangesPtr found;
+ found= NULL;
+ for (this= &old->leds;this&&(!found);this=this->next) {
+ if ((this->led_class==new->led_class)&&
+ (this->led_id==new->led_id)) {
+ found= this;
+ }
+ }
+ if (!found) {
+ found= _XkbTypedCalloc(1,XkbDeviceLedChangesRec);
+ if (!found)
+ return;
+ found->next= old->leds.next;
+ found->led_class= new->led_class;
+ found->led_id= new->led_id;
+ old->leds.next= found;
+ }
+ if ((wanted&new->reason)&XkbXI_IndicatorNamesMask)
+ found->defined= new->leds_defined;
+ }
+ else {
+ old->changed|= ((wanted&new->reason)&XkbXI_IndicatorsMask);
+ old->leds.led_class= new->led_class;
+ old->leds.led_id= new->led_id;
+ old->leds.defined= new->leds_defined;
+ if (old->leds.next) {
+ XkbDeviceLedChangesPtr next;
+ for (this=old->leds.next;this;this=next) {
+ next= this->next;
+ _XkbFree(this);
+ }
+ old->leds.next= NULL;
+ }
+ }
+ }
+ return;
+}
+
+/***====================================================================***/
+
+static Status
+_XkbReadDeviceLedInfo( XkbReadBufferPtr buf,
+ unsigned present,
+ XkbDeviceInfoPtr devi)
+{
+register unsigned i,bit;
+XkbDeviceLedInfoPtr devli;
+xkbDeviceLedsWireDesc * wireli;
+
+ wireli= _XkbGetTypedRdBufPtr(buf,1,xkbDeviceLedsWireDesc);
+ if (!wireli)
+ return BadLength;
+ devli= XkbAddDeviceLedInfo(devi,wireli->ledClass,wireli->ledID);
+ if (!devli)
+ return BadAlloc;
+ devli->phys_indicators= wireli->physIndicators;
+
+ if (present&XkbXI_IndicatorStateMask)
+ devli->state= wireli->state;
+
+ if (present&XkbXI_IndicatorNamesMask) {
+ devli->names_present= wireli->namesPresent;
+ if (devli->names_present) {
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (wireli->namesPresent&bit) {
+ if (!_XkbCopyFromReadBuffer(buf,(char *)&devli->names[i],4))
+ return BadLength;
+ }
+ }
+ }
+ }
+
+ if (present&XkbXI_IndicatorMapsMask) {
+ devli->maps_present= wireli->mapsPresent;
+ if (devli->maps_present) {
+ XkbIndicatorMapPtr im;
+ xkbIndicatorMapWireDesc * wireim;
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (wireli->mapsPresent&bit) {
+ wireim= _XkbGetTypedRdBufPtr(buf,1,xkbIndicatorMapWireDesc);
+ if (!wireim)
+ return BadAlloc;
+ im= &devli->maps[i];
+ im->flags= wireim->flags;
+ im->which_groups= wireim->whichGroups;
+ im->groups= wireim->groups;
+ im->which_mods= wireim->whichMods;
+ im->mods.mask= wireim->mods;
+ im->mods.real_mods= wireim->realMods;
+ im->mods.vmods= wireim->virtualMods;
+ im->ctrls= wireim->ctrls;
+ }
+ }
+ }
+ }
+ return Success;
+}
+
+static Status
+_XkbReadGetDeviceInfoReply( Display * dpy,
+ xkbGetDeviceInfoReply * rep,
+ XkbDeviceInfoPtr devi)
+{
+XkbReadBufferRec buf;
+XkbAction * act;
+int tmp;
+
+ if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
+ return BadAlloc;
+
+ if ((rep->totalBtns>0)&&(rep->totalBtns!=devi->num_btns)) {
+ tmp= XkbResizeDeviceButtonActions(devi,rep->totalBtns);
+ if (tmp!=Success)
+ return tmp;
+ }
+ if (rep->nBtnsWanted>0) {
+ act= &devi->btn_acts[rep->firstBtnWanted];
+ bzero((char *)act,(rep->nBtnsWanted*sizeof(XkbAction)));
+ }
+ if (devi->name!=NULL)
+ _XkbFree(devi->name);
+ if (!_XkbGetReadBufferCountedString(&buf,&devi->name))
+ goto BAILOUT;
+ if (rep->nBtnsRtrn>0) {
+ int size;
+ act= &devi->btn_acts[rep->firstBtnRtrn];
+ size= rep->nBtnsRtrn*SIZEOF(xkbActionWireDesc);
+ if (!_XkbCopyFromReadBuffer(&buf,(char *)act,size))
+ goto BAILOUT;
+ }
+ if (rep->nDeviceLedFBs>0) {
+ register int i;
+ for (i=0;i<rep->nDeviceLedFBs;i++) {
+ if ((tmp= _XkbReadDeviceLedInfo(&buf,rep->present,devi))!=Success)
+ return tmp;
+ }
+ }
+ tmp= _XkbFreeReadBuffer(&buf);
+ if (tmp)
+ fprintf(stderr,"GetDeviceInfo! Bad length (%d extra bytes)\n",tmp);
+ if (tmp || buf.error)
+ return BadLength;
+ return Success;
+BAILOUT:
+ _XkbFreeReadBuffer(&buf);
+ return BadLength;
+}
+
+XkbDeviceInfoPtr
+XkbGetDeviceInfo( Display * dpy,
+ unsigned which,
+ unsigned deviceSpec,
+ unsigned class,
+ unsigned id)
+{
+ register xkbGetDeviceInfoReq * req;
+ xkbGetDeviceInfoReply rep;
+ Status status;
+ XkbDeviceInfoPtr devi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return NULL;
+ LockDisplay(dpy);
+ GetReq(kbGetDeviceInfo, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetDeviceInfo;
+ req->deviceSpec = deviceSpec;
+ req->wanted= which;
+ req->allBtns= ((which&XkbXI_ButtonActionsMask)!=0);
+ req->firstBtn= req->nBtns= 0;
+ req->ledClass= class;
+ req->ledID= id;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+ devi= XkbAllocDeviceInfo(rep.deviceID,rep.totalBtns,rep.nDeviceLedFBs);
+ if (devi) {
+ devi->supported= rep.supported;
+ devi->unsupported= rep.unsupported;
+ devi->type= rep.devType;
+ devi->has_own_state= rep.hasOwnState;
+ devi->dflt_kbd_fb = rep.dfltKbdFB;
+ devi->dflt_led_fb = rep.dfltLedFB;
+ status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
+ if (status!=Success) {
+ XkbFreeDeviceInfo(devi,XkbXI_AllDeviceFeaturesMask,True);
+ devi= NULL;
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return devi;
+}
+
+Status
+XkbGetDeviceInfoChanges( Display * dpy,
+ XkbDeviceInfoPtr devi,
+ XkbDeviceChangesPtr changes)
+{
+ register xkbGetDeviceInfoReq * req;
+ xkbGetDeviceInfoReply rep;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadMatch;
+ if ((changes->changed&XkbXI_AllDeviceFeaturesMask)==0)
+ return Success;
+ changes->changed&= ~XkbXI_AllDeviceFeaturesMask;
+ status= Success;
+ LockDisplay(dpy);
+ while ((changes->changed)&&(status==Success)) {
+ GetReq(kbGetDeviceInfo, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetDeviceInfo;
+ req->deviceSpec = devi->device_spec;
+ req->wanted= changes->changed;
+ req->allBtns= False;
+ if (changes->changed&XkbXI_ButtonActionsMask) {
+ req->firstBtn= changes->first_btn;
+ req->nBtns= changes->num_btns;
+ changes->changed&= ~XkbXI_ButtonActionsMask;
+ }
+ else req->firstBtn= req->nBtns= 0;
+ if (changes->changed&XkbXI_IndicatorsMask) {
+ req->ledClass= changes->leds.led_class;
+ req->ledID= changes->leds.led_id;
+ if (changes->leds.next==NULL)
+ changes->changed&= ~XkbXI_IndicatorsMask;
+ else {
+ XkbDeviceLedChangesPtr next;
+ next= changes->leds.next;
+ changes->leds= *next;
+ _XkbFree(next);
+ }
+ }
+ else {
+ req->ledClass= XkbDfltXIClass;
+ req->ledID= XkbDfltXIId;
+ }
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ status= BadLength;
+ break;
+ }
+ devi->supported|= rep.supported;
+ devi->unsupported|= rep.unsupported;
+ devi->type= rep.devType;
+ status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+XkbGetDeviceButtonActions( Display * dpy,
+ XkbDeviceInfoPtr devi,
+ Bool all,
+ unsigned int first,
+ unsigned int num)
+{
+ register xkbGetDeviceInfoReq * req;
+ xkbGetDeviceInfoReply rep;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadMatch;
+ if (!devi)
+ return BadValue;
+ LockDisplay(dpy);
+ GetReq(kbGetDeviceInfo, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetDeviceInfo;
+ req->deviceSpec = devi->device_spec;
+ req->wanted= XkbXI_ButtonActionsMask;
+ req->allBtns= all;
+ req->firstBtn= first;
+ req->nBtns= num;
+ req->ledClass= XkbDfltXIClass;
+ req->ledID= XkbDfltXIId;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadLength;
+ }
+ devi->type= rep.devType;
+ devi->supported= rep.supported;
+ devi->unsupported= rep.unsupported;
+ status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+XkbGetDeviceLedInfo( Display * dpy,
+ XkbDeviceInfoPtr devi,
+ unsigned int ledClass,
+ unsigned int ledId,
+ unsigned int which)
+{
+ register xkbGetDeviceInfoReq * req;
+ xkbGetDeviceInfoReply rep;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadMatch;
+ if (((which&XkbXI_IndicatorsMask)==0)||(which&(~XkbXI_IndicatorsMask)))
+ return BadMatch;
+ if (!devi)
+ return BadValue;
+ LockDisplay(dpy);
+ GetReq(kbGetDeviceInfo, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetDeviceInfo;
+ req->deviceSpec = devi->device_spec;
+ req->wanted= which;
+ req->allBtns= False;
+ req->firstBtn= req->nBtns= 0;
+ req->ledClass= ledClass;
+ req->ledID= ledId;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadLength;
+ }
+ devi->type= rep.devType;
+ devi->supported= rep.supported;
+ devi->unsupported= rep.unsupported;
+ status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+/***====================================================================***/
+
+typedef struct _LedInfoStuff {
+ Bool used;
+ XkbDeviceLedInfoPtr devli;
+} LedInfoStuff;
+
+typedef struct _SetLedStuff {
+ unsigned wanted;
+ int num_info;
+ int dflt_class;
+ LedInfoStuff * dflt_kbd_fb;
+ LedInfoStuff * dflt_led_fb;
+ LedInfoStuff * info;
+} SetLedStuff;
+
+static void
+_InitLedStuff(SetLedStuff *stuff,unsigned wanted,XkbDeviceInfoPtr devi)
+{
+int i;
+register XkbDeviceLedInfoPtr devli;
+
+ bzero(stuff,sizeof(SetLedStuff));
+ stuff->wanted= wanted;
+ stuff->dflt_class= XkbXINone;
+ if ((devi->num_leds<1)||((wanted&XkbXI_IndicatorsMask)==0))
+ return;
+ stuff->info= _XkbTypedCalloc(devi->num_leds,LedInfoStuff);
+ if (!stuff->info)
+ return;
+ stuff->num_info= devi->num_leds;
+ for (devli=&devi->leds[0],i=0;i<devi->num_leds;i++,devli++) {
+ stuff->info[i].devli= devli;
+ if (devli->led_class==KbdFeedbackClass) {
+ stuff->dflt_class= KbdFeedbackClass;
+ if (stuff->dflt_kbd_fb==NULL)
+ stuff->dflt_kbd_fb= &stuff->info[i];
+ }
+ else if (devli->led_class==LedFeedbackClass) {
+ if (stuff->dflt_class==XkbXINone)
+ stuff->dflt_class= LedFeedbackClass;
+ if (stuff->dflt_led_fb==NULL)
+ stuff->dflt_led_fb= &stuff->info[i];
+ }
+ }
+ return;
+}
+
+static void
+_FreeLedStuff(SetLedStuff *stuff)
+{
+ if ((stuff->num_info>0)&&(stuff->info!=NULL))
+ _XkbFree(stuff->info);
+ bzero(stuff,sizeof(SetLedStuff));
+ return;
+}
+
+static int
+_XkbSizeLedInfo(unsigned changed,XkbDeviceLedInfoPtr devli)
+{
+register int i,size;
+register unsigned bit,namesNeeded,mapsNeeded;
+
+ size= SIZEOF(xkbDeviceLedsWireDesc);
+ namesNeeded= mapsNeeded= 0;
+ if (changed&XkbXI_IndicatorNamesMask)
+ namesNeeded= devli->names_present;
+ if (changed&XkbXI_IndicatorMapsMask)
+ mapsNeeded= devli->maps_present;
+ if ((namesNeeded)||(mapsNeeded)) {
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (namesNeeded&bit)
+ size+= 4; /* atoms are 4 bytes on the wire */
+ if (mapsNeeded&bit)
+ size+= SIZEOF(xkbIndicatorMapWireDesc);
+ }
+ }
+ return size;
+}
+
+static Bool
+_SizeMatches( SetLedStuff * stuff,
+ XkbDeviceLedChangesPtr changes,
+ int * sz_rtrn,
+ int * nleds_rtrn)
+{
+int i,nMatch,class,id;
+LedInfoStuff * linfo;
+Bool match;
+
+ nMatch= 0;
+ class= changes->led_class;
+ id= changes->led_id;
+ if (class==XkbDfltXIClass)
+ class= stuff->dflt_class;
+ for (i=0,linfo=&stuff->info[0];i<stuff->num_info;i++,linfo++) {
+ XkbDeviceLedInfoPtr devli;
+ LedInfoStuff * dflt;
+
+ devli= linfo->devli;
+ match= ((class==devli->led_class)||(class==XkbAllXIClasses));
+ if (devli->led_class==KbdFeedbackClass) dflt= stuff->dflt_kbd_fb;
+ else dflt= stuff->dflt_led_fb;
+ match = (match && (id == devli->led_id)) ||
+ (id == XkbAllXIIds) ||
+ ((id == XkbDfltXIId) &&
+ (linfo == dflt));
+ if (match) {
+ if (!linfo->used) {
+ *sz_rtrn+= _XkbSizeLedInfo(stuff->wanted,devli);
+ *nleds_rtrn+= 1;
+ linfo->used= True;
+ if ((class!=XkbAllXIClasses)&&(id!=XkbAllXIIds))
+ return True;
+ }
+ nMatch++;
+ linfo->used= True;
+ }
+ }
+ return (nMatch>0);
+}
+
+/***====================================================================***/
+
+
+static Status
+_XkbSetDeviceInfoSize( XkbDeviceInfoPtr devi,
+ XkbDeviceChangesPtr changes,
+ SetLedStuff * stuff,
+ int * sz_rtrn,
+ int * num_leds_rtrn)
+{
+ *sz_rtrn= 0;
+ if ((changes->changed&XkbXI_ButtonActionsMask)&&(changes->num_btns>0)) {
+ if (!XkbXI_LegalDevBtn(devi,(changes->first_btn+changes->num_btns-1)))
+ return BadMatch;
+ *sz_rtrn+= changes->num_btns*SIZEOF(xkbActionWireDesc);
+ }
+ else {
+ changes->changed&= ~XkbXI_ButtonActionsMask;
+ changes->first_btn= changes->num_btns= 0;
+ }
+ if ((changes->changed&XkbXI_IndicatorsMask)&&
+ XkbLegalXILedClass(changes->leds.led_class)) {
+ XkbDeviceLedChangesPtr leds;
+
+ for (leds=&changes->leds;leds!=NULL;leds= leds->next) {
+ if (!_SizeMatches(stuff,leds,sz_rtrn,num_leds_rtrn))
+ return BadMatch;
+ }
+ }
+ else {
+ changes->changed&= ~XkbXI_IndicatorsMask;
+ *num_leds_rtrn= 0;
+ }
+ return Success;
+}
+
+static char *
+_XkbWriteLedInfo(char *wire,unsigned changed,XkbDeviceLedInfoPtr devli)
+{
+register int i;
+register unsigned bit,namesNeeded,mapsNeeded;
+xkbDeviceLedsWireDesc * lwire;
+
+ namesNeeded= mapsNeeded= 0;
+ if (changed&XkbXI_IndicatorNamesMask)
+ namesNeeded= devli->names_present;
+ if (changed&XkbXI_IndicatorMapsMask)
+ mapsNeeded= devli->maps_present;
+
+ lwire= (xkbDeviceLedsWireDesc *)wire;
+ lwire->ledClass= devli->led_class;
+ lwire->ledID= devli->led_id;
+ lwire->namesPresent= namesNeeded;
+ lwire->mapsPresent= mapsNeeded;
+ lwire->physIndicators= devli->phys_indicators;
+ lwire->state= devli->state;
+ wire= (char *)&lwire[1];
+ if (namesNeeded) {
+ CARD32 *awire;
+ awire= (CARD32 *)wire;
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (namesNeeded&bit) {
+ *awire= (CARD32)devli->names[i];
+ awire++;
+ }
+ }
+ wire= (char *)awire;
+ }
+ if (mapsNeeded) {
+ xkbIndicatorMapWireDesc *mwire;
+
+ mwire= (xkbIndicatorMapWireDesc *)wire;
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (mapsNeeded&bit) {
+ XkbIndicatorMapPtr map;
+ map= &devli->maps[i];
+ mwire->flags= map->flags;
+ mwire->whichGroups= map->which_groups;
+ mwire->groups= map->groups;
+ mwire->whichMods= map->which_mods;
+ mwire->mods= map->mods.mask;
+ mwire->realMods= map->mods.real_mods;
+ mwire->virtualMods= map->mods.vmods;
+ mwire->ctrls= map->ctrls;
+ mwire++;
+ }
+ }
+ wire= (char *)mwire;
+ }
+ return wire;
+}
+
+
+static int
+_XkbWriteSetDeviceInfo( char * wire,
+ XkbDeviceChangesPtr changes,
+ SetLedStuff * stuff,
+ XkbDeviceInfoPtr devi)
+{
+char *start;
+
+ start= wire;
+ if (changes->changed&XkbXI_ButtonActionsMask) {
+ int size;
+ size= changes->num_btns*SIZEOF(xkbActionWireDesc);
+ memcpy(wire,(char *)&devi->btn_acts[changes->first_btn],size);
+ wire+= size;
+ }
+ if (changes->changed&XkbXI_IndicatorsMask) {
+ register int i;
+ register LedInfoStuff *linfo;
+
+ for (i=0,linfo=&stuff->info[0];i<stuff->num_info;i++,linfo++) {
+ if (linfo->used) {
+ register char *new_wire;
+ new_wire= _XkbWriteLedInfo(wire,stuff->wanted,linfo->devli);
+ if (!new_wire)
+ return wire-start;
+ wire= new_wire;
+ }
+ }
+ }
+ return wire-start;
+}
+
+Bool
+XkbSetDeviceInfo( Display * dpy,
+ unsigned which,
+ XkbDeviceInfoPtr devi)
+{
+ register xkbSetDeviceInfoReq *req;
+ Status ok = 0;
+ int size,nLeds;
+ XkbInfoPtr xkbi;
+ XkbDeviceChangesRec changes;
+ SetLedStuff lstuff;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!devi) || (which&(~XkbXI_AllDeviceFeaturesMask)) ||
+ ((which&XkbXI_ButtonActionsMask)&&(!XkbXI_DevHasBtnActs(devi)))||
+ ((which&XkbXI_IndicatorsMask)&&(!XkbXI_DevHasLeds(devi))))
+ return False;
+
+ bzero((char *)&changes,sizeof(XkbDeviceChangesRec));
+ changes.changed= which;
+ changes.first_btn= 0;
+ changes.num_btns= devi->num_btns;
+ changes.leds.led_class= XkbAllXIClasses;
+ changes.leds.led_id= XkbAllXIIds;
+ changes.leds.defined= 0;
+ size= nLeds= 0;
+ _InitLedStuff(&lstuff,changes.changed,devi);
+ if (_XkbSetDeviceInfoSize(devi,&changes,&lstuff,&size,&nLeds)!=Success)
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetDeviceInfo, req);
+ req->length+= size/4;
+ req->reqType= xkbi->codes->major_opcode;
+ req->xkbReqType= X_kbSetDeviceInfo;
+ req->deviceSpec= devi->device_spec;
+ req->firstBtn= changes.first_btn;
+ req->nBtns= changes.num_btns;
+ req->change= changes.changed;
+ req->nDeviceLedFBs= nLeds;
+ if (size>0) {
+ char * wire;
+ BufAlloc(char *,wire,size);
+ ok= (wire!=NULL)&&
+ (_XkbWriteSetDeviceInfo(wire,&changes,&lstuff,devi)==size);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ _FreeLedStuff(&lstuff);
+ /* 12/11/95 (ef) -- XXX!! should clear changes here */
+ return ok;
+}
+
+Bool
+XkbChangeDeviceInfo( Display * dpy,
+ XkbDeviceInfoPtr devi,
+ XkbDeviceChangesPtr changes)
+{
+ register xkbSetDeviceInfoReq *req;
+ Status ok = 0;
+ int size,nLeds;
+ XkbInfoPtr xkbi;
+ SetLedStuff lstuff;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!devi) || (changes->changed&(~XkbXI_AllDeviceFeaturesMask)) ||
+ ((changes->changed&XkbXI_ButtonActionsMask)&&
+ (!XkbXI_DevHasBtnActs(devi)))||
+ ((changes->changed&XkbXI_IndicatorsMask)&&(!XkbXI_DevHasLeds(devi))))
+ return False;
+
+ size= nLeds= 0;
+ _InitLedStuff(&lstuff,changes->changed,devi);
+ if (_XkbSetDeviceInfoSize(devi,changes,&lstuff,&size,&nLeds)!=Success)
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetDeviceInfo, req);
+ req->length+= size/4;
+ req->reqType= xkbi->codes->major_opcode;
+ req->xkbReqType= X_kbSetDeviceInfo;
+ req->deviceSpec= devi->device_spec;
+ req->firstBtn= changes->first_btn;
+ req->nBtns= changes->num_btns;
+ req->change= changes->changed;
+ req->nDeviceLedFBs= nLeds;
+ if (size>0) {
+ char * wire;
+ BufAlloc(char *,wire,size);
+ ok= (wire!=NULL)&&
+ (_XkbWriteSetDeviceInfo(wire,changes,&lstuff,devi)==size);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ _FreeLedStuff(&lstuff);
+ /* 12/11/95 (ef) -- XXX!! should clear changes here */
+ return ok;
+}
+
+Bool
+XkbSetDeviceLedInfo( Display * dpy,
+ XkbDeviceInfoPtr devi,
+ unsigned ledClass,
+ unsigned ledID,
+ unsigned which)
+{
+ return False;
+}
+
+Bool
+XkbSetDeviceButtonActions( Display * dpy,
+ XkbDeviceInfoPtr devi,
+ unsigned int first,
+ unsigned int nBtns)
+{
+ register xkbSetDeviceInfoReq *req;
+ Status ok = 0;
+ int size,nLeds;
+ XkbInfoPtr xkbi;
+ XkbDeviceChangesRec changes;
+ SetLedStuff lstuff;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!devi)||(!XkbXI_DevHasBtnActs(devi))||(first+nBtns>devi->num_btns))
+ return False;
+ if (nBtns==0)
+ return True;
+
+ bzero((char *)&changes,sizeof(XkbDeviceChangesRec));
+ changes.changed= XkbXI_ButtonActionsMask;
+ changes.first_btn= first;
+ changes.num_btns= nBtns;
+ changes.leds.led_class= XkbXINone;
+ changes.leds.led_id= XkbXINone;
+ changes.leds.defined= 0;
+ size= nLeds= 0;
+ if (_XkbSetDeviceInfoSize(devi,&changes,NULL,&size,&nLeds)!=Success)
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetDeviceInfo, req);
+ req->length+= size/4;
+ req->reqType= xkbi->codes->major_opcode;
+ req->xkbReqType= X_kbSetDeviceInfo;
+ req->deviceSpec= devi->device_spec;
+ req->firstBtn= changes.first_btn;
+ req->nBtns= changes.num_btns;
+ req->change= changes.changed;
+ req->nDeviceLedFBs= nLeds;
+ if (size>0) {
+ char * wire;
+ BufAlloc(char *,wire,size);
+ ok= (wire!=NULL)&&
+ (_XkbWriteSetDeviceInfo(wire,&changes,&lstuff,devi)==size);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ok;
+}
diff --git a/nx-X11/lib/X11/XKBGAlloc.c b/nx-X11/lib/X11/XKBGAlloc.c
new file mode 100644
index 000000000..fddb770b6
--- /dev/null
+++ b/nx-X11/lib/X11/XKBGAlloc.c
@@ -0,0 +1,1021 @@
+/* $Xorg: XKBGAlloc.c,v 1.3 2000/08/17 19:45:01 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBGAlloc.c,v 3.4 2001/01/17 19:41:48 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#elif defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+
+#ifndef XKB_IN_SERVER
+
+#include <stdio.h>
+#include "Xlibint.h"
+#include "XKBlibint.h"
+#include <X11/extensions/XKBgeom.h>
+#include <X11/extensions/XKBproto.h>
+
+#else
+
+#include <stdio.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XKBgeom.h>
+
+#endif /* XKB_IN_SERVER */
+
+#ifdef X_NOT_POSIX
+#define Size_t unsigned int
+#else
+#define Size_t size_t
+#endif
+
+/***====================================================================***/
+
+static void
+_XkbFreeGeomLeafElems( Bool freeAll,
+ int first,
+ int count,
+ unsigned short * num_inout,
+ unsigned short * sz_inout,
+ char ** elems,
+ unsigned int elem_sz)
+{
+ if ((freeAll)||(*elems==NULL)) {
+ *num_inout= *sz_inout= 0;
+ if (*elems!=NULL) {
+ _XkbFree(*elems);
+ *elems= NULL;
+ }
+ return;
+ }
+
+ if ((first>=(*num_inout))||(first<0)||(count<1))
+ return;
+
+ if (first+count>=(*num_inout)) {
+ /* truncating the array is easy */
+ (*num_inout)= first;
+ }
+ else {
+ char * ptr;
+ int extra;
+ ptr= *elems;
+ extra= ((*num_inout)-(first+count))*elem_sz;
+ if (extra>0)
+ memmove(&ptr[first*elem_sz],&ptr[(first+count)*elem_sz],extra);
+ (*num_inout)-= count;
+ }
+ return;
+}
+
+typedef void (*ContentsClearFunc)(
+ char * /* priv */
+);
+
+static void
+_XkbFreeGeomNonLeafElems( Bool freeAll,
+ int first,
+ int count,
+ unsigned short * num_inout,
+ unsigned short * sz_inout,
+ char ** elems,
+ unsigned int elem_sz,
+ ContentsClearFunc freeFunc)
+{
+register int i;
+register char *ptr;
+
+ if (freeAll) {
+ first= 0;
+ count= (*num_inout);
+ }
+ else if ((first>=(*num_inout))||(first<0)||(count<1))
+ return;
+ else if (first+count>(*num_inout))
+ count= (*num_inout)-first;
+ if (*elems==NULL)
+ return;
+
+ if (freeFunc) {
+ ptr= *elems;
+ ptr+= first*elem_sz;
+ for (i=0;i<count;i++) {
+ (*freeFunc)(ptr);
+ ptr+= elem_sz;
+ }
+ }
+ if (freeAll) {
+ (*num_inout)= (*sz_inout)= 0;
+ if (*elems) {
+ _XkbFree(*elems);
+ *elems= NULL;
+ }
+ }
+ else if (first+count>=(*num_inout))
+ *num_inout= first;
+ else {
+ i= ((*num_inout)-(first+count))*elem_sz;
+ ptr= *elems;
+ memmove(&ptr[first*elem_sz],&ptr[(first+count)*elem_sz],i);
+ (*num_inout)-= count;
+ }
+ return;
+}
+
+/***====================================================================***/
+
+static void
+_XkbClearProperty(char *prop_in)
+{
+XkbPropertyPtr prop= (XkbPropertyPtr)prop_in;
+
+ if (prop->name) {
+ _XkbFree(prop->name);
+ prop->name= NULL;
+ }
+ if (prop->value) {
+ _XkbFree(prop->value);
+ prop->value= NULL;
+ }
+ return;
+}
+
+void
+XkbFreeGeomProperties( XkbGeometryPtr geom,
+ int first,
+ int count,
+ Bool freeAll)
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &geom->num_properties,&geom->sz_properties,
+ (char **)&geom->properties,
+ sizeof(XkbPropertyRec),_XkbClearProperty);
+ return;
+}
+
+/***====================================================================***/
+
+void
+XkbFreeGeomKeyAliases( XkbGeometryPtr geom,
+ int first,
+ int count,
+ Bool freeAll)
+{
+ _XkbFreeGeomLeafElems(freeAll,first,count,
+ &geom->num_key_aliases,&geom->sz_key_aliases,
+ (char **)&geom->key_aliases,
+ sizeof(XkbKeyAliasRec));
+ return;
+}
+
+/***====================================================================***/
+
+static void
+_XkbClearColor(char *color_in)
+{
+XkbColorPtr color= (XkbColorPtr)color_in;
+
+ if (color->spec)
+ _XkbFree(color->spec);
+ return;
+}
+
+void
+XkbFreeGeomColors(XkbGeometryPtr geom,int first,int count,Bool freeAll)
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &geom->num_colors,&geom->sz_colors,
+ (char **)&geom->colors,
+ sizeof(XkbColorRec),_XkbClearColor);
+ return;
+}
+
+/***====================================================================***/
+
+void
+XkbFreeGeomPoints(XkbOutlinePtr outline,int first,int count,Bool freeAll)
+{
+ _XkbFreeGeomLeafElems(freeAll,first,count,
+ &outline->num_points,&outline->sz_points,
+ (char **)&outline->points,
+ sizeof(XkbPointRec));
+ return;
+}
+
+/***====================================================================***/
+
+static void
+_XkbClearOutline(char *outline_in)
+{
+XkbOutlinePtr outline= (XkbOutlinePtr)outline_in;
+
+ if (outline->points!=NULL)
+ XkbFreeGeomPoints(outline,0,outline->num_points,True);
+ return;
+}
+
+void
+XkbFreeGeomOutlines(XkbShapePtr shape,int first,int count,Bool freeAll)
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &shape->num_outlines,&shape->sz_outlines,
+ (char **)&shape->outlines,
+ sizeof(XkbOutlineRec),_XkbClearOutline);
+
+ return;
+}
+
+/***====================================================================***/
+
+static void
+_XkbClearShape(char *shape_in)
+{
+XkbShapePtr shape= (XkbShapePtr)shape_in;
+
+ if (shape->outlines)
+ XkbFreeGeomOutlines(shape,0,shape->num_outlines,True);
+ return;
+}
+
+void
+XkbFreeGeomShapes(XkbGeometryPtr geom,int first,int count,Bool freeAll)
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &geom->num_shapes,&geom->sz_shapes,
+ (char **)&geom->shapes,
+ sizeof(XkbShapeRec),_XkbClearShape);
+ return;
+}
+
+/***====================================================================***/
+
+void
+XkbFreeGeomOverlayKeys(XkbOverlayRowPtr row,int first,int count,Bool freeAll)
+{
+ _XkbFreeGeomLeafElems(freeAll,first,count,
+ &row->num_keys,&row->sz_keys,
+ (char **)&row->keys,
+ sizeof(XkbOverlayKeyRec));
+ return;
+}
+
+/***====================================================================***/
+
+static void
+_XkbClearOverlayRow(char *row_in)
+{
+XkbOverlayRowPtr row= (XkbOverlayRowPtr)row_in;
+
+ if (row->keys!=NULL)
+ XkbFreeGeomOverlayKeys(row,0,row->num_keys,True);
+ return;
+}
+
+void
+XkbFreeGeomOverlayRows(XkbOverlayPtr overlay,int first,int count,Bool freeAll)
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &overlay->num_rows,&overlay->sz_rows,
+ (char **)&overlay->rows,
+ sizeof(XkbOverlayRowRec),_XkbClearOverlayRow);
+ return;
+}
+
+/***====================================================================***/
+
+static void
+_XkbClearOverlay(char *overlay_in)
+{
+XkbOverlayPtr overlay= (XkbOverlayPtr)overlay_in;
+
+ if (overlay->rows!=NULL)
+ XkbFreeGeomOverlayRows(overlay,0,overlay->num_rows,True);
+ return;
+}
+
+void
+XkbFreeGeomOverlays(XkbSectionPtr section,int first,int count,Bool freeAll)
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &section->num_overlays,&section->sz_overlays,
+ (char **)&section->overlays,
+ sizeof(XkbOverlayRec),_XkbClearOverlay);
+ return;
+}
+
+/***====================================================================***/
+
+void
+XkbFreeGeomKeys(XkbRowPtr row,int first,int count,Bool freeAll)
+{
+ _XkbFreeGeomLeafElems(freeAll,first,count,
+ &row->num_keys,&row->sz_keys,
+ (char **)&row->keys,
+ sizeof(XkbKeyRec));
+ return;
+}
+
+/***====================================================================***/
+
+static void
+_XkbClearRow(char *row_in)
+{
+XkbRowPtr row= (XkbRowPtr)row_in;
+
+ if (row->keys!=NULL)
+ XkbFreeGeomKeys(row,0,row->num_keys,True);
+ return;
+}
+
+void
+XkbFreeGeomRows(XkbSectionPtr section,int first,int count,Bool freeAll)
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &section->num_rows,&section->sz_rows,
+ (char **)&section->rows,
+ sizeof(XkbRowRec),_XkbClearRow);
+}
+
+/***====================================================================***/
+
+static void
+_XkbClearSection(char *section_in)
+{
+XkbSectionPtr section= (XkbSectionPtr)section_in;
+
+ if (section->rows!=NULL)
+ XkbFreeGeomRows(section,0,section->num_rows,True);
+ if (section->doodads!=NULL) {
+ XkbFreeGeomDoodads(section->doodads,section->num_doodads,True);
+ section->doodads= NULL;
+ }
+ return;
+}
+
+void
+XkbFreeGeomSections(XkbGeometryPtr geom,int first,int count,Bool freeAll)
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &geom->num_sections,&geom->sz_sections,
+ (char **)&geom->sections,
+ sizeof(XkbSectionRec),_XkbClearSection);
+ return;
+}
+
+/***====================================================================***/
+
+static void
+_XkbClearDoodad(char *doodad_in)
+{
+XkbDoodadPtr doodad= (XkbDoodadPtr)doodad_in;
+
+ switch (doodad->any.type) {
+ case XkbTextDoodad:
+ {
+ if (doodad->text.text!=NULL) {
+ _XkbFree(doodad->text.text);
+ doodad->text.text= NULL;
+ }
+ if (doodad->text.font!=NULL) {
+ _XkbFree(doodad->text.font);
+ doodad->text.font= NULL;
+ }
+ }
+ break;
+ case XkbLogoDoodad:
+ {
+ if (doodad->logo.logo_name!=NULL) {
+ _XkbFree(doodad->logo.logo_name);
+ doodad->logo.logo_name= NULL;
+ }
+ }
+ break;
+ }
+ return;
+}
+
+void
+XkbFreeGeomDoodads(XkbDoodadPtr doodads,int nDoodads,Bool freeAll)
+{
+register int i;
+register XkbDoodadPtr doodad;
+
+ if (doodads) {
+ for (i=0,doodad= doodads;i<nDoodads;i++,doodad++) {
+ _XkbClearDoodad((char *)doodad);
+ }
+ if (freeAll)
+ _XkbFree(doodads);
+ }
+ return;
+}
+
+void
+XkbFreeGeometry(XkbGeometryPtr geom,unsigned which,Bool freeMap)
+{
+ if (geom==NULL)
+ return;
+ if (freeMap)
+ which= XkbGeomAllMask;
+ if ((which&XkbGeomPropertiesMask)&&(geom->properties!=NULL))
+ XkbFreeGeomProperties(geom,0,geom->num_properties,True);
+ if ((which&XkbGeomColorsMask)&&(geom->colors!=NULL))
+ XkbFreeGeomColors(geom,0,geom->num_colors,True);
+ if ((which&XkbGeomShapesMask)&&(geom->shapes!=NULL))
+ XkbFreeGeomShapes(geom,0,geom->num_shapes,True);
+ if ((which&XkbGeomSectionsMask)&&(geom->sections!=NULL))
+ XkbFreeGeomSections(geom,0,geom->num_sections,True);
+ if ((which&XkbGeomDoodadsMask)&&(geom->doodads!= NULL)) {
+ XkbFreeGeomDoodads(geom->doodads,geom->num_doodads,True);
+ geom->doodads= NULL;
+ geom->num_doodads= geom->sz_doodads= 0;
+ }
+ if ((which&XkbGeomKeyAliasesMask)&&(geom->key_aliases!=NULL))
+ XkbFreeGeomKeyAliases(geom,0,geom->num_key_aliases,True);
+ if (freeMap) {
+ if (geom->label_font!=NULL) {
+ _XkbFree(geom->label_font);
+ geom->label_font= NULL;
+ }
+ _XkbFree(geom);
+ }
+ return;
+}
+
+/***====================================================================***/
+
+static Status
+_XkbGeomAlloc( XPointer * old,
+ unsigned short * num,
+ unsigned short * total,
+ int num_new,
+ Size_t sz_elem)
+{
+ if (num_new<1)
+ return Success;
+ if ((*old)==NULL)
+ *num= *total= 0;
+
+ if ((*num)+num_new<=(*total))
+ return Success;
+
+ *total= (*num)+num_new;
+ if ((*old)!=NULL)
+ (*old)= (XPointer)_XkbRealloc((*old),(*total)*sz_elem);
+ else (*old)= (XPointer)_XkbCalloc((*total),sz_elem);
+ if ((*old)==NULL) {
+ *total= *num= 0;
+ return BadAlloc;
+ }
+
+ if (*num>0) {
+ char *tmp= (char *)(*old);
+ bzero(&tmp[sz_elem*(*num)],(num_new*sz_elem));
+ }
+ return Success;
+}
+
+#define _XkbAllocProps(g,n) _XkbGeomAlloc((XPointer *)&(g)->properties,\
+ &(g)->num_properties,&(g)->sz_properties,\
+ (n),sizeof(XkbPropertyRec))
+#define _XkbAllocColors(g,n) _XkbGeomAlloc((XPointer *)&(g)->colors,\
+ &(g)->num_colors,&(g)->sz_colors,\
+ (n),sizeof(XkbColorRec))
+#define _XkbAllocShapes(g,n) _XkbGeomAlloc((XPointer *)&(g)->shapes,\
+ &(g)->num_shapes,&(g)->sz_shapes,\
+ (n),sizeof(XkbShapeRec))
+#define _XkbAllocSections(g,n) _XkbGeomAlloc((XPointer *)&(g)->sections,\
+ &(g)->num_sections,&(g)->sz_sections,\
+ (n),sizeof(XkbSectionRec))
+#define _XkbAllocDoodads(g,n) _XkbGeomAlloc((XPointer *)&(g)->doodads,\
+ &(g)->num_doodads,&(g)->sz_doodads,\
+ (n),sizeof(XkbDoodadRec))
+#define _XkbAllocKeyAliases(g,n) _XkbGeomAlloc((XPointer *)&(g)->key_aliases,\
+ &(g)->num_key_aliases,&(g)->sz_key_aliases,\
+ (n),sizeof(XkbKeyAliasRec))
+
+#define _XkbAllocOutlines(s,n) _XkbGeomAlloc((XPointer *)&(s)->outlines,\
+ &(s)->num_outlines,&(s)->sz_outlines,\
+ (n),sizeof(XkbOutlineRec))
+#define _XkbAllocRows(s,n) _XkbGeomAlloc((XPointer *)&(s)->rows,\
+ &(s)->num_rows,&(s)->sz_rows,\
+ (n),sizeof(XkbRowRec))
+#define _XkbAllocPoints(o,n) _XkbGeomAlloc((XPointer *)&(o)->points,\
+ &(o)->num_points,&(o)->sz_points,\
+ (n),sizeof(XkbPointRec))
+#define _XkbAllocKeys(r,n) _XkbGeomAlloc((XPointer *)&(r)->keys,\
+ &(r)->num_keys,&(r)->sz_keys,\
+ (n),sizeof(XkbKeyRec))
+#define _XkbAllocOverlays(s,n) _XkbGeomAlloc((XPointer *)&(s)->overlays,\
+ &(s)->num_overlays,&(s)->sz_overlays,\
+ (n),sizeof(XkbOverlayRec))
+#define _XkbAllocOverlayRows(o,n) _XkbGeomAlloc((XPointer *)&(o)->rows,\
+ &(o)->num_rows,&(o)->sz_rows,\
+ (n),sizeof(XkbOverlayRowRec))
+#define _XkbAllocOverlayKeys(r,n) _XkbGeomAlloc((XPointer *)&(r)->keys,\
+ &(r)->num_keys,&(r)->sz_keys,\
+ (n),sizeof(XkbOverlayKeyRec))
+
+Status
+XkbAllocGeomProps(XkbGeometryPtr geom,int nProps)
+{
+ return _XkbAllocProps(geom,nProps);
+}
+
+Status
+XkbAllocGeomColors(XkbGeometryPtr geom,int nColors)
+{
+ return _XkbAllocColors(geom,nColors);
+}
+
+Status
+XkbAllocGeomKeyAliases(XkbGeometryPtr geom,int nKeyAliases)
+{
+ return _XkbAllocKeyAliases(geom,nKeyAliases);
+}
+
+Status
+XkbAllocGeomShapes(XkbGeometryPtr geom,int nShapes)
+{
+ return _XkbAllocShapes(geom,nShapes);
+}
+
+Status
+XkbAllocGeomSections(XkbGeometryPtr geom,int nSections)
+{
+ return _XkbAllocSections(geom,nSections);
+}
+
+Status
+XkbAllocGeomOverlays(XkbSectionPtr section,int nOverlays)
+{
+ return _XkbAllocOverlays(section,nOverlays);
+}
+
+Status
+XkbAllocGeomOverlayRows(XkbOverlayPtr overlay,int nRows)
+{
+ return _XkbAllocOverlayRows(overlay,nRows);
+}
+
+Status
+XkbAllocGeomOverlayKeys(XkbOverlayRowPtr row,int nKeys)
+{
+ return _XkbAllocOverlayKeys(row,nKeys);
+}
+
+Status
+XkbAllocGeomDoodads(XkbGeometryPtr geom,int nDoodads)
+{
+ return _XkbAllocDoodads(geom,nDoodads);
+}
+
+Status
+XkbAllocGeomSectionDoodads(XkbSectionPtr section,int nDoodads)
+{
+ return _XkbAllocDoodads(section,nDoodads);
+}
+
+Status
+XkbAllocGeomOutlines(XkbShapePtr shape,int nOL)
+{
+ return _XkbAllocOutlines(shape,nOL);
+}
+
+Status
+XkbAllocGeomRows(XkbSectionPtr section,int nRows)
+{
+ return _XkbAllocRows(section,nRows);
+}
+
+Status
+XkbAllocGeomPoints(XkbOutlinePtr ol,int nPts)
+{
+ return _XkbAllocPoints(ol,nPts);
+}
+
+Status
+XkbAllocGeomKeys(XkbRowPtr row,int nKeys)
+{
+ return _XkbAllocKeys(row,nKeys);
+}
+
+Status
+XkbAllocGeometry(XkbDescPtr xkb,XkbGeometrySizesPtr sizes)
+{
+XkbGeometryPtr geom;
+Status rtrn;
+
+ if (xkb->geom==NULL) {
+ xkb->geom= _XkbTypedCalloc(1,XkbGeometryRec);
+ if (!xkb->geom)
+ return BadAlloc;
+ }
+ geom= xkb->geom;
+ if ((sizes->which&XkbGeomPropertiesMask)&&
+ ((rtrn=_XkbAllocProps(geom,sizes->num_properties))!=Success)) {
+ goto BAIL;
+ }
+ if ((sizes->which&XkbGeomColorsMask)&&
+ ((rtrn=_XkbAllocColors(geom,sizes->num_colors))!=Success)) {
+ goto BAIL;
+ }
+ if ((sizes->which&XkbGeomShapesMask)&&
+ ((rtrn=_XkbAllocShapes(geom,sizes->num_shapes))!=Success)) {
+ goto BAIL;
+ }
+ if ((sizes->which&XkbGeomSectionsMask)&&
+ ((rtrn=_XkbAllocSections(geom,sizes->num_sections))!=Success)) {
+ goto BAIL;
+ }
+ if ((sizes->which&XkbGeomDoodadsMask)&&
+ ((rtrn=_XkbAllocDoodads(geom,sizes->num_doodads))!=Success)) {
+ goto BAIL;
+ }
+ if ((sizes->which&XkbGeomKeyAliasesMask)&&
+ ((rtrn=_XkbAllocKeyAliases(geom,sizes->num_key_aliases))!=Success)) {
+ goto BAIL;
+ }
+ return Success;
+BAIL:
+ XkbFreeGeometry(geom,XkbGeomAllMask,True);
+ xkb->geom= NULL;
+ return rtrn;
+}
+
+/***====================================================================***/
+
+XkbPropertyPtr
+XkbAddGeomProperty(XkbGeometryPtr geom,char *name,char *value)
+{
+register int i;
+register XkbPropertyPtr prop;
+
+ if ((!geom)||(!name)||(!value))
+ return NULL;
+ for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
+ if ((prop->name)&&(strcmp(name,prop->name)==0)) {
+ if (prop->value)
+ _XkbFree(prop->value);
+ prop->value= (char *)_XkbAlloc(strlen(value)+1);
+ if (prop->value)
+ strcpy(prop->value,value);
+ return prop;
+ }
+ }
+ if ((geom->num_properties>=geom->sz_properties)&&
+ (_XkbAllocProps(geom,1)!=Success)) {
+ return NULL;
+ }
+ prop= &geom->properties[geom->num_properties];
+ prop->name= (char *)_XkbAlloc(strlen(name)+1);
+ if (!name)
+ return NULL;
+ strcpy(prop->name,name);
+ prop->value= (char *)_XkbAlloc(strlen(value)+1);
+ if (!value) {
+ _XkbFree(prop->name);
+ prop->name= NULL;
+ return NULL;
+ }
+ strcpy(prop->value,value);
+ geom->num_properties++;
+ return prop;
+}
+
+XkbKeyAliasPtr
+XkbAddGeomKeyAlias(XkbGeometryPtr geom,char *aliasStr,char *realStr)
+{
+register int i;
+register XkbKeyAliasPtr alias;
+
+ if ((!geom)||(!aliasStr)||(!realStr)||(!aliasStr[0])||(!realStr[0]))
+ return NULL;
+ for (i=0,alias=geom->key_aliases;i<geom->num_key_aliases;i++,alias++) {
+ if (strncmp(alias->alias,aliasStr,XkbKeyNameLength)==0) {
+ bzero(alias->real,XkbKeyNameLength);
+ strncpy(alias->real,realStr,XkbKeyNameLength);
+ return alias;
+ }
+ }
+ if ((geom->num_key_aliases>=geom->sz_key_aliases)&&
+ (_XkbAllocKeyAliases(geom,1)!=Success)) {
+ return NULL;
+ }
+ alias= &geom->key_aliases[geom->num_key_aliases];
+ bzero(alias,sizeof(XkbKeyAliasRec));
+ strncpy(alias->alias,aliasStr,XkbKeyNameLength);
+ strncpy(alias->real,realStr,XkbKeyNameLength);
+ geom->num_key_aliases++;
+ return alias;
+}
+
+XkbColorPtr
+XkbAddGeomColor(XkbGeometryPtr geom,char *spec,unsigned int pixel)
+{
+register int i;
+register XkbColorPtr color;
+
+ if ((!geom)||(!spec))
+ return NULL;
+ for (i=0,color=geom->colors;i<geom->num_colors;i++,color++) {
+ if ((color->spec)&&(strcmp(color->spec,spec)==0)) {
+ color->pixel= pixel;
+ return color;
+ }
+ }
+ if ((geom->num_colors>=geom->sz_colors)&&
+ (_XkbAllocColors(geom,1)!=Success)) {
+ return NULL;
+ }
+ color= &geom->colors[geom->num_colors];
+ color->pixel= pixel;
+ color->spec= (char *)_XkbAlloc(strlen(spec)+1);
+ if (!color->spec)
+ return NULL;
+ strcpy(color->spec,spec);
+ geom->num_colors++;
+ return color;
+}
+
+XkbOutlinePtr
+XkbAddGeomOutline(XkbShapePtr shape,int sz_points)
+{
+XkbOutlinePtr outline;
+
+ if ((!shape)||(sz_points<0))
+ return NULL;
+ if ((shape->num_outlines>=shape->sz_outlines)&&
+ (_XkbAllocOutlines(shape,1)!=Success)) {
+ return NULL;
+ }
+ outline= &shape->outlines[shape->num_outlines];
+ bzero(outline,sizeof(XkbOutlineRec));
+ if ((sz_points>0)&&(_XkbAllocPoints(outline,sz_points)!=Success))
+ return NULL;
+ shape->num_outlines++;
+ return outline;
+}
+
+XkbShapePtr
+XkbAddGeomShape(XkbGeometryPtr geom,Atom name,int sz_outlines)
+{
+XkbShapePtr shape;
+register int i;
+
+ if ((!geom)||(!name)||(sz_outlines<0))
+ return NULL;
+ if (geom->num_shapes>0) {
+ for (shape=geom->shapes,i=0;i<geom->num_shapes;i++,shape++) {
+ if (name==shape->name)
+ return shape;
+ }
+ }
+ if ((geom->num_shapes>=geom->sz_shapes)&&
+ (_XkbAllocShapes(geom,1)!=Success))
+ return NULL;
+ shape= &geom->shapes[geom->num_shapes];
+ bzero(shape,sizeof(XkbShapeRec));
+ if ((sz_outlines>0)&&(_XkbAllocOutlines(shape,sz_outlines)!=Success))
+ return NULL;
+ shape->name= name;
+ shape->primary= shape->approx= NULL;
+ geom->num_shapes++;
+ return shape;
+}
+
+XkbKeyPtr
+XkbAddGeomKey(XkbRowPtr row)
+{
+XkbKeyPtr key;
+ if (!row)
+ return NULL;
+ if ((row->num_keys>=row->sz_keys)&&(_XkbAllocKeys(row,1)!=Success))
+ return NULL;
+ key= &row->keys[row->num_keys++];
+ bzero(key,sizeof(XkbKeyRec));
+ return key;
+}
+
+XkbRowPtr
+XkbAddGeomRow(XkbSectionPtr section,int sz_keys)
+{
+XkbRowPtr row;
+
+ if ((!section)||(sz_keys<0))
+ return NULL;
+ if ((section->num_rows>=section->sz_rows)&&
+ (_XkbAllocRows(section,1)!=Success))
+ return NULL;
+ row= &section->rows[section->num_rows];
+ bzero(row,sizeof(XkbRowRec));
+ if ((sz_keys>0)&&(_XkbAllocKeys(row,sz_keys)!=Success))
+ return NULL;
+ section->num_rows++;
+ return row;
+}
+
+XkbSectionPtr
+XkbAddGeomSection( XkbGeometryPtr geom,
+ Atom name,
+ int sz_rows,
+ int sz_doodads,
+ int sz_over)
+{
+register int i;
+XkbSectionPtr section;
+
+ if ((!geom)||(name==None)||(sz_rows<0))
+ return NULL;
+ for (i=0,section=geom->sections;i<geom->num_sections;i++,section++) {
+ if (section->name!=name)
+ continue;
+ if (((sz_rows>0)&&(_XkbAllocRows(section,sz_rows)!=Success))||
+ ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success))||
+ ((sz_over>0)&&(_XkbAllocOverlays(section,sz_over)!=Success)))
+ return NULL;
+ return section;
+ }
+ if ((geom->num_sections>=geom->sz_sections)&&
+ (_XkbAllocSections(geom,1)!=Success))
+ return NULL;
+ section= &geom->sections[geom->num_sections];
+ if ((sz_rows>0)&&(_XkbAllocRows(section,sz_rows)!=Success))
+ return NULL;
+ if ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success)) {
+ if (section->rows) {
+ _XkbFree(section->rows);
+ section->rows= NULL;
+ section->sz_rows= section->num_rows= 0;
+ }
+ return NULL;
+ }
+ section->name= name;
+ geom->num_sections++;
+ return section;
+}
+
+XkbDoodadPtr
+XkbAddGeomDoodad(XkbGeometryPtr geom,XkbSectionPtr section,Atom name)
+{
+XkbDoodadPtr old,doodad;
+register int i,nDoodads;
+
+ if ((!geom)||(name==None))
+ return NULL;
+ if ((section!=NULL)&&(section->num_doodads>0)) {
+ old= section->doodads;
+ nDoodads= section->num_doodads;
+ }
+ else {
+ old= geom->doodads;
+ nDoodads= geom->num_doodads;
+ }
+ for (i=0,doodad=old;i<nDoodads;i++,doodad++) {
+ if (doodad->any.name==name)
+ return doodad;
+ }
+ if (section) {
+ if ((section->num_doodads>=geom->sz_doodads)&&
+ (_XkbAllocDoodads(section,1)!=Success)) {
+ return NULL;
+ }
+ doodad= &section->doodads[section->num_doodads++];
+ }
+ else {
+ if ((geom->num_doodads>=geom->sz_doodads)&&
+ (_XkbAllocDoodads(geom,1)!=Success))
+ return NULL;
+ doodad= &geom->doodads[geom->num_doodads++];
+ }
+ bzero(doodad,sizeof(XkbDoodadRec));
+ doodad->any.name= name;
+ return doodad;
+}
+
+XkbOverlayKeyPtr
+XkbAddGeomOverlayKey( XkbOverlayPtr overlay,
+ XkbOverlayRowPtr row,
+ char * over,
+ char * under)
+{
+register int i;
+XkbOverlayKeyPtr key;
+XkbSectionPtr section;
+XkbRowPtr row_under;
+Bool found;
+
+ if ((!overlay)||(!row)||(!over)||(!under))
+ return NULL;
+ section= overlay->section_under;
+ if (row->row_under>=section->num_rows)
+ return NULL;
+ row_under= &section->rows[row->row_under];
+ for (i=0,found=False;i<row_under->num_keys;i++) {
+ if (strncmp(under,row_under->keys[i].name.name,XkbKeyNameLength)==0) {
+ found= True;
+ break;
+ }
+ }
+ if (!found)
+ return NULL;
+ if ((row->num_keys>=row->sz_keys)&&(_XkbAllocOverlayKeys(row,1)!=Success))
+ return NULL;
+ key= &row->keys[row->num_keys];
+ strncpy(key->under.name,under,XkbKeyNameLength);
+ strncpy(key->over.name,over,XkbKeyNameLength);
+ row->num_keys++;
+ return key;
+}
+
+XkbOverlayRowPtr
+XkbAddGeomOverlayRow(XkbOverlayPtr overlay,int row_under,int sz_keys)
+{
+register int i;
+XkbOverlayRowPtr row;
+
+ if ((!overlay)||(sz_keys<0))
+ return NULL;
+ if (row_under>=overlay->section_under->num_rows)
+ return NULL;
+ for (i=0;i<overlay->num_rows;i++) {
+ if (overlay->rows[i].row_under==row_under) {
+ row= &overlay->rows[i];
+ if ((row->sz_keys<sz_keys)&&
+ (_XkbAllocOverlayKeys(row,sz_keys)!=Success)) {
+ return NULL;
+ }
+ return &overlay->rows[i];
+ }
+ }
+ if ((overlay->num_rows>=overlay->sz_rows)&&
+ (_XkbAllocOverlayRows(overlay,1)!=Success))
+ return NULL;
+ row= &overlay->rows[overlay->num_rows];
+ bzero(row,sizeof(XkbOverlayRowRec));
+ if ((sz_keys>0)&&(_XkbAllocOverlayKeys(row,sz_keys)!=Success))
+ return NULL;
+ row->row_under= row_under;
+ overlay->num_rows++;
+ return row;
+}
+
+XkbOverlayPtr
+XkbAddGeomOverlay(XkbSectionPtr section,Atom name,int sz_rows)
+{
+register int i;
+XkbOverlayPtr overlay;
+
+ if ((!section)||(name==None)||(sz_rows==0))
+ return NULL;
+
+ for (i=0,overlay=section->overlays;i<section->num_overlays;i++,overlay++) {
+ if (overlay->name==name) {
+ if ((sz_rows>0)&&(_XkbAllocOverlayRows(overlay,sz_rows)!=Success))
+ return NULL;
+ return overlay;
+ }
+ }
+ if ((section->num_overlays>=section->sz_overlays)&&
+ (_XkbAllocOverlays(section,1)!=Success))
+ return NULL;
+ overlay= &section->overlays[section->num_overlays];
+ if ((sz_rows>0)&&(_XkbAllocOverlayRows(overlay,sz_rows)!=Success))
+ return NULL;
+ overlay->name= name;
+ overlay->section_under= section;
+ section->num_overlays++;
+ return overlay;
+}
diff --git a/nx-X11/lib/X11/XKBGeom.c b/nx-X11/lib/X11/XKBGeom.c
new file mode 100644
index 000000000..061175489
--- /dev/null
+++ b/nx-X11/lib/X11/XKBGeom.c
@@ -0,0 +1,670 @@
+/* $Xorg: XKBGeom.c,v 1.4 2000/08/17 19:45:01 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBGeom.c,v 1.5 2003/04/13 19:22:18 dawes Exp $ */
+
+#ifdef DEBUG
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#endif
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#define NEED_MAP_READERS
+#include "Xlibint.h"
+#include <X11/extensions/XKBgeom.h>
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+#ifndef MINSHORT
+#define MINSHORT -32768
+#endif
+#ifndef MAXSHORT
+#define MAXSHORT 32767
+#endif
+
+/***====================================================================***/
+
+static void
+_XkbCheckBounds(XkbBoundsPtr bounds,int x,int y)
+{
+ if (x<bounds->x1) bounds->x1= x;
+ if (x>bounds->x2) bounds->x2= x;
+ if (y<bounds->y1) bounds->y1= y;
+ if (y>bounds->y2) bounds->y2= y;
+ return;
+}
+
+Bool
+XkbComputeShapeBounds(XkbShapePtr shape)
+{
+register int o,p;
+XkbOutlinePtr outline;
+XkbPointPtr pt;
+
+ if ((!shape)||(shape->num_outlines<1))
+ return False;
+ shape->bounds.x1= shape->bounds.y1= MAXSHORT;
+ shape->bounds.x2= shape->bounds.y2= MINSHORT;
+ for (outline=shape->outlines,o=0;o<shape->num_outlines;o++,outline++) {
+ for (pt=outline->points,p=0;p<outline->num_points;p++,pt++) {
+ _XkbCheckBounds(&shape->bounds,pt->x,pt->y);
+ }
+ }
+ return True;
+}
+
+Bool
+XkbComputeShapeTop(XkbShapePtr shape,XkbBoundsPtr bounds)
+{
+register int p;
+XkbOutlinePtr outline;
+XkbPointPtr pt;
+
+ if ((!shape)||(shape->num_outlines<1))
+ return False;
+ if (shape->approx) outline= shape->approx;
+ else outline= &shape->outlines[shape->num_outlines-1];
+ if (outline->num_points<2) {
+ bounds->x1= bounds->y1= 0;
+ bounds->x2= bounds->y2= 0;
+ }
+ else {
+ bounds->x1= bounds->y1= MAXSHORT;
+ bounds->x2= bounds->y2= MINSHORT;
+ }
+ for (pt=outline->points,p=0;p<outline->num_points;p++,pt++) {
+ _XkbCheckBounds(bounds,pt->x,pt->y);
+ }
+ return True;
+}
+
+Bool
+XkbComputeRowBounds(XkbGeometryPtr geom,XkbSectionPtr section,XkbRowPtr row)
+{
+register int k,pos;
+XkbKeyPtr key;
+XkbBoundsPtr bounds,sbounds;
+
+ if ((!geom)||(!section)||(!row))
+ return False;
+ pos= 0;
+ bounds= &row->bounds;
+ bzero(bounds,sizeof(XkbBoundsRec));
+ for (key=row->keys,pos=k=0;k<row->num_keys;k++,key++) {
+ sbounds= &XkbKeyShape(geom,key)->bounds;
+ _XkbCheckBounds(bounds,pos,0);
+ if (!row->vertical) {
+ if (key->gap!=0) {
+ pos+= key->gap;
+ _XkbCheckBounds(bounds,pos,0);
+ }
+ _XkbCheckBounds(bounds,pos+sbounds->x1,sbounds->y1);
+ _XkbCheckBounds(bounds,pos+sbounds->x2,sbounds->y2);
+ pos+= sbounds->x2;
+ }
+ else {
+ if (key->gap!=0) {
+ pos+= key->gap;
+ _XkbCheckBounds(bounds,0,pos);
+ }
+ _XkbCheckBounds(bounds,pos+sbounds->x1,sbounds->y1);
+ _XkbCheckBounds(bounds,pos+sbounds->x2,sbounds->y2);
+ pos+= sbounds->y2;
+ }
+ }
+ return True;
+}
+
+Bool
+XkbComputeSectionBounds(XkbGeometryPtr geom,XkbSectionPtr section)
+{
+register int i;
+XkbShapePtr shape;
+XkbRowPtr row;
+XkbDoodadPtr doodad;
+XkbBoundsPtr bounds,rbounds=NULL;
+
+ if ((!geom)||(!section))
+ return False;
+ bounds= &section->bounds;
+ bzero(bounds,sizeof(XkbBoundsRec));
+ for (i=0,row=section->rows;i<section->num_rows;i++,row++) {
+ if (!XkbComputeRowBounds(geom,section,row))
+ return False;
+ rbounds= &row->bounds;
+ _XkbCheckBounds(bounds,row->left+rbounds->x1,row->top+rbounds->y1);
+ _XkbCheckBounds(bounds,row->left+rbounds->x2,row->top+rbounds->y2);
+ }
+ for (i=0,doodad=section->doodads;i<section->num_doodads;i++,doodad++) {
+ static XkbBoundsRec tbounds;
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ shape= XkbShapeDoodadShape(geom,&doodad->shape);
+ rbounds= &shape->bounds;
+ break;
+ case XkbTextDoodad:
+ tbounds.x1= doodad->text.left;
+ tbounds.y1= doodad->text.top;
+ tbounds.x2= tbounds.x1+doodad->text.width;
+ tbounds.y2= tbounds.y1+doodad->text.height;
+ rbounds= &tbounds;
+ break;
+ case XkbIndicatorDoodad:
+ shape= XkbIndicatorDoodadShape(geom,&doodad->indicator);
+ rbounds= &shape->bounds;
+ break;
+ case XkbLogoDoodad:
+ shape= XkbLogoDoodadShape(geom,&doodad->logo);
+ rbounds= &shape->bounds;
+ break;
+ default:
+ tbounds.x1= tbounds.x2= doodad->any.left;
+ tbounds.y1= tbounds.y2= doodad->any.top;
+ break;
+ }
+ _XkbCheckBounds(bounds,rbounds->x1,rbounds->y1);
+ _XkbCheckBounds(bounds,rbounds->x2,rbounds->y2);
+ }
+ return True;
+}
+
+/***====================================================================***/
+
+char *
+XkbFindOverlayForKey(XkbGeometryPtr geom,XkbSectionPtr wanted,char *under)
+{
+int s;
+XkbSectionPtr section;
+
+ if ((geom==NULL)||(under==NULL)||(geom->num_sections<1))
+ return NULL;
+
+ if (wanted)
+ section= wanted;
+ else section= geom->sections;
+
+ for (s=0;s<geom->num_sections;s++,section++) {
+ XkbOverlayPtr ol;
+ int o;
+
+ if (section->num_overlays<1)
+ continue;
+ for (o=0,ol=section->overlays;o<section->num_overlays;o++,ol++) {
+ XkbOverlayRowPtr row;
+ int r;
+
+ for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
+ XkbOverlayKeyPtr key;
+ int k;
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ if (strncmp(under,key->under.name,XkbKeyNameLength)==0)
+ return key->over.name;
+ }
+ }
+ }
+ if (wanted!=NULL)
+ break;
+ }
+ return NULL;
+}
+
+/***====================================================================***/
+
+static Status
+_XkbReadGeomProperties( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep)
+{
+Status rtrn;
+
+ if (rep->nProperties<1)
+ return Success;
+ if ((rtrn=XkbAllocGeomProps(geom,rep->nProperties))==Success) {
+ register int i;
+ register Bool ok;
+ char *name,*value;
+ ok= True;
+ for (i=0;(i<rep->nProperties)&&ok;i++) {
+ ok= _XkbGetReadBufferCountedString(buf,&name)&&ok;
+ ok= _XkbGetReadBufferCountedString(buf,&value)&&ok;
+ ok= ok&&(XkbAddGeomProperty(geom,name,value)!=NULL);
+ }
+ if (ok) rtrn= Success;
+ else rtrn= BadLength;
+ }
+ return rtrn;
+}
+
+static Status
+_XkbReadGeomKeyAliases( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep)
+{
+Status rtrn;
+
+ if (rep->nKeyAliases<1)
+ return Success;
+ if ((rtrn=XkbAllocGeomKeyAliases(geom,rep->nKeyAliases))==Success) {
+ if (!_XkbCopyFromReadBuffer(buf,(char *)geom->key_aliases,
+ (rep->nKeyAliases*XkbKeyNameLength*2)))
+ return BadLength;
+ geom->num_key_aliases= rep->nKeyAliases;
+ return Success;
+ }
+ else { /* alloc failed, just skip the aliases */
+ _XkbSkipReadBufferData(buf,(rep->nKeyAliases*XkbKeyNameLength*2));
+ }
+ return rtrn;
+}
+
+static Status
+_XkbReadGeomColors( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep)
+{
+Status rtrn;
+
+ if (rep->nColors<1)
+ return Success;
+ if ((rtrn=XkbAllocGeomColors(geom,rep->nColors))==Success) {
+ register int i;
+ char *spec;
+ for (i=0;i<rep->nColors;i++) {
+ if (!_XkbGetReadBufferCountedString(buf,&spec))
+ return BadLength;
+ if (XkbAddGeomColor(geom,spec,geom->num_colors)==NULL)
+ return BadAlloc;
+ }
+ return Success;
+ }
+ return rtrn;
+}
+
+static Status
+_XkbReadGeomShapes( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep)
+{
+register int i;
+Status rtrn;
+
+ if (rep->nShapes<1)
+ return Success;
+ if ((rtrn=XkbAllocGeomShapes(geom,rep->nShapes))!=Success)
+ return rtrn;
+ for (i=0;i<rep->nShapes;i++) {
+ xkbShapeWireDesc *shapeWire;
+ XkbShapePtr shape;
+ register int o;
+ shapeWire= (xkbShapeWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbShapeWireDesc));
+ if (!shapeWire)
+ return BadLength;
+ shape= XkbAddGeomShape(geom,shapeWire->name,shapeWire->nOutlines);
+ if (!shape)
+ return BadAlloc;
+ for (o=0;o<shapeWire->nOutlines;o++) {
+ xkbOutlineWireDesc *olWire;
+ XkbOutlinePtr ol;
+ register int p;
+ XkbPointPtr pt;
+ olWire= (xkbOutlineWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbOutlineWireDesc));
+ if (!olWire)
+ return BadLength;
+ ol= XkbAddGeomOutline(shape,olWire->nPoints);
+ if (!ol)
+ return BadAlloc;
+ ol->corner_radius= olWire->cornerRadius;
+ for (p=0,pt=ol->points;p<olWire->nPoints;p++,pt++) {
+ xkbPointWireDesc * ptWire;
+ ptWire= (xkbPointWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbPointWireDesc));
+ if (!ptWire)
+ return BadLength;
+ pt->x= ptWire->x;
+ pt->y= ptWire->y;
+ }
+ ol->num_points= olWire->nPoints;
+ }
+ if (shapeWire->primaryNdx!=XkbNoShape)
+ shape->primary= &shape->outlines[shapeWire->primaryNdx];
+ else shape->primary= NULL;
+ if (shapeWire->approxNdx!=XkbNoShape)
+ shape->approx= &shape->outlines[shapeWire->approxNdx];
+ else shape->approx= NULL;
+ XkbComputeShapeBounds(shape);
+ }
+ return Success;
+}
+
+static Status
+_XkbReadGeomDoodad( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ XkbSectionPtr section)
+{
+XkbDoodadPtr doodad;
+xkbDoodadWireDesc * doodadWire;
+
+ doodadWire= (xkbDoodadWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbDoodadWireDesc));
+ if (!doodadWire)
+ return BadLength;
+ doodad= XkbAddGeomDoodad(geom,section,doodadWire->any.name);
+ if (!doodad)
+ return BadAlloc;
+ doodad->any.type= doodadWire->any.type;
+ doodad->any.priority= doodadWire->any.priority;
+ doodad->any.top= doodadWire->any.top;
+ doodad->any.left= doodadWire->any.left;
+ doodad->any.angle= doodadWire->any.angle;
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ doodad->shape.color_ndx= doodadWire->shape.colorNdx;
+ doodad->shape.shape_ndx= doodadWire->shape.shapeNdx;
+ break;
+ case XkbTextDoodad:
+ doodad->text.width= doodadWire->text.width;
+ doodad->text.height= doodadWire->text.height;
+ doodad->text.color_ndx= doodadWire->text.colorNdx;
+ if (!_XkbGetReadBufferCountedString(buf,&doodad->text.text))
+ return BadLength;
+ if (!_XkbGetReadBufferCountedString(buf,&doodad->text.font))
+ return BadLength;
+ break;
+ case XkbIndicatorDoodad:
+ doodad->indicator.shape_ndx= doodadWire->indicator.shapeNdx;
+ doodad->indicator.on_color_ndx= doodadWire->indicator.onColorNdx;
+ doodad->indicator.off_color_ndx= doodadWire->indicator.offColorNdx;
+ break;
+ case XkbLogoDoodad:
+ doodad->logo.color_ndx= doodadWire->logo.colorNdx;
+ doodad->logo.shape_ndx= doodadWire->logo.shapeNdx;
+ if (!_XkbGetReadBufferCountedString(buf,&doodad->logo.logo_name))
+ return BadLength;
+ break;
+ default:
+ return BadValue;
+ }
+ return Success;
+}
+
+static Status
+_XkbReadGeomOverlay( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ XkbSectionPtr section)
+{
+XkbOverlayPtr ol;
+xkbOverlayWireDesc * olWire;
+register int r;
+
+ olWire= (xkbOverlayWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbOverlayWireDesc));
+ if (olWire==NULL)
+ return BadLength;
+ ol= XkbAddGeomOverlay(section,olWire->name,olWire->nRows);
+ if (ol==NULL)
+ return BadLength;
+ for (r=0;r<olWire->nRows;r++) {
+ register int k;
+ XkbOverlayRowPtr row;
+ xkbOverlayRowWireDesc * rowWire;
+ xkbOverlayKeyWireDesc * keyWire;
+ rowWire= (xkbOverlayRowWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbOverlayRowWireDesc));
+ if (rowWire==NULL)
+ return BadLength;
+ row= XkbAddGeomOverlayRow(ol,rowWire->rowUnder,rowWire->nKeys);
+ row->row_under= rowWire->rowUnder;
+ if (!row)
+ return BadAlloc;
+ if (rowWire->nKeys<1)
+ continue;
+ keyWire= (xkbOverlayKeyWireDesc *)
+ _XkbGetReadBufferPtr(buf,
+ SIZEOF(xkbOverlayKeyWireDesc)*rowWire->nKeys);
+ if (keyWire==NULL)
+ return BadLength;
+ for (k=0;k<rowWire->nKeys;k++,keyWire++,row->num_keys++) {
+ memcpy(row->keys[row->num_keys].over.name,keyWire->over,
+ XkbKeyNameLength);
+ memcpy(row->keys[row->num_keys].under.name,keyWire->under,
+ XkbKeyNameLength);
+ }
+ }
+ return Success;
+}
+
+static Status
+_XkbReadGeomSections( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep)
+{
+register int s;
+XkbSectionPtr section;
+xkbSectionWireDesc * sectionWire;
+Status rtrn;
+
+ if (rep->nSections<1)
+ return Success;
+ if ((rtrn=XkbAllocGeomSections(geom,rep->nSections))!=Success)
+ return rtrn;
+ for (s=0;s<rep->nSections;s++) {
+ sectionWire= (xkbSectionWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbSectionWireDesc));
+ if (!sectionWire)
+ return BadLength;
+ section= XkbAddGeomSection(geom,sectionWire->name,sectionWire->nRows,
+ sectionWire->nDoodads,
+ sectionWire->nOverlays);
+ if (!section)
+ return BadAlloc;
+ section->top= sectionWire->top;
+ section->left= sectionWire->left;
+ section->width= sectionWire->width;
+ section->height= sectionWire->height;
+ section->angle= sectionWire->angle;
+ section->priority= sectionWire->priority;
+ if (sectionWire->nRows>0) {
+ register int r;
+ XkbRowPtr row;
+ xkbRowWireDesc * rowWire;
+ for (r=0;r<sectionWire->nRows;r++) {
+ rowWire= (xkbRowWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbRowWireDesc));
+ if (!rowWire)
+ return BadLength;
+ row= XkbAddGeomRow(section,rowWire->nKeys);
+ if (!row)
+ return BadAlloc;
+ row->top= rowWire->top;
+ row->left= rowWire->left;
+ row->vertical= rowWire->vertical;
+ if (rowWire->nKeys>0) {
+ register int k;
+ XkbKeyPtr key;
+ xkbKeyWireDesc * keyWire;
+ for (k=0;k<rowWire->nKeys;k++) {
+ keyWire= (xkbKeyWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbKeyWireDesc));
+ if (!keyWire)
+ return BadLength;
+ key= XkbAddGeomKey(row);
+ if (!key)
+ return BadAlloc;
+ memcpy(key->name.name,keyWire->name,XkbKeyNameLength);
+ key->gap= keyWire->gap;
+ key->shape_ndx= keyWire->shapeNdx;
+ key->color_ndx= keyWire->colorNdx;
+ }
+ }
+ }
+ }
+ if (sectionWire->nDoodads>0) {
+ register int d;
+ for (d=0;d<sectionWire->nDoodads;d++) {
+ if ((rtrn=_XkbReadGeomDoodad(buf,geom,section))!=Success)
+ return rtrn;
+ }
+ }
+ if (sectionWire->nOverlays>0) {
+ register int o;
+ for (o=0;o<sectionWire->nOverlays;o++) {
+ if ((rtrn=_XkbReadGeomOverlay(buf,geom,section))!=Success)
+ return rtrn;
+ }
+ }
+ }
+ return Success;
+}
+
+static Status
+_XkbReadGeomDoodads( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep)
+{
+register int d;
+Status rtrn;
+
+ if (rep->nDoodads<1)
+ return Success;
+ if ((rtrn=XkbAllocGeomDoodads(geom,rep->nDoodads))!=Success)
+ return rtrn;
+ for (d=0;d<rep->nDoodads;d++) {
+ if ((rtrn=_XkbReadGeomDoodad(buf,geom,NULL))!=Success)
+ return rtrn;
+ }
+ return Success;
+}
+
+Status
+_XkbReadGetGeometryReply( Display * dpy,
+ xkbGetGeometryReply * rep,
+ XkbDescPtr xkb,
+ int * nread_rtrn)
+{
+XkbGeometryPtr geom;
+
+ geom= _XkbTypedCalloc(1,XkbGeometryRec);
+ if (!geom)
+ return BadAlloc;
+ if (xkb->geom)
+ XkbFreeGeometry(xkb->geom,XkbGeomAllMask,True);
+ xkb->geom= geom;
+
+ geom->name= rep->name;
+ geom->width_mm= rep->widthMM;
+ geom->height_mm= rep->heightMM;
+ if (rep->length) {
+ XkbReadBufferRec buf;
+ int left;
+ if (_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4)) {
+ Status status= Success;
+ if (nread_rtrn)
+ *nread_rtrn= (int)rep->length*4;
+ if (!_XkbGetReadBufferCountedString(&buf,&geom->label_font))
+ status= BadLength;
+ if (status==Success)
+ status= _XkbReadGeomProperties(&buf,geom,rep);
+ if (status==Success)
+ status= _XkbReadGeomColors(&buf,geom,rep);
+ if (status==Success)
+ status= _XkbReadGeomShapes(&buf,geom,rep);
+ if (status==Success)
+ status= _XkbReadGeomSections(&buf,geom,rep);
+ if (status==Success)
+ status= _XkbReadGeomDoodads(&buf,geom,rep);
+ if (status==Success)
+ status= _XkbReadGeomKeyAliases(&buf,geom,rep);
+ left= _XkbFreeReadBuffer(&buf);
+ if ((status!=Success) || left || buf.error) {
+ if (status==Success)
+ status= BadLength;
+ XkbFreeGeometry(geom,XkbGeomAllMask,True);
+ xkb->geom= NULL;
+ return status;
+ }
+ geom->base_color= &geom->colors[rep->baseColorNdx];
+ geom->label_color= &geom->colors[rep->labelColorNdx];
+ }
+ else {
+ XkbFreeGeometry(geom,XkbGeomAllMask,True);
+ xkb->geom= NULL;
+ return BadAlloc;
+ }
+ }
+ return Success;
+}
+
+Status
+XkbGetGeometry(Display *dpy,XkbDescPtr xkb)
+{
+xkbGetGeometryReq *req;
+xkbGetGeometryReply rep;
+
+ if ( (!xkb) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ GetReq(kbGetGeometry, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetGeometry;
+ req->deviceSpec = xkb->device_spec;
+ req->name= None;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
+ return BadImplementation;
+ if (!rep.found)
+ return BadName;
+ return _XkbReadGetGeometryReply(dpy,&rep,xkb,NULL);
+}
+
+Status
+XkbGetNamedGeometry(Display *dpy,XkbDescPtr xkb,Atom name)
+{
+xkbGetGeometryReq *req;
+xkbGetGeometryReply rep;
+
+ if ( (name==None) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) )
+ return BadAccess;
+
+ GetReq(kbGetGeometry, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetGeometry;
+ req->deviceSpec = xkb->device_spec;
+ req->name= (CARD32)name;
+ if ((!_XReply(dpy, (xReply *)&rep, 0, xFalse))||(!rep.found))
+ return BadImplementation;
+ if (!rep.found)
+ return BadName;
+ return _XkbReadGetGeometryReply(dpy,&rep,xkb,NULL);
+}
+
diff --git a/nx-X11/lib/X11/XKBGetByName.c b/nx-X11/lib/X11/XKBGetByName.c
new file mode 100644
index 000000000..2c6ff0849
--- /dev/null
+++ b/nx-X11/lib/X11/XKBGetByName.c
@@ -0,0 +1,218 @@
+/* $Xorg: XKBGetByName.c,v 1.3 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86$ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#define NEED_MAP_READERS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+/***====================================================================***/
+
+XkbDescPtr
+XkbGetKeyboardByName( Display * dpy,
+ unsigned deviceSpec,
+ XkbComponentNamesPtr names,
+ unsigned want,
+ unsigned need,
+ Bool load)
+{
+ register xkbGetKbdByNameReq * req;
+ xkbGetKbdByNameReply rep;
+ int len,extraLen;
+ char * str;
+ XkbDescPtr xkb;
+ int mapLen,codesLen,typesLen,compatLen;
+ int symsLen,geomLen;
+ XkbInfoPtr xkbi;
+
+ if ( (dpy==NULL) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) )
+ return NULL;
+
+ xkbi= dpy->xkb_info;
+ xkb = (XkbDescRec *)_XkbCalloc(1,sizeof(XkbDescRec));
+ if (!xkb)
+ return NULL;
+ xkb->device_spec = deviceSpec;
+ xkb->map = (XkbClientMapRec *)_XkbCalloc(1,sizeof(XkbClientMapRec));
+ xkb->dpy = dpy;
+
+ LockDisplay(dpy);
+ GetReq(kbGetKbdByName, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetKbdByName;
+ req->deviceSpec = xkb->device_spec;
+ req->want= want;
+ req->need= need;
+ req->load= load;
+
+ mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0;
+ if (names) {
+ if (names->keymap)
+ mapLen= (int)strlen(names->keymap);
+ if (names->keycodes)
+ codesLen= (int)strlen(names->keycodes);
+ if (names->types)
+ typesLen= (int)strlen(names->types);
+ if (names->compat)
+ compatLen= (int)strlen(names->compat);
+ if (names->symbols)
+ symsLen= (int)strlen(names->symbols);
+ if (names->geometry)
+ geomLen= (int)strlen(names->geometry);
+ if (mapLen>255) mapLen= 255;
+ if (codesLen>255) codesLen= 255;
+ if (typesLen>255) typesLen= 255;
+ if (compatLen>255) compatLen= 255;
+ if (symsLen>255) symsLen= 255;
+ if (geomLen>255) geomLen= 255;
+ }
+ else mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0;
+
+ len= mapLen+codesLen+typesLen+compatLen+symsLen+geomLen+6;
+ len= XkbPaddedSize(len);
+ req->length+= len/4;
+ BufAlloc(char *,str,len);
+ *str++= mapLen;
+ if (mapLen>0) {
+ memcpy(str,names->keymap,mapLen);
+ str+= mapLen;
+ }
+ *str++= codesLen;
+ if (codesLen>0) {
+ memcpy(str,names->keycodes,codesLen);
+ str+= codesLen;
+ }
+ *str++= typesLen;
+ if (typesLen>0) {
+ memcpy(str,names->types,typesLen);
+ str+= typesLen;
+ }
+ *str++= compatLen;
+ if (compatLen>0) {
+ memcpy(str,names->compat,compatLen);
+ str+= compatLen;
+ }
+ *str++= symsLen;
+ if (symsLen>0) {
+ memcpy(str,names->symbols,symsLen);
+ str+= symsLen;
+ }
+ *str++= geomLen;
+ if (geomLen>0) {
+ memcpy(str,names->geometry,geomLen);
+ str+= geomLen;
+ }
+ if ((!_XReply(dpy, (xReply *)&rep, 0, xFalse))||(!rep.reported))
+ goto BAILOUT;
+ extraLen= (int)rep.length*4;
+
+ xkb->device_spec= rep.deviceID;
+ xkb->min_key_code = rep.minKeyCode;
+ xkb->max_key_code = rep.maxKeyCode;
+ if (rep.reported&(XkbGBN_SymbolsMask|XkbGBN_TypesMask)) {
+ xkbGetMapReply mrep;
+ Status status;
+ int nread= 0;
+
+ _XRead(dpy, (char *)&mrep, SIZEOF(xkbGetMapReply));
+ extraLen-= SIZEOF(xkbGetMapReply);
+ status= _XkbReadGetMapReply(dpy,&mrep,xkb,&nread);
+ extraLen-= nread;
+ if (status!=Success)
+ goto BAILOUT;
+ }
+ if (rep.reported&XkbGBN_CompatMapMask) {
+ xkbGetCompatMapReply crep;
+ Status status;
+ int nread= 0;
+
+ _XRead(dpy, (char *)&crep, SIZEOF(xkbGetCompatMapReply));
+ extraLen-= SIZEOF(xkbGetCompatMapReply);
+ status= _XkbReadGetCompatMapReply(dpy,&crep,xkb,&nread);
+ extraLen-= nread;
+ if (status!=Success)
+ goto BAILOUT;
+ }
+ if (rep.reported&XkbGBN_IndicatorMapMask) {
+ xkbGetIndicatorMapReply irep;
+ Status status;
+ int nread= 0;
+
+ _XRead(dpy, (char *)&irep, SIZEOF(xkbGetIndicatorMapReply));
+ extraLen-= SIZEOF(xkbGetIndicatorMapReply);
+ status= _XkbReadGetIndicatorMapReply(dpy,&irep,xkb,&nread);
+ extraLen-= nread;
+ if (status!=Success)
+ goto BAILOUT;
+ }
+ if (rep.reported&(XkbGBN_KeyNamesMask|XkbGBN_OtherNamesMask)) {
+ xkbGetNamesReply nrep;
+ Status status;
+ int nread= 0;
+
+ _XRead(dpy, (char *)&nrep, SIZEOF(xkbGetNamesReply));
+ extraLen-= SIZEOF(xkbGetNamesReply);
+ status= _XkbReadGetNamesReply(dpy,&nrep,xkb,&nread);
+ extraLen-= nread;
+ if (status!=Success)
+ goto BAILOUT;
+ }
+ if (rep.reported&XkbGBN_GeometryMask) {
+ xkbGetGeometryReply grep;
+ Status status;
+ int nread= 0;
+
+ _XRead(dpy, (char *)&grep, SIZEOF(xkbGetGeometryReply));
+ extraLen-= SIZEOF(xkbGetGeometryReply);
+ status= _XkbReadGetGeometryReply(dpy,&grep,xkb,&nread);
+ extraLen-= nread;
+ if (status!=Success)
+ goto BAILOUT;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return xkb;
+BAILOUT:
+ if (xkb!=NULL)
+ XkbFreeKeyboard(xkb,XkbAllComponentsMask,xTrue);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+}
+
+XkbDescPtr
+XkbGetKeyboard(Display *dpy,unsigned which,unsigned deviceSpec)
+{
+ return XkbGetKeyboardByName(dpy,deviceSpec,NULL,which,which,False);
+}
diff --git a/nx-X11/lib/X11/XKBGetMap.c b/nx-X11/lib/X11/XKBGetMap.c
new file mode 100644
index 000000000..2b9fb97f4
--- /dev/null
+++ b/nx-X11/lib/X11/XKBGetMap.c
@@ -0,0 +1,823 @@
+/* $Xorg: XKBGetMap.c,v 1.4 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+
+/* $XFree86: xc/lib/X11/XKBGetMap.c,v 1.9 2003/04/17 02:06:31 dawes Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#define NEED_MAP_READERS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+static Status
+_XkbReadKeyTypes(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+int i,n,lastMapCount;
+XkbKeyTypePtr type;
+
+ if ( rep->nTypes>0 ) {
+ n = rep->firstType+rep->nTypes;
+ if (xkb->map->num_types>=n)
+ n= xkb->map->num_types;
+ else if (XkbAllocClientMap(xkb,XkbKeyTypesMask,n)!=Success)
+ return BadAlloc;
+
+ type = &xkb->map->types[rep->firstType];
+ for (i=0;i<(int)rep->nTypes;i++,type++) {
+ xkbKeyTypeWireDesc *desc;
+ register int ndx;
+
+ ndx= i+rep->firstType;
+ if (ndx>=xkb->map->num_types)
+ xkb->map->num_types= ndx+1;
+
+ desc= (xkbKeyTypeWireDesc *)_XkbGetReadBufferPtr(buf,
+ SIZEOF(xkbKeyTypeWireDesc));
+ if (desc==NULL)
+ return BadLength;
+
+ lastMapCount= type->map_count;
+ if ( desc->nMapEntries>0 ) {
+ if ((type->map==NULL)||(desc->nMapEntries>type->map_count)) {
+ XkbKTMapEntryRec *prev_map = type->map;
+
+ type->map= _XkbTypedRealloc(type->map,desc->nMapEntries,
+ XkbKTMapEntryRec);
+ if (type->map==NULL) {
+ _XkbFree(prev_map);
+ return BadAlloc;
+ }
+ }
+ }
+ else if (type->map!=NULL) {
+ Xfree(type->map);
+ type->map_count= 0;
+ type->map= NULL;
+ }
+
+ if ( desc->preserve && (desc->nMapEntries>0) ) {
+ if ((!type->preserve)||
+ (desc->nMapEntries>lastMapCount)) {
+ XkbModsRec *prev_preserve = type->preserve;
+
+ type->preserve= _XkbTypedRealloc(type->preserve,
+ desc->nMapEntries,
+ XkbModsRec);
+ if (type->preserve==NULL) {
+ _XkbFree(prev_preserve);
+ return BadAlloc;
+ }
+ }
+ }
+ else if (type->preserve!=NULL) {
+ Xfree(type->preserve);
+ type->preserve= NULL;
+ }
+
+ type->mods.mask = desc->mask;
+ type->mods.real_mods = desc->realMods;
+ type->mods.vmods = desc->virtualMods;
+ type->num_levels = desc->numLevels;
+ type->map_count = desc->nMapEntries;
+ if (desc->nMapEntries>0) {
+ register xkbKTMapEntryWireDesc *wire;
+ register XkbKTMapEntryPtr entry;
+ register int size;
+
+ size= type->map_count*SIZEOF(xkbKTMapEntryWireDesc);
+ wire= (xkbKTMapEntryWireDesc *)_XkbGetReadBufferPtr(buf,size);
+ if (wire==NULL)
+ return BadLength;
+ entry= type->map;
+ for (n=0;n<type->map_count;n++,wire++,entry++) {
+ entry->active= wire->active;
+ entry->level= wire->level;
+ entry->mods.mask= wire->mask;
+ entry->mods.real_mods= wire->realMods;
+ entry->mods.vmods= wire->virtualMods;
+ }
+
+ if (desc->preserve) {
+ register xkbModsWireDesc * pwire;
+ register XkbModsPtr preserve;
+ register int sz;
+
+ sz= desc->nMapEntries*SIZEOF(xkbModsWireDesc);
+ pwire=(xkbModsWireDesc *)_XkbGetReadBufferPtr(buf,sz);
+ if (pwire==NULL)
+ return BadLength;
+ preserve= type->preserve;
+ for (n=0;n<desc->nMapEntries;n++,pwire++,preserve++) {
+ preserve->mask= pwire->mask;
+ preserve->vmods= pwire->virtualMods;
+ preserve->real_mods= pwire->realMods;
+ }
+ }
+ }
+ }
+ }
+ return Success;
+}
+
+static Status
+_XkbReadKeySyms(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+register int i;
+XkbClientMapPtr map;
+
+ map= xkb->map;
+ if (map->key_sym_map==NULL) {
+ register int offset;
+ XkbSymMapPtr oldMap;
+ xkbSymMapWireDesc *newMap;
+ map->key_sym_map= _XkbTypedCalloc((xkb->max_key_code+1),XkbSymMapRec);
+ if (map->key_sym_map==NULL)
+ return BadAlloc;
+ if (map->syms==NULL) {
+ int sz;
+ sz= (rep->totalSyms*12)/10;
+ sz= ((sz+(unsigned)128)/128)*128;
+ map->syms = _XkbTypedCalloc(sz,KeySym);
+ if (map->syms==NULL)
+ return BadAlloc;
+ map->size_syms = sz;
+ }
+ offset = 1;
+ oldMap = &map->key_sym_map[rep->firstKeySym];
+ for (i=0;i<(int)rep->nKeySyms;i++,oldMap++) {
+ newMap= (xkbSymMapWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbSymMapWireDesc));
+ if (newMap==NULL)
+ return BadLength;
+ oldMap->kt_index[0]= newMap->ktIndex[0];
+ oldMap->kt_index[1]= newMap->ktIndex[1];
+ oldMap->kt_index[2]= newMap->ktIndex[2];
+ oldMap->kt_index[3]= newMap->ktIndex[3];
+ oldMap->group_info= newMap->groupInfo;
+ oldMap->width= newMap->width;
+ oldMap->offset= offset;
+ if (offset+newMap->nSyms>=map->size_syms) {
+ register int sz;
+ KeySym *prev_syms = map->syms;
+
+ sz= map->size_syms+128;
+ map->syms= _XkbTypedRealloc(map->syms,sz,KeySym);
+ if (map->syms==NULL) {
+ _XkbFree(prev_syms);
+ map->size_syms= 0;
+ return BadAlloc;
+ }
+ map->size_syms= sz;
+ }
+ if (newMap->nSyms>0) {
+ _XkbReadBufferCopyKeySyms(buf,(KeySym *)&map->syms[offset],
+ newMap->nSyms);
+ offset+= newMap->nSyms;
+ }
+ else {
+ map->syms[offset]= 0;
+ }
+ }
+ map->num_syms= offset;
+ }
+ else {
+ xkbSymMapWireDesc * newMap;
+ XkbSymMapPtr oldMap;
+ KeySym * newSyms;
+ int tmp;
+
+ oldMap = &map->key_sym_map[rep->firstKeySym];
+ for (i=0;i<(int)rep->nKeySyms;i++,oldMap++) {
+ newMap= (xkbSymMapWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbSymMapWireDesc));
+ if (newMap==NULL)
+ return BadLength;
+
+ if (newMap->nSyms>0)
+ tmp= newMap->nSyms;
+ else tmp= 0;
+
+ newSyms = XkbResizeKeySyms(xkb,i+rep->firstKeySym,tmp);
+ if (newSyms==NULL)
+ return BadAlloc;
+ if (newMap->nSyms>0)
+ _XkbReadBufferCopyKeySyms(buf,newSyms,newMap->nSyms);
+ else newSyms[0]= NoSymbol;
+ oldMap->kt_index[0] = newMap->ktIndex[0];
+ oldMap->kt_index[1] = newMap->ktIndex[1];
+ oldMap->kt_index[2] = newMap->ktIndex[2];
+ oldMap->kt_index[3] = newMap->ktIndex[3];
+ oldMap->group_info = newMap->groupInfo;
+ oldMap->width = newMap->width;
+ }
+ }
+ return Success;
+}
+
+static Status
+_XkbReadKeyActions(XkbReadBufferPtr buf,XkbDescPtr info,xkbGetMapReply *rep)
+{
+int i;
+CARD8 numDescBuf[248];
+CARD8* numDesc = NULL;
+register int nKeyActs;
+Status ret = Success;
+
+ if ( (nKeyActs=rep->nKeyActs)>0 ) {
+ XkbSymMapPtr symMap;
+
+ if (nKeyActs < sizeof numDescBuf) numDesc = numDescBuf;
+ else numDesc = Xmalloc (nKeyActs * sizeof(CARD8));
+
+ if (!_XkbCopyFromReadBuffer(buf, (char *)numDesc, nKeyActs)) {
+ ret = BadLength;
+ goto done;
+ }
+ i= XkbPaddedSize(nKeyActs)-nKeyActs;
+ if ((i>0)&&(!_XkbSkipReadBufferData(buf,i))) {
+ ret = BadLength;
+ goto done;
+ }
+ symMap = &info->map->key_sym_map[rep->firstKeyAct];
+ for (i=0;i<(int)rep->nKeyActs;i++,symMap++) {
+ if (numDesc[i]==0) {
+ info->server->key_acts[i+rep->firstKeyAct]= 0;
+ }
+ else {
+ XkbAction *newActs;
+ /* 8/16/93 (ef) -- XXX! Verify size here (numdesc must be */
+ /* either zero or XkbKeyNumSyms(info,key) */
+ newActs=XkbResizeKeyActions(info,i+rep->firstKeyAct,
+ numDesc[i]);
+ if (newActs==NULL) {
+ ret = BadAlloc;
+ goto done;
+ }
+ if (!_XkbCopyFromReadBuffer(buf,(char *)newActs,
+ (int)(numDesc[i]*sizeof(XkbAction)))) {
+ ret = BadLength;
+ goto done;
+ }
+ }
+ }
+ }
+done:
+ if (numDesc != NULL && numDesc != numDescBuf) Xfree (numDesc);
+ return ret;
+}
+
+static Status
+_XkbReadKeyBehaviors(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+register int i;
+xkbBehaviorWireDesc *wire;
+
+ if ( rep->totalKeyBehaviors>0 ) {
+ if ( xkb->server->behaviors == NULL ) {
+ int size = xkb->max_key_code+1;
+ xkb->server->behaviors = _XkbTypedCalloc(size,XkbBehavior);
+ if (xkb->server->behaviors==NULL)
+ return BadAlloc;
+ }
+ else {
+ bzero(&xkb->server->behaviors[rep->firstKeyBehavior],
+ (rep->nKeyBehaviors*sizeof(XkbBehavior)));
+ }
+ for (i=0;i<rep->totalKeyBehaviors;i++) {
+ wire= (xkbBehaviorWireDesc *)_XkbGetReadBufferPtr(buf,
+ SIZEOF(xkbBehaviorWireDesc));
+ if (wire==NULL)
+ return BadLength;
+ xkb->server->behaviors[wire->key].type= wire->type;
+ xkb->server->behaviors[wire->key].data= wire->data;
+ }
+ }
+ return Success;
+}
+
+static Status
+_XkbReadVirtualMods(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+ if ( rep->virtualMods ) {
+ register int i,bit,nVMods;
+ register char *data;
+
+ for (i=nVMods=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (rep->virtualMods&bit)
+ nVMods++;
+ }
+ data= _XkbGetReadBufferPtr(buf,XkbPaddedSize(nVMods));
+ if (data==NULL)
+ return BadLength;
+ for (i=0,bit=1;(i<XkbNumVirtualMods)&&(nVMods>0);i++,bit<<=1) {
+ if (rep->virtualMods&bit) {
+ xkb->server->vmods[i]= *data++;
+ nVMods--;
+ }
+ }
+ }
+ return Success;
+}
+
+static Status
+_XkbReadExplicitComponents( XkbReadBufferPtr buf,
+ XkbDescPtr xkb,
+ xkbGetMapReply * rep)
+{
+register int i;
+unsigned char *wire;
+
+ if ( rep->totalKeyExplicit>0 ) {
+ if ( xkb->server->explicit == NULL ) {
+ int size = xkb->max_key_code+1;
+ xkb->server->explicit = _XkbTypedCalloc(size,unsigned char);
+ if (xkb->server->explicit==NULL)
+ return BadAlloc;
+ }
+ else {
+ bzero(&xkb->server->explicit[rep->firstKeyExplicit],
+ rep->nKeyExplicit);
+ }
+ i= XkbPaddedSize(2*rep->totalKeyExplicit);
+ wire=(unsigned char *)_XkbGetReadBufferPtr(buf,i);
+ if (!wire)
+ return BadLength;
+ for (i=0;i<rep->totalKeyExplicit;i++,wire+=2) {
+ xkb->server->explicit[wire[0]]= wire[1];
+ }
+ }
+ return Success;
+}
+
+static Status
+_XkbReadModifierMap(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+register int i;
+unsigned char *wire;
+
+ if ( rep->totalModMapKeys>0 ) {
+ if ((xkb->map->modmap==NULL)&&
+ (XkbAllocClientMap(xkb,XkbModifierMapMask,0)!=Success)) {
+ return BadAlloc;
+ }
+ else {
+ bzero(&xkb->map->modmap[rep->firstModMapKey],rep->nModMapKeys);
+ }
+ i= XkbPaddedSize(2*rep->totalModMapKeys);
+ wire=(unsigned char *)_XkbGetReadBufferPtr(buf,i);
+ if (!wire)
+ return BadLength;
+ for (i=0;i<rep->totalModMapKeys;i++,wire+=2) {
+ xkb->map->modmap[wire[0]]= wire[1];
+ }
+ }
+ return Success;
+}
+
+static Status
+_XkbReadVirtualModMap(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+register int i;
+xkbVModMapWireDesc * wire;
+XkbServerMapPtr srv;
+
+ if ( rep->totalVModMapKeys>0 ) {
+ if (((xkb->server==NULL)||(xkb->server->vmodmap==NULL))&&
+ (XkbAllocServerMap(xkb,XkbVirtualModMapMask,0)!=Success)) {
+ return BadAlloc;
+ }
+ else {
+ srv= xkb->server;
+ if (rep->nVModMapKeys > rep->firstVModMapKey)
+ bzero((char *)&srv->vmodmap[rep->firstVModMapKey],
+ (rep->nVModMapKeys - rep->firstVModMapKey) *
+ sizeof(unsigned short));
+ }
+ srv= xkb->server;
+ i= rep->totalVModMapKeys*SIZEOF(xkbVModMapWireDesc);
+ wire=(xkbVModMapWireDesc *)_XkbGetReadBufferPtr(buf,i);
+ if (!wire)
+ return BadLength;
+ for (i=0;i<rep->totalVModMapKeys;i++,wire++) {
+ if ((wire->key>=xkb->min_key_code)&&(wire->key<=xkb->max_key_code))
+ srv->vmodmap[wire->key]= wire->vmods;
+ }
+ }
+ return Success;
+}
+
+static xkbGetMapReq *
+_XkbGetGetMapReq(Display *dpy,XkbDescPtr xkb)
+{
+xkbGetMapReq *req;
+
+ GetReq(kbGetMap, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetMap;
+ req->deviceSpec = xkb->device_spec;
+ req->full = req->partial = 0;
+ req->firstType = req->nTypes = 0;
+ req->firstKeySym = req->nKeySyms = 0;
+ req->firstKeyAct = req->nKeyActs = 0;
+ req->firstKeyBehavior = req->nKeyBehaviors = 0;
+ req->virtualMods = 0;
+ req->firstKeyExplicit = req->nKeyExplicit = 0;
+ req->firstModMapKey = req->nModMapKeys = 0;
+ req->firstVModMapKey = req->nVModMapKeys = 0;
+ return req;
+}
+
+Status
+_XkbReadGetMapReply( Display * dpy,
+ xkbGetMapReply *rep,
+ XkbDescPtr xkb,
+ int * nread_rtrn)
+{
+int extraData;
+unsigned mask;
+
+ if ( xkb->device_spec == XkbUseCoreKbd )
+ xkb->device_spec= rep->deviceID;
+ xkb->min_key_code = rep->minKeyCode;
+ xkb->max_key_code = rep->maxKeyCode;
+
+ if (!xkb->map) {
+ mask= rep->present&XkbAllClientInfoMask;
+ if (mask&&(XkbAllocClientMap(xkb,mask,rep->nTypes)!=Success))
+ return BadAlloc;
+ }
+ if (!xkb->server) {
+ mask= rep->present&XkbAllServerInfoMask;
+ if (mask&&(XkbAllocServerMap(xkb,mask,rep->totalActs)!=Success))
+ return BadAlloc;
+ }
+ extraData= (int)(rep->length*4);
+ extraData-= (SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply));
+ if (rep->length) {
+ XkbReadBufferRec buf;
+ int left;
+ if (_XkbInitReadBuffer(dpy,&buf,extraData)) {
+ Status status= Success;
+ if (nread_rtrn!=NULL)
+ *nread_rtrn= extraData;
+ if (status==Success)
+ status= _XkbReadKeyTypes(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadKeySyms(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadKeyActions(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadKeyBehaviors(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadVirtualMods(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadExplicitComponents(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadModifierMap(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadVirtualModMap(&buf,xkb,rep);
+ left= _XkbFreeReadBuffer(&buf);
+ if (status!=Success) return status;
+ else if ( left || buf.error ) return BadLength;
+ }
+ else return BadAlloc;
+ }
+ return Success;
+}
+
+static Status
+_XkbHandleGetMapReply(Display *dpy,XkbDescPtr xkb)
+{
+xkbGetMapReply rep;
+
+ if (!_XReply(dpy, (xReply *)&rep,
+ ( (SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply)) >> 2 ),
+ xFalse)) {
+ return BadImplementation;
+ }
+ return _XkbReadGetMapReply(dpy,&rep,xkb,NULL);
+}
+
+Status
+XkbGetUpdatedMap(Display *dpy,unsigned which,XkbDescPtr xkb)
+{
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ if (which) {
+ register xkbGetMapReq *req;
+ Status status;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->full = which;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+ }
+ return Success;
+}
+
+XkbDescPtr
+XkbGetMap(Display *dpy,unsigned which,unsigned deviceSpec)
+{
+XkbDescPtr xkb;
+
+ xkb = _XkbTypedCalloc(1,XkbDescRec);
+ if (xkb) {
+ xkb->device_spec = deviceSpec;
+ xkb->map = _XkbTypedCalloc(1,XkbClientMapRec);
+ if ((xkb->map==NULL)||
+ ((which)&&(XkbGetUpdatedMap(dpy,which,xkb)!=Success))) {
+ if (xkb->map) {
+ Xfree(xkb->map);
+ xkb->map= NULL;
+ }
+ Xfree(xkb);
+ return NULL;
+ }
+ xkb->dpy= dpy;
+ }
+ return xkb;
+}
+
+Status
+XkbGetKeyTypes(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ if ((num<1)||(num>XkbMaxKeyTypes))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstType = first;
+ req->nTypes = num;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+XkbGetKeyActions(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ if ((num<1)||(num>XkbMaxKeyCount))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstKeyAct = first;
+ req->nKeyActs = num;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+XkbGetKeySyms(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ if ((num<1)||(num>XkbMaxKeyCount))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstKeySym = first;
+ req->nKeySyms = num;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return status;
+}
+
+Status
+XkbGetKeyBehaviors(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ if ((num<1)||(num>XkbMaxKeyCount))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstKeyBehavior = first;
+ req->nKeyBehaviors = num;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+XkbGetVirtualMods(Display *dpy,unsigned which,XkbDescPtr xkb)
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->virtualMods = which;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+XkbGetKeyExplicitComponents( Display * dpy,
+ unsigned first,
+ unsigned num,
+ XkbDescPtr xkb)
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ if ((num<1)||(num>XkbMaxKeyCount))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstKeyExplicit = first;
+ req->nKeyExplicit = num;
+ if ((xkb!=NULL) && (xkb->server!=NULL) && (xkb->server->explicit!=NULL)) {
+ if ((num>0)&&(first>=xkb->min_key_code)&&(first+num<=xkb->max_key_code))
+ bzero(&xkb->server->explicit[first],num);
+ }
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+XkbGetKeyModifierMap(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ if ((num<1)||(num>XkbMaxKeyCount))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstModMapKey = first;
+ req->nModMapKeys = num;
+ if ((xkb!=NULL) && (xkb->map!=NULL) && (xkb->map->modmap!=NULL)) {
+ if ((num>0)&&(first>=xkb->min_key_code)&&(first+num<=xkb->max_key_code))
+ bzero(&xkb->map->modmap[first],num);
+ }
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+XkbGetKeyVirtualModMap(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ if ((num<1)||(num>XkbMaxKeyCount))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstVModMapKey = first;
+ req->nVModMapKeys = num;
+ if ((xkb!=NULL) && (xkb->map!=NULL) && (xkb->map->modmap!=NULL)) {
+ if ((num>0)&&(first>=xkb->min_key_code)&&(first+num<=xkb->max_key_code))
+ bzero(&xkb->server->vmodmap[first],num*sizeof(unsigned short));
+ }
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+XkbGetMapChanges(Display *dpy,XkbDescPtr xkb,XkbMapChangesPtr changes)
+{
+ xkbGetMapReq *req;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ LockDisplay(dpy);
+ if (changes->changed) {
+ Status status= Success;
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->full = 0;
+ req->partial = changes->changed;
+ req->firstType = changes->first_type;
+ req->nTypes = changes->num_types;
+ req->firstKeySym = changes->first_key_sym;
+ req->nKeySyms = changes->num_key_syms;
+ req->firstKeyAct = changes->first_key_act;
+ req->nKeyActs = changes->num_key_acts;
+ req->firstKeyBehavior = changes->first_key_behavior;
+ req->nKeyBehaviors = changes->num_key_behaviors;
+ req->virtualMods = changes->vmods;
+ req->firstKeyExplicit = changes->first_key_explicit;
+ req->nKeyExplicit = changes->num_key_explicit;
+ req->firstModMapKey = changes->first_modmap_key;
+ req->nModMapKeys = changes->num_modmap_keys;
+ req->firstVModMapKey = changes->first_vmodmap_key;
+ req->nVModMapKeys = changes->num_vmodmap_keys;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+ SyncHandle();
+ UnlockDisplay(dpy);
+ return status;
+ }
+ UnlockDisplay(dpy);
+ return Success;
+}
+
diff --git a/nx-X11/lib/X11/XKBList.c b/nx-X11/lib/X11/XKBList.c
new file mode 100644
index 000000000..2f4a53490
--- /dev/null
+++ b/nx-X11/lib/X11/XKBList.c
@@ -0,0 +1,251 @@
+/* $Xorg: XKBList.c,v 1.3 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86$ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#define NEED_MAP_READERS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+/***====================================================================***/
+
+static void
+_FreeComponentNames(int num,XkbComponentNamePtr names)
+{
+int i;
+XkbComponentNamePtr tmp;
+
+ if ((num<1)||(names==NULL))
+ return;
+ for (i=0,tmp=names;i<num;i++,tmp++) {
+ if (tmp->name) {
+ _XkbFree(tmp->name);
+ tmp->name= NULL;
+ }
+ }
+ _XkbFree(names);
+ return;
+}
+
+/***====================================================================***/
+
+static XkbComponentNamePtr
+_ReadListing(XkbReadBufferPtr buf,int count,Status *status_rtrn)
+{
+XkbComponentNamePtr first,this;
+register int i;
+CARD16 * flags;
+int slen,wlen;
+char * str;
+
+ if (count<1)
+ return NULL;
+ first= _XkbTypedCalloc(count,XkbComponentNameRec);
+ if (!first)
+ return NULL;
+ for (this=first,i=0;i<count;i++,this++) {
+ flags= (CARD16 *)_XkbGetReadBufferPtr(buf,2*sizeof(CARD16));
+ if (!flags)
+ goto BAILOUT;
+ this->flags= flags[0];
+ slen= flags[1];
+ wlen= ((slen+1)/2)*2; /* pad to 2 byte boundary */
+ this->name= _XkbTypedCalloc(slen+1,char);
+ if (!this->name)
+ goto BAILOUT;
+ str= (char *)_XkbGetReadBufferPtr(buf,wlen);
+ memcpy(this->name,str,slen);
+ }
+ return first;
+BAILOUT:
+ *status_rtrn= BadAlloc;
+ _FreeComponentNames(i,first);
+ return NULL;
+}
+
+/***====================================================================***/
+
+XkbComponentListPtr
+XkbListComponents( Display * dpy,
+ unsigned deviceSpec,
+ XkbComponentNamesPtr ptrns,
+ int * max_inout)
+{
+register xkbListComponentsReq* req;
+xkbListComponentsReply rep;
+XkbInfoPtr xkbi;
+XkbComponentListPtr list;
+XkbReadBufferRec buf;
+int left;
+char * str;
+int extraLen,len,mapLen,codesLen,typesLen,compatLen,symsLen,geomLen;
+
+ if ( (dpy==NULL) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) ||
+ (ptrns==NULL) || (max_inout==NULL))
+ return NULL;
+
+ xkbi= dpy->xkb_info;
+ LockDisplay(dpy);
+ GetReq(kbListComponents, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbListComponents;
+ req->deviceSpec = deviceSpec;
+ req->maxNames = *max_inout;
+
+ mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0;
+ if (ptrns->keymap)
+ mapLen= (int)strlen(ptrns->keymap);
+ if (ptrns->keycodes)
+ codesLen= (int)strlen(ptrns->keycodes);
+ if (ptrns->types)
+ typesLen= (int)strlen(ptrns->types);
+ if (ptrns->compat)
+ compatLen= (int)strlen(ptrns->compat);
+ if (ptrns->symbols)
+ symsLen= (int)strlen(ptrns->symbols);
+ if (ptrns->geometry)
+ geomLen= (int)strlen(ptrns->geometry);
+ if (mapLen>255) mapLen= 255;
+ if (codesLen>255) codesLen= 255;
+ if (typesLen>255) typesLen= 255;
+ if (compatLen>255) compatLen= 255;
+ if (symsLen>255) symsLen= 255;
+ if (geomLen>255) geomLen= 255;
+
+ len= mapLen+codesLen+typesLen+compatLen+symsLen+geomLen+6;
+ len= XkbPaddedSize(len);
+ req->length+= len/4;
+ BufAlloc(char *,str,len);
+ *str++= mapLen;
+ if (mapLen>0) {
+ memcpy(str,ptrns->keymap,mapLen);
+ str+= mapLen;
+ }
+ *str++= codesLen;
+ if (codesLen>0) {
+ memcpy(str,ptrns->keycodes,codesLen);
+ str+= codesLen;
+ }
+ *str++= typesLen;
+ if (typesLen>0) {
+ memcpy(str,ptrns->types,typesLen);
+ str+= typesLen;
+ }
+ *str++= compatLen;
+ if (compatLen>0) {
+ memcpy(str,ptrns->compat,compatLen);
+ str+= compatLen;
+ }
+ *str++= symsLen;
+ if (symsLen>0) {
+ memcpy(str,ptrns->symbols,symsLen);
+ str+= symsLen;
+ }
+ *str++= geomLen;
+ if (geomLen>0) {
+ memcpy(str,ptrns->geometry,geomLen);
+ str+= geomLen;
+ }
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
+ goto BAILOUT;
+ extraLen= (int)rep.length*4;
+ *max_inout= rep.extra;
+ if (extraLen==0) { /* no matches, but we don't want to report a failure */
+ list= _XkbTypedCalloc(1,XkbComponentListRec);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return list;
+ }
+ if (_XkbInitReadBuffer(dpy,&buf,extraLen)) {
+ Status status;
+
+ status= Success;
+ list= _XkbTypedCalloc(1,XkbComponentListRec);
+ if (!list) {
+ _XkbFreeReadBuffer(&buf);
+ goto BAILOUT;
+ }
+ list->num_keymaps= rep.nKeymaps;
+ list->num_keycodes= rep.nKeycodes;
+ list->num_types= rep.nTypes;
+ list->num_compat= rep.nCompatMaps;
+ list->num_symbols= rep.nSymbols;
+ list->num_geometry= rep.nGeometries;
+ if ((status==Success)&&(list->num_keymaps>0))
+ list->keymaps= _ReadListing(&buf,list->num_keymaps,&status);
+ if ((status==Success)&&(list->num_keycodes>0))
+ list->keycodes= _ReadListing(&buf,list->num_keycodes,&status);
+ if ((status==Success)&&(list->num_types>0))
+ list->types= _ReadListing(&buf,list->num_types,&status);
+ if ((status==Success)&&(list->num_compat>0))
+ list->compat= _ReadListing(&buf,list->num_compat,&status);
+ if ((status==Success)&&(list->num_symbols>0))
+ list->symbols= _ReadListing(&buf,list->num_symbols,&status);
+ if ((status==Success)&&(list->num_geometry>0))
+ list->geometry= _ReadListing(&buf,list->num_geometry,&status);
+ left= _XkbFreeReadBuffer(&buf);
+ if ((status!=Success)||(buf.error)||(left>2)) {
+ XkbFreeComponentList(list);
+ goto BAILOUT;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return list;
+ }
+BAILOUT:
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+}
+
+void
+XkbFreeComponentList(XkbComponentListPtr list)
+{
+ if (list) {
+ if (list->keymaps)
+ _FreeComponentNames(list->num_keymaps,list->keymaps);
+ if (list->keycodes)
+ _FreeComponentNames(list->num_keycodes,list->keycodes);
+ if (list->types)
+ _FreeComponentNames(list->num_types,list->types);
+ if (list->compat)
+ _FreeComponentNames(list->num_compat,list->compat);
+ if (list->symbols)
+ _FreeComponentNames(list->num_symbols,list->symbols);
+ if (list->geometry)
+ _FreeComponentNames(list->num_geometry,list->geometry);
+ bzero((char *)list,sizeof(XkbComponentListRec));
+ _XkbFree(list);
+ }
+ return;
+}
diff --git a/nx-X11/lib/X11/XKBMAlloc.c b/nx-X11/lib/X11/XKBMAlloc.c
new file mode 100644
index 000000000..d57d9a58d
--- /dev/null
+++ b/nx-X11/lib/X11/XKBMAlloc.c
@@ -0,0 +1,1023 @@
+/* $Xorg: XKBMAlloc.c,v 1.4 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBMAlloc.c,v 3.11 2001/01/17 19:41:48 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#elif defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#ifndef XKB_IN_SERVER
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include <X11/keysym.h>
+#include "XKBlibint.h"
+
+#else
+
+#include <stdio.h>
+#include <X11/X.h>
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include <X11/keysym.h>
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+
+#endif /* XKB_IN_SERVER */
+
+/***====================================================================***/
+
+Status
+XkbAllocClientMap(XkbDescPtr xkb,unsigned which,unsigned nTotalTypes)
+{
+register int i;
+XkbClientMapPtr map;
+
+ if ((xkb==NULL)||((nTotalTypes>0)&&(nTotalTypes<XkbNumRequiredTypes)))
+ return BadValue;
+ if ((which&XkbKeySymsMask)&&
+ ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))) {
+#ifdef DEBUG
+fprintf(stderr,"bad keycode (%d,%d) in XkbAllocClientMap\n",
+ xkb->min_key_code,xkb->max_key_code);
+#endif
+ return BadValue;
+ }
+
+ if (xkb->map==NULL) {
+ map= _XkbTypedCalloc(1,XkbClientMapRec);
+ if (map==NULL)
+ return BadAlloc;
+ xkb->map= map;
+ }
+ else map= xkb->map;
+
+ if ((which&XkbKeyTypesMask)&&(nTotalTypes>0)) {
+ if (map->types==NULL) {
+ map->types= _XkbTypedCalloc(nTotalTypes,XkbKeyTypeRec);
+ if (map->types==NULL)
+ return BadAlloc;
+ map->num_types= 0;
+ map->size_types= nTotalTypes;
+ }
+ else if (map->size_types<nTotalTypes) {
+ XkbKeyTypeRec *prev_types = map->types;
+
+ map->types= _XkbTypedRealloc(map->types,nTotalTypes,XkbKeyTypeRec);
+ if (map->types==NULL) {
+ _XkbFree(prev_types);
+ map->num_types= map->size_types= 0;
+ return BadAlloc;
+ }
+ map->size_types= nTotalTypes;
+ bzero(&map->types[map->num_types],
+ ((map->size_types-map->num_types)*sizeof(XkbKeyTypeRec)));
+ }
+ }
+ if (which&XkbKeySymsMask) {
+ int nKeys= XkbNumKeys(xkb);
+ if (map->syms==NULL) {
+ map->size_syms= (nKeys*15)/10;
+ map->syms= _XkbTypedCalloc(map->size_syms,KeySym);
+ if (!map->syms) {
+ map->size_syms= 0;
+ return BadAlloc;
+ }
+ map->num_syms= 1;
+ map->syms[0]= NoSymbol;
+ }
+ if (map->key_sym_map==NULL) {
+ i= xkb->max_key_code+1;
+ map->key_sym_map= _XkbTypedCalloc(i,XkbSymMapRec);
+ if (map->key_sym_map==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbModifierMapMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->modmap==NULL) {
+ i= xkb->max_key_code+1;
+ map->modmap= _XkbTypedCalloc(i,unsigned char);
+ if (map->modmap==NULL)
+ return BadAlloc;
+ }
+ }
+ return Success;
+}
+
+Status
+XkbAllocServerMap(XkbDescPtr xkb,unsigned which,unsigned nNewActions)
+{
+register int i;
+XkbServerMapPtr map;
+
+ if (xkb==NULL)
+ return BadMatch;
+ if (xkb->server==NULL) {
+ map= _XkbTypedCalloc(1,XkbServerMapRec);
+ if (map==NULL)
+ return BadAlloc;
+ for (i=0;i<XkbNumVirtualMods;i++) {
+ map->vmods[i]= XkbNoModifierMask;
+ }
+ xkb->server= map;
+ }
+ else map= xkb->server;
+ if (which&XkbExplicitComponentsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->explicit==NULL) {
+ i= xkb->max_key_code+1;
+ map->explicit= _XkbTypedCalloc(i,unsigned char);
+ if (map->explicit==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbKeyActionsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (nNewActions<1)
+ nNewActions= 1;
+ if (map->acts==NULL) {
+ map->acts= _XkbTypedCalloc((nNewActions+1),XkbAction);
+ if (map->acts==NULL)
+ return BadAlloc;
+ map->num_acts= 1;
+ map->size_acts= nNewActions+1;
+ }
+ else if ((map->size_acts-map->num_acts)<nNewActions) {
+ unsigned need;
+ XkbAction *prev_acts = map->acts;
+ need= map->num_acts+nNewActions;
+ map->acts= _XkbTypedRealloc(map->acts,need,XkbAction);
+ if (map->acts==NULL) {
+ _XkbFree(prev_acts);
+ map->num_acts= map->size_acts= 0;
+ return BadAlloc;
+ }
+ map->size_acts= need;
+ bzero(&map->acts[map->num_acts],
+ ((map->size_acts-map->num_acts)*sizeof(XkbAction)));
+ }
+ if (map->key_acts==NULL) {
+ i= xkb->max_key_code+1;
+ map->key_acts= _XkbTypedCalloc(i,unsigned short);
+ if (map->key_acts==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbKeyBehaviorsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->behaviors==NULL) {
+ i= xkb->max_key_code+1;
+ map->behaviors= _XkbTypedCalloc(i,XkbBehavior);
+ if (map->behaviors==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbVirtualModMapMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->vmodmap==NULL) {
+ i= xkb->max_key_code+1;
+ map->vmodmap= _XkbTypedCalloc(i,unsigned short);
+ if (map->vmodmap==NULL)
+ return BadAlloc;
+ }
+ }
+ return Success;
+}
+
+/***====================================================================***/
+
+Status
+XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into)
+{
+ if ((!from)||(!into))
+ return BadMatch;
+ if (into->map) {
+ _XkbFree(into->map);
+ into->map= NULL;
+ }
+ if (into->preserve) {
+ _XkbFree(into->preserve);
+ into->preserve= NULL;
+ }
+ if (into->level_names) {
+ _XkbFree(into->level_names);
+ into->level_names= NULL;
+ }
+ *into= *from;
+ if ((from->map)&&(into->map_count>0)) {
+ into->map= _XkbTypedCalloc(into->map_count,XkbKTMapEntryRec);
+ if (!into->map)
+ return BadAlloc;
+ memcpy(into->map,from->map,into->map_count*sizeof(XkbKTMapEntryRec));
+ }
+ if ((from->preserve)&&(into->map_count>0)) {
+ into->preserve= _XkbTypedCalloc(into->map_count,XkbModsRec);
+ if (!into->preserve)
+ return BadAlloc;
+ memcpy(into->preserve,from->preserve,
+ into->map_count*sizeof(XkbModsRec));
+ }
+ if ((from->level_names)&&(into->num_levels>0)) {
+ into->level_names= _XkbTypedCalloc(into->num_levels,Atom);
+ if (!into->level_names)
+ return BadAlloc;
+ memcpy(into->level_names,from->level_names,
+ into->num_levels*sizeof(Atom));
+ }
+ return Success;
+}
+
+Status
+XkbCopyKeyTypes(XkbKeyTypePtr from,XkbKeyTypePtr into,int num_types)
+{
+register int i,rtrn;
+
+ if ((!from)||(!into)||(num_types<0))
+ return BadMatch;
+ for (i=0;i<num_types;i++) {
+ if ((rtrn= XkbCopyKeyType(from++,into++))!=Success)
+ return rtrn;
+ }
+ return Success;
+}
+
+XkbKeyTypePtr
+XkbAddKeyType( XkbDescPtr xkb,
+ Atom name,
+ int map_count,
+ Bool want_preserve,
+ int num_lvls)
+{
+register int i;
+unsigned tmp;
+XkbKeyTypePtr type;
+XkbClientMapPtr map;
+
+ if ((!xkb)||(num_lvls<1))
+ return NULL;
+ map= xkb->map;
+ if ((map)&&(map->types)) {
+ for (i=0;i<map->num_types;i++) {
+ if (map->types[i].name==name) {
+ Status status;
+ status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls);
+ return (status==Success?&map->types[i]:NULL);
+ }
+ }
+ }
+ if ((!map)||(!map->types)||(!map->num_types<XkbNumRequiredTypes)) {
+ tmp= XkbNumRequiredTypes+1;
+ if (XkbAllocClientMap(xkb,XkbKeyTypesMask,tmp)!=Success)
+ return NULL;
+ tmp= 0;
+ if (map->num_types<=XkbKeypadIndex)
+ tmp|= XkbKeypadMask;
+ if (map->num_types<=XkbAlphabeticIndex)
+ tmp|= XkbAlphabeticMask;
+ if (map->num_types<=XkbTwoLevelIndex)
+ tmp|= XkbTwoLevelMask;
+ if (map->num_types<=XkbOneLevelIndex)
+ tmp|= XkbOneLevelMask;
+ if (XkbInitCanonicalKeyTypes(xkb,tmp,XkbNoModifier)==Success) {
+ for (i=0;i<map->num_types;i++) {
+ Status status;
+ if (map->types[i].name!=name)
+ continue;
+ status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls);
+ return (status==Success?&map->types[i]:NULL);
+ }
+ }
+ }
+ if ((map->num_types<=map->size_types)&&
+ (XkbAllocClientMap(xkb,XkbKeyTypesMask,map->num_types+1)!=Success)) {
+ return NULL;
+ }
+ type= &map->types[map->num_types];
+ map->num_types++;
+ bzero((char *)type,sizeof(XkbKeyTypeRec));
+ type->num_levels= num_lvls;
+ type->map_count= map_count;
+ type->name= name;
+ if (map_count>0) {
+ type->map= _XkbTypedCalloc(map_count,XkbKTMapEntryRec);
+ if (!type->map) {
+ map->num_types--;
+ return NULL;
+ }
+ if (want_preserve) {
+ type->preserve= _XkbTypedCalloc(map_count,XkbModsRec);
+ if (!type->preserve) {
+ _XkbFree(type->map);
+ map->num_types--;
+ return NULL;
+ }
+ }
+ }
+ return type;
+}
+
+Status
+XkbResizeKeyType( XkbDescPtr xkb,
+ int type_ndx,
+ int map_count,
+ Bool want_preserve,
+ int new_num_lvls)
+{
+XkbKeyTypePtr type;
+KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
+
+ if ((type_ndx<0)||(type_ndx>=xkb->map->num_types)||(map_count<0)||
+ (new_num_lvls<1))
+ return BadValue;
+ switch (type_ndx) {
+ case XkbOneLevelIndex:
+ if (new_num_lvls!=1)
+ return BadMatch;
+ break;
+ case XkbTwoLevelIndex:
+ case XkbAlphabeticIndex:
+ case XkbKeypadIndex:
+ if (new_num_lvls!=2)
+ return BadMatch;
+ break;
+ }
+ type= &xkb->map->types[type_ndx];
+ if (map_count==0) {
+ if (type->map!=NULL)
+ _XkbFree(type->map);
+ type->map= NULL;
+ if (type->preserve!=NULL)
+ _XkbFree(type->preserve);
+ type->preserve= NULL;
+ type->map_count= 0;
+ }
+ else {
+ XkbKTMapEntryRec *prev_map = type->map;
+
+ if ((map_count>type->map_count)||(type->map==NULL))
+ type->map=_XkbTypedRealloc(type->map,map_count,XkbKTMapEntryRec);
+ if (!type->map) {
+ if (prev_map)
+ _XkbFree(prev_map);
+ return BadAlloc;
+ }
+ if (want_preserve) {
+ XkbModsRec *prev_preserve = type->preserve;
+
+ if ((map_count>type->map_count)||(type->preserve==NULL)) {
+ type->preserve= _XkbTypedRealloc(type->preserve,map_count,
+ XkbModsRec);
+ }
+ if (!type->preserve) {
+ if (prev_preserve)
+ _XkbFree(prev_preserve);
+ return BadAlloc;
+ }
+ }
+ else if (type->preserve!=NULL) {
+ _XkbFree(type->preserve);
+ type->preserve= NULL;
+ }
+ type->map_count= map_count;
+ }
+
+ if ((new_num_lvls>type->num_levels)||(type->level_names==NULL)) {
+ Atom * prev_level_names = type->level_names;
+
+ type->level_names=_XkbTypedRealloc(type->level_names,new_num_lvls,Atom);
+ if (!type->level_names) {
+ if (prev_level_names)
+ _XkbFree(prev_level_names);
+ return BadAlloc;
+ }
+ }
+ /*
+ * Here's the theory:
+ * If the width of the type changed, we might have to resize the symbol
+ * maps for any keys that use the type for one or more groups. This is
+ * expensive, so we'll try to cull out any keys that are obviously okay:
+ * In any case:
+ * - keys that have a group width <= the old width are okay (because
+ * they could not possibly have been associated with the old type)
+ * If the key type increased in size:
+ * - keys that already have a group width >= to the new width are okay
+ * + keys that have a group width >= the old width but < the new width
+ * might have to be enlarged.
+ * If the key type decreased in size:
+ * - keys that have a group width > the old width don't have to be
+ * resized (because they must have some other wider type associated
+ * with some group).
+ * + keys that have a group width == the old width might have to be
+ * shrunk.
+ * The possibilities marked with '+' require us to examine the key types
+ * associated with each group for the key.
+ */
+ bzero(matchingKeys,XkbMaxKeyCount*sizeof(KeyCode));
+ nMatchingKeys= 0;
+ if (new_num_lvls>type->num_levels) {
+ int nTotal;
+ KeySym * newSyms;
+ int width,match,nResize;
+ register int i,g,nSyms;
+
+ nResize= 0;
+ for (nTotal=1,i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ width= XkbKeyGroupsWidth(xkb,i);
+ if (width<type->num_levels)
+ continue;
+ for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) {
+ if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) {
+ matchingKeys[nMatchingKeys++]= i;
+ match= 1;
+ }
+ }
+ if ((!match)||(width>=new_num_lvls))
+ nTotal+= XkbKeyNumSyms(xkb,i);
+ else {
+ nTotal+= XkbKeyNumGroups(xkb,i)*new_num_lvls;
+ nResize++;
+ }
+ }
+ if (nResize>0) {
+ int nextMatch;
+ xkb->map->size_syms= (nTotal*12)/10;
+ newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
+ if (newSyms==NULL)
+ return BadAlloc;
+ nextMatch= 0;
+ nSyms= 1;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ if (matchingKeys[nextMatch]==i) {
+ KeySym *pOld;
+ nextMatch++;
+ width= XkbKeyGroupsWidth(xkb,i);
+ pOld= XkbKeySymsPtr(xkb,i);
+ for (g=XkbKeyNumGroups(xkb,i)-1;g>=0;g--) {
+ memcpy(&newSyms[nSyms+(new_num_lvls*g)],&pOld[width*g],
+ width*sizeof(KeySym));
+ }
+ xkb->map->key_sym_map[i].offset= nSyms;
+ nSyms+= XkbKeyNumGroups(xkb,i)*new_num_lvls;
+ }
+ else {
+ memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),
+ XkbKeyNumSyms(xkb,i)*sizeof(KeySym));
+ xkb->map->key_sym_map[i].offset= nSyms;
+ nSyms+= XkbKeyNumSyms(xkb,i);
+ }
+ }
+ type->num_levels= new_num_lvls;
+ _XkbFree(xkb->map->syms);
+ xkb->map->syms= newSyms;
+ xkb->map->num_syms= nSyms;
+ return Success;
+ }
+ }
+ else if (new_num_lvls<type->num_levels) {
+ int width,match;
+ register int g,i;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ width= XkbKeyGroupsWidth(xkb,i);
+ if (width<type->num_levels)
+ continue;
+ for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) {
+ if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) {
+ matchingKeys[nMatchingKeys++]= i;
+ match= 1;
+ }
+ }
+ }
+ }
+ if (nMatchingKeys>0) {
+ int key,firstClear;
+ register int i,g;
+ if (new_num_lvls>type->num_levels)
+ firstClear= type->num_levels;
+ else firstClear= new_num_lvls;
+ for (i=0;i<nMatchingKeys;i++) {
+ KeySym * pSyms;
+ int width,nClear;
+
+ key= matchingKeys[i];
+ width= XkbKeyGroupsWidth(xkb,key);
+ nClear= width-firstClear;
+ pSyms= XkbKeySymsPtr(xkb,key);
+ for (g=XkbKeyNumGroups(xkb,key)-1;g>=0;g--) {
+ if (XkbKeyKeyTypeIndex(xkb,key,g)==type_ndx) {
+ if (nClear>0)
+ bzero(&pSyms[g*width+firstClear],nClear*sizeof(KeySym));
+ }
+ }
+ }
+ }
+ type->num_levels= new_num_lvls;
+ return Success;
+}
+
+KeySym *
+XkbResizeKeySyms(XkbDescPtr xkb,int key,int needed)
+{
+register int i,nSyms,nKeySyms;
+unsigned nOldSyms;
+KeySym *newSyms;
+
+ if (needed==0) {
+ xkb->map->key_sym_map[key].offset= 0;
+ return xkb->map->syms;
+ }
+ nOldSyms= XkbKeyNumSyms(xkb,key);
+ if (nOldSyms>=(unsigned)needed) {
+ return XkbKeySymsPtr(xkb,key);
+ }
+ if (xkb->map->size_syms-xkb->map->num_syms>=(unsigned)needed) {
+ if (nOldSyms>0) {
+ memcpy(&xkb->map->syms[xkb->map->num_syms],XkbKeySymsPtr(xkb,key),
+ nOldSyms*sizeof(KeySym));
+ }
+ if ((needed-nOldSyms)>0) {
+ bzero(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb,key)],
+ (needed-nOldSyms)*sizeof(KeySym));
+ }
+ xkb->map->key_sym_map[key].offset = xkb->map->num_syms;
+ xkb->map->num_syms+= needed;
+ return &xkb->map->syms[xkb->map->key_sym_map[key].offset];
+ }
+ xkb->map->size_syms+= (needed>32?needed:32);
+ newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
+ if (newSyms==NULL)
+ return NULL;
+ newSyms[0]= NoSymbol;
+ nSyms = 1;
+ for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
+ int nCopy;
+
+ nCopy= nKeySyms= XkbKeyNumSyms(xkb,i);
+ if ((nKeySyms==0)&&(i!=key))
+ continue;
+ if (i==key)
+ nKeySyms= needed;
+ if (nCopy!=0)
+ memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),nCopy*sizeof(KeySym));
+ if (nKeySyms>nCopy)
+ bzero(&newSyms[nSyms+nCopy],(nKeySyms-nCopy)*sizeof(KeySym));
+ xkb->map->key_sym_map[i].offset = nSyms;
+ nSyms+= nKeySyms;
+ }
+ _XkbFree(xkb->map->syms);
+ xkb->map->syms = newSyms;
+ xkb->map->num_syms = nSyms;
+ return &xkb->map->syms[xkb->map->key_sym_map[key].offset];
+}
+
+static unsigned
+_ExtendRange( unsigned int old_flags,
+ unsigned int flag,
+ KeyCode newKC,
+ KeyCode * old_min,
+ unsigned char * old_num)
+{
+ if ((old_flags&flag)==0) {
+ old_flags|= flag;
+ *old_min= newKC;
+ *old_num= 1;
+ }
+ else {
+ int last= (*old_min)+(*old_num)-1;
+ if (newKC<*old_min) {
+ *old_min= newKC;
+ *old_num= (last-newKC)+1;
+ }
+ else if (newKC>last) {
+ *old_num= (newKC-(*old_min))+1;
+ }
+ }
+ return old_flags;
+}
+
+Status
+XkbChangeKeycodeRange( XkbDescPtr xkb,
+ int minKC,
+ int maxKC,
+ XkbChangesPtr changes)
+{
+int tmp;
+
+ if ((!xkb)||(minKC<XkbMinLegalKeyCode)||(maxKC>XkbMaxLegalKeyCode))
+ return BadValue;
+ if (minKC>maxKC)
+ return BadMatch;
+ if (minKC<xkb->min_key_code) {
+ if (changes)
+ changes->map.min_key_code= minKC;
+ tmp= xkb->min_key_code-minKC;
+ if (xkb->map) {
+ if (xkb->map->key_sym_map) {
+ bzero((char *)&xkb->map->key_sym_map[minKC],
+ tmp*sizeof(XkbSymMapRec));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeySymsMask,minKC,
+ &changes->map.first_key_sym,
+ &changes->map.num_key_syms);
+ }
+ }
+ if (xkb->map->modmap) {
+ bzero((char *)&xkb->map->modmap[minKC],tmp);
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbModifierMapMask,minKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_modmap_keys);
+ }
+ }
+ }
+ if (xkb->server) {
+ if (xkb->server->behaviors) {
+ bzero((char *)&xkb->server->behaviors[minKC],
+ tmp*sizeof(XkbBehavior));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyBehaviorsMask,minKC,
+ &changes->map.first_key_behavior,
+ &changes->map.num_key_behaviors);
+ }
+ }
+ if (xkb->server->key_acts) {
+ bzero((char *)&xkb->server->key_acts[minKC],
+ tmp*sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyActionsMask,minKC,
+ &changes->map.first_key_act,
+ &changes->map.num_key_acts);
+ }
+ }
+ if (xkb->server->vmodmap) {
+ bzero((char *)&xkb->server->vmodmap[minKC],
+ tmp*sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbVirtualModMapMask,minKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_vmodmap_keys);
+ }
+ }
+ }
+ if ((xkb->names)&&(xkb->names->keys)) {
+ bzero((char *)&xkb->names->keys[minKC],tmp*sizeof(XkbKeyNameRec));
+ if (changes) {
+ changes->names.changed= _ExtendRange(changes->names.changed,
+ XkbKeyNamesMask,minKC,
+ &changes->names.first_key,
+ &changes->names.num_keys);
+ }
+ }
+ xkb->min_key_code= minKC;
+ }
+ if (maxKC>xkb->max_key_code) {
+ if (changes)
+ changes->map.max_key_code= maxKC;
+ tmp= maxKC-xkb->max_key_code;
+ if (xkb->map) {
+ if (xkb->map->key_sym_map) {
+ XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map;
+
+ xkb->map->key_sym_map= _XkbTypedRealloc(xkb->map->key_sym_map,
+ (maxKC+1),XkbSymMapRec);
+ if (!xkb->map->key_sym_map) {
+ _XkbFree(prev_key_sym_map);
+ return BadAlloc;
+ }
+#ifdef NXAGENT_SERVER
+ bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code+1],
+ tmp*sizeof(XkbSymMapRec));
+#else
+ bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code],
+ tmp*sizeof(XkbSymMapRec));
+#endif
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeySymsMask,maxKC,
+ &changes->map.first_key_sym,
+ &changes->map.num_key_syms);
+ }
+ }
+ if (xkb->map->modmap) {
+ unsigned char *prev_modmap = xkb->map->modmap;
+
+ xkb->map->modmap= _XkbTypedRealloc(xkb->map->modmap,
+ (maxKC+1),unsigned char);
+ if (!xkb->map->modmap) {
+ _XkbFree(prev_modmap);
+ return BadAlloc;
+ }
+#ifdef NXAGENT_SERVER
+ bzero((char *)&xkb->map->modmap[xkb->max_key_code+1],tmp);
+#else
+ bzero((char *)&xkb->map->modmap[xkb->max_key_code],tmp);
+#endif
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbModifierMapMask,maxKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_modmap_keys);
+ }
+ }
+ }
+ if (xkb->server) {
+ if (xkb->server->behaviors) {
+ XkbBehavior *prev_behaviors = xkb->server->behaviors;
+
+ xkb->server->behaviors=_XkbTypedRealloc(xkb->server->behaviors,
+ (maxKC+1),XkbBehavior);
+ if (!xkb->server->behaviors) {
+ _XkbFree(prev_behaviors);
+ return BadAlloc;
+ }
+#ifdef NXAGENT_SERVER
+ bzero((char *)&xkb->server->behaviors[xkb->max_key_code+1],
+ tmp*sizeof(XkbBehavior));
+#else
+ bzero((char *)&xkb->server->behaviors[xkb->max_key_code],
+ tmp*sizeof(XkbBehavior));
+#endif
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyBehaviorsMask,maxKC,
+ &changes->map.first_key_behavior,
+ &changes->map.num_key_behaviors);
+ }
+ }
+ if (xkb->server->key_acts) {
+ unsigned short *prev_key_acts = xkb->server->key_acts;
+
+ xkb->server->key_acts= _XkbTypedRealloc(xkb->server->key_acts,
+ (maxKC+1),unsigned short);
+ if (!xkb->server->key_acts) {
+ _XkbFree(prev_key_acts);
+ return BadAlloc;
+ }
+#ifdef NXAGENT_SERVER
+ bzero((char *)&xkb->server->key_acts[xkb->max_key_code+1],
+ tmp*sizeof(unsigned short));
+#else
+ bzero((char *)&xkb->server->key_acts[xkb->max_key_code],
+ tmp*sizeof(unsigned short));
+#endif
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyActionsMask,maxKC,
+ &changes->map.first_key_act,
+ &changes->map.num_key_acts);
+ }
+ }
+ if (xkb->server->vmodmap) {
+ unsigned short *prev_vmodmap = xkb->server->vmodmap;
+
+ xkb->server->vmodmap= _XkbTypedRealloc(xkb->server->vmodmap,
+ (maxKC+1),unsigned short);
+ if (!xkb->server->vmodmap) {
+ _XkbFree(prev_vmodmap);
+ return BadAlloc;
+ }
+#ifdef NXAGENT_SERVER
+ bzero((char *)&xkb->server->vmodmap[xkb->max_key_code+1],
+ tmp*sizeof(unsigned short));
+#else
+ bzero((char *)&xkb->server->vmodmap[xkb->max_key_code],
+ tmp*sizeof(unsigned short));
+#endif
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbVirtualModMapMask,maxKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_vmodmap_keys);
+ }
+ }
+ }
+ if ((xkb->names)&&(xkb->names->keys)) {
+ XkbKeyNameRec *prev_keys = xkb->names->keys;
+
+ xkb->names->keys= _XkbTypedRealloc(xkb->names->keys,
+ (maxKC+1),XkbKeyNameRec);
+ if (!xkb->names->keys) {
+ _XkbFree(prev_keys);
+ return BadAlloc;
+ }
+#ifdef NXAGENT_SERVER
+ bzero((char *)&xkb->names->keys[xkb->max_key_code+1],
+ tmp*sizeof(XkbKeyNameRec));
+#else
+ bzero((char *)&xkb->names->keys[xkb->max_key_code],
+ tmp*sizeof(XkbKeyNameRec));
+#endif
+ if (changes) {
+ changes->names.changed= _ExtendRange(changes->names.changed,
+ XkbKeyNamesMask,maxKC,
+ &changes->names.first_key,
+ &changes->names.num_keys);
+ }
+ }
+ xkb->max_key_code= maxKC;
+ }
+ return Success;
+}
+
+XkbAction *
+XkbResizeKeyActions(XkbDescPtr xkb,int key,int needed)
+{
+register int i,nActs;
+XkbAction *newActs;
+
+ if (needed==0) {
+ xkb->server->key_acts[key]= 0;
+ return NULL;
+ }
+ if (XkbKeyHasActions(xkb,key)&&(XkbKeyNumSyms(xkb,key)>=(unsigned)needed))
+ return XkbKeyActionsPtr(xkb,key);
+ if (xkb->server->size_acts-xkb->server->num_acts>=(unsigned)needed) {
+ xkb->server->key_acts[key]= xkb->server->num_acts;
+ xkb->server->num_acts+= needed;
+ return &xkb->server->acts[xkb->server->key_acts[key]];
+ }
+ xkb->server->size_acts= xkb->server->num_acts+needed+8;
+ newActs = _XkbTypedCalloc(xkb->server->size_acts,XkbAction);
+ if (newActs==NULL)
+ return NULL;
+ newActs[0].type = XkbSA_NoAction;
+ nActs = 1;
+ for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
+ int nKeyActs,nCopy;
+
+ if ((xkb->server->key_acts[i]==0)&&(i!=key))
+ continue;
+
+ nCopy= nKeyActs= XkbKeyNumActions(xkb,i);
+ if (i==key) {
+ nKeyActs= needed;
+ if (needed<nCopy)
+ nCopy= needed;
+ }
+
+ if (nCopy>0)
+ memcpy(&newActs[nActs],XkbKeyActionsPtr(xkb,i),
+ nCopy*sizeof(XkbAction));
+ if (nCopy<nKeyActs)
+ bzero(&newActs[nActs+nCopy],(nKeyActs-nCopy)*sizeof(XkbAction));
+ xkb->server->key_acts[i]= nActs;
+ nActs+= nKeyActs;
+ }
+ _XkbFree(xkb->server->acts);
+ xkb->server->acts = newActs;
+ xkb->server->num_acts= nActs;
+ return &xkb->server->acts[xkb->server->key_acts[key]];
+}
+
+void
+XkbFreeClientMap(XkbDescPtr xkb,unsigned what,Bool freeMap)
+{
+XkbClientMapPtr map;
+
+ if ((xkb==NULL)||(xkb->map==NULL))
+ return;
+ if (freeMap)
+ what= XkbAllClientInfoMask;
+ map= xkb->map;
+ if (what&XkbKeyTypesMask) {
+ if (map->types!=NULL) {
+ if (map->num_types>0) {
+ register int i;
+ XkbKeyTypePtr type;
+ for (i=0,type=map->types;i<map->num_types;i++,type++) {
+ if (type->map!=NULL) {
+ _XkbFree(type->map);
+ type->map= NULL;
+ }
+ if (type->preserve!=NULL) {
+ _XkbFree(type->preserve);
+ type->preserve= NULL;
+ }
+ type->map_count= 0;
+ if (type->level_names!=NULL) {
+ _XkbFree(type->level_names);
+ type->level_names= NULL;
+ }
+ }
+ }
+ _XkbFree(map->types);
+ map->num_types= map->size_types= 0;
+ map->types= NULL;
+ }
+ }
+ if (what&XkbKeySymsMask) {
+ if (map->key_sym_map!=NULL) {
+ _XkbFree(map->key_sym_map);
+ map->key_sym_map= NULL;
+ }
+ if (map->syms!=NULL) {
+ _XkbFree(map->syms);
+ map->size_syms= map->num_syms= 0;
+ map->syms= NULL;
+ }
+ }
+ if ((what&XkbModifierMapMask)&&(map->modmap!=NULL)) {
+ _XkbFree(map->modmap);
+ map->modmap= NULL;
+ }
+ if (freeMap) {
+ _XkbFree(xkb->map);
+ xkb->map= NULL;
+ }
+ return;
+}
+
+void
+XkbFreeServerMap(XkbDescPtr xkb,unsigned what,Bool freeMap)
+{
+XkbServerMapPtr map;
+
+ if ((xkb==NULL)||(xkb->server==NULL))
+ return;
+ if (freeMap)
+ what= XkbAllServerInfoMask;
+ map= xkb->server;
+ if ((what&XkbExplicitComponentsMask)&&(map->explicit!=NULL)) {
+ _XkbFree(map->explicit);
+ map->explicit= NULL;
+ }
+ if (what&XkbKeyActionsMask) {
+ if (map->key_acts!=NULL) {
+ _XkbFree(map->key_acts);
+ map->key_acts= NULL;
+ }
+ if (map->acts!=NULL) {
+ _XkbFree(map->acts);
+ map->num_acts= map->size_acts= 0;
+ map->acts= NULL;
+ }
+ }
+ if ((what&XkbKeyBehaviorsMask)&&(map->behaviors!=NULL)) {
+ _XkbFree(map->behaviors);
+ map->behaviors= NULL;
+ }
+ if ((what&XkbVirtualModMapMask)&&(map->vmodmap!=NULL)) {
+ _XkbFree(map->vmodmap);
+ map->vmodmap= NULL;
+ }
+
+ if (freeMap) {
+ _XkbFree(xkb->server);
+ xkb->server= NULL;
+ }
+ return;
+}
diff --git a/nx-X11/lib/X11/XKBMAlloc.c.NX.original b/nx-X11/lib/X11/XKBMAlloc.c.NX.original
new file mode 100644
index 000000000..d57d9a58d
--- /dev/null
+++ b/nx-X11/lib/X11/XKBMAlloc.c.NX.original
@@ -0,0 +1,1023 @@
+/* $Xorg: XKBMAlloc.c,v 1.4 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBMAlloc.c,v 3.11 2001/01/17 19:41:48 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#elif defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#ifndef XKB_IN_SERVER
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include <X11/keysym.h>
+#include "XKBlibint.h"
+
+#else
+
+#include <stdio.h>
+#include <X11/X.h>
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include <X11/keysym.h>
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+
+#endif /* XKB_IN_SERVER */
+
+/***====================================================================***/
+
+Status
+XkbAllocClientMap(XkbDescPtr xkb,unsigned which,unsigned nTotalTypes)
+{
+register int i;
+XkbClientMapPtr map;
+
+ if ((xkb==NULL)||((nTotalTypes>0)&&(nTotalTypes<XkbNumRequiredTypes)))
+ return BadValue;
+ if ((which&XkbKeySymsMask)&&
+ ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))) {
+#ifdef DEBUG
+fprintf(stderr,"bad keycode (%d,%d) in XkbAllocClientMap\n",
+ xkb->min_key_code,xkb->max_key_code);
+#endif
+ return BadValue;
+ }
+
+ if (xkb->map==NULL) {
+ map= _XkbTypedCalloc(1,XkbClientMapRec);
+ if (map==NULL)
+ return BadAlloc;
+ xkb->map= map;
+ }
+ else map= xkb->map;
+
+ if ((which&XkbKeyTypesMask)&&(nTotalTypes>0)) {
+ if (map->types==NULL) {
+ map->types= _XkbTypedCalloc(nTotalTypes,XkbKeyTypeRec);
+ if (map->types==NULL)
+ return BadAlloc;
+ map->num_types= 0;
+ map->size_types= nTotalTypes;
+ }
+ else if (map->size_types<nTotalTypes) {
+ XkbKeyTypeRec *prev_types = map->types;
+
+ map->types= _XkbTypedRealloc(map->types,nTotalTypes,XkbKeyTypeRec);
+ if (map->types==NULL) {
+ _XkbFree(prev_types);
+ map->num_types= map->size_types= 0;
+ return BadAlloc;
+ }
+ map->size_types= nTotalTypes;
+ bzero(&map->types[map->num_types],
+ ((map->size_types-map->num_types)*sizeof(XkbKeyTypeRec)));
+ }
+ }
+ if (which&XkbKeySymsMask) {
+ int nKeys= XkbNumKeys(xkb);
+ if (map->syms==NULL) {
+ map->size_syms= (nKeys*15)/10;
+ map->syms= _XkbTypedCalloc(map->size_syms,KeySym);
+ if (!map->syms) {
+ map->size_syms= 0;
+ return BadAlloc;
+ }
+ map->num_syms= 1;
+ map->syms[0]= NoSymbol;
+ }
+ if (map->key_sym_map==NULL) {
+ i= xkb->max_key_code+1;
+ map->key_sym_map= _XkbTypedCalloc(i,XkbSymMapRec);
+ if (map->key_sym_map==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbModifierMapMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->modmap==NULL) {
+ i= xkb->max_key_code+1;
+ map->modmap= _XkbTypedCalloc(i,unsigned char);
+ if (map->modmap==NULL)
+ return BadAlloc;
+ }
+ }
+ return Success;
+}
+
+Status
+XkbAllocServerMap(XkbDescPtr xkb,unsigned which,unsigned nNewActions)
+{
+register int i;
+XkbServerMapPtr map;
+
+ if (xkb==NULL)
+ return BadMatch;
+ if (xkb->server==NULL) {
+ map= _XkbTypedCalloc(1,XkbServerMapRec);
+ if (map==NULL)
+ return BadAlloc;
+ for (i=0;i<XkbNumVirtualMods;i++) {
+ map->vmods[i]= XkbNoModifierMask;
+ }
+ xkb->server= map;
+ }
+ else map= xkb->server;
+ if (which&XkbExplicitComponentsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->explicit==NULL) {
+ i= xkb->max_key_code+1;
+ map->explicit= _XkbTypedCalloc(i,unsigned char);
+ if (map->explicit==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbKeyActionsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (nNewActions<1)
+ nNewActions= 1;
+ if (map->acts==NULL) {
+ map->acts= _XkbTypedCalloc((nNewActions+1),XkbAction);
+ if (map->acts==NULL)
+ return BadAlloc;
+ map->num_acts= 1;
+ map->size_acts= nNewActions+1;
+ }
+ else if ((map->size_acts-map->num_acts)<nNewActions) {
+ unsigned need;
+ XkbAction *prev_acts = map->acts;
+ need= map->num_acts+nNewActions;
+ map->acts= _XkbTypedRealloc(map->acts,need,XkbAction);
+ if (map->acts==NULL) {
+ _XkbFree(prev_acts);
+ map->num_acts= map->size_acts= 0;
+ return BadAlloc;
+ }
+ map->size_acts= need;
+ bzero(&map->acts[map->num_acts],
+ ((map->size_acts-map->num_acts)*sizeof(XkbAction)));
+ }
+ if (map->key_acts==NULL) {
+ i= xkb->max_key_code+1;
+ map->key_acts= _XkbTypedCalloc(i,unsigned short);
+ if (map->key_acts==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbKeyBehaviorsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->behaviors==NULL) {
+ i= xkb->max_key_code+1;
+ map->behaviors= _XkbTypedCalloc(i,XkbBehavior);
+ if (map->behaviors==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbVirtualModMapMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->vmodmap==NULL) {
+ i= xkb->max_key_code+1;
+ map->vmodmap= _XkbTypedCalloc(i,unsigned short);
+ if (map->vmodmap==NULL)
+ return BadAlloc;
+ }
+ }
+ return Success;
+}
+
+/***====================================================================***/
+
+Status
+XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into)
+{
+ if ((!from)||(!into))
+ return BadMatch;
+ if (into->map) {
+ _XkbFree(into->map);
+ into->map= NULL;
+ }
+ if (into->preserve) {
+ _XkbFree(into->preserve);
+ into->preserve= NULL;
+ }
+ if (into->level_names) {
+ _XkbFree(into->level_names);
+ into->level_names= NULL;
+ }
+ *into= *from;
+ if ((from->map)&&(into->map_count>0)) {
+ into->map= _XkbTypedCalloc(into->map_count,XkbKTMapEntryRec);
+ if (!into->map)
+ return BadAlloc;
+ memcpy(into->map,from->map,into->map_count*sizeof(XkbKTMapEntryRec));
+ }
+ if ((from->preserve)&&(into->map_count>0)) {
+ into->preserve= _XkbTypedCalloc(into->map_count,XkbModsRec);
+ if (!into->preserve)
+ return BadAlloc;
+ memcpy(into->preserve,from->preserve,
+ into->map_count*sizeof(XkbModsRec));
+ }
+ if ((from->level_names)&&(into->num_levels>0)) {
+ into->level_names= _XkbTypedCalloc(into->num_levels,Atom);
+ if (!into->level_names)
+ return BadAlloc;
+ memcpy(into->level_names,from->level_names,
+ into->num_levels*sizeof(Atom));
+ }
+ return Success;
+}
+
+Status
+XkbCopyKeyTypes(XkbKeyTypePtr from,XkbKeyTypePtr into,int num_types)
+{
+register int i,rtrn;
+
+ if ((!from)||(!into)||(num_types<0))
+ return BadMatch;
+ for (i=0;i<num_types;i++) {
+ if ((rtrn= XkbCopyKeyType(from++,into++))!=Success)
+ return rtrn;
+ }
+ return Success;
+}
+
+XkbKeyTypePtr
+XkbAddKeyType( XkbDescPtr xkb,
+ Atom name,
+ int map_count,
+ Bool want_preserve,
+ int num_lvls)
+{
+register int i;
+unsigned tmp;
+XkbKeyTypePtr type;
+XkbClientMapPtr map;
+
+ if ((!xkb)||(num_lvls<1))
+ return NULL;
+ map= xkb->map;
+ if ((map)&&(map->types)) {
+ for (i=0;i<map->num_types;i++) {
+ if (map->types[i].name==name) {
+ Status status;
+ status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls);
+ return (status==Success?&map->types[i]:NULL);
+ }
+ }
+ }
+ if ((!map)||(!map->types)||(!map->num_types<XkbNumRequiredTypes)) {
+ tmp= XkbNumRequiredTypes+1;
+ if (XkbAllocClientMap(xkb,XkbKeyTypesMask,tmp)!=Success)
+ return NULL;
+ tmp= 0;
+ if (map->num_types<=XkbKeypadIndex)
+ tmp|= XkbKeypadMask;
+ if (map->num_types<=XkbAlphabeticIndex)
+ tmp|= XkbAlphabeticMask;
+ if (map->num_types<=XkbTwoLevelIndex)
+ tmp|= XkbTwoLevelMask;
+ if (map->num_types<=XkbOneLevelIndex)
+ tmp|= XkbOneLevelMask;
+ if (XkbInitCanonicalKeyTypes(xkb,tmp,XkbNoModifier)==Success) {
+ for (i=0;i<map->num_types;i++) {
+ Status status;
+ if (map->types[i].name!=name)
+ continue;
+ status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls);
+ return (status==Success?&map->types[i]:NULL);
+ }
+ }
+ }
+ if ((map->num_types<=map->size_types)&&
+ (XkbAllocClientMap(xkb,XkbKeyTypesMask,map->num_types+1)!=Success)) {
+ return NULL;
+ }
+ type= &map->types[map->num_types];
+ map->num_types++;
+ bzero((char *)type,sizeof(XkbKeyTypeRec));
+ type->num_levels= num_lvls;
+ type->map_count= map_count;
+ type->name= name;
+ if (map_count>0) {
+ type->map= _XkbTypedCalloc(map_count,XkbKTMapEntryRec);
+ if (!type->map) {
+ map->num_types--;
+ return NULL;
+ }
+ if (want_preserve) {
+ type->preserve= _XkbTypedCalloc(map_count,XkbModsRec);
+ if (!type->preserve) {
+ _XkbFree(type->map);
+ map->num_types--;
+ return NULL;
+ }
+ }
+ }
+ return type;
+}
+
+Status
+XkbResizeKeyType( XkbDescPtr xkb,
+ int type_ndx,
+ int map_count,
+ Bool want_preserve,
+ int new_num_lvls)
+{
+XkbKeyTypePtr type;
+KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
+
+ if ((type_ndx<0)||(type_ndx>=xkb->map->num_types)||(map_count<0)||
+ (new_num_lvls<1))
+ return BadValue;
+ switch (type_ndx) {
+ case XkbOneLevelIndex:
+ if (new_num_lvls!=1)
+ return BadMatch;
+ break;
+ case XkbTwoLevelIndex:
+ case XkbAlphabeticIndex:
+ case XkbKeypadIndex:
+ if (new_num_lvls!=2)
+ return BadMatch;
+ break;
+ }
+ type= &xkb->map->types[type_ndx];
+ if (map_count==0) {
+ if (type->map!=NULL)
+ _XkbFree(type->map);
+ type->map= NULL;
+ if (type->preserve!=NULL)
+ _XkbFree(type->preserve);
+ type->preserve= NULL;
+ type->map_count= 0;
+ }
+ else {
+ XkbKTMapEntryRec *prev_map = type->map;
+
+ if ((map_count>type->map_count)||(type->map==NULL))
+ type->map=_XkbTypedRealloc(type->map,map_count,XkbKTMapEntryRec);
+ if (!type->map) {
+ if (prev_map)
+ _XkbFree(prev_map);
+ return BadAlloc;
+ }
+ if (want_preserve) {
+ XkbModsRec *prev_preserve = type->preserve;
+
+ if ((map_count>type->map_count)||(type->preserve==NULL)) {
+ type->preserve= _XkbTypedRealloc(type->preserve,map_count,
+ XkbModsRec);
+ }
+ if (!type->preserve) {
+ if (prev_preserve)
+ _XkbFree(prev_preserve);
+ return BadAlloc;
+ }
+ }
+ else if (type->preserve!=NULL) {
+ _XkbFree(type->preserve);
+ type->preserve= NULL;
+ }
+ type->map_count= map_count;
+ }
+
+ if ((new_num_lvls>type->num_levels)||(type->level_names==NULL)) {
+ Atom * prev_level_names = type->level_names;
+
+ type->level_names=_XkbTypedRealloc(type->level_names,new_num_lvls,Atom);
+ if (!type->level_names) {
+ if (prev_level_names)
+ _XkbFree(prev_level_names);
+ return BadAlloc;
+ }
+ }
+ /*
+ * Here's the theory:
+ * If the width of the type changed, we might have to resize the symbol
+ * maps for any keys that use the type for one or more groups. This is
+ * expensive, so we'll try to cull out any keys that are obviously okay:
+ * In any case:
+ * - keys that have a group width <= the old width are okay (because
+ * they could not possibly have been associated with the old type)
+ * If the key type increased in size:
+ * - keys that already have a group width >= to the new width are okay
+ * + keys that have a group width >= the old width but < the new width
+ * might have to be enlarged.
+ * If the key type decreased in size:
+ * - keys that have a group width > the old width don't have to be
+ * resized (because they must have some other wider type associated
+ * with some group).
+ * + keys that have a group width == the old width might have to be
+ * shrunk.
+ * The possibilities marked with '+' require us to examine the key types
+ * associated with each group for the key.
+ */
+ bzero(matchingKeys,XkbMaxKeyCount*sizeof(KeyCode));
+ nMatchingKeys= 0;
+ if (new_num_lvls>type->num_levels) {
+ int nTotal;
+ KeySym * newSyms;
+ int width,match,nResize;
+ register int i,g,nSyms;
+
+ nResize= 0;
+ for (nTotal=1,i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ width= XkbKeyGroupsWidth(xkb,i);
+ if (width<type->num_levels)
+ continue;
+ for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) {
+ if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) {
+ matchingKeys[nMatchingKeys++]= i;
+ match= 1;
+ }
+ }
+ if ((!match)||(width>=new_num_lvls))
+ nTotal+= XkbKeyNumSyms(xkb,i);
+ else {
+ nTotal+= XkbKeyNumGroups(xkb,i)*new_num_lvls;
+ nResize++;
+ }
+ }
+ if (nResize>0) {
+ int nextMatch;
+ xkb->map->size_syms= (nTotal*12)/10;
+ newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
+ if (newSyms==NULL)
+ return BadAlloc;
+ nextMatch= 0;
+ nSyms= 1;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ if (matchingKeys[nextMatch]==i) {
+ KeySym *pOld;
+ nextMatch++;
+ width= XkbKeyGroupsWidth(xkb,i);
+ pOld= XkbKeySymsPtr(xkb,i);
+ for (g=XkbKeyNumGroups(xkb,i)-1;g>=0;g--) {
+ memcpy(&newSyms[nSyms+(new_num_lvls*g)],&pOld[width*g],
+ width*sizeof(KeySym));
+ }
+ xkb->map->key_sym_map[i].offset= nSyms;
+ nSyms+= XkbKeyNumGroups(xkb,i)*new_num_lvls;
+ }
+ else {
+ memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),
+ XkbKeyNumSyms(xkb,i)*sizeof(KeySym));
+ xkb->map->key_sym_map[i].offset= nSyms;
+ nSyms+= XkbKeyNumSyms(xkb,i);
+ }
+ }
+ type->num_levels= new_num_lvls;
+ _XkbFree(xkb->map->syms);
+ xkb->map->syms= newSyms;
+ xkb->map->num_syms= nSyms;
+ return Success;
+ }
+ }
+ else if (new_num_lvls<type->num_levels) {
+ int width,match;
+ register int g,i;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ width= XkbKeyGroupsWidth(xkb,i);
+ if (width<type->num_levels)
+ continue;
+ for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) {
+ if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) {
+ matchingKeys[nMatchingKeys++]= i;
+ match= 1;
+ }
+ }
+ }
+ }
+ if (nMatchingKeys>0) {
+ int key,firstClear;
+ register int i,g;
+ if (new_num_lvls>type->num_levels)
+ firstClear= type->num_levels;
+ else firstClear= new_num_lvls;
+ for (i=0;i<nMatchingKeys;i++) {
+ KeySym * pSyms;
+ int width,nClear;
+
+ key= matchingKeys[i];
+ width= XkbKeyGroupsWidth(xkb,key);
+ nClear= width-firstClear;
+ pSyms= XkbKeySymsPtr(xkb,key);
+ for (g=XkbKeyNumGroups(xkb,key)-1;g>=0;g--) {
+ if (XkbKeyKeyTypeIndex(xkb,key,g)==type_ndx) {
+ if (nClear>0)
+ bzero(&pSyms[g*width+firstClear],nClear*sizeof(KeySym));
+ }
+ }
+ }
+ }
+ type->num_levels= new_num_lvls;
+ return Success;
+}
+
+KeySym *
+XkbResizeKeySyms(XkbDescPtr xkb,int key,int needed)
+{
+register int i,nSyms,nKeySyms;
+unsigned nOldSyms;
+KeySym *newSyms;
+
+ if (needed==0) {
+ xkb->map->key_sym_map[key].offset= 0;
+ return xkb->map->syms;
+ }
+ nOldSyms= XkbKeyNumSyms(xkb,key);
+ if (nOldSyms>=(unsigned)needed) {
+ return XkbKeySymsPtr(xkb,key);
+ }
+ if (xkb->map->size_syms-xkb->map->num_syms>=(unsigned)needed) {
+ if (nOldSyms>0) {
+ memcpy(&xkb->map->syms[xkb->map->num_syms],XkbKeySymsPtr(xkb,key),
+ nOldSyms*sizeof(KeySym));
+ }
+ if ((needed-nOldSyms)>0) {
+ bzero(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb,key)],
+ (needed-nOldSyms)*sizeof(KeySym));
+ }
+ xkb->map->key_sym_map[key].offset = xkb->map->num_syms;
+ xkb->map->num_syms+= needed;
+ return &xkb->map->syms[xkb->map->key_sym_map[key].offset];
+ }
+ xkb->map->size_syms+= (needed>32?needed:32);
+ newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
+ if (newSyms==NULL)
+ return NULL;
+ newSyms[0]= NoSymbol;
+ nSyms = 1;
+ for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
+ int nCopy;
+
+ nCopy= nKeySyms= XkbKeyNumSyms(xkb,i);
+ if ((nKeySyms==0)&&(i!=key))
+ continue;
+ if (i==key)
+ nKeySyms= needed;
+ if (nCopy!=0)
+ memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),nCopy*sizeof(KeySym));
+ if (nKeySyms>nCopy)
+ bzero(&newSyms[nSyms+nCopy],(nKeySyms-nCopy)*sizeof(KeySym));
+ xkb->map->key_sym_map[i].offset = nSyms;
+ nSyms+= nKeySyms;
+ }
+ _XkbFree(xkb->map->syms);
+ xkb->map->syms = newSyms;
+ xkb->map->num_syms = nSyms;
+ return &xkb->map->syms[xkb->map->key_sym_map[key].offset];
+}
+
+static unsigned
+_ExtendRange( unsigned int old_flags,
+ unsigned int flag,
+ KeyCode newKC,
+ KeyCode * old_min,
+ unsigned char * old_num)
+{
+ if ((old_flags&flag)==0) {
+ old_flags|= flag;
+ *old_min= newKC;
+ *old_num= 1;
+ }
+ else {
+ int last= (*old_min)+(*old_num)-1;
+ if (newKC<*old_min) {
+ *old_min= newKC;
+ *old_num= (last-newKC)+1;
+ }
+ else if (newKC>last) {
+ *old_num= (newKC-(*old_min))+1;
+ }
+ }
+ return old_flags;
+}
+
+Status
+XkbChangeKeycodeRange( XkbDescPtr xkb,
+ int minKC,
+ int maxKC,
+ XkbChangesPtr changes)
+{
+int tmp;
+
+ if ((!xkb)||(minKC<XkbMinLegalKeyCode)||(maxKC>XkbMaxLegalKeyCode))
+ return BadValue;
+ if (minKC>maxKC)
+ return BadMatch;
+ if (minKC<xkb->min_key_code) {
+ if (changes)
+ changes->map.min_key_code= minKC;
+ tmp= xkb->min_key_code-minKC;
+ if (xkb->map) {
+ if (xkb->map->key_sym_map) {
+ bzero((char *)&xkb->map->key_sym_map[minKC],
+ tmp*sizeof(XkbSymMapRec));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeySymsMask,minKC,
+ &changes->map.first_key_sym,
+ &changes->map.num_key_syms);
+ }
+ }
+ if (xkb->map->modmap) {
+ bzero((char *)&xkb->map->modmap[minKC],tmp);
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbModifierMapMask,minKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_modmap_keys);
+ }
+ }
+ }
+ if (xkb->server) {
+ if (xkb->server->behaviors) {
+ bzero((char *)&xkb->server->behaviors[minKC],
+ tmp*sizeof(XkbBehavior));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyBehaviorsMask,minKC,
+ &changes->map.first_key_behavior,
+ &changes->map.num_key_behaviors);
+ }
+ }
+ if (xkb->server->key_acts) {
+ bzero((char *)&xkb->server->key_acts[minKC],
+ tmp*sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyActionsMask,minKC,
+ &changes->map.first_key_act,
+ &changes->map.num_key_acts);
+ }
+ }
+ if (xkb->server->vmodmap) {
+ bzero((char *)&xkb->server->vmodmap[minKC],
+ tmp*sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbVirtualModMapMask,minKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_vmodmap_keys);
+ }
+ }
+ }
+ if ((xkb->names)&&(xkb->names->keys)) {
+ bzero((char *)&xkb->names->keys[minKC],tmp*sizeof(XkbKeyNameRec));
+ if (changes) {
+ changes->names.changed= _ExtendRange(changes->names.changed,
+ XkbKeyNamesMask,minKC,
+ &changes->names.first_key,
+ &changes->names.num_keys);
+ }
+ }
+ xkb->min_key_code= minKC;
+ }
+ if (maxKC>xkb->max_key_code) {
+ if (changes)
+ changes->map.max_key_code= maxKC;
+ tmp= maxKC-xkb->max_key_code;
+ if (xkb->map) {
+ if (xkb->map->key_sym_map) {
+ XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map;
+
+ xkb->map->key_sym_map= _XkbTypedRealloc(xkb->map->key_sym_map,
+ (maxKC+1),XkbSymMapRec);
+ if (!xkb->map->key_sym_map) {
+ _XkbFree(prev_key_sym_map);
+ return BadAlloc;
+ }
+#ifdef NXAGENT_SERVER
+ bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code+1],
+ tmp*sizeof(XkbSymMapRec));
+#else
+ bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code],
+ tmp*sizeof(XkbSymMapRec));
+#endif
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeySymsMask,maxKC,
+ &changes->map.first_key_sym,
+ &changes->map.num_key_syms);
+ }
+ }
+ if (xkb->map->modmap) {
+ unsigned char *prev_modmap = xkb->map->modmap;
+
+ xkb->map->modmap= _XkbTypedRealloc(xkb->map->modmap,
+ (maxKC+1),unsigned char);
+ if (!xkb->map->modmap) {
+ _XkbFree(prev_modmap);
+ return BadAlloc;
+ }
+#ifdef NXAGENT_SERVER
+ bzero((char *)&xkb->map->modmap[xkb->max_key_code+1],tmp);
+#else
+ bzero((char *)&xkb->map->modmap[xkb->max_key_code],tmp);
+#endif
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbModifierMapMask,maxKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_modmap_keys);
+ }
+ }
+ }
+ if (xkb->server) {
+ if (xkb->server->behaviors) {
+ XkbBehavior *prev_behaviors = xkb->server->behaviors;
+
+ xkb->server->behaviors=_XkbTypedRealloc(xkb->server->behaviors,
+ (maxKC+1),XkbBehavior);
+ if (!xkb->server->behaviors) {
+ _XkbFree(prev_behaviors);
+ return BadAlloc;
+ }
+#ifdef NXAGENT_SERVER
+ bzero((char *)&xkb->server->behaviors[xkb->max_key_code+1],
+ tmp*sizeof(XkbBehavior));
+#else
+ bzero((char *)&xkb->server->behaviors[xkb->max_key_code],
+ tmp*sizeof(XkbBehavior));
+#endif
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyBehaviorsMask,maxKC,
+ &changes->map.first_key_behavior,
+ &changes->map.num_key_behaviors);
+ }
+ }
+ if (xkb->server->key_acts) {
+ unsigned short *prev_key_acts = xkb->server->key_acts;
+
+ xkb->server->key_acts= _XkbTypedRealloc(xkb->server->key_acts,
+ (maxKC+1),unsigned short);
+ if (!xkb->server->key_acts) {
+ _XkbFree(prev_key_acts);
+ return BadAlloc;
+ }
+#ifdef NXAGENT_SERVER
+ bzero((char *)&xkb->server->key_acts[xkb->max_key_code+1],
+ tmp*sizeof(unsigned short));
+#else
+ bzero((char *)&xkb->server->key_acts[xkb->max_key_code],
+ tmp*sizeof(unsigned short));
+#endif
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyActionsMask,maxKC,
+ &changes->map.first_key_act,
+ &changes->map.num_key_acts);
+ }
+ }
+ if (xkb->server->vmodmap) {
+ unsigned short *prev_vmodmap = xkb->server->vmodmap;
+
+ xkb->server->vmodmap= _XkbTypedRealloc(xkb->server->vmodmap,
+ (maxKC+1),unsigned short);
+ if (!xkb->server->vmodmap) {
+ _XkbFree(prev_vmodmap);
+ return BadAlloc;
+ }
+#ifdef NXAGENT_SERVER
+ bzero((char *)&xkb->server->vmodmap[xkb->max_key_code+1],
+ tmp*sizeof(unsigned short));
+#else
+ bzero((char *)&xkb->server->vmodmap[xkb->max_key_code],
+ tmp*sizeof(unsigned short));
+#endif
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbVirtualModMapMask,maxKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_vmodmap_keys);
+ }
+ }
+ }
+ if ((xkb->names)&&(xkb->names->keys)) {
+ XkbKeyNameRec *prev_keys = xkb->names->keys;
+
+ xkb->names->keys= _XkbTypedRealloc(xkb->names->keys,
+ (maxKC+1),XkbKeyNameRec);
+ if (!xkb->names->keys) {
+ _XkbFree(prev_keys);
+ return BadAlloc;
+ }
+#ifdef NXAGENT_SERVER
+ bzero((char *)&xkb->names->keys[xkb->max_key_code+1],
+ tmp*sizeof(XkbKeyNameRec));
+#else
+ bzero((char *)&xkb->names->keys[xkb->max_key_code],
+ tmp*sizeof(XkbKeyNameRec));
+#endif
+ if (changes) {
+ changes->names.changed= _ExtendRange(changes->names.changed,
+ XkbKeyNamesMask,maxKC,
+ &changes->names.first_key,
+ &changes->names.num_keys);
+ }
+ }
+ xkb->max_key_code= maxKC;
+ }
+ return Success;
+}
+
+XkbAction *
+XkbResizeKeyActions(XkbDescPtr xkb,int key,int needed)
+{
+register int i,nActs;
+XkbAction *newActs;
+
+ if (needed==0) {
+ xkb->server->key_acts[key]= 0;
+ return NULL;
+ }
+ if (XkbKeyHasActions(xkb,key)&&(XkbKeyNumSyms(xkb,key)>=(unsigned)needed))
+ return XkbKeyActionsPtr(xkb,key);
+ if (xkb->server->size_acts-xkb->server->num_acts>=(unsigned)needed) {
+ xkb->server->key_acts[key]= xkb->server->num_acts;
+ xkb->server->num_acts+= needed;
+ return &xkb->server->acts[xkb->server->key_acts[key]];
+ }
+ xkb->server->size_acts= xkb->server->num_acts+needed+8;
+ newActs = _XkbTypedCalloc(xkb->server->size_acts,XkbAction);
+ if (newActs==NULL)
+ return NULL;
+ newActs[0].type = XkbSA_NoAction;
+ nActs = 1;
+ for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
+ int nKeyActs,nCopy;
+
+ if ((xkb->server->key_acts[i]==0)&&(i!=key))
+ continue;
+
+ nCopy= nKeyActs= XkbKeyNumActions(xkb,i);
+ if (i==key) {
+ nKeyActs= needed;
+ if (needed<nCopy)
+ nCopy= needed;
+ }
+
+ if (nCopy>0)
+ memcpy(&newActs[nActs],XkbKeyActionsPtr(xkb,i),
+ nCopy*sizeof(XkbAction));
+ if (nCopy<nKeyActs)
+ bzero(&newActs[nActs+nCopy],(nKeyActs-nCopy)*sizeof(XkbAction));
+ xkb->server->key_acts[i]= nActs;
+ nActs+= nKeyActs;
+ }
+ _XkbFree(xkb->server->acts);
+ xkb->server->acts = newActs;
+ xkb->server->num_acts= nActs;
+ return &xkb->server->acts[xkb->server->key_acts[key]];
+}
+
+void
+XkbFreeClientMap(XkbDescPtr xkb,unsigned what,Bool freeMap)
+{
+XkbClientMapPtr map;
+
+ if ((xkb==NULL)||(xkb->map==NULL))
+ return;
+ if (freeMap)
+ what= XkbAllClientInfoMask;
+ map= xkb->map;
+ if (what&XkbKeyTypesMask) {
+ if (map->types!=NULL) {
+ if (map->num_types>0) {
+ register int i;
+ XkbKeyTypePtr type;
+ for (i=0,type=map->types;i<map->num_types;i++,type++) {
+ if (type->map!=NULL) {
+ _XkbFree(type->map);
+ type->map= NULL;
+ }
+ if (type->preserve!=NULL) {
+ _XkbFree(type->preserve);
+ type->preserve= NULL;
+ }
+ type->map_count= 0;
+ if (type->level_names!=NULL) {
+ _XkbFree(type->level_names);
+ type->level_names= NULL;
+ }
+ }
+ }
+ _XkbFree(map->types);
+ map->num_types= map->size_types= 0;
+ map->types= NULL;
+ }
+ }
+ if (what&XkbKeySymsMask) {
+ if (map->key_sym_map!=NULL) {
+ _XkbFree(map->key_sym_map);
+ map->key_sym_map= NULL;
+ }
+ if (map->syms!=NULL) {
+ _XkbFree(map->syms);
+ map->size_syms= map->num_syms= 0;
+ map->syms= NULL;
+ }
+ }
+ if ((what&XkbModifierMapMask)&&(map->modmap!=NULL)) {
+ _XkbFree(map->modmap);
+ map->modmap= NULL;
+ }
+ if (freeMap) {
+ _XkbFree(xkb->map);
+ xkb->map= NULL;
+ }
+ return;
+}
+
+void
+XkbFreeServerMap(XkbDescPtr xkb,unsigned what,Bool freeMap)
+{
+XkbServerMapPtr map;
+
+ if ((xkb==NULL)||(xkb->server==NULL))
+ return;
+ if (freeMap)
+ what= XkbAllServerInfoMask;
+ map= xkb->server;
+ if ((what&XkbExplicitComponentsMask)&&(map->explicit!=NULL)) {
+ _XkbFree(map->explicit);
+ map->explicit= NULL;
+ }
+ if (what&XkbKeyActionsMask) {
+ if (map->key_acts!=NULL) {
+ _XkbFree(map->key_acts);
+ map->key_acts= NULL;
+ }
+ if (map->acts!=NULL) {
+ _XkbFree(map->acts);
+ map->num_acts= map->size_acts= 0;
+ map->acts= NULL;
+ }
+ }
+ if ((what&XkbKeyBehaviorsMask)&&(map->behaviors!=NULL)) {
+ _XkbFree(map->behaviors);
+ map->behaviors= NULL;
+ }
+ if ((what&XkbVirtualModMapMask)&&(map->vmodmap!=NULL)) {
+ _XkbFree(map->vmodmap);
+ map->vmodmap= NULL;
+ }
+
+ if (freeMap) {
+ _XkbFree(xkb->server);
+ xkb->server= NULL;
+ }
+ return;
+}
diff --git a/nx-X11/lib/X11/XKBMAlloc.c.X.original b/nx-X11/lib/X11/XKBMAlloc.c.X.original
new file mode 100644
index 000000000..91d87d57c
--- /dev/null
+++ b/nx-X11/lib/X11/XKBMAlloc.c.X.original
@@ -0,0 +1,994 @@
+/* $Xorg: XKBMAlloc.c,v 1.4 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBMAlloc.c,v 3.11 2001/01/17 19:41:48 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#elif defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#ifndef XKB_IN_SERVER
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include <X11/keysym.h>
+#include "XKBlibint.h"
+
+#else
+
+#include <stdio.h>
+#include <X11/X.h>
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include <X11/keysym.h>
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+
+#endif /* XKB_IN_SERVER */
+
+/***====================================================================***/
+
+Status
+XkbAllocClientMap(XkbDescPtr xkb,unsigned which,unsigned nTotalTypes)
+{
+register int i;
+XkbClientMapPtr map;
+
+ if ((xkb==NULL)||((nTotalTypes>0)&&(nTotalTypes<XkbNumRequiredTypes)))
+ return BadValue;
+ if ((which&XkbKeySymsMask)&&
+ ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))) {
+#ifdef DEBUG
+fprintf(stderr,"bad keycode (%d,%d) in XkbAllocClientMap\n",
+ xkb->min_key_code,xkb->max_key_code);
+#endif
+ return BadValue;
+ }
+
+ if (xkb->map==NULL) {
+ map= _XkbTypedCalloc(1,XkbClientMapRec);
+ if (map==NULL)
+ return BadAlloc;
+ xkb->map= map;
+ }
+ else map= xkb->map;
+
+ if ((which&XkbKeyTypesMask)&&(nTotalTypes>0)) {
+ if (map->types==NULL) {
+ map->types= _XkbTypedCalloc(nTotalTypes,XkbKeyTypeRec);
+ if (map->types==NULL)
+ return BadAlloc;
+ map->num_types= 0;
+ map->size_types= nTotalTypes;
+ }
+ else if (map->size_types<nTotalTypes) {
+ XkbKeyTypeRec *prev_types = map->types;
+
+ map->types= _XkbTypedRealloc(map->types,nTotalTypes,XkbKeyTypeRec);
+ if (map->types==NULL) {
+ _XkbFree(prev_types);
+ map->num_types= map->size_types= 0;
+ return BadAlloc;
+ }
+ map->size_types= nTotalTypes;
+ bzero(&map->types[map->num_types],
+ ((map->size_types-map->num_types)*sizeof(XkbKeyTypeRec)));
+ }
+ }
+ if (which&XkbKeySymsMask) {
+ int nKeys= XkbNumKeys(xkb);
+ if (map->syms==NULL) {
+ map->size_syms= (nKeys*15)/10;
+ map->syms= _XkbTypedCalloc(map->size_syms,KeySym);
+ if (!map->syms) {
+ map->size_syms= 0;
+ return BadAlloc;
+ }
+ map->num_syms= 1;
+ map->syms[0]= NoSymbol;
+ }
+ if (map->key_sym_map==NULL) {
+ i= xkb->max_key_code+1;
+ map->key_sym_map= _XkbTypedCalloc(i,XkbSymMapRec);
+ if (map->key_sym_map==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbModifierMapMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->modmap==NULL) {
+ i= xkb->max_key_code+1;
+ map->modmap= _XkbTypedCalloc(i,unsigned char);
+ if (map->modmap==NULL)
+ return BadAlloc;
+ }
+ }
+ return Success;
+}
+
+Status
+XkbAllocServerMap(XkbDescPtr xkb,unsigned which,unsigned nNewActions)
+{
+register int i;
+XkbServerMapPtr map;
+
+ if (xkb==NULL)
+ return BadMatch;
+ if (xkb->server==NULL) {
+ map= _XkbTypedCalloc(1,XkbServerMapRec);
+ if (map==NULL)
+ return BadAlloc;
+ for (i=0;i<XkbNumVirtualMods;i++) {
+ map->vmods[i]= XkbNoModifierMask;
+ }
+ xkb->server= map;
+ }
+ else map= xkb->server;
+ if (which&XkbExplicitComponentsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->explicit==NULL) {
+ i= xkb->max_key_code+1;
+ map->explicit= _XkbTypedCalloc(i,unsigned char);
+ if (map->explicit==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbKeyActionsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (nNewActions<1)
+ nNewActions= 1;
+ if (map->acts==NULL) {
+ map->acts= _XkbTypedCalloc((nNewActions+1),XkbAction);
+ if (map->acts==NULL)
+ return BadAlloc;
+ map->num_acts= 1;
+ map->size_acts= nNewActions+1;
+ }
+ else if ((map->size_acts-map->num_acts)<nNewActions) {
+ unsigned need;
+ XkbAction *prev_acts = map->acts;
+ need= map->num_acts+nNewActions;
+ map->acts= _XkbTypedRealloc(map->acts,need,XkbAction);
+ if (map->acts==NULL) {
+ _XkbFree(prev_acts);
+ map->num_acts= map->size_acts= 0;
+ return BadAlloc;
+ }
+ map->size_acts= need;
+ bzero(&map->acts[map->num_acts],
+ ((map->size_acts-map->num_acts)*sizeof(XkbAction)));
+ }
+ if (map->key_acts==NULL) {
+ i= xkb->max_key_code+1;
+ map->key_acts= _XkbTypedCalloc(i,unsigned short);
+ if (map->key_acts==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbKeyBehaviorsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->behaviors==NULL) {
+ i= xkb->max_key_code+1;
+ map->behaviors= _XkbTypedCalloc(i,XkbBehavior);
+ if (map->behaviors==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbVirtualModMapMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->vmodmap==NULL) {
+ i= xkb->max_key_code+1;
+ map->vmodmap= _XkbTypedCalloc(i,unsigned short);
+ if (map->vmodmap==NULL)
+ return BadAlloc;
+ }
+ }
+ return Success;
+}
+
+/***====================================================================***/
+
+Status
+XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into)
+{
+ if ((!from)||(!into))
+ return BadMatch;
+ if (into->map) {
+ _XkbFree(into->map);
+ into->map= NULL;
+ }
+ if (into->preserve) {
+ _XkbFree(into->preserve);
+ into->preserve= NULL;
+ }
+ if (into->level_names) {
+ _XkbFree(into->level_names);
+ into->level_names= NULL;
+ }
+ *into= *from;
+ if ((from->map)&&(into->map_count>0)) {
+ into->map= _XkbTypedCalloc(into->map_count,XkbKTMapEntryRec);
+ if (!into->map)
+ return BadAlloc;
+ memcpy(into->map,from->map,into->map_count*sizeof(XkbKTMapEntryRec));
+ }
+ if ((from->preserve)&&(into->map_count>0)) {
+ into->preserve= _XkbTypedCalloc(into->map_count,XkbModsRec);
+ if (!into->preserve)
+ return BadAlloc;
+ memcpy(into->preserve,from->preserve,
+ into->map_count*sizeof(XkbModsRec));
+ }
+ if ((from->level_names)&&(into->num_levels>0)) {
+ into->level_names= _XkbTypedCalloc(into->num_levels,Atom);
+ if (!into->level_names)
+ return BadAlloc;
+ memcpy(into->level_names,from->level_names,
+ into->num_levels*sizeof(Atom));
+ }
+ return Success;
+}
+
+Status
+XkbCopyKeyTypes(XkbKeyTypePtr from,XkbKeyTypePtr into,int num_types)
+{
+register int i,rtrn;
+
+ if ((!from)||(!into)||(num_types<0))
+ return BadMatch;
+ for (i=0;i<num_types;i++) {
+ if ((rtrn= XkbCopyKeyType(from++,into++))!=Success)
+ return rtrn;
+ }
+ return Success;
+}
+
+XkbKeyTypePtr
+XkbAddKeyType( XkbDescPtr xkb,
+ Atom name,
+ int map_count,
+ Bool want_preserve,
+ int num_lvls)
+{
+register int i;
+unsigned tmp;
+XkbKeyTypePtr type;
+XkbClientMapPtr map;
+
+ if ((!xkb)||(num_lvls<1))
+ return NULL;
+ map= xkb->map;
+ if ((map)&&(map->types)) {
+ for (i=0;i<map->num_types;i++) {
+ if (map->types[i].name==name) {
+ Status status;
+ status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls);
+ return (status==Success?&map->types[i]:NULL);
+ }
+ }
+ }
+ if ((!map)||(!map->types)||(!map->num_types<XkbNumRequiredTypes)) {
+ tmp= XkbNumRequiredTypes+1;
+ if (XkbAllocClientMap(xkb,XkbKeyTypesMask,tmp)!=Success)
+ return NULL;
+ tmp= 0;
+ if (map->num_types<=XkbKeypadIndex)
+ tmp|= XkbKeypadMask;
+ if (map->num_types<=XkbAlphabeticIndex)
+ tmp|= XkbAlphabeticMask;
+ if (map->num_types<=XkbTwoLevelIndex)
+ tmp|= XkbTwoLevelMask;
+ if (map->num_types<=XkbOneLevelIndex)
+ tmp|= XkbOneLevelMask;
+ if (XkbInitCanonicalKeyTypes(xkb,tmp,XkbNoModifier)==Success) {
+ for (i=0;i<map->num_types;i++) {
+ Status status;
+ if (map->types[i].name!=name)
+ continue;
+ status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls);
+ return (status==Success?&map->types[i]:NULL);
+ }
+ }
+ }
+ if ((map->num_types<=map->size_types)&&
+ (XkbAllocClientMap(xkb,XkbKeyTypesMask,map->num_types+1)!=Success)) {
+ return NULL;
+ }
+ type= &map->types[map->num_types];
+ map->num_types++;
+ bzero((char *)type,sizeof(XkbKeyTypeRec));
+ type->num_levels= num_lvls;
+ type->map_count= map_count;
+ type->name= name;
+ if (map_count>0) {
+ type->map= _XkbTypedCalloc(map_count,XkbKTMapEntryRec);
+ if (!type->map) {
+ map->num_types--;
+ return NULL;
+ }
+ if (want_preserve) {
+ type->preserve= _XkbTypedCalloc(map_count,XkbModsRec);
+ if (!type->preserve) {
+ _XkbFree(type->map);
+ map->num_types--;
+ return NULL;
+ }
+ }
+ }
+ return type;
+}
+
+Status
+XkbResizeKeyType( XkbDescPtr xkb,
+ int type_ndx,
+ int map_count,
+ Bool want_preserve,
+ int new_num_lvls)
+{
+XkbKeyTypePtr type;
+KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
+
+ if ((type_ndx<0)||(type_ndx>=xkb->map->num_types)||(map_count<0)||
+ (new_num_lvls<1))
+ return BadValue;
+ switch (type_ndx) {
+ case XkbOneLevelIndex:
+ if (new_num_lvls!=1)
+ return BadMatch;
+ break;
+ case XkbTwoLevelIndex:
+ case XkbAlphabeticIndex:
+ case XkbKeypadIndex:
+ if (new_num_lvls!=2)
+ return BadMatch;
+ break;
+ }
+ type= &xkb->map->types[type_ndx];
+ if (map_count==0) {
+ if (type->map!=NULL)
+ _XkbFree(type->map);
+ type->map= NULL;
+ if (type->preserve!=NULL)
+ _XkbFree(type->preserve);
+ type->preserve= NULL;
+ type->map_count= 0;
+ }
+ else {
+ XkbKTMapEntryRec *prev_map = type->map;
+
+ if ((map_count>type->map_count)||(type->map==NULL))
+ type->map=_XkbTypedRealloc(type->map,map_count,XkbKTMapEntryRec);
+ if (!type->map) {
+ if (prev_map)
+ _XkbFree(prev_map);
+ return BadAlloc;
+ }
+ if (want_preserve) {
+ XkbModsRec *prev_preserve = type->preserve;
+
+ if ((map_count>type->map_count)||(type->preserve==NULL)) {
+ type->preserve= _XkbTypedRealloc(type->preserve,map_count,
+ XkbModsRec);
+ }
+ if (!type->preserve) {
+ if (prev_preserve)
+ _XkbFree(prev_preserve);
+ return BadAlloc;
+ }
+ }
+ else if (type->preserve!=NULL) {
+ _XkbFree(type->preserve);
+ type->preserve= NULL;
+ }
+ type->map_count= map_count;
+ }
+
+ if ((new_num_lvls>type->num_levels)||(type->level_names==NULL)) {
+ Atom * prev_level_names = type->level_names;
+
+ type->level_names=_XkbTypedRealloc(type->level_names,new_num_lvls,Atom);
+ if (!type->level_names) {
+ if (prev_level_names)
+ _XkbFree(prev_level_names);
+ return BadAlloc;
+ }
+ }
+ /*
+ * Here's the theory:
+ * If the width of the type changed, we might have to resize the symbol
+ * maps for any keys that use the type for one or more groups. This is
+ * expensive, so we'll try to cull out any keys that are obviously okay:
+ * In any case:
+ * - keys that have a group width <= the old width are okay (because
+ * they could not possibly have been associated with the old type)
+ * If the key type increased in size:
+ * - keys that already have a group width >= to the new width are okay
+ * + keys that have a group width >= the old width but < the new width
+ * might have to be enlarged.
+ * If the key type decreased in size:
+ * - keys that have a group width > the old width don't have to be
+ * resized (because they must have some other wider type associated
+ * with some group).
+ * + keys that have a group width == the old width might have to be
+ * shrunk.
+ * The possibilities marked with '+' require us to examine the key types
+ * associated with each group for the key.
+ */
+ bzero(matchingKeys,XkbMaxKeyCount*sizeof(KeyCode));
+ nMatchingKeys= 0;
+ if (new_num_lvls>type->num_levels) {
+ int nTotal;
+ KeySym * newSyms;
+ int width,match,nResize;
+ register int i,g,nSyms;
+
+ nResize= 0;
+ for (nTotal=1,i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ width= XkbKeyGroupsWidth(xkb,i);
+ if (width<type->num_levels)
+ continue;
+ for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) {
+ if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) {
+ matchingKeys[nMatchingKeys++]= i;
+ match= 1;
+ }
+ }
+ if ((!match)||(width>=new_num_lvls))
+ nTotal+= XkbKeyNumSyms(xkb,i);
+ else {
+ nTotal+= XkbKeyNumGroups(xkb,i)*new_num_lvls;
+ nResize++;
+ }
+ }
+ if (nResize>0) {
+ int nextMatch;
+ xkb->map->size_syms= (nTotal*12)/10;
+ newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
+ if (newSyms==NULL)
+ return BadAlloc;
+ nextMatch= 0;
+ nSyms= 1;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ if (matchingKeys[nextMatch]==i) {
+ KeySym *pOld;
+ nextMatch++;
+ width= XkbKeyGroupsWidth(xkb,i);
+ pOld= XkbKeySymsPtr(xkb,i);
+ for (g=XkbKeyNumGroups(xkb,i)-1;g>=0;g--) {
+ memcpy(&newSyms[nSyms+(new_num_lvls*g)],&pOld[width*g],
+ width*sizeof(KeySym));
+ }
+ xkb->map->key_sym_map[i].offset= nSyms;
+ nSyms+= XkbKeyNumGroups(xkb,i)*new_num_lvls;
+ }
+ else {
+ memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),
+ XkbKeyNumSyms(xkb,i)*sizeof(KeySym));
+ xkb->map->key_sym_map[i].offset= nSyms;
+ nSyms+= XkbKeyNumSyms(xkb,i);
+ }
+ }
+ type->num_levels= new_num_lvls;
+ _XkbFree(xkb->map->syms);
+ xkb->map->syms= newSyms;
+ xkb->map->num_syms= nSyms;
+ return Success;
+ }
+ }
+ else if (new_num_lvls<type->num_levels) {
+ int width,match;
+ register int g,i;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ width= XkbKeyGroupsWidth(xkb,i);
+ if (width<type->num_levels)
+ continue;
+ for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) {
+ if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) {
+ matchingKeys[nMatchingKeys++]= i;
+ match= 1;
+ }
+ }
+ }
+ }
+ if (nMatchingKeys>0) {
+ int key,firstClear;
+ register int i,g;
+ if (new_num_lvls>type->num_levels)
+ firstClear= type->num_levels;
+ else firstClear= new_num_lvls;
+ for (i=0;i<nMatchingKeys;i++) {
+ KeySym * pSyms;
+ int width,nClear;
+
+ key= matchingKeys[i];
+ width= XkbKeyGroupsWidth(xkb,key);
+ nClear= width-firstClear;
+ pSyms= XkbKeySymsPtr(xkb,key);
+ for (g=XkbKeyNumGroups(xkb,key)-1;g>=0;g--) {
+ if (XkbKeyKeyTypeIndex(xkb,key,g)==type_ndx) {
+ if (nClear>0)
+ bzero(&pSyms[g*width+firstClear],nClear*sizeof(KeySym));
+ }
+ }
+ }
+ }
+ type->num_levels= new_num_lvls;
+ return Success;
+}
+
+KeySym *
+XkbResizeKeySyms(XkbDescPtr xkb,int key,int needed)
+{
+register int i,nSyms,nKeySyms;
+unsigned nOldSyms;
+KeySym *newSyms;
+
+ if (needed==0) {
+ xkb->map->key_sym_map[key].offset= 0;
+ return xkb->map->syms;
+ }
+ nOldSyms= XkbKeyNumSyms(xkb,key);
+ if (nOldSyms>=(unsigned)needed) {
+ return XkbKeySymsPtr(xkb,key);
+ }
+ if (xkb->map->size_syms-xkb->map->num_syms>=(unsigned)needed) {
+ if (nOldSyms>0) {
+ memcpy(&xkb->map->syms[xkb->map->num_syms],XkbKeySymsPtr(xkb,key),
+ nOldSyms*sizeof(KeySym));
+ }
+ if ((needed-nOldSyms)>0) {
+ bzero(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb,key)],
+ (needed-nOldSyms)*sizeof(KeySym));
+ }
+ xkb->map->key_sym_map[key].offset = xkb->map->num_syms;
+ xkb->map->num_syms+= needed;
+ return &xkb->map->syms[xkb->map->key_sym_map[key].offset];
+ }
+ xkb->map->size_syms+= (needed>32?needed:32);
+ newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
+ if (newSyms==NULL)
+ return NULL;
+ newSyms[0]= NoSymbol;
+ nSyms = 1;
+ for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
+ int nCopy;
+
+ nCopy= nKeySyms= XkbKeyNumSyms(xkb,i);
+ if ((nKeySyms==0)&&(i!=key))
+ continue;
+ if (i==key)
+ nKeySyms= needed;
+ if (nCopy!=0)
+ memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),nCopy*sizeof(KeySym));
+ if (nKeySyms>nCopy)
+ bzero(&newSyms[nSyms+nCopy],(nKeySyms-nCopy)*sizeof(KeySym));
+ xkb->map->key_sym_map[i].offset = nSyms;
+ nSyms+= nKeySyms;
+ }
+ _XkbFree(xkb->map->syms);
+ xkb->map->syms = newSyms;
+ xkb->map->num_syms = nSyms;
+ return &xkb->map->syms[xkb->map->key_sym_map[key].offset];
+}
+
+static unsigned
+_ExtendRange( unsigned int old_flags,
+ unsigned int flag,
+ KeyCode newKC,
+ KeyCode * old_min,
+ unsigned char * old_num)
+{
+ if ((old_flags&flag)==0) {
+ old_flags|= flag;
+ *old_min= newKC;
+ *old_num= 1;
+ }
+ else {
+ int last= (*old_min)+(*old_num)-1;
+ if (newKC<*old_min) {
+ *old_min= newKC;
+ *old_num= (last-newKC)+1;
+ }
+ else if (newKC>last) {
+ *old_num= (newKC-(*old_min))+1;
+ }
+ }
+ return old_flags;
+}
+
+Status
+XkbChangeKeycodeRange( XkbDescPtr xkb,
+ int minKC,
+ int maxKC,
+ XkbChangesPtr changes)
+{
+int tmp;
+
+ if ((!xkb)||(minKC<XkbMinLegalKeyCode)||(maxKC>XkbMaxLegalKeyCode))
+ return BadValue;
+ if (minKC>maxKC)
+ return BadMatch;
+ if (minKC<xkb->min_key_code) {
+ if (changes)
+ changes->map.min_key_code= minKC;
+ tmp= xkb->min_key_code-minKC;
+ if (xkb->map) {
+ if (xkb->map->key_sym_map) {
+ bzero((char *)&xkb->map->key_sym_map[minKC],
+ tmp*sizeof(XkbSymMapRec));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeySymsMask,minKC,
+ &changes->map.first_key_sym,
+ &changes->map.num_key_syms);
+ }
+ }
+ if (xkb->map->modmap) {
+ bzero((char *)&xkb->map->modmap[minKC],tmp);
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbModifierMapMask,minKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_modmap_keys);
+ }
+ }
+ }
+ if (xkb->server) {
+ if (xkb->server->behaviors) {
+ bzero((char *)&xkb->server->behaviors[minKC],
+ tmp*sizeof(XkbBehavior));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyBehaviorsMask,minKC,
+ &changes->map.first_key_behavior,
+ &changes->map.num_key_behaviors);
+ }
+ }
+ if (xkb->server->key_acts) {
+ bzero((char *)&xkb->server->key_acts[minKC],
+ tmp*sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyActionsMask,minKC,
+ &changes->map.first_key_act,
+ &changes->map.num_key_acts);
+ }
+ }
+ if (xkb->server->vmodmap) {
+ bzero((char *)&xkb->server->vmodmap[minKC],
+ tmp*sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbVirtualModMapMask,minKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_vmodmap_keys);
+ }
+ }
+ }
+ if ((xkb->names)&&(xkb->names->keys)) {
+ bzero((char *)&xkb->names->keys[minKC],tmp*sizeof(XkbKeyNameRec));
+ if (changes) {
+ changes->names.changed= _ExtendRange(changes->names.changed,
+ XkbKeyNamesMask,minKC,
+ &changes->names.first_key,
+ &changes->names.num_keys);
+ }
+ }
+ xkb->min_key_code= minKC;
+ }
+ if (maxKC>xkb->max_key_code) {
+ if (changes)
+ changes->map.max_key_code= maxKC;
+ tmp= maxKC-xkb->max_key_code;
+ if (xkb->map) {
+ if (xkb->map->key_sym_map) {
+ XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map;
+
+ xkb->map->key_sym_map= _XkbTypedRealloc(xkb->map->key_sym_map,
+ (maxKC+1),XkbSymMapRec);
+ if (!xkb->map->key_sym_map) {
+ _XkbFree(prev_key_sym_map);
+ return BadAlloc;
+ }
+ bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code],
+ tmp*sizeof(XkbSymMapRec));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeySymsMask,maxKC,
+ &changes->map.first_key_sym,
+ &changes->map.num_key_syms);
+ }
+ }
+ if (xkb->map->modmap) {
+ unsigned char *prev_modmap = xkb->map->modmap;
+
+ xkb->map->modmap= _XkbTypedRealloc(xkb->map->modmap,
+ (maxKC+1),unsigned char);
+ if (!xkb->map->modmap) {
+ _XkbFree(prev_modmap);
+ return BadAlloc;
+ }
+ bzero((char *)&xkb->map->modmap[xkb->max_key_code],tmp);
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbModifierMapMask,maxKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_modmap_keys);
+ }
+ }
+ }
+ if (xkb->server) {
+ if (xkb->server->behaviors) {
+ XkbBehavior *prev_behaviors = xkb->server->behaviors;
+
+ xkb->server->behaviors=_XkbTypedRealloc(xkb->server->behaviors,
+ (maxKC+1),XkbBehavior);
+ if (!xkb->server->behaviors) {
+ _XkbFree(prev_behaviors);
+ return BadAlloc;
+ }
+ bzero((char *)&xkb->server->behaviors[xkb->max_key_code],
+ tmp*sizeof(XkbBehavior));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyBehaviorsMask,maxKC,
+ &changes->map.first_key_behavior,
+ &changes->map.num_key_behaviors);
+ }
+ }
+ if (xkb->server->key_acts) {
+ unsigned short *prev_key_acts = xkb->server->key_acts;
+
+ xkb->server->key_acts= _XkbTypedRealloc(xkb->server->key_acts,
+ (maxKC+1),unsigned short);
+ if (!xkb->server->key_acts) {
+ _XkbFree(prev_key_acts);
+ return BadAlloc;
+ }
+ bzero((char *)&xkb->server->key_acts[xkb->max_key_code],
+ tmp*sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyActionsMask,maxKC,
+ &changes->map.first_key_act,
+ &changes->map.num_key_acts);
+ }
+ }
+ if (xkb->server->vmodmap) {
+ unsigned short *prev_vmodmap = xkb->server->vmodmap;
+
+ xkb->server->vmodmap= _XkbTypedRealloc(xkb->server->vmodmap,
+ (maxKC+1),unsigned short);
+ if (!xkb->server->vmodmap) {
+ _XkbFree(prev_vmodmap);
+ return BadAlloc;
+ }
+ bzero((char *)&xkb->server->vmodmap[xkb->max_key_code],
+ tmp*sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbVirtualModMapMask,maxKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_vmodmap_keys);
+ }
+ }
+ }
+ if ((xkb->names)&&(xkb->names->keys)) {
+ XkbKeyNameRec *prev_keys = xkb->names->keys;
+
+ xkb->names->keys= _XkbTypedRealloc(xkb->names->keys,
+ (maxKC+1),XkbKeyNameRec);
+ if (!xkb->names->keys) {
+ _XkbFree(prev_keys);
+ return BadAlloc;
+ }
+ bzero((char *)&xkb->names->keys[xkb->max_key_code],
+ tmp*sizeof(XkbKeyNameRec));
+ if (changes) {
+ changes->names.changed= _ExtendRange(changes->names.changed,
+ XkbKeyNamesMask,maxKC,
+ &changes->names.first_key,
+ &changes->names.num_keys);
+ }
+ }
+ xkb->max_key_code= maxKC;
+ }
+ return Success;
+}
+
+XkbAction *
+XkbResizeKeyActions(XkbDescPtr xkb,int key,int needed)
+{
+register int i,nActs;
+XkbAction *newActs;
+
+ if (needed==0) {
+ xkb->server->key_acts[key]= 0;
+ return NULL;
+ }
+ if (XkbKeyHasActions(xkb,key)&&(XkbKeyNumSyms(xkb,key)>=(unsigned)needed))
+ return XkbKeyActionsPtr(xkb,key);
+ if (xkb->server->size_acts-xkb->server->num_acts>=(unsigned)needed) {
+ xkb->server->key_acts[key]= xkb->server->num_acts;
+ xkb->server->num_acts+= needed;
+ return &xkb->server->acts[xkb->server->key_acts[key]];
+ }
+ xkb->server->size_acts= xkb->server->num_acts+needed+8;
+ newActs = _XkbTypedCalloc(xkb->server->size_acts,XkbAction);
+ if (newActs==NULL)
+ return NULL;
+ newActs[0].type = XkbSA_NoAction;
+ nActs = 1;
+ for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
+ int nKeyActs,nCopy;
+
+ if ((xkb->server->key_acts[i]==0)&&(i!=key))
+ continue;
+
+ nCopy= nKeyActs= XkbKeyNumActions(xkb,i);
+ if (i==key) {
+ nKeyActs= needed;
+ if (needed<nCopy)
+ nCopy= needed;
+ }
+
+ if (nCopy>0)
+ memcpy(&newActs[nActs],XkbKeyActionsPtr(xkb,i),
+ nCopy*sizeof(XkbAction));
+ if (nCopy<nKeyActs)
+ bzero(&newActs[nActs+nCopy],(nKeyActs-nCopy)*sizeof(XkbAction));
+ xkb->server->key_acts[i]= nActs;
+ nActs+= nKeyActs;
+ }
+ _XkbFree(xkb->server->acts);
+ xkb->server->acts = newActs;
+ xkb->server->num_acts= nActs;
+ return &xkb->server->acts[xkb->server->key_acts[key]];
+}
+
+void
+XkbFreeClientMap(XkbDescPtr xkb,unsigned what,Bool freeMap)
+{
+XkbClientMapPtr map;
+
+ if ((xkb==NULL)||(xkb->map==NULL))
+ return;
+ if (freeMap)
+ what= XkbAllClientInfoMask;
+ map= xkb->map;
+ if (what&XkbKeyTypesMask) {
+ if (map->types!=NULL) {
+ if (map->num_types>0) {
+ register int i;
+ XkbKeyTypePtr type;
+ for (i=0,type=map->types;i<map->num_types;i++,type++) {
+ if (type->map!=NULL) {
+ _XkbFree(type->map);
+ type->map= NULL;
+ }
+ if (type->preserve!=NULL) {
+ _XkbFree(type->preserve);
+ type->preserve= NULL;
+ }
+ type->map_count= 0;
+ if (type->level_names!=NULL) {
+ _XkbFree(type->level_names);
+ type->level_names= NULL;
+ }
+ }
+ }
+ _XkbFree(map->types);
+ map->num_types= map->size_types= 0;
+ map->types= NULL;
+ }
+ }
+ if (what&XkbKeySymsMask) {
+ if (map->key_sym_map!=NULL) {
+ _XkbFree(map->key_sym_map);
+ map->key_sym_map= NULL;
+ }
+ if (map->syms!=NULL) {
+ _XkbFree(map->syms);
+ map->size_syms= map->num_syms= 0;
+ map->syms= NULL;
+ }
+ }
+ if ((what&XkbModifierMapMask)&&(map->modmap!=NULL)) {
+ _XkbFree(map->modmap);
+ map->modmap= NULL;
+ }
+ if (freeMap) {
+ _XkbFree(xkb->map);
+ xkb->map= NULL;
+ }
+ return;
+}
+
+void
+XkbFreeServerMap(XkbDescPtr xkb,unsigned what,Bool freeMap)
+{
+XkbServerMapPtr map;
+
+ if ((xkb==NULL)||(xkb->server==NULL))
+ return;
+ if (freeMap)
+ what= XkbAllServerInfoMask;
+ map= xkb->server;
+ if ((what&XkbExplicitComponentsMask)&&(map->explicit!=NULL)) {
+ _XkbFree(map->explicit);
+ map->explicit= NULL;
+ }
+ if (what&XkbKeyActionsMask) {
+ if (map->key_acts!=NULL) {
+ _XkbFree(map->key_acts);
+ map->key_acts= NULL;
+ }
+ if (map->acts!=NULL) {
+ _XkbFree(map->acts);
+ map->num_acts= map->size_acts= 0;
+ map->acts= NULL;
+ }
+ }
+ if ((what&XkbKeyBehaviorsMask)&&(map->behaviors!=NULL)) {
+ _XkbFree(map->behaviors);
+ map->behaviors= NULL;
+ }
+ if ((what&XkbVirtualModMapMask)&&(map->vmodmap!=NULL)) {
+ _XkbFree(map->vmodmap);
+ map->vmodmap= NULL;
+ }
+
+ if (freeMap) {
+ _XkbFree(xkb->server);
+ xkb->server= NULL;
+ }
+ return;
+}
diff --git a/nx-X11/lib/X11/XKBMisc.c b/nx-X11/lib/X11/XKBMisc.c
new file mode 100644
index 000000000..09f361c19
--- /dev/null
+++ b/nx-X11/lib/X11/XKBMisc.c
@@ -0,0 +1,981 @@
+/* $Xorg: XKBMisc.c,v 1.4 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBMisc.c,v 3.5 2001/10/28 03:32:33 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#elif defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#ifndef XKB_IN_SERVER
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include <X11/keysym.h>
+#include "XKBlibint.h"
+
+#else
+
+#include <stdio.h>
+#include <X11/X.h>
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include <X11/keysym.h>
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+
+#endif /* XKB_IN_SERVER */
+
+/***====================================================================***/
+
+#define mapSize(m) (sizeof(m)/sizeof(XkbKTMapEntryRec))
+static XkbKTMapEntryRec map2Level[]= {
+ { True, ShiftMask, {1, ShiftMask, 0} }
+};
+
+static XkbKTMapEntryRec mapAlpha[]= {
+ { True, ShiftMask, { 1, ShiftMask, 0 } },
+ { True, LockMask, { 0, LockMask, 0 } }
+};
+
+static XkbModsRec preAlpha[]= {
+ { 0, 0, 0 },
+ { LockMask, LockMask, 0 }
+};
+
+#define NL_VMOD_MASK 0
+static XkbKTMapEntryRec mapKeypad[]= {
+ { True, ShiftMask, { 1, ShiftMask, 0 } },
+ { False, 0, { 1, 0, NL_VMOD_MASK } }
+};
+
+static XkbKeyTypeRec canonicalTypes[XkbNumRequiredTypes] = {
+ { { 0, 0, 0 },
+ 1, /* num_levels */
+ 0, /* map_count */
+ NULL, NULL,
+ None, NULL
+ },
+ { { ShiftMask, ShiftMask, 0 },
+ 2, /* num_levels */
+ mapSize(map2Level), /* map_count */
+ map2Level, NULL,
+ None, NULL
+ },
+ { { ShiftMask|LockMask, ShiftMask|LockMask, 0 },
+ 2, /* num_levels */
+ mapSize(mapAlpha), /* map_count */
+ mapAlpha, preAlpha,
+ None, NULL
+ },
+ { { ShiftMask, ShiftMask, NL_VMOD_MASK },
+ 2, /* num_levels */
+ mapSize(mapKeypad), /* map_count */
+ mapKeypad, NULL,
+ None, NULL
+ }
+};
+
+Status
+XkbInitCanonicalKeyTypes(XkbDescPtr xkb,unsigned which,int keypadVMod)
+{
+XkbClientMapPtr map;
+XkbKeyTypePtr from,to;
+Status rtrn;
+
+ if (!xkb)
+ return BadMatch;
+ rtrn= XkbAllocClientMap(xkb,XkbKeyTypesMask,XkbNumRequiredTypes);
+ if (rtrn!=Success)
+ return rtrn;
+ map= xkb->map;
+ if ((which&XkbAllRequiredTypes)==0)
+ return Success;
+ rtrn= Success;
+ from= canonicalTypes;
+ to= map->types;
+ if (which&XkbOneLevelMask)
+ rtrn= XkbCopyKeyType(&from[XkbOneLevelIndex],&to[XkbOneLevelIndex]);
+ if ((which&XkbTwoLevelMask)&&(rtrn==Success))
+ rtrn= XkbCopyKeyType(&from[XkbTwoLevelIndex],&to[XkbTwoLevelIndex]);
+ if ((which&XkbAlphabeticMask)&&(rtrn==Success))
+ rtrn= XkbCopyKeyType(&from[XkbAlphabeticIndex],&to[XkbAlphabeticIndex]);
+ if ((which&XkbKeypadMask)&&(rtrn==Success)) {
+ XkbKeyTypePtr type;
+ rtrn= XkbCopyKeyType(&from[XkbKeypadIndex],&to[XkbKeypadIndex]);
+ type= &to[XkbKeypadIndex];
+ if ((keypadVMod>=0)&&(keypadVMod<XkbNumVirtualMods)&&(rtrn==Success)) {
+ type->mods.vmods= (1<<keypadVMod);
+ type->map[0].active= True;
+ type->map[0].mods.mask= ShiftMask;
+ type->map[0].mods.real_mods= ShiftMask;
+ type->map[0].mods.vmods= 0;
+ type->map[0].level= 1;
+ type->map[1].active= False;
+ type->map[1].mods.mask= 0;
+ type->map[1].mods.real_mods= 0;
+ type->map[1].mods.vmods= (1<<keypadVMod);
+ type->map[1].level= 1;
+ }
+ }
+ return Success;
+}
+
+/***====================================================================***/
+
+#define CORE_SYM(i) (i<map_width?core_syms[i]:NoSymbol)
+#define XKB_OFFSET(g,l) (((g)*groupsWidth)+(l))
+
+int
+XkbKeyTypesForCoreSymbols( XkbDescPtr xkb,
+ int map_width,
+ KeySym * core_syms,
+ unsigned int protected,
+ int * types_inout,
+ KeySym * xkb_syms_rtrn)
+{
+register int i;
+unsigned int empty;
+int nSyms[XkbNumKbdGroups];
+int nGroups,tmp,groupsWidth;
+
+ /* Section 12.2 of the protocol describes this process in more detail */
+ /* Step 1: find the # of symbols in the core mapping per group */
+ groupsWidth= 2;
+ for (i=0;i<XkbNumKbdGroups;i++) {
+ if ((protected&(1<<i))&&(types_inout[i]<xkb->map->num_types)) {
+ nSyms[i]= xkb->map->types[types_inout[i]].num_levels;
+ if (nSyms[i]>groupsWidth)
+ groupsWidth= nSyms[i];
+ }
+ else {
+ types_inout[i]= XkbTwoLevelIndex; /* don't really know, yet */
+ nSyms[i]= 2;
+ }
+ }
+ if (nSyms[XkbGroup1Index]<2)
+ nSyms[XkbGroup1Index]= 2;
+ if (nSyms[XkbGroup2Index]<2)
+ nSyms[XkbGroup2Index]= 2;
+ /* Step 2: Copy the symbols from the core ordering to XKB ordering */
+ /* symbols in the core are in the order: */
+ /* G1L1 G1L2 G2L1 G2L2 [G1L[3-n]] [G2L[3-n]] [G3L*] [G3L*] */
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index,0)]= CORE_SYM(0);
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index,1)]= CORE_SYM(1);
+ for (i=2;i<nSyms[XkbGroup1Index];i++) {
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index,i)]= CORE_SYM(2+i);
+ }
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index,0)]= CORE_SYM(2);
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index,1)]= CORE_SYM(3);
+ tmp= 2+(nSyms[XkbGroup1Index]-2); /* offset to extra group2 syms */
+ for (i=2;i<nSyms[XkbGroup2Index];i++) {
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index,i)]= CORE_SYM(tmp+i);
+ }
+ tmp= nSyms[XkbGroup1Index]+nSyms[XkbGroup2Index];
+ if ((tmp>=map_width)&&
+ ((protected&(XkbExplicitKeyType3Mask|XkbExplicitKeyType4Mask))==0)) {
+ nSyms[XkbGroup3Index]= 0;
+ nSyms[XkbGroup4Index]= 0;
+ nGroups= 2;
+ }
+ else {
+ nGroups= 3;
+ for (i=0;i<nSyms[XkbGroup3Index];i++,tmp++) {
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup3Index,i)]= CORE_SYM(tmp);
+ }
+ if ((tmp<map_width)||(protected&XkbExplicitKeyType4Mask)) {
+ nGroups= 4;
+ for (i=0;i<nSyms[XkbGroup4Index];i++,tmp++) {
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup4Index,i)]= CORE_SYM(tmp);
+ }
+ }
+ else {
+ nSyms[XkbGroup4Index]= 0;
+ }
+ }
+ /* steps 3&4: alphanumeric expansion, assign canonical types */
+ empty= 0;
+ for (i=0;i<nGroups;i++) {
+ KeySym *syms;
+ syms= &xkb_syms_rtrn[XKB_OFFSET(i,0)];
+ if ((nSyms[i]>1)&&(syms[1]==NoSymbol)&&(syms[0]!=NoSymbol)) {
+ KeySym upper,lower;
+ XConvertCase(syms[0],&lower,&upper);
+ if (upper!=lower) {
+ xkb_syms_rtrn[XKB_OFFSET(i,0)]= lower;
+ xkb_syms_rtrn[XKB_OFFSET(i,1)]= upper;
+ if ((protected&(1<<i))==0)
+ types_inout[i]= XkbAlphabeticIndex;
+ }
+ else if ((protected&(1<<i))==0) {
+ types_inout[i]= XkbOneLevelIndex;
+ /* nSyms[i]= 1;*/
+ }
+ }
+ if (((protected&(1<<i))==0)&&(types_inout[i]==XkbTwoLevelIndex)) {
+ if (IsKeypadKey(syms[0])||IsKeypadKey(syms[1]))
+ types_inout[i]= XkbKeypadIndex;
+ else {
+ KeySym upper,lower;
+ XConvertCase(syms[0],&lower,&upper);
+ if ((syms[0]==lower)&&(syms[1]==upper))
+ types_inout[i]= XkbAlphabeticIndex;
+ }
+ }
+ if (syms[0]==NoSymbol) {
+ register int n;
+ Bool found;
+ for (n=1,found=False;(!found)&&(n<nSyms[i]);n++) {
+ found= (syms[n]!=NoSymbol);
+ }
+ if (!found)
+ empty|= (1<<i);
+ }
+ }
+ /* step 5: squoosh out empty groups */
+ if (empty) {
+ for (i=nGroups-1;i>=0;i--) {
+ if (((empty&(1<<i))==0)||(protected&(1<<i)))
+ break;
+ nGroups--;
+ }
+ }
+ if (nGroups<1)
+ return 0;
+
+ /* step 6: replicate group 1 into group two, if necessary */
+ if ((nGroups>1)&&((empty&(XkbGroup1Mask|XkbGroup2Mask))==XkbGroup2Mask)) {
+ if ((protected&(XkbExplicitKeyType1Mask|XkbExplicitKeyType2Mask))==0) {
+ nSyms[XkbGroup2Index]= nSyms[XkbGroup1Index];
+ types_inout[XkbGroup2Index]= types_inout[XkbGroup1Index];
+ memcpy((char *)&xkb_syms_rtrn[2],(char *)xkb_syms_rtrn,
+ 2*sizeof(KeySym));
+ }
+ else if (types_inout[XkbGroup1Index]==types_inout[XkbGroup2Index]) {
+ memcpy((char *)&xkb_syms_rtrn[nSyms[XkbGroup1Index]],
+ (char *)xkb_syms_rtrn,
+ nSyms[XkbGroup1Index]*sizeof(KeySym));
+ }
+ }
+
+ /* step 7: check for all groups identical or all width 1 */
+ if (nGroups>1) {
+ Bool sameType,allOneLevel;
+ allOneLevel= (xkb->map->types[types_inout[0]].num_levels==1);
+ for (i=1,sameType=True;(allOneLevel||sameType)&&(i<nGroups);i++) {
+ sameType=(sameType&&(types_inout[i]==types_inout[XkbGroup1Index]));
+ if (allOneLevel)
+ allOneLevel= (xkb->map->types[types_inout[i]].num_levels==1);
+ }
+ if ((sameType)&&
+ (!(protected&(XkbExplicitKeyTypesMask&~XkbExplicitKeyType1Mask)))){
+ register int s;
+ Bool identical;
+ for (i=1,identical=True;identical&&(i<nGroups);i++) {
+ KeySym *syms;
+ syms= &xkb_syms_rtrn[XKB_OFFSET(i,0)];
+ for (s=0;identical&&(s<nSyms[i]);s++) {
+ if (syms[s]!=xkb_syms_rtrn[s])
+ identical= False;
+ }
+ }
+ if (identical)
+ nGroups= 1;
+ }
+ if (allOneLevel && (nGroups>1)) {
+ KeySym *syms;
+ syms= &xkb_syms_rtrn[nSyms[XkbGroup1Index]];
+ nSyms[XkbGroup1Index]= 1;
+ for (i=1;i<nGroups;i++) {
+ xkb_syms_rtrn[i]= syms[0];
+ syms+= nSyms[i];
+ nSyms[i]= 1;
+ }
+ }
+ }
+ return nGroups;
+}
+
+static XkbSymInterpretPtr
+_XkbFindMatchingInterp( XkbDescPtr xkb,
+ KeySym sym,
+ unsigned int real_mods,
+ unsigned int level)
+{
+register unsigned i;
+XkbSymInterpretPtr interp,rtrn;
+CARD8 mods;
+
+ rtrn= NULL;
+ interp= xkb->compat->sym_interpret;
+ for (i=0;i<xkb->compat->num_si;i++,interp++) {
+ if ((interp->sym==NoSymbol)||(sym==interp->sym)) {
+ int match;
+ if ((level==0)||((interp->match&XkbSI_LevelOneOnly)==0))
+ mods= real_mods;
+ else mods= 0;
+ switch (interp->match&XkbSI_OpMask) {
+ case XkbSI_NoneOf:
+ match= ((interp->mods&mods)==0);
+ break;
+ case XkbSI_AnyOfOrNone:
+ match= ((mods==0)||((interp->mods&mods)!=0));
+ break;
+ case XkbSI_AnyOf:
+ match= ((interp->mods&mods)!=0);
+ break;
+ case XkbSI_AllOf:
+ match= ((interp->mods&mods)==interp->mods);
+ break;
+ case XkbSI_Exactly:
+ match= (interp->mods==mods);
+ break;
+ default:
+ match= 0;
+ break;
+ }
+ if (match) {
+ if (interp->sym!=NoSymbol) {
+ return interp;
+ }
+ else if (rtrn==NULL) {
+ rtrn= interp;
+ }
+ }
+ }
+ }
+ return rtrn;
+}
+
+static void
+_XkbAddKeyChange(KeyCode *pFirst,unsigned char *pNum,KeyCode newKey)
+{
+KeyCode last;
+
+ last= (*pFirst)+(*pNum);
+ if (newKey<*pFirst) {
+ *pFirst= newKey;
+ *pNum= (last-newKey)+1;
+ }
+ else if (newKey>last) {
+ *pNum= (last-*pFirst)+1;
+ }
+ return;
+}
+
+static void
+_XkbSetActionKeyMods(XkbDescPtr xkb,XkbAction *act,unsigned mods)
+{
+unsigned tmp;
+
+ switch (act->type) {
+ case XkbSA_SetMods: case XkbSA_LatchMods: case XkbSA_LockMods:
+ if (act->mods.flags&XkbSA_UseModMapMods)
+ act->mods.real_mods= act->mods.mask= mods;
+ if ((tmp= XkbModActionVMods(&act->mods))!=0) {
+ XkbVirtualModsToReal(xkb,tmp,&tmp);
+ act->mods.mask|= tmp;
+ }
+ break;
+ case XkbSA_ISOLock:
+ if (act->iso.flags&XkbSA_UseModMapMods)
+ act->iso.real_mods= act->iso.mask= mods;
+ if ((tmp= XkbModActionVMods(&act->iso))!=0) {
+ XkbVirtualModsToReal(xkb,tmp,&tmp);
+ act->iso.mask|= tmp;
+ }
+ break;
+ }
+ return;
+}
+
+#define IBUF_SIZE 8
+
+Bool
+XkbApplyCompatMapToKey(XkbDescPtr xkb,KeyCode key,XkbChangesPtr changes)
+{
+KeySym * syms;
+unsigned char explicit,mods;
+XkbSymInterpretPtr *interps,ibuf[IBUF_SIZE];
+int n,nSyms,found;
+unsigned changed,tmp;
+
+ if ((!xkb)||(!xkb->map)||(!xkb->map->key_sym_map)||
+ (!xkb->compat)||(!xkb->compat->sym_interpret)||
+ (key<xkb->min_key_code)||(key>xkb->max_key_code)) {
+ return False;
+ }
+ if (((!xkb->server)||(!xkb->server->key_acts))&&
+ (XkbAllocServerMap(xkb,XkbAllServerInfoMask,0)!=Success)) {
+ return False;
+ }
+ changed= 0; /* keeps track of what has changed in _this_ call */
+ explicit= xkb->server->explicit[key];
+ if (explicit&XkbExplicitInterpretMask) /* nothing to do */
+ return True;
+ mods= (xkb->map->modmap?xkb->map->modmap[key]:0);
+ nSyms= XkbKeyNumSyms(xkb,key);
+ syms= XkbKeySymsPtr(xkb,key);
+ if (nSyms>IBUF_SIZE) {
+ interps= _XkbTypedCalloc(nSyms,XkbSymInterpretPtr);
+ if (interps==NULL) {
+ interps= ibuf;
+ nSyms= IBUF_SIZE;
+ }
+ }
+ else {
+ interps= ibuf;
+ }
+ found= 0;
+ for (n=0;n<nSyms;n++) {
+ unsigned level= (n%XkbKeyGroupsWidth(xkb,key));
+ interps[n]= NULL;
+ if (syms[n]!=NoSymbol) {
+ interps[n]= _XkbFindMatchingInterp(xkb,syms[n],mods,level);
+ if (interps[n]&&interps[n]->act.type!=XkbSA_NoAction)
+ found++;
+ else interps[n]= NULL;
+ }
+ }
+ /* 1/28/96 (ef) -- XXX! WORKING HERE */
+ if (!found) {
+ if (xkb->server->key_acts[key]!=0) {
+ xkb->server->key_acts[key]= 0;
+ changed|= XkbKeyActionsMask;
+ }
+ }
+ else {
+ XkbAction *pActs;
+ unsigned int new_vmodmask;
+ changed|= XkbKeyActionsMask;
+ pActs= XkbResizeKeyActions(xkb,key,nSyms);
+ if (!pActs)
+ return False;
+ new_vmodmask= 0;
+ for (n=0;n<nSyms;n++) {
+ if (interps[n]) {
+ unsigned effMods;
+
+ pActs[n]= *((XkbAction *)&interps[n]->act);
+ if ((n==0)||((interps[n]->match&XkbSI_LevelOneOnly)==0)) {
+ effMods= mods;
+ if (interps[n]->virtual_mod!=XkbNoModifier)
+ new_vmodmask|= (1<<interps[n]->virtual_mod);
+ }
+ else effMods= 0;
+ _XkbSetActionKeyMods(xkb,&pActs[n],effMods);
+ }
+ else pActs[n].type= XkbSA_NoAction;
+ }
+ if (((explicit&XkbExplicitVModMapMask)==0)&&
+ (xkb->server->vmodmap[key]!=new_vmodmask)) {
+ changed|= XkbVirtualModMapMask;
+ xkb->server->vmodmap[key]= new_vmodmask;
+ }
+ if (interps[0]) {
+ if ((interps[0]->flags&XkbSI_LockingKey)&&
+ ((explicit&XkbExplicitBehaviorMask)==0)) {
+ xkb->server->behaviors[key].type= XkbKB_Lock;
+ changed|= XkbKeyBehaviorsMask;
+ }
+ if (((explicit&XkbExplicitAutoRepeatMask)==0)&&(xkb->ctrls)) {
+ CARD8 old;
+ old= xkb->ctrls->per_key_repeat[key/8];
+ if (interps[0]->flags&XkbSI_AutoRepeat)
+ xkb->ctrls->per_key_repeat[key/8]|= (1<<(key%8));
+ else xkb->ctrls->per_key_repeat[key/8]&= ~(1<<(key%8));
+ if (changes && (old!=xkb->ctrls->per_key_repeat[key/8]))
+ changes->ctrls.changed_ctrls|= XkbPerKeyRepeatMask;
+ }
+ }
+ }
+ if ((!found)||(interps[0]==NULL)) {
+ if (((explicit&XkbExplicitAutoRepeatMask)==0)&&(xkb->ctrls)) {
+ CARD8 old;
+ old= xkb->ctrls->per_key_repeat[key/8];
+#ifdef RETURN_SHOULD_REPEAT
+ if (*XkbKeySymsPtr(xkb,key) != XK_Return)
+#endif
+ xkb->ctrls->per_key_repeat[key/8]|= (1<<(key%8));
+ if (changes && (old!=xkb->ctrls->per_key_repeat[key/8]))
+ changes->ctrls.changed_ctrls|= XkbPerKeyRepeatMask;
+ }
+ if (((explicit&XkbExplicitBehaviorMask)==0)&&
+ (xkb->server->behaviors[key].type==XkbKB_Lock)) {
+ xkb->server->behaviors[key].type= XkbKB_Default;
+ changed|= XkbKeyBehaviorsMask;
+ }
+ }
+ if (changes) {
+ XkbMapChangesPtr mc;
+ mc= &changes->map;
+ tmp= (changed&mc->changed);
+ if (tmp&XkbKeyActionsMask)
+ _XkbAddKeyChange(&mc->first_key_act,&mc->num_key_acts,key);
+ else if (changed&XkbKeyActionsMask) {
+ mc->changed|= XkbKeyActionsMask;
+ mc->first_key_act= key;
+ mc->num_key_acts= 1;
+ }
+ if (tmp&XkbKeyBehaviorsMask) {
+ _XkbAddKeyChange(&mc->first_key_behavior,&mc->num_key_behaviors,
+ key);
+ }
+ else if (changed&XkbKeyBehaviorsMask) {
+ mc->changed|= XkbKeyBehaviorsMask;
+ mc->first_key_behavior= key;
+ mc->num_key_behaviors= 1;
+ }
+ if (tmp&XkbVirtualModMapMask)
+ _XkbAddKeyChange(&mc->first_vmodmap_key,&mc->num_vmodmap_keys,key);
+ else if (changed&XkbVirtualModMapMask) {
+ mc->changed|= XkbVirtualModMapMask;
+ mc->first_vmodmap_key= key;
+ mc->num_vmodmap_keys= 1;
+ }
+ mc->changed|= changed;
+ }
+ if (interps!=ibuf)
+ _XkbFree(interps);
+ return True;
+}
+
+Bool
+XkbUpdateMapFromCore( XkbDescPtr xkb,
+ KeyCode first_key,
+ int num_keys,
+ int map_width,
+ KeySym * core_keysyms,
+ XkbChangesPtr changes)
+{
+register int key,last_key;
+KeySym * syms;
+
+ syms= &core_keysyms[(first_key-xkb->min_key_code)*map_width];
+ if (changes) {
+ if (changes->map.changed&XkbKeySymsMask) {
+ _XkbAddKeyChange(&changes->map.first_key_sym,
+ &changes->map.num_key_syms,first_key);
+ if (num_keys>1) {
+ _XkbAddKeyChange(&changes->map.first_key_sym,
+ &changes->map.num_key_syms,
+ first_key+num_keys-1);
+ }
+ }
+ else {
+ changes->map.changed|= XkbKeySymsMask;
+ changes->map.first_key_sym= first_key;
+ changes->map.num_key_syms= num_keys;
+ }
+ }
+ last_key= first_key+num_keys-1;
+ for (key=first_key;key<=last_key;key++,syms+= map_width) {
+ XkbMapChangesPtr mc;
+ unsigned explicit;
+ KeySym tsyms[XkbMaxSymsPerKey];
+ int types[XkbNumKbdGroups];
+ int nG;
+
+ explicit= xkb->server->explicit[key]&XkbExplicitKeyTypesMask;
+ types[XkbGroup1Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup1Index);
+ types[XkbGroup2Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup2Index);
+ types[XkbGroup3Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup3Index);
+ types[XkbGroup4Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup4Index);
+ nG= XkbKeyTypesForCoreSymbols(xkb,map_width,syms,explicit,types,tsyms);
+ if (changes)
+ mc= &changes->map;
+ else mc= NULL;
+ XkbChangeTypesOfKey(xkb,key,nG,XkbAllGroupsMask,types,mc);
+ memcpy((char *)XkbKeySymsPtr(xkb,key),(char *)tsyms,
+ XkbKeyNumSyms(xkb,key)*sizeof(KeySym));
+ XkbApplyCompatMapToKey(xkb,key,changes);
+ }
+
+ if ((xkb->server->vmods!=NULL)&&(xkb->map->modmap!=NULL)&&(changes)&&
+ (changes->map.changed&(XkbVirtualModMapMask|XkbModifierMapMask))) {
+ unsigned char newVMods[XkbNumVirtualMods];
+ register unsigned bit,i;
+ unsigned present;
+
+ bzero(newVMods,XkbNumVirtualMods);
+ present= 0;
+ for (key=xkb->min_key_code;key<=xkb->max_key_code;key++) {
+ if (xkb->server->vmodmap[key]==0)
+ continue;
+ for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (bit&xkb->server->vmodmap[key]) {
+ present|= bit;
+ newVMods[i]|= xkb->map->modmap[key];
+ }
+ }
+ }
+ for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if ((bit&present)&&(newVMods[i]!=xkb->server->vmods[i])) {
+ changes->map.changed|= XkbVirtualModsMask;
+ changes->map.vmods|= bit;
+ xkb->server->vmods[i]= newVMods[i];
+ }
+ }
+ }
+ if (changes && (changes->map.changed&XkbVirtualModsMask))
+ XkbApplyVirtualModChanges(xkb,changes->map.vmods,changes);
+ return True;
+}
+
+Status
+XkbChangeTypesOfKey( XkbDescPtr xkb,
+ int key,
+ int nGroups,
+ unsigned groups,
+ int * newTypesIn,
+ XkbMapChangesPtr changes)
+{
+XkbKeyTypePtr pOldType,pNewType;
+register int i;
+int width,nOldGroups,oldWidth,newTypes[XkbNumKbdGroups];
+
+ if ((!xkb) || (!XkbKeycodeInRange(xkb,key)) || (!xkb->map) ||
+ (!xkb->map->types)||(!newTypes)||((groups&XkbAllGroupsMask)==0)||
+ (nGroups>XkbNumKbdGroups)) {
+ return BadMatch;
+ }
+ if (nGroups==0) {
+ for (i=0;i<XkbNumKbdGroups;i++) {
+ xkb->map->key_sym_map[key].kt_index[i]= XkbOneLevelIndex;
+ }
+ i= xkb->map->key_sym_map[key].group_info;
+ i= XkbSetNumGroups(i,0);
+ xkb->map->key_sym_map[key].group_info= i;
+ XkbResizeKeySyms(xkb,key,0);
+ return Success;
+ }
+
+ nOldGroups= XkbKeyNumGroups(xkb,key);
+ oldWidth= XkbKeyGroupsWidth(xkb,key);
+ for (width=i=0;i<nGroups;i++) {
+ if (groups&(1<<i))
+ newTypes[i]= newTypesIn[i];
+ else if (i<nOldGroups)
+ newTypes[i]= XkbKeyKeyTypeIndex(xkb,key,i);
+ else if (nOldGroups>0)
+ newTypes[i]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup1Index);
+ else newTypes[i]= XkbTwoLevelIndex;
+ if (newTypes[i]>xkb->map->num_types)
+ return BadMatch;
+ pNewType= &xkb->map->types[newTypes[i]];
+ if (pNewType->num_levels>width)
+ width= pNewType->num_levels;
+ }
+ if ((xkb->ctrls)&&(nGroups>xkb->ctrls->num_groups))
+ xkb->ctrls->num_groups= nGroups;
+ if ((width!=oldWidth)||(nGroups!=nOldGroups)) {
+ KeySym oldSyms[XkbMaxSymsPerKey],*pSyms;
+ int nCopy;
+
+ if (nOldGroups==0) {
+ pSyms= XkbResizeKeySyms(xkb,key,width*nGroups);
+ if (pSyms!=NULL) {
+ i= xkb->map->key_sym_map[key].group_info;
+ i= XkbSetNumGroups(i,nGroups);
+ xkb->map->key_sym_map[key].group_info= i;
+ xkb->map->key_sym_map[key].width= width;
+ for (i=0;i<nGroups;i++) {
+ xkb->map->key_sym_map[key].kt_index[i]= newTypes[i];
+ }
+ return Success;
+ }
+ return BadAlloc;
+ }
+ pSyms= XkbKeySymsPtr(xkb,key);
+ memcpy(oldSyms,pSyms,XkbKeyNumSyms(xkb,key)*sizeof(KeySym));
+ pSyms= XkbResizeKeySyms(xkb,key,width*nGroups);
+ if (pSyms==NULL)
+ return BadAlloc;
+ bzero(pSyms,width*nGroups*sizeof(KeySym));
+ for (i=0;(i<nGroups)&&(i<nOldGroups);i++) {
+ pOldType= XkbKeyKeyType(xkb,key,i);
+ pNewType= &xkb->map->types[newTypes[i]];
+ if (pNewType->num_levels>pOldType->num_levels)
+ nCopy= pOldType->num_levels;
+ else nCopy= pNewType->num_levels;
+ memcpy(&pSyms[i*width],&oldSyms[i*oldWidth],nCopy*sizeof(KeySym));
+ }
+ if (XkbKeyHasActions(xkb,key)) {
+ XkbAction oldActs[XkbMaxSymsPerKey],*pActs;
+ pActs= XkbKeyActionsPtr(xkb,key);
+ memcpy(oldActs,pActs,XkbKeyNumSyms(xkb,key)*sizeof(XkbAction));
+ pActs= XkbResizeKeyActions(xkb,key,width*nGroups);
+ if (pActs==NULL)
+ return BadAlloc;
+ bzero(pActs,width*nGroups*sizeof(XkbAction));
+ for (i=0;(i<nGroups)&&(i<nOldGroups);i++) {
+ pOldType= XkbKeyKeyType(xkb,key,i);
+ pNewType= &xkb->map->types[newTypes[i]];
+ if (pNewType->num_levels>pOldType->num_levels)
+ nCopy= pOldType->num_levels;
+ else nCopy= pNewType->num_levels;
+ memcpy(&pActs[i*width],&oldActs[i*oldWidth],
+ nCopy*sizeof(XkbAction));
+ }
+ }
+ i= xkb->map->key_sym_map[key].group_info;
+ i= XkbSetNumGroups(i,nGroups);
+ xkb->map->key_sym_map[key].group_info= i;
+ xkb->map->key_sym_map[key].width= width;
+ }
+ width= 0;
+ for (i=0;i<nGroups;i++) {
+ xkb->map->key_sym_map[key].kt_index[i]= newTypes[i];
+ if (xkb->map->types[newTypes[i]].num_levels>width)
+ width= xkb->map->types[newTypes[i]].num_levels;
+ }
+ xkb->map->key_sym_map[key].width= width;
+ if (changes!=NULL) {
+ if (changes->changed&XkbKeySymsMask) {
+ _XkbAddKeyChange(&changes->first_key_sym,&changes->num_key_syms,
+ key);
+ }
+ else {
+ changes->changed|= XkbKeySymsMask;
+ changes->first_key_sym= key;
+ changes->num_key_syms= 1;
+ }
+ }
+ return Success;
+}
+
+/***====================================================================***/
+
+Bool
+XkbVirtualModsToReal(XkbDescPtr xkb,unsigned virtual_mask,unsigned *mask_rtrn)
+{
+register int i,bit;
+register unsigned mask;
+
+ if (xkb==NULL)
+ return False;
+ if (virtual_mask==0) {
+ *mask_rtrn= 0;
+ return True;
+ }
+ if (xkb->server==NULL)
+ return False;
+ for (i=mask=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (virtual_mask&bit)
+ mask|= xkb->server->vmods[i];
+ }
+ *mask_rtrn= mask;
+ return True;
+}
+
+/***====================================================================***/
+
+Bool
+XkbUpdateActionVirtualMods(XkbDescPtr xkb,XkbAction *act,unsigned changed)
+{
+unsigned int tmp;
+
+ switch (act->type) {
+ case XkbSA_SetMods: case XkbSA_LatchMods: case XkbSA_LockMods:
+ if (((tmp= XkbModActionVMods(&act->mods))&changed)!=0) {
+ XkbVirtualModsToReal(xkb,tmp,&tmp);
+ act->mods.mask= act->mods.real_mods;
+ act->mods.mask|= tmp;
+ return True;
+ }
+ break;
+ case XkbSA_ISOLock:
+ if ((((tmp= XkbModActionVMods(&act->iso))!=0)&changed)!=0) {
+ XkbVirtualModsToReal(xkb,tmp,&tmp);
+ act->iso.mask= act->iso.real_mods;
+ act->iso.mask|= tmp;
+ return True;
+ }
+ break;
+ }
+ return False;
+}
+
+void
+XkbUpdateKeyTypeVirtualMods( XkbDescPtr xkb,
+ XkbKeyTypePtr type,
+ unsigned int changed,
+ XkbChangesPtr changes)
+{
+register unsigned int i;
+unsigned int mask;
+
+ XkbVirtualModsToReal(xkb,type->mods.vmods,&mask);
+ type->mods.mask= type->mods.real_mods|mask;
+ if ((type->map_count>0)&&(type->mods.vmods!=0)) {
+ XkbKTMapEntryPtr entry;
+ for (i=0,entry=type->map;i<type->map_count;i++,entry++) {
+ if (entry->mods.vmods!=0) {
+ XkbVirtualModsToReal(xkb,entry->mods.vmods,&mask);
+ entry->mods.mask=entry->mods.real_mods|mask;
+ /* entry is active if vmods are bound*/
+ entry->active= (mask!=0);
+ }
+ else entry->active= 1;
+ }
+ }
+ if (changes) {
+ int type_ndx;
+ type_ndx= type-xkb->map->types;
+ if ((type_ndx<0)||(type_ndx>xkb->map->num_types))
+ return;
+ if (changes->map.changed&XkbKeyTypesMask) {
+ int last;
+ last= changes->map.first_type+changes->map.num_types-1;
+ if (type_ndx<changes->map.first_type) {
+ changes->map.first_type= type_ndx;
+ changes->map.num_types= (last-type_ndx)+1;
+ }
+ else if (type_ndx>last) {
+ changes->map.num_types= (type_ndx-changes->map.first_type)+1;
+ }
+ }
+ else {
+ changes->map.changed|= XkbKeyTypesMask;
+ changes->map.first_type= type_ndx;
+ changes->map.num_types= 1;
+ }
+ }
+ return;
+}
+
+Bool
+XkbApplyVirtualModChanges(XkbDescPtr xkb,unsigned changed,XkbChangesPtr changes)
+{
+register int i;
+unsigned int checkState = 0;
+
+ if ((!xkb) || (!xkb->map) || (changed==0))
+ return False;
+ for (i=0;i<xkb->map->num_types;i++) {
+ if (xkb->map->types[i].mods.vmods & changed)
+ XkbUpdateKeyTypeVirtualMods(xkb,&xkb->map->types[i],changed,changes);
+ }
+ if (changed&xkb->ctrls->internal.vmods) {
+ unsigned int newMask;
+ XkbVirtualModsToReal(xkb,xkb->ctrls->internal.vmods,&newMask);
+ newMask|= xkb->ctrls->internal.real_mods;
+ if (xkb->ctrls->internal.mask!=newMask) {
+ xkb->ctrls->internal.mask= newMask;
+ if (changes) {
+ changes->ctrls.changed_ctrls|= XkbInternalModsMask;
+ checkState= True;
+ }
+ }
+ }
+ if (changed&xkb->ctrls->ignore_lock.vmods) {
+ unsigned int newMask;
+ XkbVirtualModsToReal(xkb,xkb->ctrls->ignore_lock.vmods,&newMask);
+ newMask|= xkb->ctrls->ignore_lock.real_mods;
+ if (xkb->ctrls->ignore_lock.mask!=newMask) {
+ xkb->ctrls->ignore_lock.mask= newMask;
+ if (changes) {
+ changes->ctrls.changed_ctrls|= XkbIgnoreLockModsMask;
+ checkState= True;
+ }
+ }
+ }
+ if (xkb->indicators!=NULL) {
+ XkbIndicatorMapPtr map;
+ map= &xkb->indicators->maps[0];
+ for (i=0;i<XkbNumIndicators;i++,map++) {
+ if (map->mods.vmods&changed) {
+ unsigned int newMask;
+ XkbVirtualModsToReal(xkb,map->mods.vmods,&newMask);
+ newMask|= map->mods.real_mods;
+ if (newMask!=map->mods.mask) {
+ map->mods.mask= newMask;
+ if (changes) {
+ changes->indicators.map_changes|= (1<<i);
+ checkState= True;
+ }
+ }
+ }
+ }
+ }
+ if (xkb->compat!=NULL) {
+ XkbCompatMapPtr compat;
+ compat= xkb->compat;
+ for (i=0;i<XkbNumKbdGroups;i++) {
+ unsigned int newMask;
+ XkbVirtualModsToReal(xkb,compat->groups[i].vmods,&newMask);
+ newMask|= compat->groups[i].real_mods;
+ if (compat->groups[i].mask!=newMask) {
+ compat->groups[i].mask= newMask;
+ if (changes) {
+ changes->compat.changed_groups|= (1<<i);
+ checkState= True;
+ }
+ }
+ }
+ }
+ if (xkb->map && xkb->server) {
+ int highChange = 0, lowChange = -1;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ if (XkbKeyHasActions(xkb,i)) {
+ register XkbAction *pAct;
+ register int n;
+
+ pAct= XkbKeyActionsPtr(xkb,i);
+ for (n=XkbKeyNumActions(xkb,i);n>0;n--,pAct++) {
+ if ((pAct->type!=XkbSA_NoAction)&&
+ XkbUpdateActionVirtualMods(xkb,pAct,changed)) {
+ if (lowChange<0)
+ lowChange= i;
+ highChange= i;
+ }
+ }
+ }
+ }
+ if (changes && (lowChange>0)) { /* something changed */
+ if (changes->map.changed&XkbKeyActionsMask) {
+ int last;
+ if (changes->map.first_key_act<lowChange)
+ lowChange= changes->map.first_key_act;
+ last= changes->map.first_key_act+changes->map.num_key_acts-1;
+ if (last>highChange)
+ highChange= last;
+ }
+ changes->map.changed|= XkbKeyActionsMask;
+ changes->map.first_key_act= lowChange;
+ changes->map.num_key_acts= (highChange-lowChange)+1;
+ }
+ }
+ return checkState;
+}
diff --git a/nx-X11/lib/X11/XKBNames.c b/nx-X11/lib/X11/XKBNames.c
new file mode 100644
index 000000000..a8eeb2adf
--- /dev/null
+++ b/nx-X11/lib/X11/XKBNames.c
@@ -0,0 +1,891 @@
+/* $Xorg: XKBNames.c,v 1.3 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBNames.c,v 1.5 2003/04/13 19:22:18 dawes Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#define NEED_MAP_READERS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+
+static Status
+_XkbReadAtoms( XkbReadBufferPtr buf,
+ Atom * atoms,
+ int maxAtoms,
+ CARD32 present)
+{
+register int i,bit;
+
+ for (i=0,bit=1;(i<maxAtoms)&&(present);i++,bit<<=1) {
+ if (present&bit) {
+ if (!_XkbReadBufferCopy32(buf,(long *)&atoms[i],1))
+ return BadLength;
+ present&= ~bit;
+ }
+ }
+ return Success;
+}
+
+Status
+_XkbReadGetNamesReply( Display * dpy,
+ xkbGetNamesReply * rep,
+ XkbDescPtr xkb,
+ int * nread_rtrn)
+{
+ int i,len;
+ XkbReadBufferRec buf;
+ register XkbNamesPtr names;
+
+ if ( xkb->device_spec == XkbUseCoreKbd )
+ xkb->device_spec = rep->deviceID;
+
+ if ((xkb->names==NULL)&&
+ (XkbAllocNames(xkb,rep->which,
+ rep->nRadioGroups,rep->nKeyAliases)!=Success)) {
+ return BadAlloc;
+ }
+ names= xkb->names;
+ if (rep->length==0)
+ return Success;
+
+ if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
+ return BadAlloc;
+ if (nread_rtrn)
+ *nread_rtrn= (int)rep->length*4;
+
+ if ((rep->which&XkbKeycodesNameMask)&&
+ (!_XkbReadBufferCopy32(&buf,(long *)&names->keycodes,1)))
+ goto BAILOUT;
+ if ((rep->which&XkbGeometryNameMask)&&
+ (!_XkbReadBufferCopy32(&buf,(long *)&names->geometry,1)))
+ goto BAILOUT;
+ if ((rep->which&XkbSymbolsNameMask)&&
+ (!_XkbReadBufferCopy32(&buf,(long *)&names->symbols,1)))
+ goto BAILOUT;
+ if ((rep->which&XkbPhysSymbolsNameMask)&&
+ (!_XkbReadBufferCopy32(&buf,(long *)&names->phys_symbols,1)))
+ goto BAILOUT;
+ if ((rep->which&XkbTypesNameMask)&&
+ (!_XkbReadBufferCopy32(&buf,(long *)&names->types,1)))
+ goto BAILOUT;
+ if ((rep->which&XkbCompatNameMask)&&
+ (!_XkbReadBufferCopy32(&buf,(long *)&names->compat,1)))
+ goto BAILOUT;
+
+ if ( rep->which & XkbKeyTypeNamesMask ) {
+ XkbClientMapPtr map= xkb->map;
+ XkbKeyTypePtr type;
+
+ len= rep->nTypes*4;
+ if (map!=NULL) {
+ type= map->types;
+ for (i=0;(i<map->num_types)&&(i<rep->nTypes);i++,type++) {
+ if (!_XkbReadBufferCopy32(&buf,(long *)&type->name,1))
+ goto BAILOUT;
+ len-= 4;
+ }
+ }
+ if ((len>0)&&(!_XkbSkipReadBufferData(&buf,len)))
+ goto BAILOUT;
+ }
+ if ( rep->which&XkbKTLevelNamesMask ) {
+ CARD8 *nLevels;
+ XkbClientMapPtr map= xkb->map;
+ XkbKeyTypePtr type;
+
+ nLevels=(CARD8*)_XkbGetReadBufferPtr(&buf,XkbPaddedSize(rep->nTypes));
+ if (nLevels==NULL)
+ goto BAILOUT;
+ if (map!=NULL) {
+ type= map->types;
+ for (i=0;i<(int)rep->nTypes;i++,type++) {
+ if (i>=map->num_types) {
+ if (!_XkbSkipReadBufferData(&buf,nLevels[i]*4))
+ goto BAILOUT;
+ continue;
+ }
+ if ((nLevels[i]>0)&&(nLevels[i]!=type->num_levels)) {
+ goto BAILOUT;
+ }
+ if (type->level_names!=NULL)
+ Xfree(type->level_names);
+ if (nLevels[i]==0) {
+ type->level_names= NULL;
+ continue;
+ }
+ type->level_names= _XkbTypedCalloc(nLevels[i],Atom);
+ if (type->level_names!=NULL) {
+ if (!_XkbReadBufferCopy32(&buf,(long *)type->level_names,
+ nLevels[i]))
+ goto BAILOUT;
+ }
+ else {
+ _XkbSkipReadBufferData(&buf,nLevels[i]*4);
+ }
+ }
+ }
+ else {
+ for (i=0;i<(int)rep->nTypes;i++) {
+ _XkbSkipReadBufferData(&buf,nLevels[i]*4);
+ }
+ }
+ }
+ if (rep->which & XkbIndicatorNamesMask) {
+ if (_XkbReadAtoms(&buf,names->indicators,XkbNumIndicators,
+ rep->indicators)!=Success)
+ goto BAILOUT;
+ }
+ if ( rep->which&XkbVirtualModNamesMask ) {
+ if (_XkbReadAtoms(&buf,names->vmods,XkbNumVirtualMods,
+ (CARD32)rep->virtualMods)!=Success)
+ goto BAILOUT;
+ }
+ if ( rep->which&XkbGroupNamesMask ) {
+ if (_XkbReadAtoms(&buf,names->groups,XkbNumKbdGroups,
+ (CARD32)rep->groupNames)!=Success)
+ goto BAILOUT;
+ }
+ if ( rep->which&XkbKeyNamesMask ) {
+ if (names->keys==NULL) {
+ int nKeys;
+ if (xkb->max_key_code==0) {
+ xkb->min_key_code= rep->minKeyCode;
+ xkb->max_key_code= rep->maxKeyCode;
+ }
+ nKeys= xkb->max_key_code+1;
+ names->keys= _XkbTypedCalloc(nKeys,XkbKeyNameRec);
+ }
+ if (names->keys!=NULL) {
+ if (!_XkbCopyFromReadBuffer(&buf,
+ (char *)&names->keys[rep->firstKey],
+ rep->nKeys*XkbKeyNameLength))
+ goto BAILOUT;
+ }
+ else _XkbSkipReadBufferData(&buf,rep->nKeys*XkbKeyNameLength);
+ }
+ if ( rep->which&XkbKeyAliasesMask && (rep->nKeyAliases>0) ) {
+ if (XkbAllocNames(xkb,XkbKeyAliasesMask,0,rep->nKeyAliases)!=Success)
+ goto BAILOUT;
+ if (!_XkbCopyFromReadBuffer(&buf,(char *)names->key_aliases,
+ rep->nKeyAliases*XkbKeyNameLength*2))
+ goto BAILOUT;
+ }
+ if ( rep->which&XkbRGNamesMask ) {
+ if (rep->nRadioGroups>0) {
+ Atom *rgNames;
+
+ if (names->radio_groups==NULL)
+ names->radio_groups = _XkbTypedCalloc(rep->nRadioGroups,Atom);
+ else if (names->num_rg<rep->nRadioGroups) {
+ names->radio_groups = _XkbTypedRealloc(names->radio_groups,
+ rep->nRadioGroups,
+ Atom);
+ }
+ rgNames= names->radio_groups;
+ if (!rgNames) {
+ goto BAILOUT;
+ }
+ if (!_XkbReadBufferCopy32(&buf,(long *)rgNames,rep->nRadioGroups))
+ goto BAILOUT;
+ names->num_rg= rep->nRadioGroups;
+ }
+ else if (names->num_rg>0) {
+ names->num_rg= 0;
+ Xfree(names->radio_groups);
+ }
+ }
+ len= _XkbFreeReadBuffer(&buf);
+ if (len!=0) return BadLength;
+ else return Success;
+BAILOUT:
+ _XkbFreeReadBuffer(&buf);
+ return BadLength;
+}
+
+Status
+XkbGetNames(Display *dpy,unsigned which,XkbDescPtr xkb)
+{
+ register xkbGetNamesReq *req;
+ xkbGetNamesReply rep;
+ Status status;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ if (!xkb->names) {
+ xkb->names = _XkbTypedCalloc(1,XkbNamesRec);
+ if (!xkb->names) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadAlloc;
+ }
+ }
+ GetReq(kbGetNames, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetNames;
+ req->deviceSpec = xkb->device_spec;
+ req->which = which;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadImplementation;
+ }
+
+ status = _XkbReadGetNamesReply(dpy,&rep,xkb,NULL);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+/***====================================================================***/
+
+static int
+_XkbCountBits(int nBitsMax,unsigned long mask)
+{
+register unsigned long y, nBits;
+
+ y = (mask >> 1) &033333333333;
+ y = mask - y - ((y >>1) & 033333333333);
+ nBits = ((unsigned int) (((y + (y >> 3)) & 030707070707) % 077));
+
+ /* nBitsMax really means max+1 */
+ return (nBits < nBitsMax) ? nBits : (nBitsMax - 1);
+}
+
+static CARD32
+_XkbCountAtoms(Atom *atoms,int maxAtoms,int *count)
+{
+register unsigned int i,bit,nAtoms;
+register CARD32 atomsPresent;
+
+ for (i=nAtoms=atomsPresent=0,bit=1;i<maxAtoms;i++,bit<<=1) {
+ if (atoms[i]!=None) {
+ atomsPresent|= bit;
+ nAtoms++;
+ }
+ }
+ if (count)
+ *count= nAtoms;
+ return atomsPresent;
+}
+
+static void
+_XkbCopyAtoms(Display *dpy,Atom *atoms,CARD32 mask,int maxAtoms)
+{
+register unsigned int i,bit;
+
+ for (i=0,bit=1;i<maxAtoms;i++,bit<<=1) {
+ if (mask&bit)
+ Data32(dpy,&atoms[i],4);
+ }
+ return;
+}
+
+Bool
+XkbSetNames( Display * dpy,
+ unsigned int which,
+ unsigned int firstType,
+ unsigned int nTypes,
+ XkbDescPtr xkb)
+{
+ register xkbSetNamesReq *req;
+ int nLvlNames = 0;
+ XkbInfoPtr xkbi;
+ XkbNamesPtr names;
+ unsigned firstLvlType,nLvlTypes;
+ int nVMods,nLEDs,nRG,nKA,nGroups;
+ int nKeys=0,firstKey=0,nAtoms;
+ CARD32 leds,vmods,groups;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!xkb)||(!xkb->names))
+ return False;
+ firstLvlType= firstType;
+ nLvlTypes= nTypes;
+ if (nTypes<1)
+ which&= ~(XkbKTLevelNamesMask|XkbKeyTypeNamesMask);
+ else if (firstType<=XkbLastRequiredType) {
+ int adjust;
+ adjust= XkbLastRequiredType-firstType+1;
+ firstType+= adjust;
+ nTypes-= adjust;
+ if (nTypes<1)
+ which&= ~XkbKeyTypeNamesMask;
+ }
+ names= xkb->names;
+ if (which&(XkbKTLevelNamesMask|XkbKeyTypeNamesMask)) {
+ register int i;
+ XkbKeyTypePtr type;
+ if((xkb->map==NULL)||(xkb->map->types==NULL)||(nTypes==0)||
+ (firstType+nTypes>xkb->map->num_types)||
+ (firstLvlType+nLvlTypes>xkb->map->num_types))
+ return False;
+ if (which&XkbKTLevelNamesMask) {
+ type= &xkb->map->types[firstLvlType];
+ for (i=nLvlNames=0;i<nLvlTypes;i++,type++) {
+ if (type->level_names!=NULL)
+ nLvlNames+= type->num_levels;
+ }
+ }
+ }
+
+ nVMods= nLEDs= nRG= nKA= nAtoms= nGroups= 0;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetNames, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetNames;
+ req->deviceSpec = xkb->device_spec;
+ req->firstType = firstType;
+ req->nTypes = nTypes;
+ req->firstKey = xkb->min_key_code;
+ req->nKeys = xkb->max_key_code-xkb->min_key_code+1;
+
+ if (which&XkbKeycodesNameMask)
+ nAtoms++;
+ if (which&XkbGeometryNameMask)
+ nAtoms++;
+ if (which&XkbSymbolsNameMask)
+ nAtoms++;
+ if (which&XkbPhysSymbolsNameMask)
+ nAtoms++;
+ if (which&XkbTypesNameMask)
+ nAtoms++;
+ if (which&XkbCompatNameMask)
+ nAtoms++;
+ if (which&XkbKeyTypeNamesMask)
+ nAtoms+= nTypes;
+ if (which&XkbKTLevelNamesMask) {
+ req->firstKTLevel= firstLvlType;
+ req->nKTLevels= nLvlTypes;
+ req->length+= XkbPaddedSize(nLvlTypes)/4; /* room for group widths */
+ nAtoms+= nLvlNames;
+ }
+ else req->firstKTLevel= req->nKTLevels= 0;
+
+ if (which&XkbIndicatorNamesMask) {
+ req->indicators= leds=
+ _XkbCountAtoms(names->indicators,XkbNumIndicators,&nLEDs);
+ if (nLEDs>0)
+ nAtoms+= nLEDs;
+ else which&= ~XkbIndicatorNamesMask;
+ }
+ else req->indicators= leds= 0;
+
+ if (which&XkbVirtualModNamesMask) {
+ vmods= req->virtualMods= (CARD16)
+ _XkbCountAtoms(names->vmods,XkbNumVirtualMods,&nVMods);
+ if (nVMods>0)
+ nAtoms+= nVMods;
+ else which&= ~XkbVirtualModNamesMask;
+ }
+ else vmods= req->virtualMods= 0;
+
+ if (which&XkbGroupNamesMask) {
+ groups= req->groupNames= (CARD8)
+ _XkbCountAtoms(names->groups,XkbNumKbdGroups,&nGroups);
+ if (nGroups>0)
+ nAtoms+= nGroups;
+ else which&= ~XkbGroupNamesMask;
+ }
+ else groups= req->groupNames= 0;
+
+ if ((which&XkbKeyNamesMask)&&(names->keys!=NULL)) {
+ firstKey= req->firstKey;
+ nKeys= req->nKeys;
+ nAtoms+= nKeys; /* technically not atoms, but 4 bytes wide */
+ }
+ else which&= ~XkbKeyNamesMask;
+
+ if (which&XkbKeyAliasesMask) {
+ nKA= ((names->key_aliases!=NULL)?names->num_key_aliases:0);
+ if (nKA>0) {
+ req->nKeyAliases= nKA;
+ nAtoms+= nKA*2; /* not atoms, but 8 bytes on the wire */
+ }
+ else {
+ which&= ~XkbKeyAliasesMask;
+ req->nKeyAliases = 0;
+ }
+ }
+ else req->nKeyAliases= 0;
+
+ if (which&XkbRGNamesMask) {
+ nRG= names->num_rg;
+ if (nRG>0)
+ nAtoms+= nRG;
+ else which&= ~XkbRGNamesMask;
+ }
+
+ req->which= which;
+ req->nRadioGroups= nRG;
+ req->length+= (nAtoms*4)/4;
+
+ if (which&XkbKeycodesNameMask)
+ Data32(dpy,(long *)&names->keycodes,4);
+ if (which&XkbGeometryNameMask)
+ Data32(dpy,(long *)&names->geometry,4);
+ if (which&XkbSymbolsNameMask)
+ Data32(dpy,(long *)&names->symbols,4);
+ if (which&XkbPhysSymbolsNameMask)
+ Data32(dpy,(long *)&names->phys_symbols,4);
+ if (which&XkbTypesNameMask)
+ Data32(dpy,(long *)&names->types,4);
+ if (which&XkbCompatNameMask)
+ Data32(dpy,(long *)&names->compat,4);
+ if (which&XkbKeyTypeNamesMask) {
+ register int i;
+ register XkbKeyTypePtr type;
+ type= &xkb->map->types[firstType];
+ for (i=0;i<nTypes;i++,type++) {
+ Data32(dpy,(long *)&type->name,4);
+ }
+ }
+ if (which&XkbKTLevelNamesMask) {
+ XkbKeyTypePtr type;
+ int i;
+ char *tmp;
+
+ BufAlloc(char *,tmp,XkbPaddedSize(nLvlTypes));
+ type = &xkb->map->types[firstLvlType];
+ for (i=0;i<nLvlTypes;i++,type++) {
+ *tmp++ = type->num_levels;
+ }
+ type = &xkb->map->types[firstLvlType];
+ for (i=0;i<nLvlTypes;i++,type++) {
+ if (type->level_names!=NULL)
+ Data32(dpy,(long *)type->level_names,type->num_levels*4);
+ }
+ }
+ if (which&XkbIndicatorNamesMask)
+ _XkbCopyAtoms(dpy,names->indicators,leds,XkbNumIndicators);
+ if (which&XkbVirtualModNamesMask)
+ _XkbCopyAtoms(dpy,names->vmods,vmods,XkbNumVirtualMods);
+ if (which&XkbGroupNamesMask)
+ _XkbCopyAtoms(dpy,names->groups,groups,XkbNumKbdGroups);
+ if (which&XkbKeyNamesMask) {
+#ifdef WORD64
+ char *tmp;
+ register int i;
+ BufAlloc(char *,tmp,nKeys*XkbKeyNameLength);
+ for (i=0;i<nKeys;i++,tmp+= XkbKeyNameLength) {
+ tmp[0]= names->keys[firstKey+i].name[0];
+ tmp[1]= names->keys[firstKey+i].name[1];
+ tmp[2]= names->keys[firstKey+i].name[2];
+ tmp[3]= names->keys[firstKey+i].name[3];
+ }
+#else
+ Data(dpy,(char *)&names->keys[firstKey],nKeys*XkbKeyNameLength);
+#endif
+ }
+ if (which&XkbKeyAliasesMask) {
+#ifdef WORD64
+ char *tmp;
+ register int i;
+ BufAlloc(char *,tmp,nKA*XkbKeyNameLength*2);
+ for (i=0;i<nKeys;i++,tmp+= 2*XkbKeyNameLength) {
+ tmp[0]= names->key_aliases[i].real[0];
+ tmp[1]= names->key_aliases[i].real[1];
+ tmp[2]= names->key_aliases[i].real[2];
+ tmp[3]= names->key_aliases[i].real[3];
+ tmp[4]= names->key_aliases[i].alias[0];
+ tmp[5]= names->key_aliases[i].alias[1];
+ tmp[6]= names->key_aliases[i].alias[2];
+ tmp[7]= names->key_aliases[i].alias[3];
+ }
+#else
+ Data(dpy,(char *)names->key_aliases,nKA*XkbKeyNameLength*2);
+#endif
+ }
+ if (which&XkbRGNamesMask) {
+ Data32(dpy,(long *)names->radio_groups,nRG*4);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbChangeNames(Display *dpy,XkbDescPtr xkb,XkbNameChangesPtr changes)
+{
+ register xkbSetNamesReq *req;
+ int nLvlNames = 0;
+ XkbInfoPtr xkbi;
+ XkbNamesPtr names;
+ unsigned which,firstType,nTypes;
+ unsigned firstLvlType,nLvlTypes;
+ int nVMods,nLEDs,nRG,nKA,nGroups;
+ int nKeys=0,firstKey=0,nAtoms;
+ CARD32 leds=0,vmods=0,groups=0;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!xkb)||(!xkb->names)||(!changes))
+ return False;
+ which= changes->changed;
+ firstType= changes->first_type;
+ nTypes= changes->num_types;
+ firstLvlType= changes->first_lvl;;
+ nLvlTypes= changes->num_lvls;
+ if (which&XkbKeyTypeNamesMask) {
+ if (nTypes<1)
+ which&= ~XkbKeyTypeNamesMask;
+ else if (firstType<=XkbLastRequiredType) {
+ int adjust;
+ adjust= XkbLastRequiredType-firstType+1;
+ firstType+= adjust;
+ nTypes-= adjust;
+ if (nTypes<1)
+ which&= ~XkbKeyTypeNamesMask;
+ }
+ }
+ else firstType= nTypes= 0;
+
+ if (which&XkbKTLevelNamesMask) {
+ if (nLvlTypes<1)
+ which&= ~XkbKTLevelNamesMask;
+ }
+ else firstLvlType= nLvlTypes= 0;
+
+ names= xkb->names;
+ if (which&(XkbKTLevelNamesMask|XkbKeyTypeNamesMask)) {
+ register int i;
+ XkbKeyTypePtr type;
+ if((xkb->map==NULL)||(xkb->map->types==NULL)||(nTypes==0)||
+ (firstType+nTypes>xkb->map->num_types)||
+ (firstLvlType+nLvlTypes>xkb->map->num_types))
+ return False;
+ if (which&XkbKTLevelNamesMask) {
+ type= &xkb->map->types[firstLvlType];
+ for (i=nLvlNames=0;i<nLvlTypes;i++,type++) {
+ if (type->level_names!=NULL)
+ nLvlNames+= type->num_levels;
+ }
+ }
+ }
+
+ if (changes->num_keys<1)
+ which&= ~XkbKeyNamesMask;
+ if ((which&XkbKeyNamesMask)==0)
+ changes->first_key= changes->num_keys= 0;
+ else if ((changes->first_key<xkb->min_key_code)||
+ (changes->first_key+changes->num_keys>xkb->max_key_code)) {
+ return False;
+ }
+
+ if ((which&XkbVirtualModNamesMask)==0)
+ changes->changed_vmods= 0;
+ else if (changes->changed_vmods==0)
+ which&= ~XkbVirtualModNamesMask;
+
+ if ((which&XkbIndicatorNamesMask)==0)
+ changes->changed_indicators= 0;
+ else if (changes->changed_indicators==0)
+ which&= ~XkbIndicatorNamesMask;
+
+ if ((which&XkbGroupNamesMask)==0)
+ changes->changed_groups= 0;
+ else if (changes->changed_groups==0)
+ which&= ~XkbGroupNamesMask;
+
+ nVMods= nLEDs= nRG= nKA= nAtoms= nGroups= 0;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetNames, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetNames;
+ req->deviceSpec = xkb->device_spec;
+ req->firstType = firstType;
+ req->nTypes = nTypes;
+ req->firstKey = changes->first_key;
+ req->nKeys = changes->num_keys;
+
+ if (which&XkbKeycodesNameMask)
+ nAtoms++;
+ if (which&XkbGeometryNameMask)
+ nAtoms++;
+ if (which&XkbSymbolsNameMask)
+ nAtoms++;
+ if (which&XkbPhysSymbolsNameMask)
+ nAtoms++;
+ if (which&XkbTypesNameMask)
+ nAtoms++;
+ if (which&XkbCompatNameMask)
+ nAtoms++;
+ if (which&XkbKeyTypeNamesMask)
+ nAtoms+= nTypes;
+ if (which&XkbKTLevelNamesMask) {
+ req->firstKTLevel= firstLvlType;
+ req->nKTLevels= nLvlTypes;
+ req->length+= XkbPaddedSize(nLvlTypes)/4; /* room for group widths */
+ nAtoms+= nLvlNames;
+ }
+ else req->firstKTLevel= req->nKTLevels= 0;
+
+ if (which&XkbIndicatorNamesMask) {
+ leds= req->indicators= (CARD32)changes->changed_indicators;
+ nLEDs= _XkbCountBits(XkbNumIndicators,changes->changed_indicators);
+ if (nLEDs>0)
+ nAtoms+= nLEDs;
+ else which&= ~XkbIndicatorNamesMask;
+ }
+ else req->indicators= 0;
+
+ if (which&XkbVirtualModNamesMask) {
+ vmods= req->virtualMods= changes->changed_vmods;
+ nVMods= _XkbCountBits(XkbNumVirtualMods,
+ (unsigned long)changes->changed_vmods);
+ if (nVMods>0)
+ nAtoms+= nVMods;
+ else which&= ~XkbVirtualModNamesMask;
+ }
+ else req->virtualMods= 0;
+
+ if (which&XkbGroupNamesMask) {
+ groups= req->groupNames= changes->changed_groups;
+ nGroups= _XkbCountBits(XkbNumKbdGroups,
+ (unsigned long)changes->changed_groups);
+ if (nGroups>0)
+ nAtoms+= nGroups;
+ else which&= ~XkbGroupNamesMask;
+ }
+ else req->groupNames= 0;
+
+ if ((which&XkbKeyNamesMask)&&(names->keys!=NULL)) {
+ firstKey= req->firstKey;
+ nKeys= req->nKeys;
+ nAtoms+= nKeys; /* technically not atoms, but 4 bytes wide */
+ }
+ else which&= ~XkbKeyNamesMask;
+
+ if (which&XkbKeyAliasesMask) {
+ nKA= ((names->key_aliases!=NULL)?names->num_key_aliases:0);
+ if (nKA>0)
+ nAtoms+= nKA*2; /* not atoms, but 8 bytes on the wire */
+ else which&= ~XkbKeyAliasesMask;
+ }
+
+ if (which&XkbRGNamesMask) {
+ nRG= names->num_rg;
+ if (nRG>0)
+ nAtoms+= nRG;
+ else which&= ~XkbRGNamesMask;
+ }
+
+ req->which= which;
+ req->nRadioGroups= nRG;
+ req->length+= (nAtoms*4)/4;
+
+ if (which&XkbKeycodesNameMask)
+ Data32(dpy,(long *)&names->keycodes,4);
+ if (which&XkbGeometryNameMask)
+ Data32(dpy,(long *)&names->geometry,4);
+ if (which&XkbSymbolsNameMask)
+ Data32(dpy,(long *)&names->symbols,4);
+ if (which&XkbPhysSymbolsNameMask)
+ Data32(dpy,(long *)&names->phys_symbols,4);
+ if (which&XkbTypesNameMask)
+ Data32(dpy,(long *)&names->types,4);
+ if (which&XkbCompatNameMask)
+ Data32(dpy,(long *)&names->compat,4);
+ if (which&XkbKeyTypeNamesMask) {
+ register int i;
+ register XkbKeyTypePtr type;
+ type= &xkb->map->types[firstType];
+ for (i=0;i<nTypes;i++,type++) {
+ Data32(dpy,(long *)&type->name,4);
+ }
+ }
+ if (which&XkbKTLevelNamesMask) {
+ XkbKeyTypePtr type;
+ int i;
+ char *tmp;
+
+ BufAlloc(char *,tmp,XkbPaddedSize(nLvlTypes));
+ type = &xkb->map->types[firstLvlType];
+ for (i=0;i<nLvlTypes;i++,type++) {
+ *tmp++ = type->num_levels;
+ }
+ type = &xkb->map->types[firstLvlType];
+ for (i=0;i<nLvlTypes;i++,type++) {
+ if (type->level_names!=NULL)
+ Data32(dpy,(long *)type->level_names,type->num_levels*4);
+ }
+ }
+ if (which&XkbIndicatorNamesMask)
+ _XkbCopyAtoms(dpy,names->indicators,leds,XkbNumIndicators);
+ if (which&XkbVirtualModNamesMask)
+ _XkbCopyAtoms(dpy,names->vmods,vmods,XkbNumVirtualMods);
+ if (which&XkbGroupNamesMask)
+ _XkbCopyAtoms(dpy,names->groups,groups,XkbNumKbdGroups);
+ if (which&XkbKeyNamesMask) {
+#ifdef WORD64
+ char *tmp;
+ register int i;
+ BufAlloc(char *,tmp,nKeys*4);
+ for (i=0;i<nKeys;i++,tmp+= 4) {
+ tmp[0]= names->keys[firstKey+i].name[0];
+ tmp[1]= names->keys[firstKey+i].name[1];
+ tmp[2]= names->keys[firstKey+i].name[2];
+ tmp[3]= names->keys[firstKey+i].name[3];
+ }
+#else
+ Data(dpy,(char *)&names->keys[firstKey],nKeys*XkbKeyNameLength);
+#endif
+ }
+ if (which&XkbKeyAliasesMask) {
+#ifdef WORD64
+ char *tmp;
+ register int i;
+ BufAlloc(char *,tmp,nKA*XkbKeyNameLength*2);
+ for (i=0;i<nKeys;i++,tmp+= 2*XkbKeyNameLength) {
+ tmp[0]= names->key_aliases[i].real[0];
+ tmp[1]= names->key_aliases[i].real[1];
+ tmp[2]= names->key_aliases[i].real[2];
+ tmp[3]= names->key_aliases[i].real[3];
+ tmp[4]= names->key_aliases[i].alias[0];
+ tmp[5]= names->key_aliases[i].alias[1];
+ tmp[6]= names->key_aliases[i].alias[2];
+ tmp[7]= names->key_aliases[i].alias[3];
+ }
+#else
+ Data(dpy,(char *)names->key_aliases,nKA*XkbKeyNameLength*2);
+#endif
+ }
+ if (which&XkbRGNamesMask) {
+ Data32(dpy,(long *)names->radio_groups,nRG*4);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+void
+XkbNoteNameChanges( XkbNameChangesPtr old,
+ XkbNamesNotifyEvent * new,
+ unsigned int wanted)
+{
+int first,last,old_last,new_last;
+
+ wanted&= new->changed;
+ if ((old==NULL)||(new==NULL)||(wanted==0))
+ return;
+ if (wanted&XkbKeyTypeNamesMask) {
+ if (old->changed&XkbKeyTypeNamesMask) {
+ new_last= (new->first_type+new->num_types-1);
+ old_last= (old->first_type+old->num_types-1);
+
+ if (new->first_type<old->first_type)
+ first= new->first_type;
+ else first= old->first_type;
+
+ if (old_last>new_last)
+ last= old_last;
+ else last= new_last;
+
+ old->first_type= first;
+ old->num_types= (last-first)+1;
+ }
+ else {
+ old->first_type= new->first_type;
+ old->num_types= new->num_types;
+ }
+ }
+ if (wanted&XkbKTLevelNamesMask) {
+ if (old->changed&XkbKTLevelNamesMask) {
+ new_last= (new->first_lvl+new->num_lvls-1);
+ old_last= (old->first_lvl+old->num_lvls-1);
+
+ if (new->first_lvl<old->first_lvl)
+ first= new->first_lvl;
+ else first= old->first_lvl;
+
+ if (old_last>new_last)
+ last= old_last;
+ else last= new_last;
+
+ old->first_lvl= first;
+ old->num_lvls= (last-first)+1;
+ }
+ else {
+ old->first_lvl= new->first_lvl;
+ old->num_lvls= new->num_lvls;
+ }
+ }
+ if (wanted&XkbIndicatorNamesMask) {
+ if (old->changed&XkbIndicatorNamesMask)
+ old->changed_indicators|= new->changed_indicators;
+ else old->changed_indicators= new->changed_indicators;
+ }
+ if (wanted&XkbKeyNamesMask) {
+ if (old->changed&XkbKeyNamesMask) {
+ new_last= (new->first_key+new->num_keys-1);
+ old_last= (old->first_key+old->num_keys-1);
+
+ first= old->first_key;
+
+ if (new->first_key<old->first_key)
+ first= new->first_key;
+ if (old_last>new_last)
+ new_last= old_last;
+
+ old->first_key= first;
+ old->num_keys= (new_last-first)+1;
+ }
+ else {
+ old->first_key= new->first_key;
+ old->num_keys= new->num_keys;
+ }
+ }
+ if (wanted&XkbVirtualModNamesMask) {
+ if (old->changed&XkbVirtualModNamesMask)
+ old->changed_vmods|= new->changed_vmods;
+ else old->changed_vmods= new->changed_vmods;
+ }
+ if (wanted&XkbGroupNamesMask) {
+ if (old->changed&XkbGroupNamesMask)
+ old->changed_groups|= new->changed_groups;
+ else old->changed_groups= new->changed_groups;
+ }
+ if (wanted&XkbRGNamesMask)
+ old->num_rg= new->num_radio_groups;
+ if (wanted&XkbKeyAliasesMask)
+ old->num_aliases= new->num_aliases;
+ old->changed|= wanted;
+ return;
+}
diff --git a/nx-X11/lib/X11/XKBRdBuf.c b/nx-X11/lib/X11/XKBRdBuf.c
new file mode 100644
index 000000000..a68a80a33
--- /dev/null
+++ b/nx-X11/lib/X11/XKBRdBuf.c
@@ -0,0 +1,234 @@
+/* $Xorg: XKBRdBuf.c,v 1.3 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBRdBuf.c,v 1.2 2001/10/28 03:32:33 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "XKBlibint.h"
+#include <X11/extensions/XKBproto.h>
+
+/***====================================================================***/
+
+int
+_XkbInitReadBuffer(Display *dpy,XkbReadBufferPtr buf,int size)
+{
+ if ((dpy!=NULL) && (buf!=NULL) && (size>0)) {
+ buf->error= 0;
+ buf->size= size;
+ buf->start= buf->data= _XkbAlloc(size);
+ if (buf->start) {
+ _XRead(dpy, buf->start, size);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+#define _XkbReadBufferDataLeft(b) (((b)->size)-((b)->data-(b)->start))
+
+int
+_XkbSkipReadBufferData(XkbReadBufferPtr from,int size)
+{
+ if (size==0)
+ return 1;
+ if ((from==NULL)||(from->error)||(size<1)||
+ (_XkbReadBufferDataLeft(from)<size))
+ return 0;
+ from->data+= size;
+ return 1;
+}
+
+int
+_XkbCopyFromReadBuffer(XkbReadBufferPtr from,char *to,int size)
+{
+ if (size==0)
+ return 1;
+ if ((from==NULL)||(from->error)||(to==NULL)||(size<1)||
+ (_XkbReadBufferDataLeft(from)<size))
+ return 0;
+ memcpy(to,from->data,size);
+ from->data+= size;
+ return 1;
+}
+
+#ifdef XKB_FORCE_INT_KEYSYM
+int
+_XkbReadCopyKeySyms(int *wire,KeySym *to,int num_words)
+{
+ while (num_words-->0) {
+ *to++= *wire++;
+ }
+ return 1;
+}
+
+int
+_XkbReadBufferCopyKeySyms(XkbReadBufferPtr from,KeySym *to,int num_words)
+{
+ if ((unsigned)(num_words*4)>_XkbReadBufferDataLeft(from))
+ return 0;
+ _XkbReadCopyKeySyms((int *)from->data,to,num_words);
+ from->data+= (4*num_words);
+ return True;
+}
+
+int
+_XkbWriteCopyKeySyms (register KeySym *from,CARD32 *to,int len)
+{
+
+ while (len-->0) {
+ *to++= (CARD32)*from++;
+ }
+ return True;
+}
+#endif
+
+#ifdef LONG64
+int
+_XkbReadCopyData32(int *wire,long *to,int num_words)
+{
+ while (num_words-->0) {
+ *to++= *wire++;
+ }
+ return 1;
+}
+#endif
+#ifdef WORD64
+int
+_XkbReadCopyData32(int *from,long *lp,int num_words)
+{
+long *lpack;
+long mask32 = 0x00000000ffffffff;
+long maskw, i, bits;
+
+ lpack = (long *)from;
+ bits = 32;
+
+ for (i=0;i<num_words;i++) {
+ maskw = mask32 << bits;
+ *lp++ = (*lpack & maskw) >> bits;
+ bits = bits ^ 32;
+ if (bits)
+ lpack++;
+ }
+ return 1;
+}
+#endif
+
+#if defined(LONG64) || defined(WORD64)
+int
+_XkbReadBufferCopy32(XkbReadBufferPtr from,long *to,int num_words)
+{
+ if ((unsigned)(num_words*4)>_XkbReadBufferDataLeft(from))
+ return 0;
+ _XkbReadCopyData32((int *)from->data,to,num_words);
+ from->data+= (4*num_words);
+ return True;
+}
+#endif
+
+#ifdef LONG64
+int
+_XkbWriteCopyData32 (register unsigned long *from,CARD32 *to,int len)
+{
+
+ while (len-->0) {
+ *to++= (CARD32)*from++;
+ }
+ return True;
+}
+#endif /* LONG64 */
+
+#ifdef WORD64
+_XkbWriteCopyData32 Not Implemented Yet for sizeof(int)==8
+#endif
+
+char *
+_XkbPeekAtReadBuffer(XkbReadBufferPtr from,int size)
+{
+ if ((from==NULL)||(from->error)||(size<1)||
+ (_XkbReadBufferDataLeft(from)<size))
+ return 0;
+ return from->data;
+}
+
+char *
+_XkbGetReadBufferPtr(XkbReadBufferPtr from,int size)
+{
+char *ptr;
+ if ((from==NULL)||(from->error)||(size<1)||
+ (_XkbReadBufferDataLeft(from)<size))
+ return 0;
+ ptr= from->data;
+ from->data+= size;
+ return ptr;
+}
+
+
+int
+_XkbFreeReadBuffer(XkbReadBufferPtr buf)
+{
+ if ((buf!=NULL) && (buf->start!=NULL)) {
+ int left;
+ left= (int)_XkbReadBufferDataLeft(buf);
+ if (buf->start!=NULL)
+ Xfree(buf->start);
+ buf->size= 0;
+ buf->start= buf->data= NULL;
+ return left;
+ }
+ return 0;
+}
+
+Bool
+_XkbGetReadBufferCountedString(XkbReadBufferPtr buf,char **rtrn)
+{
+CARD16 len,*pLen;
+int left;
+char * str = NULL;
+
+ if ((buf==NULL)||(buf->error)||((left=(int)_XkbReadBufferDataLeft(buf))<4))
+ return False;
+ pLen= (CARD16 *)buf->data;
+ len= *pLen;
+ if (len>0) {
+ if (XkbPaddedSize(len+2)>left)
+ return False;
+ str= _XkbAlloc(len+1);
+ if (str) {
+ memcpy(str,&buf->data[2],len);
+ str[len]= '\0';
+ }
+ }
+ buf->data+= XkbPaddedSize(len+2);
+ *rtrn= str;
+ return True;
+}
diff --git a/nx-X11/lib/X11/XKBSetGeom.c b/nx-X11/lib/X11/XKBSetGeom.c
new file mode 100644
index 000000000..e27297c11
--- /dev/null
+++ b/nx-X11/lib/X11/XKBSetGeom.c
@@ -0,0 +1,470 @@
+/* $Xorg: XKBSetGeom.c,v 1.3 2000/08/17 19:45:03 cpqbld Exp $ */
+/* $XdotOrg: xc/lib/X11/XKBSetGeom.c,v 1.5 2005/07/03 07:00:55 daniels Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBSetGeom.c,v 3.5 2003/05/27 22:26:25 tsi Exp $ */
+
+#ifdef DEBUG
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#endif
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include "Xlibint.h"
+#include "XKBlibint.h"
+#include <X11/extensions/XKBgeom.h>
+#include <X11/extensions/XKBproto.h>
+
+#ifndef MINSHORT
+#define MINSHORT -32768
+#endif
+#ifndef MAXSHORT
+#define MAXSHORT 32767
+#endif
+
+/***====================================================================***/
+
+#define _SizeCountedString(s) ((s)?XkbPaddedSize(2+strlen(s)):4)
+
+static char *
+_WriteCountedString(char *wire,char *str)
+{
+CARD16 len,*pLen;
+
+ len= (str?strlen(str):0);
+ pLen= (CARD16 *)wire;
+ *pLen= len;
+ if (len && str)
+ memcpy(&wire[2],str,len);
+ wire+= XkbPaddedSize(len+2);
+ return wire;
+}
+
+static int
+_SizeGeomProperties(XkbGeometryPtr geom)
+{
+register int i,size;
+XkbPropertyPtr prop;
+
+ for (size=i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
+ size+= _SizeCountedString(prop->name);
+ size+= _SizeCountedString(prop->value);
+ }
+ return size;
+}
+
+static int
+_SizeGeomColors(XkbGeometryPtr geom)
+{
+register int i,size;
+register XkbColorPtr color;
+
+ for (i=size=0,color=geom->colors;i<geom->num_colors;i++,color++) {
+ size+= _SizeCountedString(color->spec);
+ }
+ return size;
+}
+
+static int
+_SizeGeomShapes(XkbGeometryPtr geom)
+{
+register int i,size;
+register XkbShapePtr shape;
+
+ for (i=size=0,shape=geom->shapes;i<geom->num_shapes;i++,shape++) {
+ register int n;
+ register XkbOutlinePtr ol;
+ size+= SIZEOF(xkbShapeWireDesc);
+ for (n=0,ol=shape->outlines;n<shape->num_outlines;n++,ol++) {
+ size+= SIZEOF(xkbOutlineWireDesc);
+ size+= ol->num_points*SIZEOF(xkbPointWireDesc);
+ }
+ }
+ return size;
+}
+
+static int
+_SizeGeomDoodads(int num_doodads,XkbDoodadPtr doodad)
+{
+register int i,size;
+
+ for (i=size=0;i<num_doodads;i++,doodad++) {
+ size+= SIZEOF(xkbAnyDoodadWireDesc);
+ if (doodad->any.type==XkbTextDoodad) {
+ size+= _SizeCountedString(doodad->text.text);
+ size+= _SizeCountedString(doodad->text.font);
+ }
+ else if (doodad->any.type==XkbLogoDoodad) {
+ size+= _SizeCountedString(doodad->logo.logo_name);
+ }
+ }
+ return size;
+}
+
+static int
+_SizeGeomSections(XkbGeometryPtr geom)
+{
+register int i,size;
+XkbSectionPtr section;
+
+ for (i=size=0,section=geom->sections;i<geom->num_sections;i++,section++) {
+ size+= SIZEOF(xkbSectionWireDesc);
+ if (section->rows) {
+ int r;
+ XkbRowPtr row;
+ for (r=0,row=section->rows;r<section->num_rows;row++,r++) {
+ size+= SIZEOF(xkbRowWireDesc);
+ size+= row->num_keys*SIZEOF(xkbKeyWireDesc);
+ }
+ }
+ if (section->doodads)
+ size+= _SizeGeomDoodads(section->num_doodads,section->doodads);
+ if (section->overlays) {
+ int o;
+ XkbOverlayPtr ol;
+ for (o=0,ol=section->overlays;o<section->num_overlays;o++,ol++) {
+ int r;
+ XkbOverlayRowPtr row;
+ size+= SIZEOF(xkbOverlayWireDesc);
+ for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
+ size+= SIZEOF(xkbOverlayRowWireDesc);
+ size+= row->num_keys*SIZEOF(xkbOverlayKeyWireDesc);
+ }
+ }
+ }
+ }
+ return size;
+}
+
+static int
+_SizeGeomKeyAliases(XkbGeometryPtr geom)
+{
+ return geom->num_key_aliases*(2*XkbKeyNameLength);
+}
+
+/***====================================================================***/
+
+static char *
+_WriteGeomProperties(char *wire,XkbGeometryPtr geom)
+{
+register int i;
+register XkbPropertyPtr prop;
+
+ for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
+ wire= _WriteCountedString(wire,prop->name);
+ wire= _WriteCountedString(wire,prop->value);
+ }
+ return wire;
+}
+
+static char *
+_WriteGeomColors(char *wire,XkbGeometryPtr geom)
+{
+register int i;
+register XkbColorPtr color;
+
+ for (i=0,color=geom->colors;i<geom->num_colors;i++,color++) {
+ wire= _WriteCountedString(wire,color->spec);
+ }
+ return wire;
+}
+
+static char *
+_WriteGeomShapes(char *wire,XkbGeometryPtr geom)
+{
+int i;
+XkbShapePtr shape;
+xkbShapeWireDesc * shapeWire;
+
+ for (i=0,shape=geom->shapes;i<geom->num_shapes;i++,shape++) {
+ register int o;
+ XkbOutlinePtr ol;
+ xkbOutlineWireDesc * olWire;
+ shapeWire= (xkbShapeWireDesc *)wire;
+ shapeWire->name= shape->name;
+ shapeWire->nOutlines= shape->num_outlines;
+ if (shape->primary!=NULL)
+ shapeWire->primaryNdx= XkbOutlineIndex(shape,shape->primary);
+ else shapeWire->primaryNdx= XkbNoShape;
+ if (shape->approx!=NULL)
+ shapeWire->approxNdx= XkbOutlineIndex(shape,shape->approx);
+ else shapeWire->approxNdx= XkbNoShape;
+ wire= (char *)&shapeWire[1];
+ for (o=0,ol=shape->outlines;o<shape->num_outlines;o++,ol++) {
+ register int p;
+ XkbPointPtr pt;
+ xkbPointWireDesc * ptWire;
+ olWire= (xkbOutlineWireDesc *)wire;
+ olWire->nPoints= ol->num_points;
+ olWire->cornerRadius= ol->corner_radius;
+ wire= (char *)&olWire[1];
+ ptWire= (xkbPointWireDesc *)wire;
+ for (p=0,pt=ol->points;p<ol->num_points;p++,pt++) {
+ ptWire[p].x= pt->x;
+ ptWire[p].y= pt->y;
+ }
+ wire= (char *)&ptWire[ol->num_points];
+ }
+ }
+ return wire;
+}
+
+static char *
+_WriteGeomDoodads(char *wire,int num_doodads,XkbDoodadPtr doodad)
+{
+register int i;
+xkbDoodadWireDesc * doodadWire;
+
+ for (i=0;i<num_doodads;i++,doodad++) {
+ doodadWire= (xkbDoodadWireDesc *)wire;
+ wire= (char *)&doodadWire[1];
+ bzero(doodadWire,SIZEOF(xkbDoodadWireDesc));
+ doodadWire->any.name= doodad->any.name;
+ doodadWire->any.type= doodad->any.type;
+ doodadWire->any.priority= doodad->any.priority;
+ doodadWire->any.top= doodad->any.top;
+ doodadWire->any.left= doodad->any.left;
+ doodadWire->any.angle= doodad->any.angle;
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ doodadWire->shape.colorNdx= doodad->shape.color_ndx;
+ doodadWire->shape.shapeNdx= doodad->shape.shape_ndx;
+ break;
+ case XkbTextDoodad:
+ doodadWire->text.width= doodad->text.width;
+ doodadWire->text.height= doodad->text.height;
+ doodadWire->text.colorNdx= doodad->text.color_ndx;
+ wire= _WriteCountedString(wire,doodad->text.text);
+ wire= _WriteCountedString(wire,doodad->text.font);
+ break;
+ case XkbIndicatorDoodad:
+ doodadWire->indicator.shapeNdx= doodad->indicator.shape_ndx;
+ doodadWire->indicator.onColorNdx=doodad->indicator.on_color_ndx;
+ doodadWire->indicator.offColorNdx=
+ doodad->indicator.off_color_ndx;
+ break;
+ case XkbLogoDoodad:
+ doodadWire->logo.colorNdx= doodad->logo.color_ndx;
+ doodadWire->logo.shapeNdx= doodad->logo.shape_ndx;
+ wire= _WriteCountedString(wire,doodad->logo.logo_name);
+ break;
+ default:
+ break;
+ }
+ }
+ return wire;
+}
+
+static char *
+_WriteGeomOverlay(char *wire,XkbOverlayPtr ol)
+{
+register int r;
+XkbOverlayRowPtr row;
+xkbOverlayWireDesc * olWire;
+
+ olWire= (xkbOverlayWireDesc *)wire;
+ olWire->name= ol->name;
+ olWire->nRows= ol->num_rows;
+ wire= (char *)&olWire[1];
+ for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
+ unsigned int k;
+ XkbOverlayKeyPtr key;
+ xkbOverlayRowWireDesc * rowWire;
+ rowWire= (xkbOverlayRowWireDesc *)wire;
+ rowWire->rowUnder= row->row_under;
+ rowWire->nKeys= row->num_keys;
+ wire= (char *)&rowWire[1];
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ xkbOverlayKeyWireDesc * keyWire;
+ keyWire= (xkbOverlayKeyWireDesc *)wire;
+ memcpy(keyWire->over,key->over.name,XkbKeyNameLength);
+ memcpy(keyWire->under,key->under.name,XkbKeyNameLength);
+ wire= (char *)&keyWire[1];
+ }
+ }
+ return wire;
+}
+
+static char *
+_WriteGeomSections(char *wire,XkbGeometryPtr geom)
+{
+register int i;
+XkbSectionPtr section;
+xkbSectionWireDesc * sectionWire;
+
+ for (i=0,section=geom->sections;i<geom->num_sections;i++,section++) {
+ sectionWire= (xkbSectionWireDesc *)wire;
+ sectionWire->name= section->name;
+ sectionWire->top= section->top;
+ sectionWire->left= section->left;
+ sectionWire->width= section->width;
+ sectionWire->height= section->height;
+ sectionWire->angle= section->angle;
+ sectionWire->priority= section->priority;
+ sectionWire->nRows= section->num_rows;
+ sectionWire->nDoodads= section->num_doodads;
+ sectionWire->nOverlays= section->num_overlays;
+ sectionWire->pad= 0;
+ wire= (char *)&sectionWire[1];
+ if (section->rows) {
+ int r;
+ XkbRowPtr row;
+ xkbRowWireDesc * rowWire;
+ for (r=0,row=section->rows;r<section->num_rows;r++,row++) {
+ rowWire= (xkbRowWireDesc *)wire;
+ rowWire->top= row->top;
+ rowWire->left= row->left;
+ rowWire->nKeys= row->num_keys;
+ rowWire->vertical= row->vertical;
+ rowWire->pad= 0;
+ wire= (char *)&rowWire[1];
+ if (row->keys) {
+ int k;
+ XkbKeyPtr key;
+ xkbKeyWireDesc * keyWire;
+ keyWire= (xkbKeyWireDesc *)wire;
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ memcpy(keyWire[k].name,key->name.name,XkbKeyNameLength);
+ keyWire[k].gap= key->gap;
+ keyWire[k].shapeNdx= key->shape_ndx;
+ keyWire[k].colorNdx= key->color_ndx;
+ }
+ wire= (char *)&keyWire[row->num_keys];
+ }
+ }
+ }
+ if (section->doodads) {
+ wire= _WriteGeomDoodads(wire,
+ section->num_doodads,section->doodads);
+ }
+ if (section->overlays) {
+ register int o;
+ for (o=0;o<section->num_overlays;o++) {
+ wire= _WriteGeomOverlay(wire,&section->overlays[o]);
+ }
+ }
+ }
+ return wire;
+}
+
+static char *
+_WriteGeomKeyAliases(char *wire,XkbGeometryPtr geom)
+{
+register int sz;
+
+ sz= geom->num_key_aliases*(XkbKeyNameLength*2);
+ if (sz>0) {
+ memcpy(wire,(char *)geom->key_aliases,sz);
+ wire+= sz;
+ }
+ return wire;
+}
+
+/***====================================================================***/
+
+static Status
+_SendSetGeometry(Display *dpy,XkbGeometryPtr geom,xkbSetGeometryReq *req)
+{
+int sz;
+char * wire,*tbuf;
+
+ sz= 0;
+ sz+= _SizeCountedString(geom->label_font);
+ sz+= _SizeGeomProperties(geom);
+ sz+= _SizeGeomColors(geom);
+ sz+= _SizeGeomShapes(geom);
+ sz+= _SizeGeomSections(geom);
+ sz+= _SizeGeomDoodads(geom->num_doodads,geom->doodads);
+ sz+= _SizeGeomKeyAliases(geom);
+ req->length+= (sz/4);
+ if (sz < (dpy->bufmax - dpy->buffer)) {
+ BufAlloc(char *,wire,sz);
+ tbuf= NULL;
+ }
+ else {
+ tbuf= _XAllocTemp(dpy,sz);
+ if (!tbuf)
+ return BadAlloc;
+ wire= tbuf;
+ }
+ wire= _WriteCountedString(wire,geom->label_font);
+ if (geom->num_properties>0)
+ wire= _WriteGeomProperties(wire,geom);
+ if (geom->num_colors>0)
+ wire= _WriteGeomColors(wire,geom);
+ if (geom->num_shapes>0)
+ wire= _WriteGeomShapes(wire,geom);
+ if (geom->num_sections>0)
+ wire= _WriteGeomSections(wire,geom);
+ if (geom->num_doodads>0)
+ wire= _WriteGeomDoodads(wire,geom->num_doodads,geom->doodads);
+ if (geom->num_key_aliases>0)
+ wire= _WriteGeomKeyAliases(wire,geom);
+ if (tbuf!=NULL) {
+ Data(dpy,tbuf,sz);
+ _XFreeTemp(dpy,tbuf,sz);
+ }
+ return Success;
+}
+
+/***====================================================================***/
+
+Status
+XkbSetGeometry(Display *dpy,unsigned deviceSpec,XkbGeometryPtr geom)
+{
+xkbSetGeometryReq *req;
+Status ret;
+
+ if ( (!geom) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ GetReq(kbSetGeometry, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbSetGeometry;
+ req->deviceSpec = deviceSpec;
+ req->nShapes= geom->num_shapes;
+ req->nSections= geom->num_sections;
+ req->name= geom->name;
+ req->widthMM= geom->width_mm;
+ req->heightMM= geom->height_mm;
+ req->nProperties= geom->num_properties;
+ req->nColors= geom->num_colors;
+ req->nDoodads= geom->num_doodads;
+ req->nKeyAliases= geom->num_key_aliases;
+ req->baseColorNdx= (geom->base_color-geom->colors);
+ req->labelColorNdx= (geom->label_color-geom->colors);
+
+ ret = _SendSetGeometry(dpy,geom,req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ret;
+}
+
diff --git a/nx-X11/lib/X11/XKBSetMap.c b/nx-X11/lib/X11/XKBSetMap.c
new file mode 100644
index 000000000..4a3b15c70
--- /dev/null
+++ b/nx-X11/lib/X11/XKBSetMap.c
@@ -0,0 +1,595 @@
+/* $Xorg: XKBSetMap.c,v 1.4 2000/08/17 19:45:03 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBSetMap.c,v 3.2 2001/01/17 19:41:49 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+static int
+_XkbSizeKeyTypes(XkbDescPtr xkb,xkbSetMapReq *req)
+{
+ XkbKeyTypePtr map;
+ int i,len;
+
+ if (((req->present&XkbKeyTypesMask)==0)||(req->nTypes==0)) {
+ req->present&= ~XkbKeyTypesMask;
+ req->firstType= req->nTypes= 0;
+ return 0;
+ }
+ len= 0;
+ map= &xkb->map->types[req->firstType];
+ for (i=0;i<req->nTypes;i++,map++){
+ len+= SIZEOF(xkbKeyTypeWireDesc);
+ len+= map->map_count*SIZEOF(xkbKTSetMapEntryWireDesc);
+ if (map->preserve)
+ len+= map->map_count*SIZEOF(xkbModsWireDesc);
+ }
+ return len;
+}
+
+static void
+_XkbWriteKeyTypes(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+{
+ char * buf;
+ XkbKeyTypePtr type;
+ int i,n,sz;
+ xkbKeyTypeWireDesc *desc;
+
+ if ((req->present&XkbKeyTypesMask)==0)
+ return;
+ type= &xkb->map->types[req->firstType];
+ for (i=0;i<req->nTypes;i++,type++) {
+ sz= SIZEOF(xkbKeyTypeWireDesc);
+ sz+= type->map_count*SIZEOF(xkbKTSetMapEntryWireDesc);
+ if (type->preserve)
+ sz+= type->map_count*SIZEOF(xkbModsWireDesc);
+ BufAlloc(xkbKeyTypeWireDesc *,desc,sz);
+ desc->mask = type->mods.mask;
+ desc->realMods = type->mods.real_mods;
+ desc->virtualMods = type->mods.vmods;
+ desc->numLevels = type->num_levels;
+ desc->nMapEntries = type->map_count;
+ desc->preserve = (type->preserve!=NULL);
+ buf= (char *)&desc[1];
+ if (desc->nMapEntries>0) {
+ xkbKTSetMapEntryWireDesc *wire;
+ wire= (xkbKTSetMapEntryWireDesc *)buf;
+ for (n=0;n<type->map_count;n++,wire++) {
+ wire->level= type->map[n].level;
+ wire->realMods= type->map[n].mods.real_mods;
+ wire->virtualMods= type->map[n].mods.vmods;
+ }
+ buf= (char *)wire;
+ if (type->preserve) {
+ xkbModsWireDesc *pwire;
+ pwire= (xkbModsWireDesc *)buf;
+ for (n=0;n<type->map_count;n++,pwire++) {
+ pwire->realMods= type->preserve[n].real_mods;
+ pwire->virtualMods= type->preserve[n].vmods;
+ }
+ }
+ }
+ }
+ return;
+}
+
+static int
+_XkbSizeKeySyms(XkbDescPtr xkb,xkbSetMapReq *req)
+{
+ int i,len;
+ unsigned nSyms;
+
+ if (((req->present&XkbKeySymsMask)==0)||(req->nKeySyms==0)) {
+ req->present&= ~XkbKeySymsMask;
+ req->firstKeySym= req->nKeySyms= 0;
+ req->totalSyms= 0;
+ return 0;
+ }
+ len= (int)(req->nKeySyms*sizeof(XkbSymMapRec));
+ for (i=nSyms=0;i<req->nKeySyms;i++) {
+ nSyms+= XkbKeyNumSyms(xkb,i+req->firstKeySym);
+ }
+ len+= nSyms*sizeof(CARD32);
+ req->totalSyms= nSyms;
+ return len;
+}
+
+static void
+_XkbWriteKeySyms(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+{
+register KeySym * pSym;
+CARD32 * outSym;
+XkbSymMapPtr symMap;
+xkbSymMapWireDesc *desc;
+register int i;
+
+ if ((req->present&XkbKeySymsMask)==0)
+ return;
+ symMap = &xkb->map->key_sym_map[req->firstKeySym];
+ for (i=0;i<req->nKeySyms;i++,symMap++) {
+ BufAlloc(xkbSymMapWireDesc *,desc,
+ SIZEOF(xkbSymMapWireDesc)+
+ (XkbKeyNumSyms(xkb,i+req->firstKeySym)*sizeof(CARD32)));
+ desc->ktIndex[0] = symMap->kt_index[0];
+ desc->ktIndex[1] = symMap->kt_index[1];
+ desc->ktIndex[2] = symMap->kt_index[2];
+ desc->ktIndex[3] = symMap->kt_index[3];
+ desc->groupInfo = symMap->group_info;
+ desc->width = symMap->width;
+ desc->nSyms = XkbKeyNumSyms(xkb,i+req->firstKeySym);
+ outSym = (CARD32 *)&desc[1];
+ if (desc->nSyms>0) {
+ pSym = XkbKeySymsPtr(xkb,i+req->firstKeySym);
+ _XkbWriteCopyKeySyms(pSym,outSym,desc->nSyms);
+ }
+ }
+ return;
+}
+
+static int
+_XkbSizeKeyActions(XkbDescPtr xkb,xkbSetMapReq *req)
+{
+ int i,len,nActs;
+
+ if (((req->present&XkbKeyActionsMask)==0)||(req->nKeyActs==0)) {
+ req->present&= ~XkbKeyActionsMask;
+ req->firstKeyAct= req->nKeyActs= 0;
+ req->totalActs= 0;
+ return 0;
+ }
+ for (nActs=i=0;i<req->nKeyActs;i++) {
+ if (xkb->server->key_acts[i+req->firstKeyAct]!=0)
+ nActs+= XkbKeyNumActions(xkb,i+req->firstKeyAct);
+ }
+ len= XkbPaddedSize(req->nKeyActs)+(nActs*SIZEOF(xkbActionWireDesc));
+ req->totalActs= nActs;
+ return len;
+}
+
+static void
+_XkbWriteKeyActions(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+{
+ register int i;
+ int n;
+ CARD8 *numDesc;
+ XkbAction *actDesc;
+
+ if ((req->present&XkbKeyActionsMask)==0)
+ return;
+ n = XkbPaddedSize(req->nKeyActs);
+ n+= (req->totalActs*SIZEOF(xkbActionWireDesc));
+
+ BufAlloc(CARD8 *,numDesc,n);
+ for (i=0;i<req->nKeyActs;i++) {
+ if (xkb->server->key_acts[i+req->firstKeyAct]==0)
+ numDesc[i] = 0;
+ else numDesc[i] = XkbKeyNumActions(xkb,(i+req->firstKeyAct));
+ }
+ actDesc = (XkbAction *)&numDesc[XkbPaddedSize(req->nKeyActs)];
+ for (i=0;i<req->nKeyActs;i++) {
+ if (xkb->server->key_acts[i+req->firstKeyAct]!=0) {
+ n = XkbKeyNumActions(xkb,(i+req->firstKeyAct));
+ memcpy(actDesc,XkbKeyActionsPtr(xkb,(i+req->firstKeyAct)),
+ n*SIZEOF(xkbActionWireDesc));
+ actDesc+= n;
+ }
+ }
+ return;
+}
+
+static int
+_XkbSizeKeyBehaviors(XkbDescPtr xkb,xkbSetMapReq *req)
+{
+register int i,first,last,nFound;
+
+ if (((req->present&XkbKeyBehaviorsMask)==0)||(req->nKeyBehaviors<1)) {
+ req->present&= ~XkbKeyBehaviorsMask;
+ req->firstKeyBehavior= req->nKeyBehaviors= 0;
+ req->totalKeyBehaviors= 0;
+ return 0;
+ }
+ first= req->firstKeyBehavior;
+ last= first+req->nKeyBehaviors-1;
+ for (i=first,nFound=0;i<=last;i++) {
+ if (xkb->server->behaviors[i].type!=XkbKB_Default)
+ nFound++;
+ }
+ req->totalKeyBehaviors= nFound;
+ return (nFound*SIZEOF(xkbBehaviorWireDesc));
+}
+
+static void
+_XkbWriteKeyBehaviors(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+{
+register int i,first,last;
+xkbBehaviorWireDesc * wire;
+char * buf;
+
+ if ((req->present&XkbKeyBehaviorsMask)==0)
+ return;
+ first= req->firstKeyBehavior;
+ last= first+req->nKeyBehaviors-1;
+
+ i= req->totalKeyBehaviors*SIZEOF(xkbBehaviorWireDesc);
+ BufAlloc(char *,buf,i);
+ wire= (xkbBehaviorWireDesc *)buf;
+ for (i=first;i<=last;i++) {
+ if (xkb->server->behaviors[i].type!=XkbKB_Default) {
+ wire->key= i;
+ wire->type= xkb->server->behaviors[i].type;
+ wire->data= xkb->server->behaviors[i].data;
+ buf+= SIZEOF(xkbBehaviorWireDesc);
+ wire= (xkbBehaviorWireDesc *)buf;
+ }
+ }
+ return;
+}
+
+static unsigned
+_XkbSizeVirtualMods(xkbSetMapReq *req)
+{
+register int i,bit,nMods;
+
+ if (((req->present&XkbVirtualModsMask)==0)||(req->virtualMods==0)) {
+ req->present&= ~XkbVirtualModsMask;
+ req->virtualMods= 0;
+ return 0;
+ }
+ for (i=nMods=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (req->virtualMods&bit)
+ nMods++;
+ }
+ return XkbPaddedSize(nMods);
+}
+
+static void
+_XkbWriteVirtualMods( Display * dpy,
+ XkbDescPtr xkb,
+ xkbSetMapReq * req,
+ unsigned size)
+{
+ register int i,bit;
+ CARD8 *vmods;
+
+ /* This was req->present&XkbVirtualModsMask==0, and '==' beats '&' */
+ if (((req->present & XkbVirtualModsMask) == 0) || (size < 1))
+ return;
+ BufAlloc(CARD8 *,vmods,size);
+ for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (req->virtualMods&bit)
+ *vmods++= xkb->server->vmods[i];
+ }
+ return;
+}
+
+static int
+_XkbSizeKeyExplicit(XkbDescPtr xkb,xkbSetMapReq *req)
+{
+register int i,first,last,nFound;
+
+ if (((req->present&XkbExplicitComponentsMask)==0)||(req->nKeyExplicit==0)) {
+ req->present&= ~XkbExplicitComponentsMask;
+ req->firstKeyExplicit= req->nKeyExplicit= 0;
+ req->totalKeyExplicit= 0;
+ return 0;
+ }
+ first= req->firstKeyExplicit;
+ last= first+req->nKeyExplicit-1;
+
+ for (i=first,nFound=0;i<=last;i++) {
+ if (xkb->server->explicit[i]!=0)
+ nFound++;
+ }
+ req->totalKeyExplicit= nFound;
+ return XkbPaddedSize((nFound*2));
+}
+
+static void
+_XkbWriteKeyExplicit(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+{
+register int i,first,last;
+CARD8 * wire;
+
+ if ((req->present&XkbExplicitComponentsMask)==0)
+ return;
+ first= req->firstKeyExplicit;
+ last= first+req->nKeyExplicit;
+ i= XkbPaddedSize((req->totalKeyExplicit*2));
+ BufAlloc(CARD8 *,wire,i);
+ for (i=first;i<=last;i++) {
+ if (xkb->server->explicit[i]!=0) {
+ wire[0]= i;
+ wire[1]= xkb->server->explicit[i];
+ wire+= 2;
+ }
+ }
+ return;
+}
+
+static int
+_XkbSizeModifierMap(XkbDescPtr xkb,xkbSetMapReq *req)
+{
+register int i,first,last,nFound;
+
+ if (((req->present&XkbModifierMapMask)==0)||(req->nModMapKeys==0)) {
+ req->present&= ~XkbModifierMapMask;
+ req->firstModMapKey= req->nModMapKeys= 0;
+ req->totalModMapKeys= 0;
+ return 0;
+ }
+ first= req->firstModMapKey;
+ last= first+req->nModMapKeys-1;
+
+ for (i=first,nFound=0;i<=last;i++) {
+ if (xkb->map->modmap[i]!=0)
+ nFound++;
+ }
+ req->totalModMapKeys= nFound;
+ return XkbPaddedSize((nFound*2));
+}
+
+static void
+_XkbWriteModifierMap(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+{
+register int i,first,last;
+CARD8 * wire;
+
+ if ((req->present&XkbModifierMapMask)==0)
+ return;
+ first= req->firstModMapKey;
+ last= first+req->nModMapKeys-1;
+ if (req->totalModMapKeys>0) {
+ i= XkbPaddedSize((req->totalModMapKeys*2));
+ BufAlloc(CARD8 *,wire,i);
+ for (i=first;i<=last;i++) {
+ if (xkb->map->modmap[i]!=0) {
+ wire[0]= i;
+ wire[1]= xkb->map->modmap[i];
+ wire+= 2;
+ }
+ }
+ }
+ return;
+}
+
+static int
+_XkbSizeVirtualModMap(XkbDescPtr xkb,xkbSetMapReq *req)
+{
+register int i,first,last,nFound;
+
+ if (((req->present&XkbVirtualModMapMask)==0)||(req->nVModMapKeys==0)) {
+ req->present&= ~XkbVirtualModMapMask;
+ req->firstVModMapKey= req->nVModMapKeys= 0;
+ req->totalVModMapKeys= 0;
+ return 0;
+ }
+ first= req->firstVModMapKey;
+ last= first+req->nVModMapKeys-1;
+
+ for (i=first,nFound=0;i<=last;i++) {
+ if (xkb->server->vmodmap[i]!=0)
+ nFound++;
+ }
+ req->totalVModMapKeys= nFound;
+ return nFound*SIZEOF(xkbVModMapWireDesc);
+}
+
+static void
+_XkbWriteVirtualModMap(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+{
+register int i,first,last;
+xkbVModMapWireDesc * wire;
+
+ if ((req->present&XkbVirtualModMapMask)==0)
+ return;
+ first= req->firstVModMapKey;
+ last= first+req->nVModMapKeys-1;
+ if (req->totalVModMapKeys>0) {
+ i= req->totalVModMapKeys*SIZEOF(xkbVModMapWireDesc);
+ BufAlloc(xkbVModMapWireDesc *,wire,i);
+ for (i=first;i<=last;i++) {
+ if (xkb->server->vmodmap[i]!=0) {
+ wire->key= i;
+ wire->vmods= xkb->server->vmodmap[i];
+ wire++;
+ }
+ }
+ }
+ return;
+}
+
+static void
+SendSetMap(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+{
+xkbSetMapReq tmp;
+unsigned szMods;
+
+ req->length+= _XkbSizeKeyTypes(xkb,req)/4;
+ req->length+= _XkbSizeKeySyms(xkb,req)/4;
+ req->length+= _XkbSizeKeyActions(xkb,req)/4;
+ req->length+= _XkbSizeKeyBehaviors(xkb,req)/4;
+ szMods= _XkbSizeVirtualMods(req);
+ req->length+= szMods/4;
+ req->length+= _XkbSizeKeyExplicit(xkb,req)/4;
+ req->length+= _XkbSizeModifierMap(xkb,req)/4;
+ req->length+= _XkbSizeVirtualModMap(xkb,req)/4;
+
+ tmp= *req;
+ if ( tmp.nTypes>0 )
+ _XkbWriteKeyTypes(dpy,xkb,&tmp);
+ if ( tmp.nKeySyms>0 )
+ _XkbWriteKeySyms(dpy,xkb,&tmp);
+ if ( tmp.nKeyActs )
+ _XkbWriteKeyActions(dpy,xkb,&tmp);
+ if ( tmp.totalKeyBehaviors>0 )
+ _XkbWriteKeyBehaviors(dpy,xkb,&tmp);
+ if ( tmp.virtualMods )
+ _XkbWriteVirtualMods(dpy,xkb,&tmp,szMods);
+ if ( tmp.totalKeyExplicit>0)
+ _XkbWriteKeyExplicit(dpy,xkb,&tmp);
+ if ( tmp.totalModMapKeys>0)
+ _XkbWriteModifierMap(dpy,xkb,&tmp);
+ if ( tmp.totalVModMapKeys>0)
+ _XkbWriteVirtualModMap(dpy,xkb,&tmp);
+ return;
+}
+
+Bool
+XkbSetMap(Display *dpy,unsigned which,XkbDescPtr xkb)
+{
+register xkbSetMapReq * req;
+XkbInfoPtr xkbi;
+XkbServerMapPtr srv;
+XkbClientMapPtr map;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))||
+ (!xkb))
+ return False;
+ map= xkb->map;
+ srv= xkb->server;
+
+ if (((which&XkbKeyTypesMask)&&((!map)||(!map->types)))||
+ ((which&XkbKeySymsMask)&&((!map)||(!map->syms)||(!map->key_sym_map)))||
+ ((which&XkbKeyActionsMask)&&((!srv)||(!srv->key_acts)))||
+ ((which&XkbKeyBehaviorsMask)&&((!srv)||(!srv->behaviors)))||
+ ((which&XkbVirtualModsMask)&&(!srv))||
+ ((which&XkbExplicitComponentsMask)&&((!srv)||(!srv->explicit)))||
+ ((which&XkbModifierMapMask)&&((!map)||(!map->modmap)))||
+ ((which&XkbVirtualModMapMask)&&((!srv)||(!srv->vmodmap))))
+ return False;
+
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetMap, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetMap;
+ req->deviceSpec = xkb->device_spec;
+ req->present = which;
+ req->flags = XkbSetMapAllFlags;
+ req->minKeyCode= xkb->min_key_code;
+ req->maxKeyCode= xkb->max_key_code;
+ req->firstType = 0;
+ if (which&XkbKeyTypesMask) req->nTypes = map->num_types;
+ else req->nTypes = 0;
+ if (which&XkbKeySymsMask) {
+ req->firstKeySym = xkb->min_key_code;
+ req->nKeySyms = XkbNumKeys(xkb);
+ }
+ if (which&XkbKeyActionsMask) {
+ req->firstKeyAct = xkb->min_key_code;
+ req->nKeyActs = XkbNumKeys(xkb);
+ }
+ if (which&XkbKeyBehaviorsMask) {
+ req->firstKeyBehavior = xkb->min_key_code;
+ req->nKeyBehaviors = XkbNumKeys(xkb);
+ }
+ if (which&XkbVirtualModsMask)
+ req->virtualMods= ~0;
+ if (which&XkbExplicitComponentsMask) {
+ req->firstKeyExplicit= xkb->min_key_code;
+ req->nKeyExplicit = XkbNumKeys(xkb);
+ }
+ if (which&XkbModifierMapMask) {
+ req->firstModMapKey= xkb->min_key_code;
+ req->nModMapKeys = XkbNumKeys(xkb);
+ }
+ if (which&XkbVirtualModMapMask) {
+ req->firstVModMapKey= xkb->min_key_code;
+ req->nVModMapKeys = XkbNumKeys(xkb);
+ }
+ SendSetMap(dpy,xkb,req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbChangeMap(Display *dpy,XkbDescPtr xkb,XkbMapChangesPtr changes)
+{
+register xkbSetMapReq * req;
+XkbInfoPtr xkbi;
+XkbServerMapPtr srv;
+XkbClientMapPtr map;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))||
+ (!xkb)||(!changes))
+ return False;
+ srv= xkb->server;
+ map= xkb->map;
+
+ if (((changes->changed&XkbKeyTypesMask)&&((!map)||(!map->types)))||
+ ((changes->changed&XkbKeySymsMask)&&((!map)||(!map->syms)||
+ (!map->key_sym_map)))||
+ ((changes->changed&XkbKeyActionsMask)&&((!srv)||(!srv->key_acts)))||
+ ((changes->changed&XkbKeyBehaviorsMask)&&((!srv)||(!srv->behaviors)))||
+ ((changes->changed&XkbVirtualModsMask)&&(!srv))||
+ ((changes->changed&XkbExplicitComponentsMask)&&
+ ((!srv)||(!srv->explicit)))||
+ ((changes->changed&XkbModifierMapMask)&&((!map)||(!map->modmap)))||
+ ((changes->changed&XkbVirtualModMapMask)&&((!srv)||(!srv->vmodmap))))
+ return False;
+
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetMap, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetMap;
+ req->deviceSpec = xkb->device_spec;
+ req->present = changes->changed;
+ req->flags = XkbSetMapRecomputeActions;
+ req->minKeyCode= xkb->min_key_code;
+ req->maxKeyCode= xkb->max_key_code;
+ req->firstType = changes->first_type;
+ req->nTypes = changes->num_types;
+ req->firstKeySym = changes->first_key_sym;
+ req->nKeySyms = changes->num_key_syms;
+ req->firstKeyAct = changes->first_key_act;
+ req->nKeyActs = changes->num_key_acts;
+ req->firstKeyBehavior = changes->first_key_behavior;
+ req->nKeyBehaviors = changes->num_key_behaviors;
+ req->virtualMods = changes->vmods;
+ req->firstKeyExplicit = changes->first_key_explicit;
+ req->nKeyExplicit = changes->num_key_explicit;
+ req->firstModMapKey = changes->first_modmap_key;
+ req->nModMapKeys = changes->num_modmap_keys;
+ req->firstVModMapKey = changes->first_vmodmap_key;
+ req->nVModMapKeys = changes->num_vmodmap_keys;
+ SendSetMap(dpy,xkb,req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
diff --git a/nx-X11/lib/X11/XKBUse.c b/nx-X11/lib/X11/XKBUse.c
new file mode 100644
index 000000000..ad18bb6fc
--- /dev/null
+++ b/nx-X11/lib/X11/XKBUse.c
@@ -0,0 +1,801 @@
+/* $Xorg: XKBUse.c,v 1.3 2000/08/17 19:45:03 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBUse.c,v 3.7 2003/07/07 15:34:21 eich Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <ctype.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+static Bool _XkbIgnoreExtension = False;
+
+void
+XkbNoteMapChanges(XkbMapChangesPtr old,XkbMapNotifyEvent *new,unsigned wanted)
+{
+ int first,oldLast,newLast;
+ wanted&= new->changed;
+
+ if (wanted&XkbKeyTypesMask) {
+ if (old->changed&XkbKeyTypesMask) {
+ first = old->first_type;
+ oldLast = old->first_type+old->num_types-1;
+ newLast = new->first_type+new->num_types-1;
+
+ if (new->first_type<first)
+ first = new->first_type;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_type = first;
+ old->num_types = newLast-first+1;
+ }
+ else {
+ old->first_type= new->first_type;
+ old->num_types = new->num_types;
+ }
+ }
+ if (wanted&XkbKeySymsMask) {
+ if (old->changed&XkbKeySymsMask) {
+ first = old->first_key_sym;
+ oldLast = old->first_key_sym+old->num_key_syms-1;
+ newLast = new->first_key_sym+new->num_key_syms-1;
+
+ if (new->first_key_sym<first)
+ first = new->first_key_sym;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_key_sym = first;
+ old->num_key_syms = newLast-first+1;
+ }
+ else {
+ old->first_key_sym = new->first_key_sym;
+ old->num_key_syms = new->num_key_syms;
+ }
+ }
+ if (wanted&XkbKeyActionsMask) {
+ if (old->changed&XkbKeyActionsMask) {
+ first = old->first_key_act;
+ oldLast = old->first_key_act+old->num_key_acts-1;
+ newLast = new->first_key_act+new->num_key_acts-1;
+
+ if (new->first_key_act<first)
+ first = new->first_key_act;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_key_act = first;
+ old->num_key_acts = newLast-first+1;
+ }
+ else {
+ old->first_key_act = new->first_key_act;
+ old->num_key_acts = new->num_key_acts;
+ }
+ }
+ if (wanted&XkbKeyBehaviorsMask) {
+ if (old->changed&XkbKeyBehaviorsMask) {
+ first = old->first_key_behavior;
+ oldLast = old->first_key_behavior+old->num_key_behaviors-1;
+ newLast = new->first_key_behavior+new->num_key_behaviors-1;
+
+ if (new->first_key_behavior<first)
+ first = new->first_key_behavior;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_key_behavior = first;
+ old->num_key_behaviors = newLast-first+1;
+ }
+ else {
+ old->first_key_behavior = new->first_key_behavior;
+ old->num_key_behaviors = new->num_key_behaviors;
+ }
+ }
+ if (wanted&XkbVirtualModsMask) {
+ old->vmods|= new->vmods;
+ }
+ if (wanted&XkbExplicitComponentsMask) {
+ if (old->changed&XkbExplicitComponentsMask) {
+ first = old->first_key_explicit;
+ oldLast = old->first_key_explicit+old->num_key_explicit-1;
+ newLast = new->first_key_explicit+new->num_key_explicit-1;
+
+ if (new->first_key_explicit<first)
+ first = new->first_key_explicit;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_key_explicit = first;
+ old->num_key_explicit = newLast-first+1;
+ }
+ else {
+ old->first_key_explicit = new->first_key_explicit;
+ old->num_key_explicit = new->num_key_explicit;
+ }
+ }
+ if (wanted&XkbModifierMapMask) {
+ if (old->changed&XkbModifierMapMask) {
+ first = old->first_modmap_key;
+ oldLast = old->first_modmap_key+old->num_modmap_keys-1;
+ newLast = new->first_modmap_key+new->num_modmap_keys-1;
+
+ if (new->first_modmap_key<first)
+ first = new->first_modmap_key;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_modmap_key = first;
+ old->num_modmap_keys = newLast-first+1;
+ }
+ else {
+ old->first_modmap_key = new->first_modmap_key;
+ old->num_modmap_keys = new->num_modmap_keys;
+ }
+ }
+ if (wanted&XkbVirtualModMapMask) {
+ if (old->changed&XkbVirtualModMapMask) {
+ first = old->first_vmodmap_key;
+ oldLast = old->first_vmodmap_key+old->num_vmodmap_keys-1;
+ newLast = new->first_vmodmap_key+new->num_vmodmap_keys-1;
+
+ if (new->first_vmodmap_key<first)
+ first = new->first_vmodmap_key;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_vmodmap_key = first;
+ old->num_vmodmap_keys = newLast-first+1;
+ }
+ else {
+ old->first_vmodmap_key = new->first_vmodmap_key;
+ old->num_vmodmap_keys = new->num_vmodmap_keys;
+ }
+ }
+ old->changed|= wanted;
+ return;
+}
+
+void
+_XkbNoteCoreMapChanges( XkbMapChangesPtr old,
+ XMappingEvent * new,
+ unsigned int wanted)
+{
+ int first,oldLast,newLast;
+
+ if ((new->request==MappingKeyboard)&&(wanted&XkbKeySymsMask)) {
+ if (old->changed&XkbKeySymsMask) {
+ first = old->first_key_sym;
+ oldLast = old->first_key_sym+old->num_key_syms-1;
+ newLast = new->first_keycode+new->count-1;
+
+ if (new->first_keycode<first)
+ first = new->first_keycode;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_key_sym = first;
+ old->num_key_syms = newLast-first+1;
+ }
+ else {
+ old->changed|= XkbKeySymsMask;
+ old->first_key_sym = new->first_keycode;
+ old->num_key_syms = new->count;
+ }
+ }
+ return;
+}
+
+static Bool
+wire_to_event(Display *dpy,XEvent *re,xEvent *event)
+{
+ xkbEvent *xkbevent= (xkbEvent *)event;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ xkbi = dpy->xkb_info;
+ if (((event->u.u.type&0x7f)-xkbi->codes->first_event)!=XkbEventCode)
+ return False;
+
+ switch (xkbevent->u.any.xkbType) {
+ case XkbStateNotify:
+ {
+ xkbStateNotify *sn = (xkbStateNotify *)event;
+ if ( xkbi->selected_events&XkbStateNotifyMask ) {
+ XkbStateNotifyEvent *sev=(XkbStateNotifyEvent *)re;
+ sev->type = XkbEventCode+xkbi->codes->first_event;
+ sev->xkb_type = XkbStateNotify;
+ sev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ sev->send_event = ((event->u.u.type & 0x80) != 0);
+ sev->display = dpy;
+ sev->time = sn->time;
+ sev->device = sn->deviceID;
+ sev->keycode = sn->keycode;
+ sev->event_type = sn->eventType;
+ sev->req_major = sn->requestMajor;
+ sev->req_minor = sn->requestMinor;
+ sev->changed = sn->changed;
+ sev->group = sn->group;
+ sev->base_group = sn->baseGroup;
+ sev->latched_group = sn->latchedGroup;
+ sev->locked_group = sn->lockedGroup;
+ sev->mods = sn->mods;
+ sev->base_mods = sn->baseMods;
+ sev->latched_mods = sn->latchedMods;
+ sev->locked_mods = sn->lockedMods;
+ sev->compat_state = sn->compatState;
+ sev->grab_mods = sn->grabMods;
+ sev->compat_grab_mods = sn->compatGrabMods;
+ sev->lookup_mods = sn->lookupMods;
+ sev->compat_lookup_mods = sn->compatLookupMods;
+ sev->ptr_buttons = sn->ptrBtnState;
+ return True;
+ }
+ }
+ break;
+ case XkbMapNotify:
+ {
+ xkbMapNotify *mn = (xkbMapNotify *)event;
+ if ((xkbi->selected_events&XkbMapNotifyMask)&&
+ (xkbi->selected_map_details&mn->changed)) {
+ XkbMapNotifyEvent *mev;
+ mev =(XkbMapNotifyEvent *)re;
+ mev->type = XkbEventCode+xkbi->codes->first_event;
+ mev->xkb_type = XkbMapNotify;
+ mev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ mev->send_event = ((event->u.u.type&0x80)!=0);
+ mev->display = dpy;
+ mev->time = mn->time;
+ mev->device = mn->deviceID;
+ mev->changed = mn->changed;
+ mev->min_key_code = mn->minKeyCode;
+ mev->max_key_code = mn->maxKeyCode;
+ mev->first_type = mn->firstType;
+ mev->num_types = mn->nTypes;
+ mev->first_key_sym = mn->firstKeySym;
+ mev->num_key_syms = mn->nKeySyms;
+ mev->first_key_act = mn->firstKeyAct;
+ mev->num_key_acts = mn->nKeyActs;
+ mev->first_key_behavior = mn->firstKeyBehavior;
+ mev->num_key_behaviors = mn->nKeyBehaviors;
+ mev->vmods = mn->virtualMods;
+ mev->first_key_explicit = mn->firstKeyExplicit;
+ mev->num_key_explicit = mn->nKeyExplicit;
+ mev->first_modmap_key = mn->firstModMapKey;
+ mev->num_modmap_keys = mn->nModMapKeys;
+ mev->first_vmodmap_key = mn->firstVModMapKey;
+ mev->num_vmodmap_keys = mn->nVModMapKeys;
+ XkbNoteMapChanges(&xkbi->changes,mev,XKB_XLIB_MAP_MASK);
+ if (xkbi->changes.changed)
+ xkbi->flags|= XkbMapPending;
+ return True;
+ }
+ else if (mn->nKeySyms>0) {
+ register XMappingEvent *ev = (XMappingEvent *)re;
+ ev->type = MappingNotify;
+ ev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ ev->send_event = ((event->u.u.type&0x80)!=0);
+ ev->display = dpy;
+ ev->window = 0;
+ ev->first_keycode = mn->firstKeySym;
+ ev->request = MappingKeyboard;
+ ev->count = mn->nKeySyms;
+ _XkbNoteCoreMapChanges(&xkbi->changes,ev,XKB_XLIB_MAP_MASK);
+ if (xkbi->changes.changed)
+ xkbi->flags|= XkbMapPending;
+ return True;
+ }
+ }
+ break;
+ case XkbControlsNotify:
+ {
+ if (xkbi->selected_events&XkbControlsNotifyMask) {
+ xkbControlsNotify *cn =(xkbControlsNotify *)event;
+ XkbControlsNotifyEvent *cev;
+ cev =(XkbControlsNotifyEvent *)re;
+ cev->type = XkbEventCode+xkbi->codes->first_event;
+ cev->xkb_type = XkbControlsNotify;
+ cev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ cev->send_event = ((event->u.u.type&0x80)!=0);
+ cev->display = dpy;
+ cev->time = cn->time;
+ cev->device = cn->deviceID;
+ cev->changed_ctrls = cn->changedControls;
+ cev->enabled_ctrls = cn->enabledControls;
+ cev->enabled_ctrl_changes = cn->enabledControlChanges;
+ cev->keycode = cn->keycode;
+ cev->num_groups = cn->numGroups;
+ cev->event_type = cn->eventType;
+ cev->req_major = cn->requestMajor;
+ cev->req_minor = cn->requestMinor;
+ return True;
+ }
+ }
+ break;
+ case XkbIndicatorMapNotify:
+ {
+ if (xkbi->selected_events&XkbIndicatorMapNotifyMask) {
+ xkbIndicatorNotify *in =(xkbIndicatorNotify *)event;
+ XkbIndicatorNotifyEvent *iev;
+ iev =(XkbIndicatorNotifyEvent *)re;
+ iev->type = XkbEventCode+xkbi->codes->first_event;
+ iev->xkb_type = XkbIndicatorMapNotify;
+ iev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ iev->send_event = ((event->u.u.type&0x80)!=0);
+ iev->display = dpy;
+ iev->time = in->time;
+ iev->device = in->deviceID;
+ iev->changed = in->changed;
+ iev->state= in->state;
+ return True;
+ }
+ }
+ break;
+ case XkbIndicatorStateNotify:
+ {
+ if (xkbi->selected_events&XkbIndicatorStateNotifyMask) {
+ xkbIndicatorNotify *in =(xkbIndicatorNotify *)event;
+ XkbIndicatorNotifyEvent *iev;
+ iev =(XkbIndicatorNotifyEvent *)re;
+ iev->type = XkbEventCode+xkbi->codes->first_event;
+ iev->xkb_type = XkbIndicatorStateNotify;
+ iev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ iev->send_event = ((event->u.u.type&0x80)!=0);
+ iev->display = dpy;
+ iev->time = in->time;
+ iev->device = in->deviceID;
+ iev->changed = in->changed;
+ iev->state= in->state;
+ return True;
+ }
+ }
+ break;
+ case XkbBellNotify:
+ {
+ if (xkbi->selected_events&XkbBellNotifyMask) {
+ xkbBellNotify *bn =(xkbBellNotify *)event;
+ XkbBellNotifyEvent *bev;
+ bev =(XkbBellNotifyEvent *)re;
+ bev->type = XkbEventCode+xkbi->codes->first_event;
+ bev->xkb_type = XkbBellNotify;
+ bev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ bev->send_event = ((event->u.u.type&0x80)!=0);
+ bev->display = dpy;
+ bev->time = bn->time;
+ bev->device = bn->deviceID;
+ bev->percent = bn->percent;
+ bev->pitch = bn->pitch;
+ bev->duration = bn->duration;
+ bev->bell_class = bn->bellClass;
+ bev->bell_id = bn->bellID;
+ bev->name = bn->name;
+ bev->window = bn->window;
+ bev->event_only = bn->eventOnly;
+ return True;
+ }
+ }
+ break;
+ case XkbAccessXNotify:
+ {
+ if (xkbi->selected_events&XkbAccessXNotifyMask) {
+ xkbAccessXNotify *axn =(xkbAccessXNotify *)event;
+ XkbAccessXNotifyEvent *axev;
+ axev =(XkbAccessXNotifyEvent *)re;
+ axev->type = XkbEventCode+xkbi->codes->first_event;
+ axev->xkb_type = XkbAccessXNotify;
+ axev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ axev->send_event = ((event->u.u.type&0x80)!=0);
+ axev->display = dpy;
+ axev->time = axn->time;
+ axev->device = axn->deviceID;
+ axev->detail = axn->detail;
+ axev->keycode = axn->keycode;
+ axev->sk_delay = axn->slowKeysDelay;
+ axev->debounce_delay = axn->debounceDelay;
+ return True;
+ }
+ }
+ break;
+ case XkbNamesNotify:
+ {
+ if (xkbi->selected_events&XkbNamesNotifyMask) {
+ xkbNamesNotify *nn =(xkbNamesNotify *)event;
+ XkbNamesNotifyEvent *nev;
+ nev =(XkbNamesNotifyEvent *)re;
+ nev->type = XkbEventCode+xkbi->codes->first_event;
+ nev->xkb_type = XkbNamesNotify;
+ nev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ nev->send_event = ((event->u.u.type&0x80)!=0);
+ nev->display = dpy;
+ nev->time = nn->time;
+ nev->device = nn->deviceID;
+ nev->changed = nn->changed;
+ nev->first_type = nn->firstType;
+ nev->num_types = nn->nTypes;
+ nev->first_lvl = nn->firstLevelName;
+ nev->num_lvls = nn->nLevelNames;
+ nev->num_aliases = nn->nAliases;
+ nev->num_radio_groups = nn->nRadioGroups;
+ nev->changed_vmods = nn->changedVirtualMods;
+ nev->changed_groups = nn->changedGroupNames;
+ nev->changed_indicators = nn->changedIndicators;
+ nev->first_key = nn->firstKey;
+ nev->num_keys = nn->nKeys;
+ return True;
+ }
+ }
+ break;
+ case XkbCompatMapNotify:
+ {
+ if (xkbi->selected_events&XkbCompatMapNotifyMask) {
+ xkbCompatMapNotify *cmn =(xkbCompatMapNotify *)event;
+ XkbCompatMapNotifyEvent *cmev;
+ cmev =(XkbCompatMapNotifyEvent *)re;
+ cmev->type = XkbEventCode+xkbi->codes->first_event;
+ cmev->xkb_type = XkbCompatMapNotify;
+ cmev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ cmev->send_event = ((event->u.u.type&0x80)!=0);
+ cmev->display = dpy;
+ cmev->time = cmn->time;
+ cmev->device = cmn->deviceID;
+ cmev->changed_groups = cmn->changedGroups;
+ cmev->first_si = cmn->firstSI;
+ cmev->num_si = cmn->nSI;
+ cmev->num_total_si = cmn->nTotalSI;
+ return True;
+ }
+ }
+ break;
+ case XkbActionMessage:
+ {
+ if (xkbi->selected_events&XkbActionMessageMask) {
+ xkbActionMessage *am= (xkbActionMessage *)event;
+ XkbActionMessageEvent *amev;
+ amev= (XkbActionMessageEvent *)re;
+ amev->type = XkbEventCode+xkbi->codes->first_event;
+ amev->xkb_type = XkbActionMessage;
+ amev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ amev->send_event = ((event->u.u.type&0x80)!=0);
+ amev->display = dpy;
+ amev->time = am->time;
+ amev->device = am->deviceID;
+ amev->keycode = am->keycode;
+ amev->press = am->press;
+ amev->key_event_follows = am->keyEventFollows;
+ amev->group = am->group;
+ amev->mods = am->mods;
+ memcpy(amev->message,am->message,XkbActionMessageLength);
+ amev->message[XkbActionMessageLength]= '\0';
+ return True;
+ }
+ }
+ break;
+ case XkbExtensionDeviceNotify:
+ {
+ if (xkbi->selected_events&XkbExtensionDeviceNotifyMask) {
+ xkbExtensionDeviceNotify *ed=
+ (xkbExtensionDeviceNotify *)event;
+ XkbExtensionDeviceNotifyEvent *edev;
+ edev= (XkbExtensionDeviceNotifyEvent *)re;
+ edev->type= XkbEventCode+xkbi->codes->first_event;
+ edev->xkb_type= XkbExtensionDeviceNotify;
+ edev->serial= _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ edev->send_event= ((event->u.u.type&0x80)!=0);
+ edev->display= dpy;
+ edev->time= ed->time;
+ edev->device= ed->deviceID;
+ edev->led_class= ed->ledClass;
+ edev->led_id= ed->ledID;
+ edev->reason= ed->reason;
+ edev->supported= ed->supported;
+ edev->leds_defined= ed->ledsDefined;
+ edev->led_state= ed->ledState;
+ edev->first_btn= ed->firstBtn;
+ edev->num_btns= ed->nBtns;
+ edev->unsupported= ed->unsupported;
+ return True;
+ }
+ }
+ break;
+ case XkbNewKeyboardNotify:
+ {
+ xkbNewKeyboardNotify *nkn = (xkbNewKeyboardNotify *)event;
+ if ((xkbi->selected_events&XkbNewKeyboardNotifyMask)&&
+ (xkbi->selected_nkn_details&nkn->changed)) {
+ XkbNewKeyboardNotifyEvent *nkev;
+ nkev =(XkbNewKeyboardNotifyEvent *)re;
+ nkev->type = XkbEventCode+xkbi->codes->first_event;
+ nkev->xkb_type = XkbNewKeyboardNotify;
+ nkev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ nkev->send_event = ((event->u.u.type&0x80)!=0);
+ nkev->display = dpy;
+ nkev->time = nkn->time;
+ nkev->device = nkn->deviceID;
+ nkev->old_device = nkn->oldDeviceID;
+ nkev->min_key_code = nkn->minKeyCode;
+ nkev->max_key_code = nkn->maxKeyCode;
+ nkev->old_min_key_code = nkn->oldMinKeyCode;
+ nkev->old_max_key_code = nkn->oldMaxKeyCode;
+ nkev->req_major = nkn->requestMajor;
+ nkev->req_minor = nkn->requestMinor;
+ nkev->changed = nkn->changed;
+ if ((xkbi->desc)&&(nkev->send_event==0)&&
+ ((xkbi->desc->device_spec==nkev->old_device)||
+ (nkev->device!=nkev->old_device))) {
+ xkbi->flags= XkbMapPending|XkbXlibNewKeyboard;
+ }
+ return True;
+ }
+ else if(nkn->changed&(XkbNKN_KeycodesMask|XkbNKN_DeviceIDMask)){
+ register XMappingEvent *ev = (XMappingEvent *)re;
+ ev->type = MappingNotify;
+ ev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ ev->send_event = ((event->u.u.type&0x80)!=0);
+ ev->display = dpy;
+ ev->window = 0;
+ ev->first_keycode = dpy->min_keycode;
+ ev->request = MappingKeyboard;
+ ev->count = (dpy->max_keycode-dpy->min_keycode)+1;
+ if ((xkbi->desc)&&(ev->send_event==0)&&
+ ((xkbi->desc->device_spec==nkn->oldDeviceID)||
+ (nkn->deviceID!=nkn->oldDeviceID))) {
+ xkbi->flags|= XkbMapPending|XkbXlibNewKeyboard;
+ }
+ return True;
+ }
+ }
+ break;
+ default:
+#ifdef DEBUG
+ fprintf(stderr,"Got unknown XKEYBOARD event (%d, base=%d)\n",
+ re->type,
+ xkbi->codes->first_event);
+#endif
+ break;
+ }
+ return False;
+}
+
+Bool
+XkbIgnoreExtension(Bool ignore)
+{
+ if (getenv("XKB_FORCE")!=NULL) {
+#ifdef DEBUG
+ fprintf(stderr,"Forcing use of XKEYBOARD (overriding an IgnoreExtensions)\n");
+#endif
+ return False;
+ }
+#ifdef DEBUG
+ else if (getenv("XKB_DEBUG")!=NULL) {
+ fprintf(stderr,"Explicitly %signoring XKEYBOARD\n",ignore?"":"not ");
+ }
+#endif
+ _XkbIgnoreExtension = ignore;
+ return True;
+}
+
+static void
+_XkbFreeInfo(Display *dpy)
+{
+ XkbInfoPtr xkbi = dpy->xkb_info;
+ if (xkbi) {
+ if (xkbi->desc)
+ XkbFreeKeyboard(xkbi->desc,XkbAllComponentsMask,True);
+ Xfree(xkbi);
+ }
+}
+
+Bool
+XkbUseExtension(Display *dpy,int *major_rtrn,int *minor_rtrn)
+{
+ xkbUseExtensionReply rep;
+ register xkbUseExtensionReq *req;
+ XExtCodes *codes;
+ int ev_base,forceIgnore;
+ XkbInfoPtr xkbi;
+ char * str;
+ static int debugMsg;
+ static int been_here= 0;
+
+ if ( dpy->xkb_info && !(dpy->flags & XlibDisplayNoXkb)) {
+ if (major_rtrn) *major_rtrn= dpy->xkb_info->srv_major;
+ if (minor_rtrn) *minor_rtrn= dpy->xkb_info->srv_minor;
+ return True;
+ }
+ if (!been_here) {
+ debugMsg= (getenv("XKB_DEBUG")!=NULL);
+ been_here= 1;
+ }
+
+ if (major_rtrn) *major_rtrn= 0;
+ if (minor_rtrn) *minor_rtrn= 0;
+
+ if (!dpy->xkb_info) {
+ xkbi = _XkbTypedCalloc(1, XkbInfoRec);
+ if ( !xkbi )
+ return False;
+ dpy->xkb_info = xkbi;
+ dpy->free_funcs->xkb = _XkbFreeInfo;
+
+ xkbi->xlib_ctrls|= (XkbLC_ControlFallback|XkbLC_ConsumeLookupMods);
+ if ((str=getenv("_XKB_OPTIONS_ENABLE"))!=NULL) {
+ if ((str=getenv("_XKB_LATIN1_LOOKUP"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_ForceLatin1Lookup;
+ else xkbi->xlib_ctrls|= XkbLC_ForceLatin1Lookup;
+ }
+ if ((str=getenv("_XKB_CONSUME_LOOKUP_MODS"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_ConsumeLookupMods;
+ else xkbi->xlib_ctrls|= XkbLC_ConsumeLookupMods;
+ }
+ if ((str=getenv("_XKB_CONSUME_SHIFT_AND_LOCK"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_AlwaysConsumeShiftAndLock;
+ else xkbi->xlib_ctrls|= XkbLC_AlwaysConsumeShiftAndLock;
+ }
+ if ((str=getenv("_XKB_IGNORE_NEW_KEYBOARDS"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_IgnoreNewKeyboards;
+ else xkbi->xlib_ctrls|= XkbLC_IgnoreNewKeyboards;
+ }
+ if ((str=getenv("_XKB_CONTROL_FALLBACK"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_ControlFallback;
+ else xkbi->xlib_ctrls|= XkbLC_ControlFallback;
+ }
+ if ((str=getenv("_XKB_COMP_LED"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_ComposeLED;
+ else {
+ xkbi->xlib_ctrls|= XkbLC_ComposeLED;
+ if (strlen(str)>0)
+ xkbi->composeLED= XInternAtom(dpy,str,False);
+ }
+ }
+ if ((str=getenv("_XKB_COMP_FAIL_BEEP"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_BeepOnComposeFail;
+ else xkbi->xlib_ctrls|= XkbLC_BeepOnComposeFail;
+ }
+ }
+ if ((xkbi->composeLED==None)&&((xkbi->xlib_ctrls&XkbLC_ComposeLED)!=0))
+ xkbi->composeLED= XInternAtom(dpy,"Compose",False);
+#ifdef DEBUG
+ if (debugMsg) {
+ register unsigned c= xkbi->xlib_ctrls;
+ fprintf(stderr,"XKEYBOARD compose: beep on failure is %s, LED is %s\n",
+ ((c&XkbLC_BeepOnComposeFail)?"on":"off"),
+ ((c&XkbLC_ComposeLED)?"on":"off"));
+ fprintf(stderr,"XKEYBOARD XLookupString: %slatin-1, %s lookup modifiers\n",
+ ((c&XkbLC_ForceLatin1Lookup)?"allow non-":"force "),
+ ((c&XkbLC_ConsumeLookupMods)?"consume":"re-use"));
+ fprintf(stderr,
+ "XKEYBOARD XLookupString: %sconsume shift and lock, %scontrol fallback\n",
+ ((c&XkbLC_AlwaysConsumeShiftAndLock)?"always ":"don't "),
+ ((c&XkbLC_ControlFallback)?"":"no "));
+
+ }
+#endif
+ } else
+ xkbi = dpy->xkb_info;
+
+ forceIgnore= (dpy->flags&XlibDisplayNoXkb)||dpy->keysyms;
+ forceIgnore= forceIgnore&&(major_rtrn==NULL)&&(minor_rtrn==NULL);
+ if ( forceIgnore || _XkbIgnoreExtension || getenv("XKB_DISABLE")) {
+ LockDisplay(dpy);
+ dpy->flags |= XlibDisplayNoXkb;
+ UnlockDisplay(dpy);
+ if (debugMsg)
+ fprintf(stderr,"XKEYBOARD extension disabled or missing\n");
+ return False;
+ }
+
+ if ( (codes=XInitExtension(dpy,XkbName))==NULL ) {
+ LockDisplay(dpy);
+ dpy->flags |= XlibDisplayNoXkb;
+ UnlockDisplay(dpy);
+ if (debugMsg)
+ fprintf(stderr,"XKEYBOARD extension not present\n");
+ return False;
+ }
+ xkbi->codes = codes;
+ LockDisplay(dpy);
+
+ GetReq(kbUseExtension, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbUseExtension;
+ req->wantedMajor = XkbMajorVersion;
+ req->wantedMinor = XkbMinorVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.supported ) {
+ Bool fail;
+ fail= True;
+ if (debugMsg)
+ fprintf(stderr,
+ "XKEYBOARD version mismatch (want %d.%02d, got %d.%02d)\n",
+ XkbMajorVersion,XkbMinorVersion,
+ rep.serverMajor, rep.serverMinor);
+
+ /* pre-release 0.65 is very close to 1.00 */
+ if ((rep.serverMajor==0)&&(rep.serverMinor==65)) {
+ if (debugMsg)
+ fprintf(stderr,"Trying to fall back to version 0.65...");
+ GetReq(kbUseExtension, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbUseExtension;
+ req->wantedMajor = 0;
+ req->wantedMinor = 65;
+ if ( _XReply(dpy, (xReply *)&rep, 0, xFalse) && rep.supported ) {
+ if (debugMsg)
+ fprintf(stderr,"succeeded\n");
+ fail= False;
+ }
+ else if (debugMsg) fprintf(stderr,"failed\n");
+ }
+ if (fail) {
+ dpy->flags |= XlibDisplayNoXkb;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (major_rtrn) *major_rtrn= rep.serverMajor;
+ if (minor_rtrn) *minor_rtrn= rep.serverMinor;
+ return False;
+ }
+ }
+#ifdef DEBUG
+ else if ( forceIgnore ) {
+ fprintf(stderr,"Internal Error! XkbUseExtension succeeded with forceIgnore set\n");
+ }
+#endif
+ UnlockDisplay(dpy);
+ xkbi->srv_major= rep.serverMajor;
+ xkbi->srv_minor= rep.serverMinor;
+ if (major_rtrn) *major_rtrn= rep.serverMajor;
+ if (minor_rtrn) *minor_rtrn= rep.serverMinor;
+ if (debugMsg)
+ fprintf(stderr,"XKEYBOARD (version %d.%02d/%d.%02d) OK!\n",
+ XkbMajorVersion,XkbMinorVersion,
+ rep.serverMajor,rep.serverMinor);
+
+ ev_base = codes->first_event;
+ XESetWireToEvent(dpy,ev_base+XkbEventCode,wire_to_event);
+ SyncHandle();
+ return True;
+}
+
diff --git a/nx-X11/lib/X11/XKBleds.c b/nx-X11/lib/X11/XKBleds.c
new file mode 100644
index 000000000..89ab2e9ec
--- /dev/null
+++ b/nx-X11/lib/X11/XKBleds.c
@@ -0,0 +1,335 @@
+/* $Xorg: XKBleds.c,v 1.3 2000/08/17 19:45:03 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBleds.c,v 1.4 2003/04/13 19:22:18 dawes Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#define NEED_MAP_READERS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+Status
+XkbGetIndicatorState(Display *dpy,unsigned deviceSpec,unsigned *pStateRtrn)
+{
+ register xkbGetIndicatorStateReq *req;
+ xkbGetIndicatorStateReply rep;
+ XkbInfoPtr xkbi;
+ Bool ok;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbGetIndicatorState, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetIndicatorState;
+ req->deviceSpec = deviceSpec;
+ ok=_XReply(dpy, (xReply *)&rep, 0, xFalse);
+ if (ok && (pStateRtrn!=NULL))
+ *pStateRtrn= rep.state;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (ok?Success:BadImplementation);
+}
+
+Status
+_XkbReadGetIndicatorMapReply( Display * dpy,
+ xkbGetIndicatorMapReply * rep,
+ XkbDescPtr xkb,
+ int * nread_rtrn)
+{
+XkbIndicatorPtr leds;
+XkbReadBufferRec buf;
+
+ if ((!xkb->indicators)&&(XkbAllocIndicatorMaps(xkb)!=Success))
+ return BadAlloc;
+ leds= xkb->indicators;
+
+ leds->phys_indicators = rep->realIndicators;
+ if (rep->length>0) {
+ register int left;
+ if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
+ return BadAlloc;
+ if (nread_rtrn)
+ *nread_rtrn= (int)rep->length*4;
+ if (rep->which) {
+ register int i,bit;
+ left= (int)rep->which;
+ for (i=0,bit=1;(i<XkbNumIndicators)&&(left);i++,bit<<=1) {
+ if (left&bit) {
+ xkbIndicatorMapWireDesc *wire;
+ wire= (xkbIndicatorMapWireDesc *)
+ _XkbGetReadBufferPtr(&buf,
+ SIZEOF(xkbIndicatorMapWireDesc));
+ if (wire==NULL) {
+ _XkbFreeReadBuffer(&buf);
+ return BadAlloc;
+ }
+ leds->maps[i].flags= wire->flags;
+ leds->maps[i].which_groups= wire->whichGroups;
+ leds->maps[i].groups= wire->groups;
+ leds->maps[i].which_mods= wire->whichMods;
+ leds->maps[i].mods.mask= wire->mods;
+ leds->maps[i].mods.real_mods= wire->realMods;
+ leds->maps[i].mods.vmods= wire->virtualMods;
+ leds->maps[i].ctrls= wire->ctrls;
+ left&= ~bit;
+ }
+ }
+ }
+ left= _XkbFreeReadBuffer(&buf);
+ }
+ return Success;
+}
+
+Bool
+XkbGetIndicatorMap(Display *dpy,unsigned long which,XkbDescPtr xkb)
+{
+ register xkbGetIndicatorMapReq * req;
+ xkbGetIndicatorMapReply rep;
+ XkbInfoPtr xkbi;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ if ((!which)||(!xkb))
+ return BadValue;
+
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ if (!xkb->indicators) {
+ xkb->indicators = _XkbTypedCalloc(1,XkbIndicatorRec);
+ if (!xkb->indicators) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadAlloc;
+ }
+ }
+ GetReq(kbGetIndicatorMap, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetIndicatorMap;
+ req->deviceSpec = xkb->device_spec;
+ req->which = (CARD32)which;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadValue;
+ }
+ status= _XkbReadGetIndicatorMapReply(dpy,&rep,xkb,NULL);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Bool
+XkbSetIndicatorMap(Display *dpy,unsigned long which,XkbDescPtr xkb)
+{
+ register xkbSetIndicatorMapReq *req;
+ register int i,bit;
+ int nMaps;
+ xkbIndicatorMapWireDesc *wire;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!xkb)||(!which)||(!xkb->indicators))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetIndicatorMap, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetIndicatorMap;
+ req->deviceSpec = xkb->device_spec;
+ req->which = (CARD32)which;
+ for (i=nMaps=0,bit=1;i<32;i++,bit<<=1) {
+ if (which&bit)
+ nMaps++;
+ }
+ req->length+= (nMaps*sizeof(XkbIndicatorMapRec))/4;
+ BufAlloc(xkbIndicatorMapWireDesc *,wire,
+ (nMaps*SIZEOF(xkbIndicatorMapWireDesc)));
+ for (i=0,bit=1;i<32;i++,bit<<=1) {
+ if (which&bit) {
+ wire->flags= xkb->indicators->maps[i].flags;
+ wire->whichGroups= xkb->indicators->maps[i].which_groups;
+ wire->groups= xkb->indicators->maps[i].groups;
+ wire->whichMods= xkb->indicators->maps[i].which_mods;
+ wire->mods= xkb->indicators->maps[i].mods.real_mods;
+ wire->virtualMods= xkb->indicators->maps[i].mods.vmods;
+ wire->ctrls= xkb->indicators->maps[i].ctrls;
+ wire++;
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbGetNamedDeviceIndicator( Display * dpy,
+ unsigned device,
+ unsigned class,
+ unsigned id,
+ Atom name,
+ int * pNdxRtrn,
+ Bool * pStateRtrn,
+ XkbIndicatorMapPtr pMapRtrn,
+ Bool * pRealRtrn)
+{
+ register xkbGetNamedIndicatorReq *req;
+ xkbGetNamedIndicatorReply rep;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) || (name==None) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbGetNamedIndicator, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetNamedIndicator;
+ req->deviceSpec = device;
+ req->ledClass = class;
+ req->ledID = id;
+ req->indicator = (CARD32)name;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ if ((!rep.found)||(!rep.supported))
+ return False;
+ if (pNdxRtrn!=NULL)
+ *pNdxRtrn= rep.ndx;
+ if (pStateRtrn!=NULL)
+ *pStateRtrn= rep.on;
+ if (pMapRtrn!=NULL) {
+ pMapRtrn->flags= rep.flags;
+ pMapRtrn->which_groups= rep.whichGroups;
+ pMapRtrn->groups= rep.groups;
+ pMapRtrn->which_mods= rep.whichMods;
+ pMapRtrn->mods.mask= rep.mods;
+ pMapRtrn->mods.real_mods= rep.realMods;
+ pMapRtrn->mods.vmods= rep.virtualMods;
+ pMapRtrn->ctrls= rep.ctrls;
+ }
+ if (pRealRtrn!=NULL)
+ *pRealRtrn= rep.realIndicator;
+ return True;
+}
+
+Bool
+XkbGetNamedIndicator( Display * dpy,
+ Atom name,
+ int * pNdxRtrn,
+ Bool * pStateRtrn,
+ XkbIndicatorMapPtr pMapRtrn,
+ Bool * pRealRtrn)
+{
+ return XkbGetNamedDeviceIndicator(dpy,XkbUseCoreKbd,
+ XkbDfltXIClass,XkbDfltXIId,
+ name,pNdxRtrn,pStateRtrn,
+ pMapRtrn,pRealRtrn);
+}
+
+Bool
+XkbSetNamedDeviceIndicator( Display * dpy,
+ unsigned device,
+ unsigned class,
+ unsigned id,
+ Atom name,
+ Bool changeState,
+ Bool state,
+ Bool createNewMap,
+ XkbIndicatorMapPtr pMap)
+{
+ register xkbSetNamedIndicatorReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) || (name==None) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetNamedIndicator, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetNamedIndicator;
+ req->deviceSpec = device;
+ req->ledClass = class;
+ req->ledID = id;
+ req->indicator= (CARD32)name;
+ req->setState= changeState;
+ if (req->setState)
+ req->on= state;
+ else req->on= False;
+ if (pMap!=NULL) {
+ req->setMap= True;
+ req->createMap= createNewMap;
+ req->flags= pMap->flags;
+ req->whichGroups= pMap->which_groups;
+ req->groups= pMap->groups;
+ req->whichMods= pMap->which_mods;
+ req->realMods= pMap->mods.real_mods;
+ req->virtualMods= pMap->mods.vmods;
+ req->ctrls= pMap->ctrls;
+ }
+ else {
+ req->setMap= False;
+ req->createMap= False;
+ req->flags= 0;
+ req->whichGroups= 0;
+ req->groups= 0;
+ req->whichMods= 0;
+ req->realMods= 0;
+ req->virtualMods= 0;
+ req->ctrls= 0;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XkbSetNamedIndicator( Display * dpy,
+ Atom name,
+ Bool changeState,
+ Bool state,
+ Bool createNewMap,
+ XkbIndicatorMapPtr pMap)
+{
+ return XkbSetNamedDeviceIndicator(dpy,XkbUseCoreKbd,
+ XkbDfltXIClass,XkbDfltXIId,
+ name,changeState,state,
+ createNewMap,pMap);
+}
diff --git a/nx-X11/lib/X11/XKBlib.h b/nx-X11/lib/X11/XKBlib.h
new file mode 100644
index 000000000..6a5dc8a7c
--- /dev/null
+++ b/nx-X11/lib/X11/XKBlib.h
@@ -0,0 +1,1151 @@
+/* $Xorg: XKBlib.h,v 1.6 2000/08/17 19:45:03 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBlib.h,v 3.5 2003/04/17 02:06:31 dawes Exp $ */
+
+#ifndef _XKBLIB_H_
+#define _XKBLIB_H_
+
+#include <X11/Xlib.h>
+#include <X11/extensions/XKBstr.h>
+
+typedef struct _XkbAnyEvent {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* # of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XKB event minor code */
+ unsigned int device; /* device ID */
+} XkbAnyEvent;
+
+typedef struct _XkbNewKeyboardNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbNewKeyboardNotify */
+ int device; /* device ID */
+ int old_device; /* device ID of previous keyboard */
+ int min_key_code; /* minimum key code */
+ int max_key_code; /* maximum key code */
+ int old_min_key_code;/* min key code of previous kbd */
+ int old_max_key_code;/* max key code of previous kbd */
+ unsigned int changed; /* changed aspects of the keyboard */
+ char req_major; /* major and minor opcode of req */
+ char req_minor; /* that caused change, if applicable */
+} XkbNewKeyboardNotifyEvent;
+
+typedef struct _XkbMapNotifyEvent {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbMapNotify */
+ int device; /* device ID */
+ unsigned int changed; /* fields which have been changed */
+ unsigned int flags; /* reserved */
+ int first_type; /* first changed key type */
+ int num_types; /* number of changed key types */
+ KeyCode min_key_code;
+ KeyCode max_key_code;
+ KeyCode first_key_sym;
+ KeyCode first_key_act;
+ KeyCode first_key_behavior;
+ KeyCode first_key_explicit;
+ KeyCode first_modmap_key;
+ KeyCode first_vmodmap_key;
+ int num_key_syms;
+ int num_key_acts;
+ int num_key_behaviors;
+ int num_key_explicit;
+ int num_modmap_keys;
+ int num_vmodmap_keys;
+ unsigned int vmods; /* mask of changed virtual mods */
+} XkbMapNotifyEvent;
+
+typedef struct _XkbStateNotifyEvent {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* # of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbStateNotify */
+ int device; /* device ID */
+ unsigned int changed; /* mask of changed state components */
+ int group; /* keyboard group */
+ int base_group; /* base keyboard group */
+ int latched_group; /* latched keyboard group */
+ int locked_group; /* locked keyboard group */
+ unsigned int mods; /* modifier state */
+ unsigned int base_mods; /* base modifier state */
+ unsigned int latched_mods; /* latched modifiers */
+ unsigned int locked_mods; /* locked modifiers */
+ int compat_state; /* compatibility state */
+ unsigned char grab_mods; /* mods used for grabs */
+ unsigned char compat_grab_mods;/* grab mods for non-XKB clients */
+ unsigned char lookup_mods; /* mods sent to clients */
+ unsigned char compat_lookup_mods; /* mods sent to non-XKB clients */
+ int ptr_buttons; /* pointer button state */
+ KeyCode keycode; /* keycode that caused the change */
+ char event_type; /* KeyPress or KeyRelease */
+ char req_major; /* Major opcode of request */
+ char req_minor; /* Minor opcode of request */
+} XkbStateNotifyEvent;
+
+typedef struct _XkbControlsNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbControlsNotify */
+ int device; /* device ID */
+ unsigned int changed_ctrls; /* controls with changed sub-values */
+ unsigned int enabled_ctrls; /* controls currently enabled */
+ unsigned int enabled_ctrl_changes;/* controls just {en,dis}abled */
+ int num_groups; /* total groups on keyboard */
+ KeyCode keycode; /* key that caused change or 0 */
+ char event_type; /* type of event that caused change */
+ char req_major; /* if keycode==0, major and minor */
+ char req_minor; /* opcode of req that caused change */
+} XkbControlsNotifyEvent;
+
+typedef struct _XkbIndicatorNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbIndicatorNotify */
+ int device; /* device ID */
+ unsigned int changed; /* indicators with new state or map */
+ unsigned int state; /* current state of all indicators */
+} XkbIndicatorNotifyEvent;
+
+typedef struct _XkbNamesNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbNamesNotify */
+ int device; /* device ID */
+ unsigned int changed; /* names that have changed */
+ int first_type; /* first key type with new name */
+ int num_types; /* number of key types with new names */
+ int first_lvl; /* first key type new new level names */
+ int num_lvls; /* # of key types w/new level names */
+ int num_aliases; /* total number of key aliases*/
+ int num_radio_groups;/* total number of radio groups */
+ unsigned int changed_vmods; /* virtual modifiers with new names */
+ unsigned int changed_groups; /* groups with new names */
+ unsigned int changed_indicators;/* indicators with new names */
+ int first_key; /* first key with new name */
+ int num_keys; /* number of keys with new names */
+} XkbNamesNotifyEvent;
+
+typedef struct _XkbCompatMapNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbCompatMapNotify */
+ int device; /* device ID */
+ unsigned int changed_groups; /* groups with new compat maps */
+ int first_si; /* first new symbol interp */
+ int num_si; /* number of new symbol interps */
+ int num_total_si; /* total # of symbol interps */
+} XkbCompatMapNotifyEvent;
+
+typedef struct _XkbBellNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbBellNotify */
+ int device; /* device ID */
+ int percent; /* requested volume as a % of maximum */
+ int pitch; /* requested pitch in Hz */
+ int duration; /* requested duration in useconds */
+ int bell_class; /* (input extension) feedback class */
+ int bell_id; /* (input extension) ID of feedback */
+ Atom name; /* "name" of requested bell */
+ Window window; /* window associated with event */
+ Bool event_only; /* "event only" requested */
+} XkbBellNotifyEvent;
+
+typedef struct _XkbActionMessage {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbActionMessage */
+ int device; /* device ID */
+ KeyCode keycode; /* key that generated the event */
+ Bool press; /* true if act caused by key press */
+ Bool key_event_follows;/* true if key event also generated */
+ int group; /* effective group */
+ unsigned int mods; /* effective mods */
+ char message[XkbActionMessageLength+1];
+ /* message -- leave space for NUL */
+} XkbActionMessageEvent;
+
+typedef struct _XkbAccessXNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbAccessXNotify */
+ int device; /* device ID */
+ int detail; /* XkbAXN_* */
+ int keycode; /* key of event */
+ int sk_delay; /* current slow keys delay */
+ int debounce_delay; /* current debounce delay */
+} XkbAccessXNotifyEvent;
+
+typedef struct _XkbExtensionDeviceNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbExtensionDeviceNotify */
+ int device; /* device ID */
+ unsigned int reason; /* reason for the event */
+ unsigned int supported; /* mask of supported features */
+ unsigned int unsupported; /* mask of unsupported features */
+ /* that some app tried to use */
+ int first_btn; /* first button that changed */
+ int num_btns; /* range of buttons changed */
+ unsigned int leds_defined; /* indicators with names or maps */
+ unsigned int led_state; /* current state of the indicators */
+ int led_class; /* feedback class for led changes */
+ int led_id; /* feedback id for led changes */
+} XkbExtensionDeviceNotifyEvent;
+
+typedef union _XkbEvent {
+ int type;
+ XkbAnyEvent any;
+ XkbNewKeyboardNotifyEvent new_kbd;
+ XkbMapNotifyEvent map;
+ XkbStateNotifyEvent state;
+ XkbControlsNotifyEvent ctrls;
+ XkbIndicatorNotifyEvent indicators;
+ XkbNamesNotifyEvent names;
+ XkbCompatMapNotifyEvent compat;
+ XkbBellNotifyEvent bell;
+ XkbActionMessageEvent message;
+ XkbAccessXNotifyEvent accessx;
+ XkbExtensionDeviceNotifyEvent device;
+ XEvent core;
+} XkbEvent;
+
+typedef struct _XkbKbdDpyState XkbKbdDpyStateRec,*XkbKbdDpyStatePtr;
+
+ /* XkbOpenDisplay error codes */
+#define XkbOD_Success 0
+#define XkbOD_BadLibraryVersion 1
+#define XkbOD_ConnectionRefused 2
+#define XkbOD_NonXkbServer 3
+#define XkbOD_BadServerVersion 4
+
+ /* Values for XlibFlags */
+#define XkbLC_ForceLatin1Lookup (1<<0)
+#define XkbLC_ConsumeLookupMods (1<<1)
+#define XkbLC_AlwaysConsumeShiftAndLock (1<<2)
+#define XkbLC_IgnoreNewKeyboards (1<<3)
+#define XkbLC_ControlFallback (1<<4)
+#define XkbLC_ConsumeKeysOnComposeFail (1<<29)
+#define XkbLC_ComposeLED (1<<30)
+#define XkbLC_BeepOnComposeFail (1<<31)
+
+#define XkbLC_AllComposeControls (0xc0000000)
+#define XkbLC_AllControls (0xc000001f)
+
+_XFUNCPROTOBEGIN
+
+extern Bool XkbIgnoreExtension(
+ Bool /* ignore */
+);
+
+extern Display *XkbOpenDisplay(
+ char * /* name */,
+ int * /* ev_rtrn */,
+ int * /* err_rtrn */,
+ int * /* major_rtrn */,
+ int * /* minor_rtrn */,
+ int * /* reason */
+);
+
+extern Bool XkbQueryExtension(
+ Display * /* dpy */,
+ int * /* opcodeReturn */,
+ int * /* eventBaseReturn */,
+ int * /* errorBaseReturn */,
+ int * /* majorRtrn */,
+ int * /* minorRtrn */
+);
+
+extern Bool XkbUseExtension(
+ Display * /* dpy */,
+ int * /* major_rtrn */,
+ int * /* minor_rtrn */
+);
+
+extern Bool XkbLibraryVersion(
+ int * /* libMajorRtrn */,
+ int * /* libMinorRtrn */
+);
+
+extern unsigned int XkbSetXlibControls(
+ Display* /* dpy */,
+ unsigned int /* affect */,
+ unsigned int /* values */
+);
+
+extern unsigned int XkbGetXlibControls(
+ Display* /* dpy */
+);
+
+extern unsigned int XkbXlibControlsImplemented(void);
+
+typedef Atom (*XkbInternAtomFunc)(
+ Display * /* dpy */,
+ _Xconst char * /* name */,
+ Bool /* only_if_exists */
+);
+
+typedef char * (*XkbGetAtomNameFunc)(
+ Display * /* dpy */,
+ Atom /* atom */
+);
+
+extern void XkbSetAtomFuncs(
+ XkbInternAtomFunc /* getAtom */,
+ XkbGetAtomNameFunc /* getName */
+);
+
+extern KeySym XkbKeycodeToKeysym(
+ Display * /* dpy */,
+#if NeedWidePrototypes
+ unsigned int /* kc */,
+#else
+ KeyCode /* kc */,
+#endif
+ int /* group */,
+ int /* level */
+);
+
+extern unsigned int XkbKeysymToModifiers(
+ Display * /* dpy */,
+ KeySym /* ks */
+);
+
+extern Bool XkbLookupKeySym(
+ Display * /* dpy */,
+ KeyCode /* keycode */,
+ unsigned int /* modifiers */,
+ unsigned int * /* modifiers_return */,
+ KeySym * /* keysym_return */
+);
+
+extern int XkbLookupKeyBinding(
+ Display * /* dpy */,
+ KeySym /* sym_rtrn */,
+ unsigned int /* mods */,
+ char * /* buffer */,
+ int /* nbytes */,
+ int * /* extra_rtrn */
+);
+
+extern Bool XkbTranslateKeyCode(
+ XkbDescPtr /* xkb */,
+ KeyCode /* keycode */,
+ unsigned int /* modifiers */,
+ unsigned int * /* modifiers_return */,
+ KeySym * /* keysym_return */
+);
+
+extern int XkbTranslateKeySym(
+ Display * /* dpy */,
+ register KeySym * /* sym_return */,
+ unsigned int /* modifiers */,
+ char * /* buffer */,
+ int /* nbytes */,
+ int * /* extra_rtrn */
+);
+
+extern Bool XkbSetAutoRepeatRate(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* delay */,
+ unsigned int /* interval */
+);
+
+extern Bool XkbGetAutoRepeatRate(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int * /* delayRtrn */,
+ unsigned int * /* intervalRtrn */
+);
+
+extern Bool XkbChangeEnabledControls(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* affect */,
+ unsigned int /* values */
+);
+
+extern Bool XkbDeviceBell(
+ Display * /* dpy */,
+ Window /* win */,
+ int /* deviceSpec */,
+ int /* bellClass */,
+ int /* bellID */,
+ int /* percent */,
+ Atom /* name */
+);
+
+extern Bool XkbForceDeviceBell(
+ Display * /* dpy */,
+ int /* deviceSpec */,
+ int /* bellClass */,
+ int /* bellID */,
+ int /* percent */
+);
+
+extern Bool XkbDeviceBellEvent(
+ Display * /* dpy */,
+ Window /* win */,
+ int /* deviceSpec */,
+ int /* bellClass */,
+ int /* bellID */,
+ int /* percent */,
+ Atom /* name */
+);
+
+extern Bool XkbBell(
+ Display * /* dpy */,
+ Window /* win */,
+ int /* percent */,
+ Atom /* name */
+);
+
+extern Bool XkbForceBell(
+ Display * /* dpy */,
+ int /* percent */
+);
+
+extern Bool XkbBellEvent(
+ Display * /* dpy */,
+ Window /* win */,
+ int /* percent */,
+ Atom /* name */
+);
+
+extern Bool XkbSelectEvents(
+ Display * /* dpy */,
+ unsigned int /* deviceID */,
+ unsigned int /* affect */,
+ unsigned int /* values */
+);
+
+extern Bool XkbSelectEventDetails(
+ Display * /* dpy */,
+ unsigned int /* deviceID */,
+ unsigned int /* eventType */,
+ unsigned long /* affect */,
+ unsigned long /* details */
+);
+
+extern void XkbNoteMapChanges(
+ XkbMapChangesPtr /* old */,
+ XkbMapNotifyEvent * /* new */,
+ unsigned int /* wanted */
+);
+
+extern void XkbNoteNameChanges(
+ XkbNameChangesPtr /* old */,
+ XkbNamesNotifyEvent * /* new */,
+ unsigned int /* wanted */
+);
+
+extern Status XkbGetIndicatorState(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int * /* pStateRtrn */
+);
+
+extern Status XkbGetDeviceIndicatorState(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* ledClass */,
+ unsigned int /* ledID */,
+ unsigned int * /* pStateRtrn */
+);
+
+extern Status XkbGetIndicatorMap(
+ Display * /* dpy */,
+ unsigned long /* which */,
+ XkbDescPtr /* desc */
+);
+
+extern Bool XkbSetIndicatorMap(
+ Display * /* dpy */,
+ unsigned long /* which */,
+ XkbDescPtr /* desc */
+);
+
+#define XkbNoteIndicatorMapChanges(o,n,w) \
+ ((o)->map_changes|=((n)->map_changes&(w)))
+#define XkbNoteIndicatorStateChanges(o,n,w)\
+ ((o)->state_changes|=((n)->state_changes&(w)))
+#define XkbGetIndicatorMapChanges(d,x,c) \
+ (XkbGetIndicatorMap((d),(c)->map_changes,x)
+#define XkbChangeIndicatorMaps(d,x,c) \
+ (XkbSetIndicatorMap((d),(c)->map_changes,x))
+
+extern Bool XkbGetNamedIndicator(
+ Display * /* dpy */,
+ Atom /* name */,
+ int * /* pNdxRtrn */,
+ Bool * /* pStateRtrn */,
+ XkbIndicatorMapPtr /* pMapRtrn */,
+ Bool * /* pRealRtrn */
+);
+
+extern Bool XkbGetNamedDeviceIndicator(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* ledClass */,
+ unsigned int /* ledID */,
+ Atom /* name */,
+ int * /* pNdxRtrn */,
+ Bool * /* pStateRtrn */,
+ XkbIndicatorMapPtr /* pMapRtrn */,
+ Bool * /* pRealRtrn */
+);
+
+extern Bool XkbSetNamedIndicator(
+ Display * /* dpy */,
+ Atom /* name */,
+ Bool /* changeState */,
+ Bool /* state */,
+ Bool /* createNewMap */,
+ XkbIndicatorMapPtr /* pMap */
+);
+
+extern Bool XkbSetNamedDeviceIndicator(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* ledClass */,
+ unsigned int /* ledID */,
+ Atom /* name */,
+ Bool /* changeState */,
+ Bool /* state */,
+ Bool /* createNewMap */,
+ XkbIndicatorMapPtr /* pMap */
+);
+
+extern Bool XkbLockModifiers(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* affect */,
+ unsigned int /* values */
+);
+
+extern Bool XkbLatchModifiers(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* affect */,
+ unsigned int /* values */
+);
+
+extern Bool XkbLockGroup(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* group */
+);
+
+extern Bool XkbLatchGroup(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* group */
+);
+
+extern Bool XkbSetServerInternalMods(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* affectReal */,
+ unsigned int /* realValues */,
+ unsigned int /* affectVirtual */,
+ unsigned int /* virtualValues */
+);
+
+extern Bool XkbSetIgnoreLockMods(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* affectReal */,
+ unsigned int /* realValues */,
+ unsigned int /* affectVirtual */,
+ unsigned int /* virtualValues */
+);
+
+
+extern Bool XkbVirtualModsToReal(
+ XkbDescPtr /* xkb */,
+ unsigned int /* virtual_mask */,
+ unsigned int * /* mask_rtrn */
+);
+
+extern Bool XkbComputeEffectiveMap(
+ XkbDescPtr /* xkb */,
+ XkbKeyTypePtr /* type */,
+ unsigned char * /* map_rtrn */
+);
+
+extern Status XkbInitCanonicalKeyTypes(
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ int /* keypadVMod */
+);
+
+extern XkbDescPtr XkbAllocKeyboard(
+ void
+);
+
+extern void XkbFreeKeyboard(
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ Bool /* freeDesc */
+);
+
+extern Status XkbAllocClientMap(
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ unsigned int /* nTypes */
+);
+
+extern Status XkbAllocServerMap(
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ unsigned int /* nActions */
+);
+
+extern void XkbFreeClientMap(
+ XkbDescPtr /* xkb */,
+ unsigned int /* what */,
+ Bool /* freeMap */
+);
+
+extern void XkbFreeServerMap(
+ XkbDescPtr /* xkb */,
+ unsigned int /* what */,
+ Bool /* freeMap */
+);
+
+extern XkbKeyTypePtr XkbAddKeyType(
+ XkbDescPtr /* xkb */,
+ Atom /* name */,
+ int /* map_count */,
+ Bool /* want_preserve */,
+ int /* num_lvls */
+);
+
+extern Status XkbAllocIndicatorMaps(
+ XkbDescPtr /* xkb */
+);
+
+extern void XkbFreeIndicatorMaps(
+ XkbDescPtr /* xkb */
+);
+
+extern XkbDescPtr XkbGetMap(
+ Display * /* dpy */,
+ unsigned int /* which */,
+ unsigned int /* deviceSpec */
+);
+
+extern Status XkbGetUpdatedMap(
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDescPtr /* desc */
+);
+
+extern Status XkbGetMapChanges(
+ Display * /* dpy */,
+ XkbDescPtr /* xkb */,
+ XkbMapChangesPtr /* changes */
+);
+
+
+extern Status XkbRefreshKeyboardMapping(
+ XkbMapNotifyEvent * /* event */
+);
+
+extern Status XkbGetKeyTypes(
+ Display * /* dpy */,
+ unsigned int /* first */,
+ unsigned int /* num */,
+ XkbDescPtr /* xkb */
+);
+
+extern Status XkbGetKeySyms(
+ Display * /* dpy */,
+ unsigned int /* first */,
+ unsigned int /* num */,
+ XkbDescPtr /* xkb */
+);
+
+extern Status XkbGetKeyActions(
+ Display * /* dpy */,
+ unsigned int /* first */,
+ unsigned int /* num */,
+ XkbDescPtr /* xkb */
+);
+
+extern Status XkbGetKeyBehaviors(
+ Display * /* dpy */,
+ unsigned int /* firstKey */,
+ unsigned int /* nKeys */,
+ XkbDescPtr /* desc */
+);
+
+extern Status XkbGetVirtualMods(
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDescPtr /* desc */
+);
+
+extern Status XkbGetKeyExplicitComponents(
+ Display * /* dpy */,
+ unsigned int /* firstKey */,
+ unsigned int /* nKeys */,
+ XkbDescPtr /* desc */
+);
+
+extern Status XkbGetKeyModifierMap(
+ Display * /* dpy */,
+ unsigned int /* firstKey */,
+ unsigned int /* nKeys */,
+ XkbDescPtr /* desc */
+);
+
+extern Status XkbGetKeyVirtualModMap(
+ Display * /* dpy */,
+ unsigned int /* first */,
+ unsigned int /* num */,
+ XkbDescPtr /* xkb */
+);
+
+extern Status XkbAllocControls(
+ XkbDescPtr /* xkb */,
+ unsigned int /* which*/
+);
+
+extern void XkbFreeControls(
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ Bool /* freeMap */
+);
+
+extern Status XkbGetControls(
+ Display * /* dpy */,
+ unsigned long /* which */,
+ XkbDescPtr /* desc */
+);
+
+extern Bool XkbSetControls(
+ Display * /* dpy */,
+ unsigned long /* which */,
+ XkbDescPtr /* desc */
+);
+
+extern void XkbNoteControlsChanges(
+ XkbControlsChangesPtr /* old */,
+ XkbControlsNotifyEvent * /* new */,
+ unsigned int /* wanted */
+);
+
+#define XkbGetControlsChanges(d,x,c) XkbGetControls(d,(c)->changed_ctrls,x)
+#define XkbChangeControls(d,x,c) XkbSetControls(d,(c)->changed_ctrls,x)
+
+extern Status XkbAllocCompatMap(
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ unsigned int /* nInterpret */
+);
+
+extern void XkbFreeCompatMap(
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ Bool /* freeMap */
+);
+
+extern Status XkbGetCompatMap(
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDescPtr /* xkb */
+);
+
+extern Bool XkbSetCompatMap(
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDescPtr /* xkb */,
+ Bool /* updateActions */
+);
+
+extern XkbSymInterpretPtr XkbAddSymInterpret(
+ XkbDescPtr /* xkb */,
+ XkbSymInterpretPtr /* si */,
+ Bool /* updateMap */,
+ XkbChangesPtr /* changes */
+);
+
+extern Status XkbAllocNames(
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ int /* nTotalRG */,
+ int /* nTotalAliases */
+);
+
+extern Status XkbGetNames(
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDescPtr /* desc */
+);
+
+extern Bool XkbSetNames(
+ Display * /* dpy */,
+ unsigned int /* which */,
+ unsigned int /* firstType */,
+ unsigned int /* nTypes */,
+ XkbDescPtr /* desc */
+);
+
+extern Bool XkbChangeNames(
+ Display * /* dpy */,
+ XkbDescPtr /* xkb */,
+ XkbNameChangesPtr /* changes */
+);
+
+extern void XkbFreeNames(
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ Bool /* freeMap */
+);
+
+
+extern Status XkbGetState(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ XkbStatePtr /* rtrnState */
+);
+
+extern Bool XkbSetMap(
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDescPtr /* desc */
+);
+
+extern Bool XkbChangeMap(
+ Display* /* dpy */,
+ XkbDescPtr /* desc */,
+ XkbMapChangesPtr /* changes */
+);
+
+extern Bool XkbSetDetectableAutoRepeat(
+ Display * /* dpy */,
+ Bool /* detectable */,
+ Bool * /* supported */
+);
+
+extern Bool XkbGetDetectableAutoRepeat(
+ Display * /* dpy */,
+ Bool * /* supported */
+);
+
+extern Bool XkbSetAutoResetControls(
+ Display * /* dpy */,
+ unsigned int /* changes */,
+ unsigned int * /* auto_ctrls */,
+ unsigned int * /* auto_values */
+);
+
+extern Bool XkbGetAutoResetControls(
+ Display * /* dpy */,
+ unsigned int * /* auto_ctrls */,
+ unsigned int * /* auto_ctrl_values */
+);
+
+extern Bool XkbSetPerClientControls(
+ Display * /* dpy */,
+ unsigned int /* change */,
+ unsigned int * /* values */
+);
+
+extern Bool XkbGetPerClientControls(
+ Display * /* dpy */,
+ unsigned int * /* ctrls */
+);
+
+extern Status XkbCopyKeyType(
+ XkbKeyTypePtr /* from */,
+ XkbKeyTypePtr /* into */
+);
+
+extern Status XkbCopyKeyTypes(
+ XkbKeyTypePtr /* from */,
+ XkbKeyTypePtr /* into */,
+ int /* num_types */
+);
+
+extern Status XkbResizeKeyType(
+ XkbDescPtr /* xkb */,
+ int /* type_ndx */,
+ int /* map_count */,
+ Bool /* want_preserve */,
+ int /* new_num_lvls */
+);
+
+extern KeySym *XkbResizeKeySyms(
+ XkbDescPtr /* desc */,
+ int /* forKey */,
+ int /* symsNeeded */
+);
+
+extern XkbAction *XkbResizeKeyActions(
+ XkbDescPtr /* desc */,
+ int /* forKey */,
+ int /* actsNeeded */
+);
+
+extern Status XkbChangeTypesOfKey(
+ XkbDescPtr /* xkb */,
+ int /* key */,
+ int /* num_groups */,
+ unsigned int /* groups */,
+ int * /* newTypes */,
+ XkbMapChangesPtr /* pChanges */
+);
+
+extern Status XkbChangeKeycodeRange(
+ XkbDescPtr /* xkb */,
+ int /* minKC */,
+ int /* maxKC */,
+ XkbChangesPtr /* changes */
+);
+
+/***====================================================================***/
+
+extern XkbComponentListPtr XkbListComponents(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ XkbComponentNamesPtr /* ptrns */,
+ int * /* max_inout */
+);
+
+extern void XkbFreeComponentList(
+ XkbComponentListPtr /* list */
+);
+
+extern XkbDescPtr XkbGetKeyboard(
+ Display * /* dpy */,
+ unsigned int /* which */,
+ unsigned int /* deviceSpec */
+);
+
+extern XkbDescPtr XkbGetKeyboardByName(
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ XkbComponentNamesPtr /* names */,
+ unsigned int /* want */,
+ unsigned int /* need */,
+ Bool /* load */
+);
+
+/***====================================================================***/
+
+extern int XkbKeyTypesForCoreSymbols( /* returns # of groups */
+ XkbDescPtr /* xkb */, /* keyboard device */
+ int /* map_width */, /* width of core KeySym array */
+ KeySym * /* core_syms */, /* always mapWidth symbols */
+ unsigned int /* protected */, /* explicit key types */
+ int * /* types_inout */, /* always four type indices */
+ KeySym * /* xkb_syms_rtrn */ /* must have enough space */
+);
+
+extern Bool XkbApplyCompatMapToKey( /* False only on error */
+ XkbDescPtr /* xkb */, /* keymap to be edited */
+ KeyCode /* key */, /* key to be updated */
+ XkbChangesPtr /* changes */ /* resulting changes to map */
+);
+
+extern Bool XkbUpdateMapFromCore( /* False only on error */
+ XkbDescPtr /* xkb */, /* XKB keyboard to be edited */
+ KeyCode /* first_key */, /* first changed key */
+ int /* num_keys */, /* number of changed keys */
+ int /* map_width */, /* width of core keymap */
+ KeySym * /* core_keysyms */, /* symbols from core keymap */
+ XkbChangesPtr /* changes */ /* resulting changes */
+);
+
+/***====================================================================***/
+
+extern XkbDeviceLedInfoPtr XkbAddDeviceLedInfo(
+ XkbDeviceInfoPtr /* devi */,
+ unsigned int /* ledClass */,
+ unsigned int /* ledId */
+);
+
+extern Status XkbResizeDeviceButtonActions(
+ XkbDeviceInfoPtr /* devi */,
+ unsigned int /* newTotal */
+);
+
+extern XkbDeviceInfoPtr XkbAllocDeviceInfo(
+ unsigned int /* deviceSpec */,
+ unsigned int /* nButtons */,
+ unsigned int /* szLeds */
+);
+
+extern void XkbFreeDeviceInfo(
+ XkbDeviceInfoPtr /* devi */,
+ unsigned int /* which */,
+ Bool /* freeDevI */
+);
+
+extern void XkbNoteDeviceChanges(
+ XkbDeviceChangesPtr /* old */,
+ XkbExtensionDeviceNotifyEvent * /* new */,
+ unsigned int /* wanted */
+);
+
+extern XkbDeviceInfoPtr XkbGetDeviceInfo(
+ Display * /* dpy */,
+ unsigned int /* which */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* ledClass */,
+ unsigned int /* ledID */
+);
+
+extern Status XkbGetDeviceInfoChanges(
+ Display * /* dpy */,
+ XkbDeviceInfoPtr /* devi */,
+ XkbDeviceChangesPtr /* changes */
+);
+
+extern Status XkbGetDeviceButtonActions(
+ Display * /* dpy */,
+ XkbDeviceInfoPtr /* devi */,
+ Bool /* all */,
+ unsigned int /* first */,
+ unsigned int /* nBtns */
+);
+
+extern Status XkbGetDeviceLedInfo(
+ Display * /* dpy */,
+ XkbDeviceInfoPtr /* devi */,
+ unsigned int /* ledClass (class, XIDflt, XIAll) */,
+ unsigned int /* ledId (id, XIDflt, XIAll) */,
+ unsigned int /* which (XkbXI_Indicator{Names,Map}Mask */
+);
+
+extern Bool XkbSetDeviceInfo(
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDeviceInfoPtr /* devi */
+);
+
+extern Bool XkbChangeDeviceInfo(
+ Display* /* dpy */,
+ XkbDeviceInfoPtr /* desc */,
+ XkbDeviceChangesPtr /* changes */
+);
+
+extern Bool XkbSetDeviceLedInfo(
+ Display * /* dpy */,
+ XkbDeviceInfoPtr /* devi */,
+ unsigned int /* ledClass */,
+ unsigned int /* ledID */,
+ unsigned int /* which */
+);
+
+extern Bool XkbSetDeviceButtonActions(
+ Display * /* dpy */,
+ XkbDeviceInfoPtr /* devi */,
+ unsigned int /* first */,
+ unsigned int /* nBtns */
+);
+
+/***====================================================================***/
+
+extern char XkbToControl(
+ char /* c */
+);
+
+/***====================================================================***/
+
+extern Bool XkbSetDebuggingFlags(
+ Display * /* dpy */,
+ unsigned int /* mask */,
+ unsigned int /* flags */,
+ char * /* msg */,
+ unsigned int /* ctrls_mask */,
+ unsigned int /* ctrls */,
+ unsigned int * /* rtrn_flags */,
+ unsigned int * /* rtrn_ctrls */
+);
+
+extern Bool XkbApplyVirtualModChanges(
+ XkbDescPtr /* xkb */,
+ unsigned int /* changed */,
+ XkbChangesPtr /* changes */
+);
+
+extern Bool XkbUpdateActionVirtualMods(
+ XkbDescPtr /* xkb */,
+ XkbAction * /* act */,
+ unsigned int /* changed */
+);
+
+extern void XkbUpdateKeyTypeVirtualMods(
+ XkbDescPtr /* xkb */,
+ XkbKeyTypePtr /* type */,
+ unsigned int /* changed */,
+ XkbChangesPtr /* changes */
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XKBLIB_H_ */
diff --git a/nx-X11/lib/X11/XKBlibint.h b/nx-X11/lib/X11/XKBlibint.h
new file mode 100644
index 000000000..a154d1bce
--- /dev/null
+++ b/nx-X11/lib/X11/XKBlibint.h
@@ -0,0 +1,345 @@
+/* $Xorg: XKBlibint.h,v 1.3 2000/08/17 19:45:04 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+
+********************************************************/
+/* $XFree86: xc/lib/X11/XKBlibint.h,v 3.5 2003/04/18 18:21:45 torrey Exp $ */
+
+#ifndef _XKBLIBINT_H_
+#define _XKBLIBINT_H_
+
+#include <X11/Xutil.h>
+#include <X11/XKBlib.h>
+
+#define XkbMapPending (1<<0)
+#define XkbXlibNewKeyboard (1<<1)
+
+typedef int (*XkbKSToMBFunc)(
+ XPointer /* priv */,
+ KeySym /* sym */,
+ char * /* buf */,
+ int /* len */,
+ int * /* extra_rtrn */
+);
+
+typedef KeySym (*XkbMBToKSFunc)(
+ XPointer /* priv */,
+ char * /* buf */,
+ int /* len */,
+ Status * /* status */
+);
+
+typedef KeySym (*XkbToUpperFunc)(
+ KeySym /* sym */
+);
+
+typedef struct _XkbConverters {
+ XkbKSToMBFunc KSToMB;
+ XPointer KSToMBPriv;
+ XkbMBToKSFunc MBToKS;
+ XPointer MBToKSPriv;
+ XkbToUpperFunc KSToUpper;
+} XkbConverters;
+
+extern XkbInternAtomFunc _XkbInternAtomFunc;
+extern XkbGetAtomNameFunc _XkbGetAtomNameFunc;
+
+typedef struct _XkbInfoRec {
+ unsigned flags;
+ unsigned xlib_ctrls;
+ XExtCodes *codes;
+ int srv_major;
+ int srv_minor;
+ unsigned selected_events;
+ unsigned short selected_nkn_details;
+ unsigned short selected_map_details;
+ XkbDescRec *desc;
+ XkbMapChangesRec changes;
+ Atom composeLED;
+ XkbConverters cvt;
+ XkbConverters latin1cvt;
+} XkbInfoRec, *XkbInfoPtr;
+
+
+#define _XkbUnavailable(d) \
+ (((d)->flags&XlibDisplayNoXkb) ||\
+ ((!(d)->xkb_info || (!(d)->xkb_info->desc)) && !_XkbLoadDpy(d)))
+
+#define _XkbCheckPendingRefresh(d,xi) {\
+ if ((xi)->flags&XkbXlibNewKeyboard)\
+ _XkbReloadDpy((d));\
+ else if ((xi)->flags&XkbMapPending) {\
+ if (XkbGetMapChanges((d),(xi)->desc, &(xi)->changes)==Success) {\
+ LockDisplay((d));\
+ (xi)->changes.changed= 0;\
+ UnlockDisplay((d));\
+ }\
+ }\
+}
+
+#define _XkbNeedModmap(i) ((!(i)->desc->map)||(!(i)->desc->map->modmap))
+
+ /*
+ * mask of the events that the "invisible" XKB support in Xlib needs
+ */
+#define XKB_XLIB_MAP_MASK (XkbAllClientInfoMask)
+
+ /*
+ * Handy helper macros
+ */
+#define XKB_INSURE_SIZE(f,t,nNum,oNum) {\
+ if ((f)==NULL) \
+ (f)=(t *)Xmalloc(sizeof(t)*(nNum));\
+ else if ((nNum)<(oNum))\
+ (f)=(t *)Xrealloc((f),sizeof(t)*(nNum));\
+ }
+
+typedef struct _XkbReadBuffer {
+ int error;
+ int size;
+ char *start;
+ char *data;
+} XkbReadBufferRec,*XkbReadBufferPtr;
+
+#define _XkbAlloc(s) Xmalloc((s))
+#define _XkbCalloc(n,s) Xcalloc((n),(s))
+#define _XkbRealloc(o,s) Xrealloc((o),(s))
+#define _XkbTypedAlloc(t) ((t *)Xmalloc(sizeof(t)))
+#define _XkbTypedCalloc(n,t) ((t *)Xcalloc((n),sizeof(t)))
+#define _XkbTypedRealloc(o,n,t) \
+ ((o)?(t *)Xrealloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
+#define _XkbClearElems(a,f,l,t) bzero(&(a)[f],((l)-(f)+1)*sizeof(t))
+#define _XkbFree(p) Xfree(p)
+
+_XFUNCPROTOBEGIN
+
+extern void _XkbReloadDpy(
+ Display * /* dpy */
+);
+
+extern KeySym _XKeycodeToKeysym(
+ Display* /* display */,
+#if NeedWidePrototypes
+ unsigned int /* keycode */,
+#else
+ KeyCode /* keycode */,
+#endif
+ int /* index */
+);
+
+extern KeyCode _XKeysymToKeycode(
+ Display* /* display */,
+ KeySym /* keysym */
+);
+
+extern KeySym _XLookupKeysym(
+ XKeyEvent* /* key_event */,
+ int /* index */
+);
+
+extern int _XRefreshKeyboardMapping(
+ XMappingEvent* /* event_map */
+);
+
+extern unsigned _XKeysymToModifiers(
+ Display * /* dpy */,
+ KeySym /* ks */
+);
+
+extern int _XTranslateKey(
+ register Display * /* dpy */,
+ KeyCode /* keycode */,
+ register unsigned int /* modifiers */,
+ unsigned int * /* modifiers_return */,
+ KeySym * /* keysym_return */
+);
+
+extern int _XTranslateKeySym(
+ Display * /* dpy */,
+ register KeySym /* symbol */,
+ unsigned int /* modifiers */,
+ char * /* buffer */,
+ int /* nbytes */
+);
+
+extern int _XLookupString(
+ register XKeyEvent * /* event */,
+ char * /* buffer */,
+ int /* nbytes */,
+ KeySym * /* keysym */,
+ XComposeStatus * /* status */
+);
+
+extern void _XkbNoteCoreMapChanges(
+ XkbMapChangesRec * /* old */,
+ XMappingEvent * /* new */,
+ unsigned int /* wanted */
+);
+
+extern int _XkbInitReadBuffer(
+ Display * /* dpy */,
+ XkbReadBufferPtr /* buf */,
+ int /* size */
+);
+
+extern int _XkbSkipReadBufferData(
+ XkbReadBufferPtr /* from */,
+ int /* size */
+);
+
+extern int _XkbCopyFromReadBuffer(
+ XkbReadBufferPtr /* from */,
+ char * /* to */,
+ int /* size */
+);
+
+
+#if defined(WORD64) || defined(LONG64)
+extern int _XkbReadCopyData32(
+ int * /* from */,
+ long * /* to */,
+ int /* num_words */
+);
+
+extern int _XkbWriteCopyData32(
+ unsigned long * /* from */,
+ CARD32 * /* to */,
+ int /* num_words */
+);
+
+extern int _XkbReadBufferCopy32(
+ XkbReadBufferPtr /* from */,
+ long * /* to */,
+ int /* size */
+);
+#else
+#define _XkbReadCopyData32(f,t,s) memcpy((char *)(t),(char *)(f),(s)*4)
+#define _XkbWriteCopyData32(f,t,s) memcpy((char *)(t),(char *)(f),(s)*4)
+#define _XkbReadBufferCopy32(f,t,s) _XkbCopyFromReadBuffer(f,(char *)t,(s)*4)
+#endif
+
+#ifndef NO_DEC_BINARY_COMPATIBILITY
+#define XKB_FORCE_INT_KEYSYM 1
+#endif
+
+#ifdef XKB_FORCE_INT_KEYSYM
+extern int _XkbReadCopyKeySyms(
+ int * /* from */,
+ KeySym * /* to */,
+ int /* num_words */
+);
+
+extern int _XkbWriteCopyKeySyms(
+ KeySym * /* from */,
+ CARD32 * /* to */,
+ int /* num_words */
+);
+
+extern int _XkbReadBufferCopyKeySyms(
+ XkbReadBufferPtr /* from */,
+#ifndef NO_DEC_BUG_FIX
+ KeySym * /* to */,
+#else
+ long * /* to */,
+#endif
+ int /* size */
+);
+#else
+#define _XkbReadCopyKeySyms(f,t,n) _XkbReadCopyData32(f,t,n)
+#define _XkbWriteCopyKeySyms(f,t,n) _XkbWriteCopyData32(f,t,n)
+#define _XkbReadBufferCopyKeySyms(f,t,s) _XkbReadBufferCopy32(f,t,s)
+#endif
+
+extern char *_XkbPeekAtReadBuffer(
+ XkbReadBufferPtr /* from */,
+ int /* size */
+);
+
+extern char *_XkbGetReadBufferPtr(
+ XkbReadBufferPtr /* from */,
+ int /* size */
+);
+#define _XkbGetTypedRdBufPtr(b,n,t) ((t *)_XkbGetReadBufferPtr(b,(n)*SIZEOF(t)))
+
+extern int _XkbFreeReadBuffer(
+ XkbReadBufferPtr /* buf */
+);
+
+extern Bool
+_XkbGetReadBufferCountedString(
+ XkbReadBufferPtr /* buf */,
+ char ** /* rtrn */
+);
+
+extern char *_XkbGetCharset(
+ void
+);
+
+extern int _XkbGetConverters(
+ char * /* encoding_name */,
+ XkbConverters * /* cvt_rtrn */
+);
+
+#ifdef NEED_MAP_READERS
+
+extern Status _XkbReadGetMapReply(
+ Display * /* dpy */,
+ xkbGetMapReply * /* rep */,
+ XkbDescRec * /* xkb */,
+ int * /* nread_rtrn */
+);
+
+extern Status _XkbReadGetCompatMapReply(
+ Display * /* dpy */,
+ xkbGetCompatMapReply * /* rep */,
+ XkbDescPtr /* xkb */,
+ int * /* nread_rtrn */
+);
+
+extern Status _XkbReadGetIndicatorMapReply(
+ Display * /* dpy */,
+ xkbGetIndicatorMapReply * /* rep */,
+ XkbDescPtr /* xkb */,
+ int * /* nread_rtrn */
+);
+
+extern Status _XkbReadGetNamesReply(
+ Display * /* dpy */,
+ xkbGetNamesReply * /* rep */,
+ XkbDescPtr /* xkb */,
+ int * /* nread_rtrn */
+);
+
+extern Status _XkbReadGetGeometryReply(
+ Display * /* dpy */,
+ xkbGetGeometryReply * /* rep */,
+ XkbDescPtr /* xkb */,
+ int * /* nread_rtrn */
+);
+
+#endif
+
+_XFUNCPROTOEND
+
+#endif /* _XKBLIBINT_H_ */
diff --git a/nx-X11/lib/X11/XKeysymDB b/nx-X11/lib/X11/XKeysymDB
new file mode 100644
index 000000000..f14695057
--- /dev/null
+++ b/nx-X11/lib/X11/XKeysymDB
@@ -0,0 +1,354 @@
+! $Xorg: XKeysymDB,v 1.3 2000/08/17 19:45:04 cpqbld Exp $
+! Copyright 1993 Massachusetts Institute of Technology
+!
+! 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 of M.I.T. not be used in advertising or
+! publicity pertaining to distribution of the software without specific,
+! written prior permission. M.I.T. makes no representations about the
+! suitability of this software for any purpose. It is provided "as is"
+! without express or implied warranty.
+!
+! $XFree86: xc/lib/X11/XKeysymDB,v 3.16 2003/02/11 02:51:10 dawes Exp $
+
+hpmute_acute :100000A8
+hpmute_grave :100000A9
+hpmute_asciicircum :100000AA
+hpmute_diaeresis :100000AB
+hpmute_asciitilde :100000AC
+hplira :100000AF
+hpguilder :100000BE
+hpYdiaeresis :100000EE
+hpIO :100000EE
+hplongminus :100000F6
+hpblock :100000FC
+apLineDel :1000FF00
+apCharDel :1000FF01
+apCopy :1000FF02
+apCut :1000FF03
+apPaste :1000FF04
+apMove :1000FF05
+apGrow :1000FF06
+apCmd :1000FF07
+apShell :1000FF08
+apLeftBar :1000FF09
+apRightBar :1000FF0A
+apLeftBox :1000FF0B
+apRightBox :1000FF0C
+apUpBox :1000FF0D
+apDownBox :1000FF0E
+apPop :1000FF0F
+apRead :1000FF10
+apEdit :1000FF11
+apSave :1000FF12
+apExit :1000FF13
+apRepeat :1000FF14
+hpModelock1 :1000FF48
+hpModelock2 :1000FF49
+hpReset :1000FF6C
+hpSystem :1000FF6D
+hpUser :1000FF6E
+hpClearLine :1000FF6F
+hpInsertLine :1000FF70
+hpDeleteLine :1000FF71
+hpInsertChar :1000FF72
+hpDeleteChar :1000FF73
+hpBackTab :1000FF74
+hpKP_BackTab :1000FF75
+apKP_parenleft :1000FFA8
+apKP_parenright :1000FFA9
+
+I2ND_FUNC_L :10004001
+I2ND_FUNC_R :10004002
+IREMOVE :10004003
+IREPEAT :10004004
+IA1 :10004101
+IA2 :10004102
+IA3 :10004103
+IA4 :10004104
+IA5 :10004105
+IA6 :10004106
+IA7 :10004107
+IA8 :10004108
+IA9 :10004109
+IA10 :1000410A
+IA11 :1000410B
+IA12 :1000410C
+IA13 :1000410D
+IA14 :1000410E
+IA15 :1000410F
+IB1 :10004201
+IB2 :10004202
+IB3 :10004203
+IB4 :10004204
+IB5 :10004205
+IB6 :10004206
+IB7 :10004207
+IB8 :10004208
+IB9 :10004209
+IB10 :1000420A
+IB11 :1000420B
+IB12 :1000420C
+IB13 :1000420D
+IB14 :1000420E
+IB15 :1000420F
+IB16 :10004210
+
+DRemove :1000FF00
+Dring_accent :1000FEB0
+Dcircumflex_accent :1000FE5E
+Dcedilla_accent :1000FE2C
+Dacute_accent :1000FE27
+Dgrave_accent :1000FE60
+Dtilde :1000FE7E
+Ddiaeresis :1000FE22
+
+osfCopy :1004FF02
+osfCut :1004FF03
+osfPaste :1004FF04
+osfBackTab :1004FF07
+osfBackSpace :1004FF08
+osfClear :1004FF0B
+osfEscape :1004FF1B
+osfAddMode :1004FF31
+osfPrimaryPaste :1004FF32
+osfQuickPaste :1004FF33
+osfPageLeft :1004FF40
+osfPageUp :1004FF41
+osfPageDown :1004FF42
+osfPageRight :1004FF43
+osfActivate :1004FF44
+osfMenuBar :1004FF45
+osfLeft :1004FF51
+osfUp :1004FF52
+osfRight :1004FF53
+osfDown :1004FF54
+osfPrior :1004FF55
+osfNext :1004FF56
+osfEndLine :1004FF57
+osfBeginLine :1004FF58
+osfEndData :1004FF59
+osfBeginData :1004FF5A
+osfPrevMenu :1004FF5B
+osfNextMenu :1004FF5C
+osfPrevField :1004FF5D
+osfNextField :1004FF5E
+osfSelect :1004FF60
+osfInsert :1004FF63
+osfUndo :1004FF65
+osfMenu :1004FF67
+osfCancel :1004FF69
+osfHelp :1004FF6A
+osfSelectAll :1004FF71
+osfDeselectAll :1004FF72
+osfReselect :1004FF73
+osfExtend :1004FF74
+osfRestore :1004FF78
+osfSwitchDirection :1004FF7E
+osfPriorMinor :1004FFF5
+osfNextMinor :1004FFF6
+osfRightLine :1004FFF7
+osfLeftLine :1004FFF8
+osfDelete :1004FFFF
+
+SunFA_Grave :1005FF00
+SunFA_Circum :1005FF01
+SunFA_Tilde :1005FF02
+SunFA_Acute :1005FF03
+SunFA_Diaeresis :1005FF04
+SunFA_Cedilla :1005FF05
+SunF36 :1005FF10
+SunF37 :1005FF11
+SunSys_Req :1005FF60
+SunProps :1005FF70
+SunFront :1005FF71
+SunCopy :1005FF72
+SunOpen :1005FF73
+SunPaste :1005FF74
+SunCut :1005FF75
+SunPowerSwitch :1005FF76
+SunAudioLowerVolume :1005FF77
+SunAudioMute :1005FF78
+SunAudioRaiseVolume :1005FF79
+SunVideoDegauss :1005FF7A
+SunVideoLowerBrightness :1005FF7B
+SunVideoRaiseBrightness :1005FF7C
+SunPowerSwitchShift :1005FF7D
+
+SunCompose :FF20
+SunPageUp :FF55
+SunPageDown :FF56
+SunPrint_Screen :FF61
+SunUndo :FF65
+SunAgain :FF66
+SunFind :FF68
+SunStop :FF69
+SunAltGraph :FF7E
+
+WYSetup :1006FF00
+
+ncdSetup :1006FF00
+
+XeroxPointerButton1 :10070001
+XeroxPointerButton2 :10070002
+XeroxPointerButton3 :10070003
+XeroxPointerButton4 :10070004
+XeroxPointerButton5 :10070005
+
+! The definitions here should match <X11/XF86keysym.h>
+XF86ModeLock :1008FF01
+XF86Standby :1008FF10
+XF86AudioLowerVolume :1008FF11
+XF86AudioMute :1008FF12
+XF86AudioRaiseVolume :1008FF13
+XF86AudioPlay :1008FF14
+XF86AudioStop :1008FF15
+XF86AudioPrev :1008FF16
+XF86AudioNext :1008FF17
+XF86HomePage :1008FF18
+XF86Mail :1008FF19
+XF86Start :1008FF1A
+XF86Search :1008FF1B
+XF86AudioRecord :1008FF1C
+XF86Calculator :1008FF1D
+XF86Memo :1008FF1E
+XF86ToDoList :1008FF1F
+XF86Calendar :1008FF20
+XF86PowerDown :1008FF21
+XF86ContrastAdjust :1008FF22
+XF86RockerUp :1008FF23
+XF86RockerDown :1008FF24
+XF86RockerEnter :1008FF25
+XF86Back :1008FF26
+XF86Forward :1008FF27
+XF86Stop :1008FF28
+XF86Refresh :1008FF29
+XF86PowerOff :1008FF2A
+XF86WakeUp :1008FF2B
+XF86Eject :1008FF2C
+XF86ScreenSaver :1008FF2D
+XF86WWW :1008FF2E
+XF86Sleep :1008FF2F
+XF86Favorites :1008FF30
+XF86AudioPause :1008FF31
+XF86AudioMedia :1008FF32
+XF86MyComputer :1008FF33
+XF86VendorHome :1008FF34
+XF86LightBulb :1008FF35
+XF86Shop :1008FF36
+XF86History :1008FF37
+XF86OpenURL :1008FF38
+XF86AddFavorite :1008FF39
+XF86HotLinks :1008FF3A
+XF86BrightnessAdjust :1008FF3B
+XF86Finance :1008FF3C
+XF86Community :1008FF3D
+XF86AudioRewind :1008FF3E
+XF86BackForward :1008FF3F
+XF86Launch0 :1008FF40
+XF86Launch1 :1008FF41
+XF86Launch2 :1008FF42
+XF86Launch3 :1008FF43
+XF86Launch4 :1008FF44
+XF86Launch5 :1008FF45
+XF86Launch6 :1008FF46
+XF86Launch7 :1008FF47
+XF86Launch8 :1008FF48
+XF86Launch9 :1008FF49
+XF86LaunchA :1008FF4A
+XF86LaunchB :1008FF4B
+XF86LaunchC :1008FF4C
+XF86LaunchD :1008FF4D
+XF86LaunchE :1008FF4E
+XF86LaunchF :1008FF4F
+XF86ApplicationLeft :1008FF50
+XF86ApplicationRight :1008FF51
+XF86Book :1008FF52
+XF86CD :1008FF53
+XF86Calculater :1008FF54
+XF86Clear :1008FF55
+XF86Close :1008FF56
+XF86Copy :1008FF57
+XF86Cut :1008FF58
+XF86Display :1008FF59
+XF86DOS :1008FF5A
+XF86Documents :1008FF5B
+XF86Excel :1008FF5C
+XF86Explorer :1008FF5D
+XF86Game :1008FF5E
+XF86Go :1008FF5F
+XF86iTouch :1008FF60
+XF86LogOff :1008FF61
+XF86Market :1008FF62
+XF86Meeting :1008FF63
+XF86MenuKB :1008FF65
+XF86MenuPB :1008FF66
+XF86MySites :1008FF67
+XF86New :1008FF68
+XF86News :1008FF69
+XF86OfficeHome :1008FF6A
+XF86Open :1008FF6B
+XF86Option :1008FF6C
+XF86Paste :1008FF6D
+XF86Phone :1008FF6E
+XF86Q :1008FF70
+XF86Reply :1008FF72
+XF86Reload :1008FF73
+XF86RotateWindows :1008FF74
+XF86RotationPB :1008FF75
+XF86RotationKB :1008FF76
+XF86Save :1008FF77
+XF86ScrollUp :1008FF78
+XF86ScrollDown :1008FF79
+XF86ScrollClick :1008FF7A
+XF86Send :1008FF7B
+XF86Spell :1008FF7C
+XF86SplitScreen :1008FF7D
+XF86Support :1008FF7E
+XF86TaskPane :1008FF7F
+XF86Terminal :1008FF80
+XF86Tools :1008FF81
+XF86Travel :1008FF82
+XF86UserPB :1008FF84
+XF86User1KB :1008FF85
+XF86User2KB :1008FF86
+XF86Video :1008FF87
+XF86WheelButton :1008FF88
+XF86Word :1008FF89
+XF86Xfer :1008FF8A
+XF86ZoomIn :1008FF8B
+XF86ZoomOut :1008FF8C
+XF86Away :1008FF8D
+XF86Messenger :1008FF8E
+XF86WebCam :1008FF8F
+XF86MailForward :1008FF90
+XF86Pictures :1008FF91
+XF86Music :1008FF92
+
+! XFree86 special action keys
+XF86_Switch_VT_1 :1008FE01
+XF86_Switch_VT_2 :1008FE02
+XF86_Switch_VT_3 :1008FE03
+XF86_Switch_VT_4 :1008FE04
+XF86_Switch_VT_5 :1008FE05
+XF86_Switch_VT_6 :1008FE06
+XF86_Switch_VT_7 :1008FE07
+XF86_Switch_VT_8 :1008FE08
+XF86_Switch_VT_9 :1008FE09
+XF86_Switch_VT_10 :1008FE0A
+XF86_Switch_VT_11 :1008FE0B
+XF86_Switch_VT_12 :1008FE0C
+XF86_Ungrab :1008FE20
+XF86_ClearGrab :1008FE21
+XF86_Next_VMode :1008FE22
+XF86_Prev_VMode :1008FE23
+
+usldead_acute :100000A8
+usldead_grave :100000A9
+usldead_diaeresis :100000AB
+usldead_asciicircum :100000AA
+usldead_asciitilde :100000AC
+usldead_cedilla :1000FE2C
+usldead_ring :1000FEB0
diff --git a/nx-X11/lib/X11/XRGB.c b/nx-X11/lib/X11/XRGB.c
new file mode 100644
index 000000000..0d7e24c7d
--- /dev/null
+++ b/nx-X11/lib/X11/XRGB.c
@@ -0,0 +1,244 @@
+/* $Xorg: XRGB.c,v 1.3 2000/08/17 19:45:04 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsRtoX.c
+ *
+ * DESCRIPTION
+ * Convert color specifications in XcmsRGB format in one array of
+ * XcmsColor structures to RGB in an array of XColor structures.
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/XRGB.c,v 3.3 2001/07/29 05:01:11 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+/*
+ * LOCAL VARIABLES
+ */
+
+static unsigned short const MASK[17] = {
+ 0x0000, /* 0 bitsPerRGB */
+ 0x8000, /* 1 bitsPerRGB */
+ 0xc000, /* 2 bitsPerRGB */
+ 0xe000, /* 3 bitsPerRGB */
+ 0xf000, /* 4 bitsPerRGB */
+ 0xf800, /* 5 bitsPerRGB */
+ 0xfc00, /* 6 bitsPerRGB */
+ 0xfe00, /* 7 bitsPerRGB */
+ 0xff00, /* 8 bitsPerRGB */
+ 0xff80, /* 9 bitsPerRGB */
+ 0xffc0, /* 10 bitsPerRGB */
+ 0xffe0, /* 11 bitsPerRGB */
+ 0xfff0, /* 12 bitsPerRGB */
+ 0xfff8, /* 13 bitsPerRGB */
+ 0xfffc, /* 14 bitsPerRGB */
+ 0xfffe, /* 15 bitsPerRGB */
+ 0xffff /* 16 bitsPerRGB */
+};
+
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsRGB_to_XColor -
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsRGB_to_XColor(
+ XcmsColor *pColors,
+ XColor *pXColors,
+ unsigned int nColors)
+/*
+ * DESCRIPTION
+ * Translates a color specification in XcmsRGBFormat in a XcmsColor
+ * structure to an XColor structure.
+ *
+ * RETURNS
+ * void.
+ */
+{
+ for (; nColors--; pXColors++, pColors++) {
+ pXColors->pixel = pColors->pixel;
+ pXColors->red = pColors->spec.RGB.red;
+ pXColors->green = pColors->spec.RGB.green;
+ pXColors->blue = pColors->spec.RGB.blue;
+ pXColors->flags = (DoRed | DoGreen | DoBlue);
+ }
+}
+
+
+/*
+ * NAME
+ * _XColor_to_XcmsRGB
+ *
+ * SYNOPSIS
+ */
+void
+_XColor_to_XcmsRGB(
+ XcmsCCC ccc,
+ XColor *pXColors,
+ XcmsColor *pColors,
+ unsigned int nColors)
+/*
+ * DESCRIPTION
+ * Translates an RGB color specification in an XColor
+ * structure to an XcmsRGB structure.
+ *
+ * IMPORTANT NOTE: Bit replication that may have been caused
+ * with ResolveColor() routine in the X Server is undone
+ * here if requested! For example, if red = 0xcaca and the
+ * bits_per_rgb is 8, then spec.RGB.red will be 0xca00.
+ *
+ * RETURNS
+ * void
+ */
+{
+ int bits_per_rgb = ccc->visual->bits_per_rgb;
+
+ for (; nColors--; pXColors++, pColors++) {
+ pColors->spec.RGB.red = (pXColors->red & MASK[bits_per_rgb]);
+ pColors->spec.RGB.green = (pXColors->green & MASK[bits_per_rgb]);
+ pColors->spec.RGB.blue = (pXColors->blue & MASK[bits_per_rgb]);
+ pColors->format = XcmsRGBFormat;
+ pColors->pixel = pXColors->pixel;
+ }
+}
+
+
+/*
+ * NAME
+ * _XcmsResolveColor
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsResolveColor(
+ XcmsCCC ccc,
+ XcmsColor *pXcmsColor)
+/*
+ * DESCRIPTION
+ * Uses the X Server ResolveColor() algorithm to
+ * modify values to closest values supported by hardware.
+ * Old algorithm simply masked low-order bits. The new algorithm
+ * has the effect of replicating significant bits into lower order
+ * bits in order to stretch the hardware value into all 16 bits.
+ *
+ * On a display with N-bit DACs, the "hardware" color is computed as:
+ *
+ * ((unsignedlong)(ClientValue >> (16-N)) * 0xFFFF) / ((1 << N) - 1)
+ *
+ *
+ * RETURNS
+ * void.
+ */
+{
+ int shift;
+ int max_color;
+
+ shift = 16 - ccc->visual->bits_per_rgb;
+ max_color = (1 << ccc->visual->bits_per_rgb) - 1;
+
+
+ pXcmsColor->spec.RGB.red =
+ ((unsigned long)(pXcmsColor->spec.RGB.red >> shift) * 0xFFFF)
+ / max_color;
+ pXcmsColor->spec.RGB.green =
+ ((unsigned long)(pXcmsColor->spec.RGB.green >> shift) * 0xFFFF)
+ / max_color;
+ pXcmsColor->spec.RGB.blue =
+ ((unsigned long)(pXcmsColor->spec.RGB.blue >> shift) * 0xFFFF)
+ / max_color;
+}
+
+
+/*
+ * NAME
+ * _XcmsUnresolveColor
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsUnresolveColor(
+ XcmsCCC ccc,
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * Masks out insignificant bits.
+ *
+ * RETURNS
+ * void.
+ *
+ * ASSUMPTIONS
+ * format == XcmsRGBFormat
+ */
+{
+ int bits_per_rgb = ccc->visual->bits_per_rgb;
+
+ pColor->spec.RGB.red &= MASK[bits_per_rgb];
+ pColor->spec.RGB.green &= MASK[bits_per_rgb];
+ pColor->spec.RGB.blue &= MASK[bits_per_rgb];
+}
+
+
+/*
+ * NAME
+ * _XUnresolveColor
+ *
+ * SYNOPSIS
+ */
+void
+_XUnresolveColor(
+ XcmsCCC ccc,
+ XColor *pXColor)
+/*
+ * DESCRIPTION
+ * Masks out insignificant bits.
+ *
+ * RETURNS
+ * void.
+ */
+{
+ int bits_per_rgb = ccc->visual->bits_per_rgb;
+
+ pXColor->red &= MASK[bits_per_rgb];
+ pXColor->green &= MASK[bits_per_rgb];
+ pXColor->blue &= MASK[bits_per_rgb];
+}
+
diff --git a/nx-X11/lib/X11/XYZ.c b/nx-X11/lib/X11/XYZ.c
new file mode 100644
index 000000000..f5f17f356
--- /dev/null
+++ b/nx-X11/lib/X11/XYZ.c
@@ -0,0 +1,188 @@
+/* $Xorg: XYZ.c,v 1.3 2000/08/17 19:45:04 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * CIEXYZ.c
+ *
+ * DESCRIPTION
+ * CIE XYZ Color Space
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/XYZ.c,v 1.3 2001/01/17 19:41:49 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+#include <stdio.h> /* sscanf */
+
+/*
+ * DEFINES
+ * Internal definitions that need NOT be exported to any package
+ * or program using this package.
+ */
+#ifdef DBL_EPSILON
+# define XMY_DBL_EPSILON DBL_EPSILON
+#else
+# define XMY_DBL_EPSILON 0.00001
+#endif
+
+/*
+ * FORWARD DECLARATIONS
+ */
+static int CIEXYZ_ParseString(register char *spec, XcmsColor *pColor);
+
+/*
+ * LOCALS VARIABLES
+ */
+
+static XcmsConversionProc Fl_CIEXYZ_to_CIEXYZ[] = {
+ NULL
+};
+
+
+
+/*
+ * GLOBALS
+ * Variables declared in this package that are allowed
+ * to be used globally.
+ */
+ /*
+ * CIE XYZ Color Space
+ */
+XcmsColorSpace XcmsCIEXYZColorSpace =
+ {
+ _XcmsCIEXYZ_prefix, /* prefix */
+ XcmsCIEXYZFormat, /* id */
+ CIEXYZ_ParseString, /* parseString */
+ Fl_CIEXYZ_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_CIEXYZ, /* from_CIEXYZ */
+ 1
+ };
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CIEXYZ_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+CIEXYZ_ParseString(
+ register char *spec,
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsCIEXYZFormat.
+ * The assumed CIEXYZ string syntax is:
+ * CIEXYZ:<X>/<Y>/<Z>
+ * Where X, Y, and Z are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsCIEXYZ_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.CIEXYZ.X,
+ &pColor->spec.CIEXYZ.Y,
+ &pColor->spec.CIEXYZ.Z) != 3) {
+ return(XcmsFailure);
+ }
+ pColor->format = XcmsCIEXYZFormat;
+ pColor->pixel = 0;
+ return(_XcmsCIEXYZ_ValidSpec(pColor));
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELab_ValidSpec
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsCIEXYZ_ValidSpec(
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * Checks if color specification valid for CIE XYZ
+ *
+ * RETURNS
+ * XcmsFailure if invalid,
+ * XcmsSuccess if valid.
+ *
+ */
+{
+ if (pColor->format != XcmsCIEXYZFormat
+ ||
+ (pColor->spec.CIEXYZ.Y < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIEXYZ.Y > 1.0 + XMY_DBL_EPSILON)) {
+ return(XcmsFailure);
+ }
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/Xaixlcint.h b/nx-X11/lib/X11/Xaixlcint.h
new file mode 100644
index 000000000..2e4f3f521
--- /dev/null
+++ b/nx-X11/lib/X11/Xaixlcint.h
@@ -0,0 +1,54 @@
+/* $Xorg: Xaixlcint.h,v 1.3 2000/08/17 19:45:04 cpqbld Exp $ */
+/*
+ *
+ * Copyright IBM Corporation 1993
+ *
+ * All Rights Reserved
+ *
+ * License 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 IBM not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND
+ * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
+ * IBM 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.
+ *
+*/
+/************************************************************************/
+/* Xaixlcint.h */
+/*----------------------------------------------------------------------*/
+/* This file contains Xlcint.h extension for AIX. */
+/************************************************************************/
+#ifndef _Xaixlcint_h
+#define _Xaixlcint_h
+
+#include "Xlcint.h"
+#include <sys/lc_core.h>
+
+#define _LC_LDX 11
+#define _LC_LDX_R6 (_LC_LDX+1)
+#define _LC_VERSION_R5 5
+#define _LC_VERSION_R6 6
+
+typedef struct _LC_core_ldx_t {
+ _LC_object_t lc_object_header;
+ XLCd (*default_loader)();
+ Bool sticky;
+} _XlcCoreObjRec, *_XlcCoreObj;
+
+#if _LC_VERSION < 0x40000000
+#define __type_id type_id
+#define __magic magic
+#define __version version
+#endif
+
+#endif /*_Xaixlcint_h*/
diff --git a/nx-X11/lib/X11/Xatomtype.h b/nx-X11/lib/X11/Xatomtype.h
new file mode 100644
index 000000000..7ab7e5a04
--- /dev/null
+++ b/nx-X11/lib/X11/Xatomtype.h
@@ -0,0 +1,134 @@
+/* $Xorg: Xatomtype.h,v 1.4 2001/02/09 02:03:38 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.
+
+******************************************************************/
+
+#ifndef _XATOMTYPE_H_
+#define _XATOMTYPE_H_
+
+/*
+ * This files defines crock C structures for calling XGetWindowProperty and
+ * XChangeProperty. All fields must be longs as the semantics of property
+ * routines will handle conversion to and from actual 32 bit objects. If your
+ * compiler doesn't treat &structoflongs the same as &arrayoflongs[0], you
+ * will have some work to do.
+ */
+
+#define BOOL long
+#define SIGNEDINT long
+#define UNSIGNEDINT unsigned long
+#define RESOURCEID unsigned long
+
+
+/* this structure may be extended, but do not change the order */
+typedef struct {
+ UNSIGNEDINT flags;
+ SIGNEDINT x, y, width, height; /* need to cvt; only for pre-ICCCM */
+ SIGNEDINT minWidth, minHeight; /* need to cvt */
+ SIGNEDINT maxWidth, maxHeight; /* need to cvt */
+ SIGNEDINT widthInc, heightInc; /* need to cvt */
+ SIGNEDINT minAspectX, minAspectY; /* need to cvt */
+ SIGNEDINT maxAspectX, maxAspectY; /* need to cvt */
+ SIGNEDINT baseWidth,baseHeight; /* need to cvt; ICCCM version 1 */
+ SIGNEDINT winGravity; /* need to cvt; ICCCM version 1 */
+} xPropSizeHints;
+#define OldNumPropSizeElements 15 /* pre-ICCCM */
+#define NumPropSizeElements 18 /* ICCCM version 1 */
+
+/* this structure may be extended, but do not change the order */
+/* RGB properties */
+typedef struct {
+ RESOURCEID colormap;
+ UNSIGNEDINT red_max;
+ UNSIGNEDINT red_mult;
+ UNSIGNEDINT green_max;
+ UNSIGNEDINT green_mult;
+ UNSIGNEDINT blue_max;
+ UNSIGNEDINT blue_mult;
+ UNSIGNEDINT base_pixel;
+ RESOURCEID visualid; /* ICCCM version 1 */
+ RESOURCEID killid; /* ICCCM version 1 */
+} xPropStandardColormap;
+#define OldNumPropStandardColormapElements 8 /* pre-ICCCM */
+#define NumPropStandardColormapElements 10 /* ICCCM version 1 */
+
+
+/* this structure may be extended, but do not change the order */
+typedef struct {
+ UNSIGNEDINT flags;
+ BOOL input; /* need to convert */
+ SIGNEDINT initialState; /* need to cvt */
+ RESOURCEID iconPixmap;
+ RESOURCEID iconWindow;
+ SIGNEDINT iconX; /* need to cvt */
+ SIGNEDINT iconY; /* need to cvt */
+ RESOURCEID iconMask;
+ UNSIGNEDINT windowGroup;
+ } xPropWMHints;
+#define NumPropWMHintsElements 9 /* number of elements in this structure */
+
+/* this structure defines the icon size hints information */
+typedef struct {
+ SIGNEDINT minWidth, minHeight; /* need to cvt */
+ SIGNEDINT maxWidth, maxHeight; /* need to cvt */
+ SIGNEDINT widthInc, heightInc; /* need to cvt */
+ } xPropIconSize;
+#define NumPropIconSizeElements 6 /* number of elements in this structure */
+
+/* this structure defines the window manager state information */
+typedef struct {
+ SIGNEDINT state; /* need to cvt */
+ RESOURCEID iconWindow;
+} xPropWMState;
+#define NumPropWMStateElements 2 /* number of elements in struct */
+
+#undef BOOL
+#undef SIGNEDINT
+#undef UNSIGNEDINT
+#undef RESOURCEID
+
+#endif /* _XATOMTYPE_H_ */
diff --git a/nx-X11/lib/X11/Xcms.h b/nx-X11/lib/X11/Xcms.h
new file mode 100644
index 000000000..779bc52ff
--- /dev/null
+++ b/nx-X11/lib/X11/Xcms.h
@@ -0,0 +1,805 @@
+/* $Xorg: Xcms.h,v 1.6 2000/08/17 19:45:04 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * DESCRIPTION
+ * Public include file for X Color Management System
+ */
+/* $XFree86: xc/lib/X11/Xcms.h,v 1.7 2003/11/03 03:46:26 dawes Exp $ */
+#ifndef _XCMS_H_
+#define _XCMS_H_
+
+#include <X11/Xlib.h>
+
+ /*
+ * XCMS Status Values
+ */
+#define XcmsFailure 0
+#define XcmsSuccess 1
+#define XcmsSuccessWithCompression 2
+
+ /*
+ * Color Space Format ID's
+ * Color Space ID's are of XcmsColorFormat type.
+ *
+ * bit 31
+ * 0 == Device-Independent
+ * 1 == Device-Dependent
+ *
+ * bit 30:
+ * 0 == Registered with X Consortium
+ * 1 == Unregistered
+ */
+#define XcmsUndefinedFormat (XcmsColorFormat)0x00000000
+#define XcmsCIEXYZFormat (XcmsColorFormat)0x00000001
+#define XcmsCIEuvYFormat (XcmsColorFormat)0x00000002
+#define XcmsCIExyYFormat (XcmsColorFormat)0x00000003
+#define XcmsCIELabFormat (XcmsColorFormat)0x00000004
+#define XcmsCIELuvFormat (XcmsColorFormat)0x00000005
+#define XcmsTekHVCFormat (XcmsColorFormat)0x00000006
+#define XcmsRGBFormat (XcmsColorFormat)0x80000000
+#define XcmsRGBiFormat (XcmsColorFormat)0x80000001
+
+ /*
+ * State of XcmsPerScrnInfo
+ */
+#define XcmsInitNone 0x00 /* no initialization attempted */
+#define XcmsInitSuccess 0x01 /* initialization successful */
+#define XcmsInitFailure 0xff /* failure, use defaults */
+
+#define DisplayOfCCC(ccc) ((ccc)->dpy)
+#define ScreenNumberOfCCC(ccc) ((ccc)->screenNumber)
+#define VisualOfCCC(ccc) ((ccc)->visual)
+#define ClientWhitePointOfCCC(ccc) (&(ccc)->clientWhitePt)
+#define ScreenWhitePointOfCCC(ccc) (&(ccc)->pPerScrnInfo->screenWhitePt)
+#define FunctionSetOfCCC(ccc) ((ccc)->pPerScrnInfo->functionSet)
+
+typedef unsigned long XcmsColorFormat; /* Color Space Format ID */
+
+typedef double XcmsFloat;
+
+ /*
+ * Device RGB
+ */
+typedef struct {
+ unsigned short red; /* scaled from 0x0000 to 0xffff */
+ unsigned short green; /* scaled from 0x0000 to 0xffff */
+ unsigned short blue; /* scaled from 0x0000 to 0xffff */
+} XcmsRGB;
+
+ /*
+ * RGB Intensity
+ */
+typedef struct {
+ XcmsFloat red; /* 0.0 - 1.0 */
+ XcmsFloat green; /* 0.0 - 1.0 */
+ XcmsFloat blue; /* 0.0 - 1.0 */
+} XcmsRGBi;
+
+ /*
+ * CIE XYZ
+ */
+typedef struct {
+ XcmsFloat X;
+ XcmsFloat Y;
+ XcmsFloat Z;
+} XcmsCIEXYZ;
+
+ /*
+ * CIE u'v'Y
+ */
+typedef struct {
+ XcmsFloat u_prime; /* 0.0 - 1.0 */
+ XcmsFloat v_prime; /* 0.0 - 1.0 */
+ XcmsFloat Y; /* 0.0 - 1.0 */
+} XcmsCIEuvY;
+
+ /*
+ * CIE xyY
+ */
+typedef struct {
+ XcmsFloat x; /* 0.0 - 1.0 */
+ XcmsFloat y; /* 0.0 - 1.0 */
+ XcmsFloat Y; /* 0.0 - 1.0 */
+} XcmsCIExyY;
+
+ /*
+ * CIE L*a*b*
+ */
+typedef struct {
+ XcmsFloat L_star; /* 0.0 - 100.0 */
+ XcmsFloat a_star;
+ XcmsFloat b_star;
+} XcmsCIELab;
+
+ /*
+ * CIE L*u*v*
+ */
+typedef struct {
+ XcmsFloat L_star; /* 0.0 - 100.0 */
+ XcmsFloat u_star;
+ XcmsFloat v_star;
+} XcmsCIELuv;
+
+ /*
+ * TekHVC
+ */
+typedef struct {
+ XcmsFloat H; /* 0.0 - 360.0 */
+ XcmsFloat V; /* 0.0 - 100.0 */
+ XcmsFloat C; /* 0.0 - 100.0 */
+} XcmsTekHVC;
+
+ /*
+ * PAD
+ */
+typedef struct {
+ XcmsFloat pad0;
+ XcmsFloat pad1;
+ XcmsFloat pad2;
+ XcmsFloat pad3;
+} XcmsPad;
+
+
+ /*
+ * XCMS Color Structure
+ */
+typedef struct {
+ union {
+ XcmsRGB RGB;
+ XcmsRGBi RGBi;
+ XcmsCIEXYZ CIEXYZ;
+ XcmsCIEuvY CIEuvY;
+ XcmsCIExyY CIExyY;
+ XcmsCIELab CIELab;
+ XcmsCIELuv CIELuv;
+ XcmsTekHVC TekHVC;
+ XcmsPad Pad;
+ } spec; /* the color specification */
+ unsigned long pixel; /* pixel value (as needed) */
+ XcmsColorFormat format; /* the specification format */
+} XcmsColor;
+
+
+ /*
+ * XCMS Per Screen related data
+ */
+
+typedef struct _XcmsPerScrnInfo {
+ XcmsColor screenWhitePt; /* Screen White point */
+ XPointer functionSet; /* pointer to Screen Color Characterization */
+ /* Function Set structure */
+ XPointer screenData; /* pointer to corresponding Screen Color*/
+ /* Characterization Data */
+ unsigned char state; /* XcmsInitNone, XcmsInitSuccess, XcmsInitFailure */
+ char pad[3];
+} XcmsPerScrnInfo;
+
+typedef struct _XcmsCCC *XcmsCCC;
+
+typedef Status (*XcmsCompressionProc)( /* Gamut Compression Proc */
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+);
+
+typedef Status (*XcmsWhiteAdjustProc)( /* White Point Adjust Proc */
+ XcmsCCC /* ccc */,
+ XcmsColor* /* initial_white_point*/,
+ XcmsColor* /* target_white_point*/,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+);
+
+ /*
+ * XCMS Color Conversion Context
+ */
+typedef struct _XcmsCCC {
+ Display *dpy; /* X Display */
+ int screenNumber; /* X screen number */
+ Visual *visual; /* X Visual */
+ XcmsColor clientWhitePt; /* Client White Point */
+ XcmsCompressionProc gamutCompProc; /* Gamut Compression Function */
+ XPointer gamutCompClientData; /* Gamut Comp Func Client Data */
+ XcmsWhiteAdjustProc whitePtAdjProc; /* White Point Adjustment Function */
+ XPointer whitePtAdjClientData; /* White Pt Adj Func Client Data */
+ XcmsPerScrnInfo *pPerScrnInfo; /* pointer to per screen information */
+ /* associated with the above display */
+ /* screenNumber */
+} XcmsCCCRec;
+
+typedef Status (*XcmsScreenInitProc)( /* Screen Initialization Proc */
+ Display* /* dpy */,
+ int /* screen_number */,
+ XcmsPerScrnInfo* /* screen_info */
+);
+
+typedef void (*XcmsScreenFreeProc)(
+ XPointer /* screenData */
+);
+
+ /*
+ * Function List Pointer -- pointer to an array of function pointers.
+ * The end of list is indicated by a NULL pointer.
+ */
+/*
+ * XXX: The use of the XcmsConversionProc type is broken. The
+ * device-independent colour conversion code uses it as:
+
+typedef Status (*XcmsConversionProc)(XcmsCCC, XcmsColor *, XcmsColor *,
+ unsigned int);
+
+ * while the device-dependent code uses it as:
+
+typedef Status (*XcmsConversionProc)(XcmsCCC, XcmsColor *, unsigned int,
+ Bool *);
+
+ * Until this is reworked, it's probably best to leave it unprotoized.
+ * The code works regardless.
+ */
+typedef Status (*XcmsDDConversionProc)( /* using device-dependent version */
+ XcmsCCC /* ccc */,
+ XcmsColor* /* pcolors_in_out */,
+ unsigned int /* ncolors */,
+ Bool* /* pCompressed */
+ );
+
+typedef Status (*XcmsDIConversionProc)( /* using device-independent version */
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* pcolors_in_out */,
+ unsigned int /* ncolors */
+ );
+
+typedef XcmsDIConversionProc XcmsConversionProc;
+typedef XcmsConversionProc *XcmsFuncListPtr;
+
+typedef int (*XcmsParseStringProc)( /* Color String Parsing Proc */
+ char* /* color_string */,
+ XcmsColor* /* color_return */
+);
+
+ /*
+ * Color Space -- per Color Space related data (Device-Independent
+ * or Device-Dependent)
+ */
+typedef struct _XcmsColorSpace {
+ const char *prefix; /* Prefix of string format. */
+ XcmsColorFormat id; /* Format ID number. */
+ XcmsParseStringProc parseString;
+ /* String format parsing function */
+ XcmsFuncListPtr to_CIEXYZ; /* Pointer to an array of function */
+ /* pointers such that when the */
+ /* functions are executed in sequence */
+ /* will convert a XcmsColor structure */
+ /* from this color space to CIEXYZ */
+ /* space. */
+ XcmsFuncListPtr from_CIEXYZ;/* Pointer to an array of function */
+ /* pointers such that when the */
+ /* functions are executed in sequence */
+ /* will convert a XcmsColor structure */
+ /* from CIEXYZ space to this color */
+ /* space. */
+ int inverse_flag; /* If 1, indicates that for 0 <= i < n */
+ /* where n is the number of function */
+ /* pointers in the lists to_CIEXYZ */
+ /* and from_CIEXYZ; for each function */
+ /* to_CIEXYZ[i] its inverse function */
+ /* is from_CIEXYZ[n - i]. */
+
+} XcmsColorSpace;
+
+ /*
+ * Screen Color Characterization Function Set -- per device class
+ * color space conversion functions.
+ */
+typedef struct _XcmsFunctionSet {
+ XcmsColorSpace **DDColorSpaces;
+ /* Pointer to an array of pointers to */
+ /* Device-DEPENDENT color spaces */
+ /* understood by this SCCFuncSet. */
+ XcmsScreenInitProc screenInitProc;
+ /* Screen initialization function that */
+ /* reads Screen Color Characterization*/
+ /* Data off properties on the screen's*/
+ /* root window. */
+ XcmsScreenFreeProc screenFreeProc;
+ /* Function that frees the SCCData */
+ /* structures. */
+} XcmsFunctionSet;
+
+_XFUNCPROTOBEGIN
+
+extern Status XcmsAddColorSpace (
+ XcmsColorSpace* /* pColorSpace */
+);
+
+extern Status XcmsAddFunctionSet (
+ XcmsFunctionSet* /* functionSet */
+);
+
+extern Status XcmsAllocColor (
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ XcmsColor* /* color_in_out */,
+ XcmsColorFormat /* result_format */
+);
+
+extern Status XcmsAllocNamedColor (
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_string */,
+ XcmsColor* /* color_scrn_return */,
+ XcmsColor* /* color_exact_return */,
+ XcmsColorFormat /* result_format */
+);
+
+extern XcmsCCC XcmsCCCOfColormap (
+ Display* /* dpy */,
+ Colormap /* colormap */
+);
+
+extern Status XcmsCIELabClipab(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsCIELabClipL(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsCIELabClipLab(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsCIELabQueryMaxC (
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsFloat /* L_star */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsCIELabQueryMaxL (
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsFloat /* chroma */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsCIELabQueryMaxLC (
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsCIELabQueryMinL (
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsFloat /* chroma */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsCIELabToCIEXYZ (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+);
+
+extern Status XcmsCIELabWhiteShiftColors(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* initial_white_point*/,
+ XcmsColor* /* target_white_point*/,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsCIELuvClipL(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsCIELuvClipLuv(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsCIELuvClipuv(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsCIELuvQueryMaxC (
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsFloat /* L_star */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsCIELuvQueryMaxL (
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsFloat /* chroma */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsCIELuvQueryMaxLC (
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsCIELuvQueryMinL (
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsFloat /* chroma */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsCIELuvToCIEuvY (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+);
+
+extern Status XcmsCIELuvWhiteShiftColors(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* initial_white_point*/,
+ XcmsColor* /* target_white_point*/,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsCIEXYZToCIELab (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+);
+
+extern Status XcmsCIEXYZToCIEuvY (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+);
+
+extern Status XcmsCIEXYZToCIExyY (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+);
+
+extern Status XcmsCIEXYZToRGBi (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsCIEuvYToCIELuv (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+);
+
+extern Status XcmsCIEuvYToCIEXYZ (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+);
+
+extern Status XcmsCIEuvYToTekHVC (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+);
+
+extern Status XcmsCIExyYToCIEXYZ (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+);
+
+extern XcmsColor *XcmsClientWhitePointOfCCC (
+ XcmsCCC /* ccc */
+);
+
+extern Status XcmsConvertColors (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colorArry_in_out */,
+ unsigned int /* nColors */,
+ XcmsColorFormat /* targetFormat */,
+ Bool* /* compArry_return */
+);
+
+extern XcmsCCC XcmsCreateCCC (
+ Display* /* dpy */,
+ int /* screenNumber */,
+ Visual* /* visual */,
+ XcmsColor* /* clientWhitePt */,
+ XcmsCompressionProc /* gamutCompProc */,
+ XPointer /* gamutCompClientData */,
+ XcmsWhiteAdjustProc /* whitePtAdjProc */,
+ XPointer /* whitePtAdjClientData */
+);
+
+extern XcmsCCC XcmsDefaultCCC (
+ Display* /* dpy */,
+ int /* screenNumber */
+);
+
+extern Display *XcmsDisplayOfCCC (
+ XcmsCCC /* ccc */
+);
+
+extern XcmsColorFormat XcmsFormatOfPrefix (
+ char* /* prefix */
+);
+
+extern void XcmsFreeCCC (
+ XcmsCCC /* ccc */
+);
+
+extern Status XcmsLookupColor (
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_string */,
+ XcmsColor* /* pColor_exact_in_out */,
+ XcmsColor* /* pColor_scrn_in_out */,
+ XcmsColorFormat /* result_format */
+);
+
+extern char *XcmsPrefixOfFormat (
+ XcmsColorFormat /* id */
+);
+
+extern Status XcmsQueryBlack (
+ XcmsCCC /* ccc */,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsQueryBlue (
+ XcmsCCC /* ccc */,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsQueryColor (
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ XcmsColor* /* pColor_in_out */,
+ XcmsColorFormat /* result_format */
+);
+
+extern Status XcmsQueryColors (
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ XcmsColor* /* colorArry_in_out */,
+ unsigned int /* nColors */,
+ XcmsColorFormat /* result_format */
+);
+
+extern Status XcmsQueryGreen (
+ XcmsCCC /* ccc */,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsQueryRed (
+ XcmsCCC /* ccc */,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsQueryWhite (
+ XcmsCCC /* ccc */,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsRGBiToCIEXYZ (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsRGBiToRGB (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsRGBToRGBi (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+);
+
+extern int XcmsScreenNumberOfCCC (
+ XcmsCCC /* ccc */
+);
+
+extern XcmsColor *XcmsScreenWhitePointOfCCC (
+ XcmsCCC /* ccc */
+);
+
+extern XcmsCCC XcmsSetCCCOfColormap(
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ XcmsCCC /* ccc */
+);
+
+extern XcmsCompressionProc XcmsSetCompressionProc (
+ XcmsCCC /* ccc */,
+ XcmsCompressionProc /* compression_proc */,
+ XPointer /* client_data */
+);
+
+extern XcmsWhiteAdjustProc XcmsSetWhiteAdjustProc (
+ XcmsCCC /* ccc */,
+ XcmsWhiteAdjustProc /* white_adjust_proc */,
+ XPointer /* client_data */
+);
+
+extern Status XcmsSetWhitePoint (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* color */
+);
+
+extern Status XcmsStoreColor (
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ XcmsColor* /* pColor_in */
+);
+
+extern Status XcmsStoreColors (
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ XcmsColor* /* colorArry_in */,
+ unsigned int /* nColors */,
+ Bool* /* compArry_return */
+);
+
+extern Status XcmsTekHVCClipC(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsTekHVCClipV(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsTekHVCClipVC(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+);
+
+extern Status XcmsTekHVCQueryMaxC (
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue */,
+ XcmsFloat /* value */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsTekHVCQueryMaxV (
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue */,
+ XcmsFloat /* chroma */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsTekHVCQueryMaxVC (
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsTekHVCQueryMaxVSamples (
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue */,
+ XcmsColor* /* colors_return */,
+ unsigned int /* nsamples */
+);
+
+extern Status XcmsTekHVCQueryMinV (
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue */,
+ XcmsFloat /* chroma */,
+ XcmsColor* /* color_return */
+);
+
+extern Status XcmsTekHVCToCIEuvY (
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+);
+
+extern Status XcmsTekHVCWhiteShiftColors(
+ XcmsCCC /* ccc */,
+ XcmsColor* /* initial_white_point*/,
+ XcmsColor* /* target_white_point*/,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+);
+
+extern Visual *XcmsVisualOfCCC (
+ XcmsCCC /* ccc */
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XCMS_H_ */
diff --git a/nx-X11/lib/X11/Xcms.txt b/nx-X11/lib/X11/Xcms.txt
new file mode 100644
index 000000000..290694162
--- /dev/null
+++ b/nx-X11/lib/X11/Xcms.txt
@@ -0,0 +1,45 @@
+/*
+ * (c) Copyright 1990 1991 Tektronix Inc.
+ * 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 Tektronix not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.
+ *
+ * Tektronix disclaims all warranties with regard to this software, including
+ * all implied warranties of merchantability and fitness, in no event shall
+ * Tektronix 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.
+ *
+ *
+ * NAME
+ * Xcms.txt
+ *
+ * DESCRIPTION
+ * Sample Color Name Database
+ *
+ * $XFree86$
+ */
+
+
+This device-independent color name database is provided just as an example.
+There are no claims that these color specifications are or should be bound
+to the corresponding color name.
+
+As you can see, the start of the database is indicated by "XCMS_COLORDB_START".
+Anything before this is assumed to be comments. The "0.1" indicates the
+version number of the format/syntax used in this file. The color name is
+delimited from the color specification by one or more tabs.
+
+XCMS_COLORDB_START 0.1
+cms red CIEXYZ:0.3811/0.2073/0.0213
+cms green CIEXYZ:0.3203/0.6805/0.1430
+cms blue CIEXYZ:0.2483/0.1122/1.2417
+XCMS_COLORDB_END
diff --git a/nx-X11/lib/X11/Xcmsint.h b/nx-X11/lib/X11/Xcmsint.h
new file mode 100644
index 000000000..1bf02ba2f
--- /dev/null
+++ b/nx-X11/lib/X11/Xcmsint.h
@@ -0,0 +1,262 @@
+/* $Xorg: Xcmsint.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * DESCRIPTION
+ * Private include file for Color Management System.
+ * (i.e., for API internal use only)
+ *
+ */
+/* $XFree86: xc/lib/X11/Xcmsint.h,v 3.3 2001/07/25 15:04:44 dawes Exp $ */
+
+#ifndef _XCMSINT_H_
+#define _XCMSINT_H_
+
+#include <X11/Xcms.h>
+
+/*
+ * DEFINES
+ */
+
+ /*
+ * Private Status Value
+ */
+#define _XCMS_NEWNAME -1
+
+ /*
+ * Color Space ID's are of XcmsColorFormat type.
+ *
+ * bit 31
+ * 0 == Device-Independent
+ * 1 == Device-Dependent
+ *
+ * bit 30:
+ * 0 == Registered with X Consortium
+ * 1 == Unregistered
+ */
+#define XCMS_DD_ID(id) ((id) & (XcmsColorFormat)0x80000000)
+#define XCMS_DI_ID(id) (!((id) & (XcmsColorFormat)0x80000000))
+#define XCMS_UNREG_ID(id) ((id) & (XcmsColorFormat)0x40000000)
+#define XCMS_REG_ID(id) (!((id) & (XcmsColorFormat)0x40000000))
+#define XCMS_FIRST_REG_DI_ID (XcmsColorFormat)0x00000001
+#define XCMS_FIRST_UNREG_DI_ID (XcmsColorFormat)0x40000000
+#define XCMS_FIRST_REG_DD_ID (XcmsColorFormat)0x80000000
+#define XCMS_FIRST_UNREG_DD_ID (XcmsColorFormat)0xc0000000
+
+/*
+ * TYPEDEFS
+ */
+
+ /*
+ * Structure for caching Colormap info.
+ * This is provided for the Xlib modifications to:
+ * XAllocNamedColor()
+ * XLookupColor()
+ * XParseColor()
+ * XStoreNamedColor()
+ */
+typedef struct _XcmsCmapRec {
+ Colormap cmapID;
+ Display *dpy;
+ Window windowID;
+ Visual *visual;
+ struct _XcmsCCC *ccc;
+ struct _XcmsCmapRec *pNext;
+} XcmsCmapRec;
+
+ /*
+ * Intensity Record (i.e., value / intensity tuple)
+ */
+typedef struct _IntensityRec {
+ unsigned short value;
+ XcmsFloat intensity;
+} IntensityRec;
+
+ /*
+ * Intensity Table
+ */
+typedef struct _IntensityTbl {
+ IntensityRec *pBase;
+ unsigned int nEntries;
+} IntensityTbl;
+
+ /*
+ * Structure for storing per-Visual Intensity Tables (aka gamma maps).
+ */
+typedef struct _XcmsIntensityMap {
+ VisualID visualID;
+ XPointer screenData; /* pointer to corresponding Screen Color*/
+ /* Characterization Data */
+ void (*pFreeScreenData)(XPointer pScreenDataTemp); /* Function that frees a Screen */
+ /* structure. */
+ struct _XcmsIntensityMap *pNext;
+} XcmsIntensityMap;
+
+
+ /*
+ * Structure for storing "registered" color space prefix/ID
+ */
+typedef struct _XcmsRegColorSpaceEntry {
+ const char *prefix; /* Color Space prefix (e.g., "CIEXYZ:") */
+ XcmsColorFormat id; /* Color Space ID (e.g., XcmsCIEXYZFormat) */
+} XcmsRegColorSpaceEntry;
+
+
+ /*
+ * Xcms Per Display (i.e. connection) related data
+ */
+typedef struct _XcmsPerDpyInfo {
+
+ XcmsCCC paDefaultCCC; /* based on default visual of screen */
+ /*
+ * Pointer to an array of XcmsCCC structures, one for
+ * each screen.
+ */
+ XcmsCmapRec *pClientCmaps; /* Pointer to linked list of XcmsCmapRec's */
+
+} XcmsPerDpyInfo, *XcmsPerDpyInfoPtr;
+
+/*
+ * DEFINES
+ */
+
+#define XDCCC_NUMBER 0x8000000L /* 2**27 per XDCCC */
+
+#ifdef GRAY
+#define XDCCC_SCREENWHITEPT_ATOM_NAME "XDCCC_GRAY_SCREENWHITEPOINT"
+#define XDCCC_GRAY_CORRECT_ATOM_NAME "XDCCC_GRAY_CORRECTION"
+#endif /* GRAY */
+
+#ifndef _ConversionValues
+typedef struct _ConversionValues {
+ IntensityTbl IntensityTbl;
+} ConversionValues;
+#endif
+
+#ifdef GRAY
+typedef struct {
+ IntensityTbl *IntensityTbl;
+} GRAY_SCCData;
+#endif /* GRAY */
+
+/*
+ * DEFINES
+ */
+
+#define XDCCC_MATRIX_ATOM_NAME "XDCCC_LINEAR_RGB_MATRICES"
+#define XDCCC_CORRECT_ATOM_NAME "XDCCC_LINEAR_RGB_CORRECTION"
+
+typedef struct {
+ XcmsFloat XYZtoRGBmatrix[3][3];
+ XcmsFloat RGBtoXYZmatrix[3][3];
+ IntensityTbl *pRedTbl;
+ IntensityTbl *pGreenTbl;
+ IntensityTbl *pBlueTbl;
+} LINEAR_RGB_SCCData;
+
+/* function prototypes */
+extern XcmsCmapRec *
+_XcmsAddCmapRec(
+ Display *dpy,
+ Colormap cmap,
+ Window windowID,
+ Visual *visual);
+extern void
+_XcmsRGB_to_XColor(
+ XcmsColor *pColors,
+ XColor *pXColors,
+ unsigned int nColors);
+extern Status
+_XcmsResolveColorString (
+ XcmsCCC ccc,
+ const char **color_string,
+ XcmsColor *pColor_exact_return,
+ XcmsColorFormat result_format);
+extern void
+_XUnresolveColor(
+ XcmsCCC ccc,
+ XColor *pXColor);
+/*
+ * DESCRIPTION
+ * Include file for defining the math macros used in the
+ * XCMS source. Instead of using math library routines
+ * directly, XCMS uses macros so that based on the
+ * definitions here, vendors and sites can specify exactly
+ * what routine will be called (those from libm.a or their
+ * custom routines). If not defined to math library routines
+ * (e.g., sqrt in libm.a), then the client is not forced to
+ * be linked with -lm.
+ */
+
+#define XCMS_ATAN(x) _XcmsArcTangent(x)
+#define XCMS_COS(x) _XcmsCosine(x)
+#define XCMS_CUBEROOT(x) _XcmsCubeRoot(x)
+#define XCMS_FABS(x) ((x) < 0.0 ? -(x) : (x))
+#define XCMS_SIN(x) _XcmsSine(x)
+#define XCMS_SQRT(x) _XcmsSquareRoot(x)
+#define XCMS_TAN(x) (XCMS_SIN(x) / XCMS_COS(x))
+
+double _XcmsArcTangent(double a);
+double _XcmsCosine(double a);
+double _XcmsCubeRoot(double a);
+double _XcmsSine(double a);
+double _XcmsSquareRoot(double a);
+
+/*
+ * DEFINES FOR GAMUT COMPRESSION AND QUERY ROUTINES
+ */
+#ifndef PI
+# ifdef M_PI
+# define PI M_PI
+# else
+# define PI 3.14159265358979323846264338327950
+# endif /* M_PI */
+#endif /* PI */
+#ifndef degrees
+# define degrees(r) ((XcmsFloat)(r) * 180.0 / PI)
+#endif /* degrees */
+#ifndef radians
+# define radians(d) ((XcmsFloat)(d) * PI / 180.0)
+#endif /* radians */
+
+#define XCMS_CIEUSTAROFHUE(h,c) \
+((XCMS_COS((h)) == 0.0) ? (XcmsFloat)0.0 : (XcmsFloat) \
+((XcmsFloat)(c) / (XcmsFloat)XCMS_SQRT((XCMS_TAN(h) * XCMS_TAN(h)) + \
+(XcmsFloat)1.0)))
+#define XCMS_CIEVSTAROFHUE(h,c) \
+((XCMS_COS((h)) == 0.0) ? (XcmsFloat)0.0 : (XcmsFloat) \
+((XcmsFloat)(c) / (XcmsFloat)XCMS_SQRT(((XcmsFloat)1.0 / \
+(XcmsFloat)(XCMS_TAN(h) * XCMS_TAN(h))) + (XcmsFloat)1.0)))
+/* this hue is returned in radians */
+#define XCMS_CIELUV_PMETRIC_HUE(u,v) \
+(((u) != 0.0) ? XCMS_ATAN( (v) / (u)) : ((v >= 0.0) ? PI / 2 : -(PI / 2)))
+#define XCMS_CIELUV_PMETRIC_CHROMA(u,v) XCMS_SQRT(((u)*(u)) + ((v)*(v)))
+
+#define XCMS_CIEASTAROFHUE(h,c) XCMS_CIEUSTAROFHUE((h), (c))
+#define XCMS_CIEBSTAROFHUE(h,c) XCMS_CIEVSTAROFHUE((h), (c))
+#define XCMS_CIELAB_PMETRIC_HUE(a,b) XCMS_CIELUV_PMETRIC_HUE((a), (b))
+#define XCMS_CIELAB_PMETRIC_CHROMA(a,b) XCMS_CIELUV_PMETRIC_CHROMA((a), (b))
+
+#endif /* _XCMSINT_H_ */
diff --git a/nx-X11/lib/X11/XimImSw.h b/nx-X11/lib/X11/XimImSw.h
new file mode 100644
index 000000000..8ad5d2872
--- /dev/null
+++ b/nx-X11/lib/X11/XimImSw.h
@@ -0,0 +1,48 @@
+/* $Xorg: XimImSw.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993 by FUJITSU LIMITED
+
+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 of FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86$ */
+
+#ifndef _XIMIMSW_H
+#define _XIMIMSW_H
+
+typedef struct {
+ Bool (*checkprocessing)(
+ Xim im
+ );
+ Bool (*im_open)(
+ Xim im
+ );
+ void (*im_free)(
+ Xim im
+ );
+} XimImsportSW;
+
+extern XimImsportSW _XimImSportRec[];
+
+#endif /* _XIMIMSW_H */
diff --git a/nx-X11/lib/X11/XimProto.h b/nx-X11/lib/X11/XimProto.h
new file mode 100644
index 000000000..fe6e5f693
--- /dev/null
+++ b/nx-X11/lib/X11/XimProto.h
@@ -0,0 +1,227 @@
+/* $Xorg: XimProto.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993 by FUJITSU LIMITED
+
+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 of FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#ifndef _XIMPROTO_H
+#define _XIMPROTO_H
+
+/*
+ * Default Preconnection selection target
+ */
+#define XIM_SERVERS "XIM_SERVERS"
+#define XIM_LOCALES "LOCALES"
+#define XIM_TRANSPORT "TRANSPORT"
+
+/*
+ * categories in XIM_SERVERS
+ */
+#define XIM_SERVER_CATEGORY "@server="
+#define XIM_LOCAL_CATEGORY "@locale="
+#define XIM_TRANSPORT_CATEGORY "@transport="
+
+/*
+ * Xim implementation revision
+ */
+#define PROTOCOLMAJORVERSION 1
+#define PROTOCOLMINORVERSION 0
+
+/*
+ * Major Protocol number
+ */
+#define XIM_CONNECT 1
+#define XIM_CONNECT_REPLY 2
+#define XIM_DISCONNECT 3
+#define XIM_DISCONNECT_REPLY 4
+
+#define XIM_AUTH_REQUIRED 10
+#define XIM_AUTH_REPLY 11
+#define XIM_AUTH_NEXT 12
+#define XIM_AUTH_SETUP 13
+#define XIM_AUTH_NG 14
+
+#define XIM_ERROR 20
+
+#define XIM_OPEN 30
+#define XIM_OPEN_REPLY 31
+#define XIM_CLOSE 32
+#define XIM_CLOSE_REPLY 33
+#define XIM_REGISTER_TRIGGERKEYS 34
+#define XIM_TRIGGER_NOTIFY 35
+#define XIM_TRIGGER_NOTIFY_REPLY 36
+#define XIM_SET_EVENT_MASK 37
+#define XIM_ENCODING_NEGOTIATION 38
+#define XIM_ENCODING_NEGOTIATION_REPLY 39
+#define XIM_QUERY_EXTENSION 40
+#define XIM_QUERY_EXTENSION_REPLY 41
+#define XIM_SET_IM_VALUES 42
+#define XIM_SET_IM_VALUES_REPLY 43
+#define XIM_GET_IM_VALUES 44
+#define XIM_GET_IM_VALUES_REPLY 45
+
+#define XIM_CREATE_IC 50
+#define XIM_CREATE_IC_REPLY 51
+#define XIM_DESTROY_IC 52
+#define XIM_DESTROY_IC_REPLY 53
+#define XIM_SET_IC_VALUES 54
+#define XIM_SET_IC_VALUES_REPLY 55
+#define XIM_GET_IC_VALUES 56
+#define XIM_GET_IC_VALUES_REPLY 57
+#define XIM_SET_IC_FOCUS 58
+#define XIM_UNSET_IC_FOCUS 59
+#define XIM_FORWARD_EVENT 60
+#define XIM_SYNC 61
+#define XIM_SYNC_REPLY 62
+#define XIM_COMMIT 63
+#define XIM_RESET_IC 64
+#define XIM_RESET_IC_REPLY 65
+
+#define XIM_GEOMETRY 70
+#define XIM_STR_CONVERSION 71
+#define XIM_STR_CONVERSION_REPLY 72
+#define XIM_PREEDIT_START 73
+#define XIM_PREEDIT_START_REPLY 74
+#define XIM_PREEDIT_DRAW 75
+#define XIM_PREEDIT_CARET 76
+#define XIM_PREEDIT_CARET_REPLY 77
+#define XIM_PREEDIT_DONE 78
+#define XIM_STATUS_START 79
+#define XIM_STATUS_DRAW 80
+#define XIM_STATUS_DONE 81
+#define XIM_PREEDITSTATE 82
+
+/*
+ * values for the flag of XIM_ERROR
+ */
+#define XIM_IMID_VALID 0x0001
+#define XIM_ICID_VALID 0x0002
+
+/*
+ * XIM Error Code
+ */
+#define XIM_BadAlloc 1
+#define XIM_BadStyle 2
+#define XIM_BadClientWindow 3
+#define XIM_BadFocusWindow 4
+#define XIM_BadArea 5
+#define XIM_BadSpotLocation 6
+#define XIM_BadColormap 7
+#define XIM_BadAtom 8
+#define XIM_BadPixel 9
+#define XIM_BadPixmap 10
+#define XIM_BadName 11
+#define XIM_BadCursor 12
+#define XIM_BadProtocol 13
+#define XIM_BadForeground 14
+#define XIM_BadBackground 15
+#define XIM_LocaleNotSupported 16
+#define XIM_BadSomething 999
+
+/*
+ * byte order
+ */
+#define BIGENDIAN (CARD8)0x42 /* MSB first */
+#define LITTLEENDIAN (CARD8)0x6c /* LSB first */
+
+/*
+ * values for the type of XIMATTR & XICATTR
+ */
+#define XimType_SeparatorOfNestedList 0
+#define XimType_CARD8 1
+#define XimType_CARD16 2
+#define XimType_CARD32 3
+#define XimType_STRING8 4
+#define XimType_Window 5
+#define XimType_XIMStyles 10
+#define XimType_XRectangle 11
+#define XimType_XPoint 12
+#define XimType_XFontSet 13
+#define XimType_XIMOptions 14
+#define XimType_XIMHotKeyTriggers 15
+#define XimType_XIMHotKeyState 16
+#define XimType_XIMStringConversion 17
+#define XimType_NEST 0x7fff
+
+/*
+ * values for the category of XIM_ENCODING_NEGITIATON_REPLY
+ */
+#define XIM_Encoding_NameCategory 0
+#define XIM_Encoding_DetailCategory 1
+
+/*
+ * value for the index of XIM_ENCODING_NEGITIATON_REPLY
+ */
+#define XIM_Default_Encoding_IDX -1
+
+/*
+ * value for the flag of XIM_FORWARD_EVENT, XIM_COMMIT
+ */
+#define XimSYNCHRONUS 0x0001
+#define XimLookupChars 0x0002
+#define XimLookupKeySym 0x0004
+#define XimLookupBoth 0x0006
+
+/*
+ * request packet header size
+ */
+#define XIM_HEADER_SIZE \
+ sizeof(CARD8) /* sizeof mejor-opcode */ \
+ + sizeof(CARD8) /* sizeof minor-opcode */ \
+ + sizeof(INT16) /* sizeof length */
+
+/*
+ * Client Message data size
+ */
+#define XIM_CM_DATA_SIZE 20
+
+/*
+ * XIM data structure
+ */
+typedef CARD16 BITMASK16;
+typedef CARD32 BITMASK32;
+typedef CARD32 EVENTMASK;
+
+typedef CARD16 XIMID; /* Input Method ID */
+typedef CARD16 XICID; /* Input Context ID */
+
+/*
+ * Padding macro
+ */
+#define XIM_PAD(length) ((4 - ((length) % 4)) % 4)
+
+#define XIM_SET_PAD(ptr, length) \
+ { \
+ register int Counter = XIM_PAD((int)length); \
+ if (Counter) { \
+ register char *Ptr = (char *)(ptr) + (length); \
+ length += Counter; \
+ for (; Counter; --Counter, ++Ptr) \
+ *Ptr = '\0'; \
+ } \
+ }
+
+#endif /* _XIMPROTO_H */
diff --git a/nx-X11/lib/X11/XimThai.h b/nx-X11/lib/X11/XimThai.h
new file mode 100644
index 000000000..5b2666ebf
--- /dev/null
+++ b/nx-X11/lib/X11/XimThai.h
@@ -0,0 +1,112 @@
+/* $Xorg: XimThai.h,v 1.4 2001/02/09 02:03:38 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.
+
+
+Copyright 1993 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/XimThai.h,v 1.5 2001/12/14 19:54:08 dawes Exp $ */
+
+/*
+**++
+** FACILITY:
+**
+** Xlib
+**
+** ABSTRACT:
+**
+** Definition file for Thai specific functions.
+**
+** MODIFICATION HISTORY:
+**
+**/
+
+#ifndef _XIMTHAI_H_
+#define _XIMTHAI_H_
+
+#include <X11/Xlib.h>
+
+/* Classification of characters in TIS620 according to WTT */
+
+#define CTRL 0 /* control chars */
+#define NON 1 /* non composibles */
+#define CONS 2 /* consonants */
+#define LV 3 /* leading vowels */
+#define FV1 4 /* following vowels */
+#define FV2 5
+#define FV3 6
+#define BV1 7 /* below vowels */
+#define BV2 8
+#define BD 9 /* below diacritics */
+#define TONE 10 /* tonemarks */
+#define AD1 11 /* above diacritics */
+#define AD2 12
+#define AD3 13
+#define AV1 14 /* above vowels */
+#define AV2 15
+#define AV3 16
+
+
+/* extended classification */
+
+#define DEAD 17 /* group of non-spacing characters */
+
+
+/* display levels in display cell */
+
+#define NONDISP 0 /* non displayable */
+#define TOP 1
+#define ABOVE 2
+#define BASE 3
+#define BELOW 4
+
+
+/* Input Sequence Check modes */
+
+#define WTT_ISC1 1 /* WTT default ISC mode */
+#define WTT_ISC2 2 /* WTT strict ISC mode */
+#define THAICAT_ISC 3 /* THAICAT ISC mode */
+#define NOISC 255 /* No ISC */
+
+
+#endif /* _XIMTHAI_H_ */
diff --git a/nx-X11/lib/X11/XimTrInt.h b/nx-X11/lib/X11/XimTrInt.h
new file mode 100644
index 000000000..cc1cabfac
--- /dev/null
+++ b/nx-X11/lib/X11/XimTrInt.h
@@ -0,0 +1,66 @@
+/* $Xorg: XimTrInt.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Sun Microsystems, Inc.
+ Copyright 1993, 1994 by FUJITSU LIMITED
+
+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 of Sun Microsystems, Inc.
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+Sun Microsystems, Inc. makes no representations about the suitability of
+this software for any purpose. It is provided "as is" without
+express or implied warranty.
+
+Sun Microsystems Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL Sun Microsystems, Inc. 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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86$ */
+
+#ifndef _XIMTRINT_H
+#define _XIMTRINT_H
+
+#include "Ximint.h"
+
+typedef struct {
+ char *transportname;
+ Bool (*config)(
+ Xim,
+ char *
+ );
+} TransportSW;
+
+extern TransportSW _XimTransportRec[];
+
+/*
+ * Global symbols
+ */
+
+extern Bool _XimXConf(
+ Xim im,
+ char *address
+);
+
+#if defined(TCPCONN) || defined(UNIXCONN) || defined(DNETCONN) || defined(STREAMSCONN)
+
+extern Bool _XimTransConf(
+ Xim im,
+ char *address
+);
+
+#endif
+
+#endif /* _XIMTRINT_H */
diff --git a/nx-X11/lib/X11/XimTrX.h b/nx-X11/lib/X11/XimTrX.h
new file mode 100644
index 000000000..a43784397
--- /dev/null
+++ b/nx-X11/lib/X11/XimTrX.h
@@ -0,0 +1,66 @@
+/* $Xorg: XimTrX.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+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 of Sun Microsystems, Inc.
+and FUJITSU LIMITED not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
+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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86$ */
+
+#ifndef _XIMTRX_H
+#define _XIMTRX_H
+
+typedef struct _XIntrCallbackRec *XIntrCallbackPtr;
+
+typedef struct _XIntrCallbackRec {
+ Bool (*func)(
+ Xim, INT16, XPointer, XPointer
+);
+ XPointer call_data;
+ XIntrCallbackPtr next;
+} XIntrCallbackRec ;
+
+typedef struct _XSpecRec {
+ XIntrCallbackPtr intr_cb;
+ Atom imconnectid;
+ Atom improtocolid;
+ Atom immoredataid;
+ Window lib_connect_wid;
+ Window ims_connect_wid;
+ XPointer ev;
+ CARD32 major_code;
+ CARD32 minor_code;
+ CARD32 BoundarySize;
+} XSpecRec;
+
+#define _XIM_PROTOCOL "_XIM_PROTOCOL"
+#define _XIM_XCONNECT "_XIM_XCONNECT"
+#define _XIM_MOREDATA "_XIM_MOREDATA"
+
+#define MAJOR_TRANSPORT_VERSION 0
+#define MINOR_TRANSPORT_VERSION 0
+
+#endif /* _XIMTRX_H */
diff --git a/nx-X11/lib/X11/XimTrans.h b/nx-X11/lib/X11/XimTrans.h
new file mode 100644
index 000000000..f75270b27
--- /dev/null
+++ b/nx-X11/lib/X11/XimTrans.h
@@ -0,0 +1,123 @@
+/* $Xorg: XimTrans.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+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 of Sun Microsystems, Inc.
+and FUJITSU LIMITED not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
+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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/XimTrans.h,v 1.3 2003/10/24 15:34:00 tsi Exp $ */
+
+#ifndef _XIMTRANS_H
+#define _XIMTRANS_H
+
+typedef struct _TransIntrCallbackRec *TransIntrCallbackPtr;
+
+typedef struct _TransIntrCallbackRec {
+ Bool (*func)(
+ Xim, INT16, XPointer, XPointer
+ );
+ XPointer call_data;
+ TransIntrCallbackPtr next;
+} TransIntrCallbackRec ;
+
+typedef struct {
+ TransIntrCallbackPtr intr_cb;
+ struct _XtransConnInfo *trans_conn; /* transport connection object */
+ int fd;
+ char *address;
+ Window window;
+ Bool is_putback;
+} TransSpecRec;
+
+
+/*
+ * Prototypes
+ */
+
+extern Bool _XimTransRegisterDispatcher(
+ Xim im,
+ Bool (*callback)(
+ Xim, INT16, XPointer, XPointer
+ ),
+ XPointer call_data
+);
+
+
+extern Bool _XimTransIntrCallback(
+ Xim im,
+ Bool (*callback)(
+ Xim, INT16, XPointer, XPointer
+ ),
+ XPointer call_data
+);
+
+extern Bool _XimTransCallDispatcher(
+ Xim im,
+ INT16 len,
+ XPointer data
+);
+
+extern void _XimFreeTransIntrCallback(
+ Xim im
+);
+
+extern Bool _XimTransIntrCallbackCheck(
+ Xim im,
+ INT16 len,
+ XPointer data
+);
+
+extern Bool _XimTransFilterWaitEvent(
+ Display *d,
+ Window w,
+ XEvent *ev,
+ XPointer arg
+);
+
+extern void _XimTransInternalConnection(
+ Display *d,
+ int fd,
+ XPointer arg
+);
+
+extern Bool _XimTransWrite(
+ Xim im,
+ INT16 len,
+ XPointer data
+);
+
+extern Bool _XimTransRead(
+ Xim im,
+ XPointer recv_buf,
+ int buf_len,
+ int *ret_len
+);
+
+extern void _XimTransFlush(
+ Xim im
+);
+
+#endif /* _XIMTRANS__H */
diff --git a/nx-X11/lib/X11/Ximint.h b/nx-X11/lib/X11/Ximint.h
new file mode 100644
index 000000000..e9bdda247
--- /dev/null
+++ b/nx-X11/lib/X11/Ximint.h
@@ -0,0 +1,1002 @@
+/* $Xorg: Ximint.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993, 1994 by Sony 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 of FUJITSU LIMITED and
+Sony Corporation not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission. FUJITSU LIMITED and Sony Corporation makes no
+representations about the suitability of this software for any
+purpose. It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED AND SONY CORPORATION DISCLAIM ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND
+SONY CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Motifier: Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/Ximint.h,v 3.13 2003/09/06 14:06:32 pascal Exp $ */
+
+#ifndef _XIMINT_H
+#define _XIMINT_H
+
+#include <stdio.h>
+#include <X11/Xutil.h>
+
+#define Public /**/
+#define Private static
+
+typedef struct _Xim *Xim;
+typedef struct _Xic *Xic;
+
+/*
+ * Input Method data
+ */
+#include "XimintP.h"
+#include "XimintL.h"
+
+/*
+ * XIM dependent data
+ */
+
+typedef struct _XimCommonPrivateRec {
+ /* This struct is also inlined in XimLocalPrivateRec, XimProtoPrivateRec. */
+ XlcConv ctom_conv;
+ XlcConv ctow_conv;
+ XlcConv ctoutf8_conv;
+ XlcConv cstomb_conv;
+ XlcConv cstowc_conv;
+ XlcConv cstoutf8_conv;
+ XlcConv ucstoc_conv;
+ XlcConv ucstoutf8_conv;
+} XimCommonPrivateRec;
+
+typedef union _XIMPrivateRec {
+ XimCommonPrivateRec common;
+ XimLocalPrivateRec local;
+ XimProtoPrivateRec proto;
+} XIMPrivateRec;
+
+/*
+ * IM struct
+ */
+typedef struct _Xim {
+ XIMMethods methods;
+ XIMCoreRec core;
+ XIMPrivateRec private;
+} XimRec;
+
+/*
+ * IC deprndent data
+ */
+typedef union _XICPrivateRec {
+ XicLocalPrivateRec local;
+ XicProtoPrivateRec proto;
+} XICPrivateRec;
+
+/*
+ * IC struct
+ */
+typedef struct _Xic {
+ XICMethods methods;
+ XICCoreRec core;
+ XICPrivateRec private;
+} XicRec;
+
+typedef struct _XimDefIMValues {
+ XIMValuesList *im_values_list;
+ XIMValuesList *ic_values_list;
+ XIMStyles *styles;
+ XIMCallback destroy_callback;
+ char *res_name;
+ char *res_class;
+ Bool visible_position;
+} XimDefIMValues;
+
+typedef struct _XimDefICValues {
+ XIMStyle input_style;
+ Window client_window;
+ Window focus_window;
+ unsigned long filter_events;
+ XICCallback geometry_callback;
+ char *res_name;
+ char *res_class;
+ XICCallback destroy_callback;
+ XICCallback preedit_state_notify_callback;
+ XICCallback string_conversion_callback;
+ XIMStringConversionText string_conversion;
+ XIMResetState reset_state;
+ XIMHotKeyTriggers *hotkey;
+ XIMHotKeyState hotkey_state;
+ ICPreeditAttributes preedit_attr;
+ ICStatusAttributes status_attr;
+} XimDefICValues;
+
+#define XIM_MODE_IM_GET (1 << 0)
+#define XIM_MODE_IM_SET (1 << 1)
+#define XIM_MODE_IM_DEFAULT (1 << 2)
+
+#define XIM_MODE_PRE_GET (1 << 0)
+#define XIM_MODE_PRE_SET (1 << 1)
+#define XIM_MODE_PRE_CREATE (1 << 2)
+#define XIM_MODE_PRE_ONCE (1 << 3)
+#define XIM_MODE_PRE_DEFAULT (1 << 4)
+
+#define XIM_MODE_STS_GET (1 << 5)
+#define XIM_MODE_STS_SET (1 << 6)
+#define XIM_MODE_STS_CREATE (1 << 7)
+#define XIM_MODE_STS_ONCE (1 << 8)
+#define XIM_MODE_STS_DEFAULT (1 << 9)
+
+#define XIM_MODE_IC_GET (XIM_MODE_PRE_GET | XIM_MODE_STS_GET)
+#define XIM_MODE_IC_SET (XIM_MODE_PRE_SET | XIM_MODE_STS_SET)
+#define XIM_MODE_IC_CREATE (XIM_MODE_PRE_CREATE | XIM_MODE_STS_CREATE)
+#define XIM_MODE_IC_ONCE (XIM_MODE_PRE_ONCE | XIM_MODE_STS_ONCE)
+#define XIM_MODE_IC_DEFAULT (XIM_MODE_PRE_DEFAULT | XIM_MODE_STS_DEFAULT)
+
+#define XIM_MODE_PRE_MASK (XIM_MODE_PRE_GET | XIM_MODE_PRE_SET | \
+ XIM_MODE_PRE_CREATE | XIM_MODE_PRE_ONCE | \
+ XIM_MODE_PRE_DEFAULT)
+#define XIM_MODE_STS_MASK (XIM_MODE_STS_GET | XIM_MODE_STS_SET | \
+ XIM_MODE_STS_CREATE | XIM_MODE_STS_ONCE | \
+ XIM_MODE_STS_DEFAULT)
+
+#define XIM_SETIMDEFAULTS (1L << 0)
+#define XIM_SETIMVALUES (1L << 1)
+#define XIM_GETIMVALUES (1L << 2)
+
+#define XIM_SETICDEFAULTS (1L << 0)
+#define XIM_CREATEIC (1L << 1)
+#define XIM_SETICVALUES (1L << 2)
+#define XIM_GETICVALUES (1L << 3)
+#define XIM_PREEDIT_ATTR (1L << 4)
+#define XIM_STATUS_ATTR (1L << 5)
+
+#define XIM_CHECK_VALID 0
+#define XIM_CHECK_INVALID 1
+#define XIM_CHECK_ERROR 2
+
+#define FILTERD True
+#define NOTFILTERD False
+
+#define XIMMODIFIER "@im="
+
+#define XIM_TRUE True
+#define XIM_FALSE False
+#define XIM_OVERFLOW (-1)
+
+/*
+ * Global symbols
+ */
+
+XPointer _XimGetLocaleCode (
+ const char *encoding_name
+);
+
+int _XimGetCharCode (
+ XPointer conv,
+ KeySym keysym,
+ unsigned char *buf,
+ int nbytes
+);
+
+unsigned int KeySymToUcs4 (
+ KeySym keysym
+);
+
+extern Bool _XimSetIMResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num
+);
+
+extern Bool _XimSetICResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num
+);
+
+extern Bool _XimSetInnerIMResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num
+);
+
+extern Bool _XimSetInnerICResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num
+);
+
+extern Bool _XimCheckCreateICValues(
+ XIMResourceList res_list,
+ unsigned int list_num
+);
+
+extern XIMResourceList _XimGetResourceListRec(
+ XIMResourceList res_list,
+ unsigned int list_num,
+ char *name
+);
+
+extern void _XimSetIMMode(
+ XIMResourceList res_list,
+ unsigned int list_num
+);
+
+extern void _XimSetICMode(
+ XIMResourceList res_list,
+ unsigned int list_num,
+ XIMStyle style
+);
+
+extern int _XimCheckIMMode(
+ XIMResourceList res_list,
+ unsigned long mode
+);
+
+extern int _XimCheckICMode(
+ XIMResourceList res_list,
+ unsigned long mode
+);
+
+extern Bool _XimSetLocalIMDefaults(
+ Xim im,
+ XPointer top,
+ XIMResourceList res_list,
+ unsigned int list_num
+);
+
+extern Bool _XimSetICDefaults(
+ Xic ic,
+ XPointer top,
+ unsigned long mode,
+ XIMResourceList res_list,
+ unsigned int list_num
+);
+
+extern Bool _XimEncodeLocalIMAttr(
+ XIMResourceList res,
+ XPointer top,
+ XPointer val
+);
+
+extern Bool _XimEncodeLocalICAttr(
+ Xic ic,
+ XIMResourceList res,
+ XPointer top,
+ XIMArg *arg,
+ unsigned long mode
+);
+
+extern Bool _XimCheckLocalInputStyle(
+ Xic ic,
+ XPointer top,
+ XIMArg *values,
+ XIMStyles *styles,
+ XIMResourceList res_list,
+ unsigned int list_num
+);
+
+extern Bool _XimDecodeLocalIMAttr(
+ XIMResourceList res,
+ XPointer top,
+ XPointer val
+);
+
+extern Bool _XimDecodeLocalICAttr(
+ XIMResourceList res,
+ XPointer top,
+ XPointer val,
+ unsigned long mode
+);
+
+extern void _XimGetCurrentIMValues(
+ Xim im,
+ XimDefIMValues *im_values
+);
+
+extern void _XimSetCurrentIMValues(
+ Xim im,
+ XimDefIMValues *im_values
+);
+
+extern void _XimGetCurrentICValues(
+ Xic ic,
+ XimDefICValues *ic_values
+);
+
+extern void _XimSetCurrentICValues(
+ Xic ic,
+ XimDefICValues *ic_values
+);
+
+extern void _XimInitialResourceInfo(
+ void
+);
+
+extern void _XimParseStringFile(
+ FILE *fp,
+ Xim im
+);
+
+extern Bool _XimCheckIfLocalProcessing(
+ Xim im
+);
+
+extern Bool _XimCheckIfThaiProcessing(
+ Xim im
+);
+
+extern Bool _XimLocalOpenIM(
+ Xim im
+);
+
+extern Bool _XimThaiOpenIM(
+ Xim im
+);
+
+extern Bool _XimProtoOpenIM(
+ Xim im
+);
+
+extern void _XimLocalIMFree(
+ Xim im
+);
+
+extern void _XimThaiIMFree(
+ Xim im
+);
+
+extern void _XimProtoIMFree(
+ Xim im
+);
+
+extern char * _XimSetIMValueData(
+ Xim im,
+ XPointer top,
+ XIMArg *arg,
+ XIMResourceList res_list,
+ unsigned int list_num
+);
+
+extern char * _XimGetIMValueData(
+ Xim im,
+ XPointer top,
+ XIMArg *arg,
+ XIMResourceList res_list,
+ unsigned int list_num
+);
+
+extern char * _XimSetICValueData(
+ Xic ic,
+ XPointer top,
+ XIMResourceList res_list,
+ unsigned int list_num,
+ XIMArg *arg,
+ unsigned long mode,
+ Bool flag
+);
+
+extern char * _XimGetICValueData(
+ Xic ic,
+ XPointer top,
+ XIMResourceList res_list,
+ unsigned int list_num,
+ XIMArg *arg,
+ unsigned long mode
+);
+
+extern char * _XimLocalSetIMValues(
+ XIM im,
+ XIMArg *arg
+);
+
+extern char * _XimLocalGetIMValues(
+ XIM im,
+ XIMArg *arg
+);
+
+extern XIC _XimLocalCreateIC(
+ XIM im,
+ XIMArg *arg
+);
+
+extern Bool _XimDispatchInit(
+ Xim im
+);
+
+extern Bool _XimGetAttributeID(
+ Xim im,
+ CARD16 *buf
+);
+
+extern Bool _XimExtension(
+ Xim im
+);
+
+extern void _XimDestroyIMStructureList(
+ Xim im
+);
+
+extern char * _XimMakeIMAttrIDList(
+ Xim im,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ XIMArg *arg,
+ CARD16 *buf,
+ INT16 *len,
+ unsigned long mode
+);
+
+extern char * _XimMakeICAttrIDList(
+ Xic ic,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ XIMArg *arg,
+ CARD16 *idList,
+ INT16 *num,
+ unsigned long mode
+);
+
+extern char * _XimDecodeIMATTRIBUTE(
+ Xim im,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ CARD16 *buf,
+ INT16 buf_len,
+ XIMArg *arg,
+ BITMASK32 mode
+);
+
+extern char * _XimDecodeICATTRIBUTE(
+ Xic ic,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ CARD16 *buf,
+ INT16 buf_len,
+ XIMArg *arg,
+ BITMASK32 mode
+);
+
+extern Bool _XimRegProtoIntrCallback(
+ Xim im,
+ CARD16 major_code,
+ CARD16 minor_code,
+ Bool (*proc)(
+ Xim, INT16, XPointer, XPointer
+ ),
+ XPointer call_data
+);
+
+extern Bool _XimErrorCallback(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+);
+
+extern Bool _XimError(
+ Xim im,
+ Xic ic,
+ CARD16 error_code,
+ INT16 detail_length,
+ CARD16 type,
+ char *detail
+);
+
+extern Bool _XimRegisterTriggerKeysCallback(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+);
+
+extern Bool _XimSetEventMaskCallback(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+);
+
+extern Bool _XimForwardEventCallback(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+);
+
+extern Bool _XimCommitCallback(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+);
+
+extern Bool _XimSyncCallback(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+);
+
+extern void _XimFreeProtoIntrCallback(
+ Xim im
+);
+
+extern XIC _XimProtoCreateIC(
+ XIM im,
+ XIMArg *arg
+);
+
+extern void _XimRegisterServerFilter(
+ Xim im
+);
+
+extern void _XimUnregisterServerFilter(
+ Xim im
+);
+
+extern Bool _XimTriggerNotify(
+ Xim im,
+ Xic ic,
+ int mode,
+ CARD32 idx
+);
+
+extern Bool _XimProcSyncReply(
+ Xim im,
+ Xic ic
+);
+
+extern void _XimSendSetFocus(
+ Xim im,
+ Xic ic
+);
+
+extern Bool _XimForwardEvent(
+ Xic ic,
+ XEvent *ev,
+ Bool sync
+);
+
+extern void _XimFreeRemakeArg(
+ XIMArg *arg
+);
+
+extern void _XimServerDestroy(
+ Xim im
+);
+
+extern char * _XimEncodeIMATTRIBUTE(
+ Xim im,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ XIMArg *arg,
+ XIMArg **arg_ret,
+ char *buf,
+ int size,
+ int *ret_len,
+ XPointer top,
+ unsigned long mode
+);
+
+extern char * _XimEncodeICATTRIBUTE(
+ Xic ic,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ XIMArg *arg,
+ XIMArg **arg_ret,
+ char *buf,
+ int size,
+ int *ret_len,
+ XPointer top,
+ BITMASK32 *flag,
+ unsigned long mode
+);
+
+#ifdef EXT_MOVE
+extern Bool _XimExtenMove(
+ Xim im,
+ Xic ic,
+ CARD32 flag,
+ CARD16 *buf,
+ INT16 length
+);
+#endif
+
+extern int _Ximctstombs(
+ XIM im,
+ char *from,
+ int from_len,
+ char *to,
+ int to_len,
+ Status *state
+);
+
+extern int _Ximctstowcs(
+ XIM im,
+ char *from,
+ int from_len,
+ wchar_t *to,
+ int to_len,
+ Status *state
+);
+
+extern int _Ximctstoutf8(
+ XIM im,
+ char *from,
+ int from_len,
+ char *to,
+ int to_len,
+ Status *state
+);
+
+extern int _XimLcctstombs(
+ XIM im,
+ char *from,
+ int from_len,
+ char *to,
+ int to_len,
+ Status *state
+);
+
+extern int _XimLcctstowcs(
+ XIM im,
+ char *from,
+ int from_len,
+ wchar_t *to,
+ int to_len,
+ Status *state
+);
+
+extern int _XimLcctstoutf8(
+ XIM im,
+ char *from,
+ int from_len,
+ char *to,
+ int to_len,
+ Status *state
+);
+
+extern int _XimCheckDataSize(
+ XPointer buf,
+ int len
+);
+
+extern void _XimSetHeader(
+ XPointer buf,
+ CARD8 major_opcode,
+ CARD8 minor_opcode,
+ INT16 *len
+);
+
+extern Bool _XimSync(
+ Xim im,
+ Xic ic
+);
+
+extern int _XimProtoMbLookupString(
+ XIC xic,
+ XKeyEvent *ev,
+ char *buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *state
+);
+
+extern int _XimProtoWcLookupString(
+ XIC xic,
+ XKeyEvent *ev,
+ wchar_t *buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *state
+);
+
+extern int _XimProtoUtf8LookupString(
+ XIC xic,
+ XKeyEvent *ev,
+ char *buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *state
+);
+
+extern void _XimRegisterFilter(
+ Xic ic
+);
+
+extern void _XimUnregisterFilter(
+ Xic ic
+);
+
+extern void _XimReregisterFilter(
+ Xic ic
+);
+
+extern Status _XimProtoEventToWire(
+ XEvent *re,
+ xEvent *event,
+ Bool sw
+);
+
+extern Bool _XimProtoWireToEvent(
+ XEvent *re,
+ xEvent *event,
+ Bool sw
+);
+
+#ifdef EXT_FORWARD
+extern Bool _XimExtForwardKeyEvent(
+ Xic ic,
+ XKeyEvent *ev,
+ Bool sync
+);
+#endif
+
+extern int _XimLookupMBText(
+ Xic ic,
+ XKeyEvent *event,
+ char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status
+);
+
+extern int _XimLookupWCText(
+ Xic ic,
+ XKeyEvent *event,
+ wchar_t *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status
+);
+
+extern int _XimLookupUTF8Text(
+ Xic ic,
+ XKeyEvent *event,
+ char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status
+);
+
+extern EVENTMASK _XimGetWindowEventmask(
+ Xic ic
+);
+
+extern Xic _XimICOfXICID(
+ Xim im,
+ XICID icid
+);
+
+extern void _XimResetIMInstantiateCallback(
+ Xim xim
+);
+
+extern Bool _XimRegisterIMInstantiateCallback(
+ XLCd lcd,
+ Display *display,
+ XrmDatabase rdb,
+ char *res_name,
+ char *res_class,
+ XIDProc callback,
+ XPointer client_data
+);
+
+extern Bool _XimUnRegisterIMInstantiateCallback(
+ XLCd lcd,
+ Display *display,
+ XrmDatabase rdb,
+ char *res_name,
+ char *res_class,
+ XIDProc callback,
+ XPointer client_data
+);
+
+extern void _XimFreeCommitInfo(
+ Xic ic
+);
+
+extern Bool _XimConnect(
+ Xim im
+);
+
+extern Bool _XimShutdown(
+ Xim im
+);
+
+extern Bool _XimWrite(
+ Xim im,
+ INT16 len,
+ XPointer data
+);
+
+extern Bool _XimRead(
+ Xim im,
+ INT16 *len,
+ XPointer data,
+ int data_len,
+ Bool (*predicate)(
+ Xim, INT16, XPointer, XPointer
+ ),
+ XPointer arg
+);
+
+extern Bool _XimIntrCallback(
+ Xim im,
+ Bool (*callback)(
+ Xim, INT16, XPointer, XPointer
+ ),
+ XPointer call_data
+);
+
+extern void _XimFlush(
+ Xim im
+);
+
+extern Bool _XimFilterWaitEvent(
+ Xim im
+);
+
+extern void _XimProcError(
+ Xim im,
+ Xic ic,
+ XPointer data
+);
+
+#ifdef EXT_MOVE
+extern CARD32 _XimExtenArgCheck(
+ XIMArg *arg
+);
+#endif
+
+extern Bool _XimCbDispatch(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+);
+
+extern Bool _XimLocalFilter(
+ Display *d,
+ Window w,
+ XEvent *ev,
+ XPointer client_data
+);
+
+extern XIMResourceList _XimGetResourceListRecByQuark(
+ XIMResourceList res_list,
+ unsigned int list_num,
+ XrmQuark quark
+);
+
+extern Bool _XimReconnectModeCreateIC(
+ Xic ic
+);
+
+extern char *_XimLocalSetICValues(
+ XIC ic,
+ XIMArg *values
+);
+
+extern char * _XimLocalGetICValues(
+ XIC ic,
+ XIMArg *values
+);
+
+extern int _XimLocalMbLookupString(
+ XIC ic,
+ XKeyEvent *ev,
+ char *buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *status
+);
+
+extern int _XimLocalWcLookupString(
+ XIC ic,
+ XKeyEvent *ev,
+ wchar_t *buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *status
+);
+
+extern int _XimLocalUtf8LookupString(
+ XIC ic,
+ XKeyEvent *ev,
+ char *buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *status
+);
+
+extern Bool _XimThaiFilter(
+ Display *d,
+ Window w,
+ XEvent *ev,
+ XPointer client_data
+);
+
+extern XIC _XimThaiCreateIC(
+ XIM im,
+ XIMArg *values
+);
+
+extern Status _XimThaiCloseIM(
+ XIM xim
+);
+
+#ifdef XIM_CONNECTABLE
+extern void _XimSetProtoResource(
+ Xim im
+);
+
+extern Bool _XimConnectServer(
+ Xim im
+);
+
+extern Bool _XimDelayModeSetAttr(
+ Xim im
+);
+
+extern void _XimServerReconectableDestroy(
+ void
+);
+
+extern Bool _XimReCreateIC(
+ Xic ic
+);
+
+extern Bool _XimEncodeSavedIMATTRIBUTE(
+ Xim im,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ int *idx,
+ char *buf,
+ int size,
+ int *ret_len,
+ XPointer top,
+ unsigned long mode
+);
+
+extern Bool _XimEncodeSavedICATTRIBUTE(
+ Xic ic,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ int *idx,
+ char *buf,
+ int size,
+ int *ret_len,
+ XPointer top,
+ unsigned long mode
+);
+#endif
+
+extern Public Bool
+_XimRegisterDispatcher(
+ Xim im,
+ Bool (*callback)(
+ Xim, INT16, XPointer, XPointer
+ ),
+ XPointer call_data);
+
+extern Public Bool
+_XimRespSyncReply(
+ Xic ic,
+ BITMASK16 mode);
+
+#endif /* _XIMINT_H */
diff --git a/nx-X11/lib/X11/XimintL.h b/nx-X11/lib/X11/XimintL.h
new file mode 100644
index 000000000..2d4f6a9e0
--- /dev/null
+++ b/nx-X11/lib/X11/XimintL.h
@@ -0,0 +1,88 @@
+/* $Xorg: XimintL.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1991, 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993 by Digital Equipment 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 of FUJITSU LIMITED and
+Digital Equipment Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission. FUJITSU LIMITED and Digital Equipment Corporation
+makes no representations about the suitability of this software for
+any purpose. It is provided "as is" without express or implied
+warranty.
+
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Franky Ling Digital Equipment Corporation
+ frankyling@hgrd01.enet.dec.com
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/XimintL.h,v 1.6 2000/12/04 18:49:19 dawes Exp $ */
+
+#ifndef _XIMINTL_H
+#define _XIMINTL_H
+
+#define COMPOSE_FILE "Compose"
+
+/*
+ * Data Structure for Local Processing
+ */
+typedef struct _DefTree {
+ struct _DefTree *next; /* another Key definition */
+ struct _DefTree *succession; /* successive Key Sequence */
+ /* Key definitions */
+ unsigned modifier_mask;
+ unsigned modifier;
+ KeySym keysym; /* leaf only */
+ char *mb;
+ wchar_t *wc; /* make from mb */
+ char *utf8; /* make from mb */
+ KeySym ks;
+} DefTree;
+
+typedef struct _XimLocalPrivateRec {
+ /* The first fields are identical with XimCommonPrivateRec. */
+ XlcConv ctom_conv;
+ XlcConv ctow_conv;
+ XlcConv ctoutf8_conv;
+ XlcConv cstomb_conv;
+ XlcConv cstowc_conv;
+ XlcConv cstoutf8_conv;
+ XlcConv ucstoc_conv;
+ XlcConv ucstoutf8_conv;
+
+ XIC current_ic;
+ DefTree *top;
+} XimLocalPrivateRec;
+
+typedef struct _XicThaiPart {
+ int comp_state;
+ KeySym keysym;
+ int input_mode;
+} XicThaiPart;
+
+typedef struct _XicLocalPrivateRec {
+ long value_mask;
+ DefTree *context;
+ DefTree *composed;
+ XicThaiPart thai;
+
+ XIMResourceList ic_resources;
+ unsigned int ic_num_resources;
+} XicLocalPrivateRec;
+#endif /* _XIMINTL_H */
diff --git a/nx-X11/lib/X11/XimintP.h b/nx-X11/lib/X11/XimintP.h
new file mode 100644
index 000000000..f10d9baad
--- /dev/null
+++ b/nx-X11/lib/X11/XimintP.h
@@ -0,0 +1,293 @@
+/* $Xorg: XimintP.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1991, 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993, 1994 by Sony 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 of Sun Microsystems, Inc., FUJITSU
+LIMITED and Sony Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission. Sun Microsystems, Inc., FUJITSU LIMITED and Sony
+Corporation makes no representations about the suitability of this
+software for any purpose. It is provided "as is" without express or
+implied warranty.
+
+Sun Microsystems Inc. ,FUJITSU LIMITED AND SONY CORPORATION DISCLAIMS ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc.,
+FUJITSU LIMITED, SONY CORPORATIN 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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+ Hiroyuki Miyamoto Digital Equipment Corporation
+ miyamoto@jrd.dec.com
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/XimintP.h,v 1.7 2001/01/17 19:41:49 dawes Exp $ */
+
+#ifndef _XIMINTP_H
+#define _XIMINTP_H
+
+#include "XimProto.h"
+#include "XlcPublic.h"
+
+/*
+ * for protocol layer callback function
+ */
+typedef Bool (*XimProtoIntrProc)(
+ Xim, INT16, XPointer, XPointer
+);
+typedef struct _XimProtoIntrRec {
+ XimProtoIntrProc func;
+ CARD16 major_code;
+ CARD16 minor_code;
+ XPointer call_data;
+ struct _XimProtoIntrRec *next;
+} XimProtoIntrRec;
+
+/*
+ * for transport layer methods
+ */
+typedef Bool (*XimTransConnectProc)(
+ Xim
+);
+typedef Bool (*XimTransShutdownProc)(
+ Xim
+);
+typedef Bool (*XimTransWriteProc)(
+ Xim, INT16, XPointer
+);
+typedef Bool (*XimTransReadProc)(
+ Xim, XPointer, int, int *
+);
+typedef void (*XimTransFlushProc)(
+ Xim
+);
+typedef Bool (*XimTransRegDispatcher)(
+ Xim, Bool (*)(Xim, INT16, XPointer, XPointer), XPointer
+);
+typedef Bool (*XimTransCallDispatcher)(
+ Xim, INT16, XPointer
+);
+
+/*
+ * private part of IM
+ */
+typedef struct _XimProtoPrivateRec {
+ /* The first fields are identical with XimCommonPrivateRec. */
+ XlcConv ctom_conv;
+ XlcConv ctow_conv;
+ XlcConv ctoutf8_conv;
+ XlcConv cstomb_conv;
+ XlcConv cstowc_conv;
+ XlcConv cstoutf8_conv;
+ XlcConv ucstoc_conv;
+ XlcConv ucstoutf8_conv;
+
+ Window im_window;
+ XIMID imid;
+ CARD16 unused;
+ XIMStyles *default_styles;
+ CARD32 *im_onkeylist;
+ CARD32 *im_offkeylist;
+ BITMASK32 flag;
+
+ BITMASK32 registed_filter_event;
+ EVENTMASK forward_event_mask;
+ EVENTMASK synchronous_event_mask;
+
+ XimProtoIntrRec *intrproto;
+ XIMResourceList im_inner_resources;
+ unsigned int im_num_inner_resources;
+ XIMResourceList ic_inner_resources;
+ unsigned int ic_num_inner_resources;
+ char *hold_data;
+ int hold_data_len;
+ char *locale_name;
+ CARD16 protocol_major_version;
+ CARD16 protocol_minor_version;
+ XrmQuark *saved_imvalues;
+ int num_saved_imvalues;
+
+ /*
+ * transport specific
+ */
+ XimTransConnectProc connect;
+ XimTransShutdownProc shutdown;
+ XimTransWriteProc write;
+ XimTransReadProc read;
+ XimTransFlushProc flush;
+ XimTransRegDispatcher register_dispatcher;
+ XimTransCallDispatcher call_dispatcher;
+ XPointer spec;
+} XimProtoPrivateRec;
+
+/*
+ * bit mask for the flag of XIMPrivateRec
+ */
+#define SERVER_CONNECTED (1L)
+#define DYNAMIC_EVENT_FLOW (1L << 1)
+#define USE_AUTHORIZATION_FUNC (1L << 2)
+#ifdef XIM_CONNECTABLE
+#define DELAYBINDABLE (1L << 3)
+#define RECONNECTABLE (1L << 4)
+#endif /* XIM_CONNECTABLE */
+
+/*
+ * macro for the flag of XIMPrivateRec
+ */
+#define IS_SERVER_CONNECTED(im) \
+ ((((Xim)im))->private.proto.flag & SERVER_CONNECTED)
+#define MARK_SERVER_CONNECTED(im) \
+ ((((Xim)im))->private.proto.flag |= SERVER_CONNECTED)
+#define UNMARK_SERVER_CONNECTED(im) \
+ ((((Xim)im))->private.proto.flag &= ~SERVER_CONNECTED)
+
+#define IS_DYNAMIC_EVENT_FLOW(im) \
+ (((Xim)im)->private.proto.flag & DYNAMIC_EVENT_FLOW)
+#define MARK_DYNAMIC_EVENT_FLOW(im) \
+ (((Xim)im)->private.proto.flag |= DYNAMIC_EVENT_FLOW)
+
+#define IS_USE_AUTHORIZATION_FUNC(im) \
+ (((Xim)im)->private.proto.flag & USE_AUTHORIZATION_FUNC)
+#define MARK_USE_AUTHORIZATION_FUNC(im) \
+ (((Xim)im)->private.proto.flag |= USE_AUTHORIZATION_FUNC)
+
+#ifdef XIM_CONNECTABLE
+#define IS_DELAYBINDABLE(im) \
+ (((Xim)im)->private.proto.flag & DELAYBINDABLE)
+#define MARK_DELAYBINDABLE(im) \
+ (((Xim)im)->private.proto.flag |= DELAYBINDABLE)
+
+#define IS_RECONNECTABLE(im) \
+ (((Xim)im)->private.proto.flag & RECONNECTABLE)
+#define MARK_RECONNECTABLE(im) \
+ (((Xim)im)->private.proto.flag |= RECONNECTABLE)
+
+#define IS_CONNECTABLE(im) \
+ (((Xim)im)->private.proto.flag & (DELAYBINDABLE|RECONNECTABLE))
+#define UNMAKE_CONNECTABLE(im) \
+ (((Xim)im)->private.proto.flag &= ~(DELAYBINDABLE|RECONNECTABLE))
+#endif /* XIM_CONNECTABLE */
+
+/*
+ * bit mask for the register_filter_event of XIMPrivateRec/XICPrivateRec
+ */
+#define KEYPRESS_MASK (1L)
+#define KEYRELEASE_MASK (1L << 1)
+#define DESTROYNOTIFY_MASK (1L << 2)
+
+typedef struct _XimCommitInfoRec {
+ struct _XimCommitInfoRec *next;
+ char *string;
+ int string_len;
+ KeySym *keysym;
+ int keysym_len;
+} XimCommitInfoRec, *XimCommitInfo;
+
+typedef struct _XimPendingCallback {
+ int major_opcode;
+ Xim im;
+ Xic ic;
+ char *proto;
+ int proto_len;
+ struct _XimPendingCallback *next;
+} XimPendingCallbackRec, *XimPendingCallback;
+
+
+/*
+ * private part of IC
+ */
+typedef struct _XicProtoPrivateRec {
+ XICID icid; /* ICID */
+ CARD16 dmy;
+ BITMASK32 flag; /* Input Mode */
+
+ BITMASK32 registed_filter_event; /* registed filter mask */
+ EVENTMASK forward_event_mask; /* forward event mask */
+ EVENTMASK synchronous_event_mask;/* sync event mask */
+ EVENTMASK filter_event_mask; /* negrect event mask */
+ EVENTMASK intercept_event_mask; /* deselect event mask */
+ EVENTMASK select_event_mask; /* select event mask */
+
+ char *preedit_font; /* Base font name list */
+ int preedit_font_length; /* length of base font name */
+ char *status_font; /* Base font name list */
+ int status_font_length; /* length of base font name */
+
+ XimCommitInfo commit_info;
+ XIMResourceList ic_resources;
+ unsigned int ic_num_resources;
+ XIMResourceList ic_inner_resources;
+ unsigned int ic_num_inner_resources;
+ XrmQuark *saved_icvalues;
+ int num_saved_icvalues;
+ XimPendingCallback pend_cb_que;
+ Bool waitCallback;
+} XicProtoPrivateRec ;
+
+/*
+ * bit mask for the flag of XICPrivateRec
+ */
+#define IC_CONNECTED (1L)
+#define FABLICATED (1L << 1)
+#define NEED_SYNC_REPLY (1L << 2)
+
+/*
+ * macro for the flag of XICPrivateRec
+ */
+#define IS_IC_CONNECTED(ic) \
+ (((Xic)ic)->private.proto.flag & IC_CONNECTED)
+#define MARK_IC_CONNECTED(ic) \
+ (((Xic)ic)->private.proto.flag |= IC_CONNECTED)
+#define UNMARK_IC_CONNECTED(ic) \
+ (((Xic)ic)->private.proto.flag &= ~IC_CONNECTED)
+
+#define IS_FABLICATED(ic) \
+ (((Xic)ic)->private.proto.flag & FABLICATED)
+#define MARK_FABLICATED(ic) \
+ (((Xic)ic)->private.proto.flag |= FABLICATED)
+#define UNMARK_FABLICATED(ic) \
+ (((Xic)ic)->private.proto.flag &= ~FABLICATED)
+
+#define IS_NEED_SYNC_REPLY(ic) \
+ (((Xic)ic)->private.proto.flag & NEED_SYNC_REPLY)
+#define MARK_NEED_SYNC_REPLY(ic) \
+ (((Xic)ic)->private.proto.flag |= NEED_SYNC_REPLY)
+#define UNMARK_NEED_SYNC_REPLY(ic) \
+ (((Xic)ic)->private.proto.flag &= ~NEED_SYNC_REPLY)
+
+/*
+ * macro for the filter_event_mask of XICPrivateRec
+ */
+#define IS_NEGLECT_EVENT(ic, mask) \
+ (((Xic)ic)->private.proto.filter_event_mask & (mask))
+
+/*
+ * macro for the forward_event_mask of XICPrivateRec
+ */
+#define IS_FORWARD_EVENT(ic, mask) \
+ (((Xic)ic)->private.proto.forward_event_mask & (mask))
+
+/*
+ * macro for the synchronous_event_mask of XICPrivateRec
+ */
+#define IS_SYNCHRONOUS_EVENT(ic, mask) \
+ ((((Xic)ic)->private.proto.synchronous_event_mask & (mask)) ? True: False)
+
+#define XIM_MAXIMNAMELEN 64
+#define XIM_MAXLCNAMELEN 64
+
+#endif /* _XIMINTP_H */
diff --git a/nx-X11/lib/X11/Xintatom.h b/nx-X11/lib/X11/Xintatom.h
new file mode 100644
index 000000000..f1e13568b
--- /dev/null
+++ b/nx-X11/lib/X11/Xintatom.h
@@ -0,0 +1,33 @@
+/* $XFree86$ */
+
+#ifndef _XINTATOM_H_
+#define _XINTATOM_H_ 1
+
+#include <X11/Xfuncproto.h>
+
+/* IntAtom.c */
+
+#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;
+
+_XFUNCPROTOBEGIN
+
+extern void _XUpdateAtomCache(Display *dpy, const char *name, Atom atom,
+ unsigned long sig, int idx, int n);
+extern void _XFreeAtomTable(Display *dpy);
+
+_XFUNCPROTOEND
+
+#endif /* _XINTATOM_H_ */
diff --git a/nx-X11/lib/X11/Xintconn.h b/nx-X11/lib/X11/Xintconn.h
new file mode 100644
index 000000000..edea98302
--- /dev/null
+++ b/nx-X11/lib/X11/Xintconn.h
@@ -0,0 +1,36 @@
+/* $XFree86: xc/lib/X11/Xintconn.h,v 1.1 2001/08/18 02:41:28 dawes Exp $ */
+
+#ifndef _XINTCONN_H_
+#define _XINTCONN_H_ 1
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+/* ConnDis.c */
+
+int _XConnectDisplay (
+ 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 */
+extern int _XDisconnectDisplay(XtransConnInfo trans_conn);
+extern Bool _XSendClientPrefix(Display *dpy, xConnClientPrefix *client,
+ char *auth_proto, char *auth_string,
+ xConnSetupPrefix *prefix);
+extern XtransConnInfo _X11TransConnectDisplay(char *display_name,
+ char **fullnamep, int *dpynump,
+ int *screenp, char **auth_namep,
+ int *auth_namelenp, char **auth_datap,
+ int *auth_datalenp);
+
+/* OpenDis.c */
+extern void _XFreeDisplayStructure(Display *dpy);
+
+_XFUNCPROTOEND
+
+#endif /* _XINTCONN_H_ */
diff --git a/nx-X11/lib/X11/XlcDL.c b/nx-X11/lib/X11/XlcDL.c
new file mode 100644
index 000000000..679b3c13a
--- /dev/null
+++ b/nx-X11/lib/X11/XlcDL.c
@@ -0,0 +1,632 @@
+/*
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Portions Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions: 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 OR SUN MICROSYSTEMS, INC. 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 EVEN IF
+ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Except as contained in this notice, the names of The Open Group and/or
+Sun Microsystems, Inc. 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 and/or Sun Microsystems,
+Inc., as applicable.
+
+
+X Window System is a trademark of The Open Group
+
+OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
+logo, LBX, X Window System, and Xinerama are trademarks of the Open
+Group. All other trademarks and registered trademarks mentioned herein
+are the property of their respective owners. No right, title or
+interest in or to any trademark, service mark, logo or trade name of
+Sun Microsystems, Inc. or its licensors is granted.
+
+*/
+/* $XFree86: xc/lib/X11/XlcDL.c,v 1.12 2003/04/13 19:22:19 dawes Exp $ */
+/* $XdotOrg: xc/lib/X11/XlcDL.c,v 1.6 2005/07/11 15:24:32 lars Exp $ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#else
+# if defined(hpux)
+# define HAVE_DL_H
+# else
+# define HAVE_DLFCN_H
+# endif
+#endif
+
+#include <stdio.h>
+
+#ifdef HAVE_DL_H
+#include <dl.h>
+#endif
+
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <ctype.h>
+
+#include "Xlibint.h"
+#include "XlcPublic.h"
+#include "XlcPubI.h"
+
+#if defined(_LP64) && defined(__sparcv9)
+# define _MACH64_NAME "sparcv9"
+#else
+# undef _MACH64_NAME
+#endif /* defined(_LP64) && defined(__sparcv9) */
+
+#ifdef _MACH64_NAME
+# define _MACH64_NAME_LEN (sizeof (_MACH64_NAME) - 1)
+#endif
+
+#define XI18N_DLREL 2
+
+#define iscomment(ch) ((ch) == '\0' || (ch) == '#')
+
+typedef enum {
+ XLC_OBJECT,
+ XIM_OBJECT,
+ XOM_OBJECT
+} XI18NDLType;
+
+typedef struct {
+ XI18NDLType type;
+ int locale_name_len;
+ char *locale_name;
+ char *dl_name;
+ char *open;
+ char *im_register;
+ char *im_unregister;
+ int dl_release;
+ unsigned int refcount;
+#if defined(hpux)
+ shl_t dl_module;
+#else
+ void *dl_module;
+#endif
+} XI18NObjectsListRec, *XI18NObjectsList;
+
+#define OBJECT_INIT_LEN 8
+#define OBJECT_INC_LEN 4
+static int lc_len = 0;
+static XI18NObjectsListRec *xi18n_objects_list = NULL;
+static int lc_count = 0;
+
+static int
+parse_line(char *line, char **argv, int argsize)
+{
+ int argc = 0;
+ char *p = line;
+
+ while (argc < argsize) {
+ while (isspace(*p)) {
+ ++p;
+ }
+ if (iscomment(*p)){
+ break;
+ }
+ argv[argc++] = p;
+ while (!isspace(*p)) {
+ ++p;
+ }
+ if (iscomment(*p)) {
+ break;
+ }
+ *p++ = '\0';
+ }
+ return argc;
+}
+
+static char *
+strdup_with_underscore(const char *symbol)
+{
+ char *result;
+
+ if ((result = malloc(strlen(symbol) + 2)) == NULL)
+ return NULL;
+ result[0] = '_';
+ strcpy(result + 1, symbol);
+ return result;
+}
+
+#ifndef hpux
+static void *
+try_both_dlsym (void *handle, char *name)
+{
+ void *ret;
+
+ ret = dlsym (handle, name);
+ if (!ret)
+ {
+ name = strdup_with_underscore (name);
+ if (name)
+ {
+ ret = dlsym (handle, name);
+ free (name);
+ }
+ }
+ return ret;
+}
+#endif
+
+static void
+resolve_object(char *path, const char *lc_name)
+{
+ char filename[BUFSIZ];
+ FILE *fp;
+ char buf[BUFSIZ];
+
+ if (lc_len == 0) { /* True only for the 1st time */
+ lc_len = OBJECT_INIT_LEN;
+ xi18n_objects_list = (XI18NObjectsList)
+ Xmalloc(sizeof(XI18NObjectsListRec) * lc_len);
+ if (!xi18n_objects_list) return;
+ }
+/*
+1266793
+Limit the length of path to prevent stack buffer corruption.
+ sprintf(filename, "%s/%s", path, "XI18N_OBJS");
+*/
+ sprintf(filename, "%.*s/%s", BUFSIZ - 12, path, "XI18N_OBJS");
+ fp = fopen(filename, "r");
+ if (fp == (FILE *)NULL){
+ return;
+ }
+
+ while (fgets(buf, BUFSIZ, fp) != NULL){
+ char *p = buf;
+ int n;
+ char *args[6];
+ while (isspace(*p)){
+ ++p;
+ }
+ if (iscomment(*p)){
+ continue;
+ }
+
+ if (lc_count == lc_len) {
+ lc_len += OBJECT_INC_LEN;
+ xi18n_objects_list = (XI18NObjectsList)
+ Xrealloc(xi18n_objects_list,
+ sizeof(XI18NObjectsListRec) * lc_len);
+ if (!xi18n_objects_list) return;
+ }
+ n = parse_line(p, args, 6);
+
+ if (n == 3 || n == 5) {
+ if (!strcmp(args[0], "XLC")){
+ xi18n_objects_list[lc_count].type = XLC_OBJECT;
+ } else if (!strcmp(args[0], "XOM")){
+ xi18n_objects_list[lc_count].type = XOM_OBJECT;
+ } else if (!strcmp(args[0], "XIM")){
+ xi18n_objects_list[lc_count].type = XIM_OBJECT;
+ }
+ xi18n_objects_list[lc_count].dl_name = strdup(args[1]);
+ xi18n_objects_list[lc_count].open = strdup(args[2]);
+ xi18n_objects_list[lc_count].dl_release = XI18N_DLREL;
+ xi18n_objects_list[lc_count].locale_name = strdup(lc_name);
+ xi18n_objects_list[lc_count].refcount = 0;
+ xi18n_objects_list[lc_count].dl_module = (void*)NULL;
+ if (n == 5) {
+ xi18n_objects_list[lc_count].im_register = strdup(args[3]);
+ xi18n_objects_list[lc_count].im_unregister = strdup(args[4]);
+ } else {
+ xi18n_objects_list[lc_count].im_register = NULL;
+ xi18n_objects_list[lc_count].im_unregister = NULL;
+ }
+ lc_count++;
+ }
+ }
+ fclose(fp);
+}
+
+static char*
+__lc_path(const char *dl_name, const char *lc_dir)
+{
+ char *path;
+ size_t len;
+
+ /*
+ * reject this for possible security issue
+ */
+ if (strstr (dl_name, "../"))
+ return NULL;
+
+#if defined (_LP64) && defined (_MACH64_NAME)
+ len = (lc_dir ? strlen(lc_dir) : 0 ) +
+ (dl_name ? strlen(dl_name) : 0) + _MACH64_NAME_LEN + 10;
+ path = Xmalloc(len + 1);
+
+ if (strchr(dl_name, '/') != NULL) {
+ char *tmp = strdup(dl_name);
+ char *dl_dir, *dl_file;
+ char *slash_p;
+ slash_p = strchr(tmp, '/');
+ *slash_p = '\0';
+ dl_dir = tmp;
+ dl_file = ++slash_p;
+
+ slash_p = strrchr(lc_dir, '/');
+ *slash_p = '\0';
+ strcpy(path, lc_dir); strcat(path, "/");
+ strcat(path, dl_dir); strcat(path, "/");
+ strcat(path, _MACH64_NAME); strcat(path, "/");
+ strcat(path, dl_file); strcat(path, ".so.2");
+
+ *slash_p = '/';
+ Xfree(tmp);
+ } else {
+ strcpy(path, lc_dir); strcat(path, "/");
+ strcat(path, _MACH64_NAME); strcat(path, "/");
+ strcat(path, dl_name); strcat(path, ".so.2");
+ }
+#else
+ len = (lc_dir ? strlen(lc_dir) : 0 ) +
+ (dl_name ? strlen(dl_name) : 0) + 10;
+#if defined POSTLOCALELIBDIR
+ len += (strlen(POSTLOCALELIBDIR) + 1);
+#endif
+ path = Xmalloc(len + 1);
+
+ if (strchr(dl_name, '/') != NULL) {
+ char *slash_p;
+ slash_p = strrchr(lc_dir, '/');
+ *slash_p = '\0';
+ strcpy(path, lc_dir); strcat(path, "/");
+#if defined POSTLOCALELIBDIR
+ strcat(path, POSTLOCALELIBDIR); strcat(path, "/");
+#endif
+ strcat(path, dl_name); strcat(path, ".so.2");
+ *slash_p = '/';
+ } else {
+ strcpy(path, lc_dir); strcat(path, "/");
+#if defined POSTLOCALELIBDIR
+ strcat(path, POSTLOCALELIBDIR); strcat(path, "/");
+#endif
+ strcat(path, dl_name); strcat(path, ".so.2");
+ }
+#endif
+ return path;
+}
+
+/* We reference count dlopen() and dlclose() of modules; unfortunately,
+ * since XCloseIM, XCloseOM, XlcClose aren't wrapped, but directly
+ * call the close method of the object, we leak a reference count every
+ * time we open then close a module. Fixing this would require
+ * either creating proxy objects or hooks for close_im/close_om
+ * in XLCd
+ */
+static Bool
+open_object(
+ XI18NObjectsList object,
+ char *lc_dir)
+{
+ char *path;
+
+ if (object->refcount == 0) {
+ path = __lc_path(object->dl_name, lc_dir);
+ if (!path)
+ return False;
+#if defined(hpux)
+ object->dl_module = shl_load(path, BIND_DEFERRED, 0L);
+#else
+ object->dl_module = dlopen(path, RTLD_LAZY);
+#endif
+ Xfree(path);
+
+ if (!object->dl_module)
+ return False;
+ }
+
+ object->refcount++;
+ return True;
+}
+
+static void *
+fetch_symbol(
+ XI18NObjectsList object,
+ char *symbol)
+{
+ void *result = NULL;
+#if defined(hpux)
+ int getsyms_cnt, i;
+ struct shl_symbol *symbols;
+#endif
+
+ if (symbol == NULL)
+ return NULL;
+
+#if defined(hpux)
+ getsyms_cnt = shl_getsymbols(object->dl_module, TYPE_PROCEDURE,
+ EXPORT_SYMBOLS, malloc, &symbols);
+
+ for(i=0; i<getsyms_cnt; i++) {
+ if(!strcmp(symbols[i].name, symbol)) {
+ result = symbols[i].value;
+ break;
+ }
+ }
+
+ if(getsyms_cnt > 0) {
+ free(symbols);
+ }
+#else
+ result = try_both_dlsym(object->dl_module, symbol);
+#endif
+
+ return result;
+}
+
+static void
+close_object(XI18NObjectsList object)
+{
+ object->refcount--;
+ if (object->refcount == 0)
+ {
+#if defined(hpux)
+ shl_unload(object->dl_module);
+#else
+ dlclose(object->dl_module);
+#endif
+ object->dl_module = NULL;
+ }
+}
+
+
+typedef XLCd (*dynamicLoadProc)(const char *);
+
+XLCd
+_XlcDynamicLoad(const char *lc_name)
+{
+ XLCd lcd = (XLCd)NULL;
+ dynamicLoadProc lc_loader = (dynamicLoadProc)NULL;
+ int count;
+ XI18NObjectsList objects_list;
+ char lc_dir[BUFSIZE];
+
+ if (lc_name == NULL) return (XLCd)NULL;
+
+ if (_XlcLocaleDirName(lc_dir, BUFSIZE, (char *)lc_name) == (char*)NULL)
+ return (XLCd)NULL;
+
+ resolve_object(lc_dir, lc_name);
+
+ objects_list = xi18n_objects_list;
+ count = lc_count;
+ for (; count-- > 0; objects_list++) {
+ if (objects_list->type != XLC_OBJECT ||
+ strcmp(objects_list->locale_name, lc_name)) continue;
+ if (!open_object (objects_list, lc_dir))
+ continue;
+
+ lc_loader = (dynamicLoadProc)fetch_symbol (objects_list, objects_list->open);
+ if (!lc_loader) continue;
+ lcd = (*lc_loader)(lc_name);
+ if (lcd != (XLCd)NULL) {
+ break;
+ }
+
+ close_object (objects_list);
+ }
+ return (XLCd)lcd;
+}
+
+
+typedef XIM (*dynamicOpenProcp)(XLCd, Display *, XrmDatabase, char *, char *);
+
+static XIM
+_XDynamicOpenIM(XLCd lcd, Display *display, XrmDatabase rdb,
+ char *res_name, char *res_class)
+{
+ XIM im = (XIM)NULL;
+ char lc_dir[BUFSIZE];
+ char *lc_name;
+ dynamicOpenProcp im_openIM = (dynamicOpenProcp)NULL;
+ int count;
+ XI18NObjectsList objects_list = xi18n_objects_list;
+
+ lc_name = lcd->core->name;
+
+ if (_XlcLocaleDirName(lc_dir, BUFSIZE, lc_name) == NULL) return (XIM)0;
+
+ count = lc_count;
+ for (; count-- > 0; objects_list++) {
+ if (objects_list->type != XIM_OBJECT ||
+ strcmp(objects_list->locale_name, lc_name)) continue;
+
+ if (!open_object (objects_list, lc_dir))
+ continue;
+
+ im_openIM = (dynamicOpenProcp)fetch_symbol(objects_list, objects_list->open);
+ if (!im_openIM) continue;
+ im = (*im_openIM)(lcd, display, rdb, res_name, res_class);
+ if (im != (XIM)NULL) {
+ break;
+ }
+
+ close_object (objects_list);
+ }
+ return (XIM)im;
+}
+
+typedef Bool (*dynamicRegisterCBProcp)(
+ XLCd, Display *, XrmDatabase, char *, char *, XIDProc, XPointer);
+
+static Bool
+_XDynamicRegisterIMInstantiateCallback(
+ XLCd lcd,
+ Display *display,
+ XrmDatabase rdb,
+ char *res_name,
+ char *res_class,
+ XIDProc callback,
+ XPointer client_data)
+{
+ char lc_dir[BUFSIZE];
+ char *lc_name;
+ dynamicRegisterCBProcp im_registerIM = (dynamicRegisterCBProcp)NULL;
+ Bool ret_flag = False;
+ int count;
+ XI18NObjectsList objects_list = xi18n_objects_list;
+#if defined(hpux)
+ int getsyms_cnt, i;
+ struct shl_symbol *symbols;
+#endif
+
+ lc_name = lcd->core->name;
+
+ if (_XlcLocaleDirName(lc_dir, BUFSIZE, lc_name) == NULL) return False;
+
+ count = lc_count;
+ for (; count-- > 0; objects_list++) {
+ if (objects_list->type != XIM_OBJECT ||
+ strcmp(objects_list->locale_name, lc_name)) continue;
+
+ if (!open_object (objects_list, lc_dir))
+ continue;
+ im_registerIM = (dynamicRegisterCBProcp)fetch_symbol(objects_list,
+ objects_list->im_register);
+ if (!im_registerIM) continue;
+ ret_flag = (*im_registerIM)(lcd, display, rdb,
+ res_name, res_class,
+ callback, client_data);
+ if (ret_flag) break;
+
+ close_object (objects_list);
+ }
+ return (Bool)ret_flag;
+}
+
+typedef Bool (*dynamicUnregisterProcp)(
+ XLCd, Display *, XrmDatabase, char *, char *, XIDProc, XPointer);
+
+static Bool
+_XDynamicUnRegisterIMInstantiateCallback(
+ XLCd lcd,
+ Display *display,
+ XrmDatabase rdb,
+ char *res_name,
+ char *res_class,
+ XIDProc callback,
+ XPointer client_data)
+{
+ char lc_dir[BUFSIZE];
+ char *lc_name;
+ dynamicUnregisterProcp im_unregisterIM = (dynamicUnregisterProcp)NULL;
+ Bool ret_flag = False;
+ int count;
+ XI18NObjectsList objects_list = xi18n_objects_list;
+#if defined(hpux)
+ int getsyms_cnt, i;
+ struct shl_symbol *symbols;
+#endif
+
+ lc_name = lcd->core->name;
+ if (_XlcLocaleDirName(lc_dir, BUFSIZE, lc_name) == NULL) return False;
+
+ count = lc_count;
+ for (; count-- > 0; objects_list++) {
+ if (objects_list->type != XIM_OBJECT ||
+ strcmp(objects_list->locale_name, lc_name)) continue;
+
+ if (!objects_list->refcount) /* Must already be opened */
+ continue;
+
+ im_unregisterIM = (dynamicUnregisterProcp)fetch_symbol(objects_list,
+ objects_list->im_unregister);
+
+ if (!im_unregisterIM) continue;
+ ret_flag = (*im_unregisterIM)(lcd, display, rdb,
+ res_name, res_class,
+ callback, client_data);
+ if (ret_flag) {
+ close_object (objects_list); /* opened in RegisterIMInstantiateCallback */
+ break;
+ }
+ }
+ return (Bool)ret_flag;
+}
+
+Bool
+_XInitDynamicIM(XLCd lcd)
+{
+ if(lcd == (XLCd)NULL)
+ return False;
+ lcd->methods->open_im = _XDynamicOpenIM;
+ lcd->methods->register_callback = _XDynamicRegisterIMInstantiateCallback;
+ lcd->methods->unregister_callback = _XDynamicUnRegisterIMInstantiateCallback;
+ return True;
+}
+
+
+typedef XOM (*dynamicIOpenProcp)(
+ XLCd, Display *, XrmDatabase, _Xconst char *, _Xconst char *);
+
+static XOM
+_XDynamicOpenOM(XLCd lcd, Display *display, XrmDatabase rdb,
+ _Xconst char *res_name, _Xconst char *res_class)
+{
+ XOM om = (XOM)NULL;
+ int count;
+ char lc_dir[BUFSIZE];
+ char *lc_name;
+ dynamicIOpenProcp om_openOM = (dynamicIOpenProcp)NULL;
+ XI18NObjectsList objects_list = xi18n_objects_list;
+#if defined(hpux)
+ int getsyms_cnt, i;
+ struct shl_symbol *symbols;
+#endif
+
+ lc_name = lcd->core->name;
+
+ if (_XlcLocaleDirName(lc_dir, BUFSIZE, lc_name) == NULL) return (XOM)0;
+
+ count = lc_count;
+ for (; count-- > 0; objects_list++) {
+ if (objects_list->type != XOM_OBJECT ||
+ strcmp(objects_list->locale_name, lc_name)) continue;
+ if (!open_object (objects_list, lc_dir))
+ continue;
+
+ om_openOM = (dynamicIOpenProcp)fetch_symbol(objects_list, objects_list->open);
+ if (!om_openOM) continue;
+ om = (*om_openOM)(lcd, display, rdb, res_name, res_class);
+ if (om != (XOM)NULL) {
+ break;
+ }
+ close_object(objects_list);
+ }
+ return (XOM)om;
+}
+
+Bool
+_XInitDynamicOM(XLCd lcd)
+{
+ if(lcd == (XLCd)NULL)
+ return False;
+
+ lcd->methods->open_om = _XDynamicOpenOM;
+
+ return True;
+}
diff --git a/nx-X11/lib/X11/XlcGeneric.h b/nx-X11/lib/X11/XlcGeneric.h
new file mode 100644
index 000000000..f1d14e710
--- /dev/null
+++ b/nx-X11/lib/X11/XlcGeneric.h
@@ -0,0 +1,164 @@
+/* $Xorg: XlcGeneric.h,v 1.3 2000/08/17 19:45:06 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+/* $XFree86: xc/lib/X11/XlcGeneric.h,v 1.4 2001/07/25 15:04:44 dawes Exp $ */
+
+#ifndef _XLCGENERIC_H_
+#define _XLCGENERIC_H_
+
+#include "XlcPubI.h"
+
+typedef struct _ByteInfo {
+ unsigned char start,end;
+} ByteInfoRec, *ByteInfo;
+
+typedef struct _ByteInfoList {
+ int M; /* 1 <= M <= length */
+ int byteinfo_num;
+ ByteInfo byteinfo;
+} ByteInfoListRec, *ByteInfoList;
+
+/* conversion_type values */
+#define LOCALCONV 1
+#define FILECONV 2
+#define FUNCTIONCONV 4
+
+typedef struct _Conversion {
+ unsigned long conversion_type;
+ int conv_num;
+ FontScope convlist;
+ char *cnv_file;
+ XlcConv cnvfunc;
+} ConversionRec, *Conversion;
+
+typedef struct _ExtdSegment {
+ char *name;
+ XlcSide side;
+ FontScope area;
+ int area_num;
+ XlcCharSet charset;
+} ExtdSegmentRec, *ExtdSegment;
+
+typedef struct _SegConvRec {
+ int length;
+ char *source_encoding;
+ XlcCharSet source;
+ char *destination_encoding;
+ XlcCharSet dest;
+ FontScopeRec range;
+ int conv_num;
+ FontScope conv;
+} SegConvRec, *SegConv;
+
+typedef struct _ParseInfoRec *ParseInfo;
+
+typedef struct _CodeSetRec {
+ XlcCharSet *charset_list;
+ int num_charsets;
+ int cs_num;
+ XlcSide side;
+ int length;
+ ByteInfoList byteM;
+ Conversion mbconv;
+ Conversion ctconv;
+ ExtdSegment ctextseg;
+ ParseInfo parse_info;
+ unsigned long wc_encoding;
+ Bool string_encoding;
+} CodeSetRec, *CodeSet;
+
+typedef enum {
+ E_GL, /* GL encoding */
+ E_GR, /* GR encoding */
+ E_SS, /* single shift */
+ E_LSL, /* locking shift left */
+ E_LSR, /* locking shift right */
+ E_LAST
+} EncodingType;
+
+typedef struct _ParseInfoRec {
+ EncodingType type;
+ char *encoding;
+ CodeSet codeset;
+} ParseInfoRec;
+
+/*
+ * XLCd private data
+ */
+
+#define XLC_GENERIC(lcd, x) (((XLCdGeneric) lcd->core)->gen.x)
+#define XLC_GENERIC_PART(lcd) (&(((XLCdGeneric) lcd->core)->gen))
+
+typedef struct _XLCdGenericPart {
+ int codeset_num;
+ CodeSet *codeset_list;
+ unsigned char *mb_parse_table;
+ int mb_parse_list_num;
+ ParseInfo *mb_parse_list;
+ unsigned long wc_encode_mask;
+ unsigned long wc_shift_bits;
+ CodeSet initial_state_GL;
+ CodeSet initial_state_GR;
+ int segment_conv_num; /* UDC */
+ SegConv segment_conv; /* UDC */
+ Bool use_stdc_env;
+ Bool force_convert_to_mb;
+} XLCdGenericPart;
+
+typedef struct _XLCdGenericRec {
+ XLCdCoreRec core;
+ XLCdPublicPart pub;
+ XLCdGenericPart gen;
+} XLCdGenericRec, *XLCdGeneric;
+
+extern XLCdMethods _XlcGenericMethods;
+
+extern FontScope
+_XlcParse_scopemaps(
+ const char *str,
+ int *size);
+extern void
+_XlcDbg_printValue(
+ const char *str,
+ char **value,
+ int num);
+
+extern XIM
+_XDefaultOpenIM(
+ XLCd lcd,
+ Display *dpy,
+ XrmDatabase rdb,
+ char *res_name,
+ char *res_class);
+
+#endif /* _XLCGENERIC_H_ */
diff --git a/nx-X11/lib/X11/XlcPubI.h b/nx-X11/lib/X11/XlcPubI.h
new file mode 100644
index 000000000..8441d7f65
--- /dev/null
+++ b/nx-X11/lib/X11/XlcPubI.h
@@ -0,0 +1,301 @@
+/* $Xorg: XlcPubI.h,v 1.4 2000/12/12 12:44:05 coskrey Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/XlcPubI.h,v 3.14 2003/11/17 22:20:10 dawes Exp $ */
+
+#ifndef _XLCPUBLICI_H_
+#define _XLCPUBLICI_H_
+
+#include "XlcPublic.h"
+
+#define XLC_PUBLIC(lcd, x) (((XLCdPublic) lcd->core)->pub.x)
+#define XLC_PUBLIC_PART(lcd) (&(((XLCdPublic) lcd->core)->pub))
+#define XLC_PUBLIC_METHODS(lcd) (&(((XLCdPublicMethods) lcd->methods)->pub))
+
+/*
+ * XLCd public methods
+ */
+
+typedef struct _XLCdPublicMethodsRec *XLCdPublicMethods;
+
+typedef XLCd (*XlcPubCreateProc)(
+ const char* name,
+ XLCdMethods methods
+);
+
+typedef Bool (*XlcPubInitializeProc)(
+ XLCd lcd
+);
+
+typedef void (*XlcPubDestroyProc)(
+ XLCd lcd
+);
+
+typedef char* (*XlcPubGetValuesProc)(
+ XLCd lcd,
+ XlcArgList args,
+ int num_args
+);
+
+typedef void (*XlcPubGetResourceProc)(
+ XLCd lcd,
+ const char* category,
+ const char* _class,
+ char*** value,
+ int* count
+);
+
+typedef struct _XLCdPublicMethodsPart {
+ XLCdPublicMethods superclass;
+ XlcPubCreateProc create;
+ XlcPubInitializeProc initialize;
+ XlcPubDestroyProc destroy;
+ XlcPubGetValuesProc get_values;
+ XlcPubGetResourceProc get_resource;
+} XLCdPublicMethodsPart;
+
+typedef struct _XLCdPublicMethodsRec {
+ XLCdMethodsRec core;
+ XLCdPublicMethodsPart pub;
+} XLCdPublicMethodsRec;
+
+/*
+ * XLCd public data
+ */
+
+typedef struct _XLCdPublicPart {
+ char *siname; /* for _XlcMapOSLocaleName() */
+ char *language; /* language part of locale name */
+ char *territory; /* territory part of locale name */
+ char *codeset; /* codeset part of locale name */
+ char *encoding_name; /* encoding name */
+ int mb_cur_max; /* ANSI C MB_CUR_MAX */
+ Bool is_state_depend; /* state-depend encoding */
+ const char *default_string; /* for XDefaultString() */
+ XPointer xlocale_db;
+} XLCdPublicPart;
+
+typedef struct _XLCdPublicRec {
+ XLCdCoreRec core;
+ XLCdPublicPart pub;
+} XLCdPublicRec, *XLCdPublic;
+
+extern XLCdMethods _XlcPublicMethods;
+
+_XFUNCPROTOBEGIN
+
+extern XLCd _XlcCreateLC(
+ const char* name,
+ XLCdMethods methods
+);
+
+extern void _XlcDestroyLC(
+ XLCd lcd
+);
+
+/* Fills into a freshly created XlcCharSet the fields that can be inferred
+ from the ESC sequence. These are side, char_size, set_size. */
+extern Bool _XlcParseCharSet(
+ XlcCharSet charset
+);
+
+/* Creates a new XlcCharSet, given its name (including side suffix) and
+ Compound Text ESC sequence (normally at most 4 bytes). */
+extern XlcCharSet _XlcCreateDefaultCharSet(
+ const char* name,
+ const char* ct_sequence
+);
+
+extern XlcCharSet _XlcAddCT(
+ const char* name,
+ const char* ct_sequence
+);
+
+extern Bool _XlcInitCTInfo (void);
+
+extern XrmMethods _XrmDefaultInitParseInfo(
+ XLCd lcd,
+ XPointer* state
+);
+
+extern int _XmbTextPropertyToTextList(
+ XLCd lcd,
+ Display* dpy,
+ const XTextProperty* text_prop,
+ char*** list_ret,
+ int* count_ret
+);
+
+extern int _XwcTextPropertyToTextList(
+ XLCd lcd,
+ Display* dpy,
+ const XTextProperty* text_prop,
+ wchar_t*** list_ret,
+ int* count_ret
+);
+
+extern int _Xutf8TextPropertyToTextList(
+ XLCd lcd,
+ Display* dpy,
+ const XTextProperty* text_prop,
+ char*** list_ret,
+ int* count_ret
+);
+
+extern int _XmbTextListToTextProperty(
+ XLCd /* lcd */,
+ Display* /* dpy */,
+ char** /* list */,
+ int /* count */,
+ XICCEncodingStyle /* style */,
+ XTextProperty* /* text_prop */
+);
+
+extern int _XwcTextListToTextProperty(
+ XLCd /* lcd */,
+ Display* /* dpy */,
+ wchar_t** /* list */,
+ int /* count */,
+ XICCEncodingStyle /* style */,
+ XTextProperty* /* text_prop */
+);
+
+extern int _Xutf8TextListToTextProperty(
+ XLCd /* lcd */,
+ Display* /* dpy */,
+ char** /* list */,
+ int /* count */,
+ XICCEncodingStyle /* style */,
+ XTextProperty* /* text_prop */
+);
+
+extern void _XwcFreeStringList(
+ XLCd /* lcd */,
+ wchar_t** /* list */
+);
+
+extern int _XlcResolveLocaleName(
+ const char* lc_name,
+ XLCdPublicPart* pub
+);
+
+extern int _XlcResolveI18NPath(
+ char* buf,
+ int buf_len
+);
+
+extern char *_XlcLocaleDirName(
+ char* /* dir_name */,
+ size_t, /* dir_len */
+ char* /* lc_name */
+);
+
+extern XPointer _XlcCreateLocaleDataBase(
+ XLCd lcd
+);
+
+extern void _XlcDestroyLocaleDataBase(
+ XLCd lcd
+);
+
+extern void _XlcGetLocaleDataBase(
+ XLCd /* lcd */,
+ const char* /* category */,
+ const char* /* name */,
+ char*** /* value */,
+ int* /* count */
+);
+
+#ifdef X_LOCALE
+extern char *
+_Xsetlocale(
+ int category,
+ _Xconst char *name);
+#else
+#ifdef __DARWIN__
+extern char *
+_Xsetlocale(
+ int category,
+ _Xconst char *name);
+#endif
+extern char *_XlcMapOSLocaleName(
+ char *osname,
+ char *siname);
+#endif
+
+extern int
+_Xmbstoutf8(
+ char *ustr,
+ const char *str,
+ int len);
+extern int
+_Xlcmbstoutf8(
+ XLCd lcd,
+ char *ustr,
+ const char *str,
+ int len);
+extern int
+_Xmbstowcs(
+ wchar_t *wstr,
+ char *str,
+ int len);
+extern int
+_Xlcwcstombs(
+ XLCd lcd,
+ char *str,
+ wchar_t *wstr,
+ int len);
+extern int
+_Xlcmbstowcs(
+ XLCd lcd,
+ wchar_t *wstr,
+ char *str,
+ int len);
+extern int
+_Xwcstombs(
+ char *str,
+ wchar_t *wstr,
+ int len);
+extern int
+_Xlcmbtowc(
+ XLCd lcd,
+ wchar_t *wstr,
+ char *str,
+ int len);
+extern int
+_Xlcwctomb(
+ XLCd lcd,
+ char *str,
+ wchar_t wc);
+
+
+
+extern XPointer
+_Utf8GetConvByName(
+ const char *name);
+
+_XFUNCPROTOEND
+
+#endif /* _XLCPUBLICI_H_ */
diff --git a/nx-X11/lib/X11/XlcPublic.h b/nx-X11/lib/X11/XlcPublic.h
new file mode 100644
index 000000000..27595d8a2
--- /dev/null
+++ b/nx-X11/lib/X11/XlcPublic.h
@@ -0,0 +1,326 @@
+/* $Xorg: XlcPublic.h,v 1.3 2000/08/17 19:45:06 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+/* $XFree86: xc/lib/X11/XlcPublic.h,v 1.11 2003/04/17 02:06:31 dawes Exp $ */
+/*
+ * Most of this API is documented in i18n/Framework.PS
+ */
+
+#ifndef _XLCPUBLIC_H_
+#define _XLCPUBLIC_H_
+
+#include "Xlcint.h"
+
+
+/*
+ * Character sets.
+ */
+
+/* Every character set has a "side". It denotes the range of byte values for
+ which the character set is responsible. This means that the character
+ set's encoded characters will only assumes bytes within the range, and
+ that the character set can be used simultaneously with another character
+ set responsible for a disjoint range. */
+typedef enum {
+ XlcUnknown,
+ XlcC0, /* responsible for values 0x00..0x1F */
+ XlcGL, /* responsible for values 0x00..0x7F or 0x20..0x7F */
+ XlcC1, /* responsible for values 0x80..0x9F */
+ XlcGR, /* responsible for values 0x80..0xFF or 0xA0..0xFF */
+ XlcGLGR, /* responsible for values 0x00..0xFF */
+ XlcOther, /* unused */
+ XlcNONE
+} XlcSide;
+
+/* Data read from XLC_LOCALE files.
+ XXX Apparently superseded by _XUDCGlyphRegion. */
+typedef struct _UDCArea {
+ unsigned long start;
+ unsigned long end;
+} UDCAreaRec, *UDCArea;
+
+/* Where the character set comes from. */
+typedef enum {
+ CSsrcUndef, /* unused */
+ CSsrcStd, /* defined in libX11 */
+ CSsrcXLC /* defined in an XLC_LOCALE file */
+} CSSrc;
+
+/* These are the supported properties of XlcCharSet. */
+#define XlcNCharSize "charSize"
+#define XlcNControlSequence "controlSequence"
+#define XlcNEncodingName "encodingName"
+#define XlcNName "name"
+#define XlcNSetSize "setSize"
+#define XlcNSide "side"
+
+/* This is the structure of an XlcCharSet.
+ Once allocated, they are never freed. */
+typedef struct _XlcCharSetRec {
+ /* Character set name, including side suffix */
+ const char *name;
+ XrmQuark xrm_name;
+
+ /* XLFD encoding name, no side suffix */
+ const char *encoding_name;
+ XrmQuark xrm_encoding_name;
+
+ /* Range for which the charset is responsible: XlcGL, XlcGR or XlcGLGR */
+ XlcSide side;
+
+ /* Number of bytes per character. 0 means a varying number (e.g. UTF-8) */
+ int char_size;
+ /* Classification of the character set according to ISO-2022 */
+ int set_size; /* e.g. 94 or 96 */
+ const char *ct_sequence; /* control sequence of CT */
+ /* (normally at most 4 bytes) */
+
+ /* for UDC */
+ Bool string_encoding;
+ UDCArea udc_area;
+ int udc_area_num;
+
+ /* Description source */
+ CSSrc source;
+} XlcCharSetRec, *XlcCharSet;
+
+_XFUNCPROTOBEGIN
+
+/* Returns the charset with the given name (including side suffix).
+ Returns NULL if not found. */
+extern XlcCharSet _XlcGetCharSet(
+ const char* name
+);
+
+/* Returns the charset with the given encoding (no side suffix) and
+ responsible for at least the given side (XlcGL or XlcGR).
+ Returns NULL if not found. */
+extern XlcCharSet _XlcGetCharSetWithSide(
+ const char* encoding_name,
+ XlcSide side
+);
+
+/* Registers an XlcCharSet in the list of character sets.
+ Returns True if successful. */
+extern Bool _XlcAddCharSet(
+ XlcCharSet charset
+);
+
+/* Retrieves a number of attributes of an XlcCharSet.
+ Return NULL if successful, otherwise the name of the first argument
+ specifiying a nonexistent attribute. */
+extern char *_XlcGetCSValues(
+ XlcCharSet charset,
+ ...
+);
+
+_XFUNCPROTOEND
+
+
+#define XlcNCodeset "codeset"
+#define XlcNDefaultString "defaultString"
+#define XlcNLanguage "language"
+#define XlcNMbCurMax "mbCurMax"
+#define XlcNStateDependentEncoding "stateDependentEncoding"
+#define XlcNTerritory "territory"
+
+typedef struct _FontScope {
+ unsigned long start;
+ unsigned long end;
+ unsigned long shift;
+ unsigned long shift_direction;
+} FontScopeRec, *FontScope;
+
+/*
+ * conversion methods
+ */
+
+typedef struct _XlcConvRec *XlcConv;
+
+typedef XlcConv (*XlcOpenConverterProc)(
+ XLCd from_lcd,
+ const char* from_type,
+ XLCd to_lcd,
+ const char* to_type
+);
+
+typedef void (*XlcCloseConverterProc)(
+ XlcConv /* conv */
+);
+
+typedef int (*XlcConvertProc)(
+ XlcConv /* conv */,
+ XPointer* /* from */,
+ int* /* from_left */,
+ XPointer* /* to */,
+ int* /* to_left */,
+ XPointer* /* args */,
+ int /* num_args */
+);
+
+typedef void (*XlcResetConverterProc)(
+ XlcConv /* conv */
+);
+
+typedef struct _XlcConvMethodsRec{
+ XlcCloseConverterProc close;
+ XlcConvertProc convert;
+ XlcResetConverterProc reset;
+} XlcConvMethodsRec, *XlcConvMethods;
+
+/*
+ * conversion data
+ */
+
+#define XlcNMultiByte "multiByte"
+#define XlcNWideChar "wideChar"
+#define XlcNCompoundText "compoundText"
+#define XlcNString "string"
+#define XlcNUtf8String "utf8String"
+#define XlcNCharSet "charSet"
+#define XlcNCTCharSet "CTcharSet"
+#define XlcNFontCharSet "FontCharSet"
+#define XlcNChar "char"
+#define XlcNUcsChar "UCSchar"
+
+typedef struct _XlcConvRec {
+ XlcConvMethods methods;
+ XPointer state;
+} XlcConvRec;
+
+
+_XFUNCPROTOBEGIN
+
+extern Bool _XInitOM(
+ XLCd /* lcd */
+);
+
+extern Bool _XInitIM(
+ XLCd /* lcd */
+);
+
+extern XIM _XimOpenIM(
+ XLCd /* lcd */,
+ Display * /* dpy */,
+ XrmDatabase /* rdb */,
+ char * /* res_name */,
+ char * /* res_class */
+);
+
+extern char *_XGetLCValues(
+ XLCd /* lcd */,
+ ...
+);
+
+extern XlcConv _XlcOpenConverter(
+ XLCd from_lcd,
+ const char* from_type,
+ XLCd to_lcd,
+ const char* to_type
+);
+
+extern void _XlcCloseConverter(
+ XlcConv conv
+);
+
+extern int _XlcConvert(
+ XlcConv conv,
+ XPointer* from,
+ int* from_left,
+ XPointer* to,
+ int* to_left,
+ XPointer* args,
+ int num_args
+);
+
+extern void _XlcResetConverter(
+ XlcConv conv
+);
+
+extern Bool _XlcSetConverter(
+ XLCd from_lcd,
+ const char* from_type,
+ XLCd to_lcd,
+ const char* to_type,
+ XlcOpenConverterProc open_converter
+);
+
+extern void _XlcGetResource(
+ XLCd lcd,
+ const char* category,
+ const char* _class,
+ char*** value,
+ int* count
+);
+
+extern char *_XlcFileName(
+ XLCd lcd,
+ const char* category
+);
+
+extern int _Xwcslen(
+ wchar_t* /* wstr */
+);
+
+extern wchar_t *_Xwcscpy(
+ wchar_t* /* wstr1 */,
+ wchar_t* /* wstr2 */
+);
+
+extern wchar_t *_Xwcsncpy(wchar_t *wstr1, wchar_t *wstr2, int len);
+extern int _Xwcscmp(wchar_t *wstr1, wchar_t *wstr2);
+extern int _Xwcsncmp(wchar_t *wstr1, wchar_t *wstr2, int len);
+
+/* Compares two ISO 8859-1 strings, ignoring case of ASCII letters.
+ Like strcasecmp in an ASCII locale. */
+extern int _XlcCompareISOLatin1(
+ const char* str1,
+ const char* str2
+);
+
+/* Compares two ISO 8859-1 strings, at most len bytes of each, ignoring
+ case of ASCII letters. Like strncasecmp in an ASCII locale. */
+extern int _XlcNCompareISOLatin1(
+ const char* str1,
+ const char* str2,
+ int len
+);
+
+extern XOM
+_XDefaultOpenOM(
+ XLCd lcd, Display *dpy, XrmDatabase rdb,
+ _Xconst char *res_name, _Xconst char *res_class);
+
+_XFUNCPROTOEND
+
+#endif /* _XLCPUBLIC_H_ */
diff --git a/nx-X11/lib/X11/XlcSL.c b/nx-X11/lib/X11/XlcSL.c
new file mode 100644
index 000000000..9e6b67f31
--- /dev/null
+++ b/nx-X11/lib/X11/XlcSL.c
@@ -0,0 +1,79 @@
+/*
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Portions Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions: 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 OR SUN MICROSYSTEMS, INC. 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 EVEN IF
+ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Except as contained in this notice, the names of The Open Group and/or
+Sun Microsystems, Inc. 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 and/or Sun Microsystems,
+Inc., as applicable.
+
+
+X Window System is a trademark of The Open Group
+
+OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
+logo, LBX, X Window System, and Xinerama are trademarks of the Open
+Group. All other trademarks and registered trademarks mentioned herein
+are the property of their respective owners. No right, title or
+interest in or to any trademark, service mark, logo or trade name of
+Sun Microsystems, Inc. or its licensors is granted.
+
+*/
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+extern XIM _XDefaultOpenIM(
+ XLCd, Display *, XrmDatabase, char *, char *
+ );
+
+Bool
+_XInitDefaultIM(lcd)
+XLCd lcd;
+{
+ if(lcd == (XLCd)NULL)
+ return False;
+
+ lcd->methods->open_im = _XDefaultOpenIM;
+ lcd->methods->register_callback = NULL;
+ lcd->methods->unregister_callback = NULL;
+ return True;
+}
+
+extern XOM _XDefaultOpenOM(
+ XLCd, Display*, XrmDatabase, _Xconst char*, _Xconst char*
+ );
+
+Bool
+_XInitDefaultOM(lcd)
+ XLCd lcd;
+{
+ lcd->methods->open_om = _XDefaultOpenOM;
+ return True;
+}
diff --git a/nx-X11/lib/X11/Xlcint.h b/nx-X11/lib/X11/Xlcint.h
new file mode 100644
index 000000000..fcc3a65f2
--- /dev/null
+++ b/nx-X11/lib/X11/Xlcint.h
@@ -0,0 +1,976 @@
+/* $Xorg: Xlcint.h,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/X11/Xlcint.h,v 3.16 2003/04/17 02:06:31 dawes Exp $ */
+
+/*
+ * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
+ * and Nippon Telegraph and Telephone Corporation
+ * Copyright 1991 by the Open Software Foundation
+ * Copyright 1993 by the TOSHIBA Corp.
+ * Copyright 1993, 1994 by Sony Corporation
+ * Copyright 1993, 1994 by the FUJITSU LIMITED
+ *
+ * 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 names of OMRON, NTT Software, NTT, Open
+ * Software Foundation, and Sony Corporation not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. OMRON, NTT Software, NTT, Open Software
+ * Foundation, and Sony Corporation make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * OMRON, NTT SOFTWARE, NTT, OPEN SOFTWARE FOUNDATION, AND SONY
+ * CORPORATION DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+ * SHALL OMRON, NTT SOFTWARE, NTT, OPEN SOFTWARE FOUNDATION, OR SONY
+ * CORPORATION 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.
+ *
+ * Authors: Li Yuhong OMRON Corporation
+ * Tatsuya Kato NTT Software Corporation
+ * Hiroshi Kuribayashi OMRON Coproration
+ * Muneiyoshi Suzuki Nippon Telegraph and Telephone Co.
+ *
+ * M. Collins OSF
+ * Katsuhisa Yano TOSHIBA Corp.
+ * Makoto Wakamatsu Sony Corporation
+ * Takashi Fujiwara FUJITSU LIMITED
+ */
+
+
+#ifndef _XLCINT_H_
+#define _XLCINT_H_
+
+#ifndef _XP_PRINT_SERVER_
+
+#include <X11/Xresource.h>
+#include <X11/Xutil.h>
+#include <stdarg.h>
+
+typedef Bool (*XFilterEventProc)(
+ Display* /* display */,
+ Window /* window */,
+ XEvent* /* event */,
+ XPointer /* client_data */
+);
+
+typedef struct _XIMFilter {
+ struct _XIMFilter *next;
+ Window window;
+ unsigned long event_mask;
+ int start_type, end_type;
+ XFilterEventProc filter;
+ XPointer client_data;
+} XFilterEventRec, *XFilterEventList;
+
+typedef struct {
+ char *name;
+ XPointer value;
+} XIMArg;
+
+#ifdef offsetof
+#define XOffsetOf(s_type,field) offsetof(s_type,field)
+#else
+#define XOffsetOf(s_type,field) ((unsigned int)&(((s_type*)NULL)->field))
+#endif
+
+#define XIMNumber(arr) ((unsigned int) (sizeof(arr) / sizeof(arr[0])))
+
+/*
+ * define secondary data structs which are part of Input Methods
+ * and Input Context
+ */
+typedef struct {
+ char *resource_name; /* Resource string */
+ XrmQuark xrm_name; /* Resource name quark */
+ int resource_size; /* Size in bytes of data */
+ long resource_offset; /* Offset from base */
+ unsigned short mode; /* Read Write Permission */
+ unsigned short id; /* Input Method Protocol */
+} XIMResource, *XIMResourceList;
+
+/*
+ * data block describing the visual attributes associated with
+ * an input context
+ */
+typedef struct {
+ XRectangle area;
+ XRectangle area_needed;
+ XPoint spot_location;
+ Colormap colormap;
+ Atom std_colormap;
+ unsigned long foreground;
+ unsigned long background;
+ Pixmap background_pixmap;
+ XFontSet fontset;
+ int line_spacing;
+ Cursor cursor;
+ XICCallback start_callback;
+ XICCallback done_callback;
+ XICCallback draw_callback;
+ XICCallback caret_callback;
+ XIMPreeditState preedit_state;
+ XICCallback state_notify_callback;
+} ICPreeditAttributes, *ICPreeditAttributesPtr;
+
+typedef struct {
+ XRectangle area;
+ XRectangle area_needed;
+ Colormap colormap;
+ Atom std_colormap;
+ unsigned long foreground;
+ unsigned long background;
+ Pixmap background_pixmap;
+ XFontSet fontset;
+ int line_spacing;
+ Cursor cursor;
+ XICCallback start_callback;
+ XICCallback done_callback;
+ XICCallback draw_callback;
+} ICStatusAttributes, *ICStatusAttributesPtr;
+
+#endif /* !_XP_PRINT_SERVER_ */
+
+/*
+ * Methods for Xrm parsing
+ */
+
+/* The state is a pointer to an object created by the locale's
+ init_parse_info function (default: _XrmDefaultInitParseInfo). */
+
+/* Sets the state to the initial state.
+ Initiates a sequence of calls to the XmbCharProc. */
+typedef void (*XmbInitProc)(
+ XPointer state
+);
+
+/* Transforms one multibyte character, starting at str, and return a 'char'
+ in the same parsing class (not a wide character!). Returns the number of
+ consumed bytes in *lenp. */
+typedef char (*XmbCharProc)(
+ XPointer state,
+ const char * str,
+ int* lenp
+);
+
+/* Terminates a sequence of calls to the XmbCharProc. */
+typedef void (*XmbFinishProc)(
+ XPointer state
+);
+
+/* Returns the name of the state's locale, as a static string. */
+typedef const char* (*XlcNameProc)(
+ XPointer state
+);
+
+/* Frees the state, which was allocated by the locale's init_parse_info
+ function. */
+typedef void (*XrmDestroyProc)(
+ XPointer state
+);
+
+/* Set of methods for Xrm parsing. */
+typedef struct {
+ XmbInitProc mbinit;
+ XmbCharProc mbchar;
+ XmbFinishProc mbfinish;
+ XlcNameProc lcname;
+ XrmDestroyProc destroy;
+} XrmMethodsRec;
+typedef const XrmMethodsRec *XrmMethods;
+
+#ifndef _XP_PRINT_SERVER_
+
+typedef struct _XLCd *XLCd; /* need forward reference */
+
+/*
+ * define an LC, it's methods, and data.
+ */
+
+typedef void (*XCloseLCProc)(
+ XLCd /* lcd */
+);
+
+typedef char* (*XlcMapModifiersProc)(
+ XLCd /* lcd */,
+ _Xconst char* /* user_mods */,
+ _Xconst char* /* prog_mods */
+);
+
+typedef XOM (*XOpenOMProc)(
+ XLCd /* lcd */,
+ Display* /* display */,
+ XrmDatabase /* rdb */,
+ _Xconst char* /* res_name */,
+ _Xconst char* /* res_class */
+);
+
+typedef XIM (*XOpenIMProc)(
+ XLCd /* lcd */,
+ Display* /* display */,
+ XrmDatabase /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */
+);
+
+typedef Bool (*XRegisterIMInstantiateCBProc)(
+ XLCd /* lcd */,
+ Display* /* display */,
+ XrmDatabase /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIDProc /* callback */,
+ XPointer /* client_data */
+);
+
+typedef Bool (*XUnregisterIMInstantiateCBProc)(
+ XLCd /* lcd */,
+ Display* /* display */,
+ XrmDatabase /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIDProc /* callback */,
+ XPointer /* client_data */
+);
+
+typedef XrmMethods (*XrmInitParseInfoProc)(
+ XLCd /* lcd */,
+ XPointer* /* state */
+);
+
+typedef int (*XmbTextPropertyToTextListProc)(
+ XLCd lcd,
+ Display* display,
+ const XTextProperty* text_prop,
+ char*** list_return,
+ int* count_return
+);
+
+typedef int (*XwcTextPropertyToTextListProc)(
+ XLCd lcd,
+ Display* display,
+ const XTextProperty* text_prop,
+ wchar_t*** list_return,
+ int* count_return
+);
+
+typedef int (*XmbTextListToTextPropertyProc)(
+ XLCd lcd,
+ Display* display,
+ char** list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty* text_prop_return
+);
+
+typedef int (*XwcTextListToTextPropertyProc)(
+ XLCd lcd,
+ Display* display,
+ wchar_t** list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty* text_prop_return
+);
+
+typedef void (*XwcFreeStringListProc)(
+ XLCd lcd,
+ wchar_t** list
+);
+
+typedef const char* (*XDefaultStringProc)(
+ XLCd lcd
+);
+
+typedef struct {
+ XCloseLCProc close;
+ XlcMapModifiersProc map_modifiers;
+ XOpenOMProc open_om;
+ XOpenIMProc open_im;
+ XrmInitParseInfoProc init_parse_info;
+ XmbTextPropertyToTextListProc mb_text_prop_to_list;
+ XwcTextPropertyToTextListProc wc_text_prop_to_list;
+ XmbTextPropertyToTextListProc utf8_text_prop_to_list;
+ XmbTextListToTextPropertyProc mb_text_list_to_prop;
+ XwcTextListToTextPropertyProc wc_text_list_to_prop;
+ XmbTextListToTextPropertyProc utf8_text_list_to_prop;
+ XwcFreeStringListProc wc_free_string_list;
+ XDefaultStringProc default_string;
+ XRegisterIMInstantiateCBProc register_callback;
+ XUnregisterIMInstantiateCBProc unregister_callback;
+} XLCdMethodsRec, *XLCdMethods;
+
+
+typedef struct {
+ char* name; /* name of this LC */
+ char* modifiers; /* modifiers of locale */
+} XLCdCoreRec, *XLCdCore;
+
+
+typedef struct _XLCd {
+ XLCdMethods methods; /* methods of this LC */
+ XLCdCore core; /* data of this LC */
+ XPointer opaque; /* LDX specific data */
+} XLCdRec;
+
+typedef int XlcPosition;
+
+#define XlcHead 0
+#define XlcTail -1
+
+typedef struct {
+ char *name;
+ XPointer value;
+} XlcArg, *XlcArgList;
+
+typedef struct _XlcResource {
+ char *name;
+ XrmQuark xrm_name;
+ int size;
+ int offset;
+ unsigned long mask;
+} XlcResource, *XlcResourceList;
+
+#define XlcCreateMask (1L<<0)
+#define XlcDefaultMask (1L<<1)
+#define XlcGetMask (1L<<2)
+#define XlcSetMask (1L<<3)
+#define XlcIgnoreMask (1L<<4)
+
+#define XlcNumber(arr) (sizeof(arr) / sizeof(arr[0]))
+
+typedef Status (*XCloseOMProc)(
+ XOM /* om */
+);
+
+typedef char* (*XSetOMValuesProc)(
+ XOM /* om */,
+ XlcArgList /* args */,
+ int /* num_args */
+);
+
+typedef char* (*XGetOMValuesProc)(
+ XOM /* om */,
+ XlcArgList /* args */,
+ int /* num_args */
+);
+
+typedef XOC (*XCreateOCProc)(
+ XOM /* om */,
+ XlcArgList /* args */,
+ int /* num_args */
+);
+
+typedef struct _XOMMethodsRec {
+ XCloseOMProc close;
+ XSetOMValuesProc set_values;
+ XGetOMValuesProc get_values;
+ XCreateOCProc create_oc;
+} XOMMethodsRec, *XOMMethods;
+
+typedef struct _XOMCoreRec {
+ XLCd lcd; /* lcd */
+ Display *display; /* display */
+ XrmDatabase rdb; /* database */
+ char *res_name; /* resource name */
+ char *res_class; /* resource class */
+ XOC oc_list; /* xoc list */
+ XlcResourceList resources; /* xom resources */
+ int num_resources; /* number of xom resources */
+ XOMCharSetList required_charset; /* required charset list */
+ XOMOrientation orientation_list; /* orientation list */
+ Bool directional_dependent; /* directional-dependent */
+ Bool contextual_drawing; /* contextual drawing */
+ Bool context_dependent; /* context-dependent drawing */
+} XOMCoreRec, *XOMCore;
+
+typedef struct _XOM {
+ XOMMethods methods;
+ XOMCoreRec core;
+} XOMRec;
+
+typedef void (*XDestroyOCProc)(
+ XOC /* oc */
+);
+
+typedef char* (*XSetOCValuesProc)(
+ XOC /* oc */,
+ XlcArgList /* args */,
+ int /* num_args */
+);
+
+typedef char* (*XGetOCValuesProc)(
+ XOC /* oc */,
+ XlcArgList /* args */,
+ int /* num_args */
+);
+
+/*
+ * X Font Sets are an instantiable object, so we define it, the
+ * object itself, a method list and data
+ */
+
+/*
+ * XFontSet object method list
+ */
+
+typedef int (*XmbTextEscapementProc)(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* text_len */
+);
+
+typedef int (*XmbTextExtentsProc)(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* text_len */,
+ XRectangle* /* overall_ink_extents */,
+ XRectangle* /* overall_logical_extents */
+);
+
+typedef Status (*XmbTextPerCharExtentsProc)(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* text_len */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* max_ink_extents */,
+ XRectangle* /* max_logical_extents */
+);
+
+typedef int (*XmbDrawStringProc)(
+ Display* /* display */,
+ Drawable /* drawable */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* text_len */
+);
+
+typedef void (*XmbDrawImageStringProc)(
+ Display* /* display */,
+ Drawable /* drawable */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* text_len */
+);
+
+typedef int (*XwcTextEscapementProc)(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* text_len */
+);
+
+typedef int (*XwcTextExtentsProc)(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* text_len */,
+ XRectangle* /* overall_ink_extents */,
+ XRectangle* /* overall_logical_extents */
+);
+
+typedef Status (*XwcTextPerCharExtentsProc)(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* text_len */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* max_ink_extents */,
+ XRectangle* /* max_logical_extents */
+);
+
+typedef int (*XwcDrawStringProc)(
+ Display* /* display */,
+ Drawable /* drawable */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* text_len */
+);
+
+typedef void (*XwcDrawImageStringProc)(
+ Display* /* display */,
+ Drawable /* drawable */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* text_len */
+);
+
+typedef struct {
+ XDestroyOCProc destroy;
+ XSetOCValuesProc set_values;
+ XGetOCValuesProc get_values;
+
+ /* multi-byte text drawing methods */
+
+ XmbTextEscapementProc mb_escapement;
+ XmbTextExtentsProc mb_extents;
+ XmbTextPerCharExtentsProc mb_extents_per_char;
+ XmbDrawStringProc mb_draw_string;
+ XmbDrawImageStringProc mb_draw_image_string;
+
+ /* wide character text drawing methods */
+
+ XwcTextEscapementProc wc_escapement;
+ XwcTextExtentsProc wc_extents;
+ XwcTextPerCharExtentsProc wc_extents_per_char;
+ XwcDrawStringProc wc_draw_string;
+ XwcDrawImageStringProc wc_draw_image_string;
+
+ /* UTF-8 text drawing methods */
+
+ XmbTextEscapementProc utf8_escapement;
+ XmbTextExtentsProc utf8_extents;
+ XmbTextPerCharExtentsProc utf8_extents_per_char;
+ XmbDrawStringProc utf8_draw_string;
+ XmbDrawImageStringProc utf8_draw_image_string;
+} XOCMethodsRec, *XOCMethods;
+
+
+/*
+ * XOC independent data
+ */
+
+typedef struct {
+ XOM om; /* XOM */
+ XOC next; /* next XOC */
+ XlcResourceList resources; /* xoc resources */
+ int num_resources; /* number of xoc resources */
+ char *base_name_list; /* base font name list */
+ Bool om_automatic; /* OM Automatic */
+ XOMFontInfo font_info; /* font info */
+ XFontSetExtents font_set_extents; /* font set extents */
+ char *default_string; /* default string */
+ XOMCharSetList missing_list; /* missing charset list */
+ XOrientation orientation; /* orientation */
+ char *res_name; /* resource name */
+ char *res_class; /* resource class */
+} XOCCoreRec, *XOCCore;
+
+typedef struct _XOC {
+ XOCMethods methods;
+ XOCCoreRec core;
+} XOCRec;
+
+
+/*
+ * X Input Managers are an instantiable object, so we define it, the
+ * object itself, a method list and data.
+ */
+
+/*
+ * an Input Manager object method list
+ */
+typedef struct {
+ Status (*close)(
+ XIM
+ );
+ char* (*set_values)(
+ XIM, XIMArg*
+ );
+ char* (*get_values)(
+ XIM, XIMArg*
+ );
+ XIC (*create_ic)(
+ XIM, XIMArg*
+ );
+ int (*ctstombs)(
+ XIM, char*, int, char*, int, Status *
+ );
+ int (*ctstowcs)(
+ XIM, char*, int, wchar_t*, int, Status *
+ );
+ int (*ctstoutf8)(
+ XIM, char*, int, char*, int, Status *
+ );
+} XIMMethodsRec, *XIMMethods;
+
+/*
+ * Input Manager LC independent data
+ */
+typedef struct {
+ XLCd lcd; /* LC of this input method */
+ XIC ic_chain; /* list of ICs for this IM */
+
+ Display * display; /* display */
+ XrmDatabase rdb;
+ char * res_name;
+ char * res_class;
+
+ XIMValuesList *im_values_list;
+ XIMValuesList *ic_values_list;
+ XIMStyles *styles;
+ XIMCallback destroy_callback;
+ char * im_name; /* XIMMODIFIER name */
+ XIMResourceList im_resources; /* compiled IM resource list */
+ unsigned int im_num_resources;
+ XIMResourceList ic_resources; /* compiled IC resource list */
+ unsigned int ic_num_resources;
+ Bool visible_position;
+} XIMCoreRec, *XIMCore;
+
+
+
+/*
+ * An X Input Manager (IM). Implementations may need to extend this data
+ * structure to accomodate additional data, state information etc.
+ */
+typedef struct _XIM {
+ XIMMethods methods; /* method list of this IM */
+ XIMCoreRec core; /* data of this IM */
+} XIMRec;
+
+
+
+/*
+ * X Input Contexts (IC) are an instantiable object, so we define it, the
+ * object itself, a method list and data for this object
+ */
+
+/*
+ * Input Context method list
+ */
+typedef struct {
+ void (*destroy)(
+ XIC
+ );
+ void (*set_focus)(
+ XIC
+ );
+ void (*unset_focus)(
+ XIC
+ );
+ char* (*set_values)(
+ XIC, XIMArg*
+ );
+ char* (*get_values)(
+ XIC, XIMArg*
+ );
+ char* (*mb_reset)(
+ XIC
+ );
+ wchar_t* (*wc_reset)(
+ XIC
+ );
+ char* (*utf8_reset)(
+ XIC
+ );
+ int (*mb_lookup_string)(
+ XIC, XKeyEvent*, char*, int, KeySym*, Status*
+ );
+ int (*wc_lookup_string)(
+ XIC, XKeyEvent*, wchar_t*, int, KeySym*, Status*
+ );
+ int (*utf8_lookup_string)(
+ XIC, XKeyEvent*, char*, int, KeySym*, Status*
+ );
+} XICMethodsRec, *XICMethods;
+
+
+/*
+ * Input Context LC independent data
+ */
+typedef struct {
+ XIM im; /* XIM this IC belongs too */
+ XIC next; /* linked list of ICs for IM */
+
+ Window client_window; /* window IM can use for */
+ /* display or subwindows */
+ XIMStyle input_style; /* IM's input style */
+ Window focus_window; /* where key events go */
+ unsigned long filter_events; /* event mask from IM */
+ XICCallback geometry_callback; /* client callback */
+ char * res_name;
+ char * res_class;
+
+ XICCallback destroy_callback;
+ XICCallback string_conversion_callback;
+ XIMStringConversionText string_conversion;
+ XIMResetState reset_state;
+ XIMHotKeyTriggers *hotkey;
+ XIMHotKeyState hotkey_state;
+
+ ICPreeditAttributes preedit_attr; /* visuals of preedit area */
+ ICStatusAttributes status_attr; /* visuals of status area */
+} XICCoreRec, *XICCore;
+
+
+/*
+ * an Input Context. Implementations may need to extend this data
+ * structure to accomodate additional data, state information etc.
+ */
+typedef struct _XIC {
+ XICMethods methods; /* method list of this IC */
+ XICCoreRec core; /* data of this IC */
+} XICRec;
+
+
+/* If the argument 'name' is appropriate for this loader, it instantiates an
+ XLCd object with appropriate locale methods and returns it. May return
+ NULL; in this case, the remaining loaders are tried. */
+typedef XLCd (*XLCdLoadProc)(
+ const char* name
+);
+
+_XFUNCPROTOBEGIN
+
+extern XLCd _XOpenLC(
+ char* name
+);
+
+extern void _XCloseLC(
+ XLCd lcd
+);
+
+extern XLCd _XlcCurrentLC (void);
+
+extern Bool _XlcValidModSyntax(
+ const char* mods,
+ const char* const * valid
+);
+
+extern char *_XlcDefaultMapModifiers(
+ XLCd lcd,
+ _Xconst char* user_mods,
+ _Xconst char* prog_mods
+);
+
+extern void _XIMCompileResourceList(
+ XIMResourceList /* res */,
+ unsigned int /* num_res */
+);
+
+extern void _XCopyToArg(
+ XPointer /* src */,
+ XPointer* /* dst */,
+ unsigned int /* size */
+);
+
+extern char ** _XParseBaseFontNameList(
+ char* /* str */,
+ int* /* num */
+);
+
+extern XrmMethods _XrmInitParseInfo(
+ XPointer* statep
+);
+
+extern void _XRegisterFilterByMask(
+ Display* /* dpy */,
+ Window /* window */,
+ unsigned long /* event_mask */,
+ Bool (*)(
+ Display* /* display */,
+ Window /* window */,
+ XEvent* /* event */,
+ XPointer /* client_data */
+ ) /* filter */,
+ XPointer /* client_data */
+);
+
+extern void _XRegisterFilterByType(
+ Display* /* dpy */,
+ Window /* window */,
+ int /* start_type */,
+ int /* end_type */,
+ Bool (*)(
+ Display* /* display */,
+ Window /* window */,
+ XEvent* /* event */,
+ XPointer /* client_data */
+ ) /* filter */,
+ XPointer /* client_data */
+);
+
+extern void _XUnregisterFilter(
+ Display* /* dpy */,
+ Window /* window */,
+ Bool (*)(
+ Display* /* display */,
+ Window /* window */,
+ XEvent* /* event */,
+ XPointer /* client_data */
+ ) /* filter */,
+ XPointer /* client_data */
+);
+
+extern void _XlcCountVaList(
+ va_list var,
+ int* count_return
+);
+
+extern void _XlcVaToArgList(
+ va_list var,
+ int count,
+ XlcArgList* args_return
+);
+
+
+extern void _XlcCopyFromArg(
+ char * src,
+ char * dst,
+ int size
+);
+
+extern void _XlcCopyToArg(
+ char * src,
+ char ** dst,
+ int size
+);
+
+extern void _XlcCompileResourceList(
+ XlcResourceList resources,
+ int num_resources
+);
+
+extern char *_XlcGetValues(
+ XPointer base,
+ XlcResourceList resources,
+ int num_resources,
+ XlcArgList args,
+ int num_args,
+ unsigned long mask
+);
+
+extern char *_XlcSetValues(
+ XPointer base,
+ XlcResourceList resources,
+ int num_resources,
+ XlcArgList args,
+ int num_args,
+ unsigned long mask
+);
+
+/* documented in i18n/Framework.PS */
+extern void _XlcInitLoader (void);
+
+extern void _XlcDeInitLoader (void);
+
+/* documented in i18n/Framework.PS */
+/* Returns True on success, False on failure. */
+extern Bool _XlcAddLoader(
+ XLCdLoadProc proc,
+ XlcPosition position
+);
+
+/* documented in i18n/Framework.PS */
+extern void _XlcRemoveLoader(
+ XLCdLoadProc proc
+);
+
+/* Registers UTF-8 converters for a non-UTF-8 locale. */
+extern void _XlcAddUtf8Converters(
+ XLCd lcd
+);
+
+/* Registers UTF-8 converters for a UTF-8 locale. */
+extern void _XlcAddUtf8LocaleConverters(
+ XLCd lcd
+);
+
+/* The default locale loader. Assumes an ASCII encoding. */
+extern XLCd _XlcDefaultLoader(
+ const char* name
+);
+
+/* The generic locale loader. Suitable for all encodings except UTF-8.
+ Uses an XLC_LOCALE configuration file. */
+extern XLCd _XlcGenericLoader(
+ const char* name
+);
+
+/* The UTF-8 locale loader. Suitable for UTF-8 encoding.
+ Uses an XLC_LOCALE configuration file. */
+extern XLCd _XlcUtf8Loader(
+ const char* name
+);
+
+/* The old EUC locale loader. */
+extern XLCd _XlcEucLoader(
+ const char* name
+);
+
+/* The old SJIS locale loader. */
+extern XLCd _XlcSjisLoader(
+ const char* name
+);
+
+/* The old ISO-2022-JP locale loader. */
+extern XLCd _XlcJisLoader(
+ const char* name
+);
+
+extern XLCd _XlcDynamicLoad(
+ const char* name
+);
+
+/* The old dynamic loader. */
+extern XLCd _XlcDynamicLoader(
+ const char* name
+);
+
+extern Bool _XInitDefaultIM(
+ XLCd lcd
+);
+
+extern Bool _XInitDefaultOM(
+ XLCd lcd
+);
+
+extern Bool _XInitDynamicIM(
+ XLCd lcd
+);
+
+extern Bool _XInitDynamicOM(
+ XLCd lcd
+);
+
+_XFUNCPROTOEND
+
+#endif /* !_XP_PRINT_SERVER_ */
+
+#endif /* _XLCINT_H_ */
diff --git a/nx-X11/lib/X11/Xlib.h b/nx-X11/lib/X11/Xlib.h
new file mode 100644
index 000000000..e21d9ffac
--- /dev/null
+++ b/nx-X11/lib/X11/Xlib.h
@@ -0,0 +1,4029 @@
+/* $XdotOrg: xc/lib/X11/Xlib.h,v 1.6 2005/11/08 06:33:25 jkj Exp $ */
+/* $Xorg: Xlib.h,v 1.6 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1986, 1987, 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.
+
+*/
+/* $XFree86: xc/lib/X11/Xlib.h,v 3.25 2003/11/17 22:20:10 dawes Exp $ */
+
+
+/*
+ * Xlib.h - Header definition and support file for the C subroutine
+ * interface library (Xlib) to the X Window System Protocol (V11).
+ * Structures and symbols starting with "_" are private to the library.
+ */
+#ifndef _XLIB_H_
+#define _XLIB_H_
+
+#define XlibSpecificationRelease 6
+
+#ifdef USG
+#ifndef __TYPES__
+#include <sys/types.h> /* forgot to protect it... */
+#define __TYPES__
+#endif /* __TYPES__ */
+#else
+#if defined(_POSIX_SOURCE) && defined(MOTOROLA)
+#undef _POSIX_SOURCE
+#include <sys/types.h>
+#define _POSIX_SOURCE
+#else
+#include <sys/types.h>
+#endif
+#endif /* USG */
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#include <stdint.h>
+#endif
+
+#include <X11/X.h>
+
+/* applications should not depend on these two headers being included! */
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+
+#ifndef X_WCHAR
+#ifdef X_NOT_STDC_ENV
+#ifndef ISC
+#define X_WCHAR
+#endif
+#endif
+#endif
+
+#ifndef X_WCHAR
+#include <stddef.h>
+#else
+#ifdef __UNIXOS2__
+#include <stdlib.h>
+#else
+/* replace this with #include or typedef appropriate for your system */
+typedef unsigned long wchar_t;
+#endif
+#endif
+
+#if defined(ISC) && defined(USE_XMBTOWC)
+#define wctomb(a,b) _Xwctomb(a,b)
+#define mblen(a,b) _Xmblen(a,b)
+#ifndef USE_XWCHAR_STRING
+#define mbtowc(a,b,c) _Xmbtowc(a,b,c)
+#endif
+#endif
+
+extern int
+_Xmblen(
+#ifdef ISC
+ char const *str,
+ size_t len
+#else
+ char *str,
+ int len
+#endif
+ );
+
+/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in
+ November 2000. Its presence is indicated through the following macro. */
+#define X_HAVE_UTF8_STRING 1
+
+typedef char *XPointer;
+
+#define Bool int
+#define Status int
+#define True 1
+#define False 0
+
+#define QueuedAlready 0
+#define QueuedAfterReading 1
+#define QueuedAfterFlush 2
+
+#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd)
+#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root)
+#define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen)
+#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root)
+#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual)
+#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc)
+#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel)
+#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel)
+#define AllPlanes ((unsigned long)~0L)
+#define QLength(dpy) (((_XPrivDisplay)dpy)->qlen)
+#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width)
+#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height)
+#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth)
+#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight)
+#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
+#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries)
+#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens)
+#define ServerVendor(dpy) (((_XPrivDisplay)dpy)->vendor)
+#define ProtocolVersion(dpy) (((_XPrivDisplay)dpy)->proto_major_version)
+#define ProtocolRevision(dpy) (((_XPrivDisplay)dpy)->proto_minor_version)
+#define VendorRelease(dpy) (((_XPrivDisplay)dpy)->release)
+#define DisplayString(dpy) (((_XPrivDisplay)dpy)->display_name)
+#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
+#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap)
+#define BitmapUnit(dpy) (((_XPrivDisplay)dpy)->bitmap_unit)
+#define BitmapBitOrder(dpy) (((_XPrivDisplay)dpy)->bitmap_bit_order)
+#define BitmapPad(dpy) (((_XPrivDisplay)dpy)->bitmap_pad)
+#define ImageByteOrder(dpy) (((_XPrivDisplay)dpy)->byte_order)
+#ifdef CRAY /* unable to get WORD64 without pulling in other symbols */
+#define NextRequest(dpy) XNextRequest(dpy)
+#else
+#define NextRequest(dpy) (((_XPrivDisplay)dpy)->request + 1)
+#endif
+#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)dpy)->last_request_read)
+
+/* macros for screen oriented applications (toolkit) */
+#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr])
+#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy))
+#define DisplayOfScreen(s) ((s)->display)
+#define RootWindowOfScreen(s) ((s)->root)
+#define BlackPixelOfScreen(s) ((s)->black_pixel)
+#define WhitePixelOfScreen(s) ((s)->white_pixel)
+#define DefaultColormapOfScreen(s)((s)->cmap)
+#define DefaultDepthOfScreen(s) ((s)->root_depth)
+#define DefaultGCOfScreen(s) ((s)->default_gc)
+#define DefaultVisualOfScreen(s)((s)->root_visual)
+#define WidthOfScreen(s) ((s)->width)
+#define HeightOfScreen(s) ((s)->height)
+#define WidthMMOfScreen(s) ((s)->mwidth)
+#define HeightMMOfScreen(s) ((s)->mheight)
+#define PlanesOfScreen(s) ((s)->root_depth)
+#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries)
+#define MinCmapsOfScreen(s) ((s)->min_maps)
+#define MaxCmapsOfScreen(s) ((s)->max_maps)
+#define DoesSaveUnders(s) ((s)->save_unders)
+#define DoesBackingStore(s) ((s)->backing_store)
+#define EventMaskOfScreen(s) ((s)->root_input_mask)
+
+/*
+ * Extensions need a way to hang private data on some structures.
+ */
+typedef struct _XExtData {
+ int number; /* number returned by XRegisterExtension */
+ struct _XExtData *next; /* next item on list of data for structure */
+ int (*free_private)( /* called to free private storage */
+ struct _XExtData *extension
+ );
+ XPointer private_data; /* data private to this extension. */
+} XExtData;
+
+/*
+ * This file contains structures used by the extension mechanism.
+ */
+typedef struct { /* public to extension, cannot be changed */
+ int extension; /* extension number */
+ int major_opcode; /* major op-code assigned by server */
+ int first_event; /* first event number for the extension */
+ int first_error; /* first error number for the extension */
+} XExtCodes;
+
+/*
+ * Data structure for retrieving info about pixmap formats.
+ */
+
+typedef struct {
+ int depth;
+ int bits_per_pixel;
+ int scanline_pad;
+} XPixmapFormatValues;
+
+
+/*
+ * Data structure for setting graphics context.
+ */
+typedef struct {
+ int function; /* logical operation */
+ unsigned long plane_mask;/* plane mask */
+ unsigned long foreground;/* foreground pixel */
+ unsigned long background;/* background pixel */
+ int line_width; /* line width */
+ int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */
+ int cap_style; /* CapNotLast, CapButt,
+ CapRound, CapProjecting */
+ int join_style; /* JoinMiter, JoinRound, JoinBevel */
+ int fill_style; /* FillSolid, FillTiled,
+ FillStippled, FillOpaeueStippled */
+ int fill_rule; /* EvenOddRule, WindingRule */
+ int arc_mode; /* ArcChord, ArcPieSlice */
+ Pixmap tile; /* tile pixmap for tiling operations */
+ Pixmap stipple; /* stipple 1 plane pixmap for stipping */
+ int ts_x_origin; /* offset for tile or stipple operations */
+ int ts_y_origin;
+ Font font; /* default text font for text operations */
+ int subwindow_mode; /* ClipByChildren, IncludeInferiors */
+ Bool graphics_exposures;/* boolean, should exposures be generated */
+ int clip_x_origin; /* origin for clipping */
+ int clip_y_origin;
+ Pixmap clip_mask; /* bitmap clipping; other calls for rects */
+ int dash_offset; /* patterned/dashed line information */
+ char dashes;
+} XGCValues;
+
+/*
+ * Graphics context. The contents of this structure are implementation
+ * dependent. A GC should be treated as opaque by application code.
+ */
+
+typedef struct _XGC
+#ifdef XLIB_ILLEGAL_ACCESS
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ GContext gid; /* protocol ID for graphics context */
+ /* there is more to this structure, but it is private to Xlib */
+}
+#endif
+*GC;
+
+/*
+ * Visual structure; contains information about colormapping possible.
+ */
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ VisualID visualid; /* visual id of this visual */
+#if defined(__cplusplus) || defined(c_plusplus)
+ int c_class; /* C++ class of screen (monochrome, etc.) */
+#else
+ int class; /* class of screen (monochrome, etc.) */
+#endif
+ unsigned long red_mask, green_mask, blue_mask; /* mask values */
+ int bits_per_rgb; /* log base 2 of distinct color values */
+ int map_entries; /* color map entries */
+} Visual;
+
+/*
+ * Depth structure; contains information for each possible depth.
+ */
+typedef struct {
+ int depth; /* this depth (Z) of the depth */
+ int nvisuals; /* number of Visual types at this depth */
+ Visual *visuals; /* list of visuals possible at this depth */
+} Depth;
+
+/*
+ * Information about the screen. The contents of this structure are
+ * implementation dependent. A Screen should be treated as opaque
+ * by application code.
+ */
+
+struct _XDisplay; /* Forward declare before use for C++ */
+
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XDisplay *display;/* back pointer to display structure */
+ Window root; /* Root window id. */
+ int width, height; /* width and height of screen */
+ int mwidth, mheight; /* width and height of in millimeters */
+ int ndepths; /* number of depths possible */
+ Depth *depths; /* list of allowable depths on the screen */
+ int root_depth; /* bits per pixel */
+ Visual *root_visual; /* root visual */
+ GC default_gc; /* GC for the root root visual */
+ Colormap cmap; /* default color map */
+ unsigned long white_pixel;
+ unsigned long black_pixel; /* White and Black pixel values */
+ int max_maps, min_maps; /* max and min color maps */
+ int backing_store; /* Never, WhenMapped, Always */
+ Bool save_unders;
+ long root_input_mask; /* initial root input mask */
+} Screen;
+
+/*
+ * Format structure; describes ZFormat data the screen will understand.
+ */
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ int depth; /* depth of this image format */
+ int bits_per_pixel; /* bits/pixel at this depth */
+ int scanline_pad; /* scanline must padded to this multiple */
+} ScreenFormat;
+
+/*
+ * Data structure for setting window attributes.
+ */
+typedef struct {
+ Pixmap background_pixmap; /* background or None or ParentRelative */
+ unsigned long background_pixel; /* background pixel */
+ Pixmap border_pixmap; /* border of the window */
+ unsigned long border_pixel; /* border pixel value */
+ int bit_gravity; /* one of bit gravity values */
+ int win_gravity; /* one of the window gravity values */
+ int backing_store; /* NotUseful, WhenMapped, Always */
+ unsigned long backing_planes;/* planes to be preseved if possible */
+ unsigned long backing_pixel;/* value to use in restoring planes */
+ Bool save_under; /* should bits under be saved? (popups) */
+ long event_mask; /* set of events that should be saved */
+ long do_not_propagate_mask; /* set of events that should not propagate */
+ Bool override_redirect; /* boolean value for override-redirect */
+ Colormap colormap; /* color map to be associated with window */
+ Cursor cursor; /* cursor to be displayed (or None) */
+} XSetWindowAttributes;
+
+typedef struct {
+ int x, y; /* location of window */
+ int width, height; /* width and height of window */
+ int border_width; /* border width of window */
+ int depth; /* depth of window */
+ Visual *visual; /* the associated visual structure */
+ Window root; /* root of screen containing window */
+#if defined(__cplusplus) || defined(c_plusplus)
+ int c_class; /* C++ InputOutput, InputOnly*/
+#else
+ int class; /* InputOutput, InputOnly*/
+#endif
+ int bit_gravity; /* one of bit gravity values */
+ int win_gravity; /* one of the window gravity values */
+ int backing_store; /* NotUseful, WhenMapped, Always */
+ unsigned long backing_planes;/* planes to be preserved if possible */
+ unsigned long backing_pixel;/* value to be used when restoring planes */
+ Bool save_under; /* boolean, should bits under be saved? */
+ Colormap colormap; /* color map to be associated with window */
+ Bool map_installed; /* boolean, is color map currently installed*/
+ int map_state; /* IsUnmapped, IsUnviewable, IsViewable */
+ long all_event_masks; /* set of events all people have interest in*/
+ long your_event_mask; /* my event mask */
+ long do_not_propagate_mask; /* set of events that should not propagate */
+ Bool override_redirect; /* boolean value for override-redirect */
+ Screen *screen; /* back pointer to correct screen */
+} XWindowAttributes;
+
+/*
+ * Data structure for host setting; getting routines.
+ *
+ */
+
+typedef struct {
+ int family; /* for example FamilyInternet */
+ int length; /* length of address, in bytes */
+ char *address; /* pointer to where to find the bytes */
+} XHostAddress;
+
+/*
+ * Data structure for ServerFamilyInterpreted addresses in host routines
+ */
+typedef struct {
+ int typelength; /* length of type string, in bytes */
+ int valuelength; /* length of value string, in bytes */
+ char *type; /* pointer to where to find the type string */
+ char *value; /* pointer to where to find the address */
+} XServerInterpretedAddress;
+
+/*
+ * Data structure for "image" data, used by image manipulation routines.
+ */
+typedef struct _XImage {
+ int width, height; /* size of image */
+ int xoffset; /* number of pixels offset in X direction */
+ int format; /* XYBitmap, XYPixmap, ZPixmap */
+ char *data; /* pointer to image data */
+ int byte_order; /* data byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* quant. of scanline 8, 16, 32 */
+ int bitmap_bit_order; /* LSBFirst, MSBFirst */
+ int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */
+ int depth; /* depth of image */
+ int bytes_per_line; /* accelarator to next line */
+ int bits_per_pixel; /* bits per pixel (ZPixmap) */
+ unsigned long red_mask; /* bits in z arrangment */
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ XPointer obdata; /* hook for the object routines to hang on */
+ struct funcs { /* image manipulation routines */
+ struct _XImage *(*create_image)(
+ struct _XDisplay* /* display */,
+ Visual* /* visual */,
+ unsigned int /* depth */,
+ int /* format */,
+ int /* offset */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* bitmap_pad */,
+ int /* bytes_per_line */);
+ int (*destroy_image) (struct _XImage *);
+ unsigned long (*get_pixel) (struct _XImage *, int, int);
+ int (*put_pixel) (struct _XImage *, int, int, unsigned long);
+ struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int);
+ int (*add_pixel) (struct _XImage *, long);
+ } f;
+} XImage;
+
+/*
+ * Data structure for XReconfigureWindow
+ */
+typedef struct {
+ int x, y;
+ int width, height;
+ int border_width;
+ Window sibling;
+ int stack_mode;
+} XWindowChanges;
+
+/*
+ * Data structure used by color operations
+ */
+typedef struct {
+ unsigned long pixel;
+ unsigned short red, green, blue;
+ char flags; /* do_red, do_green, do_blue */
+ char pad;
+} XColor;
+
+/*
+ * Data structures for graphics operations. On most machines, these are
+ * congruent with the wire protocol structures, so reformatting the data
+ * can be avoided on these architectures.
+ */
+typedef struct {
+ short x1, y1, x2, y2;
+} XSegment;
+
+typedef struct {
+ short x, y;
+} XPoint;
+
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+} XRectangle;
+
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+ short angle1, angle2;
+} XArc;
+
+
+/* Data structure for XChangeKeyboardControl */
+
+typedef struct {
+ int key_click_percent;
+ int bell_percent;
+ int bell_pitch;
+ int bell_duration;
+ int led;
+ int led_mode;
+ int key;
+ int auto_repeat_mode; /* On, Off, Default */
+} XKeyboardControl;
+
+/* Data structure for XGetKeyboardControl */
+
+typedef struct {
+ int key_click_percent;
+ int bell_percent;
+ unsigned int bell_pitch, bell_duration;
+ unsigned long led_mask;
+ int global_auto_repeat;
+ char auto_repeats[32];
+} XKeyboardState;
+
+/* Data structure for XGetMotionEvents. */
+
+typedef struct {
+ Time time;
+ short x, y;
+} XTimeCoord;
+
+/* Data structure for X{Set,Get}ModifierMapping */
+
+typedef struct {
+ int max_keypermod; /* The server's max # of keys per modifier */
+ KeyCode *modifiermap; /* An 8 by max_keypermod array of modifiers */
+} XModifierKeymap;
+
+
+/*
+ * Display datatype maintaining display specific data.
+ * The contents of this structure are implementation dependent.
+ * A Display should be treated as opaque by application code.
+ */
+#ifndef XLIB_ILLEGAL_ACCESS
+typedef struct _XDisplay Display;
+#endif
+
+struct _XPrivate; /* Forward declare before use for C++ */
+struct _XrmHashBucketRec;
+
+typedef struct
+#ifdef XLIB_ILLEGAL_ACCESS
+_XDisplay
+#endif
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XPrivate *private1;
+ int fd; /* Network socket. */
+ int private2;
+ int proto_major_version;/* major version of server's X protocol */
+ int proto_minor_version;/* minor version of servers X protocol */
+ char *vendor; /* vendor of the server hardware */
+ XID private3;
+ XID private4;
+ XID private5;
+ int private6;
+ XID (*resource_alloc)( /* allocator function */
+ struct _XDisplay*
+ );
+ int byte_order; /* screen byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* padding and data requirements */
+ int bitmap_pad; /* padding requirements on bitmaps */
+ int bitmap_bit_order; /* LeastSignificant or MostSignificant */
+ int nformats; /* number of pixmap formats in list */
+ ScreenFormat *pixmap_format; /* pixmap format list */
+ int private8;
+ int release; /* release of the server */
+ struct _XPrivate *private9, *private10;
+ int qlen; /* Length of input event queue */
+ unsigned long last_request_read; /* seq number of last event read */
+ unsigned long request; /* sequence number of last request. */
+ XPointer private11;
+ XPointer private12;
+ XPointer private13;
+ XPointer private14;
+ unsigned max_request_size; /* maximum number 32 bit words in request*/
+ struct _XrmHashBucketRec *db;
+ int (*private15)(
+ struct _XDisplay*
+ );
+ char *display_name; /* "host:display" string used on this connect*/
+ int default_screen; /* default screen for operations */
+ int nscreens; /* number of screens on this server*/
+ Screen *screens; /* pointer to list of screens */
+ unsigned long motion_buffer; /* size of motion buffer */
+ unsigned long private16;
+ int min_keycode; /* minimum defined keycode */
+ int max_keycode; /* maximum defined keycode */
+ XPointer private17;
+ XPointer private18;
+ int private19;
+ char *xdefaults; /* contents of defaults from server */
+ /* there is more to this structure, but it is private to Xlib */
+}
+#ifdef XLIB_ILLEGAL_ACCESS
+Display,
+#endif
+*_XPrivDisplay;
+
+#undef _XEVENT_
+#ifndef _XEVENT_
+/*
+ * Definitions of specific events.
+ */
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window it is reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ unsigned int keycode; /* detail */
+ Bool same_screen; /* same screen flag */
+} XKeyEvent;
+typedef XKeyEvent XKeyPressedEvent;
+typedef XKeyEvent XKeyReleasedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window it is reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ unsigned int button; /* detail */
+ Bool same_screen; /* same screen flag */
+} XButtonEvent;
+typedef XButtonEvent XButtonPressedEvent;
+typedef XButtonEvent XButtonReleasedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ char is_hint; /* detail */
+ Bool same_screen; /* same screen flag */
+} XMotionEvent;
+typedef XMotionEvent XPointerMovedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */
+ int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear,NotifyNonlinearVirtual
+ */
+ Bool same_screen; /* same screen flag */
+ Bool focus; /* boolean focus */
+ unsigned int state; /* key or button mask */
+} XCrossingEvent;
+typedef XCrossingEvent XEnterWindowEvent;
+typedef XCrossingEvent XLeaveWindowEvent;
+
+typedef struct {
+ int type; /* FocusIn or FocusOut */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* window of event */
+ int mode; /* NotifyNormal, NotifyWhileGrabbed,
+ NotifyGrab, NotifyUngrab */
+ int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
+ * NotifyPointerRoot, NotifyDetailNone
+ */
+} XFocusChangeEvent;
+typedef XFocusChangeEvent XFocusInEvent;
+typedef XFocusChangeEvent XFocusOutEvent;
+
+/* generated on EnterWindow and FocusIn when KeyMapState selected */
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ char key_vector[32];
+} XKeymapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int x, y;
+ int width, height;
+ int count; /* if non-zero, at least this many more */
+} XExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable;
+ int x, y;
+ int width, height;
+ int count; /* if non-zero, at least this many more */
+ int major_code; /* core is CopyArea or CopyPlane */
+ int minor_code; /* not defined in the core */
+} XGraphicsExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable;
+ int major_code; /* core is CopyArea or CopyPlane */
+ int minor_code; /* not defined in the core */
+} XNoExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int state; /* Visibility state */
+} XVisibilityEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent; /* parent of the window */
+ Window window; /* window id of window created */
+ int x, y; /* window location */
+ int width, height; /* size of window */
+ int border_width; /* border width */
+ Bool override_redirect; /* creation should be overridden */
+} XCreateWindowEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+} XDestroyWindowEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Bool from_configure;
+} XUnmapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Bool override_redirect; /* boolean, is override set... */
+} XMapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+} XMapRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Window parent;
+ int x, y;
+ Bool override_redirect;
+} XReparentEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int x, y;
+ int width, height;
+ int border_width;
+ Window above;
+ Bool override_redirect;
+} XConfigureEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int x, y;
+} XGravityEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int width, height;
+} XResizeRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+ int x, y;
+ int width, height;
+ int border_width;
+ Window above;
+ int detail; /* Above, Below, TopIf, BottomIf, Opposite */
+ unsigned long value_mask;
+} XConfigureRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int place; /* PlaceOnTop, PlaceOnBottom */
+} XCirculateEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+ int place; /* PlaceOnTop, PlaceOnBottom */
+} XCirculateRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom atom;
+ Time time;
+ int state; /* NewValue, Deleted */
+} XPropertyEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom selection;
+ Time time;
+} XSelectionClearEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window owner;
+ Window requestor;
+ Atom selection;
+ Atom target;
+ Atom property;
+ Time time;
+} XSelectionRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window requestor;
+ Atom selection;
+ Atom target;
+ Atom property; /* ATOM or None */
+ Time time;
+} XSelectionEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Colormap colormap; /* COLORMAP or None */
+#if defined(__cplusplus) || defined(c_plusplus)
+ Bool c_new; /* C++ */
+#else
+ Bool new;
+#endif
+ int state; /* ColormapInstalled, ColormapUninstalled */
+} XColormapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom message_type;
+ int format;
+ union {
+ char b[20];
+ short s[10];
+ long l[5];
+ } data;
+} XClientMessageEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* unused */
+ int request; /* one of MappingModifier, MappingKeyboard,
+ MappingPointer */
+ int first_keycode; /* first keycode */
+ int count; /* defines range of change w. first_keycode*/
+} XMappingEvent;
+
+typedef struct {
+ int type;
+ Display *display; /* Display the event was read from */
+ XID resourceid; /* resource id */
+ unsigned long serial; /* serial number of failed request */
+ unsigned char error_code; /* error code of failed request */
+ unsigned char request_code; /* Major op-code of failed request */
+ unsigned char minor_code; /* Minor op-code of failed request */
+} XErrorEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display;/* Display the event was read from */
+ Window window; /* window on which event was requested in event mask */
+} XAnyEvent;
+
+/*
+ * this union is defined so Xlib can always use the same sized
+ * event structure internally, to avoid memory fragmentation.
+ */
+typedef union _XEvent {
+ int type; /* must not be changed; first element */
+ XAnyEvent xany;
+ XKeyEvent xkey;
+ XButtonEvent xbutton;
+ XMotionEvent xmotion;
+ XCrossingEvent xcrossing;
+ XFocusChangeEvent xfocus;
+ XExposeEvent xexpose;
+ XGraphicsExposeEvent xgraphicsexpose;
+ XNoExposeEvent xnoexpose;
+ XVisibilityEvent xvisibility;
+ XCreateWindowEvent xcreatewindow;
+ XDestroyWindowEvent xdestroywindow;
+ XUnmapEvent xunmap;
+ XMapEvent xmap;
+ XMapRequestEvent xmaprequest;
+ XReparentEvent xreparent;
+ XConfigureEvent xconfigure;
+ XGravityEvent xgravity;
+ XResizeRequestEvent xresizerequest;
+ XConfigureRequestEvent xconfigurerequest;
+ XCirculateEvent xcirculate;
+ XCirculateRequestEvent xcirculaterequest;
+ XPropertyEvent xproperty;
+ XSelectionClearEvent xselectionclear;
+ XSelectionRequestEvent xselectionrequest;
+ XSelectionEvent xselection;
+ XColormapEvent xcolormap;
+ XClientMessageEvent xclient;
+ XMappingEvent xmapping;
+ XErrorEvent xerror;
+ XKeymapEvent xkeymap;
+ long pad[24];
+} XEvent;
+#endif
+
+#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy)))
+
+/*
+ * per character font metric information.
+ */
+typedef struct {
+ short lbearing; /* origin to left edge of raster */
+ short rbearing; /* origin to right edge of raster */
+ short width; /* advance to next char's origin */
+ short ascent; /* baseline to top edge of raster */
+ short descent; /* baseline to bottom edge of raster */
+ unsigned short attributes; /* per char flags (not predefined) */
+} XCharStruct;
+
+/*
+ * To allow arbitrary information with fonts, there are additional properties
+ * returned.
+ */
+typedef struct {
+ Atom name;
+ unsigned long card32;
+} XFontProp;
+
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ Font fid; /* Font id for this font */
+ unsigned direction; /* hint about direction the font is painted */
+ unsigned min_char_or_byte2;/* first character */
+ unsigned max_char_or_byte2;/* last character */
+ unsigned min_byte1; /* first row that exists */
+ unsigned max_byte1; /* last row that exists */
+ Bool all_chars_exist;/* flag if all characters have non-zero size*/
+ unsigned default_char; /* char to print for undefined character */
+ int n_properties; /* how many properties there are */
+ XFontProp *properties; /* pointer to array of additional properties*/
+ XCharStruct min_bounds; /* minimum bounds over all existing char*/
+ XCharStruct max_bounds; /* maximum bounds over all existing char*/
+ XCharStruct *per_char; /* first_char to last_char information */
+ int ascent; /* log. extent above baseline for spacing */
+ int descent; /* log. descent below baseline for spacing */
+} XFontStruct;
+
+/*
+ * PolyText routines take these as arguments.
+ */
+typedef struct {
+ char *chars; /* pointer to string */
+ int nchars; /* number of characters */
+ int delta; /* delta between strings */
+ Font font; /* font to print it in, None don't change */
+} XTextItem;
+
+typedef struct { /* normal 16 bit characters are two bytes */
+ unsigned char byte1;
+ unsigned char byte2;
+} XChar2b;
+
+typedef struct {
+ XChar2b *chars; /* two byte characters */
+ int nchars; /* number of characters */
+ int delta; /* delta between strings */
+ Font font; /* font to print it in, None don't change */
+} XTextItem16;
+
+
+typedef union { Display *display;
+ GC gc;
+ Visual *visual;
+ Screen *screen;
+ ScreenFormat *pixmap_format;
+ XFontStruct *font; } XEDataObject;
+
+typedef struct {
+ XRectangle max_ink_extent;
+ XRectangle max_logical_extent;
+} XFontSetExtents;
+
+/* unused:
+typedef void (*XOMProc)();
+ */
+
+typedef struct _XOM *XOM;
+typedef struct _XOC *XOC, *XFontSet;
+
+typedef struct {
+ char *chars;
+ int nchars;
+ int delta;
+ XFontSet font_set;
+} XmbTextItem;
+
+typedef struct {
+ wchar_t *chars;
+ int nchars;
+ int delta;
+ XFontSet font_set;
+} XwcTextItem;
+
+#define XNRequiredCharSet "requiredCharSet"
+#define XNQueryOrientation "queryOrientation"
+#define XNBaseFontName "baseFontName"
+#define XNOMAutomatic "omAutomatic"
+#define XNMissingCharSet "missingCharSet"
+#define XNDefaultString "defaultString"
+#define XNOrientation "orientation"
+#define XNDirectionalDependentDrawing "directionalDependentDrawing"
+#define XNContextualDrawing "contextualDrawing"
+#define XNFontInfo "fontInfo"
+
+typedef struct {
+ int charset_count;
+ char **charset_list;
+} XOMCharSetList;
+
+typedef enum {
+ XOMOrientation_LTR_TTB,
+ XOMOrientation_RTL_TTB,
+ XOMOrientation_TTB_LTR,
+ XOMOrientation_TTB_RTL,
+ XOMOrientation_Context
+} XOrientation;
+
+typedef struct {
+ int num_orientation;
+ XOrientation *orientation; /* Input Text description */
+} XOMOrientation;
+
+typedef struct {
+ int num_font;
+ XFontStruct **font_struct_list;
+ char **font_name_list;
+} XOMFontInfo;
+
+typedef struct _XIM *XIM;
+typedef struct _XIC *XIC;
+
+typedef void (*XIMProc)(
+ XIM,
+ XPointer,
+ XPointer
+);
+
+typedef Bool (*XICProc)(
+ XIC,
+ XPointer,
+ XPointer
+);
+
+typedef void (*XIDProc)(
+ Display*,
+ XPointer,
+ XPointer
+);
+
+typedef unsigned long XIMStyle;
+
+typedef struct {
+ unsigned short count_styles;
+ XIMStyle *supported_styles;
+} XIMStyles;
+
+#define XIMPreeditArea 0x0001L
+#define XIMPreeditCallbacks 0x0002L
+#define XIMPreeditPosition 0x0004L
+#define XIMPreeditNothing 0x0008L
+#define XIMPreeditNone 0x0010L
+#define XIMStatusArea 0x0100L
+#define XIMStatusCallbacks 0x0200L
+#define XIMStatusNothing 0x0400L
+#define XIMStatusNone 0x0800L
+
+#define XNVaNestedList "XNVaNestedList"
+#define XNQueryInputStyle "queryInputStyle"
+#define XNClientWindow "clientWindow"
+#define XNInputStyle "inputStyle"
+#define XNFocusWindow "focusWindow"
+#define XNResourceName "resourceName"
+#define XNResourceClass "resourceClass"
+#define XNGeometryCallback "geometryCallback"
+#define XNDestroyCallback "destroyCallback"
+#define XNFilterEvents "filterEvents"
+#define XNPreeditStartCallback "preeditStartCallback"
+#define XNPreeditDoneCallback "preeditDoneCallback"
+#define XNPreeditDrawCallback "preeditDrawCallback"
+#define XNPreeditCaretCallback "preeditCaretCallback"
+#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback"
+#define XNPreeditAttributes "preeditAttributes"
+#define XNStatusStartCallback "statusStartCallback"
+#define XNStatusDoneCallback "statusDoneCallback"
+#define XNStatusDrawCallback "statusDrawCallback"
+#define XNStatusAttributes "statusAttributes"
+#define XNArea "area"
+#define XNAreaNeeded "areaNeeded"
+#define XNSpotLocation "spotLocation"
+#define XNColormap "colorMap"
+#define XNStdColormap "stdColorMap"
+#define XNForeground "foreground"
+#define XNBackground "background"
+#define XNBackgroundPixmap "backgroundPixmap"
+#define XNFontSet "fontSet"
+#define XNLineSpace "lineSpace"
+#define XNCursor "cursor"
+
+#define XNQueryIMValuesList "queryIMValuesList"
+#define XNQueryICValuesList "queryICValuesList"
+#define XNVisiblePosition "visiblePosition"
+#define XNR6PreeditCallback "r6PreeditCallback"
+#define XNStringConversionCallback "stringConversionCallback"
+#define XNStringConversion "stringConversion"
+#define XNResetState "resetState"
+#define XNHotKey "hotKey"
+#define XNHotKeyState "hotKeyState"
+#define XNPreeditState "preeditState"
+#define XNSeparatorofNestedList "separatorofNestedList"
+
+#define XBufferOverflow -1
+#define XLookupNone 1
+#define XLookupChars 2
+#define XLookupKeySym 3
+#define XLookupBoth 4
+
+typedef void *XVaNestedList;
+
+typedef struct {
+ XPointer client_data;
+ XIMProc callback;
+} XIMCallback;
+
+typedef struct {
+ XPointer client_data;
+ XICProc callback;
+} XICCallback;
+
+typedef unsigned long XIMFeedback;
+
+#define XIMReverse 1L
+#define XIMUnderline (1L<<1)
+#define XIMHighlight (1L<<2)
+#define XIMPrimary (1L<<5)
+#define XIMSecondary (1L<<6)
+#define XIMTertiary (1L<<7)
+#define XIMVisibleToForward (1L<<8)
+#define XIMVisibleToBackword (1L<<9)
+#define XIMVisibleToCenter (1L<<10)
+
+typedef struct _XIMText {
+ unsigned short length;
+ XIMFeedback *feedback;
+ Bool encoding_is_wchar;
+ union {
+ char *multi_byte;
+ wchar_t *wide_char;
+ } string;
+} XIMText;
+
+typedef unsigned long XIMPreeditState;
+
+#define XIMPreeditUnKnown 0L
+#define XIMPreeditEnable 1L
+#define XIMPreeditDisable (1L<<1)
+
+typedef struct _XIMPreeditStateNotifyCallbackStruct {
+ XIMPreeditState state;
+} XIMPreeditStateNotifyCallbackStruct;
+
+typedef unsigned long XIMResetState;
+
+#define XIMInitialState 1L
+#define XIMPreserveState (1L<<1)
+
+typedef unsigned long XIMStringConversionFeedback;
+
+#define XIMStringConversionLeftEdge (0x00000001)
+#define XIMStringConversionRightEdge (0x00000002)
+#define XIMStringConversionTopEdge (0x00000004)
+#define XIMStringConversionBottomEdge (0x00000008)
+#define XIMStringConversionConcealed (0x00000010)
+#define XIMStringConversionWrapped (0x00000020)
+
+typedef struct _XIMStringConversionText {
+ unsigned short length;
+ XIMStringConversionFeedback *feedback;
+ Bool encoding_is_wchar;
+ union {
+ char *mbs;
+ wchar_t *wcs;
+ } string;
+} XIMStringConversionText;
+
+typedef unsigned short XIMStringConversionPosition;
+
+typedef unsigned short XIMStringConversionType;
+
+#define XIMStringConversionBuffer (0x0001)
+#define XIMStringConversionLine (0x0002)
+#define XIMStringConversionWord (0x0003)
+#define XIMStringConversionChar (0x0004)
+
+typedef unsigned short XIMStringConversionOperation;
+
+#define XIMStringConversionSubstitution (0x0001)
+#define XIMStringConversionRetrieval (0x0002)
+
+typedef enum {
+ XIMForwardChar, XIMBackwardChar,
+ XIMForwardWord, XIMBackwardWord,
+ XIMCaretUp, XIMCaretDown,
+ XIMNextLine, XIMPreviousLine,
+ XIMLineStart, XIMLineEnd,
+ XIMAbsolutePosition,
+ XIMDontChange
+} XIMCaretDirection;
+
+typedef struct _XIMStringConversionCallbackStruct {
+ XIMStringConversionPosition position;
+ XIMCaretDirection direction;
+ XIMStringConversionOperation operation;
+ unsigned short factor;
+ XIMStringConversionText *text;
+} XIMStringConversionCallbackStruct;
+
+typedef struct _XIMPreeditDrawCallbackStruct {
+ int caret; /* Cursor offset within pre-edit string */
+ int chg_first; /* Starting change position */
+ int chg_length; /* Length of the change in character count */
+ XIMText *text;
+} XIMPreeditDrawCallbackStruct;
+
+typedef enum {
+ XIMIsInvisible, /* Disable caret feedback */
+ XIMIsPrimary, /* UI defined caret feedback */
+ XIMIsSecondary /* UI defined caret feedback */
+} XIMCaretStyle;
+
+typedef struct _XIMPreeditCaretCallbackStruct {
+ int position; /* Caret offset within pre-edit string */
+ XIMCaretDirection direction; /* Caret moves direction */
+ XIMCaretStyle style; /* Feedback of the caret */
+} XIMPreeditCaretCallbackStruct;
+
+typedef enum {
+ XIMTextType,
+ XIMBitmapType
+} XIMStatusDataType;
+
+typedef struct _XIMStatusDrawCallbackStruct {
+ XIMStatusDataType type;
+ union {
+ XIMText *text;
+ Pixmap bitmap;
+ } data;
+} XIMStatusDrawCallbackStruct;
+
+typedef struct _XIMHotKeyTrigger {
+ KeySym keysym;
+ int modifier;
+ int modifier_mask;
+} XIMHotKeyTrigger;
+
+typedef struct _XIMHotKeyTriggers {
+ int num_hot_key;
+ XIMHotKeyTrigger *key;
+} XIMHotKeyTriggers;
+
+typedef unsigned long XIMHotKeyState;
+
+#define XIMHotKeyStateON (0x0001L)
+#define XIMHotKeyStateOFF (0x0002L)
+
+typedef struct {
+ unsigned short count_values;
+ char **supported_values;
+} XIMValuesList;
+
+_XFUNCPROTOBEGIN
+
+#if defined(WIN32) && !defined(_XLIBINT_)
+#define _Xdebug (*_Xdebug_p)
+#endif
+
+extern int _Xdebug;
+
+extern XFontStruct *XLoadQueryFont(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+
+extern XFontStruct *XQueryFont(
+ Display* /* display */,
+ XID /* font_ID */
+);
+
+
+extern XTimeCoord *XGetMotionEvents(
+ Display* /* display */,
+ Window /* w */,
+ Time /* start */,
+ Time /* stop */,
+ int* /* nevents_return */
+);
+
+extern XModifierKeymap *XDeleteModifiermapEntry(
+ XModifierKeymap* /* modmap */,
+#if NeedWidePrototypes
+ unsigned int /* keycode_entry */,
+#else
+ KeyCode /* keycode_entry */,
+#endif
+ int /* modifier */
+);
+
+extern XModifierKeymap *XGetModifierMapping(
+ Display* /* display */
+);
+
+extern XModifierKeymap *XInsertModifiermapEntry(
+ XModifierKeymap* /* modmap */,
+#if NeedWidePrototypes
+ unsigned int /* keycode_entry */,
+#else
+ KeyCode /* keycode_entry */,
+#endif
+ int /* modifier */
+);
+
+extern XModifierKeymap *XNewModifiermap(
+ int /* max_keys_per_mod */
+);
+
+extern XImage *XCreateImage(
+ Display* /* display */,
+ Visual* /* visual */,
+ unsigned int /* depth */,
+ int /* format */,
+ int /* offset */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* bitmap_pad */,
+ int /* bytes_per_line */
+);
+extern Status XInitImage(
+ XImage* /* image */
+);
+extern XImage *XGetImage(
+ Display* /* display */,
+ Drawable /* d */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* plane_mask */,
+ int /* format */
+);
+extern XImage *XGetSubImage(
+ Display* /* display */,
+ Drawable /* d */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* plane_mask */,
+ int /* format */,
+ XImage* /* dest_image */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+/*
+ * X function declarations.
+ */
+extern Display *XOpenDisplay(
+ _Xconst char* /* display_name */
+);
+
+extern void XrmInitialize(
+ void
+);
+
+extern char *XFetchBytes(
+ Display* /* display */,
+ int* /* nbytes_return */
+);
+extern char *XFetchBuffer(
+ Display* /* display */,
+ int* /* nbytes_return */,
+ int /* buffer */
+);
+extern char *XGetAtomName(
+ Display* /* display */,
+ Atom /* atom */
+);
+extern Status XGetAtomNames(
+ Display* /* dpy */,
+ Atom* /* atoms */,
+ int /* count */,
+ char** /* names_return */
+);
+extern char *XGetDefault(
+ Display* /* display */,
+ _Xconst char* /* program */,
+ _Xconst char* /* option */
+);
+extern char *XDisplayName(
+ _Xconst char* /* string */
+);
+extern char *XKeysymToString(
+ KeySym /* keysym */
+);
+
+extern int (*XSynchronize(
+ Display* /* display */,
+ Bool /* onoff */
+))(
+ Display* /* display */
+);
+extern int (*XSetAfterFunction(
+ Display* /* display */,
+ int (*) (
+ Display* /* display */
+ ) /* procedure */
+))(
+ Display* /* display */
+);
+extern Atom XInternAtom(
+ Display* /* display */,
+ _Xconst char* /* atom_name */,
+ Bool /* only_if_exists */
+);
+extern Status XInternAtoms(
+ Display* /* dpy */,
+ char** /* names */,
+ int /* count */,
+ Bool /* onlyIfExists */,
+ Atom* /* atoms_return */
+);
+extern Colormap XCopyColormapAndFree(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+extern Colormap XCreateColormap(
+ Display* /* display */,
+ Window /* w */,
+ Visual* /* visual */,
+ int /* alloc */
+);
+extern Cursor XCreatePixmapCursor(
+ Display* /* display */,
+ Pixmap /* source */,
+ Pixmap /* mask */,
+ XColor* /* foreground_color */,
+ XColor* /* background_color */,
+ unsigned int /* x */,
+ unsigned int /* y */
+);
+extern Cursor XCreateGlyphCursor(
+ Display* /* display */,
+ Font /* source_font */,
+ Font /* mask_font */,
+ unsigned int /* source_char */,
+ unsigned int /* mask_char */,
+ XColor _Xconst * /* foreground_color */,
+ XColor _Xconst * /* background_color */
+);
+extern Cursor XCreateFontCursor(
+ Display* /* display */,
+ unsigned int /* shape */
+);
+extern Font XLoadFont(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+extern GC XCreateGC(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values */
+);
+extern GContext XGContextFromGC(
+ GC /* gc */
+);
+extern void XFlushGC(
+ Display* /* display */,
+ GC /* gc */
+);
+extern Pixmap XCreatePixmap(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* depth */
+);
+extern Pixmap XCreateBitmapFromData(
+ Display* /* display */,
+ Drawable /* d */,
+ _Xconst char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+extern Pixmap XCreatePixmapFromBitmapData(
+ Display* /* display */,
+ Drawable /* d */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* fg */,
+ unsigned long /* bg */,
+ unsigned int /* depth */
+);
+extern Window XCreateSimpleWindow(
+ Display* /* display */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* border_width */,
+ unsigned long /* border */,
+ unsigned long /* background */
+);
+extern Window XGetSelectionOwner(
+ Display* /* display */,
+ Atom /* selection */
+);
+extern Window XCreateWindow(
+ Display* /* display */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* border_width */,
+ int /* depth */,
+ unsigned int /* class */,
+ Visual* /* visual */,
+ unsigned long /* valuemask */,
+ XSetWindowAttributes* /* attributes */
+);
+extern Colormap *XListInstalledColormaps(
+ Display* /* display */,
+ Window /* w */,
+ int* /* num_return */
+);
+extern char **XListFonts(
+ Display* /* display */,
+ _Xconst char* /* pattern */,
+ int /* maxnames */,
+ int* /* actual_count_return */
+);
+extern char **XListFontsWithInfo(
+ Display* /* display */,
+ _Xconst char* /* pattern */,
+ int /* maxnames */,
+ int* /* count_return */,
+ XFontStruct** /* info_return */
+);
+extern char **XGetFontPath(
+ Display* /* display */,
+ int* /* npaths_return */
+);
+extern char **XListExtensions(
+ Display* /* display */,
+ int* /* nextensions_return */
+);
+extern Atom *XListProperties(
+ Display* /* display */,
+ Window /* w */,
+ int* /* num_prop_return */
+);
+extern XHostAddress *XListHosts(
+ Display* /* display */,
+ int* /* nhosts_return */,
+ Bool* /* state_return */
+);
+extern KeySym XKeycodeToKeysym(
+ Display* /* display */,
+#if NeedWidePrototypes
+ unsigned int /* keycode */,
+#else
+ KeyCode /* keycode */,
+#endif
+ int /* index */
+);
+extern KeySym XLookupKeysym(
+ XKeyEvent* /* key_event */,
+ int /* index */
+);
+extern KeySym *XGetKeyboardMapping(
+ Display* /* display */,
+#if NeedWidePrototypes
+ unsigned int /* first_keycode */,
+#else
+ KeyCode /* first_keycode */,
+#endif
+ int /* keycode_count */,
+ int* /* keysyms_per_keycode_return */
+);
+extern KeySym XStringToKeysym(
+ _Xconst char* /* string */
+);
+extern long XMaxRequestSize(
+ Display* /* display */
+);
+extern long XExtendedMaxRequestSize(
+ Display* /* display */
+);
+extern char *XResourceManagerString(
+ Display* /* display */
+);
+extern char *XScreenResourceString(
+ Screen* /* screen */
+);
+extern unsigned long XDisplayMotionBufferSize(
+ Display* /* display */
+);
+extern VisualID XVisualIDFromVisual(
+ Visual* /* visual */
+);
+
+/* multithread routines */
+
+extern Status XInitThreads(
+ void
+);
+
+extern void XLockDisplay(
+ Display* /* display */
+);
+
+extern void XUnlockDisplay(
+ Display* /* display */
+);
+
+/* routines for dealing with extensions */
+
+extern XExtCodes *XInitExtension(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+
+extern XExtCodes *XAddExtension(
+ Display* /* display */
+);
+extern XExtData *XFindOnExtensionList(
+ XExtData** /* structure */,
+ int /* number */
+);
+extern XExtData **XEHeadOfExtensionList(
+ XEDataObject /* object */
+);
+
+/* these are routines for which there are also macros */
+extern Window XRootWindow(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Window XDefaultRootWindow(
+ Display* /* display */
+);
+extern Window XRootWindowOfScreen(
+ Screen* /* screen */
+);
+extern Visual *XDefaultVisual(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Visual *XDefaultVisualOfScreen(
+ Screen* /* screen */
+);
+extern GC XDefaultGC(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern GC XDefaultGCOfScreen(
+ Screen* /* screen */
+);
+extern unsigned long XBlackPixel(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern unsigned long XWhitePixel(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern unsigned long XAllPlanes(
+ void
+);
+extern unsigned long XBlackPixelOfScreen(
+ Screen* /* screen */
+);
+extern unsigned long XWhitePixelOfScreen(
+ Screen* /* screen */
+);
+extern unsigned long XNextRequest(
+ Display* /* display */
+);
+extern unsigned long XLastKnownRequestProcessed(
+ Display* /* display */
+);
+extern char *XServerVendor(
+ Display* /* display */
+);
+extern char *XDisplayString(
+ Display* /* display */
+);
+extern Colormap XDefaultColormap(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Colormap XDefaultColormapOfScreen(
+ Screen* /* screen */
+);
+extern Display *XDisplayOfScreen(
+ Screen* /* screen */
+);
+extern Screen *XScreenOfDisplay(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Screen *XDefaultScreenOfDisplay(
+ Display* /* display */
+);
+extern long XEventMaskOfScreen(
+ Screen* /* screen */
+);
+
+extern int XScreenNumberOfScreen(
+ Screen* /* screen */
+);
+
+typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */
+ Display* /* display */,
+ XErrorEvent* /* error_event */
+);
+
+extern XErrorHandler XSetErrorHandler (
+ XErrorHandler /* handler */
+);
+
+
+typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */
+ Display* /* display */
+);
+
+extern XIOErrorHandler XSetIOErrorHandler (
+ XIOErrorHandler /* handler */
+);
+
+
+extern XPixmapFormatValues *XListPixmapFormats(
+ Display* /* display */,
+ int* /* count_return */
+);
+extern int *XListDepths(
+ Display* /* display */,
+ int /* screen_number */,
+ int* /* count_return */
+);
+
+/* ICCCM routines for things that don't require special include files; */
+/* other declarations are given in Xutil.h */
+extern Status XReconfigureWMWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */,
+ unsigned int /* mask */,
+ XWindowChanges* /* changes */
+);
+
+extern Status XGetWMProtocols(
+ Display* /* display */,
+ Window /* w */,
+ Atom** /* protocols_return */,
+ int* /* count_return */
+);
+extern Status XSetWMProtocols(
+ Display* /* display */,
+ Window /* w */,
+ Atom* /* protocols */,
+ int /* count */
+);
+extern Status XIconifyWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */
+);
+extern Status XWithdrawWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */
+);
+extern Status XGetCommand(
+ Display* /* display */,
+ Window /* w */,
+ char*** /* argv_return */,
+ int* /* argc_return */
+);
+extern Status XGetWMColormapWindows(
+ Display* /* display */,
+ Window /* w */,
+ Window** /* windows_return */,
+ int* /* count_return */
+);
+extern Status XSetWMColormapWindows(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* colormap_windows */,
+ int /* count */
+);
+extern void XFreeStringList(
+ char** /* list */
+);
+extern int XSetTransientForHint(
+ Display* /* display */,
+ Window /* w */,
+ Window /* prop_window */
+);
+
+/* The following are given in alphabetical order */
+
+extern int XActivateScreenSaver(
+ Display* /* display */
+);
+
+extern int XAddHost(
+ Display* /* display */,
+ XHostAddress* /* host */
+);
+
+extern int XAddHosts(
+ Display* /* display */,
+ XHostAddress* /* hosts */,
+ int /* num_hosts */
+);
+
+extern int XAddToExtensionList(
+ struct _XExtData** /* structure */,
+ XExtData* /* ext_data */
+);
+
+extern int XAddToSaveSet(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern Status XAllocColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* screen_in_out */
+);
+
+extern Status XAllocColorCells(
+ Display* /* display */,
+ Colormap /* colormap */,
+ Bool /* contig */,
+ unsigned long* /* plane_masks_return */,
+ unsigned int /* nplanes */,
+ unsigned long* /* pixels_return */,
+ unsigned int /* npixels */
+);
+
+extern Status XAllocColorPlanes(
+ Display* /* display */,
+ Colormap /* colormap */,
+ Bool /* contig */,
+ unsigned long* /* pixels_return */,
+ int /* ncolors */,
+ int /* nreds */,
+ int /* ngreens */,
+ int /* nblues */,
+ unsigned long* /* rmask_return */,
+ unsigned long* /* gmask_return */,
+ unsigned long* /* bmask_return */
+);
+
+extern Status XAllocNamedColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_name */,
+ XColor* /* screen_def_return */,
+ XColor* /* exact_def_return */
+);
+
+extern int XAllowEvents(
+ Display* /* display */,
+ int /* event_mode */,
+ Time /* time */
+);
+
+extern int XAutoRepeatOff(
+ Display* /* display */
+);
+
+extern int XAutoRepeatOn(
+ Display* /* display */
+);
+
+extern int XBell(
+ Display* /* display */,
+ int /* percent */
+);
+
+extern int XBitmapBitOrder(
+ Display* /* display */
+);
+
+extern int XBitmapPad(
+ Display* /* display */
+);
+
+extern int XBitmapUnit(
+ Display* /* display */
+);
+
+extern int XCellsOfScreen(
+ Screen* /* screen */
+);
+
+extern int XChangeActivePointerGrab(
+ Display* /* display */,
+ unsigned int /* event_mask */,
+ Cursor /* cursor */,
+ Time /* time */
+);
+
+extern int XChangeGC(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values */
+);
+
+extern int XChangeKeyboardControl(
+ Display* /* display */,
+ unsigned long /* value_mask */,
+ XKeyboardControl* /* values */
+);
+
+extern int XChangeKeyboardMapping(
+ Display* /* display */,
+ int /* first_keycode */,
+ int /* keysyms_per_keycode */,
+ KeySym* /* keysyms */,
+ int /* num_codes */
+);
+
+extern int XChangePointerControl(
+ Display* /* display */,
+ Bool /* do_accel */,
+ Bool /* do_threshold */,
+ int /* accel_numerator */,
+ int /* accel_denominator */,
+ int /* threshold */
+);
+
+extern int XChangeProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */,
+ Atom /* type */,
+ int /* format */,
+ int /* mode */,
+ _Xconst unsigned char* /* data */,
+ int /* nelements */
+);
+
+extern int XChangeSaveSet(
+ Display* /* display */,
+ Window /* w */,
+ int /* change_mode */
+);
+
+extern int XChangeWindowAttributes(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* valuemask */,
+ XSetWindowAttributes* /* attributes */
+);
+
+extern Bool XCheckIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+#ifdef NX_TRANS_SOCKET
+
+/*
+ * This is just like XCheckIfEvent() but doesn't
+ * flush the output buffer if it can't read new
+ * events.
+ */
+
+extern Bool XCheckIfEventNoFlush(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+#endif
+
+extern Bool XCheckMaskEvent(
+ Display* /* display */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern Bool XCheckTypedEvent(
+ Display* /* display */,
+ int /* event_type */,
+ XEvent* /* event_return */
+);
+
+extern Bool XCheckTypedWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ int /* event_type */,
+ XEvent* /* event_return */
+);
+
+extern Bool XCheckWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern int XCirculateSubwindows(
+ Display* /* display */,
+ Window /* w */,
+ int /* direction */
+);
+
+extern int XCirculateSubwindowsDown(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XCirculateSubwindowsUp(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XClearArea(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ Bool /* exposures */
+);
+
+extern int XClearWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XCloseDisplay(
+ Display* /* display */
+);
+
+extern int XConfigureWindow(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* value_mask */,
+ XWindowChanges* /* values */
+);
+
+extern int XConnectionNumber(
+ Display* /* display */
+);
+
+extern int XConvertSelection(
+ Display* /* display */,
+ Atom /* selection */,
+ Atom /* target */,
+ Atom /* property */,
+ Window /* requestor */,
+ Time /* time */
+);
+
+extern int XCopyArea(
+ Display* /* display */,
+ Drawable /* src */,
+ Drawable /* dest */,
+ GC /* gc */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+extern int XCopyGC(
+ Display* /* display */,
+ GC /* src */,
+ unsigned long /* valuemask */,
+ GC /* dest */
+);
+
+extern int XCopyPlane(
+ Display* /* display */,
+ Drawable /* src */,
+ Drawable /* dest */,
+ GC /* gc */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* dest_x */,
+ int /* dest_y */,
+ unsigned long /* plane */
+);
+
+extern int XDefaultDepth(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDefaultDepthOfScreen(
+ Screen* /* screen */
+);
+
+extern int XDefaultScreen(
+ Display* /* display */
+);
+
+extern int XDefineCursor(
+ Display* /* display */,
+ Window /* w */,
+ Cursor /* cursor */
+);
+
+extern int XDeleteProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */
+);
+
+extern int XDestroyWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XDestroySubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XDoesBackingStore(
+ Screen* /* screen */
+);
+
+extern Bool XDoesSaveUnders(
+ Screen* /* screen */
+);
+
+extern int XDisableAccessControl(
+ Display* /* display */
+);
+
+
+extern int XDisplayCells(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayHeight(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayHeightMM(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayKeycodes(
+ Display* /* display */,
+ int* /* min_keycodes_return */,
+ int* /* max_keycodes_return */
+);
+
+extern int XDisplayPlanes(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayWidth(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayWidthMM(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDrawArc(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* angle1 */,
+ int /* angle2 */
+);
+
+extern int XDrawArcs(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XArc* /* arcs */,
+ int /* narcs */
+);
+
+extern int XDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* string */,
+ int /* length */
+);
+
+extern int XDrawImageString16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst XChar2b* /* string */,
+ int /* length */
+);
+
+extern int XDrawLine(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x1 */,
+ int /* y1 */,
+ int /* x2 */,
+ int /* y2 */
+);
+
+extern int XDrawLines(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* mode */
+);
+
+extern int XDrawPoint(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */
+);
+
+extern int XDrawPoints(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* mode */
+);
+
+extern int XDrawRectangle(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XDrawRectangles(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XRectangle* /* rectangles */,
+ int /* nrectangles */
+);
+
+extern int XDrawSegments(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XSegment* /* segments */,
+ int /* nsegments */
+);
+
+extern int XDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* string */,
+ int /* length */
+);
+
+extern int XDrawString16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst XChar2b* /* string */,
+ int /* length */
+);
+
+extern int XDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XTextItem* /* items */,
+ int /* nitems */
+);
+
+extern int XDrawText16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XTextItem16* /* items */,
+ int /* nitems */
+);
+
+extern int XEnableAccessControl(
+ Display* /* display */
+);
+
+extern int XEventsQueued(
+ Display* /* display */,
+ int /* mode */
+);
+
+extern Status XFetchName(
+ Display* /* display */,
+ Window /* w */,
+ char** /* window_name_return */
+);
+
+extern int XFillArc(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* angle1 */,
+ int /* angle2 */
+);
+
+extern int XFillArcs(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XArc* /* arcs */,
+ int /* narcs */
+);
+
+extern int XFillPolygon(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* shape */,
+ int /* mode */
+);
+
+extern int XFillRectangle(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XFillRectangles(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XRectangle* /* rectangles */,
+ int /* nrectangles */
+);
+
+extern int XFlush(
+ Display* /* display */
+);
+
+extern int XForceScreenSaver(
+ Display* /* display */,
+ int /* mode */
+);
+
+extern int XFree(
+ void* /* data */
+);
+
+extern int XFreeColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+extern int XFreeColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ unsigned long* /* pixels */,
+ int /* npixels */,
+ unsigned long /* planes */
+);
+
+extern int XFreeCursor(
+ Display* /* display */,
+ Cursor /* cursor */
+);
+
+extern int XFreeExtensionList(
+ char** /* list */
+);
+
+extern int XFreeFont(
+ Display* /* display */,
+ XFontStruct* /* font_struct */
+);
+
+extern int XFreeFontInfo(
+ char** /* names */,
+ XFontStruct* /* free_info */,
+ int /* actual_count */
+);
+
+extern int XFreeFontNames(
+ char** /* list */
+);
+
+extern int XFreeFontPath(
+ char** /* list */
+);
+
+extern int XFreeGC(
+ Display* /* display */,
+ GC /* gc */
+);
+
+extern int XFreeModifiermap(
+ XModifierKeymap* /* modmap */
+);
+
+extern int XFreePixmap(
+ Display* /* display */,
+ Pixmap /* pixmap */
+);
+
+extern int XGeometry(
+ Display* /* display */,
+ int /* screen */,
+ _Xconst char* /* position */,
+ _Xconst char* /* default_position */,
+ unsigned int /* bwidth */,
+ unsigned int /* fwidth */,
+ unsigned int /* fheight */,
+ int /* xadder */,
+ int /* yadder */,
+ int* /* x_return */,
+ int* /* y_return */,
+ int* /* width_return */,
+ int* /* height_return */
+);
+
+extern int XGetErrorDatabaseText(
+ Display* /* display */,
+ _Xconst char* /* name */,
+ _Xconst char* /* message */,
+ _Xconst char* /* default_string */,
+ char* /* buffer_return */,
+ int /* length */
+);
+
+extern int XGetErrorText(
+ Display* /* display */,
+ int /* code */,
+ char* /* buffer_return */,
+ int /* length */
+);
+
+extern Bool XGetFontProperty(
+ XFontStruct* /* font_struct */,
+ Atom /* atom */,
+ unsigned long* /* value_return */
+);
+
+extern Status XGetGCValues(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values_return */
+);
+
+extern Status XGetGeometry(
+ Display* /* display */,
+ Drawable /* d */,
+ Window* /* root_return */,
+ int* /* x_return */,
+ int* /* y_return */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned int* /* border_width_return */,
+ unsigned int* /* depth_return */
+);
+
+extern Status XGetIconName(
+ Display* /* display */,
+ Window /* w */,
+ char** /* icon_name_return */
+);
+
+extern int XGetInputFocus(
+ Display* /* display */,
+ Window* /* focus_return */,
+ int* /* revert_to_return */
+);
+
+extern int XGetKeyboardControl(
+ Display* /* display */,
+ XKeyboardState* /* values_return */
+);
+
+extern int XGetPointerControl(
+ Display* /* display */,
+ int* /* accel_numerator_return */,
+ int* /* accel_denominator_return */,
+ int* /* threshold_return */
+);
+
+extern int XGetPointerMapping(
+ Display* /* display */,
+ unsigned char* /* map_return */,
+ int /* nmap */
+);
+
+extern int XGetScreenSaver(
+ Display* /* display */,
+ int* /* timeout_return */,
+ int* /* interval_return */,
+ int* /* prefer_blanking_return */,
+ int* /* allow_exposures_return */
+);
+
+extern Status XGetTransientForHint(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* prop_window_return */
+);
+
+extern int XGetWindowProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */,
+ long /* long_offset */,
+ long /* long_length */,
+ Bool /* delete */,
+ Atom /* req_type */,
+ Atom* /* actual_type_return */,
+ int* /* actual_format_return */,
+ unsigned long* /* nitems_return */,
+ unsigned long* /* bytes_after_return */,
+ unsigned char** /* prop_return */
+);
+
+extern Status XGetWindowAttributes(
+ Display* /* display */,
+ Window /* w */,
+ XWindowAttributes* /* window_attributes_return */
+);
+
+extern int XGrabButton(
+ Display* /* display */,
+ unsigned int /* button */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */
+);
+
+extern int XGrabKey(
+ Display* /* display */,
+ int /* keycode */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */
+);
+
+extern int XGrabKeyboard(
+ Display* /* display */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Time /* time */
+);
+
+extern int XGrabPointer(
+ Display* /* display */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */,
+ Time /* time */
+);
+
+extern int XGrabServer(
+ Display* /* display */
+);
+
+extern int XHeightMMOfScreen(
+ Screen* /* screen */
+);
+
+extern int XHeightOfScreen(
+ Screen* /* screen */
+);
+
+extern int XIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+extern int XImageByteOrder(
+ Display* /* display */
+);
+
+extern int XInstallColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+extern KeyCode XKeysymToKeycode(
+ Display* /* display */,
+ KeySym /* keysym */
+);
+
+extern int XKillClient(
+ Display* /* display */,
+ XID /* resource */
+);
+
+extern Status XLookupColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_name */,
+ XColor* /* exact_def_return */,
+ XColor* /* screen_def_return */
+);
+
+extern int XLowerWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMapRaised(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMapSubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMapWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMaskEvent(
+ Display* /* display */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern int XMaxCmapsOfScreen(
+ Screen* /* screen */
+);
+
+extern int XMinCmapsOfScreen(
+ Screen* /* screen */
+);
+
+extern int XMoveResizeWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XMoveWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */
+);
+
+extern int XNextEvent(
+ Display* /* display */,
+ XEvent* /* event_return */
+);
+
+extern int XNoOp(
+ Display* /* display */
+);
+
+extern Status XParseColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* spec */,
+ XColor* /* exact_def_return */
+);
+
+extern int XParseGeometry(
+ _Xconst char* /* parsestring */,
+ int* /* x_return */,
+ int* /* y_return */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern int XPeekEvent(
+ Display* /* display */,
+ XEvent* /* event_return */
+);
+
+extern int XPeekIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+extern int XPending(
+ Display* /* display */
+);
+
+extern int XPlanesOfScreen(
+ Screen* /* screen */
+);
+
+extern int XProtocolRevision(
+ Display* /* display */
+);
+
+extern int XProtocolVersion(
+ Display* /* display */
+);
+
+
+extern int XPutBackEvent(
+ Display* /* display */,
+ XEvent* /* event */
+);
+
+extern int XPutImage(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XImage* /* image */,
+ int /* src_x */,
+ int /* src_y */,
+ int /* dest_x */,
+ int /* dest_y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XQLength(
+ Display* /* display */
+);
+
+extern Status XQueryBestCursor(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern Status XQueryBestSize(
+ Display* /* display */,
+ int /* class */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern Status XQueryBestStipple(
+ Display* /* display */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern Status XQueryBestTile(
+ Display* /* display */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern int XQueryColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* def_in_out */
+);
+
+extern int XQueryColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* defs_in_out */,
+ int /* ncolors */
+);
+
+extern Bool XQueryExtension(
+ Display* /* display */,
+ _Xconst char* /* name */,
+ int* /* major_opcode_return */,
+ int* /* first_event_return */,
+ int* /* first_error_return */
+);
+
+extern int XQueryKeymap(
+ Display* /* display */,
+ char [32] /* keys_return */
+);
+
+extern Bool XQueryPointer(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* root_return */,
+ Window* /* child_return */,
+ int* /* root_x_return */,
+ int* /* root_y_return */,
+ int* /* win_x_return */,
+ int* /* win_y_return */,
+ unsigned int* /* mask_return */
+);
+
+extern int XQueryTextExtents(
+ Display* /* display */,
+ XID /* font_ID */,
+ _Xconst char* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern int XQueryTextExtents16(
+ Display* /* display */,
+ XID /* font_ID */,
+ _Xconst XChar2b* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern Status XQueryTree(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* root_return */,
+ Window* /* parent_return */,
+ Window** /* children_return */,
+ unsigned int* /* nchildren_return */
+);
+
+extern int XRaiseWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XReadBitmapFile(
+ Display* /* display */,
+ Drawable /* d */,
+ _Xconst char* /* filename */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ Pixmap* /* bitmap_return */,
+ int* /* x_hot_return */,
+ int* /* y_hot_return */
+);
+
+extern int XReadBitmapFileData(
+ _Xconst char* /* filename */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned char** /* data_return */,
+ int* /* x_hot_return */,
+ int* /* y_hot_return */
+);
+
+extern int XRebindKeysym(
+ Display* /* display */,
+ KeySym /* keysym */,
+ KeySym* /* list */,
+ int /* mod_count */,
+ _Xconst unsigned char* /* string */,
+ int /* bytes_string */
+);
+
+extern int XRecolorCursor(
+ Display* /* display */,
+ Cursor /* cursor */,
+ XColor* /* foreground_color */,
+ XColor* /* background_color */
+);
+
+extern int XRefreshKeyboardMapping(
+ XMappingEvent* /* event_map */
+);
+
+extern int XRemoveFromSaveSet(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XRemoveHost(
+ Display* /* display */,
+ XHostAddress* /* host */
+);
+
+extern int XRemoveHosts(
+ Display* /* display */,
+ XHostAddress* /* hosts */,
+ int /* num_hosts */
+);
+
+extern int XReparentWindow(
+ Display* /* display */,
+ Window /* w */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */
+);
+
+extern int XResetScreenSaver(
+ Display* /* display */
+);
+
+extern int XResizeWindow(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XRestackWindows(
+ Display* /* display */,
+ Window* /* windows */,
+ int /* nwindows */
+);
+
+extern int XRotateBuffers(
+ Display* /* display */,
+ int /* rotate */
+);
+
+extern int XRotateWindowProperties(
+ Display* /* display */,
+ Window /* w */,
+ Atom* /* properties */,
+ int /* num_prop */,
+ int /* npositions */
+);
+
+extern int XScreenCount(
+ Display* /* display */
+);
+
+extern int XSelectInput(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */
+);
+
+extern Status XSendEvent(
+ Display* /* display */,
+ Window /* w */,
+ Bool /* propagate */,
+ long /* event_mask */,
+ XEvent* /* event_send */
+);
+
+extern int XSetAccessControl(
+ Display* /* display */,
+ int /* mode */
+);
+
+extern int XSetArcMode(
+ Display* /* display */,
+ GC /* gc */,
+ int /* arc_mode */
+);
+
+extern int XSetBackground(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* background */
+);
+
+extern int XSetClipMask(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* pixmap */
+);
+
+extern int XSetClipOrigin(
+ Display* /* display */,
+ GC /* gc */,
+ int /* clip_x_origin */,
+ int /* clip_y_origin */
+);
+
+extern int XSetClipRectangles(
+ Display* /* display */,
+ GC /* gc */,
+ int /* clip_x_origin */,
+ int /* clip_y_origin */,
+ XRectangle* /* rectangles */,
+ int /* n */,
+ int /* ordering */
+);
+
+extern int XSetCloseDownMode(
+ Display* /* display */,
+ int /* close_mode */
+);
+
+extern int XSetCommand(
+ Display* /* display */,
+ Window /* w */,
+ char** /* argv */,
+ int /* argc */
+);
+
+extern int XSetDashes(
+ Display* /* display */,
+ GC /* gc */,
+ int /* dash_offset */,
+ _Xconst char* /* dash_list */,
+ int /* n */
+);
+
+extern int XSetFillRule(
+ Display* /* display */,
+ GC /* gc */,
+ int /* fill_rule */
+);
+
+extern int XSetFillStyle(
+ Display* /* display */,
+ GC /* gc */,
+ int /* fill_style */
+);
+
+extern int XSetFont(
+ Display* /* display */,
+ GC /* gc */,
+ Font /* font */
+);
+
+extern int XSetFontPath(
+ Display* /* display */,
+ char** /* directories */,
+ int /* ndirs */
+);
+
+extern int XSetForeground(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* foreground */
+);
+
+extern int XSetFunction(
+ Display* /* display */,
+ GC /* gc */,
+ int /* function */
+);
+
+extern int XSetGraphicsExposures(
+ Display* /* display */,
+ GC /* gc */,
+ Bool /* graphics_exposures */
+);
+
+extern int XSetIconName(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* icon_name */
+);
+
+extern int XSetInputFocus(
+ Display* /* display */,
+ Window /* focus */,
+ int /* revert_to */,
+ Time /* time */
+);
+
+extern int XSetLineAttributes(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned int /* line_width */,
+ int /* line_style */,
+ int /* cap_style */,
+ int /* join_style */
+);
+
+extern int XSetModifierMapping(
+ Display* /* display */,
+ XModifierKeymap* /* modmap */
+);
+
+extern int XSetPlaneMask(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* plane_mask */
+);
+
+extern int XSetPointerMapping(
+ Display* /* display */,
+ _Xconst unsigned char* /* map */,
+ int /* nmap */
+);
+
+extern int XSetScreenSaver(
+ Display* /* display */,
+ int /* timeout */,
+ int /* interval */,
+ int /* prefer_blanking */,
+ int /* allow_exposures */
+);
+
+extern int XSetSelectionOwner(
+ Display* /* display */,
+ Atom /* selection */,
+ Window /* owner */,
+ Time /* time */
+);
+
+extern int XSetState(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* foreground */,
+ unsigned long /* background */,
+ int /* function */,
+ unsigned long /* plane_mask */
+);
+
+extern int XSetStipple(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* stipple */
+);
+
+extern int XSetSubwindowMode(
+ Display* /* display */,
+ GC /* gc */,
+ int /* subwindow_mode */
+);
+
+extern int XSetTSOrigin(
+ Display* /* display */,
+ GC /* gc */,
+ int /* ts_x_origin */,
+ int /* ts_y_origin */
+);
+
+extern int XSetTile(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* tile */
+);
+
+extern int XSetWindowBackground(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* background_pixel */
+);
+
+extern int XSetWindowBackgroundPixmap(
+ Display* /* display */,
+ Window /* w */,
+ Pixmap /* background_pixmap */
+);
+
+extern int XSetWindowBorder(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* border_pixel */
+);
+
+extern int XSetWindowBorderPixmap(
+ Display* /* display */,
+ Window /* w */,
+ Pixmap /* border_pixmap */
+);
+
+extern int XSetWindowBorderWidth(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* width */
+);
+
+extern int XSetWindowColormap(
+ Display* /* display */,
+ Window /* w */,
+ Colormap /* colormap */
+);
+
+extern int XStoreBuffer(
+ Display* /* display */,
+ _Xconst char* /* bytes */,
+ int /* nbytes */,
+ int /* buffer */
+);
+
+extern int XStoreBytes(
+ Display* /* display */,
+ _Xconst char* /* bytes */,
+ int /* nbytes */
+);
+
+extern int XStoreColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* color */
+);
+
+extern int XStoreColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* color */,
+ int /* ncolors */
+);
+
+extern int XStoreName(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* window_name */
+);
+
+extern int XStoreNamedColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color */,
+ unsigned long /* pixel */,
+ int /* flags */
+);
+
+extern int XSync(
+ Display* /* display */,
+ Bool /* discard */
+);
+
+extern int XTextExtents(
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern int XTextExtents16(
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern int XTextWidth(
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* count */
+);
+
+extern int XTextWidth16(
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* count */
+);
+
+extern Bool XTranslateCoordinates(
+ Display* /* display */,
+ Window /* src_w */,
+ Window /* dest_w */,
+ int /* src_x */,
+ int /* src_y */,
+ int* /* dest_x_return */,
+ int* /* dest_y_return */,
+ Window* /* child_return */
+);
+
+extern int XUndefineCursor(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XUngrabButton(
+ Display* /* display */,
+ unsigned int /* button */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */
+);
+
+extern int XUngrabKey(
+ Display* /* display */,
+ int /* keycode */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */
+);
+
+extern int XUngrabKeyboard(
+ Display* /* display */,
+ Time /* time */
+);
+
+extern int XUngrabPointer(
+ Display* /* display */,
+ Time /* time */
+);
+
+extern int XUngrabServer(
+ Display* /* display */
+);
+
+extern int XUninstallColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+extern int XUnloadFont(
+ Display* /* display */,
+ Font /* font */
+);
+
+extern int XUnmapSubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XUnmapWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XVendorRelease(
+ Display* /* display */
+);
+
+extern int XWarpPointer(
+ Display* /* display */,
+ Window /* src_w */,
+ Window /* dest_w */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* src_width */,
+ unsigned int /* src_height */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+extern int XWidthMMOfScreen(
+ Screen* /* screen */
+);
+
+extern int XWidthOfScreen(
+ Screen* /* screen */
+);
+
+extern int XWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern int XWriteBitmapFile(
+ Display* /* display */,
+ _Xconst char* /* filename */,
+ Pixmap /* bitmap */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* x_hot */,
+ int /* y_hot */
+);
+
+extern Bool XSupportsLocale (void);
+
+extern char *XSetLocaleModifiers(
+ const char* /* modifier_list */
+);
+
+extern XOM XOpenOM(
+ Display* /* display */,
+ struct _XrmHashBucketRec* /* rdb */,
+ _Xconst char* /* res_name */,
+ _Xconst char* /* res_class */
+);
+
+extern Status XCloseOM(
+ XOM /* om */
+);
+
+extern char *XSetOMValues(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+extern char *XGetOMValues(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+extern Display *XDisplayOfOM(
+ XOM /* om */
+);
+
+extern char *XLocaleOfOM(
+ XOM /* om */
+);
+
+extern XOC XCreateOC(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+extern void XDestroyOC(
+ XOC /* oc */
+);
+
+extern XOM XOMOfOC(
+ XOC /* oc */
+);
+
+extern char *XSetOCValues(
+ XOC /* oc */,
+ ...
+) _X_SENTINEL(0);
+
+extern char *XGetOCValues(
+ XOC /* oc */,
+ ...
+) _X_SENTINEL(0);
+
+extern XFontSet XCreateFontSet(
+ Display* /* display */,
+ _Xconst char* /* base_font_name_list */,
+ char*** /* missing_charset_list */,
+ int* /* missing_charset_count */,
+ char** /* def_string */
+);
+
+extern void XFreeFontSet(
+ Display* /* display */,
+ XFontSet /* font_set */
+);
+
+extern int XFontsOfFontSet(
+ XFontSet /* font_set */,
+ XFontStruct*** /* font_struct_list */,
+ char*** /* font_name_list */
+);
+
+extern char *XBaseFontNameListOfFontSet(
+ XFontSet /* font_set */
+);
+
+extern char *XLocaleOfFontSet(
+ XFontSet /* font_set */
+);
+
+extern Bool XContextDependentDrawing(
+ XFontSet /* font_set */
+);
+
+extern Bool XDirectionalDependentDrawing(
+ XFontSet /* font_set */
+);
+
+extern Bool XContextualDrawing(
+ XFontSet /* font_set */
+);
+
+extern XFontSetExtents *XExtentsOfFontSet(
+ XFontSet /* font_set */
+);
+
+extern int XmbTextEscapement(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern int XwcTextEscapement(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+extern int Xutf8TextEscapement(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern int XmbTextExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern int XwcTextExtents(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern int Xutf8TextExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern Status XmbTextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern Status XwcTextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern Status Xutf8TextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern void XmbDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XmbTextItem* /* text_items */,
+ int /* nitems */
+);
+
+extern void XwcDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XwcTextItem* /* text_items */,
+ int /* nitems */
+);
+
+extern void Xutf8DrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XmbTextItem* /* text_items */,
+ int /* nitems */
+);
+
+extern void XmbDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern void XwcDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+extern void Xutf8DrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern void XmbDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern void XwcDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+extern void Xutf8DrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern XIM XOpenIM(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */
+);
+
+extern Status XCloseIM(
+ XIM /* im */
+);
+
+extern char *XGetIMValues(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+extern char *XSetIMValues(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+extern Display *XDisplayOfIM(
+ XIM /* im */
+);
+
+extern char *XLocaleOfIM(
+ XIM /* im*/
+);
+
+extern XIC XCreateIC(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+extern void XDestroyIC(
+ XIC /* ic */
+);
+
+extern void XSetICFocus(
+ XIC /* ic */
+);
+
+extern void XUnsetICFocus(
+ XIC /* ic */
+);
+
+extern wchar_t *XwcResetIC(
+ XIC /* ic */
+);
+
+extern char *XmbResetIC(
+ XIC /* ic */
+);
+
+extern char *Xutf8ResetIC(
+ XIC /* ic */
+);
+
+extern char *XSetICValues(
+ XIC /* ic */, ...
+) _X_SENTINEL(0);
+
+extern char *XGetICValues(
+ XIC /* ic */, ...
+) _X_SENTINEL(0);
+
+extern XIM XIMOfIC(
+ XIC /* ic */
+);
+
+extern Bool XFilterEvent(
+ XEvent* /* event */,
+ Window /* window */
+);
+
+extern int XmbLookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ char* /* buffer_return */,
+ int /* bytes_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+extern int XwcLookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ wchar_t* /* buffer_return */,
+ int /* wchars_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+extern int Xutf8LookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ char* /* buffer_return */,
+ int /* bytes_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+extern XVaNestedList XVaCreateNestedList(
+ int /*unused*/, ...
+) _X_SENTINEL(0);
+
+/* internal connections for IMs */
+
+extern Bool XRegisterIMInstantiateCallback(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIDProc /* callback */,
+ XPointer /* client_data */
+);
+
+extern Bool XUnregisterIMInstantiateCallback(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIDProc /* callback */,
+ XPointer /* client_data */
+);
+
+typedef void (*XConnectionWatchProc)(
+ Display* /* dpy */,
+ XPointer /* client_data */,
+ int /* fd */,
+ Bool /* opening */, /* open or close flag */
+ XPointer* /* watch_data */ /* open sets, close uses */
+);
+
+
+extern Status XInternalConnectionNumbers(
+ Display* /* dpy */,
+ int** /* fd_return */,
+ int* /* count_return */
+);
+
+extern void XProcessInternalConnection(
+ Display* /* dpy */,
+ int /* fd */
+);
+
+extern Status XAddConnectionWatch(
+ Display* /* dpy */,
+ XConnectionWatchProc /* callback */,
+ XPointer /* client_data */
+);
+
+extern void XRemoveConnectionWatch(
+ Display* /* dpy */,
+ XConnectionWatchProc /* callback */,
+ XPointer /* client_data */
+);
+
+extern void XSetAuthorization(
+ char * /* name */,
+ int /* namelen */,
+ char * /* data */,
+ int /* datalen */
+);
+
+extern int _Xmbtowc(
+ wchar_t * /* wstr */,
+#ifdef ISC
+ char const * /* str */,
+ size_t /* len */
+#else
+ char * /* str */,
+ int /* len */
+#endif
+);
+
+extern int _Xwctomb(
+ char * /* str */,
+ wchar_t /* wc */
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XLIB_H_ */
diff --git a/nx-X11/lib/X11/Xlib.h.NX.original b/nx-X11/lib/X11/Xlib.h.NX.original
new file mode 100644
index 000000000..e21d9ffac
--- /dev/null
+++ b/nx-X11/lib/X11/Xlib.h.NX.original
@@ -0,0 +1,4029 @@
+/* $XdotOrg: xc/lib/X11/Xlib.h,v 1.6 2005/11/08 06:33:25 jkj Exp $ */
+/* $Xorg: Xlib.h,v 1.6 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1986, 1987, 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.
+
+*/
+/* $XFree86: xc/lib/X11/Xlib.h,v 3.25 2003/11/17 22:20:10 dawes Exp $ */
+
+
+/*
+ * Xlib.h - Header definition and support file for the C subroutine
+ * interface library (Xlib) to the X Window System Protocol (V11).
+ * Structures and symbols starting with "_" are private to the library.
+ */
+#ifndef _XLIB_H_
+#define _XLIB_H_
+
+#define XlibSpecificationRelease 6
+
+#ifdef USG
+#ifndef __TYPES__
+#include <sys/types.h> /* forgot to protect it... */
+#define __TYPES__
+#endif /* __TYPES__ */
+#else
+#if defined(_POSIX_SOURCE) && defined(MOTOROLA)
+#undef _POSIX_SOURCE
+#include <sys/types.h>
+#define _POSIX_SOURCE
+#else
+#include <sys/types.h>
+#endif
+#endif /* USG */
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#include <stdint.h>
+#endif
+
+#include <X11/X.h>
+
+/* applications should not depend on these two headers being included! */
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+
+#ifndef X_WCHAR
+#ifdef X_NOT_STDC_ENV
+#ifndef ISC
+#define X_WCHAR
+#endif
+#endif
+#endif
+
+#ifndef X_WCHAR
+#include <stddef.h>
+#else
+#ifdef __UNIXOS2__
+#include <stdlib.h>
+#else
+/* replace this with #include or typedef appropriate for your system */
+typedef unsigned long wchar_t;
+#endif
+#endif
+
+#if defined(ISC) && defined(USE_XMBTOWC)
+#define wctomb(a,b) _Xwctomb(a,b)
+#define mblen(a,b) _Xmblen(a,b)
+#ifndef USE_XWCHAR_STRING
+#define mbtowc(a,b,c) _Xmbtowc(a,b,c)
+#endif
+#endif
+
+extern int
+_Xmblen(
+#ifdef ISC
+ char const *str,
+ size_t len
+#else
+ char *str,
+ int len
+#endif
+ );
+
+/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in
+ November 2000. Its presence is indicated through the following macro. */
+#define X_HAVE_UTF8_STRING 1
+
+typedef char *XPointer;
+
+#define Bool int
+#define Status int
+#define True 1
+#define False 0
+
+#define QueuedAlready 0
+#define QueuedAfterReading 1
+#define QueuedAfterFlush 2
+
+#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd)
+#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root)
+#define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen)
+#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root)
+#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual)
+#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc)
+#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel)
+#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel)
+#define AllPlanes ((unsigned long)~0L)
+#define QLength(dpy) (((_XPrivDisplay)dpy)->qlen)
+#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width)
+#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height)
+#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth)
+#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight)
+#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
+#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries)
+#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens)
+#define ServerVendor(dpy) (((_XPrivDisplay)dpy)->vendor)
+#define ProtocolVersion(dpy) (((_XPrivDisplay)dpy)->proto_major_version)
+#define ProtocolRevision(dpy) (((_XPrivDisplay)dpy)->proto_minor_version)
+#define VendorRelease(dpy) (((_XPrivDisplay)dpy)->release)
+#define DisplayString(dpy) (((_XPrivDisplay)dpy)->display_name)
+#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
+#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap)
+#define BitmapUnit(dpy) (((_XPrivDisplay)dpy)->bitmap_unit)
+#define BitmapBitOrder(dpy) (((_XPrivDisplay)dpy)->bitmap_bit_order)
+#define BitmapPad(dpy) (((_XPrivDisplay)dpy)->bitmap_pad)
+#define ImageByteOrder(dpy) (((_XPrivDisplay)dpy)->byte_order)
+#ifdef CRAY /* unable to get WORD64 without pulling in other symbols */
+#define NextRequest(dpy) XNextRequest(dpy)
+#else
+#define NextRequest(dpy) (((_XPrivDisplay)dpy)->request + 1)
+#endif
+#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)dpy)->last_request_read)
+
+/* macros for screen oriented applications (toolkit) */
+#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr])
+#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy))
+#define DisplayOfScreen(s) ((s)->display)
+#define RootWindowOfScreen(s) ((s)->root)
+#define BlackPixelOfScreen(s) ((s)->black_pixel)
+#define WhitePixelOfScreen(s) ((s)->white_pixel)
+#define DefaultColormapOfScreen(s)((s)->cmap)
+#define DefaultDepthOfScreen(s) ((s)->root_depth)
+#define DefaultGCOfScreen(s) ((s)->default_gc)
+#define DefaultVisualOfScreen(s)((s)->root_visual)
+#define WidthOfScreen(s) ((s)->width)
+#define HeightOfScreen(s) ((s)->height)
+#define WidthMMOfScreen(s) ((s)->mwidth)
+#define HeightMMOfScreen(s) ((s)->mheight)
+#define PlanesOfScreen(s) ((s)->root_depth)
+#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries)
+#define MinCmapsOfScreen(s) ((s)->min_maps)
+#define MaxCmapsOfScreen(s) ((s)->max_maps)
+#define DoesSaveUnders(s) ((s)->save_unders)
+#define DoesBackingStore(s) ((s)->backing_store)
+#define EventMaskOfScreen(s) ((s)->root_input_mask)
+
+/*
+ * Extensions need a way to hang private data on some structures.
+ */
+typedef struct _XExtData {
+ int number; /* number returned by XRegisterExtension */
+ struct _XExtData *next; /* next item on list of data for structure */
+ int (*free_private)( /* called to free private storage */
+ struct _XExtData *extension
+ );
+ XPointer private_data; /* data private to this extension. */
+} XExtData;
+
+/*
+ * This file contains structures used by the extension mechanism.
+ */
+typedef struct { /* public to extension, cannot be changed */
+ int extension; /* extension number */
+ int major_opcode; /* major op-code assigned by server */
+ int first_event; /* first event number for the extension */
+ int first_error; /* first error number for the extension */
+} XExtCodes;
+
+/*
+ * Data structure for retrieving info about pixmap formats.
+ */
+
+typedef struct {
+ int depth;
+ int bits_per_pixel;
+ int scanline_pad;
+} XPixmapFormatValues;
+
+
+/*
+ * Data structure for setting graphics context.
+ */
+typedef struct {
+ int function; /* logical operation */
+ unsigned long plane_mask;/* plane mask */
+ unsigned long foreground;/* foreground pixel */
+ unsigned long background;/* background pixel */
+ int line_width; /* line width */
+ int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */
+ int cap_style; /* CapNotLast, CapButt,
+ CapRound, CapProjecting */
+ int join_style; /* JoinMiter, JoinRound, JoinBevel */
+ int fill_style; /* FillSolid, FillTiled,
+ FillStippled, FillOpaeueStippled */
+ int fill_rule; /* EvenOddRule, WindingRule */
+ int arc_mode; /* ArcChord, ArcPieSlice */
+ Pixmap tile; /* tile pixmap for tiling operations */
+ Pixmap stipple; /* stipple 1 plane pixmap for stipping */
+ int ts_x_origin; /* offset for tile or stipple operations */
+ int ts_y_origin;
+ Font font; /* default text font for text operations */
+ int subwindow_mode; /* ClipByChildren, IncludeInferiors */
+ Bool graphics_exposures;/* boolean, should exposures be generated */
+ int clip_x_origin; /* origin for clipping */
+ int clip_y_origin;
+ Pixmap clip_mask; /* bitmap clipping; other calls for rects */
+ int dash_offset; /* patterned/dashed line information */
+ char dashes;
+} XGCValues;
+
+/*
+ * Graphics context. The contents of this structure are implementation
+ * dependent. A GC should be treated as opaque by application code.
+ */
+
+typedef struct _XGC
+#ifdef XLIB_ILLEGAL_ACCESS
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ GContext gid; /* protocol ID for graphics context */
+ /* there is more to this structure, but it is private to Xlib */
+}
+#endif
+*GC;
+
+/*
+ * Visual structure; contains information about colormapping possible.
+ */
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ VisualID visualid; /* visual id of this visual */
+#if defined(__cplusplus) || defined(c_plusplus)
+ int c_class; /* C++ class of screen (monochrome, etc.) */
+#else
+ int class; /* class of screen (monochrome, etc.) */
+#endif
+ unsigned long red_mask, green_mask, blue_mask; /* mask values */
+ int bits_per_rgb; /* log base 2 of distinct color values */
+ int map_entries; /* color map entries */
+} Visual;
+
+/*
+ * Depth structure; contains information for each possible depth.
+ */
+typedef struct {
+ int depth; /* this depth (Z) of the depth */
+ int nvisuals; /* number of Visual types at this depth */
+ Visual *visuals; /* list of visuals possible at this depth */
+} Depth;
+
+/*
+ * Information about the screen. The contents of this structure are
+ * implementation dependent. A Screen should be treated as opaque
+ * by application code.
+ */
+
+struct _XDisplay; /* Forward declare before use for C++ */
+
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XDisplay *display;/* back pointer to display structure */
+ Window root; /* Root window id. */
+ int width, height; /* width and height of screen */
+ int mwidth, mheight; /* width and height of in millimeters */
+ int ndepths; /* number of depths possible */
+ Depth *depths; /* list of allowable depths on the screen */
+ int root_depth; /* bits per pixel */
+ Visual *root_visual; /* root visual */
+ GC default_gc; /* GC for the root root visual */
+ Colormap cmap; /* default color map */
+ unsigned long white_pixel;
+ unsigned long black_pixel; /* White and Black pixel values */
+ int max_maps, min_maps; /* max and min color maps */
+ int backing_store; /* Never, WhenMapped, Always */
+ Bool save_unders;
+ long root_input_mask; /* initial root input mask */
+} Screen;
+
+/*
+ * Format structure; describes ZFormat data the screen will understand.
+ */
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ int depth; /* depth of this image format */
+ int bits_per_pixel; /* bits/pixel at this depth */
+ int scanline_pad; /* scanline must padded to this multiple */
+} ScreenFormat;
+
+/*
+ * Data structure for setting window attributes.
+ */
+typedef struct {
+ Pixmap background_pixmap; /* background or None or ParentRelative */
+ unsigned long background_pixel; /* background pixel */
+ Pixmap border_pixmap; /* border of the window */
+ unsigned long border_pixel; /* border pixel value */
+ int bit_gravity; /* one of bit gravity values */
+ int win_gravity; /* one of the window gravity values */
+ int backing_store; /* NotUseful, WhenMapped, Always */
+ unsigned long backing_planes;/* planes to be preseved if possible */
+ unsigned long backing_pixel;/* value to use in restoring planes */
+ Bool save_under; /* should bits under be saved? (popups) */
+ long event_mask; /* set of events that should be saved */
+ long do_not_propagate_mask; /* set of events that should not propagate */
+ Bool override_redirect; /* boolean value for override-redirect */
+ Colormap colormap; /* color map to be associated with window */
+ Cursor cursor; /* cursor to be displayed (or None) */
+} XSetWindowAttributes;
+
+typedef struct {
+ int x, y; /* location of window */
+ int width, height; /* width and height of window */
+ int border_width; /* border width of window */
+ int depth; /* depth of window */
+ Visual *visual; /* the associated visual structure */
+ Window root; /* root of screen containing window */
+#if defined(__cplusplus) || defined(c_plusplus)
+ int c_class; /* C++ InputOutput, InputOnly*/
+#else
+ int class; /* InputOutput, InputOnly*/
+#endif
+ int bit_gravity; /* one of bit gravity values */
+ int win_gravity; /* one of the window gravity values */
+ int backing_store; /* NotUseful, WhenMapped, Always */
+ unsigned long backing_planes;/* planes to be preserved if possible */
+ unsigned long backing_pixel;/* value to be used when restoring planes */
+ Bool save_under; /* boolean, should bits under be saved? */
+ Colormap colormap; /* color map to be associated with window */
+ Bool map_installed; /* boolean, is color map currently installed*/
+ int map_state; /* IsUnmapped, IsUnviewable, IsViewable */
+ long all_event_masks; /* set of events all people have interest in*/
+ long your_event_mask; /* my event mask */
+ long do_not_propagate_mask; /* set of events that should not propagate */
+ Bool override_redirect; /* boolean value for override-redirect */
+ Screen *screen; /* back pointer to correct screen */
+} XWindowAttributes;
+
+/*
+ * Data structure for host setting; getting routines.
+ *
+ */
+
+typedef struct {
+ int family; /* for example FamilyInternet */
+ int length; /* length of address, in bytes */
+ char *address; /* pointer to where to find the bytes */
+} XHostAddress;
+
+/*
+ * Data structure for ServerFamilyInterpreted addresses in host routines
+ */
+typedef struct {
+ int typelength; /* length of type string, in bytes */
+ int valuelength; /* length of value string, in bytes */
+ char *type; /* pointer to where to find the type string */
+ char *value; /* pointer to where to find the address */
+} XServerInterpretedAddress;
+
+/*
+ * Data structure for "image" data, used by image manipulation routines.
+ */
+typedef struct _XImage {
+ int width, height; /* size of image */
+ int xoffset; /* number of pixels offset in X direction */
+ int format; /* XYBitmap, XYPixmap, ZPixmap */
+ char *data; /* pointer to image data */
+ int byte_order; /* data byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* quant. of scanline 8, 16, 32 */
+ int bitmap_bit_order; /* LSBFirst, MSBFirst */
+ int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */
+ int depth; /* depth of image */
+ int bytes_per_line; /* accelarator to next line */
+ int bits_per_pixel; /* bits per pixel (ZPixmap) */
+ unsigned long red_mask; /* bits in z arrangment */
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ XPointer obdata; /* hook for the object routines to hang on */
+ struct funcs { /* image manipulation routines */
+ struct _XImage *(*create_image)(
+ struct _XDisplay* /* display */,
+ Visual* /* visual */,
+ unsigned int /* depth */,
+ int /* format */,
+ int /* offset */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* bitmap_pad */,
+ int /* bytes_per_line */);
+ int (*destroy_image) (struct _XImage *);
+ unsigned long (*get_pixel) (struct _XImage *, int, int);
+ int (*put_pixel) (struct _XImage *, int, int, unsigned long);
+ struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int);
+ int (*add_pixel) (struct _XImage *, long);
+ } f;
+} XImage;
+
+/*
+ * Data structure for XReconfigureWindow
+ */
+typedef struct {
+ int x, y;
+ int width, height;
+ int border_width;
+ Window sibling;
+ int stack_mode;
+} XWindowChanges;
+
+/*
+ * Data structure used by color operations
+ */
+typedef struct {
+ unsigned long pixel;
+ unsigned short red, green, blue;
+ char flags; /* do_red, do_green, do_blue */
+ char pad;
+} XColor;
+
+/*
+ * Data structures for graphics operations. On most machines, these are
+ * congruent with the wire protocol structures, so reformatting the data
+ * can be avoided on these architectures.
+ */
+typedef struct {
+ short x1, y1, x2, y2;
+} XSegment;
+
+typedef struct {
+ short x, y;
+} XPoint;
+
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+} XRectangle;
+
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+ short angle1, angle2;
+} XArc;
+
+
+/* Data structure for XChangeKeyboardControl */
+
+typedef struct {
+ int key_click_percent;
+ int bell_percent;
+ int bell_pitch;
+ int bell_duration;
+ int led;
+ int led_mode;
+ int key;
+ int auto_repeat_mode; /* On, Off, Default */
+} XKeyboardControl;
+
+/* Data structure for XGetKeyboardControl */
+
+typedef struct {
+ int key_click_percent;
+ int bell_percent;
+ unsigned int bell_pitch, bell_duration;
+ unsigned long led_mask;
+ int global_auto_repeat;
+ char auto_repeats[32];
+} XKeyboardState;
+
+/* Data structure for XGetMotionEvents. */
+
+typedef struct {
+ Time time;
+ short x, y;
+} XTimeCoord;
+
+/* Data structure for X{Set,Get}ModifierMapping */
+
+typedef struct {
+ int max_keypermod; /* The server's max # of keys per modifier */
+ KeyCode *modifiermap; /* An 8 by max_keypermod array of modifiers */
+} XModifierKeymap;
+
+
+/*
+ * Display datatype maintaining display specific data.
+ * The contents of this structure are implementation dependent.
+ * A Display should be treated as opaque by application code.
+ */
+#ifndef XLIB_ILLEGAL_ACCESS
+typedef struct _XDisplay Display;
+#endif
+
+struct _XPrivate; /* Forward declare before use for C++ */
+struct _XrmHashBucketRec;
+
+typedef struct
+#ifdef XLIB_ILLEGAL_ACCESS
+_XDisplay
+#endif
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XPrivate *private1;
+ int fd; /* Network socket. */
+ int private2;
+ int proto_major_version;/* major version of server's X protocol */
+ int proto_minor_version;/* minor version of servers X protocol */
+ char *vendor; /* vendor of the server hardware */
+ XID private3;
+ XID private4;
+ XID private5;
+ int private6;
+ XID (*resource_alloc)( /* allocator function */
+ struct _XDisplay*
+ );
+ int byte_order; /* screen byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* padding and data requirements */
+ int bitmap_pad; /* padding requirements on bitmaps */
+ int bitmap_bit_order; /* LeastSignificant or MostSignificant */
+ int nformats; /* number of pixmap formats in list */
+ ScreenFormat *pixmap_format; /* pixmap format list */
+ int private8;
+ int release; /* release of the server */
+ struct _XPrivate *private9, *private10;
+ int qlen; /* Length of input event queue */
+ unsigned long last_request_read; /* seq number of last event read */
+ unsigned long request; /* sequence number of last request. */
+ XPointer private11;
+ XPointer private12;
+ XPointer private13;
+ XPointer private14;
+ unsigned max_request_size; /* maximum number 32 bit words in request*/
+ struct _XrmHashBucketRec *db;
+ int (*private15)(
+ struct _XDisplay*
+ );
+ char *display_name; /* "host:display" string used on this connect*/
+ int default_screen; /* default screen for operations */
+ int nscreens; /* number of screens on this server*/
+ Screen *screens; /* pointer to list of screens */
+ unsigned long motion_buffer; /* size of motion buffer */
+ unsigned long private16;
+ int min_keycode; /* minimum defined keycode */
+ int max_keycode; /* maximum defined keycode */
+ XPointer private17;
+ XPointer private18;
+ int private19;
+ char *xdefaults; /* contents of defaults from server */
+ /* there is more to this structure, but it is private to Xlib */
+}
+#ifdef XLIB_ILLEGAL_ACCESS
+Display,
+#endif
+*_XPrivDisplay;
+
+#undef _XEVENT_
+#ifndef _XEVENT_
+/*
+ * Definitions of specific events.
+ */
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window it is reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ unsigned int keycode; /* detail */
+ Bool same_screen; /* same screen flag */
+} XKeyEvent;
+typedef XKeyEvent XKeyPressedEvent;
+typedef XKeyEvent XKeyReleasedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window it is reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ unsigned int button; /* detail */
+ Bool same_screen; /* same screen flag */
+} XButtonEvent;
+typedef XButtonEvent XButtonPressedEvent;
+typedef XButtonEvent XButtonReleasedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ char is_hint; /* detail */
+ Bool same_screen; /* same screen flag */
+} XMotionEvent;
+typedef XMotionEvent XPointerMovedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */
+ int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear,NotifyNonlinearVirtual
+ */
+ Bool same_screen; /* same screen flag */
+ Bool focus; /* boolean focus */
+ unsigned int state; /* key or button mask */
+} XCrossingEvent;
+typedef XCrossingEvent XEnterWindowEvent;
+typedef XCrossingEvent XLeaveWindowEvent;
+
+typedef struct {
+ int type; /* FocusIn or FocusOut */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* window of event */
+ int mode; /* NotifyNormal, NotifyWhileGrabbed,
+ NotifyGrab, NotifyUngrab */
+ int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
+ * NotifyPointerRoot, NotifyDetailNone
+ */
+} XFocusChangeEvent;
+typedef XFocusChangeEvent XFocusInEvent;
+typedef XFocusChangeEvent XFocusOutEvent;
+
+/* generated on EnterWindow and FocusIn when KeyMapState selected */
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ char key_vector[32];
+} XKeymapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int x, y;
+ int width, height;
+ int count; /* if non-zero, at least this many more */
+} XExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable;
+ int x, y;
+ int width, height;
+ int count; /* if non-zero, at least this many more */
+ int major_code; /* core is CopyArea or CopyPlane */
+ int minor_code; /* not defined in the core */
+} XGraphicsExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable;
+ int major_code; /* core is CopyArea or CopyPlane */
+ int minor_code; /* not defined in the core */
+} XNoExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int state; /* Visibility state */
+} XVisibilityEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent; /* parent of the window */
+ Window window; /* window id of window created */
+ int x, y; /* window location */
+ int width, height; /* size of window */
+ int border_width; /* border width */
+ Bool override_redirect; /* creation should be overridden */
+} XCreateWindowEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+} XDestroyWindowEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Bool from_configure;
+} XUnmapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Bool override_redirect; /* boolean, is override set... */
+} XMapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+} XMapRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Window parent;
+ int x, y;
+ Bool override_redirect;
+} XReparentEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int x, y;
+ int width, height;
+ int border_width;
+ Window above;
+ Bool override_redirect;
+} XConfigureEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int x, y;
+} XGravityEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int width, height;
+} XResizeRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+ int x, y;
+ int width, height;
+ int border_width;
+ Window above;
+ int detail; /* Above, Below, TopIf, BottomIf, Opposite */
+ unsigned long value_mask;
+} XConfigureRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int place; /* PlaceOnTop, PlaceOnBottom */
+} XCirculateEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+ int place; /* PlaceOnTop, PlaceOnBottom */
+} XCirculateRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom atom;
+ Time time;
+ int state; /* NewValue, Deleted */
+} XPropertyEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom selection;
+ Time time;
+} XSelectionClearEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window owner;
+ Window requestor;
+ Atom selection;
+ Atom target;
+ Atom property;
+ Time time;
+} XSelectionRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window requestor;
+ Atom selection;
+ Atom target;
+ Atom property; /* ATOM or None */
+ Time time;
+} XSelectionEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Colormap colormap; /* COLORMAP or None */
+#if defined(__cplusplus) || defined(c_plusplus)
+ Bool c_new; /* C++ */
+#else
+ Bool new;
+#endif
+ int state; /* ColormapInstalled, ColormapUninstalled */
+} XColormapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom message_type;
+ int format;
+ union {
+ char b[20];
+ short s[10];
+ long l[5];
+ } data;
+} XClientMessageEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* unused */
+ int request; /* one of MappingModifier, MappingKeyboard,
+ MappingPointer */
+ int first_keycode; /* first keycode */
+ int count; /* defines range of change w. first_keycode*/
+} XMappingEvent;
+
+typedef struct {
+ int type;
+ Display *display; /* Display the event was read from */
+ XID resourceid; /* resource id */
+ unsigned long serial; /* serial number of failed request */
+ unsigned char error_code; /* error code of failed request */
+ unsigned char request_code; /* Major op-code of failed request */
+ unsigned char minor_code; /* Minor op-code of failed request */
+} XErrorEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display;/* Display the event was read from */
+ Window window; /* window on which event was requested in event mask */
+} XAnyEvent;
+
+/*
+ * this union is defined so Xlib can always use the same sized
+ * event structure internally, to avoid memory fragmentation.
+ */
+typedef union _XEvent {
+ int type; /* must not be changed; first element */
+ XAnyEvent xany;
+ XKeyEvent xkey;
+ XButtonEvent xbutton;
+ XMotionEvent xmotion;
+ XCrossingEvent xcrossing;
+ XFocusChangeEvent xfocus;
+ XExposeEvent xexpose;
+ XGraphicsExposeEvent xgraphicsexpose;
+ XNoExposeEvent xnoexpose;
+ XVisibilityEvent xvisibility;
+ XCreateWindowEvent xcreatewindow;
+ XDestroyWindowEvent xdestroywindow;
+ XUnmapEvent xunmap;
+ XMapEvent xmap;
+ XMapRequestEvent xmaprequest;
+ XReparentEvent xreparent;
+ XConfigureEvent xconfigure;
+ XGravityEvent xgravity;
+ XResizeRequestEvent xresizerequest;
+ XConfigureRequestEvent xconfigurerequest;
+ XCirculateEvent xcirculate;
+ XCirculateRequestEvent xcirculaterequest;
+ XPropertyEvent xproperty;
+ XSelectionClearEvent xselectionclear;
+ XSelectionRequestEvent xselectionrequest;
+ XSelectionEvent xselection;
+ XColormapEvent xcolormap;
+ XClientMessageEvent xclient;
+ XMappingEvent xmapping;
+ XErrorEvent xerror;
+ XKeymapEvent xkeymap;
+ long pad[24];
+} XEvent;
+#endif
+
+#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy)))
+
+/*
+ * per character font metric information.
+ */
+typedef struct {
+ short lbearing; /* origin to left edge of raster */
+ short rbearing; /* origin to right edge of raster */
+ short width; /* advance to next char's origin */
+ short ascent; /* baseline to top edge of raster */
+ short descent; /* baseline to bottom edge of raster */
+ unsigned short attributes; /* per char flags (not predefined) */
+} XCharStruct;
+
+/*
+ * To allow arbitrary information with fonts, there are additional properties
+ * returned.
+ */
+typedef struct {
+ Atom name;
+ unsigned long card32;
+} XFontProp;
+
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ Font fid; /* Font id for this font */
+ unsigned direction; /* hint about direction the font is painted */
+ unsigned min_char_or_byte2;/* first character */
+ unsigned max_char_or_byte2;/* last character */
+ unsigned min_byte1; /* first row that exists */
+ unsigned max_byte1; /* last row that exists */
+ Bool all_chars_exist;/* flag if all characters have non-zero size*/
+ unsigned default_char; /* char to print for undefined character */
+ int n_properties; /* how many properties there are */
+ XFontProp *properties; /* pointer to array of additional properties*/
+ XCharStruct min_bounds; /* minimum bounds over all existing char*/
+ XCharStruct max_bounds; /* maximum bounds over all existing char*/
+ XCharStruct *per_char; /* first_char to last_char information */
+ int ascent; /* log. extent above baseline for spacing */
+ int descent; /* log. descent below baseline for spacing */
+} XFontStruct;
+
+/*
+ * PolyText routines take these as arguments.
+ */
+typedef struct {
+ char *chars; /* pointer to string */
+ int nchars; /* number of characters */
+ int delta; /* delta between strings */
+ Font font; /* font to print it in, None don't change */
+} XTextItem;
+
+typedef struct { /* normal 16 bit characters are two bytes */
+ unsigned char byte1;
+ unsigned char byte2;
+} XChar2b;
+
+typedef struct {
+ XChar2b *chars; /* two byte characters */
+ int nchars; /* number of characters */
+ int delta; /* delta between strings */
+ Font font; /* font to print it in, None don't change */
+} XTextItem16;
+
+
+typedef union { Display *display;
+ GC gc;
+ Visual *visual;
+ Screen *screen;
+ ScreenFormat *pixmap_format;
+ XFontStruct *font; } XEDataObject;
+
+typedef struct {
+ XRectangle max_ink_extent;
+ XRectangle max_logical_extent;
+} XFontSetExtents;
+
+/* unused:
+typedef void (*XOMProc)();
+ */
+
+typedef struct _XOM *XOM;
+typedef struct _XOC *XOC, *XFontSet;
+
+typedef struct {
+ char *chars;
+ int nchars;
+ int delta;
+ XFontSet font_set;
+} XmbTextItem;
+
+typedef struct {
+ wchar_t *chars;
+ int nchars;
+ int delta;
+ XFontSet font_set;
+} XwcTextItem;
+
+#define XNRequiredCharSet "requiredCharSet"
+#define XNQueryOrientation "queryOrientation"
+#define XNBaseFontName "baseFontName"
+#define XNOMAutomatic "omAutomatic"
+#define XNMissingCharSet "missingCharSet"
+#define XNDefaultString "defaultString"
+#define XNOrientation "orientation"
+#define XNDirectionalDependentDrawing "directionalDependentDrawing"
+#define XNContextualDrawing "contextualDrawing"
+#define XNFontInfo "fontInfo"
+
+typedef struct {
+ int charset_count;
+ char **charset_list;
+} XOMCharSetList;
+
+typedef enum {
+ XOMOrientation_LTR_TTB,
+ XOMOrientation_RTL_TTB,
+ XOMOrientation_TTB_LTR,
+ XOMOrientation_TTB_RTL,
+ XOMOrientation_Context
+} XOrientation;
+
+typedef struct {
+ int num_orientation;
+ XOrientation *orientation; /* Input Text description */
+} XOMOrientation;
+
+typedef struct {
+ int num_font;
+ XFontStruct **font_struct_list;
+ char **font_name_list;
+} XOMFontInfo;
+
+typedef struct _XIM *XIM;
+typedef struct _XIC *XIC;
+
+typedef void (*XIMProc)(
+ XIM,
+ XPointer,
+ XPointer
+);
+
+typedef Bool (*XICProc)(
+ XIC,
+ XPointer,
+ XPointer
+);
+
+typedef void (*XIDProc)(
+ Display*,
+ XPointer,
+ XPointer
+);
+
+typedef unsigned long XIMStyle;
+
+typedef struct {
+ unsigned short count_styles;
+ XIMStyle *supported_styles;
+} XIMStyles;
+
+#define XIMPreeditArea 0x0001L
+#define XIMPreeditCallbacks 0x0002L
+#define XIMPreeditPosition 0x0004L
+#define XIMPreeditNothing 0x0008L
+#define XIMPreeditNone 0x0010L
+#define XIMStatusArea 0x0100L
+#define XIMStatusCallbacks 0x0200L
+#define XIMStatusNothing 0x0400L
+#define XIMStatusNone 0x0800L
+
+#define XNVaNestedList "XNVaNestedList"
+#define XNQueryInputStyle "queryInputStyle"
+#define XNClientWindow "clientWindow"
+#define XNInputStyle "inputStyle"
+#define XNFocusWindow "focusWindow"
+#define XNResourceName "resourceName"
+#define XNResourceClass "resourceClass"
+#define XNGeometryCallback "geometryCallback"
+#define XNDestroyCallback "destroyCallback"
+#define XNFilterEvents "filterEvents"
+#define XNPreeditStartCallback "preeditStartCallback"
+#define XNPreeditDoneCallback "preeditDoneCallback"
+#define XNPreeditDrawCallback "preeditDrawCallback"
+#define XNPreeditCaretCallback "preeditCaretCallback"
+#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback"
+#define XNPreeditAttributes "preeditAttributes"
+#define XNStatusStartCallback "statusStartCallback"
+#define XNStatusDoneCallback "statusDoneCallback"
+#define XNStatusDrawCallback "statusDrawCallback"
+#define XNStatusAttributes "statusAttributes"
+#define XNArea "area"
+#define XNAreaNeeded "areaNeeded"
+#define XNSpotLocation "spotLocation"
+#define XNColormap "colorMap"
+#define XNStdColormap "stdColorMap"
+#define XNForeground "foreground"
+#define XNBackground "background"
+#define XNBackgroundPixmap "backgroundPixmap"
+#define XNFontSet "fontSet"
+#define XNLineSpace "lineSpace"
+#define XNCursor "cursor"
+
+#define XNQueryIMValuesList "queryIMValuesList"
+#define XNQueryICValuesList "queryICValuesList"
+#define XNVisiblePosition "visiblePosition"
+#define XNR6PreeditCallback "r6PreeditCallback"
+#define XNStringConversionCallback "stringConversionCallback"
+#define XNStringConversion "stringConversion"
+#define XNResetState "resetState"
+#define XNHotKey "hotKey"
+#define XNHotKeyState "hotKeyState"
+#define XNPreeditState "preeditState"
+#define XNSeparatorofNestedList "separatorofNestedList"
+
+#define XBufferOverflow -1
+#define XLookupNone 1
+#define XLookupChars 2
+#define XLookupKeySym 3
+#define XLookupBoth 4
+
+typedef void *XVaNestedList;
+
+typedef struct {
+ XPointer client_data;
+ XIMProc callback;
+} XIMCallback;
+
+typedef struct {
+ XPointer client_data;
+ XICProc callback;
+} XICCallback;
+
+typedef unsigned long XIMFeedback;
+
+#define XIMReverse 1L
+#define XIMUnderline (1L<<1)
+#define XIMHighlight (1L<<2)
+#define XIMPrimary (1L<<5)
+#define XIMSecondary (1L<<6)
+#define XIMTertiary (1L<<7)
+#define XIMVisibleToForward (1L<<8)
+#define XIMVisibleToBackword (1L<<9)
+#define XIMVisibleToCenter (1L<<10)
+
+typedef struct _XIMText {
+ unsigned short length;
+ XIMFeedback *feedback;
+ Bool encoding_is_wchar;
+ union {
+ char *multi_byte;
+ wchar_t *wide_char;
+ } string;
+} XIMText;
+
+typedef unsigned long XIMPreeditState;
+
+#define XIMPreeditUnKnown 0L
+#define XIMPreeditEnable 1L
+#define XIMPreeditDisable (1L<<1)
+
+typedef struct _XIMPreeditStateNotifyCallbackStruct {
+ XIMPreeditState state;
+} XIMPreeditStateNotifyCallbackStruct;
+
+typedef unsigned long XIMResetState;
+
+#define XIMInitialState 1L
+#define XIMPreserveState (1L<<1)
+
+typedef unsigned long XIMStringConversionFeedback;
+
+#define XIMStringConversionLeftEdge (0x00000001)
+#define XIMStringConversionRightEdge (0x00000002)
+#define XIMStringConversionTopEdge (0x00000004)
+#define XIMStringConversionBottomEdge (0x00000008)
+#define XIMStringConversionConcealed (0x00000010)
+#define XIMStringConversionWrapped (0x00000020)
+
+typedef struct _XIMStringConversionText {
+ unsigned short length;
+ XIMStringConversionFeedback *feedback;
+ Bool encoding_is_wchar;
+ union {
+ char *mbs;
+ wchar_t *wcs;
+ } string;
+} XIMStringConversionText;
+
+typedef unsigned short XIMStringConversionPosition;
+
+typedef unsigned short XIMStringConversionType;
+
+#define XIMStringConversionBuffer (0x0001)
+#define XIMStringConversionLine (0x0002)
+#define XIMStringConversionWord (0x0003)
+#define XIMStringConversionChar (0x0004)
+
+typedef unsigned short XIMStringConversionOperation;
+
+#define XIMStringConversionSubstitution (0x0001)
+#define XIMStringConversionRetrieval (0x0002)
+
+typedef enum {
+ XIMForwardChar, XIMBackwardChar,
+ XIMForwardWord, XIMBackwardWord,
+ XIMCaretUp, XIMCaretDown,
+ XIMNextLine, XIMPreviousLine,
+ XIMLineStart, XIMLineEnd,
+ XIMAbsolutePosition,
+ XIMDontChange
+} XIMCaretDirection;
+
+typedef struct _XIMStringConversionCallbackStruct {
+ XIMStringConversionPosition position;
+ XIMCaretDirection direction;
+ XIMStringConversionOperation operation;
+ unsigned short factor;
+ XIMStringConversionText *text;
+} XIMStringConversionCallbackStruct;
+
+typedef struct _XIMPreeditDrawCallbackStruct {
+ int caret; /* Cursor offset within pre-edit string */
+ int chg_first; /* Starting change position */
+ int chg_length; /* Length of the change in character count */
+ XIMText *text;
+} XIMPreeditDrawCallbackStruct;
+
+typedef enum {
+ XIMIsInvisible, /* Disable caret feedback */
+ XIMIsPrimary, /* UI defined caret feedback */
+ XIMIsSecondary /* UI defined caret feedback */
+} XIMCaretStyle;
+
+typedef struct _XIMPreeditCaretCallbackStruct {
+ int position; /* Caret offset within pre-edit string */
+ XIMCaretDirection direction; /* Caret moves direction */
+ XIMCaretStyle style; /* Feedback of the caret */
+} XIMPreeditCaretCallbackStruct;
+
+typedef enum {
+ XIMTextType,
+ XIMBitmapType
+} XIMStatusDataType;
+
+typedef struct _XIMStatusDrawCallbackStruct {
+ XIMStatusDataType type;
+ union {
+ XIMText *text;
+ Pixmap bitmap;
+ } data;
+} XIMStatusDrawCallbackStruct;
+
+typedef struct _XIMHotKeyTrigger {
+ KeySym keysym;
+ int modifier;
+ int modifier_mask;
+} XIMHotKeyTrigger;
+
+typedef struct _XIMHotKeyTriggers {
+ int num_hot_key;
+ XIMHotKeyTrigger *key;
+} XIMHotKeyTriggers;
+
+typedef unsigned long XIMHotKeyState;
+
+#define XIMHotKeyStateON (0x0001L)
+#define XIMHotKeyStateOFF (0x0002L)
+
+typedef struct {
+ unsigned short count_values;
+ char **supported_values;
+} XIMValuesList;
+
+_XFUNCPROTOBEGIN
+
+#if defined(WIN32) && !defined(_XLIBINT_)
+#define _Xdebug (*_Xdebug_p)
+#endif
+
+extern int _Xdebug;
+
+extern XFontStruct *XLoadQueryFont(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+
+extern XFontStruct *XQueryFont(
+ Display* /* display */,
+ XID /* font_ID */
+);
+
+
+extern XTimeCoord *XGetMotionEvents(
+ Display* /* display */,
+ Window /* w */,
+ Time /* start */,
+ Time /* stop */,
+ int* /* nevents_return */
+);
+
+extern XModifierKeymap *XDeleteModifiermapEntry(
+ XModifierKeymap* /* modmap */,
+#if NeedWidePrototypes
+ unsigned int /* keycode_entry */,
+#else
+ KeyCode /* keycode_entry */,
+#endif
+ int /* modifier */
+);
+
+extern XModifierKeymap *XGetModifierMapping(
+ Display* /* display */
+);
+
+extern XModifierKeymap *XInsertModifiermapEntry(
+ XModifierKeymap* /* modmap */,
+#if NeedWidePrototypes
+ unsigned int /* keycode_entry */,
+#else
+ KeyCode /* keycode_entry */,
+#endif
+ int /* modifier */
+);
+
+extern XModifierKeymap *XNewModifiermap(
+ int /* max_keys_per_mod */
+);
+
+extern XImage *XCreateImage(
+ Display* /* display */,
+ Visual* /* visual */,
+ unsigned int /* depth */,
+ int /* format */,
+ int /* offset */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* bitmap_pad */,
+ int /* bytes_per_line */
+);
+extern Status XInitImage(
+ XImage* /* image */
+);
+extern XImage *XGetImage(
+ Display* /* display */,
+ Drawable /* d */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* plane_mask */,
+ int /* format */
+);
+extern XImage *XGetSubImage(
+ Display* /* display */,
+ Drawable /* d */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* plane_mask */,
+ int /* format */,
+ XImage* /* dest_image */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+/*
+ * X function declarations.
+ */
+extern Display *XOpenDisplay(
+ _Xconst char* /* display_name */
+);
+
+extern void XrmInitialize(
+ void
+);
+
+extern char *XFetchBytes(
+ Display* /* display */,
+ int* /* nbytes_return */
+);
+extern char *XFetchBuffer(
+ Display* /* display */,
+ int* /* nbytes_return */,
+ int /* buffer */
+);
+extern char *XGetAtomName(
+ Display* /* display */,
+ Atom /* atom */
+);
+extern Status XGetAtomNames(
+ Display* /* dpy */,
+ Atom* /* atoms */,
+ int /* count */,
+ char** /* names_return */
+);
+extern char *XGetDefault(
+ Display* /* display */,
+ _Xconst char* /* program */,
+ _Xconst char* /* option */
+);
+extern char *XDisplayName(
+ _Xconst char* /* string */
+);
+extern char *XKeysymToString(
+ KeySym /* keysym */
+);
+
+extern int (*XSynchronize(
+ Display* /* display */,
+ Bool /* onoff */
+))(
+ Display* /* display */
+);
+extern int (*XSetAfterFunction(
+ Display* /* display */,
+ int (*) (
+ Display* /* display */
+ ) /* procedure */
+))(
+ Display* /* display */
+);
+extern Atom XInternAtom(
+ Display* /* display */,
+ _Xconst char* /* atom_name */,
+ Bool /* only_if_exists */
+);
+extern Status XInternAtoms(
+ Display* /* dpy */,
+ char** /* names */,
+ int /* count */,
+ Bool /* onlyIfExists */,
+ Atom* /* atoms_return */
+);
+extern Colormap XCopyColormapAndFree(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+extern Colormap XCreateColormap(
+ Display* /* display */,
+ Window /* w */,
+ Visual* /* visual */,
+ int /* alloc */
+);
+extern Cursor XCreatePixmapCursor(
+ Display* /* display */,
+ Pixmap /* source */,
+ Pixmap /* mask */,
+ XColor* /* foreground_color */,
+ XColor* /* background_color */,
+ unsigned int /* x */,
+ unsigned int /* y */
+);
+extern Cursor XCreateGlyphCursor(
+ Display* /* display */,
+ Font /* source_font */,
+ Font /* mask_font */,
+ unsigned int /* source_char */,
+ unsigned int /* mask_char */,
+ XColor _Xconst * /* foreground_color */,
+ XColor _Xconst * /* background_color */
+);
+extern Cursor XCreateFontCursor(
+ Display* /* display */,
+ unsigned int /* shape */
+);
+extern Font XLoadFont(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+extern GC XCreateGC(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values */
+);
+extern GContext XGContextFromGC(
+ GC /* gc */
+);
+extern void XFlushGC(
+ Display* /* display */,
+ GC /* gc */
+);
+extern Pixmap XCreatePixmap(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* depth */
+);
+extern Pixmap XCreateBitmapFromData(
+ Display* /* display */,
+ Drawable /* d */,
+ _Xconst char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+extern Pixmap XCreatePixmapFromBitmapData(
+ Display* /* display */,
+ Drawable /* d */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* fg */,
+ unsigned long /* bg */,
+ unsigned int /* depth */
+);
+extern Window XCreateSimpleWindow(
+ Display* /* display */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* border_width */,
+ unsigned long /* border */,
+ unsigned long /* background */
+);
+extern Window XGetSelectionOwner(
+ Display* /* display */,
+ Atom /* selection */
+);
+extern Window XCreateWindow(
+ Display* /* display */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* border_width */,
+ int /* depth */,
+ unsigned int /* class */,
+ Visual* /* visual */,
+ unsigned long /* valuemask */,
+ XSetWindowAttributes* /* attributes */
+);
+extern Colormap *XListInstalledColormaps(
+ Display* /* display */,
+ Window /* w */,
+ int* /* num_return */
+);
+extern char **XListFonts(
+ Display* /* display */,
+ _Xconst char* /* pattern */,
+ int /* maxnames */,
+ int* /* actual_count_return */
+);
+extern char **XListFontsWithInfo(
+ Display* /* display */,
+ _Xconst char* /* pattern */,
+ int /* maxnames */,
+ int* /* count_return */,
+ XFontStruct** /* info_return */
+);
+extern char **XGetFontPath(
+ Display* /* display */,
+ int* /* npaths_return */
+);
+extern char **XListExtensions(
+ Display* /* display */,
+ int* /* nextensions_return */
+);
+extern Atom *XListProperties(
+ Display* /* display */,
+ Window /* w */,
+ int* /* num_prop_return */
+);
+extern XHostAddress *XListHosts(
+ Display* /* display */,
+ int* /* nhosts_return */,
+ Bool* /* state_return */
+);
+extern KeySym XKeycodeToKeysym(
+ Display* /* display */,
+#if NeedWidePrototypes
+ unsigned int /* keycode */,
+#else
+ KeyCode /* keycode */,
+#endif
+ int /* index */
+);
+extern KeySym XLookupKeysym(
+ XKeyEvent* /* key_event */,
+ int /* index */
+);
+extern KeySym *XGetKeyboardMapping(
+ Display* /* display */,
+#if NeedWidePrototypes
+ unsigned int /* first_keycode */,
+#else
+ KeyCode /* first_keycode */,
+#endif
+ int /* keycode_count */,
+ int* /* keysyms_per_keycode_return */
+);
+extern KeySym XStringToKeysym(
+ _Xconst char* /* string */
+);
+extern long XMaxRequestSize(
+ Display* /* display */
+);
+extern long XExtendedMaxRequestSize(
+ Display* /* display */
+);
+extern char *XResourceManagerString(
+ Display* /* display */
+);
+extern char *XScreenResourceString(
+ Screen* /* screen */
+);
+extern unsigned long XDisplayMotionBufferSize(
+ Display* /* display */
+);
+extern VisualID XVisualIDFromVisual(
+ Visual* /* visual */
+);
+
+/* multithread routines */
+
+extern Status XInitThreads(
+ void
+);
+
+extern void XLockDisplay(
+ Display* /* display */
+);
+
+extern void XUnlockDisplay(
+ Display* /* display */
+);
+
+/* routines for dealing with extensions */
+
+extern XExtCodes *XInitExtension(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+
+extern XExtCodes *XAddExtension(
+ Display* /* display */
+);
+extern XExtData *XFindOnExtensionList(
+ XExtData** /* structure */,
+ int /* number */
+);
+extern XExtData **XEHeadOfExtensionList(
+ XEDataObject /* object */
+);
+
+/* these are routines for which there are also macros */
+extern Window XRootWindow(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Window XDefaultRootWindow(
+ Display* /* display */
+);
+extern Window XRootWindowOfScreen(
+ Screen* /* screen */
+);
+extern Visual *XDefaultVisual(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Visual *XDefaultVisualOfScreen(
+ Screen* /* screen */
+);
+extern GC XDefaultGC(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern GC XDefaultGCOfScreen(
+ Screen* /* screen */
+);
+extern unsigned long XBlackPixel(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern unsigned long XWhitePixel(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern unsigned long XAllPlanes(
+ void
+);
+extern unsigned long XBlackPixelOfScreen(
+ Screen* /* screen */
+);
+extern unsigned long XWhitePixelOfScreen(
+ Screen* /* screen */
+);
+extern unsigned long XNextRequest(
+ Display* /* display */
+);
+extern unsigned long XLastKnownRequestProcessed(
+ Display* /* display */
+);
+extern char *XServerVendor(
+ Display* /* display */
+);
+extern char *XDisplayString(
+ Display* /* display */
+);
+extern Colormap XDefaultColormap(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Colormap XDefaultColormapOfScreen(
+ Screen* /* screen */
+);
+extern Display *XDisplayOfScreen(
+ Screen* /* screen */
+);
+extern Screen *XScreenOfDisplay(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Screen *XDefaultScreenOfDisplay(
+ Display* /* display */
+);
+extern long XEventMaskOfScreen(
+ Screen* /* screen */
+);
+
+extern int XScreenNumberOfScreen(
+ Screen* /* screen */
+);
+
+typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */
+ Display* /* display */,
+ XErrorEvent* /* error_event */
+);
+
+extern XErrorHandler XSetErrorHandler (
+ XErrorHandler /* handler */
+);
+
+
+typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */
+ Display* /* display */
+);
+
+extern XIOErrorHandler XSetIOErrorHandler (
+ XIOErrorHandler /* handler */
+);
+
+
+extern XPixmapFormatValues *XListPixmapFormats(
+ Display* /* display */,
+ int* /* count_return */
+);
+extern int *XListDepths(
+ Display* /* display */,
+ int /* screen_number */,
+ int* /* count_return */
+);
+
+/* ICCCM routines for things that don't require special include files; */
+/* other declarations are given in Xutil.h */
+extern Status XReconfigureWMWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */,
+ unsigned int /* mask */,
+ XWindowChanges* /* changes */
+);
+
+extern Status XGetWMProtocols(
+ Display* /* display */,
+ Window /* w */,
+ Atom** /* protocols_return */,
+ int* /* count_return */
+);
+extern Status XSetWMProtocols(
+ Display* /* display */,
+ Window /* w */,
+ Atom* /* protocols */,
+ int /* count */
+);
+extern Status XIconifyWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */
+);
+extern Status XWithdrawWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */
+);
+extern Status XGetCommand(
+ Display* /* display */,
+ Window /* w */,
+ char*** /* argv_return */,
+ int* /* argc_return */
+);
+extern Status XGetWMColormapWindows(
+ Display* /* display */,
+ Window /* w */,
+ Window** /* windows_return */,
+ int* /* count_return */
+);
+extern Status XSetWMColormapWindows(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* colormap_windows */,
+ int /* count */
+);
+extern void XFreeStringList(
+ char** /* list */
+);
+extern int XSetTransientForHint(
+ Display* /* display */,
+ Window /* w */,
+ Window /* prop_window */
+);
+
+/* The following are given in alphabetical order */
+
+extern int XActivateScreenSaver(
+ Display* /* display */
+);
+
+extern int XAddHost(
+ Display* /* display */,
+ XHostAddress* /* host */
+);
+
+extern int XAddHosts(
+ Display* /* display */,
+ XHostAddress* /* hosts */,
+ int /* num_hosts */
+);
+
+extern int XAddToExtensionList(
+ struct _XExtData** /* structure */,
+ XExtData* /* ext_data */
+);
+
+extern int XAddToSaveSet(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern Status XAllocColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* screen_in_out */
+);
+
+extern Status XAllocColorCells(
+ Display* /* display */,
+ Colormap /* colormap */,
+ Bool /* contig */,
+ unsigned long* /* plane_masks_return */,
+ unsigned int /* nplanes */,
+ unsigned long* /* pixels_return */,
+ unsigned int /* npixels */
+);
+
+extern Status XAllocColorPlanes(
+ Display* /* display */,
+ Colormap /* colormap */,
+ Bool /* contig */,
+ unsigned long* /* pixels_return */,
+ int /* ncolors */,
+ int /* nreds */,
+ int /* ngreens */,
+ int /* nblues */,
+ unsigned long* /* rmask_return */,
+ unsigned long* /* gmask_return */,
+ unsigned long* /* bmask_return */
+);
+
+extern Status XAllocNamedColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_name */,
+ XColor* /* screen_def_return */,
+ XColor* /* exact_def_return */
+);
+
+extern int XAllowEvents(
+ Display* /* display */,
+ int /* event_mode */,
+ Time /* time */
+);
+
+extern int XAutoRepeatOff(
+ Display* /* display */
+);
+
+extern int XAutoRepeatOn(
+ Display* /* display */
+);
+
+extern int XBell(
+ Display* /* display */,
+ int /* percent */
+);
+
+extern int XBitmapBitOrder(
+ Display* /* display */
+);
+
+extern int XBitmapPad(
+ Display* /* display */
+);
+
+extern int XBitmapUnit(
+ Display* /* display */
+);
+
+extern int XCellsOfScreen(
+ Screen* /* screen */
+);
+
+extern int XChangeActivePointerGrab(
+ Display* /* display */,
+ unsigned int /* event_mask */,
+ Cursor /* cursor */,
+ Time /* time */
+);
+
+extern int XChangeGC(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values */
+);
+
+extern int XChangeKeyboardControl(
+ Display* /* display */,
+ unsigned long /* value_mask */,
+ XKeyboardControl* /* values */
+);
+
+extern int XChangeKeyboardMapping(
+ Display* /* display */,
+ int /* first_keycode */,
+ int /* keysyms_per_keycode */,
+ KeySym* /* keysyms */,
+ int /* num_codes */
+);
+
+extern int XChangePointerControl(
+ Display* /* display */,
+ Bool /* do_accel */,
+ Bool /* do_threshold */,
+ int /* accel_numerator */,
+ int /* accel_denominator */,
+ int /* threshold */
+);
+
+extern int XChangeProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */,
+ Atom /* type */,
+ int /* format */,
+ int /* mode */,
+ _Xconst unsigned char* /* data */,
+ int /* nelements */
+);
+
+extern int XChangeSaveSet(
+ Display* /* display */,
+ Window /* w */,
+ int /* change_mode */
+);
+
+extern int XChangeWindowAttributes(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* valuemask */,
+ XSetWindowAttributes* /* attributes */
+);
+
+extern Bool XCheckIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+#ifdef NX_TRANS_SOCKET
+
+/*
+ * This is just like XCheckIfEvent() but doesn't
+ * flush the output buffer if it can't read new
+ * events.
+ */
+
+extern Bool XCheckIfEventNoFlush(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+#endif
+
+extern Bool XCheckMaskEvent(
+ Display* /* display */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern Bool XCheckTypedEvent(
+ Display* /* display */,
+ int /* event_type */,
+ XEvent* /* event_return */
+);
+
+extern Bool XCheckTypedWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ int /* event_type */,
+ XEvent* /* event_return */
+);
+
+extern Bool XCheckWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern int XCirculateSubwindows(
+ Display* /* display */,
+ Window /* w */,
+ int /* direction */
+);
+
+extern int XCirculateSubwindowsDown(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XCirculateSubwindowsUp(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XClearArea(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ Bool /* exposures */
+);
+
+extern int XClearWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XCloseDisplay(
+ Display* /* display */
+);
+
+extern int XConfigureWindow(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* value_mask */,
+ XWindowChanges* /* values */
+);
+
+extern int XConnectionNumber(
+ Display* /* display */
+);
+
+extern int XConvertSelection(
+ Display* /* display */,
+ Atom /* selection */,
+ Atom /* target */,
+ Atom /* property */,
+ Window /* requestor */,
+ Time /* time */
+);
+
+extern int XCopyArea(
+ Display* /* display */,
+ Drawable /* src */,
+ Drawable /* dest */,
+ GC /* gc */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+extern int XCopyGC(
+ Display* /* display */,
+ GC /* src */,
+ unsigned long /* valuemask */,
+ GC /* dest */
+);
+
+extern int XCopyPlane(
+ Display* /* display */,
+ Drawable /* src */,
+ Drawable /* dest */,
+ GC /* gc */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* dest_x */,
+ int /* dest_y */,
+ unsigned long /* plane */
+);
+
+extern int XDefaultDepth(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDefaultDepthOfScreen(
+ Screen* /* screen */
+);
+
+extern int XDefaultScreen(
+ Display* /* display */
+);
+
+extern int XDefineCursor(
+ Display* /* display */,
+ Window /* w */,
+ Cursor /* cursor */
+);
+
+extern int XDeleteProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */
+);
+
+extern int XDestroyWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XDestroySubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XDoesBackingStore(
+ Screen* /* screen */
+);
+
+extern Bool XDoesSaveUnders(
+ Screen* /* screen */
+);
+
+extern int XDisableAccessControl(
+ Display* /* display */
+);
+
+
+extern int XDisplayCells(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayHeight(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayHeightMM(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayKeycodes(
+ Display* /* display */,
+ int* /* min_keycodes_return */,
+ int* /* max_keycodes_return */
+);
+
+extern int XDisplayPlanes(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayWidth(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayWidthMM(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDrawArc(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* angle1 */,
+ int /* angle2 */
+);
+
+extern int XDrawArcs(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XArc* /* arcs */,
+ int /* narcs */
+);
+
+extern int XDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* string */,
+ int /* length */
+);
+
+extern int XDrawImageString16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst XChar2b* /* string */,
+ int /* length */
+);
+
+extern int XDrawLine(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x1 */,
+ int /* y1 */,
+ int /* x2 */,
+ int /* y2 */
+);
+
+extern int XDrawLines(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* mode */
+);
+
+extern int XDrawPoint(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */
+);
+
+extern int XDrawPoints(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* mode */
+);
+
+extern int XDrawRectangle(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XDrawRectangles(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XRectangle* /* rectangles */,
+ int /* nrectangles */
+);
+
+extern int XDrawSegments(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XSegment* /* segments */,
+ int /* nsegments */
+);
+
+extern int XDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* string */,
+ int /* length */
+);
+
+extern int XDrawString16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst XChar2b* /* string */,
+ int /* length */
+);
+
+extern int XDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XTextItem* /* items */,
+ int /* nitems */
+);
+
+extern int XDrawText16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XTextItem16* /* items */,
+ int /* nitems */
+);
+
+extern int XEnableAccessControl(
+ Display* /* display */
+);
+
+extern int XEventsQueued(
+ Display* /* display */,
+ int /* mode */
+);
+
+extern Status XFetchName(
+ Display* /* display */,
+ Window /* w */,
+ char** /* window_name_return */
+);
+
+extern int XFillArc(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* angle1 */,
+ int /* angle2 */
+);
+
+extern int XFillArcs(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XArc* /* arcs */,
+ int /* narcs */
+);
+
+extern int XFillPolygon(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* shape */,
+ int /* mode */
+);
+
+extern int XFillRectangle(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XFillRectangles(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XRectangle* /* rectangles */,
+ int /* nrectangles */
+);
+
+extern int XFlush(
+ Display* /* display */
+);
+
+extern int XForceScreenSaver(
+ Display* /* display */,
+ int /* mode */
+);
+
+extern int XFree(
+ void* /* data */
+);
+
+extern int XFreeColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+extern int XFreeColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ unsigned long* /* pixels */,
+ int /* npixels */,
+ unsigned long /* planes */
+);
+
+extern int XFreeCursor(
+ Display* /* display */,
+ Cursor /* cursor */
+);
+
+extern int XFreeExtensionList(
+ char** /* list */
+);
+
+extern int XFreeFont(
+ Display* /* display */,
+ XFontStruct* /* font_struct */
+);
+
+extern int XFreeFontInfo(
+ char** /* names */,
+ XFontStruct* /* free_info */,
+ int /* actual_count */
+);
+
+extern int XFreeFontNames(
+ char** /* list */
+);
+
+extern int XFreeFontPath(
+ char** /* list */
+);
+
+extern int XFreeGC(
+ Display* /* display */,
+ GC /* gc */
+);
+
+extern int XFreeModifiermap(
+ XModifierKeymap* /* modmap */
+);
+
+extern int XFreePixmap(
+ Display* /* display */,
+ Pixmap /* pixmap */
+);
+
+extern int XGeometry(
+ Display* /* display */,
+ int /* screen */,
+ _Xconst char* /* position */,
+ _Xconst char* /* default_position */,
+ unsigned int /* bwidth */,
+ unsigned int /* fwidth */,
+ unsigned int /* fheight */,
+ int /* xadder */,
+ int /* yadder */,
+ int* /* x_return */,
+ int* /* y_return */,
+ int* /* width_return */,
+ int* /* height_return */
+);
+
+extern int XGetErrorDatabaseText(
+ Display* /* display */,
+ _Xconst char* /* name */,
+ _Xconst char* /* message */,
+ _Xconst char* /* default_string */,
+ char* /* buffer_return */,
+ int /* length */
+);
+
+extern int XGetErrorText(
+ Display* /* display */,
+ int /* code */,
+ char* /* buffer_return */,
+ int /* length */
+);
+
+extern Bool XGetFontProperty(
+ XFontStruct* /* font_struct */,
+ Atom /* atom */,
+ unsigned long* /* value_return */
+);
+
+extern Status XGetGCValues(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values_return */
+);
+
+extern Status XGetGeometry(
+ Display* /* display */,
+ Drawable /* d */,
+ Window* /* root_return */,
+ int* /* x_return */,
+ int* /* y_return */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned int* /* border_width_return */,
+ unsigned int* /* depth_return */
+);
+
+extern Status XGetIconName(
+ Display* /* display */,
+ Window /* w */,
+ char** /* icon_name_return */
+);
+
+extern int XGetInputFocus(
+ Display* /* display */,
+ Window* /* focus_return */,
+ int* /* revert_to_return */
+);
+
+extern int XGetKeyboardControl(
+ Display* /* display */,
+ XKeyboardState* /* values_return */
+);
+
+extern int XGetPointerControl(
+ Display* /* display */,
+ int* /* accel_numerator_return */,
+ int* /* accel_denominator_return */,
+ int* /* threshold_return */
+);
+
+extern int XGetPointerMapping(
+ Display* /* display */,
+ unsigned char* /* map_return */,
+ int /* nmap */
+);
+
+extern int XGetScreenSaver(
+ Display* /* display */,
+ int* /* timeout_return */,
+ int* /* interval_return */,
+ int* /* prefer_blanking_return */,
+ int* /* allow_exposures_return */
+);
+
+extern Status XGetTransientForHint(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* prop_window_return */
+);
+
+extern int XGetWindowProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */,
+ long /* long_offset */,
+ long /* long_length */,
+ Bool /* delete */,
+ Atom /* req_type */,
+ Atom* /* actual_type_return */,
+ int* /* actual_format_return */,
+ unsigned long* /* nitems_return */,
+ unsigned long* /* bytes_after_return */,
+ unsigned char** /* prop_return */
+);
+
+extern Status XGetWindowAttributes(
+ Display* /* display */,
+ Window /* w */,
+ XWindowAttributes* /* window_attributes_return */
+);
+
+extern int XGrabButton(
+ Display* /* display */,
+ unsigned int /* button */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */
+);
+
+extern int XGrabKey(
+ Display* /* display */,
+ int /* keycode */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */
+);
+
+extern int XGrabKeyboard(
+ Display* /* display */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Time /* time */
+);
+
+extern int XGrabPointer(
+ Display* /* display */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */,
+ Time /* time */
+);
+
+extern int XGrabServer(
+ Display* /* display */
+);
+
+extern int XHeightMMOfScreen(
+ Screen* /* screen */
+);
+
+extern int XHeightOfScreen(
+ Screen* /* screen */
+);
+
+extern int XIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+extern int XImageByteOrder(
+ Display* /* display */
+);
+
+extern int XInstallColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+extern KeyCode XKeysymToKeycode(
+ Display* /* display */,
+ KeySym /* keysym */
+);
+
+extern int XKillClient(
+ Display* /* display */,
+ XID /* resource */
+);
+
+extern Status XLookupColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_name */,
+ XColor* /* exact_def_return */,
+ XColor* /* screen_def_return */
+);
+
+extern int XLowerWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMapRaised(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMapSubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMapWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMaskEvent(
+ Display* /* display */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern int XMaxCmapsOfScreen(
+ Screen* /* screen */
+);
+
+extern int XMinCmapsOfScreen(
+ Screen* /* screen */
+);
+
+extern int XMoveResizeWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XMoveWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */
+);
+
+extern int XNextEvent(
+ Display* /* display */,
+ XEvent* /* event_return */
+);
+
+extern int XNoOp(
+ Display* /* display */
+);
+
+extern Status XParseColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* spec */,
+ XColor* /* exact_def_return */
+);
+
+extern int XParseGeometry(
+ _Xconst char* /* parsestring */,
+ int* /* x_return */,
+ int* /* y_return */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern int XPeekEvent(
+ Display* /* display */,
+ XEvent* /* event_return */
+);
+
+extern int XPeekIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+extern int XPending(
+ Display* /* display */
+);
+
+extern int XPlanesOfScreen(
+ Screen* /* screen */
+);
+
+extern int XProtocolRevision(
+ Display* /* display */
+);
+
+extern int XProtocolVersion(
+ Display* /* display */
+);
+
+
+extern int XPutBackEvent(
+ Display* /* display */,
+ XEvent* /* event */
+);
+
+extern int XPutImage(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XImage* /* image */,
+ int /* src_x */,
+ int /* src_y */,
+ int /* dest_x */,
+ int /* dest_y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XQLength(
+ Display* /* display */
+);
+
+extern Status XQueryBestCursor(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern Status XQueryBestSize(
+ Display* /* display */,
+ int /* class */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern Status XQueryBestStipple(
+ Display* /* display */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern Status XQueryBestTile(
+ Display* /* display */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern int XQueryColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* def_in_out */
+);
+
+extern int XQueryColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* defs_in_out */,
+ int /* ncolors */
+);
+
+extern Bool XQueryExtension(
+ Display* /* display */,
+ _Xconst char* /* name */,
+ int* /* major_opcode_return */,
+ int* /* first_event_return */,
+ int* /* first_error_return */
+);
+
+extern int XQueryKeymap(
+ Display* /* display */,
+ char [32] /* keys_return */
+);
+
+extern Bool XQueryPointer(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* root_return */,
+ Window* /* child_return */,
+ int* /* root_x_return */,
+ int* /* root_y_return */,
+ int* /* win_x_return */,
+ int* /* win_y_return */,
+ unsigned int* /* mask_return */
+);
+
+extern int XQueryTextExtents(
+ Display* /* display */,
+ XID /* font_ID */,
+ _Xconst char* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern int XQueryTextExtents16(
+ Display* /* display */,
+ XID /* font_ID */,
+ _Xconst XChar2b* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern Status XQueryTree(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* root_return */,
+ Window* /* parent_return */,
+ Window** /* children_return */,
+ unsigned int* /* nchildren_return */
+);
+
+extern int XRaiseWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XReadBitmapFile(
+ Display* /* display */,
+ Drawable /* d */,
+ _Xconst char* /* filename */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ Pixmap* /* bitmap_return */,
+ int* /* x_hot_return */,
+ int* /* y_hot_return */
+);
+
+extern int XReadBitmapFileData(
+ _Xconst char* /* filename */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned char** /* data_return */,
+ int* /* x_hot_return */,
+ int* /* y_hot_return */
+);
+
+extern int XRebindKeysym(
+ Display* /* display */,
+ KeySym /* keysym */,
+ KeySym* /* list */,
+ int /* mod_count */,
+ _Xconst unsigned char* /* string */,
+ int /* bytes_string */
+);
+
+extern int XRecolorCursor(
+ Display* /* display */,
+ Cursor /* cursor */,
+ XColor* /* foreground_color */,
+ XColor* /* background_color */
+);
+
+extern int XRefreshKeyboardMapping(
+ XMappingEvent* /* event_map */
+);
+
+extern int XRemoveFromSaveSet(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XRemoveHost(
+ Display* /* display */,
+ XHostAddress* /* host */
+);
+
+extern int XRemoveHosts(
+ Display* /* display */,
+ XHostAddress* /* hosts */,
+ int /* num_hosts */
+);
+
+extern int XReparentWindow(
+ Display* /* display */,
+ Window /* w */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */
+);
+
+extern int XResetScreenSaver(
+ Display* /* display */
+);
+
+extern int XResizeWindow(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XRestackWindows(
+ Display* /* display */,
+ Window* /* windows */,
+ int /* nwindows */
+);
+
+extern int XRotateBuffers(
+ Display* /* display */,
+ int /* rotate */
+);
+
+extern int XRotateWindowProperties(
+ Display* /* display */,
+ Window /* w */,
+ Atom* /* properties */,
+ int /* num_prop */,
+ int /* npositions */
+);
+
+extern int XScreenCount(
+ Display* /* display */
+);
+
+extern int XSelectInput(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */
+);
+
+extern Status XSendEvent(
+ Display* /* display */,
+ Window /* w */,
+ Bool /* propagate */,
+ long /* event_mask */,
+ XEvent* /* event_send */
+);
+
+extern int XSetAccessControl(
+ Display* /* display */,
+ int /* mode */
+);
+
+extern int XSetArcMode(
+ Display* /* display */,
+ GC /* gc */,
+ int /* arc_mode */
+);
+
+extern int XSetBackground(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* background */
+);
+
+extern int XSetClipMask(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* pixmap */
+);
+
+extern int XSetClipOrigin(
+ Display* /* display */,
+ GC /* gc */,
+ int /* clip_x_origin */,
+ int /* clip_y_origin */
+);
+
+extern int XSetClipRectangles(
+ Display* /* display */,
+ GC /* gc */,
+ int /* clip_x_origin */,
+ int /* clip_y_origin */,
+ XRectangle* /* rectangles */,
+ int /* n */,
+ int /* ordering */
+);
+
+extern int XSetCloseDownMode(
+ Display* /* display */,
+ int /* close_mode */
+);
+
+extern int XSetCommand(
+ Display* /* display */,
+ Window /* w */,
+ char** /* argv */,
+ int /* argc */
+);
+
+extern int XSetDashes(
+ Display* /* display */,
+ GC /* gc */,
+ int /* dash_offset */,
+ _Xconst char* /* dash_list */,
+ int /* n */
+);
+
+extern int XSetFillRule(
+ Display* /* display */,
+ GC /* gc */,
+ int /* fill_rule */
+);
+
+extern int XSetFillStyle(
+ Display* /* display */,
+ GC /* gc */,
+ int /* fill_style */
+);
+
+extern int XSetFont(
+ Display* /* display */,
+ GC /* gc */,
+ Font /* font */
+);
+
+extern int XSetFontPath(
+ Display* /* display */,
+ char** /* directories */,
+ int /* ndirs */
+);
+
+extern int XSetForeground(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* foreground */
+);
+
+extern int XSetFunction(
+ Display* /* display */,
+ GC /* gc */,
+ int /* function */
+);
+
+extern int XSetGraphicsExposures(
+ Display* /* display */,
+ GC /* gc */,
+ Bool /* graphics_exposures */
+);
+
+extern int XSetIconName(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* icon_name */
+);
+
+extern int XSetInputFocus(
+ Display* /* display */,
+ Window /* focus */,
+ int /* revert_to */,
+ Time /* time */
+);
+
+extern int XSetLineAttributes(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned int /* line_width */,
+ int /* line_style */,
+ int /* cap_style */,
+ int /* join_style */
+);
+
+extern int XSetModifierMapping(
+ Display* /* display */,
+ XModifierKeymap* /* modmap */
+);
+
+extern int XSetPlaneMask(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* plane_mask */
+);
+
+extern int XSetPointerMapping(
+ Display* /* display */,
+ _Xconst unsigned char* /* map */,
+ int /* nmap */
+);
+
+extern int XSetScreenSaver(
+ Display* /* display */,
+ int /* timeout */,
+ int /* interval */,
+ int /* prefer_blanking */,
+ int /* allow_exposures */
+);
+
+extern int XSetSelectionOwner(
+ Display* /* display */,
+ Atom /* selection */,
+ Window /* owner */,
+ Time /* time */
+);
+
+extern int XSetState(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* foreground */,
+ unsigned long /* background */,
+ int /* function */,
+ unsigned long /* plane_mask */
+);
+
+extern int XSetStipple(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* stipple */
+);
+
+extern int XSetSubwindowMode(
+ Display* /* display */,
+ GC /* gc */,
+ int /* subwindow_mode */
+);
+
+extern int XSetTSOrigin(
+ Display* /* display */,
+ GC /* gc */,
+ int /* ts_x_origin */,
+ int /* ts_y_origin */
+);
+
+extern int XSetTile(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* tile */
+);
+
+extern int XSetWindowBackground(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* background_pixel */
+);
+
+extern int XSetWindowBackgroundPixmap(
+ Display* /* display */,
+ Window /* w */,
+ Pixmap /* background_pixmap */
+);
+
+extern int XSetWindowBorder(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* border_pixel */
+);
+
+extern int XSetWindowBorderPixmap(
+ Display* /* display */,
+ Window /* w */,
+ Pixmap /* border_pixmap */
+);
+
+extern int XSetWindowBorderWidth(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* width */
+);
+
+extern int XSetWindowColormap(
+ Display* /* display */,
+ Window /* w */,
+ Colormap /* colormap */
+);
+
+extern int XStoreBuffer(
+ Display* /* display */,
+ _Xconst char* /* bytes */,
+ int /* nbytes */,
+ int /* buffer */
+);
+
+extern int XStoreBytes(
+ Display* /* display */,
+ _Xconst char* /* bytes */,
+ int /* nbytes */
+);
+
+extern int XStoreColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* color */
+);
+
+extern int XStoreColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* color */,
+ int /* ncolors */
+);
+
+extern int XStoreName(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* window_name */
+);
+
+extern int XStoreNamedColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color */,
+ unsigned long /* pixel */,
+ int /* flags */
+);
+
+extern int XSync(
+ Display* /* display */,
+ Bool /* discard */
+);
+
+extern int XTextExtents(
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern int XTextExtents16(
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern int XTextWidth(
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* count */
+);
+
+extern int XTextWidth16(
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* count */
+);
+
+extern Bool XTranslateCoordinates(
+ Display* /* display */,
+ Window /* src_w */,
+ Window /* dest_w */,
+ int /* src_x */,
+ int /* src_y */,
+ int* /* dest_x_return */,
+ int* /* dest_y_return */,
+ Window* /* child_return */
+);
+
+extern int XUndefineCursor(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XUngrabButton(
+ Display* /* display */,
+ unsigned int /* button */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */
+);
+
+extern int XUngrabKey(
+ Display* /* display */,
+ int /* keycode */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */
+);
+
+extern int XUngrabKeyboard(
+ Display* /* display */,
+ Time /* time */
+);
+
+extern int XUngrabPointer(
+ Display* /* display */,
+ Time /* time */
+);
+
+extern int XUngrabServer(
+ Display* /* display */
+);
+
+extern int XUninstallColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+extern int XUnloadFont(
+ Display* /* display */,
+ Font /* font */
+);
+
+extern int XUnmapSubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XUnmapWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XVendorRelease(
+ Display* /* display */
+);
+
+extern int XWarpPointer(
+ Display* /* display */,
+ Window /* src_w */,
+ Window /* dest_w */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* src_width */,
+ unsigned int /* src_height */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+extern int XWidthMMOfScreen(
+ Screen* /* screen */
+);
+
+extern int XWidthOfScreen(
+ Screen* /* screen */
+);
+
+extern int XWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern int XWriteBitmapFile(
+ Display* /* display */,
+ _Xconst char* /* filename */,
+ Pixmap /* bitmap */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* x_hot */,
+ int /* y_hot */
+);
+
+extern Bool XSupportsLocale (void);
+
+extern char *XSetLocaleModifiers(
+ const char* /* modifier_list */
+);
+
+extern XOM XOpenOM(
+ Display* /* display */,
+ struct _XrmHashBucketRec* /* rdb */,
+ _Xconst char* /* res_name */,
+ _Xconst char* /* res_class */
+);
+
+extern Status XCloseOM(
+ XOM /* om */
+);
+
+extern char *XSetOMValues(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+extern char *XGetOMValues(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+extern Display *XDisplayOfOM(
+ XOM /* om */
+);
+
+extern char *XLocaleOfOM(
+ XOM /* om */
+);
+
+extern XOC XCreateOC(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+extern void XDestroyOC(
+ XOC /* oc */
+);
+
+extern XOM XOMOfOC(
+ XOC /* oc */
+);
+
+extern char *XSetOCValues(
+ XOC /* oc */,
+ ...
+) _X_SENTINEL(0);
+
+extern char *XGetOCValues(
+ XOC /* oc */,
+ ...
+) _X_SENTINEL(0);
+
+extern XFontSet XCreateFontSet(
+ Display* /* display */,
+ _Xconst char* /* base_font_name_list */,
+ char*** /* missing_charset_list */,
+ int* /* missing_charset_count */,
+ char** /* def_string */
+);
+
+extern void XFreeFontSet(
+ Display* /* display */,
+ XFontSet /* font_set */
+);
+
+extern int XFontsOfFontSet(
+ XFontSet /* font_set */,
+ XFontStruct*** /* font_struct_list */,
+ char*** /* font_name_list */
+);
+
+extern char *XBaseFontNameListOfFontSet(
+ XFontSet /* font_set */
+);
+
+extern char *XLocaleOfFontSet(
+ XFontSet /* font_set */
+);
+
+extern Bool XContextDependentDrawing(
+ XFontSet /* font_set */
+);
+
+extern Bool XDirectionalDependentDrawing(
+ XFontSet /* font_set */
+);
+
+extern Bool XContextualDrawing(
+ XFontSet /* font_set */
+);
+
+extern XFontSetExtents *XExtentsOfFontSet(
+ XFontSet /* font_set */
+);
+
+extern int XmbTextEscapement(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern int XwcTextEscapement(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+extern int Xutf8TextEscapement(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern int XmbTextExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern int XwcTextExtents(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern int Xutf8TextExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern Status XmbTextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern Status XwcTextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern Status Xutf8TextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern void XmbDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XmbTextItem* /* text_items */,
+ int /* nitems */
+);
+
+extern void XwcDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XwcTextItem* /* text_items */,
+ int /* nitems */
+);
+
+extern void Xutf8DrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XmbTextItem* /* text_items */,
+ int /* nitems */
+);
+
+extern void XmbDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern void XwcDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+extern void Xutf8DrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern void XmbDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern void XwcDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+extern void Xutf8DrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern XIM XOpenIM(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */
+);
+
+extern Status XCloseIM(
+ XIM /* im */
+);
+
+extern char *XGetIMValues(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+extern char *XSetIMValues(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+extern Display *XDisplayOfIM(
+ XIM /* im */
+);
+
+extern char *XLocaleOfIM(
+ XIM /* im*/
+);
+
+extern XIC XCreateIC(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+extern void XDestroyIC(
+ XIC /* ic */
+);
+
+extern void XSetICFocus(
+ XIC /* ic */
+);
+
+extern void XUnsetICFocus(
+ XIC /* ic */
+);
+
+extern wchar_t *XwcResetIC(
+ XIC /* ic */
+);
+
+extern char *XmbResetIC(
+ XIC /* ic */
+);
+
+extern char *Xutf8ResetIC(
+ XIC /* ic */
+);
+
+extern char *XSetICValues(
+ XIC /* ic */, ...
+) _X_SENTINEL(0);
+
+extern char *XGetICValues(
+ XIC /* ic */, ...
+) _X_SENTINEL(0);
+
+extern XIM XIMOfIC(
+ XIC /* ic */
+);
+
+extern Bool XFilterEvent(
+ XEvent* /* event */,
+ Window /* window */
+);
+
+extern int XmbLookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ char* /* buffer_return */,
+ int /* bytes_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+extern int XwcLookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ wchar_t* /* buffer_return */,
+ int /* wchars_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+extern int Xutf8LookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ char* /* buffer_return */,
+ int /* bytes_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+extern XVaNestedList XVaCreateNestedList(
+ int /*unused*/, ...
+) _X_SENTINEL(0);
+
+/* internal connections for IMs */
+
+extern Bool XRegisterIMInstantiateCallback(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIDProc /* callback */,
+ XPointer /* client_data */
+);
+
+extern Bool XUnregisterIMInstantiateCallback(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIDProc /* callback */,
+ XPointer /* client_data */
+);
+
+typedef void (*XConnectionWatchProc)(
+ Display* /* dpy */,
+ XPointer /* client_data */,
+ int /* fd */,
+ Bool /* opening */, /* open or close flag */
+ XPointer* /* watch_data */ /* open sets, close uses */
+);
+
+
+extern Status XInternalConnectionNumbers(
+ Display* /* dpy */,
+ int** /* fd_return */,
+ int* /* count_return */
+);
+
+extern void XProcessInternalConnection(
+ Display* /* dpy */,
+ int /* fd */
+);
+
+extern Status XAddConnectionWatch(
+ Display* /* dpy */,
+ XConnectionWatchProc /* callback */,
+ XPointer /* client_data */
+);
+
+extern void XRemoveConnectionWatch(
+ Display* /* dpy */,
+ XConnectionWatchProc /* callback */,
+ XPointer /* client_data */
+);
+
+extern void XSetAuthorization(
+ char * /* name */,
+ int /* namelen */,
+ char * /* data */,
+ int /* datalen */
+);
+
+extern int _Xmbtowc(
+ wchar_t * /* wstr */,
+#ifdef ISC
+ char const * /* str */,
+ size_t /* len */
+#else
+ char * /* str */,
+ int /* len */
+#endif
+);
+
+extern int _Xwctomb(
+ char * /* str */,
+ wchar_t /* wc */
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XLIB_H_ */
diff --git a/nx-X11/lib/X11/Xlib.h.X.original b/nx-X11/lib/X11/Xlib.h.X.original
new file mode 100644
index 000000000..b1535f9b1
--- /dev/null
+++ b/nx-X11/lib/X11/Xlib.h.X.original
@@ -0,0 +1,4008 @@
+/* $XdotOrg: xc/lib/X11/Xlib.h,v 1.6 2005/11/08 06:33:25 jkj Exp $ */
+/* $Xorg: Xlib.h,v 1.6 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1986, 1987, 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.
+
+*/
+/* $XFree86: xc/lib/X11/Xlib.h,v 3.25 2003/11/17 22:20:10 dawes Exp $ */
+
+
+/*
+ * Xlib.h - Header definition and support file for the C subroutine
+ * interface library (Xlib) to the X Window System Protocol (V11).
+ * Structures and symbols starting with "_" are private to the library.
+ */
+#ifndef _XLIB_H_
+#define _XLIB_H_
+
+#define XlibSpecificationRelease 6
+
+#ifdef USG
+#ifndef __TYPES__
+#include <sys/types.h> /* forgot to protect it... */
+#define __TYPES__
+#endif /* __TYPES__ */
+#else
+#if defined(_POSIX_SOURCE) && defined(MOTOROLA)
+#undef _POSIX_SOURCE
+#include <sys/types.h>
+#define _POSIX_SOURCE
+#else
+#include <sys/types.h>
+#endif
+#endif /* USG */
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#include <stdint.h>
+#endif
+
+#include <X11/X.h>
+
+/* applications should not depend on these two headers being included! */
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+
+#ifndef X_WCHAR
+#ifdef X_NOT_STDC_ENV
+#ifndef ISC
+#define X_WCHAR
+#endif
+#endif
+#endif
+
+#ifndef X_WCHAR
+#include <stddef.h>
+#else
+#ifdef __UNIXOS2__
+#include <stdlib.h>
+#else
+/* replace this with #include or typedef appropriate for your system */
+typedef unsigned long wchar_t;
+#endif
+#endif
+
+#if defined(ISC) && defined(USE_XMBTOWC)
+#define wctomb(a,b) _Xwctomb(a,b)
+#define mblen(a,b) _Xmblen(a,b)
+#ifndef USE_XWCHAR_STRING
+#define mbtowc(a,b,c) _Xmbtowc(a,b,c)
+#endif
+#endif
+
+extern int
+_Xmblen(
+#ifdef ISC
+ char const *str,
+ size_t len
+#else
+ char *str,
+ int len
+#endif
+ );
+
+/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in
+ November 2000. Its presence is indicated through the following macro. */
+#define X_HAVE_UTF8_STRING 1
+
+typedef char *XPointer;
+
+#define Bool int
+#define Status int
+#define True 1
+#define False 0
+
+#define QueuedAlready 0
+#define QueuedAfterReading 1
+#define QueuedAfterFlush 2
+
+#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd)
+#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root)
+#define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen)
+#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root)
+#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual)
+#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc)
+#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel)
+#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel)
+#define AllPlanes ((unsigned long)~0L)
+#define QLength(dpy) (((_XPrivDisplay)dpy)->qlen)
+#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width)
+#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height)
+#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth)
+#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight)
+#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
+#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries)
+#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens)
+#define ServerVendor(dpy) (((_XPrivDisplay)dpy)->vendor)
+#define ProtocolVersion(dpy) (((_XPrivDisplay)dpy)->proto_major_version)
+#define ProtocolRevision(dpy) (((_XPrivDisplay)dpy)->proto_minor_version)
+#define VendorRelease(dpy) (((_XPrivDisplay)dpy)->release)
+#define DisplayString(dpy) (((_XPrivDisplay)dpy)->display_name)
+#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
+#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap)
+#define BitmapUnit(dpy) (((_XPrivDisplay)dpy)->bitmap_unit)
+#define BitmapBitOrder(dpy) (((_XPrivDisplay)dpy)->bitmap_bit_order)
+#define BitmapPad(dpy) (((_XPrivDisplay)dpy)->bitmap_pad)
+#define ImageByteOrder(dpy) (((_XPrivDisplay)dpy)->byte_order)
+#ifdef CRAY /* unable to get WORD64 without pulling in other symbols */
+#define NextRequest(dpy) XNextRequest(dpy)
+#else
+#define NextRequest(dpy) (((_XPrivDisplay)dpy)->request + 1)
+#endif
+#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)dpy)->last_request_read)
+
+/* macros for screen oriented applications (toolkit) */
+#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr])
+#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy))
+#define DisplayOfScreen(s) ((s)->display)
+#define RootWindowOfScreen(s) ((s)->root)
+#define BlackPixelOfScreen(s) ((s)->black_pixel)
+#define WhitePixelOfScreen(s) ((s)->white_pixel)
+#define DefaultColormapOfScreen(s)((s)->cmap)
+#define DefaultDepthOfScreen(s) ((s)->root_depth)
+#define DefaultGCOfScreen(s) ((s)->default_gc)
+#define DefaultVisualOfScreen(s)((s)->root_visual)
+#define WidthOfScreen(s) ((s)->width)
+#define HeightOfScreen(s) ((s)->height)
+#define WidthMMOfScreen(s) ((s)->mwidth)
+#define HeightMMOfScreen(s) ((s)->mheight)
+#define PlanesOfScreen(s) ((s)->root_depth)
+#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries)
+#define MinCmapsOfScreen(s) ((s)->min_maps)
+#define MaxCmapsOfScreen(s) ((s)->max_maps)
+#define DoesSaveUnders(s) ((s)->save_unders)
+#define DoesBackingStore(s) ((s)->backing_store)
+#define EventMaskOfScreen(s) ((s)->root_input_mask)
+
+/*
+ * Extensions need a way to hang private data on some structures.
+ */
+typedef struct _XExtData {
+ int number; /* number returned by XRegisterExtension */
+ struct _XExtData *next; /* next item on list of data for structure */
+ int (*free_private)( /* called to free private storage */
+ struct _XExtData *extension
+ );
+ XPointer private_data; /* data private to this extension. */
+} XExtData;
+
+/*
+ * This file contains structures used by the extension mechanism.
+ */
+typedef struct { /* public to extension, cannot be changed */
+ int extension; /* extension number */
+ int major_opcode; /* major op-code assigned by server */
+ int first_event; /* first event number for the extension */
+ int first_error; /* first error number for the extension */
+} XExtCodes;
+
+/*
+ * Data structure for retrieving info about pixmap formats.
+ */
+
+typedef struct {
+ int depth;
+ int bits_per_pixel;
+ int scanline_pad;
+} XPixmapFormatValues;
+
+
+/*
+ * Data structure for setting graphics context.
+ */
+typedef struct {
+ int function; /* logical operation */
+ unsigned long plane_mask;/* plane mask */
+ unsigned long foreground;/* foreground pixel */
+ unsigned long background;/* background pixel */
+ int line_width; /* line width */
+ int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */
+ int cap_style; /* CapNotLast, CapButt,
+ CapRound, CapProjecting */
+ int join_style; /* JoinMiter, JoinRound, JoinBevel */
+ int fill_style; /* FillSolid, FillTiled,
+ FillStippled, FillOpaeueStippled */
+ int fill_rule; /* EvenOddRule, WindingRule */
+ int arc_mode; /* ArcChord, ArcPieSlice */
+ Pixmap tile; /* tile pixmap for tiling operations */
+ Pixmap stipple; /* stipple 1 plane pixmap for stipping */
+ int ts_x_origin; /* offset for tile or stipple operations */
+ int ts_y_origin;
+ Font font; /* default text font for text operations */
+ int subwindow_mode; /* ClipByChildren, IncludeInferiors */
+ Bool graphics_exposures;/* boolean, should exposures be generated */
+ int clip_x_origin; /* origin for clipping */
+ int clip_y_origin;
+ Pixmap clip_mask; /* bitmap clipping; other calls for rects */
+ int dash_offset; /* patterned/dashed line information */
+ char dashes;
+} XGCValues;
+
+/*
+ * Graphics context. The contents of this structure are implementation
+ * dependent. A GC should be treated as opaque by application code.
+ */
+
+typedef struct _XGC
+#ifdef XLIB_ILLEGAL_ACCESS
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ GContext gid; /* protocol ID for graphics context */
+ /* there is more to this structure, but it is private to Xlib */
+}
+#endif
+*GC;
+
+/*
+ * Visual structure; contains information about colormapping possible.
+ */
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ VisualID visualid; /* visual id of this visual */
+#if defined(__cplusplus) || defined(c_plusplus)
+ int c_class; /* C++ class of screen (monochrome, etc.) */
+#else
+ int class; /* class of screen (monochrome, etc.) */
+#endif
+ unsigned long red_mask, green_mask, blue_mask; /* mask values */
+ int bits_per_rgb; /* log base 2 of distinct color values */
+ int map_entries; /* color map entries */
+} Visual;
+
+/*
+ * Depth structure; contains information for each possible depth.
+ */
+typedef struct {
+ int depth; /* this depth (Z) of the depth */
+ int nvisuals; /* number of Visual types at this depth */
+ Visual *visuals; /* list of visuals possible at this depth */
+} Depth;
+
+/*
+ * Information about the screen. The contents of this structure are
+ * implementation dependent. A Screen should be treated as opaque
+ * by application code.
+ */
+
+struct _XDisplay; /* Forward declare before use for C++ */
+
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XDisplay *display;/* back pointer to display structure */
+ Window root; /* Root window id. */
+ int width, height; /* width and height of screen */
+ int mwidth, mheight; /* width and height of in millimeters */
+ int ndepths; /* number of depths possible */
+ Depth *depths; /* list of allowable depths on the screen */
+ int root_depth; /* bits per pixel */
+ Visual *root_visual; /* root visual */
+ GC default_gc; /* GC for the root root visual */
+ Colormap cmap; /* default color map */
+ unsigned long white_pixel;
+ unsigned long black_pixel; /* White and Black pixel values */
+ int max_maps, min_maps; /* max and min color maps */
+ int backing_store; /* Never, WhenMapped, Always */
+ Bool save_unders;
+ long root_input_mask; /* initial root input mask */
+} Screen;
+
+/*
+ * Format structure; describes ZFormat data the screen will understand.
+ */
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ int depth; /* depth of this image format */
+ int bits_per_pixel; /* bits/pixel at this depth */
+ int scanline_pad; /* scanline must padded to this multiple */
+} ScreenFormat;
+
+/*
+ * Data structure for setting window attributes.
+ */
+typedef struct {
+ Pixmap background_pixmap; /* background or None or ParentRelative */
+ unsigned long background_pixel; /* background pixel */
+ Pixmap border_pixmap; /* border of the window */
+ unsigned long border_pixel; /* border pixel value */
+ int bit_gravity; /* one of bit gravity values */
+ int win_gravity; /* one of the window gravity values */
+ int backing_store; /* NotUseful, WhenMapped, Always */
+ unsigned long backing_planes;/* planes to be preseved if possible */
+ unsigned long backing_pixel;/* value to use in restoring planes */
+ Bool save_under; /* should bits under be saved? (popups) */
+ long event_mask; /* set of events that should be saved */
+ long do_not_propagate_mask; /* set of events that should not propagate */
+ Bool override_redirect; /* boolean value for override-redirect */
+ Colormap colormap; /* color map to be associated with window */
+ Cursor cursor; /* cursor to be displayed (or None) */
+} XSetWindowAttributes;
+
+typedef struct {
+ int x, y; /* location of window */
+ int width, height; /* width and height of window */
+ int border_width; /* border width of window */
+ int depth; /* depth of window */
+ Visual *visual; /* the associated visual structure */
+ Window root; /* root of screen containing window */
+#if defined(__cplusplus) || defined(c_plusplus)
+ int c_class; /* C++ InputOutput, InputOnly*/
+#else
+ int class; /* InputOutput, InputOnly*/
+#endif
+ int bit_gravity; /* one of bit gravity values */
+ int win_gravity; /* one of the window gravity values */
+ int backing_store; /* NotUseful, WhenMapped, Always */
+ unsigned long backing_planes;/* planes to be preserved if possible */
+ unsigned long backing_pixel;/* value to be used when restoring planes */
+ Bool save_under; /* boolean, should bits under be saved? */
+ Colormap colormap; /* color map to be associated with window */
+ Bool map_installed; /* boolean, is color map currently installed*/
+ int map_state; /* IsUnmapped, IsUnviewable, IsViewable */
+ long all_event_masks; /* set of events all people have interest in*/
+ long your_event_mask; /* my event mask */
+ long do_not_propagate_mask; /* set of events that should not propagate */
+ Bool override_redirect; /* boolean value for override-redirect */
+ Screen *screen; /* back pointer to correct screen */
+} XWindowAttributes;
+
+/*
+ * Data structure for host setting; getting routines.
+ *
+ */
+
+typedef struct {
+ int family; /* for example FamilyInternet */
+ int length; /* length of address, in bytes */
+ char *address; /* pointer to where to find the bytes */
+} XHostAddress;
+
+/*
+ * Data structure for ServerFamilyInterpreted addresses in host routines
+ */
+typedef struct {
+ int typelength; /* length of type string, in bytes */
+ int valuelength; /* length of value string, in bytes */
+ char *type; /* pointer to where to find the type string */
+ char *value; /* pointer to where to find the address */
+} XServerInterpretedAddress;
+
+/*
+ * Data structure for "image" data, used by image manipulation routines.
+ */
+typedef struct _XImage {
+ int width, height; /* size of image */
+ int xoffset; /* number of pixels offset in X direction */
+ int format; /* XYBitmap, XYPixmap, ZPixmap */
+ char *data; /* pointer to image data */
+ int byte_order; /* data byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* quant. of scanline 8, 16, 32 */
+ int bitmap_bit_order; /* LSBFirst, MSBFirst */
+ int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */
+ int depth; /* depth of image */
+ int bytes_per_line; /* accelarator to next line */
+ int bits_per_pixel; /* bits per pixel (ZPixmap) */
+ unsigned long red_mask; /* bits in z arrangment */
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ XPointer obdata; /* hook for the object routines to hang on */
+ struct funcs { /* image manipulation routines */
+ struct _XImage *(*create_image)(
+ struct _XDisplay* /* display */,
+ Visual* /* visual */,
+ unsigned int /* depth */,
+ int /* format */,
+ int /* offset */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* bitmap_pad */,
+ int /* bytes_per_line */);
+ int (*destroy_image) (struct _XImage *);
+ unsigned long (*get_pixel) (struct _XImage *, int, int);
+ int (*put_pixel) (struct _XImage *, int, int, unsigned long);
+ struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int);
+ int (*add_pixel) (struct _XImage *, long);
+ } f;
+} XImage;
+
+/*
+ * Data structure for XReconfigureWindow
+ */
+typedef struct {
+ int x, y;
+ int width, height;
+ int border_width;
+ Window sibling;
+ int stack_mode;
+} XWindowChanges;
+
+/*
+ * Data structure used by color operations
+ */
+typedef struct {
+ unsigned long pixel;
+ unsigned short red, green, blue;
+ char flags; /* do_red, do_green, do_blue */
+ char pad;
+} XColor;
+
+/*
+ * Data structures for graphics operations. On most machines, these are
+ * congruent with the wire protocol structures, so reformatting the data
+ * can be avoided on these architectures.
+ */
+typedef struct {
+ short x1, y1, x2, y2;
+} XSegment;
+
+typedef struct {
+ short x, y;
+} XPoint;
+
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+} XRectangle;
+
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+ short angle1, angle2;
+} XArc;
+
+
+/* Data structure for XChangeKeyboardControl */
+
+typedef struct {
+ int key_click_percent;
+ int bell_percent;
+ int bell_pitch;
+ int bell_duration;
+ int led;
+ int led_mode;
+ int key;
+ int auto_repeat_mode; /* On, Off, Default */
+} XKeyboardControl;
+
+/* Data structure for XGetKeyboardControl */
+
+typedef struct {
+ int key_click_percent;
+ int bell_percent;
+ unsigned int bell_pitch, bell_duration;
+ unsigned long led_mask;
+ int global_auto_repeat;
+ char auto_repeats[32];
+} XKeyboardState;
+
+/* Data structure for XGetMotionEvents. */
+
+typedef struct {
+ Time time;
+ short x, y;
+} XTimeCoord;
+
+/* Data structure for X{Set,Get}ModifierMapping */
+
+typedef struct {
+ int max_keypermod; /* The server's max # of keys per modifier */
+ KeyCode *modifiermap; /* An 8 by max_keypermod array of modifiers */
+} XModifierKeymap;
+
+
+/*
+ * Display datatype maintaining display specific data.
+ * The contents of this structure are implementation dependent.
+ * A Display should be treated as opaque by application code.
+ */
+#ifndef XLIB_ILLEGAL_ACCESS
+typedef struct _XDisplay Display;
+#endif
+
+struct _XPrivate; /* Forward declare before use for C++ */
+struct _XrmHashBucketRec;
+
+typedef struct
+#ifdef XLIB_ILLEGAL_ACCESS
+_XDisplay
+#endif
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XPrivate *private1;
+ int fd; /* Network socket. */
+ int private2;
+ int proto_major_version;/* major version of server's X protocol */
+ int proto_minor_version;/* minor version of servers X protocol */
+ char *vendor; /* vendor of the server hardware */
+ XID private3;
+ XID private4;
+ XID private5;
+ int private6;
+ XID (*resource_alloc)( /* allocator function */
+ struct _XDisplay*
+ );
+ int byte_order; /* screen byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* padding and data requirements */
+ int bitmap_pad; /* padding requirements on bitmaps */
+ int bitmap_bit_order; /* LeastSignificant or MostSignificant */
+ int nformats; /* number of pixmap formats in list */
+ ScreenFormat *pixmap_format; /* pixmap format list */
+ int private8;
+ int release; /* release of the server */
+ struct _XPrivate *private9, *private10;
+ int qlen; /* Length of input event queue */
+ unsigned long last_request_read; /* seq number of last event read */
+ unsigned long request; /* sequence number of last request. */
+ XPointer private11;
+ XPointer private12;
+ XPointer private13;
+ XPointer private14;
+ unsigned max_request_size; /* maximum number 32 bit words in request*/
+ struct _XrmHashBucketRec *db;
+ int (*private15)(
+ struct _XDisplay*
+ );
+ char *display_name; /* "host:display" string used on this connect*/
+ int default_screen; /* default screen for operations */
+ int nscreens; /* number of screens on this server*/
+ Screen *screens; /* pointer to list of screens */
+ unsigned long motion_buffer; /* size of motion buffer */
+ unsigned long private16;
+ int min_keycode; /* minimum defined keycode */
+ int max_keycode; /* maximum defined keycode */
+ XPointer private17;
+ XPointer private18;
+ int private19;
+ char *xdefaults; /* contents of defaults from server */
+ /* there is more to this structure, but it is private to Xlib */
+}
+#ifdef XLIB_ILLEGAL_ACCESS
+Display,
+#endif
+*_XPrivDisplay;
+
+#undef _XEVENT_
+#ifndef _XEVENT_
+/*
+ * Definitions of specific events.
+ */
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window it is reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ unsigned int keycode; /* detail */
+ Bool same_screen; /* same screen flag */
+} XKeyEvent;
+typedef XKeyEvent XKeyPressedEvent;
+typedef XKeyEvent XKeyReleasedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window it is reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ unsigned int button; /* detail */
+ Bool same_screen; /* same screen flag */
+} XButtonEvent;
+typedef XButtonEvent XButtonPressedEvent;
+typedef XButtonEvent XButtonReleasedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ char is_hint; /* detail */
+ Bool same_screen; /* same screen flag */
+} XMotionEvent;
+typedef XMotionEvent XPointerMovedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */
+ int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear,NotifyNonlinearVirtual
+ */
+ Bool same_screen; /* same screen flag */
+ Bool focus; /* boolean focus */
+ unsigned int state; /* key or button mask */
+} XCrossingEvent;
+typedef XCrossingEvent XEnterWindowEvent;
+typedef XCrossingEvent XLeaveWindowEvent;
+
+typedef struct {
+ int type; /* FocusIn or FocusOut */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* window of event */
+ int mode; /* NotifyNormal, NotifyWhileGrabbed,
+ NotifyGrab, NotifyUngrab */
+ int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
+ * NotifyPointerRoot, NotifyDetailNone
+ */
+} XFocusChangeEvent;
+typedef XFocusChangeEvent XFocusInEvent;
+typedef XFocusChangeEvent XFocusOutEvent;
+
+/* generated on EnterWindow and FocusIn when KeyMapState selected */
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ char key_vector[32];
+} XKeymapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int x, y;
+ int width, height;
+ int count; /* if non-zero, at least this many more */
+} XExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable;
+ int x, y;
+ int width, height;
+ int count; /* if non-zero, at least this many more */
+ int major_code; /* core is CopyArea or CopyPlane */
+ int minor_code; /* not defined in the core */
+} XGraphicsExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable;
+ int major_code; /* core is CopyArea or CopyPlane */
+ int minor_code; /* not defined in the core */
+} XNoExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int state; /* Visibility state */
+} XVisibilityEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent; /* parent of the window */
+ Window window; /* window id of window created */
+ int x, y; /* window location */
+ int width, height; /* size of window */
+ int border_width; /* border width */
+ Bool override_redirect; /* creation should be overridden */
+} XCreateWindowEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+} XDestroyWindowEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Bool from_configure;
+} XUnmapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Bool override_redirect; /* boolean, is override set... */
+} XMapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+} XMapRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Window parent;
+ int x, y;
+ Bool override_redirect;
+} XReparentEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int x, y;
+ int width, height;
+ int border_width;
+ Window above;
+ Bool override_redirect;
+} XConfigureEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int x, y;
+} XGravityEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int width, height;
+} XResizeRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+ int x, y;
+ int width, height;
+ int border_width;
+ Window above;
+ int detail; /* Above, Below, TopIf, BottomIf, Opposite */
+ unsigned long value_mask;
+} XConfigureRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int place; /* PlaceOnTop, PlaceOnBottom */
+} XCirculateEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+ int place; /* PlaceOnTop, PlaceOnBottom */
+} XCirculateRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom atom;
+ Time time;
+ int state; /* NewValue, Deleted */
+} XPropertyEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom selection;
+ Time time;
+} XSelectionClearEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window owner;
+ Window requestor;
+ Atom selection;
+ Atom target;
+ Atom property;
+ Time time;
+} XSelectionRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window requestor;
+ Atom selection;
+ Atom target;
+ Atom property; /* ATOM or None */
+ Time time;
+} XSelectionEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Colormap colormap; /* COLORMAP or None */
+#if defined(__cplusplus) || defined(c_plusplus)
+ Bool c_new; /* C++ */
+#else
+ Bool new;
+#endif
+ int state; /* ColormapInstalled, ColormapUninstalled */
+} XColormapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom message_type;
+ int format;
+ union {
+ char b[20];
+ short s[10];
+ long l[5];
+ } data;
+} XClientMessageEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* unused */
+ int request; /* one of MappingModifier, MappingKeyboard,
+ MappingPointer */
+ int first_keycode; /* first keycode */
+ int count; /* defines range of change w. first_keycode*/
+} XMappingEvent;
+
+typedef struct {
+ int type;
+ Display *display; /* Display the event was read from */
+ XID resourceid; /* resource id */
+ unsigned long serial; /* serial number of failed request */
+ unsigned char error_code; /* error code of failed request */
+ unsigned char request_code; /* Major op-code of failed request */
+ unsigned char minor_code; /* Minor op-code of failed request */
+} XErrorEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display;/* Display the event was read from */
+ Window window; /* window on which event was requested in event mask */
+} XAnyEvent;
+
+/*
+ * this union is defined so Xlib can always use the same sized
+ * event structure internally, to avoid memory fragmentation.
+ */
+typedef union _XEvent {
+ int type; /* must not be changed; first element */
+ XAnyEvent xany;
+ XKeyEvent xkey;
+ XButtonEvent xbutton;
+ XMotionEvent xmotion;
+ XCrossingEvent xcrossing;
+ XFocusChangeEvent xfocus;
+ XExposeEvent xexpose;
+ XGraphicsExposeEvent xgraphicsexpose;
+ XNoExposeEvent xnoexpose;
+ XVisibilityEvent xvisibility;
+ XCreateWindowEvent xcreatewindow;
+ XDestroyWindowEvent xdestroywindow;
+ XUnmapEvent xunmap;
+ XMapEvent xmap;
+ XMapRequestEvent xmaprequest;
+ XReparentEvent xreparent;
+ XConfigureEvent xconfigure;
+ XGravityEvent xgravity;
+ XResizeRequestEvent xresizerequest;
+ XConfigureRequestEvent xconfigurerequest;
+ XCirculateEvent xcirculate;
+ XCirculateRequestEvent xcirculaterequest;
+ XPropertyEvent xproperty;
+ XSelectionClearEvent xselectionclear;
+ XSelectionRequestEvent xselectionrequest;
+ XSelectionEvent xselection;
+ XColormapEvent xcolormap;
+ XClientMessageEvent xclient;
+ XMappingEvent xmapping;
+ XErrorEvent xerror;
+ XKeymapEvent xkeymap;
+ long pad[24];
+} XEvent;
+#endif
+
+#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy)))
+
+/*
+ * per character font metric information.
+ */
+typedef struct {
+ short lbearing; /* origin to left edge of raster */
+ short rbearing; /* origin to right edge of raster */
+ short width; /* advance to next char's origin */
+ short ascent; /* baseline to top edge of raster */
+ short descent; /* baseline to bottom edge of raster */
+ unsigned short attributes; /* per char flags (not predefined) */
+} XCharStruct;
+
+/*
+ * To allow arbitrary information with fonts, there are additional properties
+ * returned.
+ */
+typedef struct {
+ Atom name;
+ unsigned long card32;
+} XFontProp;
+
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ Font fid; /* Font id for this font */
+ unsigned direction; /* hint about direction the font is painted */
+ unsigned min_char_or_byte2;/* first character */
+ unsigned max_char_or_byte2;/* last character */
+ unsigned min_byte1; /* first row that exists */
+ unsigned max_byte1; /* last row that exists */
+ Bool all_chars_exist;/* flag if all characters have non-zero size*/
+ unsigned default_char; /* char to print for undefined character */
+ int n_properties; /* how many properties there are */
+ XFontProp *properties; /* pointer to array of additional properties*/
+ XCharStruct min_bounds; /* minimum bounds over all existing char*/
+ XCharStruct max_bounds; /* maximum bounds over all existing char*/
+ XCharStruct *per_char; /* first_char to last_char information */
+ int ascent; /* log. extent above baseline for spacing */
+ int descent; /* log. descent below baseline for spacing */
+} XFontStruct;
+
+/*
+ * PolyText routines take these as arguments.
+ */
+typedef struct {
+ char *chars; /* pointer to string */
+ int nchars; /* number of characters */
+ int delta; /* delta between strings */
+ Font font; /* font to print it in, None don't change */
+} XTextItem;
+
+typedef struct { /* normal 16 bit characters are two bytes */
+ unsigned char byte1;
+ unsigned char byte2;
+} XChar2b;
+
+typedef struct {
+ XChar2b *chars; /* two byte characters */
+ int nchars; /* number of characters */
+ int delta; /* delta between strings */
+ Font font; /* font to print it in, None don't change */
+} XTextItem16;
+
+
+typedef union { Display *display;
+ GC gc;
+ Visual *visual;
+ Screen *screen;
+ ScreenFormat *pixmap_format;
+ XFontStruct *font; } XEDataObject;
+
+typedef struct {
+ XRectangle max_ink_extent;
+ XRectangle max_logical_extent;
+} XFontSetExtents;
+
+/* unused:
+typedef void (*XOMProc)();
+ */
+
+typedef struct _XOM *XOM;
+typedef struct _XOC *XOC, *XFontSet;
+
+typedef struct {
+ char *chars;
+ int nchars;
+ int delta;
+ XFontSet font_set;
+} XmbTextItem;
+
+typedef struct {
+ wchar_t *chars;
+ int nchars;
+ int delta;
+ XFontSet font_set;
+} XwcTextItem;
+
+#define XNRequiredCharSet "requiredCharSet"
+#define XNQueryOrientation "queryOrientation"
+#define XNBaseFontName "baseFontName"
+#define XNOMAutomatic "omAutomatic"
+#define XNMissingCharSet "missingCharSet"
+#define XNDefaultString "defaultString"
+#define XNOrientation "orientation"
+#define XNDirectionalDependentDrawing "directionalDependentDrawing"
+#define XNContextualDrawing "contextualDrawing"
+#define XNFontInfo "fontInfo"
+
+typedef struct {
+ int charset_count;
+ char **charset_list;
+} XOMCharSetList;
+
+typedef enum {
+ XOMOrientation_LTR_TTB,
+ XOMOrientation_RTL_TTB,
+ XOMOrientation_TTB_LTR,
+ XOMOrientation_TTB_RTL,
+ XOMOrientation_Context
+} XOrientation;
+
+typedef struct {
+ int num_orientation;
+ XOrientation *orientation; /* Input Text description */
+} XOMOrientation;
+
+typedef struct {
+ int num_font;
+ XFontStruct **font_struct_list;
+ char **font_name_list;
+} XOMFontInfo;
+
+typedef struct _XIM *XIM;
+typedef struct _XIC *XIC;
+
+typedef void (*XIMProc)(
+ XIM,
+ XPointer,
+ XPointer
+);
+
+typedef Bool (*XICProc)(
+ XIC,
+ XPointer,
+ XPointer
+);
+
+typedef void (*XIDProc)(
+ Display*,
+ XPointer,
+ XPointer
+);
+
+typedef unsigned long XIMStyle;
+
+typedef struct {
+ unsigned short count_styles;
+ XIMStyle *supported_styles;
+} XIMStyles;
+
+#define XIMPreeditArea 0x0001L
+#define XIMPreeditCallbacks 0x0002L
+#define XIMPreeditPosition 0x0004L
+#define XIMPreeditNothing 0x0008L
+#define XIMPreeditNone 0x0010L
+#define XIMStatusArea 0x0100L
+#define XIMStatusCallbacks 0x0200L
+#define XIMStatusNothing 0x0400L
+#define XIMStatusNone 0x0800L
+
+#define XNVaNestedList "XNVaNestedList"
+#define XNQueryInputStyle "queryInputStyle"
+#define XNClientWindow "clientWindow"
+#define XNInputStyle "inputStyle"
+#define XNFocusWindow "focusWindow"
+#define XNResourceName "resourceName"
+#define XNResourceClass "resourceClass"
+#define XNGeometryCallback "geometryCallback"
+#define XNDestroyCallback "destroyCallback"
+#define XNFilterEvents "filterEvents"
+#define XNPreeditStartCallback "preeditStartCallback"
+#define XNPreeditDoneCallback "preeditDoneCallback"
+#define XNPreeditDrawCallback "preeditDrawCallback"
+#define XNPreeditCaretCallback "preeditCaretCallback"
+#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback"
+#define XNPreeditAttributes "preeditAttributes"
+#define XNStatusStartCallback "statusStartCallback"
+#define XNStatusDoneCallback "statusDoneCallback"
+#define XNStatusDrawCallback "statusDrawCallback"
+#define XNStatusAttributes "statusAttributes"
+#define XNArea "area"
+#define XNAreaNeeded "areaNeeded"
+#define XNSpotLocation "spotLocation"
+#define XNColormap "colorMap"
+#define XNStdColormap "stdColorMap"
+#define XNForeground "foreground"
+#define XNBackground "background"
+#define XNBackgroundPixmap "backgroundPixmap"
+#define XNFontSet "fontSet"
+#define XNLineSpace "lineSpace"
+#define XNCursor "cursor"
+
+#define XNQueryIMValuesList "queryIMValuesList"
+#define XNQueryICValuesList "queryICValuesList"
+#define XNVisiblePosition "visiblePosition"
+#define XNR6PreeditCallback "r6PreeditCallback"
+#define XNStringConversionCallback "stringConversionCallback"
+#define XNStringConversion "stringConversion"
+#define XNResetState "resetState"
+#define XNHotKey "hotKey"
+#define XNHotKeyState "hotKeyState"
+#define XNPreeditState "preeditState"
+#define XNSeparatorofNestedList "separatorofNestedList"
+
+#define XBufferOverflow -1
+#define XLookupNone 1
+#define XLookupChars 2
+#define XLookupKeySym 3
+#define XLookupBoth 4
+
+typedef void *XVaNestedList;
+
+typedef struct {
+ XPointer client_data;
+ XIMProc callback;
+} XIMCallback;
+
+typedef struct {
+ XPointer client_data;
+ XICProc callback;
+} XICCallback;
+
+typedef unsigned long XIMFeedback;
+
+#define XIMReverse 1L
+#define XIMUnderline (1L<<1)
+#define XIMHighlight (1L<<2)
+#define XIMPrimary (1L<<5)
+#define XIMSecondary (1L<<6)
+#define XIMTertiary (1L<<7)
+#define XIMVisibleToForward (1L<<8)
+#define XIMVisibleToBackword (1L<<9)
+#define XIMVisibleToCenter (1L<<10)
+
+typedef struct _XIMText {
+ unsigned short length;
+ XIMFeedback *feedback;
+ Bool encoding_is_wchar;
+ union {
+ char *multi_byte;
+ wchar_t *wide_char;
+ } string;
+} XIMText;
+
+typedef unsigned long XIMPreeditState;
+
+#define XIMPreeditUnKnown 0L
+#define XIMPreeditEnable 1L
+#define XIMPreeditDisable (1L<<1)
+
+typedef struct _XIMPreeditStateNotifyCallbackStruct {
+ XIMPreeditState state;
+} XIMPreeditStateNotifyCallbackStruct;
+
+typedef unsigned long XIMResetState;
+
+#define XIMInitialState 1L
+#define XIMPreserveState (1L<<1)
+
+typedef unsigned long XIMStringConversionFeedback;
+
+#define XIMStringConversionLeftEdge (0x00000001)
+#define XIMStringConversionRightEdge (0x00000002)
+#define XIMStringConversionTopEdge (0x00000004)
+#define XIMStringConversionBottomEdge (0x00000008)
+#define XIMStringConversionConcealed (0x00000010)
+#define XIMStringConversionWrapped (0x00000020)
+
+typedef struct _XIMStringConversionText {
+ unsigned short length;
+ XIMStringConversionFeedback *feedback;
+ Bool encoding_is_wchar;
+ union {
+ char *mbs;
+ wchar_t *wcs;
+ } string;
+} XIMStringConversionText;
+
+typedef unsigned short XIMStringConversionPosition;
+
+typedef unsigned short XIMStringConversionType;
+
+#define XIMStringConversionBuffer (0x0001)
+#define XIMStringConversionLine (0x0002)
+#define XIMStringConversionWord (0x0003)
+#define XIMStringConversionChar (0x0004)
+
+typedef unsigned short XIMStringConversionOperation;
+
+#define XIMStringConversionSubstitution (0x0001)
+#define XIMStringConversionRetrieval (0x0002)
+
+typedef enum {
+ XIMForwardChar, XIMBackwardChar,
+ XIMForwardWord, XIMBackwardWord,
+ XIMCaretUp, XIMCaretDown,
+ XIMNextLine, XIMPreviousLine,
+ XIMLineStart, XIMLineEnd,
+ XIMAbsolutePosition,
+ XIMDontChange
+} XIMCaretDirection;
+
+typedef struct _XIMStringConversionCallbackStruct {
+ XIMStringConversionPosition position;
+ XIMCaretDirection direction;
+ XIMStringConversionOperation operation;
+ unsigned short factor;
+ XIMStringConversionText *text;
+} XIMStringConversionCallbackStruct;
+
+typedef struct _XIMPreeditDrawCallbackStruct {
+ int caret; /* Cursor offset within pre-edit string */
+ int chg_first; /* Starting change position */
+ int chg_length; /* Length of the change in character count */
+ XIMText *text;
+} XIMPreeditDrawCallbackStruct;
+
+typedef enum {
+ XIMIsInvisible, /* Disable caret feedback */
+ XIMIsPrimary, /* UI defined caret feedback */
+ XIMIsSecondary /* UI defined caret feedback */
+} XIMCaretStyle;
+
+typedef struct _XIMPreeditCaretCallbackStruct {
+ int position; /* Caret offset within pre-edit string */
+ XIMCaretDirection direction; /* Caret moves direction */
+ XIMCaretStyle style; /* Feedback of the caret */
+} XIMPreeditCaretCallbackStruct;
+
+typedef enum {
+ XIMTextType,
+ XIMBitmapType
+} XIMStatusDataType;
+
+typedef struct _XIMStatusDrawCallbackStruct {
+ XIMStatusDataType type;
+ union {
+ XIMText *text;
+ Pixmap bitmap;
+ } data;
+} XIMStatusDrawCallbackStruct;
+
+typedef struct _XIMHotKeyTrigger {
+ KeySym keysym;
+ int modifier;
+ int modifier_mask;
+} XIMHotKeyTrigger;
+
+typedef struct _XIMHotKeyTriggers {
+ int num_hot_key;
+ XIMHotKeyTrigger *key;
+} XIMHotKeyTriggers;
+
+typedef unsigned long XIMHotKeyState;
+
+#define XIMHotKeyStateON (0x0001L)
+#define XIMHotKeyStateOFF (0x0002L)
+
+typedef struct {
+ unsigned short count_values;
+ char **supported_values;
+} XIMValuesList;
+
+_XFUNCPROTOBEGIN
+
+#if defined(WIN32) && !defined(_XLIBINT_)
+#define _Xdebug (*_Xdebug_p)
+#endif
+
+extern int _Xdebug;
+
+extern XFontStruct *XLoadQueryFont(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+
+extern XFontStruct *XQueryFont(
+ Display* /* display */,
+ XID /* font_ID */
+);
+
+
+extern XTimeCoord *XGetMotionEvents(
+ Display* /* display */,
+ Window /* w */,
+ Time /* start */,
+ Time /* stop */,
+ int* /* nevents_return */
+);
+
+extern XModifierKeymap *XDeleteModifiermapEntry(
+ XModifierKeymap* /* modmap */,
+#if NeedWidePrototypes
+ unsigned int /* keycode_entry */,
+#else
+ KeyCode /* keycode_entry */,
+#endif
+ int /* modifier */
+);
+
+extern XModifierKeymap *XGetModifierMapping(
+ Display* /* display */
+);
+
+extern XModifierKeymap *XInsertModifiermapEntry(
+ XModifierKeymap* /* modmap */,
+#if NeedWidePrototypes
+ unsigned int /* keycode_entry */,
+#else
+ KeyCode /* keycode_entry */,
+#endif
+ int /* modifier */
+);
+
+extern XModifierKeymap *XNewModifiermap(
+ int /* max_keys_per_mod */
+);
+
+extern XImage *XCreateImage(
+ Display* /* display */,
+ Visual* /* visual */,
+ unsigned int /* depth */,
+ int /* format */,
+ int /* offset */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* bitmap_pad */,
+ int /* bytes_per_line */
+);
+extern Status XInitImage(
+ XImage* /* image */
+);
+extern XImage *XGetImage(
+ Display* /* display */,
+ Drawable /* d */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* plane_mask */,
+ int /* format */
+);
+extern XImage *XGetSubImage(
+ Display* /* display */,
+ Drawable /* d */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* plane_mask */,
+ int /* format */,
+ XImage* /* dest_image */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+/*
+ * X function declarations.
+ */
+extern Display *XOpenDisplay(
+ _Xconst char* /* display_name */
+);
+
+extern void XrmInitialize(
+ void
+);
+
+extern char *XFetchBytes(
+ Display* /* display */,
+ int* /* nbytes_return */
+);
+extern char *XFetchBuffer(
+ Display* /* display */,
+ int* /* nbytes_return */,
+ int /* buffer */
+);
+extern char *XGetAtomName(
+ Display* /* display */,
+ Atom /* atom */
+);
+extern Status XGetAtomNames(
+ Display* /* dpy */,
+ Atom* /* atoms */,
+ int /* count */,
+ char** /* names_return */
+);
+extern char *XGetDefault(
+ Display* /* display */,
+ _Xconst char* /* program */,
+ _Xconst char* /* option */
+);
+extern char *XDisplayName(
+ _Xconst char* /* string */
+);
+extern char *XKeysymToString(
+ KeySym /* keysym */
+);
+
+extern int (*XSynchronize(
+ Display* /* display */,
+ Bool /* onoff */
+))(
+ Display* /* display */
+);
+extern int (*XSetAfterFunction(
+ Display* /* display */,
+ int (*) (
+ Display* /* display */
+ ) /* procedure */
+))(
+ Display* /* display */
+);
+extern Atom XInternAtom(
+ Display* /* display */,
+ _Xconst char* /* atom_name */,
+ Bool /* only_if_exists */
+);
+extern Status XInternAtoms(
+ Display* /* dpy */,
+ char** /* names */,
+ int /* count */,
+ Bool /* onlyIfExists */,
+ Atom* /* atoms_return */
+);
+extern Colormap XCopyColormapAndFree(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+extern Colormap XCreateColormap(
+ Display* /* display */,
+ Window /* w */,
+ Visual* /* visual */,
+ int /* alloc */
+);
+extern Cursor XCreatePixmapCursor(
+ Display* /* display */,
+ Pixmap /* source */,
+ Pixmap /* mask */,
+ XColor* /* foreground_color */,
+ XColor* /* background_color */,
+ unsigned int /* x */,
+ unsigned int /* y */
+);
+extern Cursor XCreateGlyphCursor(
+ Display* /* display */,
+ Font /* source_font */,
+ Font /* mask_font */,
+ unsigned int /* source_char */,
+ unsigned int /* mask_char */,
+ XColor _Xconst * /* foreground_color */,
+ XColor _Xconst * /* background_color */
+);
+extern Cursor XCreateFontCursor(
+ Display* /* display */,
+ unsigned int /* shape */
+);
+extern Font XLoadFont(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+extern GC XCreateGC(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values */
+);
+extern GContext XGContextFromGC(
+ GC /* gc */
+);
+extern void XFlushGC(
+ Display* /* display */,
+ GC /* gc */
+);
+extern Pixmap XCreatePixmap(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* depth */
+);
+extern Pixmap XCreateBitmapFromData(
+ Display* /* display */,
+ Drawable /* d */,
+ _Xconst char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+extern Pixmap XCreatePixmapFromBitmapData(
+ Display* /* display */,
+ Drawable /* d */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* fg */,
+ unsigned long /* bg */,
+ unsigned int /* depth */
+);
+extern Window XCreateSimpleWindow(
+ Display* /* display */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* border_width */,
+ unsigned long /* border */,
+ unsigned long /* background */
+);
+extern Window XGetSelectionOwner(
+ Display* /* display */,
+ Atom /* selection */
+);
+extern Window XCreateWindow(
+ Display* /* display */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* border_width */,
+ int /* depth */,
+ unsigned int /* class */,
+ Visual* /* visual */,
+ unsigned long /* valuemask */,
+ XSetWindowAttributes* /* attributes */
+);
+extern Colormap *XListInstalledColormaps(
+ Display* /* display */,
+ Window /* w */,
+ int* /* num_return */
+);
+extern char **XListFonts(
+ Display* /* display */,
+ _Xconst char* /* pattern */,
+ int /* maxnames */,
+ int* /* actual_count_return */
+);
+extern char **XListFontsWithInfo(
+ Display* /* display */,
+ _Xconst char* /* pattern */,
+ int /* maxnames */,
+ int* /* count_return */,
+ XFontStruct** /* info_return */
+);
+extern char **XGetFontPath(
+ Display* /* display */,
+ int* /* npaths_return */
+);
+extern char **XListExtensions(
+ Display* /* display */,
+ int* /* nextensions_return */
+);
+extern Atom *XListProperties(
+ Display* /* display */,
+ Window /* w */,
+ int* /* num_prop_return */
+);
+extern XHostAddress *XListHosts(
+ Display* /* display */,
+ int* /* nhosts_return */,
+ Bool* /* state_return */
+);
+extern KeySym XKeycodeToKeysym(
+ Display* /* display */,
+#if NeedWidePrototypes
+ unsigned int /* keycode */,
+#else
+ KeyCode /* keycode */,
+#endif
+ int /* index */
+);
+extern KeySym XLookupKeysym(
+ XKeyEvent* /* key_event */,
+ int /* index */
+);
+extern KeySym *XGetKeyboardMapping(
+ Display* /* display */,
+#if NeedWidePrototypes
+ unsigned int /* first_keycode */,
+#else
+ KeyCode /* first_keycode */,
+#endif
+ int /* keycode_count */,
+ int* /* keysyms_per_keycode_return */
+);
+extern KeySym XStringToKeysym(
+ _Xconst char* /* string */
+);
+extern long XMaxRequestSize(
+ Display* /* display */
+);
+extern long XExtendedMaxRequestSize(
+ Display* /* display */
+);
+extern char *XResourceManagerString(
+ Display* /* display */
+);
+extern char *XScreenResourceString(
+ Screen* /* screen */
+);
+extern unsigned long XDisplayMotionBufferSize(
+ Display* /* display */
+);
+extern VisualID XVisualIDFromVisual(
+ Visual* /* visual */
+);
+
+/* multithread routines */
+
+extern Status XInitThreads(
+ void
+);
+
+extern void XLockDisplay(
+ Display* /* display */
+);
+
+extern void XUnlockDisplay(
+ Display* /* display */
+);
+
+/* routines for dealing with extensions */
+
+extern XExtCodes *XInitExtension(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+
+extern XExtCodes *XAddExtension(
+ Display* /* display */
+);
+extern XExtData *XFindOnExtensionList(
+ XExtData** /* structure */,
+ int /* number */
+);
+extern XExtData **XEHeadOfExtensionList(
+ XEDataObject /* object */
+);
+
+/* these are routines for which there are also macros */
+extern Window XRootWindow(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Window XDefaultRootWindow(
+ Display* /* display */
+);
+extern Window XRootWindowOfScreen(
+ Screen* /* screen */
+);
+extern Visual *XDefaultVisual(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Visual *XDefaultVisualOfScreen(
+ Screen* /* screen */
+);
+extern GC XDefaultGC(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern GC XDefaultGCOfScreen(
+ Screen* /* screen */
+);
+extern unsigned long XBlackPixel(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern unsigned long XWhitePixel(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern unsigned long XAllPlanes(
+ void
+);
+extern unsigned long XBlackPixelOfScreen(
+ Screen* /* screen */
+);
+extern unsigned long XWhitePixelOfScreen(
+ Screen* /* screen */
+);
+extern unsigned long XNextRequest(
+ Display* /* display */
+);
+extern unsigned long XLastKnownRequestProcessed(
+ Display* /* display */
+);
+extern char *XServerVendor(
+ Display* /* display */
+);
+extern char *XDisplayString(
+ Display* /* display */
+);
+extern Colormap XDefaultColormap(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Colormap XDefaultColormapOfScreen(
+ Screen* /* screen */
+);
+extern Display *XDisplayOfScreen(
+ Screen* /* screen */
+);
+extern Screen *XScreenOfDisplay(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Screen *XDefaultScreenOfDisplay(
+ Display* /* display */
+);
+extern long XEventMaskOfScreen(
+ Screen* /* screen */
+);
+
+extern int XScreenNumberOfScreen(
+ Screen* /* screen */
+);
+
+typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */
+ Display* /* display */,
+ XErrorEvent* /* error_event */
+);
+
+extern XErrorHandler XSetErrorHandler (
+ XErrorHandler /* handler */
+);
+
+
+typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */
+ Display* /* display */
+);
+
+extern XIOErrorHandler XSetIOErrorHandler (
+ XIOErrorHandler /* handler */
+);
+
+
+extern XPixmapFormatValues *XListPixmapFormats(
+ Display* /* display */,
+ int* /* count_return */
+);
+extern int *XListDepths(
+ Display* /* display */,
+ int /* screen_number */,
+ int* /* count_return */
+);
+
+/* ICCCM routines for things that don't require special include files; */
+/* other declarations are given in Xutil.h */
+extern Status XReconfigureWMWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */,
+ unsigned int /* mask */,
+ XWindowChanges* /* changes */
+);
+
+extern Status XGetWMProtocols(
+ Display* /* display */,
+ Window /* w */,
+ Atom** /* protocols_return */,
+ int* /* count_return */
+);
+extern Status XSetWMProtocols(
+ Display* /* display */,
+ Window /* w */,
+ Atom* /* protocols */,
+ int /* count */
+);
+extern Status XIconifyWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */
+);
+extern Status XWithdrawWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */
+);
+extern Status XGetCommand(
+ Display* /* display */,
+ Window /* w */,
+ char*** /* argv_return */,
+ int* /* argc_return */
+);
+extern Status XGetWMColormapWindows(
+ Display* /* display */,
+ Window /* w */,
+ Window** /* windows_return */,
+ int* /* count_return */
+);
+extern Status XSetWMColormapWindows(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* colormap_windows */,
+ int /* count */
+);
+extern void XFreeStringList(
+ char** /* list */
+);
+extern int XSetTransientForHint(
+ Display* /* display */,
+ Window /* w */,
+ Window /* prop_window */
+);
+
+/* The following are given in alphabetical order */
+
+extern int XActivateScreenSaver(
+ Display* /* display */
+);
+
+extern int XAddHost(
+ Display* /* display */,
+ XHostAddress* /* host */
+);
+
+extern int XAddHosts(
+ Display* /* display */,
+ XHostAddress* /* hosts */,
+ int /* num_hosts */
+);
+
+extern int XAddToExtensionList(
+ struct _XExtData** /* structure */,
+ XExtData* /* ext_data */
+);
+
+extern int XAddToSaveSet(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern Status XAllocColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* screen_in_out */
+);
+
+extern Status XAllocColorCells(
+ Display* /* display */,
+ Colormap /* colormap */,
+ Bool /* contig */,
+ unsigned long* /* plane_masks_return */,
+ unsigned int /* nplanes */,
+ unsigned long* /* pixels_return */,
+ unsigned int /* npixels */
+);
+
+extern Status XAllocColorPlanes(
+ Display* /* display */,
+ Colormap /* colormap */,
+ Bool /* contig */,
+ unsigned long* /* pixels_return */,
+ int /* ncolors */,
+ int /* nreds */,
+ int /* ngreens */,
+ int /* nblues */,
+ unsigned long* /* rmask_return */,
+ unsigned long* /* gmask_return */,
+ unsigned long* /* bmask_return */
+);
+
+extern Status XAllocNamedColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_name */,
+ XColor* /* screen_def_return */,
+ XColor* /* exact_def_return */
+);
+
+extern int XAllowEvents(
+ Display* /* display */,
+ int /* event_mode */,
+ Time /* time */
+);
+
+extern int XAutoRepeatOff(
+ Display* /* display */
+);
+
+extern int XAutoRepeatOn(
+ Display* /* display */
+);
+
+extern int XBell(
+ Display* /* display */,
+ int /* percent */
+);
+
+extern int XBitmapBitOrder(
+ Display* /* display */
+);
+
+extern int XBitmapPad(
+ Display* /* display */
+);
+
+extern int XBitmapUnit(
+ Display* /* display */
+);
+
+extern int XCellsOfScreen(
+ Screen* /* screen */
+);
+
+extern int XChangeActivePointerGrab(
+ Display* /* display */,
+ unsigned int /* event_mask */,
+ Cursor /* cursor */,
+ Time /* time */
+);
+
+extern int XChangeGC(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values */
+);
+
+extern int XChangeKeyboardControl(
+ Display* /* display */,
+ unsigned long /* value_mask */,
+ XKeyboardControl* /* values */
+);
+
+extern int XChangeKeyboardMapping(
+ Display* /* display */,
+ int /* first_keycode */,
+ int /* keysyms_per_keycode */,
+ KeySym* /* keysyms */,
+ int /* num_codes */
+);
+
+extern int XChangePointerControl(
+ Display* /* display */,
+ Bool /* do_accel */,
+ Bool /* do_threshold */,
+ int /* accel_numerator */,
+ int /* accel_denominator */,
+ int /* threshold */
+);
+
+extern int XChangeProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */,
+ Atom /* type */,
+ int /* format */,
+ int /* mode */,
+ _Xconst unsigned char* /* data */,
+ int /* nelements */
+);
+
+extern int XChangeSaveSet(
+ Display* /* display */,
+ Window /* w */,
+ int /* change_mode */
+);
+
+extern int XChangeWindowAttributes(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* valuemask */,
+ XSetWindowAttributes* /* attributes */
+);
+
+extern Bool XCheckIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+extern Bool XCheckMaskEvent(
+ Display* /* display */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern Bool XCheckTypedEvent(
+ Display* /* display */,
+ int /* event_type */,
+ XEvent* /* event_return */
+);
+
+extern Bool XCheckTypedWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ int /* event_type */,
+ XEvent* /* event_return */
+);
+
+extern Bool XCheckWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern int XCirculateSubwindows(
+ Display* /* display */,
+ Window /* w */,
+ int /* direction */
+);
+
+extern int XCirculateSubwindowsDown(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XCirculateSubwindowsUp(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XClearArea(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ Bool /* exposures */
+);
+
+extern int XClearWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XCloseDisplay(
+ Display* /* display */
+);
+
+extern int XConfigureWindow(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* value_mask */,
+ XWindowChanges* /* values */
+);
+
+extern int XConnectionNumber(
+ Display* /* display */
+);
+
+extern int XConvertSelection(
+ Display* /* display */,
+ Atom /* selection */,
+ Atom /* target */,
+ Atom /* property */,
+ Window /* requestor */,
+ Time /* time */
+);
+
+extern int XCopyArea(
+ Display* /* display */,
+ Drawable /* src */,
+ Drawable /* dest */,
+ GC /* gc */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+extern int XCopyGC(
+ Display* /* display */,
+ GC /* src */,
+ unsigned long /* valuemask */,
+ GC /* dest */
+);
+
+extern int XCopyPlane(
+ Display* /* display */,
+ Drawable /* src */,
+ Drawable /* dest */,
+ GC /* gc */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* dest_x */,
+ int /* dest_y */,
+ unsigned long /* plane */
+);
+
+extern int XDefaultDepth(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDefaultDepthOfScreen(
+ Screen* /* screen */
+);
+
+extern int XDefaultScreen(
+ Display* /* display */
+);
+
+extern int XDefineCursor(
+ Display* /* display */,
+ Window /* w */,
+ Cursor /* cursor */
+);
+
+extern int XDeleteProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */
+);
+
+extern int XDestroyWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XDestroySubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XDoesBackingStore(
+ Screen* /* screen */
+);
+
+extern Bool XDoesSaveUnders(
+ Screen* /* screen */
+);
+
+extern int XDisableAccessControl(
+ Display* /* display */
+);
+
+
+extern int XDisplayCells(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayHeight(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayHeightMM(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayKeycodes(
+ Display* /* display */,
+ int* /* min_keycodes_return */,
+ int* /* max_keycodes_return */
+);
+
+extern int XDisplayPlanes(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayWidth(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayWidthMM(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDrawArc(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* angle1 */,
+ int /* angle2 */
+);
+
+extern int XDrawArcs(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XArc* /* arcs */,
+ int /* narcs */
+);
+
+extern int XDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* string */,
+ int /* length */
+);
+
+extern int XDrawImageString16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst XChar2b* /* string */,
+ int /* length */
+);
+
+extern int XDrawLine(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x1 */,
+ int /* y1 */,
+ int /* x2 */,
+ int /* y2 */
+);
+
+extern int XDrawLines(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* mode */
+);
+
+extern int XDrawPoint(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */
+);
+
+extern int XDrawPoints(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* mode */
+);
+
+extern int XDrawRectangle(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XDrawRectangles(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XRectangle* /* rectangles */,
+ int /* nrectangles */
+);
+
+extern int XDrawSegments(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XSegment* /* segments */,
+ int /* nsegments */
+);
+
+extern int XDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* string */,
+ int /* length */
+);
+
+extern int XDrawString16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst XChar2b* /* string */,
+ int /* length */
+);
+
+extern int XDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XTextItem* /* items */,
+ int /* nitems */
+);
+
+extern int XDrawText16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XTextItem16* /* items */,
+ int /* nitems */
+);
+
+extern int XEnableAccessControl(
+ Display* /* display */
+);
+
+extern int XEventsQueued(
+ Display* /* display */,
+ int /* mode */
+);
+
+extern Status XFetchName(
+ Display* /* display */,
+ Window /* w */,
+ char** /* window_name_return */
+);
+
+extern int XFillArc(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* angle1 */,
+ int /* angle2 */
+);
+
+extern int XFillArcs(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XArc* /* arcs */,
+ int /* narcs */
+);
+
+extern int XFillPolygon(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* shape */,
+ int /* mode */
+);
+
+extern int XFillRectangle(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XFillRectangles(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XRectangle* /* rectangles */,
+ int /* nrectangles */
+);
+
+extern int XFlush(
+ Display* /* display */
+);
+
+extern int XForceScreenSaver(
+ Display* /* display */,
+ int /* mode */
+);
+
+extern int XFree(
+ void* /* data */
+);
+
+extern int XFreeColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+extern int XFreeColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ unsigned long* /* pixels */,
+ int /* npixels */,
+ unsigned long /* planes */
+);
+
+extern int XFreeCursor(
+ Display* /* display */,
+ Cursor /* cursor */
+);
+
+extern int XFreeExtensionList(
+ char** /* list */
+);
+
+extern int XFreeFont(
+ Display* /* display */,
+ XFontStruct* /* font_struct */
+);
+
+extern int XFreeFontInfo(
+ char** /* names */,
+ XFontStruct* /* free_info */,
+ int /* actual_count */
+);
+
+extern int XFreeFontNames(
+ char** /* list */
+);
+
+extern int XFreeFontPath(
+ char** /* list */
+);
+
+extern int XFreeGC(
+ Display* /* display */,
+ GC /* gc */
+);
+
+extern int XFreeModifiermap(
+ XModifierKeymap* /* modmap */
+);
+
+extern int XFreePixmap(
+ Display* /* display */,
+ Pixmap /* pixmap */
+);
+
+extern int XGeometry(
+ Display* /* display */,
+ int /* screen */,
+ _Xconst char* /* position */,
+ _Xconst char* /* default_position */,
+ unsigned int /* bwidth */,
+ unsigned int /* fwidth */,
+ unsigned int /* fheight */,
+ int /* xadder */,
+ int /* yadder */,
+ int* /* x_return */,
+ int* /* y_return */,
+ int* /* width_return */,
+ int* /* height_return */
+);
+
+extern int XGetErrorDatabaseText(
+ Display* /* display */,
+ _Xconst char* /* name */,
+ _Xconst char* /* message */,
+ _Xconst char* /* default_string */,
+ char* /* buffer_return */,
+ int /* length */
+);
+
+extern int XGetErrorText(
+ Display* /* display */,
+ int /* code */,
+ char* /* buffer_return */,
+ int /* length */
+);
+
+extern Bool XGetFontProperty(
+ XFontStruct* /* font_struct */,
+ Atom /* atom */,
+ unsigned long* /* value_return */
+);
+
+extern Status XGetGCValues(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values_return */
+);
+
+extern Status XGetGeometry(
+ Display* /* display */,
+ Drawable /* d */,
+ Window* /* root_return */,
+ int* /* x_return */,
+ int* /* y_return */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned int* /* border_width_return */,
+ unsigned int* /* depth_return */
+);
+
+extern Status XGetIconName(
+ Display* /* display */,
+ Window /* w */,
+ char** /* icon_name_return */
+);
+
+extern int XGetInputFocus(
+ Display* /* display */,
+ Window* /* focus_return */,
+ int* /* revert_to_return */
+);
+
+extern int XGetKeyboardControl(
+ Display* /* display */,
+ XKeyboardState* /* values_return */
+);
+
+extern int XGetPointerControl(
+ Display* /* display */,
+ int* /* accel_numerator_return */,
+ int* /* accel_denominator_return */,
+ int* /* threshold_return */
+);
+
+extern int XGetPointerMapping(
+ Display* /* display */,
+ unsigned char* /* map_return */,
+ int /* nmap */
+);
+
+extern int XGetScreenSaver(
+ Display* /* display */,
+ int* /* timeout_return */,
+ int* /* interval_return */,
+ int* /* prefer_blanking_return */,
+ int* /* allow_exposures_return */
+);
+
+extern Status XGetTransientForHint(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* prop_window_return */
+);
+
+extern int XGetWindowProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */,
+ long /* long_offset */,
+ long /* long_length */,
+ Bool /* delete */,
+ Atom /* req_type */,
+ Atom* /* actual_type_return */,
+ int* /* actual_format_return */,
+ unsigned long* /* nitems_return */,
+ unsigned long* /* bytes_after_return */,
+ unsigned char** /* prop_return */
+);
+
+extern Status XGetWindowAttributes(
+ Display* /* display */,
+ Window /* w */,
+ XWindowAttributes* /* window_attributes_return */
+);
+
+extern int XGrabButton(
+ Display* /* display */,
+ unsigned int /* button */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */
+);
+
+extern int XGrabKey(
+ Display* /* display */,
+ int /* keycode */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */
+);
+
+extern int XGrabKeyboard(
+ Display* /* display */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Time /* time */
+);
+
+extern int XGrabPointer(
+ Display* /* display */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */,
+ Time /* time */
+);
+
+extern int XGrabServer(
+ Display* /* display */
+);
+
+extern int XHeightMMOfScreen(
+ Screen* /* screen */
+);
+
+extern int XHeightOfScreen(
+ Screen* /* screen */
+);
+
+extern int XIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+extern int XImageByteOrder(
+ Display* /* display */
+);
+
+extern int XInstallColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+extern KeyCode XKeysymToKeycode(
+ Display* /* display */,
+ KeySym /* keysym */
+);
+
+extern int XKillClient(
+ Display* /* display */,
+ XID /* resource */
+);
+
+extern Status XLookupColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_name */,
+ XColor* /* exact_def_return */,
+ XColor* /* screen_def_return */
+);
+
+extern int XLowerWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMapRaised(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMapSubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMapWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMaskEvent(
+ Display* /* display */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern int XMaxCmapsOfScreen(
+ Screen* /* screen */
+);
+
+extern int XMinCmapsOfScreen(
+ Screen* /* screen */
+);
+
+extern int XMoveResizeWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XMoveWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */
+);
+
+extern int XNextEvent(
+ Display* /* display */,
+ XEvent* /* event_return */
+);
+
+extern int XNoOp(
+ Display* /* display */
+);
+
+extern Status XParseColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* spec */,
+ XColor* /* exact_def_return */
+);
+
+extern int XParseGeometry(
+ _Xconst char* /* parsestring */,
+ int* /* x_return */,
+ int* /* y_return */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern int XPeekEvent(
+ Display* /* display */,
+ XEvent* /* event_return */
+);
+
+extern int XPeekIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+extern int XPending(
+ Display* /* display */
+);
+
+extern int XPlanesOfScreen(
+ Screen* /* screen */
+);
+
+extern int XProtocolRevision(
+ Display* /* display */
+);
+
+extern int XProtocolVersion(
+ Display* /* display */
+);
+
+
+extern int XPutBackEvent(
+ Display* /* display */,
+ XEvent* /* event */
+);
+
+extern int XPutImage(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XImage* /* image */,
+ int /* src_x */,
+ int /* src_y */,
+ int /* dest_x */,
+ int /* dest_y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XQLength(
+ Display* /* display */
+);
+
+extern Status XQueryBestCursor(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern Status XQueryBestSize(
+ Display* /* display */,
+ int /* class */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern Status XQueryBestStipple(
+ Display* /* display */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern Status XQueryBestTile(
+ Display* /* display */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern int XQueryColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* def_in_out */
+);
+
+extern int XQueryColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* defs_in_out */,
+ int /* ncolors */
+);
+
+extern Bool XQueryExtension(
+ Display* /* display */,
+ _Xconst char* /* name */,
+ int* /* major_opcode_return */,
+ int* /* first_event_return */,
+ int* /* first_error_return */
+);
+
+extern int XQueryKeymap(
+ Display* /* display */,
+ char [32] /* keys_return */
+);
+
+extern Bool XQueryPointer(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* root_return */,
+ Window* /* child_return */,
+ int* /* root_x_return */,
+ int* /* root_y_return */,
+ int* /* win_x_return */,
+ int* /* win_y_return */,
+ unsigned int* /* mask_return */
+);
+
+extern int XQueryTextExtents(
+ Display* /* display */,
+ XID /* font_ID */,
+ _Xconst char* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern int XQueryTextExtents16(
+ Display* /* display */,
+ XID /* font_ID */,
+ _Xconst XChar2b* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern Status XQueryTree(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* root_return */,
+ Window* /* parent_return */,
+ Window** /* children_return */,
+ unsigned int* /* nchildren_return */
+);
+
+extern int XRaiseWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XReadBitmapFile(
+ Display* /* display */,
+ Drawable /* d */,
+ _Xconst char* /* filename */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ Pixmap* /* bitmap_return */,
+ int* /* x_hot_return */,
+ int* /* y_hot_return */
+);
+
+extern int XReadBitmapFileData(
+ _Xconst char* /* filename */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned char** /* data_return */,
+ int* /* x_hot_return */,
+ int* /* y_hot_return */
+);
+
+extern int XRebindKeysym(
+ Display* /* display */,
+ KeySym /* keysym */,
+ KeySym* /* list */,
+ int /* mod_count */,
+ _Xconst unsigned char* /* string */,
+ int /* bytes_string */
+);
+
+extern int XRecolorCursor(
+ Display* /* display */,
+ Cursor /* cursor */,
+ XColor* /* foreground_color */,
+ XColor* /* background_color */
+);
+
+extern int XRefreshKeyboardMapping(
+ XMappingEvent* /* event_map */
+);
+
+extern int XRemoveFromSaveSet(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XRemoveHost(
+ Display* /* display */,
+ XHostAddress* /* host */
+);
+
+extern int XRemoveHosts(
+ Display* /* display */,
+ XHostAddress* /* hosts */,
+ int /* num_hosts */
+);
+
+extern int XReparentWindow(
+ Display* /* display */,
+ Window /* w */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */
+);
+
+extern int XResetScreenSaver(
+ Display* /* display */
+);
+
+extern int XResizeWindow(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XRestackWindows(
+ Display* /* display */,
+ Window* /* windows */,
+ int /* nwindows */
+);
+
+extern int XRotateBuffers(
+ Display* /* display */,
+ int /* rotate */
+);
+
+extern int XRotateWindowProperties(
+ Display* /* display */,
+ Window /* w */,
+ Atom* /* properties */,
+ int /* num_prop */,
+ int /* npositions */
+);
+
+extern int XScreenCount(
+ Display* /* display */
+);
+
+extern int XSelectInput(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */
+);
+
+extern Status XSendEvent(
+ Display* /* display */,
+ Window /* w */,
+ Bool /* propagate */,
+ long /* event_mask */,
+ XEvent* /* event_send */
+);
+
+extern int XSetAccessControl(
+ Display* /* display */,
+ int /* mode */
+);
+
+extern int XSetArcMode(
+ Display* /* display */,
+ GC /* gc */,
+ int /* arc_mode */
+);
+
+extern int XSetBackground(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* background */
+);
+
+extern int XSetClipMask(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* pixmap */
+);
+
+extern int XSetClipOrigin(
+ Display* /* display */,
+ GC /* gc */,
+ int /* clip_x_origin */,
+ int /* clip_y_origin */
+);
+
+extern int XSetClipRectangles(
+ Display* /* display */,
+ GC /* gc */,
+ int /* clip_x_origin */,
+ int /* clip_y_origin */,
+ XRectangle* /* rectangles */,
+ int /* n */,
+ int /* ordering */
+);
+
+extern int XSetCloseDownMode(
+ Display* /* display */,
+ int /* close_mode */
+);
+
+extern int XSetCommand(
+ Display* /* display */,
+ Window /* w */,
+ char** /* argv */,
+ int /* argc */
+);
+
+extern int XSetDashes(
+ Display* /* display */,
+ GC /* gc */,
+ int /* dash_offset */,
+ _Xconst char* /* dash_list */,
+ int /* n */
+);
+
+extern int XSetFillRule(
+ Display* /* display */,
+ GC /* gc */,
+ int /* fill_rule */
+);
+
+extern int XSetFillStyle(
+ Display* /* display */,
+ GC /* gc */,
+ int /* fill_style */
+);
+
+extern int XSetFont(
+ Display* /* display */,
+ GC /* gc */,
+ Font /* font */
+);
+
+extern int XSetFontPath(
+ Display* /* display */,
+ char** /* directories */,
+ int /* ndirs */
+);
+
+extern int XSetForeground(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* foreground */
+);
+
+extern int XSetFunction(
+ Display* /* display */,
+ GC /* gc */,
+ int /* function */
+);
+
+extern int XSetGraphicsExposures(
+ Display* /* display */,
+ GC /* gc */,
+ Bool /* graphics_exposures */
+);
+
+extern int XSetIconName(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* icon_name */
+);
+
+extern int XSetInputFocus(
+ Display* /* display */,
+ Window /* focus */,
+ int /* revert_to */,
+ Time /* time */
+);
+
+extern int XSetLineAttributes(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned int /* line_width */,
+ int /* line_style */,
+ int /* cap_style */,
+ int /* join_style */
+);
+
+extern int XSetModifierMapping(
+ Display* /* display */,
+ XModifierKeymap* /* modmap */
+);
+
+extern int XSetPlaneMask(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* plane_mask */
+);
+
+extern int XSetPointerMapping(
+ Display* /* display */,
+ _Xconst unsigned char* /* map */,
+ int /* nmap */
+);
+
+extern int XSetScreenSaver(
+ Display* /* display */,
+ int /* timeout */,
+ int /* interval */,
+ int /* prefer_blanking */,
+ int /* allow_exposures */
+);
+
+extern int XSetSelectionOwner(
+ Display* /* display */,
+ Atom /* selection */,
+ Window /* owner */,
+ Time /* time */
+);
+
+extern int XSetState(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* foreground */,
+ unsigned long /* background */,
+ int /* function */,
+ unsigned long /* plane_mask */
+);
+
+extern int XSetStipple(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* stipple */
+);
+
+extern int XSetSubwindowMode(
+ Display* /* display */,
+ GC /* gc */,
+ int /* subwindow_mode */
+);
+
+extern int XSetTSOrigin(
+ Display* /* display */,
+ GC /* gc */,
+ int /* ts_x_origin */,
+ int /* ts_y_origin */
+);
+
+extern int XSetTile(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* tile */
+);
+
+extern int XSetWindowBackground(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* background_pixel */
+);
+
+extern int XSetWindowBackgroundPixmap(
+ Display* /* display */,
+ Window /* w */,
+ Pixmap /* background_pixmap */
+);
+
+extern int XSetWindowBorder(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* border_pixel */
+);
+
+extern int XSetWindowBorderPixmap(
+ Display* /* display */,
+ Window /* w */,
+ Pixmap /* border_pixmap */
+);
+
+extern int XSetWindowBorderWidth(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* width */
+);
+
+extern int XSetWindowColormap(
+ Display* /* display */,
+ Window /* w */,
+ Colormap /* colormap */
+);
+
+extern int XStoreBuffer(
+ Display* /* display */,
+ _Xconst char* /* bytes */,
+ int /* nbytes */,
+ int /* buffer */
+);
+
+extern int XStoreBytes(
+ Display* /* display */,
+ _Xconst char* /* bytes */,
+ int /* nbytes */
+);
+
+extern int XStoreColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* color */
+);
+
+extern int XStoreColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* color */,
+ int /* ncolors */
+);
+
+extern int XStoreName(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* window_name */
+);
+
+extern int XStoreNamedColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color */,
+ unsigned long /* pixel */,
+ int /* flags */
+);
+
+extern int XSync(
+ Display* /* display */,
+ Bool /* discard */
+);
+
+extern int XTextExtents(
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern int XTextExtents16(
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern int XTextWidth(
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* count */
+);
+
+extern int XTextWidth16(
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* count */
+);
+
+extern Bool XTranslateCoordinates(
+ Display* /* display */,
+ Window /* src_w */,
+ Window /* dest_w */,
+ int /* src_x */,
+ int /* src_y */,
+ int* /* dest_x_return */,
+ int* /* dest_y_return */,
+ Window* /* child_return */
+);
+
+extern int XUndefineCursor(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XUngrabButton(
+ Display* /* display */,
+ unsigned int /* button */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */
+);
+
+extern int XUngrabKey(
+ Display* /* display */,
+ int /* keycode */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */
+);
+
+extern int XUngrabKeyboard(
+ Display* /* display */,
+ Time /* time */
+);
+
+extern int XUngrabPointer(
+ Display* /* display */,
+ Time /* time */
+);
+
+extern int XUngrabServer(
+ Display* /* display */
+);
+
+extern int XUninstallColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+extern int XUnloadFont(
+ Display* /* display */,
+ Font /* font */
+);
+
+extern int XUnmapSubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XUnmapWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XVendorRelease(
+ Display* /* display */
+);
+
+extern int XWarpPointer(
+ Display* /* display */,
+ Window /* src_w */,
+ Window /* dest_w */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* src_width */,
+ unsigned int /* src_height */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+extern int XWidthMMOfScreen(
+ Screen* /* screen */
+);
+
+extern int XWidthOfScreen(
+ Screen* /* screen */
+);
+
+extern int XWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern int XWriteBitmapFile(
+ Display* /* display */,
+ _Xconst char* /* filename */,
+ Pixmap /* bitmap */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* x_hot */,
+ int /* y_hot */
+);
+
+extern Bool XSupportsLocale (void);
+
+extern char *XSetLocaleModifiers(
+ const char* /* modifier_list */
+);
+
+extern XOM XOpenOM(
+ Display* /* display */,
+ struct _XrmHashBucketRec* /* rdb */,
+ _Xconst char* /* res_name */,
+ _Xconst char* /* res_class */
+);
+
+extern Status XCloseOM(
+ XOM /* om */
+);
+
+extern char *XSetOMValues(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+extern char *XGetOMValues(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+extern Display *XDisplayOfOM(
+ XOM /* om */
+);
+
+extern char *XLocaleOfOM(
+ XOM /* om */
+);
+
+extern XOC XCreateOC(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+extern void XDestroyOC(
+ XOC /* oc */
+);
+
+extern XOM XOMOfOC(
+ XOC /* oc */
+);
+
+extern char *XSetOCValues(
+ XOC /* oc */,
+ ...
+) _X_SENTINEL(0);
+
+extern char *XGetOCValues(
+ XOC /* oc */,
+ ...
+) _X_SENTINEL(0);
+
+extern XFontSet XCreateFontSet(
+ Display* /* display */,
+ _Xconst char* /* base_font_name_list */,
+ char*** /* missing_charset_list */,
+ int* /* missing_charset_count */,
+ char** /* def_string */
+);
+
+extern void XFreeFontSet(
+ Display* /* display */,
+ XFontSet /* font_set */
+);
+
+extern int XFontsOfFontSet(
+ XFontSet /* font_set */,
+ XFontStruct*** /* font_struct_list */,
+ char*** /* font_name_list */
+);
+
+extern char *XBaseFontNameListOfFontSet(
+ XFontSet /* font_set */
+);
+
+extern char *XLocaleOfFontSet(
+ XFontSet /* font_set */
+);
+
+extern Bool XContextDependentDrawing(
+ XFontSet /* font_set */
+);
+
+extern Bool XDirectionalDependentDrawing(
+ XFontSet /* font_set */
+);
+
+extern Bool XContextualDrawing(
+ XFontSet /* font_set */
+);
+
+extern XFontSetExtents *XExtentsOfFontSet(
+ XFontSet /* font_set */
+);
+
+extern int XmbTextEscapement(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern int XwcTextEscapement(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+extern int Xutf8TextEscapement(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern int XmbTextExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern int XwcTextExtents(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern int Xutf8TextExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern Status XmbTextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern Status XwcTextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern Status Xutf8TextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern void XmbDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XmbTextItem* /* text_items */,
+ int /* nitems */
+);
+
+extern void XwcDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XwcTextItem* /* text_items */,
+ int /* nitems */
+);
+
+extern void Xutf8DrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XmbTextItem* /* text_items */,
+ int /* nitems */
+);
+
+extern void XmbDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern void XwcDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+extern void Xutf8DrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern void XmbDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern void XwcDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+extern void Xutf8DrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern XIM XOpenIM(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */
+);
+
+extern Status XCloseIM(
+ XIM /* im */
+);
+
+extern char *XGetIMValues(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+extern char *XSetIMValues(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+extern Display *XDisplayOfIM(
+ XIM /* im */
+);
+
+extern char *XLocaleOfIM(
+ XIM /* im*/
+);
+
+extern XIC XCreateIC(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+extern void XDestroyIC(
+ XIC /* ic */
+);
+
+extern void XSetICFocus(
+ XIC /* ic */
+);
+
+extern void XUnsetICFocus(
+ XIC /* ic */
+);
+
+extern wchar_t *XwcResetIC(
+ XIC /* ic */
+);
+
+extern char *XmbResetIC(
+ XIC /* ic */
+);
+
+extern char *Xutf8ResetIC(
+ XIC /* ic */
+);
+
+extern char *XSetICValues(
+ XIC /* ic */, ...
+) _X_SENTINEL(0);
+
+extern char *XGetICValues(
+ XIC /* ic */, ...
+) _X_SENTINEL(0);
+
+extern XIM XIMOfIC(
+ XIC /* ic */
+);
+
+extern Bool XFilterEvent(
+ XEvent* /* event */,
+ Window /* window */
+);
+
+extern int XmbLookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ char* /* buffer_return */,
+ int /* bytes_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+extern int XwcLookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ wchar_t* /* buffer_return */,
+ int /* wchars_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+extern int Xutf8LookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ char* /* buffer_return */,
+ int /* bytes_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+extern XVaNestedList XVaCreateNestedList(
+ int /*unused*/, ...
+) _X_SENTINEL(0);
+
+/* internal connections for IMs */
+
+extern Bool XRegisterIMInstantiateCallback(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIDProc /* callback */,
+ XPointer /* client_data */
+);
+
+extern Bool XUnregisterIMInstantiateCallback(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIDProc /* callback */,
+ XPointer /* client_data */
+);
+
+typedef void (*XConnectionWatchProc)(
+ Display* /* dpy */,
+ XPointer /* client_data */,
+ int /* fd */,
+ Bool /* opening */, /* open or close flag */
+ XPointer* /* watch_data */ /* open sets, close uses */
+);
+
+
+extern Status XInternalConnectionNumbers(
+ Display* /* dpy */,
+ int** /* fd_return */,
+ int* /* count_return */
+);
+
+extern void XProcessInternalConnection(
+ Display* /* dpy */,
+ int /* fd */
+);
+
+extern Status XAddConnectionWatch(
+ Display* /* dpy */,
+ XConnectionWatchProc /* callback */,
+ XPointer /* client_data */
+);
+
+extern void XRemoveConnectionWatch(
+ Display* /* dpy */,
+ XConnectionWatchProc /* callback */,
+ XPointer /* client_data */
+);
+
+extern void XSetAuthorization(
+ char * /* name */,
+ int /* namelen */,
+ char * /* data */,
+ int /* datalen */
+);
+
+extern int _Xmbtowc(
+ wchar_t * /* wstr */,
+#ifdef ISC
+ char const * /* str */,
+ size_t /* len */
+#else
+ char * /* str */,
+ int /* len */
+#endif
+);
+
+extern int _Xwctomb(
+ char * /* str */,
+ wchar_t /* wc */
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XLIB_H_ */
diff --git a/nx-X11/lib/X11/XlibAsync.c b/nx-X11/lib/X11/XlibAsync.c
new file mode 100644
index 000000000..70bd82bad
--- /dev/null
+++ b/nx-X11/lib/X11/XlibAsync.c
@@ -0,0 +1,181 @@
+/* $Xorg: XlibAsync.c,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+Copyright 1992, 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 (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xos.h>
+
+/*ARGSUSED*/
+Bool
+_XAsyncErrorHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ register _XAsyncErrorState *state;
+
+ state = (_XAsyncErrorState *)data;
+ if (rep->generic.type == X_Error &&
+ (!state->error_code ||
+ rep->error.errorCode == state->error_code) &&
+ (!state->major_opcode ||
+ rep->error.majorCode == state->major_opcode) &&
+ (!state->minor_opcode ||
+ rep->error.minorCode == state->minor_opcode) &&
+ (!state->min_sequence_number ||
+ (state->min_sequence_number <= dpy->last_request_read)) &&
+ (!state->max_sequence_number ||
+ (state->max_sequence_number >= dpy->last_request_read))) {
+ state->last_error_received = rep->error.errorCode;
+ state->error_count++;
+ return True;
+ }
+ return False;
+}
+
+void _XDeqAsyncHandler(dpy, handler)
+ Display *dpy;
+ register _XAsyncHandler *handler;
+{
+ register _XAsyncHandler **prev;
+ register _XAsyncHandler *async;
+
+ for (prev = &dpy->async_handlers;
+ (async = *prev) && (async != handler);
+ prev = &async->next)
+ ;
+ if (async)
+ *prev = async->next;
+}
+
+char *
+_XGetAsyncReply(dpy, replbuf, rep, buf, len, extra, discard)
+ register Display *dpy;
+ register char *replbuf; /* data is read into this buffer */
+ register xReply *rep; /* value passed to calling handler */
+ char *buf; /* value passed to calling handler */
+ int len; /* value passed to calling handler */
+ int extra; /* extra words to read, ala _XReply */
+ Bool discard; /* discard after extra?, ala _XReply */
+{
+ if (extra == 0) {
+ if (discard && (rep->generic.length << 2) > len)
+ _XEatData (dpy, (rep->generic.length << 2) - len);
+ return (char *)rep;
+ }
+
+ if (extra <= rep->generic.length) {
+ int size = SIZEOF(xReply) + (extra << 2);
+ if (size > len) {
+ memcpy(replbuf, buf, len);
+ _XRead(dpy, replbuf + len, size - len);
+ buf = replbuf;
+ len = size;
+#ifdef MUSTCOPY
+ } else {
+ memcpy(replbuf, buf, size);
+ buf = replbuf;
+#endif
+ }
+
+ if (discard && rep->generic.length > extra &&
+ (rep->generic.length << 2) > len)
+ _XEatData (dpy, (rep->generic.length << 2) - len);
+
+ return buf;
+ }
+ /*
+ *if we get here, then extra > rep->generic.length--meaning we
+ * read a reply that's shorter than we expected. This is an
+ * error, but we still need to figure out how to handle it...
+ */
+ if ((rep->generic.length << 2) > len)
+ _XEatData (dpy, (rep->generic.length << 2) - len);
+#ifdef NX_TRANS_SOCKET
+
+ /*
+ * The original code has provision
+ * for returning already.
+ */
+
+#endif
+ _XIOError (dpy);
+ return (char *)rep;
+}
+
+void
+_XGetAsyncData(dpy, data, buf, len, skip, datalen, discardtotal)
+ Display *dpy;
+ char *data; /* data is read into this buffer */
+ char *buf; /* value passed to calling handler */
+ int len; /* value passed to calling handler */
+ int skip; /* number of bytes already read in previous
+ _XGetAsyncReply or _XGetAsyncData calls */
+ int datalen; /* size of data buffer in bytes */
+ int discardtotal; /* min. bytes to consume (after skip) */
+{
+ buf += skip;
+ len -= skip;
+ if (!data) {
+ if (datalen > len)
+ _XEatData(dpy, datalen - len);
+ } else if (datalen <= len) {
+ memcpy(data, buf, datalen);
+ } else {
+ memcpy(data, buf, len);
+ _XRead(dpy, data + len, datalen - len);
+ }
+ if (discardtotal > len) {
+ if (datalen > len)
+ len = datalen;
+ _XEatData(dpy, discardtotal - len);
+ }
+}
diff --git a/nx-X11/lib/X11/XlibAsync.c.NX.original b/nx-X11/lib/X11/XlibAsync.c.NX.original
new file mode 100644
index 000000000..70bd82bad
--- /dev/null
+++ b/nx-X11/lib/X11/XlibAsync.c.NX.original
@@ -0,0 +1,181 @@
+/* $Xorg: XlibAsync.c,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+Copyright 1992, 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 (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xos.h>
+
+/*ARGSUSED*/
+Bool
+_XAsyncErrorHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ register _XAsyncErrorState *state;
+
+ state = (_XAsyncErrorState *)data;
+ if (rep->generic.type == X_Error &&
+ (!state->error_code ||
+ rep->error.errorCode == state->error_code) &&
+ (!state->major_opcode ||
+ rep->error.majorCode == state->major_opcode) &&
+ (!state->minor_opcode ||
+ rep->error.minorCode == state->minor_opcode) &&
+ (!state->min_sequence_number ||
+ (state->min_sequence_number <= dpy->last_request_read)) &&
+ (!state->max_sequence_number ||
+ (state->max_sequence_number >= dpy->last_request_read))) {
+ state->last_error_received = rep->error.errorCode;
+ state->error_count++;
+ return True;
+ }
+ return False;
+}
+
+void _XDeqAsyncHandler(dpy, handler)
+ Display *dpy;
+ register _XAsyncHandler *handler;
+{
+ register _XAsyncHandler **prev;
+ register _XAsyncHandler *async;
+
+ for (prev = &dpy->async_handlers;
+ (async = *prev) && (async != handler);
+ prev = &async->next)
+ ;
+ if (async)
+ *prev = async->next;
+}
+
+char *
+_XGetAsyncReply(dpy, replbuf, rep, buf, len, extra, discard)
+ register Display *dpy;
+ register char *replbuf; /* data is read into this buffer */
+ register xReply *rep; /* value passed to calling handler */
+ char *buf; /* value passed to calling handler */
+ int len; /* value passed to calling handler */
+ int extra; /* extra words to read, ala _XReply */
+ Bool discard; /* discard after extra?, ala _XReply */
+{
+ if (extra == 0) {
+ if (discard && (rep->generic.length << 2) > len)
+ _XEatData (dpy, (rep->generic.length << 2) - len);
+ return (char *)rep;
+ }
+
+ if (extra <= rep->generic.length) {
+ int size = SIZEOF(xReply) + (extra << 2);
+ if (size > len) {
+ memcpy(replbuf, buf, len);
+ _XRead(dpy, replbuf + len, size - len);
+ buf = replbuf;
+ len = size;
+#ifdef MUSTCOPY
+ } else {
+ memcpy(replbuf, buf, size);
+ buf = replbuf;
+#endif
+ }
+
+ if (discard && rep->generic.length > extra &&
+ (rep->generic.length << 2) > len)
+ _XEatData (dpy, (rep->generic.length << 2) - len);
+
+ return buf;
+ }
+ /*
+ *if we get here, then extra > rep->generic.length--meaning we
+ * read a reply that's shorter than we expected. This is an
+ * error, but we still need to figure out how to handle it...
+ */
+ if ((rep->generic.length << 2) > len)
+ _XEatData (dpy, (rep->generic.length << 2) - len);
+#ifdef NX_TRANS_SOCKET
+
+ /*
+ * The original code has provision
+ * for returning already.
+ */
+
+#endif
+ _XIOError (dpy);
+ return (char *)rep;
+}
+
+void
+_XGetAsyncData(dpy, data, buf, len, skip, datalen, discardtotal)
+ Display *dpy;
+ char *data; /* data is read into this buffer */
+ char *buf; /* value passed to calling handler */
+ int len; /* value passed to calling handler */
+ int skip; /* number of bytes already read in previous
+ _XGetAsyncReply or _XGetAsyncData calls */
+ int datalen; /* size of data buffer in bytes */
+ int discardtotal; /* min. bytes to consume (after skip) */
+{
+ buf += skip;
+ len -= skip;
+ if (!data) {
+ if (datalen > len)
+ _XEatData(dpy, datalen - len);
+ } else if (datalen <= len) {
+ memcpy(data, buf, datalen);
+ } else {
+ memcpy(data, buf, len);
+ _XRead(dpy, data + len, datalen - len);
+ }
+ if (discardtotal > len) {
+ if (datalen > len)
+ len = datalen;
+ _XEatData(dpy, discardtotal - len);
+ }
+}
diff --git a/nx-X11/lib/X11/XlibAsync.c.X.original b/nx-X11/lib/X11/XlibAsync.c.X.original
new file mode 100644
index 000000000..a0314ba81
--- /dev/null
+++ b/nx-X11/lib/X11/XlibAsync.c.X.original
@@ -0,0 +1,156 @@
+/* $Xorg: XlibAsync.c,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+Copyright 1992, 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
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xos.h>
+
+/*ARGSUSED*/
+Bool
+_XAsyncErrorHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ register _XAsyncErrorState *state;
+
+ state = (_XAsyncErrorState *)data;
+ if (rep->generic.type == X_Error &&
+ (!state->error_code ||
+ rep->error.errorCode == state->error_code) &&
+ (!state->major_opcode ||
+ rep->error.majorCode == state->major_opcode) &&
+ (!state->minor_opcode ||
+ rep->error.minorCode == state->minor_opcode) &&
+ (!state->min_sequence_number ||
+ (state->min_sequence_number <= dpy->last_request_read)) &&
+ (!state->max_sequence_number ||
+ (state->max_sequence_number >= dpy->last_request_read))) {
+ state->last_error_received = rep->error.errorCode;
+ state->error_count++;
+ return True;
+ }
+ return False;
+}
+
+void _XDeqAsyncHandler(dpy, handler)
+ Display *dpy;
+ register _XAsyncHandler *handler;
+{
+ register _XAsyncHandler **prev;
+ register _XAsyncHandler *async;
+
+ for (prev = &dpy->async_handlers;
+ (async = *prev) && (async != handler);
+ prev = &async->next)
+ ;
+ if (async)
+ *prev = async->next;
+}
+
+char *
+_XGetAsyncReply(dpy, replbuf, rep, buf, len, extra, discard)
+ register Display *dpy;
+ register char *replbuf; /* data is read into this buffer */
+ register xReply *rep; /* value passed to calling handler */
+ char *buf; /* value passed to calling handler */
+ int len; /* value passed to calling handler */
+ int extra; /* extra words to read, ala _XReply */
+ Bool discard; /* discard after extra?, ala _XReply */
+{
+ if (extra == 0) {
+ if (discard && (rep->generic.length << 2) > len)
+ _XEatData (dpy, (rep->generic.length << 2) - len);
+ return (char *)rep;
+ }
+
+ if (extra <= rep->generic.length) {
+ int size = SIZEOF(xReply) + (extra << 2);
+ if (size > len) {
+ memcpy(replbuf, buf, len);
+ _XRead(dpy, replbuf + len, size - len);
+ buf = replbuf;
+ len = size;
+#ifdef MUSTCOPY
+ } else {
+ memcpy(replbuf, buf, size);
+ buf = replbuf;
+#endif
+ }
+
+ if (discard && rep->generic.length > extra &&
+ (rep->generic.length << 2) > len)
+ _XEatData (dpy, (rep->generic.length << 2) - len);
+
+ return buf;
+ }
+ /*
+ *if we get here, then extra > rep->generic.length--meaning we
+ * read a reply that's shorter than we expected. This is an
+ * error, but we still need to figure out how to handle it...
+ */
+ if ((rep->generic.length << 2) > len)
+ _XEatData (dpy, (rep->generic.length << 2) - len);
+ _XIOError (dpy);
+ return (char *)rep;
+}
+
+void
+_XGetAsyncData(dpy, data, buf, len, skip, datalen, discardtotal)
+ Display *dpy;
+ char *data; /* data is read into this buffer */
+ char *buf; /* value passed to calling handler */
+ int len; /* value passed to calling handler */
+ int skip; /* number of bytes already read in previous
+ _XGetAsyncReply or _XGetAsyncData calls */
+ int datalen; /* size of data buffer in bytes */
+ int discardtotal; /* min. bytes to consume (after skip) */
+{
+ buf += skip;
+ len -= skip;
+ if (!data) {
+ if (datalen > len)
+ _XEatData(dpy, datalen - len);
+ } else if (datalen <= len) {
+ memcpy(data, buf, datalen);
+ } else {
+ memcpy(data, buf, len);
+ _XRead(dpy, data + len, datalen - len);
+ }
+ if (discardtotal > len) {
+ if (datalen > len)
+ len = datalen;
+ _XEatData(dpy, discardtotal - len);
+ }
+}
diff --git a/nx-X11/lib/X11/XlibConf.h b/nx-X11/lib/X11/XlibConf.h
new file mode 100644
index 000000000..32fc91b2e
--- /dev/null
+++ b/nx-X11/lib/X11/XlibConf.h
@@ -0,0 +1,7 @@
+/* Defines needed to use Xlib from non-imake projects */
+#ifndef XTHREADS
+#define XTHREADS
+#endif
+#ifndef XUSE_MTSAFE_API
+#define XUSE_MTSAFE_API
+#endif
diff --git a/nx-X11/lib/X11/XlibInt.c b/nx-X11/lib/X11/XlibInt.c
new file mode 100644
index 000000000..47e2ea139
--- /dev/null
+++ b/nx-X11/lib/X11/XlibInt.c
@@ -0,0 +1,4167 @@
+/* $Xorg: XlibInt.c,v 1.8 2001/02/09 02:03:38 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.
+
+*/
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/* $XFree86: xc/lib/X11/XlibInt.c,v 3.38 2003/10/30 21:55:05 alanh Exp $ */
+
+/*
+ * XlibInt.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
+
+#ifdef WIN32
+#define _XLIBINT_
+#endif
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xpoll.h>
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/extensions/xcmiscstr.h>
+#include <stdio.h>
+#ifdef WIN32
+#include <direct.h>
+#endif
+
+#ifdef XTHREADS
+#include "locking.h"
+
+/* these pointers get initialized by XInitThreads */
+LockInfoPtr _Xglobal_lock = NULL;
+void (*_XCreateMutex_fn)(LockInfoPtr) = NULL;
+/* struct _XCVList *(*_XCreateCVL_fn)() = NULL; */
+void (*_XFreeMutex_fn)(LockInfoPtr) = NULL;
+void (*_XLockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = NULL;
+void (*_XUnlockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = NULL;
+xthread_t (*_Xthread_self_fn)(void) = NULL;
+
+#define XThread_Self() ((*_Xthread_self_fn)())
+
+#define UnlockNextReplyReader(d) if ((d)->lock) \
+ (*(d)->lock->pop_reader)((d),&(d)->lock->reply_awaiters,&(d)->lock->reply_awaiters_tail)
+
+#define QueueReplyReaderLock(d) ((d)->lock ? \
+ (*(d)->lock->push_reader)(d,&(d)->lock->reply_awaiters_tail) : NULL)
+#define QueueEventReaderLock(d) ((d)->lock ? \
+ (*(d)->lock->push_reader)(d,&(d)->lock->event_awaiters_tail) : NULL)
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+#define InternalLockDisplay(d,wskip) if ((d)->lock) \
+ (*(d)->lock->internal_lock_display)(d,wskip,__FILE__,__LINE__)
+#else
+#define InternalLockDisplay(d,wskip) if ((d)->lock) \
+ (*(d)->lock->internal_lock_display)(d,wskip)
+#endif
+
+#else /* XTHREADS else */
+
+#define UnlockNextReplyReader(d)
+#define UnlockNextEventReader(d)
+#define InternalLockDisplay(d,wskip)
+
+#endif /* XTHREADS else */
+
+#include "NX.h"
+
+#ifdef NX_TRANS_SOCKET
+
+#include "NX.h"
+#include "NXvars.h"
+
+static struct timeval retry;
+
+/*
+ * From Xtranssock.c. Presently the congestion state
+ * is reported by the proxy to the application, by
+ * invoking the callback directly. The function will
+ * be possibly used in the future, to be able to track
+ * the bandwidth usage even when the NX transport is
+ * not running. Note that in this sample implementation
+ * the congestion state is checked very often and can
+ * be surely optimized.
+ */
+
+#ifdef NX_TRANS_CHANGE
+
+extern int _X11TransSocketCongestionChange(XtransConnInfo, int *);
+
+#endif
+
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ */
+#ifdef WIN32
+#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK)
+#else
+#ifdef __CYGWIN__ /* Cygwin uses ENOBUFS to signal socket is full */
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS)
+#else
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define ETEST() (errno == EAGAIN)
+#else
+#define ETEST() (errno == EWOULDBLOCK)
+#endif /* EAGAIN */
+#endif /* EAGAIN && EWOULDBLOCK */
+#endif /* __CYGWIN__ */
+#endif /* WIN32 */
+
+#ifdef WIN32
+#define ECHECK(err) (WSAGetLastError() == err)
+#define ESET(val) WSASetLastError(val)
+#else
+#ifdef __UNIXOS2__
+#define ECHECK(err) (errno == err)
+#define ESET(val)
+#else
+#ifdef ISC
+#define ECHECK(err) ((errno == err) || ETEST())
+#else
+#define ECHECK(err) (errno == err)
+#endif
+#define ESET(val) errno = val
+#endif
+#endif
+
+#if defined(LOCALCONN) || defined(LACHMAN)
+#ifdef EMSGSIZE
+#define ESZTEST() (ECHECK(EMSGSIZE) || ECHECK(ERANGE))
+#else
+#define ESZTEST() ECHECK(ERANGE)
+#endif
+#else
+#ifdef EMSGSIZE
+#define ESZTEST() ECHECK(EMSGSIZE)
+#endif
+#endif
+
+#ifdef __UNIXOS2__
+#define select(n,r,w,x,t) os2ClientSelect(n,r,w,x,t)
+#include <limits.h>
+#define MAX_PATH _POSIX_PATH_MAX
+#endif
+
+#ifdef MUSTCOPY
+
+#define STARTITERATE(tpvar,type,start,endcond) \
+ { register char *cpvar; \
+ for (cpvar = (char *) (start); endcond; ) { \
+ type dummy; memcpy ((char *) &dummy, cpvar, SIZEOF(type)); \
+ tpvar = &dummy;
+#define ITERPTR(tpvar) cpvar
+#define RESETITERPTR(tpvar,type,start) cpvar = start
+#define INCITERPTR(tpvar,type) cpvar += SIZEOF(type)
+#define ENDITERATE }}
+
+#else
+
+#define STARTITERATE(tpvar,type,start,endcond) \
+ for (tpvar = (type *) (start); endcond; )
+#define ITERPTR(tpvar) (char *)tpvar
+#define RESETITERPTR(tpvar,type,start) tpvar = (type *) (start)
+#define INCITERPTR(tpvar,type) tpvar++
+#define ENDITERATE
+
+#endif /* MUSTCOPY */
+
+typedef union {
+ xReply rep;
+ char buf[BUFSIZE];
+} _XAlignedBuffer;
+
+static char *_XAsyncReply(
+ Display *dpy,
+ register xReply *rep,
+ char *buf,
+ register int *lenp,
+ Bool discard);
+
+static void _XProcessInternalConnection(
+ Display *dpy,
+ struct _XConnectionInfo *conn_info);
+
+#define SEQLIMIT (65535 - (BUFSIZE / SIZEOF(xReq)) - 10)
+
+/*
+ * The following routines are internal routines used by Xlib for protocol
+ * packet transmission and reception.
+ *
+ * _XIOError(Display *) will be called if any sort of system call error occurs.
+ * This is assumed to be a fatal condition, i.e., XIOError should not return.
+ *
+ * _XError(Display *, xError *) will be called whenever an X_Error event is
+ * received. This is not assumed to be a fatal condition, i.e., it is
+ * acceptable for this procedure to return. However, XError should NOT
+ * perform any operations (directly or indirectly) on the DISPLAY.
+ *
+ * Routines declared with a return type of 'Status' return 0 on failure,
+ * and non 0 on success. Routines with no declared return type don't
+ * return anything. Whenever possible routines that create objects return
+ * the object they have created.
+ */
+
+static xReq _dummy_request = {
+ 0, 0, 0
+};
+
+#ifdef NX_TRANS_SOCKET
+
+/*
+ * Replace the standard Select with a version giving NX a
+ * chance to check its own descriptors. This doesn't cover
+ * the cases where the system is using poll or when system-
+ * specific defines override the Select definition (OS/2).
+ */
+
+int _XSelect(int maxfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+{
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XSelect: Called with [%d][%p][%p][%p][%p].\n",
+ maxfds, (void *) readfds, (void *) writefds, (void *) exceptfds,
+ (void *) timeout);
+#endif
+
+ if (NXTransRunning(NX_FD_ANY))
+ {
+ fd_set t_readfds, t_writefds;
+ struct timeval t_timeout;
+
+ int n, r, e;
+
+#ifdef NX_TRANS_TEST
+
+ if (exceptfds != NULL)
+ {
+ fprintf(stderr, "_XSelect: WARNING! Can't handle exception fds in select.\n");
+ }
+
+#endif
+
+ if (readfds == NULL)
+ {
+ FD_ZERO(&t_readfds);
+
+ readfds = &t_readfds;
+ }
+
+ if (writefds == NULL)
+ {
+ FD_ZERO(&t_writefds);
+
+ writefds = &t_writefds;
+ }
+
+ if (timeout == NULL)
+ {
+ t_timeout.tv_sec = 10;
+ t_timeout.tv_usec = 0;
+
+ timeout = &t_timeout;
+ }
+
+ n = maxfds;
+
+ /*
+ * If the transport is gone avoid
+ * sleeping until the timeout.
+ */
+
+ if (NXTransPrepare(&n, readfds, writefds, timeout) != 0)
+ {
+ NXTransSelect(&r, &e, &n, readfds, writefds, timeout);
+
+ NXTransExecute(&r, &e, &n, readfds, writefds, timeout);
+
+ errno = e;
+
+ return r;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ return select(maxfds, readfds, writefds, exceptfds, timeout);
+ }
+}
+
+#else /* #ifdef NX_TRANS_SOCKET */
+
+int _XSelect(int maxfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+{
+ return select(maxfds, readfds, writefds, exceptfds, timeout);
+}
+
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+/*
+ * This is an OS dependent routine which:
+ * 1) returns as soon as the connection can be written on....
+ * 2) if the connection can be read, must enqueue events and handle errors,
+ * until the connection is writable.
+ */
+static void
+_XWaitForWritable(
+ Display *dpy
+#ifdef XTHREADS
+ ,
+ xcondition_t cv /* our reading condition variable */
+#endif
+ )
+{
+#ifdef USE_POLL
+ struct pollfd filedes;
+#else
+ fd_set r_mask;
+ fd_set w_mask;
+#endif
+ int nfound;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ int congestion;
+#endif
+
+#ifdef NX_TRANS_SOCKET
+
+ if (_XGetIOError(dpy)) {
+ return;
+ }
+
+#endif
+
+#ifdef USE_POLL
+ filedes.fd = dpy->fd;
+ filedes.events = 0;
+#else
+ FD_ZERO(&r_mask);
+ FD_ZERO(&w_mask);
+#endif
+
+ for (;;) {
+#ifdef XTHREADS
+ /* We allow only one thread at a time to read, to minimize
+ passing of read data between threads.
+ Now, who is it? If there is a non-NULL reply_awaiters and
+ we (i.e., our cv) are not at the head of it, then whoever
+ is at the head is the reader, and we don't read.
+ Otherwise there is no reply_awaiters or we are at the
+ head, having just appended ourselves.
+ In this case, if there is a event_awaiters, then whoever
+ is at the head of it got there before we did, and they are the
+ reader.
+
+ Last cases: no event_awaiters and we are at the head of
+ reply_awaiters or reply_awaiters is NULL: we are the reader,
+ since there is obviously no one else involved.
+
+ XXX - what if cv is NULL and someone else comes along after
+ us while we are waiting?
+ */
+
+ if (!dpy->lock ||
+ (!dpy->lock->event_awaiters &&
+ (!dpy->lock->reply_awaiters ||
+ dpy->lock->reply_awaiters->cv == cv)))
+#endif
+
+#ifndef NX_TRANS_SOCKET
+#ifdef USE_POLL
+ filedes.events = POLLIN;
+ filedes.events |= POLLOUT;
+#else
+ FD_SET(dpy->fd, &r_mask);
+ FD_SET(dpy->fd, &w_mask);
+#endif
+#endif /* #ifndef NX_TRANS_SOCKET */
+
+ do {
+#ifdef NX_TRANS_SOCKET
+ /*
+ * Give a chance to the registered client to perform
+ * any needed operation before entering the select.
+ */
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XWaitForWritable: WAIT! Waiting for the display to become writable.\n");
+#endif
+ NXTransFlush(dpy->fd);
+
+ if (_NXDisplayBlockFunction != NULL) {
+ (*_NXDisplayBlockFunction)(dpy, NXBlockWrite);
+ }
+
+ /*
+ * Need to set again the descriptors as we could have
+ * run multiple selects before having the possibility
+ * to read or write to the X connection.
+ */
+
+#ifdef USE_POLL
+ filedes.events = POLLIN;
+ filedes.events |= POLLOUT;
+#else
+ FD_SET(dpy->fd, &r_mask);
+ FD_SET(dpy->fd, &w_mask);
+#endif
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+ UnlockDisplay(dpy);
+#ifdef USE_POLL
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XWaitForWritable: Calling poll().\n");
+#endif
+ nfound = poll (&filedes, 1, -1);
+#else
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XWaitForWritable: Calling select() after [%ld] ms.\n",
+ NXTransTime());
+#endif
+#ifdef NX_TRANS_SOCKET
+ /*
+ * Give a chance to the callback to detect
+ * the failure of the display even if we
+ * miss the interrupt inside the select.
+ */
+
+ if (_NXDisplayErrorFunction != NULL) {
+ retry.tv_sec = 5;
+ retry.tv_usec = 0;
+ nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, &retry);
+ } else {
+ nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL);
+ }
+#else
+ nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL);
+#endif
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XWaitForWritable: Out of select() with [%d] after [%ld] ms.\n",
+ nfound, NXTransTime());
+
+ if (FD_ISSET(dpy->fd, &r_mask))
+ {
+ BytesReadable_t pend;
+
+ _X11TransBytesReadable(dpy->trans_conn, &pend);
+
+ fprintf(stderr, "_XWaitForWritable: Descriptor [%d] is ready with [%ld] bytes to read.\n",
+ dpy->fd, pend);
+ }
+
+ if (FD_ISSET(dpy->fd, &w_mask))
+ {
+ fprintf(stderr, "_XWaitForWritable: Descriptor [%d] has become writable.\n\n",
+ dpy->fd);
+ }
+#endif
+#endif
+ InternalLockDisplay(dpy, cv != NULL);
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+#endif
+
+#ifdef NX_TRANS_SOCKET
+ if (nfound <= 0) {
+ if ((nfound == -1 && !ECHECK(EINTR)) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return;
+ }
+ }
+#else
+ if (nfound < 0 && !ECHECK(EINTR))
+ _XIOError(dpy);
+#endif
+ } while (nfound <= 0);
+
+ if (
+#ifdef USE_POLL
+ filedes.revents & POLLIN
+#else
+ FD_ISSET(dpy->fd, &r_mask)
+#endif
+ )
+ {
+ _XAlignedBuffer buf;
+ BytesReadable_t pend;
+ register int len;
+ register xReply *rep;
+
+ /* find out how much data can be read */
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+#ifdef NX_TRANS_SOCKET
+ {
+ _XIOError(dpy);
+
+ return;
+ }
+#else
+ _XIOError(dpy);
+#endif
+ len = pend;
+
+ /* must read at least one xEvent; if none is pending, then
+ we'll just block waiting for it */
+ if (len < SIZEOF(xReply)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ )
+ len = SIZEOF(xReply);
+
+ /* but we won't read more than the max buffer size */
+ if (len > BUFSIZE) len = BUFSIZE;
+
+ /* round down to an integral number of XReps */
+ len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
+
+ (void) _XRead (dpy, buf.buf, (long) len);
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ int tmp = len;
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &tmp, True));
+ len = tmp;
+ pend = len;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *)rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->event_awaiters)
+ ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
+#endif
+ }
+#ifdef USE_POLL
+ if (filedes.revents & (POLLOUT|POLLHUP|POLLERR))
+#else
+ if (FD_ISSET(dpy->fd, &w_mask))
+#endif
+ {
+#ifdef XTHREADS
+ if (dpy->lock) {
+ ConditionBroadcast(dpy, dpy->lock->writers);
+ }
+#endif
+ return;
+ }
+ }
+}
+
+
+#define POLLFD_CACHE_SIZE 5
+
+/* initialize the struct array passed to poll() below */
+Bool _XPollfdCacheInit(
+ Display *dpy)
+{
+#ifdef USE_POLL
+ struct pollfd *pfp;
+
+ pfp = (struct pollfd *)Xmalloc(POLLFD_CACHE_SIZE * sizeof(struct pollfd));
+ if (!pfp)
+ return False;
+ pfp[0].fd = dpy->fd;
+ pfp[0].events = POLLIN;
+
+ dpy->filedes = (XPointer)pfp;
+#endif
+ return True;
+}
+
+void _XPollfdCacheAdd(
+ Display *dpy,
+ int fd)
+{
+#ifdef USE_POLL
+ struct pollfd *pfp = (struct pollfd *)dpy->filedes;
+
+ if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) {
+ pfp[dpy->im_fd_length].fd = fd;
+ pfp[dpy->im_fd_length].events = POLLIN;
+ }
+#endif
+}
+
+/* ARGSUSED */
+void _XPollfdCacheDel(
+ Display *dpy,
+ int fd) /* not used */
+{
+#ifdef USE_POLL
+ struct pollfd *pfp = (struct pollfd *)dpy->filedes;
+ struct _XConnectionInfo *conni;
+
+ /* just recalculate whole list */
+ if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) {
+ int loc = 1;
+ for (conni = dpy->im_fd_info; conni; conni=conni->next) {
+ pfp[loc].fd = conni->fd;
+ pfp[loc].events = POLLIN;
+ loc++;
+ }
+ }
+#endif
+}
+
+/* returns True iff there is an event in the queue newer than serial_num */
+
+static Bool
+_XNewerQueuedEvent(
+ Display *dpy,
+ int serial_num)
+{
+ _XQEvent *qev;
+
+ if (dpy->next_event_serial_num == serial_num)
+ return False;
+
+ qev = dpy->head;
+ while (qev) {
+ if (qev->qserial_num >= serial_num) {
+ return True;
+ }
+ qev = qev->next;
+ }
+ return False;
+}
+
+static int
+_XWaitForReadable(
+ Display *dpy)
+{
+ int result;
+ int fd = dpy->fd;
+ struct _XConnectionInfo *ilist;
+ register int saved_event_serial = 0;
+ int in_read_events = 0;
+ register Bool did_proc_conni = False;
+#ifdef USE_POLL
+ struct pollfd *filedes;
+#else
+ fd_set r_mask;
+ int highest_fd = fd;
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ int congestion;
+#endif
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return -1;
+ }
+#endif
+
+#ifdef USE_POLL
+ if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE
+ && !(dpy->flags & XlibDisplayProcConni)) {
+ /* XXX - this fallback is gross */
+ int i;
+
+ filedes = (struct pollfd *)Xmalloc(dpy->im_fd_length * sizeof(struct pollfd));
+ filedes[0].fd = fd;
+ filedes[0].events = POLLIN;
+ for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
+ filedes[i].fd = ilist->fd;
+ filedes[i].events = POLLIN;
+ }
+ } else {
+ filedes = (struct pollfd *)dpy->filedes;
+ }
+#else
+ FD_ZERO(&r_mask);
+#endif
+ for (;;) {
+#ifndef USE_POLL
+ FD_SET(fd, &r_mask);
+ if (!(dpy->flags & XlibDisplayProcConni))
+ for (ilist=dpy->im_fd_info; ilist; ilist=ilist->next) {
+ FD_SET(ilist->fd, &r_mask);
+ if (ilist->fd > highest_fd)
+ highest_fd = ilist->fd;
+ }
+#endif
+ UnlockDisplay(dpy);
+#ifdef USE_POLL
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XWaitForReadable: Calling poll().\n");
+#endif
+ result = poll(filedes,
+ (dpy->flags & XlibDisplayProcConni) ? 1 : 1+dpy->im_fd_length,
+ -1);
+#else
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XWaitForReadable: Calling select().\n");
+#endif
+#ifdef NX_TRANS_SOCKET
+ /*
+ * Give a chance to the registered application
+ * to perform any needed operation.
+ */
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XWaitForReadable: WAIT! Waiting for the display to become readable.\n");
+#endif
+ NXTransFlush(dpy->fd);
+
+ if (_NXDisplayBlockFunction != NULL) {
+ (*_NXDisplayBlockFunction)(dpy, NXBlockRead);
+ }
+
+ if (_NXDisplayErrorFunction != NULL) {
+ retry.tv_sec = 5;
+ retry.tv_usec = 0;
+ result = Select(highest_fd + 1, &r_mask, NULL, NULL, &retry);
+ } else {
+ result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL);
+ }
+#else
+ result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL);
+#endif
+#endif
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XWaitForReadable: Out of select with result [%d] and errno [%d].\n",
+ result, (result < 0 ? errno : 0));
+#endif
+ InternalLockDisplay(dpy, dpy->flags & XlibDisplayReply);
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+#endif
+#ifdef NX_TRANS_SOCKET
+ if (result <= 0) {
+ if ((result == -1 && !ECHECK(EINTR)) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return -1;
+ }
+ continue;
+ }
+#else
+ if (result == -1 && !ECHECK(EINTR)) _XIOError(dpy);
+ if (result <= 0)
+ continue;
+#endif
+#ifdef USE_POLL
+ if (filedes[0].revents & (POLLIN|POLLHUP|POLLERR))
+#else
+ if (FD_ISSET(fd, &r_mask))
+#endif
+ break;
+ if (!(dpy->flags & XlibDisplayProcConni)) {
+ int i;
+
+ saved_event_serial = dpy->next_event_serial_num;
+ /* dpy flags can be clobbered by internal connection callback */
+ in_read_events = dpy->flags & XlibDisplayReadEvents;
+ for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
+#ifdef USE_POLL
+ if (filedes[i].revents & POLLIN)
+#else
+ if (FD_ISSET(ilist->fd, &r_mask))
+#endif
+ {
+ _XProcessInternalConnection(dpy, ilist);
+ did_proc_conni = True;
+ }
+ }
+#ifdef USE_POLL
+ if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE)
+ Xfree(filedes);
+#endif
+ }
+ if (did_proc_conni) {
+ /* some internal connection callback might have done an
+ XPutBackEvent. We notice it here and if we needed an event,
+ we can return all the way. */
+ if (_XNewerQueuedEvent(dpy, saved_event_serial)
+ && (in_read_events
+#ifdef XTHREADS
+ || (dpy->lock && dpy->lock->event_awaiters)
+#endif
+ ))
+ return -2;
+ did_proc_conni = False;
+ }
+ }
+#ifdef XTHREADS
+#ifdef XTHREADS_DEBUG
+ printf("thread %x _XWaitForReadable returning\n", XThread_Self());
+#endif
+#endif
+ return 0;
+}
+
+static
+int _XSeqSyncFunction(
+ register Display *dpy)
+{
+ xGetInputFocusReply rep;
+ register xReq *req;
+
+#ifdef NX_TRANS_SOCKET
+#ifdef NX_TRANS_DEBUG
+ fprintf(stderr, "_XSeqSyncFunction: Going to synchronize the display.\n");
+#endif
+ if (dpy->flags & XlibDisplayIOError)
+ {
+#ifdef NX_TRANS_DEBUG
+ fprintf(stderr, "_XSeqSyncFunction: Returning 0 with I/O error detected.\n");
+#endif
+ return 0;
+ }
+#endif
+
+ LockDisplay(dpy);
+ if ((dpy->request - dpy->last_request_read) >= (BUFSIZE / SIZEOF(xReq))) {
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ }
+ /* could get XID handler while waiting for reply in MT env */
+ if (dpy->synchandler == _XSeqSyncFunction) {
+ dpy->synchandler = dpy->savedsynchandler;
+ dpy->flags &= ~XlibDisplayPrivSync;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
+#ifdef XTHREADS
+static void _XFlushInt(
+ register Display *dpy,
+ register xcondition_t cv);
+#endif
+
+/*
+ * _XFlush - Flush the X request buffer. If the buffer is empty, no
+ * action is taken. This routine correctly handles incremental writes.
+ * This routine may have to be reworked if int < long.
+ */
+void _XFlush(
+ register Display *dpy)
+{
+#ifdef XTHREADS
+ /* With multi-threading we introduce an internal routine to which
+ we can pass a condition variable to do locking correctly. */
+
+ _XFlushInt(dpy, NULL);
+}
+
+/* _XFlushInt - Internal version of _XFlush used to do multi-threaded
+ * locking correctly.
+ */
+
+static void _XFlushInt(
+ register Display *dpy,
+ register xcondition_t cv)
+{
+#endif /* XTHREADS*/
+ register long size, todo;
+ register int write_stat;
+ register char *bufindex;
+ _XExtension *ext;
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ int congestion;
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XFlushInt: Entering flush with [%d] bytes to write.\n",
+ (dpy->bufptr - dpy->buffer));
+#endif
+ /* This fix resets the bufptr to the front of the buffer so
+ * additional appends to the bufptr will not corrupt memory. Since
+ * the server is down, these appends are no-op's anyway but
+ * callers of _XFlush() are not verifying this before they call it.
+ */
+ if (dpy->flags & XlibDisplayIOError)
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XFlushInt: Returning with I/O error detected.\n");
+#endif
+ dpy->bufptr = dpy->buffer;
+ dpy->last_req = (char *)&_dummy_request;
+ return;
+ }
+
+#ifdef XTHREADS
+#ifdef NX_TRANS_SOCKET
+ while (dpy->flags & XlibDisplayWriting) {
+ if (_XGetIOError(dpy)) {
+ return;
+ }
+#else
+ while (dpy->flags & XlibDisplayWriting) {
+#endif
+ if (dpy->lock) {
+ ConditionWait(dpy, dpy->lock->writers);
+ } else {
+ _XWaitForWritable (dpy, cv);
+ }
+ }
+#endif
+ size = todo = dpy->bufptr - dpy->buffer;
+ if (!size) return;
+#ifdef XTHREADS
+ dpy->flags |= XlibDisplayWriting;
+ /* make sure no one else can put in data */
+ dpy->bufptr = dpy->bufmax;
+#endif
+ for (ext = dpy->flushes; ext; ext = ext->next_flush)
+ (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, size);
+ bufindex = dpy->buffer;
+ /*
+ * While write has not written the entire buffer, keep looping
+ * until the entire buffer is written. bufindex will be
+ * incremented and size decremented as buffer is written out.
+ */
+ while (size) {
+ ESET(0);
+ write_stat = _X11TransWrite(dpy->trans_conn,
+ bufindex, (int) todo);
+ if (write_stat >= 0) {
+#ifdef NX_TRANS_SOCKET
+ if (_NXDisplayWriteFunction != NULL) {
+ (*_NXDisplayWriteFunction)(dpy, write_stat);
+ }
+#ifdef NX_TRANS_CHANGE
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+#endif
+#endif
+ size -= write_stat;
+ todo = size;
+ bufindex += write_stat;
+ } else if (ETEST()) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+#ifdef SUNSYSV
+ } else if (ECHECK(0)) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+#endif
+#ifdef ESZTEST
+ } else if (ESZTEST()) {
+ if (todo > 1)
+ todo >>= 1;
+ else {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+ }
+#endif
+#ifdef NX_TRANS_SOCKET
+ } else if (!ECHECK(EINTR) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return;
+ }
+#else
+ } else if (!ECHECK(EINTR)) {
+ /* Write failed! */
+ /* errno set by write system call. */
+ _XIOError(dpy);
+ }
+#endif
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return;
+ }
+#endif
+ }
+ dpy->last_req = (char *)&_dummy_request;
+ if ((dpy->request - dpy->last_request_read) >= SEQLIMIT &&
+ !(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->synchandler = _XSeqSyncFunction;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->bufptr = dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags &= ~XlibDisplayWriting;
+#endif
+}
+
+int
+_XEventsQueued(
+ register Display *dpy,
+ int mode)
+{
+ register int len;
+ BytesReadable_t pend;
+ _XAlignedBuffer buf;
+ register xReply *rep;
+ char *read_buf;
+#ifdef XTHREADS
+ int entry_event_serial_num;
+ struct _XCVList *cvl = NULL;
+ xthread_t self;
+
+#ifdef XTHREADS_DEBUG
+ printf("_XEventsQueued called in thread %x\n", XThread_Self());
+#endif
+#endif /* XTHREADS*/
+
+ if (mode == QueuedAfterFlush)
+ {
+ _XFlush(dpy);
+ if (dpy->qlen)
+ return(dpy->qlen);
+ }
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ if (dpy->flags & XlibDisplayIOError) {
+ fprintf(stderr, "_XEventsQueued: Returning [%d] after display failure.\n",
+ dpy->qlen);
+ }
+#endif
+ if (dpy->flags & XlibDisplayIOError) return(dpy->qlen);
+
+#ifdef XTHREADS
+ /* create our condition variable and append to list,
+ * unless we were called from within XProcessInternalConnection
+ * or XLockDisplay
+ */
+ xthread_clear_id(self);
+ if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
+ || xthread_have_id (dpy->lock->locking_thread)))
+ /* some thread is in XProcessInternalConnection or XLockDisplay
+ so we have to see if we are it */
+ self = XThread_Self();
+ if (!xthread_have_id(self)
+ || (!xthread_equal(self, dpy->lock->conni_thread)
+ && !xthread_equal(self, dpy->lock->locking_thread))) {
+ /* In the multi-threaded case, if there is someone else
+ reading events, then there aren't any available, so
+ we just return. If we waited we would block.
+ */
+ if (dpy->lock && dpy->lock->event_awaiters)
+ return dpy->qlen;
+ /* nobody here but us, so lock out any newcomers */
+ cvl = QueueEventReaderLock(dpy);
+ }
+
+ while (dpy->lock && cvl && dpy->lock->reply_first) {
+ /* note which events we have already seen so we'll know
+ if _XReply (in another thread) reads one */
+ entry_event_serial_num = dpy->next_event_serial_num;
+ ConditionWait(dpy, cvl->cv);
+ /* did _XReply read an event we can return? */
+ if (_XNewerQueuedEvent(dpy, entry_event_serial_num))
+ {
+ UnlockNextEventReader(dpy);
+ return 0;
+ }
+ }
+#endif /* XTHREADS*/
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XEventsQueued: Checking bytes readable.\n");
+#endif
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+#ifdef NX_TRANS_SOCKET
+ {
+ _XIOError(dpy);
+
+ return (dpy->qlen);
+ }
+#else
+ _XIOError(dpy);
+#endif
+#ifdef XCONN_CHECK_FREQ
+ /* This is a crock, required because FIONREAD or equivalent is
+ * not guaranteed to detect a broken connection.
+ */
+ if (!pend && !dpy->qlen && ++dpy->conn_checker >= XCONN_CHECK_FREQ)
+ {
+ int result;
+#ifdef USE_POLL
+ struct pollfd filedes;
+#else
+ fd_set r_mask;
+ static struct timeval zero_time;
+#endif
+
+ dpy->conn_checker = 0;
+#ifdef USE_POLL
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XEventsQueued: Calling poll().\n");
+#endif
+ filedes.fd = dpy->fd;
+ filedes.events = POLLIN;
+ if ((result = poll(&filedes, 1, 0)))
+#else
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XEventsQueued: Calling select().\n");
+#endif
+ FD_ZERO(&r_mask);
+ FD_SET(dpy->fd, &r_mask);
+ if ((result = Select(dpy->fd + 1, &r_mask, NULL, NULL, &zero_time)))
+#endif
+ {
+ if (result > 0)
+ {
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+#ifdef NX_TRANS_SOCKET
+ {
+ _XIOError(dpy);
+
+ return (dpy->qlen);
+ }
+#else
+ _XIOError(dpy);
+#endif
+ /* we should not get zero, if we do, force a read */
+ if (!pend)
+ pend = SIZEOF(xReply);
+ }
+#ifdef NX_TRANS_SOCKET
+ if (result <= 0) {
+ if ((result == -1 && !ECHECK(EINTR)) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return (dpy->qlen);
+ }
+ }
+#else
+ else if (result < 0 && !ECHECK(EINTR))
+ _XIOError(dpy);
+#endif
+ }
+ }
+#endif /* XCONN_CHECK_FREQ */
+ if (!(len = pend)) {
+ /* _XFlush can enqueue events */
+#ifdef XTHREADS
+ if (cvl)
+#endif
+ {
+ UnlockNextEventReader(dpy);
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XEventsQueued: Returning [%d].\n", dpy->qlen);
+#endif
+ return(dpy->qlen);
+ }
+ /* Force a read if there is not enough data. Otherwise,
+ * a select() loop at a higher-level will spin undesirably,
+ * and we've seen at least one OS that appears to not update
+ * the result from FIONREAD once it has returned nonzero.
+ */
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ read_buf = (char *)dpy->lock->reply_awaiters->buf;
+ len = SIZEOF(xReply);
+ } else
+#endif /* XTHREADS*/
+ {
+ read_buf = buf.buf;
+
+ if (len < SIZEOF(xReply)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ )
+ len = SIZEOF(xReply);
+ else if (len > BUFSIZE)
+ len = BUFSIZE;
+ len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
+ }
+#ifdef XCONN_CHECK_FREQ
+ dpy->conn_checker = 0;
+#endif
+
+ (void) _XRead (dpy, read_buf, (long) len);
+
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return(dpy->qlen);
+ }
+#endif
+#ifdef XTHREADS
+ /* what did we actually read: reply or event? */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ if (((xReply *)read_buf)->generic.type == X_Reply ||
+ ((xReply *)read_buf)->generic.type == X_Error)
+ {
+ dpy->lock->reply_was_read = True;
+ dpy->lock->reply_first = True;
+ if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
+ memcpy(dpy->lock->reply_awaiters->buf, read_buf,
+ len);
+ if (cvl) {
+ UnlockNextEventReader(dpy);
+ }
+ return(dpy->qlen); /* we read, so we can return */
+ } else if (read_buf != buf.buf)
+ memcpy(buf.buf, read_buf, len);
+ }
+#endif /* XTHREADS*/
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ int tmp = len;
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &tmp, True));
+ len = tmp;
+ pend = len;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *)rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE
+
+#ifdef XTHREADS
+ if (cvl)
+#endif
+ {
+ UnlockNextEventReader(dpy);
+ }
+ return(dpy->qlen);
+}
+
+/* _XReadEvents - Flush the output queue,
+ * then read as many events as possible (but at least 1) and enqueue them
+ */
+void _XReadEvents(
+ register Display *dpy)
+{
+ _XAlignedBuffer buf;
+ BytesReadable_t pend;
+ int len;
+ register xReply *rep;
+ Bool not_yet_flushed = True;
+ char *read_buf;
+ int i;
+ int entry_event_serial_num = dpy->next_event_serial_num;
+#ifdef XTHREADS
+ struct _XCVList *cvl = NULL;
+ xthread_t self;
+
+#ifdef XTHREADS_DEBUG
+ printf("_XReadEvents called in thread %x\n",
+ XThread_Self());
+#endif
+ /* create our condition variable and append to list,
+ * unless we were called from within XProcessInternalConnection
+ * or XLockDisplay
+ */
+ xthread_clear_id(self);
+ if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
+ || xthread_have_id (dpy->lock->locking_thread)))
+ /* some thread is in XProcessInternalConnection or XLockDisplay
+ so we have to see if we are it */
+ self = XThread_Self();
+ if (!xthread_have_id(self)
+ || (!xthread_equal(self, dpy->lock->conni_thread)
+ && !xthread_equal(self, dpy->lock->locking_thread)))
+ cvl = QueueEventReaderLock(dpy);
+#endif /* XTHREADS */
+
+ do {
+#ifdef XTHREADS
+ /* if it is not our turn to read an event off the wire,
+ wait til we're at head of list */
+ if (dpy->lock && cvl &&
+ (dpy->lock->event_awaiters != cvl ||
+ dpy->lock->reply_first)) {
+ ConditionWait(dpy, cvl->cv);
+ continue;
+ }
+#endif /* XTHREADS */
+ /* find out how much data can be read */
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+#ifdef NX_TRANS_SOCKET
+ {
+ _XIOError(dpy);
+
+ return;
+ }
+#else
+ _XIOError(dpy);
+#endif
+ len = pend;
+
+ /* must read at least one xEvent; if none is pending, then
+ we'll just flush and block waiting for it */
+ if (len < SIZEOF(xEvent)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ ) {
+ len = SIZEOF(xEvent);
+ /* don't flush until the first time we would block */
+ if (not_yet_flushed) {
+ _XFlush (dpy);
+ if (_XNewerQueuedEvent(dpy, entry_event_serial_num)) {
+ /* _XReply has read an event for us */
+ goto got_event;
+ }
+ not_yet_flushed = False;
+ }
+ }
+
+#ifdef XTHREADS
+ /* If someone is waiting for a reply, gamble that
+ the reply will be the next thing on the wire
+ and read it into their buffer. */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ read_buf = (char *)dpy->lock->reply_awaiters->buf;
+ len = SIZEOF(xReply);
+ } else
+#endif /* XTHREADS*/
+ {
+ read_buf = buf.buf;
+
+ /* but we won't read more than the max buffer size */
+ if (len > BUFSIZE)
+ len = BUFSIZE;
+
+ /* round down to an integral number of XReps */
+ len = (len / SIZEOF(xEvent)) * SIZEOF(xEvent);
+ }
+
+#ifdef XTHREADS
+ if (xthread_have_id(self))
+ /* save value we may have to stick in conni_thread */
+ dpy->lock->reading_thread = self;
+#endif /* XTHREADS */
+ dpy->flags |= XlibDisplayReadEvents;
+ i = _XRead (dpy, read_buf, (long) len);
+ dpy->flags &= ~XlibDisplayReadEvents;
+#ifdef NX_TRANS_SOCKET
+ if (dpy->flags & XlibDisplayIOError)
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XReadEvents: Returning with I/O error detected.\n");
+#endif
+ return;
+ }
+#endif
+ if (i == -2) {
+ /* special flag from _XRead to say that internal connection has
+ done XPutBackEvent. Which we can use so we're done. */
+ got_event:
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->lock_wait) {
+ if (dpy->lock->event_awaiters != cvl)
+ /* since it is not us, must be user lock thread */
+ ConditionSignal(dpy,
+ dpy->lock->event_awaiters->cv);
+ (*dpy->lock->lock_wait)(dpy);
+ continue;
+ }
+#endif
+ break;
+ }
+#ifdef XTHREADS
+ if (xthread_have_id(self))
+ xthread_clear_id(dpy->lock->reading_thread);
+
+ /* what did we actually read: reply or event? */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ if (((xReply *)read_buf)->generic.type == X_Reply ||
+ ((xReply *)read_buf)->generic.type == X_Error)
+ {
+ dpy->lock->reply_was_read = True;
+ dpy->lock->reply_first = True;
+ if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
+ memcpy(dpy->lock->reply_awaiters->buf,
+ read_buf, len);
+ ConditionSignal(dpy, dpy->lock->reply_awaiters->cv);
+ continue;
+ } else if (read_buf != buf.buf)
+ memcpy(buf.buf, read_buf, len);
+ }
+#endif /* XTHREADS */
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &len, True));
+ pend = len;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *) rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE;
+ } while (!_XNewerQueuedEvent(dpy, entry_event_serial_num));
+
+ UnlockNextEventReader(dpy);
+}
+
+/*
+ * _XRead - Read bytes from the socket taking into account incomplete
+ * reads. This routine may have to be reworked if int < long.
+ */
+int _XRead(
+ register Display *dpy,
+ register char *data,
+ register long size)
+{
+ register long bytes_read;
+#ifdef XTHREADS
+ int original_size = size;
+#endif
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ int congestion;
+#endif
+
+ if ((dpy->flags & XlibDisplayIOError) || size == 0)
+ return 0;
+ ESET(0);
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ while (1) {
+ /*
+ * Need to check the congestion state
+ * after the read so split the statement
+ * in multiple blocks.
+ */
+
+ bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size);
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+ if (bytes_read == size) {
+ break;
+ }
+#else
+ while ((bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size))
+ != size) {
+#endif
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ data += bytes_read;
+ }
+ else if (ETEST()) {
+ if (_XWaitForReadable(dpy) == -2)
+ return -2; /* internal connection did XPutBackEvent */
+ ESET(0);
+ }
+#ifdef SUNSYSV
+ else if (ECHECK(0)) {
+ if (_XWaitForReadable(dpy) == -2)
+ return -2; /* internal connection did XPutBackEvent */
+ }
+#endif
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ ESET(EPIPE);
+#ifdef NX_TRANS_SOCKET
+ _XIOError(dpy);
+
+ return -1;
+#else
+ _XIOError(dpy);
+#endif
+ }
+
+ else /* bytes_read is less than 0; presumably -1 */ {
+ /* If it's a system call interrupt, it's not an error. */
+#ifdef NX_TRANS_SOCKET
+ if (!ECHECK(EINTR) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return -1;
+ }
+#else
+ if (!ECHECK(EINTR))
+ _XIOError(dpy);
+#endif
+ }
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return -1;
+ }
+#endif
+ }
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_bytes_left > 0)
+ {
+ dpy->lock->reply_bytes_left -= original_size;
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ }
+#endif /* XTHREADS*/
+ return 0;
+}
+
+#ifdef LONG64
+void _XRead32(
+ Display *dpy,
+ register long *data,
+ long len)
+{
+ register int *buf;
+ register long i;
+
+ if (len) {
+ (void) _XRead(dpy, (char *)data, len);
+ i = len >> 2;
+ buf = (int *)data + i;
+ data += i;
+ while (--i >= 0)
+ *--data = *--buf;
+ }
+}
+#endif /* LONG64 */
+
+#ifdef WORD64
+
+/*
+ * XXX This is a *really* stupid way of doing this....
+ * PACKBUFFERSIZE must be a multiple of 4.
+ */
+
+#define PACKBUFFERSIZE 4096
+
+
+/*
+ * _XRead32 - Read bytes from the socket unpacking each 32 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static void _doXRead32(
+ register Display *dpy,
+ register long *data
+ register long size,
+ register char *packbuffer)
+{
+ long *lpack,*lp;
+ long mask32 = 0x00000000ffffffff;
+ long maskw, nwords, i, bits;
+
+ _XReadPad (dpy, packbuffer, size);
+
+ lp = data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 2;
+ bits = 32;
+
+ for(i=0;i<nwords;i++){
+ maskw = mask32 << bits;
+ *lp++ = ( *lpack & maskw ) >> bits;
+ bits = bits ^32;
+ if(bits){
+ lpack++;
+ }
+ }
+}
+
+void _XRead32(
+ Display *dpy,
+ long *data,
+ long len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 2;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ _doXRead32 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) _doXRead32 (dpy, data, len, packbuffer);
+}
+
+
+
+/*
+ * _XRead16 - Read bytes from the socket unpacking each 16 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static _doXRead16(
+ register Display *dpy,
+ register short *data,
+ register long size,
+ char *packbuffer)
+{
+ long *lpack,*lp;
+ long mask16 = 0x000000000000ffff;
+ long maskw, nwords, i, bits;
+
+ (void) _XRead(dpy,packbuffer,size); /* don't do a padded read... */
+
+ lp = (long *) data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 1; /* number of 16 bit words to be unpacked */
+ bits = 48;
+ for(i=0;i<nwords;i++){
+ maskw = mask16 << bits;
+ *lp++ = ( *lpack & maskw ) >> bits;
+ bits -= 16;
+ if(bits < 0){
+ lpack++;
+ bits = 48;
+ }
+ }
+}
+
+void _XRead16(
+ Display *dpy,
+ short *data,
+ long len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 1;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ _doXRead16 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) _doXRead16 (dpy, data, len, packbuffer);
+}
+
+void _XRead16Pad(
+ Display *dpy,
+ short *data,
+ long size)
+{
+ int slop = (size & 3);
+ short slopbuf[3];
+
+ _XRead16 (dpy, data, size);
+ if (slop > 0) {
+ _XRead16 (dpy, slopbuf, 4 - slop);
+ }
+}
+#endif /* WORD64 */
+
+
+/*
+ * _XReadPad - Read bytes from the socket taking into account incomplete
+ * reads. If the number of bytes is not 0 mod 4, read additional pad
+ * bytes. This routine may have to be reworked if int < long.
+ */
+void _XReadPad(
+ register Display *dpy,
+ register char *data,
+ register long size)
+{
+ register long bytes_read;
+ struct iovec iov[2];
+ char pad[3];
+#ifdef XTHREADS
+ int original_size;
+#endif
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ int congestion;
+#endif
+
+ if ((dpy->flags & XlibDisplayIOError) || size == 0) return;
+ iov[0].iov_len = (int)size;
+ iov[0].iov_base = data;
+ /*
+ * The following hack is used to provide 32 bit long-word
+ * aligned padding. The [1] vector is of length 0, 1, 2, or 3,
+ * whatever is needed.
+ */
+
+ iov[1].iov_len = -size & 3;
+ iov[1].iov_base = pad;
+ size += iov[1].iov_len;
+#ifdef XTHREADS
+ original_size = size;
+#endif
+ ESET(0);
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ while (1) {
+ bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2);
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+ if (bytes_read == size) {
+ break;
+ }
+#else
+ while ((bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2)) != size) {
+#endif
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ if (iov[0].iov_len < bytes_read) {
+ int pad_bytes_read = bytes_read - iov[0].iov_len;
+ iov[1].iov_len -= pad_bytes_read;
+ iov[1].iov_base =
+ (char *)iov[1].iov_base + pad_bytes_read;
+ iov[0].iov_len = 0;
+ }
+ else {
+ iov[0].iov_len -= bytes_read;
+ iov[0].iov_base = (char *)iov[0].iov_base + bytes_read;
+ }
+ }
+ else if (ETEST()) {
+ _XWaitForReadable(dpy);
+ ESET(0);
+ }
+#ifdef SUNSYSV
+ else if (ECHECK(0)) {
+ _XWaitForReadable(dpy);
+ }
+#endif
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ ESET(EPIPE);
+#ifdef NX_TRANS_SOCKET
+ _XIOError(dpy);
+
+ return;
+#else
+ _XIOError(dpy);
+#endif
+ }
+
+ else /* bytes_read is less than 0; presumably -1 */ {
+ /* If it's a system call interrupt, it's not an error. */
+#ifdef NX_TRANS_SOCKET
+ if (!ECHECK(EINTR) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return;
+ }
+#else
+ if (!ECHECK(EINTR))
+ _XIOError(dpy);
+#endif
+ }
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return;
+ }
+#endif
+ }
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_bytes_left > 0)
+ {
+ dpy->lock->reply_bytes_left -= original_size;
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ }
+#endif /* XTHREADS*/
+}
+
+/*
+ * _XSend - Flush the buffer and send the client data. 32 bit word aligned
+ * transmission is used, if size is not 0 mod 4, extra bytes are transmitted.
+ * This routine may have to be reworked if int < long;
+ */
+void
+_XSend (
+ register Display *dpy,
+ _Xconst char *data,
+ register long size)
+{
+ struct iovec iov[3];
+ static char const pad[3] = {0, 0, 0};
+ /* XText8 and XText16 require that the padding bytes be zero! */
+
+ long skip, dbufsize, padsize, total, todo;
+ _XExtension *ext;
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ int congestion;
+#endif
+
+#ifdef NX_TRANS_SOCKET
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XSend: Sending data with [%d] bytes to write.\n",
+ (dpy->bufptr - dpy->buffer));
+#endif
+ if (!size || (dpy->flags & XlibDisplayIOError))
+ {
+ if (dpy->flags & XlibDisplayIOError)
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XSend: Returning with I/O error detected.\n");
+#endif
+ dpy->bufptr = dpy->buffer;
+ dpy->last_req = (char *)&_dummy_request;
+ }
+
+ return;
+ }
+#else
+ if (!size || (dpy->flags & XlibDisplayIOError)) return;
+#endif
+ dbufsize = dpy->bufptr - dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags |= XlibDisplayWriting;
+ /* make sure no one else can put in data */
+ dpy->bufptr = dpy->bufmax;
+#endif
+ padsize = -size & 3;
+ for (ext = dpy->flushes; ext; ext = ext->next_flush) {
+ (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, dbufsize);
+ (*ext->before_flush)(dpy, &ext->codes, (char *)data, size);
+ if (padsize)
+ (*ext->before_flush)(dpy, &ext->codes, pad, padsize);
+ }
+ skip = 0;
+ todo = total = dbufsize + size + padsize;
+
+ /*
+ * There are 3 pieces that may need to be written out:
+ *
+ * o whatever is in the display buffer
+ * o the data passed in by the user
+ * o any padding needed to 32bit align the whole mess
+ *
+ * This loop looks at all 3 pieces each time through. It uses skip
+ * to figure out whether or not a given piece is needed.
+ */
+ while (total) {
+ long before = skip; /* amount of whole thing written */
+ long remain = todo; /* amount to try this time, <= total */
+ int i = 0;
+ long len;
+
+ /* You could be very general here and have "in" and "out" iovecs
+ * and write a loop without using a macro, but what the heck. This
+ * translates to:
+ *
+ * how much of this piece is new?
+ * if more new then we are trying this time, clamp
+ * if nothing new
+ * then bump down amount already written, for next piece
+ * else put new stuff in iovec, will need all of next piece
+ *
+ * Note that todo had better be at least 1 or else we'll end up
+ * writing 0 iovecs.
+ */
+#define InsertIOV(pointer, length) \
+ len = (length) - before; \
+ if (len > remain) \
+ len = remain; \
+ if (len <= 0) { \
+ before = (-len); \
+ } else { \
+ iov[i].iov_len = len; \
+ iov[i].iov_base = (pointer) + before; \
+ i++; \
+ remain -= len; \
+ before = 0; \
+ }
+
+ InsertIOV (dpy->buffer, dbufsize)
+ InsertIOV ((char *)data, size)
+ InsertIOV ((char *)pad, padsize)
+
+ ESET(0);
+ if ((len = _X11TransWritev(dpy->trans_conn, iov, i)) >= 0) {
+#ifdef NX_TRANS_SOCKET
+ if (_NXDisplayWriteFunction != NULL) {
+ (*_NXDisplayWriteFunction)(dpy, len);
+ }
+#ifdef NX_TRANS_CHANGE
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+#endif
+#endif
+ skip += len;
+ total -= len;
+ todo = total;
+ } else if (ETEST()) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+#ifdef SUNSYSV
+ } else if (ECHECK(0)) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+#endif
+#ifdef ESZTEST
+ } else if (ESZTEST()) {
+ if (todo > 1)
+ todo >>= 1;
+ else {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+ }
+#endif
+#ifdef NX_TRANS_SOCKET
+ } else if (!ECHECK(EINTR) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return;
+ }
+#else
+ } else if (!ECHECK(EINTR)) {
+ _XIOError(dpy);
+ }
+#endif
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return;
+ }
+#endif
+ }
+ dpy->last_req = (char *) & _dummy_request;
+ if ((dpy->request - dpy->last_request_read) >= SEQLIMIT &&
+ !(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->synchandler = _XSeqSyncFunction;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->bufptr = dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags &= ~XlibDisplayWriting;
+#endif
+ return;
+}
+
+static void
+_XGetMiscCode(
+ register Display *dpy)
+{
+ xQueryExtensionReply qrep;
+ register xQueryExtensionReq *qreq;
+ xXCMiscGetVersionReply vrep;
+ register xXCMiscGetVersionReq *vreq;
+
+ if (dpy->xcmisc_opcode)
+ return;
+ GetReq(QueryExtension, qreq);
+ qreq->nbytes = sizeof(XCMiscExtensionName) - 1;
+ qreq->length += (qreq->nbytes+(unsigned)3)>>2;
+ _XSend(dpy, XCMiscExtensionName, (long)qreq->nbytes);
+ if (!_XReply (dpy, (xReply *)&qrep, 0, xTrue))
+ dpy->xcmisc_opcode = -1;
+ else {
+ GetReq(XCMiscGetVersion, vreq);
+ vreq->reqType = qrep.major_opcode;
+ vreq->miscReqType = X_XCMiscGetVersion;
+ vreq->majorVersion = XCMiscMajorVersion;
+ vreq->minorVersion = XCMiscMinorVersion;
+ if (!_XReply (dpy, (xReply *)&vrep, 0, xTrue))
+ dpy->xcmisc_opcode = -1;
+ else
+ dpy->xcmisc_opcode = qrep.major_opcode;
+ }
+}
+
+static int
+_XIDHandler(
+ register Display *dpy)
+{
+ xXCMiscGetXIDRangeReply grep;
+ register xXCMiscGetXIDRangeReq *greq;
+
+ LockDisplay(dpy);
+ _XGetMiscCode(dpy);
+ if (dpy->xcmisc_opcode > 0) {
+ GetReq(XCMiscGetXIDRange, greq);
+ greq->reqType = dpy->xcmisc_opcode;
+ greq->miscReqType = X_XCMiscGetXIDRange;
+ if (_XReply (dpy, (xReply *)&grep, 0, xTrue) && grep.count) {
+ dpy->resource_id = ((grep.start_id - dpy->resource_base) >>
+ dpy->resource_shift);
+ dpy->resource_max = dpy->resource_id;
+ if (grep.count > 5)
+ dpy->resource_max += grep.count - 6;
+ dpy->resource_max <<= dpy->resource_shift;
+ }
+ }
+ if (dpy->flags & XlibDisplayPrivSync) {
+ dpy->synchandler = dpy->savedsynchandler;
+ dpy->flags &= ~XlibDisplayPrivSync;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
+/*
+ * _XAllocID - resource ID allocation routine.
+ */
+XID _XAllocID(
+ register Display *dpy)
+{
+ XID id;
+
+ id = dpy->resource_id << dpy->resource_shift;
+ if (id >= dpy->resource_max) {
+ if (!(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->synchandler = _XIDHandler;
+ dpy->resource_max = dpy->resource_mask + 1;
+ }
+ if (id <= dpy->resource_mask) {
+ dpy->resource_id++;
+ return (dpy->resource_base + id);
+ }
+ if (id != 0x10000000) {
+ (void) fprintf(stderr,
+ "Xlib: resource ID allocation space exhausted!\n");
+ id = 0x10000000;
+ dpy->resource_id = id >> dpy->resource_shift;
+ }
+ return id;
+}
+
+/*
+ * _XAllocIDs - multiple resource ID allocation routine.
+ */
+void _XAllocIDs(
+ register Display *dpy,
+ XID *ids,
+ int count)
+{
+ XID id;
+ int i;
+ xXCMiscGetXIDListReply grep;
+ register xXCMiscGetXIDListReq *greq;
+
+ id = dpy->resource_id << dpy->resource_shift;
+ if (dpy->resource_max <= dpy->resource_mask &&
+ id <= dpy->resource_mask &&
+ (dpy->resource_max - id) > ((count - 1) << dpy->resource_shift)) {
+ id += dpy->resource_base;
+ for (i = 0; i < count; i++) {
+ ids[i] = id;
+ id += (1 << dpy->resource_shift);
+ dpy->resource_id++;
+ }
+ return;
+ }
+ grep.count = 0;
+ _XGetMiscCode(dpy);
+ if (dpy->xcmisc_opcode > 0) {
+ GetReq(XCMiscGetXIDList, greq);
+ greq->reqType = dpy->xcmisc_opcode;
+ greq->miscReqType = X_XCMiscGetXIDList;
+ greq->count = count;
+ if (_XReply(dpy, (xReply *)&grep, 0, xFalse) && grep.count) {
+ _XRead32(dpy, (long *) ids, 4L * (long) (grep.count));
+ for (i = 0; i < grep.count; i++) {
+ id = (ids[i] - dpy->resource_base) >> dpy->resource_shift;
+ if (id >= dpy->resource_id)
+ dpy->resource_id = id;
+ }
+ if (id >= dpy->resource_max) {
+ if (!(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->synchandler = _XIDHandler;
+ dpy->resource_max = dpy->resource_mask + 1;
+ }
+ }
+ }
+ for (i = grep.count; i < count; i++)
+ ids[i] = XAllocID(dpy);
+}
+
+/*
+ * The hard part about this is that we only get 16 bits from a reply.
+ * We have three values that will march along, with the following invariant:
+ * dpy->last_request_read <= rep->sequenceNumber <= dpy->request
+ * We have to keep
+ * dpy->request - dpy->last_request_read < 2^16
+ * or else we won't know for sure what value to use in events. We do this
+ * by forcing syncs when we get close.
+ */
+
+unsigned long
+_XSetLastRequestRead(
+ register Display *dpy,
+ register xGenericReply *rep)
+{
+ register unsigned long newseq, lastseq;
+
+ lastseq = dpy->last_request_read;
+ /*
+ * KeymapNotify has no sequence number, but is always guaranteed
+ * to immediately follow another event, except when generated via
+ * SendEvent (hmmm).
+ */
+ if ((rep->type & 0x7f) == KeymapNotify)
+ return(lastseq);
+
+ newseq = (lastseq & ~((unsigned long)0xffff)) | rep->sequenceNumber;
+
+ if (newseq < lastseq) {
+ newseq += 0x10000;
+ if (newseq > dpy->request) {
+
+#ifdef NX_TRANS_SOCKET
+
+ if (_NXLostSequenceFunction != NULL)
+ {
+ (*_NXLostSequenceFunction)(dpy, newseq, dpy->request,
+ (unsigned int) rep->type);
+ }
+ else
+ {
+ (void) fprintf (stderr,
+ "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
+ newseq, dpy->request,
+ (unsigned int) rep->type);
+ }
+
+#else /* #ifdef NX_TRANS_SOCKET */
+
+ (void) fprintf (stderr,
+ "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
+ newseq, dpy->request,
+ (unsigned int) rep->type);
+
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+ newseq -= 0x10000;
+ }
+ }
+
+ dpy->last_request_read = newseq;
+ return(newseq);
+}
+
+/*
+ * _XReply - Wait for a reply packet and copy its contents into the
+ * specified rep. Meanwhile we must handle error and event packets that
+ * we may encounter.
+ */
+Status
+_XReply (
+ register Display *dpy,
+ register xReply *rep,
+ int extra, /* number of 32-bit words expected after the reply */
+ Bool discard) /* should I discard data following "extra" words? */
+{
+ /* Pull out the serial number now, so that (currently illegal) requests
+ * generated by an error handler don't confuse us.
+ */
+ unsigned long cur_request = dpy->request;
+#ifdef XTHREADS
+ struct _XCVList *cvl;
+#endif
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XReply: Going to wait for an X reply.\n");
+#endif
+
+#ifdef NX_TRANS_SOCKET
+ if (dpy->flags & XlibDisplayIOError)
+ {
+#ifdef NX_TRANS_DEBUG
+ fprintf(stderr, "_XReply: Returning 0 with I/O error detected.\n");
+#endif
+ return 0;
+ }
+#else
+ if (dpy->flags & XlibDisplayIOError)
+ return 0;
+#endif
+
+#ifdef XTHREADS
+ /* create our condition variable and append to list */
+ cvl = QueueReplyReaderLock(dpy);
+ if (cvl) {
+ cvl->buf = rep;
+ if (dpy->lock->reply_awaiters == cvl && !dpy->lock->event_awaiters)
+ dpy->lock->reply_first = True;
+ }
+
+#ifdef XTHREADS_DEBUG
+ printf("_XReply called in thread %x, adding %x to cvl\n",
+ XThread_Self(), cvl);
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XReply: Going to flush the display buffer.\n");
+#endif
+ _XFlushInt(dpy, cvl ? cvl->cv : NULL);
+ /* if it is not our turn to read a reply off the wire,
+ * wait til we're at head of list. if there is an event waiter,
+ * and our reply hasn't been read, they'll be in select and will
+ * hand control back to us next.
+ */
+ if(dpy->lock &&
+ (dpy->lock->reply_awaiters != cvl || !dpy->lock->reply_first)) {
+ ConditionWait(dpy, cvl->cv);
+ }
+ dpy->flags |= XlibDisplayReply;
+#else /* XTHREADS else */
+ _XFlush(dpy);
+#endif
+
+#ifdef NX_TRANS_SOCKET
+ /*
+ * We are going to block waiting for the remote
+ * X server. Be sure that the proxy has flushed
+ * all the data.
+ */
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XReply: Requesting a flush of the NX transport.\n");
+#endif
+
+ NXTransFlush(dpy->fd);
+#endif
+
+ for (;;) {
+#ifdef XTHREADS
+ /* Did another thread's _XReadEvents get our reply by accident? */
+ if (!dpy->lock || !dpy->lock->reply_was_read)
+#endif
+ (void) _XRead(dpy, (char *)rep, (long)SIZEOF(xReply));
+#ifdef XTHREADS
+ if (dpy->lock)
+ dpy->lock->reply_was_read = False;
+#endif
+
+ switch ((int)rep->generic.type) {
+
+ case X_Reply:
+ /* Reply received. Fast update for synchronous replies,
+ * but deal with multiple outstanding replies.
+ */
+ if (rep->generic.sequenceNumber == (cur_request & 0xffff))
+ dpy->last_request_read = cur_request;
+ else {
+ int pend = SIZEOF(xReply);
+ if (_XAsyncReply(dpy, rep, (char *)rep, &pend, False)
+ != (char *)rep)
+ continue;
+ }
+ if (extra <= rep->generic.length) {
+ if (extra > 0)
+ /*
+ * Read the extra data into storage immediately
+ * following the GenericReply structure.
+ */
+ (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
+ ((long)extra) << 2);
+ if (discard) {
+ if (extra < rep->generic.length)
+ _XEatData(dpy, (rep->generic.length - extra) << 2);
+ }
+#ifdef XTHREADS
+ if (dpy->lock) {
+ if (discard) {
+ dpy->lock->reply_bytes_left = 0;
+ } else {
+ dpy->lock->reply_bytes_left =
+ (rep->generic.length - extra) << 2;
+ }
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ } else
+ dpy->flags &= ~XlibDisplayReply;
+#endif
+ return 1;
+ }
+ /*
+ *if we get here, then extra > rep->generic.length--meaning we
+ * read a reply that's shorter than we expected. This is an
+ * error, but we still need to figure out how to handle it...
+ */
+ (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
+ ((long) rep->generic.length) << 2);
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+#ifdef NX_TRANS_SOCKET
+ /*
+ * The original code has provision
+ * for returning already.
+ */
+#endif
+ _XIOError (dpy);
+ return (0);
+
+ case X_Error:
+ {
+ register _XExtension *ext;
+ register Bool ret = False;
+ int ret_code;
+ xError *err = (xError *) rep;
+ unsigned long serial;
+
+ dpy->flags &= ~XlibDisplayReply;
+ serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
+ if (serial == cur_request)
+ /* do not die on "no such font", "can't allocate",
+ "can't grab" failures */
+ switch ((int)err->errorCode) {
+ case BadName:
+ switch (err->majorCode) {
+ case X_LookupColor:
+ case X_AllocNamedColor:
+ UnlockNextReplyReader(dpy);
+ return(0);
+ }
+ break;
+ case BadFont:
+ if (err->majorCode == X_QueryFont) {
+ UnlockNextReplyReader(dpy);
+ return (0);
+ }
+ break;
+ case BadAlloc:
+ case BadAccess:
+ UnlockNextReplyReader(dpy);
+ return (0);
+ }
+ /*
+ * we better see if there is an extension who may
+ * want to suppress the error.
+ */
+ for (ext = dpy->ext_procs; !ret && ext; ext = ext->next) {
+ if (ext->error)
+ ret = (*ext->error)(dpy, err, &ext->codes, &ret_code);
+ }
+ if (!ret) {
+ _XError(dpy, err);
+ ret_code = 0;
+ }
+ if (serial == cur_request) {
+ UnlockNextReplyReader(dpy);
+ return(ret_code);
+ }
+
+ } /* case X_Error */
+ break;
+ default:
+ _XEnq(dpy, (xEvent *) rep);
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->event_awaiters)
+ ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
+#endif
+ break;
+ }
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ UnlockNextReplyReader(dpy);
+ return 0;
+ }
+#endif
+ }
+}
+
+static char *
+_XAsyncReply(
+ Display *dpy,
+ register xReply *rep,
+ char *buf,
+ register int *lenp,
+ Bool discard)
+{
+ register _XAsyncHandler *async, *next;
+ register int len;
+ register Bool consumed = False;
+ char *nbuf;
+
+ (void) _XSetLastRequestRead(dpy, &rep->generic);
+ len = SIZEOF(xReply) + (rep->generic.length << 2);
+ if (len < SIZEOF(xReply)) {
+#ifdef NX_TRANS_SOCKET
+
+ /*
+ * The original code has provision
+ * for returning already.
+ */
+
+#endif
+ _XIOError (dpy);
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+
+ for (async = dpy->async_handlers; async; async = next) {
+ next = async->next;
+ if ((consumed = (*async->handler)(dpy, rep, buf, *lenp, async->data)))
+ break;
+ }
+ if (!consumed) {
+ if (!discard)
+ return buf;
+ (void) fprintf(stderr,
+ "Xlib: unexpected async reply (sequence 0x%lx)!\n",
+ dpy->last_request_read);
+#ifdef XTHREADS
+#ifdef XTHREADS_DEBUG
+ printf("thread %x, unexpected async reply\n", XThread_Self());
+#endif
+#endif
+ if (len > *lenp)
+ _XEatData(dpy, len - *lenp);
+ }
+ if (len < SIZEOF(xReply))
+ {
+#ifdef NX_TRANS_SOCKET
+
+ /*
+ * The original code has provision
+ * for returning already.
+ */
+
+#endif
+ _XIOError (dpy);
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+ if (len >= *lenp) {
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+ *lenp -= len;
+ buf += len;
+ len = *lenp;
+ nbuf = buf;
+ while (len > SIZEOF(xReply)) {
+ if (*buf == X_Reply)
+ return nbuf;
+ buf += SIZEOF(xReply);
+ len -= SIZEOF(xReply);
+ }
+ if (len > 0 && len < SIZEOF(xReply)) {
+ buf = nbuf;
+ len = SIZEOF(xReply) - len;
+ nbuf -= len;
+ memmove(nbuf, buf, *lenp);
+ (void) _XRead(dpy, nbuf + *lenp, (long)len);
+ *lenp += len;
+ }
+ return nbuf;
+}
+
+/*
+ * Support for internal connections, such as an IM might use.
+ * By Stephen Gildea, X Consortium, September 1993
+ */
+
+/* _XRegisterInternalConnection
+ * Each IM (or Xlib extension) that opens a file descriptor that Xlib should
+ * include in its select/poll mask must call this function to register the
+ * fd with Xlib. Any XConnectionWatchProc registered by XAddConnectionWatch
+ * will also be called.
+ *
+ * Whenever Xlib detects input available on fd, it will call callback
+ * with call_data to process it. If non-Xlib code calls select/poll
+ * and detects input available, it must call XProcessInternalConnection,
+ * which will call the associated callback.
+ *
+ * Non-Xlib code can learn about these additional fds by calling
+ * XInternalConnectionNumbers or, more typically, by registering
+ * a XConnectionWatchProc with XAddConnectionWatch
+ * to be called when fds are registered or unregistered.
+ *
+ * Returns True if registration succeeded, False if not, typically
+ * because could not allocate memory.
+ * Assumes Display locked when called.
+ */
+Status
+_XRegisterInternalConnection(
+ Display* dpy,
+ int fd,
+ _XInternalConnectionProc callback,
+ XPointer call_data
+)
+{
+ struct _XConnectionInfo *new_conni, **iptr;
+ struct _XConnWatchInfo *watchers;
+ XPointer *wd;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XRegisterInternalConnection: Got called.\n");
+#endif
+
+ new_conni = (struct _XConnectionInfo*)Xmalloc(sizeof(struct _XConnectionInfo));
+ if (!new_conni)
+ return 0;
+ new_conni->watch_data = (XPointer *)Xmalloc(dpy->watcher_count * sizeof(XPointer));
+ if (!new_conni->watch_data) {
+ Xfree(new_conni);
+ return 0;
+ }
+ new_conni->fd = fd;
+ new_conni->read_callback = callback;
+ new_conni->call_data = call_data;
+ new_conni->next = NULL;
+ /* link new structure onto end of list */
+ for (iptr = &dpy->im_fd_info; *iptr; iptr = &(*iptr)->next)
+ ;
+ *iptr = new_conni;
+ dpy->im_fd_length++;
+ _XPollfdCacheAdd(dpy, fd);
+
+ for (watchers=dpy->conn_watchers, wd=new_conni->watch_data;
+ watchers;
+ watchers=watchers->next, wd++) {
+ *wd = NULL; /* for cleanliness */
+ (*watchers->fn) (dpy, watchers->client_data, fd, True, wd);
+ }
+
+ return 1;
+}
+
+/* _XUnregisterInternalConnection
+ * Each IM (or Xlib extension) that closes a file descriptor previously
+ * registered with _XRegisterInternalConnection must call this function.
+ * Any XConnectionWatchProc registered by XAddConnectionWatch
+ * will also be called.
+ *
+ * Assumes Display locked when called.
+ */
+void
+_XUnregisterInternalConnection(
+ Display* dpy,
+ int fd
+)
+{
+ struct _XConnectionInfo *info_list, **prev;
+ struct _XConnWatchInfo *watch;
+ XPointer *wd;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XUnregisterInternalConnection: Got called.\n");
+#endif
+
+ for (prev = &dpy->im_fd_info; (info_list = *prev);
+ prev = &info_list->next) {
+ if (info_list->fd == fd) {
+ *prev = info_list->next;
+ dpy->im_fd_length--;
+ for (watch=dpy->conn_watchers, wd=info_list->watch_data;
+ watch;
+ watch=watch->next, wd++) {
+ (*watch->fn) (dpy, watch->client_data, fd, False, wd);
+ }
+ if (info_list->watch_data)
+ Xfree (info_list->watch_data);
+ Xfree (info_list);
+ break;
+ }
+ }
+ _XPollfdCacheDel(dpy, fd);
+}
+
+/* XInternalConnectionNumbers
+ * Returns an array of fds and an array of corresponding call data.
+ * Typically a XConnectionWatchProc registered with XAddConnectionWatch
+ * will be used instead of this function to discover
+ * additional fds to include in the select/poll mask.
+ *
+ * The list is allocated with Xmalloc and should be freed by the caller
+ * with Xfree;
+ */
+Status
+XInternalConnectionNumbers(
+ Display *dpy,
+ int **fd_return,
+ int *count_return
+)
+{
+ int count;
+ struct _XConnectionInfo *info_list;
+ int *fd_list;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "XInternalConnectionNumbers: Got called.\n");
+#endif
+
+ LockDisplay(dpy);
+ count = 0;
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next)
+ count++;
+ fd_list = (int*) Xmalloc (count * sizeof(int));
+ if (!fd_list) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ count = 0;
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ fd_list[count] = info_list->fd;
+ count++;
+ }
+ UnlockDisplay(dpy);
+
+ *fd_return = fd_list;
+ *count_return = count;
+ return 1;
+}
+
+static void _XProcessInternalConnection(
+ Display *dpy,
+ struct _XConnectionInfo *conn_info)
+{
+ dpy->flags |= XlibDisplayProcConni;
+#ifdef XTHREADS
+ if (dpy->lock) {
+ /* check cache to avoid call to thread_self */
+ if (xthread_have_id(dpy->lock->reading_thread))
+ dpy->lock->conni_thread = dpy->lock->reading_thread;
+ else
+ dpy->lock->conni_thread = XThread_Self();
+ }
+#endif /* XTHREADS */
+ UnlockDisplay(dpy);
+ (*conn_info->read_callback) (dpy, conn_info->fd, conn_info->call_data);
+ LockDisplay(dpy);
+#ifdef XTHREADS
+ if (dpy->lock)
+ xthread_clear_id(dpy->lock->conni_thread);
+#endif /* XTHREADS */
+ dpy->flags &= ~XlibDisplayProcConni;
+}
+
+/* XProcessInternalConnection
+ * Call the _XInternalConnectionProc registered by _XRegisterInternalConnection
+ * for this fd.
+ * The Display is NOT locked during the call.
+ */
+void
+XProcessInternalConnection(
+ Display* dpy,
+ int fd
+)
+{
+ struct _XConnectionInfo *info_list;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "XProcessInternalConnection: Got called.\n");
+#endif
+
+ LockDisplay(dpy);
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ if (info_list->fd == fd) {
+ _XProcessInternalConnection(dpy, info_list);
+ break;
+ }
+ }
+ UnlockDisplay(dpy);
+}
+
+/* XAddConnectionWatch
+ * Register a callback to be called whenever _XRegisterInternalConnection
+ * or _XUnregisterInternalConnection is called.
+ * Callbacks are called with the Display locked.
+ * If any connections are already registered, the callback is immediately
+ * called for each of them.
+ */
+Status
+XAddConnectionWatch(
+ Display* dpy,
+ XConnectionWatchProc callback,
+ XPointer client_data
+)
+{
+ struct _XConnWatchInfo *new_watcher, **wptr;
+ struct _XConnectionInfo *info_list;
+ XPointer *wd_array;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "XAddConnectionWatch: Got called.\n");
+#endif
+
+ LockDisplay(dpy);
+
+ /* allocate new watch data */
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ wd_array = (XPointer *)Xrealloc((char *)info_list->watch_data,
+ (dpy->watcher_count + 1) *
+ sizeof(XPointer));
+ if (!wd_array) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ wd_array[dpy->watcher_count] = NULL; /* for cleanliness */
+ }
+
+ new_watcher = (struct _XConnWatchInfo*)Xmalloc(sizeof(struct _XConnWatchInfo));
+ if (!new_watcher) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ new_watcher->fn = callback;
+ new_watcher->client_data = client_data;
+ new_watcher->next = NULL;
+
+ /* link new structure onto end of list */
+ for (wptr = &dpy->conn_watchers; *wptr; wptr = &(*wptr)->next)
+ ;
+ *wptr = new_watcher;
+ dpy->watcher_count++;
+
+ /* call new watcher on all currently registered fds */
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ (*callback) (dpy, client_data, info_list->fd, True,
+ info_list->watch_data + dpy->watcher_count - 1);
+ }
+
+ UnlockDisplay(dpy);
+ return 1;
+}
+
+/* XRemoveConnectionWatch
+ * Unregister a callback registered by XAddConnectionWatch.
+ * Both callback and client_data must match what was passed to
+ * XAddConnectionWatch.
+ */
+void
+XRemoveConnectionWatch(
+ Display* dpy,
+ XConnectionWatchProc callback,
+ XPointer client_data
+)
+{
+ struct _XConnWatchInfo *watch;
+ struct _XConnWatchInfo *previous = NULL;
+ struct _XConnectionInfo *conni;
+ int counter = 0;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "XRemoveConnectionWatch: Got called.\n");
+#endif
+
+ LockDisplay(dpy);
+ for (watch=dpy->conn_watchers; watch; watch=watch->next) {
+ if (watch->fn == callback && watch->client_data == client_data) {
+ if (previous)
+ previous->next = watch->next;
+ else
+ dpy->conn_watchers = watch->next;
+ Xfree (watch);
+ dpy->watcher_count--;
+ /* remove our watch_data for each connection */
+ for (conni=dpy->im_fd_info; conni; conni=conni->next) {
+ /* don't bother realloc'ing; these arrays are small anyway */
+ /* overlapping */
+ memmove(conni->watch_data+counter,
+ conni->watch_data+counter+1,
+ dpy->watcher_count - counter);
+ }
+ break;
+ }
+ previous = watch;
+ counter++;
+ }
+ UnlockDisplay(dpy);
+}
+
+/* end of internal connections support */
+
+
+/* Read and discard "n" 8-bit bytes of data */
+
+void _XEatData(
+ Display *dpy,
+ register unsigned long n)
+{
+#define SCRATCHSIZE 2048
+ char buf[SCRATCHSIZE];
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XEatData: Going to eat [%ld] bytes of data from descriptor [%d].\n",
+ n, dpy->fd);
+#endif
+ while (n > 0) {
+ register long bytes_read = (n > SCRATCHSIZE) ? SCRATCHSIZE : n;
+ (void) _XRead (dpy, buf, bytes_read);
+ n -= bytes_read;
+ }
+#undef SCRATCHSIZE
+}
+
+
+/*
+ * _XEnq - Place event packets on the display's queue.
+ * note that no squishing of move events in V11, since there
+ * is pointer motion hints....
+ */
+void _XEnq(
+ register Display *dpy,
+ register xEvent *event)
+{
+ register _XQEvent *qelt;
+
+ if ((qelt = dpy->qfree)) {
+ /* If dpy->qfree is non-NULL do this, else malloc a new one. */
+ dpy->qfree = qelt->next;
+ }
+ else if ((qelt =
+ (_XQEvent *) Xmalloc((unsigned)sizeof(_XQEvent))) == NULL) {
+ /* Malloc call failed! */
+ ESET(ENOMEM);
+#ifdef NX_TRANS_SOCKET
+ _XIOError(dpy);
+
+ return;
+#else
+ _XIOError(dpy);
+#endif
+ }
+ qelt->next = NULL;
+ /* go call through display to find proper event reformatter */
+ if ((*dpy->event_vec[event->u.u.type & 0177])(dpy, &qelt->event, event)) {
+ qelt->qserial_num = dpy->next_event_serial_num++;
+ if (dpy->tail) dpy->tail->next = qelt;
+ else dpy->head = qelt;
+
+ dpy->tail = qelt;
+ dpy->qlen++;
+ } else {
+ /* ignored, or stashed away for many-to-one compression */
+ qelt->next = dpy->qfree;
+ dpy->qfree = qelt;
+ }
+}
+
+/*
+ * _XDeq - Remove event packet from the display's queue.
+ */
+void _XDeq(
+ register Display *dpy,
+ register _XQEvent *prev, /* element before qelt */
+ register _XQEvent *qelt) /* element to be unlinked */
+{
+ if (prev) {
+ if ((prev->next = qelt->next) == NULL)
+ dpy->tail = prev;
+ } else {
+ /* no prev, so removing first elt */
+ if ((dpy->head = qelt->next) == NULL)
+ dpy->tail = NULL;
+ }
+ qelt->qserial_num = 0;
+ qelt->next = dpy->qfree;
+ dpy->qfree = qelt;
+ dpy->qlen--;
+}
+
+/*
+ * EventToWire in separate file in that often not needed.
+ */
+
+/*ARGSUSED*/
+Bool
+_XUnknownWireEvent(
+ register Display *dpy, /* pointer to display structure */
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event) /* wire protocol event */
+{
+#ifdef notdef
+ (void) fprintf(stderr,
+ "Xlib: unhandled wire event! event number = %d, display = %x\n.",
+ event->u.u.type, dpy);
+#endif
+ return(False);
+}
+
+/*ARGSUSED*/
+Status
+_XUnknownNativeEvent(
+ register Display *dpy, /* pointer to display structure */
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event) /* wire protocol event */
+{
+#ifdef notdef
+ (void) fprintf(stderr,
+ "Xlib: unhandled native event! event number = %d, display = %x\n.",
+ re->type, dpy);
+#endif
+ return(0);
+}
+/*
+ * reformat a wire event into an XEvent structure of the right type.
+ */
+Bool
+_XWireToEvent(
+ register Display *dpy, /* pointer to display structure */
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event) /* wire protocol event */
+{
+
+ re->type = event->u.u.type & 0x7f;
+ ((XAnyEvent *)re)->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ ((XAnyEvent *)re)->send_event = ((event->u.u.type & 0x80) != 0);
+ ((XAnyEvent *)re)->display = dpy;
+
+ /* Ignore the leading bit of the event type since it is set when a
+ client sends an event rather than the server. */
+
+ switch (event-> u.u.type & 0177) {
+ case KeyPress:
+ case KeyRelease:
+ {
+ register XKeyEvent *ev = (XKeyEvent*) re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->keycode = event->u.u.detail;
+ }
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ {
+ register XButtonEvent *ev = (XButtonEvent *) re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->button = event->u.u.detail;
+ }
+ break;
+ case MotionNotify:
+ {
+ register XMotionEvent *ev = (XMotionEvent *)re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->is_hint = event->u.u.detail;
+ }
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ {
+ register XCrossingEvent *ev = (XCrossingEvent *) re;
+ ev->root = event->u.enterLeave.root;
+ ev->window = event->u.enterLeave.event;
+ ev->subwindow = event->u.enterLeave.child;
+ ev->time = event->u.enterLeave.time;
+ ev->x = cvtINT16toInt(event->u.enterLeave.eventX);
+ ev->y = cvtINT16toInt(event->u.enterLeave.eventY);
+ ev->x_root = cvtINT16toInt(event->u.enterLeave.rootX);
+ ev->y_root = cvtINT16toInt(event->u.enterLeave.rootY);
+ ev->state = event->u.enterLeave.state;
+ ev->mode = event->u.enterLeave.mode;
+ ev->same_screen = (event->u.enterLeave.flags &
+ ELFlagSameScreen) && True;
+ ev->focus = (event->u.enterLeave.flags &
+ ELFlagFocus) && True;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case FocusIn:
+ case FocusOut:
+ {
+ register XFocusChangeEvent *ev = (XFocusChangeEvent *) re;
+ ev->window = event->u.focus.window;
+ ev->mode = event->u.focus.mode;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case KeymapNotify:
+ {
+ register XKeymapEvent *ev = (XKeymapEvent *) re;
+ ev->window = None;
+ memcpy(&ev->key_vector[1],
+ (char *)((xKeymapEvent *) event)->map,
+ sizeof (((xKeymapEvent *) event)->map));
+ }
+ break;
+ case Expose:
+ {
+ register XExposeEvent *ev = (XExposeEvent *) re;
+ ev->window = event->u.expose.window;
+ ev->x = event->u.expose.x;
+ ev->y = event->u.expose.y;
+ ev->width = event->u.expose.width;
+ ev->height = event->u.expose.height;
+ ev->count = event->u.expose.count;
+ }
+ break;
+ case GraphicsExpose:
+ {
+ register XGraphicsExposeEvent *ev =
+ (XGraphicsExposeEvent *) re;
+ ev->drawable = event->u.graphicsExposure.drawable;
+ ev->x = event->u.graphicsExposure.x;
+ ev->y = event->u.graphicsExposure.y;
+ ev->width = event->u.graphicsExposure.width;
+ ev->height = event->u.graphicsExposure.height;
+ ev->count = event->u.graphicsExposure.count;
+ ev->major_code = event->u.graphicsExposure.majorEvent;
+ ev->minor_code = event->u.graphicsExposure.minorEvent;
+ }
+ break;
+ case NoExpose:
+ {
+ register XNoExposeEvent *ev = (XNoExposeEvent *) re;
+ ev->drawable = event->u.noExposure.drawable;
+ ev->major_code = event->u.noExposure.majorEvent;
+ ev->minor_code = event->u.noExposure.minorEvent;
+ }
+ break;
+ case VisibilityNotify:
+ {
+ register XVisibilityEvent *ev = (XVisibilityEvent *) re;
+ ev->window = event->u.visibility.window;
+ ev->state = event->u.visibility.state;
+ }
+ break;
+ case CreateNotify:
+ {
+ register XCreateWindowEvent *ev =
+ (XCreateWindowEvent *) re;
+ ev->window = event->u.createNotify.window;
+ ev->parent = event->u.createNotify.parent;
+ ev->x = cvtINT16toInt(event->u.createNotify.x);
+ ev->y = cvtINT16toInt(event->u.createNotify.y);
+ ev->width = event->u.createNotify.width;
+ ev->height = event->u.createNotify.height;
+ ev->border_width = event->u.createNotify.borderWidth;
+ ev->override_redirect = event->u.createNotify.override;
+ }
+ break;
+ case DestroyNotify:
+ {
+ register XDestroyWindowEvent *ev =
+ (XDestroyWindowEvent *) re;
+ ev->window = event->u.destroyNotify.window;
+ ev->event = event->u.destroyNotify.event;
+ }
+ break;
+ case UnmapNotify:
+ {
+ register XUnmapEvent *ev = (XUnmapEvent *) re;
+ ev->window = event->u.unmapNotify.window;
+ ev->event = event->u.unmapNotify.event;
+ ev->from_configure = event->u.unmapNotify.fromConfigure;
+ }
+ break;
+ case MapNotify:
+ {
+ register XMapEvent *ev = (XMapEvent *) re;
+ ev->window = event->u.mapNotify.window;
+ ev->event = event->u.mapNotify.event;
+ ev->override_redirect = event->u.mapNotify.override;
+ }
+ break;
+ case MapRequest:
+ {
+ register XMapRequestEvent *ev = (XMapRequestEvent *) re;
+ ev->window = event->u.mapRequest.window;
+ ev->parent = event->u.mapRequest.parent;
+ }
+ break;
+ case ReparentNotify:
+ {
+ register XReparentEvent *ev = (XReparentEvent *) re;
+ ev->event = event->u.reparent.event;
+ ev->window = event->u.reparent.window;
+ ev->parent = event->u.reparent.parent;
+ ev->x = cvtINT16toInt(event->u.reparent.x);
+ ev->y = cvtINT16toInt(event->u.reparent.y);
+ ev->override_redirect = event->u.reparent.override;
+ }
+ break;
+ case ConfigureNotify:
+ {
+ register XConfigureEvent *ev = (XConfigureEvent *) re;
+ ev->event = event->u.configureNotify.event;
+ ev->window = event->u.configureNotify.window;
+ ev->above = event->u.configureNotify.aboveSibling;
+ ev->x = cvtINT16toInt(event->u.configureNotify.x);
+ ev->y = cvtINT16toInt(event->u.configureNotify.y);
+ ev->width = event->u.configureNotify.width;
+ ev->height = event->u.configureNotify.height;
+ ev->border_width = event->u.configureNotify.borderWidth;
+ ev->override_redirect = event->u.configureNotify.override;
+ }
+ break;
+ case ConfigureRequest:
+ {
+ register XConfigureRequestEvent *ev =
+ (XConfigureRequestEvent *) re;
+ ev->window = event->u.configureRequest.window;
+ ev->parent = event->u.configureRequest.parent;
+ ev->above = event->u.configureRequest.sibling;
+ ev->x = cvtINT16toInt(event->u.configureRequest.x);
+ ev->y = cvtINT16toInt(event->u.configureRequest.y);
+ ev->width = event->u.configureRequest.width;
+ ev->height = event->u.configureRequest.height;
+ ev->border_width = event->u.configureRequest.borderWidth;
+ ev->value_mask = event->u.configureRequest.valueMask;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case GravityNotify:
+ {
+ register XGravityEvent *ev = (XGravityEvent *) re;
+ ev->window = event->u.gravity.window;
+ ev->event = event->u.gravity.event;
+ ev->x = cvtINT16toInt(event->u.gravity.x);
+ ev->y = cvtINT16toInt(event->u.gravity.y);
+ }
+ break;
+ case ResizeRequest:
+ {
+ register XResizeRequestEvent *ev =
+ (XResizeRequestEvent *) re;
+ ev->window = event->u.resizeRequest.window;
+ ev->width = event->u.resizeRequest.width;
+ ev->height = event->u.resizeRequest.height;
+ }
+ break;
+ case CirculateNotify:
+ {
+ register XCirculateEvent *ev = (XCirculateEvent *) re;
+ ev->window = event->u.circulate.window;
+ ev->event = event->u.circulate.event;
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case CirculateRequest:
+ {
+ register XCirculateRequestEvent *ev =
+ (XCirculateRequestEvent *) re;
+ ev->window = event->u.circulate.window;
+ ev->parent = event->u.circulate.event;
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case PropertyNotify:
+ {
+ register XPropertyEvent *ev = (XPropertyEvent *) re;
+ ev->window = event->u.property.window;
+ ev->atom = event->u.property.atom;
+ ev->time = event->u.property.time;
+ ev->state = event->u.property.state;
+ }
+ break;
+ case SelectionClear:
+ {
+ register XSelectionClearEvent *ev =
+ (XSelectionClearEvent *) re;
+ ev->window = event->u.selectionClear.window;
+ ev->selection = event->u.selectionClear.atom;
+ ev->time = event->u.selectionClear.time;
+ }
+ break;
+ case SelectionRequest:
+ {
+ register XSelectionRequestEvent *ev =
+ (XSelectionRequestEvent *) re;
+ ev->owner = event->u.selectionRequest.owner;
+ ev->requestor = event->u.selectionRequest.requestor;
+ ev->selection = event->u.selectionRequest.selection;
+ ev->target = event->u.selectionRequest.target;
+ ev->property = event->u.selectionRequest.property;
+ ev->time = event->u.selectionRequest.time;
+ }
+ break;
+ case SelectionNotify:
+ {
+ register XSelectionEvent *ev = (XSelectionEvent *) re;
+ ev->requestor = event->u.selectionNotify.requestor;
+ ev->selection = event->u.selectionNotify.selection;
+ ev->target = event->u.selectionNotify.target;
+ ev->property = event->u.selectionNotify.property;
+ ev->time = event->u.selectionNotify.time;
+ }
+ break;
+ case ColormapNotify:
+ {
+ register XColormapEvent *ev = (XColormapEvent *) re;
+ ev->window = event->u.colormap.window;
+ ev->colormap = event->u.colormap.colormap;
+ ev->new = event->u.colormap.new;
+ ev->state = event->u.colormap.state;
+ }
+ break;
+ case ClientMessage:
+ {
+ register int i;
+ register XClientMessageEvent *ev
+ = (XClientMessageEvent *) re;
+ ev->window = event->u.clientMessage.window;
+ ev->format = event->u.u.detail;
+ switch (ev->format) {
+ case 8:
+ ev->message_type = event->u.clientMessage.u.b.type;
+ for (i = 0; i < 20; i++)
+ ev->data.b[i] = event->u.clientMessage.u.b.bytes[i];
+ break;
+ case 16:
+ ev->message_type = event->u.clientMessage.u.s.type;
+ ev->data.s[0] = cvtINT16toShort(event->u.clientMessage.u.s.shorts0);
+ ev->data.s[1] = cvtINT16toShort(event->u.clientMessage.u.s.shorts1);
+ ev->data.s[2] = cvtINT16toShort(event->u.clientMessage.u.s.shorts2);
+ ev->data.s[3] = cvtINT16toShort(event->u.clientMessage.u.s.shorts3);
+ ev->data.s[4] = cvtINT16toShort(event->u.clientMessage.u.s.shorts4);
+ ev->data.s[5] = cvtINT16toShort(event->u.clientMessage.u.s.shorts5);
+ ev->data.s[6] = cvtINT16toShort(event->u.clientMessage.u.s.shorts6);
+ ev->data.s[7] = cvtINT16toShort(event->u.clientMessage.u.s.shorts7);
+ ev->data.s[8] = cvtINT16toShort(event->u.clientMessage.u.s.shorts8);
+ ev->data.s[9] = cvtINT16toShort(event->u.clientMessage.u.s.shorts9);
+ break;
+ case 32:
+ ev->message_type = event->u.clientMessage.u.l.type;
+ ev->data.l[0] = cvtINT32toLong(event->u.clientMessage.u.l.longs0);
+ ev->data.l[1] = cvtINT32toLong(event->u.clientMessage.u.l.longs1);
+ ev->data.l[2] = cvtINT32toLong(event->u.clientMessage.u.l.longs2);
+ ev->data.l[3] = cvtINT32toLong(event->u.clientMessage.u.l.longs3);
+ ev->data.l[4] = cvtINT32toLong(event->u.clientMessage.u.l.longs4);
+ break;
+ default: /* XXX should never occur */
+ break;
+ }
+ }
+ break;
+ case MappingNotify:
+ {
+ register XMappingEvent *ev = (XMappingEvent *)re;
+ ev->window = 0;
+ ev->first_keycode = event->u.mappingNotify.firstKeyCode;
+ ev->request = event->u.mappingNotify.request;
+ ev->count = event->u.mappingNotify.count;
+ }
+ break;
+ default:
+ return(_XUnknownWireEvent(dpy, re, event));
+ }
+ return(True);
+}
+
+
+/*
+ * _XDefaultIOError - Default fatal system error reporting routine. Called
+ * when an X internal system error is encountered.
+ */
+int _XDefaultIOError(
+ Display *dpy)
+{
+ if (ECHECK(EPIPE)) {
+ (void) fprintf (stderr,
+ "X connection to %s broken (explicit kill or server shutdown).\r\n",
+ DisplayString (dpy));
+ } else {
+ (void) fprintf (stderr,
+ "XIO: fatal IO error %d (%s) on X server \"%s\"\r\n",
+#ifdef WIN32
+ WSAGetLastError(), strerror(WSAGetLastError()),
+#else
+ errno, strerror (errno),
+#endif
+ DisplayString (dpy));
+ (void) fprintf (stderr,
+ " after %lu requests (%lu known processed) with %d events remaining.\r\n",
+ NextRequest(dpy) - 1, LastKnownRequestProcessed(dpy),
+ QLength(dpy));
+
+ }
+#ifdef NX_TRANS_SOCKET
+ if (_NXHandleDisplayError == 1)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XDefaultIOError: Going to return from the error handler.\n");
+#endif
+ return 0;
+ }
+ else
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XDefaultIOError: Going to exit from the program.\n");
+#endif
+#ifdef NX_TRANS_EXIT
+ NXTransExit(1);
+#else
+ exit(1);
+#endif
+ }
+#else
+ exit(1);
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+ return(0); /* dummy - function should never return */
+}
+
+
+static int _XPrintDefaultError(
+ Display *dpy,
+ XErrorEvent *event,
+ FILE *fp)
+{
+ char buffer[BUFSIZ];
+ char mesg[BUFSIZ];
+ char number[32];
+ char *mtype = "XlibMessage";
+ register _XExtension *ext = (_XExtension *)NULL;
+ _XExtension *bext = (_XExtension *)NULL;
+ XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
+ XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
+ (void) fprintf(fp, "%s: %s\n ", mesg, buffer);
+ XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->request_code);
+ if (event->request_code < 128) {
+ sprintf(number, "%d", event->request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
+ } else {
+ for (ext = dpy->ext_procs;
+ ext && (ext->codes.major_opcode != event->request_code);
+ ext = ext->next)
+ ;
+ if (ext)
+ strcpy(buffer, ext->name);
+ else
+ buffer[0] = '\0';
+ }
+ (void) fprintf(fp, " (%s)\n", buffer);
+ if (event->request_code >= 128) {
+ XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->minor_code);
+ if (ext) {
+ sprintf(mesg, "%s.%d", ext->name, event->minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
+ (void) fprintf(fp, " (%s)", buffer);
+ }
+ fputs("\n", fp);
+ }
+ if (event->error_code >= 128) {
+ /* kludge, try to find the extension that caused it */
+ buffer[0] = '\0';
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_string)
+ (*ext->error_string)(dpy, event->error_code, &ext->codes,
+ buffer, BUFSIZ);
+ if (buffer[0]) {
+ bext = ext;
+ break;
+ }
+ if (ext->codes.first_error &&
+ ext->codes.first_error < (int)event->error_code &&
+ (!bext || ext->codes.first_error > bext->codes.first_error))
+ bext = ext;
+ }
+ if (bext)
+ sprintf(buffer, "%s.%d", bext->name,
+ event->error_code - bext->codes.first_error);
+ else
+ strcpy(buffer, "Value");
+ XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
+ if (mesg[0]) {
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ /* let extensions try to print the values */
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_values)
+ (*ext->error_values)(dpy, event, fp);
+ }
+ } else if ((event->error_code == BadWindow) ||
+ (event->error_code == BadPixmap) ||
+ (event->error_code == BadCursor) ||
+ (event->error_code == BadFont) ||
+ (event->error_code == BadDrawable) ||
+ (event->error_code == BadColor) ||
+ (event->error_code == BadGC) ||
+ (event->error_code == BadIDChoice) ||
+ (event->error_code == BadValue) ||
+ (event->error_code == BadAtom)) {
+ if (event->error_code == BadValue)
+ XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
+ mesg, BUFSIZ);
+ else if (event->error_code == BadAtom)
+ XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
+ mesg, BUFSIZ);
+ else
+ XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->serial);
+ XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
+ mesg, BUFSIZ);
+ fputs("\n ", fp);
+ (void) fprintf(fp, mesg, dpy->request);
+ fputs("\n", fp);
+ if (event->error_code == BadImplementation) return 0;
+ return 1;
+}
+
+int _XDefaultError(
+ Display *dpy,
+ XErrorEvent *event)
+{
+ if (_XPrintDefaultError (dpy, event, stderr) == 0) return 0;
+ exit(1);
+ /*NOTREACHED*/
+}
+
+/*ARGSUSED*/
+Bool _XDefaultWireError(display, he, we)
+ Display *display;
+ XErrorEvent *he;
+ xError *we;
+{
+ return True;
+}
+
+/*
+ * _XError - upcall internal or user protocol error handler
+ */
+int _XError (
+ Display *dpy,
+ register xError *rep)
+{
+ /*
+ * X_Error packet encountered! We need to unpack the error before
+ * giving it to the user.
+ */
+ XEvent event; /* make it a large event */
+ register _XAsyncHandler *async, *next;
+
+ event.xerror.serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
+
+ for (async = dpy->async_handlers; async; async = next) {
+ next = async->next;
+ if ((*async->handler)(dpy, (xReply *)rep,
+ (char *)rep, SIZEOF(xError), async->data))
+ return 0;
+ }
+
+ event.xerror.display = dpy;
+ event.xerror.type = X_Error;
+ event.xerror.resourceid = rep->resourceID;
+ event.xerror.error_code = rep->errorCode;
+ event.xerror.request_code = rep->majorCode;
+ event.xerror.minor_code = rep->minorCode;
+ if (dpy->error_vec &&
+ !(*dpy->error_vec[rep->errorCode])(dpy, &event.xerror, rep))
+ return 0;
+ if (_XErrorFunction != NULL) {
+ int rtn_val;
+#ifdef XTHREADS
+ if (dpy->lock)
+ (*dpy->lock->user_lock_display)(dpy);
+ UnlockDisplay(dpy);
+#endif /* XTHREADS */
+ rtn_val = (*_XErrorFunction)(dpy, (XErrorEvent *)&event); /* upcall */
+#ifdef XTHREADS
+ LockDisplay(dpy);
+ if (dpy->lock)
+ (*dpy->lock->user_unlock_display)(dpy);
+#endif /* XTHREADS */
+ return rtn_val;
+ } else {
+ return _XDefaultError(dpy, (XErrorEvent *)&event);
+ }
+}
+
+/*
+ * _XIOError - call user connection error handler and exit
+ */
+int
+_XIOError (
+ Display *dpy)
+{
+ dpy->flags |= XlibDisplayIOError;
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+
+ if (_XIOErrorFunction != NULL)
+ (*_XIOErrorFunction)(dpy);
+ else
+ _XDefaultIOError(dpy);
+#ifdef NX_TRANS_SOCKET
+ /*
+ * Check if we are supposed to return in the case
+ * of a display failure. The client which originated
+ * the X operation will have to check the value of
+ * the XlibDisplayIOError flag and handle appropria-
+ * tely the display disconnection.
+ */
+
+ if (_NXHandleDisplayError == 0)
+ {
+#ifdef NX_TRANS_EXIT
+ NXTransExit(1);
+#else
+ exit(1);
+#endif
+ }
+
+ /*
+ * We are going to return. Reset the display
+ * buffers. Further writes will be discarded.
+ */
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XIOError: Resetting the display buffer.\n");
+#endif
+
+ dpy->bufptr = dpy->buffer;
+ dpy->last_req = (char *) &_dummy_request;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XIOError: Resetting the display flags.\n");
+#endif
+
+ dpy->flags &= ~XlibDisplayProcConni;
+ dpy->flags &= ~XlibDisplayPrivSync;
+ dpy->flags &= ~XlibDisplayReadEvents;
+ dpy->flags &= ~XlibDisplayWriting;
+ dpy->flags &= ~XlibDisplayReply;
+#else
+ exit (1);
+#endif
+ return 0;
+}
+
+
+/*
+ * This routine can be used to (cheaply) get some memory within a single
+ * Xlib routine for scratch space. A single buffer is reused each time
+ * if possible. To be MT safe, you can only call this between a call to
+ * GetReq* and a call to Data* or _XSend*, or in a context when the thread
+ * is guaranteed to not unlock the display.
+ */
+char *_XAllocScratch(
+ register Display *dpy,
+ unsigned long nbytes)
+{
+ if (nbytes > dpy->scratch_length) {
+ if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer);
+ if ((dpy->scratch_buffer = Xmalloc((unsigned) nbytes)))
+ dpy->scratch_length = nbytes;
+ else dpy->scratch_length = 0;
+ }
+ return (dpy->scratch_buffer);
+}
+
+/*
+ * Scratch space allocator you can call any time, multiple times, and be
+ * MT safe, but you must hand the buffer back with _XFreeTemp.
+ */
+char *_XAllocTemp(
+ register Display *dpy,
+ unsigned long nbytes)
+{
+ char *buf;
+
+ buf = _XAllocScratch(dpy, nbytes);
+ dpy->scratch_buffer = NULL;
+ dpy->scratch_length = 0;
+ return buf;
+}
+
+void _XFreeTemp(
+ register Display *dpy,
+ char *buf,
+ unsigned long nbytes)
+{
+ if (dpy->scratch_buffer)
+ Xfree(dpy->scratch_buffer);
+ dpy->scratch_buffer = buf;
+ dpy->scratch_length = nbytes;
+}
+
+/*
+ * Given a visual id, find the visual structure for this id on this display.
+ */
+Visual *_XVIDtoVisual(
+ Display *dpy,
+ VisualID id)
+{
+ register int i, j, k;
+ register Screen *sp;
+ register Depth *dp;
+ register Visual *vp;
+ for (i = 0; i < dpy->nscreens; i++) {
+ sp = &dpy->screens[i];
+ for (j = 0; j < sp->ndepths; j++) {
+ dp = &sp->depths[j];
+ /* if nvisuals == 0 then visuals will be NULL */
+ for (k = 0; k < dp->nvisuals; k++) {
+ vp = &dp->visuals[k];
+ if (vp->visualid == id) return (vp);
+ }
+ }
+ }
+ return (NULL);
+}
+
+int
+XFree (void *data)
+{
+ Xfree (data);
+ return 1;
+}
+
+#ifdef _XNEEDBCOPYFUNC
+void _Xbcopy(b1, b2, length)
+ register char *b1, *b2;
+ register length;
+{
+ if (b1 < b2) {
+ b2 += length;
+ b1 += length;
+ while (length--)
+ *--b2 = *--b1;
+ } else {
+ while (length--)
+ *b2++ = *b1++;
+ }
+}
+#endif
+
+#ifdef DataRoutineIsProcedure
+void Data(
+ Display *dpy,
+ char *data,
+ long len)
+{
+ if (dpy->bufptr + (len) <= dpy->bufmax) {
+ memcpy(dpy->bufptr, data, (int)len);
+ dpy->bufptr += ((len) + 3) & ~3;
+ } else {
+ _XSend(dpy, data, len);
+ }
+}
+#endif /* DataRoutineIsProcedure */
+
+
+#ifdef LONG64
+int
+_XData32(
+ Display *dpy,
+ register long *data,
+ unsigned len)
+{
+ register int *buf;
+ register long i;
+
+ while (len) {
+ buf = (int *)dpy->bufptr;
+ i = dpy->bufmax - (char *)buf;
+ if (!i) {
+ _XFlush(dpy);
+ continue;
+ }
+ if (len < i)
+ i = len;
+ dpy->bufptr = (char *)buf + i;
+ len -= i;
+ i >>= 2;
+ while (--i >= 0)
+ *buf++ = *data++;
+ }
+ return 0;
+}
+#endif /* LONG64 */
+
+#ifdef WORD64
+
+/*
+ * XXX This is a *really* stupid way of doing this. It should just use
+ * dpy->bufptr directly, taking into account where in the word it is.
+ */
+
+/*
+ * Data16 - Place 16 bit data in the buffer.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static doData16(
+ register Display *dpy,
+ short *data,
+ unsigned len,
+ char *packbuffer)
+{
+ long *lp,*lpack;
+ long i, nwords,bits;
+ long mask16 = 0x000000000000ffff;
+
+ lp = (long *)data;
+ lpack = (long *)packbuffer;
+
+/* nwords is the number of 16 bit values to be packed,
+ * the low order 16 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 1;
+ bits = 48;
+
+ for(i=0;i<nwords;i++){
+ if (bits == 48) *lpack = 0;
+ *lpack ^= (*lp & mask16) << bits;
+ bits -= 16 ;
+ lp++;
+ if(bits < 0){
+ lpack++;
+ bits = 48;
+ }
+ }
+ Data(dpy, packbuffer, len);
+}
+
+_XData16 (
+ Display *dpy,
+ short *data,
+ unsigned len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 1;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ doData16 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) doData16 (dpy, data, len, packbuffer);
+}
+
+/*
+ * Data32 - Place 32 bit data in the buffer.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static doData32(
+ register Display *dpy
+ long *data,
+ unsigned len,
+ char *packbuffer)
+{
+ long *lp,*lpack;
+ long i,bits,nwords;
+ long mask32 = 0x00000000ffffffff;
+
+ lpack = (long *) packbuffer;
+ lp = data;
+
+/* nwords is the number of 32 bit values to be packed
+ * the low order 32 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 2;
+ bits = 32;
+
+ for(i=0;i<nwords;i++){
+ if (bits == 32) *lpack = 0;
+ *lpack ^= (*lp & mask32) << bits;
+ bits = bits ^32;
+ lp++;
+ if(bits)
+ lpack++;
+ }
+ Data(dpy, packbuffer, len);
+}
+
+void _XData32(
+ Display *dpy,
+ long *data,
+ unsigned len,
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 2;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ doData32 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) doData32 (dpy, data, len, packbuffer);
+}
+
+#endif /* WORD64 */
+
+
+/* Make sure this produces the same string as DefineLocal/DefineSelf in xdm.
+ * Otherwise, Xau will not be able to find your cookies in the Xauthority file.
+ *
+ * Note: POSIX says that the ``nodename'' member of utsname does _not_ have
+ * to have sufficient information for interfacing to the network,
+ * and so, you may be better off using gethostname (if it exists).
+ */
+
+#if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(USG) || defined(SVR4)
+#define NEED_UTSNAME
+#include <sys/utsname.h>
+#endif
+
+/*
+ * _XGetHostname - similar to gethostname but allows special processing.
+ */
+int _XGetHostname (
+ char *buf,
+ int maxlen)
+{
+ int len;
+
+#ifdef NEED_UTSNAME
+ struct utsname name;
+
+ if (maxlen <= 0 || buf == NULL)
+ return 0;
+
+ uname (&name);
+ len = strlen (name.nodename);
+ if (len >= maxlen) len = maxlen - 1;
+ strncpy (buf, name.nodename, len);
+ buf[len] = '\0';
+#else
+ if (maxlen <= 0 || buf == NULL)
+ return 0;
+
+ buf[0] = '\0';
+ (void) gethostname (buf, maxlen);
+ buf [maxlen - 1] = '\0';
+ len = strlen(buf);
+#endif /* NEED_UTSNAME */
+ return len;
+}
+
+
+/*
+ * _XScreenOfWindow - get the Screen of a given window
+ */
+
+Screen *_XScreenOfWindow (dpy, w)
+ Display *dpy;
+ Window w;
+{
+ register int i;
+ Window root;
+ int x, y; /* dummy variables */
+ unsigned int width, height, bw, depth; /* dummy variables */
+
+ if (XGetGeometry (dpy, w, &root, &x, &y, &width, &height,
+ &bw, &depth) == False) {
+ return None;
+ }
+ for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */
+ if (root == RootWindow (dpy, i)) {
+ return ScreenOfDisplay (dpy, i);
+ }
+ }
+ return NULL;
+}
+
+
+#if defined(WIN32)
+
+/*
+ * These functions are intended to be used internally to Xlib only.
+ * These functions will always prefix the path with a DOS drive in the
+ * form "<drive-letter>:". As such, these functions are only suitable
+ * for use by Xlib function that supply a root-based path to some
+ * particular file, e.g. <ProjectRoot>/lib/X11/locale/locale.dir will
+ * be converted to "C:/usr/X11R6.3/lib/X11/locale/locale.dir".
+ */
+
+static int access_file (path, pathbuf, len_pathbuf, pathret)
+ char* path;
+ char* pathbuf;
+ int len_pathbuf;
+ char** pathret;
+{
+ if (access (path, F_OK) == 0) {
+ if (strlen (path) < len_pathbuf)
+ *pathret = pathbuf;
+ else
+ *pathret = Xmalloc (strlen (path) + 1);
+ if (*pathret) {
+ strcpy (*pathret, path);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int AccessFile (path, pathbuf, len_pathbuf, pathret)
+ char* path;
+ char* pathbuf;
+ int len_pathbuf;
+ char** pathret;
+{
+ unsigned long drives;
+ int i, len;
+ char* drive;
+ char buf[MAX_PATH];
+ char* bufp;
+
+ /* just try the "raw" name first and see if it works */
+ if (access_file (path, pathbuf, len_pathbuf, pathret))
+ return 1;
+
+ /* try the places set in the environment */
+ drive = getenv ("_XBASEDRIVE");
+#ifdef __UNIXOS2__
+ if (!drive)
+ drive = getenv ("X11ROOT");
+#endif
+ if (!drive)
+ drive = "C:";
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+
+#ifndef __UNIXOS2__
+ /* one last place to look */
+ drive = getenv ("HOMEDRIVE");
+ if (drive) {
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+ }
+
+ /* tried everywhere else, go fishing */
+#define C_DRIVE ('C' - 'A')
+#define Z_DRIVE ('Z' - 'A')
+ /* does OS/2 (with or with gcc-emx) have getdrives? */
+ drives = _getdrives ();
+ for (i = C_DRIVE; i <= Z_DRIVE; i++) { /* don't check on A: or B: */
+ if ((1 << i) & drives) {
+ len = 2 + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ *bufp = 'A' + i;
+ *(bufp + 1) = ':';
+ *(bufp + 2) = '\0';
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+ }
+ }
+#endif
+ return 0;
+}
+
+int _XOpenFile(path, flags)
+ _Xconst char* path;
+ int flags;
+{
+ char buf[MAX_PATH];
+ char* bufp = NULL;
+ int ret = -1;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ ret = open (bufp, flags);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+void* _XFopenFile(path, mode)
+ _Xconst char* path;
+ _Xconst char* mode;
+{
+ char buf[MAX_PATH];
+ char* bufp = NULL;
+ void* ret = NULL;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ ret = fopen (bufp, mode);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+int _XAccessFile(path)
+ _Xconst char* path;
+{
+ char buf[MAX_PATH];
+ char* bufp;
+ int ret = -1;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ ret = AccessFile (path, buf, MAX_PATH, &bufp);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+#endif
+
+#ifdef WIN32
+#undef _Xdebug
+int _Xdebug = 0;
+int *_Xdebug_p = &_Xdebug;
+void (**_XCreateMutex_fn_p)(LockInfoPtr) = &_XCreateMutex_fn;
+void (**_XFreeMutex_fn_p)(LockInfoPtr) = &_XFreeMutex_fn;
+void (**_XLockMutex_fn_p)(LockInfoPtr
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = &_XLockMutex_fn;
+void (**_XUnlockMutex_fn_p)(LockInfoPtr
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = &_XUnlockMutex_fn;
+LockInfoPtr *_Xglobal_lock_p = &_Xglobal_lock;
+#endif
diff --git a/nx-X11/lib/X11/XlibInt.c.NX.original b/nx-X11/lib/X11/XlibInt.c.NX.original
new file mode 100644
index 000000000..47e2ea139
--- /dev/null
+++ b/nx-X11/lib/X11/XlibInt.c.NX.original
@@ -0,0 +1,4167 @@
+/* $Xorg: XlibInt.c,v 1.8 2001/02/09 02:03:38 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.
+
+*/
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/* $XFree86: xc/lib/X11/XlibInt.c,v 3.38 2003/10/30 21:55:05 alanh Exp $ */
+
+/*
+ * XlibInt.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
+
+#ifdef WIN32
+#define _XLIBINT_
+#endif
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xpoll.h>
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/extensions/xcmiscstr.h>
+#include <stdio.h>
+#ifdef WIN32
+#include <direct.h>
+#endif
+
+#ifdef XTHREADS
+#include "locking.h"
+
+/* these pointers get initialized by XInitThreads */
+LockInfoPtr _Xglobal_lock = NULL;
+void (*_XCreateMutex_fn)(LockInfoPtr) = NULL;
+/* struct _XCVList *(*_XCreateCVL_fn)() = NULL; */
+void (*_XFreeMutex_fn)(LockInfoPtr) = NULL;
+void (*_XLockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = NULL;
+void (*_XUnlockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = NULL;
+xthread_t (*_Xthread_self_fn)(void) = NULL;
+
+#define XThread_Self() ((*_Xthread_self_fn)())
+
+#define UnlockNextReplyReader(d) if ((d)->lock) \
+ (*(d)->lock->pop_reader)((d),&(d)->lock->reply_awaiters,&(d)->lock->reply_awaiters_tail)
+
+#define QueueReplyReaderLock(d) ((d)->lock ? \
+ (*(d)->lock->push_reader)(d,&(d)->lock->reply_awaiters_tail) : NULL)
+#define QueueEventReaderLock(d) ((d)->lock ? \
+ (*(d)->lock->push_reader)(d,&(d)->lock->event_awaiters_tail) : NULL)
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+#define InternalLockDisplay(d,wskip) if ((d)->lock) \
+ (*(d)->lock->internal_lock_display)(d,wskip,__FILE__,__LINE__)
+#else
+#define InternalLockDisplay(d,wskip) if ((d)->lock) \
+ (*(d)->lock->internal_lock_display)(d,wskip)
+#endif
+
+#else /* XTHREADS else */
+
+#define UnlockNextReplyReader(d)
+#define UnlockNextEventReader(d)
+#define InternalLockDisplay(d,wskip)
+
+#endif /* XTHREADS else */
+
+#include "NX.h"
+
+#ifdef NX_TRANS_SOCKET
+
+#include "NX.h"
+#include "NXvars.h"
+
+static struct timeval retry;
+
+/*
+ * From Xtranssock.c. Presently the congestion state
+ * is reported by the proxy to the application, by
+ * invoking the callback directly. The function will
+ * be possibly used in the future, to be able to track
+ * the bandwidth usage even when the NX transport is
+ * not running. Note that in this sample implementation
+ * the congestion state is checked very often and can
+ * be surely optimized.
+ */
+
+#ifdef NX_TRANS_CHANGE
+
+extern int _X11TransSocketCongestionChange(XtransConnInfo, int *);
+
+#endif
+
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ */
+#ifdef WIN32
+#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK)
+#else
+#ifdef __CYGWIN__ /* Cygwin uses ENOBUFS to signal socket is full */
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS)
+#else
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define ETEST() (errno == EAGAIN)
+#else
+#define ETEST() (errno == EWOULDBLOCK)
+#endif /* EAGAIN */
+#endif /* EAGAIN && EWOULDBLOCK */
+#endif /* __CYGWIN__ */
+#endif /* WIN32 */
+
+#ifdef WIN32
+#define ECHECK(err) (WSAGetLastError() == err)
+#define ESET(val) WSASetLastError(val)
+#else
+#ifdef __UNIXOS2__
+#define ECHECK(err) (errno == err)
+#define ESET(val)
+#else
+#ifdef ISC
+#define ECHECK(err) ((errno == err) || ETEST())
+#else
+#define ECHECK(err) (errno == err)
+#endif
+#define ESET(val) errno = val
+#endif
+#endif
+
+#if defined(LOCALCONN) || defined(LACHMAN)
+#ifdef EMSGSIZE
+#define ESZTEST() (ECHECK(EMSGSIZE) || ECHECK(ERANGE))
+#else
+#define ESZTEST() ECHECK(ERANGE)
+#endif
+#else
+#ifdef EMSGSIZE
+#define ESZTEST() ECHECK(EMSGSIZE)
+#endif
+#endif
+
+#ifdef __UNIXOS2__
+#define select(n,r,w,x,t) os2ClientSelect(n,r,w,x,t)
+#include <limits.h>
+#define MAX_PATH _POSIX_PATH_MAX
+#endif
+
+#ifdef MUSTCOPY
+
+#define STARTITERATE(tpvar,type,start,endcond) \
+ { register char *cpvar; \
+ for (cpvar = (char *) (start); endcond; ) { \
+ type dummy; memcpy ((char *) &dummy, cpvar, SIZEOF(type)); \
+ tpvar = &dummy;
+#define ITERPTR(tpvar) cpvar
+#define RESETITERPTR(tpvar,type,start) cpvar = start
+#define INCITERPTR(tpvar,type) cpvar += SIZEOF(type)
+#define ENDITERATE }}
+
+#else
+
+#define STARTITERATE(tpvar,type,start,endcond) \
+ for (tpvar = (type *) (start); endcond; )
+#define ITERPTR(tpvar) (char *)tpvar
+#define RESETITERPTR(tpvar,type,start) tpvar = (type *) (start)
+#define INCITERPTR(tpvar,type) tpvar++
+#define ENDITERATE
+
+#endif /* MUSTCOPY */
+
+typedef union {
+ xReply rep;
+ char buf[BUFSIZE];
+} _XAlignedBuffer;
+
+static char *_XAsyncReply(
+ Display *dpy,
+ register xReply *rep,
+ char *buf,
+ register int *lenp,
+ Bool discard);
+
+static void _XProcessInternalConnection(
+ Display *dpy,
+ struct _XConnectionInfo *conn_info);
+
+#define SEQLIMIT (65535 - (BUFSIZE / SIZEOF(xReq)) - 10)
+
+/*
+ * The following routines are internal routines used by Xlib for protocol
+ * packet transmission and reception.
+ *
+ * _XIOError(Display *) will be called if any sort of system call error occurs.
+ * This is assumed to be a fatal condition, i.e., XIOError should not return.
+ *
+ * _XError(Display *, xError *) will be called whenever an X_Error event is
+ * received. This is not assumed to be a fatal condition, i.e., it is
+ * acceptable for this procedure to return. However, XError should NOT
+ * perform any operations (directly or indirectly) on the DISPLAY.
+ *
+ * Routines declared with a return type of 'Status' return 0 on failure,
+ * and non 0 on success. Routines with no declared return type don't
+ * return anything. Whenever possible routines that create objects return
+ * the object they have created.
+ */
+
+static xReq _dummy_request = {
+ 0, 0, 0
+};
+
+#ifdef NX_TRANS_SOCKET
+
+/*
+ * Replace the standard Select with a version giving NX a
+ * chance to check its own descriptors. This doesn't cover
+ * the cases where the system is using poll or when system-
+ * specific defines override the Select definition (OS/2).
+ */
+
+int _XSelect(int maxfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+{
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XSelect: Called with [%d][%p][%p][%p][%p].\n",
+ maxfds, (void *) readfds, (void *) writefds, (void *) exceptfds,
+ (void *) timeout);
+#endif
+
+ if (NXTransRunning(NX_FD_ANY))
+ {
+ fd_set t_readfds, t_writefds;
+ struct timeval t_timeout;
+
+ int n, r, e;
+
+#ifdef NX_TRANS_TEST
+
+ if (exceptfds != NULL)
+ {
+ fprintf(stderr, "_XSelect: WARNING! Can't handle exception fds in select.\n");
+ }
+
+#endif
+
+ if (readfds == NULL)
+ {
+ FD_ZERO(&t_readfds);
+
+ readfds = &t_readfds;
+ }
+
+ if (writefds == NULL)
+ {
+ FD_ZERO(&t_writefds);
+
+ writefds = &t_writefds;
+ }
+
+ if (timeout == NULL)
+ {
+ t_timeout.tv_sec = 10;
+ t_timeout.tv_usec = 0;
+
+ timeout = &t_timeout;
+ }
+
+ n = maxfds;
+
+ /*
+ * If the transport is gone avoid
+ * sleeping until the timeout.
+ */
+
+ if (NXTransPrepare(&n, readfds, writefds, timeout) != 0)
+ {
+ NXTransSelect(&r, &e, &n, readfds, writefds, timeout);
+
+ NXTransExecute(&r, &e, &n, readfds, writefds, timeout);
+
+ errno = e;
+
+ return r;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ return select(maxfds, readfds, writefds, exceptfds, timeout);
+ }
+}
+
+#else /* #ifdef NX_TRANS_SOCKET */
+
+int _XSelect(int maxfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+{
+ return select(maxfds, readfds, writefds, exceptfds, timeout);
+}
+
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+/*
+ * This is an OS dependent routine which:
+ * 1) returns as soon as the connection can be written on....
+ * 2) if the connection can be read, must enqueue events and handle errors,
+ * until the connection is writable.
+ */
+static void
+_XWaitForWritable(
+ Display *dpy
+#ifdef XTHREADS
+ ,
+ xcondition_t cv /* our reading condition variable */
+#endif
+ )
+{
+#ifdef USE_POLL
+ struct pollfd filedes;
+#else
+ fd_set r_mask;
+ fd_set w_mask;
+#endif
+ int nfound;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ int congestion;
+#endif
+
+#ifdef NX_TRANS_SOCKET
+
+ if (_XGetIOError(dpy)) {
+ return;
+ }
+
+#endif
+
+#ifdef USE_POLL
+ filedes.fd = dpy->fd;
+ filedes.events = 0;
+#else
+ FD_ZERO(&r_mask);
+ FD_ZERO(&w_mask);
+#endif
+
+ for (;;) {
+#ifdef XTHREADS
+ /* We allow only one thread at a time to read, to minimize
+ passing of read data between threads.
+ Now, who is it? If there is a non-NULL reply_awaiters and
+ we (i.e., our cv) are not at the head of it, then whoever
+ is at the head is the reader, and we don't read.
+ Otherwise there is no reply_awaiters or we are at the
+ head, having just appended ourselves.
+ In this case, if there is a event_awaiters, then whoever
+ is at the head of it got there before we did, and they are the
+ reader.
+
+ Last cases: no event_awaiters and we are at the head of
+ reply_awaiters or reply_awaiters is NULL: we are the reader,
+ since there is obviously no one else involved.
+
+ XXX - what if cv is NULL and someone else comes along after
+ us while we are waiting?
+ */
+
+ if (!dpy->lock ||
+ (!dpy->lock->event_awaiters &&
+ (!dpy->lock->reply_awaiters ||
+ dpy->lock->reply_awaiters->cv == cv)))
+#endif
+
+#ifndef NX_TRANS_SOCKET
+#ifdef USE_POLL
+ filedes.events = POLLIN;
+ filedes.events |= POLLOUT;
+#else
+ FD_SET(dpy->fd, &r_mask);
+ FD_SET(dpy->fd, &w_mask);
+#endif
+#endif /* #ifndef NX_TRANS_SOCKET */
+
+ do {
+#ifdef NX_TRANS_SOCKET
+ /*
+ * Give a chance to the registered client to perform
+ * any needed operation before entering the select.
+ */
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XWaitForWritable: WAIT! Waiting for the display to become writable.\n");
+#endif
+ NXTransFlush(dpy->fd);
+
+ if (_NXDisplayBlockFunction != NULL) {
+ (*_NXDisplayBlockFunction)(dpy, NXBlockWrite);
+ }
+
+ /*
+ * Need to set again the descriptors as we could have
+ * run multiple selects before having the possibility
+ * to read or write to the X connection.
+ */
+
+#ifdef USE_POLL
+ filedes.events = POLLIN;
+ filedes.events |= POLLOUT;
+#else
+ FD_SET(dpy->fd, &r_mask);
+ FD_SET(dpy->fd, &w_mask);
+#endif
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+ UnlockDisplay(dpy);
+#ifdef USE_POLL
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XWaitForWritable: Calling poll().\n");
+#endif
+ nfound = poll (&filedes, 1, -1);
+#else
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XWaitForWritable: Calling select() after [%ld] ms.\n",
+ NXTransTime());
+#endif
+#ifdef NX_TRANS_SOCKET
+ /*
+ * Give a chance to the callback to detect
+ * the failure of the display even if we
+ * miss the interrupt inside the select.
+ */
+
+ if (_NXDisplayErrorFunction != NULL) {
+ retry.tv_sec = 5;
+ retry.tv_usec = 0;
+ nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, &retry);
+ } else {
+ nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL);
+ }
+#else
+ nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL);
+#endif
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XWaitForWritable: Out of select() with [%d] after [%ld] ms.\n",
+ nfound, NXTransTime());
+
+ if (FD_ISSET(dpy->fd, &r_mask))
+ {
+ BytesReadable_t pend;
+
+ _X11TransBytesReadable(dpy->trans_conn, &pend);
+
+ fprintf(stderr, "_XWaitForWritable: Descriptor [%d] is ready with [%ld] bytes to read.\n",
+ dpy->fd, pend);
+ }
+
+ if (FD_ISSET(dpy->fd, &w_mask))
+ {
+ fprintf(stderr, "_XWaitForWritable: Descriptor [%d] has become writable.\n\n",
+ dpy->fd);
+ }
+#endif
+#endif
+ InternalLockDisplay(dpy, cv != NULL);
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+#endif
+
+#ifdef NX_TRANS_SOCKET
+ if (nfound <= 0) {
+ if ((nfound == -1 && !ECHECK(EINTR)) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return;
+ }
+ }
+#else
+ if (nfound < 0 && !ECHECK(EINTR))
+ _XIOError(dpy);
+#endif
+ } while (nfound <= 0);
+
+ if (
+#ifdef USE_POLL
+ filedes.revents & POLLIN
+#else
+ FD_ISSET(dpy->fd, &r_mask)
+#endif
+ )
+ {
+ _XAlignedBuffer buf;
+ BytesReadable_t pend;
+ register int len;
+ register xReply *rep;
+
+ /* find out how much data can be read */
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+#ifdef NX_TRANS_SOCKET
+ {
+ _XIOError(dpy);
+
+ return;
+ }
+#else
+ _XIOError(dpy);
+#endif
+ len = pend;
+
+ /* must read at least one xEvent; if none is pending, then
+ we'll just block waiting for it */
+ if (len < SIZEOF(xReply)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ )
+ len = SIZEOF(xReply);
+
+ /* but we won't read more than the max buffer size */
+ if (len > BUFSIZE) len = BUFSIZE;
+
+ /* round down to an integral number of XReps */
+ len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
+
+ (void) _XRead (dpy, buf.buf, (long) len);
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ int tmp = len;
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &tmp, True));
+ len = tmp;
+ pend = len;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *)rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->event_awaiters)
+ ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
+#endif
+ }
+#ifdef USE_POLL
+ if (filedes.revents & (POLLOUT|POLLHUP|POLLERR))
+#else
+ if (FD_ISSET(dpy->fd, &w_mask))
+#endif
+ {
+#ifdef XTHREADS
+ if (dpy->lock) {
+ ConditionBroadcast(dpy, dpy->lock->writers);
+ }
+#endif
+ return;
+ }
+ }
+}
+
+
+#define POLLFD_CACHE_SIZE 5
+
+/* initialize the struct array passed to poll() below */
+Bool _XPollfdCacheInit(
+ Display *dpy)
+{
+#ifdef USE_POLL
+ struct pollfd *pfp;
+
+ pfp = (struct pollfd *)Xmalloc(POLLFD_CACHE_SIZE * sizeof(struct pollfd));
+ if (!pfp)
+ return False;
+ pfp[0].fd = dpy->fd;
+ pfp[0].events = POLLIN;
+
+ dpy->filedes = (XPointer)pfp;
+#endif
+ return True;
+}
+
+void _XPollfdCacheAdd(
+ Display *dpy,
+ int fd)
+{
+#ifdef USE_POLL
+ struct pollfd *pfp = (struct pollfd *)dpy->filedes;
+
+ if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) {
+ pfp[dpy->im_fd_length].fd = fd;
+ pfp[dpy->im_fd_length].events = POLLIN;
+ }
+#endif
+}
+
+/* ARGSUSED */
+void _XPollfdCacheDel(
+ Display *dpy,
+ int fd) /* not used */
+{
+#ifdef USE_POLL
+ struct pollfd *pfp = (struct pollfd *)dpy->filedes;
+ struct _XConnectionInfo *conni;
+
+ /* just recalculate whole list */
+ if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) {
+ int loc = 1;
+ for (conni = dpy->im_fd_info; conni; conni=conni->next) {
+ pfp[loc].fd = conni->fd;
+ pfp[loc].events = POLLIN;
+ loc++;
+ }
+ }
+#endif
+}
+
+/* returns True iff there is an event in the queue newer than serial_num */
+
+static Bool
+_XNewerQueuedEvent(
+ Display *dpy,
+ int serial_num)
+{
+ _XQEvent *qev;
+
+ if (dpy->next_event_serial_num == serial_num)
+ return False;
+
+ qev = dpy->head;
+ while (qev) {
+ if (qev->qserial_num >= serial_num) {
+ return True;
+ }
+ qev = qev->next;
+ }
+ return False;
+}
+
+static int
+_XWaitForReadable(
+ Display *dpy)
+{
+ int result;
+ int fd = dpy->fd;
+ struct _XConnectionInfo *ilist;
+ register int saved_event_serial = 0;
+ int in_read_events = 0;
+ register Bool did_proc_conni = False;
+#ifdef USE_POLL
+ struct pollfd *filedes;
+#else
+ fd_set r_mask;
+ int highest_fd = fd;
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ int congestion;
+#endif
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return -1;
+ }
+#endif
+
+#ifdef USE_POLL
+ if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE
+ && !(dpy->flags & XlibDisplayProcConni)) {
+ /* XXX - this fallback is gross */
+ int i;
+
+ filedes = (struct pollfd *)Xmalloc(dpy->im_fd_length * sizeof(struct pollfd));
+ filedes[0].fd = fd;
+ filedes[0].events = POLLIN;
+ for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
+ filedes[i].fd = ilist->fd;
+ filedes[i].events = POLLIN;
+ }
+ } else {
+ filedes = (struct pollfd *)dpy->filedes;
+ }
+#else
+ FD_ZERO(&r_mask);
+#endif
+ for (;;) {
+#ifndef USE_POLL
+ FD_SET(fd, &r_mask);
+ if (!(dpy->flags & XlibDisplayProcConni))
+ for (ilist=dpy->im_fd_info; ilist; ilist=ilist->next) {
+ FD_SET(ilist->fd, &r_mask);
+ if (ilist->fd > highest_fd)
+ highest_fd = ilist->fd;
+ }
+#endif
+ UnlockDisplay(dpy);
+#ifdef USE_POLL
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XWaitForReadable: Calling poll().\n");
+#endif
+ result = poll(filedes,
+ (dpy->flags & XlibDisplayProcConni) ? 1 : 1+dpy->im_fd_length,
+ -1);
+#else
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XWaitForReadable: Calling select().\n");
+#endif
+#ifdef NX_TRANS_SOCKET
+ /*
+ * Give a chance to the registered application
+ * to perform any needed operation.
+ */
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XWaitForReadable: WAIT! Waiting for the display to become readable.\n");
+#endif
+ NXTransFlush(dpy->fd);
+
+ if (_NXDisplayBlockFunction != NULL) {
+ (*_NXDisplayBlockFunction)(dpy, NXBlockRead);
+ }
+
+ if (_NXDisplayErrorFunction != NULL) {
+ retry.tv_sec = 5;
+ retry.tv_usec = 0;
+ result = Select(highest_fd + 1, &r_mask, NULL, NULL, &retry);
+ } else {
+ result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL);
+ }
+#else
+ result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL);
+#endif
+#endif
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XWaitForReadable: Out of select with result [%d] and errno [%d].\n",
+ result, (result < 0 ? errno : 0));
+#endif
+ InternalLockDisplay(dpy, dpy->flags & XlibDisplayReply);
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+#endif
+#ifdef NX_TRANS_SOCKET
+ if (result <= 0) {
+ if ((result == -1 && !ECHECK(EINTR)) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return -1;
+ }
+ continue;
+ }
+#else
+ if (result == -1 && !ECHECK(EINTR)) _XIOError(dpy);
+ if (result <= 0)
+ continue;
+#endif
+#ifdef USE_POLL
+ if (filedes[0].revents & (POLLIN|POLLHUP|POLLERR))
+#else
+ if (FD_ISSET(fd, &r_mask))
+#endif
+ break;
+ if (!(dpy->flags & XlibDisplayProcConni)) {
+ int i;
+
+ saved_event_serial = dpy->next_event_serial_num;
+ /* dpy flags can be clobbered by internal connection callback */
+ in_read_events = dpy->flags & XlibDisplayReadEvents;
+ for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
+#ifdef USE_POLL
+ if (filedes[i].revents & POLLIN)
+#else
+ if (FD_ISSET(ilist->fd, &r_mask))
+#endif
+ {
+ _XProcessInternalConnection(dpy, ilist);
+ did_proc_conni = True;
+ }
+ }
+#ifdef USE_POLL
+ if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE)
+ Xfree(filedes);
+#endif
+ }
+ if (did_proc_conni) {
+ /* some internal connection callback might have done an
+ XPutBackEvent. We notice it here and if we needed an event,
+ we can return all the way. */
+ if (_XNewerQueuedEvent(dpy, saved_event_serial)
+ && (in_read_events
+#ifdef XTHREADS
+ || (dpy->lock && dpy->lock->event_awaiters)
+#endif
+ ))
+ return -2;
+ did_proc_conni = False;
+ }
+ }
+#ifdef XTHREADS
+#ifdef XTHREADS_DEBUG
+ printf("thread %x _XWaitForReadable returning\n", XThread_Self());
+#endif
+#endif
+ return 0;
+}
+
+static
+int _XSeqSyncFunction(
+ register Display *dpy)
+{
+ xGetInputFocusReply rep;
+ register xReq *req;
+
+#ifdef NX_TRANS_SOCKET
+#ifdef NX_TRANS_DEBUG
+ fprintf(stderr, "_XSeqSyncFunction: Going to synchronize the display.\n");
+#endif
+ if (dpy->flags & XlibDisplayIOError)
+ {
+#ifdef NX_TRANS_DEBUG
+ fprintf(stderr, "_XSeqSyncFunction: Returning 0 with I/O error detected.\n");
+#endif
+ return 0;
+ }
+#endif
+
+ LockDisplay(dpy);
+ if ((dpy->request - dpy->last_request_read) >= (BUFSIZE / SIZEOF(xReq))) {
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ }
+ /* could get XID handler while waiting for reply in MT env */
+ if (dpy->synchandler == _XSeqSyncFunction) {
+ dpy->synchandler = dpy->savedsynchandler;
+ dpy->flags &= ~XlibDisplayPrivSync;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
+#ifdef XTHREADS
+static void _XFlushInt(
+ register Display *dpy,
+ register xcondition_t cv);
+#endif
+
+/*
+ * _XFlush - Flush the X request buffer. If the buffer is empty, no
+ * action is taken. This routine correctly handles incremental writes.
+ * This routine may have to be reworked if int < long.
+ */
+void _XFlush(
+ register Display *dpy)
+{
+#ifdef XTHREADS
+ /* With multi-threading we introduce an internal routine to which
+ we can pass a condition variable to do locking correctly. */
+
+ _XFlushInt(dpy, NULL);
+}
+
+/* _XFlushInt - Internal version of _XFlush used to do multi-threaded
+ * locking correctly.
+ */
+
+static void _XFlushInt(
+ register Display *dpy,
+ register xcondition_t cv)
+{
+#endif /* XTHREADS*/
+ register long size, todo;
+ register int write_stat;
+ register char *bufindex;
+ _XExtension *ext;
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ int congestion;
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XFlushInt: Entering flush with [%d] bytes to write.\n",
+ (dpy->bufptr - dpy->buffer));
+#endif
+ /* This fix resets the bufptr to the front of the buffer so
+ * additional appends to the bufptr will not corrupt memory. Since
+ * the server is down, these appends are no-op's anyway but
+ * callers of _XFlush() are not verifying this before they call it.
+ */
+ if (dpy->flags & XlibDisplayIOError)
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XFlushInt: Returning with I/O error detected.\n");
+#endif
+ dpy->bufptr = dpy->buffer;
+ dpy->last_req = (char *)&_dummy_request;
+ return;
+ }
+
+#ifdef XTHREADS
+#ifdef NX_TRANS_SOCKET
+ while (dpy->flags & XlibDisplayWriting) {
+ if (_XGetIOError(dpy)) {
+ return;
+ }
+#else
+ while (dpy->flags & XlibDisplayWriting) {
+#endif
+ if (dpy->lock) {
+ ConditionWait(dpy, dpy->lock->writers);
+ } else {
+ _XWaitForWritable (dpy, cv);
+ }
+ }
+#endif
+ size = todo = dpy->bufptr - dpy->buffer;
+ if (!size) return;
+#ifdef XTHREADS
+ dpy->flags |= XlibDisplayWriting;
+ /* make sure no one else can put in data */
+ dpy->bufptr = dpy->bufmax;
+#endif
+ for (ext = dpy->flushes; ext; ext = ext->next_flush)
+ (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, size);
+ bufindex = dpy->buffer;
+ /*
+ * While write has not written the entire buffer, keep looping
+ * until the entire buffer is written. bufindex will be
+ * incremented and size decremented as buffer is written out.
+ */
+ while (size) {
+ ESET(0);
+ write_stat = _X11TransWrite(dpy->trans_conn,
+ bufindex, (int) todo);
+ if (write_stat >= 0) {
+#ifdef NX_TRANS_SOCKET
+ if (_NXDisplayWriteFunction != NULL) {
+ (*_NXDisplayWriteFunction)(dpy, write_stat);
+ }
+#ifdef NX_TRANS_CHANGE
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+#endif
+#endif
+ size -= write_stat;
+ todo = size;
+ bufindex += write_stat;
+ } else if (ETEST()) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+#ifdef SUNSYSV
+ } else if (ECHECK(0)) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+#endif
+#ifdef ESZTEST
+ } else if (ESZTEST()) {
+ if (todo > 1)
+ todo >>= 1;
+ else {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+ }
+#endif
+#ifdef NX_TRANS_SOCKET
+ } else if (!ECHECK(EINTR) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return;
+ }
+#else
+ } else if (!ECHECK(EINTR)) {
+ /* Write failed! */
+ /* errno set by write system call. */
+ _XIOError(dpy);
+ }
+#endif
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return;
+ }
+#endif
+ }
+ dpy->last_req = (char *)&_dummy_request;
+ if ((dpy->request - dpy->last_request_read) >= SEQLIMIT &&
+ !(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->synchandler = _XSeqSyncFunction;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->bufptr = dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags &= ~XlibDisplayWriting;
+#endif
+}
+
+int
+_XEventsQueued(
+ register Display *dpy,
+ int mode)
+{
+ register int len;
+ BytesReadable_t pend;
+ _XAlignedBuffer buf;
+ register xReply *rep;
+ char *read_buf;
+#ifdef XTHREADS
+ int entry_event_serial_num;
+ struct _XCVList *cvl = NULL;
+ xthread_t self;
+
+#ifdef XTHREADS_DEBUG
+ printf("_XEventsQueued called in thread %x\n", XThread_Self());
+#endif
+#endif /* XTHREADS*/
+
+ if (mode == QueuedAfterFlush)
+ {
+ _XFlush(dpy);
+ if (dpy->qlen)
+ return(dpy->qlen);
+ }
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ if (dpy->flags & XlibDisplayIOError) {
+ fprintf(stderr, "_XEventsQueued: Returning [%d] after display failure.\n",
+ dpy->qlen);
+ }
+#endif
+ if (dpy->flags & XlibDisplayIOError) return(dpy->qlen);
+
+#ifdef XTHREADS
+ /* create our condition variable and append to list,
+ * unless we were called from within XProcessInternalConnection
+ * or XLockDisplay
+ */
+ xthread_clear_id(self);
+ if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
+ || xthread_have_id (dpy->lock->locking_thread)))
+ /* some thread is in XProcessInternalConnection or XLockDisplay
+ so we have to see if we are it */
+ self = XThread_Self();
+ if (!xthread_have_id(self)
+ || (!xthread_equal(self, dpy->lock->conni_thread)
+ && !xthread_equal(self, dpy->lock->locking_thread))) {
+ /* In the multi-threaded case, if there is someone else
+ reading events, then there aren't any available, so
+ we just return. If we waited we would block.
+ */
+ if (dpy->lock && dpy->lock->event_awaiters)
+ return dpy->qlen;
+ /* nobody here but us, so lock out any newcomers */
+ cvl = QueueEventReaderLock(dpy);
+ }
+
+ while (dpy->lock && cvl && dpy->lock->reply_first) {
+ /* note which events we have already seen so we'll know
+ if _XReply (in another thread) reads one */
+ entry_event_serial_num = dpy->next_event_serial_num;
+ ConditionWait(dpy, cvl->cv);
+ /* did _XReply read an event we can return? */
+ if (_XNewerQueuedEvent(dpy, entry_event_serial_num))
+ {
+ UnlockNextEventReader(dpy);
+ return 0;
+ }
+ }
+#endif /* XTHREADS*/
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XEventsQueued: Checking bytes readable.\n");
+#endif
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+#ifdef NX_TRANS_SOCKET
+ {
+ _XIOError(dpy);
+
+ return (dpy->qlen);
+ }
+#else
+ _XIOError(dpy);
+#endif
+#ifdef XCONN_CHECK_FREQ
+ /* This is a crock, required because FIONREAD or equivalent is
+ * not guaranteed to detect a broken connection.
+ */
+ if (!pend && !dpy->qlen && ++dpy->conn_checker >= XCONN_CHECK_FREQ)
+ {
+ int result;
+#ifdef USE_POLL
+ struct pollfd filedes;
+#else
+ fd_set r_mask;
+ static struct timeval zero_time;
+#endif
+
+ dpy->conn_checker = 0;
+#ifdef USE_POLL
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XEventsQueued: Calling poll().\n");
+#endif
+ filedes.fd = dpy->fd;
+ filedes.events = POLLIN;
+ if ((result = poll(&filedes, 1, 0)))
+#else
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XEventsQueued: Calling select().\n");
+#endif
+ FD_ZERO(&r_mask);
+ FD_SET(dpy->fd, &r_mask);
+ if ((result = Select(dpy->fd + 1, &r_mask, NULL, NULL, &zero_time)))
+#endif
+ {
+ if (result > 0)
+ {
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+#ifdef NX_TRANS_SOCKET
+ {
+ _XIOError(dpy);
+
+ return (dpy->qlen);
+ }
+#else
+ _XIOError(dpy);
+#endif
+ /* we should not get zero, if we do, force a read */
+ if (!pend)
+ pend = SIZEOF(xReply);
+ }
+#ifdef NX_TRANS_SOCKET
+ if (result <= 0) {
+ if ((result == -1 && !ECHECK(EINTR)) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return (dpy->qlen);
+ }
+ }
+#else
+ else if (result < 0 && !ECHECK(EINTR))
+ _XIOError(dpy);
+#endif
+ }
+ }
+#endif /* XCONN_CHECK_FREQ */
+ if (!(len = pend)) {
+ /* _XFlush can enqueue events */
+#ifdef XTHREADS
+ if (cvl)
+#endif
+ {
+ UnlockNextEventReader(dpy);
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XEventsQueued: Returning [%d].\n", dpy->qlen);
+#endif
+ return(dpy->qlen);
+ }
+ /* Force a read if there is not enough data. Otherwise,
+ * a select() loop at a higher-level will spin undesirably,
+ * and we've seen at least one OS that appears to not update
+ * the result from FIONREAD once it has returned nonzero.
+ */
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ read_buf = (char *)dpy->lock->reply_awaiters->buf;
+ len = SIZEOF(xReply);
+ } else
+#endif /* XTHREADS*/
+ {
+ read_buf = buf.buf;
+
+ if (len < SIZEOF(xReply)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ )
+ len = SIZEOF(xReply);
+ else if (len > BUFSIZE)
+ len = BUFSIZE;
+ len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
+ }
+#ifdef XCONN_CHECK_FREQ
+ dpy->conn_checker = 0;
+#endif
+
+ (void) _XRead (dpy, read_buf, (long) len);
+
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return(dpy->qlen);
+ }
+#endif
+#ifdef XTHREADS
+ /* what did we actually read: reply or event? */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ if (((xReply *)read_buf)->generic.type == X_Reply ||
+ ((xReply *)read_buf)->generic.type == X_Error)
+ {
+ dpy->lock->reply_was_read = True;
+ dpy->lock->reply_first = True;
+ if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
+ memcpy(dpy->lock->reply_awaiters->buf, read_buf,
+ len);
+ if (cvl) {
+ UnlockNextEventReader(dpy);
+ }
+ return(dpy->qlen); /* we read, so we can return */
+ } else if (read_buf != buf.buf)
+ memcpy(buf.buf, read_buf, len);
+ }
+#endif /* XTHREADS*/
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ int tmp = len;
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &tmp, True));
+ len = tmp;
+ pend = len;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *)rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE
+
+#ifdef XTHREADS
+ if (cvl)
+#endif
+ {
+ UnlockNextEventReader(dpy);
+ }
+ return(dpy->qlen);
+}
+
+/* _XReadEvents - Flush the output queue,
+ * then read as many events as possible (but at least 1) and enqueue them
+ */
+void _XReadEvents(
+ register Display *dpy)
+{
+ _XAlignedBuffer buf;
+ BytesReadable_t pend;
+ int len;
+ register xReply *rep;
+ Bool not_yet_flushed = True;
+ char *read_buf;
+ int i;
+ int entry_event_serial_num = dpy->next_event_serial_num;
+#ifdef XTHREADS
+ struct _XCVList *cvl = NULL;
+ xthread_t self;
+
+#ifdef XTHREADS_DEBUG
+ printf("_XReadEvents called in thread %x\n",
+ XThread_Self());
+#endif
+ /* create our condition variable and append to list,
+ * unless we were called from within XProcessInternalConnection
+ * or XLockDisplay
+ */
+ xthread_clear_id(self);
+ if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
+ || xthread_have_id (dpy->lock->locking_thread)))
+ /* some thread is in XProcessInternalConnection or XLockDisplay
+ so we have to see if we are it */
+ self = XThread_Self();
+ if (!xthread_have_id(self)
+ || (!xthread_equal(self, dpy->lock->conni_thread)
+ && !xthread_equal(self, dpy->lock->locking_thread)))
+ cvl = QueueEventReaderLock(dpy);
+#endif /* XTHREADS */
+
+ do {
+#ifdef XTHREADS
+ /* if it is not our turn to read an event off the wire,
+ wait til we're at head of list */
+ if (dpy->lock && cvl &&
+ (dpy->lock->event_awaiters != cvl ||
+ dpy->lock->reply_first)) {
+ ConditionWait(dpy, cvl->cv);
+ continue;
+ }
+#endif /* XTHREADS */
+ /* find out how much data can be read */
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+#ifdef NX_TRANS_SOCKET
+ {
+ _XIOError(dpy);
+
+ return;
+ }
+#else
+ _XIOError(dpy);
+#endif
+ len = pend;
+
+ /* must read at least one xEvent; if none is pending, then
+ we'll just flush and block waiting for it */
+ if (len < SIZEOF(xEvent)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ ) {
+ len = SIZEOF(xEvent);
+ /* don't flush until the first time we would block */
+ if (not_yet_flushed) {
+ _XFlush (dpy);
+ if (_XNewerQueuedEvent(dpy, entry_event_serial_num)) {
+ /* _XReply has read an event for us */
+ goto got_event;
+ }
+ not_yet_flushed = False;
+ }
+ }
+
+#ifdef XTHREADS
+ /* If someone is waiting for a reply, gamble that
+ the reply will be the next thing on the wire
+ and read it into their buffer. */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ read_buf = (char *)dpy->lock->reply_awaiters->buf;
+ len = SIZEOF(xReply);
+ } else
+#endif /* XTHREADS*/
+ {
+ read_buf = buf.buf;
+
+ /* but we won't read more than the max buffer size */
+ if (len > BUFSIZE)
+ len = BUFSIZE;
+
+ /* round down to an integral number of XReps */
+ len = (len / SIZEOF(xEvent)) * SIZEOF(xEvent);
+ }
+
+#ifdef XTHREADS
+ if (xthread_have_id(self))
+ /* save value we may have to stick in conni_thread */
+ dpy->lock->reading_thread = self;
+#endif /* XTHREADS */
+ dpy->flags |= XlibDisplayReadEvents;
+ i = _XRead (dpy, read_buf, (long) len);
+ dpy->flags &= ~XlibDisplayReadEvents;
+#ifdef NX_TRANS_SOCKET
+ if (dpy->flags & XlibDisplayIOError)
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XReadEvents: Returning with I/O error detected.\n");
+#endif
+ return;
+ }
+#endif
+ if (i == -2) {
+ /* special flag from _XRead to say that internal connection has
+ done XPutBackEvent. Which we can use so we're done. */
+ got_event:
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->lock_wait) {
+ if (dpy->lock->event_awaiters != cvl)
+ /* since it is not us, must be user lock thread */
+ ConditionSignal(dpy,
+ dpy->lock->event_awaiters->cv);
+ (*dpy->lock->lock_wait)(dpy);
+ continue;
+ }
+#endif
+ break;
+ }
+#ifdef XTHREADS
+ if (xthread_have_id(self))
+ xthread_clear_id(dpy->lock->reading_thread);
+
+ /* what did we actually read: reply or event? */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ if (((xReply *)read_buf)->generic.type == X_Reply ||
+ ((xReply *)read_buf)->generic.type == X_Error)
+ {
+ dpy->lock->reply_was_read = True;
+ dpy->lock->reply_first = True;
+ if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
+ memcpy(dpy->lock->reply_awaiters->buf,
+ read_buf, len);
+ ConditionSignal(dpy, dpy->lock->reply_awaiters->cv);
+ continue;
+ } else if (read_buf != buf.buf)
+ memcpy(buf.buf, read_buf, len);
+ }
+#endif /* XTHREADS */
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &len, True));
+ pend = len;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *) rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE;
+ } while (!_XNewerQueuedEvent(dpy, entry_event_serial_num));
+
+ UnlockNextEventReader(dpy);
+}
+
+/*
+ * _XRead - Read bytes from the socket taking into account incomplete
+ * reads. This routine may have to be reworked if int < long.
+ */
+int _XRead(
+ register Display *dpy,
+ register char *data,
+ register long size)
+{
+ register long bytes_read;
+#ifdef XTHREADS
+ int original_size = size;
+#endif
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ int congestion;
+#endif
+
+ if ((dpy->flags & XlibDisplayIOError) || size == 0)
+ return 0;
+ ESET(0);
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ while (1) {
+ /*
+ * Need to check the congestion state
+ * after the read so split the statement
+ * in multiple blocks.
+ */
+
+ bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size);
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+ if (bytes_read == size) {
+ break;
+ }
+#else
+ while ((bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size))
+ != size) {
+#endif
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ data += bytes_read;
+ }
+ else if (ETEST()) {
+ if (_XWaitForReadable(dpy) == -2)
+ return -2; /* internal connection did XPutBackEvent */
+ ESET(0);
+ }
+#ifdef SUNSYSV
+ else if (ECHECK(0)) {
+ if (_XWaitForReadable(dpy) == -2)
+ return -2; /* internal connection did XPutBackEvent */
+ }
+#endif
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ ESET(EPIPE);
+#ifdef NX_TRANS_SOCKET
+ _XIOError(dpy);
+
+ return -1;
+#else
+ _XIOError(dpy);
+#endif
+ }
+
+ else /* bytes_read is less than 0; presumably -1 */ {
+ /* If it's a system call interrupt, it's not an error. */
+#ifdef NX_TRANS_SOCKET
+ if (!ECHECK(EINTR) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return -1;
+ }
+#else
+ if (!ECHECK(EINTR))
+ _XIOError(dpy);
+#endif
+ }
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return -1;
+ }
+#endif
+ }
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_bytes_left > 0)
+ {
+ dpy->lock->reply_bytes_left -= original_size;
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ }
+#endif /* XTHREADS*/
+ return 0;
+}
+
+#ifdef LONG64
+void _XRead32(
+ Display *dpy,
+ register long *data,
+ long len)
+{
+ register int *buf;
+ register long i;
+
+ if (len) {
+ (void) _XRead(dpy, (char *)data, len);
+ i = len >> 2;
+ buf = (int *)data + i;
+ data += i;
+ while (--i >= 0)
+ *--data = *--buf;
+ }
+}
+#endif /* LONG64 */
+
+#ifdef WORD64
+
+/*
+ * XXX This is a *really* stupid way of doing this....
+ * PACKBUFFERSIZE must be a multiple of 4.
+ */
+
+#define PACKBUFFERSIZE 4096
+
+
+/*
+ * _XRead32 - Read bytes from the socket unpacking each 32 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static void _doXRead32(
+ register Display *dpy,
+ register long *data
+ register long size,
+ register char *packbuffer)
+{
+ long *lpack,*lp;
+ long mask32 = 0x00000000ffffffff;
+ long maskw, nwords, i, bits;
+
+ _XReadPad (dpy, packbuffer, size);
+
+ lp = data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 2;
+ bits = 32;
+
+ for(i=0;i<nwords;i++){
+ maskw = mask32 << bits;
+ *lp++ = ( *lpack & maskw ) >> bits;
+ bits = bits ^32;
+ if(bits){
+ lpack++;
+ }
+ }
+}
+
+void _XRead32(
+ Display *dpy,
+ long *data,
+ long len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 2;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ _doXRead32 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) _doXRead32 (dpy, data, len, packbuffer);
+}
+
+
+
+/*
+ * _XRead16 - Read bytes from the socket unpacking each 16 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static _doXRead16(
+ register Display *dpy,
+ register short *data,
+ register long size,
+ char *packbuffer)
+{
+ long *lpack,*lp;
+ long mask16 = 0x000000000000ffff;
+ long maskw, nwords, i, bits;
+
+ (void) _XRead(dpy,packbuffer,size); /* don't do a padded read... */
+
+ lp = (long *) data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 1; /* number of 16 bit words to be unpacked */
+ bits = 48;
+ for(i=0;i<nwords;i++){
+ maskw = mask16 << bits;
+ *lp++ = ( *lpack & maskw ) >> bits;
+ bits -= 16;
+ if(bits < 0){
+ lpack++;
+ bits = 48;
+ }
+ }
+}
+
+void _XRead16(
+ Display *dpy,
+ short *data,
+ long len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 1;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ _doXRead16 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) _doXRead16 (dpy, data, len, packbuffer);
+}
+
+void _XRead16Pad(
+ Display *dpy,
+ short *data,
+ long size)
+{
+ int slop = (size & 3);
+ short slopbuf[3];
+
+ _XRead16 (dpy, data, size);
+ if (slop > 0) {
+ _XRead16 (dpy, slopbuf, 4 - slop);
+ }
+}
+#endif /* WORD64 */
+
+
+/*
+ * _XReadPad - Read bytes from the socket taking into account incomplete
+ * reads. If the number of bytes is not 0 mod 4, read additional pad
+ * bytes. This routine may have to be reworked if int < long.
+ */
+void _XReadPad(
+ register Display *dpy,
+ register char *data,
+ register long size)
+{
+ register long bytes_read;
+ struct iovec iov[2];
+ char pad[3];
+#ifdef XTHREADS
+ int original_size;
+#endif
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ int congestion;
+#endif
+
+ if ((dpy->flags & XlibDisplayIOError) || size == 0) return;
+ iov[0].iov_len = (int)size;
+ iov[0].iov_base = data;
+ /*
+ * The following hack is used to provide 32 bit long-word
+ * aligned padding. The [1] vector is of length 0, 1, 2, or 3,
+ * whatever is needed.
+ */
+
+ iov[1].iov_len = -size & 3;
+ iov[1].iov_base = pad;
+ size += iov[1].iov_len;
+#ifdef XTHREADS
+ original_size = size;
+#endif
+ ESET(0);
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ while (1) {
+ bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2);
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+ if (bytes_read == size) {
+ break;
+ }
+#else
+ while ((bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2)) != size) {
+#endif
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ if (iov[0].iov_len < bytes_read) {
+ int pad_bytes_read = bytes_read - iov[0].iov_len;
+ iov[1].iov_len -= pad_bytes_read;
+ iov[1].iov_base =
+ (char *)iov[1].iov_base + pad_bytes_read;
+ iov[0].iov_len = 0;
+ }
+ else {
+ iov[0].iov_len -= bytes_read;
+ iov[0].iov_base = (char *)iov[0].iov_base + bytes_read;
+ }
+ }
+ else if (ETEST()) {
+ _XWaitForReadable(dpy);
+ ESET(0);
+ }
+#ifdef SUNSYSV
+ else if (ECHECK(0)) {
+ _XWaitForReadable(dpy);
+ }
+#endif
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ ESET(EPIPE);
+#ifdef NX_TRANS_SOCKET
+ _XIOError(dpy);
+
+ return;
+#else
+ _XIOError(dpy);
+#endif
+ }
+
+ else /* bytes_read is less than 0; presumably -1 */ {
+ /* If it's a system call interrupt, it's not an error. */
+#ifdef NX_TRANS_SOCKET
+ if (!ECHECK(EINTR) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return;
+ }
+#else
+ if (!ECHECK(EINTR))
+ _XIOError(dpy);
+#endif
+ }
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return;
+ }
+#endif
+ }
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_bytes_left > 0)
+ {
+ dpy->lock->reply_bytes_left -= original_size;
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ }
+#endif /* XTHREADS*/
+}
+
+/*
+ * _XSend - Flush the buffer and send the client data. 32 bit word aligned
+ * transmission is used, if size is not 0 mod 4, extra bytes are transmitted.
+ * This routine may have to be reworked if int < long;
+ */
+void
+_XSend (
+ register Display *dpy,
+ _Xconst char *data,
+ register long size)
+{
+ struct iovec iov[3];
+ static char const pad[3] = {0, 0, 0};
+ /* XText8 and XText16 require that the padding bytes be zero! */
+
+ long skip, dbufsize, padsize, total, todo;
+ _XExtension *ext;
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE)
+ int congestion;
+#endif
+
+#ifdef NX_TRANS_SOCKET
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XSend: Sending data with [%d] bytes to write.\n",
+ (dpy->bufptr - dpy->buffer));
+#endif
+ if (!size || (dpy->flags & XlibDisplayIOError))
+ {
+ if (dpy->flags & XlibDisplayIOError)
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XSend: Returning with I/O error detected.\n");
+#endif
+ dpy->bufptr = dpy->buffer;
+ dpy->last_req = (char *)&_dummy_request;
+ }
+
+ return;
+ }
+#else
+ if (!size || (dpy->flags & XlibDisplayIOError)) return;
+#endif
+ dbufsize = dpy->bufptr - dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags |= XlibDisplayWriting;
+ /* make sure no one else can put in data */
+ dpy->bufptr = dpy->bufmax;
+#endif
+ padsize = -size & 3;
+ for (ext = dpy->flushes; ext; ext = ext->next_flush) {
+ (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, dbufsize);
+ (*ext->before_flush)(dpy, &ext->codes, (char *)data, size);
+ if (padsize)
+ (*ext->before_flush)(dpy, &ext->codes, pad, padsize);
+ }
+ skip = 0;
+ todo = total = dbufsize + size + padsize;
+
+ /*
+ * There are 3 pieces that may need to be written out:
+ *
+ * o whatever is in the display buffer
+ * o the data passed in by the user
+ * o any padding needed to 32bit align the whole mess
+ *
+ * This loop looks at all 3 pieces each time through. It uses skip
+ * to figure out whether or not a given piece is needed.
+ */
+ while (total) {
+ long before = skip; /* amount of whole thing written */
+ long remain = todo; /* amount to try this time, <= total */
+ int i = 0;
+ long len;
+
+ /* You could be very general here and have "in" and "out" iovecs
+ * and write a loop without using a macro, but what the heck. This
+ * translates to:
+ *
+ * how much of this piece is new?
+ * if more new then we are trying this time, clamp
+ * if nothing new
+ * then bump down amount already written, for next piece
+ * else put new stuff in iovec, will need all of next piece
+ *
+ * Note that todo had better be at least 1 or else we'll end up
+ * writing 0 iovecs.
+ */
+#define InsertIOV(pointer, length) \
+ len = (length) - before; \
+ if (len > remain) \
+ len = remain; \
+ if (len <= 0) { \
+ before = (-len); \
+ } else { \
+ iov[i].iov_len = len; \
+ iov[i].iov_base = (pointer) + before; \
+ i++; \
+ remain -= len; \
+ before = 0; \
+ }
+
+ InsertIOV (dpy->buffer, dbufsize)
+ InsertIOV ((char *)data, size)
+ InsertIOV ((char *)pad, padsize)
+
+ ESET(0);
+ if ((len = _X11TransWritev(dpy->trans_conn, iov, i)) >= 0) {
+#ifdef NX_TRANS_SOCKET
+ if (_NXDisplayWriteFunction != NULL) {
+ (*_NXDisplayWriteFunction)(dpy, len);
+ }
+#ifdef NX_TRANS_CHANGE
+ if (_NXDisplayCongestionFunction != NULL &&
+ _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) {
+ (*_NXDisplayCongestionFunction)(dpy, congestion);
+ }
+#endif
+#endif
+ skip += len;
+ total -= len;
+ todo = total;
+ } else if (ETEST()) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+#ifdef SUNSYSV
+ } else if (ECHECK(0)) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+#endif
+#ifdef ESZTEST
+ } else if (ESZTEST()) {
+ if (todo > 1)
+ todo >>= 1;
+ else {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+ }
+#endif
+#ifdef NX_TRANS_SOCKET
+ } else if (!ECHECK(EINTR) ||
+ (_NXDisplayErrorFunction != NULL &&
+ (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) {
+ _XIOError(dpy);
+ return;
+ }
+#else
+ } else if (!ECHECK(EINTR)) {
+ _XIOError(dpy);
+ }
+#endif
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ return;
+ }
+#endif
+ }
+ dpy->last_req = (char *) & _dummy_request;
+ if ((dpy->request - dpy->last_request_read) >= SEQLIMIT &&
+ !(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->synchandler = _XSeqSyncFunction;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->bufptr = dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags &= ~XlibDisplayWriting;
+#endif
+ return;
+}
+
+static void
+_XGetMiscCode(
+ register Display *dpy)
+{
+ xQueryExtensionReply qrep;
+ register xQueryExtensionReq *qreq;
+ xXCMiscGetVersionReply vrep;
+ register xXCMiscGetVersionReq *vreq;
+
+ if (dpy->xcmisc_opcode)
+ return;
+ GetReq(QueryExtension, qreq);
+ qreq->nbytes = sizeof(XCMiscExtensionName) - 1;
+ qreq->length += (qreq->nbytes+(unsigned)3)>>2;
+ _XSend(dpy, XCMiscExtensionName, (long)qreq->nbytes);
+ if (!_XReply (dpy, (xReply *)&qrep, 0, xTrue))
+ dpy->xcmisc_opcode = -1;
+ else {
+ GetReq(XCMiscGetVersion, vreq);
+ vreq->reqType = qrep.major_opcode;
+ vreq->miscReqType = X_XCMiscGetVersion;
+ vreq->majorVersion = XCMiscMajorVersion;
+ vreq->minorVersion = XCMiscMinorVersion;
+ if (!_XReply (dpy, (xReply *)&vrep, 0, xTrue))
+ dpy->xcmisc_opcode = -1;
+ else
+ dpy->xcmisc_opcode = qrep.major_opcode;
+ }
+}
+
+static int
+_XIDHandler(
+ register Display *dpy)
+{
+ xXCMiscGetXIDRangeReply grep;
+ register xXCMiscGetXIDRangeReq *greq;
+
+ LockDisplay(dpy);
+ _XGetMiscCode(dpy);
+ if (dpy->xcmisc_opcode > 0) {
+ GetReq(XCMiscGetXIDRange, greq);
+ greq->reqType = dpy->xcmisc_opcode;
+ greq->miscReqType = X_XCMiscGetXIDRange;
+ if (_XReply (dpy, (xReply *)&grep, 0, xTrue) && grep.count) {
+ dpy->resource_id = ((grep.start_id - dpy->resource_base) >>
+ dpy->resource_shift);
+ dpy->resource_max = dpy->resource_id;
+ if (grep.count > 5)
+ dpy->resource_max += grep.count - 6;
+ dpy->resource_max <<= dpy->resource_shift;
+ }
+ }
+ if (dpy->flags & XlibDisplayPrivSync) {
+ dpy->synchandler = dpy->savedsynchandler;
+ dpy->flags &= ~XlibDisplayPrivSync;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
+/*
+ * _XAllocID - resource ID allocation routine.
+ */
+XID _XAllocID(
+ register Display *dpy)
+{
+ XID id;
+
+ id = dpy->resource_id << dpy->resource_shift;
+ if (id >= dpy->resource_max) {
+ if (!(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->synchandler = _XIDHandler;
+ dpy->resource_max = dpy->resource_mask + 1;
+ }
+ if (id <= dpy->resource_mask) {
+ dpy->resource_id++;
+ return (dpy->resource_base + id);
+ }
+ if (id != 0x10000000) {
+ (void) fprintf(stderr,
+ "Xlib: resource ID allocation space exhausted!\n");
+ id = 0x10000000;
+ dpy->resource_id = id >> dpy->resource_shift;
+ }
+ return id;
+}
+
+/*
+ * _XAllocIDs - multiple resource ID allocation routine.
+ */
+void _XAllocIDs(
+ register Display *dpy,
+ XID *ids,
+ int count)
+{
+ XID id;
+ int i;
+ xXCMiscGetXIDListReply grep;
+ register xXCMiscGetXIDListReq *greq;
+
+ id = dpy->resource_id << dpy->resource_shift;
+ if (dpy->resource_max <= dpy->resource_mask &&
+ id <= dpy->resource_mask &&
+ (dpy->resource_max - id) > ((count - 1) << dpy->resource_shift)) {
+ id += dpy->resource_base;
+ for (i = 0; i < count; i++) {
+ ids[i] = id;
+ id += (1 << dpy->resource_shift);
+ dpy->resource_id++;
+ }
+ return;
+ }
+ grep.count = 0;
+ _XGetMiscCode(dpy);
+ if (dpy->xcmisc_opcode > 0) {
+ GetReq(XCMiscGetXIDList, greq);
+ greq->reqType = dpy->xcmisc_opcode;
+ greq->miscReqType = X_XCMiscGetXIDList;
+ greq->count = count;
+ if (_XReply(dpy, (xReply *)&grep, 0, xFalse) && grep.count) {
+ _XRead32(dpy, (long *) ids, 4L * (long) (grep.count));
+ for (i = 0; i < grep.count; i++) {
+ id = (ids[i] - dpy->resource_base) >> dpy->resource_shift;
+ if (id >= dpy->resource_id)
+ dpy->resource_id = id;
+ }
+ if (id >= dpy->resource_max) {
+ if (!(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->synchandler = _XIDHandler;
+ dpy->resource_max = dpy->resource_mask + 1;
+ }
+ }
+ }
+ for (i = grep.count; i < count; i++)
+ ids[i] = XAllocID(dpy);
+}
+
+/*
+ * The hard part about this is that we only get 16 bits from a reply.
+ * We have three values that will march along, with the following invariant:
+ * dpy->last_request_read <= rep->sequenceNumber <= dpy->request
+ * We have to keep
+ * dpy->request - dpy->last_request_read < 2^16
+ * or else we won't know for sure what value to use in events. We do this
+ * by forcing syncs when we get close.
+ */
+
+unsigned long
+_XSetLastRequestRead(
+ register Display *dpy,
+ register xGenericReply *rep)
+{
+ register unsigned long newseq, lastseq;
+
+ lastseq = dpy->last_request_read;
+ /*
+ * KeymapNotify has no sequence number, but is always guaranteed
+ * to immediately follow another event, except when generated via
+ * SendEvent (hmmm).
+ */
+ if ((rep->type & 0x7f) == KeymapNotify)
+ return(lastseq);
+
+ newseq = (lastseq & ~((unsigned long)0xffff)) | rep->sequenceNumber;
+
+ if (newseq < lastseq) {
+ newseq += 0x10000;
+ if (newseq > dpy->request) {
+
+#ifdef NX_TRANS_SOCKET
+
+ if (_NXLostSequenceFunction != NULL)
+ {
+ (*_NXLostSequenceFunction)(dpy, newseq, dpy->request,
+ (unsigned int) rep->type);
+ }
+ else
+ {
+ (void) fprintf (stderr,
+ "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
+ newseq, dpy->request,
+ (unsigned int) rep->type);
+ }
+
+#else /* #ifdef NX_TRANS_SOCKET */
+
+ (void) fprintf (stderr,
+ "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
+ newseq, dpy->request,
+ (unsigned int) rep->type);
+
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+ newseq -= 0x10000;
+ }
+ }
+
+ dpy->last_request_read = newseq;
+ return(newseq);
+}
+
+/*
+ * _XReply - Wait for a reply packet and copy its contents into the
+ * specified rep. Meanwhile we must handle error and event packets that
+ * we may encounter.
+ */
+Status
+_XReply (
+ register Display *dpy,
+ register xReply *rep,
+ int extra, /* number of 32-bit words expected after the reply */
+ Bool discard) /* should I discard data following "extra" words? */
+{
+ /* Pull out the serial number now, so that (currently illegal) requests
+ * generated by an error handler don't confuse us.
+ */
+ unsigned long cur_request = dpy->request;
+#ifdef XTHREADS
+ struct _XCVList *cvl;
+#endif
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XReply: Going to wait for an X reply.\n");
+#endif
+
+#ifdef NX_TRANS_SOCKET
+ if (dpy->flags & XlibDisplayIOError)
+ {
+#ifdef NX_TRANS_DEBUG
+ fprintf(stderr, "_XReply: Returning 0 with I/O error detected.\n");
+#endif
+ return 0;
+ }
+#else
+ if (dpy->flags & XlibDisplayIOError)
+ return 0;
+#endif
+
+#ifdef XTHREADS
+ /* create our condition variable and append to list */
+ cvl = QueueReplyReaderLock(dpy);
+ if (cvl) {
+ cvl->buf = rep;
+ if (dpy->lock->reply_awaiters == cvl && !dpy->lock->event_awaiters)
+ dpy->lock->reply_first = True;
+ }
+
+#ifdef XTHREADS_DEBUG
+ printf("_XReply called in thread %x, adding %x to cvl\n",
+ XThread_Self(), cvl);
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XReply: Going to flush the display buffer.\n");
+#endif
+ _XFlushInt(dpy, cvl ? cvl->cv : NULL);
+ /* if it is not our turn to read a reply off the wire,
+ * wait til we're at head of list. if there is an event waiter,
+ * and our reply hasn't been read, they'll be in select and will
+ * hand control back to us next.
+ */
+ if(dpy->lock &&
+ (dpy->lock->reply_awaiters != cvl || !dpy->lock->reply_first)) {
+ ConditionWait(dpy, cvl->cv);
+ }
+ dpy->flags |= XlibDisplayReply;
+#else /* XTHREADS else */
+ _XFlush(dpy);
+#endif
+
+#ifdef NX_TRANS_SOCKET
+ /*
+ * We are going to block waiting for the remote
+ * X server. Be sure that the proxy has flushed
+ * all the data.
+ */
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XReply: Requesting a flush of the NX transport.\n");
+#endif
+
+ NXTransFlush(dpy->fd);
+#endif
+
+ for (;;) {
+#ifdef XTHREADS
+ /* Did another thread's _XReadEvents get our reply by accident? */
+ if (!dpy->lock || !dpy->lock->reply_was_read)
+#endif
+ (void) _XRead(dpy, (char *)rep, (long)SIZEOF(xReply));
+#ifdef XTHREADS
+ if (dpy->lock)
+ dpy->lock->reply_was_read = False;
+#endif
+
+ switch ((int)rep->generic.type) {
+
+ case X_Reply:
+ /* Reply received. Fast update for synchronous replies,
+ * but deal with multiple outstanding replies.
+ */
+ if (rep->generic.sequenceNumber == (cur_request & 0xffff))
+ dpy->last_request_read = cur_request;
+ else {
+ int pend = SIZEOF(xReply);
+ if (_XAsyncReply(dpy, rep, (char *)rep, &pend, False)
+ != (char *)rep)
+ continue;
+ }
+ if (extra <= rep->generic.length) {
+ if (extra > 0)
+ /*
+ * Read the extra data into storage immediately
+ * following the GenericReply structure.
+ */
+ (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
+ ((long)extra) << 2);
+ if (discard) {
+ if (extra < rep->generic.length)
+ _XEatData(dpy, (rep->generic.length - extra) << 2);
+ }
+#ifdef XTHREADS
+ if (dpy->lock) {
+ if (discard) {
+ dpy->lock->reply_bytes_left = 0;
+ } else {
+ dpy->lock->reply_bytes_left =
+ (rep->generic.length - extra) << 2;
+ }
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ } else
+ dpy->flags &= ~XlibDisplayReply;
+#endif
+ return 1;
+ }
+ /*
+ *if we get here, then extra > rep->generic.length--meaning we
+ * read a reply that's shorter than we expected. This is an
+ * error, but we still need to figure out how to handle it...
+ */
+ (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
+ ((long) rep->generic.length) << 2);
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+#ifdef NX_TRANS_SOCKET
+ /*
+ * The original code has provision
+ * for returning already.
+ */
+#endif
+ _XIOError (dpy);
+ return (0);
+
+ case X_Error:
+ {
+ register _XExtension *ext;
+ register Bool ret = False;
+ int ret_code;
+ xError *err = (xError *) rep;
+ unsigned long serial;
+
+ dpy->flags &= ~XlibDisplayReply;
+ serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
+ if (serial == cur_request)
+ /* do not die on "no such font", "can't allocate",
+ "can't grab" failures */
+ switch ((int)err->errorCode) {
+ case BadName:
+ switch (err->majorCode) {
+ case X_LookupColor:
+ case X_AllocNamedColor:
+ UnlockNextReplyReader(dpy);
+ return(0);
+ }
+ break;
+ case BadFont:
+ if (err->majorCode == X_QueryFont) {
+ UnlockNextReplyReader(dpy);
+ return (0);
+ }
+ break;
+ case BadAlloc:
+ case BadAccess:
+ UnlockNextReplyReader(dpy);
+ return (0);
+ }
+ /*
+ * we better see if there is an extension who may
+ * want to suppress the error.
+ */
+ for (ext = dpy->ext_procs; !ret && ext; ext = ext->next) {
+ if (ext->error)
+ ret = (*ext->error)(dpy, err, &ext->codes, &ret_code);
+ }
+ if (!ret) {
+ _XError(dpy, err);
+ ret_code = 0;
+ }
+ if (serial == cur_request) {
+ UnlockNextReplyReader(dpy);
+ return(ret_code);
+ }
+
+ } /* case X_Error */
+ break;
+ default:
+ _XEnq(dpy, (xEvent *) rep);
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->event_awaiters)
+ ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
+#endif
+ break;
+ }
+#ifdef NX_TRANS_SOCKET
+ if (_XGetIOError(dpy)) {
+ UnlockNextReplyReader(dpy);
+ return 0;
+ }
+#endif
+ }
+}
+
+static char *
+_XAsyncReply(
+ Display *dpy,
+ register xReply *rep,
+ char *buf,
+ register int *lenp,
+ Bool discard)
+{
+ register _XAsyncHandler *async, *next;
+ register int len;
+ register Bool consumed = False;
+ char *nbuf;
+
+ (void) _XSetLastRequestRead(dpy, &rep->generic);
+ len = SIZEOF(xReply) + (rep->generic.length << 2);
+ if (len < SIZEOF(xReply)) {
+#ifdef NX_TRANS_SOCKET
+
+ /*
+ * The original code has provision
+ * for returning already.
+ */
+
+#endif
+ _XIOError (dpy);
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+
+ for (async = dpy->async_handlers; async; async = next) {
+ next = async->next;
+ if ((consumed = (*async->handler)(dpy, rep, buf, *lenp, async->data)))
+ break;
+ }
+ if (!consumed) {
+ if (!discard)
+ return buf;
+ (void) fprintf(stderr,
+ "Xlib: unexpected async reply (sequence 0x%lx)!\n",
+ dpy->last_request_read);
+#ifdef XTHREADS
+#ifdef XTHREADS_DEBUG
+ printf("thread %x, unexpected async reply\n", XThread_Self());
+#endif
+#endif
+ if (len > *lenp)
+ _XEatData(dpy, len - *lenp);
+ }
+ if (len < SIZEOF(xReply))
+ {
+#ifdef NX_TRANS_SOCKET
+
+ /*
+ * The original code has provision
+ * for returning already.
+ */
+
+#endif
+ _XIOError (dpy);
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+ if (len >= *lenp) {
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+ *lenp -= len;
+ buf += len;
+ len = *lenp;
+ nbuf = buf;
+ while (len > SIZEOF(xReply)) {
+ if (*buf == X_Reply)
+ return nbuf;
+ buf += SIZEOF(xReply);
+ len -= SIZEOF(xReply);
+ }
+ if (len > 0 && len < SIZEOF(xReply)) {
+ buf = nbuf;
+ len = SIZEOF(xReply) - len;
+ nbuf -= len;
+ memmove(nbuf, buf, *lenp);
+ (void) _XRead(dpy, nbuf + *lenp, (long)len);
+ *lenp += len;
+ }
+ return nbuf;
+}
+
+/*
+ * Support for internal connections, such as an IM might use.
+ * By Stephen Gildea, X Consortium, September 1993
+ */
+
+/* _XRegisterInternalConnection
+ * Each IM (or Xlib extension) that opens a file descriptor that Xlib should
+ * include in its select/poll mask must call this function to register the
+ * fd with Xlib. Any XConnectionWatchProc registered by XAddConnectionWatch
+ * will also be called.
+ *
+ * Whenever Xlib detects input available on fd, it will call callback
+ * with call_data to process it. If non-Xlib code calls select/poll
+ * and detects input available, it must call XProcessInternalConnection,
+ * which will call the associated callback.
+ *
+ * Non-Xlib code can learn about these additional fds by calling
+ * XInternalConnectionNumbers or, more typically, by registering
+ * a XConnectionWatchProc with XAddConnectionWatch
+ * to be called when fds are registered or unregistered.
+ *
+ * Returns True if registration succeeded, False if not, typically
+ * because could not allocate memory.
+ * Assumes Display locked when called.
+ */
+Status
+_XRegisterInternalConnection(
+ Display* dpy,
+ int fd,
+ _XInternalConnectionProc callback,
+ XPointer call_data
+)
+{
+ struct _XConnectionInfo *new_conni, **iptr;
+ struct _XConnWatchInfo *watchers;
+ XPointer *wd;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XRegisterInternalConnection: Got called.\n");
+#endif
+
+ new_conni = (struct _XConnectionInfo*)Xmalloc(sizeof(struct _XConnectionInfo));
+ if (!new_conni)
+ return 0;
+ new_conni->watch_data = (XPointer *)Xmalloc(dpy->watcher_count * sizeof(XPointer));
+ if (!new_conni->watch_data) {
+ Xfree(new_conni);
+ return 0;
+ }
+ new_conni->fd = fd;
+ new_conni->read_callback = callback;
+ new_conni->call_data = call_data;
+ new_conni->next = NULL;
+ /* link new structure onto end of list */
+ for (iptr = &dpy->im_fd_info; *iptr; iptr = &(*iptr)->next)
+ ;
+ *iptr = new_conni;
+ dpy->im_fd_length++;
+ _XPollfdCacheAdd(dpy, fd);
+
+ for (watchers=dpy->conn_watchers, wd=new_conni->watch_data;
+ watchers;
+ watchers=watchers->next, wd++) {
+ *wd = NULL; /* for cleanliness */
+ (*watchers->fn) (dpy, watchers->client_data, fd, True, wd);
+ }
+
+ return 1;
+}
+
+/* _XUnregisterInternalConnection
+ * Each IM (or Xlib extension) that closes a file descriptor previously
+ * registered with _XRegisterInternalConnection must call this function.
+ * Any XConnectionWatchProc registered by XAddConnectionWatch
+ * will also be called.
+ *
+ * Assumes Display locked when called.
+ */
+void
+_XUnregisterInternalConnection(
+ Display* dpy,
+ int fd
+)
+{
+ struct _XConnectionInfo *info_list, **prev;
+ struct _XConnWatchInfo *watch;
+ XPointer *wd;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XUnregisterInternalConnection: Got called.\n");
+#endif
+
+ for (prev = &dpy->im_fd_info; (info_list = *prev);
+ prev = &info_list->next) {
+ if (info_list->fd == fd) {
+ *prev = info_list->next;
+ dpy->im_fd_length--;
+ for (watch=dpy->conn_watchers, wd=info_list->watch_data;
+ watch;
+ watch=watch->next, wd++) {
+ (*watch->fn) (dpy, watch->client_data, fd, False, wd);
+ }
+ if (info_list->watch_data)
+ Xfree (info_list->watch_data);
+ Xfree (info_list);
+ break;
+ }
+ }
+ _XPollfdCacheDel(dpy, fd);
+}
+
+/* XInternalConnectionNumbers
+ * Returns an array of fds and an array of corresponding call data.
+ * Typically a XConnectionWatchProc registered with XAddConnectionWatch
+ * will be used instead of this function to discover
+ * additional fds to include in the select/poll mask.
+ *
+ * The list is allocated with Xmalloc and should be freed by the caller
+ * with Xfree;
+ */
+Status
+XInternalConnectionNumbers(
+ Display *dpy,
+ int **fd_return,
+ int *count_return
+)
+{
+ int count;
+ struct _XConnectionInfo *info_list;
+ int *fd_list;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "XInternalConnectionNumbers: Got called.\n");
+#endif
+
+ LockDisplay(dpy);
+ count = 0;
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next)
+ count++;
+ fd_list = (int*) Xmalloc (count * sizeof(int));
+ if (!fd_list) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ count = 0;
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ fd_list[count] = info_list->fd;
+ count++;
+ }
+ UnlockDisplay(dpy);
+
+ *fd_return = fd_list;
+ *count_return = count;
+ return 1;
+}
+
+static void _XProcessInternalConnection(
+ Display *dpy,
+ struct _XConnectionInfo *conn_info)
+{
+ dpy->flags |= XlibDisplayProcConni;
+#ifdef XTHREADS
+ if (dpy->lock) {
+ /* check cache to avoid call to thread_self */
+ if (xthread_have_id(dpy->lock->reading_thread))
+ dpy->lock->conni_thread = dpy->lock->reading_thread;
+ else
+ dpy->lock->conni_thread = XThread_Self();
+ }
+#endif /* XTHREADS */
+ UnlockDisplay(dpy);
+ (*conn_info->read_callback) (dpy, conn_info->fd, conn_info->call_data);
+ LockDisplay(dpy);
+#ifdef XTHREADS
+ if (dpy->lock)
+ xthread_clear_id(dpy->lock->conni_thread);
+#endif /* XTHREADS */
+ dpy->flags &= ~XlibDisplayProcConni;
+}
+
+/* XProcessInternalConnection
+ * Call the _XInternalConnectionProc registered by _XRegisterInternalConnection
+ * for this fd.
+ * The Display is NOT locked during the call.
+ */
+void
+XProcessInternalConnection(
+ Display* dpy,
+ int fd
+)
+{
+ struct _XConnectionInfo *info_list;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "XProcessInternalConnection: Got called.\n");
+#endif
+
+ LockDisplay(dpy);
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ if (info_list->fd == fd) {
+ _XProcessInternalConnection(dpy, info_list);
+ break;
+ }
+ }
+ UnlockDisplay(dpy);
+}
+
+/* XAddConnectionWatch
+ * Register a callback to be called whenever _XRegisterInternalConnection
+ * or _XUnregisterInternalConnection is called.
+ * Callbacks are called with the Display locked.
+ * If any connections are already registered, the callback is immediately
+ * called for each of them.
+ */
+Status
+XAddConnectionWatch(
+ Display* dpy,
+ XConnectionWatchProc callback,
+ XPointer client_data
+)
+{
+ struct _XConnWatchInfo *new_watcher, **wptr;
+ struct _XConnectionInfo *info_list;
+ XPointer *wd_array;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "XAddConnectionWatch: Got called.\n");
+#endif
+
+ LockDisplay(dpy);
+
+ /* allocate new watch data */
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ wd_array = (XPointer *)Xrealloc((char *)info_list->watch_data,
+ (dpy->watcher_count + 1) *
+ sizeof(XPointer));
+ if (!wd_array) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ wd_array[dpy->watcher_count] = NULL; /* for cleanliness */
+ }
+
+ new_watcher = (struct _XConnWatchInfo*)Xmalloc(sizeof(struct _XConnWatchInfo));
+ if (!new_watcher) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ new_watcher->fn = callback;
+ new_watcher->client_data = client_data;
+ new_watcher->next = NULL;
+
+ /* link new structure onto end of list */
+ for (wptr = &dpy->conn_watchers; *wptr; wptr = &(*wptr)->next)
+ ;
+ *wptr = new_watcher;
+ dpy->watcher_count++;
+
+ /* call new watcher on all currently registered fds */
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ (*callback) (dpy, client_data, info_list->fd, True,
+ info_list->watch_data + dpy->watcher_count - 1);
+ }
+
+ UnlockDisplay(dpy);
+ return 1;
+}
+
+/* XRemoveConnectionWatch
+ * Unregister a callback registered by XAddConnectionWatch.
+ * Both callback and client_data must match what was passed to
+ * XAddConnectionWatch.
+ */
+void
+XRemoveConnectionWatch(
+ Display* dpy,
+ XConnectionWatchProc callback,
+ XPointer client_data
+)
+{
+ struct _XConnWatchInfo *watch;
+ struct _XConnWatchInfo *previous = NULL;
+ struct _XConnectionInfo *conni;
+ int counter = 0;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "XRemoveConnectionWatch: Got called.\n");
+#endif
+
+ LockDisplay(dpy);
+ for (watch=dpy->conn_watchers; watch; watch=watch->next) {
+ if (watch->fn == callback && watch->client_data == client_data) {
+ if (previous)
+ previous->next = watch->next;
+ else
+ dpy->conn_watchers = watch->next;
+ Xfree (watch);
+ dpy->watcher_count--;
+ /* remove our watch_data for each connection */
+ for (conni=dpy->im_fd_info; conni; conni=conni->next) {
+ /* don't bother realloc'ing; these arrays are small anyway */
+ /* overlapping */
+ memmove(conni->watch_data+counter,
+ conni->watch_data+counter+1,
+ dpy->watcher_count - counter);
+ }
+ break;
+ }
+ previous = watch;
+ counter++;
+ }
+ UnlockDisplay(dpy);
+}
+
+/* end of internal connections support */
+
+
+/* Read and discard "n" 8-bit bytes of data */
+
+void _XEatData(
+ Display *dpy,
+ register unsigned long n)
+{
+#define SCRATCHSIZE 2048
+ char buf[SCRATCHSIZE];
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "_XEatData: Going to eat [%ld] bytes of data from descriptor [%d].\n",
+ n, dpy->fd);
+#endif
+ while (n > 0) {
+ register long bytes_read = (n > SCRATCHSIZE) ? SCRATCHSIZE : n;
+ (void) _XRead (dpy, buf, bytes_read);
+ n -= bytes_read;
+ }
+#undef SCRATCHSIZE
+}
+
+
+/*
+ * _XEnq - Place event packets on the display's queue.
+ * note that no squishing of move events in V11, since there
+ * is pointer motion hints....
+ */
+void _XEnq(
+ register Display *dpy,
+ register xEvent *event)
+{
+ register _XQEvent *qelt;
+
+ if ((qelt = dpy->qfree)) {
+ /* If dpy->qfree is non-NULL do this, else malloc a new one. */
+ dpy->qfree = qelt->next;
+ }
+ else if ((qelt =
+ (_XQEvent *) Xmalloc((unsigned)sizeof(_XQEvent))) == NULL) {
+ /* Malloc call failed! */
+ ESET(ENOMEM);
+#ifdef NX_TRANS_SOCKET
+ _XIOError(dpy);
+
+ return;
+#else
+ _XIOError(dpy);
+#endif
+ }
+ qelt->next = NULL;
+ /* go call through display to find proper event reformatter */
+ if ((*dpy->event_vec[event->u.u.type & 0177])(dpy, &qelt->event, event)) {
+ qelt->qserial_num = dpy->next_event_serial_num++;
+ if (dpy->tail) dpy->tail->next = qelt;
+ else dpy->head = qelt;
+
+ dpy->tail = qelt;
+ dpy->qlen++;
+ } else {
+ /* ignored, or stashed away for many-to-one compression */
+ qelt->next = dpy->qfree;
+ dpy->qfree = qelt;
+ }
+}
+
+/*
+ * _XDeq - Remove event packet from the display's queue.
+ */
+void _XDeq(
+ register Display *dpy,
+ register _XQEvent *prev, /* element before qelt */
+ register _XQEvent *qelt) /* element to be unlinked */
+{
+ if (prev) {
+ if ((prev->next = qelt->next) == NULL)
+ dpy->tail = prev;
+ } else {
+ /* no prev, so removing first elt */
+ if ((dpy->head = qelt->next) == NULL)
+ dpy->tail = NULL;
+ }
+ qelt->qserial_num = 0;
+ qelt->next = dpy->qfree;
+ dpy->qfree = qelt;
+ dpy->qlen--;
+}
+
+/*
+ * EventToWire in separate file in that often not needed.
+ */
+
+/*ARGSUSED*/
+Bool
+_XUnknownWireEvent(
+ register Display *dpy, /* pointer to display structure */
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event) /* wire protocol event */
+{
+#ifdef notdef
+ (void) fprintf(stderr,
+ "Xlib: unhandled wire event! event number = %d, display = %x\n.",
+ event->u.u.type, dpy);
+#endif
+ return(False);
+}
+
+/*ARGSUSED*/
+Status
+_XUnknownNativeEvent(
+ register Display *dpy, /* pointer to display structure */
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event) /* wire protocol event */
+{
+#ifdef notdef
+ (void) fprintf(stderr,
+ "Xlib: unhandled native event! event number = %d, display = %x\n.",
+ re->type, dpy);
+#endif
+ return(0);
+}
+/*
+ * reformat a wire event into an XEvent structure of the right type.
+ */
+Bool
+_XWireToEvent(
+ register Display *dpy, /* pointer to display structure */
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event) /* wire protocol event */
+{
+
+ re->type = event->u.u.type & 0x7f;
+ ((XAnyEvent *)re)->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ ((XAnyEvent *)re)->send_event = ((event->u.u.type & 0x80) != 0);
+ ((XAnyEvent *)re)->display = dpy;
+
+ /* Ignore the leading bit of the event type since it is set when a
+ client sends an event rather than the server. */
+
+ switch (event-> u.u.type & 0177) {
+ case KeyPress:
+ case KeyRelease:
+ {
+ register XKeyEvent *ev = (XKeyEvent*) re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->keycode = event->u.u.detail;
+ }
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ {
+ register XButtonEvent *ev = (XButtonEvent *) re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->button = event->u.u.detail;
+ }
+ break;
+ case MotionNotify:
+ {
+ register XMotionEvent *ev = (XMotionEvent *)re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->is_hint = event->u.u.detail;
+ }
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ {
+ register XCrossingEvent *ev = (XCrossingEvent *) re;
+ ev->root = event->u.enterLeave.root;
+ ev->window = event->u.enterLeave.event;
+ ev->subwindow = event->u.enterLeave.child;
+ ev->time = event->u.enterLeave.time;
+ ev->x = cvtINT16toInt(event->u.enterLeave.eventX);
+ ev->y = cvtINT16toInt(event->u.enterLeave.eventY);
+ ev->x_root = cvtINT16toInt(event->u.enterLeave.rootX);
+ ev->y_root = cvtINT16toInt(event->u.enterLeave.rootY);
+ ev->state = event->u.enterLeave.state;
+ ev->mode = event->u.enterLeave.mode;
+ ev->same_screen = (event->u.enterLeave.flags &
+ ELFlagSameScreen) && True;
+ ev->focus = (event->u.enterLeave.flags &
+ ELFlagFocus) && True;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case FocusIn:
+ case FocusOut:
+ {
+ register XFocusChangeEvent *ev = (XFocusChangeEvent *) re;
+ ev->window = event->u.focus.window;
+ ev->mode = event->u.focus.mode;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case KeymapNotify:
+ {
+ register XKeymapEvent *ev = (XKeymapEvent *) re;
+ ev->window = None;
+ memcpy(&ev->key_vector[1],
+ (char *)((xKeymapEvent *) event)->map,
+ sizeof (((xKeymapEvent *) event)->map));
+ }
+ break;
+ case Expose:
+ {
+ register XExposeEvent *ev = (XExposeEvent *) re;
+ ev->window = event->u.expose.window;
+ ev->x = event->u.expose.x;
+ ev->y = event->u.expose.y;
+ ev->width = event->u.expose.width;
+ ev->height = event->u.expose.height;
+ ev->count = event->u.expose.count;
+ }
+ break;
+ case GraphicsExpose:
+ {
+ register XGraphicsExposeEvent *ev =
+ (XGraphicsExposeEvent *) re;
+ ev->drawable = event->u.graphicsExposure.drawable;
+ ev->x = event->u.graphicsExposure.x;
+ ev->y = event->u.graphicsExposure.y;
+ ev->width = event->u.graphicsExposure.width;
+ ev->height = event->u.graphicsExposure.height;
+ ev->count = event->u.graphicsExposure.count;
+ ev->major_code = event->u.graphicsExposure.majorEvent;
+ ev->minor_code = event->u.graphicsExposure.minorEvent;
+ }
+ break;
+ case NoExpose:
+ {
+ register XNoExposeEvent *ev = (XNoExposeEvent *) re;
+ ev->drawable = event->u.noExposure.drawable;
+ ev->major_code = event->u.noExposure.majorEvent;
+ ev->minor_code = event->u.noExposure.minorEvent;
+ }
+ break;
+ case VisibilityNotify:
+ {
+ register XVisibilityEvent *ev = (XVisibilityEvent *) re;
+ ev->window = event->u.visibility.window;
+ ev->state = event->u.visibility.state;
+ }
+ break;
+ case CreateNotify:
+ {
+ register XCreateWindowEvent *ev =
+ (XCreateWindowEvent *) re;
+ ev->window = event->u.createNotify.window;
+ ev->parent = event->u.createNotify.parent;
+ ev->x = cvtINT16toInt(event->u.createNotify.x);
+ ev->y = cvtINT16toInt(event->u.createNotify.y);
+ ev->width = event->u.createNotify.width;
+ ev->height = event->u.createNotify.height;
+ ev->border_width = event->u.createNotify.borderWidth;
+ ev->override_redirect = event->u.createNotify.override;
+ }
+ break;
+ case DestroyNotify:
+ {
+ register XDestroyWindowEvent *ev =
+ (XDestroyWindowEvent *) re;
+ ev->window = event->u.destroyNotify.window;
+ ev->event = event->u.destroyNotify.event;
+ }
+ break;
+ case UnmapNotify:
+ {
+ register XUnmapEvent *ev = (XUnmapEvent *) re;
+ ev->window = event->u.unmapNotify.window;
+ ev->event = event->u.unmapNotify.event;
+ ev->from_configure = event->u.unmapNotify.fromConfigure;
+ }
+ break;
+ case MapNotify:
+ {
+ register XMapEvent *ev = (XMapEvent *) re;
+ ev->window = event->u.mapNotify.window;
+ ev->event = event->u.mapNotify.event;
+ ev->override_redirect = event->u.mapNotify.override;
+ }
+ break;
+ case MapRequest:
+ {
+ register XMapRequestEvent *ev = (XMapRequestEvent *) re;
+ ev->window = event->u.mapRequest.window;
+ ev->parent = event->u.mapRequest.parent;
+ }
+ break;
+ case ReparentNotify:
+ {
+ register XReparentEvent *ev = (XReparentEvent *) re;
+ ev->event = event->u.reparent.event;
+ ev->window = event->u.reparent.window;
+ ev->parent = event->u.reparent.parent;
+ ev->x = cvtINT16toInt(event->u.reparent.x);
+ ev->y = cvtINT16toInt(event->u.reparent.y);
+ ev->override_redirect = event->u.reparent.override;
+ }
+ break;
+ case ConfigureNotify:
+ {
+ register XConfigureEvent *ev = (XConfigureEvent *) re;
+ ev->event = event->u.configureNotify.event;
+ ev->window = event->u.configureNotify.window;
+ ev->above = event->u.configureNotify.aboveSibling;
+ ev->x = cvtINT16toInt(event->u.configureNotify.x);
+ ev->y = cvtINT16toInt(event->u.configureNotify.y);
+ ev->width = event->u.configureNotify.width;
+ ev->height = event->u.configureNotify.height;
+ ev->border_width = event->u.configureNotify.borderWidth;
+ ev->override_redirect = event->u.configureNotify.override;
+ }
+ break;
+ case ConfigureRequest:
+ {
+ register XConfigureRequestEvent *ev =
+ (XConfigureRequestEvent *) re;
+ ev->window = event->u.configureRequest.window;
+ ev->parent = event->u.configureRequest.parent;
+ ev->above = event->u.configureRequest.sibling;
+ ev->x = cvtINT16toInt(event->u.configureRequest.x);
+ ev->y = cvtINT16toInt(event->u.configureRequest.y);
+ ev->width = event->u.configureRequest.width;
+ ev->height = event->u.configureRequest.height;
+ ev->border_width = event->u.configureRequest.borderWidth;
+ ev->value_mask = event->u.configureRequest.valueMask;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case GravityNotify:
+ {
+ register XGravityEvent *ev = (XGravityEvent *) re;
+ ev->window = event->u.gravity.window;
+ ev->event = event->u.gravity.event;
+ ev->x = cvtINT16toInt(event->u.gravity.x);
+ ev->y = cvtINT16toInt(event->u.gravity.y);
+ }
+ break;
+ case ResizeRequest:
+ {
+ register XResizeRequestEvent *ev =
+ (XResizeRequestEvent *) re;
+ ev->window = event->u.resizeRequest.window;
+ ev->width = event->u.resizeRequest.width;
+ ev->height = event->u.resizeRequest.height;
+ }
+ break;
+ case CirculateNotify:
+ {
+ register XCirculateEvent *ev = (XCirculateEvent *) re;
+ ev->window = event->u.circulate.window;
+ ev->event = event->u.circulate.event;
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case CirculateRequest:
+ {
+ register XCirculateRequestEvent *ev =
+ (XCirculateRequestEvent *) re;
+ ev->window = event->u.circulate.window;
+ ev->parent = event->u.circulate.event;
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case PropertyNotify:
+ {
+ register XPropertyEvent *ev = (XPropertyEvent *) re;
+ ev->window = event->u.property.window;
+ ev->atom = event->u.property.atom;
+ ev->time = event->u.property.time;
+ ev->state = event->u.property.state;
+ }
+ break;
+ case SelectionClear:
+ {
+ register XSelectionClearEvent *ev =
+ (XSelectionClearEvent *) re;
+ ev->window = event->u.selectionClear.window;
+ ev->selection = event->u.selectionClear.atom;
+ ev->time = event->u.selectionClear.time;
+ }
+ break;
+ case SelectionRequest:
+ {
+ register XSelectionRequestEvent *ev =
+ (XSelectionRequestEvent *) re;
+ ev->owner = event->u.selectionRequest.owner;
+ ev->requestor = event->u.selectionRequest.requestor;
+ ev->selection = event->u.selectionRequest.selection;
+ ev->target = event->u.selectionRequest.target;
+ ev->property = event->u.selectionRequest.property;
+ ev->time = event->u.selectionRequest.time;
+ }
+ break;
+ case SelectionNotify:
+ {
+ register XSelectionEvent *ev = (XSelectionEvent *) re;
+ ev->requestor = event->u.selectionNotify.requestor;
+ ev->selection = event->u.selectionNotify.selection;
+ ev->target = event->u.selectionNotify.target;
+ ev->property = event->u.selectionNotify.property;
+ ev->time = event->u.selectionNotify.time;
+ }
+ break;
+ case ColormapNotify:
+ {
+ register XColormapEvent *ev = (XColormapEvent *) re;
+ ev->window = event->u.colormap.window;
+ ev->colormap = event->u.colormap.colormap;
+ ev->new = event->u.colormap.new;
+ ev->state = event->u.colormap.state;
+ }
+ break;
+ case ClientMessage:
+ {
+ register int i;
+ register XClientMessageEvent *ev
+ = (XClientMessageEvent *) re;
+ ev->window = event->u.clientMessage.window;
+ ev->format = event->u.u.detail;
+ switch (ev->format) {
+ case 8:
+ ev->message_type = event->u.clientMessage.u.b.type;
+ for (i = 0; i < 20; i++)
+ ev->data.b[i] = event->u.clientMessage.u.b.bytes[i];
+ break;
+ case 16:
+ ev->message_type = event->u.clientMessage.u.s.type;
+ ev->data.s[0] = cvtINT16toShort(event->u.clientMessage.u.s.shorts0);
+ ev->data.s[1] = cvtINT16toShort(event->u.clientMessage.u.s.shorts1);
+ ev->data.s[2] = cvtINT16toShort(event->u.clientMessage.u.s.shorts2);
+ ev->data.s[3] = cvtINT16toShort(event->u.clientMessage.u.s.shorts3);
+ ev->data.s[4] = cvtINT16toShort(event->u.clientMessage.u.s.shorts4);
+ ev->data.s[5] = cvtINT16toShort(event->u.clientMessage.u.s.shorts5);
+ ev->data.s[6] = cvtINT16toShort(event->u.clientMessage.u.s.shorts6);
+ ev->data.s[7] = cvtINT16toShort(event->u.clientMessage.u.s.shorts7);
+ ev->data.s[8] = cvtINT16toShort(event->u.clientMessage.u.s.shorts8);
+ ev->data.s[9] = cvtINT16toShort(event->u.clientMessage.u.s.shorts9);
+ break;
+ case 32:
+ ev->message_type = event->u.clientMessage.u.l.type;
+ ev->data.l[0] = cvtINT32toLong(event->u.clientMessage.u.l.longs0);
+ ev->data.l[1] = cvtINT32toLong(event->u.clientMessage.u.l.longs1);
+ ev->data.l[2] = cvtINT32toLong(event->u.clientMessage.u.l.longs2);
+ ev->data.l[3] = cvtINT32toLong(event->u.clientMessage.u.l.longs3);
+ ev->data.l[4] = cvtINT32toLong(event->u.clientMessage.u.l.longs4);
+ break;
+ default: /* XXX should never occur */
+ break;
+ }
+ }
+ break;
+ case MappingNotify:
+ {
+ register XMappingEvent *ev = (XMappingEvent *)re;
+ ev->window = 0;
+ ev->first_keycode = event->u.mappingNotify.firstKeyCode;
+ ev->request = event->u.mappingNotify.request;
+ ev->count = event->u.mappingNotify.count;
+ }
+ break;
+ default:
+ return(_XUnknownWireEvent(dpy, re, event));
+ }
+ return(True);
+}
+
+
+/*
+ * _XDefaultIOError - Default fatal system error reporting routine. Called
+ * when an X internal system error is encountered.
+ */
+int _XDefaultIOError(
+ Display *dpy)
+{
+ if (ECHECK(EPIPE)) {
+ (void) fprintf (stderr,
+ "X connection to %s broken (explicit kill or server shutdown).\r\n",
+ DisplayString (dpy));
+ } else {
+ (void) fprintf (stderr,
+ "XIO: fatal IO error %d (%s) on X server \"%s\"\r\n",
+#ifdef WIN32
+ WSAGetLastError(), strerror(WSAGetLastError()),
+#else
+ errno, strerror (errno),
+#endif
+ DisplayString (dpy));
+ (void) fprintf (stderr,
+ " after %lu requests (%lu known processed) with %d events remaining.\r\n",
+ NextRequest(dpy) - 1, LastKnownRequestProcessed(dpy),
+ QLength(dpy));
+
+ }
+#ifdef NX_TRANS_SOCKET
+ if (_NXHandleDisplayError == 1)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XDefaultIOError: Going to return from the error handler.\n");
+#endif
+ return 0;
+ }
+ else
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XDefaultIOError: Going to exit from the program.\n");
+#endif
+#ifdef NX_TRANS_EXIT
+ NXTransExit(1);
+#else
+ exit(1);
+#endif
+ }
+#else
+ exit(1);
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+ return(0); /* dummy - function should never return */
+}
+
+
+static int _XPrintDefaultError(
+ Display *dpy,
+ XErrorEvent *event,
+ FILE *fp)
+{
+ char buffer[BUFSIZ];
+ char mesg[BUFSIZ];
+ char number[32];
+ char *mtype = "XlibMessage";
+ register _XExtension *ext = (_XExtension *)NULL;
+ _XExtension *bext = (_XExtension *)NULL;
+ XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
+ XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
+ (void) fprintf(fp, "%s: %s\n ", mesg, buffer);
+ XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->request_code);
+ if (event->request_code < 128) {
+ sprintf(number, "%d", event->request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
+ } else {
+ for (ext = dpy->ext_procs;
+ ext && (ext->codes.major_opcode != event->request_code);
+ ext = ext->next)
+ ;
+ if (ext)
+ strcpy(buffer, ext->name);
+ else
+ buffer[0] = '\0';
+ }
+ (void) fprintf(fp, " (%s)\n", buffer);
+ if (event->request_code >= 128) {
+ XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->minor_code);
+ if (ext) {
+ sprintf(mesg, "%s.%d", ext->name, event->minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
+ (void) fprintf(fp, " (%s)", buffer);
+ }
+ fputs("\n", fp);
+ }
+ if (event->error_code >= 128) {
+ /* kludge, try to find the extension that caused it */
+ buffer[0] = '\0';
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_string)
+ (*ext->error_string)(dpy, event->error_code, &ext->codes,
+ buffer, BUFSIZ);
+ if (buffer[0]) {
+ bext = ext;
+ break;
+ }
+ if (ext->codes.first_error &&
+ ext->codes.first_error < (int)event->error_code &&
+ (!bext || ext->codes.first_error > bext->codes.first_error))
+ bext = ext;
+ }
+ if (bext)
+ sprintf(buffer, "%s.%d", bext->name,
+ event->error_code - bext->codes.first_error);
+ else
+ strcpy(buffer, "Value");
+ XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
+ if (mesg[0]) {
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ /* let extensions try to print the values */
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_values)
+ (*ext->error_values)(dpy, event, fp);
+ }
+ } else if ((event->error_code == BadWindow) ||
+ (event->error_code == BadPixmap) ||
+ (event->error_code == BadCursor) ||
+ (event->error_code == BadFont) ||
+ (event->error_code == BadDrawable) ||
+ (event->error_code == BadColor) ||
+ (event->error_code == BadGC) ||
+ (event->error_code == BadIDChoice) ||
+ (event->error_code == BadValue) ||
+ (event->error_code == BadAtom)) {
+ if (event->error_code == BadValue)
+ XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
+ mesg, BUFSIZ);
+ else if (event->error_code == BadAtom)
+ XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
+ mesg, BUFSIZ);
+ else
+ XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->serial);
+ XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
+ mesg, BUFSIZ);
+ fputs("\n ", fp);
+ (void) fprintf(fp, mesg, dpy->request);
+ fputs("\n", fp);
+ if (event->error_code == BadImplementation) return 0;
+ return 1;
+}
+
+int _XDefaultError(
+ Display *dpy,
+ XErrorEvent *event)
+{
+ if (_XPrintDefaultError (dpy, event, stderr) == 0) return 0;
+ exit(1);
+ /*NOTREACHED*/
+}
+
+/*ARGSUSED*/
+Bool _XDefaultWireError(display, he, we)
+ Display *display;
+ XErrorEvent *he;
+ xError *we;
+{
+ return True;
+}
+
+/*
+ * _XError - upcall internal or user protocol error handler
+ */
+int _XError (
+ Display *dpy,
+ register xError *rep)
+{
+ /*
+ * X_Error packet encountered! We need to unpack the error before
+ * giving it to the user.
+ */
+ XEvent event; /* make it a large event */
+ register _XAsyncHandler *async, *next;
+
+ event.xerror.serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
+
+ for (async = dpy->async_handlers; async; async = next) {
+ next = async->next;
+ if ((*async->handler)(dpy, (xReply *)rep,
+ (char *)rep, SIZEOF(xError), async->data))
+ return 0;
+ }
+
+ event.xerror.display = dpy;
+ event.xerror.type = X_Error;
+ event.xerror.resourceid = rep->resourceID;
+ event.xerror.error_code = rep->errorCode;
+ event.xerror.request_code = rep->majorCode;
+ event.xerror.minor_code = rep->minorCode;
+ if (dpy->error_vec &&
+ !(*dpy->error_vec[rep->errorCode])(dpy, &event.xerror, rep))
+ return 0;
+ if (_XErrorFunction != NULL) {
+ int rtn_val;
+#ifdef XTHREADS
+ if (dpy->lock)
+ (*dpy->lock->user_lock_display)(dpy);
+ UnlockDisplay(dpy);
+#endif /* XTHREADS */
+ rtn_val = (*_XErrorFunction)(dpy, (XErrorEvent *)&event); /* upcall */
+#ifdef XTHREADS
+ LockDisplay(dpy);
+ if (dpy->lock)
+ (*dpy->lock->user_unlock_display)(dpy);
+#endif /* XTHREADS */
+ return rtn_val;
+ } else {
+ return _XDefaultError(dpy, (XErrorEvent *)&event);
+ }
+}
+
+/*
+ * _XIOError - call user connection error handler and exit
+ */
+int
+_XIOError (
+ Display *dpy)
+{
+ dpy->flags |= XlibDisplayIOError;
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+
+ if (_XIOErrorFunction != NULL)
+ (*_XIOErrorFunction)(dpy);
+ else
+ _XDefaultIOError(dpy);
+#ifdef NX_TRANS_SOCKET
+ /*
+ * Check if we are supposed to return in the case
+ * of a display failure. The client which originated
+ * the X operation will have to check the value of
+ * the XlibDisplayIOError flag and handle appropria-
+ * tely the display disconnection.
+ */
+
+ if (_NXHandleDisplayError == 0)
+ {
+#ifdef NX_TRANS_EXIT
+ NXTransExit(1);
+#else
+ exit(1);
+#endif
+ }
+
+ /*
+ * We are going to return. Reset the display
+ * buffers. Further writes will be discarded.
+ */
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XIOError: Resetting the display buffer.\n");
+#endif
+
+ dpy->bufptr = dpy->buffer;
+ dpy->last_req = (char *) &_dummy_request;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_XIOError: Resetting the display flags.\n");
+#endif
+
+ dpy->flags &= ~XlibDisplayProcConni;
+ dpy->flags &= ~XlibDisplayPrivSync;
+ dpy->flags &= ~XlibDisplayReadEvents;
+ dpy->flags &= ~XlibDisplayWriting;
+ dpy->flags &= ~XlibDisplayReply;
+#else
+ exit (1);
+#endif
+ return 0;
+}
+
+
+/*
+ * This routine can be used to (cheaply) get some memory within a single
+ * Xlib routine for scratch space. A single buffer is reused each time
+ * if possible. To be MT safe, you can only call this between a call to
+ * GetReq* and a call to Data* or _XSend*, or in a context when the thread
+ * is guaranteed to not unlock the display.
+ */
+char *_XAllocScratch(
+ register Display *dpy,
+ unsigned long nbytes)
+{
+ if (nbytes > dpy->scratch_length) {
+ if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer);
+ if ((dpy->scratch_buffer = Xmalloc((unsigned) nbytes)))
+ dpy->scratch_length = nbytes;
+ else dpy->scratch_length = 0;
+ }
+ return (dpy->scratch_buffer);
+}
+
+/*
+ * Scratch space allocator you can call any time, multiple times, and be
+ * MT safe, but you must hand the buffer back with _XFreeTemp.
+ */
+char *_XAllocTemp(
+ register Display *dpy,
+ unsigned long nbytes)
+{
+ char *buf;
+
+ buf = _XAllocScratch(dpy, nbytes);
+ dpy->scratch_buffer = NULL;
+ dpy->scratch_length = 0;
+ return buf;
+}
+
+void _XFreeTemp(
+ register Display *dpy,
+ char *buf,
+ unsigned long nbytes)
+{
+ if (dpy->scratch_buffer)
+ Xfree(dpy->scratch_buffer);
+ dpy->scratch_buffer = buf;
+ dpy->scratch_length = nbytes;
+}
+
+/*
+ * Given a visual id, find the visual structure for this id on this display.
+ */
+Visual *_XVIDtoVisual(
+ Display *dpy,
+ VisualID id)
+{
+ register int i, j, k;
+ register Screen *sp;
+ register Depth *dp;
+ register Visual *vp;
+ for (i = 0; i < dpy->nscreens; i++) {
+ sp = &dpy->screens[i];
+ for (j = 0; j < sp->ndepths; j++) {
+ dp = &sp->depths[j];
+ /* if nvisuals == 0 then visuals will be NULL */
+ for (k = 0; k < dp->nvisuals; k++) {
+ vp = &dp->visuals[k];
+ if (vp->visualid == id) return (vp);
+ }
+ }
+ }
+ return (NULL);
+}
+
+int
+XFree (void *data)
+{
+ Xfree (data);
+ return 1;
+}
+
+#ifdef _XNEEDBCOPYFUNC
+void _Xbcopy(b1, b2, length)
+ register char *b1, *b2;
+ register length;
+{
+ if (b1 < b2) {
+ b2 += length;
+ b1 += length;
+ while (length--)
+ *--b2 = *--b1;
+ } else {
+ while (length--)
+ *b2++ = *b1++;
+ }
+}
+#endif
+
+#ifdef DataRoutineIsProcedure
+void Data(
+ Display *dpy,
+ char *data,
+ long len)
+{
+ if (dpy->bufptr + (len) <= dpy->bufmax) {
+ memcpy(dpy->bufptr, data, (int)len);
+ dpy->bufptr += ((len) + 3) & ~3;
+ } else {
+ _XSend(dpy, data, len);
+ }
+}
+#endif /* DataRoutineIsProcedure */
+
+
+#ifdef LONG64
+int
+_XData32(
+ Display *dpy,
+ register long *data,
+ unsigned len)
+{
+ register int *buf;
+ register long i;
+
+ while (len) {
+ buf = (int *)dpy->bufptr;
+ i = dpy->bufmax - (char *)buf;
+ if (!i) {
+ _XFlush(dpy);
+ continue;
+ }
+ if (len < i)
+ i = len;
+ dpy->bufptr = (char *)buf + i;
+ len -= i;
+ i >>= 2;
+ while (--i >= 0)
+ *buf++ = *data++;
+ }
+ return 0;
+}
+#endif /* LONG64 */
+
+#ifdef WORD64
+
+/*
+ * XXX This is a *really* stupid way of doing this. It should just use
+ * dpy->bufptr directly, taking into account where in the word it is.
+ */
+
+/*
+ * Data16 - Place 16 bit data in the buffer.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static doData16(
+ register Display *dpy,
+ short *data,
+ unsigned len,
+ char *packbuffer)
+{
+ long *lp,*lpack;
+ long i, nwords,bits;
+ long mask16 = 0x000000000000ffff;
+
+ lp = (long *)data;
+ lpack = (long *)packbuffer;
+
+/* nwords is the number of 16 bit values to be packed,
+ * the low order 16 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 1;
+ bits = 48;
+
+ for(i=0;i<nwords;i++){
+ if (bits == 48) *lpack = 0;
+ *lpack ^= (*lp & mask16) << bits;
+ bits -= 16 ;
+ lp++;
+ if(bits < 0){
+ lpack++;
+ bits = 48;
+ }
+ }
+ Data(dpy, packbuffer, len);
+}
+
+_XData16 (
+ Display *dpy,
+ short *data,
+ unsigned len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 1;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ doData16 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) doData16 (dpy, data, len, packbuffer);
+}
+
+/*
+ * Data32 - Place 32 bit data in the buffer.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static doData32(
+ register Display *dpy
+ long *data,
+ unsigned len,
+ char *packbuffer)
+{
+ long *lp,*lpack;
+ long i,bits,nwords;
+ long mask32 = 0x00000000ffffffff;
+
+ lpack = (long *) packbuffer;
+ lp = data;
+
+/* nwords is the number of 32 bit values to be packed
+ * the low order 32 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 2;
+ bits = 32;
+
+ for(i=0;i<nwords;i++){
+ if (bits == 32) *lpack = 0;
+ *lpack ^= (*lp & mask32) << bits;
+ bits = bits ^32;
+ lp++;
+ if(bits)
+ lpack++;
+ }
+ Data(dpy, packbuffer, len);
+}
+
+void _XData32(
+ Display *dpy,
+ long *data,
+ unsigned len,
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 2;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ doData32 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) doData32 (dpy, data, len, packbuffer);
+}
+
+#endif /* WORD64 */
+
+
+/* Make sure this produces the same string as DefineLocal/DefineSelf in xdm.
+ * Otherwise, Xau will not be able to find your cookies in the Xauthority file.
+ *
+ * Note: POSIX says that the ``nodename'' member of utsname does _not_ have
+ * to have sufficient information for interfacing to the network,
+ * and so, you may be better off using gethostname (if it exists).
+ */
+
+#if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(USG) || defined(SVR4)
+#define NEED_UTSNAME
+#include <sys/utsname.h>
+#endif
+
+/*
+ * _XGetHostname - similar to gethostname but allows special processing.
+ */
+int _XGetHostname (
+ char *buf,
+ int maxlen)
+{
+ int len;
+
+#ifdef NEED_UTSNAME
+ struct utsname name;
+
+ if (maxlen <= 0 || buf == NULL)
+ return 0;
+
+ uname (&name);
+ len = strlen (name.nodename);
+ if (len >= maxlen) len = maxlen - 1;
+ strncpy (buf, name.nodename, len);
+ buf[len] = '\0';
+#else
+ if (maxlen <= 0 || buf == NULL)
+ return 0;
+
+ buf[0] = '\0';
+ (void) gethostname (buf, maxlen);
+ buf [maxlen - 1] = '\0';
+ len = strlen(buf);
+#endif /* NEED_UTSNAME */
+ return len;
+}
+
+
+/*
+ * _XScreenOfWindow - get the Screen of a given window
+ */
+
+Screen *_XScreenOfWindow (dpy, w)
+ Display *dpy;
+ Window w;
+{
+ register int i;
+ Window root;
+ int x, y; /* dummy variables */
+ unsigned int width, height, bw, depth; /* dummy variables */
+
+ if (XGetGeometry (dpy, w, &root, &x, &y, &width, &height,
+ &bw, &depth) == False) {
+ return None;
+ }
+ for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */
+ if (root == RootWindow (dpy, i)) {
+ return ScreenOfDisplay (dpy, i);
+ }
+ }
+ return NULL;
+}
+
+
+#if defined(WIN32)
+
+/*
+ * These functions are intended to be used internally to Xlib only.
+ * These functions will always prefix the path with a DOS drive in the
+ * form "<drive-letter>:". As such, these functions are only suitable
+ * for use by Xlib function that supply a root-based path to some
+ * particular file, e.g. <ProjectRoot>/lib/X11/locale/locale.dir will
+ * be converted to "C:/usr/X11R6.3/lib/X11/locale/locale.dir".
+ */
+
+static int access_file (path, pathbuf, len_pathbuf, pathret)
+ char* path;
+ char* pathbuf;
+ int len_pathbuf;
+ char** pathret;
+{
+ if (access (path, F_OK) == 0) {
+ if (strlen (path) < len_pathbuf)
+ *pathret = pathbuf;
+ else
+ *pathret = Xmalloc (strlen (path) + 1);
+ if (*pathret) {
+ strcpy (*pathret, path);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int AccessFile (path, pathbuf, len_pathbuf, pathret)
+ char* path;
+ char* pathbuf;
+ int len_pathbuf;
+ char** pathret;
+{
+ unsigned long drives;
+ int i, len;
+ char* drive;
+ char buf[MAX_PATH];
+ char* bufp;
+
+ /* just try the "raw" name first and see if it works */
+ if (access_file (path, pathbuf, len_pathbuf, pathret))
+ return 1;
+
+ /* try the places set in the environment */
+ drive = getenv ("_XBASEDRIVE");
+#ifdef __UNIXOS2__
+ if (!drive)
+ drive = getenv ("X11ROOT");
+#endif
+ if (!drive)
+ drive = "C:";
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+
+#ifndef __UNIXOS2__
+ /* one last place to look */
+ drive = getenv ("HOMEDRIVE");
+ if (drive) {
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+ }
+
+ /* tried everywhere else, go fishing */
+#define C_DRIVE ('C' - 'A')
+#define Z_DRIVE ('Z' - 'A')
+ /* does OS/2 (with or with gcc-emx) have getdrives? */
+ drives = _getdrives ();
+ for (i = C_DRIVE; i <= Z_DRIVE; i++) { /* don't check on A: or B: */
+ if ((1 << i) & drives) {
+ len = 2 + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ *bufp = 'A' + i;
+ *(bufp + 1) = ':';
+ *(bufp + 2) = '\0';
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+ }
+ }
+#endif
+ return 0;
+}
+
+int _XOpenFile(path, flags)
+ _Xconst char* path;
+ int flags;
+{
+ char buf[MAX_PATH];
+ char* bufp = NULL;
+ int ret = -1;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ ret = open (bufp, flags);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+void* _XFopenFile(path, mode)
+ _Xconst char* path;
+ _Xconst char* mode;
+{
+ char buf[MAX_PATH];
+ char* bufp = NULL;
+ void* ret = NULL;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ ret = fopen (bufp, mode);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+int _XAccessFile(path)
+ _Xconst char* path;
+{
+ char buf[MAX_PATH];
+ char* bufp;
+ int ret = -1;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ ret = AccessFile (path, buf, MAX_PATH, &bufp);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+#endif
+
+#ifdef WIN32
+#undef _Xdebug
+int _Xdebug = 0;
+int *_Xdebug_p = &_Xdebug;
+void (**_XCreateMutex_fn_p)(LockInfoPtr) = &_XCreateMutex_fn;
+void (**_XFreeMutex_fn_p)(LockInfoPtr) = &_XFreeMutex_fn;
+void (**_XLockMutex_fn_p)(LockInfoPtr
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = &_XLockMutex_fn;
+void (**_XUnlockMutex_fn_p)(LockInfoPtr
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = &_XUnlockMutex_fn;
+LockInfoPtr *_Xglobal_lock_p = &_Xglobal_lock;
+#endif
diff --git a/nx-X11/lib/X11/XlibInt.c.X.original b/nx-X11/lib/X11/XlibInt.c.X.original
new file mode 100644
index 000000000..c042eb2e4
--- /dev/null
+++ b/nx-X11/lib/X11/XlibInt.c.X.original
@@ -0,0 +1,3429 @@
+/* $Xorg: XlibInt.c,v 1.8 2001/02/09 02:03:38 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.
+
+*/
+/* $XFree86: xc/lib/X11/XlibInt.c,v 3.38 2003/10/30 21:55:05 alanh Exp $ */
+
+/*
+ * XlibInt.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
+
+#ifdef WIN32
+#define _XLIBINT_
+#endif
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/Xpoll.h>
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/extensions/xcmiscstr.h>
+#include <stdio.h>
+#ifdef WIN32
+#include <direct.h>
+#endif
+
+#ifdef XTHREADS
+#include "locking.h"
+
+/* these pointers get initialized by XInitThreads */
+LockInfoPtr _Xglobal_lock = NULL;
+void (*_XCreateMutex_fn)(LockInfoPtr) = NULL;
+/* struct _XCVList *(*_XCreateCVL_fn)() = NULL; */
+void (*_XFreeMutex_fn)(LockInfoPtr) = NULL;
+void (*_XLockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = NULL;
+void (*_XUnlockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = NULL;
+xthread_t (*_Xthread_self_fn)(void) = NULL;
+
+#define XThread_Self() ((*_Xthread_self_fn)())
+
+#define UnlockNextReplyReader(d) if ((d)->lock) \
+ (*(d)->lock->pop_reader)((d),&(d)->lock->reply_awaiters,&(d)->lock->reply_awaiters_tail)
+
+#define QueueReplyReaderLock(d) ((d)->lock ? \
+ (*(d)->lock->push_reader)(d,&(d)->lock->reply_awaiters_tail) : NULL)
+#define QueueEventReaderLock(d) ((d)->lock ? \
+ (*(d)->lock->push_reader)(d,&(d)->lock->event_awaiters_tail) : NULL)
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+#define InternalLockDisplay(d,wskip) if ((d)->lock) \
+ (*(d)->lock->internal_lock_display)(d,wskip,__FILE__,__LINE__)
+#else
+#define InternalLockDisplay(d,wskip) if ((d)->lock) \
+ (*(d)->lock->internal_lock_display)(d,wskip)
+#endif
+
+#else /* XTHREADS else */
+
+#define UnlockNextReplyReader(d)
+#define UnlockNextEventReader(d)
+#define InternalLockDisplay(d,wskip)
+
+#endif /* XTHREADS else */
+
+/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ */
+#ifdef WIN32
+#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK)
+#else
+#ifdef __CYGWIN__ /* Cygwin uses ENOBUFS to signal socket is full */
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS)
+#else
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define ETEST() (errno == EAGAIN)
+#else
+#define ETEST() (errno == EWOULDBLOCK)
+#endif /* EAGAIN */
+#endif /* EAGAIN && EWOULDBLOCK */
+#endif /* __CYGWIN__ */
+#endif /* WIN32 */
+
+#ifdef WIN32
+#define ECHECK(err) (WSAGetLastError() == err)
+#define ESET(val) WSASetLastError(val)
+#else
+#ifdef __UNIXOS2__
+#define ECHECK(err) (errno == err)
+#define ESET(val)
+#else
+#ifdef ISC
+#define ECHECK(err) ((errno == err) || ETEST())
+#else
+#define ECHECK(err) (errno == err)
+#endif
+#define ESET(val) errno = val
+#endif
+#endif
+
+#if defined(LOCALCONN) || defined(LACHMAN)
+#ifdef EMSGSIZE
+#define ESZTEST() (ECHECK(EMSGSIZE) || ECHECK(ERANGE))
+#else
+#define ESZTEST() ECHECK(ERANGE)
+#endif
+#else
+#ifdef EMSGSIZE
+#define ESZTEST() ECHECK(EMSGSIZE)
+#endif
+#endif
+
+#ifdef __UNIXOS2__
+#define select(n,r,w,x,t) os2ClientSelect(n,r,w,x,t)
+#include <limits.h>
+#define MAX_PATH _POSIX_PATH_MAX
+#endif
+
+#ifdef MUSTCOPY
+
+#define STARTITERATE(tpvar,type,start,endcond) \
+ { register char *cpvar; \
+ for (cpvar = (char *) (start); endcond; ) { \
+ type dummy; memcpy ((char *) &dummy, cpvar, SIZEOF(type)); \
+ tpvar = &dummy;
+#define ITERPTR(tpvar) cpvar
+#define RESETITERPTR(tpvar,type,start) cpvar = start
+#define INCITERPTR(tpvar,type) cpvar += SIZEOF(type)
+#define ENDITERATE }}
+
+#else
+
+#define STARTITERATE(tpvar,type,start,endcond) \
+ for (tpvar = (type *) (start); endcond; )
+#define ITERPTR(tpvar) (char *)tpvar
+#define RESETITERPTR(tpvar,type,start) tpvar = (type *) (start)
+#define INCITERPTR(tpvar,type) tpvar++
+#define ENDITERATE
+
+#endif /* MUSTCOPY */
+
+typedef union {
+ xReply rep;
+ char buf[BUFSIZE];
+} _XAlignedBuffer;
+
+static char *_XAsyncReply(
+ Display *dpy,
+ register xReply *rep,
+ char *buf,
+ register int *lenp,
+ Bool discard);
+
+static void _XProcessInternalConnection(
+ Display *dpy,
+ struct _XConnectionInfo *conn_info);
+
+#define SEQLIMIT (65535 - (BUFSIZE / SIZEOF(xReq)) - 10)
+
+/*
+ * The following routines are internal routines used by Xlib for protocol
+ * packet transmission and reception.
+ *
+ * _XIOError(Display *) will be called if any sort of system call error occurs.
+ * This is assumed to be a fatal condition, i.e., XIOError should not return.
+ *
+ * _XError(Display *, xError *) will be called whenever an X_Error event is
+ * received. This is not assumed to be a fatal condition, i.e., it is
+ * acceptable for this procedure to return. However, XError should NOT
+ * perform any operations (directly or indirectly) on the DISPLAY.
+ *
+ * Routines declared with a return type of 'Status' return 0 on failure,
+ * and non 0 on success. Routines with no declared return type don't
+ * return anything. Whenever possible routines that create objects return
+ * the object they have created.
+ */
+
+static xReq _dummy_request = {
+ 0, 0, 0
+};
+
+/*
+ * This is an OS dependent routine which:
+ * 1) returns as soon as the connection can be written on....
+ * 2) if the connection can be read, must enqueue events and handle errors,
+ * until the connection is writable.
+ */
+static void
+_XWaitForWritable(
+ Display *dpy
+#ifdef XTHREADS
+ ,
+ xcondition_t cv /* our reading condition variable */
+#endif
+ )
+{
+#ifdef USE_POLL
+ struct pollfd filedes;
+#else
+ fd_set r_mask;
+ fd_set w_mask;
+#endif
+ int nfound;
+
+#ifdef USE_POLL
+ filedes.fd = dpy->fd;
+ filedes.events = 0;
+#else
+ FD_ZERO(&r_mask);
+ FD_ZERO(&w_mask);
+#endif
+
+ for (;;) {
+#ifdef XTHREADS
+ /* We allow only one thread at a time to read, to minimize
+ passing of read data between threads.
+ Now, who is it? If there is a non-NULL reply_awaiters and
+ we (i.e., our cv) are not at the head of it, then whoever
+ is at the head is the reader, and we don't read.
+ Otherwise there is no reply_awaiters or we are at the
+ head, having just appended ourselves.
+ In this case, if there is a event_awaiters, then whoever
+ is at the head of it got there before we did, and they are the
+ reader.
+
+ Last cases: no event_awaiters and we are at the head of
+ reply_awaiters or reply_awaiters is NULL: we are the reader,
+ since there is obviously no one else involved.
+
+ XXX - what if cv is NULL and someone else comes along after
+ us while we are waiting?
+ */
+
+ if (!dpy->lock ||
+ (!dpy->lock->event_awaiters &&
+ (!dpy->lock->reply_awaiters ||
+ dpy->lock->reply_awaiters->cv == cv)))
+#endif
+#ifdef USE_POLL
+ filedes.events = POLLIN;
+ filedes.events |= POLLOUT;
+#else
+ FD_SET(dpy->fd, &r_mask);
+ FD_SET(dpy->fd, &w_mask);
+#endif
+
+ do {
+ UnlockDisplay(dpy);
+#ifdef USE_POLL
+ nfound = poll (&filedes, 1, -1);
+#else
+ nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL);
+#endif
+ InternalLockDisplay(dpy, cv != NULL);
+ if (nfound < 0 && !ECHECK(EINTR))
+ _XIOError(dpy);
+ } while (nfound <= 0);
+
+ if (
+#ifdef USE_POLL
+ filedes.revents & POLLIN
+#else
+ FD_ISSET(dpy->fd, &r_mask)
+#endif
+ )
+ {
+ _XAlignedBuffer buf;
+ BytesReadable_t pend;
+ register int len;
+ register xReply *rep;
+
+ /* find out how much data can be read */
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+ _XIOError(dpy);
+ len = pend;
+
+ /* must read at least one xEvent; if none is pending, then
+ we'll just block waiting for it */
+ if (len < SIZEOF(xReply)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ )
+ len = SIZEOF(xReply);
+
+ /* but we won't read more than the max buffer size */
+ if (len > BUFSIZE) len = BUFSIZE;
+
+ /* round down to an integral number of XReps */
+ len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
+
+ (void) _XRead (dpy, buf.buf, (long) len);
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ int tmp = len;
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &tmp, True));
+ len = tmp;
+ pend = len;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *)rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->event_awaiters)
+ ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
+#endif
+ }
+#ifdef USE_POLL
+ if (filedes.revents & (POLLOUT|POLLHUP|POLLERR))
+#else
+ if (FD_ISSET(dpy->fd, &w_mask))
+#endif
+ {
+#ifdef XTHREADS
+ if (dpy->lock) {
+ ConditionBroadcast(dpy, dpy->lock->writers);
+ }
+#endif
+ return;
+ }
+ }
+}
+
+
+#define POLLFD_CACHE_SIZE 5
+
+/* initialize the struct array passed to poll() below */
+Bool _XPollfdCacheInit(
+ Display *dpy)
+{
+#ifdef USE_POLL
+ struct pollfd *pfp;
+
+ pfp = (struct pollfd *)Xmalloc(POLLFD_CACHE_SIZE * sizeof(struct pollfd));
+ if (!pfp)
+ return False;
+ pfp[0].fd = dpy->fd;
+ pfp[0].events = POLLIN;
+
+ dpy->filedes = (XPointer)pfp;
+#endif
+ return True;
+}
+
+void _XPollfdCacheAdd(
+ Display *dpy,
+ int fd)
+{
+#ifdef USE_POLL
+ struct pollfd *pfp = (struct pollfd *)dpy->filedes;
+
+ if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) {
+ pfp[dpy->im_fd_length].fd = fd;
+ pfp[dpy->im_fd_length].events = POLLIN;
+ }
+#endif
+}
+
+/* ARGSUSED */
+void _XPollfdCacheDel(
+ Display *dpy,
+ int fd) /* not used */
+{
+#ifdef USE_POLL
+ struct pollfd *pfp = (struct pollfd *)dpy->filedes;
+ struct _XConnectionInfo *conni;
+
+ /* just recalculate whole list */
+ if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) {
+ int loc = 1;
+ for (conni = dpy->im_fd_info; conni; conni=conni->next) {
+ pfp[loc].fd = conni->fd;
+ pfp[loc].events = POLLIN;
+ loc++;
+ }
+ }
+#endif
+}
+
+/* returns True iff there is an event in the queue newer than serial_num */
+
+static Bool
+_XNewerQueuedEvent(
+ Display *dpy,
+ int serial_num)
+{
+ _XQEvent *qev;
+
+ if (dpy->next_event_serial_num == serial_num)
+ return False;
+
+ qev = dpy->head;
+ while (qev) {
+ if (qev->qserial_num >= serial_num) {
+ return True;
+ }
+ qev = qev->next;
+ }
+ return False;
+}
+
+static int
+_XWaitForReadable(
+ Display *dpy)
+{
+ int result;
+ int fd = dpy->fd;
+ struct _XConnectionInfo *ilist;
+ register int saved_event_serial = 0;
+ int in_read_events = 0;
+ register Bool did_proc_conni = False;
+#ifdef USE_POLL
+ struct pollfd *filedes;
+#else
+ fd_set r_mask;
+ int highest_fd = fd;
+#endif
+
+#ifdef USE_POLL
+ if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE
+ && !(dpy->flags & XlibDisplayProcConni)) {
+ /* XXX - this fallback is gross */
+ int i;
+
+ filedes = (struct pollfd *)Xmalloc(dpy->im_fd_length * sizeof(struct pollfd));
+ filedes[0].fd = fd;
+ filedes[0].events = POLLIN;
+ for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
+ filedes[i].fd = ilist->fd;
+ filedes[i].events = POLLIN;
+ }
+ } else {
+ filedes = (struct pollfd *)dpy->filedes;
+ }
+#else
+ FD_ZERO(&r_mask);
+#endif
+ for (;;) {
+#ifndef USE_POLL
+ FD_SET(fd, &r_mask);
+ if (!(dpy->flags & XlibDisplayProcConni))
+ for (ilist=dpy->im_fd_info; ilist; ilist=ilist->next) {
+ FD_SET(ilist->fd, &r_mask);
+ if (ilist->fd > highest_fd)
+ highest_fd = ilist->fd;
+ }
+#endif
+ UnlockDisplay(dpy);
+#ifdef USE_POLL
+ result = poll(filedes,
+ (dpy->flags & XlibDisplayProcConni) ? 1 : 1+dpy->im_fd_length,
+ -1);
+#else
+ result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL);
+#endif
+ InternalLockDisplay(dpy, dpy->flags & XlibDisplayReply);
+ if (result == -1 && !ECHECK(EINTR)) _XIOError(dpy);
+ if (result <= 0)
+ continue;
+#ifdef USE_POLL
+ if (filedes[0].revents & (POLLIN|POLLHUP|POLLERR))
+#else
+ if (FD_ISSET(fd, &r_mask))
+#endif
+ break;
+ if (!(dpy->flags & XlibDisplayProcConni)) {
+ int i;
+
+ saved_event_serial = dpy->next_event_serial_num;
+ /* dpy flags can be clobbered by internal connection callback */
+ in_read_events = dpy->flags & XlibDisplayReadEvents;
+ for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
+#ifdef USE_POLL
+ if (filedes[i].revents & POLLIN)
+#else
+ if (FD_ISSET(ilist->fd, &r_mask))
+#endif
+ {
+ _XProcessInternalConnection(dpy, ilist);
+ did_proc_conni = True;
+ }
+ }
+#ifdef USE_POLL
+ if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE)
+ Xfree(filedes);
+#endif
+ }
+ if (did_proc_conni) {
+ /* some internal connection callback might have done an
+ XPutBackEvent. We notice it here and if we needed an event,
+ we can return all the way. */
+ if (_XNewerQueuedEvent(dpy, saved_event_serial)
+ && (in_read_events
+#ifdef XTHREADS
+ || (dpy->lock && dpy->lock->event_awaiters)
+#endif
+ ))
+ return -2;
+ did_proc_conni = False;
+ }
+ }
+#ifdef XTHREADS
+#ifdef XTHREADS_DEBUG
+ printf("thread %x _XWaitForReadable returning\n", XThread_Self());
+#endif
+#endif
+ return 0;
+}
+
+static
+int _XSeqSyncFunction(
+ register Display *dpy)
+{
+ xGetInputFocusReply rep;
+ register xReq *req;
+
+ LockDisplay(dpy);
+ if ((dpy->request - dpy->last_request_read) >= (BUFSIZE / SIZEOF(xReq))) {
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ }
+ /* could get XID handler while waiting for reply in MT env */
+ if (dpy->synchandler == _XSeqSyncFunction) {
+ dpy->synchandler = dpy->savedsynchandler;
+ dpy->flags &= ~XlibDisplayPrivSync;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
+#ifdef XTHREADS
+static void _XFlushInt(
+ register Display *dpy,
+ register xcondition_t cv);
+#endif
+
+/*
+ * _XFlush - Flush the X request buffer. If the buffer is empty, no
+ * action is taken. This routine correctly handles incremental writes.
+ * This routine may have to be reworked if int < long.
+ */
+void _XFlush(
+ register Display *dpy)
+{
+#ifdef XTHREADS
+ /* With multi-threading we introduce an internal routine to which
+ we can pass a condition variable to do locking correctly. */
+
+ _XFlushInt(dpy, NULL);
+}
+
+/* _XFlushInt - Internal version of _XFlush used to do multi-threaded
+ * locking correctly.
+ */
+
+static void _XFlushInt(
+ register Display *dpy,
+ register xcondition_t cv)
+{
+#endif /* XTHREADS*/
+ register long size, todo;
+ register int write_stat;
+ register char *bufindex;
+ _XExtension *ext;
+
+ /* This fix resets the bufptr to the front of the buffer so
+ * additional appends to the bufptr will not corrupt memory. Since
+ * the server is down, these appends are no-op's anyway but
+ * callers of _XFlush() are not verifying this before they call it.
+ */
+ if (dpy->flags & XlibDisplayIOError)
+ {
+ dpy->bufptr = dpy->buffer;
+ dpy->last_req = (char *)&_dummy_request;
+ return;
+ }
+
+#ifdef XTHREADS
+ while (dpy->flags & XlibDisplayWriting) {
+ if (dpy->lock) {
+ ConditionWait(dpy, dpy->lock->writers);
+ } else {
+ _XWaitForWritable (dpy, cv);
+ }
+ }
+#endif
+ size = todo = dpy->bufptr - dpy->buffer;
+ if (!size) return;
+#ifdef XTHREADS
+ dpy->flags |= XlibDisplayWriting;
+ /* make sure no one else can put in data */
+ dpy->bufptr = dpy->bufmax;
+#endif
+ for (ext = dpy->flushes; ext; ext = ext->next_flush)
+ (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, size);
+ bufindex = dpy->buffer;
+ /*
+ * While write has not written the entire buffer, keep looping
+ * until the entire buffer is written. bufindex will be
+ * incremented and size decremented as buffer is written out.
+ */
+ while (size) {
+ ESET(0);
+ write_stat = _X11TransWrite(dpy->trans_conn,
+ bufindex, (int) todo);
+ if (write_stat >= 0) {
+ size -= write_stat;
+ todo = size;
+ bufindex += write_stat;
+ } else if (ETEST()) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+#ifdef SUNSYSV
+ } else if (ECHECK(0)) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+#endif
+#ifdef ESZTEST
+ } else if (ESZTEST()) {
+ if (todo > 1)
+ todo >>= 1;
+ else {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+ }
+#endif
+ } else if (!ECHECK(EINTR)) {
+ /* Write failed! */
+ /* errno set by write system call. */
+ _XIOError(dpy);
+ }
+ }
+ dpy->last_req = (char *)&_dummy_request;
+ if ((dpy->request - dpy->last_request_read) >= SEQLIMIT &&
+ !(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->synchandler = _XSeqSyncFunction;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->bufptr = dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags &= ~XlibDisplayWriting;
+#endif
+}
+
+int
+_XEventsQueued(
+ register Display *dpy,
+ int mode)
+{
+ register int len;
+ BytesReadable_t pend;
+ _XAlignedBuffer buf;
+ register xReply *rep;
+ char *read_buf;
+#ifdef XTHREADS
+ int entry_event_serial_num;
+ struct _XCVList *cvl = NULL;
+ xthread_t self;
+
+#ifdef XTHREADS_DEBUG
+ printf("_XEventsQueued called in thread %x\n", XThread_Self());
+#endif
+#endif /* XTHREADS*/
+
+ if (mode == QueuedAfterFlush)
+ {
+ _XFlush(dpy);
+ if (dpy->qlen)
+ return(dpy->qlen);
+ }
+ if (dpy->flags & XlibDisplayIOError) return(dpy->qlen);
+
+#ifdef XTHREADS
+ /* create our condition variable and append to list,
+ * unless we were called from within XProcessInternalConnection
+ * or XLockDisplay
+ */
+ xthread_clear_id(self);
+ if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
+ || xthread_have_id (dpy->lock->locking_thread)))
+ /* some thread is in XProcessInternalConnection or XLockDisplay
+ so we have to see if we are it */
+ self = XThread_Self();
+ if (!xthread_have_id(self)
+ || (!xthread_equal(self, dpy->lock->conni_thread)
+ && !xthread_equal(self, dpy->lock->locking_thread))) {
+ /* In the multi-threaded case, if there is someone else
+ reading events, then there aren't any available, so
+ we just return. If we waited we would block.
+ */
+ if (dpy->lock && dpy->lock->event_awaiters)
+ return dpy->qlen;
+ /* nobody here but us, so lock out any newcomers */
+ cvl = QueueEventReaderLock(dpy);
+ }
+
+ while (dpy->lock && cvl && dpy->lock->reply_first) {
+ /* note which events we have already seen so we'll know
+ if _XReply (in another thread) reads one */
+ entry_event_serial_num = dpy->next_event_serial_num;
+ ConditionWait(dpy, cvl->cv);
+ /* did _XReply read an event we can return? */
+ if (_XNewerQueuedEvent(dpy, entry_event_serial_num))
+ {
+ UnlockNextEventReader(dpy);
+ return 0;
+ }
+ }
+#endif /* XTHREADS*/
+
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+ _XIOError(dpy);
+#ifdef XCONN_CHECK_FREQ
+ /* This is a crock, required because FIONREAD or equivalent is
+ * not guaranteed to detect a broken connection.
+ */
+ if (!pend && !dpy->qlen && ++dpy->conn_checker >= XCONN_CHECK_FREQ)
+ {
+ int result;
+#ifdef USE_POLL
+ struct pollfd filedes;
+#else
+ fd_set r_mask;
+ static struct timeval zero_time;
+#endif
+
+ dpy->conn_checker = 0;
+#ifdef USE_POLL
+ filedes.fd = dpy->fd;
+ filedes.events = POLLIN;
+ if ((result = poll(&filedes, 1, 0)))
+#else
+ FD_ZERO(&r_mask);
+ FD_SET(dpy->fd, &r_mask);
+ if ((result = Select(dpy->fd + 1, &r_mask, NULL, NULL, &zero_time)))
+#endif
+ {
+ if (result > 0)
+ {
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+ _XIOError(dpy);
+ /* we should not get zero, if we do, force a read */
+ if (!pend)
+ pend = SIZEOF(xReply);
+ }
+ else if (result < 0 && !ECHECK(EINTR))
+ _XIOError(dpy);
+ }
+ }
+#endif /* XCONN_CHECK_FREQ */
+ if (!(len = pend)) {
+ /* _XFlush can enqueue events */
+#ifdef XTHREADS
+ if (cvl)
+#endif
+ {
+ UnlockNextEventReader(dpy);
+ }
+ return(dpy->qlen);
+ }
+ /* Force a read if there is not enough data. Otherwise,
+ * a select() loop at a higher-level will spin undesirably,
+ * and we've seen at least one OS that appears to not update
+ * the result from FIONREAD once it has returned nonzero.
+ */
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ read_buf = (char *)dpy->lock->reply_awaiters->buf;
+ len = SIZEOF(xReply);
+ } else
+#endif /* XTHREADS*/
+ {
+ read_buf = buf.buf;
+
+ if (len < SIZEOF(xReply)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ )
+ len = SIZEOF(xReply);
+ else if (len > BUFSIZE)
+ len = BUFSIZE;
+ len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
+ }
+#ifdef XCONN_CHECK_FREQ
+ dpy->conn_checker = 0;
+#endif
+
+ (void) _XRead (dpy, read_buf, (long) len);
+
+#ifdef XTHREADS
+ /* what did we actually read: reply or event? */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ if (((xReply *)read_buf)->generic.type == X_Reply ||
+ ((xReply *)read_buf)->generic.type == X_Error)
+ {
+ dpy->lock->reply_was_read = True;
+ dpy->lock->reply_first = True;
+ if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
+ memcpy(dpy->lock->reply_awaiters->buf, read_buf,
+ len);
+ if (cvl) {
+ UnlockNextEventReader(dpy);
+ }
+ return(dpy->qlen); /* we read, so we can return */
+ } else if (read_buf != buf.buf)
+ memcpy(buf.buf, read_buf, len);
+ }
+#endif /* XTHREADS*/
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ int tmp = len;
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &tmp, True));
+ len = tmp;
+ pend = len;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *)rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE
+
+#ifdef XTHREADS
+ if (cvl)
+#endif
+ {
+ UnlockNextEventReader(dpy);
+ }
+ return(dpy->qlen);
+}
+
+/* _XReadEvents - Flush the output queue,
+ * then read as many events as possible (but at least 1) and enqueue them
+ */
+void _XReadEvents(
+ register Display *dpy)
+{
+ _XAlignedBuffer buf;
+ BytesReadable_t pend;
+ int len;
+ register xReply *rep;
+ Bool not_yet_flushed = True;
+ char *read_buf;
+ int i;
+ int entry_event_serial_num = dpy->next_event_serial_num;
+#ifdef XTHREADS
+ struct _XCVList *cvl = NULL;
+ xthread_t self;
+
+#ifdef XTHREADS_DEBUG
+ printf("_XReadEvents called in thread %x\n",
+ XThread_Self());
+#endif
+ /* create our condition variable and append to list,
+ * unless we were called from within XProcessInternalConnection
+ * or XLockDisplay
+ */
+ xthread_clear_id(self);
+ if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
+ || xthread_have_id (dpy->lock->locking_thread)))
+ /* some thread is in XProcessInternalConnection or XLockDisplay
+ so we have to see if we are it */
+ self = XThread_Self();
+ if (!xthread_have_id(self)
+ || (!xthread_equal(self, dpy->lock->conni_thread)
+ && !xthread_equal(self, dpy->lock->locking_thread)))
+ cvl = QueueEventReaderLock(dpy);
+#endif /* XTHREADS */
+
+ do {
+#ifdef XTHREADS
+ /* if it is not our turn to read an event off the wire,
+ wait til we're at head of list */
+ if (dpy->lock && cvl &&
+ (dpy->lock->event_awaiters != cvl ||
+ dpy->lock->reply_first)) {
+ ConditionWait(dpy, cvl->cv);
+ continue;
+ }
+#endif /* XTHREADS */
+ /* find out how much data can be read */
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+ _XIOError(dpy);
+ len = pend;
+
+ /* must read at least one xEvent; if none is pending, then
+ we'll just flush and block waiting for it */
+ if (len < SIZEOF(xEvent)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ ) {
+ len = SIZEOF(xEvent);
+ /* don't flush until the first time we would block */
+ if (not_yet_flushed) {
+ _XFlush (dpy);
+ if (_XNewerQueuedEvent(dpy, entry_event_serial_num)) {
+ /* _XReply has read an event for us */
+ goto got_event;
+ }
+ not_yet_flushed = False;
+ }
+ }
+
+#ifdef XTHREADS
+ /* If someone is waiting for a reply, gamble that
+ the reply will be the next thing on the wire
+ and read it into their buffer. */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ read_buf = (char *)dpy->lock->reply_awaiters->buf;
+ len = SIZEOF(xReply);
+ } else
+#endif /* XTHREADS*/
+ {
+ read_buf = buf.buf;
+
+ /* but we won't read more than the max buffer size */
+ if (len > BUFSIZE)
+ len = BUFSIZE;
+
+ /* round down to an integral number of XReps */
+ len = (len / SIZEOF(xEvent)) * SIZEOF(xEvent);
+ }
+
+#ifdef XTHREADS
+ if (xthread_have_id(self))
+ /* save value we may have to stick in conni_thread */
+ dpy->lock->reading_thread = self;
+#endif /* XTHREADS */
+ dpy->flags |= XlibDisplayReadEvents;
+ i = _XRead (dpy, read_buf, (long) len);
+ dpy->flags &= ~XlibDisplayReadEvents;
+ if (i == -2) {
+ /* special flag from _XRead to say that internal connection has
+ done XPutBackEvent. Which we can use so we're done. */
+ got_event:
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->lock_wait) {
+ if (dpy->lock->event_awaiters != cvl)
+ /* since it is not us, must be user lock thread */
+ ConditionSignal(dpy,
+ dpy->lock->event_awaiters->cv);
+ (*dpy->lock->lock_wait)(dpy);
+ continue;
+ }
+#endif
+ break;
+ }
+#ifdef XTHREADS
+ if (xthread_have_id(self))
+ xthread_clear_id(dpy->lock->reading_thread);
+
+ /* what did we actually read: reply or event? */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ if (((xReply *)read_buf)->generic.type == X_Reply ||
+ ((xReply *)read_buf)->generic.type == X_Error)
+ {
+ dpy->lock->reply_was_read = True;
+ dpy->lock->reply_first = True;
+ if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
+ memcpy(dpy->lock->reply_awaiters->buf,
+ read_buf, len);
+ ConditionSignal(dpy, dpy->lock->reply_awaiters->cv);
+ continue;
+ } else if (read_buf != buf.buf)
+ memcpy(buf.buf, read_buf, len);
+ }
+#endif /* XTHREADS */
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &len, True));
+ pend = len;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *) rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE;
+ } while (!_XNewerQueuedEvent(dpy, entry_event_serial_num));
+
+ UnlockNextEventReader(dpy);
+}
+
+/*
+ * _XRead - Read bytes from the socket taking into account incomplete
+ * reads. This routine may have to be reworked if int < long.
+ */
+int _XRead(
+ register Display *dpy,
+ register char *data,
+ register long size)
+{
+ register long bytes_read;
+#ifdef XTHREADS
+ int original_size = size;
+#endif
+
+ if ((dpy->flags & XlibDisplayIOError) || size == 0)
+ return 0;
+ ESET(0);
+ while ((bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size))
+ != size) {
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ data += bytes_read;
+ }
+ else if (ETEST()) {
+ if (_XWaitForReadable(dpy) == -2)
+ return -2; /* internal connection did XPutBackEvent */
+ ESET(0);
+ }
+#ifdef SUNSYSV
+ else if (ECHECK(0)) {
+ if (_XWaitForReadable(dpy) == -2)
+ return -2; /* internal connection did XPutBackEvent */
+ }
+#endif
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ ESET(EPIPE);
+ _XIOError(dpy);
+ }
+
+ else /* bytes_read is less than 0; presumably -1 */ {
+ /* If it's a system call interrupt, it's not an error. */
+ if (!ECHECK(EINTR))
+ _XIOError(dpy);
+ }
+ }
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_bytes_left > 0)
+ {
+ dpy->lock->reply_bytes_left -= original_size;
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ }
+#endif /* XTHREADS*/
+ return 0;
+}
+
+#ifdef LONG64
+void _XRead32(
+ Display *dpy,
+ register long *data,
+ long len)
+{
+ register int *buf;
+ register long i;
+
+ if (len) {
+ (void) _XRead(dpy, (char *)data, len);
+ i = len >> 2;
+ buf = (int *)data + i;
+ data += i;
+ while (--i >= 0)
+ *--data = *--buf;
+ }
+}
+#endif /* LONG64 */
+
+#ifdef WORD64
+
+/*
+ * XXX This is a *really* stupid way of doing this....
+ * PACKBUFFERSIZE must be a multiple of 4.
+ */
+
+#define PACKBUFFERSIZE 4096
+
+
+/*
+ * _XRead32 - Read bytes from the socket unpacking each 32 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static void _doXRead32(
+ register Display *dpy,
+ register long *data
+ register long size,
+ register char *packbuffer)
+{
+ long *lpack,*lp;
+ long mask32 = 0x00000000ffffffff;
+ long maskw, nwords, i, bits;
+
+ _XReadPad (dpy, packbuffer, size);
+
+ lp = data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 2;
+ bits = 32;
+
+ for(i=0;i<nwords;i++){
+ maskw = mask32 << bits;
+ *lp++ = ( *lpack & maskw ) >> bits;
+ bits = bits ^32;
+ if(bits){
+ lpack++;
+ }
+ }
+}
+
+void _XRead32(
+ Display *dpy,
+ long *data,
+ long len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 2;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ _doXRead32 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) _doXRead32 (dpy, data, len, packbuffer);
+}
+
+
+
+/*
+ * _XRead16 - Read bytes from the socket unpacking each 16 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static _doXRead16(
+ register Display *dpy,
+ register short *data,
+ register long size,
+ char *packbuffer)
+{
+ long *lpack,*lp;
+ long mask16 = 0x000000000000ffff;
+ long maskw, nwords, i, bits;
+
+ (void) _XRead(dpy,packbuffer,size); /* don't do a padded read... */
+
+ lp = (long *) data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 1; /* number of 16 bit words to be unpacked */
+ bits = 48;
+ for(i=0;i<nwords;i++){
+ maskw = mask16 << bits;
+ *lp++ = ( *lpack & maskw ) >> bits;
+ bits -= 16;
+ if(bits < 0){
+ lpack++;
+ bits = 48;
+ }
+ }
+}
+
+void _XRead16(
+ Display *dpy,
+ short *data,
+ long len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 1;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ _doXRead16 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) _doXRead16 (dpy, data, len, packbuffer);
+}
+
+void _XRead16Pad(
+ Display *dpy,
+ short *data,
+ long size)
+{
+ int slop = (size & 3);
+ short slopbuf[3];
+
+ _XRead16 (dpy, data, size);
+ if (slop > 0) {
+ _XRead16 (dpy, slopbuf, 4 - slop);
+ }
+}
+#endif /* WORD64 */
+
+
+/*
+ * _XReadPad - Read bytes from the socket taking into account incomplete
+ * reads. If the number of bytes is not 0 mod 4, read additional pad
+ * bytes. This routine may have to be reworked if int < long.
+ */
+void _XReadPad(
+ register Display *dpy,
+ register char *data,
+ register long size)
+{
+ register long bytes_read;
+ struct iovec iov[2];
+ char pad[3];
+#ifdef XTHREADS
+ int original_size;
+#endif
+
+ if ((dpy->flags & XlibDisplayIOError) || size == 0) return;
+ iov[0].iov_len = (int)size;
+ iov[0].iov_base = data;
+ /*
+ * The following hack is used to provide 32 bit long-word
+ * aligned padding. The [1] vector is of length 0, 1, 2, or 3,
+ * whatever is needed.
+ */
+
+ iov[1].iov_len = -size & 3;
+ iov[1].iov_base = pad;
+ size += iov[1].iov_len;
+#ifdef XTHREADS
+ original_size = size;
+#endif
+ ESET(0);
+ while ((bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2)) != size) {
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ if (iov[0].iov_len < bytes_read) {
+ int pad_bytes_read = bytes_read - iov[0].iov_len;
+ iov[1].iov_len -= pad_bytes_read;
+ iov[1].iov_base =
+ (char *)iov[1].iov_base + pad_bytes_read;
+ iov[0].iov_len = 0;
+ }
+ else {
+ iov[0].iov_len -= bytes_read;
+ iov[0].iov_base = (char *)iov[0].iov_base + bytes_read;
+ }
+ }
+ else if (ETEST()) {
+ _XWaitForReadable(dpy);
+ ESET(0);
+ }
+#ifdef SUNSYSV
+ else if (ECHECK(0)) {
+ _XWaitForReadable(dpy);
+ }
+#endif
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ ESET(EPIPE);
+ _XIOError(dpy);
+ }
+
+ else /* bytes_read is less than 0; presumably -1 */ {
+ /* If it's a system call interrupt, it's not an error. */
+ if (!ECHECK(EINTR))
+ _XIOError(dpy);
+ }
+ }
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_bytes_left > 0)
+ {
+ dpy->lock->reply_bytes_left -= original_size;
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ }
+#endif /* XTHREADS*/
+}
+
+/*
+ * _XSend - Flush the buffer and send the client data. 32 bit word aligned
+ * transmission is used, if size is not 0 mod 4, extra bytes are transmitted.
+ * This routine may have to be reworked if int < long;
+ */
+void
+_XSend (
+ register Display *dpy,
+ _Xconst char *data,
+ register long size)
+{
+ struct iovec iov[3];
+ static char const pad[3] = {0, 0, 0};
+ /* XText8 and XText16 require that the padding bytes be zero! */
+
+ long skip, dbufsize, padsize, total, todo;
+ _XExtension *ext;
+
+ if (!size || (dpy->flags & XlibDisplayIOError)) return;
+ dbufsize = dpy->bufptr - dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags |= XlibDisplayWriting;
+ /* make sure no one else can put in data */
+ dpy->bufptr = dpy->bufmax;
+#endif
+ padsize = -size & 3;
+ for (ext = dpy->flushes; ext; ext = ext->next_flush) {
+ (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, dbufsize);
+ (*ext->before_flush)(dpy, &ext->codes, (char *)data, size);
+ if (padsize)
+ (*ext->before_flush)(dpy, &ext->codes, pad, padsize);
+ }
+ skip = 0;
+ todo = total = dbufsize + size + padsize;
+
+ /*
+ * There are 3 pieces that may need to be written out:
+ *
+ * o whatever is in the display buffer
+ * o the data passed in by the user
+ * o any padding needed to 32bit align the whole mess
+ *
+ * This loop looks at all 3 pieces each time through. It uses skip
+ * to figure out whether or not a given piece is needed.
+ */
+ while (total) {
+ long before = skip; /* amount of whole thing written */
+ long remain = todo; /* amount to try this time, <= total */
+ int i = 0;
+ long len;
+
+ /* You could be very general here and have "in" and "out" iovecs
+ * and write a loop without using a macro, but what the heck. This
+ * translates to:
+ *
+ * how much of this piece is new?
+ * if more new then we are trying this time, clamp
+ * if nothing new
+ * then bump down amount already written, for next piece
+ * else put new stuff in iovec, will need all of next piece
+ *
+ * Note that todo had better be at least 1 or else we'll end up
+ * writing 0 iovecs.
+ */
+#define InsertIOV(pointer, length) \
+ len = (length) - before; \
+ if (len > remain) \
+ len = remain; \
+ if (len <= 0) { \
+ before = (-len); \
+ } else { \
+ iov[i].iov_len = len; \
+ iov[i].iov_base = (pointer) + before; \
+ i++; \
+ remain -= len; \
+ before = 0; \
+ }
+
+ InsertIOV (dpy->buffer, dbufsize)
+ InsertIOV ((char *)data, size)
+ InsertIOV ((char *)pad, padsize)
+
+ ESET(0);
+ if ((len = _X11TransWritev(dpy->trans_conn, iov, i)) >= 0) {
+ skip += len;
+ total -= len;
+ todo = total;
+ } else if (ETEST()) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+#ifdef SUNSYSV
+ } else if (ECHECK(0)) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+#endif
+#ifdef ESZTEST
+ } else if (ESZTEST()) {
+ if (todo > 1)
+ todo >>= 1;
+ else {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+ }
+#endif
+ } else if (!ECHECK(EINTR)) {
+ _XIOError(dpy);
+ }
+ }
+ dpy->last_req = (char *) & _dummy_request;
+ if ((dpy->request - dpy->last_request_read) >= SEQLIMIT &&
+ !(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->synchandler = _XSeqSyncFunction;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->bufptr = dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags &= ~XlibDisplayWriting;
+#endif
+ return;
+}
+
+static void
+_XGetMiscCode(
+ register Display *dpy)
+{
+ xQueryExtensionReply qrep;
+ register xQueryExtensionReq *qreq;
+ xXCMiscGetVersionReply vrep;
+ register xXCMiscGetVersionReq *vreq;
+
+ if (dpy->xcmisc_opcode)
+ return;
+ GetReq(QueryExtension, qreq);
+ qreq->nbytes = sizeof(XCMiscExtensionName) - 1;
+ qreq->length += (qreq->nbytes+(unsigned)3)>>2;
+ _XSend(dpy, XCMiscExtensionName, (long)qreq->nbytes);
+ if (!_XReply (dpy, (xReply *)&qrep, 0, xTrue))
+ dpy->xcmisc_opcode = -1;
+ else {
+ GetReq(XCMiscGetVersion, vreq);
+ vreq->reqType = qrep.major_opcode;
+ vreq->miscReqType = X_XCMiscGetVersion;
+ vreq->majorVersion = XCMiscMajorVersion;
+ vreq->minorVersion = XCMiscMinorVersion;
+ if (!_XReply (dpy, (xReply *)&vrep, 0, xTrue))
+ dpy->xcmisc_opcode = -1;
+ else
+ dpy->xcmisc_opcode = qrep.major_opcode;
+ }
+}
+
+static int
+_XIDHandler(
+ register Display *dpy)
+{
+ xXCMiscGetXIDRangeReply grep;
+ register xXCMiscGetXIDRangeReq *greq;
+
+ LockDisplay(dpy);
+ _XGetMiscCode(dpy);
+ if (dpy->xcmisc_opcode > 0) {
+ GetReq(XCMiscGetXIDRange, greq);
+ greq->reqType = dpy->xcmisc_opcode;
+ greq->miscReqType = X_XCMiscGetXIDRange;
+ if (_XReply (dpy, (xReply *)&grep, 0, xTrue) && grep.count) {
+ dpy->resource_id = ((grep.start_id - dpy->resource_base) >>
+ dpy->resource_shift);
+ dpy->resource_max = dpy->resource_id;
+ if (grep.count > 5)
+ dpy->resource_max += grep.count - 6;
+ dpy->resource_max <<= dpy->resource_shift;
+ }
+ }
+ if (dpy->flags & XlibDisplayPrivSync) {
+ dpy->synchandler = dpy->savedsynchandler;
+ dpy->flags &= ~XlibDisplayPrivSync;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
+/*
+ * _XAllocID - resource ID allocation routine.
+ */
+XID _XAllocID(
+ register Display *dpy)
+{
+ XID id;
+
+ id = dpy->resource_id << dpy->resource_shift;
+ if (id >= dpy->resource_max) {
+ if (!(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->synchandler = _XIDHandler;
+ dpy->resource_max = dpy->resource_mask + 1;
+ }
+ if (id <= dpy->resource_mask) {
+ dpy->resource_id++;
+ return (dpy->resource_base + id);
+ }
+ if (id != 0x10000000) {
+ (void) fprintf(stderr,
+ "Xlib: resource ID allocation space exhausted!\n");
+ id = 0x10000000;
+ dpy->resource_id = id >> dpy->resource_shift;
+ }
+ return id;
+}
+
+/*
+ * _XAllocIDs - multiple resource ID allocation routine.
+ */
+void _XAllocIDs(
+ register Display *dpy,
+ XID *ids,
+ int count)
+{
+ XID id;
+ int i;
+ xXCMiscGetXIDListReply grep;
+ register xXCMiscGetXIDListReq *greq;
+
+ id = dpy->resource_id << dpy->resource_shift;
+ if (dpy->resource_max <= dpy->resource_mask &&
+ id <= dpy->resource_mask &&
+ (dpy->resource_max - id) > ((count - 1) << dpy->resource_shift)) {
+ id += dpy->resource_base;
+ for (i = 0; i < count; i++) {
+ ids[i] = id;
+ id += (1 << dpy->resource_shift);
+ dpy->resource_id++;
+ }
+ return;
+ }
+ grep.count = 0;
+ _XGetMiscCode(dpy);
+ if (dpy->xcmisc_opcode > 0) {
+ GetReq(XCMiscGetXIDList, greq);
+ greq->reqType = dpy->xcmisc_opcode;
+ greq->miscReqType = X_XCMiscGetXIDList;
+ greq->count = count;
+ if (_XReply(dpy, (xReply *)&grep, 0, xFalse) && grep.count) {
+ _XRead32(dpy, (long *) ids, 4L * (long) (grep.count));
+ for (i = 0; i < grep.count; i++) {
+ id = (ids[i] - dpy->resource_base) >> dpy->resource_shift;
+ if (id >= dpy->resource_id)
+ dpy->resource_id = id;
+ }
+ if (id >= dpy->resource_max) {
+ if (!(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->synchandler = _XIDHandler;
+ dpy->resource_max = dpy->resource_mask + 1;
+ }
+ }
+ }
+ for (i = grep.count; i < count; i++)
+ ids[i] = XAllocID(dpy);
+}
+
+/*
+ * The hard part about this is that we only get 16 bits from a reply.
+ * We have three values that will march along, with the following invariant:
+ * dpy->last_request_read <= rep->sequenceNumber <= dpy->request
+ * We have to keep
+ * dpy->request - dpy->last_request_read < 2^16
+ * or else we won't know for sure what value to use in events. We do this
+ * by forcing syncs when we get close.
+ */
+
+unsigned long
+_XSetLastRequestRead(
+ register Display *dpy,
+ register xGenericReply *rep)
+{
+ register unsigned long newseq, lastseq;
+
+ lastseq = dpy->last_request_read;
+ /*
+ * KeymapNotify has no sequence number, but is always guaranteed
+ * to immediately follow another event, except when generated via
+ * SendEvent (hmmm).
+ */
+ if ((rep->type & 0x7f) == KeymapNotify)
+ return(lastseq);
+
+ newseq = (lastseq & ~((unsigned long)0xffff)) | rep->sequenceNumber;
+
+ if (newseq < lastseq) {
+ newseq += 0x10000;
+ if (newseq > dpy->request) {
+ (void) fprintf (stderr,
+ "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
+ newseq, dpy->request,
+ (unsigned int) rep->type);
+ newseq -= 0x10000;
+ }
+ }
+
+ dpy->last_request_read = newseq;
+ return(newseq);
+}
+
+/*
+ * _XReply - Wait for a reply packet and copy its contents into the
+ * specified rep. Meanwhile we must handle error and event packets that
+ * we may encounter.
+ */
+Status
+_XReply (
+ register Display *dpy,
+ register xReply *rep,
+ int extra, /* number of 32-bit words expected after the reply */
+ Bool discard) /* should I discard data following "extra" words? */
+{
+ /* Pull out the serial number now, so that (currently illegal) requests
+ * generated by an error handler don't confuse us.
+ */
+ unsigned long cur_request = dpy->request;
+#ifdef XTHREADS
+ struct _XCVList *cvl;
+#endif
+
+ if (dpy->flags & XlibDisplayIOError)
+ return 0;
+
+#ifdef XTHREADS
+ /* create our condition variable and append to list */
+ cvl = QueueReplyReaderLock(dpy);
+ if (cvl) {
+ cvl->buf = rep;
+ if (dpy->lock->reply_awaiters == cvl && !dpy->lock->event_awaiters)
+ dpy->lock->reply_first = True;
+ }
+
+#ifdef XTHREADS_DEBUG
+ printf("_XReply called in thread %x, adding %x to cvl\n",
+ XThread_Self(), cvl);
+#endif
+
+ _XFlushInt(dpy, cvl ? cvl->cv : NULL);
+ /* if it is not our turn to read a reply off the wire,
+ * wait til we're at head of list. if there is an event waiter,
+ * and our reply hasn't been read, they'll be in select and will
+ * hand control back to us next.
+ */
+ if(dpy->lock &&
+ (dpy->lock->reply_awaiters != cvl || !dpy->lock->reply_first)) {
+ ConditionWait(dpy, cvl->cv);
+ }
+ dpy->flags |= XlibDisplayReply;
+#else /* XTHREADS else */
+ _XFlush(dpy);
+#endif
+
+ for (;;) {
+#ifdef XTHREADS
+ /* Did another thread's _XReadEvents get our reply by accident? */
+ if (!dpy->lock || !dpy->lock->reply_was_read)
+#endif
+ (void) _XRead(dpy, (char *)rep, (long)SIZEOF(xReply));
+#ifdef XTHREADS
+ if (dpy->lock)
+ dpy->lock->reply_was_read = False;
+#endif
+
+ switch ((int)rep->generic.type) {
+
+ case X_Reply:
+ /* Reply received. Fast update for synchronous replies,
+ * but deal with multiple outstanding replies.
+ */
+ if (rep->generic.sequenceNumber == (cur_request & 0xffff))
+ dpy->last_request_read = cur_request;
+ else {
+ int pend = SIZEOF(xReply);
+ if (_XAsyncReply(dpy, rep, (char *)rep, &pend, False)
+ != (char *)rep)
+ continue;
+ }
+ if (extra <= rep->generic.length) {
+ if (extra > 0)
+ /*
+ * Read the extra data into storage immediately
+ * following the GenericReply structure.
+ */
+ (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
+ ((long)extra) << 2);
+ if (discard) {
+ if (extra < rep->generic.length)
+ _XEatData(dpy, (rep->generic.length - extra) << 2);
+ }
+#ifdef XTHREADS
+ if (dpy->lock) {
+ if (discard) {
+ dpy->lock->reply_bytes_left = 0;
+ } else {
+ dpy->lock->reply_bytes_left =
+ (rep->generic.length - extra) << 2;
+ }
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ } else
+ dpy->flags &= ~XlibDisplayReply;
+#endif
+ return 1;
+ }
+ /*
+ *if we get here, then extra > rep->generic.length--meaning we
+ * read a reply that's shorter than we expected. This is an
+ * error, but we still need to figure out how to handle it...
+ */
+ (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
+ ((long) rep->generic.length) << 2);
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ _XIOError (dpy);
+ return (0);
+
+ case X_Error:
+ {
+ register _XExtension *ext;
+ register Bool ret = False;
+ int ret_code;
+ xError *err = (xError *) rep;
+ unsigned long serial;
+
+ dpy->flags &= ~XlibDisplayReply;
+ serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
+ if (serial == cur_request)
+ /* do not die on "no such font", "can't allocate",
+ "can't grab" failures */
+ switch ((int)err->errorCode) {
+ case BadName:
+ switch (err->majorCode) {
+ case X_LookupColor:
+ case X_AllocNamedColor:
+ UnlockNextReplyReader(dpy);
+ return(0);
+ }
+ break;
+ case BadFont:
+ if (err->majorCode == X_QueryFont) {
+ UnlockNextReplyReader(dpy);
+ return (0);
+ }
+ break;
+ case BadAlloc:
+ case BadAccess:
+ UnlockNextReplyReader(dpy);
+ return (0);
+ }
+ /*
+ * we better see if there is an extension who may
+ * want to suppress the error.
+ */
+ for (ext = dpy->ext_procs; !ret && ext; ext = ext->next) {
+ if (ext->error)
+ ret = (*ext->error)(dpy, err, &ext->codes, &ret_code);
+ }
+ if (!ret) {
+ _XError(dpy, err);
+ ret_code = 0;
+ }
+ if (serial == cur_request) {
+ UnlockNextReplyReader(dpy);
+ return(ret_code);
+ }
+
+ } /* case X_Error */
+ break;
+ default:
+ _XEnq(dpy, (xEvent *) rep);
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->event_awaiters)
+ ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
+#endif
+ break;
+ }
+ }
+}
+
+static char *
+_XAsyncReply(
+ Display *dpy,
+ register xReply *rep,
+ char *buf,
+ register int *lenp,
+ Bool discard)
+{
+ register _XAsyncHandler *async, *next;
+ register int len;
+ register Bool consumed = False;
+ char *nbuf;
+
+ (void) _XSetLastRequestRead(dpy, &rep->generic);
+ len = SIZEOF(xReply) + (rep->generic.length << 2);
+ if (len < SIZEOF(xReply)) {
+ _XIOError (dpy);
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+
+ for (async = dpy->async_handlers; async; async = next) {
+ next = async->next;
+ if ((consumed = (*async->handler)(dpy, rep, buf, *lenp, async->data)))
+ break;
+ }
+ if (!consumed) {
+ if (!discard)
+ return buf;
+ (void) fprintf(stderr,
+ "Xlib: unexpected async reply (sequence 0x%lx)!\n",
+ dpy->last_request_read);
+#ifdef XTHREADS
+#ifdef XTHREADS_DEBUG
+ printf("thread %x, unexpected async reply\n", XThread_Self());
+#endif
+#endif
+ if (len > *lenp)
+ _XEatData(dpy, len - *lenp);
+ }
+ if (len < SIZEOF(xReply))
+ {
+ _XIOError (dpy);
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+ if (len >= *lenp) {
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+ *lenp -= len;
+ buf += len;
+ len = *lenp;
+ nbuf = buf;
+ while (len > SIZEOF(xReply)) {
+ if (*buf == X_Reply)
+ return nbuf;
+ buf += SIZEOF(xReply);
+ len -= SIZEOF(xReply);
+ }
+ if (len > 0 && len < SIZEOF(xReply)) {
+ buf = nbuf;
+ len = SIZEOF(xReply) - len;
+ nbuf -= len;
+ memmove(nbuf, buf, *lenp);
+ (void) _XRead(dpy, nbuf + *lenp, (long)len);
+ *lenp += len;
+ }
+ return nbuf;
+}
+
+/*
+ * Support for internal connections, such as an IM might use.
+ * By Stephen Gildea, X Consortium, September 1993
+ */
+
+/* _XRegisterInternalConnection
+ * Each IM (or Xlib extension) that opens a file descriptor that Xlib should
+ * include in its select/poll mask must call this function to register the
+ * fd with Xlib. Any XConnectionWatchProc registered by XAddConnectionWatch
+ * will also be called.
+ *
+ * Whenever Xlib detects input available on fd, it will call callback
+ * with call_data to process it. If non-Xlib code calls select/poll
+ * and detects input available, it must call XProcessInternalConnection,
+ * which will call the associated callback.
+ *
+ * Non-Xlib code can learn about these additional fds by calling
+ * XInternalConnectionNumbers or, more typically, by registering
+ * a XConnectionWatchProc with XAddConnectionWatch
+ * to be called when fds are registered or unregistered.
+ *
+ * Returns True if registration succeeded, False if not, typically
+ * because could not allocate memory.
+ * Assumes Display locked when called.
+ */
+Status
+_XRegisterInternalConnection(
+ Display* dpy,
+ int fd,
+ _XInternalConnectionProc callback,
+ XPointer call_data
+)
+{
+ struct _XConnectionInfo *new_conni, **iptr;
+ struct _XConnWatchInfo *watchers;
+ XPointer *wd;
+
+ new_conni = (struct _XConnectionInfo*)Xmalloc(sizeof(struct _XConnectionInfo));
+ if (!new_conni)
+ return 0;
+ new_conni->watch_data = (XPointer *)Xmalloc(dpy->watcher_count * sizeof(XPointer));
+ if (!new_conni->watch_data) {
+ Xfree(new_conni);
+ return 0;
+ }
+ new_conni->fd = fd;
+ new_conni->read_callback = callback;
+ new_conni->call_data = call_data;
+ new_conni->next = NULL;
+ /* link new structure onto end of list */
+ for (iptr = &dpy->im_fd_info; *iptr; iptr = &(*iptr)->next)
+ ;
+ *iptr = new_conni;
+ dpy->im_fd_length++;
+ _XPollfdCacheAdd(dpy, fd);
+
+ for (watchers=dpy->conn_watchers, wd=new_conni->watch_data;
+ watchers;
+ watchers=watchers->next, wd++) {
+ *wd = NULL; /* for cleanliness */
+ (*watchers->fn) (dpy, watchers->client_data, fd, True, wd);
+ }
+
+ return 1;
+}
+
+/* _XUnregisterInternalConnection
+ * Each IM (or Xlib extension) that closes a file descriptor previously
+ * registered with _XRegisterInternalConnection must call this function.
+ * Any XConnectionWatchProc registered by XAddConnectionWatch
+ * will also be called.
+ *
+ * Assumes Display locked when called.
+ */
+void
+_XUnregisterInternalConnection(
+ Display* dpy,
+ int fd
+)
+{
+ struct _XConnectionInfo *info_list, **prev;
+ struct _XConnWatchInfo *watch;
+ XPointer *wd;
+
+ for (prev = &dpy->im_fd_info; (info_list = *prev);
+ prev = &info_list->next) {
+ if (info_list->fd == fd) {
+ *prev = info_list->next;
+ dpy->im_fd_length--;
+ for (watch=dpy->conn_watchers, wd=info_list->watch_data;
+ watch;
+ watch=watch->next, wd++) {
+ (*watch->fn) (dpy, watch->client_data, fd, False, wd);
+ }
+ if (info_list->watch_data)
+ Xfree (info_list->watch_data);
+ Xfree (info_list);
+ break;
+ }
+ }
+ _XPollfdCacheDel(dpy, fd);
+}
+
+/* XInternalConnectionNumbers
+ * Returns an array of fds and an array of corresponding call data.
+ * Typically a XConnectionWatchProc registered with XAddConnectionWatch
+ * will be used instead of this function to discover
+ * additional fds to include in the select/poll mask.
+ *
+ * The list is allocated with Xmalloc and should be freed by the caller
+ * with Xfree;
+ */
+Status
+XInternalConnectionNumbers(
+ Display *dpy,
+ int **fd_return,
+ int *count_return
+)
+{
+ int count;
+ struct _XConnectionInfo *info_list;
+ int *fd_list;
+
+ LockDisplay(dpy);
+ count = 0;
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next)
+ count++;
+ fd_list = (int*) Xmalloc (count * sizeof(int));
+ if (!fd_list) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ count = 0;
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ fd_list[count] = info_list->fd;
+ count++;
+ }
+ UnlockDisplay(dpy);
+
+ *fd_return = fd_list;
+ *count_return = count;
+ return 1;
+}
+
+static void _XProcessInternalConnection(
+ Display *dpy,
+ struct _XConnectionInfo *conn_info)
+{
+ dpy->flags |= XlibDisplayProcConni;
+#ifdef XTHREADS
+ if (dpy->lock) {
+ /* check cache to avoid call to thread_self */
+ if (xthread_have_id(dpy->lock->reading_thread))
+ dpy->lock->conni_thread = dpy->lock->reading_thread;
+ else
+ dpy->lock->conni_thread = XThread_Self();
+ }
+#endif /* XTHREADS */
+ UnlockDisplay(dpy);
+ (*conn_info->read_callback) (dpy, conn_info->fd, conn_info->call_data);
+ LockDisplay(dpy);
+#ifdef XTHREADS
+ if (dpy->lock)
+ xthread_clear_id(dpy->lock->conni_thread);
+#endif /* XTHREADS */
+ dpy->flags &= ~XlibDisplayProcConni;
+}
+
+/* XProcessInternalConnection
+ * Call the _XInternalConnectionProc registered by _XRegisterInternalConnection
+ * for this fd.
+ * The Display is NOT locked during the call.
+ */
+void
+XProcessInternalConnection(
+ Display* dpy,
+ int fd
+)
+{
+ struct _XConnectionInfo *info_list;
+
+ LockDisplay(dpy);
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ if (info_list->fd == fd) {
+ _XProcessInternalConnection(dpy, info_list);
+ break;
+ }
+ }
+ UnlockDisplay(dpy);
+}
+
+/* XAddConnectionWatch
+ * Register a callback to be called whenever _XRegisterInternalConnection
+ * or _XUnregisterInternalConnection is called.
+ * Callbacks are called with the Display locked.
+ * If any connections are already registered, the callback is immediately
+ * called for each of them.
+ */
+Status
+XAddConnectionWatch(
+ Display* dpy,
+ XConnectionWatchProc callback,
+ XPointer client_data
+)
+{
+ struct _XConnWatchInfo *new_watcher, **wptr;
+ struct _XConnectionInfo *info_list;
+ XPointer *wd_array;
+
+ LockDisplay(dpy);
+
+ /* allocate new watch data */
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ wd_array = (XPointer *)Xrealloc((char *)info_list->watch_data,
+ (dpy->watcher_count + 1) *
+ sizeof(XPointer));
+ if (!wd_array) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ wd_array[dpy->watcher_count] = NULL; /* for cleanliness */
+ }
+
+ new_watcher = (struct _XConnWatchInfo*)Xmalloc(sizeof(struct _XConnWatchInfo));
+ if (!new_watcher) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ new_watcher->fn = callback;
+ new_watcher->client_data = client_data;
+ new_watcher->next = NULL;
+
+ /* link new structure onto end of list */
+ for (wptr = &dpy->conn_watchers; *wptr; wptr = &(*wptr)->next)
+ ;
+ *wptr = new_watcher;
+ dpy->watcher_count++;
+
+ /* call new watcher on all currently registered fds */
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ (*callback) (dpy, client_data, info_list->fd, True,
+ info_list->watch_data + dpy->watcher_count - 1);
+ }
+
+ UnlockDisplay(dpy);
+ return 1;
+}
+
+/* XRemoveConnectionWatch
+ * Unregister a callback registered by XAddConnectionWatch.
+ * Both callback and client_data must match what was passed to
+ * XAddConnectionWatch.
+ */
+void
+XRemoveConnectionWatch(
+ Display* dpy,
+ XConnectionWatchProc callback,
+ XPointer client_data
+)
+{
+ struct _XConnWatchInfo *watch;
+ struct _XConnWatchInfo *previous = NULL;
+ struct _XConnectionInfo *conni;
+ int counter = 0;
+
+ LockDisplay(dpy);
+ for (watch=dpy->conn_watchers; watch; watch=watch->next) {
+ if (watch->fn == callback && watch->client_data == client_data) {
+ if (previous)
+ previous->next = watch->next;
+ else
+ dpy->conn_watchers = watch->next;
+ Xfree (watch);
+ dpy->watcher_count--;
+ /* remove our watch_data for each connection */
+ for (conni=dpy->im_fd_info; conni; conni=conni->next) {
+ /* don't bother realloc'ing; these arrays are small anyway */
+ /* overlapping */
+ memmove(conni->watch_data+counter,
+ conni->watch_data+counter+1,
+ dpy->watcher_count - counter);
+ }
+ break;
+ }
+ previous = watch;
+ counter++;
+ }
+ UnlockDisplay(dpy);
+}
+
+/* end of internal connections support */
+
+
+/* Read and discard "n" 8-bit bytes of data */
+
+void _XEatData(
+ Display *dpy,
+ register unsigned long n)
+{
+#define SCRATCHSIZE 2048
+ char buf[SCRATCHSIZE];
+
+ while (n > 0) {
+ register long bytes_read = (n > SCRATCHSIZE) ? SCRATCHSIZE : n;
+ (void) _XRead (dpy, buf, bytes_read);
+ n -= bytes_read;
+ }
+#undef SCRATCHSIZE
+}
+
+
+/*
+ * _XEnq - Place event packets on the display's queue.
+ * note that no squishing of move events in V11, since there
+ * is pointer motion hints....
+ */
+void _XEnq(
+ register Display *dpy,
+ register xEvent *event)
+{
+ register _XQEvent *qelt;
+
+ if ((qelt = dpy->qfree)) {
+ /* If dpy->qfree is non-NULL do this, else malloc a new one. */
+ dpy->qfree = qelt->next;
+ }
+ else if ((qelt =
+ (_XQEvent *) Xmalloc((unsigned)sizeof(_XQEvent))) == NULL) {
+ /* Malloc call failed! */
+ ESET(ENOMEM);
+ _XIOError(dpy);
+ }
+ qelt->next = NULL;
+ /* go call through display to find proper event reformatter */
+ if ((*dpy->event_vec[event->u.u.type & 0177])(dpy, &qelt->event, event)) {
+ qelt->qserial_num = dpy->next_event_serial_num++;
+ if (dpy->tail) dpy->tail->next = qelt;
+ else dpy->head = qelt;
+
+ dpy->tail = qelt;
+ dpy->qlen++;
+ } else {
+ /* ignored, or stashed away for many-to-one compression */
+ qelt->next = dpy->qfree;
+ dpy->qfree = qelt;
+ }
+}
+
+/*
+ * _XDeq - Remove event packet from the display's queue.
+ */
+void _XDeq(
+ register Display *dpy,
+ register _XQEvent *prev, /* element before qelt */
+ register _XQEvent *qelt) /* element to be unlinked */
+{
+ if (prev) {
+ if ((prev->next = qelt->next) == NULL)
+ dpy->tail = prev;
+ } else {
+ /* no prev, so removing first elt */
+ if ((dpy->head = qelt->next) == NULL)
+ dpy->tail = NULL;
+ }
+ qelt->qserial_num = 0;
+ qelt->next = dpy->qfree;
+ dpy->qfree = qelt;
+ dpy->qlen--;
+}
+
+/*
+ * EventToWire in separate file in that often not needed.
+ */
+
+/*ARGSUSED*/
+Bool
+_XUnknownWireEvent(
+ register Display *dpy, /* pointer to display structure */
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event) /* wire protocol event */
+{
+#ifdef notdef
+ (void) fprintf(stderr,
+ "Xlib: unhandled wire event! event number = %d, display = %x\n.",
+ event->u.u.type, dpy);
+#endif
+ return(False);
+}
+
+/*ARGSUSED*/
+Status
+_XUnknownNativeEvent(
+ register Display *dpy, /* pointer to display structure */
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event) /* wire protocol event */
+{
+#ifdef notdef
+ (void) fprintf(stderr,
+ "Xlib: unhandled native event! event number = %d, display = %x\n.",
+ re->type, dpy);
+#endif
+ return(0);
+}
+/*
+ * reformat a wire event into an XEvent structure of the right type.
+ */
+Bool
+_XWireToEvent(
+ register Display *dpy, /* pointer to display structure */
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event) /* wire protocol event */
+{
+
+ re->type = event->u.u.type & 0x7f;
+ ((XAnyEvent *)re)->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ ((XAnyEvent *)re)->send_event = ((event->u.u.type & 0x80) != 0);
+ ((XAnyEvent *)re)->display = dpy;
+
+ /* Ignore the leading bit of the event type since it is set when a
+ client sends an event rather than the server. */
+
+ switch (event-> u.u.type & 0177) {
+ case KeyPress:
+ case KeyRelease:
+ {
+ register XKeyEvent *ev = (XKeyEvent*) re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->keycode = event->u.u.detail;
+ }
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ {
+ register XButtonEvent *ev = (XButtonEvent *) re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->button = event->u.u.detail;
+ }
+ break;
+ case MotionNotify:
+ {
+ register XMotionEvent *ev = (XMotionEvent *)re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->is_hint = event->u.u.detail;
+ }
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ {
+ register XCrossingEvent *ev = (XCrossingEvent *) re;
+ ev->root = event->u.enterLeave.root;
+ ev->window = event->u.enterLeave.event;
+ ev->subwindow = event->u.enterLeave.child;
+ ev->time = event->u.enterLeave.time;
+ ev->x = cvtINT16toInt(event->u.enterLeave.eventX);
+ ev->y = cvtINT16toInt(event->u.enterLeave.eventY);
+ ev->x_root = cvtINT16toInt(event->u.enterLeave.rootX);
+ ev->y_root = cvtINT16toInt(event->u.enterLeave.rootY);
+ ev->state = event->u.enterLeave.state;
+ ev->mode = event->u.enterLeave.mode;
+ ev->same_screen = (event->u.enterLeave.flags &
+ ELFlagSameScreen) && True;
+ ev->focus = (event->u.enterLeave.flags &
+ ELFlagFocus) && True;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case FocusIn:
+ case FocusOut:
+ {
+ register XFocusChangeEvent *ev = (XFocusChangeEvent *) re;
+ ev->window = event->u.focus.window;
+ ev->mode = event->u.focus.mode;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case KeymapNotify:
+ {
+ register XKeymapEvent *ev = (XKeymapEvent *) re;
+ ev->window = None;
+ memcpy(&ev->key_vector[1],
+ (char *)((xKeymapEvent *) event)->map,
+ sizeof (((xKeymapEvent *) event)->map));
+ }
+ break;
+ case Expose:
+ {
+ register XExposeEvent *ev = (XExposeEvent *) re;
+ ev->window = event->u.expose.window;
+ ev->x = event->u.expose.x;
+ ev->y = event->u.expose.y;
+ ev->width = event->u.expose.width;
+ ev->height = event->u.expose.height;
+ ev->count = event->u.expose.count;
+ }
+ break;
+ case GraphicsExpose:
+ {
+ register XGraphicsExposeEvent *ev =
+ (XGraphicsExposeEvent *) re;
+ ev->drawable = event->u.graphicsExposure.drawable;
+ ev->x = event->u.graphicsExposure.x;
+ ev->y = event->u.graphicsExposure.y;
+ ev->width = event->u.graphicsExposure.width;
+ ev->height = event->u.graphicsExposure.height;
+ ev->count = event->u.graphicsExposure.count;
+ ev->major_code = event->u.graphicsExposure.majorEvent;
+ ev->minor_code = event->u.graphicsExposure.minorEvent;
+ }
+ break;
+ case NoExpose:
+ {
+ register XNoExposeEvent *ev = (XNoExposeEvent *) re;
+ ev->drawable = event->u.noExposure.drawable;
+ ev->major_code = event->u.noExposure.majorEvent;
+ ev->minor_code = event->u.noExposure.minorEvent;
+ }
+ break;
+ case VisibilityNotify:
+ {
+ register XVisibilityEvent *ev = (XVisibilityEvent *) re;
+ ev->window = event->u.visibility.window;
+ ev->state = event->u.visibility.state;
+ }
+ break;
+ case CreateNotify:
+ {
+ register XCreateWindowEvent *ev =
+ (XCreateWindowEvent *) re;
+ ev->window = event->u.createNotify.window;
+ ev->parent = event->u.createNotify.parent;
+ ev->x = cvtINT16toInt(event->u.createNotify.x);
+ ev->y = cvtINT16toInt(event->u.createNotify.y);
+ ev->width = event->u.createNotify.width;
+ ev->height = event->u.createNotify.height;
+ ev->border_width = event->u.createNotify.borderWidth;
+ ev->override_redirect = event->u.createNotify.override;
+ }
+ break;
+ case DestroyNotify:
+ {
+ register XDestroyWindowEvent *ev =
+ (XDestroyWindowEvent *) re;
+ ev->window = event->u.destroyNotify.window;
+ ev->event = event->u.destroyNotify.event;
+ }
+ break;
+ case UnmapNotify:
+ {
+ register XUnmapEvent *ev = (XUnmapEvent *) re;
+ ev->window = event->u.unmapNotify.window;
+ ev->event = event->u.unmapNotify.event;
+ ev->from_configure = event->u.unmapNotify.fromConfigure;
+ }
+ break;
+ case MapNotify:
+ {
+ register XMapEvent *ev = (XMapEvent *) re;
+ ev->window = event->u.mapNotify.window;
+ ev->event = event->u.mapNotify.event;
+ ev->override_redirect = event->u.mapNotify.override;
+ }
+ break;
+ case MapRequest:
+ {
+ register XMapRequestEvent *ev = (XMapRequestEvent *) re;
+ ev->window = event->u.mapRequest.window;
+ ev->parent = event->u.mapRequest.parent;
+ }
+ break;
+ case ReparentNotify:
+ {
+ register XReparentEvent *ev = (XReparentEvent *) re;
+ ev->event = event->u.reparent.event;
+ ev->window = event->u.reparent.window;
+ ev->parent = event->u.reparent.parent;
+ ev->x = cvtINT16toInt(event->u.reparent.x);
+ ev->y = cvtINT16toInt(event->u.reparent.y);
+ ev->override_redirect = event->u.reparent.override;
+ }
+ break;
+ case ConfigureNotify:
+ {
+ register XConfigureEvent *ev = (XConfigureEvent *) re;
+ ev->event = event->u.configureNotify.event;
+ ev->window = event->u.configureNotify.window;
+ ev->above = event->u.configureNotify.aboveSibling;
+ ev->x = cvtINT16toInt(event->u.configureNotify.x);
+ ev->y = cvtINT16toInt(event->u.configureNotify.y);
+ ev->width = event->u.configureNotify.width;
+ ev->height = event->u.configureNotify.height;
+ ev->border_width = event->u.configureNotify.borderWidth;
+ ev->override_redirect = event->u.configureNotify.override;
+ }
+ break;
+ case ConfigureRequest:
+ {
+ register XConfigureRequestEvent *ev =
+ (XConfigureRequestEvent *) re;
+ ev->window = event->u.configureRequest.window;
+ ev->parent = event->u.configureRequest.parent;
+ ev->above = event->u.configureRequest.sibling;
+ ev->x = cvtINT16toInt(event->u.configureRequest.x);
+ ev->y = cvtINT16toInt(event->u.configureRequest.y);
+ ev->width = event->u.configureRequest.width;
+ ev->height = event->u.configureRequest.height;
+ ev->border_width = event->u.configureRequest.borderWidth;
+ ev->value_mask = event->u.configureRequest.valueMask;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case GravityNotify:
+ {
+ register XGravityEvent *ev = (XGravityEvent *) re;
+ ev->window = event->u.gravity.window;
+ ev->event = event->u.gravity.event;
+ ev->x = cvtINT16toInt(event->u.gravity.x);
+ ev->y = cvtINT16toInt(event->u.gravity.y);
+ }
+ break;
+ case ResizeRequest:
+ {
+ register XResizeRequestEvent *ev =
+ (XResizeRequestEvent *) re;
+ ev->window = event->u.resizeRequest.window;
+ ev->width = event->u.resizeRequest.width;
+ ev->height = event->u.resizeRequest.height;
+ }
+ break;
+ case CirculateNotify:
+ {
+ register XCirculateEvent *ev = (XCirculateEvent *) re;
+ ev->window = event->u.circulate.window;
+ ev->event = event->u.circulate.event;
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case CirculateRequest:
+ {
+ register XCirculateRequestEvent *ev =
+ (XCirculateRequestEvent *) re;
+ ev->window = event->u.circulate.window;
+ ev->parent = event->u.circulate.event;
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case PropertyNotify:
+ {
+ register XPropertyEvent *ev = (XPropertyEvent *) re;
+ ev->window = event->u.property.window;
+ ev->atom = event->u.property.atom;
+ ev->time = event->u.property.time;
+ ev->state = event->u.property.state;
+ }
+ break;
+ case SelectionClear:
+ {
+ register XSelectionClearEvent *ev =
+ (XSelectionClearEvent *) re;
+ ev->window = event->u.selectionClear.window;
+ ev->selection = event->u.selectionClear.atom;
+ ev->time = event->u.selectionClear.time;
+ }
+ break;
+ case SelectionRequest:
+ {
+ register XSelectionRequestEvent *ev =
+ (XSelectionRequestEvent *) re;
+ ev->owner = event->u.selectionRequest.owner;
+ ev->requestor = event->u.selectionRequest.requestor;
+ ev->selection = event->u.selectionRequest.selection;
+ ev->target = event->u.selectionRequest.target;
+ ev->property = event->u.selectionRequest.property;
+ ev->time = event->u.selectionRequest.time;
+ }
+ break;
+ case SelectionNotify:
+ {
+ register XSelectionEvent *ev = (XSelectionEvent *) re;
+ ev->requestor = event->u.selectionNotify.requestor;
+ ev->selection = event->u.selectionNotify.selection;
+ ev->target = event->u.selectionNotify.target;
+ ev->property = event->u.selectionNotify.property;
+ ev->time = event->u.selectionNotify.time;
+ }
+ break;
+ case ColormapNotify:
+ {
+ register XColormapEvent *ev = (XColormapEvent *) re;
+ ev->window = event->u.colormap.window;
+ ev->colormap = event->u.colormap.colormap;
+ ev->new = event->u.colormap.new;
+ ev->state = event->u.colormap.state;
+ }
+ break;
+ case ClientMessage:
+ {
+ register int i;
+ register XClientMessageEvent *ev
+ = (XClientMessageEvent *) re;
+ ev->window = event->u.clientMessage.window;
+ ev->format = event->u.u.detail;
+ switch (ev->format) {
+ case 8:
+ ev->message_type = event->u.clientMessage.u.b.type;
+ for (i = 0; i < 20; i++)
+ ev->data.b[i] = event->u.clientMessage.u.b.bytes[i];
+ break;
+ case 16:
+ ev->message_type = event->u.clientMessage.u.s.type;
+ ev->data.s[0] = cvtINT16toShort(event->u.clientMessage.u.s.shorts0);
+ ev->data.s[1] = cvtINT16toShort(event->u.clientMessage.u.s.shorts1);
+ ev->data.s[2] = cvtINT16toShort(event->u.clientMessage.u.s.shorts2);
+ ev->data.s[3] = cvtINT16toShort(event->u.clientMessage.u.s.shorts3);
+ ev->data.s[4] = cvtINT16toShort(event->u.clientMessage.u.s.shorts4);
+ ev->data.s[5] = cvtINT16toShort(event->u.clientMessage.u.s.shorts5);
+ ev->data.s[6] = cvtINT16toShort(event->u.clientMessage.u.s.shorts6);
+ ev->data.s[7] = cvtINT16toShort(event->u.clientMessage.u.s.shorts7);
+ ev->data.s[8] = cvtINT16toShort(event->u.clientMessage.u.s.shorts8);
+ ev->data.s[9] = cvtINT16toShort(event->u.clientMessage.u.s.shorts9);
+ break;
+ case 32:
+ ev->message_type = event->u.clientMessage.u.l.type;
+ ev->data.l[0] = cvtINT32toLong(event->u.clientMessage.u.l.longs0);
+ ev->data.l[1] = cvtINT32toLong(event->u.clientMessage.u.l.longs1);
+ ev->data.l[2] = cvtINT32toLong(event->u.clientMessage.u.l.longs2);
+ ev->data.l[3] = cvtINT32toLong(event->u.clientMessage.u.l.longs3);
+ ev->data.l[4] = cvtINT32toLong(event->u.clientMessage.u.l.longs4);
+ break;
+ default: /* XXX should never occur */
+ break;
+ }
+ }
+ break;
+ case MappingNotify:
+ {
+ register XMappingEvent *ev = (XMappingEvent *)re;
+ ev->window = 0;
+ ev->first_keycode = event->u.mappingNotify.firstKeyCode;
+ ev->request = event->u.mappingNotify.request;
+ ev->count = event->u.mappingNotify.count;
+ }
+ break;
+ default:
+ return(_XUnknownWireEvent(dpy, re, event));
+ }
+ return(True);
+}
+
+
+/*
+ * _XDefaultIOError - Default fatal system error reporting routine. Called
+ * when an X internal system error is encountered.
+ */
+int _XDefaultIOError(
+ Display *dpy)
+{
+ if (ECHECK(EPIPE)) {
+ (void) fprintf (stderr,
+ "X connection to %s broken (explicit kill or server shutdown).\r\n",
+ DisplayString (dpy));
+ } else {
+ (void) fprintf (stderr,
+ "XIO: fatal IO error %d (%s) on X server \"%s\"\r\n",
+#ifdef WIN32
+ WSAGetLastError(), strerror(WSAGetLastError()),
+#else
+ errno, strerror (errno),
+#endif
+ DisplayString (dpy));
+ (void) fprintf (stderr,
+ " after %lu requests (%lu known processed) with %d events remaining.\r\n",
+ NextRequest(dpy) - 1, LastKnownRequestProcessed(dpy),
+ QLength(dpy));
+
+ }
+ exit(1);
+ return(0); /* dummy - function should never return */
+}
+
+
+static int _XPrintDefaultError(
+ Display *dpy,
+ XErrorEvent *event,
+ FILE *fp)
+{
+ char buffer[BUFSIZ];
+ char mesg[BUFSIZ];
+ char number[32];
+ char *mtype = "XlibMessage";
+ register _XExtension *ext = (_XExtension *)NULL;
+ _XExtension *bext = (_XExtension *)NULL;
+ XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
+ XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
+ (void) fprintf(fp, "%s: %s\n ", mesg, buffer);
+ XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->request_code);
+ if (event->request_code < 128) {
+ sprintf(number, "%d", event->request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
+ } else {
+ for (ext = dpy->ext_procs;
+ ext && (ext->codes.major_opcode != event->request_code);
+ ext = ext->next)
+ ;
+ if (ext)
+ strcpy(buffer, ext->name);
+ else
+ buffer[0] = '\0';
+ }
+ (void) fprintf(fp, " (%s)\n", buffer);
+ if (event->request_code >= 128) {
+ XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->minor_code);
+ if (ext) {
+ sprintf(mesg, "%s.%d", ext->name, event->minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
+ (void) fprintf(fp, " (%s)", buffer);
+ }
+ fputs("\n", fp);
+ }
+ if (event->error_code >= 128) {
+ /* kludge, try to find the extension that caused it */
+ buffer[0] = '\0';
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_string)
+ (*ext->error_string)(dpy, event->error_code, &ext->codes,
+ buffer, BUFSIZ);
+ if (buffer[0]) {
+ bext = ext;
+ break;
+ }
+ if (ext->codes.first_error &&
+ ext->codes.first_error < (int)event->error_code &&
+ (!bext || ext->codes.first_error > bext->codes.first_error))
+ bext = ext;
+ }
+ if (bext)
+ sprintf(buffer, "%s.%d", bext->name,
+ event->error_code - bext->codes.first_error);
+ else
+ strcpy(buffer, "Value");
+ XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
+ if (mesg[0]) {
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ /* let extensions try to print the values */
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_values)
+ (*ext->error_values)(dpy, event, fp);
+ }
+ } else if ((event->error_code == BadWindow) ||
+ (event->error_code == BadPixmap) ||
+ (event->error_code == BadCursor) ||
+ (event->error_code == BadFont) ||
+ (event->error_code == BadDrawable) ||
+ (event->error_code == BadColor) ||
+ (event->error_code == BadGC) ||
+ (event->error_code == BadIDChoice) ||
+ (event->error_code == BadValue) ||
+ (event->error_code == BadAtom)) {
+ if (event->error_code == BadValue)
+ XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
+ mesg, BUFSIZ);
+ else if (event->error_code == BadAtom)
+ XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
+ mesg, BUFSIZ);
+ else
+ XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->serial);
+ XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
+ mesg, BUFSIZ);
+ fputs("\n ", fp);
+ (void) fprintf(fp, mesg, dpy->request);
+ fputs("\n", fp);
+ if (event->error_code == BadImplementation) return 0;
+ return 1;
+}
+
+int _XDefaultError(
+ Display *dpy,
+ XErrorEvent *event)
+{
+ if (_XPrintDefaultError (dpy, event, stderr) == 0) return 0;
+ exit(1);
+ /*NOTREACHED*/
+}
+
+/*ARGSUSED*/
+Bool _XDefaultWireError(display, he, we)
+ Display *display;
+ XErrorEvent *he;
+ xError *we;
+{
+ return True;
+}
+
+/*
+ * _XError - upcall internal or user protocol error handler
+ */
+int _XError (
+ Display *dpy,
+ register xError *rep)
+{
+ /*
+ * X_Error packet encountered! We need to unpack the error before
+ * giving it to the user.
+ */
+ XEvent event; /* make it a large event */
+ register _XAsyncHandler *async, *next;
+
+ event.xerror.serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
+
+ for (async = dpy->async_handlers; async; async = next) {
+ next = async->next;
+ if ((*async->handler)(dpy, (xReply *)rep,
+ (char *)rep, SIZEOF(xError), async->data))
+ return 0;
+ }
+
+ event.xerror.display = dpy;
+ event.xerror.type = X_Error;
+ event.xerror.resourceid = rep->resourceID;
+ event.xerror.error_code = rep->errorCode;
+ event.xerror.request_code = rep->majorCode;
+ event.xerror.minor_code = rep->minorCode;
+ if (dpy->error_vec &&
+ !(*dpy->error_vec[rep->errorCode])(dpy, &event.xerror, rep))
+ return 0;
+ if (_XErrorFunction != NULL) {
+ int rtn_val;
+#ifdef XTHREADS
+ if (dpy->lock)
+ (*dpy->lock->user_lock_display)(dpy);
+ UnlockDisplay(dpy);
+#endif /* XTHREADS */
+ rtn_val = (*_XErrorFunction)(dpy, (XErrorEvent *)&event); /* upcall */
+#ifdef XTHREADS
+ LockDisplay(dpy);
+ if (dpy->lock)
+ (*dpy->lock->user_unlock_display)(dpy);
+#endif /* XTHREADS */
+ return rtn_val;
+ } else {
+ return _XDefaultError(dpy, (XErrorEvent *)&event);
+ }
+}
+
+/*
+ * _XIOError - call user connection error handler and exit
+ */
+int
+_XIOError (
+ Display *dpy)
+{
+ dpy->flags |= XlibDisplayIOError;
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+
+ if (_XIOErrorFunction != NULL)
+ (*_XIOErrorFunction)(dpy);
+ else
+ _XDefaultIOError(dpy);
+ exit (1);
+ return 0;
+}
+
+
+/*
+ * This routine can be used to (cheaply) get some memory within a single
+ * Xlib routine for scratch space. A single buffer is reused each time
+ * if possible. To be MT safe, you can only call this between a call to
+ * GetReq* and a call to Data* or _XSend*, or in a context when the thread
+ * is guaranteed to not unlock the display.
+ */
+char *_XAllocScratch(
+ register Display *dpy,
+ unsigned long nbytes)
+{
+ if (nbytes > dpy->scratch_length) {
+ if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer);
+ if ((dpy->scratch_buffer = Xmalloc((unsigned) nbytes)))
+ dpy->scratch_length = nbytes;
+ else dpy->scratch_length = 0;
+ }
+ return (dpy->scratch_buffer);
+}
+
+/*
+ * Scratch space allocator you can call any time, multiple times, and be
+ * MT safe, but you must hand the buffer back with _XFreeTemp.
+ */
+char *_XAllocTemp(
+ register Display *dpy,
+ unsigned long nbytes)
+{
+ char *buf;
+
+ buf = _XAllocScratch(dpy, nbytes);
+ dpy->scratch_buffer = NULL;
+ dpy->scratch_length = 0;
+ return buf;
+}
+
+void _XFreeTemp(
+ register Display *dpy,
+ char *buf,
+ unsigned long nbytes)
+{
+ if (dpy->scratch_buffer)
+ Xfree(dpy->scratch_buffer);
+ dpy->scratch_buffer = buf;
+ dpy->scratch_length = nbytes;
+}
+
+/*
+ * Given a visual id, find the visual structure for this id on this display.
+ */
+Visual *_XVIDtoVisual(
+ Display *dpy,
+ VisualID id)
+{
+ register int i, j, k;
+ register Screen *sp;
+ register Depth *dp;
+ register Visual *vp;
+ for (i = 0; i < dpy->nscreens; i++) {
+ sp = &dpy->screens[i];
+ for (j = 0; j < sp->ndepths; j++) {
+ dp = &sp->depths[j];
+ /* if nvisuals == 0 then visuals will be NULL */
+ for (k = 0; k < dp->nvisuals; k++) {
+ vp = &dp->visuals[k];
+ if (vp->visualid == id) return (vp);
+ }
+ }
+ }
+ return (NULL);
+}
+
+int
+XFree (void *data)
+{
+ Xfree (data);
+ return 1;
+}
+
+#ifdef _XNEEDBCOPYFUNC
+void _Xbcopy(b1, b2, length)
+ register char *b1, *b2;
+ register length;
+{
+ if (b1 < b2) {
+ b2 += length;
+ b1 += length;
+ while (length--)
+ *--b2 = *--b1;
+ } else {
+ while (length--)
+ *b2++ = *b1++;
+ }
+}
+#endif
+
+#ifdef DataRoutineIsProcedure
+void Data(
+ Display *dpy,
+ char *data,
+ long len)
+{
+ if (dpy->bufptr + (len) <= dpy->bufmax) {
+ memcpy(dpy->bufptr, data, (int)len);
+ dpy->bufptr += ((len) + 3) & ~3;
+ } else {
+ _XSend(dpy, data, len);
+ }
+}
+#endif /* DataRoutineIsProcedure */
+
+
+#ifdef LONG64
+int
+_XData32(
+ Display *dpy,
+ register long *data,
+ unsigned len)
+{
+ register int *buf;
+ register long i;
+
+ while (len) {
+ buf = (int *)dpy->bufptr;
+ i = dpy->bufmax - (char *)buf;
+ if (!i) {
+ _XFlush(dpy);
+ continue;
+ }
+ if (len < i)
+ i = len;
+ dpy->bufptr = (char *)buf + i;
+ len -= i;
+ i >>= 2;
+ while (--i >= 0)
+ *buf++ = *data++;
+ }
+ return 0;
+}
+#endif /* LONG64 */
+
+#ifdef WORD64
+
+/*
+ * XXX This is a *really* stupid way of doing this. It should just use
+ * dpy->bufptr directly, taking into account where in the word it is.
+ */
+
+/*
+ * Data16 - Place 16 bit data in the buffer.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static doData16(
+ register Display *dpy,
+ short *data,
+ unsigned len,
+ char *packbuffer)
+{
+ long *lp,*lpack;
+ long i, nwords,bits;
+ long mask16 = 0x000000000000ffff;
+
+ lp = (long *)data;
+ lpack = (long *)packbuffer;
+
+/* nwords is the number of 16 bit values to be packed,
+ * the low order 16 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 1;
+ bits = 48;
+
+ for(i=0;i<nwords;i++){
+ if (bits == 48) *lpack = 0;
+ *lpack ^= (*lp & mask16) << bits;
+ bits -= 16 ;
+ lp++;
+ if(bits < 0){
+ lpack++;
+ bits = 48;
+ }
+ }
+ Data(dpy, packbuffer, len);
+}
+
+_XData16 (
+ Display *dpy,
+ short *data,
+ unsigned len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 1;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ doData16 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) doData16 (dpy, data, len, packbuffer);
+}
+
+/*
+ * Data32 - Place 32 bit data in the buffer.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static doData32(
+ register Display *dpy
+ long *data,
+ unsigned len,
+ char *packbuffer)
+{
+ long *lp,*lpack;
+ long i,bits,nwords;
+ long mask32 = 0x00000000ffffffff;
+
+ lpack = (long *) packbuffer;
+ lp = data;
+
+/* nwords is the number of 32 bit values to be packed
+ * the low order 32 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 2;
+ bits = 32;
+
+ for(i=0;i<nwords;i++){
+ if (bits == 32) *lpack = 0;
+ *lpack ^= (*lp & mask32) << bits;
+ bits = bits ^32;
+ lp++;
+ if(bits)
+ lpack++;
+ }
+ Data(dpy, packbuffer, len);
+}
+
+void _XData32(
+ Display *dpy,
+ long *data,
+ unsigned len,
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 2;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ doData32 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) doData32 (dpy, data, len, packbuffer);
+}
+
+#endif /* WORD64 */
+
+
+/* Make sure this produces the same string as DefineLocal/DefineSelf in xdm.
+ * Otherwise, Xau will not be able to find your cookies in the Xauthority file.
+ *
+ * Note: POSIX says that the ``nodename'' member of utsname does _not_ have
+ * to have sufficient information for interfacing to the network,
+ * and so, you may be better off using gethostname (if it exists).
+ */
+
+#if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(USG) || defined(SVR4)
+#define NEED_UTSNAME
+#include <sys/utsname.h>
+#endif
+
+/*
+ * _XGetHostname - similar to gethostname but allows special processing.
+ */
+int _XGetHostname (
+ char *buf,
+ int maxlen)
+{
+ int len;
+
+#ifdef NEED_UTSNAME
+ struct utsname name;
+
+ if (maxlen <= 0 || buf == NULL)
+ return 0;
+
+ uname (&name);
+ len = strlen (name.nodename);
+ if (len >= maxlen) len = maxlen - 1;
+ strncpy (buf, name.nodename, len);
+ buf[len] = '\0';
+#else
+ if (maxlen <= 0 || buf == NULL)
+ return 0;
+
+ buf[0] = '\0';
+ (void) gethostname (buf, maxlen);
+ buf [maxlen - 1] = '\0';
+ len = strlen(buf);
+#endif /* NEED_UTSNAME */
+ return len;
+}
+
+
+/*
+ * _XScreenOfWindow - get the Screen of a given window
+ */
+
+Screen *_XScreenOfWindow (dpy, w)
+ Display *dpy;
+ Window w;
+{
+ register int i;
+ Window root;
+ int x, y; /* dummy variables */
+ unsigned int width, height, bw, depth; /* dummy variables */
+
+ if (XGetGeometry (dpy, w, &root, &x, &y, &width, &height,
+ &bw, &depth) == False) {
+ return None;
+ }
+ for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */
+ if (root == RootWindow (dpy, i)) {
+ return ScreenOfDisplay (dpy, i);
+ }
+ }
+ return NULL;
+}
+
+
+#if defined(WIN32)
+
+/*
+ * These functions are intended to be used internally to Xlib only.
+ * These functions will always prefix the path with a DOS drive in the
+ * form "<drive-letter>:". As such, these functions are only suitable
+ * for use by Xlib function that supply a root-based path to some
+ * particular file, e.g. <ProjectRoot>/lib/X11/locale/locale.dir will
+ * be converted to "C:/usr/X11R6.3/lib/X11/locale/locale.dir".
+ */
+
+static int access_file (path, pathbuf, len_pathbuf, pathret)
+ char* path;
+ char* pathbuf;
+ int len_pathbuf;
+ char** pathret;
+{
+ if (access (path, F_OK) == 0) {
+ if (strlen (path) < len_pathbuf)
+ *pathret = pathbuf;
+ else
+ *pathret = Xmalloc (strlen (path) + 1);
+ if (*pathret) {
+ strcpy (*pathret, path);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int AccessFile (path, pathbuf, len_pathbuf, pathret)
+ char* path;
+ char* pathbuf;
+ int len_pathbuf;
+ char** pathret;
+{
+ unsigned long drives;
+ int i, len;
+ char* drive;
+ char buf[MAX_PATH];
+ char* bufp;
+
+ /* just try the "raw" name first and see if it works */
+ if (access_file (path, pathbuf, len_pathbuf, pathret))
+ return 1;
+
+ /* try the places set in the environment */
+ drive = getenv ("_XBASEDRIVE");
+#ifdef __UNIXOS2__
+ if (!drive)
+ drive = getenv ("X11ROOT");
+#endif
+ if (!drive)
+ drive = "C:";
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+
+#ifndef __UNIXOS2__
+ /* one last place to look */
+ drive = getenv ("HOMEDRIVE");
+ if (drive) {
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+ }
+
+ /* tried everywhere else, go fishing */
+#define C_DRIVE ('C' - 'A')
+#define Z_DRIVE ('Z' - 'A')
+ /* does OS/2 (with or with gcc-emx) have getdrives? */
+ drives = _getdrives ();
+ for (i = C_DRIVE; i <= Z_DRIVE; i++) { /* don't check on A: or B: */
+ if ((1 << i) & drives) {
+ len = 2 + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ *bufp = 'A' + i;
+ *(bufp + 1) = ':';
+ *(bufp + 2) = '\0';
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+ }
+ }
+#endif
+ return 0;
+}
+
+int _XOpenFile(path, flags)
+ _Xconst char* path;
+ int flags;
+{
+ char buf[MAX_PATH];
+ char* bufp = NULL;
+ int ret = -1;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ ret = open (bufp, flags);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+void* _XFopenFile(path, mode)
+ _Xconst char* path;
+ _Xconst char* mode;
+{
+ char buf[MAX_PATH];
+ char* bufp = NULL;
+ void* ret = NULL;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ ret = fopen (bufp, mode);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+int _XAccessFile(path)
+ _Xconst char* path;
+{
+ char buf[MAX_PATH];
+ char* bufp;
+ int ret = -1;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ ret = AccessFile (path, buf, MAX_PATH, &bufp);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+#endif
+
+#ifdef WIN32
+#undef _Xdebug
+int _Xdebug = 0;
+int *_Xdebug_p = &_Xdebug;
+void (**_XCreateMutex_fn_p)(LockInfoPtr) = &_XCreateMutex_fn;
+void (**_XFreeMutex_fn_p)(LockInfoPtr) = &_XFreeMutex_fn;
+void (**_XLockMutex_fn_p)(LockInfoPtr
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = &_XLockMutex_fn;
+void (**_XUnlockMutex_fn_p)(LockInfoPtr
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = &_XUnlockMutex_fn;
+LockInfoPtr *_Xglobal_lock_p = &_Xglobal_lock;
+#endif
diff --git a/nx-X11/lib/X11/Xlibint.h b/nx-X11/lib/X11/Xlibint.h
new file mode 100644
index 000000000..56da2349b
--- /dev/null
+++ b/nx-X11/lib/X11/Xlibint.h
@@ -0,0 +1,1346 @@
+/* $Xorg: Xlibint.h,v 1.5 2001/02/09 02:03:38 xorgcvs Exp $ */
+
+/*
+
+Copyright 1984, 1985, 1987, 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.
+
+*/
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/* $XFree86: xc/lib/X11/Xlibint.h,v 3.27 2003/05/27 22:26:26 tsi Exp $ */
+
+#ifndef _XLIBINT_H_
+#define _XLIBINT_H_ 1
+
+/*
+ * Xlibint.h - Header definition and support file for the internal
+ * support routines used by the C subroutine interface
+ * library (Xlib) to the X Window System.
+ *
+ * Warning, there be dragons here....
+ */
+
+#include <X11/Xlib.h>
+#include <X11/Xproto.h> /* to declare xEvent */
+#include <X11/XlibConf.h> /* for configured options like XTHREADS */
+
+#ifdef NX_TRANS_SOCKET
+
+#include "NXvars.h"
+
+#define _XGetIOError(dpy) \
+ (dpy -> flags & XlibDisplayIOError)
+
+#endif
+
+#ifdef WIN32
+#define _XFlush _XFlushIt
+#endif
+
+/*
+ * If your BytesReadable correctly detects broken connections, then
+ * you should NOT define XCONN_CHECK_FREQ.
+ */
+#ifndef XCONN_CHECK_FREQ
+#define XCONN_CHECK_FREQ 256
+#endif
+
+struct _XGC
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ GContext gid; /* protocol ID for graphics context */
+ Bool rects; /* boolean: TRUE if clipmask is list of rectangles */
+ Bool dashes; /* boolean: TRUE if dash-list is really a list */
+ unsigned long dirty;/* cache dirty bits */
+ XGCValues values; /* shadow structure of values */
+};
+
+struct _XDisplay
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XFreeFuncs *free_funcs; /* internal free functions */
+ int fd; /* Network socket. */
+ int conn_checker; /* ugly thing used by _XEventsQueued */
+ int proto_major_version;/* maj. version of server's X protocol */
+ int proto_minor_version;/* minor version of server's X protocol */
+ char *vendor; /* vendor of the server hardware */
+ XID resource_base; /* resource ID base */
+ XID resource_mask; /* resource ID mask bits */
+ XID resource_id; /* allocator current ID */
+ int resource_shift; /* allocator shift to correct bits */
+ XID (*resource_alloc)( /* allocator function */
+ struct _XDisplay*
+ );
+ int byte_order; /* screen byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* padding and data requirements */
+ int bitmap_pad; /* padding requirements on bitmaps */
+ int bitmap_bit_order; /* LeastSignificant or MostSignificant */
+ int nformats; /* number of pixmap formats in list */
+ ScreenFormat *pixmap_format; /* pixmap format list */
+ int vnumber; /* Xlib's X protocol version number. */
+ int release; /* release of the server */
+ struct _XSQEvent *head, *tail; /* Input event queue. */
+ int qlen; /* Length of input event queue */
+ unsigned long last_request_read; /* seq number of last event read */
+ unsigned long request; /* sequence number of last request. */
+ char *last_req; /* beginning of last request, or dummy */
+ char *buffer; /* Output buffer starting address. */
+ char *bufptr; /* Output buffer index pointer. */
+ char *bufmax; /* Output buffer maximum+1 address. */
+ unsigned max_request_size; /* maximum number 32 bit words in request*/
+ struct _XrmHashBucketRec *db;
+ int (*synchandler)( /* Synchronization handler */
+ struct _XDisplay*
+ );
+ char *display_name; /* "host:display" string used on this connect*/
+ int default_screen; /* default screen for operations */
+ int nscreens; /* number of screens on this server*/
+ Screen *screens; /* pointer to list of screens */
+ unsigned long motion_buffer; /* size of motion buffer */
+ unsigned long flags; /* internal connection flags */
+ int min_keycode; /* minimum defined keycode */
+ int max_keycode; /* maximum defined keycode */
+ KeySym *keysyms; /* This server's keysyms */
+ XModifierKeymap *modifiermap; /* This server's modifier keymap */
+ int keysyms_per_keycode;/* number of rows */
+ char *xdefaults; /* contents of defaults from server */
+ char *scratch_buffer; /* place to hang scratch buffer */
+ unsigned long scratch_length; /* length of scratch buffer */
+ int ext_number; /* extension number on this display */
+ struct _XExten *ext_procs; /* extensions initialized on this display */
+ /*
+ * the following can be fixed size, as the protocol defines how
+ * much address space is available.
+ * While this could be done using the extension vector, there
+ * may be MANY events processed, so a search through the extension
+ * list to find the right procedure for each event might be
+ * expensive if many extensions are being used.
+ */
+ Bool (*event_vec[128])( /* vector for wire to event */
+ Display * /* dpy */,
+ XEvent * /* re */,
+ xEvent * /* event */
+ );
+ Status (*wire_vec[128])( /* vector for event to wire */
+ Display * /* dpy */,
+ XEvent * /* re */,
+ xEvent * /* event */
+ );
+ KeySym lock_meaning; /* for XLookupString */
+ struct _XLockInfo *lock; /* multi-thread state, display lock */
+ struct _XInternalAsync *async_handlers; /* for internal async */
+ unsigned long bigreq_size; /* max size of big requests */
+ struct _XLockPtrs *lock_fns; /* pointers to threads functions */
+ void (*idlist_alloc)( /* XID list allocator function */
+ Display * /* dpy */,
+ XID * /* ids */,
+ int /* count */
+ );
+ /* things above this line should not move, for binary compatibility */
+ struct _XKeytrans *key_bindings; /* for XLookupString */
+ Font cursor_font; /* for XCreateFontCursor */
+ struct _XDisplayAtoms *atoms; /* for XInternAtom */
+ unsigned int mode_switch; /* keyboard group modifiers */
+ unsigned int num_lock; /* keyboard numlock modifiers */
+ struct _XContextDB *context_db; /* context database */
+ Bool (**error_vec)( /* vector for wire to error */
+ Display * /* display */,
+ XErrorEvent * /* he */,
+ xError * /* we */
+ );
+ /*
+ * Xcms information
+ */
+ struct {
+ XPointer defaultCCCs; /* pointer to an array of default XcmsCCC */
+ XPointer clientCmaps; /* pointer to linked list of XcmsCmapRec */
+ XPointer perVisualIntensityMaps;
+ /* linked list of XcmsIntensityMap */
+ } cms;
+ struct _XIMFilter *im_filters;
+ struct _XSQEvent *qfree; /* unallocated event queue elements */
+ unsigned long next_event_serial_num; /* inserted into next queue elt */
+ struct _XExten *flushes; /* Flush hooks */
+ struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */
+ int im_fd_length; /* number of im_fd_info */
+ struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */
+ int watcher_count; /* number of conn_watchers */
+ XPointer filedes; /* struct pollfd cache for _XWaitForReadable */
+ int (*savedsynchandler)( /* user synchandler when Xlib usurps */
+ Display * /* dpy */
+ );
+ XID resource_max; /* allocator max ID */
+ int xcmisc_opcode; /* major opcode for XC-MISC */
+ struct _XkbInfoRec *xkb_info; /* XKB info */
+ struct _XtransConnInfo *trans_conn; /* transport connection object */
+};
+
+#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
+
+/*
+ * define the following if you want the Data macro to be a procedure instead
+ */
+#ifdef CRAY
+#define DataRoutineIsProcedure
+#endif /* CRAY */
+
+#ifndef _XEVENT_
+/*
+ * _QEvent datatype for use in input queueing.
+ */
+typedef struct _XSQEvent
+{
+ struct _XSQEvent *next;
+ XEvent event;
+ unsigned long qserial_num; /* so multi-threaded code can find new ones */
+} _XQEvent;
+#endif
+
+#ifdef XTHREADS /* for xReply */
+#define NEED_REPLIES
+#endif
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#ifdef __sgi
+#define _SGI_MP_SOURCE /* turn this on to get MP safe errno */
+#endif
+#include <errno.h>
+#define _XBCOPYFUNC _Xbcopy
+#include <X11/Xfuncs.h>
+#include <X11/Xosdefs.h>
+
+/* Utek leaves kernel macros around in include files (bleah) */
+#ifdef dirty
+#undef dirty
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+/*
+ * The following definitions can be used for locking requests in multi-threaded
+ * address spaces.
+ */
+#ifdef XTHREADS
+/* Author: Stephen Gildea, MIT X Consortium
+ *
+ * declarations for C Threads locking
+ */
+
+typedef struct _LockInfoRec *LockInfoPtr;
+
+/* interfaces for locking.c */
+struct _XLockPtrs {
+ /* used by all, including extensions; do not move */
+ void (*lock_display)(
+ Display *dpy
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char *file
+ , int line
+#endif
+ );
+ void (*unlock_display)(
+ Display *dpy
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char *file
+ , int line
+#endif
+ );
+};
+
+#if defined(WIN32) && !defined(_XLIBINT_)
+#define _XCreateMutex_fn (*_XCreateMutex_fn_p)
+#define _XFreeMutex_fn (*_XFreeMutex_fn_p)
+#define _XLockMutex_fn (*_XLockMutex_fn_p)
+#define _XUnlockMutex_fn (*_XUnlockMutex_fn_p)
+#define _Xglobal_lock (*_Xglobal_lock_p)
+#endif
+
+/* in XlibInt.c */
+extern void (*_XCreateMutex_fn)(
+ LockInfoPtr /* lock */
+);
+extern void (*_XFreeMutex_fn)(
+ LockInfoPtr /* lock */
+);
+extern void (*_XLockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+);
+extern void (*_XUnlockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+);
+
+extern LockInfoPtr _Xglobal_lock;
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__)
+#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__)
+#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__)
+#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__)
+#else
+/* used everywhere, so must be fast if not using threads */
+#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d)
+#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d)
+#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock)
+#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock)
+#endif
+#define _XCreateMutex(lock) if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock);
+#define _XFreeMutex(lock) if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock);
+
+#else /* XTHREADS */
+#define LockDisplay(dis)
+#define _XLockMutex(lock)
+#define _XUnlockMutex(lock)
+#define UnlockDisplay(dis)
+#define _XCreateMutex(lock)
+#define _XFreeMutex(lock)
+#endif
+
+#define Xfree(ptr) free((ptr))
+
+/*
+ * Note that some machines do not return a valid pointer for malloc(0), in
+ * which case we provide an alternate under the control of the
+ * define MALLOC_0_RETURNS_NULL. This is necessary because some
+ * Xlib code expects malloc(0) to return a valid pointer to storage.
+ */
+#ifdef MALLOC_0_RETURNS_NULL
+
+# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size)))
+# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size)))
+# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize))
+
+#else
+
+# define Xmalloc(size) malloc((size))
+# define Xrealloc(ptr, size) realloc((ptr), (size))
+# define Xcalloc(nelem, elsize) calloc((nelem), (elsize))
+
+#endif
+
+#include <stddef.h>
+
+#define LOCKED 1
+#define UNLOCKED 0
+
+#ifdef NX_TRANS_SOCKET
+#ifndef BUFSIZE /* Output buffer size is configurable */
+#define BUFSIZE 8192 /* but this is still used for reading. */
+#endif
+#else
+#ifndef BUFSIZE
+#define BUFSIZE 2048 /* X output buffer size. */
+#endif
+#endif
+#ifndef PTSPERBATCH
+#define PTSPERBATCH 1024 /* point batching */
+#endif
+#ifndef WLNSPERBATCH
+#define WLNSPERBATCH 50 /* wide line batching */
+#endif
+#ifndef ZLNSPERBATCH
+#define ZLNSPERBATCH 1024 /* thin line batching */
+#endif
+#ifndef WRCTSPERBATCH
+#define WRCTSPERBATCH 10 /* wide line rectangle batching */
+#endif
+#ifndef ZRCTSPERBATCH
+#define ZRCTSPERBATCH 256 /* thin line rectangle batching */
+#endif
+#ifndef FRCTSPERBATCH
+#define FRCTSPERBATCH 256 /* filled rectangle batching */
+#endif
+#ifndef FARCSPERBATCH
+#define FARCSPERBATCH 256 /* filled arc batching */
+#endif
+#ifndef CURSORFONT
+#define CURSORFONT "cursor" /* standard cursor fonts */
+#endif
+
+/*
+ * Display flags
+ */
+#define XlibDisplayIOError (1L << 0)
+#define XlibDisplayClosing (1L << 1)
+#define XlibDisplayNoXkb (1L << 2)
+#define XlibDisplayPrivSync (1L << 3)
+#define XlibDisplayProcConni (1L << 4) /* in _XProcessInternalConnection */
+#define XlibDisplayReadEvents (1L << 5) /* in _XReadEvents */
+#define XlibDisplayReply (1L << 5) /* in _XReply */
+#define XlibDisplayWriting (1L << 6) /* in _XFlushInt, _XSend */
+#define XlibDisplayDfltRMDB (1L << 7) /* mark if RM db from XGetDefault */
+
+/*
+ * X Protocol packetizing macros.
+ */
+
+/* Need to start requests on 64 bit word boundaries
+ * on a CRAY computer so add a NoOp (127) if needed.
+ * A character pointer on a CRAY computer will be non-zero
+ * after shifting right 61 bits of it is not pointing to
+ * a word boundary.
+ */
+#ifdef WORD64
+#define WORD64ALIGN if ((long)dpy->bufptr >> 61) {\
+ dpy->last_req = dpy->bufptr;\
+ *(dpy->bufptr) = X_NoOperation;\
+ *(dpy->bufptr+1) = 0;\
+ *(dpy->bufptr+2) = 0;\
+ *(dpy->bufptr+3) = 1;\
+ dpy->request++;\
+ dpy->bufptr += 4;\
+ }
+#else /* else does not require alignment on 64-bit boundaries */
+#define WORD64ALIGN
+#endif /* WORD64 */
+
+
+/*
+ * GetReq - Get the next available X request packet in the buffer and
+ * return it.
+ *
+ * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
+ * "req" is the name of the request pointer.
+ *
+ */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = (SIZEOF(x##name##Req))>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req);\
+ dpy->request++
+
+#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
+#define GetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = (SIZEOF(x/**/name/**/Req))>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req);\
+ dpy->request++
+#endif
+
+/* GetReqExtra is the same as GetReq, but allocates "n" additional
+ bytes after the request. "n" must be a multiple of 4! */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetReqExtra(name, n, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = (SIZEOF(x##name##Req) + n)>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req) + n;\
+ dpy->request++
+#else
+#define GetReqExtra(name, n, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\
+ dpy->request++
+#endif
+
+
+/*
+ * GetResReq is for those requests that have a resource ID
+ * (Window, Pixmap, GContext, etc.) as their single argument.
+ * "rid" is the name of the resource.
+ */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetResReq(name, rid, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = 2;\
+ req->id = (rid);\
+ dpy->bufptr += SIZEOF(xResourceReq);\
+ dpy->request++
+#else
+#define GetResReq(name, rid, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = 2;\
+ req->id = (rid);\
+ dpy->bufptr += SIZEOF(xResourceReq);\
+ dpy->request++
+#endif
+
+/*
+ * GetEmptyReq is for those requests that have no arguments
+ * at all.
+ */
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetEmptyReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = 1;\
+ dpy->bufptr += SIZEOF(xReq);\
+ dpy->request++
+#else
+#define GetEmptyReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = 1;\
+ dpy->bufptr += SIZEOF(xReq);\
+ dpy->request++
+#endif
+
+#ifdef WORD64
+#define MakeBigReq(req,n) \
+ { \
+ char _BRdat[4]; \
+ unsigned long _BRlen = req->length - 1; \
+ req->length = 0; \
+ memcpy(_BRdat, ((char *)req) + (_BRlen << 2), 4); \
+ memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
+ memcpy(((char *)req) + 4, _BRdat, 4); \
+ Data32(dpy, (long *)&_BRdat, 4); \
+ }
+#else
+#ifdef LONG64
+#define MakeBigReq(req,n) \
+ { \
+ CARD64 _BRdat; \
+ CARD32 _BRlen = req->length - 1; \
+ req->length = 0; \
+ _BRdat = ((CARD32 *)req)[_BRlen]; \
+ memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
+ ((CARD32 *)req)[1] = _BRlen + n + 2; \
+ Data32(dpy, &_BRdat, 4); \
+ }
+#else
+#define MakeBigReq(req,n) \
+ { \
+ CARD32 _BRdat; \
+ CARD32 _BRlen = req->length - 1; \
+ req->length = 0; \
+ _BRdat = ((CARD32 *)req)[_BRlen]; \
+ memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
+ ((CARD32 *)req)[1] = _BRlen + n + 2; \
+ Data32(dpy, &_BRdat, 4); \
+ }
+#endif
+#endif
+
+#define SetReqLen(req,n,badlen) \
+ if ((req->length + n) > (unsigned)65535) { \
+ if (dpy->bigreq_size) { \
+ MakeBigReq(req,n) \
+ } else { \
+ n = badlen; \
+ req->length += n; \
+ } \
+ } else \
+ req->length += n
+
+#define SyncHandle() \
+ if (dpy->synchandler) (*dpy->synchandler)(dpy)
+
+extern void _XFlushGCCache(Display *dpy, GC gc);
+#define FlushGC(dpy, gc) \
+ if ((gc)->dirty) _XFlushGCCache((dpy), (gc))
+/*
+ * Data - Place data in the buffer and pad the end to provide
+ * 32 bit word alignment. Transmit if the buffer fills.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pinter to a data buffer.
+ * "len" is the length of the data buffer.
+ */
+#ifndef DataRoutineIsProcedure
+#define Data(dpy, data, len) {\
+ if (dpy->bufptr + (len) <= dpy->bufmax) {\
+ memcpy(dpy->bufptr, data, (int)len);\
+ dpy->bufptr += ((len) + 3) & ~3;\
+ } else\
+ _XSend(dpy, data, len);\
+ }
+#endif /* DataRoutineIsProcedure */
+
+
+/* Allocate bytes from the buffer. No padding is done, so if
+ * the length is not a multiple of 4, the caller must be
+ * careful to leave the buffer aligned after sending the
+ * current request.
+ *
+ * "type" is the type of the pointer being assigned to.
+ * "ptr" is the pointer being assigned to.
+ * "n" is the number of bytes to allocate.
+ *
+ * Example:
+ * xTextElt *elt;
+ * BufAlloc (xTextElt *, elt, nbytes)
+ */
+
+#define BufAlloc(type, ptr, n) \
+ if (dpy->bufptr + (n) > dpy->bufmax) \
+ _XFlush (dpy); \
+ ptr = (type) dpy->bufptr; \
+ (void)ptr; \
+ dpy->bufptr += (n);
+
+#ifdef WORD64
+#define Data16(dpy, data, len) _XData16(dpy, (short *)data, len)
+#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
+#else
+#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
+#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
+#ifdef LONG64
+#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
+extern int _XData32(
+ Display *dpy,
+ register long *data,
+ unsigned len
+);
+extern void _XRead32(
+ Display *dpy,
+ register long *data,
+ long len
+);
+#else
+#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
+#endif
+#endif /* not WORD64 */
+
+#define PackData16(dpy,data,len) Data16 (dpy, data, len)
+#define PackData32(dpy,data,len) Data32 (dpy, data, len)
+
+/* Xlib manual is bogus */
+#define PackData(dpy,data,len) PackData16 (dpy, data, len)
+
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+
+#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
+ (((cs)->rbearing|(cs)->lbearing| \
+ (cs)->ascent|(cs)->descent) == 0))
+
+/*
+ * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit
+ * character. If the character is in the column and exists, then return the
+ * appropriate metrics (note that fonts with common per-character metrics will
+ * return min_bounds). If none of these hold true, try again with the default
+ * char.
+ */
+#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \
+{ \
+ cs = def; \
+ if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
+ if (fs->per_char == NULL) { \
+ cs = &fs->min_bounds; \
+ } else { \
+ cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \
+ if (CI_NONEXISTCHAR(cs)) cs = def; \
+ } \
+ } \
+}
+
+#define CI_GET_DEFAULT_INFO_1D(fs,cs) \
+ CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs)
+
+
+
+/*
+ * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and
+ * column. This is used for fonts that have more than row zero.
+ */
+#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \
+{ \
+ cs = def; \
+ if (row >= fs->min_byte1 && row <= fs->max_byte1 && \
+ col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
+ if (fs->per_char == NULL) { \
+ cs = &fs->min_bounds; \
+ } else { \
+ cs = &fs->per_char[((row - fs->min_byte1) * \
+ (fs->max_char_or_byte2 - \
+ fs->min_char_or_byte2 + 1)) + \
+ (col - fs->min_char_or_byte2)]; \
+ if (CI_NONEXISTCHAR(cs)) cs = def; \
+ } \
+ } \
+}
+
+#define CI_GET_DEFAULT_INFO_2D(fs,cs) \
+{ \
+ unsigned int r = (fs->default_char >> 8); \
+ unsigned int c = (fs->default_char & 0xff); \
+ CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \
+}
+
+
+#ifdef MUSTCOPY
+
+/* for when 32-bit alignment is not good enough */
+#define OneDataCard32(dpy,dstaddr,srcvar) \
+ { dpy->bufptr -= 4; Data32 (dpy, (char *) &(srcvar), 4); }
+
+#else
+
+/* srcvar must be a variable for large architecture version */
+#define OneDataCard32(dpy,dstaddr,srcvar) \
+ { *(CARD32 *)(dstaddr) = (srcvar); }
+
+#endif /* MUSTCOPY */
+
+typedef struct _XInternalAsync {
+ struct _XInternalAsync *next;
+ /*
+ * handler arguments:
+ * rep is the generic reply that caused this handler
+ * to be invoked. It must also be passed to _XGetAsyncReply.
+ * buf and len are opaque values that must be passed to
+ * _XGetAsyncReply or _XGetAsyncData.
+ * data is the closure stored in this struct.
+ * The handler returns True iff it handled this reply.
+ */
+ Bool (*handler)(
+ Display* /* dpy */,
+ xReply* /* rep */,
+ char* /* buf */,
+ int /* len */,
+ XPointer /* data */
+ );
+ XPointer data;
+} _XAsyncHandler;
+
+typedef struct _XAsyncEState {
+ unsigned long min_sequence_number;
+ unsigned long max_sequence_number;
+ unsigned char error_code;
+ unsigned char major_opcode;
+ unsigned short minor_opcode;
+ unsigned char last_error_received;
+ int error_count;
+} _XAsyncErrorState;
+
+extern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler);
+#define DeqAsyncHandler(dpy,handler) { \
+ if (dpy->async_handlers == (handler)) \
+ dpy->async_handlers = (handler)->next; \
+ else \
+ _XDeqAsyncHandler(dpy, handler); \
+ }
+
+typedef void (*FreeFuncType) (
+ Display* /* display */
+);
+
+typedef int (*FreeModmapType) (
+ XModifierKeymap* /* modmap */
+);
+
+/*
+ * This structure is private to the library.
+ */
+typedef struct _XFreeFuncs {
+ FreeFuncType atoms; /* _XFreeAtomTable */
+ FreeModmapType modifiermap; /* XFreeModifierMap */
+ FreeFuncType key_bindings; /* _XFreeKeyBindings */
+ FreeFuncType context_db; /* _XFreeContextDB */
+ FreeFuncType defaultCCCs; /* _XcmsFreeDefaultCCCs */
+ FreeFuncType clientCmaps; /* _XcmsFreeClientCmaps */
+ FreeFuncType intensityMaps; /* _XcmsFreeIntensityMaps */
+ FreeFuncType im_filters; /* _XFreeIMFilters */
+ FreeFuncType xkb; /* _XkbFreeInfo */
+} _XFreeFuncRec;
+
+/* types for InitExt.c */
+typedef int (*CreateGCType) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*CopyGCType)(
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*FlushGCType) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*FreeGCType) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*CreateFontType) (
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*FreeFontType) (
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*CloseDisplayType) (
+ Display* /* display */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*ErrorType) (
+ Display* /* display */,
+ xError* /* err */,
+ XExtCodes* /* codes */,
+ int* /* ret_code */
+);
+
+typedef char* (*ErrorStringType) (
+ Display* /* display */,
+ int /* code */,
+ XExtCodes* /* codes */,
+ char* /* buffer */,
+ int /* nbytes */
+);
+
+typedef void (*PrintErrorType)(
+ Display* /* display */,
+ XErrorEvent* /* ev */,
+ void* /* fp */
+);
+
+typedef void (*BeforeFlushType)(
+ Display* /* display */,
+ XExtCodes* /* codes */,
+ _Xconst char* /* data */,
+ long /* len */
+);
+
+/*
+ * This structure is private to the library.
+ */
+typedef struct _XExten { /* private to extension mechanism */
+ struct _XExten *next; /* next in list */
+ XExtCodes codes; /* public information, all extension told */
+ CreateGCType create_GC; /* routine to call when GC created */
+ CopyGCType copy_GC; /* routine to call when GC copied */
+ FlushGCType flush_GC; /* routine to call when GC flushed */
+ FreeGCType free_GC; /* routine to call when GC freed */
+ CreateFontType create_Font; /* routine to call when Font created */
+ FreeFontType free_Font; /* routine to call when Font freed */
+ CloseDisplayType close_display; /* routine to call when connection closed */
+ ErrorType error; /* who to call when an error occurs */
+ ErrorStringType error_string; /* routine to supply error string */
+ char *name; /* name of this extension */
+ PrintErrorType error_values; /* routine to supply error values */
+ BeforeFlushType before_flush; /* routine to call when sending data */
+ struct _XExten *next_flush; /* next in list of those with flushes */
+} _XExtension;
+
+/* extension hooks */
+
+#ifdef DataRoutineIsProcedure
+extern void Data(Display *dpy, char *data, long len);
+#endif
+extern int _XError(
+ Display* /* dpy */,
+ xError* /* rep */
+);
+extern int _XIOError(
+ Display* /* dpy */
+);
+extern int (*_XIOErrorFunction)(
+ Display* /* dpy */
+);
+extern int (*_XErrorFunction)(
+ Display* /* dpy */,
+ XErrorEvent* /* error_event */
+);
+extern void _XEatData(
+ Display* /* dpy */,
+ unsigned long /* n */
+);
+extern char *_XAllocScratch(
+ Display* /* dpy */,
+ unsigned long /* nbytes */
+);
+extern char *_XAllocTemp(
+ Display* /* dpy */,
+ unsigned long /* nbytes */
+);
+extern void _XFreeTemp(
+ Display* /* dpy */,
+ char* /* buf */,
+ unsigned long /* nbytes */
+);
+extern Visual *_XVIDtoVisual(
+ Display* /* dpy */,
+ VisualID /* id */
+);
+extern unsigned long _XSetLastRequestRead(
+ Display* /* dpy */,
+ xGenericReply* /* rep */
+);
+extern int _XGetHostname(
+ char* /* buf */,
+ int /* maxlen */
+);
+extern Screen *_XScreenOfWindow(
+ Display* /* dpy */,
+ Window /* w */
+);
+extern Bool _XAsyncErrorHandler(
+ Display* /* dpy */,
+ xReply* /* rep */,
+ char* /* buf */,
+ int /* len */,
+ XPointer /* data */
+);
+extern char *_XGetAsyncReply(
+ Display* /* dpy */,
+ char* /* replbuf */,
+ xReply* /* rep */,
+ char* /* buf */,
+ int /* len */,
+ int /* extra */,
+ Bool /* discard */
+);
+extern void _XGetAsyncData(
+ Display* /* dpy */,
+ char * /* data */,
+ char * /* buf */,
+ int /* len */,
+ int /* skip */,
+ int /* datalen */,
+ int /* discardtotal */
+);
+extern void _XFlush(
+ Display* /* dpy */
+);
+extern int _XEventsQueued(
+ Display* /* dpy */,
+ int /* mode */
+);
+extern void _XReadEvents(
+ Display* /* dpy */
+);
+extern int _XRead(
+ Display* /* dpy */,
+ char* /* data */,
+ long /* size */
+);
+extern void _XReadPad(
+ Display* /* dpy */,
+ char* /* data */,
+ long /* size */
+);
+extern void _XSend(
+ Display* /* dpy */,
+ _Xconst char* /* data */,
+ long /* size */
+);
+extern Status _XReply(
+ Display* /* dpy */,
+ xReply* /* rep */,
+ int /* extra */,
+ Bool /* discard */
+);
+extern void _XEnq(
+ Display* /* dpy */,
+ xEvent* /* event */
+);
+extern void _XDeq(
+ Display* /* dpy */,
+ _XQEvent* /* prev */,
+ _XQEvent* /* qelt */
+);
+
+extern Bool _XUnknownWireEvent(
+ Display* /* dpy */,
+ XEvent* /* re */,
+ xEvent* /* event */
+);
+extern Status _XUnknownNativeEvent(
+ Display* /* dpy */,
+ XEvent* /* re */,
+ xEvent* /* event */
+);
+
+extern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event);
+extern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we);
+extern Bool _XPollfdCacheInit(Display *dpy);
+extern void _XPollfdCacheAdd(Display *dpy, int fd);
+extern void _XPollfdCacheDel(Display *dpy, int fd);
+extern XID _XAllocID(Display *dpy);
+extern void _XAllocIDs(Display *dpy, XID *ids, int count);
+
+extern int _XFreeExtData(
+ XExtData* /* extension */
+);
+
+extern int (*XESetCreateGC(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, GC, XExtCodes*
+);
+
+extern int (*XESetCopyGC(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, GC, XExtCodes*
+);
+
+extern int (*XESetFlushGC(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, GC, XExtCodes*
+);
+
+extern int (*XESetFreeGC(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, GC, XExtCodes*
+);
+
+extern int (*XESetCreateFont(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, XFontStruct*, XExtCodes*
+);
+
+extern int (*XESetFreeFont(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, XFontStruct*, XExtCodes*
+);
+
+extern int (*XESetCloseDisplay(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, XExtCodes*
+);
+
+extern int (*XESetError(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ xError* /* err */,
+ XExtCodes* /* codes */,
+ int* /* ret_code */
+ ) /* proc */
+))(
+ Display*, xError*, XExtCodes*, int*
+);
+
+extern char* (*XESetErrorString(
+ Display* /* display */,
+ int /* extension */,
+ char* (*) (
+ Display* /* display */,
+ int /* code */,
+ XExtCodes* /* codes */,
+ char* /* buffer */,
+ int /* nbytes */
+ ) /* proc */
+))(
+ Display*, int, XExtCodes*, char*, int
+);
+
+extern void (*XESetPrintErrorValues (
+ Display* /* display */,
+ int /* extension */,
+ void (*)(
+ Display* /* display */,
+ XErrorEvent* /* ev */,
+ void* /* fp */
+ ) /* proc */
+))(
+ Display*, XErrorEvent*, void*
+);
+
+extern Bool (*XESetWireToEvent(
+ Display* /* display */,
+ int /* event_number */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+ ) /* proc */
+))(
+ Display*, XEvent*, xEvent*
+);
+
+extern Status (*XESetEventToWire(
+ Display* /* display */,
+ int /* event_number */,
+ Status (*) (
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+ ) /* proc */
+))(
+ Display*, XEvent*, xEvent*
+);
+
+extern Bool (*XESetWireToError(
+ Display* /* display */,
+ int /* error_number */,
+ Bool (*) (
+ Display* /* display */,
+ XErrorEvent* /* he */,
+ xError* /* we */
+ ) /* proc */
+))(
+ Display*, XErrorEvent*, xError*
+);
+
+extern void (*XESetBeforeFlush(
+ Display* /* display */,
+ int /* error_number */,
+ void (*) (
+ Display* /* display */,
+ XExtCodes* /* codes */,
+ _Xconst char* /* data */,
+ long /* len */
+ ) /* proc */
+))(
+ Display*, XExtCodes*, _Xconst char*, long
+);
+
+/* internal connections for IMs */
+
+typedef void (*_XInternalConnectionProc)(
+ Display* /* dpy */,
+ int /* fd */,
+ XPointer /* call_data */
+);
+
+
+extern Status _XRegisterInternalConnection(
+ Display* /* dpy */,
+ int /* fd */,
+ _XInternalConnectionProc /* callback */,
+ XPointer /* call_data */
+);
+
+extern void _XUnregisterInternalConnection(
+ Display* /* dpy */,
+ int /* fd */
+);
+
+/* Display structure has pointers to these */
+
+struct _XConnectionInfo { /* info from _XRegisterInternalConnection */
+ int fd;
+ _XInternalConnectionProc read_callback;
+ XPointer call_data;
+ XPointer *watch_data; /* set/used by XConnectionWatchProc */
+ struct _XConnectionInfo *next;
+};
+
+struct _XConnWatchInfo { /* info from XAddConnectionWatch */
+ XConnectionWatchProc fn;
+ XPointer client_data;
+ struct _XConnWatchInfo *next;
+};
+
+#ifdef __UNIXOS2__
+extern char* __XOS2RedirRoot(
+ char*
+);
+#endif
+
+extern int _XTextHeight(
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* count */
+);
+
+extern int _XTextHeight16(
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* count */
+);
+
+#if defined(WIN32)
+
+extern int _XOpenFile(
+ _Xconst char* /* path */,
+ int /* flags */
+);
+
+extern void* _XFopenFile(
+ _Xconst char* /* path */,
+ _Xconst char* /* mode */
+);
+
+extern int _XAccessFile(
+ _Xconst char* /* path */
+);
+#else
+#define _XOpenFile(path,flags) open(path,flags)
+#define _XFopenFile(path,mode) fopen(path,mode)
+#endif
+
+/* EvToWire.c */
+extern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event);
+
+extern int _XF86LoadQueryLocaleFont(
+ Display* /* dpy */,
+ _Xconst char* /* name*/,
+ XFontStruct** /* xfp*/,
+ Font* /* fidp */
+);
+
+extern void _XProcessWindowAttributes (
+ register Display *dpy,
+ xChangeWindowAttributesReq *req,
+ register unsigned long valuemask,
+ register XSetWindowAttributes *attributes);
+
+extern int _XDefaultError(
+ Display *dpy,
+ XErrorEvent *event);
+
+extern int _XDefaultIOError(
+ Display *dpy);
+
+extern void _XSetClipRectangles (
+ register Display *dpy,
+ GC gc,
+ int clip_x_origin, int clip_y_origin,
+ XRectangle *rectangles,
+ int n,
+ int ordering);
+
+Status _XGetWindowAttributes(
+ register Display *dpy,
+ Window w,
+ XWindowAttributes *attr);
+
+int _XPutBackEvent (
+ register Display *dpy,
+ register XEvent *event);
+
+_XFUNCPROTOEND
+
+#endif /* _XLIBINT_H_ */
diff --git a/nx-X11/lib/X11/Xlibint.h.NX.original b/nx-X11/lib/X11/Xlibint.h.NX.original
new file mode 100644
index 000000000..56da2349b
--- /dev/null
+++ b/nx-X11/lib/X11/Xlibint.h.NX.original
@@ -0,0 +1,1346 @@
+/* $Xorg: Xlibint.h,v 1.5 2001/02/09 02:03:38 xorgcvs Exp $ */
+
+/*
+
+Copyright 1984, 1985, 1987, 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.
+
+*/
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/* $XFree86: xc/lib/X11/Xlibint.h,v 3.27 2003/05/27 22:26:26 tsi Exp $ */
+
+#ifndef _XLIBINT_H_
+#define _XLIBINT_H_ 1
+
+/*
+ * Xlibint.h - Header definition and support file for the internal
+ * support routines used by the C subroutine interface
+ * library (Xlib) to the X Window System.
+ *
+ * Warning, there be dragons here....
+ */
+
+#include <X11/Xlib.h>
+#include <X11/Xproto.h> /* to declare xEvent */
+#include <X11/XlibConf.h> /* for configured options like XTHREADS */
+
+#ifdef NX_TRANS_SOCKET
+
+#include "NXvars.h"
+
+#define _XGetIOError(dpy) \
+ (dpy -> flags & XlibDisplayIOError)
+
+#endif
+
+#ifdef WIN32
+#define _XFlush _XFlushIt
+#endif
+
+/*
+ * If your BytesReadable correctly detects broken connections, then
+ * you should NOT define XCONN_CHECK_FREQ.
+ */
+#ifndef XCONN_CHECK_FREQ
+#define XCONN_CHECK_FREQ 256
+#endif
+
+struct _XGC
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ GContext gid; /* protocol ID for graphics context */
+ Bool rects; /* boolean: TRUE if clipmask is list of rectangles */
+ Bool dashes; /* boolean: TRUE if dash-list is really a list */
+ unsigned long dirty;/* cache dirty bits */
+ XGCValues values; /* shadow structure of values */
+};
+
+struct _XDisplay
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XFreeFuncs *free_funcs; /* internal free functions */
+ int fd; /* Network socket. */
+ int conn_checker; /* ugly thing used by _XEventsQueued */
+ int proto_major_version;/* maj. version of server's X protocol */
+ int proto_minor_version;/* minor version of server's X protocol */
+ char *vendor; /* vendor of the server hardware */
+ XID resource_base; /* resource ID base */
+ XID resource_mask; /* resource ID mask bits */
+ XID resource_id; /* allocator current ID */
+ int resource_shift; /* allocator shift to correct bits */
+ XID (*resource_alloc)( /* allocator function */
+ struct _XDisplay*
+ );
+ int byte_order; /* screen byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* padding and data requirements */
+ int bitmap_pad; /* padding requirements on bitmaps */
+ int bitmap_bit_order; /* LeastSignificant or MostSignificant */
+ int nformats; /* number of pixmap formats in list */
+ ScreenFormat *pixmap_format; /* pixmap format list */
+ int vnumber; /* Xlib's X protocol version number. */
+ int release; /* release of the server */
+ struct _XSQEvent *head, *tail; /* Input event queue. */
+ int qlen; /* Length of input event queue */
+ unsigned long last_request_read; /* seq number of last event read */
+ unsigned long request; /* sequence number of last request. */
+ char *last_req; /* beginning of last request, or dummy */
+ char *buffer; /* Output buffer starting address. */
+ char *bufptr; /* Output buffer index pointer. */
+ char *bufmax; /* Output buffer maximum+1 address. */
+ unsigned max_request_size; /* maximum number 32 bit words in request*/
+ struct _XrmHashBucketRec *db;
+ int (*synchandler)( /* Synchronization handler */
+ struct _XDisplay*
+ );
+ char *display_name; /* "host:display" string used on this connect*/
+ int default_screen; /* default screen for operations */
+ int nscreens; /* number of screens on this server*/
+ Screen *screens; /* pointer to list of screens */
+ unsigned long motion_buffer; /* size of motion buffer */
+ unsigned long flags; /* internal connection flags */
+ int min_keycode; /* minimum defined keycode */
+ int max_keycode; /* maximum defined keycode */
+ KeySym *keysyms; /* This server's keysyms */
+ XModifierKeymap *modifiermap; /* This server's modifier keymap */
+ int keysyms_per_keycode;/* number of rows */
+ char *xdefaults; /* contents of defaults from server */
+ char *scratch_buffer; /* place to hang scratch buffer */
+ unsigned long scratch_length; /* length of scratch buffer */
+ int ext_number; /* extension number on this display */
+ struct _XExten *ext_procs; /* extensions initialized on this display */
+ /*
+ * the following can be fixed size, as the protocol defines how
+ * much address space is available.
+ * While this could be done using the extension vector, there
+ * may be MANY events processed, so a search through the extension
+ * list to find the right procedure for each event might be
+ * expensive if many extensions are being used.
+ */
+ Bool (*event_vec[128])( /* vector for wire to event */
+ Display * /* dpy */,
+ XEvent * /* re */,
+ xEvent * /* event */
+ );
+ Status (*wire_vec[128])( /* vector for event to wire */
+ Display * /* dpy */,
+ XEvent * /* re */,
+ xEvent * /* event */
+ );
+ KeySym lock_meaning; /* for XLookupString */
+ struct _XLockInfo *lock; /* multi-thread state, display lock */
+ struct _XInternalAsync *async_handlers; /* for internal async */
+ unsigned long bigreq_size; /* max size of big requests */
+ struct _XLockPtrs *lock_fns; /* pointers to threads functions */
+ void (*idlist_alloc)( /* XID list allocator function */
+ Display * /* dpy */,
+ XID * /* ids */,
+ int /* count */
+ );
+ /* things above this line should not move, for binary compatibility */
+ struct _XKeytrans *key_bindings; /* for XLookupString */
+ Font cursor_font; /* for XCreateFontCursor */
+ struct _XDisplayAtoms *atoms; /* for XInternAtom */
+ unsigned int mode_switch; /* keyboard group modifiers */
+ unsigned int num_lock; /* keyboard numlock modifiers */
+ struct _XContextDB *context_db; /* context database */
+ Bool (**error_vec)( /* vector for wire to error */
+ Display * /* display */,
+ XErrorEvent * /* he */,
+ xError * /* we */
+ );
+ /*
+ * Xcms information
+ */
+ struct {
+ XPointer defaultCCCs; /* pointer to an array of default XcmsCCC */
+ XPointer clientCmaps; /* pointer to linked list of XcmsCmapRec */
+ XPointer perVisualIntensityMaps;
+ /* linked list of XcmsIntensityMap */
+ } cms;
+ struct _XIMFilter *im_filters;
+ struct _XSQEvent *qfree; /* unallocated event queue elements */
+ unsigned long next_event_serial_num; /* inserted into next queue elt */
+ struct _XExten *flushes; /* Flush hooks */
+ struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */
+ int im_fd_length; /* number of im_fd_info */
+ struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */
+ int watcher_count; /* number of conn_watchers */
+ XPointer filedes; /* struct pollfd cache for _XWaitForReadable */
+ int (*savedsynchandler)( /* user synchandler when Xlib usurps */
+ Display * /* dpy */
+ );
+ XID resource_max; /* allocator max ID */
+ int xcmisc_opcode; /* major opcode for XC-MISC */
+ struct _XkbInfoRec *xkb_info; /* XKB info */
+ struct _XtransConnInfo *trans_conn; /* transport connection object */
+};
+
+#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
+
+/*
+ * define the following if you want the Data macro to be a procedure instead
+ */
+#ifdef CRAY
+#define DataRoutineIsProcedure
+#endif /* CRAY */
+
+#ifndef _XEVENT_
+/*
+ * _QEvent datatype for use in input queueing.
+ */
+typedef struct _XSQEvent
+{
+ struct _XSQEvent *next;
+ XEvent event;
+ unsigned long qserial_num; /* so multi-threaded code can find new ones */
+} _XQEvent;
+#endif
+
+#ifdef XTHREADS /* for xReply */
+#define NEED_REPLIES
+#endif
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#ifdef __sgi
+#define _SGI_MP_SOURCE /* turn this on to get MP safe errno */
+#endif
+#include <errno.h>
+#define _XBCOPYFUNC _Xbcopy
+#include <X11/Xfuncs.h>
+#include <X11/Xosdefs.h>
+
+/* Utek leaves kernel macros around in include files (bleah) */
+#ifdef dirty
+#undef dirty
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+/*
+ * The following definitions can be used for locking requests in multi-threaded
+ * address spaces.
+ */
+#ifdef XTHREADS
+/* Author: Stephen Gildea, MIT X Consortium
+ *
+ * declarations for C Threads locking
+ */
+
+typedef struct _LockInfoRec *LockInfoPtr;
+
+/* interfaces for locking.c */
+struct _XLockPtrs {
+ /* used by all, including extensions; do not move */
+ void (*lock_display)(
+ Display *dpy
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char *file
+ , int line
+#endif
+ );
+ void (*unlock_display)(
+ Display *dpy
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char *file
+ , int line
+#endif
+ );
+};
+
+#if defined(WIN32) && !defined(_XLIBINT_)
+#define _XCreateMutex_fn (*_XCreateMutex_fn_p)
+#define _XFreeMutex_fn (*_XFreeMutex_fn_p)
+#define _XLockMutex_fn (*_XLockMutex_fn_p)
+#define _XUnlockMutex_fn (*_XUnlockMutex_fn_p)
+#define _Xglobal_lock (*_Xglobal_lock_p)
+#endif
+
+/* in XlibInt.c */
+extern void (*_XCreateMutex_fn)(
+ LockInfoPtr /* lock */
+);
+extern void (*_XFreeMutex_fn)(
+ LockInfoPtr /* lock */
+);
+extern void (*_XLockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+);
+extern void (*_XUnlockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+);
+
+extern LockInfoPtr _Xglobal_lock;
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__)
+#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__)
+#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__)
+#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__)
+#else
+/* used everywhere, so must be fast if not using threads */
+#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d)
+#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d)
+#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock)
+#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock)
+#endif
+#define _XCreateMutex(lock) if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock);
+#define _XFreeMutex(lock) if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock);
+
+#else /* XTHREADS */
+#define LockDisplay(dis)
+#define _XLockMutex(lock)
+#define _XUnlockMutex(lock)
+#define UnlockDisplay(dis)
+#define _XCreateMutex(lock)
+#define _XFreeMutex(lock)
+#endif
+
+#define Xfree(ptr) free((ptr))
+
+/*
+ * Note that some machines do not return a valid pointer for malloc(0), in
+ * which case we provide an alternate under the control of the
+ * define MALLOC_0_RETURNS_NULL. This is necessary because some
+ * Xlib code expects malloc(0) to return a valid pointer to storage.
+ */
+#ifdef MALLOC_0_RETURNS_NULL
+
+# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size)))
+# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size)))
+# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize))
+
+#else
+
+# define Xmalloc(size) malloc((size))
+# define Xrealloc(ptr, size) realloc((ptr), (size))
+# define Xcalloc(nelem, elsize) calloc((nelem), (elsize))
+
+#endif
+
+#include <stddef.h>
+
+#define LOCKED 1
+#define UNLOCKED 0
+
+#ifdef NX_TRANS_SOCKET
+#ifndef BUFSIZE /* Output buffer size is configurable */
+#define BUFSIZE 8192 /* but this is still used for reading. */
+#endif
+#else
+#ifndef BUFSIZE
+#define BUFSIZE 2048 /* X output buffer size. */
+#endif
+#endif
+#ifndef PTSPERBATCH
+#define PTSPERBATCH 1024 /* point batching */
+#endif
+#ifndef WLNSPERBATCH
+#define WLNSPERBATCH 50 /* wide line batching */
+#endif
+#ifndef ZLNSPERBATCH
+#define ZLNSPERBATCH 1024 /* thin line batching */
+#endif
+#ifndef WRCTSPERBATCH
+#define WRCTSPERBATCH 10 /* wide line rectangle batching */
+#endif
+#ifndef ZRCTSPERBATCH
+#define ZRCTSPERBATCH 256 /* thin line rectangle batching */
+#endif
+#ifndef FRCTSPERBATCH
+#define FRCTSPERBATCH 256 /* filled rectangle batching */
+#endif
+#ifndef FARCSPERBATCH
+#define FARCSPERBATCH 256 /* filled arc batching */
+#endif
+#ifndef CURSORFONT
+#define CURSORFONT "cursor" /* standard cursor fonts */
+#endif
+
+/*
+ * Display flags
+ */
+#define XlibDisplayIOError (1L << 0)
+#define XlibDisplayClosing (1L << 1)
+#define XlibDisplayNoXkb (1L << 2)
+#define XlibDisplayPrivSync (1L << 3)
+#define XlibDisplayProcConni (1L << 4) /* in _XProcessInternalConnection */
+#define XlibDisplayReadEvents (1L << 5) /* in _XReadEvents */
+#define XlibDisplayReply (1L << 5) /* in _XReply */
+#define XlibDisplayWriting (1L << 6) /* in _XFlushInt, _XSend */
+#define XlibDisplayDfltRMDB (1L << 7) /* mark if RM db from XGetDefault */
+
+/*
+ * X Protocol packetizing macros.
+ */
+
+/* Need to start requests on 64 bit word boundaries
+ * on a CRAY computer so add a NoOp (127) if needed.
+ * A character pointer on a CRAY computer will be non-zero
+ * after shifting right 61 bits of it is not pointing to
+ * a word boundary.
+ */
+#ifdef WORD64
+#define WORD64ALIGN if ((long)dpy->bufptr >> 61) {\
+ dpy->last_req = dpy->bufptr;\
+ *(dpy->bufptr) = X_NoOperation;\
+ *(dpy->bufptr+1) = 0;\
+ *(dpy->bufptr+2) = 0;\
+ *(dpy->bufptr+3) = 1;\
+ dpy->request++;\
+ dpy->bufptr += 4;\
+ }
+#else /* else does not require alignment on 64-bit boundaries */
+#define WORD64ALIGN
+#endif /* WORD64 */
+
+
+/*
+ * GetReq - Get the next available X request packet in the buffer and
+ * return it.
+ *
+ * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
+ * "req" is the name of the request pointer.
+ *
+ */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = (SIZEOF(x##name##Req))>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req);\
+ dpy->request++
+
+#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
+#define GetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = (SIZEOF(x/**/name/**/Req))>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req);\
+ dpy->request++
+#endif
+
+/* GetReqExtra is the same as GetReq, but allocates "n" additional
+ bytes after the request. "n" must be a multiple of 4! */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetReqExtra(name, n, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = (SIZEOF(x##name##Req) + n)>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req) + n;\
+ dpy->request++
+#else
+#define GetReqExtra(name, n, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\
+ dpy->request++
+#endif
+
+
+/*
+ * GetResReq is for those requests that have a resource ID
+ * (Window, Pixmap, GContext, etc.) as their single argument.
+ * "rid" is the name of the resource.
+ */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetResReq(name, rid, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = 2;\
+ req->id = (rid);\
+ dpy->bufptr += SIZEOF(xResourceReq);\
+ dpy->request++
+#else
+#define GetResReq(name, rid, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = 2;\
+ req->id = (rid);\
+ dpy->bufptr += SIZEOF(xResourceReq);\
+ dpy->request++
+#endif
+
+/*
+ * GetEmptyReq is for those requests that have no arguments
+ * at all.
+ */
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetEmptyReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = 1;\
+ dpy->bufptr += SIZEOF(xReq);\
+ dpy->request++
+#else
+#define GetEmptyReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = 1;\
+ dpy->bufptr += SIZEOF(xReq);\
+ dpy->request++
+#endif
+
+#ifdef WORD64
+#define MakeBigReq(req,n) \
+ { \
+ char _BRdat[4]; \
+ unsigned long _BRlen = req->length - 1; \
+ req->length = 0; \
+ memcpy(_BRdat, ((char *)req) + (_BRlen << 2), 4); \
+ memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
+ memcpy(((char *)req) + 4, _BRdat, 4); \
+ Data32(dpy, (long *)&_BRdat, 4); \
+ }
+#else
+#ifdef LONG64
+#define MakeBigReq(req,n) \
+ { \
+ CARD64 _BRdat; \
+ CARD32 _BRlen = req->length - 1; \
+ req->length = 0; \
+ _BRdat = ((CARD32 *)req)[_BRlen]; \
+ memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
+ ((CARD32 *)req)[1] = _BRlen + n + 2; \
+ Data32(dpy, &_BRdat, 4); \
+ }
+#else
+#define MakeBigReq(req,n) \
+ { \
+ CARD32 _BRdat; \
+ CARD32 _BRlen = req->length - 1; \
+ req->length = 0; \
+ _BRdat = ((CARD32 *)req)[_BRlen]; \
+ memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
+ ((CARD32 *)req)[1] = _BRlen + n + 2; \
+ Data32(dpy, &_BRdat, 4); \
+ }
+#endif
+#endif
+
+#define SetReqLen(req,n,badlen) \
+ if ((req->length + n) > (unsigned)65535) { \
+ if (dpy->bigreq_size) { \
+ MakeBigReq(req,n) \
+ } else { \
+ n = badlen; \
+ req->length += n; \
+ } \
+ } else \
+ req->length += n
+
+#define SyncHandle() \
+ if (dpy->synchandler) (*dpy->synchandler)(dpy)
+
+extern void _XFlushGCCache(Display *dpy, GC gc);
+#define FlushGC(dpy, gc) \
+ if ((gc)->dirty) _XFlushGCCache((dpy), (gc))
+/*
+ * Data - Place data in the buffer and pad the end to provide
+ * 32 bit word alignment. Transmit if the buffer fills.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pinter to a data buffer.
+ * "len" is the length of the data buffer.
+ */
+#ifndef DataRoutineIsProcedure
+#define Data(dpy, data, len) {\
+ if (dpy->bufptr + (len) <= dpy->bufmax) {\
+ memcpy(dpy->bufptr, data, (int)len);\
+ dpy->bufptr += ((len) + 3) & ~3;\
+ } else\
+ _XSend(dpy, data, len);\
+ }
+#endif /* DataRoutineIsProcedure */
+
+
+/* Allocate bytes from the buffer. No padding is done, so if
+ * the length is not a multiple of 4, the caller must be
+ * careful to leave the buffer aligned after sending the
+ * current request.
+ *
+ * "type" is the type of the pointer being assigned to.
+ * "ptr" is the pointer being assigned to.
+ * "n" is the number of bytes to allocate.
+ *
+ * Example:
+ * xTextElt *elt;
+ * BufAlloc (xTextElt *, elt, nbytes)
+ */
+
+#define BufAlloc(type, ptr, n) \
+ if (dpy->bufptr + (n) > dpy->bufmax) \
+ _XFlush (dpy); \
+ ptr = (type) dpy->bufptr; \
+ (void)ptr; \
+ dpy->bufptr += (n);
+
+#ifdef WORD64
+#define Data16(dpy, data, len) _XData16(dpy, (short *)data, len)
+#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
+#else
+#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
+#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
+#ifdef LONG64
+#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
+extern int _XData32(
+ Display *dpy,
+ register long *data,
+ unsigned len
+);
+extern void _XRead32(
+ Display *dpy,
+ register long *data,
+ long len
+);
+#else
+#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
+#endif
+#endif /* not WORD64 */
+
+#define PackData16(dpy,data,len) Data16 (dpy, data, len)
+#define PackData32(dpy,data,len) Data32 (dpy, data, len)
+
+/* Xlib manual is bogus */
+#define PackData(dpy,data,len) PackData16 (dpy, data, len)
+
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+
+#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
+ (((cs)->rbearing|(cs)->lbearing| \
+ (cs)->ascent|(cs)->descent) == 0))
+
+/*
+ * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit
+ * character. If the character is in the column and exists, then return the
+ * appropriate metrics (note that fonts with common per-character metrics will
+ * return min_bounds). If none of these hold true, try again with the default
+ * char.
+ */
+#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \
+{ \
+ cs = def; \
+ if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
+ if (fs->per_char == NULL) { \
+ cs = &fs->min_bounds; \
+ } else { \
+ cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \
+ if (CI_NONEXISTCHAR(cs)) cs = def; \
+ } \
+ } \
+}
+
+#define CI_GET_DEFAULT_INFO_1D(fs,cs) \
+ CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs)
+
+
+
+/*
+ * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and
+ * column. This is used for fonts that have more than row zero.
+ */
+#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \
+{ \
+ cs = def; \
+ if (row >= fs->min_byte1 && row <= fs->max_byte1 && \
+ col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
+ if (fs->per_char == NULL) { \
+ cs = &fs->min_bounds; \
+ } else { \
+ cs = &fs->per_char[((row - fs->min_byte1) * \
+ (fs->max_char_or_byte2 - \
+ fs->min_char_or_byte2 + 1)) + \
+ (col - fs->min_char_or_byte2)]; \
+ if (CI_NONEXISTCHAR(cs)) cs = def; \
+ } \
+ } \
+}
+
+#define CI_GET_DEFAULT_INFO_2D(fs,cs) \
+{ \
+ unsigned int r = (fs->default_char >> 8); \
+ unsigned int c = (fs->default_char & 0xff); \
+ CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \
+}
+
+
+#ifdef MUSTCOPY
+
+/* for when 32-bit alignment is not good enough */
+#define OneDataCard32(dpy,dstaddr,srcvar) \
+ { dpy->bufptr -= 4; Data32 (dpy, (char *) &(srcvar), 4); }
+
+#else
+
+/* srcvar must be a variable for large architecture version */
+#define OneDataCard32(dpy,dstaddr,srcvar) \
+ { *(CARD32 *)(dstaddr) = (srcvar); }
+
+#endif /* MUSTCOPY */
+
+typedef struct _XInternalAsync {
+ struct _XInternalAsync *next;
+ /*
+ * handler arguments:
+ * rep is the generic reply that caused this handler
+ * to be invoked. It must also be passed to _XGetAsyncReply.
+ * buf and len are opaque values that must be passed to
+ * _XGetAsyncReply or _XGetAsyncData.
+ * data is the closure stored in this struct.
+ * The handler returns True iff it handled this reply.
+ */
+ Bool (*handler)(
+ Display* /* dpy */,
+ xReply* /* rep */,
+ char* /* buf */,
+ int /* len */,
+ XPointer /* data */
+ );
+ XPointer data;
+} _XAsyncHandler;
+
+typedef struct _XAsyncEState {
+ unsigned long min_sequence_number;
+ unsigned long max_sequence_number;
+ unsigned char error_code;
+ unsigned char major_opcode;
+ unsigned short minor_opcode;
+ unsigned char last_error_received;
+ int error_count;
+} _XAsyncErrorState;
+
+extern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler);
+#define DeqAsyncHandler(dpy,handler) { \
+ if (dpy->async_handlers == (handler)) \
+ dpy->async_handlers = (handler)->next; \
+ else \
+ _XDeqAsyncHandler(dpy, handler); \
+ }
+
+typedef void (*FreeFuncType) (
+ Display* /* display */
+);
+
+typedef int (*FreeModmapType) (
+ XModifierKeymap* /* modmap */
+);
+
+/*
+ * This structure is private to the library.
+ */
+typedef struct _XFreeFuncs {
+ FreeFuncType atoms; /* _XFreeAtomTable */
+ FreeModmapType modifiermap; /* XFreeModifierMap */
+ FreeFuncType key_bindings; /* _XFreeKeyBindings */
+ FreeFuncType context_db; /* _XFreeContextDB */
+ FreeFuncType defaultCCCs; /* _XcmsFreeDefaultCCCs */
+ FreeFuncType clientCmaps; /* _XcmsFreeClientCmaps */
+ FreeFuncType intensityMaps; /* _XcmsFreeIntensityMaps */
+ FreeFuncType im_filters; /* _XFreeIMFilters */
+ FreeFuncType xkb; /* _XkbFreeInfo */
+} _XFreeFuncRec;
+
+/* types for InitExt.c */
+typedef int (*CreateGCType) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*CopyGCType)(
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*FlushGCType) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*FreeGCType) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*CreateFontType) (
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*FreeFontType) (
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*CloseDisplayType) (
+ Display* /* display */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*ErrorType) (
+ Display* /* display */,
+ xError* /* err */,
+ XExtCodes* /* codes */,
+ int* /* ret_code */
+);
+
+typedef char* (*ErrorStringType) (
+ Display* /* display */,
+ int /* code */,
+ XExtCodes* /* codes */,
+ char* /* buffer */,
+ int /* nbytes */
+);
+
+typedef void (*PrintErrorType)(
+ Display* /* display */,
+ XErrorEvent* /* ev */,
+ void* /* fp */
+);
+
+typedef void (*BeforeFlushType)(
+ Display* /* display */,
+ XExtCodes* /* codes */,
+ _Xconst char* /* data */,
+ long /* len */
+);
+
+/*
+ * This structure is private to the library.
+ */
+typedef struct _XExten { /* private to extension mechanism */
+ struct _XExten *next; /* next in list */
+ XExtCodes codes; /* public information, all extension told */
+ CreateGCType create_GC; /* routine to call when GC created */
+ CopyGCType copy_GC; /* routine to call when GC copied */
+ FlushGCType flush_GC; /* routine to call when GC flushed */
+ FreeGCType free_GC; /* routine to call when GC freed */
+ CreateFontType create_Font; /* routine to call when Font created */
+ FreeFontType free_Font; /* routine to call when Font freed */
+ CloseDisplayType close_display; /* routine to call when connection closed */
+ ErrorType error; /* who to call when an error occurs */
+ ErrorStringType error_string; /* routine to supply error string */
+ char *name; /* name of this extension */
+ PrintErrorType error_values; /* routine to supply error values */
+ BeforeFlushType before_flush; /* routine to call when sending data */
+ struct _XExten *next_flush; /* next in list of those with flushes */
+} _XExtension;
+
+/* extension hooks */
+
+#ifdef DataRoutineIsProcedure
+extern void Data(Display *dpy, char *data, long len);
+#endif
+extern int _XError(
+ Display* /* dpy */,
+ xError* /* rep */
+);
+extern int _XIOError(
+ Display* /* dpy */
+);
+extern int (*_XIOErrorFunction)(
+ Display* /* dpy */
+);
+extern int (*_XErrorFunction)(
+ Display* /* dpy */,
+ XErrorEvent* /* error_event */
+);
+extern void _XEatData(
+ Display* /* dpy */,
+ unsigned long /* n */
+);
+extern char *_XAllocScratch(
+ Display* /* dpy */,
+ unsigned long /* nbytes */
+);
+extern char *_XAllocTemp(
+ Display* /* dpy */,
+ unsigned long /* nbytes */
+);
+extern void _XFreeTemp(
+ Display* /* dpy */,
+ char* /* buf */,
+ unsigned long /* nbytes */
+);
+extern Visual *_XVIDtoVisual(
+ Display* /* dpy */,
+ VisualID /* id */
+);
+extern unsigned long _XSetLastRequestRead(
+ Display* /* dpy */,
+ xGenericReply* /* rep */
+);
+extern int _XGetHostname(
+ char* /* buf */,
+ int /* maxlen */
+);
+extern Screen *_XScreenOfWindow(
+ Display* /* dpy */,
+ Window /* w */
+);
+extern Bool _XAsyncErrorHandler(
+ Display* /* dpy */,
+ xReply* /* rep */,
+ char* /* buf */,
+ int /* len */,
+ XPointer /* data */
+);
+extern char *_XGetAsyncReply(
+ Display* /* dpy */,
+ char* /* replbuf */,
+ xReply* /* rep */,
+ char* /* buf */,
+ int /* len */,
+ int /* extra */,
+ Bool /* discard */
+);
+extern void _XGetAsyncData(
+ Display* /* dpy */,
+ char * /* data */,
+ char * /* buf */,
+ int /* len */,
+ int /* skip */,
+ int /* datalen */,
+ int /* discardtotal */
+);
+extern void _XFlush(
+ Display* /* dpy */
+);
+extern int _XEventsQueued(
+ Display* /* dpy */,
+ int /* mode */
+);
+extern void _XReadEvents(
+ Display* /* dpy */
+);
+extern int _XRead(
+ Display* /* dpy */,
+ char* /* data */,
+ long /* size */
+);
+extern void _XReadPad(
+ Display* /* dpy */,
+ char* /* data */,
+ long /* size */
+);
+extern void _XSend(
+ Display* /* dpy */,
+ _Xconst char* /* data */,
+ long /* size */
+);
+extern Status _XReply(
+ Display* /* dpy */,
+ xReply* /* rep */,
+ int /* extra */,
+ Bool /* discard */
+);
+extern void _XEnq(
+ Display* /* dpy */,
+ xEvent* /* event */
+);
+extern void _XDeq(
+ Display* /* dpy */,
+ _XQEvent* /* prev */,
+ _XQEvent* /* qelt */
+);
+
+extern Bool _XUnknownWireEvent(
+ Display* /* dpy */,
+ XEvent* /* re */,
+ xEvent* /* event */
+);
+extern Status _XUnknownNativeEvent(
+ Display* /* dpy */,
+ XEvent* /* re */,
+ xEvent* /* event */
+);
+
+extern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event);
+extern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we);
+extern Bool _XPollfdCacheInit(Display *dpy);
+extern void _XPollfdCacheAdd(Display *dpy, int fd);
+extern void _XPollfdCacheDel(Display *dpy, int fd);
+extern XID _XAllocID(Display *dpy);
+extern void _XAllocIDs(Display *dpy, XID *ids, int count);
+
+extern int _XFreeExtData(
+ XExtData* /* extension */
+);
+
+extern int (*XESetCreateGC(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, GC, XExtCodes*
+);
+
+extern int (*XESetCopyGC(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, GC, XExtCodes*
+);
+
+extern int (*XESetFlushGC(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, GC, XExtCodes*
+);
+
+extern int (*XESetFreeGC(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, GC, XExtCodes*
+);
+
+extern int (*XESetCreateFont(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, XFontStruct*, XExtCodes*
+);
+
+extern int (*XESetFreeFont(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, XFontStruct*, XExtCodes*
+);
+
+extern int (*XESetCloseDisplay(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, XExtCodes*
+);
+
+extern int (*XESetError(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ xError* /* err */,
+ XExtCodes* /* codes */,
+ int* /* ret_code */
+ ) /* proc */
+))(
+ Display*, xError*, XExtCodes*, int*
+);
+
+extern char* (*XESetErrorString(
+ Display* /* display */,
+ int /* extension */,
+ char* (*) (
+ Display* /* display */,
+ int /* code */,
+ XExtCodes* /* codes */,
+ char* /* buffer */,
+ int /* nbytes */
+ ) /* proc */
+))(
+ Display*, int, XExtCodes*, char*, int
+);
+
+extern void (*XESetPrintErrorValues (
+ Display* /* display */,
+ int /* extension */,
+ void (*)(
+ Display* /* display */,
+ XErrorEvent* /* ev */,
+ void* /* fp */
+ ) /* proc */
+))(
+ Display*, XErrorEvent*, void*
+);
+
+extern Bool (*XESetWireToEvent(
+ Display* /* display */,
+ int /* event_number */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+ ) /* proc */
+))(
+ Display*, XEvent*, xEvent*
+);
+
+extern Status (*XESetEventToWire(
+ Display* /* display */,
+ int /* event_number */,
+ Status (*) (
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+ ) /* proc */
+))(
+ Display*, XEvent*, xEvent*
+);
+
+extern Bool (*XESetWireToError(
+ Display* /* display */,
+ int /* error_number */,
+ Bool (*) (
+ Display* /* display */,
+ XErrorEvent* /* he */,
+ xError* /* we */
+ ) /* proc */
+))(
+ Display*, XErrorEvent*, xError*
+);
+
+extern void (*XESetBeforeFlush(
+ Display* /* display */,
+ int /* error_number */,
+ void (*) (
+ Display* /* display */,
+ XExtCodes* /* codes */,
+ _Xconst char* /* data */,
+ long /* len */
+ ) /* proc */
+))(
+ Display*, XExtCodes*, _Xconst char*, long
+);
+
+/* internal connections for IMs */
+
+typedef void (*_XInternalConnectionProc)(
+ Display* /* dpy */,
+ int /* fd */,
+ XPointer /* call_data */
+);
+
+
+extern Status _XRegisterInternalConnection(
+ Display* /* dpy */,
+ int /* fd */,
+ _XInternalConnectionProc /* callback */,
+ XPointer /* call_data */
+);
+
+extern void _XUnregisterInternalConnection(
+ Display* /* dpy */,
+ int /* fd */
+);
+
+/* Display structure has pointers to these */
+
+struct _XConnectionInfo { /* info from _XRegisterInternalConnection */
+ int fd;
+ _XInternalConnectionProc read_callback;
+ XPointer call_data;
+ XPointer *watch_data; /* set/used by XConnectionWatchProc */
+ struct _XConnectionInfo *next;
+};
+
+struct _XConnWatchInfo { /* info from XAddConnectionWatch */
+ XConnectionWatchProc fn;
+ XPointer client_data;
+ struct _XConnWatchInfo *next;
+};
+
+#ifdef __UNIXOS2__
+extern char* __XOS2RedirRoot(
+ char*
+);
+#endif
+
+extern int _XTextHeight(
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* count */
+);
+
+extern int _XTextHeight16(
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* count */
+);
+
+#if defined(WIN32)
+
+extern int _XOpenFile(
+ _Xconst char* /* path */,
+ int /* flags */
+);
+
+extern void* _XFopenFile(
+ _Xconst char* /* path */,
+ _Xconst char* /* mode */
+);
+
+extern int _XAccessFile(
+ _Xconst char* /* path */
+);
+#else
+#define _XOpenFile(path,flags) open(path,flags)
+#define _XFopenFile(path,mode) fopen(path,mode)
+#endif
+
+/* EvToWire.c */
+extern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event);
+
+extern int _XF86LoadQueryLocaleFont(
+ Display* /* dpy */,
+ _Xconst char* /* name*/,
+ XFontStruct** /* xfp*/,
+ Font* /* fidp */
+);
+
+extern void _XProcessWindowAttributes (
+ register Display *dpy,
+ xChangeWindowAttributesReq *req,
+ register unsigned long valuemask,
+ register XSetWindowAttributes *attributes);
+
+extern int _XDefaultError(
+ Display *dpy,
+ XErrorEvent *event);
+
+extern int _XDefaultIOError(
+ Display *dpy);
+
+extern void _XSetClipRectangles (
+ register Display *dpy,
+ GC gc,
+ int clip_x_origin, int clip_y_origin,
+ XRectangle *rectangles,
+ int n,
+ int ordering);
+
+Status _XGetWindowAttributes(
+ register Display *dpy,
+ Window w,
+ XWindowAttributes *attr);
+
+int _XPutBackEvent (
+ register Display *dpy,
+ register XEvent *event);
+
+_XFUNCPROTOEND
+
+#endif /* _XLIBINT_H_ */
diff --git a/nx-X11/lib/X11/Xlibint.h.X.original b/nx-X11/lib/X11/Xlibint.h.X.original
new file mode 100644
index 000000000..8517f6539
--- /dev/null
+++ b/nx-X11/lib/X11/Xlibint.h.X.original
@@ -0,0 +1,1313 @@
+/* $Xorg: Xlibint.h,v 1.5 2001/02/09 02:03:38 xorgcvs Exp $ */
+
+/*
+
+Copyright 1984, 1985, 1987, 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.
+
+*/
+/* $XFree86: xc/lib/X11/Xlibint.h,v 3.27 2003/05/27 22:26:26 tsi Exp $ */
+
+#ifndef _XLIBINT_H_
+#define _XLIBINT_H_ 1
+
+/*
+ * Xlibint.h - Header definition and support file for the internal
+ * support routines used by the C subroutine interface
+ * library (Xlib) to the X Window System.
+ *
+ * Warning, there be dragons here....
+ */
+
+#include <X11/Xlib.h>
+#include <X11/Xproto.h> /* to declare xEvent */
+#include <X11/XlibConf.h> /* for configured options like XTHREADS */
+
+#ifdef WIN32
+#define _XFlush _XFlushIt
+#endif
+
+/*
+ * If your BytesReadable correctly detects broken connections, then
+ * you should NOT define XCONN_CHECK_FREQ.
+ */
+#ifndef XCONN_CHECK_FREQ
+#define XCONN_CHECK_FREQ 256
+#endif
+
+struct _XGC
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ GContext gid; /* protocol ID for graphics context */
+ Bool rects; /* boolean: TRUE if clipmask is list of rectangles */
+ Bool dashes; /* boolean: TRUE if dash-list is really a list */
+ unsigned long dirty;/* cache dirty bits */
+ XGCValues values; /* shadow structure of values */
+};
+
+struct _XDisplay
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XFreeFuncs *free_funcs; /* internal free functions */
+ int fd; /* Network socket. */
+ int conn_checker; /* ugly thing used by _XEventsQueued */
+ int proto_major_version;/* maj. version of server's X protocol */
+ int proto_minor_version;/* minor version of server's X protocol */
+ char *vendor; /* vendor of the server hardware */
+ XID resource_base; /* resource ID base */
+ XID resource_mask; /* resource ID mask bits */
+ XID resource_id; /* allocator current ID */
+ int resource_shift; /* allocator shift to correct bits */
+ XID (*resource_alloc)( /* allocator function */
+ struct _XDisplay*
+ );
+ int byte_order; /* screen byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* padding and data requirements */
+ int bitmap_pad; /* padding requirements on bitmaps */
+ int bitmap_bit_order; /* LeastSignificant or MostSignificant */
+ int nformats; /* number of pixmap formats in list */
+ ScreenFormat *pixmap_format; /* pixmap format list */
+ int vnumber; /* Xlib's X protocol version number. */
+ int release; /* release of the server */
+ struct _XSQEvent *head, *tail; /* Input event queue. */
+ int qlen; /* Length of input event queue */
+ unsigned long last_request_read; /* seq number of last event read */
+ unsigned long request; /* sequence number of last request. */
+ char *last_req; /* beginning of last request, or dummy */
+ char *buffer; /* Output buffer starting address. */
+ char *bufptr; /* Output buffer index pointer. */
+ char *bufmax; /* Output buffer maximum+1 address. */
+ unsigned max_request_size; /* maximum number 32 bit words in request*/
+ struct _XrmHashBucketRec *db;
+ int (*synchandler)( /* Synchronization handler */
+ struct _XDisplay*
+ );
+ char *display_name; /* "host:display" string used on this connect*/
+ int default_screen; /* default screen for operations */
+ int nscreens; /* number of screens on this server*/
+ Screen *screens; /* pointer to list of screens */
+ unsigned long motion_buffer; /* size of motion buffer */
+ unsigned long flags; /* internal connection flags */
+ int min_keycode; /* minimum defined keycode */
+ int max_keycode; /* maximum defined keycode */
+ KeySym *keysyms; /* This server's keysyms */
+ XModifierKeymap *modifiermap; /* This server's modifier keymap */
+ int keysyms_per_keycode;/* number of rows */
+ char *xdefaults; /* contents of defaults from server */
+ char *scratch_buffer; /* place to hang scratch buffer */
+ unsigned long scratch_length; /* length of scratch buffer */
+ int ext_number; /* extension number on this display */
+ struct _XExten *ext_procs; /* extensions initialized on this display */
+ /*
+ * the following can be fixed size, as the protocol defines how
+ * much address space is available.
+ * While this could be done using the extension vector, there
+ * may be MANY events processed, so a search through the extension
+ * list to find the right procedure for each event might be
+ * expensive if many extensions are being used.
+ */
+ Bool (*event_vec[128])( /* vector for wire to event */
+ Display * /* dpy */,
+ XEvent * /* re */,
+ xEvent * /* event */
+ );
+ Status (*wire_vec[128])( /* vector for event to wire */
+ Display * /* dpy */,
+ XEvent * /* re */,
+ xEvent * /* event */
+ );
+ KeySym lock_meaning; /* for XLookupString */
+ struct _XLockInfo *lock; /* multi-thread state, display lock */
+ struct _XInternalAsync *async_handlers; /* for internal async */
+ unsigned long bigreq_size; /* max size of big requests */
+ struct _XLockPtrs *lock_fns; /* pointers to threads functions */
+ void (*idlist_alloc)( /* XID list allocator function */
+ Display * /* dpy */,
+ XID * /* ids */,
+ int /* count */
+ );
+ /* things above this line should not move, for binary compatibility */
+ struct _XKeytrans *key_bindings; /* for XLookupString */
+ Font cursor_font; /* for XCreateFontCursor */
+ struct _XDisplayAtoms *atoms; /* for XInternAtom */
+ unsigned int mode_switch; /* keyboard group modifiers */
+ unsigned int num_lock; /* keyboard numlock modifiers */
+ struct _XContextDB *context_db; /* context database */
+ Bool (**error_vec)( /* vector for wire to error */
+ Display * /* display */,
+ XErrorEvent * /* he */,
+ xError * /* we */
+ );
+ /*
+ * Xcms information
+ */
+ struct {
+ XPointer defaultCCCs; /* pointer to an array of default XcmsCCC */
+ XPointer clientCmaps; /* pointer to linked list of XcmsCmapRec */
+ XPointer perVisualIntensityMaps;
+ /* linked list of XcmsIntensityMap */
+ } cms;
+ struct _XIMFilter *im_filters;
+ struct _XSQEvent *qfree; /* unallocated event queue elements */
+ unsigned long next_event_serial_num; /* inserted into next queue elt */
+ struct _XExten *flushes; /* Flush hooks */
+ struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */
+ int im_fd_length; /* number of im_fd_info */
+ struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */
+ int watcher_count; /* number of conn_watchers */
+ XPointer filedes; /* struct pollfd cache for _XWaitForReadable */
+ int (*savedsynchandler)( /* user synchandler when Xlib usurps */
+ Display * /* dpy */
+ );
+ XID resource_max; /* allocator max ID */
+ int xcmisc_opcode; /* major opcode for XC-MISC */
+ struct _XkbInfoRec *xkb_info; /* XKB info */
+ struct _XtransConnInfo *trans_conn; /* transport connection object */
+};
+
+#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
+
+/*
+ * define the following if you want the Data macro to be a procedure instead
+ */
+#ifdef CRAY
+#define DataRoutineIsProcedure
+#endif /* CRAY */
+
+#ifndef _XEVENT_
+/*
+ * _QEvent datatype for use in input queueing.
+ */
+typedef struct _XSQEvent
+{
+ struct _XSQEvent *next;
+ XEvent event;
+ unsigned long qserial_num; /* so multi-threaded code can find new ones */
+} _XQEvent;
+#endif
+
+#ifdef XTHREADS /* for xReply */
+#define NEED_REPLIES
+#endif
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#ifdef __sgi
+#define _SGI_MP_SOURCE /* turn this on to get MP safe errno */
+#endif
+#include <errno.h>
+#define _XBCOPYFUNC _Xbcopy
+#include <X11/Xfuncs.h>
+#include <X11/Xosdefs.h>
+
+/* Utek leaves kernel macros around in include files (bleah) */
+#ifdef dirty
+#undef dirty
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+/*
+ * The following definitions can be used for locking requests in multi-threaded
+ * address spaces.
+ */
+#ifdef XTHREADS
+/* Author: Stephen Gildea, MIT X Consortium
+ *
+ * declarations for C Threads locking
+ */
+
+typedef struct _LockInfoRec *LockInfoPtr;
+
+/* interfaces for locking.c */
+struct _XLockPtrs {
+ /* used by all, including extensions; do not move */
+ void (*lock_display)(
+ Display *dpy
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char *file
+ , int line
+#endif
+ );
+ void (*unlock_display)(
+ Display *dpy
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char *file
+ , int line
+#endif
+ );
+};
+
+#if defined(WIN32) && !defined(_XLIBINT_)
+#define _XCreateMutex_fn (*_XCreateMutex_fn_p)
+#define _XFreeMutex_fn (*_XFreeMutex_fn_p)
+#define _XLockMutex_fn (*_XLockMutex_fn_p)
+#define _XUnlockMutex_fn (*_XUnlockMutex_fn_p)
+#define _Xglobal_lock (*_Xglobal_lock_p)
+#endif
+
+/* in XlibInt.c */
+extern void (*_XCreateMutex_fn)(
+ LockInfoPtr /* lock */
+);
+extern void (*_XFreeMutex_fn)(
+ LockInfoPtr /* lock */
+);
+extern void (*_XLockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+);
+extern void (*_XUnlockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+);
+
+extern LockInfoPtr _Xglobal_lock;
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__)
+#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__)
+#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__)
+#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__)
+#else
+/* used everywhere, so must be fast if not using threads */
+#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d)
+#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d)
+#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock)
+#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock)
+#endif
+#define _XCreateMutex(lock) if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock);
+#define _XFreeMutex(lock) if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock);
+
+#else /* XTHREADS */
+#define LockDisplay(dis)
+#define _XLockMutex(lock)
+#define _XUnlockMutex(lock)
+#define UnlockDisplay(dis)
+#define _XCreateMutex(lock)
+#define _XFreeMutex(lock)
+#endif
+
+#define Xfree(ptr) free((ptr))
+
+/*
+ * Note that some machines do not return a valid pointer for malloc(0), in
+ * which case we provide an alternate under the control of the
+ * define MALLOC_0_RETURNS_NULL. This is necessary because some
+ * Xlib code expects malloc(0) to return a valid pointer to storage.
+ */
+#ifdef MALLOC_0_RETURNS_NULL
+
+# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size)))
+# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size)))
+# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize))
+
+#else
+
+# define Xmalloc(size) malloc((size))
+# define Xrealloc(ptr, size) realloc((ptr), (size))
+# define Xcalloc(nelem, elsize) calloc((nelem), (elsize))
+
+#endif
+
+#include <stddef.h>
+
+#define LOCKED 1
+#define UNLOCKED 0
+
+#ifndef BUFSIZE
+#define BUFSIZE 2048 /* X output buffer size. */
+#endif
+#ifndef PTSPERBATCH
+#define PTSPERBATCH 1024 /* point batching */
+#endif
+#ifndef WLNSPERBATCH
+#define WLNSPERBATCH 50 /* wide line batching */
+#endif
+#ifndef ZLNSPERBATCH
+#define ZLNSPERBATCH 1024 /* thin line batching */
+#endif
+#ifndef WRCTSPERBATCH
+#define WRCTSPERBATCH 10 /* wide line rectangle batching */
+#endif
+#ifndef ZRCTSPERBATCH
+#define ZRCTSPERBATCH 256 /* thin line rectangle batching */
+#endif
+#ifndef FRCTSPERBATCH
+#define FRCTSPERBATCH 256 /* filled rectangle batching */
+#endif
+#ifndef FARCSPERBATCH
+#define FARCSPERBATCH 256 /* filled arc batching */
+#endif
+#ifndef CURSORFONT
+#define CURSORFONT "cursor" /* standard cursor fonts */
+#endif
+
+/*
+ * Display flags
+ */
+#define XlibDisplayIOError (1L << 0)
+#define XlibDisplayClosing (1L << 1)
+#define XlibDisplayNoXkb (1L << 2)
+#define XlibDisplayPrivSync (1L << 3)
+#define XlibDisplayProcConni (1L << 4) /* in _XProcessInternalConnection */
+#define XlibDisplayReadEvents (1L << 5) /* in _XReadEvents */
+#define XlibDisplayReply (1L << 5) /* in _XReply */
+#define XlibDisplayWriting (1L << 6) /* in _XFlushInt, _XSend */
+#define XlibDisplayDfltRMDB (1L << 7) /* mark if RM db from XGetDefault */
+
+/*
+ * X Protocol packetizing macros.
+ */
+
+/* Need to start requests on 64 bit word boundaries
+ * on a CRAY computer so add a NoOp (127) if needed.
+ * A character pointer on a CRAY computer will be non-zero
+ * after shifting right 61 bits of it is not pointing to
+ * a word boundary.
+ */
+#ifdef WORD64
+#define WORD64ALIGN if ((long)dpy->bufptr >> 61) {\
+ dpy->last_req = dpy->bufptr;\
+ *(dpy->bufptr) = X_NoOperation;\
+ *(dpy->bufptr+1) = 0;\
+ *(dpy->bufptr+2) = 0;\
+ *(dpy->bufptr+3) = 1;\
+ dpy->request++;\
+ dpy->bufptr += 4;\
+ }
+#else /* else does not require alignment on 64-bit boundaries */
+#define WORD64ALIGN
+#endif /* WORD64 */
+
+
+/*
+ * GetReq - Get the next available X request packet in the buffer and
+ * return it.
+ *
+ * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
+ * "req" is the name of the request pointer.
+ *
+ */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = (SIZEOF(x##name##Req))>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req);\
+ dpy->request++
+
+#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
+#define GetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = (SIZEOF(x/**/name/**/Req))>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req);\
+ dpy->request++
+#endif
+
+/* GetReqExtra is the same as GetReq, but allocates "n" additional
+ bytes after the request. "n" must be a multiple of 4! */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetReqExtra(name, n, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = (SIZEOF(x##name##Req) + n)>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req) + n;\
+ dpy->request++
+#else
+#define GetReqExtra(name, n, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\
+ dpy->request++
+#endif
+
+
+/*
+ * GetResReq is for those requests that have a resource ID
+ * (Window, Pixmap, GContext, etc.) as their single argument.
+ * "rid" is the name of the resource.
+ */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetResReq(name, rid, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = 2;\
+ req->id = (rid);\
+ dpy->bufptr += SIZEOF(xResourceReq);\
+ dpy->request++
+#else
+#define GetResReq(name, rid, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = 2;\
+ req->id = (rid);\
+ dpy->bufptr += SIZEOF(xResourceReq);\
+ dpy->request++
+#endif
+
+/*
+ * GetEmptyReq is for those requests that have no arguments
+ * at all.
+ */
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetEmptyReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = 1;\
+ dpy->bufptr += SIZEOF(xReq);\
+ dpy->request++
+#else
+#define GetEmptyReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = 1;\
+ dpy->bufptr += SIZEOF(xReq);\
+ dpy->request++
+#endif
+
+#ifdef WORD64
+#define MakeBigReq(req,n) \
+ { \
+ char _BRdat[4]; \
+ unsigned long _BRlen = req->length - 1; \
+ req->length = 0; \
+ memcpy(_BRdat, ((char *)req) + (_BRlen << 2), 4); \
+ memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
+ memcpy(((char *)req) + 4, _BRdat, 4); \
+ Data32(dpy, (long *)&_BRdat, 4); \
+ }
+#else
+#ifdef LONG64
+#define MakeBigReq(req,n) \
+ { \
+ CARD64 _BRdat; \
+ CARD32 _BRlen = req->length - 1; \
+ req->length = 0; \
+ _BRdat = ((CARD32 *)req)[_BRlen]; \
+ memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
+ ((CARD32 *)req)[1] = _BRlen + n + 2; \
+ Data32(dpy, &_BRdat, 4); \
+ }
+#else
+#define MakeBigReq(req,n) \
+ { \
+ CARD32 _BRdat; \
+ CARD32 _BRlen = req->length - 1; \
+ req->length = 0; \
+ _BRdat = ((CARD32 *)req)[_BRlen]; \
+ memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
+ ((CARD32 *)req)[1] = _BRlen + n + 2; \
+ Data32(dpy, &_BRdat, 4); \
+ }
+#endif
+#endif
+
+#define SetReqLen(req,n,badlen) \
+ if ((req->length + n) > (unsigned)65535) { \
+ if (dpy->bigreq_size) { \
+ MakeBigReq(req,n) \
+ } else { \
+ n = badlen; \
+ req->length += n; \
+ } \
+ } else \
+ req->length += n
+
+#define SyncHandle() \
+ if (dpy->synchandler) (*dpy->synchandler)(dpy)
+
+extern void _XFlushGCCache(Display *dpy, GC gc);
+#define FlushGC(dpy, gc) \
+ if ((gc)->dirty) _XFlushGCCache((dpy), (gc))
+/*
+ * Data - Place data in the buffer and pad the end to provide
+ * 32 bit word alignment. Transmit if the buffer fills.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pinter to a data buffer.
+ * "len" is the length of the data buffer.
+ */
+#ifndef DataRoutineIsProcedure
+#define Data(dpy, data, len) {\
+ if (dpy->bufptr + (len) <= dpy->bufmax) {\
+ memcpy(dpy->bufptr, data, (int)len);\
+ dpy->bufptr += ((len) + 3) & ~3;\
+ } else\
+ _XSend(dpy, data, len);\
+ }
+#endif /* DataRoutineIsProcedure */
+
+
+/* Allocate bytes from the buffer. No padding is done, so if
+ * the length is not a multiple of 4, the caller must be
+ * careful to leave the buffer aligned after sending the
+ * current request.
+ *
+ * "type" is the type of the pointer being assigned to.
+ * "ptr" is the pointer being assigned to.
+ * "n" is the number of bytes to allocate.
+ *
+ * Example:
+ * xTextElt *elt;
+ * BufAlloc (xTextElt *, elt, nbytes)
+ */
+
+#define BufAlloc(type, ptr, n) \
+ if (dpy->bufptr + (n) > dpy->bufmax) \
+ _XFlush (dpy); \
+ ptr = (type) dpy->bufptr; \
+ (void)ptr; \
+ dpy->bufptr += (n);
+
+#ifdef WORD64
+#define Data16(dpy, data, len) _XData16(dpy, (short *)data, len)
+#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
+#else
+#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
+#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
+#ifdef LONG64
+#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
+extern int _XData32(
+ Display *dpy,
+ register long *data,
+ unsigned len
+);
+extern void _XRead32(
+ Display *dpy,
+ register long *data,
+ long len
+);
+#else
+#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
+#endif
+#endif /* not WORD64 */
+
+#define PackData16(dpy,data,len) Data16 (dpy, data, len)
+#define PackData32(dpy,data,len) Data32 (dpy, data, len)
+
+/* Xlib manual is bogus */
+#define PackData(dpy,data,len) PackData16 (dpy, data, len)
+
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+
+#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
+ (((cs)->rbearing|(cs)->lbearing| \
+ (cs)->ascent|(cs)->descent) == 0))
+
+/*
+ * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit
+ * character. If the character is in the column and exists, then return the
+ * appropriate metrics (note that fonts with common per-character metrics will
+ * return min_bounds). If none of these hold true, try again with the default
+ * char.
+ */
+#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \
+{ \
+ cs = def; \
+ if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
+ if (fs->per_char == NULL) { \
+ cs = &fs->min_bounds; \
+ } else { \
+ cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \
+ if (CI_NONEXISTCHAR(cs)) cs = def; \
+ } \
+ } \
+}
+
+#define CI_GET_DEFAULT_INFO_1D(fs,cs) \
+ CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs)
+
+
+
+/*
+ * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and
+ * column. This is used for fonts that have more than row zero.
+ */
+#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \
+{ \
+ cs = def; \
+ if (row >= fs->min_byte1 && row <= fs->max_byte1 && \
+ col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
+ if (fs->per_char == NULL) { \
+ cs = &fs->min_bounds; \
+ } else { \
+ cs = &fs->per_char[((row - fs->min_byte1) * \
+ (fs->max_char_or_byte2 - \
+ fs->min_char_or_byte2 + 1)) + \
+ (col - fs->min_char_or_byte2)]; \
+ if (CI_NONEXISTCHAR(cs)) cs = def; \
+ } \
+ } \
+}
+
+#define CI_GET_DEFAULT_INFO_2D(fs,cs) \
+{ \
+ unsigned int r = (fs->default_char >> 8); \
+ unsigned int c = (fs->default_char & 0xff); \
+ CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \
+}
+
+
+#ifdef MUSTCOPY
+
+/* for when 32-bit alignment is not good enough */
+#define OneDataCard32(dpy,dstaddr,srcvar) \
+ { dpy->bufptr -= 4; Data32 (dpy, (char *) &(srcvar), 4); }
+
+#else
+
+/* srcvar must be a variable for large architecture version */
+#define OneDataCard32(dpy,dstaddr,srcvar) \
+ { *(CARD32 *)(dstaddr) = (srcvar); }
+
+#endif /* MUSTCOPY */
+
+typedef struct _XInternalAsync {
+ struct _XInternalAsync *next;
+ /*
+ * handler arguments:
+ * rep is the generic reply that caused this handler
+ * to be invoked. It must also be passed to _XGetAsyncReply.
+ * buf and len are opaque values that must be passed to
+ * _XGetAsyncReply or _XGetAsyncData.
+ * data is the closure stored in this struct.
+ * The handler returns True iff it handled this reply.
+ */
+ Bool (*handler)(
+ Display* /* dpy */,
+ xReply* /* rep */,
+ char* /* buf */,
+ int /* len */,
+ XPointer /* data */
+ );
+ XPointer data;
+} _XAsyncHandler;
+
+typedef struct _XAsyncEState {
+ unsigned long min_sequence_number;
+ unsigned long max_sequence_number;
+ unsigned char error_code;
+ unsigned char major_opcode;
+ unsigned short minor_opcode;
+ unsigned char last_error_received;
+ int error_count;
+} _XAsyncErrorState;
+
+extern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler);
+#define DeqAsyncHandler(dpy,handler) { \
+ if (dpy->async_handlers == (handler)) \
+ dpy->async_handlers = (handler)->next; \
+ else \
+ _XDeqAsyncHandler(dpy, handler); \
+ }
+
+typedef void (*FreeFuncType) (
+ Display* /* display */
+);
+
+typedef int (*FreeModmapType) (
+ XModifierKeymap* /* modmap */
+);
+
+/*
+ * This structure is private to the library.
+ */
+typedef struct _XFreeFuncs {
+ FreeFuncType atoms; /* _XFreeAtomTable */
+ FreeModmapType modifiermap; /* XFreeModifierMap */
+ FreeFuncType key_bindings; /* _XFreeKeyBindings */
+ FreeFuncType context_db; /* _XFreeContextDB */
+ FreeFuncType defaultCCCs; /* _XcmsFreeDefaultCCCs */
+ FreeFuncType clientCmaps; /* _XcmsFreeClientCmaps */
+ FreeFuncType intensityMaps; /* _XcmsFreeIntensityMaps */
+ FreeFuncType im_filters; /* _XFreeIMFilters */
+ FreeFuncType xkb; /* _XkbFreeInfo */
+} _XFreeFuncRec;
+
+/* types for InitExt.c */
+typedef int (*CreateGCType) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*CopyGCType)(
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*FlushGCType) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*FreeGCType) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*CreateFontType) (
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*FreeFontType) (
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*CloseDisplayType) (
+ Display* /* display */,
+ XExtCodes* /* codes */
+);
+
+typedef int (*ErrorType) (
+ Display* /* display */,
+ xError* /* err */,
+ XExtCodes* /* codes */,
+ int* /* ret_code */
+);
+
+typedef char* (*ErrorStringType) (
+ Display* /* display */,
+ int /* code */,
+ XExtCodes* /* codes */,
+ char* /* buffer */,
+ int /* nbytes */
+);
+
+typedef void (*PrintErrorType)(
+ Display* /* display */,
+ XErrorEvent* /* ev */,
+ void* /* fp */
+);
+
+typedef void (*BeforeFlushType)(
+ Display* /* display */,
+ XExtCodes* /* codes */,
+ _Xconst char* /* data */,
+ long /* len */
+);
+
+/*
+ * This structure is private to the library.
+ */
+typedef struct _XExten { /* private to extension mechanism */
+ struct _XExten *next; /* next in list */
+ XExtCodes codes; /* public information, all extension told */
+ CreateGCType create_GC; /* routine to call when GC created */
+ CopyGCType copy_GC; /* routine to call when GC copied */
+ FlushGCType flush_GC; /* routine to call when GC flushed */
+ FreeGCType free_GC; /* routine to call when GC freed */
+ CreateFontType create_Font; /* routine to call when Font created */
+ FreeFontType free_Font; /* routine to call when Font freed */
+ CloseDisplayType close_display; /* routine to call when connection closed */
+ ErrorType error; /* who to call when an error occurs */
+ ErrorStringType error_string; /* routine to supply error string */
+ char *name; /* name of this extension */
+ PrintErrorType error_values; /* routine to supply error values */
+ BeforeFlushType before_flush; /* routine to call when sending data */
+ struct _XExten *next_flush; /* next in list of those with flushes */
+} _XExtension;
+
+/* extension hooks */
+
+#ifdef DataRoutineIsProcedure
+extern void Data(Display *dpy, char *data, long len);
+#endif
+extern int _XError(
+ Display* /* dpy */,
+ xError* /* rep */
+);
+extern int _XIOError(
+ Display* /* dpy */
+);
+extern int (*_XIOErrorFunction)(
+ Display* /* dpy */
+);
+extern int (*_XErrorFunction)(
+ Display* /* dpy */,
+ XErrorEvent* /* error_event */
+);
+extern void _XEatData(
+ Display* /* dpy */,
+ unsigned long /* n */
+);
+extern char *_XAllocScratch(
+ Display* /* dpy */,
+ unsigned long /* nbytes */
+);
+extern char *_XAllocTemp(
+ Display* /* dpy */,
+ unsigned long /* nbytes */
+);
+extern void _XFreeTemp(
+ Display* /* dpy */,
+ char* /* buf */,
+ unsigned long /* nbytes */
+);
+extern Visual *_XVIDtoVisual(
+ Display* /* dpy */,
+ VisualID /* id */
+);
+extern unsigned long _XSetLastRequestRead(
+ Display* /* dpy */,
+ xGenericReply* /* rep */
+);
+extern int _XGetHostname(
+ char* /* buf */,
+ int /* maxlen */
+);
+extern Screen *_XScreenOfWindow(
+ Display* /* dpy */,
+ Window /* w */
+);
+extern Bool _XAsyncErrorHandler(
+ Display* /* dpy */,
+ xReply* /* rep */,
+ char* /* buf */,
+ int /* len */,
+ XPointer /* data */
+);
+extern char *_XGetAsyncReply(
+ Display* /* dpy */,
+ char* /* replbuf */,
+ xReply* /* rep */,
+ char* /* buf */,
+ int /* len */,
+ int /* extra */,
+ Bool /* discard */
+);
+extern void _XGetAsyncData(
+ Display* /* dpy */,
+ char * /* data */,
+ char * /* buf */,
+ int /* len */,
+ int /* skip */,
+ int /* datalen */,
+ int /* discardtotal */
+);
+extern void _XFlush(
+ Display* /* dpy */
+);
+extern int _XEventsQueued(
+ Display* /* dpy */,
+ int /* mode */
+);
+extern void _XReadEvents(
+ Display* /* dpy */
+);
+extern int _XRead(
+ Display* /* dpy */,
+ char* /* data */,
+ long /* size */
+);
+extern void _XReadPad(
+ Display* /* dpy */,
+ char* /* data */,
+ long /* size */
+);
+extern void _XSend(
+ Display* /* dpy */,
+ _Xconst char* /* data */,
+ long /* size */
+);
+extern Status _XReply(
+ Display* /* dpy */,
+ xReply* /* rep */,
+ int /* extra */,
+ Bool /* discard */
+);
+extern void _XEnq(
+ Display* /* dpy */,
+ xEvent* /* event */
+);
+extern void _XDeq(
+ Display* /* dpy */,
+ _XQEvent* /* prev */,
+ _XQEvent* /* qelt */
+);
+
+extern Bool _XUnknownWireEvent(
+ Display* /* dpy */,
+ XEvent* /* re */,
+ xEvent* /* event */
+);
+extern Status _XUnknownNativeEvent(
+ Display* /* dpy */,
+ XEvent* /* re */,
+ xEvent* /* event */
+);
+
+extern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event);
+extern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we);
+extern Bool _XPollfdCacheInit(Display *dpy);
+extern void _XPollfdCacheAdd(Display *dpy, int fd);
+extern void _XPollfdCacheDel(Display *dpy, int fd);
+extern XID _XAllocID(Display *dpy);
+extern void _XAllocIDs(Display *dpy, XID *ids, int count);
+
+extern int _XFreeExtData(
+ XExtData* /* extension */
+);
+
+extern int (*XESetCreateGC(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, GC, XExtCodes*
+);
+
+extern int (*XESetCopyGC(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, GC, XExtCodes*
+);
+
+extern int (*XESetFlushGC(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, GC, XExtCodes*
+);
+
+extern int (*XESetFreeGC(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, GC, XExtCodes*
+);
+
+extern int (*XESetCreateFont(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, XFontStruct*, XExtCodes*
+);
+
+extern int (*XESetFreeFont(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, XFontStruct*, XExtCodes*
+);
+
+extern int (*XESetCloseDisplay(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ XExtCodes* /* codes */
+ ) /* proc */
+))(
+ Display*, XExtCodes*
+);
+
+extern int (*XESetError(
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+ Display* /* display */,
+ xError* /* err */,
+ XExtCodes* /* codes */,
+ int* /* ret_code */
+ ) /* proc */
+))(
+ Display*, xError*, XExtCodes*, int*
+);
+
+extern char* (*XESetErrorString(
+ Display* /* display */,
+ int /* extension */,
+ char* (*) (
+ Display* /* display */,
+ int /* code */,
+ XExtCodes* /* codes */,
+ char* /* buffer */,
+ int /* nbytes */
+ ) /* proc */
+))(
+ Display*, int, XExtCodes*, char*, int
+);
+
+extern void (*XESetPrintErrorValues (
+ Display* /* display */,
+ int /* extension */,
+ void (*)(
+ Display* /* display */,
+ XErrorEvent* /* ev */,
+ void* /* fp */
+ ) /* proc */
+))(
+ Display*, XErrorEvent*, void*
+);
+
+extern Bool (*XESetWireToEvent(
+ Display* /* display */,
+ int /* event_number */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+ ) /* proc */
+))(
+ Display*, XEvent*, xEvent*
+);
+
+extern Status (*XESetEventToWire(
+ Display* /* display */,
+ int /* event_number */,
+ Status (*) (
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+ ) /* proc */
+))(
+ Display*, XEvent*, xEvent*
+);
+
+extern Bool (*XESetWireToError(
+ Display* /* display */,
+ int /* error_number */,
+ Bool (*) (
+ Display* /* display */,
+ XErrorEvent* /* he */,
+ xError* /* we */
+ ) /* proc */
+))(
+ Display*, XErrorEvent*, xError*
+);
+
+extern void (*XESetBeforeFlush(
+ Display* /* display */,
+ int /* error_number */,
+ void (*) (
+ Display* /* display */,
+ XExtCodes* /* codes */,
+ _Xconst char* /* data */,
+ long /* len */
+ ) /* proc */
+))(
+ Display*, XExtCodes*, _Xconst char*, long
+);
+
+/* internal connections for IMs */
+
+typedef void (*_XInternalConnectionProc)(
+ Display* /* dpy */,
+ int /* fd */,
+ XPointer /* call_data */
+);
+
+
+extern Status _XRegisterInternalConnection(
+ Display* /* dpy */,
+ int /* fd */,
+ _XInternalConnectionProc /* callback */,
+ XPointer /* call_data */
+);
+
+extern void _XUnregisterInternalConnection(
+ Display* /* dpy */,
+ int /* fd */
+);
+
+/* Display structure has pointers to these */
+
+struct _XConnectionInfo { /* info from _XRegisterInternalConnection */
+ int fd;
+ _XInternalConnectionProc read_callback;
+ XPointer call_data;
+ XPointer *watch_data; /* set/used by XConnectionWatchProc */
+ struct _XConnectionInfo *next;
+};
+
+struct _XConnWatchInfo { /* info from XAddConnectionWatch */
+ XConnectionWatchProc fn;
+ XPointer client_data;
+ struct _XConnWatchInfo *next;
+};
+
+#ifdef __UNIXOS2__
+extern char* __XOS2RedirRoot(
+ char*
+);
+#endif
+
+extern int _XTextHeight(
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* count */
+);
+
+extern int _XTextHeight16(
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* count */
+);
+
+#if defined(WIN32)
+
+extern int _XOpenFile(
+ _Xconst char* /* path */,
+ int /* flags */
+);
+
+extern void* _XFopenFile(
+ _Xconst char* /* path */,
+ _Xconst char* /* mode */
+);
+
+extern int _XAccessFile(
+ _Xconst char* /* path */
+);
+#else
+#define _XOpenFile(path,flags) open(path,flags)
+#define _XFopenFile(path,mode) fopen(path,mode)
+#endif
+
+/* EvToWire.c */
+extern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event);
+
+extern int _XF86LoadQueryLocaleFont(
+ Display* /* dpy */,
+ _Xconst char* /* name*/,
+ XFontStruct** /* xfp*/,
+ Font* /* fidp */
+);
+
+extern void _XProcessWindowAttributes (
+ register Display *dpy,
+ xChangeWindowAttributesReq *req,
+ register unsigned long valuemask,
+ register XSetWindowAttributes *attributes);
+
+extern int _XDefaultError(
+ Display *dpy,
+ XErrorEvent *event);
+
+extern int _XDefaultIOError(
+ Display *dpy);
+
+extern void _XSetClipRectangles (
+ register Display *dpy,
+ GC gc,
+ int clip_x_origin, int clip_y_origin,
+ XRectangle *rectangles,
+ int n,
+ int ordering);
+
+Status _XGetWindowAttributes(
+ register Display *dpy,
+ Window w,
+ XWindowAttributes *attr);
+
+int _XPutBackEvent (
+ register Display *dpy,
+ register XEvent *event);
+
+_XFUNCPROTOEND
+
+#endif /* _XLIBINT_H_ */
diff --git a/nx-X11/lib/X11/Xlocale.h b/nx-X11/lib/X11/Xlocale.h
new file mode 100644
index 000000000..61d2f7a84
--- /dev/null
+++ b/nx-X11/lib/X11/Xlocale.h
@@ -0,0 +1,61 @@
+/* $Xorg: Xlocale.h,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/X11/Xlocale.h,v 1.4 2001/12/14 19:54:09 dawes Exp $ */
+
+#ifndef _XLOCALE_H_
+#define _XLOCALE_H_
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+
+#ifndef X_LOCALE
+#include <locale.h>
+#else
+
+#define LC_ALL 0
+#define LC_COLLATE 1
+#define LC_CTYPE 2
+#define LC_MONETARY 3
+#define LC_NUMERIC 4
+#define LC_TIME 5
+
+_XFUNCPROTOBEGIN
+extern char *_Xsetlocale(
+ int /* category */,
+ _Xconst char* /* name */
+);
+_XFUNCPROTOEND
+
+#define setlocale _Xsetlocale
+
+#include <stddef.h>
+
+#endif /* X_LOCALE */
+
+#endif /* _XLOCALE_H_ */
diff --git a/nx-X11/lib/X11/XomGeneric.h b/nx-X11/lib/X11/XomGeneric.h
new file mode 100644
index 000000000..ce61eca34
--- /dev/null
+++ b/nx-X11/lib/X11/XomGeneric.h
@@ -0,0 +1,318 @@
+/* $Xorg: XomGeneric.h,v 1.3 2000/08/17 19:45:08 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+/* $XFree86: xc/lib/X11/XomGeneric.h,v 1.5 2003/04/13 19:22:19 dawes Exp $ */
+
+#ifndef _XOMGENERIC_H_
+#define _XOMGENERIC_H_
+
+#include "XlcPublic.h"
+
+#define XOM_GENERIC(om) (&((XOMGeneric) om)->gen)
+#define XOC_GENERIC(font_set) (&((XOCGeneric) font_set)->gen)
+
+/* For VW/UDC */
+typedef struct _CodeRangeRec {
+ unsigned long start;
+ unsigned long end;
+ unsigned long dmy1;
+ unsigned long dmy2;
+} CodeRangeRec, *CodeRange;
+
+typedef struct _VRotateRec {
+ char *charset_name; /* Charset name */
+ XlcSide side; /* Encoding side */
+ int num_cr;
+ CodeRange code_range;
+ char *xlfd_name;
+ XFontStruct *font;
+} VRotateRec, *VRotate;
+
+typedef enum {
+ XOMMultiByte,
+ XOMWideChar,
+ XOMUtf8String
+} XOMTextType;
+
+typedef struct _FontDataRec {
+ char *name;
+ XlcSide side;
+ /* For VW/UDC */
+ int scopes_num;
+ FontScope scopes;
+ char *xlfd_name;
+ XFontStruct *font;
+} FontDataRec, *FontData;
+
+#define VROTATE_NONE 0
+#define VROTATE_PART 1
+#define VROTATE_ALL 2
+
+typedef struct _OMDataRec {
+ int charset_count;
+ XlcCharSet *charset_list;
+ int font_data_count;
+ FontData font_data;
+ /* For VW/UDC */
+ int substitute_num;
+ FontData substitute;
+ /* Vertical Writing */
+ int vmap_num;
+ FontData vmap;
+ int vrotate_type;
+ int vrotate_num;
+ CodeRange vrotate;
+} OMDataRec, *OMData;
+
+typedef struct _XOMGenericPart {
+ int data_num;
+ OMData data;
+ Bool on_demand_loading;
+ char *object_name;
+} XOMGenericPart;
+
+typedef struct _XOMGenericRec {
+ XOMMethods methods;
+ XOMCoreRec core;
+ XOMGenericPart gen;
+} XOMGenericRec, *XOMGeneric;
+
+/*
+ * XOC dependent data
+ */
+
+typedef struct _FontSetRec {
+ int id;
+ int charset_count;
+ XlcCharSet *charset_list;
+ int font_data_count;
+ FontData font_data;
+ char *font_name;
+ XFontStruct *info;
+ XFontStruct *font;
+ XlcSide side;
+ Bool is_xchar2b;
+ /* For VW/UDC */
+ int substitute_num;
+ FontData substitute;
+ /* Vertical Writing */
+ int vpart_initialize;
+ int vmap_num;
+ FontData vmap;
+ int vrotate_num;
+ VRotate vrotate;
+} FontSetRec, *FontSet;
+
+typedef struct _XOCGenericPart {
+ XlcConv mbs_to_cs;
+ XlcConv wcs_to_cs;
+ XlcConv utf8_to_cs;
+ int font_set_num;
+ FontSet font_set;
+} XOCGenericPart;
+
+typedef struct _XOCGenericRec {
+ XOCMethods methods;
+ XOCCoreRec core;
+ XOCGenericPart gen;
+} XOCGenericRec, *XOCGeneric;
+
+_XFUNCPROTOBEGIN
+
+extern XOM _XomGenericOpenOM(
+ XLCd /* lcd */,
+ Display* /* dpy */,
+ XrmDatabase /* rdb */,
+ _Xconst char* /* res_name */,
+ _Xconst char* /* res_class */
+);
+
+extern XlcConv _XomInitConverter(
+ XOC /* oc */,
+ XOMTextType /* type */
+);
+
+extern int _XomConvert(
+ XOC /* oc */,
+ XlcConv /* conv */,
+ XPointer* /* from */,
+ int* /* from_left */,
+ XPointer* /* to */,
+ int* /* to_left */,
+ XPointer* /* args */,
+ int /* num_args */
+);
+
+extern int
+_XmbDefaultTextEscapement(XOC oc, _Xconst char *text, int length);
+extern int
+_XwcDefaultTextEscapement(XOC oc, _Xconst wchar_t *text, int length);
+extern int
+_Xutf8DefaultTextEscapement(XOC oc, _Xconst char *text, int length);
+extern int
+_XmbDefaultTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical);
+extern int
+_XwcDefaultTextExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical);
+extern int
+_Xutf8DefaultTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical);
+extern Status
+_XmbDefaultTextPerCharExtents(
+ XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical);
+extern Status
+_XwcDefaultTextPerCharExtents(
+ XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical);
+extern Status
+_Xutf8DefaultTextPerCharExtents(
+ XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical);
+extern int
+_XmbDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length);
+extern int
+_XwcDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst wchar_t *text, int length);
+extern int
+_Xutf8DefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length);
+extern void
+_XmbDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length);
+extern void
+_XwcDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst wchar_t *text, int length);
+extern void
+_Xutf8DefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length);
+
+extern int
+_XmbGenericTextEscapement(XOC oc, _Xconst char *text, int length);
+extern int
+_XmbGenericTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical);
+extern int
+_Xutf8GenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length);
+extern void
+_Xutf8GenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length);
+extern Status
+_Xutf8GenericTextPerCharExtents(
+ XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical);
+extern int
+_Xutf8GenericTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical);
+extern int
+_Xutf8GenericTextEscapement(XOC oc, _Xconst char *text, int length);
+extern void
+_XwcGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst wchar_t *text, int length);
+extern int
+_XwcGenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst wchar_t *text, int length);
+extern Status
+_XwcGenericTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical);
+extern int
+_XwcGenericTextExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical);
+extern int
+_XwcGenericTextEscapement(XOC oc, _Xconst wchar_t *text, int length);
+extern void
+_XmbGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length);
+extern int
+_XmbGenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length);
+extern Status
+_XmbGenericTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical);
+
+extern FontData
+read_EncodingInfo(
+ int count,
+ char **value);
+
+extern int
+_XomGenericDrawString(
+ Display *dpy,
+ Drawable d,
+ XOC oc,
+ GC gc,
+ int x, int y,
+ XOMTextType type,
+ XPointer text,
+ int length);
+extern int
+_XomGenericTextExtents(
+ XOC oc,
+ XOMTextType type,
+ XPointer text,
+ int length,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical);
+extern FontData
+_XomGetFontDataFromFontSet(
+ FontSet fs,
+ unsigned char *str,
+ int len,
+ int *len_ret,
+ int is2b,
+ int type);
+
+_XFUNCPROTOEND
+
+#endif /* _XOMGENERIC_H_ */
diff --git a/nx-X11/lib/X11/Xregion.h b/nx-X11/lib/X11/Xregion.h
new file mode 100644
index 000000000..2ddf12cac
--- /dev/null
+++ b/nx-X11/lib/X11/Xregion.h
@@ -0,0 +1,190 @@
+/* $Xorg: region.h,v 1.4 2001/02/09 02:03:40 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.
+
+************************************************************************/
+
+#ifndef _XREGION_H
+#define _XREGION_H
+
+typedef struct {
+ short x1, x2, y1, y2;
+} Box, BOX, BoxRec, *BoxPtr;
+
+typedef struct {
+ short x, y, width, height;
+}RECTANGLE, RectangleRec, *RectanglePtr;
+
+#define TRUE 1
+#define FALSE 0
+#define MAXSHORT 32767
+#define MINSHORT -MAXSHORT
+#ifndef MAX
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+#ifndef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+
+/*
+ * clip region
+ */
+
+typedef struct _XRegion {
+ long size;
+ long numRects;
+ BOX *rects;
+ BOX extents;
+} REGION;
+
+/* Xutil.h contains the declaration:
+ * typedef struct _XRegion *Region;
+ */
+
+/* 1 if two BOXs overlap.
+ * 0 if two BOXs do not overlap.
+ * Remember, x2 and y2 are not in the region
+ */
+#define EXTENTCHECK(r1, r2) \
+ ((r1)->x2 > (r2)->x1 && \
+ (r1)->x1 < (r2)->x2 && \
+ (r1)->y2 > (r2)->y1 && \
+ (r1)->y1 < (r2)->y2)
+
+/*
+ * update region extents
+ */
+#define EXTENTS(r,idRect){\
+ if((r)->x1 < (idRect)->extents.x1)\
+ (idRect)->extents.x1 = (r)->x1;\
+ if((r)->y1 < (idRect)->extents.y1)\
+ (idRect)->extents.y1 = (r)->y1;\
+ if((r)->x2 > (idRect)->extents.x2)\
+ (idRect)->extents.x2 = (r)->x2;\
+ if((r)->y2 > (idRect)->extents.y2)\
+ (idRect)->extents.y2 = (r)->y2;\
+ }
+
+/*
+ * Check to see if there is enough memory in the present region.
+ */
+#define MEMCHECK(reg, rect, firstrect){\
+ if ((reg)->numRects >= ((reg)->size - 1)){\
+ (firstrect) = (BOX *) Xrealloc \
+ ((char *)(firstrect), (unsigned) (2 * (sizeof(BOX)) * ((reg)->size)));\
+ if ((firstrect) == 0)\
+ return(0);\
+ (reg)->size *= 2;\
+ (rect) = &(firstrect)[(reg)->numRects];\
+ }\
+ }
+
+/* this routine checks to see if the previous rectangle is the same
+ * or subsumes the new rectangle to add.
+ */
+
+#define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\
+ (!(((Reg)->numRects > 0)&&\
+ ((R-1)->y1 == (Ry1)) &&\
+ ((R-1)->y2 == (Ry2)) &&\
+ ((R-1)->x1 <= (Rx1)) &&\
+ ((R-1)->x2 >= (Rx2))))
+
+/* add a rectangle to the given Region */
+#define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\
+ if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\
+ CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
+ (r)->x1 = (rx1);\
+ (r)->y1 = (ry1);\
+ (r)->x2 = (rx2);\
+ (r)->y2 = (ry2);\
+ EXTENTS((r), (reg));\
+ (reg)->numRects++;\
+ (r)++;\
+ }\
+ }
+
+
+
+/* add a rectangle to the given Region */
+#define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\
+ if ((rx1 < rx2) && (ry1 < ry2) &&\
+ CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
+ (r)->x1 = (rx1);\
+ (r)->y1 = (ry1);\
+ (r)->x2 = (rx2);\
+ (r)->y2 = (ry2);\
+ (reg)->numRects++;\
+ (r)++;\
+ }\
+ }
+
+#define EMPTY_REGION(pReg) pReg->numRects = 0
+
+#define REGION_NOT_EMPTY(pReg) pReg->numRects
+
+#define INBOX(r, x, y) \
+ ( ( ((r).x2 > x)) && \
+ ( ((r).x1 <= x)) && \
+ ( ((r).y2 > y)) && \
+ ( ((r).y1 <= y)) )
+
+/*
+ * number of points to buffer before sending them off
+ * to scanlines() : Must be an even number
+ */
+#define NUMPTSTOBUFFER 200
+
+/*
+ * used to allocate buffers for points and link
+ * the buffers together
+ */
+typedef struct _POINTBLOCK {
+ XPoint pts[NUMPTSTOBUFFER];
+ struct _POINTBLOCK *next;
+} POINTBLOCK;
+
+#endif
diff --git a/nx-X11/lib/X11/Xresinternal.h b/nx-X11/lib/X11/Xresinternal.h
new file mode 100644
index 000000000..fc752855b
--- /dev/null
+++ b/nx-X11/lib/X11/Xresinternal.h
@@ -0,0 +1,15 @@
+/* $XFree86$ */
+
+#ifndef _XRESINTERNAL_H_
+#define _XRESINTERNAL_H_
+
+/* type defines */
+typedef unsigned long Signature;
+
+/* prototypes */
+extern XrmQuark _XrmInternalStringToQuark(
+ register _Xconst char *name, register int len, register Signature sig,
+ Bool permstring);
+
+#endif /* _XRESOURCEINTERNAL_H_ */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/X11/Xresource.h b/nx-X11/lib/X11/Xresource.h
new file mode 100644
index 000000000..ce1213748
--- /dev/null
+++ b/nx-X11/lib/X11/Xresource.h
@@ -0,0 +1,360 @@
+/* $Xorg: Xresource.h,v 1.7 2001/02/09 02:03:39 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/Xresource.h,v 3.8 2001/12/14 19:54:10 dawes Exp $ */
+
+#ifndef _XRESOURCE_H_
+#define _XRESOURCE_H_
+
+#ifndef _XP_PRINT_SERVER_
+#include <X11/Xlib.h>
+#endif
+
+/****************************************************************
+ ****************************************************************
+ *** ***
+ *** ***
+ *** X Resource Manager Intrinsics ***
+ *** ***
+ *** ***
+ ****************************************************************
+ ****************************************************************/
+
+_XFUNCPROTOBEGIN
+
+/****************************************************************
+ *
+ * Memory Management
+ *
+ ****************************************************************/
+
+extern char *Xpermalloc(
+ unsigned int /* size */
+);
+
+/****************************************************************
+ *
+ * Quark Management
+ *
+ ****************************************************************/
+
+typedef int XrmQuark, *XrmQuarkList;
+#define NULLQUARK ((XrmQuark) 0)
+
+typedef char *XrmString;
+#define NULLSTRING ((XrmString) 0)
+
+/* find quark for string, create new quark if none already exists */
+extern XrmQuark XrmStringToQuark(
+ _Xconst char* /* string */
+);
+
+extern XrmQuark XrmPermStringToQuark(
+ _Xconst char* /* string */
+);
+
+/* find string for quark */
+extern XrmString XrmQuarkToString(
+ XrmQuark /* quark */
+);
+
+extern XrmQuark XrmUniqueQuark(
+ void
+);
+
+#define XrmStringsEqual(a1, a2) (strcmp(a1, a2) == 0)
+
+
+/****************************************************************
+ *
+ * Conversion of Strings to Lists
+ *
+ ****************************************************************/
+
+typedef enum {XrmBindTightly, XrmBindLoosely} XrmBinding, *XrmBindingList;
+
+extern void XrmStringToQuarkList(
+ _Xconst char* /* string */,
+ XrmQuarkList /* quarks_return */
+);
+
+extern void XrmStringToBindingQuarkList(
+ _Xconst char* /* string */,
+ XrmBindingList /* bindings_return */,
+ XrmQuarkList /* quarks_return */
+);
+
+/****************************************************************
+ *
+ * Name and Class lists.
+ *
+ ****************************************************************/
+
+typedef XrmQuark XrmName;
+typedef XrmQuarkList XrmNameList;
+#define XrmNameToString(name) XrmQuarkToString(name)
+#define XrmStringToName(string) XrmStringToQuark(string)
+#define XrmStringToNameList(str, name) XrmStringToQuarkList(str, name)
+
+typedef XrmQuark XrmClass;
+typedef XrmQuarkList XrmClassList;
+#define XrmClassToString(c_class) XrmQuarkToString(c_class)
+#define XrmStringToClass(c_class) XrmStringToQuark(c_class)
+#define XrmStringToClassList(str,c_class) XrmStringToQuarkList(str, c_class)
+
+
+
+/****************************************************************
+ *
+ * Resource Representation Types and Values
+ *
+ ****************************************************************/
+
+typedef XrmQuark XrmRepresentation;
+#define XrmStringToRepresentation(string) XrmStringToQuark(string)
+#define XrmRepresentationToString(type) XrmQuarkToString(type)
+
+typedef struct {
+ unsigned int size;
+ XPointer addr;
+} XrmValue, *XrmValuePtr;
+
+
+/****************************************************************
+ *
+ * Resource Manager Functions
+ *
+ ****************************************************************/
+
+typedef struct _XrmHashBucketRec *XrmHashBucket;
+typedef XrmHashBucket *XrmHashTable;
+typedef XrmHashTable XrmSearchList[];
+typedef struct _XrmHashBucketRec *XrmDatabase;
+
+
+extern void XrmDestroyDatabase(
+ XrmDatabase /* database */
+);
+
+extern void XrmQPutResource(
+ XrmDatabase* /* database */,
+ XrmBindingList /* bindings */,
+ XrmQuarkList /* quarks */,
+ XrmRepresentation /* type */,
+ XrmValue* /* value */
+);
+
+extern void XrmPutResource(
+ XrmDatabase* /* database */,
+ _Xconst char* /* specifier */,
+ _Xconst char* /* type */,
+ XrmValue* /* value */
+);
+
+extern void XrmQPutStringResource(
+ XrmDatabase* /* database */,
+ XrmBindingList /* bindings */,
+ XrmQuarkList /* quarks */,
+ _Xconst char* /* value */
+);
+
+extern void XrmPutStringResource(
+ XrmDatabase* /* database */,
+ _Xconst char* /* specifier */,
+ _Xconst char* /* value */
+);
+
+extern void XrmPutLineResource(
+ XrmDatabase* /* database */,
+ _Xconst char* /* line */
+);
+
+extern Bool XrmQGetResource(
+ XrmDatabase /* database */,
+ XrmNameList /* quark_name */,
+ XrmClassList /* quark_class */,
+ XrmRepresentation* /* quark_type_return */,
+ XrmValue* /* value_return */
+);
+
+extern Bool XrmGetResource(
+ XrmDatabase /* database */,
+ _Xconst char* /* str_name */,
+ _Xconst char* /* str_class */,
+ char** /* str_type_return */,
+ XrmValue* /* value_return */
+);
+
+extern Bool XrmQGetSearchList(
+ XrmDatabase /* database */,
+ XrmNameList /* names */,
+ XrmClassList /* classes */,
+ XrmSearchList /* list_return */,
+ int /* list_length */
+);
+
+extern Bool XrmQGetSearchResource(
+ XrmSearchList /* list */,
+ XrmName /* name */,
+ XrmClass /* class */,
+ XrmRepresentation* /* type_return */,
+ XrmValue* /* value_return */
+);
+
+/****************************************************************
+ *
+ * Resource Database Management
+ *
+ ****************************************************************/
+
+#ifndef _XP_PRINT_SERVER_
+
+extern void XrmSetDatabase(
+ Display* /* display */,
+ XrmDatabase /* database */
+);
+
+extern XrmDatabase XrmGetDatabase(
+ Display* /* display */
+);
+
+#endif /* !_XP_PRINT_SERVER_ */
+
+extern XrmDatabase XrmGetFileDatabase(
+ _Xconst char* /* filename */
+);
+
+extern Status XrmCombineFileDatabase(
+ _Xconst char* /* filename */,
+ XrmDatabase* /* target */,
+ Bool /* override */
+);
+
+extern XrmDatabase XrmGetStringDatabase(
+ _Xconst char* /* data */ /* null terminated string */
+);
+
+extern void XrmPutFileDatabase(
+ XrmDatabase /* database */,
+ _Xconst char* /* filename */
+);
+
+extern void XrmMergeDatabases(
+ XrmDatabase /* source_db */,
+ XrmDatabase* /* target_db */
+);
+
+extern void XrmCombineDatabase(
+ XrmDatabase /* source_db */,
+ XrmDatabase* /* target_db */,
+ Bool /* override */
+);
+
+#define XrmEnumAllLevels 0
+#define XrmEnumOneLevel 1
+
+extern Bool XrmEnumerateDatabase(
+ XrmDatabase /* db */,
+ XrmNameList /* name_prefix */,
+ XrmClassList /* class_prefix */,
+ int /* mode */,
+ Bool (*)(
+ XrmDatabase* /* db */,
+ XrmBindingList /* bindings */,
+ XrmQuarkList /* quarks */,
+ XrmRepresentation* /* type */,
+ XrmValue* /* value */,
+ XPointer /* closure */
+ ) /* proc */,
+ XPointer /* closure */
+);
+
+extern const char *XrmLocaleOfDatabase(
+ XrmDatabase /* database */
+);
+
+
+/****************************************************************
+ *
+ * Command line option mapping to resource entries
+ *
+ ****************************************************************/
+
+typedef enum {
+ XrmoptionNoArg, /* Value is specified in OptionDescRec.value */
+ XrmoptionIsArg, /* Value is the option string itself */
+ XrmoptionStickyArg, /* Value is characters immediately following option */
+ XrmoptionSepArg, /* Value is next argument in argv */
+ XrmoptionResArg, /* Resource and value in next argument in argv */
+ XrmoptionSkipArg, /* Ignore this option and the next argument in argv */
+ XrmoptionSkipLine, /* Ignore this option and the rest of argv */
+ XrmoptionSkipNArgs /* Ignore this option and the next
+ OptionDescRes.value arguments in argv */
+} XrmOptionKind;
+
+typedef struct {
+ char *option; /* Option abbreviation in argv */
+ char *specifier; /* Resource specifier */
+ XrmOptionKind argKind; /* Which style of option it is */
+ XPointer value; /* Value to provide if XrmoptionNoArg */
+} XrmOptionDescRec, *XrmOptionDescList;
+
+
+extern void XrmParseCommand(
+ XrmDatabase* /* database */,
+ XrmOptionDescList /* table */,
+ int /* table_count */,
+ _Xconst char* /* name */,
+ int* /* argc_in_out */,
+ char** /* argv_in_out */
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XRESOURCE_H_ */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/X11/Xrm.c b/nx-X11/lib/X11/Xrm.c
new file mode 100644
index 000000000..a932a5ce2
--- /dev/null
+++ b/nx-X11/lib/X11/Xrm.c
@@ -0,0 +1,2663 @@
+/* $Xorg: Xrm.c,v 1.7 2001/02/09 02:03:39 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, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/X11/Xrm.c,v 3.22 2003/07/16 01:38:26 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <ctype.h>
+#include "Xlibint.h"
+#include <X11/Xresource.h>
+#include "Xlcint.h"
+#ifdef XTHREADS
+#include "locking.h"
+#endif
+#include "XrmI.h"
+#include <X11/Xos.h>
+#include "Xresinternal.h"
+#include "Xresource.h"
+
+/*
+
+These Xrm routines allow very fast lookup of resources in the resource
+database. Several usage patterns are exploited:
+
+(1) Widgets get a lot of resources at one time. Rather than look up each from
+scratch, we can precompute the prioritized list of database levels once, then
+search for each resource starting at the beginning of the list.
+
+(2) Many database levels don't contain any leaf resource nodes. There is no
+point in looking for resources on a level that doesn't contain any. This
+information is kept on a per-level basis.
+
+(3) Sometimes the widget instance tree is structured such that you get the same
+class name repeated on the fully qualified widget name. This can result in the
+same database level occuring multiple times on the search list. The code below
+only checks to see if you get two identical search lists in a row, rather than
+look back through all database levels, but in practice this removes all
+duplicates I've ever observed.
+
+Joel McCormack
+
+*/
+
+/*
+
+The Xrm representation has been completely redesigned to substantially reduce
+memory and hopefully improve performance.
+
+The database is structured into two kinds of tables: LTables that contain
+only values, and NTables that contain only other tables.
+
+Some invariants:
+
+The next pointer of the top-level node table points to the top-level leaf
+table, if any.
+
+Within an LTable, for a given name, the tight value always precedes the
+loose value, and if both are present the loose value is always right after
+the tight value.
+
+Within an NTable, all of the entries for a given name are contiguous,
+in the order tight NTable, loose NTable, tight LTable, loose LTable.
+
+Bob Scheifler
+
+*/
+
+static XrmQuark XrmQString, XrmQANY;
+
+typedef Bool (*DBEnumProc)(
+ XrmDatabase* /* db */,
+ XrmBindingList /* bindings */,
+ XrmQuarkList /* quarks */,
+ XrmRepresentation* /* type */,
+ XrmValue* /* value */,
+ XPointer /* closure */
+);
+
+typedef struct _VEntry {
+ struct _VEntry *next; /* next in chain */
+ XrmQuark name; /* name of this entry */
+ unsigned int tight:1; /* 1 if it is a tight binding */
+ unsigned int string:1; /* 1 if type is String */
+ unsigned int size:30; /* size of value */
+} VEntryRec, *VEntry;
+
+
+typedef struct _DEntry {
+ VEntryRec entry; /* entry */
+ XrmRepresentation type; /* representation type */
+} DEntryRec, *DEntry;
+
+/* the value is right after the structure */
+#define StringValue(ve) (XPointer)((ve) + 1)
+#define RepType(ve) ((DEntry)(ve))->type
+/* the value is right after the structure */
+#define DataValue(ve) (XPointer)(((DEntry)(ve)) + 1)
+#define RawValue(ve) (char *)((ve)->string ? StringValue(ve) : DataValue(ve))
+
+typedef struct _NTable {
+ struct _NTable *next; /* next in chain */
+ XrmQuark name; /* name of this entry */
+ unsigned int tight:1; /* 1 if it is a tight binding */
+ unsigned int leaf:1; /* 1 if children are values */
+ unsigned int hasloose:1; /* 1 if has loose children */
+ unsigned int hasany:1; /* 1 if has ANY entry */
+ unsigned int pad:4; /* unused */
+ unsigned int mask:8; /* hash size - 1 */
+ unsigned int entries:16; /* number of children */
+} NTableRec, *NTable;
+
+/* the buckets are right after the structure */
+#define NodeBuckets(ne) ((NTable *)((ne) + 1))
+#define NodeHash(ne,q) NodeBuckets(ne)[(q) & (ne)->mask]
+
+/* leaf tables have an extra level of indirection for the buckets,
+ * so that resizing can be done without invalidating a search list.
+ * This is completely ugly, and wastes some memory, but the Xlib
+ * spec doesn't really specify whether invalidation is OK, and the
+ * old implementation did not invalidate.
+ */
+typedef struct _LTable {
+ NTableRec table;
+ VEntry *buckets;
+} LTableRec, *LTable;
+
+#define LeafHash(le,q) (le)->buckets[(q) & (le)->table.mask]
+
+/* An XrmDatabase just holds a pointer to the first top-level table.
+ * The type name is no longer descriptive, but better to not change
+ * the Xresource.h header file. This type also gets used to define
+ * XrmSearchList, which is a complete crock, but we'll just leave it
+ * and caste types as required.
+ */
+typedef struct _XrmHashBucketRec {
+ NTable table;
+ XPointer mbstate;
+ XrmMethods methods;
+#ifdef XTHREADS
+ LockInfoRec linfo;
+#endif
+} XrmHashBucketRec;
+
+/* closure used in get/put resource */
+typedef struct _VClosure {
+ XrmRepresentation *type; /* type of value */
+ XrmValuePtr value; /* value itself */
+} VClosureRec, *VClosure;
+
+/* closure used in get search list */
+typedef struct _SClosure {
+ LTable *list; /* search list */
+ int idx; /* index of last filled element */
+ int limit; /* maximum index */
+} SClosureRec, *SClosure;
+
+/* placed in XrmSearchList to indicate next table is loose only */
+#define LOOSESEARCH ((LTable)1)
+
+/* closure used in enumerate database */
+typedef struct _EClosure {
+ XrmDatabase db; /* the database */
+ DBEnumProc proc; /* the user proc */
+ XPointer closure; /* the user closure */
+ XrmBindingList bindings; /* binding list */
+ XrmQuarkList quarks; /* quark list */
+ int mode; /* XrmEnum<kind> */
+} EClosureRec, *EClosure;
+
+/* types for typecasting ETable based functions to NTable based functions */
+typedef Bool (*getNTableSProcp)(
+ NTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ SClosure closure);
+typedef Bool (*getNTableVProcp)(
+ NTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ VClosure closure);
+typedef Bool (*getNTableEProcp)(
+ NTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ register int level,
+ EClosure closure);
+
+/* predicate to determine when to resize a hash table */
+#define GrowthPred(n,m) ((unsigned)(n) > (((m) + 1) << 2))
+
+#define GROW(prev) \
+ if (GrowthPred((*prev)->entries, (*prev)->mask)) \
+ GrowTable(prev)
+
+/* pick a reasonable value for maximum depth of resource database */
+#define MAXDBDEPTH 100
+
+/* macro used in get/search functions */
+
+/* find an entry named ename, with leafness given by leaf */
+#define NFIND(ename) \
+ q = ename; \
+ entry = NodeHash(table, q); \
+ while (entry && entry->name != q) \
+ entry = entry->next; \
+ if (leaf && entry && !entry->leaf) { \
+ entry = entry->next; \
+ if (entry && !entry->leaf) \
+ entry = entry->next; \
+ if (entry && entry->name != q) \
+ entry = (NTable)NULL; \
+ }
+
+/* resourceQuarks keeps track of what quarks have been associated with values
+ * in all LTables. If a quark has never been used in an LTable, we don't need
+ * to bother looking for it.
+ */
+
+static unsigned char *resourceQuarks = (unsigned char *)NULL;
+static XrmQuark maxResourceQuark = -1;
+
+/* determines if a quark has been used for a value in any database */
+#define IsResourceQuark(q) ((q) > 0 && (q) <= maxResourceQuark && \
+ resourceQuarks[(q) >> 3] & (1 << ((q) & 7)))
+
+typedef unsigned char XrmBits;
+
+#define BSLASH ((XrmBits) (1 << 5))
+#define NORMAL ((XrmBits) (1 << 4))
+#define EOQ ((XrmBits) (1 << 3))
+#define SEP ((XrmBits) (1 << 2))
+#define ENDOF ((XrmBits) (1 << 1))
+#define SPACE (NORMAL|EOQ|SEP|(XrmBits)0)
+#define RSEP (NORMAL|EOQ|SEP|(XrmBits)1)
+#define EOS (EOQ|SEP|ENDOF|(XrmBits)0)
+#define EOL (EOQ|SEP|ENDOF|(XrmBits)1)
+#define BINDING (NORMAL|EOQ)
+#define ODIGIT (NORMAL|(XrmBits)1)
+
+#define next_char(ch,str) xrmtypes[(unsigned char)((ch) = *(++(str)))]
+#define next_mbchar(ch,len,str) xrmtypes[(unsigned char)(ch = (*db->methods->mbchar)(db->mbstate, str, &len), str += len, ch)]
+
+#define is_space(bits) ((bits) == SPACE)
+#define is_EOQ(bits) ((bits) & EOQ)
+#define is_EOF(bits) ((bits) == EOS)
+#define is_EOL(bits) ((bits) & ENDOF)
+#define is_binding(bits) ((bits) == BINDING)
+#define is_odigit(bits) ((bits) == ODIGIT)
+#define is_separator(bits) ((bits) & SEP)
+#define is_nonpcs(bits) (!(bits))
+#define is_normal(bits) ((bits) & NORMAL)
+#define is_simple(bits) ((bits) & (NORMAL|BSLASH))
+#define is_special(bits) ((bits) & (ENDOF|BSLASH))
+
+/* parsing types */
+static XrmBits const xrmtypes[256] = {
+ EOS,0,0,0,0,0,0,0,
+ 0,SPACE,EOL,0,0,
+#if defined(WIN32) || defined(__UNIXOS2__)
+ EOL, /* treat CR the same as LF, just in case */
+#else
+ 0,
+#endif
+ 0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ SPACE,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,BINDING,NORMAL,NORMAL,NORMAL,BINDING,NORMAL,
+ ODIGIT,ODIGIT,ODIGIT,ODIGIT,ODIGIT,ODIGIT,ODIGIT,ODIGIT,
+ NORMAL,NORMAL,RSEP,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,BSLASH,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,0
+ /* The rest will be automatically initialized to zero. */
+};
+
+void XrmInitialize(void)
+{
+ XrmQString = XrmPermStringToQuark("String");
+ XrmQANY = XrmPermStringToQuark("?");
+}
+
+#ifndef _XP_PRINT_SERVER_
+XrmDatabase XrmGetDatabase(
+ Display *display)
+{
+ XrmDatabase retval;
+ LockDisplay(display);
+ retval = display->db;
+ UnlockDisplay(display);
+ return retval;
+}
+
+void XrmSetDatabase(
+ Display *display,
+ XrmDatabase database)
+{
+ LockDisplay(display);
+ /* destroy database if set up imlicitely by XGetDefault() */
+ if (display->db && (display->flags & XlibDisplayDfltRMDB)) {
+ XrmDestroyDatabase(display->db);
+ display->flags &= ~XlibDisplayDfltRMDB;
+ }
+ display->db = database;
+ UnlockDisplay(display);
+}
+#endif /* !_XP_PRINT_SERVER_ */
+
+void
+XrmStringToQuarkList(
+ register _Xconst char *name,
+ register XrmQuarkList quarks) /* RETURN */
+{
+ register XrmBits bits;
+ register Signature sig = 0;
+ register char ch, *tname;
+ register int i = 0;
+
+ if ((tname = (char *)name)) {
+ tname--;
+ while (!is_EOF(bits = next_char(ch, tname))) {
+ if (is_binding (bits)) {
+ if (i) {
+ /* Found a complete name */
+ *quarks++ = _XrmInternalStringToQuark(name,tname - name,
+ sig, False);
+ i = 0;
+ sig = 0;
+ }
+ name = tname+1;
+ }
+ else {
+ sig = (sig << 1) + ch; /* Compute the signature. */
+ i++;
+ }
+ }
+ *quarks++ = _XrmInternalStringToQuark(name, tname - name, sig, False);
+ }
+ *quarks = NULLQUARK;
+}
+
+void
+XrmStringToBindingQuarkList(
+ register _Xconst char *name,
+ register XrmBindingList bindings, /* RETURN */
+ register XrmQuarkList quarks) /* RETURN */
+{
+ register XrmBits bits;
+ register Signature sig = 0;
+ register char ch, *tname;
+ register XrmBinding binding;
+ register int i = 0;
+
+ if ((tname = (char *)name)) {
+ tname--;
+ binding = XrmBindTightly;
+ while (!is_EOF(bits = next_char(ch, tname))) {
+ if (is_binding (bits)) {
+ if (i) {
+ /* Found a complete name */
+ *bindings++ = binding;
+ *quarks++ = _XrmInternalStringToQuark(name, tname - name,
+ sig, False);
+
+ i = 0;
+ sig = 0;
+ binding = XrmBindTightly;
+ }
+ name = tname+1;
+
+ if (ch == '*')
+ binding = XrmBindLoosely;
+ }
+ else {
+ sig = (sig << 1) + ch; /* Compute the signature. */
+ i++;
+ }
+ }
+ *bindings = binding;
+ *quarks++ = _XrmInternalStringToQuark(name, tname - name, sig, False);
+ }
+ *quarks = NULLQUARK;
+}
+
+#ifdef DEBUG
+
+static void PrintQuarkList(
+ XrmQuarkList quarks,
+ FILE *stream)
+{
+ Bool firstNameSeen;
+
+ for (firstNameSeen = False; *quarks; quarks++) {
+ if (firstNameSeen) {
+ (void) fprintf(stream, ".");
+ }
+ firstNameSeen = True;
+ (void) fputs(XrmQuarkToString(*quarks), stream);
+ }
+} /* PrintQuarkList */
+
+#endif /* DEBUG */
+
+
+/*
+ * Fallback methods for Xrm parsing.
+ * Simulate a C locale. No state needed here.
+ */
+
+static void
+c_mbnoop(
+ XPointer state)
+{
+}
+
+static char
+c_mbchar(
+ XPointer state,
+ const char *str,
+ int *lenp)
+{
+ *lenp = 1;
+ return *str;
+}
+
+static const char *
+c_lcname(
+ XPointer state)
+{
+ return "C";
+}
+
+static const XrmMethodsRec mb_methods = {
+ c_mbnoop, /* mbinit */
+ c_mbchar, /* mbchar */
+ c_mbnoop, /* mbfinish */
+ c_lcname, /* lcname */
+ c_mbnoop /* destroy */
+};
+
+
+static XrmDatabase NewDatabase(void)
+{
+ register XrmDatabase db;
+
+ db = (XrmDatabase) Xmalloc(sizeof(XrmHashBucketRec));
+ if (db) {
+ _XCreateMutex(&db->linfo);
+ db->table = (NTable)NULL;
+ db->mbstate = (XPointer)NULL;
+#ifdef _XP_PRINT_SERVER_
+ db->methods = NULL;
+#else
+ db->methods = _XrmInitParseInfo(&db->mbstate);
+#endif
+ if (!db->methods)
+ db->methods = &mb_methods;
+ }
+ return db;
+}
+
+/* move all values from ftable to ttable, and free ftable's buckets.
+ * ttable is quaranteed empty to start with.
+ */
+static void MoveValues(
+ LTable ftable,
+ register LTable ttable)
+{
+ register VEntry fentry, nfentry;
+ register VEntry *prev;
+ register VEntry *bucket;
+ register VEntry tentry;
+ register int i;
+
+ for (i = ftable->table.mask, bucket = ftable->buckets; i >= 0; i--) {
+ for (fentry = *bucket++; fentry; fentry = nfentry) {
+ prev = &LeafHash(ttable, fentry->name);
+ tentry = *prev;
+ *prev = fentry;
+ /* chain on all with same name, to preserve invariant order */
+ while ((nfentry = fentry->next) && nfentry->name == fentry->name)
+ fentry = nfentry;
+ fentry->next = tentry;
+ }
+ }
+ Xfree((char *)ftable->buckets);
+}
+
+/* move all tables from ftable to ttable, and free ftable.
+ * ttable is quaranteed empty to start with.
+ */
+static void MoveTables(
+ NTable ftable,
+ register NTable ttable)
+{
+ register NTable fentry, nfentry;
+ register NTable *prev;
+ register NTable *bucket;
+ register NTable tentry;
+ register int i;
+
+ for (i = ftable->mask, bucket = NodeBuckets(ftable); i >= 0; i--) {
+ for (fentry = *bucket++; fentry; fentry = nfentry) {
+ prev = &NodeHash(ttable, fentry->name);
+ tentry = *prev;
+ *prev = fentry;
+ /* chain on all with same name, to preserve invariant order */
+ while ((nfentry = fentry->next) && nfentry->name == fentry->name)
+ fentry = nfentry;
+ fentry->next = tentry;
+ }
+ }
+ Xfree((char *)ftable);
+}
+
+/* grow the table, based on current number of entries */
+static void GrowTable(
+ NTable *prev)
+{
+ register NTable table;
+ register int i;
+
+ table = *prev;
+ i = table->mask;
+ if (i == 255) /* biggest it gets */
+ return;
+ while (i < 255 && GrowthPred(table->entries, i))
+ i = (i << 1) + 1;
+ i++; /* i is now the new size */
+ if (table->leaf) {
+ register LTable ltable;
+ LTableRec otable;
+
+ ltable = (LTable)table;
+ /* cons up a copy to make MoveValues look symmetric */
+ otable = *ltable;
+ ltable->buckets = (VEntry *)Xmalloc(i * sizeof(VEntry));
+ if (!ltable->buckets) {
+ ltable->buckets = otable.buckets;
+ return;
+ }
+ ltable->table.mask = i - 1;
+ bzero((char *)ltable->buckets, i * sizeof(VEntry));
+ MoveValues(&otable, ltable);
+ } else {
+ register NTable ntable;
+
+ ntable = (NTable)Xmalloc(sizeof(NTableRec) + i * sizeof(NTable));
+ if (!ntable)
+ return;
+ *ntable = *table;
+ ntable->mask = i - 1;
+ bzero((char *)NodeBuckets(ntable), i * sizeof(NTable));
+ *prev = ntable;
+ MoveTables(table, ntable);
+ }
+}
+
+/* merge values from ftable into *pprev, destroy ftable in the process */
+static void MergeValues(
+ LTable ftable,
+ NTable *pprev,
+ Bool override)
+{
+ register VEntry fentry, tentry;
+ register VEntry *prev;
+ register LTable ttable;
+ VEntry *bucket;
+ int i;
+ register XrmQuark q;
+
+ ttable = (LTable)*pprev;
+ if (ftable->table.hasloose)
+ ttable->table.hasloose = 1;
+ for (i = ftable->table.mask, bucket = ftable->buckets;
+ i >= 0;
+ i--, bucket++) {
+ for (fentry = *bucket; fentry; ) {
+ q = fentry->name;
+ prev = &LeafHash(ttable, q);
+ tentry = *prev;
+ while (tentry && tentry->name != q)
+ tentry = *(prev = &tentry->next);
+ /* note: test intentionally uses fentry->name instead of q */
+ /* permits serendipitous inserts */
+ while (tentry && tentry->name == fentry->name) {
+ /* if tentry is earlier, skip it */
+ if (!fentry->tight && tentry->tight) {
+ tentry = *(prev = &tentry->next);
+ continue;
+ }
+ if (fentry->tight != tentry->tight) {
+ /* no match, chain in fentry */
+ *prev = fentry;
+ prev = &fentry->next;
+ fentry = *prev;
+ *prev = tentry;
+ ttable->table.entries++;
+ } else if (override) {
+ /* match, chain in fentry, splice out and free tentry */
+ *prev = fentry;
+ prev = &fentry->next;
+ fentry = *prev;
+ *prev = tentry->next;
+ /* free the overridden entry */
+ Xfree((char *)tentry);
+ /* get next tentry */
+ tentry = *prev;
+ } else {
+ /* match, discard fentry */
+ prev = &tentry->next;
+ tentry = fentry; /* use as a temp var */
+ fentry = fentry->next;
+ /* free the overpowered entry */
+ Xfree((char *)tentry);
+ /* get next tentry */
+ tentry = *prev;
+ }
+ if (!fentry)
+ break;
+ }
+ /* at this point, tentry cannot match any fentry named q */
+ /* chain in all bindings together, preserve invariant order */
+ while (fentry && fentry->name == q) {
+ *prev = fentry;
+ prev = &fentry->next;
+ fentry = *prev;
+ *prev = tentry;
+ ttable->table.entries++;
+ }
+ }
+ }
+ Xfree((char *)ftable->buckets);
+ Xfree((char *)ftable);
+ /* resize if necessary, now that we're all done */
+ GROW(pprev);
+}
+
+/* merge tables from ftable into *pprev, destroy ftable in the process */
+static void MergeTables(
+ NTable ftable,
+ NTable *pprev,
+ Bool override)
+{
+ register NTable fentry, tentry;
+ NTable nfentry;
+ register NTable *prev;
+ register NTable ttable;
+ NTable *bucket;
+ int i;
+ register XrmQuark q;
+
+ ttable = *pprev;
+ if (ftable->hasloose)
+ ttable->hasloose = 1;
+ if (ftable->hasany)
+ ttable->hasany = 1;
+ for (i = ftable->mask, bucket = NodeBuckets(ftable);
+ i >= 0;
+ i--, bucket++) {
+ for (fentry = *bucket; fentry; ) {
+ q = fentry->name;
+ prev = &NodeHash(ttable, q);
+ tentry = *prev;
+ while (tentry && tentry->name != q)
+ tentry = *(prev = &tentry->next);
+ /* note: test intentionally uses fentry->name instead of q */
+ /* permits serendipitous inserts */
+ while (tentry && tentry->name == fentry->name) {
+ /* if tentry is earlier, skip it */
+ if ((fentry->leaf && !tentry->leaf) ||
+ (!fentry->tight && tentry->tight &&
+ (fentry->leaf || !tentry->leaf))) {
+ tentry = *(prev = &tentry->next);
+ continue;
+ }
+ nfentry = fentry->next;
+ if (fentry->leaf != tentry->leaf ||
+ fentry->tight != tentry->tight) {
+ /* no match, just chain in */
+ *prev = fentry;
+ *(prev = &fentry->next) = tentry;
+ ttable->entries++;
+ } else {
+ if (fentry->leaf)
+ MergeValues((LTable)fentry, prev, override);
+ else
+ MergeTables(fentry, prev, override);
+ /* bump to next tentry */
+ tentry = *(prev = &(*prev)->next);
+ }
+ /* bump to next fentry */
+ fentry = nfentry;
+ if (!fentry)
+ break;
+ }
+ /* at this point, tentry cannot match any fentry named q */
+ /* chain in all bindings together, preserve invariant order */
+ while (fentry && fentry->name == q) {
+ *prev = fentry;
+ prev = &fentry->next;
+ fentry = *prev;
+ *prev = tentry;
+ ttable->entries++;
+ }
+ }
+ }
+ Xfree((char *)ftable);
+ /* resize if necessary, now that we're all done */
+ GROW(pprev);
+}
+
+void XrmCombineDatabase(
+ XrmDatabase from, XrmDatabase *into,
+ Bool override)
+{
+ register NTable *prev;
+ register NTable ftable, ttable, nftable;
+
+ if (!*into) {
+ *into = from;
+ } else if (from) {
+ _XLockMutex(&from->linfo);
+ _XLockMutex(&(*into)->linfo);
+ if ((ftable = from->table)) {
+ prev = &(*into)->table;
+ ttable = *prev;
+ if (!ftable->leaf) {
+ nftable = ftable->next;
+ if (ttable && !ttable->leaf) {
+ /* both have node tables, merge them */
+ MergeTables(ftable, prev, override);
+ /* bump to into's leaf table, if any */
+ ttable = *(prev = &(*prev)->next);
+ } else {
+ /* into has no node table, link from's in */
+ *prev = ftable;
+ *(prev = &ftable->next) = ttable;
+ }
+ /* bump to from's leaf table, if any */
+ ftable = nftable;
+ } else {
+ /* bump to into's leaf table, if any */
+ if (ttable && !ttable->leaf)
+ ttable = *(prev = &ttable->next);
+ }
+ if (ftable) {
+ /* if into has a leaf, merge, else insert */
+ if (ttable)
+ MergeValues((LTable)ftable, prev, override);
+ else
+ *prev = ftable;
+ }
+ }
+ (from->methods->destroy)(from->mbstate);
+ _XFreeMutex(&from->linfo);
+ Xfree((char *)from);
+ _XUnlockMutex(&(*into)->linfo);
+ }
+}
+
+void XrmMergeDatabases(
+ XrmDatabase from, XrmDatabase *into)
+{
+ XrmCombineDatabase(from, into, True);
+}
+
+/* store a value in the database, overriding any existing entry */
+static void PutEntry(
+ XrmDatabase db,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ XrmRepresentation type,
+ XrmValuePtr value)
+{
+ register NTable *pprev, *prev;
+ register NTable table;
+ register XrmQuark q;
+ register VEntry *vprev;
+ register VEntry entry;
+ NTable *nprev, *firstpprev;
+
+#define NEWTABLE(q,i) \
+ table = (NTable)Xmalloc(sizeof(LTableRec)); \
+ if (!table) \
+ return; \
+ table->name = q; \
+ table->hasloose = 0; \
+ table->hasany = 0; \
+ table->mask = 0; \
+ table->entries = 0; \
+ if (quarks[i]) { \
+ table->leaf = 0; \
+ nprev = NodeBuckets(table); \
+ } else { \
+ table->leaf = 1; \
+ if (!(nprev = (NTable *)Xmalloc(sizeof(VEntry *)))) \
+ return; \
+ ((LTable)table)->buckets = (VEntry *)nprev; \
+ } \
+ *nprev = (NTable)NULL; \
+ table->next = *prev; \
+ *prev = table
+
+ if (!db || !*quarks)
+ return;
+ table = *(prev = &db->table);
+ /* if already at leaf, bump to the leaf table */
+ if (!quarks[1] && table && !table->leaf)
+ table = *(prev = &table->next);
+ pprev = prev;
+ if (!table || (quarks[1] && table->leaf)) {
+ /* no top-level node table, create one and chain it in */
+ NEWTABLE(NULLQUARK,1);
+ table->tight = 1; /* arbitrary */
+ prev = nprev;
+ } else {
+ /* search along until we need a value */
+ while (quarks[1]) {
+ q = *quarks;
+ table = *(prev = &NodeHash(table, q));
+ while (table && table->name != q)
+ table = *(prev = &table->next);
+ if (!table)
+ break; /* not found */
+ if (quarks[2]) {
+ if (table->leaf)
+ break; /* not found */
+ } else {
+ if (!table->leaf) {
+ /* bump to leaf table, if any */
+ table = *(prev = &table->next);
+ if (!table || table->name != q)
+ break; /* not found */
+ if (!table->leaf) {
+ /* bump to leaf table, if any */
+ table = *(prev = &table->next);
+ if (!table || table->name != q)
+ break; /* not found */
+ }
+ }
+ }
+ if (*bindings == XrmBindTightly) {
+ if (!table->tight)
+ break; /* not found */
+ } else {
+ if (table->tight) {
+ /* bump to loose table, if any */
+ table = *(prev = &table->next);
+ if (!table || table->name != q ||
+ !quarks[2] != table->leaf)
+ break; /* not found */
+ }
+ }
+ /* found that one, bump to next quark */
+ pprev = prev;
+ quarks++;
+ bindings++;
+ }
+ if (!quarks[1]) {
+ /* found all the way to a leaf */
+ q = *quarks;
+ entry = *(vprev = &LeafHash((LTable)table, q));
+ while (entry && entry->name != q)
+ entry = *(vprev = &entry->next);
+ /* if want loose and have tight, bump to next entry */
+ if (entry && *bindings == XrmBindLoosely && entry->tight)
+ entry = *(vprev = &entry->next);
+ if (entry && entry->name == q &&
+ (*bindings == XrmBindTightly) == entry->tight) {
+ /* match, need to override */
+ if ((type == XrmQString) == entry->string &&
+ entry->size == value->size) {
+ /* update type if not String, can be different */
+ if (!entry->string)
+ RepType(entry) = type;
+ /* identical size, just overwrite value */
+ memcpy(RawValue(entry), (char *)value->addr, value->size);
+ return;
+ }
+ /* splice out and free old entry */
+ *vprev = entry->next;
+ Xfree((char *)entry);
+ (*pprev)->entries--;
+ }
+ /* this is where to insert */
+ prev = (NTable *)vprev;
+ }
+ }
+ /* keep the top table, because we may have to grow it */
+ firstpprev = pprev;
+ /* iterate until we get to the leaf */
+ while (quarks[1]) {
+ /* build a new table and chain it in */
+ NEWTABLE(*quarks,2);
+ if (*quarks++ == XrmQANY)
+ (*pprev)->hasany = 1;
+ if (*bindings++ == XrmBindTightly) {
+ table->tight = 1;
+ } else {
+ table->tight = 0;
+ (*pprev)->hasloose = 1;
+ }
+ (*pprev)->entries++;
+ pprev = prev;
+ prev = nprev;
+ }
+ /* now allocate the value entry */
+ entry = (VEntry)Xmalloc(((type == XrmQString) ?
+ sizeof(VEntryRec) : sizeof(DEntryRec)) +
+ value->size);
+ if (!entry)
+ return;
+ entry->name = q = *quarks;
+ if (*bindings == XrmBindTightly) {
+ entry->tight = 1;
+ } else {
+ entry->tight = 0;
+ (*pprev)->hasloose = 1;
+ }
+ /* chain it in, with a bit of type cast ugliness */
+ entry->next = *((VEntry *)prev);
+ *((VEntry *)prev) = entry;
+ entry->size = value->size;
+ if (type == XrmQString) {
+ entry->string = 1;
+ } else {
+ entry->string = 0;
+ RepType(entry) = type;
+ }
+ /* save a copy of the value */
+ memcpy(RawValue(entry), (char *)value->addr, value->size);
+ (*pprev)->entries++;
+ /* this is a new leaf, need to remember it for search lists */
+ if (q > maxResourceQuark) {
+ unsigned oldsize = (maxResourceQuark + 1) >> 3;
+ unsigned size = ((q | 0x7f) + 1) >> 3; /* reallocate in chunks */
+ if (resourceQuarks) {
+ unsigned char *prevQuarks = resourceQuarks;
+
+ resourceQuarks = (unsigned char *)Xrealloc((char *)resourceQuarks,
+ size);
+ if (!resourceQuarks) {
+ Xfree(prevQuarks);
+ }
+ } else
+ resourceQuarks = (unsigned char *)Xmalloc(size);
+ if (resourceQuarks) {
+ bzero((char *)&resourceQuarks[oldsize], size - oldsize);
+ maxResourceQuark = (size << 3) - 1;
+ } else {
+ maxResourceQuark = -1;
+ }
+ }
+ if (q > 0 && resourceQuarks)
+ resourceQuarks[q >> 3] |= 1 << (q & 0x7);
+ GROW(firstpprev);
+
+#undef NEWTABLE
+}
+
+void XrmQPutResource(
+ XrmDatabase *pdb,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ XrmRepresentation type,
+ XrmValuePtr value)
+{
+ if (!*pdb) *pdb = NewDatabase();
+ _XLockMutex(&(*pdb)->linfo);
+ PutEntry(*pdb, bindings, quarks, type, value);
+ _XUnlockMutex(&(*pdb)->linfo);
+}
+
+void
+XrmPutResource(
+ XrmDatabase *pdb,
+ _Xconst char *specifier,
+ _Xconst char *type,
+ XrmValuePtr value)
+{
+ XrmBinding bindings[MAXDBDEPTH+1];
+ XrmQuark quarks[MAXDBDEPTH+1];
+
+ if (!*pdb) *pdb = NewDatabase();
+ _XLockMutex(&(*pdb)->linfo);
+ XrmStringToBindingQuarkList(specifier, bindings, quarks);
+ PutEntry(*pdb, bindings, quarks, XrmStringToQuark(type), value);
+ _XUnlockMutex(&(*pdb)->linfo);
+}
+
+void
+XrmQPutStringResource(
+ XrmDatabase *pdb,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ _Xconst char *str)
+{
+ XrmValue value;
+
+ if (!*pdb) *pdb = NewDatabase();
+ value.addr = (XPointer) str;
+ value.size = strlen(str)+1;
+ _XLockMutex(&(*pdb)->linfo);
+ PutEntry(*pdb, bindings, quarks, XrmQString, &value);
+ _XUnlockMutex(&(*pdb)->linfo);
+}
+
+/* Function Name: GetDatabase
+ * Description: Parses a string and stores it as a database.
+ * Arguments: db - the database.
+ * str - a pointer to the string containing the database.
+ * filename - source filename, if any.
+ * doall - whether to do all lines or just one
+ */
+
+/*
+ * This function is highly optimized to inline as much as possible.
+ * Be very careful with modifications, or simplifications, as they
+ * may adversely affect the performance.
+ *
+ * Chris Peterson, MIT X Consortium 5/17/90.
+ */
+
+/*
+ * Xlib spec says max 100 quarks in a lookup, will stop and return if
+ * return if any single production's lhs has more than 100 components.
+ */
+#define QLIST_SIZE 100
+
+/*
+ * This should be big enough to handle things like the XKeysymDB or biggish
+ * ~/.Xdefaults or app-defaults files. Anything bigger will be allocated on
+ * the heap.
+ */
+#define DEF_BUFF_SIZE 8192
+
+static void GetIncludeFile(
+ XrmDatabase db,
+ _Xconst char *base,
+ _Xconst char *fname,
+ int fnamelen);
+
+static void GetDatabase(
+ XrmDatabase db,
+ _Xconst register char *str,
+ _Xconst char *filename,
+ Bool doall)
+{
+ char *rhs;
+ char *lhs, lhs_s[DEF_BUFF_SIZE];
+ XrmQuark quarks[QLIST_SIZE + 1]; /* allow for a terminal NullQuark */
+ XrmBinding bindings[QLIST_SIZE + 1];
+
+ register char *ptr;
+ register XrmBits bits = 0;
+ register char c;
+ register Signature sig;
+ register char *ptr_max;
+ register int num_quarks;
+ register XrmBindingList t_bindings;
+
+ int len, alloc_chars;
+ unsigned long str_len;
+ XrmValue value;
+ Bool only_pcs;
+ Bool dolines;
+
+ if (!db)
+ return;
+
+ /*
+ * if strlen (str) < DEF_BUFF_SIZE allocate buffers on the stack for
+ * speed otherwise malloc the buffer. From a buffer overflow standpoint
+ * we can be sure that neither: a) a component on the lhs, or b) a
+ * value on the rhs, will be longer than the overall length of str,
+ * i.e. strlen(str).
+ *
+ * This should give good performance when parsing "*foo: bar" type
+ * databases as might be passed with -xrm command line options; but
+ * with larger databases, e.g. .Xdefaults, app-defaults, or KeysymDB
+ * files, the size of the buffers will be overly large. One way
+ * around this would be to double-parse each production with a resulting
+ * performance hit. In any event we can be assured that a lhs component
+ * name or a rhs value won't be longer than str itself.
+ */
+
+ str_len = strlen (str);
+ if (DEF_BUFF_SIZE > str_len) lhs = lhs_s;
+ else if ((lhs = (char*) Xmalloc (str_len)) == NULL)
+ return;
+
+ alloc_chars = DEF_BUFF_SIZE < str_len ? str_len : DEF_BUFF_SIZE;
+ if ((rhs = (char*) Xmalloc (alloc_chars)) == NULL) {
+ if (lhs != lhs_s) Xfree (lhs);
+ return;
+ }
+
+ (*db->methods->mbinit)(db->mbstate);
+ str--;
+ dolines = True;
+ while (!is_EOF(bits) && dolines) {
+ dolines = doall;
+
+ /*
+ * First: Remove extra whitespace.
+ */
+
+ do {
+ bits = next_char(c, str);
+ } while is_space(bits);
+
+ /*
+ * Ignore empty lines.
+ */
+
+ if (is_EOL(bits))
+ continue; /* start a new line. */
+
+ /*
+ * Second: check the first character in a line to see if it is
+ * "!" signifying a comment, or "#" signifying a directive.
+ */
+
+ if (c == '!') { /* Comment, spin to next newline */
+ while (is_simple(bits = next_char(c, str))) {}
+ if (is_EOL(bits))
+ continue;
+ while (!is_EOL(bits = next_mbchar(c, len, str))) {}
+ str--;
+ continue; /* start a new line. */
+ }
+
+ if (c == '#') { /* Directive */
+ /* remove extra whitespace */
+ only_pcs = True;
+ while (is_space(bits = next_char(c, str))) {};
+ /* only "include" directive is currently defined */
+ if (!strncmp(str, "include", 7)) {
+ str += (7-1);
+ /* remove extra whitespace */
+ while (is_space(bits = next_char(c, str))) {};
+ /* must have a starting " */
+ if (c == '"') {
+ _Xconst char *fname = str+1;
+ len = 0;
+ do {
+ if (only_pcs) {
+ bits = next_char(c, str);
+ if (is_nonpcs(bits))
+ only_pcs = False;
+ }
+ if (!only_pcs)
+ bits = next_mbchar(c, len, str);
+ } while (c != '"' && !is_EOL(bits));
+ /* must have an ending " */
+ if (c == '"')
+ GetIncludeFile(db, filename, fname, str - len - fname);
+ }
+ }
+ /* spin to next newline */
+ if (only_pcs) {
+ while (is_simple(bits))
+ bits = next_char(c, str);
+ if (is_EOL(bits))
+ continue;
+ }
+ while (!is_EOL(bits))
+ bits = next_mbchar(c, len, str);
+ str--;
+ continue; /* start a new line. */
+ }
+
+ /*
+ * Third: loop through the LHS of the resource specification
+ * storing characters and converting this to a Quark.
+ */
+
+ num_quarks = 0;
+ t_bindings = bindings;
+
+ sig = 0;
+ ptr = lhs;
+ *t_bindings = XrmBindTightly;
+ for(;;) {
+ if (!is_binding(bits)) {
+ while (!is_EOQ(bits)) {
+ *ptr++ = c;
+ sig = (sig << 1) + c; /* Compute the signature. */
+ bits = next_char(c, str);
+ }
+
+ quarks[num_quarks++] =
+ _XrmInternalStringToQuark(lhs, ptr - lhs, sig, False);
+
+ if (num_quarks > QLIST_SIZE) {
+ Xfree(rhs);
+ if (lhs != lhs_s) Xfree (lhs);
+ (*db->methods->mbfinish)(db->mbstate);
+ return;
+ }
+
+ if (is_separator(bits)) {
+ if (!is_space(bits))
+ break;
+
+ /* Remove white space */
+ do {
+ *ptr++ = c;
+ sig = (sig << 1) + c; /* Compute the signature. */
+ } while (is_space(bits = next_char(c, str)));
+
+ /*
+ * The spec doesn't permit it, but support spaces
+ * internal to resource name/class
+ */
+
+ if (is_separator(bits))
+ break;
+ num_quarks--;
+ continue;
+ }
+
+ if (c == '.')
+ *(++t_bindings) = XrmBindTightly;
+ else
+ *(++t_bindings) = XrmBindLoosely;
+
+ sig = 0;
+ ptr = lhs;
+ }
+ else {
+ /*
+ * Magic unspecified feature #254.
+ *
+ * If two separators appear with no Text between them then
+ * ignore them.
+ *
+ * If anyone of those separators is a '*' then the binding
+ * will be loose, otherwise it will be tight.
+ */
+
+ if (c == '*')
+ *t_bindings = XrmBindLoosely;
+ }
+
+ bits = next_char(c, str);
+ }
+
+ quarks[num_quarks] = NULLQUARK;
+
+ /*
+ * Make sure that there is a ':' in this line.
+ */
+
+ if (c != ':') {
+ char oldc;
+
+ /*
+ * A parsing error has occured, toss everything on the line
+ * a new_line can still be escaped with a '\'.
+ */
+
+ while (is_normal(bits))
+ bits = next_char(c, str);
+ if (is_EOL(bits))
+ continue;
+ bits = next_mbchar(c, len, str);
+ do {
+ oldc = c;
+ bits = next_mbchar(c, len, str);
+ } while (c && (c != '\n' || oldc == '\\'));
+ str--;
+ continue;
+ }
+
+ /*
+ * I now have a quark and binding list for the entire left hand
+ * side. "c" currently points to the ":" separating the left hand
+ * side for the right hand side. It is time to begin processing
+ * the right hand side.
+ */
+
+ /*
+ * Fourth: Remove more whitespace
+ */
+
+ for(;;) {
+ if (is_space(bits = next_char(c, str)))
+ continue;
+ if (c != '\\')
+ break;
+ bits = next_char(c, str);
+ if (c == '\n')
+ continue;
+ str--;
+ bits = BSLASH;
+ c = '\\';
+ break;
+ }
+
+ /*
+ * Fifth: Process the right hand side.
+ */
+
+ ptr = rhs;
+ ptr_max = ptr + alloc_chars - 4;
+ only_pcs = True;
+ len = 1;
+
+ for(;;) {
+
+ /*
+ * Tight loop for the normal case: Non backslash, non-end of value
+ * character that will fit into the allocated buffer.
+ */
+
+ if (only_pcs) {
+ while (is_normal(bits) && ptr < ptr_max) {
+ *ptr++ = c;
+ bits = next_char(c, str);
+ }
+ if (is_EOL(bits))
+ break;
+ if (is_nonpcs(bits)) {
+ only_pcs = False;
+ bits = next_mbchar(c, len, str);
+ }
+ }
+ while (!is_special(bits) && ptr + len <= ptr_max) {
+ len = -len;
+ while (len)
+ *ptr++ = str[len++];
+ if (*str == '\0') {
+ bits = EOS;
+ break;
+ }
+ bits = next_mbchar(c, len, str);
+ }
+
+ if (is_EOL(bits)) {
+ str--;
+ break;
+ }
+
+ if (c == '\\') {
+ /*
+ * We need to do some magic after a backslash.
+ */
+ Bool read_next = True;
+
+ if (only_pcs) {
+ bits = next_char(c, str);
+ if (is_nonpcs(bits))
+ only_pcs = False;
+ }
+ if (!only_pcs)
+ bits = next_mbchar(c, len, str);
+
+ if (is_EOL(bits)) {
+ if (is_EOF(bits))
+ continue;
+ } else if (c == 'n') {
+ /*
+ * "\n" means insert a newline.
+ */
+ *ptr++ = '\n';
+ } else if (c == '\\') {
+ /*
+ * "\\" completes to just one backslash.
+ */
+ *ptr++ = '\\';
+ } else {
+ /*
+ * pick up to three octal digits after the '\'.
+ */
+ char temp[3];
+ int count = 0;
+ while (is_odigit(bits) && count < 3) {
+ temp[count++] = c;
+ if (only_pcs) {
+ bits = next_char(c, str);
+ if (is_nonpcs(bits))
+ only_pcs = False;
+ }
+ if (!only_pcs)
+ bits = next_mbchar(c, len, str);
+ }
+
+ /*
+ * If we found three digits then insert that octal code
+ * into the value string as a character.
+ */
+
+ if (count == 3) {
+ *ptr++ = (unsigned char) ((temp[0] - '0') * 0100 +
+ (temp[1] - '0') * 010 +
+ (temp[2] - '0'));
+ }
+ else {
+ int tcount;
+
+ /*
+ * Otherwise just insert those characters into the
+ * string, since no special processing is needed on
+ * numerics we can skip the special processing.
+ */
+
+ for (tcount = 0; tcount < count; tcount++) {
+ *ptr++ = temp[tcount]; /* print them in
+ the correct order */
+ }
+ }
+ read_next = False;
+ }
+ if (read_next) {
+ if (only_pcs) {
+ bits = next_char(c, str);
+ if (is_nonpcs(bits))
+ only_pcs = False;
+ }
+ if (!only_pcs)
+ bits = next_mbchar(c, len, str);
+ }
+ }
+
+ /*
+ * It is important to make sure that there is room for at least
+ * four more characters in the buffer, since I can add that
+ * many characters into the buffer after a backslash has occured.
+ */
+
+ if (ptr + len > ptr_max) {
+ char * temp_str;
+
+ alloc_chars += BUFSIZ/10;
+ temp_str = Xrealloc(rhs, sizeof(char) * alloc_chars);
+
+ if (!temp_str) {
+ Xfree(rhs);
+ if (lhs != lhs_s) Xfree (lhs);
+ (*db->methods->mbfinish)(db->mbstate);
+ return;
+ }
+
+ ptr = temp_str + (ptr - rhs); /* reset pointer. */
+ rhs = temp_str;
+ ptr_max = rhs + alloc_chars - 4;
+ }
+ }
+
+ /*
+ * Lastly: Terminate the value string, and store this entry
+ * into the database.
+ */
+
+ *ptr++ = '\0';
+
+ /* Store it in database */
+ value.size = ptr - rhs;
+ value.addr = (XPointer) rhs;
+
+ PutEntry(db, bindings, quarks, XrmQString, &value);
+ }
+
+ if (lhs != lhs_s) Xfree (lhs);
+ Xfree (rhs);
+
+ (*db->methods->mbfinish)(db->mbstate);
+}
+
+void
+XrmPutStringResource(
+ XrmDatabase *pdb,
+ _Xconst char*specifier,
+ _Xconst char*str)
+{
+ XrmValue value;
+ XrmBinding bindings[MAXDBDEPTH+1];
+ XrmQuark quarks[MAXDBDEPTH+1];
+
+ if (!*pdb) *pdb = NewDatabase();
+ XrmStringToBindingQuarkList(specifier, bindings, quarks);
+ value.addr = (XPointer) str;
+ value.size = strlen(str)+1;
+ _XLockMutex(&(*pdb)->linfo);
+ PutEntry(*pdb, bindings, quarks, XrmQString, &value);
+ _XUnlockMutex(&(*pdb)->linfo);
+}
+
+
+void
+XrmPutLineResource(
+ XrmDatabase *pdb,
+ _Xconst char*line)
+{
+ if (!*pdb) *pdb = NewDatabase();
+ _XLockMutex(&(*pdb)->linfo);
+ GetDatabase(*pdb, line, (char *)NULL, False);
+ _XUnlockMutex(&(*pdb)->linfo);
+}
+
+XrmDatabase
+XrmGetStringDatabase(
+ _Xconst char *data)
+{
+ XrmDatabase db;
+
+ db = NewDatabase();
+ _XLockMutex(&db->linfo);
+ GetDatabase(db, data, (char *)NULL, True);
+ _XUnlockMutex(&db->linfo);
+ return db;
+}
+
+/* Function Name: ReadInFile
+ * Description: Reads the file into a buffer.
+ * Arguments: filename - the name of the file.
+ * Returns: An allocated string containing the contents of the file.
+ */
+
+static char *
+ReadInFile(_Xconst char *filename)
+{
+ register int fd, size;
+ char * filebuf;
+
+#ifdef __UNIXOS2__
+ filename = __XOS2RedirRoot(filename);
+#endif
+
+ /*
+ * MS-Windows and OS/2 note: Default open mode includes O_TEXT
+ */
+ if ( (fd = _XOpenFile (filename, O_RDONLY)) == -1 )
+ return (char *)NULL;
+
+ /*
+ * MS-Windows and OS/2 note: depending on how the sources are
+ * untarred, the newlines in resource files may or may not have
+ * been expanded to CRLF. Either way the size returned by fstat
+ * is sufficient to read the file into because in text-mode any
+ * CRLFs in a file will be converted to newlines (LF) with the
+ * result that the number of bytes actually read with be <=
+ * to the size returned by fstat.
+ */
+ GetSizeOfFile(fd, size);
+
+ if (!(filebuf = Xmalloc(size + 1))) { /* leave room for '\0' */
+ close(fd);
+ return (char *)NULL;
+ }
+ size = read (fd, filebuf, size);
+
+#ifdef __UNIXOS2__
+ { /* kill CRLF */
+ int i,k;
+ for (i=k=0; i<size; i++)
+ if (filebuf[i] != 0x0d) {
+ filebuf[k++] = filebuf[i];
+ }
+ filebuf[k] = 0;
+ }
+#endif
+
+ if (size < 0) {
+ close (fd);
+ Xfree(filebuf);
+ return (char *)NULL;
+ }
+ close (fd);
+
+ filebuf[size] = '\0'; /* NULL terminate it. */
+ return filebuf;
+}
+
+static void
+GetIncludeFile(
+ XrmDatabase db,
+ _Xconst char *base,
+ _Xconst char *fname,
+ int fnamelen)
+{
+ int len;
+ char *str;
+ char realfname[BUFSIZ];
+
+ if (fnamelen <= 0 || fnamelen >= BUFSIZ)
+ return;
+ if (*fname != '/' && base && (str = strrchr(base, '/'))) {
+ len = str - base + 1;
+ if (len + fnamelen >= BUFSIZ)
+ return;
+ strncpy(realfname, base, len);
+ strncpy(realfname + len, fname, fnamelen);
+ realfname[len + fnamelen] = '\0';
+ } else {
+ strncpy(realfname, fname, fnamelen);
+ realfname[fnamelen] = '\0';
+ }
+ if (!(str = ReadInFile(realfname)))
+ return;
+ GetDatabase(db, str, realfname, True);
+ Xfree(str);
+}
+
+XrmDatabase
+XrmGetFileDatabase(
+ _Xconst char *filename)
+{
+ XrmDatabase db;
+ char *str;
+
+ if (!(str = ReadInFile(filename)))
+ return (XrmDatabase)NULL;
+
+ db = NewDatabase();
+ _XLockMutex(&db->linfo);
+ GetDatabase(db, str, filename, True);
+ _XUnlockMutex(&db->linfo);
+ Xfree(str);
+ return db;
+}
+
+Status
+XrmCombineFileDatabase(
+ _Xconst char *filename,
+ XrmDatabase *target,
+ Bool override)
+{
+ XrmDatabase db;
+ char *str;
+
+ if (!(str = ReadInFile(filename)))
+ return 0;
+ if (override) {
+ db = *target;
+ if (!db)
+ *target = db = NewDatabase();
+ } else
+ db = NewDatabase();
+ _XLockMutex(&db->linfo);
+ GetDatabase(db, str, filename, True);
+ _XUnlockMutex(&db->linfo);
+ Xfree(str);
+ if (!override)
+ XrmCombineDatabase(db, target, False);
+ return 1;
+}
+
+/* call the user proc for every value in the table, arbitrary order.
+ * stop if user proc returns True. level is current depth in database.
+ */
+/*ARGSUSED*/
+static Bool EnumLTable(
+ LTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ register int level,
+ register EClosure closure)
+{
+ register VEntry *bucket;
+ register int i;
+ register VEntry entry;
+ XrmValue value;
+ XrmRepresentation type;
+ Bool tightOk;
+
+ closure->bindings[level] = (table->table.tight ?
+ XrmBindTightly : XrmBindLoosely);
+ closure->quarks[level] = table->table.name;
+ level++;
+ tightOk = !*names;
+ closure->quarks[level + 1] = NULLQUARK;
+ for (i = table->table.mask, bucket = table->buckets;
+ i >= 0;
+ i--, bucket++) {
+ for (entry = *bucket; entry; entry = entry->next) {
+ if (entry->tight && !tightOk)
+ continue;
+ closure->bindings[level] = (entry->tight ?
+ XrmBindTightly : XrmBindLoosely);
+ closure->quarks[level] = entry->name;
+ value.size = entry->size;
+ if (entry->string) {
+ type = XrmQString;
+ value.addr = StringValue(entry);
+ } else {
+ type = RepType(entry);
+ value.addr = DataValue(entry);
+ }
+ if ((*closure->proc)(&closure->db, closure->bindings+1,
+ closure->quarks+1, &type, &value,
+ closure->closure))
+ return True;
+ }
+ }
+ return False;
+}
+
+static Bool EnumAllNTable(
+ NTable table,
+ register int level,
+ register EClosure closure)
+{
+ register NTable *bucket;
+ register int i;
+ register NTable entry;
+ XrmQuark empty = NULLQUARK;
+
+ if (level >= MAXDBDEPTH)
+ return False;
+ for (i = table->mask, bucket = NodeBuckets(table);
+ i >= 0;
+ i--, bucket++) {
+ for (entry = *bucket; entry; entry = entry->next) {
+ if (entry->leaf) {
+ if (EnumLTable((LTable)entry, &empty, &empty, level, closure))
+ return True;
+ } else {
+ closure->bindings[level] = (entry->tight ?
+ XrmBindTightly : XrmBindLoosely);
+ closure->quarks[level] = entry->name;
+ if (EnumAllNTable(entry, level+1, closure))
+ return True;
+ }
+ }
+ }
+ return False;
+}
+
+/* recurse on every table in the table, arbitrary order.
+ * stop if user proc returns True. level is current depth in database.
+ */
+static Bool EnumNTable(
+ NTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ register int level,
+ register EClosure closure)
+{
+ register NTable entry;
+ register XrmQuark q;
+ register unsigned int leaf;
+ Bool (*get)(
+ NTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ register int level,
+ EClosure closure);
+ Bool bilevel;
+
+/* find entries named ename, leafness leaf, tight or loose, and call get */
+#define ITIGHTLOOSE(ename) \
+ NFIND(ename); \
+ if (entry) { \
+ if (leaf == entry->leaf) { \
+ if (!leaf && !entry->tight && entry->next && \
+ entry->next->name == q && entry->next->tight && \
+ (bilevel || entry->next->hasloose) && \
+ EnumLTable((LTable)entry->next, names+1, classes+1, \
+ level, closure)) \
+ return True; \
+ if ((*get)(entry, names+1, classes+1, level, closure)) \
+ return True; \
+ if (entry->tight && (entry = entry->next) && \
+ entry->name == q && leaf == entry->leaf && \
+ (*get)(entry, names+1, classes+1, level, closure)) \
+ return True; \
+ } else if (entry->leaf) { \
+ if ((bilevel || entry->hasloose) && \
+ EnumLTable((LTable)entry, names+1, classes+1, level, closure))\
+ return True; \
+ if (entry->tight && (entry = entry->next) && \
+ entry->name == q && (bilevel || entry->hasloose) && \
+ EnumLTable((LTable)entry, names+1, classes+1, level, closure))\
+ return True; \
+ } \
+ }
+
+/* find entries named ename, leafness leaf, loose only, and call get */
+#define ILOOSE(ename) \
+ NFIND(ename); \
+ if (entry && entry->tight && (entry = entry->next) && entry->name != q) \
+ entry = (NTable)NULL; \
+ if (entry) { \
+ if (leaf == entry->leaf) { \
+ if ((*get)(entry, names+1, classes+1, level, closure)) \
+ return True; \
+ } else if (entry->leaf && (bilevel || entry->hasloose)) { \
+ if (EnumLTable((LTable)entry, names+1, classes+1, level, closure))\
+ return True; \
+ } \
+ }
+
+ if (level >= MAXDBDEPTH)
+ return False;
+ closure->bindings[level] = (table->tight ?
+ XrmBindTightly : XrmBindLoosely);
+ closure->quarks[level] = table->name;
+ level++;
+ if (!*names) {
+ if (EnumAllNTable(table, level, closure))
+ return True;
+ } else {
+ if (names[1] || closure->mode == XrmEnumAllLevels) {
+ get = EnumNTable; /* recurse */
+ leaf = 0;
+ bilevel = !names[1];
+ } else {
+ get = (getNTableEProcp)EnumLTable; /* bottom of recursion */
+ leaf = 1;
+ bilevel = False;
+ }
+ if (table->hasloose && closure->mode == XrmEnumAllLevels) {
+ NTable *bucket;
+ int i;
+ XrmQuark empty = NULLQUARK;
+
+ for (i = table->mask, bucket = NodeBuckets(table);
+ i >= 0;
+ i--, bucket++) {
+ q = NULLQUARK;
+ for (entry = *bucket; entry; entry = entry->next) {
+ if (!entry->tight && entry->name != q &&
+ entry->name != *names && entry->name != *classes) {
+ q = entry->name;
+ if (entry->leaf) {
+ if (EnumLTable((LTable)entry, &empty, &empty,
+ level, closure))
+ return True;
+ } else {
+ if (EnumNTable(entry, &empty, &empty,
+ level, closure))
+ return True;
+ }
+ }
+ }
+ }
+ }
+
+ ITIGHTLOOSE(*names); /* do name, tight and loose */
+ ITIGHTLOOSE(*classes); /* do class, tight and loose */
+ if (table->hasany) {
+ ITIGHTLOOSE(XrmQANY); /* do ANY, tight and loose */
+ }
+ if (table->hasloose) {
+ while (1) {
+ names++;
+ classes++;
+ if (!*names)
+ break;
+ if (!names[1] && closure->mode != XrmEnumAllLevels) {
+ get = (getNTableEProcp)EnumLTable; /* bottom of recursion */
+ leaf = 1;
+ }
+ ILOOSE(*names); /* loose names */
+ ILOOSE(*classes); /* loose classes */
+ if (table->hasany) {
+ ILOOSE(XrmQANY); /* loose ANY */
+ }
+ }
+ names--;
+ classes--;
+ }
+ }
+ /* now look for matching leaf nodes */
+ entry = table->next;
+ if (!entry)
+ return False;
+ if (entry->leaf) {
+ if (entry->tight && !table->tight)
+ entry = entry->next;
+ } else {
+ entry = entry->next;
+ if (!entry || !entry->tight)
+ return False;
+ }
+ if (!entry || entry->name != table->name)
+ return False;
+ /* found one */
+ level--;
+ if ((!*names || entry->hasloose) &&
+ EnumLTable((LTable)entry, names, classes, level, closure))
+ return True;
+ if (entry->tight && entry == table->next && (entry = entry->next) &&
+ entry->name == table->name && (!*names || entry->hasloose))
+ return EnumLTable((LTable)entry, names, classes, level, closure);
+ return False;
+
+#undef ITIGHTLOOSE
+#undef ILOOSE
+}
+
+/* call the proc for every value in the database, arbitrary order.
+ * stop if the proc returns True.
+ */
+Bool XrmEnumerateDatabase(
+ XrmDatabase db,
+ XrmNameList names,
+ XrmClassList classes,
+ int mode,
+ DBEnumProc proc,
+ XPointer closure)
+{
+ XrmBinding bindings[MAXDBDEPTH+2];
+ XrmQuark quarks[MAXDBDEPTH+2];
+ register NTable table;
+ EClosureRec eclosure;
+ Bool retval = False;
+
+ if (!db)
+ return False;
+ _XLockMutex(&db->linfo);
+ eclosure.db = db;
+ eclosure.proc = proc;
+ eclosure.closure = closure;
+ eclosure.bindings = bindings;
+ eclosure.quarks = quarks;
+ eclosure.mode = mode;
+ table = db->table;
+ if (table && !table->leaf && !*names && mode == XrmEnumOneLevel)
+ table = table->next;
+ if (table) {
+ if (!table->leaf)
+ retval = EnumNTable(table, names, classes, 0, &eclosure);
+ else
+ retval = EnumLTable((LTable)table, names, classes, 0, &eclosure);
+ }
+ _XUnlockMutex(&db->linfo);
+ return retval;
+}
+
+static void PrintBindingQuarkList(
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ FILE *stream)
+{
+ Bool firstNameSeen;
+
+ for (firstNameSeen = False; *quarks; bindings++, quarks++) {
+ if (*bindings == XrmBindLoosely) {
+ (void) fprintf(stream, "*");
+ } else if (firstNameSeen) {
+ (void) fprintf(stream, ".");
+ }
+ firstNameSeen = True;
+ (void) fputs(XrmQuarkToString(*quarks), stream);
+ }
+}
+
+/* output out the entry in correct file syntax */
+/*ARGSUSED*/
+static Bool DumpEntry(
+ XrmDatabase *db,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ XrmRepresentation *type,
+ XrmValuePtr value,
+ XPointer data)
+{
+ FILE *stream = (FILE *)data;
+ register unsigned int i;
+ register char *s;
+ register char c;
+
+ if (*type != XrmQString)
+ (void) putc('!', stream);
+ PrintBindingQuarkList(bindings, quarks, stream);
+ s = value->addr;
+ i = value->size;
+ if (*type == XrmQString) {
+ (void) fputs(":\t", stream);
+ if (i)
+ i--;
+ }
+ else
+ (void) fprintf(stream, "=%s:\t", XrmRepresentationToString(*type));
+ if (i && (*s == ' ' || *s == '\t'))
+ (void) putc('\\', stream); /* preserve leading whitespace */
+ while (i--) {
+ c = *s++;
+ if (c == '\n') {
+ if (i)
+ (void) fputs("\\n\\\n", stream);
+ else
+ (void) fputs("\\n", stream);
+ } else if (c == '\\')
+ (void) fputs("\\\\", stream);
+ else if ((c < ' ' && c != '\t') ||
+ ((unsigned char)c >= 0x7f && (unsigned char)c < 0xa0))
+ (void) fprintf(stream, "\\%03o", (unsigned char)c);
+ else
+ (void) putc(c, stream);
+ }
+ (void) putc('\n', stream);
+ return ferror(stream) != 0;
+}
+
+#ifdef DEBUG
+
+void PrintTable(
+ NTable table,
+ FILE *file)
+{
+ XrmBinding bindings[MAXDBDEPTH+1];
+ XrmQuark quarks[MAXDBDEPTH+1];
+ EClosureRec closure;
+ XrmQuark empty = NULLQUARK;
+
+ closure.db = (XrmDatabase)NULL;
+ closure.proc = DumpEntry;
+ closure.closure = (XPointer)file;
+ closure.bindings = bindings;
+ closure.quarks = quarks;
+ closure.mode = XrmEnumAllLevels;
+ if (table->leaf)
+ EnumLTable((LTable)table, &empty, &empty, 0, &closure);
+ else
+ EnumNTable(table, &empty, &empty, 0, &closure);
+}
+
+#endif /* DEBUG */
+
+void
+XrmPutFileDatabase(
+ XrmDatabase db,
+ _Xconst char *fileName)
+{
+ FILE *file;
+ XrmQuark empty = NULLQUARK;
+
+ if (!db) return;
+ if (!(file = fopen(fileName, "w"))) return;
+ if (XrmEnumerateDatabase(db, &empty, &empty, XrmEnumAllLevels,
+ DumpEntry, (XPointer) file))
+ unlink((char *)fileName);
+ fclose(file);
+}
+
+/* macros used in get/search functions */
+
+/* find entries named ename, leafness leaf, tight or loose, and call get */
+#define GTIGHTLOOSE(ename,looseleaf) \
+ NFIND(ename); \
+ if (entry) { \
+ if (leaf == entry->leaf) { \
+ if (!leaf && !entry->tight && entry->next && \
+ entry->next->name == q && entry->next->tight && \
+ entry->next->hasloose && \
+ looseleaf((LTable)entry->next, names+1, classes+1, closure)) \
+ return True; \
+ if ((*get)(entry, names+1, classes+1, closure)) \
+ return True; \
+ if (entry->tight && (entry = entry->next) && \
+ entry->name == q && leaf == entry->leaf && \
+ (*get)(entry, names+1, classes+1, closure)) \
+ return True; \
+ } else if (entry->leaf) { \
+ if (entry->hasloose && \
+ looseleaf((LTable)entry, names+1, classes+1, closure)) \
+ return True; \
+ if (entry->tight && (entry = entry->next) && \
+ entry->name == q && entry->hasloose && \
+ looseleaf((LTable)entry, names+1, classes+1, closure)) \
+ return True; \
+ } \
+ }
+
+/* find entries named ename, leafness leaf, loose only, and call get */
+#define GLOOSE(ename,looseleaf) \
+ NFIND(ename); \
+ if (entry && entry->tight && (entry = entry->next) && entry->name != q) \
+ entry = (NTable)NULL; \
+ if (entry) { \
+ if (leaf == entry->leaf) { \
+ if ((*get)(entry, names+1, classes+1, closure)) \
+ return True; \
+ } else if (entry->leaf && entry->hasloose) { \
+ if (looseleaf((LTable)entry, names+1, classes+1, closure)) \
+ return True; \
+ } \
+ }
+
+/* add tight/loose entry to the search list, return True if list is full */
+/*ARGSUSED*/
+static Bool AppendLEntry(
+ LTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ register SClosure closure)
+{
+ /* check for duplicate */
+ if (closure->idx >= 0 && closure->list[closure->idx] == table)
+ return False;
+ if (closure->idx == closure->limit)
+ return True;
+ /* append it */
+ closure->idx++;
+ closure->list[closure->idx] = table;
+ return False;
+}
+
+/* add loose entry to the search list, return True if list is full */
+/*ARGSUSED*/
+static Bool AppendLooseLEntry(
+ LTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ register SClosure closure)
+{
+ /* check for duplicate */
+ if (closure->idx >= 0 && closure->list[closure->idx] == table)
+ return False;
+ if (closure->idx >= closure->limit - 1)
+ return True;
+ /* append it */
+ closure->idx++;
+ closure->list[closure->idx] = LOOSESEARCH;
+ closure->idx++;
+ closure->list[closure->idx] = table;
+ return False;
+}
+
+/* search for a leaf table */
+static Bool SearchNEntry(
+ NTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ SClosure closure)
+{
+ register NTable entry;
+ register XrmQuark q;
+ register unsigned int leaf;
+ Bool (*get)(
+ NTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ SClosure closure);
+
+ if (names[1]) {
+ get = SearchNEntry; /* recurse */
+ leaf = 0;
+ } else {
+ get = (getNTableSProcp)AppendLEntry; /* bottom of recursion */
+ leaf = 1;
+ }
+ GTIGHTLOOSE(*names, AppendLooseLEntry); /* do name, tight and loose */
+ GTIGHTLOOSE(*classes, AppendLooseLEntry); /* do class, tight and loose */
+ if (table->hasany) {
+ GTIGHTLOOSE(XrmQANY, AppendLooseLEntry); /* do ANY, tight and loose */
+ }
+ if (table->hasloose) {
+ while (1) {
+ names++;
+ classes++;
+ if (!*names)
+ break;
+ if (!names[1]) {
+ get = (getNTableSProcp)AppendLEntry; /* bottom of recursion */
+ leaf = 1;
+ }
+ GLOOSE(*names, AppendLooseLEntry); /* loose names */
+ GLOOSE(*classes, AppendLooseLEntry); /* loose classes */
+ if (table->hasany) {
+ GLOOSE(XrmQANY, AppendLooseLEntry); /* loose ANY */
+ }
+ }
+ }
+ /* now look for matching leaf nodes */
+ entry = table->next;
+ if (!entry)
+ return False;
+ if (entry->leaf) {
+ if (entry->tight && !table->tight)
+ entry = entry->next;
+ } else {
+ entry = entry->next;
+ if (!entry || !entry->tight)
+ return False;
+ }
+ if (!entry || entry->name != table->name)
+ return False;
+ /* found one */
+ if (entry->hasloose &&
+ AppendLooseLEntry((LTable)entry, names, classes, closure))
+ return True;
+ if (entry->tight && entry == table->next && (entry = entry->next) &&
+ entry->name == table->name && entry->hasloose)
+ return AppendLooseLEntry((LTable)entry, names, classes, closure);
+ return False;
+}
+
+Bool XrmQGetSearchList(
+ XrmDatabase db,
+ XrmNameList names,
+ XrmClassList classes,
+ XrmSearchList searchList, /* RETURN */
+ int listLength)
+{
+ register NTable table;
+ SClosureRec closure;
+
+ if (listLength <= 0)
+ return False;
+ closure.list = (LTable *)searchList;
+ closure.idx = -1;
+ closure.limit = listLength - 2;
+ if (db) {
+ _XLockMutex(&db->linfo);
+ table = db->table;
+ if (*names) {
+ if (table && !table->leaf) {
+ if (SearchNEntry(table, names, classes, &closure)) {
+ _XUnlockMutex(&db->linfo);
+ return False;
+ }
+ } else if (table && table->hasloose &&
+ AppendLooseLEntry((LTable)table, names, classes,
+ &closure)) {
+ _XUnlockMutex(&db->linfo);
+ return False;
+ }
+ } else {
+ if (table && !table->leaf)
+ table = table->next;
+ if (table &&
+ AppendLEntry((LTable)table, names, classes, &closure)) {
+ _XUnlockMutex(&db->linfo);
+ return False;
+ }
+ }
+ _XUnlockMutex(&db->linfo);
+ }
+ closure.list[closure.idx + 1] = (LTable)NULL;
+ return True;
+}
+
+Bool XrmQGetSearchResource(
+ XrmSearchList searchList,
+ register XrmName name,
+ register XrmClass class,
+ XrmRepresentation *pType, /* RETURN */
+ XrmValue *pValue) /* RETURN */
+{
+ register LTable *list;
+ register LTable table;
+ register VEntry entry = NULL;
+ int flags;
+
+/* find tight or loose entry */
+#define VTIGHTLOOSE(q) \
+ entry = LeafHash(table, q); \
+ while (entry && entry->name != q) \
+ entry = entry->next; \
+ if (entry) \
+ break
+
+/* find loose entry */
+#define VLOOSE(q) \
+ entry = LeafHash(table, q); \
+ while (entry && entry->name != q) \
+ entry = entry->next; \
+ if (entry) { \
+ if (!entry->tight) \
+ break; \
+ if ((entry = entry->next) && entry->name == q) \
+ break; \
+ }
+
+ list = (LTable *)searchList;
+ /* figure out which combination of name and class we need to search for */
+ flags = 0;
+ if (IsResourceQuark(name))
+ flags = 2;
+ if (IsResourceQuark(class))
+ flags |= 1;
+ if (!flags) {
+ /* neither name nor class has ever been used to name a resource */
+ table = (LTable)NULL;
+ } else if (flags == 3) {
+ /* both name and class */
+ while ((table = *list++)) {
+ if (table != LOOSESEARCH) {
+ VTIGHTLOOSE(name); /* do name, tight and loose */
+ VTIGHTLOOSE(class); /* do class, tight and loose */
+ } else {
+ table = *list++;
+ VLOOSE(name); /* do name, loose only */
+ VLOOSE(class); /* do class, loose only */
+ }
+ }
+ } else {
+ /* just one of name or class */
+ if (flags == 1)
+ name = class;
+ while ((table = *list++)) {
+ if (table != LOOSESEARCH) {
+ VTIGHTLOOSE(name); /* tight and loose */
+ } else {
+ table = *list++;
+ VLOOSE(name); /* loose only */
+ }
+ }
+ }
+ if (table) {
+ /* found a match */
+ if (entry->string) {
+ *pType = XrmQString;
+ pValue->addr = StringValue(entry);
+ } else {
+ *pType = RepType(entry);
+ pValue->addr = DataValue(entry);
+ }
+ pValue->size = entry->size;
+ return True;
+ }
+ *pType = NULLQUARK;
+ pValue->addr = (XPointer)NULL;
+ pValue->size = 0;
+ return False;
+
+#undef VTIGHTLOOSE
+#undef VLOOSE
+}
+
+/* look for a tight/loose value */
+static Bool GetVEntry(
+ LTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ VClosure closure)
+{
+ register VEntry entry;
+ register XrmQuark q;
+
+ /* try name first */
+ q = *names;
+ entry = LeafHash(table, q);
+ while (entry && entry->name != q)
+ entry = entry->next;
+ if (!entry) {
+ /* not found, try class */
+ q = *classes;
+ entry = LeafHash(table, q);
+ while (entry && entry->name != q)
+ entry = entry->next;
+ if (!entry)
+ return False;
+ }
+ if (entry->string) {
+ *closure->type = XrmQString;
+ closure->value->addr = StringValue(entry);
+ } else {
+ *closure->type = RepType(entry);
+ closure->value->addr = DataValue(entry);
+ }
+ closure->value->size = entry->size;
+ return True;
+}
+
+/* look for a loose value */
+static Bool GetLooseVEntry(
+ LTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ VClosure closure)
+{
+ register VEntry entry;
+ register XrmQuark q;
+
+#define VLOOSE(ename) \
+ q = ename; \
+ entry = LeafHash(table, q); \
+ while (entry && entry->name != q) \
+ entry = entry->next; \
+ if (entry && entry->tight && (entry = entry->next) && entry->name != q) \
+ entry = (VEntry)NULL;
+
+ /* bump to last component */
+ while (names[1]) {
+ names++;
+ classes++;
+ }
+ VLOOSE(*names); /* do name, loose only */
+ if (!entry) {
+ VLOOSE(*classes); /* do class, loose only */
+ if (!entry)
+ return False;
+ }
+ if (entry->string) {
+ *closure->type = XrmQString;
+ closure->value->addr = StringValue(entry);
+ } else {
+ *closure->type = RepType(entry);
+ closure->value->addr = DataValue(entry);
+ }
+ closure->value->size = entry->size;
+ return True;
+
+#undef VLOOSE
+}
+
+/* recursive search for a value */
+static Bool GetNEntry(
+ NTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ VClosure closure)
+{
+ register NTable entry;
+ register XrmQuark q;
+ register unsigned int leaf;
+ Bool (*get)(
+ NTable table,
+ XrmNameList names,
+ XrmClassList classes,
+ VClosure closure);
+ NTable otable;
+
+ if (names[2]) {
+ get = GetNEntry; /* recurse */
+ leaf = 0;
+ } else {
+ get = (getNTableVProcp)GetVEntry; /* bottom of recursion */
+ leaf = 1;
+ }
+ GTIGHTLOOSE(*names, GetLooseVEntry); /* do name, tight and loose */
+ GTIGHTLOOSE(*classes, GetLooseVEntry); /* do class, tight and loose */
+ if (table->hasany) {
+ GTIGHTLOOSE(XrmQANY, GetLooseVEntry); /* do ANY, tight and loose */
+ }
+ if (table->hasloose) {
+ while (1) {
+ names++;
+ classes++;
+ if (!names[1])
+ break;
+ if (!names[2]) {
+ get = (getNTableVProcp)GetVEntry; /* bottom of recursion */
+ leaf = 1;
+ }
+ GLOOSE(*names, GetLooseVEntry); /* do name, loose only */
+ GLOOSE(*classes, GetLooseVEntry); /* do class, loose only */
+ if (table->hasany) {
+ GLOOSE(XrmQANY, GetLooseVEntry); /* do ANY, loose only */
+ }
+ }
+ }
+ /* look for matching leaf tables */
+ otable = table;
+ table = table->next;
+ if (!table)
+ return False;
+ if (table->leaf) {
+ if (table->tight && !otable->tight)
+ table = table->next;
+ } else {
+ table = table->next;
+ if (!table || !table->tight)
+ return False;
+ }
+ if (!table || table->name != otable->name)
+ return False;
+ /* found one */
+ if (table->hasloose &&
+ GetLooseVEntry((LTable)table, names, classes, closure))
+ return True;
+ if (table->tight && table == otable->next) {
+ table = table->next;
+ if (table && table->name == otable->name && table->hasloose)
+ return GetLooseVEntry((LTable)table, names, classes, closure);
+ }
+ return False;
+}
+
+Bool XrmQGetResource(
+ XrmDatabase db,
+ XrmNameList names,
+ XrmClassList classes,
+ XrmRepresentation *pType, /* RETURN */
+ XrmValuePtr pValue) /* RETURN */
+{
+ register NTable table;
+ VClosureRec closure;
+
+ if (db && *names) {
+ _XLockMutex(&db->linfo);
+ closure.type = pType;
+ closure.value = pValue;
+ table = db->table;
+ if (names[1]) {
+ if (table && !table->leaf) {
+ if (GetNEntry(table, names, classes, &closure)) {
+ _XUnlockMutex(&db->linfo);
+ return True;
+ }
+ } else if (table && table->hasloose &&
+ GetLooseVEntry((LTable)table, names, classes, &closure)) {
+ _XUnlockMutex (&db->linfo);
+ return True;
+ }
+ } else {
+ if (table && !table->leaf)
+ table = table->next;
+ if (table && GetVEntry((LTable)table, names, classes, &closure)) {
+ _XUnlockMutex(&db->linfo);
+ return True;
+ }
+ }
+ _XUnlockMutex(&db->linfo);
+ }
+ *pType = NULLQUARK;
+ pValue->addr = (XPointer)NULL;
+ pValue->size = 0;
+ return False;
+}
+
+Bool
+XrmGetResource(db, name_str, class_str, pType_str, pValue)
+ XrmDatabase db;
+ _Xconst char *name_str;
+ _Xconst char *class_str;
+ XrmString *pType_str; /* RETURN */
+ XrmValuePtr pValue; /* RETURN */
+{
+ XrmName names[MAXDBDEPTH+1];
+ XrmClass classes[MAXDBDEPTH+1];
+ XrmRepresentation fromType;
+ Bool result;
+
+ XrmStringToNameList(name_str, names);
+ XrmStringToClassList(class_str, classes);
+ result = XrmQGetResource(db, names, classes, &fromType, pValue);
+ (*pType_str) = XrmQuarkToString(fromType);
+ return result;
+}
+
+/* destroy all values, plus table itself */
+static void DestroyLTable(
+ LTable table)
+{
+ register int i;
+ register VEntry *buckets;
+ register VEntry entry, next;
+
+ buckets = table->buckets;
+ for (i = table->table.mask; i >= 0; i--, buckets++) {
+ for (next = *buckets; (entry = next); ) {
+ next = entry->next;
+ Xfree((char *)entry);
+ }
+ }
+ Xfree((char *)table->buckets);
+ Xfree((char *)table);
+}
+
+/* destroy all contained tables, plus table itself */
+static void DestroyNTable(
+ NTable table)
+{
+ register int i;
+ register NTable *buckets;
+ register NTable entry, next;
+
+ buckets = NodeBuckets(table);
+ for (i = table->mask; i >= 0; i--, buckets++) {
+ for (next = *buckets; (entry = next); ) {
+ next = entry->next;
+ if (entry->leaf)
+ DestroyLTable((LTable)entry);
+ else
+ DestroyNTable(entry);
+ }
+ }
+ Xfree((char *)table);
+}
+
+const char *
+XrmLocaleOfDatabase(
+ XrmDatabase db)
+{
+ const char* retval;
+ _XLockMutex(&db->linfo);
+ retval = (*db->methods->lcname)(db->mbstate);
+ _XUnlockMutex(&db->linfo);
+ return retval;
+}
+
+void XrmDestroyDatabase(
+ XrmDatabase db)
+{
+ register NTable table, next;
+
+ if (db) {
+ _XLockMutex(&db->linfo);
+ for (next = db->table; (table = next); ) {
+ next = table->next;
+ if (table->leaf)
+ DestroyLTable((LTable)table);
+ else
+ DestroyNTable(table);
+ }
+ _XFreeMutex(&db->linfo);
+ (*db->methods->destroy)(db->mbstate);
+ Xfree((char *)db);
+ }
+}
diff --git a/nx-X11/lib/X11/XrmI.h b/nx-X11/lib/X11/XrmI.h
new file mode 100644
index 000000000..949bcd6f3
--- /dev/null
+++ b/nx-X11/lib/X11/XrmI.h
@@ -0,0 +1,47 @@
+/* $Xorg: XrmI.h,v 1.4 2001/02/09 02:03:39 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.
+
+*/
+
+
+/*
+ * Macros to abstract out reading the file, and getting its size.
+ *
+ * You may need to redefine these for various other operating systems.
+ */
+
+#include <X11/Xos.h>
+#include <sys/stat.h>
+
+#define GetSizeOfFile(fd,size) \
+{ \
+ struct stat status_buffer; \
+ if ( (fstat((fd), &status_buffer)) == -1 ) \
+ size = -1; \
+ else \
+ size = status_buffer.st_size; \
+}
diff --git a/nx-X11/lib/X11/Xutil.h b/nx-X11/lib/X11/Xutil.h
new file mode 100644
index 000000000..82dab7d56
--- /dev/null
+++ b/nx-X11/lib/X11/Xutil.h
@@ -0,0 +1,827 @@
+/* $Xorg: Xutil.h,v 1.8 2001/02/09 02:03:39 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/Xutil.h,v 3.6 2003/04/13 19:22:20 dawes Exp $ */
+
+#ifndef _XUTIL_H_
+#define _XUTIL_H_
+
+/* You must include <X11/Xlib.h> before including this file */
+#include <X11/Xlib.h>
+
+/*
+ * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
+ * value (x, y, width, height) was found in the parsed string.
+ */
+#define NoValue 0x0000
+#define XValue 0x0001
+#define YValue 0x0002
+#define WidthValue 0x0004
+#define HeightValue 0x0008
+#define AllValues 0x000F
+#define XNegative 0x0010
+#define YNegative 0x0020
+
+/*
+ * new version containing base_width, base_height, and win_gravity fields;
+ * used with WM_NORMAL_HINTS.
+ */
+typedef struct {
+ long flags; /* marks which fields in this structure are defined */
+ int x, y; /* obsolete for new window mgrs, but clients */
+ int width, height; /* should set so old wm's don't mess up */
+ int min_width, min_height;
+ int max_width, max_height;
+ int width_inc, height_inc;
+ struct {
+ int x; /* numerator */
+ int y; /* denominator */
+ } min_aspect, max_aspect;
+ int base_width, base_height; /* added by ICCCM version 1 */
+ int win_gravity; /* added by ICCCM version 1 */
+} XSizeHints;
+
+/*
+ * The next block of definitions are for window manager properties that
+ * clients and applications use for communication.
+ */
+
+/* flags argument in size hints */
+#define USPosition (1L << 0) /* user specified x, y */
+#define USSize (1L << 1) /* user specified width, height */
+
+#define PPosition (1L << 2) /* program specified position */
+#define PSize (1L << 3) /* program specified size */
+#define PMinSize (1L << 4) /* program specified minimum size */
+#define PMaxSize (1L << 5) /* program specified maximum size */
+#define PResizeInc (1L << 6) /* program specified resize increments */
+#define PAspect (1L << 7) /* program specified min and max aspect ratios */
+#define PBaseSize (1L << 8) /* program specified base for incrementing */
+#define PWinGravity (1L << 9) /* program specified window gravity */
+
+/* obsolete */
+#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)
+
+
+
+typedef struct {
+ long flags; /* marks which fields in this structure are defined */
+ Bool input; /* does this application rely on the window manager to
+ get keyboard input? */
+ int initial_state; /* see below */
+ Pixmap icon_pixmap; /* pixmap to be used as icon */
+ Window icon_window; /* window to be used as icon */
+ int icon_x, icon_y; /* initial position of icon */
+ Pixmap icon_mask; /* icon mask bitmap */
+ XID window_group; /* id of related window group */
+ /* this structure may be extended in the future */
+} XWMHints;
+
+/* definition for flags of XWMHints */
+
+#define InputHint (1L << 0)
+#define StateHint (1L << 1)
+#define IconPixmapHint (1L << 2)
+#define IconWindowHint (1L << 3)
+#define IconPositionHint (1L << 4)
+#define IconMaskHint (1L << 5)
+#define WindowGroupHint (1L << 6)
+#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \
+IconPositionHint|IconMaskHint|WindowGroupHint)
+#define XUrgencyHint (1L << 8)
+
+/* definitions for initial window state */
+#define WithdrawnState 0 /* for windows that are not mapped */
+#define NormalState 1 /* most applications want to start this way */
+#define IconicState 3 /* application wants to start as an icon */
+
+/*
+ * Obsolete states no longer defined by ICCCM
+ */
+#define DontCareState 0 /* don't know or care */
+#define ZoomState 2 /* application wants to start zoomed */
+#define InactiveState 4 /* application believes it is seldom used; */
+ /* some wm's may put it on inactive menu */
+
+
+/*
+ * new structure for manipulating TEXT properties; used with WM_NAME,
+ * WM_ICON_NAME, WM_CLIENT_MACHINE, and WM_COMMAND.
+ */
+typedef struct {
+ unsigned char *value; /* same as Property routines */
+ Atom encoding; /* prop type */
+ int format; /* prop data format: 8, 16, or 32 */
+ unsigned long nitems; /* number of data items in value */
+} XTextProperty;
+
+#define XNoMemory -1
+#define XLocaleNotSupported -2
+#define XConverterNotFound -3
+
+typedef enum {
+ XStringStyle, /* STRING */
+ XCompoundTextStyle, /* COMPOUND_TEXT */
+ XTextStyle, /* text in owner's encoding (current locale)*/
+ XStdICCTextStyle, /* STRING, else COMPOUND_TEXT */
+ /* The following is an XFree86 extension, introduced in November 2000 */
+ XUTF8StringStyle /* UTF8_STRING */
+} XICCEncodingStyle;
+
+typedef struct {
+ int min_width, min_height;
+ int max_width, max_height;
+ int width_inc, height_inc;
+} XIconSize;
+
+typedef struct {
+ char *res_name;
+ char *res_class;
+} XClassHint;
+
+#ifdef XUTIL_DEFINE_FUNCTIONS
+extern int XDestroyImage(
+ XImage *ximage);
+extern unsigned long XGetPixel(
+ XImage *ximage,
+ int x, int y);
+extern int XPutPixel(
+ XImage *ximage,
+ int x, int y,
+ unsigned long pixel);
+extern XImage *XSubImage(
+ XImage *ximage,
+ int x, int y,
+ unsigned int width, unsigned int height);
+extern int XAddPixel(
+ XImage *ximage,
+ long value);
+#else
+/*
+ * These macros are used to give some sugar to the image routines so that
+ * naive people are more comfortable with them.
+ */
+#define XDestroyImage(ximage) \
+ ((*((ximage)->f.destroy_image))((ximage)))
+#define XGetPixel(ximage, x, y) \
+ ((*((ximage)->f.get_pixel))((ximage), (x), (y)))
+#define XPutPixel(ximage, x, y, pixel) \
+ ((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)))
+#define XSubImage(ximage, x, y, width, height) \
+ ((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height)))
+#define XAddPixel(ximage, value) \
+ ((*((ximage)->f.add_pixel))((ximage), (value)))
+#endif
+
+/*
+ * Compose sequence status structure, used in calling XLookupString.
+ */
+typedef struct _XComposeStatus {
+ XPointer compose_ptr; /* state table pointer */
+ int chars_matched; /* match state */
+} XComposeStatus;
+
+/*
+ * Keysym macros, used on Keysyms to test for classes of symbols
+ */
+#define IsKeypadKey(keysym) \
+ (((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal))
+
+#define IsPrivateKeypadKey(keysym) \
+ (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))
+
+#define IsCursorKey(keysym) \
+ (((KeySym)(keysym) >= XK_Home) && ((KeySym)(keysym) < XK_Select))
+
+#define IsPFKey(keysym) \
+ (((KeySym)(keysym) >= XK_KP_F1) && ((KeySym)(keysym) <= XK_KP_F4))
+
+#define IsFunctionKey(keysym) \
+ (((KeySym)(keysym) >= XK_F1) && ((KeySym)(keysym) <= XK_F35))
+
+#define IsMiscFunctionKey(keysym) \
+ (((KeySym)(keysym) >= XK_Select) && ((KeySym)(keysym) <= XK_Break))
+
+#ifdef XK_XKB_KEYS
+#define IsModifierKey(keysym) \
+ ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
+ || (((KeySym)(keysym) >= XK_ISO_Lock) && \
+ ((KeySym)(keysym) <= XK_ISO_Last_Group_Lock)) \
+ || ((KeySym)(keysym) == XK_Mode_switch) \
+ || ((KeySym)(keysym) == XK_Num_Lock))
+#else
+#define IsModifierKey(keysym) \
+ ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
+ || ((KeySym)(keysym) == XK_Mode_switch) \
+ || ((KeySym)(keysym) == XK_Num_Lock))
+#endif
+/*
+ * opaque reference to Region data type
+ */
+typedef struct _XRegion *Region;
+
+/* Return values from XRectInRegion() */
+
+#define RectangleOut 0
+#define RectangleIn 1
+#define RectanglePart 2
+
+
+/*
+ * Information used by the visual utility routines to find desired visual
+ * type from the many visuals a display may support.
+ */
+
+typedef struct {
+ Visual *visual;
+ VisualID visualid;
+ int screen;
+ int depth;
+#if defined(__cplusplus) || defined(c_plusplus)
+ int c_class; /* C++ */
+#else
+ int class;
+#endif
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ int colormap_size;
+ int bits_per_rgb;
+} XVisualInfo;
+
+#define VisualNoMask 0x0
+#define VisualIDMask 0x1
+#define VisualScreenMask 0x2
+#define VisualDepthMask 0x4
+#define VisualClassMask 0x8
+#define VisualRedMaskMask 0x10
+#define VisualGreenMaskMask 0x20
+#define VisualBlueMaskMask 0x40
+#define VisualColormapSizeMask 0x80
+#define VisualBitsPerRGBMask 0x100
+#define VisualAllMask 0x1FF
+
+/*
+ * This defines a window manager property that clients may use to
+ * share standard color maps of type RGB_COLOR_MAP:
+ */
+typedef struct {
+ Colormap colormap;
+ unsigned long red_max;
+ unsigned long red_mult;
+ unsigned long green_max;
+ unsigned long green_mult;
+ unsigned long blue_max;
+ unsigned long blue_mult;
+ unsigned long base_pixel;
+ VisualID visualid; /* added by ICCCM version 1 */
+ XID killid; /* added by ICCCM version 1 */
+} XStandardColormap;
+
+#define ReleaseByFreeingColormap ((XID) 1L) /* for killid field above */
+
+
+/*
+ * return codes for XReadBitmapFile and XWriteBitmapFile
+ */
+#define BitmapSuccess 0
+#define BitmapOpenFailed 1
+#define BitmapFileInvalid 2
+#define BitmapNoMemory 3
+
+/****************************************************************
+ *
+ * Context Management
+ *
+ ****************************************************************/
+
+
+/* Associative lookup table return codes */
+
+#define XCSUCCESS 0 /* No error. */
+#define XCNOMEM 1 /* Out of memory */
+#define XCNOENT 2 /* No entry in table */
+
+typedef int XContext;
+
+#define XUniqueContext() ((XContext) XrmUniqueQuark())
+#define XStringToContext(string) ((XContext) XrmStringToQuark(string))
+
+_XFUNCPROTOBEGIN
+
+/* The following declarations are alphabetized. */
+
+extern XClassHint *XAllocClassHint (
+ void
+);
+
+extern XIconSize *XAllocIconSize (
+ void
+);
+
+extern XSizeHints *XAllocSizeHints (
+ void
+);
+
+extern XStandardColormap *XAllocStandardColormap (
+ void
+);
+
+extern XWMHints *XAllocWMHints (
+ void
+);
+
+extern int XClipBox(
+ Region /* r */,
+ XRectangle* /* rect_return */
+);
+
+extern Region XCreateRegion(
+ void
+);
+
+extern const char *XDefaultString (void);
+
+extern int XDeleteContext(
+ Display* /* display */,
+ XID /* rid */,
+ XContext /* context */
+);
+
+extern int XDestroyRegion(
+ Region /* r */
+);
+
+extern int XEmptyRegion(
+ Region /* r */
+);
+
+extern int XEqualRegion(
+ Region /* r1 */,
+ Region /* r2 */
+);
+
+extern int XFindContext(
+ Display* /* display */,
+ XID /* rid */,
+ XContext /* context */,
+ XPointer* /* data_return */
+);
+
+extern Status XGetClassHint(
+ Display* /* display */,
+ Window /* w */,
+ XClassHint* /* class_hints_return */
+);
+
+extern Status XGetIconSizes(
+ Display* /* display */,
+ Window /* w */,
+ XIconSize** /* size_list_return */,
+ int* /* count_return */
+);
+
+extern Status XGetNormalHints(
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints_return */
+);
+
+extern Status XGetRGBColormaps(
+ Display* /* display */,
+ Window /* w */,
+ XStandardColormap** /* stdcmap_return */,
+ int* /* count_return */,
+ Atom /* property */
+);
+
+extern Status XGetSizeHints(
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints_return */,
+ Atom /* property */
+);
+
+extern Status XGetStandardColormap(
+ Display* /* display */,
+ Window /* w */,
+ XStandardColormap* /* colormap_return */,
+ Atom /* property */
+);
+
+extern Status XGetTextProperty(
+ Display* /* display */,
+ Window /* window */,
+ XTextProperty* /* text_prop_return */,
+ Atom /* property */
+);
+
+extern XVisualInfo *XGetVisualInfo(
+ Display* /* display */,
+ long /* vinfo_mask */,
+ XVisualInfo* /* vinfo_template */,
+ int* /* nitems_return */
+);
+
+extern Status XGetWMClientMachine(
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop_return */
+);
+
+extern XWMHints *XGetWMHints(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern Status XGetWMIconName(
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop_return */
+);
+
+extern Status XGetWMName(
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop_return */
+);
+
+extern Status XGetWMNormalHints(
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints_return */,
+ long* /* supplied_return */
+);
+
+extern Status XGetWMSizeHints(
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints_return */,
+ long* /* supplied_return */,
+ Atom /* property */
+);
+
+extern Status XGetZoomHints(
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* zhints_return */
+);
+
+extern int XIntersectRegion(
+ Region /* sra */,
+ Region /* srb */,
+ Region /* dr_return */
+);
+
+extern void XConvertCase(
+ KeySym /* sym */,
+ KeySym* /* lower */,
+ KeySym* /* upper */
+);
+
+extern int XLookupString(
+ XKeyEvent* /* event_struct */,
+ char* /* buffer_return */,
+ int /* bytes_buffer */,
+ KeySym* /* keysym_return */,
+ XComposeStatus* /* status_in_out */
+);
+
+extern Status XMatchVisualInfo(
+ Display* /* display */,
+ int /* screen */,
+ int /* depth */,
+ int /* class */,
+ XVisualInfo* /* vinfo_return */
+);
+
+extern int XOffsetRegion(
+ Region /* r */,
+ int /* dx */,
+ int /* dy */
+);
+
+extern Bool XPointInRegion(
+ Region /* r */,
+ int /* x */,
+ int /* y */
+);
+
+extern Region XPolygonRegion(
+ XPoint* /* points */,
+ int /* n */,
+ int /* fill_rule */
+);
+
+extern int XRectInRegion(
+ Region /* r */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XSaveContext(
+ Display* /* display */,
+ XID /* rid */,
+ XContext /* context */,
+ _Xconst char* /* data */
+);
+
+extern int XSetClassHint(
+ Display* /* display */,
+ Window /* w */,
+ XClassHint* /* class_hints */
+);
+
+extern int XSetIconSizes(
+ Display* /* display */,
+ Window /* w */,
+ XIconSize* /* size_list */,
+ int /* count */
+);
+
+extern int XSetNormalHints(
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints */
+);
+
+extern void XSetRGBColormaps(
+ Display* /* display */,
+ Window /* w */,
+ XStandardColormap* /* stdcmaps */,
+ int /* count */,
+ Atom /* property */
+);
+
+extern int XSetSizeHints(
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints */,
+ Atom /* property */
+);
+
+extern int XSetStandardProperties(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* window_name */,
+ _Xconst char* /* icon_name */,
+ Pixmap /* icon_pixmap */,
+ char** /* argv */,
+ int /* argc */,
+ XSizeHints* /* hints */
+);
+
+extern void XSetTextProperty(
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop */,
+ Atom /* property */
+);
+
+extern void XSetWMClientMachine(
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop */
+);
+
+extern int XSetWMHints(
+ Display* /* display */,
+ Window /* w */,
+ XWMHints* /* wm_hints */
+);
+
+extern void XSetWMIconName(
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop */
+);
+
+extern void XSetWMName(
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop */
+);
+
+extern void XSetWMNormalHints(
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints */
+);
+
+extern void XSetWMProperties(
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* window_name */,
+ XTextProperty* /* icon_name */,
+ char** /* argv */,
+ int /* argc */,
+ XSizeHints* /* normal_hints */,
+ XWMHints* /* wm_hints */,
+ XClassHint* /* class_hints */
+);
+
+extern void XmbSetWMProperties(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* window_name */,
+ _Xconst char* /* icon_name */,
+ char** /* argv */,
+ int /* argc */,
+ XSizeHints* /* normal_hints */,
+ XWMHints* /* wm_hints */,
+ XClassHint* /* class_hints */
+);
+
+extern void Xutf8SetWMProperties(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* window_name */,
+ _Xconst char* /* icon_name */,
+ char** /* argv */,
+ int /* argc */,
+ XSizeHints* /* normal_hints */,
+ XWMHints* /* wm_hints */,
+ XClassHint* /* class_hints */
+);
+
+extern void XSetWMSizeHints(
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints */,
+ Atom /* property */
+);
+
+extern int XSetRegion(
+ Display* /* display */,
+ GC /* gc */,
+ Region /* r */
+);
+
+extern void XSetStandardColormap(
+ Display* /* display */,
+ Window /* w */,
+ XStandardColormap* /* colormap */,
+ Atom /* property */
+);
+
+extern int XSetZoomHints(
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* zhints */
+);
+
+extern int XShrinkRegion(
+ Region /* r */,
+ int /* dx */,
+ int /* dy */
+);
+
+extern Status XStringListToTextProperty(
+ char** /* list */,
+ int /* count */,
+ XTextProperty* /* text_prop_return */
+);
+
+extern int XSubtractRegion(
+ Region /* sra */,
+ Region /* srb */,
+ Region /* dr_return */
+);
+
+extern int XmbTextListToTextProperty(
+ Display* display,
+ char** list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty* text_prop_return
+);
+
+extern int XwcTextListToTextProperty(
+ Display* display,
+ wchar_t** list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty* text_prop_return
+);
+
+extern int Xutf8TextListToTextProperty(
+ Display* display,
+ char** list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty* text_prop_return
+);
+
+extern void XwcFreeStringList(
+ wchar_t** list
+);
+
+extern Status XTextPropertyToStringList(
+ XTextProperty* /* text_prop */,
+ char*** /* list_return */,
+ int* /* count_return */
+);
+
+extern int XmbTextPropertyToTextList(
+ Display* display,
+ const XTextProperty* text_prop,
+ char*** list_return,
+ int* count_return
+);
+
+extern int XwcTextPropertyToTextList(
+ Display* display,
+ const XTextProperty* text_prop,
+ wchar_t*** list_return,
+ int* count_return
+);
+
+extern int Xutf8TextPropertyToTextList(
+ Display* display,
+ const XTextProperty* text_prop,
+ char*** list_return,
+ int* count_return
+);
+
+extern int XUnionRectWithRegion(
+ XRectangle* /* rectangle */,
+ Region /* src_region */,
+ Region /* dest_region_return */
+);
+
+extern int XUnionRegion(
+ Region /* sra */,
+ Region /* srb */,
+ Region /* dr_return */
+);
+
+extern int XWMGeometry(
+ Display* /* display */,
+ int /* screen_number */,
+ _Xconst char* /* user_geometry */,
+ _Xconst char* /* default_geometry */,
+ unsigned int /* border_width */,
+ XSizeHints* /* hints */,
+ int* /* x_return */,
+ int* /* y_return */,
+ int* /* width_return */,
+ int* /* height_return */,
+ int* /* gravity_return */
+);
+
+extern int XXorRegion(
+ Region /* sra */,
+ Region /* srb */,
+ Region /* dr_return */
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XUTIL_H_ */
diff --git a/nx-X11/lib/X11/cmsAllCol.c b/nx-X11/lib/X11/cmsAllCol.c
new file mode 100644
index 000000000..3aca57363
--- /dev/null
+++ b/nx-X11/lib/X11/cmsAllCol.c
@@ -0,0 +1,76 @@
+/* $Xorg: cmsAllCol.c,v 1.3 2000/08/17 19:45:08 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsAllCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsAllocColor
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/cmsAllCol.c,v 1.3 2001/01/17 19:41:50 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/*
+ * NAME
+ * XcmsAllocColor - Allocate Color
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsAllocColor(dpy, colormap, pXcmsColor_in_out, result_format)
+ Display *dpy;
+ Colormap colormap;
+ XcmsColor *pXcmsColor_in_out;
+ XcmsColorFormat result_format;
+/*
+ * DESCRIPTION
+ * Given a device-dependent or device-independent color
+ * specification, XcmsAllocColor will convert it to X RGB
+ * values then use it in a call to XAllocColor.
+ *
+ * RETURNS
+ * XcmsFailure if failed;
+ * XcmsSuccess if it succeeded without gamut compression;
+ * XcmsSuccessWithCompression if it succeeded with gamut
+ * compression;
+ *
+ * Also returns the pixel value of the color cell and a color
+ * specification of the color actually stored.
+ *
+ */
+{
+ return(_XcmsSetGetColor(XAllocColor, dpy, colormap, pXcmsColor_in_out,
+ result_format, (Bool *)NULL));
+}
diff --git a/nx-X11/lib/X11/cmsAllNCol.c b/nx-X11/lib/X11/cmsAllNCol.c
new file mode 100644
index 000000000..efee0f6b3
--- /dev/null
+++ b/nx-X11/lib/X11/cmsAllNCol.c
@@ -0,0 +1,201 @@
+/* $Xorg: cmsAllNCol.c,v 1.3 2000/08/17 19:45:09 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsAlNCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsAllocNamedColor
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/cmsAllNCol.c,v 1.4 2003/04/13 19:22:20 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/*
+ * NAME
+ * XcmsAllocNamedColor -
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsAllocNamedColor (
+ Display *dpy,
+ Colormap cmap,
+ _Xconst char *colorname,
+ XcmsColor *pColor_scrn_return,
+ XcmsColor *pColor_exact_return,
+ XcmsColorFormat result_format)
+/*
+ * DESCRIPTION
+ * Finds the color specification associated with the color
+ * name in the Device-Independent Color Name Database, then
+ * converts that color specification to an RGB format. This
+ * RGB value is then used in a call to XAllocColor to allocate
+ * a read-only color cell.
+ *
+ * RETURNS
+ * 0 if failed to parse string or find any entry in the database.
+ * 1 if succeeded in converting color name to XcmsColor.
+ * 2 if succeeded in converting color name to another color name.
+ *
+ */
+{
+ long nbytes;
+ xAllocNamedColorReply rep;
+ xAllocNamedColorReq *req;
+ XColor hard_def;
+ XColor exact_def;
+ Status retval1 = 1;
+ Status retval2 = XcmsSuccess;
+ XcmsColor tmpColor;
+ XColor XColor_in_out;
+ XcmsCCC ccc;
+
+ /*
+ * 0. Check for invalid arguments.
+ */
+ if (dpy == NULL || colorname[0] == '\0' || pColor_scrn_return == 0
+ || pColor_exact_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) == (XcmsCCC)NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * 1. Convert string to a XcmsColor using Xcms and i18n mechanism
+ */
+ if ((retval1 = _XcmsResolveColorString(ccc, &colorname,
+ &tmpColor, result_format)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ if (retval1 == _XCMS_NEWNAME) {
+ goto PassToServer;
+ }
+ memcpy((char *)pColor_exact_return, (char *)&tmpColor, sizeof(XcmsColor));
+
+ /*
+ * 2. Convert tmpColor to RGB
+ * Assume pColor_exact_return is now adjusted to Client White Point
+ */
+ if ((retval2 = XcmsConvertColors(ccc, &tmpColor,
+ 1, XcmsRGBFormat, (Bool *) NULL)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * 3. Convert to XColor and call XAllocColor
+ */
+ _XcmsRGB_to_XColor(&tmpColor, &XColor_in_out, 1);
+ if (XAllocColor(ccc->dpy, cmap, &XColor_in_out) == 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * 4. pColor_scrn_return
+ *
+ * Now convert to the target format.
+ * We can ignore the return value because we're already in a
+ * device-dependent format.
+ */
+ _XColor_to_XcmsRGB(ccc, &XColor_in_out, pColor_scrn_return, 1);
+ if (result_format != XcmsRGBFormat) {
+ if (result_format == XcmsUndefinedFormat) {
+ result_format = pColor_exact_return->format;
+ }
+ if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(retval1 > retval2 ? retval1 : retval2);
+
+PassToServer:
+ /*
+ * All previous methods failed, so lets pass it to the server
+ * for parsing.
+ */
+ dpy = ccc->dpy;
+ 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();
+
+ /*
+ * Now convert to the target format.
+ */
+ _XColor_to_XcmsRGB(ccc, &exact_def, pColor_exact_return, 1);
+ _XColor_to_XcmsRGB(ccc, &hard_def, pColor_scrn_return, 1);
+ if (result_format != XcmsRGBFormat
+ && result_format != XcmsUndefinedFormat) {
+ if (XcmsConvertColors(ccc, pColor_exact_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/cmsCmap.c b/nx-X11/lib/X11/cmsCmap.c
new file mode 100644
index 000000000..bc26638c1
--- /dev/null
+++ b/nx-X11/lib/X11/cmsCmap.c
@@ -0,0 +1,497 @@
+/* $Xorg: cmsCmap.c,v 1.3 2000/08/17 19:45:09 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsCmap.c - Client Colormap Management Routines
+ *
+ * DESCRIPTION
+ * Routines that store additional information about
+ * colormaps being used by the X Client.
+ *
+ *
+ */
+/* $XFree86$ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Xutil.h"
+#include "Cmap.h"
+#include "Cv.h"
+
+/*
+ * FORWARD DECLARATIONS
+ */
+static void _XcmsFreeClientCmaps(Display *dpy);
+
+
+/************************************************************************
+ * *
+ * PRIVATE INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CmapRecForColormap
+ *
+ * SYNOPSIS
+ */
+static XcmsCmapRec *
+CmapRecForColormap(
+ Display *dpy,
+ Colormap cmap)
+/*
+ * DESCRIPTION
+ * Find the corresponding XcmsCmapRec for cmap. In not found
+ * this routines attempts to create one.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the corresponding XcmsCmapRec.
+ *
+ */
+{
+ XcmsCmapRec *pRec;
+ int nScrn;
+ int i, j;
+ XVisualInfo visualTemplate; /* Template of the visual we want */
+ XVisualInfo *visualList; /* List for visuals that match */
+ int nVisualsMatched; /* Number of visuals that match */
+ Window tmpWindow;
+ Visual *vp;
+ unsigned long border = 0;
+ _XAsyncHandler async;
+ _XAsyncErrorState async_state;
+
+ for (pRec = (XcmsCmapRec *)dpy->cms.clientCmaps; pRec != NULL;
+ pRec = pRec->pNext) {
+ if (pRec->cmapID == cmap) {
+ return(pRec);
+ }
+ }
+
+ /*
+ * Can't find an XcmsCmapRec associated with cmap in our records.
+ * Let's try to see if its a default colormap
+ */
+ nScrn = ScreenCount(dpy);
+ for (i = 0; i < nScrn; i++) {
+ if (cmap == DefaultColormap(dpy, i)) {
+ /* It is ... lets go ahead and store that info */
+ if ((pRec = _XcmsAddCmapRec(dpy, cmap, RootWindow(dpy, i),
+ DefaultVisual(dpy, i))) == NULL) {
+ return((XcmsCmapRec *)NULL);
+ }
+ pRec->ccc = XcmsCreateCCC(
+ dpy,
+ i, /* screenNumber */
+ DefaultVisual(dpy, i),
+ (XcmsColor *)NULL, /* clientWhitePt */
+ (XcmsCompressionProc)NULL, /* gamutCompProc */
+ (XPointer)NULL, /* gamutCompClientData */
+ (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
+ (XPointer)NULL /* whitePtAdjClientData */
+ );
+ return(pRec);
+ }
+ }
+
+ /*
+ * Nope, its not a default colormap, so it's probably a foreign color map
+ * of which we have no specific details. Let's go through the
+ * rigorous process of finding this colormap:
+ * for each screen
+ * for each screen's visual types
+ * create a window with cmap specified as the colormap
+ * if successful
+ * Add a CmapRec
+ * Create an XcmsCCC
+ * return the CmapRec
+ * else
+ * continue
+ */
+
+ async_state.error_code = 0; /* don't care */
+ async_state.major_opcode = X_CreateWindow;
+ async_state.minor_opcode = 0;
+ for (i = 0; i < nScrn; i++) {
+ visualTemplate.screen = i;
+ visualList = XGetVisualInfo(dpy, VisualScreenMask, &visualTemplate,
+ &nVisualsMatched);
+ if (nVisualsMatched == 0) {
+ continue;
+ }
+
+ /*
+ * Attempt to create a window with cmap
+ */
+ j = 0;
+ do {
+ vp = (visualList+j)->visual;
+ LockDisplay(dpy);
+ {
+ register xCreateWindowReq *req;
+
+ GetReq(CreateWindow, req);
+ async_state.min_sequence_number = dpy->request;
+ async_state.max_sequence_number = dpy->request;
+ async_state.error_count = 0;
+ async.next = dpy->async_handlers;
+ async.handler = _XAsyncErrorHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+ req->parent = RootWindow(dpy, i);
+ req->x = 0;
+ req->y = 0;
+ req->width = 1;
+ req->height = 1;
+ req->borderWidth = 0;
+ req->depth = (visualList+j)->depth;
+ req->class = CopyFromParent;
+ req->visual = vp->visualid;
+ tmpWindow = req->wid = XAllocID(dpy);
+ req->mask = CWBorderPixel | CWColormap;
+ req->length += 2;
+ Data32 (dpy, (long *) &border, 4);
+ Data32 (dpy, (long *) &cmap, 4);
+ }
+ {
+ xGetInputFocusReply rep;
+ register xReq *req;
+
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ }
+ DeqAsyncHandler(dpy, &async);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ } while (async_state.error_count > 0 && ++j < nVisualsMatched);
+
+ Xfree((char *)visualList);
+
+ /*
+ * if successful
+ */
+ if (j < nVisualsMatched) {
+ if ((pRec = _XcmsAddCmapRec(dpy, cmap, tmpWindow, vp)) == NULL)
+ return((XcmsCmapRec *)NULL);
+ pRec->ccc = XcmsCreateCCC(
+ dpy,
+ i, /* screenNumber */
+ vp,
+ (XcmsColor *)NULL, /* clientWhitePt */
+ (XcmsCompressionProc)NULL, /* gamutCompProc */
+ (XPointer)NULL, /* gamutCompClientData */
+ (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
+ (XPointer)NULL /* whitePtAdjClientData */
+ );
+ XDestroyWindow(dpy, tmpWindow);
+ return(pRec);
+ }
+ }
+
+ return(NULL);
+}
+
+
+
+/************************************************************************
+ * *
+ * API PRIVATE INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsAddCmapRec
+ *
+ * SYNOPSIS
+ */
+XcmsCmapRec *
+_XcmsAddCmapRec(dpy, cmap, windowID, visual)
+ Display *dpy;
+ Colormap cmap;
+ Window windowID;
+ Visual *visual;
+/*
+ * DESCRIPTION
+ * Create an XcmsCmapRec for the specified cmap, windowID,
+ * and visual, then adds it to its list of CmapRec's.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the added XcmsCmapRec.
+ *
+ */
+{
+ XcmsCmapRec *pNew;
+
+ if ((pNew = (XcmsCmapRec *) Xcalloc(1, (unsigned) sizeof(XcmsCmapRec)))
+ == NULL) {
+ return((XcmsCmapRec *)NULL);
+ }
+
+ pNew->cmapID = cmap;
+ pNew->dpy = dpy;
+ pNew->windowID = windowID;
+ pNew->visual = visual;
+ pNew->pNext = (XcmsCmapRec *)dpy->cms.clientCmaps;
+ dpy->cms.clientCmaps = (XPointer)pNew;
+ dpy->free_funcs->clientCmaps = _XcmsFreeClientCmaps;
+
+ /*
+ * Note, we don't create the XcmsCCC for pNew->ccc here because
+ * it may require the use of XGetWindowAttributes (a round trip request)
+ * to determine the screen.
+ */
+ return(pNew);
+}
+
+
+/*
+ * NAME
+ * _XcmsCopyCmapRecAndFree
+ *
+ * SYNOPSIS
+ */
+XcmsCmapRec *
+_XcmsCopyCmapRecAndFree(
+ Display *dpy,
+ Colormap src_cmap,
+ Colormap copy_cmap)
+/*
+ * DESCRIPTION
+ * Augments Xlib's XCopyColormapAndFree() to copy
+ * XcmsCmapRecs.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the copy XcmsCmapRec.
+ *
+ */
+{
+ XcmsCmapRec *pRec_src;
+ XcmsCmapRec *pRec_copy;
+
+ if ((pRec_src = CmapRecForColormap(dpy, src_cmap)) != NULL) {
+ pRec_copy =_XcmsAddCmapRec(dpy, copy_cmap, pRec_src->windowID,
+ pRec_src->visual);
+ if (pRec_copy != NULL && pRec_src->ccc) {
+ pRec_copy->ccc = (XcmsCCC)Xcalloc(1, (unsigned) sizeof(XcmsCCCRec));
+ memcpy((char *)pRec_copy->ccc, (char *)pRec_src->ccc,
+ sizeof(XcmsCCCRec));
+ }
+ return(pRec_copy);
+ }
+ return((XcmsCmapRec *)NULL);
+}
+
+
+/*
+ * NAME
+ * _XcmsDeleteCmapRec
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsDeleteCmapRec(
+ Display *dpy,
+ Colormap cmap)
+/*
+ * DESCRIPTION
+ * Removes and frees the specified XcmsCmapRec structure
+ * from the linked list of structures.
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ XcmsCmapRec **pPrevPtr;
+ XcmsCmapRec *pRec;
+ int scr;
+
+ /* If it is the default cmap for a screen, do not delete it,
+ * because the server will not actually free it */
+ for (scr = ScreenCount(dpy); --scr >= 0; ) {
+ if (cmap == DefaultColormap(dpy, scr))
+ return;
+ }
+
+ /* search for it in the list */
+ pPrevPtr = (XcmsCmapRec **)&dpy->cms.clientCmaps;
+ while ((pRec = *pPrevPtr) && (pRec->cmapID != cmap)) {
+ pPrevPtr = &pRec->pNext;
+ }
+
+ if (pRec) {
+ if (pRec->ccc) {
+ XcmsFreeCCC(pRec->ccc);
+ }
+ *pPrevPtr = pRec->pNext;
+ Xfree((char *)pRec);
+ }
+}
+
+
+/*
+ * NAME
+ * _XcmsFreeClientCmaps
+ *
+ * SYNOPSIS
+ */
+static void
+_XcmsFreeClientCmaps(
+ Display *dpy)
+/*
+ * DESCRIPTION
+ * Frees all XcmsCmapRec structures in the linked list
+ * and sets dpy->cms.clientCmaps to NULL.
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ XcmsCmapRec *pRecNext, *pRecFree;
+
+ pRecNext = (XcmsCmapRec *)dpy->cms.clientCmaps;
+ while (pRecNext != NULL) {
+ pRecFree = pRecNext;
+ pRecNext = pRecNext->pNext;
+ if (pRecFree->ccc) {
+ /* Free the XcmsCCC structure */
+ XcmsFreeCCC(pRecFree->ccc);
+ }
+ /* Now free the XcmsCmapRec structure */
+ Xfree((char *)pRecFree);
+ }
+ dpy->cms.clientCmaps = (XPointer)NULL;
+}
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCCCOfColormap
+ *
+ * SYNOPSIS
+ */
+XcmsCCC
+XcmsCCCOfColormap(dpy, cmap)
+ Display *dpy;
+ Colormap cmap;
+/*
+ * DESCRIPTION
+ * Finds the XcmsCCC associated with the specified colormap.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the associated XcmsCCC structure.
+ *
+ */
+{
+ XWindowAttributes windowAttr;
+ XcmsCmapRec *pRec;
+ int nScrn = ScreenCount(dpy);
+ int i;
+
+ if ((pRec = CmapRecForColormap(dpy, cmap)) != NULL) {
+ if (pRec->ccc) {
+ /* XcmsCmapRec already has a XcmsCCC */
+ return(pRec->ccc);
+ }
+
+ /*
+ * The XcmsCmapRec does not have a XcmsCCC yet, so let's create
+ * one. But first, we need to know the screen associated with
+ * cmap, so use XGetWindowAttributes() to extract that
+ * information. Unless, of course there is only one screen!!
+ */
+ if (nScrn == 1) {
+ /* Assume screenNumber == 0 */
+ return(pRec->ccc = XcmsCreateCCC(
+ dpy,
+ 0, /* screenNumber */
+ pRec->visual,
+ (XcmsColor *)NULL, /* clientWhitePt */
+ (XcmsCompressionProc)NULL, /* gamutCompProc */
+ (XPointer)NULL, /* gamutCompClientData */
+ (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
+ (XPointer)NULL /* whitePtAdjClientData */
+ ));
+ } else {
+ if (XGetWindowAttributes(dpy, pRec->windowID, &windowAttr)) {
+ for (i = 0; i < nScrn; i++) {
+ if (ScreenOfDisplay(dpy, i) == windowAttr.screen) {
+ return(pRec->ccc = XcmsCreateCCC(
+ dpy,
+ i, /* screenNumber */
+ pRec->visual,
+ (XcmsColor *)NULL, /* clientWhitePt */
+ (XcmsCompressionProc)NULL, /* gamutCompProc */
+ (XPointer)NULL, /* gamutCompClientData */
+ (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
+ (XPointer)NULL /* whitePtAdjClientData */
+ ));
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * No such cmap
+ */
+ return(NULL);
+}
+
+XcmsCCC XcmsSetCCCOfColormap(dpy, cmap, ccc)
+ Display *dpy;
+ Colormap cmap;
+ XcmsCCC ccc;
+{
+ XcmsCCC prev_ccc = NULL;
+ XcmsCmapRec *pRec;
+
+ pRec = CmapRecForColormap(dpy, cmap);
+ if (pRec) {
+ prev_ccc = pRec->ccc;
+ pRec->ccc = ccc;
+ }
+ return prev_ccc;
+}
diff --git a/nx-X11/lib/X11/cmsColNm.c b/nx-X11/lib/X11/cmsColNm.c
new file mode 100644
index 000000000..d8c24cdff
--- /dev/null
+++ b/nx-X11/lib/X11/cmsColNm.c
@@ -0,0 +1,1034 @@
+/* $XdotOrg: xc/lib/X11/cmsColNm.c,v 1.4 2005/07/03 07:00:55 daniels Exp $ */
+/* $Xorg: cmsColNm.c,v 1.3 2000/08/17 19:45:09 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * XcmsColNm.c
+ *
+ * DESCRIPTION
+ * Source for _XcmsLookupColorName().
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/cmsColNm.c,v 3.11 2003/04/13 19:22:20 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <X11/Xos.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <ctype.h>
+#define XK_LATIN1
+#include <X11/keysymdef.h>
+#include "Cv.h"
+
+/* forwards/locals */
+static Status LoadColornameDB(void);
+
+
+/*
+ * LOCAL DEFINES
+ * #define declarations local to this package.
+ */
+#ifndef XCMSDB
+#define XCMSDB "/usr/lib/X11/Xcms.txt"
+#endif
+
+#ifndef isgraph
+# define isgraph(c) (isprint((c)) && !isspace((c)))
+#endif
+
+#ifndef XCMSDB_MAXLINELEN
+# define XCMSDB_MAXLINELEN 256
+#endif
+
+#define FORMAT_VERSION "0.1"
+#define START_TOKEN "XCMS_COLORDB_START"
+#define END_TOKEN "XCMS_COLORDB_END"
+#define DELIM_CHAR '\t'
+
+#define NOT_VISITED 0x0
+#define VISITED 0x1
+#define CYCLE 0xFFFF
+#define XcmsDbInitNone -1
+#define XcmsDbInitFailure 0
+#define XcmsDbInitSuccess 1
+
+/*
+ * LOCAL TYPEDEFS
+ */
+typedef struct _XcmsPair {
+ const char *first;
+ const char *second;
+ int flag;
+} XcmsPair;
+
+/*
+ * LOCAL VARIABLES
+ */
+static int XcmsColorDbState = XcmsDbInitNone;
+static int nEntries;
+static char *strings;
+static XcmsPair *pairs;
+static const char whitePtStr[] = "WhitePoint";
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsColorSpaceOfString
+ *
+ * SYNOPSIS
+ */
+static XcmsColorSpace *
+_XcmsColorSpaceOfString(
+ XcmsCCC ccc,
+ const char *color_string)
+/*
+ * DESCRIPTION
+ * Returns a pointer to the color space structure
+ * (XcmsColorSpace) associated with the specified color string.
+ *
+ * RETURNS
+ * Pointer to matching XcmsColorSpace structure if found;
+ * otherwise NULL.
+ *
+ * CAVEATS
+ *
+ */
+{
+ XcmsColorSpace **papColorSpaces;
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(color_string, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - color_string);
+
+ if (ccc == NULL) {
+ return(NULL);
+ }
+
+ /*
+ * First try Device-Independent color spaces
+ */
+ papColorSpaces = _XcmsDIColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if (strncmp((*papColorSpaces)->prefix, color_string, n) == 0 &&
+ !((*papColorSpaces)->prefix)[n]) {
+ return(*papColorSpaces);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ /*
+ * Next try Device-Dependent color spaces
+ */
+ papColorSpaces = ((XcmsFunctionSet *)ccc->pPerScrnInfo->functionSet)->DDColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if (strncmp((*papColorSpaces)->prefix, color_string, n) == 0 &&
+ !((*papColorSpaces)->prefix)[n]) {
+ return(*papColorSpaces);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ return(NULL);
+}
+
+
+/*
+ * NAME
+ * _XcmsParseColorString
+ *
+ * SYNOPSIS
+ */
+static int
+_XcmsParseColorString(
+ XcmsCCC ccc,
+ const char *color_string,
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * Assuming color_string contains a numerical string color
+ * specification, attempts to parse a string into an
+ * XcmsColor structure.
+ *
+ * RETURNS
+ * 0 if failed; otherwise non-zero.
+ *
+ * CAVEATS
+ * A color string containing a numerical color specification
+ * must be in ISO Latin-1 encoding!
+ */
+{
+ XcmsColorSpace *pColorSpace;
+ char string_buf[64];
+ char *string_lowered;
+ int len;
+ int res;
+
+ if (ccc == NULL) {
+ return(0);
+ }
+
+ /*
+ * While copying color_string to string_lowered, convert to lowercase
+ */
+ if ((len = strlen(color_string)) >= sizeof(string_buf)) {
+ string_lowered = (char *) Xmalloc(len+1);
+ } else {
+ string_lowered = string_buf;
+ }
+
+ _XcmsCopyISOLatin1Lowered(string_lowered, color_string);
+
+ if (*string_lowered == '#') {
+ if ((pColorSpace = _XcmsColorSpaceOfString(ccc, "rgb:")) != NULL) {
+ res = (*pColorSpace->parseString)(string_lowered, pColor);
+ if (len >= sizeof(string_buf)) Xfree(string_lowered);
+ return res;
+ }
+ }
+
+ if ((pColorSpace = _XcmsColorSpaceOfString(ccc, string_lowered)) != NULL) {
+ res = (*pColorSpace->parseString)(string_lowered, pColor);
+ if (len >= sizeof(string_buf)) Xfree(string_lowered);
+ return res;
+ }
+
+ if (len >= sizeof(string_buf)) Xfree(string_lowered);
+ return(0);
+}
+
+
+/*
+ * NAME
+ * FirstCmp - Compare color names of pair recs
+ *
+ * SYNOPSIS
+ */
+static int
+FirstCmp(const void *p1, const void *p2)
+/*
+ * DESCRIPTION
+ * Compares the color names of XcmsColorTuples.
+ * This routine is public to allow access from qsort???.
+ *
+ * RETURNS
+ * 0 if equal;
+ * < 0 if first precedes second,
+ * > 0 if first succeeds second.
+ *
+ */
+{
+ return(strcmp(((XcmsPair *)p1)->first, ((XcmsPair *)p2)->first));
+}
+
+
+
+/*
+ * NAME
+ * stringSectionSize - determine memory needed for strings
+ *
+ * SYNOPSIS
+ */
+static void
+SetNoVisit(void)
+/*
+ * DESCRIPTION
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ int i;
+ XcmsPair *pair = pairs;
+
+ for (i = 0; i < nEntries; i++, pair++) {
+ if (pair->flag != CYCLE) {
+ pair->flag = NOT_VISITED;
+ }
+ }
+}
+
+
+
+
+/*
+ * NAME
+ * field2 - extract two fields
+ *
+ * SYNOPSIS
+ */
+static int
+field2(
+ char *pBuf,
+ char delim, /* in: field delimiter */
+ char **p1, /* in/out: pointer to pointer to field 1 */
+ char **p2) /* in/out: pointer to pointer to field 2 */
+/*
+ * DESCRIPTION
+ * Extracts two fields from a "record".
+ *
+ * RETURNS
+ * XcmsSuccess if succeeded, otherwise XcmsFailure.
+ *
+ */
+{
+ *p1 = *p2 = NULL;
+
+ /* Find Field 1 */
+ while (!isgraph(*pBuf)) {
+ if ((*pBuf != '\n') || (*pBuf != '\0')) {
+ return(XcmsFailure);
+ }
+ if (isspace(*pBuf) || (*pBuf == delim)) {
+ pBuf++;
+ }
+ }
+ *p1 = pBuf;
+
+ /* Find end of Field 2 */
+ while (isprint(*pBuf) && (*pBuf != delim)) {
+ pBuf++;
+ }
+ if ((*pBuf == '\n') || (*pBuf == '\0')) {
+ return(XcmsFailure);
+ }
+ if ((*pBuf == ' ') || (*pBuf == delim)) {
+ *pBuf++ = '\0'; /* stuff end of string character */
+ } else {
+ return(XcmsFailure);
+ }
+
+ /* Find Field 2 */
+ while (!isgraph(*pBuf)) {
+ if ((*pBuf == '\n') || (*pBuf == '\0')) {
+ return(XcmsFailure);
+ }
+ if (isspace(*pBuf) || (*pBuf == delim)) {
+ pBuf++;
+ }
+ }
+ *p2 = pBuf;
+
+ /* Find end of Field 2 */
+ while (isprint(*pBuf) && (*pBuf != delim)) {
+ pBuf++;
+ }
+ if (*pBuf != '\0') {
+ *pBuf = '\0'; /* stuff end of string character */
+ }
+
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * _XcmsLookupColorName - Lookup DB entry for a color name
+ *
+ * SYNOPSIS
+ */
+static Status
+_XcmsLookupColorName(
+ XcmsCCC ccc,
+ const char **name,
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * Searches for an entry in the Device-Independent Color Name
+ * Database for the specified string.
+ *
+ * RETURNS
+ * XcmsFailure if failed to find a matching entry in
+ * the database.
+ * XcmsSuccess if succeeded in converting color name to
+ * XcmsColor.
+ * _XCMS_NEWNAME if succeeded in converting color string (which
+ * is a color name to yet another color name. Note
+ * that the new name is passed back via 'name'.
+ */
+ {
+ Status retval = 0;
+ char name_lowered_64[64];
+ char *name_lowered;
+ register int i, j, left, right;
+ int len;
+ const char *tmpName;
+ XcmsPair *pair = NULL;
+
+ /*
+ * Check state of Database:
+ * XcmsDbInitNone
+ * XcmsDbInitSuccess
+ * XcmsDbInitFailure
+ */
+ if (XcmsColorDbState == XcmsDbInitFailure) {
+ return(XcmsFailure);
+ }
+ if (XcmsColorDbState == XcmsDbInitNone) {
+ if (!LoadColornameDB()) {
+ return(XcmsFailure);
+ }
+ }
+
+ SetNoVisit();
+
+ /*
+ * While copying name to name_lowered, convert to lowercase
+ */
+
+ tmpName = *name;
+
+Retry:
+ if ((len = strlen(tmpName)) > 63) {
+ name_lowered = (char *) Xmalloc(len+1);
+ } else {
+ name_lowered = name_lowered_64;
+ }
+
+ _XcmsCopyISOLatin1Lowered(name_lowered, tmpName);
+
+ /*
+ * Now, remove spaces.
+ */
+ for (i = 0, j = 0; j < len; j++) {
+ if (!isspace(name_lowered[j])) {
+ name_lowered[i++] = name_lowered[j];
+ }
+ }
+ name_lowered[i] = '\0';
+
+ left = 0;
+ right = nEntries - 1;
+ while (left <= right) {
+ i = (left + right) >> 1;
+ pair = &pairs[i];
+ j = strcmp(name_lowered, pair->first);
+ if (j < 0)
+ right = i - 1;
+ else if (j > 0)
+ left = i + 1;
+ else {
+ break;
+ }
+ }
+ if (len > 63) Xfree(name_lowered);
+
+ if (left > right) {
+ if (retval == 2) {
+ if (*name != tmpName) {
+ *name = tmpName;
+ }
+ return(_XCMS_NEWNAME);
+ }
+ return(XcmsFailure);
+ }
+
+ if (pair->flag == CYCLE) {
+ return(XcmsFailure);
+ }
+ if (pair->flag == VISITED) {
+ pair->flag = CYCLE;
+ return(XcmsFailure);
+ }
+
+ if (_XcmsParseColorString(ccc, pair->second, pColor) == XcmsSuccess) {
+ /* f2 contains a numerical string specification */
+ return(XcmsSuccess);
+ } else {
+ /* f2 does not contain a numerical string specification */
+ tmpName = pair->second;
+ pair->flag = VISITED;
+ retval = 2;
+ goto Retry;
+ }
+}
+
+
+/*
+ * NAME
+ * RemoveSpaces
+ *
+ * SYNOPSIS
+ */
+static int
+RemoveSpaces(
+ char *pString)
+/*
+ * DESCRIPTION
+ * Removes spaces from string.
+ *
+ * RETURNS
+ * Void
+ *
+ */
+{
+ int i, count = 0;
+ char *cptr;
+
+ /* REMOVE SPACES */
+ cptr = pString;
+ for (i = strlen(pString); i; i--, cptr++) {
+ if (!isspace(*cptr)) {
+ *pString++ = *cptr;
+ count++;
+ }
+ }
+ *pString = '\0';
+ return(count);
+}
+
+
+/*
+ * NAME
+ * stringSectionSize - determine memory needed for strings
+ *
+ * SYNOPSIS
+ */
+static int
+stringSectionSize(
+ FILE *stream,
+ int *pNumEntries,
+ int *pSectionSize)
+/*
+ * DESCRIPTION
+ * Determines the amount of memory required to store the
+ * color name strings and also the number of strings.
+ *
+ * RETURNS
+ * XcmsSuccess if succeeded, otherwise XcmsFailure.
+ *
+ */
+{
+ char buf[XCMSDB_MAXLINELEN];
+ char token[XCMSDB_MAXLINELEN];
+ char token2[XCMSDB_MAXLINELEN];
+ char *pBuf;
+ char *f1;
+ char *f2;
+ int i;
+
+ *pNumEntries = 0;
+ *pSectionSize = 0;
+
+ /*
+ * Advance to START_TOKEN
+ * Anything before is just considered as comments.
+ */
+
+ while((pBuf = fgets(buf, XCMSDB_MAXLINELEN, stream)) != NULL) {
+ if ((sscanf(buf, "%s %s", token, token2))
+ && (strcmp(token, START_TOKEN) == 0)) {
+ if (strcmp(token2, FORMAT_VERSION) != 0) {
+ /* text file not in the right format */
+ return(XcmsFailure);
+ }
+ break;
+ } /* else it was just a blank line or comment */
+ }
+
+ if (pBuf == NULL) {
+ return(XcmsFailure);
+ }
+
+ while((pBuf = fgets(buf, XCMSDB_MAXLINELEN, stream)) != NULL) {
+ if ((sscanf(buf, "%s", token)) && (strcmp(token, END_TOKEN) == 0)) {
+ break;
+ }
+
+ if (field2(buf, DELIM_CHAR, &f1, &f2) != XcmsSuccess) {
+ return(XcmsFailure);
+ }
+
+ (*pNumEntries)++;
+
+ (*pSectionSize) += (i = strlen(f1)) + 1;
+ for (; i; i--, f1++) {
+ /* REMOVE SPACES FROM COUNT */
+ if (isspace(*f1)) {
+ (*pSectionSize)--;
+ }
+ }
+
+ (*pSectionSize) += (i = strlen(f2)) + 1;
+ for (; i; i--, f2++) {
+ /* REMOVE SPACES FROM COUNT */
+ if (isspace(*f2)) {
+ (*pSectionSize)--;
+ }
+ }
+
+ }
+
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * ReadColornameDB - Read the Color Name Database
+ *
+ * SYNOPSIS
+ */
+static Status
+ReadColornameDB(
+ FILE *stream,
+ XcmsPair *pRec,
+ char *pString)
+/*
+ * DESCRIPTION
+ * Loads the Color Name Database from a text file.
+ *
+ * RETURNS
+ * XcmsSuccess if succeeded, otherwise XcmsFailure.
+ *
+ */
+{
+ char buf[XCMSDB_MAXLINELEN];
+ char token[XCMSDB_MAXLINELEN];
+ char token2[XCMSDB_MAXLINELEN];
+ char *f1;
+ char *f2;
+ char *pBuf;
+
+ /*
+ * Advance to START_TOKEN
+ * Anything before is just considered as comments.
+ */
+
+ while((pBuf = fgets(buf, XCMSDB_MAXLINELEN, stream)) != NULL) {
+ if ((sscanf(buf, "%s %s", token, token2))
+ && (strcmp(token, START_TOKEN) == 0)) {
+ if (strcmp(token2, FORMAT_VERSION) != 0) {
+ /* text file not in the right format */
+ return(XcmsFailure);
+ }
+ break;
+ } /* else it was just a blank line or comment */
+ }
+
+ if (pBuf == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Process lines between START_TOKEN to END_TOKEN
+ */
+
+ while ((pBuf = fgets(buf, XCMSDB_MAXLINELEN, stream)) != NULL) {
+ if ((sscanf(buf, "%s", token)) && (strcmp(token, END_TOKEN) == 0)) {
+ /*
+ * Found END_TOKEN so break out of for loop
+ */
+ break;
+ }
+
+ /*
+ * Get pairs
+ */
+ if (field2(buf, DELIM_CHAR, &f1, &f2) != XcmsSuccess) {
+ /* Invalid line */
+ continue;
+ }
+
+ /*
+ * Add strings
+ */
+
+ /* Left String */
+ pRec->first = pString;
+ _XcmsCopyISOLatin1Lowered(pString, f1);
+ pString += (1 + RemoveSpaces(pString));
+ pRec->second = pString;
+ /* Right String */
+ _XcmsCopyISOLatin1Lowered(pString, f2);
+ pString += RemoveSpaces(pString) + 1;
+ pRec++;
+
+ }
+
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * LoadColornameDB - Load the Color Name Database
+ *
+ * SYNOPSIS
+ */
+static Status
+LoadColornameDB(void)
+/*
+ * DESCRIPTION
+ * Loads the Color Name Database from a text file.
+ *
+ * RETURNS
+ * XcmsSuccess if succeeded, otherwise XcmsFailure.
+ *
+ */
+{
+ int size;
+ FILE *stream;
+ char *pathname;
+ struct stat txt;
+ int length;
+
+ /* use and name of this env var is not part of the standard */
+ /* implementation-dependent feature */
+ if ((pathname = getenv("XCMSDB")) == NULL) {
+ pathname = XCMSDB;
+ }
+#ifdef __UNIXOS2__
+ pathname = __XOS2RedirRoot(pathname);
+#endif
+
+ length = strlen(pathname);
+ if ((length == 0) || (length >= (BUFSIZ - 5))){
+ XcmsColorDbState = XcmsDbInitFailure;
+ return(XcmsFailure);
+ }
+
+ if (stat(pathname, &txt)) {
+ /* can't stat file */
+ XcmsColorDbState = XcmsDbInitFailure;
+ return(XcmsFailure);
+ }
+
+ if ((stream = _XFopenFile (pathname, "r")) == NULL) {
+ return(XcmsFailure);
+ }
+
+ stringSectionSize(stream, &nEntries, &size);
+ rewind(stream);
+
+ strings = (char *) Xmalloc(size);
+ pairs = (XcmsPair *)Xcalloc(nEntries, sizeof(XcmsPair));
+
+ ReadColornameDB(stream, pairs, strings);
+ (void) fclose(stream);
+
+ /*
+ * sort the pair recs
+ */
+ qsort((char *)pairs, nEntries, sizeof(XcmsPair), FirstCmp);
+
+ XcmsColorDbState = XcmsDbInitSuccess;
+ return(XcmsSuccess);
+}
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsCopyISOLatin1Lowered
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsCopyISOLatin1Lowered(
+ char *dst,
+ const char *src)
+/*
+ * DESCRIPTION
+ * ISO Latin-1 case conversion routine
+ * Identical to XmuCopyISOLatin1Lowered() but provided here
+ * to eliminate need to link with libXmu.a.
+ *
+ * IMPLEMENTORS NOTE:
+ * This routine is also used in XcmsFormatOfPrefix.
+ *
+ * RETURNS
+ * Void
+ *
+ */
+{
+ register unsigned char *dest;
+ register const unsigned char *source;
+
+ for (dest = (unsigned char *)dst, source = (const unsigned char *)src;
+ *source;
+ source++, dest++)
+ {
+ if ((*source >= XK_A) && (*source <= XK_Z))
+ *dest = *source + (XK_a - XK_A);
+ else if ((*source >= XK_Agrave) && (*source <= XK_Odiaeresis))
+ *dest = *source + (XK_agrave - XK_Agrave);
+ else if ((*source >= XK_Ooblique) && (*source <= XK_Thorn))
+ *dest = *source + (XK_oslash - XK_Ooblique);
+ else
+ *dest = *source;
+ }
+ *dest = '\0';
+}
+
+
+/*
+ * NAME
+ * _XcmsResolveColorString -
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsResolveColorString (
+ XcmsCCC ccc,
+ const char **color_string,
+ XcmsColor *pColor_exact_return,
+ XcmsColorFormat result_format)
+/*
+ * DESCRIPTION
+ * The XcmsLookupColor function finds the color specification
+ * associated with a color name in the Device-Independent Color
+ * Name Database.
+ * RETURNS
+ * XcmsFailure if failed to convert valid color string.
+ * XcmsSuccess if succeeded in converting color string to
+ * XcmsColor.
+ * _XCMS_NEWNAME if failed to parse the string or find it in
+ * the database, or if succeeded in looking it up and
+ * found another name which is not in the database.
+ * Note that the new name is returned in color_string.
+ *
+ * This function returns both the color specification found in the
+ * database (db specification) and the color specification for the
+ * color displayable by the specified screen (screen
+ * specification). The calling routine sets the format for these
+ * returned specifications in the XcmsColor format component.
+ * If XcmsUndefinedFormat, the specification is returned in the
+ * format used to store the color in the database.
+ */
+{
+ XcmsColor dbWhitePt; /* whitePt associated with pColor_exact_return*/
+ /* the screen's white point */
+ XcmsColor *pClientWhitePt;
+ int retval;
+ const char *strptr = whitePtStr;
+
+/*
+ * 0. Check for invalid arguments.
+ */
+ if (ccc == NULL || (*color_string)[0] == '\0' || pColor_exact_return == NULL) {
+ return(XcmsFailure);
+ }
+
+/*
+ * 1. First attempt to parse the string
+ * If successful, then convert the specification to the target format
+ * and return.
+ */
+ if (_XcmsParseColorString(ccc, *color_string, pColor_exact_return)
+ == 1) {
+ if (result_format != XcmsUndefinedFormat
+ && pColor_exact_return->format != result_format) {
+ /* need to be converted to the target format */
+ return(XcmsConvertColors(ccc, pColor_exact_return, 1,
+ result_format, (Bool *)NULL));
+ } else {
+ return(XcmsSuccess);
+ }
+ }
+
+/*
+ * 2. Attempt to find it in the DI Color Name Database
+ */
+
+ /*
+ * a. Convert String into a XcmsColor structure
+ * Attempt to extract the specification for color_string from the
+ * DI Database (pColor_exact_return). If the DI Database does not
+ * have this entry, then return failure.
+ */
+ retval = _XcmsLookupColorName(ccc, color_string, pColor_exact_return);
+
+ if (retval != XcmsSuccess) {
+ /* color_string replaced with a color name, or not found */
+ return(_XCMS_NEWNAME);
+ }
+
+ if (pColor_exact_return->format == XcmsUndefinedFormat) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * b. If result_format not defined, then assume target format
+ * is the exact format.
+ */
+ if (result_format == XcmsUndefinedFormat) {
+ result_format = pColor_exact_return->format;
+ }
+
+ if ((ClientWhitePointOfCCC(ccc))->format == XcmsUndefinedFormat) {
+ pClientWhitePt = ScreenWhitePointOfCCC(ccc);
+ } else {
+ pClientWhitePt = ClientWhitePointOfCCC(ccc);
+ }
+
+ /*
+ * c. Convert to the target format, making adjustments for white
+ * point differences as necessary.
+ */
+ if (XCMS_DD_ID(pColor_exact_return->format)) {
+ /*
+ * The spec format is Device-Dependent, therefore assume the
+ * its white point is the Screen White Point.
+ */
+ if (XCMS_DD_ID(result_format)) {
+ /*
+ * Target format is Device-Dependent
+ * Therefore, DD --> DD conversion
+ */
+ return(_XcmsDDConvertColors(ccc, pColor_exact_return,
+ 1, result_format, (Bool *) NULL));
+ } else {
+ /*
+ * Target format is Device-Independent
+ * Therefore, DD --> DI conversion
+ */
+ if (ccc->whitePtAdjProc && !_XcmsEqualWhitePts(ccc,
+ pClientWhitePt, ScreenWhitePointOfCCC(ccc))) {
+ return((*ccc->whitePtAdjProc)(ccc, ScreenWhitePointOfCCC(ccc),
+ pClientWhitePt, result_format,
+ pColor_exact_return, 1, (Bool *) NULL));
+ } else {
+ if (_XcmsDDConvertColors(ccc, pColor_exact_return, 1,
+ XcmsCIEXYZFormat, (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ return(_XcmsDIConvertColors(ccc, pColor_exact_return,
+ pClientWhitePt, 1, result_format));
+ }
+ }
+ } else {
+ /*
+ * The spec format is Device-Independent, therefore attempt
+ * to find a database white point.
+ *
+ * If the Database does not have a white point, then assume the
+ * database white point is the same as the Screen White Point.
+ */
+
+ if (_XcmsLookupColorName(ccc, &strptr, &dbWhitePt) != 1) {
+ memcpy((char *)&dbWhitePt,
+ (char *)&ccc->pPerScrnInfo->screenWhitePt,
+ sizeof(XcmsColor));
+ }
+ if (XCMS_DD_ID(result_format)) {
+ /*
+ * Target format is Device-Dependent
+ * Therefore, DI --> DD conversion
+ */
+ if (ccc->whitePtAdjProc && !_XcmsEqualWhitePts(ccc,
+ &dbWhitePt, ScreenWhitePointOfCCC(ccc))) {
+ return((*ccc->whitePtAdjProc)(ccc, &dbWhitePt,
+ ScreenWhitePointOfCCC(ccc), result_format,
+ pColor_exact_return, 1, (Bool *)NULL));
+ } else {
+ if (pColor_exact_return->format != XcmsCIEXYZFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor_exact_return,
+ &dbWhitePt, 1, XcmsCIEXYZFormat) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ return (_XcmsDDConvertColors(ccc, pColor_exact_return, 1,
+ result_format, (Bool *)NULL));
+ }
+ } else {
+ /*
+ * Target format is Device-Independent
+ * Therefore, DI --> DI conversion
+ */
+ if (ccc->whitePtAdjProc && !_XcmsEqualWhitePts(ccc,
+ &dbWhitePt, pClientWhitePt)) {
+ /*
+ * The calling routine wants to resolve this color
+ * in terms if it's white point (i.e. Client White Point).
+ * Therefore, apply white adjustment for the displacement
+ * between dbWhitePt to clientWhitePt.
+ */
+ return((*ccc->whitePtAdjProc)(ccc, &dbWhitePt,
+ pClientWhitePt, result_format,
+ pColor_exact_return, 1, (Bool *)NULL));
+ } else if (_XcmsEqualWhitePts(ccc,
+ &dbWhitePt, pClientWhitePt)) {
+ /*
+ * Can use either dbWhitePt or pClientWhitePt to
+ * convert to the result_format.
+ */
+ if (pColor_exact_return->format == result_format) {
+ return(XcmsSuccess);
+ } else {
+ return (_XcmsDIConvertColors(ccc, pColor_exact_return,
+ &dbWhitePt, 1, result_format));
+ }
+ } else {
+ /*
+ * Need to convert to a white point independent color
+ * space (let's choose CIEXYZ) then convert to the
+ * target color space. Why? Lets assume that
+ * pColor_exact_return->format and result format
+ * are white point dependent format (e.g., CIELUV, CIELAB,
+ * TekHVC ... same or any combination). If so, we'll
+ * need to convert the color with dbWhitePt to an absolute
+ * spec (i.e. non-white point dependent) then convert that
+ * absolute value with clientWhitePt to the result_format.
+ */
+ if (pColor_exact_return->format != XcmsCIEXYZFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor_exact_return,
+ &dbWhitePt, 1, XcmsCIEXYZFormat) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (result_format == XcmsCIEXYZFormat) {
+ return(XcmsSuccess);
+ } else {
+ return(_XcmsDIConvertColors(ccc, pColor_exact_return,
+ pClientWhitePt, 1, result_format));
+ }
+ }
+ }
+ }
+}
diff --git a/nx-X11/lib/X11/cmsGlobls.c b/nx-X11/lib/X11/cmsGlobls.c
new file mode 100644
index 000000000..abe711c6a
--- /dev/null
+++ b/nx-X11/lib/X11/cmsGlobls.c
@@ -0,0 +1,128 @@
+/*$Xorg: cmsGlobls.c,v 1.3 2000/08/17 19:45:09 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsGlobls.c
+ *
+ * DESCRIPTION
+ * Source file containing Xcms globals
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/cmsGlobls.c,v 1.4 2001/01/17 19:41:51 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+/*
+ * GLOBALS
+ * Variables declared in this package that are allowed
+ * to be used globally.
+ */
+
+ /*
+ * Initial array of Device Independent Color Spaces
+ */
+XcmsColorSpace *_XcmsDIColorSpacesInit[] = {
+ &XcmsCIEXYZColorSpace,
+ &XcmsCIEuvYColorSpace,
+ &XcmsCIExyYColorSpace,
+ &XcmsCIELabColorSpace,
+ &XcmsCIELuvColorSpace,
+ &XcmsTekHVCColorSpace,
+ &XcmsUNDEFINEDColorSpace,
+ NULL
+};
+ /*
+ * Pointer to the array of pointers to XcmsColorSpace structures for
+ * Device-Independent Color Spaces that are currently accessible by
+ * the color management system. End of list is indicated by a NULL pointer.
+ */
+XcmsColorSpace **_XcmsDIColorSpaces = _XcmsDIColorSpacesInit;
+
+ /*
+ * Initial array of Device Dependent Color Spaces
+ */
+XcmsColorSpace *_XcmsDDColorSpacesInit[] = {
+ &XcmsRGBColorSpace,
+ &XcmsRGBiColorSpace,
+ NULL
+};
+ /*
+ * Pointer to the array of pointers to XcmsColorSpace structures for
+ * Device-Dependent Color Spaces that are currently accessible by
+ * the color management system. End of list is indicated by a NULL pointer.
+ */
+XcmsColorSpace **_XcmsDDColorSpaces = &_XcmsDDColorSpacesInit[0];
+
+ /*
+ * Initial array of Screen Color Characterization Function Sets
+ */
+XcmsFunctionSet *_XcmsSCCFuncSetsInit[] = {
+ &XcmsLinearRGBFunctionSet,
+#ifdef GRAY
+ &XcmsGrayFunctionSet,
+#endif /* GRAY */
+ NULL};
+ /*
+ * Pointer to the array of pointers to XcmsSCCFuncSet structures
+ * (Screen Color Characterization Function Sets) that are currently
+ * accessible by the color management system. End of list is
+ * indicated by a NULL pointer.
+ */
+XcmsFunctionSet **_XcmsSCCFuncSets = _XcmsSCCFuncSetsInit;
+
+ /*
+ * X Consortium Registered Device-Independent Color Spaces
+ * Note that prefix must be in lowercase.
+ */
+const char _XcmsCIEXYZ_prefix[] = "ciexyz";
+const char _XcmsCIEuvY_prefix[] = "cieuvy";
+const char _XcmsCIExyY_prefix[] = "ciexyy";
+const char _XcmsCIELab_prefix[] = "cielab";
+const char _XcmsCIELuv_prefix[] = "cieluv";
+const char _XcmsTekHVC_prefix[] = "tekhvc";
+ /*
+ * Registered Device-Dependent Color Spaces
+ */
+const char _XcmsRGBi_prefix[] = "rgbi";
+const char _XcmsRGB_prefix[] = "rgb";
+
+XcmsRegColorSpaceEntry _XcmsRegColorSpaces[] = {
+ { _XcmsCIEXYZ_prefix, XcmsCIEXYZFormat },
+ { _XcmsCIEuvY_prefix, XcmsCIEuvYFormat },
+ { _XcmsCIExyY_prefix, XcmsCIExyYFormat },
+ { _XcmsCIELab_prefix, XcmsCIELabFormat },
+ { _XcmsCIELuv_prefix, XcmsCIELuvFormat },
+ { _XcmsTekHVC_prefix, XcmsTekHVCFormat },
+ { _XcmsRGB_prefix, XcmsRGBFormat },
+ { _XcmsRGBi_prefix, XcmsRGBiFormat },
+ { NULL, 0 }
+};
diff --git a/nx-X11/lib/X11/cmsInt.c b/nx-X11/lib/X11/cmsInt.c
new file mode 100644
index 000000000..68cfebd74
--- /dev/null
+++ b/nx-X11/lib/X11/cmsInt.c
@@ -0,0 +1,415 @@
+/* $Xorg: cmsInt.c,v 1.4 2000/08/17 19:45:09 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsInt.c - Xcms API utility routines
+ *
+ * DESCRIPTION
+ * Xcms Application Program Interface (API) utility
+ * routines for hanging information directly onto
+ * the Display structure.
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/cmsInt.c,v 1.4 2003/04/13 19:22:20 dawes Exp $ */
+
+/* #define NEED_EVENTS */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+#ifndef XCMSCOMPPROC
+# define XCMSCOMPPROC XcmsTekHVCClipC
+#endif
+
+/* forward/static */
+static void _XcmsFreeDefaultCCCs(Display *dpy);
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsCopyPointerArray
+ *
+ * SYNOPSIS
+ */
+XPointer *
+_XcmsCopyPointerArray(
+ XPointer *pap)
+/*
+ * DESCRIPTION
+ * Copies an array of NULL terminated pointers.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the copy.
+ *
+ */
+{
+ XPointer *newArray;
+ char **tmp;
+ int n;
+
+ for (tmp = pap, n = 0; *tmp != NULL; tmp++, n++);
+ n++; /* add 1 to include the NULL pointer */
+
+ if ((newArray = (XPointer *)Xmalloc(n * sizeof(XPointer)))) {
+ memcpy((char *)newArray, (char *)pap,
+ (unsigned)(n * sizeof(XPointer)));
+ }
+ return((XPointer *)newArray);
+}
+
+/*
+ * NAME
+ * _XcmsFreePointerArray
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsFreePointerArray(
+ XPointer *pap)
+/*
+ * DESCRIPTION
+ * Frees an array of NULL terminated pointers.
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ Xfree(pap);
+}
+
+/*
+ * NAME
+ * _XcmsPushPointerArray
+ *
+ * SYNOPSIS
+ */
+XPointer *
+_XcmsPushPointerArray(
+ XPointer *pap,
+ XPointer p,
+ XPointer *papNoFree)
+/*
+ * DESCRIPTION
+ * Places the specified pointer at the head of an array of NULL
+ * terminated pointers.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the head of the array.
+ *
+ */
+{
+ XPointer *newArray;
+ char **tmp;
+ int n;
+
+ for (tmp = pap, n = 0; *tmp != NULL; tmp++, n++);
+
+ /* add 2: 1 for the new pointer and another for the NULL pointer */
+ n += 2;
+
+ if ((newArray = (XPointer *)Xmalloc(n * sizeof(XPointer)))) {
+ memcpy((char *)(newArray+1),(char *)pap,
+ (unsigned)((n-1) * sizeof(XPointer)));
+ *newArray = p;
+ }
+ if (pap != papNoFree) {
+ _XcmsFreePointerArray(pap);
+ }
+ return((XPointer *)newArray);
+}
+
+/*
+ * NAME
+ * _XcmsInitDefaultCCCs
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsInitDefaultCCCs(
+ Display *dpy)
+/*
+ * DESCRIPTION
+ * Initializes the Xcms per Display Info structure
+ * (XcmsPerDpyInfo).
+ *
+ * RETURNS
+ * Returns 0 if failed; otherwise non-zero.
+ *
+ */
+{
+ int nScrn = ScreenCount(dpy);
+ int i;
+ XcmsCCC ccc;
+
+ if (nScrn <= 0) {
+ return(0);
+ }
+
+ /*
+ * Create an array of XcmsCCC structures, one for each screen.
+ * They serve as the screen's default CCC.
+ */
+ if (!(ccc = (XcmsCCC)
+ Xcalloc((unsigned)nScrn, (unsigned) sizeof(XcmsCCCRec)))) {
+ return(0);
+ }
+ dpy->cms.defaultCCCs = (XPointer)ccc;
+ dpy->free_funcs->defaultCCCs = _XcmsFreeDefaultCCCs;
+
+ for (i = 0; i < nScrn; i++, ccc++) {
+ ccc->dpy = dpy;
+ ccc->screenNumber = i;
+ ccc->visual = DefaultVisual(dpy, i);
+ /*
+ * Used calloc to allocate memory so:
+ * ccc->clientWhitePt->format == XcmsUndefinedFormat
+ * ccc->gamutCompProc == NULL
+ * ccc->whitePtAdjProc == NULL
+ * ccc->pPerScrnInfo = NULL
+ *
+ * Don't need to create XcmsPerScrnInfo and its functionSet and
+ * pScreenData components until the default CCC is accessed.
+ * Note that the XcmsDefaultCCC routine calls _XcmsInitScrnInto
+ * to do this.
+ */
+ ccc->gamutCompProc = XCMSCOMPPROC;
+ }
+
+ return(1);
+}
+
+
+/*
+ * NAME
+ * _XcmsFreeDefaultCCCs - Free Default CCCs and its PerScrnInfo
+ *
+ * SYNOPSIS
+ */
+static void
+_XcmsFreeDefaultCCCs(
+ Display *dpy)
+/*
+ * DESCRIPTION
+ * This routine frees the default XcmsCCC's associated with
+ * each screen and its associated substructures as neccessary.
+ *
+ * RETURNS
+ * void
+ *
+ *
+ */
+{
+ int nScrn = ScreenCount(dpy);
+ XcmsCCC ccc;
+ int i;
+
+ /*
+ * Free Screen data in each DefaultCCC
+ * Do not use XcmsFreeCCC here because it will not free
+ * DefaultCCC's.
+ */
+ ccc = (XcmsCCC)dpy->cms.defaultCCCs;
+ for (i = nScrn; i--; ccc++) {
+ /*
+ * Check if XcmsPerScrnInfo exists.
+ *
+ * This is the only place where XcmsPerScrnInfo structures
+ * are freed since there is only one allocated per Screen.
+ * It just so happens that we place its reference in the
+ * default CCC.
+ */
+ if (ccc->pPerScrnInfo) {
+ /* Check if SCCData exists */
+ if (ccc->pPerScrnInfo->state != XcmsInitNone
+ && ccc->pPerScrnInfo->screenData) {
+ (*((XcmsFunctionSet *)ccc->pPerScrnInfo->functionSet)->screenFreeProc)
+ (ccc->pPerScrnInfo->screenData);
+ }
+ Xfree(ccc->pPerScrnInfo);
+ }
+ }
+
+ /*
+ * Free the array of XcmsCCC structures
+ */
+ Xfree(dpy->cms.defaultCCCs);
+ dpy->cms.defaultCCCs = (XPointer)NULL;
+}
+
+
+
+/*
+ * NAME
+ * _XcmsInitScrnInfo
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsInitScrnInfo(
+ register Display *dpy,
+ int screenNumber)
+/*
+ * DESCRIPTION
+ * Given a display and screen number, this routine attempts
+ * to initialize the Xcms per Screen Info structure
+ * (XcmsPerScrnInfo).
+ *
+ * RETURNS
+ * Returns zero if initialization failed; non-zero otherwise.
+ */
+{
+ XcmsFunctionSet **papSCCFuncSet = _XcmsSCCFuncSets;
+ XcmsCCC defaultccc;
+
+ /*
+ * Check if the XcmsCCC's for each screen has been created.
+ * Really dont need to be created until some routine uses the Xcms
+ * API routines.
+ */
+ if ((XcmsCCC)dpy->cms.defaultCCCs == NULL) {
+ if (!_XcmsInitDefaultCCCs(dpy)) {
+ return(0);
+ }
+ }
+
+ defaultccc = (XcmsCCC)dpy->cms.defaultCCCs + screenNumber;
+
+ /*
+ * For each SCCFuncSet, try its pInitScrnFunc.
+ * If the function succeeds, then we got it!
+ */
+
+ if (!defaultccc->pPerScrnInfo) {
+ /*
+ * This is one of two places where XcmsPerScrnInfo structures
+ * are allocated. There is one allocated per Screen that is
+ * shared among visuals that do not have specific intensity
+ * tables. Other XcmsPerScrnInfo structures are created
+ * for the latter (see XcmsCreateCCC). The ones created
+ * here are referenced by the default CCC.
+ */
+ if (!(defaultccc->pPerScrnInfo = (XcmsPerScrnInfo *)
+ Xcalloc(1, (unsigned) sizeof(XcmsPerScrnInfo)))) {
+ return(0);
+ }
+ defaultccc->pPerScrnInfo->state = XcmsInitNone;
+ }
+
+ while (*papSCCFuncSet != NULL) {
+ if ((*(*papSCCFuncSet)->screenInitProc)(dpy, screenNumber,
+ defaultccc->pPerScrnInfo)) {
+ defaultccc->pPerScrnInfo->state = XcmsInitSuccess;
+ return(1);
+ }
+ papSCCFuncSet++;
+ }
+
+ /*
+ * Use Default SCCData
+ */
+ return(_XcmsLRGB_InitScrnDefault(dpy, screenNumber, defaultccc->pPerScrnInfo));
+}
+
+
+/*
+ * NAME
+ * _XcmsFreeIntensityMaps
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsFreeIntensityMaps(
+ Display *dpy)
+/*
+ * DESCRIPTION
+ * Frees all XcmsIntensityMap structures in the linked list
+ * and sets dpy->cms.perVisualIntensityMaps to NULL.
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ XcmsIntensityMap *pNext, *pFree;
+
+ pNext = (XcmsIntensityMap *)dpy->cms.perVisualIntensityMaps;
+ while (pNext != NULL) {
+ pFree = pNext;
+ pNext = pNext->pNext;
+ (*pFree->pFreeScreenData)(pFree->screenData);
+ /* Now free the XcmsIntensityMap structure */
+ Xfree(pFree);
+ }
+ dpy->cms.perVisualIntensityMaps = (XPointer)NULL;
+}
+
+
+/*
+ * NAME
+ * _XcmsGetIntensityMap
+ *
+ * SYNOPSIS
+ */
+XcmsIntensityMap *
+_XcmsGetIntensityMap(
+ Display *dpy,
+ Visual *visual)
+/*
+ * DESCRIPTION
+ * Attempts to return a per-Visual intensity map.
+ *
+ * RETURNS
+ * Pointer to the XcmsIntensityMap structure if found;
+ * otherwise NULL
+ *
+ */
+{
+ VisualID targetID = visual->visualid;
+ XcmsIntensityMap *pNext;
+
+ pNext = (XcmsIntensityMap *)dpy->cms.perVisualIntensityMaps;
+ while (pNext != NULL) {
+ if (targetID == pNext->visualID) {
+ return(pNext);
+ }
+ pNext = pNext->pNext;
+ }
+ return((XcmsIntensityMap *)NULL);
+}
diff --git a/nx-X11/lib/X11/cmsLkCol.c b/nx-X11/lib/X11/cmsLkCol.c
new file mode 100644
index 000000000..f19f21d03
--- /dev/null
+++ b/nx-X11/lib/X11/cmsLkCol.c
@@ -0,0 +1,196 @@
+/* $Xorg: cmsLkCol.c,v 1.3 2000/08/17 19:45:09 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsLkCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsLookupColor
+ *
+ *
+ */
+/* $XFree86: xc/lib/X11/cmsLkCol.c,v 1.5 2003/04/13 19:22:20 dawes Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/*
+ * NAME
+ * XcmsLookupColor -
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsLookupColor (
+ Display *dpy,
+ Colormap cmap,
+ _Xconst char *colorname,
+ XcmsColor *pColor_exact_return,
+ XcmsColor *pColor_scrn_return,
+ XcmsColorFormat result_format)
+/*
+ * DESCRIPTION
+ * The XcmsLookupColor function finds the color specification
+ * associated with a color name in the Device-Independent Color
+ * Name Database.
+ * RETURNS
+ * This function returns both the color specification found in the
+ * database (db specification) and the color specification for the
+ * color displayable by the specified screen (screen
+ * specification). The calling routine sets the format for these
+ * returned specifications in the XcmsColor format component.
+ * If XcmsUndefinedFormat, the specification is returned in the
+ * format used to store the color in the database.
+ */
+{
+ Status retval1 = XcmsSuccess;
+ Status retval2 = XcmsSuccess;
+ XcmsCCC ccc;
+ register int n;
+ xLookupColorReply reply;
+ register xLookupColorReq *req;
+ XColor def, scr;
+
+/*
+ * 0. Check for invalid arguments.
+ */
+ if (dpy == NULL || colorname[0] == '\0' || pColor_scrn_return == 0
+ || pColor_exact_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) == (XcmsCCC)NULL) {
+ return(XcmsFailure);
+ }
+
+/*
+ * 1. Convert string to a XcmsColor
+ */
+ if ((retval1 = _XcmsResolveColorString(ccc, &colorname,
+ pColor_exact_return, result_format)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ if (retval1 == _XCMS_NEWNAME) {
+ goto PassToServer;
+ }
+
+/*
+ * 2. pColor_scrn_return
+ * Assume the pColor_exact_return has already been adjusted to
+ * the Client White Point.
+ *
+ */
+ /*
+ * Convert to RGB, adjusting for white point differences if necessary.
+ */
+ memcpy((char *)pColor_scrn_return, (char *)pColor_exact_return,
+ sizeof(XcmsColor));
+ if (pColor_scrn_return->format == XcmsRGBFormat) {
+ retval2 = XcmsSuccess;
+ } else if ((retval2 = XcmsConvertColors(ccc, pColor_scrn_return, 1,
+ XcmsRGBFormat, (Bool *)NULL)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Then, convert XcmsColor structure to the target specification
+ * format. Note that we must use NULL instead of passing
+ * pCompressed.
+ */
+
+ if (result_format == XcmsUndefinedFormat) {
+ result_format = pColor_exact_return->format;
+ }
+ if (result_format == XcmsRGBFormat) {
+ _XcmsUnresolveColor(ccc, pColor_scrn_return);
+ } else {
+ _XcmsResolveColor(ccc, pColor_scrn_return);
+ if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(retval1 > retval2 ? retval1 : retval2);
+
+PassToServer:
+ /*
+ * Xcms and i18n methods failed, so lets pass it to the server
+ * for parsing.
+ */
+
+ LockDisplay(dpy);
+ GetReq (LookupColor, req);
+ req->cmap = cmap;
+ req->nbytes = n = strlen(colorname);
+ req->length += (n + 3) >> 2;
+ Data (dpy, colorname, (long)n);
+ if (!_XReply (dpy, (xReply *) &reply, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XcmsFailure);
+ }
+ 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();
+
+ _XColor_to_XcmsRGB(ccc, &def, pColor_exact_return, 1);
+ _XColor_to_XcmsRGB(ccc, &scr, pColor_scrn_return, 1);
+
+ /*
+ * Then, convert XcmsColor structure to the target specification
+ * format. Note that we must use NULL instead of passing
+ * pCompressed.
+ */
+
+ if (result_format != XcmsRGBFormat
+ && result_format != XcmsUndefinedFormat) {
+ if (XcmsConvertColors(ccc, pColor_exact_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/cmsMath.c b/nx-X11/lib/X11/cmsMath.c
new file mode 100644
index 000000000..c97c7a90a
--- /dev/null
+++ b/nx-X11/lib/X11/cmsMath.c
@@ -0,0 +1,140 @@
+/* $Xorg: cmsMath.c,v 1.4 2001/02/09 02:03:39 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.
+
+*/
+/* $XFree86: xc/lib/X11/cmsMath.c,v 3.4 2001/07/29 05:01:11 tsi Exp $ */
+
+/*
+ * Stephen Gildea, MIT X Consortium, January 1991
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+#include <float.h>
+#ifndef DBL_EPSILON
+#define DBL_EPSILON 1e-6
+#endif
+
+#ifdef _X_ROOT_STATS
+int cbrt_loopcount;
+int sqrt_loopcount;
+#endif
+
+/* Newton's Method: x_n+1 = x_n - ( f(x_n) / f'(x_n) ) */
+
+
+/* for cube roots, x^3 - a = 0, x_new = x - 1/3 (x - a/x^2) */
+
+double
+_XcmsCubeRoot(a)
+ double a;
+{
+ register double abs_a, cur_guess, delta;
+
+#ifdef DEBUG
+ printf("_XcmsCubeRoot passed in %g\n", a);
+#endif
+#ifdef _X_ROOT_STATS
+ cbrt_loopcount = 0;
+#endif
+ if (a == 0.)
+ return 0.;
+
+ abs_a = a<0. ? -a : a; /* convert to positive to speed loop tests */
+
+ /* arbitrary first guess */
+ if (abs_a > 1.)
+ cur_guess = abs_a/8.;
+ else
+ cur_guess = abs_a*8.;
+
+ do {
+#ifdef _X_ROOT_STATS
+ cbrt_loopcount++;
+#endif
+ delta = (cur_guess - abs_a/(cur_guess*cur_guess))/3.;
+ cur_guess -= delta;
+ if (delta < 0.) delta = -delta;
+ } while (delta >= cur_guess*DBL_EPSILON);
+
+ if (a < 0.)
+ cur_guess = -cur_guess;
+
+#ifdef DEBUG
+ printf("_XcmsCubeRoot returning %g\n", cur_guess);
+#endif
+ return cur_guess;
+}
+
+
+
+/* for square roots, x^2 - a = 0, x_new = x - 1/2 (x - a/x) */
+
+double
+_XcmsSquareRoot(a)
+ double a;
+{
+ register double cur_guess, delta;
+
+#ifdef DEBUG
+ printf("_XcmsSquareRoot passed in %g\n", a);
+#endif
+#ifdef _X_ROOT_STATS
+ sqrt_loopcount = 0;
+#endif
+ if (a == 0.)
+ return 0.;
+
+ if (a < 0.) {
+ /* errno = EDOM; */
+ return 0.;
+ }
+
+ /* arbitrary first guess */
+ if (a > 1.)
+ cur_guess = a/4.;
+ else
+ cur_guess = a*4.;
+
+ do {
+#ifdef _X_ROOT_STATS
+ sqrt_loopcount++;
+#endif
+ delta = (cur_guess - a/cur_guess)/2.;
+ cur_guess -= delta;
+ if (delta < 0.) delta = -delta;
+ } while (delta >= cur_guess*DBL_EPSILON);
+
+#ifdef DEBUG
+ printf("_XcmsSquareRoot returning %g\n", cur_guess);
+#endif
+ return cur_guess;
+}
+
diff --git a/nx-X11/lib/X11/cmsProp.c b/nx-X11/lib/X11/cmsProp.c
new file mode 100644
index 000000000..81ea58ce9
--- /dev/null
+++ b/nx-X11/lib/X11/cmsProp.c
@@ -0,0 +1,152 @@
+/* $Xorg: cmsProp.c,v 1.3 2000/08/17 19:45:10 cpqbld Exp $ */
+
+/*
+ *
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * XcmsProp.c
+ *
+ * DESCRIPTION
+ * This utility routines for manipulating properties.
+ *
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xatom.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+
+/*
+ * NAME
+ * _XcmsGetElement -- get an element value from the property passed
+ *
+ * SYNOPSIS
+ */
+unsigned long
+_XcmsGetElement(
+ int format,
+ char **pValue,
+ unsigned long *pCount)
+/*
+ * DESCRIPTION
+ * Get the next element from the property and return it.
+ * Also increment the pointer the amount needed.
+ *
+ * Returns
+ * unsigned long
+ */
+{
+ unsigned long value;
+
+ switch (format) {
+ case 32:
+ value = *((unsigned long *)(*pValue)) & 0xFFFFFFFF;
+ *pValue += sizeof(unsigned long);
+ *pCount -= 1;
+ break;
+ case 16:
+ value = *((unsigned short *)(*pValue));
+ *pValue += sizeof(unsigned short);
+ *pCount -= 1;
+ break;
+ case 8:
+ value = *((unsigned char *) (*pValue));
+ *pValue += 1;
+ *pCount -= 1;
+ break;
+ default:
+ value = 0;
+ break;
+ }
+ return(value);
+}
+
+
+/*
+ * NAME
+ * _XcmsGetProperty -- Determine the existance of a property
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsGetProperty(
+ Display *pDpy,
+ Window w,
+ Atom property,
+ int *pFormat,
+ unsigned long *pNItems,
+ unsigned long *pNBytes,
+ char **pValue)
+/*
+ * DESCRIPTION
+ *
+ * Returns
+ * 0 if property does not exist.
+ * 1 if property exists.
+ */
+{
+ char *prop_ret;
+ int format_ret;
+ long len = 6516;
+ #ifdef NXAGENT_SERVER
+ unsigned long nitems_ret, after_ret = 0;
+ #else
+ unsigned long nitems_ret, after_ret;
+ #endif
+ Atom atom_ret;
+
+ while (XGetWindowProperty (pDpy, w, property, 0, len, False,
+ XA_INTEGER, &atom_ret, &format_ret,
+ &nitems_ret, &after_ret,
+ (unsigned char **)&prop_ret)) {
+ if (after_ret > 0) {
+ len += nitems_ret * (format_ret >> 3);
+ XFree (prop_ret);
+ } else {
+ break;
+ }
+ }
+ if (format_ret == 0 || nitems_ret == 0) {
+ /* the property does not exist or is of an unexpected type */
+ return(XcmsFailure);
+ }
+
+ *pFormat = format_ret;
+ *pNItems = nitems_ret;
+ *pNBytes = nitems_ret * (format_ret >> 3);
+ *pValue = prop_ret;
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/cmsProp.c.X.original b/nx-X11/lib/X11/cmsProp.c.X.original
new file mode 100644
index 000000000..4040a05ce
--- /dev/null
+++ b/nx-X11/lib/X11/cmsProp.c.X.original
@@ -0,0 +1,148 @@
+/* $Xorg: cmsProp.c,v 1.3 2000/08/17 19:45:10 cpqbld Exp $ */
+
+/*
+ *
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * XcmsProp.c
+ *
+ * DESCRIPTION
+ * This utility routines for manipulating properties.
+ *
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xatom.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+
+/*
+ * NAME
+ * _XcmsGetElement -- get an element value from the property passed
+ *
+ * SYNOPSIS
+ */
+unsigned long
+_XcmsGetElement(
+ int format,
+ char **pValue,
+ unsigned long *pCount)
+/*
+ * DESCRIPTION
+ * Get the next element from the property and return it.
+ * Also increment the pointer the amount needed.
+ *
+ * Returns
+ * unsigned long
+ */
+{
+ unsigned long value;
+
+ switch (format) {
+ case 32:
+ value = *((unsigned long *)(*pValue)) & 0xFFFFFFFF;
+ *pValue += sizeof(unsigned long);
+ *pCount -= 1;
+ break;
+ case 16:
+ value = *((unsigned short *)(*pValue));
+ *pValue += sizeof(unsigned short);
+ *pCount -= 1;
+ break;
+ case 8:
+ value = *((unsigned char *) (*pValue));
+ *pValue += 1;
+ *pCount -= 1;
+ break;
+ default:
+ value = 0;
+ break;
+ }
+ return(value);
+}
+
+
+/*
+ * NAME
+ * _XcmsGetProperty -- Determine the existance of a property
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsGetProperty(
+ Display *pDpy,
+ Window w,
+ Atom property,
+ int *pFormat,
+ unsigned long *pNItems,
+ unsigned long *pNBytes,
+ char **pValue)
+/*
+ * DESCRIPTION
+ *
+ * Returns
+ * 0 if property does not exist.
+ * 1 if property exists.
+ */
+{
+ char *prop_ret;
+ int format_ret;
+ long len = 6516;
+ unsigned long nitems_ret, after_ret;
+ Atom atom_ret;
+
+ while (XGetWindowProperty (pDpy, w, property, 0, len, False,
+ XA_INTEGER, &atom_ret, &format_ret,
+ &nitems_ret, &after_ret,
+ (unsigned char **)&prop_ret)) {
+ if (after_ret > 0) {
+ len += nitems_ret * (format_ret >> 3);
+ XFree (prop_ret);
+ } else {
+ break;
+ }
+ }
+ if (format_ret == 0 || nitems_ret == 0) {
+ /* the property does not exist or is of an unexpected type */
+ return(XcmsFailure);
+ }
+
+ *pFormat = format_ret;
+ *pNItems = nitems_ret;
+ *pNBytes = nitems_ret * (format_ret >> 3);
+ *pValue = prop_ret;
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/cmsTrig.c b/nx-X11/lib/X11/cmsTrig.c
new file mode 100644
index 000000000..1859fa93e
--- /dev/null
+++ b/nx-X11/lib/X11/cmsTrig.c
@@ -0,0 +1,597 @@
+/* $Xorg: cmsTrig.c,v 1.3 2000/08/17 19:45:10 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* $XFree86: xc/lib/X11/cmsTrig.c,v 3.8 2001/10/28 03:32:34 tsi Exp $ */
+/*
+ * It should be pointed out that for simplicity's sake, the
+ * environment parameters are defined as floating point constants,
+ * rather than octal or hexadecimal initializations of allocated
+ * storage areas. This means that the range of allowed numbers
+ * may not exactly match the hardware's capabilities. For example,
+ * if the maximum positive double precision floating point number
+ * is EXACTLY 1.11...E100 and the constant "MAXDOUBLE is
+ * defined to be 1.11E100 then the numbers between 1.11E100 and
+ * 1.11...E100 are considered to be undefined. For most
+ * applications, this will cause no problems.
+ *
+ * An alternate method is to allocate a global static "double" variable,
+ * say "maxdouble", and use a union declaration and initialization
+ * to initialize it with the proper bits for the EXACT maximum value.
+ * This was not done because the only compilers available to the
+ * author did not fully support union initialization features.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xcmsint.h"
+
+/* forward/static */
+static double _XcmsModulo(double value, double base);
+static double _XcmsPolynomial(
+ register int order,
+ double const *coeffs,
+ double x);
+static double
+_XcmsModuloF(
+ double val,
+ register double *dp);
+
+/*
+ * DEFINES
+ */
+#define XCMS_MAXERROR 0.000001
+#define XCMS_MAXITER 10000
+#define XCMS_PI 3.14159265358979323846264338327950
+#define XCMS_TWOPI 6.28318530717958620
+#define XCMS_HALFPI 1.57079632679489660
+#define XCMS_FOURTHPI 0.785398163397448280
+#define XCMS_SIXTHPI 0.523598775598298820
+#define XCMS_RADIANS(d) ((d) * XCMS_PI / 180.0)
+#define XCMS_DEGREES(r) ((r) * 180.0 / XCMS_PI)
+#define XCMS_X6_UNDERFLOWS (4.209340e-52) /* X**6 almost underflows */
+#define XCMS_X16_UNDERFLOWS (5.421010e-20) /* X**16 almost underflows*/
+#define XCMS_CHAR_BIT 8
+#define XCMS_LONG_MAX 0x7FFFFFFF
+#define XCMS_DEXPLEN 11
+#define XCMS_NBITS(type) (XCMS_CHAR_BIT * (int)sizeof(type))
+#define XCMS_FABS(x) ((x) < 0.0 ? -(x) : (x))
+
+/* XCMS_DMAXPOWTWO - largest power of two exactly representable as a double */
+#ifdef _CRAY
+#define XCMS_DMAXPOWTWO ((double)(1 < 47))
+#else
+#define XCMS_DMAXPOWTWO ((double)(XCMS_LONG_MAX) * \
+ (1L << ((XCMS_NBITS(double)-XCMS_DEXPLEN) - XCMS_NBITS(int) + 1)))
+#endif
+
+/*
+ * LOCAL VARIABLES
+ */
+
+static double const cos_pcoeffs[] = {
+ 0.12905394659037374438e7,
+ -0.37456703915723204710e6,
+ 0.13432300986539084285e5,
+ -0.11231450823340933092e3
+};
+
+static double const cos_qcoeffs[] = {
+ 0.12905394659037373590e7,
+ 0.23467773107245835052e5,
+ 0.20969518196726306286e3,
+ 1.0
+};
+
+static double const sin_pcoeffs[] = {
+ 0.20664343336995858240e7,
+ -0.18160398797407332550e6,
+ 0.35999306949636188317e4,
+ -0.20107483294588615719e2
+};
+
+static double const sin_qcoeffs[] = {
+ 0.26310659102647698963e7,
+ 0.39270242774649000308e5,
+ 0.27811919481083844087e3,
+ 1.0
+};
+
+/*
+ *
+ * FUNCTION
+ *
+ * _XcmsCosine double precision cosine
+ *
+ * KEY WORDS
+ *
+ * cos
+ * machine independent routines
+ * trigonometric functions
+ * math libraries
+ *
+ * DESCRIPTION
+ *
+ * Returns double precision cosine of double precision
+ * floating point argument.
+ *
+ * USAGE
+ *
+ * double _XcmsCosine (x)
+ * double x;
+ *
+ * REFERENCES
+ *
+ * Computer Approximations, J.F. Hart et al, John Wiley & Sons,
+ * 1968, pp. 112-120.
+ *
+ * RESTRICTIONS
+ *
+ * The sin and cos routines are interactive in the sense that
+ * in the process of reducing the argument to the range -PI/4
+ * to PI/4, each may call the other. Ultimately one or the
+ * other uses a polynomial approximation on the reduced
+ * argument. The sin approximation has a maximum relative error
+ * of 10**(-17.59) and the cos approximation has a maximum
+ * relative error of 10**(-16.18).
+ *
+ * These error bounds assume exact arithmetic
+ * in the polynomial evaluation. Additional rounding and
+ * truncation errors may occur as the argument is reduced
+ * to the range over which the polynomial approximation
+ * is valid, and as the polynomial is evaluated using
+ * finite-precision arithmetic.
+ *
+ * PROGRAMMER
+ *
+ * Fred Fish
+ *
+ * INTERNALS
+ *
+ * Computes cos(x) from:
+ *
+ * (1) Reduce argument x to range -PI to PI.
+ *
+ * (2) If x > PI/2 then call cos recursively
+ * using relation cos(x) = -cos(x - PI).
+ *
+ * (3) If x < -PI/2 then call cos recursively
+ * using relation cos(x) = -cos(x + PI).
+ *
+ * (4) If x > PI/4 then call sin using
+ * relation cos(x) = sin(PI/2 - x).
+ *
+ * (5) If x < -PI/4 then call cos using
+ * relation cos(x) = sin(PI/2 + x).
+ *
+ * (6) If x would cause underflow in approx
+ * evaluation arithmetic then return
+ * sqrt(1.0 - x**2).
+ *
+ * (7) By now x has been reduced to range
+ * -PI/4 to PI/4 and the approximation
+ * from HART pg. 119 can be used:
+ *
+ * cos(x) = ( p(y) / q(y) )
+ * Where:
+ *
+ * y = x * (4/PI)
+ *
+ * p(y) = SUM [ Pj * (y**(2*j)) ]
+ * over j = {0,1,2,3}
+ *
+ * q(y) = SUM [ Qj * (y**(2*j)) ]
+ * over j = {0,1,2,3}
+ *
+ * P0 = 0.12905394659037374438571854e+7
+ * P1 = -0.3745670391572320471032359e+6
+ * P2 = 0.134323009865390842853673e+5
+ * P3 = -0.112314508233409330923e+3
+ * Q0 = 0.12905394659037373590295914e+7
+ * Q1 = 0.234677731072458350524124e+5
+ * Q2 = 0.2096951819672630628621e+3
+ * Q3 = 1.0000...
+ * (coefficients from HART table #3843 pg 244)
+ *
+ *
+ * **** NOTE **** The range reduction relations used in
+ * this routine depend on the final approximation being valid
+ * over the negative argument range in addition to the positive
+ * argument range. The particular approximation chosen from
+ * HART satisfies this requirement, although not explicitly
+ * stated in the text. This may not be true of other
+ * approximations given in the reference.
+ *
+ */
+
+double _XcmsCosine(double x)
+{
+ auto double y;
+ auto double yt2;
+ double retval;
+
+ if (x < -XCMS_PI || x > XCMS_PI) {
+ x = _XcmsModulo (x, XCMS_TWOPI);
+ if (x > XCMS_PI) {
+ x = x - XCMS_TWOPI;
+ } else if (x < -XCMS_PI) {
+ x = x + XCMS_TWOPI;
+ }
+ }
+ if (x > XCMS_HALFPI) {
+ retval = -(_XcmsCosine (x - XCMS_PI));
+ } else if (x < -XCMS_HALFPI) {
+ retval = -(_XcmsCosine (x + XCMS_PI));
+ } else if (x > XCMS_FOURTHPI) {
+ retval = _XcmsSine (XCMS_HALFPI - x);
+ } else if (x < -XCMS_FOURTHPI) {
+ retval = _XcmsSine (XCMS_HALFPI + x);
+ } else if (x < XCMS_X6_UNDERFLOWS && x > -XCMS_X6_UNDERFLOWS) {
+ retval = _XcmsSquareRoot (1.0 - (x * x));
+ } else {
+ y = x / XCMS_FOURTHPI;
+ yt2 = y * y;
+ retval = _XcmsPolynomial (3, cos_pcoeffs, yt2) / _XcmsPolynomial (3, cos_qcoeffs, yt2);
+ }
+ return (retval);
+}
+
+
+/*
+ * FUNCTION
+ *
+ * _XcmsModulo double precision modulo
+ *
+ * KEY WORDS
+ *
+ * _XcmsModulo
+ * machine independent routines
+ * math libraries
+ *
+ * DESCRIPTION
+ *
+ * Returns double precision modulo of two double
+ * precision arguments.
+ *
+ * USAGE
+ *
+ * double _XcmsModulo (value, base)
+ * double value;
+ * double base;
+ *
+ * PROGRAMMER
+ *
+ * Fred Fish
+ *
+ */
+static double _XcmsModulo(double value, double base)
+{
+ auto double intpart;
+
+ value /= base;
+ value = _XcmsModuloF (value, &intpart);
+ value *= base;
+ return(value);
+}
+
+
+/*
+ * frac = (double) _XcmsModuloF(double val, double *dp)
+ * return fractional part of 'val'
+ * set *dp to integer part of 'val'
+ *
+ * Note -> only compiled for the CA or KA. For the KB/MC,
+ * "math.c" instantiates a copy of the inline function
+ * defined in "math.h".
+ */
+static double
+_XcmsModuloF(
+ double val,
+ register double *dp)
+{
+ register double abs;
+ /*
+ * Don't use a register for this. The extra precision this results
+ * in on some systems causes problems.
+ */
+ double ip;
+
+ /* should check for illegal values here - nan, inf, etc */
+ abs = XCMS_FABS(val);
+ if (abs >= XCMS_DMAXPOWTWO) {
+ ip = val;
+ } else {
+ ip = abs + XCMS_DMAXPOWTWO; /* dump fraction */
+ ip -= XCMS_DMAXPOWTWO; /* restore w/o frac */
+ if (ip > abs) /* if it rounds up */
+ ip -= 1.0; /* fix it */
+ ip = XCMS_FABS(ip);
+ }
+ *dp = ip;
+ return (val - ip); /* signed fractional part */
+}
+
+
+/*
+ * FUNCTION
+ *
+ * _XcmsPolynomial double precision polynomial evaluation
+ *
+ * KEY WORDS
+ *
+ * poly
+ * machine independent routines
+ * math libraries
+ *
+ * DESCRIPTION
+ *
+ * Evaluates a polynomial and returns double precision
+ * result. Is passed a the order of the polynomial,
+ * a pointer to an array of double precision polynomial
+ * coefficients (in ascending order), and the independent
+ * variable.
+ *
+ * USAGE
+ *
+ * double _XcmsPolynomial (order, coeffs, x)
+ * int order;
+ * double *coeffs;
+ * double x;
+ *
+ * PROGRAMMER
+ *
+ * Fred Fish
+ *
+ * INTERNALS
+ *
+ * Evalates the polynomial using recursion and the form:
+ *
+ * P(x) = P0 + x(P1 + x(P2 +...x(Pn)))
+ *
+ */
+
+static double _XcmsPolynomial(
+ register int order,
+ double const *coeffs,
+ double x)
+{
+ auto double rtn_value;
+
+#if 0
+ auto double curr_coeff;
+ if (order <= 0) {
+ rtn_value = *coeffs;
+ } else {
+ curr_coeff = *coeffs; /* Bug in Unisoft's compiler. Does not */
+ coeffs++; /* generate good code for *coeffs++ */
+ rtn_value = curr_coeff + x * _XcmsPolynomial (--order, coeffs, x);
+ }
+#else /* ++jrb -- removed tail recursion */
+ coeffs += order;
+ rtn_value = *coeffs--;
+ while(order-- > 0)
+ rtn_value = *coeffs-- + (x * rtn_value);
+#endif
+
+ return(rtn_value);
+}
+
+
+/*
+ * FUNCTION
+ *
+ * _XcmsSine double precision sine
+ *
+ * KEY WORDS
+ *
+ * sin
+ * machine independent routines
+ * trigonometric functions
+ * math libraries
+ *
+ * DESCRIPTION
+ *
+ * Returns double precision sine of double precision
+ * floating point argument.
+ *
+ * USAGE
+ *
+ * double _XcmsSine (x)
+ * double x;
+ *
+ * REFERENCES
+ *
+ * Computer Approximations, J.F. Hart et al, John Wiley & Sons,
+ * 1968, pp. 112-120.
+ *
+ * RESTRICTIONS
+ *
+ * The sin and cos routines are interactive in the sense that
+ * in the process of reducing the argument to the range -PI/4
+ * to PI/4, each may call the other. Ultimately one or the
+ * other uses a polynomial approximation on the reduced
+ * argument. The sin approximation has a maximum relative error
+ * of 10**(-17.59) and the cos approximation has a maximum
+ * relative error of 10**(-16.18).
+ *
+ * These error bounds assume exact arithmetic
+ * in the polynomial evaluation. Additional rounding and
+ * truncation errors may occur as the argument is reduced
+ * to the range over which the polynomial approximation
+ * is valid, and as the polynomial is evaluated using
+ * finite-precision arithmetic.
+ *
+ * PROGRAMMER
+ *
+ * Fred Fish
+ *
+ * INTERNALS
+ *
+ * Computes sin(x) from:
+ *
+ * (1) Reduce argument x to range -PI to PI.
+ *
+ * (2) If x > PI/2 then call sin recursively
+ * using relation sin(x) = -sin(x - PI).
+ *
+ * (3) If x < -PI/2 then call sin recursively
+ * using relation sin(x) = -sin(x + PI).
+ *
+ * (4) If x > PI/4 then call cos using
+ * relation sin(x) = cos(PI/2 - x).
+ *
+ * (5) If x < -PI/4 then call cos using
+ * relation sin(x) = -cos(PI/2 + x).
+ *
+ * (6) If x is small enough that polynomial
+ * evaluation would cause underflow
+ * then return x, since sin(x)
+ * approaches x as x approaches zero.
+ *
+ * (7) By now x has been reduced to range
+ * -PI/4 to PI/4 and the approximation
+ * from HART pg. 118 can be used:
+ *
+ * sin(x) = y * ( p(y) / q(y) )
+ * Where:
+ *
+ * y = x * (4/PI)
+ *
+ * p(y) = SUM [ Pj * (y**(2*j)) ]
+ * over j = {0,1,2,3}
+ *
+ * q(y) = SUM [ Qj * (y**(2*j)) ]
+ * over j = {0,1,2,3}
+ *
+ * P0 = 0.206643433369958582409167054e+7
+ * P1 = -0.18160398797407332550219213e+6
+ * P2 = 0.359993069496361883172836e+4
+ * P3 = -0.2010748329458861571949e+2
+ * Q0 = 0.263106591026476989637710307e+7
+ * Q1 = 0.3927024277464900030883986e+5
+ * Q2 = 0.27811919481083844087953e+3
+ * Q3 = 1.0000...
+ * (coefficients from HART table #3063 pg 234)
+ *
+ *
+ * **** NOTE **** The range reduction relations used in
+ * this routine depend on the final approximation being valid
+ * over the negative argument range in addition to the positive
+ * argument range. The particular approximation chosen from
+ * HART satisfies this requirement, although not explicitly
+ * stated in the text. This may not be true of other
+ * approximations given in the reference.
+ *
+ */
+
+double
+_XcmsSine (x)
+double x;
+{
+ double y;
+ double yt2;
+ double retval;
+
+ if (x < -XCMS_PI || x > XCMS_PI) {
+ x = _XcmsModulo (x, XCMS_TWOPI);
+ if (x > XCMS_PI) {
+ x = x - XCMS_TWOPI;
+ } else if (x < -XCMS_PI) {
+ x = x + XCMS_TWOPI;
+ }
+ }
+ if (x > XCMS_HALFPI) {
+ retval = -(_XcmsSine (x - XCMS_PI));
+ } else if (x < -XCMS_HALFPI) {
+ retval = -(_XcmsSine (x + XCMS_PI));
+ } else if (x > XCMS_FOURTHPI) {
+ retval = _XcmsCosine (XCMS_HALFPI - x);
+ } else if (x < -XCMS_FOURTHPI) {
+ retval = -(_XcmsCosine (XCMS_HALFPI + x));
+ } else if (x < XCMS_X6_UNDERFLOWS && x > -XCMS_X6_UNDERFLOWS) {
+ retval = x;
+ } else {
+ y = x / XCMS_FOURTHPI;
+ yt2 = y * y;
+ retval = y * (_XcmsPolynomial (3, sin_pcoeffs, yt2) / _XcmsPolynomial(3, sin_qcoeffs, yt2));
+ }
+ return(retval);
+}
+
+
+/*
+ * NAME
+ * _XcmsArcTangent
+ *
+ * SYNOPSIS
+ */
+double
+_XcmsArcTangent(x)
+ double x;
+/*
+ * DESCRIPTION
+ * Computes the arctangent.
+ * This is an implementation of the Gauss algorithm as
+ * described in:
+ * Forman S. Acton, Numerical Methods That Work,
+ * New York, NY, Harper & Row, 1970.
+ *
+ * RETURNS
+ * Returns the arctangent
+ */
+{
+ double ai, a1 = 0.0, bi, b1 = 0.0, l, d;
+ double maxerror;
+ int i;
+
+ if (x == 0.0) {
+ return (0.0);
+ }
+ if (x < 1.0) {
+ maxerror = x * XCMS_MAXERROR;
+ } else {
+ maxerror = XCMS_MAXERROR;
+ }
+ ai = _XcmsSquareRoot( 1.0 / (1.0 + (x * x)) );
+ bi = 1.0;
+ for (i = 0; i < XCMS_MAXITER; i++) {
+ a1 = (ai + bi) / 2.0;
+ b1 = _XcmsSquareRoot((a1 * bi));
+ if (a1 == b1)
+ break;
+ d = XCMS_FABS(a1 - b1);
+ if (d < maxerror)
+ break;
+ ai = a1;
+ bi = b1;
+ }
+
+ l = ((a1 > b1) ? b1 : a1);
+
+ a1 = _XcmsSquareRoot(1 + (x * x));
+ return (x / (a1 * l));
+}
diff --git a/nx-X11/lib/X11/cursorfont.h b/nx-X11/lib/X11/cursorfont.h
new file mode 100644
index 000000000..c6204f1c5
--- /dev/null
+++ b/nx-X11/lib/X11/cursorfont.h
@@ -0,0 +1,107 @@
+/* $Xorg: cursorfont.h,v 1.4 2001/02/09 02:03:39 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.
+
+*/
+
+#define XC_num_glyphs 154
+#define XC_X_cursor 0
+#define XC_arrow 2
+#define XC_based_arrow_down 4
+#define XC_based_arrow_up 6
+#define XC_boat 8
+#define XC_bogosity 10
+#define XC_bottom_left_corner 12
+#define XC_bottom_right_corner 14
+#define XC_bottom_side 16
+#define XC_bottom_tee 18
+#define XC_box_spiral 20
+#define XC_center_ptr 22
+#define XC_circle 24
+#define XC_clock 26
+#define XC_coffee_mug 28
+#define XC_cross 30
+#define XC_cross_reverse 32
+#define XC_crosshair 34
+#define XC_diamond_cross 36
+#define XC_dot 38
+#define XC_dotbox 40
+#define XC_double_arrow 42
+#define XC_draft_large 44
+#define XC_draft_small 46
+#define XC_draped_box 48
+#define XC_exchange 50
+#define XC_fleur 52
+#define XC_gobbler 54
+#define XC_gumby 56
+#define XC_hand1 58
+#define XC_hand2 60
+#define XC_heart 62
+#define XC_icon 64
+#define XC_iron_cross 66
+#define XC_left_ptr 68
+#define XC_left_side 70
+#define XC_left_tee 72
+#define XC_leftbutton 74
+#define XC_ll_angle 76
+#define XC_lr_angle 78
+#define XC_man 80
+#define XC_middlebutton 82
+#define XC_mouse 84
+#define XC_pencil 86
+#define XC_pirate 88
+#define XC_plus 90
+#define XC_question_arrow 92
+#define XC_right_ptr 94
+#define XC_right_side 96
+#define XC_right_tee 98
+#define XC_rightbutton 100
+#define XC_rtl_logo 102
+#define XC_sailboat 104
+#define XC_sb_down_arrow 106
+#define XC_sb_h_double_arrow 108
+#define XC_sb_left_arrow 110
+#define XC_sb_right_arrow 112
+#define XC_sb_up_arrow 114
+#define XC_sb_v_double_arrow 116
+#define XC_shuttle 118
+#define XC_sizing 120
+#define XC_spider 122
+#define XC_spraycan 124
+#define XC_star 126
+#define XC_target 128
+#define XC_tcross 130
+#define XC_top_left_arrow 132
+#define XC_top_left_corner 134
+#define XC_top_right_corner 136
+#define XC_top_side 138
+#define XC_top_tee 140
+#define XC_trek 142
+#define XC_ul_angle 144
+#define XC_umbrella 146
+#define XC_ur_angle 148
+#define XC_watch 150
+#define XC_xterm 152
diff --git a/nx-X11/lib/X11/evtomask.c b/nx-X11/lib/X11/evtomask.c
new file mode 100644
index 000000000..fbbb998d3
--- /dev/null
+++ b/nx-X11/lib/X11/evtomask.c
@@ -0,0 +1,76 @@
+/* $Xorg: evtomask.c,v 1.4 2001/02/09 02:03:39 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.
+
+*/
+/* $XFree86: xc/lib/X11/evtomask.c,v 3.4 2001/07/29 05:01:11 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/X.h>
+
+/*
+ * This array can be used given an event type to determine the mask bits
+ * that could have generated it.
+ */
+long const _Xevent_to_mask [LASTEvent] = {
+ 0, /* no event 0 */
+ 0, /* no event 1 */
+ KeyPressMask, /* KeyPress */
+ KeyReleaseMask, /* KeyRelease */
+ ButtonPressMask, /* ButtonPress */
+ ButtonReleaseMask, /* ButtonRelease */
+ PointerMotionMask|PointerMotionHintMask|Button1MotionMask|
+ Button2MotionMask|Button3MotionMask|Button4MotionMask|
+ Button5MotionMask|ButtonMotionMask, /* MotionNotify */
+ EnterWindowMask, /* EnterNotify */
+ LeaveWindowMask, /* LeaveNotify */
+ FocusChangeMask, /* FocusIn */
+ FocusChangeMask, /* FocusOut */
+ KeymapStateMask, /* KeymapNotify */
+ ExposureMask, /* Expose */
+ ExposureMask, /* GraphicsExpose */
+ ExposureMask, /* NoExpose */
+ VisibilityChangeMask, /* VisibilityNotify */
+ SubstructureNotifyMask, /* CreateNotify */
+ StructureNotifyMask|SubstructureNotifyMask, /* DestroyNotify */
+ StructureNotifyMask|SubstructureNotifyMask, /* UnmapNotify */
+ StructureNotifyMask|SubstructureNotifyMask, /* MapNotify */
+ SubstructureRedirectMask, /* MapRequest */
+ SubstructureNotifyMask|StructureNotifyMask, /* ReparentNotify */
+ StructureNotifyMask|SubstructureNotifyMask, /* ConfigureNotify */
+ SubstructureRedirectMask, /* ConfigureRequest */
+ SubstructureNotifyMask|StructureNotifyMask, /* GravityNotify */
+ ResizeRedirectMask, /* ResizeRequest */
+ SubstructureNotifyMask|StructureNotifyMask, /* CirculateNotify */
+ SubstructureRedirectMask, /* CirculateRequest */
+ PropertyChangeMask, /* PropertyNotify */
+ 0, /* SelectionClear */
+ 0, /* SelectionRequest */
+ 0, /* SelectionNotify */
+ ColormapChangeMask, /* ColormapNotify */
+ 0, /* ClientMessage */
+ 0, /* MappingNotify */
+};
diff --git a/nx-X11/lib/X11/globals.c b/nx-X11/lib/X11/globals.c
new file mode 100644
index 000000000..11965cb5f
--- /dev/null
+++ b/nx-X11/lib/X11/globals.c
@@ -0,0 +1,238 @@
+/* $Xorg: globals.c,v 1.4 2001/02/09 02:03:39 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.
+
+*/
+/* $XFree86: xc/lib/X11/globals.c,v 3.4 2001/07/29 05:01:11 tsi Exp $ */
+
+/*
+ *
+ * Global data
+ *
+ * This file should contain only those objects which must be predefined.
+ */
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+
+
+/*
+ * If possible, it is useful to have the global data default to a null value.
+ * Some shared library implementations are *much* happier if there isn't any
+ * global initialized data.
+ */
+#ifdef NULL_NOT_ZERO /* then need to initialize */
+#define SetZero(t,var,z) t var = z
+#else
+#define SetZero(t,var,z) t var
+#endif
+
+#ifdef USL_SHAREDLIB /* then need extra variables */
+/*
+ * If we need to define extra variables for each global
+ */
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define ZEROINIT(t,var,val) SetZero(t,var,val); \
+ SetZero (long, _libX_##var##Flag, 0); \
+ SetZero (void *, _libX_##var##Ptr, NULL)
+#else /* else pcc concatenation */
+#define ZEROINIT(t,var,val) SetZero(t,var,val); \
+ SetZero (long, _libX_/**/var/**/Flag, 0); \
+ SetZero (void *, _libX_/**/var/**/Ptr, NULL)
+#endif /* concat ANSI C vs. pcc */
+
+#else /* else not USL_SHAREDLIB */
+/*
+ * no extra crud
+ */
+#define ZEROINIT(t,var,val) SetZero (t, var, val)
+
+#endif /* USL_SHAREDLIB */
+
+
+/*
+ * Error handlers; used to be in XlibInt.c
+ */
+ZEROINIT (XErrorHandler, _XErrorFunction, NULL);
+ZEROINIT (XIOErrorHandler, _XIOErrorFunction, NULL);
+ZEROINIT (_XQEvent *, _qfree, NULL);
+
+
+/*
+ * Debugging information and display list; used to be in XOpenDis.c
+ */
+ZEROINIT (int, _Xdebug, 0);
+ZEROINIT (Display *, _XHeadOfDisplayList, NULL);
+
+
+
+#if 0
+#ifdef STREAMSCONN
+
+
+/* The following are how the Xstream connections are used: */
+/* 1) Local connections over pseudo-tty ports. */
+/* 2) SVR4 local connections using named streams or SVR3.2 */
+/* local connections using streams. */
+/* 3) SVR4 stream pipe code. This code is proprietary and */
+/* the actual code is not included in the XC distribution. */
+/* 4) remote connections using tcp */
+/* 5) remote connections using StarLan */
+
+/*
+ * descriptor block for streams connections
+ */
+
+#include "Xstreams.h"
+
+char _XsTypeOfStream[100] = { 0 };
+
+extern int write();
+extern int close();
+#ifdef SVR4
+extern int _XsSetupSpStream();
+extern int _XsSetupNamedStream();
+#endif
+extern int _XsSetupLocalStream();
+extern int _XsConnectLocalClient();
+extern int _XsCallLocalServer();
+extern int _XsReadLocalStream();
+extern int _XsErrorCall();
+extern int _XsWriteLocalStream();
+extern int _XsCloseLocalStream();
+extern int _XsSetupTliStream();
+extern int _XsConnectTliClient();
+extern int _XsCallTliServer();
+extern int _XsReadTliStream();
+extern int _XsWriteTliStream();
+extern int _XsCloseTliStream();
+
+
+Xstream _XsStream[] = {
+
+ {
+ /* local connections using pseudo-ttys */
+
+ _XsSetupLocalStream,
+ _XsConnectLocalClient,
+ _XsCallLocalServer,
+ _XsReadLocalStream,
+ _XsErrorCall,
+ write,
+ close,
+ NULL
+ },
+ {
+#ifdef SVR4
+ /* local connections using named streams */
+
+ _XsSetupNamedStream,
+#else
+ /* local connections using streams */
+ _XsSetupLocalStream,
+#endif
+ _XsConnectLocalClient,
+ _XsCallLocalServer,
+ _XsReadLocalStream,
+ _XsErrorCall,
+ write,
+ close,
+ NULL
+ },
+ /* Enhanced Application Compatibility Support */
+ {
+#ifdef SVR4
+ /* SVR4 stream pipe code */
+ _XsSetupSpStream,
+#else
+ _XsSetupLocalStream,
+#endif
+ _XsConnectLocalClient,
+ _XsCallLocalServer,
+ _XsReadLocalStream,
+ _XsErrorCall,
+ write,
+ close,
+ NULL
+ },
+ /* End Enhanced Application Compatibility Support */
+
+ {
+ /* remote connections using tcp */
+ _XsSetupTliStream,
+ _XsConnectTliClient,
+ _XsCallTliServer,
+ _XsReadLocalStream,
+ _XsErrorCall,
+ write,
+ close,
+ NULL
+ },
+ {
+ /* remote connections using StarLan */
+ _XsSetupTliStream,
+ _XsConnectTliClient,
+ _XsCallTliServer,
+ _XsReadLocalStream,
+ _XsErrorCall,
+ write,
+ close,
+ NULL
+ }
+};
+
+
+#endif /* STREAMSCONN */
+#endif
+
+
+#ifdef XTEST1
+/*
+ * Stuff for input synthesis extension:
+ */
+/*
+ * Holds the two event type codes for this extension. The event type codes
+ * for this extension may vary depending on how many extensions are installed
+ * already, so the initial values given below will be added to the base event
+ * code that is aquired when this extension is installed.
+ *
+ * These two variables must be available to programs that use this extension.
+ */
+int XTestInputActionType = 0;
+int XTestFakeAckType = 1;
+#endif
+
+/*
+ * NOTE: any additional external definition NEED
+ * to be inserted BELOW this point!!!
+ */
+
+/*
+ * NOTE: any additional external definition NEED
+ * to be inserted ABOVE this point!!!
+ */
diff --git a/nx-X11/lib/X11/imCallbk.c b/nx-X11/lib/X11/imCallbk.c
new file mode 100644
index 000000000..867746cbb
--- /dev/null
+++ b/nx-X11/lib/X11/imCallbk.c
@@ -0,0 +1,754 @@
+/* $Xorg: imCallbk.c,v 1.4 2000/08/17 19:45:10 cpqbld Exp $ */
+/***********************************************************************
+Copyright 1993 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1994 by FUJITSU LIMITED
+Copyright 1994 by Sony Corporation
+
+ 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 names of Digital, FUJITSU
+LIMITED and Sony Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission.
+
+DIGITAL, FUJITSU LIMITED AND SONY CORPORATION DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL, FUJITSU LIMITED
+AND SONY CORPORATION 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.
+
+ Author: Hiroyuki Miyamoto Digital Equipment Corporation
+ miyamoto@jrd.dec.com
+ Modifier: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+
+***********************************************************************/
+/* $XFree86: xc/lib/X11/imCallbk.c,v 3.9 2003/08/22 13:29:16 pascal Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XlcPubI.h"
+#ifdef X_LOCALE
+#define mblen(a,b) _Xmblen(a,b)
+extern int _Xmblen ();
+#endif
+
+#define sz_CARD8 1
+#define sz_INT8 1
+#define sz_CARD16 2
+#define sz_INT16 2
+#define sz_BITMASK16 sz_CARD16
+#define sz_CARD32 4
+#define sz_INT32 4
+#define sz_BITMASK32 sz_CARD32
+#define sz_XIMID sizeof(XIMID)
+#define sz_XICID sizeof(XICID)
+#define sz_XIMATTRID sizeof(XIMATTRID)
+#define sz_XICATTRID sizeof(XICATTRID)
+#define sz_ximPacketHeader (XIM_HEADER_SIZE + sz_XIMID + sz_XICID)
+#define sz_ximGeometry 0
+#define sz_ximStrConversion (sz_CARD32 + sz_CARD32 + sz_CARD32 + sz_CARD32)
+#define sz_ximPreeditStart 0
+#define sz_ximPreeditStartReply sz_INT32
+#define sz_ximPreeditCaret (sz_INT32 + sz_CARD32 + sz_CARD32)
+#define sz_ximPreeditCaretReply sz_CARD32
+#define sz_ximPreeditDone 0
+#define sz_ximStatusStart 0
+#define sz_ximStatusDone 0
+
+typedef enum {
+ XimCbSuccess,
+ XimCbNoCallback,
+ XimCbError,
+ XimCbQueued,
+ XimCbBadContextID,
+ XimCbBadOpcode
+} XimCbStatus;
+
+typedef XimCbStatus (*XimCb)(
+ Xim, Xic, char*, int
+ );
+
+#define PACKET_TO_MAJOROPCODE(p) (*(CARD8*)((CARD8*)(p)))
+#define PACKET_TO_MINOROPCODE(p) (*(CARD8*)((CARD8*)(p) + sz_CARD8))
+#define PACKET_TO_LENGTH(p) (*(CARD16*)((CARD8*)(p) + sz_CARD8 + sz_CARD8))
+#define PACKET_TO_IMID(p) (*(XIMID*)((CARD8*)(p) + XIM_HEADER_SIZE))
+#define PACKET_TO_ICID(p) (*(XICID*)((CARD8*)(p) + XIM_HEADER_SIZE + sz_XIMID))
+
+#define _XimWriteData(im,len,data) \
+ (im->private.proto.write((im),(len),(XPointer)(data)))
+#define _XimReadData(im,buf,buf_len,len) \
+ (im->private.proto.read((im),(XPointer)(buf),(buf_len),&(len)))
+#define _XimFlushData(im) im->private.proto.flush((im))
+
+Private XimCbStatus _XimGeometryCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimStrConversionCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimPreeditStartCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimPreeditDoneCallback(Xim, Xic, char*, int);
+Private void _free_memory_for_text(XIMText*);
+Private XimCbStatus _XimPreeditDrawCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimPreeditCaretCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimStatusStartCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimStatusDoneCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimStatusDrawCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimPreeditStateNotifyCallback(Xim, Xic, char *, int);
+
+#if defined(__STDC__) && ((defined(sun) && defined(SVR4)) || defined(WIN32))
+#define RConst /**/
+#else
+#define RConst const
+#endif
+
+/* NOTE:
+ * the table below depends on the protocol number
+ * defined in the IM Protocol document.
+ */
+static RConst XimCb callback_table[] = {
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #000-009 */
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #010-019 */
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #020-029 */
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #030-039 */
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #040-049 */
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #050-059 */
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #060-069 */
+ _XimGeometryCallback, /* #070 */
+ _XimStrConversionCallback, /* #071 */
+ NULL, /* #072 */
+ _XimPreeditStartCallback, /* #073 */
+ NULL, /* #074 */
+ _XimPreeditDrawCallback, /* #075 */
+ _XimPreeditCaretCallback, /* #076 */
+ NULL, /* #077 */
+ _XimPreeditDoneCallback, /* #078 */
+ _XimStatusStartCallback, /* #079 */
+ _XimStatusDrawCallback, /* #080 */
+ _XimStatusDoneCallback, /* #081 */
+ _XimPreeditStateNotifyCallback /* #082 */
+ };
+
+
+Private Bool
+_XimIsReadyForProcess(Xic ic)
+{
+ return(!ic->private.proto.waitCallback); /* check HM */
+}
+
+Private void
+_XimProcessPendingCallbacks(Xic ic)
+{
+ XimPendingCallback pcbq;
+
+ while (((pcbq = ic->private.proto.pend_cb_que) != (XimPendingCallback)NULL)
+ && _XimIsReadyForProcess(ic)) {
+ (void) (*callback_table[pcbq->major_opcode])(pcbq->im,
+ pcbq->ic,
+ pcbq->proto,
+ pcbq->proto_len);
+ ic->private.proto.pend_cb_que = pcbq->next;
+ Xfree(pcbq->proto); /* free memory of XimPendingCallback */
+ Xfree(pcbq);
+ }
+}
+
+Private void
+_XimPutCbIntoQueue(Xic ic, XimPendingCallback call_data)
+{
+ XimPendingCallback pcbq = ic->private.proto.pend_cb_que;
+
+ /* Queuing is FIFO
+ */
+ while (pcbq != (XimPendingCallback)NULL) {
+ if (pcbq->next == (XimPendingCallback)NULL) {
+ break;
+ }
+ pcbq = pcbq->next;
+ }
+ if (pcbq == (XimPendingCallback)NULL) {
+ ic->private.proto.pend_cb_que = call_data;
+ }
+ else {
+ pcbq->next = call_data;
+ }
+}
+
+Public Bool
+_XimCbDispatch(Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+{
+ /* `data' points to the beginning of the packet defined in IM Protocol doc.
+ */
+ int major_opcode = PACKET_TO_MAJOROPCODE(data);
+ XIMID imid = PACKET_TO_IMID(data);
+ XICID icid = PACKET_TO_ICID(data);
+ Xim im = (Xim)call_data; /* check HM */
+ Xic ic = _XimICOfXICID(im, icid);
+ char* proto;
+ int proto_len;
+
+ /* check validity of im/ic
+ */
+ if ((imid != im->private.proto.imid) || !ic) {
+ return False; /* status = XimCbBadContextID; */
+ }
+
+ /* process pending callbacks
+ */
+ _XimProcessPendingCallbacks(ic);
+
+ /* check if the protocol should be processed here
+ */
+ if (major_opcode > 82) {
+ return False; /* status = XimCbBadOpcode; */
+ }
+ if (!callback_table[major_opcode]) {
+ return False; /* status = XimCbBadOpcode; */
+ }
+
+ /* move the pointer ahead by the IM Protocol packet header size
+ */
+ proto = (char*)data + sz_ximPacketHeader;
+ proto_len = (int)len - sz_ximPacketHeader;
+
+ /* check if it can be processed right away
+ * and if no, queue the protocol, otherwise invoke a callback
+ */
+ if (!_XimIsReadyForProcess(ic)) {
+
+ /* queue the protocol
+ */
+ XimPendingCallback pcb;
+ char *proto_buf = (proto_len > 0) ? (char*)Xmalloc(proto_len) : NULL;
+
+ pcb = (XimPendingCallback)Xmalloc(sizeof(XimPendingCallbackRec));
+ if (pcb && (proto_len <= 0 || proto_buf)) {
+ if (proto_len > 0)
+ memcpy(proto_buf, proto, proto_len);
+
+ pcb->major_opcode = major_opcode;
+ pcb->im = im;
+ pcb->ic = ic;
+ pcb->proto = proto_buf;
+ pcb->proto_len = proto_len;
+ pcb->next = (XimPendingCallback)NULL; /* queue is FIFO */
+ _XimPutCbIntoQueue(ic, pcb);
+ /* status = XimCbQueued; */
+ } else {
+ /* status = XimCbError; */
+ }
+ }
+ else {
+ /* invoke each callback according to the major opcode.
+ * `proto' points to the next address of IM-ID and IC-ID.
+ * `proto_len' specifies the packet length.
+ */
+ (void) (*callback_table[major_opcode])(im, ic, proto, proto_len);
+ }
+ return True;
+}
+
+Private XimCbStatus
+_XimGeometryCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+{
+ XICCallback* cb = &ic->core.geometry_callback;
+
+ /* invoke the callack
+ */
+ if (cb && cb->callback) {
+ (*cb->callback)((XIC)ic, cb->client_data, (XPointer)NULL);
+ }
+ else {
+
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+_XimStrConversionCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+{
+ XICCallback* cb = &ic->core.string_conversion_callback; /* check HM */
+ XIMStringConversionCallbackStruct cbrec;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ int p = XIM_HEADER_SIZE;
+ cbrec.position = (XIMStringConversionPosition)
+ *(CARD32*)&proto[p]; p += sz_CARD32;
+ cbrec.direction = (XIMCaretDirection)
+ *(CARD32*)&proto[p]; p += sz_CARD32;
+ cbrec.operation = (XIMStringConversionOperation)
+ *(CARD32*)&proto[p]; p += sz_CARD32;
+ cbrec.factor = (unsigned short)
+ *(CARD32*)&proto[p];
+
+ (*cb->callback)((XIC)ic, cb->client_data, (XPointer)&cbrec);
+ }
+ else {
+
+ /* no callback registered
+ */
+ _XimError(im, ic,
+ (CARD16)XIM_BadSomething,
+ (INT16)len,
+ (CARD16)XIM_STR_CONVERSION,
+ (char*)proto); /* send XIM_ERROR */
+ return XimCbNoCallback;
+ }
+
+ /* send a reply
+ */
+ {
+ CARD8 *buf;
+ INT16 buf_len;
+ int p, length_in_bytes, i;
+
+ /* Assumption:
+ * `cbrec.text->length' means the string length in characters
+ */
+ {
+ length_in_bytes = (cbrec.text->encoding_is_wchar)?
+ sizeof(wchar_t) * cbrec.text->length: /* wchar */
+ strlen(cbrec.text->string.mbs); /* mb */
+ buf_len = XIM_HEADER_SIZE +
+ sz_CARD16 +
+ 2 + length_in_bytes +
+ XIM_PAD(2 + length_in_bytes) +
+ 2 + 2 + sz_CARD32 * cbrec.text->length;
+ buf = (CARD8*)Xmalloc(buf_len);
+ }
+ _XimSetHeader((XPointer)buf, XIM_STR_CONVERSION_REPLY, 0, &buf_len);
+ buf_len -= XIM_HEADER_SIZE; /* added by _XimSetHeader (HACK) */
+ p = XIM_HEADER_SIZE;
+ *(CARD16*)&buf[p] = (CARD16)im->private.proto.imid; p += sz_CARD16;
+ *(CARD16*)&buf[p] = (CARD16)ic->private.proto.icid; p += sz_CARD16;
+ *(CARD16*)&buf[p] = (CARD16)cbrec.text->length; p += sz_CARD16;
+ memcpy(&buf[p],&cbrec.text->string.mbs,length_in_bytes);
+ p += length_in_bytes;
+ *(CARD16*)&buf[p] = (CARD16)(sz_CARD32*cbrec.text->length);
+ p += XIM_PAD(2);
+ for (i = 0; i < (int)cbrec.text->length; i++) {
+ *(CARD32*)&buf[p] = (CARD32)cbrec.text->feedback[i];
+ p += sz_CARD32;
+ }
+
+ if (!(_XimWriteData(im, buf_len, buf))) {
+ return XimCbError;
+ }
+ _XimFlushData(im);
+
+ Xfree(buf);
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+_XimPreeditStartCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+{
+ XICCallback* cb = &ic->core.preedit_attr.start_callback;
+ int ret;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback){
+ ret = (*(cb->callback))((XIC)ic, cb->client_data, (XPointer)NULL);
+ }
+ else {
+
+ /* no callback registered
+ */
+ _XimError(im, ic,
+ (CARD16)XIM_BadSomething,
+ (INT16)len,
+ (CARD16)XIM_PREEDIT_START,
+ (char*)proto); /* send XIM_ERROR */
+ return XimCbNoCallback;
+ }
+
+ /* send a reply
+ */
+ {
+ CARD32 buf32[(sz_ximPacketHeader + sz_ximPreeditStartReply) / 4];
+ CARD8 *buf = (CARD8 *)buf32;
+ INT16 buf_len = sz_XIMID + sz_XICID + sz_ximPreeditStartReply;
+ int p;
+
+ _XimSetHeader((XPointer)buf, XIM_PREEDIT_START_REPLY, 0, &buf_len);
+ p = XIM_HEADER_SIZE;
+ *(CARD16*)&buf[p] = (CARD16)im->private.proto.imid; p += sz_CARD16;
+ *(CARD16*)&buf[p] = (CARD16)ic->private.proto.icid; p += sz_CARD16;
+ *(INT32*)&buf[p] = (INT32)ret;
+
+ if (!(_XimWriteData(im, buf_len, buf))) {
+ return XimCbError;
+ }
+ _XimFlushData(im);
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+_XimPreeditDoneCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+{
+ XICCallback* cb = &ic->core.preedit_attr.done_callback;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ (*cb->callback)((XIC)ic, cb->client_data, (XPointer)NULL);
+ }
+ else {
+
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
+Private void
+_read_text_from_packet(Xim im,
+ char* buf,
+ XIMText** text_ptr)
+{
+ int status;
+ XIMText* text;
+ int tmp_len;
+ char* tmp_buf;
+ Status s = 0;
+
+ status = (int)*(BITMASK32*)buf; buf += sz_BITMASK32;
+
+ /* string part
+ */
+ if (status & 0x00000001) /* "no string" bit on */ {
+ buf += sz_CARD16; /* skip "length of preedit string" */
+ buf += 2; /* pad */
+ *text_ptr = (XIMText*)NULL;
+ return;
+ }
+
+ *text_ptr = text = (XIMText*)Xmalloc(sizeof(XIMText));
+ if (text == (XIMText*)NULL) return;
+
+ tmp_len = (int)*(CARD16*)buf;
+ buf += sz_CARD16;
+ if ((tmp_buf = (char*)Xmalloc(tmp_len + 1))) {
+ memcpy(tmp_buf, buf, tmp_len);
+ tmp_buf[tmp_len] = '\0';
+
+ text->encoding_is_wchar = False;
+ text->length = im->methods->ctstombs((XIM)im,
+ tmp_buf, tmp_len,
+ NULL, 0, &s); /* CT? HM */
+ if (s != XLookupNone) {
+#ifndef NO_DEC_I18N_FIX
+ /* Allow for NULL-terminated */
+ if ((text->string.multi_byte =
+ (char*)Xmalloc(text->length *
+ XLC_PUBLIC(im->core.lcd,mb_cur_max) + 1))) {
+#else
+ if (text->string.multi_byte = (char*)Xmalloc(text->length+1)) {
+#endif
+ int tmp;
+#ifndef NO_DEC_I18N_FIX
+ char *char_tmp;
+ int char_len;
+#endif
+ tmp = im->methods->ctstombs((XIM)im,
+ tmp_buf, tmp_len,
+#ifndef NO_DEC_I18N_FIX
+ text->string.multi_byte,
+ text->length * XLC_PUBLIC(im->core.lcd,mb_cur_max) + 1,
+#else
+ text->string.multi_byte, text->length,
+#endif
+ &s);
+ text->string.multi_byte[tmp] = '\0';
+#ifndef NO_DEC_I18N_FIX
+ text->length = 0;
+ char_tmp = text->string.multi_byte;
+ while (*char_tmp != '\0') {
+ char_len = mblen(char_tmp, strlen(char_tmp));
+ char_tmp = char_tmp + char_len;
+ (text->length)++;
+ }
+#endif
+ }
+ }
+ else {
+ text->length = 0;
+ text->string.multi_byte = NULL;
+ }
+
+ Xfree(tmp_buf);
+ }
+ buf += tmp_len;
+
+ buf += XIM_PAD(sz_CARD16 + tmp_len); /* pad */
+
+ /* feedback part
+ */
+ if (status & 0x00000002) /* "no feedback" bit on */ {
+ text->feedback = (XIMFeedback*)NULL;
+ }
+ else {
+ int i, j;
+
+ i = (int)*(CARD16*)buf; buf += sz_CARD16;
+ buf += sz_CARD16; /* skip `unused' */
+ text->feedback = (XIMFeedback*)Xmalloc(i*(sizeof(XIMFeedback)/sizeof(CARD32)));
+ j = 0;
+ while (i > 0) {
+ text->feedback[j] = (XIMFeedback)*(CARD32*)buf;
+ buf += sz_CARD32;
+ i -= sz_CARD32;
+ j++;
+ }
+ /*
+ * text->length tells how long both the status string and
+ * the feedback array are. If there's "no string" the
+ * text->length was set to zero previously. See above.
+ * But if there is feedback (i.e. not "no feedback") then
+ * we need to convey the length of the feedback array.
+ * It might have been better if the protocol sent two
+ * different values, one for the length of the status
+ * string and one for the length of the feedback array.
+ */
+ if (status & 0x00000001) /* "no string" bit on */ {
+ text->length = j;
+ }
+ }
+}
+
+Private void
+_free_memory_for_text(XIMText* text)
+{
+ if (text) {
+ if (text->string.multi_byte)
+ Xfree(text->string.multi_byte);
+ if (text->feedback)
+ Xfree(text->feedback);
+ Xfree(text);
+ }
+}
+
+Private XimCbStatus
+_XimPreeditDrawCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+{
+ XICCallback* cb = &ic->core.preedit_attr.draw_callback;
+ XIMPreeditDrawCallbackStruct cbs;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ cbs.caret = (int)*(INT32*)proto; proto += sz_INT32;
+ cbs.chg_first = (int)*(INT32*)proto; proto += sz_INT32;
+ cbs.chg_length = (int)*(INT32*)proto; proto += sz_INT32;
+ _read_text_from_packet(im, proto, &cbs.text);
+
+ (*cb->callback)((XIC)ic, cb->client_data, (XPointer)&cbs);
+
+ _free_memory_for_text((XIMText*)cbs.text);
+ }
+ else {
+
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+_XimPreeditCaretCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+{
+ XICCallback* cb = &ic->core.preedit_attr.caret_callback;
+ XIMPreeditCaretCallbackStruct cbs;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ cbs.position = (int)*(INT32*)proto; proto += sz_INT32;
+ cbs.direction = (XIMCaretDirection)*(CARD32*)proto; proto += sz_CARD32;
+ cbs.style = (XIMCaretStyle)*(CARD32*)proto; proto += sz_CARD32;
+
+ (*cb->callback)((XIC)ic, cb->client_data, (XPointer)&cbs);
+ }
+ else {
+
+ /* no callback registered
+ */
+ _XimError(im, ic,
+ (CARD16)XIM_BadSomething,
+ (INT16)len,
+ (CARD16)XIM_PREEDIT_CARET,
+ (char*)proto); /* send XIM_ERROR */
+ return XimCbNoCallback;
+ }
+
+ /* Send a reply
+ */
+ {
+ CARD8 buf[sz_ximPacketHeader + sz_ximPreeditCaretReply];
+ INT16 len = sz_XIMID + sz_XICID + sz_ximPreeditCaretReply;
+ int p;
+
+ _XimSetHeader((XPointer)buf, XIM_PREEDIT_CARET_REPLY, 0, &len);
+ p = XIM_HEADER_SIZE;
+ *(CARD16*)&buf[p] = (CARD16)im->private.proto.imid; p += sz_CARD16;
+ *(CARD16*)&buf[p] = (CARD16)ic->private.proto.icid; p += sz_CARD16;
+ *(CARD32*)&buf[p] = (CARD32)cbs.position;
+
+ if (!(_XimWriteData(im, len, buf))) {
+ return XimCbError;
+ }
+ _XimFlushData(im);
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+_XimStatusStartCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+{
+ XICCallback* cb = &ic->core.status_attr.start_callback;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ (*cb->callback)((XIC)ic, cb->client_data, (XPointer)NULL);
+ }
+ else {
+
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+_XimStatusDoneCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+{
+ XICCallback* cb = &ic->core.status_attr.done_callback;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ (*cb->callback)((XIC)ic, cb->client_data, (XPointer)NULL);
+ }
+ else {
+
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+_XimStatusDrawCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+{
+ XICCallback* cb = &ic->core.status_attr.draw_callback;
+ XIMStatusDrawCallbackStruct cbs;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ cbs.type = (XIMStatusDataType)*(CARD32*)proto; proto += sz_CARD32;
+ if (cbs.type == XIMTextType) {
+ _read_text_from_packet(im, proto, &cbs.data.text);
+ }
+ else if (cbs.type == XIMBitmapType) {
+ cbs.data.bitmap = (Pixmap)*(CARD32*)proto;
+ }
+
+ (*cb->callback)((XIC)ic, cb->client_data, (XPointer)&cbs);
+
+ if (cbs.type == XIMTextType)
+ _free_memory_for_text((XIMText *)cbs.data.text);
+ }
+ else {
+
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+_XimPreeditStateNotifyCallback( Xim im, Xic ic, char* proto, int len )
+{
+ XICCallback *cb = &ic->core.preedit_attr.state_notify_callback;
+
+ /* invoke the callack
+ */
+ if( cb && cb->callback ) {
+ XIMPreeditStateNotifyCallbackStruct cbrec;
+
+ cbrec.state = *(BITMASK32 *)proto;
+ (*cb->callback)( (XIC)ic, cb->client_data, (XPointer)&cbrec );
+ }
+ else {
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
diff --git a/nx-X11/lib/X11/imConv.c b/nx-X11/lib/X11/imConv.c
new file mode 100644
index 000000000..f519401e4
--- /dev/null
+++ b/nx-X11/lib/X11/imConv.c
@@ -0,0 +1,359 @@
+/* $TOG: imConv.c /main/20 1998/06/17 15:46:41 kaleb $ */
+/******************************************************************
+
+ Copyright 1991, 1992 by Fuji Xerox Co.,Ltd.
+ Copyright 1993, 1994 by FUJITSU LIMITED
+
+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 of Fuji Xerox Co.,Ltd.
+, and that the name of FUJITSU LIMITED not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+ written prior permission.
+Fuji Xerox Co.,Ltd. , and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJI XEROX CO.,LTD. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJI XEROX CO.,LTD.
+AND FUJITSU LIMITED 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.
+
+ Auther: Kazunori Nishihara, Fuji Xerox Co.,Ltd.
+ kaz@ssdev.ksp.fujixerox.co.jp
+ Modifier: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* 2000 Modifier: Ivan Pascal The XFree86 Project.
+ */
+/* $XFree86: xc/lib/X11/imConv.c,v 1.32 2003/04/13 19:22:20 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XlcPubI.h"
+
+#ifdef XKB
+/*
+ * rather than just call _XLookupString (i.e. the pre-XKB XLookupString)
+ * do this because with XKB the event may have some funky modifiers that
+ * _XLookupString doesn't grok.
+ */
+#include "XKBlib.h"
+#define XLOOKUPSTRING lookup_string
+#else
+#define XLOOKUPSTRING XLookupString
+#endif
+
+typedef unsigned int ucs4_t;
+
+typedef int (*ucstocsConvProc)(
+ XPointer,
+ unsigned char *,
+ ucs4_t,
+ int
+);
+
+struct SubstRec {
+ char* encoding_name;
+ char* charset_name;
+};
+
+static struct SubstRec SubstTable[] = {
+ {"STRING", "ISO8859-1"},
+ {"TIS620", "TIS620-0"},
+ {"UTF-8", "ISO10646-1"}
+};
+#define num_substitute (sizeof SubstTable / sizeof SubstTable[0])
+
+/*
+ * Given the name of a charset, returns the pointer to convertors
+ * from UCS char to specified charset char.
+ * This converter is needed for _XimGetCharCode subroutine.
+ */
+XPointer
+_XimGetLocaleCode (
+ _Xconst char* encoding_name)
+{
+ XPointer cvt = _Utf8GetConvByName(encoding_name);
+ if (!cvt && encoding_name) {
+ int i;
+ for (i = 0; i < num_substitute; i++)
+ if (!strcmp(encoding_name, SubstTable[i].encoding_name))
+ return _Utf8GetConvByName(SubstTable[i].charset_name);
+ }
+ return cvt;
+}
+
+/*
+ * Returns the locale dependent representation of a keysym.
+ * The locale's encoding is passed in form of pointer to UCS convertor.
+ * The resulting multi-byte sequence is placed starting at buf (a buffer
+ * with nbytes bytes, nbytes should be >= 8) and is NUL terminated.
+ * Returns the length of the resulting multi-byte sequence, excluding the
+ * terminating NUL byte. Return 0 if the keysym is not representable in the
+ * locale
+ */
+/*ARGSUSED*/
+int
+_XimGetCharCode (
+ XPointer ucs_conv,
+ KeySym keysym,
+ unsigned char* buf,
+ int nbytes)
+{
+ int count = 0;
+ ucstocsConvProc cvt = (ucstocsConvProc) ucs_conv;
+ ucs4_t ucs4;
+
+ if (keysym < 0x80) {
+ buf[0] = (char) keysym;
+ count = 1;
+ } else if (cvt) {
+ ucs4 = KeySymToUcs4(keysym);
+ if (ucs4)
+ count = (*cvt)((XPointer)NULL, buf, ucs4, nbytes);
+ }
+
+ if (count < 0)
+ count = 0;
+ if (count>nbytes)
+ return nbytes;
+ if (count<nbytes)
+ buf[count]= '\0';
+ return count;
+}
+
+#ifdef XKB
+static int lookup_string(
+ XKeyEvent* event,
+ char* buffer,
+ int nbytes,
+ KeySym* keysym,
+ XComposeStatus* status)
+{
+ int ret;
+ unsigned ctrls = XkbGetXlibControls (event->display);
+ XkbSetXlibControls (event->display,
+ XkbLC_ForceLatin1Lookup, XkbLC_ForceLatin1Lookup);
+ ret = XLookupString(event, (char *)buffer, nbytes, keysym, status);
+ XkbSetXlibControls (event->display,
+ XkbLC_ForceLatin1Lookup, ctrls);
+ return ret;
+}
+#endif
+
+#define BUF_SIZE (20)
+
+int
+_XimLookupMBText(ic, event, buffer, nbytes, keysym, status)
+ Xic ic;
+ XKeyEvent* event;
+ char* buffer;
+ int nbytes;
+ KeySym* keysym;
+ XComposeStatus* status;
+{
+ int count;
+ KeySym symbol;
+ Status dummy;
+ Xim im = (Xim)ic->core.im;
+ XimCommonPrivateRec* private = &im->private.common;
+ unsigned char look[BUF_SIZE];
+ ucs4_t ucs4;
+
+ /* force a latin-1 lookup for compatibility */
+ count = XLOOKUPSTRING(event, (char *)buffer, nbytes, &symbol, status);
+ if (keysym != NULL) *keysym = symbol;
+ if ((nbytes == 0) || (symbol == NoSymbol)) return count;
+
+ if (count > 1) {
+ memcpy(look, (char *)buffer,count);
+ look[count] = '\0';
+ if ((count = im->methods->ctstombs(ic->core.im,
+ (char*) look, count,
+ buffer, nbytes, &dummy)) < 0) {
+ count = 0;
+ }
+ } else if ((count == 0) ||
+ (count == 1 && (symbol > 0x7f && symbol < 0xff00))) {
+
+ XPointer from = (XPointer) &ucs4;
+ XPointer to = (XPointer) look;
+ int from_len = 1;
+ int to_len = BUF_SIZE;
+ XPointer args[1];
+ XlcCharSet charset;
+ args[0] = (XPointer) &charset;
+ ucs4 = (ucs4_t) KeySymToUcs4(symbol);
+ if (!ucs4)
+ return 0;
+
+ if (_XlcConvert(private->ucstoc_conv,
+ &from, &from_len, &to, &to_len,
+ args, 1 ) != 0) {
+ count = 0;
+ } else {
+ from = (XPointer) look;
+ to = (XPointer) buffer;
+ from_len = BUF_SIZE - to_len;
+ to_len = nbytes;
+ args[0] = (XPointer) charset;
+ if (_XlcConvert(private->cstomb_conv,
+ &from, &from_len, &to, &to_len,
+ args, 1 ) != 0) {
+ count = 0;
+ } else {
+ count = nbytes - to_len;
+ }
+ }
+ }
+ /* FIXME:
+ * we should make sure that if the character is a Latin1 character
+ * and it's on the right side, and we're in a non-Latin1 locale
+ * that this is a valid Latin1 character for this locale.
+ */
+ return count;
+}
+
+int
+_XimLookupWCText(ic, event, buffer, nbytes, keysym, status)
+ Xic ic;
+ XKeyEvent* event;
+ wchar_t* buffer;
+ int nbytes;
+ KeySym* keysym;
+ XComposeStatus* status;
+{
+ int count;
+ KeySym symbol;
+ Status dummy;
+ Xim im = (Xim)ic->core.im;
+ XimCommonPrivateRec* private = &im->private.common;
+ unsigned char look[BUF_SIZE];
+ ucs4_t ucs4;
+
+ /* force a latin-1 lookup for compatibility */
+ count = XLOOKUPSTRING(event, (char *)look, nbytes, &symbol, status);
+ if (keysym != NULL) *keysym = symbol;
+ if ((nbytes == 0) || (symbol == NoSymbol)) return count;
+
+ if (count > 1) {
+ if ((count = im->methods->ctstowcs(ic->core.im,
+ (char*) look, count,
+ buffer, nbytes, &dummy)) < 0) {
+ count = 0;
+ }
+ } else if ((count == 0) ||
+ (count == 1 && (symbol > 0x7f && symbol < 0xff00))) {
+
+ XPointer from = (XPointer) &ucs4;
+ XPointer to = (XPointer) look;
+ int from_len = 1;
+ int to_len = BUF_SIZE;
+ XPointer args[1];
+ XlcCharSet charset;
+ args[0] = (XPointer) &charset;
+ ucs4 = (ucs4_t) KeySymToUcs4(symbol);
+ if (!ucs4)
+ return 0;
+
+ if (_XlcConvert(private->ucstoc_conv,
+ &from, &from_len, &to, &to_len,
+ args, 1 ) != 0) {
+ count = 0;
+ } else {
+ from = (XPointer) look;
+ to = (XPointer) buffer;
+ from_len = BUF_SIZE - to_len;
+ to_len = nbytes;
+ args[0] = (XPointer) charset;
+
+ if (_XlcConvert(private->cstowc_conv,
+ &from, &from_len, &to, &to_len,
+ args, 1 ) != 0) {
+ count = 0;
+ } else {
+ count = nbytes - to_len;
+ }
+ }
+ } else
+ /* FIXME:
+ * we should make sure that if the character is a Latin1 character
+ * and it's on the right side, and we're in a non-Latin1 locale
+ * that this is a valid Latin1 character for this locale.
+ */
+ buffer[0] = look[0];
+
+ return count;
+}
+
+int
+_XimLookupUTF8Text(ic, event, buffer, nbytes, keysym, status)
+ Xic ic;
+ XKeyEvent* event;
+ char* buffer;
+ int nbytes;
+ KeySym* keysym;
+ XComposeStatus* status;
+{
+ int count;
+ KeySym symbol;
+ Status dummy;
+ Xim im = (Xim)ic->core.im;
+ XimCommonPrivateRec* private = &im->private.common;
+ unsigned char look[BUF_SIZE];
+ ucs4_t ucs4;
+
+ /* force a latin-1 lookup for compatibility */
+ count = XLOOKUPSTRING(event, (char *)buffer, nbytes, &symbol, status);
+ if (keysym != NULL) *keysym = symbol;
+ if ((nbytes == 0) || (symbol == NoSymbol)) return count;
+
+ if (count > 1) {
+ memcpy(look, (char *)buffer,count);
+ look[count] = '\0';
+ if ((count = im->methods->ctstoutf8(ic->core.im,
+ (char*) look, count,
+ buffer, nbytes, &dummy)) < 0) {
+ count = 0;
+ }
+ } else if ((count == 0) ||
+ (count == 1 && (symbol > 0x7f && symbol < 0xff00))) {
+
+ XPointer from = (XPointer) &ucs4;
+ int from_len = 1;
+ XPointer to = (XPointer) buffer;
+ int to_len = nbytes;
+
+ ucs4 = (ucs4_t) KeySymToUcs4(symbol);
+ if (!ucs4)
+ return 0;
+
+ if (_XlcConvert(private->ucstoutf8_conv,
+ &from, &from_len, &to, &to_len,
+ NULL, 0) != 0) {
+ count = 0;
+ } else {
+ count = nbytes - to_len;
+ }
+ }
+ /* FIXME:
+ * we should make sure that if the character is a Latin1 character
+ * and it's on the right side, and we're in a non-Latin1 locale
+ * that this is a valid Latin1 character for this locale.
+ */
+ return count;
+}
diff --git a/nx-X11/lib/X11/imDefFlt.c b/nx-X11/lib/X11/imDefFlt.c
new file mode 100644
index 000000000..ccf3ba348
--- /dev/null
+++ b/nx-X11/lib/X11/imDefFlt.c
@@ -0,0 +1,420 @@
+/* $Xorg: imDefFlt.c,v 1.4 2000/08/17 19:45:11 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+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 of FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imDefFlt.c,v 1.4 2001/01/17 19:41:51 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xatom.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xutil.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Private long
+_XimTriggerCheck(
+ Xim im,
+ XKeyEvent *ev,
+ INT32 len,
+ CARD32 *keylist)
+{
+ register long i;
+ KeySym keysym;
+ CARD32 buf32[BUFSIZE/4];
+ char *buf = (char *)buf32;
+ int modifier;
+ int modifier_mask;
+ CARD32 min_len = sizeof(CARD32) /* sizeof keysym */
+ + sizeof(CARD32) /* sizeof modifier */
+ + sizeof(CARD32); /* sizeof modifier mask */
+
+ XLookupString(ev, buf, BUFSIZE, &keysym, NULL);
+ if (!keysym)
+ return -1;
+
+ for (i = 0; len >= min_len; i += 3, len -= min_len) {
+ modifier = keylist[i + 1];
+ modifier_mask = keylist[i + 2];
+ if (((KeySym)keylist[i] == keysym)
+ && ((ev->state & modifier_mask) == modifier))
+ return i;
+ }
+ return -1;
+}
+
+Private long
+_XimTriggerOnCheck(
+ Xim im,
+ XKeyEvent *ev)
+{
+ return _XimTriggerCheck(im, ev, (INT32)im->private.proto.im_onkeylist[0],
+ &im->private.proto.im_onkeylist[1]);
+}
+
+Private long
+_XimTriggerOffCheck(
+ Xim im,
+ XKeyEvent *ev)
+{
+ return _XimTriggerCheck(im, ev, (INT32)im->private.proto.im_offkeylist[0],
+ &im->private.proto.im_offkeylist[1]);
+}
+
+Private Bool
+_XimOnKeysCheck(
+ Xic ic,
+ XKeyEvent *ev)
+{
+ Xim im = (Xim)ic->core.im;
+ long idx;
+
+ if (IS_DYNAMIC_EVENT_FLOW(ic->core.im) &&
+ im->private.proto.im_onkeylist &&
+ im->private.proto.im_onkeylist[0]) {
+ if ((idx = _XimTriggerOnCheck(im, ev)) >= 0) {
+ (void)_XimTriggerNotify(im, ic, 0, (CARD32)idx); /* Trigger on */
+ return True;
+ }
+ }
+ return False;
+}
+
+Private Bool
+_XimOffKeysCheck(
+ Xic ic,
+ XKeyEvent *ev)
+{
+ Xim im = (Xim)ic->core.im;
+ long idx;
+
+ if (IS_DYNAMIC_EVENT_FLOW(ic->core.im) &&
+ im->private.proto.im_offkeylist &&
+ im->private.proto.im_offkeylist[0]) {
+ if ((idx = _XimTriggerOffCheck(im, ev)) >= 0) {
+ _XimTriggerNotify(im, ic, 1, (CARD32)idx); /* Trigger off */
+ return True;
+ }
+ }
+ return False;
+}
+
+Private void
+_XimPendingFilter(
+ Xic ic)
+{
+ Xim im = (Xim)ic->core.im;
+
+ if (IS_NEED_SYNC_REPLY(ic)) {
+ (void)_XimProcSyncReply(im, ic);
+ UNMARK_NEED_SYNC_REPLY(ic);
+ }
+ return;
+}
+
+Private Bool
+_XimProtoKeypressFilter(
+ Xic ic,
+ XKeyEvent *ev)
+{
+#ifdef XIM_CONNECTABLE
+ Xim im = (Xim)ic->core.im;
+#endif
+
+ if (IS_FABLICATED(ic)) {
+ _XimPendingFilter(ic);
+ UNMARK_FABLICATED(ic);
+ return NOTFILTERD;
+ }
+
+ if (IS_NEGLECT_EVENT(ic, KeyPressMask))
+ return FILTERD;
+
+#ifdef XIM_CONNECTABLE
+ if (!IS_IC_CONNECTED(ic)) {
+ if (IS_CONNECTABLE(im)) {
+ if (_XimConnectServer(im)) {
+ if (!_XimReCreateIC(ic)) {
+ _XimDelayModeSetAttr(im);
+ return NOTFILTERD;
+ }
+ } else {
+ return NOTFILTERD;
+ }
+ } else {
+ return NOTFILTERD;
+ }
+ }
+#else
+ if (!IS_IC_CONNECTED(ic))
+ return NOTFILTERD;
+#endif /* XIM_CONNECTABLE */
+
+ if (!IS_FORWARD_EVENT(ic, KeyPressMask)) {
+ if (_XimOnKeysCheck(ic, ev))
+ return FILTERD;
+ return NOTFILTERD;
+ }
+ if (_XimOffKeysCheck(ic, ev))
+ return FILTERD;
+
+ if (_XimForwardEvent(ic, (XEvent *)ev,
+ IS_SYNCHRONOUS_EVENT(ic, KeyPressMask)))
+ return FILTERD;
+
+ return NOTFILTERD;
+}
+
+Private Bool
+_XimFilterKeypress(
+ Display *d,
+ Window w,
+ XEvent *ev,
+ XPointer client_data)
+{
+ return _XimProtoKeypressFilter((Xic)client_data, (XKeyEvent *)ev );
+}
+
+Private Bool
+_XimProtoKeyreleaseFilter(
+ Xic ic,
+ XKeyEvent *ev)
+{
+#ifdef XIM_CONNECTABLE
+ Xim im = (Xim)ic->core.im;
+#endif
+
+ if (IS_FABLICATED(ic)) {
+ _XimPendingFilter(ic);
+ UNMARK_FABLICATED(ic);
+ return NOTFILTERD;
+ }
+
+ if (IS_NEGLECT_EVENT(ic, KeyReleaseMask))
+ return FILTERD;
+
+#ifdef XIM_CONNECTABLE
+ if (!IS_IC_CONNECTED(ic)) {
+ if (IS_CONNECTABLE(im)) {
+ if (_XimConnectServer(im)) {
+ if (!_XimReCreateIC(ic)) {
+ _XimDelayModeSetAttr(im);
+ return NOTFILTERD;
+ }
+ } else {
+ return NOTFILTERD;
+ }
+ } else {
+ return NOTFILTERD;
+ }
+ }
+#else
+ if (!IS_IC_CONNECTED(ic))
+ return NOTFILTERD;
+#endif /* XIM_CONNECTABLE */
+
+ if (!IS_FORWARD_EVENT(ic, KeyReleaseMask)) {
+ if (_XimOnKeysCheck(ic, ev))
+ return FILTERD;
+ return NOTFILTERD;
+ }
+ if (_XimOffKeysCheck(ic, ev))
+ return FILTERD;
+
+ if (_XimForwardEvent(ic, (XEvent *)ev,
+ IS_SYNCHRONOUS_EVENT(ic, KeyPressMask)))
+ return FILTERD;
+
+ return NOTFILTERD;
+}
+
+Private Bool
+_XimFilterKeyrelease(
+ Display *d,
+ Window w,
+ XEvent *ev,
+ XPointer client_data)
+{
+ return _XimProtoKeyreleaseFilter((Xic)client_data, (XKeyEvent *)ev);
+}
+
+Private void
+_XimRegisterKeyPressFilter(
+ Xic ic)
+{
+ if (ic->core.focus_window) {
+ if (!(ic->private.proto.registed_filter_event & KEYPRESS_MASK)) {
+ _XRegisterFilterByType (ic->core.im->core.display,
+ ic->core.focus_window,
+ KeyPress, KeyPress,
+ _XimFilterKeypress,
+ (XPointer)ic);
+ ic->private.proto.registed_filter_event |= KEYPRESS_MASK;
+ }
+ }
+ return;
+}
+
+Private void
+_XimRegisterKeyReleaseFilter(
+ Xic ic)
+{
+ if (ic->core.focus_window) {
+ if (!(ic->private.proto.registed_filter_event & KEYRELEASE_MASK)) {
+ _XRegisterFilterByType (ic->core.im->core.display,
+ ic->core.focus_window,
+ KeyRelease, KeyRelease,
+ _XimFilterKeyrelease,
+ (XPointer)ic);
+ ic->private.proto.registed_filter_event |= KEYRELEASE_MASK;
+ }
+ }
+ return;
+}
+
+Private void
+_XimUnregisterKeyPressFilter(
+ Xic ic)
+{
+ if (ic->core.focus_window) {
+ if (ic->private.proto.registed_filter_event & KEYPRESS_MASK) {
+ _XUnregisterFilter (ic->core.im->core.display,
+ ic->core.focus_window,
+ _XimFilterKeypress,
+ (XPointer)ic);
+ ic->private.proto.registed_filter_event &= ~KEYPRESS_MASK;
+ }
+ }
+ return;
+}
+
+Private void
+_XimUnregisterKeyReleaseFilter(
+ Xic ic)
+{
+ if (ic->core.focus_window) {
+ if (ic->private.proto.registed_filter_event & KEYRELEASE_MASK) {
+ _XUnregisterFilter (ic->core.im->core.display,
+ ic->core.focus_window,
+ _XimFilterKeyrelease,
+ (XPointer)ic);
+ ic->private.proto.registed_filter_event &= ~KEYRELEASE_MASK;
+ }
+ }
+ return;
+}
+
+Public void
+_XimRegisterFilter(
+ Xic ic)
+{
+ _XimRegisterKeyPressFilter(ic);
+ if (IS_FORWARD_EVENT(ic, KeyReleaseMask))
+ _XimRegisterKeyReleaseFilter(ic);
+ return;
+}
+
+Public void
+_XimUnregisterFilter(
+ Xic ic)
+{
+ _XimUnregisterKeyPressFilter(ic);
+ _XimUnregisterKeyReleaseFilter(ic);
+ return;
+}
+
+Public void
+_XimReregisterFilter(
+ Xic ic)
+{
+ if (IS_FORWARD_EVENT(ic, KeyReleaseMask))
+ _XimRegisterKeyReleaseFilter(ic);
+ else
+ _XimUnregisterKeyReleaseFilter(ic);
+
+ return;
+}
+
+Private Bool
+_XimFilterServerDestroy(
+ Display *d,
+ Window w,
+ XEvent *ev,
+ XPointer client_data)
+{
+ Xim im = (Xim)client_data;
+
+ if (ev->type == DestroyNotify) {
+ UNMARK_SERVER_CONNECTED(im);
+#ifdef XIM_CONNECTABLE
+ if (!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im)) {
+ _XimServerReconectableDestroy();
+ return True;
+ }
+#endif /* XIM_CONNECTABLE */
+ _XimServerDestroy(im);
+ }
+ return True;
+}
+
+Public void
+_XimRegisterServerFilter(
+ Xim im)
+{
+ if (im->private.proto.im_window) {
+ if (!(im->private.proto.registed_filter_event & DESTROYNOTIFY_MASK)) {
+ _XRegisterFilterByMask(im->core.display,
+ im->private.proto.im_window,
+ StructureNotifyMask,
+ _XimFilterServerDestroy,
+ (XPointer)im);
+ XSelectInput(im->core.display, im->private.proto.im_window,
+ StructureNotifyMask);
+ im->private.proto.registed_filter_event |= DESTROYNOTIFY_MASK;
+ }
+ }
+ return;
+}
+
+Public void
+_XimUnregisterServerFilter(
+ Xim im)
+{
+ if (im->private.proto.im_window) {
+ if (im->private.proto.registed_filter_event & DESTROYNOTIFY_MASK) {
+ _XUnregisterFilter(im->core.display,
+ im->private.proto.im_window,
+ _XimFilterServerDestroy,
+ (XPointer)im);
+ im->private.proto.registed_filter_event &= ~DESTROYNOTIFY_MASK;
+ }
+ }
+ return;
+}
+
diff --git a/nx-X11/lib/X11/imDefIc.c b/nx-X11/lib/X11/imDefIc.c
new file mode 100644
index 000000000..cb30ac232
--- /dev/null
+++ b/nx-X11/lib/X11/imDefIc.c
@@ -0,0 +1,1559 @@
+/* $Xorg: imDefIc.c,v 1.5 2000/08/17 19:45:11 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1991, 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+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 of Sun Microsystems, Inc.
+and FUJITSU LIMITED not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
+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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imDefIc.c,v 3.9 2003/04/13 19:22:20 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Private Bool
+_XimCreateICCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+
+ if ((major_opcode == XIM_CREATE_IC_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid))
+ return True;
+ return False;
+}
+
+#ifdef XIM_CONNECTABLE
+Public Bool
+_XimReCreateIC(ic)
+ Xic ic;
+{
+ Xim im = (Xim)ic->core.im;
+ Xic save_ic;
+ XIMResourceList res;
+ unsigned int num;
+ XIMStyle input_style = ic->core.input_style;
+ XimDefICValues ic_values;
+ INT16 len;
+ CARD16 *buf_s;
+ char *tmp;
+ CARD32 tmp_buf32[BUFSIZE/4];
+ char *tmp_buf = (char *)tmp_buf32;
+ char *buf;
+ int buf_size;
+ char *data;
+ int data_len;
+ int ret_len;
+ int total;
+ int idx;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int ret_code;
+
+ if (!(save_ic = (Xic)Xmalloc(sizeof(XicRec))))
+ return False;
+ memcpy((char *)save_ic, (char *)ic, sizeof(XicRec));
+
+ ic->core.filter_events = im->private.proto.forward_event_mask;
+ ic->private.proto.forward_event_mask =
+ im->private.proto.forward_event_mask;
+ ic->private.proto.synchronous_event_mask =
+ im->private.proto.synchronous_event_mask;
+
+ num = im->core.ic_num_resources;
+ buf_size = sizeof(XIMResource) * num;
+ if (!(res = (XIMResourceList)Xmalloc(buf_size)))
+ goto ErrorOnReCreateIC;
+ (void)memcpy((char *)res, (char *)im->core.ic_resources, buf_size);
+ ic->private.proto.ic_resources = res;
+ ic->private.proto.ic_num_resources = num;
+
+ num = im->private.proto.ic_num_inner_resources;
+ buf_size = sizeof(XIMResource) * num;
+ if (!(res = (XIMResourceList)Xmalloc(buf_size)))
+ goto ErrorOnReCreateIC;
+ (void)memcpy((char *)res,
+ (char *)im->private.proto.ic_inner_resources, buf_size);
+ ic->private.proto.ic_inner_resources = res;
+ ic->private.proto.ic_num_inner_resources = num;
+
+ _XimSetICMode(ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, input_style);
+
+ _XimSetICMode(ic->private.proto.ic_inner_resources,
+ ic->private.proto.ic_num_inner_resources, input_style);
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ buf = tmp_buf;
+ buf_size = XIM_HEADER_SIZE + sizeof(CARD16) + sizeof(INT16);
+ data_len = BUFSIZE - buf_size;
+ total = 0;
+ idx = 0;
+ for (;;) {
+ data = &buf[buf_size];
+ if (!_XimEncodeSavedICATTRIBUTE(ic, ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, &idx, data, data_len,
+ &ret_len, (XPointer)&ic_values, XIM_CREATEIC)) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ goto ErrorOnReCreateIC;
+ }
+
+ total += ret_len;
+ if (idx == -1) {
+ break;
+ }
+
+ buf_size += ret_len;
+ if (buf == tmp_buf) {
+ if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ goto ErrorOnReCreateIC;
+ }
+ memcpy(tmp, buf, buf_size);
+ buf = tmp;
+ } else {
+ if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ Xfree(buf);
+ goto ErrorOnReCreateIC;
+ }
+ buf = tmp;
+ }
+ }
+
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ buf_s[0] = im->private.proto.imid;
+ buf_s[1] = (INT16)total;
+
+ len = (INT16)(sizeof(CARD16) + sizeof(INT16) + total);
+ _XimSetHeader((XPointer)buf, XIM_CREATE_IC, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ goto ErrorOnReCreateIC;
+ }
+ _XimFlush(im);
+ if (buf != tmp_buf)
+ Xfree(buf);
+ ic->private.proto.waitCallback = True;
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimCreateICCheck, 0);
+ if (ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if (ret_code == XIM_OVERFLOW) {
+ if (len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = (int)len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimCreateICCheck, 0);
+ if (ret_code != XIM_TRUE) {
+ Xfree(preply);
+ ic->private.proto.waitCallback = False;
+ goto ErrorOnReCreateIC;
+ }
+ }
+ } else {
+ ic->private.proto.waitCallback = False;
+ goto ErrorOnReCreateIC;
+ }
+ ic->private.proto.waitCallback = False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if (reply != preply)
+ Xfree(preply);
+ goto ErrorOnReCreateIC;
+ }
+
+ ic->private.proto.icid = buf_s[1]; /* icid */
+ if (reply != preply)
+ Xfree(preply);
+
+ _XimRegisterFilter(ic);
+ MARK_IC_CONNECTED(ic);
+ if (save_ic->private.proto.ic_resources)
+ Xfree(save_ic->private.proto.ic_resources);
+ if (save_ic->private.proto.ic_inner_resources)
+ Xfree(save_ic->private.proto.ic_inner_resources);
+ Xfree(save_ic);
+ return True;
+
+ErrorOnReCreateIC:
+ memcpy((char *)ic, (char *)save_ic, sizeof(XicRec));
+ Xfree(save_ic);
+ return False;
+}
+
+Private char *
+_XimDelayModeGetICValues(ic, arg)
+ Xic ic;
+ XIMArg *arg;
+{
+ XimDefICValues ic_values;
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ return _XimGetICValueData(ic, (XPointer)&ic_values,
+ ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources,
+ arg, XIM_GETICVALUES);
+}
+#endif /* XIM_CONNECTABLE */
+
+Private Bool
+_XimGetICValuesCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+
+ if ((major_opcode == XIM_GET_IC_VALUES_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ return True;
+ return False;
+}
+
+Private char *
+_XimProtoGetICValues(
+ XIC xic,
+ XIMArg *arg)
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ register XIMArg *p;
+ register XIMArg *pp;
+ register int n;
+ CARD8 *buf;
+ CARD16 *buf_s;
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply = NULL;
+ int buf_size;
+ int ret_code;
+ char *makeid_name;
+ char *decode_name;
+ CARD16 *data = NULL;
+ INT16 data_len = 0;
+
+#ifndef XIM_CONNECTABLE
+ if (!IS_IC_CONNECTED(ic))
+ return arg->name;
+#else
+ if (!IS_IC_CONNECTED(ic)) {
+ if (IS_CONNECTABLE(im)) {
+ if (_XimConnectServer(im)) {
+ if (!_XimReCreateIC(ic)) {
+ _XimDelayModeSetAttr(im);
+ return _XimDelayModeGetICValues(ic, arg);
+ }
+ } else {
+ return _XimDelayModeGetICValues(ic, arg);
+ }
+ } else {
+ return arg->name;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ for (n = 0, p = arg; p && p->name; p++) {
+ n++;
+ if ((strcmp(p->name, XNPreeditAttributes) == 0)
+ || (strcmp(p->name, XNStatusAttributes) == 0)) {
+ n++;
+ for (pp = (XIMArg *)p->value; pp && pp->name; pp++)
+ n++;
+ }
+ }
+
+ if (!n)
+ return (char *)NULL;
+
+ buf_size = sizeof(CARD16) * n;
+ buf_size += XIM_HEADER_SIZE
+ + sizeof(CARD16)
+ + sizeof(CARD16)
+ + sizeof(INT16)
+ + XIM_PAD(2 + buf_size);
+
+ if (!(buf = (CARD8 *)Xmalloc(buf_size)))
+ return arg->name;
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+
+ makeid_name = _XimMakeICAttrIDList(ic, ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, arg,
+ &buf_s[3], &len, XIM_GETICVALUES);
+
+ if (len > 0) {
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+ buf_s[2] = len; /* length of ic-attr-id */
+ len += sizeof(INT16); /* sizeof length of attr */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_GET_IC_VALUES, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ Xfree(buf);
+ return arg->name;
+ }
+ _XimFlush(im);
+ Xfree(buf);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimGetICValuesCheck, (XPointer)ic);
+ if (ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if (ret_code == XIM_OVERFLOW) {
+ if (len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = (int)len;
+ preply = (XPointer)Xmalloc(len);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimGetICValuesCheck, (XPointer)ic);
+ if (ret_code != XIM_TRUE) {
+ if (preply != reply)
+ Xfree(preply);
+ return arg->name;
+ }
+ }
+ } else {
+ return arg->name;
+ }
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if (reply != preply)
+ Xfree(preply);
+ return arg->name;
+ }
+ data = &buf_s[4];
+ data_len = buf_s[2];
+ }
+ else if (len < 0) {
+ return arg->name;
+ }
+
+ decode_name = _XimDecodeICATTRIBUTE(ic, ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, data, data_len,
+ arg, XIM_GETICVALUES);
+ if (reply != preply)
+ Xfree(preply);
+
+ if (decode_name)
+ return decode_name;
+ else
+ return makeid_name;
+}
+
+#ifdef XIM_CONNECTABLE
+Private Bool
+_XimCheckNestQuarkList(quark_list, num_quark, quark, separator)
+ XrmQuark *quark_list;
+ int num_quark;
+ XrmQuark quark;
+ XrmQuark separator;
+{
+ register int i;
+
+ for (i = 0; i < num_quark; i++) {
+ if (quark_list[i] == separator) {
+ break;
+ }
+ if (quark_list[i] == quark) {
+ return True;
+ }
+ }
+ return False;
+}
+
+Private Bool
+_XimCheckNestedQuarkList(quark_list, idx, num_quark, arg, separator)
+ XrmQuark **quark_list;
+ int idx;
+ int *num_quark;
+ XIMArg *arg;
+ XrmQuark separator;
+{
+ XrmQuark *q_list = *quark_list;
+ int n_quark = *num_quark;
+ register XIMArg *p;
+ XrmQuark quark;
+ XrmQuark *tmp;
+ register int i;
+
+ for (p = arg; p && p->name; p++) {
+ quark = XrmStringToQuark(p->name);
+ if (_XimCheckNestQuarkList(&q_list[idx], n_quark - idx,
+ quark, separator)) {
+ continue;
+ }
+ if (!(tmp = (XrmQuark *)Xmalloc((sizeof(XrmQuark) * (n_quark + 1))))) {
+ *quark_list = q_list;
+ *num_quark = n_quark;
+ return False;
+ }
+ n_quark++;
+ for (i = 0; i < idx; i++) {
+ tmp[i] = q_list[i];
+ }
+ tmp[i] = quark;
+ for (i = idx + 1; i < n_quark; i++) {
+ tmp[i] = q_list[i - 1];
+ }
+ q_list = tmp;
+ }
+ *quark_list = q_list;
+ *num_quark = n_quark;
+ return True;
+}
+
+Private Bool
+_XimCheckICQuarkList(quark_list, num_quark, quark, idx)
+ XrmQuark *quark_list;
+ int num_quark;
+ XrmQuark quark;
+ int *idx;
+{
+ register int i;
+
+ for (i = 0; i < num_quark; i++) {
+ if (quark_list[i] == quark) {
+ *idx = i;
+ return True;
+ }
+ }
+ return False;
+}
+
+Private Bool
+_XimSaveICValues(ic, arg)
+ Xic ic;
+ XIMArg *arg;
+{
+ register XIMArg *p;
+ register int n;
+ XrmQuark *quark_list;
+ XrmQuark *tmp;
+ XrmQuark quark;
+ int num_quark;
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+ XrmQuark separator;
+ int idx;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+ separator = XrmStringToQuark(XNSeparatorofNestedList);
+
+ if (quark_list = ic->private.proto.saved_icvalues) {
+ num_quark = ic->private.proto.num_saved_icvalues;
+ for (p = arg; p && p->name; p++) {
+ quark = XrmStringToQuark(p->name);
+ if ((quark == pre_quark) || (quark == sts_quark)) {
+ if (!_XimCheckICQuarkList(quark_list, num_quark, quark, &idx)) {
+ register XIMArg *pp;
+ int nn;
+ XrmQuark *q_list;
+
+ for (pp = (XIMArg *)p->value, nn = 0;
+ pp && pp->name; pp++, nn++);
+ if (!(tmp = (XrmQuark *)Xrealloc(quark_list,
+ (sizeof(XrmQuark) * (num_quark + nn + 2))))) {
+ ic->private.proto.saved_icvalues = quark_list;
+ ic->private.proto.num_saved_icvalues = num_quark;
+ return False;
+ }
+ quark_list = tmp;
+ q_list = &quark_list[num_quark];
+ num_quark += nn + 2;
+ *q_list++ = quark;
+ for (pp = (XIMArg *)p->value;
+ pp && pp->name; pp++, quark_list++) {
+ *q_list = XrmStringToQuark(pp->name);
+ }
+ *q_list = separator;
+ } else {
+ if (!_XimCheckNestedQuarkList(&quark_list, idx + 1,
+ &num_quark, (XIMArg *)p->value, separator)) {
+ ic->private.proto.saved_icvalues = quark_list;
+ ic->private.proto.num_saved_icvalues = num_quark;
+ return False;
+ }
+ }
+ } else {
+ if (_XimCheckICQuarkList(quark_list, num_quark, quark, &idx)) {
+ continue;
+ }
+ if (!(tmp = (XrmQuark *)Xrealloc(quark_list,
+ (sizeof(XrmQuark) * (num_quark + 1))))) {
+ ic->private.proto.saved_icvalues = quark_list;
+ ic->private.proto.num_saved_icvalues = num_quark;
+ return False;
+ }
+ quark_list = tmp;
+ quark_list[num_quark] = quark;
+ num_quark++;
+ }
+ }
+ ic->private.proto.saved_icvalues = quark_list;
+ ic->private.proto.num_saved_icvalues = num_quark;
+ return True;
+ }
+
+ for (p = arg, n = 0; p && p->name; p++, n++) {
+ if ((!strcmp(p->name, XNPreeditAttributes))
+ || (!strcmp(p->name, XNStatusAttributes))) {
+ register XIMArg *pp;
+ int nn;
+
+ for (pp = (XIMArg *)p->value, nn = 0; pp && pp->name; pp++, nn++);
+ n += nn + 1;
+ }
+ }
+
+ if (!(quark_list = (XrmQuark *)Xmalloc(sizeof(XrmQuark) * n))) {
+ return False;
+ }
+
+ ic->private.proto.saved_icvalues = quark_list;
+ ic->private.proto.num_saved_icvalues = n;
+ for (p = arg; p && p->name; p++, quark_list++) {
+ *quark_list = XrmStringToQuark(p->name);
+ if ((*quark_list == pre_quark) || (*quark_list == sts_quark)) {
+ register XIMArg *pp;
+
+ quark_list++;
+ for (pp = (XIMArg *)p->value; pp && pp->name; pp++, quark_list++) {
+ *quark_list = XrmStringToQuark(pp->name);
+ }
+ *quark_list = separator;
+ }
+ }
+ return True;
+}
+
+Private char *
+_XimDelayModeSetICValues(ic, arg)
+ Xic ic;
+ XIMArg *arg;
+{
+ XimDefICValues ic_values;
+ char *name;
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ name = _XimSetICValueData(ic, (XPointer)&ic_values,
+ ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources,
+ arg, XIM_SETICVALUES, False);
+ _XimSetCurrentICValues(ic, &ic_values);
+ return name;
+}
+#endif /* XIM_CONNECTABLE */
+
+Private Bool
+_XimSetICValuesCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+
+ if ((major_opcode == XIM_SET_IC_VALUES_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ return True;
+ return False;
+}
+
+Private char *
+_XimProtoSetICValues(
+ XIC xic,
+ XIMArg *arg)
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ XimDefICValues ic_values;
+ INT16 len;
+ CARD16 *buf_s;
+ char *tmp;
+ CARD32 tmp_buf32[BUFSIZE/4];
+ char *tmp_buf = (char *)tmp_buf32;
+ char *buf;
+ int buf_size;
+ char *data;
+ int data_len;
+ int ret_len;
+ int total;
+ XIMArg *arg_ret;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply = NULL;
+ int ret_code;
+ BITMASK32 flag = 0L;
+ char *name;
+ char *tmp_name = (arg) ? arg->name : NULL;
+
+#ifndef XIM_CONNECTABLE
+ if (!IS_IC_CONNECTED(ic))
+ return tmp_name;
+#else
+ if (!_XimSaveICValues(ic, arg))
+ return NULL;
+
+ if (!IS_IC_CONNECTED(ic)) {
+ if (IS_CONNECTABLE(im)) {
+ if (_XimConnectServer(im)) {
+ if (!_XimReCreateIC(ic)) {
+ _XimDelayModeSetAttr(im);
+ return _XimDelayModeSetICValues(ic, arg);
+ }
+ } else {
+ return _XimDelayModeSetICValues(ic, arg);
+ }
+ } else {
+ return tmp_name;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ buf = tmp_buf;
+ buf_size = XIM_HEADER_SIZE
+ + sizeof(CARD16) + sizeof(CARD16) + sizeof(INT16) + sizeof(CARD16);
+ data_len = BUFSIZE - buf_size;
+ total = 0;
+ arg_ret = arg;
+ for (;;) {
+ data = &buf[buf_size];
+ if ((name = _XimEncodeICATTRIBUTE(ic, ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, arg, &arg_ret,
+ data, data_len, &ret_len, (XPointer)&ic_values,
+ &flag, XIM_SETICVALUES))) {
+ break;
+ }
+
+ total += ret_len;
+ if (!(arg = arg_ret)) {
+ break;
+ }
+
+ buf_size += ret_len;
+ if (buf == tmp_buf) {
+ if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ return tmp_name;
+ }
+ memcpy(tmp, buf, buf_size);
+ buf = tmp;
+ } else {
+ if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ Xfree(buf);
+ return tmp_name;
+ }
+ buf = tmp;
+ }
+ }
+ _XimSetCurrentICValues(ic, &ic_values);
+
+ if (!total) {
+ return tmp_name;
+ }
+
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+
+#ifdef EXT_MOVE
+ if (_XimExtenMove(im, ic, flag, &buf_s[4], (INT16)total))
+ return name;
+#endif
+
+ buf_s[0] = im->private.proto.imid;
+ buf_s[1] = ic->private.proto.icid;
+ buf_s[2] = (INT16)total;
+ buf_s[3] = 0;
+ len = (INT16)(sizeof(CARD16) + sizeof(CARD16)
+ + sizeof(INT16) + sizeof(CARD16) + total);
+
+ _XimSetHeader((XPointer)buf, XIM_SET_IC_VALUES, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ return tmp_name;
+ }
+ _XimFlush(im);
+ if (buf != tmp_buf)
+ Xfree(buf);
+ ic->private.proto.waitCallback = True;
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimSetICValuesCheck, (XPointer)ic);
+ if (ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if (ret_code == XIM_OVERFLOW) {
+ buf_size = (int)len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimSetICValuesCheck, (XPointer)ic);
+ if (ret_code != XIM_TRUE) {
+ Xfree(preply);
+ ic->private.proto.waitCallback = False;
+ return tmp_name;
+ }
+ } else {
+ ic->private.proto.waitCallback = False;
+ return tmp_name;
+ }
+ ic->private.proto.waitCallback = False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if (reply != preply)
+ Xfree(preply);
+ return tmp_name;
+ }
+ if (reply != preply)
+ Xfree(preply);
+
+ return name;
+}
+
+Private Bool
+_XimDestroyICCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Bool ret = False;
+
+ if ((major_opcode == XIM_DESTROY_IC_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ ret = True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ ret = False;
+ return ret;
+}
+
+Private void
+_XimProtoICFree(
+ Xic ic)
+{
+#ifdef XIM_CONNECTABLE
+ Xim im = (Xim)ic->core.im;
+#endif
+
+ if (ic->private.proto.preedit_font) {
+ Xfree(ic->private.proto.preedit_font);
+ ic->private.proto.preedit_font = NULL;
+ }
+ if (ic->private.proto.status_font) {
+ Xfree(ic->private.proto.status_font);
+ ic->private.proto.status_font = NULL;
+ }
+ if (ic->private.proto.commit_info) {
+ _XimFreeCommitInfo(ic);
+ ic->private.proto.commit_info = NULL;
+ }
+ if (ic->private.proto.ic_inner_resources) {
+ Xfree(ic->private.proto.ic_inner_resources);
+ ic->private.proto.ic_inner_resources = NULL;
+ }
+
+#ifdef XIM_CONNECTABLE
+ if (IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im)) {
+ return;
+ }
+#endif /* XIM_CONNECTABLE */
+
+ if (ic->private.proto.saved_icvalues) {
+ Xfree(ic->private.proto.saved_icvalues);
+ ic->private.proto.saved_icvalues = NULL;
+ }
+ if (ic->private.proto.ic_resources) {
+ Xfree(ic->private.proto.ic_resources);
+ ic->private.proto.ic_resources = NULL;
+ }
+ if (ic->core.hotkey) {
+ Xfree(ic->core.hotkey);
+ ic->core.hotkey = NULL;
+ }
+
+ return;
+}
+
+Private void
+_XimProtoDestroyIC(
+ XIC xic)
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+
+ if (IS_SERVER_CONNECTED(im)) {
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_DESTROY_IC, 0, &len);
+ (void)_XimWrite(im, len, (XPointer)buf);
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimDestroyICCheck, (XPointer)ic);
+ if (ret_code == XIM_OVERFLOW) {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ (void)_XimRead(im, &len, preply, buf_size,
+ _XimDestroyICCheck, (XPointer)ic);
+ Xfree(preply);
+ }
+ }
+ UNMARK_IC_CONNECTED(ic);
+ _XimUnregisterFilter(ic);
+ _XimProtoICFree(ic);
+ return;
+}
+
+Private void
+_XimProtoSetFocus(
+ XIC xic)
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+
+#ifndef XIM_CONNECTABLE
+ if (!IS_IC_CONNECTED(ic))
+ return;
+#else
+ if (!IS_IC_CONNECTED(ic)) {
+ if (IS_CONNECTABLE(im)) {
+ if (_XimConnectServer(im)) {
+ if (!_XimReCreateIC(ic)) {
+ _XimDelayModeSetAttr(im);
+ return;
+ }
+ } else {
+ return;
+ }
+ } else {
+ return;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_SET_IC_FOCUS, 0, &len);
+ (void)_XimWrite(im, len, (XPointer)buf);
+ _XimFlush(im);
+
+ _XimRegisterFilter(ic);
+ return;
+}
+
+Private void
+_XimProtoUnsetFocus(
+ XIC xic)
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+
+#ifndef XIM_CONNECTABLE
+ if (!IS_IC_CONNECTED(ic))
+ return;
+#else
+ if (!IS_IC_CONNECTED(ic)) {
+ if (IS_CONNECTABLE(im)) {
+ if (_XimConnectServer(im)) {
+ if (!_XimReCreateIC(ic)) {
+ _XimDelayModeSetAttr(im);
+ return;
+ }
+ } else {
+ return;
+ }
+ } else {
+ return;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_UNSET_IC_FOCUS, 0, &len);
+ (void)_XimWrite(im, len, (XPointer)buf);
+ _XimFlush(im);
+
+ _XimUnregisterFilter(ic);
+ return;
+}
+
+Private Bool
+_XimResetICCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+
+ if ((major_opcode == XIM_RESET_IC_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ return True;
+ return False;
+}
+
+Private char *
+_XimProtoReset(
+ XIC xic,
+ char * (*retfunc) (Xim im, Xic ic, XPointer buf) )
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ char *commit;
+
+ if (!IS_IC_CONNECTED(ic))
+ return (char *)NULL;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_RESET_IC, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return NULL;
+ _XimFlush(im);
+ ic->private.proto.waitCallback = True;
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimResetICCheck, (XPointer)ic);
+ if (ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if (ret_code == XIM_OVERFLOW) {
+ if (len < 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimResetICCheck, (XPointer)ic);
+ if (ret_code != XIM_TRUE) {
+ Xfree(preply);
+ ic->private.proto.waitCallback = False;
+ return NULL;
+ }
+ }
+ } else {
+ ic->private.proto.waitCallback = False;
+ return NULL;
+ }
+ ic->private.proto.waitCallback = False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if (reply != preply)
+ free(preply);
+ return NULL;
+ }
+
+ commit = retfunc(im, ic, (XPointer)&buf_s[2]);
+
+ if (reply != preply)
+ Xfree(preply);
+ return commit;
+}
+
+Private char *
+_XimCommitedMbString(
+ Xim im,
+ Xic ic,
+ XPointer buf)
+{
+ CARD16 *buf_s = (CARD16 *)buf;
+ XimCommitInfo info;
+ int len;
+ int new_len;
+ char *commit;
+ char *new_commit = NULL;
+ char *str;
+ Status status;
+
+ len = 0;
+ for (info = ic->private.proto.commit_info; info; info = info->next)
+ len += info->string_len;
+ len += buf_s[0];
+ if ( len == 0 )
+ return( NULL );
+
+ if (!(commit = (char *)Xmalloc(len + 1)))
+ goto Error_On_Reset;
+
+ str = commit;
+ for (info = ic->private.proto.commit_info; info; info = info->next) {
+ (void)memcpy(str, info->string, info->string_len);
+ str += info->string_len;
+ }
+ (void)memcpy(str, (char *)&buf_s[1], buf_s[0]);
+ commit[len] = '\0';
+
+ new_len = im->methods->ctstombs((XIM)im, commit, len, NULL, 0, &status);
+ if (status != XLookupNone) {
+ if (!(new_commit = Xmalloc(new_len + 1))) {
+ Xfree(commit);
+ goto Error_On_Reset;
+ }
+ (void)im->methods->ctstombs((XIM)im, commit, len,
+ new_commit, new_len, NULL);
+ new_commit[new_len] = '\0';
+ }
+ Xfree(commit);
+
+Error_On_Reset:
+ _XimFreeCommitInfo( ic );
+ return new_commit;
+}
+
+Private char *
+_XimProtoMbReset(
+ XIC xic)
+{
+ return _XimProtoReset(xic, _XimCommitedMbString);
+}
+
+Private wchar_t *
+_XimCommitedWcString(
+ Xim im,
+ Xic ic,
+ XPointer buf)
+{
+ CARD16 *buf_s = (CARD16 *)buf;
+ XimCommitInfo info;
+ int len;
+ int new_len;
+ char *commit;
+ wchar_t *new_commit = (wchar_t *)NULL;
+ char *str;
+ Status status;
+
+ len = 0;
+ for (info = ic->private.proto.commit_info; info; info = info->next)
+ len += info->string_len;
+ len += buf_s[0];
+ if ( len == 0 )
+ return( (wchar_t *)NULL );
+
+ if (!(commit = (char *)Xmalloc(len + 1)))
+ goto Error_On_Reset;
+
+ str = commit;
+ for (info = ic->private.proto.commit_info; info; info = info->next) {
+ (void)memcpy(str, info->string, info->string_len);
+ str += info->string_len;
+ }
+ (void)memcpy(str, (char *)&buf_s[1], buf_s[0]);
+ commit[len] = '\0';
+
+ new_len = im->methods->ctstowcs((XIM)im, commit, len, NULL, 0, &status);
+ if (status != XLookupNone) {
+ if (!(new_commit =
+ (wchar_t *)Xmalloc(sizeof(wchar_t) * (new_len + 1)))) {
+ Xfree(commit);
+ goto Error_On_Reset;
+ }
+ (void)im->methods->ctstowcs((XIM)im, commit, len,
+ new_commit, new_len, NULL);
+ new_commit[new_len] = (wchar_t)'\0';
+ }
+ Xfree(commit);
+
+Error_On_Reset:
+ _XimFreeCommitInfo( ic );
+ return new_commit;
+}
+
+Private wchar_t *
+_XimProtoWcReset(
+ XIC xic)
+{
+ return (wchar_t *) _XimProtoReset(xic,
+ (char * (*) (Xim, Xic, XPointer)) _XimCommitedWcString);
+}
+
+Private char *
+_XimCommitedUtf8String(
+ Xim im,
+ Xic ic,
+ XPointer buf)
+{
+ CARD16 *buf_s = (CARD16 *)buf;
+ XimCommitInfo info;
+ int len;
+ int new_len;
+ char *commit;
+ char *new_commit = NULL;
+ char *str;
+ Status status;
+
+ len = 0;
+ for (info = ic->private.proto.commit_info; info; info = info->next)
+ len += info->string_len;
+ len += buf_s[0];
+ if ( len == 0 )
+ return( NULL );
+
+ if (!(commit = (char *)Xmalloc(len + 1)))
+ goto Error_On_Reset;
+
+ str = commit;
+ for (info = ic->private.proto.commit_info; info; info = info->next) {
+ (void)memcpy(str, info->string, info->string_len);
+ str += info->string_len;
+ }
+ (void)memcpy(str, (char *)&buf_s[1], buf_s[0]);
+ commit[len] = '\0';
+
+ new_len = im->methods->ctstoutf8((XIM)im, commit, len, NULL, 0, &status);
+ if (status != XLookupNone) {
+ if (!(new_commit = Xmalloc(new_len + 1))) {
+ Xfree(commit);
+ goto Error_On_Reset;
+ }
+ (void)im->methods->ctstoutf8((XIM)im, commit, len,
+ new_commit, new_len, NULL);
+ new_commit[new_len] = '\0';
+ }
+ Xfree(commit);
+
+Error_On_Reset:
+ _XimFreeCommitInfo( ic );
+ return new_commit;
+}
+
+Private char *
+_XimProtoUtf8Reset(
+ XIC xic)
+{
+ return _XimProtoReset(xic, _XimCommitedUtf8String);
+}
+
+Private XICMethodsRec ic_methods = {
+ _XimProtoDestroyIC, /* destroy */
+ _XimProtoSetFocus, /* set_focus */
+ _XimProtoUnsetFocus, /* unset_focus */
+ _XimProtoSetICValues, /* set_values */
+ _XimProtoGetICValues, /* get_values */
+ _XimProtoMbReset, /* mb_reset */
+ _XimProtoWcReset, /* wc_reset */
+ _XimProtoUtf8Reset, /* utf8_reset */
+ _XimProtoMbLookupString, /* mb_lookup_string */
+ _XimProtoWcLookupString, /* wc_lookup_string */
+ _XimProtoUtf8LookupString /* utf8_lookup_string */
+};
+
+Private Bool
+_XimGetInputStyle(
+ XIMArg *arg,
+ XIMStyle *input_style)
+{
+ register XIMArg *p;
+
+ for (p = arg; p && p->name; p++) {
+ if (!(strcmp(p->name, XNInputStyle))) {
+ *input_style = (XIMStyle)p->value;
+ return True;
+ }
+ }
+ return False;
+}
+
+#ifdef XIM_CONNECTABLE
+Private Bool
+_XimDelayModeCreateIC(
+ Xic ic,
+ XIMArg *values,
+ XIMResourceList res,
+ unsigned int num)
+{
+ Xim im = (Xim)ic->core.im;
+ XimDefICValues ic_values;
+ int len;
+ XIMStyle input_style;
+
+ bzero((char *)&ic_values, sizeof(XimDefICValues));
+ _XimGetCurrentICValues(ic, &ic_values);
+ if (!(_XimGetInputStyle(values, &input_style)))
+ return False;
+
+ _XimSetICMode(res, num, input_style);
+
+ if (_XimSetICValueData(ic, (XPointer)&ic_values, res, num,
+ values, XIM_CREATEIC, False)) {
+ return False;
+ }
+ _XimSetCurrentICValues(ic, &ic_values);
+ if (!_XimSetICDefaults(ic, (XPointer)&ic_values,
+ XIM_SETICDEFAULTS, res, num)) {
+ return False;
+ }
+ ic_values.filter_events = KeyPressMask;
+ _XimSetCurrentICValues(ic, &ic_values);
+ _XimRegisterFilter(ic);
+
+ return True;
+}
+
+Public Bool
+_XimReconnectModeCreateIC(ic)
+ Xic ic;
+{
+ Xim im = (Xim)ic->core.im;
+ int len;
+ XIMStyle input_style = ic->core.input_style;
+ XIMResourceList res;
+ unsigned int num;
+
+ num = im->core.ic_num_resources;
+ len = sizeof(XIMResource) * num;
+ if (!(res = (XIMResourceList)Xmalloc(len)))
+ return False;
+ (void)memcpy((char *)res, (char *)im->core.ic_resources, len);
+ ic->private.proto.ic_resources = res;
+ ic->private.proto.ic_num_resources = num;
+
+ _XimSetICMode(res, num, input_style);
+
+ ic->core.filter_events = KeyPressMask;
+
+ return True;
+}
+#endif /* XIM_CONNECTABLE */
+
+Public XIC
+_XimProtoCreateIC(
+ XIM xim,
+ XIMArg *arg)
+{
+ Xim im = (Xim)xim;
+ Xic ic;
+ XimDefICValues ic_values;
+ XIMResourceList res;
+ unsigned int num;
+ XIMStyle input_style;
+ INT16 len;
+ CARD16 *buf_s;
+ char *tmp;
+ CARD32 tmp_buf32[BUFSIZE/4];
+ char *tmp_buf = (char *)tmp_buf32;
+ char *buf;
+ int buf_size;
+ char *data;
+ int data_len;
+ int ret_len;
+ int total;
+ XIMArg *arg_ret;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int ret_code;
+
+#ifdef XIM_CONNECTABLE
+ if (!IS_SERVER_CONNECTED(im) && !IS_CONNECTABLE(im))
+ return (XIC)NULL;
+#else
+ if (!IS_SERVER_CONNECTED(im))
+ return (XIC)NULL;
+#endif /* XIM_CONNECTABLE */
+
+ if (!(_XimGetInputStyle(arg, &input_style)))
+ return (XIC)NULL;
+
+ if ((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL)
+ return (XIC)NULL;
+
+ bzero((char *)ic, sizeof(XicRec));
+ ic->methods = &ic_methods;
+ ic->core.im = (XIM)im;
+ ic->core.input_style = input_style;
+
+ num = im->core.ic_num_resources;
+ len = sizeof(XIMResource) * num;
+ if (!(res = (XIMResourceList)Xmalloc(len)))
+ return (XIC)NULL;
+ (void)memcpy((char *)res, (char *)im->core.ic_resources, len);
+ ic->private.proto.ic_resources = res;
+ ic->private.proto.ic_num_resources = num;
+
+#ifdef XIM_CONNECTABLE
+ if (!_XimSaveICValues(ic, arg))
+ return False;
+
+ if (!IS_SERVER_CONNECTED(im)) {
+ if (!_XimConnectServer(im)) {
+ if (_XimDelayModeCreateIC(ic, arg, res, num)) {
+ return (XIC)ic;
+ }
+ goto ErrorOnCreatingIC;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ ic->core.filter_events = im->private.proto.forward_event_mask;
+ ic->private.proto.forward_event_mask =
+ im->private.proto.forward_event_mask;
+ ic->private.proto.synchronous_event_mask =
+ im->private.proto.synchronous_event_mask;
+
+ num = im->private.proto.ic_num_inner_resources;
+ len = sizeof(XIMResource) * num;
+ if (!(res = (XIMResourceList)Xmalloc(len)))
+ return (XIC)NULL;
+ (void)memcpy((char *)res,
+ (char *)im->private.proto.ic_inner_resources, len);
+ ic->private.proto.ic_inner_resources = res;
+ ic->private.proto.ic_num_inner_resources = num;
+
+ _XimSetICMode(ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, input_style);
+
+ _XimSetICMode(ic->private.proto.ic_inner_resources,
+ ic->private.proto.ic_num_inner_resources, input_style);
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ buf = tmp_buf;
+ buf_size = XIM_HEADER_SIZE + sizeof(CARD16) + sizeof(INT16);
+ data_len = BUFSIZE - buf_size;
+ total = 0;
+ arg_ret = arg;
+ for (;;) {
+ data = &buf[buf_size];
+ if (_XimEncodeICATTRIBUTE(ic, ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, arg, &arg_ret, data,
+ data_len, &ret_len, (XPointer)&ic_values, 0, XIM_CREATEIC)) {
+ goto ErrorOnCreatingIC;
+ }
+
+ total += ret_len;
+ if (!(arg = arg_ret)) {
+ break;
+ }
+
+ buf_size += ret_len;
+ if (buf == tmp_buf) {
+ if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ goto ErrorOnCreatingIC;
+ }
+ memcpy(tmp, buf, buf_size);
+ buf = tmp;
+ } else {
+ if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ Xfree(buf);
+ goto ErrorOnCreatingIC;
+ }
+ buf = tmp;
+ }
+ }
+ _XimSetCurrentICValues(ic, &ic_values);
+
+ if (!(_XimCheckCreateICValues(ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources)))
+ goto ErrorOnCreatingIC;
+
+ _XimRegisterFilter(ic);
+
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ buf_s[0] = im->private.proto.imid;
+ buf_s[1] = (INT16)total;
+
+ len = (INT16)(sizeof(CARD16) + sizeof(INT16) + total);
+ _XimSetHeader((XPointer)buf, XIM_CREATE_IC, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ goto ErrorOnCreatingIC;
+ }
+ _XimFlush(im);
+ if (buf != tmp_buf)
+ Xfree(buf);
+ ic->private.proto.waitCallback = True;
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimCreateICCheck, 0);
+ if (ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if (ret_code == XIM_OVERFLOW) {
+ if (len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = (int)len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimCreateICCheck, 0);
+ if (ret_code != XIM_TRUE) {
+ Xfree(preply);
+ ic->private.proto.waitCallback = False;
+ goto ErrorOnCreatingIC;
+ }
+ }
+ } else {
+ ic->private.proto.waitCallback = False;
+ goto ErrorOnCreatingIC;
+ }
+ ic->private.proto.waitCallback = False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if (reply != preply)
+ Xfree(preply);
+ goto ErrorOnCreatingIC;
+ }
+
+ ic->private.proto.icid = buf_s[1]; /* icid */
+ if (reply != preply)
+ Xfree(preply);
+ MARK_IC_CONNECTED(ic);
+ return (XIC)ic;
+
+ErrorOnCreatingIC:
+ _XimUnregisterFilter(ic);
+ if (ic->private.proto.ic_resources)
+ Xfree(ic->private.proto.ic_resources);
+ if (ic->private.proto.ic_inner_resources)
+ Xfree(ic->private.proto.ic_inner_resources);
+ Xfree(ic);
+ return (XIC)NULL;
+}
diff --git a/nx-X11/lib/X11/imDefIm.c b/nx-X11/lib/X11/imDefIm.c
new file mode 100644
index 000000000..7581548e7
--- /dev/null
+++ b/nx-X11/lib/X11/imDefIm.c
@@ -0,0 +1,2028 @@
+/* $Xorg: imDefIm.c,v 1.5 2000/08/17 19:45:12 cpqbld Exp $ */
+/******************************************************************
+ Copyright 1990, 1991, 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993, 1994 by Sony 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 of Sun Microsystems, Inc., FUJITSU LIMITED and Sony
+Corporation not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc., FUJITSU LIMITED and Sony Corporation makes no
+representations about the suitability of this software for any purpose. It
+is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc., FUJITSU LIMITED AND SONY CORPORATION DISCLAIMS ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc.,
+FUJITSU LIMITED AND SONY CORPORATION 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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imDefIm.c,v 1.15 2003/08/22 19:27:24 eich Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xatom.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcPublic.h"
+#include "XlcPubI.h"
+#include "XimTrInt.h"
+#include "Ximint.h"
+
+
+Public int
+_XimCheckDataSize(
+ XPointer buf,
+ int len)
+{
+ CARD16 *buf_s = (CARD16 *)buf;
+
+ if(len < XIM_HEADER_SIZE)
+ return -1;
+ return buf_s[1];
+}
+
+Public void
+_XimSetHeader(
+ XPointer buf,
+ CARD8 major_opcode,
+ CARD8 minor_opcode,
+ INT16 *len
+)
+{
+ CARD8 *buf_b = (CARD8 *)buf;
+ CARD16 *buf_s = (CARD16 *)buf;
+
+ buf_b[0] = major_opcode;
+ buf_b[1] = minor_opcode;
+ buf_s[1] = ((*len) / 4);
+ *len += XIM_HEADER_SIZE;
+ return;
+}
+
+Private char
+_XimGetMyEndian(void)
+{
+ CARD16 test_card = 1;
+
+ if(*((char *)&test_card))
+ return LITTLEENDIAN;
+ else
+ return BIGENDIAN;
+}
+
+Private Bool
+_XimCheckServerName(
+ Xim im,
+ char *str)
+{
+ char *server_name = im->core.im_name;
+ int len;
+ int str_len;
+ int category_len = strlen(XIM_SERVER_CATEGORY);
+ char *pp;
+ register char *p;
+
+ if(server_name && *server_name)
+ len = strlen(server_name);
+ else
+ return True;
+
+ if((int)strlen(str) < category_len)
+ return False;
+
+ if(strncmp(str, XIM_SERVER_CATEGORY, category_len))
+ return False;
+
+ pp = &str[category_len];
+
+ for(;;) {
+ for(p = pp; (*p != ',') && (*p); p++);
+ str_len = (int)(p - pp);
+
+ if((len == str_len) && (!strncmp(pp, server_name, len)))
+ break;
+ if(!(*p))
+ return False;
+ pp = p + 1;
+ }
+ return True;
+}
+
+Private char *
+_XimCheckLocaleName(
+ Xim im,
+ char *address,
+ int address_len,
+ char *locale_name[],
+ int len)
+{
+ int category_len;
+ char *pp;
+ register char *p;
+ register int n;
+ Bool finish = False;
+
+ category_len = strlen(XIM_LOCAL_CATEGORY);
+ if(address_len < category_len)
+ return (char*)NULL;
+
+ if(strncmp(address, XIM_LOCAL_CATEGORY, category_len))
+ return (char*)NULL;
+
+ pp = &address[category_len];
+
+ for(;;) {
+ for( p = pp; *p && *p != ','; p++);
+ if (!*p)
+ finish = True;
+ address_len = (int)(p - pp);
+ *p = '\0';
+
+ for( n = 0; n < len; n++ )
+ if( locale_name[n] && !_XlcCompareISOLatin1( pp, locale_name[n] ) )
+ return locale_name[n];
+ if (finish)
+ break;
+ pp = p + 1;
+ }
+ return (char *)NULL;
+}
+
+Private Bool
+_XimCheckTransport(
+ char *address,
+ int address_len,
+ char *transport,
+ int len,
+ char **trans_addr)
+{
+ int category_len = strlen(XIM_TRANSPORT_CATEGORY);
+ char *pp;
+ register char *p;
+
+ if(address_len < category_len)
+ return False;
+
+ if(strncmp(address, XIM_TRANSPORT_CATEGORY, category_len))
+ return False;
+
+ pp = &address[category_len];
+
+ for(;;) {
+ *trans_addr = pp;
+
+ for(p = pp; (*p != '/') && (*p != ',') && (*p); p++);
+ if(*p == ',') {
+ pp = p + 1;
+ continue;
+ }
+ if(!(*p))
+ return False;
+
+ address_len = (int)(p - pp);
+
+ if((len == address_len) && (!strncmp(pp, transport, len)))
+ break;
+ pp = p + 1;
+ }
+ pp = p + 1;
+ for(p = pp; (*p != ',') && (*p); p++);
+ if (*p)
+ *p = '\0';
+ return True;
+}
+
+Private Bool
+_CheckSNEvent(
+ Display *display,
+ XEvent *xevent,
+ XPointer arg)
+{
+ XSelectionEvent *event = (XSelectionEvent *)xevent;
+ Window window = *(Window*)arg;
+
+ if((event->type == SelectionNotify) && (window == event->requestor))
+ return True;
+ return False;
+}
+
+Private Bool
+_XimGetSelectionNotify(
+ Display *display,
+ Window window,
+ Atom target,
+ char **ret_address)
+{
+ XEvent event;
+ XSelectionEvent *ev = (XSelectionEvent *)&event;
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems, bytes_after;
+
+ for(;;) {
+ XIfEvent(display, &event, _CheckSNEvent, (XPointer)&window);
+ if((ev->type == SelectionNotify) && (window == ev->requestor))
+ break;
+ }
+
+ if(ev->property == (Atom)None)
+ return False;
+ if( XGetWindowProperty( display, window, target, 0L, 1000000L,
+ True, target, &actual_type, &actual_format,
+ &nitems, &bytes_after,
+ (unsigned char **)&*ret_address ) != Success )
+ return False;
+ return True;
+}
+
+Private Bool
+_XimPreConnectionIM(
+ Xim im,
+ Atom selection)
+{
+ Display *display = im->core.display;
+ Atom locales, transport;
+ char *address;
+ XLCd lcd;
+ char *language;
+ char *territory;
+ char *codeset;
+ char *trans_addr;
+ char *locale_name[4], *locale;
+ int llen, tlen, clen;
+ register int i;
+ Window window;
+ char *str;
+
+ if(!(lcd = im->core.lcd))
+ return False;
+
+ for( i = 0; i < 4; i++ )
+ locale_name[i] = NULL;
+ /* requestor window */
+ if(!(window = XCreateSimpleWindow(display, DefaultRootWindow(display),
+ 0, 0, 1, 1, 1, 0, 0)))
+ return False;
+
+ /* server name check */
+ if( !(str = XGetAtomName( display, selection )) )
+ return False;
+ if(!_XimCheckServerName(im, str)) {
+ XFree( (XPointer)str );
+ goto Error;
+ }
+ XFree( (XPointer)str );
+
+ /* locale name check */
+ _XGetLCValues(lcd, XlcNLanguage, &language, XlcNTerritory, &territory,
+ XlcNCodeset, &codeset, NULL);
+ llen = strlen( language );
+ tlen = territory ? strlen( territory ): 0;
+ clen = codeset ? strlen( codeset ): 0;
+
+ if( tlen != 0 && clen != 0 ) {
+ if( (locale_name[0] = Xmalloc(llen+tlen+clen+3)) != NULL )
+ sprintf( locale_name[0], "%s_%s.%s", language, territory, codeset );
+ }
+ if( clen != 0 ) {
+ if( (locale_name[1] = Xmalloc(llen+clen+2)) != NULL )
+ sprintf( locale_name[1], "%s.%s", language, codeset );
+ else
+ goto Error;
+ }
+ if( tlen != 0 ) {
+ if( (locale_name[2] = Xmalloc(llen+tlen+2)) != NULL )
+ sprintf( locale_name[2], "%s_%s", language, territory );
+ else
+ goto Error;
+ }
+ if( (locale_name[3] = Xmalloc(llen+1)) != NULL )
+ strcpy( locale_name[3], language );
+ else
+ goto Error;
+ if((locales = XInternAtom(display, XIM_LOCALES, True)) == (Atom)None)
+ goto Error;
+
+ XConvertSelection(display, selection, locales, locales, window,
+ CurrentTime);
+ if(!(_XimGetSelectionNotify(display, window, locales, &address)))
+ goto Error;
+
+ if((locale = _XimCheckLocaleName(im, address, strlen(address), locale_name,
+ 4)) == NULL) {
+ XFree((XPointer)address);
+ goto Error;
+ }
+ im->private.proto.locale_name = locale;
+ for( i = 0; i < 4; i++ ) {
+ if( locale_name[i] != NULL && locale_name[i] != locale ) {
+ XFree( locale_name[i] );
+ locale_name[i] = NULL;
+ }
+ }
+ XFree((XPointer)address);
+
+ /* transport check */
+ if((transport = XInternAtom(display, XIM_TRANSPORT, True)) == (Atom)None)
+ goto Error;
+
+ XConvertSelection(display, selection, transport, transport, window,
+ CurrentTime);
+ if(!_XimGetSelectionNotify(display, window, transport, &address))
+ goto Error;
+
+ for(i = 0; _XimTransportRec[i].transportname ; i++) {
+ if( _XimCheckTransport(address, strlen(address),
+ _XimTransportRec[i].transportname,
+ strlen(_XimTransportRec[i].transportname),
+ &trans_addr)) {
+ if( _XimTransportRec[i].config(im, trans_addr) ) {
+ XFree((XPointer)address);
+ XDestroyWindow(display, window);
+ return True;
+ }
+ }
+ }
+
+ XFree((XPointer)address);
+Error:
+ for( i = 0; i < 4; i++ )
+ if( locale_name[i] != NULL )
+ XFree( locale_name[i] );
+ XDestroyWindow(display, window);
+ return False;
+}
+
+Private Bool
+_XimPreConnect(
+ Xim im)
+{
+ Display *display = im->core.display;
+ Atom imserver;
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *prop_return;
+ Atom *atoms;
+ Window im_window = 0;
+ register int i;
+
+ if((imserver = XInternAtom(display, XIM_SERVERS, True)) == (Atom)None)
+ return False;
+
+ if(XGetWindowProperty(display, RootWindow(display, 0),
+ imserver, 0L, 1000000L, False, XA_ATOM, &actual_type,
+ &actual_format, &nitems, &bytes_after,
+ &prop_return) != Success)
+ return False;
+
+ if( (actual_type != XA_ATOM) || (actual_format != 32) ) {
+ if( nitems )
+ XFree((XPointer)prop_return);
+ return False;
+ }
+
+ atoms = (Atom *)prop_return;
+ for(i = 0; i < nitems; i++) {
+ if((im_window = XGetSelectionOwner(display, atoms[i])) == (Window)None)
+ continue;
+
+ if(_XimPreConnectionIM(im, atoms[i]))
+ break;
+ }
+
+ XFree((XPointer)prop_return);
+ if(i >= nitems)
+ return False;
+
+ im->private.proto.im_window = im_window;
+ return True;
+}
+
+Private Bool
+_XimGetAuthProtocolNames(
+ Xim im,
+ CARD16 *buf,
+ CARD8 *num,
+ INT16 *len)
+{
+ if (!IS_USE_AUTHORIZATION_FUNC(im)) {
+ *num = 0;
+ *len = 0;
+ return True;
+ }
+ /*
+ * Not yet
+ */
+ return True;
+}
+
+Private Bool
+_XimSetAuthReplyData(
+ Xim im,
+ XPointer buf,
+ INT16 *len)
+{
+ /*
+ * Not yet
+ */
+ *len = 0;
+ return True;
+}
+
+Private Bool
+_XimSetAuthNextData(
+ Xim im,
+ XPointer buf,
+ INT16 *len)
+{
+ /*
+ * Not yet
+ */
+ *len = 0;
+ return True;
+}
+
+Private Bool
+_XimSetAuthRequiredData(
+ Xim im,
+ XPointer buf,
+ INT16 *len)
+{
+ /*
+ * Not yet
+ */
+ *len = 0;
+ return True;
+}
+
+Private Bool
+_XimCheckAuthSetupData(
+ Xim im,
+ XPointer buf)
+{
+ /*
+ * Not yet
+ */
+ return True;
+}
+
+Private Bool
+_XimCheckAuthNextData(
+ Xim im,
+ XPointer buf)
+{
+ /*
+ * Not yet
+ */
+ return True;
+}
+
+#define NO_MORE_AUTH 2
+#define GOOD_AUTH 1
+#define BAD_AUTH 0
+
+Private int
+_XimClientAuthCheck(
+ Xim im,
+ XPointer buf)
+{
+ /*
+ * Not yet
+ */
+ return NO_MORE_AUTH;
+}
+
+Private void
+_XimAuthNG(
+ Xim im)
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ INT16 len = 0;
+
+ _XimSetHeader((XPointer)buf, XIM_AUTH_NG, 0, &len);
+ (void)_XimWrite(im, len, (XPointer)buf);
+ _XimFlush(im);
+ return;
+}
+
+Private Bool
+_XimAllRecv(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ return True;
+}
+
+#define CLIENT_WAIT1 1
+#define CLIENT_WAIT2 2
+
+Private Bool
+_XimConnection(
+ Xim im)
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD8 *buf_b = &buf[XIM_HEADER_SIZE];
+ CARD16 *buf_s = (CARD16 *)((XPointer)buf_b);
+ INT16 len;
+ CARD8 num;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ CARD8 major_opcode;
+ int wait_mode;
+ int ret;
+
+ if(!(_XimConnect(im))) /* Transport Connect */
+ return False;
+
+ if(!_XimDispatchInit(im))
+ return False;
+
+ _XimRegProtoIntrCallback(im, XIM_ERROR, 0, _XimErrorCallback, (XPointer)im);
+
+ if(!_XimGetAuthProtocolNames(im, &buf_s[4], &num, &len))
+ return False;
+
+ im->private.proto.protocol_major_version = PROTOCOLMAJORVERSION;
+ im->private.proto.protocol_minor_version = PROTOCOLMINORVERSION;
+
+ buf_b[0] = _XimGetMyEndian();
+ buf_b[1] = 0;
+ buf_s[1] = PROTOCOLMAJORVERSION;
+ buf_s[2] = PROTOCOLMINORVERSION;
+ buf_s[3] = num;
+ len += sizeof(CARD8)
+ + sizeof(CARD8)
+ + sizeof(CARD16)
+ + sizeof(CARD16)
+ + sizeof(CARD16);
+
+ major_opcode = XIM_CONNECT;
+ wait_mode = (IS_USE_AUTHORIZATION_FUNC(im)) ? CLIENT_WAIT1 : CLIENT_WAIT2;
+
+ for(;;) {
+ _XimSetHeader((XPointer)buf, major_opcode, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, reply, buf_size, _XimAllRecv, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size, _XimAllRecv, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+
+ major_opcode = *((CARD8 *)preply);
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+
+ if (wait_mode == CLIENT_WAIT1) {
+ if (major_opcode == XIM_AUTH_REQUIRED) {
+ ret = _XimClientAuthCheck(im, (XPointer)buf_s);
+ if(reply != preply)
+ Xfree(preply);
+ if (ret == NO_MORE_AUTH) {
+ if (!(_XimSetAuthReplyData(im,
+ (XPointer)&buf[XIM_HEADER_SIZE], &len))) {
+ _XimAuthNG(im);
+ return False;
+ }
+ major_opcode = XIM_AUTH_REPLY;
+ wait_mode = CLIENT_WAIT2;
+ } else if (ret == GOOD_AUTH) {
+ if (!(_XimSetAuthNextData(im,
+ (XPointer)&buf[XIM_HEADER_SIZE], &len))) {
+ _XimAuthNG(im);
+ return False;
+ }
+ major_opcode = XIM_AUTH_NEXT;
+ } else { /* BAD_AUTH */
+ _XimAuthNG(im);
+ return False;
+ }
+ } else {
+ if(reply != preply)
+ Xfree(preply);
+ _XimAuthNG(im);
+ return False;
+ }
+ } else { /* CLIENT_WAIT2 */
+ if (major_opcode == XIM_CONNECT_REPLY) {
+ break;
+ } else if (major_opcode == XIM_AUTH_SETUP) {
+ if (!(_XimCheckAuthSetupData(im, (XPointer)buf_s))) {
+ _XimAuthNG(im);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ if (!(_XimSetAuthRequiredData(im,
+ (XPointer)&buf[XIM_HEADER_SIZE], &len))) {
+ _XimAuthNG(im);
+ return False;
+ }
+ major_opcode = XIM_AUTH_REQUIRED;
+ } else if (major_opcode == XIM_AUTH_NEXT) {
+ if (!(_XimCheckAuthNextData(im, (XPointer)buf_s))) {
+ _XimAuthNG(im);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ if (!(_XimSetAuthRequiredData(im,
+ (XPointer)&buf[XIM_HEADER_SIZE], &len))) {
+ _XimAuthNG(im);
+ return False;
+ }
+ major_opcode = XIM_AUTH_REQUIRED;
+ } else if (major_opcode == XIM_AUTH_NG) {
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ } else {
+ _XimAuthNG(im);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ }
+ }
+
+ if (!( buf_s[0] == im->private.proto.protocol_major_version
+ && buf_s[1] == im->private.proto.protocol_minor_version)) {
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ MARK_SERVER_CONNECTED(im);
+
+ _XimRegProtoIntrCallback(im, XIM_REGISTER_TRIGGERKEYS, 0,
+ _XimRegisterTriggerKeysCallback, (XPointer)im);
+ return True;
+}
+
+Private Bool
+_XimDisconnectCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+
+ if ((major_opcode == XIM_DISCONNECT_REPLY)
+ && (minor_opcode == 0))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0))
+ return True;
+ return False;
+}
+
+Private Bool
+_XimDisconnect(
+ Xim im)
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ INT16 len = 0;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+
+ if (IS_SERVER_CONNECTED(im)) {
+ _XimSetHeader((XPointer)buf, XIM_DISCONNECT, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimDisconnectCheck, 0);
+ if(ret_code == XIM_OVERFLOW) {
+ if(len > 0) {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimDisconnectCheck, 0);
+ Xfree(preply);
+ if(ret_code != XIM_TRUE)
+ return False;
+ }
+ } else if(ret_code == XIM_FALSE)
+ return False;
+
+ }
+ if (!(_XimShutdown(im))) /* Transport shutdown */
+ return False;
+ return True;
+}
+
+Private Bool
+_XimOpenCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+
+ if ((major_opcode == XIM_OPEN_REPLY)
+ && (minor_opcode == 0))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0))
+ return True;
+ return False;
+}
+
+Private Bool
+_XimOpen(
+ Xim im)
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD8 *buf_b = &buf[XIM_HEADER_SIZE];
+ CARD16 *buf_s;
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ char *locale_name;
+
+ locale_name = im->private.proto.locale_name;
+ len = strlen(locale_name);
+ buf_b[0] = (BYTE)len; /* length of locale name */
+ (void)strcpy((char *)&buf_b[1], locale_name); /* locale name */
+ len += sizeof(BYTE); /* sizeof length */
+ XIM_SET_PAD(buf_b, len); /* pad */
+
+ _XimSetHeader((XPointer)buf, XIM_OPEN, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, reply, buf_size,
+ _XimOpenCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimOpenCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+
+ im->private.proto.imid = buf_s[0]; /* imid */
+
+ if (!(_XimGetAttributeID(im, &buf_s[1]))) {
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+
+ if (!(_XimSetInnerIMResourceList(&(im->private.proto.im_inner_resources),
+ &(im->private.proto.im_num_inner_resources))))
+ return False;
+
+ if (!(_XimSetInnerICResourceList(&(im->private.proto.ic_inner_resources),
+ &(im->private.proto.ic_num_inner_resources))))
+ return False;
+
+ _XimSetIMMode(im->core.im_resources, im->core.im_num_resources);
+ _XimSetIMMode(im->private.proto.im_inner_resources,
+ im->private.proto.im_num_inner_resources);
+
+ /* Transport Callbak */
+ _XimRegProtoIntrCallback(im, XIM_SET_EVENT_MASK, 0,
+ _XimSetEventMaskCallback, (XPointer)im);
+ _XimRegProtoIntrCallback(im, XIM_FORWARD_EVENT, 0,
+ _XimForwardEventCallback, (XPointer)im);
+ _XimRegProtoIntrCallback(im, XIM_COMMIT, 0,
+ _XimCommitCallback, (XPointer)im);
+ _XimRegProtoIntrCallback(im, XIM_SYNC, 0,
+ _XimSyncCallback, (XPointer)im);
+
+ if(!_XimExtension(im))
+ return False;
+
+ /* register a hook for callback protocols */
+ _XimRegisterDispatcher(im, _XimCbDispatch, (XPointer)im);
+
+ return True;
+}
+
+Private Bool
+_XimCloseCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+
+ if ((major_opcode == XIM_CLOSE_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid))
+ return True;
+ return False;
+}
+
+Private Bool
+_XimClose(
+ Xim im)
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+
+ if (!IS_SERVER_CONNECTED(im))
+ return True;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = 0; /* unused */
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof unused */
+
+ _XimSetHeader((XPointer)buf, XIM_CLOSE, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimCloseCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size, _XimCloseCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+
+ if(reply != preply)
+ Xfree(preply);
+ return True;
+}
+
+Public void
+_XimProtoIMFree(
+ Xim im)
+{
+ /* XIMPrivateRec */
+ if (im->private.proto.im_onkeylist) {
+ Xfree(im->private.proto.im_onkeylist);
+ im->private.proto.im_onkeylist = NULL;
+ }
+ if (im->private.proto.im_offkeylist) {
+ Xfree(im->private.proto.im_offkeylist);
+ im->private.proto.im_offkeylist = NULL;
+ }
+ if (im->private.proto.intrproto) {
+ _XimFreeProtoIntrCallback(im);
+ im->private.proto.intrproto = NULL;
+ }
+ if (im->private.proto.im_inner_resources) {
+ Xfree(im->private.proto.im_inner_resources);
+ im->private.proto.im_inner_resources = NULL;
+ }
+ if (im->private.proto.ic_inner_resources) {
+ Xfree(im->private.proto.ic_inner_resources);
+ im->private.proto.ic_inner_resources = NULL;
+ }
+ if (im->private.proto.hold_data) {
+ Xfree(im->private.proto.hold_data);
+ im->private.proto.hold_data = NULL;
+ }
+ if (im->private.proto.locale_name) {
+ Xfree(im->private.proto.locale_name);
+ im->private.proto.locale_name = NULL;
+ }
+ if (im->private.proto.ctom_conv) {
+ _XlcCloseConverter(im->private.proto.ctom_conv);
+ im->private.proto.ctom_conv = NULL;
+ }
+ if (im->private.proto.ctow_conv) {
+ _XlcCloseConverter(im->private.proto.ctow_conv);
+ im->private.proto.ctow_conv = NULL;
+ }
+ if (im->private.proto.ctoutf8_conv) {
+ _XlcCloseConverter(im->private.proto.ctoutf8_conv);
+ im->private.proto.ctoutf8_conv = NULL;
+ }
+ if (im->private.proto.cstomb_conv) {
+ _XlcCloseConverter(im->private.proto.cstomb_conv);
+ im->private.proto.cstomb_conv = NULL;
+ }
+ if (im->private.proto.cstowc_conv) {
+ _XlcCloseConverter(im->private.proto.cstowc_conv);
+ im->private.proto.cstowc_conv = NULL;
+ }
+ if (im->private.proto.cstoutf8_conv) {
+ _XlcCloseConverter(im->private.proto.cstoutf8_conv);
+ im->private.proto.cstoutf8_conv = NULL;
+ }
+ if (im->private.proto.ucstoc_conv) {
+ _XlcCloseConverter(im->private.proto.ucstoc_conv);
+ im->private.proto.ucstoc_conv = NULL;
+ }
+ if (im->private.proto.ucstoutf8_conv) {
+ _XlcCloseConverter(im->private.proto.ucstoutf8_conv);
+ im->private.proto.ucstoutf8_conv = NULL;
+ }
+
+#ifdef XIM_CONNECTABLE
+ if (!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im)) {
+ return;
+ }
+#endif /* XIM_CONNECTABLE */
+
+ if (im->private.proto.saved_imvalues) {
+ Xfree(im->private.proto.saved_imvalues);
+ im->private.proto.saved_imvalues = NULL;
+ }
+ if (im->private.proto.default_styles) {
+ Xfree(im->private.proto.default_styles);
+ im->private.proto.default_styles = NULL;
+ }
+
+ /* core */
+ if (im->core.res_name) {
+ Xfree(im->core.res_name);
+ im->core.res_name = NULL;
+ }
+ if (im->core.res_class) {
+ Xfree(im->core.res_class);
+ im->core.res_class = NULL;
+ }
+ if (im->core.im_values_list) {
+ Xfree(im->core.im_values_list);
+ im->core.im_values_list = NULL;
+ }
+ if (im->core.ic_values_list) {
+ Xfree(im->core.ic_values_list);
+ im->core.ic_values_list = NULL;
+ }
+ if (im->core.im_name) {
+ Xfree(im->core.im_name);
+ im->core.im_name = NULL;
+ }
+ if (im->core.styles) {
+ Xfree(im->core.styles);
+ im->core.styles = NULL;
+ }
+ if (im->core.im_resources) {
+ Xfree(im->core.im_resources);
+ im->core.im_resources = NULL;
+ }
+ if (im->core.ic_resources) {
+ Xfree(im->core.ic_resources);
+ im->core.ic_resources = NULL;
+ }
+
+ return;
+}
+
+Private Status
+_XimProtoCloseIM(
+ XIM xim)
+{
+ Xim im = (Xim)xim;
+ XIC ic;
+ XIC next;
+ Status status;
+
+ ic = im->core.ic_chain;
+ while (ic) {
+ (*ic->methods->destroy) (ic);
+ next = ic->core.next;
+#ifdef XIM_CONNECTABLE
+ if (!(!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im))) {
+ Xfree ((char *) ic);
+ }
+#else
+ Xfree ((char *) ic);
+#endif /* XIM_CONNECTABLE */
+ ic = next;
+ }
+#ifdef XIM_CONNECTABLE
+ if (!(!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im)))
+ im->core.ic_chain = NULL;
+#else
+ im->core.ic_chain = NULL;
+#endif
+
+ _XimUnregisterServerFilter(im);
+ _XimResetIMInstantiateCallback(im);
+ status = (Status)_XimClose(im);
+ status = (Status)_XimDisconnect(im) && status;
+ _XimProtoIMFree(im);
+#ifdef XIM_CONNECTABLE
+ if (!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im)) {
+ _XimReconnectModeSetAttr(im);
+ for (ic = im->core.ic_chain; ic; ic = ic->core.next) {
+ _XimReconnectModeCreateIC(ic);
+ }
+ return 0;
+ }
+#endif /* XIM_CONNECTABLE */
+ _XimDestroyIMStructureList(im);
+ return status;
+}
+
+#ifdef XIM_CONNECTABLE
+Private Bool
+_XimCheckIMQuarkList(
+ XrmQuark *quark_list,
+ int num_quark,
+ XrmQuark quark)
+{
+ register int i;
+
+ for (i = 0; i < num_quark; i++) {
+ if (quark_list[i] == quark) {
+ return True;
+ }
+ }
+ return False;
+}
+
+Private Bool
+_XimSaveIMValues(
+ Xim im,
+ XIMArg *arg)
+{
+ register XIMArg *p;
+ register int n;
+ XrmQuark *quark_list;
+ XrmQuark *tmp;
+ XrmQuark quark;
+ int num_quark;
+
+ if (quark_list = im->private.proto.saved_imvalues) {
+ num_quark = im->private.proto.num_saved_imvalues;
+ for (p = arg; p && p->name; p++) {
+ quark = XrmStringToQuark(p->name);
+ if (_XimCheckIMQuarkList(quark_list, num_quark, quark)) {
+ continue;
+ }
+ if (!(tmp = (XrmQuark *)Xrealloc(quark_list,
+ (sizeof(XrmQuark) * (num_quark + 1))))) {
+ im->private.proto.saved_imvalues = quark_list;
+ im->private.proto.num_saved_imvalues = num_quark;
+ return False;
+ }
+ num_quark++;
+ quark_list = tmp;
+ quark_list[num_quark] = quark;
+ }
+ im->private.proto.saved_imvalues = quark_list;
+ im->private.proto.num_saved_imvalues = num_quark;
+ return True;
+ }
+
+ for (p = arg, n = 0; p && p->name; p++, n++);
+
+ if (!(quark_list = (XrmQuark *)Xmalloc(sizeof(XrmQuark) * n))) {
+ return False;
+ }
+
+ im->private.proto.saved_imvalues = quark_list;
+ im->private.proto.num_saved_imvalues = n;
+ for (p = arg; p && p->name; p++, quark_list++) {
+ *quark_list = XrmStringToQuark(p->name);
+ }
+
+ return True;
+}
+
+Private char *
+_XimDelayModeSetIMValues(
+ Xim im,
+ XIMArg *arg)
+{
+ XimDefIMValues im_values;
+ char *name;
+ XIMArg *values;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ name = _XimSetIMValueData(im, (XPointer)&im_values, values,
+ im->core.im_resources, im->core.im_num_resources);
+ _XimSetCurrentIMValues(im, &im_values);
+
+ return name;
+}
+#endif /* XIM_CONNECTABLE */
+
+Private Bool
+_XimSetIMValuesCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+
+ if ((major_opcode == XIM_SET_IM_VALUES_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid))
+ return True;
+ return False;
+}
+
+Private char *
+_XimProtoSetIMValues(
+ XIM xim,
+ XIMArg *arg)
+{
+ Xim im = (Xim)xim;
+ XimDefIMValues im_values;
+ INT16 len;
+ CARD16 *buf_s;
+ char *tmp;
+ CARD32 tmp_buf32[BUFSIZE/4];
+ char *tmp_buf = (char *)tmp_buf32;
+ char *buf;
+ int buf_size;
+ char *data;
+ int data_len;
+ int ret_len;
+ int total;
+ XIMArg *arg_ret;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int ret_code;
+ char *name;
+
+#ifndef XIM_CONNECTABLE
+ if (!IS_SERVER_CONNECTED(im))
+ return arg->name;
+#else
+ if (!_XimSaveIMValues(im, arg))
+ return arg->name;
+
+ if (!IS_SERVER_CONNECTED(im)) {
+ if (IS_CONNECTABLE(im)) {
+ if (!_XimConnectServer(im)) {
+ return _XimDelayModeSetIMValues(im, arg);
+ }
+ } else {
+ return arg->name;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ _XimGetCurrentIMValues(im, &im_values);
+ buf = tmp_buf;
+ buf_size = XIM_HEADER_SIZE + sizeof(CARD16) + sizeof(INT16);
+ data_len = BUFSIZE - buf_size;
+ total = 0;
+ arg_ret = arg;
+ for (;;) {
+ data = &buf[buf_size];
+ if ((name = _XimEncodeIMATTRIBUTE(im, im->core.im_resources,
+ im->core.im_num_resources, arg, &arg_ret, data, data_len,
+ &ret_len, (XPointer)&im_values, XIM_SETIMVALUES))) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ break;
+ }
+
+ total += ret_len;
+ if (!(arg = arg_ret)) {
+ break;
+ }
+
+ buf_size += ret_len;
+ if (buf == tmp_buf) {
+ if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ return arg->name;
+ }
+ memcpy(tmp, buf, buf_size);
+ buf = tmp;
+ } else {
+ if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ Xfree(buf);
+ return arg->name;
+ }
+ buf = tmp;
+ }
+ }
+ _XimSetCurrentIMValues(im, &im_values);
+
+ if (!total)
+ return (char *)NULL;
+
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ buf_s[0] = im->private.proto.imid;
+ buf_s[1] = (INT16)total;
+
+ len = (INT16)(sizeof(CARD16) + sizeof(INT16) + total);
+ _XimSetHeader((XPointer)buf, XIM_SET_IM_VALUES, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ return arg->name;
+ }
+ _XimFlush(im);
+ if (buf != tmp_buf)
+ Xfree(buf);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimSetIMValuesCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = (int)len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, reply, buf_size,
+ _XimSetIMValuesCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return arg->name;
+ }
+ }
+ } else
+ return arg->name;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return arg->name;
+ }
+ if(reply != preply)
+ Xfree(preply);
+
+ return name;
+}
+
+#ifdef XIM_CONNECTABLE
+Private char *
+_XimDelayModeGetIMValues(
+ Xim im,
+ XIMArg *arg)
+{
+ XimDefIMValues im_values;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ return(_XimGetIMValueData(im, (XPointer)&im_values, arg,
+ im->core.im_resources, im->core.im_num_resources));
+}
+#endif /* XIM_CONNECTABLE */
+
+Private Bool
+_XimGetIMValuesCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+
+ if ((major_opcode == XIM_GET_IM_VALUES_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid))
+ return True;
+ return False;
+}
+
+Private char *
+_XimProtoGetIMValues(
+ XIM xim,
+ XIMArg *arg)
+{
+ Xim im = (Xim)xim;
+ register XIMArg *p;
+ register int n;
+ CARD8 *buf;
+ CARD16 *buf_s;
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply = NULL;
+ int buf_size;
+ int ret_code;
+ char *makeid_name;
+ char *decode_name;
+ CARD16 *data = NULL;
+ INT16 data_len = 0;
+
+#ifndef XIM_CONNECTABLE
+ if (!IS_SERVER_CONNECTED(im))
+ return arg->name;
+#else
+ if (!IS_SERVER_CONNECTED(im)) {
+ if (IS_CONNECTABLE(im)) {
+ if (!_XimConnectServer(im)) {
+ return _XimDelayModeGetIMValues(im, arg);
+ }
+ } else {
+ return arg->name;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ for (n = 0, p = arg; p->name; p++)
+ n++;
+
+ if (!n)
+ return (char *)NULL;
+
+ buf_size = sizeof(CARD16) * n;
+ buf_size += XIM_HEADER_SIZE
+ + sizeof(CARD16)
+ + sizeof(INT16)
+ + XIM_PAD(buf_size);
+
+ if (!(buf = (CARD8 *)Xmalloc(buf_size)))
+ return arg->name;
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+
+ makeid_name = _XimMakeIMAttrIDList(im, im->core.im_resources,
+ im->core.im_num_resources, arg,
+ &buf_s[2], &len, XIM_GETIMVALUES);
+
+ if (len) {
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = len; /* length of im-attr-id */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += sizeof(CARD16) /* sizeof imid */
+ + sizeof(INT16); /* sizeof length of attr */
+
+ _XimSetHeader((XPointer)buf, XIM_GET_IM_VALUES, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ Xfree(buf);
+ return arg->name;
+ }
+ _XimFlush(im);
+ Xfree(buf);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimGetIMValuesCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimGetIMValuesCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return arg->name;
+ }
+ }
+ } else
+ return arg->name;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return arg->name;
+ }
+ data = &buf_s[2];
+ data_len = buf_s[1];
+ }
+ decode_name = _XimDecodeIMATTRIBUTE(im, im->core.im_resources,
+ im->core.im_num_resources, data, data_len,
+ arg, XIM_GETIMVALUES);
+ if (reply != preply)
+ Xfree(preply);
+
+ if (decode_name)
+ return decode_name;
+ else
+ return makeid_name;
+}
+
+Private XIMMethodsRec im_methods = {
+ _XimProtoCloseIM, /* close */
+ _XimProtoSetIMValues, /* set_values */
+ _XimProtoGetIMValues, /* get_values */
+ _XimProtoCreateIC, /* create_ic */
+ _Ximctstombs, /* ctstombs */
+ _Ximctstowcs, /* ctstowcs */
+ _Ximctstoutf8 /* ctstoutf8 */
+};
+
+Private Bool
+_XimSetEncodingByName(
+ Xim im,
+ char **buf,
+ int *len)
+{
+ char *encoding = (char *)NULL;
+ int encoding_len;
+ int compound_len;
+ BYTE *ret;
+
+ _XGetLCValues(im->core.lcd, XlcNCodeset, &encoding, NULL);
+ if (!encoding) {
+ *buf = (char *)NULL;
+ *len = 0;
+ return True;
+ }
+ encoding_len = strlen(encoding);
+ compound_len = strlen("COMPOUND_TEXT");
+ *len = encoding_len + sizeof(BYTE) + compound_len + sizeof(BYTE);
+ if (!(ret = (BYTE *)Xmalloc(*len))) {
+ return False;
+ }
+ *buf = (char *)ret;
+
+ ret[0] = (BYTE)encoding_len;
+ (void)strncpy((char *)&ret[1], encoding, encoding_len);
+ ret += (encoding_len + sizeof(BYTE));
+ ret[0] = (BYTE)compound_len;
+ (void)strncpy((char *)&ret[1], "COMPOUND_TEXT", compound_len);
+ return True;
+}
+
+Private Bool
+_XimSetEncodingByDetail(
+ Xim im,
+ char **buf,
+ int *len)
+{
+ *len = 0;
+ *buf = NULL;
+ return True;
+}
+
+Private Bool
+_XimGetEncoding(
+ Xim im,
+ CARD16 *buf,
+ char *name,
+ int name_len,
+ char *detail,
+ int detail_len)
+{
+ XLCd lcd = im->core.lcd;
+ CARD16 category = buf[0];
+ CARD16 idx = buf[1];
+ int len;
+ XlcConv ctom_conv = NULL;
+ XlcConv ctow_conv = NULL;
+ XlcConv ctoutf8_conv = NULL;
+ XlcConv conv;
+ XimProtoPrivateRec *private = &im->private.proto;
+
+ if (idx == (CARD16)XIM_Default_Encoding_IDX) { /* XXX */
+ if (!(ctom_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNMultiByte)))
+ return False;
+ if (!(ctow_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNWideChar)))
+ return False;
+ if (!(ctoutf8_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNUtf8String)))
+ return False;
+ }
+
+ if (category == XIM_Encoding_NameCategory) {
+ while (name_len > 0) {
+ len = (int)name[0];
+ if (!strncmp(&name[1], "COMPOUND_TEXT", len)) {
+ if (!(ctom_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNMultiByte)))
+ return False;
+ if (!(ctow_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNWideChar)))
+ return False;
+ if (!(ctoutf8_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNUtf8String)))
+ return False;
+ break;
+ } else {
+ /*
+ * Not yet
+ */
+ }
+ len += sizeof(BYTE);
+ name_len -= len;
+ name += len;
+ }
+ } else if (category == XIM_Encoding_DetailCategory) {
+ /*
+ * Not yet
+ */
+ } else {
+ return False;
+ }
+
+ private->ctom_conv = ctom_conv;
+ private->ctow_conv = ctow_conv;
+ private->ctoutf8_conv = ctoutf8_conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte)))
+ return False;
+ private->cstomb_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNWideChar)))
+ return False;
+ private->cstowc_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNUtf8String)))
+ return False;
+ private->cstoutf8_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNChar)))
+ return False;
+ private->ucstoc_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNUtf8String)))
+ return False;
+ private->ucstoutf8_conv = conv;
+
+ return True;
+}
+
+Private Bool
+_XimEncodingNegoCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+
+ if ((major_opcode == XIM_ENCODING_NEGOTIATION_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid))
+ return True;
+ return False;
+}
+
+Private Bool
+_XimEncodingNegotiation(
+ Xim im)
+{
+ char *name_ptr = 0;
+ int name_len = 0;
+ char *detail_ptr = 0;
+ int detail_len = 0;
+ CARD8 *buf;
+ CARD16 *buf_s;
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+
+ if (!(_XimSetEncodingByName(im, &name_ptr, &name_len)))
+ return False;
+
+ if (!(_XimSetEncodingByDetail(im, &detail_ptr, &detail_len))) {
+ if (name_ptr)
+ Xfree(name_ptr);
+ return False;
+ }
+
+ len = sizeof(CARD16)
+ + sizeof(INT16)
+ + name_len
+ + XIM_PAD(name_len)
+ + sizeof(INT16)
+ + sizeof(CARD16)
+ + detail_len;
+
+ if (!(buf = (CARD8 *)Xmalloc(XIM_HEADER_SIZE + len))) {
+ if (name_ptr)
+ Xfree(name_ptr);
+ if (detail_ptr)
+ Xfree(detail_ptr);
+ return False;
+ }
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+
+ buf_s[0] = im->private.proto.imid;
+ buf_s[1] = (INT16)name_len;
+ if (name_ptr)
+ (void)memcpy((char *)&buf_s[2], name_ptr, name_len);
+ XIM_SET_PAD(&buf_s[2], name_len);
+ buf_s = (CARD16 *)((char *)&buf_s[2] + name_len);
+ buf_s[0] = detail_len;
+ buf_s[1] = 0;
+ if (detail_ptr)
+ (void)memcpy((char *)&buf_s[2], detail_ptr, detail_len);
+
+ _XimSetHeader((XPointer)buf, XIM_ENCODING_NEGOTIATION, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ Xfree(buf);
+ return False;
+ }
+ _XimFlush(im);
+ Xfree(buf);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimEncodingNegoCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimEncodingNegoCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+
+ if (!(_XimGetEncoding(im, &buf_s[1], name_ptr, name_len,
+ detail_ptr, detail_len))) {
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if (name_ptr)
+ Xfree(name_ptr);
+ if (detail_ptr)
+ Xfree(detail_ptr);
+
+ if(reply != preply)
+ Xfree(preply);
+
+ return True;
+}
+
+#ifdef XIM_CONNECTABLE
+Private Bool
+_XimSendSavedIMValues(
+ Xim im)
+{
+ XimDefIMValues im_values;
+ INT16 len;
+ CARD16 *buf_s;
+ char *tmp;
+ CARD32 tmp_buf32[BUFSIZE/4];
+ char *tmp_buf = (char *)tmp_buf32;
+ char *buf;
+ int buf_size;
+ char *data;
+ int data_len;
+ int ret_len;
+ int total;
+ int idx;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int ret_code;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ buf = tmp_buf;
+ buf_size = XIM_HEADER_SIZE + sizeof(CARD16) + sizeof(INT16);
+ data_len = BUFSIZE - buf_size;
+ total = 0;
+ idx = 0;
+ for (;;) {
+ data = &buf[buf_size];
+ if (!_XimEncodeSavedIMATTRIBUTE(im, im->core.im_resources,
+ im->core.im_num_resources, &idx, data, data_len,
+ &ret_len, (XPointer)&im_values, XIM_SETIMVALUES)) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ return False;
+ }
+
+ total += ret_len;
+ if (idx == -1) {
+ break;
+ }
+
+ buf_size += ret_len;
+ if (buf == tmp_buf) {
+ if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ return False;
+ }
+ memcpy(tmp, buf, buf_size);
+ buf = tmp;
+ } else {
+ if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ Xfree(buf);
+ return False;
+ }
+ buf = tmp;
+ }
+ }
+
+ if (!total)
+ return True;
+
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ buf_s[0] = im->private.proto.imid;
+ buf_s[1] = (INT16)total;
+
+ len = (INT16)(sizeof(CARD16) + sizeof(INT16) + total);
+ _XimSetHeader((XPointer)buf, XIM_SET_IM_VALUES, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ return False;
+ }
+ _XimFlush(im);
+ if (buf != tmp_buf)
+ Xfree(buf);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimSetIMValuesCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = (int)len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, reply, buf_size,
+ _XimSetIMValuesCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+
+ return True;
+}
+
+Private void
+_XimDelayModeIMFree(
+ Xim im)
+{
+ if (im->core.im_resources) {
+ Xfree(im->core.im_resources);
+ im->core.im_resources = NULL;
+ }
+ if (im->core.ic_resources) {
+ Xfree(im->core.ic_resources);
+ im->core.ic_resources = NULL;
+ }
+ if (im->core.im_values_list) {
+ Xfree(im->core.im_values_list);
+ im->core.im_values_list = NULL;
+ }
+ if (im->core.ic_values_list) {
+ Xfree(im->core.ic_values_list);
+ im->core.ic_values_list = NULL;
+ }
+ return;
+}
+
+Public Bool
+_XimConnectServer(
+ Xim im)
+{
+ Xim save_im;
+
+ if (!(save_im = (Xim)Xmalloc(sizeof(XimRec))))
+ return False;
+ memcpy((char *)save_im, (char *)im, sizeof(XimRec));
+
+ if (_XimPreConnect(im) && _XimConnection(im)
+ && _XimOpen(im) && _XimEncodingNegotiation(im)) {
+ if (_XimSendSavedIMValues(im)) {
+ _XimDelayModeIMFree(save_im);
+ _XimRegisterServerFilter(im);
+ Xfree(save_im);
+ return True;
+ }
+ }
+ memcpy((char *)im, (char *)save_im, sizeof(XimRec));
+ Xfree(save_im);
+ return False;
+}
+
+Public Bool
+_XimDelayModeSetAttr(
+ Xim im)
+{
+ XimDefIMValues im_values;
+
+ if(!_XimSetIMResourceList(&im->core.im_resources,
+ &im->core.im_num_resources)) {
+ return False;
+ }
+ if(!_XimSetICResourceList(&im->core.ic_resources,
+ &im->core.ic_num_resources)) {
+ return False;
+ }
+
+ _XimSetIMMode(im->core.im_resources, im->core.im_num_resources);
+
+ _XimGetCurrentIMValues(im, &im_values);
+ if(!_XimSetLocalIMDefaults(im, (XPointer)&im_values,
+ im->core.im_resources, im->core.im_num_resources)) {
+ return False;
+ }
+ _XimSetCurrentIMValues(im, &im_values);
+ if (im->private.proto.default_styles) {
+ if (im->core.styles)
+ Xfree(im->core.styles);
+ im->core.styles = im->private.proto.default_styles;
+ }
+
+ return True;
+}
+
+Private Bool
+_XimReconnectModeSetAttr(
+ Xim im)
+{
+ XimDefIMValues im_values;
+
+ if(!_XimSetIMResourceList(&im->core.im_resources,
+ &im->core.im_num_resources)) {
+ return False;
+ }
+ if(!_XimSetICResourceList(&im->core.ic_resources,
+ &im->core.ic_num_resources)) {
+ return False;
+ }
+
+ _XimSetIMMode(im->core.im_resources, im->core.im_num_resources);
+
+ if (im->private.proto.default_styles) {
+ if (im->core.styles)
+ Xfree(im->core.styles);
+ im->core.styles = im->private.proto.default_styles;
+ }
+
+ return True;
+}
+#endif /* XIM_CONNECTABLE */
+
+Public Bool
+_XimProtoOpenIM(
+ Xim im)
+{
+ _XimInitialResourceInfo();
+
+ im->methods = &im_methods;
+
+#ifdef XIM_CONNECTABLE
+ _XimSetProtoResource(im);
+#endif /* XIM_CONNECTABLE */
+
+ if (_XimPreConnect(im)) {
+ if (_XimConnection(im) && _XimOpen(im) && _XimEncodingNegotiation(im)) {
+ _XimRegisterServerFilter(im);
+ return True;
+ }
+ _XimShutdown(im);
+#ifdef XIM_CONNECTABLE
+ } else if (IS_DELAYBINDABLE(im)) {
+ if (_XimDelayModeSetAttr(im))
+ return True;
+#endif /* XIM_CONNECTABLE */
+ }
+ _XimProtoIMFree(im);
+ return False;
+}
diff --git a/nx-X11/lib/X11/imDefLkup.c b/nx-X11/lib/X11/imDefLkup.c
new file mode 100644
index 000000000..aa1aaaf06
--- /dev/null
+++ b/nx-X11/lib/X11/imDefLkup.c
@@ -0,0 +1,1171 @@
+/* $Xorg: imDefLkup.c,v 1.3 2000/08/17 19:45:12 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+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 of FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imDefLkup.c,v 3.11 2003/06/23 17:35:43 eich Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xatom.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Public Xic
+_XimICOfXICID(
+ Xim im,
+ XICID icid)
+{
+ Xic pic;
+
+ for (pic = (Xic)im->core.ic_chain; pic; pic = (Xic)pic->core.next) {
+ if (pic->private.proto.icid == icid)
+ return pic;
+ }
+ return (Xic)0;
+}
+
+Private void
+_XimProcIMSetEventMask(
+ Xim im,
+ XPointer buf)
+{
+ EVENTMASK *buf_l = (EVENTMASK *)buf;
+
+ im->private.proto.forward_event_mask = buf_l[0];
+ im->private.proto.synchronous_event_mask = buf_l[1];
+ return;
+}
+
+Private void
+_XimProcICSetEventMask(
+ Xic ic,
+ XPointer buf)
+{
+ EVENTMASK *buf_l = (EVENTMASK *)buf;
+
+ ic->private.proto.forward_event_mask = buf_l[0];
+ ic->private.proto.synchronous_event_mask = buf_l[1];
+ _XimReregisterFilter(ic);
+ return;
+}
+
+Public Bool
+_XimSetEventMaskCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Xim im = (Xim)call_data;
+ Xic ic;
+
+ if (imid == im->private.proto.imid) {
+ if (icid) {
+ ic = _XimICOfXICID(im, icid);
+ _XimProcICSetEventMask(ic, (XPointer)&buf_s[2]);
+ } else {
+ _XimProcIMSetEventMask(im, (XPointer)&buf_s[2]);
+ }
+ return True;
+ }
+ return False;
+}
+
+Private Bool
+_XimSyncCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+
+ if ((major_opcode == XIM_SYNC_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ return True;
+ return False;
+}
+
+Public Bool
+_XimSync(
+ Xim im,
+ Xic ic)
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_SYNC, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimSyncCheck, (XPointer)ic);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(len);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimSyncCheck, (XPointer)ic);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else {
+ return False;
+ }
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ return True;
+}
+
+Public Bool
+_XimProcSyncReply(
+ Xim im,
+ Xic ic)
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_SYNC_REPLY, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ return True;
+}
+
+Public Bool
+_XimRespSyncReply(
+ Xic ic,
+ BITMASK16 mode)
+{
+ if (mode & XimSYNCHRONUS) /* SYNC Request */
+ MARK_NEED_SYNC_REPLY(ic);
+ return True;
+}
+
+Public Bool
+_XimSyncCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Xim im = (Xim)call_data;
+ Xic ic;
+
+ if ((imid == im->private.proto.imid)
+ && (ic = _XimICOfXICID(im, icid))) {
+ (void)_XimProcSyncReply(im, ic);
+ return True;
+ }
+ return False;
+}
+
+Private INT16
+_XimSetEventToWire(
+ XEvent *ev,
+ xEvent *event)
+{
+ if (!(_XimProtoEventToWire(ev, event, False)))
+ return 0;
+ event->u.u.sequenceNumber =
+ ((XAnyEvent *)ev)->serial & (unsigned long)0xffff;
+ return sz_xEvent;
+}
+
+Private Bool
+_XimForwardEventCore(
+ Xic ic,
+ XEvent *ev,
+ Bool sync)
+{
+ Xim im = (Xim)ic->core.im;
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ INT16 len;
+
+ if (!(len = _XimSetEventToWire(ev, (xEvent *)&buf_s[4])))
+ return False; /* X event */
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+ buf_s[2] = sync ? XimSYNCHRONUS : 0; /* flag */
+ buf_s[3] =
+ (CARD16)((((XAnyEvent *)ev)->serial & ~((unsigned long)0xffff)) >> 16);
+ /* serial number */
+
+ len += sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16) /* sizeof icid */
+ + sizeof(BITMASK16) /* sizeof flag */
+ + sizeof(CARD16); /* sizeof serila number */
+
+ _XimSetHeader((XPointer)buf, XIM_FORWARD_EVENT, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+
+ if (sync) {
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimSyncCheck, (XPointer)ic);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(len);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimSyncCheck, (XPointer)ic);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else {
+ return False;
+ }
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ }
+ return True;
+}
+
+Public Bool
+_XimForwardEvent(
+ Xic ic,
+ XEvent *ev,
+ Bool sync)
+{
+#ifdef EXT_FORWARD
+ if (((ev->type == KeyPress) || (ev->type == KeyRelease)))
+ if (_XimExtForwardKeyEvent(ic, (XKeyEvent *)ev, sync))
+ return True;
+#endif
+ return _XimForwardEventCore(ic, ev, sync);
+}
+
+Private void
+_XimProcEvent(
+ Display *d,
+ Xic ic,
+ XEvent *ev,
+ CARD16 *buf)
+{
+ INT16 serial = buf[0];
+ xEvent *xev = (xEvent *)&buf[1];
+
+ _XimProtoWireToEvent(ev, xev, False);
+ ev->xany.serial |= serial << 16;
+ ev->xany.send_event = False;
+ ev->xany.display = d;
+ MARK_FABLICATED(ic);
+ return;
+}
+
+Private Bool
+_XimForwardEventRecv(
+ Xim im,
+ Xic ic,
+ XPointer buf)
+{
+ CARD16 *buf_s = (CARD16 *)buf;
+ Display *d = im->core.display;
+ XEvent ev;
+
+ _XimProcEvent(d, ic, &ev, &buf_s[1]);
+
+ (void)_XimRespSyncReply(ic, buf_s[0]);
+
+ XPutBackEvent(d, &ev);
+
+ return True;
+}
+
+Public Bool
+_XimForwardEventCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Xim im = (Xim)call_data;
+ Xic ic;
+
+ if ((imid == im->private.proto.imid)
+ && (ic = _XimICOfXICID(im, icid))) {
+ (void)_XimForwardEventRecv(im, ic, (XPointer)&buf_s[2]);
+ return True;
+ }
+ return False;
+}
+
+Private Bool
+_XimRegisterTriggerkey(
+ Xim im,
+ XPointer buf)
+{
+ CARD32 *buf_l = (CARD32 *)buf;
+ CARD32 len;
+ CARD32 *key;
+
+ if (IS_DYNAMIC_EVENT_FLOW(im)) /* already Dynamic event flow mode */
+ return True;
+
+ /*
+ * register onkeylist
+ */
+
+ len = buf_l[0]; /* length of on-keys */
+ len += sizeof(INT32); /* sizeof length of on-keys */
+
+ if (!(key = (CARD32 *)Xmalloc(len))) {
+ _XimError(im, 0, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
+ return False;
+ }
+ memcpy((char *)key, (char *)buf_l, len);
+ im->private.proto.im_onkeylist = key;
+
+ MARK_DYNAMIC_EVENT_FLOW(im);
+
+ /*
+ * register offkeylist
+ */
+
+ buf_l = (CARD32 *)((char *)buf + len);
+ len = buf_l[0]; /* length of off-keys */
+ len += sizeof(INT32); /* sizeof length of off-keys */
+
+ if (!(key = (CARD32 *)Xmalloc(len))) {
+ _XimError(im, 0, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
+ return False;
+ }
+
+ memcpy((char *)key, (char *)buf_l, len);
+ im->private.proto.im_offkeylist = key;
+
+ return True;
+}
+
+Public Bool
+_XimRegisterTriggerKeysCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ Xim im = (Xim)call_data;
+
+ (void )_XimRegisterTriggerkey(im, (XPointer)&buf_s[2]);
+ return True;
+}
+
+Public EVENTMASK
+_XimGetWindowEventmask(
+ Xic ic)
+{
+ Xim im = (Xim )ic->core.im;
+ XWindowAttributes atr;
+
+ if (!_XGetWindowAttributes(im->core.display, ic->core.focus_window, &atr))
+ return 0;
+ return (EVENTMASK)atr.your_event_mask;
+}
+
+
+Private Bool
+_XimTriggerNotifyCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+
+ if ((major_opcode == XIM_TRIGGER_NOTIFY_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ return True;
+ return False;
+}
+
+Public Bool
+_XimTriggerNotify(
+ Xim im,
+ Xic ic,
+ int mode,
+ CARD32 idx)
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ CARD32 *buf_l = (CARD32 *)&buf[XIM_HEADER_SIZE];
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ INT16 len;
+ EVENTMASK mask = _XimGetWindowEventmask(ic);
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+ buf_l[1] = mode; /* flag */
+ buf_l[2] = idx; /* index of keys list */
+ buf_l[3] = mask; /* select-event-mask */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16) /* sizeof icid */
+ + sizeof(CARD32) /* sizeof flag */
+ + sizeof(CARD32) /* sizeof index of key list */
+ + sizeof(EVENTMASK); /* sizeof select-event-mask */
+
+ _XimSetHeader((XPointer)buf, XIM_TRIGGER_NOTIFY, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimTriggerNotifyCheck, (XPointer)ic);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(len);
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimTriggerNotifyCheck, (XPointer)ic);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else {
+ return False;
+ }
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ return True;
+}
+
+Private Bool
+_XimRegCommitInfo(
+ Xic ic,
+ char *string,
+ int string_len,
+ KeySym *keysym,
+ int keysym_len)
+{
+ XimCommitInfo info;
+
+ if (!(info = (XimCommitInfo)Xmalloc(sizeof(XimCommitInfoRec))))
+ return False;
+ info->string = string;
+ info->string_len = string_len;
+ info->keysym = keysym;
+ info->keysym_len = keysym_len;
+ info->next = ic->private.proto.commit_info;
+ ic->private.proto.commit_info = info;
+ return True;
+}
+
+Private void
+_XimUnregCommitInfo(
+ Xic ic)
+{
+ XimCommitInfo info;
+
+ if (!(info = ic->private.proto.commit_info))
+ return;
+
+ if (info->string)
+ Xfree(info->string);
+ if (info->keysym)
+ Xfree(info->keysym);
+ ic->private.proto.commit_info = info->next;
+ Xfree(info);
+ return;
+}
+
+Public void
+_XimFreeCommitInfo(
+ Xic ic)
+{
+ while (ic->private.proto.commit_info)
+ _XimUnregCommitInfo(ic);
+ return;
+}
+
+Private Bool
+_XimProcKeySym(
+ Xic ic,
+ CARD32 sym,
+ KeySym **xim_keysym,
+ int *xim_keysym_len)
+{
+ Xim im = (Xim)ic->core.im;
+
+ if (!(*xim_keysym = (KeySym *)Xmalloc(sizeof(KeySym)))) {
+ _XimError(im, ic, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
+ return False;
+ }
+
+ **xim_keysym = (KeySym)sym;
+ *xim_keysym_len = 1;
+
+ return True;
+}
+
+Private Bool
+_XimProcCommit(
+ Xic ic,
+ BYTE *buf,
+ int len,
+ char **xim_string,
+ int *xim_string_len)
+{
+ Xim im = (Xim)ic->core.im;
+ char *string;
+
+ if (!(string = (char *)Xmalloc(len + 1))) {
+ _XimError(im, ic, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
+ return False;
+ }
+
+ (void)memcpy(string, (char *)buf, len);
+ string[len] = '\0';
+
+ *xim_string = string;
+ *xim_string_len = len;
+ return True;
+}
+
+Private Bool
+_XimCommitRecv(
+ Xim im,
+ Xic ic,
+ XPointer buf)
+{
+ CARD16 *buf_s = (CARD16 *)buf;
+ BITMASK16 flag = buf_s[0];
+ XKeyEvent ev;
+ char *string = NULL;
+ int string_len = 0;
+ KeySym *keysym = NULL;
+ int keysym_len = 0;
+
+ if ((flag & XimLookupBoth) == XimLookupChars) {
+ if (!(_XimProcCommit(ic, (BYTE *)&buf_s[2],
+ (int)buf_s[1], &string, &string_len)))
+ return False;
+
+ } else if ((flag & XimLookupBoth) == XimLookupKeySym) {
+ if (!(_XimProcKeySym(ic, *(CARD32 *)&buf_s[2], &keysym, &keysym_len)))
+ return False;
+
+ } else if ((flag & XimLookupBoth) == XimLookupBoth) {
+ if (!(_XimProcKeySym(ic, *(CARD32 *)&buf_s[2], &keysym, &keysym_len)))
+ return False;
+
+ if (!(_XimProcCommit(ic, (BYTE *)&buf_s[5],
+ (int)buf_s[4], &string, &string_len)))
+ return False;
+ }
+
+ if (!(_XimRegCommitInfo(ic, string, string_len, keysym, keysym_len))) {
+ if (string)
+ Xfree(string);
+ if (keysym)
+ Xfree(keysym);
+ _XimError(im, ic, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
+ return False;
+ }
+
+ (void)_XimRespSyncReply(ic, flag);
+
+ MARK_FABLICATED(ic);
+
+ ev.type = KeyPress;
+ ev.send_event = False;
+ ev.display = im->core.display;
+ ev.window = ic->core.focus_window;
+ ev.keycode = 0;
+ ev.state = 0;
+
+ XPutBackEvent(im->core.display, (XEvent *)&ev);
+
+ return True;
+}
+
+Public Bool
+_XimCommitCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Xim im = (Xim)call_data;
+ Xic ic;
+
+ if ((imid == im->private.proto.imid)
+ && (ic = _XimICOfXICID(im, icid))) {
+ (void)_XimCommitRecv(im, ic, (XPointer)&buf_s[2]);
+ return True;
+ }
+ return False;
+}
+
+Public void
+_XimProcError(
+ Xim im,
+ Xic ic,
+ XPointer data)
+{
+ return;
+}
+
+Public Bool
+_XimErrorCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ BITMASK16 flag = buf_s[2];
+ XIMID imid;
+ XICID icid;
+ Xim im = (Xim)call_data;
+ Xic ic = NULL;
+
+ if (flag & XIM_IMID_VALID) {
+ imid = buf_s[0];
+ if (imid != im->private.proto.imid)
+ return False;
+ }
+ if (flag & XIM_ICID_VALID) {
+ icid = buf_s[1];
+ if (!(ic = _XimICOfXICID(im, icid)))
+ return False;
+ }
+ _XimProcError(im, ic, (XPointer)&buf_s[3]);
+
+ return True;
+}
+
+Public Bool
+_XimError(
+ Xim im,
+ Xic ic,
+ CARD16 error_code,
+ INT16 detail_length,
+ CARD16 type,
+ char *detail)
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len = 0;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[2] = XIM_IMID_VALID; /* flag */
+ if (ic) {
+ buf_s[1] = ic->private.proto.icid; /* icid */
+ buf_s[2] |= XIM_ICID_VALID; /* flag */
+ }
+ buf_s[3] = error_code; /* Error Code */
+ buf_s[4] = detail_length; /* length of error detail */
+ buf_s[5] = type; /* type of error detail */
+
+ if (detail_length && detail) {
+ len = detail_length;
+ memcpy((char *)&buf_s[6], detail, len);
+ XIM_SET_PAD(&buf_s[6], len);
+ }
+
+ len += sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16) /* sizeof icid */
+ + sizeof(BITMASK16) /* sizeof flag */
+ + sizeof(CARD16) /* sizeof error_code */
+ + sizeof(INT16) /* sizeof length of detail */
+ + sizeof(CARD16); /* sizeof type */
+
+ _XimSetHeader((XPointer)buf, XIM_ERROR, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ return True;
+}
+
+Private int
+_Ximctsconvert(
+ XlcConv conv,
+ char *from,
+ int from_len,
+ char *to,
+ int to_len,
+ Status *state)
+{
+ int from_left;
+ int to_left;
+ int from_savelen;
+ int to_savelen;
+ int from_cnvlen;
+ int to_cnvlen;
+ char *from_buf;
+ char *to_buf;
+ char scratchbuf[BUFSIZ];
+ Status tmp_state;
+
+ if (!state)
+ state = &tmp_state;
+
+ if (!conv || !from || !from_len) {
+ *state = XLookupNone;
+ return 0;
+ }
+
+ /* Reset the converter. The CompoundText at 'from' starts in
+ initial state. */
+ _XlcResetConverter(conv);
+
+ from_left = from_len;
+ to_left = BUFSIZ;
+ from_cnvlen = 0;
+ to_cnvlen = 0;
+ for (;;) {
+ from_buf = &from[from_cnvlen];
+ from_savelen = from_left;
+ to_buf = &scratchbuf[to_cnvlen];
+ to_savelen = to_left;
+ if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
+ (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
+ *state = XLookupNone;
+ return 0;
+ }
+ from_cnvlen += (from_savelen - from_left);
+ to_cnvlen += (to_savelen - to_left);
+ if (from_left == 0) {
+ if (!to_cnvlen) {
+ *state = XLookupNone;
+ return 0;
+ }
+ break;
+ }
+ }
+
+ if (!to || !to_len || (to_len < to_cnvlen)) {
+ *state = XBufferOverflow;
+ } else {
+ memcpy(to, scratchbuf, to_cnvlen);
+ *state = XLookupChars;
+ }
+ return to_cnvlen;
+}
+
+Public int
+_Ximctstombs(xim, from, from_len, to, to_len, state)
+ XIM xim;
+ char *from;
+ int from_len;
+ char *to;
+ int to_len;
+ Status *state;
+{
+ return _Ximctsconvert(((Xim)xim)->private.proto.ctom_conv,
+ from, from_len, to, to_len, state);
+}
+
+Public int
+_Ximctstowcs(
+ XIM xim,
+ char *from,
+ int from_len,
+ wchar_t *to,
+ int to_len,
+ Status *state)
+{
+ Xim im = (Xim)xim;
+ XlcConv conv = im->private.proto.ctow_conv;
+ int from_left;
+ int to_left;
+ int from_savelen;
+ int to_savelen;
+ int from_cnvlen;
+ int to_cnvlen;
+ char *from_buf;
+ wchar_t *to_buf;
+ wchar_t scratchbuf[BUFSIZ];
+ Status tmp_state;
+
+ if (!state)
+ state = &tmp_state;
+
+ if (!conv || !from || !from_len) {
+ *state = XLookupNone;
+ return 0;
+ }
+
+ /* Reset the converter. The CompoundText at 'from' starts in
+ initial state. */
+ _XlcResetConverter(conv);
+
+ from_left = from_len;
+ to_left = BUFSIZ;
+ from_cnvlen = 0;
+ to_cnvlen = 0;
+ for (;;) {
+ from_buf = &from[from_cnvlen];
+ from_savelen = from_left;
+ to_buf = &scratchbuf[to_cnvlen];
+ to_savelen = to_left;
+ if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
+ (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
+ *state = XLookupNone;
+ return 0;
+ }
+ from_cnvlen += (from_savelen - from_left);
+ to_cnvlen += (to_savelen - to_left);
+ if (from_left == 0) {
+ if (!to_cnvlen){
+ *state = XLookupNone;
+ return 0;
+ }
+ break;
+ }
+ }
+
+ if (!to || !to_len || (to_len < to_cnvlen)) {
+ *state = XBufferOverflow;
+ } else {
+ memcpy(to, scratchbuf, to_cnvlen * sizeof(wchar_t));
+ *state = XLookupChars;
+ }
+ return to_cnvlen;
+}
+
+Public int
+_Ximctstoutf8(
+ XIM xim,
+ char *from,
+ int from_len,
+ char *to,
+ int to_len,
+ Status *state)
+{
+ return _Ximctsconvert(((Xim)xim)->private.proto.ctoutf8_conv,
+ from, from_len, to, to_len, state);
+}
+
+Public int
+_XimProtoMbLookupString(
+ XIC xic,
+ XKeyEvent *ev,
+ char *buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *state)
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ int ret;
+ Status tmp_state;
+ XimCommitInfo info;
+
+ if (!IS_SERVER_CONNECTED(im))
+ return 0;
+
+ if (!state)
+ state = &tmp_state;
+
+ if ((ev->type == KeyPress) && (ev->keycode == 0)) { /* Filter function */
+ if (!(info = ic->private.proto.commit_info)) {
+ *state = XLookupNone;
+ return 0;
+ }
+
+ ret = im->methods->ctstombs((XIM)im, info->string,
+ info->string_len, buffer, bytes, state);
+ if (*state == XBufferOverflow)
+ return ret;
+ if (keysym && (info->keysym && *(info->keysym))) {
+ *keysym = *(info->keysym);
+ if (*state == XLookupChars)
+ *state = XLookupBoth;
+ else
+ *state = XLookupKeySym;
+ }
+ _XimUnregCommitInfo(ic);
+
+ } else if (ev->type == KeyPress) {
+ ret = _XimLookupMBText(ic, ev, buffer, bytes, keysym, NULL);
+ if (ret > 0) {
+ if (ret > bytes)
+ *state = XBufferOverflow;
+ else if (keysym && *keysym != NoSymbol)
+ *state = XLookupBoth;
+ else
+ *state = XLookupChars;
+ } else {
+ if (keysym && *keysym != NoSymbol)
+ *state = XLookupKeySym;
+ else
+ *state = XLookupNone;
+ }
+ } else {
+ *state = XLookupNone;
+ ret = 0;
+ }
+
+ return ret;
+}
+
+Public int
+_XimProtoWcLookupString(
+ XIC xic,
+ XKeyEvent *ev,
+ wchar_t *buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *state)
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ int ret;
+ Status tmp_state;
+ XimCommitInfo info;
+
+ if (!IS_SERVER_CONNECTED(im))
+ return 0;
+
+ if (!state)
+ state = &tmp_state;
+
+ if (ev->type == KeyPress && ev->keycode == 0) { /* Filter function */
+ if (!(info = ic->private.proto.commit_info)) {
+ *state = XLookupNone;
+ return 0;
+ }
+
+ ret = im->methods->ctstowcs((XIM)im, info->string,
+ info->string_len, buffer, bytes, state);
+ if (*state == XBufferOverflow)
+ return ret;
+ if (keysym && (info->keysym && *(info->keysym))) {
+ *keysym = *(info->keysym);
+ if (*state == XLookupChars)
+ *state = XLookupBoth;
+ else
+ *state = XLookupKeySym;
+ }
+ _XimUnregCommitInfo(ic);
+
+ } else if (ev->type == KeyPress) {
+ ret = _XimLookupWCText(ic, ev, buffer, bytes, keysym, NULL);
+ if (ret > 0) {
+ if (ret > bytes)
+ *state = XBufferOverflow;
+ else if (keysym && *keysym != NoSymbol)
+ *state = XLookupBoth;
+ else
+ *state = XLookupChars;
+ } else {
+ if (keysym && *keysym != NoSymbol)
+ *state = XLookupKeySym;
+ else
+ *state = XLookupNone;
+ }
+ } else {
+ *state = XLookupNone;
+ ret = 0;
+ }
+
+ return ret;
+}
+
+Public int
+_XimProtoUtf8LookupString(
+ XIC xic,
+ XKeyEvent *ev,
+ char *buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *state)
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ int ret;
+ Status tmp_state;
+ XimCommitInfo info;
+
+ if (!IS_SERVER_CONNECTED(im))
+ return 0;
+
+ if (!state)
+ state = &tmp_state;
+
+ if (ev->type == KeyPress && ev->keycode == 0) { /* Filter function */
+ if (!(info = ic->private.proto.commit_info)) {
+ *state = XLookupNone;
+ return 0;
+ }
+
+ ret = im->methods->ctstoutf8((XIM)im, info->string,
+ info->string_len, buffer, bytes, state);
+ if (*state == XBufferOverflow)
+ return ret;
+ if (keysym && (info->keysym && *(info->keysym))) {
+ *keysym = *(info->keysym);
+ if (*state == XLookupChars)
+ *state = XLookupBoth;
+ else
+ *state = XLookupKeySym;
+ }
+ _XimUnregCommitInfo(ic);
+
+ } else if (ev->type == KeyPress) {
+ ret = _XimLookupUTF8Text(ic, ev, buffer, bytes, keysym, NULL);
+ if (ret > 0) {
+ if (ret > bytes)
+ *state = XBufferOverflow;
+ else if (keysym && *keysym != NoSymbol)
+ *state = XLookupBoth;
+ else
+ *state = XLookupChars;
+ } else {
+ if (keysym && *keysym != NoSymbol)
+ *state = XLookupKeySym;
+ else
+ *state = XLookupNone;
+ }
+ } else {
+ *state = XLookupNone;
+ ret = 0;
+ }
+
+ return ret;
+}
diff --git a/nx-X11/lib/X11/imDispch.c b/nx-X11/lib/X11/imDispch.c
new file mode 100644
index 000000000..c0c4bc726
--- /dev/null
+++ b/nx-X11/lib/X11/imDispch.c
@@ -0,0 +1,108 @@
+/* $Xorg: imDispch.c,v 1.3 2000/08/17 19:45:12 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1993, 1994 by FUJITSU LIMITED
+
+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 of FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imDispch.c,v 1.4 2003/04/13 19:22:20 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include "Xlibint.h"
+#include "Xutil.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+
+Public Bool
+_XimRegProtoIntrCallback(
+ Xim im,
+ CARD16 major_code,
+ CARD16 minor_code,
+ Bool (*proc)(
+ Xim, INT16, XPointer, XPointer
+ ),
+
+ XPointer call_data)
+{
+ XimProtoIntrRec *rec;
+
+ if (!(rec = (XimProtoIntrRec *)Xmalloc(sizeof(XimProtoIntrRec))))
+ return False;
+ rec->func = proc;
+ rec->major_code = major_code;
+ rec->minor_code = minor_code;
+ rec->call_data = call_data;
+ rec->next = im->private.proto.intrproto;
+ im->private.proto.intrproto = rec;
+ return True;
+}
+
+Public void
+_XimFreeProtoIntrCallback(im)
+ Xim im;
+{
+ register XimProtoIntrRec *rec, *next;
+
+ for (rec = im->private.proto.intrproto; rec;) {
+ next = rec->next;
+ Xfree(rec);
+ rec = next;
+ }
+ im->private.proto.intrproto = NULL;
+ return;
+}
+
+Private Bool
+_XimTransportIntr(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+{
+ Xim call_im = (Xim)call_data;
+ XimProtoIntrRec *rec = call_im->private.proto.intrproto;
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+
+ for (; rec; rec = rec->next) {
+ if ((major_opcode == (CARD8)rec->major_code)
+ && (minor_opcode == (CARD8)rec->minor_code))
+ if ((*rec->func)(call_im, len, data, rec->call_data))
+ return True;
+ }
+ return False;
+}
+
+Public Bool
+_XimDispatchInit(im)
+ Xim im;
+{
+ if (_XimRegisterDispatcher(im, _XimTransportIntr, (XPointer)im))
+ return True;
+ return False;
+}
diff --git a/nx-X11/lib/X11/imEvToWire.c b/nx-X11/lib/X11/imEvToWire.c
new file mode 100644
index 000000000..f407296df
--- /dev/null
+++ b/nx-X11/lib/X11/imEvToWire.c
@@ -0,0 +1,792 @@
+/* $Xorg: imEvToWire.c,v 1.3 2000/08/17 19:45:12 cpqbld Exp $ */
+/***********************************************************
+Copyright 1993 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.
+
+******************************************************************/
+/* $XFree86$ */
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xlib.h>
+#undef NEED_EVENTS
+#include "Ximint.h"
+
+
+#define sw16(n, s) ((s) ? \
+ (((n) << 8 & 0xff00) | \
+ ((n) >> 8 & 0xff) \
+ ) : n)
+
+#define sw32(n, s) ((s) ? \
+ (((n) << 24 & 0xff000000) | \
+ ((n) << 8 & 0xff0000) | \
+ ((n) >> 8 & 0xff00) | \
+ ((n) >> 24 & 0xff) \
+ ) : n)
+
+Status
+_XimProtoEventToWire(
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event, /* wire protocol event */
+ Bool sw) /* swap byte? */
+{
+ switch (event->u.u.type = re->type) {
+ case KeyPress:
+ case KeyRelease:
+ {
+ register XKeyEvent *ev = (XKeyEvent*) re;
+ event->u.keyButtonPointer.root = sw32(ev->root, sw);
+ event->u.keyButtonPointer.event =
+ sw32(ev->window, sw);
+ event->u.keyButtonPointer.child =
+ sw32(ev->subwindow, sw);
+ event->u.keyButtonPointer.time = sw32(ev->time, sw);
+ event->u.keyButtonPointer.eventX = sw16(ev->x, sw) ;
+ event->u.keyButtonPointer.eventY = sw16(ev->y, sw) ;
+ event->u.keyButtonPointer.rootX =
+ sw16(ev->x_root, sw);
+ event->u.keyButtonPointer.rootY =
+ sw16(ev->y_root, sw);
+ event->u.keyButtonPointer.state = sw16(ev->state, sw);
+ 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 = sw32(ev->root, sw);
+ event->u.keyButtonPointer.event = sw32(ev->window, sw);
+ event->u.keyButtonPointer.child = sw32(ev->subwindow, sw);
+ event->u.keyButtonPointer.time = sw32(ev->time, sw);
+ event->u.keyButtonPointer.eventX = sw16(ev->x, sw);
+ event->u.keyButtonPointer.eventY = sw16(ev->y, sw);
+ event->u.keyButtonPointer.rootX = sw16(ev->x_root, sw);
+ event->u.keyButtonPointer.rootY = sw16(ev->y_root, sw);
+ event->u.keyButtonPointer.state = sw16(ev->state, sw);
+ 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 = sw32(ev->root, sw);
+ event->u.keyButtonPointer.event = sw32(ev->window, sw);
+ event->u.keyButtonPointer.child = sw32(ev->subwindow, sw);
+ event->u.keyButtonPointer.time = sw32(ev->time, sw);
+ event->u.keyButtonPointer.eventX= sw16(ev->x, sw);
+ event->u.keyButtonPointer.eventY= sw16(ev->y, sw);
+ event->u.keyButtonPointer.rootX = sw16(ev->x_root, sw);
+ event->u.keyButtonPointer.rootY = sw16(ev->y_root, sw);
+ event->u.keyButtonPointer.state = sw16(ev->state, sw);
+ 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 = sw32(ev->root, sw);
+ event->u.enterLeave.event = sw32(ev->window, sw);
+ event->u.enterLeave.child = sw32(ev->subwindow, sw);
+ event->u.enterLeave.time = sw32(ev->time, sw);
+ event->u.enterLeave.eventX = sw16(ev->x, sw);
+ event->u.enterLeave.eventY = sw16(ev->y, sw);
+ event->u.enterLeave.rootX = sw16(ev->x_root, sw);
+ event->u.enterLeave.rootY = sw16(ev->y_root, sw);
+ event->u.enterLeave.state = sw16(ev->state, sw);
+ 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 = sw32(ev->window, sw);
+ 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 = sw32(ev->window, sw);
+ event->u.expose.x = sw16(ev->x, sw);
+ event->u.expose.y = sw16(ev->y, sw);
+ event->u.expose.width = sw16(ev->width, sw);
+ event->u.expose.height = sw16(ev->height, sw);
+ event->u.expose.count = sw16(ev->count, sw);
+ }
+ break;
+ case GraphicsExpose:
+ {
+ register XGraphicsExposeEvent *ev =
+ (XGraphicsExposeEvent *) re;
+ event->u.graphicsExposure.drawable = sw32(ev->drawable, sw);
+ event->u.graphicsExposure.x = sw16(ev->x, sw);
+ event->u.graphicsExposure.y = sw16(ev->y, sw);
+ event->u.graphicsExposure.width = sw16(ev->width, sw);
+ event->u.graphicsExposure.height = sw16(ev->height, sw);
+ event->u.graphicsExposure.count = sw16(ev->count, sw);
+ event->u.graphicsExposure.majorEvent= ev->major_code;
+ event->u.graphicsExposure.minorEvent= sw16(ev->minor_code, sw);
+ }
+ break;
+ case NoExpose:
+ {
+ register XNoExposeEvent *ev = (XNoExposeEvent *) re;
+ event->u.noExposure.drawable = sw32(ev->drawable, sw);
+ event->u.noExposure.majorEvent = ev->major_code;
+ event->u.noExposure.minorEvent = sw16(ev->minor_code, sw);
+ }
+ break;
+ case VisibilityNotify:
+ {
+ register XVisibilityEvent *ev = (XVisibilityEvent *) re;
+ event->u.visibility.window = sw32(ev->window, sw);
+ event->u.visibility.state = ev->state;
+ }
+ break;
+ case CreateNotify:
+ {
+ register XCreateWindowEvent *ev =
+ (XCreateWindowEvent *) re;
+ event->u.createNotify.window = sw32(ev->window, sw);
+ event->u.createNotify.parent = sw32(ev->parent, sw);
+ event->u.createNotify.x = sw16(ev->x, sw);
+ event->u.createNotify.y = sw16(ev->y, sw);
+ event->u.createNotify.width = sw16(ev->width, sw);
+ event->u.createNotify.height = sw16(ev->height, sw);
+ event->u.createNotify.borderWidth = sw16(ev->border_width, sw);
+ event->u.createNotify.override = ev->override_redirect;
+ }
+ break;
+ case DestroyNotify:
+ {
+ register XDestroyWindowEvent *ev =
+ (XDestroyWindowEvent *) re;
+ event->u.destroyNotify.window = sw32(ev->window, sw);
+ event->u.destroyNotify.event = sw32(ev->event, sw);
+ }
+ break;
+ case UnmapNotify:
+ {
+ register XUnmapEvent *ev = (XUnmapEvent *) re;
+ event->u.unmapNotify.window = sw32(ev->window, sw);
+ event->u.unmapNotify.event = sw32(ev->event, sw);
+ event->u.unmapNotify.fromConfigure = ev->from_configure;
+ }
+ break;
+ case MapNotify:
+ {
+ register XMapEvent *ev = (XMapEvent *) re;
+ event->u.mapNotify.window = sw32(ev->window, sw);
+ event->u.mapNotify.event = sw32(ev->event, sw);
+ event->u.mapNotify.override = ev->override_redirect;
+ }
+ break;
+ case MapRequest:
+ {
+ register XMapRequestEvent *ev = (XMapRequestEvent *) re;
+ event->u.mapRequest.window = sw32(ev->window, sw);
+ event->u.mapRequest.parent = sw32(ev->parent, sw);
+ }
+ break;
+ case ReparentNotify:
+ {
+ register XReparentEvent *ev = (XReparentEvent *) re;
+ event->u.reparent.window = sw32(ev->window, sw);
+ event->u.reparent.event = sw32(ev->event, sw);
+ event->u.reparent.parent = sw32(ev->parent, sw);
+ event->u.reparent.x = sw16(ev->x, sw);
+ event->u.reparent.y = sw16(ev->y, sw);
+ event->u.reparent.override = ev->override_redirect;
+ }
+ break;
+ case ConfigureNotify:
+ {
+ register XConfigureEvent *ev = (XConfigureEvent *) re;
+ event->u.configureNotify.window = sw32(ev->window, sw);
+ event->u.configureNotify.event = sw32(ev->event, sw);
+ event->u.configureNotify.aboveSibling = sw32(ev->above, sw);
+ event->u.configureNotify.x = sw16(ev->x, sw);
+ event->u.configureNotify.y = sw16(ev->y, sw);
+ event->u.configureNotify.width = sw16(ev->width, sw);
+ event->u.configureNotify.height = sw16(ev->height, sw);
+ event->u.configureNotify.borderWidth= sw16(ev->border_width, sw);
+ event->u.configureNotify.override = ev->override_redirect;
+ }
+ break;
+ case ConfigureRequest:
+ {
+ register XConfigureRequestEvent *ev =
+ (XConfigureRequestEvent *) re;
+ event->u.configureRequest.window = sw32(ev->window, sw);
+ event->u.configureRequest.parent = sw32(ev->parent, sw);
+ event->u.configureRequest.sibling = sw32(ev->above, sw);
+ event->u.configureRequest.x = sw16(ev->x, sw);
+ event->u.configureRequest.y = sw16(ev->y, sw);
+ event->u.configureRequest.width = sw16(ev->width, sw);
+ event->u.configureRequest.height = sw16(ev->height, sw);
+ event->u.configureRequest.borderWidth= sw16(ev->border_width, sw);
+ event->u.configureRequest.valueMask= sw16(ev->value_mask, sw);
+ event->u.u.detail = ev->detail;
+ }
+ break;
+ case GravityNotify:
+ {
+ register XGravityEvent *ev = (XGravityEvent *) re;
+ event->u.gravity.window = sw32(ev->window, sw);
+ event->u.gravity.event = sw32(ev->event, sw);
+ event->u.gravity.x = sw16(ev->x, sw);
+ event->u.gravity.y = sw16(ev->y, sw);
+ }
+ break;
+ case ResizeRequest:
+ {
+ register XResizeRequestEvent *ev =
+ (XResizeRequestEvent *) re;
+ event->u.resizeRequest.window = sw32(ev->window, sw);
+ event->u.resizeRequest.width = sw16(ev->width, sw);
+ event->u.resizeRequest.height = sw16(ev->height, sw);
+ }
+ break;
+ case CirculateNotify:
+ {
+ register XCirculateEvent *ev = (XCirculateEvent *) re;
+ event->u.circulate.window = sw32(ev->window, sw);
+ event->u.circulate.event = sw32(ev->event, sw);
+ event->u.circulate.place = ev->place;
+ }
+ break;
+ case CirculateRequest:
+ {
+ register XCirculateRequestEvent *ev =
+ (XCirculateRequestEvent *) re;
+ event->u.circulate.window = sw32(ev->window, sw);
+ event->u.circulate.event = sw32(ev->parent, sw);
+ event->u.circulate.place = ev->place;
+ }
+ break;
+ case PropertyNotify:
+ {
+ register XPropertyEvent *ev = (XPropertyEvent *) re;
+ event->u.property.window = sw32(ev->window, sw);
+ event->u.property.atom = sw32(ev->atom, sw);
+ event->u.property.time = sw32(ev->time, sw);
+ event->u.property.state = ev->state;
+ }
+ break;
+ case SelectionClear:
+ {
+ register XSelectionClearEvent *ev =
+ (XSelectionClearEvent *) re;
+ event->u.selectionClear.window = sw32(ev->window, sw);
+ event->u.selectionClear.atom = sw32(ev->selection, sw);
+ event->u.selectionClear.time = sw32(ev->time, sw);
+ }
+ break;
+ case SelectionRequest:
+ {
+ register XSelectionRequestEvent *ev =
+ (XSelectionRequestEvent *) re;
+ event->u.selectionRequest.owner = sw32(ev->owner, sw);
+ event->u.selectionRequest.requestor = sw32(ev->requestor, sw);
+ event->u.selectionRequest.selection = sw32(ev->selection, sw);
+ event->u.selectionRequest.target = sw32(ev->target, sw);
+ event->u.selectionRequest.property = sw32(ev->property, sw);
+ event->u.selectionRequest.time = sw32(ev->time, sw);
+ }
+ break;
+ case SelectionNotify:
+ {
+ register XSelectionEvent *ev = (XSelectionEvent *) re;
+ event->u.selectionNotify.requestor = sw32(ev->requestor, sw);
+ event->u.selectionNotify.selection = sw32(ev->selection, sw);
+ event->u.selectionNotify.target = sw32(ev->target, sw);
+ event->u.selectionNotify.property = sw32(ev->property, sw);
+ event->u.selectionNotify.time = sw32(ev->time, sw);
+ }
+ break;
+ case ColormapNotify:
+ {
+ register XColormapEvent *ev = (XColormapEvent *) re;
+ event->u.colormap.window = sw32(ev->window, sw);
+ event->u.colormap.colormap = sw32(ev->colormap, sw);
+ 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 = sw32(ev->window, sw);
+ event->u.u.detail = ev->format;
+ switch (ev->format) {
+ case 8:
+ event->u.clientMessage.u.b.type = sw32(ev->message_type, sw);
+ 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 = sw32(ev->message_type, sw);
+ event->u.clientMessage.u.s.shorts0 = sw16(ev->data.s[0], sw);
+ event->u.clientMessage.u.s.shorts1 = sw16(ev->data.s[1], sw);
+ event->u.clientMessage.u.s.shorts2 = sw16(ev->data.s[2], sw);
+ event->u.clientMessage.u.s.shorts3 = sw16(ev->data.s[3], sw);
+ event->u.clientMessage.u.s.shorts4 = sw16(ev->data.s[4], sw);
+ event->u.clientMessage.u.s.shorts5 = sw16(ev->data.s[5], sw);
+ event->u.clientMessage.u.s.shorts6 = sw16(ev->data.s[6], sw);
+ event->u.clientMessage.u.s.shorts7 = sw16(ev->data.s[7], sw);
+ event->u.clientMessage.u.s.shorts8 = sw16(ev->data.s[8], sw);
+ event->u.clientMessage.u.s.shorts9 = sw16(ev->data.s[9], sw);
+ break;
+ case 32:
+ event->u.clientMessage.u.l.type = sw32(ev->message_type, sw);
+ event->u.clientMessage.u.l.longs0 = sw32(ev->data.l[0], sw);
+ event->u.clientMessage.u.l.longs1 = sw32(ev->data.l[1], sw);
+ event->u.clientMessage.u.l.longs2 = sw32(ev->data.l[2], sw);
+ event->u.clientMessage.u.l.longs3 = sw32(ev->data.l[3], sw);
+ event->u.clientMessage.u.l.longs4 = sw32(ev->data.l[4], sw);
+ 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(0);
+ }
+ /* Common process */
+ if (((XAnyEvent *)re)->send_event)
+ event->u.u.type |= 0x80;
+ event->u.u.sequenceNumber =
+ ((XAnyEvent *)re)->serial & ~((unsigned long)0xffff);
+ event->u.u.sequenceNumber = sw16(event->u.u.sequenceNumber, sw);
+ return(1);
+}
+
+
+/*
+ * reformat a wire event into an XEvent structure of the right type.
+ */
+Bool
+_XimProtoWireToEvent(
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event, /* wire protocol event */
+ Bool sw) /* swap byte? */
+{
+
+ re->type = event->u.u.type & 0x7f;
+ ((XAnyEvent *)re)->serial = sw16(event->u.u.sequenceNumber, sw);
+ ((XAnyEvent *)re)->send_event = ((event->u.u.type & 0x80) != 0);
+ ((XAnyEvent *)re)->display = NULL;
+
+ /* Ignore the leading bit of the event type since it is set when a
+ client sends an event rather than the server. */
+
+ switch (event-> u.u.type & 0177) {
+ case KeyPress:
+ case KeyRelease:
+ {
+ register XKeyEvent *ev = (XKeyEvent*) re;
+ ev->root = sw32(event->u.keyButtonPointer.root, sw);
+ ev->window = sw32(event->u.keyButtonPointer.event, sw);
+ ev->subwindow = sw32(event->u.keyButtonPointer.child, sw);
+ ev->time = sw32(event->u.keyButtonPointer.time, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventX, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventY, sw));
+ ev->x_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootX, sw));
+ ev->y_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootY, sw));
+ ev->state = sw16(event->u.keyButtonPointer.state, sw);
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->keycode = event->u.u.detail;
+ }
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ {
+ register XButtonEvent *ev = (XButtonEvent *) re;
+ ev->root = sw32(event->u.keyButtonPointer.root, sw);
+ ev->window = sw32(event->u.keyButtonPointer.event, sw);
+ ev->subwindow = sw32(event->u.keyButtonPointer.child, sw);
+ ev->time = sw32(event->u.keyButtonPointer.time, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventX, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventY, sw));
+ ev->x_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootX, sw));
+ ev->y_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootY, sw));
+ ev->state = sw16(event->u.keyButtonPointer.state, sw);
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->button = event->u.u.detail;
+ }
+ break;
+ case MotionNotify:
+ {
+ register XMotionEvent *ev = (XMotionEvent *)re;
+ ev->root = sw32(event->u.keyButtonPointer.root, sw);
+ ev->window = sw32(event->u.keyButtonPointer.event, sw);
+ ev->subwindow = sw32(event->u.keyButtonPointer.child, sw);
+ ev->time = sw32(event->u.keyButtonPointer.time, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventX, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventY, sw));
+ ev->x_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootX, sw));
+ ev->y_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootY, sw));
+ ev->state = sw16(event->u.keyButtonPointer.state, sw);
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->is_hint = event->u.u.detail;
+ }
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ {
+ register XCrossingEvent *ev = (XCrossingEvent *) re;
+ ev->root = sw32(event->u.enterLeave.root, sw);
+ ev->window = sw32(event->u.enterLeave.event, sw);
+ ev->subwindow = sw32(event->u.enterLeave.child, sw);
+ ev->time = sw32(event->u.enterLeave.time, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.enterLeave.eventX, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.enterLeave.eventY, sw));
+ ev->x_root = cvtINT16toInt(sw16(event->u.enterLeave.rootX, sw));
+ ev->y_root = cvtINT16toInt(sw16(event->u.enterLeave.rootY, sw));
+ ev->state = sw16(event->u.enterLeave.state, sw);
+ ev->mode = event->u.enterLeave.mode;
+ ev->same_screen = (event->u.enterLeave.flags &
+ ELFlagSameScreen) && True;
+ ev->focus = (event->u.enterLeave.flags &
+ ELFlagFocus) && True;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case FocusIn:
+ case FocusOut:
+ {
+ register XFocusChangeEvent *ev = (XFocusChangeEvent *) re;
+ ev->window = sw32(event->u.focus.window, sw);
+ ev->mode = event->u.focus.mode;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case KeymapNotify:
+ {
+ register XKeymapEvent *ev = (XKeymapEvent *) re;
+ ev->window = None;
+ memcpy(&ev->key_vector[1],
+ (char *)((xKeymapEvent *) event)->map,
+ sizeof (((xKeymapEvent *) event)->map));
+ }
+ break;
+ case Expose:
+ {
+ register XExposeEvent *ev = (XExposeEvent *) re;
+ ev->window = sw32(event->u.expose.window, sw);
+ ev->x = sw16(event->u.expose.x, sw);
+ ev->y = sw16(event->u.expose.y, sw);
+ ev->width = sw16(event->u.expose.width, sw);
+ ev->height = sw16(event->u.expose.height, sw);
+ ev->count = sw16(event->u.expose.count, sw);
+ }
+ break;
+ case GraphicsExpose:
+ {
+ register XGraphicsExposeEvent *ev =
+ (XGraphicsExposeEvent *) re;
+ ev->drawable = sw32(event->u.graphicsExposure.drawable, sw);
+ ev->x = sw16(event->u.graphicsExposure.x, sw);
+ ev->y = sw16(event->u.graphicsExposure.y, sw);
+ ev->width = sw16(event->u.graphicsExposure.width, sw);
+ ev->height = sw16(event->u.graphicsExposure.height, sw);
+ ev->count = sw16(event->u.graphicsExposure.count, sw);
+ ev->major_code = event->u.graphicsExposure.majorEvent;
+ ev->minor_code = sw16(event->u.graphicsExposure.minorEvent, sw);
+ }
+ break;
+ case NoExpose:
+ {
+ register XNoExposeEvent *ev = (XNoExposeEvent *) re;
+ ev->drawable = sw32(event->u.noExposure.drawable, sw);
+ ev->major_code = event->u.noExposure.majorEvent;
+ ev->minor_code = sw16(event->u.noExposure.minorEvent, sw);
+ }
+ break;
+ case VisibilityNotify:
+ {
+ register XVisibilityEvent *ev = (XVisibilityEvent *) re;
+ ev->window = sw32(event->u.visibility.window, sw);
+ ev->state = event->u.visibility.state;
+ }
+ break;
+ case CreateNotify:
+ {
+ register XCreateWindowEvent *ev =
+ (XCreateWindowEvent *) re;
+ ev->window = sw32(event->u.createNotify.window, sw);
+ ev->parent = sw32(event->u.createNotify.parent, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.createNotify.x, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.createNotify.y, sw));
+ ev->width = sw16(event->u.createNotify.width, sw);
+ ev->height = sw16(event->u.createNotify.height, sw);
+ ev->border_width = sw16(event->u.createNotify.borderWidth, sw);
+ ev->override_redirect = event->u.createNotify.override;
+ }
+ break;
+ case DestroyNotify:
+ {
+ register XDestroyWindowEvent *ev =
+ (XDestroyWindowEvent *) re;
+ ev->window = sw32(event->u.destroyNotify.window, sw);
+ ev->event = sw32(event->u.destroyNotify.event, sw);
+ }
+ break;
+ case UnmapNotify:
+ {
+ register XUnmapEvent *ev = (XUnmapEvent *) re;
+ ev->window = sw32(event->u.unmapNotify.window, sw);
+ ev->event = sw32(event->u.unmapNotify.event, sw);
+ ev->from_configure = event->u.unmapNotify.fromConfigure;
+ }
+ break;
+ case MapNotify:
+ {
+ register XMapEvent *ev = (XMapEvent *) re;
+ ev->window = sw32(event->u.mapNotify.window, sw);
+ ev->event = sw32(event->u.mapNotify.event, sw);
+ ev->override_redirect = event->u.mapNotify.override;
+ }
+ break;
+ case MapRequest:
+ {
+ register XMapRequestEvent *ev = (XMapRequestEvent *) re;
+ ev->window = sw32(event->u.mapRequest.window, sw);
+ ev->parent = sw32(event->u.mapRequest.parent, sw);
+ }
+ break;
+ case ReparentNotify:
+ {
+ register XReparentEvent *ev = (XReparentEvent *) re;
+ ev->event = sw32(event->u.reparent.event, sw);
+ ev->window = sw32(event->u.reparent.window, sw);
+ ev->parent = sw32(event->u.reparent.parent, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.reparent.x, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.reparent.y, sw));
+ ev->override_redirect = event->u.reparent.override;
+ }
+ break;
+ case ConfigureNotify:
+ {
+ register XConfigureEvent *ev = (XConfigureEvent *) re;
+ ev->event = sw32(event->u.configureNotify.event, sw);
+ ev->window = sw32(event->u.configureNotify.window, sw);
+ ev->above = sw32(event->u.configureNotify.aboveSibling, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.configureNotify.x, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.configureNotify.y, sw));
+ ev->width = sw16(event->u.configureNotify.width, sw);
+ ev->height = sw16(event->u.configureNotify.height, sw);
+ ev->border_width = sw16(event->u.configureNotify.borderWidth, sw);
+ ev->override_redirect = event->u.configureNotify.override;
+ }
+ break;
+ case ConfigureRequest:
+ {
+ register XConfigureRequestEvent *ev =
+ (XConfigureRequestEvent *) re;
+ ev->window = sw32(event->u.configureRequest.window, sw);
+ ev->parent = sw32(event->u.configureRequest.parent, sw);
+ ev->above = sw32(event->u.configureRequest.sibling, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.configureRequest.x, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.configureRequest.y, sw));
+ ev->width = sw16(event->u.configureRequest.width, sw);
+ ev->height = sw16(event->u.configureRequest.height, sw);
+ ev->border_width = sw16(event->u.configureRequest.borderWidth, sw);
+ ev->value_mask = sw16(event->u.configureRequest.valueMask, sw);
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case GravityNotify:
+ {
+ register XGravityEvent *ev = (XGravityEvent *) re;
+ ev->window = sw32(event->u.gravity.window, sw);
+ ev->event = sw32(event->u.gravity.event, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.gravity.x, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.gravity.y, sw));
+ }
+ break;
+ case ResizeRequest:
+ {
+ register XResizeRequestEvent *ev =
+ (XResizeRequestEvent *) re;
+ ev->window = sw32(event->u.resizeRequest.window, sw);
+ ev->width = sw16(event->u.resizeRequest.width, sw);
+ ev->height = sw16(event->u.resizeRequest.height, sw);
+ }
+ break;
+ case CirculateNotify:
+ {
+ register XCirculateEvent *ev = (XCirculateEvent *) re;
+ ev->window = sw32(event->u.circulate.window, sw);
+ ev->event = sw32(event->u.circulate.event, sw);
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case CirculateRequest:
+ {
+ register XCirculateRequestEvent *ev =
+ (XCirculateRequestEvent *) re;
+ ev->window = sw32(event->u.circulate.window, sw);
+ ev->parent = sw32(event->u.circulate.event, sw);
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case PropertyNotify:
+ {
+ register XPropertyEvent *ev = (XPropertyEvent *) re;
+ ev->window = sw32(event->u.property.window, sw);
+ ev->atom = sw32(event->u.property.atom, sw);
+ ev->time = sw32(event->u.property.time, sw);
+ ev->state = event->u.property.state;
+ }
+ break;
+ case SelectionClear:
+ {
+ register XSelectionClearEvent *ev =
+ (XSelectionClearEvent *) re;
+ ev->window = sw32(event->u.selectionClear.window, sw);
+ ev->selection = sw32(event->u.selectionClear.atom, sw);
+ ev->time = sw32(event->u.selectionClear.time, sw);
+ }
+ break;
+ case SelectionRequest:
+ {
+ register XSelectionRequestEvent *ev =
+ (XSelectionRequestEvent *) re;
+ ev->owner = sw32(event->u.selectionRequest.owner, sw);
+ ev->requestor = sw32(event->u.selectionRequest.requestor, sw);
+ ev->selection = sw32(event->u.selectionRequest.selection, sw);
+ ev->target = sw32(event->u.selectionRequest.target, sw);
+ ev->property = sw32(event->u.selectionRequest.property, sw);
+ ev->time = sw32(event->u.selectionRequest.time, sw);
+ }
+ break;
+ case SelectionNotify:
+ {
+ register XSelectionEvent *ev = (XSelectionEvent *) re;
+ ev->requestor = sw32(event->u.selectionNotify.requestor, sw);
+ ev->selection = sw32(event->u.selectionNotify.selection, sw);
+ ev->target = sw32(event->u.selectionNotify.target, sw);
+ ev->property = sw32(event->u.selectionNotify.property, sw);
+ ev->time = sw32(event->u.selectionNotify.time, sw);
+ }
+ break;
+ case ColormapNotify:
+ {
+ register XColormapEvent *ev = (XColormapEvent *) re;
+ ev->window = sw32(event->u.colormap.window, sw);
+ ev->colormap = sw32(event->u.colormap.colormap, sw);
+ ev->new = event->u.colormap.new;
+ ev->state = event->u.colormap.state;
+ }
+ break;
+ case ClientMessage:
+ {
+ register int i;
+ register XClientMessageEvent *ev
+ = (XClientMessageEvent *) re;
+ ev->window = sw32(event->u.clientMessage.window, sw);
+ ev->format = event->u.u.detail;
+ switch (ev->format) {
+ case 8:
+ ev->message_type = sw32(event->u.clientMessage.u.b.type, sw);
+ for (i = 0; i < 20; i++)
+ ev->data.b[i] = event->u.clientMessage.u.b.bytes[i];
+ break;
+ case 16:
+ ev->message_type = sw32(event->u.clientMessage.u.s.type, sw);
+ ev->data.s[0] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts0, sw));
+ ev->data.s[1] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts1, sw));
+ ev->data.s[2] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts2, sw));
+ ev->data.s[3] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts3, sw));
+ ev->data.s[4] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts4, sw));
+ ev->data.s[5] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts5, sw));
+ ev->data.s[6] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts6, sw));
+ ev->data.s[7] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts7, sw));
+ ev->data.s[8] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts8, sw));
+ ev->data.s[9] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts9, sw));
+ break;
+ case 32:
+ ev->message_type = sw32(event->u.clientMessage.u.l.type, sw);
+ ev->data.l[0] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs0, sw));
+ ev->data.l[1] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs1, sw));
+ ev->data.l[2] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs2, sw));
+ ev->data.l[3] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs3, sw));
+ ev->data.l[4] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs4, sw));
+ break;
+ default: /* XXX should never occur */
+ break;
+ }
+ }
+ break;
+ case MappingNotify:
+ {
+ register XMappingEvent *ev = (XMappingEvent *)re;
+ ev->window = 0;
+ ev->first_keycode = event->u.mappingNotify.firstKeyCode;
+ ev->request = event->u.mappingNotify.request;
+ ev->count = event->u.mappingNotify.count;
+ }
+ break;
+ default:
+ return(False);
+ }
+ return(True);
+}
diff --git a/nx-X11/lib/X11/imExten.c b/nx-X11/lib/X11/imExten.c
new file mode 100644
index 000000000..782d1c356
--- /dev/null
+++ b/nx-X11/lib/X11/imExten.c
@@ -0,0 +1,579 @@
+/* $Xorg: imExten.c,v 1.3 2000/08/17 19:45:12 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+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 of FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imExten.c,v 1.4 2003/04/13 19:22:21 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xatom.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+/*
+ * index of extensions
+ */
+
+#define XIM_EXT_SET_EVENT_MASK_IDX 0
+#ifdef EXT_FORWARD
+#define XIM_EXT_FORWARD_KEYEVENT_IDX 1
+#endif
+#ifdef EXT_MOVE
+#define XIM_EXT_MOVE_IDX 2
+#endif
+
+typedef struct _XIM_QueryExtRec {
+ Bool is_support;
+ char *name;
+ int name_len;
+ CARD16 major_opcode;
+ CARD16 minor_opcode;
+ int idx;
+} XIM_QueryExtRec;
+
+Private XIM_QueryExtRec extensions[] = {
+ {False, "XIM_EXT_SET_EVENT_MASK", 0, 0, 0,
+ XIM_EXT_SET_EVENT_MASK_IDX},
+#ifdef EXT_FORWARD
+ {False, "XIM_EXT_FORWARD_KEYEVENT", 0, 0, 0,
+ XIM_EXT_FORWARD_KEYEVENT_IDX},
+#endif
+#ifdef EXT_MOVE
+ {False, "XIM_EXT_MOVE", 0, 0, 0, XIM_EXT_MOVE_IDX},
+#endif
+ {False, NULL, 0, 0, 0, 0} /* dummy */
+};
+
+Private int
+_XimIsSupportExt(
+ int idx)
+{
+ register int i;
+ int n = XIMNumber(extensions) - 1;
+
+ for (i = 0; i < n; i++) {
+ if (extensions[i].idx == idx) {
+ if (extensions[i].is_support)
+ return i;
+ else
+ break;
+ }
+ }
+ return -1;
+}
+
+Private Bool
+_XimProcExtSetEventMask(
+ Xim im,
+ Xic ic,
+ XPointer buf)
+{
+ EVENTMASK *buf_l = (EVENTMASK *)buf;
+ EVENTMASK select_mask = _XimGetWindowEventmask(ic);
+
+ ic->private.proto.filter_event_mask = buf_l[0];
+ ic->private.proto.intercept_event_mask = buf_l[1];
+ ic->private.proto.select_event_mask = buf_l[2];
+ ic->private.proto.forward_event_mask = buf_l[3];
+ ic->private.proto.synchronous_event_mask = buf_l[4];
+
+ select_mask &= ~ic->private.proto.intercept_event_mask;
+ /* deselected event mask */
+ select_mask |= ic->private.proto.select_event_mask;
+ /* selected event mask */
+ XSelectInput(im->core.display, ic->core.focus_window, select_mask);
+ _XimReregisterFilter(ic);
+
+ if (!(_XimProcSyncReply(im, ic)))
+ return False;
+ return True;
+}
+
+Private Bool
+_XimExtSetEventMaskCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Xim im = (Xim)call_data;
+ Xic ic;
+
+ if ((imid == im->private.proto.imid)
+ && (ic = _XimICOfXICID(im, icid))) {
+ (void)_XimProcExtSetEventMask(im, ic, (XPointer)&buf_s[2]);
+ return True;
+ }
+ return False;
+}
+
+#ifdef EXT_FORWARD
+Private Bool
+_XimProcExtForwardKeyEvent(
+ Xim im,
+ Xic ic,
+ XPointer buf)
+{
+ CARD8 *buf_b = (CARD8 *)buf;
+ CARD16 *buf_s = (CARD16 *)buf;
+ CARD32 *buf_l = (CARD32 *)buf;
+ XEvent ev;
+ XKeyEvent *kev = (XKeyEvent *)&ev;
+
+ bzero(&ev, sizeof(XEvent));
+ kev->send_event = False;
+ kev->display = im->core.display;
+ kev->serial = buf_s[1]; /* sequence number */
+ kev->type = buf_b[4] & 0x7f; /* xEvent.u.u.type */
+ kev->keycode = buf_b[5]; /* Keycode */
+ kev->state = buf_s[3]; /* state */
+ kev->time = buf_l[2]; /* time */
+
+ XPutBackEvent(im->core.display, &ev);
+
+ _XimRespSyncReply(ic, buf_s[0]);
+ MARK_FABLICATED(ic);
+
+ return True;
+}
+
+Private Bool
+_XimExtForwardKeyEventCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Xim im = (Xim)call_data;
+ Xic ic;
+
+ if ((imid == im->private.proto.imid)
+ && (ic = _XimICOfXICID(im, icid))) {
+ (void)_XimProcExtForwardKeyEvent(im, ic, (XPointer)&buf_s[2]);
+ return True;
+ }
+ return False;
+}
+
+Private Bool
+_XimExtForwardKeyEventCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+
+ if ((major_opcode == XIM_SYNC_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ return True;
+ return False;
+}
+
+Public Bool
+_XimExtForwardKeyEvent(
+ Xic ic,
+ XKeyEvent *ev,
+ Bool sync)
+{
+ Xim im = (Xim) ic->core.im;
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD8 *buf_b = &buf[XIM_HEADER_SIZE];
+ CARD16 *buf_s = (CARD16 *)buf_b;
+ CARD32 *buf_l = (CARD32 *)buf_b;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ INT16 len;
+ int idx;
+
+ if ((idx = _XimIsSupportExt(XIM_EXT_FORWARD_KEYEVENT_IDX)) < 0)
+ return False;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+ buf_s[2] = sync ? XimSYNCHRONUS : 0; /* flag */
+ buf_s[3] = (CARD16)(((XAnyEvent *)ev)->serial & ((unsigned long) 0xffff));
+ /* sequence number */
+ buf_b[8] = ev->type; /* xEvent.u.u.type */
+ buf_b[9] = ev->keycode; /* keycode */
+ buf_s[5] = ev->state; /* state */
+ buf_l[3] = ev->time; /* time */
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16) /* sizeof icid */
+ + sizeof(BITMASK16) /* sizeof flag */
+ + sizeof(CARD16) /* sizeof sequence number */
+ + sizeof(BYTE) /* sizeof xEvent.u.u.type */
+ + sizeof(BYTE) /* sizeof keycode */
+ + sizeof(CARD16) /* sizeof state */
+ + sizeof(CARD32); /* sizeof time */
+
+ _XimSetHeader((XPointer)buf,
+ extensions[idx].major_opcode,
+ extensions[idx].minor_opcode, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ if (sync) {
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimExtForwardKeyEventCheck, (XPointer)ic);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_sizex = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimExtForwardKeyEventCheck, (XPointer)ic);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ }
+ return True;
+}
+#endif /* EXT_FORWARD */
+
+Private int
+_XimCheckExtensionListSize(void)
+{
+ register int i;
+ int len;
+ int total = 0;
+ int n = XIMNumber(extensions) - 1;
+
+ for (i = 0; i < n; i++) {
+ len = strlen(extensions[i].name);
+ extensions[i].name_len = len;
+ len += sizeof(BYTE);
+ total += len;
+ }
+ return total;
+}
+
+Private void
+_XimSetExtensionList(
+ CARD8 *buf)
+{
+ register int i;
+ int len;
+ int n = XIMNumber(extensions) - 1;
+
+ for (i = 0; i < n; i++) {
+ len = extensions[i].name_len;
+ buf[0] = (BYTE)len;
+ (void)strcpy((char *)&buf[1], extensions[i].name);
+ len += sizeof(BYTE);
+ buf += len;
+ }
+ return;
+}
+
+Private unsigned int
+_XimCountNumberOfExtension(
+ INT16 total,
+ CARD8 *ext)
+{
+ unsigned int n;
+ INT16 len;
+ INT16 min_len = sizeof(CARD8)
+ + sizeof(CARD8)
+ + sizeof(INT16);
+
+ n = 0;
+ while (total > min_len) {
+ len = *((INT16 *)(&ext[2]));
+ len += (min_len + XIM_PAD(len));
+ total -= len;
+ ext += len;
+ n++;
+ }
+ return n;
+}
+
+Private Bool
+_XimParseExtensionList(
+ Xim im,
+ CARD16 *data)
+{
+ int num = XIMNumber(extensions) - 1;
+ unsigned int n;
+ CARD8 *buf;
+ register int i;
+ register int j;
+ INT16 len;
+
+ if (!(n = _XimCountNumberOfExtension(data[0], (CARD8 *)&data[1])))
+ return True;
+
+ buf = (CARD8 *)&data[1];;
+ for (i = 0; i < n; i++) {
+ len = *((INT16 *)(&buf[2]));
+ for (j = 0; j < num; j++) {
+ if (!(strncmp(extensions[j].name, (char *)&buf[4], len))) {
+ extensions[j].major_opcode = buf[0];
+ extensions[j].minor_opcode = buf[1];
+ extensions[j].is_support = True;
+ break;
+ }
+ }
+ len += sizeof(CARD8) /* sizeof major_opcode */
+ + sizeof(CARD8) /* sizeof minor_opcode */
+ + sizeof(INT16) /* sizeof length */
+ + XIM_PAD(len); /* sizeof pad */
+ buf += len;
+ }
+
+ return True;
+}
+
+Private Bool
+_XimQueryExtensionCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+
+ if ((major_opcode == XIM_QUERY_EXTENSION_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid))
+ return True;
+ return False;
+}
+
+Public Bool
+_XimExtension(
+ Xim im)
+{
+ CARD8 *buf;
+ CARD16 *buf_s;
+ int buf_len;
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ int idx;
+
+ if (!(len = _XimCheckExtensionListSize()))
+ return True;
+
+ buf_len = XIM_HEADER_SIZE
+ + sizeof(CARD16)
+ + sizeof(INT16)
+ + len
+ + XIM_PAD(len);
+
+ if (!(buf = (CARD8 *)Xmalloc(buf_len)))
+ return False;
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = len; /* length of Extensions */
+ _XimSetExtensionList((CARD8 *)&buf_s[2]);
+ /* extensions supported */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += sizeof(CARD16) /* sizeof imid */
+ + sizeof(INT16); /* sizeof length of extensions */
+
+ _XimSetHeader((XPointer)buf, XIM_QUERY_EXTENSION, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ XFree(buf);
+ return False;
+ }
+ XFree(buf);
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimQueryExtensionCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, reply, buf_size,
+ _XimQueryExtensionCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+
+ if (!(_XimParseExtensionList(im, &buf_s[1]))) {
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+
+ if ((idx = _XimIsSupportExt(XIM_EXT_SET_EVENT_MASK_IDX)) >= 0)
+ _XimRegProtoIntrCallback(im,
+ extensions[idx].major_opcode,
+ extensions[idx].minor_opcode,
+ _XimExtSetEventMaskCallback, (XPointer)im);
+#ifdef EXT_FORWARD
+ if ((idx = _XimIsSupportExt(XIM_EXT_FORWARD_KEYEVENT_IDX)) >= 0)
+ _XimRegProtoIntrCallback(im,
+ extensions[idx].major_opcode,
+ extensions[idx].minor_opcode,
+ _XimExtForwardKeyEventCallback, (XPointer)im);
+#endif
+
+ return True;
+}
+
+#ifdef EXT_MOVE
+/* flag of ExtenArgCheck */
+#define EXT_XNSPOTLOCATION (1L<<0)
+
+/* macro for ExtenArgCheck */
+#define SET_EXT_XNSPOTLOCATION(flag) (flag |= EXT_XNSPOTLOCATION)
+#define IS_EXT_XNSPOTLOCATION(flag) (flag & EXT_XNSPOTLOCATION)
+
+/* length of XPoint attribute */
+#define XIM_Xpoint_length 12
+
+Private Bool
+_XimExtMove(
+ Xim im,
+ Xic ic,
+ CARD16 x,
+ CARD16 y)
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+ int idx;
+
+ if ((idx = _XimIsSupportExt(XIM_EXT_MOVE_IDX)) < 0)
+ return False;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+ buf_s[2] = x; /* X */
+ buf_s[3] = y; /* Y */
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16) /* sizeof icid */
+ + sizeof(INT16) /* sizeof X */
+ + sizeof(INT16); /* sizeof Y */
+
+ _XimSetHeader((XPointer)buf, extensions[idx].major_opcode,
+ extensions[idx].minor_opcode, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ return True;
+}
+
+Public BITMASK32
+_XimExtenArgCheck(
+ XIMArg *arg)
+{
+ CARD32 flag = 0L;
+ if (!strcmp(arg->name, XNSpotLocation))
+ SET_EXT_XNSPOTLOCATION(flag);
+ return flag;
+}
+
+Public Bool
+_XimExtenMove(
+ Xim im,
+ Xic ic,
+ CARD32 flag,
+ CARD16 *buf,
+ INT16 length)
+{
+ if ((IS_EXT_XNSPOTLOCATION(flag)) && (length == XIM_Xpoint_length))
+ return _XimExtMove(im, ic, buf[4], buf[5]);
+ return False;
+}
+#endif /* EXT_MOVE */
diff --git a/nx-X11/lib/X11/imImSw.c b/nx-X11/lib/X11/imImSw.c
new file mode 100644
index 000000000..e2c113b23
--- /dev/null
+++ b/nx-X11/lib/X11/imImSw.c
@@ -0,0 +1,57 @@
+/* $Xorg: imImSw.c,v 1.3 2000/08/17 19:45:12 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993 by FUJITSU LIMITED
+ Copyright 1993 by Digital Equipment 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 of FUJITSU LIMITED and
+Digital Equipment Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission. FUJITSU LIMITED and Digital Equipment Corporation
+makes no representations about the suitability of this software for
+any purpose. It is provided "as is" without express or implied
+warranty.
+
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Franky Ling Digital Equipment Corporation
+ frankyling@hgrd01.enet.dec.com
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imImSw.c,v 1.3 2001/01/17 19:41:51 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XimImSw.h"
+
+Private Bool
+_XimCheckIfDefault(
+ Xim im)
+{
+ return(True);
+}
+
+XimImsportSW _XimImSportRec[] = {
+ { _XimCheckIfLocalProcessing, _XimLocalOpenIM, _XimLocalIMFree },
+ { _XimCheckIfThaiProcessing, _XimThaiOpenIM, _XimThaiIMFree },
+ { _XimCheckIfDefault, _XimProtoOpenIM, _XimProtoIMFree },
+ { NULL, NULL, NULL },
+};
diff --git a/nx-X11/lib/X11/imInsClbk.c b/nx-X11/lib/X11/imInsClbk.c
new file mode 100644
index 000000000..ac39f9dfd
--- /dev/null
+++ b/nx-X11/lib/X11/imInsClbk.c
@@ -0,0 +1,292 @@
+/* $Xorg: imInsClbk.c,v 1.3 2000/08/17 19:45:13 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1993, 1994 by Sony 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 of Sony Corporation
+ not be used in advertising or publicity pertaining to distribution
+ of the software without specific, written prior permission.
+Sony Corporation makes no representations about the suitability of
+ this software for any purpose. It is provided "as is" without
+ express or implied warranty.
+
+SONY CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL SONY CORPORATION 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.
+
+ Author: Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imInsClbk.c,v 3.3 2003/05/27 22:26:26 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xatom.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcPublic.h"
+#include "Ximint.h"
+
+
+typedef struct _XimInstCallback {
+ Bool call;
+ Bool destroy;
+ Display *display;
+ XLCd lcd;
+ char name[XIM_MAXLCNAMELEN];
+ char *modifiers;
+ XrmDatabase rdb;
+ char *res_name;
+ char *res_class;
+ XIDProc callback;
+ XPointer client_data;
+ struct _XimInstCallback *next;
+} XimInstCallbackRec, *XimInstCallback;
+
+
+Private XimInstCallback callback_list = NULL;
+Private Bool lock = False;
+
+
+Private void
+MakeLocale( XLCd lcd, char locale[] )
+{
+ char *language, *territory, *codeset;
+
+ _XGetLCValues( lcd, XlcNLanguage, &language, XlcNTerritory, &territory,
+ XlcNCodeset, &codeset, NULL );
+
+ strcpy( locale, language );
+ if( territory && *territory ) {
+ strcat( locale, "_" );
+ strcat( locale, territory );
+ }
+ if( codeset && *codeset ) {
+ strcat( locale, "." );
+ strcat( locale, codeset );
+ }
+}
+
+
+Private Bool
+_XimFilterPropertyNotify(
+ Display *display,
+ Window window,
+ XEvent *event,
+ XPointer client_data)
+{
+ Atom ims, actual_type, *atoms;
+ int actual_format;
+ unsigned long nitems, bytes_after;
+ int ii;
+ XIM xim;
+ Bool flag = False;
+ XimInstCallback icb, picb, tmp;
+
+ if( (ims = XInternAtom( display, XIM_SERVERS, True )) == None ||
+ event->xproperty.atom != ims ||
+ event->xproperty.state == PropertyDelete )
+ return( False );
+
+ if( XGetWindowProperty( display, RootWindow(display, 0), ims, 0L, 1000000L,
+ False, XA_ATOM, &actual_type, &actual_format,
+ &nitems, &bytes_after, (unsigned char **)&atoms )
+ != Success ) {
+ return( False );
+ }
+ if( actual_type != XA_ATOM || actual_format != 32 ) {
+ XFree( atoms );
+ return( False );
+ }
+
+ lock = True;
+ for( ii = 0; ii < nitems; ii++, atoms ) {
+ if(XGetSelectionOwner (display, atoms[ii])) {
+ for( icb = callback_list; icb; icb = icb->next ) {
+ if( !icb->call && !icb->destroy ) {
+ xim = (*icb->lcd->methods->open_im)( icb->lcd, display,
+ icb->rdb,
+ icb->res_name,
+ icb->res_class );
+ if( xim ) {
+ xim->methods->close( (XIM)xim );
+ flag = True;
+ icb->call = True;
+ icb->callback( icb->display, icb->client_data, NULL );
+ }
+ }
+ }
+ break;
+ }
+ }
+ XFree( atoms );
+
+ for( icb = callback_list, picb = NULL; icb; ) {
+ if( icb->destroy ) {
+ if( picb )
+ picb->next = icb->next;
+ else
+ callback_list = icb->next;
+ tmp = icb;
+ icb = icb->next;
+ XFree( tmp );
+ }
+ else {
+ picb = icb;
+ icb = icb->next;
+ }
+ }
+ lock = False;
+
+ return( flag );
+}
+
+
+Public Bool
+_XimRegisterIMInstantiateCallback(
+ XLCd lcd,
+ Display *display,
+ XrmDatabase rdb,
+ char *res_name,
+ char *res_class,
+ XIDProc callback,
+ XPointer client_data)
+{
+ XimInstCallback icb, tmp;
+ XIM xim;
+ Window root;
+ XWindowAttributes attr;
+
+ if( lock )
+ return( False );
+
+ icb = (XimInstCallback)Xmalloc(sizeof(XimInstCallbackRec));
+ if( !icb )
+ return( False );
+ icb->call = icb->destroy = False;
+ icb->display = display;
+ icb->lcd = lcd;
+ MakeLocale( lcd, icb->name );
+ icb->modifiers = lcd->core->modifiers; /* XXXXX */
+ icb->rdb = rdb;
+ icb->res_name = res_name;
+ icb->res_class = res_class;
+ icb->callback = callback;
+ icb->client_data = client_data;
+ icb->next = NULL;
+
+ if( !callback_list )
+ callback_list = icb;
+ else {
+ for( tmp = callback_list; tmp->next; tmp = tmp->next );
+ tmp->next = icb;
+ }
+
+ xim = (*lcd->methods->open_im)( lcd, display, rdb, res_name, res_class );
+
+ if( icb == callback_list ) {
+ root = RootWindow( display, 0 );
+ XGetWindowAttributes( display, root, &attr );
+ _XRegisterFilterByType( display, root, PropertyNotify, PropertyNotify,
+ _XimFilterPropertyNotify, (XPointer)NULL );
+ XSelectInput( display, root,
+ attr.your_event_mask | PropertyChangeMask );
+ }
+
+ if( xim ) {
+ lock = True;
+ xim->methods->close( (XIM)xim );
+ lock = False;
+ icb->call = True;
+ callback( display, client_data, NULL );
+ }
+
+ return( True );
+}
+
+
+Public Bool
+_XimUnRegisterIMInstantiateCallback(
+ XLCd lcd,
+ Display *display,
+ XrmDatabase rdb,
+ char *res_name,
+ char *res_class,
+ XIDProc callback,
+ XPointer client_data)
+{
+ char locale[XIM_MAXLCNAMELEN];
+ XimInstCallback icb, picb;
+
+ if( !callback_list )
+ return( False );
+
+ MakeLocale( lcd, locale );
+
+ for( icb = callback_list, picb = NULL; icb; picb = icb, icb = icb->next ) {
+ if( !strcmp( locale, icb->name ) &&
+ (lcd->core->modifiers == icb->modifiers || /* XXXXX */
+ (lcd->core->modifiers && icb->modifiers &&
+ !strcmp( lcd->core->modifiers, icb->modifiers ))) &&
+ rdb == icb->rdb && /* XXXXX */
+ ((res_name == NULL && icb->res_name == NULL) ||
+ (res_name != NULL && icb->res_name != NULL &&
+ !strcmp( res_name, icb->res_name ))) &&
+ ((res_class == NULL && icb->res_class == NULL) ||
+ (res_class != NULL && icb->res_class != NULL &&
+ !strcmp( res_class, icb->res_class ))) &&
+ (callback == icb->callback) &&
+ (client_data == icb->client_data) && /* XXXXX */
+ !icb->destroy ) {
+ if( lock )
+ icb->destroy = True;
+ else {
+ if( !picb ) {
+ callback_list = icb->next;
+ _XUnregisterFilter( display, RootWindow(display, 0),
+ _XimFilterPropertyNotify,
+ (XPointer)NULL );
+ }
+ else
+ picb->next = icb->next;
+ _XCloseLC( icb->lcd );
+ XFree( icb );
+ }
+ return( True );
+ }
+ }
+ return( False );
+}
+
+
+Public void
+_XimResetIMInstantiateCallback( xim )
+ Xim xim;
+{
+ char locale[XIM_MAXLCNAMELEN];
+ XimInstCallback icb;
+ XLCd lcd = xim->core.lcd;
+
+ if( !callback_list && lock )
+ return;
+
+ MakeLocale( lcd, locale );
+
+ for( icb = callback_list; icb; icb = icb->next )
+ if( !strcmp( locale, icb->name ) &&
+ (lcd->core->modifiers == icb->modifiers ||
+ (lcd->core->modifiers && icb->modifiers &&
+ !strcmp( lcd->core->modifiers, icb->modifiers ))) )
+ icb->call = False;
+}
diff --git a/nx-X11/lib/X11/imInt.c b/nx-X11/lib/X11/imInt.c
new file mode 100644
index 000000000..5a047e4aa
--- /dev/null
+++ b/nx-X11/lib/X11/imInt.c
@@ -0,0 +1,271 @@
+/* $Xorg: imInt.c,v 1.8 2000/08/17 19:45:13 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+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 of FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imInt.c,v 3.12 2003/04/17 02:06:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XimImSw.h"
+
+Private Xim *_XimCurrentIMlist = (Xim *)NULL;
+Private int _XimCurrentIMcount = 0;
+
+Private Bool
+_XimSetIMStructureList(
+ Xim im)
+{
+ register int i;
+ Xim *xim;
+
+ if(!(_XimCurrentIMlist)) {
+ if(!(_XimCurrentIMlist = (Xim *)Xmalloc(sizeof(Xim))))
+ return False;
+ _XimCurrentIMlist[0] = im;
+ _XimCurrentIMcount = 1;
+ }
+ else {
+ for(i = 0; i < _XimCurrentIMcount; i++) {
+ if(!( _XimCurrentIMlist[i])) {
+ _XimCurrentIMlist[i] = im;
+ break;
+ }
+ }
+ if(i >= _XimCurrentIMcount) {
+ if(!(xim = (Xim *)Xrealloc(_XimCurrentIMlist,
+ ((i + 1) * sizeof(Xim)))))
+ return False;
+ _XimCurrentIMlist = xim;
+ _XimCurrentIMlist[_XimCurrentIMcount] = im;
+ _XimCurrentIMcount++;
+ }
+ }
+ return True;
+}
+
+Public void
+_XimDestroyIMStructureList(im)
+ Xim im;
+{
+ register int i;
+
+ for(i = 0; i < _XimCurrentIMcount; i++) {
+ if(_XimCurrentIMlist[i] == im) {
+ _XimCurrentIMlist[i] = NULL;
+ break;
+ }
+ }
+ return;
+}
+
+Public void
+_XimServerDestroy(im_2_destroy)
+ Xim im_2_destroy;
+{
+ register int i;
+ Xim im;
+ XIC ic;
+
+ for(i = 0; i < _XimCurrentIMcount; i++) {
+ if(!(im = _XimCurrentIMlist[i]))
+ continue;
+ /*
+ * Only continue if this im is the one to be destroyed.
+ */
+ if (im != im_2_destroy)
+ continue;
+
+ if (im->core.destroy_callback.callback)
+ (*im->core.destroy_callback.callback)((XIM)im,
+ im->core.destroy_callback.client_data, NULL);
+ for (ic = im->core.ic_chain; ic; ic = ic->core.next) {
+ if (ic->core.destroy_callback.callback) {
+ (*ic->core.destroy_callback.callback)(ic,
+ ic->core.destroy_callback.client_data, NULL);
+ }
+ }
+ _XimResetIMInstantiateCallback( im );
+ (void)im->methods->close((XIM)im);
+ Xfree(im);
+ _XimCurrentIMlist[i] = NULL;
+ return;
+ }
+}
+
+#ifdef XIM_CONNECTABLE
+Public void
+_XimServerReconectableDestroy()
+{
+ register int i;
+ Xim im;
+ XIC ic;
+
+ for(i = 0; i < _XimCurrentIMcount; i++) {
+ if(!(im = _XimCurrentIMlist[i]))
+ continue;
+
+ if (im->core.destroy_callback.callback)
+ (*im->core.destroy_callback.callback)(im,
+ im->core.destroy_callback.client_data, NULL);
+ for (ic = im->core.ic_chain; ic; ic = ic->core.next) {
+ if (ic->core.destroy_callback.callback) {
+ (*ic->core.destroy_callback.callback)(ic,
+ ic->core.destroy_callback.client_data, NULL);
+ }
+ }
+ _XimResetIMInstantiateCallback( im );
+ (void)im->methods->close((XIM)im);
+ }
+ return;
+}
+#endif /* XIM_CONNECTABLE */
+
+Private char *
+_XimStrstr(
+ register char *src,
+ register char *dest)
+{
+ int len;
+
+ len = strlen(dest);
+ while((src = strchr(src, *dest))) {
+ if(!strncmp(src, dest, len))
+ return src;
+ src++;
+ }
+ return NULL;
+}
+
+Private char *
+_XimMakeImName(
+ XLCd lcd)
+{
+ char* begin = NULL;
+ char* end = NULL;
+ char* ret = NULL;
+ char* ximmodifier = XIMMODIFIER;
+
+ if(lcd->core->modifiers != NULL && *lcd->core->modifiers != '\0') {
+ begin = _XimStrstr(lcd->core->modifiers, ximmodifier);
+ if (begin != NULL) {
+ end = begin += strlen(ximmodifier);
+ while (*end && *end != '@')
+ end++;
+ }
+ }
+ ret = Xmalloc(end - begin + 1);
+ if (ret != NULL) {
+ if (begin != NULL && end != NULL) {
+ (void)strncpy(ret, begin, end - begin);
+ ret[end - begin] = '\0';
+ } else {
+ ret[0] = '\0';
+ }
+ }
+
+ return ret;
+}
+
+Public XIM
+_XimOpenIM(
+ XLCd lcd,
+ Display *dpy,
+ XrmDatabase rdb,
+ char *res_name,
+ char *res_class)
+{
+ Xim im;
+ register int i;
+
+ if (!(im = (Xim)Xmalloc(sizeof(XimRec))))
+ return (XIM)NULL;
+ bzero(im, sizeof(XimRec));
+
+ im->core.lcd = lcd;
+ im->core.ic_chain = (XIC)NULL;
+ im->core.display = dpy;
+ im->core.rdb = rdb;
+ im->core.res_name = NULL;
+ im->core.res_class = NULL;
+ if((res_name != NULL) && (*res_name != '\0')){
+ if(!(im->core.res_name = (char *)Xmalloc(strlen(res_name)+1)))
+ goto Error1;
+ strcpy(im->core.res_name,res_name);
+ }
+ if((res_class != NULL) && (*res_class != '\0')){
+ if(!(im->core.res_class = (char *)Xmalloc(strlen(res_class)+1)))
+ goto Error2;
+ strcpy(im->core.res_class,res_class);
+ }
+ if(!(im->core.im_name = _XimMakeImName(lcd)))
+ goto Error3;
+
+ for(i= 0; ; i++) {
+ if(_XimImSportRec[i].checkprocessing(im)) {
+ if(!(_XimImSportRec[i].im_open(im)))
+ goto Error4;
+ if(!_XimSetIMStructureList(im))
+ goto Error4;
+ return (XIM)im;
+ }
+ }
+
+Error4 :
+ _XimImSportRec[i].im_free(im);
+ Xfree(im);
+ return NULL;
+Error3 :
+ if(im->core.im_name)
+ Xfree(im->core.im_name);
+Error2:
+ if(im->core.res_class)
+ Xfree(im->core.res_class);
+Error1:
+ if(im->core.res_name)
+ Xfree(im->core.res_name);
+ Xfree(im);
+ return NULL;
+}
+
+Public Bool
+_XInitIM(lcd)
+ XLCd lcd;
+{
+ if(lcd == (XLCd)NULL)
+ return False;
+ lcd->methods->open_im = _XimOpenIM;
+ lcd->methods->register_callback = _XimRegisterIMInstantiateCallback;
+ lcd->methods->unregister_callback = _XimUnRegisterIMInstantiateCallback;
+ return True;
+}
diff --git a/nx-X11/lib/X11/imKStoUCS.c b/nx-X11/lib/X11/imKStoUCS.c
new file mode 100644
index 000000000..7d8d5b92d
--- /dev/null
+++ b/nx-X11/lib/X11/imKStoUCS.c
@@ -0,0 +1,323 @@
+/* $XFree86: xc/lib/X11/imKStoUCS.c,v 1.4 2003/04/29 11:29:18 pascal Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Ximint.h"
+
+static unsigned short const keysym_to_unicode_1a1_1ff[] = {
+ 0x0104, 0x02d8, 0x0141, 0x0000, 0x013d, 0x015a, 0x0000, /* 0x01a0-0x01a7 */
+ 0x0000, 0x0160, 0x015e, 0x0164, 0x0179, 0x0000, 0x017d, 0x017b, /* 0x01a8-0x01af */
+ 0x0000, 0x0105, 0x02db, 0x0142, 0x0000, 0x013e, 0x015b, 0x02c7, /* 0x01b0-0x01b7 */
+ 0x0000, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c, /* 0x01b8-0x01bf */
+ 0x0154, 0x0000, 0x0000, 0x0102, 0x0000, 0x0139, 0x0106, 0x0000, /* 0x01c0-0x01c7 */
+ 0x010c, 0x0000, 0x0118, 0x0000, 0x011a, 0x0000, 0x0000, 0x010e, /* 0x01c8-0x01cf */
+ 0x0110, 0x0143, 0x0147, 0x0000, 0x0000, 0x0150, 0x0000, 0x0000, /* 0x01d0-0x01d7 */
+ 0x0158, 0x016e, 0x0000, 0x0170, 0x0000, 0x0000, 0x0162, 0x0000, /* 0x01d8-0x01df */
+ 0x0155, 0x0000, 0x0000, 0x0103, 0x0000, 0x013a, 0x0107, 0x0000, /* 0x01e0-0x01e7 */
+ 0x010d, 0x0000, 0x0119, 0x0000, 0x011b, 0x0000, 0x0000, 0x010f, /* 0x01e8-0x01ef */
+ 0x0111, 0x0144, 0x0148, 0x0000, 0x0000, 0x0151, 0x0000, 0x0000, /* 0x01f0-0x01f7 */
+ 0x0159, 0x016f, 0x0000, 0x0171, 0x0000, 0x0000, 0x0163, 0x02d9 /* 0x01f8-0x01ff */
+};
+
+static unsigned short const keysym_to_unicode_2a1_2fe[] = {
+ 0x0126, 0x0000, 0x0000, 0x0000, 0x0000, 0x0124, 0x0000, /* 0x02a0-0x02a7 */
+ 0x0000, 0x0130, 0x0000, 0x011e, 0x0134, 0x0000, 0x0000, 0x0000, /* 0x02a8-0x02af */
+ 0x0000, 0x0127, 0x0000, 0x0000, 0x0000, 0x0000, 0x0125, 0x0000, /* 0x02b0-0x02b7 */
+ 0x0000, 0x0131, 0x0000, 0x011f, 0x0135, 0x0000, 0x0000, 0x0000, /* 0x02b8-0x02bf */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x010a, 0x0108, 0x0000, /* 0x02c0-0x02c7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x02c8-0x02cf */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0120, 0x0000, 0x0000, /* 0x02d0-0x02d7 */
+ 0x011c, 0x0000, 0x0000, 0x0000, 0x0000, 0x016c, 0x015c, 0x0000, /* 0x02d8-0x02df */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x010b, 0x0109, 0x0000, /* 0x02e0-0x02e7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x02e8-0x02ef */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0121, 0x0000, 0x0000, /* 0x02f0-0x02f7 */
+ 0x011d, 0x0000, 0x0000, 0x0000, 0x0000, 0x016d, 0x015d /* 0x02f8-0x02ff */
+};
+
+static unsigned short const keysym_to_unicode_3a2_3fe[] = {
+ 0x0138, 0x0156, 0x0000, 0x0128, 0x013b, 0x0000, /* 0x03a0-0x03a7 */
+ 0x0000, 0x0000, 0x0112, 0x0122, 0x0166, 0x0000, 0x0000, 0x0000, /* 0x03a8-0x03af */
+ 0x0000, 0x0000, 0x0000, 0x0157, 0x0000, 0x0129, 0x013c, 0x0000, /* 0x03b0-0x03b7 */
+ 0x0000, 0x0000, 0x0113, 0x0123, 0x0167, 0x014a, 0x0000, 0x014b, /* 0x03b8-0x03bf */
+ 0x0100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x012e, /* 0x03c0-0x03c7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0116, 0x0000, 0x0000, 0x012a, /* 0x03c8-0x03cf */
+ 0x0000, 0x0145, 0x014c, 0x0136, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x03d0-0x03d7 */
+ 0x0000, 0x0172, 0x0000, 0x0000, 0x0000, 0x0168, 0x016a, 0x0000, /* 0x03d8-0x03df */
+ 0x0101, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x012f, /* 0x03e0-0x03e7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0117, 0x0000, 0x0000, 0x012b, /* 0x03e8-0x03ef */
+ 0x0000, 0x0146, 0x014d, 0x0137, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x03f0-0x03f7 */
+ 0x0000, 0x0173, 0x0000, 0x0000, 0x0000, 0x0169, 0x016b /* 0x03f8-0x03ff */
+};
+
+static unsigned short const keysym_to_unicode_4a1_4df[] = {
+ 0x3002, 0x3008, 0x3009, 0x3001, 0x30fb, 0x30f2, 0x30a1, /* 0x04a0-0x04a7 */
+ 0x30a3, 0x30a5, 0x30a7, 0x30a9, 0x30e3, 0x30e5, 0x30e7, 0x30c3, /* 0x04a8-0x04af */
+ 0x30fc, 0x30a2, 0x30a4, 0x30a6, 0x30a8, 0x30aa, 0x30ab, 0x30ad, /* 0x04b0-0x04b7 */
+ 0x30af, 0x30b1, 0x30b3, 0x30b5, 0x30b7, 0x30b9, 0x30bb, 0x30bd, /* 0x04b8-0x04bf */
+ 0x30bf, 0x30c1, 0x30c4, 0x30c6, 0x30c8, 0x30ca, 0x30cb, 0x30cc, /* 0x04c0-0x04c7 */
+ 0x30cd, 0x30ce, 0x30cf, 0x30d2, 0x30d5, 0x30d8, 0x30db, 0x30de, /* 0x04c8-0x04cf */
+ 0x30df, 0x30e0, 0x30e1, 0x30e2, 0x30e4, 0x30e6, 0x30e8, 0x30e9, /* 0x04d0-0x04d7 */
+ 0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ef, 0x30f3, 0x309b, 0x309c /* 0x04d8-0x04df */
+};
+
+static unsigned short const keysym_to_unicode_590_5fe[] = {
+ 0x06f0, 0x06f1, 0x06f2, 0x06f3, 0x06f4, 0x06f5, 0x06f6, 0x06f7, /* 0x0590-0x0597 */
+ 0x06f8, 0x06f9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x0598-0x059f */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x066a, 0x0670, 0x0679, /* 0x05a0-0x05a7 */
+
+ 0x067e, 0x0686, 0x0688, 0x0691, 0x060c, 0x0000, 0x06d4, 0x0000, /* 0x05ac-0x05af */
+ 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, /* 0x05b0-0x05b7 */
+ 0x0668, 0x0669, 0x0000, 0x061b, 0x0000, 0x0000, 0x0000, 0x061f, /* 0x05b8-0x05bf */
+ 0x0000, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, /* 0x05c0-0x05c7 */
+ 0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f, /* 0x05c8-0x05cf */
+ 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, /* 0x05d0-0x05d7 */
+ 0x0638, 0x0639, 0x063a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x05d8-0x05df */
+ 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, /* 0x05e0-0x05e7 */
+ 0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f, /* 0x05e8-0x05ef */
+ 0x0650, 0x0651, 0x0652, 0x0653, 0x0654, 0x0655, 0x0698, 0x06a4, /* 0x05f0-0x05f7 */
+ 0x06a9, 0x06af, 0x06ba, 0x06be, 0x06cc, 0x06d2, 0x06c1 /* 0x05f8-0x05fe */
+};
+
+static unsigned short keysym_to_unicode_680_6ff[] = {
+ 0x0492, 0x0496, 0x049a, 0x049c, 0x04a2, 0x04ae, 0x04b0, 0x04b2, /* 0x0680-0x0687 */
+ 0x04b6, 0x04b8, 0x04ba, 0x0000, 0x04d8, 0x04e2, 0x04e8, 0x04ee, /* 0x0688-0x068f */
+ 0x0493, 0x0497, 0x049b, 0x049d, 0x04a3, 0x04af, 0x04b1, 0x04b3, /* 0x0690-0x0697 */
+ 0x04b7, 0x04b9, 0x04bb, 0x0000, 0x04d9, 0x04e3, 0x04e9, 0x04ef, /* 0x0698-0x069f */
+ 0x0000, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457, /* 0x06a0-0x06a7 */
+ 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x0491, 0x045e, 0x045f, /* 0x06a8-0x06af */
+ 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407, /* 0x06b0-0x06b7 */
+ 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x0490, 0x040e, 0x040f, /* 0x06b8-0x06bf */
+ 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, /* 0x06c0-0x06c7 */
+ 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, /* 0x06c8-0x06cf */
+ 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, /* 0x06d0-0x06d7 */
+ 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a, /* 0x06d8-0x06df */
+ 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, /* 0x06e0-0x06e7 */
+ 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, /* 0x06e8-0x06ef */
+ 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, /* 0x06f0-0x06f7 */
+ 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a /* 0x06f8-0x06ff */
+};
+
+static unsigned short const keysym_to_unicode_7a1_7f9[] = {
+ 0x0386, 0x0388, 0x0389, 0x038a, 0x03aa, 0x0000, 0x038c, /* 0x07a0-0x07a7 */
+ 0x038e, 0x03ab, 0x0000, 0x038f, 0x0000, 0x0000, 0x0385, 0x2015, /* 0x07a8-0x07af */
+ 0x0000, 0x03ac, 0x03ad, 0x03ae, 0x03af, 0x03ca, 0x0390, 0x03cc, /* 0x07b0-0x07b7 */
+ 0x03cd, 0x03cb, 0x03b0, 0x03ce, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x07b8-0x07bf */
+ 0x0000, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, /* 0x07c0-0x07c7 */
+ 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, /* 0x07c8-0x07cf */
+ 0x03a0, 0x03a1, 0x03a3, 0x0000, 0x03a4, 0x03a5, 0x03a6, 0x03a7, /* 0x07d0-0x07d7 */
+ 0x03a8, 0x03a9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x07d8-0x07df */
+ 0x0000, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, /* 0x07e0-0x07e7 */
+ 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, /* 0x07e8-0x07ef */
+ 0x03c0, 0x03c1, 0x03c3, 0x03c2, 0x03c4, 0x03c5, 0x03c6, 0x03c7, /* 0x07f0-0x07f7 */
+ 0x03c8, 0x03c9 /* 0x07f8-0x07ff */
+};
+
+static unsigned short const keysym_to_unicode_8a4_8fe[] = {
+ 0x2320, 0x2321, 0x0000, 0x231c, /* 0x08a0-0x08a7 */
+ 0x231d, 0x231e, 0x231f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08a8-0x08af */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08b0-0x08b7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x2264, 0x2260, 0x2265, 0x222b, /* 0x08b8-0x08bf */
+ 0x2234, 0x0000, 0x221e, 0x0000, 0x0000, 0x2207, 0x0000, 0x0000, /* 0x08c0-0x08c7 */
+ 0x2245, 0x2246, 0x0000, 0x0000, 0x0000, 0x0000, 0x22a2, 0x0000, /* 0x08c8-0x08cf */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x221a, 0x0000, /* 0x08d0-0x08d7 */
+ 0x0000, 0x0000, 0x2282, 0x2283, 0x2229, 0x222a, 0x2227, 0x2228, /* 0x08d8-0x08df */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08e0-0x08e7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08e8-0x08ef */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0192, 0x0000, /* 0x08f0-0x08f7 */
+ 0x0000, 0x0000, 0x0000, 0x2190, 0x2191, 0x2192, 0x2193 /* 0x08f8-0x08ff */
+};
+
+static unsigned short const keysym_to_unicode_9df_9f8[] = {
+ 0x2422, /* 0x09d8-0x09df */
+ 0x2666, 0x25a6, 0x2409, 0x240c, 0x240d, 0x240a, 0x0000, 0x0000, /* 0x09e0-0x09e7 */
+ 0x240a, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0x2500, /* 0x09e8-0x09ef */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x251c, 0x2524, 0x2534, 0x252c, /* 0x09f0-0x09f7 */
+ 0x2502 /* 0x09f8-0x09ff */
+};
+
+static unsigned short const keysym_to_unicode_aa1_afe[] = {
+ 0x2003, 0x2002, 0x2004, 0x2005, 0x2007, 0x2008, 0x2009, /* 0x0aa0-0x0aa7 */
+ 0x200a, 0x2014, 0x2013, 0x0000, 0x0000, 0x0000, 0x2026, 0x2025, /* 0x0aa8-0x0aaf */
+ 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159, 0x215a, /* 0x0ab0-0x0ab7 */
+ 0x2105, 0x0000, 0x0000, 0x2012, 0x2039, 0x2024, 0x203a, 0x0000, /* 0x0ab8-0x0abf */
+ 0x0000, 0x0000, 0x0000, 0x215b, 0x215c, 0x215d, 0x215e, 0x0000, /* 0x0ac0-0x0ac7 */
+ 0x0000, 0x2122, 0x2120, 0x0000, 0x25c1, 0x25b7, 0x25cb, 0x25ad, /* 0x0ac8-0x0acf */
+ 0x2018, 0x2019, 0x201c, 0x201d, 0x211e, 0x0000, 0x2032, 0x2033, /* 0x0ad0-0x0ad7 */
+ 0x0000, 0x271d, 0x0000, 0x220e, 0x25c2, 0x2023, 0x25cf, 0x25ac, /* 0x0ad8-0x0adf */
+ 0x25e6, 0x25ab, 0x25ae, 0x25b5, 0x25bf, 0x2606, 0x2022, 0x25aa, /* 0x0ae0-0x0ae7 */
+ 0x25b4, 0x25be, 0x261a, 0x261b, 0x2663, 0x2666, 0x2665, 0x0000, /* 0x0ae8-0x0aef */
+ 0x2720, 0x2020, 0x2021, 0x2713, 0x2612, 0x266f, 0x266d, 0x2642, /* 0x0af0-0x0af7 */
+ 0x2640, 0x2121, 0x2315, 0x2117, 0x2038, 0x201a, 0x201e /* 0x0af8-0x0aff */
+};
+
+/* none of the APL keysyms match the Unicode characters */
+
+static unsigned short const keysym_to_unicode_cdf_cfa[] = {
+ 0x2017, /* 0x0cd8-0x0cdf */
+ 0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7, /* 0x0ce0-0x0ce7 */
+ 0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df, /* 0x0ce8-0x0cef */
+ 0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7, /* 0x0cf0-0x0cf7 */
+ 0x05e8, 0x05e9, 0x05ea /* 0x0cf8-0x0cff */
+};
+
+static unsigned short const keysym_to_unicode_da1_df9[] = {
+ 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, /* 0x0da0-0x0da7 */
+ 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, /* 0x0da8-0x0daf */
+ 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, /* 0x0db0-0x0db7 */
+ 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, /* 0x0db8-0x0dbf */
+ 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, /* 0x0dc0-0x0dc7 */
+ 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, /* 0x0dc8-0x0dcf */
+ 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, /* 0x0dd0-0x0dd7 */
+ 0x0e38, 0x0e39, 0x0e3a, 0x0000, 0x0000, 0x0000, 0x0e3e, 0x0e3f, /* 0x0dd8-0x0ddf */
+ 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, /* 0x0de0-0x0de7 */
+ 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0000, 0x0000, /* 0x0de8-0x0def */
+ 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, /* 0x0df0-0x0df7 */
+ 0x0e58, 0x0e59 /* 0x0df8-0x0dff */
+};
+
+static unsigned short const keysym_to_unicode_ea0_eff[] = {
+ 0x0000, 0x1101, 0x1101, 0x11aa, 0x1102, 0x11ac, 0x11ad, 0x1103, /* 0x0ea0-0x0ea7 */
+ 0x1104, 0x1105, 0x11b0, 0x11b1, 0x11b2, 0x11b3, 0x11b4, 0x11b5, /* 0x0ea8-0x0eaf */
+ 0x11b6, 0x1106, 0x1107, 0x1108, 0x11b9, 0x1109, 0x110a, 0x110b, /* 0x0eb0-0x0eb7 */
+ 0x110c, 0x110d, 0x110e, 0x110f, 0x1110, 0x1111, 0x1112, 0x1161, /* 0x0eb8-0x0ebf */
+ 0x1162, 0x1163, 0x1164, 0x1165, 0x1166, 0x1167, 0x1168, 0x1169, /* 0x0ec0-0x0ec7 */
+ 0x116a, 0x116b, 0x116c, 0x116d, 0x116e, 0x116f, 0x1170, 0x1171, /* 0x0ec8-0x0ecf */
+ 0x1172, 0x1173, 0x1174, 0x1175, 0x11a8, 0x11a9, 0x11aa, 0x11ab, /* 0x0ed0-0x0ed7 */
+ 0x11ac, 0x11ad, 0x11ae, 0x11af, 0x11b0, 0x11b1, 0x11b2, 0x11b3, /* 0x0ed8-0x0edf */
+ 0x11b4, 0x11b5, 0x11b6, 0x11b7, 0x11b8, 0x11b9, 0x11ba, 0x11bb, /* 0x0ee0-0x0ee7 */
+ 0x11bc, 0x11bd, 0x11be, 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x0000, /* 0x0ee8-0x0eef */
+ 0x0000, 0x0000, 0x1140, 0x0000, 0x0000, 0x1159, 0x119e, 0x0000, /* 0x0ef0-0x0ef7 */
+ 0x11eb, 0x0000, 0x11f9, 0x0000, 0x0000, 0x0000, 0x0000, 0x20a9, /* 0x0ef8-0x0eff */
+};
+
+static unsigned short keysym_to_unicode_12a1_12fe[] = {
+ 0x1e02, 0x1e03, 0x0000, 0x0000, 0x0000, 0x1e0a, 0x0000, /* 0x12a0-0x12a7 */
+ 0x1e80, 0x0000, 0x1e82, 0x1e0b, 0x1ef2, 0x0000, 0x0000, 0x0000, /* 0x12a8-0x12af */
+ 0x1e1e, 0x1e1f, 0x0000, 0x0000, 0x1e40, 0x1e41, 0x0000, 0x1e56, /* 0x12b0-0x12b7 */
+ 0x1e81, 0x1e57, 0x1e83, 0x1e60, 0x1ef3, 0x1e84, 0x1e85, 0x1e61, /* 0x12b8-0x12bf */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x12c0-0x12c7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x12c8-0x12cf */
+ 0x0174, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1e6a, /* 0x12d0-0x12d7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0176, 0x0000, /* 0x12d8-0x12df */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x12e0-0x12e7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x12e8-0x12ef */
+ 0x0175, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1e6b, /* 0x12f0-0x12f7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0177 /* 0x12f0-0x12ff */
+};
+
+static unsigned short const keysym_to_unicode_13bc_13be[] = {
+ 0x0152, 0x0153, 0x0178 /* 0x13b8-0x13bf */
+};
+
+static unsigned short keysym_to_unicode_14a1_14ff[] = {
+ 0x2741, 0x00a7, 0x0589, 0x0029, 0x0028, 0x00bb, 0x00ab, /* 0x14a0-0x14a7 */
+ 0x2014, 0x002e, 0x055d, 0x002c, 0x2013, 0x058a, 0x2026, 0x055c, /* 0x14a8-0x14af */
+ 0x055b, 0x055e, 0x0531, 0x0561, 0x0532, 0x0562, 0x0533, 0x0563, /* 0x14b0-0x14b7 */
+ 0x0534, 0x0564, 0x0535, 0x0565, 0x0536, 0x0566, 0x0537, 0x0567, /* 0x14b8-0x14bf */
+ 0x0538, 0x0568, 0x0539, 0x0569, 0x053a, 0x056a, 0x053b, 0x056b, /* 0x14c0-0x14c7 */
+ 0x053c, 0x056c, 0x053d, 0x056d, 0x053e, 0x056e, 0x053f, 0x056f, /* 0x14c8-0x14cf */
+ 0x0540, 0x0570, 0x0541, 0x0571, 0x0542, 0x0572, 0x0543, 0x0573, /* 0x14d0-0x14d7 */
+ 0x0544, 0x0574, 0x0545, 0x0575, 0x0546, 0x0576, 0x0547, 0x0577, /* 0x14d8-0x14df */
+ 0x0548, 0x0578, 0x0549, 0x0579, 0x054a, 0x057a, 0x054b, 0x057b, /* 0x14e0-0x14e7 */
+ 0x054c, 0x057c, 0x054d, 0x057d, 0x054e, 0x057e, 0x054f, 0x057f, /* 0x14e8-0x14ef */
+ 0x0550, 0x0580, 0x0551, 0x0581, 0x0552, 0x0582, 0x0553, 0x0583, /* 0x14f0-0x14f7 */
+ 0x0554, 0x0584, 0x0555, 0x0585, 0x0556, 0x0586, 0x2019, 0x0027, /* 0x14f8-0x14ff */
+};
+
+static unsigned short keysym_to_unicode_15d0_15f6[] = {
+ 0x10d0, 0x10d1, 0x10d2, 0x10d3, 0x10d4, 0x10d5, 0x10d6, 0x10d7, /* 0x15d0-0x15d7 */
+ 0x10d8, 0x10d9, 0x10da, 0x10db, 0x10dc, 0x10dd, 0x10de, 0x10df, /* 0x15d8-0x15df */
+ 0x10e0, 0x10e1, 0x10e2, 0x10e3, 0x10e4, 0x10e5, 0x10e6, 0x10e7, /* 0x15e0-0x15e7 */
+ 0x10e8, 0x10e9, 0x10ea, 0x10eb, 0x10ec, 0x10ed, 0x10ee, 0x10ef, /* 0x15e8-0x15ef */
+ 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6 /* 0x15f0-0x15f7 */
+};
+
+static unsigned short keysym_to_unicode_16a0_16f6[] = {
+ 0x0000, 0x0000, 0xf0a2, 0x1e8a, 0x0000, 0xf0a5, 0x012c, 0xf0a7, /* 0x16a0-0x16a7 */
+ 0xf0a8, 0x01b5, 0x01e6, 0x0000, 0x0000, 0x0000, 0x0000, 0x019f, /* 0x16a8-0x16af */
+ 0x0000, 0x0000, 0xf0b2, 0x1e8b, 0x01d1, 0xf0b5, 0x012d, 0xf0b7, /* 0x16b0-0x16b7 */
+ 0xf0b8, 0x01b6, 0x01e7, 0x0000, 0x0000, 0x01d2, 0x0000, 0x0275, /* 0x16b8-0x16bf */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x018f, 0x0000, /* 0x16c0-0x16c7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x16c8-0x16cf */
+ 0x0000, 0x1e36, 0xf0d2, 0xf0d3, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x16d0-0x16d7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x16d8-0x16df */
+ 0x0000, 0x1e37, 0xf0e2, 0xf0e3, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x16e0-0x16e7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x16e8-0x16ef */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0259 /* 0x16f0-0x16f6 */
+};
+
+static unsigned short const keysym_to_unicode_1e9f_1eff[] = {
+ 0x0303,
+ 0x1ea0, 0x1ea1, 0x1ea2, 0x1ea3, 0x1ea4, 0x1ea5, 0x1ea6, 0x1ea7, /* 0x1ea0-0x1ea7 */
+ 0x1ea8, 0x1ea9, 0x1eaa, 0x1eab, 0x1eac, 0x1ead, 0x1eae, 0x1eaf, /* 0x1ea8-0x1eaf */
+ 0x1eb0, 0x1eb1, 0x1eb2, 0x1eb3, 0x1eb4, 0x1eb5, 0x1eb6, 0x1eb7, /* 0x1eb0-0x1eb7 */
+ 0x1eb8, 0x1eb9, 0x1eba, 0x1ebb, 0x1ebc, 0x1ebd, 0x1ebe, 0x1ebf, /* 0x1eb8-0x1ebf */
+ 0x1ec0, 0x1ec1, 0x1ec2, 0x1ec3, 0x1ec4, 0x1ec5, 0x1ec6, 0x1ec7, /* 0x1ec0-0x1ec7 */
+ 0x1ec8, 0x1ec9, 0x1eca, 0x1ecb, 0x1ecc, 0x1ecd, 0x1ece, 0x1ecf, /* 0x1ec8-0x1ecf */
+ 0x1ed0, 0x1ed1, 0x1ed2, 0x1ed3, 0x1ed4, 0x1ed5, 0x1ed6, 0x1ed7, /* 0x1ed0-0x1ed7 */
+ 0x1ed8, 0x1ed9, 0x1eda, 0x1edb, 0x1edc, 0x1edd, 0x1ede, 0x1edf, /* 0x1ed8-0x1edf */
+ 0x1ee0, 0x1ee1, 0x1ee2, 0x1ee3, 0x1ee4, 0x1ee5, 0x1ee6, 0x1ee7, /* 0x1ee0-0x1ee7 */
+ 0x1ee8, 0x1ee9, 0x1eea, 0x1eeb, 0x1eec, 0x1eed, 0x1eee, 0x1eef, /* 0x1ee8-0x1eef */
+ 0x1ef0, 0x1ef1, 0x0300, 0x0301, 0x1ef4, 0x1ef5, 0x1ef6, 0x1ef7, /* 0x1ef0-0x1ef7 */
+ 0x1ef8, 0x1ef9, 0x01a0, 0x01a1, 0x01af, 0x01b0, 0x0309, 0x0323 /* 0x1ef8-0x1eff */
+};
+
+static unsigned short const keysym_to_unicode_20a0_20ac[] = {
+ 0x20a0, 0x20a1, 0x20a2, 0x20a3, 0x20a4, 0x20a5, 0x20a6, 0x20a7, /* 0x20a0-0x20a7 */
+ 0x20a8, 0x20a9, 0x20aa, 0x20ab, 0x20ac /* 0x20a8-0x20af */
+};
+
+unsigned int
+KeySymToUcs4(KeySym keysym)
+{
+ /* 'Unicode keysym' */
+ if ((keysym & 0xff000000) == 0x01000000)
+ return (keysym & 0x00ffffff);
+
+ if (keysym > 0 && keysym < 0x100)
+ return keysym;
+ else if (keysym > 0x1a0 && keysym < 0x200)
+ return keysym_to_unicode_1a1_1ff[keysym - 0x1a1];
+ else if (keysym > 0x2a0 && keysym < 0x2ff)
+ return keysym_to_unicode_2a1_2fe[keysym - 0x2a1];
+ else if (keysym > 0x3a1 && keysym < 0x3ff)
+ return keysym_to_unicode_3a2_3fe[keysym - 0x3a2];
+ else if (keysym > 0x4a0 && keysym < 0x4e0)
+ return keysym_to_unicode_4a1_4df[keysym - 0x4a1];
+ else if (keysym > 0x589 && keysym < 0x5ff)
+ return keysym_to_unicode_590_5fe[keysym - 0x590];
+ else if (keysym > 0x67f && keysym < 0x700)
+ return keysym_to_unicode_680_6ff[keysym - 0x680];
+ else if (keysym > 0x7a0 && keysym < 0x7fa)
+ return keysym_to_unicode_7a1_7f9[keysym - 0x7a1];
+ else if (keysym > 0x8a3 && keysym < 0x8ff)
+ return keysym_to_unicode_8a4_8fe[keysym - 0x8a4];
+ else if (keysym > 0x9de && keysym < 0x9f9)
+ return keysym_to_unicode_9df_9f8[keysym - 0x9df];
+ else if (keysym > 0xaa0 && keysym < 0xaff)
+ return keysym_to_unicode_aa1_afe[keysym - 0xaa1];
+ else if (keysym > 0xcde && keysym < 0xcfb)
+ return keysym_to_unicode_cdf_cfa[keysym - 0xcdf];
+ else if (keysym > 0xda0 && keysym < 0xdfa)
+ return keysym_to_unicode_da1_df9[keysym - 0xda1];
+ else if (keysym > 0xe9f && keysym < 0xf00)
+ return keysym_to_unicode_ea0_eff[keysym - 0xea0];
+ else if (keysym > 0x12a0 && keysym < 0x12ff)
+ return keysym_to_unicode_12a1_12fe[keysym - 0x12a1];
+ else if (keysym > 0x13bb && keysym < 0x13bf)
+ return keysym_to_unicode_13bc_13be[keysym - 0x13bc];
+ else if (keysym > 0x14a0 && keysym < 0x1500)
+ return keysym_to_unicode_14a1_14ff[keysym - 0x14a1];
+ else if (keysym > 0x15cf && keysym < 0x15f7)
+ return keysym_to_unicode_15d0_15f6[keysym - 0x15d0];
+ else if (keysym > 0x169f && keysym < 0x16f7)
+ return keysym_to_unicode_16a0_16f6[keysym - 0x16a0];
+ else if (keysym > 0x1e9e && keysym < 0x1f00)
+ return keysym_to_unicode_1e9f_1eff[keysym - 0x1e9f];
+ else if (keysym > 0x209f && keysym < 0x20ad)
+ return keysym_to_unicode_20a0_20ac[keysym - 0x20a0];
+ else
+ return 0;
+}
diff --git a/nx-X11/lib/X11/imLcFlt.c b/nx-X11/lib/X11/imLcFlt.c
new file mode 100644
index 000000000..c3c64bf46
--- /dev/null
+++ b/nx-X11/lib/X11/imLcFlt.c
@@ -0,0 +1,93 @@
+/* $Xorg: imLcFlt.c,v 1.3 2000/08/17 19:45:13 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Fuji Xerox Co., Ltd.
+ Copyright 1992, 1994 by FUJITSU LIMITED
+
+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 of Fuji Xerox,
+FUJITSU LIMITED not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission. Fuji Xerox, FUJITSU LIMITED make no representations
+about the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJI XEROX, FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJI XEROX,
+FUJITSU LIMITED 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.
+
+ Author : Kazunori Nishihara Fuji Xerox
+ Modifier : Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include <X11/keysym.h>
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Bool
+_XimLocalFilter(d, w, ev, client_data)
+ Display *d;
+ Window w;
+ XEvent *ev;
+ XPointer client_data;
+{
+ Xic ic = (Xic)client_data;
+ KeySym keysym;
+ static char buf[256];
+ DefTree *p;
+
+ if( (ev->type != KeyPress)
+ || (ev->xkey.keycode == 0)
+ || (((Xim)ic->core.im)->private.local.top == (DefTree *)NULL) )
+ return(False);
+
+ XLookupString((XKeyEvent *)ev, buf, sizeof(buf), &keysym, NULL);
+
+ if(IsModifierKey(keysym))
+ return (False);
+
+ for(p = ic->private.local.context; p; p = p->next) {
+ if(((ev->xkey.state & p->modifier_mask) == p->modifier) &&
+ (keysym == p->keysym)) {
+ break;
+ }
+ }
+
+ if(p) { /* Matched */
+ if(p->succession) { /* Intermediate */
+ ic->private.local.context = p->succession;
+ return(True);
+ } else { /* Terminate (reached to leaf) */
+ ic->private.local.composed = p;
+ /* return back to client KeyPressEvent keycode == 0 */
+ ev->xkey.keycode = 0;
+ _XPutBackEvent(d, ev);
+ /* initialize internal state for next key sequence */
+ ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
+ return(True);
+ }
+ } else { /* Unmatched */
+ if(ic->private.local.context == ((Xim)ic->core.im)->private.local.top) {
+ return(False);
+ }
+ /* Error (Sequence Unmatch occured) */
+ /* initialize internal state for next key sequence */
+ ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
+ return(True);
+ }
+}
diff --git a/nx-X11/lib/X11/imLcGIc.c b/nx-X11/lib/X11/imLcGIc.c
new file mode 100644
index 000000000..e4f89a0f5
--- /dev/null
+++ b/nx-X11/lib/X11/imLcGIc.c
@@ -0,0 +1,51 @@
+/* $Xorg: imLcGIc.c,v 1.3 2000/08/17 19:45:13 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992,1993, 1994 by FUJITSU LIMITED
+
+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 of FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Public char *
+_XimLocalGetICValues(xic, values)
+ XIC xic;
+ XIMArg *values;
+{
+ Xic ic = (Xic)xic;
+ XimDefICValues ic_values;
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ return(_XimGetICValueData(ic, (XPointer)&ic_values,
+ ic->private.local.ic_resources,
+ ic->private.local.ic_num_resources,
+ values, XIM_GETICVALUES));
+}
diff --git a/nx-X11/lib/X11/imLcIc.c b/nx-X11/lib/X11/imLcIc.c
new file mode 100644
index 000000000..760e24c5f
--- /dev/null
+++ b/nx-X11/lib/X11/imLcIc.c
@@ -0,0 +1,195 @@
+/* $Xorg: imLcIc.c,v 1.3 2000/08/17 19:45:13 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992,1993, 1994 by FUJITSU LIMITED
+
+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 of FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imLcIc.c,v 1.4 2001/01/17 19:41:52 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Private void
+_XimLocalUnSetFocus(
+ XIC xic)
+{
+ Xic ic = (Xic)xic;
+ ((Xim)ic->core.im)->private.local.current_ic = (XIC)NULL;
+
+ if (ic->core.focus_window)
+ _XUnregisterFilter(ic->core.im->core.display,
+ ic->core.focus_window, _XimLocalFilter, (XPointer)ic);
+ return;
+}
+
+Private void
+_XimLocalDestroyIC(
+ XIC xic)
+{
+ Xic ic = (Xic)xic;
+
+ if(((Xim)ic->core.im)->private.local.current_ic == (XIC)ic) {
+ ((Xim)ic->core.im)->private.local.current_ic = (XIC)NULL;
+ }
+ if (ic->core.focus_window)
+ _XUnregisterFilter(ic->core.im->core.display,
+ ic->core.focus_window, _XimLocalFilter, (XPointer)ic);
+ if(ic->private.local.ic_resources) {
+ Xfree(ic->private.local.ic_resources);
+ ic->private.local.ic_resources = NULL;
+ }
+ return;
+}
+
+Private void
+_XimLocalSetFocus(
+ XIC xic)
+{
+ Xic ic = (Xic)xic;
+ XIC current_ic = ((Xim)ic->core.im)->private.local.current_ic;
+
+ if (current_ic == (XIC)ic)
+ return;
+
+ if (current_ic != (XIC)NULL) {
+ _XimLocalUnSetFocus(current_ic);
+ }
+ ((Xim)ic->core.im)->private.local.current_ic = (XIC)ic;
+
+ if (ic->core.focus_window)
+ _XRegisterFilterByType(ic->core.im->core.display,
+ ic->core.focus_window, KeyPress, KeyPress,
+ _XimLocalFilter, (XPointer)ic);
+ return;
+}
+
+Private void
+_XimLocalReset(
+ XIC xic)
+{
+ Xic ic = (Xic)xic;
+ ic->private.local.composed = (DefTree *)NULL;
+ ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
+}
+
+Private char *
+_XimLocalMbReset(
+ XIC xic)
+{
+ _XimLocalReset(xic);
+ return (char *)NULL;
+}
+
+Private wchar_t *
+_XimLocalWcReset(
+ XIC xic)
+{
+ _XimLocalReset(xic);
+ return (wchar_t *)NULL;
+}
+
+Private XICMethodsRec Local_ic_methods = {
+ _XimLocalDestroyIC, /* destroy */
+ _XimLocalSetFocus, /* set_focus */
+ _XimLocalUnSetFocus, /* unset_focus */
+ _XimLocalSetICValues, /* set_values */
+ _XimLocalGetICValues, /* get_values */
+ _XimLocalMbReset, /* mb_reset */
+ _XimLocalWcReset, /* wc_reset */
+ _XimLocalMbReset, /* utf8_reset */
+ _XimLocalMbLookupString, /* mb_lookup_string */
+ _XimLocalWcLookupString, /* wc_lookup_string */
+ _XimLocalUtf8LookupString /* utf8_lookup_string */
+};
+
+Public XIC
+_XimLocalCreateIC(
+ XIM im,
+ XIMArg *values)
+{
+ Xic ic;
+ XimDefICValues ic_values;
+ XIMResourceList res;
+ unsigned int num;
+ int len;
+
+ if((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL) {
+ return ((XIC)NULL);
+ }
+ bzero((char *)ic, sizeof(XicRec));
+
+ ic->methods = &Local_ic_methods;
+ ic->core.im = im;
+ ic->private.local.context = ((Xim)im)->private.local.top;
+ ic->private.local.composed = (DefTree *)NULL;
+
+ num = im->core.ic_num_resources;
+ len = sizeof(XIMResource) * num;
+ if((res = (XIMResourceList)Xmalloc(len)) == (XIMResourceList)NULL) {
+ goto Set_Error;
+ }
+ (void)memcpy((char *)res, (char *)im->core.ic_resources, len);
+ ic->private.local.ic_resources = res;
+ ic->private.local.ic_num_resources = num;
+
+ bzero((char *)&ic_values, sizeof(XimDefICValues));
+ if(_XimCheckLocalInputStyle(ic, (XPointer)&ic_values, values,
+ im->core.styles, res, num) == False) {
+ goto Set_Error;
+ }
+
+ _XimSetICMode(res, num, ic_values.input_style);
+
+ if(_XimSetICValueData(ic, (XPointer)&ic_values,
+ ic->private.local.ic_resources,
+ ic->private.local.ic_num_resources,
+ values, XIM_CREATEIC, True)) {
+ goto Set_Error;
+ }
+ ic_values.filter_events = KeyPressMask;
+ _XimSetCurrentICValues(ic, &ic_values);
+ if(_XimSetICDefaults(ic, (XPointer)&ic_values,
+ XIM_SETICDEFAULTS, res, num) == False) {
+ goto Set_Error;
+ }
+ _XimSetCurrentICValues(ic, &ic_values);
+
+ return((XIC)ic);
+
+Set_Error :
+ if (ic->private.local.ic_resources) {
+ Xfree(ic->private.local.ic_resources);
+ ic->private.local.ic_resources = NULL;
+ }
+ Xfree(ic);
+ return((XIC)NULL);
+}
diff --git a/nx-X11/lib/X11/imLcIm.c b/nx-X11/lib/X11/imLcIm.c
new file mode 100644
index 000000000..675b48224
--- /dev/null
+++ b/nx-X11/lib/X11/imLcIm.c
@@ -0,0 +1,340 @@
+/* $Xorg: imLcIm.c,v 1.3 2000/08/17 19:45:14 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993 by Digital Equipment 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 of FUJITSU LIMITED and
+Digital Equipment Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission. FUJITSU LIMITED and Digital Equipment Corporation
+makes no representations about the suitability of this software for
+any purpose. It is provided "as is" without express or implied
+warranty.
+
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Franky Ling Digital Equipment Corporation
+ frankyling@hgrd01.enet.dec.com
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imLcIm.c,v 1.12 2003/09/06 14:06:32 pascal Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+/*
+#include <X11/Xlib.h>
+*/
+#include <X11/Xmd.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcPublic.h"
+#include "XlcPubI.h"
+#include "Ximint.h"
+#include <ctype.h>
+
+Public Bool
+_XimCheckIfLocalProcessing(im)
+ Xim im;
+{
+ FILE *fp;
+ char *name;
+
+ if(strcmp(im->core.im_name, "") == 0) {
+ name = _XlcFileName(im->core.lcd, COMPOSE_FILE);
+ if (name != (char *)NULL) {
+ fp = _XFopenFile (name, "r");
+ Xfree(name);
+ if (fp != (FILE *)NULL) {
+ fclose(fp);
+ return(True);
+ }
+ }
+ return(False);
+ } else if(strcmp(im->core.im_name, "local") == 0 ||
+ strcmp(im->core.im_name, "none" ) == 0 ) {
+ return(True);
+ }
+ return(False);
+}
+
+Private void
+XimFreeDefaultTree(
+ DefTree *top)
+{
+ if (!top) return;
+ if (top->succession) XimFreeDefaultTree(top->succession);
+ if (top->next) XimFreeDefaultTree(top->next);
+ if (top->mb) Xfree(top->mb);
+ if (top->wc) Xfree(top->wc);
+ if (top->utf8) Xfree(top->utf8);
+ Xfree(top);
+}
+
+Public void
+_XimLocalIMFree(
+ Xim im)
+{
+ XimFreeDefaultTree(im->private.local.top);
+ im->private.local.top = NULL;
+
+ if(im->core.im_resources) {
+ Xfree(im->core.im_resources);
+ im->core.im_resources = NULL;
+ }
+ if(im->core.ic_resources) {
+ Xfree(im->core.ic_resources);
+ im->core.ic_resources = NULL;
+ }
+ if(im->core.im_values_list) {
+ Xfree(im->core.im_values_list);
+ im->core.im_values_list = NULL;
+ }
+ if(im->core.ic_values_list) {
+ Xfree(im->core.ic_values_list);
+ im->core.ic_values_list = NULL;
+ }
+ if(im->core.styles) {
+ Xfree(im->core.styles);
+ im->core.styles = NULL;
+ }
+ if(im->core.res_name) {
+ Xfree(im->core.res_name);
+ im->core.res_name = NULL;
+ }
+ if(im->core.res_class) {
+ Xfree(im->core.res_class);
+ im->core.res_class = NULL;
+ }
+ if(im->core.im_name) {
+ Xfree(im->core.im_name);
+ im->core.im_name = NULL;
+ }
+ if (im->private.local.ctom_conv) {
+ _XlcCloseConverter(im->private.local.ctom_conv);
+ im->private.local.ctom_conv = NULL;
+ }
+ if (im->private.local.ctow_conv) {
+ _XlcCloseConverter(im->private.local.ctow_conv);
+ im->private.local.ctow_conv = NULL;
+ }
+ if (im->private.local.ctoutf8_conv) {
+ _XlcCloseConverter(im->private.local.ctoutf8_conv);
+ im->private.local.ctoutf8_conv = NULL;
+ }
+ if (im->private.local.cstomb_conv) {
+ _XlcCloseConverter(im->private.local.cstomb_conv);
+ im->private.local.cstomb_conv = NULL;
+ }
+ if (im->private.local.cstowc_conv) {
+ _XlcCloseConverter(im->private.local.cstowc_conv);
+ im->private.local.cstowc_conv = NULL;
+ }
+ if (im->private.local.cstoutf8_conv) {
+ _XlcCloseConverter(im->private.local.cstoutf8_conv);
+ im->private.local.cstoutf8_conv = NULL;
+ }
+ if (im->private.local.ucstoc_conv) {
+ _XlcCloseConverter(im->private.local.ucstoc_conv);
+ im->private.local.ucstoc_conv = NULL;
+ }
+ if (im->private.local.ucstoutf8_conv) {
+ _XlcCloseConverter(im->private.local.ucstoutf8_conv);
+ im->private.local.ucstoutf8_conv = NULL;
+ }
+ return;
+}
+
+Private Status
+_XimLocalCloseIM(
+ XIM xim)
+{
+ Xim im = (Xim)xim;
+ XIC ic;
+ XIC next;
+
+ ic = im->core.ic_chain;
+ im->core.ic_chain = NULL;
+ while (ic) {
+ (*ic->methods->destroy) (ic);
+ next = ic->core.next;
+ Xfree ((char *) ic);
+ ic = next;
+ }
+ _XimLocalIMFree(im);
+ _XimDestroyIMStructureList(im);
+ return(True);
+}
+
+Public char *
+_XimLocalGetIMValues(
+ XIM xim,
+ XIMArg *values)
+{
+ Xim im = (Xim)xim;
+ XimDefIMValues im_values;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ return(_XimGetIMValueData(im, (XPointer)&im_values, values,
+ im->core.im_resources, im->core.im_num_resources));
+}
+
+Public char *
+_XimLocalSetIMValues(
+ XIM xim,
+ XIMArg *values)
+{
+ Xim im = (Xim)xim;
+ XimDefIMValues im_values;
+ char *name = (char *)NULL;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ name = _XimSetIMValueData(im, (XPointer)&im_values, values,
+ im->core.im_resources, im->core.im_num_resources);
+ _XimSetCurrentIMValues(im, &im_values);
+ return(name);
+}
+
+Private void
+_XimCreateDefaultTree(
+ Xim im)
+{
+ FILE *fp = NULL;
+ char *name, *tmpname = NULL;
+
+ name = getenv("XCOMPOSEFILE");
+
+ if (name == (char *) NULL) {
+ char *home = getenv("HOME");
+ if (home != (char *) NULL) {
+ int hl = strlen(home);
+ tmpname = name = Xmalloc(hl + 10 + 1);
+ if (name != (char *) NULL) {
+ strcpy(name, home);
+ strcpy(name + hl, "/.XCompose");
+ fp = _XFopenFile (name, "r");
+ if (fp == (FILE *) NULL) {
+ Xfree(name);
+ name = tmpname = NULL;
+ }
+ }
+ }
+ }
+
+ if (name == (char *) NULL) {
+ tmpname = name = _XlcFileName(im->core.lcd, COMPOSE_FILE);
+ }
+
+ if (name == (char *) NULL)
+ return;
+ if (fp == (FILE *) NULL) {
+ fp = _XFopenFile (name, "r");
+ }
+ if (tmpname != (char *) NULL) {
+ Xfree(tmpname);
+ }
+ if (fp == (FILE *) NULL)
+ return;
+ _XimParseStringFile(fp, im);
+ fclose(fp);
+}
+
+Private XIMMethodsRec Xim_im_local_methods = {
+ _XimLocalCloseIM, /* close */
+ _XimLocalSetIMValues, /* set_values */
+ _XimLocalGetIMValues, /* get_values */
+ _XimLocalCreateIC, /* create_ic */
+ _XimLcctstombs, /* ctstombs */
+ _XimLcctstowcs, /* ctstowcs */
+ _XimLcctstoutf8 /* ctstoutf8 */
+};
+
+Public Bool
+_XimLocalOpenIM(
+ Xim im)
+{
+ XLCd lcd = im->core.lcd;
+ XlcConv conv;
+ XimDefIMValues im_values;
+ XimLocalPrivateRec* private = &im->private.local;
+
+ _XimInitialResourceInfo();
+ if(_XimSetIMResourceList(&im->core.im_resources,
+ &im->core.im_num_resources) == False) {
+ goto Open_Error;
+ }
+ if(_XimSetICResourceList(&im->core.ic_resources,
+ &im->core.ic_num_resources) == False) {
+ goto Open_Error;
+ }
+
+ _XimSetIMMode(im->core.im_resources, im->core.im_num_resources);
+
+ _XimGetCurrentIMValues(im, &im_values);
+ if(_XimSetLocalIMDefaults(im, (XPointer)&im_values,
+ im->core.im_resources, im->core.im_num_resources) == False) {
+ goto Open_Error;
+ }
+ _XimSetCurrentIMValues(im, &im_values);
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte)))
+ goto Open_Error;
+ private->ctom_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar)))
+ goto Open_Error;
+ private->ctow_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNUtf8String)))
+ goto Open_Error;
+ private->ctoutf8_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte)))
+ goto Open_Error;
+ private->cstomb_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNWideChar)))
+ goto Open_Error;
+ private->cstowc_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNUtf8String)))
+ goto Open_Error;
+ private->cstoutf8_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNChar)))
+ goto Open_Error;
+ private->ucstoc_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNUtf8String)))
+ goto Open_Error;
+ private->ucstoutf8_conv = conv;
+
+ _XimCreateDefaultTree(im);
+
+ im->methods = &Xim_im_local_methods;
+ private->current_ic = (XIC)NULL;
+
+ return(True);
+
+Open_Error :
+ _XimLocalIMFree(im);
+ return(False);
+}
diff --git a/nx-X11/lib/X11/imLcLkup.c b/nx-X11/lib/X11/imLcLkup.c
new file mode 100644
index 000000000..59025a529
--- /dev/null
+++ b/nx-X11/lib/X11/imLcLkup.c
@@ -0,0 +1,383 @@
+/* $Xorg: imLcLkup.c,v 1.3 2000/08/17 19:45:14 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Fuji Xerox Co., Ltd.
+ Copyright 1992, 1994 by FUJITSU LIMITED
+
+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 of Fuji Xerox,
+FUJITSU LIMITED not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission. Fuji Xerox, FUJITSU LIMITED make no representations
+about the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJI XEROX, FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJI XEROX,
+FUJITSU LIMITED 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.
+
+ Author: Kazunori Nishihara Fuji Xerox
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imLcLkup.c,v 3.8 2003/06/23 17:35:43 eich Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#include <X11/Xutil.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Public int
+_XimLocalMbLookupString(xic, ev, buffer, bytes, keysym, status)
+ XIC xic;
+ XKeyEvent *ev;
+ char *buffer;
+ int bytes;
+ KeySym *keysym;
+ Status *status;
+{
+ Xic ic = (Xic)xic;
+ int ret;
+
+ if(ev->type != KeyPress) {
+ if(status) *status = XLookupNone;
+ return(0);
+ }
+ if(ev->keycode == 0 && ic->private.local.composed != NULL) { /* Composed Event */
+ ret = strlen(ic->private.local.composed->mb);
+ if(ret > bytes) {
+ if(status) *status = XBufferOverflow;
+ return(ret);
+ }
+ memcpy(buffer, ic->private.local.composed->mb, ret);
+ if(keysym) *keysym = ic->private.local.composed->ks;
+ if (ret > 0) {
+ if (keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupBoth;
+ } else {
+ if(status) *status = XLookupChars;
+ }
+ } else {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupKeySym;
+ } else {
+ if(status) *status = XLookupNone;
+ }
+ }
+ return (ret);
+ } else { /* Throughed Event */
+ ret = _XimLookupMBText(ic, ev, buffer, bytes, keysym, NULL);
+ if(ret > 0) {
+ if (ret > bytes) {
+ if (status) *status = XBufferOverflow;
+ } else if (keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupBoth;
+ } else {
+ if(status) *status = XLookupChars;
+ }
+ } else {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupKeySym;
+ } else {
+ if(status) *status = XLookupNone;
+ }
+ }
+ }
+ return (ret);
+}
+
+Public int
+_XimLocalWcLookupString(xic, ev, buffer, wlen, keysym, status)
+ XIC xic;
+ XKeyEvent *ev;
+ wchar_t *buffer;
+ int wlen;
+ KeySym *keysym;
+ Status *status;
+{
+ Xic ic = (Xic)xic;
+ int ret;
+
+ if(ev->type != KeyPress) {
+ if(status) *status = XLookupNone;
+ return(0);
+ }
+ if(ev->keycode == 0) { /* Composed Event */
+ ret = _Xwcslen(ic->private.local.composed->wc);
+ if(ret > wlen) {
+ if(status) *status = XBufferOverflow;
+ return (ret);
+ }
+ memcpy((char *)buffer, (char *)ic->private.local.composed->wc,
+ ret * sizeof(wchar_t));
+ if(keysym) *keysym = ic->private.local.composed->ks;
+ if (ret > 0) {
+ if (keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupBoth;
+ } else {
+ if(status) *status = XLookupChars;
+ }
+ } else {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupKeySym;
+ } else {
+ if(status) *status = XLookupNone;
+ }
+ }
+ return (ret);
+ } else { /* Throughed Event */
+ ret = _XimLookupWCText(ic, ev, buffer, wlen, keysym, NULL);
+ if(ret > 0) {
+ if (ret > wlen) {
+ if (status) *status = XBufferOverflow;
+ } else if (keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupBoth;
+ } else {
+ if(status) *status = XLookupChars;
+ }
+ } else {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupKeySym;
+ } else {
+ if(status) *status = XLookupNone;
+ }
+ }
+ }
+ return (ret);
+}
+
+Public int
+_XimLocalUtf8LookupString(xic, ev, buffer, bytes, keysym, status)
+ XIC xic;
+ XKeyEvent *ev;
+ char *buffer;
+ int bytes;
+ KeySym *keysym;
+ Status *status;
+{
+ Xic ic = (Xic)xic;
+ int ret;
+
+ if(ev->type != KeyPress) {
+ if(status) *status = XLookupNone;
+ return(0);
+ }
+ if(ev->keycode == 0) { /* Composed Event */
+ ret = strlen(ic->private.local.composed->utf8);
+ if(ret > bytes) {
+ if(status) *status = XBufferOverflow;
+ return (ret);
+ }
+ memcpy(buffer, ic->private.local.composed->utf8, ret);
+ if(keysym) *keysym = ic->private.local.composed->ks;
+ if (ret > 0) {
+ if (keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupBoth;
+ } else {
+ if(status) *status = XLookupChars;
+ }
+ } else {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupKeySym;
+ } else {
+ if(status) *status = XLookupNone;
+ }
+ }
+ return (ret);
+ } else { /* Throughed Event */
+ ret = _XimLookupUTF8Text(ic, ev, buffer, bytes, keysym, NULL);
+ if(ret > 0) {
+ if (ret > bytes) {
+ if (status) *status = XBufferOverflow;
+ } else if (keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupBoth;
+ } else {
+ if(status) *status = XLookupChars;
+ }
+ } else {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupKeySym;
+ } else {
+ if(status) *status = XLookupNone;
+ }
+ }
+ }
+ return (ret);
+}
+
+Private int
+_XimLcctsconvert(
+ XlcConv conv,
+ char *from,
+ int from_len,
+ char *to,
+ int to_len,
+ Status *state)
+{
+ int from_left;
+ int to_left;
+ int from_savelen;
+ int to_savelen;
+ int from_cnvlen;
+ int to_cnvlen;
+ char *from_buf;
+ char *to_buf;
+ char scratchbuf[BUFSIZ];
+ Status tmp_state;
+
+ if (!state)
+ state = &tmp_state;
+
+ if (!conv || !from || !from_len) {
+ *state = XLookupNone;
+ return 0;
+ }
+
+ /* Reset the converter. The CompoundText at 'from' starts in
+ initial state. */
+ _XlcResetConverter(conv);
+
+ from_left = from_len;
+ to_left = BUFSIZ;
+ from_cnvlen = 0;
+ to_cnvlen = 0;
+ for (;;) {
+ from_buf = &from[from_cnvlen];
+ from_savelen = from_left;
+ to_buf = &scratchbuf[to_cnvlen];
+ to_savelen = to_left;
+ if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
+ (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
+ *state = XLookupNone;
+ return 0;
+ }
+ from_cnvlen += (from_savelen - from_left);
+ to_cnvlen += (to_savelen - to_left);
+ if (from_left == 0) {
+ if (!to_cnvlen) {
+ *state = XLookupNone;
+ return 0;
+ }
+ break;
+ }
+ }
+
+ if (!to || !to_len || (to_len < to_cnvlen)) {
+ *state = XBufferOverflow;
+ } else {
+ memcpy(to, scratchbuf, to_cnvlen);
+ *state = XLookupChars;
+ }
+ return to_cnvlen;
+}
+
+Public int
+_XimLcctstombs(xim, from, from_len, to, to_len, state)
+ XIM xim;
+ char *from;
+ int from_len;
+ char *to;
+ int to_len;
+ Status *state;
+{
+ return _XimLcctsconvert(((Xim)xim)->private.local.ctom_conv,
+ from, from_len, to, to_len, state);
+}
+
+Public int
+_XimLcctstowcs(xim, from, from_len, to, to_len, state)
+ XIM xim;
+ char *from;
+ int from_len;
+ wchar_t *to;
+ int to_len;
+ Status *state;
+{
+ Xim im = (Xim)xim;
+ XlcConv conv = im->private.local.ctow_conv;
+ int from_left;
+ int to_left;
+ int from_savelen;
+ int to_savelen;
+ int from_cnvlen;
+ int to_cnvlen;
+ char *from_buf;
+ wchar_t *to_buf;
+ wchar_t scratchbuf[BUFSIZ];
+ Status tmp_state;
+
+ if (!state)
+ state = &tmp_state;
+
+ if (!conv || !from || !from_len) {
+ *state = XLookupNone;
+ return 0;
+ }
+
+ /* Reset the converter. The CompoundText at 'from' starts in
+ initial state. */
+ _XlcResetConverter(conv);
+
+ from_left = from_len;
+ to_left = BUFSIZ;
+ from_cnvlen = 0;
+ to_cnvlen = 0;
+ for (;;) {
+ from_buf = &from[from_cnvlen];
+ from_savelen = from_left;
+ to_buf = &scratchbuf[to_cnvlen];
+ to_savelen = to_left;
+ if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
+ (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
+ *state = XLookupNone;
+ return 0;
+ }
+ from_cnvlen += (from_savelen - from_left);
+ to_cnvlen += (to_savelen - to_left);
+ if (from_left == 0) {
+ if (!to_cnvlen){
+ *state = XLookupNone;
+ return 0;
+ }
+ break;
+ }
+ }
+
+ if (!to || !to_len || (to_len < to_cnvlen)) {
+ *state = XBufferOverflow;
+ } else {
+ memcpy(to, scratchbuf, to_cnvlen * sizeof(wchar_t));
+ *state = XLookupChars;
+ }
+ return to_cnvlen;
+}
+
+Public int
+_XimLcctstoutf8(xim, from, from_len, to, to_len, state)
+ XIM xim;
+ char *from;
+ int from_len;
+ char *to;
+ int to_len;
+ Status *state;
+{
+ return _XimLcctsconvert(((Xim)xim)->private.local.ctoutf8_conv,
+ from, from_len, to, to_len, state);
+}
diff --git a/nx-X11/lib/X11/imLcPrs.c b/nx-X11/lib/X11/imLcPrs.c
new file mode 100644
index 000000000..fbad5a220
--- /dev/null
+++ b/nx-X11/lib/X11/imLcPrs.c
@@ -0,0 +1,667 @@
+/* $Xorg: imLcPrs.c,v 1.3 2000/08/17 19:45:14 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Oki Technosystems Laboratory, Inc.
+ Copyright 1992 by Fuji Xerox Co., Ltd.
+
+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 of Oki Technosystems
+Laboratory and Fuji Xerox not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission.
+Oki Technosystems Laboratory and Fuji Xerox make no representations
+about the suitability of this software for any purpose. It is provided
+"as is" without express or implied warranty.
+
+OKI TECHNOSYSTEMS LABORATORY AND FUJI XEROX DISCLAIM ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL OKI TECHNOSYSTEMS
+LABORATORY AND FUJI XEROX 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.
+
+ Author: Yasuhiro Kawai Oki Technosystems Laboratory
+ Author: Kazunori Nishihara Fuji Xerox
+
+******************************************************************/
+
+/* $XFree86: xc/lib/X11/imLcPrs.c,v 1.10 2003/09/06 14:06:32 pascal Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include <sys/stat.h>
+#include <stdio.h>
+
+extern int _Xmbstowcs(
+ wchar_t *wstr,
+ char *str,
+ int len
+);
+
+extern int _Xmbstoutf8(
+ char *ustr,
+ const char *str,
+ int len
+);
+
+/*
+ * Parsing File Format:
+ *
+ * FILE ::= { [PRODUCTION] [COMMENT] "\n"}
+ * PRODUCTION ::= LHS ":" RHS [ COMMENT ]
+ * COMMENT ::= "#" {<any character except null or newline>}
+ * LHS ::= EVENT { EVENT }
+ * EVENT ::= [MODIFIER_LIST] "<" keysym ">"
+ * MODIFIER_LIST ::= ("!" {MODIFIER} ) | "None"
+ * MODIFIER ::= ["~"] modifier_name
+ * RHS ::= ( STRING | keysym | STRING keysym )
+ * STRING ::= '"' { CHAR } '"'
+ * CHAR ::= GRAPHIC_CHAR | ESCAPED_CHAR
+ * GRAPHIC_CHAR ::= locale (codeset) dependent code
+ * ESCAPED_CHAR ::= ('\\' | '\"' | OCTAL | HEX )
+ * OCTAL ::= '\' OCTAL_CHAR [OCTAL_CHAR [OCTAL_CHAR]]
+ * OCTAL_CHAR ::= (0|1|2|3|4|5|6|7)
+ * HEX ::= '\' (x|X) HEX_CHAR [HEX_CHAR]]
+ * HEX_CHAR ::= (0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|a|b|c|d|e|f)
+ *
+ */
+
+static int
+nextch(
+ FILE *fp,
+ int *lastch)
+{
+ int c;
+
+ if (*lastch != 0) {
+ c = *lastch;
+ *lastch = 0;
+ } else {
+ c = getc(fp);
+ if (c == '\\') {
+ c = getc(fp);
+ if (c == '\n') {
+ c = getc(fp);
+ } else {
+ ungetc(c, fp);
+ c = '\\';
+ }
+ }
+ }
+ return(c);
+}
+
+static void
+putbackch(
+ int c,
+ int *lastch)
+{
+ *lastch = c;
+}
+
+#define ENDOFFILE 0
+#define ENDOFLINE 1
+#define COLON 2
+#define LESS 3
+#define GREATER 4
+#define EXCLAM 5
+#define TILDE 6
+#define STRING 7
+#define KEY 8
+#define ERROR 9
+
+#ifndef isalnum
+#define isalnum(c) \
+ (('0' <= (c) && (c) <= '9') || \
+ ('A' <= (c) && (c) <= 'Z') || \
+ ('a' <= (c) && (c) <= 'z'))
+#endif
+
+static int
+nexttoken(
+ FILE *fp,
+ char *tokenbuf,
+ int *lastch)
+{
+ int c;
+ int token;
+ char *p;
+ int i, j;
+
+ while ((c = nextch(fp, lastch)) == ' ' || c == '\t') {
+ }
+ switch (c) {
+ case EOF:
+ token = ENDOFFILE;
+ break;
+ case '\n':
+ token = ENDOFLINE;
+ break;
+ case '<':
+ token = LESS;
+ break;
+ case '>':
+ token = GREATER;
+ break;
+ case ':':
+ token = COLON;
+ break;
+ case '!':
+ token = EXCLAM;
+ break;
+ case '~':
+ token = TILDE;
+ break;
+ case '"':
+ p = tokenbuf;
+ while ((c = nextch(fp, lastch)) != '"') {
+ if (c == '\n' || c == EOF) {
+ putbackch(c, lastch);
+ token = ERROR;
+ goto string_error;
+ } else if (c == '\\') {
+ c = nextch(fp, lastch);
+ switch (c) {
+ case '\\':
+ case '"':
+ *p++ = c;
+ break;
+ case 'n':
+ *p++ = '\n';
+ break;
+ case 'r':
+ *p++ = '\r';
+ break;
+ case 't':
+ *p++ = '\t';
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ i = c - '0';
+ c = nextch(fp, lastch);
+ for (j = 0; j < 2 && c >= '0' && c <= '7'; j++) {
+ i <<= 3;
+ i += c - '0';
+ c = nextch(fp, lastch);
+ }
+ putbackch(c, lastch);
+ *p++ = (char)i;
+ break;
+ case 'X':
+ case 'x':
+ i = 0;
+ for (j = 0; j < 2; j++) {
+ c = nextch(fp, lastch);
+ i <<= 4;
+ if (c >= '0' && c <= '9') {
+ i += c - '0';
+ } else if (c >= 'A' && c <= 'F') {
+ i += c - 'A' + 10;
+ } else if (c >= 'a' && c <= 'f') {
+ i += c - 'a' + 10;
+ } else {
+ putbackch(c, lastch);
+ i >>= 4;
+ break;
+ }
+ }
+ if (j == 0) {
+ token = ERROR;
+ goto string_error;
+ }
+ *p++ = (char)i;
+ break;
+ case EOF:
+ putbackch(c, lastch);
+ token = ERROR;
+ goto string_error;
+ default:
+ *p++ = c;
+ break;
+ }
+ } else {
+ *p++ = c;
+ }
+ }
+ *p = '\0';
+ token = STRING;
+ break;
+ case '#':
+ while ((c = nextch(fp, lastch)) != '\n' && c != EOF) {
+ }
+ if (c == '\n') {
+ token = ENDOFLINE;
+ } else {
+ token = ENDOFFILE;
+ }
+ break;
+ default:
+ if (isalnum(c) || c == '_' || c == '-') {
+ p = tokenbuf;
+ *p++ = c;
+ c = nextch(fp, lastch);
+ while (isalnum(c) || c == '_' || c == '-') {
+ *p++ = c;
+ c = nextch(fp, lastch);
+ }
+ *p = '\0';
+ putbackch(c, lastch);
+ token = KEY;
+ } else {
+ token = ERROR;
+ }
+ break;
+ }
+string_error:
+ return(token);
+}
+
+static long
+modmask(
+ char *name)
+{
+ long mask;
+
+ struct _modtbl {
+ char *name;
+ long mask;
+ };
+ struct _modtbl *p;
+
+ static struct _modtbl tbl[] = {
+ { "Ctrl", ControlMask },
+ { "Lock", LockMask },
+ { "Caps", LockMask },
+ { "Shift", ShiftMask },
+ { "Alt", Mod1Mask },
+ { "Meta", Mod1Mask },
+ { NULL, 0 }};
+
+ p = tbl;
+ mask = 0;
+ for (p = tbl; p->name != NULL; p++) {
+ if (strcmp(name, p->name) == 0) {
+ mask = p->mask;
+ break;
+ }
+ }
+ return(mask);
+}
+
+static char*
+TransFileName(Xim im, char *name)
+{
+ char *home = NULL, *lcCompose = NULL;
+ char *i = name, *ret, *j;
+ int l = 0;
+
+ while (*i) {
+ if (*i == '%') {
+ i++;
+ switch (*i) {
+ case '%':
+ l++;
+ break;
+ case 'H':
+ home = getenv("HOME");
+ if (home)
+ l += strlen(home);
+ break;
+ case 'L':
+ lcCompose = _XlcFileName(im->core.lcd, COMPOSE_FILE);
+ if (lcCompose)
+ l += strlen(lcCompose);
+ break;
+ }
+ } else {
+ l++;
+ }
+ i++;
+ }
+
+ j = ret = Xmalloc(l+1);
+ if (ret == NULL)
+ return ret;
+ i = name;
+ while (*i) {
+ if (*i == '%') {
+ i++;
+ switch (*i) {
+ case '%':
+ *j++ = '%';
+ break;
+ case 'H':
+ if (home) {
+ strcpy(j, home);
+ j += strlen(home);
+ }
+ break;
+ case 'L':
+ if (lcCompose) {
+ strcpy(j, lcCompose);
+ j += strlen(lcCompose);
+ Xfree(lcCompose);
+ }
+ break;
+ }
+ i++;
+ } else {
+ *j++ = *i++;
+ }
+ }
+ *j = '\0';
+ return ret;
+}
+
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 6
+#endif
+
+static int
+get_mb_string (Xim im, char *buf, KeySym ks)
+{
+ XPointer from, to;
+ int from_len, to_len, len;
+ XPointer args[1];
+ XlcCharSet charset;
+ char local_buf[MB_LEN_MAX];
+ unsigned int ucs;
+ ucs = KeySymToUcs4(ks);
+
+ from = (XPointer) &ucs;
+ to = (XPointer) local_buf;
+ from_len = 1;
+ to_len = MB_LEN_MAX;
+ args[0] = (XPointer) &charset;
+ if (_XlcConvert(im->private.local.ucstoc_conv,
+ &from, &from_len, &to, &to_len, args, 1 ) != 0) {
+ return 0;
+ }
+
+ from = (XPointer) local_buf;
+ to = (XPointer) buf;
+ from_len = MB_LEN_MAX - to_len;
+ to_len = MB_LEN_MAX + 1;
+ args[0] = (XPointer) charset;
+ if (_XlcConvert(im->private.local.cstomb_conv,
+ &from, &from_len, &to, &to_len, args, 1 ) != 0) {
+ return 0;
+ }
+ len = MB_LEN_MAX + 1 - to_len;
+ buf[len] = '\0';
+ return len;
+}
+
+#define AllMask (ShiftMask | LockMask | ControlMask | Mod1Mask)
+#define LOCAL_WC_BUFSIZE 128
+#define LOCAL_UTF8_BUFSIZE 256
+#define SEQUENCE_MAX 10
+
+static int
+parseline(
+ FILE *fp,
+ Xim im,
+ char* tokenbuf)
+{
+ int token;
+ unsigned modifier_mask;
+ unsigned modifier;
+ unsigned tmp;
+ KeySym keysym = NoSymbol;
+ DefTree **top = &im->private.local.top;
+ DefTree *p = NULL;
+ Bool exclam, tilde;
+ KeySym rhs_keysym = 0;
+ char *rhs_string_mb;
+ int l;
+ int lastch = 0;
+ char local_mb_buf[MB_LEN_MAX+1];
+ wchar_t local_wc_buf[LOCAL_WC_BUFSIZE], *rhs_string_wc;
+ char local_utf8_buf[LOCAL_UTF8_BUFSIZE], *rhs_string_utf8;
+
+ struct DefBuffer {
+ unsigned modifier_mask;
+ unsigned modifier;
+ KeySym keysym;
+ };
+
+ struct DefBuffer buf[SEQUENCE_MAX];
+ int i, n;
+
+ do {
+ token = nexttoken(fp, tokenbuf, &lastch);
+ } while (token == ENDOFLINE);
+
+ if (token == ENDOFFILE) {
+ return(-1);
+ }
+
+ n = 0;
+ do {
+ if ((token == KEY) && (strcmp("include", tokenbuf) == 0)) {
+ char *filename;
+ FILE *infp;
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token != KEY && token != STRING)
+ goto error;
+ if ((filename = TransFileName(im, tokenbuf)) == NULL)
+ goto error;
+ infp = _XFopenFile(filename, "r");
+ Xfree(filename);
+ if (infp == NULL)
+ goto error;
+ _XimParseStringFile(infp, im);
+ return (0);
+ } else if ((token == KEY) && (strcmp("None", tokenbuf) == 0)) {
+ modifier = 0;
+ modifier_mask = AllMask;
+ token = nexttoken(fp, tokenbuf, &lastch);
+ } else {
+ modifier_mask = modifier = 0;
+ exclam = False;
+ if (token == EXCLAM) {
+ exclam = True;
+ token = nexttoken(fp, tokenbuf, &lastch);
+ }
+ while (token == TILDE || token == KEY) {
+ tilde = False;
+ if (token == TILDE) {
+ tilde = True;
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token != KEY)
+ goto error;
+ }
+ tmp = modmask(tokenbuf);
+ if (!tmp) {
+ goto error;
+ }
+ modifier_mask |= tmp;
+ if (tilde) {
+ modifier &= ~tmp;
+ } else {
+ modifier |= tmp;
+ }
+ token = nexttoken(fp, tokenbuf, &lastch);
+ }
+ if (exclam) {
+ modifier_mask = AllMask;
+ }
+ }
+
+ if (token != LESS) {
+ goto error;
+ }
+
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token != KEY) {
+ goto error;
+ }
+
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token != GREATER) {
+ goto error;
+ }
+
+ keysym = XStringToKeysym(tokenbuf);
+ if (keysym == NoSymbol) {
+ goto error;
+ }
+
+ buf[n].keysym = keysym;
+ buf[n].modifier = modifier;
+ buf[n].modifier_mask = modifier_mask;
+ n++;
+ if( n >= SEQUENCE_MAX )
+ goto error;
+ token = nexttoken(fp, tokenbuf, &lastch);
+ } while (token != COLON);
+
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token == STRING) {
+ if( (rhs_string_mb = Xmalloc(strlen(tokenbuf) + 1)) == NULL )
+ goto error;
+ strcpy(rhs_string_mb, tokenbuf);
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token == KEY) {
+ rhs_keysym = XStringToKeysym(tokenbuf);
+ if (rhs_keysym == NoSymbol) {
+ Xfree(rhs_string_mb);
+ goto error;
+ }
+ token = nexttoken(fp, tokenbuf, &lastch);
+ }
+ if (token != ENDOFLINE && token != ENDOFFILE) {
+ Xfree(rhs_string_mb);
+ goto error;
+ }
+ } else if (token == KEY) {
+ rhs_keysym = XStringToKeysym(tokenbuf);
+ if (rhs_keysym == NoSymbol) {
+ goto error;
+ }
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token != ENDOFLINE && token != ENDOFFILE) {
+ goto error;
+ }
+
+ l = get_mb_string(im, local_mb_buf, rhs_keysym);
+ if (l == 0) {
+ rhs_string_mb = Xmalloc(1);
+ } else {
+ rhs_string_mb = Xmalloc(l + 1);
+ }
+ if( rhs_string_mb == NULL ) {
+ goto error;
+ }
+ memcpy(rhs_string_mb, local_mb_buf, l);
+ rhs_string_mb[l] = '\0';
+ } else {
+ goto error;
+ }
+
+ l = _Xmbstowcs(local_wc_buf, rhs_string_mb, LOCAL_WC_BUFSIZE - 1);
+ if (l == LOCAL_WC_BUFSIZE - 1) {
+ local_wc_buf[l] = (wchar_t)'\0';
+ }
+ if( (rhs_string_wc = (wchar_t *)Xmalloc((l + 1) * sizeof(wchar_t))) == NULL ) {
+ Xfree( rhs_string_mb );
+ return( 0 );
+ }
+ memcpy((char *)rhs_string_wc, (char *)local_wc_buf, (l + 1) * sizeof(wchar_t) );
+
+ l = _Xmbstoutf8(local_utf8_buf, rhs_string_mb, LOCAL_UTF8_BUFSIZE - 1);
+ if (l == LOCAL_UTF8_BUFSIZE - 1) {
+ local_wc_buf[l] = '\0';
+ }
+ if( (rhs_string_utf8 = (char *)Xmalloc(l + 1)) == NULL ) {
+ Xfree( rhs_string_wc );
+ Xfree( rhs_string_mb );
+ return( 0 );
+ }
+ memcpy(rhs_string_utf8, local_utf8_buf, l + 1);
+
+ for (i = 0; i < n; i++) {
+ for (p = *top; p; p = p->next) {
+ if (buf[i].keysym == p->keysym &&
+ buf[i].modifier == p->modifier &&
+ buf[i].modifier_mask == p->modifier_mask) {
+ break;
+ }
+ }
+ if (p) {
+ top = &p->succession;
+ } else {
+ if( (p = (DefTree*)Xmalloc(sizeof(DefTree))) == NULL ) {
+ Xfree( rhs_string_mb );
+ goto error;
+ }
+ p->keysym = buf[i].keysym;
+ p->modifier = buf[i].modifier;
+ p->modifier_mask = buf[i].modifier_mask;
+ p->succession = NULL;
+ p->next = *top;
+ p->mb = NULL;
+ p->wc = NULL;
+ p->utf8 = NULL;
+ p->ks = NoSymbol;
+ *top = p;
+ top = &p->succession;
+ }
+ }
+
+ if( p->mb != NULL )
+ Xfree( p->mb );
+ p->mb = rhs_string_mb;
+ if( p->wc != NULL )
+ Xfree( p->wc );
+ p->wc = rhs_string_wc;
+ if( p->utf8 != NULL )
+ Xfree( p->utf8 );
+ p->utf8 = rhs_string_utf8;
+ p->ks = rhs_keysym;
+ return(n);
+error:
+ while (token != ENDOFLINE && token != ENDOFFILE) {
+ token = nexttoken(fp, tokenbuf, &lastch);
+ }
+ return(0);
+}
+
+void
+_XimParseStringFile(
+ FILE *fp,
+ Xim im)
+{
+ char tb[8192];
+ char* tbp;
+ struct stat st;
+
+ if (fstat (fileno (fp), &st) != -1) {
+ unsigned long size = (unsigned long) st.st_size;
+ if (size <= sizeof tb) tbp = tb;
+ else tbp = malloc (size);
+
+ if (tbp != NULL) {
+ while (parseline(fp, im, tbp) >= 0) {}
+ if (tbp != tb) free (tbp);
+ }
+ }
+}
diff --git a/nx-X11/lib/X11/imLcSIc.c b/nx-X11/lib/X11/imLcSIc.c
new file mode 100644
index 000000000..a32211ce2
--- /dev/null
+++ b/nx-X11/lib/X11/imLcSIc.c
@@ -0,0 +1,57 @@
+/* $Xorg: imLcSIc.c,v 1.3 2000/08/17 19:45:14 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1990, 1991, 1992, 1993, 1994 by FUJITSU LIMITED
+
+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 of FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include <X11/Xutil.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Public char *
+_XimLocalSetICValues(xic, values)
+ XIC xic;
+ XIMArg *values;
+{
+ XimDefICValues ic_values;
+ Xic ic = (Xic)xic;
+ char *name;
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ name = _XimSetICValueData(ic, (XPointer)&ic_values,
+ ic->private.local.ic_resources,
+ ic->private.local.ic_num_resources,
+ values, XIM_SETICVALUES, True);
+ _XimSetCurrentICValues(ic, &ic_values);
+ return(name);
+}
diff --git a/nx-X11/lib/X11/imRm.c b/nx-X11/lib/X11/imRm.c
new file mode 100644
index 000000000..7dbc385cb
--- /dev/null
+++ b/nx-X11/lib/X11/imRm.c
@@ -0,0 +1,3133 @@
+/* $Xorg: imRm.c,v 1.4 2000/08/17 19:45:14 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1990, 1991, 1992,1993, 1994 by FUJITSU LIMITED
+ Copyright 1994 by Sony 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 of FUJITSU LIMITED
+and Sony Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific,
+written prior permission. FUJITSU LIMITED and Sony Corporation make
+no representations about the suitability of this software for any
+purpose. It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED AND SONY CORPORATION DISCLAIM ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND
+SONY CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imRm.c,v 3.12 2003/04/13 19:22:21 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "Xresource.h"
+
+typedef struct _XimValueOffsetInfo {
+ char *name;
+ XrmQuark quark;
+ unsigned int offset;
+ Bool (*defaults)(
+ struct _XimValueOffsetInfo *, XPointer, XPointer, unsigned long
+ );
+ Bool (*encode)(
+ struct _XimValueOffsetInfo *, XPointer, XPointer
+ );
+ Bool (*decode)(
+ struct _XimValueOffsetInfo *, XPointer, XPointer
+ );
+} XimValueOffsetInfoRec, *XimValueOffsetInfo;
+
+#ifdef XIM_CONNECTABLE
+Private Bool
+_XimCheckBool(str)
+ char *str;
+{
+ if(!strcmp(str, "True") || !strcmp(str, "true") ||
+ !strcmp(str, "Yes") || !strcmp(str, "yes") ||
+ !strcmp(str, "ON") || !strcmp(str, "on"))
+ return True;
+ return False;
+}
+
+Public void
+_XimSetProtoResource(im)
+ Xim im;
+{
+ char res_name_buf[256];
+ char* res_name;
+ char res_class_buf[256];
+ char* res_class;
+ char* str_type;
+ XrmValue value;
+ XIMStyle preedit_style = 0;
+ XIMStyle status_style = 0;
+ XIMStyles* imstyles;
+ char* dotximdot = ".xim.";
+ char* ximdot = "xim.";
+ char* dotXimdot = ".Xim.";
+ char* Ximdot = "Xim.";
+
+ if (!im->core.rdb)
+ return;
+
+ if (strlen (im->core.res_name) < 200) res_name = res_name_buf;
+ else res_name = Xmalloc (strlen (im->core.res_name) + 50);
+ if (strlen (im->core.res_class) < 200) res_class = res_class_buf;
+ else res_class = Xmalloc (strlen (im->core.res_class) + 50);
+ /* pretend malloc always works */
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "useAuth");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "UseAuth");
+ bzero(&value, sizeof(XrmValue));
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(_XimCheckBool(value.addr)) {
+ MARK_USE_AUTHORIZATION_FUNC(im);
+ }
+ }
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "delaybinding");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "Delaybinding");
+ bzero(&value, sizeof(XrmValue));
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(_XimCheckBool(value.addr)) {
+ MARK_DELAYBINDABLE(im);
+ }
+ }
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "reconnect");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "Reconnect");
+ bzero(&value, sizeof(XrmValue));
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(_XimCheckBool(value.addr)) {
+ MARK_RECONNECTABLE(im);
+ }
+ }
+
+ if(!IS_CONNECTABLE(im)) {
+ if (res_name != res_name_buf) Xfree (res_name);
+ if (res_class != res_class_buf) Xfree (res_class);
+ return;
+ }
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "preeditDefaultStyle");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "PreeditDefaultStyle");
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(!strcmp(value.addr, "XIMPreeditArea"))
+ preedit_style = XIMPreeditArea;
+ else if(!strcmp(value.addr, "XIMPreeditCallbacks"))
+ preedit_style = XIMPreeditCallbacks;
+ else if(!strcmp(value.addr, "XIMPreeditPosition"))
+ preedit_style = XIMPreeditPosition;
+ else if(!strcmp(value.addr, "XIMPreeditNothing"))
+ preedit_style = XIMPreeditNothing;
+ else if(!strcmp(value.addr, "XIMPreeditNone"))
+ preedit_style = XIMPreeditNone;
+ }
+ if(!preedit_style)
+ preedit_style = XIMPreeditNothing;
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "statusDefaultStyle");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "StatusDefaultStyle");
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(!strcmp(value.addr, "XIMStatusArea"))
+ status_style = XIMStatusArea;
+ else if(!strcmp(value.addr, "XIMStatusCallbacks"))
+ status_style = XIMStatusCallbacks;
+ else if(!strcmp(value.addr, "XIMStatusNothing"))
+ status_style = XIMStatusNothing;
+ else if(!strcmp(value.addr, "XIMStatusNone"))
+ status_style = XIMStatusNone;
+ }
+ if(!status_style)
+ status_style = XIMStatusNothing;
+
+ if(!(imstyles = (XIMStyles *)Xmalloc(sizeof(XIMStyles) + sizeof(XIMStyle)))){
+ if (res_name != res_name_buf) Xfree (res_name);
+ if (res_class != res_class_buf) Xfree (res_class);
+ return;
+ }
+ imstyles->count_styles = 1;
+ imstyles->supported_styles =
+ (XIMStyle *)((char *)imstyles + sizeof(XIMStyles));
+ imstyles->supported_styles[0] = preedit_style | status_style;
+ im->private.proto.default_styles = imstyles;
+ if (res_name != res_name_buf) Xfree (res_name);
+ if (res_class != res_class_buf) Xfree (res_class);
+}
+#endif /* XIM_CONNECTABLE */
+
+static char *supported_local_im_values_list[] = {
+ XNQueryInputStyle,
+ XNResourceName,
+ XNResourceClass,
+ XNDestroyCallback,
+ XNQueryIMValuesList,
+ XNQueryICValuesList,
+ XNVisiblePosition,
+ (char *)NULL
+};
+
+static char *supported_local_ic_values_list[] = {
+ XNInputStyle,
+ XNClientWindow,
+ XNFocusWindow,
+ XNResourceName,
+ XNResourceClass,
+ XNGeometryCallback,
+ XNFilterEvents,
+ XNDestroyCallback,
+ XNStringConversionCallback,
+ XNStringConversion,
+ XNResetState,
+ XNHotKey,
+ XNHotKeyState,
+ XNPreeditAttributes,
+ XNStatusAttributes,
+ XNArea,
+ XNAreaNeeded,
+ XNSpotLocation,
+ XNColormap,
+ XNStdColormap,
+ XNForeground,
+ XNBackground,
+ XNBackgroundPixmap,
+ XNFontSet,
+ XNLineSpace,
+ XNCursor,
+ XNPreeditStartCallback,
+ XNPreeditDoneCallback,
+ XNPreeditDrawCallback,
+ XNPreeditCaretCallback,
+ XNStatusStartCallback,
+ XNStatusDoneCallback,
+ XNStatusDrawCallback,
+ XNPreeditState,
+ XNPreeditStateNotifyCallback,
+ (char *)NULL
+};
+
+static XIMStyle const supported_local_styles[] = {
+ XIMPreeditNone | XIMStatusNone,
+ XIMPreeditNothing | XIMStatusNothing,
+ 0 /* dummy */
+};
+
+Private Bool
+_XimDefaultStyles(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm, /* unused */
+ unsigned long mode) /* unused */
+{
+ XIMStyles *styles;
+ XIMStyles **out;
+ register int i;
+ unsigned int n;
+ int len;
+ XPointer tmp;
+
+ n = XIMNumber(supported_local_styles) - 1;
+ len = sizeof(XIMStyles) + sizeof(XIMStyle) * n;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ styles = (XIMStyles *)tmp;
+ if (n > 0) {
+ styles->count_styles = (unsigned short)n;
+ styles->supported_styles =
+ (XIMStyle *)((char *)tmp + sizeof(XIMStyles));
+ for(i = 0; i < n; i++) {
+ styles->supported_styles[i] = supported_local_styles[i];
+ }
+ }
+
+ out = (XIMStyles **)((char *)top + info->offset);
+ *out = styles;
+ return True;
+}
+
+Private Bool
+_XimDefaultIMValues(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm, /* unused */
+ unsigned long mode) /* unused */
+{
+ XIMValuesList *values_list;
+ XIMValuesList **out;
+ register int i;
+ unsigned int n;
+ int len;
+ XPointer tmp;
+
+ n = XIMNumber(supported_local_im_values_list) - 1;
+ len = sizeof(XIMValuesList) + sizeof(char **) * n;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ values_list = (XIMValuesList *)tmp;
+ if (n > 0) {
+ values_list->count_values = (unsigned short)n;
+ values_list->supported_values
+ = (char **)((char *)tmp + sizeof(XIMValuesList));
+ for(i = 0; i < n; i++) {
+ values_list->supported_values[i]
+ = supported_local_im_values_list[i];
+ }
+ }
+
+ out = (XIMValuesList **)((char *)top + info->offset);
+ *out = values_list;
+ return True;
+}
+
+Private Bool
+_XimDefaultICValues(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm, /* unused */
+ unsigned long mode) /* unused */
+{
+ XIMValuesList *values_list;
+ XIMValuesList **out;
+ register int i;
+ unsigned int n;
+ int len;
+ XPointer tmp;
+
+ n = XIMNumber(supported_local_ic_values_list) - 1;
+ len = sizeof(XIMValuesList) + sizeof(char **) * n;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ values_list = (XIMValuesList *)tmp;
+ if (n > 0) {
+ values_list->count_values = (unsigned short)n;
+ values_list->supported_values
+ = (char **)((char *)tmp + sizeof(XIMValuesList));
+ for(i = 0; i < n; i++) {
+ values_list->supported_values[i]
+ = supported_local_ic_values_list[i];
+ }
+ }
+
+ out = (XIMValuesList **)((char *)top + info->offset);
+ *out = values_list;
+ return True;
+}
+
+Private Bool
+_XimDefaultVisiblePos(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm, /* unused */
+ unsigned long mode) /* unused */
+{
+ Bool *out;
+
+ out = (Bool *)((char *)top + info->offset);
+ *out = False;
+ return True;
+}
+
+Private Bool
+_XimDefaultFocusWindow(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Window *out;
+
+ if(ic->core.client_window == (Window)NULL) {
+ return True;
+ }
+
+ out = (Window *)((char *)top + info->offset);
+ *out = ic->core.client_window;
+ return True;
+}
+
+Private Bool
+_XimDefaultResName(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ char **out;
+
+ if(im->core.res_name == (char *)NULL) {
+ return True;
+ }
+
+ out = (char **)((char *)top + info->offset);
+ *out = im->core.res_name;
+ return True;
+}
+
+Private Bool
+_XimDefaultResClass(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ char **out;
+
+ if(im->core.res_class == (char *)NULL) {
+ return True;
+ }
+
+ out = (char **)((char *)top + info->offset);
+ *out = im->core.res_class;
+ return True;
+}
+
+Private Bool
+_XimDefaultDestroyCB(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ XIMCallback *out;
+
+ out = (XIMCallback *)((char *)top + info->offset);
+ *out = im->core.destroy_callback;
+ return True;
+}
+
+Private Bool
+_XimDefaultResetState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ XIMResetState *out;
+
+ out = (XIMResetState *)((char *)top + info->offset);
+ *out = XIMInitialState;
+ return True;
+}
+
+Private Bool
+_XimDefaultHotKeyState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ XIMHotKeyState *out;
+
+ out = (XIMHotKeyState *)((char *)top + info->offset);
+ *out = XIMHotKeyStateOFF;
+ return True;
+}
+
+Private Bool
+_XimDefaultArea(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ Window root_return;
+ int x_return, y_return;
+ unsigned int width_return, height_return;
+ unsigned int border_width_return;
+ unsigned int depth_return;
+ XRectangle area;
+ XRectangle *out;
+
+ if(ic->core.focus_window == (Window)NULL) {
+ return True;
+ }
+ if(XGetGeometry(im->core.display, (Drawable)ic->core.focus_window,
+ &root_return, &x_return, &y_return, &width_return,
+ &height_return, &border_width_return, &depth_return)
+ == (Status)NULL) {
+ return True;
+ }
+ area.x = 0;
+ area.y = 0;
+ area.width = width_return;
+ area.height = height_return;
+
+ out = (XRectangle *)((char *)top + info->offset);
+ *out = area;
+ return True;
+}
+
+Private Bool
+_XimDefaultColormap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ XWindowAttributes win_attr;
+ Colormap *out;
+
+ if(ic->core.client_window == (Window)NULL) {
+ return True;
+ }
+ if(XGetWindowAttributes(im->core.display, ic->core.client_window,
+ &win_attr) == (Status)NULL) {
+ return True;
+ }
+
+ out = (Colormap *)((char *)top + info->offset);
+ *out = win_attr.colormap;
+ return True;
+}
+
+Private Bool
+_XimDefaultStdColormap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Atom *out;
+
+ out = (Atom *)((char *)top + info->offset);
+ *out = (Atom)0;
+ return True;
+}
+
+Private Bool
+_XimDefaultFg(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ unsigned long fg;
+ unsigned long *out;
+
+ fg = WhitePixel(im->core.display, DefaultScreen(im->core.display));
+ out = (unsigned long *)((char *)top + info->offset);
+ *out = fg;
+ return True;
+}
+
+Private Bool
+_XimDefaultBg(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ unsigned long bg;
+ unsigned long *out;
+
+ bg = BlackPixel(im->core.display, DefaultScreen(im->core.display));
+ out = (unsigned long *)((char *)top + info->offset);
+ *out = bg;
+ return True;
+}
+
+Private Bool
+_XimDefaultBgPixmap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Pixmap *out;
+
+ out = (Pixmap *)((char *)top + info->offset);
+ *out = (Pixmap)0;
+ return True;
+}
+
+Private Bool
+_XimDefaultFontSet(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ XFontSet *out;
+
+ out = (XFontSet *)((char *)top + info->offset);
+ *out = 0;
+ return True;
+}
+
+Private Bool
+_XimDefaultLineSpace(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ XFontSet fontset;
+ XFontSetExtents *fset_extents;
+ int line_space = 0;
+ int *out;
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ fontset = ic->core.preedit_attr.fontset;
+ } else if(mode & XIM_STATUS_ATTR) {
+ fontset = ic->core.status_attr.fontset;
+ } else {
+ return True;
+ }
+ if (fontset) {
+ fset_extents = XExtentsOfFontSet(fontset);
+ line_space = fset_extents->max_logical_extent.height;
+ }
+ out = (int *)((char *)top + info->offset);
+ *out = line_space;
+ return True;
+}
+
+Private Bool
+_XimDefaultCursor(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Cursor *out;
+
+ out = (Cursor *)((char *)top + info->offset);
+ *out = (Cursor)0;
+ return True;
+}
+
+Private Bool
+_XimDefaultPreeditState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ XIMPreeditState *out;
+
+ out = (XIMPreeditState *)((char *)top + info->offset);
+ *out = XIMPreeditDisable;
+ return True;
+}
+
+Private Bool
+_XimDefaultNest(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ return True;
+}
+
+Private Bool
+_XimEncodeCallback(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMCallback *out;
+
+ out = (XIMCallback *)((char *)top + info->offset);
+ *out = *((XIMCallback *)val);
+ return True;
+}
+
+Private Bool
+_XimEncodeString(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ int len;
+ char *string;
+ char **out;
+
+ if(val == (XPointer)NULL) {
+ return False;
+ }
+ len = strlen((char *)val);
+ if(!(string = (char *)Xmalloc(len + 1))) {
+ return False;
+ }
+ (void)strcpy(string, (char *)val);
+ string[len] = '\0';
+
+ out = (char **)((char *)top + info->offset);
+ if(*out) {
+ Xfree(*out);
+ }
+ *out = string;
+ return True;
+}
+
+Private Bool
+_XimEncodeStyle(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMStyle *out;
+
+ out = (XIMStyle *)((char *)top + info->offset);
+ *out = (XIMStyle)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeWindow(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Window *out;
+
+ out = (Window *)((char *)top + info->offset);
+ *out = (Window)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeStringConv(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ /*
+ * Not yet
+ */
+ return True;
+}
+
+Private Bool
+_XimEncodeResetState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMResetState *out;
+
+ out = (XIMResetState *)((char *)top + info->offset);
+ *out = (XIMResetState)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeHotKey(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMHotKeyTriggers *hotkey = (XIMHotKeyTriggers *)val;
+ XIMHotKeyTriggers **out;
+ XIMHotKeyTriggers *key_list;
+ XIMHotKeyTrigger *key;
+ XPointer tmp;
+ int num;
+ int len;
+ register int i;
+
+ if(hotkey == (XIMHotKeyTriggers *)NULL) {
+ return True;
+ }
+
+ if((num = hotkey->num_hot_key) == 0) {
+ return True;
+ }
+
+ len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+
+ key_list = (XIMHotKeyTriggers *)tmp;
+ key = (XIMHotKeyTrigger *)((char *)tmp + sizeof(XIMHotKeyTriggers));
+
+ for(i = 0; i < num; i++) {
+ key[i] = hotkey->key[i];
+ }
+
+ key_list->num_hot_key = num;
+ key_list->key = key;
+
+ out = (XIMHotKeyTriggers **)((char *)top + info->offset);
+ *out = key_list;
+ return True;
+}
+
+Private Bool
+_XimEncodeHotKetState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMHotKeyState *out;
+
+ out = (XIMHotKeyState *)((char *)top + info->offset);
+ *out = (XIMHotKeyState)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeRectangle(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XRectangle *out;
+
+ out = (XRectangle *)((char *)top + info->offset);
+ *out = *((XRectangle *)val);
+ return True;
+}
+
+Private Bool
+_XimEncodeSpot(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XPoint *out;
+
+ out = (XPoint *)((char *)top + info->offset);
+ *out = *((XPoint *)val);
+ return True;
+}
+
+Private Bool
+_XimEncodeColormap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Colormap *out;
+
+ out = (Colormap *)((char *)top + info->offset);
+ *out = (Colormap)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeStdColormap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Atom *out;
+
+ out = (Atom *)((char *)top + info->offset);
+ *out = (Atom)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeLong(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ unsigned long *out;
+
+ out = (unsigned long *)((char *)top + info->offset);
+ *out = (unsigned long)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeBgPixmap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Pixmap *out;
+
+ out = (Pixmap *)((char *)top + info->offset);
+ *out = (Pixmap)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeFontSet(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XFontSet *out;
+
+ out = (XFontSet *)((char *)top + info->offset);
+ *out = (XFontSet)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeLineSpace(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ int *out;
+
+ out = (int *)((char *)top + info->offset);
+ *out = (long)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeCursor(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Cursor *out;
+
+ out = (Cursor *)((char *)top + info->offset);
+ *out = (Cursor)val;
+ return True;
+}
+
+Private Bool
+_XimEncodePreeditState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMPreeditState *out;
+
+ out = (XIMPreeditState *)((char *)top + info->offset);
+ *out = (XIMPreeditState)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeNest(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ return True;
+}
+
+Private Bool
+_XimDecodeStyles(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMStyles *styles;
+ XIMStyles *out;
+ register int i;
+ unsigned int num;
+ int len;
+ XPointer tmp;
+
+ if(val == (XPointer)NULL) {
+ return False;
+ }
+
+ styles = *((XIMStyles **)((char *)top + info->offset));
+ num = styles->count_styles;
+
+ len = sizeof(XIMStyles) + sizeof(XIMStyle) * num;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ out = (XIMStyles *)tmp;
+ if(num >0) {
+ out->count_styles = (unsigned short)num;
+ out->supported_styles = (XIMStyle *)((char *)tmp + sizeof(XIMStyles));
+
+ for(i = 0; i < num; i++) {
+ out->supported_styles[i] = styles->supported_styles[i];
+ }
+ }
+ *((XIMStyles **)val) = out;
+ return True;
+}
+
+Private Bool
+_XimDecodeValues(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMValuesList *values_list;
+ XIMValuesList *out;
+ register int i;
+ unsigned int num;
+ int len;
+ XPointer tmp;
+
+ if(val == (XPointer)NULL) {
+ return False;
+ }
+
+ values_list = *((XIMValuesList **)((char *)top + info->offset));
+ num = values_list->count_values;
+
+ len = sizeof(XIMValuesList) + sizeof(char **) * num;
+ if(!(tmp = (char *)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ out = (XIMValuesList *)tmp;
+ if(num) {
+ out->count_values = (unsigned short)num;
+ out->supported_values = (char **)((char *)tmp + sizeof(XIMValuesList));
+
+ for(i = 0; i < num; i++) {
+ out->supported_values[i] = values_list->supported_values[i];
+ }
+ }
+ *((XIMValuesList **)val) = out;
+ return True;
+}
+
+Private Bool
+_XimDecodeCallback(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMCallback *in;
+ XIMCallback *callback;
+
+ in = (XIMCallback *)((char *)top + info->offset);
+ if(!(callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback)))) {
+ return False;
+ }
+ callback->client_data = in->client_data;
+ callback->callback = in->callback;
+
+ *((XIMCallback **)val) = callback;
+ return True;
+}
+
+Private Bool
+_XimDecodeString(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ int len = 0;
+ char *in;
+ char *string;
+
+ in = *((char **)((char *)top + info->offset));
+ if(in != (char *)NULL) {
+ len = strlen(in);
+ }
+ if(!(string = (char *)Xmalloc(len + 1))) {
+ return False;
+ }
+ if(in != (char *)NULL) {
+ (void)strcpy(string, in);
+ }
+ string[len] = '\0';
+ *((char **)val) = string;
+ return True;
+}
+
+Private Bool
+_XimDecodeBool(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Bool *in;
+
+ in = (Bool *)((char *)top + info->offset);
+ *((Bool *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeStyle(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMStyle *in;
+
+ in = (XIMStyle *)((char *)top + info->offset);
+ *((XIMStyle *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeWindow(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Window *in;
+
+ in = (Window *)((char *)top + info->offset);
+ *((Window *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeStringConv(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ /*
+ * Not yet
+ */
+ return True;
+}
+
+Private Bool
+_XimDecodeResetState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMResetState *in;
+
+ in = (XIMResetState *)((char *)top + info->offset);
+ *((XIMResetState *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeHotKey(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMHotKeyTriggers *in;
+ XIMHotKeyTriggers *hotkey;
+ XIMHotKeyTrigger *key;
+ XPointer tmp;
+ int num;
+ int len;
+ register int i;
+
+ in = *((XIMHotKeyTriggers **)((char *)top + info->offset));
+ num = in->num_hot_key;
+ len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+
+ hotkey = (XIMHotKeyTriggers *)tmp;
+ key = (XIMHotKeyTrigger *)((char *)tmp + sizeof(XIMHotKeyTriggers));
+
+ for(i = 0; i < num; i++) {
+ key[i] = in->key[i];
+ }
+ hotkey->num_hot_key = num;
+ hotkey->key = key;
+
+ *((XIMHotKeyTriggers **)val) = hotkey;
+ return True;
+}
+
+Private Bool
+_XimDecodeHotKetState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMHotKeyState *in;
+
+ in = (XIMHotKeyState *)((char *)top + info->offset);
+ *((XIMHotKeyState *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeRectangle(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XRectangle *in;
+ XRectangle *rect;
+
+ in = (XRectangle *)((char *)top + info->offset);
+ if(!(rect = (XRectangle *)Xmalloc(sizeof(XRectangle)))) {
+ return False;
+ }
+ *rect = *in;
+ *((XRectangle **)val) = rect;
+ return True;
+}
+
+Private Bool
+_XimDecodeSpot(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XPoint *in;
+ XPoint *spot;
+
+ in = (XPoint *)((char *)top + info->offset);
+ if(!(spot = (XPoint *)Xmalloc(sizeof(XPoint)))) {
+ return False;
+ }
+ *spot = *in;
+ *((XPoint **)val) = spot;
+ return True;
+}
+
+Private Bool
+_XimDecodeColormap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Colormap *in;
+
+ in = (Colormap *)((char *)top + info->offset);
+ *((Colormap *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeStdColormap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Atom *in;
+
+ in = (Atom *)((char *)top + info->offset);
+ *((Atom *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeLong(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ unsigned long *in;
+
+ in = (unsigned long *)((char *)top + info->offset);
+ *((unsigned long *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeBgPixmap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Pixmap *in;
+
+ in = (Pixmap *)((char *)top + info->offset);
+ *((Pixmap *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeFontSet(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XFontSet *in;
+
+ in = (XFontSet *)((char *)top + info->offset);
+ *((XFontSet *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeLineSpace(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ int *in;
+
+ in = (int *)((char *)top + info->offset);
+ *((int *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeCursor(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Cursor *in;
+
+ in = (Cursor *)((char *)top + info->offset);
+ *((Cursor *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodePreeditState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMPreeditState *in;
+
+ in = (XIMPreeditState *)((char *)top + info->offset);
+ *((XIMPreeditState *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeNest(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ return True;
+}
+
+static XIMResource im_resources[] = {
+ {XNQueryInputStyle, 0, XimType_XIMStyles, 0, 0, 0},
+ {XNDestroyCallback, 0, 0, 0, 0, 0},
+ {XNResourceName, 0, XimType_STRING8, 0, 0, 0},
+ {XNResourceClass, 0, XimType_STRING8, 0, 0, 0},
+ {XNQueryIMValuesList, 0, 0, 0, 0, 0},
+ {XNQueryICValuesList, 0, 0, 0, 0, 0},
+ {XNVisiblePosition, 0, 0, 0, 0, 0}
+};
+
+static XIMResource im_inner_resources[] = {
+ {XNDestroyCallback, 0, 0, 0, 0, 0},
+ {XNResourceName, 0, XimType_STRING8, 0, 0, 0},
+ {XNResourceClass, 0, XimType_STRING8, 0, 0, 0},
+ {XNQueryIMValuesList, 0, 0, 0, 0, 0},
+ {XNQueryICValuesList, 0, 0, 0, 0, 0},
+ {XNVisiblePosition, 0, 0, 0, 0, 0}
+};
+
+static XIMResource ic_resources[] = {
+ {XNInputStyle, 0, XimType_CARD32, 0, 0, 0},
+ {XNClientWindow, 0, XimType_Window, 0, 0, 0},
+ {XNFocusWindow, 0, XimType_Window, 0, 0, 0},
+ {XNResourceName, 0, XimType_STRING8, 0, 0, 0},
+ {XNResourceClass, 0, XimType_STRING8, 0, 0, 0},
+ {XNGeometryCallback, 0, 0, 0, 0, 0},
+ {XNFilterEvents, 0, XimType_CARD32, 0, 0, 0},
+ {XNDestroyCallback, 0, 0, 0, 0, 0},
+ {XNStringConversionCallback, 0, 0, 0, 0, 0},
+ {XNStringConversion, 0, XimType_XIMStringConversion,0, 0, 0},
+ {XNResetState, 0, 0, 0, 0, 0},
+ {XNHotKey, 0, XimType_XIMHotKeyTriggers,0, 0, 0},
+ {XNHotKeyState, 0, XimType_XIMHotKeyState, 0, 0, 0},
+ {XNPreeditAttributes, 0, XimType_NEST, 0, 0, 0},
+ {XNStatusAttributes, 0, XimType_NEST, 0, 0, 0},
+ {XNArea, 0, XimType_XRectangle, 0, 0, 0},
+ {XNAreaNeeded, 0, XimType_XRectangle, 0, 0, 0},
+ {XNSpotLocation, 0, XimType_XPoint, 0, 0, 0},
+ {XNColormap, 0, XimType_CARD32, 0, 0, 0},
+ {XNStdColormap, 0, XimType_CARD32, 0, 0, 0},
+ {XNForeground, 0, XimType_CARD32, 0, 0, 0},
+ {XNBackground, 0, XimType_CARD32, 0, 0, 0},
+ {XNBackgroundPixmap, 0, XimType_CARD32, 0, 0, 0},
+ {XNFontSet, 0, XimType_XFontSet, 0, 0, 0},
+ {XNLineSpace, 0, XimType_CARD32, 0, 0, 0},
+ {XNCursor, 0, XimType_CARD32, 0, 0, 0},
+ {XNPreeditStartCallback, 0, 0, 0, 0, 0},
+ {XNPreeditDoneCallback, 0, 0, 0, 0, 0},
+ {XNPreeditDrawCallback, 0, 0, 0, 0, 0},
+ {XNPreeditCaretCallback, 0, 0, 0, 0, 0},
+ {XNStatusStartCallback, 0, 0, 0, 0, 0},
+ {XNStatusDoneCallback, 0, 0, 0, 0, 0},
+ {XNStatusDrawCallback, 0, 0, 0, 0, 0},
+ {XNPreeditState, 0, 0, 0, 0, 0},
+ {XNPreeditStateNotifyCallback, 0, 0, 0, 0, 0},
+};
+
+static XIMResource ic_inner_resources[] = {
+ {XNResourceName, 0, XimType_STRING8, 0, 0, 0},
+ {XNResourceClass, 0, XimType_STRING8, 0, 0, 0},
+ {XNGeometryCallback, 0, 0, 0, 0, 0},
+ {XNDestroyCallback, 0, 0, 0, 0, 0},
+ {XNStringConversionCallback, 0, 0, 0, 0, 0},
+ {XNPreeditStartCallback, 0, 0, 0, 0, 0},
+ {XNPreeditDoneCallback, 0, 0, 0, 0, 0},
+ {XNPreeditDrawCallback, 0, 0, 0, 0, 0},
+ {XNPreeditCaretCallback, 0, 0, 0, 0, 0},
+ {XNStatusStartCallback, 0, 0, 0, 0, 0},
+ {XNStatusDoneCallback, 0, 0, 0, 0, 0},
+ {XNStatusDrawCallback, 0, 0, 0, 0, 0},
+ {XNPreeditStateNotifyCallback, 0, 0, 0, 0, 0},
+};
+
+static XimValueOffsetInfoRec im_attr_info[] = {
+ {XNQueryInputStyle, 0,
+ XOffsetOf(XimDefIMValues, styles),
+ _XimDefaultStyles, NULL, _XimDecodeStyles},
+
+ {XNDestroyCallback, 0,
+ XOffsetOf(XimDefIMValues, destroy_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNResourceName, 0,
+ XOffsetOf(XimDefIMValues, res_name),
+ NULL, _XimEncodeString, _XimDecodeString},
+
+ {XNResourceClass, 0,
+ XOffsetOf(XimDefIMValues, res_class),
+ NULL, _XimEncodeString, _XimDecodeString},
+
+ {XNQueryIMValuesList, 0,
+ XOffsetOf(XimDefIMValues, im_values_list),
+ _XimDefaultIMValues, NULL, _XimDecodeValues},
+
+ {XNQueryICValuesList, 0,
+ XOffsetOf(XimDefIMValues, ic_values_list),
+ _XimDefaultICValues, NULL, _XimDecodeValues},
+
+ {XNVisiblePosition, 0,
+ XOffsetOf(XimDefIMValues, visible_position),
+ _XimDefaultVisiblePos, NULL, _XimDecodeBool}
+};
+
+static XimValueOffsetInfoRec ic_attr_info[] = {
+ {XNInputStyle, 0,
+ XOffsetOf(XimDefICValues, input_style),
+ NULL, _XimEncodeStyle, _XimDecodeStyle},
+
+ {XNClientWindow, 0,
+ XOffsetOf(XimDefICValues, client_window),
+ NULL, _XimEncodeWindow, _XimDecodeWindow},
+
+ {XNFocusWindow, 0,
+ XOffsetOf(XimDefICValues, focus_window),
+ _XimDefaultFocusWindow, _XimEncodeWindow, _XimDecodeWindow},
+
+ {XNResourceName, 0,
+ XOffsetOf(XimDefICValues, res_name),
+ _XimDefaultResName, _XimEncodeString, _XimDecodeString},
+
+ {XNResourceClass, 0,
+ XOffsetOf(XimDefICValues, res_class),
+ _XimDefaultResClass, _XimEncodeString, _XimDecodeString},
+
+ {XNGeometryCallback, 0,
+ XOffsetOf(XimDefICValues, geometry_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNFilterEvents, 0,
+ XOffsetOf(XimDefICValues, filter_events),
+ NULL, NULL, _XimDecodeLong},
+
+ {XNDestroyCallback, 0,
+ XOffsetOf(XimDefICValues, destroy_callback),
+ _XimDefaultDestroyCB, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNStringConversionCallback, 0,
+ XOffsetOf(XimDefICValues, string_conversion_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNStringConversion, 0,
+ XOffsetOf(XimDefICValues, string_conversion),
+ NULL, _XimEncodeStringConv, _XimDecodeStringConv},
+
+ {XNResetState, 0,
+ XOffsetOf(XimDefICValues, reset_state),
+ _XimDefaultResetState, _XimEncodeResetState, _XimDecodeResetState},
+
+ {XNHotKey, 0,
+ XOffsetOf(XimDefICValues, hotkey),
+ NULL, _XimEncodeHotKey, _XimDecodeHotKey},
+
+ {XNHotKeyState, 0,
+ XOffsetOf(XimDefICValues, hotkey_state),
+ _XimDefaultHotKeyState, _XimEncodeHotKetState, _XimDecodeHotKetState},
+
+ {XNPreeditAttributes, 0,
+ XOffsetOf(XimDefICValues, preedit_attr),
+ _XimDefaultNest, _XimEncodeNest, _XimDecodeNest},
+
+ {XNStatusAttributes, 0,
+ XOffsetOf(XimDefICValues, status_attr),
+ _XimDefaultNest, _XimEncodeNest, _XimDecodeNest},
+};
+
+static XimValueOffsetInfoRec ic_pre_attr_info[] = {
+ {XNArea, 0,
+ XOffsetOf(ICPreeditAttributes, area),
+ _XimDefaultArea, _XimEncodeRectangle, _XimDecodeRectangle},
+
+ {XNAreaNeeded, 0,
+ XOffsetOf(ICPreeditAttributes, area_needed),
+ NULL, _XimEncodeRectangle, _XimDecodeRectangle},
+
+ {XNSpotLocation, 0,
+ XOffsetOf(ICPreeditAttributes, spot_location),
+ NULL, _XimEncodeSpot, _XimDecodeSpot},
+
+ {XNColormap, 0,
+ XOffsetOf(ICPreeditAttributes, colormap),
+ _XimDefaultColormap, _XimEncodeColormap, _XimDecodeColormap},
+
+ {XNStdColormap, 0,
+ XOffsetOf(ICPreeditAttributes, std_colormap),
+ _XimDefaultStdColormap, _XimEncodeStdColormap, _XimDecodeStdColormap},
+
+ {XNForeground, 0,
+ XOffsetOf(ICPreeditAttributes, foreground),
+ _XimDefaultFg, _XimEncodeLong, _XimDecodeLong},
+
+ {XNBackground, 0,
+ XOffsetOf(ICPreeditAttributes, background),
+ _XimDefaultBg, _XimEncodeLong, _XimDecodeLong},
+
+ {XNBackgroundPixmap, 0,
+ XOffsetOf(ICPreeditAttributes, background_pixmap),
+ _XimDefaultBgPixmap, _XimEncodeBgPixmap, _XimDecodeBgPixmap},
+
+ {XNFontSet, 0,
+ XOffsetOf(ICPreeditAttributes, fontset),
+ _XimDefaultFontSet, _XimEncodeFontSet, _XimDecodeFontSet},
+
+ {XNLineSpace, 0,
+ XOffsetOf(ICPreeditAttributes, line_spacing),
+ _XimDefaultLineSpace, _XimEncodeLineSpace, _XimDecodeLineSpace},
+
+ {XNCursor, 0,
+ XOffsetOf(ICPreeditAttributes, cursor),
+ _XimDefaultCursor, _XimEncodeCursor, _XimDecodeCursor},
+
+ {XNPreeditStartCallback, 0,
+ XOffsetOf(ICPreeditAttributes, start_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNPreeditDoneCallback, 0,
+ XOffsetOf(ICPreeditAttributes, done_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNPreeditDrawCallback, 0,
+ XOffsetOf(ICPreeditAttributes, draw_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNPreeditCaretCallback, 0,
+ XOffsetOf(ICPreeditAttributes, caret_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNPreeditState, 0,
+ XOffsetOf(ICPreeditAttributes, preedit_state),
+ _XimDefaultPreeditState, _XimEncodePreeditState,_XimDecodePreeditState},
+
+ {XNPreeditStateNotifyCallback, 0,
+ XOffsetOf(ICPreeditAttributes, state_notify_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+};
+
+static XimValueOffsetInfoRec ic_sts_attr_info[] = {
+ {XNArea, 0,
+ XOffsetOf(ICStatusAttributes, area),
+ _XimDefaultArea, _XimEncodeRectangle, _XimDecodeRectangle},
+
+ {XNAreaNeeded, 0,
+ XOffsetOf(ICStatusAttributes, area_needed),
+ NULL, _XimEncodeRectangle, _XimDecodeRectangle},
+
+ {XNColormap, 0,
+ XOffsetOf(ICStatusAttributes, colormap),
+ _XimDefaultColormap, _XimEncodeColormap, _XimDecodeColormap},
+
+ {XNStdColormap, 0,
+ XOffsetOf(ICStatusAttributes, std_colormap),
+ _XimDefaultStdColormap, _XimEncodeStdColormap, _XimDecodeStdColormap},
+
+ {XNForeground, 0,
+ XOffsetOf(ICStatusAttributes, foreground),
+ _XimDefaultFg, _XimEncodeLong, _XimDecodeLong},
+
+ {XNBackground, 0,
+ XOffsetOf(ICStatusAttributes, background),
+ _XimDefaultBg, _XimEncodeLong, _XimDecodeLong},
+
+ {XNBackgroundPixmap, 0,
+ XOffsetOf(ICStatusAttributes, background_pixmap),
+ _XimDefaultBgPixmap, _XimEncodeBgPixmap, _XimDecodeBgPixmap},
+
+ {XNFontSet, 0,
+ XOffsetOf(ICStatusAttributes, fontset),
+ _XimDefaultFontSet, _XimEncodeFontSet, _XimDecodeFontSet},
+
+ {XNLineSpace, 0,
+ XOffsetOf(ICStatusAttributes, line_spacing),
+ _XimDefaultLineSpace, _XimEncodeLineSpace, _XimDecodeLineSpace},
+
+ {XNCursor, 0,
+ XOffsetOf(ICStatusAttributes, cursor),
+ _XimDefaultCursor, _XimEncodeCursor, _XimDecodeCursor},
+
+ {XNStatusStartCallback, 0,
+ XOffsetOf(ICStatusAttributes, start_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNStatusDoneCallback, 0,
+ XOffsetOf(ICStatusAttributes, done_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNStatusDrawCallback, 0,
+ XOffsetOf(ICStatusAttributes, draw_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback}
+};
+
+typedef struct _XimIMMode {
+ char *name;
+ XrmQuark quark;
+ unsigned short mode;
+} XimIMMode;
+
+static XimIMMode im_mode[] = {
+ {XNQueryInputStyle, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)},
+ {XNDestroyCallback, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)},
+ {XNResourceName, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)},
+ {XNResourceClass, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)},
+ {XNQueryIMValuesList, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)},
+ {XNQueryICValuesList, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)},
+ {XNVisiblePosition, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)}
+};
+
+typedef struct _XimICMode {
+ char *name;
+ XrmQuark quark;
+ unsigned short preedit_callback_mode;
+ unsigned short preedit_position_mode;
+ unsigned short preedit_area_mode;
+ unsigned short preedit_nothing_mode;
+ unsigned short preedit_none_mode;
+ unsigned short status_callback_mode;
+ unsigned short status_area_mode;
+ unsigned short status_nothing_mode;
+ unsigned short status_none_mode;
+} XimICMode;
+
+static XimICMode ic_mode[] = {
+ {XNInputStyle, 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET)},
+ {XNClientWindow, 0,
+ (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
+ 0,
+ (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET),
+ 0},
+ {XNFocusWindow, 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNResourceName, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNResourceClass, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNGeometryCallback, 0,
+ 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0},
+ {XNFilterEvents, 0,
+ XIM_MODE_PRE_GET,
+ XIM_MODE_PRE_GET,
+ XIM_MODE_PRE_GET,
+ XIM_MODE_PRE_GET,
+ 0,
+ XIM_MODE_STS_GET,
+ XIM_MODE_STS_GET,
+ XIM_MODE_STS_GET,
+ XIM_MODE_STS_GET},
+ {XNDestroyCallback, 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNStringConversionCallback, 0,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNStringConversion, 0,
+ XIM_MODE_PRE_SET,
+ XIM_MODE_PRE_SET,
+ XIM_MODE_PRE_SET,
+ XIM_MODE_PRE_SET,
+ XIM_MODE_PRE_SET,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNResetState, 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNHotKey, 0,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNHotKeyState, 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNPreeditAttributes, 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNStatusAttributes, 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNArea, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0},
+ {XNAreaNeeded, 0,
+ 0,
+ 0,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0},
+ {XNSpotLocation, 0,
+ 0, /*(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),*/
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNColormap, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNStdColormap, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNForeground, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNBackground, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNBackgroundPixmap, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNFontSet, 0,
+ 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNLineSpace, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNCursor, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNPreeditStartCallback, 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNPreeditDoneCallback, 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNPreeditDrawCallback, 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNPreeditCaretCallback, 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNPreeditState, 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNPreeditStateNotifyCallback, 0,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNStatusStartCallback, 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0,
+ 0},
+ {XNStatusDoneCallback, 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0,
+ 0},
+ {XNStatusDrawCallback, 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0,
+ 0}
+};
+
+Private Bool
+_XimSetResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num,
+ XIMResourceList resource,
+ unsigned int num_resource,
+ unsigned short id)
+{
+ register int i;
+ int len;
+ XIMResourceList res;
+
+ len = sizeof(XIMResource) * num_resource;
+ if(!(res = (XIMResourceList)Xmalloc(len))) {
+ return False;
+ }
+ bzero((char *)res, len);
+
+ for(i = 0; i < num_resource; i++, id++) {
+ res[i] = resource[i];
+ res[i].id = id;
+ }
+
+ _XIMCompileResourceList(res, num_resource);
+ *res_list = res;
+ *list_num = num_resource;
+ return True;
+}
+
+Public Bool
+_XimSetIMResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num)
+{
+ return _XimSetResourceList(res_list, list_num,
+ im_resources, XIMNumber(im_resources), 100);
+}
+
+Public Bool
+_XimSetICResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num)
+{
+ return _XimSetResourceList(res_list, list_num,
+ ic_resources, XIMNumber(ic_resources), 200);
+}
+
+Public Bool
+_XimSetInnerIMResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num)
+{
+ return _XimSetResourceList(res_list, list_num,
+ im_inner_resources, XIMNumber(im_inner_resources), 100);
+}
+
+Public Bool
+_XimSetInnerICResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num)
+{
+ return _XimSetResourceList(res_list, list_num,
+ ic_inner_resources, XIMNumber(ic_inner_resources), 200);
+}
+
+Private XIMResourceList
+_XimGetResourceListRecByMode(
+ XIMResourceList res_list,
+ unsigned int list_num,
+ unsigned short mode)
+{
+ register int i;
+
+ for(i = 0; i < list_num; i++) {
+ if (res_list[i].mode & mode) {
+ return (XIMResourceList)&res_list[i];
+ }
+ }
+ return (XIMResourceList)NULL;
+}
+
+Public Bool
+_XimCheckCreateICValues(
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ if (!_XimGetResourceListRecByMode(res_list, list_num, XIM_MODE_IC_CREATE)) {
+ return True;
+ }
+ return False;
+}
+
+Public XIMResourceList
+_XimGetResourceListRecByQuark(
+ XIMResourceList res_list,
+ unsigned int list_num,
+ XrmQuark quark)
+{
+ register int i;
+
+ for(i = 0; i < list_num; i++) {
+ if (res_list[i].xrm_name == quark) {
+ return (XIMResourceList)&res_list[i];
+ }
+ }
+ return (XIMResourceList)NULL;
+}
+
+Public XIMResourceList
+_XimGetResourceListRec(
+ XIMResourceList res_list,
+ unsigned int list_num,
+ char *name)
+{
+ XrmQuark quark = XrmStringToQuark(name);
+
+ return _XimGetResourceListRecByQuark(res_list, list_num, quark);
+}
+
+Public char *
+_XimSetIMValueData(
+ Xim im,
+ XPointer top,
+ XIMArg *values,
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+
+ for(p = values; p->name != NULL; p++) {
+ if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) {
+ return p->value;
+ }
+ check = _XimCheckIMMode(res, XIM_SETIMVALUES);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if (check == XIM_CHECK_ERROR) {
+ return p->value;
+ }
+
+ if(!_XimEncodeLocalIMAttr(res, top, p->value)) {
+ return p->value;
+ }
+ }
+ return NULL;
+}
+
+Public char *
+_XimGetIMValueData(
+ Xim im,
+ XPointer top,
+ XIMArg *values,
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+
+ for(p = values; p->name != NULL; p++) {
+ if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) {
+ return p->value;
+ }
+ check = _XimCheckIMMode(res, XIM_GETIMVALUES);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if (check == XIM_CHECK_ERROR) {
+ return p->value;
+ }
+
+ if(!_XimDecodeLocalIMAttr(res, top, p->value)) {
+ return p->value;
+ }
+ }
+ return NULL;
+}
+
+Public void
+_XimSetIMMode(
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ XIMResourceList res;
+ unsigned int n = XIMNumber(im_mode);
+ register int i;
+
+ for(i = 0; i < n; i++) {
+ if(!(res = _XimGetResourceListRecByQuark(res_list,
+ list_num, im_mode[i].quark))) {
+ continue;
+ }
+ res->mode = im_mode[i].mode;
+ }
+ return;
+}
+
+Private int
+_XimCheckSetIMDefaultsMode(
+ XIMResourceList res)
+{
+ if(res->mode & XIM_MODE_IM_DEFAULT) {
+ return XIM_CHECK_VALID;
+ }
+ return XIM_CHECK_INVALID;
+}
+
+Private int
+_XimCheckSetIMValuesMode(
+ XIMResourceList res)
+{
+ if(res->mode & XIM_MODE_IM_SET) {
+ return XIM_CHECK_VALID;
+ }
+ return XIM_CHECK_INVALID;
+}
+
+Private int
+ _XimCheckGetIMValuesMode(
+ XIMResourceList res)
+{
+ if(res->mode & XIM_MODE_IM_GET) {
+ return XIM_CHECK_VALID;
+ }
+ return XIM_CHECK_INVALID;
+}
+
+Public int
+ _XimCheckIMMode(
+ XIMResourceList res,
+ unsigned long mode)
+{
+ if(res->mode == 0) {
+ return XIM_CHECK_INVALID;
+ }
+ if(mode & XIM_SETIMDEFAULTS) {
+ return _XimCheckSetIMDefaultsMode(res);
+ } else if (mode & XIM_SETIMVALUES) {
+ return _XimCheckSetIMValuesMode(res);
+ } else if (mode & XIM_GETIMVALUES) {
+ return _XimCheckGetIMValuesMode(res);
+ } else {
+ return XIM_CHECK_ERROR;
+ }
+}
+
+Public void
+_XimSetICMode(res_list, list_num, style)
+ XIMResourceList res_list;
+ unsigned int list_num;
+ XIMStyle style;
+{
+ XIMResourceList res;
+ unsigned int n = XIMNumber(ic_mode);
+ register int i;
+ unsigned int pre_offset;
+ unsigned int sts_offset;
+
+ if(style & XIMPreeditArea) {
+ pre_offset = XOffsetOf(XimICMode, preedit_area_mode);
+ } else if(style & XIMPreeditCallbacks) {
+ pre_offset = XOffsetOf(XimICMode, preedit_callback_mode);
+ } else if(style & XIMPreeditPosition) {
+ pre_offset = XOffsetOf(XimICMode, preedit_position_mode);
+ } else if(style & XIMPreeditNothing) {
+ pre_offset = XOffsetOf(XimICMode, preedit_nothing_mode);
+ } else {
+ pre_offset = XOffsetOf(XimICMode, preedit_none_mode);
+ }
+
+ if(style & XIMStatusArea) {
+ sts_offset = XOffsetOf(XimICMode, status_area_mode);
+ } else if(style & XIMStatusCallbacks) {
+ sts_offset = XOffsetOf(XimICMode, status_callback_mode);
+ } else if(style & XIMStatusNothing) {
+ sts_offset = XOffsetOf(XimICMode, status_nothing_mode);
+ } else {
+ sts_offset = XOffsetOf(XimICMode, status_none_mode);
+ }
+
+ for(i = 0; i < n; i++) {
+ if(!(res = _XimGetResourceListRecByQuark(res_list,
+ list_num, ic_mode[i].quark))) {
+ continue;
+ }
+ res->mode = ( (*(unsigned short *)((char *)&ic_mode[i] + pre_offset))
+ | (*(unsigned short *)((char *)&ic_mode[i] + sts_offset)));
+ }
+ return;
+}
+
+Private int
+_XimCheckSetICDefaultsMode(
+ XIMResourceList res,
+ unsigned long mode)
+{
+ if(mode & XIM_PREEDIT_ATTR) {
+ if(!(res->mode & XIM_MODE_PRE_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_PRE_CREATE) {
+ return XIM_CHECK_ERROR;
+ } else if (!(res->mode & XIM_MODE_PRE_DEFAULT)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ } else if(mode & XIM_STATUS_ATTR) {
+ if(!(res->mode & XIM_MODE_STS_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_STS_CREATE) {
+ return XIM_CHECK_ERROR;
+ }
+ if(!(res->mode & XIM_MODE_STS_DEFAULT)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ } else {
+ if(!res->mode) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_IC_CREATE) {
+ return XIM_CHECK_ERROR;
+ }
+ if(!(res->mode & XIM_MODE_IC_DEFAULT)) {
+ return XIM_CHECK_INVALID;
+ }
+ }
+ return XIM_CHECK_VALID;
+}
+
+Private int
+_XimCheckCreateICMode(
+ XIMResourceList res,
+ unsigned long mode)
+{
+ if(mode & XIM_PREEDIT_ATTR) {
+ if(!(res->mode & XIM_MODE_PRE_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_PRE_CREATE) {
+ res->mode &= ~XIM_MODE_PRE_CREATE;
+ } else if(res->mode & XIM_MODE_PRE_ONCE) {
+ res->mode &= ~XIM_MODE_PRE_ONCE;
+ } else if(res->mode & XIM_MODE_PRE_DEFAULT) {
+ res->mode &= ~XIM_MODE_PRE_DEFAULT;
+ } else if (!(res->mode & XIM_MODE_PRE_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else if(mode & XIM_STATUS_ATTR) {
+ if(!(res->mode & XIM_MODE_STS_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_STS_CREATE) {
+ res->mode &= ~XIM_MODE_STS_CREATE;
+ } else if(res->mode & XIM_MODE_STS_ONCE) {
+ res->mode &= ~XIM_MODE_STS_ONCE;
+ } else if(res->mode & XIM_MODE_STS_DEFAULT) {
+ res->mode &= ~XIM_MODE_STS_DEFAULT;
+ } else if (!(res->mode & XIM_MODE_STS_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else {
+ if(!res->mode) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_IC_CREATE) {
+ res->mode &= ~XIM_MODE_IC_CREATE;
+ } else if(res->mode & XIM_MODE_IC_ONCE) {
+ res->mode &= ~XIM_MODE_IC_ONCE;
+ } else if(res->mode & XIM_MODE_IC_DEFAULT) {
+ res->mode &= ~XIM_MODE_IC_DEFAULT;
+ } else if (!(res->mode & XIM_MODE_IC_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+ }
+ return XIM_CHECK_VALID;
+}
+
+Private int
+_XimCheckSetICValuesMode(
+ XIMResourceList res,
+ unsigned long mode)
+{
+ if(mode & XIM_PREEDIT_ATTR) {
+ if(!(res->mode & XIM_MODE_PRE_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_PRE_ONCE) {
+ res->mode &= ~XIM_MODE_PRE_ONCE;
+ } else if(!(res->mode & XIM_MODE_PRE_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else if(mode & XIM_STATUS_ATTR) {
+ if(!(res->mode & XIM_MODE_STS_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_STS_ONCE) {
+ res->mode &= ~XIM_MODE_STS_ONCE;
+ } else if(!(res->mode & XIM_MODE_STS_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else {
+ if(!res->mode) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_IC_ONCE) {
+ res->mode &= ~XIM_MODE_IC_ONCE;
+ } else if(!(res->mode & XIM_MODE_IC_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+ }
+ return XIM_CHECK_VALID;
+}
+
+Private int
+_XimCheckGetICValuesMode(
+ XIMResourceList res,
+ unsigned long mode)
+{
+ if(mode & XIM_PREEDIT_ATTR) {
+ if(!(res->mode & XIM_MODE_PRE_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(!(res->mode & XIM_MODE_PRE_GET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else if(mode & XIM_STATUS_ATTR) {
+ if(!(res->mode & XIM_MODE_STS_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(!(res->mode & XIM_MODE_STS_GET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else {
+ if(!res->mode) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(!(res->mode & XIM_MODE_IC_GET)) {
+ return XIM_CHECK_ERROR;
+ }
+ }
+ return XIM_CHECK_VALID;
+}
+
+Public int
+ _XimCheckICMode(
+ XIMResourceList res,
+ unsigned long mode)
+{
+ if(mode &XIM_SETICDEFAULTS) {
+ return _XimCheckSetICDefaultsMode(res, mode);
+ } else if (mode & XIM_CREATEIC) {
+ return _XimCheckCreateICMode(res, mode);
+ } else if (mode & XIM_SETICVALUES) {
+ return _XimCheckSetICValuesMode(res, mode);
+ } else if (mode & XIM_GETICVALUES) {
+ return _XimCheckGetICValuesMode(res, mode);
+ } else {
+ return XIM_CHECK_ERROR;
+ }
+}
+
+Public Bool
+_XimSetLocalIMDefaults(
+ Xim im,
+ XPointer top,
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ XimValueOffsetInfo info;
+ unsigned int num;
+ register int i;
+ XIMResourceList res;
+ int check;
+
+ info = im_attr_info;
+ num = XIMNumber(im_attr_info);
+
+ for(i = 0; i < num; i++) {
+ if((res = _XimGetResourceListRecByQuark( res_list, list_num,
+ info[i].quark)) == (XIMResourceList)NULL) {
+ return False;
+ }
+
+ check = _XimCheckIMMode(res, XIM_SETIMDEFAULTS);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if (check == XIM_CHECK_ERROR) {
+ return False;
+ }
+
+ if(!info[i].defaults) {
+ continue;
+ }
+ if(!(info[i].defaults(&info[i], top, (XPointer)NULL, 0))) {
+ return False;
+ }
+ }
+ return True;
+}
+
+Public Bool
+_XimSetICDefaults(
+ Xic ic,
+ XPointer top,
+ unsigned long mode,
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ unsigned int num;
+ XimValueOffsetInfo info;
+ register int i;
+ XIMResourceList res;
+ int check;
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ info = ic_pre_attr_info;
+ num = XIMNumber(ic_pre_attr_info);
+ } else if(mode & XIM_STATUS_ATTR) {
+ info = ic_sts_attr_info;
+ num = XIMNumber(ic_sts_attr_info);
+ } else {
+ info = ic_attr_info;
+ num = XIMNumber(ic_attr_info);
+ }
+
+ for(i = 0; i < num; i++) {
+ if(info[i].quark == pre_quark) {
+ if(!_XimSetICDefaults(ic, (XPointer)((char *)top + info[i].offset),
+ (mode | XIM_PREEDIT_ATTR), res_list, list_num)) {
+ return False;
+ }
+ } else if (info[i].quark == sts_quark) {
+ if(!_XimSetICDefaults(ic, (XPointer)((char *)top + info[i].offset),
+ (mode | XIM_STATUS_ATTR), res_list, list_num)) {
+ return False;
+ }
+ } else {
+ if(!(res = _XimGetResourceListRecByQuark(res_list, list_num,
+ info[i].quark))) {
+ return False;
+ }
+
+ check = _XimCheckICMode(res, mode);
+ if (check == XIM_CHECK_INVALID) {
+ continue;
+ } else if (check == XIM_CHECK_ERROR) {
+ return False;
+ }
+
+ if (!info[i].defaults) {
+ continue;
+ }
+ if (!(info[i].defaults(&info[i], top, (XPointer)ic, mode))) {
+ return False;
+ }
+ }
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodeAttr(
+ XimValueOffsetInfo info,
+ unsigned int num,
+ XIMResourceList res,
+ XPointer top,
+ XPointer val)
+{
+ register int i;
+
+ for(i = 0; i < num; i++ ) {
+ if(info[i].quark == res->xrm_name) {
+ if(!info[i].encode) {
+ return False;
+ }
+ return (*info[i].encode)(&info[i], top, val);
+ }
+ }
+ return False;
+}
+
+Public Bool
+_XimEncodeLocalIMAttr(
+ XIMResourceList res,
+ XPointer top,
+ XPointer val)
+{
+ return _XimEncodeAttr(im_attr_info, XIMNumber(im_attr_info),
+ res, top, val);
+}
+
+Public Bool
+_XimEncodeLocalICAttr(
+ Xic ic,
+ XIMResourceList res,
+ XPointer top,
+ XIMArg *arg,
+ unsigned long mode)
+{
+ unsigned int num;
+ XimValueOffsetInfo info;
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ info = ic_pre_attr_info;
+ num = XIMNumber(ic_pre_attr_info);
+ } else if(mode & XIM_STATUS_ATTR) {
+ info = ic_sts_attr_info;
+ num = XIMNumber(ic_sts_attr_info);
+ } else {
+ info = ic_attr_info;
+ num = XIMNumber(ic_attr_info);
+ }
+
+ return _XimEncodeAttr(info, num, res, top, arg->value);
+}
+
+Private Bool
+_XimEncodeLocalTopValue(
+ Xic ic,
+ XIMResourceList res,
+ XPointer val,
+ Bool flag)
+{
+ XIMArg *p = (XIMArg *)val;
+
+ if (res->xrm_name == XrmStringToQuark(XNClientWindow)) {
+ ic->core.client_window = (Window)p->value;
+ if (ic->core.focus_window == (Window)0)
+ ic->core.focus_window = ic->core.client_window;
+ if (flag) {
+ _XRegisterFilterByType(ic->core.im->core.display,
+ ic->core.focus_window,
+ KeyPress, KeyPress, _XimLocalFilter, (XPointer)ic);
+ }
+ } else if (res->xrm_name == XrmStringToQuark(XNFocusWindow)) {
+ if (ic->core.client_window) {
+ if (flag) {
+ _XUnregisterFilter(ic->core.im->core.display,
+ ic->core.focus_window, _XimLocalFilter, (XPointer)ic);
+ }
+ ic->core.focus_window = (Window)p->value;
+ if (flag) {
+ _XRegisterFilterByType(ic->core.im->core.display,
+ ic->core.focus_window, KeyPress, KeyPress,
+ _XimLocalFilter, (XPointer)ic);
+ }
+ } else
+ ic->core.focus_window = (Window)p->value;
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodeLocalPreeditValue(
+ Xic ic,
+ XIMResourceList res,
+ XPointer val)
+{
+ XIMArg *p = (XIMArg *)val;
+
+ if (res->xrm_name == XrmStringToQuark(XNStdColormap)) {
+ XStandardColormap *colormap_ret;
+ int count;
+
+ if (!(XGetRGBColormaps(ic->core.im->core.display,
+ ic->core.focus_window, &colormap_ret,
+ &count, (Atom)p->value)))
+ return False;
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodeLocalStatusValue(
+ Xic ic,
+ XIMResourceList res,
+ XPointer val)
+{
+ XIMArg *p = (XIMArg *)val;
+
+ if (res->xrm_name == XrmStringToQuark(XNStdColormap)) {
+ XStandardColormap *colormap_ret;
+ int count;
+
+ if (!(XGetRGBColormaps(ic->core.im->core.display,
+ ic->core.focus_window, &colormap_ret,
+ &count, (Atom)p->value)))
+ return False;
+ }
+ return True;
+}
+
+Public char *
+_XimSetICValueData(
+ Xic ic,
+ XPointer top,
+ XIMResourceList res_list,
+ unsigned int list_num,
+ XIMArg *values,
+ unsigned long mode,
+ Bool flag)
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ char *name;
+ int check;
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ for(p = values; p->name != NULL; p++) {
+ if((res = _XimGetResourceListRec(res_list, list_num,
+ p->name)) == (XIMResourceList)NULL) {
+ return p->name;
+ }
+ if(res->xrm_name == pre_quark) {
+ if(((name = _XimSetICValueData(ic,
+ (XPointer)(&((XimDefICValues *)top)->preedit_attr),
+ res_list, list_num, (XIMArg *)p->value,
+ (mode | XIM_PREEDIT_ATTR), flag)))) {
+ return name;
+ }
+ } else if(res->xrm_name == sts_quark) {
+ if(((name = _XimSetICValueData(ic,
+ (XPointer)(&((XimDefICValues *)top)->status_attr),
+ res_list, list_num, (XIMArg *)p->value,
+ (mode | XIM_STATUS_ATTR), flag)))) {
+ return name;
+ }
+ } else {
+ check = _XimCheckICMode(res, mode);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if(check == XIM_CHECK_ERROR) {
+ return p->name;
+ }
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ if (!_XimEncodeLocalPreeditValue(ic, res, (XPointer)p))
+ return False;
+ } else if(mode & XIM_STATUS_ATTR) {
+ if (!_XimEncodeLocalStatusValue(ic, res, (XPointer)p))
+ return False;
+ } else {
+ if (!_XimEncodeLocalTopValue(ic, res, (XPointer)p, flag))
+ return False;
+ }
+ if(_XimEncodeLocalICAttr(ic, res, top, p, mode) == False) {
+ return p->name;
+ }
+ }
+ }
+ return NULL;
+}
+
+Private Bool
+_XimCheckInputStyle(
+ XIMStyles *styles,
+ XIMStyle style)
+{
+ int num = styles->count_styles;
+ register int i;
+
+ for(i = 0; i < num; i++) {
+ if(styles->supported_styles[i] == style) {
+ return True;
+ }
+ }
+ return False;
+}
+
+Public Bool
+_XimCheckLocalInputStyle(
+ Xic ic,
+ XPointer top,
+ XIMArg *values,
+ XIMStyles *styles,
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ XrmQuark quark = XrmStringToQuark(XNInputStyle);
+ register XIMArg *p;
+ XIMResourceList res;
+
+ for(p = values; p && p->name != NULL; p++) {
+ if(quark == XrmStringToQuark(p->name)) {
+ if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) {
+ return False;
+ }
+ if(!_XimEncodeLocalICAttr(ic, res, top, p, 0)) {
+ return False;
+ }
+ if (_XimCheckInputStyle(styles,
+ ((XimDefICValues *)top)->input_style)) {
+ return True;
+ }
+ return False;
+ }
+ }
+ return False;
+}
+
+Private Bool
+_XimDecodeAttr(
+ XimValueOffsetInfo info,
+ unsigned int num,
+ XIMResourceList res,
+ XPointer top,
+ XPointer val)
+{
+ register int i;
+
+ for(i = 0; i < num; i++ ) {
+ if(info[i].quark == res->xrm_name) {
+ if(!info[i].decode) {
+ return False;
+ }
+ return (*info[i].decode)(&info[i], top, val);
+ }
+ }
+ return False;
+}
+
+Public Bool
+_XimDecodeLocalIMAttr(
+ XIMResourceList res,
+ XPointer top,
+ XPointer val)
+{
+ return _XimDecodeAttr(im_attr_info, XIMNumber(im_attr_info),
+ res, top, val);
+}
+
+Public Bool
+_XimDecodeLocalICAttr(
+ XIMResourceList res,
+ XPointer top,
+ XPointer val,
+ unsigned long mode)
+{
+ unsigned int num;
+ XimValueOffsetInfo info;
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ info = ic_pre_attr_info;
+ num = XIMNumber(ic_pre_attr_info);
+ } else if(mode & XIM_STATUS_ATTR) {
+ info = ic_sts_attr_info;
+ num = XIMNumber(ic_sts_attr_info);
+ } else {
+ info = ic_attr_info;
+ num = XIMNumber(ic_attr_info);
+ }
+
+ return _XimDecodeAttr(info, num, res, top, val);
+}
+
+Public char *
+_XimGetICValueData(ic, top, res_list, list_num, values, mode)
+ Xic ic;
+ XPointer top;
+ XIMResourceList res_list;
+ unsigned int list_num;
+ XIMArg *values;
+ unsigned long mode;
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ char *name;
+ int check;
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ for(p = values; p->name != NULL; p++) {
+ if((res = _XimGetResourceListRec(res_list, list_num,
+ p->name)) == (XIMResourceList)NULL) {
+ return p->name;
+ }
+ if(res->xrm_name == pre_quark) {
+ if((name = _XimGetICValueData(ic,
+ (XPointer)(&((XimDefICValues *)top)->preedit_attr),
+ res_list, list_num, (XIMArg *)p->value,
+ (mode | XIM_PREEDIT_ATTR)))) {
+ return name;
+ }
+ } else if(res->xrm_name == sts_quark) {
+ if((name = _XimGetICValueData(ic,
+ (XPointer)(&((XimDefICValues *)top)->status_attr),
+ res_list, list_num, (XIMArg *)p->value,
+ (mode | XIM_STATUS_ATTR)))) {
+ return name;
+ }
+ } else {
+ check = _XimCheckICMode(res, mode);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if(check == XIM_CHECK_ERROR) {
+ return p->name;
+ }
+
+ if(_XimDecodeLocalICAttr(res, top, p->value, mode) == False) {
+ return p->name;
+ }
+ }
+ }
+ return NULL;
+}
+
+Public void
+_XimGetCurrentIMValues(im, im_values)
+ Xim im;
+ XimDefIMValues *im_values;
+{
+ bzero((char *)im_values, sizeof(XimDefIMValues));
+
+ im_values->styles = im->core.styles;
+ im_values->im_values_list = im->core.im_values_list;
+ im_values->ic_values_list = im->core.ic_values_list;
+ im_values->destroy_callback = im->core.destroy_callback;
+ im_values->res_name = im->core.res_name;
+ im_values->res_class = im->core.res_class;
+ im_values->visible_position = im->core.visible_position;
+}
+
+Public void
+_XimSetCurrentIMValues(im, im_values)
+ Xim im;
+ XimDefIMValues *im_values;
+{
+ im->core.styles = im_values->styles;
+ im->core.im_values_list = im_values->im_values_list;
+ im->core.ic_values_list = im_values->ic_values_list;
+ im->core.destroy_callback = im_values->destroy_callback;
+ im->core.res_name = im_values->res_name;
+ im->core.res_class = im_values->res_class;
+ im->core.visible_position = im_values->visible_position;
+}
+
+Public void
+_XimGetCurrentICValues(ic, ic_values)
+ Xic ic;
+ XimDefICValues *ic_values;
+{
+ bzero((char *)ic_values, sizeof(XimDefICValues));
+
+ ic_values->input_style = ic->core.input_style;
+ ic_values->client_window = ic->core.client_window;
+ ic_values->focus_window = ic->core.focus_window;
+ ic_values->filter_events = ic->core.filter_events;
+ ic_values->geometry_callback = ic->core.geometry_callback;
+ ic_values->res_name = ic->core.res_name;
+ ic_values->res_class = ic->core.res_class;
+ ic_values->destroy_callback = ic->core.destroy_callback;
+ ic_values->string_conversion_callback
+ = ic->core.string_conversion_callback;
+ ic_values->string_conversion = ic->core.string_conversion;
+ ic_values->reset_state = ic->core.reset_state;
+ ic_values->hotkey = ic->core.hotkey;
+ ic_values->hotkey_state = ic->core.hotkey_state;
+ ic_values->preedit_attr = ic->core.preedit_attr;
+ ic_values->status_attr = ic->core.status_attr;
+}
+
+Public void
+_XimSetCurrentICValues(
+ Xic ic,
+ XimDefICValues *ic_values)
+{
+ ic->core.input_style = ic_values->input_style;
+ ic->core.client_window = ic_values->client_window;
+ if (ic_values->focus_window)
+ ic->core.focus_window = ic_values->focus_window;
+ ic->core.filter_events = ic_values->filter_events;
+ ic->core.geometry_callback = ic_values->geometry_callback;
+ ic->core.res_name = ic_values->res_name;
+ ic->core.res_class = ic_values->res_class;
+ ic->core.destroy_callback = ic_values->destroy_callback;
+ ic->core.string_conversion_callback
+ = ic_values->string_conversion_callback;
+ ic->core.string_conversion = ic_values->string_conversion;
+ ic->core.reset_state = ic_values->reset_state;
+ ic->core.hotkey = ic_values->hotkey;
+ ic->core.hotkey_state = ic_values->hotkey_state;
+ ic->core.preedit_attr = ic_values->preedit_attr;
+ ic->core.status_attr = ic_values->status_attr;
+}
+
+Private void
+_XimInitialIMOffsetInfo(void)
+{
+ unsigned int n = XIMNumber(im_attr_info);
+ register int i;
+
+ for(i = 0; i < n; i++) {
+ im_attr_info[i].quark = XrmStringToQuark(im_attr_info[i].name);
+ }
+}
+
+Private void
+_XimInitialICOffsetInfo(void)
+{
+ unsigned int n;
+ register int i;
+
+ n = XIMNumber(ic_attr_info);
+ for(i = 0; i < n; i++) {
+ ic_attr_info[i].quark = XrmStringToQuark(ic_attr_info[i].name);
+ }
+
+ n = XIMNumber(ic_pre_attr_info);
+ for(i = 0; i < n; i++) {
+ ic_pre_attr_info[i].quark = XrmStringToQuark(ic_pre_attr_info[i].name);
+ }
+
+ n = XIMNumber(ic_sts_attr_info);
+ for(i = 0; i < n; i++) {
+ ic_sts_attr_info[i].quark = XrmStringToQuark(ic_sts_attr_info[i].name);
+ }
+}
+
+Private void
+_XimInitialIMMode(void)
+{
+ unsigned int n = XIMNumber(im_mode);
+ register int i;
+
+ for(i = 0; i < n; i++) {
+ im_mode[i].quark = XrmStringToQuark(im_mode[i].name);
+ }
+}
+
+Private void
+_XimInitialICMode(void)
+{
+ unsigned int n = XIMNumber(ic_mode);
+ register int i;
+
+ for(i = 0; i < n; i++) {
+ ic_mode[i].quark = XrmStringToQuark(ic_mode[i].name);
+ }
+}
+
+Public void
+_XimInitialResourceInfo(void)
+{
+ static Bool init_flag = False;
+
+ if(init_flag == True) {
+ return;
+ }
+ _XimInitialIMOffsetInfo();
+ _XimInitialICOffsetInfo();
+ _XimInitialIMMode();
+ _XimInitialICMode();
+ init_flag = True;
+}
diff --git a/nx-X11/lib/X11/imRmAttr.c b/nx-X11/lib/X11/imRmAttr.c
new file mode 100644
index 000000000..af4db3db0
--- /dev/null
+++ b/nx-X11/lib/X11/imRmAttr.c
@@ -0,0 +1,1517 @@
+/* $Xorg: imRmAttr.c,v 1.4 2000/08/17 19:45:15 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+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 of FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imRmAttr.c,v 1.7 2003/04/13 19:22:21 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+
+Private XIMResourceList
+_XimGetNestedListSeparator(
+ XIMResourceList res_list, /* LISTofIMATTR or IMATTR */
+ unsigned int res_num)
+{
+ return _XimGetResourceListRec(res_list, res_num, XNSeparatorofNestedList);
+}
+
+Private Bool
+_XimCheckInnerIMAttributes(
+ Xim im,
+ XIMArg *arg,
+ unsigned long mode)
+{
+ XIMResourceList res;
+ int check;
+
+ if (!(res = _XimGetResourceListRec(im->private.proto.im_inner_resources,
+ im->private.proto.im_num_inner_resources, arg->name)))
+ return False;
+
+ check = _XimCheckIMMode(res, mode);
+ if(check == XIM_CHECK_INVALID)
+ return True;
+ else if(check == XIM_CHECK_ERROR)
+ return False;
+
+ return True;
+}
+
+Public char *
+_XimMakeIMAttrIDList(
+ Xim im,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ XIMArg *arg,
+ CARD16 *buf,
+ INT16 *len,
+ unsigned long mode)
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+
+ *len = 0;
+ if (!arg)
+ return (char *)NULL;
+
+ for (p = arg; p->name; p++) {
+ if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
+ if (_XimCheckInnerIMAttributes(im, p, mode))
+ continue;
+ return p->name;
+ }
+
+ check = _XimCheckIMMode(res, mode);
+ if (check == XIM_CHECK_INVALID)
+ continue;
+ else if (check == XIM_CHECK_ERROR)
+ return p->name;
+
+ *buf = res->id;
+ *len += sizeof(CARD16);
+ buf++;
+ }
+ return (char *)NULL;
+}
+
+Private Bool
+_XimCheckInnerICAttributes(
+ Xic ic,
+ XIMArg *arg,
+ unsigned long mode)
+{
+ XIMResourceList res;
+ int check;
+
+ if (!(res = _XimGetResourceListRec(ic->private.proto.ic_inner_resources,
+ ic->private.proto.ic_num_inner_resources, arg->name)))
+ return False;
+
+ check = _XimCheckICMode(res, mode);
+ if(check == XIM_CHECK_INVALID)
+ return True;
+ else if(check == XIM_CHECK_ERROR)
+ return False;
+
+ return True;
+}
+
+Public char *
+_XimMakeICAttrIDList(
+ Xic ic,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ XIMArg *arg,
+ CARD16 *buf,
+ INT16 *len,
+ unsigned long mode)
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+ char *name;
+ INT16 new_len;
+
+ *len = 0;
+ if (!arg)
+ return (char *)NULL;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ for (p = arg; p && p->name; p++) {
+ if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
+ if (_XimCheckInnerICAttributes(ic, p, mode))
+ continue;
+ *len = -1;
+ return p->name;
+ }
+
+ check = _XimCheckICMode(res, mode);
+ if(check == XIM_CHECK_INVALID)
+ continue;
+ else if(check == XIM_CHECK_ERROR) {
+ *len = -1;
+ return p->name;
+ }
+
+ *buf = res->id;
+ *len += sizeof(CARD16);
+ buf++;
+ if (res->resource_size == XimType_NEST) {
+ if (res->xrm_name == pre_quark) {
+ if ((name = _XimMakeICAttrIDList(ic, res_list, res_num,
+ (XIMArg *)p->value, buf, &new_len,
+ (mode | XIM_PREEDIT_ATTR)))) {
+ if (new_len < 0) *len = -1;
+ else *len += new_len;
+ return name;
+ }
+ } else if (res->xrm_name == sts_quark) {
+ if ((name = _XimMakeICAttrIDList(ic, res_list, res_num,
+ (XIMArg *)p->value, buf, &new_len,
+ (mode | XIM_STATUS_ATTR)))) {
+ if (new_len < 0) *len = -1;
+ else *len += new_len;
+ return name;
+ }
+ }
+ *len += new_len;
+ buf = (CARD16 *)((char *)buf + new_len);
+ if (!(res = _XimGetNestedListSeparator(res_list, res_num))) {
+ p++;
+ if (p) {
+ *len = -1;
+ return p->name;
+ }
+ else {
+ return (char *)NULL;
+ }
+ }
+ *buf = res->id;
+ *len += sizeof(CARD16);
+ buf++;
+ }
+ }
+ return (char *)NULL;
+}
+
+Private Bool
+_XimAttributeToValue(
+ Xic ic,
+ XIMResourceList res,
+ CARD16 *data,
+ INT16 data_len,
+ XPointer value,
+ BITMASK32 mode)
+{
+ switch (res->resource_size) {
+ case XimType_SeparatorOfNestedList:
+ case XimType_NEST:
+ break;
+
+ case XimType_CARD8:
+ case XimType_CARD16:
+ case XimType_CARD32:
+ case XimType_Window:
+ case XimType_XIMHotKeyState:
+ _XCopyToArg((XPointer)data, (XPointer *)&value, data_len);
+ break;
+
+ case XimType_STRING8:
+ {
+ char *str;
+
+ if (!(value))
+ return False;
+
+ if (!(str = (char *)Xmalloc(data_len + 1)))
+ return False;
+
+ (void)memcpy(str, (char *)data, data_len);
+ str[data_len] = '\0';
+
+ *((char **)value) = str;
+ break;
+ }
+
+ case XimType_XIMStyles:
+ {
+ INT16 num = data[0];
+ register CARD32 *style_list = (CARD32 *)&data[2];
+ XIMStyle *style;
+ XIMStyles *rep;
+ register int i;
+ char *p;
+ int alloc_len;
+
+ if (!(value))
+ return False;
+
+ alloc_len = sizeof(XIMStyles) + sizeof(XIMStyle) * num;
+ if (!(p = (char *)Xmalloc(alloc_len)))
+ return False;
+
+ rep = (XIMStyles *)p;
+ style = (XIMStyle *)(p + sizeof(XIMStyles));
+
+ for (i = 0; i < num; i++)
+ style[i] = (XIMStyle)style_list[i];
+
+ rep->count_styles = (unsigned short)num;
+ rep->supported_styles = style;
+ *((XIMStyles **)value) = rep;
+ break;
+ }
+
+ case XimType_XRectangle:
+ {
+ XRectangle *rep;
+
+ if (!(value))
+ return False;
+
+ if (!(rep = (XRectangle *)Xmalloc(sizeof(XRectangle))))
+ return False;
+
+ rep->x = data[0];
+ rep->y = data[1];
+ rep->width = data[2];
+ rep->height = data[3];
+ *((XRectangle **)value) = rep;
+ break;
+ }
+
+ case XimType_XPoint:
+ {
+ XPoint *rep;
+
+ if (!(value))
+ return False;
+
+ if (!(rep = (XPoint *)Xmalloc(sizeof(XPoint))))
+ return False;
+
+ rep->x = data[0];
+ rep->y = data[1];
+ *((XPoint **)value) = rep;
+ break;
+ }
+
+ case XimType_XFontSet:
+ {
+ INT16 len = data[0];
+ char *base_name;
+ XFontSet rep = (XFontSet)NULL;
+ char **missing_list;
+ int missing_count;
+ char *def_string;
+
+ if (!(value))
+ return False;
+ if (!ic)
+ return False;
+
+ if (!(base_name = (char *)Xmalloc(len + 1)))
+ return False;
+
+ (void)strncpy(base_name, (char *)&data[1], (int)len);
+ base_name[len] = '\0';
+
+ if (mode & XIM_PREEDIT_ATTR) {
+ if (!strcmp(base_name, ic->private.proto.preedit_font)) {
+ rep = ic->core.preedit_attr.fontset;
+ } else if (!ic->private.proto.preedit_font_length) {
+ rep = XCreateFontSet(ic->core.im->core.display,
+ base_name, &missing_list,
+ &missing_count, &def_string);
+ }
+ } else if (mode & XIM_STATUS_ATTR) {
+ if (!strcmp(base_name, ic->private.proto.status_font)) {
+ rep = ic->core.status_attr.fontset;
+ } else if (!ic->private.proto.status_font_length) {
+ rep = XCreateFontSet(ic->core.im->core.display,
+ base_name, &missing_list,
+ &missing_count, &def_string);
+ }
+ }
+
+ Xfree(base_name);
+ *((XFontSet *)value) = rep;
+ break;
+ }
+
+ case XimType_XIMHotKeyTriggers:
+ {
+ INT32 num = *((CARD32 *)data);
+ register CARD32 *key_list = (CARD32 *)&data[2];
+ XIMHotKeyTrigger *key;
+ XIMHotKeyTriggers *rep;
+ register int i;
+ char *p;
+ int alloc_len;
+
+ if (!(value))
+ return False;
+
+ alloc_len = sizeof(XIMHotKeyTriggers)
+ + sizeof(XIMHotKeyTrigger) * num;
+ if (!(p = (char *)Xmalloc(alloc_len)))
+ return False;
+
+ rep = (XIMHotKeyTriggers *)p;
+ key = (XIMHotKeyTrigger *)(p + sizeof(XIMHotKeyTriggers));
+
+ for (i = 0; i < num; i++, key_list += 3) {
+ key[i].keysym = (KeySym)key_list[0]; /* keysym */
+ key[i].modifier = (int)key_list[1]; /* modifier */
+ key[i].modifier_mask = (int)key_list[2]; /* modifier_mask */
+ }
+
+ rep->num_hot_key = (int)num;
+ rep->key = key;
+ *((XIMHotKeyTriggers **)value) = rep;
+ break;
+ }
+
+ case XimType_XIMStringConversion:
+ {
+ break;
+ }
+
+ default:
+ return False;
+ }
+ return True;
+}
+
+Private Bool
+_XimDecodeInnerIMATTRIBUTE(
+ Xim im,
+ XIMArg *arg)
+{
+ XIMResourceList res;
+ XimDefIMValues im_values;
+
+ if (!(res = _XimGetResourceListRec(im->private.proto.im_inner_resources,
+ im->private.proto.im_num_inner_resources, arg->name)))
+ return False;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ return _XimDecodeLocalIMAttr(res, (XPointer)&im_values, arg->value);
+}
+
+Public char *
+_XimDecodeIMATTRIBUTE(
+ Xim im,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ CARD16 *data,
+ INT16 data_len,
+ XIMArg *arg,
+ BITMASK32 mode)
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+ INT16 len;
+ CARD16 *buf;
+ INT16 total;
+ INT16 min_len = sizeof(CARD16) /* sizeof attributeID */
+ + sizeof(INT16); /* sizeof length */
+
+ for (p = arg; p->name; p++) {
+ if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
+ if (_XimDecodeInnerIMATTRIBUTE(im, p))
+ continue;
+ return p->name;
+ }
+
+ check = _XimCheckIMMode(res, mode);
+ if(check == XIM_CHECK_INVALID)
+ continue;
+ else if(check == XIM_CHECK_ERROR)
+ return p->name;
+
+ total = data_len;
+ buf = data;
+ while (total >= min_len) {
+ if (res->id == buf[0])
+ break;
+
+ len = buf[1];
+ len += XIM_PAD(len) + min_len;
+ buf = (CARD16 *)((char *)buf + len);
+ total -= len;
+ }
+ if (total < min_len)
+ return p->name;
+
+ if (!(_XimAttributeToValue((Xic) im->private.local.current_ic,
+ res, &buf[2], buf[1], p->value, mode)))
+ return p->name;
+ }
+ return (char *)NULL;
+}
+
+Private Bool
+_XimDecodeInnerICATTRIBUTE(
+ Xic ic,
+ XIMArg *arg,
+ unsigned long mode)
+{
+ XIMResourceList res;
+ XimDefICValues ic_values;
+
+ if (!(res = _XimGetResourceListRec(ic->private.proto.ic_inner_resources,
+ ic->private.proto.ic_num_inner_resources, arg->name)))
+ return False;
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ if (!_XimDecodeLocalICAttr(res, (XPointer)&ic_values, arg->value, mode))
+ return False;
+ _XimSetCurrentICValues(ic, &ic_values);
+ return True;
+}
+
+Public char *
+_XimDecodeICATTRIBUTE(
+ Xic ic,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ CARD16 *data,
+ INT16 data_len,
+ XIMArg *arg,
+ BITMASK32 mode)
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+ INT16 len;
+ CARD16 *buf;
+ INT16 total;
+ char *name;
+ INT16 min_len = sizeof(CARD16) /* sizeof attributeID */
+ + sizeof(INT16); /* sizeof length */
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+
+ if (!arg)
+ return (char *)NULL;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ for (p = arg; p->name; p++) {
+ if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
+ if (_XimDecodeInnerICATTRIBUTE(ic, p, mode))
+ continue;
+ return p->name;
+ }
+
+ check = _XimCheckICMode(res, mode);
+ if (check == XIM_CHECK_INVALID)
+ continue;
+ else if (check == XIM_CHECK_ERROR)
+ return p->name;
+
+ total = data_len;
+ buf = data;
+ while (total >= min_len) {
+ if (res->id == buf[0])
+ break;
+
+ len = buf[1];
+ len += XIM_PAD(len) + min_len;
+ buf = (CARD16 *)((char *)buf + len);
+ total -= len;
+ }
+ if (total < min_len)
+ return p->name;
+
+ if (res->resource_size == XimType_NEST) {
+ if (res->xrm_name == pre_quark) {
+ if ((name = _XimDecodeICATTRIBUTE(ic, res_list, res_num,
+ &buf[2], buf[1], (XIMArg *)p->value,
+ (mode | XIM_PREEDIT_ATTR))))
+ return name;
+ } else if (res->xrm_name == sts_quark) {
+ if ((name = _XimDecodeICATTRIBUTE(ic, res_list, res_num,
+ &buf[2], buf[1], (XIMArg *)p->value,
+ (mode | XIM_STATUS_ATTR))))
+ return name;
+ }
+ } else {
+ if (!(_XimAttributeToValue(ic, res, &buf[2], buf[1],
+ p->value, mode)))
+ return p->name;
+ }
+ }
+ return (char *)NULL;
+}
+
+Private Bool
+_XimValueToAttribute(
+ XIMResourceList res,
+ XPointer buf,
+ int buf_size,
+ XPointer value,
+ int *len,
+ unsigned long mode,
+ XPointer param)
+{
+ int ret_len;
+
+ switch (res->resource_size) {
+ case XimType_SeparatorOfNestedList:
+ case XimType_NEST:
+ *len = 0;
+ break;
+
+ case XimType_CARD8:
+ ret_len = sizeof(CARD8);
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ *((CARD8 *)buf) = (CARD8)(long)value;
+ *len = ret_len;
+ break;
+
+ case XimType_CARD16:
+ ret_len = sizeof(CARD16);
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ *((CARD16 *)buf) = (CARD16)(long)value;
+ *len = ret_len;
+ break;
+
+ case XimType_CARD32:
+ case XimType_Window:
+ case XimType_XIMHotKeyState:
+ ret_len = sizeof(CARD32);
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ *((CARD32 *)buf) = (CARD32)(long)value;
+ *len = ret_len;
+ break;
+
+ case XimType_STRING8:
+ if (!value) {
+ *len = 0;
+ return False;
+ }
+
+ ret_len = strlen((char *)value);
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ (void)memcpy((char *)buf, (char *)value, ret_len);
+ *len = ret_len;
+ break;
+
+ case XimType_XRectangle:
+ {
+ XRectangle *rect = (XRectangle *)value;
+ CARD16 *buf_s = (CARD16 *)buf;
+
+ if (!rect) {
+ *len = 0;
+ return False;
+ }
+
+ ret_len = sizeof(INT16) /* sizeof X */
+ + sizeof(INT16) /* sizeof Y */
+ + sizeof(CARD16) /* sizeof width */
+ + sizeof(CARD16); /* sizeof height */
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ buf_s[0] = (CARD16)rect->x; /* X */
+ buf_s[1] = (CARD16)rect->y; /* Y */
+ buf_s[2] = (CARD16)rect->width; /* width */
+ buf_s[3] = (CARD16)rect->height; /* heght */
+ *len = ret_len;
+ break;
+ }
+
+ case XimType_XPoint:
+ {
+ XPoint *point = (XPoint *)value;
+ CARD16 *buf_s = (CARD16 *)buf;
+
+ if (!point) {
+ *len = 0;
+ return False;
+ }
+
+ ret_len = sizeof(INT16) /* sizeof X */
+ + sizeof(INT16); /* sizeof Y */
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ buf_s[0] = (CARD16)point->x; /* X */
+ buf_s[1] = (CARD16)point->y; /* Y */
+ *len = ret_len;
+ break;
+ }
+
+ case XimType_XFontSet:
+ {
+ XFontSet font = (XFontSet)value;
+ Xic ic = (Xic)param;
+ char *base_name = NULL;
+ int length = 0;
+ CARD16 *buf_s = (CARD16 *)buf;
+
+ if (!font) {
+ *len = 0;
+ return False;
+ }
+
+ if (mode & XIM_PREEDIT_ATTR) {
+ base_name = ic->private.proto.preedit_font;
+ length = ic->private.proto.preedit_font_length;
+ } else if (mode & XIM_STATUS_ATTR) {
+ base_name = ic->private.proto.status_font;
+ length = ic->private.proto.status_font_length;
+ }
+
+ if (!base_name) {
+ *len = 0;
+ return False;
+ }
+
+ ret_len = sizeof(CARD16) /* sizeof length of Base name */
+ + length; /* sizeof Base font name list */
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ buf_s[0] = (INT16)length; /* length of Base font name */
+ (void)memcpy((char *)&buf_s[1], base_name, length);
+ /* Base font name list */
+ *len = ret_len;
+ break;
+ }
+
+ case XimType_XIMHotKeyTriggers:
+ {
+ XIMHotKeyTriggers *hotkey = (XIMHotKeyTriggers *)value;
+ INT32 num;
+ CARD32 *buf_l = (CARD32 *)buf;
+ register CARD32 *key = (CARD32 *)&buf_l[1];
+ register int i;
+
+ if (!hotkey) {
+ *len = 0;
+ return False;
+ }
+ num = (INT32)hotkey->num_hot_key;
+
+ ret_len = sizeof(INT32) /* sizeof number of key list */
+ + (sizeof(CARD32) /* sizeof keysyn */
+ + sizeof(CARD32) /* sizeof modifier */
+ + sizeof(CARD32)) /* sizeof modifier_mask */
+ * num; /* number of key list */
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ buf_l[0] = num; /* number of key list */
+ for (i = 0; i < num; i++, key += 3) {
+ key[0] = (CARD32)(hotkey->key[i].keysym);
+ /* keysym */
+ key[1] = (CARD32)(hotkey->key[i].modifier);
+ /* modifier */
+ key[2] = (CARD32)(hotkey->key[i].modifier_mask);
+ /* modifier_mask */
+ }
+ *len = ret_len;
+ break;
+ }
+
+ case XimType_XIMStringConversion:
+ {
+ *len = 0;
+ break;
+ }
+
+ default:
+ return False;
+ }
+ return True;
+}
+
+Private Bool
+_XimSetInnerIMAttributes(
+ Xim im,
+ XPointer top,
+ XIMArg *arg,
+ unsigned long mode)
+{
+ XIMResourceList res;
+ int check;
+
+ if (!(res = _XimGetResourceListRec(im->private.proto.im_inner_resources,
+ im->private.proto.im_num_inner_resources, arg->name)))
+ return False;
+
+ check = _XimCheckIMMode(res, mode);
+ if(check == XIM_CHECK_INVALID)
+ return True;
+ else if(check == XIM_CHECK_ERROR)
+ return False;
+
+ return _XimEncodeLocalIMAttr(res, top, arg->value);
+}
+
+Public char *
+_XimEncodeIMATTRIBUTE(
+ Xim im,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ XIMArg *arg,
+ XIMArg **arg_ret,
+ char *buf,
+ int size,
+ int *ret_len,
+ XPointer top,
+ unsigned long mode)
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+ CARD16 *buf_s;
+ int len;
+ int min_len = sizeof(CARD16) /* sizeof attribute ID */
+ + sizeof(INT16); /* sizeof value length */
+
+ *ret_len = 0;
+ for (p = arg; p->name; p++) {
+ if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
+ if (_XimSetInnerIMAttributes(im, top, p, mode))
+ continue;
+ return p->name;
+ }
+
+ check = _XimCheckIMMode(res, mode);
+ if (check == XIM_CHECK_INVALID)
+ continue;
+ else if (check == XIM_CHECK_ERROR)
+ return p->name;
+
+ if (!(_XimEncodeLocalIMAttr(res, top, p->value)))
+ return p->name;
+
+ buf_s = (CARD16 *)buf;
+ if (!(_XimValueToAttribute(res, (XPointer)&buf_s[2], (size - min_len),
+ p->value, &len, mode, (XPointer)NULL)))
+ return p->name;
+
+ if (len == 0) {
+ continue;
+ } else if (len < 0) {
+ *arg_ret = p;
+ return (char *)NULL;
+ }
+
+ buf_s[0] = res->id; /* attribute ID */
+ buf_s[1] = len; /* value length */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += min_len;
+
+ buf += len;
+ *ret_len += len;
+ size -= len;
+ }
+ *arg_ret = (XIMArg *)NULL;
+ return (char *)NULL;
+}
+
+#ifdef XIM_CONNECTABLE
+Public Bool
+_XimEncodeSavedIMATTRIBUTE(
+ Xim im,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ int *idx,
+ char *buf,
+ int size,
+ int *ret_len,
+ XPointer top,
+ unsigned long mode)
+{
+ register int i;
+ int num = im->private.proto.num_saved_imvalues;
+ XrmQuark *quark_list = im->private.proto.saved_imvalues;
+ XIMResourceList res;
+ XPointer value;
+ CARD16 *buf_s;
+ int len;
+ int min_len = sizeof(CARD16) /* sizeof attribute ID */
+ + sizeof(INT16); /* sizeof value length */
+
+ if (!im->private.proto.saved_imvalues) {
+ *idx = -1;
+ *ret_len = 0;
+ return True;
+ }
+
+ *ret_len = 0;
+ for (i = *idx; i < num; i++) {
+ if (!(res = _XimGetResourceListRecByQuark(res_list,
+ res_num, quark_list[i])))
+ continue;
+
+ if (!_XimDecodeLocalIMAttr(res, top, value))
+ return False;
+
+ buf_s = (CARD16 *)buf;
+ if (!(_XimValueToAttribute(res, (XPointer)&buf_s[2],
+ (size - min_len), value, &len, mode, (XPointer)NULL)))
+ return False;
+
+ if (len == 0) {
+ continue;
+ } else if (len < 0) {
+ *idx = i;
+ return True;
+ }
+
+ buf_s[0] = res->id; /* attribute ID */
+ buf_s[1] = len; /* value length */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += min_len;
+
+ buf += len;
+ *ret_len += len;
+ size -= len;
+ }
+ *idx = -1;
+ return True;
+}
+#endif /* XIM_CONNECTABLE */
+
+Private Bool
+_XimEncodeTopValue(
+ Xic ic,
+ XIMResourceList res,
+ XIMArg *p)
+{
+ if (res->xrm_name == XrmStringToQuark(XNClientWindow)) {
+ ic->core.client_window = (Window)p->value;
+ if (ic->core.focus_window == (Window)0)
+ ic->core.focus_window = ic->core.client_window;
+ _XimRegisterFilter(ic);
+
+ } else if (res->xrm_name == XrmStringToQuark(XNFocusWindow)) {
+ if (ic->core.client_window) {
+ _XimUnregisterFilter(ic);
+ ic->core.focus_window = (Window)p->value;
+ _XimRegisterFilter(ic);
+ } else /* client_window not yet */
+ ic->core.focus_window = (Window)p->value;
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodePreeditValue(
+ Xic ic,
+ XIMResourceList res,
+ XIMArg *p)
+{
+ if (res->xrm_name == XrmStringToQuark(XNStdColormap)) {
+ XStandardColormap *colormap_ret;
+ int count;
+
+ if (!(XGetRGBColormaps(ic->core.im->core.display,
+ ic->core.focus_window, &colormap_ret,
+ &count, (Atom)p->value)))
+ return False;
+
+ } else if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
+ int list_ret;
+ XFontStruct **struct_list;
+ char **name_list;
+ char *tmp;
+ int len;
+ register int i;
+
+ if (!p->value)
+ return False;
+
+ if (ic->private.proto.preedit_font)
+ Xfree(ic->private.proto.preedit_font);
+
+ list_ret = XFontsOfFontSet((XFontSet)p->value,
+ &struct_list, &name_list);
+ for (i = 0, len = 0; i < list_ret; i++) {
+ len += (strlen(name_list[i]) + sizeof(char));
+ }
+ if (!(tmp = Xmalloc(len + 1))) {
+ ic->private.proto.preedit_font = NULL;
+ return False;
+ }
+
+ tmp[0] = '\0';
+ for (i = 0; i < list_ret; i++) {
+ strcat(tmp, name_list[i]);
+ strcat(tmp, ",");
+ }
+ tmp[len - 1] = 0;
+ ic->private.proto.preedit_font = tmp;
+ ic->private.proto.preedit_font_length = len - 1;
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodeStatusValue(
+ Xic ic,
+ XIMResourceList res,
+ XIMArg *p)
+{
+ if (res->xrm_name == XrmStringToQuark(XNStdColormap)) {
+ XStandardColormap *colormap_ret;
+ int count;
+
+ if (!(XGetRGBColormaps(ic->core.im->core.display,
+ ic->core.focus_window, &colormap_ret,
+ &count, (Atom)p->value)))
+ return False;
+
+ } else if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
+ int list_ret;
+ XFontStruct **struct_list;
+ char **name_list;
+ char *tmp;
+ int len;
+ register int i;
+
+ if (!p->value)
+ return False;
+
+ if (ic->private.proto.status_font)
+ Xfree(ic->private.proto.status_font);
+
+ list_ret = XFontsOfFontSet((XFontSet)p->value,
+ &struct_list, &name_list);
+ for (i = 0, len = 0; i < list_ret; i++) {
+ len += (strlen(name_list[i]) + sizeof(char));
+ }
+ if (!(tmp = Xmalloc(len+1))) {
+ ic->private.proto.status_font = NULL;
+ return False;
+ }
+
+ tmp[0] = '\0';
+ for(i = 0; i < list_ret; i++) {
+ strcat(tmp, name_list[i]);
+ strcat(tmp, ",");
+ }
+ tmp[len - 1] = 0;
+ ic->private.proto.status_font = tmp;
+ ic->private.proto.status_font_length = len - 1;
+ }
+ return True;
+}
+
+Private Bool
+_XimSetInnerICAttributes(
+ Xic ic,
+ XPointer top,
+ XIMArg *arg,
+ unsigned long mode)
+{
+ XIMResourceList res;
+ int check;
+
+ if (!(res = _XimGetResourceListRec(ic->private.proto.ic_inner_resources,
+ ic->private.proto.ic_num_inner_resources, arg->name)))
+ return False;
+
+ check = _XimCheckICMode(res, mode);
+ if(check == XIM_CHECK_INVALID)
+ return True;
+ else if(check == XIM_CHECK_ERROR)
+ return False;
+
+ return _XimEncodeLocalICAttr(ic, res, top, arg, mode);
+}
+
+Public char *
+_XimEncodeICATTRIBUTE(
+ Xic ic,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ XIMArg *arg,
+ XIMArg **arg_ret,
+ char *buf,
+ int size,
+ int *ret_len,
+ XPointer top,
+ BITMASK32 *flag,
+ unsigned long mode)
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+ CARD16 *buf_s;
+ int len;
+ int min_len = sizeof(CARD16) /* sizeof attribute ID */
+ + sizeof(INT16); /* sizeof value length */
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+ char *name;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ *ret_len = 0;
+ for (p = arg; p && p->name; p++) {
+ buf_s = (CARD16 *)buf;
+ if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
+ if (_XimSetInnerICAttributes(ic, top, p, mode))
+ continue;
+ return p->name;
+ }
+
+ check = _XimCheckICMode(res, mode);
+ if (check == XIM_CHECK_INVALID)
+ continue;
+ else if (check == XIM_CHECK_ERROR)
+ return p->name;
+
+ if (mode & XIM_PREEDIT_ATTR) {
+ if (!(_XimEncodePreeditValue(ic, res, p)))
+ return p->name;
+ } else if (mode & XIM_STATUS_ATTR) {
+ if (!(_XimEncodeStatusValue(ic, res, p)))
+ return p->name;
+ } else {
+ if (!(_XimEncodeTopValue(ic, res, p)))
+ return p->name;
+ }
+
+ if (res->resource_size == XimType_NEST) {
+ XimDefICValues *ic_attr = (XimDefICValues *)top;
+
+ if (res->xrm_name == pre_quark) {
+ XIMArg *arg_rt;
+ if ((name = _XimEncodeICATTRIBUTE(ic, res_list, res_num,
+ (XIMArg *)p->value, &arg_rt,
+ (char *)&buf_s[2], (size - min_len),
+ &len, (XPointer)&ic_attr->preedit_attr, flag,
+ (mode | XIM_PREEDIT_ATTR)))) {
+ return name;
+ }
+
+ } else if (res->xrm_name == sts_quark) {
+ XIMArg *arg_rt;
+ if ((name = _XimEncodeICATTRIBUTE(ic, res_list, res_num,
+ (XIMArg *)p->value, &arg_rt,
+ (char *)&buf_s[2], (size - min_len),
+ &len, (XPointer)&ic_attr->status_attr, flag,
+ (mode | XIM_STATUS_ATTR)))) {
+ return name;
+ }
+ }
+ } else {
+#ifdef EXT_MOVE
+ if (flag)
+ *flag |= _XimExtenArgCheck(p);
+#endif
+ if (!(_XimEncodeLocalICAttr(ic, res, top, p, mode)))
+ return p->name;
+
+ if (!(_XimValueToAttribute(res, (XPointer)&buf_s[2],
+ (size - min_len), p->value,
+ &len, mode, (XPointer)ic)))
+ return p->name;
+ }
+
+ if (len == 0) {
+ continue;
+ } else if (len < 0) {
+ *arg_ret = p;
+ return (char *)NULL;
+ }
+
+ buf_s[0] = res->id; /* attribute ID */
+ buf_s[1] = len; /* value length */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += min_len;
+
+ buf += len;
+ *ret_len += len;
+ size -= len;
+ }
+ *arg_ret = (XIMArg *)NULL;
+ return (char *)NULL;
+}
+
+#ifdef XIM_CONNECTABLE
+Private Bool
+_XimEncodeSavedPreeditValue(
+ Xic ic,
+ XIMResourceList res,
+ XPointer value)
+{
+ int list_ret;
+ XFontStruct **struct_list;
+ char **name_list;
+ char *tmp;
+ int len;
+ register int i;
+
+ if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
+ if (!value)
+ return False;
+
+ if (ic->private.proto.preedit_font)
+ Xfree(ic->private.proto.preedit_font);
+
+ list_ret = XFontsOfFontSet((XFontSet)value,
+ &struct_list, &name_list);
+ for(i = 0, len = 0; i < list_ret; i++) {
+ len += (strlen(name_list[i]) + sizeof(char));
+ }
+ if(!(tmp = Xmalloc(len + 1))) {
+ ic->private.proto.preedit_font = NULL;
+ return False;
+ }
+
+ tmp[0] = '\0';
+ for(i = 0; i < list_ret; i++) {
+ strcat(tmp, name_list[i]);
+ strcat(tmp, ",");
+ }
+ tmp[len - 1] = 0;
+ ic->private.proto.preedit_font = tmp;
+ ic->private.proto.preedit_font_length = len - 1;
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodeSavedStatusValue(
+ Xic ic,
+ XIMResourceList res,
+ XPointer value)
+{
+ int list_ret;
+ XFontStruct **struct_list;
+ char **name_list;
+ char *tmp;
+ int len;
+ register int i;
+
+ if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
+ if (!value)
+ return False;
+
+ if (ic->private.proto.status_font)
+ Xfree(ic->private.proto.status_font);
+
+ list_ret = XFontsOfFontSet((XFontSet)value,
+ &struct_list, &name_list);
+ for(i = 0, len = 0; i < list_ret; i++) {
+ len += (strlen(name_list[i]) + sizeof(char));
+ }
+ if(!(tmp = Xmalloc(len + 1))) {
+ ic->private.proto.status_font = NULL;
+ return False;
+ }
+
+ tmp[0] = '\0';
+ for(i = 0; i < list_ret; i++) {
+ strcat(tmp, name_list[i]);
+ strcat(tmp, ",");
+ }
+ tmp[len - 1] = 0;
+ ic->private.proto.status_font = tmp;
+ ic->private.proto.status_font_length = len - 1;
+ }
+ return True;
+}
+
+Public Bool
+_XimEncodeSavedICATTRIBUTE(
+ Xic ic,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ int *idx,
+ char *buf,
+ int size,
+ int *ret_len,
+ XPointer top,
+ unsigned long mode)
+{
+ int i;
+ int num = ic->private.proto.num_saved_icvalues;
+ XrmQuark *quark_list = ic->private.proto.saved_icvalues;
+ XIMResourceList res;
+ XPointer value;
+ CARD16 *buf_s;
+ int len;
+ int min_len = sizeof(CARD16) /* sizeof attribute ID */
+ + sizeof(INT16); /* sizeof value length */
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+ XrmQuark separator;
+
+ if (!ic->private.proto.saved_icvalues) {
+ *idx = -1;
+ *ret_len = 0;
+ return True;
+ }
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+ separator = XrmStringToQuark(XNSeparatorofNestedList);
+
+ *ret_len = 0;
+ for (i = *idx; i < num; i++) {
+ if (quark_list[i] == separator) {
+ *idx = i;
+ return True;
+ }
+
+ if (!(res = _XimGetResourceListRecByQuark(res_list,
+ res_num, quark_list[i])))
+ continue;
+
+ if (!_XimDecodeLocalICAttr(res, top,(XPointer)&value, mode))
+ return False;
+
+ if (mode & XIM_PREEDIT_ATTR) {
+ if (!(_XimEncodeSavedPreeditValue(ic, res, value))) {
+ return False;
+ }
+ } else if (mode & XIM_STATUS_ATTR) {
+ if (!(_XimEncodeSavedStatusValue(ic, res, value))) {
+ return False;
+ }
+ }
+
+ buf_s = (CARD16 *)buf;
+ if (res->resource_size == XimType_NEST) {
+ XimDefICValues *ic_attr = (XimDefICValues *)top;
+
+ i++;
+ if (res->xrm_name == pre_quark) {
+ if (!_XimEncodeSavedICATTRIBUTE(ic, res_list, res_num,
+ &i, (char *)&buf_s[2], (size - min_len),
+ &len, (XPointer)&ic_attr->preedit_attr,
+ (mode | XIM_PREEDIT_ATTR))) {
+ return False;
+ }
+
+ } else if (res->xrm_name == sts_quark) {
+ if (!_XimEncodeSavedICATTRIBUTE(ic, res_list, res_num,
+ &i, (char *)&buf_s[2], (size - min_len),
+ &len, (XPointer)&ic_attr->status_attr,
+ (mode | XIM_STATUS_ATTR))) {
+ return False;
+ }
+ }
+ } else {
+ if (!(_XimValueToAttribute(res, (XPointer)&buf_s[2],
+ (size - min_len), value,
+ &len, mode, (XPointer)ic))) {
+ return False;
+ }
+ }
+
+ if (len == 0) {
+ continue;
+ } else if (len < 0) {
+ if (quark_list[i] == separator)
+ i++;
+ *idx = i;
+ return True;
+ }
+
+ buf_s[0] = res->id; /* attribute ID */
+ buf_s[1] = len; /* value length */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += min_len;
+
+ buf += len;
+ *ret_len += len;
+ size -= len;
+ }
+ *idx = -1;
+ return True;
+}
+#endif /* XIM_CONNECTABLE */
+
+Private unsigned int
+_XimCountNumberOfAttr(
+ INT16 total,
+ CARD16 *attr,
+ int *names_len)
+{
+ unsigned int n;
+ INT16 len;
+ INT16 min_len = sizeof(CARD16) /* sizeof attrinute ID */
+ + sizeof(CARD16) /* sizeof type of value */
+ + sizeof(INT16); /* sizeof length of attribute */
+
+ n = 0;
+ *names_len = 0;
+ while (total > min_len) {
+ len = attr[2];
+ *names_len += (len + 1);
+ len += (min_len + XIM_PAD(len + 2));
+ total -= len;
+ attr = (CARD16 *)((char *)attr + len);
+ n++;
+ }
+ return n;
+}
+
+Public Bool
+_XimGetAttributeID(
+ Xim im,
+ CARD16 *buf)
+{
+ unsigned int n;
+ XIMResourceList res;
+ int res_len;
+ char *names;
+ int names_len;
+ XPointer tmp;
+ XIMValuesList *values_list;
+ char **values;
+ int values_len;
+ register int i;
+ INT16 len;
+ INT16 min_len = sizeof(CARD16) /* sizeof attrinute ID */
+ + sizeof(CARD16) /* sizeof type of value */
+ + sizeof(INT16); /* sizeof length of attr */
+ /*
+ * IM attribute ID
+ */
+
+ if (!(n = _XimCountNumberOfAttr(buf[0], &buf[1], &names_len)))
+ return False;
+ res_len = sizeof(XIMResource) * n;
+
+ if (!(res = (XIMResourceList)Xmalloc(res_len)))
+ return False;
+ bzero((char *)res, res_len);
+
+ values_len = sizeof(XIMValuesList) + (sizeof(char **) * n) + names_len;
+ if (!(tmp = (XPointer)Xmalloc(values_len)))
+ return False;
+ bzero(tmp, values_len);
+
+ values_list = (XIMValuesList *)tmp;
+ values = (char **)((char *)tmp + sizeof(XIMValuesList));
+ names = (char *)((char *)values + (sizeof(char **) * n));
+
+ values_list->count_values = n;
+ values_list->supported_values = values;
+
+ buf++;
+ for (i = 0; i < n; i++) {
+ len = buf[2];
+ (void)memcpy(names, (char *)&buf[3], len);
+ values[i] = names;
+ names[len] = '\0';
+ res[i].resource_name = names;
+ res[i].resource_size = buf[1];
+ res[i].id = buf[0];
+ names += (len + 1);
+ len += (min_len + XIM_PAD(len + 2));
+ buf = (CARD16 *)((char *)buf + len);
+ }
+ _XIMCompileResourceList(res, n);
+
+ if (im->core.im_resources)
+ Xfree(im->core.im_resources);
+ if (im->core.im_values_list)
+ Xfree(im->core.im_values_list);
+ im->core.im_resources = res;
+ im->core.im_num_resources = n;
+ im->core.im_values_list = values_list;
+
+ /*
+ * IC attribute ID
+ */
+
+ if (!(n = _XimCountNumberOfAttr(buf[0], &buf[2], &names_len)))
+ return False;
+ res_len = sizeof(XIMResource) * n;
+
+ if (!(res = (XIMResourceList)Xmalloc(res_len)))
+ return False;
+ bzero((char *)res, res_len);
+
+ values_len = sizeof(XIMValuesList) + (sizeof(char **) * n) + names_len;
+ if (!(tmp = (XPointer)Xmalloc(values_len)))
+ return False;
+ bzero(tmp, values_len);
+
+ values_list = (XIMValuesList *)tmp;
+ values = (char **)((char *)tmp + sizeof(XIMValuesList));
+ names = (char *)((char *)values + (sizeof(char **) * n));
+
+ values_list->count_values = n;
+ values_list->supported_values = values;
+
+ buf += 2;
+ for (i = 0; i < n; i++) {
+ len = buf[2];
+ (void)memcpy(names, (char *)&buf[3], len);
+ values[i] = names;
+ names[len] = '\0';
+ res[i].resource_name = names;
+ res[i].resource_size = buf[1];
+ res[i].id = buf[0];
+ names += (len + 1);
+ len += (min_len + XIM_PAD(len + 2));
+ buf = (CARD16 *)((char *)buf + len);
+ }
+ _XIMCompileResourceList(res, n);
+
+ if (im->core.ic_resources)
+ Xfree(im->core.ic_resources);
+ if (im->core.ic_values_list)
+ Xfree(im->core.ic_values_list);
+ im->core.ic_resources = res;
+ im->core.ic_num_resources = n;
+ im->core.ic_values_list = values_list;
+
+ return True;
+}
diff --git a/nx-X11/lib/X11/imThaiFlt.c b/nx-X11/lib/X11/imThaiFlt.c
new file mode 100644
index 000000000..18df0e1ff
--- /dev/null
+++ b/nx-X11/lib/X11/imThaiFlt.c
@@ -0,0 +1,1375 @@
+/* $Xorg: imThaiFlt.c,v 1.5 2001/02/09 02:03:39 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.
+
+
+Copyright 1993 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imThaiFlt.c,v 3.22tsi Exp $ */
+
+/*
+**++
+** FACILITY:
+**
+** Xlib
+**
+** ABSTRACT:
+**
+** Thai specific functions.
+** Handles character classifications, composibility checking,
+** Input sequence check and other Thai specific requirements
+** according to WTT specification and DEC extensions.
+**
+** MODIFICATION HISTORY:
+**
+**/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include <X11/keysym.h>
+#include <X11/Xutil.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XimThai.h"
+#include "XlcPubI.h"
+
+
+#define SPACE 32
+
+/* character classification table */
+#define TACTIS_CHARS 256
+Private
+char const tactis_chtype[TACTIS_CHARS] = {
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 0 - 7 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 8 - 15 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 16 - 23 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 24 - 31 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 32 - 39 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 40 - 47 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 48 - 55 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 56 - 63 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 64 - 71 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 72 - 79 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 80 - 87 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 88 - 95 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 96 - 103 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 104 - 111 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 112 - 119 */
+ NON, NON, NON, NON, NON, NON, NON, CTRL, /* 120 - 127 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 128 - 135 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 136 - 143 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 144 - 151 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 152 - 159 */
+ NON, CONS, CONS, CONS, CONS, CONS, CONS, CONS, /* 160 - 167 */
+ CONS, CONS, CONS, CONS, CONS, CONS, CONS, CONS, /* 168 - 175 */
+ CONS, CONS, CONS, CONS, CONS, CONS, CONS, CONS, /* 176 - 183 */
+ CONS, CONS, CONS, CONS, CONS, CONS, CONS, CONS, /* 184 - 191 */
+ CONS, CONS, CONS, CONS, FV3, CONS, FV3, CONS, /* 192 - 199 */
+ CONS, CONS, CONS, CONS, CONS, CONS, CONS, NON, /* 200 - 207 */
+ FV1, AV2, FV1, FV1, AV1, AV3, AV2, AV3, /* 208 - 215 */
+ BV1, BV2, BD, NON, NON, NON, NON, NON, /* 216 - 223 */
+ LV, LV, LV, LV, LV, FV2, NON, AD2, /* 224 - 231 */
+ TONE, TONE, TONE, TONE, AD1, AD1, AD3, NON, /* 232 - 239 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 240 - 247 */
+ NON, NON, NON, NON, NON, NON, NON, CTRL /* 248 - 255 */
+};
+
+/* Composibility checking tables */
+#define NC 0 /* NOT COMPOSIBLE - following char displays in next cell */
+#define CP 1 /* COMPOSIBLE - following char is displayed in the same cell
+ as leading char, also implies ACCEPT */
+#define XC 3 /* Non-display */
+#define AC 4 /* ACCEPT - display the following char in the next cell */
+#define RJ 5 /* REJECT - discard that following char, ignore it */
+
+#define CH_CLASSES 17 /* 17 classes of chars */
+
+Private
+char const write_rules_lookup[CH_CLASSES][CH_CLASSES] = {
+ /* Table 0: writing/outputing rules */
+ /* row: leading char, column: following char */
+/* CTRL NON CONS LV FV1 FV2 FV3 BV1 BV2 BD TONE AD1 AD2 AD3 AV1 AV2 AV3 */
+ {XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*CTRL*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*NON*/
+ ,{XC, NC, NC, NC, NC, NC, NC, CP, CP, CP, CP, CP, CP, CP, CP, CP, CP}/*CONS*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*LV*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*FV1*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*FV2*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*FV3*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, CP, CP, NC, NC, NC, NC, NC}/*BV1*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, CP, NC, NC, NC, NC, NC, NC}/*BV2*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*BD*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*TONE*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*AD1*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*AD2*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*AD3*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, CP, CP, NC, NC, NC, NC, NC}/*AV1*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, CP, NC, NC, NC, NC, NC, NC}/*AV2*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, CP, NC, CP, NC, NC, NC, NC}/*AV3*/
+};
+
+Private
+char const wtt_isc1_lookup[CH_CLASSES][CH_CLASSES] = {
+ /* Table 1: WTT default input sequence check rules */
+ /* row: leading char, column: following char */
+/* CTRL NON CONS LV FV1 FV2 FV3 BV1 BV2 BD TONE AD1 AD2 AD3 AV1 AV2 AV3 */
+ {XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*CTRL*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*NON*/
+ ,{XC, AC, AC, AC, AC, AC, AC, CP, CP, CP, CP, CP, CP, CP, CP, CP, CP}/*CONS*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*LV*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV3*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, CP, RJ, RJ, RJ, RJ, RJ}/*BV1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, RJ, RJ, RJ, RJ, RJ, RJ}/*BV2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*BD*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*TONE*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD3*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, CP, RJ, RJ, RJ, RJ, RJ}/*AV1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, RJ, RJ, RJ, RJ, RJ, RJ}/*AV2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, RJ, CP, RJ, RJ, RJ, RJ}/*AV3*/
+};
+
+Private
+char const wtt_isc2_lookup[CH_CLASSES][CH_CLASSES] = {
+ /* Table 2: WTT strict input sequence check rules */
+ /* row: leading char, column: following char */
+/* CTRL NON CONS LV FV1 FV2 FV3 BV1 BV2 BD TONE AD1 AD2 AD3 AV1 AV2 AV3 */
+ {XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*CTRL*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*NON*/
+ ,{XC, AC, AC, AC, AC, RJ, AC, CP, CP, CP, CP, CP, CP, CP, CP, CP, CP}/*CONS*/
+ ,{XC, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*LV*/
+ ,{XC, AC, AC, AC, AC, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV1*/
+ ,{XC, AC, AC, AC, AC, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV2*/
+ ,{XC, AC, AC, AC, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV3*/
+ ,{XC, AC, AC, AC, AC, RJ, AC, RJ, RJ, RJ, CP, CP, RJ, RJ, RJ, RJ, RJ}/*BV1*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, CP, RJ, RJ, RJ, RJ, RJ, RJ}/*BV2*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*BD*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*TONE*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD1*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD2*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD3*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, CP, CP, RJ, RJ, RJ, RJ, RJ}/*AV1*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, CP, RJ, RJ, RJ, RJ, RJ, RJ}/*AV2*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, CP, RJ, CP, RJ, RJ, RJ, RJ}/*AV3*/
+};
+
+Private
+char const thaicat_isc_lookup[CH_CLASSES][CH_CLASSES] = {
+ /* Table 3: Thaicat input sequence check rules */
+ /* row: leading char, column: following char */
+/* CTRL NON CONS LV FV1 FV2 FV3 BV1 BV2 BD TONE AD1 AD2 AD3 AV1 AV2 AV3 */
+ {XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*CTRL*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*NON*/
+ ,{XC, AC, AC, AC, AC, AC, AC, CP, CP, CP, CP, CP, CP, CP, CP, CP, CP}/*CONS*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*LV*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ} /*FV3*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, CP, RJ, RJ, RJ, RJ, RJ}/*BV1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, RJ, RJ, RJ, RJ, RJ, RJ}/*BV2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*BD*/
+ ,{XC, AC, AC, AC, AC, AC, AC, CP, CP, RJ, RJ, RJ, RJ, RJ, CP, CP, CP}/*TONE*/
+ ,{XC, AC, AC, AC, AC, AC, AC, CP, RJ, RJ, RJ, RJ, RJ, RJ, CP, RJ, RJ}/*AD1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, CP}/*AD2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD3*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, CP, RJ, RJ, RJ, RJ, RJ}/*AV1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, RJ, RJ, RJ, RJ, RJ, RJ}/*AV2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, RJ, CP, RJ, RJ, RJ, RJ}/*AV3*/
+};
+
+
+/* returns classification of a char */
+Private int
+THAI_chtype (unsigned char ch)
+{
+ return tactis_chtype[ch];
+}
+
+#ifdef UNUSED
+/* returns the display level */
+Private int
+THAI_chlevel (unsigned char ch)
+{
+ int chlevel;
+
+ switch (tactis_chtype[ch])
+ {
+ case CTRL:
+ chlevel = NON;
+ break;
+ case BV1:
+ case BV2:
+ case BD:
+ chlevel = BELOW;
+ break;
+ case TONE:
+ case AD1:
+ case AD2:
+ chlevel = TOP;
+ break;
+ case AV1:
+ case AV2:
+ case AV3:
+ case AD3:
+ chlevel = ABOVE;
+ break;
+ case NON:
+ case CONS:
+ case LV:
+ case FV1:
+ case FV2:
+ case FV3:
+ default: /* if tactis_chtype is invalid */
+ chlevel = BASE;
+ break;
+ }
+ return chlevel;
+}
+
+
+/* return True if char is non-spacing */
+Private Bool
+THAI_isdead (unsigned char ch)
+{
+ return ((tactis_chtype[ch] == CTRL) || (tactis_chtype[ch] == BV1) ||
+ (tactis_chtype[ch] == BV2) || (tactis_chtype[ch] == BD) ||
+ (tactis_chtype[ch] == TONE) || (tactis_chtype[ch] == AD1) ||
+ (tactis_chtype[ch] == AD2) || (tactis_chtype[ch] == AD3) ||
+ (tactis_chtype[ch] == AV1) || (tactis_chtype[ch] == AV2) ||
+ (tactis_chtype[ch] == AV3));
+}
+
+
+/* return True if char is consonant */
+Private Bool
+THAI_iscons (unsigned char ch)
+{
+ return (tactis_chtype[ch] == CONS);
+}
+
+
+/* return True if char is vowel */
+Private Bool
+THAI_isvowel (unsigned char ch)
+{
+ return ((tactis_chtype[ch] == LV) || (tactis_chtype[ch] == FV1) ||
+ (tactis_chtype[ch] == FV2) || (tactis_chtype[ch] == FV3) ||
+ (tactis_chtype[ch] == BV1) || (tactis_chtype[ch] == BV2) ||
+ (tactis_chtype[ch] == AV1) || (tactis_chtype[ch] == AV2) ||
+ (tactis_chtype[ch] == AV3));
+}
+
+
+/* return True if char is tonemark */
+Private Bool
+THAI_istone (unsigned char ch)
+{
+ return (tactis_chtype[ch] == TONE);
+}
+#endif
+
+Private Bool
+THAI_iscomposible (
+ unsigned char follow_ch,
+ unsigned char lead_ch)
+{/* "Can follow_ch be put in the same display cell as lead_ch?" */
+
+ return (write_rules_lookup[THAI_chtype(lead_ch)][THAI_chtype(follow_ch)]
+ == CP);
+}
+
+Private Bool
+THAI_isaccepted (
+ unsigned char follow_ch,
+ unsigned char lead_ch,
+ unsigned char mode)
+{
+ Bool iskeyvalid; /* means "Can follow_ch be keyed in after lead_ch?" */
+
+ switch (mode)
+ {
+ case WTT_ISC1:
+ iskeyvalid =
+ (wtt_isc1_lookup[THAI_chtype(lead_ch)][THAI_chtype(follow_ch)] != RJ);
+ break;
+ case WTT_ISC2:
+ iskeyvalid =
+ (wtt_isc2_lookup[THAI_chtype(lead_ch)][THAI_chtype(follow_ch)] != RJ);
+ break;
+ case THAICAT_ISC:
+ iskeyvalid =
+ (thaicat_isc_lookup[THAI_chtype(lead_ch)][THAI_chtype(follow_ch)] != RJ);
+ break;
+ default:
+ iskeyvalid = True;
+ break;
+ }
+
+ return iskeyvalid;
+}
+
+#ifdef UNUSED
+Private void
+THAI_apply_write_rules(
+ unsigned char *instr,
+ unsigned char *outstr,
+ unsigned char insert_ch,
+ int *num_insert_ch)
+{
+/*
+Input parameters:
+ instr - input string
+ insert_ch specify what char to be added when invalid composition is found
+Output parameters:
+ outstr - output string after input string has been applied the rules
+ num_insert_ch - number of insert_ch added to outstr.
+*/
+ unsigned char *lead_ch = NULL, *follow_ch = NULL, *out_ch = NULL;
+
+ *num_insert_ch = 0;
+ lead_ch = follow_ch = instr;
+ out_ch = outstr;
+ if ((*lead_ch == '\0') || !(THAI_find_chtype(instr,DEAD)))
+ { /* Empty string or can't find any non-spacing char*/
+ strcpy((char *)outstr, (char *)instr);
+ } else { /* String of length >= 1, keep looking */
+ follow_ch++;
+ if (THAI_isdead(*lead_ch)) { /* is first char non-spacing? */
+ *out_ch++ = SPACE;
+ (*num_insert_ch)++;
+ }
+ *out_ch++ = *lead_ch;
+ while (*follow_ch != '\0') /* more char in string to check */
+ {
+ if (THAI_isdead(*follow_ch) &&
+ !THAI_iscomposible(*follow_ch,*lead_ch))
+ {
+ *out_ch++ = SPACE;
+ (*num_insert_ch)++;
+ }
+ *out_ch++ = *follow_ch;
+ lead_ch = follow_ch;
+ follow_ch++;
+ }
+ *out_ch = '\0';
+ }
+}
+
+Private int
+THAI_find_chtype (
+ unsigned char *instr,
+ int chtype)
+{
+/*
+Input parameters:
+ instr - input string
+ chtype - type of character to look for
+Output parameters:
+ function returns first position of character with matched chtype
+ function returns -1 if it does not find.
+*/
+ int i = 0, position = -1;
+
+ switch (chtype)
+ {
+ case DEAD:
+ for (i = 0; *instr != '\0' && THAI_isdead(*instr); i++, instr++)
+ ;
+ if (*instr != '\0') position = i;
+ break;
+ default:
+ break;
+ }
+ return position;
+}
+
+
+Private int
+THAI_apply_scm(
+ unsigned char *instr,
+ unsigned char *outstr,
+ unsigned char spec_ch,
+ int num_sp,
+ unsigned char insert_ch)
+{
+ unsigned char *scan, *outch;
+ int i, dead_count, found_count;
+ Bool isconsecutive;
+
+ scan = instr;
+ outch = outstr;
+ dead_count = found_count = 0;
+ isconsecutive = False;
+ while (*scan != '\0') {
+ if (THAI_isdead(*scan))
+ dead_count++; /* count number of non-spacing char */
+ if (*scan == spec_ch)
+ if (!isconsecutive)
+ found_count++; /* count number consecutive spec char found */
+ *outch++ = *scan++;
+ if (found_count == num_sp) {
+ for (i = 0; i < dead_count; i++)
+ *outch++ = insert_ch;
+ dead_count = found_count = 0;
+ }
+ }
+ /* what to return? */
+ return 0; /* probably not right but better than returning garbage */
+}
+
+
+/* The following functions are copied from XKeyBind.c */
+
+Private void ComputeMaskFromKeytrans();
+Private int IsCancelComposeKey(KeySym *symbol, XKeyEvent *event);
+Private void SetLed(Display *dpy, int num, int state);
+Private CARD8 FindKeyCode();
+
+
+/* The following functions are specific to this module */
+
+Private int XThaiTranslateKey();
+Private int XThaiTranslateKeySym();
+
+
+Private KeySym HexIMNormalKey(
+ XicThaiPart *thai_part,
+ KeySym symbol,
+ XKeyEvent *event);
+Private KeySym HexIMFirstComposeKey(
+ XicThaiPart *thai_part,
+ KeySym symbol,
+ XKeyEvent *event);
+Private KeySym HexIMSecondComposeKey(
+ XicThaiPart *thai_part,
+ KeySym symbol
+ XKeyEvent *event);
+Private KeySym HexIMComposeSequence(KeySym ks1, KeySym ks2);
+Private void InitIscMode(Xic ic);
+Private Bool ThaiComposeConvert(
+ Display *dpy,
+ KeySym insym,
+ KeySym *outsym, KeySym *lower, KeySym *upper);
+#endif
+
+/*
+ * Definitions
+ */
+
+#define BellVolume 0
+
+#define ucs2tis(wc) \
+ (unsigned char) ( \
+ (0<=(wc)&&(wc)<=0x7F) ? \
+ (wc) : \
+ ((0x0E01<=(wc)&&(wc)<=0x0E5F) ? ((wc)-0x0E00+0xA0) : 0))
+/* "c" is an unsigned char */
+#define tis2ucs(c) \
+ ( \
+ ((c)<=0x7F) ? \
+ (wchar_t)(c) : \
+ ((0x0A1<=(c)) ? ((wchar_t)(c)-0xA0+0x0E00) : 0))
+
+/*
+ * Macros to save and recall last input character in XIC
+ */
+#define IC_SavePreviousChar(ic,ch) \
+ (*((ic)->private.local.context->mb) = (char) (ch))
+#define IC_ClearPreviousChar(ic) \
+ (*((ic)->private.local.context->mb) = 0)
+#define IC_GetPreviousChar(ic) \
+ (IC_RealGetPreviousChar(ic,1))
+#define IC_GetContextChar(ic) \
+ (IC_RealGetPreviousChar(ic,2))
+#define IC_DeletePreviousChar(ic) \
+ (IC_RealDeletePreviousChar(ic))
+
+Private unsigned char
+IC_RealGetPreviousChar(Xic ic, unsigned short pos)
+{
+ XICCallback* cb = &ic->core.string_conversion_callback;
+
+ if (cb && cb->callback) {
+ XIMStringConversionCallbackStruct screc;
+ unsigned char c;
+
+ /* Use a safe value of position = 0 and stretch the range to desired
+ * place, as XIM protocol is unclear here whether it could be negative
+ */
+ screc.position = 0;
+ screc.direction = XIMBackwardChar;
+ screc.operation = XIMStringConversionRetrieval;
+ screc.factor = pos;
+ screc.text = 0;
+
+ (cb->callback)((XIC)ic, cb->client_data, (XPointer)&screc);
+ if (!screc.text)
+ return (unsigned char) *((ic)->private.local.context->mb);
+ if ((screc.text->feedback &&
+ *screc.text->feedback == XIMStringConversionLeftEdge) ||
+ screc.text->length < 1)
+ {
+ c = 0;
+ } else {
+ if (screc.text->encoding_is_wchar) {
+ c = ucs2tis(screc.text->string.wcs[0]);
+ XFree(screc.text->string.wcs);
+ } else {
+ c = screc.text->string.mbs[0];
+ XFree(screc.text->string.mbs);
+ }
+ }
+ XFree(screc.text);
+ return c;
+ } else {
+ return (unsigned char) *((ic)->private.local.context->mb);
+ }
+}
+
+Private unsigned char
+IC_RealDeletePreviousChar(Xic ic)
+{
+ XICCallback* cb = &ic->core.string_conversion_callback;
+
+ if (cb && cb->callback) {
+ XIMStringConversionCallbackStruct screc;
+ unsigned char c;
+
+ screc.position = 0;
+ screc.direction = XIMBackwardChar;
+ screc.operation = XIMStringConversionSubstitution;
+ screc.factor = 1;
+ screc.text = 0;
+
+ (cb->callback)((XIC)ic, cb->client_data, (XPointer)&screc);
+ if (!screc.text) { return 0; }
+ if ((screc.text->feedback &&
+ *screc.text->feedback == XIMStringConversionLeftEdge) ||
+ screc.text->length < 1)
+ {
+ c = 0;
+ } else {
+ if (screc.text->encoding_is_wchar) {
+ c = ucs2tis(screc.text->string.wcs[0]);
+ XFree(screc.text->string.wcs);
+ } else {
+ c = screc.text->string.mbs[0];
+ XFree(screc.text->string.mbs);
+ }
+ }
+ XFree(screc.text);
+ return c;
+ } else {
+ return 0;
+ }
+}
+/*
+ * Input sequence check mode in XIC
+ */
+#define IC_IscMode(ic) ((ic)->private.local.thai.input_mode)
+
+/*
+ * Max. size of string handled by the two String Lookup functions.
+ */
+#define STR_LKUP_BUF_SIZE 256
+
+/*
+ * Size of buffer to contain previous locale name.
+ */
+#define SAV_LOCALE_NAME_SIZE 256
+
+/*
+ * Size of buffer to contain the IM modifier.
+ */
+#define MAXTHAIIMMODLEN 20
+
+#define AllMods (ShiftMask|LockMask|ControlMask| \
+ Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)
+
+
+#define IsISOControlKey(ks) ((ks) >= XK_2 && (ks) <= XK_8)
+
+#define IsValidControlKey(ks) (((((ks)>=XK_A && (ks)<=XK_asciitilde) || \
+ (ks)==XK_space || (ks)==XK_Delete) && \
+ ((ks)!=0)))
+
+#define COMPOSE_LED 2
+
+#ifdef UNUSED
+typedef KeySym (*StateProc)(
+ XicThaiPart *thai_part,
+ KeySym symbol,
+ XKeyEvent *event);
+
+
+/*
+ * macros to classify XKeyEvent state field
+ */
+
+#define IsShift(state) (((state) & ShiftMask) != 0)
+#define IsLock(state) (((state) & LockMask) != 0)
+#define IsControl(state) (((state) & ControlMask) != 0)
+#define IsMod1(state) (((state) & Mod1Mask) != 0)
+#define IsMod2(state) (((state) & Mod2Mask) != 0)
+#define IsMod3(state) (((state) & Mod3Mask) != 0)
+#define IsMod4(state) (((state) & Mod4Mask) != 0)
+#define IsMod5(state) (((state) & Mod5Mask) != 0)
+
+/*
+ * key starts Thai compose sequence (Hex input method) if :
+ */
+
+#define IsComposeKey(ks, event) \
+ (( ks==XK_Alt_L && \
+ IsControl((event)->state) && \
+ !IsShift((event)->state)) \
+ ? True : False)
+
+
+/*
+ * State handler to implement the Thai hex input method.
+ */
+
+Private int const nstate_handlers = 3;
+Private StateProc state_handler[] = {
+ HexIMNormalKey,
+ HexIMFirstComposeKey,
+ HexIMSecondComposeKey
+};
+
+
+/*
+ * Table for 'Thai Compose' character input.
+ * The current implementation uses latin-1 keysyms.
+ */
+struct _XMapThaiKey {
+ KeySym from;
+ KeySym to;
+};
+
+Private struct _XMapThaiKey const ThaiComposeTable[] = {
+ { /* 0xa4 */ XK_currency, /* 0xa5 */ XK_yen },
+ { /* 0xa2 */ XK_cent, /* 0xa3 */ XK_sterling },
+ { /* 0xe6 */ XK_ae, /* 0xef */ XK_idiaeresis },
+ { /* 0xd3 */ XK_Oacute, /* 0xee */ XK_icircumflex },
+ { /* 0xb9 */ XK_onesuperior, /* 0xfa */ XK_uacute },
+ { /* 0xd2 */ XK_Ograve, /* 0xe5 */ XK_aring },
+ { /* 0xbc */ XK_onequarter, /* 0xfb */ XK_ucircumflex },
+ { XK_VoidSymbol, XK_VoidSymbol }
+};
+
+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 */
+};
+
+
+/* Convert keysym to 'Thai Compose' keysym */
+/* The current implementation use latin-1 keysyms */
+Private Bool
+ThaiComposeConvert(
+ Display *dpy,
+ KeySym insym,
+ KeySym *outsym, KeySym *lower, KeySym *upper)
+{
+ struct _XMapThaiKey const *table_entry = ThaiComposeTable;
+
+ while (table_entry->from != XK_VoidSymbol) {
+ if (table_entry->from == insym) {
+ *outsym = table_entry->to;
+ *lower = *outsym;
+ *upper = *outsym;
+ return True;
+ }
+ table_entry++;
+ }
+ return False;
+}
+
+Private int
+XThaiTranslateKey(
+ register Display *dpy,
+ KeyCode keycode,
+ register unsigned int modifiers,
+ unsigned int *modifiers_return,
+ KeySym *keysym_return,
+ KeySym *lsym_return,
+ KeySym *usym_return)
+{
+ int per;
+ register KeySym *syms;
+ KeySym sym = 0, lsym = 0, usym = 0;
+
+ if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+ return 0;
+ *modifiers_return = (ShiftMask|LockMask) | dpy->mode_switch;
+ 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 & ShiftMask) &&
+ (!(modifiers & LockMask) || (dpy->lock_meaning == NoSymbol))) {
+ if ((per == 1) || (syms[1] == NoSymbol))
+ XConvertCase(syms[0], keysym_return, &usym);
+ else {
+ XConvertCase(syms[0], &lsym, &usym);
+ *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;
+ }
+ /*
+ * ThaiCat keyboard support :
+ * When the Shift and Thai keys are hold for some keys a 'Thai Compose'
+ * character code is generated which is different from column 3 and
+ * 4 of the keymap.
+ * Since we don't know whether ThaiCat keyboard or WTT keyboard is
+ * in use, the same mapping is done for all Thai input.
+ * We just arbitary choose to use column 3 keysyms as the indices of
+ * this mapping.
+ * When the control key is also hold, this mapping has no effect.
+ */
+ if ((modifiers & Mod1Mask) &&
+ (modifiers & ShiftMask) &&
+ !(modifiers & ControlMask)) {
+ if (ThaiComposeConvert(dpy, syms[0], &sym, &lsym, &usym))
+ *keysym_return = sym;
+ }
+
+ if (*keysym_return == XK_VoidSymbol)
+ *keysym_return = NoSymbol;
+ *lsym_return = lsym;
+ *usym_return = usym;
+ return 1;
+}
+
+/*
+ * XThaiTranslateKeySym
+ *
+ * Translate KeySym to TACTIS code output.
+ * The current implementation uses ISO latin-1 keysym.
+ * Should be changed to TACTIS keysyms when they are defined by the
+ * standard.
+ */
+Private int
+XThaiTranslateKeySym(
+ Display *dpy,
+ register KeySym symbol,
+ register KeySym lsym,
+ register KeySym usym,
+ unsigned int modifiers,
+ unsigned char *buffer,
+ int nbytes)
+{
+ KeySym ckey = 0;
+ register struct _XKeytrans *p;
+ int length;
+ unsigned long hiBytes;
+ register unsigned char c;
+
+ /*
+ * initialize length = 1 ;
+ */
+ length = 1;
+
+ 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 TACTIS, 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_Scroll_Lock) ||
+#ifdef DXK_PRIVATE /* DEC private keysyms */
+ (symbol == DXK_Remove) ||
+#endif
+ (symbol == NoSymbol) ||
+ (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 */
+/* not for Thai
+ else if (symbol == XK_hyphen)
+ c = XK_minus & 0xFF; */ /* map to equiv character */
+ 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 (!(IsKeypadKey(lsym) || lsym==XK_Return || lsym==XK_Tab)) {
+ if (IsISOControlKey(lsym)) ckey = lsym;
+ else if (IsISOControlKey(usym)) ckey = usym;
+ else if (lsym == XK_question) ckey = lsym;
+ else if (usym == XK_question) ckey = usym;
+ else if (IsValidControlKey(lsym)) ckey = lsym;
+ else if (IsValidControlKey(usym)) ckey = usym;
+ else length = 0;
+
+ if (length != 0) {
+ if (ckey == XK_2) c = '\000';
+ else if (ckey >= XK_3 && ckey <= XK_7)
+ c = (char)(ckey-('3'-'\033'));
+ else if (ckey == XK_8) c = '\177';
+ else if (ckey == XK_Delete) c = '\030';
+ else if (ckey == XK_question) c = '\037';
+ else if (ckey == XK_quoteleft) c = '\036'; /* KLee 1/24/91 */
+ else c = (char)(ckey & 0x1f);
+ }
+ }
+ }
+ /*
+ * ThaiCat has a key that generates two TACTIS codes D1 & E9.
+ * It is represented by the latin-1 keysym XK_thorn (0xfe).
+ * If c is XK_thorn, this key is pressed and it is converted to
+ * 0xd1 0xe9.
+ */
+ if (c == XK_thorn) {
+ buffer[0] = 0xd1;
+ buffer[1] = 0xe9;
+ buffer[2] = '\0';
+ return 2;
+ }
+ else {
+ /* Normal case */
+ buffer[0] = c;
+ buffer[1] = '\0';
+ return 1;
+ }
+}
+
+/*
+ * given a KeySym, returns the first keycode containing it, if any.
+ */
+Private CARD8
+FindKeyCode(
+ register Display *dpy,
+ register KeySym code)
+{
+
+ register KeySym *kmax = dpy->keysyms +
+ (dpy->max_keycode - dpy->min_keycode + 1) * dpy->keysyms_per_keycode;
+ register KeySym *k = dpy->keysyms;
+ while (k < kmax) {
+ if (*k == code)
+ return (((k - dpy->keysyms) / dpy->keysyms_per_keycode) +
+ dpy->min_keycode);
+ k += 1;
+ }
+ return 0;
+}
+
+/*
+ * 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.
+ */
+Private void
+ComputeMaskFromKeytrans(
+ Display *dpy,
+ register struct _XKeytrans *p)
+{
+ register int i;
+ register CARD8 code;
+ register XModifierKeymap *m = dpy->modifiermap;
+
+ p->state = AnyModifier;
+ for (i = 0; i < p->mlen; i++) {
+ /* if not found, then not on current keyboard */
+ if ((code = FindKeyCode(dpy, p->modifiers[i])) == 0)
+ return;
+ /* code is now the keycode for the modifier you want */
+ {
+ register int j = m->max_keypermod<<3;
+
+ while ((--j >= 0) && (code != m->modifiermap[j]))
+ ;
+ if (j < 0)
+ return;
+ p->state |= (1<<(j/m->max_keypermod));
+ }
+ }
+ p->state &= AllMods;
+}
+
+/************************************************************************
+ *
+ *
+ * Compose handling routines - compose handlers 0,1,2
+ *
+ *
+ ************************************************************************/
+
+#define NORMAL_KEY_STATE 0
+#define FIRST_COMPOSE_KEY_STATE 1
+#define SECOND_COMPOSE_KEY_STATE 2
+
+Private
+KeySym HexIMNormalKey(
+ XicThaiPart *thai_part,
+ KeySym symbol,
+ XKeyEvent *event)
+{
+ if (IsComposeKey (symbol, event)) /* start compose sequence */
+ {
+ SetLed (event->display,COMPOSE_LED, LedModeOn);
+ thai_part->comp_state = FIRST_COMPOSE_KEY_STATE;
+ return NoSymbol;
+ }
+ return symbol;
+}
+
+
+Private
+KeySym HexIMFirstComposeKey(
+ XicThaiPart *thai_part,
+ KeySym symbol,
+ XKeyEvent *event)
+{
+ if (IsModifierKey (symbol)) return symbol; /* ignore shift etc. */
+ if (IsCancelComposeKey (&symbol, event)) /* cancel sequence */
+ {
+ SetLed (event->display,COMPOSE_LED, LedModeOff);
+ thai_part->comp_state = NORMAL_KEY_STATE;
+ return symbol;
+ }
+ if (IsComposeKey (symbol, event)) /* restart sequence ?? */
+ {
+ return NoSymbol; /* no state change necessary */
+ }
+
+ thai_part->keysym = symbol; /* save key pressed */
+ thai_part->comp_state = SECOND_COMPOSE_KEY_STATE;
+ return NoSymbol;
+}
+
+Private
+KeySym HexIMSecondComposeKey(
+ XicThaiPart *thai_part,
+ KeySym symbol,
+ XKeyEvent *event)
+{
+ if (IsModifierKey (symbol)) return symbol; /* ignore shift etc. */
+ if (IsComposeKey (symbol, event)) /* restart sequence ? */
+ {
+ thai_part->comp_state =FIRST_COMPOSE_KEY_STATE;
+ return NoSymbol;
+ }
+ SetLed (event->display,COMPOSE_LED, LedModeOff);
+ if (IsCancelComposeKey (&symbol, event)) /* cancel sequence ? */
+ {
+ thai_part->comp_state = NORMAL_KEY_STATE;
+ return symbol;
+ }
+
+ if ((symbol = HexIMComposeSequence (thai_part->keysym, symbol))
+ ==NoSymbol)
+ { /* invalid compose sequence */
+ XBell(event->display, BellVolume);
+ }
+ thai_part->comp_state = NORMAL_KEY_STATE; /* reset to normal state */
+ return symbol;
+}
+
+
+/*
+ * Interprets two keysyms entered as hex digits and return the Thai keysym
+ * correspond to the TACTIS code formed.
+ * The current implementation of this routine returns ISO Latin Keysyms.
+ */
+
+Private
+KeySym HexIMComposeSequence(KeySym ks1, KeySym ks2)
+{
+int hi_digit;
+int lo_digit;
+int tactis_code;
+
+ if ((ks1 >= XK_0) && (ks1 <= XK_9))
+ hi_digit = ks1 - XK_0;
+ else if ((ks1 >= XK_A) && (ks1 <= XK_F))
+ hi_digit = ks1 - XK_A + 10;
+ else if ((ks1 >= XK_a) && (ks1 <= XK_f))
+ hi_digit = ks1 - XK_a + 10;
+ else /* out of range */
+ return NoSymbol;
+
+ if ((ks2 >= XK_0) && (ks2 <= XK_9))
+ lo_digit = ks2 - XK_0;
+ else if ((ks2 >= XK_A) && (ks2 <= XK_F))
+ lo_digit = ks2 - XK_A + 10;
+ else if ((ks2 >= XK_a) && (ks2 <= XK_f))
+ lo_digit = ks2 - XK_a + 10;
+ else /* out of range */
+ return NoSymbol;
+
+ tactis_code = hi_digit * 0x10 + lo_digit ;
+
+ return (KeySym)tactis_code;
+
+}
+
+/*
+ * routine determines
+ * 1) whether key event should cancel a compose sequence
+ * 2) whether cancelling key event should be processed or ignored
+ */
+
+Private
+int IsCancelComposeKey(
+ KeySym *symbol,
+ XKeyEvent *event)
+{
+ if (*symbol==XK_Delete && !IsControl(event->state) &&
+ !IsMod1(event->state)) {
+ *symbol=NoSymbol; /* cancel compose sequence, and ignore key */
+ return True;
+ }
+ if (IsComposeKey(*symbol, event)) return False;
+ return (
+ IsControl (event->state) ||
+ IsMod1(event->state) ||
+ IsKeypadKey (*symbol) ||
+ IsFunctionKey (*symbol) ||
+ IsMiscFunctionKey (*symbol) ||
+#ifdef DXK_PRIVATE /* DEC private keysyms */
+ *symbol == DXK_Remove ||
+#endif
+ IsPFKey (*symbol) ||
+ IsCursorKey (*symbol) ||
+ (*symbol >= XK_Tab && *symbol < XK_Multi_key)
+ ? True : False); /* cancel compose sequence and pass */
+ /* cancelling key through */
+}
+
+
+/*
+ * set specified keyboard LED on or off
+ */
+
+Private
+void SetLed(
+ Display *dpy,
+ int num,
+ int state)
+{
+ XKeyboardControl led_control;
+
+ led_control.led_mode = state;
+ led_control.led = num;
+ XChangeKeyboardControl (dpy, KBLed | KBLedMode, &led_control);
+}
+#endif
+
+/*
+ * Initialize ISC mode from im modifier
+ */
+Private void InitIscMode(Xic ic)
+{
+ Xim im;
+ char *im_modifier_name;
+
+ /* If already defined, just return */
+
+ if (IC_IscMode(ic)) return;
+
+ /* Get IM modifier */
+
+ im = (Xim) XIMOfIC((XIC)ic);
+ im_modifier_name = im->core.im_name;
+
+ /* Match with predefined value, default is Basic Check */
+
+ if (!strncmp(im_modifier_name,"BasicCheck",MAXTHAIIMMODLEN+1))
+ IC_IscMode(ic) = WTT_ISC1;
+ else if (!strncmp(im_modifier_name,"Strict",MAXTHAIIMMODLEN+1))
+ IC_IscMode(ic) = WTT_ISC2;
+ else if (!strncmp(im_modifier_name,"Thaicat",MAXTHAIIMMODLEN+1))
+ IC_IscMode(ic) = THAICAT_ISC;
+ else if (!strncmp(im_modifier_name,"Passthrough",MAXTHAIIMMODLEN+1))
+ IC_IscMode(ic) = NOISC;
+ else
+ IC_IscMode(ic) = WTT_ISC1;
+
+ return;
+}
+
+/*
+ * Helper functions for _XimThaiFilter()
+ */
+Private Bool
+ThaiFltAcceptInput(Xic ic, unsigned char new_char, KeySym symbol)
+{
+ ic->private.local.composed->wc[0] = tis2ucs(new_char);
+ ic->private.local.composed->wc[1] = '\0';
+
+ if ((new_char <= 0x1f) || (new_char == 0x7f))
+ ic->private.local.composed->keysym = symbol;
+ else
+ ic->private.local.composed->keysym = NoSymbol;
+
+ return True;
+}
+
+Private Bool
+ThaiFltReorderInput(Xic ic, unsigned char previous_char, unsigned char new_char)
+{
+ if (!IC_DeletePreviousChar(ic)) return False;
+ ic->private.local.composed->wc[0] = tis2ucs(new_char);
+ ic->private.local.composed->wc[1] = tis2ucs(previous_char);
+ ic->private.local.composed->wc[2] = '\0';
+
+ ic->private.local.composed->keysym = NoSymbol;
+
+ return True;
+}
+
+Private Bool
+ThaiFltReplaceInput(Xic ic, unsigned char new_char, KeySym symbol)
+{
+ if (!IC_DeletePreviousChar(ic)) return False;
+ ic->private.local.composed->wc[0] = tis2ucs(new_char);
+ ic->private.local.composed->wc[1] = '\0';
+
+ if ((new_char <= 0x1f) || (new_char == 0x7f))
+ ic->private.local.composed->keysym = symbol;
+ else
+ ic->private.local.composed->keysym = NoSymbol;
+
+ return True;
+}
+
+/*
+ * Filter function for TACTIS
+ */
+Bool
+_XimThaiFilter(d, w, ev, client_data)
+Display *d;
+Window w;
+XEvent *ev;
+XPointer client_data;
+{
+ Xic ic = (Xic)client_data;
+ KeySym symbol;
+ int isc_mode; /* Thai Input Sequence Check mode */
+ unsigned char previous_char; /* Last inputted Thai char */
+ unsigned char new_char;
+#ifdef UNUSED
+ unsigned int modifiers;
+ KeySym lsym,usym;
+ int state;
+ XicThaiPart *thai_part;
+ char buf[10];
+#endif
+ wchar_t wbuf[10];
+ Bool isReject;
+
+ if ((ev->type != KeyPress)
+ || (ev->xkey.keycode == 0))
+ return False;
+
+ if (!IC_IscMode(ic)) InitIscMode(ic);
+
+ XwcLookupString((XIC)ic, &ev->xkey, wbuf, sizeof(wbuf) / sizeof(wbuf[0]),
+ &symbol, NULL);
+
+ if ((ev->xkey.state & (AllMods & ~ShiftMask)) ||
+ ((symbol >> 8 == 0xFF) &&
+ ((XK_BackSpace <= symbol && symbol <= XK_Clear) ||
+ (symbol == XK_Return) ||
+ (symbol == XK_Pause) ||
+ (symbol == XK_Scroll_Lock) ||
+ (symbol == XK_Sys_Req) ||
+ (symbol == XK_Escape) ||
+ (symbol == XK_Delete) ||
+ IsCursorKey(symbol) ||
+ IsKeypadKey(symbol) ||
+ IsMiscFunctionKey(symbol) ||
+ IsFunctionKey(symbol))))
+ {
+ IC_ClearPreviousChar(ic);
+ return False;
+ }
+ if (((symbol >> 8 == 0xFF) &&
+ IsModifierKey(symbol)) ||
+#ifdef XK_XKB_KEYS
+ ((symbol >> 8 == 0xFE) &&
+ (XK_ISO_Lock <= symbol && symbol <= XK_ISO_Last_Group_Lock)) ||
+#endif
+ (symbol == NoSymbol))
+ {
+ return False;
+ }
+#ifdef UNUSED
+ if (! XThaiTranslateKey(ev->xkey.display, ev->xkey.keycode, ev->xkey.state,
+ &modifiers, &symbol, &lsym, &usym))
+ return False;
+
+ /*
+ * Hex input method processing
+ */
+
+ thai_part = &ic->private.local.thai;
+ state = thai_part->comp_state;
+ if (state >= 0 && state < nstate_handlers) /* call handler for state */
+ {
+ symbol = (* state_handler[state])(thai_part, symbol, (XKeyEvent *)ev);
+ }
+
+ /*
+ * Translate KeySym into mb.
+ */
+ count = XThaiTranslateKeySym(ev->xkey.display, symbol, lsym,
+ usym, ev->xkey.state, buf, 10);
+
+ if (!symbol && !count)
+ return True;
+
+ /* Return symbol if cannot convert to character */
+ if (!count)
+ return False;
+#endif
+
+ /*
+ * Thai Input sequence check
+ */
+ isc_mode = IC_IscMode(ic);
+ if (!(previous_char = IC_GetPreviousChar(ic))) previous_char = ' ';
+ new_char = ucs2tis(wbuf[0]);
+ isReject = True;
+ if (THAI_isaccepted(new_char, previous_char, isc_mode)) {
+ ThaiFltAcceptInput(ic, new_char, symbol);
+ isReject = False;
+ } else {
+ unsigned char context_char;
+
+ context_char = IC_GetContextChar(ic);
+ if (context_char) {
+ if (THAI_iscomposible(new_char, context_char)) {
+ if (THAI_iscomposible(previous_char, new_char)) {
+ isReject = !ThaiFltReorderInput(ic, previous_char, new_char);
+ } else if (THAI_iscomposible(previous_char, context_char)) {
+ isReject = !ThaiFltReplaceInput(ic, new_char, symbol);
+ } else if (THAI_chtype(previous_char) == FV1
+ && THAI_chtype(new_char) == TONE) {
+ isReject = !ThaiFltReorderInput(ic, previous_char, new_char);
+ }
+ } else if (THAI_isaccepted(new_char, context_char, isc_mode)) {
+ isReject = !ThaiFltReplaceInput(ic, new_char, symbol);
+ }
+ }
+ }
+ if (isReject) {
+ /* reject character */
+ XBell(ev->xkey.display, BellVolume);
+ return True;
+ }
+
+ _Xlcwcstombs(ic->core.im->core.lcd, ic->private.local.composed->mb,
+ ic->private.local.composed->wc, 10);
+
+ _Xlcmbstoutf8(ic->core.im->core.lcd, ic->private.local.composed->utf8,
+ ic->private.local.composed->mb, 10);
+
+ /* Remember the last character inputted
+ * (as fallback in case StringConversionCallback is not provided)
+ */
+ IC_SavePreviousChar(ic, new_char);
+
+ ev->xkey.keycode = 0;
+ XPutBackEvent(d, ev);
+ return True;
+}
diff --git a/nx-X11/lib/X11/imThaiIc.c b/nx-X11/lib/X11/imThaiIc.c
new file mode 100644
index 000000000..67d7cc268
--- /dev/null
+++ b/nx-X11/lib/X11/imThaiIc.c
@@ -0,0 +1,233 @@
+/* $Xorg: imThaiIc.c,v 1.3 2000/08/17 19:45:15 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993 by Digital Equipment 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 of FUJITSU LIMITED and
+Digital Equipment Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission. FUJITSU LIMITED and Digital Equipment Corporation
+makes no representations about the suitability of this software for
+any purpose. It is provided "as is" without express or implied
+warranty.
+
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Franky Ling Digital Equipment Corporation
+ frankyling@hgrd01.enet.dec.com
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imThaiIc.c,v 1.4 2001/01/17 19:41:52 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Private void
+_XimThaiUnSetFocus(
+ XIC xic)
+{
+ Xic ic = (Xic)xic;
+ ((Xim)ic->core.im)->private.local.current_ic = (XIC)NULL;
+
+ if (ic->core.focus_window)
+ _XUnregisterFilter(ic->core.im->core.display, ic->core.focus_window,
+ _XimThaiFilter, (XPointer)ic);
+ return;
+}
+
+Private void
+_XimThaiDestroyIC(
+ XIC xic)
+{
+ Xic ic = (Xic)xic;
+ if(((Xim)ic->core.im)->private.local.current_ic == (XIC)ic) {
+ _XimThaiUnSetFocus(xic);
+ }
+ if(ic->private.local.ic_resources) {
+ Xfree(ic->private.local.ic_resources);
+ ic->private.local.ic_resources = NULL;
+ }
+
+ Xfree(ic->private.local.context->mb);
+ Xfree(ic->private.local.context->wc);
+ Xfree(ic->private.local.context->utf8);
+ Xfree(ic->private.local.context);
+ Xfree(ic->private.local.composed->mb);
+ Xfree(ic->private.local.composed->wc);
+ Xfree(ic->private.local.composed->utf8);
+ Xfree(ic->private.local.composed);
+ return;
+}
+
+Private void
+_XimThaiSetFocus(
+ XIC xic)
+{
+ Xic ic = (Xic)xic;
+ XIC current_ic = ((Xim)ic->core.im)->private.local.current_ic;
+
+ if (current_ic == (XIC)ic)
+ return;
+
+ if (current_ic != (XIC)NULL) {
+ _XimThaiUnSetFocus(current_ic);
+ }
+ ((Xim)ic->core.im)->private.local.current_ic = (XIC)ic;
+
+ if (ic->core.focus_window)
+ _XRegisterFilterByType(ic->core.im->core.display, ic->core.focus_window,
+ KeyPress, KeyPress, _XimThaiFilter, (XPointer)ic);
+ return;
+}
+
+Private void
+_XimThaiReset(
+ XIC xic)
+{
+ Xic ic = (Xic)xic;
+ ic->private.local.thai.comp_state = 0;
+ ic->private.local.thai.keysym = 0;
+ ic->private.local.composed->mb[0] = '\0';
+ ic->private.local.composed->wc[0] = 0;
+ ic->private.local.composed->utf8[0] = '\0';
+}
+
+Private char *
+_XimThaiMbReset(
+ XIC xic)
+{
+ _XimThaiReset(xic);
+ return (char *)NULL;
+}
+
+Private wchar_t *
+_XimThaiWcReset(
+ XIC xic)
+{
+ _XimThaiReset(xic);
+ return (wchar_t *)NULL;
+}
+
+Private XICMethodsRec Thai_ic_methods = {
+ _XimThaiDestroyIC, /* destroy */
+ _XimThaiSetFocus, /* set_focus */
+ _XimThaiUnSetFocus, /* unset_focus */
+ _XimLocalSetICValues, /* set_values */
+ _XimLocalGetICValues, /* get_values */
+ _XimThaiMbReset, /* mb_reset */
+ _XimThaiWcReset, /* wc_reset */
+ _XimThaiMbReset, /* utf8_reset */
+ _XimLocalMbLookupString, /* mb_lookup_string */
+ _XimLocalWcLookupString, /* wc_lookup_string */
+ _XimLocalUtf8LookupString /* utf8_lookup_string */
+};
+
+XIC
+_XimThaiCreateIC(
+ XIM im,
+ XIMArg *values)
+{
+ Xic ic;
+ XimDefICValues ic_values;
+ XIMResourceList res;
+ unsigned int num;
+ int len;
+
+ if((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL) {
+ return ((XIC)NULL);
+ }
+ bzero((char *)ic, sizeof(XicRec));
+
+ ic->methods = &Thai_ic_methods;
+ ic->core.im = im;
+ ic->core.filter_events = KeyPressMask;
+ if ((ic->private.local.context = (DefTree *)Xmalloc(sizeof(DefTree)))
+ == (DefTree *)NULL)
+ goto Set_Error;
+ if ((ic->private.local.context->mb = (char *)Xmalloc(10))
+ == (char *)NULL)
+ goto Set_Error;
+ if ((ic->private.local.context->wc = (wchar_t *)Xmalloc(10*sizeof(wchar_t)))
+ == (wchar_t *)NULL)
+ goto Set_Error;
+ if ((ic->private.local.context->utf8 = (char *)Xmalloc(10))
+ == (char *)NULL)
+ goto Set_Error;
+ if ((ic->private.local.composed = (DefTree *)Xmalloc(sizeof(DefTree)))
+ == (DefTree *)NULL)
+ goto Set_Error;
+ if ((ic->private.local.composed->mb = (char *)Xmalloc(10))
+ == (char *)NULL)
+ goto Set_Error;
+ if ((ic->private.local.composed->wc = (wchar_t *)Xmalloc(10*sizeof(wchar_t)))
+ == (wchar_t *)NULL)
+ goto Set_Error;
+ if ((ic->private.local.composed->utf8 = (char *)Xmalloc(10))
+ == (char *)NULL)
+ goto Set_Error;
+
+ ic->private.local.thai.comp_state = 0;
+ ic->private.local.thai.keysym = 0;
+ ic->private.local.thai.input_mode = 0;
+
+ num = im->core.ic_num_resources;
+ len = sizeof(XIMResource) * num;
+ if((res = (XIMResourceList)Xmalloc(len)) == (XIMResourceList)NULL) {
+ goto Set_Error;
+ }
+ (void)memcpy((char *)res, (char *)im->core.ic_resources, len);
+ ic->private.local.ic_resources = res;
+ ic->private.local.ic_num_resources = num;
+
+ bzero((char *)&ic_values, sizeof(XimDefICValues));
+ if(_XimCheckLocalInputStyle(ic, (XPointer)&ic_values, values,
+ im->core.styles, res, num) == False) {
+ goto Set_Error;
+ }
+
+ _XimSetICMode(res, num, ic_values.input_style);
+
+ if(_XimSetICValueData(ic, (XPointer)&ic_values,
+ ic->private.local.ic_resources,
+ ic->private.local.ic_num_resources,
+ values, XIM_CREATEIC, True)) {
+ goto Set_Error;
+ }
+ if(_XimSetICDefaults(ic, (XPointer)&ic_values,
+ XIM_SETICDEFAULTS, res, num) == False) {
+ goto Set_Error;
+ }
+ ic_values.filter_events = KeyPressMask;
+ _XimSetCurrentICValues(ic, &ic_values);
+
+ return ((XIC)ic);
+
+Set_Error :
+ if (ic->private.local.ic_resources) {
+ Xfree(ic->private.local.ic_resources);
+ }
+ Xfree(ic);
+ return((XIC)NULL);
+}
diff --git a/nx-X11/lib/X11/imThaiIm.c b/nx-X11/lib/X11/imThaiIm.c
new file mode 100644
index 000000000..e24715022
--- /dev/null
+++ b/nx-X11/lib/X11/imThaiIm.c
@@ -0,0 +1,235 @@
+/* $Xorg: imThaiIm.c,v 1.3 2000/08/17 19:45:15 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993 by Digital Equipment 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 of FUJITSU LIMITED and
+Digital Equipment Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission. FUJITSU LIMITED and Digital Equipment Corporation
+makes no representations about the suitability of this software for
+any purpose. It is provided "as is" without express or implied
+warranty.
+
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Franky Ling Digital Equipment Corporation
+ frankyling@hgrd01.enet.dec.com
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imThaiIm.c,v 1.7 2001/01/17 19:41:52 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcPublic.h"
+#include "XlcPubI.h"
+#include "Ximint.h"
+
+Private XIMMethodsRec Xim_im_thai_methods = {
+ _XimThaiCloseIM, /* close */
+ _XimLocalSetIMValues, /* set_values */
+ _XimLocalGetIMValues, /* get_values */
+ _XimThaiCreateIC, /* create_ic */
+ _XimLcctstombs, /* ctstombs */
+ _XimLcctstowcs, /* ctstowcs */
+ _XimLcctstoutf8 /* ctstoutf8 */
+};
+
+#define THAI_LANGUAGE_NAME "th"
+
+Bool
+_XimCheckIfThaiProcessing(im)
+ Xim im;
+{
+ char *language;
+
+ _XGetLCValues(im->core.lcd, XlcNLanguage, &language, NULL);
+ if(strcmp(language, THAI_LANGUAGE_NAME) == 0) {
+ return(True);
+ }
+ return(False);
+}
+
+Public Bool
+_XimThaiOpenIM(im)
+ Xim im;
+{
+ XLCd lcd = im->core.lcd;
+ XlcConv conv;
+ XimDefIMValues im_values;
+ XimLocalPrivateRec* private = &im->private.local;
+
+ _XimInitialResourceInfo();
+ if(_XimSetIMResourceList(&im->core.im_resources,
+ &im->core.im_num_resources) == False) {
+ goto Open_Error;
+ }
+ if(_XimSetICResourceList(&im->core.ic_resources,
+ &im->core.ic_num_resources) == False) {
+ goto Open_Error;
+ }
+
+ _XimSetIMMode(im->core.im_resources, im->core.im_num_resources);
+
+ _XimGetCurrentIMValues(im, &im_values);
+ if(_XimSetLocalIMDefaults(im, (XPointer)&im_values,
+ im->core.im_resources, im->core.im_num_resources) == False) {
+ goto Open_Error;
+ }
+ _XimSetCurrentIMValues(im, &im_values);
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte)))
+ goto Open_Error;
+ private->ctom_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar)))
+ goto Open_Error;
+ private->ctow_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNUtf8String)))
+ goto Open_Error;
+ private->ctoutf8_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte)))
+ goto Open_Error;
+ private->cstomb_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNWideChar)))
+ goto Open_Error;
+ private->cstowc_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNUtf8String)))
+ goto Open_Error;
+ private->cstoutf8_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNChar)))
+ goto Open_Error;
+ private->ucstoc_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNUtf8String)))
+ goto Open_Error;
+ private->ucstoutf8_conv = conv;
+
+ im->methods = &Xim_im_thai_methods;
+ private->current_ic = (XIC)NULL;
+
+ return(True);
+
+Open_Error :
+ _XimThaiIMFree(im);
+ return(False);
+}
+
+Public void
+_XimThaiIMFree(im)
+ Xim im;
+{
+ if(im->core.im_resources) {
+ Xfree(im->core.im_resources);
+ im->core.im_resources = NULL;
+ }
+ if(im->core.ic_resources) {
+ Xfree(im->core.ic_resources);
+ im->core.ic_resources = NULL;
+ }
+ if(im->core.im_values_list) {
+ Xfree(im->core.im_values_list);
+ im->core.im_values_list = NULL;
+ }
+ if(im->core.ic_values_list) {
+ Xfree(im->core.ic_values_list);
+ im->core.ic_values_list = NULL;
+ }
+ if(im->core.styles) {
+ Xfree(im->core.styles);
+ im->core.styles = NULL;
+ }
+ if(im->core.res_name) {
+ Xfree(im->core.res_name);
+ im->core.res_name = NULL;
+ }
+ if(im->core.res_class) {
+ Xfree(im->core.res_class);
+ im->core.res_class = NULL;
+ }
+ if(im->core.im_name) {
+ Xfree(im->core.im_name);
+ im->core.im_name = NULL;
+ }
+ if (im->private.local.ctom_conv) {
+ _XlcCloseConverter(im->private.local.ctom_conv);
+ im->private.local.ctom_conv = NULL;
+ }
+ if (im->private.local.ctow_conv) {
+ _XlcCloseConverter(im->private.local.ctow_conv);
+ im->private.local.ctow_conv = NULL;
+ }
+ if (im->private.local.ctoutf8_conv) {
+ _XlcCloseConverter(im->private.local.ctoutf8_conv);
+ im->private.local.ctoutf8_conv = NULL;
+ }
+ if (im->private.local.cstomb_conv) {
+ _XlcCloseConverter(im->private.local.cstomb_conv);
+ im->private.local.cstomb_conv = NULL;
+ }
+ if (im->private.local.cstowc_conv) {
+ _XlcCloseConverter(im->private.local.cstowc_conv);
+ im->private.local.cstowc_conv = NULL;
+ }
+ if (im->private.local.cstoutf8_conv) {
+ _XlcCloseConverter(im->private.local.cstoutf8_conv);
+ im->private.local.cstoutf8_conv = NULL;
+ }
+ if (im->private.local.ucstoc_conv) {
+ _XlcCloseConverter(im->private.local.ucstoc_conv);
+ im->private.local.ucstoc_conv = NULL;
+ }
+ if (im->private.local.ucstoutf8_conv) {
+ _XlcCloseConverter(im->private.local.ucstoutf8_conv);
+ im->private.local.ucstoutf8_conv = NULL;
+ }
+ return;
+}
+
+Public Status
+_XimThaiCloseIM(xim)
+ XIM xim;
+{
+ Xim im = (Xim)xim;
+ XIC ic;
+ XIC next;
+
+ ic = im->core.ic_chain;
+ im->core.ic_chain = NULL;
+ while (ic) {
+ (*ic->methods->destroy) (ic);
+ next = ic->core.next;
+ Xfree ((char *) ic);
+ ic = next;
+ }
+ _XimThaiIMFree(im);
+ return(True);
+}
diff --git a/nx-X11/lib/X11/imTrX.c b/nx-X11/lib/X11/imTrX.c
new file mode 100644
index 000000000..e2de05f28
--- /dev/null
+++ b/nx-X11/lib/X11/imTrX.c
@@ -0,0 +1,491 @@
+/* $Xorg: imTrX.c,v 1.4 2000/08/17 19:45:15 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+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 of Sun Microsystems, Inc.
+and FUJITSU LIMITED not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
+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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imTrX.c,v 1.3 2003/04/13 19:22:21 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <string.h>
+#include <X11/Xatom.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XimTrInt.h"
+#include "XimTrX.h"
+
+Private Bool
+_XimXRegisterDispatcher(
+ Xim im,
+ Bool (*callback)(
+ Xim, INT16, XPointer, XPointer
+ ),
+ XPointer call_data)
+{
+ XIntrCallbackPtr rec;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+
+ if (!(rec = (XIntrCallbackPtr)Xmalloc(sizeof(XIntrCallbackRec))))
+ return False;
+
+ rec->func = callback;
+ rec->call_data = call_data;
+ rec->next = spec->intr_cb;
+ spec->intr_cb = rec;
+ return True;
+}
+
+Private void
+_XimXFreeIntrCallback(
+ Xim im)
+{
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ register XIntrCallbackPtr rec, next;
+
+ for (rec = spec->intr_cb; rec;) {
+ next = rec->next;
+ Xfree(rec);
+ rec = next;
+ }
+ return;
+}
+
+Private Bool
+_XimXCallDispatcher(Xim im, INT16 len, XPointer data)
+{
+ register XIntrCallbackRec *rec;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+
+ for (rec = spec->intr_cb; rec; rec = rec->next) {
+ if ((*rec->func)(im, len, data, rec->call_data))
+ return True;
+ }
+ return False;
+}
+
+Private Bool
+_XimXFilterWaitEvent(
+ Display *d,
+ Window w,
+ XEvent *ev,
+ XPointer arg)
+{
+ Xim im = (Xim)arg;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ Bool ret;
+
+ spec->ev = (XPointer)ev;
+ ret = _XimFilterWaitEvent(im);
+
+ /*
+ * If ev is a pointer to a stack variable, there could be
+ * a coredump later on if the pointer is dereferenced.
+ * Therefore, reset to NULL to force reinitialization in
+ * _XimXRead().
+ *
+ * Keep in mind _XimXRead may be called again when the stack
+ * is very different.
+ */
+ spec->ev = (XPointer)NULL;
+
+ return ret;
+}
+
+Private Bool
+_CheckConnect(
+ Display *display,
+ XEvent *event,
+ XPointer xim)
+{
+ Xim im = (Xim)xim;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+
+ if ((event->type == ClientMessage)
+ && (event->xclient.message_type == spec->imconnectid)) {
+ return True;
+ }
+ return False;
+}
+
+Private Bool
+_XimXConnect(Xim im)
+{
+ XEvent event;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ CARD32 major_code;
+ CARD32 minor_code;
+
+ if (!(spec->lib_connect_wid = XCreateSimpleWindow(im->core.display,
+ DefaultRootWindow(im->core.display), 0, 0, 1, 1, 1, 0, 0))) {
+ return False;
+ }
+
+ event.xclient.type = ClientMessage;
+ event.xclient.display = im->core.display;
+ event.xclient.window = im->private.proto.im_window;
+ event.xclient.message_type = spec->imconnectid;
+ event.xclient.format = 32;
+ event.xclient.data.l[0] = (CARD32)spec->lib_connect_wid;
+ event.xclient.data.l[1] = spec->major_code;
+ event.xclient.data.l[2] = spec->minor_code;
+
+ if(event.xclient.data.l[1] == 1 || event.xclient.data.l[1] == 2) {
+ XWindowAttributes atr;
+ long event_mask;
+
+ XGetWindowAttributes(im->core.display, spec->lib_connect_wid, &atr);
+ event_mask = atr.your_event_mask | PropertyChangeMask;
+ XSelectInput(im->core.display, spec->lib_connect_wid, event_mask);
+ _XRegisterFilterByType(im->core.display, spec->lib_connect_wid,
+ PropertyNotify, PropertyNotify,
+ _XimXFilterWaitEvent, (XPointer)im);
+ }
+
+ XSendEvent(im->core.display, im->private.proto.im_window,
+ False, NoEventMask, &event);
+ XFlush(im->core.display);
+
+ for (;;) {
+ XIfEvent(im->core.display, &event, _CheckConnect, (XPointer)im);
+ if (event.xclient.type != ClientMessage) {
+ return False;
+ }
+ if (event.xclient.message_type == spec->imconnectid)
+ break;
+ }
+
+ spec->ims_connect_wid = (Window)event.xclient.data.l[0];
+ major_code = (CARD32)event.xclient.data.l[1];
+ minor_code = (CARD32)event.xclient.data.l[2];
+
+ if (((major_code == 0) && (minor_code <= 2)) ||
+ ((major_code == 1) && (minor_code == 0)) ||
+ ((major_code == 2) && (minor_code <= 1))) {
+ spec->major_code = major_code;
+ spec->minor_code = minor_code;
+ }
+ if (((major_code == 0) && (minor_code == 2)) ||
+ ((major_code == 2) && (minor_code == 1))) {
+ spec->BoundarySize = (CARD32)event.xclient.data.l[3];
+ }
+
+ /* ClientMessage Event Filter */
+ _XRegisterFilterByType(im->core.display, spec->lib_connect_wid,
+ ClientMessage, ClientMessage,
+ _XimXFilterWaitEvent, (XPointer)im);
+ return True;
+}
+
+Private Bool
+_XimXShutdown(Xim im)
+{
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+
+ if (!spec)
+ return True;
+
+ /* ClientMessage Event Filter */
+ _XUnregisterFilter(im->core.display,
+ ((XSpecRec *)im->private.proto.spec)->lib_connect_wid,
+ _XimXFilterWaitEvent, (XPointer)im);
+ XDestroyWindow(im->core.display,
+ ((XSpecRec *)im->private.proto.spec)->lib_connect_wid);
+ _XimXFreeIntrCallback(im);
+ Xfree(spec);
+ im->private.proto.spec = 0;
+ return True;
+}
+
+Private char *
+_NewAtom(
+ char *atomName)
+{
+ static int sequence = 0;
+
+ (void)sprintf(atomName, "_client%d", sequence);
+ sequence = ((sequence < 20) ? sequence + 1 : 0);
+ return atomName;
+}
+
+Private Bool
+_XimXWrite(Xim im, INT16 len, XPointer data)
+{
+ Atom atom;
+ char atomName[16];
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ XEvent event;
+ CARD8 *p;
+ CARD32 major_code = spec->major_code;
+ CARD32 minor_code = spec->minor_code;
+ int BoundSize;
+
+ bzero(&event,sizeof(XEvent));
+ event.xclient.type = ClientMessage;
+ event.xclient.display = im->core.display;
+ event.xclient.window = spec->ims_connect_wid;
+ if(major_code == 1 && minor_code == 0) {
+ BoundSize = 0;
+ } else if((major_code == 0 && minor_code == 2) ||
+ (major_code == 2 && minor_code == 1)) {
+ BoundSize = spec->BoundarySize;
+ } else if(major_code == 0 && minor_code == 1) {
+ BoundSize = len;
+ } else {
+ BoundSize = XIM_CM_DATA_SIZE;
+ }
+ if (len > BoundSize) {
+ event.xclient.message_type = spec->improtocolid;
+ atom = XInternAtom(im->core.display, _NewAtom(atomName), False);
+ XChangeProperty(im->core.display, spec->ims_connect_wid,
+ atom, XA_STRING, 8, PropModeAppend,
+ (unsigned char *)data, len);
+ if(major_code == 0) {
+ event.xclient.format = 32;
+ event.xclient.data.l[0] = (long)len;
+ event.xclient.data.l[1] = (long)atom;
+ XSendEvent(im->core.display, spec->ims_connect_wid,
+ False, NoEventMask, &event);
+ }
+ } else {
+ int length;
+
+ event.xclient.format = 8;
+ for(length = 0 ; length < len ; length += XIM_CM_DATA_SIZE) {
+ p = (CARD8 *)&event.xclient.data.b[0];
+ if((length + XIM_CM_DATA_SIZE) >= len) {
+ event.xclient.message_type = spec->improtocolid;
+ bzero(p, XIM_CM_DATA_SIZE);
+ memcpy((char *)p, (data + length), (len - length));
+ } else {
+ event.xclient.message_type = spec->immoredataid;
+ memcpy((char *)p, (data + length), XIM_CM_DATA_SIZE);
+ }
+ XSendEvent(im->core.display, spec->ims_connect_wid,
+ False, NoEventMask, &event);
+ }
+ }
+
+ return True;
+}
+
+Private Bool
+_XimXGetReadData(
+ Xim im,
+ char *buf,
+ int buf_len,
+ int *ret_len,
+ XEvent *event)
+{
+ char *data;
+ int len;
+
+ char tmp_buf[XIM_CM_DATA_SIZE];
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ unsigned long length;
+ Atom prop;
+ int return_code;
+ Atom type_ret;
+ int format_ret;
+ unsigned long nitems;
+ unsigned long bytes_after_ret;
+ unsigned char *prop_ret;
+
+ if ((event->type == ClientMessage) &&
+ !((event->xclient.message_type == spec->improtocolid) ||
+ (event->xclient.message_type == spec->immoredataid))) {
+ /* This event has nothing to do with us,
+ * FIXME should not have gotten here then...
+ */
+ return False;
+ } else if ((event->type == ClientMessage) && (event->xclient.format == 8)) {
+ data = event->xclient.data.b;
+ if (buf_len >= XIM_CM_DATA_SIZE) {
+ (void)memcpy(buf, data, XIM_CM_DATA_SIZE);
+ *ret_len = XIM_CM_DATA_SIZE;
+ } else {
+ (void)memcpy(buf, data, buf_len);
+ len = XIM_CM_DATA_SIZE - buf_len;
+ (void)memcpy(tmp_buf, &data[buf_len], len);
+ bzero(data, XIM_CM_DATA_SIZE);
+ (void)memcpy(data, tmp_buf, len);
+ XPutBackEvent(im->core.display, event);
+ *ret_len = buf_len;
+ }
+ } else if ((event->type == ClientMessage)
+ && (event->xclient.format == 32)) {
+ length = (unsigned long)event->xclient.data.l[0];
+ prop = (Atom)event->xclient.data.l[1];
+ return_code = XGetWindowProperty(im->core.display,
+ spec->lib_connect_wid, prop, 0L,
+ (long)((length + 3)/ 4), True, AnyPropertyType,
+ &type_ret, &format_ret, &nitems, &bytes_after_ret, &prop_ret);
+ if (return_code != Success || format_ret == 0 || nitems == 0) {
+ if (return_code == Success)
+ XFree(prop_ret);
+ return False;
+ }
+ if (buf_len >= length) {
+ (void)memcpy(buf, prop_ret, (int)nitems);
+ *ret_len = (int)nitems;
+ if (bytes_after_ret > 0) {
+ XGetWindowProperty(im->core.display,
+ spec->lib_connect_wid, prop, 0L,
+ ((length + bytes_after_ret + 3)/ 4), True, AnyPropertyType,
+ &type_ret, &format_ret, &nitems, &bytes_after_ret,
+ &prop_ret);
+ XChangeProperty(im->core.display, spec->lib_connect_wid, prop,
+ XA_STRING, 8, PropModePrepend, &prop_ret[length],
+ (nitems - length));
+ }
+ } else {
+ (void)memcpy(buf, prop_ret, buf_len);
+ *ret_len = buf_len;
+ len = nitems - buf_len;
+
+ if (bytes_after_ret > 0) {
+ XFree(prop_ret);
+ XGetWindowProperty(im->core.display,
+ spec->lib_connect_wid, prop, 0L,
+ ((length + bytes_after_ret + 3)/ 4), True, AnyPropertyType,
+ &type_ret, &format_ret, &nitems, &bytes_after_ret, &prop_ret);
+ }
+ XChangeProperty(im->core.display, spec->lib_connect_wid, prop,
+ XA_STRING, 8, PropModePrepend, &prop_ret[buf_len], len);
+ event->xclient.data.l[0] = (long)len;
+ event->xclient.data.l[1] = (long)prop;
+ XPutBackEvent(im->core.display, event);
+ }
+ XFree(prop_ret);
+ } else if (event->type == PropertyNotify) {
+ prop = event->xproperty.atom;
+ return_code = XGetWindowProperty(im->core.display,
+ spec->lib_connect_wid, prop, 0L,
+ 1000000L, True, AnyPropertyType,
+ &type_ret, &format_ret, &nitems, &bytes_after_ret, &prop_ret);
+ if (return_code != Success || format_ret == 0 || nitems == 0) {
+ if (return_code == Success)
+ XFree(prop_ret);
+ return False;
+ }
+ if (buf_len >= nitems) {
+ (void)memcpy(buf, prop_ret, (int)nitems);
+ *ret_len = (int)nitems;
+ } else {
+ (void)memcpy(buf, prop_ret, buf_len);
+ *ret_len = buf_len;
+ len = nitems - buf_len;
+ XChangeProperty(im->core.display, spec->lib_connect_wid, prop,
+ XA_STRING, 8, PropModePrepend, &prop_ret[buf_len], len);
+ }
+ XFree(prop_ret);
+ }
+ return True;
+}
+
+Private Bool
+_CheckCMEvent(
+ Display *display,
+ XEvent *event,
+ XPointer xim)
+{
+ Xim im = (Xim)xim;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ CARD32 major_code = spec->major_code;
+
+ if ((event->type == ClientMessage)
+ &&((event->xclient.message_type == spec->improtocolid) ||
+ (event->xclient.message_type == spec->immoredataid)))
+ return True;
+ if((major_code == 1 || major_code == 2) &&
+ (event->type == PropertyNotify) &&
+ (event->xproperty.state == PropertyNewValue))
+ return True;
+ return False;
+}
+
+Private Bool
+_XimXRead(Xim im, XPointer recv_buf, int buf_len, int *ret_len)
+{
+ XEvent *ev;
+ XEvent event;
+ int len;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ XPointer arg = spec->ev;
+
+ if (!arg) {
+ bzero(&event, sizeof(XEvent));
+ ev = &event;
+ XIfEvent(im->core.display, ev, _CheckCMEvent, (XPointer)im);
+ } else {
+ ev = (XEvent *)arg;
+ spec->ev = (XPointer)NULL;
+ }
+ if (!(_XimXGetReadData(im, recv_buf, buf_len, &len, ev)))
+ return False;
+ *ret_len = len;
+ return True;
+}
+
+Private void
+_XimXFlush(Xim im)
+{
+ XFlush(im->core.display);
+ return;
+}
+
+Public Bool
+_XimXConf(im, address)
+ Xim im;
+ char *address;
+{
+ XSpecRec *spec;
+
+ if (!(spec = (XSpecRec *)Xmalloc(sizeof(XSpecRec))))
+ return False;
+ bzero(spec, sizeof(XSpecRec));
+
+ spec->improtocolid = XInternAtom(im->core.display, _XIM_PROTOCOL, False);
+ spec->imconnectid = XInternAtom(im->core.display, _XIM_XCONNECT, False);
+ spec->immoredataid = XInternAtom(im->core.display, _XIM_MOREDATA, False);
+ spec->major_code = MAJOR_TRANSPORT_VERSION;
+ spec->minor_code = MINOR_TRANSPORT_VERSION;
+
+ im->private.proto.spec = (XPointer)spec;
+ im->private.proto.connect = _XimXConnect;
+ im->private.proto.shutdown = _XimXShutdown;
+ im->private.proto.write = _XimXWrite;
+ im->private.proto.read = _XimXRead;
+ im->private.proto.flush = _XimXFlush;
+ im->private.proto.register_dispatcher = _XimXRegisterDispatcher;
+ im->private.proto.call_dispatcher = _XimXCallDispatcher;
+
+ return True;
+}
diff --git a/nx-X11/lib/X11/imTrans.c b/nx-X11/lib/X11/imTrans.c
new file mode 100644
index 000000000..a239219b7
--- /dev/null
+++ b/nx-X11/lib/X11/imTrans.c
@@ -0,0 +1,301 @@
+/* $Xorg: imTrans.c,v 1.3 2000/08/17 19:45:16 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+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 of Sun Microsystems, Inc.
+and FUJITSU LIMITED not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
+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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imTrans.c,v 1.3 2003/04/17 02:06:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xatom.h>
+#include <X11/Xmd.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/Xtrans/Xtrans.h>
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XimTrans.h"
+#include "XimTrInt.h"
+
+#ifdef WIN32
+#include <X11/Xwindows.h>
+#endif
+
+
+#ifndef XIM_CONNECTION_RETRIES
+#define XIM_CONNECTION_RETRIES 5
+#endif
+
+
+Private Bool
+_XimTransConnect(
+ Xim im)
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+ int connect_stat, retry;
+ Window window;
+
+ for (retry = XIM_CONNECTION_RETRIES; retry >= 0; retry--)
+ {
+ if ((spec->trans_conn = _XimXTransOpenCOTSClient (
+ spec->address)) == NULL)
+ {
+ break;
+ }
+
+ if ((connect_stat = _XimXTransConnect (
+ spec->trans_conn, spec->address)) < 0)
+ {
+ _XimXTransClose (spec->trans_conn);
+ spec->trans_conn = NULL;
+
+ if (connect_stat == TRANS_TRY_CONNECT_AGAIN)
+ {
+ sleep(1);
+ continue;
+ }
+ else
+ break;
+ }
+ else
+ break;
+ }
+
+ if (spec->trans_conn == NULL)
+ return False;
+
+ spec->fd = _XimXTransGetConnectionNumber (spec->trans_conn);
+
+ if (!(window = XCreateSimpleWindow(im->core.display,
+ DefaultRootWindow(im->core.display), 0, 0, 1, 1, 1, 0, 0)))
+ return False;
+ spec->window = window;
+
+ _XRegisterFilterByType(im->core.display, window, KeyPress, KeyPress,
+ _XimTransFilterWaitEvent, (XPointer)im);
+
+ return _XRegisterInternalConnection(im->core.display, spec->fd,
+ (_XInternalConnectionProc)_XimTransInternalConnection,
+ (XPointer)im);
+}
+
+
+Private Bool
+_XimTransShutdown(
+ Xim im)
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+
+ _XimXTransDisconnect(spec->trans_conn);
+ (void)_XimXTransClose(spec->trans_conn);
+ _XimFreeTransIntrCallback(im);
+ _XUnregisterInternalConnection(im->core.display, spec->fd);
+ _XUnregisterFilter(im->core.display, spec->window,
+ _XimTransFilterWaitEvent, (XPointer)im);
+ XDestroyWindow(im->core.display, spec->window);
+ Xfree(spec->address);
+ Xfree(spec);
+ return True;
+}
+
+
+
+Public Bool
+_XimTransRegisterDispatcher(
+ Xim im,
+ Bool (*callback)(
+ Xim, INT16, XPointer, XPointer
+ ),
+ XPointer call_data)
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+ TransIntrCallbackPtr rec;
+
+ if (!(rec = (TransIntrCallbackPtr)Xmalloc(sizeof(TransIntrCallbackRec))))
+ return False;
+
+ rec->func = callback;
+ rec->call_data = call_data;
+ rec->next = spec->intr_cb;
+ spec->intr_cb = rec;
+ return True;
+}
+
+
+Public void
+_XimFreeTransIntrCallback(
+ Xim im)
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+ register TransIntrCallbackPtr rec, next;
+
+ for (rec = spec->intr_cb; rec;) {
+ next = rec->next;
+ Xfree(rec);
+ rec = next;
+ }
+ return;
+}
+
+
+Public Bool
+_XimTransCallDispatcher(Xim im, INT16 len, XPointer data)
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+ TransIntrCallbackRec *rec;
+
+ for (rec = spec->intr_cb; rec; rec = rec->next) {
+ if ((*rec->func)(im, len, data, rec->call_data))
+ return True;
+ }
+ return False;
+}
+
+
+Public Bool
+_XimTransFilterWaitEvent(
+ Display *d,
+ Window w,
+ XEvent *ev,
+ XPointer arg)
+{
+ Xim im = (Xim)arg;
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+
+ spec->is_putback = False;
+ return _XimFilterWaitEvent(im);
+}
+
+
+Public void
+_XimTransInternalConnection(
+ Display *d,
+ int fd,
+ XPointer arg)
+{
+ Xim im = (Xim)arg;
+ XEvent ev;
+ XKeyEvent *kev;
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+
+ if (spec->is_putback)
+ return;
+ kev = (XKeyEvent *)&ev;
+ kev->type = KeyPress;
+ kev->send_event = False;
+ kev->display = im->core.display;
+ kev->window = spec->window;
+ kev->keycode = 0;
+ XPutBackEvent(im->core.display, &ev);
+ XFlush(im->core.display);
+ spec->is_putback = True;
+ return;
+}
+
+
+Public Bool
+_XimTransWrite(Xim im, INT16 len, XPointer data)
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+ char *buf = (char *)data;
+ register int nbyte;
+
+ while (len > 0) {
+ if ((nbyte = _XimXTransWrite(spec->trans_conn, buf, len)) <= 0)
+ return False;
+ len -= nbyte;
+ buf += nbyte;
+ }
+ return True;
+}
+
+
+Public Bool
+_XimTransRead(
+ Xim im,
+ XPointer recv_buf,
+ int buf_len,
+ int *ret_len)
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+ int len;
+
+ if (buf_len == 0) {
+ *ret_len = 0;
+ return True;
+ }
+ if ((len = _XimXTransRead(spec->trans_conn, recv_buf, buf_len)) <= 0)
+ return False;
+ *ret_len = len;
+ return True;
+}
+
+
+Public void
+_XimTransFlush(
+ Xim im)
+{
+ return;
+}
+
+
+
+Public Bool
+_XimTransConf(
+ Xim im,
+ char *address)
+{
+ char *paddr;
+ TransSpecRec *spec;
+
+ if (!(paddr = (char *)Xmalloc(strlen(address) + 1)))
+ return False;
+
+ if (!(spec = (TransSpecRec *) Xmalloc(sizeof(TransSpecRec)))) {
+ Xfree(paddr);
+ return False;
+ }
+
+ bzero(spec, sizeof(TransSpecRec));
+
+ (void)strcpy(paddr, address);
+ spec->address = paddr;
+
+ im->private.proto.spec = (XPointer)spec;
+ im->private.proto.connect = _XimTransConnect;
+ im->private.proto.shutdown = _XimTransShutdown;
+ im->private.proto.write = _XimTransWrite;
+ im->private.proto.read = _XimTransRead;
+ im->private.proto.flush = _XimTransFlush;
+ im->private.proto.register_dispatcher = _XimTransRegisterDispatcher;
+ im->private.proto.call_dispatcher = _XimTransCallDispatcher;
+
+ return True;
+}
diff --git a/nx-X11/lib/X11/imTransR.c b/nx-X11/lib/X11/imTransR.c
new file mode 100644
index 000000000..5ca4a39c0
--- /dev/null
+++ b/nx-X11/lib/X11/imTransR.c
@@ -0,0 +1,304 @@
+/* $Xorg: imTransR.c,v 1.4 2000/08/17 19:45:16 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+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 of Sun Microsystems, Inc.
+and FUJITSU LIMITED not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
+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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/imTransR.c,v 3.6 2003/04/17 02:39:56 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XimTrInt.h"
+#include "Ximint.h"
+
+Public TransportSW _XimTransportRec[] = {
+ { "X", _XimXConf }, /* 1st entry must be X.
+ This will be a fallback */
+#ifdef TCPCONN
+ { "tcp", _XimTransConf }, /* use X transport lib */
+#endif /* TCPCONN */
+#if defined(UNIXCONN) || defined(LOCALCONN)
+ { "local", _XimTransConf }, /* use X transport lib */
+#endif /* UNIXCONN */
+#ifdef DNETCONN
+ { "dnet", _XimTransConf }, /* use X transport lib */
+#endif /* DNETCONN */
+#ifdef STREAMSCONN
+ { "streams", _XimTransConf }, /* use X transport lib */
+#endif /* STREAMSCONN */
+ { (char *)NULL, (Bool (*)(Xim, char *))NULL },
+};
+
+Public Bool
+_XimConnect(im)
+ Xim im;
+{
+ return im->private.proto.connect(im);
+}
+
+Public Bool
+_XimShutdown(im)
+ Xim im;
+{
+ return im->private.proto.shutdown(im);
+}
+
+Public Bool
+_XimWrite(Xim im, INT16 len, XPointer data)
+{
+ return im->private.proto.write(im, len, data);
+}
+
+Private int
+_CheckProtocolData(
+ Xim im,
+ char *recv_buf)
+{
+ int data_len;
+
+ data_len = (int)(((*((CARD16 *)recv_buf + 1)) * 4) + XIM_HEADER_SIZE);
+ return data_len;
+}
+
+Private int
+_XimReadData(
+ Xim im,
+ INT16 *len,
+ XPointer buf,
+ int buf_size)
+{
+ char *hold_buf;
+ char *tmp;
+ int data_len;
+ int packet_size;
+ int ret_len;
+ register int i;
+
+ if (buf_size < XIM_HEADER_SIZE) {
+ *len = (INT16)XIM_HEADER_SIZE;
+ return XIM_OVERFLOW;
+ }
+
+ bzero(buf, buf_size);
+ packet_size = 0;
+ data_len = 0;
+
+ if ((hold_buf = im->private.proto.hold_data)) {
+ data_len = im->private.proto.hold_data_len;
+ if (data_len >= XIM_HEADER_SIZE) {
+ packet_size = _CheckProtocolData(im, hold_buf);
+ if (packet_size > buf_size) {
+ *len = (INT16)packet_size;
+ return XIM_OVERFLOW;
+ }
+ if (packet_size <= data_len) {
+ memcpy(buf, hold_buf, packet_size);
+ for (i = packet_size; i < data_len; i++) {
+ if (hold_buf[i])
+ break;
+ }
+ data_len -= i;
+
+ if (data_len) {
+ if (!(tmp = (char *)Xmalloc(data_len))) {
+ return XIM_FALSE;
+ }
+ memcpy(tmp, &hold_buf[i], data_len);
+ im->private.proto.hold_data = tmp;
+ im->private.proto.hold_data_len = data_len;
+ } else {
+ im->private.proto.hold_data = 0;
+ im->private.proto.hold_data_len = 0;
+ }
+ Xfree(hold_buf);
+ *len = (INT16)packet_size;
+ return XIM_TRUE;
+ }
+ }
+ memcpy(buf, hold_buf, data_len);
+ buf_size -= data_len;
+ Xfree(hold_buf);
+ im->private.proto.hold_data = 0;
+ im->private.proto.hold_data_len = 0;
+ }
+
+ if (!packet_size) {
+ while (data_len < XIM_HEADER_SIZE) {
+ if (!(im->private.proto.read(im,
+ (XPointer)&buf[data_len], buf_size, &ret_len))) {
+ return XIM_FALSE;
+ }
+ data_len += ret_len;
+ buf_size -= ret_len;
+ }
+ packet_size = _CheckProtocolData(im, buf);
+ }
+
+ if (packet_size > buf_size) {
+ if (!(tmp = (char *)Xmalloc(data_len))) {
+ return XIM_FALSE;
+ }
+ memcpy(tmp, buf, data_len);
+ bzero(buf, data_len);
+ im->private.proto.hold_data = tmp;
+ im->private.proto.hold_data_len = data_len;
+ *len = (INT16)packet_size;
+ return XIM_OVERFLOW;
+ }
+
+ while (data_len < packet_size) {
+ if (!(im->private.proto.read(im,
+ (XPointer)&buf[data_len], buf_size, &ret_len))) {
+ return XIM_FALSE;
+ }
+ data_len += ret_len;
+ buf_size -= ret_len;
+ }
+
+ for (i = packet_size; i < data_len; i++) {
+ if (buf[i])
+ break;
+ }
+ data_len -= i;
+
+ if (data_len) {
+ if (!(tmp = (char *)Xmalloc(data_len))) {
+ return XIM_FALSE;
+ }
+ memcpy(tmp, &buf[i], data_len);
+ bzero(&buf[i], data_len);
+ im->private.proto.hold_data = tmp;
+ im->private.proto.hold_data_len = data_len;
+ } else {
+ im->private.proto.hold_data = 0;
+ im->private.proto.hold_data_len = 0;
+ }
+ *len = (INT16)packet_size;
+ return XIM_TRUE;
+}
+
+Private Bool
+_XimCallDispatcher(
+ Xim im,
+ INT16 len,
+ XPointer data)
+{
+ return im->private.proto.call_dispatcher(im, len, data);
+}
+
+Public int
+_XimRead(im, len, buf, buf_size, predicate, arg)
+ Xim im;
+ INT16 *len;
+ XPointer buf;
+ int buf_size;
+ Bool (*predicate)(
+ Xim, INT16, XPointer, XPointer
+ );
+ XPointer arg;
+{
+ INT16 read_len;
+ int ret_code;
+
+ for (;;) {
+ ret_code = _XimReadData(im, &read_len, buf, buf_size);
+ if(ret_code != XIM_TRUE) {
+ return ret_code;
+ }
+ if ((*predicate)(im, read_len, buf, arg))
+ break;
+ if (_XimCallDispatcher(im, read_len, buf))
+ continue;
+ _XimError(im, 0, XIM_BadProtocol, (INT16)0, (CARD16)0, (char *)NULL);
+ }
+ *len = read_len;
+ return True;
+}
+
+Public Bool
+_XimRegisterDispatcher(
+ Xim im,
+ Bool (*callback)(
+ Xim, INT16, XPointer, XPointer
+ ),
+ XPointer call_data)
+{
+ return im->private.proto.register_dispatcher(im, callback, call_data);
+}
+
+Public void
+_XimFlush(im)
+ Xim im;
+{
+ im->private.proto.flush(im);
+ return;
+}
+
+Public Bool
+_XimFilterWaitEvent(im)
+ Xim im;
+{
+ INT16 read_len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+
+ buf_size = BUFSIZE;
+ ret_code = _XimReadData(im, &read_len, (XPointer)reply, buf_size);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(read_len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = (int)read_len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimReadData(im, &read_len, preply, buf_size);
+ if(ret_code != XIM_TRUE) {
+ if (preply != reply)
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else {
+ return False;
+ }
+ if (_XimCallDispatcher(im, read_len, preply)) {
+ if(reply != preply)
+ Xfree(preply);
+ return True;
+ }
+ _XimError(im, 0, XIM_BadProtocol, (INT16)0, (CARD16)0, (char *)NULL);
+ if(reply != preply)
+ Xfree(preply);
+ return True;
+}
diff --git a/nx-X11/lib/X11/jump_funcs b/nx-X11/lib/X11/jump_funcs
new file mode 100644
index 000000000..ab60422ae
--- /dev/null
+++ b/nx-X11/lib/X11/jump_funcs
@@ -0,0 +1,1467 @@
+# $Xorg: jump_funcs,v 1.3 2000/08/17 19:45:16 cpqbld Exp $
+#
+#
+#
+#
+# $XFree86: xc/lib/X11/jump_funcs,v 3.10 1998/10/03 08:41:36 dawes Exp $
+#
+00000000 T _XSaveContext libX11 Context
+00000000 T _XFindContext libX11 Context
+00000000 T _XDeleteContext libX11 Context
+00000000 T _XListDepths libX11 Depths
+00000000 T _XrmParseCommand libX11 ParseCmd
+00000000 T _Xpermalloc libX11 Quarks
+00000000 T __XrmInternalStringToQuark libX11 Quarks
+00000000 T _XrmStringToQuark libX11 Quarks
+00000000 T _XrmPermStringToQuark libX11 Quarks
+00000000 T _XrmUniqueQuark libX11 Quarks
+00000000 T _XrmQuarkToString libX11 Quarks
+00000000 T _XAllocColorCells libX11 XAllCells
+00000000 T _XAllocColorPlanes libX11 XAllPlanes
+00000000 T _XAllowEvents libX11 XAllowEv
+00000000 T _XAutoRepeatOn libX11 XAutoRep
+00000000 T _XAutoRepeatOff libX11 XAutoRep
+00000000 T _XSetWindowBackground libX11 XBackgnd
+00000000 T _XSetWindowBorderWidth libX11 XBdrWidth
+00000000 T _XBell libX11 XBell
+00000000 T _XSetWindowBorder libX11 XBorder
+00000000 T _XEnableAccessControl libX11 XChAccCon
+00000000 T _XDisableAccessControl libX11 XChAccCon
+00000000 T _XSetAccessControl libX11 XChAccCon
+00000000 T _XSetCloseDownMode libX11 XChClMode
+00000000 T _XChangeActivePointerGrab libX11 XChActPGb
+00000000 T _XSetWindowColormap libX11 XChCmap
+00000000 T _XChangeGC libX11 XChGC
+00000000 T _XChangeKeyboardControl libX11 XChKeyCon
+00000000 T _XChangePointerControl libX11 XChPntCon
+00000000 T _XChangeProperty libX11 XChProp
+00000000 T _XChangeSaveSet libX11 XChSaveSet
+00000000 T _XAddToSaveSet libX11 XChSaveSet
+00000000 T _XRemoveFromSaveSet libX11 XChSaveSet
+00000000 T _XChangeWindowAttributes libX11 XChWAttrs
+00000000 T _XResizeWindow libX11 XChWindow
+00000000 T _XCheckIfEvent libX11 XChkIfEv
+00000000 T _XCheckMaskEvent libX11 XChkMaskEv
+00000000 T _XCheckWindowEvent libX11 XChkWinEv
+00000000 T _XCheckTypedEvent libX11 XChkTypEv
+00000000 T _XCheckTypedWindowEvent libX11 XChkTypWEv
+00000000 T _XCirculateSubwindows libX11 XCirWin
+00000000 T _XCirculateSubwindowsDown libX11 XCirWinDn
+00000000 T _XCirculateSubwindowsUp libX11 XCirWinUp
+00000000 T _XCloseDisplay libX11 XClDisplay
+00000000 T _XClearWindow libX11 XClear
+00000000 T _XClearArea libX11 XClearArea
+00000000 T _XMoveResizeWindow libX11 XConfWind
+00000000 T __XConnectDisplay libX11 XConnDis
+00000000 T __XDisconnectDisplay libX11 XConnDis
+00000000 T __XSendClientPrefix libX11 XConnDis
+00000000 T _XSetAuthorization libX11 XConnDis
+00000000 T _XConvertSelection libX11 XConvSel
+00000000 T _XCopyArea libX11 XCopyArea
+00000000 T _XCopyColormapAndFree libX11 XCopyCmap
+00000000 T _XCopyGC libX11 XCopyGC
+00000000 T _XCopyPlane libX11 XCopyPlane
+00000000 T _XCreateBitmapFromData libX11 XCrBFData
+00000000 T _XCreateColormap libX11 XCrCmap
+00000000 T _XCreatePixmapCursor libX11 XCrCursor
+00000000 T _XCreateGC libX11 XCrGC
+00000000 T __XUpdateGCCache libX11 XCrGC
+00000000 T __XFlushGCCache libX11 XCrGC
+00000000 T _XFlushGC libX11 XCrGC
+00000000 T _XGContextFromGC libX11 XCrGC
+00000000 T _XCreateGlyphCursor libX11 XCrGlCur
+00000000 T _XCreatePixmapFromBitmapData libX11 XCrPFBData
+00000000 T _XCreatePixmap libX11 XCrPixmap
+00000000 T _XCreateSimpleWindow libX11 XCrWindow
+00000000 T _XCreateFontCursor libX11 XCursor
+00000000 T _XDefineCursor libX11 XDefCursor
+00000000 T _XDeleteProperty libX11 XDelProp
+00000000 T _XDestroySubwindows libX11 XDestSubs
+00000000 T _XDestroyWindow libX11 XDestWind
+00000000 T _XDisplayName libX11 XDisName
+00000000 T _XDrawArc libX11 XDrArc
+00000000 T _XDrawArcs libX11 XDrArcs
+00000000 T _XDrawLine libX11 XDrLine
+00000000 T _XDrawLines libX11 XDrLines
+00000000 T _XDrawPoint libX11 XDrPoint
+00000000 T _XDrawPoints libX11 XDrPoints
+00000000 T _XDrawRectangle libX11 XDrRect
+00000000 T _XDrawRectangles libX11 XDrRects
+00000000 T _XDrawSegments libX11 XDrSegs
+00000000 T _XGetErrorText libX11 XErrDes
+00000000 T _XGetErrorDatabaseText libX11 XErrDes
+00000000 T _XSetErrorHandler libX11 XErrHndlr
+00000000 T _XSetIOErrorHandler libX11 XErrHndlr
+00000000 T __XEventToWire libX11 XEvToWire
+00000000 T _XFetchName libX11 XFetchName
+00000000 T _XGetIconName libX11 XFetchName
+00000000 T _XFillArc libX11 XFillArc
+00000000 T _XFillArcs libX11 XFillArcs
+00000000 T _XFillPolygon libX11 XFillPoly
+00000000 T _XFillRectangle libX11 XFillRect
+00000000 T _XFillRectangles libX11 XFillRects
+00000000 T _XFlush libX11 XFlush
+00000000 T _XLoadQueryFont libX11 XFont
+00000000 T _XFreeFont libX11 XFont
+00000000 T _XQueryFont libX11 XFont
+00000000 T _XListFonts libX11 XFontNames
+00000000 T _XFreeFontNames libX11 XFontNames
+00000000 T _XListFontsWithInfo libX11 XFontInfo
+00000000 T _XFreeFontInfo libX11 XFontInfo
+00000000 T _XFreeColormap libX11 XFreeCmap
+00000000 T _XFreeColors libX11 XFreeCols
+00000000 T _XFreeCursor libX11 XFreeCurs
+00000000 T __XFreeExtData libX11 XFreeEData
+00000000 T _XFreeGC libX11 XFreeGC
+00000000 T _XFreePixmap libX11 XFreePix
+00000000 T _XActivateScreenSaver libX11 XFSSaver
+00000000 T _XResetScreenSaver libX11 XFSSaver
+00000000 T _XForceScreenSaver libX11 XFSSaver
+00000000 T _XSetArcMode libX11 XGCMisc
+00000000 T _XSetFillRule libX11 XGCMisc
+00000000 T _XSetFillStyle libX11 XGCMisc
+00000000 T _XSetGraphicsExposures libX11 XGCMisc
+00000000 T _XSetSubwindowMode libX11 XGCMisc
+00000000 T _XGeometry libX11 XGeom
+00000000 T _XGetAtomName libX11 XGetAtomNm
+00000000 T _XAllocNamedColor libX11 XGetColor
+00000000 T _XGetDefault libX11 XGetDflt
+00000000 T _XGetFontPath libX11 XGetFPath
+00000000 T _XFreeFontPath libX11 XGetFPath
+00000000 T _XGetFontProperty libX11 XGetFProp
+00000000 T _XGetGeometry libX11 XGetGeom
+00000000 T _XAllocColor libX11 XGetHColor
+00000000 T _XGetSizeHints libX11 XGetHints
+00000000 T _XGetWMHints libX11 XGetHints
+00000000 T _XGetZoomHints libX11 XGetHints
+00000000 T _XGetNormalHints libX11 XGetHints
+00000000 T _XGetIconSizes libX11 XGetHints
+00000000 T _XGetCommand libX11 XGetHints
+00000000 T _XGetTransientForHint libX11 XGetHints
+00000000 T _XGetClassHint libX11 XGetHints
+00000000 T _XGetInputFocus libX11 XGetIFocus
+00000000 T _XGetImage libX11 XGetImage
+00000000 T _XGetSubImage libX11 XGetImage
+00000000 T _XGetKeyboardControl libX11 XGetKCnt
+00000000 T _XGetMotionEvents libX11 XGetMoEv
+00000000 T _XGetPointerControl libX11 XGetPCnt
+00000000 T _XGetPointerMapping libX11 XGetPntMap
+00000000 T _XGetKeyboardMapping libX11 XGetPntMap
+00000000 T _XGetWindowProperty libX11 XGetProp
+00000000 T _XGetSelectionOwner libX11 XGetSOwner
+00000000 T _XGetScreenSaver libX11 XGetSSaver
+00000000 T _XGetStandardColormap libX11 XGetStCmap
+00000000 T _XGetWindowAttributes libX11 XGetWAttrs
+00000000 T _XGrabButton libX11 XGrButton
+00000000 T _XGrabKey libX11 XGrKey
+00000000 T _XGrabKeyboard libX11 XGrKeybd
+00000000 T _XGrabPointer libX11 XGrPointer
+00000000 T _XGrabServer libX11 XGrServer
+00000000 T _XAddHost libX11 XHost
+00000000 T _XRemoveHost libX11 XHost
+00000000 T _XAddHosts libX11 XHost
+00000000 T _XRemoveHosts libX11 XHost
+00000000 T _XIfEvent libX11 XIfEvent
+00000000 T __XGetScanlinePad libX11 XImUtil
+00000000 T __XGetBitsPerPixel libX11 XImUtil
+00000000 T _XCreateImage libX11 XImUtil
+00000000 T __XSetImage libX11 XImUtil
+00000000 T __XInitImageFuncPtrs libX11 XImUtil
+00000000 T _XDrawImageString libX11 XImText
+00000000 T _XDrawImageString16 libX11 XImText16
+00000000 T _XInitExtension libX11 XInitExt
+00000000 T _XAddExtension libX11 XInitExt
+00000000 T _XEHeadOfExtensionList libX11 XInitExt
+00000000 T _XAddToExtensionList libX11 XInitExt
+00000000 T _XFindOnExtensionList libX11 XInitExt
+00000000 T _XESetCreateGC libX11 XInitExt
+00000000 T _XESetCopyGC libX11 XInitExt
+00000000 T _XESetFlushGC libX11 XInitExt
+00000000 T _XESetFreeGC libX11 XInitExt
+00000000 T _XESetCreateFont libX11 XInitExt
+00000000 T _XESetFreeFont libX11 XInitExt
+00000000 T _XESetCloseDisplay libX11 XInitExt
+00000000 T _XESetWireToEvent libX11 XInitExt
+00000000 T _XESetEventToWire libX11 XInitExt
+00000000 T _XESetWireToError libX11 XInitExt
+00000000 T _XESetError libX11 XInitExt
+00000000 T _XESetErrorString libX11 XInitExt
+00000000 T _XESetPrintErrorValues libX11 XInitExt
+00000000 T _XInstallColormap libX11 XInsCmap
+00000000 T _XInternAtom libX11 XIntAtom
+00000000 T _XKeycodeToKeysym libX11 XKeyBind
+00000000 T _XKeysymToKeycode libX11 XKeyBind
+00000000 T _XLookupKeysym libX11 XKeyBind
+00000000 T _XRefreshKeyboardMapping libX11 XKeyBind
+00000000 T _XLookupString libX11 XKeyBind
+00000000 T _XRebindKeysym libX11 XKeyBind
+00000000 T _XKeysymToString libX11 XKeysymStr
+00000000 T _XKillClient libX11 XKillCl
+00000000 T _XListHosts libX11 XLiHosts
+00000000 T _XListInstalledColormaps libX11 XLiICmaps
+00000000 T _XListProperties libX11 XLiProps
+00000000 T _XListExtensions libX11 XListExt
+00000000 T _XFreeExtensionList libX11 XListExt
+00000000 T _XLoadFont libX11 XLoadFont
+00000000 T _XLookupColor libX11 XLookupCol
+00000000 T _XLowerWindow libX11 XLowerWin
+00000000 T _XConnectionNumber libX11 XMacros
+00000000 T _XRootWindow libX11 XMacros
+00000000 T _XDefaultScreen libX11 XMacros
+00000000 T _XDefaultRootWindow libX11 XMacros
+00000000 T _XDefaultVisual libX11 XMacros
+00000000 T _XDefaultGC libX11 XMacros
+00000000 T _XBlackPixel libX11 XMacros
+00000000 T _XWhitePixel libX11 XMacros
+00000000 T _XAllPlanes libX11 XMacros
+00000000 T _XQLength libX11 XMacros
+00000000 T _XDisplayWidth libX11 XMacros
+00000000 T _XDisplayHeight libX11 XMacros
+00000000 T _XDisplayWidthMM libX11 XMacros
+00000000 T _XDisplayHeightMM libX11 XMacros
+00000000 T _XDisplayPlanes libX11 XMacros
+00000000 T _XDisplayCells libX11 XMacros
+00000000 T _XScreenCount libX11 XMacros
+00000000 T _XServerVendor libX11 XMacros
+00000000 T _XProtocolVersion libX11 XMacros
+00000000 T _XProtocolRevision libX11 XMacros
+00000000 T _XVendorRelease libX11 XMacros
+00000000 T _XDisplayString libX11 XMacros
+00000000 T _XDefaultDepth libX11 XMacros
+00000000 T _XDefaultColormap libX11 XMacros
+00000000 T _XBitmapUnit libX11 XMacros
+00000000 T _XBitmapBitOrder libX11 XMacros
+00000000 T _XBitmapPad libX11 XMacros
+00000000 T _XImageByteOrder libX11 XMacros
+00000000 T _XNextRequest libX11 XMacros
+00000000 T _XLastKnownRequestProcessed libX11 XMacros
+00000000 T _XScreenOfDisplay libX11 XMacros
+00000000 T _XDefaultScreenOfDisplay libX11 XMacros
+00000000 T _XDisplayOfScreen libX11 XMacros
+00000000 T _XRootWindowOfScreen libX11 XMacros
+00000000 T _XBlackPixelOfScreen libX11 XMacros
+00000000 T _XWhitePixelOfScreen libX11 XMacros
+00000000 T _XDefaultColormapOfScreen libX11 XMacros
+00000000 T _XDefaultDepthOfScreen libX11 XMacros
+00000000 T _XDefaultGCOfScreen libX11 XMacros
+00000000 T _XDefaultVisualOfScreen libX11 XMacros
+00000000 T _XWidthOfScreen libX11 XMacros
+00000000 T _XHeightOfScreen libX11 XMacros
+00000000 T _XWidthMMOfScreen libX11 XMacros
+00000000 T _XHeightMMOfScreen libX11 XMacros
+00000000 T _XPlanesOfScreen libX11 XMacros
+00000000 T _XCellsOfScreen libX11 XMacros
+00000000 T _XMinCmapsOfScreen libX11 XMacros
+00000000 T _XMaxCmapsOfScreen libX11 XMacros
+00000000 T _XDoesSaveUnders libX11 XMacros
+00000000 T _XDoesBackingStore libX11 XMacros
+00000000 T _XEventMaskOfScreen libX11 XMacros
+00000000 T _XScreenNumberOfScreen libX11 XMacros
+00000000 T _XDestroyImage libX11 XMacros
+00000000 T _XGetPixel libX11 XMacros
+00000000 T _XPutPixel libX11 XMacros
+00000000 T _XSubImage libX11 XMacros
+00000000 T _XAddPixel libX11 XMacros
+00000000 T _XNoOp libX11 XMacros
+00000000 T _XMapRaised libX11 XMapRaised
+00000000 T _XMapSubwindows libX11 XMapSubs
+00000000 T _XMapWindow libX11 XMapWindow
+00000000 T _XMaskEvent libX11 XMaskEvent
+00000000 T _XMaxRequestSize libX11 XMisc
+00000000 T _XResourceManagerString libX11 XMisc
+00000000 T _XDisplayMotionBufferSize libX11 XMisc
+00000000 T _XDisplayKeycodes libX11 XMisc
+00000000 T _XVisualIDFromVisual libX11 XMisc
+00000000 T _XGetModifierMapping libX11 XModMap
+00000000 T _XSetModifierMapping libX11 XModMap
+00000000 T _XNewModifiermap libX11 XModMap
+00000000 T _XFreeModifiermap libX11 XModMap
+00000000 T _XInsertModifiermapEntry libX11 XModMap
+00000000 T _XDeleteModifiermapEntry libX11 XModMap
+00000000 T _XMoveWindow libX11 XMoveWin
+00000000 T _XNextEvent libX11 XNextEvent
+00000000 T _XOpenDisplay libX11 XOpenDis
+00000000 T __XFreeDisplayStructure libX11 XOpenDis
+00000000 T _XParseColor libX11 XParseCol
+00000000 T _XParseGeometry libX11 XParseGeom
+00000000 T _XPeekEvent libX11 XPeekEvent
+00000000 T _XPeekIfEvent libX11 XPeekIfEv
+00000000 T _XEventsQueued libX11 XPending
+00000000 T _XPending libX11 XPending
+00000000 T _XSetWindowBackgroundPixmap libX11 XPmapBgnd
+00000000 T _XSetWindowBorderPixmap libX11 XPmapBord
+00000000 T _XPolygonRegion libX11 XPolyReg
+00000000 T _XDrawText libX11 XPolyTxt
+00000000 T _XDrawText16 libX11 XPolyTxt16
+00000000 T _XPutBackEvent libX11 XPutBEvent
+00000000 T __XReverse_Bytes libX11 XPutImage
+00000000 T _XPutImage libX11 XPutImage
+00000000 T _XQueryBestSize libX11 XQuBest
+00000000 T _XQueryColor libX11 XQuColor
+00000000 T _XQueryColors libX11 XQuColors
+00000000 T _XQueryBestCursor libX11 XQuCurShp
+00000000 T _XQueryExtension libX11 XQuExt
+00000000 T _XQueryKeymap libX11 XQuKeybd
+00000000 T _XQueryPointer libX11 XQuPntr
+00000000 T _XQueryBestStipple libX11 XQuStipShp
+00000000 T _XQueryTextExtents16 libX11 XQuTextE16
+00000000 T _XQueryTextExtents libX11 XQuTextExt
+00000000 T _XQueryBestTile libX11 XQuTileShp
+00000000 T _XQueryTree libX11 XQuTree
+00000000 T _XRaiseWindow libX11 XRaiseWin
+00000000 T _XReadBitmapFile libX11 XRdBitF
+00000000 T _XRecolorCursor libX11 XRecolorC
+00000000 T _XConfigureWindow libX11 XReconfWin
+00000000 T _XCreateRegion libX11 XRegion
+00000000 T _XClipBox libX11 XRegion
+00000000 T _XUnionRectWithRegion libX11 XRegion
+00000000 T _XSetRegion libX11 XRegion
+00000000 T _XDestroyRegion libX11 XRegion
+00000000 T _XOffsetRegion libX11 XRegion
+00000000 T _XShrinkRegion libX11 XRegion
+00000000 T _XIntersectRegion libX11 XRegion
+00000000 T _XUnionRegion libX11 XRegion
+00000000 T _XSubtractRegion libX11 XRegion
+00000000 T _XXorRegion libX11 XRegion
+00000000 T _XEmptyRegion libX11 XRegion
+00000000 T _XEqualRegion libX11 XRegion
+00000000 T _XPointInRegion libX11 XRegion
+00000000 T _XRectInRegion libX11 XRegion
+00000000 T _XReparentWindow libX11 XRepWindow
+00000000 T _XRestackWindows libX11 XRestackWs
+00000000 T _XRotateWindowProperties libX11 XRotProp
+00000000 T _XScreenResourceString libX11 XScrResStr
+00000000 T _XSelectInput libX11 XSelInput
+00000000 T _XSendEvent libX11 XSendEvent
+00000000 T _XSetBackground libX11 XSetBack
+00000000 T _XSetClipRectangles libX11 XSetCRects
+00000000 T __XSetClipRectangles libX11 XSetCRects
+00000000 T _XSetClipMask libX11 XSetClMask
+00000000 T _XSetClipOrigin libX11 XSetClOrig
+00000000 T _XSetDashes libX11 XSetDashes
+00000000 T _XSetFontPath libX11 XSetFPath
+00000000 T _XSetFont libX11 XSetFont
+00000000 T _XSetForeground libX11 XSetFore
+00000000 T _XSetFunction libX11 XSetFunc
+00000000 T _XSetSizeHints libX11 XSetHints
+00000000 T _XSetWMHints libX11 XSetHints
+00000000 T _XSetZoomHints libX11 XSetHints
+00000000 T _XSetNormalHints libX11 XSetHints
+00000000 T _XSetIconSizes libX11 XSetHints
+00000000 T _XSetCommand libX11 XSetHints
+00000000 T _XSetStandardProperties libX11 XSetHints
+00000000 T _XSetTransientForHint libX11 XSetHints
+00000000 T _XSetClassHint libX11 XSetHints
+00000000 T _XSetInputFocus libX11 XSetIFocus
+00000000 T _XSetLineAttributes libX11 XSetLStyle
+00000000 T _XSetPlaneMask libX11 XSetPMask
+00000000 T _XSetPointerMapping libX11 XSetPntMap
+00000000 T _XChangeKeyboardMapping libX11 XSetPntMap
+00000000 T _XSetSelectionOwner libX11 XSetSOwner
+00000000 T _XSetScreenSaver libX11 XSetSSaver
+00000000 T _XSetState libX11 XSetState
+00000000 T _XSetStipple libX11 XSetStip
+00000000 T _XSetStandardColormap libX11 XSetStCmap
+00000000 T _XSetTile libX11 XSetTile
+00000000 T _XSetTSOrigin libX11 XSetTSOrig
+00000000 T _XRotateBuffers libX11 XStBytes
+00000000 T _XFetchBuffer libX11 XStBytes
+00000000 T _XFetchBytes libX11 XStBytes
+00000000 T _XStoreBuffer libX11 XStBytes
+00000000 T _XStoreBytes libX11 XStBytes
+00000000 T _XStoreColor libX11 XStColor
+00000000 T _XStoreColors libX11 XStColors
+00000000 T _XStoreNamedColor libX11 XStNColor
+00000000 T _XStoreName libX11 XStName
+00000000 T _XSetIconName libX11 XStName
+00000000 T __XInitKeysymDB libX11 XStrKeysym
+00000000 T _XStringToKeysym libX11 XStrKeysym
+00000000 T _XSync libX11 XSync
+00000000 T __XSyncFunction libX11 XSynchro
+00000000 T _XSynchronize libX11 XSynchro
+00000000 T _XSetAfterFunction libX11 XSynchro
+00000000 T _XDrawString libX11 XText
+00000000 T _XDrawString16 libX11 XText16
+00000000 T _XTextExtents libX11 XTextExt
+00000000 T _XTextWidth libX11 XTextExt
+00000000 T _XTextExtents16 libX11 XTextExt16
+00000000 T _XTextWidth16 libX11 XTextExt16
+00000000 T _XTranslateCoordinates libX11 XTrCoords
+00000000 T _XUndefineCursor libX11 XUndefCurs
+00000000 T _XUngrabButton libX11 XUngrabBut
+00000000 T _XUngrabKeyboard libX11 XUngrabKbd
+00000000 T _XUngrabKey libX11 XUngrabKey
+00000000 T _XUngrabPointer libX11 XUngrabPtr
+00000000 T _XUngrabServer libX11 XUngrabSvr
+00000000 T _XUninstallColormap libX11 XUninsCmap
+00000000 T _XUnloadFont libX11 XUnldFont
+00000000 T _XUnmapSubwindows libX11 XUnmapSubs
+00000000 T _XUnmapWindow libX11 XUnmapWin
+00000000 T _XGetVisualInfo libX11 XVisUtil
+00000000 T _XMatchVisualInfo libX11 XVisUtil
+00000000 T _XWarpPointer libX11 XWarpPtr
+00000000 T _XWindowEvent libX11 XWinEvent
+00000000 T _XCreateWindow libX11 XWindow
+00000000 T __XProcessWindowAttributes libX11 XWindow
+00000000 T _XWriteBitmapFile libX11 XWrBitF
+00000000 T __XFlush libX11 XlibInt
+00000000 T __XEventsQueued libX11 XlibInt
+00000000 T __XReadEvents libX11 XlibInt
+00000000 T __XRead libX11 XlibInt
+00000000 T __XReadPad libX11 XlibInt
+00000000 T __XSend libX11 XlibInt
+00000000 T __XAllocID libX11 XlibInt
+00000000 T __XSetLastRequestRead libX11 XlibInt
+00000000 T __XReply libX11 XlibInt
+00000000 T __XEatData libX11 XlibInt
+00000000 T __XEnq libX11 XlibInt
+00000000 T __XUnknownWireEvent libX11 XlibInt
+00000000 T __XUnknownNativeEvent libX11 XlibInt
+00000000 T __XWireToEvent libX11 XlibInt
+00000000 T __XDefaultIOError libX11 XlibInt
+00000000 T __XDefaultError libX11 XlibInt
+00000000 T __XDefaultWireError libX11 XlibInt
+00000000 T __XError libX11 XlibInt
+00000000 T __XIOError libX11 XlibInt
+00000000 T __XAllocScratch libX11 XlibInt
+00000000 T __XVIDtoVisual libX11 XlibInt
+00000000 T _XFree libX11 XlibInt
+00000000 T __XGetHostname libX11 XlibInt
+00000000 T __XScreenOfWindow libX11 XlibInt
+00000000 T __DUMMY__ libX11 XlibInt
+00000000 T __XAllocIDs libX11 XlibInt
+00000000 T __XAllocTemp libX11 XlibInt
+00000000 T __XFreeTemp libX11 XlibInt
+00000000 T _XrmInitialize libX11 Xrm
+00000000 T _XrmGetDatabase libX11 Xrm
+00000000 T _XrmSetDatabase libX11 Xrm
+00000000 T _XrmStringToQuarkList libX11 Xrm
+00000000 T _XrmStringToBindingQuarkList libX11 Xrm
+00000000 T _XrmCombineDatabase libX11 Xrm
+00000000 T _XrmMergeDatabases libX11 Xrm
+00000000 T _XrmQPutResource libX11 Xrm
+00000000 T _XrmPutResource libX11 Xrm
+00000000 T _XrmQPutStringResource libX11 Xrm
+00000000 T _XrmPutStringResource libX11 Xrm
+00000000 T _XrmPutLineResource libX11 Xrm
+00000000 T _XrmGetStringDatabase libX11 Xrm
+00000000 T _XrmGetFileDatabase libX11 Xrm
+00000000 T _XrmCombineFileDatabase libX11 Xrm
+00000000 T _XrmEnumerateDatabase libX11 Xrm
+00000000 T _XrmPutFileDatabase libX11 Xrm
+00000000 T _XrmQGetSearchList libX11 Xrm
+00000000 T _XrmQGetSearchResource libX11 Xrm
+00000000 T _XrmQGetResource libX11 Xrm
+00000000 T _XrmGetResource libX11 Xrm
+00000000 T _XrmLocaleOfDatabase libX11 Xrm
+00000000 T _XrmDestroyDatabase libX11 Xrm
+00000000 T _XGetGCValues libX11 GetGCVals
+00000000 T _XGetWMSizeHints libX11 GetNrmHint
+00000000 T _XGetWMNormalHints libX11 GetNrmHint
+00000000 T _XGetRGBColormaps libX11 GetRGBCMap
+00000000 T _XGetTextProperty libX11 GetTxtProp
+00000000 T _XGetWMName libX11 GetTxtProp
+00000000 T _XGetWMIconName libX11 GetTxtProp
+00000000 T _XGetWMClientMachine libX11 GetTxtProp
+00000000 T _XGetWMColormapWindows libX11 GetWMCMapW
+00000000 T _XGetWMProtocols libX11 GetWMProto
+00000000 T _XIconifyWindow libX11 Iconify
+00000000 T _XListPixmapFormats libX11 PixFormats
+00000000 T _XAllocSizeHints libX11 PropAlloc
+00000000 T _XAllocStandardColormap libX11 PropAlloc
+00000000 T _XAllocWMHints libX11 PropAlloc
+00000000 T _XAllocClassHint libX11 PropAlloc
+00000000 T _XAllocIconSize libX11 PropAlloc
+00000000 T _XReconfigureWMWindow libX11 ReconfWM
+00000000 T _XSetWMSizeHints libX11 SetNrmHint
+00000000 T _XSetWMNormalHints libX11 SetNrmHint
+00000000 T _XSetRGBColormaps libX11 SetRGBCMap
+00000000 T _XSetTextProperty libX11 SetTxtProp
+00000000 T _XSetWMName libX11 SetTxtProp
+00000000 T _XSetWMIconName libX11 SetTxtProp
+00000000 T _XSetWMClientMachine libX11 SetTxtProp
+00000000 T _XSetWMColormapWindows libX11 SetWMCMapW
+00000000 T _XSetWMProperties libX11 SetWMProps
+00000000 T _XSetWMProtocols libX11 SetWMProto
+00000000 T _XStringListToTextProperty libX11 StrToText
+00000000 T _XTextPropertyToStringList libX11 TextToStr
+00000000 T _XFreeStringList libX11 TextToStr
+00000000 T _XWMGeometry libX11 WMGeom
+00000000 T _XWithdrawWindow libX11 Withdraw
+00000000 T _XauDisposeAuth libX11 AuDispose
+00000000 T _XauGetBestAuthByAddr libX11 AuGetBest
+00000000 T _XauFileName libX11 AuFileName
+00000000 T _XauReadAuth libX11 AuRead
+00000000 T _XcmsCIELabToCIEXYZ libX11 CIELab
+00000000 T _XcmsCIEXYZToCIELab libX11 CIELab
+00000000 T _XcmsCIELabClipab libX11 CIELabGcC
+00000000 T _XcmsCIELabClipL libX11 CIELabGcL
+00000000 T _XcmsCIELabClipLab libX11 CIELabGcLC
+00000000 T _XcmsCIELabQueryMinL libX11 CIELabMnL
+00000000 T _XcmsCIELabQueryMaxC libX11 CIELabMxC
+00000000 T _XcmsCIELabQueryMaxL libX11 CIELabMxL
+00000000 T __XcmsCIELabQueryMaxLCRGB libX11 CIELabMxLC
+00000000 T _XcmsCIELabQueryMaxLC libX11 CIELabMxLC
+00000000 T _XcmsCIELabWhiteShiftColors libX11 CIELabWpAj
+00000000 T _XcmsCIELuvToCIEuvY libX11 CIELuv
+00000000 T _XcmsCIEuvYToCIELuv libX11 CIELuv
+00000000 T _XcmsCIELuvClipuv libX11 CIELuvGcC
+00000000 T _XcmsCIELuvClipL libX11 CIELuvGcL
+00000000 T _XcmsCIELuvClipLuv libX11 CIELuvGcLC
+00000000 T _XcmsCIELuvQueryMinL libX11 CIELuvMnL
+00000000 T _XcmsCIELuvQueryMaxC libX11 CIELuvMxC
+00000000 T _XcmsCIELuvQueryMaxL libX11 CIELuvMxL
+00000000 T __XcmsCIELuvQueryMaxLCRGB libX11 CIELuvMxLC
+00000000 T _XcmsCIELuvQueryMaxLC libX11 CIELuvMxLC
+00000000 T _XcmsCIELuvWhiteShiftColors libX11 CIELuvWpAj
+00000000 T _XcmsCIEuvYToCIEXYZ libX11 CIEuvY
+00000000 T _XcmsCIEXYZToCIEuvY libX11 CIEuvY
+00000000 T _XcmsCIExyYToCIEXYZ libX11 CIExyY
+00000000 T _XcmsCIEXYZToCIExyY libX11 CIExyY
+00000000 T _XcmsTekHVCToCIEuvY libX11 TekHVC
+00000000 T _XcmsCIEuvYToTekHVC libX11 TekHVC
+00000000 T __XcmsTekHVC_CheckModify libX11 TekHVC
+00000000 T _XcmsTekHVCClipC libX11 TekHVCGcC
+00000000 T _XcmsTekHVCClipV libX11 TekHVCGcV
+00000000 T _XcmsTekHVCClipVC libX11 TekHVCGcVC
+00000000 T _XcmsTekHVCQueryMinV libX11 TekHVCMnV
+00000000 T _XcmsTekHVCQueryMaxC libX11 TekHVCMxC
+00000000 T _XcmsTekHVCQueryMaxV libX11 TekHVCMxV
+00000000 T __XcmsTekHVCQueryMaxVCRGB libX11 TekHVCMxVC
+00000000 T _XcmsTekHVCQueryMaxVC libX11 TekHVCMxVC
+00000000 T _XcmsTekHVCQueryMaxVSamples libX11 TekHVCMxVs
+00000000 T _XcmsTekHVCWhiteShiftColors libX11 TekHVCWpAj
+00000000 T _XcmsAddColorSpace libX11 XcmsAddDIC
+00000000 T _XcmsAddFunctionSet libX11 XcmsAddSF
+00000000 T _XcmsAllocNamedColor libX11 XcmsAlNCol
+00000000 T _XcmsAllocColor libX11 XcmsAllCol
+00000000 T _XcmsCreateCCC libX11 XcmsCCC
+00000000 T _XcmsDefaultCCC libX11 XcmsCCC
+00000000 T _XcmsFreeCCC libX11 XcmsCCC
+00000000 T __XcmsAddCmapRec libX11 XcmsCmap
+00000000 T __XcmsCopyCmapRecAndFree libX11 XcmsCmap
+00000000 T __XcmsDeleteCmapRec libX11 XcmsCmap
+00000000 T _XcmsCCCOfColormap libX11 XcmsCmap
+00000000 T __XcmsCopyISOLatin1Lowered libX11 XcmsColNm
+00000000 T __XcmsResolveColorString libX11 XcmsColNm
+00000000 T __XcmsConvertColorsWithWhitePt libX11 XcmsCvColW
+00000000 T __XcmsEqualWhitePts libX11 XcmsCvCols
+00000000 T __XcmsDIConvertColors libX11 XcmsCvCols
+00000000 T __XcmsDDConvertColors libX11 XcmsCvCols
+00000000 T _XcmsConvertColors libX11 XcmsCvCols
+00000000 T __XcmsRegFormatOfPrefix libX11 XcmsCvCols
+00000000 T _XcmsFormatOfPrefix libX11 XcmsIdOfPr
+00000000 T __XcmsCopyPointerArray libX11 XcmsInt
+00000000 T __XcmsFreePointerArray libX11 XcmsInt
+00000000 T __XcmsPushPointerArray libX11 XcmsInt
+00000000 T __XcmsInitDefaultCCCs libX11 XcmsInt
+00000000 T __XcmsInitScrnInfo libX11 XcmsInt
+00000000 T __XcmsFreeIntensityMaps libX11 XcmsInt
+00000000 T __XcmsGetIntensityMap libX11 XcmsInt
+00000000 T __XcmsGetTableType0 libX11 XcmsLRGB
+00000000 T __XcmsGetTableType1 libX11 XcmsLRGB
+00000000 T __XcmsValueCmp libX11 XcmsLRGB
+00000000 T __XcmsIntensityCmp libX11 XcmsLRGB
+00000000 T __XcmsValueInterpolation libX11 XcmsLRGB
+00000000 T __XcmsIntensityInterpolation libX11 XcmsLRGB
+00000000 T __XcmsTableSearch libX11 XcmsLRGB
+00000000 T __XcmsMatVec libX11 XcmsLRGB
+00000000 T _XcmsCIEXYZToRGBi libX11 XcmsLRGB
+00000000 T _XcmsRGBiToCIEXYZ libX11 XcmsLRGB
+00000000 T _XcmsRGBiToRGB libX11 XcmsLRGB
+00000000 T _XcmsRGBToRGBi libX11 XcmsLRGB
+00000000 T __XcmsLRGB_InitScrnDefault libX11 XcmsLRGB
+00000000 T _XcmsLookupColor libX11 XcmsLkCol
+00000000 T __XcmsCubeRoot libX11 XcmsMath
+00000000 T __XcmsSquareRoot libX11 XcmsMath
+00000000 T _XcmsDisplayOfCCC libX11 XcmsOfCCC
+00000000 T _XcmsVisualOfCCC libX11 XcmsOfCCC
+00000000 T _XcmsScreenNumberOfCCC libX11 XcmsOfCCC
+00000000 T _XcmsScreenWhitePointOfCCC libX11 XcmsOfCCC
+00000000 T _XcmsClientWhitePointOfCCC libX11 XcmsOfCCC
+00000000 T _XcmsPrefixOfFormat libX11 XcmsPrOfId
+00000000 T __XcmsGetElement libX11 XcmsProp
+00000000 T __XcmsGetProperty libX11 XcmsProp
+00000000 T _XcmsQueryBlack libX11 XcmsQBlack
+00000000 T _XcmsQueryBlue libX11 XcmsQBlue
+00000000 T _XcmsQueryGreen libX11 XcmsQGreen
+00000000 T _XcmsQueryRed libX11 XcmsQRed
+00000000 T _XcmsQueryWhite libX11 XcmsQWhite
+00000000 T _XcmsQueryColor libX11 XcmsQuCol
+00000000 T _XcmsQueryColors libX11 XcmsQuCols
+00000000 T _XcmsSetWhitePoint libX11 XcmsSetCCC
+00000000 T _XcmsSetCompressionProc libX11 XcmsSetCCC
+00000000 T _XcmsSetWhiteAdjustProc libX11 XcmsSetCCC
+00000000 T __XcmsSetGetColors libX11 XcmsSetGet
+00000000 T _XcmsStoreColor libX11 XcmsStCol
+00000000 T _XcmsStoreColors libX11 XcmsStCols
+00000000 T __XcmsCosine libX11 XcmsTrig
+00000000 T __XcmsSine libX11 XcmsTrig
+00000000 T __XcmsArcTangent libX11 XcmsTrig
+00000000 T __XcmsRGB_to_XColor libX11 XcmsXRGB
+00000000 T __XColor_to_XcmsRGB libX11 XcmsXRGB
+00000000 T __XcmsResolveColor libX11 XcmsXRGB
+00000000 T __XcmsUnresolveColor libX11 XcmsXRGB
+00000000 T __XUnresolveColor libX11 XcmsXRGB
+00000000 T __XParseBaseFontNameList libX11 XFSWrap
+00000000 T _XCreateFontSet libX11 XFSWrap
+00000000 T _XFontsOfFontSet libX11 XFSWrap
+00000000 T _XBaseFontNameListOfFontSet libX11 XFSWrap
+00000000 T _XLocaleOfFontSet libX11 XFSWrap
+00000000 T _XContextDependentDrawing libX11 XFSWrap
+00000000 T _XExtentsOfFontSet libX11 XFSWrap
+00000000 T _XFreeFontSet libX11 XFSWrap
+00000000 T _XVaCreateNestedList libX11 XICWrap
+00000000 T _XGetIMValues libX11 XICWrap
+00000000 T _XCreateIC libX11 XICWrap
+00000000 T _XDestroyIC libX11 XICWrap
+00000000 T _XGetICValues libX11 XICWrap
+00000000 T _XSetICValues libX11 XICWrap
+00000000 T _XSetICFocus libX11 XICWrap
+00000000 T _XUnsetICFocus libX11 XICWrap
+00000000 T _XIMOfIC libX11 XICWrap
+00000000 T _XmbResetIC libX11 XICWrap
+00000000 T _XwcResetIC libX11 XICWrap
+00000000 T _XmbLookupString libX11 XICWrap
+00000000 T _XwcLookupString libX11 XICWrap
+00000000 T __XIMCompileResourceList libX11 XIMWrap
+00000000 T __XCopyToArg libX11 XIMWrap
+00000000 T _XOpenIM libX11 XIMWrap
+00000000 T _XCloseIM libX11 XIMWrap
+00000000 T _XDisplayOfIM libX11 XIMWrap
+00000000 T _XLocaleOfIM libX11 XIMWrap
+00000000 T _XSetLocaleModifiers libX11 XlcWrap
+00000000 T _XSupportsLocale libX11 XlcWrap
+00000000 T __XlcValidModSyntax libX11 XlcWrap
+00000000 T __XlcDefaultMapModifiers libX11 XlcWrap
+00000000 T __XlcAddLoader libX11 XlcWrap
+00000000 T __XlcCurrentLC libX11 XlcWrap
+00000000 T _XmbSetWMProperties libX11 XmbWMProps
+00000000 T _XmbDrawText libX11 XmbWrap
+00000000 T _XmbDrawString libX11 XmbWrap
+00000000 T _XmbDrawImageString libX11 XmbWrap
+00000000 T _XmbTextEscapement libX11 XmbWrap
+00000000 T _XmbTextExtents libX11 XmbWrap
+00000000 T _XmbTextPerCharExtents libX11 XmbWrap
+00000000 T _XwcDrawText libX11 XwcWrap
+00000000 T _XwcDrawString libX11 XwcWrap
+00000000 T _XwcDrawImageString libX11 XwcWrap
+00000000 T _XwcTextEscapement libX11 XwcWrap
+00000000 T _XwcTextExtents libX11 XwcWrap
+00000000 T _XwcTextPerCharExtents libX11 XwcWrap
+00000000 T _XFilterEvent libX11 XFilterEv
+00000000 T __XRegisterFilterByMask libX11 XRegstFlt
+00000000 T __XRegisterFilterByType libX11 XRegstFlt
+00000000 T __XUnregisterFilter libX11 XRegstFlt
+#ifdef X_LOCALE
+00000000 T __DUMMY__ libX11 XSetLocale
+#else
+00000000 T __XlcMapOSLocaleName libX11 XSetLocale
+#endif
+00000000 T _XDefaultString libX11 XCnvToStr
+00000000 T __XlcDefaultLoader libX11 XlcDefLd
+00000000 T __XrmInitParseInfo libX11 XlcLoad
+00000000 T _XmbTextPropertyToTextList libX11 XmbPrpText
+00000000 T _XmbTextListToTextProperty libX11 XmbTextPrp
+00000000 T _XwcTextPropertyToTextList libX11 XwcPrpText
+00000000 T _XwcFreeStringList libX11 XwcPrpText
+00000000 T _XwcTextListToTextProperty libX11 XwcTextPrp
+00000000 T __X11TransConnectDisplay libX11 ConnDis
+00000000 T _XGetAtomNames libX11 GetAtomNm
+00000000 T _XInitImage libX11 ImUtil
+00000000 T _XESetBeforeFlush libX11 InitExt
+00000000 T __XFreeAtomTable libX11 IntAtom
+00000000 T __XUpdateAtomCache libX11 IntAtom
+00000000 T _XInternAtoms libX11 IntAtom
+00000000 T __XKeyInitialize libX11 KeyBind
+00000000 T _XConvertCase libX11 KeyBind
+00000000 T __XTranslateKey libX11 KeyBind
+00000000 T __XTranslateKeySym libX11 KeyBind
+00000000 T __XKeysymToModifiers libX11 KeyBind
+00000000 T _XExtendedMaxRequestSize libX11 Misc
+00000000 T _XReadBitmapFileData libX11 RdBitF
+00000000 T __XAsyncErrorHandler libX11 XlibAsync
+00000000 T __XDeqAsyncHandler libX11 XlibAsync
+00000000 T __XGetAsyncReply libX11 XlibAsync
+00000000 T __XGetAsyncData libX11 XlibAsync
+00000000 T __XPollfdCacheInit libX11 XlibInt
+00000000 T __XPollfdCacheAdd libX11 XlibInt
+00000000 T __XPollfdCacheDel libX11 XlibInt
+00000000 T __XRegisterInternalConnection libX11 XlibInt
+00000000 T __XUnregisterInternalConnection libX11 XlibInt
+00000000 T _XInternalConnectionNumbers libX11 XlibInt
+00000000 T _XProcessInternalConnection libX11 XlibInt
+00000000 T _XAddConnectionWatch libX11 XlibInt
+00000000 T _XRemoveConnectionWatch libX11 XlibInt
+00000000 T __XDeq libX11 XlibInt
+00000000 T __XcmsCIEXYZ_ValidSpec libX11 XYZ
+00000000 T __XcmsCIEuvY_ValidSpec libX11 uvY
+00000000 T _XcmsSetCCCOfColormap libX11 cmsCmap
+00000000 T _XDirectionalDependentDrawing libX11 FSWrap
+00000000 T _XContextualDrawing libX11 FSWrap
+00000000 T _XSetIMValues libX11 ICWrap
+00000000 T _XRegisterIMInstantiateCallback libX11 IMWrap
+00000000 T _XUnregisterIMInstantiateCallback libX11 IMWrap
+00000000 T _XCreateOC libX11 OCWrap
+00000000 T _XDestroyOC libX11 OCWrap
+00000000 T _XOMOfOC libX11 OCWrap
+00000000 T _XSetOCValues libX11 OCWrap
+00000000 T _XGetOCValues libX11 OCWrap
+00000000 T _XOpenOM libX11 OMWrap
+00000000 T _XCloseOM libX11 OMWrap
+00000000 T _XSetOMValues libX11 OMWrap
+00000000 T _XGetOMValues libX11 OMWrap
+00000000 T _XDisplayOfOM libX11 OMWrap
+00000000 T _XLocaleOfOM libX11 OMWrap
+00000000 T __XlcRemoveLoader libX11 lcWrap
+00000000 T __XOpenLC libX11 lcWrap
+00000000 T __XCloseLC libX11 lcWrap
+00000000 T __XlcCopyFromArg libX11 lcWrap
+00000000 T __XlcCopyToArg libX11 lcWrap
+00000000 T __XlcCountVaList libX11 lcWrap
+00000000 T __XlcVaToArgList libX11 lcWrap
+00000000 T __XlcCompileResourceList libX11 lcWrap
+00000000 T __XlcGetValues libX11 lcWrap
+00000000 T __XlcSetValues libX11 lcWrap
+00000000 T _XInitThreads libX11 locking
+00000000 T _XLockDisplay libX11 LockDis
+00000000 T _XUnlockDisplay libX11 LockDis
+00000000 T __X11TransFreeConnInfo libX11 x11trans
+00000000 T __X11TransOpenCOTSClient libX11 x11trans
+00000000 T __X11TransOpenCLTSClient libX11 x11trans
+00000000 T __X11TransSetOption libX11 x11trans
+00000000 T __X11TransConnect libX11 x11trans
+00000000 T __X11TransBytesReadable libX11 x11trans
+00000000 T __X11TransRead libX11 x11trans
+00000000 T __X11TransWrite libX11 x11trans
+00000000 T __X11TransReadv libX11 x11trans
+00000000 T __X11TransWritev libX11 x11trans
+00000000 T __X11TransDisconnect libX11 x11trans
+00000000 T __X11TransClose libX11 x11trans
+00000000 T __X11TransCloseForCloning libX11 x11trans
+00000000 T __X11TransIsLocal libX11 x11trans
+00000000 T __X11TransGetMyAddr libX11 x11trans
+00000000 T __X11TransGetPeerAddr libX11 x11trans
+00000000 T __X11TransGetConnectionNumber libX11 x11trans
+00000000 T __X11TransGetHostname libX11 x11trans
+00000000 T __X11TransConvertAddress libX11 x11trans
+00000000 T __XimCbDispatch libX11 imCallbk
+00000000 T __XimLookupMBText libX11 imConv
+00000000 T __XimLookupWCText libX11 imConv
+00000000 T __XimRegisterFilter libX11 imDefFlt
+00000000 T __XimUnregisterFilter libX11 imDefFlt
+00000000 T __XimReregisterFilter libX11 imDefFlt
+00000000 T __XimRegisterServerFilter libX11 imDefFlt
+00000000 T __XimUnregisterServerFilter libX11 imDefFlt
+00000000 T __XimProtoCreateIC libX11 imDefIc
+00000000 T __XimCheckDataSize libX11 imDefIm
+00000000 T __XimSetHeader libX11 imDefIm
+00000000 T __XimProtoIMFree libX11 imDefIm
+00000000 T __XimProtoOpenIM libX11 imDefIm
+00000000 T __XimICOfXICID libX11 imDefLkup
+00000000 T __XimSetEventMaskCallback libX11 imDefLkup
+00000000 T __XimSync libX11 imDefLkup
+00000000 T __XimProcSyncReply libX11 imDefLkup
+00000000 T __XimRespSyncReply libX11 imDefLkup
+00000000 T __XimSyncCallback libX11 imDefLkup
+00000000 T __XimForwardEvent libX11 imDefLkup
+00000000 T __XimForwardEventCallback libX11 imDefLkup
+00000000 T __XimRegisterTriggerKeysCallback libX11 imDefLkup
+00000000 T __XimGetWindowEventmask libX11 imDefLkup
+00000000 T __XimTriggerNotify libX11 imDefLkup
+00000000 T __XimFreeCommitInfo libX11 imDefLkup
+00000000 T __XimCommitCallback libX11 imDefLkup
+00000000 T __XimProcError libX11 imDefLkup
+00000000 T __XimErrorCallback libX11 imDefLkup
+00000000 T __XimError libX11 imDefLkup
+00000000 T __Ximctstombs libX11 imDefLkup
+00000000 T __Ximctstowcs libX11 imDefLkup
+00000000 T __XimProtoMbLookupString libX11 imDefLkup
+00000000 T __XimProtoWcLookupString libX11 imDefLkup
+00000000 T __XimRegProtoIntrCallback libX11 imDispch
+00000000 T __XimFreeProtoIntrCallback libX11 imDispch
+00000000 T __XimDispatchInit libX11 imDispch
+00000000 T __XimProtoEventToWire libX11 imEvToWire
+00000000 T __XimProtoWireToEvent libX11 imEvToWire
+00000000 T __XimExtension libX11 imExten
+00000000 T __XimRegisterIMInstantiateCallback libX11 imInsClbk
+00000000 T __XimUnRegisterIMInstantiateCallback libX11 imInsClbk
+00000000 T __XimResetIMInstantiateCallback libX11 imInsClbk
+00000000 T __XimDestroyIMStructureList libX11 imInt
+00000000 T __XimServerDestroy libX11 imInt
+00000000 T __DUMMY__ libX11 imInt
+00000000 T __XInitIM libX11 imInt
+00000000 T __XimLocalFilter libX11 imLcFlt
+00000000 T __XimLocalGetICValues libX11 imLcGIc
+00000000 T __XimLocalCreateIC libX11 imLcIc
+00000000 T __XimCheckIfLocalProcessing libX11 imLcIm
+00000000 T __XimLocalIMFree libX11 imLcIm
+00000000 T __XimLocalGetIMValues libX11 imLcIm
+00000000 T __XimLocalSetIMValues libX11 imLcIm
+00000000 T __XimLocalOpenIM libX11 imLcIm
+00000000 T __XimLocalMbLookupString libX11 imLcLkup
+00000000 T __XimLocalWcLookupString libX11 imLcLkup
+00000000 T __XimParseStringFile libX11 imLcPrs
+00000000 T __XimSetICValueData libX11 imLcSIc
+00000000 T __XimLocalSetICValues libX11 imLcSIc
+00000000 T __XimSetIMResourceList libX11 imRm
+00000000 T __XimSetICResourceList libX11 imRm
+00000000 T __XimSetInnerIMResourceList libX11 imRm
+00000000 T __XimSetInnerICResourceList libX11 imRm
+00000000 T __XimCheckCreateICValues libX11 imRm
+00000000 T __XimGetResourceListRec libX11 imRm
+00000000 T __XimSetIMMode libX11 imRm
+00000000 T __XimCheckIMMode libX11 imRm
+00000000 T __XimSetICMode libX11 imRm
+00000000 T __XimCheckICMode libX11 imRm
+00000000 T __XimSetLocalIMDefaults libX11 imRm
+00000000 T __XimSetICDefaults libX11 imRm
+00000000 T __XimDecodeLocalIMAttr libX11 imRm
+00000000 T __XimDecodeLocalICAttr libX11 imRm
+00000000 T __XimCheckLocalInputStyle libX11 imRm
+00000000 T __XimEncodeLocalIMAttr libX11 imRm
+00000000 T __XimEncodeLocalICAttr libX11 imRm
+00000000 T __XimGetCurrentIMValues libX11 imRm
+00000000 T __XimSetCurrentIMValues libX11 imRm
+00000000 T __XimGetCurrentICValues libX11 imRm
+00000000 T __XimSetCurrentICValues libX11 imRm
+00000000 T __XimInitialResourceInfo libX11 imRm
+00000000 T __XimDecodeIMATTRIBUTE libX11 imRmAttr
+00000000 T __XimDecodeICATTRIBUTE libX11 imRmAttr
+00000000 T __XimEncodeIMATTRIBUTE libX11 imRmAttr
+00000000 T __XimEncodeICATTRIBUTE libX11 imRmAttr
+00000000 T __XimGetAttributeID libX11 imRmAttr
+00000000 T __XimThaiFilter libX11 imThaiFlt
+00000000 T __XimThaiCreateIC libX11 imThaiIc
+00000000 T __XimCheckIfThaiProcessing libX11 imThaiIm
+00000000 T __XimThaiOpenIM libX11 imThaiIm
+00000000 T __XimThaiIMFree libX11 imThaiIm
+00000000 T __XimThaiCloseIM libX11 imThaiIm
+00000000 T __XimXConf libX11 imTrX
+00000000 T __XimConnect libX11 imTransR
+00000000 T __XimShutdown libX11 imTransR
+00000000 T __XimFlush libX11 imTransR
+00000000 T __XimFilterWaitEvent libX11 imTransR
+00000000 T __XimFreeTransIntrCallback libX11 imTrans
+00000000 T __XimTransFilterWaitEvent libX11 imTrans
+00000000 T __XimTransInternalConnection libX11 imTrans
+00000000 T __XimTransFlush libX11 imTrans
+00000000 T __XimTransConf libX11 imTrans
+00000000 T __XlcParseCharSet libX11 lcCT
+00000000 T __XlcInitCTInfo libX11 lcCT
+00000000 T __XlcGetCSValues libX11 lcCharSet
+00000000 T __XlcGetCharSet libX11 lcCharSet
+00000000 T __XlcAddCharSet libX11 lcCharSet
+00000000 T __XlcCreateDefaultCharSet libX11 lcCharSet
+00000000 T __XlcSetConverter libX11 lcConv
+00000000 T __XlcOpenConverter libX11 lcConv
+00000000 T __XlcCloseConverter libX11 lcConv
+00000000 T __XlcConvert libX11 lcConv
+00000000 T __XlcResetConverter libX11 lcConv
+00000000 T __XlcGetResource libX11 lcDB
+00000000 T __XlcGetLocaleDataBase libX11 lcDB
+00000000 T __XlcDestroyLocaleDataBase libX11 lcDB
+00000000 T __XlcCreateLocaleDataBase libX11 lcDB
+00000000 T __XlcEucLoader libX11 lcEuc
+00000000 T __XlcFileName libX11 lcFile
+00000000 T __XlcResolveLocaleName libX11 lcFile
+00000000 T __XlcResolveDBName libX11 lcFile
+00000000 T __XlcResolveI18NPath libX11 lcFile
+00000000 T __XlcGenericLoader libX11 lcGenConv
+00000000 T __XlcInitLoader libX11 lcInit
+00000000 T __XmbTextPropertyToTextList libX11 lcPrTxt
+00000000 T __XwcTextPropertyToTextList libX11 lcPrTxt
+00000000 T __XwcFreeStringList libX11 lcPrTxt
+00000000 T __XGetLCValues libX11 lcPubWrap
+00000000 T __XlcDestroyLC libX11 lcPubWrap
+00000000 T __XlcCreateLC libX11 lcPubWrap
+00000000 T __XrmDefaultInitParseInfo libX11 lcRM
+00000000 T __XlcSjisLoader libX11 lcSjis
+00000000 T __Xlcmbtowc libX11 lcStd
+00000000 T __Xlcwctomb libX11 lcStd
+00000000 T __Xlcmbstowcs libX11 lcStd
+00000000 T __Xlcwcstombs libX11 lcStd
+00000000 T __Xmbtowc libX11 lcStd
+00000000 T __Xwctomb libX11 lcStd
+00000000 T __Xmbstowcs libX11 lcStd
+00000000 T __Xwcstombs libX11 lcStd
+00000000 T __Xwcscpy libX11 lcStd
+00000000 T __Xwcsncpy libX11 lcStd
+00000000 T __Xwcslen libX11 lcStd
+00000000 T __Xwcscmp libX11 lcStd
+00000000 T __Xwcsncmp libX11 lcStd
+00000000 T __XmbTextListToTextProperty libX11 lcTxtPr
+00000000 T __XwcTextListToTextProperty libX11 lcTxtPr
+00000000 T __XlcUtfLoader libX11 lcUTF
+00000000 T __XlcCompareISOLatin1 libX11 lcUtil
+00000000 T __XlcNCompareISOLatin1 libX11 lcUtil
+00000000 T __DUMMY__ libX11 omDefault
+00000000 T __DUMMY__ libX11 omDefault
+00000000 T __DUMMY__ libX11 omDefault
+00000000 T __DUMMY__ libX11 omDefault
+00000000 T __DUMMY__ libX11 omDefault
+00000000 T __DUMMY__ libX11 omDefault
+00000000 T __DUMMY__ libX11 omDefault
+00000000 T __DUMMY__ libX11 omDefault
+00000000 T __DUMMY__ libX11 omDefault
+00000000 T __DUMMY__ libX11 omDefault
+00000000 T __XomGenericOpenOM libX11 omGeneric
+00000000 T __XInitOM libX11 omGeneric
+00000000 T __XmbGenericDrawImageString libX11 omImText
+00000000 T __XwcGenericDrawImageString libX11 omImText
+00000000 T __XomGenericDrawString libX11 omText
+00000000 T __XmbGenericDrawString libX11 omText
+00000000 T __XwcGenericDrawString libX11 omText
+00000000 T __XmbGenericTextEscapement libX11 omTextEsc
+00000000 T __XwcGenericTextEscapement libX11 omTextEsc
+00000000 T __XomGenericTextExtents libX11 omTextExt
+00000000 T __XmbGenericTextExtents libX11 omTextExt
+00000000 T __XwcGenericTextExtents libX11 omTextExt
+00000000 T __XmbGenericTextPerCharExtents libX11 omTextPer
+00000000 T __XwcGenericTextPerCharExtents libX11 omTextPer
+00000000 T __XomConvert libX11 omXChar
+00000000 T __XomInitConverter libX11 omXChar
+00000000 T __Xmblen libX11 lcStd
+00000000 T _SmcOpenConnection libSM sm_client
+00000000 T _SmcCloseConnection libSM sm_client
+00000000 T _SmcModifyCallbacks libSM sm_client
+00000000 T _SmcSetProperties libSM sm_client
+00000000 T _SmcDeleteProperties libSM sm_client
+00000000 T _SmcGetProperties libSM sm_client
+00000000 T _SmcInteractRequest libSM sm_client
+00000000 T _SmcInteractDone libSM sm_client
+00000000 T _SmcSaveYourselfDone libSM sm_client
+00000000 T _SmsGenerateClientID libSM sm_genid
+00000000 T _SmsInitialize libSM sm_manager
+00000000 T _SmsClientHostName libSM sm_manager
+00000000 T _SmsRegisterClientReply libSM sm_manager
+00000000 T _SmsSaveYourself libSM sm_manager
+00000000 T _SmsInteract libSM sm_manager
+00000000 T _SmsDie libSM sm_manager
+00000000 T _SmsShutdownCancelled libSM sm_manager
+00000000 T _SmsReturnProperties libSM sm_manager
+00000000 T _SmsCleanUp libSM sm_manager
+00000000 T __SmcProcessMessage libSM sm_process
+00000000 T __SmsProcessMessage libSM sm_process
+00000000 T __SmcDefaultErrorHandler libSM sm_error
+00000000 T __SmsDefaultErrorHandler libSM sm_error
+00000000 T _SmcSetErrorHandler libSM sm_error
+00000000 T _SmsSetErrorHandler libSM sm_error
+00000000 T _SmFreeProperty libSM sm_misc
+00000000 T _SmFreeReasons libSM sm_misc
+00000000 T _SmcProtocolVersion libSM sm_misc
+00000000 T _SmcProtocolRevision libSM sm_misc
+00000000 T _SmcVendor libSM sm_misc
+00000000 T _SmcRelease libSM sm_misc
+00000000 T _SmcClientID libSM sm_misc
+00000000 T _SmcGetIceConnection libSM sm_misc
+00000000 T _SmsProtocolVersion libSM sm_misc
+00000000 T _SmsProtocolRevision libSM sm_misc
+00000000 T _SmsClientID libSM sm_misc
+00000000 T _SmsGetIceConnection libSM sm_misc
+00000000 T _IceAcceptConnection libICE accept
+00000000 T _IceAuthFileName libICE authutil
+00000000 T _IceLockAuthFile libICE authutil
+00000000 T _IceUnlockAuthFile libICE authutil
+00000000 T _IceReadAuthFileEntry libICE authutil
+00000000 T _IceFreeAuthFileEntry libICE authutil
+00000000 T _IceWriteAuthFileEntry libICE authutil
+00000000 T _IceGetAuthFileEntry libICE authutil
+00000000 T _IceOpenConnection libICE connect
+00000000 T __IceErrorBadMinor libICE error
+00000000 T __IceErrorBadState libICE error
+00000000 T __IceErrorBadLength libICE error
+00000000 T __IceErrorBadValue libICE error
+00000000 T __IceErrorNoAuthentication libICE error
+00000000 T __IceErrorNoVersion libICE error
+00000000 T __IceErrorAuthenticationRejected libICE error
+00000000 T __IceErrorAuthenticationFailed libICE error
+00000000 T __IceErrorProtocolDuplicate libICE error
+00000000 T __IceErrorMajorOpcodeDuplicate libICE error
+00000000 T __IceErrorUnknownProtocol libICE error
+00000000 T __IceErrorBadMajor libICE error
+00000000 T __IceDefaultErrorHandler libICE error
+00000000 T _IceSetErrorHandler libICE error
+00000000 T __IceDefaultIOErrorHandler libICE error
+00000000 T _IceSetIOErrorHandler libICE error
+00000000 T __IceGetPoValidAuthIndices libICE getauth
+00000000 T __IceGetPaValidAuthIndices libICE getauth
+00000000 T __IcePoMagicCookie1Proc libICE iceauth
+00000000 T __IcePaMagicCookie1Proc libICE iceauth
+00000000 T _IceListenForConnections libICE listen
+00000000 T _IceComposeNetworkIdList libICE listen
+00000000 T _IceSetHostBasedAuthProc libICE listen
+00000000 T _IceInitThreads libICE locking
+00000000 T _IceAllocScratch libICE misc
+00000000 T _IceConnectionStatus libICE misc
+00000000 T _IceVendor libICE misc
+00000000 T _IceRelease libICE misc
+00000000 T _IceProtocolVersion libICE misc
+00000000 T _IceProtocolRevision libICE misc
+00000000 T _IceConnectionNumber libICE misc
+00000000 T _IceConnectionString libICE misc
+00000000 T __IceRead libICE misc
+00000000 T __IceReadSkip libICE misc
+00000000 T __IceWrite libICE misc
+00000000 T __IceAddOpcodeMapping libICE misc
+00000000 T __IceGetPeerName libICE misc
+00000000 T _IcePing libICE ping
+00000000 T __IceProcessCoreMessage libICE process
+00000000 T _IceProtocolSetup libICE protosetup
+00000000 T _IceRegisterForProtocolSetup libICE register
+00000000 T _IceRegisterForProtocolReply libICE register
+00000000 T __IceAddReplyWait libICE replywait
+00000000 T __IceSearchReplyWaits libICE replywait
+00000000 T __IceSetReplyReady libICE replywait
+00000000 T __IceCheckReplyReady libICE replywait
+00000000 T _IceSetPaAuthData libICE setauth
+00000000 T _IceProtocolShutdown libICE shutdown
+00000000 T _IceSetShutdownNegotiation libICE shutdown
+00000000 T _IceCheckShutdownNegotiation libICE shutdown
+00000000 T _IceCloseConnection libICE shutdown
+00000000 T __IceFreeConnection libICE shutdown
+00000000 T _IceAddConnectionWatch libICE watch
+00000000 T _IceRemoveConnectionWatch libICE watch
+00000000 T __IceConnectionOpened libICE watch
+00000000 T __IceConnectionClosed libICE watch
+00000000 T __XimGetResourceName libX11 imRm
+00000000 T __XimGetResourceListRecByQuark libX11 imRm
+00000000 T __XimSetIMValueData libX11 imRm
+00000000 T __XimGetIMValueData libX11 imRm
+00000000 T __XimGetICValueData libX11 imRm
+00000000 T __XimMakeIMAttrIDList libX11 imRmAttr
+00000000 T __XimMakeICAttrIDList libX11 imRmAttr
+00000000 T __XimWrite libX11 imTransR
+00000000 T __XimRead libX11 imTransR
+00000000 T __XimRegisterDispatcher libX11 imTransR
+00000000 T __XimTransRegisterDispatcher libX11 imTrans
+00000000 T __XimTransCallDispatcher libX11 imTrans
+00000000 T __XimTransWrite libX11 imTrans
+00000000 T __XimTransRead libX11 imTrans
+00000000 T __XimXTransFreeConnInfo libX11 ximtrans
+00000000 T __XimXTransOpenCOTSClient libX11 ximtrans
+00000000 T __XimXTransOpenCLTSClient libX11 ximtrans
+00000000 T __XimXTransSetOption libX11 ximtrans
+00000000 T __XimXTransConnect libX11 ximtrans
+00000000 T __XimXTransBytesReadable libX11 ximtrans
+00000000 T __XimXTransRead libX11 ximtrans
+00000000 T __XimXTransWrite libX11 ximtrans
+00000000 T __XimXTransReadv libX11 ximtrans
+00000000 T __XimXTransWritev libX11 ximtrans
+00000000 T __XimXTransDisconnect libX11 ximtrans
+00000000 T __XimXTransClose libX11 ximtrans
+00000000 T __XimXTransCloseForCloning libX11 ximtrans
+00000000 T __XimXTransIsLocal libX11 ximtrans
+00000000 T __XimXTransGetMyAddr libX11 ximtrans
+00000000 T __XimXTransGetPeerAddr libX11 ximtrans
+00000000 T __XimXTransGetConnectionNumber libX11 ximtrans
+00000000 T __XimXTransGetHostname libX11 ximtrans
+00000000 T _SmcRequestSaveYourself libSM sm_client
+00000000 T _SmcRequestSaveYourselfPhase2 libSM sm_client
+00000000 T __SmsProtocolSetupProc libSM sm_manager
+00000000 T _SmsSaveYourselfPhase2 libSM sm_manager
+00000000 T _SmsSaveComplete libSM sm_manager
+00000000 T _IceGetConnectionContext libICE connect
+00000000 T __IceErrorSetupFailed libICE error
+00000000 T __IceGetPoAuthData libICE getauth
+00000000 T __IceGetPaAuthData libICE getauth
+00000000 T _IceGenerateMagicCookie libICE iceauth
+00000000 T _IceGetListenConnectionNumber libICE listen
+00000000 T _IceGetListenConnectionString libICE listen
+00000000 T _IceFreeListenObjs libICE listen
+00000000 T _IceAppLockConn libICE locking
+00000000 T _IceAppUnlockConn libICE locking
+00000000 T _IceFlush libICE misc
+00000000 T _IceGetOutBufSize libICE misc
+00000000 T _IceGetInBufSize libICE misc
+00000000 T _IceLastSentSequenceNumber libICE misc
+00000000 T _IceLastReceivedSequenceNumber libICE misc
+00000000 T _IceSwapping libICE misc
+00000000 T _IceProcessMessages libICE process
+00000000 T __IceTransFreeConnInfo libICE transport
+00000000 T __IceTransOpenCOTSClient libICE transport
+00000000 T __IceTransOpenCOTSServer libICE transport
+00000000 T __IceTransOpenCLTSClient libICE transport
+00000000 T __IceTransOpenCLTSServer libICE transport
+00000000 T __IceTransSetOption libICE transport
+00000000 T __IceTransCreateListener libICE transport
+00000000 T __IceTransResetListener libICE transport
+00000000 T __IceTransAccept libICE transport
+00000000 T __IceTransConnect libICE transport
+00000000 T __IceTransBytesReadable libICE transport
+00000000 T __IceTransRead libICE transport
+00000000 T __IceTransWrite libICE transport
+00000000 T __IceTransReadv libICE transport
+00000000 T __IceTransWritev libICE transport
+00000000 T __IceTransDisconnect libICE transport
+00000000 T __IceTransClose libICE transport
+00000000 T __IceTransCloseForCloning libICE transport
+00000000 T __IceTransIsLocal libICE transport
+00000000 T __IceTransGetMyAddr libICE transport
+00000000 T __IceTransGetPeerAddr libICE transport
+00000000 T __IceTransGetConnectionNumber libICE transport
+00000000 T __IceTransMakeAllCOTSServerListeners libICE transport
+00000000 T __IceTransMakeAllCLTSServerListeners libICE transport
+00000000 T __IceTransGetHostname libICE transport
+00000000 T __IceTransGetMyNetworkId libICE transport
+00000000 T __IceTransGetPeerNetworkId libICE transport
+00000000 T __XimLcctstombs libX11 imLcLkup
+00000000 T __XimLcctstowcs libX11 imLcLkup
+#ifdef HASXDMAUTH
+00000000 T _XdmcpWrap libX11 Wrap
+00000000 T __XdmcpWrapperToOddParity libX11 Wrap
+00000000 T __XdmcpAuthSetup libX11 Wraphelp
+00000000 T __XdmcpAuthDoIt libX11 Wraphelp
+#else
+00000000 T __DUMMY__ libX11 Wrap
+00000000 T __DUMMY__ libX11 Wrap
+00000000 T __DUMMY__ libX11 Wraphelp
+00000000 T __DUMMY__ libX11 Wraphelp
+#endif
+#ifdef X_LOCALE
+00000000 T __Xsetlocale libX11 SetLocale
+#else
+00000000 T __DUMMY__ libX11 SetLocale
+#endif
+#ifdef XKB
+#undef XKB
+00000000 T _XkbQueryExtension libX11 XKB
+00000000 T _XkbLibraryVersion libX11 XKB
+00000000 T _XkbSelectEvents libX11 XKB
+00000000 T _XkbSelectEventDetails libX11 XKB
+00000000 T _XkbLockModifiers libX11 XKB
+00000000 T _XkbLatchModifiers libX11 XKB
+00000000 T _XkbLockGroup libX11 XKB
+00000000 T _XkbLatchGroup libX11 XKB
+00000000 T _XkbSetXlibControls libX11 XKB
+00000000 T _XkbGetXlibControls libX11 XKB
+00000000 T _XkbXlibControlsImplemented libX11 XKB
+00000000 T _XkbSetDebuggingFlags libX11 XKB
+00000000 T _XkbComputeEffectiveMap libX11 XKB
+00000000 T _XkbGetState libX11 XKB
+00000000 T _XkbSetDetectableAutoRepeat libX11 XKB
+00000000 T _XkbGetDetectableAutoRepeat libX11 XKB
+00000000 T _XkbSetAutoResetControls libX11 XKB
+00000000 T _XkbGetAutoResetControls libX11 XKB
+00000000 T _XkbOpenDisplay libX11 XKB
+00000000 T _XkbSetAtomFuncs libX11 XKB
+00000000 T _XkbKeycodeToKeysym libX11 XKBBind
+00000000 T _XkbKeysymToModifiers libX11 XKBBind
+00000000 T _XkbTranslateKey libX11 XKBBind
+00000000 T _XkbLookupKeySym libX11 XKBBind
+00000000 T _XkbTranslateKeyCode libX11 XKBBind
+00000000 T _XkbRefreshKeyboardMapping libX11 XKBBind
+00000000 T _XkbTranslateKeySym libX11 XKBBind
+00000000 T _XkbLookupKeyBinding libX11 XKBBind
+00000000 T _XkbToControl libX11 XKBBind
+00000000 T _XkbGetCompatMap libX11 XKBCompat
+00000000 T _XkbSetCompatMap libX11 XKBCompat
+00000000 T _XkbSetAutoRepeatRate libX11 XKBCtrls
+00000000 T _XkbGetAutoRepeatRate libX11 XKBCtrls
+00000000 T _XkbSetServerInternalMods libX11 XKBCtrls
+00000000 T _XkbSetIgnoreLockMods libX11 XKBCtrls
+00000000 T _XkbChangeEnabledControls libX11 XKBCtrls
+00000000 T _XkbGetControls libX11 XKBCtrls
+00000000 T _XkbSetControls libX11 XKBCtrls
+00000000 T _XkbNoteControlsChanges libX11 XKBCtrls
+00000000 T _XkbGetUpdatedMap libX11 XKBGetMap
+00000000 T _XkbGetMap libX11 XKBGetMap
+00000000 T _XkbGetKeyTypes libX11 XKBGetMap
+00000000 T _XkbGetKeyActions libX11 XKBGetMap
+00000000 T _XkbGetKeySyms libX11 XKBGetMap
+00000000 T _XkbGetKeyBehaviors libX11 XKBGetMap
+00000000 T _XkbGetVirtualMods libX11 XKBGetMap
+00000000 T _XkbGetKeyExplicitComponents libX11 XKBGetMap
+00000000 T _XkbGetKeyModifierMap libX11 XKBGetMap
+00000000 T _XkbGetKeyVirtualModMap libX11 XKBGetMap
+00000000 T _XkbGetMapChanges libX11 XKBGetMap
+00000000 T _XkbGetKeyboardByName libX11 XKBGetByName
+00000000 T _XkbGetKeyboard libX11 XKBGetByName
+00000000 T _XkbGetNames libX11 XKBNames
+00000000 T _XkbSetNames libX11 XKBNames
+00000000 T _XkbChangeNames libX11 XKBNames
+00000000 T _XkbNoteNameChanges libX11 XKBNames
+00000000 T _XkbSetMap libX11 XKBSetMap
+00000000 T _XkbChangeMap libX11 XKBSetMap
+00000000 T _XkbNoteMapChanges libX11 XKBUse
+00000000 T _XkbIgnoreExtension libX11 XKBUse
+00000000 T _XkbUseExtension libX11 XKBUse
+00000000 T _XkbGetIndicatorState libX11 XKBleds
+00000000 T _XkbGetIndicatorMap libX11 XKBleds
+00000000 T _XkbSetIndicatorMap libX11 XKBleds
+00000000 T _XkbGetNamedDeviceIndicator libX11 XKBleds
+00000000 T _XkbGetNamedIndicator libX11 XKBleds
+00000000 T _XkbSetNamedDeviceIndicator libX11 XKBleds
+00000000 T _XkbSetNamedIndicator libX11 XKBleds
+00000000 T _XkbDeviceBell libX11 XKBBell
+00000000 T _XkbForceDeviceBell libX11 XKBBell
+00000000 T _XkbDeviceBellEvent libX11 XKBBell
+00000000 T _XkbBell libX11 XKBBell
+00000000 T _XkbForceBell libX11 XKBBell
+00000000 T _XkbBellEvent libX11 XKBBell
+00000000 T _XkbComputeShapeBounds libX11 XKBGeom
+00000000 T _XkbComputeShapeTop libX11 XKBGeom
+00000000 T _XkbComputeRowBounds libX11 XKBGeom
+00000000 T _XkbComputeSectionBounds libX11 XKBGeom
+00000000 T _XkbFindOverlayForKey libX11 XKBGeom
+00000000 T _XkbGetGeometry libX11 XKBGeom
+00000000 T _XkbGetNamedGeometry libX11 XKBGeom
+00000000 T _XkbSetGeometry libX11 XKBSetGeom
+00000000 T _XkbNoteDeviceChanges libX11 XKBExtDev
+00000000 T _XkbGetDeviceInfo libX11 XKBExtDev
+00000000 T _XkbGetDeviceInfoChanges libX11 XKBExtDev
+00000000 T _XkbGetDeviceButtonActions libX11 XKBExtDev
+00000000 T _XkbGetDeviceLedInfo libX11 XKBExtDev
+00000000 T _XkbSetDeviceInfo libX11 XKBExtDev
+00000000 T _XkbChangeDeviceInfo libX11 XKBExtDev
+00000000 T _XkbSetDeviceLedInfo libX11 XKBExtDev
+00000000 T _XkbSetDeviceButtonActions libX11 XKBExtDev
+00000000 T _XkbListComponents libX11 XKBList
+00000000 T _XkbFreeComponentList libX11 XKBList
+00000000 T _XkbInitCanonicalKeyTypes libX11 XKBMisc
+00000000 T _XkbKeyTypesForCoreSymbols libX11 XKBMisc
+00000000 T _XkbApplyCompatMapToKey libX11 XKBMisc
+00000000 T _XkbUpdateMapFromCore libX11 XKBMisc
+00000000 T _XkbChangeTypesOfKey libX11 XKBMisc
+00000000 T _XkbVirtualModsToReal libX11 XKBMisc
+00000000 T _XkbUpdateActionVirtualMods libX11 XKBMisc
+00000000 T _XkbUpdateKeyTypeVirtualMods libX11 XKBMisc
+00000000 T _XkbApplyVirtualModChanges libX11 XKBMisc
+00000000 T _XkbAllocClientMap libX11 XKBMAlloc
+00000000 T _XkbAllocServerMap libX11 XKBMAlloc
+00000000 T _XkbCopyKeyType libX11 XKBMAlloc
+00000000 T _XkbCopyKeyTypes libX11 XKBMAlloc
+00000000 T _XkbAddKeyType libX11 XKBMAlloc
+00000000 T _XkbResizeKeyType libX11 XKBMAlloc
+00000000 T _XkbResizeKeySyms libX11 XKBMAlloc
+00000000 T _XkbResizeKeyActions libX11 XKBMAlloc
+00000000 T _XkbFreeClientMap libX11 XKBMAlloc
+00000000 T _XkbFreeServerMap libX11 XKBMAlloc
+00000000 T _XkbFreeGeomProperties libX11 XKBGAlloc
+00000000 T _XkbFreeGeomKeyAliases libX11 XKBGAlloc
+00000000 T _XkbFreeGeomColors libX11 XKBGAlloc
+00000000 T _XkbFreeGeomPoints libX11 XKBGAlloc
+00000000 T _XkbFreeGeomOutlines libX11 XKBGAlloc
+00000000 T _XkbFreeGeomShapes libX11 XKBGAlloc
+00000000 T _XkbFreeGeomOverlayKeys libX11 XKBGAlloc
+00000000 T _XkbFreeGeomOverlayRows libX11 XKBGAlloc
+00000000 T _XkbFreeGeomOverlays libX11 XKBGAlloc
+00000000 T _XkbFreeGeomKeys libX11 XKBGAlloc
+00000000 T _XkbFreeGeomRows libX11 XKBGAlloc
+00000000 T _XkbFreeGeomSections libX11 XKBGAlloc
+00000000 T _XkbFreeGeomDoodads libX11 XKBGAlloc
+00000000 T _XkbFreeGeometry libX11 XKBGAlloc
+00000000 T _XkbAllocGeomProps libX11 XKBGAlloc
+00000000 T _XkbAllocGeomColors libX11 XKBGAlloc
+00000000 T _XkbAllocGeomKeyAliases libX11 XKBGAlloc
+00000000 T _XkbAllocGeomShapes libX11 XKBGAlloc
+00000000 T _XkbAllocGeomSections libX11 XKBGAlloc
+00000000 T _XkbAllocGeomOverlays libX11 XKBGAlloc
+00000000 T _XkbAllocGeomOverlayRows libX11 XKBGAlloc
+00000000 T _XkbAllocGeomOverlayKeys libX11 XKBGAlloc
+00000000 T _XkbAllocGeomDoodads libX11 XKBGAlloc
+00000000 T _XkbAllocGeomSectionDoodads libX11 XKBGAlloc
+00000000 T _XkbAllocGeomOutlines libX11 XKBGAlloc
+00000000 T _XkbAllocGeomRows libX11 XKBGAlloc
+00000000 T _XkbAllocGeomPoints libX11 XKBGAlloc
+00000000 T _XkbAllocGeomKeys libX11 XKBGAlloc
+00000000 T _XkbAllocGeometry libX11 XKBGAlloc
+00000000 T _XkbAddGeomProperty libX11 XKBGAlloc
+00000000 T _XkbAddGeomKeyAlias libX11 XKBGAlloc
+00000000 T _XkbAddGeomColor libX11 XKBGAlloc
+00000000 T _XkbAddGeomOutline libX11 XKBGAlloc
+00000000 T _XkbAddGeomShape libX11 XKBGAlloc
+00000000 T _XkbAddGeomKey libX11 XKBGAlloc
+00000000 T _XkbAddGeomRow libX11 XKBGAlloc
+00000000 T _XkbAddGeomSection libX11 XKBGAlloc
+00000000 T _XkbAddGeomDoodad libX11 XKBGAlloc
+00000000 T _XkbAddGeomOverlayKey libX11 XKBGAlloc
+00000000 T _XkbAddGeomOverlayRow libX11 XKBGAlloc
+00000000 T _XkbAddGeomOverlay libX11 XKBGAlloc
+00000000 T _XkbAllocCompatMap libX11 XKBAlloc
+00000000 T _XkbFreeCompatMap libX11 XKBAlloc
+00000000 T _XkbAllocNames libX11 XKBAlloc
+00000000 T _XkbFreeNames libX11 XKBAlloc
+00000000 T _XkbAllocControls libX11 XKBAlloc
+00000000 T _XkbFreeControls libX11 XKBAlloc
+00000000 T _XkbAllocIndicatorMaps libX11 XKBAlloc
+00000000 T _XkbFreeIndicatorMaps libX11 XKBAlloc
+00000000 T _XkbAllocKeyboard libX11 XKBAlloc
+00000000 T _XkbFreeKeyboard libX11 XKBAlloc
+00000000 T _XkbAddDeviceLedInfo libX11 XKBAlloc
+00000000 T _XkbResizeDeviceButtonActions libX11 XKBAlloc
+00000000 T _XkbAllocDeviceInfo libX11 XKBAlloc
+00000000 T _XkbFreeDeviceInfo libX11 XKBAlloc
+00000000 T _XkbChangeKeycodeRange libX11 XKBMAlloc
+#else
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKB
+00000000 T __DUMMY__ libX11 XKBBind
+00000000 T __DUMMY__ libX11 XKBBind
+00000000 T __DUMMY__ libX11 XKBBind
+00000000 T __DUMMY__ libX11 XKBBind
+00000000 T __DUMMY__ libX11 XKBBind
+00000000 T __DUMMY__ libX11 XKBBind
+00000000 T __DUMMY__ libX11 XKBBind
+00000000 T __DUMMY__ libX11 XKBBind
+00000000 T __DUMMY__ libX11 XKBBind
+00000000 T __DUMMY__ libX11 XKBCompat
+00000000 T __DUMMY__ libX11 XKBCompat
+00000000 T __DUMMY__ libX11 XKBCtrls
+00000000 T __DUMMY__ libX11 XKBCtrls
+00000000 T __DUMMY__ libX11 XKBCtrls
+00000000 T __DUMMY__ libX11 XKBCtrls
+00000000 T __DUMMY__ libX11 XKBCtrls
+00000000 T __DUMMY__ libX11 XKBCtrls
+00000000 T __DUMMY__ libX11 XKBCtrls
+00000000 T __DUMMY__ libX11 XKBCtrls
+00000000 T __DUMMY__ libX11 XKBGetMap
+00000000 T __DUMMY__ libX11 XKBGetMap
+00000000 T __DUMMY__ libX11 XKBGetMap
+00000000 T __DUMMY__ libX11 XKBGetMap
+00000000 T __DUMMY__ libX11 XKBGetMap
+00000000 T __DUMMY__ libX11 XKBGetMap
+00000000 T __DUMMY__ libX11 XKBGetMap
+00000000 T __DUMMY__ libX11 XKBGetMap
+00000000 T __DUMMY__ libX11 XKBGetMap
+00000000 T __DUMMY__ libX11 XKBGetMap
+00000000 T __DUMMY__ libX11 XKBGetMap
+00000000 T __DUMMY__ libX11 XKBGetByName
+00000000 T __DUMMY__ libX11 XKBGetByName
+00000000 T __DUMMY__ libX11 XKBNames
+00000000 T __DUMMY__ libX11 XKBNames
+00000000 T __DUMMY__ libX11 XKBNames
+00000000 T __DUMMY__ libX11 XKBNames
+00000000 T __DUMMY__ libX11 XKBSetMap
+00000000 T __DUMMY__ libX11 XKBSetMap
+00000000 T __DUMMY__ libX11 XKBUse
+00000000 T __DUMMY__ libX11 XKBUse
+00000000 T __DUMMY__ libX11 XKBUse
+00000000 T __DUMMY__ libX11 XKBleds
+00000000 T __DUMMY__ libX11 XKBleds
+00000000 T __DUMMY__ libX11 XKBleds
+00000000 T __DUMMY__ libX11 XKBleds
+00000000 T __DUMMY__ libX11 XKBleds
+00000000 T __DUMMY__ libX11 XKBleds
+00000000 T __DUMMY__ libX11 XKBleds
+00000000 T __DUMMY__ libX11 XKBBell
+00000000 T __DUMMY__ libX11 XKBBell
+00000000 T __DUMMY__ libX11 XKBBell
+00000000 T __DUMMY__ libX11 XKBBell
+00000000 T __DUMMY__ libX11 XKBBell
+00000000 T __DUMMY__ libX11 XKBBell
+00000000 T __DUMMY__ libX11 XKBGeom
+00000000 T __DUMMY__ libX11 XKBGeom
+00000000 T __DUMMY__ libX11 XKBGeom
+00000000 T __DUMMY__ libX11 XKBGeom
+00000000 T __DUMMY__ libX11 XKBGeom
+00000000 T __DUMMY__ libX11 XKBGeom
+00000000 T __DUMMY__ libX11 XKBGeom
+00000000 T __DUMMY__ libX11 XKBSetGeom
+00000000 T __DUMMY__ libX11 XKBExtDev
+00000000 T __DUMMY__ libX11 XKBExtDev
+00000000 T __DUMMY__ libX11 XKBExtDev
+00000000 T __DUMMY__ libX11 XKBExtDev
+00000000 T __DUMMY__ libX11 XKBExtDev
+00000000 T __DUMMY__ libX11 XKBExtDev
+00000000 T __DUMMY__ libX11 XKBExtDev
+00000000 T __DUMMY__ libX11 XKBExtDev
+00000000 T __DUMMY__ libX11 XKBExtDev
+00000000 T __DUMMY__ libX11 XKBList
+00000000 T __DUMMY__ libX11 XKBList
+00000000 T __DUMMY__ libX11 XKBMisc
+00000000 T __DUMMY__ libX11 XKBMisc
+00000000 T __DUMMY__ libX11 XKBMisc
+00000000 T __DUMMY__ libX11 XKBMisc
+00000000 T __DUMMY__ libX11 XKBMisc
+00000000 T __DUMMY__ libX11 XKBMisc
+00000000 T __DUMMY__ libX11 XKBMisc
+00000000 T __DUMMY__ libX11 XKBMisc
+00000000 T __DUMMY__ libX11 XKBMisc
+00000000 T __DUMMY__ libX11 XKBMAlloc
+00000000 T __DUMMY__ libX11 XKBMAlloc
+00000000 T __DUMMY__ libX11 XKBMAlloc
+00000000 T __DUMMY__ libX11 XKBMAlloc
+00000000 T __DUMMY__ libX11 XKBMAlloc
+00000000 T __DUMMY__ libX11 XKBMAlloc
+00000000 T __DUMMY__ libX11 XKBMAlloc
+00000000 T __DUMMY__ libX11 XKBMAlloc
+00000000 T __DUMMY__ libX11 XKBMAlloc
+00000000 T __DUMMY__ libX11 XKBMAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBGAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+00000000 T __DUMMY__ libX11 XKBAlloc
+#endif
+00000000 T _IceListenForWellKnownConnections libICE listenwk
+00000000 T __IceTransNoListen libICE transport
diff --git a/nx-X11/lib/X11/jump_ignore b/nx-X11/lib/X11/jump_ignore
new file mode 100644
index 000000000..c7eadae90
--- /dev/null
+++ b/nx-X11/lib/X11/jump_ignore
@@ -0,0 +1,67 @@
+# $Xorg: jump_ignore,v 1.3 2000/08/17 19:45:16 cpqbld Exp $
+#
+#
+#
+#
+# $XFree86: xc/lib/X11/jump_ignore,v 3.10 1999/05/30 02:27:59 dawes Exp $
+# jump_ignore
+00000000 T __XlcAddCT libX11 lcCT
+00000000 T __XKeycodeToKeysym libX11 KeyBind
+00000000 T __XKeysymToKeycode libX11 KeyBind
+00000000 T __XLookupKeysym libX11 KeyBind
+00000000 T __XRefreshKeyboardMapping libX11 KeyBind
+00000000 T __XLookupString libX11 KeyBind
+00000000 T __XkbReloadDpy libX11 XKBBind
+00000000 T __XkbReadGetCompatMapReply libX11 XKBCompat
+00000000 T __XkbKSToKnownSet libX11 XKBCvt
+00000000 T __XkbKSToThai libX11 XKBCvt
+00000000 T __XkbGetConverters libX11 XKBCvt
+00000000 T __XkbGetCharset libX11 XKBCvt
+00000000 T __XkbReadGetMapReply libX11 XKBGetMap
+00000000 T __XkbReadGetNamesReply libX11 XKBNames
+00000000 T __XkbInitReadBuffer libX11 XKBRdBuf
+00000000 T __XkbSkipReadBufferData libX11 XKBRdBuf
+00000000 T __XkbCopyFromReadBuffer libX11 XKBRdBuf
+00000000 T __XkbReadCopyKeySyms libX11 XKBRdBuf
+00000000 T __XkbReadBufferCopyKeySyms libX11 XKBRdBuf
+00000000 T __XkbWriteCopyKeySyms libX11 XKBRdBuf
+00000000 T __XkbPeekAtReadBuffer libX11 XKBRdBuf
+00000000 T __XkbGetReadBufferPtr libX11 XKBRdBuf
+00000000 T __XkbFreeReadBuffer libX11 XKBRdBuf
+00000000 T __XkbGetReadBufferCountedString libX11 XKBRdBuf
+00000000 T __XkbNoteCoreMapChanges libX11 XKBUse
+00000000 T __XkbReadGetIndicatorMapReply libX11 XKBleds
+00000000 T __XkbReadGetGeometryReply libX11 XKBGeom
+00000000 T __SendSetGeometry libX11 XKBSetGeom
+00000000 T __XmbDefaultTextEscapement libX11 omDefault
+00000000 T __XwcDefaultTextEscapement libX11 omDefault
+00000000 T __XmbDefaultTextExtents libX11 omDefault
+00000000 T __XwcDefaultTextExtents libX11 omDefault
+00000000 T __XmbDefaultTextPerCharExtents libX11 omDefault
+00000000 T __XwcDefaultTextPerCharExtents libX11 omDefault
+00000000 T __XmbDefaultDrawString libX11 omDefault
+00000000 T __XwcDefaultDrawString libX11 omDefault
+00000000 T __XmbDefaultDrawImageString libX11 omDefault
+00000000 T __XwcDefaultDrawImageString libX11 omDefault
+00000000 T __XSnprintf libX11 snprintf
+00000000 T __XVsnprintf libX11 snprintf
+00000004 D __XkbInternAtomFunc libX11 XKB
+00000004 D __XkbGetAtomNameFunc libX11 XKB
+00000000 T __XTextHeight libX11 TextExt
+00000000 T __XTextHeight16 libX11 TextExt16
+00000000 T _default_ct_data_list libX11 lcCT
+00000000 T _default_ct_data_list_num libX11 lcCT
+00000000 T __XlcParsePath libX11 lcFile
+00000000 T __XlcGetCodeSetFromName libX11 lcGenConv
+00000000 T __XlcParse_scopemaps libX11 lcGeneric
+00000000 T __XlcDbg_printValue libX11 lcGeneric
+00000000 T _add_conversion libX11 lcGeneric
+00000000 T __XlcJisLoader libX11 lcJis
+00000000 T _parse_fontname libX11 omGeneric
+00000000 T _destroy_fontdata libX11 omGeneric
+00000000 T _read_EncodingInfo libX11 omGeneric
+00000000 T __XomGetFontDataFromFontSet libX11 omXChar
+00000000 K __Xcyrillic libX11 XKBCvt
+00000000 K __Xkoi8 libX11 XKBCvt
+00000000 K __Xkoi8u libX11 XKBCvt
+00000000 K __Xgreek libX11 XKBCvt
diff --git a/nx-X11/lib/X11/jump_vars b/nx-X11/lib/X11/jump_vars
new file mode 100644
index 000000000..34e857a14
--- /dev/null
+++ b/nx-X11/lib/X11/jump_vars
@@ -0,0 +1,84 @@
+# $Xorg: jump_vars,v 1.3 2000/08/17 19:45:16 cpqbld Exp $
+#
+#
+#
+#
+# $XFree86: xc/lib/X11/jump_vars,v 3.1 1995/01/28 15:42:57 dawes Exp $
+#
+00008000 K __XkeyTable libX11 XStrKeysym
+00000100 K __Xevent_to_mask libX11 evtomask
+00000004 D __qfree libX11 globals
+00000004 C __XIOErrorFunction libX11 globals
+00000004 C __XErrorFunction libX11 globals
+00000004 C __Xdebug libX11 globals
+00000004 C __XHeadOfDisplayList libX11 globals
+00000040 D _XcmsCIELabColorSpace libX11 CIELab
+00000040 D _XcmsCIELuvColorSpace libX11 CIELuv
+00000040 D _XcmsCIEXYZColorSpace libX11 CIEXYZ
+00000040 D _XcmsCIEuvYColorSpace libX11 CIEuvY
+00000040 D _XcmsCIExyYColorSpace libX11 CIExyY
+00000040 D _XcmsTekHVCColorSpace libX11 TekHVC
+00000040 D _XcmsUNDEFINEDColorSpace libX11 UNDEFINED
+00000040 D __XcmsDIColorSpacesInit libX11 XcmsGlobls
+00000004 D __XcmsDIColorSpaces libX11 XcmsGlobls
+00000020 D __XcmsDDColorSpacesInit libX11 XcmsGlobls
+00000004 D __XcmsDDColorSpaces libX11 XcmsGlobls
+00000010 D __XcmsSCCFuncSetsInit libX11 XcmsGlobls
+00000004 D __XcmsSCCFuncSets libX11 XcmsGlobls
+00000010 D __XcmsCIEXYZ_prefix libX11 XcmsGlobls
+00000010 D __XcmsCIEuvY_prefix libX11 XcmsGlobls
+00000010 D __XcmsCIExyY_prefix libX11 XcmsGlobls
+00000010 D __XcmsCIELab_prefix libX11 XcmsGlobls
+00000010 D __XcmsCIELuv_prefix libX11 XcmsGlobls
+00000010 D __XcmsTekHVC_prefix libX11 XcmsGlobls
+00000010 D __XcmsRGBi_prefix libX11 XcmsGlobls
+00000010 D __XcmsRGB_prefix libX11 XcmsGlobls
+00000080 D __XcmsRegColorSpaces libX11 XcmsGlobls
+00000040 D _XcmsRGBiColorSpace libX11 XcmsLRGB
+00000040 D _XcmsRGBColorSpace libX11 XcmsLRGB
+00000020 D _XcmsLinearRGBFunctionSet libX11 XcmsLRGB
+000000a8 D __X11TransSocketINETFuncs libX11 x11trans
+000000a8 D __X11TransSocketTCPFuncs libX11 x11trans
+000000a8 D __X11TransSocketUNIXFuncs libX11 x11trans
+000000a8 D __X11TransSocketLocalFuncs libX11 x11trans
+000000a8 D __XimXTransSocketINETFuncs libX11 ximtrans
+000000a8 D __XimXTransSocketTCPFuncs libX11 ximtrans
+000000a8 D __XimXTransSocketUNIXFuncs libX11 ximtrans
+000000a8 D __XimXTransSocketLocalFuncs libX11 ximtrans
+00000040 D __XimImSportRec libX11 imImSw
+00000040 D __XimTransportRec libX11 imTransR
+00000004 D __XlcGenericMethods libX11 lcGeneric
+00000004 D __XlcPublicMethods libX11 lcPublic
+00000004 D __SmcOpcode libSM sm_client
+00000004 D __SmsOpcode libSM sm_client
+00000004 D __SmVersionCount libSM sm_client
+00000018 D __SmcVersions libSM sm_client
+00000018 D __SmsVersions libSM sm_client
+00000004 D __SmAuthCount libSM sm_client
+00000004 D __SmAuthNames libSM sm_client
+00000004 D __SmcAuthProcs libSM sm_client
+00000004 D __SmsAuthProcs libSM sm_client
+00000004 D __SmcErrorHandler libSM sm_client
+00000004 D __SmsErrorHandler libSM sm_client
+00000004 C __SmsNewClientProc libSM sm_client
+00000004 C __SmsNewClientData libSM sm_client
+00000004 D __IceConnectionCount libICE connect
+00000004 D __IceLastMajorOpcode libICE connect
+00000004 D __IceAuthCount libICE connect
+00000004 D __IceAuthNames libICE connect
+00000004 D __IcePoAuthProcs libICE connect
+00000004 D __IcePaAuthProcs libICE connect
+00000004 D __IcePaAuthDataEntryCount libICE connect
+00000004 D __IceVersionCount libICE connect
+00000018 D __IceVersions libICE connect
+00000004 D __IceWatchProcs libICE connect
+00000004 D __IceErrorHandler libICE connect
+00000004 D __IceIOErrorHandler libICE connect
+00000600 C __IceConnectionObjs libICE connect
+00000600 C __IceConnectionStrings libICE connect
+00001000 C __IceProtocols libICE connect
+00001000 C __IcePaAuthDataEntries libICE connect
+00000070 D __IceTransSocketINETFuncs libICE transport
+00000070 D __IceTransSocketTCPFuncs libICE transport
+00000070 D __IceTransSocketUNIXFuncs libICE transport
+00000070 D __IceTransSocketLocalFuncs libICE transport
diff --git a/nx-X11/lib/X11/lcCT.c b/nx-X11/lib/X11/lcCT.c
new file mode 100644
index 000000000..63608a3cd
--- /dev/null
+++ b/nx-X11/lib/X11/lcCT.c
@@ -0,0 +1,1303 @@
+/* $Xorg: lcCT.c,v 1.4 2000/08/17 19:45:16 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+/*
+ * 2000
+ * Modifier: Ivan Pascal The XFree86 Project
+ * Modifier: Bruno Haible The XFree86 Project
+ */
+/* $XFree86: xc/lib/X11/lcCT.c,v 3.26 2001/10/28 03:32:34 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include <X11/Xos.h>
+#include <stdio.h>
+
+
+/* ====================== Built-in Character Sets ====================== */
+
+/*
+ * Static representation of a character set that can be used in Compound Text.
+ */
+typedef struct _CTDataRec {
+ const char *name;
+ const char *ct_sequence; /* Compound Text encoding, ESC sequence */
+} CTDataRec, *CTData;
+
+static CTDataRec default_ct_data[] =
+{
+ /* */
+ /* X11 registry name MIME name ISO-IR ESC sequence */
+ /* */
+
+ /* Registered character sets with one byte per character */
+ { "ISO8859-1:GL", /* US-ASCII 6 */ "\033(B" },
+ { "ISO8859-1:GR", /* ISO-8859-1 100 */ "\033-A" },
+ { "ISO8859-2:GR", /* ISO-8859-2 101 */ "\033-B" },
+ { "ISO8859-3:GR", /* ISO-8859-3 109 */ "\033-C" },
+ { "ISO8859-4:GR", /* ISO-8859-4 110 */ "\033-D" },
+ { "ISO8859-5:GR", /* ISO-8859-5 144 */ "\033-L" },
+ { "ISO8859-6:GR", /* ISO-8859-6 127 */ "\033-G" },
+ { "ISO8859-7:GR", /* ISO-8859-7 126 */ "\033-F" },
+ { "ISO8859-8:GR", /* ISO-8859-8 138 */ "\033-H" },
+ { "ISO8859-9:GR", /* ISO-8859-9 148 */ "\033-M" },
+ { "ISO8859-10:GR", /* ISO-8859-10 157 */ "\033-V" },
+ { "ISO8859-11:GR", /* ISO-8859-11 166 */ "\033-T" },
+ { "ISO8859-13:GR", /* ISO-8859-13 179 */ "\033-Y" },
+ { "ISO8859-14:GR", /* ISO-8859-14 199 */ "\033-_" },
+ { "ISO8859-15:GR", /* ISO-8859-15 203 */ "\033-b" },
+ { "ISO8859-16:GR", /* ISO-8859-16 226 */ "\033-f" },
+ { "JISX0201.1976-0:GL", /* ISO-646-JP 14 */ "\033(J" },
+ { "JISX0201.1976-0:GR", "\033)I" },
+#if 0
+ { "TIS620-0:GR", /* TIS-620 166 */ "\033-T" },
+#endif
+
+ /* Registered character sets with two byte per character */
+ { "GB2312.1980-0:GL", /* GB_2312-80 58 */ "\033$(A" },
+ { "GB2312.1980-0:GR", /* GB_2312-80 58 */ "\033$)A" },
+ { "JISX0208.1983-0:GL", /* JIS_X0208-1983 87 */ "\033$(B" },
+ { "JISX0208.1983-0:GR", /* JIS_X0208-1983 87 */ "\033$)B" },
+ { "JISX0208.1990-0:GL", /* JIS_X0208-1990 168 */ "\033$(B" },
+ { "JISX0208.1990-0:GR", /* JIS_X0208-1990 168 */ "\033$)B" },
+ { "JISX0212.1990-0:GL", /* JIS_X0212-1990 159 */ "\033$(D" },
+ { "JISX0212.1990-0:GR", /* JIS_X0212-1990 159 */ "\033$)D" },
+ { "KSC5601.1987-0:GL", /* KS_C_5601-1987 149 */ "\033$(C" },
+ { "KSC5601.1987-0:GR", /* KS_C_5601-1987 149 */ "\033$)C" },
+ { "CNS11643.1986-1:GL", /* CNS 11643-1992 pl.1 171 */ "\033$(G" },
+ { "CNS11643.1986-1:GR", /* CNS 11643-1992 pl.1 171 */ "\033$)G" },
+ { "CNS11643.1986-2:GL", /* CNS 11643-1992 pl.2 172 */ "\033$(H" },
+ { "CNS11643.1986-2:GR", /* CNS 11643-1992 pl.2 172 */ "\033$)H" },
+ { "CNS11643.1992-3:GL", /* CNS 11643-1992 pl.3 183 */ "\033$(I" },
+ { "CNS11643.1992-3:GR", /* CNS 11643-1992 pl.3 183 */ "\033$)I" },
+ { "CNS11643.1992-4:GL", /* CNS 11643-1992 pl.4 184 */ "\033$(J" },
+ { "CNS11643.1992-4:GR", /* CNS 11643-1992 pl.4 184 */ "\033$)J" },
+ { "CNS11643.1992-5:GL", /* CNS 11643-1992 pl.5 185 */ "\033$(K" },
+ { "CNS11643.1992-5:GR", /* CNS 11643-1992 pl.5 185 */ "\033$)K" },
+ { "CNS11643.1992-6:GL", /* CNS 11643-1992 pl.6 186 */ "\033$(L" },
+ { "CNS11643.1992-6:GR", /* CNS 11643-1992 pl.6 186 */ "\033$)L" },
+ { "CNS11643.1992-7:GL", /* CNS 11643-1992 pl.7 187 */ "\033$(M" },
+ { "CNS11643.1992-7:GR", /* CNS 11643-1992 pl.7 187 */ "\033$)M" },
+
+ /* Registered encodings with a varying number of bytes per character */
+ { "ISO10646-1", /* UTF-8 196 */ "\033%G" },
+
+ /* Encodings without ISO-IR assigned escape sequence must be
+ defined in XLC_LOCALE files, using "\033%/1" or "\033%/2". */
+
+ /* Backward compatibility with XFree86 3.x */
+#if 1
+ { "ISO8859-14:GR", "\033%/1" },
+ { "ISO8859-15:GR", "\033%/1" },
+#endif
+ /* For use by utf8 -> ctext */
+ { "BIG5-0:GLGR", "\033%/2"},
+ /* used by Emacs, but not backed by ISO-IR */
+ { "BIG5-E0:GL", "\033$(0" },
+ { "BIG5-E0:GR", "\033$)0" },
+ { "BIG5-E1:GL", "\033$(1" },
+ { "BIG5-E1:GR", "\033$)1" },
+
+};
+
+/* We represent UTF-8 as an XlcGLGR charset, not in extended segments. */
+#define UTF8_IN_EXTSEQ 0
+
+/* ======================= Parsing ESC Sequences ======================= */
+
+#define XctC0 0x0000
+#define XctHT 0x0009
+#define XctNL 0x000a
+#define XctESC 0x001b
+#define XctGL 0x0020
+#define XctC1 0x0080
+#define XctCSI 0x009b
+#define XctGR 0x00a0
+#define XctSTX 0x0002
+
+#define XctCntrlFunc 0x0023
+#define XctMB 0x0024
+#define XctOtherCoding 0x0025
+#define XctGL94 0x0028
+#define XctGR94 0x0029
+#define XctGR96 0x002d
+#define XctNonStandard 0x002f
+#define XctIgnoreExt 0x0030
+#define XctNotIgnoreExt 0x0031
+#define XctLeftToRight 0x0031
+#define XctRightToLeft 0x0032
+#define XctDirection 0x005d
+#define XctDirectionEnd 0x005d
+
+#define XctGL94MB 0x2428
+#define XctGR94MB 0x2429
+#define XctExtSeg 0x252f
+#define XctReturn 0x2540
+
+/*
+ * Parses the header of a Compound Text segment, i.e. the charset designator.
+ * The string starts at *text and has *length bytes.
+ * Return value is one of:
+ * 0 (no valid charset designator),
+ * XctGL94, XctGR94, XctGR96, XctGL94MB, XctGR94MB,
+ * XctLeftToRight, XctRightToLeft, XctDirectionEnd,
+ * XctExtSeg, XctOtherCoding, XctReturn, XctIgnoreExt, XctNotIgnoreExt.
+ * If the return value is not 0, *text is incremented and *length decremented,
+ * to point past the charset designator. If the return value is one of
+ * XctGL94, XctGR94, XctGR96, XctGL94MB, XctGR94MB,
+ * XctExtSeg, XctOtherCoding, XctIgnoreExt, XctNotIgnoreExt,
+ * *final_byte is set to the "final byte" of the charset designator.
+ */
+static unsigned int
+_XlcParseCT(
+ const char **text,
+ int *length,
+ unsigned char *final_byte)
+{
+ unsigned int ret = 0;
+ unsigned char ch;
+ const unsigned char *str = (const unsigned char *) *text;
+
+ *final_byte = 0;
+
+ if (*length < 1)
+ return 0;
+ switch (ch = *str++) {
+ case XctESC:
+ if (*length < 2)
+ return 0;
+ switch (ch = *str++) {
+ case XctOtherCoding: /* % */
+ if (*length < 3)
+ return 0;
+ ch = *str++;
+ if (ch == XctNonStandard) { /* / */
+ if (*length < 4)
+ return 0;
+ ret = XctExtSeg;
+ ch = *str++;
+ } else if (ch == '@') {
+ ret = XctReturn;
+ } else {
+ ret = XctOtherCoding;
+ }
+ *final_byte = ch;
+ break;
+
+ case XctCntrlFunc: /* # */
+ if (*length < 4)
+ return 0;
+ *final_byte = *str++;
+ switch (*str++) {
+ case XctIgnoreExt: /* 0 */
+ ret = XctIgnoreExt;
+ break;
+ case XctNotIgnoreExt: /* 1 */
+ ret = XctNotIgnoreExt;
+ break;
+ default:
+ ret = 0;
+ break;
+ }
+ break;
+
+ case XctMB: /* $ */
+ if (*length < 4)
+ return 0;
+ ch = *str++;
+ switch (ch) {
+ case XctGL94: /* ( */
+ ret = XctGL94MB;
+ break;
+ case XctGR94: /* ) */
+ ret = XctGR94MB;
+ break;
+ default:
+ ret = 0;
+ break;
+ }
+ *final_byte = *str++;
+ break;
+
+ case XctGL94: /* ( */
+ if (*length < 3)
+ return 0;
+ ret = XctGL94;
+ *final_byte = *str++;
+ break;
+ case XctGR94: /* ) */
+ if (*length < 3)
+ return 0;
+ ret = XctGR94;
+ *final_byte = *str++;
+ break;
+ case XctGR96: /* - */
+ if (*length < 3)
+ return 0;
+ ret = XctGR96;
+ *final_byte = *str++;
+ break;
+ }
+ break;
+ case XctCSI:
+ /* direction */
+ if (*length < 2)
+ return 0;
+ switch (*str++) {
+ case XctLeftToRight:
+ if (*length < 3)
+ return 0;
+ if (*str++ == XctDirection)
+ ret = XctLeftToRight;
+ break;
+ case XctRightToLeft:
+ if (*length < 3)
+ return 0;
+ if (*str++ == XctDirection)
+ ret = XctRightToLeft;
+ break;
+ case XctDirectionEnd:
+ ret = XctDirectionEnd;
+ break;
+ }
+ break;
+ }
+
+ if (ret) {
+ *length -= (const char *) str - *text;
+ *text = (const char *) str;
+ }
+ return ret;
+}
+
+/*
+ * Fills into a freshly created XlcCharSet the fields that can be inferred
+ * from the ESC sequence. These are side, char_size, set_size.
+ * Returns True if the charset can be used with Compound Text.
+ *
+ * Used by _XlcCreateDefaultCharSet.
+ */
+Bool
+_XlcParseCharSet(
+ XlcCharSet charset)
+{
+ unsigned int type;
+ unsigned char final_byte;
+ const char *ptr = charset->ct_sequence;
+ int length;
+ int char_size;
+
+ if (*ptr == '\0')
+ return False;
+
+ length = strlen(ptr);
+
+ type = _XlcParseCT(&ptr, &length, &final_byte);
+
+ /* Check for validity and determine char_size.
+ char_size = 0 means varying number of bytes per character. */
+ switch (type) {
+ case XctGL94:
+ case XctGR94:
+ case XctGR96:
+ char_size = 1;
+ break;
+ case XctGL94MB:
+ case XctGR94MB:
+ char_size = (final_byte < 0x60 ? 2 : final_byte < 0x70 ? 3 : 4);
+ break;
+ case XctExtSeg:
+ char_size = final_byte - '0';
+ if (!(char_size >= 0 && char_size <= 4))
+ return False;
+ break;
+ case XctOtherCoding:
+ char_size = 0;
+ break;
+ default:
+ return False;
+ }
+
+ charset->char_size = char_size;
+
+ /* Fill in other values. */
+ switch (type) {
+ case XctGL94:
+ case XctGL94MB:
+ charset->side = XlcGL;
+ charset->set_size = 94;
+ break;
+ case XctGR94:
+ case XctGR94MB:
+ charset->side = XlcGR;
+ charset->set_size = 94;
+ break;
+ case XctGR96:
+ charset->side = XlcGR;
+ charset->set_size = 96;
+ break;
+ case XctExtSeg:
+ case XctOtherCoding:
+ charset->side = XlcGLGR;
+ charset->set_size = 0;
+ break;
+ }
+ return True;
+}
+
+
+/* =============== Management of the List of Character Sets =============== */
+
+/*
+ * Representation of a character set that can be used for Compound Text,
+ * at run time.
+ * Note: This information is not contained in the XlcCharSet, because
+ * multiple ESC sequences may be used for the same XlcCharSet.
+ */
+typedef struct _CTInfoRec {
+ XlcCharSet charset;
+ const char *ct_sequence; /* Compound Text ESC sequence */
+ unsigned int type;
+ unsigned char final_byte;
+ /* If type == XctExtSeg: */
+ const char *ext_segment; /* extended segment name, then '\002' */
+ int ext_segment_len; /* length of above, including final '\002' */
+
+ struct _CTInfoRec *next;
+} CTInfoRec, *CTInfo;
+
+/*
+ * List of character sets that can be used for Compound Text,
+ * Includes all that are listed in default_ct_data, but more can be added
+ * at runtime through _XlcAddCT.
+ */
+static CTInfo ct_list = NULL;
+static CTInfo ct_list_end = NULL;
+
+/*
+ * Returns a Compound Text info record for an ESC sequence.
+ * The first part of the ESC sequence has already been parsed into 'type'
+ * and 'final_byte'. The remainder starts at 'text', at least 'text_len'
+ * bytes (only used if type == XctExtSeg).
+ */
+static CTInfo
+_XlcGetCTInfo(
+ unsigned int type,
+ unsigned char final_byte,
+ const char *text,
+ int text_len)
+{
+ CTInfo ct_info;
+
+ for (ct_info = ct_list; ct_info; ct_info = ct_info->next)
+ if (ct_info->type == type
+ && ct_info->final_byte == final_byte
+ && (type != XctExtSeg
+ || (text_len >= ct_info->ext_segment_len
+ && memcmp(text, ct_info->ext_segment,
+ ct_info->ext_segment_len) == 0)))
+ return ct_info;
+
+ return (CTInfo) NULL;
+}
+
+/* Returns the Compound Text info for a given XlcCharSet.
+ Returns NULL if none is found. */
+static CTInfo
+_XlcGetCTInfoFromCharSet(
+ XlcCharSet charset)
+{
+ CTInfo ct_info;
+
+ for (ct_info = ct_list; ct_info; ct_info = ct_info->next)
+ if (ct_info->charset == charset)
+ return ct_info;
+
+ return (CTInfo) NULL;
+}
+
+/* Creates a new XlcCharSet, given its name (including side suffix) and
+ Compound Text ESC sequence (normally at most 4 bytes), and makes it
+ eligible for Compound Text processing. */
+XlcCharSet
+_XlcAddCT(
+ const char *name,
+ const char *ct_sequence)
+{
+ CTInfo ct_info, existing_info;
+ XlcCharSet charset;
+ const char *ct_ptr;
+ int length;
+ unsigned int type;
+ unsigned char final_byte;
+
+ charset = _XlcGetCharSet(name);
+ if (charset != NULL) {
+ /* Even if the charset already exists, it is OK to register a second
+ Compound Text sequence for it. */
+ } else {
+ /* Attempt to create the charset. */
+ charset = _XlcCreateDefaultCharSet(name, ct_sequence);
+ if (charset == NULL)
+ return (XlcCharSet) NULL;
+ _XlcAddCharSet(charset);
+ }
+
+ /* Allocate a CTinfo record. */
+ length = strlen(ct_sequence);
+ ct_info = (CTInfo) Xmalloc(sizeof(CTInfoRec) + length+1);
+ if (ct_info == NULL)
+ return charset;
+
+ ct_info->charset = charset;
+ ct_info->ct_sequence = strcpy((char *) (ct_info + 1), ct_sequence);
+
+ /* Parse the Compound Text sequence. */
+ ct_ptr = ct_sequence;
+ type = _XlcParseCT(&ct_ptr, &length, &final_byte);
+
+ ct_info->type = type;
+ ct_info->final_byte = final_byte;
+
+ switch (type) {
+ case XctGL94:
+ case XctGR94:
+ case XctGR96:
+ case XctGL94MB:
+ case XctGR94MB:
+ case XctOtherCoding:
+ ct_info->ext_segment = NULL;
+ ct_info->ext_segment_len = 0;
+ break;
+ case XctExtSeg: {
+ /* By convention, the extended segment name is the encoding_name
+ in lowercase. */
+ const char *q = charset->encoding_name;
+ int n = strlen(q);
+ char *p;
+
+ /* Ensure ct_info->ext_segment_len <= 0x3fff - 6. */
+ if (n > 0x3fff - 6 - 1) {
+ Xfree(ct_info);
+ return charset;
+ }
+ p = (char *) Xmalloc(n+1);
+ if (p == NULL) {
+ Xfree(ct_info);
+ return charset;
+ }
+ ct_info->ext_segment = p;
+ ct_info->ext_segment_len = n+1;
+ for ( ; n > 0; p++, q++, n--)
+ *p = (*q >= 'A' && *q <= 'Z' ? *q - 'A' + 'a' : *q);
+ *p = XctSTX;
+ break;
+ }
+ default:
+ Xfree(ct_info);
+ return (XlcCharSet) NULL;
+ }
+
+ /* Insert it into the list, if not already present. */
+ existing_info =
+ _XlcGetCTInfo(type, ct_info->final_byte,
+ ct_info->ext_segment, ct_info->ext_segment_len);
+ if (existing_info == NULL) {
+ /* Insert it at the end. If there are duplicates CTinfo entries
+ for the same XlcCharSet, we want the first (standard) one to
+ override the second (user defined) one. */
+ ct_info->next = NULL;
+ if (ct_list_end)
+ ct_list_end->next = ct_info;
+ else
+ ct_list = ct_info;
+ ct_list_end = ct_info;
+ } else {
+ if (existing_info->charset != charset
+ /* We have a conflict, with one exception: JISX0208.1983-0 and
+ JISX0208.1990-0 are the same for all practical purposes. */
+ && !(strncmp(existing_info->charset->name, "JISX0208", 8) == 0
+ && strncmp(charset->name, "JISX0208", 8) == 0)) {
+ fprintf(stderr,
+ "Xlib: charsets %s and %s have the same CT sequence\n",
+ charset->name, existing_info->charset->name);
+ if (strcmp(charset->ct_sequence, ct_sequence) == 0)
+ charset->ct_sequence = "";
+ }
+ Xfree(ct_info);
+ }
+
+ return charset;
+}
+
+
+/* ========== Converters String <--> CharSet <--> Compound Text ========== */
+
+/*
+ * Structure representing the parse state of a Compound Text string.
+ */
+typedef struct _StateRec {
+ XlcCharSet charset; /* The charset of the current segment */
+ XlcCharSet GL_charset; /* The charset responsible for 0x00..0x7F */
+ XlcCharSet GR_charset; /* The charset responsible for 0x80..0xFF */
+ XlcCharSet Other_charset; /* != NULL if currently in an other segment */
+ int ext_seg_left; /* > 0 if currently in an extended segment */
+} StateRec, *State;
+
+
+/* Subroutine for parsing an ESC sequence. */
+
+typedef enum {
+ resOK, /* Charset saved in 'state', sequence skipped */
+ resNotInList, /* Charset not found, sequence skipped */
+ resNotCTSeq /* EscSeq not recognized, pointers not changed */
+} CheckResult;
+
+static CheckResult
+_XlcCheckCTSequence(
+ State state,
+ const char **ctext,
+ int *ctext_len)
+{
+ XlcCharSet charset;
+ CTInfo ct_info;
+ const char *tmp_ctext = *ctext;
+ int tmp_ctext_len = *ctext_len;
+ unsigned int type;
+ unsigned char final_byte;
+ int ext_seg_left = 0;
+
+ /* Check for validity. */
+ type = _XlcParseCT(&tmp_ctext, &tmp_ctext_len, &final_byte);
+
+ switch (type) {
+ case XctGL94:
+ case XctGR94:
+ case XctGR96:
+ case XctGL94MB:
+ case XctGR94MB:
+ case XctOtherCoding:
+ *ctext = tmp_ctext;
+ *ctext_len = tmp_ctext_len;
+ break;
+ case XctReturn:
+ *ctext = tmp_ctext;
+ *ctext_len = tmp_ctext_len;
+ state->Other_charset = NULL;
+ return resOK;
+ case XctExtSeg:
+ if (tmp_ctext_len > 2
+ && (tmp_ctext[0] & 0x80) && (tmp_ctext[0] & 0x80)) {
+ unsigned int msb = tmp_ctext[0] & 0x7f;
+ unsigned int lsb = tmp_ctext[1] & 0x7f;
+ ext_seg_left = (msb << 7) + lsb;
+ if (ext_seg_left <= tmp_ctext_len - 2) {
+ *ctext = tmp_ctext + 2;
+ *ctext_len = tmp_ctext_len - 2;
+ break;
+ }
+ }
+ return resNotCTSeq;
+ default:
+ return resNotCTSeq;
+ }
+
+ ct_info = _XlcGetCTInfo(type, final_byte, *ctext, ext_seg_left);
+
+ if (ct_info) {
+ charset = ct_info->charset;
+ state->ext_seg_left = ext_seg_left;
+ if (type == XctExtSeg) {
+ state->charset = charset;
+ /* Skip past the extended segment name and the separator. */
+ *ctext += ct_info->ext_segment_len;
+ *ctext_len -= ct_info->ext_segment_len;
+ state->ext_seg_left -= ct_info->ext_segment_len;
+ } else if (type == XctOtherCoding) {
+ state->Other_charset = charset;
+ } else {
+ if (charset->side == XlcGL) {
+ state->GL_charset = charset;
+ } else if (charset->side == XlcGR) {
+ state->GR_charset = charset;
+ } else {
+ state->GL_charset = charset;
+ state->GR_charset = charset;
+ }
+ }
+ return resOK;
+ } else {
+ state->ext_seg_left = 0;
+ if (type == XctExtSeg) {
+ /* Skip the entire extended segment. */
+ *ctext += ext_seg_left;
+ *ctext_len -= ext_seg_left;
+ }
+ return resNotInList;
+ }
+}
+
+static void
+init_state(
+ XlcConv conv)
+{
+ State state = (State) conv->state;
+ static XlcCharSet default_GL_charset = NULL;
+ static XlcCharSet default_GR_charset = NULL;
+
+ if (default_GL_charset == NULL) {
+ default_GL_charset = _XlcGetCharSet("ISO8859-1:GL");
+ default_GR_charset = _XlcGetCharSet("ISO8859-1:GR");
+ }
+
+ /* The initial state is ISO-8859-1 on both sides. */
+ state->GL_charset = state->charset = default_GL_charset;
+ state->GR_charset = default_GR_charset;
+
+ state->Other_charset = NULL;
+
+ state->ext_seg_left = 0;
+}
+
+/* from XlcNCompoundText to XlcNCharSet */
+
+static int
+cttocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XlcCharSet charset = NULL;
+ const char *ctptr;
+ char *bufptr;
+ int ctext_len, buf_len;
+ int unconv_num = 0;
+
+ ctptr = (const char *) *from;
+ bufptr = (char *) *to;
+ ctext_len = *from_left;
+ buf_len = *to_left;
+
+ while (ctext_len > 0 && buf_len > 0) {
+ if (state->ext_seg_left == 0) {
+ /* Not in the middle of an extended segment; look at next byte. */
+ unsigned char ch = *ctptr;
+ XlcCharSet ch_charset;
+
+ if (ch == XctESC) {
+ CheckResult ret =
+ _XlcCheckCTSequence(state, &ctptr, &ctext_len);
+ if (ret == resOK)
+ /* state has been modified. */
+ continue;
+ if (ret == resNotInList) {
+ /* XXX Just continue with previous charset. */
+ unconv_num++;
+ continue;
+ }
+ } else if (ch == XctCSI) {
+ /* XXX Simply ignore the XctLeftToRight, XctRightToLeft,
+ XctDirectionEnd sequences for the moment. */
+ unsigned char dummy;
+ if (_XlcParseCT(&ctptr, &ctext_len, &dummy)) {
+ unconv_num++;
+ continue;
+ }
+ }
+
+ /* Find the charset which is responsible for this byte. */
+ ch_charset = (state->Other_charset != NULL ? state->Other_charset :
+ (ch & 0x80 ? state->GR_charset : state->GL_charset));
+
+ /* Set the charset of this run, or continue the current run,
+ or stop the current run. */
+ if (charset) {
+ if (charset != ch_charset)
+ break;
+ } else {
+ state->charset = charset = ch_charset;
+ }
+
+ /* We don't want to split a character into multiple pieces. */
+ if (buf_len < 6) {
+ if (charset->char_size > 0) {
+ if (buf_len < charset->char_size)
+ break;
+ } else {
+ /* char_size == 0 is tricky. The code here is good only
+ for valid UTF-8 input. */
+ if (charset->ct_sequence[0] == XctESC
+ && charset->ct_sequence[1] == XctOtherCoding
+ && charset->ct_sequence[2] == 'G') {
+ int char_size = (ch < 0xc0 ? 1 :
+ ch < 0xe0 ? 2 :
+ ch < 0xf0 ? 3 :
+ ch < 0xf8 ? 4 :
+ ch < 0xfc ? 5 :
+ 6);
+ if (buf_len < char_size)
+ break;
+ }
+ }
+ }
+
+ *bufptr++ = *ctptr++;
+ ctext_len--;
+ buf_len--;
+ } else {
+ /* Copy as much as possible from the current extended segment
+ to the buffer. */
+ int char_size;
+
+ /* Set the charset of this run, or continue the current run,
+ or stop the current run. */
+ if (charset) {
+ if (charset != state->charset)
+ break;
+ } else {
+ charset = state->charset;
+ }
+
+ char_size = charset->char_size;
+
+ if (state->ext_seg_left <= buf_len || char_size > 0) {
+ int n = (state->ext_seg_left <= buf_len
+ ? state->ext_seg_left
+ : (buf_len / char_size) * char_size);
+ memcpy(bufptr, ctptr, n);
+ ctptr += n; ctext_len -= n;
+ bufptr += n; buf_len -= n;
+ state->ext_seg_left -= n;
+ } else {
+#if UTF8_IN_EXTSEQ
+ /* char_size == 0 is tricky. The code here is good only
+ for valid UTF-8 input. */
+ if (strcmp(charset->name, "ISO10646-1") == 0) {
+ unsigned char ch = *ctptr;
+ int char_size = (ch < 0xc0 ? 1 :
+ ch < 0xe0 ? 2 :
+ ch < 0xf0 ? 3 :
+ ch < 0xf8 ? 4 :
+ ch < 0xfc ? 5 :
+ 6);
+ int i;
+ if (buf_len < char_size)
+ break;
+ /* A small loop is faster than calling memcpy. */
+ for (i = char_size; i > 0; i--)
+ *bufptr++ = *ctptr++;
+ ctext_len -= char_size;
+ buf_len -= char_size;
+ state->ext_seg_left -= char_size;
+ } else
+#endif
+ {
+ /* Here ctext_len >= state->ext_seg_left > buf_len.
+ We may be splitting a character into multiple pieces.
+ Oh well. */
+ int n = buf_len;
+ memcpy(bufptr, ctptr, n);
+ ctptr += n; ctext_len -= n;
+ bufptr += n; buf_len -= n;
+ state->ext_seg_left -= n;
+ }
+ }
+ }
+ }
+
+ /* 'charset' is the charset for the current run. In some cases,
+ 'state->charset' contains the charset for the next run. Therefore,
+ return 'charset'.
+ 'charset' may still be NULL only if no output was produced. */
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ *from_left -= ctptr - *((const char **) from);
+ *from = (XPointer) ctptr;
+
+ *to_left -= bufptr - *((char **) to);
+ *to = (XPointer) bufptr;
+
+ return unconv_num;
+}
+
+/* from XlcNCharSet to XlcNCompoundText */
+
+static int
+cstoct(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XlcSide side;
+ unsigned char min_ch = 0, max_ch = 0;
+ int length, unconv_num;
+ CTInfo ct_info;
+ XlcCharSet charset;
+ const char *csptr;
+ char *ctptr;
+ int csstr_len, ct_len;
+ char *ext_segment_start;
+ int char_size;
+
+ /* One argument is required, of type XlcCharSet. */
+ if (num_args < 1)
+ return -1;
+
+ csptr = *((const char **) from);
+ ctptr = *((char **) to);
+ csstr_len = *from_left;
+ ct_len = *to_left;
+
+ charset = (XlcCharSet) args[0];
+
+ ct_info = _XlcGetCTInfoFromCharSet(charset);
+ if (ct_info == NULL)
+ return -1;
+
+ side = charset->side;
+ length = strlen(ct_info->ct_sequence);
+
+ ext_segment_start = NULL;
+
+ if (ct_info->type == XctOtherCoding) {
+ /* Output the Escape sequence for switching to the charset, and
+ reserve room now for the XctReturn sequence at the end. */
+ if (ct_len < length + 3)
+ return -1;
+
+ memcpy(ctptr, ct_info->ct_sequence, length);
+ ctptr += length;
+ ct_len -= length + 3;
+ } else
+ /* Test whether the charset is already active. */
+ if (((side == XlcGR || side == XlcGLGR)
+ && charset != state->GR_charset)
+ || ((side == XlcGL || side == XlcGLGR)
+ && charset != state->GL_charset)) {
+
+ /* Output the Escape sequence for switching to the charset. */
+ if (ct_info->type == XctExtSeg) {
+ if (ct_len < length + 2 + ct_info->ext_segment_len)
+ return -1;
+
+ memcpy(ctptr, ct_info->ct_sequence, length);
+ ctptr += length;
+ ct_len -= length;
+
+ ctptr += 2;
+ ct_len -= 2;
+ ext_segment_start = ctptr;
+
+ /* The size of an extended segment must fit in 14 bits. */
+ if (ct_len > 0x3fff)
+ ct_len = 0x3fff;
+
+ memcpy(ctptr, ct_info->ext_segment, ct_info->ext_segment_len);
+ ctptr += ct_info->ext_segment_len;
+ ct_len -= ct_info->ext_segment_len;
+ } else {
+ if (ct_len < length)
+ return -1;
+
+ memcpy(ctptr, ct_info->ct_sequence, length);
+ ctptr += length;
+ ct_len -= length;
+ }
+ }
+
+ /* If the charset has side GL or GR, prepare remapping the characters
+ to the correct side. */
+ if (charset->set_size) {
+ min_ch = 0x20;
+ max_ch = 0x7f;
+ if (charset->set_size == 94) {
+ max_ch--;
+ if (charset->char_size > 1 || side == XlcGR)
+ min_ch++;
+ }
+ }
+
+ /* Actually copy the contents. */
+ unconv_num = 0;
+ char_size = charset->char_size;
+ if (char_size == 1) {
+ while (csstr_len > 0 && ct_len > 0) {
+ if (charset->set_size) {
+ /* The CompoundText specification says that the only
+ control characters allowed are 0x09, 0x0a, 0x1b, 0x9b.
+ Therefore here we eliminate other control characters. */
+ unsigned char ch = *((unsigned char *) csptr) & 0x7f;
+ if (!((ch >= min_ch && ch <= max_ch)
+ || (side == XlcGL
+ && (ch == 0x00 || ch == 0x09 || ch == 0x0a))
+ || ((side == XlcGL || side == XlcGR)
+ && (ch == 0x1b)))) {
+ csptr++;
+ csstr_len--;
+ unconv_num++;
+ continue;
+ }
+ }
+
+ if (side == XlcGL)
+ *ctptr++ = *csptr++ & 0x7f;
+ else if (side == XlcGR)
+ *ctptr++ = *csptr++ | 0x80;
+ else
+ *ctptr++ = *csptr++;
+ csstr_len--;
+ ct_len--;
+ }
+ } else if (char_size > 1) {
+ while (csstr_len >= char_size && ct_len >= char_size) {
+ if (side == XlcGL) {
+ int i;
+ for (i = char_size; i > 0; i--)
+ *ctptr++ = *csptr++ & 0x7f;
+ } else if (side == XlcGR) {
+ int i;
+ for (i = char_size; i > 0; i--)
+ *ctptr++ = *csptr++ | 0x80;
+ } else {
+ int i;
+ for (i = char_size; i > 0; i--)
+ *ctptr++ = *csptr++;
+ }
+ csstr_len -= char_size;
+ ct_len -= char_size;
+ }
+ } else {
+ /* char_size = 0. The code here is good only for valid UTF-8 input. */
+ if ((charset->ct_sequence[0] == XctESC
+ && charset->ct_sequence[1] == XctOtherCoding
+ && charset->ct_sequence[2] == 'G')
+#if UTF8_IN_EXTSEQ
+ || strcmp(charset->name, "ISO10646-1") == 0
+#endif
+ ) {
+ while (csstr_len > 0 && ct_len > 0) {
+ unsigned char ch = * (unsigned char *) csptr;
+ int char_size = (ch < 0xc0 ? 1 :
+ ch < 0xe0 ? 2 :
+ ch < 0xf0 ? 3 :
+ ch < 0xf8 ? 4 :
+ ch < 0xfc ? 5 :
+ 6);
+ int i;
+ if (!(csstr_len >= char_size && ct_len >= char_size))
+ break;
+ for (i = char_size; i > 0; i--)
+ *ctptr++ = *csptr++;
+ csstr_len -= char_size;
+ ct_len -= char_size;
+ }
+ } else {
+ while (csstr_len > 0 && ct_len > 0) {
+ *ctptr++ = *csptr++;
+ csstr_len--;
+ ct_len--;
+ }
+ }
+ }
+
+ if (ct_info->type == XctOtherCoding) {
+ /* Terminate with an XctReturn sequence. */
+ ctptr[0] = XctESC;
+ ctptr[1] = XctOtherCoding;
+ ctptr[2] = '@';
+ ctptr += 3;
+ } else if (ext_segment_start != NULL) {
+ /* Backpatch the extended segment's length. */
+ int ext_segment_length = ctptr - ext_segment_start;
+ *(ext_segment_start - 2) = (ext_segment_length >> 7) | 0x80;
+ *(ext_segment_start - 1) = (ext_segment_length & 0x7f) | 0x80;
+ } else {
+ if (side == XlcGR || side == XlcGLGR)
+ state->GR_charset = charset;
+ if (side == XlcGL || side == XlcGLGR)
+ state->GL_charset = charset;
+ }
+
+ *from_left -= csptr - *((const char **) from);
+ *from = (XPointer) csptr;
+
+ *to_left -= ctptr - *((char **) to);
+ *to = (XPointer) ctptr;
+
+ return 0;
+}
+
+/* from XlcNString to XlcNCharSet */
+
+static int
+strtocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ const char *src;
+ char *dst;
+ unsigned char side;
+ int length;
+
+ src = (const char *) *from;
+ dst = (char *) *to;
+
+ length = min(*from_left, *to_left);
+ side = *((unsigned char *) src) & 0x80;
+
+ while (side == (*((unsigned char *) src) & 0x80) && length-- > 0)
+ *dst++ = *src++;
+
+ *from_left -= src - (const char *) *from;
+ *from = (XPointer) src;
+ *to_left -= dst - (char *) *to;
+ *to = (XPointer) dst;
+
+ if (num_args > 0)
+ *((XlcCharSet *)args[0]) = (side ? state->GR_charset : state->GL_charset);
+
+ return 0;
+}
+
+/* from XlcNCharSet to XlcNString */
+
+static int
+cstostr(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ const char *csptr;
+ char *string_ptr;
+ int csstr_len, str_len;
+ unsigned char ch;
+ int unconv_num = 0;
+
+ /* This converter can only convert from ISO8859-1:GL and ISO8859-1:GR. */
+ if (num_args < 1
+ || !((XlcCharSet) args[0] == state->GL_charset
+ || (XlcCharSet) args[0] == state->GR_charset))
+ return -1;
+
+ csptr = *((const char **) from);
+ string_ptr = *((char **) to);
+ csstr_len = *from_left;
+ str_len = *to_left;
+
+ while (csstr_len > 0 && str_len > 0) {
+ ch = *((unsigned char *) csptr++);
+ csstr_len--;
+ /* Citing ICCCM: "STRING as a type specifies the ISO Latin-1 character
+ set plus the control characters TAB and NEWLINE." */
+ if ((ch < 0x20 && ch != 0x00 && ch != 0x09 && ch != 0x0a)
+ || (ch >= 0x7f && ch < 0xa0)) {
+ unconv_num++;
+ continue;
+ }
+ *((unsigned char *) string_ptr++) = ch;
+ str_len--;
+ }
+
+ *from_left -= csptr - *((const char **) from);
+ *from = (XPointer) csptr;
+
+ *to_left -= string_ptr - *((char **) to);
+ *to = (XPointer) string_ptr;
+
+ return unconv_num;
+}
+
+
+static XlcConv
+create_conv(
+ XlcConvMethods methods)
+{
+ XlcConv conv;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec) + sizeof(StateRec));
+ if (conv == NULL)
+ return (XlcConv) NULL;
+
+ conv->state = (XPointer) &conv[1];
+
+ conv->methods = methods;
+
+ init_state(conv);
+
+ return conv;
+}
+
+static void
+close_converter(
+ XlcConv conv)
+{
+ /* conv->state is allocated together with conv, free both at once. */
+ Xfree((char *) conv);
+}
+
+
+static XlcConvMethodsRec cttocs_methods = {
+ close_converter,
+ cttocs,
+ init_state
+};
+
+static XlcConv
+open_cttocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(&cttocs_methods);
+}
+
+
+static XlcConvMethodsRec cstoct_methods = {
+ close_converter,
+ cstoct,
+ init_state
+};
+
+static XlcConv
+open_cstoct(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(&cstoct_methods);
+}
+
+
+static XlcConvMethodsRec strtocs_methods = {
+ close_converter,
+ strtocs,
+ init_state
+};
+
+static XlcConv
+open_strtocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(&strtocs_methods);
+}
+
+
+static XlcConvMethodsRec cstostr_methods = {
+ close_converter,
+ cstostr,
+ init_state
+};
+
+static XlcConv
+open_cstostr(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(&cstostr_methods);
+}
+
+
+/* =========================== Initialization =========================== */
+
+Bool
+_XlcInitCTInfo()
+{
+ if (ct_list == NULL) {
+ CTData ct_data;
+ int num;
+ XlcCharSet charset;
+
+ /* Initialize ct_list. */
+
+ num = sizeof(default_ct_data) / sizeof(CTDataRec);
+ for (ct_data = default_ct_data; num > 0; ct_data++, num--) {
+ charset = _XlcAddCT(ct_data->name, ct_data->ct_sequence);
+ if (charset == NULL)
+ continue;
+ if (strncmp(charset->ct_sequence, "\x1b\x25\x2f", 3) != 0)
+ charset->source = CSsrcStd;
+ else
+ charset->source = CSsrcXLC;
+ }
+
+ /* Register CompoundText and CharSet converters. */
+
+ _XlcSetConverter((XLCd) NULL, XlcNCompoundText,
+ (XLCd) NULL, XlcNCharSet,
+ open_cttocs);
+ _XlcSetConverter((XLCd) NULL, XlcNString,
+ (XLCd) NULL, XlcNCharSet,
+ open_strtocs);
+
+ _XlcSetConverter((XLCd) NULL, XlcNCharSet,
+ (XLCd) NULL, XlcNCompoundText,
+ open_cstoct);
+ _XlcSetConverter((XLCd) NULL, XlcNCharSet,
+ (XLCd) NULL, XlcNString,
+ open_cstostr);
+ }
+
+ return True;
+}
diff --git a/nx-X11/lib/X11/lcCharSet.c b/nx-X11/lib/X11/lcCharSet.c
new file mode 100644
index 000000000..006a0be23
--- /dev/null
+++ b/nx-X11/lib/X11/lcCharSet.c
@@ -0,0 +1,228 @@
+/* $Xorg: lcCharSet.c,v 1.3 2000/08/17 19:45:16 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/lcCharSet.c,v 3.8 2001/01/17 19:41:53 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "XlcPublic.h"
+#include "XlcPubI.h"
+
+/* The list of all known XlcCharSets. They are identified by their name. */
+
+typedef struct _XlcCharSetListRec {
+ XlcCharSet charset;
+ struct _XlcCharSetListRec *next;
+} XlcCharSetListRec, *XlcCharSetList;
+
+static XlcCharSetList charset_list = NULL;
+
+/* Returns the charset with the given name (including side suffix).
+ Returns NULL if not found. */
+XlcCharSet
+_XlcGetCharSet(
+ const char *name)
+{
+ XlcCharSetList list;
+ XrmQuark xrm_name;
+
+ xrm_name = XrmStringToQuark(name);
+
+ for (list = charset_list; list; list = list->next) {
+ if (xrm_name == list->charset->xrm_name)
+ return (XlcCharSet) list->charset;
+ }
+
+ return (XlcCharSet) NULL;
+}
+
+/* Returns the charset with the given encoding (no side suffix) and
+ responsible for at least the given side (XlcGL or XlcGR).
+ Returns NULL if not found. */
+XlcCharSet
+_XlcGetCharSetWithSide(
+ const char *encoding_name,
+ XlcSide side)
+{
+ XlcCharSetList list;
+ XrmQuark xrm_encoding_name;
+
+ xrm_encoding_name = XrmStringToQuark(encoding_name);
+
+ for (list = charset_list; list; list = list->next) {
+ if (list->charset->xrm_encoding_name == xrm_encoding_name
+ && (list->charset->side == XlcGLGR || list->charset->side == side))
+ return (XlcCharSet) list->charset;
+ }
+
+ return (XlcCharSet) NULL;
+}
+
+/* Registers an XlcCharSet in the list of character sets.
+ Returns True if successful. */
+Bool
+_XlcAddCharSet(
+ XlcCharSet charset)
+{
+ XlcCharSetList list;
+
+ if (_XlcGetCharSet(charset->name))
+ return False;
+
+ list = (XlcCharSetList) Xmalloc(sizeof(XlcCharSetListRec));
+ if (list == NULL)
+ return False;
+
+ list->charset = charset;
+ list->next = charset_list;
+ charset_list = list;
+
+ return True;
+}
+
+/* List of resources for XlcCharSet. */
+static XlcResource resources[] = {
+ { XlcNName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XlcCharSetRec, name), XlcGetMask },
+ { XlcNEncodingName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XlcCharSetRec, encoding_name), XlcGetMask },
+ { XlcNSide, NULLQUARK, sizeof(XlcSide),
+ XOffsetOf(XlcCharSetRec, side), XlcGetMask },
+ { XlcNCharSize, NULLQUARK, sizeof(int),
+ XOffsetOf(XlcCharSetRec, char_size), XlcGetMask },
+ { XlcNSetSize, NULLQUARK, sizeof(int),
+ XOffsetOf(XlcCharSetRec, set_size), XlcGetMask },
+ { XlcNControlSequence, NULLQUARK, sizeof(char *),
+ XOffsetOf(XlcCharSetRec, ct_sequence), XlcGetMask }
+};
+
+/* Retrieves a number of attributes of an XlcCharSet.
+ Return NULL if successful, otherwise the name of the first argument
+ specifiying a nonexistent attribute. */
+static char *
+get_values(
+ XlcCharSet charset,
+ XlcArgList args,
+ int num_args)
+{
+ if (resources[0].xrm_name == NULLQUARK)
+ _XlcCompileResourceList(resources, XlcNumber(resources));
+
+ return _XlcGetValues((XPointer) charset, resources, XlcNumber(resources),
+ args, num_args, XlcGetMask);
+}
+
+/* Retrieves a number of attributes of an XlcCharSet.
+ Return NULL if successful, otherwise the name of the first argument
+ specifiying a nonexistent attribute. */
+char *
+_XlcGetCSValues(XlcCharSet charset, ...)
+{
+ va_list var;
+ XlcArgList args;
+ char *ret;
+ int num_args;
+
+ va_start(var, charset);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ va_start(var, charset);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (char *) NULL;
+
+ ret = get_values(charset, args, num_args);
+
+ Xfree(args);
+
+ return ret;
+}
+
+/* Creates a new XlcCharSet, given its name (including side suffix) and
+ Compound Text ESC sequence (normally at most 4 bytes). */
+XlcCharSet
+_XlcCreateDefaultCharSet(
+ const char *name,
+ const char *ct_sequence)
+{
+ XlcCharSet charset;
+ int name_len, ct_sequence_len;
+ const char *colon;
+ char *tmp;
+
+ charset = (XlcCharSet) Xmalloc(sizeof(XlcCharSetRec));
+ if (charset == NULL)
+ return (XlcCharSet) NULL;
+ bzero((char *) charset, sizeof(XlcCharSetRec));
+
+ name_len = strlen(name);
+ ct_sequence_len = strlen(ct_sequence);
+
+ /* Fill in name and xrm_name. */
+ tmp = (char *) Xmalloc(name_len + 1 + ct_sequence_len + 1);
+ if (tmp == NULL) {
+ Xfree((char *) charset);
+ return (XlcCharSet) NULL;
+ }
+ memcpy(tmp, name, name_len+1);
+ charset->name = tmp;
+ charset->xrm_name = XrmStringToQuark(charset->name);
+
+ /* Fill in encoding_name and xrm_encoding_name. */
+ if ((colon = strchr(charset->name, ':')) != NULL) {
+ unsigned int length = colon - charset->name;
+ char *encoding_tmp = (char *) Xmalloc(length + 1);
+ if (encoding_tmp == NULL) {
+ Xfree((char *) charset->name);
+ Xfree((char *) charset);
+ return (XlcCharSet) NULL;
+ }
+ memcpy(encoding_tmp, charset->name, length);
+ encoding_tmp[length] = '\0';
+ charset->encoding_name = encoding_tmp;
+ charset->xrm_encoding_name = XrmStringToQuark(charset->encoding_name);
+ } else {
+ charset->encoding_name = charset->name;
+ charset->xrm_encoding_name = charset->xrm_name;
+ }
+
+ /* Fill in ct_sequence. */
+ tmp += name_len + 1;
+ memcpy(tmp, ct_sequence, ct_sequence_len+1);
+ charset->ct_sequence = tmp;
+
+ /* Fill in side, char_size, set_size. */
+ if (!_XlcParseCharSet(charset))
+ /* If ct_sequence is not usable in Compound Text, remove it. */
+ charset->ct_sequence = "";
+
+ return (XlcCharSet) charset;
+}
diff --git a/nx-X11/lib/X11/lcConv.c b/nx-X11/lib/X11/lcConv.c
new file mode 100644
index 000000000..2f65ac7bd
--- /dev/null
+++ b/nx-X11/lib/X11/lcConv.c
@@ -0,0 +1,341 @@
+/* $Xorg: lcConv.c,v 1.4 2000/08/17 19:45:17 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/lcConv.c,v 1.5 2000/12/04 18:49:26 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include <stdio.h>
+
+typedef struct _XlcConverterListRec {
+ XLCd from_lcd;
+ const char *from;
+ XrmQuark from_type;
+ XLCd to_lcd;
+ const char *to;
+ XrmQuark to_type;
+ XlcOpenConverterProc converter;
+ struct _XlcConverterListRec *next;
+} XlcConverterListRec, *XlcConverterList;
+
+static XlcConverterList conv_list = NULL;
+
+static void
+close_converter(
+ XlcConv conv)
+{
+ (*conv->methods->close)(conv);
+}
+
+static XlcConv
+get_converter(
+ XLCd from_lcd,
+ XrmQuark from_type,
+ XLCd to_lcd,
+ XrmQuark to_type)
+{
+ XlcConverterList list, prev = NULL;
+
+ for (list = conv_list; list; list = list->next) {
+ if (list->from_lcd == from_lcd && list->to_lcd == to_lcd
+ && list->from_type == from_type && list->to_type == to_type) {
+
+ if (prev && prev != conv_list) { /* XXX */
+ prev->next = list->next;
+ list->next = conv_list;
+ conv_list = list;
+ }
+
+ return (*list->converter)(from_lcd, list->from, to_lcd, list->to);
+ }
+
+ prev = list;
+ }
+
+ return (XlcConv) NULL;
+}
+
+Bool
+_XlcSetConverter(
+ XLCd from_lcd,
+ const char *from,
+ XLCd to_lcd,
+ const char *to,
+ XlcOpenConverterProc converter)
+{
+ XlcConverterList list;
+ XrmQuark from_type, to_type;
+
+ from_type = XrmStringToQuark(from);
+ to_type = XrmStringToQuark(to);
+
+ for (list = conv_list; list; list = list->next) {
+ if (list->from_lcd == from_lcd && list->to_lcd == to_lcd
+ && list->from_type == from_type && list->to_type == to_type) {
+
+ list->converter = converter;
+ return True;
+ }
+ }
+
+ list = (XlcConverterList) Xmalloc(sizeof(XlcConverterListRec));
+ if (list == NULL)
+ return False;
+
+ list->from_lcd = from_lcd;
+ list->from = from;
+ list->from_type = from_type;
+ list->to_lcd = to_lcd;
+ list->to = to;
+ list->to_type = to_type;
+ list->converter = converter;
+ list->next = conv_list;
+ conv_list = list;
+
+ return True;
+}
+
+typedef struct _ConvRec {
+ XlcConv from_conv;
+ XlcConv to_conv;
+} ConvRec, *Conv;
+
+static int
+indirect_convert(
+ XlcConv lc_conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ Conv conv = (Conv) lc_conv->state;
+ XlcConv from_conv = conv->from_conv;
+ XlcConv to_conv = conv->to_conv;
+ XlcCharSet charset;
+ char buf[BUFSIZ], *cs;
+ XPointer tmp_args[1];
+ int cs_left, ret, length, unconv_num = 0;
+
+ if (from == NULL || *from == NULL) {
+ if (from_conv->methods->reset)
+ (*from_conv->methods->reset)(from_conv);
+
+ if (to_conv->methods->reset)
+ (*to_conv->methods->reset)(to_conv);
+
+ return 0;
+ }
+
+ while (*from_left > 0) {
+ cs = buf;
+ cs_left = BUFSIZ;
+ tmp_args[0] = (XPointer) &charset;
+
+ ret = (*from_conv->methods->convert)(from_conv, from, from_left, &cs,
+ &cs_left, tmp_args, 1);
+ if (ret < 0)
+ break;
+
+ unconv_num += ret;
+
+ length = cs - buf;
+ if (length > 0) {
+ cs_left = length;
+ cs = buf;
+
+ tmp_args[0] = (XPointer) charset;
+
+ ret = (*to_conv->methods->convert)(to_conv, &cs, &cs_left, to, to_left,
+ tmp_args, 1);
+ if (ret < 0) {
+ unconv_num += length / (charset->char_size > 0 ? charset->char_size : 1);
+ continue;
+ }
+
+ unconv_num += ret;
+
+ if (*to_left < 1)
+ break;
+ }
+ }
+
+ return unconv_num;
+}
+
+static void
+close_indirect_converter(
+ XlcConv lc_conv)
+{
+ Conv conv = (Conv) lc_conv->state;
+
+ if (conv) {
+ if (conv->from_conv)
+ close_converter(conv->from_conv);
+ if (conv->to_conv)
+ close_converter(conv->to_conv);
+
+ Xfree((char *) conv);
+ }
+
+ Xfree((char *) lc_conv);
+}
+
+static void
+reset_indirect_converter(
+ XlcConv lc_conv)
+{
+ Conv conv = (Conv) lc_conv->state;
+
+ if (conv) {
+ if (conv->from_conv && conv->from_conv->methods->reset)
+ (*conv->from_conv->methods->reset)(conv->from_conv);
+ if (conv->to_conv && conv->to_conv->methods->reset)
+ (*conv->to_conv->methods->reset)(conv->to_conv);
+ }
+}
+
+static XlcConvMethodsRec conv_methods = {
+ close_indirect_converter,
+ indirect_convert,
+ reset_indirect_converter
+} ;
+
+static XlcConv
+open_indirect_converter(
+ XLCd from_lcd,
+ const char *from,
+ XLCd to_lcd,
+ const char *to)
+{
+ XlcConv lc_conv, from_conv, to_conv;
+ Conv conv;
+ XrmQuark from_type, to_type;
+ static XrmQuark QChar, QCharSet, QCTCharSet = (XrmQuark) 0;
+
+ if (QCTCharSet == (XrmQuark) 0) {
+ QCTCharSet = XrmStringToQuark(XlcNCTCharSet);
+ QCharSet = XrmStringToQuark(XlcNCharSet);
+ QChar = XrmStringToQuark(XlcNChar);
+ }
+
+ from_type = XrmStringToQuark(from);
+ to_type = XrmStringToQuark(to);
+
+ if (from_type == QCharSet || from_type == QChar || to_type == QCharSet ||
+ to_type == QChar)
+ return (XlcConv) NULL;
+
+ lc_conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (lc_conv == NULL)
+ return (XlcConv) NULL;
+
+ lc_conv->methods = &conv_methods;
+
+ lc_conv->state = (XPointer) Xcalloc(1, sizeof(ConvRec));
+ if (lc_conv->state == NULL)
+ goto err;
+
+ conv = (Conv) lc_conv->state;
+
+ from_conv = get_converter(from_lcd, from_type, from_lcd, QCTCharSet);
+ if (from_conv == NULL)
+ from_conv = get_converter(from_lcd, from_type, from_lcd, QCharSet);
+ if (from_conv == NULL)
+ from_conv = get_converter((XLCd)NULL, from_type, (XLCd)NULL, QCharSet);
+ if (from_conv == NULL)
+ from_conv = get_converter(from_lcd, from_type, from_lcd, QChar);
+ if (from_conv == NULL)
+ goto err;
+ conv->from_conv = from_conv;
+
+ to_conv = get_converter(to_lcd, QCTCharSet, to_lcd, to_type);
+ if (to_conv == NULL)
+ to_conv = get_converter(to_lcd, QCharSet, to_lcd, to_type);
+ if (to_conv == NULL)
+ to_conv = get_converter((XLCd) NULL, QCharSet, (XLCd) NULL, to_type);
+ if (to_conv == NULL)
+ goto err;
+ conv->to_conv = to_conv;
+
+ return lc_conv;
+
+err:
+ close_indirect_converter(lc_conv);
+
+ return (XlcConv) NULL;
+}
+
+XlcConv
+_XlcOpenConverter(
+ XLCd from_lcd,
+ const char *from,
+ XLCd to_lcd,
+ const char *to)
+{
+ XlcConv conv;
+ XrmQuark from_type, to_type;
+
+ from_type = XrmStringToQuark(from);
+ to_type = XrmStringToQuark(to);
+
+ if ((conv = get_converter(from_lcd, from_type, to_lcd, to_type)))
+ return conv;
+
+ return open_indirect_converter(from_lcd, from, to_lcd, to);
+}
+
+void
+_XlcCloseConverter(
+ XlcConv conv)
+{
+ close_converter(conv);
+}
+
+int
+_XlcConvert(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ return (*conv->methods->convert)(conv, from, from_left, to, to_left, args,
+ num_args);
+}
+
+void
+_XlcResetConverter(
+ XlcConv conv)
+{
+ if (conv->methods->reset)
+ (*conv->methods->reset)(conv);
+}
diff --git a/nx-X11/lib/X11/lcDB.c b/nx-X11/lib/X11/lcDB.c
new file mode 100644
index 000000000..ffa8f49ae
--- /dev/null
+++ b/nx-X11/lib/X11/lcDB.c
@@ -0,0 +1,1308 @@
+/* $Xorg: lcDB.c,v 1.6 2000/08/17 19:45:17 cpqbld Exp $ */
+/*
+ *
+ * Copyright IBM Corporation 1993
+ *
+ * All Rights Reserved
+ *
+ * License 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 IBM not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND
+ * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
+ * IBM 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.
+ *
+*/
+/*
+ * (c) Copyright 1995 FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+/* $XFree86: xc/lib/X11/lcDB.c,v 3.15tsi Exp $ */
+
+
+
+#ifndef NOT_X_ENV
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xresource.h>
+#include "Xlibint.h"
+#include "XlcPubI.h"
+
+#else /* NOT_X_ENV */
+
+#define Xmalloc malloc
+#define Xrealloc realloc
+#define Xfree free
+
+#endif /* NOT_X_ENV */
+
+/* specifying NOT_X_ENV allows users to just use
+ the database parsing routine. */
+/* For UDC/VW */
+#ifndef BUFSIZE
+#define BUFSIZE 2048
+#endif
+
+#ifdef COMMENT
+#ifdef BUFSIZE
+#undef BUFSIZE
+#endif
+#define BUFSIZE 6144 /* 2048*3 */
+#endif
+
+#include <stdio.h>
+
+typedef struct _DatabaseRec {
+ char *category;
+ char *name;
+ char **value;
+ int value_num;
+ struct _DatabaseRec *next;
+} DatabaseRec, *Database;
+
+typedef enum {
+ S_NULL, /* outside category */
+ S_CATEGORY, /* inside category */
+ S_NAME, /* has name, expecting values */
+ S_VALUE
+} ParseState;
+
+typedef enum {
+ T_NEWLINE,
+ T_COMMENT,
+ T_SEMICOLON,
+ T_DOUBLE_QUOTE,
+ T_LEFT_BRACE,
+ T_RIGHT_BRACE,
+ T_SPACE,
+ T_TAB,
+ T_BACKSLASH,
+ T_NUMERIC_HEX,
+ T_NUMERIC_DEC,
+ T_NUMERIC_OCT,
+ T_DEFAULT
+} Token;
+
+typedef struct {
+ Token token; /* token id */
+ const char *name; /* token sequence */
+ int len; /* length of token sequence */
+ int (*parse_proc)(const char *str, Token token, Database *db);
+ /* parsing procedure */
+} TokenTable;
+
+static int f_newline (const char *str, Token token, Database *db);
+static int f_comment (const char *str, Token token, Database *db);
+static int f_semicolon (const char *str, Token token, Database *db);
+static int f_double_quote (const char *str, Token token, Database *db);
+static int f_left_brace (const char *str, Token token, Database *db);
+static int f_right_brace (const char *str, Token token, Database *db);
+static int f_white (const char *str, Token token, Database *db);
+static int f_backslash (const char *str, Token token, Database *db);
+static int f_numeric (const char *str, Token token, Database *db);
+static int f_default (const char *str, Token token, Database *db);
+
+static TokenTable token_tbl[] = {
+ { T_NEWLINE, "\n", 1, f_newline },
+ { T_COMMENT, "#", 1, f_comment },
+ { T_SEMICOLON, ";", 1, f_semicolon },
+ { T_DOUBLE_QUOTE, "\"", 1, f_double_quote },
+ { T_LEFT_BRACE, "{", 1, f_left_brace },
+ { T_RIGHT_BRACE, "}", 1, f_right_brace },
+ { T_SPACE, " ", 1, f_white },
+ { T_TAB, "\t", 1, f_white },
+ { T_BACKSLASH, "\\", 1, f_backslash },
+ { T_NUMERIC_HEX, "\\x", 2, f_numeric },
+ { T_NUMERIC_DEC, "\\d", 2, f_numeric },
+ { T_NUMERIC_OCT, "\\o", 2, f_numeric },
+ { T_DEFAULT, " ", 1, f_default } /* any character */
+};
+
+#define SYM_CR '\r'
+#define SYM_NEWLINE '\n'
+#define SYM_COMMENT '#'
+#define SYM_SEMICOLON ';'
+#define SYM_DOUBLE_QUOTE '"'
+#define SYM_LEFT_BRACE '{'
+#define SYM_RIGHT_BRACE '}'
+#define SYM_SPACE ' '
+#define SYM_TAB '\t'
+#define SYM_BACKSLASH '\\'
+
+/************************************************************************/
+
+#define MAX_NAME_NEST 64
+
+typedef struct {
+ ParseState pre_state;
+ char *category;
+ char *name[MAX_NAME_NEST];
+ int nest_depth;
+ char **value;
+ int value_len;
+ int value_num;
+ int bufsize; /* bufMaxSize >= bufsize >= 0 */
+ int bufMaxSize; /* default : BUFSIZE */
+ char *buf;
+} DBParseInfo;
+
+static DBParseInfo parse_info;
+
+static void
+init_parse_info (void)
+{
+ static int allocated /* = 0 */;
+ char *ptr;
+ int size;
+ if (!allocated) {
+ bzero(&parse_info, sizeof(DBParseInfo));
+ parse_info.buf = (char *)Xmalloc(BUFSIZE);
+ parse_info.bufMaxSize = BUFSIZE;
+ allocated = 1;
+ return;
+ }
+ ptr = parse_info.buf;
+ size = parse_info.bufMaxSize;
+ bzero(&parse_info, sizeof(DBParseInfo));
+ parse_info.buf = ptr;
+ parse_info.bufMaxSize = size;
+}
+
+static void
+clear_parse_info (void)
+{
+ int i;
+ char *ptr;
+ int size;
+ parse_info.pre_state = S_NULL;
+ if (parse_info.category != NULL) {
+ Xfree(parse_info.category);
+ }
+ for (i = 0; i <= parse_info.nest_depth; ++i) {
+ if (parse_info.name[i]) {
+ Xfree(parse_info.name[i]);
+ }
+ }
+ if (parse_info.value) {
+ if (*parse_info.value) {
+ Xfree(*parse_info.value);
+ }
+ Xfree((char *)parse_info.value);
+ }
+ ptr = parse_info.buf;
+ size = parse_info.bufMaxSize;
+ bzero(&parse_info, sizeof(DBParseInfo));
+ parse_info.buf = ptr;
+ parse_info.bufMaxSize = size;
+}
+
+static Bool
+realloc_parse_info(
+ int len)
+{
+ char *p;
+
+ parse_info.bufMaxSize = BUFSIZE * ((parse_info.bufsize + len)/BUFSIZE + 1);
+ p = (char *)Xrealloc(parse_info.buf, parse_info.bufMaxSize);
+ if (p == NULL)
+ return False;
+ parse_info.buf = p;
+
+ return True;
+}
+
+/************************************************************************/
+
+typedef struct _Line {
+ char *str;
+ int cursize;
+ int maxsize;
+ int seq;
+} Line;
+
+static void
+free_line(
+ Line *line)
+{
+ if (line->str != NULL) {
+ Xfree(line->str);
+ }
+ bzero(line, sizeof(Line));
+}
+
+static int
+realloc_line(
+ Line *line,
+ int size)
+{
+ char *str = line->str;
+
+ if (str != NULL) {
+ str = (char *)Xrealloc(str, size);
+ } else {
+ str = (char *)Xmalloc(size);
+ }
+ if (str == NULL) {
+ /* malloc error */
+ if (line->str != NULL) {
+ Xfree(line->str);
+ }
+ bzero(line, sizeof(Line));
+ return 0;
+ }
+ line->str = str;
+ line->maxsize = size;
+ return 1;
+}
+
+#define iswhite(ch) ((ch) == SYM_SPACE || (ch) == SYM_TAB)
+
+static void
+zap_comment(
+ char *str,
+ int *quoted)
+{
+ char *p = str;
+#ifdef never
+ *quoted = 0;
+ if (*p == SYM_COMMENT) {
+ int len = strlen(str);
+ if (p[len - 1] == SYM_NEWLINE || p[len - 1] == SYM_CR) {
+ *p++ = SYM_NEWLINE;
+ }
+ *p = '\0';
+ }
+#else
+ while (*p) {
+ if (*p == SYM_DOUBLE_QUOTE) {
+ if (p == str || p[-1] != SYM_BACKSLASH) {
+ /* unescaped double quote changes quoted state. */
+ *quoted = *quoted ? 0 : 1;
+ }
+ }
+ if (*p == SYM_COMMENT && !*quoted) {
+ int pos = p - str;
+ if (pos == 0 ||
+ (iswhite(p[-1]) && (pos == 1 || p[-2] != SYM_BACKSLASH))) {
+ int len = strlen(p);
+ if (len > 0 && (p[len - 1] == SYM_NEWLINE || p[len-1] == SYM_CR)) {
+ /* newline is the identifier for finding end of value.
+ therefore, it should not be removed. */
+ *p++ = SYM_NEWLINE;
+ }
+ *p = '\0';
+ break;
+ }
+ }
+ ++p;
+ }
+#endif
+}
+
+static int
+read_line(
+ FILE *fd,
+ Line *line)
+{
+ char buf[BUFSIZE], *p;
+ int len;
+ int quoted = 0; /* quoted by double quote? */
+ char *str;
+ int cur;
+
+ str = line->str;
+ cur = line->cursize = 0;
+
+ while ((p = fgets(buf, BUFSIZE, fd)) != NULL) {
+ ++line->seq;
+ zap_comment(p, &quoted); /* remove comment line */
+ len = strlen(p);
+ if (len == 0) {
+ if (cur > 0) {
+ break;
+ }
+ continue;
+ }
+ if (cur + len + 1 > line->maxsize) {
+ /* need to reallocate buffer. */
+ if (! realloc_line(line, line->maxsize + BUFSIZE)) {
+ return -1; /* realloc error. */
+ }
+ str = line->str;
+ }
+ strncpy(str + cur, p, len);
+
+ cur += len;
+ str[cur] = '\0';
+#ifdef __UNIXOS2__ /* Take out carriage returns under OS/2 */
+ if (cur>1) {
+ if (str[cur-2] == '\r' && str[cur-1] == '\n') {
+ str[cur-2] = '\n';
+ str[cur-1] = '\0';
+ cur--;
+ }
+ }
+#endif
+ if (!quoted && cur > 1 && str[cur - 2] == SYM_BACKSLASH &&
+ (str[cur - 1] == SYM_NEWLINE || str[cur-1] == SYM_CR)) {
+ /* the line is ended backslash followed by newline.
+ need to concatinate the next line. */
+ cur -= 2;
+ str[cur] = '\0';
+ } else if (len < BUFSIZE - 1 || buf[len - 1] == SYM_NEWLINE ||
+ buf[len - 1] == SYM_CR) {
+ /* the line is shorter than BUFSIZE. */
+ break;
+ }
+ }
+ if (quoted) {
+ /* error. still in quoted state. */
+ return -1;
+ }
+ return line->cursize = cur;
+}
+
+/************************************************************************/
+
+static Token
+get_token(
+ const char *str)
+{
+ switch (*str) {
+ case SYM_NEWLINE:
+ case SYM_CR: return T_NEWLINE;
+ case SYM_COMMENT: return T_COMMENT;
+ case SYM_SEMICOLON: return T_SEMICOLON;
+ case SYM_DOUBLE_QUOTE: return T_DOUBLE_QUOTE;
+ case SYM_LEFT_BRACE: return T_LEFT_BRACE;
+ case SYM_RIGHT_BRACE: return T_RIGHT_BRACE;
+ case SYM_SPACE: return T_SPACE;
+ case SYM_TAB: return T_TAB;
+ case SYM_BACKSLASH:
+ switch (str[1]) {
+ case 'x': return T_NUMERIC_HEX;
+ case 'd': return T_NUMERIC_DEC;
+ case 'o': return T_NUMERIC_OCT;
+ }
+ return T_BACKSLASH;
+ default:
+ return T_DEFAULT;
+ }
+}
+
+static int
+get_word(
+ const char *str,
+ char *word)
+{
+ const char *p = str;
+ char *w = word;
+ Token token;
+ int token_len;
+
+ while (*p != '\0') {
+ token = get_token(p);
+ token_len = token_tbl[token].len;
+ if (token == T_BACKSLASH) {
+ p += token_len;
+ if (*p == '\0')
+ break;
+ token = get_token(p);
+ token_len = token_tbl[token].len;
+ } else if (token != T_COMMENT && token != T_DEFAULT) {
+ break;
+ }
+ strncpy(w, p, token_len);
+ p += token_len; w += token_len;
+ }
+ *w = '\0';
+ return p - str; /* return number of scanned chars */
+}
+
+static int
+get_quoted_word(
+ const char *str,
+ char *word)
+{
+ const char *p = str;
+ char *w = word;
+ Token token;
+ int token_len;
+
+ if (*p == SYM_DOUBLE_QUOTE) {
+ ++p;
+ }
+ while (*p != '\0') {
+ token = get_token(p);
+ token_len = token_tbl[token].len;
+ if (token == T_DOUBLE_QUOTE) {
+ p += token_len;
+ goto found;
+ }
+ if (token == T_BACKSLASH) {
+ p += token_len;
+ if (*p == '\0') {
+ break;
+ }
+ token = get_token(p);
+ token_len = token_tbl[token].len;
+ }
+ strncpy(w, p, token_len);
+ p += token_len; w += token_len;
+ }
+ /* error. cannot detect next double quote */
+ return 0;
+
+ found:;
+ *w = '\0';
+ return p - str;
+}
+
+/************************************************************************/
+
+static int
+append_value_list (void)
+{
+ char **value_list = parse_info.value;
+ char *value;
+ int value_num = parse_info.value_num;
+ int value_len = parse_info.value_len;
+ char *str = parse_info.buf;
+ int len = parse_info.bufsize;
+ char *p;
+
+ if (len < 1) {
+ return 1; /* return with no error */
+ }
+
+ if (value_list == (char **)NULL) {
+ value_list = (char **)Xmalloc(sizeof(char *) * 2);
+ *value_list = NULL;
+ } else {
+ char **prev_list = value_list;
+
+ value_list = (char **)
+ Xrealloc(value_list, sizeof(char *) * (value_num + 2));
+ if (value_list == NULL) {
+ Xfree(prev_list);
+ }
+ }
+ if (value_list == (char **)NULL)
+ goto err2;
+
+ value = *value_list;
+ if (value == NULL) {
+ value = (char *)Xmalloc(value_len + len + 1);
+ } else {
+ char *prev_value = value;
+
+ value = (char *)Xrealloc(value, value_len + len + 1);
+ if (value == NULL) {
+ Xfree(prev_value);
+ }
+ }
+ if (value == NULL) {
+ goto err1;
+ }
+ if (value != *value_list) {
+ int delta, i;
+ delta = value - *value_list;
+ *value_list = value;
+ for (i = 1; i < value_num; ++i) {
+ value_list[i] += delta;
+ }
+ }
+
+ value_list[value_num] = p = &value[value_len];
+ value_list[value_num + 1] = NULL;
+ strncpy(p, str, len);
+ p[len] = 0;
+
+ parse_info.value = value_list;
+ parse_info.value_num = value_num + 1;
+ parse_info.value_len = value_len + len + 1;
+ parse_info.bufsize = 0;
+ return 1;
+
+ err1:
+ if (value_list) {
+ Xfree((char **)value_list);
+ }
+ if (value) {
+ Xfree(value);
+ }
+ err2:
+ parse_info.value = (char **)NULL;
+ parse_info.value_num = 0;
+ parse_info.value_len = 0;
+ parse_info.bufsize = 0;
+ return 0;
+}
+
+static int
+construct_name(
+ char *name,
+ int size)
+{
+ int i;
+ int len = 0;
+ char *p = name;
+
+ for (i = 0; i <= parse_info.nest_depth; ++i) {
+ len += strlen(parse_info.name[i]) + 1;
+ }
+ if (len >= size)
+ return 0;
+
+ strcpy(p, parse_info.name[0]);
+ p += strlen(parse_info.name[0]);
+ for (i = 1; i <= parse_info.nest_depth; ++i) {
+ *p++ = '.';
+ strcpy(p, parse_info.name[i]);
+ p += strlen(parse_info.name[i]);
+ }
+ return *name != '\0';
+}
+
+static int
+store_to_database(
+ Database *db)
+{
+ Database new = (Database)NULL;
+ char name[BUFSIZE];
+
+ if (parse_info.pre_state == S_VALUE) {
+ if (! append_value_list()) {
+ goto err;
+ }
+ }
+
+ if (parse_info.name[parse_info.nest_depth] == NULL) {
+ goto err;
+ }
+
+ new = (Database)Xmalloc(sizeof(DatabaseRec));
+ if (new == (Database)NULL) {
+ goto err;
+ }
+ bzero(new, sizeof(DatabaseRec));
+
+ new->category = (char *)Xmalloc(strlen(parse_info.category) + 1);
+ if (new->category == NULL) {
+ goto err;
+ }
+ strcpy(new->category, parse_info.category);
+
+ if (! construct_name(name, sizeof(name))) {
+ goto err;
+ }
+ new->name = (char *)Xmalloc(strlen(name) + 1);
+ if (new->name == NULL) {
+ goto err;
+ }
+ strcpy(new->name, name);
+ new->next = *db;
+ new->value = parse_info.value;
+ new->value_num = parse_info.value_num;
+ *db = new;
+
+ Xfree(parse_info.name[parse_info.nest_depth]);
+ parse_info.name[parse_info.nest_depth] = NULL;
+
+ parse_info.value = (char **)NULL;
+ parse_info.value_num = 0;
+ parse_info.value_len = 0;
+
+ return 1;
+
+ err:
+ if (new) {
+ if (new->category) {
+ Xfree(new->category);
+ }
+ if (new->name) {
+ Xfree(new->name);
+ }
+ }
+ if (parse_info.value) {
+ if (*parse_info.value) {
+ Xfree(*parse_info.value);
+ }
+ Xfree((char **)parse_info.value);
+ parse_info.value = (char **)NULL;
+ parse_info.value_num = 0;
+ parse_info.value_len = 0;
+ }
+ return 0;
+}
+
+#define END_MARK "END"
+#define END_MARK_LEN 3 /*strlen(END_MARK)*/
+
+static int
+check_category_end(
+ const char *str)
+{
+ const char *p;
+ int len;
+
+ p = str;
+ if (strncmp(p, END_MARK, END_MARK_LEN)) {
+ return 0;
+ }
+ p += END_MARK_LEN;
+
+ while (iswhite(*p)) {
+ ++p;
+ }
+ len = strlen(parse_info.category);
+ if (strncmp(p, parse_info.category, len)) {
+ return 0;
+ }
+ p += len;
+ return p - str;
+}
+
+/************************************************************************/
+
+static int
+f_newline(
+ const char *str,
+ Token token,
+ Database *db)
+{
+ switch (parse_info.pre_state) {
+ case S_NULL:
+ case S_CATEGORY:
+ break;
+ case S_NAME:
+ return 0; /* no value */
+ case S_VALUE:
+ if (!store_to_database(db))
+ return 0;
+ parse_info.pre_state = S_CATEGORY;
+ break;
+ default:
+ return 0;
+ }
+ return token_tbl[token].len;
+}
+
+static int
+f_comment(
+ const char *str,
+ Token token,
+ Database *db)
+{
+ /* NOTE: comment is already handled in read_line(),
+ so this function is not necessary. */
+
+ const char *p = str;
+
+ while (*p != SYM_NEWLINE && *p != SYM_CR && *p != '\0') {
+ ++p; /* zap to the end of line */
+ }
+ return p - str;
+}
+
+static int
+f_white(
+ const char *str,
+ Token token,
+ Database *db)
+{
+ const char *p = str;
+
+ while (iswhite(*p)) {
+ ++p;
+ }
+ return p - str;
+}
+
+static int
+f_semicolon(
+ const char *str,
+ Token token,
+ Database *db)
+{
+ switch (parse_info.pre_state) {
+ case S_NULL:
+ case S_CATEGORY:
+ case S_NAME:
+ return 0;
+ case S_VALUE:
+ if (! append_value_list())
+ return 0;
+ parse_info.pre_state = S_VALUE;
+ break;
+ default:
+ return 0;
+ }
+ return token_tbl[token].len;
+}
+
+static int
+f_left_brace(
+ const char *str,
+ Token token,
+ Database *db)
+{
+ switch (parse_info.pre_state) {
+ case S_NULL:
+ case S_CATEGORY:
+ case S_VALUE:
+ return 0;
+ case S_NAME:
+ if (parse_info.name[parse_info.nest_depth] == NULL
+ || parse_info.nest_depth + 1 > MAX_NAME_NEST)
+ return 0;
+ ++parse_info.nest_depth;
+ parse_info.pre_state = S_CATEGORY;
+ break;
+ default:
+ return 0;
+ }
+ return token_tbl[token].len;
+}
+
+static int
+f_right_brace(
+ const char *str,
+ Token token,
+ Database *db)
+{
+ if (parse_info.nest_depth < 1)
+ return 0;
+
+ switch (parse_info.pre_state) {
+ case S_NULL:
+ case S_NAME:
+ return 0;
+ case S_VALUE:
+ if (! store_to_database(db))
+ return 0;
+ /* fall into next case */
+ case S_CATEGORY:
+ if (parse_info.name[parse_info.nest_depth] != NULL) {
+ Xfree(parse_info.name[parse_info.nest_depth]);
+ parse_info.name[parse_info.nest_depth] = NULL;
+ }
+ --parse_info.nest_depth;
+ parse_info.pre_state = S_CATEGORY;
+ break;
+ default:
+ return 0;
+ }
+ return token_tbl[token].len;
+}
+
+static int
+f_double_quote(
+ const char *str,
+ Token token,
+ Database *db)
+{
+ char word[BUFSIZE];
+ char* wordp;
+ int len;
+
+ if ((len = strlen (str)) < sizeof word)
+ wordp = word;
+ else
+ wordp = Xmalloc (len + 1);
+ if (wordp == NULL)
+ return 0;
+
+ len = 0;
+ switch (parse_info.pre_state) {
+ case S_NULL:
+ case S_CATEGORY:
+ goto err;
+ case S_NAME:
+ case S_VALUE:
+ len = get_quoted_word(str, wordp);
+ if (len < 1)
+ goto err;
+ if ((parse_info.bufsize + (int)strlen(wordp) + 1)
+ >= parse_info.bufMaxSize) {
+ if (realloc_parse_info(strlen(wordp)+1) == False) {
+ goto err;
+ }
+ }
+ strcpy(&parse_info.buf[parse_info.bufsize], wordp);
+ parse_info.bufsize += strlen(wordp);
+ parse_info.pre_state = S_VALUE;
+ break;
+ default:
+ goto err;
+ }
+ if (wordp != word)
+ Xfree (wordp);
+ return len; /* including length of token */
+
+err:
+ if (wordp != word)
+ Xfree (wordp);
+ return 0;
+}
+
+static int
+f_backslash(
+ const char *str,
+ Token token,
+ Database *db)
+{
+ return f_default(str, token, db);
+}
+
+static int
+f_numeric(
+ const char *str,
+ Token token,
+ Database *db)
+{
+ char word[BUFSIZE];
+ const char *p;
+ char* wordp;
+ int len;
+ int token_len;
+
+ if ((len = strlen (str)) < sizeof word)
+ wordp = word;
+ else
+ wordp = Xmalloc (len + 1);
+ if (wordp == NULL)
+ return 0;
+
+ switch (parse_info.pre_state) {
+ case S_NULL:
+ case S_CATEGORY:
+ goto err;
+ case S_NAME:
+ case S_VALUE:
+ token_len = token_tbl[token].len;
+ p = str + token_len;
+ len = get_word(p, wordp);
+ if (len < 1)
+ goto err;
+ if ((parse_info.bufsize + token_len + (int)strlen(wordp) + 1)
+ >= parse_info.bufMaxSize) {
+ if (realloc_parse_info(token_len + strlen(wordp) + 1) == False)
+ goto err;
+ }
+ strncpy(&parse_info.buf[parse_info.bufsize], str, token_len);
+ strcpy(&parse_info.buf[parse_info.bufsize + token_len], wordp);
+ parse_info.bufsize += token_len + strlen(wordp);
+ parse_info.pre_state = S_VALUE;
+ break;
+ default:
+ goto err;
+ }
+ if (wordp != word)
+ Xfree (wordp);
+ return len + token_len;
+
+err:
+ if (wordp != word)
+ Xfree (wordp);
+ return 0;
+}
+
+static int
+f_default(
+ const char *str,
+ Token token,
+ Database *db)
+{
+ char word[BUFSIZE], *p;
+ char* wordp;
+ int len;
+
+ if ((len = strlen (str)) < sizeof word)
+ wordp = word;
+ else
+ wordp = Xmalloc (len + 1);
+ if (wordp == NULL)
+ return 0;
+
+ len = get_word(str, wordp);
+ if (len < 1)
+ goto err;
+
+ switch (parse_info.pre_state) {
+ case S_NULL:
+ if (parse_info.category != NULL)
+ goto err;
+ p = (char *)Xmalloc(strlen(wordp) + 1);
+ if (p == NULL)
+ goto err;
+ strcpy(p, wordp);
+ parse_info.category = p;
+ parse_info.pre_state = S_CATEGORY;
+ break;
+ case S_CATEGORY:
+ if (parse_info.nest_depth == 0) {
+ if (check_category_end(str)) {
+ /* end of category is detected.
+ clear context and zap to end of this line */
+ clear_parse_info();
+ len = strlen(str);
+ break;
+ }
+ }
+ p = (char *)Xmalloc(strlen(wordp) + 1);
+ if (p == NULL)
+ goto err;
+ strcpy(p, wordp);
+ if (parse_info.name[parse_info.nest_depth] != NULL) {
+ Xfree(parse_info.name[parse_info.nest_depth]);
+ }
+ parse_info.name[parse_info.nest_depth] = p;
+ parse_info.pre_state = S_NAME;
+ break;
+ case S_NAME:
+ case S_VALUE:
+ if ((parse_info.bufsize + (int)strlen(wordp) + 1)
+ >= parse_info.bufMaxSize) {
+ if (realloc_parse_info(strlen(wordp) + 1) == False)
+ goto err;
+ }
+ strcpy(&parse_info.buf[parse_info.bufsize], wordp);
+ parse_info.bufsize += strlen(wordp);
+ parse_info.pre_state = S_VALUE;
+ break;
+ default:
+ goto err;
+ }
+ if (wordp != word)
+ Xfree (wordp);
+ return len;
+
+err:
+ if (wordp != word)
+ Xfree (wordp);
+ return 0;
+}
+
+/************************************************************************/
+
+#ifdef DEBUG
+static void
+PrintDatabase(
+ Database db)
+{
+ Database p = db;
+ int i = 0, j;
+
+ printf("***\n*** BEGIN Database\n***\n");
+ while (p) {
+ printf("%3d: ", i++);
+ printf("%s, %s, ", p->category, p->name);
+ printf("\t[%d: ", p->value_num);
+ for (j = 0; j < p->value_num; ++j) {
+ printf("%s, ", p->value[j]);
+ }
+ printf("]\n");
+ p = p->next;
+ }
+ printf("***\n*** END Database\n***\n");
+}
+#endif
+
+static void
+DestroyDatabase(
+ Database db)
+{
+ Database p = db;
+
+ while (p) {
+ if (p->category != NULL) {
+ Xfree(p->category);
+ }
+ if (p->name != NULL) {
+ Xfree(p->name);
+ }
+ if (p->value != (char **)NULL) {
+ if (*p->value != NULL) {
+ Xfree(*p->value);
+ }
+ Xfree((char *)p->value);
+ }
+ db = p->next;
+ Xfree((char *)p);
+ p = db;
+ }
+}
+
+static int
+CountDatabase(
+ Database db)
+{
+ Database p = db;
+ int cnt = 0;
+
+ while (p) {
+ ++cnt;
+ p = p->next;
+ }
+ return cnt;
+}
+
+static Database
+CreateDatabase(
+ char *dbfile)
+{
+ Database db = (Database)NULL;
+ FILE *fd;
+ Line line;
+ char *p;
+ Token token;
+ int len;
+ int error = 0;
+
+ fd = _XFopenFile(dbfile, "r");
+ if (fd == (FILE *)NULL)
+ return NULL;
+
+ bzero(&line, sizeof(Line));
+ init_parse_info();
+
+ do {
+ int rc = read_line(fd, &line);
+ if (rc < 0) {
+ error = 1;
+ break;
+ } else if (rc == 0) {
+ break;
+ }
+ p = line.str;
+ while (*p) {
+ token = get_token(p);
+ len = (*token_tbl[token].parse_proc)(p, token, &db);
+ if (len < 1) {
+ error = 1;
+ break;
+ }
+ p += len;
+ }
+ } while (!error);
+
+ if (parse_info.pre_state != S_NULL) {
+ clear_parse_info();
+ error = 1;
+ }
+ if (error) {
+#ifdef DEBUG
+ fprintf(stderr, "database format error at line %d.\n", line.seq);
+#endif
+ DestroyDatabase(db);
+ db = (Database)NULL;
+ }
+
+ fclose(fd);
+ free_line(&line);
+
+#ifdef DEBUG
+ PrintDatabase(db);
+#endif
+
+ return db;
+}
+
+/************************************************************************/
+
+#ifndef NOT_X_ENV
+
+/* locale framework functions */
+
+typedef struct _XlcDatabaseRec {
+ XrmQuark category_q;
+ XrmQuark name_q;
+ Database db;
+ struct _XlcDatabaseRec *next;
+} XlcDatabaseRec, *XlcDatabase;
+
+typedef struct _XlcDatabaseListRec {
+ XrmQuark name_q;
+ XlcDatabase lc_db;
+ Database database;
+ int ref_count;
+ struct _XlcDatabaseListRec *next;
+} XlcDatabaseListRec, *XlcDatabaseList;
+
+/* database cache list (per file) */
+static XlcDatabaseList _db_list = (XlcDatabaseList)NULL;
+
+/************************************************************************/
+/* _XlcGetResource(lcd, category, class, value, count) */
+/*----------------------------------------------------------------------*/
+/* This function retrieves XLocale database information. */
+/************************************************************************/
+void
+_XlcGetResource(
+ XLCd lcd,
+ const char *category,
+ const char *class,
+ char ***value,
+ int *count)
+{
+ XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd);
+
+ (*methods->get_resource)(lcd, category, class, value, count);
+ return;
+}
+
+/************************************************************************/
+/* _XlcGetLocaleDataBase(lcd, category, class, value, count) */
+/*----------------------------------------------------------------------*/
+/* This function retrieves XLocale database information. */
+/************************************************************************/
+void
+_XlcGetLocaleDataBase(
+ XLCd lcd,
+ const char *category,
+ const char *name,
+ char ***value,
+ int *count)
+{
+ XlcDatabase lc_db = (XlcDatabase)XLC_PUBLIC(lcd, xlocale_db);
+ XrmQuark category_q, name_q;
+
+ category_q = XrmStringToQuark(category);
+ name_q = XrmStringToQuark(name);
+ for (; lc_db->db; ++lc_db) {
+ if (category_q == lc_db->category_q && name_q == lc_db->name_q) {
+ *value = lc_db->db->value;
+ *count = lc_db->db->value_num;
+ return;
+ }
+ }
+ *value = (char **)NULL;
+ *count = 0;
+}
+
+/************************************************************************/
+/* _XlcDestroyLocaleDataBase(lcd) */
+/*----------------------------------------------------------------------*/
+/* This function destroy the XLocale Database that bound to the */
+/* specified lcd. If the XLocale Database is refered from some */
+/* other lcd, this function just decreases reference count of */
+/* the database. If no locale refers the database, this function */
+/* remove it from the cache list and free work area. */
+/************************************************************************/
+void
+_XlcDestroyLocaleDataBase(
+ XLCd lcd)
+{
+ XlcDatabase lc_db = (XlcDatabase)XLC_PUBLIC(lcd, xlocale_db);
+ XlcDatabaseList p, prev;
+
+ for (p = _db_list, prev = (XlcDatabaseList)NULL; p;
+ prev = p, p = p->next) {
+ if (p->lc_db == lc_db) {
+ if ((-- p->ref_count) < 1) {
+ if (p->lc_db != (XlcDatabase)NULL) {
+ Xfree((char *)p->lc_db);
+ }
+ DestroyDatabase(p->database);
+ if (prev == (XlcDatabaseList)NULL) {
+ _db_list = p->next;
+ } else {
+ prev->next = p->next;
+ }
+ Xfree((char*)p);
+ }
+ break;
+ }
+ }
+ XLC_PUBLIC(lcd, xlocale_db) = (XPointer)NULL;
+}
+
+/************************************************************************/
+/* _XlcCreateLocaleDataBase(lcd) */
+/*----------------------------------------------------------------------*/
+/* This function create an XLocale database which correspond to */
+/* the specified XLCd. */
+/************************************************************************/
+XPointer
+_XlcCreateLocaleDataBase(
+ XLCd lcd)
+{
+ XlcDatabaseList list, new;
+ Database p, database = (Database)NULL;
+ XlcDatabase lc_db = (XlcDatabase)NULL;
+ XrmQuark name_q;
+ char *name;
+ int i, n;
+
+ name = _XlcFileName(lcd, "locale");
+ if (name == NULL)
+ return (XPointer)NULL;
+
+#ifndef __UNIXOS2__
+ name_q = XrmStringToQuark(name);
+#else
+ name_q = XrmStringToQuark((char*)__XOS2RedirRoot(name));
+#endif
+ for (list = _db_list; list; list = list->next) {
+ if (name_q == list->name_q) {
+ list->ref_count++;
+ Xfree (name);
+ return XLC_PUBLIC(lcd, xlocale_db) = (XPointer)list->lc_db;
+ }
+ }
+
+ database = CreateDatabase(name);
+ if (database == (Database)NULL) {
+ Xfree (name);
+ return (XPointer)NULL;
+ }
+ n = CountDatabase(database);
+ lc_db = (XlcDatabase)Xmalloc(sizeof(XlcDatabaseRec) * (n + 1));
+ if (lc_db == (XlcDatabase)NULL)
+ goto err;
+ bzero(lc_db, sizeof(XlcDatabaseRec) * (n + 1));
+ for (p = database, i = 0; p && i < n; p = p->next, ++i) {
+ lc_db[i].category_q = XrmStringToQuark(p->category);
+ lc_db[i].name_q = XrmStringToQuark(p->name);
+ lc_db[i].db = p;
+ }
+
+ new = (XlcDatabaseList)Xmalloc(sizeof(XlcDatabaseListRec));
+ if (new == (XlcDatabaseList)NULL) {
+ goto err;
+ }
+ new->name_q = name_q;
+ new->lc_db = lc_db;
+ new->database = database;
+ new->ref_count = 1;
+ new->next = _db_list;
+ _db_list = new;
+
+ Xfree (name);
+ return XLC_PUBLIC(lcd, xlocale_db) = (XPointer)lc_db;
+
+ err:
+ DestroyDatabase(database);
+ if (lc_db != (XlcDatabase)NULL) {
+ Xfree((char *)lc_db);
+ }
+ Xfree (name);
+ return (XPointer)NULL;
+}
+
+#endif /* NOT_X_ENV */
diff --git a/nx-X11/lib/X11/lcDefConv.c b/nx-X11/lib/X11/lcDefConv.c
new file mode 100644
index 000000000..fb504d11d
--- /dev/null
+++ b/nx-X11/lib/X11/lcDefConv.c
@@ -0,0 +1,793 @@
+/* $Xorg: lcDefConv.c,v 1.3 2000/08/17 19:45:17 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * 2000
+ * Modifier: Ivan Pascal The XFree86 Project
+ */
+/* $XFree86: xc/lib/X11/lcDefConv.c,v 1.6 2001/01/17 19:41:53 dawes Exp $ */
+
+/*
+ * The default locale loader.
+ * Supports: one byte per char (iso8859 like) locales.
+ * How: converts bytes to wide characters in a 1:1 manner.
+ * Platforms: all systems.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcGeneric.h"
+
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 6
+#endif
+
+#if !defined(macII) && !defined(Lynx_22) && !defined(X_LOCALE)
+#define STDCVT
+#endif
+
+#define GR 0x80
+#define GL 0x7f
+
+typedef struct _StateRec *State;
+typedef struct _StateRec {
+ CodeSet GL_codeset;
+ CodeSet GR_codeset;
+ wchar_t wc_mask;
+ wchar_t wc_encode_mask;
+ Bool (*MBtoWC) (State state, const char *ch, wchar_t *wc);
+ Bool (*WCtoMB) (State state, wchar_t wc, char *ch);
+} StateRec;
+
+static
+Bool MBtoWCdef(
+ State state,
+ const char *ch,
+ wchar_t *wc)
+{
+ wchar_t wc_encoding;
+ CodeSet codeset = (*ch & GR) ? state->GR_codeset : state->GL_codeset;
+ if (!codeset)
+ return False;
+ wc_encoding = codeset->wc_encoding;
+ *wc = ((wchar_t) *ch & state->wc_mask) | wc_encoding;
+ return True;
+}
+
+#ifdef STDCVT
+static
+Bool MBtoWCstd(
+ State state,
+ const char *ch,
+ wchar_t *wc)
+{
+ return (mbtowc(wc, ch, 1) == 1);
+}
+#endif
+
+static
+Bool WCtoMBdef(
+ State state,
+ wchar_t wc,
+ char *ch)
+{
+ wchar_t wc_encoding = wc & state->wc_encode_mask;
+ CodeSet codeset;
+
+ codeset = state->GL_codeset;
+ if (codeset && (wc_encoding == codeset->wc_encoding)) {
+ *ch = wc & state->wc_mask;
+ return True;
+ }
+ codeset = state->GR_codeset;
+ if (codeset && (wc_encoding == codeset->wc_encoding)) {
+ *ch = (wc & state->wc_mask) | GR;
+ return True;
+ }
+ return False;
+}
+
+#ifdef STDCVT
+static
+Bool WCtoMBstd(
+ State state,
+ wchar_t wc,
+ char *ch)
+{
+ return (wctomb(ch, wc) == 1);
+}
+#endif
+
+static
+XlcCharSet get_charset(
+ State state,
+ char side)
+{
+ CodeSet codeset = side ? state->GR_codeset : state->GL_codeset;
+ if (codeset) {
+ int i;
+ XlcCharSet charset;
+ for (i = 0; i < codeset->num_charsets; i++) {
+ charset = codeset->charset_list[i];
+ if (*charset->ct_sequence != '\0')
+ return charset;
+ }
+ return *(codeset->charset_list);
+ }
+ return (XlcCharSet) NULL;
+}
+
+static int
+def_mbstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const char *src = (const char *) *from;
+ wchar_t *dst = (wchar_t *) * to;
+ State state = (State) conv->state;
+ int unconv = 0;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ while (*from_left && *to_left) {
+ (*from_left)--;
+ if (state->MBtoWC (state, src++, dst)) {
+ dst++;
+ (*to_left)--;
+ } else {
+ unconv++;
+ }
+ }
+ *from = (XPointer) src;
+ *to = (XPointer) dst;
+ return unconv;
+}
+
+static int
+def_wcstombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const wchar_t *src = (const wchar_t *) * from;
+ char *dst = (char *) *to;
+ State state = (State) conv->state;
+ char ch[MB_LEN_MAX];
+ int unconv = 0;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ while (*from_left && *to_left) {
+ (*from_left)--;
+ if (state->WCtoMB (state, *src++, ch)) {
+ *dst++ = *ch;
+ (*to_left)--;
+ } else {
+ unconv++;
+ }
+ }
+ *from = (XPointer) src;
+ *to = (XPointer) dst;
+ return unconv;
+}
+
+static int
+mbstostr(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const char *src = (const char *) *from;
+ char *dst = (char *) *to;
+ CodeSet codeset;
+ State state = (State) conv->state;
+ char ch;
+ int unconv = 0;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ while (*from_left && *to_left) {
+ ch = *src++;
+ (*from_left)--;
+
+ codeset = (ch & GR) ? state->GR_codeset : state->GL_codeset;
+ if (codeset && codeset->string_encoding) {
+ *dst++ = ch;
+ (*to_left)--;
+ } else {
+ unconv++;
+ }
+ }
+ *from = (XPointer) src;
+ *to = (XPointer) dst;
+ return unconv;
+}
+
+static int
+wcstostr(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const wchar_t *src = (const wchar_t *) *from;
+ char *dst = (char *) *to;
+ CodeSet codeset;
+ State state = (State) conv->state;
+ char ch[MB_LEN_MAX];
+ int unconv = 0;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ while (*from_left && *to_left) {
+ (*from_left)--;
+ if (state->WCtoMB (state, *src++, ch)) {
+ codeset = (*ch & GR) ? state->GR_codeset : state->GL_codeset;
+ if (codeset && codeset->string_encoding) {
+ *dst++ = *ch;
+ (*to_left)--;
+ } else {
+ unconv++;
+ }
+ } else {
+ unconv++;
+ }
+ }
+ *from = (XPointer) src;
+ *to = (XPointer) dst;
+ return unconv;
+}
+
+static int
+mbstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const char *src = (const char *) *from;
+ char *dst = (char *) *to;
+ int length;
+ State state = (State) conv->state;
+ char cur_side;
+ int unconv = 0;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ length = min(*from_left, *to_left);
+
+ cur_side = *src & GR;
+ while (length) {
+ if ((char) (*src & GR) != cur_side)
+ break;
+ *dst++ = *src++;
+ length--;
+ }
+
+ if (num_args > 0) {
+ XlcCharSet charset = get_charset(state, cur_side);
+ if (charset) {
+ *((XlcCharSet *) args[0]) = charset;
+ } else {
+ dst = *to;
+ unconv = -1;
+ }
+ }
+ *from_left -= src - (char *) *from;
+ *to_left -= dst - (char *) *to;
+ *from = (XPointer) src;
+ *to = (XPointer) dst;
+ return unconv;
+}
+
+static int
+wcstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const wchar_t *src = (const wchar_t *) * from;
+ char *dst = (char *) *to;
+ State state = (State) conv->state;
+ char cur_side = 0, ch[MB_LEN_MAX];
+ int unconv = 0;
+ Bool found = False;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ while (*from_left) {
+ if ((found = state->WCtoMB (state, *src, ch)))
+ break;
+ unconv++;
+ src++;
+ (*from_left)--;
+ }
+
+ if (found) {
+ cur_side = *ch & GR;
+ while (*from_left && *to_left) {
+ (*from_left)--;
+ if (state->WCtoMB (state, *src++, ch)) {
+ if ((char) (*ch & GR) != cur_side) {
+ src--;
+ (*from_left)++;
+ break;
+ } else {
+ *dst++ = *ch;
+ (*to_left)--;
+ }
+ } else {
+ unconv++;
+ }
+ }
+ } else {
+ unconv++;
+ }
+
+ if (num_args > 0) {
+ XlcCharSet charset = get_charset(state, cur_side);
+ if (charset) {
+ *((XlcCharSet *) args[0]) = charset;
+ } else {
+ unconv = -1;
+ }
+ }
+ *from = (XPointer) src;
+ *to = (XPointer) dst;
+ return unconv;
+}
+
+static int
+cstombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const char *src = (const char *) *from;
+ char *dst = (char *) *to;
+ CodeSet codeset;
+ XlcCharSet charset;
+ State state = (State) conv->state;
+ unsigned char cur_side = 0;
+ int i;
+ Bool found = False;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ if (num_args > 0) {
+ charset = (XlcCharSet) args[0];
+ if (charset == NULL)
+ return -1;
+ } else {
+ return -1;
+ }
+
+ if ((charset->side == XlcGL) || (charset->side == XlcGLGR)) {
+ codeset = state->GL_codeset;
+ if (codeset) {
+ for (i = 0; i < codeset->num_charsets; i++)
+ if (charset == codeset->charset_list[i]) {
+ found = True;
+ cur_side = 0;
+ break;
+ }
+ }
+ }
+ if (!found && ((charset->side == XlcGR) || (charset->side == XlcGLGR))) {
+ codeset = state->GR_codeset;
+ if (codeset) {
+ for (i = 0; i < codeset->num_charsets; i++)
+ if (charset == codeset->charset_list[i]) {
+ found = True;
+ cur_side = GR;
+ break;
+ }
+ }
+ }
+ if (found) {
+ int length = min(*from_left, *to_left);
+ while (length) {
+ *dst++ = *src++ | cur_side;
+ length--;
+ }
+ } else {
+ return -1;
+ }
+
+ *from_left -= src - (char *) *from;
+ *to_left -= dst - (char *) *to;
+ *from = (XPointer) src;
+ *to = (XPointer) dst;
+ return 0;
+}
+
+static int
+cstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const char *src = (const char *) *from;
+ wchar_t *dst = (wchar_t *) * to;
+ CodeSet codeset;
+ XlcCharSet charset;
+ State state = (State) conv->state;
+ Bool found = False;
+ int i, unconv = 0;
+ unsigned char cur_side = 0;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ if (num_args > 0) {
+ charset = (XlcCharSet) args[0];
+ if (charset == NULL)
+ return -1;
+ } else {
+ return -1;
+ }
+
+ if ((charset->side == XlcGL) || (charset->side == XlcGLGR)) {
+ codeset = state->GL_codeset;
+ if (codeset) {
+ for (i = 0; i < codeset->num_charsets; i++)
+ if (charset == codeset->charset_list[i]) {
+ found = True;
+ cur_side = 0;
+ break;
+ }
+ }
+ }
+ if (!found && ((charset->side == XlcGR) || (charset->side == XlcGLGR))) {
+ codeset = state->GR_codeset;
+ if (codeset) {
+ for (i = 0; i < codeset->num_charsets; i++)
+ if (charset == codeset->charset_list[i]) {
+ found = True;
+ cur_side = GR;
+ break;
+ }
+ }
+ }
+ if (found) {
+ char ch;
+ while (*from_left && *to_left) {
+ ch = *src++ | cur_side;
+ (*from_left)--;
+ if (state->MBtoWC (state, &ch, dst)) {
+ dst++;
+ (*to_left)--;
+ } else {
+ unconv++;
+ }
+ }
+ } else {
+ return -1;
+ }
+ *from = (XPointer) src;
+ *to = (XPointer) dst;
+ return unconv;
+}
+
+static int
+strtombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const char *src = (const char *) *from;
+ char *dst = (char *) *to;
+ int length;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ length = min(*from_left, *to_left);
+ while (length) {
+ *dst++ = *src++;
+ length--;
+ }
+
+ *from_left -= src - (char *) *from;
+ *to_left -= dst - (char *) *to;
+ *from = (XPointer) src;
+ *to = (XPointer) dst;
+ return 0;
+}
+
+static void
+close_converter(
+ XlcConv conv)
+{
+ if (conv->state)
+ Xfree((char *) conv->state);
+
+ Xfree((char *) conv);
+}
+
+static XlcConv
+create_conv(
+ XLCd lcd,
+ XlcConvMethods methods)
+{
+ XlcConv conv;
+ State state;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (conv == NULL)
+ return (XlcConv) NULL;
+
+ state = (State) Xmalloc(sizeof(StateRec));
+ if (state == NULL) {
+ close_converter(conv);
+ return (XlcConv) NULL;
+ }
+ state->GL_codeset = XLC_GENERIC(lcd, initial_state_GL);
+ state->GR_codeset = XLC_GENERIC(lcd, initial_state_GR);
+ state->wc_mask = (1 << XLC_GENERIC(lcd, wc_shift_bits)) - 1;
+ state->wc_encode_mask = XLC_GENERIC(lcd, wc_encode_mask);
+
+#ifdef STDCVT
+ if (XLC_GENERIC(lcd, use_stdc_env) == True)
+ state->MBtoWC = &MBtoWCstd;
+ else
+#endif
+ state->MBtoWC = &MBtoWCdef;
+
+#ifdef STDCVT
+ if (XLC_GENERIC(lcd, use_stdc_env) == True)
+ state->WCtoMB = &WCtoMBstd;
+ else
+#endif
+ state->WCtoMB = &WCtoMBdef;
+
+ conv->methods = methods;
+ conv->state = (XPointer) state;
+
+ return conv;
+}
+
+static XlcConvMethodsRec mbstowcs_methods = {
+ close_converter,
+ def_mbstowcs,
+ NULL
+};
+
+static XlcConv
+open_mbstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &mbstowcs_methods);
+}
+
+static XlcConvMethodsRec mbstostr_methods = {
+ close_converter,
+ mbstostr,
+ NULL
+};
+
+static XlcConv
+open_mbstostr(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &mbstostr_methods);
+}
+
+static XlcConvMethodsRec mbstocs_methods = {
+ close_converter,
+ mbstocs,
+ NULL
+};
+
+static XlcConv
+open_mbstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &mbstocs_methods);
+}
+
+static XlcConvMethodsRec wcstombs_methods = {
+ close_converter,
+ def_wcstombs,
+ NULL
+};
+
+static XlcConv
+open_wcstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &wcstombs_methods);
+}
+
+static XlcConvMethodsRec wcstostr_methods = {
+ close_converter,
+ wcstostr,
+ NULL
+};
+
+static XlcConv
+open_wcstostr(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &wcstostr_methods);
+}
+
+static XlcConvMethodsRec wcstocs_methods = {
+ close_converter,
+ wcstocs,
+ NULL
+};
+
+static XlcConv
+open_wcstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &wcstocs_methods);
+}
+
+static XlcConvMethodsRec strtombs_methods = {
+ close_converter,
+ strtombs,
+ NULL
+};
+
+static XlcConv
+open_strtombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &strtombs_methods);
+}
+
+static XlcConvMethodsRec cstombs_methods = {
+ close_converter,
+ cstombs,
+ NULL
+};
+
+static XlcConv
+open_cstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &cstombs_methods);
+}
+
+static XlcConvMethodsRec cstowcs_methods = {
+ close_converter,
+ cstowcs,
+ NULL
+};
+
+static XlcConv
+open_cstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &cstowcs_methods);
+}
+
+XLCd
+_XlcDefaultLoader(
+ const char *name)
+{
+ XLCd lcd;
+
+ lcd = _XlcCreateLC(name, _XlcGenericMethods);
+ if (lcd == NULL)
+ return lcd;
+
+ if (XLC_PUBLIC(lcd, mb_cur_max) != 1){
+ _XlcDestroyLC(lcd);
+ return (XLCd) NULL;
+ }
+
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_mbstowcs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNString, open_mbstostr);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbstocs);
+
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstombs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_wcstostr);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
+
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_strtombs);
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_mbstowcs);
+
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
+
+ _XlcAddUtf8Converters(lcd);
+
+ return lcd;
+}
diff --git a/nx-X11/lib/X11/lcDynamic.c b/nx-X11/lib/X11/lcDynamic.c
new file mode 100644
index 000000000..5d359ed74
--- /dev/null
+++ b/nx-X11/lib/X11/lcDynamic.c
@@ -0,0 +1,80 @@
+/* $Xorg: lcDynamic.c,v 1.4 2001/02/09 02:03:39 xorgcvs Exp $ */
+/*
+Copyright 1996, 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 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+/* $XFree86: xc/lib/X11/lcDynamic.c,v 1.4 2001/01/17 19:41:53 dawes Exp $ */
+
+/*
+ * A dynamically loaded locale.
+ * Supports: All locale names.
+ * How: Loads $(XLOCALEDIR)/xi18n.so and forwards the request to that library.
+ * Platforms: Only those defining USE_DYNAMIC_LOADER (none known).
+ */
+
+#ifdef USE_DYNAMIC_LOADER
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+#ifndef XLOCALEDIR
+#define XLOCALEDIR "/usr/lib/X11/locale"
+#endif
+
+#define LCLIBNAME "xi18n.so"
+
+XLCd
+_XlcDynamicLoader(
+ const char *name)
+{
+ char libpath[1024];
+ XLCdMethods _XlcGenericMethods;
+ XLCd lcd;
+ void *nlshandler;
+
+ sprintf(libpath,"%s/%s/%s",
+ XLOCALEDIR,name,LCLIBNAME);
+ nlshandler = dlopen(libpath,LAZY);
+ _XlcGenericMethods = (XLCdMethods)dlsym(nlshandler,"genericMethods");
+ lcd = _XlcCreateLC(name,_XlcGenericMethods);
+
+ return lcd;
+}
+#else
+typedef int dummy;
+#endif /* USE_DYNAMIC_LOADER */
diff --git a/nx-X11/lib/X11/lcEuc.c b/nx-X11/lib/X11/lcEuc.c
new file mode 100644
index 000000000..1b54508be
--- /dev/null
+++ b/nx-X11/lib/X11/lcEuc.c
@@ -0,0 +1,1539 @@
+/* $Xorg: lcEuc.c,v 1.3 2000/08/17 19:45:17 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993 by FUJITSU LIMITED
+ Copyright 1993 by Fujitsu Open Systems Solutions, Inc.
+
+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 of FUJITSU LIMITED and
+Fujitsu Open Systems Solutions, Inc. not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+written prior permission.
+FUJITSU LIMITED and Fujitsu Open Systems Solutions, Inc. makes no
+representations about the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED AND FUJITSU OPEN SYSTEMS SOLUTIONS, INC. DISCLAIMS ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU OPEN SYSTEMS
+SOLUTIONS, INC. AND FUJITSU LIMITED 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.
+
+ Authors: Shigeru Yamada (yamada@ossi.com)
+ Jeffrey Bloomfield (jeffb@ossi.com)
+ Yoshiyuki Segawa (segawa@ossi.com)
+
+*****************************************************************/
+/* $XFree86: xc/lib/X11/lcEuc.c,v 3.12 2003/01/20 04:05:30 dawes Exp $ */
+
+/*
+ * An EUC locale.
+ * Supports: all locales with codeset eucJP, eucKR, eucCN, eucTW.
+ * How: Provides converters for euc*.
+ * Platforms: Only those defining X_LOCALE (only Lynx, Linux-libc5, OS/2).
+ */
+
+#ifdef X_LOCALE
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcGeneric.h"
+
+#include <ctype.h>
+#ifdef WIN32
+#define isascii __isascii
+#endif
+
+#define CS0 codesets[0] /* Codeset 0 - 7-bit ASCII */
+#define CS1 codesets[1] /* Codeset 1 - Kanji */
+#define CS2 codesets[2] /* Codeset 2 - Half-Kana */
+#define CS3 codesets[3] /* Codeset 3 - User defined */
+
+#define SS2 0x8e /* Single-shift char: CS2 */
+#define SS3 0x8f /* Single-shift char: CS3 */
+
+#define ASCII_CODESET 0
+#define KANJI_CODESET 1
+#define KANA_CODESET 2
+#define USERDEF_CODESET 3
+#define MAX_CODESETS
+
+#define GR 0x80 /* begins right-side (non-ascii) region */
+#define GL 0x7f /* ends left-side (ascii) region */
+
+#define isleftside(c) (((c) & GR) ? 0 : 1)
+#define isrightside(c) (!isleftside(c))
+
+#define BIT8OFF(c) ((c) & GL)
+#define BIT8ON(c) ((c) | GR)
+
+typedef unsigned char Uchar;
+typedef unsigned long Ulong;
+typedef unsigned int Uint;
+
+static CodeSet GetCodeSetFromCharSet (XLCd lcd, XlcCharSet charset);
+static CodeSet wc_codeset (XLCd lcd, wchar_t wch);
+
+#define BADCHAR(min_ch, c) (BIT8OFF(c) < (char)min_ch && BIT8OFF(c) != 0x0 && \
+ BIT8OFF(c) != '\t' && BIT8OFF(c) != '\n' && \
+ BIT8OFF(c) != 0x1b)
+
+/*
+ * Notes:
+ * 1. Defining FORCE_INDIRECT_CONVERTER (see _XlcEucLoader())
+ * forces indirect (charset) conversions (e.g. wcstocs()<->cstombs()).
+ * 2. Using direct converters (e.g. mbstowcs()) decreases conversion
+ * times by 20-40% (depends on specific converter used).
+ */
+
+static int
+euc_mbstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XLCd lcd = (XLCd)conv->state;
+
+ Uchar ch;
+ int chr_len = 0;
+ int sshift = False;
+ int shift_mult = 0;
+ Uint chrcode;
+
+ Uint wc_encode = 0;
+ Uint wc_tmp = 0;
+
+ int cs0flg = False;
+ int cs1flg = False;
+ int length = 0;
+ int unconv_num = 0;
+
+ Bool new_char;
+
+ const char *inbufptr = *from;
+ wchar_t *outbufptr = (wchar_t *) *to;
+
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
+
+ for (new_char = True; *from_left > 0 && *to_left > 0;) {
+
+ ch = *inbufptr++;
+
+ if (isleftside(ch)) { /* CS0 */
+ if (ASCII_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ if( cs0flg == True) {
+ new_char = True;
+ cs0flg = False;
+ }
+ length = CS0->length;
+ *outbufptr++ = (wchar_t)ch;
+ (*from_left)--;
+ (*to_left)--;
+ continue;
+ }
+ else if (ch == SS2) { /* CS2 */
+ if (KANA_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ if (sshift == True || cs1flg == True) {
+ cs1flg = False;
+ unconv_num++;
+ continue;
+ }
+ length = CS2->length;
+ wc_encode = CS2->wc_encoding;
+ chrcode = 0;
+ sshift = True;
+ cs0flg = True;
+ (*from_left)--;
+ continue;
+ }
+ else if (ch == SS3) { /* CS3 */
+ if (USERDEF_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ if (sshift == True || cs1flg == True) {
+ cs1flg = False;
+ unconv_num++;
+ continue;
+ }
+ length = CS3->length;
+ if (*from_left < 1 )
+ unconv_num++;
+ wc_encode = CS3->wc_encoding;
+ chrcode = 0;
+ sshift = True;
+ cs0flg = True;
+ (*from_left)--;
+ continue;
+
+ } else { /* CS1 */
+ if (KANJI_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ if (sshift == False) {
+ length = CS1->length;
+ if (*from_left < 1)
+ unconv_num++;
+ wc_encode = CS1->wc_encoding;
+ }
+ chrcode = BIT8OFF(ch);
+ cs0flg = True;
+ cs1flg = True;
+ (*from_left)--;
+ }
+
+ if (new_char) { /* begin new character */
+ chr_len = length;
+ shift_mult = length - 1;
+ new_char = False;
+ }
+
+ chrcode <<= (wc_shift * shift_mult);
+ shift_mult--;
+ wc_tmp |= chrcode;
+
+ if (--chr_len == 0) {
+ wc_tmp |= wc_encode;
+ *outbufptr++ = wc_tmp;
+ (*to_left)--;
+
+ new_char = True;
+ sshift = False;
+ cs0flg = False;
+ cs1flg = False;
+ wc_tmp = (Uint)0;
+ }
+
+ } /* end for */
+
+ *to = (XPointer)outbufptr;
+
+ if (cs0flg == True || cs1flg == True) /* error check on last char */
+ unconv_num++;
+
+ return unconv_num;
+}
+
+
+static int
+euc_wcstombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const wchar_t *inbufptr = (const wchar_t *) *from;
+ XPointer outbufptr = *to;
+ wchar_t wch;
+ int length;
+ Uchar tmp;
+ int unconv_num = 0;
+
+ XLCd lcd = (XLCd)conv->state;
+ CodeSet codeset;
+ Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
+
+ for (; *from_left > 0 && *to_left > 0; (*from_left)-- ) {
+
+ wch = *inbufptr++;
+
+ if (!(codeset = wc_codeset(lcd, wch))) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+
+ length = codeset->length;
+ wch ^= (wchar_t)codeset->wc_encoding;
+
+ if (codeset->parse_info) { /* put out SS2 or SS3 */
+ if (*to_left < length + 1) {
+ unconv_num++;
+ break;
+ }
+ *outbufptr++ = *codeset->parse_info->encoding;
+ (*to_left)--;
+ } else {
+ if (*to_left < length) {
+ unconv_num++;
+ break;
+ }
+ }
+
+ do {
+ length--;
+ tmp = (wch>>(wchar_t)(length * wc_shift));
+
+ if (codeset->side == XlcGR)
+ tmp = BIT8ON(tmp);
+
+ *outbufptr++ = (Uchar)tmp;
+ (*to_left)--;
+ } while (length);
+ }
+
+ *to = (XPointer)outbufptr;
+
+ return unconv_num;
+}
+
+
+static int
+euc_mbtocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XLCd lcd = (XLCd)conv->state;
+ XlcCharSet charset;
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ int length;
+ int unconv_num = 0;
+ int min_ch = 0;
+ const char *src = *from;
+ char *dst = *to;
+
+ if (isleftside(*src)) { /* 7-bit (CS0) */
+ if (ASCII_CODESET >= codeset_num)
+ return -1;
+ charset = *CS0->charset_list;
+ }
+ else if ((Uchar)*src == SS2) { /* half-kana (CS2) */
+ if (KANA_CODESET >= codeset_num)
+ return -1;
+ charset = *CS2->charset_list;
+ src++;
+ (*from_left)--;
+ }
+ else if ((Uchar)*src == SS3) { /* user-def */
+ if (USERDEF_CODESET >= codeset_num)
+ return -1;
+ charset = *CS3->charset_list;
+ src++;
+ (*from_left)--;
+ }
+ else { /* Kanji (CS1) */
+ if (KANJI_CODESET >= codeset_num)
+ return -1;
+ charset = *CS1->charset_list;
+ }
+
+ if(*from_left < charset->char_size || *to_left < charset->char_size)
+ return -1;
+
+ min_ch = 0x20;
+ if (charset->set_size == 94)
+ if (charset->char_size > 1 || charset->side == XlcGR)
+ min_ch = 0x21;
+
+ length = charset->char_size;
+ do {
+ if(BADCHAR(min_ch, *src)) {
+ unconv_num++;
+ src++;
+ break;
+ }
+ switch (charset->side) {
+ case XlcGL:
+ *dst++ = BIT8OFF(*src++);
+ break;
+ case XlcGR:
+ *dst++ = BIT8ON(*src++);
+ break;
+ default:
+ *dst++ = *src++;
+ break;
+ }
+ } while (--length);
+
+ *to = dst;
+ *from = (XPointer) src;
+ *from_left -= charset->char_size;
+ *to_left -= charset->char_size - length;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return unconv_num;
+}
+
+
+static int
+euc_mbstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const char *tmp_from;
+ char *tmp_to;
+ int tmp_from_left, tmp_to_left;
+ XlcCharSet charset, tmp_charset;
+ XPointer tmp_args[1];
+ int unconv_num = 0, ret;
+
+/* Determine the charset of the segment and convert one characater: */
+
+ tmp_args[0] = (XPointer) &charset; /* charset from euc_mbtocs() */
+ while
+ ((ret = euc_mbtocs(conv, from, from_left, to, to_left, tmp_args, 1)) > 0)
+ unconv_num += ret;
+ if ( ret < 0 )
+ return ret;
+
+ tmp_from = *from;
+ tmp_from_left = *from_left;
+ tmp_to_left = *to_left;
+ tmp_to = *to;
+
+/* Convert remainder of the segment: */
+
+ tmp_args[0] = (XPointer) &tmp_charset;
+ while( (ret = euc_mbtocs(conv, (XPointer *) &tmp_from, &tmp_from_left,
+ (XPointer *) &tmp_to, &tmp_to_left, tmp_args, 1)) >= 0 ) {
+
+ if (ret > 0) {
+ unconv_num += ret;
+ continue;
+ }
+
+ if (tmp_charset != charset) /* quit on end of segment */
+ break;
+
+ *from = (XPointer) tmp_from;
+ *from_left = tmp_from_left;
+ *to = (XPointer) tmp_to;
+ *to_left = tmp_to_left;
+ }
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return unconv_num;
+}
+
+
+static int
+euc_wcstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XLCd lcd = (XLCd)conv->state;
+ const wchar_t *wcptr = (const wchar_t *) *from;
+ char *bufptr = (char *) *to;
+ wchar_t wch;
+ char *tmpptr;
+ int length;
+ CodeSet codeset;
+ Ulong wc_encoding;
+ int wcstr_len = *from_left, buf_len = *to_left;
+
+ if (!(codeset = wc_codeset(lcd, *wcptr)))
+ return -1;
+
+ wc_encoding = codeset->wc_encoding;
+
+ if (wcstr_len < buf_len / codeset->length)
+ buf_len = wcstr_len * codeset->length;
+
+ for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) {
+ wch = *wcptr;
+
+ if ((wch & XLC_GENERIC(lcd, wc_encode_mask)) != wc_encoding)
+ break;
+
+ length = codeset->length;
+
+ buf_len -= length;
+ bufptr += length;
+ tmpptr = bufptr - 1;
+
+ while (length--) {
+ *tmpptr-- = codeset->length == 1 && codeset->side == XlcGR ?
+ BIT8ON(wch) : BIT8OFF(wch);
+ wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
+ }
+ }
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = *codeset->charset_list;
+
+ *from_left -= wcptr - (wchar_t *) *from;
+ *from = (XPointer) wcptr;
+
+ *to_left -= bufptr - *to;
+ *to = bufptr;
+
+ return 0;
+}
+
+
+static int
+euc_cstombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XLCd lcd = (XLCd)conv->state;
+ const char *csptr = *from;
+ char *bufptr = *to;
+ int csstr_len = *from_left;
+ int buf_len = *to_left;
+ int length;
+ CodeSet codeset;
+ int cvt_length;
+
+ if (num_args < 1)
+ return -1;
+
+ if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0])))
+ return -1;
+
+ cvt_length = 0;
+ csstr_len /= codeset->length;
+ buf_len /= codeset->length;
+
+ if (codeset->parse_info)
+ csstr_len *= 2;
+
+ if (csstr_len < buf_len)
+ buf_len = csstr_len;
+
+ cvt_length += buf_len * codeset->length;
+
+ if (bufptr) {
+ while (buf_len--) {
+ if (codeset->parse_info) /* put out SS2 or SS3 */
+ *bufptr++ = *codeset->parse_info->encoding;
+
+ length = codeset->length;
+ while (length--)
+ *bufptr++ = codeset->side == XlcGR ?
+ BIT8ON(*csptr++) : BIT8OFF(*csptr++);
+ }
+ }
+
+ *from_left -= csptr - *from;
+ *from = (XPointer) csptr;
+ if (bufptr)
+ *to += cvt_length;
+ *to_left -= cvt_length;
+
+ return 0;
+}
+
+
+static int
+euc_cstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XLCd lcd = (XLCd)conv->state;
+ const char *csptr = *from;
+ wchar_t *bufptr = (wchar_t *) *to;
+ wchar_t *toptr = (wchar_t *) *to;
+ int csstr_len = *from_left;
+ int buf_len = *to_left;
+ wchar_t wch;
+ int length;
+ Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
+ CodeSet codeset;
+
+ if (num_args < 1)
+ return -1;
+
+ if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0])))
+ return -1;
+
+ csstr_len /= codeset->length;
+ if (csstr_len < buf_len)
+ buf_len = csstr_len;
+ *to_left -= buf_len;
+
+ if (bufptr) {
+
+ toptr += buf_len;
+ *to = (XPointer) toptr;
+
+ while (buf_len--) {
+
+ wch = (wchar_t) BIT8OFF(*csptr);
+ csptr++;
+
+ length = codeset->length - 1;
+ while (length--) {
+ wch = (wch << wc_shift_bits) | BIT8OFF(*csptr);
+ csptr++;
+ }
+ *bufptr++ = wch | codeset->wc_encoding;
+ }
+ }
+ *from_left -= csptr - *from;
+ *from = (XPointer) csptr;
+
+ return 0;
+}
+
+
+static CodeSet
+wc_codeset(
+ XLCd lcd,
+ wchar_t wch)
+{
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ int end = XLC_GENERIC(lcd, codeset_num);
+ Ulong widech = (Ulong)(wch & XLC_GENERIC(lcd, wc_encode_mask));
+
+ for (; --end >= 0; codesets++)
+ if ( widech == (*codesets)->wc_encoding )
+ return *codesets;
+
+ return NULL;
+}
+
+
+static CodeSet
+GetCodeSetFromCharSet(
+ XLCd lcd,
+ XlcCharSet charset)
+{
+ CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
+ XlcCharSet *charset_list;
+ int codeset_num, num_charsets;
+
+ codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+ for ( ; codeset_num-- > 0; codeset++) {
+ num_charsets = (*codeset)->num_charsets;
+ charset_list = (*codeset)->charset_list;
+
+ for ( ; num_charsets-- > 0; charset_list++)
+ if (*charset_list == charset)
+ return *codeset;
+ }
+
+ return (CodeSet) NULL;
+}
+
+
+static XlcConv
+create_conv(
+ XLCd lcd,
+ XlcConvMethods methods)
+{
+ XlcConv conv;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (conv == NULL)
+ return (XlcConv) NULL;
+
+ conv->methods = methods;
+ conv->state = (XPointer) lcd;
+ return conv;
+}
+
+
+/*
+ * Stripped down Direct CT converters for EUC
+ *
+ */
+
+typedef struct _CTDataRec {
+ int side;
+ int length;
+ char *name;
+ Ulong wc_encoding;
+ char sshift;
+ char *ct_encoding;
+ int ct_encoding_len;
+ int set_size;
+ Uchar min_ch;
+ Uchar ct_type;
+} CTDataRec, *CTData;
+
+typedef struct _StateRec {
+ CTData GL_charset;
+ CTData GR_charset;
+ CTData charset;
+} StateRec, *State;
+
+#define CT_STD 0
+#define CT_NSTD 1
+#define CT_DIR 2
+#define CT_EXT0 3
+#define CT_EXT1 4
+#define CT_EXT2 5
+#define CT_VER 6
+
+static CTDataRec ctdata[] =
+{
+ { XlcGL, 1, "ISO8859-1:GL", 0, 0, "\033(B" , 3, 0, 0, CT_STD },
+ { XlcGR, 1, "ISO8859-1:GR", 0, 0, "\033-A" , 3, 0, 0, CT_STD },
+ { XlcGL, 1, "JISX0201.1976-0:GL", 0, 0, "\033(J" , 3, 0, 0, CT_STD },
+ { XlcGR, 1, "JISX0201.1976-0:GR", 0, 0, "\033)I" , 3, 0, 0, CT_STD },
+ { XlcGL, 2, "JISX0208.1983-0:GL", 0, 0, "\033$(B" , 4, 0, 0, CT_STD },
+ { XlcGR, 2, "JISX0208.1983-0:GR", 0, 0, "\033$)B" , 4, 0, 0, CT_STD },
+ { XlcGL, 2, "JISX0212.1990-0:GL", 0, 0, "\033$(D" , 4, 0, 0, CT_STD },
+ { XlcGR, 2, "JISX0212.1990-0:GR", 0, 0, "\033$)D" , 4, 0, 0, CT_STD },
+ { XlcUnknown, 0, "Ignore-Ext-Status?", 0, 0, "\033#" , 2, 0, 0, CT_VER },
+ { XlcUnknown, 0, "NonStd-?-OctetChar", 0, 0, "\033%/0" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 1, "NonStd-1-OctetChar", 0, 0, "\033%/1" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 2, "NonStd-2-OctetChar", 0, 0, "\033%/2" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 3, "NonStd-3-OctetChar", 0, 0, "\033%/3" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 4, "NonStd-4-OctetChar", 0, 0, "\033%/4" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 0, "Extension-2" , 0, 0, "\033%/" , 3, 0, 0, CT_EXT2 },
+ { XlcUnknown, 0, "Extension-0" , 0, 0, "\033" , 1, 0, 0, CT_EXT0 },
+ { XlcUnknown, 0, "Begin-L-to-R-Text", 0, 0, "\2331]" , 3, 0, 0, CT_DIR },
+ { XlcUnknown, 0, "Begin-R-to-L-Text", 0, 0, "\2332]" , 3, 0, 0, CT_DIR },
+ { XlcUnknown, 0, "End-Of-String", 0, 0, "\233]" , 2, 0, 0, CT_DIR },
+ { XlcUnknown, 0, "Extension-1" , 0, 0, "\233" , 1, 0, 0, CT_EXT1 },
+};
+
+/* Note on above table: euc_ctstombs() and euc_ctstowcs() parser depends on
+ * certain table entries occuring in decreasing string length--
+ * 1. CT_EXT2 and CT_EXT0 entries must occur after CT_NSTD entries.
+ * 2. CT_DIR and CT_EXT1 entries must occur after CT_DIR entries.
+ */
+
+static CTData ctd_endp = ctdata + ((sizeof(ctdata) / sizeof(CTDataRec))) - 1;
+static CTData ctdptr[sizeof(ctdata) / sizeof(CTDataRec)];
+
+#define Ascii 0
+#define Kanji 1
+#define Kana 2
+#define Userdef 3
+
+/*
+ * initCTptr(): Set ctdptr[] to point at ctdata[], indexed by codeset_num.
+ */
+static void
+initCTptr(
+ XLCd lcd)
+{
+ int num_codesets = XLC_GENERIC(lcd, codeset_num);
+ int num_charsets;
+ int i, j;
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ CodeSet codeset;
+ XlcCharSet charset;
+ CTData ctdp = ctdata;
+
+ ctdptr[Ascii] = &ctdata[0]; /* failsafe */
+
+ for (i = 0; i < num_codesets; i++) {
+
+ codeset = codesets[i];
+ num_charsets = codeset->num_charsets;
+
+ for (j = 0; j < num_charsets; j++) {
+
+ charset = codeset->charset_list[j];
+
+ for (ctdp = ctdata; ctdp <= ctd_endp; ctdp++)
+
+ if (! strcmp(ctdp->name, charset->name)) {
+
+ ctdptr[codeset->cs_num] = ctdp;
+
+ ctdptr[codeset->cs_num]->wc_encoding = codeset->wc_encoding;
+
+ ctdptr[codeset->cs_num]->set_size =
+ charset->set_size;
+
+ ctdptr[codeset->cs_num]->min_ch =
+ charset->set_size == 94 &&
+ (ctdptr[codeset->cs_num]->length > 1 ||
+ ctdptr[codeset->cs_num]->side == XlcGR) ? 0x21 : 0x20;
+
+ if (codeset->parse_info) {
+ ctdptr[codeset->cs_num]->sshift =
+ *codeset->parse_info->encoding;
+ }
+
+ break;
+ }
+ }
+ }
+}
+
+
+#define SKIP_I(str) while (*(str) >= 0x20 && *(str) <= 0x2f) (str)++;
+#define SKIP_P(str) while (*(str) >= 0x30 && *(str) <= 0x3f) (str)++;
+
+static int
+euc_ctstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XLCd lcd = (XLCd)conv->state;
+ Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
+ const char *inbufptr = *from;
+ const char *inbuf_base;
+ wchar_t *outbufptr = (wchar_t *) *to;
+ wchar_t *outbuf_base = outbufptr;
+ int clen, length;
+ int unconv_num = 0;
+ unsigned int ct_seglen = 0;
+ Uchar ct_type = 0;
+ int shift_mult;
+ wchar_t wc_tmp;
+ wchar_t wch;
+ Ulong wc_encoding;
+ CTData ctdp = ctdata;
+ CTData GL_ctdp = ctdp; /* GL ctdp save */
+ CTData GR_ctdp = ctdp; /* GR ctdp save */
+ Bool save_outbuf = True;
+ /* If outbufptr is NULL, doen't save output, but just counts
+ a length to hold the output */
+ if (outbufptr == NULL) save_outbuf = False;
+
+ for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length)
+ {
+ ct_type = CT_STD;
+ /* change GL/GR charset */
+ if(ctdp->side == XlcGR && isleftside(*inbufptr)){
+ /* select GL side */
+ ctdp = GL_ctdp;
+ length = ctdp->length;
+ ct_type = ctdp->ct_type;
+ }else if(ctdp->side == XlcGL && isrightside(*inbufptr)){
+ /* select GR side */
+ ctdp = GR_ctdp;
+ length = ctdp->length;
+ ct_type = ctdp->ct_type;
+ }
+ if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
+ for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
+
+ if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len))
+ {
+ inbufptr += ctdp->ct_encoding_len;
+ (*from_left) -= ctdp->ct_encoding_len;
+ if (ctdp->length) {
+ length = ctdp->length;
+ if( *from_left < length ) {
+ *to = (XPointer)outbufptr;
+ *to_left -= outbufptr - outbuf_base;
+ return( unconv_num + *from_left );
+ }
+ }
+ ct_type = ctdp->ct_type;
+ if(ctdp->side == XlcGL){
+ GL_ctdp = ctdp; /* save GL ctdp */
+ }else{
+ GR_ctdp = ctdp; /* save GR ctdp */
+ }
+ break;
+ }
+ }
+ if (ctdp > ctd_endp) /* failed to match CT sequence */
+ unconv_num++;
+ }
+
+/* The following code insures that non-standard encodings, direction, extension,
+ * and version strings are ignored; subject to change in future.
+ */
+ switch (ct_type) {
+ case CT_STD:
+ break;
+ case CT_EXT2:
+ inbufptr++;
+ (*from_left)--;
+ case CT_NSTD:
+ ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2;
+ inbufptr += ct_seglen;
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_EXT0:
+ inbuf_base = inbufptr;
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ *(from_left) -= ct_seglen;
+ continue;
+ case CT_EXT1:
+ inbuf_base = inbufptr;
+ SKIP_P(inbufptr);
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ *(from_left) -= ct_seglen;
+ continue;
+ case CT_DIR:
+ continue;
+ case CT_VER:
+ inbufptr += 2;
+ *(from_left) -= 2;
+ continue;
+ }
+
+ wc_encoding = (ctdp == ctdptr[Kana] && isleftside(*inbufptr)) ?
+ ctdptr[Ascii]->wc_encoding: ctdp->wc_encoding;
+
+ shift_mult = length - 1;
+ wch = (wchar_t)0;
+ clen = length;
+
+ do {
+ wc_tmp = BIT8OFF(*inbufptr++) << (wc_shift_bits * shift_mult);
+ wch |= wc_tmp;
+ shift_mult--;
+ } while (--clen);
+
+ if (save_outbuf == True)
+ *outbufptr++ = wch | wc_encoding;
+ if (--*to_left == 0 && *from_left != length) {
+ *to = (XPointer)outbufptr;
+ unconv_num = *from_left;
+ return unconv_num;
+ }
+ }
+
+ *to = (XPointer)outbufptr;
+
+ return unconv_num;
+
+}
+
+
+#define byte1 (length == codeset->length - 1)
+#define byte2 (byte1 == 0)
+#define kanji (codeset->cs_num == 1)
+#define kana (codeset->cs_num == 2)
+#define userdef (codeset->cs_num == 3)
+
+static int
+euc_wcstocts(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ int ct_len = *to_left;
+ const wchar_t *inbufptr = (const wchar_t *) *from;
+ char *ctptr = *to;
+ XPointer ct_base = ctptr;
+ wchar_t wch;
+ int length;
+ int unconv_num = 0;
+ Uchar tmp;
+ Uchar t1 = 0;
+ int num_conv;
+
+ StateRec ct_state;
+ XLCd lcd = (XLCd)conv->state;
+ CTData charset;
+ CodeSet codeset;
+ Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
+
+/* Initial State: */
+ ct_state.GL_charset = ctdptr[0]; /* Codeset 0 */
+ ct_state.GR_charset = NULL;
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (; *from_left > 0 ; (*from_left)-- ) {
+
+ wch = *inbufptr++;
+
+ if (!(codeset = wc_codeset(lcd, wch))) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+
+ charset = ctdptr[codeset->cs_num];
+
+ length = codeset->length;
+ wch ^= (wchar_t)codeset->wc_encoding;
+
+ if ( (charset->side == XlcGR && charset != ct_state.GR_charset) ||
+ (charset->side == XlcGL && charset != ct_state.GL_charset) ) {
+
+ ct_len -= ctdptr[codeset->cs_num]->ct_encoding_len;
+
+ if (ct_len < 0) {
+ unconv_num++;
+ break;
+ }
+
+ if (ctptr) {
+ strcpy(ctptr, ctdptr[codeset->cs_num]->ct_encoding);
+ ctptr += ctdptr[codeset->cs_num]->ct_encoding_len;
+ }
+ }
+
+ if (charset->side == XlcGR) {
+ ct_state.GR_charset = charset;
+ ct_state.GL_charset = NULL;
+ } else if (charset->side == XlcGL) {
+ ct_state.GL_charset = charset;
+ ct_state.GR_charset = NULL;
+ }
+
+ do {
+
+ length--;
+ tmp = wch>>(wchar_t)( (Ulong)length * wc_shift);
+
+ if (kana) {
+ if (BADCHAR(charset->min_ch, (char)tmp)) {
+ unconv_num++;
+ break;
+ }
+ *ctptr++ = (char)BIT8ON(tmp);
+ }
+
+ else if (byte1 && (kanji || userdef))
+ t1 = tmp;
+
+ else if (byte2 && (kanji || userdef)) {
+ if (BADCHAR(charset->min_ch, (char)t1) ||
+ BADCHAR(charset->min_ch, (char)tmp)) {
+ unconv_num++;
+ break;
+ }
+ if (charset->side == XlcGR) {
+ *ctptr++ = (char)BIT8ON(t1);
+ *ctptr++ = (char)BIT8ON(tmp);
+ } else {
+ *ctptr++ = (char)BIT8OFF(t1);
+ *ctptr++ = (char)BIT8OFF(tmp);
+ }
+ }
+
+ else {
+ if (BADCHAR(charset->min_ch, (char)tmp)) {
+ unconv_num++;
+ break;
+ }
+ *ctptr++ = (char)tmp;
+ }
+
+
+ } while (length);
+
+ } /* end for */
+
+ *to = (XPointer)ctptr;
+
+ if ((num_conv = (int)(ctptr - ct_base)) > 0)
+ (*to_left) -= num_conv;
+
+ return unconv_num;
+}
+#undef byte1
+#undef byte2
+#undef kana
+#undef kanji
+#undef userdef
+
+
+#define byte1 (ctdp->length == clen)
+#define kana (ctdp == ctdptr[Kana] && isrightside(*inbufptr))
+/* #define kanji (ctdp == ctdptr[Kanji]) */
+#define kanji (strstr(ctdp->name, "JISX0208"))
+#define userdef (ctdp == ctdptr[Userdef])
+
+static int
+euc_ctstombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ char *inbufptr = *from;
+ XPointer outbufptr = *to;
+ const char *inbuf_base;
+ XPointer outbuf_base = outbufptr;
+ int clen, length;
+ int unconv_num = 0;
+ unsigned int ct_seglen = 0;
+ Uchar ct_type = 0;
+ CTData ctdp = &ctdata[0]; /* default */
+ CTData GL_ctdp = ctdp; /* GL ctdp save */
+ CTData GR_ctdp = ctdp; /* GR ctdp save */
+ Bool save_outbuf = True;
+ /* If outbufptr is NULL, doen't save output, but just counts
+ a length to hold the output */
+ if (outbufptr == NULL) save_outbuf = False;
+
+ for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length)
+ {
+ ct_type = CT_STD;
+ /* change GL/GR charset */
+ if(ctdp->side == XlcGR && isleftside(*inbufptr)){
+ /* select GL side */
+ ctdp = GL_ctdp;
+ length = ctdp->length;
+ ct_type = ctdp->ct_type;
+ }else if(ctdp->side == XlcGL && isrightside(*inbufptr)){
+ /* select GR side */
+ ctdp = GR_ctdp;
+ length = ctdp->length;
+ ct_type = ctdp->ct_type;
+ }
+ if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
+
+ for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
+
+ if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len))
+ {
+ inbufptr += ctdp->ct_encoding_len;
+ (*from_left) -= ctdp->ct_encoding_len;
+ if (ctdp->length) {
+ length = ctdp->length;
+ if( *from_left < length ) {
+ *to = (XPointer)outbufptr;
+ *to_left -= outbufptr - outbuf_base;
+ return( unconv_num + *from_left );
+ }
+ }
+ ct_type = ctdp->ct_type;
+ if(ctdp->side == XlcGL){
+ GL_ctdp = ctdp; /* save GL ctdp */
+ }else{
+ GR_ctdp = ctdp; /* save GR ctdp */
+ }
+ break;
+ }
+ }
+ if (ctdp > ctd_endp) /* failed to match CT sequence */
+ unconv_num++;
+ }
+
+/* The following code insures that non-standard encodings, direction, extension,
+ * and version strings are ignored; subject to change in future.
+ */
+ switch (ct_type) {
+ case CT_STD:
+ break;
+ case CT_EXT2:
+ inbufptr++;
+ (*from_left)--;
+ case CT_NSTD:
+ ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2;
+ inbufptr += ct_seglen;
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_EXT0:
+ inbuf_base = inbufptr;
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ *(from_left) -= ct_seglen;
+ continue;
+ case CT_EXT1:
+ inbuf_base = inbufptr;
+ SKIP_P(inbufptr);
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ *(from_left) -= ct_seglen;
+ continue;
+ case CT_DIR:
+ continue;
+ case CT_VER:
+ inbufptr += 2;
+ *(from_left) -= 2;
+ continue;
+ }
+
+ clen = length;
+ do {
+
+ if (byte1) {
+ if (kanji) {
+ /* FIXME: assignment of read-only location */
+ *inbufptr = BIT8ON(*inbufptr);
+ *(inbufptr+1) = BIT8ON(*(inbufptr+1));
+ }
+ else if (kana || userdef) {
+ if (save_outbuf == True) {
+ *outbufptr++ = ctdp->sshift;
+ }
+ (*to_left)--;
+ }
+ }
+ if (save_outbuf == True) {
+ *outbufptr++ = *inbufptr;
+ }
+ (*to_left)--;
+ inbufptr++;
+
+ if (*to_left == 0 && *from_left != length) {
+ *to = (XPointer)outbufptr;
+ unconv_num = *from_left;
+ return unconv_num;
+ }
+ } while (--clen);
+ }
+
+ *to = outbufptr;
+
+ return unconv_num;
+
+}
+#undef byte1
+#undef kana
+#undef kanji
+#undef userdef
+
+
+static int
+euc_mbstocts(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ int ct_len = *to_left;
+ int cs_num;
+ int clen, length = 0;
+ int unconv_num = 0;
+ int num_conv;
+ const char *inbufptr = *from;
+ char *ctptr = *to;
+ XPointer ct_base = ctptr;
+
+ StateRec ct_state;
+ CTData charset;
+ XLCd lcd = (XLCd) conv->state;
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+/* Initial State: */
+ ct_state.GL_charset = NULL;
+ ct_state.GR_charset = NULL;
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (;*from_left > 0; (*from_left) -= length) {
+
+ if (isleftside(*inbufptr)) { /* 7-bit (CS0) */
+ if (ASCII_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Ascii;
+ charset = ctdptr[Ascii];
+ }
+ else if ((Uchar)*inbufptr == SS2) { /* Kana */
+ if (KANA_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Kana;
+ charset = ctdptr[Kana];
+ inbufptr++;
+ (*from_left)--;
+ }
+ else if ((Uchar)*inbufptr == SS3) { /* Userdef */
+ if (USERDEF_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Userdef;
+ charset = ctdptr[Userdef];
+ inbufptr++;
+ (*from_left)--;
+ }
+ else {
+ if (KANJI_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Kanji;
+ charset = ctdptr[Kanji];
+ }
+
+ length = charset->length;
+
+ if (BADCHAR(charset->min_ch, *inbufptr))
+ continue;
+
+ if ( (charset->side == XlcGR && charset != ct_state.GR_charset) ||
+ (charset->side == XlcGL && charset != ct_state.GL_charset) ) {
+
+ ct_len -= ctdptr[cs_num]->ct_encoding_len;
+ if (ct_len < 0) {
+ unconv_num++;
+ break;
+ }
+
+ if (ctptr) {
+ strcpy(ctptr, ctdptr[cs_num]->ct_encoding);
+ ctptr += ctdptr[cs_num]->ct_encoding_len;
+ }
+ }
+
+ if (charset->side == XlcGR) {
+ ct_state.GR_charset = charset;
+ ct_state.GL_charset = NULL;
+ } else if (charset->side == XlcGL) {
+ ct_state.GL_charset = charset;
+ ct_state.GR_charset = NULL;
+ }
+
+ clen = length;
+
+ do {
+ *ctptr++ = charset == ct_state.GR_charset ?
+ BIT8ON(*inbufptr++) : BIT8OFF(*inbufptr++);
+ } while (--clen);
+ }
+
+ *to = (XPointer)ctptr;
+
+ if ((num_conv = (int)(ctptr - ct_base)) > 0)
+ (*to_left) -= num_conv;
+ return unconv_num;
+
+}
+
+
+static void
+close_converter(
+ XlcConv conv)
+{
+ Xfree((char *) conv);
+}
+
+enum { MBSTOCS, WCSTOCS, MBTOCS, CSTOMBS, CSTOWCS, MBSTOWCS, WCSTOMBS,
+ CTSTOWCS, CTSTOMBS, WCSTOCTS, MBSTOCTS };
+
+static XlcConvMethodsRec conv_methods[] = {
+ {close_converter, euc_mbstocs, NULL },
+ {close_converter, euc_wcstocs, NULL },
+ {close_converter, euc_mbtocs, NULL },
+ {close_converter, euc_cstombs, NULL },
+ {close_converter, euc_cstowcs, NULL },
+ {close_converter, euc_mbstowcs, NULL },
+ {close_converter, euc_wcstombs, NULL },
+ {close_converter, euc_ctstowcs, NULL },
+ {close_converter, euc_ctstombs, NULL },
+ {close_converter, euc_wcstocts, NULL },
+ {close_converter, euc_mbstocts, NULL },
+};
+
+
+static XlcConv
+open_mbstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[MBSTOCS]);
+}
+
+static XlcConv
+open_wcstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[WCSTOCS]);
+}
+
+static XlcConv
+open_mbtocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[MBTOCS]);
+}
+
+static XlcConv
+open_cstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[CSTOMBS]);
+}
+
+static XlcConv
+open_cstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[CSTOWCS]);
+}
+
+static XlcConv
+open_mbstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[MBSTOWCS]);
+}
+
+static XlcConv
+open_wcstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[WCSTOMBS]);
+}
+
+static XlcConv
+open_ctstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[CTSTOWCS]);
+}
+
+static XlcConv
+open_ctstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[CTSTOMBS]);
+}
+
+static XlcConv
+open_wcstocts(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[WCSTOCTS]);
+}
+
+static XlcConv
+open_mbstocts(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[MBSTOCTS]);
+}
+
+XLCd
+_XlcEucLoader(
+ const char *name)
+{
+ XLCd lcd;
+
+ lcd = _XlcCreateLC(name, _XlcGenericMethods);
+ if (lcd == NULL)
+ return lcd;
+
+ if (!XLC_PUBLIC_PART(lcd)->codeset ||
+ (_XlcNCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "euc", 3))) {
+ _XlcDestroyLC(lcd);
+ return (XLCd) NULL;
+ }
+
+ initCTptr(lcd);
+
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs);
+
+#ifndef FORCE_INDIRECT_CONVERTER
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte, open_ctstombs);
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar, open_ctstowcs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_mbstocts);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_mbstowcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstocts);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstombs);
+#endif
+
+ _XlcAddUtf8Converters(lcd);
+
+ return lcd;
+}
+
+#else
+typedef int dummy;
+#endif /* X_LOCALE */
diff --git a/nx-X11/lib/X11/lcFile.c b/nx-X11/lib/X11/lcFile.c
new file mode 100644
index 000000000..691daeb9e
--- /dev/null
+++ b/nx-X11/lib/X11/lcFile.c
@@ -0,0 +1,648 @@
+/* $Xorg: lcFile.c,v 1.5 2000/12/12 12:44:05 coskrey Exp $ */
+/*
+ *
+ * Copyright IBM Corporation 1993
+ *
+ * All Rights Reserved
+ *
+ * License 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 IBM not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND
+ * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
+ * IBM 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.
+ *
+*/
+/* $XFree86: xc/lib/X11/lcFile.c,v 3.32 2003/03/25 04:18:09 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include <X11/Xos.h>
+#if 0
+#include <unistd.h> /* in theory delivers getresuid/gid prototypes,
+ * in practice only the Linux syscall wrapper is there. */
+#endif
+
+
+/************************************************************************/
+
+#ifdef __UNIXOS2__
+# define seteuid setuid
+#endif
+#define iscomment(ch) ((ch) == '#' || (ch) == '\0')
+#if defined(WIN32)
+#define isreadable(f) (_XAccessFile(f))
+#else
+#define isreadable(f) ((access((f), R_OK) != -1) ? 1 : 0)
+#endif
+
+#ifndef __UNIXOS2__
+#define LC_PATHDELIM ':'
+#else
+#define LC_PATHDELIM ';'
+#endif
+
+#define XLC_BUFSIZE 256
+
+#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
+
+#define NUM_LOCALEDIR 64
+
+/* Splits a NUL terminated line into constituents, at colons and newline
+ characters. Leading whitespace is removed from constituents. The
+ constituents are stored at argv[0..argsize-1]. The number of stored
+ constituents (<= argsize) is returned. The line is destructively
+ modified. */
+static int
+parse_line(
+ char *line,
+ char **argv,
+ int argsize)
+{
+ int argc = 0;
+ char *p = line;
+
+ while (argc < argsize) {
+ while (isspace(*p)) {
+ ++p;
+ }
+ if (*p == '\0') {
+ break;
+ }
+ argv[argc++] = p;
+ while (*p != ':' && *p != '\n' && *p != '\0') {
+ ++p;
+ }
+ if (*p == '\0') {
+ break;
+ }
+ *p++ = '\0';
+ }
+
+ return argc;
+}
+
+#ifdef __UNIXOS2__
+
+/* fg021216: entries in locale files are separated by colons while under
+ OS/2, path entries are separated by semicolon, so we need two functions */
+
+static int
+parse_line1(
+ char *line,
+ char **argv,
+ int argsize)
+{
+ int argc = 0;
+ char *p = line;
+
+ while (argc < argsize) {
+ while (isspace(*p)) {
+ ++p;
+ }
+ if (*p == '\0') {
+ break;
+ }
+ argv[argc++] = p;
+ while (*p != ';' && *p != '\n' && *p != '\0') {
+ ++p;
+ }
+ if (*p == '\0') {
+ break;
+ }
+ *p++ = '\0';
+ }
+
+ return argc;
+}
+#elif defined(WIN32)
+
+/* this is parse_line but skips drive letters at the beginning of the entry */
+static int
+parse_line1(
+ char *line,
+ char **argv,
+ int argsize)
+{
+ int argc = 0;
+ char *p = line;
+
+ while (argc < argsize) {
+ while (isspace(*p)) {
+ ++p;
+ }
+ if (*p == '\0') {
+ break;
+ }
+ argv[argc++] = p;
+ if (isalpha(*p) && p[1] == ':') {
+ p+= 2; /* skip drive letters */
+ }
+ while (*p != ':' && *p != '\n' && *p != '\0') {
+ ++p;
+ }
+ if (*p == '\0') {
+ break;
+ }
+ *p++ = '\0';
+ }
+
+ return argc;
+}
+
+#endif /* __UNIXOS2__ */
+
+/* Splits a colon separated list of directories, and returns the constituent
+ paths (without trailing slash). At most argsize constituents are stored
+ at argv[0..argsize-1]. The number of stored constituents is returned. */
+static int
+_XlcParsePath(
+ char *path,
+ char **argv,
+ int argsize)
+{
+ char *p = path;
+ int n, i;
+
+#if !defined(__UNIXOS2__) && !defined(WIN32)
+ n = parse_line(path, argv, argsize);
+#else
+ n = parse_line1(path, argv, argsize);
+#endif
+ for (i = 0; i < n; ++i) {
+ int len;
+ p = argv[i];
+ len = strlen(p);
+ if (len > 0 && p[len - 1] == '/') {
+ /* eliminate trailing slash */
+ p[len - 1] = '\0';
+ }
+ }
+ return n;
+}
+
+#ifndef XLOCALEDIR
+#define XLOCALEDIR "/usr/lib/X11/locale"
+#endif
+
+static void
+xlocaledir(
+ char *buf,
+ int buf_len)
+{
+ char *p = buf;
+ int len = 0;
+
+#ifndef NO_XLOCALEDIR
+ char *dir;
+ int priv = 1;
+
+ dir = getenv("XLOCALEDIR");
+
+ if (dir) {
+#ifndef WIN32
+ /*
+ * Only use the user-supplied path if the process isn't priviledged.
+ */
+ if (getuid() == geteuid() && getgid() == getegid()) {
+#if defined(HASSETUGID)
+ priv = issetugid();
+#elif defined(HASGETRESUID)
+ {
+ uid_t ruid, euid, suid;
+ gid_t rgid, egid, sgid;
+ if ((getresuid(&ruid, &euid, &suid) == 0) &&
+ (getresgid(&rgid, &egid, &sgid) == 0))
+ priv = (euid != suid) || (egid != sgid);
+ }
+#else
+ /*
+ * If there are saved ID's the process might still be priviledged
+ * even though the above test succeeded. If issetugid() and
+ * getresgid() aren't available, test this by trying to set
+ * euid to 0.
+ *
+ * Note: this only protects setuid-root clients. It doesn't
+ * protect other setuid or any setgid clients. If this tradeoff
+ * isn't acceptable, set DisableXLocaleDirEnv to YES in host.def.
+ */
+ unsigned int oldeuid;
+ oldeuid = geteuid();
+ if (seteuid(0) != 0) {
+ priv = 0;
+ } else {
+ if (seteuid(oldeuid) == -1) {
+ /* XXX ouch, coudn't get back to original uid
+ what can we do ??? */
+ _exit(127);
+ }
+ priv = 1;
+ }
+#endif
+ }
+#else
+ priv = 0;
+#endif
+ if (!priv) {
+ len = strlen(dir);
+ strncpy(p, dir, buf_len);
+ if (len < buf_len) {
+ p[len++] = LC_PATHDELIM;
+ p += len;
+ }
+ }
+ }
+#endif /* NO_XLOCALEDIR */
+
+ if (len < buf_len)
+#ifndef __UNIXOS2__
+ strncpy(p, XLOCALEDIR, buf_len - len);
+#else
+ strncpy(p,__XOS2RedirRoot(XLOCALEDIR), buf_len - len);
+#endif
+ buf[buf_len-1] = '\0';
+}
+
+/* Mapping direction */
+typedef enum {
+ LtoR, /* Map first field to second field */
+ RtoL /* Map second field to first field */
+} MapDirection;
+
+static char *
+resolve_name(
+ const char *lc_name,
+ char *file_name,
+ MapDirection direction)
+{
+ FILE *fp;
+ char buf[XLC_BUFSIZE], *name = NULL;
+
+ fp = _XFopenFile (file_name, "r");
+ if (fp == NULL)
+ return NULL;
+
+ while (fgets(buf, XLC_BUFSIZE, fp) != NULL) {
+ char *p = buf;
+ int n;
+ char *args[2], *from, *to;
+#ifdef __UNIXOS2__ /* Take out CR under OS/2 */
+ int len;
+
+ len = strlen(p);
+ if (len > 1) {
+ if (*(p+len-2) == '\r' && *(p+len-1) == '\n') {
+ *(p+len-2) = '\n';
+ *(p+len-1) = '\0';
+ }
+ }
+#endif
+ while (isspace(*p)) {
+ ++p;
+ }
+ if (iscomment(*p)) {
+ continue;
+ }
+ n = parse_line(p, args, 2); /* get first 2 fields */
+ if (n != 2) {
+ continue;
+ }
+ if (direction == LtoR) {
+ from = args[0], to = args[1]; /* left to right */
+ } else {
+ from = args[1], to = args[0]; /* right to left */
+ }
+ if (! strcmp(from, lc_name)) {
+ name = Xmalloc(strlen(to) + 1);
+ if (name != NULL) {
+ strcpy(name, to);
+ }
+ break;
+ }
+ }
+ fclose(fp);
+ return name;
+}
+
+#define c_tolower(ch) ((ch) >= 'A' && (ch) <= 'Z' ? (ch) - 'A' + 'a' : (ch))
+
+static char *
+lowercase(
+ char *dst,
+ const char *src)
+{
+ const char *s;
+ char *t;
+
+ for (s = src, t = dst; *s; ++s, ++t)
+ *t = c_tolower(*s);
+ *t = '\0';
+ return dst;
+}
+
+/*
+ * normalize_lcname(): remove any '_' and '-' and convert any character
+ * to lower case after the <language>_<territory> part. If result is identical
+ * to argument, free result and
+ * return NULL.
+ */
+static char *
+normalize_lcname (const char *name)
+{
+ char *p, *ret;
+ const char *tmp = name;
+
+ p = ret = Xmalloc(strlen(name) + 1);
+ if (!p)
+ return NULL;
+
+ if (tmp) {
+ while (*tmp && *tmp != '.' && *tmp != '@')
+ *p++ = *tmp++;
+ while (*tmp) {
+ if (*tmp != '-')
+ *p++ = c_tolower(*tmp);
+ tmp++;
+ }
+ }
+ *p = '\0';
+
+ if (strcmp(ret, name) == 0) {
+ Xfree(ret);
+ return NULL;
+ }
+
+ return ret;
+}
+
+/************************************************************************/
+char *
+_XlcFileName(
+ XLCd lcd,
+ const char *category)
+{
+ char *siname;
+ char cat[XLC_BUFSIZE], dir[XLC_BUFSIZE];
+ int i, n;
+ char *args[NUM_LOCALEDIR];
+ char *file_name = NULL;
+
+ if (lcd == (XLCd)NULL)
+ return NULL;
+
+ siname = XLC_PUBLIC(lcd, siname);
+
+ lowercase(cat, category);
+ xlocaledir(dir,XLC_BUFSIZE);
+ n = _XlcParsePath(dir, args, NUM_LOCALEDIR);
+ for (i = 0; i < n; ++i) {
+ char buf[PATH_MAX], *name;
+
+ name = NULL;
+ if ((5 + (args[i] ? strlen (args[i]) : 0) +
+ (cat ? strlen (cat) : 0)) < PATH_MAX) {
+ sprintf(buf, "%s/%s.dir", args[i], cat);
+ name = resolve_name(siname, buf, RtoL);
+ }
+ if (name == NULL) {
+ continue;
+ }
+ if (*name == '/') {
+ /* supposed to be absolute path name */
+ file_name = name;
+ } else {
+ file_name = Xmalloc(2 + (args[i] ? strlen (args[i]) : 0) +
+ (name ? strlen (name) : 0));
+ if (file_name != NULL)
+ sprintf(file_name, "%s/%s", args[i], name);
+ Xfree(name);
+ }
+ if (isreadable(file_name)) {
+ break;
+ }
+ Xfree(file_name);
+ file_name = NULL;
+ /* Then, try with next dir */
+ }
+ return file_name;
+}
+
+/************************************************************************/
+#ifndef LOCALE_ALIAS
+#define LOCALE_ALIAS "locale.alias"
+#endif
+
+int
+_XlcResolveLocaleName(
+ const char* lc_name,
+ XLCdPublicPart* pub)
+{
+ char dir[PATH_MAX], buf[PATH_MAX], *name = NULL;
+ char *dst;
+ int i, n, sinamelen;
+ char *args[NUM_LOCALEDIR];
+ static const char locale_alias[] = LOCALE_ALIAS;
+ char *tmp_siname;
+ char *nlc_name = NULL;
+
+ xlocaledir (dir, PATH_MAX);
+ n = _XlcParsePath(dir, args, NUM_LOCALEDIR);
+ for (i = 0; i < n; ++i) {
+ if ((2 + (args[i] ? strlen (args[i]) : 0) +
+ strlen (locale_alias)) < PATH_MAX) {
+ sprintf (buf, "%s/%s", args[i], locale_alias);
+ name = resolve_name (lc_name, buf, LtoR);
+ if (!name) {
+ if (!nlc_name)
+ nlc_name = normalize_lcname(lc_name);
+ if (nlc_name)
+ name = resolve_name (nlc_name, buf, LtoR);
+ }
+ }
+ if (name != NULL) {
+ break;
+ }
+ }
+ if (nlc_name) Xfree(nlc_name);
+
+ if (name == NULL) {
+ /* vendor locale name == Xlocale name, no expansion of alias */
+ pub->siname = Xmalloc (strlen (lc_name) + 1);
+ strcpy (pub->siname, lc_name);
+ } else {
+ pub->siname = name;
+ }
+
+ sinamelen = strlen (pub->siname);
+ if (sinamelen == 1 && pub->siname[0] == 'C') {
+ pub->language = pub->siname;
+ pub->territory = pub->codeset = NULL;
+ return 1;
+ }
+
+ /*
+ * pub->siname is in the format <lang>_<terr>.<codeset>, typical would
+ * be "en_US.ISO8859-1", "en_US.utf8", "ru_RU.KOI-8", or ja_JP.SJIS,
+ * although it could be ja.SJIS too.
+ */
+ tmp_siname = Xrealloc (pub->siname, 2 * (sinamelen + 1));
+ if (tmp_siname == NULL) {
+ return 0;
+ }
+ pub->siname = tmp_siname;
+
+ /* language */
+ dst = &pub->siname[sinamelen + 1];
+ strcpy (dst, pub->siname);
+ pub->language = dst;
+
+ /* territory */
+ dst = strchr (dst, '_');
+ if (dst) {
+ *dst = '\0';
+ pub->territory = ++dst;
+ } else
+ dst = &pub->siname[sinamelen + 1];
+
+ /* codeset */
+ dst = strchr (dst, '.');
+ if (dst) {
+ *dst = '\0';
+ pub->codeset = ++dst;
+ }
+
+ return (pub->siname[0] != '\0') ? 1 : 0;
+}
+
+/************************************************************************/
+int
+_XlcResolveI18NPath(buf, buf_len)
+ char *buf;
+ int buf_len;
+{
+ if (buf != NULL) {
+ xlocaledir(buf, buf_len);
+ }
+ return 1;
+}
+
+char *
+_XlcLocaleDirName(dir_name, dir_len, lc_name)
+ char *dir_name;
+ size_t dir_len;
+ char *lc_name;
+{
+ char dir[PATH_MAX], buf[PATH_MAX], *name = NULL;
+ int i, n;
+ char *args[NUM_LOCALEDIR];
+ static char locale_alias[] = LOCALE_ALIAS;
+ char *target_name = (char*)0;
+ char *target_dir = (char*)0;
+ char *nlc_name = NULL;
+
+ xlocaledir (dir, PATH_MAX);
+ n = _XlcParsePath(dir, args, 256);
+ for (i = 0; i < n; ++i) {
+
+ if ((2 + (args[i] ? strlen(args[i]) : 0) +
+ strlen(locale_alias)) < PATH_MAX) {
+ sprintf (buf, "%s/%s", args[i], locale_alias);
+ name = resolve_name(lc_name, buf, LtoR);
+ if (!name) {
+ if (!nlc_name)
+ nlc_name = normalize_lcname(lc_name);
+ if (nlc_name)
+ name = resolve_name (nlc_name, buf, LtoR);
+ }
+ }
+
+ /* If name is not an alias, use lc_name for locale.dir search */
+ if (name == NULL)
+ name = lc_name;
+
+ /* look at locale.dir */
+
+ target_dir = args[i];
+ if (!target_dir) {
+ /* something wrong */
+ if (name != lc_name)
+ Xfree(name);
+ continue;
+ }
+ if ((1 + (target_dir ? strlen (target_dir) : 0) +
+ strlen("locale.dir")) < PATH_MAX) {
+ sprintf(buf, "%s/locale.dir", target_dir);
+ target_name = resolve_name(name, buf, RtoL);
+ }
+ if (name != lc_name)
+ Xfree(name);
+ if (target_name != NULL) {
+ char *p = 0;
+ if ((p = strstr(target_name, "/XLC_LOCALE"))) {
+ *p = '\0';
+ break;
+ }
+ Xfree(target_name);
+ target_name = NULL;
+ }
+ name = NULL;
+ }
+ if (nlc_name) Xfree(nlc_name);
+
+ if (target_name == NULL) {
+ /* vendor locale name == Xlocale name, no expansion of alias */
+ target_dir = args[0];
+ target_name = lc_name;
+ }
+ /* snprintf(dir_name, dir_len, "%s/%", target_dir, target_name); */
+ strncpy(dir_name, target_dir, dir_len - 1);
+ if (strlen(target_dir) >= dir_len - 1) {
+ dir_name[dir_len - 1] = '\0';
+ } else {
+ strcat(dir_name, "/");
+ strncat(dir_name, target_name, dir_len - strlen(dir_name) - 1);
+ if (strlen(target_name) >= dir_len - strlen(dir_name) - 1)
+ dir_name[dir_len - 1] = '\0';
+ }
+ if (target_name != lc_name)
+ Xfree(target_name);
+ return dir_name;
+}
diff --git a/nx-X11/lib/X11/lcGenConv.c b/nx-X11/lib/X11/lcGenConv.c
new file mode 100644
index 000000000..76e7d0f78
--- /dev/null
+++ b/nx-X11/lib/X11/lcGenConv.c
@@ -0,0 +1,3151 @@
+/* $Xorg: lcGenConv.c,v 1.5 2000/08/17 19:45:17 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * (c) Copyright 1995 FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Masayoshi Shimamura FUJITSU LIMITED
+ *
+ */
+/*
+ * 2000
+ * Modifier: Ivan Pascal The XFree86 Project
+ */
+/* $XFree86: xc/lib/X11/lcGenConv.c,v 3.27tsi Exp $ */
+
+/*
+ * A generic locale loader for all kinds of ISO-2022 based codesets.
+ * Supports: all locales.
+ * How: Provides generic converters for ISO-2022 based codesets. Extensible as
+ * far as ISO-2022 is extensible: codesets can be given by name in the
+ * stream. Overall distinction between GL (0x00..0x7f) and GR (0x80..0xff).
+ * In every chunk between escape sequences, the number of bytes per
+ * character (char_size) is constant.
+ * Platforms: all systems.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcGeneric.h"
+#include <stdio.h>
+
+#if !defined(macII) && !defined(Lynx_22) && !defined(X_LOCALE)
+#define STDCVT
+#endif
+
+typedef struct _CTDataRec {
+ char *name;
+ char *encoding; /* Compound Text encoding */
+} CTDataRec, *CTData;
+
+static CTDataRec directionality_data[] =
+{
+ { "BEGIN_LEFT-TO-RIGHT_TEXT", "\2331]" },
+ { "BEGIN_RIGHT-TO-LEFT_TEXT", "\2332]" },
+ { "END_OF_STRING", "\233]" },
+};
+
+typedef struct _StateRec {
+ XLCd lcd;
+ /* CT state */
+ XlcCharSet charset; /* charset of current state */
+ XlcCharSet GL_charset; /* charset of initial state in GL */
+ XlcCharSet GR_charset; /* charset of initial state in GR */
+ /* MB shift state */
+ CodeSet GL_codeset;
+ CodeSet GR_codeset;
+} StateRec, *State;
+
+#define GR 0x80 /* begins right-side (non-ascii) region */
+#define GL 0x7f /* ends left-side (ascii) region */
+#define ESC 0x1b
+#define CSI 0x9b
+#define STX 0x02
+
+#define isrightside(c) ((c) & GR)
+#define isleftside(c) (!isrightside(c))
+
+/* Forward declarations for local routines. */
+static int mbstocts (XlcConv conv, XPointer *from, int *from_left,
+ XPointer *to, int *to_left, XPointer *args, int num_args);
+static int ctstombs (XlcConv conv, XPointer *from, int *from_left,
+ XPointer *to, int *to_left, XPointer *args, int num_args);
+static int cstombs (XlcConv conv, XPointer *from, int *from_left,
+ XPointer *to, int *to_left, XPointer *args, int num_args);
+
+/* ------------------------------------------------------------------------- */
+/* Misc */
+/* ------------------------------------------------------------------------- */
+
+static int
+compare(
+ const char *src,
+ const char *encoding,
+ int length)
+{
+ const char *start = src;
+
+ while (length-- > 0) {
+ if (*src++ != *encoding++)
+ return 0;
+ if (*encoding == '\0')
+ return src - start;
+ }
+
+ return 0;
+}
+
+static unsigned long
+conv_to_dest(
+ Conversion conv,
+ unsigned long code)
+{
+ int i;
+ int conv_num = conv->conv_num;
+ FontScope convlist = conv->convlist;
+
+ for (i = 0; i < conv_num; i++) {
+ if (convlist[i].start <= code && code <= convlist[i].end) {
+ switch (convlist[i].shift_direction) {
+ case '+':
+ return(code + convlist[i].shift);
+ case '-':
+ return(code - convlist[i].shift);
+ default:
+ return(code);
+ }
+ }
+ }
+
+ return(code);
+}
+
+static unsigned long
+conv_to_source(
+ Conversion conv,
+ unsigned long code)
+{
+ int i;
+ int conv_num;
+ FontScope convlist;
+ unsigned long start_p;
+ unsigned long start_m;
+ unsigned long end_p;
+ unsigned long end_m;
+
+ if (!conv)
+ return(code);
+
+ conv_num = conv->conv_num;
+ convlist = conv->convlist;
+
+ for (i = 0; i < conv_num; i++) {
+ switch (convlist[i].shift_direction) {
+ case '+':
+ start_p = convlist[i].start + convlist[i].shift;
+ end_p = convlist[i].end + convlist[i].shift;
+ if (start_p <= code && code <= end_p)
+ return(code - convlist[i].shift);
+ break;
+ case '-':
+ start_m = convlist[i].start - convlist[i].shift;
+ end_m = convlist[i].end - convlist[i].shift;
+ if (start_m <= code && code <= end_m)
+ return(code + convlist[i].shift);
+ break;
+ default:
+ continue;
+ }
+ }
+
+ return(code);
+}
+
+static unsigned long
+mb_to_gi(
+ unsigned long mb,
+ CodeSet codeset)
+{
+ int i;
+ unsigned long mb_tmp, mask = 0;
+
+ if (codeset->mbconv) {
+ mb_tmp = conv_to_dest(codeset->mbconv, mb);
+ if (mb_tmp != mb)
+ return(mb_tmp);
+ }
+
+ if (codeset->side == XlcC0 || codeset->side == XlcGL ||
+ codeset->side == XlcC1 || codeset->side == XlcGR) {
+
+ for (i = 0; i < codeset->length; i++)
+ mask = (mask << 8) | GL;
+ mb = mb & mask;
+ }
+
+ return(mb);
+}
+
+static unsigned long
+gi_to_mb(
+ unsigned long glyph_index,
+ CodeSet codeset)
+{
+ int i;
+ unsigned long mask = 0;
+
+ if (codeset->side == XlcC1 || codeset->side == XlcGR) {
+ for (i = 0; i < codeset->length; i++)
+ mask = (mask << 8) | GR;
+ glyph_index = glyph_index | mask;
+ }
+
+ if (codeset->mbconv)
+ return( conv_to_source(codeset->mbconv, glyph_index) );
+
+ return(glyph_index);
+}
+
+static Bool
+gi_to_wc(
+ XLCd lcd,
+ unsigned long glyph_index,
+ CodeSet codeset,
+ wchar_t *wc)
+{
+ unsigned char mask = 0;
+ unsigned long wc_encoding = codeset->wc_encoding;
+ int length = codeset->length;
+ unsigned long wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
+
+ mask = (1 << wc_shift_bits) - 1 ;
+
+ for (*wc = 0, length--; length >= 0; length--)
+ *wc = (*wc << wc_shift_bits) | ((glyph_index >> (length * 8 )) & mask);
+
+ *wc = *wc | wc_encoding;
+
+ return(True);
+}
+
+static Bool
+wc_to_gi(
+ XLCd lcd,
+ wchar_t wc,
+ unsigned long *glyph_index,
+ CodeSet *codeset)
+{
+ int i;
+ unsigned char mask = 0;
+ unsigned long wc_encoding;
+ unsigned long wc_encode_mask = XLC_GENERIC(lcd, wc_encode_mask);
+ unsigned long wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list);
+
+ wc_encoding = wc & wc_encode_mask;
+ for (*codeset = NULL, i = 0; i < codeset_num; i++) {
+ if (wc_encoding == codeset_list[i]->wc_encoding) {
+ *codeset = codeset_list[i];
+ break;
+ }
+ }
+ if (*codeset == NULL)
+ return(False);
+
+ mask = (1 << wc_shift_bits) - 1 ;
+
+ wc = wc & ~wc_encode_mask;
+ for (*glyph_index = 0, i = (*codeset)->length - 1; i >= 0; i--)
+ *glyph_index = (*glyph_index << 8) |
+ ( ((unsigned long)wc >> (i * wc_shift_bits)) & mask );
+
+ return(True);
+}
+
+static CodeSet
+mb_parse_codeset(
+ State state,
+ int num,
+ const char **inbufptr,
+ int *from_left)
+{
+ int len;
+ int from_len = (*from_left) + 1;
+ const char *src = (*inbufptr) - 1;
+ ParseInfo *mb_parse_list = XLC_GENERIC(state->lcd, mb_parse_list);
+ ParseInfo parse_info;
+ CodeSet codeset;
+
+ for (--num ; (parse_info = mb_parse_list[num]) != NULL; num++) {
+ len = compare(src, parse_info->encoding, from_len);
+ if (len > 0) {
+ codeset = parse_info->codeset;
+ if (parse_info->type == E_LSL)
+ state->GL_codeset = codeset;
+ else if (parse_info->type == E_LSR)
+ state->GR_codeset = codeset;
+ --len;
+ *inbufptr += len;
+ *from_left -= len;
+ return codeset;
+ }
+ }
+ return (CodeSet) NULL;
+}
+
+static CodeSet
+byteM_parse_codeset(
+ XLCd lcd,
+ const char *inbufptr)
+{
+ unsigned char ch;
+ CodeSet codeset;
+ ByteInfoList byteM;
+ ByteInfoListRec byteM_rec;
+ ByteInfo byteinfo;
+ ByteInfoRec byteinfo_rec;
+ Bool hit = False;
+ int i, j, k;
+
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list);
+
+ for (i = 0; i < codeset_num; i++) {
+ codeset = codeset_list[i];
+ byteM = codeset->byteM;
+ if (codeset->side != XlcNONE || byteM == NULL)
+ continue;
+
+ for (j = 0; j < codeset->length; j++) {
+ ch = *((unsigned char *)(inbufptr + j));
+ byteM_rec = byteM[j];
+ byteinfo = byteM_rec.byteinfo;
+
+ for (hit = False, k = 0; k < byteM_rec.byteinfo_num; k++) {
+ byteinfo_rec = byteinfo[k];
+ if (byteinfo_rec.start <= ch && ch <= byteinfo_rec.end) {
+ hit = True;
+ break;
+ }
+ }
+
+ if (!hit)
+ break;
+ }
+
+ if (hit)
+ return(codeset);
+ }
+
+ return(NULL);
+}
+
+#define GLGR_parse_codeset(ch) \
+ (isrightside(ch) ? (state->GR_codeset) : \
+ (state->GL_codeset) )
+
+static XlcCharSet
+gi_parse_charset(
+ unsigned long glyph_index,
+ CodeSet codeset)
+{
+ int i;
+ XlcCharSet *charset_list = codeset->charset_list;
+ int num_charsets = codeset->num_charsets;
+ ExtdSegment ctextseg = codeset->ctextseg;
+ XlcCharSet charset = NULL;
+ int area_num;
+ FontScope area;
+
+ /* lockup ct sequence */
+ for (i = 0; i < num_charsets; i++) {
+ charset = charset_list[i];
+ if (*charset->ct_sequence != '\0')
+ break;
+ }
+ if (i >= num_charsets)
+ return(NULL);
+
+ if (charset->source != CSsrcStd)
+ return (charset);
+
+ if (!ctextseg)
+ return(charset);
+
+ area = ctextseg->area;
+ area_num = ctextseg->area_num;
+
+ for (i = 0; i < area_num; i++) {
+
+ if (area[i].start <= glyph_index && glyph_index <= area[i].end) {
+
+ charset = ctextseg->charset;
+
+ if (*charset->ct_sequence == '\0')
+ return(NULL);
+
+ break;
+ }
+ }
+
+ return(charset);
+}
+
+static Bool
+ct_parse_csi(
+ const char *inbufptr,
+ int *ctr_seq_len)
+{
+ int i;
+ int num = sizeof(directionality_data) / sizeof(directionality_data[0]);
+
+ for (i = 0; i < num; i++) {
+ if ( !(*ctr_seq_len = strlen(directionality_data[i].encoding)) )
+ continue;
+
+ if ( strncmp(inbufptr, directionality_data[i].encoding,
+ *ctr_seq_len) == 0)
+ return(True);
+ }
+
+ return(False);
+}
+
+static int
+cmp_esc_sequence(
+ const char *inbufptr,
+ XlcCharSet charset)
+{
+ int seq_len, name_len, total_len;
+ unsigned char byte_m, byte_l;
+ const char *ct_sequence = charset->ct_sequence;
+ const char *encoding_name = charset->encoding_name;
+
+ /* check esc sequence */
+ if ( !(seq_len = strlen(ct_sequence) ) )
+ return(0);
+ if ( strncmp(inbufptr, ct_sequence, seq_len) != 0)
+ return(0);
+
+ /* Standard Character Set Encoding ? */
+ if (charset->source == CSsrcStd)
+ return(seq_len);
+
+ /*
+ * Non-Standard Character Set Encoding
+ *
+ * +--- ---+-----+-----+-----+---- ----+-----+-----+------- ------+
+ * | ctseq | M | L | encoding name | STX | contents |
+ * +--- ---+-----+-----+-----+---- ----+-----+-----+------- ------+
+ * 4bytes 1byte 1byte variable length 1byte variable length
+ * | |
+ * +----------------------------------------------+
+ * rest length = ((M - 128) * 128) + (L - 128)
+ */
+
+ /* get length of encoding name */
+ inbufptr += seq_len;
+ byte_m = *inbufptr++;
+ byte_l = *inbufptr++;
+ name_len = strlen(encoding_name);
+
+ if (((byte_m - 128) * 128 + (byte_l - 128) - 1) < name_len)
+ return(0);
+
+ if ( _XlcNCompareISOLatin1(inbufptr, encoding_name, name_len) != 0 )
+ return(0);
+
+ /* check STX (Start of Text) */
+ inbufptr = inbufptr + name_len;
+ if ( *inbufptr != STX )
+ return(0);
+
+ total_len = seq_len + name_len + 3;
+ return(total_len);
+}
+
+static Bool
+ct_parse_charset(
+ XLCd lcd,
+ const char *inbufptr,
+ XlcCharSet *charset,
+ int *ctr_seq_len)
+{
+ int i, j;
+ ExtdSegment ctextseg;
+ int num_charsets;
+ XlcCharSet *charset_list;
+ CodeSet codeset;
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list);
+ int segment_conv_num = XLC_GENERIC(lcd, segment_conv_num);
+ SegConv segment_conv = XLC_GENERIC(lcd, segment_conv);
+
+ /* get charset from XLC_XLOCALE by escape sequence */
+
+ for (i = 0; i < codeset_num; i++) {
+ codeset = codeset_list[i];
+
+ num_charsets = codeset->num_charsets;
+ charset_list = codeset->charset_list;
+ ctextseg = codeset->ctextseg;
+
+ for (j = 0; j < num_charsets; j++) {
+ *charset = charset_list[j];
+ if ((*ctr_seq_len = cmp_esc_sequence(inbufptr, *charset)))
+ return(True);
+ }
+
+ if (ctextseg) {
+ *charset = ctextseg->charset;
+ if ((*ctr_seq_len = cmp_esc_sequence(inbufptr, *charset)))
+ return(True);
+ }
+ }
+
+ /* get charset from XLC_SEGMENTCONVERSION by escape sequence */
+
+ if (!segment_conv)
+ return(False);
+
+ for (i = 0; i < segment_conv_num; i++) {
+ *charset = segment_conv[i].source;
+ if ((*ctr_seq_len = cmp_esc_sequence(inbufptr, *charset)))
+ return(True);
+ *charset = segment_conv[i].dest;
+ if ((*ctr_seq_len = cmp_esc_sequence(inbufptr, *charset)))
+ return(True);
+ }
+
+ return(False);
+}
+
+static Bool
+segment_conversion(
+ XLCd lcd,
+ XlcCharSet *charset,
+ unsigned long *glyph_index)
+{
+ int i;
+ int segment_conv_num = XLC_GENERIC(lcd, segment_conv_num);
+ SegConv segment_conv = XLC_GENERIC(lcd, segment_conv);
+ FontScopeRec range;
+ ConversionRec conv_rec;
+
+ if (!segment_conv)
+ return(True);
+
+ for (i = 0; i < segment_conv_num; i++) {
+ if (segment_conv[i].source == *charset)
+ break;
+ }
+
+ if (i >= segment_conv_num)
+ return(True);
+
+ range = segment_conv[i].range;
+ if (*glyph_index < range.start || range.end < *glyph_index)
+ return(True);
+
+ *charset = segment_conv[i].dest;
+ conv_rec.conv_num = segment_conv[i].conv_num;
+ conv_rec.convlist = segment_conv[i].conv;
+ *glyph_index = conv_to_dest(&conv_rec, *glyph_index);
+
+ return(True);
+}
+
+static CodeSet
+_XlcGetCodeSetFromName(
+ XLCd lcd,
+ const char *name)
+{
+ int i, j;
+ XlcCharSet charset;
+ int num_charsets;
+ XlcCharSet *charset_list;
+ CodeSet codeset;
+
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list);
+
+ for (i = 0; i < codeset_num; i++) {
+ codeset = codeset_list[i];
+
+ num_charsets = codeset->num_charsets;
+ charset_list = codeset->charset_list;
+
+ for (j = 0; j < num_charsets; j++) {
+ charset = charset_list[j];
+
+ if (!strlen(charset->name))
+ continue;
+ if ( strcmp(charset->name, name) == 0)
+ return(codeset);
+ }
+ }
+
+ return(NULL);
+}
+
+static Bool
+_XlcGetCodeSetFromCharSet(
+ XLCd lcd,
+ XlcCharSet charset,
+ CodeSet *codeset,
+ unsigned long *glyph_index)
+{
+ int j, num;
+ CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list);
+ XlcCharSet *charset_list;
+ int codeset_num, num_charsets;
+ Conversion ctconv;
+ unsigned long glyph_index_tmp = 0;
+ ExtdSegment ctextseg;
+
+ codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+ for (num = 0 ; num < codeset_num; num++) {
+ *codeset = codeset_list[num];
+ ctconv = (*codeset)->ctconv;
+ ctextseg = (*codeset)->ctextseg;
+
+ num_charsets = (*codeset)->num_charsets;
+ charset_list = (*codeset)->charset_list;
+
+ glyph_index_tmp = conv_to_source(ctconv, *glyph_index);
+
+ if (charset->source == CSsrcStd) {
+
+ /* Standard Character Set Encoding */
+ if (glyph_index_tmp == *glyph_index) {
+ for (j = 0; j < num_charsets; j++) {
+ if (charset_list[j] == charset) {
+ goto end_loop;
+ }
+ }
+ }
+
+ } else {
+
+ /* Non-Standard Character Set Encoding */
+ for (j = 0; j < num_charsets; j++) {
+ if (charset_list[j] == charset) {
+ goto end_loop;
+ }
+ }
+
+ if (glyph_index_tmp != *glyph_index) {
+ if (ctextseg && ctextseg->charset == charset) {
+ goto end_loop;
+ }
+ }
+
+ }
+
+ }
+
+end_loop:
+ if (num < codeset_num) {
+ *glyph_index = glyph_index_tmp;
+ return(True);
+ }
+
+ return(False);
+}
+
+#define check_string_encoding(codeset) (codeset->string_encoding)
+
+static void
+output_ulong_value(
+ char *outbufptr,
+ unsigned long code,
+ int length,
+ XlcSide side)
+{
+ int i;
+
+ for (i = (length - 1) * 8; i >= 0; i -= 8) {
+ *outbufptr = ( code >> i) & 0xff;
+
+ if (side == XlcC0 || side == XlcGL) {
+ *outbufptr = *outbufptr & GL;
+ } else if (side == XlcC1 || side == XlcGR) {
+ *outbufptr = *outbufptr | GR;
+ }
+
+ outbufptr++;
+ }
+}
+
+/* -------------------------------------------------------------------------- */
+/* Init */
+/* -------------------------------------------------------------------------- */
+
+static XlcCharSet default_GL_charset = 0;
+static XlcCharSet default_GR_charset = 0;
+
+static void
+init_state(
+ XlcConv conv)
+{
+ State state = (State) conv->state;
+
+ /* for CT */
+ state->charset = NULL;
+ state->GL_charset = default_GL_charset;
+ state->GR_charset = default_GR_charset;
+
+ /* for MB shift state */
+ state->GL_codeset = XLC_GENERIC(state->lcd, initial_state_GL);
+ state->GR_codeset = XLC_GENERIC(state->lcd, initial_state_GR);
+}
+
+/* -------------------------------------------------------------------------- */
+/* Convert */
+/* -------------------------------------------------------------------------- */
+
+static int
+mbstowcs_org(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ unsigned char ch;
+ unsigned long mb = 0;
+ wchar_t wc;
+
+ int length = 0, len_left = 0;
+ int unconv_num = 0;
+ int num;
+
+ CodeSet codeset = NULL;
+
+ const char *inbufptr = *from;
+ wchar_t *outbufptr = (wchar_t *) *to;
+ int from_size = *from_left;
+
+ unsigned char *mb_parse_table = XLC_GENERIC(lcd, mb_parse_table);
+
+ if (from == NULL || *from == NULL) {
+ _XlcResetConverter(conv);
+ return( 0 );
+ }
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ ch = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!ch) {
+ if (outbufptr) {*outbufptr++ = L'\0';}
+ (*to_left)--;
+
+ /* error check */
+ if (len_left) {
+ unconv_num += (length - len_left);
+ len_left = 0;
+ }
+
+ continue;
+ }
+
+ /* same mb char data */
+ if (len_left)
+ goto output_one_wc;
+
+ /* next mb char data for single shift ? */
+ if (mb_parse_table && (num = mb_parse_table[ch]) ) {
+ codeset = mb_parse_codeset(state, num, &inbufptr, from_left);
+ if (codeset != NULL) {
+ length = len_left = codeset->length;
+ mb = 0;
+ continue;
+ }
+ }
+
+ /* next mb char data for byteM ? */
+ if ((codeset = byteM_parse_codeset(lcd, (inbufptr - 1))))
+ goto next_mb_char;
+
+ /* next mb char data for GL or GR side ? */
+ if ((codeset = GLGR_parse_codeset(ch)))
+ goto next_mb_char;
+
+ /* can't find codeset for the ch */
+ unconv_num++;
+ continue;
+
+next_mb_char:
+ length = len_left = codeset->length;
+ mb = 0;
+
+output_one_wc:
+ mb = (mb << 8) | ch; /* 1 byte left shift */
+ len_left--;
+
+ /* last of one mb char data */
+ if (!len_left) {
+ gi_to_wc(lcd, mb_to_gi(mb, codeset), codeset, &wc);
+ if (outbufptr) {*outbufptr++ = wc;}
+ (*to_left)--;
+ }
+
+ } /* end of while */
+
+ /* error check on last char */
+ if (len_left) {
+ inbufptr -= (length - len_left);
+ (*from_left) += (length - len_left);
+ unconv_num += (length - len_left);
+ }
+
+ *from = (XPointer) ((const char *) *from + from_size);
+ *from_left = 0;
+ *to = (XPointer) outbufptr;
+
+ return unconv_num;
+}
+
+static int
+stdc_mbstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const char *src = *((const char **) from);
+ wchar_t *dst = *((wchar_t **) to);
+ int src_left = *from_left;
+ int dst_left = *to_left;
+ int length, unconv_num = 0;
+
+ while (src_left > 0 && dst_left > 0) {
+ length = mbtowc(dst, src, src_left);
+
+ if (length > 0) {
+ src += length;
+ src_left -= length;
+ if (dst)
+ dst++;
+ dst_left--;
+ } else if (length < 0) {
+ src++;
+ src_left--;
+ unconv_num++;
+ } else {
+ /* null ? */
+ src++;
+ src_left--;
+ if (dst)
+ *dst++ = L'\0';
+ dst_left--;
+ }
+ }
+
+ *from = (XPointer) src;
+ if (dst)
+ *to = (XPointer) dst;
+ *from_left = src_left;
+ *to_left = dst_left;
+
+ return unconv_num;
+}
+
+static int
+wcstombs_org(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ char *encoding;
+ unsigned long mb, glyph_index;
+ wchar_t wc;
+
+ int length;
+ int unconv_num = 0;
+
+ CodeSet codeset;
+
+ const wchar_t *inbufptr = (const wchar_t *) *from;
+ char *outbufptr = *to;
+ int from_size = *from_left;
+
+ const char *default_string = XLC_PUBLIC(lcd, default_string);
+ int defstr_len = strlen(default_string);
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ wc = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!wc) {
+ if (outbufptr) {*outbufptr++ = '\0';}
+ (*to_left)--;
+
+ continue;
+ }
+
+ /* convert */
+ if ( !wc_to_gi(lcd, wc, &glyph_index, &codeset) ) {
+
+ /* output default_string of XDefaultString() */
+ if (*to_left < defstr_len)
+ break;
+ if (outbufptr) {
+ strncpy((char *)outbufptr, default_string, defstr_len);
+ outbufptr += defstr_len;
+ }
+ (*to_left) -= defstr_len;
+
+ unconv_num++;
+
+ } else {
+ mb = gi_to_mb(glyph_index, codeset);
+ if (codeset->parse_info) {
+ Bool need_shift = False;
+ switch (codeset->parse_info->type) {
+ case E_LSL :
+ if (codeset != state->GL_codeset) {
+ need_shift = True;
+ state->GL_codeset = codeset;
+ }
+ break;
+ case E_LSR :
+ if (codeset != state->GR_codeset) {
+ need_shift = True;
+ state->GR_codeset = codeset;
+ }
+ break;
+ /* case E_SS */
+ default:
+ need_shift = True;
+ }
+
+ /* output shift sequence */
+ if (need_shift) {
+ encoding = codeset->parse_info->encoding;
+ length = strlen(encoding);
+ if (*to_left < length)
+ break;
+ if (outbufptr) {
+ strncpy((char *)outbufptr, encoding, length);
+ outbufptr += length;
+ }
+ (*to_left) -= length;
+ }
+ }
+
+ /* output characters */
+ length = codeset->length;
+ if (*to_left < length)
+ break;
+
+ if (outbufptr) {
+ output_ulong_value(outbufptr, mb, length, XlcNONE);
+ outbufptr += length;
+ }
+
+ (*to_left) -= length;
+ }
+
+ } /* end of while */
+
+ *from = (XPointer) ((const wchar_t *) *from + from_size);
+ *from_left = 0;
+ *to = (XPointer) outbufptr;
+
+ return unconv_num;
+}
+
+static int
+stdc_wcstombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const wchar_t *src = *((const wchar_t **) from);
+ char *dst = *((char **) to);
+ int src_left = *from_left;
+ int dst_left = *to_left;
+ int length, unconv_num = 0;
+
+ while (src_left > 0 && dst_left >= MB_CUR_MAX) {
+ length = wctomb(dst, *src); /* XXX */
+
+ if (length > 0) {
+ src++;
+ src_left--;
+ if (dst)
+ dst += length;
+ dst_left -= length;
+ } else if (length < 0) {
+ src++;
+ src_left--;
+ unconv_num++;
+ }
+ }
+
+ *from = (XPointer) src;
+ if (dst)
+ *to = (XPointer) dst;
+ *from_left = src_left;
+ *to_left = dst_left;
+
+ return unconv_num;
+}
+
+static int
+wcstocts(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ unsigned long glyph_index;
+ wchar_t wc;
+
+ int total_len, seq_len, name_len;
+ int unconv_num = 0;
+ Bool first_flag = True, standard_flag;
+ XlcSide side;
+
+ CodeSet codeset;
+ XlcCharSet charset, old_charset = NULL;
+ const char *ct_sequence;
+
+ const wchar_t *inbufptr = (const wchar_t *) *from;
+ char *outbufptr = *to;
+ int from_size = *from_left;
+ char *ext_seg_len = NULL;
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ wc = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!wc) {
+ if (outbufptr) {*outbufptr++ = '\0';}
+ (*to_left)--;
+
+ continue;
+ }
+
+ /* convert */
+ if ( !wc_to_gi(lcd, wc, &glyph_index, &codeset) ) {
+ unconv_num++;
+ continue;
+ }
+
+ /* parse charset */
+ if ( !(charset = gi_parse_charset(glyph_index, codeset)) ) {
+ unconv_num++;
+ continue;
+ }
+
+ /* Standard Character Set Encoding ? */
+ standard_flag = charset->source == CSsrcStd ? True : False;
+
+ /*
+ * Non-Standard Character Set Encoding
+ *
+ * +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+
+ * | esc sequence | M | L | encoding name | STX |
+ * +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+
+ * 4bytes 1byte 1byte variable length 1byte
+ * | |
+ * +-----------------------------------------+
+ * name length = ((M - 128) * 128) + (L - 128)
+ */
+
+ /* make encoding data */
+ ct_sequence = charset->ct_sequence;
+ side = charset->side;
+ seq_len = strlen(ct_sequence);
+ if (standard_flag) {
+ name_len = 0;
+ total_len = seq_len;
+ } else {
+ name_len = strlen(charset->encoding_name) + 1;
+ total_len = seq_len + name_len + 2;
+ }
+
+ /* output escape sequence of CT */
+ if ( (charset != old_charset) &&
+ !(first_flag && charset->string_encoding) ){
+
+ if ( (ext_seg_len != NULL) && outbufptr) {
+ int i = (outbufptr - ext_seg_len) - 2;
+ *ext_seg_len++ = i / 128 + 128;
+ *ext_seg_len = i % 128 + 128;
+ ext_seg_len = NULL;
+ }
+
+ if (*to_left < total_len + 1) {
+ unconv_num++;
+ break;
+ }
+
+ if (outbufptr) {
+ strcpy((char *)outbufptr, ct_sequence);
+ outbufptr += seq_len;
+
+ if (!standard_flag) {
+ const char *i = charset->encoding_name;
+ ext_seg_len = outbufptr;
+ outbufptr += 2;
+ for (; *i ; i++)
+ *outbufptr++ = ((*i >= 'A') && (*i <= 'Z')) ?
+ *i - 'A' + 'a' : *i;
+ *outbufptr++ = STX;
+ }
+ }
+
+ (*to_left) -= total_len;
+
+ first_flag = False;
+ old_charset = charset;
+ }
+
+ /* output glyph index */
+ if (codeset->ctconv)
+ glyph_index = conv_to_dest(codeset->ctconv, glyph_index);
+ if (*to_left < charset->char_size) {
+ unconv_num++;
+ break;
+ }
+
+ if (outbufptr) {
+ output_ulong_value(outbufptr, glyph_index, charset->char_size, side);
+ outbufptr += charset->char_size;
+ }
+
+ (*to_left) -= charset->char_size;
+
+ } /* end of while */
+
+ if ( (ext_seg_len != NULL) && outbufptr) {
+ int i = (outbufptr - ext_seg_len) - 2;
+ *ext_seg_len++ = i / 128 + 128;
+ *ext_seg_len = i % 128 + 128;
+ }
+
+ *from = (XPointer) ((const wchar_t *) *from + from_size);
+ *from_left = 0;
+ *to = (XPointer) outbufptr;
+
+ return unconv_num;
+}
+
+static int
+stdc_wcstocts(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
+ char *buf_ptr1 = buf;
+ int buf_left1 = (*from_left) * MB_CUR_MAX;
+ char *buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = stdc_wcstombs(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = buf_ptr1 - buf_ptr2;
+
+ unconv_num2 = mbstocts(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+static int
+ctstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ unsigned char ch;
+ unsigned long glyph_index = 0;
+ wchar_t wc;
+
+ int ctr_seq_len = 0, gi_len_left = 0, gi_len = 0;
+ int unconv_num = 0;
+
+ CodeSet codeset = NULL;
+ XlcCharSet charset_tmp;
+
+ const char *inbufptr = *from;
+ wchar_t *outbufptr = (wchar_t *) *to;
+ int from_size = *from_left;
+
+ _XlcResetConverter(conv); /* ??? */
+
+ if (from == NULL || *from == NULL) {
+ _XlcResetConverter(conv);
+ return( 0 );
+ }
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ ch = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!ch) {
+ if (outbufptr) {*outbufptr++ = L'\0';}
+ (*to_left)--;
+
+ /* error check */
+ if (gi_len_left) {
+ unconv_num += (gi_len - gi_len_left);
+ gi_len_left = 0;
+ }
+
+ continue;
+ }
+
+ /* same glyph_index data */
+ if (gi_len_left)
+ goto output_one_wc;
+
+ /* control sequence ? */
+ if (ch == CSI) {
+ if ( !ct_parse_csi(inbufptr - 1, &ctr_seq_len) )
+ goto skip_the_seg;
+
+ if (*from_left + 1 < ctr_seq_len) {
+ inbufptr--;
+ (*from_left)++;
+ unconv_num += *from_left;
+ break;
+ }
+
+ /* skip the control sequence */
+ inbufptr += (ctr_seq_len - 1);
+ *from_left -= (ctr_seq_len - 1);
+
+ continue;
+ }
+
+ /* escape sequence ? */
+ if (ch == ESC) {
+ if ( !ct_parse_charset(lcd,
+ inbufptr - 1, &state->charset, &ctr_seq_len) )
+ goto skip_the_seg;
+
+ if (state->charset->side == XlcC0 ||
+ state->charset->side == XlcGL)
+ {
+ state->GL_charset = state->charset;
+ }
+ else if (state->charset->side == XlcC1 ||
+ state->charset->side == XlcGR)
+ {
+ state->GR_charset = state->charset;
+ }
+ else if (state->charset->side == XlcGLGR)
+ {
+ state->GL_charset = state->charset;
+ state->GR_charset = state->charset;
+ }
+
+ if (*from_left + 1 < ctr_seq_len) {
+ inbufptr--;
+ (*from_left)++;
+ unconv_num += *from_left;
+ break;
+ }
+
+ /* skip the escape sequence */
+ inbufptr += (ctr_seq_len - 1);
+ *from_left -= (ctr_seq_len - 1);
+
+ continue;
+ }
+
+ /* check current state */
+ if (isleftside(ch))
+ state->charset = state->GL_charset;
+ else
+ state->charset = state->GR_charset;
+
+ gi_len = gi_len_left = state->charset->char_size;
+ glyph_index = 0;
+
+output_one_wc:
+ if (state->charset->side == XlcC1 || state->charset->side == XlcGR)
+ glyph_index = (glyph_index << 8) | (ch & GL);
+ else
+ glyph_index = (glyph_index << 8) | ch;
+
+ gi_len_left--;
+
+ /* last of one glyph_index data */
+ if (!gi_len_left) {
+
+ /* segment conversion */
+ charset_tmp = state->charset;
+ segment_conversion(lcd, &charset_tmp, &glyph_index);
+
+ /* get codeset */
+ if ( !_XlcGetCodeSetFromCharSet(lcd, charset_tmp,
+ &codeset, &glyph_index) ) {
+ unconv_num += gi_len;
+ continue;
+ }
+
+ /* convert glyph index to wicd char */
+ gi_to_wc(lcd, glyph_index, codeset, &wc);
+ if (outbufptr) {*outbufptr++ = wc;}
+ (*to_left)--;
+ }
+
+ continue;
+
+skip_the_seg:
+ /* skip until next escape or control sequence */
+ while ( *from_left ) {
+ ch = *inbufptr++;
+ (*from_left)--;
+ unconv_num++;
+
+ if (ch == ESC || ch == CSI) {
+ inbufptr--;
+ (*from_left)++;
+ unconv_num--;
+ break;
+ }
+ }
+
+ if ( !(*from_left) )
+ break;
+
+ } /* end of while */
+
+ /* error check on last char */
+ if (gi_len_left) {
+ inbufptr -= (gi_len - gi_len_left);
+ (*from_left) += (gi_len - gi_len_left);
+ unconv_num += (gi_len - gi_len_left);
+ }
+
+ *from = (XPointer) ((const char *) *from + from_size);
+ *from_left = 0;
+ *to = (XPointer) outbufptr;
+
+ return unconv_num;
+}
+
+static int
+cstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ unsigned char ch;
+ unsigned long glyph_index = 0;
+ wchar_t wc;
+ int gi_len_left = 0, gi_len = 0;
+
+ int unconv_num = 0;
+
+ CodeSet codeset = NULL;
+ XlcCharSet charset, charset_tmp;
+
+ const char *inbufptr = *from;
+ wchar_t *outbufptr = (wchar_t *) *to;
+ int from_size = *from_left;
+
+ if (from == NULL || *from == NULL) {
+ return( 0 );
+ }
+
+ charset = (XlcCharSet) args[0];
+
+ while (*from_left && *to_left) {
+
+ if (!gi_len_left) {
+ gi_len_left = gi_len = charset->char_size;
+ glyph_index = 0;
+ }
+
+ ch = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!ch) {
+ if (outbufptr) {*outbufptr++ = L'\0';}
+ (*to_left)--;
+
+ /* error check */
+ if (gi_len_left) {
+ unconv_num += (gi_len - gi_len_left);
+ gi_len_left = 0;
+ }
+ continue;
+ }
+
+ if (charset->side == XlcC1 || charset->side == XlcGR)
+ glyph_index = (glyph_index << 8) | (ch & GL);
+ else
+ glyph_index = (glyph_index << 8) | ch;
+
+ gi_len_left--;
+
+ /* last of one glyph_index data */
+ if (!gi_len_left) {
+
+ /* segment conversion */
+ charset_tmp = charset;
+ segment_conversion(lcd, &charset_tmp, &glyph_index);
+
+ /* get codeset */
+ if ( !_XlcGetCodeSetFromCharSet(lcd, charset_tmp,
+ &codeset, &glyph_index) ) {
+ unconv_num += gi_len;
+ continue;
+ }
+
+ /* convert glyph index to wicd char */
+ gi_to_wc(lcd, glyph_index, codeset, &wc);
+ if (outbufptr) {*outbufptr++ = wc;}
+ (*to_left)--;
+ }
+
+ } /* end of while */
+
+ /* error check on last char */
+ if (gi_len_left) {
+ inbufptr -= (gi_len - gi_len_left);
+ (*from_left) += (gi_len - gi_len_left);
+ unconv_num += (gi_len - gi_len_left);
+ }
+
+ *from = (XPointer) ((const char *) *from + from_size);
+ *from_left = 0;
+ *to = (XPointer) outbufptr;
+
+ return unconv_num;
+}
+
+static int
+stdc_ctstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
+ char *buf_ptr1 = buf;
+ int buf_left1 = (*from_left) * MB_CUR_MAX;
+ char *buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = ctstombs(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = buf_ptr1 - buf_ptr2;
+
+ unconv_num2 = stdc_mbstowcs(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+static int
+stdc_cstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
+ char *buf_ptr1 = buf;
+ int buf_left1 = (*from_left) * MB_CUR_MAX;
+ char *buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = cstombs(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = buf_ptr1 - buf_ptr2;
+
+ unconv_num2 = stdc_mbstowcs(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+static int
+mbstocts(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XPointer buf = Xmalloc((*from_left) * sizeof(wchar_t));
+ char *buf_ptr1 = buf;
+ int buf_left1 = (*from_left);
+ char *buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = mbstowcs_org(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = (buf_ptr1 - buf_ptr2) / sizeof(wchar_t);
+
+ unconv_num2 += wcstocts(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+static int
+mbstostr(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ unsigned char ch;
+ unsigned long mb = 0;
+
+ int length = 0, len_left = 0;
+ int unconv_num = 0;
+ int num;
+
+ CodeSet codeset = NULL;
+
+ const char *inbufptr = *from;
+ char *outbufptr = *to;
+ int from_size = *from_left;
+
+ unsigned char *mb_parse_table = XLC_GENERIC(lcd, mb_parse_table);
+
+ if (from == NULL || *from == NULL) {
+ _XlcResetConverter(conv);
+ return( 0 );
+ }
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ ch = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!ch) {
+ if (outbufptr) {*outbufptr++ = '\0';}
+ (*to_left)--;
+
+ /* error check */
+ if (len_left) {
+ unconv_num += (length - len_left);
+ len_left = 0;
+ }
+
+ continue;
+ }
+
+ /* same mb char data */
+ if (len_left)
+ goto output_one_mb;
+
+ /* next mb char data for single shift ? */
+ if (mb_parse_table && (num = mb_parse_table[ch]) ) {
+ codeset = mb_parse_codeset(state, num, &inbufptr, from_left);
+ if (codeset != NULL) {
+ length = len_left = codeset->length;
+ mb = 0;
+ continue;
+ }
+ }
+
+ /* next char data : byteM ? */
+ if ((codeset = byteM_parse_codeset(lcd, (inbufptr - 1))))
+ goto next_mb_char;
+
+ /* next char data : GL or GR side ? */
+ if ((codeset = GLGR_parse_codeset(ch)))
+ goto next_mb_char;
+
+ /* can't find codeset for the ch */
+ unconv_num++;
+ continue;
+
+next_mb_char:
+ length = len_left = codeset->length;
+ mb = 0;
+
+output_one_mb:
+ mb = (mb << 8) | ch; /* 1 byte left shift */
+ len_left--;
+
+ /* last of one mb char data */
+ if (!len_left) {
+ if (check_string_encoding(codeset)) {
+ if (outbufptr) {*outbufptr++ = mb & 0xff;}
+ (*to_left)--;
+ } else {
+ unconv_num++;
+ }
+ }
+
+ } /* end of while */
+
+ /* error check on last char */
+ if (len_left) {
+ inbufptr -= (length - len_left);
+ (*from_left) += (length - len_left);
+ unconv_num += (length - len_left);
+ }
+
+ *from = (XPointer) ((const char *) *from + from_size);
+ *from_left = 0;
+ *to = (XPointer) outbufptr;
+
+ return unconv_num;
+}
+
+static int
+mbtocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ unsigned char ch;
+ unsigned long mb = 0;
+ unsigned long glyph_index;
+
+ int length = 0, len_left = 0, char_len;
+ int unconv_num = 0;
+ int num;
+ XlcSide side;
+
+ CodeSet codeset = NULL;
+ XlcCharSet charset = NULL;
+
+ const char *inbufptr = *from;
+ char *outbufptr = *to;
+ int from_size = *from_left;
+
+ unsigned char *mb_parse_table = XLC_GENERIC(lcd, mb_parse_table);
+
+ if (from == NULL || *from == NULL) {
+ _XlcResetConverter(conv);
+ return( 0 );
+ }
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ ch = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!ch) {
+ unconv_num = 1;
+ if (len_left)
+ unconv_num += (length - len_left);
+ break;
+ }
+
+ /* same mb char data */
+ if (len_left)
+ goto output;
+
+ /* next mb char data for single shift ? */
+ if (mb_parse_table && (num = mb_parse_table[ch]) ) {
+ codeset = mb_parse_codeset(state, num, &inbufptr, from_left);
+ if (codeset != NULL) {
+ length = len_left = codeset->length;
+ mb = 0;
+ continue;
+ }
+ }
+
+ /* next mb char data for byteM ? */
+ if ((codeset = byteM_parse_codeset(lcd, (inbufptr - 1))))
+ goto next_mb_char;
+
+ /* next mb char data for GL or GR side ? */
+ if ((codeset = GLGR_parse_codeset(ch)))
+ goto next_mb_char;
+
+ /* can't find codeset for the ch */
+ unconv_num = 1;
+ break;
+
+next_mb_char:
+ length = len_left = codeset->length;
+ mb = 0;
+
+output:
+ mb = (mb << 8) | ch; /* 1 byte left shift */
+ len_left--;
+
+ /* last of one mb char data */
+ if (!len_left) {
+ glyph_index = mb_to_gi(mb, codeset);
+ if (!(charset = gi_parse_charset(glyph_index, codeset))) {
+ unconv_num = length;
+ break;
+ }
+ char_len = charset->char_size;
+ side = charset->side;
+
+ /* output glyph index */
+ if (codeset->ctconv)
+ glyph_index = conv_to_dest(codeset->ctconv, glyph_index);
+ if (*to_left < char_len) {
+ unconv_num = length;
+ break;
+ }
+
+ if (outbufptr) {
+ output_ulong_value(outbufptr, glyph_index, char_len, side);
+ outbufptr += char_len;
+ }
+
+ (*to_left) -= char_len;
+
+ break;
+ }
+
+ } /* end of while */
+
+ /* error end */
+ if (unconv_num) {
+ *from = (XPointer) ((const char *) *from + from_size);
+ *from_left = 0;
+ *to = (XPointer) outbufptr;
+ return -1;
+ }
+
+ /* nomal end */
+ *from = (XPointer) inbufptr;
+ *to = (XPointer) outbufptr;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return 0;
+}
+
+static int
+mbstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ int ret;
+ XlcCharSet charset_old, charset = NULL;
+ XPointer tmp_args[1];
+
+ const char *inbufptr;
+ int in_left;
+ char *outbufptr;
+ int out_left;
+ tmp_args[0] = (XPointer) &charset;
+
+ ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, 1);
+ charset_old = charset;
+
+ while ( ret == 0 && *from_left && *to_left) {
+ inbufptr = *from;
+ in_left = *from_left;
+ outbufptr = *to;
+ out_left = *to_left;
+ ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, 1);
+ if (charset_old != charset) {
+ *from = (XPointer) inbufptr;
+ *from_left = in_left;
+ *to = (XPointer) outbufptr;
+ *to_left = out_left;
+ break;
+ }
+ }
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset_old;
+
+ /* error end */
+ if (ret != 0)
+ return( -1 );
+
+ return(0);
+}
+
+static int
+wcstostr(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ char *encoding;
+ unsigned long mb, glyph_index;
+ wchar_t wc;
+
+ int length;
+ int unconv_num = 0;
+
+ CodeSet codeset;
+
+ const wchar_t *inbufptr = (const wchar_t *) *from;
+ char *outbufptr = *to;
+ int from_size = *from_left;
+
+ const char *default_string = XLC_PUBLIC(lcd, default_string);
+ int defstr_len = strlen(default_string);
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ wc = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!wc) {
+ if (outbufptr) {*outbufptr++ = '\0';}
+ (*to_left)--;
+
+ continue;
+ }
+
+ /* convert */
+ if ( !wc_to_gi(lcd, wc, &glyph_index, &codeset) ) {
+
+ /* output default_string of XDefaultString() */
+ if (*to_left < defstr_len)
+ break;
+ if (outbufptr) {
+ strncpy((char *)outbufptr, default_string, defstr_len);
+ outbufptr += defstr_len;
+ }
+ (*to_left) -= defstr_len;
+
+ unconv_num++;
+
+ } else {
+ mb = gi_to_mb(glyph_index, codeset);
+
+ if (check_string_encoding(codeset)) {
+ if (codeset->parse_info) {
+ Bool need_shift = False;
+ switch (codeset->parse_info->type) {
+ case E_LSL :
+ if (codeset != state->GL_codeset) {
+ need_shift = True;
+ state->GL_codeset = codeset;
+ }
+ break;
+ case E_LSR :
+ if (codeset != state->GR_codeset) {
+ need_shift = True;
+ state->GR_codeset = codeset;
+ }
+ break;
+ /* case E_SS */
+ default:
+ need_shift = True;
+ }
+
+ /* output shift sequence */
+ if (need_shift) {
+ encoding = codeset->parse_info->encoding;
+ length = strlen(encoding);
+ if (*to_left < length)
+ break;
+
+ if (outbufptr) {
+ strncpy((char *)outbufptr, encoding, length);
+ outbufptr += length;
+ }
+ (*to_left) -= length;
+ }
+ }
+
+ /* output characters */
+ length = codeset->length;
+ if (*to_left < length)
+ break;
+
+ if (outbufptr) {
+ output_ulong_value(outbufptr, mb, length, XlcNONE);
+ outbufptr += length;
+ }
+
+ (*to_left) -= length;
+ } else {
+ unconv_num++;
+ }
+ }
+
+ } /* end of while */
+
+ *from = (XPointer) ((const wchar_t *) *from + from_size);
+ *from_left = 0;
+ *to = (XPointer) outbufptr;
+
+ return unconv_num;
+}
+
+static int
+stdc_wcstostr(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
+ char *buf_ptr1 = buf;
+ int buf_left1 = (*from_left) * MB_CUR_MAX;
+ char *buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = stdc_wcstombs(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = buf_ptr1 - buf_ptr2;
+
+ unconv_num2 = mbstostr(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+static int
+wctocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ wchar_t wc;
+ unsigned long glyph_index;
+
+ int char_len;
+ int unconv_num = 0;
+ XlcSide side;
+
+ CodeSet codeset;
+ XlcCharSet charset = NULL;
+
+ const wchar_t *inbufptr = (const wchar_t *) *from;
+ char *outbufptr = *to;
+ int from_size = *from_left;
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ if (*from_left && *to_left) {
+
+ wc = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!wc) {
+ unconv_num = 1;
+ goto end;
+ }
+
+ /* convert */
+ if ( !wc_to_gi(lcd, wc, &glyph_index, &codeset) ) {
+ unconv_num = 1;
+ goto end;
+ }
+
+ if ( !(charset = gi_parse_charset(glyph_index, codeset)) ) {
+ unconv_num = 1;
+ goto end;
+ }
+ char_len = charset->char_size;
+ side = charset->side;
+
+ /* output glyph index */
+ if (codeset->ctconv)
+ glyph_index = conv_to_dest(codeset->ctconv, glyph_index);
+ if (*to_left < char_len) {
+ unconv_num++;
+ goto end;
+ }
+
+ if (outbufptr) {
+ output_ulong_value(outbufptr, glyph_index, char_len, side);
+ outbufptr += char_len;
+ }
+
+ (*to_left) -= char_len;
+
+ }
+
+end:
+
+ /* error end */
+ if (unconv_num) {
+ *from = (XPointer) ((const wchar_t *) *from + from_size);
+ *from_left = 0;
+ *to = (XPointer) outbufptr;
+ return -1;
+ }
+
+ /* nomal end */
+ *from = (XPointer) inbufptr;
+ *to = (XPointer) outbufptr;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return 0;
+}
+
+static int
+stdc_wctocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const wchar_t *src = *((const wchar_t **) from);
+ wchar_t wch;
+ XPointer tmp_from, save_from = *from;
+ char tmp[32];
+ int length, ret, src_left = *from_left;
+ int from_size = *from_left;
+
+ if (src_left > 0 && *to_left > 0) {
+ if ((wch = *src)) {
+ length = wctomb(tmp, wch);
+ } else {
+ goto end;
+ }
+
+ if (length < 0)
+ goto end;
+
+ tmp_from = (XPointer) tmp;
+ ret = mbtocs(conv, &tmp_from, &length, to, to_left, args, num_args);
+ if (ret < 0)
+ goto end;
+
+ src++;
+ src_left--;
+ }
+
+end:
+ /* error end */
+ if (save_from == (XPointer) src) {
+ *from = (XPointer) ((const wchar_t *) *from + from_size);
+ *from_left = 0;
+ return -1;
+ }
+
+ /* nomal end */
+ *from = (XPointer) src;
+ *from_left = src_left;
+
+ return 0;
+}
+
+static int
+wcstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ int ret;
+ XlcCharSet charset_old, charset = NULL;
+ XPointer tmp_args[1];
+
+ const wchar_t *inbufptr;
+ int in_left;
+ XPointer outbufptr;
+ int out_left;
+ tmp_args[0] = (XPointer) &charset;
+
+ ret = wctocs(conv, from, from_left, to, to_left, tmp_args, 1);
+ charset_old = charset;
+
+ while ( ret == 0 && *from_left && *to_left) {
+ inbufptr = (const wchar_t *) *from;
+ in_left = *from_left;
+ outbufptr = *to;
+ out_left = *to_left;
+ ret = wctocs(conv, from, from_left, to, to_left, tmp_args, 1);
+ if (charset_old != charset) {
+ *from = (XPointer) inbufptr;
+ *from_left = in_left;
+ *to = (XPointer) outbufptr;
+ *to_left = out_left;
+ break;
+ }
+ }
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset_old;
+
+ /* error end */
+ if (ret != 0)
+ return( -1 );
+
+ return(0);
+}
+
+#ifdef STDCVT
+
+static int
+stdc_wcstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ int ret;
+ XlcCharSet charset_old, charset = NULL;
+ XPointer tmp_args[1];
+
+ const wchar_t *inbufptr;
+ int in_left;
+ XPointer outbufptr;
+ int out_left;
+ tmp_args[0] = (XPointer) &charset;
+
+ ret = stdc_wctocs(conv, from, from_left, to, to_left, tmp_args, 1);
+ charset_old = charset;
+
+ while ( ret == 0 && *from_left && *to_left ) {
+ inbufptr = (const wchar_t *) *from;
+ in_left = *from_left;
+ outbufptr = *to;
+ out_left = *to_left;
+ ret = stdc_wctocs(conv, from, from_left, to, to_left, tmp_args, 1);
+ if (charset_old != charset) {
+ *from = (XPointer) inbufptr;
+ *from_left = in_left;
+ *to = (XPointer) outbufptr;
+ *to_left = out_left;
+ break;
+ }
+ }
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset_old;
+
+ /* error end */
+ if (ret != 0)
+ return( -1 );
+
+ return(0);
+}
+
+#endif
+
+static int
+ctstombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XPointer buf = Xmalloc((*from_left) * sizeof(wchar_t));
+ char *buf_ptr1 = buf;
+ int buf_left1 = (*from_left);
+ char *buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = ctstowcs(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = (buf_ptr1 - buf_ptr2) / sizeof(wchar_t);
+
+ unconv_num2 += wcstombs_org(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+static int
+cstombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XPointer buf = Xmalloc((*from_left) * sizeof(wchar_t));
+ char *buf_ptr1 = buf;
+ int buf_left1 = (*from_left);
+ char *buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = cstowcs(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = (buf_ptr1 - buf_ptr2) / sizeof(wchar_t);
+
+ unconv_num2 += wcstombs_org(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+static int
+strtombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ char *encoding;
+ unsigned long mb, glyph_index;
+ unsigned char ch;
+
+ int length;
+ int unconv_num = 0;
+
+ CodeSet codeset;
+
+ const char *inbufptr = *from;
+ char *outbufptr = *to;
+ int from_size = *from_left;
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ ch = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!ch) {
+ if (outbufptr) {*outbufptr++ = '\0';}
+ (*to_left)--;
+
+ continue;
+ }
+
+ /* convert */
+ if (isleftside(ch)) {
+ glyph_index = ch;
+ codeset = _XlcGetCodeSetFromName(lcd, "ISO8859-1:GL");
+ } else {
+ glyph_index = ch & GL;
+ codeset = _XlcGetCodeSetFromName(lcd, "ISO8859-1:GR");
+ }
+
+ if (!codeset) {
+ unconv_num++;
+ continue;
+ }
+
+ mb = gi_to_mb(glyph_index, codeset);
+ if (codeset->parse_info) {
+ Bool need_shift = False;
+ switch (codeset->parse_info->type) {
+ case E_LSL :
+ if (codeset != state->GL_codeset) {
+ need_shift = True;
+ state->GL_codeset = codeset;
+ }
+ break;
+ case E_LSR :
+ if (codeset != state->GR_codeset) {
+ need_shift = True;
+ state->GR_codeset = codeset;
+ }
+ break;
+ /* case E_SS */
+ default:
+ need_shift = True;
+ }
+
+ /* output shift sequence */
+ if (need_shift) {
+ encoding = codeset->parse_info->encoding;
+ length = strlen(encoding);
+ if (*to_left < length)
+ break;
+ if (outbufptr) {
+ strncpy((char *)outbufptr, encoding, length);
+ outbufptr += length;
+ }
+ (*to_left) -= length;
+ }
+ }
+
+ /* output characters */
+ length = codeset->length;
+ if (*to_left < length)
+ break;
+
+ if (outbufptr) {
+ output_ulong_value(outbufptr, mb, length, XlcNONE);
+ outbufptr += length;
+ }
+
+ (*to_left) -= length;
+
+ } /* end of while */
+
+ *from = (XPointer) ((const char *) *from + from_size);
+ *from_left = 0;
+ *to = (XPointer) outbufptr;
+
+ return unconv_num;
+}
+
+static int
+strtowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ unsigned char ch;
+ unsigned long glyph_index;
+ wchar_t wc;
+
+ int unconv_num = 0;
+ CodeSet codeset;
+
+ const char *inbufptr = *from;
+ wchar_t *outbufptr = (wchar_t *)*to;
+ int from_size = *from_left;
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ ch = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!ch) {
+ if (outbufptr) {*outbufptr++ = L'\0';}
+ (*to_left)--;
+
+ continue;
+ }
+
+ /* convert */
+ if (isleftside(ch)) {
+ glyph_index = ch;
+ codeset = _XlcGetCodeSetFromName(lcd, "ISO8859-1:GL");
+ } else {
+ glyph_index = ch & GL;
+ codeset = _XlcGetCodeSetFromName(lcd, "ISO8859-1:GR");
+ }
+
+ if (!codeset) {
+ unconv_num++;
+ continue;
+ }
+
+ gi_to_wc(lcd, glyph_index, codeset, &wc);
+ if (outbufptr) {*outbufptr++ = wc;}
+ (*to_left)--;
+
+ } /* end of while */
+
+ *from = (XPointer) ((const char *) *from + from_size);
+ *from_left = 0;
+ *to = (XPointer) outbufptr;
+
+ return unconv_num;
+}
+
+static int
+stdc_strtowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
+ char *buf_ptr1 = buf;
+ int buf_left1 = (*from_left) * MB_CUR_MAX;
+ char *buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = strtombs(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = buf_ptr1 - buf_ptr2;
+
+ unconv_num2 = stdc_mbstowcs(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+/* -------------------------------------------------------------------------- */
+/* Close */
+/* -------------------------------------------------------------------------- */
+
+static void
+close_converter(
+ XlcConv conv)
+{
+ if (conv->state) {
+ Xfree((char *) conv->state);
+ }
+
+ if (conv->methods) {
+ Xfree((char *) conv->methods);
+ }
+
+ Xfree((char *) conv);
+}
+
+/* -------------------------------------------------------------------------- */
+/* Open */
+/* -------------------------------------------------------------------------- */
+
+static XlcConv
+create_conv(
+ XLCd lcd,
+ XlcConvMethods methods)
+{
+ XlcConv conv;
+ State state;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (conv == NULL)
+ return (XlcConv) NULL;
+
+ conv->methods = (XlcConvMethods) Xmalloc(sizeof(XlcConvMethodsRec));
+ if (conv->methods == NULL)
+ goto err;
+ *conv->methods = *methods;
+ conv->methods->reset = init_state;
+
+ conv->state = (XPointer) Xmalloc(sizeof(StateRec));
+ if (conv->state == NULL)
+ goto err;
+ bzero((char *) conv->state, sizeof(StateRec));
+
+ state = (State) conv->state;
+ state->lcd = lcd;
+
+ _XlcResetConverter(conv);
+
+ return conv;
+
+err:
+ close_converter(conv);
+
+ return (XlcConv) NULL;
+}
+
+static XlcConvMethodsRec mbstocts_methods = {
+ close_converter,
+ mbstocts,
+ NULL
+};
+
+static XlcConv
+open_mbstocts(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &mbstocts_methods);
+}
+
+static XlcConvMethodsRec mbstostr_methods = {
+ close_converter,
+ mbstostr,
+ NULL
+};
+
+static XlcConv
+open_mbstostr(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &mbstostr_methods);
+}
+
+static XlcConvMethodsRec mbstocs_methods = {
+ close_converter,
+ mbstocs,
+ NULL
+};
+
+static XlcConv
+open_mbstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &mbstocs_methods);
+}
+
+static XlcConvMethodsRec mbtocs_methods = {
+ close_converter,
+ mbtocs,
+ NULL
+};
+
+static XlcConv
+open_mbtocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &mbtocs_methods);
+}
+
+static XlcConvMethodsRec ctstombs_methods = {
+ close_converter,
+ ctstombs,
+ NULL
+};
+
+static XlcConv
+open_ctstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &ctstombs_methods);
+}
+
+static XlcConvMethodsRec cstombs_methods = {
+ close_converter,
+ cstombs,
+ NULL
+};
+
+static XlcConv
+open_cstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &cstombs_methods);
+}
+
+static XlcConvMethodsRec strtombs_methods = {
+ close_converter,
+ strtombs,
+ NULL
+};
+
+static XlcConv
+open_strtombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &strtombs_methods);
+}
+
+#ifdef STDCVT
+
+static XlcConvMethodsRec stdc_mbstowcs_methods = {
+ close_converter,
+ stdc_mbstowcs,
+ NULL
+};
+
+static XlcConv
+open_stdc_mbstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &stdc_mbstowcs_methods);
+}
+
+static XlcConvMethodsRec stdc_wcstombs_methods = {
+ close_converter,
+ stdc_wcstombs,
+ NULL
+};
+
+static XlcConv
+open_stdc_wcstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &stdc_wcstombs_methods);
+}
+
+static XlcConvMethodsRec stdc_wcstocts_methods = {
+ close_converter,
+ stdc_wcstocts,
+ NULL
+};
+
+static XlcConv
+open_stdc_wcstocts(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &stdc_wcstocts_methods);
+}
+
+static XlcConvMethodsRec stdc_wcstostr_methods = {
+ close_converter,
+ stdc_wcstostr,
+ NULL
+};
+
+static XlcConv
+open_stdc_wcstostr(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &stdc_wcstostr_methods);
+}
+
+static XlcConvMethodsRec stdc_wcstocs_methods = {
+ close_converter,
+ stdc_wcstocs,
+ NULL
+};
+
+static XlcConv
+open_stdc_wcstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &stdc_wcstocs_methods);
+}
+
+static XlcConvMethodsRec stdc_wctocs_methods = {
+ close_converter,
+ stdc_wctocs,
+ NULL
+};
+
+static XlcConv
+open_stdc_wctocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &stdc_wctocs_methods);
+}
+
+static XlcConvMethodsRec stdc_ctstowcs_methods = {
+ close_converter,
+ stdc_ctstowcs,
+ NULL
+};
+
+static XlcConv
+open_stdc_ctstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &stdc_ctstowcs_methods);
+}
+
+static XlcConvMethodsRec stdc_cstowcs_methods = {
+ close_converter,
+ stdc_cstowcs,
+ NULL
+};
+
+static XlcConv
+open_stdc_cstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &stdc_cstowcs_methods);
+}
+
+static XlcConvMethodsRec stdc_strtowcs_methods = {
+ close_converter,
+ stdc_strtowcs,
+ NULL
+};
+
+static XlcConv
+open_stdc_strtowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &stdc_strtowcs_methods);
+}
+
+#endif /* STDCVT */
+
+static XlcConvMethodsRec mbstowcs_methods = {
+ close_converter,
+ mbstowcs_org,
+ NULL
+};
+
+static XlcConv
+open_mbstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &mbstowcs_methods);
+}
+
+static XlcConvMethodsRec wcstombs_methods = {
+ close_converter,
+ wcstombs_org,
+ NULL
+};
+
+static XlcConv
+open_wcstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &wcstombs_methods);
+}
+
+static XlcConvMethodsRec wcstocts_methods = {
+ close_converter,
+ wcstocts,
+ NULL
+};
+
+static XlcConv
+open_wcstocts(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &wcstocts_methods);
+}
+
+static XlcConvMethodsRec wcstostr_methods = {
+ close_converter,
+ wcstostr,
+ NULL
+};
+
+static XlcConv
+open_wcstostr(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &wcstostr_methods);
+}
+
+static XlcConvMethodsRec wcstocs_methods = {
+ close_converter,
+ wcstocs,
+ NULL
+};
+
+static XlcConv
+open_wcstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &wcstocs_methods);
+}
+
+static XlcConvMethodsRec wctocs_methods = {
+ close_converter,
+ wctocs,
+ NULL
+};
+
+static XlcConv
+open_wctocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &wctocs_methods);
+}
+
+static XlcConvMethodsRec ctstowcs_methods = {
+ close_converter,
+ ctstowcs,
+ NULL
+};
+
+static XlcConv
+open_ctstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &ctstowcs_methods);
+}
+
+static XlcConvMethodsRec cstowcs_methods = {
+ close_converter,
+ cstowcs,
+ NULL
+};
+
+static XlcConv
+open_cstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &cstowcs_methods);
+}
+
+static XlcConvMethodsRec strtowcs_methods = {
+ close_converter,
+ strtowcs,
+ NULL
+};
+
+static XlcConv
+open_strtowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &strtowcs_methods);
+}
+
+/* -------------------------------------------------------------------------- */
+/* Loader */
+/* -------------------------------------------------------------------------- */
+
+XLCd
+_XlcGenericLoader(
+ const char *name)
+{
+ XLCd lcd;
+#ifdef STDCVT
+ XLCdGenericPart *gen;
+#endif
+
+ lcd = _XlcCreateLC(name, _XlcGenericMethods);
+
+ if (lcd == NULL)
+ return lcd;
+
+ default_GL_charset = _XlcGetCharSet("ISO8859-1:GL");
+ default_GR_charset = _XlcGetCharSet("ISO8859-1:GR");
+
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_mbstocts);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNString, open_mbstostr);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs);
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte, open_ctstombs);
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_strtombs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs);
+
+#ifdef STDCVT
+ gen = XLC_GENERIC_PART(lcd);
+
+ if (gen->use_stdc_env != True) {
+#endif
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_mbstowcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstombs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstocts);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_wcstostr);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNChar, open_wctocs);
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar, open_ctstowcs);
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_strtowcs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
+#ifdef STDCVT
+ }
+#endif
+
+#ifdef STDCVT
+ if (gen->use_stdc_env == True) {
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_stdc_mbstowcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_stdc_wcstombs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_stdc_wcstocts);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_stdc_wcstostr);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_stdc_wcstocs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNChar, open_stdc_wctocs);
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar, open_stdc_ctstowcs);
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_stdc_strtowcs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_stdc_cstowcs);
+ }
+#endif
+
+ _XlcAddUtf8Converters(lcd);
+
+ return lcd;
+}
diff --git a/nx-X11/lib/X11/lcGeneric.c b/nx-X11/lib/X11/lcGeneric.c
new file mode 100644
index 000000000..dead30561
--- /dev/null
+++ b/nx-X11/lib/X11/lcGeneric.c
@@ -0,0 +1,1194 @@
+/* $Xorg: lcGeneric.c,v 1.7 2000/12/12 12:44:05 coskrey Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * (c) Copyright 1995 FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+/* $XFree86: xc/lib/X11/lcGeneric.c,v 3.19 2003/05/27 16:55:27 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "XlcGeneric.h"
+
+static XLCd create (const char *name, XLCdMethods methods);
+static Bool initialize (XLCd lcd);
+static void destroy (XLCd lcd);
+
+static XLCdPublicMethodsRec genericMethods = {
+ { NULL }, /* use default methods */
+ {
+ NULL,
+ create,
+ initialize,
+ destroy,
+ NULL
+ }
+};
+
+XLCdMethods _XlcGenericMethods = (XLCdMethods) &genericMethods;
+
+static XLCd
+create(
+ const char *name,
+ XLCdMethods methods)
+{
+ XLCd lcd;
+ XLCdPublicMethods new;
+
+ lcd = (XLCd) Xmalloc(sizeof(XLCdRec));
+ if (lcd == NULL)
+ return (XLCd) NULL;
+ bzero((char *) lcd, sizeof(XLCdRec));
+
+ lcd->core = (XLCdCore) Xmalloc(sizeof(XLCdGenericRec));
+ if (lcd->core == NULL)
+ goto err;
+ bzero((char *) lcd->core, sizeof(XLCdGenericRec));
+
+ new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec));
+ if (new == NULL)
+ goto err;
+ memcpy(new,methods,sizeof(XLCdPublicMethodsRec));
+ lcd->methods = (XLCdMethods) new;
+
+ return lcd;
+
+err:
+ Xfree(lcd);
+ return (XLCd) NULL;
+}
+
+static Bool
+string_to_encoding(
+ const char *str,
+ char *encoding)
+{
+ char *next;
+ long value;
+ int base;
+
+ while (*str) {
+ if (*str == '\\') {
+ switch (*(str + 1)) {
+ case 'x':
+ case 'X':
+ base = 16;
+ break;
+ default:
+ base = 8;
+ break;
+ }
+ value = strtol(str + 2, &next, base);
+ if (str + 2 != next) {
+ *((unsigned char *) encoding++) = (unsigned char) value;
+ str = next;
+ continue;
+ }
+ }
+ *encoding++ = *str++;
+ }
+
+ *encoding = '\0';
+
+ return True;
+}
+
+static Bool
+string_to_ulong(
+ const char *str,
+ unsigned long *value)
+{
+ const char *tmp1 = str;
+ int base;
+
+ if (*tmp1++ != '\\') {
+ tmp1--;
+ base = 10;
+ } else {
+ switch (*tmp1++) {
+ case 'x':
+ base = 16;
+ break;
+ case 'o':
+ base = 8;
+ break;
+ case 'd':
+ base = 10;
+ break;
+ default:
+ return(False);
+ }
+ }
+ *value = (unsigned long) strtol(tmp1, NULL, base);
+ return(True);
+}
+
+
+static Bool
+add_charset(
+ CodeSet codeset,
+ XlcCharSet charset)
+{
+ XlcCharSet *new_list;
+ int num;
+
+ if ((num = codeset->num_charsets))
+ new_list = (XlcCharSet *) Xrealloc(codeset->charset_list,
+ (num + 1) * sizeof(XlcCharSet));
+ else
+ new_list = (XlcCharSet *) Xmalloc(sizeof(XlcCharSet));
+
+ if (new_list == NULL)
+ return False;
+
+ new_list[num] = charset;
+ codeset->charset_list = new_list;
+ codeset->num_charsets = num + 1;
+
+ return True;
+}
+
+static CodeSet
+add_codeset(
+ XLCdGenericPart *gen)
+{
+ CodeSet new, *new_list;
+ int num;
+
+ new = (CodeSet) Xmalloc(sizeof(CodeSetRec));
+ if (new == NULL)
+ return NULL;
+ bzero((char *) new, sizeof(CodeSetRec));
+
+ if ((num = gen->codeset_num))
+ new_list = (CodeSet *) Xrealloc(gen->codeset_list,
+ (num + 1) * sizeof(CodeSet));
+ else
+ new_list = (CodeSet *) Xmalloc(sizeof(CodeSet));
+
+ if (new_list == NULL)
+ goto err;
+
+ new_list[num] = new;
+ gen->codeset_list = new_list;
+ gen->codeset_num = num + 1;
+
+ return new;
+
+err:
+ Xfree(new);
+
+ return NULL;
+}
+
+static Bool
+add_parse_list(
+ XLCdGenericPart *gen,
+ EncodingType type,
+ const char *encoding,
+ CodeSet codeset)
+{
+ ParseInfo new, *new_list;
+ char *str;
+ unsigned char ch;
+ int num;
+
+ str = (char *) Xmalloc(strlen(encoding) + 1);
+ if (str == NULL)
+ return False;
+ strcpy(str, encoding);
+
+ new = (ParseInfo) Xmalloc(sizeof(ParseInfoRec));
+ if (new == NULL)
+ goto err;
+ bzero((char *) new, sizeof(ParseInfoRec));
+
+ if (gen->mb_parse_table == NULL) {
+ gen->mb_parse_table = (unsigned char *) Xmalloc(256); /* 2^8 */
+ if (gen->mb_parse_table == NULL)
+ goto err;
+ bzero((char *) gen->mb_parse_table, 256);
+ }
+
+ if ((num = gen->mb_parse_list_num))
+ new_list = (ParseInfo *) Xrealloc(gen->mb_parse_list,
+ (num + 2) * sizeof(ParseInfo));
+ else {
+ new_list = (ParseInfo *) Xmalloc(2 * sizeof(ParseInfo));
+ }
+
+ if (new_list == NULL)
+ goto err;
+
+ new_list[num] = new;
+ new_list[num + 1] = NULL;
+ gen->mb_parse_list = new_list;
+ gen->mb_parse_list_num = num + 1;
+
+ ch = (unsigned char) *str;
+ if (gen->mb_parse_table[ch] == 0)
+ gen->mb_parse_table[ch] = num + 1;
+
+ new->type = type;
+ new->encoding = str;
+ new->codeset = codeset;
+
+ if (codeset->parse_info == NULL)
+ codeset->parse_info = new;
+
+ return True;
+
+err:
+ Xfree(str);
+ if (new)
+ Xfree(new);
+
+ return False;
+}
+
+static void
+free_charset(
+ XLCd lcd)
+{
+ XLCdGenericPart *gen = XLC_GENERIC_PART(lcd);
+ ParseInfo *parse_info;
+ int num;
+
+ if (gen->mb_parse_table)
+ Xfree(gen->mb_parse_table);
+ if ((num = gen->mb_parse_list_num) > 0) {
+ for (parse_info = gen->mb_parse_list; num-- > 0; parse_info++) {
+ if ((*parse_info)->encoding)
+ Xfree((*parse_info)->encoding);
+ Xfree(*parse_info);
+ }
+ Xfree(gen->mb_parse_list);
+ }
+
+ if ((num = gen->codeset_num) > 0)
+ Xfree(gen->codeset_list);
+}
+
+/* For VW/UDC */
+
+#define FORWARD (unsigned long)'+'
+#define BACKWARD (unsigned long)'-'
+
+static const char *
+getscope(
+ const char *str,
+ FontScope scp)
+{
+ unsigned long start = 0;
+ unsigned long end = 0;
+ unsigned long dest = 0;
+ unsigned long shift = 0;
+ unsigned long direction = 0;
+ sscanf(str,"[\\x%lx,\\x%lx]->\\x%lx", &start, &end, &dest);
+ if (dest) {
+ if (dest >= start) {
+ shift = dest - start;
+ direction = FORWARD ;
+ } else {
+ shift = start - dest;
+ direction = BACKWARD;
+ }
+ }
+ scp->start = start ;
+ scp->end = end ;
+ scp->shift = shift ;
+ scp->shift_direction
+ = direction ;
+ /* .......... */
+ while (*str) {
+ if (*str == ',' && *(str+1) == '[')
+ break;
+ str++;
+ }
+ return str+1;
+}
+
+static int
+count_scopemap(
+ const char *str)
+{
+ const char *ptr;
+ int num=0;
+ for (ptr=str; *ptr; ptr++) {
+ if (*ptr == ']') {
+ num++;
+ }
+ }
+ return num;
+}
+
+FontScope
+_XlcParse_scopemaps(
+ const char *str,
+ int *size)
+{
+ int num=0,i;
+ FontScope scope,sc_ptr;
+ const char *str_sc;
+
+ num = count_scopemap(str);
+ scope = (FontScope) Xmalloc(num * sizeof(FontScopeRec));
+ if (scope == NULL)
+ return NULL;
+
+ for (i=0, str_sc=str, sc_ptr=scope; i < num; i++, sc_ptr++) {
+ str_sc = getscope(str_sc, sc_ptr);
+ }
+ *size = num;
+ return scope;
+}
+
+void
+_XlcDbg_printValue(
+ const char *str,
+ char **value,
+ int num)
+{
+/*
+ int i;
+ for (i = 0; i < num; i++)
+ fprintf(stderr, "%s value[%d] = %s\n", str, i, value[i]);
+*/
+}
+
+static void
+dmpscope(
+ const char* name,
+ FontScope sc,
+ int num)
+{
+/*
+ int i;
+ fprintf(stderr, "dmpscope %s\n", name);
+ for (i=0; i<num; i++)
+ fprintf(stderr,"%x %x %x %x \n",
+ sc[i].start,
+ sc[i].end,
+ sc[i].shift,
+ sc[i].shift_direction);
+ fprintf(stderr, "dmpscope end\n");
+*/
+}
+
+static XlcCharSet
+srch_charset_define(
+ const char *name,
+ int *new)
+{
+ XlcCharSet charset;
+
+ *new = 0;
+ charset = _XlcGetCharSet(name);
+ if (charset == NULL &&
+ (charset = _XlcCreateDefaultCharSet(name, ""))) {
+ _XlcAddCharSet(charset);
+ *new = 1;
+ charset->source = CSsrcXLC;
+ }
+ return charset;
+}
+
+static void
+read_charset_define(
+ XLCd lcd,
+ XLCdGenericPart *gen)
+{
+ int i;
+ char csd[16], cset_name[256];
+ char name[BUFSIZ];
+ XlcCharSet charsetd;
+ char **value;
+ int num, new;
+ XlcSide side = XlcUnknown;
+ char *tmp;
+
+ for (i=0; ; i++) { /* loop start */
+ charsetd = 0;
+ sprintf(csd, "csd%d", i);
+
+ /* charset_name */
+ sprintf(name, "%s.%s", csd, "charset_name");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ _XlcDbg_printValue(name,value,num);
+ if (num > 0) {
+ /* hackers will get truncated -- C'est la vie */
+ strncpy(cset_name,value[0], sizeof cset_name - 1);
+ cset_name[(sizeof cset_name) - 1] = '\0';
+ sprintf(name, "%s.%s", csd , "side");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ if (!_XlcNCompareISOLatin1(value[0], "none", 4)) {
+ side = XlcGLGR;
+ } else if (!_XlcNCompareISOLatin1(value[0], "GL", 2)) {
+ side = XlcGL;
+ strcat(cset_name,":GL");
+ } else {
+ side = XlcGR;
+ strcat(cset_name,":GR");
+ }
+ if (charsetd == NULL &&
+ (charsetd = srch_charset_define(cset_name,&new)) == NULL)
+ return;
+ }
+ } else {
+ if (i == 0)
+ continue;
+ else
+ break;
+ }
+ if (new) {
+ tmp = (char *)Xmalloc(strlen(cset_name)+1);
+ if (tmp == NULL)
+ return;
+ strcpy(tmp,cset_name);
+ charsetd->name = tmp;
+ }
+ /* side */
+ charsetd->side = side ;
+ /* length */
+ sprintf(name, "%s.%s", csd, "length");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ charsetd->char_size = atoi(value[0]);
+ }
+ /* gc_number */
+ sprintf(name, "%s.%s", csd, "gc_number");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ charsetd->set_size = atoi(value[0]);
+ }
+ /* string_encoding */
+ sprintf(name, "%s.%s", csd, "string_encoding");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ if (!strcmp("False",value[0])) {
+ charsetd->string_encoding = False;
+ } else {
+ charsetd->string_encoding = True;
+ }
+ }
+ /* sequence */
+ sprintf(name, "%s.%s", csd, "sequence");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+/*
+ if (charsetd->ct_sequence) {
+ Xfree(charsetd->ct_sequence);
+ }
+*/
+ tmp = (char *)Xmalloc(strlen(value[0])+1);
+ if (tmp == NULL)
+ return;
+ charsetd->ct_sequence = tmp;
+ string_to_encoding(value[0],tmp);
+ }
+ /* encoding_name */
+ sprintf(name, "%s.%s", csd, "encoding_name");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+/*
+ if (charsetd->encoding_name) {
+ Xfree(charsetd->encoding_name);
+ }
+*/
+ tmp = (char *)Xmalloc(strlen(value[0])+1);
+ strcpy(tmp,value[0]);
+ charsetd->encoding_name = tmp;
+ charsetd->xrm_encoding_name = XrmStringToQuark(tmp);
+ }
+ _XlcAddCT(charsetd->name, charsetd->ct_sequence);
+ }
+}
+
+static SegConv
+add_conversion(
+ XLCdGenericPart *gen)
+{
+ SegConv new_list;
+ int num;
+
+ if ((num = gen->segment_conv_num) > 0) {
+ new_list = (SegConv) Xrealloc(gen->segment_conv,
+ (num + 1) * sizeof(SegConvRec));
+ } else {
+ new_list = (SegConv) Xmalloc(sizeof(SegConvRec));
+ }
+
+ if (new_list == NULL)
+ return NULL;
+
+ gen->segment_conv = new_list;
+ gen->segment_conv_num = num + 1;
+
+ return &new_list[num];
+
+}
+
+static void
+read_segmentconversion(
+ XLCd lcd,
+ XLCdGenericPart *gen)
+{
+ int i;
+ char conv[16];
+ char name[BUFSIZ];
+ char **value;
+ int num,new;
+ SegConv conversion;
+ for (i=0 ; ; i++) { /* loop start */
+ conversion = 0;
+ sprintf(conv, "conv%d", i);
+
+ /* length */
+ sprintf(name, "%s.%s", conv, "length");
+ _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
+ if (num > 0) {
+ if (conversion == NULL &&
+ (conversion = add_conversion(gen)) == NULL) {
+ return;
+ }
+ _XlcDbg_printValue(name,value,num);
+ } else {
+ if (i == 0)
+ continue;
+ else
+ break;
+ }
+ conversion->length = atoi(value[0]);
+
+ /* source_encoding */
+ sprintf(name, "%s.%s", conv, "source_encoding");
+ _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
+ if (num > 0) {
+ char *tmp;
+ _XlcDbg_printValue(name,value,num);
+ tmp = (char *)Xmalloc(strlen(value[0])+1);
+ if (tmp == NULL)
+ return;
+ strcpy(tmp,value[0]);
+ conversion->source_encoding = tmp;
+ conversion->source = srch_charset_define(tmp,&new);
+ }
+ /* destination_encoding */
+ sprintf(name, "%s.%s", conv, "destination_encoding");
+ _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
+ if (num > 0) {
+ char *tmp;
+ _XlcDbg_printValue(name,value,num);
+ tmp = (char *)Xmalloc(strlen(value[0])+1);
+ if (tmp == NULL)
+ return;
+ strcpy(tmp,value[0]);
+ conversion->destination_encoding = tmp;
+ conversion->dest = srch_charset_define(tmp,&new);
+ }
+ /* range */
+ sprintf(name, "%s.%s", conv, "range");
+ _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ sscanf(value[0],"\\x%lx,\\x%lx",
+ &(conversion->range.start), &(conversion->range.end));
+ }
+ /* conversion */
+ sprintf(name, "%s.%s", conv, "conversion");
+ _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ conversion->conv =
+ _XlcParse_scopemaps(value[0],&conversion->conv_num);
+ }
+ } /* loop end */
+}
+
+static ExtdSegment
+create_ctextseg(
+ char **value,
+ int num)
+{
+ ExtdSegment ret;
+ char* ptr;
+ char* cset_name = NULL;
+ int i,new;
+ FontScope scope;
+ ret = (ExtdSegment)Xmalloc(sizeof(ExtdSegmentRec));
+ if (ret == NULL)
+ return NULL;
+ ret->name = (char *)Xmalloc(strlen(value[0]) + 1);
+ if (ret->name == NULL) {
+ Xfree (ret);
+ return NULL;
+ }
+ strcpy(ret->name,value[0]);
+ cset_name = (char*) Xmalloc (strlen(ret->name) + 1);
+ if (cset_name == NULL) {
+ Xfree (ret->name);
+ Xfree (ret);
+ return NULL;
+ }
+ if (strchr(value[0],':')) {
+ ptr = strchr(ret->name,':');
+ *ptr = '\0';
+ ptr++;
+ if (!_XlcNCompareISOLatin1(ptr, "GL", 2)) {
+ ret->side = XlcGL;
+ sprintf(cset_name,"%s:%s",ret->name,"GL");
+ } else {
+ ret->side = XlcGR;
+ sprintf(cset_name,"%s:%s",ret->name,"GR");
+ }
+ } else {
+ ret->side = XlcGLGR;
+ strcpy(cset_name,ret->name);
+ }
+ ret->area = (FontScope)Xmalloc((num - 1)*sizeof(FontScopeRec));
+ if (ret->area == NULL) {
+ Xfree (cset_name);
+ Xfree (ret->name);
+ Xfree (ret);
+ return NULL;
+ }
+ ret->area_num = num - 1;
+ scope = ret->area ;
+ for (i = 1; i < num; i++) {
+ sscanf(value[i],"\\x%lx,\\x%lx",
+ &scope[i-1].start, &scope[i-1].end);
+ }
+ ret->charset = srch_charset_define(cset_name,&new);
+ Xfree (cset_name);
+
+ return ret;
+}
+/* For VW/UDC end */
+
+static Bool
+load_generic(
+ XLCd lcd)
+{
+ XLCdGenericPart *gen = XLC_GENERIC_PART(lcd);
+ char **value;
+ int num;
+ unsigned long l;
+ int i;
+ int M,ii;
+ XlcCharSet charset;
+
+ gen->codeset_num = 0;
+
+ /***** wc_encoding_mask *****/
+ _XlcGetResource(lcd, "XLC_XLOCALE", "wc_encoding_mask", &value, &num);
+ if (num > 0) {
+ if (string_to_ulong(value[0], &l) == False)
+ goto err;
+ gen->wc_encode_mask = l;
+ }
+ /***** wc_shift_bits *****/
+ _XlcGetResource(lcd, "XLC_XLOCALE", "wc_shift_bits", &value, &num);
+ if (num > 0)
+ gen->wc_shift_bits = atoi(value[0]);
+ if (gen->wc_shift_bits < 1)
+ gen->wc_shift_bits = 8;
+ /***** use_stdc_env *****/
+ _XlcGetResource(lcd, "XLC_XLOCALE", "use_stdc_env", &value, &num);
+ if (num > 0 && !_XlcCompareISOLatin1(value[0], "True"))
+ gen->use_stdc_env = True;
+ else
+ gen->use_stdc_env = False;
+ /***** force_convert_to_mb *****/
+ _XlcGetResource(lcd, "XLC_XLOCALE", "force_convert_to_mb", &value, &num);
+ if (num > 0 && !_XlcCompareISOLatin1(value[0], "True"))
+ gen->force_convert_to_mb = True;
+ else
+ gen->force_convert_to_mb = False;
+
+ for (i = 0; ; i++) {
+ CodeSetRec *codeset = NULL;
+ char cs[16];
+ char name[BUFSIZ];
+
+ sprintf(cs, "cs%d", i);
+
+ /***** codeset.side *****/
+ sprintf(name, "%s.%s", cs , "side");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ char *tmp;
+
+ if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)
+ goto err;
+
+ /* 3.4.1 side */
+ if (!_XlcNCompareISOLatin1(value[0], "none", 4)) {
+ codeset->side = XlcNONE;
+ } else if (!_XlcNCompareISOLatin1(value[0], "GL", 2)) {
+ codeset->side = XlcGL;
+ } else {
+ codeset->side = XlcGR;
+ }
+
+ tmp = strrchr(value[0], ':');
+ if (tmp != NULL && !_XlcCompareISOLatin1(tmp + 1, "Default")) {
+ if (codeset->side == XlcGR)
+ gen->initial_state_GR = codeset;
+ else
+ gen->initial_state_GL = codeset;
+ }
+ }
+
+ /***** codeset.length *****/
+ sprintf(name, "%s.%s", cs , "length");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)
+ goto err;
+ codeset->length = atoi(value[0]);
+ if (codeset->length < 1)
+ codeset->length = 1;
+ }
+
+ /***** codeset.mb_encoding *****/
+ sprintf(name, "%s.%s", cs, "mb_encoding");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ static struct {
+ const char *str;
+ EncodingType type;
+ } shifts[] = {
+ {"<SS>", E_SS},
+ {"<LSL>", E_LSL},
+ {"<LSR>", E_LSR},
+ {0}
+ };
+ int j;
+
+ if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)
+ goto err;
+ for ( ; num-- > 0; value++) {
+ char encoding[256];
+ char *tmp = *value;
+ EncodingType type = E_SS; /* for BC */
+ for (j = 0; shifts[j].str; j++) {
+ if (!_XlcNCompareISOLatin1(tmp, shifts[j].str,
+ strlen(shifts[j].str))) {
+ type = shifts[j].type;
+ tmp += strlen(shifts[j].str);
+ break;
+ }
+ }
+ if (strlen (tmp) > sizeof encoding ||
+ string_to_encoding(tmp, encoding) == False)
+ goto err;
+ add_parse_list(gen, type, encoding, codeset);
+ }
+ }
+
+ /***** codeset.wc_encoding *****/
+ sprintf(name, "%s.%s", cs, "wc_encoding");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)
+ goto err;
+ if (string_to_ulong(value[0], &l) == False)
+ goto err;
+ codeset->wc_encoding = l;
+ }
+
+ /***** codeset.ct_encoding *****/
+ sprintf(name, "%s.%s", cs, "ct_encoding");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ char *encoding;
+
+ if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)
+ goto err;
+ for ( ; num-- > 0; value++) {
+ if (strlen (*value) > sizeof name)
+ goto err;
+ string_to_encoding(*value, name);
+ charset = NULL;
+ if ((encoding = strchr(name, ':')) &&
+ (encoding = strchr(encoding + 1, ':'))) {
+ *encoding++ = '\0';
+ charset = _XlcAddCT(name, encoding);
+ }
+ if (charset == NULL) {
+ charset = _XlcGetCharSet(name);
+ if (charset == NULL &&
+ (charset = _XlcCreateDefaultCharSet(name, ""))) {
+ charset->side = codeset->side;
+ charset->char_size = codeset->length;
+ _XlcAddCharSet(charset);
+ }
+ }
+ if (charset) {
+ if (add_charset(codeset, charset) == False)
+ goto err;
+ }
+ }
+ }
+
+ if (codeset == NULL)
+ break;
+ codeset->cs_num = i;
+ /* For VW/UDC */
+ /***** 3.4.2 byteM (1 <= M <= length)*****/
+ for (M=1; M-1 < codeset->length; M++) {
+ unsigned long start,end;
+ ByteInfo tmpb;
+
+ sprintf(name,"%s.%s%d",cs,"byte",M);
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+
+ if (M == 1) {
+ if (num < 1) {
+ codeset->byteM = NULL;
+ break ;
+ }
+ codeset->byteM =
+ (ByteInfoListRec *)Xmalloc(
+ (codeset->length)*sizeof(ByteInfoListRec));
+ if (codeset->byteM == NULL) {
+ goto err;
+ }
+ }
+
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ (codeset->byteM)[M-1].M = M;
+ (codeset->byteM)[M-1].byteinfo_num = num;
+ (codeset->byteM)[M-1].byteinfo =
+ (ByteInfo)Xmalloc( num * sizeof(ByteInfoRec));
+ for (ii = 0 ; ii < num ; ii++) {
+ tmpb = (codeset->byteM)[M-1].byteinfo ;
+ /* default 0x00 - 0xff */
+ sscanf(value[ii],"\\x%lx,\\x%lx",&start,&end);
+ tmpb[ii].start = (unsigned char)start;
+ tmpb[ii].end = (unsigned char)end;
+ }
+ }
+ /* .... */
+ }
+
+
+ /***** codeset.mb_conversion *****/
+ sprintf(name, "%s.%s", cs, "mb_conversion");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ codeset->mbconv = Xmalloc(sizeof(ConversionRec));
+ codeset->mbconv->convlist =
+ _XlcParse_scopemaps(value[0],&(codeset->mbconv->conv_num));
+ dmpscope("mb_conv",codeset->mbconv->convlist,
+ codeset->mbconv->conv_num);
+ /* [\x%x,\x%x]->\x%x,... */
+ }
+ /***** codeset.ct_conversion *****/
+ sprintf(name, "%s.%s", cs, "ct_conversion");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ codeset->ctconv = Xmalloc(sizeof(ConversionRec));
+ codeset->ctconv->convlist =
+ _XlcParse_scopemaps(value[0],&(codeset->ctconv->conv_num));
+ dmpscope("ctconv",codeset->ctconv->convlist,
+ codeset->ctconv->conv_num);
+ /* [\x%x,\x%x]->\x%x,... */
+ }
+ /***** codeset.ct_conversion_file *****/
+ sprintf(name, "%s.%s", cs, "ct_conversion_file");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ /* [\x%x,\x%x]->\x%x,... */
+ }
+ /***** codeset.ct_extended_segment *****/
+ sprintf(name, "%s.%s", cs, "ct_extended_segment");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ codeset->ctextseg = create_ctextseg(value,num);
+ /* [\x%x,\x%x]->\x%x,... */
+ }
+ /* For VW/UDC end */
+
+ }
+
+ read_charset_define(lcd,gen); /* For VW/UDC */
+ read_segmentconversion(lcd,gen); /* For VW/UDC */
+
+ if (gen->initial_state_GL == NULL) {
+ CodeSetRec *codeset;
+ for (i = 0; i < gen->codeset_num; i++) {
+ codeset = gen->codeset_list[i];
+ if (codeset->side == XlcGL)
+ gen->initial_state_GL = codeset;
+ }
+ }
+
+ if (gen->initial_state_GR == NULL) {
+ CodeSetRec *codeset;
+ for (i = 0; i < gen->codeset_num; i++) {
+ codeset = gen->codeset_list[i];
+ if (codeset->side == XlcGR)
+ gen->initial_state_GR = codeset;
+ }
+ }
+
+ for (i = 0; i < gen->codeset_num; i++) {
+ CodeSetRec *codeset = gen->codeset_list[i];
+ for (ii = 0; ii < codeset->num_charsets; ii++) {
+ charset = codeset->charset_list[ii];
+ if (! strcmp(charset->encoding_name, "ISO8859-1"))
+ charset->string_encoding = True;
+ if ( charset->string_encoding )
+ codeset->string_encoding = True;
+ }
+ }
+ return True;
+
+err:
+ free_charset(lcd);
+
+ return False;
+}
+
+#ifdef USE_DYNAMIC_LC
+/* override the open_om and open_im methods which were set by
+ super_class's initialize method() */
+
+static Bool
+initialize_core(
+ XLCd lcd)
+{
+ _XInitDynamicOM(lcd);
+
+ _XInitDynamicIM(lcd);
+
+ return True;
+}
+#endif
+
+static Bool
+initialize(lcd)
+ XLCd lcd;
+{
+ XLCdPublicMethods superclass = (XLCdPublicMethods) _XlcPublicMethods;
+
+ XLC_PUBLIC_METHODS(lcd)->superclass = superclass;
+
+ if (superclass->pub.initialize) {
+ if ((*superclass->pub.initialize)(lcd) == False)
+ return False;
+ }
+
+#ifdef USE_DYNAMIC_LC
+ if (initialize_core(lcd) == False)
+ return False;
+#endif
+
+ if (load_generic(lcd) == False)
+ return False;
+
+ return True;
+}
+
+/* VW/UDC start 95.01.08 */
+static void
+freeByteM(
+ CodeSet codeset)
+{
+ int i;
+ ByteInfoList blst;
+ if (codeset->byteM == NULL) {
+ return ;
+ }
+ blst = codeset->byteM;
+ for (i = 0; i < codeset->length; i++) {
+ if (blst[i].byteinfo) {
+ Xfree(blst[i].byteinfo);
+ blst[i].byteinfo = NULL;
+ }
+ }
+ Xfree(codeset->byteM);
+ codeset->byteM = NULL;
+}
+
+static void
+freeConversion(
+ CodeSet codeset)
+{
+ Conversion mbconv,ctconv;
+ if (codeset->mbconv) {
+ mbconv = codeset->mbconv;
+ /* ... */
+ if (mbconv->convlist) {
+ Xfree(mbconv->convlist);
+ mbconv->convlist = NULL;
+ }
+ Xfree(mbconv);
+ codeset->mbconv = NULL;
+ }
+ if (codeset->ctconv) {
+ ctconv = codeset->ctconv;
+ /* ... */
+ if (ctconv->convlist) {
+ Xfree(ctconv->convlist);
+ ctconv->convlist = NULL;
+ }
+ Xfree(ctconv);
+ codeset->ctconv = NULL;
+ }
+}
+
+static void
+freeExtdSegment(
+ CodeSet codeset)
+{
+ ExtdSegment ctextseg;
+ if (codeset->ctextseg == NULL) {
+ return;
+ }
+ ctextseg = codeset->ctextseg;
+ if (ctextseg->name) {
+ Xfree(ctextseg->name);
+ ctextseg->name = NULL;
+ }
+ if (ctextseg->area) {
+ Xfree(ctextseg->area);
+ ctextseg->area = NULL;
+ }
+ Xfree(codeset->ctextseg);
+ codeset->ctextseg = NULL;
+}
+
+static void
+freeParseInfo(
+ CodeSet codeset)
+{
+ ParseInfo parse_info;
+ if (codeset->parse_info == NULL) {
+ return;
+ }
+ parse_info = codeset->parse_info;
+ if (parse_info->encoding) {
+ Xfree(parse_info->encoding);
+ parse_info->encoding = NULL;
+ }
+ Xfree(codeset->parse_info);
+ codeset->parse_info = NULL;
+}
+
+static void
+destroy_CodeSetList(
+ XLCdGenericPart *gen)
+{
+ CodeSet *codeset = gen->codeset_list;
+ int i;
+ if (gen->codeset_num == 0) {
+ return;
+ }
+ for (i=0;i<gen->codeset_num;i++) {
+ freeByteM(codeset[i]);
+ freeConversion(codeset[i]);
+ freeExtdSegment(codeset[i]);
+ freeParseInfo(codeset[i]);
+ if (codeset[i]->charset_list) {
+ Xfree(codeset[i]->charset_list);
+ codeset[i]->charset_list = NULL;
+ }
+ Xfree(codeset[i]); codeset[i]=NULL;
+ }
+ Xfree(codeset); gen->codeset_list = NULL;
+}
+
+static void
+destroy_SegConv(
+ XLCdGenericPart *gen)
+{
+ SegConv seg = gen->segment_conv;
+ int i;
+ if (gen->segment_conv_num == 0) {
+ return;
+ }
+ for (i=0;i<gen->segment_conv_num;i++) {
+ if (seg[i].source_encoding) {
+ Xfree(seg[i].source_encoding);
+ seg[i].source_encoding = NULL;
+ }
+ if (seg[i].destination_encoding) {
+ Xfree(seg[i].destination_encoding);
+ seg[i].destination_encoding = NULL;
+ }
+ if (seg[i].conv) {
+ Xfree(seg[i].conv); seg[i].conv = NULL;
+ }
+ }
+ Xfree(seg); gen->segment_conv = NULL;
+}
+
+static void
+destroy_gen(
+ XLCd lcd)
+{
+ XLCdGenericPart *gen = XLC_GENERIC_PART(lcd);
+ destroy_SegConv(gen);
+ destroy_CodeSetList(gen);
+ if (gen->mb_parse_table) {
+ Xfree(gen->mb_parse_table);
+ gen->mb_parse_table = NULL;
+ }
+ if (gen->mb_parse_list) {
+ Xfree(gen->mb_parse_list);
+ gen->mb_parse_list = NULL;
+ }
+}
+/* VW/UDC end 95.01.08 */
+
+static void
+destroy(
+ XLCd lcd)
+{
+ XLCdPublicMethods superclass = XLC_PUBLIC_METHODS(lcd)->superclass;
+
+ destroy_gen(lcd); /* ADD 1996.01.08 */
+ if (superclass && superclass->pub.destroy)
+ (*superclass->pub.destroy)(lcd);
+}
diff --git a/nx-X11/lib/X11/lcInit.c b/nx-X11/lib/X11/lcInit.c
new file mode 100644
index 000000000..6375de805
--- /dev/null
+++ b/nx-X11/lib/X11/lcInit.c
@@ -0,0 +1,181 @@
+/*
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Portions Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions: 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 OR SUN MICROSYSTEMS, INC. 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 EVEN IF
+ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Except as contained in this notice, the names of The Open Group and/or
+Sun Microsystems, Inc. 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 and/or Sun Microsystems,
+Inc., as applicable.
+
+
+X Window System is a trademark of The Open Group
+
+OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
+logo, LBX, X Window System, and Xinerama are trademarks of the Open
+Group. All other trademarks and registered trademarks mentioned herein
+are the property of their respective owners. No right, title or
+interest in or to any trademark, service mark, logo or trade name of
+Sun Microsystems, Inc. or its licensors is granted.
+
+*/
+/* $Xorg: lcInit.c,v 1.4 2000/12/12 12:44:05 coskrey Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * (c) Copyright 1995 FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Masayoshi Shimamura FUJITSU LIMITED
+ *
+ */
+/* $XFree86: xc/lib/X11/lcInit.c,v 3.9 2001/11/16 00:52:27 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+#ifdef USE_DYNAMIC_LC
+#undef USE_DEFAULT_LOADER
+#undef USE_GENERIC_LOADER
+#undef USE_UTF8_LOADER
+#else
+#define USE_GENERIC_LOADER
+#define USE_DEFAULT_LOADER
+#define USE_UTF8_LOADER
+#ifdef X_LOCALE
+# define USE_EUC_LOADER
+# define USE_SJIS_LOADER
+# define USE_JIS_LOADER
+#endif
+#endif
+
+/*
+ * The _XlcInitLoader function initializes the locale object loader list
+ * with vendor specific manner.
+ */
+
+void
+_XlcInitLoader()
+{
+
+#ifdef USE_DYNAMIC_LC
+ _XlcAddLoader(_XlcDynamicLoad, XlcHead);
+#else /* USE_DYNAMIC_LC */
+
+#ifdef USE_GENERIC_LOADER
+ _XlcAddLoader(_XlcGenericLoader, XlcHead);
+#endif
+
+#ifdef USE_DEFAULT_LOADER
+ _XlcAddLoader(_XlcDefaultLoader, XlcHead);
+#endif
+
+#ifdef USE_UTF8_LOADER
+ _XlcAddLoader(_XlcUtf8Loader, XlcHead);
+#endif
+
+#ifdef USE_EUC_LOADER
+ _XlcAddLoader(_XlcEucLoader, XlcHead);
+#endif
+
+#ifdef USE_SJIS_LOADER
+ _XlcAddLoader(_XlcSjisLoader, XlcHead);
+#endif
+
+#ifdef USE_JIS_LOADER
+ _XlcAddLoader(_XlcJisLoader, XlcHead);
+#endif
+
+#ifdef USE_DYNAMIC_LOADER
+ _XlcAddLoader(_XlcDynamicLoader, XlcHead);
+#endif
+
+#endif /* USE_DYNAMIC_LC */
+}
+
+void
+_XlcDeInitLoader()
+{
+
+#ifdef USE_DYNAMIC_LC
+ _XlcRemoveLoader(_XlcDynamicLoad);
+#else /* USE_DYNAMIC_LC */
+
+#ifdef USE_GENERIC_LOADER
+ _XlcRemoveLoader(_XlcGenericLoader);
+#endif
+
+#ifdef USE_DEFAULT_LOADER
+ _XlcRemoveLoader(_XlcDefaultLoader);
+#endif
+
+#ifdef USE_UTF8_LOADER
+ _XlcRemoveLoader(_XlcUtf8Loader);
+#endif
+
+#ifdef USE_EUC_LOADER
+ _XlcRemoveLoader(_XlcEucLoader);
+#endif
+
+#ifdef USE_SJIS_LOADER
+ _XlcRemoveLoader(_XlcSjisLoader);
+#endif
+
+#ifdef USE_JIS_LOADER
+ _XlcRemoveLoader(_XlcJisLoader);
+#endif
+
+#ifdef USE_DYNAMIC_LOADER
+ _XlcRemoveLoader(_XlcDynamicLoader);
+#endif
+
+#endif /* USE_DYNAMIC_LC */
+}
diff --git a/nx-X11/lib/X11/lcJis.c b/nx-X11/lib/X11/lcJis.c
new file mode 100644
index 000000000..bdd46e36e
--- /dev/null
+++ b/nx-X11/lib/X11/lcJis.c
@@ -0,0 +1,947 @@
+/* $Xorg: lcJis.c,v 1.3 2000/08/17 19:45:18 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/lcJis.c,v 1.9 2002/04/10 16:20:06 tsi Exp $ */
+
+/*
+ * A Japanese JIS locale.
+ * Supports: all locales with codeset JIS7.
+ * How: Provides converters for JIS.
+ * Platforms: Only those defining X_LOCALE (only Lynx, Linux-libc5, OS/2).
+ */
+
+#ifdef X_LOCALE
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcGeneric.h"
+#include <stdio.h>
+
+#if !defined(macII) && !defined(X_LOCALE)
+#define STDCVT
+#endif
+
+typedef struct _StateRec {
+ XLCd lcd;
+ XlcCharSet charset;
+ XlcCharSet GL_charset;
+ XlcCharSet GR_charset;
+} StateRec, *State;
+
+static void
+init_state(
+ XlcConv conv)
+{
+ State state = (State) conv->state;
+ XLCdGenericPart *gen = XLC_GENERIC_PART(state->lcd);
+ CodeSet codeset;
+
+ codeset = gen->initial_state_GL;
+ if (codeset && codeset->charset_list)
+ state->GL_charset = *codeset->charset_list;
+ codeset = gen->initial_state_GR;
+ if (codeset && codeset->charset_list)
+ state->GR_charset = *codeset->charset_list;
+
+ if (state->GL_charset == NULL)
+ if ((codeset = *gen->codeset_list) != NULL)
+ state->GL_charset = *codeset->charset_list;
+}
+
+static int
+compare(
+ const char *src,
+ const char *encoding,
+ int length)
+{
+ const char *start = src;
+
+ while (length-- > 0) {
+ if (*src++ != *encoding++)
+ return 0;
+ if (*encoding == '\0')
+ return src - start;
+ }
+
+ return 0;
+}
+
+static int
+mbtocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+ const char *src;
+ char *dst;
+ unsigned char *mb_parse_table;
+ ParseInfo *parse_list, parse_info;
+ XlcCharSet charset;
+ int length, number, encoding_len = 0;
+ int i;
+
+ src = *((const char **) from);
+ dst = *((char **) to);
+
+ mb_parse_table = XLC_GENERIC(lcd, mb_parse_table);
+ if (mb_parse_table != NULL) {
+ number = mb_parse_table[(unsigned char) *src];
+ if (number > 0) {
+ parse_list = XLC_GENERIC(lcd, mb_parse_list) + number - 1;
+ for ( ; (parse_info = *parse_list) != NULL; parse_list++) {
+ encoding_len = compare(src, parse_info->encoding, *from_left);
+ if (encoding_len > 0) {
+ switch (parse_info->type) {
+ case E_SS:
+ src += encoding_len;
+ charset = *parse_info->codeset->charset_list;
+ goto found;
+ case E_LSL:
+ case E_LSR:
+ src += encoding_len;
+ charset = *parse_info->codeset->charset_list;
+ if (parse_info->type == E_LSL)
+ state->GL_charset = charset;
+ else
+ state->GR_charset = charset;
+ length = 0;
+ goto end;
+ case E_GL:
+ charset = state->GL_charset;
+ goto found;
+ case E_GR:
+ charset = state->GR_charset;
+ goto found;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if ((*src & 0x80) && state->GR_charset)
+ charset = state->GR_charset;
+ else
+ charset = state->GL_charset;
+
+found:
+ if (charset == NULL ||
+ (num_args == 2 && (XlcCharSet) args[1] != charset))
+ return -1;
+
+ length = charset->char_size;
+ if (length > *from_left - encoding_len)
+ return -1;
+
+ if (dst) {
+ if (length > *to_left)
+ return -1;
+ if (charset->side == XlcGL) {
+ for (i = 0; i < length; i++)
+ *dst++ = *src++ & 0x7f;
+ } else if (charset->side == XlcGR) {
+ for (i = 0; i < length; i++)
+ *dst++ = *src++ | 0x80;
+ } else {
+ for (i = 0; i < length; i++)
+ *dst++ = *src++;
+ }
+ *to = (XPointer) dst;
+ *to_left -= length;
+ }
+end:
+ *from = (XPointer) src;
+ *from_left -= encoding_len + length;
+ state->charset = charset;
+ if (num_args == 1)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return 0;
+}
+
+static int
+mbstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XlcCharSet charset = NULL;
+ XPointer tmp_args[2], save_from = *from;
+ int ret, unconv_num = 0, tmp_num = 1;
+
+ tmp_args[0] = (XPointer) &charset;
+
+ while (*from_left > 0 && *to_left > 0) {
+ ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, tmp_num);
+ if (ret < 0)
+ break;
+ unconv_num += ret;
+ if (tmp_num == 1 && charset) {
+ tmp_args[1] = (XPointer) charset;
+ tmp_num = 2;
+ }
+ }
+
+ if (save_from == *from)
+ return -1;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return unconv_num;
+}
+
+static CodeSet
+wc_parse_codeset(
+ XLCd lcd,
+ const wchar_t *wcstr)
+{
+ CodeSet *codeset;
+ unsigned long wc_encoding;
+ int num;
+
+ wc_encoding = *wcstr & XLC_GENERIC(lcd, wc_encode_mask);
+ num = XLC_GENERIC(lcd, codeset_num);
+ codeset = XLC_GENERIC(lcd, codeset_list);
+ while (num-- > 0) {
+ if (wc_encoding == (*codeset)->wc_encoding)
+ return *codeset;
+ codeset++;
+ }
+
+ return NULL;
+}
+
+static int
+wcstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+ const wchar_t *wcptr;
+ char *bufptr;
+ wchar_t wch;
+ char *tmpptr;
+ int length;
+ CodeSet codeset;
+ unsigned long wc_encoding;
+ int wcstr_len, buf_len;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ wcptr = *((const wchar_t **) from);
+ bufptr = *((char **) to);
+ wcstr_len = *from_left;
+ buf_len = *to_left;
+
+ codeset = wc_parse_codeset(lcd, wcptr);
+ if (codeset == NULL)
+ return -1;
+ wc_encoding = codeset->wc_encoding;
+
+ if (wcstr_len < buf_len / codeset->length)
+ buf_len = wcstr_len * codeset->length;
+
+ for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) {
+ wch = *wcptr;
+ if ((wch & XLC_GENERIC(lcd, wc_encode_mask)) != wc_encoding)
+ break;
+ length = codeset->length;
+ buf_len -= length;
+ bufptr += length;
+
+ tmpptr = bufptr - 1;
+ if ((*codeset->charset_list)->side == XlcGL) {
+ while (length--) {
+ *tmpptr-- = (unsigned char) (wch & 0x7f);
+ wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
+ }
+ } else if ((*codeset->charset_list)->side == XlcGR) {
+ while (length--) {
+ *tmpptr-- = (unsigned char) (wch | 0x80);
+ wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
+ }
+ } else {
+ while (length--) {
+ *tmpptr-- = (unsigned char) wch;
+ wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
+ }
+ }
+ }
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = *codeset->charset_list;
+
+ *from_left -= wcptr - *((wchar_t **) from);
+ *from = (XPointer) wcptr;
+
+ *to_left -= bufptr - *((char **) to);
+ *to = bufptr;
+
+ return 0;
+}
+
+static CodeSet
+GetCodeSetFromCharSet(
+ XLCd lcd,
+ XlcCharSet charset)
+{
+ CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
+ XlcCharSet *charset_list;
+ int codeset_num, num_charsets;
+
+ codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+ for ( ; codeset_num-- > 0; codeset++) {
+ num_charsets = (*codeset)->num_charsets;
+ charset_list = (*codeset)->charset_list;
+
+ for ( ; num_charsets-- > 0; charset_list++)
+ if (*charset_list == charset)
+ return *codeset;
+ }
+
+ return (CodeSet) NULL;
+}
+
+static int
+cstombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ const char *csptr;
+ char *bufptr;
+ int csstr_len;
+ int buf_len;
+ int num, encoding_len = 0;
+ CodeSet codeset;
+ XlcCharSet charset;
+ EncodingType type;
+ int cvt_length;
+
+ csptr = *((const char **) from);
+ bufptr = *((char **) to);
+ csstr_len = *from_left;
+ buf_len = *to_left;
+
+ if (num_args < 1)
+ return -1;
+
+ charset = (XlcCharSet) args[0];
+
+ codeset = GetCodeSetFromCharSet(state->lcd, charset);
+ if (codeset == NULL)
+ return -1;
+
+ cvt_length = 0;
+ if (codeset->parse_info) {
+ switch (type = codeset->parse_info->type) {
+ case E_SS:
+ encoding_len = strlen(codeset->parse_info->encoding);
+ break;
+ case E_LSL:
+ case E_LSR:
+ if (type == E_LSL) {
+ if (charset == state->GL_charset)
+ break;
+ } else {
+ if (charset == state->GR_charset)
+ break;
+ }
+ encoding_len = strlen(codeset->parse_info->encoding);
+ if (encoding_len > buf_len)
+ return -1;
+ cvt_length += encoding_len;
+ if (bufptr) {
+ strcpy(bufptr, codeset->parse_info->encoding);
+ bufptr += encoding_len;
+ }
+ buf_len -= encoding_len;
+ encoding_len = 0;
+ if (type == E_LSL)
+ state->GL_charset = charset;
+ else
+ state->GR_charset = charset;
+ break;
+ default:
+ break;
+ }
+ }
+
+ csstr_len /= codeset->length;
+ buf_len /= codeset->length + encoding_len;
+ if (csstr_len < buf_len)
+ buf_len = csstr_len;
+
+ cvt_length += buf_len * (encoding_len + codeset->length);
+ if (bufptr) {
+ while (buf_len--) {
+ if (encoding_len) {
+ strcpy(bufptr, codeset->parse_info->encoding);
+ bufptr += encoding_len;
+ }
+ num = codeset->length;
+ if (codeset->side == XlcGL) {
+ while (num--)
+ *bufptr++ = *csptr++ & 0x7f;
+ } else if (codeset->side == XlcGR) {
+ while (num--)
+ *bufptr++ = *csptr++ | 0x80;
+ } else {
+ while (num--)
+ *bufptr++ = *csptr++;
+ }
+ }
+ }
+
+ *from_left -= csptr - *((char **) from);
+ *from = (XPointer) csptr;
+
+ if (bufptr)
+ *to = (XPointer) bufptr;
+ *to_left -= cvt_length;
+
+ return 0;
+}
+
+static int
+cstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+ const char *csptr;
+ wchar_t *bufptr;
+ int csstr_len;
+ int buf_len;
+ wchar_t wch;
+ unsigned long code_mask, wc_encoding;
+ int num, length, wc_shift_bits;
+ CodeSet codeset;
+
+ csptr = *((const char **) from);
+ bufptr = *((wchar_t **) to);
+ csstr_len = *from_left;
+ buf_len = *to_left;
+
+ if (num_args < 1)
+ return -1;
+
+ codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0]);
+ if (codeset == NULL)
+ return -1;
+
+ length = codeset->length;
+ csstr_len /= length;
+ if (csstr_len < buf_len)
+ buf_len = csstr_len;
+
+ code_mask = ~XLC_GENERIC(lcd, wc_encode_mask);
+ wc_encoding = codeset->wc_encoding;
+ wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
+
+ *to_left -= buf_len;
+
+ if (bufptr) {
+ while (buf_len--) {
+ wch = (wchar_t) (*csptr++ & 0x7f);
+ num = length - 1;
+ while (num--)
+ wch = (wch << wc_shift_bits) | (*csptr++ & 0x7f);
+
+ *bufptr++ = (wch & code_mask) | wc_encoding;
+ }
+ }
+
+ *from_left -= csptr - *((char **) from);
+ *from = (XPointer) csptr;
+
+ if (bufptr)
+ *to = (XPointer) bufptr;
+
+ return 0;
+}
+
+
+static void
+close_converter(
+ XlcConv conv)
+{
+ if (conv->state) {
+ Xfree((char *) conv->state);
+ }
+
+ Xfree((char *) conv);
+}
+
+static XlcConv
+create_conv(
+ XLCd lcd,
+ XlcConvMethods methods)
+{
+ XlcConv conv;
+ State state;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (conv == NULL)
+ return (XlcConv) NULL;
+
+ conv->methods = (XlcConvMethods) Xmalloc(sizeof(XlcConvMethodsRec));
+ if (conv->methods == NULL)
+ goto err;
+ *conv->methods = *methods;
+ if (XLC_PUBLIC(lcd, is_state_depend))
+ conv->methods->reset = init_state;
+
+ conv->state = (XPointer) Xmalloc(sizeof(StateRec));
+ if (conv->state == NULL)
+ goto err;
+ bzero((char *) conv->state, sizeof(StateRec));
+
+ state = (State) conv->state;
+ state->lcd = lcd;
+ init_state(conv);
+
+ return conv;
+
+err:
+ close_converter(conv);
+
+ return (XlcConv) NULL;
+}
+
+static XlcConvMethodsRec mbstocs_methods = {
+ close_converter,
+ mbstocs,
+ NULL
+};
+
+static XlcConv
+open_mbstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &mbstocs_methods);
+}
+
+static XlcConvMethodsRec wcstocs_methods = {
+ close_converter,
+ wcstocs,
+ NULL
+};
+
+static XlcConv
+open_wcstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &wcstocs_methods);
+}
+
+static XlcConvMethodsRec mbtocs_methods = {
+ close_converter,
+ mbtocs,
+ NULL
+};
+
+static XlcConv
+open_mbtocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &mbtocs_methods);
+}
+
+static XlcConvMethodsRec cstombs_methods = {
+ close_converter,
+ cstombs,
+ NULL
+};
+
+static XlcConv
+open_cstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &cstombs_methods);
+}
+
+static XlcConvMethodsRec cstowcs_methods = {
+ close_converter,
+ cstowcs,
+ NULL
+};
+
+static XlcConv
+open_cstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &cstowcs_methods);
+}
+
+#ifdef STDCVT
+static int
+stdc_mbstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const char *src = *((const char **) from);
+ wchar_t *dst = *((wchar_t **) to);
+ int src_left = *from_left;
+ int dst_left = *to_left;
+ int length;
+
+ while (src_left > 0 && dst_left > 0) {
+ length = mbtowc(dst, src, src_left);
+ if (length < 0)
+ break;
+
+ src += length;
+ src_left -= length;
+ if (dst)
+ dst++;
+ dst_left--;
+
+ if (length == 0) {
+ src++;
+ src_left--;
+ break;
+ }
+ }
+
+ if (*from_left == src_left)
+ return -1;
+
+ *from = (XPointer) src;
+ if (dst)
+ *to = (XPointer) dst;
+ *from_left = src_left;
+ *to_left = dst_left;
+
+ return 0;
+}
+
+static int
+stdc_wcstombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const wchar_t *src = *((const wchar_t **) from);
+ char *dst = *((char **) to);
+ int src_left = *from_left;
+ int dst_left = *to_left;
+ int length;
+
+ while (src_left > 0 && dst_left > 0) {
+ length = wctomb(dst, *src); /* XXX */
+ if (length < 0 || dst_left < length)
+ break;
+
+ src++;
+ src_left--;
+ dst += length;
+ dst_left -= length;
+
+ if (length == 0) {
+ dst++;
+ dst_left--;
+ break;
+ }
+ }
+
+ if (*from_left == src_left)
+ return -1;
+
+ *from = (XPointer) src;
+ *to = (XPointer) dst;
+ *from_left = src_left;
+ *to_left = dst_left;
+
+ return 0;
+}
+
+static int
+stdc_wcstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const wchar_t *src = *((const wchar_t **) from);
+ wchar_t wch;
+ XlcCharSet charset = NULL;
+ XPointer tmp_args[2], tmp_from, save_from = *from;
+ char tmp[32];
+ int length, ret, src_left = *from_left;
+ int unconv_num = 0, tmp_num = 1;
+
+ tmp_args[0] = (XPointer) &charset;
+
+ while (src_left > 0 && *to_left > 0) {
+ if (wch = *src) {
+ length = wctomb(tmp, wch);
+ } else {
+ length = 1;
+ *tmp = '\0';
+ }
+
+ if (length < 0)
+ break;
+
+ tmp_from = (XPointer) tmp;
+ ret = mbtocs(conv, &tmp_from, &length, to, to_left, tmp_args, tmp_num);
+ if (ret < 0)
+ break;
+ unconv_num += ret;
+ if (tmp_num == 1 && charset) {
+ tmp_args[1] = (XPointer) charset;
+ tmp_num = 2;
+ }
+
+ src++;
+ src_left--;
+ }
+
+ if (save_from == (XPointer) src)
+ return -1;
+
+ *from = (XPointer) src;
+ *from_left = src_left;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return unconv_num;
+}
+
+#define DefineLocalBuf char local_buf[BUFSIZ]
+#define AllocLocalBuf(length) (length > BUFSIZ ? (char*) Xmalloc(length) : local_buf)
+#define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr)
+
+static int
+stdc_cstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XLCd lcd = ((State) conv->state)->lcd;
+ DefineLocalBuf;
+ XPointer buf, save_buf;
+ int length, left, ret;
+
+ left = length = *to_left * XLC_PUBLIC(lcd, mb_cur_max);
+ buf = save_buf = (XPointer) AllocLocalBuf(length);
+ if (buf == NULL)
+ return -1;
+
+ ret = cstombs(conv, from, from_left, &buf, &left, args, num_args);
+ if (ret < 0)
+ goto err;
+
+ buf = save_buf;
+ length -= left;
+ if (stdc_mbstowcs(conv, &buf, &length, to, to_left, args, num_args) < 0)
+ ret = -1;
+
+err:
+ FreeLocalBuf(save_buf);
+
+ return ret;
+}
+
+static XlcConvMethodsRec stdc_mbstowcs_methods = {
+ close_converter,
+ stdc_mbstowcs,
+ NULL
+};
+
+static XlcConv
+open_stdc_mbstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &stdc_mbstowcs_methods);
+}
+
+static XlcConvMethodsRec stdc_wcstombs_methods = {
+ close_converter,
+ stdc_wcstombs,
+ NULL
+};
+
+static XlcConv
+open_stdc_wcstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &stdc_wcstombs_methods);
+}
+
+static XlcConvMethodsRec stdc_wcstocs_methods = {
+ close_converter,
+ stdc_wcstocs,
+ NULL
+};
+
+static XlcConv
+open_stdc_wcstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &stdc_wcstocs_methods);
+}
+
+static XlcConvMethodsRec stdc_cstowcs_methods = {
+ close_converter,
+ stdc_cstowcs,
+ NULL
+};
+
+static XlcConv
+open_stdc_cstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &stdc_cstowcs_methods);
+}
+#endif /* STDCVT */
+
+XLCd
+_XlcJisLoader(
+ const char *name)
+{
+ XLCd lcd;
+#ifdef STDCVT
+ XLCdGenericPart *gen;
+#endif
+
+ lcd = _XlcCreateLC(name, _XlcGenericMethods);
+ if (lcd == NULL)
+ return lcd;
+
+ if (!XLC_PUBLIC_PART(lcd)->codeset ||
+ (_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "JIS7"))) {
+ _XlcDestroyLC(lcd);
+ return (XLCd) NULL;
+ }
+
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs);
+
+#ifdef STDCVT
+ gen = XLC_GENERIC_PART(lcd);
+
+ if (gen->use_stdc_env == True) {
+ _XlcSetConverter(lcd,XlcNMultiByte,lcd,XlcNWideChar,open_stdc_mbstowcs);
+ _XlcSetConverter(lcd,XlcNWideChar,lcd,XlcNMultiByte,open_stdc_wcstombs);
+ }
+ if (gen->force_convert_to_mb == True) {
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet,open_stdc_wcstocs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar,open_stdc_cstowcs);
+ } else {
+#endif
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
+#ifdef STDCVT
+ }
+#endif
+
+ _XlcAddUtf8Converters(lcd);
+
+ return lcd;
+}
+
+#else
+typedef int dummy;
+#endif /* X_LOCALE */
diff --git a/nx-X11/lib/X11/lcPrTxt.c b/nx-X11/lib/X11/lcPrTxt.c
new file mode 100644
index 000000000..5a781280e
--- /dev/null
+++ b/nx-X11/lib/X11/lcPrTxt.c
@@ -0,0 +1,292 @@
+/* $Xorg: lcPrTxt.c,v 1.3 2000/08/17 19:45:18 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/lcPrTxt.c,v 1.9 2003/04/03 22:34:02 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+
+static XPointer *
+alloc_list(
+ Bool is_wide_char,
+ int count,
+ int nitems)
+{
+ if (is_wide_char) {
+ wchar_t **wstr_list;
+
+ wstr_list = (wchar_t **) Xmalloc(count * sizeof(wchar_t *));
+ if (wstr_list == NULL)
+ return (XPointer *) NULL;
+
+ *wstr_list = (wchar_t *) Xmalloc(nitems * sizeof(wchar_t));
+ if (*wstr_list == NULL) {
+ Xfree(wstr_list);
+ return (XPointer *) NULL;
+ }
+
+ return (XPointer *) wstr_list;
+ } else {
+ char **str_list;
+
+ str_list = (char **) Xmalloc(count * sizeof(char *));
+ if (str_list == NULL)
+ return (XPointer *) NULL;
+
+ *str_list = (char *) Xmalloc(nitems);
+ if (*str_list == NULL) {
+ Xfree(str_list);
+ return (XPointer *) NULL;
+ }
+
+ return (XPointer *) str_list;
+ }
+}
+
+static void
+copy_list(
+ Bool is_wide_char,
+ XPointer text,
+ XPointer *list,
+ int count)
+{
+ int length;
+
+ if (is_wide_char) {
+ wchar_t *wc_text, *wstr, **wstr_list;
+
+ wc_text = (wchar_t *) text;
+ wstr_list = (wchar_t **) list;
+
+ for (wstr = *wstr_list; count > 0; count--, wstr_list++) {
+ _Xwcscpy(wstr, wc_text);
+ *wstr_list = wstr;
+ length = _Xwcslen(wstr) + 1;
+ wstr += length;
+ wc_text += length;
+ }
+ } else {
+ char *mb_text, *str, **str_list;
+
+ mb_text = (char *) text;
+ str_list = (char **) list;
+
+ for (str = *str_list; count > 0; count--, str_list++) {
+ strcpy(str, mb_text);
+ *str_list = str;
+ length = strlen(str) + 1;
+ str += length;
+ mb_text += length;
+ }
+ }
+}
+
+static int
+_XTextPropertyToTextList(
+ XLCd lcd,
+ Display *dpy,
+ const XTextProperty *text_prop,
+ const char *to_type,
+ XPointer **list_ret,
+ int *count_ret)
+{
+ XlcConv conv = NULL;
+ const char *from_type;
+ XPointer from, to, buf;
+ char *str_ptr, *last_ptr;
+ Atom encoding;
+ int from_left, to_left, buf_len, ret, len;
+ int unconv_num, nitems = text_prop->nitems;
+ Bool is_wide_char = False, do_strcpy = False;
+
+ if (strcmp(XlcNWideChar, to_type) == 0)
+ is_wide_char = True;
+
+ if (nitems <= 0) {
+ *list_ret = NULL;
+ *count_ret = 0;
+ return Success;
+ }
+
+ if (text_prop->format != 8)
+ return XConverterNotFound;
+
+ encoding = text_prop->encoding;
+ if (encoding == XA_STRING)
+ from_type = XlcNString;
+ else if (encoding == XInternAtom(dpy, "UTF8_STRING", False))
+ from_type = XlcNUtf8String;
+ else if (encoding == XInternAtom(dpy, "COMPOUND_TEXT", False))
+ from_type = XlcNCompoundText;
+ else if (encoding == XInternAtom(dpy, XLC_PUBLIC(lcd, encoding_name), False))
+ from_type = XlcNMultiByte;
+ else
+ return XConverterNotFound;
+
+ if (is_wide_char) {
+ buf_len = (text_prop->nitems + 1) * sizeof(wchar_t);;
+ } else {
+ if (strcmp(to_type, XlcNUtf8String) == 0)
+ buf_len = text_prop->nitems * 6 + 1;
+ else
+ buf_len = text_prop->nitems * XLC_PUBLIC(lcd, mb_cur_max) + 1;
+ }
+ buf = (XPointer) Xmalloc(buf_len);
+ if (buf == NULL)
+ return XNoMemory;
+ to = buf;
+ to_left = buf_len;
+
+ /* can be XlcNMultiByte to XlcNMultiByte,
+ or XlcNUtf8String to XlcNUtf8String */
+ if (!strcmp(from_type, to_type)) {
+ do_strcpy = True;
+ } else {
+ conv = _XlcOpenConverter(lcd, from_type, lcd, to_type);
+ if (conv == NULL) {
+ Xfree(buf);
+ return XConverterNotFound;
+ }
+ }
+
+ last_ptr = str_ptr = (char *) text_prop->value;
+ unconv_num = *count_ret = 0;
+
+ while (1) {
+ if (nitems == 0 || *str_ptr == 0) {
+ from = (XPointer) last_ptr;
+ from_left = str_ptr - last_ptr;
+ last_ptr = str_ptr;
+
+ if (do_strcpy) {
+ len = min(from_left, to_left);
+ strncpy(to, from, len);
+ from += len;
+ to += len;
+ from_left -= len;
+ to_left -= len;
+ ret = 0;
+ } else {
+ ret = _XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0);
+ }
+
+ if (ret < 0)
+ continue;
+
+ unconv_num += ret;
+ (*count_ret)++;
+
+ if (nitems == 0)
+ break;
+ last_ptr = ++str_ptr;
+ if (is_wide_char) {
+ *((wchar_t *)to) = (wchar_t) 0;
+ to += sizeof(wchar_t);
+ to_left -= sizeof(wchar_t);
+ } else {
+ *((char *)to) = '\0';
+ to++;
+ to_left--;
+ }
+ if (! do_strcpy)
+ _XlcResetConverter(conv);
+ } else
+ str_ptr++;
+
+ nitems--;
+ }
+
+ if (! do_strcpy)
+ _XlcCloseConverter(conv);
+
+ if (is_wide_char) {
+ *((wchar_t *) to) = (wchar_t) 0;
+ to_left -= sizeof(wchar_t);
+ } else {
+ *((char *) to) = '\0';
+ to_left--;
+ }
+
+ *list_ret = alloc_list(is_wide_char, *count_ret, buf_len - to_left);
+ if (*list_ret)
+ copy_list(is_wide_char, buf, *list_ret, *count_ret);
+
+ Xfree(buf);
+
+ return unconv_num;
+}
+
+int
+_XmbTextPropertyToTextList(
+ XLCd lcd,
+ Display *dpy,
+ const XTextProperty *text_prop,
+ char ***list_ret,
+ int *count_ret)
+{
+ return _XTextPropertyToTextList(lcd, dpy, text_prop, XlcNMultiByte,
+ (XPointer **) list_ret, count_ret);
+}
+
+int
+_XwcTextPropertyToTextList(
+ XLCd lcd,
+ Display *dpy,
+ const XTextProperty *text_prop,
+ wchar_t ***list_ret,
+ int *count_ret)
+{
+ return _XTextPropertyToTextList(lcd, dpy, text_prop, XlcNWideChar,
+ (XPointer **) list_ret, count_ret);
+}
+
+int
+_Xutf8TextPropertyToTextList(
+ XLCd lcd,
+ Display *dpy,
+ const XTextProperty *text_prop,
+ char ***list_ret,
+ int *count_ret)
+{
+ return _XTextPropertyToTextList(lcd, dpy, text_prop, XlcNUtf8String,
+ (XPointer **) list_ret, count_ret);
+}
+
+void
+_XwcFreeStringList(
+ XLCd lcd,
+ wchar_t **list)
+{
+ if (list) {
+ if (*list)
+ Xfree(*list);
+ Xfree(list);
+ }
+}
diff --git a/nx-X11/lib/X11/lcPubWrap.c b/nx-X11/lib/X11/lcPubWrap.c
new file mode 100644
index 000000000..e30a55c08
--- /dev/null
+++ b/nx-X11/lib/X11/lcPubWrap.c
@@ -0,0 +1,101 @@
+/* $Xorg: lcPubWrap.c,v 1.3 2000/08/17 19:45:18 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/lcPubWrap.c,v 1.4 2001/01/17 19:41:55 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcPubI.h"
+
+char *
+_XGetLCValues(XLCd lcd, ...)
+{
+ va_list var;
+ XlcArgList args;
+ char *ret;
+ int num_args;
+ XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd);
+
+ va_start(var, lcd);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ va_start(var, lcd);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (char *) NULL;
+
+ ret = (*methods->get_values)(lcd, args, num_args);
+
+ Xfree(args);
+
+ return ret;
+}
+
+void
+_XlcDestroyLC(
+ XLCd lcd)
+{
+ XLCdPublicMethods methods = (XLCdPublicMethods) lcd->methods;
+
+ (*methods->pub.destroy)(lcd);
+}
+
+XLCd
+_XlcCreateLC(
+ const char *name,
+ XLCdMethods methods)
+{
+ XLCdPublicMethods pub_methods = (XLCdPublicMethods) methods;
+ XLCd lcd;
+
+ lcd = (*pub_methods->pub.create)(name, methods);
+ if (lcd == NULL)
+ return (XLCd) NULL;
+
+ if (lcd->core->name == NULL) {
+ lcd->core->name = (char*) Xmalloc(strlen(name) + 1);
+ if (lcd->core->name == NULL)
+ goto err;
+ strcpy(lcd->core->name, name);
+ }
+
+ if (lcd->methods == NULL)
+ lcd->methods = methods;
+
+ if ((*pub_methods->pub.initialize)(lcd) == False)
+ goto err;
+
+ return lcd;
+
+err:
+ _XlcDestroyLC(lcd);
+
+ return (XLCd) NULL;
+}
diff --git a/nx-X11/lib/X11/lcPublic.c b/nx-X11/lib/X11/lcPublic.c
new file mode 100644
index 000000000..d80451610
--- /dev/null
+++ b/nx-X11/lib/X11/lcPublic.c
@@ -0,0 +1,319 @@
+/* $Xorg: lcPublic.c,v 1.4 2000/12/12 12:44:05 coskrey Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/lcPublic.c,v 1.11 2001/11/16 00:52:28 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "XlcPubI.h"
+
+static const char *
+default_string(
+ XLCd lcd)
+{
+ return XLC_PUBLIC(lcd, default_string);
+}
+
+static XLCd create (const char *name, XLCdMethods methods);
+static Bool initialize (XLCd lcd);
+static void destroy (XLCd lcd);
+static char *get_values (XLCd lcd, XlcArgList args, int num_args);
+
+static XLCdPublicMethodsRec publicMethods = {
+ {
+ destroy,
+ _XlcDefaultMapModifiers,
+ NULL,
+ NULL,
+ _XrmDefaultInitParseInfo,
+ _XmbTextPropertyToTextList,
+ _XwcTextPropertyToTextList,
+ _Xutf8TextPropertyToTextList,
+ _XmbTextListToTextProperty,
+ _XwcTextListToTextProperty,
+ _Xutf8TextListToTextProperty,
+ _XwcFreeStringList,
+ default_string,
+ NULL,
+ NULL
+ },
+ {
+ NULL,
+ create,
+ initialize,
+ destroy,
+ get_values,
+ _XlcGetLocaleDataBase
+ }
+};
+
+XLCdMethods _XlcPublicMethods = (XLCdMethods) &publicMethods;
+
+static XLCd
+create(
+ const char *name,
+ XLCdMethods methods)
+{
+ XLCd lcd;
+ XLCdPublicMethods new;
+
+ lcd = (XLCd) Xmalloc(sizeof(XLCdRec));
+ if (lcd == NULL)
+ return (XLCd) NULL;
+ bzero((char *) lcd, sizeof(XLCdRec));
+
+ lcd->core = (XLCdCore) Xmalloc(sizeof(XLCdPublicRec));
+ if (lcd->core == NULL)
+ goto err;
+ bzero((char *) lcd->core, sizeof(XLCdPublicRec));
+
+ new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec));
+ if (new == NULL)
+ goto err;
+ memcpy(new,methods,sizeof(XLCdPublicMethodsRec));
+ lcd->methods = (XLCdMethods) new;
+
+ return lcd;
+
+err:
+ Xfree(lcd);
+ return (XLCd) NULL;
+}
+
+static Bool
+load_public(
+ XLCd lcd)
+{
+ XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
+ char **values, *str;
+ int num;
+
+ if(_XlcCreateLocaleDataBase(lcd) == NULL)
+ return False;
+
+ _XlcGetResource(lcd, "XLC_XLOCALE", "mb_cur_max", &values, &num);
+ if (num > 0) {
+ pub->mb_cur_max = atoi(values[0]);
+ if (pub->mb_cur_max < 1)
+ pub->mb_cur_max = 1;
+ } else
+ pub->mb_cur_max = 1;
+
+ _XlcGetResource(lcd, "XLC_XLOCALE", "state_depend_encoding", &values, &num);
+ if (num > 0 && !_XlcCompareISOLatin1(values[0], "True"))
+ pub->is_state_depend = True;
+ else
+ pub->is_state_depend = False;
+
+ _XlcGetResource(lcd, "XLC_XLOCALE", "encoding_name", &values, &num);
+ str = (num > 0) ? values[0] : "STRING";
+ pub->encoding_name = (char*) Xmalloc(strlen(str) + 1);
+ if (pub->encoding_name == NULL)
+ return False;
+ strcpy(pub->encoding_name, str);
+
+ return True;
+}
+
+static Bool
+initialize_core(
+ XLCd lcd)
+{
+ XLCdMethods methods = lcd->methods;
+ XLCdMethods core = &publicMethods.core;
+
+ if (methods->close == NULL)
+ methods->close = core->close;
+
+ if (methods->map_modifiers == NULL)
+ methods->map_modifiers = core->map_modifiers;
+
+ if (methods->open_om == NULL)
+#ifdef USE_DYNAMIC_LC
+ _XInitDefaultOM(lcd);
+#else
+ _XInitOM(lcd);
+#endif
+
+ if (methods->open_im == NULL)
+#ifdef USE_DYNAMIC_LC
+ _XInitDefaultIM(lcd);
+#else
+ _XInitIM(lcd);
+#endif
+
+ if (methods->init_parse_info == NULL)
+ methods->init_parse_info = core->init_parse_info;
+
+ if (methods->mb_text_prop_to_list == NULL)
+ methods->mb_text_prop_to_list = core->mb_text_prop_to_list;
+
+ if (methods->wc_text_prop_to_list == NULL)
+ methods->wc_text_prop_to_list = core->wc_text_prop_to_list;
+
+ if (methods->utf8_text_prop_to_list == NULL)
+ methods->utf8_text_prop_to_list = core->utf8_text_prop_to_list;
+
+ if (methods->mb_text_list_to_prop == NULL)
+ methods->mb_text_list_to_prop = core->mb_text_list_to_prop;
+
+ if (methods->wc_text_list_to_prop == NULL)
+ methods->wc_text_list_to_prop = core->wc_text_list_to_prop;
+
+ if (methods->utf8_text_list_to_prop == NULL)
+ methods->utf8_text_list_to_prop = core->utf8_text_list_to_prop;
+
+ if (methods->wc_free_string_list == NULL)
+ methods->wc_free_string_list = core->wc_free_string_list;
+
+ if (methods->default_string == NULL)
+ methods->default_string = core->default_string;
+
+ return True;
+}
+
+static Bool
+initialize(
+ XLCd lcd)
+{
+ XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd);
+ XLCdPublicMethodsPart *pub_methods = &publicMethods.pub;
+ XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
+ char *name;
+#if !defined(X_LOCALE)
+ int len;
+ char sinamebuf[256];
+ char* siname;
+#endif
+
+ _XlcInitCTInfo();
+
+ if (initialize_core(lcd) == False)
+ return False;
+
+ name = lcd->core->name;
+#if !defined(X_LOCALE)
+ /*
+ * _XlMapOSLocaleName will return the same string or a substring
+ * of name, so strlen(name) is okay
+ */
+ if ((len = strlen(name)) < sizeof sinamebuf)
+ siname = sinamebuf;
+ else
+ siname = Xmalloc (len + 1);
+ if (siname == NULL)
+ return False;
+ name = _XlcMapOSLocaleName(name, siname);
+#endif
+ /* _XlcResolveLocaleName will lookup the SI's name for the locale */
+ if (_XlcResolveLocaleName(name, pub) == 0) {
+#if !defined(X_LOCALE)
+ if (siname != sinamebuf) Xfree (siname);
+#endif
+ return False;
+ }
+#if !defined(X_LOCALE)
+ if (siname != sinamebuf)
+ Xfree (siname);
+#endif
+
+ if (pub->default_string == NULL)
+ pub->default_string = "";
+
+ if (methods->get_values == NULL)
+ methods->get_values = pub_methods->get_values;
+
+ if (methods->get_resource == NULL)
+ methods->get_resource = pub_methods->get_resource;
+
+ return load_public(lcd);
+}
+
+static void
+destroy_core(
+ XLCd lcd)
+{
+ if (lcd->core) {
+ if (lcd->core->name)
+ Xfree(lcd->core->name);
+ Xfree(lcd->core);
+ }
+
+ if (lcd->methods)
+ Xfree(lcd->methods);
+
+ Xfree(lcd);
+}
+
+static void
+destroy(
+ XLCd lcd)
+{
+ XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
+
+ _XlcDestroyLocaleDataBase(lcd);
+
+ if (pub->siname)
+ Xfree(pub->siname);
+ if (pub->encoding_name)
+ Xfree(pub->encoding_name);
+
+ destroy_core(lcd);
+}
+
+static XlcResource resources[] = {
+ { XlcNCodeset, NULLQUARK, sizeof(char *),
+ XOffsetOf(XLCdPublicRec, pub.codeset), XlcGetMask },
+ { XlcNDefaultString, NULLQUARK, sizeof(char *),
+ XOffsetOf(XLCdPublicRec, pub.default_string), XlcGetMask },
+ { XlcNEncodingName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XLCdPublicRec, pub.encoding_name), XlcGetMask },
+ { XlcNLanguage, NULLQUARK, sizeof(char *),
+ XOffsetOf(XLCdPublicRec, pub.language), XlcGetMask },
+ { XlcNMbCurMax, NULLQUARK, sizeof(int),
+ XOffsetOf(XLCdPublicRec, pub.mb_cur_max), XlcGetMask },
+ { XlcNStateDependentEncoding, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XLCdPublicRec, pub.is_state_depend), XlcGetMask },
+ { XlcNTerritory, NULLQUARK, sizeof(char *),
+ XOffsetOf(XLCdPublicRec, pub.territory), XlcGetMask }
+};
+
+static char *
+get_values(
+ XLCd lcd,
+ XlcArgList args,
+ int num_args)
+{
+ XLCdPublic pub = (XLCdPublic) lcd->core;
+
+ if (resources[0].xrm_name == NULLQUARK)
+ _XlcCompileResourceList(resources, XlcNumber(resources));
+
+ return _XlcGetValues((XPointer) pub, resources, XlcNumber(resources), args,
+ num_args, XlcGetMask);
+}
diff --git a/nx-X11/lib/X11/lcRM.c b/nx-X11/lib/X11/lcRM.c
new file mode 100644
index 000000000..1ffa4ef72
--- /dev/null
+++ b/nx-X11/lib/X11/lcRM.c
@@ -0,0 +1,226 @@
+/* $Xorg: lcRM.c,v 1.3 2000/08/17 19:45:19 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ * Bug fixes: Bruno Haible XFree86 Inc.
+ */
+/* $XFree86: xc/lib/X11/lcRM.c,v 1.4 2000/11/28 18:49:48 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include <stdio.h>
+
+/*
+ * Default implementation of methods for Xrm parsing.
+ */
+
+/* ======================= Unibyte implementation ======================= */
+
+/* Only for efficiency, to speed up things. */
+
+/* This implementation must keep the locale, for lcname. */
+typedef struct _UbStateRec {
+ XLCd lcd;
+} UbStateRec, *UbState;
+
+/* Sets the state to the initial state.
+ Initiates a sequence of calls to mbchar. */
+static void
+ub_mbinit(
+ XPointer state)
+{
+}
+
+/* Transforms one multibyte character, and return a 'char' in the same
+ parsing class. Returns the number of consumed bytes in *lenp. */
+static char
+ub_mbchar(
+ XPointer state,
+ const char *str,
+ int *lenp)
+{
+ *lenp = 1;
+ return *str;
+}
+
+/* Terminates a sequence of calls to mbchar. */
+static void
+ub_mbfinish(
+ XPointer state)
+{
+}
+
+/* Returns the name of the state's locale, as a static string. */
+static const char *
+ub_lcname(
+ XPointer state)
+{
+ return ((UbState) state)->lcd->core->name;
+}
+
+/* Frees the state, which was allocated by _XrmDefaultInitParseInfo. */
+static void
+ub_destroy(
+ XPointer state)
+{
+ _XCloseLC(((UbState) state)->lcd);
+ Xfree((char *) state);
+}
+
+static const XrmMethodsRec ub_methods = {
+ ub_mbinit,
+ ub_mbchar,
+ ub_mbfinish,
+ ub_lcname,
+ ub_destroy
+};
+
+/* ======================= Multibyte implementation ======================= */
+
+/* This implementation uses an XlcConv from XlcNMultiByte to XlcNWideChar. */
+typedef struct _MbStateRec {
+ XLCd lcd;
+ XlcConv conv;
+} MbStateRec, *MbState;
+
+/* Sets the state to the initial state.
+ Initiates a sequence of calls to mbchar. */
+static void
+mb_mbinit(
+ XPointer state)
+{
+ _XlcResetConverter(((MbState) state)->conv);
+}
+
+/* Transforms one multibyte character, and return a 'char' in the same
+ parsing class. Returns the number of consumed bytes in *lenp. */
+static char
+mb_mbchar(
+ XPointer state,
+ const char *str,
+ int *lenp)
+{
+ XlcConv conv = ((MbState) state)->conv;
+ const char *from;
+ wchar_t *to, wc;
+ int cur_max, i, from_left, to_left, ret;
+
+ cur_max = XLC_PUBLIC(((MbState) state)->lcd, mb_cur_max);
+
+ from = str;
+ /* Determine from_left. Avoid overrun error which could occur if
+ from_left > strlen(str). */
+ from_left = cur_max;
+ for (i = 0; i < cur_max; i++)
+ if (str[i] == '\0') {
+ from_left = i;
+ break;
+ }
+ *lenp = from_left;
+
+ to = &wc;
+ to_left = 1;
+
+ ret = _XlcConvert(conv, (XPointer *) &from, &from_left,
+ (XPointer *) &to, &to_left, NULL, 0);
+ *lenp -= from_left;
+
+ if (ret < 0 || to_left > 0) {
+ /* Invalid or incomplete multibyte character seen. */
+ *lenp = 1;
+ return 0x7f;
+ }
+ /* Return a 'char' equivalent to wc. */
+ return (wc >= 0 && wc <= 0x7f ? wc : 0x7f);
+}
+
+/* Terminates a sequence of calls to mbchar. */
+static void
+mb_mbfinish(
+ XPointer state)
+{
+}
+
+/* Returns the name of the state's locale, as a static string. */
+static const char *
+mb_lcname(
+ XPointer state)
+{
+ return ((MbState) state)->lcd->core->name;
+}
+
+/* Frees the state, which was allocated by _XrmDefaultInitParseInfo. */
+static void
+mb_destroy(
+ XPointer state)
+{
+ _XlcCloseConverter(((MbState) state)->conv);
+ _XCloseLC(((MbState) state)->lcd);
+ Xfree((char *) state);
+}
+
+static const XrmMethodsRec mb_methods = {
+ mb_mbinit,
+ mb_mbchar,
+ mb_mbfinish,
+ mb_lcname,
+ mb_destroy
+};
+
+/* ======================= Exported function ======================= */
+
+XrmMethods
+_XrmDefaultInitParseInfo(
+ XLCd lcd,
+ XPointer *rm_state)
+{
+ if (XLC_PUBLIC(lcd, mb_cur_max) == 1) {
+ /* Unibyte case. */
+ UbState state = (UbState) Xmalloc(sizeof(UbStateRec));
+ if (state == NULL)
+ return (XrmMethods) NULL;
+
+ state->lcd = lcd;
+
+ *rm_state = (XPointer) state;
+ return &ub_methods;
+ } else {
+ /* Multibyte case. */
+ MbState state = (MbState) Xmalloc(sizeof(MbStateRec));
+ if (state == NULL)
+ return (XrmMethods) NULL;
+
+ state->lcd = lcd;
+ state->conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar);
+ if (state->conv == NULL) {
+ Xfree((char *) state);
+ return (XrmMethods) NULL;
+ }
+
+ *rm_state = (XPointer) state;
+ return &mb_methods;
+ }
+}
diff --git a/nx-X11/lib/X11/lcSjis.c b/nx-X11/lib/X11/lcSjis.c
new file mode 100644
index 000000000..6adb2945d
--- /dev/null
+++ b/nx-X11/lib/X11/lcSjis.c
@@ -0,0 +1,1614 @@
+/* $Xorg: lcSjis.c,v 1.3 2000/08/17 19:45:19 cpqbld Exp $ */
+/****************************************************************
+
+ Copyright 1992, 1993 by FUJITSU LIMITED
+ Copyright 1993 by Fujitsu Open Systems Solutions, Inc.
+ Copyright 1994 by Sony 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 of FUJITSU LIMITED,
+Fujitsu Open Systems Solutions, Inc. and Sony Corporation not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+FUJITSU LIMITED, Fujitsu Open Systems Solutions, Inc. and
+Sony Corporation make no representations about the suitability of
+this software for any purpose. It is provided "as is" without
+express or implied warranty.
+
+FUJITSU LIMITED, FUJITSU OPEN SYSTEMS SOLUTIONS, INC. AND SONY
+CORPORATION DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL FUJITSU OPEN SYSTEMS SOLUTIONS, INC., FUJITSU LIMITED
+AND SONY CORPORATION 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.
+
+ Authors: Jeffrey Bloomfield (jeffb@ossi.com)
+ Shigeru Yamada (yamada@ossi.com)
+ Yoshiyuki Segawa (segawa@ossi.com)
+ Modifier:Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+
+*****************************************************************/
+/* $XFree86: xc/lib/X11/lcSjis.c,v 3.9 2002/04/10 16:20:06 tsi Exp $ */
+
+/*
+ * A Japanese SJIS locale.
+ * Supports: all locales with codeset SJIS.
+ * How: Provides converters for SJIS.
+ * Platforms: Only those defining X_LOCALE (only Lynx, Linux-libc5, OS/2).
+ */
+
+#ifdef X_LOCALE
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcGeneric.h"
+
+#include <ctype.h>
+#ifdef WIN32
+#define isascii __isascii
+#endif
+
+#define CS0 codesets[0] /* Codeset 0 - 7-bit ASCII */
+#define CS1 codesets[1] /* Codeset 1 - Kanji */
+#define CS2 codesets[2] /* Codeset 2 - Half-Kana */
+#define CS3 codesets[3] /* Codeset 3 - User defined */
+
+#define ascii (codeset->cs_num == 0)
+#define kanji (codeset->cs_num == 1)
+#define kana (codeset->cs_num == 2)
+#define userdef (codeset->cs_num == 3)
+
+#define ASCII_CODESET 0
+#define KANJI_CODESET 1
+#define KANA_CODESET 2
+#define USERDEF_CODESET 3
+#define MAX_CODESETS 4
+
+#define GR 0x80 /* begins right-side (non-ascii) region */
+#define GL 0x7f /* ends left-side (ascii) region */
+
+#define isleftside(c) (((c) & GR) ? 0 : 1)
+#define isrightside(c) (!isleftside(c))
+
+typedef unsigned char Uchar;
+typedef unsigned long Ulong;
+typedef unsigned int Uint;
+
+/* Acceptable range for 2nd byte of SJIS multibyte char */
+#define VALID_MULTIBYTE(c) \
+ ((0x40<=((Uchar)c) && ((Uchar)c)<=0x7e) \
+ || (0x80<=((Uchar)c) && ((Uchar)c)<=0xfc))
+
+#ifndef iskanji
+#define iskanji(c) ((0x81<=((Uchar)c) && ((Uchar)c)<=0x9f) \
+ || (0xe0<=((Uchar)c) && ((Uchar)c)<=0xef))
+#endif /* !iskanji */
+
+#ifndef iskana
+#define iskana(c) (0xa1<=((Uchar)c) && ((Uchar)c)<=0xdf)
+#endif /* !iskana */
+
+#define isuserdef(c) (0xf0<=((Uchar)c) && ((Uchar)c)<=0xfc)
+
+#define BIT8OFF(c) ((c) & GL)
+#define BIT8ON(c) ((c) | GR)
+
+
+static void jis_to_sjis (Uchar *p1, Uchar *p2);
+static void sjis_to_jis (Uchar *p1, Uchar *p2);
+static CodeSet wc_codeset (XLCd lcd, wchar_t wch);
+
+
+/*
+ * Notes:
+ * 1. 16-bit widechar format is limited to 14 data bits. Since the 2nd byte
+ * of SJIS multibyte chars are in the ranges of 0x40 - 7E and 0x80 - 0xFC,
+ * SJIS cannot map directly into 16 bit widechar format within the confines
+ * of a single codeset. Therefore, for SJIS widechar conversion, SJIS Kanji
+ * is mapped into the JIS codeset. (The algorithms used in jis_to_sjis()
+ * and sjis_to_jis() are from Ken Lunde (lunde@mv.us.adobe.com) and are in
+ * the public domain.)
+ * 2. Defining FORCE_INDIRECT_CONVERTER (see _XlcEucLoader())
+ * forces indirect (charset) conversions (e.g. wcstocs()<->cstombs()).
+ * 3. Using direct converters (e.g. mbstowcs()) decreases conversion
+ * times by 20-40% (depends on specific converter used).
+ */
+
+
+static int
+sjis_mbstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+
+ XLCd lcd = (XLCd)conv->state;
+
+ int chr_len = 0;
+ int shift_mult = 0;
+ Uint chrcode = 0;
+
+ Uchar ch, ch2;
+ Uint wc_encode = 0;
+ Uint wc_tmp = 0;
+
+ Bool new_char;
+
+ int firstbyte;
+ int length = 0;
+ int num_conv;
+ int unconv_num = 0;
+
+ const char *inbufptr = *from;
+ wchar_t *outbufptr = (wchar_t *) *to;
+ wchar_t *outbuf_base = outbufptr;
+
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (new_char = True, firstbyte = True; *from_left > 0; (*from_left)--) {
+
+ ch = *inbufptr++;
+
+ if (firstbyte) {
+ if (ASCII_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ if (isascii(ch)) {
+ length = CS0->length;
+ *outbufptr++ = (wchar_t)ch;
+ continue;
+ }
+ else if (iskanji(ch)) {
+ if (KANJI_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ firstbyte = False;
+ length = CS1->length;
+ if (*from_left < length || *to_left < length)
+ return -1;
+ wc_encode = CS1->wc_encoding;
+ ch2 = *inbufptr;
+ sjis_to_jis(&ch, &ch2);
+ chrcode = ch;
+ }
+ else if (iskana(ch)) {
+ if (KANA_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ length = CS2->length;
+ wc_encode = CS2->wc_encoding;
+ chrcode = BIT8OFF(ch);
+ }
+ else if (isuserdef(ch)) {
+ if (USERDEF_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ firstbyte = False;
+ length = CS3->length;
+ if (*from_left < length || *to_left < length)
+ return -1;
+ wc_encode = CS3->wc_encoding;
+ ch2 = *inbufptr;
+ sjis_to_jis(&ch, &ch2);
+ chrcode = ch;
+ }
+ else /* unknown */ {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ } else { /* 2nd byte of multibyte char */
+ if (!VALID_MULTIBYTE((Uchar) *(inbufptr-1))) {
+ unconv_num++;
+ firstbyte = True;
+ }
+ chrcode = ch2;
+ }
+
+ if (new_char) {
+ chr_len = length;
+ shift_mult = length - 1;
+ new_char = False;
+ }
+
+ chrcode <<= (wc_shift * shift_mult);
+ shift_mult--;
+ wc_tmp |= chrcode;
+ if (--chr_len == 0) {
+ wc_tmp |= wc_encode;
+ *outbufptr++ = wc_tmp;
+
+ firstbyte = True;
+ new_char = True;
+ wc_tmp = (Uint)0;
+ }
+
+ } /* end for */
+
+ *to = (XPointer)outbufptr;
+
+ if ((num_conv = outbufptr - outbuf_base) > 0)
+ (*to_left) -= num_conv;
+
+ return unconv_num;
+}
+
+
+#define byte1 (length == codeset->length - 1)
+#define byte2 (byte1 == 0)
+
+static int
+sjis_wcstombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const wchar_t *inbufptr = (const wchar_t *) *from;
+ XPointer outbufptr = *to;
+ XPointer outbuf_base = outbufptr;
+ wchar_t wch;
+ int length;
+ Uchar tmp;
+ Uchar t1, t2;
+ int num_conv;
+ int unconv_num = 0;
+
+ XLCd lcd = (XLCd)conv->state;
+ CodeSet codeset;
+ Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (; *from_left > 0 ; (*from_left)-- ) {
+
+ wch = *inbufptr++;
+
+ if (!(codeset = wc_codeset(lcd, wch))) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+
+ length = codeset->length;
+ wch ^= (wchar_t)codeset->wc_encoding;
+
+ do {
+ length--;
+ tmp = wch>>(wchar_t)( (Ulong)length * wc_shift);
+
+ if (kana)
+ tmp = BIT8ON(tmp);
+
+ else if (byte1 && (kanji || userdef)) {
+ t1 = BIT8OFF(tmp);
+ continue;
+ }
+
+ else if (byte2 && (kanji || userdef)) {
+ t2 = BIT8OFF(tmp);
+ jis_to_sjis(&t1, &t2);
+ *outbufptr++ = (char)t1;
+ tmp = t2;
+ }
+
+ *outbufptr++ = (char)tmp;
+ } while (length);
+
+ } /* end for */
+
+ *to = (XPointer)outbufptr;
+
+ if ((num_conv = (int)(outbufptr - outbuf_base)) > 0)
+ (*to_left) -= num_conv;
+
+ return unconv_num;
+}
+#undef byte1
+#undef byte2
+
+/*
+ * sjis<->jis conversion for widechar kanji (See Note at top of file)
+ */
+static void
+sjis_to_jis(
+ Uchar *p1,
+ Uchar *p2)
+{
+ Uchar c1 = *p1;
+ Uchar c2 = *p2;
+ Uchar adjust = c2 < 0x9f;
+ Uchar rowOffset = c1 < 0xa0 ? 0x70 : 0xb0;
+ Uchar cellOffset = adjust ? (0x1f + (c2 > 0x7f)) : 0x7e;
+
+ *p1 = ((c1 - rowOffset) << 1) - adjust;
+ *p2 -= cellOffset;
+}
+
+static void
+jis_to_sjis(
+ Uchar *p1,
+ Uchar *p2)
+{
+ Uchar c1 = *p1;
+ Uchar c2 = *p2;
+ Uchar rowOffset = c1 < 0x5f ? 0x70 : 0xb0;
+ Uchar cellOffset = c1 % 2 ? 0x1f + (c2 > 0x5f) : 0x7e;
+
+ *p1 = ((Uchar)(c1 + 1) >> 1) + rowOffset;
+ *p2 = c2 + cellOffset;
+}
+
+static CodeSet
+wc_codeset(
+ XLCd lcd,
+ wchar_t wch)
+{
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+#if !defined(__sony_news) || defined(SVR4)
+ int end = XLC_GENERIC(lcd, codeset_num);
+ Ulong widech = (Ulong)(wch & XLC_GENERIC(lcd, wc_encode_mask));
+
+ for (; --end >= 0; codesets++)
+ if ( widech == (*codesets)->wc_encoding )
+ return *codesets;
+
+ return NULL;
+#else
+ if( iskanji(wch >> 8) )
+ return( codesets[1] );
+ if( iskana(wch & 0xff) )
+ return( codesets[2] );
+ return( codesets[0] );
+#endif
+}
+
+
+static int
+sjis_mbtocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XLCd lcd = (XLCd)conv->state;
+ XlcCharSet charset = NULL;
+ int char_size = 0;
+ int unconv_num = 0;
+ const char *src = *from;
+ char *dst = *to;
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+ if (iskanji(*src)) {
+ if (KANJI_CODESET >= codeset_num)
+ return -1;
+ charset = *CS1->charset_list;
+ char_size = charset->char_size;
+
+ if (*from_left >= char_size && *to_left >= char_size) {
+ *dst++ = *src++;
+ *dst++ = *src++;
+ if (!VALID_MULTIBYTE((Uchar) *(src-1))) /* check 2nd byte */
+ unconv_num++;
+ sjis_to_jis((Uchar *)(dst-2), (Uchar *)(dst-1));
+ } else
+ return -1;
+ }
+ else if (isuserdef(*src)) {
+ if (USERDEF_CODESET >= codeset_num)
+ return -1;
+ charset = *CS3->charset_list;
+ char_size = charset->char_size;
+
+ if (*from_left >= char_size && *to_left >= char_size) {
+ *dst++ = *src++;
+ *dst++ = *src++;
+ if (!VALID_MULTIBYTE((Uchar) *(src-1))) /* check 2nd byte */
+ unconv_num++;
+ sjis_to_jis((Uchar *)(dst-2), (Uchar *)(dst-1));
+ } else
+ return -1;
+ }
+ else if (isascii(*src)) {
+ if (ASCII_CODESET >= codeset_num)
+ return -1;
+ charset = *CS0->charset_list;
+ char_size = charset->char_size;
+
+ if (*from_left >= char_size && *to_left >= char_size)
+ *dst++ = *src++;
+ else
+ return -1;
+ }
+ else if (iskana(*src)) {
+ if (KANA_CODESET >= codeset_num)
+ return -1;
+ charset = *CS2->charset_list;
+ char_size = charset->char_size;
+
+ if (*from_left >= char_size && *to_left >= char_size)
+ *dst++ = *src++;
+ else
+ return -1;
+ }
+ else /* unknown */
+ return -1;
+
+ *from_left -= char_size;
+ *to_left -= char_size;
+
+ *to = (XPointer) dst;
+ *from = (XPointer) src;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return unconv_num;
+}
+
+
+static int
+sjis_mbstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const char *tmp_from;
+ char *tmp_to;
+ int tmp_from_left, tmp_to_left;
+ XlcCharSet charset, tmp_charset;
+ XPointer tmp_args[1];
+ int unconv_num = 0, ret;
+
+/* Determine the charset of the segment and convert one character: */
+
+ tmp_args[0] = (XPointer) &charset; /* charset from sjis_mbtocs() */
+ while
+ ((ret = sjis_mbtocs(conv, from, from_left, to, to_left, tmp_args, 1)) > 0)
+ unconv_num += ret;
+ if ( ret < 0 )
+ return ret;
+
+ tmp_from = *from;
+ tmp_from_left = *from_left;
+ tmp_to_left = *to_left;
+ tmp_to = *to;
+
+/* Convert remainder of the segment: */
+
+ tmp_args[0] = (XPointer) &tmp_charset;
+ while( (ret = sjis_mbtocs(conv, (XPointer *) &tmp_from, &tmp_from_left,
+ (XPointer *) &tmp_to, &tmp_to_left, tmp_args, 1)) >= 0 ) {
+
+ if (ret > 0) {
+ unconv_num += ret;
+ continue;
+ }
+
+ if (tmp_charset != charset) /* quit on end of segment */
+ break;
+
+ *from = (XPointer) tmp_from;
+ *from_left = tmp_from_left;
+ *to = (XPointer) tmp_to;
+ *to_left = tmp_to_left;
+ }
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return unconv_num;
+}
+
+static int
+sjis_wcstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XLCd lcd = (XLCd) conv->state;
+ const wchar_t *wcptr = *((const wchar_t **)from);
+ char *bufptr = *((char **) to);
+ wchar_t wch;
+ char *tmpptr;
+ int length;
+ CodeSet codeset;
+ Ulong wc_encoding;
+ int buf_len = *to_left;
+ int wcstr_len = *from_left;
+
+ if (!(codeset = wc_codeset(lcd, *wcptr)))
+ return -1;
+
+ if (wcstr_len < buf_len / codeset->length)
+ buf_len = wcstr_len * codeset->length;
+
+#if !defined(__sony_news) || defined(SVR4)
+ wc_encoding = codeset->wc_encoding;
+
+ for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) {
+ wch = *wcptr;
+
+ if ((wch & XLC_GENERIC(lcd, wc_encode_mask)) != wc_encoding)
+ break;
+
+ length = codeset->length;
+
+ buf_len -= length;
+ bufptr += length;
+ tmpptr = bufptr - 1;
+
+ while (length--) {
+ *tmpptr-- = kana ? BIT8ON(wch) : BIT8OFF(wch);
+ wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
+ }
+ }
+#else
+ length = codeset->length;
+ for( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len-- ) {
+ wch = *wcptr;
+ if( codeset != wc_codeset( lcd, wch ) )
+ break;
+
+ buf_len -= length;
+ if( length == 2 ) {
+ unsigned short code;
+
+ code = sjis2jis( wch & 0xffff );
+ *bufptr++ = code >> 8;
+ *bufptr++ = code & 0xff;
+ }
+ else
+ *bufptr++ = wch & 0xff;
+ }
+#endif
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = *codeset->charset_list;
+
+ *from_left -= wcptr - (wchar_t *) *from;
+ *from = (XPointer) wcptr;
+
+ *to_left -= bufptr - *to;
+ *to = bufptr;
+
+ return 0;
+}
+
+static CodeSet
+GetCodeSetFromCharSet(
+ XLCd lcd,
+ XlcCharSet charset)
+{
+ CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
+ XlcCharSet *charset_list;
+ int codeset_num, num_charsets;
+
+ codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+ for ( ; codeset_num-- > 0; codeset++) {
+ num_charsets = (*codeset)->num_charsets;
+ charset_list = (*codeset)->charset_list;
+
+ for ( ; num_charsets-- > 0; charset_list++)
+ if (*charset_list == charset)
+ return *codeset;
+ }
+
+ return (CodeSet) NULL;
+}
+
+
+static int
+sjis_cstombs(
+ XlcConv conv,
+ char **from,
+ int *from_left,
+ char **to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XLCd lcd = (XLCd) conv->state;
+ const char *csptr = *from;
+ char *bufptr = *to;
+ int csstr_len = *from_left;
+ int buf_len = *to_left;
+ int length;
+ CodeSet codeset;
+ int cvt_length = 0;
+
+ if (num_args < 1)
+ return -1;
+
+ if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0])))
+ return -1;
+
+ csstr_len /= codeset->length;
+ buf_len /= codeset->length;
+ if (csstr_len < buf_len)
+ buf_len = csstr_len;
+
+ cvt_length += buf_len * codeset->length;
+
+ if (bufptr) {
+ while (buf_len--) {
+ length = codeset->length;
+ while (length--)
+ *bufptr++ = codeset->length == 1 && codeset->side == XlcGR ?
+ BIT8ON(*csptr++) : BIT8OFF(*csptr++);
+
+ if (codeset->length == 2)
+ jis_to_sjis((Uchar *)(bufptr-2), (Uchar *)(bufptr-1));
+ }
+ }
+
+ *from_left -= csptr - *from;
+ *from = (XPointer) csptr;
+
+ if (bufptr)
+ *to += cvt_length;
+ *to_left -= cvt_length;
+
+
+ return 0;
+}
+
+static int
+sjis_cstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XLCd lcd = (XLCd) conv->state;
+ const char *csptr = (const char *) *from;
+ wchar_t *bufptr = (wchar_t *) *to;
+ wchar_t *toptr = (wchar_t *) *to;
+ int csstr_len = *from_left;
+ int buf_len = *to_left;
+ wchar_t wch;
+ int length;
+ Ulong wc_shift_bits = (int)XLC_GENERIC(lcd, wc_shift_bits);
+ CodeSet codeset;
+
+ if (num_args < 1)
+ return -1;
+
+ if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0])))
+ return -1;
+
+ csstr_len /= codeset->length;
+ if (csstr_len < buf_len)
+ buf_len = csstr_len;
+
+ *to_left -= buf_len;
+
+ if (bufptr) {
+
+ toptr += buf_len;
+ *to = (XPointer) toptr;
+
+ while (buf_len--) {
+ wch = (wchar_t) BIT8OFF(*csptr);
+ csptr++;
+
+ length = codeset->length - 1;
+ while (length--) {
+ wch = (wch << wc_shift_bits) | BIT8OFF(*csptr);
+ csptr++;
+ }
+ *bufptr++ = wch | codeset->wc_encoding;
+ }
+ }
+
+ *from_left -= csptr - *from;
+ *from = (XPointer) csptr;
+
+ return 0;
+}
+
+
+/*
+ * Stripped down Direct CT converters for SJIS
+ *
+ */
+
+#define BADCHAR(min_ch, c) (BIT8OFF(c) < (char)min_ch && BIT8OFF(c) != 0x0 && \
+ BIT8OFF(c) != '\t' && BIT8OFF(c) != '\n' && \
+ BIT8OFF(c) != 0x1b)
+
+typedef struct _CTDataRec {
+ int side;
+ int length;
+ char *name;
+ Ulong wc_encoding;
+ char *ct_encoding;
+ int ct_encoding_len;
+ int set_size;
+ Uchar min_ch;
+ Uchar ct_type;
+} CTDataRec, *CTData;
+
+typedef struct _StateRec {
+ CTData GL_charset;
+ CTData GR_charset;
+ CTData charset;
+} StateRec, *State;
+
+#define CT_STD 0
+#define CT_NSTD 1
+#define CT_DIR 2
+#define CT_EXT0 3
+#define CT_EXT1 4
+#define CT_EXT2 5
+#define CT_VER 6
+
+static CTDataRec ctdata[] =
+{
+ { XlcGL, 1, "ISO8859-1:GL", 0, "\033(B" , 3, 0, 0, CT_STD },
+ { XlcGR, 1, "ISO8859-1:GR", 0, "\033-A" , 3, 0, 0, CT_STD },
+ { XlcGL, 1, "JISX0201.1976-0:GL", 0, "\033(J" , 3, 0, 0, CT_STD },
+ { XlcGR, 1, "JISX0201.1976-0:GR", 0, "\033)I" , 3, 0, 0, CT_STD },
+ { XlcGL, 2, "JISX0208.1983-0:GL", 0, "\033$(B" , 4, 0, 0, CT_STD },
+ { XlcGR, 2, "JISX0208.1983-0:GR", 0, "\033$)B" , 4, 0, 0, CT_STD },
+ { XlcGL, 2, "JISX0212.1990-0:GL", 0, "\033$(D" , 4, 0, 0, CT_STD },
+ { XlcGR, 2, "JISX0212.1990-0:GR", 0, "\033$)D" , 4, 0, 0, CT_STD },
+ { XlcUnknown, 0, "Ignore-Ext-Status?", 0, "\033#" , 2, 0, 0, CT_VER },
+ { XlcUnknown, 0, "NonStd-?-OctetChar", 0, "\033%/0" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 1, "NonStd-1-OctetChar", 0, "\033%/1" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 2, "NonStd-2-OctetChar", 0, "\033%/2" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 3, "NonStd-3-OctetChar", 0, "\033%/3" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 4, "NonStd-4-OctetChar", 0, "\033%/4" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 0, "Extension-2" , 0, "\033%/" , 3, 0, 0, CT_EXT2 },
+ { XlcUnknown, 0, "Extension-0" , 0, "\033" , 1, 0, 0, CT_EXT0 },
+ { XlcUnknown, 0, "Begin-L-to-R-Text", 0, "\2331]" , 3, 0, 0, CT_DIR },
+ { XlcUnknown, 0, "Begin-R-to-L-Text", 0, "\2332]" , 3, 0, 0, CT_DIR },
+ { XlcUnknown, 0, "End-Of-String", 0, "\233]" , 2, 0, 0, CT_DIR },
+ { XlcUnknown, 0, "Extension-1" , 0, "\233" , 1, 0, 0, CT_EXT1 },
+};
+
+/* Note on above table: sjis_ctstombs() and sjis_ctstowcs() parser depends on
+ * certain table entries occuring in decreasing string length--
+ * 1. CT_EXT2 and CT_EXT0 entries must occur after CT_NSTD entries.
+ * 2. CT_DIR and CT_EXT1 entries must occur after CT_DIR entries.
+ */
+
+static CTData ctdptr[sizeof(ctdata) / sizeof(CTDataRec)];
+static CTData ctd_endp = ctdata + ((sizeof(ctdata) / sizeof(CTDataRec))) - 1;
+
+#define Ascii 0
+#define Kanji 1
+#define Kana 2
+#define Userdef 3
+
+/*
+ * initCTptr(): Set ctptr[] to point at ctdata[], indexed by codeset_num.
+ */
+static void
+initCTptr(
+ XLCd lcd)
+{
+ int num_codesets = XLC_GENERIC(lcd, codeset_num);
+ int num_charsets;
+ int i, j;
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ CodeSet codeset;
+ XlcCharSet charset;
+ CTData ctdp = ctdata;
+
+ ctdptr[Ascii] = &ctdata[0]; /* failsafe */
+
+ for (i = 0; i < num_codesets; i++) {
+
+ codeset = codesets[i];
+ num_charsets = codeset->num_charsets;
+
+ for (j = 0; j < num_charsets; j++) {
+
+ charset = codeset->charset_list[j];
+
+ for (ctdp = ctdata; ctdp <= ctd_endp; ctdp++)
+
+ if (! strcmp(ctdp->name, charset->name)) {
+
+ ctdptr[codeset->cs_num] = ctdp;
+
+ ctdptr[codeset->cs_num]->wc_encoding = codeset->wc_encoding;
+
+ ctdptr[codeset->cs_num]->set_size =
+ charset->set_size;
+
+ ctdptr[codeset->cs_num]->min_ch =
+ charset->set_size == 94 &&
+ (ctdptr[codeset->cs_num]->length > 1 ||
+ ctdptr[codeset->cs_num]->side == XlcGR) ? 0x21 : 0x20;
+
+ break;
+ }
+ }
+ }
+}
+
+
+static int
+sjis_mbstocts(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ int ct_len = *to_left;
+ int cs_num;
+ int clen;
+ int unconv_num = 0;
+ int num_conv;
+ const char *inbufptr = *from;
+ char *ctptr = *to;
+ XPointer ct_base = ctptr;
+
+ StateRec ct_state;
+ CTData charset = NULL;
+ XLCd lcd = (XLCd) conv->state;
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+/* Initial State: */
+
+ ct_state.GL_charset = ctdptr[Ascii];
+ ct_state.GR_charset = NULL;
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (;*from_left > 0; (*from_left) -= charset->length) {
+
+ if (iskanji(*inbufptr)) {
+ if (KANJI_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Kanji;
+ charset = ctdptr[Kanji];
+ if (!VALID_MULTIBYTE((Uchar) *(inbufptr+1)))
+ unconv_num++;
+ }
+ else if (isuserdef(*inbufptr)) {
+ if (USERDEF_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Userdef;
+ charset = ctdptr[Userdef];
+ if (!VALID_MULTIBYTE((Uchar) *(inbufptr+1)))
+ unconv_num++;
+ }
+ else if (isascii(*inbufptr)) {
+ if (ASCII_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Ascii;
+ charset = ctdptr[Ascii];
+ }
+ else if (iskana(*inbufptr)) {
+ if (KANA_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Kana;
+ charset = ctdptr[Kana];
+ }
+ else { /* unknown */
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+
+ if ( (charset->side == XlcGR && charset != ct_state.GR_charset) ||
+ (charset->side == XlcGL && charset != ct_state.GL_charset) ) {
+
+ ct_len -= ctdptr[cs_num]->ct_encoding_len;
+ if (ct_len < 0) {
+ unconv_num++;
+ break;
+ }
+
+ if (ctptr) {
+ strcpy(ctptr, ctdptr[cs_num]->ct_encoding);
+ ctptr += ctdptr[cs_num]->ct_encoding_len;
+ }
+ }
+
+ clen = charset->length;
+ do {
+ *ctptr++ = *inbufptr++;
+ } while (--clen);
+
+ if (charset->length >= 2) {
+ sjis_to_jis((Uchar *)(ctptr-2), (Uchar *)(ctptr-1));
+ if (BADCHAR(charset->min_ch, *(ctptr-2)) ||
+ BADCHAR(charset->min_ch, *(ctptr-1))) {
+ unconv_num++;
+ continue;
+ }
+ }
+ else
+ if (BADCHAR(charset->min_ch, *(ctptr-1))) {
+ unconv_num++;
+ continue;
+ }
+
+ if (charset->side == XlcGR)
+ ct_state.GR_charset = charset;
+ else if (charset->side == XlcGL)
+ ct_state.GL_charset = charset;
+
+ if (charset->side == XlcGR) {
+ clen = charset->length;
+ do {
+ (*(Uchar *)(ctptr-clen)) = BIT8ON(*(Uchar *)(ctptr-clen));
+ } while (--clen);
+ }
+ }
+
+ *to = (XPointer)ctptr;
+
+ if ((num_conv = (int)(ctptr - ct_base)) > 0)
+ (*to_left) -= num_conv;
+
+ return unconv_num;
+
+}
+
+
+#define byte1 (length == codeset->length - 1)
+#define byte2 (byte1 == 0)
+
+static int
+sjis_wcstocts(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ int ct_len = *to_left;
+ const wchar_t *inbufptr = (const wchar_t *) *from;
+ char *ctptr = *to;
+ XPointer ct_base = ctptr;
+ wchar_t wch;
+ int length;
+ Uchar tmp;
+ Uchar t1 = 0;
+ int num_conv;
+
+ StateRec ct_state;
+ XLCd lcd = (XLCd)conv->state;
+ CTData charset;
+ CodeSet codeset;
+ int unconv_num = 0;
+ Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
+
+/* Initial State: */
+ ct_state.GL_charset = ctdptr[0]; /* Codeset 0 */
+ ct_state.GR_charset = NULL;
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (; *from_left > 0 ; (*from_left)-- ) {
+
+ wch = *inbufptr++;
+
+ if (!(codeset = wc_codeset(lcd, wch))) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+
+ charset = ctdptr[codeset->cs_num];
+
+ length = codeset->length;
+ wch ^= (wchar_t)codeset->wc_encoding;
+
+ if ( (charset->side == XlcGR && charset != ct_state.GR_charset) ||
+ (charset->side == XlcGL && charset != ct_state.GL_charset) ) {
+
+ ct_len -= ctdptr[codeset->cs_num]->ct_encoding_len;
+ if (ct_len < 0) {
+ unconv_num++;
+ break;
+ }
+
+ if (ctptr) {
+ strcpy(ctptr, ctdptr[codeset->cs_num]->ct_encoding);
+ ctptr += ctdptr[codeset->cs_num]->ct_encoding_len;
+ }
+
+ }
+
+ if (charset->side == XlcGR)
+ ct_state.GR_charset = charset;
+ else if (charset->side == XlcGL)
+ ct_state.GL_charset = charset;
+
+ do {
+ length--;
+ tmp = wch>>(wchar_t)( (Ulong)length * wc_shift);
+
+ if (kana) {
+ if (BADCHAR(charset->min_ch, (char)tmp)) {
+ unconv_num++;
+ break;
+ }
+ *ctptr++ = (char)BIT8ON(tmp);
+ }
+
+ else if (byte1 && (kanji || userdef)) {
+ t1 = tmp;
+ }
+
+ else if (byte2 && (kanji || userdef)) {
+ if (BADCHAR(charset->min_ch, (char)t1) ||
+ BADCHAR(charset->min_ch, (char)tmp)) {
+ unconv_num++;
+ break;
+ }
+
+ *ctptr++ = (char)BIT8OFF(t1);
+ *ctptr++ = (char)BIT8OFF(tmp);
+ }
+
+ else {
+ if (BADCHAR(charset->min_ch, (char)tmp)) {
+ unconv_num++;
+ break;
+ }
+ *ctptr++ = (char)tmp;
+ }
+ } while (length);
+
+ } /* end for */
+
+ *to = (XPointer)ctptr;
+
+ if ((num_conv = (int)(ctptr - ct_base)) > 0)
+ (*to_left) -= num_conv;
+
+ return unconv_num;
+}
+#undef byte1
+#undef byte2
+
+#define SKIP_I(str) while (*(str) >= 0x20 && *(str) <= 0x2f) (str)++;
+#define SKIP_P(str) while (*(str) >= 0x30 && *(str) <= 0x3f) (str)++;
+
+static int
+sjis_ctstombs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const char *inbufptr = *from;
+ XPointer outbufptr = *to;
+ const char *inbuf_base;
+ XPointer outbuf_base = outbufptr;
+ int clen, length;
+ int unconv_num = 0;
+ int num_conv;
+ unsigned int ct_seglen = 0;
+ Uchar ct_type;
+ CTData ctdp = ctdata; /* default */
+ CTData GL_ctdp = ctdp; /* GL ctdp save */
+ CTData GR_ctdp = ctdp; /* GR ctdp save */
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (length = ctdata[Ascii].length; *from_left > 0 ; (*from_left) -= length)
+ {
+ ct_type = CT_STD;
+ /* change GL/GR charset */
+ if(ctdp->side == XlcGR && isleftside(*inbufptr)){
+ /* select GL side */
+ ctdp = GL_ctdp;
+ length = ctdp->length;
+ ct_type = ctdp->ct_type;
+ }else if(ctdp->side == XlcGL && isrightside(*inbufptr)){
+ /* select GR side */
+ ctdp = GR_ctdp;
+ length = ctdp->length;
+ ct_type = ctdp->ct_type;
+ }
+ if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
+
+ for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
+
+ if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len))
+ {
+ inbufptr += ctdp->ct_encoding_len;
+ (*from_left) -= ctdp->ct_encoding_len;
+ if( ctdp->length ) {
+ length = ctdp->length;
+ if( *from_left < length ) {
+ *to = (XPointer)outbufptr;
+ *to_left -= outbufptr - outbuf_base;
+ return( unconv_num + *from_left );
+ }
+ }
+ ct_type = ctdp->ct_type;
+ if(ctdp->side == XlcGL){
+ GL_ctdp = ctdp; /* save GL ctdp */
+ }else{
+ GR_ctdp = ctdp; /* save GR ctdp */
+ }
+ break;
+ }
+ }
+ if (ctdp > ctd_endp) /* failed to match CT sequence */
+ unconv_num++;
+ }
+
+/* The following code insures that non-standard encodings, direction, extension,
+ * and version strings are ignored; subject to change in future.
+ */
+ switch (ct_type) {
+ case CT_STD:
+ break;
+ case CT_EXT2:
+ inbufptr++;
+ (*from_left)--;
+ case CT_NSTD:
+ ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2;
+ inbufptr += ct_seglen;
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_EXT0:
+ inbuf_base = inbufptr;
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_EXT1:
+ inbuf_base = inbufptr;
+ SKIP_P(inbufptr);
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_DIR:
+ continue;
+ case CT_VER:
+ inbufptr += 2;
+ (*from_left) -= 2;
+ continue;
+ }
+
+ if (ctdp->side == XlcGL || isrightside (*inbufptr)) {
+ clen = length;
+ } else {
+ clen = 1;
+ *from_left += length - clen;
+ }
+ do {
+ Uchar mask = (length == 2) ? GL : -1;
+ *outbufptr++ = *inbufptr++ & mask;
+ } while (--clen);
+
+ if (length >= 2)
+ jis_to_sjis((Uchar *)(outbufptr-2), (Uchar *)(outbufptr-1));
+ }
+
+ *to = (XPointer)outbufptr;
+
+ if ((num_conv = (int)(outbufptr - outbuf_base)) > 0)
+ (*to_left) -= num_conv;
+
+ return unconv_num;
+}
+
+
+static int
+sjis_ctstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XLCd lcd = (XLCd)conv->state;
+ Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
+ const char *inbufptr = *from;
+ const char *inbuf_base;
+ wchar_t *outbufptr = (wchar_t *) *to;
+ wchar_t *outbuf_base = outbufptr;
+ int clen, length;
+ int num_conv;
+ int unconv_num = 0;
+ unsigned int ct_seglen = 0;
+ Uchar ct_type = 0;
+ int shift_mult;
+ wchar_t wc_tmp;
+ wchar_t wch;
+ Ulong wc_encoding;
+ CTData ctdp = ctdata;
+ CTData GL_ctdp = ctdp; /* GL ctdp save */
+ CTData GR_ctdp = ctdp; /* GR ctdp save */
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length )
+ {
+ ct_type = CT_STD;
+ /* change GL/GR charset */
+ if(ctdp->side == XlcGR && isleftside(*inbufptr)){
+ /* select GL side */
+ ctdp = GL_ctdp;
+ length = ctdp->length;
+ ct_type = ctdp->ct_type;
+ }else if(ctdp->side == XlcGL && isrightside(*inbufptr)){
+ /* select GR side */
+ ctdp = GR_ctdp;
+ length = ctdp->length;
+ ct_type = ctdp->ct_type;
+ }
+ if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
+ for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
+
+ if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len))
+ {
+ inbufptr += ctdp->ct_encoding_len;
+ (*from_left) -= ctdp->ct_encoding_len;
+ if( ctdp->length ) {
+ length = ctdp->length;
+ if( *from_left < length ) {
+ *to = (XPointer)outbufptr;
+ *to_left -= outbufptr - outbuf_base;
+ return( unconv_num + *from_left );
+ }
+ }
+ ct_type = ctdp->ct_type;
+ if(ctdp->side == XlcGL){
+ GL_ctdp = ctdp; /* save GL ctdp */
+ }else{
+ GR_ctdp = ctdp; /* save GR ctdp */
+ }
+ break;
+ }
+ }
+ if (ctdp > ctd_endp) /* failed to match CT sequence */
+ unconv_num++;
+ }
+
+/* The following block of code insures that non-standard encodings, direction,
+ * extension, and version strings are ignored; subject to change in future.
+ */
+ switch (ct_type) {
+ case CT_STD:
+ break;
+ case CT_EXT2:
+ inbufptr++;
+ (*from_left)--;
+ case CT_NSTD:
+ ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2;
+ inbufptr += ct_seglen;
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_EXT0:
+ inbuf_base = inbufptr;
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_EXT1:
+ inbuf_base = inbufptr;
+ SKIP_P(inbufptr);
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_DIR:
+ continue;
+ case CT_VER:
+ inbufptr += 2;
+ (*from_left) -= 2;
+ continue;
+ }
+#if !defined(__sony_news) || defined(SVR4)
+ if (ctdp->side == XlcGL || isrightside (*inbufptr)) {
+ clen = length;
+ wc_encoding = ctdp->wc_encoding;
+ } else {
+ clen = 1;
+ *from_left += length - clen;
+ wc_encoding = ctdptr[Ascii]->wc_encoding;
+ }
+ shift_mult = clen - 1;
+ wch = (wchar_t)0;
+
+ do {
+ wc_tmp = BIT8OFF(*inbufptr++) << (wc_shift_bits * shift_mult);
+ wch |= wc_tmp;
+ shift_mult--;
+ } while (--clen);
+ *outbufptr++ = wch | wc_encoding;
+#else
+ if( length == 1 )
+ *outbufptr++ = (unsigned char)*inbufptr++;
+ else if( length == 2 ) {
+ unsigned short code;
+ code = (*inbufptr << 8) | *(inbufptr+1);
+ *outbufptr++ = jis2sjis( code );
+ inbufptr += 2;
+ }
+#endif
+ }
+ *to = (XPointer)outbufptr;
+
+ if ((num_conv = (int)(outbufptr - outbuf_base)) > 0)
+ (*to_left) -= num_conv ;
+
+ return unconv_num;
+
+}
+#undef BADCHAR
+
+static void
+close_converter(
+ XlcConv conv)
+{
+ Xfree((char *) conv);
+}
+
+
+static XlcConv
+create_conv(
+ XLCd lcd,
+ XlcConvMethods methods)
+{
+ XlcConv conv;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (conv == NULL)
+ return (XlcConv) NULL;
+
+ conv->methods = methods;
+ conv->state = (XPointer) lcd;
+ return conv;
+}
+
+
+enum { MBSTOCS, WCSTOCS, MBTOCS, CSTOMBS, CSTOWCS, MBSTOWCS, WCSTOMBS,
+ WCSTOCTS, MBSTOCTS, CTSTOMBS, CTSTOWCS };
+
+static XlcConvMethodsRec conv_methods[] = {
+ {close_converter, sjis_mbstocs, NULL },
+ {close_converter, sjis_wcstocs, NULL },
+ {close_converter, sjis_mbtocs, NULL },
+ {close_converter, sjis_cstombs, NULL },
+ {close_converter, sjis_cstowcs, NULL },
+ {close_converter, sjis_mbstowcs, NULL },
+ {close_converter, sjis_wcstombs, NULL },
+ {close_converter, sjis_wcstocts, NULL },
+ {close_converter, sjis_mbstocts, NULL },
+ {close_converter, sjis_ctstombs, NULL },
+ {close_converter, sjis_ctstowcs, NULL },
+};
+
+
+static XlcConv
+open_mbstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[MBSTOCS]);
+}
+
+static XlcConv
+open_wcstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[WCSTOCS]);
+}
+
+static XlcConv
+open_mbtocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[MBTOCS]);
+}
+
+static XlcConv
+open_cstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[CSTOMBS]);
+}
+
+static XlcConv
+open_cstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[CSTOWCS]);
+}
+
+static XlcConv
+open_mbstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[MBSTOWCS]);
+}
+
+static XlcConv
+open_wcstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[WCSTOMBS]);
+}
+
+static XlcConv
+open_wcstocts(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[WCSTOCTS]);
+}
+
+static XlcConv
+open_mbstocts(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[MBSTOCTS]);
+}
+
+static XlcConv
+open_ctstombs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[CTSTOMBS]);
+}
+
+static XlcConv
+open_ctstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &conv_methods[CTSTOWCS]);
+}
+
+XLCd
+_XlcSjisLoader(
+ const char *name)
+{
+ XLCd lcd;
+
+ lcd = _XlcCreateLC(name, _XlcGenericMethods);
+ if (lcd == NULL)
+ return lcd;
+
+ if (!XLC_PUBLIC_PART(lcd)->codeset ||
+ (_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "SJIS"))) {
+ _XlcDestroyLC(lcd);
+ return (XLCd) NULL;
+ }
+
+ initCTptr(lcd);
+
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs);
+
+#ifndef FORCE_INDIRECT_CONVERTER
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte, open_ctstombs);
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar, open_ctstowcs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_mbstocts);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_mbstowcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstocts);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstombs);
+#endif
+
+ _XlcAddUtf8Converters(lcd);
+
+ return lcd;
+}
+
+#else
+typedef int dummy;
+#endif /* X_LOCALE */
diff --git a/nx-X11/lib/X11/lcStd.c b/nx-X11/lib/X11/lcStd.c
new file mode 100644
index 000000000..e112dceac
--- /dev/null
+++ b/nx-X11/lib/X11/lcStd.c
@@ -0,0 +1,370 @@
+/* $Xorg: lcStd.c,v 1.4 2000/08/17 19:45:20 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/lcStd.c,v 1.6 2003/04/13 19:22:21 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcPubI.h"
+
+int
+_Xlcmbtowc(
+ XLCd lcd,
+ wchar_t *wstr,
+ char *str,
+ int len)
+{
+ static XLCd last_lcd = NULL;
+ static XlcConv conv = NULL;
+ XPointer from, to;
+ int from_left, to_left;
+ wchar_t tmp_wc;
+
+ if (lcd == NULL) {
+ lcd = _XlcCurrentLC();
+ if (lcd == NULL)
+ return -1;
+ }
+ if (str == NULL)
+ return XLC_PUBLIC(lcd, is_state_depend);
+
+ if (conv && lcd != last_lcd) {
+ _XlcCloseConverter(conv);
+ conv = NULL;
+ }
+
+ last_lcd = lcd;
+
+ if (conv == NULL) {
+ conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar);
+ if (conv == NULL)
+ return -1;
+ }
+
+ from = (XPointer) str;
+ from_left = len;
+ to = (XPointer) (wstr ? wstr : &tmp_wc);
+ to_left = 1;
+
+ if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
+ return -1;
+
+ return (len - from_left);
+}
+
+int
+_Xlcwctomb(
+ XLCd lcd,
+ char *str,
+ wchar_t wc)
+{
+ static XLCd last_lcd = NULL;
+ static XlcConv conv = NULL;
+ XPointer from, to;
+ int from_left, to_left, length;
+
+ if (lcd == NULL) {
+ lcd = _XlcCurrentLC();
+ if (lcd == NULL)
+ return -1;
+ }
+ if (str == NULL)
+ return XLC_PUBLIC(lcd, is_state_depend);
+
+ if (conv && lcd != last_lcd) {
+ _XlcCloseConverter(conv);
+ conv = NULL;
+ }
+
+ last_lcd = lcd;
+
+ if (conv == NULL) {
+ conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
+ if (conv == NULL)
+ return -1;
+ }
+
+ from = (XPointer) &wc;
+ from_left = 1;
+ to = (XPointer) str;
+ length = to_left = XLC_PUBLIC(lcd, mb_cur_max);
+
+ if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
+ return -1;
+
+ return (length - to_left);
+}
+
+int
+_Xlcmbstowcs(
+ XLCd lcd,
+ wchar_t *wstr,
+ char *str,
+ int len)
+{
+ XlcConv conv;
+ XPointer from, to;
+ int from_left, to_left, ret;
+
+ if (lcd == NULL) {
+ lcd = _XlcCurrentLC();
+ if (lcd == NULL)
+ return -1;
+ }
+
+ conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar);
+ if (conv == NULL)
+ return -1;
+
+ from = (XPointer) str;
+ from_left = strlen(str);
+ to = (XPointer) wstr;
+ to_left = len;
+
+ if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
+ ret = -1;
+ else {
+ ret = len - to_left;
+ if (wstr && to_left > 0)
+ wstr[ret] = (wchar_t) 0;
+ }
+
+ _XlcCloseConverter(conv);
+
+ return ret;
+}
+
+int
+_Xlcwcstombs(
+ XLCd lcd,
+ char *str,
+ wchar_t *wstr,
+ int len)
+{
+ XlcConv conv;
+ XPointer from, to;
+ int from_left, to_left, ret;
+
+ if (lcd == NULL) {
+ lcd = _XlcCurrentLC();
+ if (lcd == NULL)
+ return -1;
+ }
+
+ conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
+ if (conv == NULL)
+ return -1;
+
+ from = (XPointer) wstr;
+ from_left = _Xwcslen(wstr);
+ to = (XPointer) str;
+ to_left = len;
+
+ if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
+ ret = -1;
+ else {
+ ret = len - to_left;
+ if (str && to_left > 0)
+ str[ret] = '\0';
+ }
+
+ _XlcCloseConverter(conv);
+
+ return ret;
+}
+
+
+int
+_Xmbtowc(
+ wchar_t *wstr,
+#ifdef ISC
+ char const *str,
+ size_t len
+#else
+ char *str,
+ int len
+#endif
+ )
+{
+ return _Xlcmbtowc((XLCd) NULL, wstr, str, len);
+}
+
+int
+_Xmblen(
+#ifdef ISC
+ char const *str,
+ size_t len
+#else
+ char *str,
+ int len
+#endif
+ )
+{
+ return _Xmbtowc((wchar_t *) NULL, str, len);
+}
+
+int
+_Xwctomb(
+ char *str,
+ wchar_t wc)
+{
+ return _Xlcwctomb((XLCd) NULL, str, wc);
+}
+
+int
+_Xmbstowcs(
+ wchar_t *wstr,
+ char *str,
+ int len)
+{
+ return _Xlcmbstowcs((XLCd) NULL, wstr, str, len);
+}
+
+int
+_Xwcstombs(
+ char *str,
+ wchar_t *wstr,
+ int len)
+{
+ return _Xlcwcstombs((XLCd) NULL, str, wstr, len);
+}
+
+wchar_t *
+_Xwcscpy(
+ register wchar_t *wstr1, register wchar_t *wstr2)
+{
+ wchar_t *wstr_tmp = wstr1;
+
+ while ((*wstr1++ = *wstr2++))
+ ;
+
+ return wstr_tmp;
+}
+
+wchar_t *
+_Xwcsncpy(
+ register wchar_t *wstr1, register wchar_t *wstr2,
+ register int len)
+{
+ wchar_t *wstr_tmp = wstr1;
+
+ while (len-- > 0)
+ if (!(*wstr1++ = *wstr2++))
+ break;
+
+ while (len-- > 0)
+ *wstr1++ = (wchar_t) 0;
+
+ return wstr_tmp;
+}
+
+int
+_Xwcslen(
+ register wchar_t *wstr)
+{
+ register wchar_t *wstr_ptr = wstr;
+
+ while (*wstr_ptr)
+ wstr_ptr++;
+
+ return wstr_ptr - wstr;
+}
+
+int
+_Xwcscmp(
+ register wchar_t *wstr1, register wchar_t *wstr2)
+{
+ for ( ; *wstr1 && *wstr2; wstr1++, wstr2++)
+ if (*wstr1 != *wstr2)
+ break;
+
+ return *wstr1 - *wstr2;
+}
+
+int
+_Xwcsncmp(
+ register wchar_t *wstr1, register wchar_t *wstr2,
+ register int len)
+{
+ for ( ; *wstr1 && *wstr2 && len > 0; wstr1++, wstr2++, len--)
+ if (*wstr1 != *wstr2)
+ break;
+
+ if (len <= 0)
+ return 0;
+
+ return *wstr1 - *wstr2;
+}
+
+
+int
+_Xlcmbstoutf8(
+ XLCd lcd,
+ char *ustr,
+ const char *str,
+ int len)
+{
+ XlcConv conv;
+ XPointer from, to;
+ int from_left, to_left, ret;
+
+ if (lcd == NULL) {
+ lcd = _XlcCurrentLC();
+ if (lcd == NULL)
+ return -1;
+ }
+
+ conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNUtf8String);
+ if (conv == NULL)
+ return -1;
+
+ from = (XPointer) str;
+ from_left = strlen(str);
+ to = (XPointer) ustr;
+ to_left = len;
+
+ if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
+ ret = -1;
+ else {
+ ret = len - to_left;
+ if (ustr && to_left > 0)
+ ustr[ret] = '\0';
+ }
+
+ _XlcCloseConverter(conv);
+
+ return ret;
+}
+
+int
+_Xmbstoutf8(
+ char *ustr,
+ const char *str,
+ int len)
+{
+ return _Xlcmbstoutf8((XLCd) NULL, ustr, str, len);
+}
diff --git a/nx-X11/lib/X11/lcTxtPr.c b/nx-X11/lib/X11/lcTxtPr.c
new file mode 100644
index 000000000..1f9765f6e
--- /dev/null
+++ b/nx-X11/lib/X11/lcTxtPr.c
@@ -0,0 +1,256 @@
+/* $Xorg: lcTxtPr.c,v 1.3 2000/08/17 19:45:20 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/lcTxtPr.c,v 3.3 2001/01/17 19:41:55 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+static int
+get_buf_size(
+ Bool is_wide_char,
+ XPointer list,
+ int count)
+{
+ int length = 0;
+ char **mb_list;
+ wchar_t **wc_list;
+
+ if (list == NULL)
+ return 0;
+
+ if (is_wide_char) {
+ wc_list = (wchar_t **) list;
+ for ( ; count-- > 0; wc_list++) {
+ if (*wc_list)
+ length += _Xwcslen(*wc_list) + 1;
+ }
+ length *= 5; /* XXX */
+ } else {
+ mb_list = (char **) list;
+ for ( ; count-- > 0; mb_list++) {
+ if (*mb_list)
+ length += strlen(*mb_list) + 1;
+ }
+ length *= 3; /* XXX */
+ }
+ length = (length / BUFSIZ + 1) * BUFSIZ; /* XXX */
+
+ return length;
+}
+
+static int
+_XTextListToTextProperty(
+ XLCd lcd,
+ Display *dpy,
+ const char *from_type,
+ XPointer list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty *text_prop)
+{
+ Atom encoding;
+ XlcConv conv;
+ const char *to_type;
+ char **mb_list = NULL;
+ wchar_t **wc_list = NULL;
+ XPointer from;
+ char *to, *buf, *value;
+ int from_left, to_left, buf_len, nitems, unconv_num = 0, ret, i;
+ Bool is_wide_char = False;
+
+ if (strcmp(XlcNWideChar, from_type) == 0)
+ is_wide_char = True;
+
+ buf_len = get_buf_size(is_wide_char, list, count);
+ if ((buf = (char *) Xmalloc(buf_len)) == NULL)
+ return XNoMemory;
+
+ switch (style) {
+ case XStringStyle:
+ case XStdICCTextStyle:
+ encoding = XA_STRING;
+ to_type = XlcNString;
+ break;
+ case XUTF8StringStyle:
+ encoding = XInternAtom(dpy, "UTF8_STRING", False);
+ to_type = XlcNUtf8String;
+ break;
+ case XCompoundTextStyle:
+ encoding = XInternAtom(dpy, "COMPOUND_TEXT", False);
+ to_type = XlcNCompoundText;
+ break;
+ case XTextStyle:
+ encoding = XInternAtom(dpy, XLC_PUBLIC(lcd, encoding_name), False);
+ to_type = XlcNMultiByte;
+ if (is_wide_char == False) {
+ nitems = 0;
+ mb_list = (char **) list;
+ to = buf;
+ for (i = 0; i < count && buf_len > 0; i++) {
+ if (*mb_list)
+ strcpy(to, *mb_list);
+ else
+ *to = '\0';
+ from_left = (*mb_list ? strlen(*mb_list) : 0) + 1;
+ nitems += from_left;
+ to += from_left;
+ mb_list++;
+ }
+ unconv_num = 0;
+ goto done;
+ }
+ break;
+ default:
+ Xfree(buf);
+ return XConverterNotFound;
+ }
+
+ if (count < 1) {
+ nitems = 0;
+ goto done;
+ }
+
+retry:
+ conv = _XlcOpenConverter(lcd, from_type, lcd, to_type);
+ if (conv == NULL) {
+ Xfree(buf);
+ return XConverterNotFound;
+ }
+
+ if (is_wide_char)
+ wc_list = (wchar_t **) list;
+ else
+ mb_list = (char **) list;
+
+ to = buf;
+ to_left = buf_len;
+
+ unconv_num = 0;
+
+ for (i = 1; to_left > 0; i++) {
+ if (is_wide_char) {
+ from = (XPointer) *wc_list;
+ from_left = _Xwcslen(*wc_list);
+ wc_list++;
+ } else {
+ from = (XPointer) *mb_list;
+ from_left = (*mb_list ? strlen(*mb_list) : 0);
+ mb_list++;
+ }
+
+ ret = _XlcConvert(conv, &from, &from_left, (XPointer *) &to, &to_left,
+ NULL, 0);
+
+ if (ret < 0)
+ continue;
+
+ if (ret > 0 && style == XStdICCTextStyle && encoding == XA_STRING) {
+ _XlcCloseConverter(conv);
+ encoding = XInternAtom(dpy, "COMPOUND_TEXT", False);
+ to_type = XlcNCompoundText;
+ goto retry;
+ }
+
+ unconv_num += ret;
+ *to++ = '\0';
+ to_left--;
+
+ if (i >= count)
+ break;
+
+ _XlcResetConverter(conv);
+ }
+
+ _XlcCloseConverter(conv);
+
+ nitems = to - buf;
+done:
+ if (nitems <= 0)
+ nitems = 1;
+ value = (char *) Xmalloc(nitems);
+ if (value == NULL) {
+ Xfree(buf);
+ return XNoMemory;
+ }
+ if (nitems == 1)
+ *value = 0;
+ else
+ memcpy(value, buf, nitems);
+ nitems--;
+ Xfree(buf);
+
+ text_prop->value = (unsigned char *) value;
+ text_prop->encoding = encoding;
+ text_prop->format = 8;
+ text_prop->nitems = nitems;
+
+ return unconv_num;
+}
+
+int
+_XmbTextListToTextProperty(
+ XLCd lcd,
+ Display *dpy,
+ char **list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty *text_prop)
+{
+ return _XTextListToTextProperty(lcd, dpy, XlcNMultiByte, (XPointer) list,
+ count, style, text_prop);
+}
+
+int
+_XwcTextListToTextProperty(
+ XLCd lcd,
+ Display *dpy,
+ wchar_t **list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty *text_prop)
+{
+ return _XTextListToTextProperty(lcd, dpy, XlcNWideChar, (XPointer) list,
+ count, style, text_prop);
+}
+
+int
+_Xutf8TextListToTextProperty(
+ XLCd lcd,
+ Display *dpy,
+ char **list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty *text_prop)
+{
+ return _XTextListToTextProperty(lcd, dpy, XlcNUtf8String, (XPointer) list,
+ count, style, text_prop);
+}
diff --git a/nx-X11/lib/X11/lcUTF8.c b/nx-X11/lib/X11/lcUTF8.c
new file mode 100644
index 000000000..405250039
--- /dev/null
+++ b/nx-X11/lib/X11/lcUTF8.c
@@ -0,0 +1,1844 @@
+/* $TOG: $ */
+/******************************************************************
+
+ Copyright 1993 by SunSoft, Inc.
+ Copyright 1999-2000 by Bruno Haible
+
+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 names of SunSoft, Inc. and
+Bruno Haible not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission. SunSoft, Inc. and Bruno Haible make no representations
+about the suitability of this software for any purpose. It is
+provided "as is" without express or implied warranty.
+
+SunSoft Inc. AND Bruno Haible DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL SunSoft, Inc. OR Bruno Haible 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/lcUTF8.c,v 1.15 2002/10/08 23:31:36 dawes Exp $ */
+
+/*
+ * This file contains:
+ *
+ * I. Conversion routines CompoundText/CharSet <--> Unicode/UTF-8.
+ *
+ * Used for three purposes:
+ * 1. The UTF-8 locales, see below.
+ * 2. Unicode aware applications for which the use of 8-bit character
+ * sets is an anachronism.
+ * 3. For conversion from keysym to locale encoding.
+ *
+ * II. Conversion files for an UTF-8 locale loader.
+ * Supports: all locales with codeset UTF-8.
+ * How: Provides converters for UTF-8.
+ * Platforms: all systems.
+ *
+ * The loader itself is located in lcUTF8.c.
+ */
+
+/*
+ * The conversion from UTF-8 to CompoundText is realized in a very
+ * conservative way. Recall that CompoundText data is used for inter-client
+ * communication purposes. We distinguish three classes of clients:
+ * - Clients which accept only those pieces of CompoundText which belong to
+ * the character set understood by the current locale.
+ * (Example: clients which are linked to an older X11 library.)
+ * - Clients which accept CompoundText with multiple character sets and parse
+ * it themselves.
+ * (Example: emacs, xemacs.)
+ * - Clients which rely entirely on the X{mb,wc}TextPropertyToTextList
+ * functions for the conversion of CompoundText to their current locale's
+ * multi-byte/wide-character format.
+ * For best interoperation, the UTF-8 to CompoundText conversion proceeds as
+ * follows. For every character, it first tests whether the character is
+ * representable in the current locale's original (non-UTF-8) character set.
+ * If not, it goes through the list of predefined character sets for
+ * CompoundText and tests if the character is representable in that character
+ * set. If so, it encodes the character using its code within that character
+ * set. If not, it uses an UTF-8-in-CompoundText encapsulation. Since
+ * clients of the first and second kind ignore such encapsulated text,
+ * this encapsulation is kept to a minimum and terminated as early as possible.
+ *
+ * In a distant future, when clients of the first and second kind will have
+ * disappeared, we will be able to stuff UTF-8 data directly in CompoundText
+ * without first going through the list of predefined character sets.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include "XlcGeneric.h"
+
+static XlcConv
+create_conv(
+ XLCd lcd,
+ XlcConvMethods methods)
+{
+ XlcConv conv;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (conv == (XlcConv) NULL)
+ return (XlcConv) NULL;
+
+ conv->methods = methods;
+ conv->state = NULL;
+
+ return conv;
+}
+
+static void
+close_converter(
+ XlcConv conv)
+{
+ Xfree((char *) conv);
+}
+
+/* Replacement character for invalid multibyte sequence or wide character. */
+#define BAD_WCHAR ((ucs4_t) 0xfffd)
+#define BAD_CHAR '?'
+
+/***************************************************************************/
+/* Part I: Conversion routines CompoundText/CharSet <--> Unicode/UTF-8.
+ *
+ * Note that this code works in any locale. We store Unicode values in
+ * `ucs4_t' variables, but don't pass them to the user.
+ *
+ * This code has to support all character sets that are used for CompoundText,
+ * nothing more, nothing less. See the table in lcCT.c.
+ * Since the conversion _to_ CompoundText is likely to need the tables for all
+ * character sets at once, we don't use dynamic loading (of tables or shared
+ * libraries through iconv()). Use a fixed set of tables instead.
+ *
+ * We use statically computed tables, not dynamically allocated arrays,
+ * because it's more memory efficient: Different processes using the same
+ * libX11 shared library share the "text" and read-only "data" sections.
+ */
+
+typedef unsigned int ucs4_t;
+#define conv_t XlcConv
+
+typedef struct _Utf8ConvRec {
+ const char *name;
+ XrmQuark xrm_name;
+ int (* cstowc) (XlcConv, ucs4_t *, unsigned char const *, int);
+ int (* wctocs) (XlcConv, unsigned char *, ucs4_t, int);
+} Utf8ConvRec, *Utf8Conv;
+
+/*
+ * int xxx_cstowc (XlcConv conv, ucs4_t *pwc, unsigned char const *s, int n)
+ * converts the byte sequence starting at s to a wide character. Up to n bytes
+ * are available at s. n is >= 1.
+ * Result is number of bytes consumed (if a wide character was read),
+ * or 0 if invalid, or -1 if n too small.
+ *
+ * int xxx_wctocs (XlcConv conv, unsigned char *r, ucs4_t wc, int n)
+ * converts the wide character wc to the character set xxx, and stores the
+ * result beginning at r. Up to n bytes may be written at r. n is >= 1.
+ * Result is number of bytes written, or 0 if invalid, or -1 if n too small.
+ */
+
+/* Return code if invalid. (xxx_mbtowc, xxx_wctomb) */
+#define RET_ILSEQ 0
+/* Return code if only a shift sequence of n bytes was read. (xxx_mbtowc) */
+#define RET_TOOFEW(n) (-1-(n))
+/* Return code if output buffer is too small. (xxx_wctomb, xxx_reset) */
+#define RET_TOOSMALL -1
+
+/*
+ * The tables below are bijective. It would be possible to extend the
+ * xxx_wctocs tables to do some transliteration (e.g. U+201C,U+201D -> 0x22)
+ * but *only* with characters not contained in any other table, and *only*
+ * when the current locale is not an UTF-8 locale.
+ */
+
+#include "lcUniConv/utf8.h"
+#include "lcUniConv/ucs2be.h"
+#ifdef notused
+#include "lcUniConv/ascii.h"
+#endif
+#include "lcUniConv/iso8859_1.h"
+#include "lcUniConv/iso8859_2.h"
+#include "lcUniConv/iso8859_3.h"
+#include "lcUniConv/iso8859_4.h"
+#include "lcUniConv/iso8859_5.h"
+#include "lcUniConv/iso8859_6.h"
+#include "lcUniConv/iso8859_7.h"
+#include "lcUniConv/iso8859_8.h"
+#include "lcUniConv/iso8859_9.h"
+#include "lcUniConv/iso8859_10.h"
+#include "lcUniConv/iso8859_11.h"
+#include "lcUniConv/iso8859_13.h"
+#include "lcUniConv/iso8859_14.h"
+#include "lcUniConv/iso8859_15.h"
+#include "lcUniConv/iso8859_16.h"
+#include "lcUniConv/iso8859_9e.h"
+#include "lcUniConv/jisx0201.h"
+#include "lcUniConv/tis620.h"
+#include "lcUniConv/koi8_r.h"
+#include "lcUniConv/koi8_u.h"
+#include "lcUniConv/koi8_c.h"
+#include "lcUniConv/armscii_8.h"
+#include "lcUniConv/cp1133.h"
+#include "lcUniConv/mulelao.h"
+#include "lcUniConv/viscii.h"
+#include "lcUniConv/tcvn.h"
+#include "lcUniConv/georgian_academy.h"
+#include "lcUniConv/georgian_ps.h"
+#include "lcUniConv/cp1251.h"
+#include "lcUniConv/cp1255.h"
+#include "lcUniConv/cp1256.h"
+#include "lcUniConv/tatar_cyr.h"
+
+typedef struct {
+ unsigned short indx; /* index into big table */
+ unsigned short used; /* bitmask of used entries */
+} Summary16;
+
+#include "lcUniConv/gb2312.h"
+#include "lcUniConv/jisx0208.h"
+#include "lcUniConv/jisx0212.h"
+#include "lcUniConv/ksc5601.h"
+#include "lcUniConv/big5.h"
+#include "lcUniConv/big5_emacs.h"
+
+static Utf8ConvRec all_charsets[] = {
+ /* The ISO10646-1/UTF-8 entry occurs twice, once at the beginning
+ (for lookup speed), once at the end (as a fallback). */
+ { "ISO10646-1", NULLQUARK,
+ utf8_mbtowc, utf8_wctomb
+ },
+
+ { "ISO8859-1", NULLQUARK,
+ iso8859_1_mbtowc, iso8859_1_wctomb
+ },
+ { "ISO8859-2", NULLQUARK,
+ iso8859_2_mbtowc, iso8859_2_wctomb
+ },
+ { "ISO8859-3", NULLQUARK,
+ iso8859_3_mbtowc, iso8859_3_wctomb
+ },
+ { "ISO8859-4", NULLQUARK,
+ iso8859_4_mbtowc, iso8859_4_wctomb
+ },
+ { "ISO8859-5", NULLQUARK,
+ iso8859_5_mbtowc, iso8859_5_wctomb
+ },
+ { "ISO8859-6", NULLQUARK,
+ iso8859_6_mbtowc, iso8859_6_wctomb
+ },
+ { "ISO8859-7", NULLQUARK,
+ iso8859_7_mbtowc, iso8859_7_wctomb
+ },
+ { "ISO8859-8", NULLQUARK,
+ iso8859_8_mbtowc, iso8859_8_wctomb
+ },
+ { "ISO8859-9", NULLQUARK,
+ iso8859_9_mbtowc, iso8859_9_wctomb
+ },
+ { "ISO8859-10", NULLQUARK,
+ iso8859_10_mbtowc, iso8859_10_wctomb
+ },
+ { "ISO8859-11", NULLQUARK,
+ iso8859_11_mbtowc, iso8859_11_wctomb
+ },
+ { "ISO8859-13", NULLQUARK,
+ iso8859_13_mbtowc, iso8859_13_wctomb
+ },
+ { "ISO8859-14", NULLQUARK,
+ iso8859_14_mbtowc, iso8859_14_wctomb
+ },
+ { "ISO8859-15", NULLQUARK,
+ iso8859_15_mbtowc, iso8859_15_wctomb
+ },
+ { "ISO8859-16", NULLQUARK,
+ iso8859_16_mbtowc, iso8859_16_wctomb
+ },
+ { "JISX0201.1976-0", NULLQUARK,
+ jisx0201_mbtowc, jisx0201_wctomb
+ },
+ { "TIS620-0", NULLQUARK,
+ tis620_mbtowc, tis620_wctomb
+ },
+ { "GB2312.1980-0", NULLQUARK,
+ gb2312_mbtowc, gb2312_wctomb
+ },
+ { "JISX0208.1983-0", NULLQUARK,
+ jisx0208_mbtowc, jisx0208_wctomb
+ },
+ { "JISX0208.1990-0", NULLQUARK,
+ jisx0208_mbtowc, jisx0208_wctomb
+ },
+ { "JISX0212.1990-0", NULLQUARK,
+ jisx0212_mbtowc, jisx0212_wctomb
+ },
+ { "KSC5601.1987-0", NULLQUARK,
+ ksc5601_mbtowc, ksc5601_wctomb
+ },
+ { "KOI8-R", NULLQUARK,
+ koi8_r_mbtowc, koi8_r_wctomb
+ },
+ { "KOI8-U", NULLQUARK,
+ koi8_u_mbtowc, koi8_u_wctomb
+ },
+ { "KOI8-C", NULLQUARK,
+ koi8_c_mbtowc, koi8_c_wctomb
+ },
+ { "TATAR-CYR", NULLQUARK,
+ tatar_cyr_mbtowc, tatar_cyr_wctomb
+ },
+ { "ARMSCII-8", NULLQUARK,
+ armscii_8_mbtowc, armscii_8_wctomb
+ },
+ { "IBM-CP1133", NULLQUARK,
+ cp1133_mbtowc, cp1133_wctomb
+ },
+ { "MULELAO-1", NULLQUARK,
+ mulelao_mbtowc, mulelao_wctomb
+ },
+ { "VISCII1.1-1", NULLQUARK,
+ viscii_mbtowc, viscii_wctomb
+ },
+ { "TCVN-5712", NULLQUARK,
+ tcvn_mbtowc, tcvn_wctomb
+ },
+ { "GEORGIAN-ACADEMY", NULLQUARK,
+ georgian_academy_mbtowc, georgian_academy_wctomb
+ },
+ { "GEORGIAN-PS", NULLQUARK,
+ georgian_ps_mbtowc, georgian_ps_wctomb
+ },
+ { "ISO8859-9E", NULLQUARK,
+ iso8859_9e_mbtowc, iso8859_9e_wctomb
+ },
+ { "MICROSOFT-CP1251", NULLQUARK,
+ cp1251_mbtowc, cp1251_wctomb
+ },
+ { "MICROSOFT-CP1255", NULLQUARK,
+ cp1255_mbtowc, cp1255_wctomb
+ },
+ { "MICROSOFT-CP1256", NULLQUARK,
+ cp1256_mbtowc, cp1256_wctomb
+ },
+ { "BIG5-0", NULLQUARK,
+ big5_mbtowc, big5_wctomb
+ },
+ { "BIG5-E0", NULLQUARK,
+ big5_0_mbtowc, big5_0_wctomb
+ },
+ { "BIG5-E1", NULLQUARK,
+ big5_1_mbtowc, big5_1_wctomb
+ },
+
+ /* The ISO10646-1/UTF-8 entry occurs twice, once at the beginning
+ (for lookup speed), once at the end (as a fallback). */
+ { "ISO10646-1", NULLQUARK,
+ utf8_mbtowc, utf8_wctomb
+ },
+
+ /* Encoding ISO10646-1 for fonts means UCS2-like encoding
+ so for conversion to FontCharSet we need this record */
+ { "ISO10646-1", NULLQUARK,
+ ucs2be_mbtowc, ucs2be_wctomb
+ }
+};
+
+#define charsets_table_size (sizeof(all_charsets)/sizeof(all_charsets[0]))
+#define all_charsets_count (charsets_table_size - 1)
+#define ucs2_conv_index (charsets_table_size - 1)
+
+static void
+init_all_charsets (void)
+{
+ Utf8Conv convptr;
+ int i;
+
+ for (convptr = all_charsets, i = charsets_table_size; i > 0; convptr++, i--)
+ convptr->xrm_name = XrmStringToQuark(convptr->name);
+}
+
+#define lazy_init_all_charsets() \
+ do { \
+ if (all_charsets[0].xrm_name == NULLQUARK) \
+ init_all_charsets(); \
+ } while (0)
+
+/* from XlcNCharSet to XlcNUtf8String */
+
+static int
+cstoutf8(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XlcCharSet charset;
+ const char *name;
+ Utf8Conv convptr;
+ int i;
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ if (num_args < 1)
+ return -1;
+
+ charset = (XlcCharSet) args[0];
+ name = charset->encoding_name;
+ /* not charset->name because the latter has a ":GL"/":GR" suffix */
+
+ for (convptr = all_charsets, i = all_charsets_count-1; i > 0; convptr++, i--)
+ if (!strcmp(convptr->name, name))
+ break;
+ if (i == 0)
+ return -1;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend) {
+ ucs4_t wc;
+ int consumed;
+ int count;
+
+ consumed = convptr->cstowc(conv, &wc, src, srcend-src);
+ if (consumed == RET_ILSEQ)
+ return -1;
+ if (consumed == RET_TOOFEW(0))
+ break;
+
+ count = utf8_wctomb(NULL, dst, wc, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ count = utf8_wctomb(NULL, dst, BAD_WCHAR, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ unconv_num++;
+ }
+ src += consumed;
+ dst += count;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_cstoutf8 = {
+ close_converter,
+ cstoutf8,
+ NULL
+};
+
+static XlcConv
+open_cstoutf8(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ lazy_init_all_charsets();
+ return create_conv(from_lcd, &methods_cstoutf8);
+}
+
+/* from XlcNUtf8String to XlcNCharSet */
+
+static XlcConv
+create_tocs_conv(
+ XLCd lcd,
+ XlcConvMethods methods)
+{
+ XlcConv conv;
+ CodeSet *codeset_list;
+ int codeset_num;
+ int charset_num;
+ int i, j, k;
+ Utf8Conv *preferred;
+
+ lazy_init_all_charsets();
+
+ codeset_list = XLC_GENERIC(lcd, codeset_list);
+ codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+ charset_num = 0;
+ for (i = 0; i < codeset_num; i++)
+ charset_num += codeset_list[i]->num_charsets;
+ if (charset_num > all_charsets_count-1)
+ charset_num = all_charsets_count-1;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)
+ + (charset_num + 1) * sizeof(Utf8Conv));
+ if (conv == (XlcConv) NULL)
+ return (XlcConv) NULL;
+ preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
+
+ /* Loop through all codesets mentioned in the locale. */
+ charset_num = 0;
+ for (i = 0; i < codeset_num; i++) {
+ XlcCharSet *charsets = codeset_list[i]->charset_list;
+ int num_charsets = codeset_list[i]->num_charsets;
+ for (j = 0; j < num_charsets; j++) {
+ const char *name = charsets[j]->encoding_name;
+ /* If it wasn't already encountered... */
+ for (k = charset_num-1; k >= 0; k--)
+ if (!strcmp(preferred[k]->name, name))
+ break;
+ if (k < 0) {
+ /* Look it up in all_charsets[]. */
+ for (k = 0; k < all_charsets_count-1; k++)
+ if (!strcmp(all_charsets[k].name, name)) {
+ /* Add it to the preferred set. */
+ preferred[charset_num++] = &all_charsets[k];
+ break;
+ }
+ }
+ }
+ }
+ preferred[charset_num] = (Utf8Conv) NULL;
+
+ conv->methods = methods;
+ conv->state = (XPointer) preferred;
+
+ return conv;
+}
+
+static void
+close_tocs_converter(
+ XlcConv conv)
+{
+ /* conv->state is allocated together with conv, free both at once. */
+ Xfree((char *) conv);
+}
+
+/*
+ * Converts a Unicode character to an appropriate character set. The NULL
+ * terminated array of preferred character sets is passed as first argument.
+ * If successful, *charsetp is set to the character set that was used, and
+ * *sidep is set to the character set side (XlcGL or XlcGR).
+ */
+static int
+charset_wctocs(
+ Utf8Conv *preferred,
+ Utf8Conv *charsetp,
+ XlcSide *sidep,
+ XlcConv conv,
+ unsigned char *r,
+ ucs4_t wc,
+ int n)
+{
+ int count;
+ Utf8Conv convptr;
+ int i;
+
+ for (; *preferred != (Utf8Conv) NULL; preferred++) {
+ convptr = *preferred;
+ count = convptr->wctocs(conv, r, wc, n);
+ if (count == RET_TOOSMALL)
+ return RET_TOOSMALL;
+ if (count != RET_ILSEQ) {
+ *charsetp = convptr;
+ *sidep = (*r < 0x80 ? XlcGL : XlcGR);
+ return count;
+ }
+ }
+ for (convptr = all_charsets+1, i = all_charsets_count-1; i > 0; convptr++, i--) {
+ count = convptr->wctocs(conv, r, wc, n);
+ if (count == RET_TOOSMALL)
+ return RET_TOOSMALL;
+ if (count != RET_ILSEQ) {
+ *charsetp = convptr;
+ *sidep = (*r < 0x80 ? XlcGL : XlcGR);
+ return count;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static int
+utf8tocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ Utf8Conv *preferred_charsets;
+ XlcCharSet last_charset = NULL;
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ preferred_charsets = (Utf8Conv *) conv->state;
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ Utf8Conv chosen_charset = NULL;
+ XlcSide chosen_side = XlcNONE;
+ ucs4_t wc;
+ int consumed;
+ int count;
+
+ consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
+ if (consumed == RET_TOOFEW(0))
+ break;
+ if (consumed == RET_ILSEQ) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+
+ count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ src += consumed;
+ unconv_num++;
+ continue;
+ }
+
+ if (last_charset == NULL) {
+ last_charset =
+ _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
+ if (last_charset == NULL) {
+ src += consumed;
+ unconv_num++;
+ continue;
+ }
+ } else {
+ if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
+ && (last_charset->side == XlcGLGR
+ || last_charset->side == chosen_side)))
+ break;
+ }
+ src += consumed;
+ dst += count;
+ }
+
+ if (last_charset == NULL)
+ return -1;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ if (num_args >= 1)
+ *((XlcCharSet *)args[0]) = last_charset;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_utf8tocs = {
+ close_tocs_converter,
+ utf8tocs,
+ NULL
+};
+
+static XlcConv
+open_utf8tocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_tocs_conv(from_lcd, &methods_utf8tocs);
+}
+
+/* from XlcNUtf8String to XlcNChar */
+
+static int
+utf8tocs1(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ Utf8Conv *preferred_charsets;
+ XlcCharSet last_charset = NULL;
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ preferred_charsets = (Utf8Conv *) conv->state;
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ Utf8Conv chosen_charset = NULL;
+ XlcSide chosen_side = XlcNONE;
+ ucs4_t wc;
+ int consumed;
+ int count;
+
+ consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
+ if (consumed == RET_TOOFEW(0))
+ break;
+ if (consumed == RET_ILSEQ) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+
+ count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ src += consumed;
+ unconv_num++;
+ continue;
+ }
+
+ if (last_charset == NULL) {
+ last_charset =
+ _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
+ if (last_charset == NULL) {
+ src += consumed;
+ unconv_num++;
+ continue;
+ }
+ } else {
+ if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
+ && (last_charset->side == XlcGLGR
+ || last_charset->side == chosen_side)))
+ break;
+ }
+ src += consumed;
+ dst += count;
+ break;
+ }
+
+ if (last_charset == NULL)
+ return -1;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ if (num_args >= 1)
+ *((XlcCharSet *)args[0]) = last_charset;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_utf8tocs1 = {
+ close_tocs_converter,
+ utf8tocs1,
+ NULL
+};
+
+static XlcConv
+open_utf8tocs1(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_tocs_conv(from_lcd, &methods_utf8tocs1);
+}
+
+/* from XlcNUtf8String to XlcNString */
+
+static int
+utf8tostr(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend) {
+ unsigned char c;
+ ucs4_t wc;
+ int consumed;
+
+ consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
+ if (consumed == RET_TOOFEW(0))
+ break;
+ if (dst == dstend)
+ break;
+ if (consumed == RET_ILSEQ) {
+ consumed = 1;
+ c = BAD_CHAR;
+ unconv_num++;
+ } else {
+ if ((wc & ~(ucs4_t)0xff) != 0) {
+ c = BAD_CHAR;
+ unconv_num++;
+ } else
+ c = (unsigned char) wc;
+ }
+ *dst++ = c;
+ src += consumed;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_utf8tostr = {
+ close_converter,
+ utf8tostr,
+ NULL
+};
+
+static XlcConv
+open_utf8tostr(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_utf8tostr);
+}
+
+/* from XlcNString to XlcNUtf8String */
+
+static int
+strtoutf8(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+
+ while (src < srcend) {
+ int count = utf8_wctomb(NULL, dst, *src, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ dst += count;
+ src++;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return 0;
+}
+
+static XlcConvMethodsRec methods_strtoutf8 = {
+ close_converter,
+ strtoutf8,
+ NULL
+};
+
+static XlcConv
+open_strtoutf8(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_strtoutf8);
+}
+
+/* Support for the input methods. */
+
+XPointer
+_Utf8GetConvByName(
+ const char *name)
+{
+ XrmQuark xrm_name;
+ Utf8Conv convptr;
+ int i;
+
+ if (name == NULL)
+ return (XPointer) NULL;
+
+ lazy_init_all_charsets();
+ xrm_name = XrmStringToQuark(name);
+
+ for (convptr = all_charsets, i = all_charsets_count-1; i > 0; convptr++, i--)
+ if (convptr->xrm_name == xrm_name)
+ return (XPointer) convptr->wctocs;
+ return (XPointer) NULL;
+}
+
+/* from XlcNUcsChar to XlcNChar, needed for input methods */
+
+static XlcConv
+create_ucstocs_conv(
+ XLCd lcd,
+ XlcConvMethods methods)
+{
+
+ if (XLC_PUBLIC_PART(lcd)->codeset
+ && _XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "UTF-8") == 0) {
+ XlcConv conv;
+ Utf8Conv *preferred;
+
+ lazy_init_all_charsets();
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec) + 2 * sizeof(Utf8Conv));
+ if (conv == (XlcConv) NULL)
+ return (XlcConv) NULL;
+ preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
+
+ preferred[0] = &all_charsets[0]; /* ISO10646 */
+ preferred[1] = (Utf8Conv) NULL;
+
+ conv->methods = methods;
+ conv->state = (XPointer) preferred;
+
+ return conv;
+ } else {
+ return create_tocs_conv(lcd, methods);
+ }
+}
+
+static int
+charset_wctocs_exactly(
+ Utf8Conv *preferred,
+ Utf8Conv *charsetp,
+ XlcSide *sidep,
+ XlcConv conv,
+ unsigned char *r,
+ ucs4_t wc,
+ int n)
+{
+ int count;
+ Utf8Conv convptr;
+
+ for (; *preferred != (Utf8Conv) NULL; preferred++) {
+ convptr = *preferred;
+ count = convptr->wctocs(conv, r, wc, n);
+ if (count == RET_TOOSMALL)
+ return RET_TOOSMALL;
+ if (count != RET_ILSEQ) {
+ *charsetp = convptr;
+ *sidep = (*r < 0x80 ? XlcGL : XlcGR);
+ return count;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static int
+ucstocs1(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ ucs4_t const *src = (ucs4_t const *) *from;
+ unsigned char *dst = (unsigned char *) *to;
+ int unconv_num = 0;
+ Utf8Conv *preferred_charsets = (Utf8Conv *) conv->state;
+ Utf8Conv chosen_charset = NULL;
+ XlcSide chosen_side = XlcNONE;
+ XlcCharSet charset = NULL;
+ int count;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ count = charset_wctocs_exactly(preferred_charsets, &chosen_charset,
+ &chosen_side, conv, dst, *src, *to_left);
+ if (count < 1) {
+ unconv_num++;
+ count = 0;
+ } else {
+ charset = _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
+ }
+ if (charset == NULL)
+ return -1;
+
+ *from = (XPointer) ++src;
+ (*from_left)--;
+ *to = (XPointer) dst;
+ *to_left -= count;
+
+ if (num_args >= 1)
+ *((XlcCharSet *)args[0]) = charset;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_ucstocs1 = {
+ close_tocs_converter,
+ ucstocs1,
+ NULL
+};
+
+static XlcConv
+open_ucstocs1(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_ucstocs_conv(from_lcd, &methods_ucstocs1);
+}
+
+/* from XlcNUcsChar to XlcNUtf8String, needed for input methods */
+
+static int
+ucstoutf8(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const ucs4_t *src;
+ const ucs4_t *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (const ucs4_t *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend) {
+ int count = utf8_wctomb(NULL, dst, *src, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ)
+ unconv_num++;
+ src++;
+ dst += count;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_ucstoutf8 = {
+ close_converter,
+ ucstoutf8,
+ NULL
+};
+
+static XlcConv
+open_ucstoutf8(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_ucstoutf8);
+}
+
+/* Registers UTF-8 converters for a non-UTF-8 locale. */
+void
+_XlcAddUtf8Converters(
+ XLCd lcd)
+{
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNUtf8String, open_cstoutf8);
+ _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNCharSet, open_utf8tocs);
+ _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNChar, open_utf8tocs1);
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNUtf8String, open_strtoutf8);
+ _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNString, open_utf8tostr);
+ _XlcSetConverter(lcd, XlcNUcsChar, lcd, XlcNChar, open_ucstocs1);
+ _XlcSetConverter(lcd, XlcNUcsChar, lcd, XlcNUtf8String, open_ucstoutf8);
+}
+
+/***************************************************************************/
+/* Part II: UTF-8 locale loader conversion files
+ *
+ * Here we can assume that "multi-byte" is UTF-8 and that `wchar_t' is Unicode.
+ */
+
+/* from XlcNMultiByte to XlcNWideChar */
+
+static int
+utf8towcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ unsigned char const *src;
+ unsigned char const *srcend;
+ wchar_t *dst;
+ wchar_t *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (wchar_t *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ ucs4_t wc;
+ int consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
+ if (consumed == RET_TOOFEW(0))
+ break;
+ if (consumed == RET_ILSEQ) {
+ src++;
+ *dst = BAD_WCHAR;
+ unconv_num++;
+ } else {
+ src += consumed;
+ *dst = wc;
+ }
+ dst++;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_utf8towcs = {
+ close_converter,
+ utf8towcs,
+ NULL
+};
+
+static XlcConv
+open_utf8towcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_utf8towcs);
+}
+
+/* from XlcNWideChar to XlcNMultiByte */
+
+static int
+wcstoutf8(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ wchar_t const *src;
+ wchar_t const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (wchar_t const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend) {
+ int count = utf8_wctomb(NULL, dst, *src, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ count = utf8_wctomb(NULL, dst, BAD_WCHAR, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ unconv_num++;
+ }
+ dst += count;
+ src++;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_wcstoutf8 = {
+ close_converter,
+ wcstoutf8,
+ NULL
+};
+
+static XlcConv
+open_wcstoutf8(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_wcstoutf8);
+}
+
+/* from XlcNString to XlcNWideChar */
+
+static int
+our_strtowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ unsigned char const *src;
+ unsigned char const *srcend;
+ wchar_t *dst;
+ wchar_t *dstend;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (wchar_t *) *to;
+ dstend = dst + *to_left;
+
+ while (src < srcend && dst < dstend)
+ *dst++ = (wchar_t) *src++;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return 0;
+}
+
+static XlcConvMethodsRec methods_strtowcs = {
+ close_converter,
+ our_strtowcs,
+ NULL
+};
+
+static XlcConv
+open_strtowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_strtowcs);
+}
+
+/* from XlcNWideChar to XlcNString */
+
+static int
+our_wcstostr(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ wchar_t const *src;
+ wchar_t const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (wchar_t const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ unsigned int wc = *src++;
+ if (wc < 0x80)
+ *dst = wc;
+ else {
+ *dst = BAD_CHAR;
+ unconv_num++;
+ }
+ dst++;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_wcstostr = {
+ close_converter,
+ our_wcstostr,
+ NULL
+};
+
+static XlcConv
+open_wcstostr(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_wcstostr);
+}
+
+/* from XlcNCharSet to XlcNWideChar */
+
+static int
+cstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XlcCharSet charset;
+ const char *name;
+ Utf8Conv convptr;
+ int i;
+ unsigned char const *src;
+ unsigned char const *srcend;
+ wchar_t *dst;
+ wchar_t *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ if (num_args < 1)
+ return -1;
+
+ charset = (XlcCharSet) args[0];
+ name = charset->encoding_name;
+ /* not charset->name because the latter has a ":GL"/":GR" suffix */
+
+ for (convptr = all_charsets, i = all_charsets_count-1; i > 0; convptr++, i--)
+ if (!strcmp(convptr->name, name))
+ break;
+ if (i == 0)
+ return -1;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (wchar_t *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ unsigned int wc;
+ int consumed;
+
+ consumed = convptr->cstowc(conv, &wc, src, srcend-src);
+ if (consumed == RET_ILSEQ)
+ return -1;
+ if (consumed == RET_TOOFEW(0))
+ break;
+
+ *dst++ = wc;
+ src += consumed;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_cstowcs = {
+ close_converter,
+ cstowcs,
+ NULL
+};
+
+static XlcConv
+open_cstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ lazy_init_all_charsets();
+ return create_conv(from_lcd, &methods_cstowcs);
+}
+
+/* from XlcNWideChar to XlcNCharSet */
+
+static int
+wcstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ Utf8Conv *preferred_charsets;
+ XlcCharSet last_charset = NULL;
+ wchar_t const *src;
+ wchar_t const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ preferred_charsets = (Utf8Conv *) conv->state;
+ src = (wchar_t const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ Utf8Conv chosen_charset = NULL;
+ XlcSide chosen_side = XlcNONE;
+ wchar_t wc = *src;
+ int count;
+
+ count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+
+ if (last_charset == NULL) {
+ last_charset =
+ _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
+ if (last_charset == NULL) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+ } else {
+ if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
+ && (last_charset->side == XlcGLGR
+ || last_charset->side == chosen_side)))
+ break;
+ }
+ src++;
+ dst += count;
+ }
+
+ if (last_charset == NULL)
+ return -1;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ if (num_args >= 1)
+ *((XlcCharSet *)args[0]) = last_charset;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_wcstocs = {
+ close_tocs_converter,
+ wcstocs,
+ NULL
+};
+
+static XlcConv
+open_wcstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_tocs_conv(from_lcd, &methods_wcstocs);
+}
+
+/* from XlcNWideChar to XlcNChar */
+
+static int
+wcstocs1(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ Utf8Conv *preferred_charsets;
+ XlcCharSet last_charset = NULL;
+ wchar_t const *src;
+ wchar_t const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ preferred_charsets = (Utf8Conv *) conv->state;
+ src = (wchar_t const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ Utf8Conv chosen_charset = NULL;
+ XlcSide chosen_side = XlcNONE;
+ wchar_t wc = *src;
+ int count;
+
+ count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+
+ if (last_charset == NULL) {
+ last_charset =
+ _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
+ if (last_charset == NULL) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+ } else {
+ if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
+ && (last_charset->side == XlcGLGR
+ || last_charset->side == chosen_side)))
+ break;
+ }
+ src++;
+ dst += count;
+ break;
+ }
+
+ if (last_charset == NULL)
+ return -1;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ if (num_args >= 1)
+ *((XlcCharSet *)args[0]) = last_charset;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_wcstocs1 = {
+ close_tocs_converter,
+ wcstocs1,
+ NULL
+};
+
+static XlcConv
+open_wcstocs1(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_tocs_conv(from_lcd, &methods_wcstocs1);
+}
+
+/* trivial, no conversion */
+
+static int
+identity(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+
+ while (src < srcend && dst < dstend)
+ *dst++ = *src++;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return 0;
+}
+
+static XlcConvMethodsRec methods_identity = {
+ close_converter,
+ identity,
+ NULL
+};
+
+static XlcConv
+open_identity(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_identity);
+}
+
+/* from MultiByte/WideChar to FontCharSet. */
+/* They really use converters to CharSet
+ * but with different create_conv procedure. */
+
+static XlcConv
+create_tofontcs_conv(
+ XLCd lcd,
+ XlcConvMethods methods)
+{
+ XlcConv conv;
+ int i, num, k, count;
+ char **value, buf[20];
+ Utf8Conv *preferred;
+
+ lazy_init_all_charsets();
+
+ for (i = 0, num = 0;; i++) {
+ sprintf(buf, "fs%d.charset.name", i);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1) {
+ sprintf(buf, "fs%d.charset", i);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1)
+ break;
+ }
+ num += count;
+ }
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec) + (num + 1) * sizeof(Utf8Conv));
+ if (conv == (XlcConv) NULL)
+ return (XlcConv) NULL;
+ preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
+
+ /* Loop through all fontsets mentioned in the locale. */
+ for (i = 0, num = 0;; i++) {
+ sprintf(buf, "fs%d.charset.name", i);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1) {
+ sprintf(buf, "fs%d.charset", i);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1)
+ break;
+ }
+ while (count-- > 0) {
+ XlcCharSet charset = _XlcGetCharSet(*value++);
+ const char *name;
+
+ if (charset == (XlcCharSet) NULL)
+ continue;
+
+ name = charset->encoding_name;
+ /* If it wasn't already encountered... */
+ for (k = num - 1; k >= 0; k--)
+ if (!strcmp(preferred[k]->name, name))
+ break;
+ if (k < 0) {
+ /* For fonts "ISO10646-1" means ucs2, not utf8.*/
+ if (!strcmp("ISO10646-1", name)) {
+ preferred[num++] = &all_charsets[ucs2_conv_index];
+ continue;
+ }
+ /* Look it up in all_charsets[]. */
+ for (k = 0; k < all_charsets_count-1; k++)
+ if (!strcmp(all_charsets[k].name, name)) {
+ /* Add it to the preferred set. */
+ preferred[num++] = &all_charsets[k];
+ break;
+ }
+ }
+ }
+ }
+ preferred[num] = (Utf8Conv) NULL;
+
+ conv->methods = methods;
+ conv->state = (XPointer) preferred;
+
+ return conv;
+}
+
+static XlcConv
+open_wcstofcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_tofontcs_conv(from_lcd, &methods_wcstocs);
+}
+
+static XlcConv
+open_utf8tofcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_tofontcs_conv(from_lcd, &methods_utf8tocs);
+}
+
+/* Registers UTF-8 converters for a UTF-8 locale. */
+
+void
+_XlcAddUtf8LocaleConverters(
+ XLCd lcd)
+{
+ /* Register elementary converters. */
+
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_utf8towcs);
+
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstoutf8);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_wcstostr);
+
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_strtowcs);
+
+ /* Register converters for XlcNCharSet. This implicitly provides
+ * converters from and to XlcNCompoundText. */
+
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstoutf8);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_utf8tocs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_utf8tocs1);
+
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNChar, open_wcstocs1);
+
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_strtoutf8);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNString, open_utf8tostr);
+ _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNMultiByte, open_identity);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNUtf8String, open_identity);
+
+ /* Register converters for XlcNFontCharSet */
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNFontCharSet, open_utf8tofcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNFontCharSet, open_wcstofcs);
+}
diff --git a/nx-X11/lib/X11/lcUTF8Load.c b/nx-X11/lib/X11/lcUTF8Load.c
new file mode 100644
index 000000000..f4bff2880
--- /dev/null
+++ b/nx-X11/lib/X11/lcUTF8Load.c
@@ -0,0 +1,64 @@
+/* $TOG: $ */
+/******************************************************************
+
+ Copyright 1993 by SunSoft, Inc.
+ Copyright 1999-2000 by Bruno Haible
+
+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 names of SunSoft, Inc. and
+Bruno Haible not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission. SunSoft, Inc. and Bruno Haible make no representations
+about the suitability of this software for any purpose. It is
+provided "as is" without express or implied warranty.
+
+SunSoft Inc. AND Bruno Haible DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL SunSoft, Inc. OR Bruno Haible 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/X11/lcUTF8.c,v 1.12 2001/02/09 00:02:53 dawes Exp $ */
+
+/*
+ * This file contains the UTF-8 locale loader.
+ * Supports: all locales with codeset UTF-8.
+ * Platforms: all systems.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include "XlcGeneric.h"
+
+XLCd
+_XlcUtf8Loader(
+ const char *name)
+{
+ XLCd lcd;
+
+ lcd = _XlcCreateLC(name, _XlcGenericMethods);
+ if (lcd == (XLCd) NULL)
+ return lcd;
+
+ /* The official IANA name for UTF-8 is "UTF-8" in upper case with a dash. */
+ if (!XLC_PUBLIC_PART(lcd)->codeset ||
+ (_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "UTF-8"))) {
+ _XlcDestroyLC(lcd);
+ return (XLCd) NULL;
+ }
+
+ _XlcAddUtf8LocaleConverters(lcd);
+ _XlcAddUtf8Converters(lcd);
+
+ return lcd;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/8bit_tab_to_h.c b/nx-X11/lib/X11/lcUniConv/8bit_tab_to_h.c
new file mode 100644
index 000000000..ae5340cf3
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/8bit_tab_to_h.c
@@ -0,0 +1,536 @@
+/* $XFree86: xc/lib/X11/lcUniConv/8bit_tab_to_h.c,v 1.2 2000/12/04 18:49:30 dawes Exp $ */
+
+/*
+ * Generates an 8-bit character set table from a .TXT table as found on
+ * ftp.unicode.org or from a table containing the 256 Unicode values as
+ * hexadecimal integers.
+ * Examples:
+ *
+ * ./8bit_tab_to_h ISO-8859-1 iso8859_1 < tab8859_1
+ * ./8bit_tab_to_h ISO-8859-2 iso8859_2 < tab8859_2
+ * ./8bit_tab_to_h ISO-8859-3 iso8859_3 < tab8859_3
+ * ./8bit_tab_to_h ISO-8859-4 iso8859_4 < tab8859_4
+ * ./8bit_tab_to_h ISO-8859-5 iso8859_5 < tab8859_5
+ * ./8bit_tab_to_h ISO-8859-6 iso8859_6 < tab8859_6
+ * ./8bit_tab_to_h ISO-8859-7 iso8859_7 < tab8859_7
+ * ./8bit_tab_to_h ISO-8859-8 iso8859_8 < tab8859_8
+ * ./8bit_tab_to_h ISO-8859-9 iso8859_9 < tab8859_9
+ * ./8bit_tab_to_h ISO-8859-10 iso8859_10 < tab8859_10
+ * ./8bit_tab_to_h ISO-8859-14 iso8859_14 < tab8859_14
+ * ./8bit_tab_to_h ISO-8859-15 iso8859_15 < tab8859_15
+ * ./8bit_tab_to_h JISX0201.1976-0 jisx0201 < jis0201
+ * ./8bit_tab_to_h TIS620-0 tis620 < tabtis620
+ * ./8bit_tab_to_h KOI8-R koi8_r < tabkoi8_r
+ * ./8bit_tab_to_h KOI8-U koi8_u < tabkoi8_u
+ * ./8bit_tab_to_h ARMSCII-8 armscii_8 < tabarmscii_8
+ * ./8bit_tab_to_h CP1133 cp1133 < tabibm_cp1133
+ * ./8bit_tab_to_h MULELAO-1 mulelao < tabmulelao_1
+ * ./8bit_tab_to_h VISCII1.1-1 viscii1 < tabviscii
+ * ./8bit_tab_to_h TCVN-5712 tcvn < tabtcvn
+ * ./8bit_tab_to_h GEORGIAN-ACADEMY georgian_ac < tabgeorgian_academy
+ * ./8bit_tab_to_h GEORGIAN-PS georgian_ps < tabgeorgian_ps
+ *
+ * ./8bit_tab_to_h ISO-8859-1 iso8859_1 < 8859-1.TXT
+ * ./8bit_tab_to_h ISO-8859-2 iso8859_2 < 8859-2.TXT
+ * ./8bit_tab_to_h ISO-8859-3 iso8859_3 < 8859-3.TXT
+ * ./8bit_tab_to_h ISO-8859-4 iso8859_4 < 8859-4.TXT
+ * ./8bit_tab_to_h ISO-8859-5 iso8859_5 < 8859-5.TXT
+ * ./8bit_tab_to_h ISO-8859-6 iso8859_6 < 8859-6.TXT
+ * ./8bit_tab_to_h ISO-8859-7 iso8859_7 < 8859-7.TXT
+ * ./8bit_tab_to_h ISO-8859-8 iso8859_8 < 8859-8.TXT
+ * ./8bit_tab_to_h ISO-8859-9 iso8859_9 < 8859-9.TXT
+ * ./8bit_tab_to_h ISO-8859-10 iso8859_10 < 8859-10.TXT
+ * ./8bit_tab_to_h ISO-8859-14 iso8859_14 < 8859-14.TXT
+ * ./8bit_tab_to_h ISO-8859-15 iso8859_15 < 8859-15.TXT
+ * ./8bit_tab_to_h JISX0201.1976-0 jisx0201 < JIS0201.TXT
+ * ./8bit_tab_to_h KOI8-R koi8_r < KOI8-R.TXT
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+
+int main (int argc, char *argv[])
+{
+ const char* charsetname;
+ const char* c_charsetname;
+ const char* filename;
+ const char* directory;
+ int charset2uni[0x100];
+
+ if (argc != 3 && argc != 4 && argc != 5)
+ exit(1);
+ charsetname = argv[1];
+ c_charsetname = argv[2];
+ if (argc > 3) {
+ filename = argv[3];
+ } else {
+ char* s = (char*) malloc(strlen(c_charsetname)+strlen(".h")+1);
+ strcpy(s,c_charsetname); strcat(s,".h");
+ filename = s;
+ }
+ directory = (argc > 4 ? argv[4] : "");
+
+ fprintf(stderr, "Creating %s%s\n", directory, filename);
+
+ {
+ int i, c;
+ c = getc(stdin);
+ ungetc(c,stdin);
+ if (c == '#') {
+ /* Read a unicode.org style .TXT file. */
+ for (i = 0; i < 0x100; i++)
+ charset2uni[i] = 0xfffd;
+ for (;;) {
+ c = getc(stdin);
+ if (c == EOF)
+ break;
+ if (c == '\n' || c == ' ' || c == '\t')
+ continue;
+ if (c == '#') {
+ do { c = getc(stdin); } while (!(c == EOF || c == '\n'));
+ continue;
+ }
+ ungetc(c,stdin);
+ if (scanf("0x%x", &i) != 1 || !(i >= 0 && i < 0x100))
+ exit(1);
+ do { c = getc(stdin); } while (c == ' ' || c == '\t');
+ if (c != EOF)
+ ungetc(c,stdin);
+ if (c == '\n' || c == '#')
+ continue;
+ if (scanf("0x%x", &charset2uni[i]) != 1)
+ exit(1);
+ }
+ } else {
+ /* Read a table of hexadecimal Unicode values. */
+ for (i = 0; i < 0x100; i++) {
+ if (scanf("%x", &charset2uni[i]) != 1)
+ exit(1);
+ if (charset2uni[i] < 0 || charset2uni[i] == 0xffff)
+ charset2uni[i] = 0xfffd;
+ }
+ if (scanf("%x", &i) != EOF)
+ exit(1);
+ }
+ }
+
+ /* Write the output file. */
+ {
+ FILE* f;
+
+ {
+ char* fname = malloc(strlen(directory)+strlen(filename)+1);
+ strcpy(fname,directory); strcat(fname,filename);
+ f = fopen(fname,"w");
+ if (f == NULL)
+ exit(1);
+ }
+
+ fprintf(f, "\n");
+ fprintf(f, "/*\n");
+ fprintf(f, " * %s\n", charsetname);
+ fprintf(f, " */\n");
+ fprintf(f, "\n");
+
+ {
+ int i, i1, i2, i3;
+ int line[16];
+ int tableno;
+ struct { int minline; int maxline; } tables[16];
+ bool some_invalid;
+ bool final_ret_reached;
+
+ for (i1 = 0; i1 < 16; i1++) {
+ bool all_invalid = true;
+ bool all_identity = true;
+ for (i2 = 0; i2 < 16; i2++) {
+ i = 16*i1+i2;
+ if (charset2uni[i] != 0xfffd)
+ all_invalid = false;
+ if (charset2uni[i] != i)
+ all_identity = false;
+ }
+ if (all_invalid)
+ line[i1] = -2;
+ else if (all_identity)
+ line[i1] = -1;
+ else
+ line[i1] = 0;
+ }
+ tableno = 0;
+ for (i1 = 0; i1 < 16; i1++) {
+ if (line[i1] >= 0) {
+ if (i1 > 0 && tableno > 0 && line[i1-1] == tableno-1) {
+ line[i1] = tableno-1;
+ tables[tableno-1].maxline = i1;
+ } else {
+ tableno++;
+ line[i1] = tableno-1;
+ tables[tableno-1].minline = tables[tableno-1].maxline = i1;
+ }
+ }
+ }
+ some_invalid = false;
+ for (i = 0; i < 0x100; i++)
+ if (charset2uni[i] == 0xfffd)
+ some_invalid = true;
+ if (tableno > 0) {
+ int t;
+ for (t = 0; t < tableno; t++) {
+ fprintf(f, "static const unsigned short %s_2uni", c_charsetname);
+ if (tableno > 1)
+ fprintf(f, "_%d", t+1);
+ fprintf(f, "[%d] = {\n", 16*(tables[t].maxline-tables[t].minline+1));
+ for (i1 = tables[t].minline; i1 <= tables[t].maxline; i1++) {
+ fprintf(f, " /* 0x%02x */\n", 16*i1);
+ for (i2 = 0; i2 < 2; i2++) {
+ fprintf(f, " ");
+ for (i3 = 0; i3 < 8; i3++) {
+ i = 16*i1+8*i2+i3;
+ fprintf(f, " 0x%04x,", charset2uni[i]);
+ }
+ fprintf(f, "\n");
+ }
+ }
+ fprintf(f, "};\n");
+ }
+ fprintf(f, "\n");
+ }
+ final_ret_reached = false;
+ fprintf(f, "static int\n%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)\n", c_charsetname);
+ fprintf(f, "{\n");
+ fprintf(f, " unsigned char c = *s;\n");
+ if (some_invalid) {
+ for (i1 = 0; i1 < 16;) {
+ int t = line[i1];
+ const char* indent;
+ for (i2 = i1; i2 < 16 && line[i2] == t; i2++);
+ indent = (i1 == 0 && i2 == 16 ? " " : " ");
+ if (i1 == 0) {
+ if (i2 == 16) {
+ } else {
+ fprintf(f, " if (c < 0x%02x) {\n", 16*i2);
+ }
+ } else {
+ if (i2 == 16) {
+ fprintf(f, " else {\n");
+ } else {
+ fprintf(f, " else if (c < 0x%02x) {\n", 16*i2);
+ }
+ }
+ if (t == -2) {
+ final_ret_reached = true;
+ } else if (t == -1) {
+ fprintf(f, "%s*pwc = (ucs4_t) c;\n", indent);
+ fprintf(f, "%sreturn 1;\n", indent);
+ } else {
+ fprintf(f, "%s", indent);
+ some_invalid = false;
+ for (i = 16*i1; i < 16*i2; i++)
+ if (charset2uni[i] == 0xfffd)
+ some_invalid = true;
+ if (some_invalid)
+ fprintf(f, "unsigned short wc = ");
+ else
+ fprintf(f, "*pwc = (ucs4_t) ");
+ fprintf(f, "%s_2uni", c_charsetname);
+ if (tableno > 1)
+ fprintf(f, "_%d", t+1);
+ fprintf(f, "[c");
+ if (tables[t].minline > 0)
+ fprintf(f, "-0x%02x", 16*tables[t].minline);
+ fprintf(f, "];\n");
+ if (some_invalid) {
+ fprintf(f, "%sif (wc != 0xfffd) {\n", indent);
+ fprintf(f, "%s *pwc = (ucs4_t) wc;\n", indent);
+ fprintf(f, "%s return 1;\n", indent);
+ fprintf(f, "%s}\n", indent);
+ final_ret_reached = true;
+ } else {
+ fprintf(f, "%sreturn 1;\n", indent);
+ }
+ }
+ if (!(i1 == 0 && i2 == 16))
+ fprintf(f, " }\n");
+ i1 = i2;
+ }
+ if (final_ret_reached)
+ fprintf(f, " return RET_ILSEQ;\n");
+ } else {
+ for (i1 = 0; i1 < 16;) {
+ int t = line[i1];
+ for (i2 = i1; i2 < 16 && line[i2] == t; i2++);
+ if (i1 == 0) {
+ if (i2 == 16) {
+ fprintf(f, " ");
+ } else {
+ fprintf(f, " if (c < 0x%02x)\n ", 16*i2);
+ }
+ } else {
+ if (i2 == 16) {
+ fprintf(f, " else\n ");
+ } else {
+ fprintf(f, " else if (c < 0x%02x)\n ", 16*i2);
+ }
+ }
+ if (t == -1)
+ fprintf(f, "*pwc = (ucs4_t) c;\n");
+ else {
+ fprintf(f, "*pwc = (ucs4_t) %s_2uni", c_charsetname);
+ if (tableno > 1)
+ fprintf(f, "_%d", t+1);
+ fprintf(f, "[c");
+ if (tables[t].minline > 0)
+ fprintf(f, "-0x%02x", 16*tables[t].minline);
+ fprintf(f, "];\n");
+ }
+ i1 = i2;
+ }
+ fprintf(f, " return 1;\n");
+ }
+ fprintf(f, "}\n");
+
+ }
+
+ fprintf(f, "\n");
+
+ {
+ int uni2charset[0x10000];
+ bool pages[0x100];
+ int line[0x2000];
+ int tableno;
+ struct { int minline; int maxline; int usecount; const char* suffix; } tables[0x2000];
+ bool need_c;
+ bool fix_0000;
+ int i, j, p, j1, j2, t;
+
+ for (j = 0; j < 0x10000; j++)
+ uni2charset[j] = 0;
+ for (p = 0; p < 0x100; p++)
+ pages[p] = false;
+ for (i = 0; i < 0x100; i++) {
+ j = charset2uni[i];
+ if (j != 0xfffd) {
+ uni2charset[j] = i;
+ pages[j>>8] = true;
+ }
+ }
+ for (j1 = 0; j1 < 0x2000; j1++) {
+ bool all_invalid = true;
+ bool all_identity = true;
+ for (j2 = 0; j2 < 8; j2++) {
+ j = 8*j1+j2;
+ if (uni2charset[j] != 0)
+ all_invalid = false;
+ if (uni2charset[j] != j)
+ all_identity = false;
+ }
+ if (all_invalid)
+ line[j1] = -2;
+ else if (all_identity)
+ line[j1] = -1;
+ else
+ line[j1] = 0;
+ }
+ tableno = 0;
+ for (j1 = 0; j1 < 0x2000; j1++) {
+ if (line[j1] >= 0) {
+ if (tableno > 0
+ && ((j1 > 0 && line[j1-1] == tableno-1)
+ || ((tables[tableno-1].maxline >> 5) == (j1 >> 5)
+ && j1 - tables[tableno-1].maxline <= 8))) {
+ line[j1] = tableno-1;
+ tables[tableno-1].maxline = j1;
+ } else {
+ tableno++;
+ line[j1] = tableno-1;
+ tables[tableno-1].minline = tables[tableno-1].maxline = j1;
+ }
+ }
+ }
+ for (t = 0; t < tableno; t++) {
+ tables[t].usecount = 0;
+ j1 = 8*tables[t].minline;
+ j2 = 8*(tables[t].maxline+1);
+ for (j = j1; j < j2; j++)
+ if (uni2charset[j] != 0)
+ tables[t].usecount++;
+ }
+ for (t = 0, p = -1, i = 0; t < tableno; t++) {
+ if (tables[t].usecount > 1) {
+ char* s;
+ if (p == tables[t].minline >> 5) {
+ s = (char*) malloc(5+1);
+ sprintf(s, "%02x_%d", p, ++i);
+ } else {
+ p = tables[t].minline >> 5;
+ s = (char*) malloc(2+1);
+ sprintf(s, "%02x", p);
+ }
+ tables[t].suffix = s;
+ } else
+ tables[t].suffix = NULL;
+ }
+ {
+ p = -1;
+ for (t = 0; t < tableno; t++)
+ if (tables[t].usecount > 1) {
+ p = 0;
+ fprintf(f, "static const unsigned char %s_page%s[%d] = {\n", c_charsetname, tables[t].suffix, 8*(tables[t].maxline-tables[t].minline+1));
+ for (j1 = tables[t].minline; j1 <= tables[t].maxline; j1++) {
+ if ((j1 % 0x20) == 0 && j1 > tables[t].minline)
+ fprintf(f, " /* 0x%04x */\n", 8*j1);
+ fprintf(f, " ");
+ for (j2 = 0; j2 < 8; j2++) {
+ j = 8*j1+j2;
+ fprintf(f, " 0x%02x,", uni2charset[j]);
+ }
+ fprintf(f, " /* 0x%02x-0x%02x */\n", 8*(j1 % 0x20), 8*(j1 % 0x20)+7);
+ }
+ fprintf(f, "};\n");
+ }
+ if (p >= 0)
+ fprintf(f, "\n");
+ }
+ need_c = false;
+ for (j1 = 0; j1 < 0x2000;) {
+ t = line[j1];
+ for (j2 = j1; j2 < 0x2000 && line[j2] == t; j2++);
+ if (t >= 0)
+ j2 = tables[t].maxline+1;
+ if (!(t == -2 || (t == -1 && j1 == 0)))
+ need_c = true;
+ j1 = j2;
+ }
+ fix_0000 = false;
+ fprintf(f, "static int\n%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", c_charsetname);
+ fprintf(f, "{\n");
+ if (need_c)
+ fprintf(f, " unsigned char c = 0;\n");
+ for (j1 = 0; j1 < 0x2000;) {
+ t = line[j1];
+ for (j2 = j1; j2 < 0x2000 && line[j2] == t; j2++);
+ if (t >= 0) {
+ if (j1 != tables[t].minline) abort();
+ if (j2 > tables[t].maxline+1) abort();
+ j2 = tables[t].maxline+1;
+ }
+ if (t == -2) {
+ } else {
+ if (j1 == 0)
+ fprintf(f, " ");
+ else
+ fprintf(f, " else ");
+ if (t >= 0 && tables[t].usecount == 0) abort();
+ if (t >= 0 && tables[t].usecount == 1) {
+ if (j2 != j1+1) abort();
+ for (j = 8*j1; j < 8*j2; j++)
+ if (uni2charset[j] != 0) {
+ fprintf(f, "if (wc == 0x%04x)\n c = 0x%02x;\n", j, uni2charset[j]);
+ break;
+ }
+ } else {
+ if (j1 == 0) {
+ fprintf(f, "if (wc < 0x%04x)", 8*j2);
+ } else {
+ fprintf(f, "if (wc >= 0x%04x && wc < 0x%04x)", 8*j1, 8*j2);
+ }
+ if (t == -1) {
+ if (j1 == 0)
+ /* If wc == 0, the function must return 1, not -1. */
+ fprintf(f, " {\n *r = wc;\n return 1;\n }\n");
+ else
+ fprintf(f, "\n c = wc;\n");
+ } else {
+ fprintf(f, "\n c = %s_page%s[wc", c_charsetname, tables[t].suffix);
+ if (tables[t].minline > 0)
+ fprintf(f, "-0x%04x", 8*j1);
+ fprintf(f, "];\n");
+ if (j1 == 0 && uni2charset[0] == 0)
+ /* If wc == 0, the function must return 1, not -1. */
+ fix_0000 = true;
+ }
+ }
+ }
+ j1 = j2;
+ }
+ if (need_c) {
+ if (fix_0000)
+ fprintf(f, " if (c != 0 || wc == 0) {\n");
+ else
+ fprintf(f, " if (c != 0) {\n");
+ fprintf(f, " *r = c;\n");
+ fprintf(f, " return 1;\n");
+ fprintf(f, " }\n");
+ }
+ fprintf(f, " return RET_ILSEQ;\n");
+ fprintf(f, "}\n");
+
+ }
+
+ if (ferror(f) || fclose(f))
+ exit(1);
+ }
+
+#if 0
+
+ int i1, i2, i3, i1_min, i1_max, j1, j2;
+
+ i1_min = 16;
+ i1_max = -1;
+ for (i1 = 0; i1 < 16; i1++)
+ for (i2 = 0; i2 < 16; i2++)
+ if (charset2uni[16*i1+i2] != 0xfffd) {
+ if (i1_min > i1) i1_min = i1;
+ if (i1_max < i1) i1_max = i1;
+ }
+ printf("static const unsigned short %s_2uni[%d] = {\n",
+ name, 16*(i1_max-i1_min+1));
+ for (i1 = i1_min; i1 <= i1_max; i1++) {
+ printf(" /""* 0x%02x *""/\n", 16*i1);
+ for (i2 = 0; i2 < 2; i2++) {
+ printf(" ");
+ for (i3 = 0; i3 < 8; i3++) {
+ if (i3 > 0) printf(" ");
+ printf("0x%04x,", charset2uni[16*i1+8*i2+i3]);
+ }
+ printf("\n");
+ }
+ }
+ printf("};\n");
+ printf("\n");
+
+ for (p = 0; p < 0x100; p++)
+ pages[p] = 0;
+ for (i = 0; i < 0x100; i++)
+ if (charset2uni[i] != 0xfffd)
+ pages[charset2uni[i]>>8] = 1;
+ for (p = 0; p < 0x100; p++)
+ if (pages[p]) {
+ int j1_min = 32;
+ int j1_max = -1;
+ for (j1 = 0; j1 < 32; j1++)
+ for (j2 = 0; j2 < 8; j2++)
+ if (uni2charset[256*p+8*j1+j2] != 0) {
+ if (j1_min > j1) j1_min = j1;
+ if (j1_max < j1) j1_max = j1;
+ }
+ printf("static const unsigned char %s_page%02x[%d] = {\n",
+ name, p, 8*(j1_max-j1_min+1));
+ for (j1 = j1_min; j1 <= j1_max; j1++) {
+ printf(" ");
+ for (j2 = 0; j2 < 8; j2++)
+ printf("0x%02x, ", uni2charset[256*p+8*j1+j2]);
+ printf("/""* 0x%02x-0x%02x *""/\n", 8*j1, 8*j1+7);
+ }
+ printf("};\n");
+ }
+ printf("\n");
+
+}
+#endif
+
+ exit(0);
+}
diff --git a/nx-X11/lib/X11/lcUniConv/COPYRIGHT b/nx-X11/lib/X11/lcUniConv/COPYRIGHT
new file mode 100644
index 000000000..ccc162664
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/COPYRIGHT
@@ -0,0 +1,39 @@
+This notice applies to the files in this directory. They are taken from
+the libiconv-1.1 package, which is covered by the LGPL license. The files
+in this directory have been placed under the following copyright, with
+permission from the Free Software Foundation.
+
+
+Copyright (c) 1999-2000 Free Software Foundation, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+FREE SOFTWARE FOUNDATION 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 Free Software Foundation
+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
+Free Software Foundation.
+
+
+Notes:
+
+1. This copyright applies only to the files in this directory, and not to
+the remaining files in libiconv.
+
+2. The Free Software Foundation does not encourage the use of the above
+license for newly written software.
+
diff --git a/nx-X11/lib/X11/lcUniConv/README b/nx-X11/lib/X11/lcUniConv/README
new file mode 100644
index 000000000..5ea4f0566
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/README
@@ -0,0 +1,12 @@
+$XFree86$
+
+The files in this directory are taken from the libiconv-1.1 package.
+
+The *.h files were generated from tables (mostly from ftp.unicode.org) using
+the programs '8bit_tab_to_h.c' and 'cjk_tab_to_h.c'. On some of them, further
+optimizations were applied by hand.
+
+If you find a bug in these files, instead of modifying them in XFree86
+and let it diverge from libiconv, please notify the libiconv maintainer
+(currently <bruno@clisp.org>) so he can fix both in synch.
+
diff --git a/nx-X11/lib/X11/lcUniConv/armscii_8.h b/nx-X11/lib/X11/lcUniConv/armscii_8.h
new file mode 100644
index 000000000..6ca102eaa
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/armscii_8.h
@@ -0,0 +1,98 @@
+/* $XFree86: xc/lib/X11/lcUniConv/armscii_8.h,v 1.3 2000/11/29 17:40:28 dawes Exp $ */
+
+/*
+ * ARMSCII-8
+ */
+
+static const unsigned short armscii_8_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0xfffd, 0x0587, 0x0589, 0x0029, 0x0028, 0x00bb, 0x00ab,
+ 0x2014, 0x002e, 0x055d, 0x002c, 0x002d, 0x058a, 0x2026, 0x055c,
+ /* 0xb0 */
+ 0x055b, 0x055e, 0x0531, 0x0561, 0x0532, 0x0562, 0x0533, 0x0563,
+ 0x0534, 0x0564, 0x0535, 0x0565, 0x0536, 0x0566, 0x0537, 0x0567,
+ /* 0xc0 */
+ 0x0538, 0x0568, 0x0539, 0x0569, 0x053a, 0x056a, 0x053b, 0x056b,
+ 0x053c, 0x056c, 0x053d, 0x056d, 0x053e, 0x056e, 0x053f, 0x056f,
+ /* 0xd0 */
+ 0x0540, 0x0570, 0x0541, 0x0571, 0x0542, 0x0572, 0x0543, 0x0573,
+ 0x0544, 0x0574, 0x0545, 0x0575, 0x0546, 0x0576, 0x0547, 0x0577,
+ /* 0xe0 */
+ 0x0548, 0x0578, 0x0549, 0x0579, 0x054a, 0x057a, 0x054b, 0x057b,
+ 0x054c, 0x057c, 0x054d, 0x057d, 0x054e, 0x057e, 0x054f, 0x057f,
+ /* 0xf0 */
+ 0x0550, 0x0580, 0x0551, 0x0581, 0x0552, 0x0582, 0x0553, 0x0583,
+ 0x0554, 0x0584, 0x0555, 0x0585, 0x0556, 0x0586, 0x055a, 0xfffd,
+};
+
+static int
+armscii_8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0xa0) {
+ *pwc = (ucs4_t) c;
+ return 1;
+ }
+ else {
+ unsigned short wc = armscii_8_2uni[c-0xa0];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 1;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned char armscii_8_page00[8] = {
+ 0xa5, 0xa4, 0x2a, 0x2b, 0xab, 0xac, 0xa9, 0x2f, /* 0x28-0x2f */
+};
+static const unsigned char armscii_8_page00_1[32] = {
+ 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+ 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
+ 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+};
+static const unsigned char armscii_8_page05[96] = {
+ 0x00, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe, /* 0x30-0x37 */
+ 0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, /* 0x38-0x3f */
+ 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde, /* 0x40-0x47 */
+ 0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, /* 0x48-0x4f */
+ 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0xfe, 0xb0, 0xaf, 0xaa, 0xb1, 0x00, /* 0x58-0x5f */
+ 0x00, 0xb3, 0xb5, 0xb7, 0xb9, 0xbb, 0xbd, 0xbf, /* 0x60-0x67 */
+ 0xc1, 0xc3, 0xc5, 0xc7, 0xc9, 0xcb, 0xcd, 0xcf, /* 0x68-0x6f */
+ 0xd1, 0xd3, 0xd5, 0xd7, 0xd9, 0xdb, 0xdd, 0xdf, /* 0x70-0x77 */
+ 0xe1, 0xe3, 0xe5, 0xe7, 0xe9, 0xeb, 0xed, 0xef, /* 0x78-0x7f */
+ 0xf1, 0xf3, 0xf5, 0xf7, 0xf9, 0xfb, 0xfd, 0xa2, /* 0x80-0x87 */
+ 0x00, 0xa3, 0xad, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+};
+static const unsigned char armscii_8_page20[24] = {
+ 0x00, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xae, 0x00, /* 0x20-0x27 */
+};
+
+static int
+armscii_8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0028) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x0028 && wc < 0x0030)
+ c = armscii_8_page00[wc-0x0028];
+ else if (wc >= 0x0030 && wc < 0x00a0)
+ c = wc;
+ else if (wc >= 0x00a0 && wc < 0x00c0)
+ c = armscii_8_page00_1[wc-0x00a0];
+ else if (wc >= 0x0530 && wc < 0x0590)
+ c = armscii_8_page05[wc-0x0530];
+ else if (wc >= 0x2010 && wc < 0x2028)
+ c = armscii_8_page20[wc-0x2010];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/ascii.h b/nx-X11/lib/X11/lcUniConv/ascii.h
new file mode 100644
index 000000000..db8677d7f
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/ascii.h
@@ -0,0 +1,26 @@
+/* $XFree86$ */
+
+/*
+ * ASCII
+ */
+
+static int
+ascii_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0x80) {
+ *pwc = (ucs4_t) c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
+
+static int
+ascii_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ if (wc < 0x0080) {
+ *r = wc;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/big5.h b/nx-X11/lib/X11/lcUniConv/big5.h
new file mode 100644
index 000000000..b356b5ebf
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/big5.h
@@ -0,0 +1,4142 @@
+/* $XFree86: xc/lib/X11/lcUniConv/big5.h,v 1.1tsi Exp $ */
+
+/*
+ * BIG5
+ */
+
+static const unsigned short big5_2uni_pagea1[6121] = {
+ /* 0xa1 */
+ 0x3000, 0xff0c, 0x3001, 0x3002, 0xff0e, 0x2022, 0xff1b, 0xff1a,
+ 0xff1f, 0xff01, 0xfe30, 0x2026, 0x2025, 0xfe50, 0xff64, 0xfe52,
+ 0x00b7, 0xfe54, 0xfe55, 0xfe56, 0xfe57, 0xff5c, 0x2013, 0xfe31,
+ 0x2014, 0xfe33, 0xfffd, 0xfe34, 0xfe4f, 0xff08, 0xff09, 0xfe35,
+ 0xfe36, 0xff5b, 0xff5d, 0xfe37, 0xfe38, 0x3014, 0x3015, 0xfe39,
+ 0xfe3a, 0x3010, 0x3011, 0xfe3b, 0xfe3c, 0x300a, 0x300b, 0xfe3d,
+ 0xfe3e, 0x3008, 0x3009, 0xfe3f, 0xfe40, 0x300c, 0x300d, 0xfe41,
+ 0xfe42, 0x300e, 0x300f, 0xfe43, 0xfe44, 0xfe59, 0xfe5a, 0xfe5b,
+ 0xfe5c, 0xfe5d, 0xfe5e, 0x2018, 0x2019, 0x201c, 0x201d, 0x301d,
+ 0x301e, 0x2035, 0x2032, 0xff03, 0xff06, 0xff0a, 0x203b, 0x00a7,
+ 0x3003, 0x25cb, 0x25cf, 0x25b3, 0x25b2, 0x25ce, 0x2606, 0x2605,
+ 0x25c7, 0x25c6, 0x25a1, 0x25a0, 0x25bd, 0x25bc, 0x32a3, 0x2105,
+ 0x203e, 0xfffd, 0xff3f, 0xfffd, 0xfe49, 0xfe4a, 0xfe4d, 0xfe4e,
+ 0xfe4b, 0xfe4c, 0xfe5f, 0xfe60, 0xfe61, 0xff0b, 0xff0d, 0x00d7,
+ 0x00f7, 0x00b1, 0x221a, 0xff1c, 0xff1e, 0xff1d, 0x2266, 0x2267,
+ 0x2260, 0x221e, 0x2252, 0x2261, 0xfe62, 0xfe63, 0xfe64, 0xfe65,
+ 0xfe66, 0x223c, 0x2229, 0x222a, 0x22a5, 0x2220, 0x221f, 0x22bf,
+ 0x33d2, 0x33d1, 0x222b, 0x222e, 0x2235, 0x2234, 0x2640, 0x2642,
+ 0x2641, 0x2609, 0x2191, 0x2193, 0x2190, 0x2192, 0x2196, 0x2197,
+ 0x2199, 0x2198, 0x2225, 0x2223, 0xfffd,
+ /* 0xa2 */
+ 0xfffd, 0xff0f, 0xff3c, 0xff04, 0x00a5, 0x3012, 0x00a2, 0x00a3,
+ 0xff05, 0xff20, 0x2103, 0x2109, 0xfe69, 0xfe6a, 0xfe6b, 0x33d5,
+ 0x339c, 0x339d, 0x339e, 0x33ce, 0x33a1, 0x338e, 0x338f, 0x33c4,
+ 0x00b0, 0x5159, 0x515b, 0x515e, 0x515d, 0x5161, 0x5163, 0x55e7,
+ 0x74e9, 0x7cce, 0x2581, 0x2582, 0x2583, 0x2584, 0x2585, 0x2586,
+ 0x2587, 0x2588, 0x258f, 0x258e, 0x258d, 0x258c, 0x258b, 0x258a,
+ 0x2589, 0x253c, 0x2534, 0x252c, 0x2524, 0x251c, 0x2594, 0x2500,
+ 0x2502, 0x2595, 0x250c, 0x2510, 0x2514, 0x2518, 0x256d, 0x256e,
+ 0x2570, 0x256f, 0x2550, 0x255e, 0x256a, 0x2561, 0x25e2, 0x25e3,
+ 0x25e5, 0x25e4, 0x2571, 0x2572, 0x2573, 0xff10, 0xff11, 0xff12,
+ 0xff13, 0xff14, 0xff15, 0xff16, 0xff17, 0xff18, 0xff19, 0x2160,
+ 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168,
+ 0x2169, 0x3021, 0x3022, 0x3023, 0x3024, 0x3025, 0x3026, 0x3027,
+ 0x3028, 0x3029, 0xfffd, 0x5344, 0xfffd, 0xff21, 0xff22, 0xff23,
+ 0xff24, 0xff25, 0xff26, 0xff27, 0xff28, 0xff29, 0xff2a, 0xff2b,
+ 0xff2c, 0xff2d, 0xff2e, 0xff2f, 0xff30, 0xff31, 0xff32, 0xff33,
+ 0xff34, 0xff35, 0xff36, 0xff37, 0xff38, 0xff39, 0xff3a, 0xff41,
+ 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48, 0xff49,
+ 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50, 0xff51,
+ 0xff52, 0xff53, 0xff54, 0xff55, 0xff56,
+ /* 0xa3 */
+ 0xff57, 0xff58, 0xff59, 0xff5a, 0x0391, 0x0392, 0x0393, 0x0394,
+ 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c,
+ 0x039d, 0x039e, 0x039f, 0x03a0, 0x03a1, 0x03a3, 0x03a4, 0x03a5,
+ 0x03a6, 0x03a7, 0x03a8, 0x03a9, 0x03b1, 0x03b2, 0x03b3, 0x03b4,
+ 0x03b5, 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc,
+ 0x03bd, 0x03be, 0x03bf, 0x03c0, 0x03c1, 0x03c3, 0x03c4, 0x03c5,
+ 0x03c6, 0x03c7, 0x03c8, 0x03c9, 0x3105, 0x3106, 0x3107, 0x3108,
+ 0x3109, 0x310a, 0x310b, 0x310c, 0x310d, 0x310e, 0x310f, 0x3110,
+ 0x3111, 0x3112, 0x3113, 0x3114, 0x3115, 0x3116, 0x3117, 0x3118,
+ 0x3119, 0x311a, 0x311b, 0x311c, 0x311d, 0x311e, 0x311f, 0x3120,
+ 0x3121, 0x3122, 0x3123, 0x3124, 0x3125, 0x3126, 0x3127, 0x3128,
+ 0x3129, 0x02d9, 0x02c9, 0x02ca, 0x02c7, 0x02cb, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0xa4 */
+ 0x4e00, 0x4e59, 0x4e01, 0x4e03, 0x4e43, 0x4e5d, 0x4e86, 0x4e8c,
+ 0x4eba, 0x513f, 0x5165, 0x516b, 0x51e0, 0x5200, 0x5201, 0x529b,
+ 0x5315, 0x5341, 0x535c, 0x53c8, 0x4e09, 0x4e0b, 0x4e08, 0x4e0a,
+ 0x4e2b, 0x4e38, 0x51e1, 0x4e45, 0x4e48, 0x4e5f, 0x4e5e, 0x4e8e,
+ 0x4ea1, 0x5140, 0x5203, 0x52fa, 0x5343, 0x53c9, 0x53e3, 0x571f,
+ 0x58eb, 0x5915, 0x5927, 0x5973, 0x5b50, 0x5b51, 0x5b53, 0x5bf8,
+ 0x5c0f, 0x5c22, 0x5c38, 0x5c71, 0x5ddd, 0x5de5, 0x5df1, 0x5df2,
+ 0x5df3, 0x5dfe, 0x5e72, 0x5efe, 0x5f0b, 0x5f13, 0x624d, 0x4e11,
+ 0x4e10, 0x4e0d, 0x4e2d, 0x4e30, 0x4e39, 0x4e4b, 0x5c39, 0x4e88,
+ 0x4e91, 0x4e95, 0x4e92, 0x4e94, 0x4ea2, 0x4ec1, 0x4ec0, 0x4ec3,
+ 0x4ec6, 0x4ec7, 0x4ecd, 0x4eca, 0x4ecb, 0x4ec4, 0x5143, 0x5141,
+ 0x5167, 0x516d, 0x516e, 0x516c, 0x5197, 0x51f6, 0x5206, 0x5207,
+ 0x5208, 0x52fb, 0x52fe, 0x52ff, 0x5316, 0x5339, 0x5348, 0x5347,
+ 0x5345, 0x535e, 0x5384, 0x53cb, 0x53ca, 0x53cd, 0x58ec, 0x5929,
+ 0x592b, 0x592a, 0x592d, 0x5b54, 0x5c11, 0x5c24, 0x5c3a, 0x5c6f,
+ 0x5df4, 0x5e7b, 0x5eff, 0x5f14, 0x5f15, 0x5fc3, 0x6208, 0x6236,
+ 0x624b, 0x624e, 0x652f, 0x6587, 0x6597, 0x65a4, 0x65b9, 0x65e5,
+ 0x66f0, 0x6708, 0x6728, 0x6b20, 0x6b62, 0x6b79, 0x6bcb, 0x6bd4,
+ 0x6bdb, 0x6c0f, 0x6c34, 0x706b, 0x722a, 0x7236, 0x723b, 0x7247,
+ 0x7259, 0x725b, 0x72ac, 0x738b, 0x4e19,
+ /* 0xa5 */
+ 0x4e16, 0x4e15, 0x4e14, 0x4e18, 0x4e3b, 0x4e4d, 0x4e4f, 0x4e4e,
+ 0x4ee5, 0x4ed8, 0x4ed4, 0x4ed5, 0x4ed6, 0x4ed7, 0x4ee3, 0x4ee4,
+ 0x4ed9, 0x4ede, 0x5145, 0x5144, 0x5189, 0x518a, 0x51ac, 0x51f9,
+ 0x51fa, 0x51f8, 0x520a, 0x52a0, 0x529f, 0x5305, 0x5306, 0x5317,
+ 0x531d, 0x4edf, 0x534a, 0x5349, 0x5361, 0x5360, 0x536f, 0x536e,
+ 0x53bb, 0x53ef, 0x53e4, 0x53f3, 0x53ec, 0x53ee, 0x53e9, 0x53e8,
+ 0x53fc, 0x53f8, 0x53f5, 0x53eb, 0x53e6, 0x53ea, 0x53f2, 0x53f1,
+ 0x53f0, 0x53e5, 0x53ed, 0x53fb, 0x56db, 0x56da, 0x5916, 0x592e,
+ 0x5931, 0x5974, 0x5976, 0x5b55, 0x5b83, 0x5c3c, 0x5de8, 0x5de7,
+ 0x5de6, 0x5e02, 0x5e03, 0x5e73, 0x5e7c, 0x5f01, 0x5f18, 0x5f17,
+ 0x5fc5, 0x620a, 0x6253, 0x6254, 0x6252, 0x6251, 0x65a5, 0x65e6,
+ 0x672e, 0x672c, 0x672a, 0x672b, 0x672d, 0x6b63, 0x6bcd, 0x6c11,
+ 0x6c10, 0x6c38, 0x6c41, 0x6c40, 0x6c3e, 0x72af, 0x7384, 0x7389,
+ 0x74dc, 0x74e6, 0x7518, 0x751f, 0x7528, 0x7529, 0x7530, 0x7531,
+ 0x7532, 0x7533, 0x758b, 0x767d, 0x76ae, 0x76bf, 0x76ee, 0x77db,
+ 0x77e2, 0x77f3, 0x793a, 0x79be, 0x7a74, 0x7acb, 0x4e1e, 0x4e1f,
+ 0x4e52, 0x4e53, 0x4e69, 0x4e99, 0x4ea4, 0x4ea6, 0x4ea5, 0x4eff,
+ 0x4f09, 0x4f19, 0x4f0a, 0x4f15, 0x4f0d, 0x4f10, 0x4f11, 0x4f0f,
+ 0x4ef2, 0x4ef6, 0x4efb, 0x4ef0, 0x4ef3, 0x4efd, 0x4f01, 0x4f0b,
+ 0x5149, 0x5147, 0x5146, 0x5148, 0x5168,
+ /* 0xa6 */
+ 0x5171, 0x518d, 0x51b0, 0x5217, 0x5211, 0x5212, 0x520e, 0x5216,
+ 0x52a3, 0x5308, 0x5321, 0x5320, 0x5370, 0x5371, 0x5409, 0x540f,
+ 0x540c, 0x540a, 0x5410, 0x5401, 0x540b, 0x5404, 0x5411, 0x540d,
+ 0x5408, 0x5403, 0x540e, 0x5406, 0x5412, 0x56e0, 0x56de, 0x56dd,
+ 0x5733, 0x5730, 0x5728, 0x572d, 0x572c, 0x572f, 0x5729, 0x5919,
+ 0x591a, 0x5937, 0x5938, 0x5984, 0x5978, 0x5983, 0x597d, 0x5979,
+ 0x5982, 0x5981, 0x5b57, 0x5b58, 0x5b87, 0x5b88, 0x5b85, 0x5b89,
+ 0x5bfa, 0x5c16, 0x5c79, 0x5dde, 0x5e06, 0x5e76, 0x5e74, 0x5f0f,
+ 0x5f1b, 0x5fd9, 0x5fd6, 0x620e, 0x620c, 0x620d, 0x6210, 0x6263,
+ 0x625b, 0x6258, 0x6536, 0x65e9, 0x65e8, 0x65ec, 0x65ed, 0x66f2,
+ 0x66f3, 0x6709, 0x673d, 0x6734, 0x6731, 0x6735, 0x6b21, 0x6b64,
+ 0x6b7b, 0x6c16, 0x6c5d, 0x6c57, 0x6c59, 0x6c5f, 0x6c60, 0x6c50,
+ 0x6c55, 0x6c61, 0x6c5b, 0x6c4d, 0x6c4e, 0x7070, 0x725f, 0x725d,
+ 0x767e, 0x7af9, 0x7c73, 0x7cf8, 0x7f36, 0x7f8a, 0x7fbd, 0x8001,
+ 0x8003, 0x800c, 0x8012, 0x8033, 0x807f, 0x8089, 0x808b, 0x808c,
+ 0x81e3, 0x81ea, 0x81f3, 0x81fc, 0x820c, 0x821b, 0x821f, 0x826e,
+ 0x8272, 0x827e, 0x866b, 0x8840, 0x884c, 0x8863, 0x897f, 0x9621,
+ 0x4e32, 0x4ea8, 0x4f4d, 0x4f4f, 0x4f47, 0x4f57, 0x4f5e, 0x4f34,
+ 0x4f5b, 0x4f55, 0x4f30, 0x4f50, 0x4f51, 0x4f3d, 0x4f3a, 0x4f38,
+ 0x4f43, 0x4f54, 0x4f3c, 0x4f46, 0x4f63,
+ /* 0xa7 */
+ 0x4f5c, 0x4f60, 0x4f2f, 0x4f4e, 0x4f36, 0x4f59, 0x4f5d, 0x4f48,
+ 0x4f5a, 0x514c, 0x514b, 0x514d, 0x5175, 0x51b6, 0x51b7, 0x5225,
+ 0x5224, 0x5229, 0x522a, 0x5228, 0x52ab, 0x52a9, 0x52aa, 0x52ac,
+ 0x5323, 0x5373, 0x5375, 0x541d, 0x542d, 0x541e, 0x543e, 0x5426,
+ 0x544e, 0x5427, 0x5446, 0x5443, 0x5433, 0x5448, 0x5442, 0x541b,
+ 0x5429, 0x544a, 0x5439, 0x543b, 0x5438, 0x542e, 0x5435, 0x5436,
+ 0x5420, 0x543c, 0x5440, 0x5431, 0x542b, 0x541f, 0x542c, 0x56ea,
+ 0x56f0, 0x56e4, 0x56eb, 0x574a, 0x5751, 0x5740, 0x574d, 0x5747,
+ 0x574e, 0x573e, 0x5750, 0x574f, 0x573b, 0x58ef, 0x593e, 0x599d,
+ 0x5992, 0x59a8, 0x599e, 0x59a3, 0x5999, 0x5996, 0x598d, 0x59a4,
+ 0x5993, 0x598a, 0x59a5, 0x5b5d, 0x5b5c, 0x5b5a, 0x5b5b, 0x5b8c,
+ 0x5b8b, 0x5b8f, 0x5c2c, 0x5c40, 0x5c41, 0x5c3f, 0x5c3e, 0x5c90,
+ 0x5c91, 0x5c94, 0x5c8c, 0x5deb, 0x5e0c, 0x5e8f, 0x5e87, 0x5e8a,
+ 0x5ef7, 0x5f04, 0x5f1f, 0x5f64, 0x5f62, 0x5f77, 0x5f79, 0x5fd8,
+ 0x5fcc, 0x5fd7, 0x5fcd, 0x5ff1, 0x5feb, 0x5ff8, 0x5fea, 0x6212,
+ 0x6211, 0x6284, 0x6297, 0x6296, 0x6280, 0x6276, 0x6289, 0x626d,
+ 0x628a, 0x627c, 0x627e, 0x6279, 0x6273, 0x6292, 0x626f, 0x6298,
+ 0x626e, 0x6295, 0x6293, 0x6291, 0x6286, 0x6539, 0x653b, 0x6538,
+ 0x65f1, 0x66f4, 0x675f, 0x674e, 0x674f, 0x6750, 0x6751, 0x675c,
+ 0x6756, 0x675e, 0x6749, 0x6746, 0x6760,
+ /* 0xa8 */
+ 0x6753, 0x6757, 0x6b65, 0x6bcf, 0x6c42, 0x6c5e, 0x6c99, 0x6c81,
+ 0x6c88, 0x6c89, 0x6c85, 0x6c9b, 0x6c6a, 0x6c7a, 0x6c90, 0x6c70,
+ 0x6c8c, 0x6c68, 0x6c96, 0x6c92, 0x6c7d, 0x6c83, 0x6c72, 0x6c7e,
+ 0x6c74, 0x6c86, 0x6c76, 0x6c8d, 0x6c94, 0x6c98, 0x6c82, 0x7076,
+ 0x707c, 0x707d, 0x7078, 0x7262, 0x7261, 0x7260, 0x72c4, 0x72c2,
+ 0x7396, 0x752c, 0x752b, 0x7537, 0x7538, 0x7682, 0x76ef, 0x77e3,
+ 0x79c1, 0x79c0, 0x79bf, 0x7a76, 0x7cfb, 0x7f55, 0x8096, 0x8093,
+ 0x809d, 0x8098, 0x809b, 0x809a, 0x80b2, 0x826f, 0x8292, 0x828b,
+ 0x828d, 0x898b, 0x89d2, 0x8a00, 0x8c37, 0x8c46, 0x8c55, 0x8c9d,
+ 0x8d64, 0x8d70, 0x8db3, 0x8eab, 0x8eca, 0x8f9b, 0x8fb0, 0x8fc2,
+ 0x8fc6, 0x8fc5, 0x8fc4, 0x5de1, 0x9091, 0x90a2, 0x90aa, 0x90a6,
+ 0x90a3, 0x9149, 0x91c6, 0x91cc, 0x9632, 0x962e, 0x9631, 0x962a,
+ 0x962c, 0x4e26, 0x4e56, 0x4e73, 0x4e8b, 0x4e9b, 0x4e9e, 0x4eab,
+ 0x4eac, 0x4f6f, 0x4f9d, 0x4f8d, 0x4f73, 0x4f7f, 0x4f6c, 0x4f9b,
+ 0x4f8b, 0x4f86, 0x4f83, 0x4f70, 0x4f75, 0x4f88, 0x4f69, 0x4f7b,
+ 0x4f96, 0x4f7e, 0x4f8f, 0x4f91, 0x4f7a, 0x5154, 0x5152, 0x5155,
+ 0x5169, 0x5177, 0x5176, 0x5178, 0x51bd, 0x51fd, 0x523b, 0x5238,
+ 0x5237, 0x523a, 0x5230, 0x522e, 0x5236, 0x5241, 0x52be, 0x52bb,
+ 0x5352, 0x5354, 0x5353, 0x5351, 0x5366, 0x5377, 0x5378, 0x5379,
+ 0x53d6, 0x53d4, 0x53d7, 0x5473, 0x5475,
+ /* 0xa9 */
+ 0x5496, 0x5478, 0x5495, 0x5480, 0x547b, 0x5477, 0x5484, 0x5492,
+ 0x5486, 0x547c, 0x5490, 0x5471, 0x5476, 0x548c, 0x549a, 0x5462,
+ 0x5468, 0x548b, 0x547d, 0x548e, 0x56fa, 0x5783, 0x5777, 0x576a,
+ 0x5769, 0x5761, 0x5766, 0x5764, 0x577c, 0x591c, 0x5949, 0x5947,
+ 0x5948, 0x5944, 0x5954, 0x59be, 0x59bb, 0x59d4, 0x59b9, 0x59ae,
+ 0x59d1, 0x59c6, 0x59d0, 0x59cd, 0x59cb, 0x59d3, 0x59ca, 0x59af,
+ 0x59b3, 0x59d2, 0x59c5, 0x5b5f, 0x5b64, 0x5b63, 0x5b97, 0x5b9a,
+ 0x5b98, 0x5b9c, 0x5b99, 0x5b9b, 0x5c1a, 0x5c48, 0x5c45, 0x5c46,
+ 0x5cb7, 0x5ca1, 0x5cb8, 0x5ca9, 0x5cab, 0x5cb1, 0x5cb3, 0x5e18,
+ 0x5e1a, 0x5e16, 0x5e15, 0x5e1b, 0x5e11, 0x5e78, 0x5e9a, 0x5e97,
+ 0x5e9c, 0x5e95, 0x5e96, 0x5ef6, 0x5f26, 0x5f27, 0x5f29, 0x5f80,
+ 0x5f81, 0x5f7f, 0x5f7c, 0x5fdd, 0x5fe0, 0x5ffd, 0x5ff5, 0x5fff,
+ 0x600f, 0x6014, 0x602f, 0x6035, 0x6016, 0x602a, 0x6015, 0x6021,
+ 0x6027, 0x6029, 0x602b, 0x601b, 0x6216, 0x6215, 0x623f, 0x623e,
+ 0x6240, 0x627f, 0x62c9, 0x62cc, 0x62c4, 0x62bf, 0x62c2, 0x62b9,
+ 0x62d2, 0x62db, 0x62ab, 0x62d3, 0x62d4, 0x62cb, 0x62c8, 0x62a8,
+ 0x62bd, 0x62bc, 0x62d0, 0x62d9, 0x62c7, 0x62cd, 0x62b5, 0x62da,
+ 0x62b1, 0x62d8, 0x62d6, 0x62d7, 0x62c6, 0x62ac, 0x62ce, 0x653e,
+ 0x65a7, 0x65bc, 0x65fa, 0x6614, 0x6613, 0x660c, 0x6606, 0x6602,
+ 0x660e, 0x6600, 0x660f, 0x6615, 0x660a,
+ /* 0xaa */
+ 0x6607, 0x670d, 0x670b, 0x676d, 0x678b, 0x6795, 0x6771, 0x679c,
+ 0x6773, 0x6777, 0x6787, 0x679d, 0x6797, 0x676f, 0x6770, 0x677f,
+ 0x6789, 0x677e, 0x6790, 0x6775, 0x679a, 0x6793, 0x677c, 0x676a,
+ 0x6772, 0x6b23, 0x6b66, 0x6b67, 0x6b7f, 0x6c13, 0x6c1b, 0x6ce3,
+ 0x6ce8, 0x6cf3, 0x6cb1, 0x6ccc, 0x6ce5, 0x6cb3, 0x6cbd, 0x6cbe,
+ 0x6cbc, 0x6ce2, 0x6cab, 0x6cd5, 0x6cd3, 0x6cb8, 0x6cc4, 0x6cb9,
+ 0x6cc1, 0x6cae, 0x6cd7, 0x6cc5, 0x6cf1, 0x6cbf, 0x6cbb, 0x6ce1,
+ 0x6cdb, 0x6cca, 0x6cac, 0x6cef, 0x6cdc, 0x6cd6, 0x6ce0, 0x7095,
+ 0x708e, 0x7092, 0x708a, 0x7099, 0x722c, 0x722d, 0x7238, 0x7248,
+ 0x7267, 0x7269, 0x72c0, 0x72ce, 0x72d9, 0x72d7, 0x72d0, 0x73a9,
+ 0x73a8, 0x739f, 0x73ab, 0x73a5, 0x753d, 0x759d, 0x7599, 0x759a,
+ 0x7684, 0x76c2, 0x76f2, 0x76f4, 0x77e5, 0x77fd, 0x793e, 0x7940,
+ 0x7941, 0x79c9, 0x79c8, 0x7a7a, 0x7a79, 0x7afa, 0x7cfe, 0x7f54,
+ 0x7f8c, 0x7f8b, 0x8005, 0x80ba, 0x80a5, 0x80a2, 0x80b1, 0x80a1,
+ 0x80ab, 0x80a9, 0x80b4, 0x80aa, 0x80af, 0x81e5, 0x81fe, 0x820d,
+ 0x82b3, 0x829d, 0x8299, 0x82ad, 0x82bd, 0x829f, 0x82b9, 0x82b1,
+ 0x82ac, 0x82a5, 0x82af, 0x82b8, 0x82a3, 0x82b0, 0x82be, 0x82b7,
+ 0x864e, 0x8671, 0x521d, 0x8868, 0x8ecb, 0x8fce, 0x8fd4, 0x8fd1,
+ 0x90b5, 0x90b8, 0x90b1, 0x90b6, 0x91c7, 0x91d1, 0x9577, 0x9580,
+ 0x961c, 0x9640, 0x963f, 0x963b, 0x9644,
+ /* 0xab */
+ 0x9642, 0x96b9, 0x96e8, 0x9752, 0x975e, 0x4e9f, 0x4ead, 0x4eae,
+ 0x4fe1, 0x4fb5, 0x4faf, 0x4fbf, 0x4fe0, 0x4fd1, 0x4fcf, 0x4fdd,
+ 0x4fc3, 0x4fb6, 0x4fd8, 0x4fdf, 0x4fca, 0x4fd7, 0x4fae, 0x4fd0,
+ 0x4fc4, 0x4fc2, 0x4fda, 0x4fce, 0x4fde, 0x4fb7, 0x5157, 0x5192,
+ 0x5191, 0x51a0, 0x524e, 0x5243, 0x524a, 0x524d, 0x524c, 0x524b,
+ 0x5247, 0x52c7, 0x52c9, 0x52c3, 0x52c1, 0x530d, 0x5357, 0x537b,
+ 0x539a, 0x53db, 0x54ac, 0x54c0, 0x54a8, 0x54ce, 0x54c9, 0x54b8,
+ 0x54a6, 0x54b3, 0x54c7, 0x54c2, 0x54bd, 0x54aa, 0x54c1, 0x54c4,
+ 0x54c8, 0x54af, 0x54ab, 0x54b1, 0x54bb, 0x54a9, 0x54a7, 0x54bf,
+ 0x56ff, 0x5782, 0x578b, 0x57a0, 0x57a3, 0x57a2, 0x57ce, 0x57ae,
+ 0x5793, 0x5955, 0x5951, 0x594f, 0x594e, 0x5950, 0x59dc, 0x59d8,
+ 0x59ff, 0x59e3, 0x59e8, 0x5a03, 0x59e5, 0x59ea, 0x59da, 0x59e6,
+ 0x5a01, 0x59fb, 0x5b69, 0x5ba3, 0x5ba6, 0x5ba4, 0x5ba2, 0x5ba5,
+ 0x5c01, 0x5c4e, 0x5c4f, 0x5c4d, 0x5c4b, 0x5cd9, 0x5cd2, 0x5df7,
+ 0x5e1d, 0x5e25, 0x5e1f, 0x5e7d, 0x5ea0, 0x5ea6, 0x5efa, 0x5f08,
+ 0x5f2d, 0x5f65, 0x5f88, 0x5f85, 0x5f8a, 0x5f8b, 0x5f87, 0x5f8c,
+ 0x5f89, 0x6012, 0x601d, 0x6020, 0x6025, 0x600e, 0x6028, 0x604d,
+ 0x6070, 0x6068, 0x6062, 0x6046, 0x6043, 0x606c, 0x606b, 0x606a,
+ 0x6064, 0x6241, 0x62dc, 0x6316, 0x6309, 0x62fc, 0x62ed, 0x6301,
+ 0x62ee, 0x62fd, 0x6307, 0x62f1, 0x62f7,
+ /* 0xac */
+ 0x62ef, 0x62ec, 0x62fe, 0x62f4, 0x6311, 0x6302, 0x653f, 0x6545,
+ 0x65ab, 0x65bd, 0x65e2, 0x6625, 0x662d, 0x6620, 0x6627, 0x662f,
+ 0x661f, 0x6628, 0x6631, 0x6624, 0x66f7, 0x67ff, 0x67d3, 0x67f1,
+ 0x67d4, 0x67d0, 0x67ec, 0x67b6, 0x67af, 0x67f5, 0x67e9, 0x67ef,
+ 0x67c4, 0x67d1, 0x67b4, 0x67da, 0x67e5, 0x67b8, 0x67cf, 0x67de,
+ 0x67f3, 0x67b0, 0x67d9, 0x67e2, 0x67dd, 0x67d2, 0x6b6a, 0x6b83,
+ 0x6b86, 0x6bb5, 0x6bd2, 0x6bd7, 0x6c1f, 0x6cc9, 0x6d0b, 0x6d32,
+ 0x6d2a, 0x6d41, 0x6d25, 0x6d0c, 0x6d31, 0x6d1e, 0x6d17, 0x6d3b,
+ 0x6d3d, 0x6d3e, 0x6d36, 0x6d1b, 0x6cf5, 0x6d39, 0x6d27, 0x6d38,
+ 0x6d29, 0x6d2e, 0x6d35, 0x6d0e, 0x6d2b, 0x70ab, 0x70ba, 0x70b3,
+ 0x70ac, 0x70af, 0x70ad, 0x70b8, 0x70ae, 0x70a4, 0x7230, 0x7272,
+ 0x726f, 0x7274, 0x72e9, 0x72e0, 0x72e1, 0x73b7, 0x73ca, 0x73bb,
+ 0x73b2, 0x73cd, 0x73c0, 0x73b3, 0x751a, 0x752d, 0x754f, 0x754c,
+ 0x754e, 0x754b, 0x75ab, 0x75a4, 0x75a5, 0x75a2, 0x75a3, 0x7678,
+ 0x7686, 0x7687, 0x7688, 0x76c8, 0x76c6, 0x76c3, 0x76c5, 0x7701,
+ 0x76f9, 0x76f8, 0x7709, 0x770b, 0x76fe, 0x76fc, 0x7707, 0x77dc,
+ 0x7802, 0x7814, 0x780c, 0x780d, 0x7946, 0x7949, 0x7948, 0x7947,
+ 0x79b9, 0x79ba, 0x79d1, 0x79d2, 0x79cb, 0x7a7f, 0x7a81, 0x7aff,
+ 0x7afd, 0x7c7d, 0x7d02, 0x7d05, 0x7d00, 0x7d09, 0x7d07, 0x7d04,
+ 0x7d06, 0x7f38, 0x7f8e, 0x7fbf, 0x8004,
+ /* 0xad */
+ 0x8010, 0x800d, 0x8011, 0x8036, 0x80d6, 0x80e5, 0x80da, 0x80c3,
+ 0x80c4, 0x80cc, 0x80e1, 0x80db, 0x80ce, 0x80de, 0x80e4, 0x80dd,
+ 0x81f4, 0x8222, 0x82e7, 0x8303, 0x8305, 0x82e3, 0x82db, 0x82e6,
+ 0x8304, 0x82e5, 0x8302, 0x8309, 0x82d2, 0x82d7, 0x82f1, 0x8301,
+ 0x82dc, 0x82d4, 0x82d1, 0x82de, 0x82d3, 0x82df, 0x82ef, 0x8306,
+ 0x8650, 0x8679, 0x867b, 0x867a, 0x884d, 0x886b, 0x8981, 0x89d4,
+ 0x8a08, 0x8a02, 0x8a03, 0x8c9e, 0x8ca0, 0x8d74, 0x8d73, 0x8db4,
+ 0x8ecd, 0x8ecc, 0x8ff0, 0x8fe6, 0x8fe2, 0x8fea, 0x8fe5, 0x8fed,
+ 0x8feb, 0x8fe4, 0x8fe8, 0x90ca, 0x90ce, 0x90c1, 0x90c3, 0x914b,
+ 0x914a, 0x91cd, 0x9582, 0x9650, 0x964b, 0x964c, 0x964d, 0x9762,
+ 0x9769, 0x97cb, 0x97ed, 0x97f3, 0x9801, 0x98a8, 0x98db, 0x98df,
+ 0x9996, 0x9999, 0x4e58, 0x4eb3, 0x500c, 0x500d, 0x5023, 0x4fef,
+ 0x5026, 0x5025, 0x4ff8, 0x5029, 0x5016, 0x5006, 0x503c, 0x501f,
+ 0x501a, 0x5012, 0x5011, 0x4ffa, 0x5000, 0x5014, 0x5028, 0x4ff1,
+ 0x5021, 0x500b, 0x5019, 0x5018, 0x4ff3, 0x4fee, 0x502d, 0x502a,
+ 0x4ffe, 0x502b, 0x5009, 0x517c, 0x51a4, 0x51a5, 0x51a2, 0x51cd,
+ 0x51cc, 0x51c6, 0x51cb, 0x5256, 0x525c, 0x5254, 0x525b, 0x525d,
+ 0x532a, 0x537f, 0x539f, 0x539d, 0x53df, 0x54e8, 0x5510, 0x5501,
+ 0x5537, 0x54fc, 0x54e5, 0x54f2, 0x5506, 0x54fa, 0x5514, 0x54e9,
+ 0x54ed, 0x54e1, 0x5509, 0x54ee, 0x54ea,
+ /* 0xae */
+ 0x54e6, 0x5527, 0x5507, 0x54fd, 0x550f, 0x5703, 0x5704, 0x57c2,
+ 0x57d4, 0x57cb, 0x57c3, 0x5809, 0x590f, 0x5957, 0x5958, 0x595a,
+ 0x5a11, 0x5a18, 0x5a1c, 0x5a1f, 0x5a1b, 0x5a13, 0x59ec, 0x5a20,
+ 0x5a23, 0x5a29, 0x5a25, 0x5a0c, 0x5a09, 0x5b6b, 0x5c58, 0x5bb0,
+ 0x5bb3, 0x5bb6, 0x5bb4, 0x5bae, 0x5bb5, 0x5bb9, 0x5bb8, 0x5c04,
+ 0x5c51, 0x5c55, 0x5c50, 0x5ced, 0x5cfd, 0x5cfb, 0x5cea, 0x5ce8,
+ 0x5cf0, 0x5cf6, 0x5d01, 0x5cf4, 0x5dee, 0x5e2d, 0x5e2b, 0x5eab,
+ 0x5ead, 0x5ea7, 0x5f31, 0x5f92, 0x5f91, 0x5f90, 0x6059, 0x6063,
+ 0x6065, 0x6050, 0x6055, 0x606d, 0x6069, 0x606f, 0x6084, 0x609f,
+ 0x609a, 0x608d, 0x6094, 0x608c, 0x6085, 0x6096, 0x6247, 0x62f3,
+ 0x6308, 0x62ff, 0x634e, 0x633e, 0x632f, 0x6355, 0x6342, 0x6346,
+ 0x634f, 0x6349, 0x633a, 0x6350, 0x633d, 0x632a, 0x632b, 0x6328,
+ 0x634d, 0x634c, 0x6548, 0x6549, 0x6599, 0x65c1, 0x65c5, 0x6642,
+ 0x6649, 0x664f, 0x6643, 0x6652, 0x664c, 0x6645, 0x6641, 0x66f8,
+ 0x6714, 0x6715, 0x6717, 0x6821, 0x6838, 0x6848, 0x6846, 0x6853,
+ 0x6839, 0x6842, 0x6854, 0x6829, 0x68b3, 0x6817, 0x684c, 0x6851,
+ 0x683d, 0x67f4, 0x6850, 0x6840, 0x683c, 0x6843, 0x682a, 0x6845,
+ 0x6813, 0x6818, 0x6841, 0x6b8a, 0x6b89, 0x6bb7, 0x6c23, 0x6c27,
+ 0x6c28, 0x6c26, 0x6c24, 0x6cf0, 0x6d6a, 0x6d95, 0x6d88, 0x6d87,
+ 0x6d66, 0x6d78, 0x6d77, 0x6d59, 0x6d93,
+ /* 0xaf */
+ 0x6d6c, 0x6d89, 0x6d6e, 0x6d5a, 0x6d74, 0x6d69, 0x6d8c, 0x6d8a,
+ 0x6d79, 0x6d85, 0x6d65, 0x6d94, 0x70ca, 0x70d8, 0x70e4, 0x70d9,
+ 0x70c8, 0x70cf, 0x7239, 0x7279, 0x72fc, 0x72f9, 0x72fd, 0x72f8,
+ 0x72f7, 0x7386, 0x73ed, 0x7409, 0x73ee, 0x73e0, 0x73ea, 0x73de,
+ 0x7554, 0x755d, 0x755c, 0x755a, 0x7559, 0x75be, 0x75c5, 0x75c7,
+ 0x75b2, 0x75b3, 0x75bd, 0x75bc, 0x75b9, 0x75c2, 0x75b8, 0x768b,
+ 0x76b0, 0x76ca, 0x76cd, 0x76ce, 0x7729, 0x771f, 0x7720, 0x7728,
+ 0x77e9, 0x7830, 0x7827, 0x7838, 0x781d, 0x7834, 0x7837, 0x7825,
+ 0x782d, 0x7820, 0x781f, 0x7832, 0x7955, 0x7950, 0x7960, 0x795f,
+ 0x7956, 0x795e, 0x795d, 0x7957, 0x795a, 0x79e4, 0x79e3, 0x79e7,
+ 0x79df, 0x79e6, 0x79e9, 0x79d8, 0x7a84, 0x7a88, 0x7ad9, 0x7b06,
+ 0x7b11, 0x7c89, 0x7d21, 0x7d17, 0x7d0b, 0x7d0a, 0x7d20, 0x7d22,
+ 0x7d14, 0x7d10, 0x7d15, 0x7d1a, 0x7d1c, 0x7d0d, 0x7d19, 0x7d1b,
+ 0x7f3a, 0x7f5f, 0x7f94, 0x7fc5, 0x7fc1, 0x8006, 0x8018, 0x8015,
+ 0x8019, 0x8017, 0x803d, 0x803f, 0x80f1, 0x8102, 0x80f0, 0x8105,
+ 0x80ed, 0x80f4, 0x8106, 0x80f8, 0x80f3, 0x8108, 0x80fd, 0x810a,
+ 0x80fc, 0x80ef, 0x81ed, 0x81ec, 0x8200, 0x8210, 0x822a, 0x822b,
+ 0x8228, 0x822c, 0x82bb, 0x832b, 0x8352, 0x8354, 0x834a, 0x8338,
+ 0x8350, 0x8349, 0x8335, 0x8334, 0x834f, 0x8332, 0x8339, 0x8336,
+ 0x8317, 0x8340, 0x8331, 0x8328, 0x8343,
+ /* 0xb0 */
+ 0x8654, 0x868a, 0x86aa, 0x8693, 0x86a4, 0x86a9, 0x868c, 0x86a3,
+ 0x869c, 0x8870, 0x8877, 0x8881, 0x8882, 0x887d, 0x8879, 0x8a18,
+ 0x8a10, 0x8a0e, 0x8a0c, 0x8a15, 0x8a0a, 0x8a17, 0x8a13, 0x8a16,
+ 0x8a0f, 0x8a11, 0x8c48, 0x8c7a, 0x8c79, 0x8ca1, 0x8ca2, 0x8d77,
+ 0x8eac, 0x8ed2, 0x8ed4, 0x8ecf, 0x8fb1, 0x9001, 0x9006, 0x8ff7,
+ 0x9000, 0x8ffa, 0x8ff4, 0x9003, 0x8ffd, 0x9005, 0x8ff8, 0x9095,
+ 0x90e1, 0x90dd, 0x90e2, 0x9152, 0x914d, 0x914c, 0x91d8, 0x91dd,
+ 0x91d7, 0x91dc, 0x91d9, 0x9583, 0x9662, 0x9663, 0x9661, 0x965b,
+ 0x965d, 0x9664, 0x9658, 0x965e, 0x96bb, 0x98e2, 0x99ac, 0x9aa8,
+ 0x9ad8, 0x9b25, 0x9b32, 0x9b3c, 0x4e7e, 0x507a, 0x507d, 0x505c,
+ 0x5047, 0x5043, 0x504c, 0x505a, 0x5049, 0x5065, 0x5076, 0x504e,
+ 0x5055, 0x5075, 0x5074, 0x5077, 0x504f, 0x500f, 0x506f, 0x506d,
+ 0x515c, 0x5195, 0x51f0, 0x526a, 0x526f, 0x52d2, 0x52d9, 0x52d8,
+ 0x52d5, 0x5310, 0x530f, 0x5319, 0x533f, 0x5340, 0x533e, 0x53c3,
+ 0x66fc, 0x5546, 0x556a, 0x5566, 0x5544, 0x555e, 0x5561, 0x5543,
+ 0x554a, 0x5531, 0x5556, 0x554f, 0x5555, 0x552f, 0x5564, 0x5538,
+ 0x552e, 0x555c, 0x552c, 0x5563, 0x5533, 0x5541, 0x5557, 0x5708,
+ 0x570b, 0x5709, 0x57df, 0x5805, 0x580a, 0x5806, 0x57e0, 0x57e4,
+ 0x57fa, 0x5802, 0x5835, 0x57f7, 0x57f9, 0x5920, 0x5962, 0x5a36,
+ 0x5a41, 0x5a49, 0x5a66, 0x5a6a, 0x5a40,
+ /* 0xb1 */
+ 0x5a3c, 0x5a62, 0x5a5a, 0x5a46, 0x5a4a, 0x5b70, 0x5bc7, 0x5bc5,
+ 0x5bc4, 0x5bc2, 0x5bbf, 0x5bc6, 0x5c09, 0x5c08, 0x5c07, 0x5c60,
+ 0x5c5c, 0x5c5d, 0x5d07, 0x5d06, 0x5d0e, 0x5d1b, 0x5d16, 0x5d22,
+ 0x5d11, 0x5d29, 0x5d14, 0x5d19, 0x5d24, 0x5d27, 0x5d17, 0x5de2,
+ 0x5e38, 0x5e36, 0x5e33, 0x5e37, 0x5eb7, 0x5eb8, 0x5eb6, 0x5eb5,
+ 0x5ebe, 0x5f35, 0x5f37, 0x5f57, 0x5f6c, 0x5f69, 0x5f6b, 0x5f97,
+ 0x5f99, 0x5f9e, 0x5f98, 0x5fa1, 0x5fa0, 0x5f9c, 0x607f, 0x60a3,
+ 0x6089, 0x60a0, 0x60a8, 0x60cb, 0x60b4, 0x60e6, 0x60bd, 0x60c5,
+ 0x60bb, 0x60b5, 0x60dc, 0x60bc, 0x60d8, 0x60d5, 0x60c6, 0x60df,
+ 0x60b8, 0x60da, 0x60c7, 0x621a, 0x621b, 0x6248, 0x63a0, 0x63a7,
+ 0x6372, 0x6396, 0x63a2, 0x63a5, 0x6377, 0x6367, 0x6398, 0x63aa,
+ 0x6371, 0x63a9, 0x6389, 0x6383, 0x639b, 0x636b, 0x63a8, 0x6384,
+ 0x6388, 0x6399, 0x63a1, 0x63ac, 0x6392, 0x638f, 0x6380, 0x637b,
+ 0x6369, 0x6368, 0x637a, 0x655d, 0x6556, 0x6551, 0x6559, 0x6557,
+ 0x555f, 0x654f, 0x6558, 0x6555, 0x6554, 0x659c, 0x659b, 0x65ac,
+ 0x65cf, 0x65cb, 0x65cc, 0x65ce, 0x665d, 0x665a, 0x6664, 0x6668,
+ 0x6666, 0x665e, 0x66f9, 0x52d7, 0x671b, 0x6881, 0x68af, 0x68a2,
+ 0x6893, 0x68b5, 0x687f, 0x6876, 0x68b1, 0x68a7, 0x6897, 0x68b0,
+ 0x6883, 0x68c4, 0x68ad, 0x6886, 0x6885, 0x6894, 0x689d, 0x68a8,
+ 0x689f, 0x68a1, 0x6882, 0x6b32, 0x6bba,
+ /* 0xb2 */
+ 0x6beb, 0x6bec, 0x6c2b, 0x6d8e, 0x6dbc, 0x6df3, 0x6dd9, 0x6db2,
+ 0x6de1, 0x6dcc, 0x6de4, 0x6dfb, 0x6dfa, 0x6e05, 0x6dc7, 0x6dcb,
+ 0x6daf, 0x6dd1, 0x6dae, 0x6dde, 0x6df9, 0x6db8, 0x6df7, 0x6df5,
+ 0x6dc5, 0x6dd2, 0x6e1a, 0x6db5, 0x6dda, 0x6deb, 0x6dd8, 0x6dea,
+ 0x6df1, 0x6dee, 0x6de8, 0x6dc6, 0x6dc4, 0x6daa, 0x6dec, 0x6dbf,
+ 0x6de6, 0x70f9, 0x7109, 0x710a, 0x70fd, 0x70ef, 0x723d, 0x727d,
+ 0x7281, 0x731c, 0x731b, 0x7316, 0x7313, 0x7319, 0x7387, 0x7405,
+ 0x740a, 0x7403, 0x7406, 0x73fe, 0x740d, 0x74e0, 0x74f6, 0x74f7,
+ 0x751c, 0x7522, 0x7565, 0x7566, 0x7562, 0x7570, 0x758f, 0x75d4,
+ 0x75d5, 0x75b5, 0x75ca, 0x75cd, 0x768e, 0x76d4, 0x76d2, 0x76db,
+ 0x7737, 0x773e, 0x773c, 0x7736, 0x7738, 0x773a, 0x786b, 0x7843,
+ 0x784e, 0x7965, 0x7968, 0x796d, 0x79fb, 0x7a92, 0x7a95, 0x7b20,
+ 0x7b28, 0x7b1b, 0x7b2c, 0x7b26, 0x7b19, 0x7b1e, 0x7b2e, 0x7c92,
+ 0x7c97, 0x7c95, 0x7d46, 0x7d43, 0x7d71, 0x7d2e, 0x7d39, 0x7d3c,
+ 0x7d40, 0x7d30, 0x7d33, 0x7d44, 0x7d2f, 0x7d42, 0x7d32, 0x7d31,
+ 0x7f3d, 0x7f9e, 0x7f9a, 0x7fcc, 0x7fce, 0x7fd2, 0x801c, 0x804a,
+ 0x8046, 0x812f, 0x8116, 0x8123, 0x812b, 0x8129, 0x8130, 0x8124,
+ 0x8202, 0x8235, 0x8237, 0x8236, 0x8239, 0x838e, 0x839e, 0x8398,
+ 0x8378, 0x83a2, 0x8396, 0x83bd, 0x83ab, 0x8392, 0x838a, 0x8393,
+ 0x8389, 0x83a0, 0x8377, 0x837b, 0x837c,
+ /* 0xb3 */
+ 0x8386, 0x83a7, 0x8655, 0x5f6a, 0x86c7, 0x86c0, 0x86b6, 0x86c4,
+ 0x86b5, 0x86c6, 0x86cb, 0x86b1, 0x86af, 0x86c9, 0x8853, 0x889e,
+ 0x8888, 0x88ab, 0x8892, 0x8896, 0x888d, 0x888b, 0x8993, 0x898f,
+ 0x8a2a, 0x8a1d, 0x8a23, 0x8a25, 0x8a31, 0x8a2d, 0x8a1f, 0x8a1b,
+ 0x8a22, 0x8c49, 0x8c5a, 0x8ca9, 0x8cac, 0x8cab, 0x8ca8, 0x8caa,
+ 0x8ca7, 0x8d67, 0x8d66, 0x8dbe, 0x8dba, 0x8edb, 0x8edf, 0x9019,
+ 0x900d, 0x901a, 0x9017, 0x9023, 0x901f, 0x901d, 0x9010, 0x9015,
+ 0x901e, 0x9020, 0x900f, 0x9022, 0x9016, 0x901b, 0x9014, 0x90e8,
+ 0x90ed, 0x90fd, 0x9157, 0x91ce, 0x91f5, 0x91e6, 0x91e3, 0x91e7,
+ 0x91ed, 0x91e9, 0x9589, 0x966a, 0x9675, 0x9673, 0x9678, 0x9670,
+ 0x9674, 0x9676, 0x9677, 0x966c, 0x96c0, 0x96ea, 0x96e9, 0x7ae0,
+ 0x7adf, 0x9802, 0x9803, 0x9b5a, 0x9ce5, 0x9e75, 0x9e7f, 0x9ea5,
+ 0x9ebb, 0x50a2, 0x508d, 0x5085, 0x5099, 0x5091, 0x5080, 0x5096,
+ 0x5098, 0x509a, 0x6700, 0x51f1, 0x5272, 0x5274, 0x5275, 0x5269,
+ 0x52de, 0x52dd, 0x52db, 0x535a, 0x53a5, 0x557b, 0x5580, 0x55a7,
+ 0x557c, 0x558a, 0x559d, 0x5598, 0x5582, 0x559c, 0x55aa, 0x5594,
+ 0x5587, 0x558b, 0x5583, 0x55b3, 0x55ae, 0x559f, 0x553e, 0x55b2,
+ 0x559a, 0x55bb, 0x55ac, 0x55b1, 0x557e, 0x5589, 0x55ab, 0x5599,
+ 0x570d, 0x582f, 0x582a, 0x5834, 0x5824, 0x5830, 0x5831, 0x5821,
+ 0x581d, 0x5820, 0x58f9, 0x58fa, 0x5960,
+ /* 0xb4 */
+ 0x5a77, 0x5a9a, 0x5a7f, 0x5a92, 0x5a9b, 0x5aa7, 0x5b73, 0x5b71,
+ 0x5bd2, 0x5bcc, 0x5bd3, 0x5bd0, 0x5c0a, 0x5c0b, 0x5c31, 0x5d4c,
+ 0x5d50, 0x5d34, 0x5d47, 0x5dfd, 0x5e45, 0x5e3d, 0x5e40, 0x5e43,
+ 0x5e7e, 0x5eca, 0x5ec1, 0x5ec2, 0x5ec4, 0x5f3c, 0x5f6d, 0x5fa9,
+ 0x5faa, 0x5fa8, 0x60d1, 0x60e1, 0x60b2, 0x60b6, 0x60e0, 0x611c,
+ 0x6123, 0x60fa, 0x6115, 0x60f0, 0x60fb, 0x60f4, 0x6168, 0x60f1,
+ 0x610e, 0x60f6, 0x6109, 0x6100, 0x6112, 0x621f, 0x6249, 0x63a3,
+ 0x638c, 0x63cf, 0x63c0, 0x63e9, 0x63c9, 0x63c6, 0x63cd, 0x63d2,
+ 0x63e3, 0x63d0, 0x63e1, 0x63d6, 0x63ed, 0x63ee, 0x6376, 0x63f4,
+ 0x63ea, 0x63db, 0x6452, 0x63da, 0x63f9, 0x655e, 0x6566, 0x6562,
+ 0x6563, 0x6591, 0x6590, 0x65af, 0x666e, 0x6670, 0x6674, 0x6676,
+ 0x666f, 0x6691, 0x667a, 0x667e, 0x6677, 0x66fe, 0x66ff, 0x671f,
+ 0x671d, 0x68fa, 0x68d5, 0x68e0, 0x68d8, 0x68d7, 0x6905, 0x68df,
+ 0x68f5, 0x68ee, 0x68e7, 0x68f9, 0x68d2, 0x68f2, 0x68e3, 0x68cb,
+ 0x68cd, 0x690d, 0x6912, 0x690e, 0x68c9, 0x68da, 0x696e, 0x68fb,
+ 0x6b3e, 0x6b3a, 0x6b3d, 0x6b98, 0x6b96, 0x6bbc, 0x6bef, 0x6c2e,
+ 0x6c2f, 0x6c2c, 0x6e2f, 0x6e38, 0x6e54, 0x6e21, 0x6e32, 0x6e67,
+ 0x6e4a, 0x6e20, 0x6e25, 0x6e23, 0x6e1b, 0x6e5b, 0x6e58, 0x6e24,
+ 0x6e56, 0x6e6e, 0x6e2d, 0x6e26, 0x6e6f, 0x6e34, 0x6e4d, 0x6e3a,
+ 0x6e2c, 0x6e43, 0x6e1d, 0x6e3e, 0x6ecb,
+ /* 0xb5 */
+ 0x6e89, 0x6e19, 0x6e4e, 0x6e63, 0x6e44, 0x6e72, 0x6e69, 0x6e5f,
+ 0x7119, 0x711a, 0x7126, 0x7130, 0x7121, 0x7136, 0x716e, 0x711c,
+ 0x724c, 0x7284, 0x7280, 0x7336, 0x7325, 0x7334, 0x7329, 0x743a,
+ 0x742a, 0x7433, 0x7422, 0x7425, 0x7435, 0x7436, 0x7434, 0x742f,
+ 0x741b, 0x7426, 0x7428, 0x7525, 0x7526, 0x756b, 0x756a, 0x75e2,
+ 0x75db, 0x75e3, 0x75d9, 0x75d8, 0x75de, 0x75e0, 0x767b, 0x767c,
+ 0x7696, 0x7693, 0x76b4, 0x76dc, 0x774f, 0x77ed, 0x785d, 0x786c,
+ 0x786f, 0x7a0d, 0x7a08, 0x7a0b, 0x7a05, 0x7a00, 0x7a98, 0x7a97,
+ 0x7a96, 0x7ae5, 0x7ae3, 0x7b49, 0x7b56, 0x7b46, 0x7b50, 0x7b52,
+ 0x7b54, 0x7b4d, 0x7b4b, 0x7b4f, 0x7b51, 0x7c9f, 0x7ca5, 0x7d5e,
+ 0x7d50, 0x7d68, 0x7d55, 0x7d2b, 0x7d6e, 0x7d72, 0x7d61, 0x7d66,
+ 0x7d62, 0x7d70, 0x7d73, 0x5584, 0x7fd4, 0x7fd5, 0x800b, 0x8052,
+ 0x8085, 0x8155, 0x8154, 0x814b, 0x8151, 0x814e, 0x8139, 0x8146,
+ 0x813e, 0x814c, 0x8153, 0x8174, 0x8212, 0x821c, 0x83e9, 0x8403,
+ 0x83f8, 0x840d, 0x83e0, 0x83c5, 0x840b, 0x83c1, 0x83ef, 0x83f1,
+ 0x83f4, 0x8457, 0x840a, 0x83f0, 0x840c, 0x83cc, 0x83fd, 0x83f2,
+ 0x83ca, 0x8438, 0x840e, 0x8404, 0x83dc, 0x8407, 0x83d4, 0x83df,
+ 0x865b, 0x86df, 0x86d9, 0x86ed, 0x86d4, 0x86db, 0x86e4, 0x86d0,
+ 0x86de, 0x8857, 0x88c1, 0x88c2, 0x88b1, 0x8983, 0x8996, 0x8a3b,
+ 0x8a60, 0x8a55, 0x8a5e, 0x8a3c, 0x8a41,
+ /* 0xb6 */
+ 0x8a54, 0x8a5b, 0x8a50, 0x8a46, 0x8a34, 0x8a3a, 0x8a36, 0x8a56,
+ 0x8c61, 0x8c82, 0x8caf, 0x8cbc, 0x8cb3, 0x8cbd, 0x8cc1, 0x8cbb,
+ 0x8cc0, 0x8cb4, 0x8cb7, 0x8cb6, 0x8cbf, 0x8cb8, 0x8d8a, 0x8d85,
+ 0x8d81, 0x8dce, 0x8ddd, 0x8dcb, 0x8dda, 0x8dd1, 0x8dcc, 0x8ddb,
+ 0x8dc6, 0x8efb, 0x8ef8, 0x8efc, 0x8f9c, 0x902e, 0x9035, 0x9031,
+ 0x9038, 0x9032, 0x9036, 0x9102, 0x90f5, 0x9109, 0x90fe, 0x9163,
+ 0x9165, 0x91cf, 0x9214, 0x9215, 0x9223, 0x9209, 0x921e, 0x920d,
+ 0x9210, 0x9207, 0x9211, 0x9594, 0x958f, 0x958b, 0x9591, 0x9593,
+ 0x9592, 0x958e, 0x968a, 0x968e, 0x968b, 0x967d, 0x9685, 0x9686,
+ 0x968d, 0x9672, 0x9684, 0x96c1, 0x96c5, 0x96c4, 0x96c6, 0x96c7,
+ 0x96ef, 0x96f2, 0x97cc, 0x9805, 0x9806, 0x9808, 0x98e7, 0x98ea,
+ 0x98ef, 0x98e9, 0x98f2, 0x98ed, 0x99ae, 0x99ad, 0x9ec3, 0x9ecd,
+ 0x9ed1, 0x4e82, 0x50ad, 0x50b5, 0x50b2, 0x50b3, 0x50c5, 0x50be,
+ 0x50ac, 0x50b7, 0x50bb, 0x50af, 0x50c7, 0x527f, 0x5277, 0x527d,
+ 0x52df, 0x52e6, 0x52e4, 0x52e2, 0x52e3, 0x532f, 0x55df, 0x55e8,
+ 0x55d3, 0x55e6, 0x55ce, 0x55dc, 0x55c7, 0x55d1, 0x55e3, 0x55e4,
+ 0x55ef, 0x55da, 0x55e1, 0x55c5, 0x55c6, 0x55e5, 0x55c9, 0x5712,
+ 0x5713, 0x585e, 0x5851, 0x5858, 0x5857, 0x585a, 0x5854, 0x586b,
+ 0x584c, 0x586d, 0x584a, 0x5862, 0x5852, 0x584b, 0x5967, 0x5ac1,
+ 0x5ac9, 0x5acc, 0x5abe, 0x5abd, 0x5abc,
+ /* 0xb7 */
+ 0x5ab3, 0x5ac2, 0x5ab2, 0x5d69, 0x5d6f, 0x5e4c, 0x5e79, 0x5ec9,
+ 0x5ec8, 0x5f12, 0x5f59, 0x5fac, 0x5fae, 0x611a, 0x610f, 0x6148,
+ 0x611f, 0x60f3, 0x611b, 0x60f9, 0x6101, 0x6108, 0x614e, 0x614c,
+ 0x6144, 0x614d, 0x613e, 0x6134, 0x6127, 0x610d, 0x6106, 0x6137,
+ 0x6221, 0x6222, 0x6413, 0x643e, 0x641e, 0x642a, 0x642d, 0x643d,
+ 0x642c, 0x640f, 0x641c, 0x6414, 0x640d, 0x6436, 0x6416, 0x6417,
+ 0x6406, 0x656c, 0x659f, 0x65b0, 0x6697, 0x6689, 0x6687, 0x6688,
+ 0x6696, 0x6684, 0x6698, 0x668d, 0x6703, 0x6994, 0x696d, 0x695a,
+ 0x6977, 0x6960, 0x6954, 0x6975, 0x6930, 0x6982, 0x694a, 0x6968,
+ 0x696b, 0x695e, 0x6953, 0x6979, 0x6986, 0x695d, 0x6963, 0x695b,
+ 0x6b47, 0x6b72, 0x6bc0, 0x6bbf, 0x6bd3, 0x6bfd, 0x6ea2, 0x6eaf,
+ 0x6ed3, 0x6eb6, 0x6ec2, 0x6e90, 0x6e9d, 0x6ec7, 0x6ec5, 0x6ea5,
+ 0x6e98, 0x6ebc, 0x6eba, 0x6eab, 0x6ed1, 0x6e96, 0x6e9c, 0x6ec4,
+ 0x6ed4, 0x6eaa, 0x6ea7, 0x6eb4, 0x714e, 0x7159, 0x7169, 0x7164,
+ 0x7149, 0x7167, 0x715c, 0x716c, 0x7166, 0x714c, 0x7165, 0x715e,
+ 0x7146, 0x7168, 0x7156, 0x723a, 0x7252, 0x7337, 0x7345, 0x733f,
+ 0x733e, 0x746f, 0x745a, 0x7455, 0x745f, 0x745e, 0x7441, 0x743f,
+ 0x7459, 0x745b, 0x745c, 0x7576, 0x7578, 0x7600, 0x75f0, 0x7601,
+ 0x75f2, 0x75f1, 0x75fa, 0x75ff, 0x75f4, 0x75f3, 0x76de, 0x76df,
+ 0x775b, 0x776b, 0x7766, 0x775e, 0x7763,
+ /* 0xb8 */
+ 0x7779, 0x776a, 0x776c, 0x775c, 0x7765, 0x7768, 0x7762, 0x77ee,
+ 0x788e, 0x78b0, 0x7897, 0x7898, 0x788c, 0x7889, 0x787c, 0x7891,
+ 0x7893, 0x787f, 0x797a, 0x797f, 0x7981, 0x842c, 0x79bd, 0x7a1c,
+ 0x7a1a, 0x7a20, 0x7a14, 0x7a1f, 0x7a1e, 0x7a9f, 0x7aa0, 0x7b77,
+ 0x7bc0, 0x7b60, 0x7b6e, 0x7b67, 0x7cb1, 0x7cb3, 0x7cb5, 0x7d93,
+ 0x7d79, 0x7d91, 0x7d81, 0x7d8f, 0x7d5b, 0x7f6e, 0x7f69, 0x7f6a,
+ 0x7f72, 0x7fa9, 0x7fa8, 0x7fa4, 0x8056, 0x8058, 0x8086, 0x8084,
+ 0x8171, 0x8170, 0x8178, 0x8165, 0x816e, 0x8173, 0x816b, 0x8179,
+ 0x817a, 0x8166, 0x8205, 0x8247, 0x8482, 0x8477, 0x843d, 0x8431,
+ 0x8475, 0x8466, 0x846b, 0x8449, 0x846c, 0x845b, 0x843c, 0x8435,
+ 0x8461, 0x8463, 0x8469, 0x846d, 0x8446, 0x865e, 0x865c, 0x865f,
+ 0x86f9, 0x8713, 0x8708, 0x8707, 0x8700, 0x86fe, 0x86fb, 0x8702,
+ 0x8703, 0x8706, 0x870a, 0x8859, 0x88df, 0x88d4, 0x88d9, 0x88dc,
+ 0x88d8, 0x88dd, 0x88e1, 0x88ca, 0x88d5, 0x88d2, 0x899c, 0x89e3,
+ 0x8a6b, 0x8a72, 0x8a73, 0x8a66, 0x8a69, 0x8a70, 0x8a87, 0x8a7c,
+ 0x8a63, 0x8aa0, 0x8a71, 0x8a85, 0x8a6d, 0x8a62, 0x8a6e, 0x8a6c,
+ 0x8a79, 0x8a7b, 0x8a3e, 0x8a68, 0x8c62, 0x8c8a, 0x8c89, 0x8cca,
+ 0x8cc7, 0x8cc8, 0x8cc4, 0x8cb2, 0x8cc3, 0x8cc2, 0x8cc5, 0x8de1,
+ 0x8ddf, 0x8de8, 0x8def, 0x8df3, 0x8dfa, 0x8dea, 0x8de4, 0x8de6,
+ 0x8eb2, 0x8f03, 0x8f09, 0x8efe, 0x8f0a,
+ /* 0xb9 */
+ 0x8f9f, 0x8fb2, 0x904b, 0x904a, 0x9053, 0x9042, 0x9054, 0x903c,
+ 0x9055, 0x9050, 0x9047, 0x904f, 0x904e, 0x904d, 0x9051, 0x903e,
+ 0x9041, 0x9112, 0x9117, 0x916c, 0x916a, 0x9169, 0x91c9, 0x9237,
+ 0x9257, 0x9238, 0x923d, 0x9240, 0x923e, 0x925b, 0x924b, 0x9264,
+ 0x9251, 0x9234, 0x9249, 0x924d, 0x9245, 0x9239, 0x923f, 0x925a,
+ 0x9598, 0x9698, 0x9694, 0x9695, 0x96cd, 0x96cb, 0x96c9, 0x96ca,
+ 0x96f7, 0x96fb, 0x96f9, 0x96f6, 0x9756, 0x9774, 0x9776, 0x9810,
+ 0x9811, 0x9813, 0x980a, 0x9812, 0x980c, 0x98fc, 0x98f4, 0x98fd,
+ 0x98fe, 0x99b3, 0x99b1, 0x99b4, 0x9ae1, 0x9ce9, 0x9e82, 0x9f0e,
+ 0x9f13, 0x9f20, 0x50e7, 0x50ee, 0x50e5, 0x50d6, 0x50ed, 0x50da,
+ 0x50d5, 0x50cf, 0x50d1, 0x50f1, 0x50ce, 0x50e9, 0x5162, 0x51f3,
+ 0x5283, 0x5282, 0x5331, 0x53ad, 0x55fe, 0x5600, 0x561b, 0x5617,
+ 0x55fd, 0x5614, 0x5606, 0x5609, 0x560d, 0x560e, 0x55f7, 0x5616,
+ 0x561f, 0x5608, 0x5610, 0x55f6, 0x5718, 0x5716, 0x5875, 0x587e,
+ 0x5883, 0x5893, 0x588a, 0x5879, 0x5885, 0x587d, 0x58fd, 0x5925,
+ 0x5922, 0x5924, 0x596a, 0x5969, 0x5ae1, 0x5ae6, 0x5ae9, 0x5ad7,
+ 0x5ad6, 0x5ad8, 0x5ae3, 0x5b75, 0x5bde, 0x5be7, 0x5be1, 0x5be5,
+ 0x5be6, 0x5be8, 0x5be2, 0x5be4, 0x5bdf, 0x5c0d, 0x5c62, 0x5d84,
+ 0x5d87, 0x5e5b, 0x5e63, 0x5e55, 0x5e57, 0x5e54, 0x5ed3, 0x5ed6,
+ 0x5f0a, 0x5f46, 0x5f70, 0x5fb9, 0x6147,
+ /* 0xba */
+ 0x613f, 0x614b, 0x6177, 0x6162, 0x6163, 0x615f, 0x615a, 0x6158,
+ 0x6175, 0x622a, 0x6487, 0x6458, 0x6454, 0x64a4, 0x6478, 0x645f,
+ 0x647a, 0x6451, 0x6467, 0x6434, 0x646d, 0x647b, 0x6572, 0x65a1,
+ 0x65d7, 0x65d6, 0x66a2, 0x66a8, 0x669d, 0x699c, 0x69a8, 0x6995,
+ 0x69c1, 0x69ae, 0x69d3, 0x69cb, 0x699b, 0x69b7, 0x69bb, 0x69ab,
+ 0x69b4, 0x69d0, 0x69cd, 0x69ad, 0x69cc, 0x69a6, 0x69c3, 0x69a3,
+ 0x6b49, 0x6b4c, 0x6c33, 0x6f33, 0x6f14, 0x6efe, 0x6f13, 0x6ef4,
+ 0x6f29, 0x6f3e, 0x6f20, 0x6f2c, 0x6f0f, 0x6f02, 0x6f22, 0x6eff,
+ 0x6eef, 0x6f06, 0x6f31, 0x6f38, 0x6f32, 0x6f23, 0x6f15, 0x6f2b,
+ 0x6f2f, 0x6f88, 0x6f2a, 0x6eec, 0x6f01, 0x6ef2, 0x6ecc, 0x6ef7,
+ 0x7194, 0x7199, 0x717d, 0x718a, 0x7184, 0x7192, 0x723e, 0x7292,
+ 0x7296, 0x7344, 0x7350, 0x7464, 0x7463, 0x746a, 0x7470, 0x746d,
+ 0x7504, 0x7591, 0x7627, 0x760d, 0x760b, 0x7609, 0x7613, 0x76e1,
+ 0x76e3, 0x7784, 0x777d, 0x777f, 0x7761, 0x78c1, 0x789f, 0x78a7,
+ 0x78b3, 0x78a9, 0x78a3, 0x798e, 0x798f, 0x798d, 0x7a2e, 0x7a31,
+ 0x7aaa, 0x7aa9, 0x7aed, 0x7aef, 0x7ba1, 0x7b95, 0x7b8b, 0x7b75,
+ 0x7b97, 0x7b9d, 0x7b94, 0x7b8f, 0x7bb8, 0x7b87, 0x7b84, 0x7cb9,
+ 0x7cbd, 0x7cbe, 0x7dbb, 0x7db0, 0x7d9c, 0x7dbd, 0x7dbe, 0x7da0,
+ 0x7dca, 0x7db4, 0x7db2, 0x7db1, 0x7dba, 0x7da2, 0x7dbf, 0x7db5,
+ 0x7db8, 0x7dad, 0x7dd2, 0x7dc7, 0x7dac,
+ /* 0xbb */
+ 0x7f70, 0x7fe0, 0x7fe1, 0x7fdf, 0x805e, 0x805a, 0x8087, 0x8150,
+ 0x8180, 0x818f, 0x8188, 0x818a, 0x817f, 0x8182, 0x81e7, 0x81fa,
+ 0x8207, 0x8214, 0x821e, 0x824b, 0x84c9, 0x84bf, 0x84c6, 0x84c4,
+ 0x8499, 0x849e, 0x84b2, 0x849c, 0x84cb, 0x84b8, 0x84c0, 0x84d3,
+ 0x8490, 0x84bc, 0x84d1, 0x84ca, 0x873f, 0x871c, 0x873b, 0x8722,
+ 0x8725, 0x8734, 0x8718, 0x8755, 0x8737, 0x8729, 0x88f3, 0x8902,
+ 0x88f4, 0x88f9, 0x88f8, 0x88fd, 0x88e8, 0x891a, 0x88ef, 0x8aa6,
+ 0x8a8c, 0x8a9e, 0x8aa3, 0x8a8d, 0x8aa1, 0x8a93, 0x8aa4, 0x8aaa,
+ 0x8aa5, 0x8aa8, 0x8a98, 0x8a91, 0x8a9a, 0x8aa7, 0x8c6a, 0x8c8d,
+ 0x8c8c, 0x8cd3, 0x8cd1, 0x8cd2, 0x8d6b, 0x8d99, 0x8d95, 0x8dfc,
+ 0x8f14, 0x8f12, 0x8f15, 0x8f13, 0x8fa3, 0x9060, 0x9058, 0x905c,
+ 0x9063, 0x9059, 0x905e, 0x9062, 0x905d, 0x905b, 0x9119, 0x9118,
+ 0x911e, 0x9175, 0x9178, 0x9177, 0x9174, 0x9278, 0x9280, 0x9285,
+ 0x9298, 0x9296, 0x927b, 0x9293, 0x929c, 0x92a8, 0x927c, 0x9291,
+ 0x95a1, 0x95a8, 0x95a9, 0x95a3, 0x95a5, 0x95a4, 0x9699, 0x969c,
+ 0x969b, 0x96cc, 0x96d2, 0x9700, 0x977c, 0x9785, 0x97f6, 0x9817,
+ 0x9818, 0x98af, 0x98b1, 0x9903, 0x9905, 0x990c, 0x9909, 0x99c1,
+ 0x9aaf, 0x9ab0, 0x9ae6, 0x9b41, 0x9b42, 0x9cf4, 0x9cf6, 0x9cf3,
+ 0x9ebc, 0x9f3b, 0x9f4a, 0x5104, 0x5100, 0x50fb, 0x50f5, 0x50f9,
+ 0x5102, 0x5108, 0x5109, 0x5105, 0x51dc,
+ /* 0xbc */
+ 0x5287, 0x5288, 0x5289, 0x528d, 0x528a, 0x52f0, 0x53b2, 0x562e,
+ 0x563b, 0x5639, 0x5632, 0x563f, 0x5634, 0x5629, 0x5653, 0x564e,
+ 0x5657, 0x5674, 0x5636, 0x562f, 0x5630, 0x5880, 0x589f, 0x589e,
+ 0x58b3, 0x589c, 0x58ae, 0x58a9, 0x58a6, 0x596d, 0x5b09, 0x5afb,
+ 0x5b0b, 0x5af5, 0x5b0c, 0x5b08, 0x5bee, 0x5bec, 0x5be9, 0x5beb,
+ 0x5c64, 0x5c65, 0x5d9d, 0x5d94, 0x5e62, 0x5e5f, 0x5e61, 0x5ee2,
+ 0x5eda, 0x5edf, 0x5edd, 0x5ee3, 0x5ee0, 0x5f48, 0x5f71, 0x5fb7,
+ 0x5fb5, 0x6176, 0x6167, 0x616e, 0x615d, 0x6155, 0x6182, 0x617c,
+ 0x6170, 0x616b, 0x617e, 0x61a7, 0x6190, 0x61ab, 0x618e, 0x61ac,
+ 0x619a, 0x61a4, 0x6194, 0x61ae, 0x622e, 0x6469, 0x646f, 0x6479,
+ 0x649e, 0x64b2, 0x6488, 0x6490, 0x64b0, 0x64a5, 0x6493, 0x6495,
+ 0x64a9, 0x6492, 0x64ae, 0x64ad, 0x64ab, 0x649a, 0x64ac, 0x6499,
+ 0x64a2, 0x64b3, 0x6575, 0x6577, 0x6578, 0x66ae, 0x66ab, 0x66b4,
+ 0x66b1, 0x6a23, 0x6a1f, 0x69e8, 0x6a01, 0x6a1e, 0x6a19, 0x69fd,
+ 0x6a21, 0x6a13, 0x6a0a, 0x69f3, 0x6a02, 0x6a05, 0x69ed, 0x6a11,
+ 0x6b50, 0x6b4e, 0x6ba4, 0x6bc5, 0x6bc6, 0x6f3f, 0x6f7c, 0x6f84,
+ 0x6f51, 0x6f66, 0x6f54, 0x6f86, 0x6f6d, 0x6f5b, 0x6f78, 0x6f6e,
+ 0x6f8e, 0x6f7a, 0x6f70, 0x6f64, 0x6f97, 0x6f58, 0x6ed5, 0x6f6f,
+ 0x6f60, 0x6f5f, 0x719f, 0x71ac, 0x71b1, 0x71a8, 0x7256, 0x729b,
+ 0x734e, 0x7357, 0x7469, 0x748b, 0x7483,
+ /* 0xbd */
+ 0x747e, 0x7480, 0x757f, 0x7620, 0x7629, 0x761f, 0x7624, 0x7626,
+ 0x7621, 0x7622, 0x769a, 0x76ba, 0x76e4, 0x778e, 0x7787, 0x778c,
+ 0x7791, 0x778b, 0x78cb, 0x78c5, 0x78ba, 0x78ca, 0x78be, 0x78d5,
+ 0x78bc, 0x78d0, 0x7a3f, 0x7a3c, 0x7a40, 0x7a3d, 0x7a37, 0x7a3b,
+ 0x7aaf, 0x7aae, 0x7bad, 0x7bb1, 0x7bc4, 0x7bb4, 0x7bc6, 0x7bc7,
+ 0x7bc1, 0x7ba0, 0x7bcc, 0x7cca, 0x7de0, 0x7df4, 0x7def, 0x7dfb,
+ 0x7dd8, 0x7dec, 0x7ddd, 0x7de8, 0x7de3, 0x7dda, 0x7dde, 0x7de9,
+ 0x7d9e, 0x7dd9, 0x7df2, 0x7df9, 0x7f75, 0x7f77, 0x7faf, 0x7fe9,
+ 0x8026, 0x819b, 0x819c, 0x819d, 0x81a0, 0x819a, 0x8198, 0x8517,
+ 0x853d, 0x851a, 0x84ee, 0x852c, 0x852d, 0x8513, 0x8511, 0x8523,
+ 0x8521, 0x8514, 0x84ec, 0x8525, 0x84ff, 0x8506, 0x8782, 0x8774,
+ 0x8776, 0x8760, 0x8766, 0x8778, 0x8768, 0x8759, 0x8757, 0x874c,
+ 0x8753, 0x885b, 0x885d, 0x8910, 0x8907, 0x8912, 0x8913, 0x8915,
+ 0x890a, 0x8abc, 0x8ad2, 0x8ac7, 0x8ac4, 0x8a95, 0x8acb, 0x8af8,
+ 0x8ab2, 0x8ac9, 0x8ac2, 0x8abf, 0x8ab0, 0x8ad6, 0x8acd, 0x8ab6,
+ 0x8ab9, 0x8adb, 0x8c4c, 0x8c4e, 0x8c6c, 0x8ce0, 0x8cde, 0x8ce6,
+ 0x8ce4, 0x8cec, 0x8ced, 0x8ce2, 0x8ce3, 0x8cdc, 0x8cea, 0x8ce1,
+ 0x8d6d, 0x8d9f, 0x8da3, 0x8e2b, 0x8e10, 0x8e1d, 0x8e22, 0x8e0f,
+ 0x8e29, 0x8e1f, 0x8e21, 0x8e1e, 0x8eba, 0x8f1d, 0x8f1b, 0x8f1f,
+ 0x8f29, 0x8f26, 0x8f2a, 0x8f1c, 0x8f1e,
+ /* 0xbe */
+ 0x8f25, 0x9069, 0x906e, 0x9068, 0x906d, 0x9077, 0x9130, 0x912d,
+ 0x9127, 0x9131, 0x9187, 0x9189, 0x918b, 0x9183, 0x92c5, 0x92bb,
+ 0x92b7, 0x92ea, 0x92ac, 0x92e4, 0x92c1, 0x92b3, 0x92bc, 0x92d2,
+ 0x92c7, 0x92f0, 0x92b2, 0x95ad, 0x95b1, 0x9704, 0x9706, 0x9707,
+ 0x9709, 0x9760, 0x978d, 0x978b, 0x978f, 0x9821, 0x982b, 0x981c,
+ 0x98b3, 0x990a, 0x9913, 0x9912, 0x9918, 0x99dd, 0x99d0, 0x99df,
+ 0x99db, 0x99d1, 0x99d5, 0x99d2, 0x99d9, 0x9ab7, 0x9aee, 0x9aef,
+ 0x9b27, 0x9b45, 0x9b44, 0x9b77, 0x9b6f, 0x9d06, 0x9d09, 0x9d03,
+ 0x9ea9, 0x9ebe, 0x9ece, 0x58a8, 0x9f52, 0x5112, 0x5118, 0x5114,
+ 0x5110, 0x5115, 0x5180, 0x51aa, 0x51dd, 0x5291, 0x5293, 0x52f3,
+ 0x5659, 0x566b, 0x5679, 0x5669, 0x5664, 0x5678, 0x566a, 0x5668,
+ 0x5665, 0x5671, 0x566f, 0x566c, 0x5662, 0x5676, 0x58c1, 0x58be,
+ 0x58c7, 0x58c5, 0x596e, 0x5b1d, 0x5b34, 0x5b78, 0x5bf0, 0x5c0e,
+ 0x5f4a, 0x61b2, 0x6191, 0x61a9, 0x618a, 0x61cd, 0x61b6, 0x61be,
+ 0x61ca, 0x61c8, 0x6230, 0x64c5, 0x64c1, 0x64cb, 0x64bb, 0x64bc,
+ 0x64da, 0x64c4, 0x64c7, 0x64c2, 0x64cd, 0x64bf, 0x64d2, 0x64d4,
+ 0x64be, 0x6574, 0x66c6, 0x66c9, 0x66b9, 0x66c4, 0x66c7, 0x66b8,
+ 0x6a3d, 0x6a38, 0x6a3a, 0x6a59, 0x6a6b, 0x6a58, 0x6a39, 0x6a44,
+ 0x6a62, 0x6a61, 0x6a4b, 0x6a47, 0x6a35, 0x6a5f, 0x6a48, 0x6b59,
+ 0x6b77, 0x6c05, 0x6fc2, 0x6fb1, 0x6fa1,
+ /* 0xbf */
+ 0x6fc3, 0x6fa4, 0x6fc1, 0x6fa7, 0x6fb3, 0x6fc0, 0x6fb9, 0x6fb6,
+ 0x6fa6, 0x6fa0, 0x6fb4, 0x71be, 0x71c9, 0x71d0, 0x71d2, 0x71c8,
+ 0x71d5, 0x71b9, 0x71ce, 0x71d9, 0x71dc, 0x71c3, 0x71c4, 0x7368,
+ 0x749c, 0x74a3, 0x7498, 0x749f, 0x749e, 0x74e2, 0x750c, 0x750d,
+ 0x7634, 0x7638, 0x763a, 0x76e7, 0x76e5, 0x77a0, 0x779e, 0x779f,
+ 0x77a5, 0x78e8, 0x78da, 0x78ec, 0x78e7, 0x79a6, 0x7a4d, 0x7a4e,
+ 0x7a46, 0x7a4c, 0x7a4b, 0x7aba, 0x7bd9, 0x7c11, 0x7bc9, 0x7be4,
+ 0x7bdb, 0x7be1, 0x7be9, 0x7be6, 0x7cd5, 0x7cd6, 0x7e0a, 0x7e11,
+ 0x7e08, 0x7e1b, 0x7e23, 0x7e1e, 0x7e1d, 0x7e09, 0x7e10, 0x7f79,
+ 0x7fb2, 0x7ff0, 0x7ff1, 0x7fee, 0x8028, 0x81b3, 0x81a9, 0x81a8,
+ 0x81fb, 0x8208, 0x8258, 0x8259, 0x854a, 0x8559, 0x8548, 0x8568,
+ 0x8569, 0x8543, 0x8549, 0x856d, 0x856a, 0x855e, 0x8783, 0x879f,
+ 0x879e, 0x87a2, 0x878d, 0x8861, 0x892a, 0x8932, 0x8925, 0x892b,
+ 0x8921, 0x89aa, 0x89a6, 0x8ae6, 0x8afa, 0x8aeb, 0x8af1, 0x8b00,
+ 0x8adc, 0x8ae7, 0x8aee, 0x8afe, 0x8b01, 0x8b02, 0x8af7, 0x8aed,
+ 0x8af3, 0x8af6, 0x8afc, 0x8c6b, 0x8c6d, 0x8c93, 0x8cf4, 0x8e44,
+ 0x8e31, 0x8e34, 0x8e42, 0x8e39, 0x8e35, 0x8f3b, 0x8f2f, 0x8f38,
+ 0x8f33, 0x8fa8, 0x8fa6, 0x9075, 0x9074, 0x9078, 0x9072, 0x907c,
+ 0x907a, 0x9134, 0x9192, 0x9320, 0x9336, 0x92f8, 0x9333, 0x932f,
+ 0x9322, 0x92fc, 0x932b, 0x9304, 0x931a,
+ /* 0xc0 */
+ 0x9310, 0x9326, 0x9321, 0x9315, 0x932e, 0x9319, 0x95bb, 0x96a7,
+ 0x96a8, 0x96aa, 0x96d5, 0x970e, 0x9711, 0x9716, 0x970d, 0x9713,
+ 0x970f, 0x975b, 0x975c, 0x9766, 0x9798, 0x9830, 0x9838, 0x983b,
+ 0x9837, 0x982d, 0x9839, 0x9824, 0x9910, 0x9928, 0x991e, 0x991b,
+ 0x9921, 0x991a, 0x99ed, 0x99e2, 0x99f1, 0x9ab8, 0x9abc, 0x9afb,
+ 0x9aed, 0x9b28, 0x9b91, 0x9d15, 0x9d23, 0x9d26, 0x9d28, 0x9d12,
+ 0x9d1b, 0x9ed8, 0x9ed4, 0x9f8d, 0x9f9c, 0x512a, 0x511f, 0x5121,
+ 0x5132, 0x52f5, 0x568e, 0x5680, 0x5690, 0x5685, 0x5687, 0x568f,
+ 0x58d5, 0x58d3, 0x58d1, 0x58ce, 0x5b30, 0x5b2a, 0x5b24, 0x5b7a,
+ 0x5c37, 0x5c68, 0x5dbc, 0x5dba, 0x5dbd, 0x5db8, 0x5e6b, 0x5f4c,
+ 0x5fbd, 0x61c9, 0x61c2, 0x61c7, 0x61e6, 0x61cb, 0x6232, 0x6234,
+ 0x64ce, 0x64ca, 0x64d8, 0x64e0, 0x64f0, 0x64e6, 0x64ec, 0x64f1,
+ 0x64e2, 0x64ed, 0x6582, 0x6583, 0x66d9, 0x66d6, 0x6a80, 0x6a94,
+ 0x6a84, 0x6aa2, 0x6a9c, 0x6adb, 0x6aa3, 0x6a7e, 0x6a97, 0x6a90,
+ 0x6aa0, 0x6b5c, 0x6bae, 0x6bda, 0x6c08, 0x6fd8, 0x6ff1, 0x6fdf,
+ 0x6fe0, 0x6fdb, 0x6fe4, 0x6feb, 0x6fef, 0x6f80, 0x6fec, 0x6fe1,
+ 0x6fe9, 0x6fd5, 0x6fee, 0x6ff0, 0x71e7, 0x71df, 0x71ee, 0x71e6,
+ 0x71e5, 0x71ed, 0x71ec, 0x71f4, 0x71e0, 0x7235, 0x7246, 0x7370,
+ 0x7372, 0x74a9, 0x74b0, 0x74a6, 0x74a8, 0x7646, 0x7642, 0x764c,
+ 0x76ea, 0x77b3, 0x77aa, 0x77b0, 0x77ac,
+ /* 0xc1 */
+ 0x77a7, 0x77ad, 0x77ef, 0x78f7, 0x78fa, 0x78f4, 0x78ef, 0x7901,
+ 0x79a7, 0x79aa, 0x7a57, 0x7abf, 0x7c07, 0x7c0d, 0x7bfe, 0x7bf7,
+ 0x7c0c, 0x7be0, 0x7ce0, 0x7cdc, 0x7cde, 0x7ce2, 0x7cdf, 0x7cd9,
+ 0x7cdd, 0x7e2e, 0x7e3e, 0x7e46, 0x7e37, 0x7e32, 0x7e43, 0x7e2b,
+ 0x7e3d, 0x7e31, 0x7e45, 0x7e41, 0x7e34, 0x7e39, 0x7e48, 0x7e35,
+ 0x7e3f, 0x7e2f, 0x7f44, 0x7ff3, 0x7ffc, 0x8071, 0x8072, 0x8070,
+ 0x806f, 0x8073, 0x81c6, 0x81c3, 0x81ba, 0x81c2, 0x81c0, 0x81bf,
+ 0x81bd, 0x81c9, 0x81be, 0x81e8, 0x8209, 0x8271, 0x85aa, 0x8584,
+ 0x857e, 0x859c, 0x8591, 0x8594, 0x85af, 0x859b, 0x8587, 0x85a8,
+ 0x858a, 0x8667, 0x87c0, 0x87d1, 0x87b3, 0x87d2, 0x87c6, 0x87ab,
+ 0x87bb, 0x87ba, 0x87c8, 0x87cb, 0x893b, 0x8936, 0x8944, 0x8938,
+ 0x893d, 0x89ac, 0x8b0e, 0x8b17, 0x8b19, 0x8b1b, 0x8b0a, 0x8b20,
+ 0x8b1d, 0x8b04, 0x8b10, 0x8c41, 0x8c3f, 0x8c73, 0x8cfa, 0x8cfd,
+ 0x8cfc, 0x8cf8, 0x8cfb, 0x8da8, 0x8e49, 0x8e4b, 0x8e48, 0x8e4a,
+ 0x8f44, 0x8f3e, 0x8f42, 0x8f45, 0x8f3f, 0x907f, 0x907d, 0x9084,
+ 0x9081, 0x9082, 0x9080, 0x9139, 0x91a3, 0x919e, 0x919c, 0x934d,
+ 0x9382, 0x9328, 0x9375, 0x934a, 0x9365, 0x934b, 0x9318, 0x937e,
+ 0x936c, 0x935b, 0x9370, 0x935a, 0x9354, 0x95ca, 0x95cb, 0x95cc,
+ 0x95c8, 0x95c6, 0x96b1, 0x96b8, 0x96d6, 0x971c, 0x971e, 0x97a0,
+ 0x97d3, 0x9846, 0x98b6, 0x9935, 0x9a01,
+ /* 0xc2 */
+ 0x99ff, 0x9bae, 0x9bab, 0x9baa, 0x9bad, 0x9d3b, 0x9d3f, 0x9e8b,
+ 0x9ecf, 0x9ede, 0x9edc, 0x9edd, 0x9edb, 0x9f3e, 0x9f4b, 0x53e2,
+ 0x5695, 0x56ae, 0x58d9, 0x58d8, 0x5b38, 0x5f5d, 0x61e3, 0x6233,
+ 0x64f4, 0x64f2, 0x64fe, 0x6506, 0x64fa, 0x64fb, 0x64f7, 0x65b7,
+ 0x66dc, 0x6726, 0x6ab3, 0x6aac, 0x6ac3, 0x6abb, 0x6ab8, 0x6ac2,
+ 0x6aae, 0x6aaf, 0x6b5f, 0x6b78, 0x6baf, 0x7009, 0x700b, 0x6ffe,
+ 0x7006, 0x6ffa, 0x7011, 0x700f, 0x71fb, 0x71fc, 0x71fe, 0x71f8,
+ 0x7377, 0x7375, 0x74a7, 0x74bf, 0x7515, 0x7656, 0x7658, 0x7652,
+ 0x77bd, 0x77bf, 0x77bb, 0x77bc, 0x790e, 0x79ae, 0x7a61, 0x7a62,
+ 0x7a60, 0x7ac4, 0x7ac5, 0x7c2b, 0x7c27, 0x7c2a, 0x7c1e, 0x7c23,
+ 0x7c21, 0x7ce7, 0x7e54, 0x7e55, 0x7e5e, 0x7e5a, 0x7e61, 0x7e52,
+ 0x7e59, 0x7f48, 0x7ff9, 0x7ffb, 0x8077, 0x8076, 0x81cd, 0x81cf,
+ 0x820a, 0x85cf, 0x85a9, 0x85cd, 0x85d0, 0x85c9, 0x85b0, 0x85ba,
+ 0x85b9, 0x85a6, 0x87ef, 0x87ec, 0x87f2, 0x87e0, 0x8986, 0x89b2,
+ 0x89f4, 0x8b28, 0x8b39, 0x8b2c, 0x8b2b, 0x8c50, 0x8d05, 0x8e59,
+ 0x8e63, 0x8e66, 0x8e64, 0x8e5f, 0x8e55, 0x8ec0, 0x8f49, 0x8f4d,
+ 0x9087, 0x9083, 0x9088, 0x91ab, 0x91ac, 0x91d0, 0x9394, 0x938a,
+ 0x9396, 0x93a2, 0x93b3, 0x93ae, 0x93ac, 0x93b0, 0x9398, 0x939a,
+ 0x9397, 0x95d4, 0x95d6, 0x95d0, 0x95d5, 0x96e2, 0x96dc, 0x96d9,
+ 0x96db, 0x96de, 0x9724, 0x97a3, 0x97a6,
+ /* 0xc3 */
+ 0x97ad, 0x97f9, 0x984d, 0x984f, 0x984c, 0x984e, 0x9853, 0x98ba,
+ 0x993e, 0x993f, 0x993d, 0x992e, 0x99a5, 0x9a0e, 0x9ac1, 0x9b03,
+ 0x9b06, 0x9b4f, 0x9b4e, 0x9b4d, 0x9bca, 0x9bc9, 0x9bfd, 0x9bc8,
+ 0x9bc0, 0x9d51, 0x9d5d, 0x9d60, 0x9ee0, 0x9f15, 0x9f2c, 0x5133,
+ 0x56a5, 0x58de, 0x58df, 0x58e2, 0x5bf5, 0x9f90, 0x5eec, 0x61f2,
+ 0x61f7, 0x61f6, 0x61f5, 0x6500, 0x650f, 0x66e0, 0x66dd, 0x6ae5,
+ 0x6add, 0x6ada, 0x6ad3, 0x701b, 0x701f, 0x7028, 0x701a, 0x701d,
+ 0x7015, 0x7018, 0x7206, 0x720d, 0x7258, 0x72a2, 0x7378, 0x737a,
+ 0x74bd, 0x74ca, 0x74e3, 0x7587, 0x7586, 0x765f, 0x7661, 0x77c7,
+ 0x7919, 0x79b1, 0x7a6b, 0x7a69, 0x7c3e, 0x7c3f, 0x7c38, 0x7c3d,
+ 0x7c37, 0x7c40, 0x7e6b, 0x7e6d, 0x7e79, 0x7e69, 0x7e6a, 0x7f85,
+ 0x7e73, 0x7fb6, 0x7fb9, 0x7fb8, 0x81d8, 0x85e9, 0x85dd, 0x85ea,
+ 0x85d5, 0x85e4, 0x85e5, 0x85f7, 0x87fb, 0x8805, 0x880d, 0x87f9,
+ 0x87fe, 0x8960, 0x895f, 0x8956, 0x895e, 0x8b41, 0x8b5c, 0x8b58,
+ 0x8b49, 0x8b5a, 0x8b4e, 0x8b4f, 0x8b46, 0x8b59, 0x8d08, 0x8d0a,
+ 0x8e7c, 0x8e72, 0x8e87, 0x8e76, 0x8e6c, 0x8e7a, 0x8e74, 0x8f54,
+ 0x8f4e, 0x8fad, 0x908a, 0x908b, 0x91b1, 0x91ae, 0x93e1, 0x93d1,
+ 0x93df, 0x93c3, 0x93c8, 0x93dc, 0x93dd, 0x93d6, 0x93e2, 0x93cd,
+ 0x93d8, 0x93e4, 0x93d7, 0x93e8, 0x95dc, 0x96b4, 0x96e3, 0x972a,
+ 0x9727, 0x9761, 0x97dc, 0x97fb, 0x985e,
+ /* 0xc4 */
+ 0x9858, 0x985b, 0x98bc, 0x9945, 0x9949, 0x9a16, 0x9a19, 0x9b0d,
+ 0x9be8, 0x9be7, 0x9bd6, 0x9bdb, 0x9d89, 0x9d61, 0x9d72, 0x9d6a,
+ 0x9d6c, 0x9e92, 0x9e97, 0x9e93, 0x9eb4, 0x52f8, 0x56a8, 0x56b7,
+ 0x56b6, 0x56b4, 0x56bc, 0x58e4, 0x5b40, 0x5b43, 0x5b7d, 0x5bf6,
+ 0x5dc9, 0x61f8, 0x61fa, 0x6518, 0x6514, 0x6519, 0x66e6, 0x6727,
+ 0x6aec, 0x703e, 0x7030, 0x7032, 0x7210, 0x737b, 0x74cf, 0x7662,
+ 0x7665, 0x7926, 0x792a, 0x792c, 0x792b, 0x7ac7, 0x7af6, 0x7c4c,
+ 0x7c43, 0x7c4d, 0x7cef, 0x7cf0, 0x8fae, 0x7e7d, 0x7e7c, 0x7e82,
+ 0x7f4c, 0x8000, 0x81da, 0x8266, 0x85fb, 0x85f9, 0x8611, 0x85fa,
+ 0x8606, 0x860b, 0x8607, 0x860a, 0x8814, 0x8815, 0x8964, 0x89ba,
+ 0x89f8, 0x8b70, 0x8b6c, 0x8b66, 0x8b6f, 0x8b5f, 0x8b6b, 0x8d0f,
+ 0x8d0d, 0x8e89, 0x8e81, 0x8e85, 0x8e82, 0x91b4, 0x91cb, 0x9418,
+ 0x9403, 0x93fd, 0x95e1, 0x9730, 0x98c4, 0x9952, 0x9951, 0x99a8,
+ 0x9a2b, 0x9a30, 0x9a37, 0x9a35, 0x9c13, 0x9c0d, 0x9e79, 0x9eb5,
+ 0x9ee8, 0x9f2f, 0x9f5f, 0x9f63, 0x9f61, 0x5137, 0x5138, 0x56c1,
+ 0x56c0, 0x56c2, 0x5914, 0x5c6c, 0x5dcd, 0x61fc, 0x61fe, 0x651d,
+ 0x651c, 0x6595, 0x66e9, 0x6afb, 0x6b04, 0x6afa, 0x6bb2, 0x704c,
+ 0x721b, 0x72a7, 0x74d6, 0x74d4, 0x7669, 0x77d3, 0x7c50, 0x7e8f,
+ 0x7e8c, 0x7fbc, 0x8617, 0x862d, 0x861a, 0x8823, 0x8822, 0x8821,
+ 0x881f, 0x896a, 0x896c, 0x89bd, 0x8b74,
+ /* 0xc5 */
+ 0x8b77, 0x8b7d, 0x8d13, 0x8e8a, 0x8e8d, 0x8e8b, 0x8f5f, 0x8faf,
+ 0x91ba, 0x942e, 0x9433, 0x9435, 0x943a, 0x9438, 0x9432, 0x942b,
+ 0x95e2, 0x9738, 0x9739, 0x9732, 0x97ff, 0x9867, 0x9865, 0x9957,
+ 0x9a45, 0x9a43, 0x9a40, 0x9a3e, 0x9acf, 0x9b54, 0x9b51, 0x9c2d,
+ 0x9c25, 0x9daf, 0x9db4, 0x9dc2, 0x9db8, 0x9e9d, 0x9eef, 0x9f19,
+ 0x9f5c, 0x9f66, 0x9f67, 0x513c, 0x513b, 0x56c8, 0x56ca, 0x56c9,
+ 0x5b7f, 0x5dd4, 0x5dd2, 0x5f4e, 0x61ff, 0x6524, 0x6b0a, 0x6b61,
+ 0x7051, 0x7058, 0x7380, 0x74e4, 0x758a, 0x766e, 0x766c, 0x79b3,
+ 0x7c60, 0x7c5f, 0x807e, 0x807d, 0x81df, 0x8972, 0x896f, 0x89fc,
+ 0x8b80, 0x8d16, 0x8d17, 0x8e91, 0x8e93, 0x8f61, 0x9148, 0x9444,
+ 0x9451, 0x9452, 0x973d, 0x973e, 0x97c3, 0x97c1, 0x986b, 0x9955,
+ 0x9a55, 0x9a4d, 0x9ad2, 0x9b1a, 0x9c49, 0x9c31, 0x9c3e, 0x9c3b,
+ 0x9dd3, 0x9dd7, 0x9f34, 0x9f6c, 0x9f6a, 0x9f94, 0x56cc, 0x5dd6,
+ 0x6200, 0x6523, 0x652b, 0x652a, 0x66ec, 0x6b10, 0x74da, 0x7aca,
+ 0x7c64, 0x7c63, 0x7c65, 0x7e93, 0x7e96, 0x7e94, 0x81e2, 0x8638,
+ 0x863f, 0x8831, 0x8b8a, 0x9090, 0x908f, 0x9463, 0x9460, 0x9464,
+ 0x9768, 0x986f, 0x995c, 0x9a5a, 0x9a5b, 0x9a57, 0x9ad3, 0x9ad4,
+ 0x9ad1, 0x9c54, 0x9c57, 0x9c56, 0x9de5, 0x9e9f, 0x9ef4, 0x56d1,
+ 0x58e9, 0x652c, 0x705e, 0x7671, 0x7672, 0x77d7, 0x7f50, 0x7f88,
+ 0x8836, 0x8839, 0x8862, 0x8b93, 0x8b92,
+ /* 0xc6 */
+ 0x8b96, 0x8277, 0x8d1b, 0x91c0, 0x946a, 0x9742, 0x9748, 0x9744,
+ 0x97c6, 0x9870, 0x9a5f, 0x9b22, 0x9b58, 0x9c5f, 0x9df9, 0x9dfa,
+ 0x9e7c, 0x9e7d, 0x9f07, 0x9f77, 0x9f72, 0x5ef3, 0x6b16, 0x7063,
+ 0x7c6c, 0x7c6e, 0x883b, 0x89c0, 0x8ea1, 0x91c1, 0x9472, 0x9470,
+ 0x9871, 0x995e, 0x9ad6, 0x9b23, 0x9ecc, 0x7064, 0x77da, 0x8b9a,
+ 0x9477, 0x97c9, 0x9a62, 0x9a65, 0x7e9c, 0x8b9c, 0x8eaa, 0x91c5,
+ 0x947d, 0x947e, 0x947c, 0x9c77, 0x9c78, 0x9ef7, 0x8c54, 0x947f,
+ 0x9e1a, 0x7228, 0x9a6a, 0x9b31, 0x9e1b, 0x9e1e, 0x7c72, 0x30fe,
+ 0x309d, 0x309e, 0x3005, 0x3041, 0x3042, 0x3043, 0x3044, 0x3045,
+ 0x3046, 0x3047, 0x3048, 0x3049, 0x304a, 0x304b, 0x304c, 0x304d,
+ 0x304e, 0x304f, 0x3050, 0x3051, 0x3052, 0x3053, 0x3054, 0x3055,
+ 0x3056, 0x3057, 0x3058, 0x3059, 0x305a, 0x305b, 0x305c, 0x305d,
+ 0x305e, 0x305f, 0x3060, 0x3061, 0x3062, 0x3063, 0x3064, 0x3065,
+ 0x3066, 0x3067, 0x3068, 0x3069, 0x306a, 0x306b, 0x306c, 0x306d,
+ 0x306e, 0x306f, 0x3070, 0x3071, 0x3072, 0x3073, 0x3074, 0x3075,
+ 0x3076, 0x3077, 0x3078, 0x3079, 0x307a, 0x307b, 0x307c, 0x307d,
+ 0x307e, 0x307f, 0x3080, 0x3081, 0x3082, 0x3083, 0x3084, 0x3085,
+ 0x3086, 0x3087, 0x3088, 0x3089, 0x308a, 0x308b, 0x308c, 0x308d,
+ 0x308e, 0x308f, 0x3090, 0x3091, 0x3092, 0x3093, 0x30a1, 0x30a2,
+ 0x30a3, 0x30a4, 0x30a5, 0x30a6, 0x30a7,
+ /* 0xc7 */
+ 0x30a8, 0x30a9, 0x30aa, 0x30ab, 0x30ac, 0x30ad, 0x30ae, 0x30af,
+ 0x30b0, 0x30b1, 0x30b2, 0x30b3, 0x30b4, 0x30b5, 0x30b6, 0x30b7,
+ 0x30b8, 0x30b9, 0x30ba, 0x30bb, 0x30bc, 0x30bd, 0x30be, 0x30bf,
+ 0x30c0, 0x30c1, 0x30c2, 0x30c3, 0x30c4, 0x30c5, 0x30c6, 0x30c7,
+ 0x30c8, 0x30c9, 0x30ca, 0x30cb, 0x30cc, 0x30cd, 0x30ce, 0x30cf,
+ 0x30d0, 0x30d1, 0x30d2, 0x30d3, 0x30d4, 0x30d5, 0x30d6, 0x30d7,
+ 0x30d8, 0x30d9, 0x30da, 0x30db, 0x30dc, 0x30dd, 0x30de, 0x30df,
+ 0x30e0, 0x30e1, 0x30e2, 0x30e3, 0x30e4, 0x30e5, 0x30e6, 0x30e7,
+ 0x30e8, 0x30e9, 0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ee, 0x30ef,
+ 0x30f0, 0x30f1, 0x30f2, 0x30f3, 0x30f4, 0x30f5, 0x30f6, 0x0414,
+ 0x0415, 0x0401, 0x0416, 0x0417, 0x0418, 0x0419, 0x041a, 0x041b,
+ 0x041c, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429,
+ 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, 0x0430, 0x0431,
+ 0x0432, 0x0433, 0x0434, 0x0435, 0x0451, 0x0436, 0x0437, 0x0438,
+ 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, 0x0440,
+ 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448,
+ 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, 0x2460,
+ 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, 0x2468,
+ 0x2469, 0x2474, 0x2475, 0x2476, 0x2477, 0x2478, 0x2479, 0x247a,
+ 0x247b, 0x247c, 0x247d,
+};
+static const unsigned short big5_2uni_pagec9[7652] = {
+ /* 0xc9 */
+ 0x4e42, 0x4e5c, 0x51f5, 0x531a, 0x5382, 0x4e07, 0x4e0c, 0x4e47,
+ 0x4e8d, 0x56d7, 0xfa0c, 0x5c6e, 0x5f73, 0x4e0f, 0x5187, 0x4e0e,
+ 0x4e2e, 0x4e93, 0x4ec2, 0x4ec9, 0x4ec8, 0x5198, 0x52fc, 0x536c,
+ 0x53b9, 0x5720, 0x5903, 0x592c, 0x5c10, 0x5dff, 0x65e1, 0x6bb3,
+ 0x6bcc, 0x6c14, 0x723f, 0x4e31, 0x4e3c, 0x4ee8, 0x4edc, 0x4ee9,
+ 0x4ee1, 0x4edd, 0x4eda, 0x520c, 0x531c, 0x534c, 0x5722, 0x5723,
+ 0x5917, 0x592f, 0x5b81, 0x5b84, 0x5c12, 0x5c3b, 0x5c74, 0x5c73,
+ 0x5e04, 0x5e80, 0x5e82, 0x5fc9, 0x6209, 0x6250, 0x6c15, 0x6c36,
+ 0x6c43, 0x6c3f, 0x6c3b, 0x72ae, 0x72b0, 0x738a, 0x79b8, 0x808a,
+ 0x961e, 0x4f0e, 0x4f18, 0x4f2c, 0x4ef5, 0x4f14, 0x4ef1, 0x4f00,
+ 0x4ef7, 0x4f08, 0x4f1d, 0x4f02, 0x4f05, 0x4f22, 0x4f13, 0x4f04,
+ 0x4ef4, 0x4f12, 0x51b1, 0x5213, 0x5209, 0x5210, 0x52a6, 0x5322,
+ 0x531f, 0x534d, 0x538a, 0x5407, 0x56e1, 0x56df, 0x572e, 0x572a,
+ 0x5734, 0x593c, 0x5980, 0x597c, 0x5985, 0x597b, 0x597e, 0x5977,
+ 0x597f, 0x5b56, 0x5c15, 0x5c25, 0x5c7c, 0x5c7a, 0x5c7b, 0x5c7e,
+ 0x5ddf, 0x5e75, 0x5e84, 0x5f02, 0x5f1a, 0x5f74, 0x5fd5, 0x5fd4,
+ 0x5fcf, 0x625c, 0x625e, 0x6264, 0x6261, 0x6266, 0x6262, 0x6259,
+ 0x6260, 0x625a, 0x6265, 0x65ef, 0x65ee, 0x673e, 0x6739, 0x6738,
+ 0x673b, 0x673a, 0x673f, 0x673c, 0x6733, 0x6c18, 0x6c46, 0x6c52,
+ 0x6c5c, 0x6c4f, 0x6c4a, 0x6c54, 0x6c4b,
+ /* 0xca */
+ 0x6c4c, 0x7071, 0x725e, 0x72b4, 0x72b5, 0x738e, 0x752a, 0x767f,
+ 0x7a75, 0x7f51, 0x8278, 0x827c, 0x8280, 0x827d, 0x827f, 0x864d,
+ 0x897e, 0x9099, 0x9097, 0x9098, 0x909b, 0x9094, 0x9622, 0x9624,
+ 0x9620, 0x9623, 0x4f56, 0x4f3b, 0x4f62, 0x4f49, 0x4f53, 0x4f64,
+ 0x4f3e, 0x4f67, 0x4f52, 0x4f5f, 0x4f41, 0x4f58, 0x4f2d, 0x4f33,
+ 0x4f3f, 0x4f61, 0x518f, 0x51b9, 0x521c, 0x521e, 0x5221, 0x52ad,
+ 0x52ae, 0x5309, 0x5363, 0x5372, 0x538e, 0x538f, 0x5430, 0x5437,
+ 0x542a, 0x5454, 0x5445, 0x5419, 0x541c, 0x5425, 0x5418, 0x543d,
+ 0x544f, 0x5441, 0x5428, 0x5424, 0x5447, 0x56ee, 0x56e7, 0x56e5,
+ 0x5741, 0x5745, 0x574c, 0x5749, 0x574b, 0x5752, 0x5906, 0x5940,
+ 0x59a6, 0x5998, 0x59a0, 0x5997, 0x598e, 0x59a2, 0x5990, 0x598f,
+ 0x59a7, 0x59a1, 0x5b8e, 0x5b92, 0x5c28, 0x5c2a, 0x5c8d, 0x5c8f,
+ 0x5c88, 0x5c8b, 0x5c89, 0x5c92, 0x5c8a, 0x5c86, 0x5c93, 0x5c95,
+ 0x5de0, 0x5e0a, 0x5e0e, 0x5e8b, 0x5e89, 0x5e8c, 0x5e88, 0x5e8d,
+ 0x5f05, 0x5f1d, 0x5f78, 0x5f76, 0x5fd2, 0x5fd1, 0x5fd0, 0x5fed,
+ 0x5fe8, 0x5fee, 0x5ff3, 0x5fe1, 0x5fe4, 0x5fe3, 0x5ffa, 0x5fef,
+ 0x5ff7, 0x5ffb, 0x6000, 0x5ff4, 0x623a, 0x6283, 0x628c, 0x628e,
+ 0x628f, 0x6294, 0x6287, 0x6271, 0x627b, 0x627a, 0x6270, 0x6281,
+ 0x6288, 0x6277, 0x627d, 0x6272, 0x6274, 0x6537, 0x65f0, 0x65f4,
+ 0x65f3, 0x65f2, 0x65f5, 0x6745, 0x6747,
+ /* 0xcb */
+ 0x6759, 0x6755, 0x674c, 0x6748, 0x675d, 0x674d, 0x675a, 0x674b,
+ 0x6bd0, 0x6c19, 0x6c1a, 0x6c78, 0x6c67, 0x6c6b, 0x6c84, 0x6c8b,
+ 0x6c8f, 0x6c71, 0x6c6f, 0x6c69, 0x6c9a, 0x6c6d, 0x6c87, 0x6c95,
+ 0x6c9c, 0x6c66, 0x6c73, 0x6c65, 0x6c7b, 0x6c8e, 0x7074, 0x707a,
+ 0x7263, 0x72bf, 0x72bd, 0x72c3, 0x72c6, 0x72c1, 0x72ba, 0x72c5,
+ 0x7395, 0x7397, 0x7393, 0x7394, 0x7392, 0x753a, 0x7539, 0x7594,
+ 0x7595, 0x7681, 0x793d, 0x8034, 0x8095, 0x8099, 0x8090, 0x8092,
+ 0x809c, 0x8290, 0x828f, 0x8285, 0x828e, 0x8291, 0x8293, 0x828a,
+ 0x8283, 0x8284, 0x8c78, 0x8fc9, 0x8fbf, 0x909f, 0x90a1, 0x90a5,
+ 0x909e, 0x90a7, 0x90a0, 0x9630, 0x9628, 0x962f, 0x962d, 0x4e33,
+ 0x4f98, 0x4f7c, 0x4f85, 0x4f7d, 0x4f80, 0x4f87, 0x4f76, 0x4f74,
+ 0x4f89, 0x4f84, 0x4f77, 0x4f4c, 0x4f97, 0x4f6a, 0x4f9a, 0x4f79,
+ 0x4f81, 0x4f78, 0x4f90, 0x4f9c, 0x4f94, 0x4f9e, 0x4f92, 0x4f82,
+ 0x4f95, 0x4f6b, 0x4f6e, 0x519e, 0x51bc, 0x51be, 0x5235, 0x5232,
+ 0x5233, 0x5246, 0x5231, 0x52bc, 0x530a, 0x530b, 0x533c, 0x5392,
+ 0x5394, 0x5487, 0x547f, 0x5481, 0x5491, 0x5482, 0x5488, 0x546b,
+ 0x547a, 0x547e, 0x5465, 0x546c, 0x5474, 0x5466, 0x548d, 0x546f,
+ 0x5461, 0x5460, 0x5498, 0x5463, 0x5467, 0x5464, 0x56f7, 0x56f9,
+ 0x576f, 0x5772, 0x576d, 0x576b, 0x5771, 0x5770, 0x5776, 0x5780,
+ 0x5775, 0x577b, 0x5773, 0x5774, 0x5762,
+ /* 0xcc */
+ 0x5768, 0x577d, 0x590c, 0x5945, 0x59b5, 0x59ba, 0x59cf, 0x59ce,
+ 0x59b2, 0x59cc, 0x59c1, 0x59b6, 0x59bc, 0x59c3, 0x59d6, 0x59b1,
+ 0x59bd, 0x59c0, 0x59c8, 0x59b4, 0x59c7, 0x5b62, 0x5b65, 0x5b93,
+ 0x5b95, 0x5c44, 0x5c47, 0x5cae, 0x5ca4, 0x5ca0, 0x5cb5, 0x5caf,
+ 0x5ca8, 0x5cac, 0x5c9f, 0x5ca3, 0x5cad, 0x5ca2, 0x5caa, 0x5ca7,
+ 0x5c9d, 0x5ca5, 0x5cb6, 0x5cb0, 0x5ca6, 0x5e17, 0x5e14, 0x5e19,
+ 0x5f28, 0x5f22, 0x5f23, 0x5f24, 0x5f54, 0x5f82, 0x5f7e, 0x5f7d,
+ 0x5fde, 0x5fe5, 0x602d, 0x6026, 0x6019, 0x6032, 0x600b, 0x6034,
+ 0x600a, 0x6017, 0x6033, 0x601a, 0x601e, 0x602c, 0x6022, 0x600d,
+ 0x6010, 0x602e, 0x6013, 0x6011, 0x600c, 0x6009, 0x601c, 0x6214,
+ 0x623d, 0x62ad, 0x62b4, 0x62d1, 0x62be, 0x62aa, 0x62b6, 0x62ca,
+ 0x62ae, 0x62b3, 0x62af, 0x62bb, 0x62a9, 0x62b0, 0x62b8, 0x653d,
+ 0x65a8, 0x65bb, 0x6609, 0x65fc, 0x6604, 0x6612, 0x6608, 0x65fb,
+ 0x6603, 0x660b, 0x660d, 0x6605, 0x65fd, 0x6611, 0x6610, 0x66f6,
+ 0x670a, 0x6785, 0x676c, 0x678e, 0x6792, 0x6776, 0x677b, 0x6798,
+ 0x6786, 0x6784, 0x6774, 0x678d, 0x678c, 0x677a, 0x679f, 0x6791,
+ 0x6799, 0x6783, 0x677d, 0x6781, 0x6778, 0x6779, 0x6794, 0x6b25,
+ 0x6b80, 0x6b7e, 0x6bde, 0x6c1d, 0x6c93, 0x6cec, 0x6ceb, 0x6cee,
+ 0x6cd9, 0x6cb6, 0x6cd4, 0x6cad, 0x6ce7, 0x6cb7, 0x6cd0, 0x6cc2,
+ 0x6cba, 0x6cc3, 0x6cc6, 0x6ced, 0x6cf2,
+ /* 0xcd */
+ 0x6cd2, 0x6cdd, 0x6cb4, 0x6c8a, 0x6c9d, 0x6c80, 0x6cde, 0x6cc0,
+ 0x6d30, 0x6ccd, 0x6cc7, 0x6cb0, 0x6cf9, 0x6ccf, 0x6ce9, 0x6cd1,
+ 0x7094, 0x7098, 0x7085, 0x7093, 0x7086, 0x7084, 0x7091, 0x7096,
+ 0x7082, 0x709a, 0x7083, 0x726a, 0x72d6, 0x72cb, 0x72d8, 0x72c9,
+ 0x72dc, 0x72d2, 0x72d4, 0x72da, 0x72cc, 0x72d1, 0x73a4, 0x73a1,
+ 0x73ad, 0x73a6, 0x73a2, 0x73a0, 0x73ac, 0x739d, 0x74dd, 0x74e8,
+ 0x753f, 0x7540, 0x753e, 0x758c, 0x7598, 0x76af, 0x76f3, 0x76f1,
+ 0x76f0, 0x76f5, 0x77f8, 0x77fc, 0x77f9, 0x77fb, 0x77fa, 0x77f7,
+ 0x7942, 0x793f, 0x79c5, 0x7a78, 0x7a7b, 0x7afb, 0x7c75, 0x7cfd,
+ 0x8035, 0x808f, 0x80ae, 0x80a3, 0x80b8, 0x80b5, 0x80ad, 0x8220,
+ 0x82a0, 0x82c0, 0x82ab, 0x829a, 0x8298, 0x829b, 0x82b5, 0x82a7,
+ 0x82ae, 0x82bc, 0x829e, 0x82ba, 0x82b4, 0x82a8, 0x82a1, 0x82a9,
+ 0x82c2, 0x82a4, 0x82c3, 0x82b6, 0x82a2, 0x8670, 0x866f, 0x866d,
+ 0x866e, 0x8c56, 0x8fd2, 0x8fcb, 0x8fd3, 0x8fcd, 0x8fd6, 0x8fd5,
+ 0x8fd7, 0x90b2, 0x90b4, 0x90af, 0x90b3, 0x90b0, 0x9639, 0x963d,
+ 0x963c, 0x963a, 0x9643, 0x4fcd, 0x4fc5, 0x4fd3, 0x4fb2, 0x4fc9,
+ 0x4fcb, 0x4fc1, 0x4fd4, 0x4fdc, 0x4fd9, 0x4fbb, 0x4fb3, 0x4fdb,
+ 0x4fc7, 0x4fd6, 0x4fba, 0x4fc0, 0x4fb9, 0x4fec, 0x5244, 0x5249,
+ 0x52c0, 0x52c2, 0x533d, 0x537c, 0x5397, 0x5396, 0x5399, 0x5398,
+ 0x54ba, 0x54a1, 0x54ad, 0x54a5, 0x54cf,
+ /* 0xce */
+ 0x54c3, 0x830d, 0x54b7, 0x54ae, 0x54d6, 0x54b6, 0x54c5, 0x54c6,
+ 0x54a0, 0x5470, 0x54bc, 0x54a2, 0x54be, 0x5472, 0x54de, 0x54b0,
+ 0x57b5, 0x579e, 0x579f, 0x57a4, 0x578c, 0x5797, 0x579d, 0x579b,
+ 0x5794, 0x5798, 0x578f, 0x5799, 0x57a5, 0x579a, 0x5795, 0x58f4,
+ 0x590d, 0x5953, 0x59e1, 0x59de, 0x59ee, 0x5a00, 0x59f1, 0x59dd,
+ 0x59fa, 0x59fd, 0x59fc, 0x59f6, 0x59e4, 0x59f2, 0x59f7, 0x59db,
+ 0x59e9, 0x59f3, 0x59f5, 0x59e0, 0x59fe, 0x59f4, 0x59ed, 0x5ba8,
+ 0x5c4c, 0x5cd0, 0x5cd8, 0x5ccc, 0x5cd7, 0x5ccb, 0x5cdb, 0x5cde,
+ 0x5cda, 0x5cc9, 0x5cc7, 0x5cca, 0x5cd6, 0x5cd3, 0x5cd4, 0x5ccf,
+ 0x5cc8, 0x5cc6, 0x5cce, 0x5cdf, 0x5cf8, 0x5df9, 0x5e21, 0x5e22,
+ 0x5e23, 0x5e20, 0x5e24, 0x5eb0, 0x5ea4, 0x5ea2, 0x5e9b, 0x5ea3,
+ 0x5ea5, 0x5f07, 0x5f2e, 0x5f56, 0x5f86, 0x6037, 0x6039, 0x6054,
+ 0x6072, 0x605e, 0x6045, 0x6053, 0x6047, 0x6049, 0x605b, 0x604c,
+ 0x6040, 0x6042, 0x605f, 0x6024, 0x6044, 0x6058, 0x6066, 0x606e,
+ 0x6242, 0x6243, 0x62cf, 0x630d, 0x630b, 0x62f5, 0x630e, 0x6303,
+ 0x62eb, 0x62f9, 0x630f, 0x630c, 0x62f8, 0x62f6, 0x6300, 0x6313,
+ 0x6314, 0x62fa, 0x6315, 0x62fb, 0x62f0, 0x6541, 0x6543, 0x65aa,
+ 0x65bf, 0x6636, 0x6621, 0x6632, 0x6635, 0x661c, 0x6626, 0x6622,
+ 0x6633, 0x662b, 0x663a, 0x661d, 0x6634, 0x6639, 0x662e, 0x670f,
+ 0x6710, 0x67c1, 0x67f2, 0x67c8, 0x67ba,
+ /* 0xcf */
+ 0x67dc, 0x67bb, 0x67f8, 0x67d8, 0x67c0, 0x67b7, 0x67c5, 0x67eb,
+ 0x67e4, 0x67df, 0x67b5, 0x67cd, 0x67b3, 0x67f7, 0x67f6, 0x67ee,
+ 0x67e3, 0x67c2, 0x67b9, 0x67ce, 0x67e7, 0x67f0, 0x67b2, 0x67fc,
+ 0x67c6, 0x67ed, 0x67cc, 0x67ae, 0x67e6, 0x67db, 0x67fa, 0x67c9,
+ 0x67ca, 0x67c3, 0x67ea, 0x67cb, 0x6b28, 0x6b82, 0x6b84, 0x6bb6,
+ 0x6bd6, 0x6bd8, 0x6be0, 0x6c20, 0x6c21, 0x6d28, 0x6d34, 0x6d2d,
+ 0x6d1f, 0x6d3c, 0x6d3f, 0x6d12, 0x6d0a, 0x6cda, 0x6d33, 0x6d04,
+ 0x6d19, 0x6d3a, 0x6d1a, 0x6d11, 0x6d00, 0x6d1d, 0x6d42, 0x6d01,
+ 0x6d18, 0x6d37, 0x6d03, 0x6d0f, 0x6d40, 0x6d07, 0x6d20, 0x6d2c,
+ 0x6d08, 0x6d22, 0x6d09, 0x6d10, 0x70b7, 0x709f, 0x70be, 0x70b1,
+ 0x70b0, 0x70a1, 0x70b4, 0x70b5, 0x70a9, 0x7241, 0x7249, 0x724a,
+ 0x726c, 0x7270, 0x7273, 0x726e, 0x72ca, 0x72e4, 0x72e8, 0x72eb,
+ 0x72df, 0x72ea, 0x72e6, 0x72e3, 0x7385, 0x73cc, 0x73c2, 0x73c8,
+ 0x73c5, 0x73b9, 0x73b6, 0x73b5, 0x73b4, 0x73eb, 0x73bf, 0x73c7,
+ 0x73be, 0x73c3, 0x73c6, 0x73b8, 0x73cb, 0x74ec, 0x74ee, 0x752e,
+ 0x7547, 0x7548, 0x75a7, 0x75aa, 0x7679, 0x76c4, 0x7708, 0x7703,
+ 0x7704, 0x7705, 0x770a, 0x76f7, 0x76fb, 0x76fa, 0x77e7, 0x77e8,
+ 0x7806, 0x7811, 0x7812, 0x7805, 0x7810, 0x780f, 0x780e, 0x7809,
+ 0x7803, 0x7813, 0x794a, 0x794c, 0x794b, 0x7945, 0x7944, 0x79d5,
+ 0x79cd, 0x79cf, 0x79d6, 0x79ce, 0x7a80,
+ /* 0xd0 */
+ 0x7a7e, 0x7ad1, 0x7b00, 0x7b01, 0x7c7a, 0x7c78, 0x7c79, 0x7c7f,
+ 0x7c80, 0x7c81, 0x7d03, 0x7d08, 0x7d01, 0x7f58, 0x7f91, 0x7f8d,
+ 0x7fbe, 0x8007, 0x800e, 0x800f, 0x8014, 0x8037, 0x80d8, 0x80c7,
+ 0x80e0, 0x80d1, 0x80c8, 0x80c2, 0x80d0, 0x80c5, 0x80e3, 0x80d9,
+ 0x80dc, 0x80ca, 0x80d5, 0x80c9, 0x80cf, 0x80d7, 0x80e6, 0x80cd,
+ 0x81ff, 0x8221, 0x8294, 0x82d9, 0x82fe, 0x82f9, 0x8307, 0x82e8,
+ 0x8300, 0x82d5, 0x833a, 0x82eb, 0x82d6, 0x82f4, 0x82ec, 0x82e1,
+ 0x82f2, 0x82f5, 0x830c, 0x82fb, 0x82f6, 0x82f0, 0x82ea, 0x82e4,
+ 0x82e0, 0x82fa, 0x82f3, 0x82ed, 0x8677, 0x8674, 0x867c, 0x8673,
+ 0x8841, 0x884e, 0x8867, 0x886a, 0x8869, 0x89d3, 0x8a04, 0x8a07,
+ 0x8d72, 0x8fe3, 0x8fe1, 0x8fee, 0x8fe0, 0x90f1, 0x90bd, 0x90bf,
+ 0x90d5, 0x90c5, 0x90be, 0x90c7, 0x90cb, 0x90c8, 0x91d4, 0x91d3,
+ 0x9654, 0x964f, 0x9651, 0x9653, 0x964a, 0x964e, 0x501e, 0x5005,
+ 0x5007, 0x5013, 0x5022, 0x5030, 0x501b, 0x4ff5, 0x4ff4, 0x5033,
+ 0x5037, 0x502c, 0x4ff6, 0x4ff7, 0x5017, 0x501c, 0x5020, 0x5027,
+ 0x5035, 0x502f, 0x5031, 0x500e, 0x515a, 0x5194, 0x5193, 0x51ca,
+ 0x51c4, 0x51c5, 0x51c8, 0x51ce, 0x5261, 0x525a, 0x5252, 0x525e,
+ 0x525f, 0x5255, 0x5262, 0x52cd, 0x530e, 0x539e, 0x5526, 0x54e2,
+ 0x5517, 0x5512, 0x54e7, 0x54f3, 0x54e4, 0x551a, 0x54ff, 0x5504,
+ 0x5508, 0x54eb, 0x5511, 0x5505, 0x54f1,
+ /* 0xd1 */
+ 0x550a, 0x54fb, 0x54f7, 0x54f8, 0x54e0, 0x550e, 0x5503, 0x550b,
+ 0x5701, 0x5702, 0x57cc, 0x5832, 0x57d5, 0x57d2, 0x57ba, 0x57c6,
+ 0x57bd, 0x57bc, 0x57b8, 0x57b6, 0x57bf, 0x57c7, 0x57d0, 0x57b9,
+ 0x57c1, 0x590e, 0x594a, 0x5a19, 0x5a16, 0x5a2d, 0x5a2e, 0x5a15,
+ 0x5a0f, 0x5a17, 0x5a0a, 0x5a1e, 0x5a33, 0x5b6c, 0x5ba7, 0x5bad,
+ 0x5bac, 0x5c03, 0x5c56, 0x5c54, 0x5cec, 0x5cff, 0x5cee, 0x5cf1,
+ 0x5cf7, 0x5d00, 0x5cf9, 0x5e29, 0x5e28, 0x5ea8, 0x5eae, 0x5eaa,
+ 0x5eac, 0x5f33, 0x5f30, 0x5f67, 0x605d, 0x605a, 0x6067, 0x6041,
+ 0x60a2, 0x6088, 0x6080, 0x6092, 0x6081, 0x609d, 0x6083, 0x6095,
+ 0x609b, 0x6097, 0x6087, 0x609c, 0x608e, 0x6219, 0x6246, 0x62f2,
+ 0x6310, 0x6356, 0x632c, 0x6344, 0x6345, 0x6336, 0x6343, 0x63e4,
+ 0x6339, 0x634b, 0x634a, 0x633c, 0x6329, 0x6341, 0x6334, 0x6358,
+ 0x6354, 0x6359, 0x632d, 0x6347, 0x6333, 0x635a, 0x6351, 0x6338,
+ 0x6357, 0x6340, 0x6348, 0x654a, 0x6546, 0x65c6, 0x65c3, 0x65c4,
+ 0x65c2, 0x664a, 0x665f, 0x6647, 0x6651, 0x6712, 0x6713, 0x681f,
+ 0x681a, 0x6849, 0x6832, 0x6833, 0x683b, 0x684b, 0x684f, 0x6816,
+ 0x6831, 0x681c, 0x6835, 0x682b, 0x682d, 0x682f, 0x684e, 0x6844,
+ 0x6834, 0x681d, 0x6812, 0x6814, 0x6826, 0x6828, 0x682e, 0x684d,
+ 0x683a, 0x6825, 0x6820, 0x6b2c, 0x6b2f, 0x6b2d, 0x6b31, 0x6b34,
+ 0x6b6d, 0x8082, 0x6b88, 0x6be6, 0x6be4,
+ /* 0xd2 */
+ 0x6be8, 0x6be3, 0x6be2, 0x6be7, 0x6c25, 0x6d7a, 0x6d63, 0x6d64,
+ 0x6d76, 0x6d0d, 0x6d61, 0x6d92, 0x6d58, 0x6d62, 0x6d6d, 0x6d6f,
+ 0x6d91, 0x6d8d, 0x6def, 0x6d7f, 0x6d86, 0x6d5e, 0x6d67, 0x6d60,
+ 0x6d97, 0x6d70, 0x6d7c, 0x6d5f, 0x6d82, 0x6d98, 0x6d2f, 0x6d68,
+ 0x6d8b, 0x6d7e, 0x6d80, 0x6d84, 0x6d16, 0x6d83, 0x6d7b, 0x6d7d,
+ 0x6d75, 0x6d90, 0x70dc, 0x70d3, 0x70d1, 0x70dd, 0x70cb, 0x7f39,
+ 0x70e2, 0x70d7, 0x70d2, 0x70de, 0x70e0, 0x70d4, 0x70cd, 0x70c5,
+ 0x70c6, 0x70c7, 0x70da, 0x70ce, 0x70e1, 0x7242, 0x7278, 0x7277,
+ 0x7276, 0x7300, 0x72fa, 0x72f4, 0x72fe, 0x72f6, 0x72f3, 0x72fb,
+ 0x7301, 0x73d3, 0x73d9, 0x73e5, 0x73d6, 0x73bc, 0x73e7, 0x73e3,
+ 0x73e9, 0x73dc, 0x73d2, 0x73db, 0x73d4, 0x73dd, 0x73da, 0x73d7,
+ 0x73d8, 0x73e8, 0x74de, 0x74df, 0x74f4, 0x74f5, 0x7521, 0x755b,
+ 0x755f, 0x75b0, 0x75c1, 0x75bb, 0x75c4, 0x75c0, 0x75bf, 0x75b6,
+ 0x75ba, 0x768a, 0x76c9, 0x771d, 0x771b, 0x7710, 0x7713, 0x7712,
+ 0x7723, 0x7711, 0x7715, 0x7719, 0x771a, 0x7722, 0x7727, 0x7823,
+ 0x782c, 0x7822, 0x7835, 0x782f, 0x7828, 0x782e, 0x782b, 0x7821,
+ 0x7829, 0x7833, 0x782a, 0x7831, 0x7954, 0x795b, 0x794f, 0x795c,
+ 0x7953, 0x7952, 0x7951, 0x79eb, 0x79ec, 0x79e0, 0x79ee, 0x79ed,
+ 0x79ea, 0x79dc, 0x79de, 0x79dd, 0x7a86, 0x7a89, 0x7a85, 0x7a8b,
+ 0x7a8c, 0x7a8a, 0x7a87, 0x7ad8, 0x7b10,
+ /* 0xd3 */
+ 0x7b04, 0x7b13, 0x7b05, 0x7b0f, 0x7b08, 0x7b0a, 0x7b0e, 0x7b09,
+ 0x7b12, 0x7c84, 0x7c91, 0x7c8a, 0x7c8c, 0x7c88, 0x7c8d, 0x7c85,
+ 0x7d1e, 0x7d1d, 0x7d11, 0x7d0e, 0x7d18, 0x7d16, 0x7d13, 0x7d1f,
+ 0x7d12, 0x7d0f, 0x7d0c, 0x7f5c, 0x7f61, 0x7f5e, 0x7f60, 0x7f5d,
+ 0x7f5b, 0x7f96, 0x7f92, 0x7fc3, 0x7fc2, 0x7fc0, 0x8016, 0x803e,
+ 0x8039, 0x80fa, 0x80f2, 0x80f9, 0x80f5, 0x8101, 0x80fb, 0x8100,
+ 0x8201, 0x822f, 0x8225, 0x8333, 0x832d, 0x8344, 0x8319, 0x8351,
+ 0x8325, 0x8356, 0x833f, 0x8341, 0x8326, 0x831c, 0x8322, 0x8342,
+ 0x834e, 0x831b, 0x832a, 0x8308, 0x833c, 0x834d, 0x8316, 0x8324,
+ 0x8320, 0x8337, 0x832f, 0x8329, 0x8347, 0x8345, 0x834c, 0x8353,
+ 0x831e, 0x832c, 0x834b, 0x8327, 0x8348, 0x8653, 0x8652, 0x86a2,
+ 0x86a8, 0x8696, 0x868d, 0x8691, 0x869e, 0x8687, 0x8697, 0x8686,
+ 0x868b, 0x869a, 0x8685, 0x86a5, 0x8699, 0x86a1, 0x86a7, 0x8695,
+ 0x8698, 0x868e, 0x869d, 0x8690, 0x8694, 0x8843, 0x8844, 0x886d,
+ 0x8875, 0x8876, 0x8872, 0x8880, 0x8871, 0x887f, 0x886f, 0x8883,
+ 0x887e, 0x8874, 0x887c, 0x8a12, 0x8c47, 0x8c57, 0x8c7b, 0x8ca4,
+ 0x8ca3, 0x8d76, 0x8d78, 0x8db5, 0x8db7, 0x8db6, 0x8ed1, 0x8ed3,
+ 0x8ffe, 0x8ff5, 0x9002, 0x8fff, 0x8ffb, 0x9004, 0x8ffc, 0x8ff6,
+ 0x90d6, 0x90e0, 0x90d9, 0x90da, 0x90e3, 0x90df, 0x90e5, 0x90d8,
+ 0x90db, 0x90d7, 0x90dc, 0x90e4, 0x9150,
+ /* 0xd4 */
+ 0x914e, 0x914f, 0x91d5, 0x91e2, 0x91da, 0x965c, 0x965f, 0x96bc,
+ 0x98e3, 0x9adf, 0x9b2f, 0x4e7f, 0x5070, 0x506a, 0x5061, 0x505e,
+ 0x5060, 0x5053, 0x504b, 0x505d, 0x5072, 0x5048, 0x504d, 0x5041,
+ 0x505b, 0x504a, 0x5062, 0x5015, 0x5045, 0x505f, 0x5069, 0x506b,
+ 0x5063, 0x5064, 0x5046, 0x5040, 0x506e, 0x5073, 0x5057, 0x5051,
+ 0x51d0, 0x526b, 0x526d, 0x526c, 0x526e, 0x52d6, 0x52d3, 0x532d,
+ 0x539c, 0x5575, 0x5576, 0x553c, 0x554d, 0x5550, 0x5534, 0x552a,
+ 0x5551, 0x5562, 0x5536, 0x5535, 0x5530, 0x5552, 0x5545, 0x550c,
+ 0x5532, 0x5565, 0x554e, 0x5539, 0x5548, 0x552d, 0x553b, 0x5540,
+ 0x554b, 0x570a, 0x5707, 0x57fb, 0x5814, 0x57e2, 0x57f6, 0x57dc,
+ 0x57f4, 0x5800, 0x57ed, 0x57fd, 0x5808, 0x57f8, 0x580b, 0x57f3,
+ 0x57cf, 0x5807, 0x57ee, 0x57e3, 0x57f2, 0x57e5, 0x57ec, 0x57e1,
+ 0x580e, 0x57fc, 0x5810, 0x57e7, 0x5801, 0x580c, 0x57f1, 0x57e9,
+ 0x57f0, 0x580d, 0x5804, 0x595c, 0x5a60, 0x5a58, 0x5a55, 0x5a67,
+ 0x5a5e, 0x5a38, 0x5a35, 0x5a6d, 0x5a50, 0x5a5f, 0x5a65, 0x5a6c,
+ 0x5a53, 0x5a64, 0x5a57, 0x5a43, 0x5a5d, 0x5a52, 0x5a44, 0x5a5b,
+ 0x5a48, 0x5a8e, 0x5a3e, 0x5a4d, 0x5a39, 0x5a4c, 0x5a70, 0x5a69,
+ 0x5a47, 0x5a51, 0x5a56, 0x5a42, 0x5a5c, 0x5b72, 0x5b6e, 0x5bc1,
+ 0x5bc0, 0x5c59, 0x5d1e, 0x5d0b, 0x5d1d, 0x5d1a, 0x5d20, 0x5d0c,
+ 0x5d28, 0x5d0d, 0x5d26, 0x5d25, 0x5d0f,
+ /* 0xd5 */
+ 0x5d30, 0x5d12, 0x5d23, 0x5d1f, 0x5d2e, 0x5e3e, 0x5e34, 0x5eb1,
+ 0x5eb4, 0x5eb9, 0x5eb2, 0x5eb3, 0x5f36, 0x5f38, 0x5f9b, 0x5f96,
+ 0x5f9f, 0x608a, 0x6090, 0x6086, 0x60be, 0x60b0, 0x60ba, 0x60d3,
+ 0x60d4, 0x60cf, 0x60e4, 0x60d9, 0x60dd, 0x60c8, 0x60b1, 0x60db,
+ 0x60b7, 0x60ca, 0x60bf, 0x60c3, 0x60cd, 0x60c0, 0x6332, 0x6365,
+ 0x638a, 0x6382, 0x637d, 0x63bd, 0x639e, 0x63ad, 0x639d, 0x6397,
+ 0x63ab, 0x638e, 0x636f, 0x6387, 0x6390, 0x636e, 0x63af, 0x6375,
+ 0x639c, 0x636d, 0x63ae, 0x637c, 0x63a4, 0x633b, 0x639f, 0x6378,
+ 0x6385, 0x6381, 0x6391, 0x638d, 0x6370, 0x6553, 0x65cd, 0x6665,
+ 0x6661, 0x665b, 0x6659, 0x665c, 0x6662, 0x6718, 0x6879, 0x6887,
+ 0x6890, 0x689c, 0x686d, 0x686e, 0x68ae, 0x68ab, 0x6956, 0x686f,
+ 0x68a3, 0x68ac, 0x68a9, 0x6875, 0x6874, 0x68b2, 0x688f, 0x6877,
+ 0x6892, 0x687c, 0x686b, 0x6872, 0x68aa, 0x6880, 0x6871, 0x687e,
+ 0x689b, 0x6896, 0x688b, 0x68a0, 0x6889, 0x68a4, 0x6878, 0x687b,
+ 0x6891, 0x688c, 0x688a, 0x687d, 0x6b36, 0x6b33, 0x6b37, 0x6b38,
+ 0x6b91, 0x6b8f, 0x6b8d, 0x6b8e, 0x6b8c, 0x6c2a, 0x6dc0, 0x6dab,
+ 0x6db4, 0x6db3, 0x6e74, 0x6dac, 0x6de9, 0x6de2, 0x6db7, 0x6df6,
+ 0x6dd4, 0x6e00, 0x6dc8, 0x6de0, 0x6ddf, 0x6dd6, 0x6dbe, 0x6de5,
+ 0x6ddc, 0x6ddd, 0x6ddb, 0x6df4, 0x6dca, 0x6dbd, 0x6ded, 0x6df0,
+ 0x6dba, 0x6dd5, 0x6dc2, 0x6dcf, 0x6dc9,
+ /* 0xd6 */
+ 0x6dd0, 0x6df2, 0x6dd3, 0x6dfd, 0x6dd7, 0x6dcd, 0x6de3, 0x6dbb,
+ 0x70fa, 0x710d, 0x70f7, 0x7117, 0x70f4, 0x710c, 0x70f0, 0x7104,
+ 0x70f3, 0x7110, 0x70fc, 0x70ff, 0x7106, 0x7113, 0x7100, 0x70f8,
+ 0x70f6, 0x710b, 0x7102, 0x710e, 0x727e, 0x727b, 0x727c, 0x727f,
+ 0x731d, 0x7317, 0x7307, 0x7311, 0x7318, 0x730a, 0x7308, 0x72ff,
+ 0x730f, 0x731e, 0x7388, 0x73f6, 0x73f8, 0x73f5, 0x7404, 0x7401,
+ 0x73fd, 0x7407, 0x7400, 0x73fa, 0x73fc, 0x73ff, 0x740c, 0x740b,
+ 0x73f4, 0x7408, 0x7564, 0x7563, 0x75ce, 0x75d2, 0x75cf, 0x75cb,
+ 0x75cc, 0x75d1, 0x75d0, 0x768f, 0x7689, 0x76d3, 0x7739, 0x772f,
+ 0x772d, 0x7731, 0x7732, 0x7734, 0x7733, 0x773d, 0x7725, 0x773b,
+ 0x7735, 0x7848, 0x7852, 0x7849, 0x784d, 0x784a, 0x784c, 0x7826,
+ 0x7845, 0x7850, 0x7964, 0x7967, 0x7969, 0x796a, 0x7963, 0x796b,
+ 0x7961, 0x79bb, 0x79fa, 0x79f8, 0x79f6, 0x79f7, 0x7a8f, 0x7a94,
+ 0x7a90, 0x7b35, 0x7b47, 0x7b34, 0x7b25, 0x7b30, 0x7b22, 0x7b24,
+ 0x7b33, 0x7b18, 0x7b2a, 0x7b1d, 0x7b31, 0x7b2b, 0x7b2d, 0x7b2f,
+ 0x7b32, 0x7b38, 0x7b1a, 0x7b23, 0x7c94, 0x7c98, 0x7c96, 0x7ca3,
+ 0x7d35, 0x7d3d, 0x7d38, 0x7d36, 0x7d3a, 0x7d45, 0x7d2c, 0x7d29,
+ 0x7d41, 0x7d47, 0x7d3e, 0x7d3f, 0x7d4a, 0x7d3b, 0x7d28, 0x7f63,
+ 0x7f95, 0x7f9c, 0x7f9d, 0x7f9b, 0x7fca, 0x7fcb, 0x7fcd, 0x7fd0,
+ 0x7fd1, 0x7fc7, 0x7fcf, 0x7fc9, 0x801f,
+ /* 0xd7 */
+ 0x801e, 0x801b, 0x8047, 0x8043, 0x8048, 0x8118, 0x8125, 0x8119,
+ 0x811b, 0x812d, 0x811f, 0x812c, 0x811e, 0x8121, 0x8115, 0x8127,
+ 0x811d, 0x8122, 0x8211, 0x8238, 0x8233, 0x823a, 0x8234, 0x8232,
+ 0x8274, 0x8390, 0x83a3, 0x83a8, 0x838d, 0x837a, 0x8373, 0x83a4,
+ 0x8374, 0x838f, 0x8381, 0x8395, 0x8399, 0x8375, 0x8394, 0x83a9,
+ 0x837d, 0x8383, 0x838c, 0x839d, 0x839b, 0x83aa, 0x838b, 0x837e,
+ 0x83a5, 0x83af, 0x8388, 0x8397, 0x83b0, 0x837f, 0x83a6, 0x8387,
+ 0x83ae, 0x8376, 0x839a, 0x8659, 0x8656, 0x86bf, 0x86b7, 0x86c2,
+ 0x86c1, 0x86c5, 0x86ba, 0x86b0, 0x86c8, 0x86b9, 0x86b3, 0x86b8,
+ 0x86cc, 0x86b4, 0x86bb, 0x86bc, 0x86c3, 0x86bd, 0x86be, 0x8852,
+ 0x8889, 0x8895, 0x88a8, 0x88a2, 0x88aa, 0x889a, 0x8891, 0x88a1,
+ 0x889f, 0x8898, 0x88a7, 0x8899, 0x889b, 0x8897, 0x88a4, 0x88ac,
+ 0x888c, 0x8893, 0x888e, 0x8982, 0x89d6, 0x89d9, 0x89d5, 0x8a30,
+ 0x8a27, 0x8a2c, 0x8a1e, 0x8c39, 0x8c3b, 0x8c5c, 0x8c5d, 0x8c7d,
+ 0x8ca5, 0x8d7d, 0x8d7b, 0x8d79, 0x8dbc, 0x8dc2, 0x8db9, 0x8dbf,
+ 0x8dc1, 0x8ed8, 0x8ede, 0x8edd, 0x8edc, 0x8ed7, 0x8ee0, 0x8ee1,
+ 0x9024, 0x900b, 0x9011, 0x901c, 0x900c, 0x9021, 0x90ef, 0x90ea,
+ 0x90f0, 0x90f4, 0x90f2, 0x90f3, 0x90d4, 0x90eb, 0x90ec, 0x90e9,
+ 0x9156, 0x9158, 0x915a, 0x9153, 0x9155, 0x91ec, 0x91f4, 0x91f1,
+ 0x91f3, 0x91f8, 0x91e4, 0x91f9, 0x91ea,
+ /* 0xd8 */
+ 0x91eb, 0x91f7, 0x91e8, 0x91ee, 0x957a, 0x9586, 0x9588, 0x967c,
+ 0x966d, 0x966b, 0x9671, 0x966f, 0x96bf, 0x976a, 0x9804, 0x98e5,
+ 0x9997, 0x509b, 0x5095, 0x5094, 0x509e, 0x508b, 0x50a3, 0x5083,
+ 0x508c, 0x508e, 0x509d, 0x5068, 0x509c, 0x5092, 0x5082, 0x5087,
+ 0x515f, 0x51d4, 0x5312, 0x5311, 0x53a4, 0x53a7, 0x5591, 0x55a8,
+ 0x55a5, 0x55ad, 0x5577, 0x5645, 0x55a2, 0x5593, 0x5588, 0x558f,
+ 0x55b5, 0x5581, 0x55a3, 0x5592, 0x55a4, 0x557d, 0x558c, 0x55a6,
+ 0x557f, 0x5595, 0x55a1, 0x558e, 0x570c, 0x5829, 0x5837, 0x5819,
+ 0x581e, 0x5827, 0x5823, 0x5828, 0x57f5, 0x5848, 0x5825, 0x581c,
+ 0x581b, 0x5833, 0x583f, 0x5836, 0x582e, 0x5839, 0x5838, 0x582d,
+ 0x582c, 0x583b, 0x5961, 0x5aaf, 0x5a94, 0x5a9f, 0x5a7a, 0x5aa2,
+ 0x5a9e, 0x5a78, 0x5aa6, 0x5a7c, 0x5aa5, 0x5aac, 0x5a95, 0x5aae,
+ 0x5a37, 0x5a84, 0x5a8a, 0x5a97, 0x5a83, 0x5a8b, 0x5aa9, 0x5a7b,
+ 0x5a7d, 0x5a8c, 0x5a9c, 0x5a8f, 0x5a93, 0x5a9d, 0x5bea, 0x5bcd,
+ 0x5bcb, 0x5bd4, 0x5bd1, 0x5bca, 0x5bce, 0x5c0c, 0x5c30, 0x5d37,
+ 0x5d43, 0x5d6b, 0x5d41, 0x5d4b, 0x5d3f, 0x5d35, 0x5d51, 0x5d4e,
+ 0x5d55, 0x5d33, 0x5d3a, 0x5d52, 0x5d3d, 0x5d31, 0x5d59, 0x5d42,
+ 0x5d39, 0x5d49, 0x5d38, 0x5d3c, 0x5d32, 0x5d36, 0x5d40, 0x5d45,
+ 0x5e44, 0x5e41, 0x5f58, 0x5fa6, 0x5fa5, 0x5fab, 0x60c9, 0x60b9,
+ 0x60cc, 0x60e2, 0x60ce, 0x60c4, 0x6114,
+ /* 0xd9 */
+ 0x60f2, 0x610a, 0x6116, 0x6105, 0x60f5, 0x6113, 0x60f8, 0x60fc,
+ 0x60fe, 0x60c1, 0x6103, 0x6118, 0x611d, 0x6110, 0x60ff, 0x6104,
+ 0x610b, 0x624a, 0x6394, 0x63b1, 0x63b0, 0x63ce, 0x63e5, 0x63e8,
+ 0x63ef, 0x63c3, 0x649d, 0x63f3, 0x63ca, 0x63e0, 0x63f6, 0x63d5,
+ 0x63f2, 0x63f5, 0x6461, 0x63df, 0x63be, 0x63dd, 0x63dc, 0x63c4,
+ 0x63d8, 0x63d3, 0x63c2, 0x63c7, 0x63cc, 0x63cb, 0x63c8, 0x63f0,
+ 0x63d7, 0x63d9, 0x6532, 0x6567, 0x656a, 0x6564, 0x655c, 0x6568,
+ 0x6565, 0x658c, 0x659d, 0x659e, 0x65ae, 0x65d0, 0x65d2, 0x667c,
+ 0x666c, 0x667b, 0x6680, 0x6671, 0x6679, 0x666a, 0x6672, 0x6701,
+ 0x690c, 0x68d3, 0x6904, 0x68dc, 0x692a, 0x68ec, 0x68ea, 0x68f1,
+ 0x690f, 0x68d6, 0x68f7, 0x68eb, 0x68e4, 0x68f6, 0x6913, 0x6910,
+ 0x68f3, 0x68e1, 0x6907, 0x68cc, 0x6908, 0x6970, 0x68b4, 0x6911,
+ 0x68ef, 0x68c6, 0x6914, 0x68f8, 0x68d0, 0x68fd, 0x68fc, 0x68e8,
+ 0x690b, 0x690a, 0x6917, 0x68ce, 0x68c8, 0x68dd, 0x68de, 0x68e6,
+ 0x68f4, 0x68d1, 0x6906, 0x68d4, 0x68e9, 0x6915, 0x6925, 0x68c7,
+ 0x6b39, 0x6b3b, 0x6b3f, 0x6b3c, 0x6b94, 0x6b97, 0x6b99, 0x6b95,
+ 0x6bbd, 0x6bf0, 0x6bf2, 0x6bf3, 0x6c30, 0x6dfc, 0x6e46, 0x6e47,
+ 0x6e1f, 0x6e49, 0x6e88, 0x6e3c, 0x6e3d, 0x6e45, 0x6e62, 0x6e2b,
+ 0x6e3f, 0x6e41, 0x6e5d, 0x6e73, 0x6e1c, 0x6e33, 0x6e4b, 0x6e40,
+ 0x6e51, 0x6e3b, 0x6e03, 0x6e2e, 0x6e5e,
+ /* 0xda */
+ 0x6e68, 0x6e5c, 0x6e61, 0x6e31, 0x6e28, 0x6e60, 0x6e71, 0x6e6b,
+ 0x6e39, 0x6e22, 0x6e30, 0x6e53, 0x6e65, 0x6e27, 0x6e78, 0x6e64,
+ 0x6e77, 0x6e55, 0x6e79, 0x6e52, 0x6e66, 0x6e35, 0x6e36, 0x6e5a,
+ 0x7120, 0x711e, 0x712f, 0x70fb, 0x712e, 0x7131, 0x7123, 0x7125,
+ 0x7122, 0x7132, 0x711f, 0x7128, 0x713a, 0x711b, 0x724b, 0x725a,
+ 0x7288, 0x7289, 0x7286, 0x7285, 0x728b, 0x7312, 0x730b, 0x7330,
+ 0x7322, 0x7331, 0x7333, 0x7327, 0x7332, 0x732d, 0x7326, 0x7323,
+ 0x7335, 0x730c, 0x742e, 0x742c, 0x7430, 0x742b, 0x7416, 0x741a,
+ 0x7421, 0x742d, 0x7431, 0x7424, 0x7423, 0x741d, 0x7429, 0x7420,
+ 0x7432, 0x74fb, 0x752f, 0x756f, 0x756c, 0x75e7, 0x75da, 0x75e1,
+ 0x75e6, 0x75dd, 0x75df, 0x75e4, 0x75d7, 0x7695, 0x7692, 0x76da,
+ 0x7746, 0x7747, 0x7744, 0x774d, 0x7745, 0x774a, 0x774e, 0x774b,
+ 0x774c, 0x77de, 0x77ec, 0x7860, 0x7864, 0x7865, 0x785c, 0x786d,
+ 0x7871, 0x786a, 0x786e, 0x7870, 0x7869, 0x7868, 0x785e, 0x7862,
+ 0x7974, 0x7973, 0x7972, 0x7970, 0x7a02, 0x7a0a, 0x7a03, 0x7a0c,
+ 0x7a04, 0x7a99, 0x7ae6, 0x7ae4, 0x7b4a, 0x7b3b, 0x7b44, 0x7b48,
+ 0x7b4c, 0x7b4e, 0x7b40, 0x7b58, 0x7b45, 0x7ca2, 0x7c9e, 0x7ca8,
+ 0x7ca1, 0x7d58, 0x7d6f, 0x7d63, 0x7d53, 0x7d56, 0x7d67, 0x7d6a,
+ 0x7d4f, 0x7d6d, 0x7d5c, 0x7d6b, 0x7d52, 0x7d54, 0x7d69, 0x7d51,
+ 0x7d5f, 0x7d4e, 0x7f3e, 0x7f3f, 0x7f65,
+ /* 0xdb */
+ 0x7f66, 0x7fa2, 0x7fa0, 0x7fa1, 0x7fd7, 0x8051, 0x804f, 0x8050,
+ 0x80fe, 0x80d4, 0x8143, 0x814a, 0x8152, 0x814f, 0x8147, 0x813d,
+ 0x814d, 0x813a, 0x81e6, 0x81ee, 0x81f7, 0x81f8, 0x81f9, 0x8204,
+ 0x823c, 0x823d, 0x823f, 0x8275, 0x833b, 0x83cf, 0x83f9, 0x8423,
+ 0x83c0, 0x83e8, 0x8412, 0x83e7, 0x83e4, 0x83fc, 0x83f6, 0x8410,
+ 0x83c6, 0x83c8, 0x83eb, 0x83e3, 0x83bf, 0x8401, 0x83dd, 0x83e5,
+ 0x83d8, 0x83ff, 0x83e1, 0x83cb, 0x83ce, 0x83d6, 0x83f5, 0x83c9,
+ 0x8409, 0x840f, 0x83de, 0x8411, 0x8406, 0x83c2, 0x83f3, 0x83d5,
+ 0x83fa, 0x83c7, 0x83d1, 0x83ea, 0x8413, 0x83c3, 0x83ec, 0x83ee,
+ 0x83c4, 0x83fb, 0x83d7, 0x83e2, 0x841b, 0x83db, 0x83fe, 0x86d8,
+ 0x86e2, 0x86e6, 0x86d3, 0x86e3, 0x86da, 0x86ea, 0x86dd, 0x86eb,
+ 0x86dc, 0x86ec, 0x86e9, 0x86d7, 0x86e8, 0x86d1, 0x8848, 0x8856,
+ 0x8855, 0x88ba, 0x88d7, 0x88b9, 0x88b8, 0x88c0, 0x88be, 0x88b6,
+ 0x88bc, 0x88b7, 0x88bd, 0x88b2, 0x8901, 0x88c9, 0x8995, 0x8998,
+ 0x8997, 0x89dd, 0x89da, 0x89db, 0x8a4e, 0x8a4d, 0x8a39, 0x8a59,
+ 0x8a40, 0x8a57, 0x8a58, 0x8a44, 0x8a45, 0x8a52, 0x8a48, 0x8a51,
+ 0x8a4a, 0x8a4c, 0x8a4f, 0x8c5f, 0x8c81, 0x8c80, 0x8cba, 0x8cbe,
+ 0x8cb0, 0x8cb9, 0x8cb5, 0x8d84, 0x8d80, 0x8d89, 0x8dd8, 0x8dd3,
+ 0x8dcd, 0x8dc7, 0x8dd6, 0x8ddc, 0x8dcf, 0x8dd5, 0x8dd9, 0x8dc8,
+ 0x8dd7, 0x8dc5, 0x8eef, 0x8ef7, 0x8efa,
+ /* 0xdc */
+ 0x8ef9, 0x8ee6, 0x8eee, 0x8ee5, 0x8ef5, 0x8ee7, 0x8ee8, 0x8ef6,
+ 0x8eeb, 0x8ef1, 0x8eec, 0x8ef4, 0x8ee9, 0x902d, 0x9034, 0x902f,
+ 0x9106, 0x912c, 0x9104, 0x90ff, 0x90fc, 0x9108, 0x90f9, 0x90fb,
+ 0x9101, 0x9100, 0x9107, 0x9105, 0x9103, 0x9161, 0x9164, 0x915f,
+ 0x9162, 0x9160, 0x9201, 0x920a, 0x9225, 0x9203, 0x921a, 0x9226,
+ 0x920f, 0x920c, 0x9200, 0x9212, 0x91ff, 0x91fd, 0x9206, 0x9204,
+ 0x9227, 0x9202, 0x921c, 0x9224, 0x9219, 0x9217, 0x9205, 0x9216,
+ 0x957b, 0x958d, 0x958c, 0x9590, 0x9687, 0x967e, 0x9688, 0x9689,
+ 0x9683, 0x9680, 0x96c2, 0x96c8, 0x96c3, 0x96f1, 0x96f0, 0x976c,
+ 0x9770, 0x976e, 0x9807, 0x98a9, 0x98eb, 0x9ce6, 0x9ef9, 0x4e83,
+ 0x4e84, 0x4eb6, 0x50bd, 0x50bf, 0x50c6, 0x50ae, 0x50c4, 0x50ca,
+ 0x50b4, 0x50c8, 0x50c2, 0x50b0, 0x50c1, 0x50ba, 0x50b1, 0x50cb,
+ 0x50c9, 0x50b6, 0x50b8, 0x51d7, 0x527a, 0x5278, 0x527b, 0x527c,
+ 0x55c3, 0x55db, 0x55cc, 0x55d0, 0x55cb, 0x55ca, 0x55dd, 0x55c0,
+ 0x55d4, 0x55c4, 0x55e9, 0x55bf, 0x55d2, 0x558d, 0x55cf, 0x55d5,
+ 0x55e2, 0x55d6, 0x55c8, 0x55f2, 0x55cd, 0x55d9, 0x55c2, 0x5714,
+ 0x5853, 0x5868, 0x5864, 0x584f, 0x584d, 0x5849, 0x586f, 0x5855,
+ 0x584e, 0x585d, 0x5859, 0x5865, 0x585b, 0x583d, 0x5863, 0x5871,
+ 0x58fc, 0x5ac7, 0x5ac4, 0x5acb, 0x5aba, 0x5ab8, 0x5ab1, 0x5ab5,
+ 0x5ab0, 0x5abf, 0x5ac8, 0x5abb, 0x5ac6,
+ /* 0xdd */
+ 0x5ab7, 0x5ac0, 0x5aca, 0x5ab4, 0x5ab6, 0x5acd, 0x5ab9, 0x5a90,
+ 0x5bd6, 0x5bd8, 0x5bd9, 0x5c1f, 0x5c33, 0x5d71, 0x5d63, 0x5d4a,
+ 0x5d65, 0x5d72, 0x5d6c, 0x5d5e, 0x5d68, 0x5d67, 0x5d62, 0x5df0,
+ 0x5e4f, 0x5e4e, 0x5e4a, 0x5e4d, 0x5e4b, 0x5ec5, 0x5ecc, 0x5ec6,
+ 0x5ecb, 0x5ec7, 0x5f40, 0x5faf, 0x5fad, 0x60f7, 0x6149, 0x614a,
+ 0x612b, 0x6145, 0x6136, 0x6132, 0x612e, 0x6146, 0x612f, 0x614f,
+ 0x6129, 0x6140, 0x6220, 0x9168, 0x6223, 0x6225, 0x6224, 0x63c5,
+ 0x63f1, 0x63eb, 0x6410, 0x6412, 0x6409, 0x6420, 0x6424, 0x6433,
+ 0x6443, 0x641f, 0x6415, 0x6418, 0x6439, 0x6437, 0x6422, 0x6423,
+ 0x640c, 0x6426, 0x6430, 0x6428, 0x6441, 0x6435, 0x642f, 0x640a,
+ 0x641a, 0x6440, 0x6425, 0x6427, 0x640b, 0x63e7, 0x641b, 0x642e,
+ 0x6421, 0x640e, 0x656f, 0x6592, 0x65d3, 0x6686, 0x668c, 0x6695,
+ 0x6690, 0x668b, 0x668a, 0x6699, 0x6694, 0x6678, 0x6720, 0x6966,
+ 0x695f, 0x6938, 0x694e, 0x6962, 0x6971, 0x693f, 0x6945, 0x696a,
+ 0x6939, 0x6942, 0x6957, 0x6959, 0x697a, 0x6948, 0x6949, 0x6935,
+ 0x696c, 0x6933, 0x693d, 0x6965, 0x68f0, 0x6978, 0x6934, 0x6969,
+ 0x6940, 0x696f, 0x6944, 0x6976, 0x6958, 0x6941, 0x6974, 0x694c,
+ 0x693b, 0x694b, 0x6937, 0x695c, 0x694f, 0x6951, 0x6932, 0x6952,
+ 0x692f, 0x697b, 0x693c, 0x6b46, 0x6b45, 0x6b43, 0x6b42, 0x6b48,
+ 0x6b41, 0x6b9b, 0xfa0d, 0x6bfb, 0x6bfc,
+ /* 0xde */
+ 0x6bf9, 0x6bf7, 0x6bf8, 0x6e9b, 0x6ed6, 0x6ec8, 0x6e8f, 0x6ec0,
+ 0x6e9f, 0x6e93, 0x6e94, 0x6ea0, 0x6eb1, 0x6eb9, 0x6ec6, 0x6ed2,
+ 0x6ebd, 0x6ec1, 0x6e9e, 0x6ec9, 0x6eb7, 0x6eb0, 0x6ecd, 0x6ea6,
+ 0x6ecf, 0x6eb2, 0x6ebe, 0x6ec3, 0x6edc, 0x6ed8, 0x6e99, 0x6e92,
+ 0x6e8e, 0x6e8d, 0x6ea4, 0x6ea1, 0x6ebf, 0x6eb3, 0x6ed0, 0x6eca,
+ 0x6e97, 0x6eae, 0x6ea3, 0x7147, 0x7154, 0x7152, 0x7163, 0x7160,
+ 0x7141, 0x715d, 0x7162, 0x7172, 0x7178, 0x716a, 0x7161, 0x7142,
+ 0x7158, 0x7143, 0x714b, 0x7170, 0x715f, 0x7150, 0x7153, 0x7144,
+ 0x714d, 0x715a, 0x724f, 0x728d, 0x728c, 0x7291, 0x7290, 0x728e,
+ 0x733c, 0x7342, 0x733b, 0x733a, 0x7340, 0x734a, 0x7349, 0x7444,
+ 0x744a, 0x744b, 0x7452, 0x7451, 0x7457, 0x7440, 0x744f, 0x7450,
+ 0x744e, 0x7442, 0x7446, 0x744d, 0x7454, 0x74e1, 0x74ff, 0x74fe,
+ 0x74fd, 0x751d, 0x7579, 0x7577, 0x6983, 0x75ef, 0x760f, 0x7603,
+ 0x75f7, 0x75fe, 0x75fc, 0x75f9, 0x75f8, 0x7610, 0x75fb, 0x75f6,
+ 0x75ed, 0x75f5, 0x75fd, 0x7699, 0x76b5, 0x76dd, 0x7755, 0x775f,
+ 0x7760, 0x7752, 0x7756, 0x775a, 0x7769, 0x7767, 0x7754, 0x7759,
+ 0x776d, 0x77e0, 0x7887, 0x789a, 0x7894, 0x788f, 0x7884, 0x7895,
+ 0x7885, 0x7886, 0x78a1, 0x7883, 0x7879, 0x7899, 0x7880, 0x7896,
+ 0x787b, 0x797c, 0x7982, 0x797d, 0x7979, 0x7a11, 0x7a18, 0x7a19,
+ 0x7a12, 0x7a17, 0x7a15, 0x7a22, 0x7a13,
+ /* 0xdf */
+ 0x7a1b, 0x7a10, 0x7aa3, 0x7aa2, 0x7a9e, 0x7aeb, 0x7b66, 0x7b64,
+ 0x7b6d, 0x7b74, 0x7b69, 0x7b72, 0x7b65, 0x7b73, 0x7b71, 0x7b70,
+ 0x7b61, 0x7b78, 0x7b76, 0x7b63, 0x7cb2, 0x7cb4, 0x7caf, 0x7d88,
+ 0x7d86, 0x7d80, 0x7d8d, 0x7d7f, 0x7d85, 0x7d7a, 0x7d8e, 0x7d7b,
+ 0x7d83, 0x7d7c, 0x7d8c, 0x7d94, 0x7d84, 0x7d7d, 0x7d92, 0x7f6d,
+ 0x7f6b, 0x7f67, 0x7f68, 0x7f6c, 0x7fa6, 0x7fa5, 0x7fa7, 0x7fdb,
+ 0x7fdc, 0x8021, 0x8164, 0x8160, 0x8177, 0x815c, 0x8169, 0x815b,
+ 0x8162, 0x8172, 0x6721, 0x815e, 0x8176, 0x8167, 0x816f, 0x8144,
+ 0x8161, 0x821d, 0x8249, 0x8244, 0x8240, 0x8242, 0x8245, 0x84f1,
+ 0x843f, 0x8456, 0x8476, 0x8479, 0x848f, 0x848d, 0x8465, 0x8451,
+ 0x8440, 0x8486, 0x8467, 0x8430, 0x844d, 0x847d, 0x845a, 0x8459,
+ 0x8474, 0x8473, 0x845d, 0x8507, 0x845e, 0x8437, 0x843a, 0x8434,
+ 0x847a, 0x8443, 0x8478, 0x8432, 0x8445, 0x8429, 0x83d9, 0x844b,
+ 0x842f, 0x8442, 0x842d, 0x845f, 0x8470, 0x8439, 0x844e, 0x844c,
+ 0x8452, 0x846f, 0x84c5, 0x848e, 0x843b, 0x8447, 0x8436, 0x8433,
+ 0x8468, 0x847e, 0x8444, 0x842b, 0x8460, 0x8454, 0x846e, 0x8450,
+ 0x870b, 0x8704, 0x86f7, 0x870c, 0x86fa, 0x86d6, 0x86f5, 0x874d,
+ 0x86f8, 0x870e, 0x8709, 0x8701, 0x86f6, 0x870d, 0x8705, 0x88d6,
+ 0x88cb, 0x88cd, 0x88ce, 0x88de, 0x88db, 0x88da, 0x88cc, 0x88d0,
+ 0x8985, 0x899b, 0x89df, 0x89e5, 0x89e4,
+ /* 0xe0 */
+ 0x89e1, 0x89e0, 0x89e2, 0x89dc, 0x89e6, 0x8a76, 0x8a86, 0x8a7f,
+ 0x8a61, 0x8a3f, 0x8a77, 0x8a82, 0x8a84, 0x8a75, 0x8a83, 0x8a81,
+ 0x8a74, 0x8a7a, 0x8c3c, 0x8c4b, 0x8c4a, 0x8c65, 0x8c64, 0x8c66,
+ 0x8c86, 0x8c84, 0x8c85, 0x8ccc, 0x8d68, 0x8d69, 0x8d91, 0x8d8c,
+ 0x8d8e, 0x8d8f, 0x8d8d, 0x8d93, 0x8d94, 0x8d90, 0x8d92, 0x8df0,
+ 0x8de0, 0x8dec, 0x8df1, 0x8dee, 0x8dd0, 0x8de9, 0x8de3, 0x8de2,
+ 0x8de7, 0x8df2, 0x8deb, 0x8df4, 0x8f06, 0x8eff, 0x8f01, 0x8f00,
+ 0x8f05, 0x8f07, 0x8f08, 0x8f02, 0x8f0b, 0x9052, 0x903f, 0x9044,
+ 0x9049, 0x903d, 0x9110, 0x910d, 0x910f, 0x9111, 0x9116, 0x9114,
+ 0x910b, 0x910e, 0x916e, 0x916f, 0x9248, 0x9252, 0x9230, 0x923a,
+ 0x9266, 0x9233, 0x9265, 0x925e, 0x9283, 0x922e, 0x924a, 0x9246,
+ 0x926d, 0x926c, 0x924f, 0x9260, 0x9267, 0x926f, 0x9236, 0x9261,
+ 0x9270, 0x9231, 0x9254, 0x9263, 0x9250, 0x9272, 0x924e, 0x9253,
+ 0x924c, 0x9256, 0x9232, 0x959f, 0x959c, 0x959e, 0x959b, 0x9692,
+ 0x9693, 0x9691, 0x9697, 0x96ce, 0x96fa, 0x96fd, 0x96f8, 0x96f5,
+ 0x9773, 0x9777, 0x9778, 0x9772, 0x980f, 0x980d, 0x980e, 0x98ac,
+ 0x98f6, 0x98f9, 0x99af, 0x99b2, 0x99b0, 0x99b5, 0x9aad, 0x9aab,
+ 0x9b5b, 0x9cea, 0x9ced, 0x9ce7, 0x9e80, 0x9efd, 0x50e6, 0x50d4,
+ 0x50d7, 0x50e8, 0x50f3, 0x50db, 0x50ea, 0x50dd, 0x50e4, 0x50d3,
+ 0x50ec, 0x50f0, 0x50ef, 0x50e3, 0x50e0,
+ /* 0xe1 */
+ 0x51d8, 0x5280, 0x5281, 0x52e9, 0x52eb, 0x5330, 0x53ac, 0x5627,
+ 0x5615, 0x560c, 0x5612, 0x55fc, 0x560f, 0x561c, 0x5601, 0x5613,
+ 0x5602, 0x55fa, 0x561d, 0x5604, 0x55ff, 0x55f9, 0x5889, 0x587c,
+ 0x5890, 0x5898, 0x5886, 0x5881, 0x587f, 0x5874, 0x588b, 0x587a,
+ 0x5887, 0x5891, 0x588e, 0x5876, 0x5882, 0x5888, 0x587b, 0x5894,
+ 0x588f, 0x58fe, 0x596b, 0x5adc, 0x5aee, 0x5ae5, 0x5ad5, 0x5aea,
+ 0x5ada, 0x5aed, 0x5aeb, 0x5af3, 0x5ae2, 0x5ae0, 0x5adb, 0x5aec,
+ 0x5ade, 0x5add, 0x5ad9, 0x5ae8, 0x5adf, 0x5b77, 0x5be0, 0x5be3,
+ 0x5c63, 0x5d82, 0x5d80, 0x5d7d, 0x5d86, 0x5d7a, 0x5d81, 0x5d77,
+ 0x5d8a, 0x5d89, 0x5d88, 0x5d7e, 0x5d7c, 0x5d8d, 0x5d79, 0x5d7f,
+ 0x5e58, 0x5e59, 0x5e53, 0x5ed8, 0x5ed1, 0x5ed7, 0x5ece, 0x5edc,
+ 0x5ed5, 0x5ed9, 0x5ed2, 0x5ed4, 0x5f44, 0x5f43, 0x5f6f, 0x5fb6,
+ 0x612c, 0x6128, 0x6141, 0x615e, 0x6171, 0x6173, 0x6152, 0x6153,
+ 0x6172, 0x616c, 0x6180, 0x6174, 0x6154, 0x617a, 0x615b, 0x6165,
+ 0x613b, 0x616a, 0x6161, 0x6156, 0x6229, 0x6227, 0x622b, 0x642b,
+ 0x644d, 0x645b, 0x645d, 0x6474, 0x6476, 0x6472, 0x6473, 0x647d,
+ 0x6475, 0x6466, 0x64a6, 0x644e, 0x6482, 0x645e, 0x645c, 0x644b,
+ 0x6453, 0x6460, 0x6450, 0x647f, 0x643f, 0x646c, 0x646b, 0x6459,
+ 0x6465, 0x6477, 0x6573, 0x65a0, 0x66a1, 0x66a0, 0x669f, 0x6705,
+ 0x6704, 0x6722, 0x69b1, 0x69b6, 0x69c9,
+ /* 0xe2 */
+ 0x69a0, 0x69ce, 0x6996, 0x69b0, 0x69ac, 0x69bc, 0x6991, 0x6999,
+ 0x698e, 0x69a7, 0x698d, 0x69a9, 0x69be, 0x69af, 0x69bf, 0x69c4,
+ 0x69bd, 0x69a4, 0x69d4, 0x69b9, 0x69ca, 0x699a, 0x69cf, 0x69b3,
+ 0x6993, 0x69aa, 0x69a1, 0x699e, 0x69d9, 0x6997, 0x6990, 0x69c2,
+ 0x69b5, 0x69a5, 0x69c6, 0x6b4a, 0x6b4d, 0x6b4b, 0x6b9e, 0x6b9f,
+ 0x6ba0, 0x6bc3, 0x6bc4, 0x6bfe, 0x6ece, 0x6ef5, 0x6ef1, 0x6f03,
+ 0x6f25, 0x6ef8, 0x6f37, 0x6efb, 0x6f2e, 0x6f09, 0x6f4e, 0x6f19,
+ 0x6f1a, 0x6f27, 0x6f18, 0x6f3b, 0x6f12, 0x6eed, 0x6f0a, 0x6f36,
+ 0x6f73, 0x6ef9, 0x6eee, 0x6f2d, 0x6f40, 0x6f30, 0x6f3c, 0x6f35,
+ 0x6eeb, 0x6f07, 0x6f0e, 0x6f43, 0x6f05, 0x6efd, 0x6ef6, 0x6f39,
+ 0x6f1c, 0x6efc, 0x6f3a, 0x6f1f, 0x6f0d, 0x6f1e, 0x6f08, 0x6f21,
+ 0x7187, 0x7190, 0x7189, 0x7180, 0x7185, 0x7182, 0x718f, 0x717b,
+ 0x7186, 0x7181, 0x7197, 0x7244, 0x7253, 0x7297, 0x7295, 0x7293,
+ 0x7343, 0x734d, 0x7351, 0x734c, 0x7462, 0x7473, 0x7471, 0x7475,
+ 0x7472, 0x7467, 0x746e, 0x7500, 0x7502, 0x7503, 0x757d, 0x7590,
+ 0x7616, 0x7608, 0x760c, 0x7615, 0x7611, 0x760a, 0x7614, 0x76b8,
+ 0x7781, 0x777c, 0x7785, 0x7782, 0x776e, 0x7780, 0x776f, 0x777e,
+ 0x7783, 0x78b2, 0x78aa, 0x78b4, 0x78ad, 0x78a8, 0x787e, 0x78ab,
+ 0x789e, 0x78a5, 0x78a0, 0x78ac, 0x78a2, 0x78a4, 0x7998, 0x798a,
+ 0x798b, 0x7996, 0x7995, 0x7994, 0x7993,
+ /* 0xe3 */
+ 0x7997, 0x7988, 0x7992, 0x7990, 0x7a2b, 0x7a4a, 0x7a30, 0x7a2f,
+ 0x7a28, 0x7a26, 0x7aa8, 0x7aab, 0x7aac, 0x7aee, 0x7b88, 0x7b9c,
+ 0x7b8a, 0x7b91, 0x7b90, 0x7b96, 0x7b8d, 0x7b8c, 0x7b9b, 0x7b8e,
+ 0x7b85, 0x7b98, 0x5284, 0x7b99, 0x7ba4, 0x7b82, 0x7cbb, 0x7cbf,
+ 0x7cbc, 0x7cba, 0x7da7, 0x7db7, 0x7dc2, 0x7da3, 0x7daa, 0x7dc1,
+ 0x7dc0, 0x7dc5, 0x7d9d, 0x7dce, 0x7dc4, 0x7dc6, 0x7dcb, 0x7dcc,
+ 0x7daf, 0x7db9, 0x7d96, 0x7dbc, 0x7d9f, 0x7da6, 0x7dae, 0x7da9,
+ 0x7da1, 0x7dc9, 0x7f73, 0x7fe2, 0x7fe3, 0x7fe5, 0x7fde, 0x8024,
+ 0x805d, 0x805c, 0x8189, 0x8186, 0x8183, 0x8187, 0x818d, 0x818c,
+ 0x818b, 0x8215, 0x8497, 0x84a4, 0x84a1, 0x849f, 0x84ba, 0x84ce,
+ 0x84c2, 0x84ac, 0x84ae, 0x84ab, 0x84b9, 0x84b4, 0x84c1, 0x84cd,
+ 0x84aa, 0x849a, 0x84b1, 0x84d0, 0x849d, 0x84a7, 0x84bb, 0x84a2,
+ 0x8494, 0x84c7, 0x84cc, 0x849b, 0x84a9, 0x84af, 0x84a8, 0x84d6,
+ 0x8498, 0x84b6, 0x84cf, 0x84a0, 0x84d7, 0x84d4, 0x84d2, 0x84db,
+ 0x84b0, 0x8491, 0x8661, 0x8733, 0x8723, 0x8728, 0x876b, 0x8740,
+ 0x872e, 0x871e, 0x8721, 0x8719, 0x871b, 0x8743, 0x872c, 0x8741,
+ 0x873e, 0x8746, 0x8720, 0x8732, 0x872a, 0x872d, 0x873c, 0x8712,
+ 0x873a, 0x8731, 0x8735, 0x8742, 0x8726, 0x8727, 0x8738, 0x8724,
+ 0x871a, 0x8730, 0x8711, 0x88f7, 0x88e7, 0x88f1, 0x88f2, 0x88fa,
+ 0x88fe, 0x88ee, 0x88fc, 0x88f6, 0x88fb,
+ /* 0xe4 */
+ 0x88f0, 0x88ec, 0x88eb, 0x899d, 0x89a1, 0x899f, 0x899e, 0x89e9,
+ 0x89eb, 0x89e8, 0x8aab, 0x8a99, 0x8a8b, 0x8a92, 0x8a8f, 0x8a96,
+ 0x8c3d, 0x8c68, 0x8c69, 0x8cd5, 0x8ccf, 0x8cd7, 0x8d96, 0x8e09,
+ 0x8e02, 0x8dff, 0x8e0d, 0x8dfd, 0x8e0a, 0x8e03, 0x8e07, 0x8e06,
+ 0x8e05, 0x8dfe, 0x8e00, 0x8e04, 0x8f10, 0x8f11, 0x8f0e, 0x8f0d,
+ 0x9123, 0x911c, 0x9120, 0x9122, 0x911f, 0x911d, 0x911a, 0x9124,
+ 0x9121, 0x911b, 0x917a, 0x9172, 0x9179, 0x9173, 0x92a5, 0x92a4,
+ 0x9276, 0x929b, 0x927a, 0x92a0, 0x9294, 0x92aa, 0x928d, 0x92a6,
+ 0x929a, 0x92ab, 0x9279, 0x9297, 0x927f, 0x92a3, 0x92ee, 0x928e,
+ 0x9282, 0x9295, 0x92a2, 0x927d, 0x9288, 0x92a1, 0x928a, 0x9286,
+ 0x928c, 0x9299, 0x92a7, 0x927e, 0x9287, 0x92a9, 0x929d, 0x928b,
+ 0x922d, 0x969e, 0x96a1, 0x96ff, 0x9758, 0x977d, 0x977a, 0x977e,
+ 0x9783, 0x9780, 0x9782, 0x977b, 0x9784, 0x9781, 0x977f, 0x97ce,
+ 0x97cd, 0x9816, 0x98ad, 0x98ae, 0x9902, 0x9900, 0x9907, 0x999d,
+ 0x999c, 0x99c3, 0x99b9, 0x99bb, 0x99ba, 0x99c2, 0x99bd, 0x99c7,
+ 0x9ab1, 0x9ae3, 0x9ae7, 0x9b3e, 0x9b3f, 0x9b60, 0x9b61, 0x9b5f,
+ 0x9cf1, 0x9cf2, 0x9cf5, 0x9ea7, 0x50ff, 0x5103, 0x5130, 0x50f8,
+ 0x5106, 0x5107, 0x50f6, 0x50fe, 0x510b, 0x510c, 0x50fd, 0x510a,
+ 0x528b, 0x528c, 0x52f1, 0x52ef, 0x5648, 0x5642, 0x564c, 0x5635,
+ 0x5641, 0x564a, 0x5649, 0x5646, 0x5658,
+ /* 0xe5 */
+ 0x565a, 0x5640, 0x5633, 0x563d, 0x562c, 0x563e, 0x5638, 0x562a,
+ 0x563a, 0x571a, 0x58ab, 0x589d, 0x58b1, 0x58a0, 0x58a3, 0x58af,
+ 0x58ac, 0x58a5, 0x58a1, 0x58ff, 0x5aff, 0x5af4, 0x5afd, 0x5af7,
+ 0x5af6, 0x5b03, 0x5af8, 0x5b02, 0x5af9, 0x5b01, 0x5b07, 0x5b05,
+ 0x5b0f, 0x5c67, 0x5d99, 0x5d97, 0x5d9f, 0x5d92, 0x5da2, 0x5d93,
+ 0x5d95, 0x5da0, 0x5d9c, 0x5da1, 0x5d9a, 0x5d9e, 0x5e69, 0x5e5d,
+ 0x5e60, 0x5e5c, 0x7df3, 0x5edb, 0x5ede, 0x5ee1, 0x5f49, 0x5fb2,
+ 0x618b, 0x6183, 0x6179, 0x61b1, 0x61b0, 0x61a2, 0x6189, 0x619b,
+ 0x6193, 0x61af, 0x61ad, 0x619f, 0x6192, 0x61aa, 0x61a1, 0x618d,
+ 0x6166, 0x61b3, 0x622d, 0x646e, 0x6470, 0x6496, 0x64a0, 0x6485,
+ 0x6497, 0x649c, 0x648f, 0x648b, 0x648a, 0x648c, 0x64a3, 0x649f,
+ 0x6468, 0x64b1, 0x6498, 0x6576, 0x657a, 0x6579, 0x657b, 0x65b2,
+ 0x65b3, 0x66b5, 0x66b0, 0x66a9, 0x66b2, 0x66b7, 0x66aa, 0x66af,
+ 0x6a00, 0x6a06, 0x6a17, 0x69e5, 0x69f8, 0x6a15, 0x69f1, 0x69e4,
+ 0x6a20, 0x69ff, 0x69ec, 0x69e2, 0x6a1b, 0x6a1d, 0x69fe, 0x6a27,
+ 0x69f2, 0x69ee, 0x6a14, 0x69f7, 0x69e7, 0x6a40, 0x6a08, 0x69e6,
+ 0x69fb, 0x6a0d, 0x69fc, 0x69eb, 0x6a09, 0x6a04, 0x6a18, 0x6a25,
+ 0x6a0f, 0x69f6, 0x6a26, 0x6a07, 0x69f4, 0x6a16, 0x6b51, 0x6ba5,
+ 0x6ba3, 0x6ba2, 0x6ba6, 0x6c01, 0x6c00, 0x6bff, 0x6c02, 0x6f41,
+ 0x6f26, 0x6f7e, 0x6f87, 0x6fc6, 0x6f92,
+ /* 0xe6 */
+ 0x6f8d, 0x6f89, 0x6f8c, 0x6f62, 0x6f4f, 0x6f85, 0x6f5a, 0x6f96,
+ 0x6f76, 0x6f6c, 0x6f82, 0x6f55, 0x6f72, 0x6f52, 0x6f50, 0x6f57,
+ 0x6f94, 0x6f93, 0x6f5d, 0x6f00, 0x6f61, 0x6f6b, 0x6f7d, 0x6f67,
+ 0x6f90, 0x6f53, 0x6f8b, 0x6f69, 0x6f7f, 0x6f95, 0x6f63, 0x6f77,
+ 0x6f6a, 0x6f7b, 0x71b2, 0x71af, 0x719b, 0x71b0, 0x71a0, 0x719a,
+ 0x71a9, 0x71b5, 0x719d, 0x71a5, 0x719e, 0x71a4, 0x71a1, 0x71aa,
+ 0x719c, 0x71a7, 0x71b3, 0x7298, 0x729a, 0x7358, 0x7352, 0x735e,
+ 0x735f, 0x7360, 0x735d, 0x735b, 0x7361, 0x735a, 0x7359, 0x7362,
+ 0x7487, 0x7489, 0x748a, 0x7486, 0x7481, 0x747d, 0x7485, 0x7488,
+ 0x747c, 0x7479, 0x7508, 0x7507, 0x757e, 0x7625, 0x761e, 0x7619,
+ 0x761d, 0x761c, 0x7623, 0x761a, 0x7628, 0x761b, 0x769c, 0x769d,
+ 0x769e, 0x769b, 0x778d, 0x778f, 0x7789, 0x7788, 0x78cd, 0x78bb,
+ 0x78cf, 0x78cc, 0x78d1, 0x78ce, 0x78d4, 0x78c8, 0x78c3, 0x78c4,
+ 0x78c9, 0x799a, 0x79a1, 0x79a0, 0x799c, 0x79a2, 0x799b, 0x6b76,
+ 0x7a39, 0x7ab2, 0x7ab4, 0x7ab3, 0x7bb7, 0x7bcb, 0x7bbe, 0x7bac,
+ 0x7bce, 0x7baf, 0x7bb9, 0x7bca, 0x7bb5, 0x7cc5, 0x7cc8, 0x7ccc,
+ 0x7ccb, 0x7df7, 0x7ddb, 0x7dea, 0x7de7, 0x7dd7, 0x7de1, 0x7e03,
+ 0x7dfa, 0x7de6, 0x7df6, 0x7df1, 0x7df0, 0x7dee, 0x7ddf, 0x7f76,
+ 0x7fac, 0x7fb0, 0x7fad, 0x7fed, 0x7feb, 0x7fea, 0x7fec, 0x7fe6,
+ 0x7fe8, 0x8064, 0x8067, 0x81a3, 0x819f,
+ /* 0xe7 */
+ 0x819e, 0x8195, 0x81a2, 0x8199, 0x8197, 0x8216, 0x824f, 0x8253,
+ 0x8252, 0x8250, 0x824e, 0x8251, 0x8524, 0x853b, 0x850f, 0x8500,
+ 0x8529, 0x850e, 0x8509, 0x850d, 0x851f, 0x850a, 0x8527, 0x851c,
+ 0x84fb, 0x852b, 0x84fa, 0x8508, 0x850c, 0x84f4, 0x852a, 0x84f2,
+ 0x8515, 0x84f7, 0x84eb, 0x84f3, 0x84fc, 0x8512, 0x84ea, 0x84e9,
+ 0x8516, 0x84fe, 0x8528, 0x851d, 0x852e, 0x8502, 0x84fd, 0x851e,
+ 0x84f6, 0x8531, 0x8526, 0x84e7, 0x84e8, 0x84f0, 0x84ef, 0x84f9,
+ 0x8518, 0x8520, 0x8530, 0x850b, 0x8519, 0x852f, 0x8662, 0x8756,
+ 0x8763, 0x8764, 0x8777, 0x87e1, 0x8773, 0x8758, 0x8754, 0x875b,
+ 0x8752, 0x8761, 0x875a, 0x8751, 0x875e, 0x876d, 0x876a, 0x8750,
+ 0x874e, 0x875f, 0x875d, 0x876f, 0x876c, 0x877a, 0x876e, 0x875c,
+ 0x8765, 0x874f, 0x877b, 0x8775, 0x8762, 0x8767, 0x8769, 0x885a,
+ 0x8905, 0x890c, 0x8914, 0x890b, 0x8917, 0x8918, 0x8919, 0x8906,
+ 0x8916, 0x8911, 0x890e, 0x8909, 0x89a2, 0x89a4, 0x89a3, 0x89ed,
+ 0x89f0, 0x89ec, 0x8acf, 0x8ac6, 0x8ab8, 0x8ad3, 0x8ad1, 0x8ad4,
+ 0x8ad5, 0x8abb, 0x8ad7, 0x8abe, 0x8ac0, 0x8ac5, 0x8ad8, 0x8ac3,
+ 0x8aba, 0x8abd, 0x8ad9, 0x8c3e, 0x8c4d, 0x8c8f, 0x8ce5, 0x8cdf,
+ 0x8cd9, 0x8ce8, 0x8cda, 0x8cdd, 0x8ce7, 0x8da0, 0x8d9c, 0x8da1,
+ 0x8d9b, 0x8e20, 0x8e23, 0x8e25, 0x8e24, 0x8e2e, 0x8e15, 0x8e1b,
+ 0x8e16, 0x8e11, 0x8e19, 0x8e26, 0x8e27,
+ /* 0xe8 */
+ 0x8e14, 0x8e12, 0x8e18, 0x8e13, 0x8e1c, 0x8e17, 0x8e1a, 0x8f2c,
+ 0x8f24, 0x8f18, 0x8f1a, 0x8f20, 0x8f23, 0x8f16, 0x8f17, 0x9073,
+ 0x9070, 0x906f, 0x9067, 0x906b, 0x912f, 0x912b, 0x9129, 0x912a,
+ 0x9132, 0x9126, 0x912e, 0x9185, 0x9186, 0x918a, 0x9181, 0x9182,
+ 0x9184, 0x9180, 0x92d0, 0x92c3, 0x92c4, 0x92c0, 0x92d9, 0x92b6,
+ 0x92cf, 0x92f1, 0x92df, 0x92d8, 0x92e9, 0x92d7, 0x92dd, 0x92cc,
+ 0x92ef, 0x92c2, 0x92e8, 0x92ca, 0x92c8, 0x92ce, 0x92e6, 0x92cd,
+ 0x92d5, 0x92c9, 0x92e0, 0x92de, 0x92e7, 0x92d1, 0x92d3, 0x92b5,
+ 0x92e1, 0x92c6, 0x92b4, 0x957c, 0x95ac, 0x95ab, 0x95ae, 0x95b0,
+ 0x96a4, 0x96a2, 0x96d3, 0x9705, 0x9708, 0x9702, 0x975a, 0x978a,
+ 0x978e, 0x9788, 0x97d0, 0x97cf, 0x981e, 0x981d, 0x9826, 0x9829,
+ 0x9828, 0x9820, 0x981b, 0x9827, 0x98b2, 0x9908, 0x98fa, 0x9911,
+ 0x9914, 0x9916, 0x9917, 0x9915, 0x99dc, 0x99cd, 0x99cf, 0x99d3,
+ 0x99d4, 0x99ce, 0x99c9, 0x99d6, 0x99d8, 0x99cb, 0x99d7, 0x99cc,
+ 0x9ab3, 0x9aec, 0x9aeb, 0x9af3, 0x9af2, 0x9af1, 0x9b46, 0x9b43,
+ 0x9b67, 0x9b74, 0x9b71, 0x9b66, 0x9b76, 0x9b75, 0x9b70, 0x9b68,
+ 0x9b64, 0x9b6c, 0x9cfc, 0x9cfa, 0x9cfd, 0x9cff, 0x9cf7, 0x9d07,
+ 0x9d00, 0x9cf9, 0x9cfb, 0x9d08, 0x9d05, 0x9d04, 0x9e83, 0x9ed3,
+ 0x9f0f, 0x9f10, 0x511c, 0x5113, 0x5117, 0x511a, 0x5111, 0x51de,
+ 0x5334, 0x53e1, 0x5670, 0x5660, 0x566e,
+ /* 0xe9 */
+ 0x5673, 0x5666, 0x5663, 0x566d, 0x5672, 0x565e, 0x5677, 0x571c,
+ 0x571b, 0x58c8, 0x58bd, 0x58c9, 0x58bf, 0x58ba, 0x58c2, 0x58bc,
+ 0x58c6, 0x5b17, 0x5b19, 0x5b1b, 0x5b21, 0x5b14, 0x5b13, 0x5b10,
+ 0x5b16, 0x5b28, 0x5b1a, 0x5b20, 0x5b1e, 0x5bef, 0x5dac, 0x5db1,
+ 0x5da9, 0x5da7, 0x5db5, 0x5db0, 0x5dae, 0x5daa, 0x5da8, 0x5db2,
+ 0x5dad, 0x5daf, 0x5db4, 0x5e67, 0x5e68, 0x5e66, 0x5e6f, 0x5ee9,
+ 0x5ee7, 0x5ee6, 0x5ee8, 0x5ee5, 0x5f4b, 0x5fbc, 0x619d, 0x61a8,
+ 0x6196, 0x61c5, 0x61b4, 0x61c6, 0x61c1, 0x61cc, 0x61ba, 0x61bf,
+ 0x61b8, 0x618c, 0x64d7, 0x64d6, 0x64d0, 0x64cf, 0x64c9, 0x64bd,
+ 0x6489, 0x64c3, 0x64db, 0x64f3, 0x64d9, 0x6533, 0x657f, 0x657c,
+ 0x65a2, 0x66c8, 0x66be, 0x66c0, 0x66ca, 0x66cb, 0x66cf, 0x66bd,
+ 0x66bb, 0x66ba, 0x66cc, 0x6723, 0x6a34, 0x6a66, 0x6a49, 0x6a67,
+ 0x6a32, 0x6a68, 0x6a3e, 0x6a5d, 0x6a6d, 0x6a76, 0x6a5b, 0x6a51,
+ 0x6a28, 0x6a5a, 0x6a3b, 0x6a3f, 0x6a41, 0x6a6a, 0x6a64, 0x6a50,
+ 0x6a4f, 0x6a54, 0x6a6f, 0x6a69, 0x6a60, 0x6a3c, 0x6a5e, 0x6a56,
+ 0x6a55, 0x6a4d, 0x6a4e, 0x6a46, 0x6b55, 0x6b54, 0x6b56, 0x6ba7,
+ 0x6baa, 0x6bab, 0x6bc8, 0x6bc7, 0x6c04, 0x6c03, 0x6c06, 0x6fad,
+ 0x6fcb, 0x6fa3, 0x6fc7, 0x6fbc, 0x6fce, 0x6fc8, 0x6f5e, 0x6fc4,
+ 0x6fbd, 0x6f9e, 0x6fca, 0x6fa8, 0x7004, 0x6fa5, 0x6fae, 0x6fba,
+ 0x6fac, 0x6faa, 0x6fcf, 0x6fbf, 0x6fb8,
+ /* 0xea */
+ 0x6fa2, 0x6fc9, 0x6fab, 0x6fcd, 0x6faf, 0x6fb2, 0x6fb0, 0x71c5,
+ 0x71c2, 0x71bf, 0x71b8, 0x71d6, 0x71c0, 0x71c1, 0x71cb, 0x71d4,
+ 0x71ca, 0x71c7, 0x71cf, 0x71bd, 0x71d8, 0x71bc, 0x71c6, 0x71da,
+ 0x71db, 0x729d, 0x729e, 0x7369, 0x7366, 0x7367, 0x736c, 0x7365,
+ 0x736b, 0x736a, 0x747f, 0x749a, 0x74a0, 0x7494, 0x7492, 0x7495,
+ 0x74a1, 0x750b, 0x7580, 0x762f, 0x762d, 0x7631, 0x763d, 0x7633,
+ 0x763c, 0x7635, 0x7632, 0x7630, 0x76bb, 0x76e6, 0x779a, 0x779d,
+ 0x77a1, 0x779c, 0x779b, 0x77a2, 0x77a3, 0x7795, 0x7799, 0x7797,
+ 0x78dd, 0x78e9, 0x78e5, 0x78ea, 0x78de, 0x78e3, 0x78db, 0x78e1,
+ 0x78e2, 0x78ed, 0x78df, 0x78e0, 0x79a4, 0x7a44, 0x7a48, 0x7a47,
+ 0x7ab6, 0x7ab8, 0x7ab5, 0x7ab1, 0x7ab7, 0x7bde, 0x7be3, 0x7be7,
+ 0x7bdd, 0x7bd5, 0x7be5, 0x7bda, 0x7be8, 0x7bf9, 0x7bd4, 0x7bea,
+ 0x7be2, 0x7bdc, 0x7beb, 0x7bd8, 0x7bdf, 0x7cd2, 0x7cd4, 0x7cd7,
+ 0x7cd0, 0x7cd1, 0x7e12, 0x7e21, 0x7e17, 0x7e0c, 0x7e1f, 0x7e20,
+ 0x7e13, 0x7e0e, 0x7e1c, 0x7e15, 0x7e1a, 0x7e22, 0x7e0b, 0x7e0f,
+ 0x7e16, 0x7e0d, 0x7e14, 0x7e25, 0x7e24, 0x7f43, 0x7f7b, 0x7f7c,
+ 0x7f7a, 0x7fb1, 0x7fef, 0x802a, 0x8029, 0x806c, 0x81b1, 0x81a6,
+ 0x81ae, 0x81b9, 0x81b5, 0x81ab, 0x81b0, 0x81ac, 0x81b4, 0x81b2,
+ 0x81b7, 0x81a7, 0x81f2, 0x8255, 0x8256, 0x8257, 0x8556, 0x8545,
+ 0x856b, 0x854d, 0x8553, 0x8561, 0x8558,
+ /* 0xeb */
+ 0x8540, 0x8546, 0x8564, 0x8541, 0x8562, 0x8544, 0x8551, 0x8547,
+ 0x8563, 0x853e, 0x855b, 0x8571, 0x854e, 0x856e, 0x8575, 0x8555,
+ 0x8567, 0x8560, 0x858c, 0x8566, 0x855d, 0x8554, 0x8565, 0x856c,
+ 0x8663, 0x8665, 0x8664, 0x879b, 0x878f, 0x8797, 0x8793, 0x8792,
+ 0x8788, 0x8781, 0x8796, 0x8798, 0x8779, 0x8787, 0x87a3, 0x8785,
+ 0x8790, 0x8791, 0x879d, 0x8784, 0x8794, 0x879c, 0x879a, 0x8789,
+ 0x891e, 0x8926, 0x8930, 0x892d, 0x892e, 0x8927, 0x8931, 0x8922,
+ 0x8929, 0x8923, 0x892f, 0x892c, 0x891f, 0x89f1, 0x8ae0, 0x8ae2,
+ 0x8af2, 0x8af4, 0x8af5, 0x8add, 0x8b14, 0x8ae4, 0x8adf, 0x8af0,
+ 0x8ac8, 0x8ade, 0x8ae1, 0x8ae8, 0x8aff, 0x8aef, 0x8afb, 0x8c91,
+ 0x8c92, 0x8c90, 0x8cf5, 0x8cee, 0x8cf1, 0x8cf0, 0x8cf3, 0x8d6c,
+ 0x8d6e, 0x8da5, 0x8da7, 0x8e33, 0x8e3e, 0x8e38, 0x8e40, 0x8e45,
+ 0x8e36, 0x8e3c, 0x8e3d, 0x8e41, 0x8e30, 0x8e3f, 0x8ebd, 0x8f36,
+ 0x8f2e, 0x8f35, 0x8f32, 0x8f39, 0x8f37, 0x8f34, 0x9076, 0x9079,
+ 0x907b, 0x9086, 0x90fa, 0x9133, 0x9135, 0x9136, 0x9193, 0x9190,
+ 0x9191, 0x918d, 0x918f, 0x9327, 0x931e, 0x9308, 0x931f, 0x9306,
+ 0x930f, 0x937a, 0x9338, 0x933c, 0x931b, 0x9323, 0x9312, 0x9301,
+ 0x9346, 0x932d, 0x930e, 0x930d, 0x92cb, 0x931d, 0x92fa, 0x9325,
+ 0x9313, 0x92f9, 0x92f7, 0x9334, 0x9302, 0x9324, 0x92ff, 0x9329,
+ 0x9339, 0x9335, 0x932a, 0x9314, 0x930c,
+ /* 0xec */
+ 0x930b, 0x92fe, 0x9309, 0x9300, 0x92fb, 0x9316, 0x95bc, 0x95cd,
+ 0x95be, 0x95b9, 0x95ba, 0x95b6, 0x95bf, 0x95b5, 0x95bd, 0x96a9,
+ 0x96d4, 0x970b, 0x9712, 0x9710, 0x9799, 0x9797, 0x9794, 0x97f0,
+ 0x97f8, 0x9835, 0x982f, 0x9832, 0x9924, 0x991f, 0x9927, 0x9929,
+ 0x999e, 0x99ee, 0x99ec, 0x99e5, 0x99e4, 0x99f0, 0x99e3, 0x99ea,
+ 0x99e9, 0x99e7, 0x9ab9, 0x9abf, 0x9ab4, 0x9abb, 0x9af6, 0x9afa,
+ 0x9af9, 0x9af7, 0x9b33, 0x9b80, 0x9b85, 0x9b87, 0x9b7c, 0x9b7e,
+ 0x9b7b, 0x9b82, 0x9b93, 0x9b92, 0x9b90, 0x9b7a, 0x9b95, 0x9b7d,
+ 0x9b88, 0x9d25, 0x9d17, 0x9d20, 0x9d1e, 0x9d14, 0x9d29, 0x9d1d,
+ 0x9d18, 0x9d22, 0x9d10, 0x9d19, 0x9d1f, 0x9e88, 0x9e86, 0x9e87,
+ 0x9eae, 0x9ead, 0x9ed5, 0x9ed6, 0x9efa, 0x9f12, 0x9f3d, 0x5126,
+ 0x5125, 0x5122, 0x5124, 0x5120, 0x5129, 0x52f4, 0x5693, 0x568c,
+ 0x568d, 0x5686, 0x5684, 0x5683, 0x567e, 0x5682, 0x567f, 0x5681,
+ 0x58d6, 0x58d4, 0x58cf, 0x58d2, 0x5b2d, 0x5b25, 0x5b32, 0x5b23,
+ 0x5b2c, 0x5b27, 0x5b26, 0x5b2f, 0x5b2e, 0x5b7b, 0x5bf1, 0x5bf2,
+ 0x5db7, 0x5e6c, 0x5e6a, 0x5fbe, 0x5fbb, 0x61c3, 0x61b5, 0x61bc,
+ 0x61e7, 0x61e0, 0x61e5, 0x61e4, 0x61e8, 0x61de, 0x64ef, 0x64e9,
+ 0x64e3, 0x64eb, 0x64e4, 0x64e8, 0x6581, 0x6580, 0x65b6, 0x65da,
+ 0x66d2, 0x6a8d, 0x6a96, 0x6a81, 0x6aa5, 0x6a89, 0x6a9f, 0x6a9b,
+ 0x6aa1, 0x6a9e, 0x6a87, 0x6a93, 0x6a8e,
+ /* 0xed */
+ 0x6a95, 0x6a83, 0x6aa8, 0x6aa4, 0x6a91, 0x6a7f, 0x6aa6, 0x6a9a,
+ 0x6a85, 0x6a8c, 0x6a92, 0x6b5b, 0x6bad, 0x6c09, 0x6fcc, 0x6fa9,
+ 0x6ff4, 0x6fd4, 0x6fe3, 0x6fdc, 0x6fed, 0x6fe7, 0x6fe6, 0x6fde,
+ 0x6ff2, 0x6fdd, 0x6fe2, 0x6fe8, 0x71e1, 0x71f1, 0x71e8, 0x71f2,
+ 0x71e4, 0x71f0, 0x71e2, 0x7373, 0x736e, 0x736f, 0x7497, 0x74b2,
+ 0x74ab, 0x7490, 0x74aa, 0x74ad, 0x74b1, 0x74a5, 0x74af, 0x7510,
+ 0x7511, 0x7512, 0x750f, 0x7584, 0x7643, 0x7648, 0x7649, 0x7647,
+ 0x76a4, 0x76e9, 0x77b5, 0x77ab, 0x77b2, 0x77b7, 0x77b6, 0x77b4,
+ 0x77b1, 0x77a8, 0x77f0, 0x78f3, 0x78fd, 0x7902, 0x78fb, 0x78fc,
+ 0x78f2, 0x7905, 0x78f9, 0x78fe, 0x7904, 0x79ab, 0x79a8, 0x7a5c,
+ 0x7a5b, 0x7a56, 0x7a58, 0x7a54, 0x7a5a, 0x7abe, 0x7ac0, 0x7ac1,
+ 0x7c05, 0x7c0f, 0x7bf2, 0x7c00, 0x7bff, 0x7bfb, 0x7c0e, 0x7bf4,
+ 0x7c0b, 0x7bf3, 0x7c02, 0x7c09, 0x7c03, 0x7c01, 0x7bf8, 0x7bfd,
+ 0x7c06, 0x7bf0, 0x7bf1, 0x7c10, 0x7c0a, 0x7ce8, 0x7e2d, 0x7e3c,
+ 0x7e42, 0x7e33, 0x9848, 0x7e38, 0x7e2a, 0x7e49, 0x7e40, 0x7e47,
+ 0x7e29, 0x7e4c, 0x7e30, 0x7e3b, 0x7e36, 0x7e44, 0x7e3a, 0x7f45,
+ 0x7f7f, 0x7f7e, 0x7f7d, 0x7ff4, 0x7ff2, 0x802c, 0x81bb, 0x81c4,
+ 0x81cc, 0x81ca, 0x81c5, 0x81c7, 0x81bc, 0x81e9, 0x825b, 0x825a,
+ 0x825c, 0x8583, 0x8580, 0x858f, 0x85a7, 0x8595, 0x85a0, 0x858b,
+ 0x85a3, 0x857b, 0x85a4, 0x859a, 0x859e,
+ /* 0xee */
+ 0x8577, 0x857c, 0x8589, 0x85a1, 0x857a, 0x8578, 0x8557, 0x858e,
+ 0x8596, 0x8586, 0x858d, 0x8599, 0x859d, 0x8581, 0x85a2, 0x8582,
+ 0x8588, 0x8585, 0x8579, 0x8576, 0x8598, 0x8590, 0x859f, 0x8668,
+ 0x87be, 0x87aa, 0x87ad, 0x87c5, 0x87b0, 0x87ac, 0x87b9, 0x87b5,
+ 0x87bc, 0x87ae, 0x87c9, 0x87c3, 0x87c2, 0x87cc, 0x87b7, 0x87af,
+ 0x87c4, 0x87ca, 0x87b4, 0x87b6, 0x87bf, 0x87b8, 0x87bd, 0x87de,
+ 0x87b2, 0x8935, 0x8933, 0x893c, 0x893e, 0x8941, 0x8952, 0x8937,
+ 0x8942, 0x89ad, 0x89af, 0x89ae, 0x89f2, 0x89f3, 0x8b1e, 0x8b18,
+ 0x8b16, 0x8b11, 0x8b05, 0x8b0b, 0x8b22, 0x8b0f, 0x8b12, 0x8b15,
+ 0x8b07, 0x8b0d, 0x8b08, 0x8b06, 0x8b1c, 0x8b13, 0x8b1a, 0x8c4f,
+ 0x8c70, 0x8c72, 0x8c71, 0x8c6f, 0x8c95, 0x8c94, 0x8cf9, 0x8d6f,
+ 0x8e4e, 0x8e4d, 0x8e53, 0x8e50, 0x8e4c, 0x8e47, 0x8f43, 0x8f40,
+ 0x9085, 0x907e, 0x9138, 0x919a, 0x91a2, 0x919b, 0x9199, 0x919f,
+ 0x91a1, 0x919d, 0x91a0, 0x93a1, 0x9383, 0x93af, 0x9364, 0x9356,
+ 0x9347, 0x937c, 0x9358, 0x935c, 0x9376, 0x9349, 0x9350, 0x9351,
+ 0x9360, 0x936d, 0x938f, 0x934c, 0x936a, 0x9379, 0x9357, 0x9355,
+ 0x9352, 0x934f, 0x9371, 0x9377, 0x937b, 0x9361, 0x935e, 0x9363,
+ 0x9367, 0x9380, 0x934e, 0x9359, 0x95c7, 0x95c0, 0x95c9, 0x95c3,
+ 0x95c5, 0x95b7, 0x96ae, 0x96b0, 0x96ac, 0x9720, 0x971f, 0x9718,
+ 0x971d, 0x9719, 0x979a, 0x97a1, 0x979c,
+ /* 0xef */
+ 0x979e, 0x979d, 0x97d5, 0x97d4, 0x97f1, 0x9841, 0x9844, 0x984a,
+ 0x9849, 0x9845, 0x9843, 0x9925, 0x992b, 0x992c, 0x992a, 0x9933,
+ 0x9932, 0x992f, 0x992d, 0x9931, 0x9930, 0x9998, 0x99a3, 0x99a1,
+ 0x9a02, 0x99fa, 0x99f4, 0x99f7, 0x99f9, 0x99f8, 0x99f6, 0x99fb,
+ 0x99fd, 0x99fe, 0x99fc, 0x9a03, 0x9abe, 0x9afe, 0x9afd, 0x9b01,
+ 0x9afc, 0x9b48, 0x9b9a, 0x9ba8, 0x9b9e, 0x9b9b, 0x9ba6, 0x9ba1,
+ 0x9ba5, 0x9ba4, 0x9b86, 0x9ba2, 0x9ba0, 0x9baf, 0x9d33, 0x9d41,
+ 0x9d67, 0x9d36, 0x9d2e, 0x9d2f, 0x9d31, 0x9d38, 0x9d30, 0x9d45,
+ 0x9d42, 0x9d43, 0x9d3e, 0x9d37, 0x9d40, 0x9d3d, 0x7ff5, 0x9d2d,
+ 0x9e8a, 0x9e89, 0x9e8d, 0x9eb0, 0x9ec8, 0x9eda, 0x9efb, 0x9eff,
+ 0x9f24, 0x9f23, 0x9f22, 0x9f54, 0x9fa0, 0x5131, 0x512d, 0x512e,
+ 0x5698, 0x569c, 0x5697, 0x569a, 0x569d, 0x5699, 0x5970, 0x5b3c,
+ 0x5c69, 0x5c6a, 0x5dc0, 0x5e6d, 0x5e6e, 0x61d8, 0x61df, 0x61ed,
+ 0x61ee, 0x61f1, 0x61ea, 0x61f0, 0x61eb, 0x61d6, 0x61e9, 0x64ff,
+ 0x6504, 0x64fd, 0x64f8, 0x6501, 0x6503, 0x64fc, 0x6594, 0x65db,
+ 0x66da, 0x66db, 0x66d8, 0x6ac5, 0x6ab9, 0x6abd, 0x6ae1, 0x6ac6,
+ 0x6aba, 0x6ab6, 0x6ab7, 0x6ac7, 0x6ab4, 0x6aad, 0x6b5e, 0x6bc9,
+ 0x6c0b, 0x7007, 0x700c, 0x700d, 0x7001, 0x7005, 0x7014, 0x700e,
+ 0x6fff, 0x7000, 0x6ffb, 0x7026, 0x6ffc, 0x6ff7, 0x700a, 0x7201,
+ 0x71ff, 0x71f9, 0x7203, 0x71fd, 0x7376,
+ /* 0xf0 */
+ 0x74b8, 0x74c0, 0x74b5, 0x74c1, 0x74be, 0x74b6, 0x74bb, 0x74c2,
+ 0x7514, 0x7513, 0x765c, 0x7664, 0x7659, 0x7650, 0x7653, 0x7657,
+ 0x765a, 0x76a6, 0x76bd, 0x76ec, 0x77c2, 0x77ba, 0x78ff, 0x790c,
+ 0x7913, 0x7914, 0x7909, 0x7910, 0x7912, 0x7911, 0x79ad, 0x79ac,
+ 0x7a5f, 0x7c1c, 0x7c29, 0x7c19, 0x7c20, 0x7c1f, 0x7c2d, 0x7c1d,
+ 0x7c26, 0x7c28, 0x7c22, 0x7c25, 0x7c30, 0x7e5c, 0x7e50, 0x7e56,
+ 0x7e63, 0x7e58, 0x7e62, 0x7e5f, 0x7e51, 0x7e60, 0x7e57, 0x7e53,
+ 0x7fb5, 0x7fb3, 0x7ff7, 0x7ff8, 0x8075, 0x81d1, 0x81d2, 0x81d0,
+ 0x825f, 0x825e, 0x85b4, 0x85c6, 0x85c0, 0x85c3, 0x85c2, 0x85b3,
+ 0x85b5, 0x85bd, 0x85c7, 0x85c4, 0x85bf, 0x85cb, 0x85ce, 0x85c8,
+ 0x85c5, 0x85b1, 0x85b6, 0x85d2, 0x8624, 0x85b8, 0x85b7, 0x85be,
+ 0x8669, 0x87e7, 0x87e6, 0x87e2, 0x87db, 0x87eb, 0x87ea, 0x87e5,
+ 0x87df, 0x87f3, 0x87e4, 0x87d4, 0x87dc, 0x87d3, 0x87ed, 0x87d8,
+ 0x87e3, 0x87a4, 0x87d7, 0x87d9, 0x8801, 0x87f4, 0x87e8, 0x87dd,
+ 0x8953, 0x894b, 0x894f, 0x894c, 0x8946, 0x8950, 0x8951, 0x8949,
+ 0x8b2a, 0x8b27, 0x8b23, 0x8b33, 0x8b30, 0x8b35, 0x8b47, 0x8b2f,
+ 0x8b3c, 0x8b3e, 0x8b31, 0x8b25, 0x8b37, 0x8b26, 0x8b36, 0x8b2e,
+ 0x8b24, 0x8b3b, 0x8b3d, 0x8b3a, 0x8c42, 0x8c75, 0x8c99, 0x8c98,
+ 0x8c97, 0x8cfe, 0x8d04, 0x8d02, 0x8d00, 0x8e5c, 0x8e62, 0x8e60,
+ 0x8e57, 0x8e56, 0x8e5e, 0x8e65, 0x8e67,
+ /* 0xf1 */
+ 0x8e5b, 0x8e5a, 0x8e61, 0x8e5d, 0x8e69, 0x8e54, 0x8f46, 0x8f47,
+ 0x8f48, 0x8f4b, 0x9128, 0x913a, 0x913b, 0x913e, 0x91a8, 0x91a5,
+ 0x91a7, 0x91af, 0x91aa, 0x93b5, 0x938c, 0x9392, 0x93b7, 0x939b,
+ 0x939d, 0x9389, 0x93a7, 0x938e, 0x93aa, 0x939e, 0x93a6, 0x9395,
+ 0x9388, 0x9399, 0x939f, 0x938d, 0x93b1, 0x9391, 0x93b2, 0x93a4,
+ 0x93a8, 0x93b4, 0x93a3, 0x93a5, 0x95d2, 0x95d3, 0x95d1, 0x96b3,
+ 0x96d7, 0x96da, 0x5dc2, 0x96df, 0x96d8, 0x96dd, 0x9723, 0x9722,
+ 0x9725, 0x97ac, 0x97ae, 0x97a8, 0x97ab, 0x97a4, 0x97aa, 0x97a2,
+ 0x97a5, 0x97d7, 0x97d9, 0x97d6, 0x97d8, 0x97fa, 0x9850, 0x9851,
+ 0x9852, 0x98b8, 0x9941, 0x993c, 0x993a, 0x9a0f, 0x9a0b, 0x9a09,
+ 0x9a0d, 0x9a04, 0x9a11, 0x9a0a, 0x9a05, 0x9a07, 0x9a06, 0x9ac0,
+ 0x9adc, 0x9b08, 0x9b04, 0x9b05, 0x9b29, 0x9b35, 0x9b4a, 0x9b4c,
+ 0x9b4b, 0x9bc7, 0x9bc6, 0x9bc3, 0x9bbf, 0x9bc1, 0x9bb5, 0x9bb8,
+ 0x9bd3, 0x9bb6, 0x9bc4, 0x9bb9, 0x9bbd, 0x9d5c, 0x9d53, 0x9d4f,
+ 0x9d4a, 0x9d5b, 0x9d4b, 0x9d59, 0x9d56, 0x9d4c, 0x9d57, 0x9d52,
+ 0x9d54, 0x9d5f, 0x9d58, 0x9d5a, 0x9e8e, 0x9e8c, 0x9edf, 0x9f01,
+ 0x9f00, 0x9f16, 0x9f25, 0x9f2b, 0x9f2a, 0x9f29, 0x9f28, 0x9f4c,
+ 0x9f55, 0x5134, 0x5135, 0x5296, 0x52f7, 0x53b4, 0x56ab, 0x56ad,
+ 0x56a6, 0x56a7, 0x56aa, 0x56ac, 0x58da, 0x58dd, 0x58db, 0x5912,
+ 0x5b3d, 0x5b3e, 0x5b3f, 0x5dc3, 0x5e70,
+ /* 0xf2 */
+ 0x5fbf, 0x61fb, 0x6507, 0x6510, 0x650d, 0x6509, 0x650c, 0x650e,
+ 0x6584, 0x65de, 0x65dd, 0x66de, 0x6ae7, 0x6ae0, 0x6acc, 0x6ad1,
+ 0x6ad9, 0x6acb, 0x6adf, 0x6adc, 0x6ad0, 0x6aeb, 0x6acf, 0x6acd,
+ 0x6ade, 0x6b60, 0x6bb0, 0x6c0c, 0x7019, 0x7027, 0x7020, 0x7016,
+ 0x702b, 0x7021, 0x7022, 0x7023, 0x7029, 0x7017, 0x7024, 0x701c,
+ 0x702a, 0x720c, 0x720a, 0x7207, 0x7202, 0x7205, 0x72a5, 0x72a6,
+ 0x72a4, 0x72a3, 0x72a1, 0x74cb, 0x74c5, 0x74b7, 0x74c3, 0x7516,
+ 0x7660, 0x77c9, 0x77ca, 0x77c4, 0x77f1, 0x791d, 0x791b, 0x7921,
+ 0x791c, 0x7917, 0x791e, 0x79b0, 0x7a67, 0x7a68, 0x7c33, 0x7c3c,
+ 0x7c39, 0x7c2c, 0x7c3b, 0x7cec, 0x7cea, 0x7e76, 0x7e75, 0x7e78,
+ 0x7e70, 0x7e77, 0x7e6f, 0x7e7a, 0x7e72, 0x7e74, 0x7e68, 0x7f4b,
+ 0x7f4a, 0x7f83, 0x7f86, 0x7fb7, 0x7ffd, 0x7ffe, 0x8078, 0x81d7,
+ 0x81d5, 0x8264, 0x8261, 0x8263, 0x85eb, 0x85f1, 0x85ed, 0x85d9,
+ 0x85e1, 0x85e8, 0x85da, 0x85d7, 0x85ec, 0x85f2, 0x85f8, 0x85d8,
+ 0x85df, 0x85e3, 0x85dc, 0x85d1, 0x85f0, 0x85e6, 0x85ef, 0x85de,
+ 0x85e2, 0x8800, 0x87fa, 0x8803, 0x87f6, 0x87f7, 0x8809, 0x880c,
+ 0x880b, 0x8806, 0x87fc, 0x8808, 0x87ff, 0x880a, 0x8802, 0x8962,
+ 0x895a, 0x895b, 0x8957, 0x8961, 0x895c, 0x8958, 0x895d, 0x8959,
+ 0x8988, 0x89b7, 0x89b6, 0x89f6, 0x8b50, 0x8b48, 0x8b4a, 0x8b40,
+ 0x8b53, 0x8b56, 0x8b54, 0x8b4b, 0x8b55,
+ /* 0xf3 */
+ 0x8b51, 0x8b42, 0x8b52, 0x8b57, 0x8c43, 0x8c77, 0x8c76, 0x8c9a,
+ 0x8d06, 0x8d07, 0x8d09, 0x8dac, 0x8daa, 0x8dad, 0x8dab, 0x8e6d,
+ 0x8e78, 0x8e73, 0x8e6a, 0x8e6f, 0x8e7b, 0x8ec2, 0x8f52, 0x8f51,
+ 0x8f4f, 0x8f50, 0x8f53, 0x8fb4, 0x9140, 0x913f, 0x91b0, 0x91ad,
+ 0x93de, 0x93c7, 0x93cf, 0x93c2, 0x93da, 0x93d0, 0x93f9, 0x93ec,
+ 0x93cc, 0x93d9, 0x93a9, 0x93e6, 0x93ca, 0x93d4, 0x93ee, 0x93e3,
+ 0x93d5, 0x93c4, 0x93ce, 0x93c0, 0x93d2, 0x93e7, 0x957d, 0x95da,
+ 0x95db, 0x96e1, 0x9729, 0x972b, 0x972c, 0x9728, 0x9726, 0x97b3,
+ 0x97b7, 0x97b6, 0x97dd, 0x97de, 0x97df, 0x985c, 0x9859, 0x985d,
+ 0x9857, 0x98bf, 0x98bd, 0x98bb, 0x98be, 0x9948, 0x9947, 0x9943,
+ 0x99a6, 0x99a7, 0x9a1a, 0x9a15, 0x9a25, 0x9a1d, 0x9a24, 0x9a1b,
+ 0x9a22, 0x9a20, 0x9a27, 0x9a23, 0x9a1e, 0x9a1c, 0x9a14, 0x9ac2,
+ 0x9b0b, 0x9b0a, 0x9b0e, 0x9b0c, 0x9b37, 0x9bea, 0x9beb, 0x9be0,
+ 0x9bde, 0x9be4, 0x9be6, 0x9be2, 0x9bf0, 0x9bd4, 0x9bd7, 0x9bec,
+ 0x9bdc, 0x9bd9, 0x9be5, 0x9bd5, 0x9be1, 0x9bda, 0x9d77, 0x9d81,
+ 0x9d8a, 0x9d84, 0x9d88, 0x9d71, 0x9d80, 0x9d78, 0x9d86, 0x9d8b,
+ 0x9d8c, 0x9d7d, 0x9d6b, 0x9d74, 0x9d75, 0x9d70, 0x9d69, 0x9d85,
+ 0x9d73, 0x9d7b, 0x9d82, 0x9d6f, 0x9d79, 0x9d7f, 0x9d87, 0x9d68,
+ 0x9e94, 0x9e91, 0x9ec0, 0x9efc, 0x9f2d, 0x9f40, 0x9f41, 0x9f4d,
+ 0x9f56, 0x9f57, 0x9f58, 0x5337, 0x56b2,
+ /* 0xf4 */
+ 0x56b5, 0x56b3, 0x58e3, 0x5b45, 0x5dc6, 0x5dc7, 0x5eee, 0x5eef,
+ 0x5fc0, 0x5fc1, 0x61f9, 0x6517, 0x6516, 0x6515, 0x6513, 0x65df,
+ 0x66e8, 0x66e3, 0x66e4, 0x6af3, 0x6af0, 0x6aea, 0x6ae8, 0x6af9,
+ 0x6af1, 0x6aee, 0x6aef, 0x703c, 0x7035, 0x702f, 0x7037, 0x7034,
+ 0x7031, 0x7042, 0x7038, 0x703f, 0x703a, 0x7039, 0x7040, 0x703b,
+ 0x7033, 0x7041, 0x7213, 0x7214, 0x72a8, 0x737d, 0x737c, 0x74ba,
+ 0x76ab, 0x76aa, 0x76be, 0x76ed, 0x77cc, 0x77ce, 0x77cf, 0x77cd,
+ 0x77f2, 0x7925, 0x7923, 0x7927, 0x7928, 0x7924, 0x7929, 0x79b2,
+ 0x7a6e, 0x7a6c, 0x7a6d, 0x7af7, 0x7c49, 0x7c48, 0x7c4a, 0x7c47,
+ 0x7c45, 0x7cee, 0x7e7b, 0x7e7e, 0x7e81, 0x7e80, 0x7fba, 0x7fff,
+ 0x8079, 0x81db, 0x81d9, 0x820b, 0x8268, 0x8269, 0x8622, 0x85ff,
+ 0x8601, 0x85fe, 0x861b, 0x8600, 0x85f6, 0x8604, 0x8609, 0x8605,
+ 0x860c, 0x85fd, 0x8819, 0x8810, 0x8811, 0x8817, 0x8813, 0x8816,
+ 0x8963, 0x8966, 0x89b9, 0x89f7, 0x8b60, 0x8b6a, 0x8b5d, 0x8b68,
+ 0x8b63, 0x8b65, 0x8b67, 0x8b6d, 0x8dae, 0x8e86, 0x8e88, 0x8e84,
+ 0x8f59, 0x8f56, 0x8f57, 0x8f55, 0x8f58, 0x8f5a, 0x908d, 0x9143,
+ 0x9141, 0x91b7, 0x91b5, 0x91b2, 0x91b3, 0x940b, 0x9413, 0x93fb,
+ 0x9420, 0x940f, 0x9414, 0x93fe, 0x9415, 0x9410, 0x9428, 0x9419,
+ 0x940d, 0x93f5, 0x9400, 0x93f7, 0x9407, 0x940e, 0x9416, 0x9412,
+ 0x93fa, 0x9409, 0x93f8, 0x940a, 0x93ff,
+ /* 0xf5 */
+ 0x93fc, 0x940c, 0x93f6, 0x9411, 0x9406, 0x95de, 0x95e0, 0x95df,
+ 0x972e, 0x972f, 0x97b9, 0x97bb, 0x97fd, 0x97fe, 0x9860, 0x9862,
+ 0x9863, 0x985f, 0x98c1, 0x98c2, 0x9950, 0x994e, 0x9959, 0x994c,
+ 0x994b, 0x9953, 0x9a32, 0x9a34, 0x9a31, 0x9a2c, 0x9a2a, 0x9a36,
+ 0x9a29, 0x9a2e, 0x9a38, 0x9a2d, 0x9ac7, 0x9aca, 0x9ac6, 0x9b10,
+ 0x9b12, 0x9b11, 0x9c0b, 0x9c08, 0x9bf7, 0x9c05, 0x9c12, 0x9bf8,
+ 0x9c40, 0x9c07, 0x9c0e, 0x9c06, 0x9c17, 0x9c14, 0x9c09, 0x9d9f,
+ 0x9d99, 0x9da4, 0x9d9d, 0x9d92, 0x9d98, 0x9d90, 0x9d9b, 0x9da0,
+ 0x9d94, 0x9d9c, 0x9daa, 0x9d97, 0x9da1, 0x9d9a, 0x9da2, 0x9da8,
+ 0x9d9e, 0x9da3, 0x9dbf, 0x9da9, 0x9d96, 0x9da6, 0x9da7, 0x9e99,
+ 0x9e9b, 0x9e9a, 0x9ee5, 0x9ee4, 0x9ee7, 0x9ee6, 0x9f30, 0x9f2e,
+ 0x9f5b, 0x9f60, 0x9f5e, 0x9f5d, 0x9f59, 0x9f91, 0x513a, 0x5139,
+ 0x5298, 0x5297, 0x56c3, 0x56bd, 0x56be, 0x5b48, 0x5b47, 0x5dcb,
+ 0x5dcf, 0x5ef1, 0x61fd, 0x651b, 0x6b02, 0x6afc, 0x6b03, 0x6af8,
+ 0x6b00, 0x7043, 0x7044, 0x704a, 0x7048, 0x7049, 0x7045, 0x7046,
+ 0x721d, 0x721a, 0x7219, 0x737e, 0x7517, 0x766a, 0x77d0, 0x792d,
+ 0x7931, 0x792f, 0x7c54, 0x7c53, 0x7cf2, 0x7e8a, 0x7e87, 0x7e88,
+ 0x7e8b, 0x7e86, 0x7e8d, 0x7f4d, 0x7fbb, 0x8030, 0x81dd, 0x8618,
+ 0x862a, 0x8626, 0x861f, 0x8623, 0x861c, 0x8619, 0x8627, 0x862e,
+ 0x8621, 0x8620, 0x8629, 0x861e, 0x8625,
+ /* 0xf6 */
+ 0x8829, 0x881d, 0x881b, 0x8820, 0x8824, 0x881c, 0x882b, 0x884a,
+ 0x896d, 0x8969, 0x896e, 0x896b, 0x89fa, 0x8b79, 0x8b78, 0x8b45,
+ 0x8b7a, 0x8b7b, 0x8d10, 0x8d14, 0x8daf, 0x8e8e, 0x8e8c, 0x8f5e,
+ 0x8f5b, 0x8f5d, 0x9146, 0x9144, 0x9145, 0x91b9, 0x943f, 0x943b,
+ 0x9436, 0x9429, 0x943d, 0x943c, 0x9430, 0x9439, 0x942a, 0x9437,
+ 0x942c, 0x9440, 0x9431, 0x95e5, 0x95e4, 0x95e3, 0x9735, 0x973a,
+ 0x97bf, 0x97e1, 0x9864, 0x98c9, 0x98c6, 0x98c0, 0x9958, 0x9956,
+ 0x9a39, 0x9a3d, 0x9a46, 0x9a44, 0x9a42, 0x9a41, 0x9a3a, 0x9a3f,
+ 0x9acd, 0x9b15, 0x9b17, 0x9b18, 0x9b16, 0x9b3a, 0x9b52, 0x9c2b,
+ 0x9c1d, 0x9c1c, 0x9c2c, 0x9c23, 0x9c28, 0x9c29, 0x9c24, 0x9c21,
+ 0x9db7, 0x9db6, 0x9dbc, 0x9dc1, 0x9dc7, 0x9dca, 0x9dcf, 0x9dbe,
+ 0x9dc5, 0x9dc3, 0x9dbb, 0x9db5, 0x9dce, 0x9db9, 0x9dba, 0x9dac,
+ 0x9dc8, 0x9db1, 0x9dad, 0x9dcc, 0x9db3, 0x9dcd, 0x9db2, 0x9e7a,
+ 0x9e9c, 0x9eeb, 0x9eee, 0x9eed, 0x9f1b, 0x9f18, 0x9f1a, 0x9f31,
+ 0x9f4e, 0x9f65, 0x9f64, 0x9f92, 0x4eb9, 0x56c6, 0x56c5, 0x56cb,
+ 0x5971, 0x5b4b, 0x5b4c, 0x5dd5, 0x5dd1, 0x5ef2, 0x6521, 0x6520,
+ 0x6526, 0x6522, 0x6b0b, 0x6b08, 0x6b09, 0x6c0d, 0x7055, 0x7056,
+ 0x7057, 0x7052, 0x721e, 0x721f, 0x72a9, 0x737f, 0x74d8, 0x74d5,
+ 0x74d9, 0x74d7, 0x766d, 0x76ad, 0x7935, 0x79b4, 0x7a70, 0x7a71,
+ 0x7c57, 0x7c5c, 0x7c59, 0x7c5b, 0x7c5a,
+ /* 0xf7 */
+ 0x7cf4, 0x7cf1, 0x7e91, 0x7f4f, 0x7f87, 0x81de, 0x826b, 0x8634,
+ 0x8635, 0x8633, 0x862c, 0x8632, 0x8636, 0x882c, 0x8828, 0x8826,
+ 0x882a, 0x8825, 0x8971, 0x89bf, 0x89be, 0x89fb, 0x8b7e, 0x8b84,
+ 0x8b82, 0x8b86, 0x8b85, 0x8b7f, 0x8d15, 0x8e95, 0x8e94, 0x8e9a,
+ 0x8e92, 0x8e90, 0x8e96, 0x8e97, 0x8f60, 0x8f62, 0x9147, 0x944c,
+ 0x9450, 0x944a, 0x944b, 0x944f, 0x9447, 0x9445, 0x9448, 0x9449,
+ 0x9446, 0x973f, 0x97e3, 0x986a, 0x9869, 0x98cb, 0x9954, 0x995b,
+ 0x9a4e, 0x9a53, 0x9a54, 0x9a4c, 0x9a4f, 0x9a48, 0x9a4a, 0x9a49,
+ 0x9a52, 0x9a50, 0x9ad0, 0x9b19, 0x9b2b, 0x9b3b, 0x9b56, 0x9b55,
+ 0x9c46, 0x9c48, 0x9c3f, 0x9c44, 0x9c39, 0x9c33, 0x9c41, 0x9c3c,
+ 0x9c37, 0x9c34, 0x9c32, 0x9c3d, 0x9c36, 0x9ddb, 0x9dd2, 0x9dde,
+ 0x9dda, 0x9dcb, 0x9dd0, 0x9ddc, 0x9dd1, 0x9ddf, 0x9de9, 0x9dd9,
+ 0x9dd8, 0x9dd6, 0x9df5, 0x9dd5, 0x9ddd, 0x9eb6, 0x9ef0, 0x9f35,
+ 0x9f33, 0x9f32, 0x9f42, 0x9f6b, 0x9f95, 0x9fa2, 0x513d, 0x5299,
+ 0x58e8, 0x58e7, 0x5972, 0x5b4d, 0x5dd8, 0x882f, 0x5f4f, 0x6201,
+ 0x6203, 0x6204, 0x6529, 0x6525, 0x6596, 0x66eb, 0x6b11, 0x6b12,
+ 0x6b0f, 0x6bca, 0x705b, 0x705a, 0x7222, 0x7382, 0x7381, 0x7383,
+ 0x7670, 0x77d4, 0x7c67, 0x7c66, 0x7e95, 0x826c, 0x863a, 0x8640,
+ 0x8639, 0x863c, 0x8631, 0x863b, 0x863e, 0x8830, 0x8832, 0x882e,
+ 0x8833, 0x8976, 0x8974, 0x8973, 0x89fe,
+ /* 0xf8 */
+ 0x8b8c, 0x8b8e, 0x8b8b, 0x8b88, 0x8c45, 0x8d19, 0x8e98, 0x8f64,
+ 0x8f63, 0x91bc, 0x9462, 0x9455, 0x945d, 0x9457, 0x945e, 0x97c4,
+ 0x97c5, 0x9800, 0x9a56, 0x9a59, 0x9b1e, 0x9b1f, 0x9b20, 0x9c52,
+ 0x9c58, 0x9c50, 0x9c4a, 0x9c4d, 0x9c4b, 0x9c55, 0x9c59, 0x9c4c,
+ 0x9c4e, 0x9dfb, 0x9df7, 0x9def, 0x9de3, 0x9deb, 0x9df8, 0x9de4,
+ 0x9df6, 0x9de1, 0x9dee, 0x9de6, 0x9df2, 0x9df0, 0x9de2, 0x9dec,
+ 0x9df4, 0x9df3, 0x9de8, 0x9ded, 0x9ec2, 0x9ed0, 0x9ef2, 0x9ef3,
+ 0x9f06, 0x9f1c, 0x9f38, 0x9f37, 0x9f36, 0x9f43, 0x9f4f, 0x9f71,
+ 0x9f70, 0x9f6e, 0x9f6f, 0x56d3, 0x56cd, 0x5b4e, 0x5c6d, 0x652d,
+ 0x66ed, 0x66ee, 0x6b13, 0x705f, 0x7061, 0x705d, 0x7060, 0x7223,
+ 0x74db, 0x74e5, 0x77d5, 0x7938, 0x79b7, 0x79b6, 0x7c6a, 0x7e97,
+ 0x7f89, 0x826d, 0x8643, 0x8838, 0x8837, 0x8835, 0x884b, 0x8b94,
+ 0x8b95, 0x8e9e, 0x8e9f, 0x8ea0, 0x8e9d, 0x91be, 0x91bd, 0x91c2,
+ 0x946b, 0x9468, 0x9469, 0x96e5, 0x9746, 0x9743, 0x9747, 0x97c7,
+ 0x97e5, 0x9a5e, 0x9ad5, 0x9b59, 0x9c63, 0x9c67, 0x9c66, 0x9c62,
+ 0x9c5e, 0x9c60, 0x9e02, 0x9dfe, 0x9e07, 0x9e03, 0x9e06, 0x9e05,
+ 0x9e00, 0x9e01, 0x9e09, 0x9dff, 0x9dfd, 0x9e04, 0x9ea0, 0x9f1e,
+ 0x9f46, 0x9f74, 0x9f75, 0x9f76, 0x56d4, 0x652e, 0x65b8, 0x6b18,
+ 0x6b19, 0x6b17, 0x6b1a, 0x7062, 0x7226, 0x72aa, 0x77d8, 0x77d9,
+ 0x7939, 0x7c69, 0x7c6b, 0x7cf6, 0x7e9a,
+ /* 0xf9 */
+ 0x7e98, 0x7e9b, 0x7e99, 0x81e0, 0x81e1, 0x8646, 0x8647, 0x8648,
+ 0x8979, 0x897a, 0x897c, 0x897b, 0x89ff, 0x8b98, 0x8b99, 0x8ea5,
+ 0x8ea4, 0x8ea3, 0x946e, 0x946d, 0x946f, 0x9471, 0x9473, 0x9749,
+ 0x9872, 0x995f, 0x9c68, 0x9c6e, 0x9c6d, 0x9e0b, 0x9e0d, 0x9e10,
+ 0x9e0f, 0x9e12, 0x9e11, 0x9ea1, 0x9ef5, 0x9f09, 0x9f47, 0x9f78,
+ 0x9f7b, 0x9f7a, 0x9f79, 0x571e, 0x7066, 0x7c6f, 0x883c, 0x8db2,
+ 0x8ea6, 0x91c3, 0x9474, 0x9478, 0x9476, 0x9475, 0x9a60, 0x9c74,
+ 0x9c73, 0x9c71, 0x9c75, 0x9e14, 0x9e13, 0x9ef6, 0x9f0a, 0x9fa4,
+ 0x7068, 0x7065, 0x7cf7, 0x866a, 0x883e, 0x883d, 0x883f, 0x8b9e,
+ 0x8c9c, 0x8ea9, 0x8ec9, 0x974b, 0x9873, 0x9874, 0x98cc, 0x9961,
+ 0x99ab, 0x9a64, 0x9a66, 0x9a67, 0x9b24, 0x9e15, 0x9e17, 0x9f48,
+ 0x6207, 0x6b1e, 0x7227, 0x864c, 0x8ea8, 0x9482, 0x9480, 0x9481,
+ 0x9a69, 0x9a68, 0x9b2e, 0x9e19, 0x7229, 0x864b, 0x8b9f, 0x9483,
+ 0x9c79, 0x9eb7, 0x7675, 0x9a6b, 0x9c7a, 0x9e1d, 0x7069, 0x706a,
+ 0x9ea4, 0x9f7e, 0x9f49, 0x9f98,
+};
+
+static int
+big5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c1 = s[0];
+ if ((c1 >= 0xa1 && c1 <= 0xc7) || (c1 >= 0xc9 && c1 <= 0xf9)) {
+ if (n >= 2) {
+ unsigned char c2 = s[1];
+ if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) {
+ unsigned int i = 157 * (c1 - 0xa1) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40));
+ unsigned short wc = 0xfffd;
+ if (i < 6280) {
+ if (i < 6121)
+ wc = big5_2uni_pagea1[i];
+ } else {
+ if (i < 13932)
+ wc = big5_2uni_pagec9[i-6280];
+ }
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 2;
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOFEW(0);
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned short big5_2charset[13703] = {
+ 0xa246, 0xa247, 0xa244, 0xa1b1, 0xa258, 0xa1d3, 0xa150, 0xa1d1,
+ 0xa1d2, 0xa3be, 0xa3bc, 0xa3bd, 0xa3bf, 0xa3bb, 0xa344, 0xa345,
+ 0xa346, 0xa347, 0xa348, 0xa349, 0xa34a, 0xa34b, 0xa34c, 0xa34d,
+ 0xa34e, 0xa34f, 0xa350, 0xa351, 0xa352, 0xa353, 0xa354, 0xa355,
+ 0xa356, 0xa357, 0xa358, 0xa359, 0xa35a, 0xa35b, 0xa35c, 0xa35d,
+ 0xa35e, 0xa35f, 0xa360, 0xa361, 0xa362, 0xa363, 0xa364, 0xa365,
+ 0xa366, 0xa367, 0xa368, 0xa369, 0xa36a, 0xa36b, 0xa36c, 0xa36d,
+ 0xa36e, 0xa36f, 0xa370, 0xa371, 0xa372, 0xa373, 0xc7b3, 0xc7b1,
+ 0xc7b2, 0xc7b4, 0xc7b5, 0xc7b6, 0xc7b7, 0xc7b8, 0xc7b9, 0xc7ba,
+ 0xc7bb, 0xc7bc, 0xc7bd, 0xc7be, 0xc7bf, 0xc7c0, 0xc7c1, 0xc7c2,
+ 0xc7c3, 0xc7c4, 0xc7c5, 0xc7c6, 0xc7c7, 0xc7c8, 0xc7c9, 0xc7ca,
+ 0xc7cb, 0xc7cc, 0xc7cd, 0xc7cf, 0xc7d0, 0xc7d1, 0xc7d2, 0xc7d3,
+ 0xc7d4, 0xc7d5, 0xc7d6, 0xc7d7, 0xc7d8, 0xc7d9, 0xc7da, 0xc7db,
+ 0xc7dc, 0xc7dd, 0xc7de, 0xc7df, 0xc7e0, 0xc7e1, 0xc7e2, 0xc7e3,
+ 0xc7e4, 0xc7e5, 0xc7e6, 0xc7e7, 0xc7e8, 0xc7ce, 0xa156, 0xa158,
+ 0xa1a5, 0xa1a6, 0xa1a7, 0xa1a8, 0xa145, 0xa14c, 0xa14b, 0xa1ac,
+ 0xa1ab, 0xa1b0, 0xa1c2, 0xa24a, 0xa1c1, 0xa24b, 0xa2b9, 0xa2ba,
+ 0xa2bb, 0xa2bc, 0xa2bd, 0xa2be, 0xa2bf, 0xa2c0, 0xa2c1, 0xa2c2,
+ 0xa1f6, 0xa1f4, 0xa1f7, 0xa1f5, 0xa1f8, 0xa1f9, 0xa1fb, 0xa1fa,
+ 0xa1d4, 0xa1db, 0xa1e8, 0xa1e7, 0xa1fd, 0xa1fc, 0xa1e4, 0xa1e5,
+ 0xa1ec, 0xa1ed, 0xa1ef, 0xa1ee, 0xa1e3, 0xa1dc, 0xa1da, 0xa1dd,
+ 0xa1d8, 0xa1d9, 0xa1e6, 0xa1e9, 0xc7e9, 0xc7ea, 0xc7eb, 0xc7ec,
+ 0xc7ed, 0xc7ee, 0xc7ef, 0xc7f0, 0xc7f1, 0xc7f2, 0xc7f3, 0xc7f4,
+ 0xc7f5, 0xc7f6, 0xc7f7, 0xc7f8, 0xc7f9, 0xc7fa, 0xc7fb, 0xc7fc,
+ 0xa277, 0xa278, 0xa27a, 0xa27b, 0xa27c, 0xa27d, 0xa275, 0xa274,
+ 0xa273, 0xa272, 0xa271, 0xa2a4, 0xa2a5, 0xa2a7, 0xa2a6, 0xa27e,
+ 0xa2a1, 0xa2a3, 0xa2a2, 0xa2ac, 0xa2ad, 0xa2ae, 0xa262, 0xa263,
+ 0xa264, 0xa265, 0xa266, 0xa267, 0xa268, 0xa269, 0xa270, 0xa26f,
+ 0xa26e, 0xa26d, 0xa26c, 0xa26b, 0xa26a, 0xa276, 0xa279, 0xa1bd,
+ 0xa1bc, 0xa1b6, 0xa1b5, 0xa1bf, 0xa1be, 0xa1bb, 0xa1ba, 0xa1b3,
+ 0xa1b7, 0xa1b4, 0xa2a8, 0xa2a9, 0xa2ab, 0xa2aa, 0xa1b9, 0xa1b8,
+ 0xa1f3, 0xa1f0, 0xa1f2, 0xa1f1, 0xa140, 0xa142, 0xa143, 0xa1b2,
+ 0xc6a4, 0xa171, 0xa172, 0xa16d, 0xa16e, 0xa175, 0xa176, 0xa179,
+ 0xa17a, 0xa169, 0xa16a, 0xa245, 0xa165, 0xa166, 0xa1a9, 0xa1aa,
+ 0xa2c3, 0xa2c4, 0xa2c5, 0xa2c6, 0xa2c7, 0xa2c8, 0xa2c9, 0xa2ca,
+ 0xa2cb, 0xc6a5, 0xc6a6, 0xc6a7, 0xc6a8, 0xc6a9, 0xc6aa, 0xc6ab,
+ 0xc6ac, 0xc6ad, 0xc6ae, 0xc6af, 0xc6b0, 0xc6b1, 0xc6b2, 0xc6b3,
+ 0xc6b4, 0xc6b5, 0xc6b6, 0xc6b7, 0xc6b8, 0xc6b9, 0xc6ba, 0xc6bb,
+ 0xc6bc, 0xc6bd, 0xc6be, 0xc6bf, 0xc6c0, 0xc6c1, 0xc6c2, 0xc6c3,
+ 0xc6c4, 0xc6c5, 0xc6c6, 0xc6c7, 0xc6c8, 0xc6c9, 0xc6ca, 0xc6cb,
+ 0xc6cc, 0xc6cd, 0xc6ce, 0xc6cf, 0xc6d0, 0xc6d1, 0xc6d2, 0xc6d3,
+ 0xc6d4, 0xc6d5, 0xc6d6, 0xc6d7, 0xc6d8, 0xc6d9, 0xc6da, 0xc6db,
+ 0xc6dc, 0xc6dd, 0xc6de, 0xc6df, 0xc6e0, 0xc6e1, 0xc6e2, 0xc6e3,
+ 0xc6e4, 0xc6e5, 0xc6e6, 0xc6e7, 0xc6e8, 0xc6e9, 0xc6ea, 0xc6eb,
+ 0xc6ec, 0xc6ed, 0xc6ee, 0xc6ef, 0xc6f0, 0xc6f1, 0xc6f2, 0xc6f3,
+ 0xc6f4, 0xc6f5, 0xc6f6, 0xc6f7, 0xc6a2, 0xc6a3, 0xc6f8, 0xc6f9,
+ 0xc6fa, 0xc6fb, 0xc6fc, 0xc6fd, 0xc6fe, 0xc740, 0xc741, 0xc742,
+ 0xc743, 0xc744, 0xc745, 0xc746, 0xc747, 0xc748, 0xc749, 0xc74a,
+ 0xc74b, 0xc74c, 0xc74d, 0xc74e, 0xc74f, 0xc750, 0xc751, 0xc752,
+ 0xc753, 0xc754, 0xc755, 0xc756, 0xc757, 0xc758, 0xc759, 0xc75a,
+ 0xc75b, 0xc75c, 0xc75d, 0xc75e, 0xc75f, 0xc760, 0xc761, 0xc762,
+ 0xc763, 0xc764, 0xc765, 0xc766, 0xc767, 0xc768, 0xc769, 0xc76a,
+ 0xc76b, 0xc76c, 0xc76d, 0xc76e, 0xc76f, 0xc770, 0xc771, 0xc772,
+ 0xc773, 0xc774, 0xc775, 0xc776, 0xc777, 0xc778, 0xc779, 0xc77a,
+ 0xc77b, 0xc77c, 0xc77d, 0xc77e, 0xc7a1, 0xc7a2, 0xc7a3, 0xc7a4,
+ 0xc7a5, 0xc7a6, 0xc7a7, 0xc7a8, 0xc7a9, 0xc7aa, 0xc7ab, 0xc7ac,
+ 0xc7ad, 0xc7ae, 0xc7af, 0xc7b0, 0xc6a1, 0xa374, 0xa375, 0xa376,
+ 0xa377, 0xa378, 0xa379, 0xa37a, 0xa37b, 0xa37c, 0xa37d, 0xa37e,
+ 0xa3a1, 0xa3a2, 0xa3a3, 0xa3a4, 0xa3a5, 0xa3a6, 0xa3a7, 0xa3a8,
+ 0xa3a9, 0xa3aa, 0xa3ab, 0xa3ac, 0xa3ad, 0xa3ae, 0xa3af, 0xa3b0,
+ 0xa3b1, 0xa3b2, 0xa3b3, 0xa3b4, 0xa3b5, 0xa3b6, 0xa3b7, 0xa3b8,
+ 0xa3b9, 0xa3ba, 0xa1c0, 0xa255, 0xa256, 0xa250, 0xa251, 0xa252,
+ 0xa254, 0xa257, 0xa253, 0xa1eb, 0xa1ea, 0xa24f, 0xa440, 0xa442,
+ 0xa443, 0xc945, 0xa456, 0xa454, 0xa457, 0xa455, 0xc946, 0xa4a3,
+ 0xc94f, 0xc94d, 0xa4a2, 0xa4a1, 0xa542, 0xa541, 0xa540, 0xa543,
+ 0xa4fe, 0xa5e0, 0xa5e1, 0xa8c3, 0xa458, 0xa4a4, 0xc950, 0xa4a5,
+ 0xc963, 0xa6ea, 0xcbb1, 0xa459, 0xa4a6, 0xa544, 0xc964, 0xc940,
+ 0xa444, 0xa45b, 0xc947, 0xa45c, 0xa4a7, 0xa545, 0xa547, 0xa546,
+ 0xa5e2, 0xa5e3, 0xa8c4, 0xadbc, 0xa441, 0xc941, 0xa445, 0xa45e,
+ 0xa45d, 0xa5e4, 0xa8c5, 0xb0ae, 0xd44b, 0xb6c3, 0xdcb1, 0xdcb2,
+ 0xa446, 0xa4a9, 0xa8c6, 0xa447, 0xc948, 0xa45f, 0xa4aa, 0xa4ac,
+ 0xc951, 0xa4ad, 0xa4ab, 0xa5e5, 0xa8c7, 0xa8c8, 0xab45, 0xa460,
+ 0xa4ae, 0xa5e6, 0xa5e8, 0xa5e7, 0xa6eb, 0xa8c9, 0xa8ca, 0xab46,
+ 0xab47, 0xadbd, 0xdcb3, 0xf6d6, 0xa448, 0xa4b0, 0xa4af, 0xc952,
+ 0xa4b1, 0xa4b7, 0xa4b2, 0xa4b3, 0xc954, 0xc953, 0xa4b5, 0xa4b6,
+ 0xa4b4, 0xa54a, 0xa54b, 0xa54c, 0xa54d, 0xa549, 0xa550, 0xc96a,
+ 0xc966, 0xc969, 0xa551, 0xa561, 0xc968, 0xa54e, 0xa54f, 0xa548,
+ 0xc965, 0xc967, 0xa5f5, 0xc9b0, 0xa5f2, 0xa5f6, 0xc9ba, 0xc9ae,
+ 0xa5f3, 0xc9b2, 0xa5f4, 0xa5f7, 0xa5e9, 0xc9b1, 0xa5f8, 0xc9b5,
+ 0xc9b9, 0xc9b6, 0xc9b3, 0xa5ea, 0xa5ec, 0xa5f9, 0xa5ee, 0xc9ab,
+ 0xa5f1, 0xa5ef, 0xa5f0, 0xc9bb, 0xc9b8, 0xc9af, 0xa5ed, 0xc9ac,
+ 0xa5eb, 0xc9b4, 0xc9b7, 0xc9ad, 0xca66, 0xa742, 0xa6f4, 0xca67,
+ 0xa6f1, 0xa744, 0xa6f9, 0xa6f8, 0xca5b, 0xa6fc, 0xa6f7, 0xca60,
+ 0xca68, 0xca64, 0xa6fa, 0xa6fd, 0xa6ee, 0xa747, 0xca5d, 0xcbbd,
+ 0xa6ec, 0xa743, 0xa6ed, 0xa6f5, 0xa6f6, 0xca62, 0xca5e, 0xa6fb,
+ 0xa6f3, 0xca5a, 0xa6ef, 0xca65, 0xa745, 0xa748, 0xa6f2, 0xa740,
+ 0xa746, 0xa6f0, 0xca63, 0xa741, 0xca69, 0xca5c, 0xa6fe, 0xca5f,
+ 0xca61, 0xa8d8, 0xcbbf, 0xcbcb, 0xa8d0, 0xcbcc, 0xa8cb, 0xa8d5,
+ 0xa8ce, 0xcbb9, 0xa8d6, 0xcbb8, 0xcbbc, 0xcbc3, 0xcbc1, 0xa8de,
+ 0xa8d9, 0xcbb3, 0xcbb5, 0xa8db, 0xa8cf, 0xcbb6, 0xcbc2, 0xcbc9,
+ 0xa8d4, 0xcbbb, 0xcbb4, 0xa8d3, 0xcbb7, 0xa8d7, 0xcbba, 0xa8d2,
+ 0xa8cd, 0xa8dc, 0xcbc4, 0xa8dd, 0xcbc8, 0xcbc6, 0xcbca, 0xa8da,
+ 0xcbbe, 0xcbb2, 0xcbc0, 0xa8d1, 0xcbc5, 0xa8cc, 0xcbc7, 0xab56,
+ 0xab4a, 0xcde0, 0xcde8, 0xab49, 0xab51, 0xab5d, 0xcdee, 0xcdec,
+ 0xcde7, 0xab4b, 0xcded, 0xcde3, 0xab59, 0xab50, 0xab58, 0xcdde,
+ 0xcdea, 0xcde1, 0xab54, 0xcde2, 0xcddd, 0xab5b, 0xab4e, 0xab57,
+ 0xab4d, 0xcddf, 0xcde4, 0xcdeb, 0xab55, 0xab52, 0xcde6, 0xab5a,
+ 0xcde9, 0xcde5, 0xab4f, 0xab5c, 0xab53, 0xab4c, 0xab48, 0xcdef,
+ 0xadd7, 0xadc1, 0xadd1, 0xadd6, 0xd0d0, 0xd0cf, 0xd0d4, 0xd0d5,
+ 0xadc4, 0xadcd, 0xadda, 0xadce, 0xd0c9, 0xadc7, 0xd0ca, 0xaddc,
+ 0xadd3, 0xadbe, 0xadbf, 0xd0dd, 0xb0bf, 0xadcc, 0xadcb, 0xd0cb,
+ 0xadcf, 0xd45b, 0xadc6, 0xd0d6, 0xadd5, 0xadd4, 0xadca, 0xd0ce,
+ 0xd0d7, 0xd0c8, 0xadc9, 0xd0d8, 0xadd2, 0xd0cc, 0xadc0, 0xadc3,
+ 0xadc2, 0xd0d9, 0xadd0, 0xadc5, 0xadd9, 0xaddb, 0xd0d3, 0xadd8,
+ 0xd0db, 0xd0cd, 0xd0dc, 0xd0d1, 0xd0da, 0xd0d2, 0xadc8, 0xd463,
+ 0xd457, 0xb0b3, 0xd45c, 0xd462, 0xb0b2, 0xd455, 0xb0b6, 0xd459,
+ 0xd452, 0xb0b4, 0xd456, 0xb0b9, 0xb0be, 0xd467, 0xd451, 0xb0ba,
+ 0xd466, 0xb0b5, 0xd458, 0xb0b1, 0xd453, 0xd44f, 0xd45d, 0xd450,
+ 0xd44e, 0xd45a, 0xd460, 0xd461, 0xb0b7, 0xd85b, 0xd45e, 0xd44d,
+ 0xd45f, 0xb0c1, 0xd464, 0xb0c0, 0xd44c, 0xd454, 0xd465, 0xb0bc,
+ 0xb0bb, 0xb0b8, 0xb0bd, 0xb0af, 0xb0b0, 0xb3c8, 0xd85e, 0xd857,
+ 0xb3c5, 0xd85f, 0xd855, 0xd858, 0xb3c4, 0xd859, 0xb3c7, 0xd85d,
+ 0xd853, 0xd852, 0xb3c9, 0xb3ca, 0xb3c6, 0xb3cb, 0xd851, 0xd85c,
+ 0xd85a, 0xd854, 0xb3c3, 0xd856, 0xb6ca, 0xb6c4, 0xdcb7, 0xb6cd,
+ 0xdcbd, 0xdcc0, 0xb6c6, 0xb6c7, 0xdcba, 0xb6c5, 0xdcc3, 0xb6cb,
+ 0xdcc4, 0xdcbf, 0xb6cc, 0xdcb4, 0xb6c9, 0xdcb5, 0xdcbe, 0xdcbc,
+ 0xdcb8, 0xb6c8, 0xdcb6, 0xb6ce, 0xdcbb, 0xdcc2, 0xdcb9, 0xdcc1,
+ 0xb9b6, 0xb9b3, 0xb9b4, 0xe0f9, 0xe0f1, 0xb9b2, 0xb9af, 0xe0f2,
+ 0xb9b1, 0xe0f5, 0xe0f7, 0xe0fe, 0xe0fd, 0xe0f8, 0xb9ae, 0xe0f0,
+ 0xb9ac, 0xe0f3, 0xb9b7, 0xe0f6, 0xe0fa, 0xb9b0, 0xb9ad, 0xe0fc,
+ 0xe0fb, 0xb9b5, 0xe0f4, 0xbbf8, 0xe4ec, 0xe4e9, 0xbbf9, 0xbbf7,
+ 0xe4f0, 0xe4ed, 0xe4e6, 0xbbf6, 0xbbfa, 0xe4e7, 0xbbf5, 0xbbfd,
+ 0xe4ea, 0xe4eb, 0xbbfb, 0xbbfc, 0xe4f1, 0xe4ee, 0xe4ef, 0xbeaa,
+ 0xe8f8, 0xbea7, 0xe8f5, 0xbea9, 0xbeab, 0xe8f6, 0xbea8, 0xe8f7,
+ 0xe8f4, 0xc076, 0xecbd, 0xc077, 0xecbb, 0xecbc, 0xecba, 0xecb9,
+ 0xecbe, 0xc075, 0xefb8, 0xefb9, 0xe4e8, 0xefb7, 0xc078, 0xc35f,
+ 0xf1eb, 0xf1ec, 0xc4d7, 0xc4d8, 0xf5c1, 0xf5c0, 0xc56c, 0xc56b,
+ 0xf7d0, 0xa449, 0xa461, 0xa4b9, 0xa4b8, 0xa553, 0xa552, 0xa5fc,
+ 0xa5fb, 0xa5fd, 0xa5fa, 0xa74a, 0xa749, 0xa74b, 0xa8e0, 0xa8df,
+ 0xa8e1, 0xab5e, 0xa259, 0xd0de, 0xa25a, 0xb0c2, 0xa25c, 0xa25b,
+ 0xd860, 0xa25d, 0xb9b8, 0xa25e, 0xa44a, 0xa4ba, 0xa5fe, 0xa8e2,
+ 0xa44b, 0xa4bd, 0xa4bb, 0xa4bc, 0xa640, 0xa74c, 0xa8e4, 0xa8e3,
+ 0xa8e5, 0xaddd, 0xbeac, 0xc94e, 0xa554, 0xa555, 0xa641, 0xca6a,
+ 0xab60, 0xab5f, 0xd0e0, 0xd0df, 0xb0c3, 0xa4be, 0xc955, 0xcbcd,
+ 0xab61, 0xade0, 0xadde, 0xaddf, 0xbead, 0xa556, 0xa642, 0xc9bc,
+ 0xa74d, 0xa74e, 0xca6b, 0xcbce, 0xa8e6, 0xcbcf, 0xd0e2, 0xd0e3,
+ 0xade3, 0xd0e4, 0xd0e1, 0xade4, 0xade2, 0xade1, 0xd0e5, 0xd468,
+ 0xd861, 0xdcc5, 0xe140, 0xbbfe, 0xbeae, 0xe8f9, 0xa44c, 0xa45a,
+ 0xb0c4, 0xb3cd, 0xb9b9, 0xc942, 0xa4bf, 0xa559, 0xa557, 0xa558,
+ 0xa8e7, 0xa44d, 0xa44e, 0xa462, 0xa4c0, 0xa4c1, 0xa4c2, 0xc9be,
+ 0xa55a, 0xc96b, 0xa646, 0xc9bf, 0xa644, 0xa645, 0xc9bd, 0xa647,
+ 0xa643, 0xca6c, 0xaaec, 0xca6d, 0xca6e, 0xa750, 0xa74f, 0xa753,
+ 0xa751, 0xa752, 0xa8ed, 0xa8ec, 0xcbd4, 0xcbd1, 0xcbd2, 0xcbd0,
+ 0xa8ee, 0xa8ea, 0xa8e9, 0xa8eb, 0xa8e8, 0xa8ef, 0xab63, 0xcdf0,
+ 0xcbd3, 0xab68, 0xcdf1, 0xab64, 0xab67, 0xab66, 0xab65, 0xab62,
+ 0xd0e8, 0xade7, 0xd0eb, 0xade5, 0xd0e7, 0xade8, 0xade6, 0xade9,
+ 0xd0e9, 0xd0ea, 0xd0e6, 0xd0ec, 0xb3d1, 0xb0c5, 0xd469, 0xd46b,
+ 0xd46a, 0xd46c, 0xb0c6, 0xb3ce, 0xb3cf, 0xb3d0, 0xb6d0, 0xdcc7,
+ 0xdcc6, 0xdcc8, 0xdcc9, 0xb6d1, 0xb6cf, 0xe141, 0xe142, 0xb9bb,
+ 0xb9ba, 0xe35a, 0xbc40, 0xbc41, 0xbc42, 0xbc44, 0xe4f2, 0xe4f3,
+ 0xbc43, 0xbeaf, 0xbeb0, 0xf1ed, 0xf5c3, 0xf5c2, 0xf7d1, 0xa44f,
+ 0xa55c, 0xa55b, 0xa648, 0xc9c0, 0xa755, 0xa756, 0xa754, 0xa757,
+ 0xca6f, 0xca70, 0xa8f1, 0xcbd5, 0xa8f0, 0xcdf2, 0xab6c, 0xcdf3,
+ 0xab6b, 0xab69, 0xab6a, 0xd0ed, 0xb0c7, 0xd46e, 0xb0ca, 0xd46d,
+ 0xb1e5, 0xb0c9, 0xb0c8, 0xb3d4, 0xb3d3, 0xb3d2, 0xb6d2, 0xb6d5,
+ 0xb6d6, 0xb6d4, 0xb6d3, 0xe143, 0xe144, 0xe4f5, 0xbc45, 0xe4f4,
+ 0xbeb1, 0xecbf, 0xc079, 0xf1ee, 0xc455, 0xa463, 0xa4c3, 0xc956,
+ 0xa4c4, 0xa4c5, 0xa55d, 0xa55e, 0xa649, 0xca71, 0xcbd6, 0xcbd7,
+ 0xab6d, 0xd0ee, 0xb0cc, 0xb0cb, 0xd863, 0xd862, 0xa450, 0xa4c6,
+ 0xa55f, 0xb0cd, 0xc943, 0xc96c, 0xa560, 0xc9c2, 0xa64b, 0xa64a,
+ 0xc9c1, 0xa758, 0xadea, 0xd46f, 0xb6d7, 0xe145, 0xb9bc, 0xe8fa,
+ 0xf3fd, 0xa4c7, 0xcbd8, 0xcdf4, 0xb0d0, 0xb0ce, 0xb0cf, 0xa451,
+ 0xa464, 0xa2cd, 0xa4ca, 0xa4c9, 0xa4c8, 0xa563, 0xa562, 0xc96d,
+ 0xc9c3, 0xa8f5, 0xa8f2, 0xa8f4, 0xa8f3, 0xab6e, 0xb3d5, 0xa452,
+ 0xa4cb, 0xa565, 0xa564, 0xca72, 0xa8f6, 0xc957, 0xa567, 0xa566,
+ 0xa64c, 0xa64d, 0xca73, 0xa759, 0xa75a, 0xa8f7, 0xa8f8, 0xa8f9,
+ 0xab6f, 0xcdf5, 0xadeb, 0xc944, 0xa4cc, 0xc9c4, 0xca74, 0xca75,
+ 0xcbd9, 0xcbda, 0xcdf7, 0xcdf6, 0xcdf9, 0xcdf8, 0xab70, 0xd470,
+ 0xaded, 0xd0ef, 0xadec, 0xd864, 0xb3d6, 0xd865, 0xe146, 0xb9bd,
+ 0xbc46, 0xf1ef, 0xc958, 0xa568, 0xb0d1, 0xa453, 0xa465, 0xa4ce,
+ 0xa4cd, 0xa4cf, 0xa8fb, 0xa8fa, 0xa8fc, 0xab71, 0xadee, 0xe8fb,
+ 0xc24f, 0xa466, 0xa56a, 0xa579, 0xa574, 0xa56f, 0xa56e, 0xa575,
+ 0xa573, 0xa56c, 0xa57a, 0xa56d, 0xa569, 0xa578, 0xa577, 0xa576,
+ 0xa56b, 0xa572, 0xa571, 0xa57b, 0xa570, 0xa653, 0xa659, 0xa655,
+ 0xa65b, 0xc9c5, 0xa658, 0xa64e, 0xa651, 0xa654, 0xa650, 0xa657,
+ 0xa65a, 0xa64f, 0xa652, 0xa656, 0xa65c, 0xca7e, 0xca7b, 0xa767,
+ 0xca7c, 0xa75b, 0xa75d, 0xa775, 0xa770, 0xcaa5, 0xca7d, 0xa75f,
+ 0xa761, 0xcaa4, 0xa768, 0xca78, 0xa774, 0xa776, 0xa75c, 0xa76d,
+ 0xca76, 0xa773, 0xa764, 0xa76e, 0xa76f, 0xca77, 0xa76c, 0xa76a,
+ 0xa76b, 0xa771, 0xcaa1, 0xa75e, 0xa772, 0xcaa3, 0xa766, 0xa763,
+ 0xca7a, 0xa762, 0xcaa6, 0xa765, 0xa769, 0xa760, 0xcaa2, 0xca79,
+ 0xcbeb, 0xcbea, 0xa94f, 0xcbed, 0xcbef, 0xcbe4, 0xcbe7, 0xcbee,
+ 0xa950, 0xcbe1, 0xcbe5, 0xcbe9, 0xce49, 0xa94b, 0xce4d, 0xa8fd,
+ 0xcbe6, 0xa8fe, 0xa94c, 0xa945, 0xa941, 0xcbe2, 0xa944, 0xa949,
+ 0xa952, 0xcbe3, 0xcbdc, 0xa943, 0xcbdd, 0xcbdf, 0xa946, 0xa948,
+ 0xcbdb, 0xcbe0, 0xa951, 0xa94d, 0xcbe8, 0xa953, 0xa94a, 0xcbde,
+ 0xa947, 0xa942, 0xa940, 0xcbec, 0xa94e, 0xce48, 0xcdfb, 0xce4b,
+ 0xcdfd, 0xab78, 0xaba8, 0xab74, 0xaba7, 0xab7d, 0xaba4, 0xab72,
+ 0xcdfc, 0xce43, 0xaba3, 0xce4f, 0xaba5, 0xab79, 0xce45, 0xce42,
+ 0xab77, 0xcdfa, 0xaba6, 0xce4a, 0xab7c, 0xce4c, 0xaba9, 0xab73,
+ 0xab7e, 0xab7b, 0xce40, 0xaba1, 0xce46, 0xce47, 0xab7a, 0xaba2,
+ 0xab76, 0xab75, 0xcdfe, 0xce44, 0xce4e, 0xd144, 0xadfb, 0xd0f1,
+ 0xd0f6, 0xadf4, 0xae40, 0xd0f4, 0xadef, 0xadf9, 0xadfe, 0xd0fb,
+ 0xadfa, 0xadfd, 0xd0fe, 0xadf5, 0xd0f5, 0xd142, 0xd143, 0xadf7,
+ 0xd141, 0xadf3, 0xae43, 0xd0f8, 0xadf1, 0xd146, 0xd0f9, 0xd0fd,
+ 0xadf6, 0xae42, 0xd0fa, 0xadfc, 0xd140, 0xd147, 0xd4a1, 0xd145,
+ 0xae44, 0xadf0, 0xd0fc, 0xd0f3, 0xadf8, 0xd0f2, 0xd0f7, 0xd0f0,
+ 0xae41, 0xd477, 0xb0e4, 0xd4a7, 0xb0e2, 0xb0df, 0xd47c, 0xb0db,
+ 0xd4a2, 0xb0e6, 0xd476, 0xd47b, 0xd47a, 0xadf2, 0xb0e1, 0xd4a5,
+ 0xd4a8, 0xd473, 0xb3e8, 0xd4a9, 0xb0e7, 0xb0d9, 0xb0d6, 0xd47e,
+ 0xb0d3, 0xd4a6, 0xb0da, 0xd4aa, 0xd474, 0xd4a4, 0xb0dd, 0xd475,
+ 0xd478, 0xd47d, 0xb0de, 0xb0dc, 0xb0e8, 0xb0e3, 0xb0d7, 0xb1d2,
+ 0xb0d8, 0xd479, 0xb0e5, 0xb0e0, 0xd4a3, 0xb0d5, 0xb0d4, 0xd471,
+ 0xd472, 0xd86a, 0xb3d7, 0xb3da, 0xd875, 0xb3ee, 0xd878, 0xb3d8,
+ 0xd871, 0xb3de, 0xb3e4, 0xb5bd, 0xb3e2, 0xd86e, 0xb3ef, 0xb3db,
+ 0xb3e3, 0xd876, 0xdcd7, 0xd87b, 0xd86f, 0xd866, 0xd873, 0xd86d,
+ 0xb3e1, 0xd879, 0xb3dd, 0xb3f1, 0xb3ea, 0xb3df, 0xb3dc, 0xb3e7,
+ 0xd87a, 0xd86c, 0xd872, 0xd874, 0xd868, 0xd877, 0xb3d9, 0xd867,
+ 0xb3e0, 0xb3f0, 0xb3ec, 0xd869, 0xb3e6, 0xb3ed, 0xb3e9, 0xb3e5,
+ 0xd870, 0xb3eb, 0xdcd5, 0xdcd1, 0xdce0, 0xdcca, 0xdcd3, 0xb6e5,
+ 0xb6e6, 0xb6de, 0xdcdc, 0xb6e8, 0xdccf, 0xdcce, 0xdccc, 0xdcde,
+ 0xb6dc, 0xdcd8, 0xdccd, 0xb6df, 0xdcd6, 0xb6da, 0xdcd2, 0xdcd9,
+ 0xdcdb, 0xdcdf, 0xb6e3, 0xdccb, 0xb6dd, 0xdcd0, 0xb6d8, 0xb6e4,
+ 0xdcda, 0xb6e0, 0xb6e1, 0xb6e7, 0xb6db, 0xa25f, 0xb6d9, 0xdcd4,
+ 0xb6e2, 0xdcdd, 0xb9cd, 0xb9c8, 0xe155, 0xe151, 0xe14b, 0xb9c2,
+ 0xb9be, 0xe154, 0xb9bf, 0xe14e, 0xe150, 0xe153, 0xb9c4, 0xb9cb,
+ 0xb9c5, 0xe149, 0xb9c6, 0xb9c7, 0xe14c, 0xb9cc, 0xe14a, 0xe14f,
+ 0xb9c3, 0xe148, 0xb9c9, 0xb9c1, 0xb9c0, 0xe14d, 0xe152, 0xb9ca,
+ 0xe147, 0xbc4d, 0xe547, 0xe544, 0xbc47, 0xbc53, 0xbc54, 0xbc4a,
+ 0xe542, 0xbc4c, 0xe4f9, 0xbc52, 0xe546, 0xbc49, 0xe548, 0xbc48,
+ 0xe543, 0xe545, 0xbc4b, 0xe541, 0xe4fa, 0xe4f7, 0xd86b, 0xe4fd,
+ 0xe4f6, 0xe4fc, 0xe4fb, 0xe4f8, 0xbc4f, 0xbc4e, 0xbc50, 0xe4fe,
+ 0xbeb2, 0xe540, 0xe945, 0xe8fd, 0xbebe, 0xe942, 0xbeb6, 0xbeba,
+ 0xe941, 0xbeb9, 0xbeb5, 0xbeb8, 0xbeb3, 0xbebd, 0xe943, 0xe8fe,
+ 0xbebc, 0xe8fc, 0xbebb, 0xe944, 0xe940, 0xbc51, 0xbebf, 0xe946,
+ 0xbeb7, 0xbeb4, 0xecc6, 0xecc8, 0xc07b, 0xecc9, 0xecc7, 0xecc5,
+ 0xecc4, 0xc07d, 0xecc3, 0xc07e, 0xecc1, 0xecc2, 0xc07a, 0xc0a1,
+ 0xc07c, 0xecc0, 0xc250, 0xefbc, 0xefba, 0xefbf, 0xefbd, 0xefbb,
+ 0xefbe, 0xc360, 0xf1f2, 0xf1f3, 0xc456, 0xf1f4, 0xf1f0, 0xf1f5,
+ 0xf1f1, 0xc251, 0xf3fe, 0xf441, 0xc459, 0xf440, 0xc458, 0xc457,
+ 0xc45a, 0xf5c5, 0xf5c6, 0xc4da, 0xc4d9, 0xc4db, 0xf5c4, 0xf6d8,
+ 0xf6d7, 0xc56d, 0xc56f, 0xc56e, 0xf6d9, 0xc5c8, 0xf8a6, 0xc5f1,
+ 0xf8a5, 0xf8ee, 0xc949, 0xa57d, 0xa57c, 0xa65f, 0xa65e, 0xc9c7,
+ 0xa65d, 0xc9c6, 0xa779, 0xcaa9, 0xcaa8, 0xa777, 0xa77a, 0xcaa7,
+ 0xa778, 0xcbf0, 0xcbf1, 0xa954, 0xabaa, 0xd148, 0xd149, 0xae45,
+ 0xae46, 0xd4ac, 0xb0e9, 0xb0eb, 0xd4ab, 0xb0ea, 0xd87c, 0xb3f2,
+ 0xb6e9, 0xb6ea, 0xdce1, 0xb9cf, 0xb9ce, 0xe549, 0xe948, 0xe947,
+ 0xf96b, 0xa467, 0xc959, 0xc96e, 0xc96f, 0xa662, 0xa666, 0xc9c9,
+ 0xa664, 0xa663, 0xc9c8, 0xa665, 0xa661, 0xa660, 0xc9ca, 0xa7a6,
+ 0xa7a3, 0xa77d, 0xcaaa, 0xcaab, 0xa7a1, 0xcaad, 0xa77b, 0xcaae,
+ 0xcaac, 0xa77e, 0xa7a2, 0xa7a5, 0xa7a4, 0xa77c, 0xcaaf, 0xa959,
+ 0xcbfe, 0xa95b, 0xa95a, 0xcc40, 0xa958, 0xa957, 0xcbf5, 0xcbf4,
+ 0xcbf2, 0xcbf7, 0xcbf6, 0xcbf3, 0xcbfc, 0xcbfd, 0xcbfa, 0xcbf8,
+ 0xa956, 0xcbfb, 0xa95c, 0xcc41, 0xcbf9, 0xabab, 0xa955, 0xabac,
+ 0xce54, 0xce5a, 0xabb2, 0xce58, 0xce5e, 0xce55, 0xce59, 0xce5b,
+ 0xce5d, 0xce57, 0xce56, 0xce51, 0xce52, 0xabad, 0xabaf, 0xabae,
+ 0xce53, 0xce5c, 0xabb1, 0xce50, 0xd153, 0xd152, 0xd157, 0xd14e,
+ 0xd151, 0xd150, 0xd154, 0xd158, 0xae47, 0xae4a, 0xd14f, 0xd155,
+ 0xae49, 0xd14a, 0xabb0, 0xd4ba, 0xd156, 0xd14d, 0xae48, 0xd14c,
+ 0xd4b1, 0xb0ec, 0xb0f0, 0xd4c1, 0xd4af, 0xd4bd, 0xb0f1, 0xd4bf,
+ 0xd4c5, 0xd4c9, 0xd4c0, 0xd4b4, 0xd4bc, 0xd4ca, 0xd4c8, 0xd4be,
+ 0xd4b9, 0xd4b2, 0xd8a6, 0xd4b0, 0xb0f5, 0xd4b7, 0xb0f6, 0xb0f2,
+ 0xd4ad, 0xd4c3, 0xd4b5, 0xd4b3, 0xd4c6, 0xb0f3, 0xd4cc, 0xb0ed,
+ 0xb0ef, 0xd4bb, 0xd4b6, 0xae4b, 0xb0ee, 0xd4b8, 0xd4c7, 0xd4cb,
+ 0xd4c2, 0xd4c4, 0xd4ae, 0xd8a1, 0xd8aa, 0xd8a9, 0xb3fa, 0xd8a2,
+ 0xb3fb, 0xb3f9, 0xd8a4, 0xb3f6, 0xd8a8, 0xd8a3, 0xd8a5, 0xd87d,
+ 0xb3f4, 0xd8b2, 0xd8b1, 0xd8ae, 0xb3f3, 0xb3f7, 0xb3f8, 0xd14b,
+ 0xd8ab, 0xb3f5, 0xb0f4, 0xd8ad, 0xd87e, 0xd8b0, 0xd8af, 0xd8b3,
+ 0xdcef, 0xd8ac, 0xd8a7, 0xdce7, 0xb6f4, 0xb6f7, 0xb6f2, 0xdce6,
+ 0xdcea, 0xdce5, 0xb6ec, 0xb6f6, 0xdce2, 0xb6f0, 0xdce9, 0xb6ee,
+ 0xb6ed, 0xdcec, 0xb6ef, 0xdcee, 0xdceb, 0xb6eb, 0xb6f5, 0xdcf0,
+ 0xdce4, 0xdced, 0xdce3, 0xb6f1, 0xb6f3, 0xdce8, 0xdcf1, 0xe15d,
+ 0xb9d0, 0xe163, 0xb9d5, 0xe15f, 0xe166, 0xe157, 0xb9d7, 0xb9d1,
+ 0xe15c, 0xbc55, 0xe15b, 0xe164, 0xb9d2, 0xb9d6, 0xe15a, 0xe160,
+ 0xe165, 0xe156, 0xb9d4, 0xe15e, 0xe162, 0xe168, 0xe158, 0xe161,
+ 0xb9d3, 0xe167, 0xe159, 0xbc59, 0xe54b, 0xbc57, 0xbc56, 0xe54d,
+ 0xe552, 0xe54e, 0xe551, 0xbc5c, 0xbea5, 0xbc5b, 0xe54a, 0xe550,
+ 0xbc5a, 0xe54f, 0xe54c, 0xbc58, 0xe94d, 0xe94f, 0xe94a, 0xbec1,
+ 0xe94c, 0xbec0, 0xe94e, 0xbec3, 0xe950, 0xbec2, 0xe949, 0xe94b,
+ 0xc0a5, 0xeccc, 0xc0a4, 0xeccd, 0xc0a3, 0xeccb, 0xc0a2, 0xecca,
+ 0xc253, 0xc252, 0xf1f6, 0xf1f8, 0xf1f7, 0xc361, 0xc362, 0xc363,
+ 0xf442, 0xc45b, 0xf7d3, 0xf7d2, 0xc5f2, 0xa468, 0xa4d0, 0xa7a7,
+ 0xce5f, 0xb3fc, 0xb3fd, 0xdcf2, 0xb9d8, 0xe169, 0xe553, 0xc95a,
+ 0xcab0, 0xcc42, 0xce60, 0xd159, 0xae4c, 0xf1f9, 0xc4dc, 0xa469,
+ 0xa57e, 0xc970, 0xa667, 0xa668, 0xa95d, 0xb0f7, 0xb9da, 0xb9db,
+ 0xb9d9, 0xa46a, 0xa4d1, 0xa4d3, 0xa4d2, 0xc95b, 0xa4d4, 0xa5a1,
+ 0xc971, 0xa5a2, 0xa669, 0xa66a, 0xc9cb, 0xa7a8, 0xcab1, 0xa961,
+ 0xcc43, 0xa95f, 0xa960, 0xa95e, 0xd15a, 0xabb6, 0xabb5, 0xabb7,
+ 0xabb4, 0xce61, 0xa962, 0xabb3, 0xae4d, 0xae4e, 0xae4f, 0xd4cd,
+ 0xb3fe, 0xd8b4, 0xb0f8, 0xb6f8, 0xb9dd, 0xb9dc, 0xe16a, 0xbc5d,
+ 0xbec4, 0xefc0, 0xf6da, 0xf7d4, 0xa46b, 0xa5a3, 0xa5a4, 0xc9d1,
+ 0xa66c, 0xa66f, 0xc9cf, 0xc9cd, 0xa66e, 0xc9d0, 0xc9d2, 0xc9cc,
+ 0xa671, 0xa670, 0xa66d, 0xa66b, 0xc9ce, 0xa7b3, 0xa7b0, 0xcab6,
+ 0xcab9, 0xcab8, 0xa7aa, 0xa7b2, 0xa7af, 0xcab5, 0xcab3, 0xa7ae,
+ 0xa7a9, 0xa7ac, 0xcab4, 0xcabb, 0xcab7, 0xa7ad, 0xa7b1, 0xa7b4,
+ 0xcab2, 0xcaba, 0xa7ab, 0xa967, 0xa96f, 0xcc4f, 0xcc48, 0xa970,
+ 0xcc53, 0xcc44, 0xcc4b, 0xa966, 0xcc45, 0xa964, 0xcc4c, 0xcc50,
+ 0xa963, 0xcc51, 0xcc4a, 0xcc4d, 0xa972, 0xa969, 0xcc54, 0xcc52,
+ 0xa96e, 0xa96c, 0xcc49, 0xa96b, 0xcc47, 0xcc46, 0xa96a, 0xa968,
+ 0xa971, 0xa96d, 0xa965, 0xcc4e, 0xabb9, 0xabc0, 0xce6f, 0xabb8,
+ 0xce67, 0xce63, 0xce73, 0xce62, 0xabbb, 0xce6c, 0xabbe, 0xabc1,
+ 0xabbc, 0xce70, 0xabbf, 0xae56, 0xce76, 0xce64, 0xce66, 0xce6d,
+ 0xce71, 0xce75, 0xce72, 0xce6b, 0xce6e, 0xce68, 0xabc3, 0xce6a,
+ 0xce69, 0xce74, 0xabba, 0xce65, 0xabc2, 0xabbd, 0xae5c, 0xd162,
+ 0xae5b, 0xd160, 0xae50, 0xae55, 0xd15f, 0xd15c, 0xd161, 0xae51,
+ 0xd15b, 0xae54, 0xae52, 0xd163, 0xae53, 0xae57, 0xae58, 0xae5a,
+ 0xae59, 0xd15d, 0xd15e, 0xd164, 0xd4d4, 0xb0f9, 0xd8c2, 0xd4d3,
+ 0xd4e6, 0xb140, 0xd4e4, 0xb0fe, 0xb0fa, 0xd4ed, 0xd4dd, 0xd4e0,
+ 0xb143, 0xd4ea, 0xd4e2, 0xb0fb, 0xb144, 0xd4e7, 0xd4e5, 0xd4d6,
+ 0xd4eb, 0xd4df, 0xd4da, 0xd4d0, 0xd4ec, 0xd4dc, 0xd4cf, 0xb142,
+ 0xd4e1, 0xd4ee, 0xd4de, 0xd4d2, 0xd4d7, 0xd4ce, 0xb141, 0xd4db,
+ 0xd4d8, 0xb0fc, 0xd4d1, 0xd4e9, 0xb0fd, 0xd4d9, 0xd4d5, 0xd4e8,
+ 0xb440, 0xd8bb, 0xd8b8, 0xd8c9, 0xd8bd, 0xd8ca, 0xb442, 0xd8c6,
+ 0xd8c3, 0xd8c4, 0xd8c7, 0xd8cb, 0xd4e3, 0xd8cd, 0xdd47, 0xb443,
+ 0xd8ce, 0xd8b6, 0xd8c0, 0xd8c5, 0xb441, 0xb444, 0xd8cc, 0xd8cf,
+ 0xd8ba, 0xd8b7, 0xd8b9, 0xd8be, 0xd8bc, 0xb445, 0xd8c8, 0xd8bf,
+ 0xd8c1, 0xd8b5, 0xdcfa, 0xdcf8, 0xb742, 0xb740, 0xdd43, 0xdcf9,
+ 0xdd44, 0xdd40, 0xdcf7, 0xdd46, 0xdcf6, 0xdcfd, 0xb6fe, 0xb6fd,
+ 0xb6fc, 0xdcfb, 0xdd41, 0xb6f9, 0xb741, 0xdcf4, 0xdcfe, 0xdcf3,
+ 0xdcfc, 0xb6fa, 0xdd42, 0xdcf5, 0xb6fb, 0xdd45, 0xe16e, 0xb9e2,
+ 0xb9e1, 0xb9e3, 0xe17a, 0xe170, 0xe176, 0xe16b, 0xe179, 0xe178,
+ 0xe17c, 0xe175, 0xb9de, 0xe174, 0xb9e4, 0xe16d, 0xb9df, 0xe17b,
+ 0xb9e0, 0xe16f, 0xe172, 0xe177, 0xe171, 0xe16c, 0xe173, 0xe555,
+ 0xbc61, 0xe558, 0xe557, 0xe55a, 0xe55c, 0xbc5f, 0xe556, 0xe554,
+ 0xe55d, 0xe55b, 0xe559, 0xe55f, 0xe55e, 0xbc63, 0xbc5e, 0xbc60,
+ 0xbc62, 0xe560, 0xe957, 0xe956, 0xe955, 0xe958, 0xe951, 0xe952,
+ 0xe95a, 0xe953, 0xbec5, 0xe95c, 0xe95b, 0xe954, 0xecd1, 0xc0a8,
+ 0xeccf, 0xecd4, 0xecd3, 0xe959, 0xc0a7, 0xecd2, 0xecce, 0xecd6,
+ 0xecd5, 0xc0a6, 0xecd0, 0xbec6, 0xc254, 0xefc1, 0xf1fa, 0xf1fb,
+ 0xf1fc, 0xc45c, 0xc45d, 0xf443, 0xf5c8, 0xf5c7, 0xf6db, 0xf6dc,
+ 0xf7d5, 0xf8a7, 0xa46c, 0xa46d, 0xa46e, 0xa4d5, 0xa5a5, 0xc9d3,
+ 0xa672, 0xa673, 0xa7b7, 0xa7b8, 0xa7b6, 0xa7b5, 0xa973, 0xcc55,
+ 0xa975, 0xa974, 0xcc56, 0xabc4, 0xae5d, 0xd165, 0xd4f0, 0xb145,
+ 0xb447, 0xd4ef, 0xb446, 0xb9e5, 0xe17d, 0xbec7, 0xc0a9, 0xecd7,
+ 0xc45e, 0xc570, 0xc972, 0xa5a6, 0xc973, 0xa676, 0xa674, 0xa675,
+ 0xa677, 0xa7ba, 0xa7b9, 0xcabc, 0xa7bb, 0xcabd, 0xcc57, 0xcc58,
+ 0xa976, 0xa978, 0xa97a, 0xa977, 0xa97b, 0xa979, 0xabc8, 0xabc5,
+ 0xabc7, 0xabc9, 0xabc6, 0xd166, 0xce77, 0xd168, 0xd167, 0xae63,
+ 0xae5f, 0xae60, 0xae62, 0xae64, 0xae61, 0xae66, 0xae65, 0xb14a,
+ 0xd4f2, 0xd4f1, 0xb149, 0xb148, 0xb147, 0xb14b, 0xb146, 0xd8d5,
+ 0xd8d2, 0xb449, 0xd8d1, 0xd8d6, 0xb44b, 0xd8d4, 0xb448, 0xb44a,
+ 0xd8d3, 0xdd48, 0xdd49, 0xdd4a, 0xb9e6, 0xb9ee, 0xe17e, 0xb9e8,
+ 0xb9ec, 0xe1a1, 0xb9ed, 0xb9e9, 0xb9ea, 0xb9e7, 0xb9eb, 0xbc66,
+ 0xd8d0, 0xbc67, 0xbc65, 0xbc64, 0xe95d, 0xbec8, 0xecd8, 0xecd9,
+ 0xc364, 0xc45f, 0xa46f, 0xa678, 0xabca, 0xd169, 0xae67, 0xb14e,
+ 0xb14d, 0xb14c, 0xb44c, 0xb44d, 0xd8d7, 0xb9ef, 0xbec9, 0xa470,
+ 0xc95c, 0xa4d6, 0xc974, 0xc9d4, 0xa679, 0xa97c, 0xdd4b, 0xa471,
+ 0xa4d7, 0xc9d5, 0xcabe, 0xcabf, 0xa7bc, 0xd8d8, 0xb44e, 0xdd4c,
+ 0xc0aa, 0xa472, 0xa4a8, 0xa4d8, 0xc975, 0xa5a7, 0xa7c0, 0xa7bf,
+ 0xa7bd, 0xa7be, 0xcc59, 0xa97e, 0xa9a1, 0xcc5a, 0xa97d, 0xabce,
+ 0xce78, 0xabcd, 0xabcb, 0xabcc, 0xae6a, 0xae68, 0xd16b, 0xae69,
+ 0xd16a, 0xae5e, 0xd4f3, 0xb150, 0xb151, 0xb14f, 0xb9f0, 0xe1a2,
+ 0xbc68, 0xbc69, 0xe561, 0xc0ab, 0xefc2, 0xefc3, 0xc4dd, 0xf8a8,
+ 0xc94b, 0xa4d9, 0xa473, 0xc977, 0xc976, 0xa67a, 0xc9d7, 0xc9d8,
+ 0xc9d6, 0xc9d9, 0xcac7, 0xcac2, 0xcac4, 0xcac6, 0xcac3, 0xa7c4,
+ 0xcac0, 0xcac1, 0xa7c1, 0xa7c2, 0xcac5, 0xcac8, 0xa7c3, 0xcac9,
+ 0xcc68, 0xcc62, 0xcc5d, 0xa9a3, 0xcc65, 0xcc63, 0xcc5c, 0xcc69,
+ 0xcc6c, 0xcc67, 0xcc60, 0xa9a5, 0xcc66, 0xa9a6, 0xcc61, 0xcc64,
+ 0xcc5b, 0xcc5f, 0xcc6b, 0xa9a7, 0xa9a8, 0xcc5e, 0xcc6a, 0xa9a2,
+ 0xa9a4, 0xceab, 0xcea4, 0xceaa, 0xcea3, 0xcea5, 0xce7d, 0xce7b,
+ 0xceac, 0xcea9, 0xce79, 0xabd0, 0xcea7, 0xcea8, 0xcea6, 0xce7c,
+ 0xce7a, 0xabcf, 0xcea2, 0xce7e, 0xcea1, 0xcead, 0xae6f, 0xae6e,
+ 0xd16c, 0xae6b, 0xd16e, 0xae70, 0xd16f, 0xae73, 0xae71, 0xd170,
+ 0xceae, 0xd172, 0xae6d, 0xae6c, 0xd16d, 0xd171, 0xae72, 0xb153,
+ 0xb152, 0xd4f5, 0xd4f9, 0xd4fb, 0xb154, 0xd4fe, 0xb158, 0xd541,
+ 0xb15a, 0xb156, 0xb15e, 0xb15b, 0xd4f7, 0xb155, 0xd4f6, 0xd4f4,
+ 0xd543, 0xd4f8, 0xb157, 0xd542, 0xb15c, 0xd4fd, 0xd4fc, 0xb15d,
+ 0xd4fa, 0xb159, 0xd544, 0xd540, 0xd8e7, 0xd8ee, 0xd8e3, 0xb451,
+ 0xd8df, 0xd8ef, 0xd8d9, 0xd8ec, 0xd8ea, 0xd8e4, 0xd8ed, 0xd8e6,
+ 0xd8de, 0xd8f0, 0xd8dc, 0xd8e9, 0xd8da, 0xd8f1, 0xb452, 0xd8eb,
+ 0xdd4f, 0xd8dd, 0xb44f, 0xd8e1, 0xb450, 0xd8e0, 0xd8e5, 0xd8e2,
+ 0xd8e8, 0xdd53, 0xdd56, 0xdd4e, 0xdd50, 0xdd55, 0xdd54, 0xb743,
+ 0xd8db, 0xdd52, 0xb744, 0xdd4d, 0xdd51, 0xe1a9, 0xe1b0, 0xe1a7,
+ 0xe1ae, 0xe1a5, 0xe1ad, 0xe1b1, 0xe1a4, 0xe1a8, 0xe1a3, 0xb9f1,
+ 0xe1a6, 0xb9f2, 0xe1ac, 0xe1ab, 0xe1aa, 0xe1af, 0xe565, 0xe567,
+ 0xbc6b, 0xe568, 0xe563, 0xe562, 0xe56c, 0xe56a, 0xbc6a, 0xe56d,
+ 0xe564, 0xe569, 0xe56b, 0xe566, 0xe961, 0xe966, 0xe960, 0xe965,
+ 0xe95e, 0xe968, 0xe964, 0xe969, 0xe963, 0xe95f, 0xe967, 0xe96a,
+ 0xe962, 0xecda, 0xc0af, 0xc0ad, 0xc0ac, 0xc0ae, 0xefc4, 0xf172,
+ 0xf1fd, 0xf444, 0xf445, 0xc460, 0xf5c9, 0xc4de, 0xf5ca, 0xf6de,
+ 0xc572, 0xc571, 0xf6dd, 0xc5c9, 0xf7d6, 0xa474, 0xa67b, 0xc9da,
+ 0xcaca, 0xa8b5, 0xb15f, 0xa475, 0xa5aa, 0xa5a9, 0xa5a8, 0xa7c5,
+ 0xae74, 0xdd57, 0xa476, 0xa477, 0xa478, 0xa4da, 0xabd1, 0xceaf,
+ 0xb453, 0xa479, 0xc95d, 0xa5ab, 0xa5ac, 0xc978, 0xa67c, 0xcacb,
+ 0xa7c6, 0xcacc, 0xa9ae, 0xcc6e, 0xa9ac, 0xa9ab, 0xcc6d, 0xa9a9,
+ 0xcc6f, 0xa9aa, 0xa9ad, 0xabd2, 0xabd4, 0xceb3, 0xceb0, 0xceb1,
+ 0xceb2, 0xceb4, 0xabd3, 0xd174, 0xd173, 0xae76, 0xae75, 0xb162,
+ 0xd546, 0xb161, 0xb163, 0xb160, 0xb455, 0xd545, 0xb456, 0xd8f3,
+ 0xb457, 0xd8f2, 0xb454, 0xdd5a, 0xdd5c, 0xb745, 0xdd5b, 0xdd59,
+ 0xdd58, 0xe1b4, 0xb9f7, 0xb9f5, 0xb9f6, 0xe1b2, 0xe1b3, 0xb9f3,
+ 0xe571, 0xe56f, 0xbc6d, 0xe570, 0xbc6e, 0xbc6c, 0xb9f4, 0xe96d,
+ 0xe96b, 0xe96c, 0xe56e, 0xecdc, 0xc0b0, 0xecdb, 0xefc5, 0xefc6,
+ 0xe96e, 0xf1fe, 0xa47a, 0xa5ad, 0xa67e, 0xc9db, 0xa67d, 0xa9af,
+ 0xb746, 0xa4db, 0xa5ae, 0xabd5, 0xb458, 0xc979, 0xc97a, 0xc9dc,
+ 0xa7c8, 0xcad0, 0xcace, 0xa7c9, 0xcacd, 0xcacf, 0xcad1, 0xa7c7,
+ 0xa9b3, 0xa9b4, 0xa9b1, 0xa9b0, 0xceb8, 0xa9b2, 0xabd6, 0xceb7,
+ 0xceb9, 0xceb6, 0xceba, 0xabd7, 0xae79, 0xd175, 0xd177, 0xae77,
+ 0xd178, 0xae78, 0xd176, 0xceb5, 0xd547, 0xd54a, 0xd54b, 0xd548,
+ 0xb167, 0xb166, 0xb164, 0xb165, 0xd549, 0xb168, 0xb45a, 0xb45b,
+ 0xb45c, 0xdd5d, 0xdd5f, 0xdd61, 0xb748, 0xb747, 0xb459, 0xdd60,
+ 0xdd5e, 0xe1b8, 0xe1b6, 0xe1bc, 0xb9f8, 0xe1bd, 0xe1ba, 0xb9f9,
+ 0xe1b7, 0xe1b5, 0xe1bb, 0xbc70, 0xe573, 0xe1b9, 0xbc72, 0xe574,
+ 0xbc71, 0xbc74, 0xe575, 0xbc6f, 0xbc73, 0xe973, 0xe971, 0xe970,
+ 0xe972, 0xe96f, 0xc366, 0xf446, 0xf447, 0xf5cb, 0xf6df, 0xc655,
+ 0xa9b5, 0xa7ca, 0xabd8, 0xa47b, 0xa4dc, 0xa5af, 0xc9dd, 0xa7cb,
+ 0xcad2, 0xcebb, 0xabd9, 0xb9fa, 0xa47c, 0xa6a1, 0xb749, 0xa47d,
+ 0xa4dd, 0xa4de, 0xa5b1, 0xa5b0, 0xc9de, 0xa6a2, 0xcad3, 0xa7cc,
+ 0xcc71, 0xcc72, 0xcc73, 0xa9b6, 0xa9b7, 0xcc70, 0xa9b8, 0xabda,
+ 0xcebc, 0xd17a, 0xae7a, 0xd179, 0xb169, 0xd54c, 0xb16a, 0xd54d,
+ 0xb45d, 0xdd62, 0xe1bf, 0xe1be, 0xb9fb, 0xbc75, 0xe576, 0xbeca,
+ 0xe974, 0xc0b1, 0xc573, 0xf7d8, 0xcc74, 0xcebd, 0xb16b, 0xd8f4,
+ 0xb74a, 0xc255, 0xa7ce, 0xa7cd, 0xabdb, 0xd17b, 0xb16d, 0xb343,
+ 0xb16e, 0xb16c, 0xb45e, 0xe1c0, 0xb9fc, 0xbc76, 0xc94c, 0xc9df,
+ 0xcad5, 0xa7cf, 0xcad4, 0xa7d0, 0xa9bc, 0xcc77, 0xcc76, 0xa9bb,
+ 0xa9b9, 0xa9ba, 0xcc75, 0xabdd, 0xcebe, 0xabe0, 0xabdc, 0xabe2,
+ 0xabde, 0xabdf, 0xabe1, 0xae7d, 0xae7c, 0xae7b, 0xd54f, 0xb16f,
+ 0xb172, 0xb170, 0xd54e, 0xb175, 0xb171, 0xd550, 0xb174, 0xb173,
+ 0xd8f6, 0xd8f5, 0xb461, 0xb45f, 0xb460, 0xd8f7, 0xb74b, 0xdd64,
+ 0xb74c, 0xdd63, 0xe577, 0xbc78, 0xe1c1, 0xbc77, 0xb9fd, 0xecde,
+ 0xe975, 0xc0b2, 0xecdd, 0xf240, 0xf448, 0xf449, 0xa4df, 0xa5b2,
+ 0xc97b, 0xa7d2, 0xa7d4, 0xc9e2, 0xcad8, 0xcad7, 0xcad6, 0xc9e1,
+ 0xc9e0, 0xa6a4, 0xa7d3, 0xa7d1, 0xa6a3, 0xa9bd, 0xcc78, 0xa9be,
+ 0xcadd, 0xcadf, 0xcade, 0xcc79, 0xcada, 0xa7d8, 0xa7d6, 0xcad9,
+ 0xcadb, 0xcae1, 0xa7d5, 0xcadc, 0xcae5, 0xa9c0, 0xcae2, 0xa7d7,
+ 0xcae0, 0xcae3, 0xa9bf, 0xa9c1, 0xcae4, 0xccaf, 0xcca2, 0xcc7e,
+ 0xccae, 0xcca9, 0xabe7, 0xa9c2, 0xccaa, 0xccad, 0xabe3, 0xccac,
+ 0xa9c3, 0xa9c8, 0xa9c6, 0xcca3, 0xcc7c, 0xcca5, 0xa9cd, 0xccb0,
+ 0xabe4, 0xcca6, 0xabe5, 0xa9c9, 0xcca8, 0xcecd, 0xabe6, 0xcc7b,
+ 0xa9ca, 0xabe8, 0xa9cb, 0xa9c7, 0xa9cc, 0xcca7, 0xcc7a, 0xccab,
+ 0xa9c4, 0xcc7d, 0xcca4, 0xcca1, 0xa9c5, 0xcebf, 0xcec0, 0xceca,
+ 0xd1a1, 0xcecb, 0xabee, 0xcece, 0xcec4, 0xabed, 0xcec6, 0xcec7,
+ 0xcec9, 0xabe9, 0xaea3, 0xcec5, 0xcec1, 0xaea4, 0xcecf, 0xae7e,
+ 0xd17d, 0xcec8, 0xd17c, 0xcec3, 0xcecc, 0xabec, 0xaea1, 0xabf2,
+ 0xaea2, 0xced0, 0xd17e, 0xabeb, 0xaea6, 0xabf1, 0xabf0, 0xabef,
+ 0xaea5, 0xced1, 0xaea7, 0xabea, 0xcec2, 0xb176, 0xd1a4, 0xd1a6,
+ 0xd1a8, 0xaea8, 0xaeae, 0xd553, 0xd1ac, 0xd1a3, 0xb178, 0xd551,
+ 0xaead, 0xaeab, 0xd1ae, 0xd552, 0xd1a5, 0xaeac, 0xd1a9, 0xaeaf,
+ 0xd1ab, 0xaeaa, 0xd1aa, 0xd1ad, 0xd1a7, 0xaea9, 0xb179, 0xd1a2,
+ 0xb177, 0xb17a, 0xd555, 0xd55e, 0xb464, 0xb17c, 0xb1a3, 0xb465,
+ 0xd560, 0xb1aa, 0xd8f9, 0xd556, 0xb1a2, 0xb1a5, 0xb17e, 0xd554,
+ 0xd562, 0xd565, 0xd949, 0xd563, 0xd8fd, 0xb1a1, 0xb1a8, 0xb1ac,
+ 0xd55d, 0xd8f8, 0xd561, 0xb17b, 0xd8fa, 0xd564, 0xd8fc, 0xd559,
+ 0xb462, 0xd557, 0xd558, 0xb1a7, 0xb1a6, 0xd55b, 0xb1ab, 0xd55f,
+ 0xb1a4, 0xd55c, 0xb1a9, 0xb466, 0xb463, 0xd8fb, 0xd55a, 0xb17d,
+ 0xb46b, 0xb46f, 0xd940, 0xb751, 0xb46d, 0xd944, 0xb471, 0xdd65,
+ 0xd946, 0xb753, 0xb469, 0xb46c, 0xd947, 0xd948, 0xd94e, 0xb473,
+ 0xb754, 0xd94a, 0xd94f, 0xd943, 0xb75e, 0xb755, 0xb472, 0xd941,
+ 0xd950, 0xb75d, 0xb470, 0xb74e, 0xd94d, 0xb474, 0xd945, 0xd8fe,
+ 0xb46a, 0xd942, 0xd94b, 0xb74d, 0xb752, 0xb467, 0xd94c, 0xb750,
+ 0xb468, 0xb75c, 0xe1c3, 0xdd70, 0xdd68, 0xe1c2, 0xdd6c, 0xdd6e,
+ 0xdd6b, 0xb75b, 0xdd6a, 0xb75f, 0xe1d2, 0xb75a, 0xba40, 0xdd71,
+ 0xe1c4, 0xb758, 0xdd69, 0xdd6d, 0xb9fe, 0xb74f, 0xdd66, 0xdd67,
+ 0xba41, 0xb757, 0xb759, 0xb756, 0xdd6f, 0xe1c8, 0xe1c9, 0xe1ce,
+ 0xbc7d, 0xe1d5, 0xba47, 0xba46, 0xe1d0, 0xbc7c, 0xe1c5, 0xba45,
+ 0xe1d4, 0xba43, 0xba44, 0xe1d1, 0xe5aa, 0xbc7a, 0xb46e, 0xe1d3,
+ 0xbca3, 0xe1cb, 0xbc7b, 0xbca2, 0xe1c6, 0xe1ca, 0xe1c7, 0xe1cd,
+ 0xba48, 0xbc79, 0xba42, 0xe57a, 0xe1cf, 0xbca1, 0xbca4, 0xe1cc,
+ 0xbc7e, 0xe579, 0xe57e, 0xbece, 0xe578, 0xe9a3, 0xe5a9, 0xbca8,
+ 0xbca6, 0xbecc, 0xe5a6, 0xe5a2, 0xbcac, 0xe978, 0xbcaa, 0xe5a1,
+ 0xe976, 0xe5a5, 0xe5a8, 0xe57d, 0xbcab, 0xbca5, 0xe977, 0xbecd,
+ 0xe5a7, 0xbca7, 0xbca9, 0xe5a4, 0xbcad, 0xe5a3, 0xe57c, 0xe57b,
+ 0xbecb, 0xe5ab, 0xe97a, 0xece0, 0xbed0, 0xe9a2, 0xe97e, 0xece1,
+ 0xbed1, 0xe9a1, 0xe97c, 0xc0b4, 0xecdf, 0xe979, 0xe97b, 0xc0b5,
+ 0xbed3, 0xc0b3, 0xbed2, 0xc0b7, 0xe97d, 0xbecf, 0xefcf, 0xefc7,
+ 0xece7, 0xefc8, 0xece3, 0xc256, 0xece5, 0xece4, 0xc0b6, 0xece2,
+ 0xece6, 0xefd0, 0xefcc, 0xefce, 0xefc9, 0xefca, 0xefcd, 0xefcb,
+ 0xc367, 0xc36a, 0xc369, 0xc368, 0xc461, 0xf44a, 0xc462, 0xf241,
+ 0xc4df, 0xf5cc, 0xc4e0, 0xc574, 0xc5ca, 0xf7d9, 0xf7da, 0xf7db,
+ 0xf9ba, 0xa4e0, 0xc97c, 0xa5b3, 0xa6a6, 0xa6a7, 0xa6a5, 0xa6a8,
+ 0xa7da, 0xa7d9, 0xccb1, 0xa9cf, 0xa9ce, 0xd1af, 0xb1ad, 0xb1ae,
+ 0xb475, 0xdd72, 0xb760, 0xb761, 0xdd74, 0xdd76, 0xdd75, 0xe1d7,
+ 0xe1d6, 0xba49, 0xe1d8, 0xe5ac, 0xbcae, 0xbed4, 0xc0b8, 0xc257,
+ 0xc0b9, 0xa4e1, 0xcae6, 0xccb2, 0xa9d1, 0xa9d0, 0xa9d2, 0xabf3,
+ 0xced2, 0xced3, 0xd1b0, 0xaeb0, 0xb1af, 0xb476, 0xd951, 0xa4e2,
+ 0xa47e, 0xa4e3, 0xc97d, 0xa5b7, 0xa5b6, 0xa5b4, 0xa5b5, 0xa6ab,
+ 0xc9e9, 0xc9eb, 0xa6aa, 0xc9e3, 0xc9e4, 0xc9ea, 0xc9e6, 0xc9e8,
+ 0xa6a9, 0xc9e5, 0xc9ec, 0xc9e7, 0xa7e1, 0xa7ea, 0xa7e8, 0xcaf0,
+ 0xcaed, 0xcaf5, 0xa7e6, 0xcaf6, 0xa7df, 0xcaf3, 0xa7e5, 0xcaef,
+ 0xcaee, 0xa7e3, 0xcaf4, 0xa7e4, 0xa9d3, 0xa7de, 0xcaf1, 0xcae7,
+ 0xa7db, 0xa7ee, 0xcaec, 0xcaf2, 0xa7e0, 0xa7e2, 0xcae8, 0xcae9,
+ 0xcaea, 0xa7ed, 0xa7e7, 0xa7ec, 0xcaeb, 0xa7eb, 0xa7dd, 0xa7dc,
+ 0xa7e9, 0xa9e1, 0xccbe, 0xccb7, 0xa9dc, 0xa9ef, 0xccb3, 0xccba,
+ 0xccbc, 0xccbf, 0xa9ea, 0xccbb, 0xccb4, 0xa9e8, 0xccb8, 0xccc0,
+ 0xa9d9, 0xccbd, 0xa9e3, 0xa9e2, 0xccb6, 0xa9d7, 0xa9d8, 0xa9d6,
+ 0xa9ee, 0xa9e6, 0xa9e0, 0xa9d4, 0xccb9, 0xa9df, 0xa9d5, 0xa9e7,
+ 0xa9f0, 0xced4, 0xa9e4, 0xccb5, 0xa9da, 0xa9dd, 0xa9de, 0xa9ec,
+ 0xa9ed, 0xa9eb, 0xa9e5, 0xa9e9, 0xa9db, 0xabf4, 0xceda, 0xac41,
+ 0xabf8, 0xabfa, 0xac40, 0xcee6, 0xabfd, 0xd1b1, 0xaeb1, 0xac43,
+ 0xced7, 0xcedf, 0xabfe, 0xcede, 0xcedb, 0xcee3, 0xcee5, 0xabf7,
+ 0xabfb, 0xac42, 0xaeb3, 0xcee0, 0xabf9, 0xac45, 0xced9, 0xabfc,
+ 0xaeb2, 0xabf6, 0xced6, 0xcedd, 0xced5, 0xced8, 0xcedc, 0xd1b2,
+ 0xac44, 0xcee1, 0xcee2, 0xcee4, 0xabf5, 0xaec1, 0xd1be, 0xaebf,
+ 0xaec0, 0xd1b4, 0xd1c4, 0xaeb6, 0xd566, 0xd1c6, 0xd1c0, 0xd1b7,
+ 0xd1c9, 0xd1ba, 0xaebc, 0xd57d, 0xd1bd, 0xaebe, 0xaeb5, 0xd1cb,
+ 0xd1bf, 0xaeb8, 0xd1b8, 0xd1b5, 0xd1b6, 0xaeb9, 0xd1c5, 0xd1cc,
+ 0xaebb, 0xd1bc, 0xd1bb, 0xaec3, 0xaec2, 0xaeb4, 0xaeba, 0xaebd,
+ 0xd1c8, 0xd1c2, 0xaeb7, 0xd1b3, 0xd1ca, 0xd1c1, 0xd1c3, 0xd1c7,
+ 0xd567, 0xb1b7, 0xb1cb, 0xb1ca, 0xb1bf, 0xd579, 0xd575, 0xd572,
+ 0xd5a6, 0xb1ba, 0xb1b2, 0xd577, 0xb4a8, 0xb1b6, 0xd5a1, 0xb1cc,
+ 0xb1c9, 0xd57b, 0xd56a, 0xb1c8, 0xd5a3, 0xd569, 0xb1bd, 0xb1c1,
+ 0xd5a2, 0xd573, 0xb1c2, 0xb1bc, 0xd568, 0xb478, 0xd5a5, 0xd571,
+ 0xb1c7, 0xd574, 0xd5a4, 0xb1c6, 0xd952, 0xb1b3, 0xd56f, 0xb1b8,
+ 0xb1c3, 0xb1be, 0xd578, 0xd56e, 0xd56c, 0xd57e, 0xb1b0, 0xb1c4,
+ 0xb1b4, 0xb477, 0xd57c, 0xb1b5, 0xb1b1, 0xb1c0, 0xb1bb, 0xb1b9,
+ 0xd570, 0xb1c5, 0xd56d, 0xd57a, 0xd576, 0xd954, 0xd953, 0xd56b,
+ 0xd964, 0xb47a, 0xd96a, 0xd959, 0xd967, 0xdd77, 0xb47d, 0xd96b,
+ 0xd96e, 0xb47c, 0xd95c, 0xd96d, 0xd96c, 0xb47e, 0xd955, 0xb479,
+ 0xb4a3, 0xb4a1, 0xd969, 0xd95f, 0xb4a5, 0xd970, 0xd968, 0xd971,
+ 0xb4ad, 0xb4ab, 0xd966, 0xd965, 0xd963, 0xd95d, 0xb4a4, 0xb4a2,
+ 0xd1b9, 0xd956, 0xddb7, 0xd957, 0xb47b, 0xb4aa, 0xdd79, 0xb4a6,
+ 0xb4a7, 0xd958, 0xd96f, 0xdd78, 0xd960, 0xd95b, 0xb4a9, 0xd961,
+ 0xd95e, 0xb4ae, 0xb770, 0xdd7c, 0xddb1, 0xddb6, 0xddaa, 0xb76c,
+ 0xddbb, 0xb769, 0xdd7a, 0xdd7b, 0xb762, 0xb76b, 0xdda4, 0xb76e,
+ 0xb76f, 0xdda5, 0xddb2, 0xddb8, 0xb76a, 0xb764, 0xdda3, 0xdd7d,
+ 0xddba, 0xdda8, 0xdda9, 0xdd7e, 0xddb4, 0xddab, 0xddb5, 0xddad,
+ 0xb765, 0xe1d9, 0xb768, 0xb766, 0xddb9, 0xddb0, 0xddac, 0xdda1,
+ 0xba53, 0xddaf, 0xb76d, 0xdda7, 0xdda6, 0xb767, 0xb763, 0xe1ee,
+ 0xddb3, 0xddae, 0xdda2, 0xe1e9, 0xe1da, 0xe1e5, 0xe1ec, 0xba51,
+ 0xb4ac, 0xe1ea, 0xba4c, 0xba4b, 0xe1f1, 0xe1db, 0xe1e8, 0xe1dc,
+ 0xe1e7, 0xba4f, 0xe1eb, 0xd962, 0xe1f2, 0xe1e3, 0xba52, 0xe5ba,
+ 0xbcaf, 0xe1f0, 0xe1ef, 0xba54, 0xe5ad, 0xbcb0, 0xe5ae, 0xe1df,
+ 0xe1e0, 0xe1dd, 0xe1e2, 0xe1de, 0xe1f3, 0xba4e, 0xbcb1, 0xba50,
+ 0xba55, 0xe1e1, 0xe1ed, 0xe1e6, 0xe5b1, 0xba4a, 0xbcb4, 0xe9aa,
+ 0xe5b6, 0xe5b5, 0xe5b7, 0xe5b4, 0xbcb5, 0xbcbb, 0xbcb8, 0xbcb9,
+ 0xe5af, 0xe5b2, 0xe5bc, 0xbcc1, 0xbcbf, 0xe5b3, 0xd95a, 0xbcb2,
+ 0xe5b9, 0xe5b0, 0xbcc2, 0xe5b8, 0xba4d, 0xbcb7, 0xe1e4, 0xbcba,
+ 0xbcbe, 0xbcc0, 0xbcbd, 0xbcbc, 0xbcb6, 0xe5bb, 0xbcb3, 0xbcc3,
+ 0xbed8, 0xbed9, 0xe9a9, 0xbee2, 0xbedf, 0xbed6, 0xbedd, 0xe9ab,
+ 0xbedb, 0xbed5, 0xbedc, 0xe9a8, 0xc0bb, 0xbed7, 0xbede, 0xc0ba,
+ 0xe9a7, 0xe9a6, 0xbee0, 0xbee1, 0xe9a5, 0xe9a4, 0xc0bc, 0xe9ae,
+ 0xbeda, 0xe9ac, 0xc0bd, 0xc0c2, 0xecea, 0xecec, 0xc0bf, 0xeced,
+ 0xece9, 0xeceb, 0xc0c0, 0xc0c3, 0xece8, 0xc0be, 0xc0c1, 0xc259,
+ 0xe9ad, 0xc258, 0xc25e, 0xefd4, 0xc25c, 0xc25d, 0xefd7, 0xefd3,
+ 0xc25a, 0xefd1, 0xc36b, 0xefd5, 0xefd6, 0xefd2, 0xc25b, 0xf242,
+ 0xf245, 0xf246, 0xf244, 0xf247, 0xc36c, 0xf243, 0xf44e, 0xc464,
+ 0xf44d, 0xf44c, 0xf44b, 0xc463, 0xc465, 0xf5cd, 0xc4e2, 0xc4e1,
+ 0xf6e1, 0xf6e0, 0xf6e3, 0xc5cb, 0xc575, 0xf7dd, 0xf6e2, 0xf7dc,
+ 0xc5cd, 0xc5cc, 0xc5f3, 0xf8a9, 0xf8ef, 0xa4e4, 0xd972, 0xe9af,
+ 0xa6ac, 0xcaf7, 0xa7f1, 0xa7ef, 0xa7f0, 0xccc1, 0xa9f1, 0xac46,
+ 0xcee7, 0xcee8, 0xac47, 0xd1ce, 0xaec4, 0xaec5, 0xd1cd, 0xb1d3,
+ 0xb1cf, 0xd5a7, 0xb1d6, 0xb1d5, 0xb1ce, 0xb1d1, 0xb1d4, 0xb1d0,
+ 0xd976, 0xb1cd, 0xb4af, 0xb4b1, 0xb4b2, 0xd975, 0xd978, 0xb4b0,
+ 0xd973, 0xd977, 0xd974, 0xb771, 0xddbc, 0xba56, 0xe1f4, 0xbee3,
+ 0xbcc4, 0xe5bd, 0xbcc5, 0xbcc6, 0xe5bf, 0xe5be, 0xe5c0, 0xe9b1,
+ 0xe9b0, 0xecef, 0xecee, 0xc0c4, 0xc0c5, 0xf248, 0xa4e5, 0xd979,
+ 0xb4b4, 0xb4b3, 0xddbd, 0xefd8, 0xc4e3, 0xf7de, 0xa4e6, 0xaec6,
+ 0xb1d8, 0xb1d7, 0xd97a, 0xd97b, 0xb772, 0xe1f5, 0xba57, 0xe9b2,
+ 0xa4e7, 0xa5b8, 0xa9f2, 0xccc2, 0xcee9, 0xac48, 0xb1d9, 0xd97c,
+ 0xb4b5, 0xb773, 0xe5c1, 0xe5c2, 0xecf0, 0xc25f, 0xf8f0, 0xa4e8,
+ 0xccc3, 0xa9f3, 0xac49, 0xceea, 0xaec7, 0xd1d2, 0xd1d0, 0xd1d1,
+ 0xaec8, 0xd1cf, 0xb1db, 0xb1dc, 0xd5a8, 0xb1dd, 0xb1da, 0xd97d,
+ 0xd97e, 0xddbe, 0xba59, 0xba58, 0xecf1, 0xefd9, 0xf24a, 0xf249,
+ 0xf44f, 0xc95e, 0xac4a, 0xa4e9, 0xa5b9, 0xa6ae, 0xa6ad, 0xa6af,
+ 0xa6b0, 0xc9ee, 0xc9ed, 0xcaf8, 0xa7f2, 0xcafb, 0xcafa, 0xcaf9,
+ 0xcafc, 0xa9f4, 0xccc9, 0xccc5, 0xccce, 0xa9fb, 0xa9f9, 0xccca,
+ 0xccc6, 0xcccd, 0xa9f8, 0xaa40, 0xccc8, 0xccc4, 0xa9fe, 0xcccb,
+ 0xa9f7, 0xcccc, 0xa9fa, 0xa9fc, 0xccd0, 0xcccf, 0xccc7, 0xa9f6,
+ 0xa9f5, 0xa9fd, 0xceef, 0xcef5, 0xac50, 0xac4d, 0xceec, 0xcef1,
+ 0xac53, 0xac4b, 0xcef0, 0xac4e, 0xac51, 0xcef3, 0xac4c, 0xcef8,
+ 0xac4f, 0xac52, 0xceed, 0xcef2, 0xcef6, 0xceee, 0xceeb, 0xcef7,
+ 0xcef4, 0xaed0, 0xaec9, 0xaecc, 0xaecf, 0xd1d5, 0xaeca, 0xd1d3,
+ 0xaece, 0xaecb, 0xd1d6, 0xaecd, 0xd5ac, 0xb1df, 0xd5ab, 0xd5ad,
+ 0xb1de, 0xb1e3, 0xd1d4, 0xd5aa, 0xd5ae, 0xb1e0, 0xd5a9, 0xb1e2,
+ 0xb1e1, 0xd9a7, 0xd9a2, 0xb4b6, 0xb4ba, 0xb4b7, 0xd9a5, 0xd9a8,
+ 0xb4b8, 0xb4b9, 0xb4be, 0xddc7, 0xd9a6, 0xb4bc, 0xd9a3, 0xd9a1,
+ 0xb4bd, 0xd9a4, 0xb779, 0xddbf, 0xb776, 0xb777, 0xb775, 0xddc4,
+ 0xddc3, 0xddc0, 0xb77b, 0xddc2, 0xb4bb, 0xddc6, 0xddc1, 0xb778,
+ 0xb774, 0xb77a, 0xddc5, 0xba5c, 0xe1f8, 0xe1f7, 0xe1f6, 0xba5a,
+ 0xba5b, 0xe5c5, 0xe5c8, 0xbcc8, 0xbcc7, 0xe5c9, 0xe5c4, 0xbcca,
+ 0xe5c6, 0xbcc9, 0xe5c3, 0xe5c7, 0xbee9, 0xbee6, 0xe9bb, 0xe9ba,
+ 0xe9b9, 0xe9b4, 0xe9b5, 0xbee7, 0xbee4, 0xbee8, 0xe9b3, 0xbee5,
+ 0xe9b6, 0xe9b7, 0xe9bc, 0xe9b8, 0xecf2, 0xc0c7, 0xefdc, 0xc0c6,
+ 0xefda, 0xefdb, 0xc260, 0xc36e, 0xf24b, 0xc36d, 0xf451, 0xf452,
+ 0xc466, 0xf450, 0xc4e4, 0xf7df, 0xc5ce, 0xf8aa, 0xf8ab, 0xa4ea,
+ 0xa6b1, 0xa6b2, 0xa7f3, 0xccd1, 0xac54, 0xaed1, 0xb1e4, 0xb0d2,
+ 0xb4bf, 0xb4c0, 0xb3cc, 0xd9a9, 0xb77c, 0xe1fa, 0xe1f9, 0xa4eb,
+ 0xa6b3, 0xccd2, 0xaa42, 0xaa41, 0xcef9, 0xcefa, 0xd1d7, 0xd1d8,
+ 0xaed2, 0xaed3, 0xaed4, 0xd5af, 0xb1e6, 0xb4c2, 0xb4c1, 0xddc8,
+ 0xdf7a, 0xe1fb, 0xe9bd, 0xc261, 0xc467, 0xa4ec, 0xa5bc, 0xa5bd,
+ 0xa5bb, 0xa5be, 0xa5ba, 0xa6b6, 0xc9f6, 0xa6b5, 0xa6b7, 0xc9f1,
+ 0xc9f0, 0xc9f3, 0xc9f2, 0xc9f5, 0xa6b4, 0xc9ef, 0xc9f4, 0xcafd,
+ 0xa7fd, 0xcafe, 0xcb43, 0xa7fc, 0xcb47, 0xcb42, 0xcb45, 0xa7f5,
+ 0xa7f6, 0xa7f7, 0xa7f8, 0xa840, 0xcb41, 0xa7fa, 0xa841, 0xcb40,
+ 0xcb46, 0xa7f9, 0xcb44, 0xa7fb, 0xa7f4, 0xa7fe, 0xaa57, 0xccd4,
+ 0xaa43, 0xaa4d, 0xaa4e, 0xaa46, 0xaa58, 0xaa48, 0xccdc, 0xaa53,
+ 0xccd7, 0xaa49, 0xcce6, 0xcce7, 0xccdf, 0xccd8, 0xaa56, 0xcce4,
+ 0xaa51, 0xaa4f, 0xcce5, 0xcce3, 0xccdb, 0xccd3, 0xccda, 0xaa4a,
+ 0xaa50, 0xaa44, 0xccde, 0xccdd, 0xccd5, 0xaa52, 0xcce1, 0xccd6,
+ 0xaa55, 0xcce8, 0xaa45, 0xaa4c, 0xccd9, 0xcce2, 0xaa54, 0xaa47,
+ 0xaa4b, 0xcce0, 0xcf5b, 0xac5c, 0xac69, 0xcf56, 0xcf4c, 0xac62,
+ 0xcf4a, 0xac5b, 0xcf45, 0xac65, 0xcf52, 0xcefe, 0xcf41, 0xcf44,
+ 0xcefb, 0xcf51, 0xcf61, 0xac60, 0xcf46, 0xcf58, 0xcefd, 0xcf5f,
+ 0xcf60, 0xcf63, 0xcf5a, 0xcf4b, 0xcf53, 0xac66, 0xac59, 0xac61,
+ 0xac6d, 0xac56, 0xac58, 0xcf43, 0xac6a, 0xac63, 0xcf5d, 0xcf40,
+ 0xac6c, 0xac67, 0xcf49, 0xac6b, 0xcf50, 0xcf48, 0xac64, 0xcf5c,
+ 0xcf54, 0xac5e, 0xcf62, 0xcf47, 0xac5a, 0xcf59, 0xcf4f, 0xac5f,
+ 0xcf55, 0xac57, 0xcefc, 0xac68, 0xaee3, 0xac5d, 0xcf4e, 0xcf4d,
+ 0xcf42, 0xcf5e, 0xcf57, 0xac55, 0xd1ec, 0xaeea, 0xd1ed, 0xd1e1,
+ 0xaedf, 0xaeeb, 0xd1da, 0xd1e3, 0xd1eb, 0xd1d9, 0xd1f4, 0xaed5,
+ 0xd1f3, 0xd1ee, 0xd1ef, 0xaedd, 0xaee8, 0xd1e5, 0xd1e6, 0xd1f0,
+ 0xd1e7, 0xd1e2, 0xd1dc, 0xd1dd, 0xd1ea, 0xd1e4, 0xaed6, 0xaeda,
+ 0xd1f2, 0xd1de, 0xaee6, 0xaee2, 0xaee5, 0xaeec, 0xaedb, 0xaee7,
+ 0xd1e9, 0xaee9, 0xaed8, 0xaed7, 0xd1db, 0xd1df, 0xaee0, 0xd1f1,
+ 0xd1e8, 0xd1e0, 0xaee4, 0xaee1, 0xaed9, 0xaedc, 0xd5c4, 0xd5b4,
+ 0xd5b5, 0xd5b9, 0xd5c8, 0xd5c5, 0xd5be, 0xd5bd, 0xb1ed, 0xd5c1,
+ 0xd5d0, 0xd5b0, 0xd5d1, 0xd5c3, 0xd5d5, 0xd5c9, 0xb1ec, 0xd5c7,
+ 0xb1e7, 0xb1fc, 0xb1f2, 0xb1f6, 0xb1f5, 0xd5b1, 0xd5ce, 0xd5d4,
+ 0xd5cc, 0xd5d3, 0xd5c0, 0xd5b2, 0xd5d2, 0xd5c2, 0xb1ea, 0xb1f7,
+ 0xd5cb, 0xb1f0, 0xd5ca, 0xd5b3, 0xb1f8, 0xb1fa, 0xd5cd, 0xb1fb,
+ 0xb1e9, 0xd5ba, 0xd5cf, 0xb1ef, 0xb1f9, 0xd5bc, 0xd5c6, 0xd5b7,
+ 0xd5bb, 0xb1f4, 0xd5b6, 0xb1e8, 0xb1f1, 0xb1ee, 0xd5bf, 0xaede,
+ 0xd9c0, 0xb1eb, 0xb1f3, 0xd9c3, 0xd9d9, 0xd9ce, 0xb4d6, 0xb4d1,
+ 0xd9bd, 0xb4d2, 0xd9cd, 0xd9c6, 0xd9d3, 0xb4ce, 0xd9ab, 0xd9d5,
+ 0xb4c4, 0xd9b3, 0xb4c7, 0xb4c6, 0xb4d7, 0xd9ad, 0xd9cf, 0xd9d0,
+ 0xb4c9, 0xb4c5, 0xd9bb, 0xb4d0, 0xd9b6, 0xd9d1, 0xb4cc, 0xd9c9,
+ 0xd9d6, 0xd9b0, 0xd9b5, 0xd9af, 0xb4cb, 0xd9c2, 0xddde, 0xd9b1,
+ 0xb4cf, 0xd9ba, 0xd9d2, 0xb4ca, 0xd9b7, 0xd9b4, 0xd9c5, 0xb4cd,
+ 0xb4c3, 0xb4d9, 0xd9c8, 0xd9c7, 0xd9ac, 0xb4c8, 0xd9d4, 0xd9bc,
+ 0xd9be, 0xd9cb, 0xd9ca, 0xd9aa, 0xb4d3, 0xb4d5, 0xd9b2, 0xd9b9,
+ 0xd9c1, 0xb4d4, 0xd9b8, 0xd9c4, 0xd9d7, 0xd9cc, 0xd9d8, 0xd9ae,
+ 0xddf2, 0xb7a6, 0xddf0, 0xdddb, 0xdde0, 0xddd9, 0xddec, 0xddcb,
+ 0xddd2, 0xddea, 0xddf4, 0xdddc, 0xddcf, 0xdde2, 0xdde7, 0xddd3,
+ 0xdde4, 0xddd0, 0xddd7, 0xddd8, 0xb7a8, 0xddeb, 0xdde9, 0xddcc,
+ 0xddee, 0xddef, 0xddf1, 0xb7ac, 0xb7a4, 0xd5b8, 0xddd4, 0xdde6,
+ 0xddd5, 0xb7a1, 0xb7b1, 0xdded, 0xb7af, 0xb7ab, 0xddca, 0xb7a3,
+ 0xddcd, 0xb7b0, 0xdddd, 0xddc9, 0xb7a9, 0xdde1, 0xddd1, 0xb7aa,
+ 0xddda, 0xb77e, 0xb4d8, 0xdde3, 0xd9bf, 0xddce, 0xdde8, 0xb7a5,
+ 0xdde5, 0xb7a2, 0xdddf, 0xb7ad, 0xddd6, 0xddf3, 0xb7a7, 0xdec6,
+ 0xb7ae, 0xe24a, 0xe248, 0xe25e, 0xe246, 0xe258, 0xb77d, 0xba5f,
+ 0xe242, 0xe25d, 0xe247, 0xe255, 0xba64, 0xba5d, 0xe25b, 0xe240,
+ 0xe25a, 0xba6f, 0xe251, 0xe261, 0xba6d, 0xe249, 0xba5e, 0xe24b,
+ 0xe259, 0xba67, 0xe244, 0xba6b, 0xba61, 0xe24d, 0xe243, 0xe1fc,
+ 0xe257, 0xba68, 0xe260, 0xe1fd, 0xba65, 0xe253, 0xba66, 0xe245,
+ 0xe250, 0xe24c, 0xe24e, 0xba60, 0xe25f, 0xba6e, 0xe24f, 0xe262,
+ 0xe1fe, 0xe254, 0xba63, 0xba6c, 0xba6a, 0xe241, 0xe256, 0xba69,
+ 0xba62, 0xe252, 0xe25c, 0xe5d5, 0xe5d1, 0xe5cd, 0xe5e1, 0xe5de,
+ 0xbccd, 0xe5e5, 0xe5d4, 0xbcd8, 0xe5db, 0xe5d0, 0xe5da, 0xbcd5,
+ 0xe5ee, 0xe5eb, 0xe5dd, 0xe5ce, 0xe5e2, 0xe5e4, 0xbcd1, 0xe5d8,
+ 0xe5d3, 0xe5ca, 0xbcce, 0xbcd6, 0xe5e7, 0xbcd7, 0xe5cb, 0xe5ed,
+ 0xe5e0, 0xe5e6, 0xbcd4, 0xe5e3, 0xe5ea, 0xbcd9, 0xbcd3, 0xe5dc,
+ 0xe5cf, 0xe5ef, 0xe5cc, 0xe5e8, 0xbcd0, 0xe5d6, 0xe5d7, 0xbccf,
+ 0xbccc, 0xe5d2, 0xbcd2, 0xbccb, 0xe5e9, 0xe5ec, 0xe5d9, 0xe9ca,
+ 0xe9c2, 0xe9be, 0xbef6, 0xbeeb, 0xbef0, 0xbeec, 0xe9cc, 0xe9d7,
+ 0xbeea, 0xe9c4, 0xe9cd, 0xe5df, 0xe9ce, 0xbef1, 0xe9dd, 0xbef5,
+ 0xbef8, 0xe9c0, 0xbef4, 0xe9db, 0xe9dc, 0xe9d2, 0xe9d1, 0xe9c9,
+ 0xe9d3, 0xe9da, 0xe9d9, 0xbeef, 0xbeed, 0xe9cb, 0xe9c8, 0xe9c5,
+ 0xe9d8, 0xbef7, 0xe9d6, 0xbef3, 0xbef2, 0xe9d0, 0xe9bf, 0xe9c1,
+ 0xe9c3, 0xe9d5, 0xe9cf, 0xbeee, 0xe9c6, 0xe9d4, 0xe9c7, 0xc0cf,
+ 0xed45, 0xc0c8, 0xecf5, 0xed41, 0xc0ca, 0xed48, 0xecfc, 0xecf7,
+ 0xed49, 0xecf3, 0xecfe, 0xc0d1, 0xed44, 0xed4a, 0xecfd, 0xc0c9,
+ 0xed40, 0xecf4, 0xc0d0, 0xed47, 0xecf9, 0xc0cc, 0xecfb, 0xecf8,
+ 0xc0d2, 0xecfa, 0xc0cb, 0xc0ce, 0xed43, 0xecf6, 0xed46, 0xed42,
+ 0xc263, 0xefe7, 0xc268, 0xc269, 0xc262, 0xefe6, 0xefe3, 0xefe4,
+ 0xc266, 0xefde, 0xefe2, 0xc265, 0xefdf, 0xc267, 0xc264, 0xefdd,
+ 0xefe1, 0xefe5, 0xf251, 0xf24e, 0xf257, 0xf256, 0xf254, 0xf24f,
+ 0xc372, 0xf250, 0xc371, 0xc0cd, 0xf253, 0xc370, 0xf258, 0xf252,
+ 0xf24d, 0xefe0, 0xc36f, 0xf24c, 0xf456, 0xf455, 0xf255, 0xc468,
+ 0xf459, 0xf45a, 0xf454, 0xf458, 0xf453, 0xf5d1, 0xf457, 0xc4e7,
+ 0xc4e5, 0xf5cf, 0xf5d2, 0xf5ce, 0xf5d0, 0xc4e6, 0xf6e5, 0xf6e6,
+ 0xc576, 0xf6e4, 0xf7e2, 0xc5cf, 0xf7e0, 0xf7e1, 0xf8ac, 0xc656,
+ 0xf8f3, 0xf8f1, 0xf8f2, 0xf8f4, 0xf9bb, 0xa4ed, 0xa6b8, 0xaa59,
+ 0xcce9, 0xcf64, 0xd1f5, 0xd1f7, 0xd1f6, 0xd1f8, 0xb1fd, 0xd5d7,
+ 0xd1f9, 0xd5d6, 0xd5d8, 0xd5d9, 0xd9da, 0xb4db, 0xd9db, 0xd9dd,
+ 0xb4dc, 0xb4da, 0xd9dc, 0xddfa, 0xddf8, 0xddf7, 0xddf6, 0xddf5,
+ 0xb7b2, 0xddf9, 0xba70, 0xe263, 0xe265, 0xba71, 0xe264, 0xbcdb,
+ 0xbcda, 0xe5f0, 0xe9df, 0xe9de, 0xe9e0, 0xbef9, 0xed4b, 0xc0d3,
+ 0xefe8, 0xc26a, 0xf259, 0xc577, 0xa4ee, 0xa5bf, 0xa6b9, 0xa842,
+ 0xaa5a, 0xaa5b, 0xac6e, 0xd1fa, 0xb7b3, 0xe6d1, 0xbefa, 0xc26b,
+ 0xa4ef, 0xa6ba, 0xcceb, 0xaa5c, 0xccea, 0xcf65, 0xac6f, 0xcf66,
+ 0xac70, 0xd1fc, 0xaeee, 0xaeed, 0xd5de, 0xd5dc, 0xd5dd, 0xd5db,
+ 0xd5da, 0xd9de, 0xd9e1, 0xb4de, 0xd9df, 0xb4dd, 0xd9e0, 0xddfb,
+ 0xe266, 0xe267, 0xe268, 0xe5f3, 0xe5f2, 0xbcdc, 0xe5f1, 0xe5f4,
+ 0xe9e1, 0xe9e2, 0xe9e3, 0xed4c, 0xc0d4, 0xc26c, 0xf25a, 0xc4e8,
+ 0xc95f, 0xac71, 0xcf67, 0xaeef, 0xb1fe, 0xb4df, 0xd9e2, 0xb7b5,
+ 0xb7b4, 0xe269, 0xe26a, 0xbcdd, 0xbcde, 0xe9e5, 0xe9e4, 0xefe9,
+ 0xf7e3, 0xa4f0, 0xc960, 0xa5c0, 0xa843, 0xcb48, 0xac72, 0xb7b6,
+ 0xa4f1, 0xcf68, 0xac73, 0xcf69, 0xc0d5, 0xa4f2, 0xccec, 0xcf6a,
+ 0xd242, 0xd241, 0xd1fe, 0xd1fd, 0xd243, 0xd240, 0xb240, 0xb241,
+ 0xb4e0, 0xd9e3, 0xd9e4, 0xd9e5, 0xde41, 0xde42, 0xde40, 0xddfd,
+ 0xddfe, 0xb7b7, 0xe26b, 0xe5f7, 0xe5f6, 0xe5f5, 0xe5f8, 0xe9e7,
+ 0xe9e6, 0xbefb, 0xe9e8, 0xc0d6, 0xed4d, 0xefea, 0xf25b, 0xf6e7,
+ 0xa4f3, 0xa5c2, 0xa5c1, 0xaa5d, 0xc961, 0xc97e, 0xa6bb, 0xc9f7,
+ 0xcb49, 0xcb4a, 0xaa5e, 0xcced, 0xac74, 0xcf6b, 0xcf6c, 0xaef0,
+ 0xaef4, 0xd244, 0xaef3, 0xaef1, 0xaef2, 0xd5df, 0xb242, 0xb4e3,
+ 0xb4e1, 0xb4e2, 0xd9e6, 0xba72, 0xa4f4, 0xc9a1, 0xa5c3, 0xc9a4,
+ 0xa5c6, 0xc9a3, 0xa5c5, 0xa5c4, 0xa844, 0xc9a2, 0xc9f8, 0xc9fc,
+ 0xc9fe, 0xca40, 0xa6c5, 0xa6c6, 0xc9fb, 0xa6c1, 0xc9f9, 0xc9fd,
+ 0xa6c2, 0xa6bd, 0xa6be, 0xa6c4, 0xc9fa, 0xa6bc, 0xa845, 0xa6bf,
+ 0xa6c0, 0xa6c3, 0xcb5b, 0xcb59, 0xcb4c, 0xa851, 0xcb53, 0xa84c,
+ 0xcb4d, 0xcb55, 0xcb52, 0xa84f, 0xcb51, 0xa856, 0xcb5a, 0xa858,
+ 0xa85a, 0xcb4b, 0xa84d, 0xcb5c, 0xa854, 0xa857, 0xcd45, 0xa847,
+ 0xa85e, 0xa855, 0xcb4e, 0xa84a, 0xa859, 0xcb56, 0xa848, 0xa849,
+ 0xcd43, 0xcb4f, 0xa850, 0xa85b, 0xcb5d, 0xcb50, 0xa84e, 0xa853,
+ 0xccee, 0xa85c, 0xcb57, 0xa852, 0xa85d, 0xa846, 0xcb54, 0xa84b,
+ 0xcb58, 0xcd44, 0xaa6a, 0xaa7a, 0xccf5, 0xaa71, 0xcd4b, 0xaa62,
+ 0xaa65, 0xcd42, 0xccf3, 0xccf7, 0xaa6d, 0xaa6f, 0xccfa, 0xaa76,
+ 0xaa68, 0xaa66, 0xaa67, 0xaa75, 0xcd47, 0xaa70, 0xccf9, 0xccfb,
+ 0xaa6e, 0xaa73, 0xccfc, 0xcd4a, 0xac75, 0xaa79, 0xaa63, 0xcd49,
+ 0xcd4d, 0xccf8, 0xcd4f, 0xcd40, 0xaa6c, 0xccf4, 0xaa6b, 0xaa7d,
+ 0xaa72, 0xccf2, 0xcf75, 0xaa78, 0xaa7c, 0xcd41, 0xcd46, 0xaa7e,
+ 0xaa77, 0xaa69, 0xaa5f, 0xaa64, 0xccf6, 0xaa60, 0xcd4e, 0xccf0,
+ 0xccef, 0xccfd, 0xccf1, 0xaa7b, 0xaef5, 0xaa74, 0xccfe, 0xaa61,
+ 0xaca6, 0xcd4c, 0xcf7c, 0xcfa1, 0xcfa4, 0xcf77, 0xcfa7, 0xcfaa,
+ 0xcfac, 0xcf74, 0xac76, 0xac7b, 0xd249, 0xacad, 0xcfa5, 0xcfad,
+ 0xcf7b, 0xcf73, 0xd264, 0xac7e, 0xcfa2, 0xcf78, 0xcf7a, 0xaca5,
+ 0xcf7d, 0xac7d, 0xcf70, 0xcfa8, 0xcfab, 0xac7a, 0xaca8, 0xcf6d,
+ 0xacaa, 0xac78, 0xacae, 0xcfa9, 0xcf6f, 0xacab, 0xd25e, 0xcd48,
+ 0xac7c, 0xac77, 0xcf76, 0xcf6e, 0xacac, 0xaca4, 0xcfa3, 0xaca9,
+ 0xaca7, 0xcf79, 0xaca1, 0xcf71, 0xaca2, 0xaca3, 0xcf72, 0xcfa6,
+ 0xac79, 0xcf7e, 0xd24c, 0xaefd, 0xaf43, 0xd255, 0xd25b, 0xd257,
+ 0xd24a, 0xd24d, 0xd246, 0xd247, 0xaf4a, 0xaefa, 0xd256, 0xd25f,
+ 0xaf45, 0xaef6, 0xaf40, 0xd24e, 0xaf42, 0xd24f, 0xd259, 0xaf44,
+ 0xd268, 0xd248, 0xaefc, 0xaefb, 0xaf48, 0xd245, 0xd266, 0xd25a,
+ 0xd267, 0xd261, 0xd253, 0xd262, 0xd25c, 0xd265, 0xd263, 0xaf49,
+ 0xd254, 0xaef9, 0xaef8, 0xaf41, 0xaf47, 0xd260, 0xaf46, 0xd251,
+ 0xb243, 0xd269, 0xd250, 0xd24b, 0xaefe, 0xaf4b, 0xaef7, 0xd258,
+ 0xd25d, 0xb265, 0xd5e1, 0xd5e5, 0xb252, 0xb250, 0xb247, 0xd5e3,
+ 0xd5e2, 0xb25b, 0xd5e8, 0xb255, 0xd5fa, 0xd647, 0xb244, 0xd5f7,
+ 0xd5f0, 0xb267, 0xd5e0, 0xd5fc, 0xb264, 0xb258, 0xb263, 0xb24e,
+ 0xd5ec, 0xd5fe, 0xd5f6, 0xb24f, 0xb249, 0xd645, 0xd5fd, 0xd640,
+ 0xb251, 0xb259, 0xd642, 0xd5ea, 0xd5fb, 0xd5ef, 0xd644, 0xb25e,
+ 0xb246, 0xb25c, 0xd5f4, 0xd5f2, 0xd5f3, 0xb253, 0xd5ee, 0xd5ed,
+ 0xb248, 0xd5e7, 0xd646, 0xb24a, 0xd5f1, 0xb268, 0xb262, 0xd5e6,
+ 0xb25f, 0xb25d, 0xb266, 0xd5f8, 0xb261, 0xd252, 0xd5f9, 0xb260,
+ 0xd641, 0xb245, 0xd5f5, 0xb257, 0xd5e9, 0xb256, 0xb254, 0xb24c,
+ 0xb24b, 0xd9e7, 0xd643, 0xd5eb, 0xd9fc, 0xb24d, 0xb541, 0xb25a,
+ 0xb4ee, 0xd9f6, 0xb4fc, 0xd9ea, 0xb4eb, 0xb4e7, 0xda49, 0xb4ed,
+ 0xb4f1, 0xb4ec, 0xb4f5, 0xda4d, 0xda44, 0xd9f1, 0xb4fa, 0xb4f4,
+ 0xd9fd, 0xb4e4, 0xda4a, 0xda43, 0xb4e8, 0xd9f7, 0xb4f7, 0xda55,
+ 0xda56, 0xb4e5, 0xda48, 0xb4f9, 0xd9fb, 0xd9ed, 0xd9ee, 0xb4fd,
+ 0xd9f2, 0xd9f9, 0xd9f3, 0xb4fb, 0xb544, 0xd9ef, 0xd9e8, 0xd9e9,
+ 0xd9eb, 0xb4ea, 0xd9f8, 0xb4f8, 0xb542, 0xd9fa, 0xda53, 0xda4b,
+ 0xb4e6, 0xda51, 0xb4f2, 0xb4f0, 0xda57, 0xb4ef, 0xda41, 0xd9f4,
+ 0xd9fe, 0xb547, 0xda45, 0xda42, 0xd9f0, 0xb543, 0xda4f, 0xda4c,
+ 0xda54, 0xb4e9, 0xda40, 0xb546, 0xda47, 0xb4f3, 0xb4f6, 0xda46,
+ 0xb545, 0xd9f5, 0xd5e4, 0xda50, 0xda4e, 0xda52, 0xd9ec, 0xb540,
+ 0xde61, 0xde60, 0xde46, 0xb7bd, 0xde5f, 0xde49, 0xde4a, 0xb7c7,
+ 0xde68, 0xb7c2, 0xde5e, 0xde43, 0xb7c8, 0xb7be, 0xde52, 0xde48,
+ 0xde4b, 0xde63, 0xb7b8, 0xde6a, 0xde62, 0xb7c1, 0xde57, 0xb7cc,
+ 0xb7cb, 0xb7c5, 0xde69, 0xb7b9, 0xde55, 0xde4c, 0xde59, 0xde65,
+ 0xb7cd, 0xb7bb, 0xde54, 0xde4d, 0xb7c4, 0xb7c3, 0xde50, 0xde5a,
+ 0xde64, 0xde47, 0xde51, 0xb7bc, 0xde5b, 0xb7c9, 0xb7c0, 0xde4e,
+ 0xb7bf, 0xde45, 0xde53, 0xde67, 0xb4fe, 0xbab0, 0xde56, 0xe26c,
+ 0xde58, 0xde66, 0xb7c6, 0xde4f, 0xb7ba, 0xb7ca, 0xbcf0, 0xde44,
+ 0xde5d, 0xde5c, 0xe2aa, 0xbaad, 0xe27d, 0xe2a4, 0xbaa2, 0xe26e,
+ 0xbaaf, 0xba77, 0xe26d, 0xe2b0, 0xbab1, 0xe271, 0xe2a3, 0xe273,
+ 0xe2b3, 0xe2af, 0xba75, 0xbaa1, 0xe653, 0xbaae, 0xba7d, 0xe26f,
+ 0xe2ae, 0xbaa3, 0xe2ab, 0xe2b8, 0xe275, 0xe27e, 0xe2b6, 0xe2ac,
+ 0xba7c, 0xe27c, 0xba76, 0xba74, 0xbaa8, 0xe27a, 0xe277, 0xe278,
+ 0xe2b2, 0xe2b7, 0xe2b5, 0xba7a, 0xe2b9, 0xba7e, 0xbaa7, 0xe270,
+ 0xe5fa, 0xe279, 0xba78, 0xbaac, 0xbaa9, 0xba7b, 0xe2a5, 0xe274,
+ 0xbaaa, 0xe2a7, 0xbaa4, 0xbaa6, 0xba73, 0xe2a9, 0xe2a1, 0xe272,
+ 0xbaa5, 0xe2b1, 0xe2b4, 0xe27b, 0xe2a8, 0xba79, 0xbcdf, 0xe2a6,
+ 0xe5f9, 0xe2ad, 0xe276, 0xe644, 0xe64e, 0xbce2, 0xe64d, 0xe659,
+ 0xbce4, 0xe64b, 0xe64f, 0xbcef, 0xe646, 0xbce7, 0xe652, 0xe9f0,
+ 0xbcf3, 0xbcf2, 0xe654, 0xe643, 0xe65e, 0xbced, 0xbce3, 0xe657,
+ 0xe65b, 0xe660, 0xe655, 0xe649, 0xbce6, 0xbce9, 0xbcf1, 0xbcec,
+ 0xe64c, 0xe2a2, 0xe648, 0xe65f, 0xbce8, 0xbceb, 0xe661, 0xbce0,
+ 0xe656, 0xe5fb, 0xe65c, 0xc0df, 0xe64a, 0xbce1, 0xe645, 0xbce5,
+ 0xe5fc, 0xbaab, 0xe641, 0xe65a, 0xe642, 0xe640, 0xbcea, 0xe658,
+ 0xe5fe, 0xe651, 0xe650, 0xe65d, 0xe647, 0xbcee, 0xe9f3, 0xbf49,
+ 0xbefe, 0xea40, 0xe9eb, 0xbf41, 0xe9f7, 0xbf48, 0xbf43, 0xe9f5,
+ 0xed4f, 0xe9fb, 0xea42, 0xe9fa, 0xe9e9, 0xe9f8, 0xea44, 0xea46,
+ 0xbefd, 0xea45, 0xbf44, 0xbf4a, 0xbf47, 0xe9fe, 0xbf46, 0xe9f9,
+ 0xe9ed, 0xe9f2, 0xe9fd, 0xbf45, 0xbf42, 0xbefc, 0xbf40, 0xe9f1,
+ 0xe5fd, 0xe9ec, 0xe9ef, 0xea41, 0xe9f4, 0xe9ea, 0xed4e, 0xea43,
+ 0xe9ee, 0xe9fc, 0xed51, 0xc0e3, 0xc0d7, 0xc0db, 0xed53, 0xed59,
+ 0xed57, 0xc0d9, 0xc0da, 0xc0e1, 0xed5a, 0xed52, 0xc0dc, 0xed56,
+ 0xed55, 0xed5b, 0xc0e2, 0xc0dd, 0xc0e0, 0xed54, 0xc0e4, 0xc0de,
+ 0xc0e5, 0xc0d8, 0xed58, 0xed50, 0xeff7, 0xc271, 0xeff4, 0xeff6,
+ 0xc26f, 0xeff2, 0xeff3, 0xefee, 0xe9f6, 0xefef, 0xc270, 0xefeb,
+ 0xc26d, 0xeff8, 0xc26e, 0xefec, 0xefed, 0xeff1, 0xc273, 0xc272,
+ 0xeff0, 0xc378, 0xf25f, 0xf265, 0xc379, 0xf25c, 0xc376, 0xc373,
+ 0xf267, 0xc377, 0xc374, 0xf25e, 0xf261, 0xf262, 0xf263, 0xf266,
+ 0xeff5, 0xf25d, 0xc375, 0xf264, 0xf268, 0xf260, 0xf45d, 0xc46a,
+ 0xf460, 0xc46b, 0xf468, 0xf45f, 0xf45c, 0xf45e, 0xf462, 0xf465,
+ 0xf464, 0xf467, 0xf45b, 0xc469, 0xf463, 0xf466, 0xf469, 0xf461,
+ 0xf5d3, 0xf5d4, 0xf5d8, 0xf5d9, 0xf5d6, 0xf5d7, 0xf5d5, 0xc4e9,
+ 0xc578, 0xf6eb, 0xf6e8, 0xf6e9, 0xf6ea, 0xc579, 0xf7e5, 0xf7e4,
+ 0xf8af, 0xc5f4, 0xf8ad, 0xf8b0, 0xf8ae, 0xf8f5, 0xc657, 0xc665,
+ 0xf9a3, 0xf96c, 0xf9a2, 0xf9d0, 0xf9d1, 0xa4f5, 0xa6c7, 0xca41,
+ 0xcb5e, 0xa85f, 0xa862, 0xcb5f, 0xa860, 0xa861, 0xcd58, 0xcd5a,
+ 0xcd55, 0xcd52, 0xcd54, 0xaaa4, 0xaaa2, 0xcd56, 0xaaa3, 0xcd53,
+ 0xcd50, 0xaaa1, 0xcd57, 0xcd51, 0xaaa5, 0xcd59, 0xcfaf, 0xcfb3,
+ 0xacb7, 0xcfb6, 0xacaf, 0xacb2, 0xacb4, 0xacb6, 0xacb3, 0xcfb2,
+ 0xcfb1, 0xacb1, 0xcfb4, 0xcfb5, 0xcfae, 0xacb5, 0xacb0, 0xcfb0,
+ 0xd277, 0xd278, 0xd279, 0xaf50, 0xaf4c, 0xd26e, 0xd276, 0xd27b,
+ 0xaf51, 0xd26c, 0xd272, 0xd26b, 0xd275, 0xd271, 0xaf4d, 0xaf4f,
+ 0xd27a, 0xd26a, 0xd26d, 0xd273, 0xd274, 0xd27c, 0xd270, 0xaf4e,
+ 0xb26d, 0xd64e, 0xd650, 0xd64c, 0xd658, 0xd64a, 0xd657, 0xb269,
+ 0xd648, 0xda5b, 0xd652, 0xb26c, 0xd653, 0xd656, 0xd65a, 0xd64f,
+ 0xd654, 0xb26a, 0xb26b, 0xd659, 0xd64d, 0xd649, 0xd65b, 0xd651,
+ 0xd655, 0xd64b, 0xb548, 0xb549, 0xda65, 0xb54f, 0xda59, 0xda62,
+ 0xda58, 0xb54c, 0xda60, 0xda5e, 0xda5f, 0xb54a, 0xda63, 0xda5c,
+ 0xda5a, 0xb54b, 0xda5d, 0xda61, 0xb54d, 0xda64, 0xde70, 0xde77,
+ 0xde79, 0xdea1, 0xb7da, 0xde6b, 0xb7d2, 0xde7a, 0xb7d7, 0xdea2,
+ 0xb7ce, 0xde7d, 0xde6d, 0xde7e, 0xde6c, 0xb7dc, 0xde78, 0xb7cf,
+ 0xdea3, 0xb7d4, 0xde71, 0xb7d9, 0xde7c, 0xde6f, 0xde76, 0xde72,
+ 0xde6e, 0xb7d1, 0xb7d8, 0xb7d6, 0xb7d3, 0xb7db, 0xb7d0, 0xde75,
+ 0xb7d5, 0xb54e, 0xde7b, 0xde73, 0xde74, 0xe2c1, 0xbab4, 0xe2bd,
+ 0xe2c3, 0xe2bf, 0xbab6, 0xe2be, 0xe2c2, 0xe2ba, 0xe2bc, 0xbab5,
+ 0xe2c0, 0xe2bb, 0xbab7, 0xbab2, 0xe2c4, 0xbab3, 0xe667, 0xe664,
+ 0xe670, 0xe66a, 0xe66c, 0xbcf4, 0xe666, 0xe66e, 0xe66d, 0xe66b,
+ 0xe671, 0xbcf7, 0xe668, 0xe66f, 0xbcf5, 0xe663, 0xe665, 0xbcf6,
+ 0xe662, 0xe672, 0xe669, 0xea4a, 0xbf51, 0xea55, 0xea53, 0xbf4b,
+ 0xea49, 0xea4c, 0xea4d, 0xea48, 0xbf55, 0xbf56, 0xea47, 0xea56,
+ 0xea51, 0xbf4f, 0xbf4c, 0xea50, 0xea4e, 0xbf52, 0xea52, 0xbf4d,
+ 0xbf4e, 0xea4f, 0xbf50, 0xea4b, 0xea54, 0xbf53, 0xea57, 0xea58,
+ 0xbf54, 0xc0e7, 0xc0ee, 0xed5c, 0xed62, 0xed60, 0xc0ea, 0xc0e9,
+ 0xc0e6, 0xed5e, 0xc0ec, 0xc0eb, 0xc0e8, 0xed61, 0xed5d, 0xed5f,
+ 0xc0ed, 0xc277, 0xeffb, 0xc274, 0xc275, 0xeffd, 0xc276, 0xeffa,
+ 0xeff9, 0xf26c, 0xeffc, 0xf26d, 0xc37a, 0xf26b, 0xf26a, 0xf269,
+ 0xc37b, 0xc46c, 0xf46a, 0xf46b, 0xf5dc, 0xf5db, 0xc4ea, 0xf5da,
+ 0xf6ec, 0xf6ed, 0xf7e6, 0xf8b1, 0xf8f6, 0xf9bc, 0xc679, 0xf9c6,
+ 0xa4f6, 0xaaa6, 0xaaa7, 0xacb8, 0xc0ef, 0xa4f7, 0xaaa8, 0xaf52,
+ 0xb7dd, 0xa4f8, 0xb26e, 0xbab8, 0xc962, 0xcfb7, 0xd27d, 0xe2c5,
+ 0xc0f0, 0xa4f9, 0xaaa9, 0xcfb8, 0xcfb9, 0xda66, 0xb550, 0xdea4,
+ 0xb7de, 0xe2c6, 0xbcf8, 0xc37c, 0xa4fa, 0xda67, 0xa4fb, 0xa6c9,
+ 0xca42, 0xa6c8, 0xa865, 0xa864, 0xa863, 0xcb60, 0xaaaa, 0xaaab,
+ 0xcd5b, 0xcfba, 0xcfbd, 0xacba, 0xcfbb, 0xacb9, 0xcfbc, 0xacbb,
+ 0xd2a2, 0xd2a1, 0xd27e, 0xaf53, 0xd65d, 0xd65e, 0xb26f, 0xd65c,
+ 0xd65f, 0xb552, 0xb270, 0xb551, 0xda6b, 0xda6a, 0xda68, 0xda69,
+ 0xda6c, 0xdea6, 0xdea5, 0xdea9, 0xdea8, 0xdea7, 0xbab9, 0xe2c9,
+ 0xe2c8, 0xbaba, 0xe2c7, 0xe673, 0xe674, 0xbcf9, 0xea59, 0xea5a,
+ 0xf272, 0xc37d, 0xf271, 0xf270, 0xf26e, 0xf26f, 0xc4eb, 0xf46c,
+ 0xf6ee, 0xf8f7, 0xa4fc, 0xc9a5, 0xa5c7, 0xc9a6, 0xca43, 0xca44,
+ 0xcb66, 0xcb62, 0xcb61, 0xaaac, 0xcb65, 0xa867, 0xcb63, 0xa866,
+ 0xcb67, 0xcb64, 0xcd5f, 0xcfbe, 0xcd5d, 0xcd64, 0xaaad, 0xaab0,
+ 0xcd65, 0xcd61, 0xcd62, 0xcd5c, 0xaaaf, 0xcd5e, 0xaaae, 0xcd63,
+ 0xcd60, 0xcfc2, 0xacbd, 0xacbe, 0xcfc5, 0xcfbf, 0xcfc4, 0xcfc0,
+ 0xacbc, 0xcfc3, 0xcfc1, 0xd2a8, 0xd2a5, 0xd2a7, 0xaf58, 0xaf57,
+ 0xaf55, 0xd2a4, 0xd2a9, 0xaf54, 0xaf56, 0xd2a6, 0xd667, 0xd2a3,
+ 0xd2aa, 0xd662, 0xd666, 0xd665, 0xda6e, 0xda79, 0xd668, 0xd663,
+ 0xda6d, 0xb274, 0xb273, 0xd661, 0xd664, 0xb275, 0xb272, 0xb271,
+ 0xd660, 0xd669, 0xda70, 0xda77, 0xb554, 0xda76, 0xda73, 0xb556,
+ 0xda75, 0xda6f, 0xda71, 0xda74, 0xda72, 0xb555, 0xda78, 0xb553,
+ 0xb7df, 0xdead, 0xdeac, 0xdeaa, 0xb7e2, 0xb7e1, 0xdeae, 0xdeab,
+ 0xe2ca, 0xbabb, 0xb7e0, 0xdeb0, 0xdeaf, 0xe2cd, 0xe2cb, 0xbcfa,
+ 0xbabc, 0xe2cc, 0xe676, 0xbcfb, 0xe675, 0xe67e, 0xe67d, 0xe67b,
+ 0xe67a, 0xe677, 0xe678, 0xe679, 0xe67c, 0xe6a1, 0xea5f, 0xea5c,
+ 0xea5d, 0xbf57, 0xea5b, 0xea61, 0xea60, 0xea5e, 0xed64, 0xed65,
+ 0xc0f1, 0xc0f2, 0xed63, 0xc279, 0xeffe, 0xc278, 0xc37e, 0xc3a1,
+ 0xc46d, 0xf46e, 0xf46d, 0xf5dd, 0xf6ef, 0xc57a, 0xf7e8, 0xf7e7,
+ 0xf7e9, 0xa5c8, 0xcfc6, 0xaf59, 0xb276, 0xd66a, 0xa5c9, 0xc9a7,
+ 0xa4fd, 0xca45, 0xcb6c, 0xcb6a, 0xcb6b, 0xcb68, 0xa868, 0xcb69,
+ 0xcd6d, 0xaab3, 0xcd6b, 0xcd67, 0xcd6a, 0xcd66, 0xaab5, 0xcd69,
+ 0xaab2, 0xaab1, 0xaab4, 0xcd6c, 0xcd68, 0xacc2, 0xacc5, 0xcfce,
+ 0xcfcd, 0xcfcc, 0xacbf, 0xcfd5, 0xcfcb, 0xacc1, 0xd2af, 0xcfd2,
+ 0xcfd0, 0xacc4, 0xcfc8, 0xcfd3, 0xcfca, 0xcfd4, 0xcfd1, 0xcfc9,
+ 0xacc0, 0xcfd6, 0xcfc7, 0xacc3, 0xd2b4, 0xd2ab, 0xd2b6, 0xd2ae,
+ 0xd2b9, 0xd2ba, 0xd2ac, 0xd2b8, 0xd2b5, 0xd2b3, 0xd2b7, 0xaf5f,
+ 0xaf5d, 0xd2b1, 0xd2ad, 0xd2b0, 0xd2bb, 0xd2b2, 0xaf5e, 0xcfcf,
+ 0xaf5a, 0xaf5c, 0xd678, 0xd66d, 0xd66b, 0xd66c, 0xd673, 0xd674,
+ 0xd670, 0xb27b, 0xd675, 0xd672, 0xd66f, 0xb279, 0xd66e, 0xb277,
+ 0xb27a, 0xd671, 0xd679, 0xaf5b, 0xb278, 0xd677, 0xd676, 0xb27c,
+ 0xda7e, 0xdaa1, 0xb560, 0xdaa7, 0xdaa9, 0xdaa2, 0xb55a, 0xdaa6,
+ 0xdaa5, 0xb55b, 0xb561, 0xb562, 0xdaa8, 0xb558, 0xda7d, 0xda7b,
+ 0xdaa3, 0xda7a, 0xb55f, 0xda7c, 0xdaa4, 0xdaaa, 0xb559, 0xb55e,
+ 0xb55c, 0xb55d, 0xb557, 0xb7e9, 0xdeb7, 0xb7e8, 0xdebb, 0xdeb1,
+ 0xdebc, 0xdeb2, 0xdeb3, 0xdebd, 0xdeba, 0xdeb8, 0xdeb9, 0xdeb5,
+ 0xdeb4, 0xdebe, 0xb7e5, 0xdeb6, 0xb7ea, 0xb7e4, 0xb7eb, 0xb7ec,
+ 0xb7e7, 0xb7e6, 0xe2ce, 0xbabe, 0xbabd, 0xe2d3, 0xbcfc, 0xbabf,
+ 0xbac1, 0xe2d4, 0xb7e3, 0xbac0, 0xe2d0, 0xe2d2, 0xe2cf, 0xe2d1,
+ 0xe6ab, 0xe6aa, 0xe6a7, 0xbd40, 0xea62, 0xbd41, 0xe6a6, 0xbcfe,
+ 0xe6a8, 0xe6a5, 0xe6a2, 0xe6a9, 0xe6a3, 0xe6a4, 0xbcfd, 0xed69,
+ 0xea66, 0xea65, 0xea67, 0xed66, 0xbf5a, 0xea63, 0xbf58, 0xbf5c,
+ 0xbf5b, 0xea64, 0xea68, 0xbf59, 0xed6d, 0xc0f5, 0xc27a, 0xc0f6,
+ 0xc0f3, 0xed6a, 0xed68, 0xed6b, 0xed6e, 0xc0f4, 0xed6c, 0xed67,
+ 0xf042, 0xf045, 0xf275, 0xf040, 0xf46f, 0xf046, 0xc3a2, 0xf044,
+ 0xc27b, 0xf041, 0xf043, 0xf047, 0xf276, 0xf274, 0xc3a3, 0xf273,
+ 0xc46e, 0xc4ed, 0xf6f1, 0xc4ec, 0xf6f3, 0xf6f0, 0xf6f2, 0xc5d0,
+ 0xf8b2, 0xa5ca, 0xcd6e, 0xd2bc, 0xd2bd, 0xb27d, 0xdebf, 0xbf5d,
+ 0xc3a4, 0xc57b, 0xf8b3, 0xa5cb, 0xcd6f, 0xa260, 0xcfd7, 0xcfd8,
+ 0xd2be, 0xd2bf, 0xb27e, 0xb2a1, 0xdaab, 0xdec2, 0xdec1, 0xdec0,
+ 0xe2d5, 0xe2d6, 0xe2d7, 0xbac2, 0xe6ad, 0xe6ac, 0xea69, 0xbf5e,
+ 0xbf5f, 0xed72, 0xed6f, 0xed70, 0xed71, 0xf049, 0xf048, 0xc27c,
+ 0xf277, 0xf5de, 0xa5cc, 0xacc6, 0xb2a2, 0xdec3, 0xa5cd, 0xd2c0,
+ 0xb2a3, 0xb563, 0xb564, 0xa5ce, 0xa5cf, 0xca46, 0xa86a, 0xa869,
+ 0xacc7, 0xcfd9, 0xdaac, 0xa5d0, 0xa5d1, 0xa5d2, 0xa5d3, 0xa86b,
+ 0xa86c, 0xcb6e, 0xcb6d, 0xaab6, 0xcd72, 0xcd70, 0xcd71, 0xcfda,
+ 0xcfdb, 0xaccb, 0xacc9, 0xacca, 0xacc8, 0xaf60, 0xaf64, 0xaf63,
+ 0xd2c1, 0xaf62, 0xaf61, 0xd2c2, 0xb2a6, 0xd67b, 0xd67a, 0xb2a4,
+ 0xb2a5, 0xb566, 0xb565, 0xdaae, 0xdaad, 0xb2a7, 0xb7ed, 0xdec5,
+ 0xb7ee, 0xdec4, 0xe2d8, 0xe6ae, 0xbd42, 0xea6a, 0xed73, 0xc3a6,
+ 0xc3a5, 0xc57c, 0xa5d4, 0xcd73, 0xb2a8, 0xe2d9, 0xbac3, 0xcb6f,
+ 0xcb70, 0xcd74, 0xaab8, 0xaab9, 0xaab7, 0xaccf, 0xacd0, 0xaccd,
+ 0xacce, 0xcfdc, 0xcfdd, 0xaccc, 0xd2c3, 0xaf68, 0xaf69, 0xb2ab,
+ 0xd2c9, 0xaf6e, 0xaf6c, 0xd2ca, 0xd2c5, 0xaf6b, 0xaf6a, 0xaf65,
+ 0xd2c8, 0xd2c7, 0xd2c4, 0xaf6d, 0xd2c6, 0xaf66, 0xaf67, 0xb2ac,
+ 0xd6a1, 0xd6a2, 0xb2ad, 0xd67c, 0xd67e, 0xd6a4, 0xd6a3, 0xd67d,
+ 0xb2a9, 0xb2aa, 0xdab6, 0xb56b, 0xb56a, 0xdab0, 0xb568, 0xdab3,
+ 0xb56c, 0xdab4, 0xb56d, 0xdab1, 0xb567, 0xb569, 0xdab5, 0xdab2,
+ 0xdaaf, 0xded2, 0xdec7, 0xb7f0, 0xb7f3, 0xb7f2, 0xb7f7, 0xb7f6,
+ 0xded3, 0xded1, 0xdeca, 0xdece, 0xdecd, 0xb7f4, 0xded0, 0xdecc,
+ 0xded4, 0xdecb, 0xb7f5, 0xb7ef, 0xb7f1, 0xdec9, 0xe2db, 0xbac7,
+ 0xe2df, 0xbac6, 0xe2dc, 0xbac5, 0xdec8, 0xdecf, 0xe2de, 0xbac8,
+ 0xe2e0, 0xe2dd, 0xe2da, 0xe6b1, 0xe6b5, 0xe6b7, 0xe6b3, 0xe6b2,
+ 0xe6b0, 0xbd45, 0xbd43, 0xbd48, 0xbd49, 0xe6b4, 0xbd46, 0xe6af,
+ 0xbd47, 0xbac4, 0xe6b6, 0xbd44, 0xea6c, 0xea6b, 0xea73, 0xea6d,
+ 0xea72, 0xea6f, 0xbf60, 0xea71, 0xbf61, 0xbf62, 0xea70, 0xea6e,
+ 0xc0f8, 0xed74, 0xc0f7, 0xed77, 0xed75, 0xed76, 0xc0f9, 0xf04d,
+ 0xc2a1, 0xf04e, 0xc27d, 0xf04f, 0xc27e, 0xf04c, 0xf050, 0xf04a,
+ 0xc3a7, 0xf278, 0xc3a8, 0xc46f, 0xf04b, 0xc470, 0xc4ee, 0xf5df,
+ 0xc57e, 0xf6f4, 0xc57d, 0xf7ea, 0xc5f5, 0xc5f6, 0xf9cc, 0xacd1,
+ 0xcfde, 0xb56e, 0xb56f, 0xa5d5, 0xa6ca, 0xca47, 0xcb71, 0xa86d,
+ 0xaaba, 0xacd2, 0xacd3, 0xacd4, 0xd6a6, 0xd2cb, 0xaf6f, 0xb2ae,
+ 0xd6a5, 0xdab8, 0xb571, 0xdab7, 0xb570, 0xded5, 0xbd4a, 0xe6bb,
+ 0xe6b8, 0xe6b9, 0xe6ba, 0xed78, 0xf051, 0xf471, 0xf470, 0xf6f5,
+ 0xa5d6, 0xcd75, 0xaf70, 0xb572, 0xded6, 0xe2e1, 0xbd4b, 0xea74,
+ 0xf052, 0xf472, 0xa5d7, 0xaabb, 0xacd7, 0xcfdf, 0xacd8, 0xacd6,
+ 0xacd5, 0xd2cc, 0xaf71, 0xaf72, 0xaf73, 0xb2b0, 0xd6a7, 0xb2af,
+ 0xdab9, 0xb2b1, 0xb573, 0xded7, 0xb7f8, 0xb7f9, 0xbac9, 0xbaca,
+ 0xbd4c, 0xbf64, 0xea75, 0xbf63, 0xed79, 0xc0fa, 0xf053, 0xf473,
+ 0xa5d8, 0xa86e, 0xcd78, 0xcd77, 0xaabc, 0xcd76, 0xaabd, 0xcd79,
+ 0xcfe5, 0xacdb, 0xacda, 0xcfe7, 0xcfe6, 0xacdf, 0xacde, 0xacd9,
+ 0xcfe1, 0xcfe2, 0xcfe3, 0xace0, 0xcfe0, 0xacdc, 0xcfe4, 0xacdd,
+ 0xd2cf, 0xd2d3, 0xd2d1, 0xd2d0, 0xd2d4, 0xd2d5, 0xd2d6, 0xd2ce,
+ 0xd2cd, 0xaf75, 0xaf76, 0xd2d7, 0xd2d2, 0xd6b0, 0xd2d8, 0xaf77,
+ 0xaf74, 0xd6aa, 0xd6a9, 0xd6ab, 0xd6ac, 0xd6ae, 0xd6ad, 0xd6b2,
+ 0xb2b5, 0xb2b2, 0xb2b6, 0xd6a8, 0xb2b7, 0xd6b1, 0xb2b4, 0xd6af,
+ 0xb2b3, 0xdabc, 0xdabe, 0xdaba, 0xdabb, 0xdabf, 0xdac1, 0xdac2,
+ 0xdabd, 0xdac0, 0xb574, 0xdedb, 0xdee0, 0xded8, 0xdedc, 0xdee1,
+ 0xdedd, 0xb7fa, 0xb843, 0xb7fd, 0xded9, 0xdeda, 0xbace, 0xb846,
+ 0xb7fe, 0xb844, 0xb7fc, 0xdedf, 0xb845, 0xdede, 0xb841, 0xb7fb,
+ 0xb842, 0xdee2, 0xe2e6, 0xe2e8, 0xb840, 0xe2e3, 0xbacc, 0xe2e9,
+ 0xbacd, 0xe2e7, 0xe2e2, 0xe2e5, 0xe2ea, 0xbacb, 0xe2e4, 0xbd4e,
+ 0xe6bf, 0xe6be, 0xbd51, 0xbd4f, 0xe6bc, 0xbd4d, 0xe6bd, 0xbd50,
+ 0xea7d, 0xeaa1, 0xea7e, 0xea76, 0xea7a, 0xea79, 0xea77, 0xbf66,
+ 0xbf67, 0xbf65, 0xea78, 0xea7b, 0xea7c, 0xbf68, 0xc140, 0xeda3,
+ 0xc0fc, 0xed7b, 0xc0fe, 0xc141, 0xc0fd, 0xeda2, 0xed7c, 0xc0fb,
+ 0xeda1, 0xed7a, 0xed7e, 0xed7d, 0xf055, 0xc2a4, 0xc2a5, 0xc2a2,
+ 0xc2a3, 0xf054, 0xf27b, 0xc3a9, 0xf279, 0xf27a, 0xf474, 0xf477,
+ 0xf475, 0xf476, 0xf5e0, 0xc4ef, 0xf7eb, 0xf8b4, 0xc5f7, 0xf8f8,
+ 0xf8f9, 0xc666, 0xa5d9, 0xace1, 0xdac3, 0xdee3, 0xa5da, 0xa86f,
+ 0xaabe, 0xcfe8, 0xcfe9, 0xaf78, 0xdac4, 0xb575, 0xb847, 0xc142,
+ 0xeda4, 0xf27c, 0xf478, 0xa5db, 0xcda1, 0xcd7a, 0xcd7c, 0xcd7e,
+ 0xcd7d, 0xcd7b, 0xaabf, 0xace2, 0xcff2, 0xcfed, 0xcfea, 0xcff1,
+ 0xace4, 0xace5, 0xcff0, 0xcfef, 0xcfee, 0xcfeb, 0xcfec, 0xcff3,
+ 0xace3, 0xaf7c, 0xafa4, 0xafa3, 0xd2e1, 0xd2db, 0xd2d9, 0xafa1,
+ 0xd6b9, 0xaf7a, 0xd2de, 0xd2e2, 0xd2e4, 0xd2e0, 0xd2da, 0xafa2,
+ 0xd2df, 0xd2dd, 0xaf79, 0xd2e5, 0xafa5, 0xd2e3, 0xaf7d, 0xd2dc,
+ 0xaf7e, 0xaf7b, 0xb2b9, 0xd6ba, 0xd6b3, 0xd6b5, 0xd6b7, 0xd6b8,
+ 0xd6b6, 0xb2ba, 0xd6bb, 0xd6b4, 0xdac8, 0xb576, 0xdad0, 0xdac5,
+ 0xdad1, 0xdac6, 0xdac7, 0xdacf, 0xdace, 0xdacb, 0xb2b8, 0xb577,
+ 0xdac9, 0xdacc, 0xb578, 0xdacd, 0xdaca, 0xdeee, 0xdef2, 0xb84e,
+ 0xe2f0, 0xb851, 0xdef0, 0xdeed, 0xdee8, 0xdeea, 0xdeeb, 0xdee4,
+ 0xb84d, 0xb84c, 0xb848, 0xdee7, 0xb84f, 0xb850, 0xdee6, 0xdee9,
+ 0xdef1, 0xb84a, 0xb84b, 0xdeef, 0xdee5, 0xe2f2, 0xbad0, 0xe2f4,
+ 0xdeec, 0xe2f6, 0xbad4, 0xe2f7, 0xe2f3, 0xbad1, 0xe2ef, 0xbad3,
+ 0xe2ec, 0xe2f1, 0xe2f5, 0xe2ee, 0xb849, 0xe2eb, 0xbad2, 0xe2ed,
+ 0xbd54, 0xe6c1, 0xbd58, 0xbd56, 0xbacf, 0xe6c8, 0xe6c9, 0xbd53,
+ 0xe6c7, 0xe6ca, 0xbd55, 0xbd52, 0xe6c3, 0xe6c0, 0xe6c5, 0xe6c2,
+ 0xbd59, 0xe6c4, 0xe6c6, 0xbd57, 0xbf6a, 0xeaa8, 0xeaa2, 0xeaa6,
+ 0xeaac, 0xeaad, 0xeaa9, 0xeaaa, 0xeaa7, 0xeaa4, 0xbf6c, 0xbf69,
+ 0xeaa3, 0xeaa5, 0xbf6b, 0xeaab, 0xc146, 0xedaa, 0xeda5, 0xc145,
+ 0xc143, 0xedac, 0xc144, 0xeda8, 0xeda9, 0xeda6, 0xedad, 0xf056,
+ 0xc147, 0xeda7, 0xedae, 0xedab, 0xf05a, 0xf057, 0xc2a6, 0xf05b,
+ 0xf05d, 0xf05c, 0xf058, 0xf059, 0xf2a3, 0xc3aa, 0xf27e, 0xf2a2,
+ 0xf27d, 0xf2a4, 0xf2a1, 0xf47a, 0xf47d, 0xf479, 0xc471, 0xf47b,
+ 0xf47c, 0xf47e, 0xc472, 0xc474, 0xc473, 0xf5e1, 0xf5e3, 0xf5e2,
+ 0xf6f6, 0xf8b5, 0xf8fa, 0xa5dc, 0xcb72, 0xaac0, 0xcda3, 0xaac1,
+ 0xaac2, 0xcda2, 0xcff8, 0xcff7, 0xace6, 0xace9, 0xace8, 0xace7,
+ 0xcff4, 0xcff6, 0xcff5, 0xd2e8, 0xafa7, 0xd2ec, 0xd2eb, 0xd2ea,
+ 0xd2e6, 0xafa6, 0xafaa, 0xafad, 0xafae, 0xd2e7, 0xd2e9, 0xafac,
+ 0xafab, 0xafa9, 0xafa8, 0xd6c2, 0xd6c0, 0xd6bc, 0xb2bb, 0xd6bd,
+ 0xb2bc, 0xd6be, 0xd6bf, 0xd6c1, 0xb2bd, 0xdad5, 0xdad4, 0xdad3,
+ 0xdad2, 0xdef6, 0xb852, 0xdef3, 0xdef5, 0xb853, 0xb854, 0xdef4,
+ 0xe341, 0xe2f9, 0xe2fa, 0xbad7, 0xbad5, 0xbad6, 0xe343, 0xe342,
+ 0xe2fe, 0xe2fd, 0xe2fc, 0xe2fb, 0xe340, 0xe2f8, 0xe6cb, 0xe6d0,
+ 0xe6ce, 0xe6cd, 0xe6cc, 0xe6cf, 0xeaae, 0xbf6d, 0xc148, 0xedb0,
+ 0xc149, 0xedaf, 0xf05f, 0xf05e, 0xc2a7, 0xf2a5, 0xc3ab, 0xf4a1,
+ 0xc5a1, 0xf6f7, 0xf8b7, 0xf8b6, 0xc9a8, 0xacea, 0xaceb, 0xd6c3,
+ 0xb856, 0xa5dd, 0xa872, 0xa871, 0xa870, 0xcda4, 0xaac4, 0xaac3,
+ 0xacee, 0xcffa, 0xcffd, 0xcffb, 0xacec, 0xaced, 0xcff9, 0xcffc,
+ 0xafb5, 0xd2f3, 0xd2f5, 0xd2f4, 0xafb2, 0xd2ef, 0xafb0, 0xafaf,
+ 0xafb3, 0xafb1, 0xafb4, 0xd2f2, 0xd2ed, 0xd2ee, 0xd2f1, 0xd2f0,
+ 0xd6c6, 0xd6c7, 0xd6c5, 0xd6c4, 0xb2be, 0xb57d, 0xdad6, 0xdad8,
+ 0xdada, 0xb57c, 0xb57a, 0xdad7, 0xb57b, 0xdad9, 0xb579, 0xdf41,
+ 0xdef7, 0xdefa, 0xdefe, 0xb85a, 0xdefc, 0xdefb, 0xdef8, 0xdef9,
+ 0xb858, 0xdf40, 0xb857, 0xb85c, 0xb85b, 0xb859, 0xdefd, 0xe349,
+ 0xe348, 0xe344, 0xbad8, 0xe347, 0xe346, 0xbad9, 0xbd5e, 0xe6d2,
+ 0xbd5f, 0xbd5b, 0xbd5d, 0xbd5a, 0xbd5c, 0xeaaf, 0xbf70, 0xeab1,
+ 0xeab0, 0xe345, 0xbf72, 0xbf71, 0xbf6e, 0xbf6f, 0xedb5, 0xedb3,
+ 0xc14a, 0xedb4, 0xedb6, 0xedb2, 0xedb1, 0xf060, 0xc2aa, 0xc2a8,
+ 0xc2a9, 0xf2a6, 0xf2a7, 0xc3ad, 0xc3ac, 0xf4a3, 0xf4a4, 0xf4a2,
+ 0xf6f8, 0xf6f9, 0xa5de, 0xca48, 0xa873, 0xcda5, 0xaac6, 0xaac5,
+ 0xcda6, 0xd040, 0xacef, 0xcffe, 0xacf0, 0xafb6, 0xd2f8, 0xd2f6,
+ 0xd2fc, 0xafb7, 0xd2f7, 0xd2fb, 0xd2f9, 0xd2fa, 0xd6c8, 0xd6ca,
+ 0xb2bf, 0xd6c9, 0xb2c0, 0xb5a2, 0xb5a1, 0xb57e, 0xdadb, 0xdf44,
+ 0xb85d, 0xb85e, 0xdf43, 0xdf42, 0xe34a, 0xbadb, 0xbada, 0xe34b,
+ 0xe34c, 0xbd61, 0xbd60, 0xeab5, 0xe6d3, 0xe6d5, 0xe6d4, 0xeab4,
+ 0xeab2, 0xeab6, 0xeab3, 0xbf73, 0xedb7, 0xc14b, 0xedb8, 0xedb9,
+ 0xc2ab, 0xc2ac, 0xc475, 0xc5d1, 0xa5df, 0xd041, 0xd2fd, 0xafb8,
+ 0xb3ba, 0xb3b9, 0xb5a4, 0xdadd, 0xb5a3, 0xdadc, 0xdf45, 0xbadc,
+ 0xe34d, 0xbadd, 0xc476, 0xf4a5, 0xa6cb, 0xaac7, 0xcda7, 0xacf2,
+ 0xacf1, 0xd042, 0xd043, 0xd340, 0xd342, 0xafb9, 0xd344, 0xd347,
+ 0xd345, 0xd346, 0xd343, 0xd2fe, 0xafba, 0xd348, 0xd341, 0xd6d3,
+ 0xb2c6, 0xd6dc, 0xb2c3, 0xd6d5, 0xb2c7, 0xb2c1, 0xd6d0, 0xd6dd,
+ 0xd6d1, 0xd6ce, 0xb2c5, 0xb2c2, 0xd6d4, 0xd6d7, 0xb2c4, 0xd6d8,
+ 0xb2c8, 0xd6d9, 0xd6cf, 0xd6d6, 0xd6da, 0xd6d2, 0xd6cd, 0xd6cb,
+ 0xd6db, 0xdadf, 0xdae4, 0xdae0, 0xdae6, 0xb5a7, 0xd6cc, 0xdae1,
+ 0xb5a5, 0xdade, 0xb5ac, 0xdae2, 0xb5ab, 0xdae3, 0xb5ad, 0xb5a8,
+ 0xb5ae, 0xb5a9, 0xb5aa, 0xb5a6, 0xdae5, 0xb861, 0xdf50, 0xdf53,
+ 0xdf47, 0xdf4c, 0xdf46, 0xb863, 0xdf4a, 0xdf48, 0xb862, 0xdf4f,
+ 0xdf4e, 0xdf4b, 0xdf4d, 0xdf49, 0xbae1, 0xdf52, 0xb85f, 0xdf51,
+ 0xe35d, 0xbae8, 0xe358, 0xbae7, 0xe34e, 0xe350, 0xbae0, 0xe355,
+ 0xe354, 0xe357, 0xbae5, 0xe352, 0xe351, 0xbae4, 0xbadf, 0xe353,
+ 0xbae2, 0xe359, 0xe35b, 0xe356, 0xe34f, 0xbae3, 0xbd69, 0xbade,
+ 0xe35c, 0xe6d9, 0xbd62, 0xe6db, 0xbd63, 0xbd65, 0xe6de, 0xe6d6,
+ 0xbae6, 0xe6dc, 0xe6d8, 0xb860, 0xbd68, 0xbd64, 0xbd66, 0xbd67,
+ 0xbf76, 0xe6dd, 0xe6d7, 0xbd6a, 0xe6da, 0xeac0, 0xeabb, 0xeac5,
+ 0xbf74, 0xeabd, 0xbf78, 0xeac3, 0xeaba, 0xeab7, 0xeac6, 0xc151,
+ 0xbf79, 0xeac2, 0xeab8, 0xbf77, 0xeabc, 0xbf7b, 0xeab9, 0xeabe,
+ 0xbf7a, 0xeac1, 0xeac4, 0xedcb, 0xedcc, 0xedbc, 0xedc3, 0xedc1,
+ 0xc14f, 0xedc8, 0xeabf, 0xedbf, 0xedc9, 0xc14e, 0xedbe, 0xedbd,
+ 0xedc7, 0xedc4, 0xedc6, 0xedba, 0xedca, 0xc14c, 0xedc5, 0xedce,
+ 0xedc2, 0xc150, 0xc14d, 0xedc0, 0xedbb, 0xedcd, 0xbf75, 0xf063,
+ 0xf061, 0xf067, 0xc2b0, 0xf065, 0xf064, 0xc2b2, 0xf06a, 0xc2b1,
+ 0xf06b, 0xf068, 0xc2ae, 0xf069, 0xf062, 0xc2af, 0xc2ad, 0xf2ab,
+ 0xf066, 0xf06c, 0xf2a8, 0xc3b2, 0xc3b0, 0xf2aa, 0xf2ac, 0xf2a9,
+ 0xc3b1, 0xc3ae, 0xc3af, 0xc3b3, 0xc478, 0xf4aa, 0xf4a9, 0xf4a7,
+ 0xf4a6, 0xf4a8, 0xc477, 0xc479, 0xc4f0, 0xf5e5, 0xf5e4, 0xf6fa,
+ 0xf6fc, 0xf6fe, 0xf6fd, 0xf6fb, 0xc5a3, 0xc5a2, 0xc5d3, 0xc5d2,
+ 0xc5d4, 0xf7ed, 0xf7ec, 0xf8fb, 0xf8b8, 0xf8fc, 0xc658, 0xc659,
+ 0xf96d, 0xc67e, 0xa6cc, 0xcda8, 0xd045, 0xd046, 0xd044, 0xacf3,
+ 0xd047, 0xd048, 0xd049, 0xd349, 0xd34f, 0xd34d, 0xafbb, 0xd34b,
+ 0xd34c, 0xd34e, 0xd34a, 0xb2c9, 0xd6de, 0xb2cb, 0xd6e0, 0xb2ca,
+ 0xd6df, 0xdae8, 0xb5af, 0xdaea, 0xdae7, 0xd6e1, 0xb5b0, 0xdae9,
+ 0xdf56, 0xb864, 0xdf54, 0xb865, 0xdf55, 0xb866, 0xbae9, 0xe361,
+ 0xe35e, 0xe360, 0xbaea, 0xbaeb, 0xe35f, 0xe6df, 0xe6e0, 0xbd6b,
+ 0xe6e2, 0xe6e1, 0xa261, 0xeaca, 0xeacb, 0xeac7, 0xeac8, 0xbf7c,
+ 0xbf7d, 0xeac9, 0xc157, 0xc153, 0xc158, 0xc154, 0xc156, 0xc152,
+ 0xc155, 0xc2b3, 0xedcf, 0xf2ae, 0xf2ad, 0xf4ab, 0xc47a, 0xc47b,
+ 0xf741, 0xf5e6, 0xf740, 0xf8fd, 0xf9a4, 0xa6cd, 0xa874, 0xcda9,
+ 0xaac8, 0xacf6, 0xd04c, 0xacf4, 0xd04a, 0xacf9, 0xacf5, 0xacfa,
+ 0xacf8, 0xd04b, 0xacf7, 0xafbf, 0xafbe, 0xd35a, 0xafc7, 0xd353,
+ 0xd359, 0xafc3, 0xd352, 0xd358, 0xd356, 0xafc2, 0xafc4, 0xd355,
+ 0xafbd, 0xd354, 0xafc8, 0xafc5, 0xafc9, 0xafc6, 0xd351, 0xd350,
+ 0xd357, 0xafc0, 0xafbc, 0xafc1, 0xd6f0, 0xd6e9, 0xb5b5, 0xd6e8,
+ 0xb2cf, 0xb2d6, 0xb2d3, 0xb2d9, 0xb2d8, 0xb2d4, 0xd6e2, 0xd6e5,
+ 0xd6e4, 0xb2d0, 0xd6e6, 0xd6ef, 0xb2d1, 0xd6e3, 0xd6ec, 0xd6ed,
+ 0xb2d2, 0xd6ea, 0xb2d7, 0xb2cd, 0xb2d5, 0xd6e7, 0xb2cc, 0xd6eb,
+ 0xd6ee, 0xdafb, 0xdaf2, 0xb5b2, 0xdaf9, 0xdaf6, 0xdaee, 0xdaf7,
+ 0xb5b4, 0xdaef, 0xdaeb, 0xb86c, 0xdaf4, 0xb5b1, 0xdafa, 0xb5b8,
+ 0xb5ba, 0xdaed, 0xb5b9, 0xdaf0, 0xb5b3, 0xdaf8, 0xdaf1, 0xdaf5,
+ 0xdaf3, 0xb5b6, 0xdaec, 0xb5bb, 0xb2ce, 0xb5b7, 0xb5bc, 0xb868,
+ 0xdf5d, 0xdf5f, 0xdf61, 0xdf65, 0xdf5b, 0xdf59, 0xb86a, 0xdf60,
+ 0xdf64, 0xdf5c, 0xdf58, 0xdf57, 0xdf62, 0xdf5a, 0xdf5e, 0xb86b,
+ 0xb869, 0xdf66, 0xb867, 0xdf63, 0xe372, 0xbaee, 0xe36a, 0xbd78,
+ 0xe374, 0xbaf1, 0xe378, 0xbaf7, 0xe365, 0xe375, 0xe362, 0xe377,
+ 0xe366, 0xbafe, 0xbafb, 0xe376, 0xe370, 0xbaed, 0xbaf5, 0xbaf4,
+ 0xbaf3, 0xbaf9, 0xe363, 0xbafa, 0xe371, 0xbaf6, 0xbaec, 0xe373,
+ 0xbaef, 0xbaf0, 0xbaf8, 0xe368, 0xe367, 0xe364, 0xe36c, 0xe369,
+ 0xe36d, 0xbafd, 0xe379, 0xbaf2, 0xe36e, 0xe36f, 0xe36b, 0xbafc,
+ 0xe6e7, 0xbd70, 0xbd79, 0xbd75, 0xe6e4, 0xbd72, 0xbd76, 0xe6f0,
+ 0xbd6c, 0xe6e8, 0xbd74, 0xe6eb, 0xe6e6, 0xbd73, 0xbd77, 0xe6e5,
+ 0xbd71, 0xe6ef, 0xbd6e, 0xe6ee, 0xe6ed, 0xbd7a, 0xe572, 0xbd6d,
+ 0xe6ec, 0xe6e3, 0xbd7b, 0xe6ea, 0xbd6f, 0xe6e9, 0xbfa2, 0xbfa7,
+ 0xbf7e, 0xead8, 0xeacf, 0xeadb, 0xead3, 0xead9, 0xbfa8, 0xbfa1,
+ 0xeacc, 0xead2, 0xeadc, 0xead5, 0xeada, 0xeace, 0xead6, 0xbfa3,
+ 0xead4, 0xbfa6, 0xbfa5, 0xead0, 0xead1, 0xeacd, 0xead7, 0xbfa4,
+ 0xeade, 0xeadd, 0xedda, 0xedd6, 0xc15f, 0xedd0, 0xc159, 0xc169,
+ 0xeddc, 0xc161, 0xc15d, 0xedd3, 0xc164, 0xc167, 0xedde, 0xc15c,
+ 0xedd5, 0xc165, 0xede0, 0xeddd, 0xedd1, 0xc160, 0xc15a, 0xc168,
+ 0xedd8, 0xc163, 0xedd2, 0xc15e, 0xeddf, 0xc162, 0xc15b, 0xedd9,
+ 0xc166, 0xedd7, 0xeddb, 0xf06e, 0xf074, 0xc2b9, 0xf077, 0xc2b4,
+ 0xc2b5, 0xf06f, 0xf076, 0xf071, 0xc2ba, 0xc2b7, 0xf06d, 0xc2b6,
+ 0xf073, 0xf075, 0xc2b8, 0xf072, 0xf070, 0xf2b8, 0xc3b7, 0xc3b8,
+ 0xc3b4, 0xc3b5, 0xf2b4, 0xf2b2, 0xf2b6, 0xc3ba, 0xf2b7, 0xf2b0,
+ 0xf2af, 0xf2b3, 0xf2b1, 0xc3b6, 0xf2b5, 0xf4ac, 0xc47e, 0xc47d,
+ 0xf4ad, 0xf4af, 0xf4ae, 0xc4a1, 0xf5eb, 0xf5e8, 0xf5e9, 0xf5e7,
+ 0xf5ea, 0xc4f2, 0xf5ec, 0xc4f1, 0xf742, 0xc5d5, 0xc5d7, 0xf7ee,
+ 0xc5d6, 0xf8b9, 0xf940, 0xf942, 0xf8fe, 0xf941, 0xc66c, 0xa6ce,
+ 0xacfb, 0xd26f, 0xafca, 0xb2da, 0xdafc, 0xdafd, 0xeadf, 0xc16a,
+ 0xede1, 0xc2bb, 0xf2ba, 0xf2b9, 0xc4a2, 0xf5ed, 0xf743, 0xc5f8,
+ 0xca49, 0xaac9, 0xa875, 0xd04d, 0xd360, 0xd35b, 0xd35f, 0xd35d,
+ 0xafcb, 0xd35e, 0xd35c, 0xd6f1, 0xdafe, 0xdb40, 0xdf69, 0xdf6a,
+ 0xb86e, 0xb86f, 0xdf68, 0xdf6b, 0xdf67, 0xb86d, 0xbb40, 0xb870,
+ 0xe37a, 0xbd7c, 0xe6f1, 0xbd7d, 0xbfa9, 0xeae2, 0xeae0, 0xeae1,
+ 0xede4, 0xede3, 0xede2, 0xf2bb, 0xc3b9, 0xf2bc, 0xf744, 0xc5f9,
+ 0xf8ba, 0xa6cf, 0xaacb, 0xaaca, 0xd04f, 0xacfc, 0xd04e, 0xd362,
+ 0xafcc, 0xd6f2, 0xd361, 0xb2dc, 0xd6f5, 0xd6f3, 0xd6f4, 0xb2db,
+ 0xdb42, 0xdb43, 0xdb41, 0xb873, 0xdf6d, 0xdf6c, 0xdf6e, 0xb872,
+ 0xb871, 0xe6f2, 0xe6f4, 0xbd7e, 0xe6f3, 0xeae3, 0xbfaa, 0xf079,
+ 0xf078, 0xc3bb, 0xf2bd, 0xc3bd, 0xc3bc, 0xf4b0, 0xf5ee, 0xc4f3,
+ 0xa6d0, 0xd050, 0xacfd, 0xd365, 0xafce, 0xd364, 0xd363, 0xafcd,
+ 0xd6fb, 0xd6fd, 0xd6f6, 0xd6f7, 0xb2dd, 0xd6f8, 0xb2de, 0xd6fc,
+ 0xd6f9, 0xd6fa, 0xb2df, 0xb5be, 0xb5bf, 0xdb44, 0xdf6f, 0xdf70,
+ 0xe37e, 0xbb43, 0xbb41, 0xbb42, 0xe37b, 0xe37c, 0xe37d, 0xe6f9,
+ 0xe6fa, 0xbda1, 0xe6f7, 0xe6f6, 0xe6f8, 0xe6f5, 0xbfad, 0xeae4,
+ 0xbfab, 0xbfac, 0xede6, 0xc16b, 0xede5, 0xefa8, 0xf07a, 0xf07b,
+ 0xc2bc, 0xc2bd, 0xc16c, 0xf2be, 0xf2bf, 0xf4b1, 0xc4a3, 0xa6d1,
+ 0xa6d2, 0xacfe, 0xaacc, 0xafcf, 0xd051, 0xb5c0, 0xa6d3, 0xad41,
+ 0xd052, 0xd053, 0xad40, 0xad42, 0xa6d4, 0xd054, 0xafd1, 0xd366,
+ 0xafd3, 0xafd0, 0xafd2, 0xd741, 0xb2e0, 0xd740, 0xd6fe, 0xdf71,
+ 0xe3a1, 0xbda2, 0xbfae, 0xeae6, 0xeae5, 0xede7, 0xf5ef, 0xa6d5,
+ 0xcb73, 0xcdaa, 0xad43, 0xd055, 0xd368, 0xafd4, 0xd367, 0xafd5,
+ 0xd743, 0xb2e2, 0xd742, 0xd744, 0xb2e1, 0xdb46, 0xdb47, 0xdb45,
+ 0xb5c1, 0xb874, 0xb875, 0xbb45, 0xe3a3, 0xe3a2, 0xbb44, 0xe6fb,
+ 0xe6fc, 0xeae7, 0xc170, 0xc16f, 0xc16d, 0xc16e, 0xc171, 0xf07c,
+ 0xc2bf, 0xc2be, 0xf2c0, 0xf4b2, 0xc5a5, 0xc5a4, 0xa6d6, 0xd1fb,
+ 0xb877, 0xb5c2, 0xb876, 0xbb46, 0xa6d7, 0xc9a9, 0xa6d8, 0xa6d9,
+ 0xcdab, 0xcb76, 0xcb77, 0xa877, 0xcb74, 0xa876, 0xa879, 0xcb75,
+ 0xa87b, 0xa87a, 0xcb78, 0xa878, 0xaad1, 0xaacf, 0xcdad, 0xaace,
+ 0xaad3, 0xaad5, 0xaad2, 0xcdb0, 0xcdac, 0xaad6, 0xaad0, 0xa87c,
+ 0xaad4, 0xcdaf, 0xcdae, 0xaacd, 0xd05b, 0xad47, 0xad48, 0xd05d,
+ 0xd057, 0xd05a, 0xd063, 0xd061, 0xad49, 0xd067, 0xad4c, 0xd064,
+ 0xd05c, 0xd059, 0xdb49, 0xd062, 0xad44, 0xd065, 0xd056, 0xd05f,
+ 0xad46, 0xad4b, 0xd060, 0xad4f, 0xad4d, 0xd058, 0xad4a, 0xd05e,
+ 0xad4e, 0xad45, 0xd066, 0xafda, 0xafe3, 0xafd8, 0xafd6, 0xd36a,
+ 0xafde, 0xafdb, 0xd36c, 0xafdd, 0xd36b, 0xd369, 0xd36e, 0xafe2,
+ 0xafe0, 0xdb48, 0xd36f, 0xd36d, 0xafd7, 0xafd9, 0xafdc, 0xafdf,
+ 0xafe1, 0xd74e, 0xb2e4, 0xd745, 0xd747, 0xd748, 0xd750, 0xd74c,
+ 0xd74a, 0xd74d, 0xd751, 0xb2e5, 0xb2e9, 0xd746, 0xd74f, 0xb2e7,
+ 0xb2e6, 0xd74b, 0xd749, 0xb2e3, 0xb2e8, 0xb5c8, 0xdb51, 0xdb4f,
+ 0xb5ca, 0xdb4a, 0xdfa1, 0xb5c9, 0xdb4e, 0xdb4b, 0xb5c5, 0xb5cb,
+ 0xdb50, 0xb5c7, 0xdb4d, 0xbb47, 0xb5c6, 0xdb4c, 0xb5cc, 0xb5c4,
+ 0xb5c3, 0xdf77, 0xdf75, 0xdf7b, 0xdf73, 0xdfa2, 0xdf78, 0xdf72,
+ 0xb87b, 0xb8a3, 0xdf7d, 0xdf76, 0xb87e, 0xb87c, 0xdf7e, 0xb879,
+ 0xb878, 0xdf79, 0xb87d, 0xb5cd, 0xdf7c, 0xdf74, 0xb87a, 0xb8a1,
+ 0xb8a2, 0xbb4c, 0xbb48, 0xbb4d, 0xe3a6, 0xe3a5, 0xe3a7, 0xbb4a,
+ 0xe3a4, 0xbb4b, 0xe3aa, 0xe3a9, 0xe3a8, 0xbb49, 0xe741, 0xe744,
+ 0xbda8, 0xe743, 0xbda7, 0xbda3, 0xbda4, 0xbda5, 0xe740, 0xe6fe,
+ 0xbda6, 0xe742, 0xe6fd, 0xeae9, 0xeaf3, 0xbfb1, 0xbfb0, 0xeaed,
+ 0xeaef, 0xeaea, 0xeaee, 0xeae8, 0xeaf1, 0xbfaf, 0xeaf0, 0xeaec,
+ 0xeaf2, 0xeaeb, 0xc174, 0xede8, 0xedee, 0xc178, 0xc17a, 0xc177,
+ 0xc176, 0xc175, 0xc173, 0xede9, 0xedec, 0xc172, 0xeded, 0xc179,
+ 0xedeb, 0xedea, 0xc2c0, 0xc2c1, 0xf0a1, 0xf07d, 0xf07e, 0xf2c2,
+ 0xf2c1, 0xc3be, 0xf4b4, 0xc4a4, 0xf4b3, 0xf5f0, 0xf745, 0xc5a6,
+ 0xf943, 0xf944, 0xc5d8, 0xa6da, 0xaad7, 0xdb52, 0xbb4e, 0xc17b,
+ 0xedef, 0xa6db, 0xafe5, 0xafe4, 0xdb53, 0xeaf4, 0xa6dc, 0xad50,
+ 0xdb54, 0xdb55, 0xdb56, 0xbb4f, 0xbfb2, 0xa6dd, 0xaad8, 0xd068,
+ 0xafe6, 0xd370, 0xb2ea, 0xdb57, 0xb8a4, 0xbb50, 0xbfb3, 0xc17c,
+ 0xc2c2, 0xf4b5, 0xa6de, 0xaad9, 0xafe7, 0xd752, 0xb5ce, 0xbb51,
+ 0xe3ab, 0xe745, 0xa6df, 0xb5cf, 0xdfa3, 0xbb52, 0xa6e0, 0xcdb1,
+ 0xd069, 0xad51, 0xd372, 0xafea, 0xafe8, 0xafe9, 0xafeb, 0xd371,
+ 0xd757, 0xd754, 0xd756, 0xb2eb, 0xb2ed, 0xb2ec, 0xd753, 0xb2ee,
+ 0xd755, 0xdb58, 0xdb59, 0xdb5a, 0xdfa6, 0xdfa7, 0xdfa5, 0xdfa8,
+ 0xb8a5, 0xdfa4, 0xbb53, 0xe74a, 0xe746, 0xe749, 0xe74b, 0xe748,
+ 0xe747, 0xeaf5, 0xeaf6, 0xeaf7, 0xbfb4, 0xbfb5, 0xedf1, 0xedf0,
+ 0xedf2, 0xf0a3, 0xf0a2, 0xf2c4, 0xf2c5, 0xf2c3, 0xc4a5, 0xf4b6,
+ 0xf4b7, 0xf746, 0xf7ef, 0xf8bb, 0xa6e1, 0xa87d, 0xc17d, 0xa6e2,
+ 0xd758, 0xdb5b, 0xc641, 0xca4a, 0xca4b, 0xca4d, 0xa6e3, 0xca4e,
+ 0xca4c, 0xcba2, 0xcba3, 0xcb7b, 0xcba1, 0xa8a1, 0xa8a2, 0xcb7c,
+ 0xcb7a, 0xcb79, 0xcb7d, 0xa87e, 0xcb7e, 0xd06a, 0xcdb6, 0xaadc,
+ 0xcdb5, 0xcdb7, 0xaadb, 0xcdbc, 0xaadf, 0xcdb2, 0xcdc0, 0xcdc6,
+ 0xaae6, 0xcdc3, 0xaae3, 0xcdb9, 0xcdbf, 0xcdc1, 0xcdb4, 0xaae2,
+ 0xaadd, 0xcdba, 0xaae4, 0xaae7, 0xaae1, 0xaada, 0xcdbe, 0xcdb8,
+ 0xcdc5, 0xaae9, 0xaae5, 0xaae0, 0xcdbd, 0xafec, 0xcdbb, 0xaade,
+ 0xaae8, 0xcdb3, 0xcdc2, 0xcdc4, 0xad62, 0xad5c, 0xad64, 0xad61,
+ 0xd071, 0xd074, 0xad5d, 0xd06b, 0xad56, 0xad60, 0xad63, 0xad65,
+ 0xd0a2, 0xd077, 0xad55, 0xd0a1, 0xad59, 0xad57, 0xad52, 0xd06f,
+ 0xd07e, 0xd073, 0xd076, 0xd0a5, 0xad66, 0xd07d, 0xad5e, 0xd078,
+ 0xd0a4, 0xd075, 0xd079, 0xd07c, 0xd06d, 0xd0a3, 0xd07b, 0xd06c,
+ 0xd070, 0xad5f, 0xad5a, 0xad53, 0xad58, 0xad54, 0xad67, 0xd06e,
+ 0xd3a5, 0xad5b, 0xd07a, 0xce41, 0xd3a8, 0xaffa, 0xd376, 0xd3a3,
+ 0xd37d, 0xd3b2, 0xd3aa, 0xd37e, 0xd3a9, 0xd378, 0xd37c, 0xd3b5,
+ 0xaffd, 0xd3ad, 0xd3a4, 0xafed, 0xd3b3, 0xd374, 0xd3ac, 0xaffc,
+ 0xaff7, 0xd373, 0xaff5, 0xaff4, 0xaff9, 0xd3ab, 0xaff1, 0xaff8,
+ 0xd072, 0xdb5c, 0xd3a6, 0xd37a, 0xaffb, 0xd37b, 0xd3a1, 0xaffe,
+ 0xd375, 0xd3af, 0xd3ae, 0xd3b6, 0xaff3, 0xaff0, 0xd3b4, 0xd3b0,
+ 0xd3a7, 0xd3a2, 0xaff6, 0xaff2, 0xd377, 0xafee, 0xd3b1, 0xafef,
+ 0xd379, 0xd75e, 0xd760, 0xd765, 0xd779, 0xb2fc, 0xb2f2, 0xd75d,
+ 0xb2fd, 0xb2fe, 0xd768, 0xd76f, 0xd775, 0xd762, 0xd769, 0xb340,
+ 0xd777, 0xd772, 0xb2fa, 0xb2f8, 0xd76e, 0xd76a, 0xd75c, 0xb2ef,
+ 0xd761, 0xd759, 0xb2f7, 0xb2f9, 0xd766, 0xd763, 0xb2f4, 0xd773,
+ 0xb2f1, 0xd764, 0xd77a, 0xd76c, 0xd76b, 0xb2f0, 0xb2fb, 0xb2f3,
+ 0xd75a, 0xd75f, 0xd770, 0xd776, 0xb341, 0xd75b, 0xd767, 0xd76d,
+ 0xb2f6, 0xd778, 0xd771, 0xd774, 0xb2f5, 0xdb6c, 0xdb60, 0xb5d7,
+ 0xdb7d, 0xdba7, 0xdbaa, 0xb5d5, 0xdb68, 0xdba3, 0xdb69, 0xdb77,
+ 0xb5e2, 0xdb73, 0xb5df, 0xdb74, 0xdb5d, 0xdba4, 0xb5e8, 0xdba1,
+ 0xdb75, 0xdbac, 0xdb70, 0xdfc8, 0xdbaf, 0xb5e6, 0xdb6e, 0xdb7a,
+ 0xb5e9, 0xb5d4, 0xdb72, 0xdbad, 0xdb6b, 0xdb64, 0xdb6f, 0xdb63,
+ 0xdb61, 0xb5d0, 0xdba5, 0xdb6a, 0xdba8, 0xdba9, 0xb5d8, 0xb5dd,
+ 0xb5d9, 0xb5e1, 0xdb7e, 0xb5da, 0xdb76, 0xdb66, 0xb5d2, 0xdb5e,
+ 0xdba2, 0xdbab, 0xdb65, 0xb5e0, 0xdbb0, 0xdb71, 0xdb6d, 0xb5d1,
+ 0xb5e5, 0xdb7c, 0xb5e7, 0xdb78, 0xb5dc, 0xb5d6, 0xb5de, 0xb5d3,
+ 0xb5e4, 0xdb79, 0xdb67, 0xdb7b, 0xdb62, 0xdba6, 0xdbae, 0xdb5f,
+ 0xdfc7, 0xdfdd, 0xb855, 0xdfcc, 0xdfca, 0xdfb5, 0xb8a9, 0xdfc5,
+ 0xdfd9, 0xdfc1, 0xb8b1, 0xdfd8, 0xdfbf, 0xb5e3, 0xdfcf, 0xdfc0,
+ 0xdfd6, 0xb8b0, 0xb8a8, 0xdfaa, 0xdfb2, 0xdfcb, 0xdfc3, 0xdfdc,
+ 0xdfc6, 0xb8b6, 0xdfd7, 0xb8ad, 0xdfc9, 0xdfd1, 0xdfb6, 0xdfd0,
+ 0xdfe1, 0xdfb1, 0xdfd2, 0xdfdf, 0xdfab, 0xb5db, 0xdfb9, 0xdfb8,
+ 0xb8af, 0xdfbc, 0xdfbe, 0xdfcd, 0xdfde, 0xb8b2, 0xb8b3, 0xdfb0,
+ 0xb8ab, 0xdfb4, 0xdfda, 0xb8b4, 0xb8ac, 0xb8ae, 0xb8b5, 0xdfe0,
+ 0xdfd3, 0xdfce, 0xdfbb, 0xdfba, 0xb8aa, 0xdfac, 0xb8a7, 0xdfc4,
+ 0xdfad, 0xdfc2, 0xdfb7, 0xdfdb, 0xb8a6, 0xdfb3, 0xdfaf, 0xdfd5,
+ 0xdfae, 0xbb60, 0xe3d3, 0xe3c2, 0xe3ac, 0xe3ca, 0xbb58, 0xe3bb,
+ 0xe3c5, 0xbb5b, 0xe3be, 0xbb59, 0xe3af, 0xe3cd, 0xe3ae, 0xe3c1,
+ 0xe3ad, 0xe3bf, 0xe3c8, 0xe3c6, 0xe3ba, 0xe3b5, 0xe3b3, 0xe3b4,
+ 0xe3c7, 0xe3d2, 0xe3bc, 0xbb5a, 0xe3b7, 0xe3cb, 0xbb5d, 0xe3b6,
+ 0xe3b0, 0xe3c0, 0xbb61, 0xbb55, 0xbb5e, 0xe3b8, 0xe3b2, 0xbb57,
+ 0xdfd4, 0xbb56, 0xe3c3, 0xbb54, 0xbb63, 0xbb5c, 0xe3c4, 0xe3b9,
+ 0xe3b1, 0xe3cc, 0xe3bd, 0xbb62, 0xe3d0, 0xbb5f, 0xe3cf, 0xe3c9,
+ 0xe3ce, 0xe3d1, 0xe773, 0xe774, 0xe767, 0xe766, 0xe762, 0xbdb4,
+ 0xbdac, 0xe776, 0xe775, 0xdfa9, 0xe75f, 0xe763, 0xe75d, 0xe770,
+ 0xe761, 0xe777, 0xe75a, 0xe758, 0xe764, 0xe76e, 0xe769, 0xbdb6,
+ 0xe74f, 0xe76d, 0xbdb7, 0xdfbd, 0xe75b, 0xe752, 0xe755, 0xe77b,
+ 0xe75c, 0xe753, 0xe751, 0xe74e, 0xbdb0, 0xe765, 0xbdaf, 0xbdb3,
+ 0xe760, 0xe768, 0xbda9, 0xe778, 0xe77c, 0xbdab, 0xe757, 0xe76b,
+ 0xe76f, 0xe754, 0xe779, 0xbdb2, 0xbdb1, 0xe74c, 0xbdb5, 0xe772,
+ 0xe756, 0xe76a, 0xe750, 0xe75e, 0xe759, 0xbdad, 0xbdae, 0xe76c,
+ 0xe77d, 0xe77a, 0xe771, 0xe74d, 0xbdaa, 0xeb49, 0xeb40, 0xeb43,
+ 0xbfbb, 0xeb45, 0xeaf9, 0xeb41, 0xeb47, 0xbfb8, 0xbfbc, 0xbfb6,
+ 0xeafb, 0xeb4c, 0xeb46, 0xeafc, 0xeb55, 0xeb4f, 0xeaf8, 0xee46,
+ 0xeafe, 0xbfb7, 0xeb4a, 0xeb54, 0xbfbf, 0xeb51, 0xeafd, 0xeb44,
+ 0xeb48, 0xeb42, 0xeb56, 0xeb53, 0xeb50, 0xbfb9, 0xbfba, 0xbfbe,
+ 0xeafa, 0xeb57, 0xbfbd, 0xeb4d, 0xeb4b, 0xeb4e, 0xee53, 0xee40,
+ 0xee45, 0xee52, 0xee44, 0xedfb, 0xee41, 0xc1a2, 0xedf4, 0xee4d,
+ 0xee4f, 0xedf3, 0xc1a1, 0xee51, 0xee49, 0xc1a8, 0xee50, 0xee42,
+ 0xc1aa, 0xedf9, 0xeb52, 0xee4a, 0xee47, 0xedf5, 0xee55, 0xc1a4,
+ 0xc1a5, 0xedf7, 0xee48, 0xee54, 0xee4b, 0xedfd, 0xc1a7, 0xc1a3,
+ 0xee4c, 0xedfe, 0xee56, 0xedf8, 0xee43, 0xee4e, 0xedfa, 0xedfc,
+ 0xc2cb, 0xedf6, 0xc1a9, 0xc2c4, 0xc17e, 0xc1a6, 0xc2c8, 0xf0b3,
+ 0xf0a9, 0xf0a4, 0xf0aa, 0xf0b4, 0xf0b8, 0xf0b7, 0xc2ca, 0xc2c9,
+ 0xf0ab, 0xf0b9, 0xf0ae, 0xf0a6, 0xf0a8, 0xf0a7, 0xf0ad, 0xf0b2,
+ 0xf0a5, 0xf0ac, 0xf0b1, 0xc2c7, 0xf0af, 0xc2c5, 0xf0b0, 0xc2c3,
+ 0xc2c6, 0xf2d5, 0xf0b5, 0xc3c2, 0xf2cd, 0xf2d1, 0xf2c9, 0xf2cc,
+ 0xf2d4, 0xc3c0, 0xf2d9, 0xf2d2, 0xf2ca, 0xf2da, 0xf2d3, 0xc3c3,
+ 0xc3c4, 0xf2d7, 0xf2cb, 0xc3bf, 0xc3c1, 0xf2c6, 0xf2ce, 0xf2c8,
+ 0xf2d8, 0xf2d6, 0xf2c7, 0xf2cf, 0xf4be, 0xc3c5, 0xf2d0, 0xc4a7,
+ 0xc4a9, 0xc4a6, 0xf4c3, 0xf4bb, 0xf4b9, 0xf4bd, 0xf4ba, 0xf4bf,
+ 0xf4c1, 0xc4aa, 0xc4ac, 0xf4c0, 0xc4ad, 0xc4ab, 0xf4c2, 0xc4a8,
+ 0xc4f4, 0xf5f1, 0xf5f7, 0xc4f6, 0xf4bc, 0xf5f6, 0xf5fd, 0xf5f4,
+ 0xf5fb, 0xf5fa, 0xf4b8, 0xf5f5, 0xf0b6, 0xf5fe, 0xf5f3, 0xf5f8,
+ 0xf5fc, 0xf5f2, 0xf74a, 0xc4f5, 0xf5f9, 0xf7f4, 0xf74b, 0xf749,
+ 0xf747, 0xf748, 0xf74c, 0xc5d9, 0xf7f2, 0xf7f0, 0xf7f5, 0xf7f3,
+ 0xf7f6, 0xc5da, 0xf7f1, 0xf8bc, 0xf945, 0xf946, 0xf947, 0xf9c7,
+ 0xf9bd, 0xca4f, 0xaaea, 0xad68, 0xd3b8, 0xd3b7, 0xb040, 0xb342,
+ 0xd77c, 0xd77b, 0xb5ea, 0xb8b8, 0xb8b7, 0xb8b9, 0xe3d4, 0xe77e,
+ 0xeb58, 0xeb5a, 0xeb59, 0xc1ab, 0xee57, 0xf0ba, 0xf9a5, 0xa6e4,
+ 0xcdc9, 0xcdca, 0xcdc8, 0xcdc7, 0xaaeb, 0xd0a9, 0xd0a7, 0xd0a6,
+ 0xad69, 0xad6b, 0xad6a, 0xd0a8, 0xd3c4, 0xd3c1, 0xd3bf, 0xb041,
+ 0xd3c2, 0xb046, 0xd3bc, 0xd3cb, 0xd3cd, 0xd3bd, 0xb043, 0xd3ce,
+ 0xd3c9, 0xd3bb, 0xd3c0, 0xd3ca, 0xd3c6, 0xd3c3, 0xb048, 0xd3cc,
+ 0xd3be, 0xd3c7, 0xd3b9, 0xb047, 0xb044, 0xd3c5, 0xd3c8, 0xd3ba,
+ 0xb045, 0xb042, 0xb34c, 0xd7a5, 0xb34b, 0xd7a8, 0xd7ab, 0xb348,
+ 0xb346, 0xd77e, 0xd7a9, 0xd7a7, 0xd7a4, 0xd7ac, 0xd7ad, 0xd7af,
+ 0xd7b0, 0xd77d, 0xb345, 0xd7a2, 0xd7a1, 0xd7ae, 0xb347, 0xd7a3,
+ 0xb349, 0xb344, 0xd7a6, 0xb34d, 0xb34a, 0xd7aa, 0xb5f1, 0xdbbf,
+ 0xdbb4, 0xb5ee, 0xdfe7, 0xdbbd, 0xdbb1, 0xb5ec, 0xdbb6, 0xb5ef,
+ 0xdbba, 0xdbb8, 0xb5f2, 0xb5eb, 0xdbb2, 0xdbb5, 0xb5f0, 0xdbb3,
+ 0xdbbe, 0xdbbc, 0xdbb7, 0xdbb9, 0xdbbb, 0xb5ed, 0xdfe8, 0xdfee,
+ 0xdfe4, 0xdfea, 0xb8ba, 0xdfe6, 0xb8c0, 0xb8bf, 0xb8be, 0xdfed,
+ 0xb8c1, 0xb8c2, 0xdfe3, 0xdff0, 0xb8c3, 0xb8bd, 0xb8bc, 0xdfec,
+ 0xb8c4, 0xdfe2, 0xdfe5, 0xdfef, 0xdfeb, 0xe3f4, 0xe3e9, 0xb8bb,
+ 0xbb6a, 0xe3dd, 0xe3f2, 0xe3de, 0xbb65, 0xe3db, 0xe3e4, 0xe3dc,
+ 0xbb67, 0xe3d6, 0xe3f1, 0xbb68, 0xe3ee, 0xe3ef, 0xe3d7, 0xbb6d,
+ 0xe3e6, 0xe3e0, 0xe3e7, 0xe3da, 0xe3f3, 0xe3eb, 0xe3e5, 0xe3d5,
+ 0xbb69, 0xe3ec, 0xbb6c, 0xe3f0, 0xe3ea, 0xbb66, 0xe3e8, 0xe3e2,
+ 0xbb64, 0xe3d9, 0xe3e1, 0xe3ed, 0xe3df, 0xe3e3, 0xbdc1, 0xdfe9,
+ 0xe7b2, 0xe7bb, 0xe7b1, 0xe7ad, 0xe7aa, 0xbdc2, 0xe7a8, 0xbb6b,
+ 0xe7a1, 0xbdc0, 0xe7a7, 0xbdbf, 0xe7ac, 0xe7a9, 0xe7b9, 0xe7b4,
+ 0xe7ae, 0xe7b3, 0xbdbb, 0xe7ab, 0xe7be, 0xe7a2, 0xe7a3, 0xe7ba,
+ 0xbdbc, 0xe7bf, 0xbdbe, 0xe7c0, 0xe7b0, 0xe3d8, 0xe7b6, 0xe7af,
+ 0xe7b8, 0xe7b5, 0xe7a6, 0xbdb9, 0xe7bd, 0xbdba, 0xe7a4, 0xbdbd,
+ 0xeb64, 0xe7b7, 0xe7bc, 0xeb61, 0xbdb8, 0xbfc0, 0xeb6b, 0xeb67,
+ 0xeb65, 0xeb60, 0xeb6f, 0xbfc4, 0xeb5c, 0xeb68, 0xeb69, 0xeb5f,
+ 0xeb5e, 0xeb6c, 0xeb62, 0xeb5d, 0xeb63, 0xeb6e, 0xeb5b, 0xeb6d,
+ 0xeb6a, 0xbfc2, 0xbfc1, 0xbfc3, 0xeb66, 0xf0cb, 0xee59, 0xc1b1,
+ 0xee5d, 0xee5a, 0xee61, 0xee67, 0xee5c, 0xee70, 0xc1ae, 0xee6a,
+ 0xee5f, 0xee6b, 0xee66, 0xee6d, 0xee5e, 0xc1b3, 0xc1b2, 0xee60,
+ 0xee6e, 0xee58, 0xee6c, 0xc1ac, 0xee64, 0xee63, 0xee68, 0xee5b,
+ 0xc1b0, 0xc1b4, 0xee62, 0xee69, 0xc1b5, 0xee65, 0xc1ad, 0xc1af,
+ 0xf0c7, 0xf0c5, 0xf0cc, 0xf0c9, 0xf0cd, 0xf0be, 0xf0c6, 0xf0d1,
+ 0xee6f, 0xf0c2, 0xc2cf, 0xe7a5, 0xf0bd, 0xf0ca, 0xf0c4, 0xf0c1,
+ 0xf0bc, 0xf0bb, 0xf0d0, 0xf0c0, 0xf0bf, 0xc2cd, 0xf0c8, 0xc2cc,
+ 0xc2ce, 0xf0c3, 0xf0cf, 0xf2de, 0xf2df, 0xc3c9, 0xf2dc, 0xc3c6,
+ 0xf2e4, 0xc3ca, 0xf2e6, 0xf2db, 0xf0ce, 0xf2e8, 0xf2dd, 0xc3c7,
+ 0xf2e3, 0xf2e5, 0xf2e0, 0xf2e7, 0xf2e2, 0xf2e1, 0xc3c8, 0xf4c5,
+ 0xf4c6, 0xf4c8, 0xc4ae, 0xc4af, 0xf4c9, 0xf4c7, 0xf4c4, 0xf642,
+ 0xf645, 0xf641, 0xc4fa, 0xf643, 0xc4f9, 0xc4f8, 0xc4f7, 0xf644,
+ 0xf751, 0xf74f, 0xf74e, 0xf640, 0xf750, 0xf646, 0xf74d, 0xf7f9,
+ 0xf7d7, 0xf7f7, 0xc5db, 0xf7f8, 0xf7fa, 0xf8bf, 0xc5fa, 0xf8be,
+ 0xf8bd, 0xc5fb, 0xc65a, 0xf96e, 0xf9a7, 0xf9a6, 0xf9a8, 0xa6e5,
+ 0xd0aa, 0xd3cf, 0xd3d0, 0xdbc0, 0xf647, 0xf8c0, 0xa6e6, 0xad6c,
+ 0xd0ab, 0xd7b1, 0xb34e, 0xdbc2, 0xdbc1, 0xb5f3, 0xb8c5, 0xe7c1,
+ 0xbdc3, 0xbdc4, 0xbfc5, 0xc5fc, 0xa6e7, 0xd0ac, 0xaaed, 0xd0ae,
+ 0xd0ad, 0xad6d, 0xd3d1, 0xd3d8, 0xb049, 0xd3d6, 0xd3d4, 0xd3db,
+ 0xd3d2, 0xd3d3, 0xb04a, 0xb04e, 0xd3dc, 0xb04d, 0xd3da, 0xd3d7,
+ 0xd3d5, 0xb04b, 0xb04c, 0xd3d9, 0xb350, 0xd7b2, 0xb355, 0xd7c2,
+ 0xb354, 0xd7c4, 0xd7b8, 0xb352, 0xd7c3, 0xd7b3, 0xb353, 0xd7bf,
+ 0xd7bb, 0xd7bd, 0xd7b7, 0xd7be, 0xb34f, 0xd7ba, 0xd7b9, 0xd7b5,
+ 0xd7c0, 0xd7bc, 0xd7b4, 0xd7b6, 0xb351, 0xd7c1, 0xb5f6, 0xdbcd,
+ 0xdbc9, 0xdbcb, 0xdbc6, 0xdbc5, 0xdbc3, 0xdbca, 0xdbcc, 0xdbc8,
+ 0xdbc7, 0xb5f4, 0xb5f5, 0xdbcf, 0xb8cd, 0xdff2, 0xdff8, 0xdff3,
+ 0xdff4, 0xdff9, 0xb8cf, 0xb8c7, 0xb8ce, 0xdff1, 0xdbc4, 0xb8ca,
+ 0xb8c8, 0xdff7, 0xdff6, 0xb8c9, 0xb8cb, 0xdff5, 0xb8c6, 0xb8cc,
+ 0xe3f6, 0xbb74, 0xe442, 0xe441, 0xe3fb, 0xbb76, 0xe440, 0xe3f7,
+ 0xe3f8, 0xbb6e, 0xbb70, 0xe3fd, 0xe3f5, 0xbb72, 0xbb71, 0xe3f9,
+ 0xe3fe, 0xe3fc, 0xbb73, 0xe3fa, 0xdbce, 0xbb6f, 0xe7c2, 0xe7c9,
+ 0xbdc6, 0xe7cd, 0xbdca, 0xe7c5, 0xe7c3, 0xe7cc, 0xbdc5, 0xe7cb,
+ 0xbdc7, 0xbdc8, 0xe7c4, 0xbdc9, 0xe7ca, 0xe7c6, 0xe7c7, 0xe7c8,
+ 0xbb75, 0xeb70, 0xeb7c, 0xbfca, 0xeb77, 0xeb79, 0xbfc8, 0xeb71,
+ 0xeb75, 0xeb78, 0xbfc6, 0xbfc9, 0xeb7b, 0xeb73, 0xeb74, 0xeb7a,
+ 0xeb72, 0xeb76, 0xbfc7, 0xee72, 0xee71, 0xc1b7, 0xee77, 0xc1b9,
+ 0xc1b6, 0xee73, 0xc1ba, 0xee74, 0xee75, 0xee78, 0xc1b8, 0xf0d6,
+ 0xf0d9, 0xf0d3, 0xf0d5, 0xf0d4, 0xf0d7, 0xf0d8, 0xee76, 0xf0d2,
+ 0xc3cd, 0xf2ec, 0xf2ef, 0xf2f1, 0xf2ea, 0xf2eb, 0xf2ee, 0xf2f0,
+ 0xc3ce, 0xc3cc, 0xc3cb, 0xf2ed, 0xf2e9, 0xf4ca, 0xc4b0, 0xf4cb,
+ 0xf649, 0xc4fb, 0xf64b, 0xc4fc, 0xf648, 0xf64a, 0xc5a8, 0xf752,
+ 0xc5a7, 0xf7fd, 0xf7fc, 0xf7fb, 0xf948, 0xf949, 0xf94b, 0xf94a,
+ 0xca50, 0xa6e8, 0xad6e, 0xd7c5, 0xb5f7, 0xdffa, 0xc2d0, 0xf2f2,
+ 0xa8a3, 0xb357, 0xb356, 0xdbd0, 0xb5f8, 0xdbd2, 0xdbd1, 0xdffb,
+ 0xb8d0, 0xe443, 0xe446, 0xe445, 0xe444, 0xe7ce, 0xe7d0, 0xe7cf,
+ 0xbfcc, 0xbfcb, 0xc1bb, 0xee79, 0xee7b, 0xee7a, 0xc2d1, 0xf2f4,
+ 0xf2f3, 0xf4cc, 0xc4b1, 0xc4fd, 0xf754, 0xf753, 0xc65b, 0xa8a4,
+ 0xd0af, 0xad6f, 0xd7c8, 0xd7c6, 0xd7c7, 0xdbd4, 0xdbd5, 0xe043,
+ 0xdbd3, 0xdffc, 0xe041, 0xe040, 0xe042, 0xb8d1, 0xdffe, 0xdffd,
+ 0xe044, 0xe449, 0xe447, 0xe448, 0xe7d3, 0xe7d1, 0xe7d2, 0xeb7d,
+ 0xee7c, 0xee7d, 0xc2d2, 0xf2f5, 0xf4cd, 0xc4b2, 0xf64c, 0xf755,
+ 0xc5a9, 0xf7fe, 0xf94c, 0xa8a5, 0xad71, 0xad72, 0xd0b0, 0xd0b1,
+ 0xad70, 0xb054, 0xb052, 0xb051, 0xb058, 0xb050, 0xb059, 0xd3dd,
+ 0xb056, 0xb053, 0xb057, 0xb055, 0xb04f, 0xb35f, 0xb359, 0xd7cc,
+ 0xb35e, 0xb360, 0xb35a, 0xb35b, 0xd7ca, 0xb358, 0xd7cb, 0xb35d,
+ 0xd7c9, 0xb35c, 0xb644, 0xb646, 0xdbd8, 0xb645, 0xb5f9, 0xb5fd,
+ 0xb8e4, 0xe049, 0xdbda, 0xb5fe, 0xdbdd, 0xdbde, 0xb643, 0xdbe0,
+ 0xdbe2, 0xdbe3, 0xdbd7, 0xdbd6, 0xdbe4, 0xb642, 0xdbe1, 0xdbdf,
+ 0xb640, 0xb5fb, 0xb647, 0xdbdb, 0xdbdc, 0xdbd9, 0xb641, 0xb5fc,
+ 0xb5fa, 0xe048, 0xb8df, 0xb8da, 0xb8d5, 0xb8e5, 0xb8d6, 0xb8d2,
+ 0xb8e1, 0xb8de, 0xb8e0, 0xb8d7, 0xb8dc, 0xb8d3, 0xb8d4, 0xe050,
+ 0xe04d, 0xe045, 0xe04a, 0xb8e2, 0xe051, 0xb8e3, 0xb8d9, 0xe047,
+ 0xe04f, 0xe04b, 0xe04e, 0xe04c, 0xb8dd, 0xe046, 0xb8d8, 0xe44c,
+ 0xbb78, 0xbb7b, 0xe44e, 0xbba5, 0xe44d, 0xbb7d, 0xbdcf, 0xe44f,
+ 0xbba4, 0xe44b, 0xbba6, 0xbb79, 0xb8db, 0xbb7c, 0xbb7a, 0xbb7e,
+ 0xbba2, 0xbb77, 0xbba7, 0xbba3, 0xbba1, 0xe44a, 0xbdd6, 0xbdd2,
+ 0xbdd9, 0xe7d6, 0xbdda, 0xe7e2, 0xe7db, 0xbdcb, 0xe7e3, 0xe7dd,
+ 0xbdd5, 0xe7de, 0xbdd4, 0xe7e1, 0xbdce, 0xe7df, 0xe7d5, 0xbdcd,
+ 0xebaa, 0xbdd3, 0xbdd0, 0xbdd8, 0xe7d4, 0xe7d8, 0xbdcc, 0xe7d7,
+ 0xe7d9, 0xe7da, 0xbdd7, 0xe7dc, 0xe7e0, 0xe7e4, 0xbddb, 0xbfd2,
+ 0xeba5, 0xebab, 0xeba8, 0xeb7e, 0xebac, 0xeba1, 0xeba7, 0xbfcd,
+ 0xbfd3, 0xebad, 0xbfcf, 0xbfd9, 0xbfd4, 0xebaf, 0xeba9, 0xbfd0,
+ 0xeba2, 0xbfda, 0xeba3, 0xeba4, 0xbfdb, 0xbfd8, 0xbdd1, 0xbfce,
+ 0xebb0, 0xbfdc, 0xbfd5, 0xebae, 0xbfd1, 0xbfd6, 0xbfd7, 0xc1c3,
+ 0xeea4, 0xeead, 0xeeaa, 0xeeac, 0xc1c0, 0xeea5, 0xeeab, 0xc1bc,
+ 0xeea7, 0xc1c4, 0xeea3, 0xeea8, 0xeeaf, 0xeba6, 0xeea9, 0xeea2,
+ 0xc1bd, 0xeea1, 0xc1be, 0xeeb0, 0xc1bf, 0xeeae, 0xc1c2, 0xee7e,
+ 0xc1c1, 0xeea6, 0xf0dc, 0xf0ea, 0xf0e5, 0xf0e7, 0xf0db, 0xc2d3,
+ 0xf0da, 0xc2d6, 0xc2d5, 0xf0e9, 0xf0e1, 0xf0de, 0xf0e4, 0xf0dd,
+ 0xf0df, 0xf0e8, 0xf0e6, 0xc2d4, 0xf0ed, 0xf0eb, 0xf0e2, 0xf0ec,
+ 0xf0e3, 0xf2f9, 0xc3cf, 0xf341, 0xf64f, 0xc3d6, 0xf0e0, 0xf2f7,
+ 0xc3d2, 0xf2f8, 0xf2fd, 0xc3d4, 0xc3d5, 0xf2f6, 0xf340, 0xf342,
+ 0xf2fa, 0xf2fc, 0xf2fe, 0xf2fb, 0xf343, 0xc3d1, 0xc3d7, 0xc3d3,
+ 0xc3d0, 0xf4d0, 0xc4b7, 0xf4ce, 0xf4d2, 0xf4d3, 0xc4b5, 0xf4d4,
+ 0xf4d1, 0xf4cf, 0xc4b8, 0xc4b4, 0xf4d5, 0xc4b6, 0xc4b3, 0xc4fe,
+ 0xc540, 0xf64e, 0xf64d, 0xf650, 0xf651, 0xc541, 0xf756, 0xf75b,
+ 0xc5aa, 0xf758, 0xf757, 0xf75a, 0xf759, 0xf843, 0xc5dc, 0xf842,
+ 0xf840, 0xf841, 0xc5fe, 0xc5fd, 0xf8c1, 0xf8c2, 0xc640, 0xf94d,
+ 0xf94e, 0xc667, 0xc66d, 0xf9a9, 0xf9c8, 0xa8a6, 0xd7cd, 0xd7ce,
+ 0xe052, 0xe450, 0xe7e5, 0xc1c6, 0xc1c5, 0xf0ee, 0xf344, 0xf844,
+ 0xa8a7, 0xd3de, 0xb05a, 0xb361, 0xe054, 0xe053, 0xbddc, 0xe7e6,
+ 0xbddd, 0xeeb1, 0xc2d7, 0xc676, 0xa8a8, 0xcdcb, 0xd3df, 0xb362,
+ 0xd7cf, 0xd7d0, 0xdbe5, 0xb648, 0xb8e6, 0xe056, 0xe055, 0xe057,
+ 0xe451, 0xe452, 0xbba8, 0xbfdd, 0xbdde, 0xbfde, 0xeeb5, 0xeeb2,
+ 0xeeb4, 0xeeb3, 0xc1c7, 0xf0ef, 0xf346, 0xf345, 0xcba4, 0xb05c,
+ 0xb05b, 0xd3e0, 0xd7d1, 0xdbe7, 0xdbe6, 0xb649, 0xe059, 0xe05a,
+ 0xe058, 0xb8e8, 0xb8e7, 0xbbaa, 0xbba9, 0xe7e7, 0xebb3, 0xebb1,
+ 0xebb2, 0xbfdf, 0xeeb7, 0xeeb6, 0xf0f2, 0xf0f1, 0xf0f0, 0xf347,
+ 0xf9aa, 0xa8a9, 0xad73, 0xad74, 0xb05d, 0xb05e, 0xd3e2, 0xd3e1,
+ 0xd7d2, 0xb368, 0xb366, 0xb363, 0xb367, 0xb365, 0xb364, 0xb64a,
+ 0xdbea, 0xb8ed, 0xb64c, 0xb651, 0xdbec, 0xb653, 0xb652, 0xb655,
+ 0xdbeb, 0xdbe8, 0xb64f, 0xb64b, 0xb64d, 0xdbe9, 0xb654, 0xb650,
+ 0xb64e, 0xb8ef, 0xb8ee, 0xb8ec, 0xb8f0, 0xb8ea, 0xb8eb, 0xb8e9,
+ 0xe05b, 0xe454, 0xbbac, 0xbbad, 0xbbab, 0xe453, 0xe455, 0xe7ea,
+ 0xe7ec, 0xbde7, 0xe7ed, 0xbde0, 0xe7e9, 0xbddf, 0xbde9, 0xbde5,
+ 0xbde6, 0xbde2, 0xe7e8, 0xbde1, 0xe7ee, 0xe7eb, 0xbde8, 0xbde3,
+ 0xbde4, 0xebb5, 0xebb7, 0xebb6, 0xebb8, 0xbfe0, 0xebb4, 0xc1cb,
+ 0xeeb8, 0xc1c8, 0xc1cc, 0xc1ca, 0xc1c9, 0xf0f3, 0xf0f6, 0xf0f5,
+ 0xf0f4, 0xc2d8, 0xf348, 0xf349, 0xc3d8, 0xf34a, 0xc3d9, 0xc4ba,
+ 0xc4b9, 0xf652, 0xc542, 0xf653, 0xf75c, 0xc5ab, 0xc5ac, 0xf845,
+ 0xc642, 0xa8aa, 0xb36a, 0xb369, 0xe05c, 0xe05d, 0xbbae, 0xebb9,
+ 0xbdea, 0xebba, 0xeeb9, 0xa8ab, 0xd0b2, 0xad76, 0xad75, 0xd3e3,
+ 0xb05f, 0xd3e4, 0xd7d5, 0xd7d4, 0xd7d3, 0xdbee, 0xb658, 0xdbed,
+ 0xb657, 0xdbef, 0xb656, 0xe05f, 0xe062, 0xe060, 0xe061, 0xe065,
+ 0xe05e, 0xe066, 0xe063, 0xe064, 0xbbb0, 0xe456, 0xbbaf, 0xe7f2,
+ 0xe7f0, 0xbdeb, 0xe7ef, 0xe7f1, 0xbdec, 0xebbb, 0xebbc, 0xc1cd,
+ 0xf34c, 0xf34e, 0xf34b, 0xf34d, 0xf4d6, 0xf654, 0xf96f, 0xa8ac,
+ 0xad77, 0xd3e5, 0xd3e7, 0xd3e6, 0xd7d8, 0xb36c, 0xd7d6, 0xb36b,
+ 0xd7d9, 0xd7da, 0xd7d7, 0xdbfb, 0xb660, 0xdbf3, 0xdbf9, 0xb65b,
+ 0xb65e, 0xdbf2, 0xb659, 0xdbf6, 0xe06c, 0xb65d, 0xdbf1, 0xdbf7,
+ 0xdbf4, 0xdbfa, 0xdbf0, 0xdbf8, 0xb65c, 0xb65f, 0xdbf5, 0xb65a,
+ 0xb8f2, 0xe068, 0xb8f1, 0xe06f, 0xe06e, 0xb8f8, 0xb8f9, 0xe070,
+ 0xb8f3, 0xe06d, 0xb8f7, 0xe072, 0xe069, 0xe06b, 0xb8f4, 0xe067,
+ 0xe06a, 0xe071, 0xb8f5, 0xe073, 0xb8f6, 0xbbb1, 0xe45b, 0xe461,
+ 0xe459, 0xe462, 0xe458, 0xe45d, 0xe463, 0xe460, 0xe45f, 0xe45e,
+ 0xe457, 0xe45c, 0xe45a, 0xbdf1, 0xbdee, 0xe7fb, 0xe841, 0xe843,
+ 0xe840, 0xe7f8, 0xe7fa, 0xe845, 0xe842, 0xe7fc, 0xe846, 0xe7f9,
+ 0xe844, 0xbdef, 0xbdf5, 0xbdf3, 0xe7f3, 0xbdf4, 0xbdf0, 0xe7f4,
+ 0xe7f6, 0xe7f5, 0xe7fd, 0xe7fe, 0xbdf2, 0xbded, 0xe7f7, 0xebc6,
+ 0xbfe2, 0xebbd, 0xbfe3, 0xbfe6, 0xebc2, 0xebbf, 0xbfe5, 0xebc3,
+ 0xebc4, 0xebbe, 0xebc7, 0xebc0, 0xebc5, 0xbfe4, 0xbfe1, 0xebc1,
+ 0xeebf, 0xc1d0, 0xc1ce, 0xc1d1, 0xc1cf, 0xeebe, 0xeebb, 0xeeba,
+ 0xeebd, 0xeebc, 0xf145, 0xc2de, 0xf0fb, 0xf0fa, 0xc2d9, 0xf141,
+ 0xf140, 0xf0f7, 0xf143, 0xf0fc, 0xc2dd, 0xf0f9, 0xf142, 0xf0f8,
+ 0xc2da, 0xc2dc, 0xf0fd, 0xc2db, 0xf0fe, 0xf144, 0xf352, 0xc3de,
+ 0xf34f, 0xf353, 0xc3db, 0xf351, 0xc3e0, 0xc3dd, 0xf350, 0xc3df,
+ 0xf354, 0xc3da, 0xc4bc, 0xc4be, 0xf4d9, 0xc4bd, 0xf4d7, 0xc3dc,
+ 0xf4d8, 0xc4bb, 0xc543, 0xc545, 0xf656, 0xc544, 0xf655, 0xf761,
+ 0xc5ad, 0xf760, 0xc5ae, 0xf75e, 0xf75d, 0xf762, 0xf763, 0xf846,
+ 0xf75f, 0xf8c6, 0xf8c3, 0xf8c4, 0xf8c5, 0xc65c, 0xf951, 0xf950,
+ 0xf94f, 0xf970, 0xf9be, 0xf9ab, 0xc66e, 0xa8ad, 0xb060, 0xb8fa,
+ 0xbdf6, 0xebc8, 0xc2df, 0xf355, 0xf9ac, 0xa8ae, 0xaaee, 0xad79,
+ 0xad78, 0xb063, 0xd3e8, 0xb061, 0xd3e9, 0xb062, 0xd7df, 0xd7db,
+ 0xb36d, 0xd7de, 0xd7dd, 0xd7dc, 0xb36e, 0xd7e0, 0xd7e1, 0xdc43,
+ 0xdc41, 0xdc45, 0xdc46, 0xdc4c, 0xdc48, 0xdc4a, 0xdc42, 0xdbfc,
+ 0xdc49, 0xdc4b, 0xdc44, 0xdc47, 0xdbfd, 0xb662, 0xdc40, 0xdbfe,
+ 0xb661, 0xb663, 0xb8fd, 0xe075, 0xe077, 0xe076, 0xe07b, 0xb8fb,
+ 0xe078, 0xe074, 0xe079, 0xe07a, 0xb8fc, 0xb8fe, 0xe07c, 0xe467,
+ 0xe466, 0xe464, 0xe465, 0xbbb3, 0xbbb5, 0xbbb2, 0xbbb4, 0xe84d,
+ 0xe84e, 0xe849, 0xe84a, 0xbdf8, 0xbdfd, 0xbdf7, 0xbdfe, 0xbdf9,
+ 0xe84b, 0xe84c, 0xe848, 0xbe40, 0xbdfb, 0xbdfa, 0xbdfc, 0xe847,
+ 0xebca, 0xbfe8, 0xebcc, 0xbfea, 0xebcf, 0xebcb, 0xebc9, 0xebce,
+ 0xbfe9, 0xebcd, 0xbfe7, 0xc1d3, 0xc1d6, 0xeec1, 0xc1d4, 0xeec0,
+ 0xc1d2, 0xc1d5, 0xf146, 0xf147, 0xf148, 0xc2e0, 0xf149, 0xc2e1,
+ 0xc3e2, 0xf358, 0xf359, 0xf357, 0xf356, 0xf35a, 0xc3e1, 0xf4dd,
+ 0xf4db, 0xf4dc, 0xf4de, 0xf4da, 0xf4df, 0xf658, 0xf659, 0xf657,
+ 0xc546, 0xf764, 0xc5af, 0xf765, 0xf848, 0xf847, 0xa8af, 0xb664,
+ 0xb940, 0xbbb6, 0xbfec, 0xbfeb, 0xc3e3, 0xc47c, 0xc547, 0xa8b0,
+ 0xb064, 0xb941, 0xf35b, 0xcba6, 0xa8b1, 0xa8b4, 0xa8b3, 0xa8b2,
+ 0xcba5, 0xcdcd, 0xcdcf, 0xaaef, 0xaaf1, 0xcdcc, 0xcdce, 0xaaf0,
+ 0xcdd1, 0xcdd0, 0xcdd2, 0xd0b6, 0xd0b4, 0xad7c, 0xd0b3, 0xada3,
+ 0xad7e, 0xad7b, 0xada4, 0xad7d, 0xada2, 0xada1, 0xd0b5, 0xad7a,
+ 0xb06a, 0xd3eb, 0xd3f1, 0xb067, 0xb06e, 0xb069, 0xd3ee, 0xd3f0,
+ 0xb06c, 0xd3ea, 0xd3ed, 0xb068, 0xb065, 0xd3ec, 0xb06b, 0xd3ef,
+ 0xb06d, 0xb066, 0xd7e3, 0xd7e6, 0xb370, 0xb37a, 0xb376, 0xd7e4,
+ 0xb37e, 0xb377, 0xb37c, 0xb372, 0xb36f, 0xb371, 0xb37d, 0xd7e5,
+ 0xb375, 0xb378, 0xb374, 0xb379, 0xd7e7, 0xb37b, 0xb373, 0xd7e2,
+ 0xdc4d, 0xb665, 0xdc4f, 0xb667, 0xb669, 0xdc4e, 0xb666, 0xb66a,
+ 0xb668, 0xb947, 0xe0a3, 0xb94f, 0xe07e, 0xb950, 0xb945, 0xe0a1,
+ 0xb94a, 0xe0a2, 0xb943, 0xb942, 0xb94d, 0xb94c, 0xb94b, 0xb949,
+ 0xb94e, 0xe07d, 0xb944, 0xb946, 0xb948, 0xbbb8, 0xbbbb, 0xbbbf,
+ 0xbbb9, 0xbbbe, 0xbbbc, 0xbbb7, 0xbbbd, 0xbbba, 0xe852, 0xbe43,
+ 0xbe41, 0xe853, 0xbe44, 0xbe42, 0xe851, 0xe850, 0xbff0, 0xe84f,
+ 0xbfee, 0xbfed, 0xebd0, 0xbe45, 0xbfef, 0xebd1, 0xbff2, 0xebd2,
+ 0xbff1, 0xc1d8, 0xeec3, 0xc1d7, 0xc1dc, 0xc1da, 0xc1db, 0xc2e3,
+ 0xc1d9, 0xeec2, 0xebd3, 0xc2e2, 0xc2e4, 0xc3e4, 0xc3e5, 0xf4e0,
+ 0xc5de, 0xc5dd, 0xa8b6, 0xca55, 0xb06f, 0xca52, 0xca53, 0xca51,
+ 0xca54, 0xcbaa, 0xcba7, 0xcbac, 0xcba8, 0xa8b7, 0xa8ba, 0xcba9,
+ 0xa8b9, 0xcbab, 0xa8b8, 0xcdd5, 0xcdd7, 0xaaf4, 0xcdd3, 0xcdd6,
+ 0xcdd4, 0xaaf2, 0xaaf5, 0xaaf3, 0xd0b8, 0xd0bc, 0xd0b9, 0xada7,
+ 0xada8, 0xd0bb, 0xd0bd, 0xd0bf, 0xada5, 0xd0be, 0xada6, 0xd7ee,
+ 0xd0ba, 0xd3f2, 0xd3fb, 0xd3f9, 0xd3f4, 0xd3f5, 0xd3fa, 0xd3fc,
+ 0xb071, 0xd3f7, 0xd3f3, 0xb070, 0xb072, 0xd3f6, 0xd3fd, 0xd3f8,
+ 0xb3a1, 0xd7f1, 0xd7e9, 0xd7ef, 0xd7f0, 0xb3a2, 0xd7e8, 0xd7ea,
+ 0xd0b7, 0xd7ec, 0xd7ed, 0xd7eb, 0xb66c, 0xdc56, 0xebd4, 0xdc57,
+ 0xdc54, 0xb3a3, 0xb66e, 0xdc53, 0xdc59, 0xdc58, 0xb66b, 0xdc5c,
+ 0xdc52, 0xdc5b, 0xdc50, 0xdc5a, 0xdc55, 0xb66d, 0xe0aa, 0xe0a5,
+ 0xe0ab, 0xe0a6, 0xe0a4, 0xe0a7, 0xb951, 0xe0a9, 0xe0a8, 0xb952,
+ 0xbbc1, 0xbbc0, 0xe46e, 0xe471, 0xe469, 0xe46d, 0xbbc2, 0xe46c,
+ 0xe46a, 0xe470, 0xe46b, 0xe468, 0xe46f, 0xe859, 0xbe48, 0xf14a,
+ 0xe856, 0xe857, 0xe855, 0xdc51, 0xbe47, 0xe85a, 0xe854, 0xbe46,
+ 0xbe49, 0xe858, 0xebd5, 0xbff3, 0xebd6, 0xebd7, 0xeec4, 0xc1dd,
+ 0xf14b, 0xf14c, 0xf14d, 0xf35d, 0xf35c, 0xf4e2, 0xf4e1, 0xf65b,
+ 0xf65c, 0xf65a, 0xf766, 0xc5b0, 0xa8bb, 0xadaa, 0xada9, 0xb075,
+ 0xb074, 0xd440, 0xd441, 0xd3fe, 0xb073, 0xd7f5, 0xd7f6, 0xd7f2,
+ 0xb3a4, 0xd7f3, 0xd7f4, 0xdc5f, 0xdc61, 0xdc5d, 0xdc60, 0xb66f,
+ 0xdc5e, 0xb670, 0xdd73, 0xb955, 0xb954, 0xb953, 0xe0ac, 0xe0ad,
+ 0xe473, 0xe475, 0xbbc6, 0xbbc3, 0xbbc5, 0xbbc4, 0xe474, 0xe472,
+ 0xe861, 0xe85e, 0xe85f, 0xbe4d, 0xe860, 0xe85b, 0xe85c, 0xbe4a,
+ 0xbe4b, 0xe85d, 0xbe4c, 0xebdb, 0xebdc, 0xebd9, 0xebda, 0xbff4,
+ 0xebd8, 0xeec8, 0xeec5, 0xeec7, 0xc1e0, 0xeecb, 0xc1df, 0xeec9,
+ 0xeecc, 0xeeca, 0xeec6, 0xc1de, 0xf14f, 0xf150, 0xf14e, 0xf152,
+ 0xc2e5, 0xc2e6, 0xf35f, 0xc3e7, 0xf151, 0xf35e, 0xc3e6, 0xf4e5,
+ 0xf4e6, 0xc4bf, 0xf4e4, 0xf4e3, 0xf65d, 0xc548, 0xf849, 0xf8c8,
+ 0xf8c7, 0xc643, 0xc65d, 0xf8c9, 0xf971, 0xc66f, 0xa8bc, 0xaaf6,
+ 0xb956, 0xc4c0, 0xa8bd, 0xadab, 0xb3a5, 0xb671, 0xc2e7, 0xaaf7,
+ 0xd0c1, 0xd0c0, 0xd442, 0xb078, 0xb076, 0xb07a, 0xd444, 0xb079,
+ 0xb077, 0xd443, 0xb3a8, 0xd7fc, 0xb3a7, 0xb3a9, 0xd842, 0xb3ab,
+ 0xd7fe, 0xd840, 0xd7f7, 0xb3aa, 0xd843, 0xd7f9, 0xd7fa, 0xd7f8,
+ 0xb3a6, 0xd841, 0xd7fb, 0xd7fd, 0xdc6d, 0xdc6c, 0xdc6a, 0xdc62,
+ 0xdc71, 0xdc65, 0xdc6f, 0xdc76, 0xdc6e, 0xb679, 0xb675, 0xdc63,
+ 0xdc69, 0xb677, 0xdc68, 0xb678, 0xb67a, 0xdc6b, 0xb672, 0xb673,
+ 0xdc77, 0xdc75, 0xdc74, 0xdc66, 0xdc72, 0xb676, 0xb674, 0xdc73,
+ 0xdc64, 0xdc67, 0xdc70, 0xe4ba, 0xe0b7, 0xe0b0, 0xe0c3, 0xe0cc,
+ 0xe0b3, 0xb961, 0xe0c0, 0xb957, 0xb959, 0xb965, 0xe0b1, 0xb95a,
+ 0xb95c, 0xb966, 0xb95b, 0xb964, 0xe0b9, 0xe0ae, 0xb962, 0xe0b8,
+ 0xb95e, 0xe0ca, 0xb963, 0xe0c8, 0xe0bc, 0xe0c6, 0xb960, 0xe0af,
+ 0xe0c9, 0xe0c4, 0xe0cb, 0xb958, 0xb967, 0xb95d, 0xe0b5, 0xe0bd,
+ 0xe0c1, 0xe0c5, 0xb95f, 0xe0b4, 0xe0b2, 0xe0be, 0xe0bb, 0xe0ba,
+ 0xe0bf, 0xe0c2, 0xe0c7, 0xe478, 0xbbc7, 0xe4a4, 0xe47a, 0xbbcc,
+ 0xbbd0, 0xe4ad, 0xe4b5, 0xe4a6, 0xbbc8, 0xe4aa, 0xe0b6, 0xbbc9,
+ 0xe4b1, 0xe4b6, 0xe4ae, 0xe4b0, 0xe4b9, 0xe4b2, 0xe47e, 0xe4a9,
+ 0xbbd1, 0xbbcd, 0xe47c, 0xe4ab, 0xbbcb, 0xe4a5, 0xbbca, 0xe4b3,
+ 0xe4a2, 0xe479, 0xbbce, 0xe4b8, 0xe47b, 0xe4af, 0xe4ac, 0xe4a7,
+ 0xe477, 0xe476, 0xe4a1, 0xe4b4, 0xbbcf, 0xe4b7, 0xe47d, 0xe4a3,
+ 0xbe52, 0xbe5a, 0xbe55, 0xe8a4, 0xe8a1, 0xe867, 0xbe50, 0xbe4f,
+ 0xbe56, 0xe865, 0xbe54, 0xe871, 0xe863, 0xe864, 0xbe4e, 0xe8a3,
+ 0xbe58, 0xe874, 0xe879, 0xe873, 0xebee, 0xe86f, 0xe877, 0xe875,
+ 0xe868, 0xe862, 0xe87d, 0xbe57, 0xe87e, 0xe878, 0xe86d, 0xe86b,
+ 0xe866, 0xe86e, 0xe87b, 0xe86a, 0xe87a, 0xe8a2, 0xbe53, 0xe876,
+ 0xe87c, 0xe872, 0xe86c, 0xbe51, 0xe4a8, 0xe870, 0xbe59, 0xe869,
+ 0xebf4, 0xbff7, 0xebf3, 0xebf0, 0xec44, 0xbffb, 0xec41, 0xebf8,
+ 0xec43, 0xebe9, 0xebf6, 0xbffd, 0xebe1, 0xebdf, 0xec42, 0xec40,
+ 0xebfe, 0xebed, 0xebec, 0xebe2, 0xc040, 0xebe8, 0xebf2, 0xebfd,
+ 0xc043, 0xec45, 0xc1e8, 0xc045, 0xbffe, 0xebe6, 0xebef, 0xebde,
+ 0xebe0, 0xbff5, 0xc042, 0xbffa, 0xebe7, 0xebf7, 0xebf1, 0xc041,
+ 0xebdd, 0xc1e3, 0xebf9, 0xebfc, 0xbffc, 0xebeb, 0xc044, 0xbff9,
+ 0xbff8, 0xebf5, 0xebfb, 0xbff6, 0xebe4, 0xebfa, 0xebe5, 0xebea,
+ 0xeed2, 0xeed7, 0xc1e5, 0xc1e7, 0xeedd, 0xc1e1, 0xeeec, 0xeee3,
+ 0xeed8, 0xeed9, 0xeee2, 0xc1ee, 0xeee1, 0xeed1, 0xeee0, 0xeed4,
+ 0xeeed, 0xc1ed, 0xc1eb, 0xeed5, 0xeee8, 0xeeda, 0xeee7, 0xeee9,
+ 0xeed0, 0xc1e6, 0xeeea, 0xeede, 0xc1ea, 0xeedb, 0xc1ec, 0xeee4,
+ 0xc1e4, 0xeed6, 0xeee5, 0xeedf, 0xebe3, 0xeee6, 0xeed3, 0xc1e9,
+ 0xeeeb, 0xc1e2, 0xeece, 0xf160, 0xf159, 0xc2e9, 0xf154, 0xf163,
+ 0xf15b, 0xeedc, 0xf165, 0xf155, 0xc2e8, 0xf15f, 0xc2ea, 0xc2f2,
+ 0xc2f0, 0xf161, 0xc2f1, 0xf157, 0xf158, 0xf15d, 0xf162, 0xeecd,
+ 0xc2eb, 0xf16a, 0xf167, 0xf16b, 0xf15e, 0xf15a, 0xf168, 0xf36a,
+ 0xf15c, 0xc2ee, 0xc2ed, 0xeecf, 0xc2ef, 0xf164, 0xf166, 0xc2ec,
+ 0xf169, 0xf153, 0xf156, 0xf373, 0xf363, 0xc3eb, 0xf371, 0xf361,
+ 0xc3ec, 0xf36c, 0xf368, 0xc3f1, 0xf372, 0xf362, 0xf365, 0xc3e9,
+ 0xf374, 0xf36d, 0xf370, 0xc3ef, 0xc3f4, 0xc3f2, 0xf369, 0xf364,
+ 0xc3ed, 0xc3ee, 0xf360, 0xc3ea, 0xc3e8, 0xc3f0, 0xf36f, 0xc3f3,
+ 0xf36b, 0xf375, 0xc3f5, 0xf367, 0xf36e, 0xf4f3, 0xf542, 0xf4f5,
+ 0xf4fc, 0xf366, 0xf4fa, 0xf4e9, 0xf540, 0xc4c3, 0xf4ed, 0xf4fe,
+ 0xf4f4, 0xc4c2, 0xf544, 0xf4f6, 0xf4fb, 0xf4fd, 0xf4e7, 0xf541,
+ 0xf4f2, 0xf4f7, 0xf4eb, 0xf4ef, 0xf543, 0xf4f9, 0xf4e8, 0xf4ec,
+ 0xf4ee, 0xf4f8, 0xc4c1, 0xf4f1, 0xf4ea, 0xf4f0, 0xf661, 0xf666,
+ 0xc54f, 0xf668, 0xc549, 0xf664, 0xf66a, 0xc54e, 0xc54a, 0xc54b,
+ 0xf660, 0xf667, 0xc54d, 0xf665, 0xc54c, 0xf65f, 0xf663, 0xf662,
+ 0xf65e, 0xf669, 0xc5b1, 0xf76d, 0xf770, 0xf76c, 0xf76e, 0xf76f,
+ 0xf769, 0xf76a, 0xf767, 0xf76b, 0xf768, 0xc5b2, 0xc5b3, 0xf84b,
+ 0xf84d, 0xf84c, 0xf84e, 0xc5e0, 0xf84a, 0xc5df, 0xc5e1, 0xf8cb,
+ 0xf8cc, 0xc644, 0xf8ca, 0xf953, 0xf952, 0xf954, 0xc65f, 0xf955,
+ 0xc65e, 0xf956, 0xf972, 0xf975, 0xf974, 0xc668, 0xf973, 0xc672,
+ 0xc670, 0xc671, 0xc677, 0xf9c0, 0xf9c1, 0xf9bf, 0xf9c9, 0xaaf8,
+ 0xd844, 0xdc78, 0xe8a5, 0xf376, 0xaaf9, 0xadac, 0xb07b, 0xd845,
+ 0xd846, 0xb3ac, 0xb67d, 0xdc7a, 0xdc79, 0xb6a3, 0xb67c, 0xdc7b,
+ 0xb67e, 0xb6a2, 0xb6a1, 0xb67b, 0xb968, 0xe0d0, 0xe0ce, 0xe0cf,
+ 0xe0cd, 0xbbd2, 0xbbd5, 0xbbd7, 0xbbd6, 0xbbd3, 0xbbd4, 0xe8a7,
+ 0xe8a6, 0xbe5b, 0xe8a8, 0xe8a9, 0xbe5c, 0xec4d, 0xec4b, 0xeef3,
+ 0xec49, 0xec4a, 0xc046, 0xec46, 0xec4e, 0xec48, 0xec4c, 0xeeef,
+ 0xeef1, 0xeef2, 0xc1f3, 0xeeee, 0xc1f2, 0xeef0, 0xc1ef, 0xc1f0,
+ 0xc1f1, 0xec47, 0xc2f5, 0xf16e, 0xf16c, 0xf16d, 0xc2f3, 0xc2f6,
+ 0xc2f4, 0xf377, 0xf378, 0xc3f6, 0xf545, 0xf547, 0xf546, 0xc4c4,
+ 0xc550, 0xf66d, 0xf66c, 0xf66b, 0xaafa, 0xc9aa, 0xca58, 0xa6e9,
+ 0xca56, 0xca59, 0xca57, 0xcbae, 0xa8c1, 0xa8c2, 0xcbb0, 0xa8bf,
+ 0xcbaf, 0xcbad, 0xa8c0, 0xa8be, 0xcdd8, 0xcddb, 0xaafd, 0xcdda,
+ 0xcdd9, 0xaafc, 0xaafb, 0xab40, 0xcddc, 0xaafe, 0xd0c6, 0xadae,
+ 0xadaf, 0xadb0, 0xd0c7, 0xd0c3, 0xadad, 0xd0c4, 0xd0c5, 0xd0c2,
+ 0xb0a4, 0xb0a1, 0xd445, 0xb0a2, 0xb0a5, 0xd446, 0xb07e, 0xb07c,
+ 0xb07d, 0xb0a3, 0xb3ad, 0xd849, 0xb3b5, 0xd848, 0xd84b, 0xb3b1,
+ 0xd84a, 0xb6ab, 0xb3af, 0xb3b2, 0xb3ae, 0xb3b3, 0xb3b4, 0xb3b0,
+ 0xd847, 0xb6a7, 0xdc7d, 0xdca3, 0xdca2, 0xb6ac, 0xb6a8, 0xb6a9,
+ 0xdc7c, 0xdc7e, 0xdca1, 0xb6a4, 0xb6a6, 0xb6aa, 0xb6a5, 0xe0d3,
+ 0xe0d1, 0xe0d2, 0xb96a, 0xb96b, 0xe0d4, 0xb969, 0xbbd8, 0xbbda,
+ 0xbbd9, 0xe4bb, 0xe4bc, 0xe8ab, 0xe8aa, 0xc047, 0xc048, 0xec4f,
+ 0xc049, 0xeef6, 0xeef4, 0xeef5, 0xc1f4, 0xf16f, 0xc3f7, 0xc1f5,
+ 0xab41, 0xb0a6, 0xd447, 0xd84c, 0xb3b6, 0xb6ad, 0xdca4, 0xdca6,
+ 0xb6af, 0xb6ae, 0xb6b0, 0xb6b1, 0xdca5, 0xb96e, 0xb96f, 0xb96d,
+ 0xbbdb, 0xb96c, 0xe0d5, 0xbbdc, 0xe8ac, 0xec50, 0xc04a, 0xc1f6,
+ 0xf170, 0xf174, 0xc2f9, 0xf171, 0xc2fa, 0xc2f8, 0xf175, 0xc2fb,
+ 0xf173, 0xf379, 0xc2f7, 0xc3f8, 0xf8cd, 0xab42, 0xb3b8, 0xb3b7,
+ 0xb6b2, 0xdca8, 0xdca7, 0xb6b3, 0xe0d9, 0xb973, 0xb970, 0xe0d8,
+ 0xb972, 0xe0d6, 0xb971, 0xe0d7, 0xe4bd, 0xbbdd, 0xe8af, 0xbe5d,
+ 0xe8ad, 0xbe5e, 0xbe5f, 0xe8ae, 0xbe60, 0xec51, 0xc04e, 0xc04b,
+ 0xc050, 0xec53, 0xc04c, 0xec52, 0xc04f, 0xc04d, 0xeef9, 0xeefb,
+ 0xc1f7, 0xeefa, 0xc1f8, 0xeef8, 0xeef7, 0xf177, 0xf176, 0xc2fc,
+ 0xf178, 0xf37e, 0xc3fa, 0xf37d, 0xf37a, 0xc3f9, 0xf37b, 0xf37c,
+ 0xf548, 0xf549, 0xc4c5, 0xc553, 0xf66e, 0xc551, 0xc552, 0xf66f,
+ 0xc5b4, 0xc5b5, 0xf771, 0xc645, 0xf8cf, 0xc647, 0xf8ce, 0xf8d0,
+ 0xc646, 0xf957, 0xf9ad, 0xab43, 0xb974, 0xe4be, 0xe8b0, 0xc051,
+ 0xc052, 0xab44, 0xbe61, 0xc3fb, 0xadb1, 0xc053, 0xc5e2, 0xadb2,
+ 0xd84d, 0xdca9, 0xdcab, 0xdcaa, 0xe0dd, 0xe0da, 0xb975, 0xb976,
+ 0xe0db, 0xe0dc, 0xe4c0, 0xe4c5, 0xbbde, 0xe4bf, 0xe4c1, 0xe4c8,
+ 0xe4c3, 0xe4c7, 0xe4c4, 0xe4c2, 0xe4c6, 0xbbdf, 0xe8b3, 0xe8b1,
+ 0xbe63, 0xbe62, 0xe8b2, 0xbe64, 0xec56, 0xec55, 0xc054, 0xec54,
+ 0xeefc, 0xeefe, 0xef41, 0xef40, 0xc1f9, 0xeefd, 0xf1a1, 0xc2fd,
+ 0xf17d, 0xf1a2, 0xc2fe, 0xf17b, 0xf17e, 0xf17c, 0xf179, 0xc340,
+ 0xf17a, 0xf3a1, 0xf3a3, 0xf3a2, 0xf54a, 0xf54b, 0xf670, 0xc5b7,
+ 0xc5b6, 0xf84f, 0xf850, 0xc648, 0xf8d1, 0xc669, 0xadb3, 0xb6b4,
+ 0xe4ca, 0xe4c9, 0xe8b5, 0xe8b4, 0xc1fa, 0xef43, 0xef42, 0xf1a5,
+ 0xf1a3, 0xf1a6, 0xf1a4, 0xc3fc, 0xf3a4, 0xf3a5, 0xf3a6, 0xf671,
+ 0xf772, 0xf8d2, 0xadb4, 0xec57, 0xef44, 0xadb5, 0xbbe0, 0xec58,
+ 0xc341, 0xf1a7, 0xc3fd, 0xf54c, 0xf54d, 0xc554, 0xf851, 0xadb6,
+ 0xb3bb, 0xb3bc, 0xd84e, 0xb6b5, 0xb6b6, 0xdcac, 0xb6b7, 0xb97a,
+ 0xb97c, 0xe0df, 0xe0e0, 0xe0de, 0xb977, 0xb978, 0xb97b, 0xb979,
+ 0xe4cb, 0xbbe1, 0xbbe2, 0xe8bc, 0xbe67, 0xe8b7, 0xe8b6, 0xe8bb,
+ 0xbe65, 0xc05b, 0xe8b8, 0xe8bd, 0xe8ba, 0xe8b9, 0xbe66, 0xc059,
+ 0xec5a, 0xc055, 0xec5b, 0xec59, 0xc058, 0xc056, 0xc05a, 0xc057,
+ 0xef45, 0xef4a, 0xef46, 0xef49, 0xc1fb, 0xedd4, 0xef48, 0xef47,
+ 0xc344, 0xc342, 0xc345, 0xc343, 0xf1a8, 0xf1a9, 0xf1aa, 0xc346,
+ 0xf3aa, 0xc440, 0xf3a8, 0xc441, 0xf3a7, 0xf3a9, 0xc3fe, 0xf551,
+ 0xf54e, 0xf54f, 0xf550, 0xf672, 0xc556, 0xc555, 0xf774, 0xf773,
+ 0xc5b8, 0xc5e3, 0xc649, 0xc660, 0xf958, 0xf9ae, 0xf9af, 0xadb7,
+ 0xdcad, 0xe0e1, 0xe4cc, 0xe4cd, 0xbbe3, 0xbbe4, 0xe8be, 0xbe68,
+ 0xc1fc, 0xf1ab, 0xc347, 0xf3ad, 0xc442, 0xf3ac, 0xf3ae, 0xf3ab,
+ 0xf675, 0xf552, 0xf553, 0xc4c6, 0xf674, 0xf673, 0xf775, 0xf9b0,
+ 0xadb8, 0xadb9, 0xb0a7, 0xd448, 0xd84f, 0xb6b8, 0xb6bb, 0xb6b9,
+ 0xdcae, 0xb6bd, 0xb6ba, 0xb6bc, 0xb97e, 0xe0e2, 0xe0e3, 0xe8c0,
+ 0xb97d, 0xb9a1, 0xb9a2, 0xe4cf, 0xe4ce, 0xbbe5, 0xbbe6, 0xe4d0,
+ 0xe8bf, 0xbbe8, 0xbe69, 0xbbe7, 0xc05c, 0xe8c1, 0xbe6b, 0xbe6a,
+ 0xe8c2, 0xe8c5, 0xe8c3, 0xe8c4, 0xbe6c, 0xc061, 0xc05f, 0xc05e,
+ 0xec5d, 0xc060, 0xec5c, 0xef4b, 0xec5e, 0xc05d, 0xec5f, 0xef4e,
+ 0xef4c, 0xef4d, 0xef52, 0xc34b, 0xef51, 0xef54, 0xef53, 0xef50,
+ 0xef4f, 0xc1fd, 0xf1ae, 0xf1ad, 0xc34a, 0xc348, 0xc349, 0xf1ac,
+ 0xf3b1, 0xc443, 0xf3b0, 0xf3af, 0xc444, 0xf558, 0xf557, 0xf555,
+ 0xf554, 0xc4c8, 0xc4c7, 0xf559, 0xf776, 0xc5b9, 0xf677, 0xc557,
+ 0xf676, 0xf556, 0xf777, 0xc5e4, 0xc661, 0xf959, 0xf9b1, 0xadba,
+ 0xd850, 0xef55, 0xadbb, 0xe4d2, 0xe4d1, 0xec60, 0xef57, 0xef56,
+ 0xc34c, 0xf3b2, 0xf3b3, 0xc4c9, 0xf9b2, 0xb0a8, 0xb6bf, 0xb6be,
+ 0xe0e4, 0xe0e6, 0xb9a4, 0xe0e5, 0xb9a3, 0xb9a5, 0xe0e7, 0xe4d4,
+ 0xe4d6, 0xe4d5, 0xe4d8, 0xbbe9, 0xe4d7, 0xe4d3, 0xe4d9, 0xe8cc,
+ 0xe8cf, 0xe8d1, 0xe8c7, 0xe8cb, 0xe8c8, 0xbe6e, 0xbe71, 0xbe73,
+ 0xe8c9, 0xe8ca, 0xbe72, 0xe8cd, 0xe8d0, 0xe8ce, 0xbe74, 0xbe70,
+ 0xe8c6, 0xbe6d, 0xbe6f, 0xc063, 0xec66, 0xec64, 0xec63, 0xec69,
+ 0xec68, 0xec67, 0xec62, 0xc062, 0xec61, 0xec65, 0xc064, 0xef5a,
+ 0xef5e, 0xef5b, 0xef5d, 0xef5c, 0xef59, 0xef5f, 0xef62, 0xef60,
+ 0xef61, 0xc240, 0xc1fe, 0xef58, 0xef63, 0xf1b3, 0xf1b6, 0xf1b8,
+ 0xf1b7, 0xf1b1, 0xf1b5, 0xf1b0, 0xf1b2, 0xc34d, 0xf1af, 0xf1b4,
+ 0xf3c0, 0xf3b5, 0xc445, 0xc446, 0xf3b4, 0xf3b9, 0xf3bf, 0xf3b7,
+ 0xf3be, 0xf3bb, 0xf3ba, 0xf3bd, 0xf3b8, 0xf3b6, 0xf3bc, 0xf560,
+ 0xf55e, 0xc4ca, 0xf55d, 0xf563, 0xf561, 0xc4cb, 0xf55c, 0xf55a,
+ 0xf55b, 0xc4cd, 0xf55f, 0xc4cc, 0xf562, 0xf678, 0xf67e, 0xf679,
+ 0xc55b, 0xf6a1, 0xc55a, 0xf67d, 0xf67c, 0xc559, 0xf67b, 0xc558,
+ 0xf67a, 0xf77d, 0xf7a1, 0xf77e, 0xf77b, 0xc5bb, 0xf778, 0xf77c,
+ 0xf7a3, 0xf7a2, 0xf779, 0xf77a, 0xc5ba, 0xf852, 0xc5e7, 0xf853,
+ 0xc5e5, 0xc5e6, 0xf8d3, 0xc64a, 0xf976, 0xc66a, 0xf9b3, 0xc66b,
+ 0xf9b4, 0xf9b5, 0xf9c3, 0xf9c2, 0xc67a, 0xf9cd, 0xb0a9, 0xe0e9,
+ 0xe0e8, 0xbbea, 0xbbeb, 0xe4da, 0xe8d2, 0xec6c, 0xbe75, 0xc065,
+ 0xec6a, 0xec6d, 0xc066, 0xef64, 0xec6b, 0xf1b9, 0xc34e, 0xf3c1,
+ 0xf566, 0xf564, 0xf565, 0xf6a2, 0xc55c, 0xf7a4, 0xc5ea, 0xc5bc,
+ 0xc5e8, 0xc5e9, 0xf8d4, 0xc662, 0xb0aa, 0xf1ba, 0xd449, 0xb9a6,
+ 0xe4db, 0xbbec, 0xe4dc, 0xe8d4, 0xe8d3, 0xc068, 0xbe76, 0xbe77,
+ 0xe8d7, 0xe8d6, 0xe8d5, 0xec6e, 0xec71, 0xec70, 0xec6f, 0xc067,
+ 0xef68, 0xef66, 0xef65, 0xef67, 0xc34f, 0xf1bc, 0xf1bd, 0xc350,
+ 0xf1bb, 0xf3c3, 0xf3c2, 0xf3c5, 0xc447, 0xf3c4, 0xf567, 0xf569,
+ 0xf568, 0xf6a3, 0xf6a6, 0xf6a4, 0xf6a5, 0xf7a5, 0xc5bd, 0xf854,
+ 0xf855, 0xf856, 0xc64b, 0xc663, 0xf9b6, 0xb0ab, 0xbe78, 0xc069,
+ 0xf1be, 0xf7a6, 0xf9c4, 0xd44a, 0xc67b, 0xb0ac, 0xec72, 0xf1bf,
+ 0xf3c6, 0xf6a7, 0xf7a7, 0xb0ad, 0xe4dd, 0xe4de, 0xbbed, 0xbbee,
+ 0xe8d9, 0xbe7a, 0xbe79, 0xe8d8, 0xef69, 0xf1c0, 0xf1c2, 0xf1c1,
+ 0xc353, 0xc352, 0xc351, 0xc55e, 0xf6a8, 0xc55d, 0xf7a9, 0xf7a8,
+ 0xc64c, 0xf8d5, 0xb3bd, 0xe0ea, 0xe4e1, 0xe4df, 0xe4e0, 0xe8e2,
+ 0xe8dd, 0xe8da, 0xe8e1, 0xe8e3, 0xbe7c, 0xe8e0, 0xe8dc, 0xe8db,
+ 0xe8df, 0xe8de, 0xbe7b, 0xec7d, 0xec78, 0xec76, 0xeca1, 0xec77,
+ 0xec73, 0xec79, 0xec74, 0xef72, 0xec75, 0xeca2, 0xec7c, 0xc06a,
+ 0xec7b, 0xec7a, 0xec7e, 0xef6a, 0xef6d, 0xef6c, 0xef74, 0xef6f,
+ 0xef73, 0xef71, 0xef70, 0xef6e, 0xef6b, 0xc243, 0xc242, 0xc244,
+ 0xc241, 0xef75, 0xf1c8, 0xf1cb, 0xf1c9, 0xf1cd, 0xf1ce, 0xf1c6,
+ 0xc358, 0xf1c7, 0xf1c5, 0xf1cc, 0xf1c4, 0xf1c3, 0xc357, 0xc355,
+ 0xc354, 0xf1ca, 0xf3cf, 0xf3d5, 0xc44a, 0xf3d0, 0xf3d3, 0xf3d7,
+ 0xc44b, 0xf3d2, 0xf3ca, 0xf3c9, 0xf3d6, 0xf3cd, 0xf3cb, 0xf3d4,
+ 0xf3cc, 0xc449, 0xc448, 0xf3c7, 0xf3c8, 0xf3d1, 0xf3ce, 0xf56c,
+ 0xf56f, 0xc356, 0xf56d, 0xf573, 0xf571, 0xf56b, 0xf576, 0xf56a,
+ 0xc4cf, 0xf572, 0xf56e, 0xc4ce, 0xf575, 0xf574, 0xf6ab, 0xf6aa,
+ 0xf6b1, 0xf6ad, 0xf6b0, 0xc560, 0xf6ae, 0xf6af, 0xf6a9, 0xf6ac,
+ 0xc55f, 0xc5bf, 0xf7b4, 0xf7af, 0xf7b3, 0xf7b6, 0xf7b2, 0xf7ae,
+ 0xc5c1, 0xf7b1, 0xf7b5, 0xc5c0, 0xf7ac, 0xf570, 0xf7b0, 0xf7ad,
+ 0xf7aa, 0xf7ab, 0xc5be, 0xf85a, 0xf85c, 0xf85f, 0xf85b, 0xf860,
+ 0xf859, 0xf857, 0xc5eb, 0xf85d, 0xc5ed, 0xc5ec, 0xf858, 0xf85e,
+ 0xf8da, 0xc64d, 0xf8db, 0xf8d9, 0xf8d6, 0xf8d8, 0xf8d7, 0xf95a,
+ 0xf95c, 0xf95b, 0xf979, 0xf978, 0xf977, 0xf97a, 0xc673, 0xc674,
+ 0xf9ca, 0xf9ce, 0xb3be, 0xdcaf, 0xe0ed, 0xb9a7, 0xe0eb, 0xe0ec,
+ 0xe4e2, 0xe4e3, 0xbbf1, 0xbbef, 0xe4e4, 0xbbf0, 0xe8e8, 0xe8eb,
+ 0xe8e5, 0xe8ec, 0xe8e4, 0xe8e6, 0xe8e7, 0xe8ea, 0xbea1, 0xe8ef,
+ 0xe8ee, 0xbe7d, 0xe8e9, 0xe8ed, 0xbe7e, 0xecac, 0xc06f, 0xeca7,
+ 0xc06b, 0xeca4, 0xecaa, 0xecad, 0xc070, 0xeca9, 0xeca6, 0xecae,
+ 0xeca5, 0xecab, 0xc06c, 0xeca3, 0xc06d, 0xc06e, 0xeca8, 0xefa9,
+ 0xef7a, 0xef7b, 0xef7e, 0xef7c, 0xef76, 0xef79, 0xefa5, 0xef7d,
+ 0xc245, 0xefa7, 0xefa4, 0xc246, 0xefa6, 0xef77, 0xefa2, 0xefa3,
+ 0xefa1, 0xf1d2, 0xf1d4, 0xf1d7, 0xf1d1, 0xc359, 0xf1d9, 0xf1d0,
+ 0xf1da, 0xf1d6, 0xf1d8, 0xf1dc, 0xf1d5, 0xf1dd, 0xf1d3, 0xf1cf,
+ 0xc35a, 0xf1db, 0xc35b, 0xc44d, 0xef78, 0xf3f1, 0xf3e8, 0xc44f,
+ 0xf3e4, 0xc450, 0xf3ed, 0xf3e7, 0xf3dd, 0xc44e, 0xf3ea, 0xf3e5,
+ 0xf3e6, 0xf3d8, 0xf3df, 0xf3ee, 0xf3eb, 0xf3e3, 0xf3ef, 0xf3de,
+ 0xf3d9, 0xf3ec, 0xf3db, 0xf3e9, 0xf3e0, 0xf3f0, 0xf3dc, 0xc44c,
+ 0xf3da, 0xf3e1, 0xf3e2, 0xf57d, 0xf57b, 0xf5a2, 0xf5ae, 0xf5a5,
+ 0xf57c, 0xf578, 0xf5a7, 0xf57e, 0xf5a3, 0xf57a, 0xf5aa, 0xf577,
+ 0xf5a1, 0xf5a6, 0xf5a8, 0xf5ab, 0xf579, 0xf5af, 0xf5b0, 0xf5a9,
+ 0xf5ad, 0xf5a4, 0xf6c1, 0xf6c4, 0xc561, 0xf6c3, 0xf6c8, 0xf6c6,
+ 0xc562, 0xf6bd, 0xf6b3, 0xf6b2, 0xc564, 0xf6bf, 0xf6c0, 0xf6bc,
+ 0xf6b4, 0xf6b9, 0xf5ac, 0xf6b5, 0xc563, 0xf6bb, 0xf6ba, 0xf6b6,
+ 0xf6c2, 0xf6b7, 0xf7bb, 0xf6c5, 0xf6c7, 0xf6be, 0xf6b8, 0xf7bc,
+ 0xf7be, 0xf7b8, 0xc5c2, 0xf7c5, 0xf7c3, 0xc5c3, 0xf7c2, 0xf7c1,
+ 0xf7ba, 0xf7b7, 0xf7bd, 0xf7c6, 0xf7b9, 0xf7bf, 0xf869, 0xf86e,
+ 0xf864, 0xf867, 0xc5ee, 0xf86b, 0xf872, 0xf7c0, 0xf865, 0xf86f,
+ 0xf873, 0xf86a, 0xf863, 0xf86d, 0xf86c, 0xf871, 0xf870, 0xf7c4,
+ 0xf868, 0xf862, 0xf866, 0xc64e, 0xc64f, 0xf861, 0xf8e6, 0xf8dd,
+ 0xf8e5, 0xf8e2, 0xf8e3, 0xf8dc, 0xf8df, 0xf8e7, 0xf8e1, 0xf8e0,
+ 0xf8de, 0xf8e4, 0xf95d, 0xf95e, 0xf960, 0xf95f, 0xf962, 0xf961,
+ 0xf97c, 0xf97b, 0xf9b7, 0xf9b8, 0xf9c5, 0xc678, 0xc67c, 0xf9cf,
+ 0xc67d, 0xb3bf, 0xc4d0, 0xf6c9, 0xc650, 0xc651, 0xb3c0, 0xe0ee,
+ 0xb9a8, 0xe8f0, 0xecb0, 0xecb1, 0xecaf, 0xefab, 0xefaa, 0xc247,
+ 0xf1df, 0xefac, 0xf1de, 0xf3f3, 0xc451, 0xc453, 0xf3f2, 0xc452,
+ 0xf5b1, 0xf5b3, 0xf5b2, 0xf6ca, 0xc565, 0xc5ef, 0xf8e8, 0xf963,
+ 0xf9d2, 0xb3c1, 0xe4e5, 0xbea2, 0xecb3, 0xecb2, 0xefad, 0xc454,
+ 0xc4d1, 0xf7c7, 0xf9cb, 0xb3c2, 0xbbf2, 0xbea3, 0xf3f4, 0xf874,
+ 0xb6c0, 0xefae, 0xc664, 0xb6c1, 0xbea4, 0xc248, 0xf875, 0xb6c2,
+ 0xe8f1, 0xc072, 0xecb4, 0xecb5, 0xc071, 0xefaf, 0xc24c, 0xc24a,
+ 0xc24b, 0xc249, 0xf1e0, 0xc35c, 0xf5b5, 0xf5b4, 0xf5b7, 0xf5b6,
+ 0xc4d2, 0xf6cb, 0xf6cd, 0xf6cc, 0xc566, 0xf7c8, 0xf876, 0xf877,
+ 0xc5f0, 0xf964, 0xf97d, 0xc675, 0xdcb0, 0xecb6, 0xefb0, 0xf3f5,
+ 0xe0ef, 0xefb1, 0xf1e2, 0xf1e1, 0xf878, 0xc652, 0xf965, 0xf97e,
+ 0xb9a9, 0xe8f2, 0xe8f3, 0xecb7, 0xb9aa, 0xc35d, 0xf1e3, 0xf6cf,
+ 0xc567, 0xf6d0, 0xf6ce, 0xf879, 0xf8e9, 0xb9ab, 0xefb4, 0xefb3,
+ 0xefb2, 0xf1e4, 0xf1e8, 0xf1e7, 0xf1e6, 0xf1e5, 0xc35e, 0xf3f6,
+ 0xf5b9, 0xc4d3, 0xf5b8, 0xf6d1, 0xf7cb, 0xf7ca, 0xc5c4, 0xf7c9,
+ 0xf87c, 0xf87b, 0xf87a, 0xbbf3, 0xecb8, 0xc24d, 0xf3f7, 0xf3f8,
+ 0xf7cc, 0xf87d, 0xf8ea, 0xf966, 0xf9b9, 0xf9d4, 0xbbf4, 0xc24e,
+ 0xf1e9, 0xf3f9, 0xf6d2, 0xf87e, 0xbea6, 0xefb5, 0xf1ea, 0xf3fa,
+ 0xf3fb, 0xf3fc, 0xf5be, 0xf5ba, 0xc568, 0xf5bd, 0xf5bc, 0xc4d4,
+ 0xf5bb, 0xc4d6, 0xc4d5, 0xf6d4, 0xf6d3, 0xc569, 0xc56a, 0xc5c6,
+ 0xf7cd, 0xc5c5, 0xf8a3, 0xf8a4, 0xf8a2, 0xf8a1, 0xc654, 0xf8eb,
+ 0xf8ec, 0xf8ed, 0xc653, 0xf967, 0xf96a, 0xf969, 0xf968, 0xf9d3,
+ 0xc073, 0xc365, 0xf5bf, 0xf6d5, 0xc5c7, 0xf7ce, 0xf9d5, 0xc074,
+ 0xefb6, 0xf7cf, 0xf9a1, 0xc94a, 0xddfc, 0xa14a, 0xa157, 0xa159,
+ 0xa15b, 0xa15f, 0xa160, 0xa163, 0xa164, 0xa167, 0xa168, 0xa16b,
+ 0xa16c, 0xa16f, 0xa170, 0xa173, 0xa174, 0xa177, 0xa178, 0xa17b,
+ 0xa17c, 0xa1c6, 0xa1c7, 0xa1ca, 0xa1cb, 0xa1c8, 0xa1c9, 0xa15c,
+ 0xa14d, 0xa14f, 0xa151, 0xa152, 0xa153, 0xa154, 0xa17d, 0xa17e,
+ 0xa1a1, 0xa1a2, 0xa1a3, 0xa1a4, 0xa1cc, 0xa1cd, 0xa1ce, 0xa1de,
+ 0xa1df, 0xa1e0, 0xa1e1, 0xa1e2, 0xa24c, 0xa24d, 0xa24e, 0xa149,
+ 0xa1ad, 0xa243, 0xa248, 0xa1ae, 0xa15d, 0xa15e, 0xa1af, 0xa1cf,
+ 0xa141, 0xa1d0, 0xa144, 0xa241, 0xa2af, 0xa2b0, 0xa2b1, 0xa2b2,
+ 0xa2b3, 0xa2b4, 0xa2b5, 0xa2b6, 0xa2b7, 0xa2b8, 0xa147, 0xa146,
+ 0xa1d5, 0xa1d7, 0xa1d6, 0xa148, 0xa249, 0xa2cf, 0xa2d0, 0xa2d1,
+ 0xa2d2, 0xa2d3, 0xa2d4, 0xa2d5, 0xa2d6, 0xa2d7, 0xa2d8, 0xa2d9,
+ 0xa2da, 0xa2db, 0xa2dc, 0xa2dd, 0xa2de, 0xa2df, 0xa2e0, 0xa2e1,
+ 0xa2e2, 0xa2e3, 0xa2e4, 0xa2e5, 0xa2e6, 0xa2e7, 0xa2e8, 0xa242,
+ 0xa1c4, 0xa2e9, 0xa2ea, 0xa2eb, 0xa2ec, 0xa2ed, 0xa2ee, 0xa2ef,
+ 0xa2f0, 0xa2f1, 0xa2f2, 0xa2f3, 0xa2f4, 0xa2f5, 0xa2f6, 0xa2f7,
+ 0xa2f8, 0xa2f9, 0xa2fa, 0xa2fb, 0xa2fc, 0xa2fd, 0xa2fe, 0xa340,
+ 0xa341, 0xa342, 0xa343, 0xa161, 0xa155, 0xa162, 0xa14e,
+};
+
+static const Summary16 big5_uni2indx_page00[16] = {
+ /* 0x0000 */
+ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
+ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
+ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x00ac }, { 4, 0x0083 },
+ { 7, 0x0000 }, { 7, 0x0080 }, { 8, 0x0000 }, { 8, 0x0080 },
+};
+static const Summary16 big5_uni2indx_page02[38] = {
+ /* 0x0200 */
+ { 9, 0x0000 }, { 9, 0x0000 }, { 9, 0x0000 }, { 9, 0x0000 },
+ { 9, 0x0000 }, { 9, 0x0000 }, { 9, 0x0000 }, { 9, 0x0000 },
+ { 9, 0x0000 }, { 9, 0x0000 }, { 9, 0x0000 }, { 9, 0x0000 },
+ { 9, 0x0e80 }, { 13, 0x0200 }, { 14, 0x0000 }, { 14, 0x0000 },
+ /* 0x0300 */
+ { 14, 0x0000 }, { 14, 0x0000 }, { 14, 0x0000 }, { 14, 0x0000 },
+ { 14, 0x0000 }, { 14, 0x0000 }, { 14, 0x0000 }, { 14, 0x0000 },
+ { 14, 0x0000 }, { 14, 0xfffe }, { 29, 0x03fb }, { 38, 0xfffe },
+ { 53, 0x03fb }, { 62, 0x0000 }, { 62, 0x0000 }, { 62, 0x0000 },
+ /* 0x0400 */
+ { 62, 0x0002 }, { 63, 0x1ff0 }, { 72, 0xfff8 }, { 85, 0xffff },
+ { 101, 0xffff }, { 117, 0x0002 },
+};
+static const Summary16 big5_uni2indx_page20[44] = {
+ /* 0x2000 */
+ { 118, 0x0000 }, { 118, 0x3318 }, { 124, 0x0064 }, { 127, 0x4824 },
+ { 131, 0x0000 }, { 131, 0x0000 }, { 131, 0x0000 }, { 131, 0x0000 },
+ { 131, 0x0000 }, { 131, 0x0000 }, { 131, 0x0000 }, { 131, 0x0000 },
+ { 131, 0x0000 }, { 131, 0x0000 }, { 131, 0x0000 }, { 131, 0x0000 },
+ /* 0x2100 */
+ { 131, 0x0228 }, { 134, 0x0000 }, { 134, 0x0000 }, { 134, 0x0000 },
+ { 134, 0x0000 }, { 134, 0x0000 }, { 134, 0x03ff }, { 144, 0x0000 },
+ { 144, 0x0000 }, { 144, 0x03cf }, { 152, 0x0000 }, { 152, 0x0000 },
+ { 152, 0x0000 }, { 152, 0x0000 }, { 152, 0x0000 }, { 152, 0x0000 },
+ /* 0x2200 */
+ { 152, 0x0000 }, { 152, 0xc400 }, { 155, 0x4e29 }, { 162, 0x1030 },
+ { 165, 0x0000 }, { 165, 0x0004 }, { 166, 0x00c3 }, { 170, 0x0000 },
+ { 170, 0x0000 }, { 170, 0x0000 }, { 170, 0x0020 }, { 171, 0x8000 },
+};
+static const Summary16 big5_uni2indx_page24[37] = {
+ /* 0x2400 */
+ { 172, 0x0000 }, { 172, 0x0000 }, { 172, 0x0000 }, { 172, 0x0000 },
+ { 172, 0x0000 }, { 172, 0x0000 }, { 172, 0x03ff }, { 182, 0x3ff0 },
+ { 192, 0x0000 }, { 192, 0x0000 }, { 192, 0x0000 }, { 192, 0x0000 },
+ { 192, 0x0000 }, { 192, 0x0000 }, { 192, 0x0000 }, { 192, 0x0000 },
+ /* 0x2500 */
+ { 192, 0x1005 }, { 195, 0x1111 }, { 199, 0x1010 }, { 201, 0x1010 },
+ { 203, 0x0000 }, { 203, 0x4001 }, { 205, 0xe402 }, { 210, 0x000f },
+ { 214, 0xfffe }, { 229, 0x0030 }, { 231, 0x0003 }, { 233, 0x300c },
+ { 237, 0xc8c0 }, { 242, 0x0000 }, { 242, 0x003c }, { 246, 0x0000 },
+ /* 0x2600 */
+ { 246, 0x0260 }, { 249, 0x0000 }, { 249, 0x0000 }, { 249, 0x0000 },
+ { 249, 0x0007 },
+};
+static const Summary16 big5_uni2indx_page30[62] = {
+ /* 0x3000 */
+ { 252, 0xff2f }, { 265, 0x6037 }, { 272, 0x03fe }, { 281, 0x0000 },
+ { 281, 0xfffe }, { 296, 0xffff }, { 312, 0xffff }, { 328, 0xffff },
+ { 344, 0xffff }, { 360, 0x600f }, { 366, 0xfffe }, { 381, 0xffff },
+ { 397, 0xffff }, { 413, 0xffff }, { 429, 0xffff }, { 445, 0x407f },
+ /* 0x3100 */
+ { 453, 0xffe0 }, { 464, 0xffff }, { 480, 0x03ff }, { 490, 0x0000 },
+ { 490, 0x0000 }, { 490, 0x0000 }, { 490, 0x0000 }, { 490, 0x0000 },
+ { 490, 0x0000 }, { 490, 0x0000 }, { 490, 0x0000 }, { 490, 0x0000 },
+ { 490, 0x0000 }, { 490, 0x0000 }, { 490, 0x0000 }, { 490, 0x0000 },
+ /* 0x3200 */
+ { 490, 0x0000 }, { 490, 0x0000 }, { 490, 0x0000 }, { 490, 0x0000 },
+ { 490, 0x0000 }, { 490, 0x0000 }, { 490, 0x0000 }, { 490, 0x0000 },
+ { 490, 0x0000 }, { 490, 0x0000 }, { 490, 0x0008 }, { 491, 0x0000 },
+ { 491, 0x0000 }, { 491, 0x0000 }, { 491, 0x0000 }, { 491, 0x0000 },
+ /* 0x3300 */
+ { 491, 0x0000 }, { 491, 0x0000 }, { 491, 0x0000 }, { 491, 0x0000 },
+ { 491, 0x0000 }, { 491, 0x0000 }, { 491, 0x0000 }, { 491, 0x0000 },
+ { 491, 0xc000 }, { 493, 0x7000 }, { 496, 0x0002 }, { 497, 0x0000 },
+ { 497, 0x4010 }, { 499, 0x0026 },
+};
+static const Summary16 big5_uni2indx_page4e[1307] = {
+ /* 0x4e00 */
+ { 502, 0xff8b }, { 514, 0xc373 }, { 523, 0x6840 }, { 527, 0x1b0f },
+ { 535, 0xe9ac }, { 544, 0xf34c }, { 553, 0x0200 }, { 554, 0xc008 },
+ { 557, 0x795c }, { 566, 0xca3e }, { 575, 0x7976 }, { 585, 0x0648 },
+ { 589, 0x2fdf }, { 601, 0xf7f0 }, { 612, 0x033a }, { 618, 0xa8ff },
+ /* 0x4f00 */
+ { 629, 0xef37 }, { 641, 0x233f }, { 650, 0xb004 }, { 654, 0xfd59 },
+ { 665, 0xf3ca }, { 675, 0xffff }, { 691, 0xde9f }, { 703, 0xfff9 },
+ { 717, 0xabff }, { 730, 0x7df7 }, { 743, 0xc000 }, { 745, 0x8eec },
+ { 754, 0xeebf }, { 767, 0xffdb }, { 781, 0xd003 }, { 786, 0x45fa },
+ /* 0x5000 */
+ { 795, 0xfae1 }, { 805, 0xdffe }, { 819, 0xbfef }, { 833, 0x10ab },
+ { 839, 0xffeb }, { 853, 0xfcaa }, { 863, 0xef3f }, { 876, 0x24fd },
+ { 885, 0x78ad }, { 894, 0x7f76 }, { 906, 0xf00c }, { 912, 0xedff },
+ { 926, 0xcff6 }, { 938, 0x2cfa }, { 947, 0xf7f9 }, { 960, 0xeb6b },
+ /* 0x5100 */
+ { 971, 0x1ffd }, { 983, 0x95bf }, { 994, 0x6677 }, { 1004, 0xbfbf },
+ { 1018, 0x3bfb }, { 1030, 0xfeb4 }, { 1041, 0x7bae }, { 1052, 0x11e2 },
+ { 1058, 0xa681 }, { 1064, 0x41be }, { 1072, 0x1435 }, { 1078, 0x72c3 },
+ { 1086, 0x7d70 }, { 1095, 0x7191 }, { 1102, 0x0003 }, { 1104, 0x276b },
+ /* 0x5200 */
+ { 1113, 0x57cb }, { 1123, 0x70cf }, { 1132, 0x4732 }, { 1139, 0x0def },
+ { 1149, 0x7eda }, { 1160, 0xfc74 }, { 1170, 0xfe06 }, { 1179, 0xbdb4 },
+ { 1189, 0x3f9f }, { 1201, 0x8bca }, { 1209, 0x7e49 }, { 1218, 0x5800 },
+ { 1221, 0x228f }, { 1228, 0xebec }, { 1239, 0x8a5c }, { 1246, 0xddbb },
+ /* 0x5300 */
+ { 1258, 0xef60 }, { 1267, 0xb6e7 }, { 1278, 0xa40f }, { 1285, 0xf293 },
+ { 1294, 0x37bb }, { 1305, 0x549e }, { 1313, 0xd04b }, { 1320, 0x9baf },
+ { 1331, 0xc414 }, { 1336, 0xf7d4 }, { 1347, 0x30b0 }, { 1352, 0x0a14 },
+ { 1356, 0x2f08 }, { 1362, 0x88d0 }, { 1367, 0xff7e }, { 1381, 0x192f },
+ /* 0x5400 */
+ { 1389, 0xffda }, { 1402, 0xfb07 }, { 1412, 0x7ff1 }, { 1424, 0x7beb },
+ { 1436, 0xc5ef }, { 1447, 0x0010 }, { 1448, 0x99ff }, { 1460, 0xfdff },
+ { 1475, 0x79d7 }, { 1486, 0x0567 }, { 1493, 0xffe7 }, { 1507, 0xfdcb },
+ { 1519, 0xc3ff }, { 1531, 0x4040 }, { 1533, 0x6ff7 }, { 1546, 0xbd8e },
+ /* 0x5500 */
+ { 1556, 0xdffa }, { 1569, 0x0497 }, { 1575, 0xf4c0 }, { 1582, 0x5bff },
+ { 1595, 0xed7b }, { 1607, 0xd0e7 }, { 1616, 0x047e }, { 1623, 0xf8e0 },
+ { 1631, 0xff9f }, { 1645, 0xb73e }, { 1656, 0x7dfe }, { 1669, 0x882e },
+ { 1675, 0xfffd }, { 1690, 0xbe7f }, { 1703, 0x83fe }, { 1713, 0xf6c4 },
+ /* 0x5600 */
+ { 1722, 0xf357 }, { 1733, 0xb8fd }, { 1744, 0xd680 }, { 1750, 0xef7d },
+ { 1763, 0x5767 }, { 1773, 0x4788 }, { 1779, 0xff7d }, { 1793, 0xc3df },
+ { 1804, 0xf0ff }, { 1816, 0x37a9 }, { 1825, 0x7de0 }, { 1834, 0x70fc },
+ { 1843, 0x3f6f }, { 1855, 0xec9a }, { 1864, 0x4cb3 }, { 1872, 0x8681 },
+ /* 0x5700 */
+ { 1877, 0x3f9e }, { 1888, 0xdd5c }, { 1898, 0xf70d }, { 1908, 0x4819 },
+ { 1913, 0xfea3 }, { 1924, 0x0007 }, { 1927, 0xaf56 }, { 1937, 0x38ff },
+ { 1948, 0x980d }, { 1954, 0xefb8 }, { 1965, 0x403d }, { 1971, 0xb760 },
+ { 1979, 0xd8ce }, { 1988, 0x9035 }, { 1994, 0x72bf }, { 2005, 0x3fff },
+ /* 0x5800 */
+ { 2019, 0x7ff7 }, { 2033, 0x7a11 }, { 2040, 0xf7bb }, { 2053, 0xabff },
+ { 2066, 0xff00 }, { 2074, 0x6fbe }, { 2086, 0xa93c }, { 2094, 0xfe72 },
+ { 2105, 0xcfef }, { 2118, 0xf11b }, { 2127, 0xdb6b }, { 2138, 0xf40a },
+ { 2145, 0xc3e6 }, { 2154, 0xef7e }, { 2167, 0x9b9c }, { 2176, 0xf610 },
+ /* 0x5900 */
+ { 2183, 0xf048 }, { 2189, 0x16f4 }, { 2197, 0xfeb5 }, { 2209, 0x5182 },
+ { 2214, 0xc7b1 }, { 2223, 0x15bb }, { 2232, 0x6e87 }, { 2241, 0xfbdf },
+ { 2255, 0xe43f }, { 2265, 0x63cd }, { 2274, 0xc1ff }, { 2285, 0x7e7e },
+ { 2297, 0xfdeb }, { 2310, 0x7d5f }, { 2322, 0x777b }, { 2334, 0xfcfe },
+ /* 0x5a00 */
+ { 2347, 0x960b }, { 2354, 0xdbea }, { 2365, 0x6229 }, { 2371, 0x53e8 },
+ { 2379, 0x37df }, { 2391, 0xfdef }, { 2405, 0x36f5 }, { 2415, 0xbd81 },
+ { 2423, 0xdc18 }, { 2430, 0xfcbd }, { 2442, 0xd2e4 }, { 2450, 0xffff },
+ { 2466, 0x3fd7 }, { 2478, 0xffe0 }, { 2489, 0x7f6f }, { 2502, 0xabf8 },
+ /* 0x5b00 */
+ { 2512, 0x9bae }, { 2522, 0x6ed9 }, { 2532, 0xf5fb }, { 2545, 0xf115 },
+ { 2553, 0x79a9 }, { 2562, 0xbdfb }, { 2575, 0x5a3c }, { 2583, 0xadaf },
+ { 2594, 0xdbba }, { 2605, 0x1fac }, { 2614, 0x71fc }, { 2624, 0x8379 },
+ { 2632, 0x7cf7 }, { 2644, 0xc35f }, { 2654, 0xdfff }, { 2669, 0x0567 },
+ /* 0x5c00 */
+ { 2676, 0xff9a }, { 2688, 0x8467 }, { 2695, 0x1534 }, { 2701, 0xdf8b },
+ { 2712, 0xf9f3 }, { 2724, 0x3373 }, { 2733, 0xf7bd }, { 2746, 0x5e1a },
+ { 2754, 0xbf40 }, { 2762, 0xa03f }, { 2770, 0xffff }, { 2786, 0x01eb },
+ { 2793, 0xdfc0 }, { 2802, 0xcfdd }, { 2814, 0x7500 }, { 2819, 0xabd3 },
+ /* 0x5d00 */
+ { 2829, 0xf8c3 }, { 2838, 0xeed6 }, { 2849, 0x43fd }, { 2859, 0xb7ff },
+ { 2873, 0x5eaf }, { 2884, 0x4227 }, { 2890, 0x9bac }, { 2899, 0xf686 },
+ { 2908, 0x27d7 }, { 2918, 0xf6bc }, { 2929, 0xf787 }, { 2940, 0x35b7 },
+ { 2950, 0xaacd }, { 2959, 0xe176 }, { 2968, 0x49e7 }, { 2977, 0xe29f },
+ /* 0x5e00 */
+ { 2987, 0x545c }, { 2994, 0xaff2 }, { 3005, 0x2b3f }, { 3015, 0x61d8 },
+ { 3022, 0xfc3b }, { 3033, 0xbbb8 }, { 3043, 0xffcf }, { 3057, 0x7b7d },
+ { 3069, 0xbf95 }, { 3080, 0x1ce0 }, { 3086, 0x7dfd }, { 3099, 0x43ff },
+ { 3110, 0x5ff6 }, { 3122, 0xfffe }, { 3137, 0xd3ef }, { 3149, 0xc4ce },
+ /* 0x5f00 */
+ { 3157, 0x8db6 }, { 3166, 0xadbc }, { 3176, 0x63dc }, { 3185, 0x11eb },
+ { 3193, 0xdf59 }, { 3204, 0x23d0 }, { 3210, 0xbeb4 }, { 3220, 0xf3db },
+ { 3232, 0x1fe7 }, { 3243, 0xdbc7 }, { 3254, 0xff63 }, { 3266, 0xfae4 },
+ { 3276, 0xb22b }, { 3284, 0x63f7 }, { 3295, 0xed3b }, { 3306, 0xadba },
+ /* 0x6000 */
+ { 3316, 0xfe01 }, { 3324, 0x7eff }, { 3338, 0xfff7 }, { 3353, 0x02bc },
+ { 3359, 0x32ff }, { 3370, 0xef39 }, { 3381, 0xfffc }, { 3395, 0x8005 },
+ { 3398, 0x77fb }, { 3411, 0xbcf5 }, { 3422, 0x010d }, { 3426, 0xfff7 },
+ { 3441, 0xfffb }, { 3456, 0xbf3a }, { 3467, 0x0057 }, { 3472, 0xdfff },
+ /* 0x6100 */
+ { 3487, 0xef7b }, { 3500, 0xbd7d }, { 3512, 0xdb88 }, { 3520, 0xc8d4 },
+ { 3527, 0xfff3 }, { 3541, 0xed7c }, { 3552, 0x5dee }, { 3563, 0x56ff },
+ { 3575, 0x7e0d }, { 3584, 0xac5f }, { 3594, 0xff96 }, { 3606, 0xd57f },
+ { 3618, 0x3fee }, { 3630, 0xc140 }, { 3634, 0x6ff9 }, { 3646, 0xffe7 },
+ /* 0x6200 */
+ { 3660, 0x779b }, { 3671, 0x8e77 }, { 3681, 0x6ebf }, { 3693, 0xe45d },
+ { 3702, 0x6fcf }, { 3714, 0x5f1f }, { 3725, 0xe07f }, { 3735, 0xfedf },
+ { 3749, 0xd7db }, { 3761, 0x01fe }, { 3769, 0xff00 }, { 3777, 0xfb7b },
+ { 3790, 0xffd4 }, { 3802, 0x1fdf }, { 3814, 0xf800 }, { 3819, 0xffff },
+ /* 0x6300 */
+ { 3835, 0xfb8f }, { 3847, 0x007b }, { 3853, 0xbf00 }, { 3860, 0x7f5c },
+ { 3871, 0xffff }, { 3887, 0x07f3 }, { 3896, 0xeba0 }, { 3904, 0x3de7 },
+ { 3915, 0xf7bf }, { 3929, 0xfbd7 }, { 3942, 0xffbf }, { 3957, 0x6003 },
+ { 3961, 0xfffd }, { 3976, 0xbfed }, { 3989, 0xefbb }, { 4002, 0x027f },
+ /* 0x6400 */
+ { 4010, 0xfe40 }, { 4018, 0xddfd }, { 4031, 0xfdff }, { 4046, 0xe2f9 },
+ { 4056, 0x680b }, { 4062, 0xfb1f }, { 4074, 0xfbe3 }, { 4086, 0xaffd },
+ { 4099, 0x9fa4 }, { 4108, 0xf7ed }, { 4121, 0x7a7d }, { 4132, 0xf80f },
+ { 4141, 0xeebe }, { 4153, 0x0fd5 }, { 4162, 0xbb5d }, { 4173, 0xfd9f },
+ /* 0x6500 */
+ { 4186, 0xf2db }, { 4197, 0x3bf9 }, { 4208, 0xfe7f }, { 4222, 0xebcc },
+ { 4232, 0x876a }, { 4240, 0x73fa }, { 4251, 0x95fc }, { 4261, 0x9ffc },
+ { 4273, 0x109f }, { 4280, 0xfaf7 }, { 4293, 0xddb7 }, { 4305, 0xbbcd },
+ { 4316, 0xf87e }, { 4327, 0xeccd }, { 4337, 0xf366 }, { 4347, 0x3c3f },
+ /* 0x6600 */
+ { 4357, 0xfffd }, { 4372, 0xb03f }, { 4381, 0xe9f7 }, { 4393, 0x067e },
+ { 4401, 0x96ae }, { 4410, 0xfe06 }, { 4419, 0xd576 }, { 4429, 0x5fd7 },
+ { 4441, 0x3fd1 }, { 4451, 0xa3f3 }, { 4461, 0xcf07 }, { 4470, 0x6fb7 },
+ { 4482, 0x9fd1 }, { 4492, 0x7f44 }, { 4501, 0x7b59 }, { 4511, 0xd3dd },
+ /* 0x6700 */
+ { 4522, 0xaf3b }, { 4533, 0xa9bd }, { 4543, 0x7dcf }, { 4555, 0xff3a },
+ { 4567, 0xfbe0 }, { 4577, 0xf6eb }, { 4589, 0xb401 }, { 4594, 0xffff },
+ { 4610, 0x7afa }, { 4621, 0xb7bf }, { 4634, 0xc000 }, { 4636, 0x0ffd },
+ { 4647, 0xff7f }, { 4662, 0xff1f }, { 4675, 0xfefc }, { 4688, 0x95ff },
+ /* 0x6800 */
+ { 4700, 0x0000 }, { 4700, 0xb5dc }, { 4710, 0xef63 }, { 4721, 0x3f3e },
+ { 4732, 0xfb7f }, { 4746, 0x001b }, { 4750, 0xe800 }, { 4754, 0xfbf6 },
+ { 4767, 0x9eef }, { 4779, 0xb8df }, { 4790, 0xff9f }, { 4804, 0x003f },
+ { 4810, 0x7bd0 }, { 4819, 0xf5ff }, { 4833, 0xdfdb }, { 4846, 0x3fff },
+ /* 0x6900 */
+ { 4860, 0xfdf0 }, { 4871, 0x00bf }, { 4878, 0x8420 }, { 4881, 0xbbbd },
+ { 4893, 0xdf37 }, { 4905, 0xffde }, { 4919, 0xff6d }, { 4932, 0x0ff3 },
+ { 4942, 0x604c }, { 4947, 0x5efb }, { 4959, 0xfffb }, { 4974, 0xfafb },
+ { 4987, 0xfe5e }, { 4999, 0x0219 }, { 5003, 0x79f4 }, { 5013, 0xf9de },
+ /* 0x6a00 */
+ { 5025, 0xa7f7 }, { 5037, 0xebfa }, { 5049, 0x01eb }, { 5056, 0xff34 },
+ { 5067, 0xebd3 }, { 5078, 0xef73 }, { 5090, 0xafd7 }, { 5102, 0xc040 },
+ { 5105, 0x72bb }, { 5115, 0xdcff }, { 5128, 0xf17f }, { 5140, 0x2fd8 },
+ { 5149, 0xb8ec }, { 5158, 0xfe0b }, { 5168, 0xdda3 }, { 5178, 0x1f0b },
+ /* 0x6b00 */
+ { 5186, 0x8f1d }, { 5195, 0x47cf }, { 5205, 0xb12b }, { 5213, 0xffde },
+ { 5227, 0x7fee }, { 5240, 0xda73 }, { 5250, 0x24ff }, { 5260, 0xcbc4 },
+ { 5268, 0xf75d }, { 5280, 0xcbf2 }, { 5290, 0xecfd }, { 5302, 0xb4ed },
+ { 5312, 0xbff9 }, { 5325, 0x4ddd }, { 5335, 0x99dd }, { 5345, 0xfb8d },
+ /* 0x6c00 */
+ { 5356, 0xbb7f }, { 5369, 0xaf7b }, { 5381, 0xddfb }, { 5394, 0xc959 },
+ { 5402, 0xfc4f }, { 5413, 0xfab5 }, { 5424, 0xafe3 }, { 5435, 0x6d5f },
+ { 5446, 0xffff }, { 5462, 0x3f7d }, { 5474, 0x7800 }, { 5478, 0xffdb },
+ { 5492, 0xb6ff }, { 5505, 0x7eff }, { 5519, 0xfbaf }, { 5532, 0x022f },
+ /* 0x6d00 */
+ { 5538, 0xff9b }, { 5551, 0xefc7 }, { 5563, 0xffa5 }, { 5575, 0xffff },
+ { 5591, 0x0007 }, { 5594, 0xc700 }, { 5599, 0xf7ff }, { 5614, 0xfff1 },
+ { 5627, 0x7ffd }, { 5641, 0x01bf }, { 5649, 0xdc00 }, { 5654, 0xfdbc },
+ { 5666, 0xbff5 }, { 5679, 0xffff }, { 5695, 0xff7f }, { 5710, 0x3eff },
+ /* 0x6e00 */
+ { 5723, 0x0029 }, { 5726, 0xbe00 }, { 5732, 0xf9ff }, { 5746, 0xff7f },
+ { 5761, 0x6efb }, { 5773, 0xfd7e }, { 5786, 0xcbff }, { 5799, 0x039e },
+ { 5806, 0xe300 }, { 5811, 0xfbdd }, { 5824, 0xccff }, { 5836, 0xf6df },
+ { 5849, 0xffff }, { 5865, 0x117f }, { 5874, 0xf800 }, { 5879, 0xfbf6 },
+ /* 0x6f00 */
+ { 5892, 0xe7ef }, { 5905, 0xd73c }, { 5915, 0xfeef }, { 5929, 0xdfef },
+ { 5943, 0xc00b }, { 5948, 0xedbf }, { 5961, 0xfedf }, { 5975, 0xfdcd },
+ { 5987, 0x7bf5 }, { 5999, 0x40fd }, { 6007, 0xffff }, { 6023, 0xb75f },
+ { 6035, 0xffdf }, { 6050, 0xf930 }, { 6058, 0xfbdf }, { 6072, 0xdc97 },
+ /* 0x7000 */
+ { 6082, 0xfef3 }, { 6095, 0xbff2 }, { 6107, 0x8fdf }, { 6119, 0xdfbf },
+ { 6133, 0x177f }, { 6144, 0xede6 }, { 6155, 0x0f7f }, { 6166, 0x3553 },
+ { 6174, 0x447c }, { 6181, 0x877e }, { 6191, 0xfa12 }, { 6199, 0x45bb },
+ { 6208, 0xede0 }, { 6217, 0x779e }, { 6228, 0x8017 }, { 6233, 0xbfd9 },
+ /* 0x7100 */
+ { 6245, 0x7e55 }, { 6255, 0xde89 }, { 6264, 0xc16f }, { 6273, 0x0447 },
+ { 6278, 0x7ade }, { 6289, 0xf75d }, { 6301, 0x57ff }, { 6314, 0x2905 },
+ { 6319, 0x86f7 }, { 6329, 0xfe95 }, { 6340, 0x97b3 }, { 6350, 0xf32f },
+ { 6361, 0xcfff }, { 6375, 0x9f75 }, { 6386, 0x71f7 }, { 6397, 0xfb17 },
+ /* 0x7200 */
+ { 6408, 0x34ee }, { 6417, 0xee19 }, { 6426, 0x37cc }, { 6435, 0xef61 },
+ { 6445, 0x9fd6 }, { 6456, 0xef4c }, { 6466, 0xd68f }, { 6476, 0xfbdd },
+ { 6489, 0x7b73 }, { 6500, 0x6def }, { 6512, 0xd7fe }, { 6525, 0xa431 },
+ { 6531, 0x5e7f }, { 6543, 0x97d7 }, { 6554, 0x0f5b }, { 6563, 0xffd8 },
+ /* 0x7300 */
+ { 6575, 0x9d83 }, { 6583, 0x7bce }, { 6594, 0x22ec }, { 6601, 0xdcff },
+ { 6614, 0x763d }, { 6624, 0xef87 }, { 6635, 0xdfe7 }, { 6648, 0xfded },
+ { 6661, 0x4fff }, { 6674, 0xa0fc }, { 6682, 0x3b77 }, { 6693, 0xdbfc },
+ { 6705, 0x3ded }, { 6716, 0x7fdc }, { 6728, 0x6fa9 }, { 6738, 0xf570 },
+ /* 0x7400 */
+ { 6747, 0x3ffb }, { 6760, 0x2c40 }, { 6764, 0xff7f }, { 6779, 0x847f },
+ { 6788, 0xec57 }, { 6798, 0xdeb7 }, { 6810, 0xe69c }, { 6819, 0xf22f },
+ { 6829, 0x0feb }, { 6839, 0xd5b5 }, { 6849, 0xafeb }, { 6861, 0xede7 },
+ { 6873, 0x8c2f }, { 6881, 0xfff0 }, { 6893, 0x537f }, { 6904, 0xe8f0 },
+ /* 0x7500 */
+ { 6912, 0xb99d }, { 6922, 0xb5ff }, { 6935, 0xff66 }, { 6947, 0xe78f },
+ { 6958, 0xd981 }, { 6965, 0xbe10 }, { 6972, 0x9c7c }, { 6981, 0xe3c1 },
+ { 6989, 0x9cd1 }, { 6997, 0x2733 }, { 7005, 0x0cbc }, { 7012, 0xff6d },
+ { 7025, 0xfcb7 }, { 7037, 0xefb7 }, { 7050, 0xa0df }, { 7059, 0xffff },
+ /* 0x7600 */
+ { 7075, 0xbf0b }, { 7085, 0xfe7b }, { 7098, 0xa3ff }, { 7110, 0x353f },
+ { 7120, 0x13cc }, { 7127, 0x97cd }, { 7137, 0x7637 }, { 7147, 0xfb27 },
+ { 7158, 0xcfd6 }, { 7169, 0x7e6c }, { 7179, 0xec50 }, { 7186, 0xed31 },
+ { 7195, 0x677c }, { 7205, 0xfc1c }, { 7214, 0xf6fa }, { 7226, 0x5fbf },
+ /* 0x7700 */
+ { 7239, 0x0fba }, { 7248, 0xae2f }, { 7258, 0xa3ad }, { 7267, 0x7ffe },
+ { 7281, 0xfcf0 }, { 7291, 0xde74 }, { 7301, 0xffef }, { 7316, 0xf200 },
+ { 7321, 0xfbbf }, { 7335, 0xfea2 }, { 7345, 0x3daf }, { 7356, 0xbcff },
+ { 7369, 0xf694 }, { 7378, 0x5fb9 }, { 7389, 0xf3ad }, { 7400, 0x3f8f },
+ /* 0x7800 */
+ { 7411, 0xf26c }, { 7420, 0xa01f }, { 7427, 0xffef }, { 7442, 0x01bf },
+ { 7450, 0x7728 }, { 7458, 0x7005 }, { 7463, 0xff35 }, { 7475, 0xda03 },
+ { 7482, 0xd2f9 }, { 7492, 0xc7fa }, { 7503, 0x3fbf }, { 7516, 0x5c1d },
+ { 7524, 0xff3a }, { 7536, 0xec33 }, { 7545, 0xb7af }, { 7557, 0xfe9c },
+ /* 0x7900 */
+ { 7568, 0x5236 }, { 7575, 0x7a9f }, { 7586, 0xbffa }, { 7599, 0xe722 },
+ { 7607, 0x9ff7 }, { 7620, 0xfcff }, { 7634, 0x2fbb }, { 7645, 0xb61d },
+ { 7654, 0xed06 }, { 7662, 0x1dfd }, { 7673, 0x7dd7 }, { 7685, 0xefdf },
+ { 7699, 0xeb23 }, { 7708, 0xf166 }, { 7717, 0x7ed9 }, { 7728, 0x0dc0 },
+ /* 0x7a00 */
+ { 7733, 0x3d3d }, { 7743, 0xdfbf }, { 7757, 0xc945 }, { 7764, 0xba83 },
+ { 7772, 0x7dd1 }, { 7782, 0x9dd0 }, { 7790, 0x7b87 }, { 7800, 0xcf73 },
+ { 7811, 0x9ff3 }, { 7823, 0xc3f5 }, { 7833, 0xdf0d }, { 7843, 0xc5fe },
+ { 7854, 0x0cb3 }, { 7861, 0x8302 }, { 7865, 0xe879 }, { 7874, 0xaec0 },
+ /* 0x7b00 */
+ { 7881, 0xc773 }, { 7891, 0x6f0f }, { 7901, 0xfd7d }, { 7914, 0x093f },
+ { 7922, 0xfff1 }, { 7935, 0x0157 }, { 7941, 0x62fb }, { 7951, 0x01ff },
+ { 7960, 0xfdb4 }, { 7971, 0x3bf3 }, { 7982, 0xb013 }, { 7988, 0x43b2 },
+ { 7995, 0x5ed3 }, { 8005, 0xff30 }, { 8015, 0x0fff }, { 8027, 0xeb9f },
+ /* 0x7c00 */
+ { 8039, 0xfeef }, { 8053, 0xf203 }, { 8060, 0x3fef }, { 8073, 0xfb89 },
+ { 8083, 0x37a9 }, { 8092, 0x9e99 }, { 8101, 0xdef9 }, { 8113, 0xa72c },
+ { 8121, 0x3733 }, { 8130, 0xc1f6 }, { 8139, 0x812e }, { 8145, 0xfe3e },
+ { 8157, 0x5d20 }, { 8163, 0xf2f7 }, { 8175, 0xd585 }, { 8183, 0x69d7 },
+ /* 0x7d00 */
+ { 8193, 0xffff }, { 8209, 0xffff }, { 8225, 0xdb07 }, { 8234, 0xff6f },
+ { 8248, 0xc4ff }, { 8259, 0xd97f }, { 8271, 0xefce }, { 8283, 0xbe0f },
+ { 8293, 0xf17b }, { 8304, 0xf05e }, { 8313, 0xf6cf }, { 8325, 0xffb7 },
+ { 8339, 0x5ef7 }, { 8351, 0xef84 }, { 8360, 0xd7cb }, { 8371, 0x0edf },
+ /* 0x7e00 */
+ { 8381, 0xff08 }, { 8390, 0xfcff }, { 8404, 0xee3f }, { 8416, 0xffff },
+ { 8432, 0x13ff }, { 8443, 0xd7ff }, { 8457, 0xaf0f }, { 8467, 0x7ffd },
+ { 8481, 0xbdc7 }, { 8492, 0x1ffa }, { 8503, 0x0000 }, { 8503, 0x0000 },
+ { 8503, 0x0000 }, { 8503, 0x0000 }, { 8503, 0x0000 }, { 8503, 0x0000 },
+ /* 0x7f00 */
+ { 8503, 0x0000 }, { 8503, 0x0000 }, { 8503, 0x0000 }, { 8503, 0xe740 },
+ { 8510, 0xbd38 }, { 8519, 0xf933 }, { 8529, 0x7feb }, { 8542, 0xfeed },
+ { 8555, 0x7fe8 }, { 8566, 0x7c76 }, { 8576, 0xb3f7 }, { 8588, 0xffef },
+ { 8603, 0xfeaf }, { 8616, 0xd8b7 }, { 8626, 0xff6f }, { 8640, 0xfbbf },
+ /* 0x8000 */
+ { 8654, 0xf8fb }, { 8666, 0xdbf7 }, { 8679, 0x1752 }, { 8686, 0xe2f9 },
+ { 8696, 0x85c8 }, { 8702, 0x7547 }, { 8711, 0x9090 }, { 8715, 0xe3ef },
+ { 8727, 0x9ef4 }, { 8737, 0x3f6d }, { 8748, 0xee2e }, { 8758, 0x0536 },
+ { 8764, 0xf7bc }, { 8776, 0x7ff3 }, { 8789, 0xa07b }, { 8797, 0x7f3f },
+ /* 0x8100 */
+ { 8810, 0x0567 }, { 8817, 0xeb60 }, { 8825, 0xbabe }, { 8836, 0x6601 },
+ { 8841, 0xfcd8 }, { 8851, 0x583f }, { 8860, 0xcaf7 }, { 8871, 0x87df },
+ { 8882, 0xbfcd }, { 8894, 0xffa0 }, { 8904, 0x5bcd }, { 8914, 0xfebf },
+ { 8928, 0xb6fd }, { 8940, 0xefa7 }, { 8952, 0x77ef }, { 8965, 0xdf9c },
+ /* 0x8200 */
+ { 8976, 0x3fb7 }, { 8988, 0xf877 }, { 8999, 0x9d27 }, { 9008, 0xb7fc },
+ { 9020, 0xcab5 }, { 9029, 0xdfef }, { 9043, 0xfb5a }, { 9054, 0xf1b6 },
+ { 9064, 0xec39 }, { 9073, 0xef1f }, { 9085, 0xfbbf }, { 9099, 0x7ffb },
+ { 9113, 0x000d }, { 9116, 0xdafe }, { 9128, 0xbdfb }, { 9141, 0x4e7f },
+ /* 0x8300 */
+ { 9152, 0x33ff }, { 9164, 0x5ac0 }, { 9170, 0xbff5 }, { 9183, 0x9ffe },
+ { 9196, 0xffbf }, { 9211, 0x005f }, { 9217, 0x0000 }, { 9217, 0xfdf8 },
+ { 9229, 0xffca }, { 9241, 0x6ffd }, { 9254, 0xcffd }, { 9267, 0xa001 },
+ { 9270, 0xdfff }, { 9285, 0xfbf2 }, { 9297, 0xdfbf }, { 9311, 0xff7f },
+ /* 0x8400 */
+ { 9326, 0xfeda }, { 9338, 0x080f }, { 9343, 0xba08 }, { 9349, 0xbfff },
+ { 9364, 0x7afd }, { 9376, 0xeed7 }, { 9388, 0xfbeb }, { 9401, 0x67f9 },
+ { 9412, 0xe044 }, { 9417, 0xff93 }, { 9429, 0xdf97 }, { 9441, 0x9f57 },
+ { 9452, 0xfef7 }, { 9466, 0x08df }, { 9474, 0xdf80 }, { 9482, 0xfedf },
+ /* 0x8500 */
+ { 9496, 0xffc5 }, { 9508, 0xf7fe }, { 9522, 0xfffb }, { 9537, 0x6803 },
+ { 9542, 0x67fb }, { 9554, 0x6bfa }, { 9565, 0x7fff }, { 9580, 0x5fe2 },
+ { 9590, 0xffff }, { 9606, 0xff73 }, { 9619, 0x87df }, { 9630, 0xe7fb },
+ { 9643, 0xebfd }, { 9656, 0xf7a7 }, { 9668, 0xbf7e }, { 9681, 0xefc7 },
+ /* 0x8600 */
+ { 9693, 0x1ef3 }, { 9703, 0xdf82 }, { 9712, 0x76ff }, { 9725, 0xdf7e },
+ { 9738, 0x79c9 }, { 9747, 0xda7d }, { 9758, 0xefbe }, { 9771, 0x1e9b },
+ { 9780, 0x7ce0 }, { 9788, 0x77fb }, { 9801, 0x87be }, { 9811, 0xfffb },
+ { 9826, 0x1bff }, { 9838, 0xffdb }, { 9852, 0x3f5c }, { 9862, 0x4fe0 },
+ /* 0x8700 */
+ { 9870, 0x7fff }, { 9885, 0x5f0e }, { 9894, 0x77ff }, { 9908, 0xddbf },
+ { 9921, 0xf04f }, { 9930, 0xffff }, { 9946, 0xffff }, { 9962, 0x0ff8 },
+ { 9971, 0xa3be }, { 9981, 0xfddf }, { 9995, 0xfc1c }, { 10004, 0xfffd },
+ { 10019, 0x1f7d }, { 10030, 0xfb9e }, { 10042, 0xbdff }, { 10056, 0xdedc },
+ /* 0x8800 */
+ { 10067, 0x3f6f }, { 10079, 0xbafb }, { 10091, 0xdf7f }, { 10105, 0xfbef },
+ { 10119, 0x7d1b }, { 10129, 0x2eec }, { 10138, 0xaf8e }, { 10148, 0xf2f7 },
+ { 10160, 0x7b0f }, { 10170, 0xcfee }, { 10182, 0x1d96 }, { 10190, 0x77c6 },
+ { 10200, 0x7e07 }, { 10209, 0xfff5 }, { 10223, 0xd982 }, { 10230, 0x7fdf },
+ /* 0x8900 */
+ { 10244, 0x5ee6 }, { 10254, 0xc7ff }, { 10267, 0xfeee }, { 10280, 0x79ef },
+ { 10292, 0x9a56 }, { 10300, 0xffcf }, { 10314, 0xfe5f }, { 10327, 0xde5e },
+ { 10338, 0x896e }, { 10346, 0xf9e8 }, { 10356, 0xf45e }, { 10366, 0xe6c4 },
+ { 10374, 0x0001 }, { 10375, 0xbe7c }, { 10386, 0x3b7f }, { 10398, 0xdddf },
+ /* 0x8a00 */
+ { 10411, 0xd59d }, { 10421, 0xe9ef }, { 10433, 0x34ac }, { 10440, 0xde53 },
+ { 10450, 0xf573 }, { 10461, 0x4bf7 }, { 10472, 0x7b4f }, { 10483, 0x9eff },
+ { 10496, 0xb8fe }, { 10507, 0x476e }, { 10516, 0x0dfb }, { 10526, 0xff45 },
+ { 10537, 0xabfd }, { 10549, 0xfbfe }, { 10563, 0xe9d7 }, { 10574, 0xddff },
+ /* 0x8b00 */
+ { 10588, 0xedf7 }, { 10601, 0x7fff }, { 10616, 0xddfd }, { 10629, 0x7eeb },
+ { 10641, 0xcfe7 }, { 10653, 0xb7ff }, { 10667, 0xbde9 }, { 10678, 0xef91 },
+ { 10688, 0x5d75 }, { 10698, 0xd77c }, { 10709, 0x0000 }, { 10709, 0x0000 },
+ { 10709, 0x0000 }, { 10709, 0x0000 }, { 10709, 0x0000 }, { 10709, 0x0000 },
+ /* 0x8c00 */
+ { 10709, 0x0000 }, { 10709, 0x0000 }, { 10709, 0x0000 }, { 10709, 0xfa80 },
+ { 10716, 0xffee }, { 10730, 0xb4f1 }, { 10739, 0xbf76 }, { 10751, 0x2fef },
+ { 10763, 0xb677 }, { 10774, 0x77bf }, { 10787, 0x9fbf }, { 10800, 0xfffd },
+ { 10815, 0x95bf }, { 10826, 0xf6ae }, { 10837, 0x75ff }, { 10850, 0x7f3b },
+ /* 0x8d00 */
+ { 10862, 0xa7f5 }, { 10873, 0x0af9 }, { 10881, 0x0000 }, { 10881, 0x0000 },
+ { 10881, 0x0000 }, { 10881, 0x0000 }, { 10881, 0xfbd0 }, { 10891, 0x2bdd },
+ { 10901, 0xf633 }, { 10911, 0x9a7f }, { 10922, 0xfdab }, { 10934, 0xd6fc },
+ { 10945, 0xf9e6 }, { 10956, 0xbfeb }, { 10969, 0xdfdf }, { 10983, 0xf41f },
+ /* 0x8e00 */
+ { 10993, 0xa6fd }, { 11004, 0xffff }, { 11020, 0x4aff }, { 11031, 0xf37b },
+ { 11043, 0x7fb7 }, { 11056, 0xfef9 }, { 11069, 0xb6ff }, { 11082, 0x1d5c },
+ { 11090, 0x7ff6 }, { 11103, 0xe5ff }, { 11116, 0x1f7b }, { 11127, 0x2404 },
+ { 11130, 0xbe05 }, { 11138, 0xf99e }, { 11149, 0xdbe3 }, { 11160, 0xdff2 },
+ /* 0x8f00 */
+ { 11172, 0x6fef }, { 11185, 0xfdff }, { 11200, 0xd679 }, { 11210, 0xcbfc },
+ { 11221, 0xebfd }, { 11234, 0xefff }, { 11249, 0x001f }, { 11254, 0x0000 },
+ { 11254, 0x0000 }, { 11254, 0x9800 }, { 11257, 0xe148 }, { 11263, 0x8017 },
+ { 11268, 0x6a74 }, { 11276, 0x00fe }, { 11283, 0x6d7f }, { 11295, 0xfdf1 },
+ /* 0x9000 */
+ { 11307, 0xb87f }, { 11318, 0xfef3 }, { 11331, 0xe01f }, { 11339, 0xf176 },
+ { 11349, 0xee96 }, { 11359, 0x7b3f }, { 11371, 0xeb8d }, { 11381, 0xfffd },
+ { 11396, 0xadff }, { 11409, 0xcbb3 }, { 11419, 0x84ef }, { 11428, 0xe17f },
+ { 11439, 0x4daa }, { 11447, 0xbff0 }, { 11458, 0xbf3f }, { 11471, 0xfe3f },
+ /* 0x9100 */
+ { 11484, 0xebff }, { 11498, 0xffd7 }, { 11512, 0xffdf }, { 11527, 0xcf7f },
+ { 11540, 0xfffb }, { 11555, 0x85ed }, { 11564, 0xd73f }, { 11576, 0x07bc },
+ { 11584, 0xaeff }, { 11597, 0xfe0f }, { 11608, 0xfdaf }, { 11621, 0x76bf },
+ { 11633, 0xfaef }, { 11646, 0x37bb }, { 11657, 0x7fdc }, { 11669, 0xa3ba },
+ /* 0x9200 */
+ { 11678, 0xb6ff }, { 11691, 0x56f7 }, { 11702, 0x60f8 }, { 11709, 0xe7df },
+ { 11722, 0xff61 }, { 11733, 0x4cdf }, { 11743, 0xb0fb }, { 11753, 0xff45 },
+ { 11764, 0x7ded }, { 11776, 0x3ffa }, { 11788, 0x1fff }, { 11801, 0x18fc },
+ { 11809, 0xffff }, { 11825, 0xe3af }, { 11836, 0xc7d3 }, { 11846, 0xdf83 },
+ /* 0x9300 */
+ { 11856, 0xfb57 }, { 11868, 0xef7d }, { 11881, 0xefff }, { 11896, 0x1378 },
+ { 11903, 0xfec0 }, { 11912, 0x5ff7 }, { 11925, 0x34bb }, { 11934, 0x5ee3 },
+ { 11944, 0xf70d }, { 11954, 0xeff6 }, { 11967, 0xd7fe }, { 11980, 0x00bf },
+ { 11987, 0xf59d }, { 11998, 0xf7f7 }, { 12012, 0x51de }, { 12021, 0xffe0 },
+ /* 0x9400 */
+ { 12032, 0xfec9 }, { 12043, 0x037f }, { 12052, 0x5f01 }, { 12059, 0xbfef },
+ { 12073, 0x9ff1 }, { 12084, 0x60a7 }, { 12091, 0xef1d }, { 12102, 0xf1ff },
+ { 12115, 0x000f }, { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x0000 },
+ { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x0000 },
+ /* 0x9500 */
+ { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x0000 },
+ { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x3c80 },
+ { 12124, 0xfb4d }, { 12135, 0xd91f }, { 12145, 0x7b3a }, { 12155, 0xfee3 },
+ { 12167, 0x3fe9 }, { 12178, 0xdc7f }, { 12190, 0x003f }, { 12196, 0x0000 },
+ /* 0x9600 */
+ { 12196, 0x0000 }, { 12196, 0x5000 }, { 12198, 0xf51f }, { 12209, 0xbe07 },
+ { 12218, 0xfc1d }, { 12228, 0xf91b }, { 12238, 0xbc1e }, { 12247, 0x71ff },
+ { 12259, 0x6ff9 }, { 12271, 0x5bbe }, { 12282, 0x5796 }, { 12291, 0x9b1b },
+ { 12300, 0x7fff }, { 12315, 0xfffc }, { 12329, 0x872e }, { 12337, 0xafe7 },
+ /* 0x9700 */
+ { 12349, 0xebf5 }, { 12361, 0xf34f }, { 12372, 0xdffd }, { 12386, 0xe725 },
+ { 12395, 0x0bdc }, { 12403, 0x5d44 }, { 12410, 0x5747 }, { 12419, 0xfddd },
+ { 12432, 0xed3f }, { 12444, 0x7790 }, { 12452, 0x7d7f }, { 12465, 0x8ac8 },
+ { 12471, 0xfafa }, { 12483, 0xf3f9 }, { 12495, 0x202a }, { 12499, 0xef4b },
+ /* 0x9800 */
+ { 12510, 0xf5ff }, { 12524, 0x79cf }, { 12535, 0xabd3 }, { 12545, 0x0ba5 },
+ { 12552, 0xf77a }, { 12564, 0xfb8f }, { 12576, 0x8ebd }, { 12586, 0x001f },
+ { 12591, 0x0000 }, { 12591, 0x0000 }, { 12591, 0xf300 }, { 12597, 0xfd4e },
+ { 12608, 0x1a57 }, { 12616, 0x8800 }, { 12618, 0xaeac }, { 12627, 0x7654 },
+ /* 0x9900 */
+ { 12635, 0x17ad }, { 12644, 0xcdff }, { 12657, 0xffb2 }, { 12669, 0xf42f },
+ { 12679, 0x5baa }, { 12688, 0xdbff }, { 12702, 0x0002 }, { 12703, 0x0000 },
+ { 12703, 0x0000 }, { 12703, 0x73c0 }, { 12710, 0xf9ea }, { 12721, 0x2e3f },
+ { 12731, 0xfa8e }, { 12741, 0xbbff }, { 12755, 0x76bc }, { 12765, 0xffd3 },
+ /* 0x9a00 */
+ { 12778, 0xeefe }, { 12791, 0x7e72 }, { 12801, 0x7ebd }, { 12813, 0xe7f7 },
+ { 12826, 0xf77f }, { 12840, 0xcefd }, { 12852, 0x0ff5 }, { 12862, 0x0000 },
+ { 12862, 0x0000 }, { 12862, 0x0000 }, { 12862, 0xa900 }, { 12866, 0xdb9b },
+ { 12877, 0xa4c7 }, { 12885, 0x917f }, { 12895, 0xf8ca }, { 12904, 0x7ece },
+ /* 0x9b00 */
+ { 12915, 0x7d7a }, { 12926, 0xc7e7 }, { 12937, 0xcbbd }, { 12948, 0xdcae },
+ { 12958, 0xfd7e }, { 12971, 0x8f76 }, { 12981, 0x91d3 }, { 12989, 0x7cf3 },
+ { 13000, 0x01e5 }, { 13006, 0x4c2f }, { 13014, 0xed77 }, { 13026, 0xa360 },
+ { 13032, 0x07db }, { 13041, 0x5ef8 }, { 13051, 0x1df7 }, { 13062, 0x2181 },
+ /* 0x9c00 */
+ { 13066, 0x6be0 }, { 13074, 0x309c }, { 13080, 0x3b3a }, { 13089, 0xfade },
+ { 13101, 0x7f53 }, { 13112, 0xc3f5 }, { 13122, 0x61cd }, { 13130, 0x07ba },
+ { 13138, 0x0000 }, { 13138, 0x0000 }, { 13138, 0x0000 }, { 13138, 0x0000 },
+ { 13138, 0x0000 }, { 13138, 0x0000 }, { 13138, 0x26e0 }, { 13144, 0xbefe },
+ /* 0x9d00 */
+ { 13157, 0x03f9 }, { 13165, 0xebb5 }, { 13176, 0xe36d }, { 13186, 0xe9cb },
+ { 13196, 0x9c2f }, { 13205, 0xbfde }, { 13218, 0x9f83 }, { 13227, 0xabbf },
+ { 13239, 0x1ff7 }, { 13251, 0xffd5 }, { 13264, 0xb7df }, { 13277, 0xdffe },
+ { 13291, 0xfdae }, { 13303, 0xffef }, { 13318, 0xfb7e }, { 13331, 0xeffd },
+ /* 0x9e00 */
+ { 13345, 0xaaff }, { 13357, 0x6ebf }, { 13369, 0x0000 }, { 13369, 0x0000 },
+ { 13369, 0x0000 }, { 13369, 0x0000 }, { 13369, 0x0000 }, { 13369, 0xb620 },
+ { 13375, 0x7fcd }, { 13387, 0xbe9e }, { 13398, 0x62b3 }, { 13406, 0x58f1 },
+ { 13414, 0xf10d }, { 13422, 0xfd7b }, { 13435, 0xe9f1 }, { 13445, 0xbefd },
+ /* 0x9f00 */
+ { 13458, 0xc6c3 }, { 13466, 0x5f6d }, { 13477, 0xff3d }, { 13490, 0x69ff },
+ { 13502, 0xffcf }, { 13516, 0xfbf4 }, { 13528, 0xdcfb }, { 13540, 0x4ff7 },
+ { 13552, 0x2000 }, { 13553, 0x1137 }, { 13560, 0x0015 },
+};
+static const Summary16 big5_uni2indx_pagefa[1] = {
+ /* 0xfa00 */
+ { 13563, 0x3000 },
+};
+static const Summary16 big5_uni2indx_pagefe[23] = {
+ /* 0xfe00 */
+ { 13565, 0x0000 }, { 13565, 0x0000 }, { 13565, 0x0000 }, { 13565, 0xfffb },
+ { 13580, 0xfe1f }, { 13592, 0xfef5 }, { 13605, 0x0e7f }, { 13615, 0x0000 },
+ { 13615, 0x0000 }, { 13615, 0x0000 }, { 13615, 0x0000 }, { 13615, 0x0000 },
+ { 13615, 0x0000 }, { 13615, 0x0000 }, { 13615, 0x0000 }, { 13615, 0x0000 },
+ /* 0xff00 */
+ { 13615, 0xff7a }, { 13628, 0xffff }, { 13644, 0xffff }, { 13660, 0x97ff },
+ { 13673, 0xfffe }, { 13688, 0x3fff }, { 13702, 0x0010 },
+};
+
+static int
+big5_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ if (n >= 2) {
+ const Summary16 *summary = NULL;
+ if (wc < 0x0100)
+ summary = &big5_uni2indx_page00[(wc>>4)];
+ else if (wc >= 0x0200 && wc < 0x0460)
+ summary = &big5_uni2indx_page02[(wc>>4)-0x020];
+ else if (wc >= 0x2000 && wc < 0x22c0)
+ summary = &big5_uni2indx_page20[(wc>>4)-0x200];
+ else if (wc >= 0x2400 && wc < 0x2650)
+ summary = &big5_uni2indx_page24[(wc>>4)-0x240];
+ else if (wc >= 0x3000 && wc < 0x33e0)
+ summary = &big5_uni2indx_page30[(wc>>4)-0x300];
+ else if (wc >= 0x4e00 && wc < 0x9fb0)
+ summary = &big5_uni2indx_page4e[(wc>>4)-0x4e0];
+ else if (wc >= 0xfa00 && wc < 0xfa10)
+ summary = &big5_uni2indx_pagefa[(wc>>4)-0xfa0];
+ else if (wc >= 0xfe00 && wc < 0xff70)
+ summary = &big5_uni2indx_pagefe[(wc>>4)-0xfe0];
+ if (summary) {
+ unsigned short used = summary->used;
+ unsigned int i = wc & 0x0f;
+ if (used & ((unsigned short) 1 << i)) {
+ unsigned short c;
+ /* Keep in `used' only the bits 0..i-1. */
+ used &= ((unsigned short) 1 << i) - 1;
+ /* Add `summary->indx' and the number of bits set in `used'. */
+ used = (used & 0x5555) + ((used & 0xaaaa) >> 1);
+ used = (used & 0x3333) + ((used & 0xcccc) >> 2);
+ used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4);
+ used = (used & 0x00ff) + (used >> 8);
+ c = big5_2charset[summary->indx + used];
+ r[0] = (c >> 8); r[1] = (c & 0xff);
+ return 2;
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOSMALL;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/big5_emacs.h b/nx-X11/lib/X11/lcUniConv/big5_emacs.h
new file mode 100644
index 000000000..4a8f6ed51
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/big5_emacs.h
@@ -0,0 +1,164 @@
+/* $XFree86$ */
+
+/*
+ * BIG5-0 and BIG5-1
+ */
+
+/*
+ BIG5 with its 13494 characters doesn't fit in a single 94x94 or 96x96
+ block. Therefore Emacs/Mule developers, in a typically Japanese way of
+ thinking, have developed an alternative encoding of BIG5 in two 94x94
+ planes, very similar to the SHIFT_JIS encoding for JISX0208.
+
+ Conversion between BIG5 codes (s1,s2) and BIG5-0 codes (c1,c2):
+ Example. (s1,s2) = 0xA140, (c1,c2) = 0x2121.
+ 0xA1 <= s1 <= 0xC7, 0x40 <= s2 <= 0x7E || 0xA1 <= s2 <= 0xFE,
+ 0x21 <= c1 <= 0x62, 0x21 <= c2 <= 0x7E.
+ Invariant:
+ 157*(s1-0xA1) + (s2 < 0x80 ? s2-0x40 : s2-0x62)
+ = 94*(c1-0x21)+(c2-0x21)
+ Conversion (s1,s2) -> (c1,c2):
+ t := 157*(s1-0xA1) + (s2 < 0x80 ? s2-0x40 : s2-0x62)
+ c1 := (t div 94) + 0x21
+ c2 := (t mod 94) + 0x21
+ Conversion (c1,c2) -> (s1,s2):
+ t := 94*(c1-0x21)+(c2-0x21)
+ t2 := t mod 157
+ s1 := (t div 157) + 0xA1
+ s2 := (t2 < 0x3F ? t2+0x40 : t2+0x62)
+
+ Conversion between BIG5 codes (s1,s2) and BIG5-1 codes (c1,c2):
+ Example. (s1,s2) = 0xC940, (c1,c2) = 0x2121.
+ 0xC9 <= s1 <= 0xF9, 0x40 <= s2 <= 0x7E || 0xA1 <= s2 <= 0xFE,
+ 0x21 <= c1 <= 0x72, 0x21 <= c2 <= 0x7E.
+ Invariant:
+ 157*(s1-0xC9) + (s2 < 0x80 ? s2-0x40 : s2-0x62)
+ = 94*(c1-0x21)+(c2-0x21)
+ Conversion (s1,s2) -> (c1,c2):
+ t := 157*(s1-0xC9) + (s2 < 0x80 ? s2-0x40 : s2-0x62)
+ c1 := (t div 94) + 0x21
+ c2 := (t mod 94) + 0x21
+ Conversion (c1,c2) -> (s1,s2):
+ t := 94*(c1-0x21)+(c2-0x21)
+ t2 := t mod 157
+ s1 := (t div 157) + 0xC9
+ s2 := (t2 < 0x3F ? t2+0x40 : t2+0x62)
+ */
+
+static int
+big5_0_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c1 = s[0];
+ if (c1 >= 0x21 && c1 <= 0x62) {
+ if (n >= 2) {
+ unsigned char c2 = s[1];
+ if (c2 >= 0x21 && c2 <= 0x7e) {
+ unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21);
+ if (0) {
+ /* Unoptimized. */
+ unsigned char buf[2];
+ buf[0] = (i / 157) + 0xa1;
+ i = i % 157;
+ buf[1] = i + (i < 0x3f ? 0x40 : 0x62);
+ return big5_mbtowc(conv,pwc,buf,2);
+ } else {
+ /* Inline the implementation of big5_mbtowc. */
+ if (i < 6121) {
+ unsigned short wc = big5_2uni_pagea1[i];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 2;
+ }
+ }
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOFEW(0);
+ }
+ return RET_ILSEQ;
+}
+
+static int
+big5_1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c1 = s[0];
+ if (c1 >= 0x21 && c1 <= 0x72) {
+ if (n >= 2) {
+ unsigned char c2 = s[1];
+ if (c2 >= 0x21 && c2 <= 0x7e) {
+ unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21);
+ if (0) {
+ /* Unoptimized. */
+ unsigned char buf[2];
+ buf[0] = (i / 157) + 0xc9;
+ i = i % 157;
+ buf[1] = i + (i < 0x3f ? 0x40 : 0x62);
+ return big5_mbtowc(conv,pwc,buf,2);
+ } else {
+ /* Inline the implementation of big5_mbtowc. */
+ if (i < 7652) {
+ unsigned short wc = big5_2uni_pagec9[i];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 2;
+ }
+ }
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOFEW(0);
+ }
+ return RET_ILSEQ;
+}
+
+static int
+big5_0_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ if (n >= 2) {
+ unsigned char buf[2];
+ int ret = big5_wctomb(conv,buf,wc,2);
+ if (ret != RET_ILSEQ) {
+ unsigned char s1, s2;
+ if (ret != 2) abort();
+ s1 = buf[0];
+ s2 = buf[1];
+ if (!(s1 >= 0xa1)) abort();
+ if (!((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0xa1 && s2 <= 0xfe))) abort();
+ if (s1 < 0xc9) {
+ unsigned int t = 157 * (s1 - 0xa1) + s2 - (s2 < 0x80 ? 0x40 : 0x62);
+ r[0] = (t / 94) + 0x21;
+ r[1] = (t % 94) + 0x21;
+ return 2;
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOSMALL;
+}
+
+static int
+big5_1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ if (n >= 2) {
+ unsigned char buf[2];
+ int ret = big5_wctomb(conv,buf,wc,2);
+ if (ret != RET_ILSEQ) {
+ unsigned char s1, s2;
+ if (ret != 2) abort();
+ s1 = buf[0];
+ s2 = buf[1];
+ if (!(s1 <= 0xf9)) abort();
+ if (!((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0xa1 && s2 <= 0xfe))) abort();
+ if (s1 >= 0xc9) {
+ unsigned int t = 157 * (s1 - 0xc9) + s2 - (s2 < 0x80 ? 0x40 : 0x62);
+ r[0] = (t / 94) + 0x21;
+ r[1] = (t % 94) + 0x21;
+ return 2;
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOSMALL;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/cjk_tab_to_h.c b/nx-X11/lib/X11/lcUniConv/cjk_tab_to_h.c
new file mode 100644
index 000000000..f3cc1e0e4
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/cjk_tab_to_h.c
@@ -0,0 +1,1025 @@
+/* $XFree86$ */
+
+/*
+ * Generates a CJK character set table from a .TXT table as found on
+ * ftp.unicode.org or in the X nls directory.
+ * Examples:
+ *
+ * ./cjk_tab_to_h GB2312.1980-0 gb2312 > gb2312.h < gb2312
+ * ./cjk_tab_to_h JISX0208.1983-0 jisx0208 > jisx0208.h < jis0208
+ * ./cjk_tab_to_h KSC5601.1987-0 ksc5601 > ksc5601.h < ksc5601
+ *
+ * ./cjk_tab_to_h GB2312.1980-0 gb2312 > gb2312.h < GB2312.TXT
+ * ./cjk_tab_to_h JISX0208.1983-0 jisx0208 > jisx0208.h < JIS0208.TXT
+ * ./cjk_tab_to_h JISX0212.1990-0 jisx0212 > jisx0212.h < JIS0212.TXT
+ * ./cjk_tab_to_h KSC5601.1987-0 ksc5601 > ksc5601.h < KSC5601.TXT
+ * ./cjk_tab_to_h KSX1001.1992-0 ksc5601 > ksc5601.h < KSX1001.TXT
+ *
+ * ./cjk_tab_to_h BIG5 big5 > big5.h < BIG5.TXT
+ *
+ * ./cjk_tab_to_h JOHAB johab > johab.h < JOHAB.TXT
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+
+typedef struct {
+ int start;
+ int end;
+} Block;
+
+typedef struct {
+ int rows; /* number of possible values for the 1st byte */
+ int cols; /* number of possible values for the 2nd byte */
+ int (*row_byte) (int row); /* returns the 1st byte value for a given row */
+ int (*col_byte) (int col); /* returns the 2nd byte value for a given col */
+ int (*byte_row) (int byte); /* converts a 1st byte value to a row, else -1 */
+ int (*byte_col) (int byte); /* converts a 2nd byte value to a col, else -1 */
+ const char* check_row_expr; /* format string for 1st byte value checking */
+ const char* check_col_expr; /* format string for 2nd byte value checking */
+ const char* byte_row_expr; /* format string for 1st byte value to row */
+ const char* byte_col_expr; /* format string for 2nd byte value to col */
+ int** charset2uni; /* charset2uni[0..rows-1][0..cols-1] is valid */
+ /* You'll understand the terms "row" and "col" when you buy Ken Lunde's book.
+ Once a row is fixed, choosing a "col" is the same as choosing a "cell". */
+ int* charsetpage; /* charsetpage[0..rows]: how large is a page for a row */
+ int ncharsetblocks;
+ Block* charsetblocks; /* blocks[0..nblocks-1] */
+ int* uni2charset; /* uni2charset[0x0000..0xffff] */
+} Encoding;
+
+/*
+ * Outputs the file title.
+ */
+static void output_title (const char *charsetname)
+{
+ printf("\n");
+ printf("/*\n");
+ printf(" * %s\n", charsetname);
+ printf(" */\n");
+ printf("\n");
+}
+
+/*
+ * Reads the charset2uni table from standard input.
+ */
+static void read_table (Encoding* enc)
+{
+ int row, col, i, i1, i2, c, j;
+
+ enc->charset2uni = (int**) malloc(enc->rows*sizeof(int*));
+ for (row = 0; row < enc->rows; row++)
+ enc->charset2uni[row] = (int*) malloc(enc->cols*sizeof(int));
+
+ for (row = 0; row < enc->rows; row++)
+ for (col = 0; col < enc->cols; col++)
+ enc->charset2uni[row][col] = 0xfffd;
+
+ c = getc(stdin);
+ ungetc(c,stdin);
+ if (c == '#') {
+ /* Read a unicode.org style .TXT file. */
+ for (;;) {
+ c = getc(stdin);
+ if (c == EOF)
+ break;
+ if (c == '\n' || c == ' ' || c == '\t')
+ continue;
+ if (c == '#') {
+ do { c = getc(stdin); } while (!(c == EOF || c == '\n'));
+ continue;
+ }
+ ungetc(c,stdin);
+ if (scanf("0x%x", &j) != 1)
+ exit(1);
+ i1 = j >> 8;
+ i2 = j & 0xff;
+ row = enc->byte_row(i1);
+ col = enc->byte_col(i2);
+ if (row < 0 || col < 0) {
+ fprintf(stderr, "lost entry for %02x %02x\n", i1, i2);
+ exit(1);
+ }
+ if (scanf(" 0x%x", &enc->charset2uni[row][col]) != 1)
+ exit(1);
+ }
+ } else {
+ /* Read a table of hexadecimal Unicode values. */
+ for (i1 = 32; i1 < 132; i1++)
+ for (i2 = 32; i2 < 132; i2++) {
+ i = scanf("%x", &j);
+ if (i == EOF)
+ goto read_done;
+ if (i != 1)
+ exit(1);
+ if (j < 0 || j == 0xffff)
+ j = 0xfffd;
+ if (j != 0xfffd) {
+ if (enc->byte_row(i1) < 0 || enc->byte_col(i2) < 0) {
+ fprintf(stderr, "lost entry at %02x %02x\n", i1, i2);
+ exit (1);
+ }
+ enc->charset2uni[enc->byte_row(i1)][enc->byte_col(i2)] = j;
+ }
+ }
+ read_done: ;
+ }
+}
+
+/*
+ * Computes the charsetpage[0..rows] array.
+ */
+static void find_charset2uni_pages (Encoding* enc)
+{
+ int row, col;
+
+ enc->charsetpage = (int*) malloc((enc->rows+1)*sizeof(int));
+
+ for (row = 0; row <= enc->rows; row++)
+ enc->charsetpage[row] = 0;
+
+ for (row = 0; row < enc->rows; row++) {
+ int used = 0;
+ for (col = 0; col < enc->cols; col++)
+ if (enc->charset2uni[row][col] != 0xfffd)
+ used = col+1;
+ enc->charsetpage[row] = used;
+ }
+}
+
+/*
+ * Fills in nblocks and blocks.
+ */
+static void find_charset2uni_blocks (Encoding* enc)
+{
+ int n, row, lastrow;
+
+ enc->charsetblocks = (Block*) malloc(enc->rows*sizeof(Block));
+
+ n = 0;
+ for (row = 0; row < enc->rows; row++)
+ if (enc->charsetpage[row] > 0 && (row == 0 || enc->charsetpage[row-1] == 0)) {
+ for (lastrow = row; enc->charsetpage[lastrow+1] > 0; lastrow++);
+ enc->charsetblocks[n].start = row * enc->cols;
+ enc->charsetblocks[n].end = lastrow * enc->cols + enc->charsetpage[lastrow];
+ n++;
+ }
+ enc->ncharsetblocks = n;
+}
+
+/*
+ * Outputs the charset to unicode table and function.
+ */
+static void output_charset2uni (const char* name, Encoding* enc)
+{
+ int row, col, lastrow, col_max, i, i1_min, i1_max;
+
+ find_charset2uni_pages(enc);
+
+ find_charset2uni_blocks(enc);
+
+ for (row = 0; row < enc->rows; row++)
+ if (enc->charsetpage[row] > 0) {
+ if (row == 0 || enc->charsetpage[row-1] == 0) {
+ /* Start a new block. */
+ for (lastrow = row; enc->charsetpage[lastrow+1] > 0; lastrow++);
+ printf("static const unsigned short %s_2uni_page%02x[%d] = {\n",
+ name, enc->row_byte(row),
+ (lastrow-row) * enc->cols + enc->charsetpage[lastrow]);
+ }
+ printf(" /""* 0x%02x *""/\n ", enc->row_byte(row));
+ col_max = (enc->charsetpage[row+1] > 0 ? enc->cols : enc->charsetpage[row]);
+ for (col = 0; col < col_max; col++) {
+ printf(" 0x%04x,", enc->charset2uni[row][col]);
+ if ((col % 8) == 7 && (col+1 < col_max)) printf("\n ");
+ }
+ printf("\n");
+ if (enc->charsetpage[row+1] == 0) {
+ /* End a block. */
+ printf("};\n");
+ }
+ }
+ printf("\n");
+
+ printf("static int\n");
+ printf("%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)\n", name);
+ printf("{\n");
+ printf(" unsigned char c1 = s[0];\n");
+ printf(" if (");
+ for (i = 0; i < enc->ncharsetblocks; i++) {
+ i1_min = enc->row_byte(enc->charsetblocks[i].start / enc->cols);
+ i1_max = enc->row_byte((enc->charsetblocks[i].end-1) / enc->cols);
+ if (i > 0)
+ printf(" || ");
+ if (i1_min == i1_max)
+ printf("(c1 == 0x%02x)", i1_min);
+ else
+ printf("(c1 >= 0x%02x && c1 <= 0x%02x)", i1_min, i1_max);
+ }
+ printf(") {\n");
+ printf(" if (n >= 2) {\n");
+ printf(" unsigned char c2 = s[1];\n");
+ printf(" if (");
+ printf(enc->check_col_expr, "c2");
+ printf(") {\n");
+ printf(" unsigned int i = %d * (", enc->cols);
+ printf(enc->byte_row_expr, "c1");
+ printf(") + (");
+ printf(enc->byte_col_expr, "c2");
+ printf(");\n");
+ printf(" unsigned short wc = 0xfffd;\n");
+ for (i = 0; i < enc->ncharsetblocks; i++) {
+ printf(" ");
+ if (i > 0)
+ printf("} else ");
+ if (i < enc->ncharsetblocks-1)
+ printf("if (i < %d) ", enc->charsetblocks[i+1].start);
+ printf("{\n");
+ printf(" if (i < %d)\n", enc->charsetblocks[i].end);
+ printf(" wc = %s_2uni_page%02x[i", name, enc->row_byte(enc->charsetblocks[i].start / enc->cols));
+ if (enc->charsetblocks[i].start > 0)
+ printf("-%d", enc->charsetblocks[i].start);
+ printf("];\n");
+ }
+ printf(" }\n");
+ printf(" if (wc != 0xfffd) {\n");
+ printf(" *pwc = (ucs4_t) wc;\n");
+ printf(" return 2;\n");
+ printf(" }\n");
+ printf(" }\n");
+ printf(" return RET_ILSEQ;\n");
+ printf(" }\n");
+ printf(" return RET_TOOFEW(0);\n");
+ printf(" }\n");
+ printf(" return RET_ILSEQ;\n");
+ printf("}\n");
+ printf("\n");
+}
+
+/*
+ * Computes the uni2charset[0x0000..0xffff] array.
+ */
+static void invert (Encoding* enc)
+{
+ int row, col, j;
+
+ enc->uni2charset = (int*) malloc(0x10000*sizeof(int));
+
+ for (j = 0; j < 0x10000; j++)
+ enc->uni2charset[j] = 0;
+
+ for (row = 0; row < enc->rows; row++)
+ for (col = 0; col < enc->cols; col++) {
+ j = enc->charset2uni[row][col];
+ if (j != 0xfffd)
+ enc->uni2charset[j] = 0x100 * enc->row_byte(row) + enc->col_byte(col);
+ }
+}
+
+/*
+ * Outputs the unicode to charset table and function, using a linear array.
+ * (Suitable if the table is dense.)
+ */
+static void output_uni2charset_dense (const char* name, Encoding* enc)
+{
+ /* Like in 8bit_tab_to_h.c */
+ bool pages[0x100];
+ int line[0x2000];
+ int tableno;
+ struct { int minline; int maxline; int usecount; } tables[0x2000];
+ bool first;
+ int row, col, j, p, j1, j2, t;
+
+ for (p = 0; p < 0x100; p++)
+ pages[p] = false;
+ for (row = 0; row < enc->rows; row++)
+ for (col = 0; col < enc->cols; col++) {
+ j = enc->charset2uni[row][col];
+ if (j != 0xfffd)
+ pages[j>>8] = true;
+ }
+ for (j1 = 0; j1 < 0x2000; j1++) {
+ bool all_invalid = true;
+ for (j2 = 0; j2 < 8; j2++) {
+ j = 8*j1+j2;
+ if (enc->uni2charset[j] != 0)
+ all_invalid = false;
+ }
+ if (all_invalid)
+ line[j1] = -1;
+ else
+ line[j1] = 0;
+ }
+ tableno = 0;
+ for (j1 = 0; j1 < 0x2000; j1++) {
+ if (line[j1] >= 0) {
+ if (tableno > 0
+ && ((j1 > 0 && line[j1-1] == tableno-1)
+ || ((tables[tableno-1].maxline >> 5) == (j1 >> 5)
+ && j1 - tables[tableno-1].maxline <= 8))) {
+ line[j1] = tableno-1;
+ tables[tableno-1].maxline = j1;
+ } else {
+ tableno++;
+ line[j1] = tableno-1;
+ tables[tableno-1].minline = tables[tableno-1].maxline = j1;
+ }
+ }
+ }
+ for (t = 0; t < tableno; t++) {
+ tables[t].usecount = 0;
+ j1 = 8*tables[t].minline;
+ j2 = 8*(tables[t].maxline+1);
+ for (j = j1; j < j2; j++)
+ if (enc->uni2charset[j] != 0)
+ tables[t].usecount++;
+ }
+ {
+ p = -1;
+ for (t = 0; t < tableno; t++)
+ if (tables[t].usecount > 1) {
+ p = tables[t].minline >> 5;
+ printf("static const unsigned short %s_page%02x[%d] = {\n", name, p, 8*(tables[t].maxline-tables[t].minline+1));
+ for (j1 = tables[t].minline; j1 <= tables[t].maxline; j1++) {
+ if ((j1 % 0x20) == 0 && j1 > tables[t].minline)
+ printf(" /* 0x%04x */\n", 8*j1);
+ printf(" ");
+ for (j2 = 0; j2 < 8; j2++) {
+ j = 8*j1+j2;
+ printf(" 0x%04x,", enc->uni2charset[j]);
+ }
+ printf(" /*0x%02x-0x%02x*/\n", 8*(j1 % 0x20), 8*(j1 % 0x20)+7);
+ }
+ printf("};\n");
+ }
+ if (p >= 0)
+ printf("\n");
+ }
+ printf("static int\n%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", name);
+ printf("{\n");
+ printf(" if (n >= 2) {\n");
+ printf(" unsigned short c = 0;\n");
+ first = true;
+ for (j1 = 0; j1 < 0x2000;) {
+ t = line[j1];
+ for (j2 = j1; j2 < 0x2000 && line[j2] == t; j2++);
+ if (t >= 0) {
+ if (j1 != tables[t].minline) abort();
+ if (j2 > tables[t].maxline+1) abort();
+ j2 = tables[t].maxline+1;
+ if (first)
+ printf(" ");
+ else
+ printf(" else ");
+ first = false;
+ if (tables[t].usecount == 0) abort();
+ if (tables[t].usecount == 1) {
+ if (j2 != j1+1) abort();
+ for (j = 8*j1; j < 8*j2; j++)
+ if (enc->uni2charset[j] != 0) {
+ printf("if (wc == 0x%04x)\n c = 0x%02x;\n", j, enc->uni2charset[j]);
+ break;
+ }
+ } else {
+ if (j1 == 0) {
+ printf("if (wc < 0x%04x)", 8*j2);
+ } else {
+ printf("if (wc >= 0x%04x && wc < 0x%04x)", 8*j1, 8*j2);
+ }
+ printf("\n c = %s_page%02x[wc", name, j1 >> 5);
+ if (tables[t].minline > 0)
+ printf("-0x%04x", 8*j1);
+ printf("];\n");
+ }
+ }
+ j1 = j2;
+ }
+ printf(" if (c != 0) {\n");
+ printf(" r[0] = (c >> 8); r[1] = (c & 0xff);\n");
+ printf(" return 2;\n");
+ printf(" }\n");
+ printf(" return RET_ILSEQ;\n");
+ printf(" }\n");
+ printf(" return RET_TOOSMALL;\n");
+ printf("}\n");
+}
+
+/*
+ * Outputs the unicode to charset table and function, using a packed array.
+ * (Suitable if the table is sparse.)
+ */
+static void output_uni2charset_sparse (const char* name, Encoding* enc)
+{
+ bool pages[0x100];
+ Block pageblocks[0x100]; int npageblocks;
+ int indx2charset[0x10000];
+ int summary_indx[0x1000];
+ int summary_used[0x1000];
+ int i, row, col, j, p, j1, j2, indx;
+
+ /* Fill pages[0x100]. */
+ for (p = 0; p < 0x100; p++)
+ pages[p] = false;
+ for (row = 0; row < enc->rows; row++)
+ for (col = 0; col < enc->cols; col++) {
+ j = enc->charset2uni[row][col];
+ if (j != 0xfffd)
+ pages[j>>8] = true;
+ }
+
+#if 0
+ for (p = 0; p < 0x100; p++)
+ if (pages[p]) {
+ printf("static const unsigned short %s_page%02x[256] = {\n", name, p);
+ for (j1 = 0; j1 < 32; j1++) {
+ printf(" ");
+ for (j2 = 0; j2 < 8; j2++)
+ printf("0x%04x, ", enc->uni2charset[256*p+8*j1+j2]);
+ printf("/""*0x%02x-0x%02x*""/\n", 8*j1, 8*j1+7);
+ }
+ printf("};\n");
+ }
+ printf("\n");
+#endif
+
+ /* Fill summary_indx[] and summary_used[]. */
+ indx = 0;
+ for (j1 = 0; j1 < 0x1000; j1++) {
+ summary_indx[j1] = indx;
+ summary_used[j1] = 0;
+ for (j2 = 0; j2 < 16; j2++) {
+ j = 16*j1+j2;
+ if (enc->uni2charset[j] != 0) {
+ indx2charset[indx++] = enc->uni2charset[j];
+ summary_used[j1] |= (1 << j2);
+ }
+ }
+ }
+
+ /* Fill npageblocks and pageblocks[]. */
+ npageblocks = 0;
+ for (p = 0; p < 0x100; ) {
+ if (pages[p] && (p == 0 || !pages[p-1])) {
+ pageblocks[npageblocks].start = 16*p;
+ do p++; while (p < 0x100 && pages[p]);
+ j1 = 16*p;
+ while (summary_used[j1-1] == 0) j1--;
+ pageblocks[npageblocks].end = j1;
+ npageblocks++;
+ } else
+ p++;
+ }
+
+ printf("static const unsigned short %s_2charset[%d] = {\n", name, indx);
+ for (i = 0; i < indx; ) {
+ if ((i % 8) == 0) printf(" ");
+ printf(" 0x%04x,", indx2charset[i]);
+ i++;
+ if ((i % 8) == 0 || i == indx) printf("\n");
+ }
+ printf("};\n");
+ printf("\n");
+ for (i = 0; i < npageblocks; i++) {
+ printf("static const Summary16 %s_uni2indx_page%02x[%d] = {\n", name,
+ pageblocks[i].start/16, pageblocks[i].end-pageblocks[i].start);
+ for (j1 = pageblocks[i].start; j1 < pageblocks[i].end; ) {
+ if (((16*j1) % 0x100) == 0) printf(" /""* 0x%04x *""/\n", 16*j1);
+ if ((j1 % 4) == 0) printf(" ");
+ printf(" { %4d, 0x%04x },", summary_indx[j1], summary_used[j1]);
+ j1++;
+ if ((j1 % 4) == 0 || j1 == pageblocks[i].end) printf("\n");
+ }
+ printf("};\n");
+ }
+ printf("\n");
+
+ printf("static int\n");
+ printf("%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", name);
+ printf("{\n");
+ printf(" if (n >= 2) {\n");
+ printf(" const Summary16 *summary = NULL;\n");
+ for (i = 0; i < npageblocks; i++) {
+ printf(" ");
+ if (i > 0)
+ printf("else ");
+ printf("if (wc >= 0x%04x && wc < 0x%04x)\n",
+ 16*pageblocks[i].start, 16*pageblocks[i].end);
+ printf(" summary = &%s_uni2indx_page%02x[(wc>>4)", name,
+ pageblocks[i].start/16);
+ if (pageblocks[i].start > 0)
+ printf("-0x%03x", pageblocks[i].start);
+ printf("];\n");
+ }
+ printf(" if (summary) {\n");
+ printf(" unsigned short used = summary->used;\n");
+ printf(" unsigned int i = wc & 0x0f;\n");
+ printf(" if (used & ((unsigned short) 1 << i)) {\n");
+ printf(" unsigned short c;\n");
+ printf(" /* Keep in `used' only the bits 0..i-1. */\n");
+ printf(" used &= ((unsigned short) 1 << i) - 1;\n");
+ printf(" /* Add `summary->indx' and the number of bits set in `used'. */\n");
+ printf(" used = (used & 0x5555) + ((used & 0xaaaa) >> 1);\n");
+ printf(" used = (used & 0x3333) + ((used & 0xcccc) >> 2);\n");
+ printf(" used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4);\n");
+ printf(" used = (used & 0x00ff) + (used >> 8);\n");
+ printf(" c = %s_2charset[summary->indx + used];\n", name);
+ printf(" r[0] = (c >> 8); r[1] = (c & 0xff);\n");
+ printf(" return 2;\n");
+ printf(" }\n");
+ printf(" }\n");
+ printf(" return RET_ILSEQ;\n");
+ printf(" }\n");
+ printf(" return RET_TOOSMALL;\n");
+ printf("}\n");
+}
+
+/* ISO-2022/EUC specifics */
+
+static int row_byte_normal (int row) { return 0x21+row; }
+static int col_byte_normal (int col) { return 0x21+col; }
+static int byte_row_normal (int byte) { return byte-0x21; }
+static int byte_col_normal (int byte) { return byte-0x21; }
+
+static void do_normal (const char* name)
+{
+ Encoding enc;
+
+ enc.rows = 94;
+ enc.cols = 94;
+ enc.row_byte = row_byte_normal;
+ enc.col_byte = col_byte_normal;
+ enc.byte_row = byte_row_normal;
+ enc.byte_col = byte_col_normal;
+ enc.check_row_expr = "%1$s >= 0x21 && %1$s < 0x7f";
+ enc.check_col_expr = "%1$s >= 0x21 && %1$s < 0x7f";
+ enc.byte_row_expr = "%1$s - 0x21";
+ enc.byte_col_expr = "%1$s - 0x21";
+
+ read_table(&enc);
+ output_charset2uni(name,&enc);
+ invert(&enc); output_uni2charset_sparse(name,&enc);
+}
+
+/* Note: On first sight, the jisx0212_2charset[] table seems to be in order,
+ starting from the charset=0x3021/uni=0x4e02 pair. But it's only mostly in
+ order. There are 75 out-of-order values, scattered all throughout the table.
+ */
+
+static void do_normal_only_charset2uni (const char* name)
+{
+ Encoding enc;
+
+ enc.rows = 94;
+ enc.cols = 94;
+ enc.row_byte = row_byte_normal;
+ enc.col_byte = col_byte_normal;
+ enc.byte_row = byte_row_normal;
+ enc.byte_col = byte_col_normal;
+ enc.check_row_expr = "%1$s >= 0x21 && %1$s < 0x7f";
+ enc.check_col_expr = "%1$s >= 0x21 && %1$s < 0x7f";
+ enc.byte_row_expr = "%1$s - 0x21";
+ enc.byte_col_expr = "%1$s - 0x21";
+
+ read_table(&enc);
+ output_charset2uni(name,&enc);
+}
+
+/* CNS 11643 specifics - trick to put two tables into one */
+
+static int row_byte_cns11643 (int row) {
+ return 0x100 * (row / 94) + (row % 94) + 0x21;
+}
+static int byte_row_cns11643 (int byte) {
+ return (byte >= 0x100 && byte < 0x200 ? byte-0x121 :
+ byte >= 0x200 && byte < 0x300 ? byte-0x221+94 :
+ byte >= 0x300 && byte < 0x400 ? byte-0x321+2*94 :
+ -1);
+}
+
+static void do_cns11643_only_uni2charset (const char* name)
+{
+ Encoding enc;
+ int j, x;
+
+ enc.rows = 3*94;
+ enc.cols = 94;
+ enc.row_byte = row_byte_cns11643;
+ enc.col_byte = col_byte_normal;
+ enc.byte_row = byte_row_cns11643;
+ enc.byte_col = byte_col_normal;
+ enc.check_row_expr = "%1$s >= 0x21 && %1$s < 0x7f";
+ enc.check_col_expr = "%1$s >= 0x21 && %1$s < 0x7f";
+ enc.byte_row_expr = "%1$s - 0x21";
+ enc.byte_col_expr = "%1$s - 0x21";
+
+ read_table(&enc);
+ invert(&enc);
+ /* Move the 2 plane bits into the unused bits 15 and 7. */
+ for (j = 0; j < 0x10000; j++) {
+ x = enc.uni2charset[j];
+ if (x != 0) {
+ if (x & 0x8080) abort();
+ switch (x >> 16) {
+ case 0: /* plane 1 */ x = (x & 0xffff) | 0x0000; break;
+ case 1: /* plane 2 */ x = (x & 0xffff) | 0x0080; break;
+ case 2: /* plane 3 */ x = (x & 0xffff) | 0x8000; break;
+ default: abort();
+ }
+ enc.uni2charset[j] = x;
+ }
+ }
+ output_uni2charset_sparse(name,&enc);
+}
+
+/* GBK specifics */
+
+static int row_byte_gbk1 (int row) {
+ return 0x81+row;
+}
+static int col_byte_gbk1 (int col) {
+ return (col >= 0x3f ? 0x41 : 0x40) + col;
+}
+static int byte_row_gbk1 (int byte) {
+ if (byte >= 0x81 && byte < 0xff)
+ return byte-0x81;
+ else
+ return -1;
+}
+static int byte_col_gbk1 (int byte) {
+ if (byte >= 0x40 && byte < 0x7f)
+ return byte-0x40;
+ else if (byte >= 0x80 && byte < 0xff)
+ return byte-0x41;
+ else
+ return -1;
+}
+
+static void do_gbk1 (const char* name)
+{
+ Encoding enc;
+
+ enc.rows = 126;
+ enc.cols = 190;
+ enc.row_byte = row_byte_gbk1;
+ enc.col_byte = col_byte_gbk1;
+ enc.byte_row = byte_row_gbk1;
+ enc.byte_col = byte_col_gbk1;
+ enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff";
+ enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xff)";
+ enc.byte_row_expr = "%1$s - 0x81";
+ enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)";
+
+ read_table(&enc);
+ output_charset2uni(name,&enc);
+ invert(&enc); output_uni2charset_dense(name,&enc);
+}
+
+static void do_gbk1_only_charset2uni (const char* name)
+{
+ Encoding enc;
+
+ enc.rows = 126;
+ enc.cols = 190;
+ enc.row_byte = row_byte_gbk1;
+ enc.col_byte = col_byte_gbk1;
+ enc.byte_row = byte_row_gbk1;
+ enc.byte_col = byte_col_gbk1;
+ enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff";
+ enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xff)";
+ enc.byte_row_expr = "%1$s - 0x81";
+ enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)";
+
+ read_table(&enc);
+ output_charset2uni(name,&enc);
+}
+
+static int row_byte_gbk2 (int row) {
+ return 0x81+row;
+}
+static int col_byte_gbk2 (int col) {
+ return (col >= 0x3f ? 0x41 : 0x40) + col;
+}
+static int byte_row_gbk2 (int byte) {
+ if (byte >= 0x81 && byte < 0xff)
+ return byte-0x81;
+ else
+ return -1;
+}
+static int byte_col_gbk2 (int byte) {
+ if (byte >= 0x40 && byte < 0x7f)
+ return byte-0x40;
+ else if (byte >= 0x80 && byte < 0xa1)
+ return byte-0x41;
+ else
+ return -1;
+}
+
+static void do_gbk2_only_charset2uni (const char* name)
+{
+ Encoding enc;
+
+ enc.rows = 126;
+ enc.cols = 96;
+ enc.row_byte = row_byte_gbk2;
+ enc.col_byte = col_byte_gbk2;
+ enc.byte_row = byte_row_gbk2;
+ enc.byte_col = byte_col_gbk2;
+ enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff";
+ enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xa1)";
+ enc.byte_row_expr = "%1$s - 0x81";
+ enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)";
+
+ read_table(&enc);
+ output_charset2uni(name,&enc);
+}
+
+static void do_gbk1_only_uni2charset (const char* name)
+{
+ Encoding enc;
+
+ enc.rows = 126;
+ enc.cols = 190;
+ enc.row_byte = row_byte_gbk1;
+ enc.col_byte = col_byte_gbk1;
+ enc.byte_row = byte_row_gbk1;
+ enc.byte_col = byte_col_gbk1;
+ enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff";
+ enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xff)";
+ enc.byte_row_expr = "%1$s - 0x81";
+ enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)";
+
+ read_table(&enc);
+ invert(&enc); output_uni2charset_sparse(name,&enc);
+}
+
+/* KSC 5601 specifics */
+
+/*
+ * Reads the charset2uni table from standard input.
+ */
+static void read_table_ksc5601 (Encoding* enc)
+{
+ int row, col, i, i1, i2, c, j;
+
+ enc->charset2uni = (int**) malloc(enc->rows*sizeof(int*));
+ for (row = 0; row < enc->rows; row++)
+ enc->charset2uni[row] = (int*) malloc(enc->cols*sizeof(int));
+
+ for (row = 0; row < enc->rows; row++)
+ for (col = 0; col < enc->cols; col++)
+ enc->charset2uni[row][col] = 0xfffd;
+
+ c = getc(stdin);
+ ungetc(c,stdin);
+ if (c == '#') {
+ /* Read a unicode.org style .TXT file. */
+ for (;;) {
+ c = getc(stdin);
+ if (c == EOF)
+ break;
+ if (c == '\n' || c == ' ' || c == '\t')
+ continue;
+ if (c == '#') {
+ do { c = getc(stdin); } while (!(c == EOF || c == '\n'));
+ continue;
+ }
+ ungetc(c,stdin);
+ if (scanf("0x%x", &j) != 1)
+ exit(1);
+ i1 = j >> 8;
+ i2 = j & 0xff;
+ if (scanf(" 0x%x", &j) != 1)
+ exit(1);
+ /* Take only the range covered by KS C 5601.1987-0 = KS C 5601.1989-0
+ = KS X 1001.1992, ignore the rest. */
+ if (!(i1 >= 128+33 && i1 < 128+127 && i2 >= 128+33 && i2 < 128+127))
+ continue; /* KSC5601 specific */
+ i1 &= 0x7f; /* KSC5601 specific */
+ i2 &= 0x7f; /* KSC5601 specific */
+ row = enc->byte_row(i1);
+ col = enc->byte_col(i2);
+ if (row < 0 || col < 0) {
+ fprintf(stderr, "lost entry for %02x %02x\n", i1, i2);
+ exit(1);
+ }
+ enc->charset2uni[row][col] = j;
+ }
+ } else {
+ /* Read a table of hexadecimal Unicode values. */
+ for (i1 = 33; i1 < 127; i1++)
+ for (i2 = 33; i2 < 127; i2++) {
+ i = scanf("%x", &j);
+ if (i == EOF)
+ goto read_done;
+ if (i != 1)
+ exit(1);
+ if (j < 0 || j == 0xffff)
+ j = 0xfffd;
+ if (j != 0xfffd) {
+ if (enc->byte_row(i1) < 0 || enc->byte_col(i2) < 0) {
+ fprintf(stderr, "lost entry at %02x %02x\n", i1, i2);
+ exit (1);
+ }
+ enc->charset2uni[enc->byte_row(i1)][enc->byte_col(i2)] = j;
+ }
+ }
+ read_done: ;
+ }
+}
+
+static void do_ksc5601 (const char* name)
+{
+ Encoding enc;
+
+ enc.rows = 94;
+ enc.cols = 94;
+ enc.row_byte = row_byte_normal;
+ enc.col_byte = col_byte_normal;
+ enc.byte_row = byte_row_normal;
+ enc.byte_col = byte_col_normal;
+ enc.check_row_expr = "%1$s >= 0x21 && %1$s < 0x7f";
+ enc.check_col_expr = "%1$s >= 0x21 && %1$s < 0x7f";
+ enc.byte_row_expr = "%1$s - 0x21";
+ enc.byte_col_expr = "%1$s - 0x21";
+
+ read_table_ksc5601(&enc);
+ output_charset2uni(name,&enc);
+ invert(&enc); output_uni2charset_sparse(name,&enc);
+}
+
+/* Big5 specifics */
+
+static int row_byte_big5 (int row) {
+ return 0xa1+row;
+}
+static int col_byte_big5 (int col) {
+ return (col >= 0x3f ? 0x62 : 0x40) + col;
+}
+static int byte_row_big5 (int byte) {
+ if (byte >= 0xa1 && byte < 0xff)
+ return byte-0xa1;
+ else
+ return -1;
+}
+static int byte_col_big5 (int byte) {
+ if (byte >= 0x40 && byte < 0x7f)
+ return byte-0x40;
+ else if (byte >= 0xa1 && byte < 0xff)
+ return byte-0x62;
+ else
+ return -1;
+}
+
+static void do_big5 (const char* name)
+{
+ Encoding enc;
+
+ enc.rows = 94;
+ enc.cols = 157;
+ enc.row_byte = row_byte_big5;
+ enc.col_byte = col_byte_big5;
+ enc.byte_row = byte_row_big5;
+ enc.byte_col = byte_col_big5;
+ enc.check_row_expr = "%1$s >= 0xa1 && %1$s < 0xff";
+ enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0xa1 && %1$s < 0xff)";
+ enc.byte_row_expr = "%1$s - 0xa1";
+ enc.byte_col_expr = "%1$s - (%1$s >= 0xa1 ? 0x62 : 0x40)";
+
+ read_table(&enc);
+ output_charset2uni(name,&enc);
+ invert(&enc); output_uni2charset_sparse(name,&enc);
+}
+
+/* Johab Hangul specifics */
+
+static int row_byte_johab_hangul (int row) {
+ return 0x84+row;
+}
+static int col_byte_johab_hangul (int col) {
+ return (col >= 0x3e ? 0x43 : 0x41) + col;
+}
+static int byte_row_johab_hangul (int byte) {
+ if (byte >= 0x84 && byte < 0xd4)
+ return byte-0x84;
+ else
+ return -1;
+}
+static int byte_col_johab_hangul (int byte) {
+ if (byte >= 0x41 && byte < 0x7f)
+ return byte-0x41;
+ else if (byte >= 0x81 && byte < 0xff)
+ return byte-0x43;
+ else
+ return -1;
+}
+
+static void do_johab_hangul (const char* name)
+{
+ Encoding enc;
+
+ enc.rows = 80;
+ enc.cols = 188;
+ enc.row_byte = row_byte_johab_hangul;
+ enc.col_byte = col_byte_johab_hangul;
+ enc.byte_row = byte_row_johab_hangul;
+ enc.byte_col = byte_col_johab_hangul;
+ enc.check_row_expr = "%1$s >= 0x84 && %1$s < 0xd4";
+ enc.check_col_expr = "(%1$s >= 0x41 && %1$s < 0x7f) || (%1$s >= 0x81 && %1$s < 0xff)";
+ enc.byte_row_expr = "%1$s - 0x84";
+ enc.byte_col_expr = "%1$s - (%1$s >= 0x81 ? 0x43 : 0x41)";
+
+ read_table(&enc);
+ output_charset2uni(name,&enc);
+ invert(&enc); output_uni2charset_dense(name,&enc);
+}
+
+/* SJIS specifics */
+
+static int row_byte_sjis (int row) {
+ return (row >= 0x1f ? 0xc1 : 0x81) + row;
+}
+static int col_byte_sjis (int col) {
+ return (col >= 0x3f ? 0x41 : 0x40) + col;
+}
+static int byte_row_sjis (int byte) {
+ if (byte >= 0x81 && byte < 0xa0)
+ return byte-0x81;
+ else if (byte >= 0xe0)
+ return byte-0xc1;
+ else
+ return -1;
+}
+static int byte_col_sjis (int byte) {
+ if (byte >= 0x40 && byte < 0x7f)
+ return byte-0x40;
+ else if (byte >= 0x80 && byte < 0xfd)
+ return byte-0x41;
+ else
+ return -1;
+}
+
+static void do_sjis (const char* name)
+{
+ Encoding enc;
+
+ enc.rows = 94;
+ enc.cols = 188;
+ enc.row_byte = row_byte_sjis;
+ enc.col_byte = col_byte_sjis;
+ enc.byte_row = byte_row_sjis;
+ enc.byte_col = byte_col_sjis;
+ enc.check_row_expr = "(%1$s >= 0x81 && %1$s < 0xa0) || (%1$s >= 0xe0)";
+ enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xfd)";
+ enc.byte_row_expr = "%1$s - (%1$s >= 0xe0 ? 0xc1 : 0x81)";
+ enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)";
+
+ read_table(&enc);
+ output_charset2uni(name,&enc);
+ invert(&enc); output_uni2charset_sparse(name,&enc);
+}
+
+/* Main program */
+
+int main (int argc, char *argv[])
+{
+ const char* charsetname;
+ const char* name;
+
+ if (argc != 3)
+ exit(1);
+ charsetname = argv[1];
+ name = argv[2];
+
+ output_title(charsetname);
+
+ if (!strcmp(name,"gb2312") || !strcmp(name,"gb12345ext")
+ || !strcmp(name,"jisx0208") || !strcmp(name,"jisx0212"))
+ do_normal(name);
+ else if (!strcmp(name,"cns11643_1") || !strcmp(name,"cns11643_2")
+ || !strcmp(name,"cns11643_3"))
+ do_normal_only_charset2uni(name);
+ else if (!strcmp(name,"cns11643_inv"))
+ do_cns11643_only_uni2charset(name);
+ else if (!strcmp(name,"gbkext1"))
+ do_gbk1_only_charset2uni(name);
+ else if (!strcmp(name,"gbkext2"))
+ do_gbk2_only_charset2uni(name);
+ else if (!strcmp(name,"gbkext_inv"))
+ do_gbk1_only_uni2charset(name);
+ else if (!strcmp(name,"cp936ext"))
+ do_gbk1(name);
+ else if (!strcmp(name,"ksc5601"))
+ do_ksc5601(name);
+ else if (!strcmp(name,"big5") || !strcmp(name,"cp950ext"))
+ do_big5(name);
+ else if (!strcmp(name,"johab_hangul"))
+ do_johab_hangul(name);
+ else if (!strcmp(name,"cp932ext"))
+ do_sjis(name);
+ else
+ exit(1);
+
+ return 0;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/cp1133.h b/nx-X11/lib/X11/lcUniConv/cp1133.h
new file mode 100644
index 000000000..8b7ff5484
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/cp1133.h
@@ -0,0 +1,92 @@
+/* $XFree86$ */
+
+/*
+ * IBM-CP1133
+ */
+
+static const unsigned short cp1133_2uni_1[64] = {
+ /* 0xa0 */
+ 0x00a0, 0x0e81, 0x0e82, 0x0e84, 0x0e87, 0x0e88, 0x0eaa, 0x0e8a,
+ 0x0e8d, 0x0e94, 0x0e95, 0x0e96, 0x0e97, 0x0e99, 0x0e9a, 0x0e9b,
+ /* 0xb0 */
+ 0x0e9c, 0x0e9d, 0x0e9e, 0x0e9f, 0x0ea1, 0x0ea2, 0x0ea3, 0x0ea5,
+ 0x0ea7, 0x0eab, 0x0ead, 0x0eae, 0xfffd, 0xfffd, 0xfffd, 0x0eaf,
+ /* 0xc0 */
+ 0x0eb0, 0x0eb2, 0x0eb3, 0x0eb4, 0x0eb5, 0x0eb6, 0x0eb7, 0x0eb8,
+ 0x0eb9, 0x0ebc, 0x0eb1, 0x0ebb, 0x0ebd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0xd0 */
+ 0x0ec0, 0x0ec1, 0x0ec2, 0x0ec3, 0x0ec4, 0x0ec8, 0x0ec9, 0x0eca,
+ 0x0ecb, 0x0ecc, 0x0ecd, 0x0ec6, 0xfffd, 0x0edc, 0x0edd, 0x20ad,
+};
+static const unsigned short cp1133_2uni_2[16] = {
+ /* 0xf0 */
+ 0x0ed0, 0x0ed1, 0x0ed2, 0x0ed3, 0x0ed4, 0x0ed5, 0x0ed6, 0x0ed7,
+ 0x0ed8, 0x0ed9, 0xfffd, 0xfffd, 0x00a2, 0x00ac, 0x00a6, 0xfffd,
+};
+
+static int
+cp1133_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0xa0) {
+ *pwc = (ucs4_t) c;
+ return 1;
+ }
+ else if (c < 0xe0) {
+ unsigned short wc = cp1133_2uni_1[c-0xa0];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 1;
+ }
+ }
+ else if (c < 0xf0) {
+ }
+ else {
+ unsigned short wc = cp1133_2uni_2[c-0xf0];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 1;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned char cp1133_page00[16] = {
+ 0xa0, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfe, 0x00, /* 0xa0-0xa7 */
+ 0x00, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
+};
+static const unsigned char cp1133_page0e[96] = {
+ 0x00, 0xa1, 0xa2, 0x00, 0xa3, 0x00, 0x00, 0xa4, /* 0x80-0x87 */
+ 0xa5, 0x00, 0xa7, 0x00, 0x00, 0xa8, 0x00, 0x00, /* 0x88-0x8f */
+ 0x00, 0x00, 0x00, 0x00, 0xa9, 0xaa, 0xab, 0xac, /* 0x90-0x97 */
+ 0x00, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, /* 0x98-0x9f */
+ 0x00, 0xb4, 0xb5, 0xb6, 0x00, 0xb7, 0x00, 0xb8, /* 0xa0-0xa7 */
+ 0x00, 0x00, 0xa6, 0xb9, 0x00, 0xba, 0xbb, 0xbf, /* 0xa8-0xaf */
+ 0xc0, 0xca, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, /* 0xb0-0xb7 */
+ 0xc7, 0xc8, 0x00, 0xcb, 0xc9, 0xcc, 0x00, 0x00, /* 0xb8-0xbf */
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0x00, 0xdb, 0x00, /* 0xc0-0xc7 */
+ 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0x00, 0x00, /* 0xc8-0xcf */
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xd0-0xd7 */
+ 0xf8, 0xf9, 0x00, 0x00, 0xdd, 0xde, 0x00, 0x00, /* 0xd8-0xdf */
+};
+
+static int
+cp1133_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x00b0)
+ c = cp1133_page00[wc-0x00a0];
+ else if (wc >= 0x0e80 && wc < 0x0ee0)
+ c = cp1133_page0e[wc-0x0e80];
+ else if (wc == 0x20ad)
+ c = 0xdf;
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/cp1251.h b/nx-X11/lib/X11/lcUniConv/cp1251.h
new file mode 100644
index 000000000..166d5ba88
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/cp1251.h
@@ -0,0 +1,113 @@
+/* $XFree86$ */
+
+/*
+ * CP1251
+ */
+
+static const unsigned short cp1251_2uni[128] = {
+ /* 0x80 */
+ 0x0402, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x20ac, 0x2030, 0x0409, 0x2039, 0x040a, 0x040c, 0x040b, 0x040f,
+ /* 0x90 */
+ 0x0452, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0xfffd, 0x2122, 0x0459, 0x203a, 0x045a, 0x045c, 0x045b, 0x045f,
+ /* 0xa0 */
+ 0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7,
+ 0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407,
+ /* 0xb0 */
+ 0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7,
+ 0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457,
+ /* 0xc0 */
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+ 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
+ /* 0xd0 */
+ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+ 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
+ /* 0xe0 */
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+ 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
+ /* 0xf0 */
+ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+ 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
+};
+
+static int
+cp1251_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0x80) {
+ *pwc = (ucs4_t) c;
+ return 1;
+ }
+ else {
+ unsigned short wc = cp1251_2uni[c-0x80];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 1;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned char cp1251_page00[32] = {
+ 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */
+ 0x00, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0x00, /* 0xa8-0xaf */
+ 0xb0, 0xb1, 0x00, 0x00, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
+ 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+};
+static const unsigned char cp1251_page04[152] = {
+ 0x00, 0xa8, 0x80, 0x81, 0xaa, 0xbd, 0xb2, 0xaf, /* 0x00-0x07 */
+ 0xa3, 0x8a, 0x8c, 0x8e, 0x8d, 0x00, 0xa1, 0x8f, /* 0x08-0x0f */
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x10-0x17 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x18-0x1f */
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x20-0x27 */
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0x28-0x2f */
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x30-0x37 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x38-0x3f */
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x40-0x47 */
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0x48-0x4f */
+ 0x00, 0xb8, 0x90, 0x83, 0xba, 0xbe, 0xb3, 0xbf, /* 0x50-0x57 */
+ 0xbc, 0x9a, 0x9c, 0x9e, 0x9d, 0x00, 0xa2, 0x9f, /* 0x58-0x5f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+ 0xa5, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+};
+static const unsigned char cp1251_page20[48] = {
+ 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */
+ 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+};
+
+static int
+cp1251_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0080) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x00c0)
+ c = cp1251_page00[wc-0x00a0];
+ else if (wc >= 0x0400 && wc < 0x0498)
+ c = cp1251_page04[wc-0x0400];
+ else if (wc >= 0x2010 && wc < 0x2040)
+ c = cp1251_page20[wc-0x2010];
+ else if (wc == 0x20ac)
+ c = 0x88;
+ else if (wc == 0x2116)
+ c = 0xb9;
+ else if (wc == 0x2122)
+ c = 0x99;
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/cp1255.h b/nx-X11/lib/X11/lcUniConv/cp1255.h
new file mode 100644
index 000000000..f8e175d84
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/cp1255.h
@@ -0,0 +1,121 @@
+/* $XFree86$ */
+
+/*
+ * CP1255
+ */
+
+static const unsigned short cp1255_2uni[128] = {
+ /* 0x80 */
+ 0x20ac, 0xfffd, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x02c6, 0x2030, 0xfffd, 0x2039, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x90 */
+ 0xfffd, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x02dc, 0x2122, 0xfffd, 0x203a, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0xa0 */
+ 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20aa, 0x00a5, 0x00a6, 0x00a7,
+ 0x00a8, 0x00a9, 0x00d7, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+ /* 0xb0 */
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
+ 0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
+ /* 0xc0 */
+ 0x05b0, 0x05b1, 0x05b2, 0x05b3, 0x05b4, 0x05b5, 0x05b6, 0x05b7,
+ 0x05b8, 0x05b9, 0xfffd, 0x05bb, 0x05bc, 0x05bd, 0x05be, 0x05bf,
+ /* 0xd0 */
+ 0x05c0, 0x05c1, 0x05c2, 0x05c3, 0x05f0, 0x05f1, 0x05f2, 0x05f3,
+ 0x05f4, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0xe0 */
+ 0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7,
+ 0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
+ /* 0xf0 */
+ 0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7,
+ 0x05e8, 0x05e9, 0x05ea, 0xfffd, 0xfffd, 0x200e, 0x200f, 0xfffd,
+};
+
+static int
+cp1255_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0x80) {
+ *pwc = (ucs4_t) c;
+ return 1;
+ }
+ else {
+ unsigned short wc = cp1255_2uni[c-0x80];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 1;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned char cp1255_page00[88] = {
+ 0xa0, 0xa1, 0xa2, 0xa3, 0x00, 0xa5, 0xa6, 0xa7, /* 0xa0-0xa7 */
+ 0xa8, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
+ 0xb8, 0xb9, 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* 0xb8-0xbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, /* 0xd0-0xd7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, /* 0xf0-0xf7 */
+};
+static const unsigned char cp1255_page02[32] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+ 0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+};
+static const unsigned char cp1255_page05[72] = {
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xb0-0xb7 */
+ 0xc8, 0xc9, 0x00, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xb8-0xbf */
+ 0xd0, 0xd1, 0xd2, 0xd3, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xd0-0xd7 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xd8-0xdf */
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xe0-0xe7 */
+ 0xf8, 0xf9, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
+ 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */
+};
+static const unsigned char cp1255_page20[56] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, 0xfe, /* 0x08-0x0f */
+ 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */
+ 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+};
+
+static int
+cp1255_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0080) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x00f8)
+ c = cp1255_page00[wc-0x00a0];
+ else if (wc == 0x0192)
+ c = 0x83;
+ else if (wc >= 0x02c0 && wc < 0x02e0)
+ c = cp1255_page02[wc-0x02c0];
+ else if (wc >= 0x05b0 && wc < 0x05f8)
+ c = cp1255_page05[wc-0x05b0];
+ else if (wc >= 0x2008 && wc < 0x2040)
+ c = cp1255_page20[wc-0x2008];
+ else if (wc == 0x20aa)
+ c = 0xa4;
+ else if (wc == 0x20ac)
+ c = 0x80;
+ else if (wc == 0x2122)
+ c = 0x99;
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/cp1256.h b/nx-X11/lib/X11/lcUniConv/cp1256.h
new file mode 100644
index 000000000..5097762aa
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/cp1256.h
@@ -0,0 +1,135 @@
+/* $XFree86$ */
+
+/*
+ * CP1256
+ */
+
+static const unsigned short cp1256_2uni[128] = {
+ /* 0x80 */
+ 0x20ac, 0x067e, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x02c6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688,
+ /* 0x90 */
+ 0x06af, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x06a9, 0x2122, 0x0691, 0x203a, 0x0153, 0x200c, 0x200d, 0x06ba,
+ /* 0xa0 */
+ 0x00a0, 0x060c, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
+ 0x00a8, 0x00a9, 0x06be, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+ /* 0xb0 */
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
+ 0x00b8, 0x00b9, 0x061b, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x061f,
+ /* 0xc0 */
+ 0x06c1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
+ 0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f,
+ /* 0xd0 */
+ 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00d7,
+ 0x0637, 0x0638, 0x0639, 0x063a, 0x0640, 0x0641, 0x0642, 0x0643,
+ /* 0xe0 */
+ 0x00e0, 0x0644, 0x00e2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00e7,
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x0649, 0x064a, 0x00ee, 0x00ef,
+ /* 0xf0 */
+ 0x064b, 0x064c, 0x064d, 0x064e, 0x00f4, 0x064f, 0x0650, 0x00f7,
+ 0x0651, 0x00f9, 0x0652, 0x00fb, 0x00fc, 0x200e, 0x200f, 0x06d2,
+};
+
+static int
+cp1256_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0x80)
+ *pwc = (ucs4_t) c;
+ else
+ *pwc = (ucs4_t) cp1256_2uni[c-0x80];
+ return 1;
+}
+
+static const unsigned char cp1256_page00[96] = {
+ 0xa0, 0x00, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0xa0-0xa7 */
+ 0xa8, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
+ 0xb8, 0xb9, 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0x00, /* 0xb8-0xbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd7, /* 0xd0-0xd7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+ 0xe0, 0x00, 0xe2, 0x00, 0x00, 0x00, 0x00, 0xe7, /* 0xe0-0xe7 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0x00, 0x00, 0xee, 0xef, /* 0xe8-0xef */
+ 0x00, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, 0xf7, /* 0xf0-0xf7 */
+ 0x00, 0xf9, 0x00, 0xfb, 0xfc, 0x00, 0x00, 0x00, /* 0xf8-0xff */
+};
+static const unsigned char cp1256_page01[72] = {
+ 0x00, 0x00, 0x8c, 0x9c, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+ 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+};
+static const unsigned char cp1256_page06[208] = {
+ 0x00, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, /* 0x08-0x0f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, 0xbf, /* 0x18-0x1f */
+ 0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x20-0x27 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x28-0x2f */
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd8, /* 0x30-0x37 */
+ 0xd9, 0xda, 0xdb, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0xdc, 0xdd, 0xde, 0xdf, 0xe1, 0xe3, 0xe4, 0xe5, /* 0x40-0x47 */
+ 0xe6, 0xec, 0xed, 0xf0, 0xf1, 0xf2, 0xf3, 0xf5, /* 0x48-0x4f */
+ 0xf6, 0xf8, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, /* 0x78-0x7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8d, 0x00, /* 0x80-0x87 */
+ 0x8f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+ 0x00, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+ 0x8e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+ 0x00, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, /* 0xa8-0xaf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
+ 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, 0xaa, 0x00, /* 0xb8-0xbf */
+ 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+};
+static const unsigned char cp1256_page20[56] = {
+ 0x00, 0x00, 0x00, 0x00, 0x9d, 0x9e, 0xfd, 0xfe, /* 0x08-0x0f */
+ 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */
+ 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+};
+
+static int
+cp1256_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0080) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x0100)
+ c = cp1256_page00[wc-0x00a0];
+ else if (wc >= 0x0150 && wc < 0x0198)
+ c = cp1256_page01[wc-0x0150];
+ else if (wc == 0x02c6)
+ c = 0x88;
+ else if (wc >= 0x0608 && wc < 0x06d8)
+ c = cp1256_page06[wc-0x0608];
+ else if (wc >= 0x2008 && wc < 0x2040)
+ c = cp1256_page20[wc-0x2008];
+ else if (wc == 0x20ac)
+ c = 0x80;
+ else if (wc == 0x2122)
+ c = 0x99;
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/gb2312.h b/nx-X11/lib/X11/lcUniConv/gb2312.h
new file mode 100644
index 000000000..db900a478
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/gb2312.h
@@ -0,0 +1,2553 @@
+/* $XFree86: xc/lib/X11/lcUniConv/gb2312.h,v 1.4tsi Exp $ */
+
+/*
+ * GB2312.1980-0
+ */
+
+static const unsigned short gb2312_2uni_page21[831] = {
+ /* 0x21 */
+ 0x3000, 0x3001, 0x3002, 0x30fb, 0x02c9, 0x02c7, 0x00a8, 0x3003,
+ 0x3005, 0x2015, 0xff5e, 0x2016, 0x2026, 0x2018, 0x2019, 0x201c,
+ 0x201d, 0x3014, 0x3015, 0x3008, 0x3009, 0x300a, 0x300b, 0x300c,
+ 0x300d, 0x300e, 0x300f, 0x3016, 0x3017, 0x3010, 0x3011, 0x00b1,
+ 0x00d7, 0x00f7, 0x2236, 0x2227, 0x2228, 0x2211, 0x220f, 0x222a,
+ 0x2229, 0x2208, 0x2237, 0x221a, 0x22a5, 0x2225, 0x2220, 0x2312,
+ 0x2299, 0x222b, 0x222e, 0x2261, 0x224c, 0x2248, 0x223d, 0x221d,
+ 0x2260, 0x226e, 0x226f, 0x2264, 0x2265, 0x221e, 0x2235, 0x2234,
+ 0x2642, 0x2640, 0x00b0, 0x2032, 0x2033, 0x2103, 0xff04, 0x00a4,
+ 0xffe0, 0xffe1, 0x2030, 0x00a7, 0x2116, 0x2606, 0x2605, 0x25cb,
+ 0x25cf, 0x25ce, 0x25c7, 0x25c6, 0x25a1, 0x25a0, 0x25b3, 0x25b2,
+ 0x203b, 0x2192, 0x2190, 0x2191, 0x2193, 0x3013,
+ /* 0x22 */
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0x2488, 0x2489, 0x248a, 0x248b, 0x248c, 0x248d, 0x248e, 0x248f,
+ 0x2490, 0x2491, 0x2492, 0x2493, 0x2494, 0x2495, 0x2496, 0x2497,
+ 0x2498, 0x2499, 0x249a, 0x249b, 0x2474, 0x2475, 0x2476, 0x2477,
+ 0x2478, 0x2479, 0x247a, 0x247b, 0x247c, 0x247d, 0x247e, 0x247f,
+ 0x2480, 0x2481, 0x2482, 0x2483, 0x2484, 0x2485, 0x2486, 0x2487,
+ 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467,
+ 0x2468, 0x2469, 0xfffd, 0xfffd, 0x3220, 0x3221, 0x3222, 0x3223,
+ 0x3224, 0x3225, 0x3226, 0x3227, 0x3228, 0x3229, 0xfffd, 0xfffd,
+ 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167,
+ 0x2168, 0x2169, 0x216a, 0x216b, 0xfffd, 0xfffd,
+ /* 0x23 */
+ 0xff01, 0xff02, 0xff03, 0xffe5, 0xff05, 0xff06, 0xff07, 0xff08,
+ 0xff09, 0xff0a, 0xff0b, 0xff0c, 0xff0d, 0xff0e, 0xff0f, 0xff10,
+ 0xff11, 0xff12, 0xff13, 0xff14, 0xff15, 0xff16, 0xff17, 0xff18,
+ 0xff19, 0xff1a, 0xff1b, 0xff1c, 0xff1d, 0xff1e, 0xff1f, 0xff20,
+ 0xff21, 0xff22, 0xff23, 0xff24, 0xff25, 0xff26, 0xff27, 0xff28,
+ 0xff29, 0xff2a, 0xff2b, 0xff2c, 0xff2d, 0xff2e, 0xff2f, 0xff30,
+ 0xff31, 0xff32, 0xff33, 0xff34, 0xff35, 0xff36, 0xff37, 0xff38,
+ 0xff39, 0xff3a, 0xff3b, 0xff3c, 0xff3d, 0xff3e, 0xff3f, 0xff40,
+ 0xff41, 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48,
+ 0xff49, 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50,
+ 0xff51, 0xff52, 0xff53, 0xff54, 0xff55, 0xff56, 0xff57, 0xff58,
+ 0xff59, 0xff5a, 0xff5b, 0xff5c, 0xff5d, 0xffe3,
+ /* 0x24 */
+ 0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046, 0x3047, 0x3048,
+ 0x3049, 0x304a, 0x304b, 0x304c, 0x304d, 0x304e, 0x304f, 0x3050,
+ 0x3051, 0x3052, 0x3053, 0x3054, 0x3055, 0x3056, 0x3057, 0x3058,
+ 0x3059, 0x305a, 0x305b, 0x305c, 0x305d, 0x305e, 0x305f, 0x3060,
+ 0x3061, 0x3062, 0x3063, 0x3064, 0x3065, 0x3066, 0x3067, 0x3068,
+ 0x3069, 0x306a, 0x306b, 0x306c, 0x306d, 0x306e, 0x306f, 0x3070,
+ 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076, 0x3077, 0x3078,
+ 0x3079, 0x307a, 0x307b, 0x307c, 0x307d, 0x307e, 0x307f, 0x3080,
+ 0x3081, 0x3082, 0x3083, 0x3084, 0x3085, 0x3086, 0x3087, 0x3088,
+ 0x3089, 0x308a, 0x308b, 0x308c, 0x308d, 0x308e, 0x308f, 0x3090,
+ 0x3091, 0x3092, 0x3093, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x25 */
+ 0x30a1, 0x30a2, 0x30a3, 0x30a4, 0x30a5, 0x30a6, 0x30a7, 0x30a8,
+ 0x30a9, 0x30aa, 0x30ab, 0x30ac, 0x30ad, 0x30ae, 0x30af, 0x30b0,
+ 0x30b1, 0x30b2, 0x30b3, 0x30b4, 0x30b5, 0x30b6, 0x30b7, 0x30b8,
+ 0x30b9, 0x30ba, 0x30bb, 0x30bc, 0x30bd, 0x30be, 0x30bf, 0x30c0,
+ 0x30c1, 0x30c2, 0x30c3, 0x30c4, 0x30c5, 0x30c6, 0x30c7, 0x30c8,
+ 0x30c9, 0x30ca, 0x30cb, 0x30cc, 0x30cd, 0x30ce, 0x30cf, 0x30d0,
+ 0x30d1, 0x30d2, 0x30d3, 0x30d4, 0x30d5, 0x30d6, 0x30d7, 0x30d8,
+ 0x30d9, 0x30da, 0x30db, 0x30dc, 0x30dd, 0x30de, 0x30df, 0x30e0,
+ 0x30e1, 0x30e2, 0x30e3, 0x30e4, 0x30e5, 0x30e6, 0x30e7, 0x30e8,
+ 0x30e9, 0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ee, 0x30ef, 0x30f0,
+ 0x30f1, 0x30f2, 0x30f3, 0x30f4, 0x30f5, 0x30f6, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x26 */
+ 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398,
+ 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, 0x03a0,
+ 0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, 0x03b8,
+ 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, 0x03c0,
+ 0x03c1, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x27 */
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0401, 0x0416,
+ 0x0417, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e,
+ 0x041f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426,
+ 0x0427, 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e,
+ 0x042f, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0451, 0x0436,
+ 0x0437, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e,
+ 0x043f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446,
+ 0x0447, 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e,
+ 0x044f, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x28 */
+ 0x0101, 0x00e1, 0x01ce, 0x00e0, 0x0113, 0x00e9, 0x011b, 0x00e8,
+ 0x012b, 0x00ed, 0x01d0, 0x00ec, 0x014d, 0x00f3, 0x01d2, 0x00f2,
+ 0x016b, 0x00fa, 0x01d4, 0x00f9, 0x01d6, 0x01d8, 0x01da, 0x01dc,
+ 0x00fc, 0x00ea, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x3105, 0x3106, 0x3107, 0x3108,
+ 0x3109, 0x310a, 0x310b, 0x310c, 0x310d, 0x310e, 0x310f, 0x3110,
+ 0x3111, 0x3112, 0x3113, 0x3114, 0x3115, 0x3116, 0x3117, 0x3118,
+ 0x3119, 0x311a, 0x311b, 0x311c, 0x311d, 0x311e, 0x311f, 0x3120,
+ 0x3121, 0x3122, 0x3123, 0x3124, 0x3125, 0x3126, 0x3127, 0x3128,
+ 0x3129, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x29 */
+ 0xfffd, 0xfffd, 0xfffd, 0x2500, 0x2501, 0x2502, 0x2503, 0x2504,
+ 0x2505, 0x2506, 0x2507, 0x2508, 0x2509, 0x250a, 0x250b, 0x250c,
+ 0x250d, 0x250e, 0x250f, 0x2510, 0x2511, 0x2512, 0x2513, 0x2514,
+ 0x2515, 0x2516, 0x2517, 0x2518, 0x2519, 0x251a, 0x251b, 0x251c,
+ 0x251d, 0x251e, 0x251f, 0x2520, 0x2521, 0x2522, 0x2523, 0x2524,
+ 0x2525, 0x2526, 0x2527, 0x2528, 0x2529, 0x252a, 0x252b, 0x252c,
+ 0x252d, 0x252e, 0x252f, 0x2530, 0x2531, 0x2532, 0x2533, 0x2534,
+ 0x2535, 0x2536, 0x2537, 0x2538, 0x2539, 0x253a, 0x253b, 0x253c,
+ 0x253d, 0x253e, 0x253f, 0x2540, 0x2541, 0x2542, 0x2543, 0x2544,
+ 0x2545, 0x2546, 0x2547, 0x2548, 0x2549, 0x254a, 0x254b,
+};
+static const unsigned short gb2312_2uni_page30[6768] = {
+ /* 0x30 */
+ 0x554a, 0x963f, 0x57c3, 0x6328, 0x54ce, 0x5509, 0x54c0, 0x7691,
+ 0x764c, 0x853c, 0x77ee, 0x827e, 0x788d, 0x7231, 0x9698, 0x978d,
+ 0x6c28, 0x5b89, 0x4ffa, 0x6309, 0x6697, 0x5cb8, 0x80fa, 0x6848,
+ 0x80ae, 0x6602, 0x76ce, 0x51f9, 0x6556, 0x71ac, 0x7ff1, 0x8884,
+ 0x50b2, 0x5965, 0x61ca, 0x6fb3, 0x82ad, 0x634c, 0x6252, 0x53ed,
+ 0x5427, 0x7b06, 0x516b, 0x75a4, 0x5df4, 0x62d4, 0x8dcb, 0x9776,
+ 0x628a, 0x8019, 0x575d, 0x9738, 0x7f62, 0x7238, 0x767d, 0x67cf,
+ 0x767e, 0x6446, 0x4f70, 0x8d25, 0x62dc, 0x7a17, 0x6591, 0x73ed,
+ 0x642c, 0x6273, 0x822c, 0x9881, 0x677f, 0x7248, 0x626e, 0x62cc,
+ 0x4f34, 0x74e3, 0x534a, 0x529e, 0x7eca, 0x90a6, 0x5e2e, 0x6886,
+ 0x699c, 0x8180, 0x7ed1, 0x68d2, 0x78c5, 0x868c, 0x9551, 0x508d,
+ 0x8c24, 0x82de, 0x80de, 0x5305, 0x8912, 0x5265,
+ /* 0x31 */
+ 0x8584, 0x96f9, 0x4fdd, 0x5821, 0x9971, 0x5b9d, 0x62b1, 0x62a5,
+ 0x66b4, 0x8c79, 0x9c8d, 0x7206, 0x676f, 0x7891, 0x60b2, 0x5351,
+ 0x5317, 0x8f88, 0x80cc, 0x8d1d, 0x94a1, 0x500d, 0x72c8, 0x5907,
+ 0x60eb, 0x7119, 0x88ab, 0x5954, 0x82ef, 0x672c, 0x7b28, 0x5d29,
+ 0x7ef7, 0x752d, 0x6cf5, 0x8e66, 0x8ff8, 0x903c, 0x9f3b, 0x6bd4,
+ 0x9119, 0x7b14, 0x5f7c, 0x78a7, 0x84d6, 0x853d, 0x6bd5, 0x6bd9,
+ 0x6bd6, 0x5e01, 0x5e87, 0x75f9, 0x95ed, 0x655d, 0x5f0a, 0x5fc5,
+ 0x8f9f, 0x58c1, 0x81c2, 0x907f, 0x965b, 0x97ad, 0x8fb9, 0x7f16,
+ 0x8d2c, 0x6241, 0x4fbf, 0x53d8, 0x535e, 0x8fa8, 0x8fa9, 0x8fab,
+ 0x904d, 0x6807, 0x5f6a, 0x8198, 0x8868, 0x9cd6, 0x618b, 0x522b,
+ 0x762a, 0x5f6c, 0x658c, 0x6fd2, 0x6ee8, 0x5bbe, 0x6448, 0x5175,
+ 0x51b0, 0x67c4, 0x4e19, 0x79c9, 0x997c, 0x70b3,
+ /* 0x32 */
+ 0x75c5, 0x5e76, 0x73bb, 0x83e0, 0x64ad, 0x62e8, 0x94b5, 0x6ce2,
+ 0x535a, 0x52c3, 0x640f, 0x94c2, 0x7b94, 0x4f2f, 0x5e1b, 0x8236,
+ 0x8116, 0x818a, 0x6e24, 0x6cca, 0x9a73, 0x6355, 0x535c, 0x54fa,
+ 0x8865, 0x57e0, 0x4e0d, 0x5e03, 0x6b65, 0x7c3f, 0x90e8, 0x6016,
+ 0x64e6, 0x731c, 0x88c1, 0x6750, 0x624d, 0x8d22, 0x776c, 0x8e29,
+ 0x91c7, 0x5f69, 0x83dc, 0x8521, 0x9910, 0x53c2, 0x8695, 0x6b8b,
+ 0x60ed, 0x60e8, 0x707f, 0x82cd, 0x8231, 0x4ed3, 0x6ca7, 0x85cf,
+ 0x64cd, 0x7cd9, 0x69fd, 0x66f9, 0x8349, 0x5395, 0x7b56, 0x4fa7,
+ 0x518c, 0x6d4b, 0x5c42, 0x8e6d, 0x63d2, 0x53c9, 0x832c, 0x8336,
+ 0x67e5, 0x78b4, 0x643d, 0x5bdf, 0x5c94, 0x5dee, 0x8be7, 0x62c6,
+ 0x67f4, 0x8c7a, 0x6400, 0x63ba, 0x8749, 0x998b, 0x8c17, 0x7f20,
+ 0x94f2, 0x4ea7, 0x9610, 0x98a4, 0x660c, 0x7316,
+ /* 0x33 */
+ 0x573a, 0x5c1d, 0x5e38, 0x957f, 0x507f, 0x80a0, 0x5382, 0x655e,
+ 0x7545, 0x5531, 0x5021, 0x8d85, 0x6284, 0x949e, 0x671d, 0x5632,
+ 0x6f6e, 0x5de2, 0x5435, 0x7092, 0x8f66, 0x626f, 0x64a4, 0x63a3,
+ 0x5f7b, 0x6f88, 0x90f4, 0x81e3, 0x8fb0, 0x5c18, 0x6668, 0x5ff1,
+ 0x6c89, 0x9648, 0x8d81, 0x886c, 0x6491, 0x79f0, 0x57ce, 0x6a59,
+ 0x6210, 0x5448, 0x4e58, 0x7a0b, 0x60e9, 0x6f84, 0x8bda, 0x627f,
+ 0x901e, 0x9a8b, 0x79e4, 0x5403, 0x75f4, 0x6301, 0x5319, 0x6c60,
+ 0x8fdf, 0x5f1b, 0x9a70, 0x803b, 0x9f7f, 0x4f88, 0x5c3a, 0x8d64,
+ 0x7fc5, 0x65a5, 0x70bd, 0x5145, 0x51b2, 0x866b, 0x5d07, 0x5ba0,
+ 0x62bd, 0x916c, 0x7574, 0x8e0c, 0x7a20, 0x6101, 0x7b79, 0x4ec7,
+ 0x7ef8, 0x7785, 0x4e11, 0x81ed, 0x521d, 0x51fa, 0x6a71, 0x53a8,
+ 0x8e87, 0x9504, 0x96cf, 0x6ec1, 0x9664, 0x695a,
+ /* 0x34 */
+ 0x7840, 0x50a8, 0x77d7, 0x6410, 0x89e6, 0x5904, 0x63e3, 0x5ddd,
+ 0x7a7f, 0x693d, 0x4f20, 0x8239, 0x5598, 0x4e32, 0x75ae, 0x7a97,
+ 0x5e62, 0x5e8a, 0x95ef, 0x521b, 0x5439, 0x708a, 0x6376, 0x9524,
+ 0x5782, 0x6625, 0x693f, 0x9187, 0x5507, 0x6df3, 0x7eaf, 0x8822,
+ 0x6233, 0x7ef0, 0x75b5, 0x8328, 0x78c1, 0x96cc, 0x8f9e, 0x6148,
+ 0x74f7, 0x8bcd, 0x6b64, 0x523a, 0x8d50, 0x6b21, 0x806a, 0x8471,
+ 0x56f1, 0x5306, 0x4ece, 0x4e1b, 0x51d1, 0x7c97, 0x918b, 0x7c07,
+ 0x4fc3, 0x8e7f, 0x7be1, 0x7a9c, 0x6467, 0x5d14, 0x50ac, 0x8106,
+ 0x7601, 0x7cb9, 0x6dec, 0x7fe0, 0x6751, 0x5b58, 0x5bf8, 0x78cb,
+ 0x64ae, 0x6413, 0x63aa, 0x632b, 0x9519, 0x642d, 0x8fbe, 0x7b54,
+ 0x7629, 0x6253, 0x5927, 0x5446, 0x6b79, 0x50a3, 0x6234, 0x5e26,
+ 0x6b86, 0x4ee3, 0x8d37, 0x888b, 0x5f85, 0x902e,
+ /* 0x35 */
+ 0x6020, 0x803d, 0x62c5, 0x4e39, 0x5355, 0x90f8, 0x63b8, 0x80c6,
+ 0x65e6, 0x6c2e, 0x4f46, 0x60ee, 0x6de1, 0x8bde, 0x5f39, 0x86cb,
+ 0x5f53, 0x6321, 0x515a, 0x8361, 0x6863, 0x5200, 0x6363, 0x8e48,
+ 0x5012, 0x5c9b, 0x7977, 0x5bfc, 0x5230, 0x7a3b, 0x60bc, 0x9053,
+ 0x76d7, 0x5fb7, 0x5f97, 0x7684, 0x8e6c, 0x706f, 0x767b, 0x7b49,
+ 0x77aa, 0x51f3, 0x9093, 0x5824, 0x4f4e, 0x6ef4, 0x8fea, 0x654c,
+ 0x7b1b, 0x72c4, 0x6da4, 0x7fdf, 0x5ae1, 0x62b5, 0x5e95, 0x5730,
+ 0x8482, 0x7b2c, 0x5e1d, 0x5f1f, 0x9012, 0x7f14, 0x98a0, 0x6382,
+ 0x6ec7, 0x7898, 0x70b9, 0x5178, 0x975b, 0x57ab, 0x7535, 0x4f43,
+ 0x7538, 0x5e97, 0x60e6, 0x5960, 0x6dc0, 0x6bbf, 0x7889, 0x53fc,
+ 0x96d5, 0x51cb, 0x5201, 0x6389, 0x540a, 0x9493, 0x8c03, 0x8dcc,
+ 0x7239, 0x789f, 0x8776, 0x8fed, 0x8c0d, 0x53e0,
+ /* 0x36 */
+ 0x4e01, 0x76ef, 0x53ee, 0x9489, 0x9876, 0x9f0e, 0x952d, 0x5b9a,
+ 0x8ba2, 0x4e22, 0x4e1c, 0x51ac, 0x8463, 0x61c2, 0x52a8, 0x680b,
+ 0x4f97, 0x606b, 0x51bb, 0x6d1e, 0x515c, 0x6296, 0x6597, 0x9661,
+ 0x8c46, 0x9017, 0x75d8, 0x90fd, 0x7763, 0x6bd2, 0x728a, 0x72ec,
+ 0x8bfb, 0x5835, 0x7779, 0x8d4c, 0x675c, 0x9540, 0x809a, 0x5ea6,
+ 0x6e21, 0x5992, 0x7aef, 0x77ed, 0x953b, 0x6bb5, 0x65ad, 0x7f0e,
+ 0x5806, 0x5151, 0x961f, 0x5bf9, 0x58a9, 0x5428, 0x8e72, 0x6566,
+ 0x987f, 0x56e4, 0x949d, 0x76fe, 0x9041, 0x6387, 0x54c6, 0x591a,
+ 0x593a, 0x579b, 0x8eb2, 0x6735, 0x8dfa, 0x8235, 0x5241, 0x60f0,
+ 0x5815, 0x86fe, 0x5ce8, 0x9e45, 0x4fc4, 0x989d, 0x8bb9, 0x5a25,
+ 0x6076, 0x5384, 0x627c, 0x904f, 0x9102, 0x997f, 0x6069, 0x800c,
+ 0x513f, 0x8033, 0x5c14, 0x9975, 0x6d31, 0x4e8c,
+ /* 0x37 */
+ 0x8d30, 0x53d1, 0x7f5a, 0x7b4f, 0x4f10, 0x4e4f, 0x9600, 0x6cd5,
+ 0x73d0, 0x85e9, 0x5e06, 0x756a, 0x7ffb, 0x6a0a, 0x77fe, 0x9492,
+ 0x7e41, 0x51e1, 0x70e6, 0x53cd, 0x8fd4, 0x8303, 0x8d29, 0x72af,
+ 0x996d, 0x6cdb, 0x574a, 0x82b3, 0x65b9, 0x80aa, 0x623f, 0x9632,
+ 0x59a8, 0x4eff, 0x8bbf, 0x7eba, 0x653e, 0x83f2, 0x975e, 0x5561,
+ 0x98de, 0x80a5, 0x532a, 0x8bfd, 0x5420, 0x80ba, 0x5e9f, 0x6cb8,
+ 0x8d39, 0x82ac, 0x915a, 0x5429, 0x6c1b, 0x5206, 0x7eb7, 0x575f,
+ 0x711a, 0x6c7e, 0x7c89, 0x594b, 0x4efd, 0x5fff, 0x6124, 0x7caa,
+ 0x4e30, 0x5c01, 0x67ab, 0x8702, 0x5cf0, 0x950b, 0x98ce, 0x75af,
+ 0x70fd, 0x9022, 0x51af, 0x7f1d, 0x8bbd, 0x5949, 0x51e4, 0x4f5b,
+ 0x5426, 0x592b, 0x6577, 0x80a4, 0x5b75, 0x6276, 0x62c2, 0x8f90,
+ 0x5e45, 0x6c1f, 0x7b26, 0x4f0f, 0x4fd8, 0x670d,
+ /* 0x38 */
+ 0x6d6e, 0x6daa, 0x798f, 0x88b1, 0x5f17, 0x752b, 0x629a, 0x8f85,
+ 0x4fef, 0x91dc, 0x65a7, 0x812f, 0x8151, 0x5e9c, 0x8150, 0x8d74,
+ 0x526f, 0x8986, 0x8d4b, 0x590d, 0x5085, 0x4ed8, 0x961c, 0x7236,
+ 0x8179, 0x8d1f, 0x5bcc, 0x8ba3, 0x9644, 0x5987, 0x7f1a, 0x5490,
+ 0x5676, 0x560e, 0x8be5, 0x6539, 0x6982, 0x9499, 0x76d6, 0x6e89,
+ 0x5e72, 0x7518, 0x6746, 0x67d1, 0x7aff, 0x809d, 0x8d76, 0x611f,
+ 0x79c6, 0x6562, 0x8d63, 0x5188, 0x521a, 0x94a2, 0x7f38, 0x809b,
+ 0x7eb2, 0x5c97, 0x6e2f, 0x6760, 0x7bd9, 0x768b, 0x9ad8, 0x818f,
+ 0x7f94, 0x7cd5, 0x641e, 0x9550, 0x7a3f, 0x544a, 0x54e5, 0x6b4c,
+ 0x6401, 0x6208, 0x9e3d, 0x80f3, 0x7599, 0x5272, 0x9769, 0x845b,
+ 0x683c, 0x86e4, 0x9601, 0x9694, 0x94ec, 0x4e2a, 0x5404, 0x7ed9,
+ 0x6839, 0x8ddf, 0x8015, 0x66f4, 0x5e9a, 0x7fb9,
+ /* 0x39 */
+ 0x57c2, 0x803f, 0x6897, 0x5de5, 0x653b, 0x529f, 0x606d, 0x9f9a,
+ 0x4f9b, 0x8eac, 0x516c, 0x5bab, 0x5f13, 0x5de9, 0x6c5e, 0x62f1,
+ 0x8d21, 0x5171, 0x94a9, 0x52fe, 0x6c9f, 0x82df, 0x72d7, 0x57a2,
+ 0x6784, 0x8d2d, 0x591f, 0x8f9c, 0x83c7, 0x5495, 0x7b8d, 0x4f30,
+ 0x6cbd, 0x5b64, 0x59d1, 0x9f13, 0x53e4, 0x86ca, 0x9aa8, 0x8c37,
+ 0x80a1, 0x6545, 0x987e, 0x56fa, 0x96c7, 0x522e, 0x74dc, 0x5250,
+ 0x5be1, 0x6302, 0x8902, 0x4e56, 0x62d0, 0x602a, 0x68fa, 0x5173,
+ 0x5b98, 0x51a0, 0x89c2, 0x7ba1, 0x9986, 0x7f50, 0x60ef, 0x704c,
+ 0x8d2f, 0x5149, 0x5e7f, 0x901b, 0x7470, 0x89c4, 0x572d, 0x7845,
+ 0x5f52, 0x9f9f, 0x95fa, 0x8f68, 0x9b3c, 0x8be1, 0x7678, 0x6842,
+ 0x67dc, 0x8dea, 0x8d35, 0x523d, 0x8f8a, 0x6eda, 0x68cd, 0x9505,
+ 0x90ed, 0x56fd, 0x679c, 0x88f9, 0x8fc7, 0x54c8,
+ /* 0x3a */
+ 0x9ab8, 0x5b69, 0x6d77, 0x6c26, 0x4ea5, 0x5bb3, 0x9a87, 0x9163,
+ 0x61a8, 0x90af, 0x97e9, 0x542b, 0x6db5, 0x5bd2, 0x51fd, 0x558a,
+ 0x7f55, 0x7ff0, 0x64bc, 0x634d, 0x65f1, 0x61be, 0x608d, 0x710a,
+ 0x6c57, 0x6c49, 0x592f, 0x676d, 0x822a, 0x58d5, 0x568e, 0x8c6a,
+ 0x6beb, 0x90dd, 0x597d, 0x8017, 0x53f7, 0x6d69, 0x5475, 0x559d,
+ 0x8377, 0x83cf, 0x6838, 0x79be, 0x548c, 0x4f55, 0x5408, 0x76d2,
+ 0x8c89, 0x9602, 0x6cb3, 0x6db8, 0x8d6b, 0x8910, 0x9e64, 0x8d3a,
+ 0x563f, 0x9ed1, 0x75d5, 0x5f88, 0x72e0, 0x6068, 0x54fc, 0x4ea8,
+ 0x6a2a, 0x8861, 0x6052, 0x8f70, 0x54c4, 0x70d8, 0x8679, 0x9e3f,
+ 0x6d2a, 0x5b8f, 0x5f18, 0x7ea2, 0x5589, 0x4faf, 0x7334, 0x543c,
+ 0x539a, 0x5019, 0x540e, 0x547c, 0x4e4e, 0x5ffd, 0x745a, 0x58f6,
+ 0x846b, 0x80e1, 0x8774, 0x72d0, 0x7cca, 0x6e56,
+ /* 0x3b */
+ 0x5f27, 0x864e, 0x552c, 0x62a4, 0x4e92, 0x6caa, 0x6237, 0x82b1,
+ 0x54d7, 0x534e, 0x733e, 0x6ed1, 0x753b, 0x5212, 0x5316, 0x8bdd,
+ 0x69d0, 0x5f8a, 0x6000, 0x6dee, 0x574f, 0x6b22, 0x73af, 0x6853,
+ 0x8fd8, 0x7f13, 0x6362, 0x60a3, 0x5524, 0x75ea, 0x8c62, 0x7115,
+ 0x6da3, 0x5ba6, 0x5e7b, 0x8352, 0x614c, 0x9ec4, 0x78fa, 0x8757,
+ 0x7c27, 0x7687, 0x51f0, 0x60f6, 0x714c, 0x6643, 0x5e4c, 0x604d,
+ 0x8c0e, 0x7070, 0x6325, 0x8f89, 0x5fbd, 0x6062, 0x86d4, 0x56de,
+ 0x6bc1, 0x6094, 0x6167, 0x5349, 0x60e0, 0x6666, 0x8d3f, 0x79fd,
+ 0x4f1a, 0x70e9, 0x6c47, 0x8bb3, 0x8bf2, 0x7ed8, 0x8364, 0x660f,
+ 0x5a5a, 0x9b42, 0x6d51, 0x6df7, 0x8c41, 0x6d3b, 0x4f19, 0x706b,
+ 0x83b7, 0x6216, 0x60d1, 0x970d, 0x8d27, 0x7978, 0x51fb, 0x573e,
+ 0x57fa, 0x673a, 0x7578, 0x7a3d, 0x79ef, 0x7b95,
+ /* 0x3c */
+ 0x808c, 0x9965, 0x8ff9, 0x6fc0, 0x8ba5, 0x9e21, 0x59ec, 0x7ee9,
+ 0x7f09, 0x5409, 0x6781, 0x68d8, 0x8f91, 0x7c4d, 0x96c6, 0x53ca,
+ 0x6025, 0x75be, 0x6c72, 0x5373, 0x5ac9, 0x7ea7, 0x6324, 0x51e0,
+ 0x810a, 0x5df1, 0x84df, 0x6280, 0x5180, 0x5b63, 0x4f0e, 0x796d,
+ 0x5242, 0x60b8, 0x6d4e, 0x5bc4, 0x5bc2, 0x8ba1, 0x8bb0, 0x65e2,
+ 0x5fcc, 0x9645, 0x5993, 0x7ee7, 0x7eaa, 0x5609, 0x67b7, 0x5939,
+ 0x4f73, 0x5bb6, 0x52a0, 0x835a, 0x988a, 0x8d3e, 0x7532, 0x94be,
+ 0x5047, 0x7a3c, 0x4ef7, 0x67b6, 0x9a7e, 0x5ac1, 0x6b7c, 0x76d1,
+ 0x575a, 0x5c16, 0x7b3a, 0x95f4, 0x714e, 0x517c, 0x80a9, 0x8270,
+ 0x5978, 0x7f04, 0x8327, 0x68c0, 0x67ec, 0x78b1, 0x7877, 0x62e3,
+ 0x6361, 0x7b80, 0x4fed, 0x526a, 0x51cf, 0x8350, 0x69db, 0x9274,
+ 0x8df5, 0x8d31, 0x89c1, 0x952e, 0x7bad, 0x4ef6,
+ /* 0x3d */
+ 0x5065, 0x8230, 0x5251, 0x996f, 0x6e10, 0x6e85, 0x6da7, 0x5efa,
+ 0x50f5, 0x59dc, 0x5c06, 0x6d46, 0x6c5f, 0x7586, 0x848b, 0x6868,
+ 0x5956, 0x8bb2, 0x5320, 0x9171, 0x964d, 0x8549, 0x6912, 0x7901,
+ 0x7126, 0x80f6, 0x4ea4, 0x90ca, 0x6d47, 0x9a84, 0x5a07, 0x56bc,
+ 0x6405, 0x94f0, 0x77eb, 0x4fa5, 0x811a, 0x72e1, 0x89d2, 0x997a,
+ 0x7f34, 0x7ede, 0x527f, 0x6559, 0x9175, 0x8f7f, 0x8f83, 0x53eb,
+ 0x7a96, 0x63ed, 0x63a5, 0x7686, 0x79f8, 0x8857, 0x9636, 0x622a,
+ 0x52ab, 0x8282, 0x6854, 0x6770, 0x6377, 0x776b, 0x7aed, 0x6d01,
+ 0x7ed3, 0x89e3, 0x59d0, 0x6212, 0x85c9, 0x82a5, 0x754c, 0x501f,
+ 0x4ecb, 0x75a5, 0x8beb, 0x5c4a, 0x5dfe, 0x7b4b, 0x65a4, 0x91d1,
+ 0x4eca, 0x6d25, 0x895f, 0x7d27, 0x9526, 0x4ec5, 0x8c28, 0x8fdb,
+ 0x9773, 0x664b, 0x7981, 0x8fd1, 0x70ec, 0x6d78,
+ /* 0x3e */
+ 0x5c3d, 0x52b2, 0x8346, 0x5162, 0x830e, 0x775b, 0x6676, 0x9cb8,
+ 0x4eac, 0x60ca, 0x7cbe, 0x7cb3, 0x7ecf, 0x4e95, 0x8b66, 0x666f,
+ 0x9888, 0x9759, 0x5883, 0x656c, 0x955c, 0x5f84, 0x75c9, 0x9756,
+ 0x7adf, 0x7ade, 0x51c0, 0x70af, 0x7a98, 0x63ea, 0x7a76, 0x7ea0,
+ 0x7396, 0x97ed, 0x4e45, 0x7078, 0x4e5d, 0x9152, 0x53a9, 0x6551,
+ 0x65e7, 0x81fc, 0x8205, 0x548e, 0x5c31, 0x759a, 0x97a0, 0x62d8,
+ 0x72d9, 0x75bd, 0x5c45, 0x9a79, 0x83ca, 0x5c40, 0x5480, 0x77e9,
+ 0x4e3e, 0x6cae, 0x805a, 0x62d2, 0x636e, 0x5de8, 0x5177, 0x8ddd,
+ 0x8e1e, 0x952f, 0x4ff1, 0x53e5, 0x60e7, 0x70ac, 0x5267, 0x6350,
+ 0x9e43, 0x5a1f, 0x5026, 0x7737, 0x5377, 0x7ee2, 0x6485, 0x652b,
+ 0x6289, 0x6398, 0x5014, 0x7235, 0x89c9, 0x51b3, 0x8bc0, 0x7edd,
+ 0x5747, 0x83cc, 0x94a7, 0x519b, 0x541b, 0x5cfb,
+ /* 0x3f */
+ 0x4fca, 0x7ae3, 0x6d5a, 0x90e1, 0x9a8f, 0x5580, 0x5496, 0x5361,
+ 0x54af, 0x5f00, 0x63e9, 0x6977, 0x51ef, 0x6168, 0x520a, 0x582a,
+ 0x52d8, 0x574e, 0x780d, 0x770b, 0x5eb7, 0x6177, 0x7ce0, 0x625b,
+ 0x6297, 0x4ea2, 0x7095, 0x8003, 0x62f7, 0x70e4, 0x9760, 0x5777,
+ 0x82db, 0x67ef, 0x68f5, 0x78d5, 0x9897, 0x79d1, 0x58f3, 0x54b3,
+ 0x53ef, 0x6e34, 0x514b, 0x523b, 0x5ba2, 0x8bfe, 0x80af, 0x5543,
+ 0x57a6, 0x6073, 0x5751, 0x542d, 0x7a7a, 0x6050, 0x5b54, 0x63a7,
+ 0x62a0, 0x53e3, 0x6263, 0x5bc7, 0x67af, 0x54ed, 0x7a9f, 0x82e6,
+ 0x9177, 0x5e93, 0x88e4, 0x5938, 0x57ae, 0x630e, 0x8de8, 0x80ef,
+ 0x5757, 0x7b77, 0x4fa9, 0x5feb, 0x5bbd, 0x6b3e, 0x5321, 0x7b50,
+ 0x72c2, 0x6846, 0x77ff, 0x7736, 0x65f7, 0x51b5, 0x4e8f, 0x76d4,
+ 0x5cbf, 0x7aa5, 0x8475, 0x594e, 0x9b41, 0x5080,
+ /* 0x40 */
+ 0x9988, 0x6127, 0x6e83, 0x5764, 0x6606, 0x6346, 0x56f0, 0x62ec,
+ 0x6269, 0x5ed3, 0x9614, 0x5783, 0x62c9, 0x5587, 0x8721, 0x814a,
+ 0x8fa3, 0x5566, 0x83b1, 0x6765, 0x8d56, 0x84dd, 0x5a6a, 0x680f,
+ 0x62e6, 0x7bee, 0x9611, 0x5170, 0x6f9c, 0x8c30, 0x63fd, 0x89c8,
+ 0x61d2, 0x7f06, 0x70c2, 0x6ee5, 0x7405, 0x6994, 0x72fc, 0x5eca,
+ 0x90ce, 0x6717, 0x6d6a, 0x635e, 0x52b3, 0x7262, 0x8001, 0x4f6c,
+ 0x59e5, 0x916a, 0x70d9, 0x6d9d, 0x52d2, 0x4e50, 0x96f7, 0x956d,
+ 0x857e, 0x78ca, 0x7d2f, 0x5121, 0x5792, 0x64c2, 0x808b, 0x7c7b,
+ 0x6cea, 0x68f1, 0x695e, 0x51b7, 0x5398, 0x68a8, 0x7281, 0x9ece,
+ 0x7bf1, 0x72f8, 0x79bb, 0x6f13, 0x7406, 0x674e, 0x91cc, 0x9ca4,
+ 0x793c, 0x8389, 0x8354, 0x540f, 0x6817, 0x4e3d, 0x5389, 0x52b1,
+ 0x783e, 0x5386, 0x5229, 0x5088, 0x4f8b, 0x4fd0,
+ /* 0x41 */
+ 0x75e2, 0x7acb, 0x7c92, 0x6ca5, 0x96b6, 0x529b, 0x7483, 0x54e9,
+ 0x4fe9, 0x8054, 0x83b2, 0x8fde, 0x9570, 0x5ec9, 0x601c, 0x6d9f,
+ 0x5e18, 0x655b, 0x8138, 0x94fe, 0x604b, 0x70bc, 0x7ec3, 0x7cae,
+ 0x51c9, 0x6881, 0x7cb1, 0x826f, 0x4e24, 0x8f86, 0x91cf, 0x667e,
+ 0x4eae, 0x8c05, 0x64a9, 0x804a, 0x50da, 0x7597, 0x71ce, 0x5be5,
+ 0x8fbd, 0x6f66, 0x4e86, 0x6482, 0x9563, 0x5ed6, 0x6599, 0x5217,
+ 0x88c2, 0x70c8, 0x52a3, 0x730e, 0x7433, 0x6797, 0x78f7, 0x9716,
+ 0x4e34, 0x90bb, 0x9cde, 0x6dcb, 0x51db, 0x8d41, 0x541d, 0x62ce,
+ 0x73b2, 0x83f1, 0x96f6, 0x9f84, 0x94c3, 0x4f36, 0x7f9a, 0x51cc,
+ 0x7075, 0x9675, 0x5cad, 0x9886, 0x53e6, 0x4ee4, 0x6e9c, 0x7409,
+ 0x69b4, 0x786b, 0x998f, 0x7559, 0x5218, 0x7624, 0x6d41, 0x67f3,
+ 0x516d, 0x9f99, 0x804b, 0x5499, 0x7b3c, 0x7abf,
+ /* 0x42 */
+ 0x9686, 0x5784, 0x62e2, 0x9647, 0x697c, 0x5a04, 0x6402, 0x7bd3,
+ 0x6f0f, 0x964b, 0x82a6, 0x5362, 0x9885, 0x5e90, 0x7089, 0x63b3,
+ 0x5364, 0x864f, 0x9c81, 0x9e93, 0x788c, 0x9732, 0x8def, 0x8d42,
+ 0x9e7f, 0x6f5e, 0x7984, 0x5f55, 0x9646, 0x622e, 0x9a74, 0x5415,
+ 0x94dd, 0x4fa3, 0x65c5, 0x5c65, 0x5c61, 0x7f15, 0x8651, 0x6c2f,
+ 0x5f8b, 0x7387, 0x6ee4, 0x7eff, 0x5ce6, 0x631b, 0x5b6a, 0x6ee6,
+ 0x5375, 0x4e71, 0x63a0, 0x7565, 0x62a1, 0x8f6e, 0x4f26, 0x4ed1,
+ 0x6ca6, 0x7eb6, 0x8bba, 0x841d, 0x87ba, 0x7f57, 0x903b, 0x9523,
+ 0x7ba9, 0x9aa1, 0x88f8, 0x843d, 0x6d1b, 0x9a86, 0x7edc, 0x5988,
+ 0x9ebb, 0x739b, 0x7801, 0x8682, 0x9a6c, 0x9a82, 0x561b, 0x5417,
+ 0x57cb, 0x4e70, 0x9ea6, 0x5356, 0x8fc8, 0x8109, 0x7792, 0x9992,
+ 0x86ee, 0x6ee1, 0x8513, 0x66fc, 0x6162, 0x6f2b,
+ /* 0x43 */
+ 0x8c29, 0x8292, 0x832b, 0x76f2, 0x6c13, 0x5fd9, 0x83bd, 0x732b,
+ 0x8305, 0x951a, 0x6bdb, 0x77db, 0x94c6, 0x536f, 0x8302, 0x5192,
+ 0x5e3d, 0x8c8c, 0x8d38, 0x4e48, 0x73ab, 0x679a, 0x6885, 0x9176,
+ 0x9709, 0x7164, 0x6ca1, 0x7709, 0x5a92, 0x9541, 0x6bcf, 0x7f8e,
+ 0x6627, 0x5bd0, 0x59b9, 0x5a9a, 0x95e8, 0x95f7, 0x4eec, 0x840c,
+ 0x8499, 0x6aac, 0x76df, 0x9530, 0x731b, 0x68a6, 0x5b5f, 0x772f,
+ 0x919a, 0x9761, 0x7cdc, 0x8ff7, 0x8c1c, 0x5f25, 0x7c73, 0x79d8,
+ 0x89c5, 0x6ccc, 0x871c, 0x5bc6, 0x5e42, 0x68c9, 0x7720, 0x7ef5,
+ 0x5195, 0x514d, 0x52c9, 0x5a29, 0x7f05, 0x9762, 0x82d7, 0x63cf,
+ 0x7784, 0x85d0, 0x79d2, 0x6e3a, 0x5e99, 0x5999, 0x8511, 0x706d,
+ 0x6c11, 0x62bf, 0x76bf, 0x654f, 0x60af, 0x95fd, 0x660e, 0x879f,
+ 0x9e23, 0x94ed, 0x540d, 0x547d, 0x8c2c, 0x6478,
+ /* 0x44 */
+ 0x6479, 0x8611, 0x6a21, 0x819c, 0x78e8, 0x6469, 0x9b54, 0x62b9,
+ 0x672b, 0x83ab, 0x58a8, 0x9ed8, 0x6cab, 0x6f20, 0x5bde, 0x964c,
+ 0x8c0b, 0x725f, 0x67d0, 0x62c7, 0x7261, 0x4ea9, 0x59c6, 0x6bcd,
+ 0x5893, 0x66ae, 0x5e55, 0x52df, 0x6155, 0x6728, 0x76ee, 0x7766,
+ 0x7267, 0x7a46, 0x62ff, 0x54ea, 0x5450, 0x94a0, 0x90a3, 0x5a1c,
+ 0x7eb3, 0x6c16, 0x4e43, 0x5976, 0x8010, 0x5948, 0x5357, 0x7537,
+ 0x96be, 0x56ca, 0x6320, 0x8111, 0x607c, 0x95f9, 0x6dd6, 0x5462,
+ 0x9981, 0x5185, 0x5ae9, 0x80fd, 0x59ae, 0x9713, 0x502a, 0x6ce5,
+ 0x5c3c, 0x62df, 0x4f60, 0x533f, 0x817b, 0x9006, 0x6eba, 0x852b,
+ 0x62c8, 0x5e74, 0x78be, 0x64b5, 0x637b, 0x5ff5, 0x5a18, 0x917f,
+ 0x9e1f, 0x5c3f, 0x634f, 0x8042, 0x5b7d, 0x556e, 0x954a, 0x954d,
+ 0x6d85, 0x60a8, 0x67e0, 0x72de, 0x51dd, 0x5b81,
+ /* 0x45 */
+ 0x62e7, 0x6cde, 0x725b, 0x626d, 0x94ae, 0x7ebd, 0x8113, 0x6d53,
+ 0x519c, 0x5f04, 0x5974, 0x52aa, 0x6012, 0x5973, 0x6696, 0x8650,
+ 0x759f, 0x632a, 0x61e6, 0x7cef, 0x8bfa, 0x54e6, 0x6b27, 0x9e25,
+ 0x6bb4, 0x85d5, 0x5455, 0x5076, 0x6ca4, 0x556a, 0x8db4, 0x722c,
+ 0x5e15, 0x6015, 0x7436, 0x62cd, 0x6392, 0x724c, 0x5f98, 0x6e43,
+ 0x6d3e, 0x6500, 0x6f58, 0x76d8, 0x78d0, 0x76fc, 0x7554, 0x5224,
+ 0x53db, 0x4e53, 0x5e9e, 0x65c1, 0x802a, 0x80d6, 0x629b, 0x5486,
+ 0x5228, 0x70ae, 0x888d, 0x8dd1, 0x6ce1, 0x5478, 0x80da, 0x57f9,
+ 0x88f4, 0x8d54, 0x966a, 0x914d, 0x4f69, 0x6c9b, 0x55b7, 0x76c6,
+ 0x7830, 0x62a8, 0x70f9, 0x6f8e, 0x5f6d, 0x84ec, 0x68da, 0x787c,
+ 0x7bf7, 0x81a8, 0x670b, 0x9e4f, 0x6367, 0x78b0, 0x576f, 0x7812,
+ 0x9739, 0x6279, 0x62ab, 0x5288, 0x7435, 0x6bd7,
+ /* 0x46 */
+ 0x5564, 0x813e, 0x75b2, 0x76ae, 0x5339, 0x75de, 0x50fb, 0x5c41,
+ 0x8b6c, 0x7bc7, 0x504f, 0x7247, 0x9a97, 0x98d8, 0x6f02, 0x74e2,
+ 0x7968, 0x6487, 0x77a5, 0x62fc, 0x9891, 0x8d2b, 0x54c1, 0x8058,
+ 0x4e52, 0x576a, 0x82f9, 0x840d, 0x5e73, 0x51ed, 0x74f6, 0x8bc4,
+ 0x5c4f, 0x5761, 0x6cfc, 0x9887, 0x5a46, 0x7834, 0x9b44, 0x8feb,
+ 0x7c95, 0x5256, 0x6251, 0x94fa, 0x4ec6, 0x8386, 0x8461, 0x83e9,
+ 0x84b2, 0x57d4, 0x6734, 0x5703, 0x666e, 0x6d66, 0x8c31, 0x66dd,
+ 0x7011, 0x671f, 0x6b3a, 0x6816, 0x621a, 0x59bb, 0x4e03, 0x51c4,
+ 0x6f06, 0x67d2, 0x6c8f, 0x5176, 0x68cb, 0x5947, 0x6b67, 0x7566,
+ 0x5d0e, 0x8110, 0x9f50, 0x65d7, 0x7948, 0x7941, 0x9a91, 0x8d77,
+ 0x5c82, 0x4e5e, 0x4f01, 0x542f, 0x5951, 0x780c, 0x5668, 0x6c14,
+ 0x8fc4, 0x5f03, 0x6c7d, 0x6ce3, 0x8bab, 0x6390,
+ /* 0x47 */
+ 0x6070, 0x6d3d, 0x7275, 0x6266, 0x948e, 0x94c5, 0x5343, 0x8fc1,
+ 0x7b7e, 0x4edf, 0x8c26, 0x4e7e, 0x9ed4, 0x94b1, 0x94b3, 0x524d,
+ 0x6f5c, 0x9063, 0x6d45, 0x8c34, 0x5811, 0x5d4c, 0x6b20, 0x6b49,
+ 0x67aa, 0x545b, 0x8154, 0x7f8c, 0x5899, 0x8537, 0x5f3a, 0x62a2,
+ 0x6a47, 0x9539, 0x6572, 0x6084, 0x6865, 0x77a7, 0x4e54, 0x4fa8,
+ 0x5de7, 0x9798, 0x64ac, 0x7fd8, 0x5ced, 0x4fcf, 0x7a8d, 0x5207,
+ 0x8304, 0x4e14, 0x602f, 0x7a83, 0x94a6, 0x4fb5, 0x4eb2, 0x79e6,
+ 0x7434, 0x52e4, 0x82b9, 0x64d2, 0x79bd, 0x5bdd, 0x6c81, 0x9752,
+ 0x8f7b, 0x6c22, 0x503e, 0x537f, 0x6e05, 0x64ce, 0x6674, 0x6c30,
+ 0x60c5, 0x9877, 0x8bf7, 0x5e86, 0x743c, 0x7a77, 0x79cb, 0x4e18,
+ 0x90b1, 0x7403, 0x6c42, 0x56da, 0x914b, 0x6cc5, 0x8d8b, 0x533a,
+ 0x86c6, 0x66f2, 0x8eaf, 0x5c48, 0x9a71, 0x6e20,
+ /* 0x48 */
+ 0x53d6, 0x5a36, 0x9f8b, 0x8da3, 0x53bb, 0x5708, 0x98a7, 0x6743,
+ 0x919b, 0x6cc9, 0x5168, 0x75ca, 0x62f3, 0x72ac, 0x5238, 0x529d,
+ 0x7f3a, 0x7094, 0x7638, 0x5374, 0x9e4a, 0x69b7, 0x786e, 0x96c0,
+ 0x88d9, 0x7fa4, 0x7136, 0x71c3, 0x5189, 0x67d3, 0x74e4, 0x58e4,
+ 0x6518, 0x56b7, 0x8ba9, 0x9976, 0x6270, 0x7ed5, 0x60f9, 0x70ed,
+ 0x58ec, 0x4ec1, 0x4eba, 0x5fcd, 0x97e7, 0x4efb, 0x8ba4, 0x5203,
+ 0x598a, 0x7eab, 0x6254, 0x4ecd, 0x65e5, 0x620e, 0x8338, 0x84c9,
+ 0x8363, 0x878d, 0x7194, 0x6eb6, 0x5bb9, 0x7ed2, 0x5197, 0x63c9,
+ 0x67d4, 0x8089, 0x8339, 0x8815, 0x5112, 0x5b7a, 0x5982, 0x8fb1,
+ 0x4e73, 0x6c5d, 0x5165, 0x8925, 0x8f6f, 0x962e, 0x854a, 0x745e,
+ 0x9510, 0x95f0, 0x6da6, 0x82e5, 0x5f31, 0x6492, 0x6d12, 0x8428,
+ 0x816e, 0x9cc3, 0x585e, 0x8d5b, 0x4e09, 0x53c1,
+ /* 0x49 */
+ 0x4f1e, 0x6563, 0x6851, 0x55d3, 0x4e27, 0x6414, 0x9a9a, 0x626b,
+ 0x5ac2, 0x745f, 0x8272, 0x6da9, 0x68ee, 0x50e7, 0x838e, 0x7802,
+ 0x6740, 0x5239, 0x6c99, 0x7eb1, 0x50bb, 0x5565, 0x715e, 0x7b5b,
+ 0x6652, 0x73ca, 0x82eb, 0x6749, 0x5c71, 0x5220, 0x717d, 0x886b,
+ 0x95ea, 0x9655, 0x64c5, 0x8d61, 0x81b3, 0x5584, 0x6c55, 0x6247,
+ 0x7f2e, 0x5892, 0x4f24, 0x5546, 0x8d4f, 0x664c, 0x4e0a, 0x5c1a,
+ 0x88f3, 0x68a2, 0x634e, 0x7a0d, 0x70e7, 0x828d, 0x52fa, 0x97f6,
+ 0x5c11, 0x54e8, 0x90b5, 0x7ecd, 0x5962, 0x8d4a, 0x86c7, 0x820c,
+ 0x820d, 0x8d66, 0x6444, 0x5c04, 0x6151, 0x6d89, 0x793e, 0x8bbe,
+ 0x7837, 0x7533, 0x547b, 0x4f38, 0x8eab, 0x6df1, 0x5a20, 0x7ec5,
+ 0x795e, 0x6c88, 0x5ba1, 0x5a76, 0x751a, 0x80be, 0x614e, 0x6e17,
+ 0x58f0, 0x751f, 0x7525, 0x7272, 0x5347, 0x7ef3,
+ /* 0x4a */
+ 0x7701, 0x76db, 0x5269, 0x80dc, 0x5723, 0x5e08, 0x5931, 0x72ee,
+ 0x65bd, 0x6e7f, 0x8bd7, 0x5c38, 0x8671, 0x5341, 0x77f3, 0x62fe,
+ 0x65f6, 0x4ec0, 0x98df, 0x8680, 0x5b9e, 0x8bc6, 0x53f2, 0x77e2,
+ 0x4f7f, 0x5c4e, 0x9a76, 0x59cb, 0x5f0f, 0x793a, 0x58eb, 0x4e16,
+ 0x67ff, 0x4e8b, 0x62ed, 0x8a93, 0x901d, 0x52bf, 0x662f, 0x55dc,
+ 0x566c, 0x9002, 0x4ed5, 0x4f8d, 0x91ca, 0x9970, 0x6c0f, 0x5e02,
+ 0x6043, 0x5ba4, 0x89c6, 0x8bd5, 0x6536, 0x624b, 0x9996, 0x5b88,
+ 0x5bff, 0x6388, 0x552e, 0x53d7, 0x7626, 0x517d, 0x852c, 0x67a2,
+ 0x68b3, 0x6b8a, 0x6292, 0x8f93, 0x53d4, 0x8212, 0x6dd1, 0x758f,
+ 0x4e66, 0x8d4e, 0x5b70, 0x719f, 0x85af, 0x6691, 0x66d9, 0x7f72,
+ 0x8700, 0x9ecd, 0x9f20, 0x5c5e, 0x672f, 0x8ff0, 0x6811, 0x675f,
+ 0x620d, 0x7ad6, 0x5885, 0x5eb6, 0x6570, 0x6f31,
+ /* 0x4b */
+ 0x6055, 0x5237, 0x800d, 0x6454, 0x8870, 0x7529, 0x5e05, 0x6813,
+ 0x62f4, 0x971c, 0x53cc, 0x723d, 0x8c01, 0x6c34, 0x7761, 0x7a0e,
+ 0x542e, 0x77ac, 0x987a, 0x821c, 0x8bf4, 0x7855, 0x6714, 0x70c1,
+ 0x65af, 0x6495, 0x5636, 0x601d, 0x79c1, 0x53f8, 0x4e1d, 0x6b7b,
+ 0x8086, 0x5bfa, 0x55e3, 0x56db, 0x4f3a, 0x4f3c, 0x9972, 0x5df3,
+ 0x677e, 0x8038, 0x6002, 0x9882, 0x9001, 0x5b8b, 0x8bbc, 0x8bf5,
+ 0x641c, 0x8258, 0x64de, 0x55fd, 0x82cf, 0x9165, 0x4fd7, 0x7d20,
+ 0x901f, 0x7c9f, 0x50f3, 0x5851, 0x6eaf, 0x5bbf, 0x8bc9, 0x8083,
+ 0x9178, 0x849c, 0x7b97, 0x867d, 0x968b, 0x968f, 0x7ee5, 0x9ad3,
+ 0x788e, 0x5c81, 0x7a57, 0x9042, 0x96a7, 0x795f, 0x5b59, 0x635f,
+ 0x7b0b, 0x84d1, 0x68ad, 0x5506, 0x7f29, 0x7410, 0x7d22, 0x9501,
+ 0x6240, 0x584c, 0x4ed6, 0x5b83, 0x5979, 0x5854,
+ /* 0x4c */
+ 0x736d, 0x631e, 0x8e4b, 0x8e0f, 0x80ce, 0x82d4, 0x62ac, 0x53f0,
+ 0x6cf0, 0x915e, 0x592a, 0x6001, 0x6c70, 0x574d, 0x644a, 0x8d2a,
+ 0x762b, 0x6ee9, 0x575b, 0x6a80, 0x75f0, 0x6f6d, 0x8c2d, 0x8c08,
+ 0x5766, 0x6bef, 0x8892, 0x78b3, 0x63a2, 0x53f9, 0x70ad, 0x6c64,
+ 0x5858, 0x642a, 0x5802, 0x68e0, 0x819b, 0x5510, 0x7cd6, 0x5018,
+ 0x8eba, 0x6dcc, 0x8d9f, 0x70eb, 0x638f, 0x6d9b, 0x6ed4, 0x7ee6,
+ 0x8404, 0x6843, 0x9003, 0x6dd8, 0x9676, 0x8ba8, 0x5957, 0x7279,
+ 0x85e4, 0x817e, 0x75bc, 0x8a8a, 0x68af, 0x5254, 0x8e22, 0x9511,
+ 0x63d0, 0x9898, 0x8e44, 0x557c, 0x4f53, 0x66ff, 0x568f, 0x60d5,
+ 0x6d95, 0x5243, 0x5c49, 0x5929, 0x6dfb, 0x586b, 0x7530, 0x751c,
+ 0x606c, 0x8214, 0x8146, 0x6311, 0x6761, 0x8fe2, 0x773a, 0x8df3,
+ 0x8d34, 0x94c1, 0x5e16, 0x5385, 0x542c, 0x70c3,
+ /* 0x4d */
+ 0x6c40, 0x5ef7, 0x505c, 0x4ead, 0x5ead, 0x633a, 0x8247, 0x901a,
+ 0x6850, 0x916e, 0x77b3, 0x540c, 0x94dc, 0x5f64, 0x7ae5, 0x6876,
+ 0x6345, 0x7b52, 0x7edf, 0x75db, 0x5077, 0x6295, 0x5934, 0x900f,
+ 0x51f8, 0x79c3, 0x7a81, 0x56fe, 0x5f92, 0x9014, 0x6d82, 0x5c60,
+ 0x571f, 0x5410, 0x5154, 0x6e4d, 0x56e2, 0x63a8, 0x9893, 0x817f,
+ 0x8715, 0x892a, 0x9000, 0x541e, 0x5c6f, 0x81c0, 0x62d6, 0x6258,
+ 0x8131, 0x9e35, 0x9640, 0x9a6e, 0x9a7c, 0x692d, 0x59a5, 0x62d3,
+ 0x553e, 0x6316, 0x54c7, 0x86d9, 0x6d3c, 0x5a03, 0x74e6, 0x889c,
+ 0x6b6a, 0x5916, 0x8c4c, 0x5f2f, 0x6e7e, 0x73a9, 0x987d, 0x4e38,
+ 0x70f7, 0x5b8c, 0x7897, 0x633d, 0x665a, 0x7696, 0x60cb, 0x5b9b,
+ 0x5a49, 0x4e07, 0x8155, 0x6c6a, 0x738b, 0x4ea1, 0x6789, 0x7f51,
+ 0x5f80, 0x65fa, 0x671b, 0x5fd8, 0x5984, 0x5a01,
+ /* 0x4e */
+ 0x5dcd, 0x5fae, 0x5371, 0x97e6, 0x8fdd, 0x6845, 0x56f4, 0x552f,
+ 0x60df, 0x4e3a, 0x6f4d, 0x7ef4, 0x82c7, 0x840e, 0x59d4, 0x4f1f,
+ 0x4f2a, 0x5c3e, 0x7eac, 0x672a, 0x851a, 0x5473, 0x754f, 0x80c3,
+ 0x5582, 0x9b4f, 0x4f4d, 0x6e2d, 0x8c13, 0x5c09, 0x6170, 0x536b,
+ 0x761f, 0x6e29, 0x868a, 0x6587, 0x95fb, 0x7eb9, 0x543b, 0x7a33,
+ 0x7d0a, 0x95ee, 0x55e1, 0x7fc1, 0x74ee, 0x631d, 0x8717, 0x6da1,
+ 0x7a9d, 0x6211, 0x65a1, 0x5367, 0x63e1, 0x6c83, 0x5deb, 0x545c,
+ 0x94a8, 0x4e4c, 0x6c61, 0x8bec, 0x5c4b, 0x65e0, 0x829c, 0x68a7,
+ 0x543e, 0x5434, 0x6bcb, 0x6b66, 0x4e94, 0x6342, 0x5348, 0x821e,
+ 0x4f0d, 0x4fae, 0x575e, 0x620a, 0x96fe, 0x6664, 0x7269, 0x52ff,
+ 0x52a1, 0x609f, 0x8bef, 0x6614, 0x7199, 0x6790, 0x897f, 0x7852,
+ 0x77fd, 0x6670, 0x563b, 0x5438, 0x9521, 0x727a,
+ /* 0x4f */
+ 0x7a00, 0x606f, 0x5e0c, 0x6089, 0x819d, 0x5915, 0x60dc, 0x7184,
+ 0x70ef, 0x6eaa, 0x6c50, 0x7280, 0x6a84, 0x88ad, 0x5e2d, 0x4e60,
+ 0x5ab3, 0x559c, 0x94e3, 0x6d17, 0x7cfb, 0x9699, 0x620f, 0x7ec6,
+ 0x778e, 0x867e, 0x5323, 0x971e, 0x8f96, 0x6687, 0x5ce1, 0x4fa0,
+ 0x72ed, 0x4e0b, 0x53a6, 0x590f, 0x5413, 0x6380, 0x9528, 0x5148,
+ 0x4ed9, 0x9c9c, 0x7ea4, 0x54b8, 0x8d24, 0x8854, 0x8237, 0x95f2,
+ 0x6d8e, 0x5f26, 0x5acc, 0x663e, 0x9669, 0x73b0, 0x732e, 0x53bf,
+ 0x817a, 0x9985, 0x7fa1, 0x5baa, 0x9677, 0x9650, 0x7ebf, 0x76f8,
+ 0x53a2, 0x9576, 0x9999, 0x7bb1, 0x8944, 0x6e58, 0x4e61, 0x7fd4,
+ 0x7965, 0x8be6, 0x60f3, 0x54cd, 0x4eab, 0x9879, 0x5df7, 0x6a61,
+ 0x50cf, 0x5411, 0x8c61, 0x8427, 0x785d, 0x9704, 0x524a, 0x54ee,
+ 0x56a3, 0x9500, 0x6d88, 0x5bb5, 0x6dc6, 0x6653,
+ /* 0x50 */
+ 0x5c0f, 0x5b5d, 0x6821, 0x8096, 0x5578, 0x7b11, 0x6548, 0x6954,
+ 0x4e9b, 0x6b47, 0x874e, 0x978b, 0x534f, 0x631f, 0x643a, 0x90aa,
+ 0x659c, 0x80c1, 0x8c10, 0x5199, 0x68b0, 0x5378, 0x87f9, 0x61c8,
+ 0x6cc4, 0x6cfb, 0x8c22, 0x5c51, 0x85aa, 0x82af, 0x950c, 0x6b23,
+ 0x8f9b, 0x65b0, 0x5ffb, 0x5fc3, 0x4fe1, 0x8845, 0x661f, 0x8165,
+ 0x7329, 0x60fa, 0x5174, 0x5211, 0x578b, 0x5f62, 0x90a2, 0x884c,
+ 0x9192, 0x5e78, 0x674f, 0x6027, 0x59d3, 0x5144, 0x51f6, 0x80f8,
+ 0x5308, 0x6c79, 0x96c4, 0x718a, 0x4f11, 0x4fee, 0x7f9e, 0x673d,
+ 0x55c5, 0x9508, 0x79c0, 0x8896, 0x7ee3, 0x589f, 0x620c, 0x9700,
+ 0x865a, 0x5618, 0x987b, 0x5f90, 0x8bb8, 0x84c4, 0x9157, 0x53d9,
+ 0x65ed, 0x5e8f, 0x755c, 0x6064, 0x7d6e, 0x5a7f, 0x7eea, 0x7eed,
+ 0x8f69, 0x55a7, 0x5ba3, 0x60ac, 0x65cb, 0x7384,
+ /* 0x51 */
+ 0x9009, 0x7663, 0x7729, 0x7eda, 0x9774, 0x859b, 0x5b66, 0x7a74,
+ 0x96ea, 0x8840, 0x52cb, 0x718f, 0x5faa, 0x65ec, 0x8be2, 0x5bfb,
+ 0x9a6f, 0x5de1, 0x6b89, 0x6c5b, 0x8bad, 0x8baf, 0x900a, 0x8fc5,
+ 0x538b, 0x62bc, 0x9e26, 0x9e2d, 0x5440, 0x4e2b, 0x82bd, 0x7259,
+ 0x869c, 0x5d16, 0x8859, 0x6daf, 0x96c5, 0x54d1, 0x4e9a, 0x8bb6,
+ 0x7109, 0x54bd, 0x9609, 0x70df, 0x6df9, 0x76d0, 0x4e25, 0x7814,
+ 0x8712, 0x5ca9, 0x5ef6, 0x8a00, 0x989c, 0x960e, 0x708e, 0x6cbf,
+ 0x5944, 0x63a9, 0x773c, 0x884d, 0x6f14, 0x8273, 0x5830, 0x71d5,
+ 0x538c, 0x781a, 0x96c1, 0x5501, 0x5f66, 0x7130, 0x5bb4, 0x8c1a,
+ 0x9a8c, 0x6b83, 0x592e, 0x9e2f, 0x79e7, 0x6768, 0x626c, 0x4f6f,
+ 0x75a1, 0x7f8a, 0x6d0b, 0x9633, 0x6c27, 0x4ef0, 0x75d2, 0x517b,
+ 0x6837, 0x6f3e, 0x9080, 0x8170, 0x5996, 0x7476,
+ /* 0x52 */
+ 0x6447, 0x5c27, 0x9065, 0x7a91, 0x8c23, 0x59da, 0x54ac, 0x8200,
+ 0x836f, 0x8981, 0x8000, 0x6930, 0x564e, 0x8036, 0x7237, 0x91ce,
+ 0x51b6, 0x4e5f, 0x9875, 0x6396, 0x4e1a, 0x53f6, 0x66f3, 0x814b,
+ 0x591c, 0x6db2, 0x4e00, 0x58f9, 0x533b, 0x63d6, 0x94f1, 0x4f9d,
+ 0x4f0a, 0x8863, 0x9890, 0x5937, 0x9057, 0x79fb, 0x4eea, 0x80f0,
+ 0x7591, 0x6c82, 0x5b9c, 0x59e8, 0x5f5d, 0x6905, 0x8681, 0x501a,
+ 0x5df2, 0x4e59, 0x77e3, 0x4ee5, 0x827a, 0x6291, 0x6613, 0x9091,
+ 0x5c79, 0x4ebf, 0x5f79, 0x81c6, 0x9038, 0x8084, 0x75ab, 0x4ea6,
+ 0x88d4, 0x610f, 0x6bc5, 0x5fc6, 0x4e49, 0x76ca, 0x6ea2, 0x8be3,
+ 0x8bae, 0x8c0a, 0x8bd1, 0x5f02, 0x7ffc, 0x7fcc, 0x7ece, 0x8335,
+ 0x836b, 0x56e0, 0x6bb7, 0x97f3, 0x9634, 0x59fb, 0x541f, 0x94f6,
+ 0x6deb, 0x5bc5, 0x996e, 0x5c39, 0x5f15, 0x9690,
+ /* 0x53 */
+ 0x5370, 0x82f1, 0x6a31, 0x5a74, 0x9e70, 0x5e94, 0x7f28, 0x83b9,
+ 0x8424, 0x8425, 0x8367, 0x8747, 0x8fce, 0x8d62, 0x76c8, 0x5f71,
+ 0x9896, 0x786c, 0x6620, 0x54df, 0x62e5, 0x4f63, 0x81c3, 0x75c8,
+ 0x5eb8, 0x96cd, 0x8e0a, 0x86f9, 0x548f, 0x6cf3, 0x6d8c, 0x6c38,
+ 0x607f, 0x52c7, 0x7528, 0x5e7d, 0x4f18, 0x60a0, 0x5fe7, 0x5c24,
+ 0x7531, 0x90ae, 0x94c0, 0x72b9, 0x6cb9, 0x6e38, 0x9149, 0x6709,
+ 0x53cb, 0x53f3, 0x4f51, 0x91c9, 0x8bf1, 0x53c8, 0x5e7c, 0x8fc2,
+ 0x6de4, 0x4e8e, 0x76c2, 0x6986, 0x865e, 0x611a, 0x8206, 0x4f59,
+ 0x4fde, 0x903e, 0x9c7c, 0x6109, 0x6e1d, 0x6e14, 0x9685, 0x4e88,
+ 0x5a31, 0x96e8, 0x4e0e, 0x5c7f, 0x79b9, 0x5b87, 0x8bed, 0x7fbd,
+ 0x7389, 0x57df, 0x828b, 0x90c1, 0x5401, 0x9047, 0x55bb, 0x5cea,
+ 0x5fa1, 0x6108, 0x6b32, 0x72f1, 0x80b2, 0x8a89,
+ /* 0x54 */
+ 0x6d74, 0x5bd3, 0x88d5, 0x9884, 0x8c6b, 0x9a6d, 0x9e33, 0x6e0a,
+ 0x51a4, 0x5143, 0x57a3, 0x8881, 0x539f, 0x63f4, 0x8f95, 0x56ed,
+ 0x5458, 0x5706, 0x733f, 0x6e90, 0x7f18, 0x8fdc, 0x82d1, 0x613f,
+ 0x6028, 0x9662, 0x66f0, 0x7ea6, 0x8d8a, 0x8dc3, 0x94a5, 0x5cb3,
+ 0x7ca4, 0x6708, 0x60a6, 0x9605, 0x8018, 0x4e91, 0x90e7, 0x5300,
+ 0x9668, 0x5141, 0x8fd0, 0x8574, 0x915d, 0x6655, 0x97f5, 0x5b55,
+ 0x531d, 0x7838, 0x6742, 0x683d, 0x54c9, 0x707e, 0x5bb0, 0x8f7d,
+ 0x518d, 0x5728, 0x54b1, 0x6512, 0x6682, 0x8d5e, 0x8d43, 0x810f,
+ 0x846c, 0x906d, 0x7cdf, 0x51ff, 0x85fb, 0x67a3, 0x65e9, 0x6fa1,
+ 0x86a4, 0x8e81, 0x566a, 0x9020, 0x7682, 0x7076, 0x71e5, 0x8d23,
+ 0x62e9, 0x5219, 0x6cfd, 0x8d3c, 0x600e, 0x589e, 0x618e, 0x66fe,
+ 0x8d60, 0x624e, 0x55b3, 0x6e23, 0x672d, 0x8f67,
+ /* 0x55 */
+ 0x94e1, 0x95f8, 0x7728, 0x6805, 0x69a8, 0x548b, 0x4e4d, 0x70b8,
+ 0x8bc8, 0x6458, 0x658b, 0x5b85, 0x7a84, 0x503a, 0x5be8, 0x77bb,
+ 0x6be1, 0x8a79, 0x7c98, 0x6cbe, 0x76cf, 0x65a9, 0x8f97, 0x5d2d,
+ 0x5c55, 0x8638, 0x6808, 0x5360, 0x6218, 0x7ad9, 0x6e5b, 0x7efd,
+ 0x6a1f, 0x7ae0, 0x5f70, 0x6f33, 0x5f20, 0x638c, 0x6da8, 0x6756,
+ 0x4e08, 0x5e10, 0x8d26, 0x4ed7, 0x80c0, 0x7634, 0x969c, 0x62db,
+ 0x662d, 0x627e, 0x6cbc, 0x8d75, 0x7167, 0x7f69, 0x5146, 0x8087,
+ 0x53ec, 0x906e, 0x6298, 0x54f2, 0x86f0, 0x8f99, 0x8005, 0x9517,
+ 0x8517, 0x8fd9, 0x6d59, 0x73cd, 0x659f, 0x771f, 0x7504, 0x7827,
+ 0x81fb, 0x8d1e, 0x9488, 0x4fa6, 0x6795, 0x75b9, 0x8bca, 0x9707,
+ 0x632f, 0x9547, 0x9635, 0x84b8, 0x6323, 0x7741, 0x5f81, 0x72f0,
+ 0x4e89, 0x6014, 0x6574, 0x62ef, 0x6b63, 0x653f,
+ /* 0x56 */
+ 0x5e27, 0x75c7, 0x90d1, 0x8bc1, 0x829d, 0x679d, 0x652f, 0x5431,
+ 0x8718, 0x77e5, 0x80a2, 0x8102, 0x6c41, 0x4e4b, 0x7ec7, 0x804c,
+ 0x76f4, 0x690d, 0x6b96, 0x6267, 0x503c, 0x4f84, 0x5740, 0x6307,
+ 0x6b62, 0x8dbe, 0x53ea, 0x65e8, 0x7eb8, 0x5fd7, 0x631a, 0x63b7,
+ 0x81f3, 0x81f4, 0x7f6e, 0x5e1c, 0x5cd9, 0x5236, 0x667a, 0x79e9,
+ 0x7a1a, 0x8d28, 0x7099, 0x75d4, 0x6ede, 0x6cbb, 0x7a92, 0x4e2d,
+ 0x76c5, 0x5fe0, 0x949f, 0x8877, 0x7ec8, 0x79cd, 0x80bf, 0x91cd,
+ 0x4ef2, 0x4f17, 0x821f, 0x5468, 0x5dde, 0x6d32, 0x8bcc, 0x7ca5,
+ 0x8f74, 0x8098, 0x5e1a, 0x5492, 0x76b1, 0x5b99, 0x663c, 0x9aa4,
+ 0x73e0, 0x682a, 0x86db, 0x6731, 0x732a, 0x8bf8, 0x8bdb, 0x9010,
+ 0x7af9, 0x70db, 0x716e, 0x62c4, 0x77a9, 0x5631, 0x4e3b, 0x8457,
+ 0x67f1, 0x52a9, 0x86c0, 0x8d2e, 0x94f8, 0x7b51,
+ /* 0x57 */
+ 0x4f4f, 0x6ce8, 0x795d, 0x9a7b, 0x6293, 0x722a, 0x62fd, 0x4e13,
+ 0x7816, 0x8f6c, 0x64b0, 0x8d5a, 0x7bc6, 0x6869, 0x5e84, 0x88c5,
+ 0x5986, 0x649e, 0x58ee, 0x72b6, 0x690e, 0x9525, 0x8ffd, 0x8d58,
+ 0x5760, 0x7f00, 0x8c06, 0x51c6, 0x6349, 0x62d9, 0x5353, 0x684c,
+ 0x7422, 0x8301, 0x914c, 0x5544, 0x7740, 0x707c, 0x6d4a, 0x5179,
+ 0x54a8, 0x8d44, 0x59ff, 0x6ecb, 0x6dc4, 0x5b5c, 0x7d2b, 0x4ed4,
+ 0x7c7d, 0x6ed3, 0x5b50, 0x81ea, 0x6e0d, 0x5b57, 0x9b03, 0x68d5,
+ 0x8e2a, 0x5b97, 0x7efc, 0x603b, 0x7eb5, 0x90b9, 0x8d70, 0x594f,
+ 0x63cd, 0x79df, 0x8db3, 0x5352, 0x65cf, 0x7956, 0x8bc5, 0x963b,
+ 0x7ec4, 0x94bb, 0x7e82, 0x5634, 0x9189, 0x6700, 0x7f6a, 0x5c0a,
+ 0x9075, 0x6628, 0x5de6, 0x4f50, 0x67de, 0x505a, 0x4f5c, 0x5750,
+ 0x5ea7, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x58 */
+ 0x4e8d, 0x4e0c, 0x5140, 0x4e10, 0x5eff, 0x5345, 0x4e15, 0x4e98,
+ 0x4e1e, 0x9b32, 0x5b6c, 0x5669, 0x4e28, 0x79ba, 0x4e3f, 0x5315,
+ 0x4e47, 0x592d, 0x723b, 0x536e, 0x6c10, 0x56df, 0x80e4, 0x9997,
+ 0x6bd3, 0x777e, 0x9f17, 0x4e36, 0x4e9f, 0x9f10, 0x4e5c, 0x4e69,
+ 0x4e93, 0x8288, 0x5b5b, 0x556c, 0x560f, 0x4ec4, 0x538d, 0x539d,
+ 0x53a3, 0x53a5, 0x53ae, 0x9765, 0x8d5d, 0x531a, 0x53f5, 0x5326,
+ 0x532e, 0x533e, 0x8d5c, 0x5366, 0x5363, 0x5202, 0x5208, 0x520e,
+ 0x522d, 0x5233, 0x523f, 0x5240, 0x524c, 0x525e, 0x5261, 0x525c,
+ 0x84af, 0x527d, 0x5282, 0x5281, 0x5290, 0x5293, 0x5182, 0x7f54,
+ 0x4ebb, 0x4ec3, 0x4ec9, 0x4ec2, 0x4ee8, 0x4ee1, 0x4eeb, 0x4ede,
+ 0x4f1b, 0x4ef3, 0x4f22, 0x4f64, 0x4ef5, 0x4f25, 0x4f27, 0x4f09,
+ 0x4f2b, 0x4f5e, 0x4f67, 0x6538, 0x4f5a, 0x4f5d,
+ /* 0x59 */
+ 0x4f5f, 0x4f57, 0x4f32, 0x4f3d, 0x4f76, 0x4f74, 0x4f91, 0x4f89,
+ 0x4f83, 0x4f8f, 0x4f7e, 0x4f7b, 0x4faa, 0x4f7c, 0x4fac, 0x4f94,
+ 0x4fe6, 0x4fe8, 0x4fea, 0x4fc5, 0x4fda, 0x4fe3, 0x4fdc, 0x4fd1,
+ 0x4fdf, 0x4ff8, 0x5029, 0x504c, 0x4ff3, 0x502c, 0x500f, 0x502e,
+ 0x502d, 0x4ffe, 0x501c, 0x500c, 0x5025, 0x5028, 0x507e, 0x5043,
+ 0x5055, 0x5048, 0x504e, 0x506c, 0x507b, 0x50a5, 0x50a7, 0x50a9,
+ 0x50ba, 0x50d6, 0x5106, 0x50ed, 0x50ec, 0x50e6, 0x50ee, 0x5107,
+ 0x510b, 0x4edd, 0x6c3d, 0x4f58, 0x4f65, 0x4fce, 0x9fa0, 0x6c46,
+ 0x7c74, 0x516e, 0x5dfd, 0x9ec9, 0x9998, 0x5181, 0x5914, 0x52f9,
+ 0x530d, 0x8a07, 0x5310, 0x51eb, 0x5919, 0x5155, 0x4ea0, 0x5156,
+ 0x4eb3, 0x886e, 0x88a4, 0x4eb5, 0x8114, 0x88d2, 0x7980, 0x5b34,
+ 0x8803, 0x7fb8, 0x51ab, 0x51b1, 0x51bd, 0x51bc,
+ /* 0x5a */
+ 0x51c7, 0x5196, 0x51a2, 0x51a5, 0x8ba0, 0x8ba6, 0x8ba7, 0x8baa,
+ 0x8bb4, 0x8bb5, 0x8bb7, 0x8bc2, 0x8bc3, 0x8bcb, 0x8bcf, 0x8bce,
+ 0x8bd2, 0x8bd3, 0x8bd4, 0x8bd6, 0x8bd8, 0x8bd9, 0x8bdc, 0x8bdf,
+ 0x8be0, 0x8be4, 0x8be8, 0x8be9, 0x8bee, 0x8bf0, 0x8bf3, 0x8bf6,
+ 0x8bf9, 0x8bfc, 0x8bff, 0x8c00, 0x8c02, 0x8c04, 0x8c07, 0x8c0c,
+ 0x8c0f, 0x8c11, 0x8c12, 0x8c14, 0x8c15, 0x8c16, 0x8c19, 0x8c1b,
+ 0x8c18, 0x8c1d, 0x8c1f, 0x8c20, 0x8c21, 0x8c25, 0x8c27, 0x8c2a,
+ 0x8c2b, 0x8c2e, 0x8c2f, 0x8c32, 0x8c33, 0x8c35, 0x8c36, 0x5369,
+ 0x537a, 0x961d, 0x9622, 0x9621, 0x9631, 0x962a, 0x963d, 0x963c,
+ 0x9642, 0x9649, 0x9654, 0x965f, 0x9667, 0x966c, 0x9672, 0x9674,
+ 0x9688, 0x968d, 0x9697, 0x96b0, 0x9097, 0x909b, 0x909d, 0x9099,
+ 0x90ac, 0x90a1, 0x90b4, 0x90b3, 0x90b6, 0x90ba,
+ /* 0x5b */
+ 0x90b8, 0x90b0, 0x90cf, 0x90c5, 0x90be, 0x90d0, 0x90c4, 0x90c7,
+ 0x90d3, 0x90e6, 0x90e2, 0x90dc, 0x90d7, 0x90db, 0x90eb, 0x90ef,
+ 0x90fe, 0x9104, 0x9122, 0x911e, 0x9123, 0x9131, 0x912f, 0x9139,
+ 0x9143, 0x9146, 0x520d, 0x5942, 0x52a2, 0x52ac, 0x52ad, 0x52be,
+ 0x54ff, 0x52d0, 0x52d6, 0x52f0, 0x53df, 0x71ee, 0x77cd, 0x5ef4,
+ 0x51f5, 0x51fc, 0x9b2f, 0x53b6, 0x5f01, 0x755a, 0x5def, 0x574c,
+ 0x57a9, 0x57a1, 0x587e, 0x58bc, 0x58c5, 0x58d1, 0x5729, 0x572c,
+ 0x572a, 0x5733, 0x5739, 0x572e, 0x572f, 0x575c, 0x573b, 0x5742,
+ 0x5769, 0x5785, 0x576b, 0x5786, 0x577c, 0x577b, 0x5768, 0x576d,
+ 0x5776, 0x5773, 0x57ad, 0x57a4, 0x578c, 0x57b2, 0x57cf, 0x57a7,
+ 0x57b4, 0x5793, 0x57a0, 0x57d5, 0x57d8, 0x57da, 0x57d9, 0x57d2,
+ 0x57b8, 0x57f4, 0x57ef, 0x57f8, 0x57e4, 0x57dd,
+ /* 0x5c */
+ 0x580b, 0x580d, 0x57fd, 0x57ed, 0x5800, 0x581e, 0x5819, 0x5844,
+ 0x5820, 0x5865, 0x586c, 0x5881, 0x5889, 0x589a, 0x5880, 0x99a8,
+ 0x9f19, 0x61ff, 0x8279, 0x827d, 0x827f, 0x828f, 0x828a, 0x82a8,
+ 0x8284, 0x828e, 0x8291, 0x8297, 0x8299, 0x82ab, 0x82b8, 0x82be,
+ 0x82b0, 0x82c8, 0x82ca, 0x82e3, 0x8298, 0x82b7, 0x82ae, 0x82cb,
+ 0x82cc, 0x82c1, 0x82a9, 0x82b4, 0x82a1, 0x82aa, 0x829f, 0x82c4,
+ 0x82ce, 0x82a4, 0x82e1, 0x8309, 0x82f7, 0x82e4, 0x830f, 0x8307,
+ 0x82dc, 0x82f4, 0x82d2, 0x82d8, 0x830c, 0x82fb, 0x82d3, 0x8311,
+ 0x831a, 0x8306, 0x8314, 0x8315, 0x82e0, 0x82d5, 0x831c, 0x8351,
+ 0x835b, 0x835c, 0x8308, 0x8392, 0x833c, 0x8334, 0x8331, 0x839b,
+ 0x835e, 0x832f, 0x834f, 0x8347, 0x8343, 0x835f, 0x8340, 0x8317,
+ 0x8360, 0x832d, 0x833a, 0x8333, 0x8366, 0x8365,
+ /* 0x5d */
+ 0x8368, 0x831b, 0x8369, 0x836c, 0x836a, 0x836d, 0x836e, 0x83b0,
+ 0x8378, 0x83b3, 0x83b4, 0x83a0, 0x83aa, 0x8393, 0x839c, 0x8385,
+ 0x837c, 0x83b6, 0x83a9, 0x837d, 0x83b8, 0x837b, 0x8398, 0x839e,
+ 0x83a8, 0x83ba, 0x83bc, 0x83c1, 0x8401, 0x83e5, 0x83d8, 0x5807,
+ 0x8418, 0x840b, 0x83dd, 0x83fd, 0x83d6, 0x841c, 0x8438, 0x8411,
+ 0x8406, 0x83d4, 0x83df, 0x840f, 0x8403, 0x83f8, 0x83f9, 0x83ea,
+ 0x83c5, 0x83c0, 0x8426, 0x83f0, 0x83e1, 0x845c, 0x8451, 0x845a,
+ 0x8459, 0x8473, 0x8487, 0x8488, 0x847a, 0x8489, 0x8478, 0x843c,
+ 0x8446, 0x8469, 0x8476, 0x848c, 0x848e, 0x8431, 0x846d, 0x84c1,
+ 0x84cd, 0x84d0, 0x84e6, 0x84bd, 0x84d3, 0x84ca, 0x84bf, 0x84ba,
+ 0x84e0, 0x84a1, 0x84b9, 0x84b4, 0x8497, 0x84e5, 0x84e3, 0x850c,
+ 0x750d, 0x8538, 0x84f0, 0x8539, 0x851f, 0x853a,
+ /* 0x5e */
+ 0x8556, 0x853b, 0x84ff, 0x84fc, 0x8559, 0x8548, 0x8568, 0x8564,
+ 0x855e, 0x857a, 0x77a2, 0x8543, 0x8572, 0x857b, 0x85a4, 0x85a8,
+ 0x8587, 0x858f, 0x8579, 0x85ae, 0x859c, 0x8585, 0x85b9, 0x85b7,
+ 0x85b0, 0x85d3, 0x85c1, 0x85dc, 0x85ff, 0x8627, 0x8605, 0x8629,
+ 0x8616, 0x863c, 0x5efe, 0x5f08, 0x593c, 0x5941, 0x8037, 0x5955,
+ 0x595a, 0x5958, 0x530f, 0x5c22, 0x5c25, 0x5c2c, 0x5c34, 0x624c,
+ 0x626a, 0x629f, 0x62bb, 0x62ca, 0x62da, 0x62d7, 0x62ee, 0x6322,
+ 0x62f6, 0x6339, 0x634b, 0x6343, 0x63ad, 0x63f6, 0x6371, 0x637a,
+ 0x638e, 0x63b4, 0x636d, 0x63ac, 0x638a, 0x6369, 0x63ae, 0x63bc,
+ 0x63f2, 0x63f8, 0x63e0, 0x63ff, 0x63c4, 0x63de, 0x63ce, 0x6452,
+ 0x63c6, 0x63be, 0x6445, 0x6441, 0x640b, 0x641b, 0x6420, 0x640c,
+ 0x6426, 0x6421, 0x645e, 0x6484, 0x646d, 0x6496,
+ /* 0x5f */
+ 0x647a, 0x64b7, 0x64b8, 0x6499, 0x64ba, 0x64c0, 0x64d0, 0x64d7,
+ 0x64e4, 0x64e2, 0x6509, 0x6525, 0x652e, 0x5f0b, 0x5fd2, 0x7519,
+ 0x5f11, 0x535f, 0x53f1, 0x53fd, 0x53e9, 0x53e8, 0x53fb, 0x5412,
+ 0x5416, 0x5406, 0x544b, 0x5452, 0x5453, 0x5454, 0x5456, 0x5443,
+ 0x5421, 0x5457, 0x5459, 0x5423, 0x5432, 0x5482, 0x5494, 0x5477,
+ 0x5471, 0x5464, 0x549a, 0x549b, 0x5484, 0x5476, 0x5466, 0x549d,
+ 0x54d0, 0x54ad, 0x54c2, 0x54b4, 0x54d2, 0x54a7, 0x54a6, 0x54d3,
+ 0x54d4, 0x5472, 0x54a3, 0x54d5, 0x54bb, 0x54bf, 0x54cc, 0x54d9,
+ 0x54da, 0x54dc, 0x54a9, 0x54aa, 0x54a4, 0x54dd, 0x54cf, 0x54de,
+ 0x551b, 0x54e7, 0x5520, 0x54fd, 0x5514, 0x54f3, 0x5522, 0x5523,
+ 0x550f, 0x5511, 0x5527, 0x552a, 0x5567, 0x558f, 0x55b5, 0x5549,
+ 0x556d, 0x5541, 0x5555, 0x553f, 0x5550, 0x553c,
+ /* 0x60 */
+ 0x5537, 0x5556, 0x5575, 0x5576, 0x5577, 0x5533, 0x5530, 0x555c,
+ 0x558b, 0x55d2, 0x5583, 0x55b1, 0x55b9, 0x5588, 0x5581, 0x559f,
+ 0x557e, 0x55d6, 0x5591, 0x557b, 0x55df, 0x55bd, 0x55be, 0x5594,
+ 0x5599, 0x55ea, 0x55f7, 0x55c9, 0x561f, 0x55d1, 0x55eb, 0x55ec,
+ 0x55d4, 0x55e6, 0x55dd, 0x55c4, 0x55ef, 0x55e5, 0x55f2, 0x55f3,
+ 0x55cc, 0x55cd, 0x55e8, 0x55f5, 0x55e4, 0x8f94, 0x561e, 0x5608,
+ 0x560c, 0x5601, 0x5624, 0x5623, 0x55fe, 0x5600, 0x5627, 0x562d,
+ 0x5658, 0x5639, 0x5657, 0x562c, 0x564d, 0x5662, 0x5659, 0x565c,
+ 0x564c, 0x5654, 0x5686, 0x5664, 0x5671, 0x566b, 0x567b, 0x567c,
+ 0x5685, 0x5693, 0x56af, 0x56d4, 0x56d7, 0x56dd, 0x56e1, 0x56f5,
+ 0x56eb, 0x56f9, 0x56ff, 0x5704, 0x570a, 0x5709, 0x571c, 0x5e0f,
+ 0x5e19, 0x5e14, 0x5e11, 0x5e31, 0x5e3b, 0x5e3c,
+ /* 0x61 */
+ 0x5e37, 0x5e44, 0x5e54, 0x5e5b, 0x5e5e, 0x5e61, 0x5c8c, 0x5c7a,
+ 0x5c8d, 0x5c90, 0x5c96, 0x5c88, 0x5c98, 0x5c99, 0x5c91, 0x5c9a,
+ 0x5c9c, 0x5cb5, 0x5ca2, 0x5cbd, 0x5cac, 0x5cab, 0x5cb1, 0x5ca3,
+ 0x5cc1, 0x5cb7, 0x5cc4, 0x5cd2, 0x5ce4, 0x5ccb, 0x5ce5, 0x5d02,
+ 0x5d03, 0x5d27, 0x5d26, 0x5d2e, 0x5d24, 0x5d1e, 0x5d06, 0x5d1b,
+ 0x5d58, 0x5d3e, 0x5d34, 0x5d3d, 0x5d6c, 0x5d5b, 0x5d6f, 0x5d5d,
+ 0x5d6b, 0x5d4b, 0x5d4a, 0x5d69, 0x5d74, 0x5d82, 0x5d99, 0x5d9d,
+ 0x8c73, 0x5db7, 0x5dc5, 0x5f73, 0x5f77, 0x5f82, 0x5f87, 0x5f89,
+ 0x5f8c, 0x5f95, 0x5f99, 0x5f9c, 0x5fa8, 0x5fad, 0x5fb5, 0x5fbc,
+ 0x8862, 0x5f61, 0x72ad, 0x72b0, 0x72b4, 0x72b7, 0x72b8, 0x72c3,
+ 0x72c1, 0x72ce, 0x72cd, 0x72d2, 0x72e8, 0x72ef, 0x72e9, 0x72f2,
+ 0x72f4, 0x72f7, 0x7301, 0x72f3, 0x7303, 0x72fa,
+ /* 0x62 */
+ 0x72fb, 0x7317, 0x7313, 0x7321, 0x730a, 0x731e, 0x731d, 0x7315,
+ 0x7322, 0x7339, 0x7325, 0x732c, 0x7338, 0x7331, 0x7350, 0x734d,
+ 0x7357, 0x7360, 0x736c, 0x736f, 0x737e, 0x821b, 0x5925, 0x98e7,
+ 0x5924, 0x5902, 0x9963, 0x9967, 0x9968, 0x9969, 0x996a, 0x996b,
+ 0x996c, 0x9974, 0x9977, 0x997d, 0x9980, 0x9984, 0x9987, 0x998a,
+ 0x998d, 0x9990, 0x9991, 0x9993, 0x9994, 0x9995, 0x5e80, 0x5e91,
+ 0x5e8b, 0x5e96, 0x5ea5, 0x5ea0, 0x5eb9, 0x5eb5, 0x5ebe, 0x5eb3,
+ 0x8d53, 0x5ed2, 0x5ed1, 0x5edb, 0x5ee8, 0x5eea, 0x81ba, 0x5fc4,
+ 0x5fc9, 0x5fd6, 0x5fcf, 0x6003, 0x5fee, 0x6004, 0x5fe1, 0x5fe4,
+ 0x5ffe, 0x6005, 0x6006, 0x5fea, 0x5fed, 0x5ff8, 0x6019, 0x6035,
+ 0x6026, 0x601b, 0x600f, 0x600d, 0x6029, 0x602b, 0x600a, 0x603f,
+ 0x6021, 0x6078, 0x6079, 0x607b, 0x607a, 0x6042,
+ /* 0x63 */
+ 0x606a, 0x607d, 0x6096, 0x609a, 0x60ad, 0x609d, 0x6083, 0x6092,
+ 0x608c, 0x609b, 0x60ec, 0x60bb, 0x60b1, 0x60dd, 0x60d8, 0x60c6,
+ 0x60da, 0x60b4, 0x6120, 0x6126, 0x6115, 0x6123, 0x60f4, 0x6100,
+ 0x610e, 0x612b, 0x614a, 0x6175, 0x61ac, 0x6194, 0x61a7, 0x61b7,
+ 0x61d4, 0x61f5, 0x5fdd, 0x96b3, 0x95e9, 0x95eb, 0x95f1, 0x95f3,
+ 0x95f5, 0x95f6, 0x95fc, 0x95fe, 0x9603, 0x9604, 0x9606, 0x9608,
+ 0x960a, 0x960b, 0x960c, 0x960d, 0x960f, 0x9612, 0x9615, 0x9616,
+ 0x9617, 0x9619, 0x961a, 0x4e2c, 0x723f, 0x6215, 0x6c35, 0x6c54,
+ 0x6c5c, 0x6c4a, 0x6ca3, 0x6c85, 0x6c90, 0x6c94, 0x6c8c, 0x6c68,
+ 0x6c69, 0x6c74, 0x6c76, 0x6c86, 0x6ca9, 0x6cd0, 0x6cd4, 0x6cad,
+ 0x6cf7, 0x6cf8, 0x6cf1, 0x6cd7, 0x6cb2, 0x6ce0, 0x6cd6, 0x6cfa,
+ 0x6ceb, 0x6cee, 0x6cb1, 0x6cd3, 0x6cef, 0x6cfe,
+ /* 0x64 */
+ 0x6d39, 0x6d27, 0x6d0c, 0x6d43, 0x6d48, 0x6d07, 0x6d04, 0x6d19,
+ 0x6d0e, 0x6d2b, 0x6d4d, 0x6d2e, 0x6d35, 0x6d1a, 0x6d4f, 0x6d52,
+ 0x6d54, 0x6d33, 0x6d91, 0x6d6f, 0x6d9e, 0x6da0, 0x6d5e, 0x6d93,
+ 0x6d94, 0x6d5c, 0x6d60, 0x6d7c, 0x6d63, 0x6e1a, 0x6dc7, 0x6dc5,
+ 0x6dde, 0x6e0e, 0x6dbf, 0x6de0, 0x6e11, 0x6de6, 0x6ddd, 0x6dd9,
+ 0x6e16, 0x6dab, 0x6e0c, 0x6dae, 0x6e2b, 0x6e6e, 0x6e4e, 0x6e6b,
+ 0x6eb2, 0x6e5f, 0x6e86, 0x6e53, 0x6e54, 0x6e32, 0x6e25, 0x6e44,
+ 0x6edf, 0x6eb1, 0x6e98, 0x6ee0, 0x6f2d, 0x6ee2, 0x6ea5, 0x6ea7,
+ 0x6ebd, 0x6ebb, 0x6eb7, 0x6ed7, 0x6eb4, 0x6ecf, 0x6e8f, 0x6ec2,
+ 0x6e9f, 0x6f62, 0x6f46, 0x6f47, 0x6f24, 0x6f15, 0x6ef9, 0x6f2f,
+ 0x6f36, 0x6f4b, 0x6f74, 0x6f2a, 0x6f09, 0x6f29, 0x6f89, 0x6f8d,
+ 0x6f8c, 0x6f78, 0x6f72, 0x6f7c, 0x6f7a, 0x6fd1,
+ /* 0x65 */
+ 0x6fc9, 0x6fa7, 0x6fb9, 0x6fb6, 0x6fc2, 0x6fe1, 0x6fee, 0x6fde,
+ 0x6fe0, 0x6fef, 0x701a, 0x7023, 0x701b, 0x7039, 0x7035, 0x704f,
+ 0x705e, 0x5b80, 0x5b84, 0x5b95, 0x5b93, 0x5ba5, 0x5bb8, 0x752f,
+ 0x9a9e, 0x6434, 0x5be4, 0x5bee, 0x8930, 0x5bf0, 0x8e47, 0x8b07,
+ 0x8fb6, 0x8fd3, 0x8fd5, 0x8fe5, 0x8fee, 0x8fe4, 0x8fe9, 0x8fe6,
+ 0x8ff3, 0x8fe8, 0x9005, 0x9004, 0x900b, 0x9026, 0x9011, 0x900d,
+ 0x9016, 0x9021, 0x9035, 0x9036, 0x902d, 0x902f, 0x9044, 0x9051,
+ 0x9052, 0x9050, 0x9068, 0x9058, 0x9062, 0x905b, 0x66b9, 0x9074,
+ 0x907d, 0x9082, 0x9088, 0x9083, 0x908b, 0x5f50, 0x5f57, 0x5f56,
+ 0x5f58, 0x5c3b, 0x54ab, 0x5c50, 0x5c59, 0x5b71, 0x5c63, 0x5c66,
+ 0x7fbc, 0x5f2a, 0x5f29, 0x5f2d, 0x8274, 0x5f3c, 0x9b3b, 0x5c6e,
+ 0x5981, 0x5983, 0x598d, 0x59a9, 0x59aa, 0x59a3,
+ /* 0x66 */
+ 0x5997, 0x59ca, 0x59ab, 0x599e, 0x59a4, 0x59d2, 0x59b2, 0x59af,
+ 0x59d7, 0x59be, 0x5a05, 0x5a06, 0x59dd, 0x5a08, 0x59e3, 0x59d8,
+ 0x59f9, 0x5a0c, 0x5a09, 0x5a32, 0x5a34, 0x5a11, 0x5a23, 0x5a13,
+ 0x5a40, 0x5a67, 0x5a4a, 0x5a55, 0x5a3c, 0x5a62, 0x5a75, 0x80ec,
+ 0x5aaa, 0x5a9b, 0x5a77, 0x5a7a, 0x5abe, 0x5aeb, 0x5ab2, 0x5ad2,
+ 0x5ad4, 0x5ab8, 0x5ae0, 0x5ae3, 0x5af1, 0x5ad6, 0x5ae6, 0x5ad8,
+ 0x5adc, 0x5b09, 0x5b17, 0x5b16, 0x5b32, 0x5b37, 0x5b40, 0x5c15,
+ 0x5c1c, 0x5b5a, 0x5b65, 0x5b73, 0x5b51, 0x5b53, 0x5b62, 0x9a75,
+ 0x9a77, 0x9a78, 0x9a7a, 0x9a7f, 0x9a7d, 0x9a80, 0x9a81, 0x9a85,
+ 0x9a88, 0x9a8a, 0x9a90, 0x9a92, 0x9a93, 0x9a96, 0x9a98, 0x9a9b,
+ 0x9a9c, 0x9a9d, 0x9a9f, 0x9aa0, 0x9aa2, 0x9aa3, 0x9aa5, 0x9aa7,
+ 0x7e9f, 0x7ea1, 0x7ea3, 0x7ea5, 0x7ea8, 0x7ea9,
+ /* 0x67 */
+ 0x7ead, 0x7eb0, 0x7ebe, 0x7ec0, 0x7ec1, 0x7ec2, 0x7ec9, 0x7ecb,
+ 0x7ecc, 0x7ed0, 0x7ed4, 0x7ed7, 0x7edb, 0x7ee0, 0x7ee1, 0x7ee8,
+ 0x7eeb, 0x7eee, 0x7eef, 0x7ef1, 0x7ef2, 0x7f0d, 0x7ef6, 0x7efa,
+ 0x7efb, 0x7efe, 0x7f01, 0x7f02, 0x7f03, 0x7f07, 0x7f08, 0x7f0b,
+ 0x7f0c, 0x7f0f, 0x7f11, 0x7f12, 0x7f17, 0x7f19, 0x7f1c, 0x7f1b,
+ 0x7f1f, 0x7f21, 0x7f22, 0x7f23, 0x7f24, 0x7f25, 0x7f26, 0x7f27,
+ 0x7f2a, 0x7f2b, 0x7f2c, 0x7f2d, 0x7f2f, 0x7f30, 0x7f31, 0x7f32,
+ 0x7f33, 0x7f35, 0x5e7a, 0x757f, 0x5ddb, 0x753e, 0x9095, 0x738e,
+ 0x7391, 0x73ae, 0x73a2, 0x739f, 0x73cf, 0x73c2, 0x73d1, 0x73b7,
+ 0x73b3, 0x73c0, 0x73c9, 0x73c8, 0x73e5, 0x73d9, 0x987c, 0x740a,
+ 0x73e9, 0x73e7, 0x73de, 0x73ba, 0x73f2, 0x740f, 0x742a, 0x745b,
+ 0x7426, 0x7425, 0x7428, 0x7430, 0x742e, 0x742c,
+ /* 0x68 */
+ 0x741b, 0x741a, 0x7441, 0x745c, 0x7457, 0x7455, 0x7459, 0x7477,
+ 0x746d, 0x747e, 0x749c, 0x748e, 0x7480, 0x7481, 0x7487, 0x748b,
+ 0x749e, 0x74a8, 0x74a9, 0x7490, 0x74a7, 0x74d2, 0x74ba, 0x97ea,
+ 0x97eb, 0x97ec, 0x674c, 0x6753, 0x675e, 0x6748, 0x6769, 0x67a5,
+ 0x6787, 0x676a, 0x6773, 0x6798, 0x67a7, 0x6775, 0x67a8, 0x679e,
+ 0x67ad, 0x678b, 0x6777, 0x677c, 0x67f0, 0x6809, 0x67d8, 0x680a,
+ 0x67e9, 0x67b0, 0x680c, 0x67d9, 0x67b5, 0x67da, 0x67b3, 0x67dd,
+ 0x6800, 0x67c3, 0x67b8, 0x67e2, 0x680e, 0x67c1, 0x67fd, 0x6832,
+ 0x6833, 0x6860, 0x6861, 0x684e, 0x6862, 0x6844, 0x6864, 0x6883,
+ 0x681d, 0x6855, 0x6866, 0x6841, 0x6867, 0x6840, 0x683e, 0x684a,
+ 0x6849, 0x6829, 0x68b5, 0x688f, 0x6874, 0x6877, 0x6893, 0x686b,
+ 0x68c2, 0x696e, 0x68fc, 0x691f, 0x6920, 0x68f9,
+ /* 0x69 */
+ 0x6924, 0x68f0, 0x690b, 0x6901, 0x6957, 0x68e3, 0x6910, 0x6971,
+ 0x6939, 0x6960, 0x6942, 0x695d, 0x6984, 0x696b, 0x6980, 0x6998,
+ 0x6978, 0x6934, 0x69cc, 0x6987, 0x6988, 0x69ce, 0x6989, 0x6966,
+ 0x6963, 0x6979, 0x699b, 0x69a7, 0x69bb, 0x69ab, 0x69ad, 0x69d4,
+ 0x69b1, 0x69c1, 0x69ca, 0x69df, 0x6995, 0x69e0, 0x698d, 0x69ff,
+ 0x6a2f, 0x69ed, 0x6a17, 0x6a18, 0x6a65, 0x69f2, 0x6a44, 0x6a3e,
+ 0x6aa0, 0x6a50, 0x6a5b, 0x6a35, 0x6a8e, 0x6a79, 0x6a3d, 0x6a28,
+ 0x6a58, 0x6a7c, 0x6a91, 0x6a90, 0x6aa9, 0x6a97, 0x6aab, 0x7337,
+ 0x7352, 0x6b81, 0x6b82, 0x6b87, 0x6b84, 0x6b92, 0x6b93, 0x6b8d,
+ 0x6b9a, 0x6b9b, 0x6ba1, 0x6baa, 0x8f6b, 0x8f6d, 0x8f71, 0x8f72,
+ 0x8f73, 0x8f75, 0x8f76, 0x8f78, 0x8f77, 0x8f79, 0x8f7a, 0x8f7c,
+ 0x8f7e, 0x8f81, 0x8f82, 0x8f84, 0x8f87, 0x8f8b,
+ /* 0x6a */
+ 0x8f8d, 0x8f8e, 0x8f8f, 0x8f98, 0x8f9a, 0x8ece, 0x620b, 0x6217,
+ 0x621b, 0x621f, 0x6222, 0x6221, 0x6225, 0x6224, 0x622c, 0x81e7,
+ 0x74ef, 0x74f4, 0x74ff, 0x750f, 0x7511, 0x7513, 0x6534, 0x65ee,
+ 0x65ef, 0x65f0, 0x660a, 0x6619, 0x6772, 0x6603, 0x6615, 0x6600,
+ 0x7085, 0x66f7, 0x661d, 0x6634, 0x6631, 0x6636, 0x6635, 0x8006,
+ 0x665f, 0x6654, 0x6641, 0x664f, 0x6656, 0x6661, 0x6657, 0x6677,
+ 0x6684, 0x668c, 0x66a7, 0x669d, 0x66be, 0x66db, 0x66dc, 0x66e6,
+ 0x66e9, 0x8d32, 0x8d33, 0x8d36, 0x8d3b, 0x8d3d, 0x8d40, 0x8d45,
+ 0x8d46, 0x8d48, 0x8d49, 0x8d47, 0x8d4d, 0x8d55, 0x8d59, 0x89c7,
+ 0x89ca, 0x89cb, 0x89cc, 0x89ce, 0x89cf, 0x89d0, 0x89d1, 0x726e,
+ 0x729f, 0x725d, 0x7266, 0x726f, 0x727e, 0x727f, 0x7284, 0x728b,
+ 0x728d, 0x728f, 0x7292, 0x6308, 0x6332, 0x63b0,
+ /* 0x6b */
+ 0x643f, 0x64d8, 0x8004, 0x6bea, 0x6bf3, 0x6bfd, 0x6bf5, 0x6bf9,
+ 0x6c05, 0x6c07, 0x6c06, 0x6c0d, 0x6c15, 0x6c18, 0x6c19, 0x6c1a,
+ 0x6c21, 0x6c29, 0x6c24, 0x6c2a, 0x6c32, 0x6535, 0x6555, 0x656b,
+ 0x724d, 0x7252, 0x7256, 0x7230, 0x8662, 0x5216, 0x809f, 0x809c,
+ 0x8093, 0x80bc, 0x670a, 0x80bd, 0x80b1, 0x80ab, 0x80ad, 0x80b4,
+ 0x80b7, 0x80e7, 0x80e8, 0x80e9, 0x80ea, 0x80db, 0x80c2, 0x80c4,
+ 0x80d9, 0x80cd, 0x80d7, 0x6710, 0x80dd, 0x80eb, 0x80f1, 0x80f4,
+ 0x80ed, 0x810d, 0x810e, 0x80f2, 0x80fc, 0x6715, 0x8112, 0x8c5a,
+ 0x8136, 0x811e, 0x812c, 0x8118, 0x8132, 0x8148, 0x814c, 0x8153,
+ 0x8174, 0x8159, 0x815a, 0x8171, 0x8160, 0x8169, 0x817c, 0x817d,
+ 0x816d, 0x8167, 0x584d, 0x5ab5, 0x8188, 0x8182, 0x8191, 0x6ed5,
+ 0x81a3, 0x81aa, 0x81cc, 0x6726, 0x81ca, 0x81bb,
+ /* 0x6c */
+ 0x81c1, 0x81a6, 0x6b24, 0x6b37, 0x6b39, 0x6b43, 0x6b46, 0x6b59,
+ 0x98d1, 0x98d2, 0x98d3, 0x98d5, 0x98d9, 0x98da, 0x6bb3, 0x5f40,
+ 0x6bc2, 0x89f3, 0x6590, 0x9f51, 0x6593, 0x65bc, 0x65c6, 0x65c4,
+ 0x65c3, 0x65cc, 0x65ce, 0x65d2, 0x65d6, 0x7080, 0x709c, 0x7096,
+ 0x709d, 0x70bb, 0x70c0, 0x70b7, 0x70ab, 0x70b1, 0x70e8, 0x70ca,
+ 0x7110, 0x7113, 0x7116, 0x712f, 0x7131, 0x7173, 0x715c, 0x7168,
+ 0x7145, 0x7172, 0x714a, 0x7178, 0x717a, 0x7198, 0x71b3, 0x71b5,
+ 0x71a8, 0x71a0, 0x71e0, 0x71d4, 0x71e7, 0x71f9, 0x721d, 0x7228,
+ 0x706c, 0x7118, 0x7166, 0x71b9, 0x623e, 0x623d, 0x6243, 0x6248,
+ 0x6249, 0x793b, 0x7940, 0x7946, 0x7949, 0x795b, 0x795c, 0x7953,
+ 0x795a, 0x7962, 0x7957, 0x7960, 0x796f, 0x7967, 0x797a, 0x7985,
+ 0x798a, 0x799a, 0x79a7, 0x79b3, 0x5fd1, 0x5fd0,
+ /* 0x6d */
+ 0x603c, 0x605d, 0x605a, 0x6067, 0x6041, 0x6059, 0x6063, 0x60ab,
+ 0x6106, 0x610d, 0x615d, 0x61a9, 0x619d, 0x61cb, 0x61d1, 0x6206,
+ 0x8080, 0x807f, 0x6c93, 0x6cf6, 0x6dfc, 0x77f6, 0x77f8, 0x7800,
+ 0x7809, 0x7817, 0x7818, 0x7811, 0x65ab, 0x782d, 0x781c, 0x781d,
+ 0x7839, 0x783a, 0x783b, 0x781f, 0x783c, 0x7825, 0x782c, 0x7823,
+ 0x7829, 0x784e, 0x786d, 0x7856, 0x7857, 0x7826, 0x7850, 0x7847,
+ 0x784c, 0x786a, 0x789b, 0x7893, 0x789a, 0x7887, 0x789c, 0x78a1,
+ 0x78a3, 0x78b2, 0x78b9, 0x78a5, 0x78d4, 0x78d9, 0x78c9, 0x78ec,
+ 0x78f2, 0x7905, 0x78f4, 0x7913, 0x7924, 0x791e, 0x7934, 0x9f9b,
+ 0x9ef9, 0x9efb, 0x9efc, 0x76f1, 0x7704, 0x770d, 0x76f9, 0x7707,
+ 0x7708, 0x771a, 0x7722, 0x7719, 0x772d, 0x7726, 0x7735, 0x7738,
+ 0x7750, 0x7751, 0x7747, 0x7743, 0x775a, 0x7768,
+ /* 0x6e */
+ 0x7762, 0x7765, 0x777f, 0x778d, 0x777d, 0x7780, 0x778c, 0x7791,
+ 0x779f, 0x77a0, 0x77b0, 0x77b5, 0x77bd, 0x753a, 0x7540, 0x754e,
+ 0x754b, 0x7548, 0x755b, 0x7572, 0x7579, 0x7583, 0x7f58, 0x7f61,
+ 0x7f5f, 0x8a48, 0x7f68, 0x7f74, 0x7f71, 0x7f79, 0x7f81, 0x7f7e,
+ 0x76cd, 0x76e5, 0x8832, 0x9485, 0x9486, 0x9487, 0x948b, 0x948a,
+ 0x948c, 0x948d, 0x948f, 0x9490, 0x9494, 0x9497, 0x9495, 0x949a,
+ 0x949b, 0x949c, 0x94a3, 0x94a4, 0x94ab, 0x94aa, 0x94ad, 0x94ac,
+ 0x94af, 0x94b0, 0x94b2, 0x94b4, 0x94b6, 0x94b7, 0x94b8, 0x94b9,
+ 0x94ba, 0x94bc, 0x94bd, 0x94bf, 0x94c4, 0x94c8, 0x94c9, 0x94ca,
+ 0x94cb, 0x94cc, 0x94cd, 0x94ce, 0x94d0, 0x94d1, 0x94d2, 0x94d5,
+ 0x94d6, 0x94d7, 0x94d9, 0x94d8, 0x94db, 0x94de, 0x94df, 0x94e0,
+ 0x94e2, 0x94e4, 0x94e5, 0x94e7, 0x94e8, 0x94ea,
+ /* 0x6f */
+ 0x94e9, 0x94eb, 0x94ee, 0x94ef, 0x94f3, 0x94f4, 0x94f5, 0x94f7,
+ 0x94f9, 0x94fc, 0x94fd, 0x94ff, 0x9503, 0x9502, 0x9506, 0x9507,
+ 0x9509, 0x950a, 0x950d, 0x950e, 0x950f, 0x9512, 0x9513, 0x9514,
+ 0x9515, 0x9516, 0x9518, 0x951b, 0x951d, 0x951e, 0x951f, 0x9522,
+ 0x952a, 0x952b, 0x9529, 0x952c, 0x9531, 0x9532, 0x9534, 0x9536,
+ 0x9537, 0x9538, 0x953c, 0x953e, 0x953f, 0x9542, 0x9535, 0x9544,
+ 0x9545, 0x9546, 0x9549, 0x954c, 0x954e, 0x954f, 0x9552, 0x9553,
+ 0x9554, 0x9556, 0x9557, 0x9558, 0x9559, 0x955b, 0x955e, 0x955f,
+ 0x955d, 0x9561, 0x9562, 0x9564, 0x9565, 0x9566, 0x9567, 0x9568,
+ 0x9569, 0x956a, 0x956b, 0x956c, 0x956f, 0x9571, 0x9572, 0x9573,
+ 0x953a, 0x77e7, 0x77ec, 0x96c9, 0x79d5, 0x79ed, 0x79e3, 0x79eb,
+ 0x7a06, 0x5d47, 0x7a03, 0x7a02, 0x7a1e, 0x7a14,
+ /* 0x70 */
+ 0x7a39, 0x7a37, 0x7a51, 0x9ecf, 0x99a5, 0x7a70, 0x7688, 0x768e,
+ 0x7693, 0x7699, 0x76a4, 0x74de, 0x74e0, 0x752c, 0x9e20, 0x9e22,
+ 0x9e28, 0x9e29, 0x9e2a, 0x9e2b, 0x9e2c, 0x9e32, 0x9e31, 0x9e36,
+ 0x9e38, 0x9e37, 0x9e39, 0x9e3a, 0x9e3e, 0x9e41, 0x9e42, 0x9e44,
+ 0x9e46, 0x9e47, 0x9e48, 0x9e49, 0x9e4b, 0x9e4c, 0x9e4e, 0x9e51,
+ 0x9e55, 0x9e57, 0x9e5a, 0x9e5b, 0x9e5c, 0x9e5e, 0x9e63, 0x9e66,
+ 0x9e67, 0x9e68, 0x9e69, 0x9e6a, 0x9e6b, 0x9e6c, 0x9e71, 0x9e6d,
+ 0x9e73, 0x7592, 0x7594, 0x7596, 0x75a0, 0x759d, 0x75ac, 0x75a3,
+ 0x75b3, 0x75b4, 0x75b8, 0x75c4, 0x75b1, 0x75b0, 0x75c3, 0x75c2,
+ 0x75d6, 0x75cd, 0x75e3, 0x75e8, 0x75e6, 0x75e4, 0x75eb, 0x75e7,
+ 0x7603, 0x75f1, 0x75fc, 0x75ff, 0x7610, 0x7600, 0x7605, 0x760c,
+ 0x7617, 0x760a, 0x7625, 0x7618, 0x7615, 0x7619,
+ /* 0x71 */
+ 0x761b, 0x763c, 0x7622, 0x7620, 0x7640, 0x762d, 0x7630, 0x763f,
+ 0x7635, 0x7643, 0x763e, 0x7633, 0x764d, 0x765e, 0x7654, 0x765c,
+ 0x7656, 0x766b, 0x766f, 0x7fca, 0x7ae6, 0x7a78, 0x7a79, 0x7a80,
+ 0x7a86, 0x7a88, 0x7a95, 0x7aa6, 0x7aa0, 0x7aac, 0x7aa8, 0x7aad,
+ 0x7ab3, 0x8864, 0x8869, 0x8872, 0x887d, 0x887f, 0x8882, 0x88a2,
+ 0x88c6, 0x88b7, 0x88bc, 0x88c9, 0x88e2, 0x88ce, 0x88e3, 0x88e5,
+ 0x88f1, 0x891a, 0x88fc, 0x88e8, 0x88fe, 0x88f0, 0x8921, 0x8919,
+ 0x8913, 0x891b, 0x890a, 0x8934, 0x892b, 0x8936, 0x8941, 0x8966,
+ 0x897b, 0x758b, 0x80e5, 0x76b2, 0x76b4, 0x77dc, 0x8012, 0x8014,
+ 0x8016, 0x801c, 0x8020, 0x8022, 0x8025, 0x8026, 0x8027, 0x8029,
+ 0x8028, 0x8031, 0x800b, 0x8035, 0x8043, 0x8046, 0x804d, 0x8052,
+ 0x8069, 0x8071, 0x8983, 0x9878, 0x9880, 0x9883,
+ /* 0x72 */
+ 0x9889, 0x988c, 0x988d, 0x988f, 0x9894, 0x989a, 0x989b, 0x989e,
+ 0x989f, 0x98a1, 0x98a2, 0x98a5, 0x98a6, 0x864d, 0x8654, 0x866c,
+ 0x866e, 0x867f, 0x867a, 0x867c, 0x867b, 0x86a8, 0x868d, 0x868b,
+ 0x86ac, 0x869d, 0x86a7, 0x86a3, 0x86aa, 0x8693, 0x86a9, 0x86b6,
+ 0x86c4, 0x86b5, 0x86ce, 0x86b0, 0x86ba, 0x86b1, 0x86af, 0x86c9,
+ 0x86cf, 0x86b4, 0x86e9, 0x86f1, 0x86f2, 0x86ed, 0x86f3, 0x86d0,
+ 0x8713, 0x86de, 0x86f4, 0x86df, 0x86d8, 0x86d1, 0x8703, 0x8707,
+ 0x86f8, 0x8708, 0x870a, 0x870d, 0x8709, 0x8723, 0x873b, 0x871e,
+ 0x8725, 0x872e, 0x871a, 0x873e, 0x8748, 0x8734, 0x8731, 0x8729,
+ 0x8737, 0x873f, 0x8782, 0x8722, 0x877d, 0x877e, 0x877b, 0x8760,
+ 0x8770, 0x874c, 0x876e, 0x878b, 0x8753, 0x8763, 0x877c, 0x8764,
+ 0x8759, 0x8765, 0x8793, 0x87af, 0x87a8, 0x87d2,
+ /* 0x73 */
+ 0x87c6, 0x8788, 0x8785, 0x87ad, 0x8797, 0x8783, 0x87ab, 0x87e5,
+ 0x87ac, 0x87b5, 0x87b3, 0x87cb, 0x87d3, 0x87bd, 0x87d1, 0x87c0,
+ 0x87ca, 0x87db, 0x87ea, 0x87e0, 0x87ee, 0x8816, 0x8813, 0x87fe,
+ 0x880a, 0x881b, 0x8821, 0x8839, 0x883c, 0x7f36, 0x7f42, 0x7f44,
+ 0x7f45, 0x8210, 0x7afa, 0x7afd, 0x7b08, 0x7b03, 0x7b04, 0x7b15,
+ 0x7b0a, 0x7b2b, 0x7b0f, 0x7b47, 0x7b38, 0x7b2a, 0x7b19, 0x7b2e,
+ 0x7b31, 0x7b20, 0x7b25, 0x7b24, 0x7b33, 0x7b3e, 0x7b1e, 0x7b58,
+ 0x7b5a, 0x7b45, 0x7b75, 0x7b4c, 0x7b5d, 0x7b60, 0x7b6e, 0x7b7b,
+ 0x7b62, 0x7b72, 0x7b71, 0x7b90, 0x7ba6, 0x7ba7, 0x7bb8, 0x7bac,
+ 0x7b9d, 0x7ba8, 0x7b85, 0x7baa, 0x7b9c, 0x7ba2, 0x7bab, 0x7bb4,
+ 0x7bd1, 0x7bc1, 0x7bcc, 0x7bdd, 0x7bda, 0x7be5, 0x7be6, 0x7bea,
+ 0x7c0c, 0x7bfe, 0x7bfc, 0x7c0f, 0x7c16, 0x7c0b,
+ /* 0x74 */
+ 0x7c1f, 0x7c2a, 0x7c26, 0x7c38, 0x7c41, 0x7c40, 0x81fe, 0x8201,
+ 0x8202, 0x8204, 0x81ec, 0x8844, 0x8221, 0x8222, 0x8223, 0x822d,
+ 0x822f, 0x8228, 0x822b, 0x8238, 0x823b, 0x8233, 0x8234, 0x823e,
+ 0x8244, 0x8249, 0x824b, 0x824f, 0x825a, 0x825f, 0x8268, 0x887e,
+ 0x8885, 0x8888, 0x88d8, 0x88df, 0x895e, 0x7f9d, 0x7f9f, 0x7fa7,
+ 0x7faf, 0x7fb0, 0x7fb2, 0x7c7c, 0x6549, 0x7c91, 0x7c9d, 0x7c9c,
+ 0x7c9e, 0x7ca2, 0x7cb2, 0x7cbc, 0x7cbd, 0x7cc1, 0x7cc7, 0x7ccc,
+ 0x7ccd, 0x7cc8, 0x7cc5, 0x7cd7, 0x7ce8, 0x826e, 0x66a8, 0x7fbf,
+ 0x7fce, 0x7fd5, 0x7fe5, 0x7fe1, 0x7fe6, 0x7fe9, 0x7fee, 0x7ff3,
+ 0x7cf8, 0x7d77, 0x7da6, 0x7dae, 0x7e47, 0x7e9b, 0x9eb8, 0x9eb4,
+ 0x8d73, 0x8d84, 0x8d94, 0x8d91, 0x8db1, 0x8d67, 0x8d6d, 0x8c47,
+ 0x8c49, 0x914a, 0x9150, 0x914e, 0x914f, 0x9164,
+ /* 0x75 */
+ 0x9162, 0x9161, 0x9170, 0x9169, 0x916f, 0x917d, 0x917e, 0x9172,
+ 0x9174, 0x9179, 0x918c, 0x9185, 0x9190, 0x918d, 0x9191, 0x91a2,
+ 0x91a3, 0x91aa, 0x91ad, 0x91ae, 0x91af, 0x91b5, 0x91b4, 0x91ba,
+ 0x8c55, 0x9e7e, 0x8db8, 0x8deb, 0x8e05, 0x8e59, 0x8e69, 0x8db5,
+ 0x8dbf, 0x8dbc, 0x8dba, 0x8dc4, 0x8dd6, 0x8dd7, 0x8dda, 0x8dde,
+ 0x8dce, 0x8dcf, 0x8ddb, 0x8dc6, 0x8dec, 0x8df7, 0x8df8, 0x8de3,
+ 0x8df9, 0x8dfb, 0x8de4, 0x8e09, 0x8dfd, 0x8e14, 0x8e1d, 0x8e1f,
+ 0x8e2c, 0x8e2e, 0x8e23, 0x8e2f, 0x8e3a, 0x8e40, 0x8e39, 0x8e35,
+ 0x8e3d, 0x8e31, 0x8e49, 0x8e41, 0x8e42, 0x8e51, 0x8e52, 0x8e4a,
+ 0x8e70, 0x8e76, 0x8e7c, 0x8e6f, 0x8e74, 0x8e85, 0x8e8f, 0x8e94,
+ 0x8e90, 0x8e9c, 0x8e9e, 0x8c78, 0x8c82, 0x8c8a, 0x8c85, 0x8c98,
+ 0x8c94, 0x659b, 0x89d6, 0x89de, 0x89da, 0x89dc,
+ /* 0x76 */
+ 0x89e5, 0x89eb, 0x89ef, 0x8a3e, 0x8b26, 0x9753, 0x96e9, 0x96f3,
+ 0x96ef, 0x9706, 0x9701, 0x9708, 0x970f, 0x970e, 0x972a, 0x972d,
+ 0x9730, 0x973e, 0x9f80, 0x9f83, 0x9f85, 0x9f86, 0x9f87, 0x9f88,
+ 0x9f89, 0x9f8a, 0x9f8c, 0x9efe, 0x9f0b, 0x9f0d, 0x96b9, 0x96bc,
+ 0x96bd, 0x96ce, 0x96d2, 0x77bf, 0x96e0, 0x928e, 0x92ae, 0x92c8,
+ 0x933e, 0x936a, 0x93ca, 0x938f, 0x943e, 0x946b, 0x9c7f, 0x9c82,
+ 0x9c85, 0x9c86, 0x9c87, 0x9c88, 0x7a23, 0x9c8b, 0x9c8e, 0x9c90,
+ 0x9c91, 0x9c92, 0x9c94, 0x9c95, 0x9c9a, 0x9c9b, 0x9c9e, 0x9c9f,
+ 0x9ca0, 0x9ca1, 0x9ca2, 0x9ca3, 0x9ca5, 0x9ca6, 0x9ca7, 0x9ca8,
+ 0x9ca9, 0x9cab, 0x9cad, 0x9cae, 0x9cb0, 0x9cb1, 0x9cb2, 0x9cb3,
+ 0x9cb4, 0x9cb5, 0x9cb6, 0x9cb7, 0x9cba, 0x9cbb, 0x9cbc, 0x9cbd,
+ 0x9cc4, 0x9cc5, 0x9cc6, 0x9cc7, 0x9cca, 0x9ccb,
+ /* 0x77 */
+ 0x9ccc, 0x9ccd, 0x9cce, 0x9ccf, 0x9cd0, 0x9cd3, 0x9cd4, 0x9cd5,
+ 0x9cd7, 0x9cd8, 0x9cd9, 0x9cdc, 0x9cdd, 0x9cdf, 0x9ce2, 0x977c,
+ 0x9785, 0x9791, 0x9792, 0x9794, 0x97af, 0x97ab, 0x97a3, 0x97b2,
+ 0x97b4, 0x9ab1, 0x9ab0, 0x9ab7, 0x9e58, 0x9ab6, 0x9aba, 0x9abc,
+ 0x9ac1, 0x9ac0, 0x9ac5, 0x9ac2, 0x9acb, 0x9acc, 0x9ad1, 0x9b45,
+ 0x9b43, 0x9b47, 0x9b49, 0x9b48, 0x9b4d, 0x9b51, 0x98e8, 0x990d,
+ 0x992e, 0x9955, 0x9954, 0x9adf, 0x9ae1, 0x9ae6, 0x9aef, 0x9aeb,
+ 0x9afb, 0x9aed, 0x9af9, 0x9b08, 0x9b0f, 0x9b13, 0x9b1f, 0x9b23,
+ 0x9ebd, 0x9ebe, 0x7e3b, 0x9e82, 0x9e87, 0x9e88, 0x9e8b, 0x9e92,
+ 0x93d6, 0x9e9d, 0x9e9f, 0x9edb, 0x9edc, 0x9edd, 0x9ee0, 0x9edf,
+ 0x9ee2, 0x9ee9, 0x9ee7, 0x9ee5, 0x9eea, 0x9eef, 0x9f22, 0x9f2c,
+ 0x9f2f, 0x9f39, 0x9f37, 0x9f3d, 0x9f3e, 0x9f44,
+};
+
+static int
+gb2312_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c1 = (s[0] & 0x7F);
+ if ((c1 >= 0x21 && c1 <= 0x29) || (c1 >= 0x30 && c1 <= 0x77)) {
+ if (n >= 2) {
+ unsigned char c2 = (s[1] & 0x7F);
+ if (c2 >= 0x21 && c2 < 0x7f) {
+ unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21);
+ unsigned short wc = 0xfffd;
+ if (i < 1410) {
+ if (i < 831)
+ wc = gb2312_2uni_page21[i];
+ } else {
+ if (i < 8178)
+ wc = gb2312_2uni_page30[i-1410];
+ }
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 2;
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOFEW(0);
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned short gb2312_2charset[7445] = {
+ 0x2168, 0x216c, 0x2127, 0x2163, 0x2140, 0x2141, 0x2824, 0x2822,
+ 0x2828, 0x2826, 0x283a, 0x282c, 0x282a, 0x2830, 0x282e, 0x2142,
+ 0x2834, 0x2832, 0x2839, 0x2821, 0x2825, 0x2827, 0x2829, 0x282d,
+ 0x2831, 0x2823, 0x282b, 0x282f, 0x2833, 0x2835, 0x2836, 0x2837,
+ 0x2838, 0x2126, 0x2125, 0x2621, 0x2622, 0x2623, 0x2624, 0x2625,
+ 0x2626, 0x2627, 0x2628, 0x2629, 0x262a, 0x262b, 0x262c, 0x262d,
+ 0x262e, 0x262f, 0x2630, 0x2631, 0x2632, 0x2633, 0x2634, 0x2635,
+ 0x2636, 0x2637, 0x2638, 0x2641, 0x2642, 0x2643, 0x2644, 0x2645,
+ 0x2646, 0x2647, 0x2648, 0x2649, 0x264a, 0x264b, 0x264c, 0x264d,
+ 0x264e, 0x264f, 0x2650, 0x2651, 0x2652, 0x2653, 0x2654, 0x2655,
+ 0x2656, 0x2657, 0x2658, 0x2727, 0x2721, 0x2722, 0x2723, 0x2724,
+ 0x2725, 0x2726, 0x2728, 0x2729, 0x272a, 0x272b, 0x272c, 0x272d,
+ 0x272e, 0x272f, 0x2730, 0x2731, 0x2732, 0x2733, 0x2734, 0x2735,
+ 0x2736, 0x2737, 0x2738, 0x2739, 0x273a, 0x273b, 0x273c, 0x273d,
+ 0x273e, 0x273f, 0x2740, 0x2741, 0x2751, 0x2752, 0x2753, 0x2754,
+ 0x2755, 0x2756, 0x2758, 0x2759, 0x275a, 0x275b, 0x275c, 0x275d,
+ 0x275e, 0x275f, 0x2760, 0x2761, 0x2762, 0x2763, 0x2764, 0x2765,
+ 0x2766, 0x2767, 0x2768, 0x2769, 0x276a, 0x276b, 0x276c, 0x276d,
+ 0x276e, 0x276f, 0x2770, 0x2771, 0x2757, 0x212a, 0x212c, 0x212e,
+ 0x212f, 0x2130, 0x2131, 0x212d, 0x216b, 0x2164, 0x2165, 0x2179,
+ 0x2166, 0x216d, 0x2271, 0x2272, 0x2273, 0x2274, 0x2275, 0x2276,
+ 0x2277, 0x2278, 0x2279, 0x227a, 0x227b, 0x227c, 0x217b, 0x217c,
+ 0x217a, 0x217d, 0x214a, 0x2147, 0x2146, 0x214c, 0x2158, 0x215e,
+ 0x214f, 0x214e, 0x2144, 0x2145, 0x2149, 0x2148, 0x2152, 0x2153,
+ 0x2160, 0x215f, 0x2143, 0x214b, 0x2157, 0x2156, 0x2155, 0x2159,
+ 0x2154, 0x215c, 0x215d, 0x215a, 0x215b, 0x2151, 0x214d, 0x2150,
+ 0x2259, 0x225a, 0x225b, 0x225c, 0x225d, 0x225e, 0x225f, 0x2260,
+ 0x2261, 0x2262, 0x2245, 0x2246, 0x2247, 0x2248, 0x2249, 0x224a,
+ 0x224b, 0x224c, 0x224d, 0x224e, 0x224f, 0x2250, 0x2251, 0x2252,
+ 0x2253, 0x2254, 0x2255, 0x2256, 0x2257, 0x2258, 0x2231, 0x2232,
+ 0x2233, 0x2234, 0x2235, 0x2236, 0x2237, 0x2238, 0x2239, 0x223a,
+ 0x223b, 0x223c, 0x223d, 0x223e, 0x223f, 0x2240, 0x2241, 0x2242,
+ 0x2243, 0x2244, 0x2924, 0x2925, 0x2926, 0x2927, 0x2928, 0x2929,
+ 0x292a, 0x292b, 0x292c, 0x292d, 0x292e, 0x292f, 0x2930, 0x2931,
+ 0x2932, 0x2933, 0x2934, 0x2935, 0x2936, 0x2937, 0x2938, 0x2939,
+ 0x293a, 0x293b, 0x293c, 0x293d, 0x293e, 0x293f, 0x2940, 0x2941,
+ 0x2942, 0x2943, 0x2944, 0x2945, 0x2946, 0x2947, 0x2948, 0x2949,
+ 0x294a, 0x294b, 0x294c, 0x294d, 0x294e, 0x294f, 0x2950, 0x2951,
+ 0x2952, 0x2953, 0x2954, 0x2955, 0x2956, 0x2957, 0x2958, 0x2959,
+ 0x295a, 0x295b, 0x295c, 0x295d, 0x295e, 0x295f, 0x2960, 0x2961,
+ 0x2962, 0x2963, 0x2964, 0x2965, 0x2966, 0x2967, 0x2968, 0x2969,
+ 0x296a, 0x296b, 0x296c, 0x296d, 0x296e, 0x296f, 0x2176, 0x2175,
+ 0x2178, 0x2177, 0x2174, 0x2173, 0x2170, 0x2172, 0x2171, 0x216f,
+ 0x216e, 0x2162, 0x2161, 0x2121, 0x2122, 0x2123, 0x2128, 0x2129,
+ 0x2134, 0x2135, 0x2136, 0x2137, 0x2138, 0x2139, 0x213a, 0x213b,
+ 0x213e, 0x213f, 0x217e, 0x2132, 0x2133, 0x213c, 0x213d, 0x2421,
+ 0x2422, 0x2423, 0x2424, 0x2425, 0x2426, 0x2427, 0x2428, 0x2429,
+ 0x242a, 0x242b, 0x242c, 0x242d, 0x242e, 0x242f, 0x2430, 0x2431,
+ 0x2432, 0x2433, 0x2434, 0x2435, 0x2436, 0x2437, 0x2438, 0x2439,
+ 0x243a, 0x243b, 0x243c, 0x243d, 0x243e, 0x243f, 0x2440, 0x2441,
+ 0x2442, 0x2443, 0x2444, 0x2445, 0x2446, 0x2447, 0x2448, 0x2449,
+ 0x244a, 0x244b, 0x244c, 0x244d, 0x244e, 0x244f, 0x2450, 0x2451,
+ 0x2452, 0x2453, 0x2454, 0x2455, 0x2456, 0x2457, 0x2458, 0x2459,
+ 0x245a, 0x245b, 0x245c, 0x245d, 0x245e, 0x245f, 0x2460, 0x2461,
+ 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, 0x2468, 0x2469,
+ 0x246a, 0x246b, 0x246c, 0x246d, 0x246e, 0x246f, 0x2470, 0x2471,
+ 0x2472, 0x2473, 0x2521, 0x2522, 0x2523, 0x2524, 0x2525, 0x2526,
+ 0x2527, 0x2528, 0x2529, 0x252a, 0x252b, 0x252c, 0x252d, 0x252e,
+ 0x252f, 0x2530, 0x2531, 0x2532, 0x2533, 0x2534, 0x2535, 0x2536,
+ 0x2537, 0x2538, 0x2539, 0x253a, 0x253b, 0x253c, 0x253d, 0x253e,
+ 0x253f, 0x2540, 0x2541, 0x2542, 0x2543, 0x2544, 0x2545, 0x2546,
+ 0x2547, 0x2548, 0x2549, 0x254a, 0x254b, 0x254c, 0x254d, 0x254e,
+ 0x254f, 0x2550, 0x2551, 0x2552, 0x2553, 0x2554, 0x2555, 0x2556,
+ 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d, 0x255e,
+ 0x255f, 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566,
+ 0x2567, 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x256d, 0x256e,
+ 0x256f, 0x2570, 0x2571, 0x2572, 0x2573, 0x2574, 0x2575, 0x2576,
+ 0x2124, 0x2845, 0x2846, 0x2847, 0x2848, 0x2849, 0x284a, 0x284b,
+ 0x284c, 0x284d, 0x284e, 0x284f, 0x2850, 0x2851, 0x2852, 0x2853,
+ 0x2854, 0x2855, 0x2856, 0x2857, 0x2858, 0x2859, 0x285a, 0x285b,
+ 0x285c, 0x285d, 0x285e, 0x285f, 0x2860, 0x2861, 0x2862, 0x2863,
+ 0x2864, 0x2865, 0x2866, 0x2867, 0x2868, 0x2869, 0x2265, 0x2266,
+ 0x2267, 0x2268, 0x2269, 0x226a, 0x226b, 0x226c, 0x226d, 0x226e,
+ 0x523b, 0x3621, 0x465f, 0x4d72, 0x5549, 0x487d, 0x494f, 0x4f42,
+ 0x5822, 0x323b, 0x536b, 0x5824, 0x3373, 0x5728, 0x4752, 0x5827,
+ 0x4a40, 0x4770, 0x317b, 0x5235, 0x3454, 0x362b, 0x4b3f, 0x5829,
+ 0x362a, 0x413d, 0x514f, 0x4925, 0x582d, 0x3876, 0x513e, 0x635c,
+ 0x5650, 0x3761, 0x342e, 0x4159, 0x583c, 0x4d68, 0x3524, 0x4e2a,
+ 0x5677, 0x4076, 0x3e59, 0x582f, 0x444b, 0x3e43, 0x5831, 0x4334,
+ 0x5265, 0x562e, 0x4e5a, 0x5527, 0x3a75, 0x3726, 0x4056, 0x4639,
+ 0x4552, 0x4747, 0x3954, 0x334b, 0x5252, 0x583f, 0x3e45, 0x4672,
+ 0x5232, 0x4f30, 0x4f67, 0x4a69, 0x5840, 0x4272, 0x4252, 0x4869,
+ 0x472c, 0x414b, 0x5368, 0x5579, 0x4a42, 0x367e, 0x5821, 0x535a,
+ 0x3f77, 0x5446, 0x3b25, 0x5841, 0x4e65, 0x3e2e, 0x5828, 0x5147,
+ 0x5029, 0x583d, 0x596f, 0x4d76, 0x3f3a, 0x3d3b, 0x3a25, 0x5260,
+ 0x327a, 0x3a60, 0x4436, 0x4f6d, 0x3e29, 0x4d24, 0x4141, 0x4757,
+ 0x5971, 0x5974, 0x484b, 0x5869, 0x525a, 0x4a32, 0x484a, 0x586c,
+ 0x586a, 0x5846, 0x3d76, 0x464d, 0x3370, 0x586b, 0x3d71, 0x3d69,
+ 0x4854, 0x3453, 0x4258, 0x3256, 0x5750, 0x4a4b, 0x4b7b, 0x554c,
+ 0x3836, 0x4f49, 0x595a, 0x5870, 0x472a, 0x586e, 0x347a, 0x416e,
+ 0x5254, 0x586d, 0x5247, 0x586f, 0x4347, 0x5176, 0x5659, 0x5872,
+ 0x5875, 0x3c7e, 0x3c5b, 0x484e, 0x375d, 0x3742, 0x4673, 0x5878,
+ 0x5241, 0x4e69, 0x3c3f, 0x377c, 0x3725, 0x505d, 0x565a, 0x5345,
+ 0x3b6f, 0x3b61, 0x5871, 0x4921, 0x4e30, 0x342b, 0x5873, 0x494b,
+ 0x5876, 0x4257, 0x5877, 0x4e31, 0x5879, 0x322e, 0x3940, 0x5923,
+ 0x3069, 0x4166, 0x496c, 0x4b45, 0x4b46, 0x5924, 0x3568, 0x352b,
+ 0x4e3b, 0x354d, 0x5721, 0x5774, 0x5353, 0x4c65, 0x3a4e, 0x5922,
+ 0x595c, 0x5360, 0x587d, 0x3770, 0x5777, 0x587e, 0x587a, 0x5921,
+ 0x4463, 0x5336, 0x5874, 0x595d, 0x587b, 0x4565, 0x4050, 0x5170,
+ 0x305b, 0x3c51, 0x5926, 0x5925, 0x592c, 0x592e, 0x592b, 0x4a39,
+ 0x5929, 0x5636, 0x335e, 0x5928, 0x407d, 0x4a4c, 0x592a, 0x5927,
+ 0x5930, 0x3631, 0x3929, 0x5240, 0x4f40, 0x4242, 0x3d44, 0x556c,
+ 0x3260, 0x4748, 0x3f6b, 0x592d, 0x592f, 0x4e6a, 0x3a6e, 0x4756,
+ 0x3163, 0x3459, 0x366d, 0x5934, 0x3f21, 0x595e, 0x474e, 0x407e,
+ 0x5938, 0x4b57, 0x377d, 0x5935, 0x5937, 0x3123, 0x5361, 0x5939,
+ 0x5045, 0x5936, 0x5931, 0x5932, 0x4129, 0x5933, 0x3c73, 0x505e,
+ 0x3829, 0x3e63, 0x593d, 0x593a, 0x3033, 0x5942, 0x5944, 0x3136,
+ 0x593f, 0x3539, 0x3e73, 0x4c48, 0x3a72, 0x5250, 0x5943, 0x3d68,
+ 0x332b, 0x5945, 0x3e6b, 0x5946, 0x593b, 0x445f, 0x593e, 0x5941,
+ 0x5940, 0x552e, 0x5635, 0x4763, 0x5948, 0x3c59, 0x594a, 0x593c,
+ 0x594b, 0x462b, 0x5949, 0x5776, 0x4d23, 0x3d21, 0x594c, 0x453c,
+ 0x4d35, 0x594d, 0x5947, 0x3325, 0x3f7e, 0x3835, 0x407c, 0x3078,
+ 0x3476, 0x594e, 0x594f, 0x3422, 0x5950, 0x345f, 0x3041, 0x5951,
+ 0x4935, 0x4f71, 0x5952, 0x4145, 0x5956, 0x492e, 0x5955, 0x5954,
+ 0x5957, 0x4b5b, 0x3d29, 0x4627, 0x5953, 0x5958, 0x5959, 0x4865,
+ 0x405c, 0x3679, 0x5823, 0x544a, 0x542a, 0x5056, 0x3364, 0x5557,
+ 0x4f48, 0x3962, 0x3f4b, 0x4362, 0x3652, 0x4d43, 0x596e, 0x5970,
+ 0x3533, 0x3635, 0x3e24, 0x486b, 0x482b, 0x304b, 0x392b, 0x4179,
+ 0x5962, 0x403c, 0x3932, 0x3958, 0x504b, 0x3178, 0x4664, 0x3e5f,
+ 0x3564, 0x5748, 0x5178, 0x3c66, 0x4a5e, 0x3c3d, 0x5966, 0x5867,
+ 0x445a, 0x3854, 0x483d, 0x3261, 0x5459, 0x4330, 0x4361, 0x5a22,
+ 0x485f, 0x5034, 0x3e7c, 0x4529, 0x395a, 0x5a23, 0x5429, 0x5a24,
+ 0x597b, 0x362c, 0x376b, 0x3179, 0x597c, 0x3365, 0x3e76, 0x3f76,
+ 0x5231, 0x4064, 0x3633, 0x597e, 0x597d, 0x3e3b, 0x4660, 0x573c,
+ 0x5a21, 0x4139, 0x3572, 0x4168, 0x3c75, 0x3455, 0x415d, 0x447d,
+ 0x3c38, 0x3732, 0x376f, 0x596c, 0x463e, 0x3f2d, 0x3b4b, 0x354a,
+ 0x5b49, 0x5057, 0x4d39, 0x303c, 0x3376, 0x3b77, 0x5b4a, 0x3a2f,
+ 0x5464, 0x3536, 0x3573, 0x5856, 0x4850, 0x3756, 0x4750, 0x5857,
+ 0x3f2f, 0x5b3b, 0x5858, 0x504c, 0x3b2e, 0x6b3e, 0x4150, 0x4175,
+ 0x5472, 0x3855, 0x3434, 0x3375, 0x493e, 0x4550, 0x4559, 0x407b,
+ 0x3170, 0x5859, 0x394e, 0x353d, 0x585a, 0x5646, 0x4b22, 0x482f,
+ 0x4932, 0x344c, 0x3f4c, 0x3974, 0x585b, 0x585c, 0x3667, 0x3c41,
+ 0x4c6a, 0x4f77, 0x585d, 0x4730, 0x3950, 0x3d23, 0x4c5e, 0x464a,
+ 0x5860, 0x585e, 0x585f, 0x307e, 0x3e67, 0x4a23, 0x3c74, 0x3831,
+ 0x386e, 0x5862, 0x3d4b, 0x5864, 0x5863, 0x457c, 0x5865, 0x5866,
+ 0x4126, 0x4830, 0x306c, 0x3926, 0x3c53, 0x4e71, 0x5b3d, 0x4153,
+ 0x362f, 0x567a, 0x452c, 0x3d59, 0x5b3e, 0x5b3f, 0x4078, 0x3e22,
+ 0x404d, 0x5b40, 0x4a46, 0x322a, 0x5342, 0x4363, 0x512b, 0x5b42,
+ 0x4055, 0x5b43, 0x3f31, 0x443c, 0x475a, 0x5b44, 0x5968, 0x4957,
+ 0x3934, 0x4e70, 0x5448, 0x307c, 0x3452, 0x5059, 0x5969, 0x5e4b,
+ 0x596b, 0x5830, 0x3b2f, 0x3131, 0x3357, 0x584e, 0x5451, 0x3d33,
+ 0x3f6f, 0x4f3b, 0x5850, 0x374b, 0x5851, 0x4625, 0x4778, 0x523d,
+ 0x5852, 0x4464, 0x4a2e, 0x4727, 0x5826, 0x497d, 0x4e67, 0x3b5c,
+ 0x306b, 0x3b2a, 0x502d, 0x3130, 0x5764, 0x573f, 0x3525, 0x4274,
+ 0x444f, 0x3229, 0x3237, 0x3165, 0x5f32, 0x553c, 0x3f28, 0x422c,
+ 0x5855, 0x4231, 0x5854, 0x4e54, 0x5a60, 0x4e40, 0x5834, 0x432e,
+ 0x5321, 0x4e23, 0x3c34, 0x4834, 0x4251, 0x3e6d, 0x5036, 0x5a61,
+ 0x4764, 0x3327, 0x3672, 0x4c7c, 0x407a, 0x4077, 0x5139, 0x5161,
+ 0x5847, 0x325e, 0x4065, 0x3a71, 0x5848, 0x542d, 0x4f61, 0x5849,
+ 0x584a, 0x4f43, 0x3378, 0x3e47, 0x584b, 0x5b4c, 0x4825, 0x4f58,
+ 0x487e, 0x324e, 0x5356, 0x3266, 0x3c30, 0x5351, 0x4b2b, 0x3734,
+ 0x3722, 0x4a65, 0x4821, 0x4a5c, 0x3164, 0x5070, 0x4551, 0x5b45,
+ 0x357e, 0x3f5a, 0x3945, 0x3e64, 0x416d, 0x5f36, 0x5f35, 0x563b,
+ 0x3d50, 0x5559, 0x3048, 0x3623, 0x3f49, 0x4c28, 0x5f33, 0x4a37,
+ 0x5352, 0x584f, 0x5236, 0x3a45, 0x4b3e, 0x4c3e, 0x5f37, 0x3570,
+ 0x5f34, 0x5375, 0x3354, 0x3877, 0x5f3a, 0x3a4f, 0x3c2a, 0x3575,
+ 0x4d2c, 0x437b, 0x3a73, 0x4074, 0x4d42, 0x4f72, 0x5f38, 0x4f45,
+ 0x4240, 0x5f39, 0x4270, 0x3e7d, 0x415f, 0x4d4c, 0x5277, 0x374d,
+ 0x5f41, 0x5f44, 0x3771, 0x3049, 0x3656, 0x3754, 0x3a2c, 0x4c7d,
+ 0x3f54, 0x4b31, 0x4674, 0x5628, 0x5f45, 0x4e62, 0x3333, 0x4e7c,
+ 0x3435, 0x4e47, 0x3a70, 0x4e61, 0x513d, 0x5f40, 0x3474, 0x334a,
+ 0x3866, 0x5f3b, 0x4445, 0x5f3c, 0x5f3d, 0x5f3e, 0x453b, 0x5f3f,
+ 0x5f42, 0x5431, 0x5f43, 0x473a, 0x4e58, 0x4458, 0x5f4a, 0x5f4f,
+ 0x565c, 0x5f49, 0x5f5a, 0x4e36, 0x3a47, 0x5f4e, 0x5f48, 0x455e,
+ 0x496b, 0x3a74, 0x437c, 0x3e57, 0x5f46, 0x5f4d, 0x4558, 0x5526,
+ 0x3a4d, 0x3e4c, 0x533d, 0x3840, 0x5664, 0x5f47, 0x393e, 0x3f27,
+ 0x417c, 0x5f4b, 0x5f4c, 0x5f50, 0x5f5b, 0x5f65, 0x5f57, 0x5f56,
+ 0x5749, 0x5f63, 0x5f64, 0x656b, 0x5227, 0x5f52, 0x3f29, 0x545b,
+ 0x3f48, 0x5f54, 0x4f4c, 0x5f5d, 0x514a, 0x5f5e, 0x3027, 0x4637,
+ 0x5f53, 0x3a65, 0x365f, 0x4d5b, 0x397e, 0x5455, 0x5f5f, 0x4f6c,
+ 0x3025, 0x5f67, 0x5f51, 0x5146, 0x5f55, 0x5f58, 0x5f59, 0x5f5c,
+ 0x3b29, 0x5f60, 0x5f61, 0x5f62, 0x5f66, 0x5f68, 0x5334, 0x3867,
+ 0x4536, 0x5f6a, 0x495a, 0x4128, 0x4444, 0x3f5e, 0x4f78, 0x555c,
+ 0x5f6e, 0x3238, 0x3a5f, 0x5f6c, 0x5b41, 0x5164, 0x4b74, 0x343d,
+ 0x3026, 0x5f71, 0x4c46, 0x5f72, 0x5f6d, 0x5f69, 0x5f6b, 0x5f6f,
+ 0x5f70, 0x3b3d, 0x5f73, 0x5f74, 0x3b23, 0x4a5b, 0x4e28, 0x6027,
+ 0x332a, 0x6026, 0x6021, 0x5f7e, 0x4d59, 0x5f7c, 0x5f7a, 0x3f50,
+ 0x5744, 0x494c, 0x5f78, 0x3021, 0x5f7d, 0x5f7b, 0x6022, 0x6028,
+ 0x3748, 0x4621, 0x4936, 0x4032, 0x5f75, 0x453e, 0x5844, 0x5f79,
+ 0x4476, 0x6023, 0x6024, 0x6025, 0x5025, 0x6034, 0x4c64, 0x6031,
+ 0x3f26, 0x602f, 0x4e39, 0x602b, 0x4946, 0x402e, 0x602e, 0x3a6d,
+ 0x3a30, 0x6029, 0x5f76, 0x6033, 0x6038, 0x342d, 0x6039, 0x4f32,
+ 0x3a48, 0x6030, 0x507a, 0x602c, 0x547b, 0x5f77, 0x4567, 0x602d,
+ 0x5377, 0x6036, 0x6037, 0x6044, 0x5061, 0x603c, 0x6049, 0x604a,
+ 0x603e, 0x602a, 0x4924, 0x6041, 0x6032, 0x4a48, 0x6043, 0x6035,
+ 0x4e4b, 0x4b43, 0x604d, 0x6046, 0x6042, 0x604b, 0x603a, 0x603f,
+ 0x6040, 0x6045, 0x6047, 0x6048, 0x604c, 0x603b, 0x4b54, 0x6055,
+ 0x6056, 0x6052, 0x6050, 0x3c4e, 0x6051, 0x3842, 0x5845, 0x506a,
+ 0x426f, 0x604f, 0x603d, 0x6054, 0x6053, 0x6057, 0x605c, 0x6058,
+ 0x5676, 0x3330, 0x576c, 0x4b3b, 0x605a, 0x4e7b, 0x3a59, 0x6061,
+ 0x605d, 0x522d, 0x6062, 0x605b, 0x6059, 0x605f, 0x6060, 0x605e,
+ 0x6064, 0x4677, 0x582c, 0x546b, 0x6066, 0x4a49, 0x6065, 0x3841,
+ 0x6067, 0x6068, 0x6069, 0x6063, 0x3a3f, 0x4c67, 0x606a, 0x4f79,
+ 0x606b, 0x4842, 0x3d40, 0x4452, 0x606c, 0x606d, 0x4774, 0x4b44,
+ 0x606e, 0x3b58, 0x5836, 0x5272, 0x606f, 0x4d45, 0x365a, 0x6071,
+ 0x5430, 0x4027, 0x3451, 0x4e27, 0x6070, 0x6072, 0x394c, 0x397a,
+ 0x4d3c, 0x6073, 0x4654, 0x6074, 0x5432, 0x4826, 0x6076, 0x6075,
+ 0x6077, 0x4d41, 0x4a25, 0x545a, 0x5b57, 0x5b59, 0x5b58, 0x3967,
+ 0x5b5c, 0x5b5d, 0x3558, 0x5b5a, 0x5b5b, 0x3321, 0x5b5f, 0x3b78,
+ 0x5637, 0x5b60, 0x3e79, 0x373b, 0x5b50, 0x4c2e, 0x3f32, 0x3b35,
+ 0x5778, 0x3f53, 0x3f69, 0x3c61, 0x4c33, 0x5b5e, 0x3053, 0x4e6b,
+ 0x3758, 0x5739, 0x4642, 0x4024, 0x4c39, 0x5b67, 0x5b61, 0x463a,
+ 0x5b63, 0x5b68, 0x4577, 0x5b6a, 0x5b69, 0x3f40, 0x5b66, 0x5b65,
+ 0x3439, 0x402c, 0x4222, 0x5b62, 0x5b64, 0x504d, 0x5b6d, 0x405d,
+ 0x5b72, 0x3662, 0x5b73, 0x5b52, 0x3938, 0x542b, 0x5b6c, 0x3f51,
+ 0x5b70, 0x5b51, 0x3566, 0x5b6b, 0x3f65, 0x5b6e, 0x5b71, 0x5b79,
+ 0x3921, 0x3023, 0x4271, 0x3347, 0x5b6f, 0x5b78, 0x4652, 0x5b74,
+ 0x5b75, 0x5b77, 0x5b76, 0x5b7e, 0x5372, 0x323a, 0x5b7d, 0x5c24,
+ 0x5b7b, 0x5b7a, 0x5b7c, 0x4560, 0x3b79, 0x5c23, 0x5c25, 0x4c43,
+ 0x3651, 0x5d40, 0x5c21, 0x5c22, 0x4735, 0x3669, 0x5c27, 0x5c26,
+ 0x5c29, 0x3124, 0x354c, 0x3f30, 0x515f, 0x3642, 0x5c28, 0x4b7a,
+ 0x6b73, 0x4b5c, 0x4b7e, 0x4c41, 0x487b, 0x5c2a, 0x4c6e, 0x5c2b,
+ 0x5b53, 0x5c2f, 0x5c2c, 0x3e33, 0x4a7b, 0x5c2d, 0x494a, 0x4439,
+ 0x473d, 0x5c2e, 0x5476, 0x5066, 0x442b, 0x3655, 0x5b54, 0x315a,
+ 0x5b55, 0x5b56, 0x3a3e, 0x4840, 0x4a3f, 0x4849, 0x5733, 0x4979,
+ 0x3f47, 0x3a78, 0x523c, 0x623a, 0x3426, 0x3138, 0x3834, 0x4f44,
+ 0x5967, 0x4f26, 0x4d62, 0x596d, 0x3660, 0x5239, 0x393b, 0x6239,
+ 0x6237, 0x3473, 0x4c6c, 0x4c2b, 0x3772, 0x5832, 0x516b, 0x3a3b,
+ 0x4a27, 0x4d37, 0x5244, 0x3f64, 0x3c50, 0x3661, 0x5e45, 0x5e46,
+ 0x5b3c, 0x5159, 0x4666, 0x444e, 0x376e, 0x375c, 0x3f7c, 0x5760,
+ 0x4675, 0x313c, 0x5e48, 0x3d31, 0x4c57, 0x5e4a, 0x5e49, 0x356c,
+ 0x495d, 0x3042, 0x452e, 0x452b, 0x444c, 0x3c69, 0x4b7d, 0x3a43,
+ 0x6579, 0x4867, 0x657a, 0x4d7d, 0x5731, 0x383e, 0x4268, 0x4851,
+ 0x657b, 0x364a, 0x3c4b, 0x517d, 0x6621, 0x436e, 0x6624, 0x657e,
+ 0x6625, 0x4d57, 0x3741, 0x657c, 0x657d, 0x6623, 0x445d, 0x6628,
+ 0x6627, 0x4343, 0x465e, 0x662a, 0x4437, 0x6622, 0x4a3c, 0x3d63,
+ 0x3943, 0x6626, 0x5055, 0x4e2f, 0x6629, 0x6630, 0x5226, 0x3d2a,
+ 0x662d, 0x662f, 0x4051, 0x524c, 0x3c27, 0x6631, 0x5276, 0x574b,
+ 0x4d7e, 0x4d5e, 0x4226, 0x662b, 0x662c, 0x3d3f, 0x662e, 0x6633,
+ 0x6632, 0x6636, 0x6638, 0x446f, 0x4448, 0x3e6a, 0x496f, 0x6637,
+ 0x3670, 0x4364, 0x5369, 0x6634, 0x6635, 0x4822, 0x663d, 0x6639,
+ 0x4645, 0x4d71, 0x663b, 0x663c, 0x3b69, 0x663e, 0x663a, 0x4037,
+ 0x5324, 0x663f, 0x4974, 0x6643, 0x6644, 0x5076, 0x433d, 0x4344,
+ 0x6642, 0x6641, 0x6647, 0x4f31, 0x6b74, 0x664a, 0x6645, 0x3c5e,
+ 0x4929, 0x3c35, 0x4f53, 0x6648, 0x6649, 0x664e, 0x6650, 0x6651,
+ 0x664b, 0x3555, 0x664c, 0x664f, 0x445b, 0x6646, 0x664d, 0x6652,
+ 0x6654, 0x6653, 0x6655, 0x5978, 0x6656, 0x6657, 0x5753, 0x665d,
+ 0x665e, 0x3f57, 0x5450, 0x5756, 0x3466, 0x4b6f, 0x665a, 0x5843,
+ 0x574e, 0x5022, 0x434f, 0x665f, 0x3c3e, 0x3942, 0x665b, 0x5127,
+ 0x3a22, 0x424f, 0x582b, 0x4a6b, 0x656e, 0x665c, 0x3775, 0x4866,
+ 0x4475, 0x6532, 0x447e, 0x4b7c, 0x6533, 0x552c, 0x536e, 0x4a58,
+ 0x3032, 0x4b4e, 0x4d6a, 0x3a6a, 0x6535, 0x6534, 0x575a, 0x3959,
+ 0x5666, 0x3628, 0x4d70, 0x524b, 0x3126, 0x4a35, 0x3368, 0x4973,
+ 0x3f4d, 0x507b, 0x4a52, 0x6536, 0x3b42, 0x4f5c, 0x392c, 0x5457,
+ 0x3a26, 0x5167, 0x4f7c, 0x3c52, 0x6537, 0x485d, 0x3f6d, 0x3176,
+ 0x4b5e, 0x3c45, 0x3c44, 0x527a, 0x435c, 0x3f5c, 0x383b, 0x4342,
+ 0x3a2e, 0x5422, 0x475e, 0x442f, 0x326c, 0x3951, 0x653b, 0x4148,
+ 0x552f, 0x653c, 0x653e, 0x3467, 0x3654, 0x4b42, 0x5130, 0x353c,
+ 0x4a59, 0x3762, 0x4964, 0x3d2b, 0x4e3e, 0x5770, 0x5021, 0x4959,
+ 0x367b, 0x6658, 0x3c62, 0x333e, 0x4950, 0x6659, 0x3322, 0x5e4c,
+ 0x5348, 0x5e4d, 0x5222, 0x5e4e, 0x3e4d, 0x5e4f, 0x4a2c, 0x527c,
+ 0x335f, 0x656a, 0x4461, 0x3e21, 0x4e32, 0x4472, 0x3e56, 0x4628,
+ 0x3263, 0x3e53, 0x477c, 0x4c6b, 0x3d6c, 0x4e5d, 0x4a3a, 0x4641,
+ 0x656c, 0x503c, 0x5539, 0x656d, 0x4a74, 0x4d40, 0x4245, 0x656f,
+ 0x4244, 0x6570, 0x6578, 0x4d4d, 0x493d, 0x5259, 0x6128, 0x536c,
+ 0x4b6a, 0x4671, 0x612c, 0x6127, 0x6129, 0x612a, 0x612f, 0x326d,
+ 0x612b, 0x385a, 0x612d, 0x612e, 0x6130, 0x353a, 0x6131, 0x6133,
+ 0x6138, 0x5152, 0x6136, 0x6135, 0x416b, 0x6137, 0x5440, 0x6132,
+ 0x613a, 0x3036, 0x6134, 0x3f79, 0x6139, 0x613b, 0x613e, 0x613c,
+ 0x5645, 0x4f3f, 0x613d, 0x613f, 0x424d, 0x366b, 0x5378, 0x474d,
+ 0x3765, 0x3e7e, 0x6140, 0x6141, 0x6147, 0x3367, 0x4669, 0x345e,
+ 0x5142, 0x6148, 0x6146, 0x6145, 0x6143, 0x6142, 0x3140, 0x5538,
+ 0x6144, 0x614b, 0x614c, 0x614a, 0x6f7a, 0x6153, 0x6152, 0x4736,
+ 0x6149, 0x614e, 0x6150, 0x6154, 0x6151, 0x614d, 0x614f, 0x6155,
+ 0x6156, 0x6157, 0x6158, 0x615a, 0x615b, 0x4e21, 0x675d, 0x3428,
+ 0x565d, 0x5132, 0x3332, 0x3924, 0x5773, 0x4749, 0x3e5e, 0x392e,
+ 0x4e57, 0x326e, 0x5b4f, 0x3c3a, 0x5251, 0x4b48, 0x304d, 0x4f6f,
+ 0x5963, 0x3d6d, 0x3152, 0x4a50, 0x323c, 0x4b27, 0x372b, 0x4a26,
+ 0x4f23, 0x6078, 0x554a, 0x607b, 0x607a, 0x4541, 0x4c7b, 0x4131,
+ 0x6079, 0x5663, 0x322f, 0x5644, 0x355b, 0x3478, 0x5621, 0x4f2f,
+ 0x306f, 0x607c, 0x6121, 0x3323, 0x607d, 0x607e, 0x4331, 0x435d,
+ 0x6122, 0x3779, 0x3b4f, 0x6123, 0x443b, 0x6124, 0x6125, 0x6126,
+ 0x3431, 0x3849, 0x463d, 0x446a, 0x3222, 0x5052, 0x675b, 0x3b43,
+ 0x5357, 0x5344, 0x3963, 0x624f, 0x572f, 0x476c, 0x3153, 0x3432,
+ 0x6251, 0x5072, 0x422e, 0x6250, 0x3f62, 0x5326, 0x3557, 0x6252,
+ 0x356a, 0x436d, 0x387d, 0x382e, 0x4553, 0x374f, 0x6254, 0x6253,
+ 0x3648, 0x5779, 0x4d25, 0x6258, 0x6256, 0x4a7c, 0x3f35, 0x5339,
+ 0x6255, 0x6257, 0x412e, 0x4048, 0x625b, 0x625a, 0x402a, 0x414e,
+ 0x625c, 0x625d, 0x625e, 0x5b48, 0x5153, 0x4d22, 0x3d28, 0x5e43,
+ 0x5825, 0x3f2a, 0x5b4d, 0x526c, 0x467a, 0x452a, 0x5e44, 0x3157,
+ 0x5f2e, 0x4a3d, 0x5f31, 0x392d, 0x527d, 0x3825, 0x3a6b, 0x335a,
+ 0x355c, 0x5545, 0x4356, 0x4f52, 0x3b21, 0x6573, 0x6572, 0x6574,
+ 0x4d64, 0x4875, 0x352f, 0x473f, 0x6576, 0x6c30, 0x6566, 0x3969,
+ 0x3531, 0x423c, 0x6568, 0x6567, 0x6569, 0x524d, 0x616a, 0x504e,
+ 0x4d2e, 0x5165, 0x324a, 0x316b, 0x3172, 0x456d, 0x5543, 0x5330,
+ 0x615c, 0x615d, 0x525b, 0x3339, 0x314b, 0x4d79, 0x5577, 0x615e,
+ 0x3e36, 0x347d, 0x615f, 0x3a5c, 0x6160, 0x3b32, 0x4249, 0x6161,
+ 0x506c, 0x4d3d, 0x6162, 0x3543, 0x4547, 0x6163, 0x6164, 0x5379,
+ 0x6165, 0x512d, 0x6166, 0x4e22, 0x6167, 0x3542, 0x6168, 0x3b55,
+ 0x5044, 0x6260, 0x3158, 0x5264, 0x6261, 0x3c49, 0x484c, 0x6263,
+ 0x6c7e, 0x6c7d, 0x5f2f, 0x6262, 0x563e, 0x4d7c, 0x4326, 0x6343,
+ 0x5652, 0x6267, 0x6268, 0x5347, 0x626c, 0x3f6c, 0x626d, 0x6265,
+ 0x3340, 0x446e, 0x626e, 0x5043, 0x3a76, 0x6269, 0x375e, 0x3b33,
+ 0x4c2c, 0x4b4b, 0x6264, 0x6266, 0x626a, 0x626b, 0x6277, 0x6274,
+ 0x5475, 0x6273, 0x452d, 0x557a, 0x4542, 0x3240, 0x626f, 0x6272,
+ 0x412f, 0x4b3c, 0x3521, 0x6279, 0x3c31, 0x6271, 0x5054, 0x5439,
+ 0x6275, 0x3956, 0x6276, 0x4753, 0x6270, 0x575c, 0x6d21, 0x6278,
+ 0x6d25, 0x627e, 0x4a51, 0x4135, 0x3b50, 0x3f56, 0x3a63, 0x4b21,
+ 0x6d26, 0x6d23, 0x6d22, 0x3b56, 0x6d27, 0x5074, 0x6d24, 0x3a5e,
+ 0x3677, 0x6321, 0x3632, 0x4c71, 0x3927, 0x4f22, 0x4721, 0x3f52,
+ 0x3671, 0x627a, 0x627b, 0x627d, 0x627c, 0x4455, 0x6322, 0x5341,
+ 0x6327, 0x4744, 0x4f24, 0x6329, 0x3a37, 0x6328, 0x3b5a, 0x6323,
+ 0x6324, 0x632a, 0x6326, 0x4e72, 0x5346, 0x3b3c, 0x5443, 0x447a,
+ 0x6d28, 0x507c, 0x6325, 0x4375, 0x632d, 0x312f, 0x6332, 0x3c42,
+ 0x632c, 0x353f, 0x4769, 0x6330, 0x3e2a, 0x4d6f, 0x3b73, 0x4c68,
+ 0x632f, 0x6331, 0x4f27, 0x632e, 0x4e29, 0x3b5d, 0x356b, 0x3e65,
+ 0x3252, 0x334d, 0x3139, 0x632b, 0x3251, 0x352c, 0x395f, 0x3668,
+ 0x4f6b, 0x6337, 0x3b4c, 0x4847, 0x504a, 0x6338, 0x336e, 0x6d29,
+ 0x537a, 0x5364, 0x6d2a, 0x6339, 0x5262, 0x6335, 0x535e, 0x3850,
+ 0x6333, 0x6336, 0x375f, 0x6334, 0x4022, 0x633a, 0x5438, 0x3448,
+ 0x633b, 0x3b45, 0x4977, 0x4965, 0x443d, 0x6d2b, 0x427d, 0x3b5b,
+ 0x3f2e, 0x4e3f, 0x633c, 0x3f36, 0x316f, 0x5477, 0x633e, 0x6d2d,
+ 0x633f, 0x3a29, 0x6d2c, 0x633d, 0x6340, 0x3a36, 0x362e, 0x5038,
+ 0x3043, 0x6d2e, 0x6d2f, 0x4041, 0x6341, 0x4533, 0x6342, 0x5c32,
+ 0x6d30, 0x386a, 0x4e6c, 0x6a27, 0x5067, 0x4a79, 0x4856, 0x4f37,
+ 0x3349, 0x4e52, 0x3d64, 0x635e, 0x3b72, 0x6a28, 0x553d, 0x465d,
+ 0x6a29, 0x6a2a, 0x6a2c, 0x6a2b, 0x6a2e, 0x6a2d, 0x3d58, 0x6a2f,
+ 0x423e, 0x3441, 0x3477, 0x3b27, 0x6c66, 0x6c65, 0x373f, 0x4b79,
+ 0x3162, 0x6c67, 0x4948, 0x6c68, 0x6c69, 0x4a56, 0x5e50, 0x3245,
+ 0x547a, 0x464b, 0x3047, 0x3472, 0x4853, 0x4d50, 0x3f38, 0x3f5b,
+ 0x4724, 0x5634, 0x4029, 0x5e51, 0x4928, 0x516f, 0x4524, 0x3067,
+ 0x3336, 0x4845, 0x3062, 0x3776, 0x457a, 0x3673, 0x5552, 0x3350,
+ 0x3c3c, 0x332d, 0x3e71, 0x3051, 0x5256, 0x4a63, 0x5725, 0x4d36,
+ 0x3636, 0x3f39, 0x555b, 0x3827, 0x4557, 0x5e52, 0x3f59, 0x4255,
+ 0x4740, 0x3b24, 0x3128, 0x456a, 0x457b, 0x4c27, 0x3127, 0x3556,
+ 0x4428, 0x5e53, 0x513a, 0x3369, 0x4372, 0x3777, 0x5674, 0x3523,
+ 0x3270, 0x4434, 0x4469, 0x402d, 0x5e54, 0x3068, 0x4544, 0x4160,
+ 0x3955, 0x3e5c, 0x4d58, 0x304e, 0x4d4f, 0x5e56, 0x3e50, 0x573e,
+ 0x5e55, 0x5550, 0x305d, 0x4462, 0x4223, 0x3c70, 0x5335, 0x4039,
+ 0x4521, 0x3226, 0x5471, 0x4028, 0x4a43, 0x5e57, 0x557c, 0x3930,
+ 0x482d, 0x4b29, 0x5e59, 0x3f3d, 0x4634, 0x5727, 0x4a30, 0x4443,
+ 0x3356, 0x3952, 0x5638, 0x6a7c, 0x3034, 0x3f66, 0x4c74, 0x4d5a,
+ 0x563f, 0x424e, 0x4e4e, 0x4c22, 0x502e, 0x4453, 0x3532, 0x5e58,
+ 0x5575, 0x3c37, 0x3b53, 0x3024, 0x4532, 0x346c, 0x5571, 0x6a7d,
+ 0x5e5a, 0x4d26, 0x4d6c, 0x4e66, 0x5e5c, 0x4d31, 0x4026, 0x573d,
+ 0x5e5b, 0x3046, 0x3a34, 0x4953, 0x4473, 0x3e68, 0x3236, 0x404c,
+ 0x4b70, 0x3c71, 0x3b3b, 0x3537, 0x4575, 0x5e66, 0x5e63, 0x3e5d,
+ 0x5e5f, 0x3437, 0x3d5d, 0x5e60, 0x446d, 0x4f46, 0x3560, 0x365e,
+ 0x4a5a, 0x3574, 0x5e65, 0x5546, 0x5e61, 0x4c4d, 0x467e, 0x4545,
+ 0x5234, 0x3e72, 0x4253, 0x4c3d, 0x3338, 0x3d53, 0x3f58, 0x4d46,
+ 0x515a, 0x346b, 0x5e64, 0x5e5d, 0x5e67, 0x6a7e, 0x4230, 0x5e62,
+ 0x5640, 0x3527, 0x3274, 0x5e68, 0x5e72, 0x5e6d, 0x5e71, 0x4860,
+ 0x5761, 0x5e6f, 0x4368, 0x4c61, 0x3265, 0x523e, 0x5e6e, 0x5e6b,
+ 0x4e55, 0x3427, 0x3f2b, 0x3e3e, 0x3d52, 0x5e69, 0x542e, 0x5e5e,
+ 0x5e6a, 0x403f, 0x5e6c, 0x3273, 0x3869, 0x4227, 0x3d41, 0x5e75,
+ 0x5e78, 0x322b, 0x3424, 0x346a, 0x4926, 0x5e76, 0x4b51, 0x3863,
+ 0x5e77, 0x5e7a, 0x5e79, 0x4c42, 0x3061, 0x346e, 0x653a, 0x502f,
+ 0x326b, 0x6b21, 0x5e74, 0x4963, 0x5e73, 0x305a, 0x5221, 0x3177,
+ 0x4c2f, 0x5e70, 0x4b24, 0x552a, 0x5e7b, 0x345d, 0x4426, 0x5e7d,
+ 0x437e, 0x4421, 0x5f21, 0x414c, 0x5e7c, 0x3e6f, 0x4632, 0x3345,
+ 0x4876, 0x4b3a, 0x5e7e, 0x5f24, 0x5732, 0x3337, 0x4143, 0x474b,
+ 0x3225, 0x3469, 0x572b, 0x446c, 0x5f22, 0x5f23, 0x5f25, 0x3a33,
+ 0x5f26, 0x405e, 0x4943, 0x3259, 0x4766, 0x5f27, 0x475c, 0x5f28,
+ 0x6b22, 0x4b53, 0x5f2a, 0x5f29, 0x3241, 0x454a, 0x5f2b, 0x545c,
+ 0x4841, 0x5f2c, 0x3e70, 0x5f2d, 0x5627, 0x6a37, 0x6b36, 0x4a55,
+ 0x587c, 0x3844, 0x3925, 0x3745, 0x557e, 0x394a, 0x5027, 0x744d,
+ 0x3550, 0x4374, 0x3e48, 0x6b37, 0x303d, 0x3d4c, 0x4132, 0x3156,
+ 0x3328, 0x3852, 0x4922, 0x3658, 0x6b38, 0x3e34, 0x4a7d, 0x4743,
+ 0x557b, 0x3773, 0x4e44, 0x552b, 0x3173, 0x6c33, 0x305f, 0x6c35,
+ 0x3637, 0x414f, 0x757a, 0x5031, 0x5565, 0x4e53, 0x3d6f, 0x3362,
+ 0x382b, 0x5536, 0x6d3d, 0x364f, 0x4b39, 0x5042, 0x373d, 0x6c36,
+ 0x4a29, 0x4554, 0x6c39, 0x6c38, 0x4243, 0x6c37, 0x507d, 0x6c3a,
+ 0x6c3b, 0x5765, 0x6c3c, 0x6c3d, 0x466c, 0x4e5e, 0x3c48, 0x4855,
+ 0x3529, 0x3e49, 0x563c, 0x5467, 0x512e, 0x5071, 0x6a38, 0x6a39,
+ 0x6a3a, 0x3a35, 0x4a31, 0x3f75, 0x4d7a, 0x6a40, 0x303a, 0x6a3e,
+ 0x4025, 0x6a3b, 0x327d, 0x4377, 0x3b68, 0x5257, 0x4e74, 0x6a3f,
+ 0x6a3c, 0x6a43, 0x5047, 0x5333, 0x343a, 0x4341, 0x5772, 0x5551,
+ 0x4a47, 0x6a45, 0x6a44, 0x6a47, 0x6a46, 0x5667, 0x4f54, 0x6a4b,
+ 0x3b4e, 0x3d7a, 0x494e, 0x6a4c, 0x4939, 0x4f7e, 0x6a4a, 0x544e,
+ 0x6a4d, 0x6a4f, 0x4d6d, 0x6a49, 0x6a4e, 0x4e6e, 0x3b5e, 0x333f,
+ 0x4655, 0x3e30, 0x4e7a, 0x4767, 0x3e27, 0x6a50, 0x5647, 0x4140,
+ 0x545d, 0x6a51, 0x4f3e, 0x6a52, 0x4a6e, 0x452f, 0x3035, 0x6a54,
+ 0x6a53, 0x745f, 0x443a, 0x3129, 0x655f, 0x6a55, 0x4a6f, 0x6a56,
+ 0x6a57, 0x4658, 0x6a58, 0x6a59, 0x543b, 0x477a, 0x5237, 0x387c,
+ 0x6a42, 0x325c, 0x427c, 0x5478, 0x4c66, 0x576e, 0x5442, 0x5350,
+ 0x6b43, 0x4573, 0x377e, 0x6b54, 0x4b37, 0x6b5e, 0x404a, 0x4d7b,
+ 0x332f, 0x465a, 0x6b7c, 0x443e, 0x4e34, 0x4429, 0x313e, 0x547d,
+ 0x4a75, 0x566c, 0x4653, 0x3664, 0x3b7a, 0x5060, 0x4931, 0x5453,
+ 0x4828, 0x384b, 0x683e, 0x493c, 0x683b, 0x406e, 0x5053, 0x3244,
+ 0x3465, 0x683c, 0x5548, 0x3645, 0x683d, 0x4a78, 0x385c, 0x4c75,
+ 0x4034, 0x516e, 0x683f, 0x6842, 0x3a3c, 0x312d, 0x3d5c, 0x6a3d,
+ 0x6843, 0x6846, 0x684b, 0x684c, 0x4b49, 0x3065, 0x3c2b, 0x3939,
+ 0x6841, 0x4d77, 0x684a, 0x4e76, 0x556d, 0x4156, 0x6844, 0x4336,
+ 0x397b, 0x5626, 0x6848, 0x4a60, 0x5466, 0x6840, 0x6845, 0x6847,
+ 0x4739, 0x3763, 0x6849, 0x3f5d, 0x6852, 0x6857, 0x6855, 0x3c5c,
+ 0x3c4f, 0x685b, 0x685e, 0x685a, 0x317a, 0x3058, 0x4433, 0x384c,
+ 0x4662, 0x483e, 0x4861, 0x684f, 0x6854, 0x6856, 0x3971, 0x6858,
+ 0x5775, 0x447b, 0x685c, 0x3269, 0x6851, 0x3c6d, 0x3f42, 0x684d,
+ 0x5679, 0x4178, 0x3271, 0x685f, 0x4a41, 0x6859, 0x5524, 0x316a,
+ 0x553b, 0x684e, 0x6850, 0x3630, 0x6853, 0x685d, 0x4038, 0x4a77,
+ 0x4b28, 0x465c, 0x4075, 0x6869, 0x5023, 0x6872, 0x566a, 0x6860,
+ 0x6861, 0x5179, 0x3a4b, 0x3879, 0x3871, 0x5454, 0x686f, 0x686e,
+ 0x686c, 0x3970, 0x4c52, 0x6866, 0x4e26, 0x3f72, 0x3038, 0x6871,
+ 0x6870, 0x5740, 0x6864, 0x4d29, 0x4923, 0x3b38, 0x3d5b, 0x686a,
+ 0x6862, 0x6863, 0x6865, 0x3535, 0x6867, 0x4745, 0x686b, 0x686d,
+ 0x3d30, 0x572e, 0x6878, 0x6875, 0x4d30, 0x6876, 0x413a, 0x6868,
+ 0x4337, 0x3070, 0x6874, 0x6877, 0x3923, 0x4952, 0x434e, 0x4e60,
+ 0x4066, 0x4b73, 0x4c5d, 0x5035, 0x4a61, 0x6873, 0x3c6c, 0x6879,
+ 0x435e, 0x4665, 0x3977, 0x3074, 0x5758, 0x3c2c, 0x456f, 0x4c44,
+ 0x6926, 0x492d, 0x6922, 0x4062, 0x3f43, 0x687e, 0x3957, 0x687b,
+ 0x6924, 0x524e, 0x6923, 0x5632, 0x5735, 0x6927, 0x3d37, 0x687c,
+ 0x687d, 0x6921, 0x4d56, 0x522c, 0x6932, 0x6929, 0x342a, 0x343b,
+ 0x692b, 0x5028, 0x6925, 0x337e, 0x692c, 0x4063, 0x692a, 0x6939,
+ 0x6938, 0x692e, 0x687a, 0x6928, 0x3f2c, 0x6931, 0x693a, 0x4225,
+ 0x692f, 0x3845, 0x692d, 0x535c, 0x6934, 0x6935, 0x6937, 0x6947,
+ 0x4046, 0x6945, 0x6930, 0x693b, 0x3071, 0x693c, 0x5525, 0x693e,
+ 0x693f, 0x6941, 0x4171, 0x4836, 0x693d, 0x6942, 0x6943, 0x6933,
+ 0x6936, 0x3b31, 0x6940, 0x3c77, 0x6944, 0x6946, 0x694a, 0x694e,
+ 0x325b, 0x6948, 0x372e, 0x694b, 0x694c, 0x5541, 0x4423, 0x6958,
+ 0x3a61, 0x6949, 0x5323, 0x6954, 0x6957, 0x6950, 0x694f, 0x4741,
+ 0x6952, 0x6959, 0x3348, 0x6953, 0x4f70, 0x694d, 0x3377, 0x6956,
+ 0x695a, 0x4c34, 0x4f2d, 0x6955, 0x695c, 0x695b, 0x695e, 0x6951,
+ 0x695d, 0x695f, 0x434a, 0x4737, 0x344e, 0x3b36, 0x5040, 0x6c23,
+ 0x4537, 0x537b, 0x6c24, 0x6c25, 0x465b, 0x3f6e, 0x6c26, 0x6c27,
+ 0x502a, 0x4738, 0x3868, 0x6c28, 0x5639, 0x557d, 0x344b, 0x323d,
+ 0x4e64, 0x4667, 0x4d61, 0x3475, 0x4b40, 0x3c5f, 0x6962, 0x6963,
+ 0x516a, 0x6965, 0x3479, 0x6964, 0x5133, 0x4a62, 0x3250, 0x6968,
+ 0x6966, 0x6967, 0x5633, 0x6969, 0x696a, 0x696b, 0x696c, 0x6c2f,
+ 0x4539, 0x364e, 0x5273, 0x356e, 0x3b59, 0x6c31, 0x5263, 0x4e63,
+ 0x4438, 0x433f, 0x363e, 0x5839, 0x3148, 0x314f, 0x3151, 0x457e,
+ 0x3150, 0x432b, 0x5531, 0x6b24, 0x3a41, 0x4c3a, 0x6b25, 0x6b27,
+ 0x6b28, 0x6b26, 0x6b29, 0x6b2b, 0x6b2a, 0x6b2c, 0x4a4f, 0x5835,
+ 0x4371, 0x4325, 0x4678, 0x6b2d, 0x444a, 0x6b2e, 0x6b2f, 0x6b30,
+ 0x3755, 0x377a, 0x6b31, 0x4762, 0x6b33, 0x3a24, 0x5175, 0x3031,
+ 0x6b32, 0x6b34, 0x352a, 0x4248, 0x4768, 0x6b35, 0x4b2e, 0x635f,
+ 0x5340, 0x595b, 0x4d21, 0x562d, 0x4773, 0x5960, 0x3b63, 0x3a3a,
+ 0x6362, 0x4f2b, 0x6360, 0x4947, 0x3a39, 0x5134, 0x6361, 0x486a,
+ 0x392f, 0x3d2d, 0x3358, 0x4e5b, 0x4c40, 0x6368, 0x6369, 0x4d74,
+ 0x4c2d, 0x3c33, 0x636a, 0x636b, 0x505a, 0x467b, 0x375a, 0x475f,
+ 0x524a, 0x4e56, 0x6364, 0x636c, 0x4972, 0x3341, 0x6367, 0x4663,
+ 0x6365, 0x6d33, 0x6366, 0x4933, 0x4566, 0x3935, 0x433b, 0x6363,
+ 0x453d, 0x4124, 0x4259, 0x3257, 0x636d, 0x3b26, 0x442d, 0x6370,
+ 0x3e5a, 0x637b, 0x6375, 0x3a53, 0x3750, 0x534d, 0x564e, 0x5553,
+ 0x3941, 0x5534, 0x5158, 0x5039, 0x4776, 0x482a, 0x3234, 0x435a,
+ 0x636e, 0x637c, 0x636f, 0x3728, 0x6377, 0x6374, 0x373a, 0x4522,
+ 0x6376, 0x455d, 0x3228, 0x467c, 0x4460, 0x5722, 0x4061, 0x6379,
+ 0x637a, 0x637d, 0x4c29, 0x6373, 0x533e, 0x3143, 0x6d34, 0x6371,
+ 0x6372, 0x6378, 0x503a, 0x4643, 0x5473, 0x637e, 0x3d60, 0x6427,
+ 0x6426, 0x5173, 0x6423, 0x6429, 0x4877, 0x4f34, 0x6428, 0x642e,
+ 0x4265, 0x3634, 0x3d72, 0x6422, 0x3a69, 0x642a, 0x642c, 0x367d,
+ 0x565e, 0x6432, 0x642d, 0x6421, 0x3b6e, 0x4d5d, 0x4722, 0x4549,
+ 0x4177, 0x6424, 0x4733, 0x3d2c, 0x3d3d, 0x6425, 0x5747, 0x3262,
+ 0x642b, 0x3c43, 0x642f, 0x3b6b, 0x6430, 0x4528, 0x6431, 0x5563,
+ 0x3f23, 0x643a, 0x6437, 0x643b, 0x643d, 0x4656, 0x3a46, 0x404b,
+ 0x3821, 0x6434, 0x5421, 0x3a23, 0x3d7e, 0x643c, 0x4d3f, 0x4479,
+ 0x4f7b, 0x4966, 0x533f, 0x4f51, 0x6433, 0x6438, 0x6439, 0x4c69,
+ 0x4c4e, 0x4054, 0x6435, 0x4130, 0x6436, 0x4e50, 0x3b41, 0x3553,
+ 0x4873, 0x3d27, 0x5547, 0x492c, 0x3822, 0x644a, 0x644c, 0x5144,
+ 0x523a, 0x3a2d, 0x3a54, 0x6443, 0x356d, 0x574d, 0x6440, 0x4f7d,
+ 0x643f, 0x415c, 0x4c4a, 0x4a67, 0x4457, 0x4c54, 0x6448, 0x6447,
+ 0x6441, 0x6444, 0x352d, 0x5359, 0x6446, 0x5279, 0x3463, 0x3b34,
+ 0x496e, 0x343e, 0x3b6c, 0x514d, 0x4c6d, 0x6d35, 0x4765, 0x5428,
+ 0x644b, 0x5755, 0x6442, 0x3d25, 0x6445, 0x5366, 0x6449, 0x4978,
+ 0x643e, 0x5365, 0x477e, 0x3649, 0x547c, 0x3233, 0x6457, 0x4e42,
+ 0x644d, 0x4e3c, 0x385b, 0x6456, 0x3f4a, 0x534e, 0x436c, 0x4548,
+ 0x6458, 0x4d44, 0x644f, 0x6454, 0x6455, 0x3a7e, 0x4f66, 0x553f,
+ 0x6452, 0x6450, 0x644e, 0x4d65, 0x4a2a, 0x4023, 0x3d26, 0x6453,
+ 0x3848, 0x6467, 0x5434, 0x645b, 0x416f, 0x6469, 0x5267, 0x645f,
+ 0x6460, 0x4f2a, 0x4b5d, 0x645a, 0x6451, 0x6465, 0x485c, 0x6463,
+ 0x4467, 0x6462, 0x6461, 0x337c, 0x6468, 0x3561, 0x574c, 0x6466,
+ 0x3b2c, 0x5752, 0x4c4f, 0x6b78, 0x6464, 0x3976, 0x564d, 0x6459,
+ 0x645c, 0x427a, 0x645e, 0x424b, 0x4044, 0x4250, 0x3175, 0x4c32,
+ 0x354e, 0x646f, 0x462f, 0x4661, 0x6475, 0x4229, 0x406c, 0x515d,
+ 0x646e, 0x442e, 0x646d, 0x6476, 0x6474, 0x427e, 0x645d, 0x6470,
+ 0x4a7e, 0x5544, 0x6471, 0x517a, 0x646b, 0x646c, 0x6472, 0x4e2b,
+ 0x454b, 0x4731, 0x423a, 0x646a, 0x414a, 0x4c36, 0x3331, 0x647b,
+ 0x6473, 0x647a, 0x647d, 0x647c, 0x334e, 0x333a, 0x6477, 0x6479,
+ 0x6478, 0x456c, 0x403d, 0x5468, 0x6522, 0x3044, 0x6524, 0x6523,
+ 0x3c24, 0x6525, 0x6521, 0x647e, 0x3174, 0x6528, 0x6529, 0x6526,
+ 0x6527, 0x652a, 0x4659, 0x652b, 0x652d, 0x652c, 0x652f, 0x652e,
+ 0x3960, 0x6530, 0x6531, 0x3b70, 0x6c61, 0x4370, 0x3546, 0x3b52,
+ 0x4169, 0x546e, 0x3e44, 0x5746, 0x5456, 0x3253, 0x6c3e, 0x6a41,
+ 0x422f, 0x3436, 0x5157, 0x3334, 0x4832, 0x3f3b, 0x6c40, 0x564b,
+ 0x6c3f, 0x6c41, 0x6c45, 0x3e66, 0x4c3f, 0x455a, 0x3e3c, 0x6c46,
+ 0x317e, 0x6c44, 0x5528, 0x3563, 0x6c42, 0x4136, 0x3363, 0x6c43,
+ 0x4b38, 0x4043, 0x4c7e, 0x4152, 0x6c48, 0x3a66, 0x4053, 0x5672,
+ 0x514c, 0x3f3e, 0x3733, 0x4955, 0x6c47, 0x3b62, 0x4c4c, 0x3d7d,
+ 0x4848, 0x4f29, 0x4d69, 0x456b, 0x3769, 0x5149, 0x3a38, 0x6c49,
+ 0x6c4a, 0x3b40, 0x6c4b, 0x6c62, 0x313a, 0x3759, 0x3d39, 0x6c4c,
+ 0x5166, 0x6c4d, 0x483b, 0x6c51, 0x6c53, 0x3b4d, 0x3c65, 0x6c4f,
+ 0x4937, 0x433a, 0x6c63, 0x5555, 0x6c50, 0x5673, 0x6c52, 0x6c4e,
+ 0x6c54, 0x6c55, 0x493f, 0x4f28, 0x505c, 0x512c, 0x485b, 0x6c56,
+ 0x4e75, 0x4a6c, 0x6c5a, 0x6c59, 0x303e, 0x6c57, 0x6c58, 0x6c64,
+ 0x483c, 0x4147, 0x6c5c, 0x5160, 0x6c5b, 0x546f, 0x6c5d, 0x5b46,
+ 0x6c5e, 0x312c, 0x6c5f, 0x6c60, 0x5726, 0x4540, 0x6b3c, 0x302e,
+ 0x3e74, 0x3838, 0x522f, 0x3056, 0x3579, 0x5833, 0x4b2c, 0x635d,
+ 0x462c, 0x3066, 0x4546, 0x6b39, 0x6b3a, 0x6b3b, 0x5140, 0x4523,
+ 0x6a72, 0x4432, 0x4435, 0x404e, 0x6a73, 0x4441, 0x4e6f, 0x6a70,
+ 0x6a74, 0x497c, 0x4723, 0x4c58, 0x4e7e, 0x6a75, 0x6a76, 0x4f2c,
+ 0x4067, 0x6a77, 0x363f, 0x6a78, 0x6a79, 0x6a7a, 0x6a7b, 0x6a71,
+ 0x482e, 0x616b, 0x3738, 0x616c, 0x616d, 0x5734, 0x616e, 0x616f,
+ 0x534c, 0x6171, 0x3f71, 0x6170, 0x3552, 0x3137, 0x6173, 0x6172,
+ 0x3a7c, 0x6174, 0x3937, 0x3e51, 0x447c, 0x3a5d, 0x3d46, 0x6175,
+ 0x6177, 0x3640, 0x4f41, 0x4a28, 0x6176, 0x5578, 0x537c, 0x6178,
+ 0x617c, 0x6179, 0x617a, 0x406a, 0x617e, 0x6221, 0x4047, 0x617b,
+ 0x617d, 0x6225, 0x4154, 0x6223, 0x6228, 0x327e, 0x6222, 0x434d,
+ 0x3242, 0x6227, 0x6226, 0x6224, 0x6229, 0x622b, 0x5049, 0x566d,
+ 0x4328, 0x622c, 0x4f57, 0x622e, 0x3a6f, 0x6960, 0x622d, 0x622a,
+ 0x3b2b, 0x5433, 0x6230, 0x622f, 0x6961, 0x6231, 0x6232, 0x6233,
+ 0x4c21, 0x6234, 0x6235, 0x507e, 0x424a, 0x5371, 0x4d75, 0x6760,
+ 0x6761, 0x3e41, 0x426a, 0x6764, 0x6763, 0x4d66, 0x4335, 0x6762,
+ 0x3b37, 0x4f56, 0x4161, 0x6769, 0x6768, 0x6774, 0x3223, 0x676a,
+ 0x6766, 0x676c, 0x676b, 0x493a, 0x5564, 0x6765, 0x3729, 0x6767,
+ 0x676e, 0x6773, 0x5669, 0x676d, 0x6772, 0x6771, 0x3060, 0x6775,
+ 0x4772, 0x4045, 0x406d, 0x4170, 0x6770, 0x6776, 0x4b76, 0x6822,
+ 0x6821, 0x5741, 0x677a, 0x6779, 0x677b, 0x6777, 0x677e, 0x677d,
+ 0x677c, 0x4155, 0x4759, 0x457d, 0x4543, 0x476d, 0x6823, 0x6826,
+ 0x6825, 0x6827, 0x3a77, 0x6778, 0x6824, 0x4870, 0x492a, 0x6829,
+ 0x3965, 0x517e, 0x6828, 0x682a, 0x682d, 0x682e, 0x4127, 0x682f,
+ 0x6830, 0x682c, 0x6834, 0x682b, 0x6831, 0x6835, 0x6832, 0x6833,
+ 0x6837, 0x6836, 0x394f, 0x702c, 0x702d, 0x4630, 0x306a, 0x483f,
+ 0x4d5f, 0x4e4d, 0x6a31, 0x6a32, 0x463f, 0x3449, 0x6a33, 0x5567,
+ 0x5d79, 0x6a34, 0x6a35, 0x6a36, 0x384a, 0x5f30, 0x4975, 0x4c70,
+ 0x497a, 0x497b, 0x5343, 0x4b26, 0x3826, 0x702e, 0x3142, 0x6538,
+ 0x4c6f, 0x5349, 0x3c57, 0x496a, 0x3567, 0x4450, 0x3569, 0x6e2e,
+ 0x3b2d, 0x675e, 0x6e2f, 0x3329, 0x6e32, 0x6e31, 0x3d67, 0x6e30,
+ 0x4e37, 0x454f, 0x4174, 0x5b4e, 0x6e33, 0x5073, 0x4254, 0x4668,
+ 0x372c, 0x6e34, 0x336b, 0x3b7b, 0x6e35, 0x675c, 0x6e36, 0x3d2e,
+ 0x7162, 0x4a68, 0x5249, 0x705a, 0x705b, 0x705c, 0x4146, 0x386d,
+ 0x3e4e, 0x705e, 0x4531, 0x705d, 0x5171, 0x7060, 0x304c, 0x3d6a,
+ 0x525f, 0x705f, 0x342f, 0x3768, 0x7066, 0x7065, 0x4623, 0x7061,
+ 0x7062, 0x3443, 0x7063, 0x556e, 0x4c5b, 0x3e52, 0x3c32, 0x7068,
+ 0x7067, 0x7064, 0x3221, 0x5622, 0x5338, 0x3e37, 0x482c, 0x706a,
+ 0x5177, 0x564c, 0x3a5b, 0x7069, 0x363b, 0x4d34, 0x4626, 0x4121,
+ 0x706b, 0x706e, 0x706d, 0x7070, 0x706c, 0x3b3e, 0x706f, 0x4c35,
+ 0x7072, 0x3355, 0x3154, 0x7073, 0x7074, 0x7076, 0x3461, 0x7071,
+ 0x7077, 0x707a, 0x7078, 0x7075, 0x707d, 0x7079, 0x707c, 0x707e,
+ 0x7121, 0x4e41, 0x7124, 0x7123, 0x4176, 0x707b, 0x4a5d, 0x3471,
+ 0x3171, 0x4c31, 0x7126, 0x7127, 0x712c, 0x554e, 0x7129, 0x4833,
+ 0x7122, 0x712b, 0x7128, 0x7125, 0x712a, 0x3029, 0x712d, 0x712f,
+ 0x7131, 0x7130, 0x712e, 0x5122, 0x7132, 0x7133, 0x396f, 0x3547,
+ 0x3057, 0x3059, 0x546d, 0x3544, 0x3d54, 0x3b4a, 0x7027, 0x385e,
+ 0x7028, 0x3028, 0x7029, 0x4d6e, 0x702a, 0x702b, 0x4624, 0x5665,
+ 0x7164, 0x7165, 0x4373, 0x535b, 0x5651, 0x4568, 0x532f, 0x5266,
+ 0x6e41, 0x303b, 0x5535, 0x514e, 0x3c60, 0x3a50, 0x3f78, 0x3847,
+ 0x3541, 0x454c, 0x4a22, 0x434b, 0x6e42, 0x443f, 0x3622, 0x6d6c,
+ 0x4324, 0x5631, 0x4f60, 0x6d6f, 0x454e, 0x365c, 0x4a21, 0x6d6d,
+ 0x6d70, 0x6d71, 0x433c, 0x3f34, 0x6d6e, 0x6d74, 0x6d72, 0x5566,
+ 0x435f, 0x6d73, 0x6d76, 0x5523, 0x5123, 0x6d75, 0x4350, 0x6d77,
+ 0x3f74, 0x3e6c, 0x6d78, 0x4c77, 0x515b, 0x5745, 0x5576, 0x6d7c,
+ 0x6d7b, 0x6d79, 0x6d7a, 0x6d7d, 0x3e26, 0x4b2f, 0x6e21, 0x363d,
+ 0x6e22, 0x4440, 0x6d7e, 0x3d5e, 0x3247, 0x3643, 0x6e25, 0x583a,
+ 0x6e23, 0x6e26, 0x4369, 0x3372, 0x6e27, 0x6e24, 0x4f39, 0x6e28,
+ 0x4277, 0x6e29, 0x6e2a, 0x5e2b, 0x4633, 0x4746, 0x5675, 0x3549,
+ 0x4b32, 0x6e2b, 0x4d2b, 0x6e2c, 0x5530, 0x6e2d, 0x7644, 0x5b47,
+ 0x3423, 0x432c, 0x7166, 0x4a38, 0x5253, 0x562a, 0x6f72, 0x3e58,
+ 0x3d43, 0x6f73, 0x364c, 0x302b, 0x4a2f, 0x6d36, 0x6d37, 0x4e79,
+ 0x372f, 0x3f73, 0x6d38, 0x426b, 0x4930, 0x6d39, 0x4676, 0x3f33,
+ 0x6d3c, 0x4578, 0x5150, 0x5729, 0x6d3a, 0x6d3b, 0x5162, 0x6d3f,
+ 0x6d40, 0x6d44, 0x6d48, 0x6d46, 0x6d4e, 0x5568, 0x6d49, 0x6d47,
+ 0x6d3e, 0x4569, 0x4646, 0x4969, 0x5452, 0x6d41, 0x6d42, 0x6d43,
+ 0x6d45, 0x4079, 0x3421, 0x3968, 0x6d50, 0x6d51, 0x6d4a, 0x6d4f,
+ 0x4e78, 0x4b36, 0x6d4c, 0x6d4d, 0x4f75, 0x6d52, 0x4172, 0x5332,
+ 0x6d4b, 0x4837, 0x3c6f, 0x4570, 0x6d56, 0x356f, 0x4235, 0x302d,
+ 0x4b69, 0x312e, 0x6d54, 0x4d6b, 0x3562, 0x6d55, 0x6d53, 0x6d57,
+ 0x357a, 0x6d58, 0x6d59, 0x6d5c, 0x314c, 0x4576, 0x3c6e, 0x6d5a,
+ 0x4c3c, 0x326a, 0x6d5b, 0x446b, 0x3445, 0x3075, 0x6d5f, 0x405a,
+ 0x3468, 0x454d, 0x6d5d, 0x3f44, 0x6d5e, 0x4425, 0x6d60, 0x6d61,
+ 0x6d63, 0x4157, 0x3b47, 0x3d38, 0x6d62, 0x6d64, 0x6d66, 0x6d65,
+ 0x6d67, 0x4a3e, 0x6c6a, 0x4071, 0x4967, 0x6c6b, 0x466e, 0x6c6c,
+ 0x466d, 0x6c6d, 0x6c70, 0x5766, 0x6c73, 0x6c71, 0x6c6e, 0x6c6f,
+ 0x5723, 0x4971, 0x4b6e, 0x6c74, 0x6c72, 0x4f69, 0x6c76, 0x4631,
+ 0x3c40, 0x6c75, 0x353b, 0x3b76, 0x6c77, 0x5977, 0x3d7b, 0x423b,
+ 0x6c78, 0x6c79, 0x3823, 0x6c7a, 0x6c7b, 0x6c7c, 0x536d, 0x582e,
+ 0x406b, 0x475d, 0x3a4c, 0x5063, 0x4b3d, 0x4d3a, 0x3851, 0x317c,
+ 0x476f, 0x5656, 0x3f46, 0x436b, 0x6f75, 0x4358, 0x5762, 0x6f77,
+ 0x3353, 0x4758, 0x516d, 0x5648, 0x6f78, 0x6f76, 0x3b7d, 0x3346,
+ 0x3d55, 0x5246, 0x3b60, 0x4f21, 0x6f7c, 0x6f7b, 0x6f79, 0x334c,
+ 0x4954, 0x4b30, 0x6f7e, 0x305e, 0x5649, 0x6f7d, 0x336d, 0x7655,
+ 0x4e48, 0x7022, 0x7021, 0x353e, 0x3c5a, 0x3b7c, 0x3865, 0x4442,
+ 0x7023, 0x4b6b, 0x7026, 0x5128, 0x3e3f, 0x476e, 0x7136, 0x7137,
+ 0x3f55, 0x3429, 0x7138, 0x4d3b, 0x4754, 0x552d, 0x7139, 0x713a,
+ 0x474f, 0x5224, 0x564f, 0x713b, 0x3d51, 0x3430, 0x3e3d, 0x345c,
+ 0x4e51, 0x3f5f, 0x713d, 0x3f7a, 0x713c, 0x713f, 0x713e, 0x7140,
+ 0x7141, 0x417e, 0x4122, 0x4a7a, 0x553e, 0x3e3a, 0x3e39, 0x5542,
+ 0x3f22, 0x4d2f, 0x7135, 0x3d5f, 0x364b, 0x5671, 0x7343, 0x7344,
+ 0x384d, 0x7346, 0x7347, 0x304a, 0x7345, 0x7349, 0x4b71, 0x734b,
+ 0x5026, 0x314a, 0x7348, 0x734f, 0x3551, 0x7357, 0x7352, 0x7354,
+ 0x7353, 0x377b, 0x313f, 0x734e, 0x734a, 0x355a, 0x7350, 0x7351,
+ 0x7355, 0x734d, 0x3c63, 0x417d, 0x7356, 0x735a, 0x734c, 0x3548,
+ 0x3d6e, 0x735c, 0x3724, 0x3f70, 0x567e, 0x4d32, 0x3470, 0x325f,
+ 0x7358, 0x7359, 0x4938, 0x735d, 0x735e, 0x7361, 0x735f, 0x7363,
+ 0x7362, 0x735b, 0x3f6a, 0x336f, 0x7360, 0x4729, 0x3c72, 0x736b,
+ 0x393f, 0x7364, 0x322d, 0x3b7e, 0x4b63, 0x736d, 0x7369, 0x395c,
+ 0x736e, 0x7365, 0x7366, 0x736a, 0x4261, 0x736c, 0x736f, 0x7368,
+ 0x3c7d, 0x4f64, 0x7370, 0x7367, 0x7372, 0x572d, 0x462a, 0x7373,
+ 0x7371, 0x4228, 0x385d, 0x7375, 0x7374, 0x345b, 0x7376, 0x7377,
+ 0x7378, 0x403a, 0x4069, 0x4571, 0x737b, 0x737a, 0x3458, 0x737e,
+ 0x7379, 0x737c, 0x737d, 0x7421, 0x7423, 0x3b49, 0x7422, 0x7424,
+ 0x323e, 0x7426, 0x7425, 0x3c2e, 0x4357, 0x5961, 0x4060, 0x744c,
+ 0x5751, 0x375b, 0x744e, 0x4123, 0x4649, 0x3456, 0x5533, 0x7450,
+ 0x744f, 0x7451, 0x4b5a, 0x7452, 0x5441, 0x5660, 0x3760, 0x4138,
+ 0x413b, 0x7453, 0x3e2c, 0x3462, 0x7454, 0x7455, 0x3e2b, 0x7456,
+ 0x745b, 0x7457, 0x745a, 0x3a7d, 0x7458, 0x7459, 0x3862, 0x4c47,
+ 0x745c, 0x325a, 0x4353, 0x5463, 0x3f37, 0x745d, 0x4534, 0x7469,
+ 0x4f35, 0x4e49, 0x4b58, 0x4b77, 0x3d74, 0x574f, 0x405b, 0x5075,
+ 0x746a, 0x746b, 0x746c, 0x7763, 0x3731, 0x746d, 0x576b, 0x746e,
+ 0x6679, 0x3e40, 0x667a, 0x3a6c, 0x667b, 0x4f4b, 0x667c, 0x543c,
+ 0x3c36, 0x667d, 0x667e, 0x3c4d, 0x4852, 0x4e33, 0x6721, 0x343f,
+ 0x6722, 0x4934, 0x3859, 0x4449, 0x575d, 0x425a, 0x3757, 0x563d,
+ 0x4e46, 0x3744, 0x4526, 0x6723, 0x4f5f, 0x6724, 0x6725, 0x6726,
+ 0x4137, 0x5769, 0x4970, 0x4f38, 0x562f, 0x5655, 0x6727, 0x306d,
+ 0x6728, 0x6729, 0x495c, 0x526f, 0x3e2d, 0x672a, 0x3073, 0x485e,
+ 0x3d61, 0x672b, 0x4846, 0x672c, 0x3b66, 0x3878, 0x5124, 0x672d,
+ 0x4267, 0x3e78, 0x3d4a, 0x4d33, 0x672e, 0x672f, 0x3e6e, 0x5065,
+ 0x4b67, 0x4c50, 0x3c4c, 0x6730, 0x3c28, 0x5077, 0x6731, 0x5078,
+ 0x6732, 0x6733, 0x3442, 0x6734, 0x6735, 0x497e, 0x4e2c, 0x4360,
+ 0x6737, 0x3141, 0x3371, 0x6738, 0x6739, 0x575b, 0x5540, 0x673a,
+ 0x424c, 0x573a, 0x673b, 0x673c, 0x673d, 0x3c6a, 0x4365, 0x4042,
+ 0x673e, 0x673f, 0x3c29, 0x6740, 0x6741, 0x6736, 0x3650, 0x6742,
+ 0x6743, 0x6744, 0x3b3a, 0x355e, 0x4246, 0x3160, 0x6745, 0x5435,
+ 0x6746, 0x383f, 0x6748, 0x6747, 0x376c, 0x6749, 0x3278, 0x674a,
+ 0x674b, 0x674c, 0x674d, 0x674e, 0x674f, 0x6750, 0x5327, 0x4b75,
+ 0x6751, 0x6752, 0x6753, 0x6754, 0x4949, 0x6755, 0x6756, 0x6757,
+ 0x6758, 0x6759, 0x3d49, 0x675a, 0x733e, 0x3857, 0x4831, 0x733f,
+ 0x7340, 0x7341, 0x395e, 0x4d78, 0x5868, 0x3a31, 0x425e, 0x6e37,
+ 0x3723, 0x6e39, 0x6e38, 0x3055, 0x6e3b, 0x5556, 0x576f, 0x5643,
+ 0x6e3d, 0x4a70, 0x6e3c, 0x6e3e, 0x6e40, 0x6e3f, 0x5172, 0x473c,
+ 0x4340, 0x3861, 0x4167, 0x7446, 0x505f, 0x7447, 0x4f5b, 0x483a,
+ 0x7448, 0x7449, 0x744a, 0x744b, 0x597a, 0x387e, 0x6571, 0x5370,
+ 0x7460, 0x4e4c, 0x3361, 0x7134, 0x526e, 0x7461, 0x4f68, 0x7462,
+ 0x474c, 0x3554, 0x3464, 0x7464, 0x7463, 0x7465, 0x7466, 0x7467,
+ 0x3a32, 0x303f, 0x7468, 0x372d, 0x526d, 0x522b, 0x404f, 0x3f3c,
+ 0x6b23, 0x555f, 0x6a48, 0x7173, 0x3678, 0x4b23, 0x444d, 0x7167,
+ 0x7168, 0x387b, 0x7169, 0x3a44, 0x5445, 0x3052, 0x716a, 0x716b,
+ 0x716c, 0x716d, 0x716e, 0x716f, 0x7171, 0x7170, 0x4555, 0x7172,
+ 0x367a, 0x7174, 0x522e, 0x5e47, 0x4b4a, 0x335c, 0x3522, 0x3922,
+ 0x4474, 0x7175, 0x7176, 0x4144, 0x417b, 0x5630, 0x7177, 0x7178,
+ 0x412a, 0x4638, 0x3e5b, 0x7179, 0x344f, 0x717a, 0x6d32, 0x6d31,
+ 0x4b60, 0x525e, 0x4b41, 0x5558, 0x4862, 0x405f, 0x3c21, 0x6b41,
+ 0x5024, 0x5662, 0x3647, 0x3858, 0x6b40, 0x384e, 0x6b3f, 0x3326,
+ 0x3949, 0x562b, 0x3774, 0x374a, 0x3c67, 0x373e, 0x6b46, 0x6b47,
+ 0x3039, 0x3f4f, 0x6b45, 0x537d, 0x6b48, 0x6b49, 0x374e, 0x6b42,
+ 0x6b44, 0x4976, 0x5657, 0x554d, 0x5032, 0x6b4f, 0x4e38, 0x6b50,
+ 0x3528, 0x3133, 0x6b52, 0x4c25, 0x4556, 0x6b53, 0x6b51, 0x455f,
+ 0x6b4e, 0x4a24, 0x6b55, 0x307b, 0x3a7a, 0x5837, 0x7163, 0x6b4a,
+ 0x6b4b, 0x6b4c, 0x6b4d, 0x6b56, 0x6640, 0x6b59, 0x3f68, 0x5248,
+ 0x6b57, 0x6b5c, 0x386c, 0x6b58, 0x3d3a, 0x5058, 0x3037, 0x6b5d,
+ 0x445c, 0x562c, 0x3460, 0x4276, 0x3c39, 0x6b5a, 0x6b5b, 0x5460,
+ 0x466a, 0x4454, 0x6b5f, 0x4527, 0x5975, 0x3231, 0x6b64, 0x3d45,
+ 0x6b62, 0x6b63, 0x382c, 0x4d51, 0x6b65, 0x6b61, 0x4133, 0x4622,
+ 0x4c73, 0x6b66, 0x4030, 0x5238, 0x6b67, 0x382f, 0x382d, 0x6b68,
+ 0x473b, 0x4d73, 0x6b6a, 0x6b6b, 0x6b6d, 0x5048, 0x6b72, 0x6b6e,
+ 0x6b71, 0x4879, 0x517c, 0x6b6c, 0x6b69, 0x3839, 0x4f59, 0x4465,
+ 0x6b6f, 0x6b70, 0x4c5a, 0x4d48, 0x3072, 0x6b76, 0x6b75, 0x3232,
+ 0x3860, 0x6b77, 0x316c, 0x4c45, 0x4424, 0x4f25, 0x6b79, 0x6c22,
+ 0x4572, 0x6b7a, 0x4945, 0x625f, 0x6b7e, 0x4d4e, 0x6c21, 0x315b,
+ 0x5337, 0x525c, 0x6b7d, 0x6b7b, 0x333c, 0x6a30, 0x5754, 0x742b,
+ 0x3374, 0x5641, 0x5642, 0x5569, 0x3e4a, 0x7427, 0x5228, 0x7428,
+ 0x7429, 0x742a, 0x3e4b, 0x535f, 0x4960, 0x4961, 0x7342, 0x4a66,
+ 0x4c72, 0x6236, 0x4b34, 0x4e68, 0x565b, 0x742d, 0x742e, 0x742f,
+ 0x7432, 0x3a3d, 0x7433, 0x3063, 0x7430, 0x7431, 0x3d22, 0x3255,
+ 0x7436, 0x7437, 0x3666, 0x3230, 0x4f4f, 0x7434, 0x342c, 0x7435,
+ 0x7438, 0x7439, 0x4d27, 0x743a, 0x743b, 0x743c, 0x4b52, 0x743d,
+ 0x743e, 0x743f, 0x745e, 0x413c, 0x3c68, 0x492b, 0x515e, 0x6575,
+ 0x5c33, 0x5255, 0x5c34, 0x302c, 0x5c35, 0x3d5a, 0x5c39, 0x5842,
+ 0x5c37, 0x5373, 0x4956, 0x5c3a, 0x5c36, 0x5c3b, 0x4322, 0x5c3c,
+ 0x5c45, 0x5c3d, 0x4e5f, 0x5625, 0x5c4f, 0x5c4d, 0x5c52, 0x3d66,
+ 0x422b, 0x5c38, 0x5c4b, 0x5c4e, 0x5c3e, 0x3752, 0x3045, 0x5c47,
+ 0x503e, 0x5c41, 0x3b28, 0x373c, 0x5c4c, 0x5c46, 0x5c3f, 0x475b,
+ 0x513f, 0x5c40, 0x5c4a, 0x5c50, 0x4e2d, 0x5c42, 0x5c43, 0x5c48,
+ 0x5c49, 0x3254, 0x5c51, 0x4b55, 0x5437, 0x5c5b, 0x5c5f, 0x4c26,
+ 0x5c66, 0x4367, 0x5c5c, 0x3f41, 0x5c59, 0x307a, 0x3936, 0x5c65,
+ 0x5c53, 0x5c44, 0x5c56, 0x4874, 0x3f60, 0x493b, 0x313d, 0x5322,
+ 0x5c5a, 0x5c55, 0x463b, 0x5c5e, 0x5742, 0x432f, 0x3736, 0x4751,
+ 0x4329, 0x5c62, 0x5c58, 0x5c6b, 0x5c54, 0x5c5d, 0x3e25, 0x5c57,
+ 0x5c60, 0x5c63, 0x5c64, 0x5c78, 0x5c61, 0x5d22, 0x5c67, 0x3c6b,
+ 0x3444, 0x4323, 0x3267, 0x5c7a, 0x5c72, 0x5c6f, 0x5c7c, 0x5c6e,
+ 0x5270, 0x3268, 0x4857, 0x4863, 0x5c7b, 0x5c6d, 0x5c77, 0x5c75,
+ 0x3e23, 0x5c74, 0x325d, 0x5c73, 0x3c76, 0x5c68, 0x3b44, 0x4073,
+ 0x3c54, 0x5c69, 0x5c6a, 0x5c71, 0x5c76, 0x5c79, 0x3534, 0x4859,
+ 0x3b67, 0x5c7e, 0x5c7d, 0x532b, 0x5d21, 0x5d23, 0x5d25, 0x5271,
+ 0x5d24, 0x5d26, 0x5d27, 0x5229, 0x3a49, 0x5d29, 0x5d36, 0x5d31,
+ 0x5d34, 0x5d30, 0x464e, 0x4072, 0x492f, 0x5c6c, 0x5d2e, 0x5d37,
+ 0x5c70, 0x5d2f, 0x5d38, 0x5d2c, 0x5d39, 0x5d33, 0x5d2d, 0x442a,
+ 0x5d28, 0x4033, 0x412b, 0x5d2a, 0x5d2b, 0x5d32, 0x3b71, 0x5d35,
+ 0x5328, 0x5d3a, 0x5d3b, 0x4327, 0x5d52, 0x5d3c, 0x5d51, 0x393d,
+ 0x3e55, 0x3e7a, 0x3a4a, 0x5d4a, 0x5d45, 0x5d3f, 0x324b, 0x5d43,
+ 0x5d4b, 0x3224, 0x5d55, 0x5d3e, 0x4650, 0x5d50, 0x5d54, 0x4162,
+ 0x3746, 0x5d4e, 0x5d4f, 0x5d44, 0x5d3d, 0x5d4d, 0x4c51, 0x5d49,
+ 0x5d42, 0x4348, 0x463c, 0x4e2e, 0x5d4c, 0x5d48, 0x5d41, 0x5d46,
+ 0x425c, 0x5329, 0x532a, 0x5d53, 0x4f74, 0x4878, 0x5d66, 0x5d47,
+ 0x5d60, 0x4264, 0x5d61, 0x5d57, 0x5678, 0x5d59, 0x5d58, 0x3870,
+ 0x5d56, 0x464f, 0x362d, 0x5d62, 0x3a79, 0x5461, 0x5d67, 0x3450,
+ 0x5d5a, 0x3f7b, 0x5d63, 0x5d5f, 0x5d5d, 0x3559, 0x5d5b, 0x5d5c,
+ 0x5d5e, 0x3d2f, 0x5d64, 0x5d65, 0x5d75, 0x4349, 0x4b62, 0x5d72,
+ 0x5861, 0x4651, 0x5d74, 0x5574, 0x5d73, 0x5d70, 0x5d6c, 0x5d6f,
+ 0x5d68, 0x506e, 0x4858, 0x5d6e, 0x5d69, 0x5d6a, 0x4b72, 0x5d6d,
+ 0x314d, 0x4036, 0x3c3b, 0x5d71, 0x5d77, 0x5d76, 0x5d6b, 0x456e,
+ 0x5d7b, 0x5e24, 0x5e23, 0x5d78, 0x436f, 0x427b, 0x5561, 0x4e35,
+ 0x5d7d, 0x324c, 0x4468, 0x4a5f, 0x473e, 0x5d7a, 0x5d7c, 0x5d7e,
+ 0x5e22, 0x302a, 0x314e, 0x5e2c, 0x5e26, 0x3d36, 0x486f, 0x5e21,
+ 0x5e25, 0x5e29, 0x5e28, 0x5e27, 0x5e2d, 0x544c, 0x5e33, 0x5e2a,
+ 0x5e2e, 0x4059, 0x3121, 0x5e36, 0x5e31, 0x5e32, 0x5126, 0x5e35,
+ 0x5e2f, 0x5e30, 0x503d, 0x5e34, 0x4a6d, 0x5e39, 0x5e38, 0x5e37,
+ 0x5e3b, 0x3d65, 0x3258, 0x436a, 0x5e3a, 0x453a, 0x5e3c, 0x4c59,
+ 0x372a, 0x5465, 0x5e3d, 0x5e3f, 0x4422, 0x5e41, 0x5e3e, 0x5e40,
+ 0x553a, 0x5e42, 0x722e, 0x3b22, 0x4232, 0x4530, 0x4247, 0x722f,
+ 0x5069, 0x535d, 0x6b3d, 0x3366, 0x7230, 0x7231, 0x4a2d, 0x3a67,
+ 0x7233, 0x7235, 0x7234, 0x4b64, 0x4f3a, 0x7232, 0x4a34, 0x524f,
+ 0x426c, 0x4e43, 0x7238, 0x3076, 0x7237, 0x723e, 0x324f, 0x5141,
+ 0x723a, 0x723c, 0x5469, 0x723b, 0x7236, 0x723f, 0x723d, 0x7239,
+ 0x7247, 0x7244, 0x7246, 0x724a, 0x7242, 0x7240, 0x7245, 0x567b,
+ 0x7241, 0x4779, 0x495f, 0x7248, 0x3946, 0x3530, 0x7243, 0x7249,
+ 0x7250, 0x7256, 0x3b57, 0x7255, 0x4d5c, 0x566b, 0x7252, 0x7254,
+ 0x3872, 0x724b, 0x724e, 0x4279, 0x555d, 0x724c, 0x724d, 0x724f,
+ 0x7253, 0x7259, 0x533c, 0x366a, 0x4a71, 0x3764, 0x7257, 0x7258,
+ 0x725a, 0x725d, 0x725b, 0x725c, 0x5151, 0x7251, 0x4d49, 0x4e4f,
+ 0x5629, 0x7263, 0x435b, 0x7260, 0x402f, 0x726c, 0x725e, 0x7261,
+ 0x7268, 0x7262, 0x7267, 0x7266, 0x7269, 0x725f, 0x7264, 0x726a,
+ 0x532c, 0x7265, 0x3275, 0x7272, 0x502b, 0x7275, 0x3b48, 0x7279,
+ 0x7270, 0x7276, 0x7278, 0x727a, 0x7273, 0x7271, 0x3a7b, 0x357b,
+ 0x726f, 0x7277, 0x726d, 0x726e, 0x726b, 0x7326, 0x7323, 0x7322,
+ 0x7274, 0x485a, 0x727b, 0x7325, 0x4378, 0x727d, 0x7327, 0x7329,
+ 0x7324, 0x727c, 0x732b, 0x732a, 0x425d, 0x732e, 0x7330, 0x7321,
+ 0x7331, 0x732c, 0x732f, 0x727e, 0x732d, 0x7332, 0x7334, 0x7328,
+ 0x7333, 0x7335, 0x5037, 0x7338, 0x5979, 0x7339, 0x7337, 0x4864,
+ 0x7336, 0x733a, 0x733b, 0x3440, 0x6e43, 0x733c, 0x733d, 0x512a,
+ 0x742c, 0x5046, 0x5050, 0x515c, 0x4f4e, 0x3d56, 0x5143, 0x3a62,
+ 0x6169, 0x5242, 0x7142, 0x3239, 0x316d, 0x7143, 0x4940, 0x3344,
+ 0x5972, 0x4b25, 0x7144, 0x5654, 0x7145, 0x7440, 0x7146, 0x542c,
+ 0x7147, 0x3040, 0x7441, 0x7442, 0x347c, 0x455b, 0x4c3b, 0x5064,
+ 0x4d60, 0x7148, 0x5973, 0x313b, 0x4f2e, 0x3824, 0x714a, 0x714b,
+ 0x3243, 0x4151, 0x5730, 0x7149, 0x714c, 0x714e, 0x5976, 0x5261,
+ 0x5423, 0x7443, 0x4839, 0x7444, 0x714d, 0x714f, 0x3f63, 0x7150,
+ 0x7154, 0x7156, 0x7151, 0x4951, 0x4561, 0x4263, 0x397c, 0x7153,
+ 0x7155, 0x3953, 0x715b, 0x3a56, 0x307d, 0x7159, 0x7158, 0x7152,
+ 0x715a, 0x7157, 0x486c, 0x4d4a, 0x715d, 0x653d, 0x715c, 0x715e,
+ 0x715f, 0x4f65, 0x7445, 0x3d73, 0x7160, 0x7161, 0x4e77, 0x522a,
+ 0x717b, 0x3832, 0x3c7b, 0x395b, 0x3966, 0x4359, 0x4a53, 0x6a68,
+ 0x4040, 0x3e75, 0x6a69, 0x6a6a, 0x6a6b, 0x6a6c, 0x6a6d, 0x6a6e,
+ 0x6a6f, 0x3d47, 0x757b, 0x757d, 0x757e, 0x757c, 0x3d62, 0x7621,
+ 0x3425, 0x7622, 0x7623, 0x6c32, 0x5154, 0x596a, 0x7624, 0x6e3a,
+ 0x5532, 0x537e, 0x4c5c, 0x4a44, 0x6540, 0x7625, 0x3e2f, 0x4629,
+ 0x5a25, 0x3c46, 0x3629, 0x383c, 0x484f, 0x3c25, 0x5a26, 0x5a27,
+ 0x4c56, 0x4843, 0x5a28, 0x467d, 0x5135, 0x5269, 0x5136, 0x3c47,
+ 0x3d32, 0x3b64, 0x5a29, 0x5a2a, 0x5148, 0x5a2b, 0x506d, 0x366f,
+ 0x425b, 0x4b4f, 0x376d, 0x4968, 0x3743, 0x3e77, 0x5624, 0x5a2c,
+ 0x5a2d, 0x4640, 0x5767, 0x4a36, 0x5529, 0x4b5f, 0x556f, 0x5a2e,
+ 0x565f, 0x344a, 0x5a30, 0x5a2f, 0x526b, 0x5a31, 0x5a32, 0x5a33,
+ 0x4a54, 0x5a34, 0x4a2b, 0x5a35, 0x5a36, 0x334f, 0x566f, 0x5a37,
+ 0x3b30, 0x352e, 0x5a38, 0x5a39, 0x396e, 0x512f, 0x5268, 0x5a3a,
+ 0x3843, 0x4f6a, 0x326f, 0x5a3b, 0x5a3c, 0x3d6b, 0x4e5c, 0x536f,
+ 0x5a3d, 0x4e73, 0x5a3e, 0x5355, 0x3b65, 0x5a3f, 0x4b35, 0x4b50,
+ 0x5a40, 0x476b, 0x566e, 0x5a41, 0x4535, 0x3641, 0x5a42, 0x374c,
+ 0x3f4e, 0x5a43, 0x5a44, 0x4b2d, 0x5a45, 0x3577, 0x5a46, 0x4142,
+ 0x573b, 0x5a47, 0x4c38, 0x526a, 0x4431, 0x5a48, 0x357d, 0x3b51,
+ 0x5a49, 0x5033, 0x5a4a, 0x5a4b, 0x4e3d, 0x5a4c, 0x5a4d, 0x5a4e,
+ 0x3277, 0x5a51, 0x5a4f, 0x5168, 0x5a50, 0x4355, 0x5a52, 0x5a53,
+ 0x5a54, 0x5a55, 0x503b, 0x5225, 0x3079, 0x5a56, 0x472b, 0x5a57,
+ 0x3d77, 0x4321, 0x5a58, 0x5a59, 0x437d, 0x4c37, 0x5a5a, 0x5a5b,
+ 0x403e, 0x4657, 0x5a5c, 0x5a5d, 0x4734, 0x5a5e, 0x5a5f, 0x3948,
+ 0x3b6d, 0x3639, 0x7478, 0x7479, 0x4d63, 0x7539, 0x6b60, 0x4f73,
+ 0x3b3f, 0x3a40, 0x5425, 0x6159, 0x7574, 0x312a, 0x3272, 0x7575,
+ 0x7577, 0x3a51, 0x7576, 0x4332, 0x7579, 0x7578, 0x3134, 0x556a,
+ 0x383a, 0x3931, 0x3246, 0x5470, 0x4f4d, 0x305c, 0x554b, 0x3b75,
+ 0x564a, 0x3737, 0x4c30, 0x4636, 0x3161, 0x393a, 0x567c, 0x3961,
+ 0x3721, 0x3c7a, 0x6a5a, 0x6a5b, 0x4c79, 0x3973, 0x6a5c, 0x347b,
+ 0x4333, 0x3751, 0x3a58, 0x6a5d, 0x5474, 0x6a5e, 0x3c56, 0x3b5f,
+ 0x6a5f, 0x415e, 0x4238, 0x545f, 0x574a, 0x6a60, 0x6a61, 0x6a64,
+ 0x6a62, 0x6a63, 0x495e, 0x3833, 0x3644, 0x6a65, 0x4a6a, 0x494d,
+ 0x344d, 0x6259, 0x4562, 0x6a66, 0x4035, 0x5738, 0x6a67, 0x572c,
+ 0x487c, 0x5853, 0x584d, 0x545e, 0x5479, 0x4944, 0x532e, 0x3853,
+ 0x3360, 0x4962, 0x7476, 0x3a55, 0x7477, 0x575f, 0x7471, 0x3830,
+ 0x5554, 0x384f, 0x4670, 0x3343, 0x7472, 0x332c, 0x543d, 0x4777,
+ 0x7474, 0x7473, 0x4c4b, 0x4824, 0x7475, 0x5763, 0x453f, 0x7540,
+ 0x753b, 0x7543, 0x7542, 0x563a, 0x7541, 0x543e, 0x7544, 0x754c,
+ 0x304f, 0x3578, 0x7549, 0x754a, 0x455c, 0x7545, 0x7546, 0x7547,
+ 0x754b, 0x3e60, 0x7548, 0x387a, 0x7550, 0x7553, 0x3f67, 0x3972,
+ 0x753c, 0x754d, 0x4237, 0x4c78, 0x3c79, 0x754e, 0x754f, 0x7551,
+ 0x3665, 0x7552, 0x7555, 0x753d, 0x7554, 0x533b, 0x336c, 0x4c24,
+ 0x7556, 0x7557, 0x3e61, 0x7558, 0x4c5f, 0x755b, 0x3248, 0x5759,
+ 0x7559, 0x755a, 0x755c, 0x7562, 0x7560, 0x755f, 0x755d, 0x7561,
+ 0x755e, 0x7564, 0x7565, 0x4c63, 0x653f, 0x3538, 0x7563, 0x7568,
+ 0x4c23, 0x7566, 0x7567, 0x753e, 0x3144, 0x753f, 0x3545, 0x3264,
+ 0x756c, 0x7569, 0x3657, 0x756d, 0x756a, 0x756b, 0x345a, 0x546a,
+ 0x756e, 0x3379, 0x756f, 0x7571, 0x7570, 0x7572, 0x7573, 0x496d,
+ 0x392a, 0x477b, 0x3663, 0x4c49, 0x6a26, 0x3335, 0x547e, 0x396c,
+ 0x5079, 0x696d, 0x572a, 0x696e, 0x4256, 0x486d, 0x3a64, 0x696f,
+ 0x6970, 0x6971, 0x5661, 0x6972, 0x6973, 0x6975, 0x6974, 0x6976,
+ 0x6977, 0x4761, 0x6978, 0x5458, 0x6979, 0x3d4e, 0x697a, 0x697b,
+ 0x3d4f, 0x697c, 0x3828, 0x413e, 0x697d, 0x3132, 0x3b54, 0x3975,
+ 0x697e, 0x6a21, 0x6a22, 0x6a23, 0x3778, 0x3c2d, 0x4a64, 0x604e,
+ 0x542f, 0x4f3d, 0x5537, 0x6a24, 0x555e, 0x6a25, 0x5041, 0x393c,
+ 0x3447, 0x3159, 0x4031, 0x3166, 0x3167, 0x3168, 0x333d, 0x4868,
+ 0x6541, 0x315f, 0x4149, 0x346f, 0x4728, 0x5358, 0x4679, 0x5138,
+ 0x397d, 0x4275, 0x532d, 0x544b, 0x3d7c, 0x6542, 0x3735, 0x6543,
+ 0x3b39, 0x5562, 0x3d78, 0x5436, 0x4e25, 0x412c, 0x3359, 0x4c76,
+ 0x6546, 0x6544, 0x6548, 0x654a, 0x6547, 0x354f, 0x4648, 0x357c,
+ 0x6545, 0x4a76, 0x6549, 0x4354, 0x3145, 0x3c23, 0x5737, 0x4d4b,
+ 0x4b4d, 0x4a4a, 0x4c53, 0x654c, 0x654b, 0x4466, 0x5121, 0x5137,
+ 0x654d, 0x6550, 0x4d38, 0x5670, 0x654f, 0x355d, 0x4d3e, 0x6551,
+ 0x363a, 0x4d28, 0x3964, 0x4a45, 0x3351, 0x4b59, 0x546c, 0x6552,
+ 0x376a, 0x654e, 0x6555, 0x347e, 0x6556, 0x6553, 0x6554, 0x525d,
+ 0x425f, 0x3146, 0x5362, 0x365d, 0x4b6c, 0x6557, 0x5376, 0x3169,
+ 0x3674, 0x655a, 0x6558, 0x6559, 0x3540, 0x5245, 0x655c, 0x655e,
+ 0x655d, 0x4732, 0x5223, 0x655b, 0x5462, 0x555a, 0x6560, 0x5771,
+ 0x6561, 0x315c, 0x517b, 0x6562, 0x6564, 0x6563, 0x6565, 0x5258,
+ 0x354b, 0x675f, 0x5a75, 0x5a78, 0x5a76, 0x5a77, 0x5a7a, 0x504f,
+ 0x4447, 0x306e, 0x5030, 0x5a79, 0x534a, 0x3a2a, 0x5b22, 0x4771,
+ 0x5a7c, 0x5a7b, 0x495b, 0x5a7d, 0x5b21, 0x575e, 0x5a7e, 0x415a,
+ 0x5b25, 0x5374, 0x5b27, 0x5b24, 0x5b28, 0x3d3c, 0x4049, 0x5b23,
+ 0x5b26, 0x5623, 0x5b29, 0x5b2d, 0x5b2e, 0x5b2c, 0x3a42, 0x3f24,
+ 0x5b2b, 0x5b2a, 0x5447, 0x323f, 0x5b2f, 0x3979, 0x5b30, 0x333b,
+ 0x3526, 0x363c, 0x5b31, 0x3675, 0x5b32, 0x3149, 0x5b34, 0x5b33,
+ 0x5b35, 0x5b37, 0x5b36, 0x5b38, 0x5b39, 0x5b3a, 0x534f, 0x747a,
+ 0x4775, 0x5743, 0x4564, 0x747c, 0x747d, 0x747b, 0x3e46, 0x506f,
+ 0x3753, 0x544d, 0x4c2a, 0x7522, 0x7521, 0x3a28, 0x747e, 0x4b56,
+ 0x7524, 0x4052, 0x336a, 0x4d2a, 0x7525, 0x7523, 0x3d34, 0x7528,
+ 0x7529, 0x3d4d, 0x4338, 0x3f61, 0x4b61, 0x752a, 0x7526, 0x7527,
+ 0x4470, 0x752c, 0x343c, 0x576d, 0x3457, 0x752b, 0x752e, 0x752d,
+ 0x752f, 0x5051, 0x4351, 0x4829, 0x7530, 0x7531, 0x7532, 0x7533,
+ 0x7534, 0x7535, 0x7537, 0x7536, 0x7538, 0x3249, 0x5354, 0x4a4d,
+ 0x406f, 0x5658, 0x5230, 0x413f, 0x3d70, 0x382a, 0x3c78, 0x7646,
+ 0x7647, 0x7648, 0x7649, 0x764a, 0x764c, 0x764b, 0x7769, 0x764d,
+ 0x764e, 0x6e44, 0x6e45, 0x6e46, 0x556b, 0x3624, 0x6e48, 0x6e47,
+ 0x6e49, 0x6e4a, 0x4725, 0x6e4b, 0x6e4c, 0x3730, 0x3576, 0x6e4d,
+ 0x6e4f, 0x6e4e, 0x3846, 0x6e50, 0x6e51, 0x6e52, 0x365b, 0x332e,
+ 0x5653, 0x4446, 0x3135, 0x3856, 0x6e53, 0x6e54, 0x543f, 0x4755,
+ 0x3e7b, 0x4e59, 0x3933, 0x6e56, 0x6e55, 0x6e58, 0x6e57, 0x4525,
+ 0x6e59, 0x6e5a, 0x472e, 0x6e5b, 0x472f, 0x6e5c, 0x3227, 0x6e5d,
+ 0x6e5e, 0x6e5f, 0x6e60, 0x6e61, 0x576a, 0x6e62, 0x6e63, 0x3c58,
+ 0x6e64, 0x534b, 0x4c7a, 0x322c, 0x4165, 0x6e65, 0x4726, 0x432d,
+ 0x6e66, 0x6e67, 0x6e68, 0x6e69, 0x6e6a, 0x6e6b, 0x6e6c, 0x6e6d,
+ 0x6e6e, 0x6e6f, 0x6e70, 0x6e71, 0x6e72, 0x6e74, 0x6e73, 0x6e75,
+ 0x4d2d, 0x4241, 0x6e76, 0x6e77, 0x6e78, 0x5521, 0x6e79, 0x4f33,
+ 0x6e7a, 0x6e7b, 0x6e7c, 0x6e7d, 0x6f21, 0x6e7e, 0x6f22, 0x3875,
+ 0x437a, 0x6f23, 0x6f24, 0x3d42, 0x523f, 0x3279, 0x6f25, 0x6f26,
+ 0x6f27, 0x5278, 0x6f28, 0x567d, 0x6f29, 0x464c, 0x6f2a, 0x6f2b,
+ 0x4134, 0x6f2c, 0x4f7a, 0x4b78, 0x6f2e, 0x6f2d, 0x337a, 0x3978,
+ 0x6f2f, 0x6f30, 0x5062, 0x6f31, 0x6f32, 0x3766, 0x503f, 0x6f33,
+ 0x6f34, 0x6f35, 0x4871, 0x4c60, 0x6f36, 0x6f37, 0x6f38, 0x6f39,
+ 0x6f3a, 0x5560, 0x6f3b, 0x346d, 0x432a, 0x6f3c, 0x6f3d, 0x6f3e,
+ 0x6f3f, 0x4e7d, 0x6f40, 0x4260, 0x3438, 0x5736, 0x3d75, 0x4f47,
+ 0x6f43, 0x6f41, 0x6f42, 0x6f44, 0x3627, 0x3c7c, 0x3e62, 0x434c,
+ 0x6f45, 0x6f46, 0x6f47, 0x6f4f, 0x6f48, 0x6f49, 0x6f4a, 0x4742,
+ 0x6f71, 0x364d, 0x6f4b, 0x6f4c, 0x6f4d, 0x3646, 0x433e, 0x6f4e,
+ 0x6f50, 0x6f51, 0x6f52, 0x5572, 0x6f53, 0x4477, 0x6f54, 0x4478,
+ 0x6f55, 0x6f56, 0x3864, 0x3077, 0x6f57, 0x6f58, 0x6f59, 0x6f5a,
+ 0x6f5b, 0x6f5c, 0x6f5d, 0x6f5e, 0x3e35, 0x6f61, 0x6f5f, 0x6f60,
+ 0x6f62, 0x6f63, 0x414d, 0x6f64, 0x6f65, 0x6f66, 0x6f67, 0x6f68,
+ 0x6f69, 0x6f6a, 0x6f6b, 0x6f6c, 0x4058, 0x6f6d, 0x412d, 0x6f6e,
+ 0x6f6f, 0x6f70, 0x4f62, 0x3324, 0x4345, 0x6345, 0x4941, 0x6346,
+ 0x3155, 0x4e4a, 0x3433, 0x4872, 0x6347, 0x4f50, 0x6348, 0x3c64,
+ 0x6349, 0x634a, 0x4346, 0x5522, 0x4456, 0x396b, 0x4e45, 0x634b,
+ 0x4376, 0x634c, 0x3727, 0x3873, 0x3a52, 0x634d, 0x634e, 0x5444,
+ 0x634f, 0x6350, 0x514b, 0x6351, 0x6352, 0x6353, 0x6354, 0x5156,
+ 0x6355, 0x327b, 0x403b, 0x6356, 0x402b, 0x6357, 0x6358, 0x6359,
+ 0x635a, 0x635b, 0x3837, 0x5a62, 0x3653, 0x5a64, 0x5a63, 0x5a66,
+ 0x486e, 0x5a65, 0x3740, 0x5174, 0x5275, 0x5573, 0x3d57, 0x5768,
+ 0x5a68, 0x5a67, 0x3022, 0x4d53, 0x5a69, 0x383d, 0x3c4a, 0x423d,
+ 0x4224, 0x3342, 0x5a6a, 0x422a, 0x4430, 0x3d35, 0x4f5e, 0x5a6b,
+ 0x4942, 0x315d, 0x5a6c, 0x3638, 0x543a, 0x337d, 0x5a6d, 0x5449,
+ 0x4f55, 0x4563, 0x5a6e, 0x5a6f, 0x5a70, 0x416a, 0x4c55, 0x4f5d,
+ 0x5367, 0x4221, 0x5a71, 0x4b65, 0x5a72, 0x4b66, 0x527e, 0x3874,
+ 0x5a73, 0x302f, 0x4f36, 0x554f, 0x4b6d, 0x5a74, 0x6344, 0x4125,
+ 0x763f, 0x7640, 0x7641, 0x4451, 0x4838, 0x5163, 0x505b, 0x5145,
+ 0x3c2f, 0x394d, 0x6f74, 0x3446, 0x533a, 0x7642, 0x337b, 0x7643,
+ 0x3571, 0x7645, 0x536a, 0x7627, 0x5129, 0x7629, 0x7628, 0x4163,
+ 0x4057, 0x3122, 0x4e6d, 0x5068, 0x762b, 0x4f76, 0x762a, 0x5570,
+ 0x762c, 0x4339, 0x3b74, 0x762e, 0x762d, 0x445e, 0x4158, 0x4b2a,
+ 0x4f3c, 0x762f, 0x7630, 0x7631, 0x4236, 0x3054, 0x4579, 0x7632,
+ 0x4760, 0x7626, 0x3e38, 0x3e32, 0x3565, 0x3747, 0x3f3f, 0x4352,
+ 0x4366, 0x584c, 0x386f, 0x3d79, 0x5125, 0x3050, 0x7730, 0x7731,
+ 0x502c, 0x3030, 0x7732, 0x7733, 0x7734, 0x474a, 0x3e4f, 0x7737,
+ 0x7736, 0x315e, 0x7735, 0x7738, 0x7739, 0x4e24, 0x484d, 0x3a2b,
+ 0x6838, 0x6839, 0x683a, 0x3e42, 0x5274, 0x544f, 0x4958, 0x5233,
+ 0x3625, 0x476a, 0x717c, 0x4f6e, 0x4b33, 0x506b, 0x676f, 0x4d67,
+ 0x394b, 0x3659, 0x717d, 0x3064, 0x4b4c, 0x717e, 0x5424, 0x422d,
+ 0x416c, 0x4644, 0x3e31, 0x7221, 0x3c55, 0x7222, 0x7223, 0x7224,
+ 0x5243, 0x4635, 0x4d47, 0x7225, 0x5331, 0x3f45, 0x4c62, 0x7226,
+ 0x7227, 0x5155, 0x366e, 0x7228, 0x7229, 0x355f, 0x722a, 0x722b,
+ 0x327c, 0x722c, 0x722d, 0x4827, 0x3767, 0x6c29, 0x6c2a, 0x6c2b,
+ 0x6c2c, 0x462e, 0x6c2d, 0x6c2e, 0x3749, 0x4a33, 0x6238, 0x774f,
+ 0x7750, 0x324d, 0x7751, 0x7753, 0x7752, 0x623b, 0x3c22, 0x623c,
+ 0x623d, 0x623e, 0x623f, 0x6240, 0x6241, 0x3739, 0x527b, 0x3d24,
+ 0x4a4e, 0x3125, 0x4b47, 0x6242, 0x367c, 0x4844, 0x6243, 0x3d48,
+ 0x317d, 0x6244, 0x3676, 0x6245, 0x4459, 0x6246, 0x4f5a, 0x395d,
+ 0x6247, 0x4021, 0x6248, 0x3276, 0x6249, 0x4173, 0x624a, 0x624b,
+ 0x4278, 0x624c, 0x624d, 0x624e, 0x4a57, 0x5838, 0x5965, 0x4f63,
+ 0x7025, 0x5c30, 0x426d, 0x5426, 0x4d54, 0x5131, 0x335b, 0x477d,
+ 0x3235, 0x423f, 0x6660, 0x4a3b, 0x6661, 0x6662, 0x3e54, 0x6663,
+ 0x5724, 0x4d55, 0x6665, 0x3c5d, 0x6664, 0x6666, 0x6667, 0x426e,
+ 0x3d3e, 0x6668, 0x4266, 0x3a27, 0x6669, 0x666a, 0x3352, 0x5169,
+ 0x3f25, 0x666b, 0x466f, 0x666c, 0x666d, 0x666e, 0x462d, 0x666f,
+ 0x4927, 0x6670, 0x6671, 0x6672, 0x6539, 0x6673, 0x6674, 0x4262,
+ 0x6675, 0x6676, 0x5668, 0x6677, 0x6678, 0x3947, 0x773b, 0x773a,
+ 0x773e, 0x773c, 0x3a21, 0x773f, 0x7740, 0x7742, 0x7741, 0x7744,
+ 0x7743, 0x7745, 0x7746, 0x7747, 0x4b68, 0x385f, 0x7754, 0x7755,
+ 0x7756, 0x7758, 0x775a, 0x7757, 0x775b, 0x7759, 0x5757, 0x775c,
+ 0x775d, 0x775e, 0x775f, 0x7760, 0x5b4b, 0x582a, 0x6577, 0x396d,
+ 0x3f7d, 0x3b6a, 0x7749, 0x4647, 0x7748, 0x774a, 0x774c, 0x774b,
+ 0x774d, 0x4e3a, 0x774e, 0x4427, 0x5363, 0x764f, 0x4233, 0x7650,
+ 0x7651, 0x7652, 0x7653, 0x7654, 0x7656, 0x312b, 0x7657, 0x7658,
+ 0x7659, 0x765a, 0x765b, 0x765c, 0x765d, 0x765e, 0x4f4a, 0x765f,
+ 0x7660, 0x7661, 0x7662, 0x7663, 0x7664, 0x4070, 0x7665, 0x7666,
+ 0x7667, 0x7668, 0x7669, 0x766a, 0x766b, 0x766c, 0x766d, 0x766e,
+ 0x766f, 0x7670, 0x7671, 0x7672, 0x7673, 0x7674, 0x3e28, 0x7675,
+ 0x7676, 0x7677, 0x7678, 0x487a, 0x7679, 0x767a, 0x767b, 0x767c,
+ 0x767d, 0x767e, 0x7721, 0x7722, 0x7723, 0x7724, 0x7725, 0x7726,
+ 0x7727, 0x7728, 0x316e, 0x7729, 0x772a, 0x772b, 0x772c, 0x772d,
+ 0x415b, 0x772e, 0x772f, 0x4471, 0x702f, 0x3c26, 0x7030, 0x4379,
+ 0x4538, 0x513b, 0x7031, 0x7032, 0x7033, 0x7034, 0x7035, 0x513c,
+ 0x516c, 0x7037, 0x7036, 0x5427, 0x4d52, 0x7038, 0x703a, 0x7039,
+ 0x703b, 0x703c, 0x386b, 0x703d, 0x3a68, 0x703e, 0x703f, 0x3e69,
+ 0x7040, 0x366c, 0x7041, 0x7042, 0x7043, 0x7044, 0x4835, 0x7045,
+ 0x7046, 0x7047, 0x4574, 0x7048, 0x7049, 0x704a, 0x773d, 0x704b,
+ 0x704c, 0x704d, 0x704e, 0x704f, 0x3a57, 0x7050, 0x7051, 0x7052,
+ 0x7053, 0x7054, 0x7055, 0x7056, 0x7058, 0x5325, 0x7057, 0x7059,
+ 0x753a, 0x4239, 0x7764, 0x7765, 0x7766, 0x7767, 0x7768, 0x4234,
+ 0x776a, 0x776b, 0x4273, 0x7470, 0x746f, 0x4269, 0x7761, 0x7762,
+ 0x3b46, 0x5964, 0x4a72, 0x4068, 0x7024, 0x3a5a, 0x472d, 0x442c,
+ 0x776c, 0x776d, 0x776e, 0x7770, 0x776f, 0x7771, 0x7774, 0x7773,
+ 0x7772, 0x7775, 0x7776, 0x6d69, 0x6d6a, 0x6d6b, 0x763c, 0x763d,
+ 0x763e, 0x3626, 0x583e, 0x3944, 0x583b, 0x5c31, 0x4a73, 0x7777,
+ 0x7778, 0x7779, 0x777b, 0x777a, 0x3147, 0x777c, 0x777d, 0x777e,
+ 0x466b, 0x6c34, 0x335d, 0x7633, 0x7634, 0x4164, 0x7635, 0x7636,
+ 0x7637, 0x7638, 0x7639, 0x763a, 0x4823, 0x763b, 0x417a, 0x3928,
+ 0x6d68, 0x396a, 0x595f, 0x2321, 0x2322, 0x2323, 0x2167, 0x2325,
+ 0x2326, 0x2327, 0x2328, 0x2329, 0x232a, 0x232b, 0x232c, 0x232d,
+ 0x232e, 0x232f, 0x2330, 0x2331, 0x2332, 0x2333, 0x2334, 0x2335,
+ 0x2336, 0x2337, 0x2338, 0x2339, 0x233a, 0x233b, 0x233c, 0x233d,
+ 0x233e, 0x233f, 0x2340, 0x2341, 0x2342, 0x2343, 0x2344, 0x2345,
+ 0x2346, 0x2347, 0x2348, 0x2349, 0x234a, 0x234b, 0x234c, 0x234d,
+ 0x234e, 0x234f, 0x2350, 0x2351, 0x2352, 0x2353, 0x2354, 0x2355,
+ 0x2356, 0x2357, 0x2358, 0x2359, 0x235a, 0x235b, 0x235c, 0x235d,
+ 0x235e, 0x235f, 0x2360, 0x2361, 0x2362, 0x2363, 0x2364, 0x2365,
+ 0x2366, 0x2367, 0x2368, 0x2369, 0x236a, 0x236b, 0x236c, 0x236d,
+ 0x236e, 0x236f, 0x2370, 0x2371, 0x2372, 0x2373, 0x2374, 0x2375,
+ 0x2376, 0x2377, 0x2378, 0x2379, 0x237a, 0x237b, 0x237c, 0x237d,
+ 0x212b, 0x2169, 0x216a, 0x237e, 0x2324,
+};
+
+static const Summary16 gb2312_uni2indx_page00[70] = {
+ /* 0x0000 */
+ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
+ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
+ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0190 }, { 3, 0x0003 },
+ { 5, 0x0000 }, { 5, 0x0080 }, { 6, 0x3703 }, { 13, 0x168c },
+ /* 0x0100 */
+ { 19, 0x0002 }, { 20, 0x0808 }, { 22, 0x0800 }, { 23, 0x0000 },
+ { 23, 0x2000 }, { 24, 0x0000 }, { 24, 0x0800 }, { 25, 0x0000 },
+ { 25, 0x0000 }, { 25, 0x0000 }, { 25, 0x0000 }, { 25, 0x0000 },
+ { 25, 0x4000 }, { 26, 0x1555 }, { 33, 0x0000 }, { 33, 0x0000 },
+ /* 0x0200 */
+ { 33, 0x0000 }, { 33, 0x0000 }, { 33, 0x0000 }, { 33, 0x0000 },
+ { 33, 0x0000 }, { 33, 0x0000 }, { 33, 0x0000 }, { 33, 0x0000 },
+ { 33, 0x0000 }, { 33, 0x0000 }, { 33, 0x0000 }, { 33, 0x0000 },
+ { 33, 0x0280 }, { 35, 0x0000 }, { 35, 0x0000 }, { 35, 0x0000 },
+ /* 0x0300 */
+ { 35, 0x0000 }, { 35, 0x0000 }, { 35, 0x0000 }, { 35, 0x0000 },
+ { 35, 0x0000 }, { 35, 0x0000 }, { 35, 0x0000 }, { 35, 0x0000 },
+ { 35, 0x0000 }, { 35, 0xfffe }, { 50, 0x03fb }, { 59, 0xfffe },
+ { 74, 0x03fb }, { 83, 0x0000 }, { 83, 0x0000 }, { 83, 0x0000 },
+ /* 0x0400 */
+ { 83, 0x0002 }, { 84, 0xffff }, { 100, 0xffff }, { 116, 0xffff },
+ { 132, 0xffff }, { 148, 0x0002 },
+};
+static const Summary16 gb2312_uni2indx_page20[101] = {
+ /* 0x2000 */
+ { 149, 0x0000 }, { 149, 0x3360 }, { 155, 0x0040 }, { 156, 0x080d },
+ { 160, 0x0000 }, { 160, 0x0000 }, { 160, 0x0000 }, { 160, 0x0000 },
+ { 160, 0x0000 }, { 160, 0x0000 }, { 160, 0x0000 }, { 160, 0x0000 },
+ { 160, 0x0000 }, { 160, 0x0000 }, { 160, 0x0000 }, { 160, 0x0000 },
+ /* 0x2100 */
+ { 160, 0x0008 }, { 161, 0x0040 }, { 162, 0x0000 }, { 162, 0x0000 },
+ { 162, 0x0000 }, { 162, 0x0000 }, { 162, 0x0fff }, { 174, 0x0000 },
+ { 174, 0x0000 }, { 174, 0x000f }, { 178, 0x0000 }, { 178, 0x0000 },
+ { 178, 0x0000 }, { 178, 0x0000 }, { 178, 0x0000 }, { 178, 0x0000 },
+ /* 0x2200 */
+ { 178, 0x8100 }, { 180, 0x6402 }, { 184, 0x4fa1 }, { 192, 0x20f0 },
+ { 197, 0x1100 }, { 199, 0x0000 }, { 199, 0xc033 }, { 205, 0x0000 },
+ { 205, 0x0000 }, { 205, 0x0200 }, { 206, 0x0020 }, { 207, 0x0000 },
+ { 207, 0x0000 }, { 207, 0x0000 }, { 207, 0x0000 }, { 207, 0x0000 },
+ /* 0x2300 */
+ { 207, 0x0000 }, { 207, 0x0004 }, { 208, 0x0000 }, { 208, 0x0000 },
+ { 208, 0x0000 }, { 208, 0x0000 }, { 208, 0x0000 }, { 208, 0x0000 },
+ { 208, 0x0000 }, { 208, 0x0000 }, { 208, 0x0000 }, { 208, 0x0000 },
+ { 208, 0x0000 }, { 208, 0x0000 }, { 208, 0x0000 }, { 208, 0x0000 },
+ /* 0x2400 */
+ { 208, 0x0000 }, { 208, 0x0000 }, { 208, 0x0000 }, { 208, 0x0000 },
+ { 208, 0x0000 }, { 208, 0x0000 }, { 208, 0x03ff }, { 218, 0xfff0 },
+ { 230, 0xffff }, { 246, 0x0fff }, { 258, 0x0000 }, { 258, 0x0000 },
+ { 258, 0x0000 }, { 258, 0x0000 }, { 258, 0x0000 }, { 258, 0x0000 },
+ /* 0x2500 */
+ { 258, 0xffff }, { 274, 0xffff }, { 290, 0xffff }, { 306, 0xffff },
+ { 322, 0x0fff }, { 334, 0x0000 }, { 334, 0x0000 }, { 334, 0x0000 },
+ { 334, 0x0000 }, { 334, 0x0000 }, { 334, 0x0003 }, { 336, 0x000c },
+ { 338, 0xc8c0 }, { 343, 0x0000 }, { 343, 0x0000 }, { 343, 0x0000 },
+ /* 0x2600 */
+ { 343, 0x0060 }, { 345, 0x0000 }, { 345, 0x0000 }, { 345, 0x0000 },
+ { 345, 0x0005 },
+};
+static const Summary16 gb2312_uni2indx_page30[35] = {
+ /* 0x3000 */
+ { 347, 0xff2f }, { 360, 0x00fb }, { 367, 0x0000 }, { 367, 0x0000 },
+ { 367, 0xfffe }, { 382, 0xffff }, { 398, 0xffff }, { 414, 0xffff },
+ { 430, 0xffff }, { 446, 0x000f }, { 450, 0xfffe }, { 465, 0xffff },
+ { 481, 0xffff }, { 497, 0xffff }, { 513, 0xffff }, { 529, 0x087f },
+ /* 0x3100 */
+ { 537, 0xffe0 }, { 548, 0xffff }, { 564, 0x03ff }, { 574, 0x0000 },
+ { 574, 0x0000 }, { 574, 0x0000 }, { 574, 0x0000 }, { 574, 0x0000 },
+ { 574, 0x0000 }, { 574, 0x0000 }, { 574, 0x0000 }, { 574, 0x0000 },
+ { 574, 0x0000 }, { 574, 0x0000 }, { 574, 0x0000 }, { 574, 0x0000 },
+ /* 0x3200 */
+ { 574, 0x0000 }, { 574, 0x0000 }, { 574, 0x03ff },
+};
+static const Summary16 gb2312_uni2indx_page4e[1263] = {
+ /* 0x4e00 */
+ { 584, 0x7f8b }, { 595, 0x7f7b }, { 608, 0x3db4 }, { 617, 0xef55 },
+ { 628, 0xfba8 }, { 638, 0xf35d }, { 649, 0x0243 }, { 653, 0x400b },
+ { 657, 0xfb40 }, { 665, 0x8d3e }, { 674, 0x7bf7 }, { 687, 0x8c2c },
+ { 693, 0x6eff }, { 706, 0xe3fa }, { 717, 0x1d3a }, { 725, 0xa8ed },
+ /* 0x4f00 */
+ { 734, 0xe602 }, { 740, 0xcf83 }, { 749, 0x8cf5 }, { 758, 0x3555 },
+ { 766, 0xe048 }, { 771, 0xffab }, { 784, 0x92b9 }, { 792, 0xd859 },
+ { 800, 0xab18 }, { 807, 0x2892 }, { 812, 0xd7e9 }, { 823, 0x8020 },
+ { 825, 0xc438 }, { 831, 0xf583 }, { 840, 0xe74a }, { 849, 0x450a },
+ /* 0x5000 */
+ { 854, 0xb000 }, { 857, 0x9714 }, { 864, 0x7762 }, { 873, 0x5400 },
+ { 876, 0xd188 }, { 882, 0x1420 }, { 885, 0x1020 }, { 887, 0xc8c0 },
+ { 892, 0x2121 }, { 896, 0x0000 }, { 896, 0x13a8 }, { 902, 0x0c04 },
+ { 905, 0x8000 }, { 906, 0x0440 }, { 908, 0x70c0 }, { 913, 0x0828 },
+ /* 0x5100 */
+ { 916, 0x08c0 }, { 919, 0x0004 }, { 920, 0x0002 }, { 921, 0x8000 },
+ { 922, 0x2b7b }, { 932, 0x1472 }, { 938, 0x7924 }, { 945, 0x3bfb },
+ { 957, 0x3327 }, { 965, 0x1ae4 }, { 972, 0x9835 }, { 979, 0x38ef },
+ { 989, 0x9ad1 }, { 997, 0x2802 }, { 1000, 0xa813 }, { 1006, 0xbf69 },
+ /* 0x5200 */
+ { 1017, 0x65cf }, { 1027, 0x2fc6 }, { 1036, 0x6b11 }, { 1043, 0xafc9 },
+ { 1053, 0x340f }, { 1060, 0x5053 }, { 1066, 0x86a2 }, { 1072, 0xa004 },
+ { 1075, 0x0106 }, { 1078, 0xe809 }, { 1084, 0x3f0f }, { 1094, 0xc00e },
+ { 1099, 0x0a88 }, { 1103, 0x8145 }, { 1108, 0x0010 }, { 1109, 0xc601 },
+ /* 0x5300 */
+ { 1114, 0xa161 }, { 1120, 0x26e1 }, { 1127, 0x444b }, { 1133, 0xce00 },
+ { 1138, 0xc7aa }, { 1147, 0xd4ee }, { 1157, 0xcadf }, { 1168, 0x85bb },
+ { 1177, 0x3a74 }, { 1185, 0xa520 }, { 1190, 0x436c }, { 1197, 0x8840 },
+ { 1200, 0x3f06 }, { 1208, 0x8bd2 }, { 1216, 0xff79 }, { 1229, 0x3bef },
+ /* 0x5400 */
+ { 1241, 0xf75a }, { 1252, 0xe8ef }, { 1263, 0xfbcb }, { 1275, 0x5b36 },
+ { 1284, 0x0d49 }, { 1290, 0x1bfd }, { 1301, 0x0154 }, { 1305, 0x39ee },
+ { 1315, 0xd855 }, { 1323, 0x2e75 }, { 1332, 0xbfd8 }, { 1343, 0xa91a },
+ { 1350, 0xf3d7 }, { 1362, 0xf6bf }, { 1375, 0x67e0 }, { 1383, 0xb40c },
+ /* 0x5500 */
+ { 1389, 0x82c2 }, { 1394, 0x0813 }, { 1398, 0xd49d }, { 1407, 0xd08b },
+ { 1414, 0x065a }, { 1420, 0x1061 }, { 1424, 0x74f2 }, { 1433, 0x59e0 },
+ { 1440, 0x8f9f }, { 1451, 0xb312 }, { 1458, 0x0080 }, { 1459, 0x6aaa },
+ { 1467, 0x3230 }, { 1472, 0xb05e }, { 1480, 0x9d7a }, { 1490, 0x60ac },
+ /* 0x5600 */
+ { 1496, 0xd303 }, { 1503, 0xc900 }, { 1507, 0x3098 }, { 1512, 0x8a56 },
+ { 1519, 0x7000 }, { 1522, 0x1390 }, { 1527, 0x1f14 }, { 1534, 0x1842 },
+ { 1538, 0xc060 }, { 1542, 0x0008 }, { 1543, 0x8008 }, { 1545, 0x1080 },
+ { 1547, 0x0400 }, { 1548, 0xec90 }, { 1555, 0x2817 }, { 1561, 0xe633 },
+ /* 0x5700 */
+ { 1570, 0x0758 }, { 1576, 0x9000 }, { 1578, 0xf708 }, { 1586, 0x4e09 },
+ { 1592, 0xf485 }, { 1600, 0xfc83 }, { 1609, 0xaf53 }, { 1619, 0x18c8 },
+ { 1624, 0x187c }, { 1631, 0x080c }, { 1634, 0x6adf }, { 1645, 0x0114 },
+ { 1648, 0xc80c }, { 1653, 0xa734 }, { 1661, 0xa011 }, { 1665, 0x2710 },
+ /* 0x5800 */
+ { 1670, 0x28c5 }, { 1676, 0x4222 }, { 1680, 0x0413 }, { 1684, 0x0021 },
+ { 1686, 0x3010 }, { 1689, 0x4112 }, { 1693, 0x1820 }, { 1696, 0x4000 },
+ { 1697, 0x022b }, { 1702, 0xc60c }, { 1708, 0x0300 }, { 1710, 0x1000 },
+ { 1711, 0x0022 }, { 1713, 0x0022 }, { 1715, 0x5810 }, { 1719, 0x0249 },
+ /* 0x5900 */
+ { 1723, 0xa094 }, { 1728, 0x9670 }, { 1735, 0xeeb0 }, { 1744, 0x1792 },
+ { 1751, 0xcb96 }, { 1760, 0x05f2 }, { 1767, 0x0025 }, { 1770, 0x2358 },
+ { 1776, 0x25de }, { 1785, 0x42cc }, { 1791, 0xcf38 }, { 1800, 0x4a04 },
+ { 1804, 0x0c40 }, { 1807, 0x359f }, { 1817, 0x1128 }, { 1821, 0x8a00 },
+ /* 0x5a00 */
+ { 1824, 0x13fa }, { 1833, 0x910a }, { 1838, 0x0229 }, { 1842, 0x1056 },
+ { 1847, 0x0641 }, { 1851, 0x0420 }, { 1853, 0x0484 }, { 1856, 0x84f0 },
+ { 1862, 0x0000 }, { 1862, 0x0c04 }, { 1865, 0x0400 }, { 1866, 0x412c },
+ { 1871, 0x1206 }, { 1875, 0x1154 }, { 1880, 0x0a4b }, { 1886, 0x0002 },
+ /* 0x5b00 */
+ { 1887, 0x0200 }, { 1888, 0x00c0 }, { 1890, 0x0000 }, { 1890, 0x0094 },
+ { 1893, 0x0001 }, { 1894, 0xbfbb }, { 1907, 0x167c }, { 1915, 0x242b },
+ { 1921, 0x9bbb }, { 1932, 0x7fa8 }, { 1942, 0x0c7f }, { 1951, 0xe379 },
+ { 1961, 0x10f4 }, { 1967, 0xe00d }, { 1973, 0x4132 }, { 1978, 0x9f01 },
+ /* 0x5c00 */
+ { 1985, 0x8652 }, { 1991, 0x3572 }, { 1999, 0x10b4 }, { 2004, 0xff12 },
+ { 2014, 0xcf27 }, { 2024, 0x4223 }, { 2029, 0xc06b }, { 2036, 0x8602 },
+ { 2040, 0x3106 }, { 2045, 0x1fd3 }, { 2055, 0x3a0c }, { 2061, 0xa1aa },
+ { 2068, 0x0812 }, { 2071, 0x0204 }, { 2073, 0x2572 }, { 2080, 0x0801 },
+ /* 0x5d00 */
+ { 2082, 0x40cc }, { 2087, 0x4850 }, { 2091, 0x62d0 }, { 2097, 0x6010 },
+ { 2100, 0x1c80 }, { 2104, 0x2900 }, { 2107, 0x9a00 }, { 2111, 0x0010 },
+ { 2112, 0x0004 }, { 2113, 0x2200 }, { 2115, 0x0000 }, { 2115, 0x0080 },
+ { 2116, 0x2020 }, { 2118, 0x6800 }, { 2121, 0xcbe6 }, { 2131, 0x609e },
+ /* 0x5e00 */
+ { 2138, 0x916e }, { 2146, 0x3f73 }, { 2157, 0x60c0 }, { 2161, 0x3982 },
+ { 2167, 0x1034 }, { 2171, 0x4830 }, { 2175, 0x0006 }, { 2177, 0xbd5c },
+ { 2187, 0x8cd1 }, { 2194, 0xd6fb }, { 2206, 0x20e1 }, { 2211, 0x43e8 },
+ { 2218, 0x0600 }, { 2220, 0x084e }, { 2225, 0x0500 }, { 2227, 0xc4d0 },
+ /* 0x5f00 */
+ { 2233, 0x8d1f }, { 2242, 0x89aa }, { 2249, 0xa6e1 }, { 2257, 0x1602 },
+ { 2261, 0x0001 }, { 2262, 0x21ed }, { 2270, 0x3656 }, { 2278, 0x1a8b },
+ { 2285, 0x1fb7 }, { 2296, 0x13a5 }, { 2303, 0x6502 }, { 2308, 0x30a0 },
+ { 2312, 0xb278 }, { 2320, 0x23c7 }, { 2328, 0x6c93 }, { 2336, 0xe922 },
+ /* 0x6000 */
+ { 2343, 0xe47f }, { 2354, 0x3a74 }, { 2362, 0x8fe3 }, { 2372, 0x9820 },
+ { 2376, 0x280e }, { 2381, 0x2625 }, { 2387, 0xbf9c }, { 2398, 0xbf49 },
+ { 2408, 0x3218 }, { 2413, 0xac54 }, { 2420, 0xb949 }, { 2428, 0x1916 },
+ { 2434, 0x0c60 }, { 2438, 0xb522 }, { 2445, 0xfbc1 }, { 2455, 0x0659 },
+ /* 0x6100 */
+ { 2461, 0xe343 }, { 2469, 0x8420 }, { 2472, 0x08d9 }, { 2478, 0x8000 },
+ { 2479, 0x5500 }, { 2483, 0x2022 }, { 2486, 0x0184 }, { 2489, 0x00a1 },
+ { 2492, 0x4800 }, { 2494, 0x2010 }, { 2496, 0x1380 }, { 2500, 0x4080 },
+ { 2502, 0x0d04 }, { 2506, 0x0016 }, { 2509, 0x0040 }, { 2510, 0x8020 },
+ /* 0x6200 */
+ { 2512, 0xfd40 }, { 2520, 0x8de7 }, { 2530, 0x5436 }, { 2537, 0xe098 },
+ { 2543, 0x7b8b }, { 2553, 0x091e }, { 2559, 0xfec8 }, { 2569, 0xd249 },
+ { 2576, 0x0611 }, { 2580, 0x8dee }, { 2590, 0x1937 }, { 2598, 0xba22 },
+ { 2605, 0x77f4 }, { 2616, 0x9fdd }, { 2628, 0xf3ec }, { 2639, 0xf0da },
+ /* 0x6300 */
+ { 2648, 0x4386 }, { 2654, 0xec42 }, { 2661, 0x8d3f }, { 2671, 0x2604 },
+ { 2675, 0xfa6c }, { 2685, 0xc021 }, { 2689, 0x628e }, { 2696, 0x0cc2 },
+ { 2701, 0xd785 }, { 2710, 0x0145 }, { 2714, 0x77ad }, { 2725, 0x5599 },
+ { 2733, 0xe250 }, { 2739, 0x4045 }, { 2743, 0x260b }, { 2749, 0xa154 },
+ /* 0x6400 */
+ { 2755, 0x9827 }, { 2762, 0x5819 }, { 2768, 0x3443 }, { 2774, 0xa410 },
+ { 2778, 0x05f2 }, { 2785, 0x4114 }, { 2789, 0x2280 }, { 2792, 0x0700 },
+ { 2795, 0x00b4 }, { 2799, 0x4266 }, { 2805, 0x7210 }, { 2810, 0x15a1 },
+ { 2816, 0x6025 }, { 2821, 0x4185 }, { 2826, 0x0054 }, { 2829, 0x0000 },
+ /* 0x6500 */
+ { 2829, 0x0201 }, { 2831, 0x0104 }, { 2833, 0xc820 }, { 2837, 0xcb70 },
+ { 2845, 0x9320 }, { 2850, 0x6a62 }, { 2857, 0x184c }, { 2862, 0x0095 },
+ { 2866, 0x1880 }, { 2869, 0x9a8b }, { 2877, 0xaab2 }, { 2885, 0x3201 },
+ { 2889, 0xd87a }, { 2898, 0x00c4 }, { 2901, 0xf3e5 }, { 2912, 0x04c3 },
+ /* 0x6600 */
+ { 2917, 0xd44d }, { 2925, 0xa238 }, { 2931, 0xa1a1 }, { 2937, 0x5072 },
+ { 2943, 0x980a }, { 2948, 0x84fc }, { 2956, 0xc152 }, { 2962, 0x44d1 },
+ { 2968, 0x1094 }, { 2972, 0x20c2 }, { 2976, 0x4180 }, { 2979, 0x4210 },
+ { 2982, 0x0000 }, { 2982, 0x3a00 }, { 2986, 0x0240 }, { 2988, 0xd29d },
+ /* 0x6700 */
+ { 2997, 0x2f01 }, { 3003, 0xa8b1 }, { 3010, 0xbd40 }, { 3017, 0x2432 },
+ { 3022, 0xd34d }, { 3031, 0xd04b }, { 3038, 0xa723 }, { 3046, 0xd0ad },
+ { 3054, 0x0a92 }, { 3059, 0x75a1 }, { 3067, 0xadac }, { 3076, 0x01e9 },
+ { 3082, 0x801a }, { 3086, 0x771f }, { 3097, 0x9225 }, { 3103, 0xa01b },
+ /* 0x6800 */
+ { 3109, 0xdfa1 }, { 3119, 0x20ca }, { 3124, 0x0602 }, { 3127, 0x738c },
+ { 3135, 0x577f }, { 3147, 0x003b }, { 3152, 0x0bff }, { 3163, 0x00d0 },
+ { 3166, 0x806a }, { 3171, 0x0088 }, { 3173, 0xa1c4 }, { 3179, 0x0029 },
+ { 3182, 0x2a05 }, { 3187, 0x0524 }, { 3191, 0x4009 }, { 3194, 0x1623 },
+ /* 0x6900 */
+ { 3200, 0x6822 }, { 3205, 0x8005 }, { 3208, 0x2011 }, { 3211, 0xa211 },
+ { 3216, 0x0004 }, { 3217, 0x6490 }, { 3222, 0x4849 }, { 3227, 0x1382 },
+ { 3232, 0x23d5 }, { 3240, 0x1930 }, { 3245, 0x2980 }, { 3249, 0x0892 },
+ { 3253, 0x5402 }, { 3257, 0x8811 }, { 3261, 0x2001 }, { 3263, 0xa004 },
+ /* 0x6a00 */
+ { 3266, 0x0400 }, { 3267, 0x8180 }, { 3270, 0x8502 }, { 3274, 0x6022 },
+ { 3278, 0x0090 }, { 3280, 0x0b01 }, { 3284, 0x0022 }, { 3286, 0x1202 },
+ { 3289, 0x4011 }, { 3292, 0x0083 }, { 3295, 0x1a01 }, { 3299, 0x0000 },
+ { 3299, 0x0000 }, { 3299, 0x0000 }, { 3299, 0x0000 }, { 3299, 0x0000 },
+ /* 0x6b00 */
+ { 3299, 0x0000 }, { 3299, 0x0000 }, { 3299, 0x009f }, { 3305, 0x4684 },
+ { 3310, 0x12c8 }, { 3315, 0x0200 }, { 3316, 0x04fc }, { 3323, 0x1a00 },
+ { 3326, 0x2ede }, { 3336, 0x0c4c }, { 3341, 0x0402 }, { 3343, 0x80b8 },
+ { 3348, 0xa826 }, { 3354, 0x0afc }, { 3362, 0x8c02 }, { 3366, 0x2228 },
+ /* 0x6c00 */
+ { 3370, 0xa0e0 }, { 3375, 0x8f7b }, { 3386, 0xc7d6 }, { 3396, 0x2135 },
+ { 3402, 0x06c7 }, { 3409, 0xf8b1 }, { 3418, 0x0713 }, { 3424, 0x6255 },
+ { 3431, 0x936e }, { 3440, 0x8a19 }, { 3446, 0x6efa }, { 3457, 0xfb0e },
+ { 3467, 0x1630 }, { 3472, 0x48f9 }, { 3480, 0xcd2f }, { 3490, 0x7deb },
+ /* 0x6d00 */
+ { 3502, 0x5892 }, { 3508, 0x4e84 }, { 3514, 0x4ca0 }, { 3519, 0x7a2e },
+ { 3528, 0xedea }, { 3539, 0x561e }, { 3547, 0xc649 }, { 3554, 0x1190 },
+ { 3558, 0x5324 }, { 3564, 0xe83a }, { 3572, 0xcfdb }, { 3584, 0x8124 },
+ { 3588, 0x18f1 }, { 3595, 0x6342 }, { 3601, 0x5853 }, { 3608, 0x1a8a },
+ /* 0x6e00 */
+ { 3614, 0x7420 }, { 3619, 0x24d3 }, { 3626, 0xaa3b }, { 3635, 0x0514 },
+ { 3639, 0x6018 }, { 3643, 0x8958 }, { 3649, 0x4800 }, { 3651, 0xc000 },
+ { 3653, 0x8268 }, { 3658, 0x9101 }, { 3662, 0x84a4 }, { 3667, 0x2cd6 },
+ { 3675, 0x8886 }, { 3680, 0xc4ba }, { 3688, 0x0377 }, { 3696, 0x0210 },
+ /* 0x6f00 */
+ { 3698, 0x8244 }, { 3702, 0x0038 }, { 3705, 0xae11 }, { 3712, 0x404a },
+ { 3716, 0x28c0 }, { 3720, 0x5100 }, { 3723, 0x6044 }, { 3727, 0x1514 },
+ { 3732, 0x7310 }, { 3738, 0x1000 }, { 3739, 0x0082 }, { 3741, 0x0248 },
+ { 3744, 0x0205 }, { 3747, 0x4006 }, { 3750, 0xc003 }, { 3754, 0x0000 },
+ /* 0x7000 */
+ { 3754, 0x0000 }, { 3754, 0x0c02 }, { 3757, 0x0008 }, { 3758, 0x0220 },
+ { 3760, 0x9000 }, { 3762, 0x4000 }, { 3763, 0xb800 }, { 3767, 0xd161 },
+ { 3774, 0x4621 }, { 3779, 0x3274 }, { 3786, 0xf800 }, { 3791, 0x3b8a },
+ { 3799, 0x050f }, { 3805, 0x8b00 }, { 3809, 0xbbd0 }, { 3818, 0x2280 },
+ /* 0x7100 */
+ { 3821, 0x0600 }, { 3823, 0x0769 }, { 3830, 0x8040 }, { 3832, 0x0043 },
+ { 3835, 0x5420 }, { 3839, 0x5000 }, { 3841, 0x41d0 }, { 3846, 0x250c },
+ { 3851, 0x8410 }, { 3854, 0x8310 }, { 3858, 0x1101 }, { 3861, 0x0228 },
+ { 3864, 0x4008 }, { 3866, 0x0030 }, { 3868, 0x40a1 }, { 3872, 0x0200 },
+ /* 0x7200 */
+ { 3873, 0x0040 }, { 3874, 0x2000 }, { 3875, 0x1500 }, { 3878, 0xabe3 },
+ { 3888, 0x3180 }, { 3892, 0xaa44 }, { 3898, 0xc2c6 }, { 3905, 0xc624 },
+ { 3911, 0xac13 }, { 3918, 0x8004 }, { 3920, 0xb000 }, { 3923, 0x03d1 },
+ { 3929, 0x611e }, { 3936, 0x4285 }, { 3941, 0xf303 }, { 3949, 0x1d9f },
+ /* 0x7300 */
+ { 3959, 0x440a }, { 3963, 0x78e8 }, { 3971, 0x5e26 }, { 3979, 0xc392 },
+ { 3986, 0x2000 }, { 3987, 0x0085 }, { 3990, 0xb001 }, { 3994, 0x4000 },
+ { 3995, 0x4a90 }, { 4000, 0x8842 }, { 4004, 0xca04 }, { 4009, 0x0c8d },
+ { 4015, 0xa705 }, { 4022, 0x4203 }, { 4026, 0x22a1 }, { 4031, 0x0004 },
+ /* 0x7400 */
+ { 4032, 0x8668 }, { 4038, 0x0c01 }, { 4041, 0x5564 }, { 4048, 0x1079 },
+ { 4054, 0x0002 }, { 4055, 0xdea0 }, { 4063, 0x2000 }, { 4064, 0x40c1 },
+ { 4068, 0x488b }, { 4074, 0x5001 }, { 4077, 0x0380 }, { 4080, 0x0400 },
+ { 4081, 0x0000 }, { 4081, 0x5004 }, { 4084, 0xc05d }, { 4091, 0x80d0 },
+ /* 0x7500 */
+ { 4095, 0xa010 }, { 4098, 0x970a }, { 4105, 0xbb20 }, { 4112, 0x4daf },
+ { 4122, 0xd921 }, { 4129, 0x1e10 }, { 4134, 0x0460 }, { 4137, 0x8314 },
+ { 4142, 0x8848 }, { 4146, 0xa6d6 }, { 4155, 0xd83b }, { 4164, 0x733f },
+ { 4175, 0x27bc }, { 4184, 0x4974 }, { 4191, 0x0ddc }, { 4199, 0x9213 },
+ /* 0x7600 */
+ { 4205, 0x142b }, { 4211, 0x8ba1 }, { 4218, 0x2e75 }, { 4227, 0xd139 },
+ { 4235, 0x3009 }, { 4239, 0x5050 }, { 4243, 0x8808 }, { 4246, 0x6900 },
+ { 4250, 0x49d4 }, { 4257, 0x024a }, { 4261, 0x4010 }, { 4263, 0x8016 },
+ { 4267, 0xe564 }, { 4275, 0x89d7 }, { 4284, 0xc020 }, { 4287, 0x5316 },
+ /* 0x7700 */
+ { 4294, 0x2b92 }, { 4301, 0x8600 }, { 4304, 0xa345 }, { 4311, 0x15e0 },
+ { 4317, 0x008b }, { 4321, 0x0c03 }, { 4325, 0x196e }, { 4333, 0xe200 },
+ { 4337, 0x7031 }, { 4343, 0x8006 }, { 4346, 0x16a5 }, { 4353, 0xa829 },
+ { 4359, 0x2000 }, { 4360, 0x1880 }, { 4363, 0x7aac }, { 4372, 0xe148 },
+ /* 0x7800 */
+ { 4378, 0x3207 }, { 4384, 0xb5d6 }, { 4394, 0x32e8 }, { 4401, 0x5f91 },
+ { 4410, 0x50a1 }, { 4415, 0x20e5 }, { 4421, 0x7c00 }, { 4426, 0x1080 },
+ { 4428, 0x7280 }, { 4433, 0x9d8a }, { 4441, 0x00aa }, { 4445, 0x421f },
+ { 4452, 0x0e22 }, { 4457, 0x0231 }, { 4461, 0x1100 }, { 4463, 0x0494 },
+ /* 0x7900 */
+ { 4467, 0x0022 }, { 4469, 0x4008 }, { 4471, 0x0010 }, { 4472, 0x5c10 },
+ { 4477, 0x0343 }, { 4482, 0xfcc8 }, { 4491, 0xa1a5 }, { 4498, 0x0580 },
+ { 4501, 0x8433 }, { 4507, 0x0400 }, { 4508, 0x0080 }, { 4509, 0x6e08 },
+ { 4515, 0x2a4b }, { 4522, 0x8126 }, { 4527, 0xaad8 }, { 4535, 0x2901 },
+ /* 0x7a00 */
+ { 4539, 0x684d }, { 4546, 0x4490 }, { 4550, 0x0009 }, { 4552, 0xba88 },
+ { 4559, 0x0040 }, { 4560, 0x0082 }, { 4562, 0x0000 }, { 4562, 0x87d1 },
+ { 4570, 0x215b }, { 4577, 0xb1e6 }, { 4586, 0x3161 }, { 4592, 0x8008 },
+ { 4594, 0x0800 }, { 4595, 0xc240 }, { 4599, 0xa069 }, { 4605, 0xa600 },
+ /* 0x7b00 */
+ { 4609, 0x8d58 }, { 4616, 0x4a32 }, { 4622, 0x5d71 }, { 4631, 0x550a },
+ { 4637, 0x9aa0 }, { 4643, 0x2d57 }, { 4652, 0x4005 }, { 4655, 0x4aa6 },
+ { 4662, 0x2021 }, { 4665, 0x30b1 }, { 4671, 0x3fc6 }, { 4681, 0x0112 },
+ { 4684, 0x10c2 }, { 4688, 0x260a }, { 4693, 0x4462 }, { 4698, 0x5082 },
+ /* 0x7c00 */
+ { 4702, 0x9880 }, { 4706, 0x8040 }, { 4708, 0x04c0 }, { 4711, 0x8100 },
+ { 4713, 0x2003 }, { 4716, 0x0000 }, { 4716, 0x0000 }, { 4716, 0x3818 },
+ { 4721, 0x0200 }, { 4722, 0xf1a6 }, { 4731, 0x4434 }, { 4736, 0x720e },
+ { 4743, 0x35a2 }, { 4750, 0x92e0 }, { 4756, 0x8101 }, { 4759, 0x0900 },
+ /* 0x7d00 */
+ { 4761, 0x0400 }, { 4762, 0x0000 }, { 4762, 0x8885 }, { 4767, 0x0000 },
+ { 4767, 0x0000 }, { 4767, 0x0000 }, { 4767, 0x4000 }, { 4768, 0x0080 },
+ { 4769, 0x0000 }, { 4769, 0x0000 }, { 4769, 0x4040 }, { 4771, 0x0000 },
+ { 4771, 0x0000 }, { 4771, 0x0000 }, { 4771, 0x0000 }, { 4771, 0x0000 },
+ /* 0x7e00 */
+ { 4771, 0x0000 }, { 4771, 0x0000 }, { 4771, 0x0000 }, { 4771, 0x0800 },
+ { 4772, 0x0082 }, { 4774, 0x0000 }, { 4774, 0x0000 }, { 4774, 0x0000 },
+ { 4774, 0x0004 }, { 4775, 0x8800 }, { 4777, 0xbfff }, { 4792, 0xe7ef },
+ { 4805, 0xffff }, { 4821, 0xffbf }, { 4836, 0xefef }, { 4850, 0xfdff },
+ /* 0x7f00 */
+ { 4865, 0xfbff }, { 4880, 0xbffe }, { 4894, 0xffff }, { 4910, 0x057f },
+ { 4919, 0x0034 }, { 4922, 0x85b3 }, { 4930, 0x4706 }, { 4936, 0x4216 },
+ { 4941, 0x5402 }, { 4945, 0xe410 }, { 4950, 0x8092 }, { 4954, 0xb305 },
+ { 4961, 0x5422 }, { 4966, 0x8130 }, { 4970, 0x4263 }, { 4976, 0x180b },
+ /* 0x8000 */
+ { 4981, 0x387b }, { 4990, 0x13f5 }, { 4999, 0x07e5 }, { 5007, 0xa9ea },
+ { 5016, 0x3c4c }, { 5023, 0x0514 }, { 5027, 0x0600 }, { 5029, 0x8002 },
+ { 5031, 0x1ad9 }, { 5039, 0xbd48 }, { 5047, 0xee37 }, { 5058, 0xf496 },
+ { 5067, 0x705f }, { 5076, 0x7ec0 }, { 5084, 0xbfb2 }, { 5095, 0x355f },
+ /* 0x8100 */
+ { 5105, 0xe644 }, { 5112, 0x455f }, { 5121, 0x9000 }, { 5123, 0x4146 },
+ { 5128, 0x1d40 }, { 5133, 0x063b }, { 5140, 0x62a1 }, { 5146, 0xfe13 },
+ { 5156, 0x8505 }, { 5161, 0x3902 }, { 5166, 0x0548 }, { 5170, 0x0c08 },
+ { 5173, 0x144f }, { 5180, 0x0000 }, { 5180, 0x3488 }, { 5185, 0x5818 },
+ /* 0x8200 */
+ { 5190, 0x3077 }, { 5198, 0xd815 }, { 5205, 0xbd0e }, { 5214, 0x4bfb },
+ { 5225, 0x8a90 }, { 5230, 0x8500 }, { 5233, 0xc100 }, { 5236, 0xe61d },
+ { 5245, 0xed14 }, { 5253, 0xb386 }, { 5261, 0xff72 }, { 5273, 0x639b },
+ { 5282, 0xfd92 }, { 5292, 0xd9be }, { 5303, 0x887b }, { 5311, 0x0a92 },
+ /* 0x8300 */
+ { 5316, 0xd3fe }, { 5328, 0x1cb2 }, { 5335, 0xb980 }, { 5341, 0x177a },
+ { 5350, 0x82c9 }, { 5356, 0xdc17 }, { 5365, 0xfffb }, { 5380, 0x3980 },
+ { 5385, 0x4260 }, { 5389, 0x590c }, { 5395, 0x0f01 }, { 5400, 0x37df },
+ { 5412, 0x94a3 }, { 5419, 0xb150 }, { 5425, 0x0623 }, { 5430, 0x2307 },
+ /* 0x8400 */
+ { 5436, 0xf85a }, { 5445, 0x3102 }, { 5449, 0x01f0 }, { 5454, 0x3102 },
+ { 5458, 0x0040 }, { 5459, 0x1e82 }, { 5465, 0x3a0a }, { 5471, 0x056a },
+ { 5477, 0x5b84 }, { 5484, 0x1280 }, { 5487, 0x8002 }, { 5489, 0xa714 },
+ { 5496, 0x2612 }, { 5501, 0xa04b }, { 5507, 0x1069 }, { 5512, 0x9001 },
+ /* 0x8500 */
+ { 5515, 0x1000 }, { 5516, 0x848a }, { 5521, 0x1802 }, { 5524, 0x3f80 },
+ { 5531, 0x0708 }, { 5535, 0x4240 }, { 5538, 0x0110 }, { 5540, 0x4e14 },
+ { 5546, 0x80b0 }, { 5550, 0x1800 }, { 5552, 0xc510 }, { 5557, 0x0281 },
+ { 5560, 0x8202 }, { 5563, 0x1029 }, { 5567, 0x0210 }, { 5569, 0x8800 },
+ /* 0x8600 */
+ { 5571, 0x0020 }, { 5572, 0x0042 }, { 5574, 0x0280 }, { 5576, 0x1100 },
+ { 5578, 0xe000 }, { 5581, 0x4413 }, { 5586, 0x5804 }, { 5590, 0xfe02 },
+ { 5598, 0x3c07 }, { 5605, 0x3028 }, { 5609, 0x9798 }, { 5617, 0x0473 },
+ { 5623, 0xced1 }, { 5632, 0xcb13 }, { 5640, 0x6210 }, { 5644, 0x431f },
+ /* 0x8700 */
+ { 5652, 0x278d }, { 5660, 0x55ac }, { 5668, 0x422e }, { 5674, 0xc892 },
+ { 5680, 0x5380 }, { 5685, 0x0288 }, { 5688, 0x4039 }, { 5693, 0x7851 },
+ { 5700, 0x292c }, { 5706, 0x8088 }, { 5709, 0xb900 }, { 5714, 0x2428 },
+ { 5718, 0x0c41 }, { 5722, 0x080e }, { 5726, 0x4421 }, { 5730, 0x4200 },
+ /* 0x8800 */
+ { 5732, 0x0408 }, { 5734, 0x0868 }, { 5738, 0x0006 }, { 5740, 0x1204 },
+ { 5743, 0x3031 }, { 5748, 0x0290 }, { 5751, 0x5b3e }, { 5761, 0xe085 },
+ { 5767, 0x2936 }, { 5774, 0x1044 }, { 5777, 0x2814 }, { 5781, 0x1082 },
+ { 5784, 0x4266 }, { 5790, 0x8334 }, { 5796, 0x013c }, { 5801, 0x531b },
+ /* 0x8900 */
+ { 5809, 0x0404 }, { 5811, 0x0e0d }, { 5817, 0x0c22 }, { 5821, 0x0051 },
+ { 5824, 0x0012 }, { 5826, 0xc000 }, { 5828, 0x0040 }, { 5829, 0x8800 },
+ { 5831, 0x004a }, { 5834, 0x0000 }, { 5834, 0x0000 }, { 5834, 0x0000 },
+ { 5834, 0xdff6 }, { 5847, 0x5447 }, { 5854, 0x8868 }, { 5859, 0x0008 },
+ /* 0x8a00 */
+ { 5860, 0x0081 }, { 5862, 0x0000 }, { 5862, 0x0000 }, { 5862, 0x4000 },
+ { 5863, 0x0100 }, { 5864, 0x0000 }, { 5864, 0x0000 }, { 5864, 0x0200 },
+ { 5865, 0x0600 }, { 5867, 0x0008 }, { 5868, 0x0000 }, { 5868, 0x0000 },
+ { 5868, 0x0000 }, { 5868, 0x0000 }, { 5868, 0x0000 }, { 5868, 0x0000 },
+ /* 0x8b00 */
+ { 5868, 0x0080 }, { 5869, 0x0000 }, { 5869, 0x0040 }, { 5870, 0x0000 },
+ { 5870, 0x0000 }, { 5870, 0x0000 }, { 5870, 0x1040 }, { 5872, 0x0000 },
+ { 5872, 0x0000 }, { 5872, 0x0000 }, { 5872, 0xefff }, { 5887, 0xf7fd },
+ { 5901, 0xff7f }, { 5916, 0xfffe }, { 5931, 0xfbff }, { 5946, 0xffff },
+ /* 0x8c00 */
+ { 5962, 0xfdff }, { 5977, 0xbfff }, { 5992, 0xffff }, { 6008, 0x00ff },
+ { 6016, 0x12c2 }, { 6021, 0x0420 }, { 6023, 0x0c06 }, { 6027, 0x0708 },
+ { 6031, 0x1624 }, { 6036, 0x0110 }, { 6038, 0x0000 }, { 6038, 0x0000 },
+ { 6038, 0x0000 }, { 6038, 0x0000 }, { 6038, 0x0000 }, { 6038, 0x0000 },
+ /* 0x8d00 */
+ { 6038, 0x0000 }, { 6038, 0xe000 }, { 6041, 0xfffe }, { 6056, 0xffff },
+ { 6072, 0xffff }, { 6088, 0x7f79 }, { 6100, 0x28df }, { 6109, 0x00f9 },
+ { 6115, 0x0c32 }, { 6120, 0x8012 }, { 6123, 0x0008 }, { 6124, 0xd53a },
+ { 6133, 0xd858 }, { 6140, 0xecc2 }, { 6148, 0x9d18 }, { 6155, 0x2fa8 },
+ /* 0x8e00 */
+ { 6163, 0x9620 }, { 6168, 0xe010 }, { 6172, 0xd60c }, { 6179, 0x2622 },
+ { 6184, 0x0f97 }, { 6193, 0x0206 }, { 6196, 0xb240 }, { 6201, 0x9055 },
+ { 6207, 0x80a2 }, { 6211, 0x5011 }, { 6215, 0x9800 }, { 6218, 0x0404 },
+ { 6220, 0x4000 }, { 6221, 0x0000 }, { 6221, 0x0000 }, { 6221, 0x0000 },
+ /* 0x8f00 */
+ { 6221, 0x0000 }, { 6221, 0x0000 }, { 6221, 0x0000 }, { 6221, 0x0000 },
+ { 6221, 0x0000 }, { 6221, 0x0000 }, { 6221, 0xfbc0 }, { 6230, 0xffff },
+ { 6246, 0xeffe }, { 6260, 0xdffb }, { 6274, 0x0b08 }, { 6278, 0x6243 },
+ { 6284, 0x41b6 }, { 6291, 0xfb3b }, { 6303, 0x6f74 }, { 6313, 0x2389 },
+ /* 0x9000 */
+ { 6319, 0xae7f }, { 6331, 0xecd7 }, { 6342, 0xe047 }, { 6349, 0x5960 },
+ { 6355, 0xa096 }, { 6361, 0x098f }, { 6368, 0x612c }, { 6374, 0xa030 },
+ { 6378, 0x090d }, { 6383, 0x2aaa }, { 6390, 0xd44e }, { 6398, 0x4f7b },
+ { 6409, 0xc4b2 }, { 6416, 0x388b }, { 6423, 0xa9c6 }, { 6431, 0x6110 },
+ /* 0x9100 */
+ { 6435, 0x0014 }, { 6437, 0x4200 }, { 6439, 0x800c }, { 6442, 0x0202 },
+ { 6444, 0xfe48 }, { 6453, 0x6485 }, { 6459, 0xd63e }, { 6469, 0xe3f7 },
+ { 6481, 0x3aa0 }, { 6487, 0x0c07 }, { 6492, 0xe40c }, { 6498, 0x0430 },
+ { 6501, 0xf680 }, { 6508, 0x1002 }, { 6510, 0x0000 }, { 6510, 0x0000 },
+ /* 0x9200 */
+ { 6510, 0x0000 }, { 6510, 0x0000 }, { 6510, 0x0000 }, { 6510, 0x0000 },
+ { 6510, 0x0000 }, { 6510, 0x0000 }, { 6510, 0x0000 }, { 6510, 0x0010 },
+ { 6511, 0x4000 }, { 6512, 0x0000 }, { 6512, 0x4000 }, { 6513, 0x0000 },
+ { 6513, 0x0100 }, { 6514, 0x0000 }, { 6514, 0x0000 }, { 6514, 0x0000 },
+ /* 0x9300 */
+ { 6514, 0x0000 }, { 6514, 0x0000 }, { 6514, 0x0000 }, { 6514, 0x4000 },
+ { 6515, 0x0000 }, { 6515, 0x0000 }, { 6515, 0x0400 }, { 6516, 0x0000 },
+ { 6516, 0x8000 }, { 6517, 0x0000 }, { 6517, 0x0000 }, { 6517, 0x0000 },
+ { 6517, 0x0400 }, { 6518, 0x0040 }, { 6519, 0x0000 }, { 6519, 0x0000 },
+ /* 0x9400 */
+ { 6519, 0x0000 }, { 6519, 0x0000 }, { 6519, 0x0000 }, { 6519, 0x4000 },
+ { 6520, 0x0000 }, { 6520, 0x0000 }, { 6520, 0x0800 }, { 6521, 0x0000 },
+ { 6521, 0xffe0 }, { 6532, 0xfebd }, { 6545, 0xffff }, { 6561, 0xffff },
+ { 6577, 0x7f7f }, { 6591, 0xfbe7 }, { 6604, 0xffbf }, { 6619, 0xf7ff },
+ /* 0x9500 */
+ { 6634, 0xffff }, { 6650, 0xefff }, { 6665, 0xff7e }, { 6679, 0xdff7 },
+ { 6693, 0xf6f7 }, { 6706, 0xfbdf }, { 6720, 0xbffe }, { 6734, 0x804f },
+ { 6740, 0x0000 }, { 6740, 0x0000 }, { 6740, 0x0000 }, { 6740, 0x0000 },
+ { 6740, 0x0000 }, { 6740, 0x0000 }, { 6740, 0xef00 }, { 6747, 0x7fff },
+ /* 0x9600 */
+ { 6762, 0xff7f }, { 6777, 0xb6f7 }, { 6789, 0x4406 }, { 6793, 0xb87e },
+ { 6803, 0x3bf5 }, { 6814, 0x8831 }, { 6819, 0x1796 }, { 6827, 0x00f4 },
+ { 6832, 0xa960 }, { 6838, 0x1391 }, { 6844, 0x0080 }, { 6845, 0x7249 },
+ { 6852, 0xf2f3 }, { 6863, 0x0024 }, { 6865, 0x8701 }, { 6870, 0x42c8 },
+ /* 0x9700 */
+ { 6875, 0xe3d3 }, { 6885, 0x5048 }, { 6889, 0x2400 }, { 6891, 0x4305 },
+ { 6896, 0x0000 }, { 6896, 0x4a4c }, { 6902, 0x0227 }, { 6907, 0x1058 },
+ { 6911, 0x2820 }, { 6914, 0x0116 }, { 6918, 0xa809 }, { 6923, 0x0014 },
+ { 6925, 0x0000 }, { 6925, 0x0000 }, { 6925, 0x3ec0 }, { 6932, 0x0068 },
+ /* 0x9800 */
+ { 6935, 0x0000 }, { 6935, 0x0000 }, { 6935, 0x0000 }, { 6935, 0x0000 },
+ { 6935, 0x0000 }, { 6935, 0x0000 }, { 6935, 0x0000 }, { 6935, 0xffe0 },
+ { 6946, 0xb7ff }, { 6960, 0xfddb }, { 6973, 0x00f7 }, { 6980, 0x0000 },
+ { 6980, 0x4000 }, { 6981, 0xc72e }, { 6990, 0x0180 }, { 6992, 0x0000 },
+ /* 0x9900 */
+ { 6992, 0x2000 }, { 6993, 0x0001 }, { 6994, 0x4000 }, { 6995, 0x0000 },
+ { 6995, 0x0000 }, { 6995, 0x0030 }, { 6997, 0xffa8 }, { 7008, 0xb4f7 },
+ { 7019, 0xadf3 }, { 7030, 0x03ff }, { 7040, 0x0120 }, { 7042, 0x0000 },
+ { 7042, 0x0000 }, { 7042, 0x0000 }, { 7042, 0x0000 }, { 7042, 0x0000 },
+ /* 0x9a00 */
+ { 7042, 0x0000 }, { 7042, 0x0000 }, { 7042, 0x0000 }, { 7042, 0x0000 },
+ { 7042, 0x0000 }, { 7042, 0x0000 }, { 7042, 0xf000 }, { 7046, 0xfffb },
+ { 7061, 0x9df7 }, { 7073, 0xfdcf }, { 7086, 0x01bf }, { 7094, 0x15c3 },
+ { 7101, 0x1827 }, { 7107, 0x810a }, { 7111, 0xa842 }, { 7116, 0x0a00 },
+ /* 0x9b00 */
+ { 7118, 0x8108 }, { 7121, 0x8008 }, { 7123, 0x8008 }, { 7125, 0x1804 },
+ { 7128, 0xa3be }, { 7138, 0x0012 }, { 7140, 0x0000 }, { 7140, 0x0000 },
+ { 7140, 0x0000 }, { 7140, 0x0000 }, { 7140, 0x0000 }, { 7140, 0x0000 },
+ { 7140, 0x0000 }, { 7140, 0x0000 }, { 7140, 0x0000 }, { 7140, 0x0000 },
+ /* 0x9c00 */
+ { 7140, 0x0000 }, { 7140, 0x0000 }, { 7140, 0x0000 }, { 7140, 0x0000 },
+ { 7140, 0x0000 }, { 7140, 0x0000 }, { 7140, 0x0000 }, { 7140, 0x9000 },
+ { 7142, 0x69e6 }, { 7151, 0xdc37 }, { 7161, 0x6bff }, { 7174, 0x3dff },
+ { 7187, 0xfcf8 }, { 7198, 0xf3f9 }, { 7210, 0x0004 },
+};
+static const Summary16 gb2312_uni2indx_page9e[27] = {
+ /* 0x9e00 */
+ { 7211, 0x0000 }, { 7211, 0x8000 }, { 7212, 0xbf6f }, { 7225, 0xe7ee },
+ { 7237, 0xdffe }, { 7251, 0x5da2 }, { 7259, 0x3fd8 }, { 7269, 0xc00b },
+ { 7274, 0x0984 }, { 7278, 0xa00c }, { 7282, 0x0040 }, { 7283, 0x6910 },
+ { 7288, 0xe210 }, { 7293, 0xb912 }, { 7300, 0x86a5 }, { 7307, 0x5a00 },
+ /* 0x9f00 */
+ { 7311, 0x6800 }, { 7314, 0x0289 }, { 7318, 0x9005 }, { 7322, 0x6a80 },
+ { 7327, 0x0010 }, { 7328, 0x0003 }, { 7330, 0x0000 }, { 7330, 0x8000 },
+ { 7331, 0x1ff9 }, { 7342, 0x8e00 }, { 7346, 0x0001 },
+};
+static const Summary16 gb2312_uni2indx_pageff[15] = {
+ /* 0xff00 */
+ { 7347, 0xfffe }, { 7362, 0xffff }, { 7378, 0xffff }, { 7394, 0xffff },
+ { 7410, 0xffff }, { 7426, 0x7fff }, { 7441, 0x0000 }, { 7441, 0x0000 },
+ { 7441, 0x0000 }, { 7441, 0x0000 }, { 7441, 0x0000 }, { 7441, 0x0000 },
+ { 7441, 0x0000 }, { 7441, 0x0000 }, { 7441, 0x002b },
+};
+
+static int
+gb2312_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ if (n >= 2) {
+ const Summary16 *summary = NULL;
+ if (wc < 0x0460)
+ summary = &gb2312_uni2indx_page00[(wc>>4)];
+ else if (wc >= 0x2000 && wc < 0x2650)
+ summary = &gb2312_uni2indx_page20[(wc>>4)-0x200];
+ else if (wc >= 0x3000 && wc < 0x3230)
+ summary = &gb2312_uni2indx_page30[(wc>>4)-0x300];
+ else if (wc >= 0x4e00 && wc < 0x9cf0)
+ summary = &gb2312_uni2indx_page4e[(wc>>4)-0x4e0];
+ else if (wc >= 0x9e00 && wc < 0x9fb0)
+ summary = &gb2312_uni2indx_page9e[(wc>>4)-0x9e0];
+ else if (wc >= 0xff00 && wc < 0xfff0)
+ summary = &gb2312_uni2indx_pageff[(wc>>4)-0xff0];
+ if (summary) {
+ unsigned short used = summary->used;
+ unsigned int i = wc & 0x0f;
+ if (used & ((unsigned short) 1 << i)) {
+ unsigned short c;
+ /* Keep in `used' only the bits 0..i-1. */
+ used &= ((unsigned short) 1 << i) - 1;
+ /* Add `summary->indx' and the number of bits set in `used'. */
+ used = (used & 0x5555) + ((used & 0xaaaa) >> 1);
+ used = (used & 0x3333) + ((used & 0xcccc) >> 2);
+ used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4);
+ used = (used & 0x00ff) + (used >> 8);
+ c = gb2312_2charset[summary->indx + used];
+ r[0] = (c >> 8); r[1] = (c & 0xff);
+ return 2;
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOSMALL;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/georgian_academy.h b/nx-X11/lib/X11/lcUniConv/georgian_academy.h
new file mode 100644
index 000000000..230369014
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/georgian_academy.h
@@ -0,0 +1,88 @@
+/* $XFree86$ */
+
+/*
+ * GEORGIAN-ACADEMY
+ */
+
+static const unsigned short georgian_academy_2uni[32] = {
+ /* 0x80 */
+ 0x0080, 0x0081, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008d, 0x008e, 0x008f,
+ /* 0x90 */
+ 0x0090, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x009d, 0x009e, 0x0178,
+};
+
+static int
+georgian_academy_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c >= 0x80 && c < 0xa0)
+ *pwc = (ucs4_t) georgian_academy_2uni[c-0x80];
+ else if (c >= 0xc0 && c < 0xe7)
+ *pwc = (ucs4_t) c + 0x1010;
+ else
+ *pwc = (ucs4_t) c;
+ return 1;
+}
+
+static const unsigned char georgian_academy_page00[32] = {
+ 0x80, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x8d, 0x8e, 0x8f, /* 0x88-0x8f */
+ 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x9d, 0x9e, 0x00, /* 0x98-0x9f */
+};
+static const unsigned char georgian_academy_page01[72] = {
+ 0x00, 0x00, 0x8c, 0x9c, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0x8a, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x9f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+ 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+};
+static const unsigned char georgian_academy_page02[32] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+ 0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+};
+static const unsigned char georgian_academy_page20[48] = {
+ 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */
+ 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+};
+
+static int
+georgian_academy_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0080) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x0080 && wc < 0x00a0)
+ c = georgian_academy_page00[wc-0x0080];
+ else if ((wc >= 0x00a0 && wc < 0x00c0) || (wc >= 0x00e7 && wc < 0x0100))
+ c = wc;
+ else if (wc >= 0x0150 && wc < 0x0198)
+ c = georgian_academy_page01[wc-0x0150];
+ else if (wc >= 0x02c0 && wc < 0x02e0)
+ c = georgian_academy_page02[wc-0x02c0];
+ else if (wc >= 0x10d0 && wc < 0x10f7)
+ c = wc-0x1010;
+ else if (wc >= 0x2010 && wc < 0x2040)
+ c = georgian_academy_page20[wc-0x2010];
+ else if (wc == 0x2122)
+ c = 0x99;
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/georgian_ps.h b/nx-X11/lib/X11/lcUniConv/georgian_ps.h
new file mode 100644
index 000000000..b7e30bf0c
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/georgian_ps.h
@@ -0,0 +1,105 @@
+/* $XFree86$ */
+
+/*
+ * GEORGIAN-PS
+ */
+
+static const unsigned short georgian_ps_2uni_1[32] = {
+ /* 0x80 */
+ 0x0080, 0x0081, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008d, 0x008e, 0x008f,
+ /* 0x90 */
+ 0x0090, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x009d, 0x009e, 0x0178,
+};
+static const unsigned short georgian_ps_2uni_2[39] = {
+ /* 0xc0 */
+ 0x10d0, 0x10d1, 0x10d2, 0x10d3, 0x10d4, 0x10d5, 0x10d6, 0x10f1,
+ 0x10d7, 0x10d8, 0x10d9, 0x10da, 0x10db, 0x10dc, 0x10f2, 0x10dd,
+ /* 0xd0 */
+ 0x10de, 0x10df, 0x10e0, 0x10e1, 0x10e2, 0x10f3, 0x10e3, 0x10e4,
+ 0x10e5, 0x10e6, 0x10e7, 0x10e8, 0x10e9, 0x10ea, 0x10eb, 0x10ec,
+ /* 0xe0 */
+ 0x10ed, 0x10ee, 0x10f4, 0x10ef, 0x10f0, 0x10f5,
+};
+
+static int
+georgian_ps_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c >= 0x80 && c < 0xa0)
+ *pwc = (ucs4_t) georgian_ps_2uni_1[c-0x80];
+ else if (c >= 0xc0 && c < 0xe6)
+ *pwc = (ucs4_t) georgian_ps_2uni_2[c-0xc0];
+ else
+ *pwc = (ucs4_t) c;
+ return 1;
+}
+
+static const unsigned char georgian_ps_page00[32] = {
+ 0x80, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x8d, 0x8e, 0x8f, /* 0x88-0x8f */
+ 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x9d, 0x9e, 0x00, /* 0x98-0x9f */
+};
+static const unsigned char georgian_ps_page01[72] = {
+ 0x00, 0x00, 0x8c, 0x9c, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0x8a, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x9f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+ 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+};
+static const unsigned char georgian_ps_page02[32] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+ 0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+};
+static const unsigned char georgian_ps_page10[40] = {
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc8, /* 0xd0-0xd7 */
+ 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xcf, 0xd0, 0xd1, /* 0xd8-0xdf */
+ 0xd2, 0xd3, 0xd4, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, /* 0xe0-0xe7 */
+ 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe3, /* 0xe8-0xef */
+ 0xe4, 0xc7, 0xce, 0xd5, 0xe2, 0xe5, 0x00, 0x00, /* 0xf0-0xf7 */
+};
+static const unsigned char georgian_ps_page20[48] = {
+ 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */
+ 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+};
+
+static int
+georgian_ps_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0080) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x0080 && wc < 0x00a0)
+ c = georgian_ps_page00[wc-0x0080];
+ else if ((wc >= 0x00a0 && wc < 0x00c0) || (wc >= 0x00e6 && wc < 0x0100))
+ c = wc;
+ else if (wc >= 0x0150 && wc < 0x0198)
+ c = georgian_ps_page01[wc-0x0150];
+ else if (wc >= 0x02c0 && wc < 0x02e0)
+ c = georgian_ps_page02[wc-0x02c0];
+ else if (wc >= 0x10d0 && wc < 0x10f8)
+ c = georgian_ps_page10[wc-0x10d0];
+ else if (wc >= 0x2010 && wc < 0x2040)
+ c = georgian_ps_page20[wc-0x2010];
+ else if (wc == 0x2122)
+ c = 0x99;
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_1.h b/nx-X11/lib/X11/lcUniConv/iso8859_1.h
new file mode 100644
index 000000000..0b03e7023
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_1.h
@@ -0,0 +1,23 @@
+/* $XFree86$ */
+
+/*
+ * ISO-8859-1
+ */
+
+static int
+iso8859_1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ *pwc = (ucs4_t) c;
+ return 1;
+}
+
+static int
+iso8859_1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ if (wc < 0x0100) {
+ *r = wc;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_10.h b/nx-X11/lib/X11/lcUniConv/iso8859_10.h
new file mode 100644
index 000000000..f0ef2f694
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_10.h
@@ -0,0 +1,88 @@
+/* $XFree86$ */
+
+/*
+ * ISO-8859-10
+ */
+
+static const unsigned short iso8859_10_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0x0104, 0x0112, 0x0122, 0x012a, 0x0128, 0x0136, 0x00a7,
+ 0x013b, 0x0110, 0x0160, 0x0166, 0x017d, 0x00ad, 0x016a, 0x014a,
+ /* 0xb0 */
+ 0x00b0, 0x0105, 0x0113, 0x0123, 0x012b, 0x0129, 0x0137, 0x00b7,
+ 0x013c, 0x0111, 0x0161, 0x0167, 0x017e, 0x2015, 0x016b, 0x014b,
+ /* 0xc0 */
+ 0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e,
+ 0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x00cf,
+ /* 0xd0 */
+ 0x00d0, 0x0145, 0x014c, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x0168,
+ 0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
+ /* 0xe0 */
+ 0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f,
+ 0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x00ef,
+ /* 0xf0 */
+ 0x00f0, 0x0146, 0x014d, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x0169,
+ 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x0138,
+};
+
+static int
+iso8859_10_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0xa0)
+ *pwc = (ucs4_t) c;
+ else
+ *pwc = (ucs4_t) iso8859_10_2uni[c-0xa0];
+ return 1;
+}
+
+static const unsigned char iso8859_10_page00[224] = {
+ 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, /* 0xa0-0xa7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, /* 0xa8-0xaf */
+ 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, /* 0xb0-0xb7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+ 0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0xc9, 0x00, 0xcb, 0x00, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */
+ 0xd0, 0x00, 0x00, 0xd3, 0xd4, 0xd5, 0xd6, 0x00, /* 0xd0-0xd7 */
+ 0xd8, 0x00, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0xd8-0xdf */
+ 0x00, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0x00, /* 0xe0-0xe7 */
+ 0x00, 0xe9, 0x00, 0xeb, 0x00, 0xed, 0xee, 0xef, /* 0xe8-0xef */
+ 0xf0, 0x00, 0x00, 0xf3, 0xf4, 0xf5, 0xf6, 0x00, /* 0xf0-0xf7 */
+ 0xf8, 0x00, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0x00, /* 0xf8-0xff */
+ /* 0x0100 */
+ 0xc0, 0xe0, 0x00, 0x00, 0xa1, 0xb1, 0x00, 0x00, /* 0x00-0x07 */
+ 0x00, 0x00, 0x00, 0x00, 0xc8, 0xe8, 0x00, 0x00, /* 0x08-0x0f */
+ 0xa9, 0xb9, 0xa2, 0xb2, 0x00, 0x00, 0xcc, 0xec, /* 0x10-0x17 */
+ 0xca, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0xa3, 0xb3, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0xa5, 0xb5, 0xa4, 0xb4, 0x00, 0x00, 0xc7, 0xe7, /* 0x28-0x2f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0xb6, /* 0x30-0x37 */
+ 0xff, 0x00, 0x00, 0xa8, 0xb8, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xf1, 0x00, /* 0x40-0x47 */
+ 0x00, 0x00, 0xaf, 0xbf, 0xd2, 0xf2, 0x00, 0x00, /* 0x48-0x4f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0xaa, 0xba, 0x00, 0x00, 0x00, 0x00, 0xab, 0xbb, /* 0x60-0x67 */
+ 0xd7, 0xf7, 0xae, 0xbe, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0xd9, 0xf9, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0xbc, 0x00, /* 0x78-0x7f */
+};
+
+static int
+iso8859_10_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x0180)
+ c = iso8859_10_page00[wc-0x00a0];
+ else if (wc == 0x2015)
+ c = 0xbd;
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_11.h b/nx-X11/lib/X11/lcUniConv/iso8859_11.h
new file mode 100644
index 000000000..57eb016a8
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_11.h
@@ -0,0 +1,78 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_11.h,v 1.1tsi Exp $ */
+
+/*
+ * ISO8859-11
+ */
+
+static const unsigned short iso8859_11_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07,
+ 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f,
+ /* 0xb0 */
+ 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17,
+ 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f,
+ /* 0xc0 */
+ 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27,
+ 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f,
+ /* 0xd0 */
+ 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37,
+ 0x0e38, 0x0e39, 0x0e3a, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x0e3f,
+ /* 0xe0 */
+ 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47,
+ 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f,
+ /* 0xf0 */
+ 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57,
+ 0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+};
+
+static int
+iso8859_11_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0x80) {
+ *pwc = (ucs4_t) c;
+ return 1;
+ }
+ else if (c < 0xa0) {
+ }
+ else {
+ unsigned short wc = iso8859_11_2uni[c-0xa0];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 1;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned char iso8859_11_page0e[96] = {
+ 0x00, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0x00-0x07 */
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0x08-0x0f */
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0x10-0x17 */
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* 0x18-0x1f */
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x20-0x27 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x28-0x2f */
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x30-0x37 */
+ 0xd8, 0xd9, 0xda, 0x00, 0x00, 0x00, 0x00, 0xdf, /* 0x38-0x3f */
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x40-0x47 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x48-0x4f */
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x50-0x57 */
+ 0xf8, 0xf9, 0xfa, 0xfb, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+};
+
+static int
+iso8859_11_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0080 || wc == 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x0e00 && wc < 0x0e60)
+ c = iso8859_11_page0e[wc-0x0e00];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_13.h b/nx-X11/lib/X11/lcUniConv/iso8859_13.h
new file mode 100644
index 000000000..7ad1fd2a1
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_13.h
@@ -0,0 +1,91 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_13.h,v 1.1 2000/06/23 19:50:59 dawes Exp $ */
+
+/*
+ * ISO-8859-13
+ */
+
+static const unsigned short iso8859_13_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0x201d, 0x00a2, 0x00a3, 0x00a4, 0x201e, 0x00a6, 0x00a7,
+ 0x00d8, 0x00a9, 0x0156, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00c6,
+ /* 0xb0 */
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x201c, 0x00b5, 0x00b6, 0x00b7,
+ 0x00f8, 0x00b9, 0x0157, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00e6,
+ /* 0xc0 */
+ 0x0104, 0x012e, 0x0100, 0x0106, 0x00c4, 0x00c5, 0x0118, 0x0112,
+ 0x010c, 0x00c9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012a, 0x013b,
+ /* 0xd0 */
+ 0x0160, 0x0143, 0x0145, 0x00d3, 0x014c, 0x00d5, 0x00d6, 0x00d7,
+ 0x0172, 0x0141, 0x015a, 0x016a, 0x00dc, 0x017b, 0x017d, 0x00df,
+ /* 0xe0 */
+ 0x0105, 0x012f, 0x0101, 0x0107, 0x00e4, 0x00e5, 0x0119, 0x0113,
+ 0x010d, 0x00e9, 0x017a, 0x0117, 0x0123, 0x0137, 0x012b, 0x013c,
+ /* 0xf0 */
+ 0x0161, 0x0144, 0x0146, 0x00f3, 0x014d, 0x00f5, 0x00f6, 0x00f7,
+ 0x0173, 0x0142, 0x015b, 0x016b, 0x00fc, 0x017c, 0x017e, 0x2019,
+};
+
+static int
+iso8859_13_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0xa0)
+ *pwc = (ucs4_t) c;
+ else
+ *pwc = (ucs4_t) iso8859_13_2uni[c-0xa0];
+ return 1;
+}
+
+static const unsigned char iso8859_13_page00[224] = {
+ 0xa0, 0x00, 0xa2, 0xa3, 0xa4, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */
+ 0x00, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0x00, /* 0xa8-0xaf */
+ 0xb0, 0xb1, 0xb2, 0xb3, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
+ 0x00, 0xb9, 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0x00, /* 0xb8-0xbf */
+ 0x00, 0x00, 0x00, 0x00, 0xc4, 0xc5, 0xaf, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0xc9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0xd3, 0x00, 0xd5, 0xd6, 0xd7, /* 0xd0-0xd7 */
+ 0xa8, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0xdf, /* 0xd8-0xdf */
+ 0x00, 0x00, 0x00, 0x00, 0xe4, 0xe5, 0xbf, 0x00, /* 0xe0-0xe7 */
+ 0x00, 0xe9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
+ 0x00, 0x00, 0x00, 0xf3, 0x00, 0xf5, 0xf6, 0xf7, /* 0xf0-0xf7 */
+ 0xb8, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, /* 0xf8-0xff */
+ /* 0x0100 */
+ 0xc2, 0xe2, 0x00, 0x00, 0xc0, 0xe0, 0xc3, 0xe3, /* 0x00-0x07 */
+ 0x00, 0x00, 0x00, 0x00, 0xc8, 0xe8, 0x00, 0x00, /* 0x08-0x0f */
+ 0x00, 0x00, 0xc7, 0xe7, 0x00, 0x00, 0xcb, 0xeb, /* 0x10-0x17 */
+ 0xc6, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0xcc, 0xec, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0xce, 0xee, 0x00, 0x00, 0xc1, 0xe1, /* 0x28-0x2f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcd, 0xed, /* 0x30-0x37 */
+ 0x00, 0x00, 0x00, 0xcf, 0xef, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0xd9, 0xf9, 0xd1, 0xf1, 0xd2, 0xf2, 0x00, /* 0x40-0x47 */
+ 0x00, 0x00, 0x00, 0x00, 0xd4, 0xf4, 0x00, 0x00, /* 0x48-0x4f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xba, /* 0x50-0x57 */
+ 0x00, 0x00, 0xda, 0xfa, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0xd0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0xdb, 0xfb, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0xd8, 0xf8, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0xca, 0xea, 0xdd, 0xfd, 0xde, 0xfe, 0x00, /* 0x78-0x7f */
+};
+static const unsigned char iso8859_13_page20[8] = {
+ 0x00, 0xff, 0x00, 0x00, 0xb4, 0xa1, 0xa5, 0x00, /* 0x18-0x1f */
+};
+
+static int
+iso8859_13_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x0180)
+ c = iso8859_13_page00[wc-0x00a0];
+ else if (wc >= 0x2018 && wc < 0x2020)
+ c = iso8859_13_page20[wc-0x2018];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_14.h b/nx-X11/lib/X11/lcUniConv/iso8859_14.h
new file mode 100644
index 000000000..7fd322ccf
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_14.h
@@ -0,0 +1,109 @@
+/* $XFree86$ */
+
+/*
+ * ISO-8859-14
+ */
+
+static const unsigned short iso8859_14_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0x1e02, 0x1e03, 0x00a3, 0x010a, 0x010b, 0x1e0a, 0x00a7,
+ 0x1e80, 0x00a9, 0x1e82, 0x1e0b, 0x1ef2, 0x00ad, 0x00ae, 0x0178,
+ /* 0xb0 */
+ 0x1e1e, 0x1e1f, 0x0120, 0x0121, 0x1e40, 0x1e41, 0x00b6, 0x1e56,
+ 0x1e81, 0x1e57, 0x1e83, 0x1e60, 0x1ef3, 0x1e84, 0x1e85, 0x1e61,
+ /* 0xc0 */
+ 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
+ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+ /* 0xd0 */
+ 0x0174, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x1e6a,
+ 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x0176, 0x00df,
+ /* 0xe0 */
+ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+ /* 0xf0 */
+ 0x0175, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x1e6b,
+ 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x0177, 0x00ff,
+};
+
+static int
+iso8859_14_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c >= 0xa0)
+ *pwc = (ucs4_t) iso8859_14_2uni[c-0xa0];
+ else
+ *pwc = (ucs4_t) c;
+ return 1;
+}
+
+static const unsigned char iso8859_14_page00[96] = {
+ 0xa0, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, 0xa7, /* 0xa0-0xa7 */
+ 0x00, 0xa9, 0x00, 0x00, 0x00, 0xad, 0xae, 0x00, /* 0xa8-0xaf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb6, 0x00, /* 0xb0-0xb7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0-0xc7 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */
+ 0x00, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0x00, /* 0xd0-0xd7 */
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0x00, 0xdf, /* 0xd8-0xdf */
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0-0xe7 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */
+ 0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0x00, /* 0xf0-0xf7 */
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0x00, 0xff, /* 0xf8-0xff */
+};
+static const unsigned char iso8859_14_page01_0[32] = {
+ 0x00, 0x00, 0xa4, 0xa5, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0xb2, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+};
+static const unsigned char iso8859_14_page01_1[16] = {
+ 0x00, 0x00, 0x00, 0x00, 0xd0, 0xf0, 0xde, 0xfe, /* 0x70-0x77 */
+ 0xaf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+};
+static const unsigned char iso8859_14_page1e_0[136] = {
+ 0x00, 0x00, 0xa1, 0xa2, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */
+ 0x00, 0x00, 0xa6, 0xab, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0xb1, /* 0x18-0x1f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0xb4, 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, 0xb9, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0xbb, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0xd7, 0xf7, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+ 0xa8, 0xb8, 0xaa, 0xba, 0xbd, 0xbe, 0x00, 0x00, /* 0x80-0x87 */
+};
+static const unsigned char iso8859_14_page1e_1[8] = {
+ 0x00, 0x00, 0xac, 0xbc, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */
+};
+
+static int
+iso8859_14_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x0100)
+ c = iso8859_14_page00[wc-0x00a0];
+ else if (wc >= 0x0108 && wc < 0x0128)
+ c = iso8859_14_page01_0[wc-0x0108];
+ else if (wc >= 0x0170 && wc < 0x0180)
+ c = iso8859_14_page01_1[wc-0x0170];
+ else if (wc >= 0x1e00 && wc < 0x1e88)
+ c = iso8859_14_page1e_0[wc-0x1e00];
+ else if (wc >= 0x1ef0 && wc < 0x1ef8)
+ c = iso8859_14_page1e_1[wc-0x1ef0];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_15.h b/nx-X11/lib/X11/lcUniConv/iso8859_15.h
new file mode 100644
index 000000000..209ca21b8
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_15.h
@@ -0,0 +1,63 @@
+/* $XFree86$ */
+
+/*
+ * ISO-8859-15
+ */
+
+static const unsigned short iso8859_15_2uni[32] = {
+ /* 0xa0 */
+ 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x0160, 0x00a7,
+ 0x0161, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+ /* 0xb0 */
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x017d, 0x00b5, 0x00b6, 0x00b7,
+ 0x017e, 0x00b9, 0x00ba, 0x00bb, 0x0152, 0x0153, 0x0178, 0x00bf,
+};
+
+static int
+iso8859_15_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c >= 0xa0 && c < 0xc0)
+ *pwc = (ucs4_t) iso8859_15_2uni[c-0xa0];
+ else
+ *pwc = (ucs4_t) c;
+ return 1;
+}
+
+static const unsigned char iso8859_15_page00[32] = {
+ 0xa0, 0xa1, 0xa2, 0xa3, 0x00, 0xa5, 0x00, 0xa7, /* 0xa0-0xa7 */
+ 0x00, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */
+ 0xb0, 0xb1, 0xb2, 0xb3, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
+ 0x00, 0xb9, 0xba, 0xbb, 0x00, 0x00, 0x00, 0xbf, /* 0xb8-0xbf */
+};
+static const unsigned char iso8859_15_page01[48] = {
+ 0x00, 0x00, 0xbc, 0xbd, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0xa6, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0xbe, 0x00, 0x00, 0x00, 0x00, 0xb4, 0xb8, 0x00, /* 0x78-0x7f */
+};
+
+static int
+iso8859_15_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x00c0)
+ c = iso8859_15_page00[wc-0x00a0];
+ else if (wc >= 0x00c0 && wc < 0x0100)
+ c = wc;
+ else if (wc >= 0x0150 && wc < 0x0180)
+ c = iso8859_15_page01[wc-0x0150];
+ else if (wc == 0x20ac)
+ c = 0xa4;
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_16.h b/nx-X11/lib/X11/lcUniConv/iso8859_16.h
new file mode 100644
index 000000000..657e4450d
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_16.h
@@ -0,0 +1,98 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_16.h,v 1.3 2000/11/29 17:40:31 dawes Exp $ */
+
+/*
+ * ISO-8859-16
+ */
+
+static const unsigned short iso8859_16_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0x0104, 0x0105, 0x0141, 0x20ac, 0x201e, 0x0160, 0x00a7,
+ 0x0161, 0x00a9, 0x0218, 0x00ab, 0x0179, 0x00ad, 0x017a, 0x017b,
+ /* 0xb0 */
+ 0x00b0, 0x00b1, 0x010c, 0x0142, 0x017d, 0x201d, 0x00b6, 0x00b7,
+ 0x017e, 0x010d, 0x0219, 0x00bb, 0x0152, 0x0153, 0x0178, 0x017c,
+ /* 0xc0 */
+ 0x00c0, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0106, 0x00c6, 0x00c7,
+ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+ /* 0xd0 */
+ 0x0110, 0x0143, 0x00d2, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x015a,
+ 0x0170, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0118, 0x021a, 0x00df,
+ /* 0xe0 */
+ 0x00e0, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x0107, 0x00e6, 0x00e7,
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+ /* 0xf0 */
+ 0x0111, 0x0144, 0x00f2, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x015b,
+ 0x0171, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0119, 0x021b, 0x00ff,
+};
+
+static int
+iso8859_16_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0xa0)
+ *pwc = (ucs4_t) c;
+ else
+ *pwc = (ucs4_t) iso8859_16_2uni[c-0xa0];
+ return 1;
+}
+
+static const unsigned char iso8859_16_page00[224] = {
+ 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, /* 0xa0-0xa7 */
+ 0x00, 0xa9, 0x00, 0xab, 0x00, 0xad, 0x00, 0x00, /* 0xa8-0xaf */
+ 0xb0, 0xb1, 0x00, 0x00, 0x00, 0x00, 0xb6, 0xb7, /* 0xb0-0xb7 */
+ 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+ 0xc0, 0xc1, 0xc2, 0x00, 0xc4, 0x00, 0xc6, 0xc7, /* 0xc0-0xc7 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */
+ 0x00, 0x00, 0xd2, 0xd3, 0xd4, 0x00, 0xd6, 0x00, /* 0xd0-0xd7 */
+ 0x00, 0xd9, 0xda, 0xdb, 0xdc, 0x00, 0x00, 0xdf, /* 0xd8-0xdf */
+ 0xe0, 0xe1, 0xe2, 0x00, 0xe4, 0x00, 0xe6, 0xe7, /* 0xe0-0xe7 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */
+ 0x00, 0x00, 0xf2, 0xf3, 0xf4, 0x00, 0xf6, 0x00, /* 0xf0-0xf7 */
+ 0x00, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0x00, 0xff, /* 0xf8-0xff */
+ /* 0x0100 */
+ 0x00, 0x00, 0xc3, 0xe3, 0xa1, 0xa2, 0xc5, 0xe5, /* 0x00-0x07 */
+ 0x00, 0x00, 0x00, 0x00, 0xb2, 0xb9, 0x00, 0x00, /* 0x08-0x0f */
+ 0xd0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0xdd, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0xa3, 0xb3, 0xd1, 0xf1, 0x00, 0x00, 0x00, /* 0x40-0x47 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
+ 0xd5, 0xf5, 0xbc, 0xbd, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0xd7, 0xf7, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0xa6, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0xd8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0xbe, 0xac, 0xae, 0xaf, 0xbf, 0xb4, 0xb8, 0x00, /* 0x78-0x7f */
+};
+static const unsigned char iso8859_16_page02[8] = {
+ 0xaa, 0xba, 0xde, 0xfe, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+};
+static const unsigned char iso8859_16_page20[8] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, 0xa5, 0x00, /* 0x18-0x1f */
+};
+
+static int
+iso8859_16_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x0180)
+ c = iso8859_16_page00[wc-0x00a0];
+ else if (wc >= 0x0218 && wc < 0x0220)
+ c = iso8859_16_page02[wc-0x0218];
+ else if (wc >= 0x2018 && wc < 0x2020)
+ c = iso8859_16_page20[wc-0x2018];
+ else if (wc == 0x20ac)
+ c = 0xa4;
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_2.h b/nx-X11/lib/X11/lcUniConv/iso8859_2.h
new file mode 100644
index 000000000..67abd8556
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_2.h
@@ -0,0 +1,94 @@
+/* $XFree86$ */
+
+/*
+ * ISO-8859-2
+ */
+
+static const unsigned short iso8859_2_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7,
+ 0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b,
+ /* 0xb0 */
+ 0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7,
+ 0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c,
+ /* 0xc0 */
+ 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7,
+ 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e,
+ /* 0xd0 */
+ 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7,
+ 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
+ /* 0xe0 */
+ 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7,
+ 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
+ /* 0xf0 */
+ 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7,
+ 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9,
+};
+
+static int
+iso8859_2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0xa0)
+ *pwc = (ucs4_t) c;
+ else
+ *pwc = (ucs4_t) iso8859_2_2uni[c-0xa0];
+ return 1;
+}
+
+static const unsigned char iso8859_2_page00[224] = {
+ 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0xa7, /* 0xa0-0xa7 */
+ 0xa8, 0x00, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, /* 0xa8-0xaf */
+ 0xb0, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
+ 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+ 0x00, 0xc1, 0xc2, 0x00, 0xc4, 0x00, 0x00, 0xc7, /* 0xc0-0xc7 */
+ 0x00, 0xc9, 0x00, 0xcb, 0x00, 0xcd, 0xce, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0xd3, 0xd4, 0x00, 0xd6, 0xd7, /* 0xd0-0xd7 */
+ 0x00, 0x00, 0xda, 0x00, 0xdc, 0xdd, 0x00, 0xdf, /* 0xd8-0xdf */
+ 0x00, 0xe1, 0xe2, 0x00, 0xe4, 0x00, 0x00, 0xe7, /* 0xe0-0xe7 */
+ 0x00, 0xe9, 0x00, 0xeb, 0x00, 0xed, 0xee, 0x00, /* 0xe8-0xef */
+ 0x00, 0x00, 0x00, 0xf3, 0xf4, 0x00, 0xf6, 0xf7, /* 0xf0-0xf7 */
+ 0x00, 0x00, 0xfa, 0x00, 0xfc, 0xfd, 0x00, 0x00, /* 0xf8-0xff */
+ /* 0x0100 */
+ 0x00, 0x00, 0xc3, 0xe3, 0xa1, 0xb1, 0xc6, 0xe6, /* 0x00-0x07 */
+ 0x00, 0x00, 0x00, 0x00, 0xc8, 0xe8, 0xcf, 0xef, /* 0x08-0x0f */
+ 0xd0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0xca, 0xea, 0xcc, 0xec, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0xc5, 0xe5, 0x00, 0x00, 0xa5, 0xb5, 0x00, /* 0x38-0x3f */
+ 0x00, 0xa3, 0xb3, 0xd1, 0xf1, 0x00, 0x00, 0xd2, /* 0x40-0x47 */
+ 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
+ 0xd5, 0xf5, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, /* 0x50-0x57 */
+ 0xd8, 0xf8, 0xa6, 0xb6, 0x00, 0x00, 0xaa, 0xba, /* 0x58-0x5f */
+ 0xa9, 0xb9, 0xde, 0xfe, 0xab, 0xbb, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd9, 0xf9, /* 0x68-0x6f */
+ 0xdb, 0xfb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0xac, 0xbc, 0xaf, 0xbf, 0xae, 0xbe, 0x00, /* 0x78-0x7f */
+};
+static const unsigned char iso8859_2_page02[32] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+ 0xa2, 0xff, 0x00, 0xb2, 0x00, 0xbd, 0x00, 0x00, /* 0xd8-0xdf */
+};
+
+static int
+iso8859_2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x0180)
+ c = iso8859_2_page00[wc-0x00a0];
+ else if (wc >= 0x02c0 && wc < 0x02e0)
+ c = iso8859_2_page02[wc-0x02c0];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_3.h b/nx-X11/lib/X11/lcUniConv/iso8859_3.h
new file mode 100644
index 000000000..399b7906a
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_3.h
@@ -0,0 +1,100 @@
+/* $XFree86$ */
+
+/*
+ * ISO-8859-3
+ */
+
+static const unsigned short iso8859_3_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0x0126, 0x02d8, 0x00a3, 0x00a4, 0xfffd, 0x0124, 0x00a7,
+ 0x00a8, 0x0130, 0x015e, 0x011e, 0x0134, 0x00ad, 0xfffd, 0x017b,
+ /* 0xb0 */
+ 0x00b0, 0x0127, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x0125, 0x00b7,
+ 0x00b8, 0x0131, 0x015f, 0x011f, 0x0135, 0x00bd, 0xfffd, 0x017c,
+ /* 0xc0 */
+ 0x00c0, 0x00c1, 0x00c2, 0xfffd, 0x00c4, 0x010a, 0x0108, 0x00c7,
+ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+ /* 0xd0 */
+ 0xfffd, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x0120, 0x00d6, 0x00d7,
+ 0x011c, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x016c, 0x015c, 0x00df,
+ /* 0xe0 */
+ 0x00e0, 0x00e1, 0x00e2, 0xfffd, 0x00e4, 0x010b, 0x0109, 0x00e7,
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+ /* 0xf0 */
+ 0xfffd, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x0121, 0x00f6, 0x00f7,
+ 0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9,
+};
+
+static int
+iso8859_3_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0xa0) {
+ *pwc = (ucs4_t) c;
+ return 1;
+ }
+ else {
+ unsigned short wc = iso8859_3_2uni[c-0xa0];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 1;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned char iso8859_3_page00[96] = {
+ 0xa0, 0x00, 0x00, 0xa3, 0xa4, 0x00, 0x00, 0xa7, /* 0xa0-0xa7 */
+ 0xa8, 0x00, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, /* 0xa8-0xaf */
+ 0xb0, 0x00, 0xb2, 0xb3, 0xb4, 0xb5, 0x00, 0xb7, /* 0xb0-0xb7 */
+ 0xb8, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, /* 0xb8-0xbf */
+ 0xc0, 0xc1, 0xc2, 0x00, 0xc4, 0x00, 0x00, 0xc7, /* 0xc0-0xc7 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */
+ 0x00, 0xd1, 0xd2, 0xd3, 0xd4, 0x00, 0xd6, 0xd7, /* 0xd0-0xd7 */
+ 0x00, 0xd9, 0xda, 0xdb, 0xdc, 0x00, 0x00, 0xdf, /* 0xd8-0xdf */
+ 0xe0, 0xe1, 0xe2, 0x00, 0xe4, 0x00, 0x00, 0xe7, /* 0xe0-0xe7 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */
+ 0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0x00, 0xf6, 0xf7, /* 0xf0-0xf7 */
+ 0x00, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0x00, 0x00, /* 0xf8-0xff */
+};
+static const unsigned char iso8859_3_page01[120] = {
+ 0xc6, 0xe6, 0xc5, 0xe5, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x00, 0x00, 0x00, 0x00, 0xd8, 0xf8, 0xab, 0xbb, /* 0x18-0x1f */
+ 0xd5, 0xf5, 0x00, 0x00, 0xa6, 0xb6, 0xa1, 0xb1, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0xa9, 0xb9, 0x00, 0x00, 0xac, 0xbc, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0xde, 0xfe, 0xaa, 0xba, /* 0x58-0x5f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0x00, 0x00, 0xdd, 0xfd, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x00, 0x00, 0xaf, 0xbf, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+};
+static const unsigned char iso8859_3_page02[8] = {
+ 0xa2, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+};
+
+static int
+iso8859_3_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x0100)
+ c = iso8859_3_page00[wc-0x00a0];
+ else if (wc >= 0x0108 && wc < 0x0180)
+ c = iso8859_3_page01[wc-0x0108];
+ else if (wc >= 0x02d8 && wc < 0x02e0)
+ c = iso8859_3_page02[wc-0x02d8];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_4.h b/nx-X11/lib/X11/lcUniConv/iso8859_4.h
new file mode 100644
index 000000000..f787fa858
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_4.h
@@ -0,0 +1,94 @@
+/* $XFree86$ */
+
+/*
+ * ISO-8859-4
+ */
+
+static const unsigned short iso8859_4_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0x0104, 0x0138, 0x0156, 0x00a4, 0x0128, 0x013b, 0x00a7,
+ 0x00a8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00ad, 0x017d, 0x00af,
+ /* 0xb0 */
+ 0x00b0, 0x0105, 0x02db, 0x0157, 0x00b4, 0x0129, 0x013c, 0x02c7,
+ 0x00b8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014a, 0x017e, 0x014b,
+ /* 0xc0 */
+ 0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e,
+ 0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x012a,
+ /* 0xd0 */
+ 0x0110, 0x0145, 0x014c, 0x0136, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
+ 0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x0168, 0x016a, 0x00df,
+ /* 0xe0 */
+ 0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f,
+ 0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x012b,
+ /* 0xf0 */
+ 0x0111, 0x0146, 0x014d, 0x0137, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
+ 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9,
+};
+
+static int
+iso8859_4_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0xa0)
+ *pwc = (ucs4_t) c;
+ else
+ *pwc = (ucs4_t) iso8859_4_2uni[c-0xa0];
+ return 1;
+}
+
+static const unsigned char iso8859_4_page00[224] = {
+ 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0xa7, /* 0xa0-0xa7 */
+ 0xa8, 0x00, 0x00, 0x00, 0x00, 0xad, 0x00, 0xaf, /* 0xa8-0xaf */
+ 0xb0, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
+ 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+ 0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0xc9, 0x00, 0xcb, 0x00, 0xcd, 0xce, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0x00, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xd0-0xd7 */
+ 0xd8, 0x00, 0xda, 0xdb, 0xdc, 0x00, 0x00, 0xdf, /* 0xd8-0xdf */
+ 0x00, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0x00, /* 0xe0-0xe7 */
+ 0x00, 0xe9, 0x00, 0xeb, 0x00, 0xed, 0xee, 0x00, /* 0xe8-0xef */
+ 0x00, 0x00, 0x00, 0x00, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xf0-0xf7 */
+ 0xf8, 0x00, 0xfa, 0xfb, 0xfc, 0x00, 0x00, 0x00, /* 0xf8-0xff */
+ /* 0x0100 */
+ 0xc0, 0xe0, 0x00, 0x00, 0xa1, 0xb1, 0x00, 0x00, /* 0x00-0x07 */
+ 0x00, 0x00, 0x00, 0x00, 0xc8, 0xe8, 0x00, 0x00, /* 0x08-0x0f */
+ 0xd0, 0xf0, 0xaa, 0xba, 0x00, 0x00, 0xcc, 0xec, /* 0x10-0x17 */
+ 0xca, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0xab, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0xa5, 0xb5, 0xcf, 0xef, 0x00, 0x00, 0xc7, 0xe7, /* 0x28-0x2f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd3, 0xf3, /* 0x30-0x37 */
+ 0xa2, 0x00, 0x00, 0xa6, 0xb6, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xf1, 0x00, /* 0x40-0x47 */
+ 0x00, 0x00, 0xbd, 0xbf, 0xd2, 0xf2, 0x00, 0x00, /* 0x48-0x4f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa3, 0xb3, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0xa9, 0xb9, 0x00, 0x00, 0x00, 0x00, 0xac, 0xbc, /* 0x60-0x67 */
+ 0xdd, 0xfd, 0xde, 0xfe, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0xd9, 0xf9, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xae, 0xbe, 0x00, /* 0x78-0x7f */
+};
+static const unsigned char iso8859_4_page02[32] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+ 0x00, 0xff, 0x00, 0xb2, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+};
+
+static int
+iso8859_4_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x0180)
+ c = iso8859_4_page00[wc-0x00a0];
+ else if (wc >= 0x02c0 && wc < 0x02e0)
+ c = iso8859_4_page02[wc-0x02c0];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_5.h b/nx-X11/lib/X11/lcUniConv/iso8859_5.h
new file mode 100644
index 000000000..4a2e46e59
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_5.h
@@ -0,0 +1,77 @@
+/* $XFree86$ */
+
+/*
+ * ISO-8859-5
+ */
+
+static const unsigned short iso8859_5_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x00ad, 0x040e, 0x040f,
+ /* 0xb0 */
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+ 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
+ /* 0xc0 */
+ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+ 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
+ /* 0xd0 */
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+ 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
+ /* 0xe0 */
+ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+ 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
+ /* 0xf0 */
+ 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x00a7, 0x045e, 0x045f,
+};
+
+static int
+iso8859_5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0xa0)
+ *pwc = (ucs4_t) c;
+ else
+ *pwc = (ucs4_t) iso8859_5_2uni[c-0xa0];
+ return 1;
+}
+
+static const unsigned char iso8859_5_page00[16] = {
+ 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, /* 0xa0-0xa7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, /* 0xa8-0xaf */
+};
+static const unsigned char iso8859_5_page04[96] = {
+ 0x00, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0x00-0x07 */
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0x00, 0xae, 0xaf, /* 0x08-0x0f */
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0x10-0x17 */
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* 0x18-0x1f */
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x20-0x27 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x28-0x2f */
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x30-0x37 */
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0x38-0x3f */
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x40-0x47 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x48-0x4f */
+ 0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x50-0x57 */
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0xfe, 0xff, /* 0x58-0x5f */
+};
+
+static int
+iso8859_5_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x00b0)
+ c = iso8859_5_page00[wc-0x00a0];
+ else if (wc >= 0x0400 && wc < 0x0460)
+ c = iso8859_5_page04[wc-0x0400];
+ else if (wc == 0x2116)
+ c = 0xf0;
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_6.h b/nx-X11/lib/X11/lcUniConv/iso8859_6.h
new file mode 100644
index 000000000..22c667139
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_6.h
@@ -0,0 +1,80 @@
+/* $XFree86$ */
+
+/*
+ * ISO-8859-6
+ */
+
+static const unsigned short iso8859_6_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0xfffd, 0xfffd, 0xfffd, 0x00a4, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x060c, 0x00ad, 0xfffd, 0xfffd,
+ /* 0xb0 */
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0x061b, 0xfffd, 0xfffd, 0xfffd, 0x061f,
+ /* 0xc0 */
+ 0xfffd, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
+ 0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f,
+ /* 0xd0 */
+ 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637,
+ 0x0638, 0x0639, 0x063a, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0xe0 */
+ 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647,
+ 0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f,
+ /* 0xf0 */
+ 0x0650, 0x0651, 0x0652, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+};
+
+static int
+iso8859_6_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0xa0) {
+ *pwc = (ucs4_t) c;
+ return 1;
+ }
+ else {
+ unsigned short wc = iso8859_6_2uni[c-0xa0];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 1;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned char iso8859_6_page00[16] = {
+ 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, /* 0xa8-0xaf */
+};
+static const unsigned char iso8859_6_page06[80] = {
+ 0x00, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, /* 0x08-0x0f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0xbf, /* 0x18-0x1f */
+ 0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x20-0x27 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x28-0x2f */
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x30-0x37 */
+ 0xd8, 0xd9, 0xda, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x40-0x47 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x48-0x4f */
+ 0xf0, 0xf1, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+};
+
+static int
+iso8859_6_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x00b0)
+ c = iso8859_6_page00[wc-0x00a0];
+ else if (wc >= 0x0608 && wc < 0x0658)
+ c = iso8859_6_page06[wc-0x0608];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_7.h b/nx-X11/lib/X11/lcUniConv/iso8859_7.h
new file mode 100644
index 000000000..2fb38cae1
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_7.h
@@ -0,0 +1,88 @@
+/* $XFree86$ */
+
+/*
+ * ISO-8859-7
+ */
+
+static const unsigned short iso8859_7_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0x2018, 0x2019, 0x00a3, 0xfffd, 0xfffd, 0x00a6, 0x00a7,
+ 0x00a8, 0x00a9, 0xfffd, 0x00ab, 0x00ac, 0x00ad, 0xfffd, 0x2015,
+ /* 0xb0 */
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x0384, 0x0385, 0x0386, 0x00b7,
+ 0x0388, 0x0389, 0x038a, 0x00bb, 0x038c, 0x00bd, 0x038e, 0x038f,
+ /* 0xc0 */
+ 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+ 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f,
+ /* 0xd0 */
+ 0x03a0, 0x03a1, 0xfffd, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7,
+ 0x03a8, 0x03a9, 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03ae, 0x03af,
+ /* 0xe0 */
+ 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7,
+ 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
+ /* 0xf0 */
+ 0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7,
+ 0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0xfffd,
+};
+
+static int
+iso8859_7_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0xa0) {
+ *pwc = (ucs4_t) c;
+ return 1;
+ }
+ else {
+ unsigned short wc = iso8859_7_2uni[c-0xa0];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 1;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned char iso8859_7_page00[32] = {
+ 0xa0, 0x00, 0x00, 0xa3, 0x00, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */
+ 0xa8, 0xa9, 0x00, 0xab, 0xac, 0xad, 0x00, 0x00, /* 0xa8-0xaf */
+ 0xb0, 0xb1, 0xb2, 0xb3, 0x00, 0x00, 0x00, 0xb7, /* 0xb0-0xb7 */
+ 0x00, 0x00, 0x00, 0xbb, 0x00, 0xbd, 0x00, 0x00, /* 0xb8-0xbf */
+};
+static const unsigned char iso8859_7_page03[80] = {
+ 0x00, 0x00, 0x00, 0x00, 0xb4, 0xb5, 0xb6, 0x00, /* 0x80-0x87 */
+ 0xb8, 0xb9, 0xba, 0x00, 0xbc, 0x00, 0xbe, 0xbf, /* 0x88-0x8f */
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x90-0x97 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x98-0x9f */
+ 0xd0, 0xd1, 0x00, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xa0-0xa7 */
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0xa8-0xaf */
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xb0-0xb7 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xb8-0xbf */
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xc0-0xc7 */
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0x00, /* 0xc8-0xcf */
+};
+static const unsigned char iso8859_7_page20[16] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, /* 0x10-0x17 */
+ 0xa1, 0xa2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+};
+
+static int
+iso8859_7_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x00c0)
+ c = iso8859_7_page00[wc-0x00a0];
+ else if (wc >= 0x0380 && wc < 0x03d0)
+ c = iso8859_7_page03[wc-0x0380];
+ else if (wc >= 0x2010 && wc < 0x2020)
+ c = iso8859_7_page20[wc-0x2010];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_8.h b/nx-X11/lib/X11/lcUniConv/iso8859_8.h
new file mode 100644
index 000000000..e9d77a22d
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_8.h
@@ -0,0 +1,89 @@
+/* $XFree86$ */
+
+/*
+ * ISO-8859-8
+ */
+
+static const unsigned short iso8859_8_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0xfffd, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
+ 0x00a8, 0x00a9, 0x00d7, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+ /* 0xb0 */
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
+ 0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0xfffd,
+ /* 0xc0 */
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0xd0 */
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x2017,
+ /* 0xe0 */
+ 0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7,
+ 0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
+ /* 0xf0 */
+ 0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7,
+ 0x05e8, 0x05e9, 0x05ea, 0xfffd, 0xfffd, 0x200e, 0x200f, 0xfffd,
+};
+
+static int
+iso8859_8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c >= 0xa0) {
+ unsigned short wc = iso8859_8_2uni[c-0xa0];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 1;
+ }
+ }
+ else {
+ *pwc = (ucs4_t) c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned char iso8859_8_page00[88] = {
+ 0xa0, 0x00, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0xa0-0xa7 */
+ 0xa8, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
+ 0xb8, 0xb9, 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0x00, /* 0xb8-0xbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, /* 0xd0-0xd7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, /* 0xf0-0xf7 */
+};
+static const unsigned char iso8859_8_page05[32] = {
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xd0-0xd7 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xd8-0xdf */
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xe0-0xe7 */
+ 0xf8, 0xf9, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
+};
+static const unsigned char iso8859_8_page20[16] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, 0xfe, /* 0x08-0x0f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdf, /* 0x10-0x17 */
+};
+
+static int
+iso8859_8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x00f8)
+ c = iso8859_8_page00[wc-0x00a0];
+ else if (wc >= 0x05d0 && wc < 0x05f0)
+ c = iso8859_8_page05[wc-0x05d0];
+ else if (wc >= 0x2008 && wc < 0x2018)
+ c = iso8859_8_page20[wc-0x2008];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_9.h b/nx-X11/lib/X11/lcUniConv/iso8859_9.h
new file mode 100644
index 000000000..662992d07
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_9.h
@@ -0,0 +1,67 @@
+/* $XFree86$ */
+
+/*
+ * ISO-8859-9
+ */
+
+static const unsigned short iso8859_9_2uni[48] = {
+ /* 0xd0 */
+ 0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
+ 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df,
+ /* 0xe0 */
+ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+ /* 0xf0 */
+ 0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
+ 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff,
+};
+
+static int
+iso8859_9_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c >= 0xd0)
+ *pwc = (ucs4_t) iso8859_9_2uni[c-0xd0];
+ else
+ *pwc = (ucs4_t) c;
+ return 1;
+}
+
+static const unsigned char iso8859_9_page00[48] = {
+ 0x00, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xd0-0xd7 */
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0x00, 0x00, 0xdf, /* 0xd8-0xdf */
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0-0xe7 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */
+ 0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xf0-0xf7 */
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0x00, 0xff, /* 0xf8-0xff */
+};
+static const unsigned char iso8859_9_page01[72] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0xf0, /* 0x18-0x1f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0xdd, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xfe, /* 0x58-0x5f */
+};
+
+static int
+iso8859_9_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00d0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00d0 && wc < 0x0100)
+ c = iso8859_9_page00[wc-0x00d0];
+ else if (wc >= 0x0118 && wc < 0x0160)
+ c = iso8859_9_page01[wc-0x0118];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/iso8859_9e.h b/nx-X11/lib/X11/lcUniConv/iso8859_9e.h
new file mode 100644
index 000000000..17ff75b03
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/iso8859_9e.h
@@ -0,0 +1,103 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_9e.h,v 1.2 2000/11/02 19:10:45 dawes Exp $ */
+
+/*
+ * ISO-8859-9E
+ */
+
+static const unsigned short iso8859_9e_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0x017d, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x012c, 0x00a7,
+ 0x016c, 0x00a9, 0x01e6, 0x00ab, 0x014a, 0x00ad, 0x00ae, 0x01d1,
+ /* 0xb0 */
+ 0x00b0, 0x017e, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x012d, 0x00b7,
+ 0x016d, 0x00b9, 0x01e7, 0x00bb, 0x014b, 0x00bd, 0x0178, 0x01d2,
+ /* 0xc0 */
+ 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x018f, 0x00c7,
+ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+ /* 0xd0 */
+ 0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00dd,
+ 0x019f, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df,
+ /* 0xe0 */
+ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x0259, 0x00e7,
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+ /* 0xf0 */
+ 0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00fd,
+ 0x0275, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff,
+};
+
+static int
+iso8859_9e_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c >= 0xa0)
+ *pwc = (ucs4_t) iso8859_9e_2uni[c-0xa0];
+ else
+ *pwc = (ucs4_t) c;
+ return 1;
+}
+
+static const unsigned char iso8859_9e_page00[96] = {
+ 0xa0, 0x00, 0xa2, 0xa3, 0x00, 0xa5, 0x00, 0xa7, /* 0xa0-0xa7 */
+ 0x00, 0xa9, 0x00, 0xab, 0x00, 0xad, 0xae, 0x00, /* 0xa8-0xaf */
+ 0xb0, 0x00, 0xb2, 0xb3, 0xb4, 0xb5, 0x00, 0xb7, /* 0xb0-0xb7 */
+ 0x00, 0xb9, 0x00, 0xbb, 0x00, 0xbd, 0x00, 0x00, /* 0xb8-0xbf */
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0x00, 0xc7, /* 0xc0-0xc7 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */
+ 0x00, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0x00, /* 0xd0-0xd7 */
+ 0x00, 0xd9, 0xda, 0xdb, 0xdc, 0xd7, 0x00, 0xdf, /* 0xd8-0xdf */
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0x00, 0xe7, /* 0xe0-0xe7 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */
+ 0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0x00, /* 0xf0-0xf7 */
+ 0x00, 0xf9, 0xfa, 0xfb, 0xfc, 0xf7, 0x00, 0xff, /* 0xf8-0xff */
+};
+static const unsigned char iso8859_9e_page01[136] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0xf0, /* 0x18-0x1f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0xa6, 0xb6, 0x00, 0x00, /* 0x28-0x2f */
+ 0xdd, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
+ 0x00, 0x00, 0xac, 0xbc, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xfe, /* 0x58-0x5f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0x00, 0x00, 0xa8, 0xb8, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0xbe, 0x00, 0x00, 0x00, 0x00, 0xa1, 0xb1, 0x00, /* 0x78-0x7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, /* 0x88-0x8f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, /* 0x98-0x9f */
+};
+static const unsigned char iso8859_9e_page01_d[24] = {
+ 0x00, 0xaf, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xba, /* 0xe0-0xe7 */
+};
+
+static int
+iso8859_9e_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x0100)
+ c = iso8859_9e_page00[wc-0x00a0];
+ else if (wc >= 0x0118 && wc < 0x01a0)
+ c = iso8859_9e_page01[wc-0x0118];
+ else if (wc >= 0x01d0 && wc < 0x01e8)
+ c = iso8859_9e_page01_d[wc-0x01d0];
+ else if (wc == 0x0259)
+ c = 0xe6;
+ else if (wc == 0x0275)
+ c = 0xf8;
+ else if (wc == 0x20ac)
+ c = 0xa4;
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/jisx0201.h b/nx-X11/lib/X11/lcUniConv/jisx0201.h
new file mode 100644
index 000000000..fec138a48
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/jisx0201.h
@@ -0,0 +1,48 @@
+/* $XFree86$ */
+
+/*
+ * JISX0201.1976-0
+ */
+
+static int
+jisx0201_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0x80) {
+ if (c == 0x5c)
+ *pwc = (ucs4_t) 0x00a5;
+ else if (c == 0x7e)
+ *pwc = (ucs4_t) 0x203e;
+ else
+ *pwc = (ucs4_t) c;
+ return 1;
+ } else {
+ if (c >= 0xa1 && c < 0xe0) {
+ *pwc = (ucs4_t) c + 0xfec0;
+ return 1;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static int
+jisx0201_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ if (wc < 0x0080 && !(wc == 0x005c || wc == 0x007e)) {
+ *r = wc;
+ return 1;
+ }
+ if (wc == 0x00a5) {
+ *r = 0x5c;
+ return 1;
+ }
+ if (wc == 0x203e) {
+ *r = 0x7e;
+ return 1;
+ }
+ if (wc >= 0xff61 && wc < 0xffa0) {
+ *r = wc - 0xfec0;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/jisx0208.h b/nx-X11/lib/X11/lcUniConv/jisx0208.h
new file mode 100644
index 000000000..4d8a8918a
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/jisx0208.h
@@ -0,0 +1,2397 @@
+/* $XFree86: xc/lib/X11/lcUniConv/jisx0208.h,v 1.5tsi Exp $ */
+
+/*
+ * JISX0208.1990-0
+ */
+
+static const unsigned short jisx0208_2uni_page21[690] = {
+ /* 0x21 */
+ 0x3000, 0x3001, 0x3002, 0xff0c, 0xff0e, 0x30fb, 0xff1a, 0xff1b,
+ 0xff1f, 0xff01, 0x309b, 0x309c, 0x00b4, 0xff40, 0x00a8, 0xff3e,
+ 0xffe3, 0xff3f, 0x30fd, 0x30fe, 0x309d, 0x309e, 0x3003, 0x4edd,
+ 0x3005, 0x3006, 0x3007, 0x30fc, 0x2015, 0x2010, 0xff0f, 0xff3c,
+ 0x301c, 0x2016, 0xff5c, 0x2026, 0x2025, 0x2018, 0x2019, 0x201c,
+ 0x201d, 0xff08, 0xff09, 0x3014, 0x3015, 0xff3b, 0xff3d, 0xff5b,
+ 0xff5d, 0x3008, 0x3009, 0x300a, 0x300b, 0x300c, 0x300d, 0x300e,
+ 0x300f, 0x3010, 0x3011, 0xff0b, 0x2212, 0x00b1, 0x00d7, 0x00f7,
+ 0xff1d, 0x2260, 0xff1c, 0xff1e, 0x2266, 0x2267, 0x221e, 0x2234,
+ 0x2642, 0x2640, 0x00b0, 0x2032, 0x2033, 0x2103, 0xffe5, 0xff04,
+ 0x00a2, 0x00a3, 0xff05, 0xff03, 0xff06, 0xff0a, 0xff20, 0x00a7,
+ 0x2606, 0x2605, 0x25cb, 0x25cf, 0x25ce, 0x25c7,
+ /* 0x22 */
+ 0x25c6, 0x25a1, 0x25a0, 0x25b3, 0x25b2, 0x25bd, 0x25bc, 0x203b,
+ 0x3012, 0x2192, 0x2190, 0x2191, 0x2193, 0x3013, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0x2208, 0x220b, 0x2286, 0x2287, 0x2282, 0x2283, 0x222a,
+ 0x2229, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0x2227, 0x2228, 0x00ac, 0x21d2, 0x21d4, 0x2200, 0x2203,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0x2220, 0x22a5, 0x2312, 0x2202, 0x2207,
+ 0x2261, 0x2252, 0x226a, 0x226b, 0x221a, 0x223d, 0x221d, 0x2235,
+ 0x222b, 0x222c, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0x212b, 0x2030, 0x266f, 0x266d, 0x266a, 0x2020, 0x2021,
+ 0x00b6, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x25ef,
+ /* 0x23 */
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xff10,
+ 0xff11, 0xff12, 0xff13, 0xff14, 0xff15, 0xff16, 0xff17, 0xff18,
+ 0xff19, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xff21, 0xff22, 0xff23, 0xff24, 0xff25, 0xff26, 0xff27, 0xff28,
+ 0xff29, 0xff2a, 0xff2b, 0xff2c, 0xff2d, 0xff2e, 0xff2f, 0xff30,
+ 0xff31, 0xff32, 0xff33, 0xff34, 0xff35, 0xff36, 0xff37, 0xff38,
+ 0xff39, 0xff3a, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xff41, 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48,
+ 0xff49, 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50,
+ 0xff51, 0xff52, 0xff53, 0xff54, 0xff55, 0xff56, 0xff57, 0xff58,
+ 0xff59, 0xff5a, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x24 */
+ 0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046, 0x3047, 0x3048,
+ 0x3049, 0x304a, 0x304b, 0x304c, 0x304d, 0x304e, 0x304f, 0x3050,
+ 0x3051, 0x3052, 0x3053, 0x3054, 0x3055, 0x3056, 0x3057, 0x3058,
+ 0x3059, 0x305a, 0x305b, 0x305c, 0x305d, 0x305e, 0x305f, 0x3060,
+ 0x3061, 0x3062, 0x3063, 0x3064, 0x3065, 0x3066, 0x3067, 0x3068,
+ 0x3069, 0x306a, 0x306b, 0x306c, 0x306d, 0x306e, 0x306f, 0x3070,
+ 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076, 0x3077, 0x3078,
+ 0x3079, 0x307a, 0x307b, 0x307c, 0x307d, 0x307e, 0x307f, 0x3080,
+ 0x3081, 0x3082, 0x3083, 0x3084, 0x3085, 0x3086, 0x3087, 0x3088,
+ 0x3089, 0x308a, 0x308b, 0x308c, 0x308d, 0x308e, 0x308f, 0x3090,
+ 0x3091, 0x3092, 0x3093, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x25 */
+ 0x30a1, 0x30a2, 0x30a3, 0x30a4, 0x30a5, 0x30a6, 0x30a7, 0x30a8,
+ 0x30a9, 0x30aa, 0x30ab, 0x30ac, 0x30ad, 0x30ae, 0x30af, 0x30b0,
+ 0x30b1, 0x30b2, 0x30b3, 0x30b4, 0x30b5, 0x30b6, 0x30b7, 0x30b8,
+ 0x30b9, 0x30ba, 0x30bb, 0x30bc, 0x30bd, 0x30be, 0x30bf, 0x30c0,
+ 0x30c1, 0x30c2, 0x30c3, 0x30c4, 0x30c5, 0x30c6, 0x30c7, 0x30c8,
+ 0x30c9, 0x30ca, 0x30cb, 0x30cc, 0x30cd, 0x30ce, 0x30cf, 0x30d0,
+ 0x30d1, 0x30d2, 0x30d3, 0x30d4, 0x30d5, 0x30d6, 0x30d7, 0x30d8,
+ 0x30d9, 0x30da, 0x30db, 0x30dc, 0x30dd, 0x30de, 0x30df, 0x30e0,
+ 0x30e1, 0x30e2, 0x30e3, 0x30e4, 0x30e5, 0x30e6, 0x30e7, 0x30e8,
+ 0x30e9, 0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ee, 0x30ef, 0x30f0,
+ 0x30f1, 0x30f2, 0x30f3, 0x30f4, 0x30f5, 0x30f6, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x26 */
+ 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398,
+ 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, 0x03a0,
+ 0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, 0x03b8,
+ 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, 0x03c0,
+ 0x03c1, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x27 */
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0401, 0x0416,
+ 0x0417, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e,
+ 0x041f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426,
+ 0x0427, 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e,
+ 0x042f, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0451, 0x0436,
+ 0x0437, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e,
+ 0x043f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446,
+ 0x0447, 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e,
+ 0x044f, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x28 */
+ 0x2500, 0x2502, 0x250c, 0x2510, 0x2518, 0x2514, 0x251c, 0x252c,
+ 0x2524, 0x2534, 0x253c, 0x2501, 0x2503, 0x250f, 0x2513, 0x251b,
+ 0x2517, 0x2523, 0x2533, 0x252b, 0x253b, 0x254b, 0x2520, 0x252f,
+ 0x2528, 0x2537, 0x253f, 0x251d, 0x2530, 0x2525, 0x2538, 0x2542,
+};
+static const unsigned short jisx0208_2uni_page30[6398] = {
+ /* 0x30 */
+ 0x4e9c, 0x5516, 0x5a03, 0x963f, 0x54c0, 0x611b, 0x6328, 0x59f6,
+ 0x9022, 0x8475, 0x831c, 0x7a50, 0x60aa, 0x63e1, 0x6e25, 0x65ed,
+ 0x8466, 0x82a6, 0x9bf5, 0x6893, 0x5727, 0x65a1, 0x6271, 0x5b9b,
+ 0x59d0, 0x867b, 0x98f4, 0x7d62, 0x7dbe, 0x9b8e, 0x6216, 0x7c9f,
+ 0x88b7, 0x5b89, 0x5eb5, 0x6309, 0x6697, 0x6848, 0x95c7, 0x978d,
+ 0x674f, 0x4ee5, 0x4f0a, 0x4f4d, 0x4f9d, 0x5049, 0x56f2, 0x5937,
+ 0x59d4, 0x5a01, 0x5c09, 0x60df, 0x610f, 0x6170, 0x6613, 0x6905,
+ 0x70ba, 0x754f, 0x7570, 0x79fb, 0x7dad, 0x7def, 0x80c3, 0x840e,
+ 0x8863, 0x8b02, 0x9055, 0x907a, 0x533b, 0x4e95, 0x4ea5, 0x57df,
+ 0x80b2, 0x90c1, 0x78ef, 0x4e00, 0x58f1, 0x6ea2, 0x9038, 0x7a32,
+ 0x8328, 0x828b, 0x9c2f, 0x5141, 0x5370, 0x54bd, 0x54e1, 0x56e0,
+ 0x59fb, 0x5f15, 0x98f2, 0x6deb, 0x80e4, 0x852d,
+ /* 0x31 */
+ 0x9662, 0x9670, 0x96a0, 0x97fb, 0x540b, 0x53f3, 0x5b87, 0x70cf,
+ 0x7fbd, 0x8fc2, 0x96e8, 0x536f, 0x9d5c, 0x7aba, 0x4e11, 0x7893,
+ 0x81fc, 0x6e26, 0x5618, 0x5504, 0x6b1d, 0x851a, 0x9c3b, 0x59e5,
+ 0x53a9, 0x6d66, 0x74dc, 0x958f, 0x5642, 0x4e91, 0x904b, 0x96f2,
+ 0x834f, 0x990c, 0x53e1, 0x55b6, 0x5b30, 0x5f71, 0x6620, 0x66f3,
+ 0x6804, 0x6c38, 0x6cf3, 0x6d29, 0x745b, 0x76c8, 0x7a4e, 0x9834,
+ 0x82f1, 0x885b, 0x8a60, 0x92ed, 0x6db2, 0x75ab, 0x76ca, 0x99c5,
+ 0x60a6, 0x8b01, 0x8d8a, 0x95b2, 0x698e, 0x53ad, 0x5186, 0x5712,
+ 0x5830, 0x5944, 0x5bb4, 0x5ef6, 0x6028, 0x63a9, 0x63f4, 0x6cbf,
+ 0x6f14, 0x708e, 0x7114, 0x7159, 0x71d5, 0x733f, 0x7e01, 0x8276,
+ 0x82d1, 0x8597, 0x9060, 0x925b, 0x9d1b, 0x5869, 0x65bc, 0x6c5a,
+ 0x7525, 0x51f9, 0x592e, 0x5965, 0x5f80, 0x5fdc,
+ /* 0x32 */
+ 0x62bc, 0x65fa, 0x6a2a, 0x6b27, 0x6bb4, 0x738b, 0x7fc1, 0x8956,
+ 0x9d2c, 0x9d0e, 0x9ec4, 0x5ca1, 0x6c96, 0x837b, 0x5104, 0x5c4b,
+ 0x61b6, 0x81c6, 0x6876, 0x7261, 0x4e59, 0x4ffa, 0x5378, 0x6069,
+ 0x6e29, 0x7a4f, 0x97f3, 0x4e0b, 0x5316, 0x4eee, 0x4f55, 0x4f3d,
+ 0x4fa1, 0x4f73, 0x52a0, 0x53ef, 0x5609, 0x590f, 0x5ac1, 0x5bb6,
+ 0x5be1, 0x79d1, 0x6687, 0x679c, 0x67b6, 0x6b4c, 0x6cb3, 0x706b,
+ 0x73c2, 0x798d, 0x79be, 0x7a3c, 0x7b87, 0x82b1, 0x82db, 0x8304,
+ 0x8377, 0x83ef, 0x83d3, 0x8766, 0x8ab2, 0x5629, 0x8ca8, 0x8fe6,
+ 0x904e, 0x971e, 0x868a, 0x4fc4, 0x5ce8, 0x6211, 0x7259, 0x753b,
+ 0x81e5, 0x82bd, 0x86fe, 0x8cc0, 0x96c5, 0x9913, 0x99d5, 0x4ecb,
+ 0x4f1a, 0x89e3, 0x56de, 0x584a, 0x58ca, 0x5efb, 0x5feb, 0x602a,
+ 0x6094, 0x6062, 0x61d0, 0x6212, 0x62d0, 0x6539,
+ /* 0x33 */
+ 0x9b41, 0x6666, 0x68b0, 0x6d77, 0x7070, 0x754c, 0x7686, 0x7d75,
+ 0x82a5, 0x87f9, 0x958b, 0x968e, 0x8c9d, 0x51f1, 0x52be, 0x5916,
+ 0x54b3, 0x5bb3, 0x5d16, 0x6168, 0x6982, 0x6daf, 0x788d, 0x84cb,
+ 0x8857, 0x8a72, 0x93a7, 0x9ab8, 0x6d6c, 0x99a8, 0x86d9, 0x57a3,
+ 0x67ff, 0x86ce, 0x920e, 0x5283, 0x5687, 0x5404, 0x5ed3, 0x62e1,
+ 0x64b9, 0x683c, 0x6838, 0x6bbb, 0x7372, 0x78ba, 0x7a6b, 0x899a,
+ 0x89d2, 0x8d6b, 0x8f03, 0x90ed, 0x95a3, 0x9694, 0x9769, 0x5b66,
+ 0x5cb3, 0x697d, 0x984d, 0x984e, 0x639b, 0x7b20, 0x6a2b, 0x6a7f,
+ 0x68b6, 0x9c0d, 0x6f5f, 0x5272, 0x559d, 0x6070, 0x62ec, 0x6d3b,
+ 0x6e07, 0x6ed1, 0x845b, 0x8910, 0x8f44, 0x4e14, 0x9c39, 0x53f6,
+ 0x691b, 0x6a3a, 0x9784, 0x682a, 0x515c, 0x7ac3, 0x84b2, 0x91dc,
+ 0x938c, 0x565b, 0x9d28, 0x6822, 0x8305, 0x8431,
+ /* 0x34 */
+ 0x7ca5, 0x5208, 0x82c5, 0x74e6, 0x4e7e, 0x4f83, 0x51a0, 0x5bd2,
+ 0x520a, 0x52d8, 0x52e7, 0x5dfb, 0x559a, 0x582a, 0x59e6, 0x5b8c,
+ 0x5b98, 0x5bdb, 0x5e72, 0x5e79, 0x60a3, 0x611f, 0x6163, 0x61be,
+ 0x63db, 0x6562, 0x67d1, 0x6853, 0x68fa, 0x6b3e, 0x6b53, 0x6c57,
+ 0x6f22, 0x6f97, 0x6f45, 0x74b0, 0x7518, 0x76e3, 0x770b, 0x7aff,
+ 0x7ba1, 0x7c21, 0x7de9, 0x7f36, 0x7ff0, 0x809d, 0x8266, 0x839e,
+ 0x89b3, 0x8acc, 0x8cab, 0x9084, 0x9451, 0x9593, 0x9591, 0x95a2,
+ 0x9665, 0x97d3, 0x9928, 0x8218, 0x4e38, 0x542b, 0x5cb8, 0x5dcc,
+ 0x73a9, 0x764c, 0x773c, 0x5ca9, 0x7feb, 0x8d0b, 0x96c1, 0x9811,
+ 0x9854, 0x9858, 0x4f01, 0x4f0e, 0x5371, 0x559c, 0x5668, 0x57fa,
+ 0x5947, 0x5b09, 0x5bc4, 0x5c90, 0x5e0c, 0x5e7e, 0x5fcc, 0x63ee,
+ 0x673a, 0x65d7, 0x65e2, 0x671f, 0x68cb, 0x68c4,
+ /* 0x35 */
+ 0x6a5f, 0x5e30, 0x6bc5, 0x6c17, 0x6c7d, 0x757f, 0x7948, 0x5b63,
+ 0x7a00, 0x7d00, 0x5fbd, 0x898f, 0x8a18, 0x8cb4, 0x8d77, 0x8ecc,
+ 0x8f1d, 0x98e2, 0x9a0e, 0x9b3c, 0x4e80, 0x507d, 0x5100, 0x5993,
+ 0x5b9c, 0x622f, 0x6280, 0x64ec, 0x6b3a, 0x72a0, 0x7591, 0x7947,
+ 0x7fa9, 0x87fb, 0x8abc, 0x8b70, 0x63ac, 0x83ca, 0x97a0, 0x5409,
+ 0x5403, 0x55ab, 0x6854, 0x6a58, 0x8a70, 0x7827, 0x6775, 0x9ecd,
+ 0x5374, 0x5ba2, 0x811a, 0x8650, 0x9006, 0x4e18, 0x4e45, 0x4ec7,
+ 0x4f11, 0x53ca, 0x5438, 0x5bae, 0x5f13, 0x6025, 0x6551, 0x673d,
+ 0x6c42, 0x6c72, 0x6ce3, 0x7078, 0x7403, 0x7a76, 0x7aae, 0x7b08,
+ 0x7d1a, 0x7cfe, 0x7d66, 0x65e7, 0x725b, 0x53bb, 0x5c45, 0x5de8,
+ 0x62d2, 0x62e0, 0x6319, 0x6e20, 0x865a, 0x8a31, 0x8ddd, 0x92f8,
+ 0x6f01, 0x79a6, 0x9b5a, 0x4ea8, 0x4eab, 0x4eac,
+ /* 0x36 */
+ 0x4f9b, 0x4fa0, 0x50d1, 0x5147, 0x7af6, 0x5171, 0x51f6, 0x5354,
+ 0x5321, 0x537f, 0x53eb, 0x55ac, 0x5883, 0x5ce1, 0x5f37, 0x5f4a,
+ 0x602f, 0x6050, 0x606d, 0x631f, 0x6559, 0x6a4b, 0x6cc1, 0x72c2,
+ 0x72ed, 0x77ef, 0x80f8, 0x8105, 0x8208, 0x854e, 0x90f7, 0x93e1,
+ 0x97ff, 0x9957, 0x9a5a, 0x4ef0, 0x51dd, 0x5c2d, 0x6681, 0x696d,
+ 0x5c40, 0x66f2, 0x6975, 0x7389, 0x6850, 0x7c81, 0x50c5, 0x52e4,
+ 0x5747, 0x5dfe, 0x9326, 0x65a4, 0x6b23, 0x6b3d, 0x7434, 0x7981,
+ 0x79bd, 0x7b4b, 0x7dca, 0x82b9, 0x83cc, 0x887f, 0x895f, 0x8b39,
+ 0x8fd1, 0x91d1, 0x541f, 0x9280, 0x4e5d, 0x5036, 0x53e5, 0x533a,
+ 0x72d7, 0x7396, 0x77e9, 0x82e6, 0x8eaf, 0x99c6, 0x99c8, 0x99d2,
+ 0x5177, 0x611a, 0x865e, 0x55b0, 0x7a7a, 0x5076, 0x5bd3, 0x9047,
+ 0x9685, 0x4e32, 0x6adb, 0x91e7, 0x5c51, 0x5c48,
+ /* 0x37 */
+ 0x6398, 0x7a9f, 0x6c93, 0x9774, 0x8f61, 0x7aaa, 0x718a, 0x9688,
+ 0x7c82, 0x6817, 0x7e70, 0x6851, 0x936c, 0x52f2, 0x541b, 0x85ab,
+ 0x8a13, 0x7fa4, 0x8ecd, 0x90e1, 0x5366, 0x8888, 0x7941, 0x4fc2,
+ 0x50be, 0x5211, 0x5144, 0x5553, 0x572d, 0x73ea, 0x578b, 0x5951,
+ 0x5f62, 0x5f84, 0x6075, 0x6176, 0x6167, 0x61a9, 0x63b2, 0x643a,
+ 0x656c, 0x666f, 0x6842, 0x6e13, 0x7566, 0x7a3d, 0x7cfb, 0x7d4c,
+ 0x7d99, 0x7e4b, 0x7f6b, 0x830e, 0x834a, 0x86cd, 0x8a08, 0x8a63,
+ 0x8b66, 0x8efd, 0x981a, 0x9d8f, 0x82b8, 0x8fce, 0x9be8, 0x5287,
+ 0x621f, 0x6483, 0x6fc0, 0x9699, 0x6841, 0x5091, 0x6b20, 0x6c7a,
+ 0x6f54, 0x7a74, 0x7d50, 0x8840, 0x8a23, 0x6708, 0x4ef6, 0x5039,
+ 0x5026, 0x5065, 0x517c, 0x5238, 0x5263, 0x55a7, 0x570f, 0x5805,
+ 0x5acc, 0x5efa, 0x61b2, 0x61f8, 0x62f3, 0x6372,
+ /* 0x38 */
+ 0x691c, 0x6a29, 0x727d, 0x72ac, 0x732e, 0x7814, 0x786f, 0x7d79,
+ 0x770c, 0x80a9, 0x898b, 0x8b19, 0x8ce2, 0x8ed2, 0x9063, 0x9375,
+ 0x967a, 0x9855, 0x9a13, 0x9e78, 0x5143, 0x539f, 0x53b3, 0x5e7b,
+ 0x5f26, 0x6e1b, 0x6e90, 0x7384, 0x73fe, 0x7d43, 0x8237, 0x8a00,
+ 0x8afa, 0x9650, 0x4e4e, 0x500b, 0x53e4, 0x547c, 0x56fa, 0x59d1,
+ 0x5b64, 0x5df1, 0x5eab, 0x5f27, 0x6238, 0x6545, 0x67af, 0x6e56,
+ 0x72d0, 0x7cca, 0x88b4, 0x80a1, 0x80e1, 0x83f0, 0x864e, 0x8a87,
+ 0x8de8, 0x9237, 0x96c7, 0x9867, 0x9f13, 0x4e94, 0x4e92, 0x4f0d,
+ 0x5348, 0x5449, 0x543e, 0x5a2f, 0x5f8c, 0x5fa1, 0x609f, 0x68a7,
+ 0x6a8e, 0x745a, 0x7881, 0x8a9e, 0x8aa4, 0x8b77, 0x9190, 0x4e5e,
+ 0x9bc9, 0x4ea4, 0x4f7c, 0x4faf, 0x5019, 0x5016, 0x5149, 0x516c,
+ 0x529f, 0x52b9, 0x52fe, 0x539a, 0x53e3, 0x5411,
+ /* 0x39 */
+ 0x540e, 0x5589, 0x5751, 0x57a2, 0x597d, 0x5b54, 0x5b5d, 0x5b8f,
+ 0x5de5, 0x5de7, 0x5df7, 0x5e78, 0x5e83, 0x5e9a, 0x5eb7, 0x5f18,
+ 0x6052, 0x614c, 0x6297, 0x62d8, 0x63a7, 0x653b, 0x6602, 0x6643,
+ 0x66f4, 0x676d, 0x6821, 0x6897, 0x69cb, 0x6c5f, 0x6d2a, 0x6d69,
+ 0x6e2f, 0x6e9d, 0x7532, 0x7687, 0x786c, 0x7a3f, 0x7ce0, 0x7d05,
+ 0x7d18, 0x7d5e, 0x7db1, 0x8015, 0x8003, 0x80af, 0x80b1, 0x8154,
+ 0x818f, 0x822a, 0x8352, 0x884c, 0x8861, 0x8b1b, 0x8ca2, 0x8cfc,
+ 0x90ca, 0x9175, 0x9271, 0x783f, 0x92fc, 0x95a4, 0x964d, 0x9805,
+ 0x9999, 0x9ad8, 0x9d3b, 0x525b, 0x52ab, 0x53f7, 0x5408, 0x58d5,
+ 0x62f7, 0x6fe0, 0x8c6a, 0x8f5f, 0x9eb9, 0x514b, 0x523b, 0x544a,
+ 0x56fd, 0x7a40, 0x9177, 0x9d60, 0x9ed2, 0x7344, 0x6f09, 0x8170,
+ 0x7511, 0x5ffd, 0x60da, 0x9aa8, 0x72db, 0x8fbc,
+ /* 0x3a */
+ 0x6b64, 0x9803, 0x4eca, 0x56f0, 0x5764, 0x58be, 0x5a5a, 0x6068,
+ 0x61c7, 0x660f, 0x6606, 0x6839, 0x68b1, 0x6df7, 0x75d5, 0x7d3a,
+ 0x826e, 0x9b42, 0x4e9b, 0x4f50, 0x53c9, 0x5506, 0x5d6f, 0x5de6,
+ 0x5dee, 0x67fb, 0x6c99, 0x7473, 0x7802, 0x8a50, 0x9396, 0x88df,
+ 0x5750, 0x5ea7, 0x632b, 0x50b5, 0x50ac, 0x518d, 0x6700, 0x54c9,
+ 0x585e, 0x59bb, 0x5bb0, 0x5f69, 0x624d, 0x63a1, 0x683d, 0x6b73,
+ 0x6e08, 0x707d, 0x91c7, 0x7280, 0x7815, 0x7826, 0x796d, 0x658e,
+ 0x7d30, 0x83dc, 0x88c1, 0x8f09, 0x969b, 0x5264, 0x5728, 0x6750,
+ 0x7f6a, 0x8ca1, 0x51b4, 0x5742, 0x962a, 0x583a, 0x698a, 0x80b4,
+ 0x54b2, 0x5d0e, 0x57fc, 0x7895, 0x9dfa, 0x4f5c, 0x524a, 0x548b,
+ 0x643e, 0x6628, 0x6714, 0x67f5, 0x7a84, 0x7b56, 0x7d22, 0x932f,
+ 0x685c, 0x9bad, 0x7b39, 0x5319, 0x518a, 0x5237,
+ /* 0x3b */
+ 0x5bdf, 0x62f6, 0x64ae, 0x64e6, 0x672d, 0x6bba, 0x85a9, 0x96d1,
+ 0x7690, 0x9bd6, 0x634c, 0x9306, 0x9bab, 0x76bf, 0x6652, 0x4e09,
+ 0x5098, 0x53c2, 0x5c71, 0x60e8, 0x6492, 0x6563, 0x685f, 0x71e6,
+ 0x73ca, 0x7523, 0x7b97, 0x7e82, 0x8695, 0x8b83, 0x8cdb, 0x9178,
+ 0x9910, 0x65ac, 0x66ab, 0x6b8b, 0x4ed5, 0x4ed4, 0x4f3a, 0x4f7f,
+ 0x523a, 0x53f8, 0x53f2, 0x55e3, 0x56db, 0x58eb, 0x59cb, 0x59c9,
+ 0x59ff, 0x5b50, 0x5c4d, 0x5e02, 0x5e2b, 0x5fd7, 0x601d, 0x6307,
+ 0x652f, 0x5b5c, 0x65af, 0x65bd, 0x65e8, 0x679d, 0x6b62, 0x6b7b,
+ 0x6c0f, 0x7345, 0x7949, 0x79c1, 0x7cf8, 0x7d19, 0x7d2b, 0x80a2,
+ 0x8102, 0x81f3, 0x8996, 0x8a5e, 0x8a69, 0x8a66, 0x8a8c, 0x8aee,
+ 0x8cc7, 0x8cdc, 0x96cc, 0x98fc, 0x6b6f, 0x4e8b, 0x4f3c, 0x4f8d,
+ 0x5150, 0x5b57, 0x5bfa, 0x6148, 0x6301, 0x6642,
+ /* 0x3c */
+ 0x6b21, 0x6ecb, 0x6cbb, 0x723e, 0x74bd, 0x75d4, 0x78c1, 0x793a,
+ 0x800c, 0x8033, 0x81ea, 0x8494, 0x8f9e, 0x6c50, 0x9e7f, 0x5f0f,
+ 0x8b58, 0x9d2b, 0x7afa, 0x8ef8, 0x5b8d, 0x96eb, 0x4e03, 0x53f1,
+ 0x57f7, 0x5931, 0x5ac9, 0x5ba4, 0x6089, 0x6e7f, 0x6f06, 0x75be,
+ 0x8cea, 0x5b9f, 0x8500, 0x7be0, 0x5072, 0x67f4, 0x829d, 0x5c61,
+ 0x854a, 0x7e1e, 0x820e, 0x5199, 0x5c04, 0x6368, 0x8d66, 0x659c,
+ 0x716e, 0x793e, 0x7d17, 0x8005, 0x8b1d, 0x8eca, 0x906e, 0x86c7,
+ 0x90aa, 0x501f, 0x52fa, 0x5c3a, 0x6753, 0x707c, 0x7235, 0x914c,
+ 0x91c8, 0x932b, 0x82e5, 0x5bc2, 0x5f31, 0x60f9, 0x4e3b, 0x53d6,
+ 0x5b88, 0x624b, 0x6731, 0x6b8a, 0x72e9, 0x73e0, 0x7a2e, 0x816b,
+ 0x8da3, 0x9152, 0x9996, 0x5112, 0x53d7, 0x546a, 0x5bff, 0x6388,
+ 0x6a39, 0x7dac, 0x9700, 0x56da, 0x53ce, 0x5468,
+ /* 0x3d */
+ 0x5b97, 0x5c31, 0x5dde, 0x4fee, 0x6101, 0x62fe, 0x6d32, 0x79c0,
+ 0x79cb, 0x7d42, 0x7e4d, 0x7fd2, 0x81ed, 0x821f, 0x8490, 0x8846,
+ 0x8972, 0x8b90, 0x8e74, 0x8f2f, 0x9031, 0x914b, 0x916c, 0x96c6,
+ 0x919c, 0x4ec0, 0x4f4f, 0x5145, 0x5341, 0x5f93, 0x620e, 0x67d4,
+ 0x6c41, 0x6e0b, 0x7363, 0x7e26, 0x91cd, 0x9283, 0x53d4, 0x5919,
+ 0x5bbf, 0x6dd1, 0x795d, 0x7e2e, 0x7c9b, 0x587e, 0x719f, 0x51fa,
+ 0x8853, 0x8ff0, 0x4fca, 0x5cfb, 0x6625, 0x77ac, 0x7ae3, 0x821c,
+ 0x99ff, 0x51c6, 0x5faa, 0x65ec, 0x696f, 0x6b89, 0x6df3, 0x6e96,
+ 0x6f64, 0x76fe, 0x7d14, 0x5de1, 0x9075, 0x9187, 0x9806, 0x51e6,
+ 0x521d, 0x6240, 0x6691, 0x66d9, 0x6e1a, 0x5eb6, 0x7dd2, 0x7f72,
+ 0x66f8, 0x85af, 0x85f7, 0x8af8, 0x52a9, 0x53d9, 0x5973, 0x5e8f,
+ 0x5f90, 0x6055, 0x92e4, 0x9664, 0x50b7, 0x511f,
+ /* 0x3e */
+ 0x52dd, 0x5320, 0x5347, 0x53ec, 0x54e8, 0x5546, 0x5531, 0x5617,
+ 0x5968, 0x59be, 0x5a3c, 0x5bb5, 0x5c06, 0x5c0f, 0x5c11, 0x5c1a,
+ 0x5e84, 0x5e8a, 0x5ee0, 0x5f70, 0x627f, 0x6284, 0x62db, 0x638c,
+ 0x6377, 0x6607, 0x660c, 0x662d, 0x6676, 0x677e, 0x68a2, 0x6a1f,
+ 0x6a35, 0x6cbc, 0x6d88, 0x6e09, 0x6e58, 0x713c, 0x7126, 0x7167,
+ 0x75c7, 0x7701, 0x785d, 0x7901, 0x7965, 0x79f0, 0x7ae0, 0x7b11,
+ 0x7ca7, 0x7d39, 0x8096, 0x83d6, 0x848b, 0x8549, 0x885d, 0x88f3,
+ 0x8a1f, 0x8a3c, 0x8a54, 0x8a73, 0x8c61, 0x8cde, 0x91a4, 0x9266,
+ 0x937e, 0x9418, 0x969c, 0x9798, 0x4e0a, 0x4e08, 0x4e1e, 0x4e57,
+ 0x5197, 0x5270, 0x57ce, 0x5834, 0x58cc, 0x5b22, 0x5e38, 0x60c5,
+ 0x64fe, 0x6761, 0x6756, 0x6d44, 0x72b6, 0x7573, 0x7a63, 0x84b8,
+ 0x8b72, 0x91b8, 0x9320, 0x5631, 0x57f4, 0x98fe,
+ /* 0x3f */
+ 0x62ed, 0x690d, 0x6b96, 0x71ed, 0x7e54, 0x8077, 0x8272, 0x89e6,
+ 0x98df, 0x8755, 0x8fb1, 0x5c3b, 0x4f38, 0x4fe1, 0x4fb5, 0x5507,
+ 0x5a20, 0x5bdd, 0x5be9, 0x5fc3, 0x614e, 0x632f, 0x65b0, 0x664b,
+ 0x68ee, 0x699b, 0x6d78, 0x6df1, 0x7533, 0x75b9, 0x771f, 0x795e,
+ 0x79e6, 0x7d33, 0x81e3, 0x82af, 0x85aa, 0x89aa, 0x8a3a, 0x8eab,
+ 0x8f9b, 0x9032, 0x91dd, 0x9707, 0x4eba, 0x4ec1, 0x5203, 0x5875,
+ 0x58ec, 0x5c0b, 0x751a, 0x5c3d, 0x814e, 0x8a0a, 0x8fc5, 0x9663,
+ 0x976d, 0x7b25, 0x8acf, 0x9808, 0x9162, 0x56f3, 0x53a8, 0x9017,
+ 0x5439, 0x5782, 0x5e25, 0x63a8, 0x6c34, 0x708a, 0x7761, 0x7c8b,
+ 0x7fe0, 0x8870, 0x9042, 0x9154, 0x9310, 0x9318, 0x968f, 0x745e,
+ 0x9ac4, 0x5d07, 0x5d69, 0x6570, 0x67a2, 0x8da8, 0x96db, 0x636e,
+ 0x6749, 0x6919, 0x83c5, 0x9817, 0x96c0, 0x88fe,
+ /* 0x40 */
+ 0x6f84, 0x647a, 0x5bf8, 0x4e16, 0x702c, 0x755d, 0x662f, 0x51c4,
+ 0x5236, 0x52e2, 0x59d3, 0x5f81, 0x6027, 0x6210, 0x653f, 0x6574,
+ 0x661f, 0x6674, 0x68f2, 0x6816, 0x6b63, 0x6e05, 0x7272, 0x751f,
+ 0x76db, 0x7cbe, 0x8056, 0x58f0, 0x88fd, 0x897f, 0x8aa0, 0x8a93,
+ 0x8acb, 0x901d, 0x9192, 0x9752, 0x9759, 0x6589, 0x7a0e, 0x8106,
+ 0x96bb, 0x5e2d, 0x60dc, 0x621a, 0x65a5, 0x6614, 0x6790, 0x77f3,
+ 0x7a4d, 0x7c4d, 0x7e3e, 0x810a, 0x8cac, 0x8d64, 0x8de1, 0x8e5f,
+ 0x78a9, 0x5207, 0x62d9, 0x63a5, 0x6442, 0x6298, 0x8a2d, 0x7a83,
+ 0x7bc0, 0x8aac, 0x96ea, 0x7d76, 0x820c, 0x8749, 0x4ed9, 0x5148,
+ 0x5343, 0x5360, 0x5ba3, 0x5c02, 0x5c16, 0x5ddd, 0x6226, 0x6247,
+ 0x64b0, 0x6813, 0x6834, 0x6cc9, 0x6d45, 0x6d17, 0x67d3, 0x6f5c,
+ 0x714e, 0x717d, 0x65cb, 0x7a7f, 0x7bad, 0x7dda,
+ /* 0x41 */
+ 0x7e4a, 0x7fa8, 0x817a, 0x821b, 0x8239, 0x85a6, 0x8a6e, 0x8cce,
+ 0x8df5, 0x9078, 0x9077, 0x92ad, 0x9291, 0x9583, 0x9bae, 0x524d,
+ 0x5584, 0x6f38, 0x7136, 0x5168, 0x7985, 0x7e55, 0x81b3, 0x7cce,
+ 0x564c, 0x5851, 0x5ca8, 0x63aa, 0x66fe, 0x66fd, 0x695a, 0x72d9,
+ 0x758f, 0x758e, 0x790e, 0x7956, 0x79df, 0x7c97, 0x7d20, 0x7d44,
+ 0x8607, 0x8a34, 0x963b, 0x9061, 0x9f20, 0x50e7, 0x5275, 0x53cc,
+ 0x53e2, 0x5009, 0x55aa, 0x58ee, 0x594f, 0x723d, 0x5b8b, 0x5c64,
+ 0x531d, 0x60e3, 0x60f3, 0x635c, 0x6383, 0x633f, 0x63bb, 0x64cd,
+ 0x65e9, 0x66f9, 0x5de3, 0x69cd, 0x69fd, 0x6f15, 0x71e5, 0x4e89,
+ 0x75e9, 0x76f8, 0x7a93, 0x7cdf, 0x7dcf, 0x7d9c, 0x8061, 0x8349,
+ 0x8358, 0x846c, 0x84bc, 0x85fb, 0x88c5, 0x8d70, 0x9001, 0x906d,
+ 0x9397, 0x971c, 0x9a12, 0x50cf, 0x5897, 0x618e,
+ /* 0x42 */
+ 0x81d3, 0x8535, 0x8d08, 0x9020, 0x4fc3, 0x5074, 0x5247, 0x5373,
+ 0x606f, 0x6349, 0x675f, 0x6e2c, 0x8db3, 0x901f, 0x4fd7, 0x5c5e,
+ 0x8cca, 0x65cf, 0x7d9a, 0x5352, 0x8896, 0x5176, 0x63c3, 0x5b58,
+ 0x5b6b, 0x5c0a, 0x640d, 0x6751, 0x905c, 0x4ed6, 0x591a, 0x592a,
+ 0x6c70, 0x8a51, 0x553e, 0x5815, 0x59a5, 0x60f0, 0x6253, 0x67c1,
+ 0x8235, 0x6955, 0x9640, 0x99c4, 0x9a28, 0x4f53, 0x5806, 0x5bfe,
+ 0x8010, 0x5cb1, 0x5e2f, 0x5f85, 0x6020, 0x614b, 0x6234, 0x66ff,
+ 0x6cf0, 0x6ede, 0x80ce, 0x817f, 0x82d4, 0x888b, 0x8cb8, 0x9000,
+ 0x902e, 0x968a, 0x9edb, 0x9bdb, 0x4ee3, 0x53f0, 0x5927, 0x7b2c,
+ 0x918d, 0x984c, 0x9df9, 0x6edd, 0x7027, 0x5353, 0x5544, 0x5b85,
+ 0x6258, 0x629e, 0x62d3, 0x6ca2, 0x6fef, 0x7422, 0x8a17, 0x9438,
+ 0x6fc1, 0x8afe, 0x8338, 0x51e7, 0x86f8, 0x53ea,
+ /* 0x43 */
+ 0x53e9, 0x4f46, 0x9054, 0x8fb0, 0x596a, 0x8131, 0x5dfd, 0x7aea,
+ 0x8fbf, 0x68da, 0x8c37, 0x72f8, 0x9c48, 0x6a3d, 0x8ab0, 0x4e39,
+ 0x5358, 0x5606, 0x5766, 0x62c5, 0x63a2, 0x65e6, 0x6b4e, 0x6de1,
+ 0x6e5b, 0x70ad, 0x77ed, 0x7aef, 0x7baa, 0x7dbb, 0x803d, 0x80c6,
+ 0x86cb, 0x8a95, 0x935b, 0x56e3, 0x58c7, 0x5f3e, 0x65ad, 0x6696,
+ 0x6a80, 0x6bb5, 0x7537, 0x8ac7, 0x5024, 0x77e5, 0x5730, 0x5f1b,
+ 0x6065, 0x667a, 0x6c60, 0x75f4, 0x7a1a, 0x7f6e, 0x81f4, 0x8718,
+ 0x9045, 0x99b3, 0x7bc9, 0x755c, 0x7af9, 0x7b51, 0x84c4, 0x9010,
+ 0x79e9, 0x7a92, 0x8336, 0x5ae1, 0x7740, 0x4e2d, 0x4ef2, 0x5b99,
+ 0x5fe0, 0x62bd, 0x663c, 0x67f1, 0x6ce8, 0x866b, 0x8877, 0x8a3b,
+ 0x914e, 0x92f3, 0x99d0, 0x6a17, 0x7026, 0x732a, 0x82e7, 0x8457,
+ 0x8caf, 0x4e01, 0x5146, 0x51cb, 0x558b, 0x5bf5,
+ /* 0x44 */
+ 0x5e16, 0x5e33, 0x5e81, 0x5f14, 0x5f35, 0x5f6b, 0x5fb4, 0x61f2,
+ 0x6311, 0x66a2, 0x671d, 0x6f6e, 0x7252, 0x753a, 0x773a, 0x8074,
+ 0x8139, 0x8178, 0x8776, 0x8abf, 0x8adc, 0x8d85, 0x8df3, 0x929a,
+ 0x9577, 0x9802, 0x9ce5, 0x52c5, 0x6357, 0x76f4, 0x6715, 0x6c88,
+ 0x73cd, 0x8cc3, 0x93ae, 0x9673, 0x6d25, 0x589c, 0x690e, 0x69cc,
+ 0x8ffd, 0x939a, 0x75db, 0x901a, 0x585a, 0x6802, 0x63b4, 0x69fb,
+ 0x4f43, 0x6f2c, 0x67d8, 0x8fbb, 0x8526, 0x7db4, 0x9354, 0x693f,
+ 0x6f70, 0x576a, 0x58f7, 0x5b2c, 0x7d2c, 0x722a, 0x540a, 0x91e3,
+ 0x9db4, 0x4ead, 0x4f4e, 0x505c, 0x5075, 0x5243, 0x8c9e, 0x5448,
+ 0x5824, 0x5b9a, 0x5e1d, 0x5e95, 0x5ead, 0x5ef7, 0x5f1f, 0x608c,
+ 0x62b5, 0x633a, 0x63d0, 0x68af, 0x6c40, 0x7887, 0x798e, 0x7a0b,
+ 0x7de0, 0x8247, 0x8a02, 0x8ae6, 0x8e44, 0x9013,
+ /* 0x45 */
+ 0x90b8, 0x912d, 0x91d8, 0x9f0e, 0x6ce5, 0x6458, 0x64e2, 0x6575,
+ 0x6ef4, 0x7684, 0x7b1b, 0x9069, 0x93d1, 0x6eba, 0x54f2, 0x5fb9,
+ 0x64a4, 0x8f4d, 0x8fed, 0x9244, 0x5178, 0x586b, 0x5929, 0x5c55,
+ 0x5e97, 0x6dfb, 0x7e8f, 0x751c, 0x8cbc, 0x8ee2, 0x985b, 0x70b9,
+ 0x4f1d, 0x6bbf, 0x6fb1, 0x7530, 0x96fb, 0x514e, 0x5410, 0x5835,
+ 0x5857, 0x59ac, 0x5c60, 0x5f92, 0x6597, 0x675c, 0x6e21, 0x767b,
+ 0x83df, 0x8ced, 0x9014, 0x90fd, 0x934d, 0x7825, 0x783a, 0x52aa,
+ 0x5ea6, 0x571f, 0x5974, 0x6012, 0x5012, 0x515a, 0x51ac, 0x51cd,
+ 0x5200, 0x5510, 0x5854, 0x5858, 0x5957, 0x5b95, 0x5cf6, 0x5d8b,
+ 0x60bc, 0x6295, 0x642d, 0x6771, 0x6843, 0x68bc, 0x68df, 0x76d7,
+ 0x6dd8, 0x6e6f, 0x6d9b, 0x706f, 0x71c8, 0x5f53, 0x75d8, 0x7977,
+ 0x7b49, 0x7b54, 0x7b52, 0x7cd6, 0x7d71, 0x5230,
+ /* 0x46 */
+ 0x8463, 0x8569, 0x85e4, 0x8a0e, 0x8b04, 0x8c46, 0x8e0f, 0x9003,
+ 0x900f, 0x9419, 0x9676, 0x982d, 0x9a30, 0x95d8, 0x50cd, 0x52d5,
+ 0x540c, 0x5802, 0x5c0e, 0x61a7, 0x649e, 0x6d1e, 0x77b3, 0x7ae5,
+ 0x80f4, 0x8404, 0x9053, 0x9285, 0x5ce0, 0x9d07, 0x533f, 0x5f97,
+ 0x5fb3, 0x6d9c, 0x7279, 0x7763, 0x79bf, 0x7be4, 0x6bd2, 0x72ec,
+ 0x8aad, 0x6803, 0x6a61, 0x51f8, 0x7a81, 0x6934, 0x5c4a, 0x9cf6,
+ 0x82eb, 0x5bc5, 0x9149, 0x701e, 0x5678, 0x5c6f, 0x60c7, 0x6566,
+ 0x6c8c, 0x8c5a, 0x9041, 0x9813, 0x5451, 0x66c7, 0x920d, 0x5948,
+ 0x90a3, 0x5185, 0x4e4d, 0x51ea, 0x8599, 0x8b0e, 0x7058, 0x637a,
+ 0x934b, 0x6962, 0x99b4, 0x7e04, 0x7577, 0x5357, 0x6960, 0x8edf,
+ 0x96e3, 0x6c5d, 0x4e8c, 0x5c3c, 0x5f10, 0x8fe9, 0x5302, 0x8cd1,
+ 0x8089, 0x8679, 0x5eff, 0x65e5, 0x4e73, 0x5165,
+ /* 0x47 */
+ 0x5982, 0x5c3f, 0x97ee, 0x4efb, 0x598a, 0x5fcd, 0x8a8d, 0x6fe1,
+ 0x79b0, 0x7962, 0x5be7, 0x8471, 0x732b, 0x71b1, 0x5e74, 0x5ff5,
+ 0x637b, 0x649a, 0x71c3, 0x7c98, 0x4e43, 0x5efc, 0x4e4b, 0x57dc,
+ 0x56a2, 0x60a9, 0x6fc3, 0x7d0d, 0x80fd, 0x8133, 0x81bf, 0x8fb2,
+ 0x8997, 0x86a4, 0x5df4, 0x628a, 0x64ad, 0x8987, 0x6777, 0x6ce2,
+ 0x6d3e, 0x7436, 0x7834, 0x5a46, 0x7f75, 0x82ad, 0x99ac, 0x4ff3,
+ 0x5ec3, 0x62dd, 0x6392, 0x6557, 0x676f, 0x76c3, 0x724c, 0x80cc,
+ 0x80ba, 0x8f29, 0x914d, 0x500d, 0x57f9, 0x5a92, 0x6885, 0x6973,
+ 0x7164, 0x72fd, 0x8cb7, 0x58f2, 0x8ce0, 0x966a, 0x9019, 0x877f,
+ 0x79e4, 0x77e7, 0x8429, 0x4f2f, 0x5265, 0x535a, 0x62cd, 0x67cf,
+ 0x6cca, 0x767d, 0x7b94, 0x7c95, 0x8236, 0x8584, 0x8feb, 0x66dd,
+ 0x6f20, 0x7206, 0x7e1b, 0x83ab, 0x99c1, 0x9ea6,
+ /* 0x48 */
+ 0x51fd, 0x7bb1, 0x7872, 0x7bb8, 0x8087, 0x7b48, 0x6ae8, 0x5e61,
+ 0x808c, 0x7551, 0x7560, 0x516b, 0x9262, 0x6e8c, 0x767a, 0x9197,
+ 0x9aea, 0x4f10, 0x7f70, 0x629c, 0x7b4f, 0x95a5, 0x9ce9, 0x567a,
+ 0x5859, 0x86e4, 0x96bc, 0x4f34, 0x5224, 0x534a, 0x53cd, 0x53db,
+ 0x5e06, 0x642c, 0x6591, 0x677f, 0x6c3e, 0x6c4e, 0x7248, 0x72af,
+ 0x73ed, 0x7554, 0x7e41, 0x822c, 0x85e9, 0x8ca9, 0x7bc4, 0x91c6,
+ 0x7169, 0x9812, 0x98ef, 0x633d, 0x6669, 0x756a, 0x76e4, 0x78d0,
+ 0x8543, 0x86ee, 0x532a, 0x5351, 0x5426, 0x5983, 0x5e87, 0x5f7c,
+ 0x60b2, 0x6249, 0x6279, 0x62ab, 0x6590, 0x6bd4, 0x6ccc, 0x75b2,
+ 0x76ae, 0x7891, 0x79d8, 0x7dcb, 0x7f77, 0x80a5, 0x88ab, 0x8ab9,
+ 0x8cbb, 0x907f, 0x975e, 0x98db, 0x6a0b, 0x7c38, 0x5099, 0x5c3e,
+ 0x5fae, 0x6787, 0x6bd8, 0x7435, 0x7709, 0x7f8e,
+ /* 0x49 */
+ 0x9f3b, 0x67ca, 0x7a17, 0x5339, 0x758b, 0x9aed, 0x5f66, 0x819d,
+ 0x83f1, 0x8098, 0x5f3c, 0x5fc5, 0x7562, 0x7b46, 0x903c, 0x6867,
+ 0x59eb, 0x5a9b, 0x7d10, 0x767e, 0x8b2c, 0x4ff5, 0x5f6a, 0x6a19,
+ 0x6c37, 0x6f02, 0x74e2, 0x7968, 0x8868, 0x8a55, 0x8c79, 0x5edf,
+ 0x63cf, 0x75c5, 0x79d2, 0x82d7, 0x9328, 0x92f2, 0x849c, 0x86ed,
+ 0x9c2d, 0x54c1, 0x5f6c, 0x658c, 0x6d5c, 0x7015, 0x8ca7, 0x8cd3,
+ 0x983b, 0x654f, 0x74f6, 0x4e0d, 0x4ed8, 0x57e0, 0x592b, 0x5a66,
+ 0x5bcc, 0x51a8, 0x5e03, 0x5e9c, 0x6016, 0x6276, 0x6577, 0x65a7,
+ 0x666e, 0x6d6e, 0x7236, 0x7b26, 0x8150, 0x819a, 0x8299, 0x8b5c,
+ 0x8ca0, 0x8ce6, 0x8d74, 0x961c, 0x9644, 0x4fae, 0x64ab, 0x6b66,
+ 0x821e, 0x8461, 0x856a, 0x90e8, 0x5c01, 0x6953, 0x98a8, 0x847a,
+ 0x8557, 0x4f0f, 0x526f, 0x5fa9, 0x5e45, 0x670d,
+ /* 0x4a */
+ 0x798f, 0x8179, 0x8907, 0x8986, 0x6df5, 0x5f17, 0x6255, 0x6cb8,
+ 0x4ecf, 0x7269, 0x9b92, 0x5206, 0x543b, 0x5674, 0x58b3, 0x61a4,
+ 0x626e, 0x711a, 0x596e, 0x7c89, 0x7cde, 0x7d1b, 0x96f0, 0x6587,
+ 0x805e, 0x4e19, 0x4f75, 0x5175, 0x5840, 0x5e63, 0x5e73, 0x5f0a,
+ 0x67c4, 0x4e26, 0x853d, 0x9589, 0x965b, 0x7c73, 0x9801, 0x50fb,
+ 0x58c1, 0x7656, 0x78a7, 0x5225, 0x77a5, 0x8511, 0x7b86, 0x504f,
+ 0x5909, 0x7247, 0x7bc7, 0x7de8, 0x8fba, 0x8fd4, 0x904d, 0x4fbf,
+ 0x52c9, 0x5a29, 0x5f01, 0x97ad, 0x4fdd, 0x8217, 0x92ea, 0x5703,
+ 0x6355, 0x6b69, 0x752b, 0x88dc, 0x8f14, 0x7a42, 0x52df, 0x5893,
+ 0x6155, 0x620a, 0x66ae, 0x6bcd, 0x7c3f, 0x83e9, 0x5023, 0x4ff8,
+ 0x5305, 0x5446, 0x5831, 0x5949, 0x5b9d, 0x5cf0, 0x5cef, 0x5d29,
+ 0x5e96, 0x62b1, 0x6367, 0x653e, 0x65b9, 0x670b,
+ /* 0x4b */
+ 0x6cd5, 0x6ce1, 0x70f9, 0x7832, 0x7e2b, 0x80de, 0x82b3, 0x840c,
+ 0x84ec, 0x8702, 0x8912, 0x8a2a, 0x8c4a, 0x90a6, 0x92d2, 0x98fd,
+ 0x9cf3, 0x9d6c, 0x4e4f, 0x4ea1, 0x508d, 0x5256, 0x574a, 0x59a8,
+ 0x5e3d, 0x5fd8, 0x5fd9, 0x623f, 0x66b4, 0x671b, 0x67d0, 0x68d2,
+ 0x5192, 0x7d21, 0x80aa, 0x81a8, 0x8b00, 0x8c8c, 0x8cbf, 0x927e,
+ 0x9632, 0x5420, 0x982c, 0x5317, 0x50d5, 0x535c, 0x58a8, 0x64b2,
+ 0x6734, 0x7267, 0x7766, 0x7a46, 0x91e6, 0x52c3, 0x6ca1, 0x6b86,
+ 0x5800, 0x5e4c, 0x5954, 0x672c, 0x7ffb, 0x51e1, 0x76c6, 0x6469,
+ 0x78e8, 0x9b54, 0x9ebb, 0x57cb, 0x59b9, 0x6627, 0x679a, 0x6bce,
+ 0x54e9, 0x69d9, 0x5e55, 0x819c, 0x6795, 0x9baa, 0x67fe, 0x9c52,
+ 0x685d, 0x4ea6, 0x4fe3, 0x53c8, 0x62b9, 0x672b, 0x6cab, 0x8fc4,
+ 0x4fad, 0x7e6d, 0x9ebf, 0x4e07, 0x6162, 0x6e80,
+ /* 0x4c */
+ 0x6f2b, 0x8513, 0x5473, 0x672a, 0x9b45, 0x5df3, 0x7b95, 0x5cac,
+ 0x5bc6, 0x871c, 0x6e4a, 0x84d1, 0x7a14, 0x8108, 0x5999, 0x7c8d,
+ 0x6c11, 0x7720, 0x52d9, 0x5922, 0x7121, 0x725f, 0x77db, 0x9727,
+ 0x9d61, 0x690b, 0x5a7f, 0x5a18, 0x51a5, 0x540d, 0x547d, 0x660e,
+ 0x76df, 0x8ff7, 0x9298, 0x9cf4, 0x59ea, 0x725d, 0x6ec5, 0x514d,
+ 0x68c9, 0x7dbf, 0x7dec, 0x9762, 0x9eba, 0x6478, 0x6a21, 0x8302,
+ 0x5984, 0x5b5f, 0x6bdb, 0x731b, 0x76f2, 0x7db2, 0x8017, 0x8499,
+ 0x5132, 0x6728, 0x9ed9, 0x76ee, 0x6762, 0x52ff, 0x9905, 0x5c24,
+ 0x623b, 0x7c7e, 0x8cb0, 0x554f, 0x60b6, 0x7d0b, 0x9580, 0x5301,
+ 0x4e5f, 0x51b6, 0x591c, 0x723a, 0x8036, 0x91ce, 0x5f25, 0x77e2,
+ 0x5384, 0x5f79, 0x7d04, 0x85ac, 0x8a33, 0x8e8d, 0x9756, 0x67f3,
+ 0x85ae, 0x9453, 0x6109, 0x6108, 0x6cb9, 0x7652,
+ /* 0x4d */
+ 0x8aed, 0x8f38, 0x552f, 0x4f51, 0x512a, 0x52c7, 0x53cb, 0x5ba5,
+ 0x5e7d, 0x60a0, 0x6182, 0x63d6, 0x6709, 0x67da, 0x6e67, 0x6d8c,
+ 0x7336, 0x7337, 0x7531, 0x7950, 0x88d5, 0x8a98, 0x904a, 0x9091,
+ 0x90f5, 0x96c4, 0x878d, 0x5915, 0x4e88, 0x4f59, 0x4e0e, 0x8a89,
+ 0x8f3f, 0x9810, 0x50ad, 0x5e7c, 0x5996, 0x5bb9, 0x5eb8, 0x63da,
+ 0x63fa, 0x64c1, 0x66dc, 0x694a, 0x69d8, 0x6d0b, 0x6eb6, 0x7194,
+ 0x7528, 0x7aaf, 0x7f8a, 0x8000, 0x8449, 0x84c9, 0x8981, 0x8b21,
+ 0x8e0a, 0x9065, 0x967d, 0x990a, 0x617e, 0x6291, 0x6b32, 0x6c83,
+ 0x6d74, 0x7fcc, 0x7ffc, 0x6dc0, 0x7f85, 0x87ba, 0x88f8, 0x6765,
+ 0x83b1, 0x983c, 0x96f7, 0x6d1b, 0x7d61, 0x843d, 0x916a, 0x4e71,
+ 0x5375, 0x5d50, 0x6b04, 0x6feb, 0x85cd, 0x862d, 0x89a7, 0x5229,
+ 0x540f, 0x5c65, 0x674e, 0x68a8, 0x7406, 0x7483,
+ /* 0x4e */
+ 0x75e2, 0x88cf, 0x88e1, 0x91cc, 0x96e2, 0x9678, 0x5f8b, 0x7387,
+ 0x7acb, 0x844e, 0x63a0, 0x7565, 0x5289, 0x6d41, 0x6e9c, 0x7409,
+ 0x7559, 0x786b, 0x7c92, 0x9686, 0x7adc, 0x9f8d, 0x4fb6, 0x616e,
+ 0x65c5, 0x865c, 0x4e86, 0x4eae, 0x50da, 0x4e21, 0x51cc, 0x5bee,
+ 0x6599, 0x6881, 0x6dbc, 0x731f, 0x7642, 0x77ad, 0x7a1c, 0x7ce7,
+ 0x826f, 0x8ad2, 0x907c, 0x91cf, 0x9675, 0x9818, 0x529b, 0x7dd1,
+ 0x502b, 0x5398, 0x6797, 0x6dcb, 0x71d0, 0x7433, 0x81e8, 0x8f2a,
+ 0x96a3, 0x9c57, 0x9e9f, 0x7460, 0x5841, 0x6d99, 0x7d2f, 0x985e,
+ 0x4ee4, 0x4f36, 0x4f8b, 0x51b7, 0x52b1, 0x5dba, 0x601c, 0x73b2,
+ 0x793c, 0x82d3, 0x9234, 0x96b7, 0x96f6, 0x970a, 0x9e97, 0x9f62,
+ 0x66a6, 0x6b74, 0x5217, 0x52a3, 0x70c8, 0x88c2, 0x5ec9, 0x604b,
+ 0x6190, 0x6f23, 0x7149, 0x7c3e, 0x7df4, 0x806f,
+ /* 0x4f */
+ 0x84ee, 0x9023, 0x932c, 0x5442, 0x9b6f, 0x6ad3, 0x7089, 0x8cc2,
+ 0x8def, 0x9732, 0x52b4, 0x5a41, 0x5eca, 0x5f04, 0x6717, 0x697c,
+ 0x6994, 0x6d6a, 0x6f0f, 0x7262, 0x72fc, 0x7bed, 0x8001, 0x807e,
+ 0x874b, 0x90ce, 0x516d, 0x9e93, 0x7984, 0x808b, 0x9332, 0x8ad6,
+ 0x502d, 0x548c, 0x8a71, 0x6b6a, 0x8cc4, 0x8107, 0x60d1, 0x67a0,
+ 0x9df2, 0x4e99, 0x4e98, 0x9c10, 0x8a6b, 0x85c1, 0x8568, 0x6900,
+ 0x6e7e, 0x7897, 0x8155, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x50 */
+ 0x5f0c, 0x4e10, 0x4e15, 0x4e2a, 0x4e31, 0x4e36, 0x4e3c, 0x4e3f,
+ 0x4e42, 0x4e56, 0x4e58, 0x4e82, 0x4e85, 0x8c6b, 0x4e8a, 0x8212,
+ 0x5f0d, 0x4e8e, 0x4e9e, 0x4e9f, 0x4ea0, 0x4ea2, 0x4eb0, 0x4eb3,
+ 0x4eb6, 0x4ece, 0x4ecd, 0x4ec4, 0x4ec6, 0x4ec2, 0x4ed7, 0x4ede,
+ 0x4eed, 0x4edf, 0x4ef7, 0x4f09, 0x4f5a, 0x4f30, 0x4f5b, 0x4f5d,
+ 0x4f57, 0x4f47, 0x4f76, 0x4f88, 0x4f8f, 0x4f98, 0x4f7b, 0x4f69,
+ 0x4f70, 0x4f91, 0x4f6f, 0x4f86, 0x4f96, 0x5118, 0x4fd4, 0x4fdf,
+ 0x4fce, 0x4fd8, 0x4fdb, 0x4fd1, 0x4fda, 0x4fd0, 0x4fe4, 0x4fe5,
+ 0x501a, 0x5028, 0x5014, 0x502a, 0x5025, 0x5005, 0x4f1c, 0x4ff6,
+ 0x5021, 0x5029, 0x502c, 0x4ffe, 0x4fef, 0x5011, 0x5006, 0x5043,
+ 0x5047, 0x6703, 0x5055, 0x5050, 0x5048, 0x505a, 0x5056, 0x506c,
+ 0x5078, 0x5080, 0x509a, 0x5085, 0x50b4, 0x50b2,
+ /* 0x51 */
+ 0x50c9, 0x50ca, 0x50b3, 0x50c2, 0x50d6, 0x50de, 0x50e5, 0x50ed,
+ 0x50e3, 0x50ee, 0x50f9, 0x50f5, 0x5109, 0x5101, 0x5102, 0x5116,
+ 0x5115, 0x5114, 0x511a, 0x5121, 0x513a, 0x5137, 0x513c, 0x513b,
+ 0x513f, 0x5140, 0x5152, 0x514c, 0x5154, 0x5162, 0x7af8, 0x5169,
+ 0x516a, 0x516e, 0x5180, 0x5182, 0x56d8, 0x518c, 0x5189, 0x518f,
+ 0x5191, 0x5193, 0x5195, 0x5196, 0x51a4, 0x51a6, 0x51a2, 0x51a9,
+ 0x51aa, 0x51ab, 0x51b3, 0x51b1, 0x51b2, 0x51b0, 0x51b5, 0x51bd,
+ 0x51c5, 0x51c9, 0x51db, 0x51e0, 0x8655, 0x51e9, 0x51ed, 0x51f0,
+ 0x51f5, 0x51fe, 0x5204, 0x520b, 0x5214, 0x520e, 0x5227, 0x522a,
+ 0x522e, 0x5233, 0x5239, 0x524f, 0x5244, 0x524b, 0x524c, 0x525e,
+ 0x5254, 0x526a, 0x5274, 0x5269, 0x5273, 0x527f, 0x527d, 0x528d,
+ 0x5294, 0x5292, 0x5271, 0x5288, 0x5291, 0x8fa8,
+ /* 0x52 */
+ 0x8fa7, 0x52ac, 0x52ad, 0x52bc, 0x52b5, 0x52c1, 0x52cd, 0x52d7,
+ 0x52de, 0x52e3, 0x52e6, 0x98ed, 0x52e0, 0x52f3, 0x52f5, 0x52f8,
+ 0x52f9, 0x5306, 0x5308, 0x7538, 0x530d, 0x5310, 0x530f, 0x5315,
+ 0x531a, 0x5323, 0x532f, 0x5331, 0x5333, 0x5338, 0x5340, 0x5346,
+ 0x5345, 0x4e17, 0x5349, 0x534d, 0x51d6, 0x535e, 0x5369, 0x536e,
+ 0x5918, 0x537b, 0x5377, 0x5382, 0x5396, 0x53a0, 0x53a6, 0x53a5,
+ 0x53ae, 0x53b0, 0x53b6, 0x53c3, 0x7c12, 0x96d9, 0x53df, 0x66fc,
+ 0x71ee, 0x53ee, 0x53e8, 0x53ed, 0x53fa, 0x5401, 0x543d, 0x5440,
+ 0x542c, 0x542d, 0x543c, 0x542e, 0x5436, 0x5429, 0x541d, 0x544e,
+ 0x548f, 0x5475, 0x548e, 0x545f, 0x5471, 0x5477, 0x5470, 0x5492,
+ 0x547b, 0x5480, 0x5476, 0x5484, 0x5490, 0x5486, 0x54c7, 0x54a2,
+ 0x54b8, 0x54a5, 0x54ac, 0x54c4, 0x54c8, 0x54a8,
+ /* 0x53 */
+ 0x54ab, 0x54c2, 0x54a4, 0x54be, 0x54bc, 0x54d8, 0x54e5, 0x54e6,
+ 0x550f, 0x5514, 0x54fd, 0x54ee, 0x54ed, 0x54fa, 0x54e2, 0x5539,
+ 0x5540, 0x5563, 0x554c, 0x552e, 0x555c, 0x5545, 0x5556, 0x5557,
+ 0x5538, 0x5533, 0x555d, 0x5599, 0x5580, 0x54af, 0x558a, 0x559f,
+ 0x557b, 0x557e, 0x5598, 0x559e, 0x55ae, 0x557c, 0x5583, 0x55a9,
+ 0x5587, 0x55a8, 0x55da, 0x55c5, 0x55df, 0x55c4, 0x55dc, 0x55e4,
+ 0x55d4, 0x5614, 0x55f7, 0x5616, 0x55fe, 0x55fd, 0x561b, 0x55f9,
+ 0x564e, 0x5650, 0x71df, 0x5634, 0x5636, 0x5632, 0x5638, 0x566b,
+ 0x5664, 0x562f, 0x566c, 0x566a, 0x5686, 0x5680, 0x568a, 0x56a0,
+ 0x5694, 0x568f, 0x56a5, 0x56ae, 0x56b6, 0x56b4, 0x56c2, 0x56bc,
+ 0x56c1, 0x56c3, 0x56c0, 0x56c8, 0x56ce, 0x56d1, 0x56d3, 0x56d7,
+ 0x56ee, 0x56f9, 0x5700, 0x56ff, 0x5704, 0x5709,
+ /* 0x54 */
+ 0x5708, 0x570b, 0x570d, 0x5713, 0x5718, 0x5716, 0x55c7, 0x571c,
+ 0x5726, 0x5737, 0x5738, 0x574e, 0x573b, 0x5740, 0x574f, 0x5769,
+ 0x57c0, 0x5788, 0x5761, 0x577f, 0x5789, 0x5793, 0x57a0, 0x57b3,
+ 0x57a4, 0x57aa, 0x57b0, 0x57c3, 0x57c6, 0x57d4, 0x57d2, 0x57d3,
+ 0x580a, 0x57d6, 0x57e3, 0x580b, 0x5819, 0x581d, 0x5872, 0x5821,
+ 0x5862, 0x584b, 0x5870, 0x6bc0, 0x5852, 0x583d, 0x5879, 0x5885,
+ 0x58b9, 0x589f, 0x58ab, 0x58ba, 0x58de, 0x58bb, 0x58b8, 0x58ae,
+ 0x58c5, 0x58d3, 0x58d1, 0x58d7, 0x58d9, 0x58d8, 0x58e5, 0x58dc,
+ 0x58e4, 0x58df, 0x58ef, 0x58fa, 0x58f9, 0x58fb, 0x58fc, 0x58fd,
+ 0x5902, 0x590a, 0x5910, 0x591b, 0x68a6, 0x5925, 0x592c, 0x592d,
+ 0x5932, 0x5938, 0x593e, 0x7ad2, 0x5955, 0x5950, 0x594e, 0x595a,
+ 0x5958, 0x5962, 0x5960, 0x5967, 0x596c, 0x5969,
+ /* 0x55 */
+ 0x5978, 0x5981, 0x599d, 0x4f5e, 0x4fab, 0x59a3, 0x59b2, 0x59c6,
+ 0x59e8, 0x59dc, 0x598d, 0x59d9, 0x59da, 0x5a25, 0x5a1f, 0x5a11,
+ 0x5a1c, 0x5a09, 0x5a1a, 0x5a40, 0x5a6c, 0x5a49, 0x5a35, 0x5a36,
+ 0x5a62, 0x5a6a, 0x5a9a, 0x5abc, 0x5abe, 0x5acb, 0x5ac2, 0x5abd,
+ 0x5ae3, 0x5ad7, 0x5ae6, 0x5ae9, 0x5ad6, 0x5afa, 0x5afb, 0x5b0c,
+ 0x5b0b, 0x5b16, 0x5b32, 0x5ad0, 0x5b2a, 0x5b36, 0x5b3e, 0x5b43,
+ 0x5b45, 0x5b40, 0x5b51, 0x5b55, 0x5b5a, 0x5b5b, 0x5b65, 0x5b69,
+ 0x5b70, 0x5b73, 0x5b75, 0x5b78, 0x6588, 0x5b7a, 0x5b80, 0x5b83,
+ 0x5ba6, 0x5bb8, 0x5bc3, 0x5bc7, 0x5bc9, 0x5bd4, 0x5bd0, 0x5be4,
+ 0x5be6, 0x5be2, 0x5bde, 0x5be5, 0x5beb, 0x5bf0, 0x5bf6, 0x5bf3,
+ 0x5c05, 0x5c07, 0x5c08, 0x5c0d, 0x5c13, 0x5c20, 0x5c22, 0x5c28,
+ 0x5c38, 0x5c39, 0x5c41, 0x5c46, 0x5c4e, 0x5c53,
+ /* 0x56 */
+ 0x5c50, 0x5c4f, 0x5b71, 0x5c6c, 0x5c6e, 0x4e62, 0x5c76, 0x5c79,
+ 0x5c8c, 0x5c91, 0x5c94, 0x599b, 0x5cab, 0x5cbb, 0x5cb6, 0x5cbc,
+ 0x5cb7, 0x5cc5, 0x5cbe, 0x5cc7, 0x5cd9, 0x5ce9, 0x5cfd, 0x5cfa,
+ 0x5ced, 0x5d8c, 0x5cea, 0x5d0b, 0x5d15, 0x5d17, 0x5d5c, 0x5d1f,
+ 0x5d1b, 0x5d11, 0x5d14, 0x5d22, 0x5d1a, 0x5d19, 0x5d18, 0x5d4c,
+ 0x5d52, 0x5d4e, 0x5d4b, 0x5d6c, 0x5d73, 0x5d76, 0x5d87, 0x5d84,
+ 0x5d82, 0x5da2, 0x5d9d, 0x5dac, 0x5dae, 0x5dbd, 0x5d90, 0x5db7,
+ 0x5dbc, 0x5dc9, 0x5dcd, 0x5dd3, 0x5dd2, 0x5dd6, 0x5ddb, 0x5deb,
+ 0x5df2, 0x5df5, 0x5e0b, 0x5e1a, 0x5e19, 0x5e11, 0x5e1b, 0x5e36,
+ 0x5e37, 0x5e44, 0x5e43, 0x5e40, 0x5e4e, 0x5e57, 0x5e54, 0x5e5f,
+ 0x5e62, 0x5e64, 0x5e47, 0x5e75, 0x5e76, 0x5e7a, 0x9ebc, 0x5e7f,
+ 0x5ea0, 0x5ec1, 0x5ec2, 0x5ec8, 0x5ed0, 0x5ecf,
+ /* 0x57 */
+ 0x5ed6, 0x5ee3, 0x5edd, 0x5eda, 0x5edb, 0x5ee2, 0x5ee1, 0x5ee8,
+ 0x5ee9, 0x5eec, 0x5ef1, 0x5ef3, 0x5ef0, 0x5ef4, 0x5ef8, 0x5efe,
+ 0x5f03, 0x5f09, 0x5f5d, 0x5f5c, 0x5f0b, 0x5f11, 0x5f16, 0x5f29,
+ 0x5f2d, 0x5f38, 0x5f41, 0x5f48, 0x5f4c, 0x5f4e, 0x5f2f, 0x5f51,
+ 0x5f56, 0x5f57, 0x5f59, 0x5f61, 0x5f6d, 0x5f73, 0x5f77, 0x5f83,
+ 0x5f82, 0x5f7f, 0x5f8a, 0x5f88, 0x5f91, 0x5f87, 0x5f9e, 0x5f99,
+ 0x5f98, 0x5fa0, 0x5fa8, 0x5fad, 0x5fbc, 0x5fd6, 0x5ffb, 0x5fe4,
+ 0x5ff8, 0x5ff1, 0x5fdd, 0x60b3, 0x5fff, 0x6021, 0x6060, 0x6019,
+ 0x6010, 0x6029, 0x600e, 0x6031, 0x601b, 0x6015, 0x602b, 0x6026,
+ 0x600f, 0x603a, 0x605a, 0x6041, 0x606a, 0x6077, 0x605f, 0x604a,
+ 0x6046, 0x604d, 0x6063, 0x6043, 0x6064, 0x6042, 0x606c, 0x606b,
+ 0x6059, 0x6081, 0x608d, 0x60e7, 0x6083, 0x609a,
+ /* 0x58 */
+ 0x6084, 0x609b, 0x6096, 0x6097, 0x6092, 0x60a7, 0x608b, 0x60e1,
+ 0x60b8, 0x60e0, 0x60d3, 0x60b4, 0x5ff0, 0x60bd, 0x60c6, 0x60b5,
+ 0x60d8, 0x614d, 0x6115, 0x6106, 0x60f6, 0x60f7, 0x6100, 0x60f4,
+ 0x60fa, 0x6103, 0x6121, 0x60fb, 0x60f1, 0x610d, 0x610e, 0x6147,
+ 0x613e, 0x6128, 0x6127, 0x614a, 0x613f, 0x613c, 0x612c, 0x6134,
+ 0x613d, 0x6142, 0x6144, 0x6173, 0x6177, 0x6158, 0x6159, 0x615a,
+ 0x616b, 0x6174, 0x616f, 0x6165, 0x6171, 0x615f, 0x615d, 0x6153,
+ 0x6175, 0x6199, 0x6196, 0x6187, 0x61ac, 0x6194, 0x619a, 0x618a,
+ 0x6191, 0x61ab, 0x61ae, 0x61cc, 0x61ca, 0x61c9, 0x61f7, 0x61c8,
+ 0x61c3, 0x61c6, 0x61ba, 0x61cb, 0x7f79, 0x61cd, 0x61e6, 0x61e3,
+ 0x61f6, 0x61fa, 0x61f4, 0x61ff, 0x61fd, 0x61fc, 0x61fe, 0x6200,
+ 0x6208, 0x6209, 0x620d, 0x620c, 0x6214, 0x621b,
+ /* 0x59 */
+ 0x621e, 0x6221, 0x622a, 0x622e, 0x6230, 0x6232, 0x6233, 0x6241,
+ 0x624e, 0x625e, 0x6263, 0x625b, 0x6260, 0x6268, 0x627c, 0x6282,
+ 0x6289, 0x627e, 0x6292, 0x6293, 0x6296, 0x62d4, 0x6283, 0x6294,
+ 0x62d7, 0x62d1, 0x62bb, 0x62cf, 0x62ff, 0x62c6, 0x64d4, 0x62c8,
+ 0x62dc, 0x62cc, 0x62ca, 0x62c2, 0x62c7, 0x629b, 0x62c9, 0x630c,
+ 0x62ee, 0x62f1, 0x6327, 0x6302, 0x6308, 0x62ef, 0x62f5, 0x6350,
+ 0x633e, 0x634d, 0x641c, 0x634f, 0x6396, 0x638e, 0x6380, 0x63ab,
+ 0x6376, 0x63a3, 0x638f, 0x6389, 0x639f, 0x63b5, 0x636b, 0x6369,
+ 0x63be, 0x63e9, 0x63c0, 0x63c6, 0x63e3, 0x63c9, 0x63d2, 0x63f6,
+ 0x63c4, 0x6416, 0x6434, 0x6406, 0x6413, 0x6426, 0x6436, 0x651d,
+ 0x6417, 0x6428, 0x640f, 0x6467, 0x646f, 0x6476, 0x644e, 0x652a,
+ 0x6495, 0x6493, 0x64a5, 0x64a9, 0x6488, 0x64bc,
+ /* 0x5a */
+ 0x64da, 0x64d2, 0x64c5, 0x64c7, 0x64bb, 0x64d8, 0x64c2, 0x64f1,
+ 0x64e7, 0x8209, 0x64e0, 0x64e1, 0x62ac, 0x64e3, 0x64ef, 0x652c,
+ 0x64f6, 0x64f4, 0x64f2, 0x64fa, 0x6500, 0x64fd, 0x6518, 0x651c,
+ 0x6505, 0x6524, 0x6523, 0x652b, 0x6534, 0x6535, 0x6537, 0x6536,
+ 0x6538, 0x754b, 0x6548, 0x6556, 0x6555, 0x654d, 0x6558, 0x655e,
+ 0x655d, 0x6572, 0x6578, 0x6582, 0x6583, 0x8b8a, 0x659b, 0x659f,
+ 0x65ab, 0x65b7, 0x65c3, 0x65c6, 0x65c1, 0x65c4, 0x65cc, 0x65d2,
+ 0x65db, 0x65d9, 0x65e0, 0x65e1, 0x65f1, 0x6772, 0x660a, 0x6603,
+ 0x65fb, 0x6773, 0x6635, 0x6636, 0x6634, 0x661c, 0x664f, 0x6644,
+ 0x6649, 0x6641, 0x665e, 0x665d, 0x6664, 0x6667, 0x6668, 0x665f,
+ 0x6662, 0x6670, 0x6683, 0x6688, 0x668e, 0x6689, 0x6684, 0x6698,
+ 0x669d, 0x66c1, 0x66b9, 0x66c9, 0x66be, 0x66bc,
+ /* 0x5b */
+ 0x66c4, 0x66b8, 0x66d6, 0x66da, 0x66e0, 0x663f, 0x66e6, 0x66e9,
+ 0x66f0, 0x66f5, 0x66f7, 0x670f, 0x6716, 0x671e, 0x6726, 0x6727,
+ 0x9738, 0x672e, 0x673f, 0x6736, 0x6741, 0x6738, 0x6737, 0x6746,
+ 0x675e, 0x6760, 0x6759, 0x6763, 0x6764, 0x6789, 0x6770, 0x67a9,
+ 0x677c, 0x676a, 0x678c, 0x678b, 0x67a6, 0x67a1, 0x6785, 0x67b7,
+ 0x67ef, 0x67b4, 0x67ec, 0x67b3, 0x67e9, 0x67b8, 0x67e4, 0x67de,
+ 0x67dd, 0x67e2, 0x67ee, 0x67b9, 0x67ce, 0x67c6, 0x67e7, 0x6a9c,
+ 0x681e, 0x6846, 0x6829, 0x6840, 0x684d, 0x6832, 0x684e, 0x68b3,
+ 0x682b, 0x6859, 0x6863, 0x6877, 0x687f, 0x689f, 0x688f, 0x68ad,
+ 0x6894, 0x689d, 0x689b, 0x6883, 0x6aae, 0x68b9, 0x6874, 0x68b5,
+ 0x68a0, 0x68ba, 0x690f, 0x688d, 0x687e, 0x6901, 0x68ca, 0x6908,
+ 0x68d8, 0x6922, 0x6926, 0x68e1, 0x690c, 0x68cd,
+ /* 0x5c */
+ 0x68d4, 0x68e7, 0x68d5, 0x6936, 0x6912, 0x6904, 0x68d7, 0x68e3,
+ 0x6925, 0x68f9, 0x68e0, 0x68ef, 0x6928, 0x692a, 0x691a, 0x6923,
+ 0x6921, 0x68c6, 0x6979, 0x6977, 0x695c, 0x6978, 0x696b, 0x6954,
+ 0x697e, 0x696e, 0x6939, 0x6974, 0x693d, 0x6959, 0x6930, 0x6961,
+ 0x695e, 0x695d, 0x6981, 0x696a, 0x69b2, 0x69ae, 0x69d0, 0x69bf,
+ 0x69c1, 0x69d3, 0x69be, 0x69ce, 0x5be8, 0x69ca, 0x69dd, 0x69bb,
+ 0x69c3, 0x69a7, 0x6a2e, 0x6991, 0x69a0, 0x699c, 0x6995, 0x69b4,
+ 0x69de, 0x69e8, 0x6a02, 0x6a1b, 0x69ff, 0x6b0a, 0x69f9, 0x69f2,
+ 0x69e7, 0x6a05, 0x69b1, 0x6a1e, 0x69ed, 0x6a14, 0x69eb, 0x6a0a,
+ 0x6a12, 0x6ac1, 0x6a23, 0x6a13, 0x6a44, 0x6a0c, 0x6a72, 0x6a36,
+ 0x6a78, 0x6a47, 0x6a62, 0x6a59, 0x6a66, 0x6a48, 0x6a38, 0x6a22,
+ 0x6a90, 0x6a8d, 0x6aa0, 0x6a84, 0x6aa2, 0x6aa3,
+ /* 0x5d */
+ 0x6a97, 0x8617, 0x6abb, 0x6ac3, 0x6ac2, 0x6ab8, 0x6ab3, 0x6aac,
+ 0x6ade, 0x6ad1, 0x6adf, 0x6aaa, 0x6ada, 0x6aea, 0x6afb, 0x6b05,
+ 0x8616, 0x6afa, 0x6b12, 0x6b16, 0x9b31, 0x6b1f, 0x6b38, 0x6b37,
+ 0x76dc, 0x6b39, 0x98ee, 0x6b47, 0x6b43, 0x6b49, 0x6b50, 0x6b59,
+ 0x6b54, 0x6b5b, 0x6b5f, 0x6b61, 0x6b78, 0x6b79, 0x6b7f, 0x6b80,
+ 0x6b84, 0x6b83, 0x6b8d, 0x6b98, 0x6b95, 0x6b9e, 0x6ba4, 0x6baa,
+ 0x6bab, 0x6baf, 0x6bb2, 0x6bb1, 0x6bb3, 0x6bb7, 0x6bbc, 0x6bc6,
+ 0x6bcb, 0x6bd3, 0x6bdf, 0x6bec, 0x6beb, 0x6bf3, 0x6bef, 0x9ebe,
+ 0x6c08, 0x6c13, 0x6c14, 0x6c1b, 0x6c24, 0x6c23, 0x6c5e, 0x6c55,
+ 0x6c62, 0x6c6a, 0x6c82, 0x6c8d, 0x6c9a, 0x6c81, 0x6c9b, 0x6c7e,
+ 0x6c68, 0x6c73, 0x6c92, 0x6c90, 0x6cc4, 0x6cf1, 0x6cd3, 0x6cbd,
+ 0x6cd7, 0x6cc5, 0x6cdd, 0x6cae, 0x6cb1, 0x6cbe,
+ /* 0x5e */
+ 0x6cba, 0x6cdb, 0x6cef, 0x6cd9, 0x6cea, 0x6d1f, 0x884d, 0x6d36,
+ 0x6d2b, 0x6d3d, 0x6d38, 0x6d19, 0x6d35, 0x6d33, 0x6d12, 0x6d0c,
+ 0x6d63, 0x6d93, 0x6d64, 0x6d5a, 0x6d79, 0x6d59, 0x6d8e, 0x6d95,
+ 0x6fe4, 0x6d85, 0x6df9, 0x6e15, 0x6e0a, 0x6db5, 0x6dc7, 0x6de6,
+ 0x6db8, 0x6dc6, 0x6dec, 0x6dde, 0x6dcc, 0x6de8, 0x6dd2, 0x6dc5,
+ 0x6dfa, 0x6dd9, 0x6de4, 0x6dd5, 0x6dea, 0x6dee, 0x6e2d, 0x6e6e,
+ 0x6e2e, 0x6e19, 0x6e72, 0x6e5f, 0x6e3e, 0x6e23, 0x6e6b, 0x6e2b,
+ 0x6e76, 0x6e4d, 0x6e1f, 0x6e43, 0x6e3a, 0x6e4e, 0x6e24, 0x6eff,
+ 0x6e1d, 0x6e38, 0x6e82, 0x6eaa, 0x6e98, 0x6ec9, 0x6eb7, 0x6ed3,
+ 0x6ebd, 0x6eaf, 0x6ec4, 0x6eb2, 0x6ed4, 0x6ed5, 0x6e8f, 0x6ea5,
+ 0x6ec2, 0x6e9f, 0x6f41, 0x6f11, 0x704c, 0x6eec, 0x6ef8, 0x6efe,
+ 0x6f3f, 0x6ef2, 0x6f31, 0x6eef, 0x6f32, 0x6ecc,
+ /* 0x5f */
+ 0x6f3e, 0x6f13, 0x6ef7, 0x6f86, 0x6f7a, 0x6f78, 0x6f81, 0x6f80,
+ 0x6f6f, 0x6f5b, 0x6ff3, 0x6f6d, 0x6f82, 0x6f7c, 0x6f58, 0x6f8e,
+ 0x6f91, 0x6fc2, 0x6f66, 0x6fb3, 0x6fa3, 0x6fa1, 0x6fa4, 0x6fb9,
+ 0x6fc6, 0x6faa, 0x6fdf, 0x6fd5, 0x6fec, 0x6fd4, 0x6fd8, 0x6ff1,
+ 0x6fee, 0x6fdb, 0x7009, 0x700b, 0x6ffa, 0x7011, 0x7001, 0x700f,
+ 0x6ffe, 0x701b, 0x701a, 0x6f74, 0x701d, 0x7018, 0x701f, 0x7030,
+ 0x703e, 0x7032, 0x7051, 0x7063, 0x7099, 0x7092, 0x70af, 0x70f1,
+ 0x70ac, 0x70b8, 0x70b3, 0x70ae, 0x70df, 0x70cb, 0x70dd, 0x70d9,
+ 0x7109, 0x70fd, 0x711c, 0x7119, 0x7165, 0x7155, 0x7188, 0x7166,
+ 0x7162, 0x714c, 0x7156, 0x716c, 0x718f, 0x71fb, 0x7184, 0x7195,
+ 0x71a8, 0x71ac, 0x71d7, 0x71b9, 0x71be, 0x71d2, 0x71c9, 0x71d4,
+ 0x71ce, 0x71e0, 0x71ec, 0x71e7, 0x71f5, 0x71fc,
+ /* 0x60 */
+ 0x71f9, 0x71ff, 0x720d, 0x7210, 0x721b, 0x7228, 0x722d, 0x722c,
+ 0x7230, 0x7232, 0x723b, 0x723c, 0x723f, 0x7240, 0x7246, 0x724b,
+ 0x7258, 0x7274, 0x727e, 0x7282, 0x7281, 0x7287, 0x7292, 0x7296,
+ 0x72a2, 0x72a7, 0x72b9, 0x72b2, 0x72c3, 0x72c6, 0x72c4, 0x72ce,
+ 0x72d2, 0x72e2, 0x72e0, 0x72e1, 0x72f9, 0x72f7, 0x500f, 0x7317,
+ 0x730a, 0x731c, 0x7316, 0x731d, 0x7334, 0x732f, 0x7329, 0x7325,
+ 0x733e, 0x734e, 0x734f, 0x9ed8, 0x7357, 0x736a, 0x7368, 0x7370,
+ 0x7378, 0x7375, 0x737b, 0x737a, 0x73c8, 0x73b3, 0x73ce, 0x73bb,
+ 0x73c0, 0x73e5, 0x73ee, 0x73de, 0x74a2, 0x7405, 0x746f, 0x7425,
+ 0x73f8, 0x7432, 0x743a, 0x7455, 0x743f, 0x745f, 0x7459, 0x7441,
+ 0x745c, 0x7469, 0x7470, 0x7463, 0x746a, 0x7476, 0x747e, 0x748b,
+ 0x749e, 0x74a7, 0x74ca, 0x74cf, 0x74d4, 0x73f1,
+ /* 0x61 */
+ 0x74e0, 0x74e3, 0x74e7, 0x74e9, 0x74ee, 0x74f2, 0x74f0, 0x74f1,
+ 0x74f8, 0x74f7, 0x7504, 0x7503, 0x7505, 0x750c, 0x750e, 0x750d,
+ 0x7515, 0x7513, 0x751e, 0x7526, 0x752c, 0x753c, 0x7544, 0x754d,
+ 0x754a, 0x7549, 0x755b, 0x7546, 0x755a, 0x7569, 0x7564, 0x7567,
+ 0x756b, 0x756d, 0x7578, 0x7576, 0x7586, 0x7587, 0x7574, 0x758a,
+ 0x7589, 0x7582, 0x7594, 0x759a, 0x759d, 0x75a5, 0x75a3, 0x75c2,
+ 0x75b3, 0x75c3, 0x75b5, 0x75bd, 0x75b8, 0x75bc, 0x75b1, 0x75cd,
+ 0x75ca, 0x75d2, 0x75d9, 0x75e3, 0x75de, 0x75fe, 0x75ff, 0x75fc,
+ 0x7601, 0x75f0, 0x75fa, 0x75f2, 0x75f3, 0x760b, 0x760d, 0x7609,
+ 0x761f, 0x7627, 0x7620, 0x7621, 0x7622, 0x7624, 0x7634, 0x7630,
+ 0x763b, 0x7647, 0x7648, 0x7646, 0x765c, 0x7658, 0x7661, 0x7662,
+ 0x7668, 0x7669, 0x766a, 0x7667, 0x766c, 0x7670,
+ /* 0x62 */
+ 0x7672, 0x7676, 0x7678, 0x767c, 0x7680, 0x7683, 0x7688, 0x768b,
+ 0x768e, 0x7696, 0x7693, 0x7699, 0x769a, 0x76b0, 0x76b4, 0x76b8,
+ 0x76b9, 0x76ba, 0x76c2, 0x76cd, 0x76d6, 0x76d2, 0x76de, 0x76e1,
+ 0x76e5, 0x76e7, 0x76ea, 0x862f, 0x76fb, 0x7708, 0x7707, 0x7704,
+ 0x7729, 0x7724, 0x771e, 0x7725, 0x7726, 0x771b, 0x7737, 0x7738,
+ 0x7747, 0x775a, 0x7768, 0x776b, 0x775b, 0x7765, 0x777f, 0x777e,
+ 0x7779, 0x778e, 0x778b, 0x7791, 0x77a0, 0x779e, 0x77b0, 0x77b6,
+ 0x77b9, 0x77bf, 0x77bc, 0x77bd, 0x77bb, 0x77c7, 0x77cd, 0x77d7,
+ 0x77da, 0x77dc, 0x77e3, 0x77ee, 0x77fc, 0x780c, 0x7812, 0x7926,
+ 0x7820, 0x792a, 0x7845, 0x788e, 0x7874, 0x7886, 0x787c, 0x789a,
+ 0x788c, 0x78a3, 0x78b5, 0x78aa, 0x78af, 0x78d1, 0x78c6, 0x78cb,
+ 0x78d4, 0x78be, 0x78bc, 0x78c5, 0x78ca, 0x78ec,
+ /* 0x63 */
+ 0x78e7, 0x78da, 0x78fd, 0x78f4, 0x7907, 0x7912, 0x7911, 0x7919,
+ 0x792c, 0x792b, 0x7940, 0x7960, 0x7957, 0x795f, 0x795a, 0x7955,
+ 0x7953, 0x797a, 0x797f, 0x798a, 0x799d, 0x79a7, 0x9f4b, 0x79aa,
+ 0x79ae, 0x79b3, 0x79b9, 0x79ba, 0x79c9, 0x79d5, 0x79e7, 0x79ec,
+ 0x79e1, 0x79e3, 0x7a08, 0x7a0d, 0x7a18, 0x7a19, 0x7a20, 0x7a1f,
+ 0x7980, 0x7a31, 0x7a3b, 0x7a3e, 0x7a37, 0x7a43, 0x7a57, 0x7a49,
+ 0x7a61, 0x7a62, 0x7a69, 0x9f9d, 0x7a70, 0x7a79, 0x7a7d, 0x7a88,
+ 0x7a97, 0x7a95, 0x7a98, 0x7a96, 0x7aa9, 0x7ac8, 0x7ab0, 0x7ab6,
+ 0x7ac5, 0x7ac4, 0x7abf, 0x9083, 0x7ac7, 0x7aca, 0x7acd, 0x7acf,
+ 0x7ad5, 0x7ad3, 0x7ad9, 0x7ada, 0x7add, 0x7ae1, 0x7ae2, 0x7ae6,
+ 0x7aed, 0x7af0, 0x7b02, 0x7b0f, 0x7b0a, 0x7b06, 0x7b33, 0x7b18,
+ 0x7b19, 0x7b1e, 0x7b35, 0x7b28, 0x7b36, 0x7b50,
+ /* 0x64 */
+ 0x7b7a, 0x7b04, 0x7b4d, 0x7b0b, 0x7b4c, 0x7b45, 0x7b75, 0x7b65,
+ 0x7b74, 0x7b67, 0x7b70, 0x7b71, 0x7b6c, 0x7b6e, 0x7b9d, 0x7b98,
+ 0x7b9f, 0x7b8d, 0x7b9c, 0x7b9a, 0x7b8b, 0x7b92, 0x7b8f, 0x7b5d,
+ 0x7b99, 0x7bcb, 0x7bc1, 0x7bcc, 0x7bcf, 0x7bb4, 0x7bc6, 0x7bdd,
+ 0x7be9, 0x7c11, 0x7c14, 0x7be6, 0x7be5, 0x7c60, 0x7c00, 0x7c07,
+ 0x7c13, 0x7bf3, 0x7bf7, 0x7c17, 0x7c0d, 0x7bf6, 0x7c23, 0x7c27,
+ 0x7c2a, 0x7c1f, 0x7c37, 0x7c2b, 0x7c3d, 0x7c4c, 0x7c43, 0x7c54,
+ 0x7c4f, 0x7c40, 0x7c50, 0x7c58, 0x7c5f, 0x7c64, 0x7c56, 0x7c65,
+ 0x7c6c, 0x7c75, 0x7c83, 0x7c90, 0x7ca4, 0x7cad, 0x7ca2, 0x7cab,
+ 0x7ca1, 0x7ca8, 0x7cb3, 0x7cb2, 0x7cb1, 0x7cae, 0x7cb9, 0x7cbd,
+ 0x7cc0, 0x7cc5, 0x7cc2, 0x7cd8, 0x7cd2, 0x7cdc, 0x7ce2, 0x9b3b,
+ 0x7cef, 0x7cf2, 0x7cf4, 0x7cf6, 0x7cfa, 0x7d06,
+ /* 0x65 */
+ 0x7d02, 0x7d1c, 0x7d15, 0x7d0a, 0x7d45, 0x7d4b, 0x7d2e, 0x7d32,
+ 0x7d3f, 0x7d35, 0x7d46, 0x7d73, 0x7d56, 0x7d4e, 0x7d72, 0x7d68,
+ 0x7d6e, 0x7d4f, 0x7d63, 0x7d93, 0x7d89, 0x7d5b, 0x7d8f, 0x7d7d,
+ 0x7d9b, 0x7dba, 0x7dae, 0x7da3, 0x7db5, 0x7dc7, 0x7dbd, 0x7dab,
+ 0x7e3d, 0x7da2, 0x7daf, 0x7ddc, 0x7db8, 0x7d9f, 0x7db0, 0x7dd8,
+ 0x7ddd, 0x7de4, 0x7dde, 0x7dfb, 0x7df2, 0x7de1, 0x7e05, 0x7e0a,
+ 0x7e23, 0x7e21, 0x7e12, 0x7e31, 0x7e1f, 0x7e09, 0x7e0b, 0x7e22,
+ 0x7e46, 0x7e66, 0x7e3b, 0x7e35, 0x7e39, 0x7e43, 0x7e37, 0x7e32,
+ 0x7e3a, 0x7e67, 0x7e5d, 0x7e56, 0x7e5e, 0x7e59, 0x7e5a, 0x7e79,
+ 0x7e6a, 0x7e69, 0x7e7c, 0x7e7b, 0x7e83, 0x7dd5, 0x7e7d, 0x8fae,
+ 0x7e7f, 0x7e88, 0x7e89, 0x7e8c, 0x7e92, 0x7e90, 0x7e93, 0x7e94,
+ 0x7e96, 0x7e8e, 0x7e9b, 0x7e9c, 0x7f38, 0x7f3a,
+ /* 0x66 */
+ 0x7f45, 0x7f4c, 0x7f4d, 0x7f4e, 0x7f50, 0x7f51, 0x7f55, 0x7f54,
+ 0x7f58, 0x7f5f, 0x7f60, 0x7f68, 0x7f69, 0x7f67, 0x7f78, 0x7f82,
+ 0x7f86, 0x7f83, 0x7f88, 0x7f87, 0x7f8c, 0x7f94, 0x7f9e, 0x7f9d,
+ 0x7f9a, 0x7fa3, 0x7faf, 0x7fb2, 0x7fb9, 0x7fae, 0x7fb6, 0x7fb8,
+ 0x8b71, 0x7fc5, 0x7fc6, 0x7fca, 0x7fd5, 0x7fd4, 0x7fe1, 0x7fe6,
+ 0x7fe9, 0x7ff3, 0x7ff9, 0x98dc, 0x8006, 0x8004, 0x800b, 0x8012,
+ 0x8018, 0x8019, 0x801c, 0x8021, 0x8028, 0x803f, 0x803b, 0x804a,
+ 0x8046, 0x8052, 0x8058, 0x805a, 0x805f, 0x8062, 0x8068, 0x8073,
+ 0x8072, 0x8070, 0x8076, 0x8079, 0x807d, 0x807f, 0x8084, 0x8086,
+ 0x8085, 0x809b, 0x8093, 0x809a, 0x80ad, 0x5190, 0x80ac, 0x80db,
+ 0x80e5, 0x80d9, 0x80dd, 0x80c4, 0x80da, 0x80d6, 0x8109, 0x80ef,
+ 0x80f1, 0x811b, 0x8129, 0x8123, 0x812f, 0x814b,
+ /* 0x67 */
+ 0x968b, 0x8146, 0x813e, 0x8153, 0x8151, 0x80fc, 0x8171, 0x816e,
+ 0x8165, 0x8166, 0x8174, 0x8183, 0x8188, 0x818a, 0x8180, 0x8182,
+ 0x81a0, 0x8195, 0x81a4, 0x81a3, 0x815f, 0x8193, 0x81a9, 0x81b0,
+ 0x81b5, 0x81be, 0x81b8, 0x81bd, 0x81c0, 0x81c2, 0x81ba, 0x81c9,
+ 0x81cd, 0x81d1, 0x81d9, 0x81d8, 0x81c8, 0x81da, 0x81df, 0x81e0,
+ 0x81e7, 0x81fa, 0x81fb, 0x81fe, 0x8201, 0x8202, 0x8205, 0x8207,
+ 0x820a, 0x820d, 0x8210, 0x8216, 0x8229, 0x822b, 0x8238, 0x8233,
+ 0x8240, 0x8259, 0x8258, 0x825d, 0x825a, 0x825f, 0x8264, 0x8262,
+ 0x8268, 0x826a, 0x826b, 0x822e, 0x8271, 0x8277, 0x8278, 0x827e,
+ 0x828d, 0x8292, 0x82ab, 0x829f, 0x82bb, 0x82ac, 0x82e1, 0x82e3,
+ 0x82df, 0x82d2, 0x82f4, 0x82f3, 0x82fa, 0x8393, 0x8303, 0x82fb,
+ 0x82f9, 0x82de, 0x8306, 0x82dc, 0x8309, 0x82d9,
+ /* 0x68 */
+ 0x8335, 0x8334, 0x8316, 0x8332, 0x8331, 0x8340, 0x8339, 0x8350,
+ 0x8345, 0x832f, 0x832b, 0x8317, 0x8318, 0x8385, 0x839a, 0x83aa,
+ 0x839f, 0x83a2, 0x8396, 0x8323, 0x838e, 0x8387, 0x838a, 0x837c,
+ 0x83b5, 0x8373, 0x8375, 0x83a0, 0x8389, 0x83a8, 0x83f4, 0x8413,
+ 0x83eb, 0x83ce, 0x83fd, 0x8403, 0x83d8, 0x840b, 0x83c1, 0x83f7,
+ 0x8407, 0x83e0, 0x83f2, 0x840d, 0x8422, 0x8420, 0x83bd, 0x8438,
+ 0x8506, 0x83fb, 0x846d, 0x842a, 0x843c, 0x855a, 0x8484, 0x8477,
+ 0x846b, 0x84ad, 0x846e, 0x8482, 0x8469, 0x8446, 0x842c, 0x846f,
+ 0x8479, 0x8435, 0x84ca, 0x8462, 0x84b9, 0x84bf, 0x849f, 0x84d9,
+ 0x84cd, 0x84bb, 0x84da, 0x84d0, 0x84c1, 0x84c6, 0x84d6, 0x84a1,
+ 0x8521, 0x84ff, 0x84f4, 0x8517, 0x8518, 0x852c, 0x851f, 0x8515,
+ 0x8514, 0x84fc, 0x8540, 0x8563, 0x8558, 0x8548,
+ /* 0x69 */
+ 0x8541, 0x8602, 0x854b, 0x8555, 0x8580, 0x85a4, 0x8588, 0x8591,
+ 0x858a, 0x85a8, 0x856d, 0x8594, 0x859b, 0x85ea, 0x8587, 0x859c,
+ 0x8577, 0x857e, 0x8590, 0x85c9, 0x85ba, 0x85cf, 0x85b9, 0x85d0,
+ 0x85d5, 0x85dd, 0x85e5, 0x85dc, 0x85f9, 0x860a, 0x8613, 0x860b,
+ 0x85fe, 0x85fa, 0x8606, 0x8622, 0x861a, 0x8630, 0x863f, 0x864d,
+ 0x4e55, 0x8654, 0x865f, 0x8667, 0x8671, 0x8693, 0x86a3, 0x86a9,
+ 0x86aa, 0x868b, 0x868c, 0x86b6, 0x86af, 0x86c4, 0x86c6, 0x86b0,
+ 0x86c9, 0x8823, 0x86ab, 0x86d4, 0x86de, 0x86e9, 0x86ec, 0x86df,
+ 0x86db, 0x86ef, 0x8712, 0x8706, 0x8708, 0x8700, 0x8703, 0x86fb,
+ 0x8711, 0x8709, 0x870d, 0x86f9, 0x870a, 0x8734, 0x873f, 0x8737,
+ 0x873b, 0x8725, 0x8729, 0x871a, 0x8760, 0x875f, 0x8778, 0x874c,
+ 0x874e, 0x8774, 0x8757, 0x8768, 0x876e, 0x8759,
+ /* 0x6a */
+ 0x8753, 0x8763, 0x876a, 0x8805, 0x87a2, 0x879f, 0x8782, 0x87af,
+ 0x87cb, 0x87bd, 0x87c0, 0x87d0, 0x96d6, 0x87ab, 0x87c4, 0x87b3,
+ 0x87c7, 0x87c6, 0x87bb, 0x87ef, 0x87f2, 0x87e0, 0x880f, 0x880d,
+ 0x87fe, 0x87f6, 0x87f7, 0x880e, 0x87d2, 0x8811, 0x8816, 0x8815,
+ 0x8822, 0x8821, 0x8831, 0x8836, 0x8839, 0x8827, 0x883b, 0x8844,
+ 0x8842, 0x8852, 0x8859, 0x885e, 0x8862, 0x886b, 0x8881, 0x887e,
+ 0x889e, 0x8875, 0x887d, 0x88b5, 0x8872, 0x8882, 0x8897, 0x8892,
+ 0x88ae, 0x8899, 0x88a2, 0x888d, 0x88a4, 0x88b0, 0x88bf, 0x88b1,
+ 0x88c3, 0x88c4, 0x88d4, 0x88d8, 0x88d9, 0x88dd, 0x88f9, 0x8902,
+ 0x88fc, 0x88f4, 0x88e8, 0x88f2, 0x8904, 0x890c, 0x890a, 0x8913,
+ 0x8943, 0x891e, 0x8925, 0x892a, 0x892b, 0x8941, 0x8944, 0x893b,
+ 0x8936, 0x8938, 0x894c, 0x891d, 0x8960, 0x895e,
+ /* 0x6b */
+ 0x8966, 0x8964, 0x896d, 0x896a, 0x896f, 0x8974, 0x8977, 0x897e,
+ 0x8983, 0x8988, 0x898a, 0x8993, 0x8998, 0x89a1, 0x89a9, 0x89a6,
+ 0x89ac, 0x89af, 0x89b2, 0x89ba, 0x89bd, 0x89bf, 0x89c0, 0x89da,
+ 0x89dc, 0x89dd, 0x89e7, 0x89f4, 0x89f8, 0x8a03, 0x8a16, 0x8a10,
+ 0x8a0c, 0x8a1b, 0x8a1d, 0x8a25, 0x8a36, 0x8a41, 0x8a5b, 0x8a52,
+ 0x8a46, 0x8a48, 0x8a7c, 0x8a6d, 0x8a6c, 0x8a62, 0x8a85, 0x8a82,
+ 0x8a84, 0x8aa8, 0x8aa1, 0x8a91, 0x8aa5, 0x8aa6, 0x8a9a, 0x8aa3,
+ 0x8ac4, 0x8acd, 0x8ac2, 0x8ada, 0x8aeb, 0x8af3, 0x8ae7, 0x8ae4,
+ 0x8af1, 0x8b14, 0x8ae0, 0x8ae2, 0x8af7, 0x8ade, 0x8adb, 0x8b0c,
+ 0x8b07, 0x8b1a, 0x8ae1, 0x8b16, 0x8b10, 0x8b17, 0x8b20, 0x8b33,
+ 0x97ab, 0x8b26, 0x8b2b, 0x8b3e, 0x8b28, 0x8b41, 0x8b4c, 0x8b4f,
+ 0x8b4e, 0x8b49, 0x8b56, 0x8b5b, 0x8b5a, 0x8b6b,
+ /* 0x6c */
+ 0x8b5f, 0x8b6c, 0x8b6f, 0x8b74, 0x8b7d, 0x8b80, 0x8b8c, 0x8b8e,
+ 0x8b92, 0x8b93, 0x8b96, 0x8b99, 0x8b9a, 0x8c3a, 0x8c41, 0x8c3f,
+ 0x8c48, 0x8c4c, 0x8c4e, 0x8c50, 0x8c55, 0x8c62, 0x8c6c, 0x8c78,
+ 0x8c7a, 0x8c82, 0x8c89, 0x8c85, 0x8c8a, 0x8c8d, 0x8c8e, 0x8c94,
+ 0x8c7c, 0x8c98, 0x621d, 0x8cad, 0x8caa, 0x8cbd, 0x8cb2, 0x8cb3,
+ 0x8cae, 0x8cb6, 0x8cc8, 0x8cc1, 0x8ce4, 0x8ce3, 0x8cda, 0x8cfd,
+ 0x8cfa, 0x8cfb, 0x8d04, 0x8d05, 0x8d0a, 0x8d07, 0x8d0f, 0x8d0d,
+ 0x8d10, 0x9f4e, 0x8d13, 0x8ccd, 0x8d14, 0x8d16, 0x8d67, 0x8d6d,
+ 0x8d71, 0x8d73, 0x8d81, 0x8d99, 0x8dc2, 0x8dbe, 0x8dba, 0x8dcf,
+ 0x8dda, 0x8dd6, 0x8dcc, 0x8ddb, 0x8dcb, 0x8dea, 0x8deb, 0x8ddf,
+ 0x8de3, 0x8dfc, 0x8e08, 0x8e09, 0x8dff, 0x8e1d, 0x8e1e, 0x8e10,
+ 0x8e1f, 0x8e42, 0x8e35, 0x8e30, 0x8e34, 0x8e4a,
+ /* 0x6d */
+ 0x8e47, 0x8e49, 0x8e4c, 0x8e50, 0x8e48, 0x8e59, 0x8e64, 0x8e60,
+ 0x8e2a, 0x8e63, 0x8e55, 0x8e76, 0x8e72, 0x8e7c, 0x8e81, 0x8e87,
+ 0x8e85, 0x8e84, 0x8e8b, 0x8e8a, 0x8e93, 0x8e91, 0x8e94, 0x8e99,
+ 0x8eaa, 0x8ea1, 0x8eac, 0x8eb0, 0x8ec6, 0x8eb1, 0x8ebe, 0x8ec5,
+ 0x8ec8, 0x8ecb, 0x8edb, 0x8ee3, 0x8efc, 0x8efb, 0x8eeb, 0x8efe,
+ 0x8f0a, 0x8f05, 0x8f15, 0x8f12, 0x8f19, 0x8f13, 0x8f1c, 0x8f1f,
+ 0x8f1b, 0x8f0c, 0x8f26, 0x8f33, 0x8f3b, 0x8f39, 0x8f45, 0x8f42,
+ 0x8f3e, 0x8f4c, 0x8f49, 0x8f46, 0x8f4e, 0x8f57, 0x8f5c, 0x8f62,
+ 0x8f63, 0x8f64, 0x8f9c, 0x8f9f, 0x8fa3, 0x8fad, 0x8faf, 0x8fb7,
+ 0x8fda, 0x8fe5, 0x8fe2, 0x8fea, 0x8fef, 0x9087, 0x8ff4, 0x9005,
+ 0x8ff9, 0x8ffa, 0x9011, 0x9015, 0x9021, 0x900d, 0x901e, 0x9016,
+ 0x900b, 0x9027, 0x9036, 0x9035, 0x9039, 0x8ff8,
+ /* 0x6e */
+ 0x904f, 0x9050, 0x9051, 0x9052, 0x900e, 0x9049, 0x903e, 0x9056,
+ 0x9058, 0x905e, 0x9068, 0x906f, 0x9076, 0x96a8, 0x9072, 0x9082,
+ 0x907d, 0x9081, 0x9080, 0x908a, 0x9089, 0x908f, 0x90a8, 0x90af,
+ 0x90b1, 0x90b5, 0x90e2, 0x90e4, 0x6248, 0x90db, 0x9102, 0x9112,
+ 0x9119, 0x9132, 0x9130, 0x914a, 0x9156, 0x9158, 0x9163, 0x9165,
+ 0x9169, 0x9173, 0x9172, 0x918b, 0x9189, 0x9182, 0x91a2, 0x91ab,
+ 0x91af, 0x91aa, 0x91b5, 0x91b4, 0x91ba, 0x91c0, 0x91c1, 0x91c9,
+ 0x91cb, 0x91d0, 0x91d6, 0x91df, 0x91e1, 0x91db, 0x91fc, 0x91f5,
+ 0x91f6, 0x921e, 0x91ff, 0x9214, 0x922c, 0x9215, 0x9211, 0x925e,
+ 0x9257, 0x9245, 0x9249, 0x9264, 0x9248, 0x9295, 0x923f, 0x924b,
+ 0x9250, 0x929c, 0x9296, 0x9293, 0x929b, 0x925a, 0x92cf, 0x92b9,
+ 0x92b7, 0x92e9, 0x930f, 0x92fa, 0x9344, 0x932e,
+ /* 0x6f */
+ 0x9319, 0x9322, 0x931a, 0x9323, 0x933a, 0x9335, 0x933b, 0x935c,
+ 0x9360, 0x937c, 0x936e, 0x9356, 0x93b0, 0x93ac, 0x93ad, 0x9394,
+ 0x93b9, 0x93d6, 0x93d7, 0x93e8, 0x93e5, 0x93d8, 0x93c3, 0x93dd,
+ 0x93d0, 0x93c8, 0x93e4, 0x941a, 0x9414, 0x9413, 0x9403, 0x9407,
+ 0x9410, 0x9436, 0x942b, 0x9435, 0x9421, 0x943a, 0x9441, 0x9452,
+ 0x9444, 0x945b, 0x9460, 0x9462, 0x945e, 0x946a, 0x9229, 0x9470,
+ 0x9475, 0x9477, 0x947d, 0x945a, 0x947c, 0x947e, 0x9481, 0x947f,
+ 0x9582, 0x9587, 0x958a, 0x9594, 0x9596, 0x9598, 0x9599, 0x95a0,
+ 0x95a8, 0x95a7, 0x95ad, 0x95bc, 0x95bb, 0x95b9, 0x95be, 0x95ca,
+ 0x6ff6, 0x95c3, 0x95cd, 0x95cc, 0x95d5, 0x95d4, 0x95d6, 0x95dc,
+ 0x95e1, 0x95e5, 0x95e2, 0x9621, 0x9628, 0x962e, 0x962f, 0x9642,
+ 0x964c, 0x964f, 0x964b, 0x9677, 0x965c, 0x965e,
+ /* 0x70 */
+ 0x965d, 0x965f, 0x9666, 0x9672, 0x966c, 0x968d, 0x9698, 0x9695,
+ 0x9697, 0x96aa, 0x96a7, 0x96b1, 0x96b2, 0x96b0, 0x96b4, 0x96b6,
+ 0x96b8, 0x96b9, 0x96ce, 0x96cb, 0x96c9, 0x96cd, 0x894d, 0x96dc,
+ 0x970d, 0x96d5, 0x96f9, 0x9704, 0x9706, 0x9708, 0x9713, 0x970e,
+ 0x9711, 0x970f, 0x9716, 0x9719, 0x9724, 0x972a, 0x9730, 0x9739,
+ 0x973d, 0x973e, 0x9744, 0x9746, 0x9748, 0x9742, 0x9749, 0x975c,
+ 0x9760, 0x9764, 0x9766, 0x9768, 0x52d2, 0x976b, 0x9771, 0x9779,
+ 0x9785, 0x977c, 0x9781, 0x977a, 0x9786, 0x978b, 0x978f, 0x9790,
+ 0x979c, 0x97a8, 0x97a6, 0x97a3, 0x97b3, 0x97b4, 0x97c3, 0x97c6,
+ 0x97c8, 0x97cb, 0x97dc, 0x97ed, 0x9f4f, 0x97f2, 0x7adf, 0x97f6,
+ 0x97f5, 0x980f, 0x980c, 0x9838, 0x9824, 0x9821, 0x9837, 0x983d,
+ 0x9846, 0x984f, 0x984b, 0x986b, 0x986f, 0x9870,
+ /* 0x71 */
+ 0x9871, 0x9874, 0x9873, 0x98aa, 0x98af, 0x98b1, 0x98b6, 0x98c4,
+ 0x98c3, 0x98c6, 0x98e9, 0x98eb, 0x9903, 0x9909, 0x9912, 0x9914,
+ 0x9918, 0x9921, 0x991d, 0x991e, 0x9924, 0x9920, 0x992c, 0x992e,
+ 0x993d, 0x993e, 0x9942, 0x9949, 0x9945, 0x9950, 0x994b, 0x9951,
+ 0x9952, 0x994c, 0x9955, 0x9997, 0x9998, 0x99a5, 0x99ad, 0x99ae,
+ 0x99bc, 0x99df, 0x99db, 0x99dd, 0x99d8, 0x99d1, 0x99ed, 0x99ee,
+ 0x99f1, 0x99f2, 0x99fb, 0x99f8, 0x9a01, 0x9a0f, 0x9a05, 0x99e2,
+ 0x9a19, 0x9a2b, 0x9a37, 0x9a45, 0x9a42, 0x9a40, 0x9a43, 0x9a3e,
+ 0x9a55, 0x9a4d, 0x9a5b, 0x9a57, 0x9a5f, 0x9a62, 0x9a65, 0x9a64,
+ 0x9a69, 0x9a6b, 0x9a6a, 0x9aad, 0x9ab0, 0x9abc, 0x9ac0, 0x9acf,
+ 0x9ad1, 0x9ad3, 0x9ad4, 0x9ade, 0x9adf, 0x9ae2, 0x9ae3, 0x9ae6,
+ 0x9aef, 0x9aeb, 0x9aee, 0x9af4, 0x9af1, 0x9af7,
+ /* 0x72 */
+ 0x9afb, 0x9b06, 0x9b18, 0x9b1a, 0x9b1f, 0x9b22, 0x9b23, 0x9b25,
+ 0x9b27, 0x9b28, 0x9b29, 0x9b2a, 0x9b2e, 0x9b2f, 0x9b32, 0x9b44,
+ 0x9b43, 0x9b4f, 0x9b4d, 0x9b4e, 0x9b51, 0x9b58, 0x9b74, 0x9b93,
+ 0x9b83, 0x9b91, 0x9b96, 0x9b97, 0x9b9f, 0x9ba0, 0x9ba8, 0x9bb4,
+ 0x9bc0, 0x9bca, 0x9bb9, 0x9bc6, 0x9bcf, 0x9bd1, 0x9bd2, 0x9be3,
+ 0x9be2, 0x9be4, 0x9bd4, 0x9be1, 0x9c3a, 0x9bf2, 0x9bf1, 0x9bf0,
+ 0x9c15, 0x9c14, 0x9c09, 0x9c13, 0x9c0c, 0x9c06, 0x9c08, 0x9c12,
+ 0x9c0a, 0x9c04, 0x9c2e, 0x9c1b, 0x9c25, 0x9c24, 0x9c21, 0x9c30,
+ 0x9c47, 0x9c32, 0x9c46, 0x9c3e, 0x9c5a, 0x9c60, 0x9c67, 0x9c76,
+ 0x9c78, 0x9ce7, 0x9cec, 0x9cf0, 0x9d09, 0x9d08, 0x9ceb, 0x9d03,
+ 0x9d06, 0x9d2a, 0x9d26, 0x9daf, 0x9d23, 0x9d1f, 0x9d44, 0x9d15,
+ 0x9d12, 0x9d41, 0x9d3f, 0x9d3e, 0x9d46, 0x9d48,
+ /* 0x73 */
+ 0x9d5d, 0x9d5e, 0x9d64, 0x9d51, 0x9d50, 0x9d59, 0x9d72, 0x9d89,
+ 0x9d87, 0x9dab, 0x9d6f, 0x9d7a, 0x9d9a, 0x9da4, 0x9da9, 0x9db2,
+ 0x9dc4, 0x9dc1, 0x9dbb, 0x9db8, 0x9dba, 0x9dc6, 0x9dcf, 0x9dc2,
+ 0x9dd9, 0x9dd3, 0x9df8, 0x9de6, 0x9ded, 0x9def, 0x9dfd, 0x9e1a,
+ 0x9e1b, 0x9e1e, 0x9e75, 0x9e79, 0x9e7d, 0x9e81, 0x9e88, 0x9e8b,
+ 0x9e8c, 0x9e92, 0x9e95, 0x9e91, 0x9e9d, 0x9ea5, 0x9ea9, 0x9eb8,
+ 0x9eaa, 0x9ead, 0x9761, 0x9ecc, 0x9ece, 0x9ecf, 0x9ed0, 0x9ed4,
+ 0x9edc, 0x9ede, 0x9edd, 0x9ee0, 0x9ee5, 0x9ee8, 0x9eef, 0x9ef4,
+ 0x9ef6, 0x9ef7, 0x9ef9, 0x9efb, 0x9efc, 0x9efd, 0x9f07, 0x9f08,
+ 0x76b7, 0x9f15, 0x9f21, 0x9f2c, 0x9f3e, 0x9f4a, 0x9f52, 0x9f54,
+ 0x9f63, 0x9f5f, 0x9f60, 0x9f61, 0x9f66, 0x9f67, 0x9f6c, 0x9f6a,
+ 0x9f77, 0x9f72, 0x9f76, 0x9f95, 0x9f9c, 0x9fa0,
+ /* 0x74 */
+ 0x582f, 0x69c7, 0x9059, 0x7464, 0x51dc, 0x7199,
+};
+
+static int
+jisx0208_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c1 = (s[0] & 0x7F);
+ if ((c1 >= 0x21 && c1 <= 0x28) || (c1 >= 0x30 && c1 <= 0x74)) {
+ if (n >= 2) {
+ unsigned char c2 = (s[1] & 0x7F);
+ if (c2 >= 0x21 && c2 < 0x7f) {
+ unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21);
+ unsigned short wc = 0xfffd;
+ if (i < 1410) {
+ if (i < 690)
+ wc = jisx0208_2uni_page21[i];
+ } else {
+ if (i < 7808)
+ wc = jisx0208_2uni_page30[i-1410];
+ }
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 2;
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOFEW(0);
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned short jisx0208_2charset[6879] = {
+ 0x2140, 0x2171, 0x2172, 0x2178, 0x212f, 0x224c, 0x216b, 0x215e,
+ 0x212d, 0x2279, 0x215f, 0x2160, 0x2621, 0x2622, 0x2623, 0x2624,
+ 0x2625, 0x2626, 0x2627, 0x2628, 0x2629, 0x262a, 0x262b, 0x262c,
+ 0x262d, 0x262e, 0x262f, 0x2630, 0x2631, 0x2632, 0x2633, 0x2634,
+ 0x2635, 0x2636, 0x2637, 0x2638, 0x2641, 0x2642, 0x2643, 0x2644,
+ 0x2645, 0x2646, 0x2647, 0x2648, 0x2649, 0x264a, 0x264b, 0x264c,
+ 0x264d, 0x264e, 0x264f, 0x2650, 0x2651, 0x2652, 0x2653, 0x2654,
+ 0x2655, 0x2656, 0x2657, 0x2658, 0x2727, 0x2721, 0x2722, 0x2723,
+ 0x2724, 0x2725, 0x2726, 0x2728, 0x2729, 0x272a, 0x272b, 0x272c,
+ 0x272d, 0x272e, 0x272f, 0x2730, 0x2731, 0x2732, 0x2733, 0x2734,
+ 0x2735, 0x2736, 0x2737, 0x2738, 0x2739, 0x273a, 0x273b, 0x273c,
+ 0x273d, 0x273e, 0x273f, 0x2740, 0x2741, 0x2751, 0x2752, 0x2753,
+ 0x2754, 0x2755, 0x2756, 0x2758, 0x2759, 0x275a, 0x275b, 0x275c,
+ 0x275d, 0x275e, 0x275f, 0x2760, 0x2761, 0x2762, 0x2763, 0x2764,
+ 0x2765, 0x2766, 0x2767, 0x2768, 0x2769, 0x276a, 0x276b, 0x276c,
+ 0x276d, 0x276e, 0x276f, 0x2770, 0x2771, 0x2757, 0x213e, 0x213d,
+ 0x2142, 0x2146, 0x2147, 0x2148, 0x2149, 0x2277, 0x2278, 0x2145,
+ 0x2144, 0x2273, 0x216c, 0x216d, 0x2228, 0x216e, 0x2272, 0x222b,
+ 0x222c, 0x222a, 0x222d, 0x224d, 0x224e, 0x224f, 0x225f, 0x2250,
+ 0x2260, 0x223a, 0x223b, 0x215d, 0x2265, 0x2267, 0x2167, 0x225c,
+ 0x224a, 0x224b, 0x2241, 0x2240, 0x2269, 0x226a, 0x2168, 0x2268,
+ 0x2266, 0x2262, 0x2162, 0x2261, 0x2165, 0x2166, 0x2263, 0x2264,
+ 0x223e, 0x223f, 0x223c, 0x223d, 0x225d, 0x225e, 0x2821, 0x282c,
+ 0x2822, 0x282d, 0x2823, 0x282e, 0x2824, 0x282f, 0x2826, 0x2831,
+ 0x2825, 0x2830, 0x2827, 0x283c, 0x2837, 0x2832, 0x2829, 0x283e,
+ 0x2839, 0x2834, 0x2828, 0x2838, 0x283d, 0x2833, 0x282a, 0x283a,
+ 0x283f, 0x2835, 0x282b, 0x283b, 0x2840, 0x2836, 0x2223, 0x2222,
+ 0x2225, 0x2224, 0x2227, 0x2226, 0x2221, 0x217e, 0x217b, 0x217d,
+ 0x217c, 0x227e, 0x217a, 0x2179, 0x216a, 0x2169, 0x2276, 0x2275,
+ 0x2274, 0x2121, 0x2122, 0x2123, 0x2137, 0x2139, 0x213a, 0x213b,
+ 0x2152, 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159,
+ 0x215a, 0x215b, 0x2229, 0x222e, 0x214c, 0x214d, 0x2141, 0x2421,
+ 0x2422, 0x2423, 0x2424, 0x2425, 0x2426, 0x2427, 0x2428, 0x2429,
+ 0x242a, 0x242b, 0x242c, 0x242d, 0x242e, 0x242f, 0x2430, 0x2431,
+ 0x2432, 0x2433, 0x2434, 0x2435, 0x2436, 0x2437, 0x2438, 0x2439,
+ 0x243a, 0x243b, 0x243c, 0x243d, 0x243e, 0x243f, 0x2440, 0x2441,
+ 0x2442, 0x2443, 0x2444, 0x2445, 0x2446, 0x2447, 0x2448, 0x2449,
+ 0x244a, 0x244b, 0x244c, 0x244d, 0x244e, 0x244f, 0x2450, 0x2451,
+ 0x2452, 0x2453, 0x2454, 0x2455, 0x2456, 0x2457, 0x2458, 0x2459,
+ 0x245a, 0x245b, 0x245c, 0x245d, 0x245e, 0x245f, 0x2460, 0x2461,
+ 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, 0x2468, 0x2469,
+ 0x246a, 0x246b, 0x246c, 0x246d, 0x246e, 0x246f, 0x2470, 0x2471,
+ 0x2472, 0x2473, 0x212b, 0x212c, 0x2135, 0x2136, 0x2521, 0x2522,
+ 0x2523, 0x2524, 0x2525, 0x2526, 0x2527, 0x2528, 0x2529, 0x252a,
+ 0x252b, 0x252c, 0x252d, 0x252e, 0x252f, 0x2530, 0x2531, 0x2532,
+ 0x2533, 0x2534, 0x2535, 0x2536, 0x2537, 0x2538, 0x2539, 0x253a,
+ 0x253b, 0x253c, 0x253d, 0x253e, 0x253f, 0x2540, 0x2541, 0x2542,
+ 0x2543, 0x2544, 0x2545, 0x2546, 0x2547, 0x2548, 0x2549, 0x254a,
+ 0x254b, 0x254c, 0x254d, 0x254e, 0x254f, 0x2550, 0x2551, 0x2552,
+ 0x2553, 0x2554, 0x2555, 0x2556, 0x2557, 0x2558, 0x2559, 0x255a,
+ 0x255b, 0x255c, 0x255d, 0x255e, 0x255f, 0x2560, 0x2561, 0x2562,
+ 0x2563, 0x2564, 0x2565, 0x2566, 0x2567, 0x2568, 0x2569, 0x256a,
+ 0x256b, 0x256c, 0x256d, 0x256e, 0x256f, 0x2570, 0x2571, 0x2572,
+ 0x2573, 0x2574, 0x2575, 0x2576, 0x2126, 0x213c, 0x2133, 0x2134,
+ 0x306c, 0x437a, 0x3c37, 0x4b7c, 0x3e66, 0x3b30, 0x3e65, 0x323c,
+ 0x4954, 0x4d3f, 0x5022, 0x312f, 0x336e, 0x5023, 0x4024, 0x5242,
+ 0x3556, 0x4a3a, 0x3e67, 0x4e3e, 0x4a42, 0x5024, 0x4366, 0x5025,
+ 0x367a, 0x5026, 0x345d, 0x4330, 0x3c67, 0x5027, 0x5028, 0x5029,
+ 0x4735, 0x3557, 0x4737, 0x4663, 0x3843, 0x4b33, 0x6949, 0x502a,
+ 0x3e68, 0x502b, 0x3235, 0x3665, 0x3870, 0x4c69, 0x5626, 0x4d70,
+ 0x467d, 0x3425, 0x3535, 0x502c, 0x502d, 0x4e3b, 0x4d3d, 0x4168,
+ 0x502f, 0x3b76, 0x4673, 0x5032, 0x313e, 0x385f, 0x385e, 0x3066,
+ 0x4f4b, 0x4f4a, 0x3a33, 0x3021, 0x5033, 0x5034, 0x5035, 0x4b34,
+ 0x5036, 0x3872, 0x3067, 0x4b72, 0x357c, 0x357d, 0x357e, 0x4462,
+ 0x4e3c, 0x5037, 0x5038, 0x5039, 0x3f4d, 0x3d3a, 0x3f4e, 0x503e,
+ 0x503c, 0x503d, 0x3558, 0x3a23, 0x3270, 0x503b, 0x503a, 0x4a29,
+ 0x3b46, 0x3b45, 0x423e, 0x503f, 0x4955, 0x4067, 0x2138, 0x5040,
+ 0x5042, 0x4265, 0x4e61, 0x304a, 0x5041, 0x323e, 0x3644, 0x4367,
+ 0x376f, 0x5043, 0x4724, 0x346b, 0x5044, 0x304b, 0x3860, 0x346c,
+ 0x497a, 0x4832, 0x3559, 0x3271, 0x5067, 0x4541, 0x476c, 0x5046,
+ 0x483c, 0x4e62, 0x3f2d, 0x3b47, 0x3b77, 0x3240, 0x4451, 0x4322,
+ 0x504a, 0x304c, 0x4463, 0x3d3b, 0x3a34, 0x4d24, 0x424e, 0x323f,
+ 0x5049, 0x4d3e, 0x5045, 0x5047, 0x3a6e, 0x5048, 0x5524, 0x5050,
+ 0x5053, 0x5051, 0x3242, 0x4a3b, 0x504b, 0x504f, 0x3873, 0x3b48,
+ 0x3426, 0x5054, 0x504c, 0x4e63, 0x3b78, 0x504d, 0x5052, 0x5055,
+ 0x504e, 0x3621, 0x304d, 0x3622, 0x3241, 0x5525, 0x4b79, 0x496e,
+ 0x3874, 0x3f2f, 0x4e37, 0x4a58, 0x3738, 0x4225, 0x3264, 0x3d53,
+ 0x5059, 0x505e, 0x505c, 0x5057, 0x422f, 0x505a, 0x505d, 0x505b,
+ 0x4a5d, 0x5058, 0x3f2e, 0x4b73, 0x505f, 0x5060, 0x3d24, 0x506d,
+ 0x4750, 0x4936, 0x5068, 0x4a70, 0x3236, 0x506c, 0x5066, 0x506f,
+ 0x4152, 0x3844, 0x475c, 0x6047, 0x506e, 0x455d, 0x5063, 0x3876,
+ 0x3875, 0x5061, 0x3c5a, 0x5069, 0x4a6f, 0x434d, 0x5065, 0x3771,
+ 0x5062, 0x506a, 0x5064, 0x4e51, 0x506b, 0x4f41, 0x3666, 0x3770,
+ 0x5070, 0x5071, 0x5075, 0x304e, 0x4a50, 0x5074, 0x5073, 0x5077,
+ 0x5076, 0x4464, 0x3772, 0x5078, 0x3c45, 0x4226, 0x4465, 0x3676,
+ 0x5079, 0x3536, 0x507a, 0x507c, 0x4b35, 0x3766, 0x3b31, 0x4877,
+ 0x507b, 0x3a45, 0x4d43, 0x507e, 0x5123, 0x507d, 0x3a44, 0x3d7d,
+ 0x3739, 0x5124, 0x364f, 0x5121, 0x5122, 0x462f, 0x417c, 0x3623,
+ 0x4b4d, 0x5125, 0x4e3d, 0x5126, 0x5129, 0x5127, 0x414e, 0x5128,
+ 0x512a, 0x512c, 0x512b, 0x4a48, 0x3537, 0x512e, 0x512f, 0x322f,
+ 0x512d, 0x3c74, 0x5132, 0x5131, 0x5130, 0x5056, 0x5133, 0x3d7e,
+ 0x5134, 0x4d25, 0x4c59, 0x5136, 0x5135, 0x5138, 0x5137, 0x5139,
+ 0x513a, 0x3074, 0x3835, 0x373b, 0x3d3c, 0x437b, 0x3624, 0x4068,
+ 0x3877, 0x396e, 0x513c, 0x4c48, 0x4546, 0x3b79, 0x513b, 0x513d,
+ 0x455e, 0x3375, 0x513e, 0x467e, 0x4134, 0x5140, 0x5141, 0x482c,
+ 0x3878, 0x4f3b, 0x5142, 0x3626, 0x4a3c, 0x4236, 0x3671, 0x4535,
+ 0x3773, 0x5143, 0x5144, 0x4662, 0x315f, 0x5147, 0x3a7d, 0x5146,
+ 0x3a46, 0x5148, 0x666e, 0x5149, 0x4b41, 0x514a, 0x514b, 0x514c,
+ 0x3e69, 0x3c4c, 0x3427, 0x514f, 0x514d, 0x4c3d, 0x514e, 0x495a,
+ 0x5150, 0x5151, 0x5152, 0x455f, 0x5156, 0x5154, 0x5155, 0x5153,
+ 0x3a63, 0x5157, 0x4c6a, 0x4e64, 0x5158, 0x4028, 0x5159, 0x3d5a,
+ 0x515a, 0x437c, 0x4e3f, 0x4560, 0x5245, 0x515b, 0x7425, 0x3645,
+ 0x515c, 0x4b5e, 0x3d68, 0x427c, 0x515e, 0x4664, 0x515f, 0x5160,
+ 0x332e, 0x5161, 0x3627, 0x464c, 0x317a, 0x3d50, 0x4821, 0x5162,
+ 0x4561, 0x3f4f, 0x5163, 0x4a2c, 0x405a, 0x3422, 0x3429, 0x5164,
+ 0x5166, 0x373a, 0x5165, 0x4e73, 0x3d69, 0x483d, 0x4a4c, 0x5167,
+ 0x4d78, 0x5168, 0x5169, 0x457e, 0x516a, 0x4029, 0x3a7e, 0x3774,
+ 0x516b, 0x3b49, 0x396f, 0x4466, 0x516d, 0x4227, 0x3a6f, 0x516e,
+ 0x516f, 0x4130, 0x516c, 0x5171, 0x4b36, 0x3964, 0x5170, 0x3775,
+ 0x3a5e, 0x476d, 0x5174, 0x5172, 0x497b, 0x3e6a, 0x517b, 0x3364,
+ 0x5175, 0x5173, 0x414f, 0x5177, 0x5176, 0x3344, 0x3760, 0x517c,
+ 0x4e2d, 0x5178, 0x517d, 0x517a, 0x5179, 0x4e4f, 0x3879, 0x3243,
+ 0x4e74, 0x3d75, 0x4558, 0x3965, 0x5222, 0x5223, 0x4e65, 0x4f2b,
+ 0x5225, 0x387a, 0x5224, 0x332f, 0x5226, 0x4b56, 0x443c, 0x4d26,
+ 0x4a59, 0x5227, 0x7055, 0x4630, 0x5228, 0x342a, 0x4c33, 0x3e21,
+ 0x5229, 0x4a67, 0x522d, 0x402a, 0x522a, 0x3650, 0x522b, 0x342b,
+ 0x372e, 0x522e, 0x522f, 0x5230, 0x5231, 0x3c5b, 0x387b, 0x4c5e,
+ 0x4c68, 0x4677, 0x4a71, 0x5232, 0x5233, 0x5235, 0x5237, 0x5236,
+ 0x5238, 0x323d, 0x4b4c, 0x3a7c, 0x5239, 0x4159, 0x3e22, 0x3629,
+ 0x523a, 0x485b, 0x523b, 0x523c, 0x523d, 0x523e, 0x4924, 0x3668,
+ 0x3065, 0x463f, 0x523f, 0x3d3d, 0x4069, 0x5241, 0x5240, 0x3e23,
+ 0x3861, 0x5243, 0x483e, 0x5244, 0x485c, 0x4234, 0x426e, 0x3628,
+ 0x466e, 0x4331, 0x476e, 0x4b4e, 0x5246, 0x406a, 0x3735, 0x5247,
+ 0x5248, 0x312c, 0x3075, 0x346d, 0x4228, 0x3551, 0x4d71, 0x524b,
+ 0x3237, 0x524a, 0x362a, 0x524c, 0x4c71, 0x524d, 0x4e52, 0x387c,
+ 0x3836, 0x524e, 0x5250, 0x524f, 0x3f5f, 0x3139, 0x315e, 0x5251,
+ 0x5252, 0x3837, 0x5253, 0x356e, 0x3b32, 0x5254, 0x4b74, 0x3a35,
+ 0x355a, 0x4d27, 0x4150, 0x483f, 0x3c7d, 0x3d47, 0x3c68, 0x3c75,
+ 0x3d76, 0x4840, 0x5257, 0x3143, 0x4151, 0x387d, 0x3845, 0x3667,
+ 0x525b, 0x4321, 0x427e, 0x362b, 0x3e24, 0x525c, 0x525a, 0x3244,
+ 0x4266, 0x3c38, 0x3b4b, 0x3126, 0x3370, 0x3966, 0x3b4a, 0x525d,
+ 0x525e, 0x3549, 0x3346, 0x3967, 0x3548, 0x445f, 0x3125, 0x4631,
+ 0x4c3e, 0x3921, 0x4d79, 0x4547, 0x387e, 0x372f, 0x5267, 0x3663,
+ 0x4b4a, 0x485d, 0x5266, 0x345e, 0x5261, 0x5262, 0x5264, 0x5265,
+ 0x355b, 0x3f61, 0x4a2d, 0x5263, 0x525f, 0x3863, 0x5260, 0x4f24,
+ 0x4a72, 0x4468, 0x3862, 0x3970, 0x5268, 0x465d, 0x526c, 0x3c7e,
+ 0x3c76, 0x526f, 0x526d, 0x4c23, 0x526a, 0x5273, 0x526e, 0x5271,
+ 0x3846, 0x4c3f, 0x5272, 0x5274, 0x5276, 0x3a70, 0x4f42, 0x526b,
+ 0x5269, 0x5275, 0x5270, 0x5278, 0x5323, 0x527a, 0x527e, 0x5321,
+ 0x527b, 0x533e, 0x3a69, 0x3331, 0x5279, 0x5325, 0x3076, 0x5324,
+ 0x3025, 0x494a, 0x5322, 0x527c, 0x5277, 0x527d, 0x3a48, 0x5326,
+ 0x3077, 0x532f, 0x5327, 0x5328, 0x3e25, 0x4b69, 0x532d, 0x532c,
+ 0x452f, 0x532e, 0x532b, 0x3134, 0x3a36, 0x3f30, 0x5329, 0x4562,
+ 0x532a, 0x3022, 0x5334, 0x4d23, 0x3e27, 0x533a, 0x5339, 0x5330,
+ 0x4243, 0x5331, 0x426f, 0x5336, 0x3e26, 0x5333, 0x4c64, 0x373c,
+ 0x5337, 0x5338, 0x5335, 0x533b, 0x5332, 0x5341, 0x5346, 0x5342,
+ 0x533d, 0x5347, 0x4131, 0x5349, 0x3922, 0x533f, 0x437d, 0x5343,
+ 0x533c, 0x342d, 0x346e, 0x3365, 0x5344, 0x5340, 0x3776, 0x534a,
+ 0x5348, 0x4153, 0x354a, 0x362c, 0x5345, 0x3674, 0x3144, 0x534e,
+ 0x534c, 0x5427, 0x5351, 0x534b, 0x534f, 0x534d, 0x3b4c, 0x5350,
+ 0x5353, 0x5358, 0x5356, 0x5355, 0x4332, 0x3245, 0x5352, 0x5354,
+ 0x3e28, 0x3133, 0x5357, 0x325e, 0x5362, 0x3e7c, 0x535e, 0x535c,
+ 0x535d, 0x535f, 0x313d, 0x4139, 0x5359, 0x535a, 0x337a, 0x5361,
+ 0x346f, 0x5364, 0x5360, 0x5363, 0x4a2e, 0x4655, 0x4838, 0x5366,
+ 0x5365, 0x3345, 0x5367, 0x536a, 0x5369, 0x5368, 0x4739, 0x536b,
+ 0x536c, 0x536e, 0x536d, 0x5370, 0x5373, 0x5371, 0x536f, 0x5372,
+ 0x5374, 0x5375, 0x5376, 0x5377, 0x5378, 0x5145, 0x3c7c, 0x3b4d,
+ 0x3273, 0x3078, 0x4344, 0x5379, 0x3a24, 0x304f, 0x3f5e, 0x537a,
+ 0x3847, 0x3971, 0x537c, 0x537b, 0x4a60, 0x537d, 0x5421, 0x537e,
+ 0x5422, 0x5423, 0x3777, 0x3160, 0x5424, 0x5426, 0x5425, 0x5428,
+ 0x455a, 0x5429, 0x3035, 0x3a5f, 0x373d, 0x434f, 0x542a, 0x542b,
+ 0x542d, 0x542e, 0x3a64, 0x3651, 0x4b37, 0x542c, 0x542f, 0x3a41,
+ 0x3923, 0x5433, 0x3a25, 0x4333, 0x5430, 0x445a, 0x5434, 0x3f62,
+ 0x5432, 0x5435, 0x373f, 0x5436, 0x5437, 0x3924, 0x3340, 0x5439,
+ 0x543a, 0x543b, 0x5438, 0x5431, 0x543c, 0x543d, 0x4b64, 0x3e6b,
+ 0x543f, 0x5440, 0x543e, 0x5442, 0x4738, 0x3068, 0x4956, 0x5443,
+ 0x3e7d, 0x3c39, 0x475d, 0x3470, 0x3a6b, 0x4b59, 0x4632, 0x3778,
+ 0x424f, 0x5441, 0x5444, 0x4244, 0x5445, 0x5446, 0x5448, 0x4469,
+ 0x342e, 0x7421, 0x3161, 0x4a73, 0x3e6c, 0x4548, 0x3a66, 0x544e,
+ 0x4a3d, 0x4e5d, 0x3274, 0x544a, 0x413a, 0x544d, 0x4563, 0x4549,
+ 0x4564, 0x4839, 0x444d, 0x3a49, 0x5449, 0x3176, 0x4536, 0x544b,
+ 0x5447, 0x3f50, 0x544f, 0x3d4e, 0x362d, 0x5450, 0x4a68, 0x417d,
+ 0x4446, 0x5452, 0x4b4f, 0x5453, 0x5458, 0x4a2f, 0x5457, 0x5451,
+ 0x5454, 0x5456, 0x3a26, 0x4a49, 0x5459, 0x4345, 0x3275, 0x3e6d,
+ 0x545b, 0x545a, 0x3968, 0x545c, 0x545e, 0x545d, 0x5460, 0x5455,
+ 0x5462, 0x5461, 0x545f, 0x3b4e, 0x3f51, 0x4154, 0x5463, 0x403c,
+ 0x306d, 0x4764, 0x445b, 0x5465, 0x5464, 0x5466, 0x5467, 0x5468,
+ 0x5469, 0x4a51, 0x546a, 0x3246, 0x546b, 0x4d3c, 0x3330, 0x5249,
+ 0x3d48, 0x423f, 0x546c, 0x4c6b, 0x4c34, 0x546e, 0x4267, 0x4537,
+ 0x4240, 0x4957, 0x546f, 0x5470, 0x317b, 0x3c3a, 0x5471, 0x3050,
+ 0x5472, 0x5473, 0x3162, 0x3471, 0x4660, 0x4a74, 0x5477, 0x4155,
+ 0x5476, 0x3740, 0x4b5b, 0x5475, 0x4565, 0x5479, 0x5478, 0x547b,
+ 0x547a, 0x317c, 0x547c, 0x3e29, 0x547e, 0x4325, 0x547d, 0x4a33,
+ 0x3d77, 0x455b, 0x5521, 0x3925, 0x5522, 0x4721, 0x485e, 0x4c51,
+ 0x4725, 0x552b, 0x3538, 0x4d45, 0x4c2f, 0x562c, 0x5523, 0x5526,
+ 0x4245, 0x4b38, 0x454a, 0x5527, 0x4b65, 0x3a4a, 0x3e2a, 0x5528,
+ 0x3b50, 0x3b4f, 0x3039, 0x3848, 0x402b, 0x3051, 0x552c, 0x552d,
+ 0x552a, 0x3138, 0x342f, 0x5529, 0x4c45, 0x4931, 0x3028, 0x3079,
+ 0x3b51, 0x3052, 0x3023, 0x5532, 0x5530, 0x4c3c, 0x5533, 0x5531,
+ 0x552f, 0x3f31, 0x552e, 0x4a5a, 0x3864, 0x5537, 0x5538, 0x3e2b,
+ 0x5534, 0x4f2c, 0x474c, 0x5536, 0x3a27, 0x5539, 0x4958, 0x553a,
+ 0x5535, 0x4c3b, 0x475e, 0x553b, 0x4932, 0x553c, 0x5540, 0x553d,
+ 0x3247, 0x553f, 0x3c3b, 0x553e, 0x3779, 0x554c, 0x5545, 0x5542,
+ 0x4364, 0x5541, 0x5543, 0x5544, 0x5546, 0x5547, 0x3472, 0x5549,
+ 0x5548, 0x554a, 0x3e6e, 0x554d, 0x445c, 0x3145, 0x554b, 0x554e,
+ 0x554f, 0x5552, 0x5550, 0x5551, 0x3b52, 0x5553, 0x3926, 0x5554,
+ 0x3b7a, 0x4238, 0x5555, 0x5556, 0x3b5a, 0x3927, 0x4c52, 0x3528,
+ 0x3849, 0x5557, 0x3358, 0x5558, 0x4239, 0x5559, 0x5623, 0x555a,
+ 0x555b, 0x555c, 0x555e, 0x555f, 0x5560, 0x4270, 0x3127, 0x3c69,
+ 0x3042, 0x4157, 0x3430, 0x3c35, 0x3928, 0x4566, 0x3d21, 0x3431,
+ 0x4368, 0x446a, 0x3038, 0x3539, 0x4a75, 0x3c42, 0x3552, 0x406b,
+ 0x3c3c, 0x4d28, 0x5561, 0x355c, 0x3a4b, 0x3332, 0x3163, 0x3e2c,
+ 0x3248, 0x5562, 0x4d46, 0x3d49, 0x3c64, 0x5563, 0x3473, 0x4652,
+ 0x4c29, 0x5564, 0x5565, 0x4959, 0x5567, 0x3428, 0x3677, 0x5566,
+ 0x3432, 0x3f32, 0x556b, 0x3b21, 0x3249, 0x556a, 0x5568, 0x556c,
+ 0x5569, 0x472b, 0x5c4d, 0x3f33, 0x556d, 0x4e40, 0x556e, 0x5570,
+ 0x437e, 0x556f, 0x4023, 0x3b7b, 0x4250, 0x3c77, 0x4975, 0x406c,
+ 0x3c4d, 0x5571, 0x3e2d, 0x5572, 0x5573, 0x3053, 0x423a, 0x3f52,
+ 0x5574, 0x4633, 0x3e2e, 0x3e2f, 0x5575, 0x406d, 0x3e30, 0x5576,
+ 0x5577, 0x4c60, 0x5578, 0x3646, 0x3d22, 0x5579, 0x557a, 0x3c5c,
+ 0x3f2c, 0x4674, 0x3f54, 0x4878, 0x4722, 0x3649, 0x557b, 0x356f,
+ 0x557c, 0x367e, 0x464f, 0x3230, 0x3b53, 0x557d, 0x5622, 0x5621,
+ 0x367d, 0x557e, 0x4538, 0x4230, 0x454b, 0x3c48, 0x4158, 0x4d7a,
+ 0x5624, 0x5625, 0x4656, 0x3b33, 0x5627, 0x5628, 0x5629, 0x3474,
+ 0x562a, 0x562b, 0x322c, 0x413b, 0x3464, 0x562d, 0x4c28, 0x4252,
+ 0x3359, 0x562f, 0x5631, 0x345f, 0x562e, 0x5630, 0x5633, 0x5632,
+ 0x5634, 0x5635, 0x463d, 0x362e, 0x3265, 0x5636, 0x563b, 0x5639,
+ 0x4a77, 0x4a76, 0x4567, 0x5638, 0x3d54, 0x5637, 0x3f72, 0x563c,
+ 0x3a6a, 0x5642, 0x5643, 0x563d, 0x3333, 0x563e, 0x5647, 0x5646,
+ 0x5645, 0x5641, 0x5640, 0x5644, 0x4a78, 0x564b, 0x5648, 0x564a,
+ 0x4d72, 0x5649, 0x563f, 0x3f73, 0x564c, 0x3a37, 0x564d, 0x564e,
+ 0x5651, 0x5650, 0x564f, 0x4568, 0x563a, 0x5657, 0x5653, 0x5652,
+ 0x5654, 0x5655, 0x5658, 0x4e66, 0x5659, 0x5656, 0x565a, 0x3460,
+ 0x565b, 0x565d, 0x565c, 0x565e, 0x565f, 0x406e, 0x3d23, 0x3d64,
+ 0x4163, 0x3929, 0x3a38, 0x392a, 0x3570, 0x5660, 0x3a39, 0x384a,
+ 0x5661, 0x4c26, 0x4743, 0x5662, 0x392b, 0x342c, 0x4327, 0x3652,
+ 0x3b54, 0x495b, 0x4841, 0x5663, 0x3475, 0x5666, 0x4421, 0x5665,
+ 0x5664, 0x5667, 0x446b, 0x3f63, 0x3b55, 0x404a, 0x4253, 0x3522,
+ 0x4422, 0x5668, 0x5669, 0x3e6f, 0x4b39, 0x566c, 0x566b, 0x566a,
+ 0x497d, 0x5673, 0x4b5a, 0x566d, 0x566f, 0x4b6b, 0x566e, 0x5670,
+ 0x4828, 0x5671, 0x4a3e, 0x5672, 0x3433, 0x4a3f, 0x472f, 0x5674,
+ 0x5675, 0x392c, 0x3434, 0x5676, 0x3838, 0x4d44, 0x4d29, 0x3476,
+ 0x5678, 0x4423, 0x392d, 0x3e31, 0x485f, 0x3e32, 0x3d78, 0x446c,
+ 0x4a79, 0x4539, 0x392e, 0x495c, 0x5679, 0x4559, 0x3a42, 0x384b,
+ 0x446d, 0x3043, 0x3d6e, 0x392f, 0x4d47, 0x567a, 0x567b, 0x4751,
+ 0x567c, 0x4e77, 0x4f2d, 0x567e, 0x567d, 0x3347, 0x5721, 0x5724,
+ 0x5725, 0x5723, 0x4940, 0x3e33, 0x5727, 0x5726, 0x5722, 0x5728,
+ 0x5729, 0x572a, 0x572d, 0x572b, 0x572c, 0x572e, 0x3164, 0x446e,
+ 0x572f, 0x377a, 0x3276, 0x4736, 0x5730, 0x467b, 0x4a5b, 0x5731,
+ 0x4f2e, 0x5732, 0x4a40, 0x5735, 0x5021, 0x5031, 0x3c30, 0x4675,
+ 0x5736, 0x355d, 0x4424, 0x307a, 0x5737, 0x4a26, 0x3930, 0x4350,
+ 0x446f, 0x4c6f, 0x3839, 0x384c, 0x5738, 0x5739, 0x573f, 0x3c65,
+ 0x4425, 0x362f, 0x573a, 0x492b, 0x4346, 0x573b, 0x573c, 0x3630,
+ 0x573d, 0x573e, 0x5740, 0x4576, 0x5741, 0x5742, 0x5743, 0x5734,
+ 0x5733, 0x5744, 0x3741, 0x4927, 0x3a4c, 0x4937, 0x4426, 0x494b,
+ 0x5745, 0x3e34, 0x3146, 0x5746, 0x5747, 0x4c72, 0x4860, 0x574a,
+ 0x317d, 0x402c, 0x5749, 0x5748, 0x3742, 0x4254, 0x574e, 0x574c,
+ 0x574b, 0x4e27, 0x3865, 0x3d79, 0x574d, 0x454c, 0x3d3e, 0x4640,
+ 0x5751, 0x5750, 0x574f, 0x5752, 0x3866, 0x5753, 0x497c, 0x3d5b,
+ 0x5754, 0x4879, 0x4641, 0x4427, 0x4530, 0x5755, 0x352b, 0x3f34,
+ 0x492c, 0x3477, 0x4726, 0x5756, 0x3b56, 0x4b3a, 0x4b3b, 0x317e,
+ 0x575b, 0x4369, 0x5758, 0x3277, 0x582d, 0x575a, 0x4730, 0x5759,
+ 0x5757, 0x397a, 0x575d, 0x5763, 0x5769, 0x5761, 0x455c, 0x5766,
+ 0x495d, 0x5760, 0x5765, 0x4e67, 0x3b57, 0x4255, 0x575e, 0x355e,
+ 0x5768, 0x402d, 0x3165, 0x5762, 0x3278, 0x5767, 0x3631, 0x5764,
+ 0x576a, 0x576c, 0x5776, 0x5774, 0x5771, 0x5770, 0x4e78, 0x5772,
+ 0x3632, 0x3931, 0x3d7a, 0x5779, 0x576b, 0x576f, 0x575f, 0x327a,
+ 0x5773, 0x5775, 0x4351, 0x3a28, 0x3238, 0x576d, 0x5778, 0x5777,
+ 0x3633, 0x4229, 0x3366, 0x3743, 0x576e, 0x577a, 0x577d, 0x5821,
+ 0x3c3d, 0x5827, 0x4470, 0x577b, 0x5825, 0x3279, 0x5823, 0x5824,
+ 0x577e, 0x5822, 0x3867, 0x4d2a, 0x3435, 0x3159, 0x5826, 0x473a,
+ 0x302d, 0x4861, 0x575c, 0x582c, 0x5830, 0x4c65, 0x5829, 0x4569,
+ 0x582e, 0x3e70, 0x582f, 0x4657, 0x4f47, 0x582b, 0x5831, 0x397b,
+ 0x404b, 0x3054, 0x582a, 0x5828, 0x415a, 0x577c, 0x3b34, 0x4246,
+ 0x583d, 0x415b, 0x5838, 0x5835, 0x5836, 0x3c66, 0x5839, 0x583c,
+ 0x5837, 0x3d25, 0x583a, 0x5834, 0x4c7c, 0x4c7b, 0x583e, 0x583f,
+ 0x3055, 0x5833, 0x3672, 0x3026, 0x3436, 0x583b, 0x5843, 0x5842,
+ 0x5847, 0x5848, 0x5846, 0x5849, 0x5841, 0x5845, 0x584a, 0x584b,
+ 0x5840, 0x3b7c, 0x5844, 0x4256, 0x3932, 0x5832, 0x3f35, 0x5858,
+ 0x4a69, 0x584e, 0x584f, 0x5850, 0x5857, 0x5856, 0x4b7d, 0x3437,
+ 0x5854, 0x3745, 0x3334, 0x5851, 0x4e38, 0x5853, 0x3056, 0x5855,
+ 0x584c, 0x5852, 0x5859, 0x3744, 0x584d, 0x4d5d, 0x4d2b, 0x585c,
+ 0x5860, 0x417e, 0x4e79, 0x5861, 0x585e, 0x585b, 0x585a, 0x585f,
+ 0x4a30, 0x4634, 0x3746, 0x5862, 0x585d, 0x5863, 0x377b, 0x3231,
+ 0x586b, 0x3438, 0x5869, 0x586a, 0x3a29, 0x5868, 0x5866, 0x5865,
+ 0x586c, 0x5864, 0x586e, 0x327b, 0x5870, 0x586f, 0x4428, 0x5873,
+ 0x5871, 0x5867, 0x377c, 0x5872, 0x5876, 0x5875, 0x5877, 0x5874,
+ 0x5878, 0x5879, 0x587a, 0x4a6a, 0x587c, 0x587b, 0x3d3f, 0x402e,
+ 0x3266, 0x327c, 0x587d, 0x303f, 0x404c, 0x587e, 0x6c43, 0x5921,
+ 0x3761, 0x5922, 0x406f, 0x5923, 0x5924, 0x353a, 0x5925, 0x5926,
+ 0x5927, 0x4257, 0x384d, 0x4c61, 0x4b3c, 0x3d6a, 0x5928, 0x4070,
+ 0x6e3d, 0x4862, 0x3c6a, 0x3a4d, 0x5929, 0x4247, 0x4a27, 0x4271,
+ 0x592c, 0x592a, 0x592d, 0x592b, 0x592e, 0x4a31, 0x3037, 0x495e,
+ 0x4863, 0x592f, 0x5932, 0x3e35, 0x353b, 0x5930, 0x5937, 0x3e36,
+ 0x5931, 0x4744, 0x4d5e, 0x5933, 0x5934, 0x5938, 0x456a, 0x5935,
+ 0x3933, 0x405e, 0x5946, 0x4834, 0x4272, 0x4864, 0x5a2d, 0x4a7a,
+ 0x4471, 0x4b75, 0x593b, 0x3221, 0x436a, 0x5944, 0x4334, 0x593e,
+ 0x5945, 0x5940, 0x5947, 0x5943, 0x5942, 0x476f, 0x593c, 0x327d,
+ 0x593a, 0x3571, 0x4273, 0x5936, 0x5939, 0x3934, 0x405b, 0x3e37,
+ 0x5941, 0x4752, 0x3572, 0x3348, 0x3367, 0x3f21, 0x5949, 0x594e,
+ 0x594a, 0x377d, 0x594f, 0x3b22, 0x3969, 0x3d26, 0x593d, 0x3b7d,
+ 0x594c, 0x3b58, 0x594d, 0x3044, 0x5948, 0x4429, 0x3573, 0x3634,
+ 0x594b, 0x3027, 0x3a43, 0x3f36, 0x4472, 0x4854, 0x5951, 0x415e,
+ 0x422a, 0x3b2b, 0x5952, 0x5954, 0x5950, 0x4a61, 0x443d, 0x415c,
+ 0x4a7b, 0x3c4e, 0x5960, 0x595f, 0x3f78, 0x377e, 0x5959, 0x3e39,
+ 0x4668, 0x4731, 0x5957, 0x415d, 0x3c78, 0x595c, 0x3e38, 0x5956,
+ 0x595b, 0x4753, 0x5955, 0x3721, 0x335d, 0x595d, 0x4e2b, 0x3a4e,
+ 0x4335, 0x595a, 0x405c, 0x3935, 0x3f64, 0x3166, 0x413c, 0x5958,
+ 0x3545, 0x3747, 0x444f, 0x595e, 0x415f, 0x5961, 0x5963, 0x4237,
+ 0x5969, 0x5964, 0x5966, 0x4941, 0x4473, 0x5967, 0x4d2c, 0x4d48,
+ 0x3439, 0x302e, 0x5965, 0x5962, 0x3478, 0x3167, 0x5968, 0x4d49,
+ 0x596c, 0x423b, 0x5973, 0x596d, 0x596a, 0x5971, 0x5953, 0x596e,
+ 0x5972, 0x4842, 0x456b, 0x596b, 0x596f, 0x3748, 0x3a71, 0x405d,
+ 0x5977, 0x4526, 0x5974, 0x4b60, 0x5975, 0x5976, 0x4c4e, 0x4022,
+ 0x3762, 0x597d, 0x3b35, 0x597a, 0x5979, 0x4732, 0x4635, 0x4531,
+ 0x597b, 0x597c, 0x496f, 0x4745, 0x3b23, 0x4071, 0x4b50, 0x3349,
+ 0x5a25, 0x597e, 0x4d4a, 0x5a27, 0x5a23, 0x5a24, 0x4160, 0x5a22,
+ 0x593f, 0x5a26, 0x5a21, 0x5a2b, 0x5a2c, 0x4527, 0x5a2e, 0x3b24,
+ 0x5a29, 0x353c, 0x5a2f, 0x5a28, 0x5a33, 0x5a32, 0x5a31, 0x5a34,
+ 0x5a36, 0x3e71, 0x5a35, 0x5a39, 0x5a37, 0x5a38, 0x5970, 0x5a3b,
+ 0x5a3a, 0x5978, 0x5a3c, 0x5a30, 0x3b59, 0x5a3d, 0x5a3e, 0x5a40,
+ 0x5a3f, 0x5a41, 0x327e, 0x3936, 0x4a7c, 0x402f, 0x384e, 0x5a43,
+ 0x5a46, 0x4952, 0x355f, 0x5a45, 0x5a44, 0x4754, 0x5a47, 0x3635,
+ 0x5a49, 0x5a48, 0x343a, 0x3b36, 0x4658, 0x3749, 0x3f74, 0x5a4a,
+ 0x4030, 0x4528, 0x495f, 0x5a4b, 0x5a4c, 0x5a4d, 0x4a38, 0x555d,
+ 0x4046, 0x494c, 0x3a58, 0x4865, 0x4843, 0x454d, 0x4e41, 0x5a4f,
+ 0x3c50, 0x5a50, 0x3036, 0x3654, 0x404d, 0x4960, 0x5a51, 0x3b42,
+ 0x4347, 0x3b5b, 0x3f37, 0x5a52, 0x4a7d, 0x3177, 0x3b5c, 0x5a55,
+ 0x5a53, 0x5a56, 0x4e39, 0x5a54, 0x407b, 0x5a57, 0x4232, 0x5a58,
+ 0x347a, 0x5a5a, 0x5a59, 0x5a5b, 0x5a5c, 0x347b, 0x467c, 0x4336,
+ 0x356c, 0x3b5d, 0x4161, 0x3d5c, 0x3030, 0x5a5d, 0x3222, 0x5a61,
+ 0x3937, 0x5a60, 0x3a2b, 0x3e3a, 0x5a5f, 0x3e3b, 0x4c40, 0x3a2a,
+ 0x3057, 0x404e, 0x5a66, 0x4031, 0x3147, 0x3d55, 0x4b66, 0x3a72,
+ 0x3e3c, 0x4027, 0x5a65, 0x5a63, 0x5a64, 0x436b, 0x5b26, 0x5a6a,
+ 0x3b7e, 0x3938, 0x5a68, 0x5a69, 0x3f38, 0x5a67, 0x3b2f, 0x5a6c,
+ 0x5a6b, 0x5a70, 0x5a71, 0x5a6d, 0x3322, 0x5a6e, 0x5a6f, 0x4855,
+ 0x4961, 0x374a, 0x5a72, 0x4032, 0x3e3d, 0x4352, 0x3647, 0x5a73,
+ 0x5a77, 0x324b, 0x5a74, 0x5a76, 0x5a75, 0x3d6b, 0x4348, 0x3045,
+ 0x5a78, 0x5a79, 0x442a, 0x4e71, 0x3b43, 0x4a6b, 0x4b3d, 0x5b22,
+ 0x5a7b, 0x5a7e, 0x5a7d, 0x5a7a, 0x5b21, 0x465e, 0x5a7c, 0x5b23,
+ 0x3d6c, 0x5b24, 0x4d4b, 0x4778, 0x5b25, 0x5b27, 0x5b28, 0x5b29,
+ 0x364a, 0x3148, 0x3939, 0x5b2a, 0x5b2b, 0x3d71, 0x4162, 0x5258,
+ 0x413e, 0x413d, 0x4258, 0x3a47, 0x5072, 0x376e, 0x4d2d, 0x4a7e,
+ 0x497e, 0x5b2c, 0x3a73, 0x443f, 0x5b2d, 0x4f2f, 0x4b3e, 0x442b,
+ 0x5b2e, 0x347c, 0x5b2f, 0x5b30, 0x4c5a, 0x4c24, 0x4b76, 0x4b5c,
+ 0x3b25, 0x5b32, 0x3c6b, 0x4b51, 0x5b34, 0x5b37, 0x5b36, 0x3479,
+ 0x3560, 0x5b33, 0x5b35, 0x5b38, 0x3f79, 0x4d7b, 0x3049, 0x3a60,
+ 0x423c, 0x3c5d, 0x3e73, 0x5b3b, 0x454e, 0x5b39, 0x422b, 0x5b3a,
+ 0x3e72, 0x4c5d, 0x5b3c, 0x5b3d, 0x4d68, 0x5b42, 0x393a, 0x4755,
+ 0x5b3f, 0x456c, 0x5a5e, 0x5a62, 0x354f, 0x4747, 0x5b41, 0x3e3e,
+ 0x4844, 0x5b47, 0x487a, 0x5b3e, 0x5b44, 0x5b43, 0x404f, 0x4b6d,
+ 0x4e53, 0x4b67, 0x324c, 0x3b5e, 0x4f48, 0x5b46, 0x3f75, 0x5b45,
+ 0x5b40, 0x384f, 0x5b4c, 0x5b4a, 0x324d, 0x5b48, 0x5b4e, 0x5b54,
+ 0x4248, 0x4a41, 0x5b56, 0x4922, 0x5b55, 0x4770, 0x4b3f, 0x343b,
+ 0x4077, 0x3d40, 0x4453, 0x4d2e, 0x5b51, 0x5b50, 0x5b52, 0x5b4f,
+ 0x5b57, 0x5b4d, 0x5b4b, 0x5b53, 0x5b49, 0x436c, 0x4c78, 0x3c46,
+ 0x3a74, 0x3a3a, 0x4b6f, 0x3341, 0x444e, 0x464a, 0x3149, 0x4072,
+ 0x4034, 0x372a, 0x5b59, 0x393b, 0x337c, 0x5b5b, 0x3374, 0x5b61,
+ 0x5b5e, 0x4073, 0x334b, 0x3a2c, 0x334a, 0x3a4f, 0x5b5c, 0x3765,
+ 0x374b, 0x456d, 0x5b5a, 0x3046, 0x5b5d, 0x5b5f, 0x364d, 0x372c,
+ 0x343c, 0x354b, 0x5b62, 0x3a79, 0x4b71, 0x3b37, 0x5b63, 0x4930,
+ 0x5b6f, 0x3233, 0x5b64, 0x5b75, 0x5b65, 0x4e42, 0x5b6c, 0x475f,
+ 0x5b74, 0x5b67, 0x3034, 0x5b69, 0x393c, 0x5b6b, 0x5b6a, 0x5b66,
+ 0x5b71, 0x3e3f, 0x546d, 0x3868, 0x4d7c, 0x5b68, 0x4474, 0x3323,
+ 0x3a2d, 0x5b60, 0x5b70, 0x3361, 0x5b6e, 0x5b72, 0x456e, 0x347e,
+ 0x5c32, 0x4c49, 0x5b77, 0x347d, 0x5b7e, 0x4b40, 0x5c21, 0x5c23,
+ 0x5c27, 0x5b79, 0x432a, 0x456f, 0x5c2b, 0x5b7c, 0x5c28, 0x5c22,
+ 0x3f39, 0x5c2c, 0x4033, 0x5c2a, 0x343d, 0x4f50, 0x5b76, 0x5c26,
+ 0x3058, 0x5b78, 0x4c3a, 0x5b7d, 0x3f22, 0x4447, 0x5b73, 0x5c25,
+ 0x3f7a, 0x5c2f, 0x3371, 0x3821, 0x5c31, 0x5b7a, 0x5c30, 0x5c29,
+ 0x5b7b, 0x5c2d, 0x5c2e, 0x5c3f, 0x464e, 0x5c24, 0x5c3b, 0x5c3d,
+ 0x4458, 0x4d4c, 0x4976, 0x5c38, 0x424a, 0x5c3e, 0x413f, 0x5c35,
+ 0x5c42, 0x5c41, 0x466f, 0x5c40, 0x466a, 0x5c44, 0x5c37, 0x3648,
+ 0x5c3a, 0x3d5d, 0x4760, 0x5c3c, 0x364b, 0x5c34, 0x5c36, 0x5c33,
+ 0x4f30, 0x335a, 0x5c39, 0x5c43, 0x3335, 0x3a67, 0x315d, 0x5c54,
+ 0x4f31, 0x5c57, 0x3f3a, 0x5c56, 0x5c55, 0x5c52, 0x5c46, 0x5c63,
+ 0x5c45, 0x5c58, 0x5c50, 0x5c4b, 0x5c48, 0x5c49, 0x5c51, 0x7422,
+ 0x5c4e, 0x393d, 0x4448, 0x4164, 0x5c4c, 0x5c47, 0x5c4a, 0x4d4d,
+ 0x4b6a, 0x5c4f, 0x5c59, 0x5c61, 0x5c5a, 0x5c67, 0x5c65, 0x5c60,
+ 0x5c5f, 0x4450, 0x4165, 0x5c5d, 0x5c5b, 0x5c62, 0x5c68, 0x4875,
+ 0x5c6e, 0x5c69, 0x5c6c, 0x5c66, 0x4374, 0x4938, 0x5c5c, 0x5c64,
+ 0x3e40, 0x4c4f, 0x5c78, 0x5c6b, 0x3822, 0x3223, 0x335f, 0x5c53,
+ 0x3e41, 0x5c70, 0x5c77, 0x3c79, 0x3372, 0x432e, 0x5c6d, 0x5c72,
+ 0x5c76, 0x3636, 0x354c, 0x5c74, 0x3521, 0x464b, 0x5c73, 0x5c75,
+ 0x5c6f, 0x5c71, 0x3360, 0x4349, 0x5c7c, 0x5c7a, 0x3869, 0x5c79,
+ 0x5d21, 0x5b58, 0x5c7b, 0x5c7d, 0x5c7e, 0x5d2c, 0x5d28, 0x5b6d,
+ 0x5d27, 0x5d26, 0x5d23, 0x5c6a, 0x5d25, 0x5d24, 0x5d2a, 0x4f26,
+ 0x5d2d, 0x367b, 0x5d29, 0x5d2b, 0x4827, 0x5d2e, 0x5d32, 0x5d2f,
+ 0x4d73, 0x5d30, 0x5c5e, 0x5d33, 0x5d34, 0x3135, 0x5d36, 0x3767,
+ 0x3c21, 0x3655, 0x3224, 0x4d5f, 0x5d38, 0x5d37, 0x5d3a, 0x353d,
+ 0x3656, 0x343e, 0x5d3d, 0x5d3c, 0x5d3e, 0x324e, 0x4337, 0x5d3f,
+ 0x343f, 0x5d41, 0x5d40, 0x5d42, 0x5d43, 0x5d44, 0x3b5f, 0x4035,
+ 0x3a21, 0x4970, 0x4a62, 0x4f44, 0x3b75, 0x3a50, 0x4e72, 0x5d45,
+ 0x5d46, 0x3b60, 0x5d47, 0x5d48, 0x5d4a, 0x5d49, 0x4b58, 0x3d5e,
+ 0x3c6c, 0x3b44, 0x5d4b, 0x5d4d, 0x3f23, 0x5d4c, 0x5d4e, 0x5d4f,
+ 0x5d50, 0x5d51, 0x5d52, 0x5d54, 0x5d53, 0x5d55, 0x3225, 0x434a,
+ 0x5d56, 0x3b26, 0x334c, 0x5d57, 0x4542, 0x544c, 0x3523, 0x5d58,
+ 0x5d59, 0x4a6c, 0x4b68, 0x4647, 0x5d5a, 0x4866, 0x487b, 0x4c53,
+ 0x5d5b, 0x5d5d, 0x5d5c, 0x5d5f, 0x5d5e, 0x5d61, 0x3b61, 0x4c31,
+ 0x5d62, 0x5d63, 0x3524, 0x5d64, 0x5d66, 0x5d65, 0x3f65, 0x4939,
+ 0x314a, 0x4845, 0x4475, 0x3d41, 0x3561, 0x4846, 0x3c2e, 0x5d68,
+ 0x3440, 0x3178, 0x4672, 0x5d67, 0x393e, 0x4353, 0x5d69, 0x5d71,
+ 0x5d6a, 0x4241, 0x3562, 0x5d72, 0x3768, 0x3525, 0x5d70, 0x5d6e,
+ 0x5d6b, 0x4d60, 0x4440, 0x4659, 0x5d6c, 0x5d74, 0x5d73, 0x3723,
+ 0x322d, 0x3a3b, 0x5d6d, 0x5d6f, 0x4b57, 0x4274, 0x4b77, 0x5d7c,
+ 0x5d7d, 0x324f, 0x4a28, 0x4c7d, 0x5e21, 0x3c23, 0x3e42, 0x5d78,
+ 0x5d7e, 0x3168, 0x3637, 0x5d75, 0x5d7a, 0x4074, 0x4771, 0x4867,
+ 0x5d77, 0x4b21, 0x5d79, 0x5e24, 0x5e22, 0x5d7b, 0x4b22, 0x4748,
+ 0x3563, 0x4525, 0x436d, 0x5e25, 0x5e23, 0x4259, 0x5d76, 0x314b,
+ 0x4d4e, 0x5e30, 0x5e2f, 0x4076, 0x5e2c, 0x4d6c, 0x4636, 0x5e26,
+ 0x4445, 0x314c, 0x393f, 0x5e29, 0x3d27, 0x5e2e, 0x5e2d, 0x5e28,
+ 0x5e2b, 0x3368, 0x5e2a, 0x4749, 0x4e2e, 0x3e74, 0x4075, 0x5e36,
+ 0x5e34, 0x494d, 0x5e31, 0x5e33, 0x313a, 0x3940, 0x4f32, 0x333d,
+ 0x4962, 0x4d61, 0x3324, 0x3f3b, 0x5e35, 0x5e3a, 0x3e43, 0x4d30,
+ 0x5e37, 0x5e32, 0x5e38, 0x4e5e, 0x4573, 0x4642, 0x3336, 0x3155,
+ 0x5e3e, 0x5e41, 0x4e43, 0x4d64, 0x5e48, 0x5e42, 0x5e3f, 0x4e54,
+ 0x5e45, 0x3d4a, 0x5e47, 0x5e4c, 0x4571, 0x5e4a, 0x5e44, 0x4338,
+ 0x5e4b, 0x5e40, 0x5e46, 0x5e4d, 0x307c, 0x5e43, 0x5e4e, 0x3f3c,
+ 0x3d5f, 0x4a25, 0x3a2e, 0x5e3b, 0x5e49, 0x453a, 0x4036, 0x3369,
+ 0x3a51, 0x3e44, 0x5e3d, 0x3d42, 0x374c, 0x5e3c, 0x5e52, 0x3d6d,
+ 0x383a, 0x5e61, 0x5e5b, 0x3574, 0x454f, 0x5e56, 0x5e5f, 0x302f,
+ 0x3132, 0x3239, 0x5e58, 0x422c, 0x5e4f, 0x5e51, 0x3941, 0x5e62,
+ 0x5e5d, 0x5e55, 0x5e5c, 0x4c2b, 0x5e5a, 0x5e5e, 0x3850, 0x3e45,
+ 0x4339, 0x5e54, 0x4d2f, 0x5e57, 0x5e50, 0x4572, 0x5e53, 0x5e59,
+ 0x4f51, 0x3c3e, 0x4b7e, 0x5e63, 0x482e, 0x5e6f, 0x383b, 0x3d60,
+ 0x5e65, 0x4e2f, 0x3942, 0x5e72, 0x306e, 0x5e70, 0x5e64, 0x5e6a,
+ 0x5e6c, 0x4d4f, 0x5e67, 0x452e, 0x5e69, 0x5e71, 0x5e6b, 0x4c47,
+ 0x5e66, 0x3c22, 0x5e7e, 0x336a, 0x5e68, 0x5e6d, 0x5e6e, 0x426c,
+ 0x425a, 0x5e76, 0x5e7c, 0x5e7a, 0x4529, 0x5f23, 0x5e77, 0x5e78,
+ 0x5e60, 0x3579, 0x493a, 0x3c3f, 0x3977, 0x4f33, 0x5e74, 0x5f22,
+ 0x3169, 0x4166, 0x4779, 0x3441, 0x4e7a, 0x4c21, 0x4452, 0x5e7b,
+ 0x5e7d, 0x4132, 0x5f21, 0x5e79, 0x5e73, 0x3443, 0x3769, 0x5f2f,
+ 0x5f2a, 0x4078, 0x3363, 0x3d61, 0x5f33, 0x5f2c, 0x442c, 0x5f29,
+ 0x4459, 0x5f4c, 0x5f26, 0x5f25, 0x5f2e, 0x5f28, 0x5f27, 0x5f2d,
+ 0x4021, 0x5f24, 0x5f30, 0x5f31, 0x3442, 0x5f36, 0x5f35, 0x5f37,
+ 0x5f3a, 0x4543, 0x5f34, 0x5f38, 0x3763, 0x4279, 0x5f32, 0x473b,
+ 0x5f39, 0x5f3e, 0x5f3c, 0x5f3f, 0x5f42, 0x5f3b, 0x396a, 0x4728,
+ 0x5e39, 0x4d74, 0x5f3d, 0x5f41, 0x4275, 0x5f40, 0x5f2b, 0x6f69,
+ 0x5f45, 0x5f49, 0x5f47, 0x5f43, 0x5f44, 0x5f48, 0x5f46, 0x494e,
+ 0x5f4e, 0x5f4b, 0x5f4a, 0x5f4d, 0x4654, 0x5f4f, 0x4375, 0x426d,
+ 0x4025, 0x5f50, 0x5f52, 0x5f51, 0x5e75, 0x5f53, 0x4667, 0x5f54,
+ 0x3250, 0x4574, 0x3325, 0x3564, 0x3c5e, 0x3a52, 0x4f27, 0x3f66,
+ 0x316a, 0x5f56, 0x5f55, 0x5f59, 0x433a, 0x5f5c, 0x5f57, 0x5f5b,
+ 0x5f5a, 0x4540, 0x3059, 0x4e75, 0x5f5e, 0x3128, 0x5f60, 0x5f5f,
+ 0x5f5d, 0x5f58, 0x4b23, 0x5f62, 0x5f61, 0x316b, 0x5f64, 0x4a32,
+ 0x5f63, 0x4c35, 0x3e47, 0x4133, 0x3e46, 0x4e7b, 0x5f6a, 0x4079,
+ 0x5f66, 0x5f6b, 0x316c, 0x5f69, 0x4761, 0x5f65, 0x5f68, 0x3e48,
+ 0x4851, 0x5f6c, 0x3c51, 0x407a, 0x5f6f, 0x5f67, 0x3727, 0x5f6d,
+ 0x4d50, 0x5f70, 0x7426, 0x3d4f, 0x5f71, 0x5f72, 0x472e, 0x5f74,
+ 0x5f75, 0x4733, 0x4575, 0x5f77, 0x5f79, 0x4e55, 0x5f76, 0x5f78,
+ 0x316d, 0x5f73, 0x535b, 0x5f7a, 0x4167, 0x3b38, 0x5f7c, 0x5f7b,
+ 0x3f24, 0x5259, 0x5f7d, 0x6021, 0x5f6e, 0x5f7e, 0x6022, 0x477a,
+ 0x6023, 0x6024, 0x6025, 0x6026, 0x445e, 0x6028, 0x6027, 0x6029,
+ 0x602a, 0x3c5f, 0x4963, 0x4c6c, 0x602b, 0x602c, 0x4156, 0x3c24,
+ 0x602d, 0x602e, 0x602f, 0x4a52, 0x4847, 0x6030, 0x4757, 0x442d,
+ 0x6031, 0x3267, 0x356d, 0x4c46, 0x4c36, 0x3234, 0x4f34, 0x4b52,
+ 0x4a2a, 0x4037, 0x6032, 0x4643, 0x3823, 0x6033, 0x3a54, 0x6035,
+ 0x6034, 0x6036, 0x6037, 0x6038, 0x353e, 0x6039, 0x603a, 0x3824,
+ 0x4848, 0x603c, 0x3e75, 0x603b, 0x3638, 0x603d, 0x603f, 0x603e,
+ 0x6040, 0x3851, 0x6041, 0x3669, 0x4140, 0x397d, 0x6043, 0x6044,
+ 0x6042, 0x3c6d, 0x4648, 0x3639, 0x6046, 0x432c, 0x6045, 0x4f35,
+ 0x4762, 0x6049, 0x604b, 0x6048, 0x4c54, 0x604a, 0x604c, 0x4e44,
+ 0x6050, 0x604f, 0x4376, 0x472d, 0x3825, 0x604e, 0x604d, 0x4d31,
+ 0x4d32, 0x6051, 0x316e, 0x3976, 0x3b62, 0x6052, 0x6053, 0x6055,
+ 0x3d43, 0x6057, 0x6056, 0x6058, 0x334d, 0x605a, 0x6059, 0x605c,
+ 0x605b, 0x383c, 0x4e28, 0x364c, 0x3226, 0x366a, 0x3461, 0x4e68,
+ 0x605e, 0x6060, 0x6061, 0x3251, 0x605d, 0x3b39, 0x4441, 0x605f,
+ 0x6064, 0x3c6e, 0x6062, 0x373e, 0x4849, 0x6063, 0x607e, 0x6069,
+ 0x383d, 0x3565, 0x6066, 0x4d7d, 0x4e30, 0x4276, 0x6068, 0x606a,
+ 0x4e56, 0x3657, 0x487c, 0x474a, 0x606b, 0x606d, 0x6070, 0x606c,
+ 0x606f, 0x386a, 0x314d, 0x6071, 0x3f70, 0x606e, 0x4e5c, 0x6074,
+ 0x7424, 0x6072, 0x6075, 0x6067, 0x6073, 0x3a3c, 0x6076, 0x6077,
+ 0x4d7e, 0x6078, 0x6079, 0x6065, 0x607a, 0x3444, 0x3c25, 0x607b,
+ 0x607c, 0x607d, 0x313b, 0x6121, 0x493b, 0x6122, 0x3424, 0x6123,
+ 0x6124, 0x6125, 0x6127, 0x6128, 0x6126, 0x4953, 0x612a, 0x6129,
+ 0x612c, 0x612b, 0x612d, 0x612e, 0x6130, 0x612f, 0x3979, 0x6132,
+ 0x6131, 0x3445, 0x3f53, 0x453c, 0x6133, 0x4038, 0x3b3a, 0x3179,
+ 0x6134, 0x4d51, 0x4a63, 0x6135, 0x4544, 0x4d33, 0x3943, 0x3f3d,
+ 0x434b, 0x5234, 0x442e, 0x3268, 0x6136, 0x6137, 0x613c, 0x613a,
+ 0x6139, 0x5a42, 0x3326, 0x6138, 0x305a, 0x482a, 0x484a, 0x4e31,
+ 0x613d, 0x613b, 0x435c, 0x4026, 0x482b, 0x492d, 0x613f, 0x4e2c,
+ 0x374d, 0x6140, 0x613e, 0x4856, 0x6141, 0x6142, 0x305b, 0x3e76,
+ 0x6147, 0x6144, 0x466d, 0x6143, 0x3526, 0x614a, 0x6145, 0x6146,
+ 0x6149, 0x6148, 0x4925, 0x4142, 0x4141, 0x353f, 0x614b, 0x614c,
+ 0x614d, 0x614f, 0x614e, 0x3156, 0x6157, 0x4868, 0x6151, 0x6153,
+ 0x6155, 0x3f3e, 0x6156, 0x6154, 0x3c40, 0x6150, 0x6152, 0x4942,
+ 0x3e49, 0x6159, 0x6158, 0x615a, 0x3c26, 0x3a2f, 0x4577, 0x615b,
+ 0x444b, 0x615d, 0x4e21, 0x615c, 0x4169, 0x6162, 0x6164, 0x6165,
+ 0x4354, 0x6163, 0x6160, 0x615e, 0x615f, 0x6161, 0x6168, 0x6166,
+ 0x6167, 0x6169, 0x616b, 0x616c, 0x616d, 0x616e, 0x616a, 0x6170,
+ 0x616f, 0x6171, 0x4e45, 0x6174, 0x6172, 0x6173, 0x3462, 0x4c7e,
+ 0x4a4a, 0x6176, 0x6175, 0x6177, 0x6178, 0x617c, 0x6179, 0x617a,
+ 0x617b, 0x617d, 0x617e, 0x6221, 0x6222, 0x6223, 0x482f, 0x4550,
+ 0x6224, 0x4772, 0x4934, 0x6225, 0x6226, 0x452a, 0x3327, 0x3944,
+ 0x6227, 0x6228, 0x6229, 0x3b29, 0x622b, 0x622a, 0x622c, 0x622d,
+ 0x4869, 0x622e, 0x622f, 0x7369, 0x6230, 0x6231, 0x6232, 0x3b2e,
+ 0x6233, 0x4756, 0x4b5f, 0x314e, 0x3157, 0x6234, 0x6236, 0x6235,
+ 0x4570, 0x4039, 0x5d39, 0x6237, 0x4c41, 0x6238, 0x3446, 0x4857,
+ 0x6239, 0x623a, 0x623b, 0x4c5c, 0x4c55, 0x443e, 0x416a, 0x623d,
+ 0x3d62, 0x3e4a, 0x6240, 0x623f, 0x623e, 0x487d, 0x3447, 0x3829,
+ 0x6246, 0x6243, 0x3f3f, 0x4c32, 0x6242, 0x6244, 0x6245, 0x6241,
+ 0x6247, 0x6248, 0x442f, 0x3463, 0x4365, 0x6249, 0x624a, 0x624d,
+ 0x3f67, 0x4644, 0x624e, 0x4b53, 0x624b, 0x624c, 0x6251, 0x6250,
+ 0x624f, 0x6253, 0x6252, 0x6254, 0x6256, 0x6255, 0x4a4d, 0x3d56,
+ 0x4e46, 0x6257, 0x4637, 0x6258, 0x6259, 0x625d, 0x625b, 0x625c,
+ 0x625a, 0x625e, 0x625f, 0x6260, 0x6261, 0x4c37, 0x6262, 0x4c70,
+ 0x6263, 0x434e, 0x476a, 0x366b, 0x433b, 0x6264, 0x363a, 0x4050,
+ 0x6265, 0x3a3d, 0x6266, 0x6267, 0x3826, 0x3a55, 0x6269, 0x4556,
+ 0x3a56, 0x354e, 0x4b24, 0x474b, 0x4557, 0x395c, 0x626b, 0x3e4b,
+ 0x4e32, 0x3945, 0x3827, 0x4823, 0x626d, 0x626f, 0x386b, 0x626e,
+ 0x4476, 0x6271, 0x3337, 0x626c, 0x486a, 0x3130, 0x3a6c, 0x4f52,
+ 0x6270, 0x6272, 0x4a4b, 0x4059, 0x6274, 0x6275, 0x6273, 0x334e,
+ 0x627b, 0x627a, 0x3c27, 0x627c, 0x6277, 0x627d, 0x6278, 0x4858,
+ 0x6276, 0x6279, 0x6322, 0x6321, 0x4b61, 0x627e, 0x306b, 0x6324,
+ 0x6323, 0x3e4c, 0x6325, 0x4143, 0x6327, 0x6326, 0x6328, 0x6268,
+ 0x626a, 0x632a, 0x6329, 0x3c28, 0x4e69, 0x3c52, 0x632b, 0x3737,
+ 0x3540, 0x3527, 0x3b63, 0x4d34, 0x6331, 0x6330, 0x4144, 0x632d,
+ 0x632f, 0x3d4b, 0x3f40, 0x632e, 0x632c, 0x472a, 0x3e4d, 0x493c,
+ 0x3a57, 0x4578, 0x6332, 0x6333, 0x6349, 0x3658, 0x4f3d, 0x4135,
+ 0x6334, 0x3252, 0x4477, 0x4a21, 0x6335, 0x357a, 0x6336, 0x6338,
+ 0x6339, 0x4729, 0x633a, 0x633b, 0x633c, 0x3659, 0x3253, 0x4645,
+ 0x3d28, 0x3b64, 0x633d, 0x3d29, 0x324a, 0x4943, 0x633e, 0x486b,
+ 0x4145, 0x6341, 0x6342, 0x4769, 0x3f41, 0x633f, 0x4361, 0x6340,
+ 0x3e4e, 0x305c, 0x3529, 0x6343, 0x4478, 0x6344, 0x4047, 0x4c2d,
+ 0x4923, 0x6345, 0x6346, 0x4355, 0x4e47, 0x6348, 0x6347, 0x3c6f,
+ 0x634a, 0x3070, 0x634d, 0x634b, 0x3254, 0x374e, 0x634c, 0x3946,
+ 0x3972, 0x4a66, 0x634e, 0x4b54, 0x6350, 0x4051, 0x314f, 0x323a,
+ 0x302c, 0x634f, 0x6351, 0x6352, 0x3e77, 0x6353, 0x334f, 0x6355,
+ 0x376a, 0x3566, 0x6356, 0x3675, 0x6357, 0x407c, 0x464d, 0x4060,
+ 0x3a75, 0x6358, 0x4362, 0x416b, 0x635a, 0x635c, 0x6359, 0x635b,
+ 0x3722, 0x635d, 0x3726, 0x3567, 0x4d52, 0x635f, 0x6360, 0x312e,
+ 0x6363, 0x3376, 0x6362, 0x6361, 0x6365, 0x635e, 0x6366, 0x4e29,
+ 0x6367, 0x6368, 0x5474, 0x636a, 0x6369, 0x636b, 0x636c, 0x4e35,
+ 0x636d, 0x706f, 0x3e4f, 0x636e, 0x636f, 0x3d57, 0x4638, 0x6370,
+ 0x4328, 0x6371, 0x433c, 0x6372, 0x3625, 0x513f, 0x435d, 0x3c33,
+ 0x3448, 0x6373, 0x6422, 0x6376, 0x3568, 0x6375, 0x6424, 0x6374,
+ 0x3e50, 0x6378, 0x6379, 0x452b, 0x637a, 0x335e, 0x3f5a, 0x4964,
+ 0x637c, 0x4268, 0x6377, 0x637b, 0x637d, 0x3a7b, 0x6426, 0x492e,
+ 0x4826, 0x4579, 0x365a, 0x6425, 0x6423, 0x4835, 0x637e, 0x435e,
+ 0x457b, 0x457a, 0x3a76, 0x6438, 0x6428, 0x642a, 0x642d, 0x642e,
+ 0x642b, 0x642c, 0x6429, 0x6427, 0x6421, 0x4a4f, 0x3255, 0x6435,
+ 0x6432, 0x6437, 0x6436, 0x4773, 0x4c27, 0x3b3b, 0x6430, 0x6439,
+ 0x6434, 0x6433, 0x642f, 0x6431, 0x3449, 0x433d, 0x407d, 0x4822,
+ 0x643e, 0x4824, 0x4061, 0x643b, 0x484f, 0x643f, 0x4a53, 0x435b,
+ 0x643a, 0x643c, 0x643d, 0x6440, 0x3c44, 0x4646, 0x6445, 0x6444,
+ 0x6441, 0x4f36, 0x644a, 0x644e, 0x644b, 0x6447, 0x6448, 0x644d,
+ 0x6442, 0x5255, 0x6449, 0x6443, 0x644c, 0x6452, 0x344a, 0x644f,
+ 0x6450, 0x6451, 0x6454, 0x6453, 0x4876, 0x6455, 0x4e7c, 0x4a6d,
+ 0x645a, 0x6457, 0x6456, 0x4052, 0x6459, 0x645b, 0x6458, 0x645f,
+ 0x645c, 0x645d, 0x6446, 0x645e, 0x6460, 0x6461, 0x4a46, 0x6462,
+ 0x4c62, 0x364e, 0x3729, 0x6463, 0x4a34, 0x3f68, 0x4c30, 0x6464,
+ 0x4e33, 0x4774, 0x4146, 0x4734, 0x3d4d, 0x3040, 0x6469, 0x6467,
+ 0x6465, 0x3421, 0x3e51, 0x646a, 0x6468, 0x6466, 0x646e, 0x646d,
+ 0x646c, 0x646b, 0x646f, 0x6470, 0x403a, 0x6471, 0x6473, 0x6472,
+ 0x3852, 0x4138, 0x6475, 0x457c, 0x6474, 0x6476, 0x4a35, 0x416c,
+ 0x3947, 0x6477, 0x4e48, 0x6479, 0x647a, 0x647b, 0x647c, 0x3b65,
+ 0x647d, 0x374f, 0x356a, 0x352a, 0x6521, 0x4c73, 0x3948, 0x647e,
+ 0x6524, 0x4c66, 0x473c, 0x4933, 0x3d63, 0x6523, 0x3c53, 0x3949,
+ 0x3b66, 0x3569, 0x4a36, 0x6522, 0x4147, 0x4b42, 0x3a77, 0x3b67,
+ 0x445d, 0x6527, 0x4e5f, 0x3a59, 0x6528, 0x3f42, 0x652a, 0x3e52,
+ 0x3a30, 0x6529, 0x3d2a, 0x383e, 0x4148, 0x6525, 0x652b, 0x6526,
+ 0x3750, 0x652e, 0x6532, 0x376b, 0x652d, 0x6536, 0x394a, 0x4d6d,
+ 0x303c, 0x6533, 0x356b, 0x6530, 0x6531, 0x457d, 0x652f, 0x652c,
+ 0x3328, 0x4064, 0x3828, 0x6538, 0x6535, 0x6537, 0x6534, 0x3751,
+ 0x4233, 0x6539, 0x416e, 0x6546, 0x6542, 0x653c, 0x6540, 0x3c7a,
+ 0x305d, 0x653b, 0x6543, 0x6547, 0x394b, 0x4c56, 0x4456, 0x653d,
+ 0x6545, 0x653a, 0x433e, 0x653f, 0x303d, 0x4c4a, 0x653e, 0x365b,
+ 0x486c, 0x416d, 0x4e50, 0x3d6f, 0x656e, 0x6548, 0x407e, 0x6544,
+ 0x6549, 0x654b, 0x4479, 0x654e, 0x654a, 0x4a54, 0x344b, 0x4c4b,
+ 0x305e, 0x654d, 0x4e7d, 0x654c, 0x316f, 0x466c, 0x654f, 0x6556,
+ 0x6550, 0x6557, 0x6553, 0x477b, 0x3c4a, 0x6555, 0x6552, 0x6558,
+ 0x6551, 0x3d44, 0x4b25, 0x3d4c, 0x6554, 0x6560, 0x655c, 0x655f,
+ 0x655d, 0x6561, 0x655b, 0x6541, 0x4053, 0x484b, 0x655e, 0x6559,
+ 0x4121, 0x3752, 0x3d2b, 0x3f25, 0x4136, 0x6564, 0x6566, 0x6567,
+ 0x6563, 0x6565, 0x655a, 0x6562, 0x656a, 0x6569, 0x4b7a, 0x372b,
+ 0x6568, 0x656c, 0x656b, 0x656f, 0x6571, 0x3b3c, 0x656d, 0x6572,
+ 0x6573, 0x6574, 0x657a, 0x453b, 0x6576, 0x6575, 0x6577, 0x6578,
+ 0x6579, 0x657b, 0x657c, 0x344c, 0x657d, 0x657e, 0x6621, 0x6622,
+ 0x6623, 0x6624, 0x6625, 0x6626, 0x6628, 0x6627, 0x6629, 0x662a,
+ 0x662b, 0x662e, 0x662c, 0x662d, 0x3a61, 0x3753, 0x4356, 0x4833,
+ 0x3d70, 0x474d, 0x486d, 0x662f, 0x586d, 0x6630, 0x6632, 0x4d65,
+ 0x6631, 0x6634, 0x6633, 0x4d53, 0x6635, 0x487e, 0x6636, 0x6639,
+ 0x6638, 0x6637, 0x663a, 0x3732, 0x4122, 0x3541, 0x663e, 0x663b,
+ 0x663c, 0x663f, 0x6640, 0x663d, 0x3129, 0x3227, 0x6642, 0x6643,
+ 0x6644, 0x4d62, 0x3d2c, 0x6646, 0x6645, 0x3f69, 0x6647, 0x6648,
+ 0x6649, 0x3465, 0x344d, 0x664a, 0x664b, 0x4b5d, 0x4d63, 0x4d54,
+ 0x4f37, 0x394d, 0x664e, 0x3c54, 0x664d, 0x664f, 0x3c29, 0x4251,
+ 0x6650, 0x394c, 0x4c57, 0x6651, 0x6652, 0x6653, 0x6654, 0x6655,
+ 0x3c2a, 0x4c6d, 0x6657, 0x433f, 0x6656, 0x6659, 0x6658, 0x665a,
+ 0x403b, 0x665b, 0x665c, 0x4a39, 0x665d, 0x416f, 0x665e, 0x665f,
+ 0x4e7e, 0x6662, 0x6661, 0x6660, 0x4430, 0x6663, 0x3f26, 0x6664,
+ 0x6665, 0x4f38, 0x6666, 0x6667, 0x6669, 0x6668, 0x4825, 0x4679,
+ 0x4f3e, 0x4829, 0x666b, 0x3e53, 0x492a, 0x666c, 0x666a, 0x344e,
+ 0x3854, 0x3b68, 0x486e, 0x382a, 0x4b43, 0x666f, 0x666d, 0x394e,
+ 0x394f, 0x3069, 0x3a68, 0x4759, 0x305f, 0x6674, 0x4340, 0x4758,
+ 0x425b, 0x6676, 0x6672, 0x6675, 0x6670, 0x6673, 0x4b26, 0x3855,
+ 0x307d, 0x6671, 0x6678, 0x6679, 0x4639, 0x363b, 0x6726, 0x473d,
+ 0x3b69, 0x363c, 0x4048, 0x4f46, 0x4c2e, 0x6677, 0x4054, 0x3553,
+ 0x667a, 0x667c, 0x667b, 0x667d, 0x4326, 0x473e, 0x4431, 0x6723,
+ 0x6722, 0x667e, 0x3f55, 0x4965, 0x6725, 0x6724, 0x3950, 0x4f53,
+ 0x6735, 0x6729, 0x672a, 0x3c70, 0x6728, 0x3978, 0x6727, 0x672b,
+ 0x4432, 0x4a22, 0x4123, 0x425c, 0x672f, 0x6730, 0x672c, 0x672d,
+ 0x672e, 0x3951, 0x6736, 0x6732, 0x4966, 0x4b6c, 0x4928, 0x6731,
+ 0x6734, 0x6733, 0x4b44, 0x6737, 0x6738, 0x4137, 0x6739, 0x673b,
+ 0x673f, 0x673c, 0x673a, 0x473f, 0x673d, 0x673e, 0x3232, 0x6745,
+ 0x6740, 0x6741, 0x6742, 0x4221, 0x6744, 0x6743, 0x6746, 0x6747,
+ 0x6748, 0x3f43, 0x3269, 0x6749, 0x4e57, 0x3c2b, 0x3d2d, 0x3b6a,
+ 0x4357, 0x674a, 0x674b, 0x3131, 0x674c, 0x674d, 0x674e, 0x674f,
+ 0x6750, 0x363d, 0x5a2a, 0x6751, 0x4065, 0x6752, 0x3c4b, 0x6753,
+ 0x5030, 0x6754, 0x4a5e, 0x345c, 0x4124, 0x3d58, 0x4971, 0x3d2e,
+ 0x6755, 0x3952, 0x6756, 0x484c, 0x6764, 0x6758, 0x4249, 0x4775,
+ 0x383f, 0x6757, 0x4125, 0x6759, 0x447a, 0x675b, 0x675a, 0x675d,
+ 0x675c, 0x675e, 0x6760, 0x675f, 0x344f, 0x6761, 0x6762, 0x6763,
+ 0x3a31, 0x4e49, 0x6765, 0x3f27, 0x3170, 0x6766, 0x6767, 0x6768,
+ 0x3072, 0x6769, 0x676a, 0x4967, 0x3c47, 0x676c, 0x3329, 0x3032,
+ 0x676b, 0x676e, 0x474e, 0x3f44, 0x3256, 0x4b27, 0x375d, 0x365c,
+ 0x676d, 0x326a, 0x3423, 0x3171, 0x6772, 0x4e6a, 0x425d, 0x4944,
+ 0x677e, 0x3257, 0x677c, 0x677a, 0x6771, 0x676f, 0x6770, 0x3c63,
+ 0x366c, 0x4377, 0x4651, 0x3151, 0x6774, 0x6773, 0x6779, 0x6775,
+ 0x6778, 0x4c50, 0x6777, 0x3258, 0x337d, 0x677b, 0x677d, 0x3754,
+ 0x6823, 0x682c, 0x682d, 0x302b, 0x6834, 0x3071, 0x682b, 0x682a,
+ 0x6825, 0x6824, 0x6822, 0x6821, 0x4363, 0x427b, 0x6827, 0x6826,
+ 0x6829, 0x4170, 0x3755, 0x3141, 0x6828, 0x3953, 0x4171, 0x683a,
+ 0x683b, 0x3259, 0x322e, 0x6838, 0x682e, 0x6836, 0x683d, 0x6837,
+ 0x6835, 0x6776, 0x6833, 0x682f, 0x3450, 0x6831, 0x683c, 0x6832,
+ 0x683e, 0x6830, 0x477c, 0x4d69, 0x6839, 0x684f, 0x6847, 0x3f7b,
+ 0x3546, 0x365d, 0x6842, 0x325b, 0x3e54, 0x6845, 0x3a5a, 0x4551,
+ 0x684a, 0x4a6e, 0x6841, 0x325a, 0x3856, 0x4929, 0x684b, 0x683f,
+ 0x6848, 0x6852, 0x6843, 0x6844, 0x463a, 0x6849, 0x6846, 0x4b28,
+ 0x684c, 0x3060, 0x6840, 0x684e, 0x684d, 0x476b, 0x6854, 0x685f,
+ 0x337e, 0x6862, 0x6850, 0x6855, 0x4d6e, 0x685e, 0x4d55, 0x4e2a,
+ 0x4378, 0x336b, 0x4972, 0x6864, 0x4621, 0x3031, 0x685d, 0x6859,
+ 0x4172, 0x6853, 0x685b, 0x6860, 0x472c, 0x302a, 0x6858, 0x6861,
+ 0x4978, 0x685c, 0x6857, 0x3e55, 0x3d2f, 0x3c2c, 0x4c58, 0x4947,
+ 0x6867, 0x6870, 0x685a, 0x3377, 0x3e78, 0x6865, 0x686a, 0x4173,
+ 0x6866, 0x686d, 0x435f, 0x686e, 0x4d56, 0x6863, 0x3338, 0x6869,
+ 0x686c, 0x4c2c, 0x686f, 0x6868, 0x686b, 0x4b29, 0x4f21, 0x6873,
+ 0x687a, 0x6872, 0x3c43, 0x6851, 0x4a4e, 0x4c22, 0x6879, 0x6878,
+ 0x6874, 0x6875, 0x3136, 0x6877, 0x6871, 0x4455, 0x6876, 0x307e,
+ 0x4222, 0x4a43, 0x687b, 0x6921, 0x4859, 0x687e, 0x3e56, 0x3c49,
+ 0x6923, 0x363e, 0x6924, 0x4979, 0x687d, 0x6856, 0x687c, 0x4f4f,
+ 0x4622, 0x4973, 0x692b, 0x6931, 0x6932, 0x6925, 0x4776, 0x692f,
+ 0x6927, 0x6929, 0x6933, 0x6928, 0x692c, 0x3172, 0x4665, 0x692d,
+ 0x6930, 0x6926, 0x4126, 0x692a, 0x3b27, 0x3f45, 0x3730, 0x4c74,
+ 0x4c79, 0x3d72, 0x6937, 0x6935, 0x4f4e, 0x6934, 0x4d75, 0x6936,
+ 0x6938, 0x6939, 0x693c, 0x693a, 0x4623, 0x693b, 0x484d, 0x692e,
+ 0x3d73, 0x693d, 0x6942, 0x4174, 0x6941, 0x6922, 0x6943, 0x4149,
+ 0x693e, 0x6940, 0x693f, 0x5d31, 0x5d22, 0x6945, 0x6944, 0x4d76,
+ 0x623c, 0x6946, 0x6947, 0x6948, 0x3857, 0x3554, 0x694a, 0x515d,
+ 0x3575, 0x4e3a, 0x3673, 0x694b, 0x694c, 0x436e, 0x694d, 0x467a,
+ 0x303a, 0x3263, 0x6952, 0x6953, 0x694e, 0x3b3d, 0x694f, 0x4742,
+ 0x6950, 0x6951, 0x695b, 0x6955, 0x6958, 0x6954, 0x6956, 0x6957,
+ 0x3c58, 0x6959, 0x4341, 0x3756, 0x3342, 0x695c, 0x333f, 0x6961,
+ 0x695d, 0x6960, 0x483a, 0x695e, 0x695f, 0x4948, 0x485a, 0x6962,
+ 0x427d, 0x696c, 0x6968, 0x326b, 0x6966, 0x4b2a, 0x6967, 0x6964,
+ 0x6965, 0x696a, 0x696d, 0x696b, 0x6969, 0x6963, 0x4358, 0x6974,
+ 0x4c2a, 0x6972, 0x6973, 0x696e, 0x6970, 0x6971, 0x696f, 0x4066,
+ 0x4f39, 0x6978, 0x6979, 0x6a21, 0x3f2a, 0x697b, 0x697e, 0x6976,
+ 0x6975, 0x6a22, 0x325c, 0x697c, 0x6a23, 0x697d, 0x697a, 0x4433,
+ 0x6977, 0x4768, 0x6a27, 0x4d3b, 0x6a26, 0x6a25, 0x6a2e, 0x6a28,
+ 0x6a30, 0x4d66, 0x6a33, 0x6a2a, 0x6a2b, 0x6a2f, 0x6a32, 0x6a31,
+ 0x6a29, 0x6a2c, 0x6a3d, 0x6a36, 0x6a34, 0x6a35, 0x6a3a, 0x6a3b,
+ 0x332a, 0x3542, 0x6a39, 0x6a24, 0x6a38, 0x6a3c, 0x6a37, 0x6a3e,
+ 0x6a40, 0x6a3f, 0x6a42, 0x6a41, 0x695a, 0x6a46, 0x6a43, 0x6a44,
+ 0x6a45, 0x6a47, 0x376c, 0x6a49, 0x6a48, 0x3d30, 0x3954, 0x5e27,
+ 0x6a4a, 0x3d51, 0x3339, 0x6a4b, 0x3152, 0x3e57, 0x6a4c, 0x3955,
+ 0x6a4d, 0x3061, 0x493d, 0x6a4e, 0x3f6a, 0x6a55, 0x6a52, 0x436f,
+ 0x6a53, 0x6a50, 0x365e, 0x6a4f, 0x6a56, 0x3736, 0x425e, 0x6a5c,
+ 0x6a58, 0x4235, 0x6a57, 0x6a5a, 0x6a51, 0x6a5b, 0x6a5d, 0x486f,
+ 0x6a59, 0x6a5e, 0x6a60, 0x3853, 0x6a54, 0x3041, 0x6a5f, 0x3a5b,
+ 0x4e76, 0x6a61, 0x6a62, 0x4175, 0x4e22, 0x6a63, 0x4d35, 0x6a64,
+ 0x6a65, 0x4a64, 0x6a66, 0x3a40, 0x4e23, 0x6a6b, 0x6a6c, 0x3e58,
+ 0x6a6a, 0x4d67, 0x6a67, 0x6a69, 0x403d, 0x3f7e, 0x6a68, 0x6a6d,
+ 0x4a23, 0x6a6f, 0x6a6e, 0x336c, 0x4b2b, 0x6a70, 0x6a7c, 0x6a72,
+ 0x6a73, 0x6a74, 0x6a75, 0x6a79, 0x6a7a, 0x6a78, 0x6a76, 0x6a71,
+ 0x6a77, 0x6a7b, 0x7037, 0x3228, 0x6a7e, 0x365f, 0x6a7d, 0x6b22,
+ 0x6b21, 0x6b24, 0x6b23, 0x6b25, 0x3d31, 0x6b26, 0x6b27, 0x6b28,
+ 0x403e, 0x4d57, 0x6b29, 0x4a24, 0x4746, 0x6b2a, 0x6b2b, 0x382b,
+ 0x352c, 0x6b2c, 0x3b6b, 0x4741, 0x6b2d, 0x3350, 0x6b2e, 0x6b30,
+ 0x4d77, 0x6b2f, 0x3f46, 0x6b31, 0x6b32, 0x6b33, 0x3451, 0x6b34,
+ 0x6b35, 0x6b36, 0x6b37, 0x3351, 0x6b38, 0x6b39, 0x6b3a, 0x3272,
+ 0x3f28, 0x6b3b, 0x6b3c, 0x6b3d, 0x3840, 0x447b, 0x6b3e, 0x3757,
+ 0x3f56, 0x6b41, 0x4624, 0x6b40, 0x3731, 0x6b3f, 0x4277, 0x352d,
+ 0x6b42, 0x6b43, 0x3e59, 0x376d, 0x6b44, 0x4b2c, 0x405f, 0x3576,
+ 0x4c75, 0x414a, 0x6b45, 0x3f47, 0x4370, 0x3e5a, 0x6b46, 0x6b49,
+ 0x6b4a, 0x3a3e, 0x4242, 0x6b48, 0x3e5b, 0x493e, 0x6b47, 0x3b6c,
+ 0x3153, 0x6b4e, 0x3758, 0x3b6e, 0x3b6d, 0x4f4d, 0x6b4d, 0x6b4c,
+ 0x4127, 0x354d, 0x4f43, 0x333a, 0x3e5c, 0x6b4b, 0x6b50, 0x6b51,
+ 0x6b4f, 0x3858, 0x4d40, 0x3b6f, 0x4727, 0x6b54, 0x4040, 0x4342,
+ 0x4d36, 0x6b57, 0x386c, 0x403f, 0x6b53, 0x6b58, 0x386d, 0x6b55,
+ 0x6b56, 0x6b52, 0x4062, 0x4649, 0x432f, 0x325d, 0x4870, 0x3543,
+ 0x4434, 0x6b5b, 0x6b59, 0x434c, 0x4041, 0x3452, 0x6b5a, 0x3f5b,
+ 0x4e4a, 0x4f40, 0x6b5c, 0x6b67, 0x4435, 0x6b66, 0x6b63, 0x6b6b,
+ 0x6b64, 0x6b60, 0x447c, 0x6b5f, 0x6b5d, 0x4d21, 0x3b70, 0x6b61,
+ 0x6b5e, 0x6b65, 0x3d74, 0x3841, 0x427a, 0x4b45, 0x315a, 0x3062,
+ 0x4625, 0x6b69, 0x6b68, 0x4666, 0x6b6d, 0x6b62, 0x6b6c, 0x6b6e,
+ 0x382c, 0x6b6a, 0x3956, 0x3c55, 0x6b6f, 0x4d58, 0x6b72, 0x6b75,
+ 0x6b73, 0x4935, 0x6b70, 0x3660, 0x6b74, 0x6b76, 0x6b7a, 0x6b77,
+ 0x6b79, 0x6b78, 0x6b7b, 0x3c31, 0x6b7d, 0x6b7c, 0x4968, 0x6c21,
+ 0x3759, 0x6b7e, 0x6c22, 0x6c23, 0x3544, 0x6641, 0x3e79, 0x6c24,
+ 0x386e, 0x6c25, 0x6c26, 0x3b3e, 0x5a4e, 0x6c27, 0x6c28, 0x3d32,
+ 0x6c29, 0x6c2a, 0x6c2b, 0x6c2c, 0x6c2d, 0x432b, 0x6c2e, 0x6c30,
+ 0x6c2f, 0x4626, 0x6c31, 0x4b2d, 0x6c32, 0x6c33, 0x6c34, 0x6c35,
+ 0x465a, 0x3e5d, 0x6c36, 0x396b, 0x502e, 0x6c37, 0x6c38, 0x493f,
+ 0x6c39, 0x6c41, 0x6c3a, 0x6c3c, 0x6c3b, 0x6c3d, 0x4b46, 0x6c3e,
+ 0x6c3f, 0x6c40, 0x6c42, 0x332d, 0x4467, 0x4969, 0x3a62, 0x3957,
+ 0x494f, 0x325f, 0x484e, 0x6c45, 0x3453, 0x4055, 0x6c44, 0x6c49,
+ 0x4379, 0x4c63, 0x6c47, 0x6c48, 0x352e, 0x6c4a, 0x4763, 0x425f,
+ 0x4871, 0x453d, 0x6c46, 0x4b47, 0x326c, 0x6c4c, 0x4f28, 0x4442,
+ 0x4f45, 0x3b71, 0x6c4b, 0x4231, 0x6c5c, 0x4128, 0x4678, 0x4950,
+ 0x6c4f, 0x3b3f, 0x3b72, 0x3e5e, 0x4765, 0x382d, 0x6c4e, 0x6c4d,
+ 0x496a, 0x3c41, 0x4552, 0x6c51, 0x6c52, 0x3958, 0x6c50, 0x6c53,
+ 0x6c54, 0x6c56, 0x4223, 0x6c55, 0x3466, 0x6c58, 0x6c57, 0x6c59,
+ 0x6c5b, 0x6c5d, 0x6c5e, 0x4056, 0x3c4f, 0x6c5f, 0x3352, 0x6c60,
+ 0x4176, 0x6c61, 0x6c62, 0x496b, 0x352f, 0x6c63, 0x4436, 0x315b,
+ 0x6c64, 0x3c71, 0x3f76, 0x422d, 0x6c67, 0x6c66, 0x6c65, 0x6c6d,
+ 0x6c6b, 0x6c68, 0x6c6a, 0x6c69, 0x6c6c, 0x3577, 0x6c70, 0x4057,
+ 0x6c71, 0x3859, 0x6c6e, 0x6c6f, 0x4f29, 0x4437, 0x4129, 0x6c72,
+ 0x6c75, 0x6c73, 0x6c74, 0x4d59, 0x4627, 0x6c78, 0x6c76, 0x6c77,
+ 0x6c79, 0x6d29, 0x6c7c, 0x6c7d, 0x6c7b, 0x6c7a, 0x447d, 0x6d21,
+ 0x6d25, 0x6d22, 0x6c7e, 0x6d23, 0x6d24, 0x6d2b, 0x6d26, 0x4058,
+ 0x6d28, 0x6d2a, 0x6d27, 0x6d2d, 0x3d33, 0x6d2c, 0x6d2e, 0x6d2f,
+ 0x6d32, 0x6d31, 0x6d30, 0x6d34, 0x6d33, 0x4c76, 0x6d36, 0x6d35,
+ 0x6d37, 0x6d38, 0x6d3a, 0x6d39, 0x3f48, 0x6d3b, 0x366d, 0x6d3c,
+ 0x6d3e, 0x6d3f, 0x6d40, 0x6d3d, 0x6d41, 0x3c56, 0x6d42, 0x3530,
+ 0x3733, 0x382e, 0x6d43, 0x4670, 0x453e, 0x6d44, 0x6d47, 0x3c34,
+ 0x6d46, 0x6d45, 0x375a, 0x6d48, 0x3353, 0x6d4a, 0x3a5c, 0x6d49,
+ 0x6d52, 0x6d4c, 0x6d4e, 0x4a65, 0x6d4b, 0x6d4d, 0x6d51, 0x6d4f,
+ 0x3531, 0x6d50, 0x6d53, 0x475a, 0x4e58, 0x3d34, 0x6d54, 0x4d22,
+ 0x6d56, 0x6d55, 0x6d59, 0x4d41, 0x6d58, 0x336d, 0x6d57, 0x6d5c,
+ 0x6d5b, 0x6d5a, 0x4532, 0x6d5d, 0x6d5e, 0x6d5f, 0x396c, 0x3725,
+ 0x6d60, 0x6d61, 0x6d62, 0x3f49, 0x6d63, 0x3c2d, 0x6d64, 0x6d65,
+ 0x5221, 0x517e, 0x6d66, 0x6570, 0x6d67, 0x4324, 0x3f2b, 0x4740,
+ 0x6d68, 0x4a55, 0x4454, 0x397e, 0x4329, 0x312a, 0x4b78, 0x3f57,
+ 0x375e, 0x3661, 0x4a56, 0x6d69, 0x6d6b, 0x6d6a, 0x3260, 0x4676,
+ 0x6d6c, 0x4777, 0x4533, 0x6d6d, 0x3d52, 0x6d6f, 0x4c42, 0x6d7e,
+ 0x6d71, 0x6d72, 0x4449, 0x4260, 0x4177, 0x4628, 0x6d70, 0x3555,
+ 0x6d79, 0x6d76, 0x6e25, 0x4629, 0x4360, 0x6d73, 0x447e, 0x4553,
+ 0x6d74, 0x6d78, 0x3f60, 0x4767, 0x444c, 0x4042, 0x6d77, 0x422e,
+ 0x4224, 0x6d75, 0x3029, 0x4f22, 0x6d7a, 0x4261, 0x3d35, 0x3f4a,
+ 0x6d7c, 0x6d7b, 0x306f, 0x6d7d, 0x492f, 0x6e27, 0x465b, 0x3f6b,
+ 0x4359, 0x3678, 0x6e26, 0x4d37, 0x313f, 0x4a57, 0x3261, 0x6e21,
+ 0x6e22, 0x6e23, 0x6e24, 0x463b, 0x4323, 0x3063, 0x6e28, 0x6e29,
+ 0x7423, 0x423d, 0x6e2a, 0x3173, 0x414c, 0x382f, 0x4d5a, 0x6e2b,
+ 0x452c, 0x4178, 0x3c57, 0x6e2c, 0x6e2f, 0x3d65, 0x6e2d, 0x412b,
+ 0x412a, 0x3064, 0x4e4b, 0x6e31, 0x4872, 0x6e33, 0x6e32, 0x6e30,
+ 0x6364, 0x3454, 0x6d6e, 0x6e35, 0x6e34, 0x6e36, 0x4d38, 0x4661,
+ 0x4b2e, 0x6e37, 0x3c59, 0x6e38, 0x6e39, 0x6e3a, 0x4521, 0x306a,
+ 0x3959, 0x4f3a, 0x6e3e, 0x3734, 0x6e3b, 0x6e3c, 0x4974, 0x3354,
+ 0x4d39, 0x363f, 0x4554, 0x6e3f, 0x6e40, 0x6e41, 0x4522, 0x6e43,
+ 0x6e42, 0x4653, 0x6e44, 0x3d36, 0x3c60, 0x475b, 0x4371, 0x3c72,
+ 0x3f6c, 0x6e45, 0x6e46, 0x3f5d, 0x6e47, 0x6e48, 0x6e49, 0x4d6f,
+ 0x3d37, 0x6e4b, 0x6e4a, 0x395a, 0x3973, 0x3b40, 0x6e4e, 0x3d66,
+ 0x6e4d, 0x6e4c, 0x4269, 0x386f, 0x4043, 0x4830, 0x3d39, 0x6e4f,
+ 0x3e5f, 0x6e52, 0x6e50, 0x6e51, 0x6e54, 0x6e53, 0x3e7a, 0x6e55,
+ 0x6e56, 0x6e57, 0x4850, 0x3a53, 0x3c61, 0x6e58, 0x6e59, 0x4e24,
+ 0x3d45, 0x4c6e, 0x4e4c, 0x6e5a, 0x3662, 0x6e5b, 0x4523, 0x6e5e,
+ 0x3378, 0x3f4b, 0x6e5c, 0x6e5d, 0x4460, 0x4b55, 0x367c, 0x6e60,
+ 0x6e61, 0x6e5f, 0x6e63, 0x465f, 0x3343, 0x6e67, 0x6e64, 0x6e66,
+ 0x6e62, 0x6f4f, 0x6e65, 0x4e6b, 0x385a, 0x6e6f, 0x4534, 0x6e6a,
+ 0x6e6d, 0x6e6b, 0x6e70, 0x6e71, 0x6e69, 0x6e76, 0x3174, 0x6e68,
+ 0x482d, 0x6e6c, 0x3e60, 0x395b, 0x4b48, 0x3664, 0x3d46, 0x463c,
+ 0x412d, 0x6e74, 0x6e6e, 0x6e73, 0x4c43, 0x4438, 0x6e75, 0x6e72,
+ 0x412c, 0x6e79, 0x6e78, 0x6e77, 0x4b2f, 0x3d7b, 0x6e7a, 0x4a5f,
+ 0x3154, 0x4946, 0x4372, 0x3578, 0x6e7c, 0x395d, 0x3b2c, 0x6e7b,
+ 0x3f6d, 0x3f6e, 0x6f21, 0x6f23, 0x3e7b, 0x6f22, 0x6f24, 0x3653,
+ 0x4945, 0x3c62, 0x4f23, 0x6e7e, 0x3a78, 0x4f3f, 0x6f26, 0x6f25,
+ 0x6f27, 0x6e7d, 0x4669, 0x4555, 0x4457, 0x6f2c, 0x4343, 0x6f28,
+ 0x6f29, 0x372d, 0x6f2b, 0x3830, 0x6f2a, 0x3e61, 0x3379, 0x6f30,
+ 0x3a3f, 0x4179, 0x444a, 0x333b, 0x6f2e, 0x6f2f, 0x4443, 0x6f2d,
+ 0x6f31, 0x6f37, 0x6f3a, 0x6f39, 0x452d, 0x6f32, 0x6f33, 0x6f36,
+ 0x6f38, 0x3640, 0x6f3b, 0x6f35, 0x6f34, 0x6f3f, 0x6f40, 0x6f41,
+ 0x6f3e, 0x6f3d, 0x3e62, 0x462a, 0x6f3c, 0x6f45, 0x6f43, 0x6f44,
+ 0x6f42, 0x4278, 0x6f46, 0x6f47, 0x6f49, 0x3455, 0x6f48, 0x4c7a,
+ 0x6f54, 0x6f4a, 0x6f4d, 0x6f4b, 0x6f4c, 0x6f4e, 0x6f50, 0x6f51,
+ 0x6f52, 0x6f55, 0x6f53, 0x6f56, 0x6f58, 0x6f57, 0x4439, 0x4c67,
+ 0x6f59, 0x412e, 0x6f5a, 0x4a44, 0x6f5b, 0x332b, 0x313c, 0x3457,
+ 0x3456, 0x6f5c, 0x6f5d, 0x6f5e, 0x6f5f, 0x6f60, 0x3458, 0x3355,
+ 0x395e, 0x4836, 0x6f62, 0x6f61, 0x6f63, 0x315c, 0x6f66, 0x6f65,
+ 0x6f64, 0x6f67, 0x6f6a, 0x3047, 0x6f68, 0x6f6c, 0x6f6b, 0x6f6e,
+ 0x6f6d, 0x6f6f, 0x462e, 0x6f70, 0x6f71, 0x6f73, 0x6f72, 0x496c,
+ 0x6f74, 0x6f75, 0x3a65, 0x6f76, 0x6f77, 0x4b49, 0x414b, 0x3024,
+ 0x424b, 0x6f78, 0x496d, 0x6f7b, 0x6f79, 0x395f, 0x6f7a, 0x3842,
+ 0x4a45, 0x6f7d, 0x7021, 0x6f7e, 0x7022, 0x3121, 0x3f58, 0x3d7c,
+ 0x3459, 0x7023, 0x4766, 0x7025, 0x3122, 0x7024, 0x4444, 0x4e4d,
+ 0x462b, 0x6f7c, 0x4e26, 0x3831, 0x4d5b, 0x3679, 0x4e34, 0x3728,
+ 0x4262, 0x6721, 0x7026, 0x332c, 0x3f6f, 0x3356, 0x7028, 0x7029,
+ 0x7027, 0x3764, 0x3a5d, 0x3e63, 0x3123, 0x4e59, 0x702b, 0x6e2e,
+ 0x702a, 0x702e, 0x702c, 0x702d, 0x702f, 0x7030, 0x4e6c, 0x7031,
+ 0x7032, 0x4049, 0x483b, 0x3f7d, 0x3467, 0x4d3a, 0x326d, 0x3d38,
+ 0x385b, 0x7035, 0x7034, 0x3b73, 0x7036, 0x7033, 0x3b28, 0x703a,
+ 0x6a2d, 0x5256, 0x3f77, 0x7038, 0x4e25, 0x4671, 0x312b, 0x4063,
+ 0x3c36, 0x4a37, 0x3140, 0x4e6d, 0x4d6b, 0x703b, 0x4545, 0x3c7b,
+ 0x703c, 0x703d, 0x3f4c, 0x703e, 0x4e6e, 0x7039, 0x7040, 0x7042,
+ 0x7041, 0x703f, 0x7043, 0x7044, 0x417a, 0x3262, 0x7045, 0x4c38,
+ 0x7046, 0x7047, 0x4f2a, 0x5b31, 0x7048, 0x7049, 0x704a, 0x704e,
+ 0x704b, 0x704c, 0x704d, 0x704f, 0x4044, 0x4c77, 0x4045, 0x7050,
+ 0x4873, 0x7051, 0x7353, 0x4c4c, 0x7052, 0x7053, 0x7054, 0x3357,
+ 0x7056, 0x3f59, 0x7057, 0x3724, 0x7058, 0x705c, 0x705a, 0x705b,
+ 0x3373, 0x7059, 0x705d, 0x705e, 0x3048, 0x705f, 0x7060, 0x3e64,
+ 0x7061, 0x3547, 0x7064, 0x7063, 0x7062, 0x6b71, 0x4a5c, 0x7065,
+ 0x7066, 0x7067, 0x7068, 0x7069, 0x706a, 0x345a, 0x706b, 0x706c,
+ 0x4723, 0x706e, 0x323b, 0x7071, 0x7070, 0x3124, 0x3641, 0x4a47,
+ 0x443a, 0x3a22, 0x3960, 0x3d67, 0x3f5c, 0x7073, 0x7072, 0x4d42,
+ 0x3468, 0x4852, 0x465c, 0x3f7c, 0x4e4e, 0x375b, 0x7076, 0x7075,
+ 0x4b4b, 0x462c, 0x3150, 0x7077, 0x7074, 0x4951, 0x4d6a, 0x7078,
+ 0x7079, 0x707b, 0x426a, 0x335b, 0x335c, 0x707a, 0x3469, 0x3832,
+ 0x346a, 0x453f, 0x4e60, 0x385c, 0x707c, 0x707d, 0x707e, 0x7121,
+ 0x7123, 0x7122, 0x4977, 0x7124, 0x7125, 0x7126, 0x7127, 0x7129,
+ 0x7128, 0x712a, 0x4874, 0x664c, 0x3f29, 0x3532, 0x712b, 0x712c,
+ 0x522c, 0x5d3b, 0x4853, 0x307b, 0x303b, 0x3b74, 0x4b30, 0x3e7e,
+ 0x712d, 0x4c5f, 0x712e, 0x4d5c, 0x3142, 0x3b41, 0x712f, 0x326e,
+ 0x7130, 0x7131, 0x7133, 0x7134, 0x7136, 0x7132, 0x7135, 0x345b,
+ 0x7137, 0x7138, 0x7139, 0x713a, 0x713b, 0x713d, 0x713c, 0x713f,
+ 0x7142, 0x713e, 0x7140, 0x7141, 0x7143, 0x3642, 0x3c73, 0x7144,
+ 0x7145, 0x3961, 0x7146, 0x333e, 0x474f, 0x7147, 0x7148, 0x435a,
+ 0x466b, 0x7149, 0x477d, 0x424c, 0x3158, 0x366e, 0x366f, 0x4373,
+ 0x714e, 0x3670, 0x326f, 0x714d, 0x714b, 0x714c, 0x714a, 0x7158,
+ 0x714f, 0x7150, 0x7151, 0x7152, 0x7154, 0x7153, 0x3d59, 0x7155,
+ 0x7157, 0x3533, 0x7156, 0x417b, 0x3833, 0x7159, 0x424d, 0x715a,
+ 0x462d, 0x715b, 0x7160, 0x715e, 0x715d, 0x715f, 0x715c, 0x7162,
+ 0x7161, 0x7164, 0x3643, 0x7163, 0x7165, 0x7166, 0x7168, 0x7167,
+ 0x7169, 0x716b, 0x716a, 0x397c, 0x716c, 0x716d, 0x333c, 0x716e,
+ 0x716f, 0x3f71, 0x7170, 0x7171, 0x7172, 0x7173, 0x3962, 0x7174,
+ 0x7175, 0x7176, 0x7177, 0x7178, 0x4831, 0x717a, 0x4926, 0x717b,
+ 0x7179, 0x717d, 0x717c, 0x717e, 0x7221, 0x7222, 0x7223, 0x7224,
+ 0x7225, 0x7226, 0x7227, 0x7228, 0x7229, 0x722a, 0x722b, 0x722c,
+ 0x722d, 0x722e, 0x5d35, 0x722f, 0x6478, 0x3534, 0x3321, 0x3a32,
+ 0x7231, 0x7230, 0x4c25, 0x7233, 0x7234, 0x7232, 0x7235, 0x4b62,
+ 0x7236, 0x357b, 0x4f25, 0x7237, 0x7239, 0x303e, 0x723a, 0x4a2b,
+ 0x7238, 0x723b, 0x723c, 0x723d, 0x723e, 0x723f, 0x4b6e, 0x3b2d,
+ 0x3a7a, 0x412f, 0x7240, 0x7243, 0x7241, 0x7244, 0x3871, 0x7242,
+ 0x7245, 0x7246, 0x7247, 0x724b, 0x3b2a, 0x4264, 0x724c, 0x7249,
+ 0x7248, 0x724a, 0x375f, 0x7250, 0x724f, 0x724e, 0x3033, 0x725a,
+ 0x7256, 0x7257, 0x7253, 0x7259, 0x7255, 0x3362, 0x4f4c, 0x7258,
+ 0x7254, 0x7252, 0x7251, 0x725c, 0x725f, 0x725e, 0x725d, 0x4949,
+ 0x725b, 0x3073, 0x7260, 0x7262, 0x336f, 0x724d, 0x3137, 0x7264,
+ 0x7263, 0x7261, 0x432d, 0x4b70, 0x4e5a, 0x7265, 0x7266, 0x7267,
+ 0x7268, 0x7269, 0x443b, 0x726a, 0x4837, 0x726f, 0x726b, 0x726c,
+ 0x4b31, 0x4c44, 0x4650, 0x7270, 0x7271, 0x463e, 0x726e, 0x726d,
+ 0x322a, 0x7279, 0x7278, 0x3175, 0x7276, 0x7275, 0x7273, 0x337b,
+ 0x7272, 0x3c32, 0x3229, 0x3963, 0x727c, 0x727b, 0x727a, 0x7277,
+ 0x727d, 0x727e, 0x7325, 0x7324, 0x7326, 0x312d, 0x7321, 0x7322,
+ 0x3974, 0x4c39, 0x7323, 0x4b32, 0x732b, 0x7327, 0x732c, 0x7329,
+ 0x7328, 0x375c, 0x732d, 0x732e, 0x732f, 0x732a, 0x7274, 0x7330,
+ 0x4461, 0x7334, 0x7335, 0x7333, 0x7332, 0x7338, 0x7331, 0x7336,
+ 0x7337, 0x733a, 0x7339, 0x733c, 0x733d, 0x733e, 0x4f49, 0x733b,
+ 0x426b, 0x3a6d, 0x733f, 0x7340, 0x7341, 0x7342, 0x7343, 0x3834,
+ 0x7344, 0x7345, 0x3c2f, 0x7346, 0x7347, 0x7348, 0x7349, 0x734c,
+ 0x734a, 0x4f3c, 0x734b, 0x4e6f, 0x734d, 0x4e5b, 0x734e, 0x477e,
+ 0x734f, 0x7351, 0x7352, 0x7350, 0x396d, 0x4c4d, 0x4b63, 0x5677,
+ 0x5d60, 0x4b7b, 0x322b, 0x7354, 0x3550, 0x7355, 0x7356, 0x7357,
+ 0x3975, 0x7358, 0x6054, 0x4c5b, 0x4263, 0x7359, 0x735b, 0x735a,
+ 0x735c, 0x735d, 0x735e, 0x735f, 0x7360, 0x7361, 0x7362, 0x7363,
+ 0x7364, 0x7365, 0x7366, 0x7367, 0x7368, 0x4524, 0x385d, 0x736a,
+ 0x414d, 0x736b, 0x736c, 0x4921, 0x736d, 0x736e, 0x6337, 0x6c5a,
+ 0x706d, 0x736f, 0x7370, 0x7372, 0x7373, 0x7374, 0x4e70, 0x7371,
+ 0x7375, 0x7376, 0x7378, 0x7377, 0x737a, 0x737b, 0x7379, 0x4e36,
+ 0x737c, 0x737d, 0x6354, 0x737e, 0x212a, 0x2174, 0x2170, 0x2173,
+ 0x2175, 0x214a, 0x214b, 0x2176, 0x215c, 0x2124, 0x2125, 0x213f,
+ 0x2330, 0x2331, 0x2332, 0x2333, 0x2334, 0x2335, 0x2336, 0x2337,
+ 0x2338, 0x2339, 0x2127, 0x2128, 0x2163, 0x2161, 0x2164, 0x2129,
+ 0x2177, 0x2341, 0x2342, 0x2343, 0x2344, 0x2345, 0x2346, 0x2347,
+ 0x2348, 0x2349, 0x234a, 0x234b, 0x234c, 0x234d, 0x234e, 0x234f,
+ 0x2350, 0x2351, 0x2352, 0x2353, 0x2354, 0x2355, 0x2356, 0x2357,
+ 0x2358, 0x2359, 0x235a, 0x214e, 0x214f, 0x2130, 0x2132, 0x212e,
+ 0x2361, 0x2362, 0x2363, 0x2364, 0x2365, 0x2366, 0x2367, 0x2368,
+ 0x2369, 0x236a, 0x236b, 0x236c, 0x236d, 0x236e, 0x236f, 0x2370,
+ 0x2371, 0x2372, 0x2373, 0x2374, 0x2375, 0x2376, 0x2377, 0x2378,
+ 0x2379, 0x237a, 0x2150, 0x2143, 0x2151, 0x2131, 0x216f,
+};
+
+static const Summary16 jisx0208_uni2indx_page00[16] = {
+ /* 0x0000 */
+ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
+ { 0, 0x0000 }, { 0, 0x1000 }, { 1, 0x0000 }, { 1, 0x0000 },
+ { 1, 0x0000 }, { 1, 0x0000 }, { 1, 0x118c }, { 6, 0x0053 },
+ { 10, 0x0000 }, { 10, 0x0080 }, { 11, 0x0000 }, { 11, 0x0080 },
+};
+static const Summary16 jisx0208_uni2indx_page03[22] = {
+ /* 0x0300 */
+ { 12, 0x0000 }, { 12, 0x0000 }, { 12, 0x0000 }, { 12, 0x0000 },
+ { 12, 0x0000 }, { 12, 0x0000 }, { 12, 0x0000 }, { 12, 0x0000 },
+ { 12, 0x0000 }, { 12, 0xfffe }, { 27, 0x03fb }, { 36, 0xfffe },
+ { 51, 0x03fb }, { 60, 0x0000 }, { 60, 0x0000 }, { 60, 0x0000 },
+ /* 0x0400 */
+ { 60, 0x0002 }, { 61, 0xffff }, { 77, 0xffff }, { 93, 0xffff },
+ { 109, 0xffff }, { 125, 0x0002 },
+};
+static const Summary16 jisx0208_uni2indx_page20[50] = {
+ /* 0x2000 */
+ { 126, 0x0000 }, { 126, 0x3361 }, { 133, 0x0063 }, { 137, 0x080d },
+ { 141, 0x0000 }, { 141, 0x0000 }, { 141, 0x0000 }, { 141, 0x0000 },
+ { 141, 0x0000 }, { 141, 0x0000 }, { 141, 0x0000 }, { 141, 0x0000 },
+ { 141, 0x0000 }, { 141, 0x0000 }, { 141, 0x0000 }, { 141, 0x0000 },
+ /* 0x2100 */
+ { 141, 0x0008 }, { 142, 0x0000 }, { 142, 0x0800 }, { 143, 0x0000 },
+ { 143, 0x0000 }, { 143, 0x0000 }, { 143, 0x0000 }, { 143, 0x0000 },
+ { 143, 0x0000 }, { 143, 0x000f }, { 147, 0x0000 }, { 147, 0x0000 },
+ { 147, 0x0000 }, { 147, 0x0014 }, { 149, 0x0000 }, { 149, 0x0000 },
+ /* 0x2200 */
+ { 149, 0x098d }, { 155, 0x6404 }, { 159, 0x1f81 }, { 166, 0x2030 },
+ { 169, 0x0000 }, { 169, 0x0004 }, { 170, 0x0cc3 }, { 176, 0x0000 },
+ { 176, 0x00cc }, { 180, 0x0000 }, { 180, 0x0020 }, { 181, 0x0000 },
+ { 181, 0x0000 }, { 181, 0x0000 }, { 181, 0x0000 }, { 181, 0x0000 },
+ /* 0x2300 */
+ { 181, 0x0000 }, { 181, 0x0004 },
+};
+static const Summary16 jisx0208_uni2indx_page25[23] = {
+ /* 0x2500 */
+ { 182, 0x900f }, { 188, 0x3999 }, { 196, 0x9939 }, { 204, 0x9999 },
+ { 212, 0x0804 }, { 214, 0x0000 }, { 214, 0x0000 }, { 214, 0x0000 },
+ { 214, 0x0000 }, { 214, 0x0000 }, { 214, 0x0003 }, { 216, 0x300c },
+ { 220, 0xc8c0 }, { 225, 0x0000 }, { 225, 0x8000 }, { 226, 0x0000 },
+ /* 0x2600 */
+ { 226, 0x0060 }, { 228, 0x0000 }, { 228, 0x0000 }, { 228, 0x0000 },
+ { 228, 0x0005 }, { 230, 0x0000 }, { 230, 0xa400 },
+};
+static const Summary16 jisx0208_uni2indx_page30[16] = {
+ /* 0x3000 */
+ { 233, 0xffef }, { 248, 0x103f }, { 255, 0x0000 }, { 255, 0x0000 },
+ { 255, 0xfffe }, { 270, 0xffff }, { 286, 0xffff }, { 302, 0xffff },
+ { 318, 0xffff }, { 334, 0x780f }, { 342, 0xfffe }, { 357, 0xffff },
+ { 373, 0xffff }, { 389, 0xffff }, { 405, 0xffff }, { 421, 0x787f },
+};
+static const Summary16 jisx0208_uni2indx_page4e[1307] = {
+ /* 0x4e00 */
+ { 432, 0x6f8b }, { 442, 0x43f3 }, { 451, 0x2442 }, { 455, 0x9b46 },
+ { 463, 0xe82c }, { 470, 0xe3e0 }, { 478, 0x0004 }, { 479, 0x400a },
+ { 482, 0x5f65 }, { 492, 0xdb36 }, { 502, 0x7977 }, { 513, 0x0449 },
+ { 517, 0xecd7 }, { 528, 0xe3f0 }, { 537, 0x6038 }, { 542, 0x08c5 },
+ /* 0x4f00 */
+ { 547, 0xe602 }, { 553, 0x3403 }, { 558, 0x8000 }, { 559, 0x3551 },
+ { 566, 0xe0c8 }, { 572, 0x7eab }, { 583, 0x8200 }, { 585, 0x9869 },
+ { 592, 0xa948 }, { 598, 0x2942 }, { 603, 0xe803 }, { 609, 0x8060 },
+ { 612, 0x441c }, { 617, 0xad93 }, { 626, 0xc03a }, { 632, 0x4568 },
+ /* 0x5000 */
+ { 638, 0xaa60 }, { 644, 0x8656 }, { 651, 0x3f7a }, { 662, 0x0240 },
+ { 664, 0x8388 }, { 669, 0x1461 }, { 674, 0x1020 }, { 676, 0x2174 },
+ { 682, 0x2021 }, { 685, 0x0702 }, { 689, 0x3000 }, { 691, 0x40bc },
+ { 697, 0xa624 }, { 703, 0x4462 }, { 708, 0x60a8 }, { 713, 0x0a20 },
+ /* 0x5100 */
+ { 716, 0x0217 }, { 721, 0x8574 }, { 728, 0x0402 }, { 730, 0x9c84 },
+ { 736, 0x7bfb }, { 749, 0x1415 }, { 754, 0x7f24 }, { 763, 0x11e2 },
+ { 769, 0xb665 }, { 778, 0x02ef }, { 786, 0x1f75 }, { 796, 0x20ff },
+ { 805, 0x3a70 }, { 812, 0x3840 }, { 816, 0x26c3 }, { 823, 0x6763 },
+ /* 0x5200 */
+ { 832, 0x4dd9 }, { 841, 0x2092 }, { 845, 0x46b0 }, { 851, 0x0fc9 },
+ { 859, 0xbc98 }, { 867, 0x4850 }, { 871, 0x8638 }, { 877, 0xa03f },
+ { 885, 0x2388 }, { 890, 0x8816 }, { 895, 0x3e09 }, { 902, 0x5232 },
+ { 908, 0x22aa }, { 914, 0xe3a4 }, { 922, 0x00dd }, { 928, 0xc72c },
+ /* 0x5300 */
+ { 936, 0xa166 }, { 943, 0x26e1 }, { 950, 0x840b }, { 955, 0x8f0a },
+ { 962, 0x27eb }, { 972, 0x559e }, { 981, 0xc241 }, { 986, 0x89bb },
+ { 995, 0x0014 }, { 997, 0x8540 }, { 1001, 0x6361 }, { 1008, 0x0849 },
+ { 1012, 0x7f0c }, { 1021, 0x8ad0 }, { 1027, 0xff3e }, { 1040, 0x05cf },
+ /* 0x5400 */
+ { 1048, 0xff1a }, { 1059, 0xa803 }, { 1064, 0x7a41 }, { 1071, 0x7b40 },
+ { 1078, 0x4745 }, { 1085, 0x8002 }, { 1087, 0x0500 }, { 1089, 0x38eb },
+ { 1098, 0xd851 }, { 1105, 0x0005 }, { 1107, 0x9934 }, { 1114, 0x710c },
+ { 1120, 0x0397 }, { 1127, 0x0100 }, { 1128, 0x6366 }, { 1136, 0x2404 },
+ /* 0x5500 */
+ { 1139, 0x80d0 }, { 1143, 0x0051 }, { 1146, 0xc000 }, { 1148, 0x430a },
+ { 1153, 0x9071 }, { 1159, 0x30c8 }, { 1164, 0x0008 }, { 1165, 0x5800 },
+ { 1168, 0x0e99 }, { 1175, 0xf700 }, { 1182, 0x5f80 }, { 1189, 0x0041 },
+ { 1191, 0x00b0 }, { 1194, 0x9410 }, { 1198, 0x0018 }, { 1200, 0x6280 },
+ /* 0x5600 */
+ { 1204, 0x0240 }, { 1206, 0x09d0 }, { 1211, 0x8200 }, { 1213, 0x0156 },
+ { 1218, 0x5004 }, { 1221, 0x0801 }, { 1223, 0x1d10 }, { 1228, 0x0510 },
+ { 1231, 0x84c1 }, { 1236, 0x0010 }, { 1237, 0x4025 }, { 1241, 0x1050 },
+ { 1244, 0x410f }, { 1250, 0x4d8a }, { 1257, 0x4009 }, { 1260, 0xa60d },
+ /* 0x5700 */
+ { 1267, 0xab19 }, { 1275, 0x914c }, { 1281, 0x21c0 }, { 1285, 0x0981 },
+ { 1289, 0xc485 }, { 1295, 0x0003 }, { 1297, 0x0652 }, { 1302, 0x8000 },
+ { 1303, 0x0b04 }, { 1307, 0x0008 }, { 1308, 0x041d }, { 1313, 0x0009 },
+ { 1315, 0x4849 }, { 1320, 0x905c }, { 1326, 0x0009 }, { 1328, 0x1690 },
+ /* 0x5800 */
+ { 1333, 0x0c65 }, { 1339, 0x2220 }, { 1342, 0x8412 }, { 1346, 0x2433 },
+ { 1352, 0x0c03 }, { 1356, 0x4796 }, { 1364, 0x0a04 }, { 1367, 0x4225 },
+ { 1372, 0x0028 }, { 1374, 0x9088 }, { 1378, 0x4900 }, { 1381, 0x4f08 },
+ { 1387, 0x14a2 }, { 1392, 0xd3aa }, { 1401, 0xd830 }, { 1407, 0x3e87 },
+ /* 0x5900 */
+ { 1416, 0x8604 }, { 1420, 0x1f61 }, { 1428, 0x7ea4 }, { 1437, 0x4186 },
+ { 1442, 0xc390 }, { 1448, 0x05b3 }, { 1455, 0x57a5 }, { 1464, 0x2118 },
+ { 1468, 0x241e }, { 1474, 0x2a48 }, { 1479, 0x1128 }, { 1483, 0x4a04 },
+ { 1487, 0x0a40 }, { 1490, 0x161b }, { 1497, 0x0d60 }, { 1502, 0x8840 },
+ /* 0x5a00 */
+ { 1505, 0x020a }, { 1508, 0x9502 }, { 1513, 0x8221 }, { 1517, 0x1060 },
+ { 1520, 0x0243 }, { 1524, 0x0400 }, { 1525, 0x1444 }, { 1529, 0x8000 },
+ { 1530, 0x0000 }, { 1530, 0x0c04 }, { 1533, 0x0000 }, { 1533, 0x7000 },
+ { 1536, 0x1a06 }, { 1541, 0x00c1 }, { 1544, 0x024a }, { 1548, 0x0c00 },
+ /* 0x5b00 */
+ { 1550, 0x1a00 }, { 1553, 0x0040 }, { 1554, 0x1404 }, { 1557, 0x4045 },
+ { 1561, 0x0029 }, { 1564, 0xbdb3 }, { 1575, 0x0a78 }, { 1581, 0x052b },
+ { 1587, 0xbba9 }, { 1597, 0xbfa0 }, { 1606, 0x407c }, { 1612, 0x8379 },
+ { 1620, 0x12fc }, { 1628, 0xe81d }, { 1636, 0x4bf6 }, { 1646, 0xc569 },
+ /* 0x5c00 */
+ { 1654, 0xeff6 }, { 1667, 0x044a }, { 1671, 0x2115 }, { 1676, 0xff02 },
+ { 1685, 0xed63 }, { 1695, 0x402b }, { 1700, 0xd033 }, { 1707, 0x0242 },
+ { 1710, 0x1000 }, { 1711, 0x0013 }, { 1714, 0x1b02 }, { 1719, 0x59ca },
+ { 1727, 0x00a0 }, { 1729, 0x0200 }, { 1730, 0xa703 }, { 1737, 0x2c41 },
+ /* 0x5d00 */
+ { 1742, 0x4880 }, { 1745, 0x8ff2 }, { 1755, 0x0204 }, { 1757, 0x0000 },
+ { 1757, 0x5800 }, { 1760, 0x1005 }, { 1763, 0x9200 }, { 1766, 0x0048 },
+ { 1768, 0x1894 }, { 1773, 0x2001 }, { 1775, 0x5004 }, { 1778, 0x3480 },
+ { 1782, 0x3200 }, { 1785, 0x684c }, { 1791, 0x49ea }, { 1799, 0x68be },
+ /* 0x5e00 */
+ { 1808, 0x184c }, { 1813, 0x2e42 }, { 1819, 0xa820 }, { 1823, 0x21c9 },
+ { 1829, 0x50b9 }, { 1836, 0x80b0 }, { 1840, 0x001e }, { 1844, 0xff7c },
+ { 1857, 0x849a }, { 1863, 0x14e0 }, { 1868, 0x28c1 }, { 1873, 0x01e0 },
+ { 1877, 0x870e }, { 1884, 0xac49 }, { 1891, 0x130f }, { 1898, 0xdddb },
+ /* 0x5f00 */
+ { 1910, 0xbe1a }, { 1919, 0x89fb }, { 1929, 0xa2e0 }, { 1935, 0x51a2 },
+ { 1941, 0x5502 }, { 1946, 0x32ca }, { 1953, 0x3e46 }, { 1961, 0x928b },
+ { 1968, 0x1dbf }, { 1979, 0x438f }, { 1987, 0x6703 }, { 1994, 0x3218 },
+ { 1999, 0x3028 }, { 2003, 0x33c0 }, { 2009, 0x0811 }, { 2012, 0xa923 },
+ /* 0x6000 */
+ { 2019, 0xc000 }, { 2021, 0x3a65 }, { 2029, 0x8fe3 }, { 2039, 0x0402 },
+ { 2041, 0x2c4e }, { 2048, 0x8625 }, { 2054, 0xbf3d }, { 2066, 0x00a1 },
+ { 2069, 0x3a1a }, { 2076, 0x8cd4 }, { 2083, 0x06c9 }, { 2089, 0x317c },
+ { 2097, 0x00e0 }, { 2100, 0x950a }, { 2106, 0x018b }, { 2111, 0x0edb },
+ /* 0x6100 */
+ { 2120, 0xe34b }, { 2129, 0x8c20 }, { 2133, 0x1182 }, { 2137, 0xf010 },
+ { 2142, 0x7d94 }, { 2151, 0xa728 }, { 2158, 0xc9ac }, { 2166, 0x40fb },
+ { 2174, 0x4484 }, { 2178, 0x0653 }, { 2184, 0x5a90 }, { 2190, 0x4444 },
+ { 2194, 0x3fc8 }, { 2203, 0x0001 }, { 2204, 0x0048 }, { 2206, 0xf5d4 },
+ /* 0x6200 */
+ { 2216, 0x7701 }, { 2223, 0xec57 }, { 2233, 0xc442 }, { 2238, 0x891d },
+ { 2245, 0x6b83 }, { 2253, 0x4928 }, { 2258, 0x4109 }, { 2262, 0xd242 },
+ { 2268, 0x061d }, { 2274, 0x59fe }, { 2285, 0x1800 }, { 2287, 0x3a22 },
+ { 2293, 0xb7e4 }, { 2303, 0x3b9f }, { 2314, 0xf003 }, { 2320, 0xc0ea },
+ /* 0x6300 */
+ { 2327, 0x1386 }, { 2333, 0x8202 }, { 2336, 0x8980 }, { 2340, 0xe400 },
+ { 2344, 0xb200 }, { 2348, 0x10a1 }, { 2352, 0x4b80 }, { 2357, 0x0cc4 },
+ { 2362, 0xd309 }, { 2369, 0x8944 }, { 2374, 0x1faf }, { 2385, 0x4834 },
+ { 2390, 0x8259 }, { 2396, 0x0c45 }, { 2401, 0x420a }, { 2405, 0x0450 },
+ /* 0x6400 */
+ { 2408, 0xa040 }, { 2411, 0x10c8 }, { 2415, 0x3140 }, { 2419, 0x4450 },
+ { 2423, 0x4004 }, { 2425, 0x0100 }, { 2426, 0x8280 }, { 2429, 0x0540 },
+ { 2432, 0x0108 }, { 2434, 0x442c }, { 2439, 0x6a30 }, { 2445, 0x1a05 },
+ { 2450, 0x20a6 }, { 2455, 0x0514 }, { 2459, 0x90cf }, { 2467, 0x6456 },
+ /* 0x6500 */
+ { 2474, 0x0021 }, { 2476, 0x3100 }, { 2479, 0x9c18 }, { 2485, 0xcbf0 },
+ { 2494, 0xa120 }, { 2498, 0x63e2 }, { 2506, 0x104c }, { 2510, 0x01b5 },
+ { 2516, 0x538c }, { 2523, 0x9a83 }, { 2530, 0xb8b2 }, { 2538, 0x3281 },
+ { 2543, 0x987a }, { 2551, 0x0a84 }, { 2555, 0x33e7 }, { 2565, 0x0c02 },
+ /* 0x6600 */
+ { 2568, 0xd4cc }, { 2576, 0x9018 }, { 2580, 0xa1a1 }, { 2586, 0x9070 },
+ { 2591, 0x8a1e }, { 2598, 0xe004 }, { 2602, 0xc3d4 }, { 2610, 0x0451 },
+ { 2614, 0x439a }, { 2621, 0x21c2 }, { 2626, 0x4844 }, { 2630, 0x5310 },
+ { 2635, 0x0292 }, { 2639, 0x3640 }, { 2644, 0x0241 }, { 2647, 0xf3bd },
+ /* 0x6700 */
+ { 2659, 0xab09 }, { 2666, 0xe8f0 }, { 2674, 0x7dc0 }, { 2682, 0xa5d2 },
+ { 2690, 0xc242 }, { 2695, 0xd24b }, { 2703, 0xa43f }, { 2712, 0xd0af },
+ { 2721, 0x1aa0 }, { 2726, 0x34a1 }, { 2732, 0x8247 }, { 2738, 0x03d8 },
+ { 2744, 0xc452 }, { 2750, 0x651b }, { 2758, 0xd294 }, { 2765, 0xc83a },
+ /* 0x6800 */
+ { 2772, 0x001c }, { 2775, 0x40c8 }, { 2779, 0x0e06 }, { 2784, 0x3314 },
+ { 2790, 0x614f }, { 2798, 0xb21b }, { 2806, 0x0088 }, { 2808, 0xc0d0 },
+ { 2813, 0xa02a }, { 2818, 0xa898 }, { 2824, 0xa1c5 }, { 2831, 0x166b },
+ { 2839, 0x2e50 }, { 2845, 0x85b4 }, { 2852, 0xc08b }, { 2858, 0x0604 },
+ /* 0x6900 */
+ { 2861, 0xf933 }, { 2871, 0x1e04 }, { 2876, 0x056e }, { 2883, 0xa251 },
+ { 2889, 0x0400 }, { 2890, 0x7638 }, { 2898, 0xec07 }, { 2906, 0x73b8 },
+ { 2915, 0x4406 }, { 2919, 0x1832 }, { 2924, 0x4081 }, { 2927, 0xc816 },
+ { 2933, 0x7c8a }, { 2941, 0x6309 }, { 2947, 0x2980 }, { 2951, 0xaa04 },
+ /* 0x6a00 */
+ { 2956, 0x1c24 }, { 2961, 0xca9c }, { 2969, 0x4e0e }, { 2976, 0x2760 },
+ { 2982, 0x0990 }, { 2986, 0x8300 }, { 2989, 0x0046 }, { 2992, 0x8104 },
+ { 2995, 0x6011 }, { 2999, 0x1081 }, { 3002, 0x540d }, { 3008, 0x0908 },
+ { 3011, 0x000e }, { 3014, 0xcc0a }, { 3020, 0x0500 }, { 3022, 0x0c00 },
+ /* 0x6b00 */
+ { 3024, 0x0430 }, { 3027, 0xa044 }, { 3031, 0x008b }, { 3035, 0x6784 },
+ { 3042, 0x5288 }, { 3047, 0x8a19 }, { 3053, 0x865e }, { 3061, 0x8b18 },
+ { 3067, 0x2e59 }, { 3075, 0x4160 }, { 3079, 0x8c10 }, { 3083, 0x9cbe },
+ { 3093, 0x6861 }, { 3099, 0x891c }, { 3105, 0x9800 }, { 3108, 0x0008 },
+ /* 0x6c00 */
+ { 3109, 0x8100 }, { 3111, 0x089a }, { 3116, 0x0018 }, { 3118, 0x4190 },
+ { 3122, 0x4007 }, { 3126, 0xe4a1 }, { 3133, 0x0505 }, { 3137, 0x640d },
+ { 3143, 0x310e }, { 3149, 0x0e4d }, { 3156, 0x4806 }, { 3160, 0xff0a },
+ { 3170, 0x1632 }, { 3176, 0x2aa8 }, { 3182, 0x852e }, { 3189, 0x000b },
+ /* 0x6d00 */
+ { 3192, 0x1800 }, { 3194, 0xca84 }, { 3200, 0x0e20 }, { 3204, 0x696c },
+ { 3212, 0x0032 }, { 3215, 0x1600 }, { 3218, 0x5658 }, { 3225, 0x0390 },
+ { 3229, 0x5120 }, { 3233, 0x1a28 }, { 3238, 0x8000 }, { 3239, 0x1124 },
+ { 3243, 0x18e1 }, { 3249, 0x4326 }, { 3255, 0x5d52 }, { 3263, 0x0eaa },
+ /* 0x6e00 */
+ { 3270, 0x0fa0 }, { 3276, 0xae28 }, { 3283, 0xfa7b }, { 3295, 0x4500 },
+ { 3298, 0x6408 }, { 3302, 0x8940 }, { 3306, 0xc880 }, { 3310, 0xc044 },
+ { 3314, 0x9005 }, { 3318, 0xb141 }, { 3324, 0x8424 }, { 3328, 0x24c4 },
+ { 3333, 0x1a34 }, { 3339, 0x603a }, { 3345, 0x9000 }, { 3347, 0xc194 },
+ /* 0x6f00 */
+ { 3353, 0x8246 }, { 3358, 0x003a }, { 3362, 0x180d }, { 3367, 0xc106 },
+ { 3372, 0x0022 }, { 3374, 0x9910 }, { 3379, 0xe050 }, { 3384, 0x1511 },
+ { 3389, 0x4057 }, { 3395, 0x0082 }, { 3397, 0x041a }, { 3401, 0x020a },
+ { 3404, 0x004f }, { 3409, 0x8930 }, { 3414, 0xd813 }, { 3421, 0x444a },
+ /* 0x7000 */
+ { 3426, 0x8a02 }, { 3430, 0xed22 }, { 3438, 0x10c0 }, { 3441, 0x4005 },
+ { 3444, 0x1000 }, { 3445, 0x0102 }, { 3447, 0x8808 }, { 3450, 0x3101 },
+ { 3454, 0x4600 }, { 3457, 0x0204 }, { 3459, 0xf000 }, { 3463, 0x0708 },
+ { 3467, 0x8900 }, { 3470, 0xa200 }, { 3473, 0x0000 }, { 3473, 0x2202 },
+ /* 0x7100 */
+ { 3476, 0x0200 }, { 3477, 0x1610 }, { 3481, 0x0042 }, { 3483, 0x1040 },
+ { 3485, 0x5200 }, { 3488, 0x0260 }, { 3491, 0x52f4 }, { 3499, 0x2000 },
+ { 3500, 0x8510 }, { 3504, 0x8230 }, { 3508, 0x1100 }, { 3510, 0x4202 },
+ { 3513, 0x4308 }, { 3517, 0x80b5 }, { 3523, 0x70e1 }, { 3530, 0x9a20 },
+ /* 0x7200 */
+ { 3535, 0x2040 }, { 3537, 0x0801 }, { 3539, 0x3500 }, { 3543, 0xfc65 },
+ { 3553, 0x19c1 }, { 3559, 0xab04 }, { 3565, 0x0286 }, { 3569, 0x6214 },
+ { 3574, 0x0087 }, { 3578, 0x0044 }, { 3580, 0x9085 }, { 3585, 0x0244 },
+ { 3588, 0x405c }, { 3593, 0x0a85 }, { 3598, 0x3207 }, { 3604, 0x3380 },
+ /* 0x7300 */
+ { 3609, 0x0400 }, { 3610, 0xb8c0 }, { 3616, 0xce20 }, { 3622, 0xc0d0 },
+ { 3627, 0xc030 }, { 3631, 0x0080 }, { 3632, 0x0508 }, { 3635, 0x0d25 },
+ { 3641, 0x0a90 }, { 3645, 0x0040 }, { 3646, 0x0200 }, { 3647, 0x080c },
+ { 3650, 0x6505 }, { 3656, 0x4000 }, { 3657, 0x6421 }, { 3662, 0x4102 },
+ /* 0x7400 */
+ { 3665, 0x0268 }, { 3669, 0x0000 }, { 3669, 0x0024 }, { 3671, 0x847c },
+ { 3678, 0x0002 }, { 3679, 0xde20 }, { 3686, 0x8619 }, { 3692, 0x4049 },
+ { 3696, 0x0808 }, { 3698, 0x4000 }, { 3699, 0x0084 }, { 3701, 0x2001 },
+ { 3703, 0x8400 }, { 3705, 0x1010 }, { 3707, 0x42cd }, { 3714, 0x01c7 },
+ /* 0x7500 */
+ { 3720, 0x7038 }, { 3726, 0xd52a }, { 3734, 0x1968 }, { 3740, 0x1d8f },
+ { 3749, 0xbe50 }, { 3757, 0x3e12 }, { 3764, 0x2ef5 }, { 3774, 0x81d9 },
+ { 3781, 0xcec4 }, { 3789, 0x2412 }, { 3793, 0x0828 }, { 3796, 0x732e },
+ { 3805, 0x24ac }, { 3811, 0x4b34 }, { 3818, 0x020c }, { 3821, 0xd41d },
+ /* 0x7600 */
+ { 3829, 0x2a02 }, { 3833, 0x8000 }, { 3834, 0x0097 }, { 3839, 0x0811 },
+ { 3842, 0x11c4 }, { 3847, 0x1144 }, { 3851, 0x1786 }, { 3858, 0x7d45 },
+ { 3867, 0x49d9 }, { 3875, 0x0649 }, { 3880, 0x4000 }, { 3881, 0x8791 },
+ { 3888, 0x254c }, { 3894, 0xd8c4 }, { 3901, 0x44ba }, { 3908, 0x4914 },
+ /* 0x7700 */
+ { 3913, 0x1b92 }, { 3920, 0xc800 }, { 3923, 0x0271 }, { 3928, 0x1580 },
+ { 3932, 0x0081 }, { 3934, 0x0c00 }, { 3936, 0x096a }, { 3942, 0xc200 },
+ { 3945, 0x4800 }, { 3947, 0x4002 }, { 3949, 0x3021 }, { 3953, 0xba49 },
+ { 3961, 0x2080 }, { 3963, 0x1c80 }, { 3967, 0xe2ac }, { 3975, 0x1008 },
+ /* 0x7800 */
+ { 3977, 0x1004 }, { 3979, 0x0034 }, { 3982, 0x00e1 }, { 3986, 0x8414 },
+ { 3990, 0x0020 }, { 3991, 0x2000 }, { 3992, 0x9800 }, { 3995, 0x1014 },
+ { 3998, 0x70c2 }, { 4004, 0x04aa }, { 4009, 0x8688 }, { 4014, 0x5420 },
+ { 4018, 0x0c62 }, { 4023, 0x0413 }, { 4027, 0x9180 }, { 4031, 0x2010 },
+ /* 0x7900 */
+ { 4033, 0x4082 }, { 4036, 0x0206 }, { 4039, 0x1c40 }, { 4043, 0x5400 },
+ { 4046, 0x0383 }, { 4051, 0xe4e9 }, { 4060, 0x2125 }, { 4065, 0x8480 },
+ { 4068, 0xe433 }, { 4076, 0x2000 }, { 4077, 0x44c0 }, { 4081, 0xe609 },
+ { 4088, 0x0a03 }, { 4092, 0x8126 }, { 4097, 0x12da }, { 4104, 0x0801 },
+ /* 0x7a00 */
+ { 4106, 0x6901 }, { 4111, 0x9790 }, { 4118, 0x4001 }, { 4120, 0xf886 },
+ { 4128, 0xe24d }, { 4136, 0x0081 }, { 4138, 0x0a0e }, { 4143, 0xa651 },
+ { 4150, 0x011a }, { 4154, 0x81ec }, { 4161, 0xc600 }, { 4165, 0x8441 },
+ { 4169, 0xadb8 }, { 4178, 0xb62c }, { 4186, 0xa46f }, { 4195, 0x8741 },
+ /* 0x7b00 */
+ { 4201, 0x8d54 }, { 4208, 0x4b02 }, { 4213, 0x1161 }, { 4218, 0x0268 },
+ { 4222, 0xbb60 }, { 4230, 0x2057 }, { 4236, 0x50a0 }, { 4240, 0x0433 },
+ { 4245, 0xa8c0 }, { 4250, 0xb7b4 }, { 4260, 0x2402 }, { 4263, 0x0112 },
+ { 4266, 0x9ad3 }, { 4275, 0x2000 }, { 4276, 0x2271 }, { 4282, 0x00c8 },
+ /* 0x7c00 */
+ { 4285, 0x2081 }, { 4288, 0x809e }, { 4294, 0x0c8a }, { 4299, 0xe180 },
+ { 4304, 0xb009 }, { 4309, 0x8151 }, { 4314, 0x1031 }, { 4318, 0x4028 },
+ { 4321, 0x2a0e }, { 4327, 0x89a5 }, { 4334, 0x69b6 }, { 4343, 0x620e },
+ { 4349, 0x4425 }, { 4354, 0xd144 }, { 4360, 0x8085 }, { 4364, 0x4d54 },
+ /* 0x7d00 */
+ { 4371, 0x2c75 }, { 4379, 0x1fb1 }, { 4388, 0xd807 }, { 4395, 0x862d },
+ { 4402, 0xd87c }, { 4411, 0x4841 }, { 4415, 0x414e }, { 4421, 0x226e },
+ { 4428, 0x8200 }, { 4430, 0x9e08 }, { 4436, 0xf80c }, { 4443, 0xed37 },
+ { 4454, 0x8c80 }, { 4458, 0x7526 }, { 4466, 0x9313 }, { 4473, 0x0814 },
+ /* 0x7e00 */
+ { 4476, 0x0e32 }, { 4482, 0xc804 }, { 4486, 0x484e }, { 4492, 0x6ea6 },
+ { 4501, 0x2c4a }, { 4507, 0x6670 }, { 4514, 0x26c0 }, { 4519, 0xba01 },
+ { 4525, 0xd30c }, { 4532, 0x185d }, { 4539, 0x0000 }, { 4539, 0x0000 },
+ { 4539, 0x0000 }, { 4539, 0x0000 }, { 4539, 0x0000 }, { 4539, 0x0000 },
+ /* 0x7f00 */
+ { 4539, 0x0000 }, { 4539, 0x0000 }, { 4539, 0x0000 }, { 4539, 0x0540 },
+ { 4542, 0x7020 }, { 4546, 0x8133 }, { 4552, 0x4f81 }, { 4559, 0x03a5 },
+ { 4565, 0x55ec }, { 4574, 0x6410 }, { 4578, 0xc318 }, { 4584, 0x2344 },
+ { 4589, 0x1462 }, { 4594, 0x0034 }, { 4597, 0x0a43 }, { 4602, 0x1a09 },
+ /* 0x8000 */
+ { 4607, 0x187b }, { 4615, 0x13a5 }, { 4622, 0x0102 }, { 4624, 0xa848 },
+ { 4629, 0x0440 }, { 4631, 0xc544 }, { 4637, 0x8106 }, { 4641, 0xe2dd },
+ { 4651, 0x1af0 }, { 4658, 0x2d48 }, { 4664, 0xb626 }, { 4672, 0x0416 },
+ { 4676, 0x5058 }, { 4681, 0x6e40 }, { 4687, 0x8032 }, { 4691, 0x3112 },
+ /* 0x8100 */
+ { 4696, 0x07e4 }, { 4703, 0x0c00 }, { 4705, 0x8208 }, { 4708, 0x420a },
+ { 4712, 0x4840 }, { 4715, 0x803b }, { 4721, 0x4860 }, { 4725, 0x8713 },
+ { 4732, 0x850d }, { 4738, 0x3428 }, { 4743, 0x0319 }, { 4748, 0xe529 },
+ { 4756, 0x2345 }, { 4762, 0x870a }, { 4768, 0x25a9 }, { 4775, 0x5c18 },
+ /* 0x8200 */
+ { 4781, 0x77a6 }, { 4791, 0xd9c5 }, { 4800, 0x5e00 }, { 4805, 0x03e8 },
+ { 4811, 0x0081 }, { 4813, 0xa700 }, { 4818, 0xcd54 }, { 4826, 0x41c6 },
+ { 4832, 0x2800 }, { 4834, 0xa204 }, { 4838, 0xb860 }, { 4844, 0x2b0a },
+ { 4850, 0x0020 }, { 4851, 0xda9e }, { 4861, 0x08ea }, { 4867, 0x0e1a },
+ /* 0x8300 */
+ { 4873, 0x427c }, { 4880, 0x11c0 }, { 4884, 0x8908 }, { 4888, 0x0376 },
+ { 4895, 0x8621 }, { 4900, 0x0105 }, { 4903, 0x0000 }, { 4903, 0x18a8 },
+ { 4908, 0x46a0 }, { 4913, 0xc448 }, { 4918, 0x0d05 }, { 4923, 0x2022 },
+ { 4926, 0x5422 }, { 4931, 0x9148 }, { 4936, 0x8a01 }, { 4940, 0x2897 },
+ /* 0x8400 */
+ { 4947, 0x7898 }, { 4954, 0x0008 }, { 4955, 0x1605 }, { 4960, 0x3122 },
+ { 4965, 0x4240 }, { 4968, 0x0880 }, { 4970, 0xfa4e }, { 4980, 0x06a2 },
+ { 4985, 0x0814 }, { 4988, 0x9211 }, { 4993, 0x2002 }, { 4995, 0x9b04 },
+ { 5001, 0x2e52 }, { 5008, 0x0643 }, { 5013, 0x5000 }, { 5015, 0x9010 },
+ /* 0x8500 */
+ { 5018, 0x0041 }, { 5020, 0x85ba }, { 5028, 0x3042 }, { 5032, 0x2020 },
+ { 5034, 0x4f0b }, { 5042, 0x05a0 }, { 5046, 0x2708 }, { 5051, 0x4080 },
+ { 5053, 0x0591 }, { 5058, 0x1a93 }, { 5065, 0xdf50 }, { 5074, 0x0600 },
+ { 5076, 0xa202 }, { 5080, 0x3021 }, { 5084, 0x0630 }, { 5088, 0x4e80 },
+ /* 0x8600 */
+ { 5093, 0x0cc4 }, { 5098, 0x04c8 }, { 5102, 0xa004 }, { 5105, 0x8001 },
+ { 5107, 0x6000 }, { 5109, 0xd431 }, { 5116, 0x0880 }, { 5118, 0x0a02 },
+ { 5121, 0x1c00 }, { 5124, 0x0028 }, { 5126, 0x8e18 }, { 5132, 0x0041 },
+ { 5134, 0x6ad0 }, { 5141, 0xca10 }, { 5146, 0xf210 }, { 5152, 0x4b00 },
+ /* 0x8700 */
+ { 5156, 0x274d }, { 5164, 0x1506 }, { 5169, 0x0220 }, { 5171, 0x8890 },
+ { 5175, 0x5a00 }, { 5179, 0x82a8 }, { 5184, 0x4549 }, { 5190, 0x8150 },
+ { 5194, 0x2004 }, { 5196, 0x8000 }, { 5197, 0x8804 }, { 5200, 0x2c08 },
+ { 5204, 0x08d1 }, { 5209, 0x0005 }, { 5211, 0x8001 }, { 5213, 0x4ac4 },
+ /* 0x8800 */
+ { 5219, 0xe020 }, { 5223, 0x0062 }, { 5226, 0x008e }, { 5230, 0x0a42 },
+ { 5234, 0x3055 }, { 5240, 0x6a8c }, { 5247, 0x090e }, { 5252, 0xe0a5 },
+ { 5259, 0x2906 }, { 5264, 0x42c4 }, { 5269, 0x4814 }, { 5273, 0x80b3 },
+ { 5279, 0x803e }, { 5285, 0xb330 }, { 5292, 0x0102 }, { 5294, 0x731c },
+ /* 0x8900 */
+ { 5302, 0x1494 }, { 5307, 0x600d }, { 5312, 0x0c20 }, { 5315, 0x0940 },
+ { 5318, 0x301a }, { 5323, 0xc040 }, { 5326, 0xa451 }, { 5332, 0xc094 },
+ { 5337, 0x8dca }, { 5345, 0x05c8 }, { 5350, 0x96c2 }, { 5357, 0xa40c },
+ { 5362, 0x0001 }, { 5363, 0x3404 }, { 5367, 0x00c8 }, { 5370, 0x0110 },
+ /* 0x8a00 */
+ { 5372, 0x550d }, { 5379, 0xa9c9 }, { 5387, 0x2428 }, { 5391, 0x1c5a },
+ { 5398, 0x0142 }, { 5401, 0x4837 }, { 5408, 0x7a4d }, { 5417, 0x100f },
+ { 5422, 0x32b4 }, { 5429, 0x452a }, { 5435, 0x317b }, { 5444, 0x9205 },
+ { 5449, 0xb894 }, { 5456, 0x5c44 }, { 5462, 0x68d7 }, { 5471, 0x458a },
+ /* 0x8b00 */
+ { 5477, 0x5097 }, { 5484, 0x2ed1 }, { 5492, 0x1943 }, { 5498, 0x4208 },
+ { 5501, 0xd202 }, { 5506, 0x9d40 }, { 5512, 0x9840 }, { 5516, 0x2097 },
+ { 5522, 0x5409 }, { 5527, 0x064d }, { 5533, 0x0000 }, { 5533, 0x0000 },
+ { 5533, 0x0000 }, { 5533, 0x0000 }, { 5533, 0x0000 }, { 5533, 0x0000 },
+ /* 0x8c00 */
+ { 5533, 0x0000 }, { 5533, 0x0000 }, { 5533, 0x0000 }, { 5533, 0x8480 },
+ { 5536, 0x5542 }, { 5542, 0x0421 }, { 5545, 0x1c06 }, { 5550, 0x1700 },
+ { 5554, 0x7624 }, { 5561, 0x6110 }, { 5565, 0xff87 }, { 5577, 0xb9dd },
+ { 5588, 0x659f }, { 5598, 0x5c0a }, { 5604, 0x245d }, { 5611, 0x3c00 },
+ /* 0x8d00 */
+ { 5615, 0xadb0 }, { 5623, 0x0059 }, { 5627, 0x0000 }, { 5627, 0x0000 },
+ { 5627, 0x0000 }, { 5627, 0x0000 }, { 5627, 0x28d0 }, { 5632, 0x009b },
+ { 5637, 0x0422 }, { 5640, 0x0200 }, { 5641, 0x0108 }, { 5643, 0x4408 },
+ { 5646, 0x9804 }, { 5650, 0xac40 }, { 5655, 0x8d0a }, { 5661, 0x9028 },
+ /* 0x8e00 */
+ { 5665, 0x8700 }, { 5669, 0xe001 }, { 5673, 0x0400 }, { 5674, 0x0031 },
+ { 5677, 0x1794 }, { 5684, 0x8221 }, { 5688, 0x0019 }, { 5691, 0x1054 },
+ { 5695, 0x2cb2 }, { 5702, 0x021a }, { 5706, 0x9c02 }, { 5711, 0x4003 },
+ { 5714, 0x3d60 }, { 5721, 0x8804 }, { 5724, 0x080c }, { 5727, 0x7900 },
+ /* 0x8f00 */
+ { 5732, 0x1628 }, { 5737, 0xba3c }, { 5746, 0x8640 }, { 5750, 0xcb08 },
+ { 5756, 0x7274 }, { 5764, 0x9080 }, { 5767, 0x001e }, { 5771, 0x0000 },
+ { 5771, 0x0000 }, { 5771, 0xd800 }, { 5775, 0xe188 }, { 5781, 0x9c87 },
+ { 5789, 0x4034 }, { 5793, 0x0412 }, { 5796, 0xae64 }, { 5804, 0x2791 },
+ /* 0x9000 */
+ { 5811, 0xe86b }, { 5820, 0xe6fb }, { 5832, 0x408f }, { 5838, 0x5366 },
+ { 5846, 0xeea6 }, { 5856, 0x537f }, { 5867, 0xe32b }, { 5876, 0xb5e4 },
+ { 5885, 0x869f }, { 5894, 0x0002 }, { 5895, 0x8548 }, { 5900, 0x0122 },
+ { 5903, 0x4402 }, { 5906, 0x0800 }, { 5907, 0x2116 }, { 5912, 0x20a0 },
+ /* 0x9100 */
+ { 5915, 0x0004 }, { 5916, 0x0204 }, { 5918, 0x2000 }, { 5919, 0x0005 },
+ { 5921, 0x7e00 }, { 5927, 0x0154 }, { 5931, 0x162c }, { 5937, 0x01ac },
+ { 5942, 0x2a84 }, { 5947, 0x1085 }, { 5951, 0x8c14 }, { 5956, 0x0530 },
+ { 5960, 0xfbc3 }, { 5971, 0xb943 }, { 5979, 0x00ca }, { 5983, 0x9060 },
+ /* 0x9200 */
+ { 5987, 0x6000 }, { 5989, 0x4032 }, { 5993, 0x1200 }, { 5995, 0x8090 },
+ { 5998, 0x0b30 }, { 6003, 0x4c81 }, { 6008, 0x0054 }, { 6011, 0x4002 },
+ { 6013, 0x0029 }, { 6016, 0x1d6a }, { 6024, 0x2000 }, { 6025, 0x0280 },
+ { 6027, 0x8000 }, { 6028, 0x0004 }, { 6029, 0x2610 }, { 6033, 0x150c },
+ /* 0x9300 */
+ { 6038, 0x8040 }, { 6040, 0x0701 }, { 6044, 0xd94d }, { 6053, 0x0c24 },
+ { 6057, 0x2810 }, { 6060, 0x1850 }, { 6064, 0x5001 }, { 6067, 0x5020 },
+ { 6070, 0x1000 }, { 6071, 0x04d0 }, { 6075, 0x7080 }, { 6079, 0x0201 },
+ { 6081, 0x0108 }, { 6083, 0x21c3 }, { 6089, 0x0132 }, { 6093, 0x0000 },
+ /* 0x9400 */
+ { 6093, 0x0088 }, { 6095, 0x0719 }, { 6101, 0x0802 }, { 6103, 0x0560 },
+ { 6107, 0x0012 }, { 6109, 0x4c0e }, { 6115, 0x0405 }, { 6118, 0xf0a1 },
+ { 6125, 0x0002 }, { 6126, 0x0000 }, { 6126, 0x0000 }, { 6126, 0x0000 },
+ { 6126, 0x0000 }, { 6126, 0x0000 }, { 6126, 0x0000 }, { 6126, 0x0000 },
+ /* 0x9500 */
+ { 6126, 0x0000 }, { 6126, 0x0000 }, { 6126, 0x0000 }, { 6126, 0x0000 },
+ { 6126, 0x0000 }, { 6126, 0x0000 }, { 6126, 0x0000 }, { 6126, 0x0080 },
+ { 6127, 0x8e8d }, { 6135, 0x035a }, { 6141, 0x21bd }, { 6149, 0x5a04 },
+ { 6154, 0x3488 }, { 6159, 0x1170 }, { 6164, 0x0026 }, { 6167, 0x0000 },
+ /* 0x9600 */
+ { 6167, 0x0000 }, { 6167, 0x1000 }, { 6168, 0xc502 }, { 6173, 0x8804 },
+ { 6176, 0xb815 }, { 6183, 0xf801 }, { 6189, 0x147c }, { 6196, 0x25ed },
+ { 6205, 0xed60 }, { 6213, 0x1bb0 }, { 6220, 0x0589 }, { 6225, 0x1bd7 },
+ { 6235, 0x7af3 }, { 6246, 0x1a62 }, { 6252, 0x0d0c }, { 6257, 0x0ac5 },
+ /* 0x9700 */
+ { 6263, 0xe5d1 }, { 6272, 0x524a }, { 6278, 0x0490 }, { 6281, 0x6305 },
+ { 6287, 0x0354 }, { 6292, 0x5244 }, { 6297, 0x2b57 }, { 6306, 0x1612 },
+ { 6311, 0xa872 }, { 6318, 0x1101 }, { 6321, 0x2949 }, { 6327, 0x0018 },
+ { 6329, 0x0948 }, { 6333, 0x1008 }, { 6335, 0x6000 }, { 6337, 0x886c },
+ /* 0x9800 */
+ { 6343, 0x916e }, { 6351, 0x058f }, { 6358, 0x3012 }, { 6362, 0x3990 },
+ { 6368, 0xf840 }, { 6374, 0x4930 }, { 6379, 0x8880 }, { 6382, 0x001b },
+ { 6386, 0x0000 }, { 6386, 0x0000 }, { 6386, 0x8500 }, { 6389, 0x0042 },
+ { 6391, 0x0058 }, { 6394, 0x9800 }, { 6397, 0xea04 }, { 6403, 0x7014 },
+ /* 0x9900 */
+ { 6408, 0x1628 }, { 6413, 0x611d }, { 6420, 0x5113 }, { 6426, 0x6000 },
+ { 6428, 0x1a24 }, { 6433, 0x00a7 }, { 6438, 0x0000 }, { 6438, 0x0000 },
+ { 6438, 0x0000 }, { 6438, 0x03c0 }, { 6442, 0x7120 }, { 6447, 0x1018 },
+ { 6450, 0x0172 }, { 6455, 0xa927 }, { 6463, 0x6004 }, { 6466, 0x8906 },
+ /* 0x9a00 */
+ { 6471, 0xc022 }, { 6475, 0x020c }, { 6478, 0x0900 }, { 6480, 0x4081 },
+ { 6483, 0x202d }, { 6488, 0x8ca0 }, { 6493, 0x0e34 }, { 6499, 0x0000 },
+ { 6499, 0x0000 }, { 6499, 0x0000 }, { 6499, 0x2100 }, { 6501, 0x1101 },
+ { 6504, 0x8011 }, { 6507, 0xc11a }, { 6513, 0xec4c }, { 6521, 0x0892 },
+ /* 0x9b00 */
+ { 6525, 0x0040 }, { 6526, 0x8500 }, { 6529, 0xc7ac }, { 6538, 0x1806 },
+ { 6542, 0xe03e }, { 6550, 0x0512 }, { 6554, 0x8000 }, { 6555, 0x0010 },
+ { 6556, 0x4008 }, { 6558, 0x80ce }, { 6564, 0x6d01 }, { 6570, 0x0210 },
+ { 6572, 0x8641 }, { 6577, 0x0856 }, { 6582, 0x011e }, { 6587, 0x0027 },
+ /* 0x9c00 */
+ { 6591, 0x3750 }, { 6598, 0x083d }, { 6604, 0xe032 }, { 6610, 0x4e05 },
+ { 6616, 0x01c0 }, { 6619, 0x0484 }, { 6622, 0x0081 }, { 6624, 0x0140 },
+ { 6626, 0x0000 }, { 6626, 0x0000 }, { 6626, 0x0000 }, { 6626, 0x0000 },
+ { 6626, 0x0000 }, { 6626, 0x0000 }, { 6626, 0x1aa0 }, { 6631, 0x0059 },
+ /* 0x9d00 */
+ { 6635, 0x43c8 }, { 6641, 0x8824 }, { 6645, 0x1d48 }, { 6651, 0xc800 },
+ { 6654, 0x0152 }, { 6658, 0x7203 }, { 6664, 0x9013 }, { 6669, 0x0404 },
+ { 6671, 0x8280 }, { 6674, 0x0400 }, { 6675, 0x8a10 }, { 6679, 0x0d14 },
+ { 6684, 0x8056 }, { 6689, 0x0208 }, { 6691, 0xa040 }, { 6694, 0x2704 },
+ /* 0x9e00 */
+ { 6699, 0x0000 }, { 6699, 0x4c00 }, { 6702, 0x0000 }, { 6702, 0x0000 },
+ { 6702, 0x0000 }, { 6702, 0x0000 }, { 6702, 0x0000 }, { 6702, 0xa320 },
+ { 6707, 0x1902 }, { 6711, 0xa0ae }, { 6718, 0x2660 }, { 6723, 0xdf00 },
+ { 6730, 0xf010 }, { 6735, 0x7b15 }, { 6744, 0x8121 }, { 6748, 0x3ad0 },
+ /* 0x9f00 */
+ { 6755, 0x4180 }, { 6758, 0x0028 }, { 6760, 0x1003 }, { 6763, 0x4800 },
+ { 6765, 0xcc00 }, { 6769, 0x8014 }, { 6772, 0x14cf }, { 6780, 0x00c4 },
+ { 6783, 0x2000 }, { 6784, 0x3020 }, { 6787, 0x0001 },
+};
+static const Summary16 jisx0208_uni2indx_pageff[15] = {
+ /* 0xff00 */
+ { 6788, 0xdf7a }, { 6800, 0xffff }, { 6816, 0xffff }, { 6832, 0xefff },
+ { 6847, 0xffff }, { 6863, 0x3fff }, { 6877, 0x0000 }, { 6877, 0x0000 },
+ { 6877, 0x0000 }, { 6877, 0x0000 }, { 6877, 0x0000 }, { 6877, 0x0000 },
+ { 6877, 0x0000 }, { 6877, 0x0000 }, { 6877, 0x0028 },
+};
+
+static int
+jisx0208_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ if (n >= 2) {
+ const Summary16 *summary = NULL;
+ if (wc < 0x0100)
+ summary = &jisx0208_uni2indx_page00[(wc>>4)];
+ else if (wc >= 0x0300 && wc < 0x0460)
+ summary = &jisx0208_uni2indx_page03[(wc>>4)-0x030];
+ else if (wc >= 0x2000 && wc < 0x2320)
+ summary = &jisx0208_uni2indx_page20[(wc>>4)-0x200];
+ else if (wc >= 0x2500 && wc < 0x2670)
+ summary = &jisx0208_uni2indx_page25[(wc>>4)-0x250];
+ else if (wc >= 0x3000 && wc < 0x3100)
+ summary = &jisx0208_uni2indx_page30[(wc>>4)-0x300];
+ else if (wc >= 0x4e00 && wc < 0x9fb0)
+ summary = &jisx0208_uni2indx_page4e[(wc>>4)-0x4e0];
+ else if (wc >= 0xff00 && wc < 0xfff0)
+ summary = &jisx0208_uni2indx_pageff[(wc>>4)-0xff0];
+ if (summary) {
+ unsigned short used = summary->used;
+ unsigned int i = wc & 0x0f;
+ if (used & ((unsigned short) 1 << i)) {
+ unsigned short c;
+ /* Keep in `used' only the bits 0..i-1. */
+ used &= ((unsigned short) 1 << i) - 1;
+ /* Add `summary->indx' and the number of bits set in `used'. */
+ used = (used & 0x5555) + ((used & 0xaaaa) >> 1);
+ used = (used & 0x3333) + ((used & 0xcccc) >> 2);
+ used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4);
+ used = (used & 0x00ff) + (used >> 8);
+ c = jisx0208_2charset[summary->indx + used];
+ r[0] = (c >> 8); r[1] = (c & 0xff);
+ return 2;
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOSMALL;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/jisx0212.h b/nx-X11/lib/X11/lcUniConv/jisx0212.h
new file mode 100644
index 000000000..6c89ee638
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/jisx0212.h
@@ -0,0 +1,2164 @@
+/* $XFree86: xc/lib/X11/lcUniConv/jisx0212.h,v 1.4tsi Exp $ */
+
+/*
+ * JISX0212.1990-0
+ */
+
+static const unsigned short jisx0212_2uni_page22[81] = {
+ /* 0x22 */
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x02d8, 0x02c7,
+ 0x00b8, 0x02d9, 0x02dd, 0x00af, 0x02db, 0x02da, 0x007e, 0x0384,
+ 0x0385, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0x00a1, 0x00a6, 0x00bf, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0x00ba, 0x00aa, 0x00a9, 0x00ae, 0x2122, 0x00a4,
+ 0x2116,
+};
+static const unsigned short jisx0212_2uni_page26[188] = {
+ /* 0x26 */
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0x0386, 0x0388, 0x0389, 0x038a, 0x03aa, 0xfffd, 0x038c, 0xfffd,
+ 0x038e, 0x03ab, 0xfffd, 0x038f, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0x03ac, 0x03ad, 0x03ae, 0x03af, 0x03ca, 0x0390, 0x03cc, 0x03c2,
+ 0x03cd, 0x03cb, 0x03b0, 0x03ce, 0xfffd, 0xfffd,
+ /* 0x27 */
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407, 0x0408,
+ 0x0409, 0x040a, 0x040b, 0x040c, 0x040e, 0x040f, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457, 0x0458,
+ 0x0459, 0x045a, 0x045b, 0x045c, 0x045e, 0x045f,
+};
+static const unsigned short jisx0212_2uni_page29[275] = {
+ /* 0x29 */
+ 0x00c6, 0x0110, 0xfffd, 0x0126, 0xfffd, 0x0132, 0xfffd, 0x0141,
+ 0x013f, 0xfffd, 0x014a, 0x00d8, 0x0152, 0xfffd, 0x0166, 0x00de,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0x00e6, 0x0111, 0x00f0, 0x0127, 0x0131, 0x0133, 0x0138, 0x0142,
+ 0x0140, 0x0149, 0x014b, 0x00f8, 0x0153, 0x00df, 0x0167, 0x00fe,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x2a */
+ 0x00c1, 0x00c0, 0x00c4, 0x00c2, 0x0102, 0x01cd, 0x0100, 0x0104,
+ 0x00c5, 0x00c3, 0x0106, 0x0108, 0x010c, 0x00c7, 0x010a, 0x010e,
+ 0x00c9, 0x00c8, 0x00cb, 0x00ca, 0x011a, 0x0116, 0x0112, 0x0118,
+ 0xfffd, 0x011c, 0x011e, 0x0122, 0x0120, 0x0124, 0x00cd, 0x00cc,
+ 0x00cf, 0x00ce, 0x01cf, 0x0130, 0x012a, 0x012e, 0x0128, 0x0134,
+ 0x0136, 0x0139, 0x013d, 0x013b, 0x0143, 0x0147, 0x0145, 0x00d1,
+ 0x00d3, 0x00d2, 0x00d6, 0x00d4, 0x01d1, 0x0150, 0x014c, 0x00d5,
+ 0x0154, 0x0158, 0x0156, 0x015a, 0x015c, 0x0160, 0x015e, 0x0164,
+ 0x0162, 0x00da, 0x00d9, 0x00dc, 0x00db, 0x016c, 0x01d3, 0x0170,
+ 0x016a, 0x0172, 0x016e, 0x0168, 0x01d7, 0x01db, 0x01d9, 0x01d5,
+ 0x0174, 0x00dd, 0x0178, 0x0176, 0x0179, 0x017d, 0x017b, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x2b */
+ 0x00e1, 0x00e0, 0x00e4, 0x00e2, 0x0103, 0x01ce, 0x0101, 0x0105,
+ 0x00e5, 0x00e3, 0x0107, 0x0109, 0x010d, 0x00e7, 0x010b, 0x010f,
+ 0x00e9, 0x00e8, 0x00eb, 0x00ea, 0x011b, 0x0117, 0x0113, 0x0119,
+ 0x01f5, 0x011d, 0x011f, 0xfffd, 0x0121, 0x0125, 0x00ed, 0x00ec,
+ 0x00ef, 0x00ee, 0x01d0, 0xfffd, 0x012b, 0x012f, 0x0129, 0x0135,
+ 0x0137, 0x013a, 0x013e, 0x013c, 0x0144, 0x0148, 0x0146, 0x00f1,
+ 0x00f3, 0x00f2, 0x00f6, 0x00f4, 0x01d2, 0x0151, 0x014d, 0x00f5,
+ 0x0155, 0x0159, 0x0157, 0x015b, 0x015d, 0x0161, 0x015f, 0x0165,
+ 0x0163, 0x00fa, 0x00f9, 0x00fc, 0x00fb, 0x016d, 0x01d4, 0x0171,
+ 0x016b, 0x0173, 0x016f, 0x0169, 0x01d8, 0x01dc, 0x01da, 0x01d6,
+ 0x0175, 0x00fd, 0x00ff, 0x0177, 0x017a, 0x017e, 0x017c,
+};
+static const unsigned short jisx0212_2uni_page30[5801] = {
+ /* 0x30 */
+ 0x4e02, 0x4e04, 0x4e05, 0x4e0c, 0x4e12, 0x4e1f, 0x4e23, 0x4e24,
+ 0x4e28, 0x4e2b, 0x4e2e, 0x4e2f, 0x4e30, 0x4e35, 0x4e40, 0x4e41,
+ 0x4e44, 0x4e47, 0x4e51, 0x4e5a, 0x4e5c, 0x4e63, 0x4e68, 0x4e69,
+ 0x4e74, 0x4e75, 0x4e79, 0x4e7f, 0x4e8d, 0x4e96, 0x4e97, 0x4e9d,
+ 0x4eaf, 0x4eb9, 0x4ec3, 0x4ed0, 0x4eda, 0x4edb, 0x4ee0, 0x4ee1,
+ 0x4ee2, 0x4ee8, 0x4eef, 0x4ef1, 0x4ef3, 0x4ef5, 0x4efd, 0x4efe,
+ 0x4eff, 0x4f00, 0x4f02, 0x4f03, 0x4f08, 0x4f0b, 0x4f0c, 0x4f12,
+ 0x4f15, 0x4f16, 0x4f17, 0x4f19, 0x4f2e, 0x4f31, 0x4f60, 0x4f33,
+ 0x4f35, 0x4f37, 0x4f39, 0x4f3b, 0x4f3e, 0x4f40, 0x4f42, 0x4f48,
+ 0x4f49, 0x4f4b, 0x4f4c, 0x4f52, 0x4f54, 0x4f56, 0x4f58, 0x4f5f,
+ 0x4f63, 0x4f6a, 0x4f6c, 0x4f6e, 0x4f71, 0x4f77, 0x4f78, 0x4f79,
+ 0x4f7a, 0x4f7d, 0x4f7e, 0x4f81, 0x4f82, 0x4f84,
+ /* 0x31 */
+ 0x4f85, 0x4f89, 0x4f8a, 0x4f8c, 0x4f8e, 0x4f90, 0x4f92, 0x4f93,
+ 0x4f94, 0x4f97, 0x4f99, 0x4f9a, 0x4f9e, 0x4f9f, 0x4fb2, 0x4fb7,
+ 0x4fb9, 0x4fbb, 0x4fbc, 0x4fbd, 0x4fbe, 0x4fc0, 0x4fc1, 0x4fc5,
+ 0x4fc6, 0x4fc8, 0x4fc9, 0x4fcb, 0x4fcc, 0x4fcd, 0x4fcf, 0x4fd2,
+ 0x4fdc, 0x4fe0, 0x4fe2, 0x4ff0, 0x4ff2, 0x4ffc, 0x4ffd, 0x4fff,
+ 0x5000, 0x5001, 0x5004, 0x5007, 0x500a, 0x500c, 0x500e, 0x5010,
+ 0x5013, 0x5017, 0x5018, 0x501b, 0x501c, 0x501d, 0x501e, 0x5022,
+ 0x5027, 0x502e, 0x5030, 0x5032, 0x5033, 0x5035, 0x5040, 0x5041,
+ 0x5042, 0x5045, 0x5046, 0x504a, 0x504c, 0x504e, 0x5051, 0x5052,
+ 0x5053, 0x5057, 0x5059, 0x505f, 0x5060, 0x5062, 0x5063, 0x5066,
+ 0x5067, 0x506a, 0x506d, 0x5070, 0x5071, 0x503b, 0x5081, 0x5083,
+ 0x5084, 0x5086, 0x508a, 0x508e, 0x508f, 0x5090,
+ /* 0x32 */
+ 0x5092, 0x5093, 0x5094, 0x5096, 0x509b, 0x509c, 0x509e, 0x509f,
+ 0x50a0, 0x50a1, 0x50a2, 0x50aa, 0x50af, 0x50b0, 0x50b9, 0x50ba,
+ 0x50bd, 0x50c0, 0x50c3, 0x50c4, 0x50c7, 0x50cc, 0x50ce, 0x50d0,
+ 0x50d3, 0x50d4, 0x50d8, 0x50dc, 0x50dd, 0x50df, 0x50e2, 0x50e4,
+ 0x50e6, 0x50e8, 0x50e9, 0x50ef, 0x50f1, 0x50f6, 0x50fa, 0x50fe,
+ 0x5103, 0x5106, 0x5107, 0x5108, 0x510b, 0x510c, 0x510d, 0x510e,
+ 0x50f2, 0x5110, 0x5117, 0x5119, 0x511b, 0x511c, 0x511d, 0x511e,
+ 0x5123, 0x5127, 0x5128, 0x512c, 0x512d, 0x512f, 0x5131, 0x5133,
+ 0x5134, 0x5135, 0x5138, 0x5139, 0x5142, 0x514a, 0x514f, 0x5153,
+ 0x5155, 0x5157, 0x5158, 0x515f, 0x5164, 0x5166, 0x517e, 0x5183,
+ 0x5184, 0x518b, 0x518e, 0x5198, 0x519d, 0x51a1, 0x51a3, 0x51ad,
+ 0x51b8, 0x51ba, 0x51bc, 0x51be, 0x51bf, 0x51c2,
+ /* 0x33 */
+ 0x51c8, 0x51cf, 0x51d1, 0x51d2, 0x51d3, 0x51d5, 0x51d8, 0x51de,
+ 0x51e2, 0x51e5, 0x51ee, 0x51f2, 0x51f3, 0x51f4, 0x51f7, 0x5201,
+ 0x5202, 0x5205, 0x5212, 0x5213, 0x5215, 0x5216, 0x5218, 0x5222,
+ 0x5228, 0x5231, 0x5232, 0x5235, 0x523c, 0x5245, 0x5249, 0x5255,
+ 0x5257, 0x5258, 0x525a, 0x525c, 0x525f, 0x5260, 0x5261, 0x5266,
+ 0x526e, 0x5277, 0x5278, 0x5279, 0x5280, 0x5282, 0x5285, 0x528a,
+ 0x528c, 0x5293, 0x5295, 0x5296, 0x5297, 0x5298, 0x529a, 0x529c,
+ 0x52a4, 0x52a5, 0x52a6, 0x52a7, 0x52af, 0x52b0, 0x52b6, 0x52b7,
+ 0x52b8, 0x52ba, 0x52bb, 0x52bd, 0x52c0, 0x52c4, 0x52c6, 0x52c8,
+ 0x52cc, 0x52cf, 0x52d1, 0x52d4, 0x52d6, 0x52db, 0x52dc, 0x52e1,
+ 0x52e5, 0x52e8, 0x52e9, 0x52ea, 0x52ec, 0x52f0, 0x52f1, 0x52f4,
+ 0x52f6, 0x52f7, 0x5300, 0x5303, 0x530a, 0x530b,
+ /* 0x34 */
+ 0x530c, 0x5311, 0x5313, 0x5318, 0x531b, 0x531c, 0x531e, 0x531f,
+ 0x5325, 0x5327, 0x5328, 0x5329, 0x532b, 0x532c, 0x532d, 0x5330,
+ 0x5332, 0x5335, 0x533c, 0x533d, 0x533e, 0x5342, 0x534c, 0x534b,
+ 0x5359, 0x535b, 0x5361, 0x5363, 0x5365, 0x536c, 0x536d, 0x5372,
+ 0x5379, 0x537e, 0x5383, 0x5387, 0x5388, 0x538e, 0x5393, 0x5394,
+ 0x5399, 0x539d, 0x53a1, 0x53a4, 0x53aa, 0x53ab, 0x53af, 0x53b2,
+ 0x53b4, 0x53b5, 0x53b7, 0x53b8, 0x53ba, 0x53bd, 0x53c0, 0x53c5,
+ 0x53cf, 0x53d2, 0x53d3, 0x53d5, 0x53da, 0x53dd, 0x53de, 0x53e0,
+ 0x53e6, 0x53e7, 0x53f5, 0x5402, 0x5413, 0x541a, 0x5421, 0x5427,
+ 0x5428, 0x542a, 0x542f, 0x5431, 0x5434, 0x5435, 0x5443, 0x5444,
+ 0x5447, 0x544d, 0x544f, 0x545e, 0x5462, 0x5464, 0x5466, 0x5467,
+ 0x5469, 0x546b, 0x546d, 0x546e, 0x5474, 0x547f,
+ /* 0x35 */
+ 0x5481, 0x5483, 0x5485, 0x5488, 0x5489, 0x548d, 0x5491, 0x5495,
+ 0x5496, 0x549c, 0x549f, 0x54a1, 0x54a6, 0x54a7, 0x54a9, 0x54aa,
+ 0x54ad, 0x54ae, 0x54b1, 0x54b7, 0x54b9, 0x54ba, 0x54bb, 0x54bf,
+ 0x54c6, 0x54ca, 0x54cd, 0x54ce, 0x54e0, 0x54ea, 0x54ec, 0x54ef,
+ 0x54f6, 0x54fc, 0x54fe, 0x54ff, 0x5500, 0x5501, 0x5505, 0x5508,
+ 0x5509, 0x550c, 0x550d, 0x550e, 0x5515, 0x552a, 0x552b, 0x5532,
+ 0x5535, 0x5536, 0x553b, 0x553c, 0x553d, 0x5541, 0x5547, 0x5549,
+ 0x554a, 0x554d, 0x5550, 0x5551, 0x5558, 0x555a, 0x555b, 0x555e,
+ 0x5560, 0x5561, 0x5564, 0x5566, 0x557f, 0x5581, 0x5582, 0x5586,
+ 0x5588, 0x558e, 0x558f, 0x5591, 0x5592, 0x5593, 0x5594, 0x5597,
+ 0x55a3, 0x55a4, 0x55ad, 0x55b2, 0x55bf, 0x55c1, 0x55c3, 0x55c6,
+ 0x55c9, 0x55cb, 0x55cc, 0x55ce, 0x55d1, 0x55d2,
+ /* 0x36 */
+ 0x55d3, 0x55d7, 0x55d8, 0x55db, 0x55de, 0x55e2, 0x55e9, 0x55f6,
+ 0x55ff, 0x5605, 0x5608, 0x560a, 0x560d, 0x560e, 0x560f, 0x5610,
+ 0x5611, 0x5612, 0x5619, 0x562c, 0x5630, 0x5633, 0x5635, 0x5637,
+ 0x5639, 0x563b, 0x563c, 0x563d, 0x563f, 0x5640, 0x5641, 0x5643,
+ 0x5644, 0x5646, 0x5649, 0x564b, 0x564d, 0x564f, 0x5654, 0x565e,
+ 0x5660, 0x5661, 0x5662, 0x5663, 0x5666, 0x5669, 0x566d, 0x566f,
+ 0x5671, 0x5672, 0x5675, 0x5684, 0x5685, 0x5688, 0x568b, 0x568c,
+ 0x5695, 0x5699, 0x569a, 0x569d, 0x569e, 0x569f, 0x56a6, 0x56a7,
+ 0x56a8, 0x56a9, 0x56ab, 0x56ac, 0x56ad, 0x56b1, 0x56b3, 0x56b7,
+ 0x56be, 0x56c5, 0x56c9, 0x56ca, 0x56cb, 0x56cf, 0x56d0, 0x56cc,
+ 0x56cd, 0x56d9, 0x56dc, 0x56dd, 0x56df, 0x56e1, 0x56e4, 0x56e5,
+ 0x56e6, 0x56e7, 0x56e8, 0x56f1, 0x56eb, 0x56ed,
+ /* 0x37 */
+ 0x56f6, 0x56f7, 0x5701, 0x5702, 0x5707, 0x570a, 0x570c, 0x5711,
+ 0x5715, 0x571a, 0x571b, 0x571d, 0x5720, 0x5722, 0x5723, 0x5724,
+ 0x5725, 0x5729, 0x572a, 0x572c, 0x572e, 0x572f, 0x5733, 0x5734,
+ 0x573d, 0x573e, 0x573f, 0x5745, 0x5746, 0x574c, 0x574d, 0x5752,
+ 0x5762, 0x5765, 0x5767, 0x5768, 0x576b, 0x576d, 0x576e, 0x576f,
+ 0x5770, 0x5771, 0x5773, 0x5774, 0x5775, 0x5777, 0x5779, 0x577a,
+ 0x577b, 0x577c, 0x577e, 0x5781, 0x5783, 0x578c, 0x5794, 0x5797,
+ 0x5799, 0x579a, 0x579c, 0x579d, 0x579e, 0x579f, 0x57a1, 0x5795,
+ 0x57a7, 0x57a8, 0x57a9, 0x57ac, 0x57b8, 0x57bd, 0x57c7, 0x57c8,
+ 0x57cc, 0x57cf, 0x57d5, 0x57dd, 0x57de, 0x57e4, 0x57e6, 0x57e7,
+ 0x57e9, 0x57ed, 0x57f0, 0x57f5, 0x57f6, 0x57f8, 0x57fd, 0x57fe,
+ 0x57ff, 0x5803, 0x5804, 0x5808, 0x5809, 0x57e1,
+ /* 0x38 */
+ 0x580c, 0x580d, 0x581b, 0x581e, 0x581f, 0x5820, 0x5826, 0x5827,
+ 0x582d, 0x5832, 0x5839, 0x583f, 0x5849, 0x584c, 0x584d, 0x584f,
+ 0x5850, 0x5855, 0x585f, 0x5861, 0x5864, 0x5867, 0x5868, 0x5878,
+ 0x587c, 0x587f, 0x5880, 0x5881, 0x5887, 0x5888, 0x5889, 0x588a,
+ 0x588c, 0x588d, 0x588f, 0x5890, 0x5894, 0x5896, 0x589d, 0x58a0,
+ 0x58a1, 0x58a2, 0x58a6, 0x58a9, 0x58b1, 0x58b2, 0x58c4, 0x58bc,
+ 0x58c2, 0x58c8, 0x58cd, 0x58ce, 0x58d0, 0x58d2, 0x58d4, 0x58d6,
+ 0x58da, 0x58dd, 0x58e1, 0x58e2, 0x58e9, 0x58f3, 0x5905, 0x5906,
+ 0x590b, 0x590c, 0x5912, 0x5913, 0x5914, 0x8641, 0x591d, 0x5921,
+ 0x5923, 0x5924, 0x5928, 0x592f, 0x5930, 0x5933, 0x5935, 0x5936,
+ 0x593f, 0x5943, 0x5946, 0x5952, 0x5953, 0x5959, 0x595b, 0x595d,
+ 0x595e, 0x595f, 0x5961, 0x5963, 0x596b, 0x596d,
+ /* 0x39 */
+ 0x596f, 0x5972, 0x5975, 0x5976, 0x5979, 0x597b, 0x597c, 0x598b,
+ 0x598c, 0x598e, 0x5992, 0x5995, 0x5997, 0x599f, 0x59a4, 0x59a7,
+ 0x59ad, 0x59ae, 0x59af, 0x59b0, 0x59b3, 0x59b7, 0x59ba, 0x59bc,
+ 0x59c1, 0x59c3, 0x59c4, 0x59c8, 0x59ca, 0x59cd, 0x59d2, 0x59dd,
+ 0x59de, 0x59df, 0x59e3, 0x59e4, 0x59e7, 0x59ee, 0x59ef, 0x59f1,
+ 0x59f2, 0x59f4, 0x59f7, 0x5a00, 0x5a04, 0x5a0c, 0x5a0d, 0x5a0e,
+ 0x5a12, 0x5a13, 0x5a1e, 0x5a23, 0x5a24, 0x5a27, 0x5a28, 0x5a2a,
+ 0x5a2d, 0x5a30, 0x5a44, 0x5a45, 0x5a47, 0x5a48, 0x5a4c, 0x5a50,
+ 0x5a55, 0x5a5e, 0x5a63, 0x5a65, 0x5a67, 0x5a6d, 0x5a77, 0x5a7a,
+ 0x5a7b, 0x5a7e, 0x5a8b, 0x5a90, 0x5a93, 0x5a96, 0x5a99, 0x5a9c,
+ 0x5a9e, 0x5a9f, 0x5aa0, 0x5aa2, 0x5aa7, 0x5aac, 0x5ab1, 0x5ab2,
+ 0x5ab3, 0x5ab5, 0x5ab8, 0x5aba, 0x5abb, 0x5abf,
+ /* 0x3a */
+ 0x5ac4, 0x5ac6, 0x5ac8, 0x5acf, 0x5ada, 0x5adc, 0x5ae0, 0x5ae5,
+ 0x5aea, 0x5aee, 0x5af5, 0x5af6, 0x5afd, 0x5b00, 0x5b01, 0x5b08,
+ 0x5b17, 0x5b34, 0x5b19, 0x5b1b, 0x5b1d, 0x5b21, 0x5b25, 0x5b2d,
+ 0x5b38, 0x5b41, 0x5b4b, 0x5b4c, 0x5b52, 0x5b56, 0x5b5e, 0x5b68,
+ 0x5b6e, 0x5b6f, 0x5b7c, 0x5b7d, 0x5b7e, 0x5b7f, 0x5b81, 0x5b84,
+ 0x5b86, 0x5b8a, 0x5b8e, 0x5b90, 0x5b91, 0x5b93, 0x5b94, 0x5b96,
+ 0x5ba8, 0x5ba9, 0x5bac, 0x5bad, 0x5baf, 0x5bb1, 0x5bb2, 0x5bb7,
+ 0x5bba, 0x5bbc, 0x5bc0, 0x5bc1, 0x5bcd, 0x5bcf, 0x5bd6, 0x5bd7,
+ 0x5bd8, 0x5bd9, 0x5bda, 0x5be0, 0x5bef, 0x5bf1, 0x5bf4, 0x5bfd,
+ 0x5c0c, 0x5c17, 0x5c1e, 0x5c1f, 0x5c23, 0x5c26, 0x5c29, 0x5c2b,
+ 0x5c2c, 0x5c2e, 0x5c30, 0x5c32, 0x5c35, 0x5c36, 0x5c59, 0x5c5a,
+ 0x5c5c, 0x5c62, 0x5c63, 0x5c67, 0x5c68, 0x5c69,
+ /* 0x3b */
+ 0x5c6d, 0x5c70, 0x5c74, 0x5c75, 0x5c7a, 0x5c7b, 0x5c7c, 0x5c7d,
+ 0x5c87, 0x5c88, 0x5c8a, 0x5c8f, 0x5c92, 0x5c9d, 0x5c9f, 0x5ca0,
+ 0x5ca2, 0x5ca3, 0x5ca6, 0x5caa, 0x5cb2, 0x5cb4, 0x5cb5, 0x5cba,
+ 0x5cc9, 0x5ccb, 0x5cd2, 0x5cdd, 0x5cd7, 0x5cee, 0x5cf1, 0x5cf2,
+ 0x5cf4, 0x5d01, 0x5d06, 0x5d0d, 0x5d12, 0x5d2b, 0x5d23, 0x5d24,
+ 0x5d26, 0x5d27, 0x5d31, 0x5d34, 0x5d39, 0x5d3d, 0x5d3f, 0x5d42,
+ 0x5d43, 0x5d46, 0x5d48, 0x5d55, 0x5d51, 0x5d59, 0x5d4a, 0x5d5f,
+ 0x5d60, 0x5d61, 0x5d62, 0x5d64, 0x5d6a, 0x5d6d, 0x5d70, 0x5d79,
+ 0x5d7a, 0x5d7e, 0x5d7f, 0x5d81, 0x5d83, 0x5d88, 0x5d8a, 0x5d92,
+ 0x5d93, 0x5d94, 0x5d95, 0x5d99, 0x5d9b, 0x5d9f, 0x5da0, 0x5da7,
+ 0x5dab, 0x5db0, 0x5db4, 0x5db8, 0x5db9, 0x5dc3, 0x5dc7, 0x5dcb,
+ 0x5dd0, 0x5dce, 0x5dd8, 0x5dd9, 0x5de0, 0x5de4,
+ /* 0x3c */
+ 0x5de9, 0x5df8, 0x5df9, 0x5e00, 0x5e07, 0x5e0d, 0x5e12, 0x5e14,
+ 0x5e15, 0x5e18, 0x5e1f, 0x5e20, 0x5e2e, 0x5e28, 0x5e32, 0x5e35,
+ 0x5e3e, 0x5e4b, 0x5e50, 0x5e49, 0x5e51, 0x5e56, 0x5e58, 0x5e5b,
+ 0x5e5c, 0x5e5e, 0x5e68, 0x5e6a, 0x5e6b, 0x5e6c, 0x5e6d, 0x5e6e,
+ 0x5e70, 0x5e80, 0x5e8b, 0x5e8e, 0x5ea2, 0x5ea4, 0x5ea5, 0x5ea8,
+ 0x5eaa, 0x5eac, 0x5eb1, 0x5eb3, 0x5ebd, 0x5ebe, 0x5ebf, 0x5ec6,
+ 0x5ecc, 0x5ecb, 0x5ece, 0x5ed1, 0x5ed2, 0x5ed4, 0x5ed5, 0x5edc,
+ 0x5ede, 0x5ee5, 0x5eeb, 0x5f02, 0x5f06, 0x5f07, 0x5f08, 0x5f0e,
+ 0x5f19, 0x5f1c, 0x5f1d, 0x5f21, 0x5f22, 0x5f23, 0x5f24, 0x5f28,
+ 0x5f2b, 0x5f2c, 0x5f2e, 0x5f30, 0x5f34, 0x5f36, 0x5f3b, 0x5f3d,
+ 0x5f3f, 0x5f40, 0x5f44, 0x5f45, 0x5f47, 0x5f4d, 0x5f50, 0x5f54,
+ 0x5f58, 0x5f5b, 0x5f60, 0x5f63, 0x5f64, 0x5f67,
+ /* 0x3d */
+ 0x5f6f, 0x5f72, 0x5f74, 0x5f75, 0x5f78, 0x5f7a, 0x5f7d, 0x5f7e,
+ 0x5f89, 0x5f8d, 0x5f8f, 0x5f96, 0x5f9c, 0x5f9d, 0x5fa2, 0x5fa7,
+ 0x5fab, 0x5fa4, 0x5fac, 0x5faf, 0x5fb0, 0x5fb1, 0x5fb8, 0x5fc4,
+ 0x5fc7, 0x5fc8, 0x5fc9, 0x5fcb, 0x5fd0, 0x5fd1, 0x5fd2, 0x5fd3,
+ 0x5fd4, 0x5fde, 0x5fe1, 0x5fe2, 0x5fe8, 0x5fe9, 0x5fea, 0x5fec,
+ 0x5fed, 0x5fee, 0x5fef, 0x5ff2, 0x5ff3, 0x5ff6, 0x5ffa, 0x5ffc,
+ 0x6007, 0x600a, 0x600d, 0x6013, 0x6014, 0x6017, 0x6018, 0x601a,
+ 0x601f, 0x6024, 0x602d, 0x6033, 0x6035, 0x6040, 0x6047, 0x6048,
+ 0x6049, 0x604c, 0x6051, 0x6054, 0x6056, 0x6057, 0x605d, 0x6061,
+ 0x6067, 0x6071, 0x607e, 0x607f, 0x6082, 0x6086, 0x6088, 0x608a,
+ 0x608e, 0x6091, 0x6093, 0x6095, 0x6098, 0x609d, 0x609e, 0x60a2,
+ 0x60a4, 0x60a5, 0x60a8, 0x60b0, 0x60b1, 0x60b7,
+ /* 0x3e */
+ 0x60bb, 0x60be, 0x60c2, 0x60c4, 0x60c8, 0x60c9, 0x60ca, 0x60cb,
+ 0x60ce, 0x60cf, 0x60d4, 0x60d5, 0x60d9, 0x60db, 0x60dd, 0x60de,
+ 0x60e2, 0x60e5, 0x60f2, 0x60f5, 0x60f8, 0x60fc, 0x60fd, 0x6102,
+ 0x6107, 0x610a, 0x610c, 0x6110, 0x6111, 0x6112, 0x6113, 0x6114,
+ 0x6116, 0x6117, 0x6119, 0x611c, 0x611e, 0x6122, 0x612a, 0x612b,
+ 0x6130, 0x6131, 0x6135, 0x6136, 0x6137, 0x6139, 0x6141, 0x6145,
+ 0x6146, 0x6149, 0x615e, 0x6160, 0x616c, 0x6172, 0x6178, 0x617b,
+ 0x617c, 0x617f, 0x6180, 0x6181, 0x6183, 0x6184, 0x618b, 0x618d,
+ 0x6192, 0x6193, 0x6197, 0x6198, 0x619c, 0x619d, 0x619f, 0x61a0,
+ 0x61a5, 0x61a8, 0x61aa, 0x61ad, 0x61b8, 0x61b9, 0x61bc, 0x61c0,
+ 0x61c1, 0x61c2, 0x61ce, 0x61cf, 0x61d5, 0x61dc, 0x61dd, 0x61de,
+ 0x61df, 0x61e1, 0x61e2, 0x61e7, 0x61e9, 0x61e5,
+ /* 0x3f */
+ 0x61ec, 0x61ed, 0x61ef, 0x6201, 0x6203, 0x6204, 0x6207, 0x6213,
+ 0x6215, 0x621c, 0x6220, 0x6222, 0x6223, 0x6227, 0x6229, 0x622b,
+ 0x6239, 0x623d, 0x6242, 0x6243, 0x6244, 0x6246, 0x624c, 0x6250,
+ 0x6251, 0x6252, 0x6254, 0x6256, 0x625a, 0x625c, 0x6264, 0x626d,
+ 0x626f, 0x6273, 0x627a, 0x627d, 0x628d, 0x628e, 0x628f, 0x6290,
+ 0x62a6, 0x62a8, 0x62b3, 0x62b6, 0x62b7, 0x62ba, 0x62be, 0x62bf,
+ 0x62c4, 0x62ce, 0x62d5, 0x62d6, 0x62da, 0x62ea, 0x62f2, 0x62f4,
+ 0x62fc, 0x62fd, 0x6303, 0x6304, 0x630a, 0x630b, 0x630d, 0x6310,
+ 0x6313, 0x6316, 0x6318, 0x6329, 0x632a, 0x632d, 0x6335, 0x6336,
+ 0x6339, 0x633c, 0x6341, 0x6342, 0x6343, 0x6344, 0x6346, 0x634a,
+ 0x634b, 0x634e, 0x6352, 0x6353, 0x6354, 0x6358, 0x635b, 0x6365,
+ 0x6366, 0x636c, 0x636d, 0x6371, 0x6374, 0x6375,
+ /* 0x40 */
+ 0x6378, 0x637c, 0x637d, 0x637f, 0x6382, 0x6384, 0x6387, 0x638a,
+ 0x6390, 0x6394, 0x6395, 0x6399, 0x639a, 0x639e, 0x63a4, 0x63a6,
+ 0x63ad, 0x63ae, 0x63af, 0x63bd, 0x63c1, 0x63c5, 0x63c8, 0x63ce,
+ 0x63d1, 0x63d3, 0x63d4, 0x63d5, 0x63dc, 0x63e0, 0x63e5, 0x63ea,
+ 0x63ec, 0x63f2, 0x63f3, 0x63f5, 0x63f8, 0x63f9, 0x6409, 0x640a,
+ 0x6410, 0x6412, 0x6414, 0x6418, 0x641e, 0x6420, 0x6422, 0x6424,
+ 0x6425, 0x6429, 0x642a, 0x642f, 0x6430, 0x6435, 0x643d, 0x643f,
+ 0x644b, 0x644f, 0x6451, 0x6452, 0x6453, 0x6454, 0x645a, 0x645b,
+ 0x645c, 0x645d, 0x645f, 0x6460, 0x6461, 0x6463, 0x646d, 0x6473,
+ 0x6474, 0x647b, 0x647d, 0x6485, 0x6487, 0x648f, 0x6490, 0x6491,
+ 0x6498, 0x6499, 0x649b, 0x649d, 0x649f, 0x64a1, 0x64a3, 0x64a6,
+ 0x64a8, 0x64ac, 0x64b3, 0x64bd, 0x64be, 0x64bf,
+ /* 0x41 */
+ 0x64c4, 0x64c9, 0x64ca, 0x64cb, 0x64cc, 0x64ce, 0x64d0, 0x64d1,
+ 0x64d5, 0x64d7, 0x64e4, 0x64e5, 0x64e9, 0x64ea, 0x64ed, 0x64f0,
+ 0x64f5, 0x64f7, 0x64fb, 0x64ff, 0x6501, 0x6504, 0x6508, 0x6509,
+ 0x650a, 0x650f, 0x6513, 0x6514, 0x6516, 0x6519, 0x651b, 0x651e,
+ 0x651f, 0x6522, 0x6526, 0x6529, 0x652e, 0x6531, 0x653a, 0x653c,
+ 0x653d, 0x6543, 0x6547, 0x6549, 0x6550, 0x6552, 0x6554, 0x655f,
+ 0x6560, 0x6567, 0x656b, 0x657a, 0x657d, 0x6581, 0x6585, 0x658a,
+ 0x6592, 0x6595, 0x6598, 0x659d, 0x65a0, 0x65a3, 0x65a6, 0x65ae,
+ 0x65b2, 0x65b3, 0x65b4, 0x65bf, 0x65c2, 0x65c8, 0x65c9, 0x65ce,
+ 0x65d0, 0x65d4, 0x65d6, 0x65d8, 0x65df, 0x65f0, 0x65f2, 0x65f4,
+ 0x65f5, 0x65f9, 0x65fe, 0x65ff, 0x6600, 0x6604, 0x6608, 0x6609,
+ 0x660d, 0x6611, 0x6612, 0x6615, 0x6616, 0x661d,
+ /* 0x42 */
+ 0x661e, 0x6621, 0x6622, 0x6623, 0x6624, 0x6626, 0x6629, 0x662a,
+ 0x662b, 0x662c, 0x662e, 0x6630, 0x6631, 0x6633, 0x6639, 0x6637,
+ 0x6640, 0x6645, 0x6646, 0x664a, 0x664c, 0x6651, 0x664e, 0x6657,
+ 0x6658, 0x6659, 0x665b, 0x665c, 0x6660, 0x6661, 0x66fb, 0x666a,
+ 0x666b, 0x666c, 0x667e, 0x6673, 0x6675, 0x667f, 0x6677, 0x6678,
+ 0x6679, 0x667b, 0x6680, 0x667c, 0x668b, 0x668c, 0x668d, 0x6690,
+ 0x6692, 0x6699, 0x669a, 0x669b, 0x669c, 0x669f, 0x66a0, 0x66a4,
+ 0x66ad, 0x66b1, 0x66b2, 0x66b5, 0x66bb, 0x66bf, 0x66c0, 0x66c2,
+ 0x66c3, 0x66c8, 0x66cc, 0x66ce, 0x66cf, 0x66d4, 0x66db, 0x66df,
+ 0x66e8, 0x66eb, 0x66ec, 0x66ee, 0x66fa, 0x6705, 0x6707, 0x670e,
+ 0x6713, 0x6719, 0x671c, 0x6720, 0x6722, 0x6733, 0x673e, 0x6745,
+ 0x6747, 0x6748, 0x674c, 0x6754, 0x6755, 0x675d,
+ /* 0x43 */
+ 0x6766, 0x676c, 0x676e, 0x6774, 0x6776, 0x677b, 0x6781, 0x6784,
+ 0x678e, 0x678f, 0x6791, 0x6793, 0x6796, 0x6798, 0x6799, 0x679b,
+ 0x67b0, 0x67b1, 0x67b2, 0x67b5, 0x67bb, 0x67bc, 0x67bd, 0x67f9,
+ 0x67c0, 0x67c2, 0x67c3, 0x67c5, 0x67c8, 0x67c9, 0x67d2, 0x67d7,
+ 0x67d9, 0x67dc, 0x67e1, 0x67e6, 0x67f0, 0x67f2, 0x67f6, 0x67f7,
+ 0x6852, 0x6814, 0x6819, 0x681d, 0x681f, 0x6828, 0x6827, 0x682c,
+ 0x682d, 0x682f, 0x6830, 0x6831, 0x6833, 0x683b, 0x683f, 0x6844,
+ 0x6845, 0x684a, 0x684c, 0x6855, 0x6857, 0x6858, 0x685b, 0x686b,
+ 0x686e, 0x686f, 0x6870, 0x6871, 0x6872, 0x6875, 0x6879, 0x687a,
+ 0x687b, 0x687c, 0x6882, 0x6884, 0x6886, 0x6888, 0x6896, 0x6898,
+ 0x689a, 0x689c, 0x68a1, 0x68a3, 0x68a5, 0x68a9, 0x68aa, 0x68ae,
+ 0x68b2, 0x68bb, 0x68c5, 0x68c8, 0x68cc, 0x68cf,
+ /* 0x44 */
+ 0x68d0, 0x68d1, 0x68d3, 0x68d6, 0x68d9, 0x68dc, 0x68dd, 0x68e5,
+ 0x68e8, 0x68ea, 0x68eb, 0x68ec, 0x68ed, 0x68f0, 0x68f1, 0x68f5,
+ 0x68f6, 0x68fb, 0x68fc, 0x68fd, 0x6906, 0x6909, 0x690a, 0x6910,
+ 0x6911, 0x6913, 0x6916, 0x6917, 0x6931, 0x6933, 0x6935, 0x6938,
+ 0x693b, 0x6942, 0x6945, 0x6949, 0x694e, 0x6957, 0x695b, 0x6963,
+ 0x6964, 0x6965, 0x6966, 0x6968, 0x6969, 0x696c, 0x6970, 0x6971,
+ 0x6972, 0x697a, 0x697b, 0x697f, 0x6980, 0x698d, 0x6992, 0x6996,
+ 0x6998, 0x69a1, 0x69a5, 0x69a6, 0x69a8, 0x69ab, 0x69ad, 0x69af,
+ 0x69b7, 0x69b8, 0x69ba, 0x69bc, 0x69c5, 0x69c8, 0x69d1, 0x69d6,
+ 0x69d7, 0x69e2, 0x69e5, 0x69ee, 0x69ef, 0x69f1, 0x69f3, 0x69f5,
+ 0x69fe, 0x6a00, 0x6a01, 0x6a03, 0x6a0f, 0x6a11, 0x6a15, 0x6a1a,
+ 0x6a1d, 0x6a20, 0x6a24, 0x6a28, 0x6a30, 0x6a32,
+ /* 0x45 */
+ 0x6a34, 0x6a37, 0x6a3b, 0x6a3e, 0x6a3f, 0x6a45, 0x6a46, 0x6a49,
+ 0x6a4a, 0x6a4e, 0x6a50, 0x6a51, 0x6a52, 0x6a55, 0x6a56, 0x6a5b,
+ 0x6a64, 0x6a67, 0x6a6a, 0x6a71, 0x6a73, 0x6a7e, 0x6a81, 0x6a83,
+ 0x6a86, 0x6a87, 0x6a89, 0x6a8b, 0x6a91, 0x6a9b, 0x6a9d, 0x6a9e,
+ 0x6a9f, 0x6aa5, 0x6aab, 0x6aaf, 0x6ab0, 0x6ab1, 0x6ab4, 0x6abd,
+ 0x6abe, 0x6abf, 0x6ac6, 0x6ac9, 0x6ac8, 0x6acc, 0x6ad0, 0x6ad4,
+ 0x6ad5, 0x6ad6, 0x6adc, 0x6add, 0x6ae4, 0x6ae7, 0x6aec, 0x6af0,
+ 0x6af1, 0x6af2, 0x6afc, 0x6afd, 0x6b02, 0x6b03, 0x6b06, 0x6b07,
+ 0x6b09, 0x6b0f, 0x6b10, 0x6b11, 0x6b17, 0x6b1b, 0x6b1e, 0x6b24,
+ 0x6b28, 0x6b2b, 0x6b2c, 0x6b2f, 0x6b35, 0x6b36, 0x6b3b, 0x6b3f,
+ 0x6b46, 0x6b4a, 0x6b4d, 0x6b52, 0x6b56, 0x6b58, 0x6b5d, 0x6b60,
+ 0x6b67, 0x6b6b, 0x6b6e, 0x6b70, 0x6b75, 0x6b7d,
+ /* 0x46 */
+ 0x6b7e, 0x6b82, 0x6b85, 0x6b97, 0x6b9b, 0x6b9f, 0x6ba0, 0x6ba2,
+ 0x6ba3, 0x6ba8, 0x6ba9, 0x6bac, 0x6bad, 0x6bae, 0x6bb0, 0x6bb8,
+ 0x6bb9, 0x6bbd, 0x6bbe, 0x6bc3, 0x6bc4, 0x6bc9, 0x6bcc, 0x6bd6,
+ 0x6bda, 0x6be1, 0x6be3, 0x6be6, 0x6be7, 0x6bee, 0x6bf1, 0x6bf7,
+ 0x6bf9, 0x6bff, 0x6c02, 0x6c04, 0x6c05, 0x6c09, 0x6c0d, 0x6c0e,
+ 0x6c10, 0x6c12, 0x6c19, 0x6c1f, 0x6c26, 0x6c27, 0x6c28, 0x6c2c,
+ 0x6c2e, 0x6c33, 0x6c35, 0x6c36, 0x6c3a, 0x6c3b, 0x6c3f, 0x6c4a,
+ 0x6c4b, 0x6c4d, 0x6c4f, 0x6c52, 0x6c54, 0x6c59, 0x6c5b, 0x6c5c,
+ 0x6c6b, 0x6c6d, 0x6c6f, 0x6c74, 0x6c76, 0x6c78, 0x6c79, 0x6c7b,
+ 0x6c85, 0x6c86, 0x6c87, 0x6c89, 0x6c94, 0x6c95, 0x6c97, 0x6c98,
+ 0x6c9c, 0x6c9f, 0x6cb0, 0x6cb2, 0x6cb4, 0x6cc2, 0x6cc6, 0x6ccd,
+ 0x6ccf, 0x6cd0, 0x6cd1, 0x6cd2, 0x6cd4, 0x6cd6,
+ /* 0x47 */
+ 0x6cda, 0x6cdc, 0x6ce0, 0x6ce7, 0x6ce9, 0x6ceb, 0x6cec, 0x6cee,
+ 0x6cf2, 0x6cf4, 0x6d04, 0x6d07, 0x6d0a, 0x6d0e, 0x6d0f, 0x6d11,
+ 0x6d13, 0x6d1a, 0x6d26, 0x6d27, 0x6d28, 0x6c67, 0x6d2e, 0x6d2f,
+ 0x6d31, 0x6d39, 0x6d3c, 0x6d3f, 0x6d57, 0x6d5e, 0x6d5f, 0x6d61,
+ 0x6d65, 0x6d67, 0x6d6f, 0x6d70, 0x6d7c, 0x6d82, 0x6d87, 0x6d91,
+ 0x6d92, 0x6d94, 0x6d96, 0x6d97, 0x6d98, 0x6daa, 0x6dac, 0x6db4,
+ 0x6db7, 0x6db9, 0x6dbd, 0x6dbf, 0x6dc4, 0x6dc8, 0x6dca, 0x6dce,
+ 0x6dcf, 0x6dd6, 0x6ddb, 0x6ddd, 0x6ddf, 0x6de0, 0x6de2, 0x6de5,
+ 0x6de9, 0x6def, 0x6df0, 0x6df4, 0x6df6, 0x6dfc, 0x6e00, 0x6e04,
+ 0x6e1e, 0x6e22, 0x6e27, 0x6e32, 0x6e36, 0x6e39, 0x6e3b, 0x6e3c,
+ 0x6e44, 0x6e45, 0x6e48, 0x6e49, 0x6e4b, 0x6e4f, 0x6e51, 0x6e52,
+ 0x6e53, 0x6e54, 0x6e57, 0x6e5c, 0x6e5d, 0x6e5e,
+ /* 0x48 */
+ 0x6e62, 0x6e63, 0x6e68, 0x6e73, 0x6e7b, 0x6e7d, 0x6e8d, 0x6e93,
+ 0x6e99, 0x6ea0, 0x6ea7, 0x6ead, 0x6eae, 0x6eb1, 0x6eb3, 0x6ebb,
+ 0x6ebf, 0x6ec0, 0x6ec1, 0x6ec3, 0x6ec7, 0x6ec8, 0x6eca, 0x6ecd,
+ 0x6ece, 0x6ecf, 0x6eeb, 0x6eed, 0x6eee, 0x6ef9, 0x6efb, 0x6efd,
+ 0x6f04, 0x6f08, 0x6f0a, 0x6f0c, 0x6f0d, 0x6f16, 0x6f18, 0x6f1a,
+ 0x6f1b, 0x6f26, 0x6f29, 0x6f2a, 0x6f2f, 0x6f30, 0x6f33, 0x6f36,
+ 0x6f3b, 0x6f3c, 0x6f2d, 0x6f4f, 0x6f51, 0x6f52, 0x6f53, 0x6f57,
+ 0x6f59, 0x6f5a, 0x6f5d, 0x6f5e, 0x6f61, 0x6f62, 0x6f68, 0x6f6c,
+ 0x6f7d, 0x6f7e, 0x6f83, 0x6f87, 0x6f88, 0x6f8b, 0x6f8c, 0x6f8d,
+ 0x6f90, 0x6f92, 0x6f93, 0x6f94, 0x6f96, 0x6f9a, 0x6f9f, 0x6fa0,
+ 0x6fa5, 0x6fa6, 0x6fa7, 0x6fa8, 0x6fae, 0x6faf, 0x6fb0, 0x6fb5,
+ 0x6fb6, 0x6fbc, 0x6fc5, 0x6fc7, 0x6fc8, 0x6fca,
+ /* 0x49 */
+ 0x6fda, 0x6fde, 0x6fe8, 0x6fe9, 0x6ff0, 0x6ff5, 0x6ff9, 0x6ffc,
+ 0x6ffd, 0x7000, 0x7005, 0x7006, 0x7007, 0x700d, 0x7017, 0x7020,
+ 0x7023, 0x702f, 0x7034, 0x7037, 0x7039, 0x703c, 0x7043, 0x7044,
+ 0x7048, 0x7049, 0x704a, 0x704b, 0x7054, 0x7055, 0x705d, 0x705e,
+ 0x704e, 0x7064, 0x7065, 0x706c, 0x706e, 0x7075, 0x7076, 0x707e,
+ 0x7081, 0x7085, 0x7086, 0x7094, 0x7095, 0x7096, 0x7097, 0x7098,
+ 0x709b, 0x70a4, 0x70ab, 0x70b0, 0x70b1, 0x70b4, 0x70b7, 0x70ca,
+ 0x70d1, 0x70d3, 0x70d4, 0x70d5, 0x70d6, 0x70d8, 0x70dc, 0x70e4,
+ 0x70fa, 0x7103, 0x7104, 0x7105, 0x7106, 0x7107, 0x710b, 0x710c,
+ 0x710f, 0x711e, 0x7120, 0x712b, 0x712d, 0x712f, 0x7130, 0x7131,
+ 0x7138, 0x7141, 0x7145, 0x7146, 0x7147, 0x714a, 0x714b, 0x7150,
+ 0x7152, 0x7157, 0x715a, 0x715c, 0x715e, 0x7160,
+ /* 0x4a */
+ 0x7168, 0x7179, 0x7180, 0x7185, 0x7187, 0x718c, 0x7192, 0x719a,
+ 0x719b, 0x71a0, 0x71a2, 0x71af, 0x71b0, 0x71b2, 0x71b3, 0x71ba,
+ 0x71bf, 0x71c0, 0x71c1, 0x71c4, 0x71cb, 0x71cc, 0x71d3, 0x71d6,
+ 0x71d9, 0x71da, 0x71dc, 0x71f8, 0x71fe, 0x7200, 0x7207, 0x7208,
+ 0x7209, 0x7213, 0x7217, 0x721a, 0x721d, 0x721f, 0x7224, 0x722b,
+ 0x722f, 0x7234, 0x7238, 0x7239, 0x7241, 0x7242, 0x7243, 0x7245,
+ 0x724e, 0x724f, 0x7250, 0x7253, 0x7255, 0x7256, 0x725a, 0x725c,
+ 0x725e, 0x7260, 0x7263, 0x7268, 0x726b, 0x726e, 0x726f, 0x7271,
+ 0x7277, 0x7278, 0x727b, 0x727c, 0x727f, 0x7284, 0x7289, 0x728d,
+ 0x728e, 0x7293, 0x729b, 0x72a8, 0x72ad, 0x72ae, 0x72b1, 0x72b4,
+ 0x72be, 0x72c1, 0x72c7, 0x72c9, 0x72cc, 0x72d5, 0x72d6, 0x72d8,
+ 0x72df, 0x72e5, 0x72f3, 0x72f4, 0x72fa, 0x72fb,
+ /* 0x4b */
+ 0x72fe, 0x7302, 0x7304, 0x7305, 0x7307, 0x730b, 0x730d, 0x7312,
+ 0x7313, 0x7318, 0x7319, 0x731e, 0x7322, 0x7324, 0x7327, 0x7328,
+ 0x732c, 0x7331, 0x7332, 0x7335, 0x733a, 0x733b, 0x733d, 0x7343,
+ 0x734d, 0x7350, 0x7352, 0x7356, 0x7358, 0x735d, 0x735e, 0x735f,
+ 0x7360, 0x7366, 0x7367, 0x7369, 0x736b, 0x736c, 0x736e, 0x736f,
+ 0x7371, 0x7377, 0x7379, 0x737c, 0x7380, 0x7381, 0x7383, 0x7385,
+ 0x7386, 0x738e, 0x7390, 0x7393, 0x7395, 0x7397, 0x7398, 0x739c,
+ 0x739e, 0x739f, 0x73a0, 0x73a2, 0x73a5, 0x73a6, 0x73aa, 0x73ab,
+ 0x73ad, 0x73b5, 0x73b7, 0x73b9, 0x73bc, 0x73bd, 0x73bf, 0x73c5,
+ 0x73c6, 0x73c9, 0x73cb, 0x73cc, 0x73cf, 0x73d2, 0x73d3, 0x73d6,
+ 0x73d9, 0x73dd, 0x73e1, 0x73e3, 0x73e6, 0x73e7, 0x73e9, 0x73f4,
+ 0x73f5, 0x73f7, 0x73f9, 0x73fa, 0x73fb, 0x73fd,
+ /* 0x4c */
+ 0x73ff, 0x7400, 0x7401, 0x7404, 0x7407, 0x740a, 0x7411, 0x741a,
+ 0x741b, 0x7424, 0x7426, 0x7428, 0x7429, 0x742a, 0x742b, 0x742c,
+ 0x742d, 0x742e, 0x742f, 0x7430, 0x7431, 0x7439, 0x7440, 0x7443,
+ 0x7444, 0x7446, 0x7447, 0x744b, 0x744d, 0x7451, 0x7452, 0x7457,
+ 0x745d, 0x7462, 0x7466, 0x7467, 0x7468, 0x746b, 0x746d, 0x746e,
+ 0x7471, 0x7472, 0x7480, 0x7481, 0x7485, 0x7486, 0x7487, 0x7489,
+ 0x748f, 0x7490, 0x7491, 0x7492, 0x7498, 0x7499, 0x749a, 0x749c,
+ 0x749f, 0x74a0, 0x74a1, 0x74a3, 0x74a6, 0x74a8, 0x74a9, 0x74aa,
+ 0x74ab, 0x74ae, 0x74af, 0x74b1, 0x74b2, 0x74b5, 0x74b9, 0x74bb,
+ 0x74bf, 0x74c8, 0x74c9, 0x74cc, 0x74d0, 0x74d3, 0x74d8, 0x74da,
+ 0x74db, 0x74de, 0x74df, 0x74e4, 0x74e8, 0x74ea, 0x74eb, 0x74ef,
+ 0x74f4, 0x74fa, 0x74fb, 0x74fc, 0x74ff, 0x7506,
+ /* 0x4d */
+ 0x7512, 0x7516, 0x7517, 0x7520, 0x7521, 0x7524, 0x7527, 0x7529,
+ 0x752a, 0x752f, 0x7536, 0x7539, 0x753d, 0x753e, 0x753f, 0x7540,
+ 0x7543, 0x7547, 0x7548, 0x754e, 0x7550, 0x7552, 0x7557, 0x755e,
+ 0x755f, 0x7561, 0x756f, 0x7571, 0x7579, 0x757a, 0x757b, 0x757c,
+ 0x757d, 0x757e, 0x7581, 0x7585, 0x7590, 0x7592, 0x7593, 0x7595,
+ 0x7599, 0x759c, 0x75a2, 0x75a4, 0x75b4, 0x75ba, 0x75bf, 0x75c0,
+ 0x75c1, 0x75c4, 0x75c6, 0x75cc, 0x75ce, 0x75cf, 0x75d7, 0x75dc,
+ 0x75df, 0x75e0, 0x75e1, 0x75e4, 0x75e7, 0x75ec, 0x75ee, 0x75ef,
+ 0x75f1, 0x75f9, 0x7600, 0x7602, 0x7603, 0x7604, 0x7607, 0x7608,
+ 0x760a, 0x760c, 0x760f, 0x7612, 0x7613, 0x7615, 0x7616, 0x7619,
+ 0x761b, 0x761c, 0x761d, 0x761e, 0x7623, 0x7625, 0x7626, 0x7629,
+ 0x762d, 0x7632, 0x7633, 0x7635, 0x7638, 0x7639,
+ /* 0x4e */
+ 0x763a, 0x763c, 0x764a, 0x7640, 0x7641, 0x7643, 0x7644, 0x7645,
+ 0x7649, 0x764b, 0x7655, 0x7659, 0x765f, 0x7664, 0x7665, 0x766d,
+ 0x766e, 0x766f, 0x7671, 0x7674, 0x7681, 0x7685, 0x768c, 0x768d,
+ 0x7695, 0x769b, 0x769c, 0x769d, 0x769f, 0x76a0, 0x76a2, 0x76a3,
+ 0x76a4, 0x76a5, 0x76a6, 0x76a7, 0x76a8, 0x76aa, 0x76ad, 0x76bd,
+ 0x76c1, 0x76c5, 0x76c9, 0x76cb, 0x76cc, 0x76ce, 0x76d4, 0x76d9,
+ 0x76e0, 0x76e6, 0x76e8, 0x76ec, 0x76f0, 0x76f1, 0x76f6, 0x76f9,
+ 0x76fc, 0x7700, 0x7706, 0x770a, 0x770e, 0x7712, 0x7714, 0x7715,
+ 0x7717, 0x7719, 0x771a, 0x771c, 0x7722, 0x7728, 0x772d, 0x772e,
+ 0x772f, 0x7734, 0x7735, 0x7736, 0x7739, 0x773d, 0x773e, 0x7742,
+ 0x7745, 0x7746, 0x774a, 0x774d, 0x774e, 0x774f, 0x7752, 0x7756,
+ 0x7757, 0x775c, 0x775e, 0x775f, 0x7760, 0x7762,
+ /* 0x4f */
+ 0x7764, 0x7767, 0x776a, 0x776c, 0x7770, 0x7772, 0x7773, 0x7774,
+ 0x777a, 0x777d, 0x7780, 0x7784, 0x778c, 0x778d, 0x7794, 0x7795,
+ 0x7796, 0x779a, 0x779f, 0x77a2, 0x77a7, 0x77aa, 0x77ae, 0x77af,
+ 0x77b1, 0x77b5, 0x77be, 0x77c3, 0x77c9, 0x77d1, 0x77d2, 0x77d5,
+ 0x77d9, 0x77de, 0x77df, 0x77e0, 0x77e4, 0x77e6, 0x77ea, 0x77ec,
+ 0x77f0, 0x77f1, 0x77f4, 0x77f8, 0x77fb, 0x7805, 0x7806, 0x7809,
+ 0x780d, 0x780e, 0x7811, 0x781d, 0x7821, 0x7822, 0x7823, 0x782d,
+ 0x782e, 0x7830, 0x7835, 0x7837, 0x7843, 0x7844, 0x7847, 0x7848,
+ 0x784c, 0x784e, 0x7852, 0x785c, 0x785e, 0x7860, 0x7861, 0x7863,
+ 0x7864, 0x7868, 0x786a, 0x786e, 0x787a, 0x787e, 0x788a, 0x788f,
+ 0x7894, 0x7898, 0x78a1, 0x789d, 0x789e, 0x789f, 0x78a4, 0x78a8,
+ 0x78ac, 0x78ad, 0x78b0, 0x78b1, 0x78b2, 0x78b3,
+ /* 0x50 */
+ 0x78bb, 0x78bd, 0x78bf, 0x78c7, 0x78c8, 0x78c9, 0x78cc, 0x78ce,
+ 0x78d2, 0x78d3, 0x78d5, 0x78d6, 0x78e4, 0x78db, 0x78df, 0x78e0,
+ 0x78e1, 0x78e6, 0x78ea, 0x78f2, 0x78f3, 0x7900, 0x78f6, 0x78f7,
+ 0x78fa, 0x78fb, 0x78ff, 0x7906, 0x790c, 0x7910, 0x791a, 0x791c,
+ 0x791e, 0x791f, 0x7920, 0x7925, 0x7927, 0x7929, 0x792d, 0x7931,
+ 0x7934, 0x7935, 0x793b, 0x793d, 0x793f, 0x7944, 0x7945, 0x7946,
+ 0x794a, 0x794b, 0x794f, 0x7951, 0x7954, 0x7958, 0x795b, 0x795c,
+ 0x7967, 0x7969, 0x796b, 0x7972, 0x7979, 0x797b, 0x797c, 0x797e,
+ 0x798b, 0x798c, 0x7991, 0x7993, 0x7994, 0x7995, 0x7996, 0x7998,
+ 0x799b, 0x799c, 0x79a1, 0x79a8, 0x79a9, 0x79ab, 0x79af, 0x79b1,
+ 0x79b4, 0x79b8, 0x79bb, 0x79c2, 0x79c4, 0x79c7, 0x79c8, 0x79ca,
+ 0x79cf, 0x79d4, 0x79d6, 0x79da, 0x79dd, 0x79de,
+ /* 0x51 */
+ 0x79e0, 0x79e2, 0x79e5, 0x79ea, 0x79eb, 0x79ed, 0x79f1, 0x79f8,
+ 0x79fc, 0x7a02, 0x7a03, 0x7a07, 0x7a09, 0x7a0a, 0x7a0c, 0x7a11,
+ 0x7a15, 0x7a1b, 0x7a1e, 0x7a21, 0x7a27, 0x7a2b, 0x7a2d, 0x7a2f,
+ 0x7a30, 0x7a34, 0x7a35, 0x7a38, 0x7a39, 0x7a3a, 0x7a44, 0x7a45,
+ 0x7a47, 0x7a48, 0x7a4c, 0x7a55, 0x7a56, 0x7a59, 0x7a5c, 0x7a5d,
+ 0x7a5f, 0x7a60, 0x7a65, 0x7a67, 0x7a6a, 0x7a6d, 0x7a75, 0x7a78,
+ 0x7a7e, 0x7a80, 0x7a82, 0x7a85, 0x7a86, 0x7a8a, 0x7a8b, 0x7a90,
+ 0x7a91, 0x7a94, 0x7a9e, 0x7aa0, 0x7aa3, 0x7aac, 0x7ab3, 0x7ab5,
+ 0x7ab9, 0x7abb, 0x7abc, 0x7ac6, 0x7ac9, 0x7acc, 0x7ace, 0x7ad1,
+ 0x7adb, 0x7ae8, 0x7ae9, 0x7aeb, 0x7aec, 0x7af1, 0x7af4, 0x7afb,
+ 0x7afd, 0x7afe, 0x7b07, 0x7b14, 0x7b1f, 0x7b23, 0x7b27, 0x7b29,
+ 0x7b2a, 0x7b2b, 0x7b2d, 0x7b2e, 0x7b2f, 0x7b30,
+ /* 0x52 */
+ 0x7b31, 0x7b34, 0x7b3d, 0x7b3f, 0x7b40, 0x7b41, 0x7b47, 0x7b4e,
+ 0x7b55, 0x7b60, 0x7b64, 0x7b66, 0x7b69, 0x7b6a, 0x7b6d, 0x7b6f,
+ 0x7b72, 0x7b73, 0x7b77, 0x7b84, 0x7b89, 0x7b8e, 0x7b90, 0x7b91,
+ 0x7b96, 0x7b9b, 0x7b9e, 0x7ba0, 0x7ba5, 0x7bac, 0x7baf, 0x7bb0,
+ 0x7bb2, 0x7bb5, 0x7bb6, 0x7bba, 0x7bbb, 0x7bbc, 0x7bbd, 0x7bc2,
+ 0x7bc5, 0x7bc8, 0x7bca, 0x7bd4, 0x7bd6, 0x7bd7, 0x7bd9, 0x7bda,
+ 0x7bdb, 0x7be8, 0x7bea, 0x7bf2, 0x7bf4, 0x7bf5, 0x7bf8, 0x7bf9,
+ 0x7bfa, 0x7bfc, 0x7bfe, 0x7c01, 0x7c02, 0x7c03, 0x7c04, 0x7c06,
+ 0x7c09, 0x7c0b, 0x7c0c, 0x7c0e, 0x7c0f, 0x7c19, 0x7c1b, 0x7c20,
+ 0x7c25, 0x7c26, 0x7c28, 0x7c2c, 0x7c31, 0x7c33, 0x7c34, 0x7c36,
+ 0x7c39, 0x7c3a, 0x7c46, 0x7c4a, 0x7c55, 0x7c51, 0x7c52, 0x7c53,
+ 0x7c59, 0x7c5a, 0x7c5b, 0x7c5c, 0x7c5d, 0x7c5e,
+ /* 0x53 */
+ 0x7c61, 0x7c63, 0x7c67, 0x7c69, 0x7c6d, 0x7c6e, 0x7c70, 0x7c72,
+ 0x7c79, 0x7c7c, 0x7c7d, 0x7c86, 0x7c87, 0x7c8f, 0x7c94, 0x7c9e,
+ 0x7ca0, 0x7ca6, 0x7cb0, 0x7cb6, 0x7cb7, 0x7cba, 0x7cbb, 0x7cbc,
+ 0x7cbf, 0x7cc4, 0x7cc7, 0x7cc8, 0x7cc9, 0x7ccd, 0x7ccf, 0x7cd3,
+ 0x7cd4, 0x7cd5, 0x7cd7, 0x7cd9, 0x7cda, 0x7cdd, 0x7ce6, 0x7ce9,
+ 0x7ceb, 0x7cf5, 0x7d03, 0x7d07, 0x7d08, 0x7d09, 0x7d0f, 0x7d11,
+ 0x7d12, 0x7d13, 0x7d16, 0x7d1d, 0x7d1e, 0x7d23, 0x7d26, 0x7d2a,
+ 0x7d2d, 0x7d31, 0x7d3c, 0x7d3d, 0x7d3e, 0x7d40, 0x7d41, 0x7d47,
+ 0x7d48, 0x7d4d, 0x7d51, 0x7d53, 0x7d57, 0x7d59, 0x7d5a, 0x7d5c,
+ 0x7d5d, 0x7d65, 0x7d67, 0x7d6a, 0x7d70, 0x7d78, 0x7d7a, 0x7d7b,
+ 0x7d7f, 0x7d81, 0x7d82, 0x7d83, 0x7d85, 0x7d86, 0x7d88, 0x7d8b,
+ 0x7d8c, 0x7d8d, 0x7d91, 0x7d96, 0x7d97, 0x7d9d,
+ /* 0x54 */
+ 0x7d9e, 0x7da6, 0x7da7, 0x7daa, 0x7db3, 0x7db6, 0x7db7, 0x7db9,
+ 0x7dc2, 0x7dc3, 0x7dc4, 0x7dc5, 0x7dc6, 0x7dcc, 0x7dcd, 0x7dce,
+ 0x7dd7, 0x7dd9, 0x7e00, 0x7de2, 0x7de5, 0x7de6, 0x7dea, 0x7deb,
+ 0x7ded, 0x7df1, 0x7df5, 0x7df6, 0x7df9, 0x7dfa, 0x7e08, 0x7e10,
+ 0x7e11, 0x7e15, 0x7e17, 0x7e1c, 0x7e1d, 0x7e20, 0x7e27, 0x7e28,
+ 0x7e2c, 0x7e2d, 0x7e2f, 0x7e33, 0x7e36, 0x7e3f, 0x7e44, 0x7e45,
+ 0x7e47, 0x7e4e, 0x7e50, 0x7e52, 0x7e58, 0x7e5f, 0x7e61, 0x7e62,
+ 0x7e65, 0x7e6b, 0x7e6e, 0x7e6f, 0x7e73, 0x7e78, 0x7e7e, 0x7e81,
+ 0x7e86, 0x7e87, 0x7e8a, 0x7e8d, 0x7e91, 0x7e95, 0x7e98, 0x7e9a,
+ 0x7e9d, 0x7e9e, 0x7f3c, 0x7f3b, 0x7f3d, 0x7f3e, 0x7f3f, 0x7f43,
+ 0x7f44, 0x7f47, 0x7f4f, 0x7f52, 0x7f53, 0x7f5b, 0x7f5c, 0x7f5d,
+ 0x7f61, 0x7f63, 0x7f64, 0x7f65, 0x7f66, 0x7f6d,
+ /* 0x55 */
+ 0x7f71, 0x7f7d, 0x7f7e, 0x7f7f, 0x7f80, 0x7f8b, 0x7f8d, 0x7f8f,
+ 0x7f90, 0x7f91, 0x7f96, 0x7f97, 0x7f9c, 0x7fa1, 0x7fa2, 0x7fa6,
+ 0x7faa, 0x7fad, 0x7fb4, 0x7fbc, 0x7fbf, 0x7fc0, 0x7fc3, 0x7fc8,
+ 0x7fce, 0x7fcf, 0x7fdb, 0x7fdf, 0x7fe3, 0x7fe5, 0x7fe8, 0x7fec,
+ 0x7fee, 0x7fef, 0x7ff2, 0x7ffa, 0x7ffd, 0x7ffe, 0x7fff, 0x8007,
+ 0x8008, 0x800a, 0x800d, 0x800e, 0x800f, 0x8011, 0x8013, 0x8014,
+ 0x8016, 0x801d, 0x801e, 0x801f, 0x8020, 0x8024, 0x8026, 0x802c,
+ 0x802e, 0x8030, 0x8034, 0x8035, 0x8037, 0x8039, 0x803a, 0x803c,
+ 0x803e, 0x8040, 0x8044, 0x8060, 0x8064, 0x8066, 0x806d, 0x8071,
+ 0x8075, 0x8081, 0x8088, 0x808e, 0x809c, 0x809e, 0x80a6, 0x80a7,
+ 0x80ab, 0x80b8, 0x80b9, 0x80c8, 0x80cd, 0x80cf, 0x80d2, 0x80d4,
+ 0x80d5, 0x80d7, 0x80d8, 0x80e0, 0x80ed, 0x80ee,
+ /* 0x56 */
+ 0x80f0, 0x80f2, 0x80f3, 0x80f6, 0x80f9, 0x80fa, 0x80fe, 0x8103,
+ 0x810b, 0x8116, 0x8117, 0x8118, 0x811c, 0x811e, 0x8120, 0x8124,
+ 0x8127, 0x812c, 0x8130, 0x8135, 0x813a, 0x813c, 0x8145, 0x8147,
+ 0x814a, 0x814c, 0x8152, 0x8157, 0x8160, 0x8161, 0x8167, 0x8168,
+ 0x8169, 0x816d, 0x816f, 0x8177, 0x8181, 0x8190, 0x8184, 0x8185,
+ 0x8186, 0x818b, 0x818e, 0x8196, 0x8198, 0x819b, 0x819e, 0x81a2,
+ 0x81ae, 0x81b2, 0x81b4, 0x81bb, 0x81cb, 0x81c3, 0x81c5, 0x81ca,
+ 0x81ce, 0x81cf, 0x81d5, 0x81d7, 0x81db, 0x81dd, 0x81de, 0x81e1,
+ 0x81e4, 0x81eb, 0x81ec, 0x81f0, 0x81f1, 0x81f2, 0x81f5, 0x81f6,
+ 0x81f8, 0x81f9, 0x81fd, 0x81ff, 0x8200, 0x8203, 0x820f, 0x8213,
+ 0x8214, 0x8219, 0x821a, 0x821d, 0x8221, 0x8222, 0x8228, 0x8232,
+ 0x8234, 0x823a, 0x8243, 0x8244, 0x8245, 0x8246,
+ /* 0x57 */
+ 0x824b, 0x824e, 0x824f, 0x8251, 0x8256, 0x825c, 0x8260, 0x8263,
+ 0x8267, 0x826d, 0x8274, 0x827b, 0x827d, 0x827f, 0x8280, 0x8281,
+ 0x8283, 0x8284, 0x8287, 0x8289, 0x828a, 0x828e, 0x8291, 0x8294,
+ 0x8296, 0x8298, 0x829a, 0x829b, 0x82a0, 0x82a1, 0x82a3, 0x82a4,
+ 0x82a7, 0x82a8, 0x82a9, 0x82aa, 0x82ae, 0x82b0, 0x82b2, 0x82b4,
+ 0x82b7, 0x82ba, 0x82bc, 0x82be, 0x82bf, 0x82c6, 0x82d0, 0x82d5,
+ 0x82da, 0x82e0, 0x82e2, 0x82e4, 0x82e8, 0x82ea, 0x82ed, 0x82ef,
+ 0x82f6, 0x82f7, 0x82fd, 0x82fe, 0x8300, 0x8301, 0x8307, 0x8308,
+ 0x830a, 0x830b, 0x8354, 0x831b, 0x831d, 0x831e, 0x831f, 0x8321,
+ 0x8322, 0x832c, 0x832d, 0x832e, 0x8330, 0x8333, 0x8337, 0x833a,
+ 0x833c, 0x833d, 0x8342, 0x8343, 0x8344, 0x8347, 0x834d, 0x834e,
+ 0x8351, 0x8355, 0x8356, 0x8357, 0x8370, 0x8378,
+ /* 0x58 */
+ 0x837d, 0x837f, 0x8380, 0x8382, 0x8384, 0x8386, 0x838d, 0x8392,
+ 0x8394, 0x8395, 0x8398, 0x8399, 0x839b, 0x839c, 0x839d, 0x83a6,
+ 0x83a7, 0x83a9, 0x83ac, 0x83be, 0x83bf, 0x83c0, 0x83c7, 0x83c9,
+ 0x83cf, 0x83d0, 0x83d1, 0x83d4, 0x83dd, 0x8353, 0x83e8, 0x83ea,
+ 0x83f6, 0x83f8, 0x83f9, 0x83fc, 0x8401, 0x8406, 0x840a, 0x840f,
+ 0x8411, 0x8415, 0x8419, 0x83ad, 0x842f, 0x8439, 0x8445, 0x8447,
+ 0x8448, 0x844a, 0x844d, 0x844f, 0x8451, 0x8452, 0x8456, 0x8458,
+ 0x8459, 0x845a, 0x845c, 0x8460, 0x8464, 0x8465, 0x8467, 0x846a,
+ 0x8470, 0x8473, 0x8474, 0x8476, 0x8478, 0x847c, 0x847d, 0x8481,
+ 0x8485, 0x8492, 0x8493, 0x8495, 0x849e, 0x84a6, 0x84a8, 0x84a9,
+ 0x84aa, 0x84af, 0x84b1, 0x84b4, 0x84ba, 0x84bd, 0x84be, 0x84c0,
+ 0x84c2, 0x84c7, 0x84c8, 0x84cc, 0x84cf, 0x84d3,
+ /* 0x59 */
+ 0x84dc, 0x84e7, 0x84ea, 0x84ef, 0x84f0, 0x84f1, 0x84f2, 0x84f7,
+ 0x8532, 0x84fa, 0x84fb, 0x84fd, 0x8502, 0x8503, 0x8507, 0x850c,
+ 0x850e, 0x8510, 0x851c, 0x851e, 0x8522, 0x8523, 0x8524, 0x8525,
+ 0x8527, 0x852a, 0x852b, 0x852f, 0x8533, 0x8534, 0x8536, 0x853f,
+ 0x8546, 0x854f, 0x8550, 0x8551, 0x8552, 0x8553, 0x8556, 0x8559,
+ 0x855c, 0x855d, 0x855e, 0x855f, 0x8560, 0x8561, 0x8562, 0x8564,
+ 0x856b, 0x856f, 0x8579, 0x857a, 0x857b, 0x857d, 0x857f, 0x8581,
+ 0x8585, 0x8586, 0x8589, 0x858b, 0x858c, 0x858f, 0x8593, 0x8598,
+ 0x859d, 0x859f, 0x85a0, 0x85a2, 0x85a5, 0x85a7, 0x85b4, 0x85b6,
+ 0x85b7, 0x85b8, 0x85bc, 0x85bd, 0x85be, 0x85bf, 0x85c2, 0x85c7,
+ 0x85ca, 0x85cb, 0x85ce, 0x85ad, 0x85d8, 0x85da, 0x85df, 0x85e0,
+ 0x85e6, 0x85e8, 0x85ed, 0x85f3, 0x85f6, 0x85fc,
+ /* 0x5a */
+ 0x85ff, 0x8600, 0x8604, 0x8605, 0x860d, 0x860e, 0x8610, 0x8611,
+ 0x8612, 0x8618, 0x8619, 0x861b, 0x861e, 0x8621, 0x8627, 0x8629,
+ 0x8636, 0x8638, 0x863a, 0x863c, 0x863d, 0x8640, 0x8642, 0x8646,
+ 0x8652, 0x8653, 0x8656, 0x8657, 0x8658, 0x8659, 0x865d, 0x8660,
+ 0x8661, 0x8662, 0x8663, 0x8664, 0x8669, 0x866c, 0x866f, 0x8675,
+ 0x8676, 0x8677, 0x867a, 0x868d, 0x8691, 0x8696, 0x8698, 0x869a,
+ 0x869c, 0x86a1, 0x86a6, 0x86a7, 0x86a8, 0x86ad, 0x86b1, 0x86b3,
+ 0x86b4, 0x86b5, 0x86b7, 0x86b8, 0x86b9, 0x86bf, 0x86c0, 0x86c1,
+ 0x86c3, 0x86c5, 0x86d1, 0x86d2, 0x86d5, 0x86d7, 0x86da, 0x86dc,
+ 0x86e0, 0x86e3, 0x86e5, 0x86e7, 0x8688, 0x86fa, 0x86fc, 0x86fd,
+ 0x8704, 0x8705, 0x8707, 0x870b, 0x870e, 0x870f, 0x8710, 0x8713,
+ 0x8714, 0x8719, 0x871e, 0x871f, 0x8721, 0x8723,
+ /* 0x5b */
+ 0x8728, 0x872e, 0x872f, 0x8731, 0x8732, 0x8739, 0x873a, 0x873c,
+ 0x873d, 0x873e, 0x8740, 0x8743, 0x8745, 0x874d, 0x8758, 0x875d,
+ 0x8761, 0x8764, 0x8765, 0x876f, 0x8771, 0x8772, 0x877b, 0x8783,
+ 0x8784, 0x8785, 0x8786, 0x8787, 0x8788, 0x8789, 0x878b, 0x878c,
+ 0x8790, 0x8793, 0x8795, 0x8797, 0x8798, 0x8799, 0x879e, 0x87a0,
+ 0x87a3, 0x87a7, 0x87ac, 0x87ad, 0x87ae, 0x87b1, 0x87b5, 0x87be,
+ 0x87bf, 0x87c1, 0x87c8, 0x87c9, 0x87ca, 0x87ce, 0x87d5, 0x87d6,
+ 0x87d9, 0x87da, 0x87dc, 0x87df, 0x87e2, 0x87e3, 0x87e4, 0x87ea,
+ 0x87eb, 0x87ed, 0x87f1, 0x87f3, 0x87f8, 0x87fa, 0x87ff, 0x8801,
+ 0x8803, 0x8806, 0x8809, 0x880a, 0x880b, 0x8810, 0x8819, 0x8812,
+ 0x8813, 0x8814, 0x8818, 0x881a, 0x881b, 0x881c, 0x881e, 0x881f,
+ 0x8828, 0x882d, 0x882e, 0x8830, 0x8832, 0x8835,
+ /* 0x5c */
+ 0x883a, 0x883c, 0x8841, 0x8843, 0x8845, 0x8848, 0x8849, 0x884a,
+ 0x884b, 0x884e, 0x8851, 0x8855, 0x8856, 0x8858, 0x885a, 0x885c,
+ 0x885f, 0x8860, 0x8864, 0x8869, 0x8871, 0x8879, 0x887b, 0x8880,
+ 0x8898, 0x889a, 0x889b, 0x889c, 0x889f, 0x88a0, 0x88a8, 0x88aa,
+ 0x88ba, 0x88bd, 0x88be, 0x88c0, 0x88ca, 0x88cb, 0x88cc, 0x88cd,
+ 0x88ce, 0x88d1, 0x88d2, 0x88d3, 0x88db, 0x88de, 0x88e7, 0x88ef,
+ 0x88f0, 0x88f1, 0x88f5, 0x88f7, 0x8901, 0x8906, 0x890d, 0x890e,
+ 0x890f, 0x8915, 0x8916, 0x8918, 0x8919, 0x891a, 0x891c, 0x8920,
+ 0x8926, 0x8927, 0x8928, 0x8930, 0x8931, 0x8932, 0x8935, 0x8939,
+ 0x893a, 0x893e, 0x8940, 0x8942, 0x8945, 0x8946, 0x8949, 0x894f,
+ 0x8952, 0x8957, 0x895a, 0x895b, 0x895c, 0x8961, 0x8962, 0x8963,
+ 0x896b, 0x896e, 0x8970, 0x8973, 0x8975, 0x897a,
+ /* 0x5d */
+ 0x897b, 0x897c, 0x897d, 0x8989, 0x898d, 0x8990, 0x8994, 0x8995,
+ 0x899b, 0x899c, 0x899f, 0x89a0, 0x89a5, 0x89b0, 0x89b4, 0x89b5,
+ 0x89b6, 0x89b7, 0x89bc, 0x89d4, 0x89d5, 0x89d6, 0x89d7, 0x89d8,
+ 0x89e5, 0x89e9, 0x89eb, 0x89ed, 0x89f1, 0x89f3, 0x89f6, 0x89f9,
+ 0x89fd, 0x89ff, 0x8a04, 0x8a05, 0x8a07, 0x8a0f, 0x8a11, 0x8a12,
+ 0x8a14, 0x8a15, 0x8a1e, 0x8a20, 0x8a22, 0x8a24, 0x8a26, 0x8a2b,
+ 0x8a2c, 0x8a2f, 0x8a35, 0x8a37, 0x8a3d, 0x8a3e, 0x8a40, 0x8a43,
+ 0x8a45, 0x8a47, 0x8a49, 0x8a4d, 0x8a4e, 0x8a53, 0x8a56, 0x8a57,
+ 0x8a58, 0x8a5c, 0x8a5d, 0x8a61, 0x8a65, 0x8a67, 0x8a75, 0x8a76,
+ 0x8a77, 0x8a79, 0x8a7a, 0x8a7b, 0x8a7e, 0x8a7f, 0x8a80, 0x8a83,
+ 0x8a86, 0x8a8b, 0x8a8f, 0x8a90, 0x8a92, 0x8a96, 0x8a97, 0x8a99,
+ 0x8a9f, 0x8aa7, 0x8aa9, 0x8aae, 0x8aaf, 0x8ab3,
+ /* 0x5e */
+ 0x8ab6, 0x8ab7, 0x8abb, 0x8abe, 0x8ac3, 0x8ac6, 0x8ac8, 0x8ac9,
+ 0x8aca, 0x8ad1, 0x8ad3, 0x8ad4, 0x8ad5, 0x8ad7, 0x8add, 0x8adf,
+ 0x8aec, 0x8af0, 0x8af4, 0x8af5, 0x8af6, 0x8afc, 0x8aff, 0x8b05,
+ 0x8b06, 0x8b0b, 0x8b11, 0x8b1c, 0x8b1e, 0x8b1f, 0x8b0a, 0x8b2d,
+ 0x8b30, 0x8b37, 0x8b3c, 0x8b42, 0x8b43, 0x8b44, 0x8b45, 0x8b46,
+ 0x8b48, 0x8b52, 0x8b53, 0x8b54, 0x8b59, 0x8b4d, 0x8b5e, 0x8b63,
+ 0x8b6d, 0x8b76, 0x8b78, 0x8b79, 0x8b7c, 0x8b7e, 0x8b81, 0x8b84,
+ 0x8b85, 0x8b8b, 0x8b8d, 0x8b8f, 0x8b94, 0x8b95, 0x8b9c, 0x8b9e,
+ 0x8b9f, 0x8c38, 0x8c39, 0x8c3d, 0x8c3e, 0x8c45, 0x8c47, 0x8c49,
+ 0x8c4b, 0x8c4f, 0x8c51, 0x8c53, 0x8c54, 0x8c57, 0x8c58, 0x8c5b,
+ 0x8c5d, 0x8c59, 0x8c63, 0x8c64, 0x8c66, 0x8c68, 0x8c69, 0x8c6d,
+ 0x8c73, 0x8c75, 0x8c76, 0x8c7b, 0x8c7e, 0x8c86,
+ /* 0x5f */
+ 0x8c87, 0x8c8b, 0x8c90, 0x8c92, 0x8c93, 0x8c99, 0x8c9b, 0x8c9c,
+ 0x8ca4, 0x8cb9, 0x8cba, 0x8cc5, 0x8cc6, 0x8cc9, 0x8ccb, 0x8ccf,
+ 0x8cd6, 0x8cd5, 0x8cd9, 0x8cdd, 0x8ce1, 0x8ce8, 0x8cec, 0x8cef,
+ 0x8cf0, 0x8cf2, 0x8cf5, 0x8cf7, 0x8cf8, 0x8cfe, 0x8cff, 0x8d01,
+ 0x8d03, 0x8d09, 0x8d12, 0x8d17, 0x8d1b, 0x8d65, 0x8d69, 0x8d6c,
+ 0x8d6e, 0x8d7f, 0x8d82, 0x8d84, 0x8d88, 0x8d8d, 0x8d90, 0x8d91,
+ 0x8d95, 0x8d9e, 0x8d9f, 0x8da0, 0x8da6, 0x8dab, 0x8dac, 0x8daf,
+ 0x8db2, 0x8db5, 0x8db7, 0x8db9, 0x8dbb, 0x8dc0, 0x8dc5, 0x8dc6,
+ 0x8dc7, 0x8dc8, 0x8dca, 0x8dce, 0x8dd1, 0x8dd4, 0x8dd5, 0x8dd7,
+ 0x8dd9, 0x8de4, 0x8de5, 0x8de7, 0x8dec, 0x8df0, 0x8dbc, 0x8df1,
+ 0x8df2, 0x8df4, 0x8dfd, 0x8e01, 0x8e04, 0x8e05, 0x8e06, 0x8e0b,
+ 0x8e11, 0x8e14, 0x8e16, 0x8e20, 0x8e21, 0x8e22,
+ /* 0x60 */
+ 0x8e23, 0x8e26, 0x8e27, 0x8e31, 0x8e33, 0x8e36, 0x8e37, 0x8e38,
+ 0x8e39, 0x8e3d, 0x8e40, 0x8e41, 0x8e4b, 0x8e4d, 0x8e4e, 0x8e4f,
+ 0x8e54, 0x8e5b, 0x8e5c, 0x8e5d, 0x8e5e, 0x8e61, 0x8e62, 0x8e69,
+ 0x8e6c, 0x8e6d, 0x8e6f, 0x8e70, 0x8e71, 0x8e79, 0x8e7a, 0x8e7b,
+ 0x8e82, 0x8e83, 0x8e89, 0x8e90, 0x8e92, 0x8e95, 0x8e9a, 0x8e9b,
+ 0x8e9d, 0x8e9e, 0x8ea2, 0x8ea7, 0x8ea9, 0x8ead, 0x8eae, 0x8eb3,
+ 0x8eb5, 0x8eba, 0x8ebb, 0x8ec0, 0x8ec1, 0x8ec3, 0x8ec4, 0x8ec7,
+ 0x8ecf, 0x8ed1, 0x8ed4, 0x8edc, 0x8ee8, 0x8eee, 0x8ef0, 0x8ef1,
+ 0x8ef7, 0x8ef9, 0x8efa, 0x8eed, 0x8f00, 0x8f02, 0x8f07, 0x8f08,
+ 0x8f0f, 0x8f10, 0x8f16, 0x8f17, 0x8f18, 0x8f1e, 0x8f20, 0x8f21,
+ 0x8f23, 0x8f25, 0x8f27, 0x8f28, 0x8f2c, 0x8f2d, 0x8f2e, 0x8f34,
+ 0x8f35, 0x8f36, 0x8f37, 0x8f3a, 0x8f40, 0x8f41,
+ /* 0x61 */
+ 0x8f43, 0x8f47, 0x8f4f, 0x8f51, 0x8f52, 0x8f53, 0x8f54, 0x8f55,
+ 0x8f58, 0x8f5d, 0x8f5e, 0x8f65, 0x8f9d, 0x8fa0, 0x8fa1, 0x8fa4,
+ 0x8fa5, 0x8fa6, 0x8fb5, 0x8fb6, 0x8fb8, 0x8fbe, 0x8fc0, 0x8fc1,
+ 0x8fc6, 0x8fca, 0x8fcb, 0x8fcd, 0x8fd0, 0x8fd2, 0x8fd3, 0x8fd5,
+ 0x8fe0, 0x8fe3, 0x8fe4, 0x8fe8, 0x8fee, 0x8ff1, 0x8ff5, 0x8ff6,
+ 0x8ffb, 0x8ffe, 0x9002, 0x9004, 0x9008, 0x900c, 0x9018, 0x901b,
+ 0x9028, 0x9029, 0x902f, 0x902a, 0x902c, 0x902d, 0x9033, 0x9034,
+ 0x9037, 0x903f, 0x9043, 0x9044, 0x904c, 0x905b, 0x905d, 0x9062,
+ 0x9066, 0x9067, 0x906c, 0x9070, 0x9074, 0x9079, 0x9085, 0x9088,
+ 0x908b, 0x908c, 0x908e, 0x9090, 0x9095, 0x9097, 0x9098, 0x9099,
+ 0x909b, 0x90a0, 0x90a1, 0x90a2, 0x90a5, 0x90b0, 0x90b2, 0x90b3,
+ 0x90b4, 0x90b6, 0x90bd, 0x90cc, 0x90be, 0x90c3,
+ /* 0x62 */
+ 0x90c4, 0x90c5, 0x90c7, 0x90c8, 0x90d5, 0x90d7, 0x90d8, 0x90d9,
+ 0x90dc, 0x90dd, 0x90df, 0x90e5, 0x90d2, 0x90f6, 0x90eb, 0x90ef,
+ 0x90f0, 0x90f4, 0x90fe, 0x90ff, 0x9100, 0x9104, 0x9105, 0x9106,
+ 0x9108, 0x910d, 0x9110, 0x9114, 0x9116, 0x9117, 0x9118, 0x911a,
+ 0x911c, 0x911e, 0x9120, 0x9125, 0x9122, 0x9123, 0x9127, 0x9129,
+ 0x912e, 0x912f, 0x9131, 0x9134, 0x9136, 0x9137, 0x9139, 0x913a,
+ 0x913c, 0x913d, 0x9143, 0x9147, 0x9148, 0x914f, 0x9153, 0x9157,
+ 0x9159, 0x915a, 0x915b, 0x9161, 0x9164, 0x9167, 0x916d, 0x9174,
+ 0x9179, 0x917a, 0x917b, 0x9181, 0x9183, 0x9185, 0x9186, 0x918a,
+ 0x918e, 0x9191, 0x9193, 0x9194, 0x9195, 0x9198, 0x919e, 0x91a1,
+ 0x91a6, 0x91a8, 0x91ac, 0x91ad, 0x91ae, 0x91b0, 0x91b1, 0x91b2,
+ 0x91b3, 0x91b6, 0x91bb, 0x91bc, 0x91bd, 0x91bf,
+ /* 0x63 */
+ 0x91c2, 0x91c3, 0x91c5, 0x91d3, 0x91d4, 0x91d7, 0x91d9, 0x91da,
+ 0x91de, 0x91e4, 0x91e5, 0x91e9, 0x91ea, 0x91ec, 0x91ed, 0x91ee,
+ 0x91ef, 0x91f0, 0x91f1, 0x91f7, 0x91f9, 0x91fb, 0x91fd, 0x9200,
+ 0x9201, 0x9204, 0x9205, 0x9206, 0x9207, 0x9209, 0x920a, 0x920c,
+ 0x9210, 0x9212, 0x9213, 0x9216, 0x9218, 0x921c, 0x921d, 0x9223,
+ 0x9224, 0x9225, 0x9226, 0x9228, 0x922e, 0x922f, 0x9230, 0x9233,
+ 0x9235, 0x9236, 0x9238, 0x9239, 0x923a, 0x923c, 0x923e, 0x9240,
+ 0x9242, 0x9243, 0x9246, 0x9247, 0x924a, 0x924d, 0x924e, 0x924f,
+ 0x9251, 0x9258, 0x9259, 0x925c, 0x925d, 0x9260, 0x9261, 0x9265,
+ 0x9267, 0x9268, 0x9269, 0x926e, 0x926f, 0x9270, 0x9275, 0x9276,
+ 0x9277, 0x9278, 0x9279, 0x927b, 0x927c, 0x927d, 0x927f, 0x9288,
+ 0x9289, 0x928a, 0x928d, 0x928e, 0x9292, 0x9297,
+ /* 0x64 */
+ 0x9299, 0x929f, 0x92a0, 0x92a4, 0x92a5, 0x92a7, 0x92a8, 0x92ab,
+ 0x92af, 0x92b2, 0x92b6, 0x92b8, 0x92ba, 0x92bb, 0x92bc, 0x92bd,
+ 0x92bf, 0x92c0, 0x92c1, 0x92c2, 0x92c3, 0x92c5, 0x92c6, 0x92c7,
+ 0x92c8, 0x92cb, 0x92cc, 0x92cd, 0x92ce, 0x92d0, 0x92d3, 0x92d5,
+ 0x92d7, 0x92d8, 0x92d9, 0x92dc, 0x92dd, 0x92df, 0x92e0, 0x92e1,
+ 0x92e3, 0x92e5, 0x92e7, 0x92e8, 0x92ec, 0x92ee, 0x92f0, 0x92f9,
+ 0x92fb, 0x92ff, 0x9300, 0x9302, 0x9308, 0x930d, 0x9311, 0x9314,
+ 0x9315, 0x931c, 0x931d, 0x931e, 0x931f, 0x9321, 0x9324, 0x9325,
+ 0x9327, 0x9329, 0x932a, 0x9333, 0x9334, 0x9336, 0x9337, 0x9347,
+ 0x9348, 0x9349, 0x9350, 0x9351, 0x9352, 0x9355, 0x9357, 0x9358,
+ 0x935a, 0x935e, 0x9364, 0x9365, 0x9367, 0x9369, 0x936a, 0x936d,
+ 0x936f, 0x9370, 0x9371, 0x9373, 0x9374, 0x9376,
+ /* 0x65 */
+ 0x937a, 0x937d, 0x937f, 0x9380, 0x9381, 0x9382, 0x9388, 0x938a,
+ 0x938b, 0x938d, 0x938f, 0x9392, 0x9395, 0x9398, 0x939b, 0x939e,
+ 0x93a1, 0x93a3, 0x93a4, 0x93a6, 0x93a8, 0x93ab, 0x93b4, 0x93b5,
+ 0x93b6, 0x93ba, 0x93a9, 0x93c1, 0x93c4, 0x93c5, 0x93c6, 0x93c7,
+ 0x93c9, 0x93ca, 0x93cb, 0x93cc, 0x93cd, 0x93d3, 0x93d9, 0x93dc,
+ 0x93de, 0x93df, 0x93e2, 0x93e6, 0x93e7, 0x93f9, 0x93f7, 0x93f8,
+ 0x93fa, 0x93fb, 0x93fd, 0x9401, 0x9402, 0x9404, 0x9408, 0x9409,
+ 0x940d, 0x940e, 0x940f, 0x9415, 0x9416, 0x9417, 0x941f, 0x942e,
+ 0x942f, 0x9431, 0x9432, 0x9433, 0x9434, 0x943b, 0x943f, 0x943d,
+ 0x9443, 0x9445, 0x9448, 0x944a, 0x944c, 0x9455, 0x9459, 0x945c,
+ 0x945f, 0x9461, 0x9463, 0x9468, 0x946b, 0x946d, 0x946e, 0x946f,
+ 0x9471, 0x9472, 0x9484, 0x9483, 0x9578, 0x9579,
+ /* 0x66 */
+ 0x957e, 0x9584, 0x9588, 0x958c, 0x958d, 0x958e, 0x959d, 0x959e,
+ 0x959f, 0x95a1, 0x95a6, 0x95a9, 0x95ab, 0x95ac, 0x95b4, 0x95b6,
+ 0x95ba, 0x95bd, 0x95bf, 0x95c6, 0x95c8, 0x95c9, 0x95cb, 0x95d0,
+ 0x95d1, 0x95d2, 0x95d3, 0x95d9, 0x95da, 0x95dd, 0x95de, 0x95df,
+ 0x95e0, 0x95e4, 0x95e6, 0x961d, 0x961e, 0x9622, 0x9624, 0x9625,
+ 0x9626, 0x962c, 0x9631, 0x9633, 0x9637, 0x9638, 0x9639, 0x963a,
+ 0x963c, 0x963d, 0x9641, 0x9652, 0x9654, 0x9656, 0x9657, 0x9658,
+ 0x9661, 0x966e, 0x9674, 0x967b, 0x967c, 0x967e, 0x967f, 0x9681,
+ 0x9682, 0x9683, 0x9684, 0x9689, 0x9691, 0x9696, 0x969a, 0x969d,
+ 0x969f, 0x96a4, 0x96a5, 0x96a6, 0x96a9, 0x96ae, 0x96af, 0x96b3,
+ 0x96ba, 0x96ca, 0x96d2, 0x5db2, 0x96d8, 0x96da, 0x96dd, 0x96de,
+ 0x96df, 0x96e9, 0x96ef, 0x96f1, 0x96fa, 0x9702,
+ /* 0x67 */
+ 0x9703, 0x9705, 0x9709, 0x971a, 0x971b, 0x971d, 0x9721, 0x9722,
+ 0x9723, 0x9728, 0x9731, 0x9733, 0x9741, 0x9743, 0x974a, 0x974e,
+ 0x974f, 0x9755, 0x9757, 0x9758, 0x975a, 0x975b, 0x9763, 0x9767,
+ 0x976a, 0x976e, 0x9773, 0x9776, 0x9777, 0x9778, 0x977b, 0x977d,
+ 0x977f, 0x9780, 0x9789, 0x9795, 0x9796, 0x9797, 0x9799, 0x979a,
+ 0x979e, 0x979f, 0x97a2, 0x97ac, 0x97ae, 0x97b1, 0x97b2, 0x97b5,
+ 0x97b6, 0x97b8, 0x97b9, 0x97ba, 0x97bc, 0x97be, 0x97bf, 0x97c1,
+ 0x97c4, 0x97c5, 0x97c7, 0x97c9, 0x97ca, 0x97cc, 0x97cd, 0x97ce,
+ 0x97d0, 0x97d1, 0x97d4, 0x97d7, 0x97d8, 0x97d9, 0x97dd, 0x97de,
+ 0x97e0, 0x97db, 0x97e1, 0x97e4, 0x97ef, 0x97f1, 0x97f4, 0x97f7,
+ 0x97f8, 0x97fa, 0x9807, 0x980a, 0x9819, 0x980d, 0x980e, 0x9814,
+ 0x9816, 0x981c, 0x981e, 0x9820, 0x9823, 0x9826,
+ /* 0x68 */
+ 0x982b, 0x982e, 0x982f, 0x9830, 0x9832, 0x9833, 0x9835, 0x9825,
+ 0x983e, 0x9844, 0x9847, 0x984a, 0x9851, 0x9852, 0x9853, 0x9856,
+ 0x9857, 0x9859, 0x985a, 0x9862, 0x9863, 0x9865, 0x9866, 0x986a,
+ 0x986c, 0x98ab, 0x98ad, 0x98ae, 0x98b0, 0x98b4, 0x98b7, 0x98b8,
+ 0x98ba, 0x98bb, 0x98bf, 0x98c2, 0x98c5, 0x98c8, 0x98cc, 0x98e1,
+ 0x98e3, 0x98e5, 0x98e6, 0x98e7, 0x98ea, 0x98f3, 0x98f6, 0x9902,
+ 0x9907, 0x9908, 0x9911, 0x9915, 0x9916, 0x9917, 0x991a, 0x991b,
+ 0x991c, 0x991f, 0x9922, 0x9926, 0x9927, 0x992b, 0x9931, 0x9932,
+ 0x9933, 0x9934, 0x9935, 0x9939, 0x993a, 0x993b, 0x993c, 0x9940,
+ 0x9941, 0x9946, 0x9947, 0x9948, 0x994d, 0x994e, 0x9954, 0x9958,
+ 0x9959, 0x995b, 0x995c, 0x995e, 0x995f, 0x9960, 0x999b, 0x999d,
+ 0x999f, 0x99a6, 0x99b0, 0x99b1, 0x99b2, 0x99b5,
+ /* 0x69 */
+ 0x99b9, 0x99ba, 0x99bd, 0x99bf, 0x99c3, 0x99c9, 0x99d3, 0x99d4,
+ 0x99d9, 0x99da, 0x99dc, 0x99de, 0x99e7, 0x99ea, 0x99eb, 0x99ec,
+ 0x99f0, 0x99f4, 0x99f5, 0x99f9, 0x99fd, 0x99fe, 0x9a02, 0x9a03,
+ 0x9a04, 0x9a0b, 0x9a0c, 0x9a10, 0x9a11, 0x9a16, 0x9a1e, 0x9a20,
+ 0x9a22, 0x9a23, 0x9a24, 0x9a27, 0x9a2d, 0x9a2e, 0x9a33, 0x9a35,
+ 0x9a36, 0x9a38, 0x9a47, 0x9a41, 0x9a44, 0x9a4a, 0x9a4b, 0x9a4c,
+ 0x9a4e, 0x9a51, 0x9a54, 0x9a56, 0x9a5d, 0x9aaa, 0x9aac, 0x9aae,
+ 0x9aaf, 0x9ab2, 0x9ab4, 0x9ab5, 0x9ab6, 0x9ab9, 0x9abb, 0x9abe,
+ 0x9abf, 0x9ac1, 0x9ac3, 0x9ac6, 0x9ac8, 0x9ace, 0x9ad0, 0x9ad2,
+ 0x9ad5, 0x9ad6, 0x9ad7, 0x9adb, 0x9adc, 0x9ae0, 0x9ae4, 0x9ae5,
+ 0x9ae7, 0x9ae9, 0x9aec, 0x9af2, 0x9af3, 0x9af5, 0x9af9, 0x9afa,
+ 0x9afd, 0x9aff, 0x9b00, 0x9b01, 0x9b02, 0x9b03,
+ /* 0x6a */
+ 0x9b04, 0x9b05, 0x9b08, 0x9b09, 0x9b0b, 0x9b0c, 0x9b0d, 0x9b0e,
+ 0x9b10, 0x9b12, 0x9b16, 0x9b19, 0x9b1b, 0x9b1c, 0x9b20, 0x9b26,
+ 0x9b2b, 0x9b2d, 0x9b33, 0x9b34, 0x9b35, 0x9b37, 0x9b39, 0x9b3a,
+ 0x9b3d, 0x9b48, 0x9b4b, 0x9b4c, 0x9b55, 0x9b56, 0x9b57, 0x9b5b,
+ 0x9b5e, 0x9b61, 0x9b63, 0x9b65, 0x9b66, 0x9b68, 0x9b6a, 0x9b6b,
+ 0x9b6c, 0x9b6d, 0x9b6e, 0x9b73, 0x9b75, 0x9b77, 0x9b78, 0x9b79,
+ 0x9b7f, 0x9b80, 0x9b84, 0x9b85, 0x9b86, 0x9b87, 0x9b89, 0x9b8a,
+ 0x9b8b, 0x9b8d, 0x9b8f, 0x9b90, 0x9b94, 0x9b9a, 0x9b9d, 0x9b9e,
+ 0x9ba6, 0x9ba7, 0x9ba9, 0x9bac, 0x9bb0, 0x9bb1, 0x9bb2, 0x9bb7,
+ 0x9bb8, 0x9bbb, 0x9bbc, 0x9bbe, 0x9bbf, 0x9bc1, 0x9bc7, 0x9bc8,
+ 0x9bce, 0x9bd0, 0x9bd7, 0x9bd8, 0x9bdd, 0x9bdf, 0x9be5, 0x9be7,
+ 0x9bea, 0x9beb, 0x9bef, 0x9bf3, 0x9bf7, 0x9bf8,
+ /* 0x6b */
+ 0x9bf9, 0x9bfa, 0x9bfd, 0x9bff, 0x9c00, 0x9c02, 0x9c0b, 0x9c0f,
+ 0x9c11, 0x9c16, 0x9c18, 0x9c19, 0x9c1a, 0x9c1c, 0x9c1e, 0x9c22,
+ 0x9c23, 0x9c26, 0x9c27, 0x9c28, 0x9c29, 0x9c2a, 0x9c31, 0x9c35,
+ 0x9c36, 0x9c37, 0x9c3d, 0x9c41, 0x9c43, 0x9c44, 0x9c45, 0x9c49,
+ 0x9c4a, 0x9c4e, 0x9c4f, 0x9c50, 0x9c53, 0x9c54, 0x9c56, 0x9c58,
+ 0x9c5b, 0x9c5d, 0x9c5e, 0x9c5f, 0x9c63, 0x9c69, 0x9c6a, 0x9c5c,
+ 0x9c6b, 0x9c68, 0x9c6e, 0x9c70, 0x9c72, 0x9c75, 0x9c77, 0x9c7b,
+ 0x9ce6, 0x9cf2, 0x9cf7, 0x9cf9, 0x9d0b, 0x9d02, 0x9d11, 0x9d17,
+ 0x9d18, 0x9d1c, 0x9d1d, 0x9d1e, 0x9d2f, 0x9d30, 0x9d32, 0x9d33,
+ 0x9d34, 0x9d3a, 0x9d3c, 0x9d45, 0x9d3d, 0x9d42, 0x9d43, 0x9d47,
+ 0x9d4a, 0x9d53, 0x9d54, 0x9d5f, 0x9d63, 0x9d62, 0x9d65, 0x9d69,
+ 0x9d6a, 0x9d6b, 0x9d70, 0x9d76, 0x9d77, 0x9d7b,
+ /* 0x6c */
+ 0x9d7c, 0x9d7e, 0x9d83, 0x9d84, 0x9d86, 0x9d8a, 0x9d8d, 0x9d8e,
+ 0x9d92, 0x9d93, 0x9d95, 0x9d96, 0x9d97, 0x9d98, 0x9da1, 0x9daa,
+ 0x9dac, 0x9dae, 0x9db1, 0x9db5, 0x9db9, 0x9dbc, 0x9dbf, 0x9dc3,
+ 0x9dc7, 0x9dc9, 0x9dca, 0x9dd4, 0x9dd5, 0x9dd6, 0x9dd7, 0x9dda,
+ 0x9dde, 0x9ddf, 0x9de0, 0x9de5, 0x9de7, 0x9de9, 0x9deb, 0x9dee,
+ 0x9df0, 0x9df3, 0x9df4, 0x9dfe, 0x9e0a, 0x9e02, 0x9e07, 0x9e0e,
+ 0x9e10, 0x9e11, 0x9e12, 0x9e15, 0x9e16, 0x9e19, 0x9e1c, 0x9e1d,
+ 0x9e7a, 0x9e7b, 0x9e7c, 0x9e80, 0x9e82, 0x9e83, 0x9e84, 0x9e85,
+ 0x9e87, 0x9e8e, 0x9e8f, 0x9e96, 0x9e98, 0x9e9b, 0x9e9e, 0x9ea4,
+ 0x9ea8, 0x9eac, 0x9eae, 0x9eaf, 0x9eb0, 0x9eb3, 0x9eb4, 0x9eb5,
+ 0x9ec6, 0x9ec8, 0x9ecb, 0x9ed5, 0x9edf, 0x9ee4, 0x9ee7, 0x9eec,
+ 0x9eed, 0x9eee, 0x9ef0, 0x9ef1, 0x9ef2, 0x9ef5,
+ /* 0x6d */
+ 0x9ef8, 0x9eff, 0x9f02, 0x9f03, 0x9f09, 0x9f0f, 0x9f10, 0x9f11,
+ 0x9f12, 0x9f14, 0x9f16, 0x9f17, 0x9f19, 0x9f1a, 0x9f1b, 0x9f1f,
+ 0x9f22, 0x9f26, 0x9f2a, 0x9f2b, 0x9f2f, 0x9f31, 0x9f32, 0x9f34,
+ 0x9f37, 0x9f39, 0x9f3a, 0x9f3c, 0x9f3d, 0x9f3f, 0x9f41, 0x9f43,
+ 0x9f44, 0x9f45, 0x9f46, 0x9f47, 0x9f53, 0x9f55, 0x9f56, 0x9f57,
+ 0x9f58, 0x9f5a, 0x9f5d, 0x9f5e, 0x9f68, 0x9f69, 0x9f6d, 0x9f6e,
+ 0x9f6f, 0x9f70, 0x9f71, 0x9f73, 0x9f75, 0x9f7a, 0x9f7d, 0x9f8f,
+ 0x9f90, 0x9f91, 0x9f92, 0x9f94, 0x9f96, 0x9f97, 0x9f9e, 0x9fa1,
+ 0x9fa2, 0x9fa3, 0x9fa5,
+};
+
+static int
+jisx0212_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c1 = (s[0] & 0x7F);
+ if ((c1 == 0x22) || (c1 >= 0x26 && c1 <= 0x27) || (c1 >= 0x29 && c1 <= 0x2b) || (c1 >= 0x30 && c1 <= 0x6d)) {
+ if (n >= 2) {
+ unsigned char c2 = (s[1] & 0x7F);
+ if (c2 >= 0x21 && c2 < 0x7f) {
+ unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21);
+ unsigned short wc = 0xfffd;
+ if (i < 470) {
+ if (i < 175)
+ wc = jisx0212_2uni_page22[i-94];
+ } else if (i < 752) {
+ if (i < 658)
+ wc = jisx0212_2uni_page26[i-470];
+ } else if (i < 1410) {
+ if (i < 1027)
+ wc = jisx0212_2uni_page29[i-752];
+ } else {
+ if (i < 7211)
+ wc = jisx0212_2uni_page30[i-1410];
+ }
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 2;
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOFEW(0);
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned short jisx0212_2charset[6067] = {
+ 0x2237, 0x2242, 0x2270, 0x2243, 0x226d, 0x226c, 0x226e, 0x2234,
+ 0x2231, 0x226b, 0x2244, 0x2a22, 0x2a21, 0x2a24, 0x2a2a, 0x2a23,
+ 0x2a29, 0x2921, 0x2a2e, 0x2a32, 0x2a31, 0x2a34, 0x2a33, 0x2a40,
+ 0x2a3f, 0x2a42, 0x2a41, 0x2a50, 0x2a52, 0x2a51, 0x2a54, 0x2a58,
+ 0x2a53, 0x292c, 0x2a63, 0x2a62, 0x2a65, 0x2a64, 0x2a72, 0x2930,
+ 0x294e, 0x2b22, 0x2b21, 0x2b24, 0x2b2a, 0x2b23, 0x2b29, 0x2941,
+ 0x2b2e, 0x2b32, 0x2b31, 0x2b34, 0x2b33, 0x2b40, 0x2b3f, 0x2b42,
+ 0x2b41, 0x2943, 0x2b50, 0x2b52, 0x2b51, 0x2b54, 0x2b58, 0x2b53,
+ 0x294c, 0x2b63, 0x2b62, 0x2b65, 0x2b64, 0x2b72, 0x2950, 0x2b73,
+ 0x2a27, 0x2b27, 0x2a25, 0x2b25, 0x2a28, 0x2b28, 0x2a2b, 0x2b2b,
+ 0x2a2c, 0x2b2c, 0x2a2f, 0x2b2f, 0x2a2d, 0x2b2d, 0x2a30, 0x2b30,
+ 0x2922, 0x2942, 0x2a37, 0x2b37, 0x2a36, 0x2b36, 0x2a38, 0x2b38,
+ 0x2a35, 0x2b35, 0x2a3a, 0x2b3a, 0x2a3b, 0x2b3b, 0x2a3d, 0x2b3d,
+ 0x2a3c, 0x2a3e, 0x2b3e, 0x2924, 0x2944, 0x2a47, 0x2b47, 0x2a45,
+ 0x2b45, 0x2a46, 0x2b46, 0x2a44, 0x2945, 0x2926, 0x2946, 0x2a48,
+ 0x2b48, 0x2a49, 0x2b49, 0x2947, 0x2a4a, 0x2b4a, 0x2a4c, 0x2b4c,
+ 0x2a4b, 0x2b4b, 0x2929, 0x2949, 0x2928, 0x2948, 0x2a4d, 0x2b4d,
+ 0x2a4f, 0x2b4f, 0x2a4e, 0x2b4e, 0x294a, 0x292b, 0x294b, 0x2a57,
+ 0x2b57, 0x2a56, 0x2b56, 0x292d, 0x294d, 0x2a59, 0x2b59, 0x2a5b,
+ 0x2b5b, 0x2a5a, 0x2b5a, 0x2a5c, 0x2b5c, 0x2a5d, 0x2b5d, 0x2a5f,
+ 0x2b5f, 0x2a5e, 0x2b5e, 0x2a61, 0x2b61, 0x2a60, 0x2b60, 0x292f,
+ 0x294f, 0x2a6c, 0x2b6c, 0x2a69, 0x2b69, 0x2a66, 0x2b66, 0x2a6b,
+ 0x2b6b, 0x2a68, 0x2b68, 0x2a6a, 0x2b6a, 0x2a71, 0x2b71, 0x2a74,
+ 0x2b74, 0x2a73, 0x2a75, 0x2b75, 0x2a77, 0x2b77, 0x2a76, 0x2b76,
+ 0x2a26, 0x2b26, 0x2a43, 0x2b43, 0x2a55, 0x2b55, 0x2a67, 0x2b67,
+ 0x2a70, 0x2b70, 0x2a6d, 0x2b6d, 0x2a6f, 0x2b6f, 0x2a6e, 0x2b6e,
+ 0x2b39, 0x2230, 0x222f, 0x2232, 0x2236, 0x2235, 0x2233, 0x2238,
+ 0x2239, 0x2661, 0x2662, 0x2663, 0x2664, 0x2667, 0x2669, 0x266c,
+ 0x2676, 0x2665, 0x266a, 0x2671, 0x2672, 0x2673, 0x2674, 0x267b,
+ 0x2678, 0x2675, 0x267a, 0x2677, 0x2679, 0x267c, 0x2742, 0x2743,
+ 0x2744, 0x2745, 0x2746, 0x2747, 0x2748, 0x2749, 0x274a, 0x274b,
+ 0x274c, 0x274d, 0x274e, 0x2772, 0x2773, 0x2774, 0x2775, 0x2776,
+ 0x2777, 0x2778, 0x2779, 0x277a, 0x277b, 0x277c, 0x277d, 0x277e,
+ 0x2271, 0x226f, 0x3021, 0x3022, 0x3023, 0x3024, 0x3025, 0x3026,
+ 0x3027, 0x3028, 0x3029, 0x302a, 0x302b, 0x302c, 0x302d, 0x302e,
+ 0x302f, 0x3030, 0x3031, 0x3032, 0x3033, 0x3034, 0x3035, 0x3036,
+ 0x3037, 0x3038, 0x3039, 0x303a, 0x303b, 0x303c, 0x303d, 0x303e,
+ 0x303f, 0x3040, 0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046,
+ 0x3047, 0x3048, 0x3049, 0x304a, 0x304b, 0x304c, 0x304d, 0x304e,
+ 0x304f, 0x3050, 0x3051, 0x3052, 0x3053, 0x3054, 0x3055, 0x3056,
+ 0x3057, 0x3058, 0x3059, 0x305a, 0x305b, 0x305c, 0x305d, 0x305e,
+ 0x3060, 0x3061, 0x3062, 0x3063, 0x3064, 0x3065, 0x3066, 0x3067,
+ 0x3068, 0x3069, 0x306a, 0x306b, 0x306c, 0x306d, 0x306e, 0x306f,
+ 0x3070, 0x305f, 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076,
+ 0x3077, 0x3078, 0x3079, 0x307a, 0x307b, 0x307c, 0x307d, 0x307e,
+ 0x3121, 0x3122, 0x3123, 0x3124, 0x3125, 0x3126, 0x3127, 0x3128,
+ 0x3129, 0x312a, 0x312b, 0x312c, 0x312d, 0x312e, 0x312f, 0x3130,
+ 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137, 0x3138,
+ 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f, 0x3140,
+ 0x3141, 0x3142, 0x3143, 0x3144, 0x3145, 0x3146, 0x3147, 0x3148,
+ 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e, 0x314f, 0x3150,
+ 0x3151, 0x3152, 0x3153, 0x3154, 0x3155, 0x3156, 0x3157, 0x3158,
+ 0x3159, 0x315a, 0x315b, 0x315c, 0x315d, 0x315e, 0x3176, 0x315f,
+ 0x3160, 0x3161, 0x3162, 0x3163, 0x3164, 0x3165, 0x3166, 0x3167,
+ 0x3168, 0x3169, 0x316a, 0x316b, 0x316c, 0x316d, 0x316e, 0x316f,
+ 0x3170, 0x3171, 0x3172, 0x3173, 0x3174, 0x3175, 0x3177, 0x3178,
+ 0x3179, 0x317a, 0x317b, 0x317c, 0x317d, 0x317e, 0x3221, 0x3222,
+ 0x3223, 0x3224, 0x3225, 0x3226, 0x3227, 0x3228, 0x3229, 0x322a,
+ 0x322b, 0x322c, 0x322d, 0x322e, 0x322f, 0x3230, 0x3231, 0x3232,
+ 0x3233, 0x3234, 0x3235, 0x3236, 0x3237, 0x3238, 0x3239, 0x323a,
+ 0x323b, 0x323c, 0x323d, 0x323e, 0x323f, 0x3240, 0x3241, 0x3242,
+ 0x3243, 0x3244, 0x3245, 0x3251, 0x3246, 0x3247, 0x3248, 0x3249,
+ 0x324a, 0x324b, 0x324c, 0x324d, 0x324e, 0x324f, 0x3250, 0x3252,
+ 0x3253, 0x3254, 0x3255, 0x3256, 0x3257, 0x3258, 0x3259, 0x325a,
+ 0x325b, 0x325c, 0x325d, 0x325e, 0x325f, 0x3260, 0x3261, 0x3262,
+ 0x3263, 0x3264, 0x3265, 0x3266, 0x3267, 0x3268, 0x3269, 0x326a,
+ 0x326b, 0x326c, 0x326d, 0x326e, 0x326f, 0x3270, 0x3271, 0x3272,
+ 0x3273, 0x3274, 0x3275, 0x3276, 0x3277, 0x3278, 0x3279, 0x327a,
+ 0x327b, 0x327c, 0x327d, 0x327e, 0x3321, 0x3322, 0x3323, 0x3324,
+ 0x3325, 0x3326, 0x3327, 0x3328, 0x3329, 0x332a, 0x332b, 0x332c,
+ 0x332d, 0x332e, 0x332f, 0x3330, 0x3331, 0x3332, 0x3333, 0x3334,
+ 0x3335, 0x3336, 0x3337, 0x3338, 0x3339, 0x333a, 0x333b, 0x333c,
+ 0x333d, 0x333e, 0x333f, 0x3340, 0x3341, 0x3342, 0x3343, 0x3344,
+ 0x3345, 0x3346, 0x3347, 0x3348, 0x3349, 0x334a, 0x334b, 0x334c,
+ 0x334d, 0x334e, 0x334f, 0x3350, 0x3351, 0x3352, 0x3353, 0x3354,
+ 0x3355, 0x3356, 0x3357, 0x3358, 0x3359, 0x335a, 0x335b, 0x335c,
+ 0x335d, 0x335e, 0x335f, 0x3360, 0x3361, 0x3362, 0x3363, 0x3364,
+ 0x3365, 0x3366, 0x3367, 0x3368, 0x3369, 0x336a, 0x336b, 0x336c,
+ 0x336d, 0x336e, 0x336f, 0x3370, 0x3371, 0x3372, 0x3373, 0x3374,
+ 0x3375, 0x3376, 0x3377, 0x3378, 0x3379, 0x337a, 0x337b, 0x337c,
+ 0x337d, 0x337e, 0x3421, 0x3422, 0x3423, 0x3424, 0x3425, 0x3426,
+ 0x3427, 0x3428, 0x3429, 0x342a, 0x342b, 0x342c, 0x342d, 0x342e,
+ 0x342f, 0x3430, 0x3431, 0x3432, 0x3433, 0x3434, 0x3435, 0x3436,
+ 0x3438, 0x3437, 0x3439, 0x343a, 0x343b, 0x343c, 0x343d, 0x343e,
+ 0x343f, 0x3440, 0x3441, 0x3442, 0x3443, 0x3444, 0x3445, 0x3446,
+ 0x3447, 0x3448, 0x3449, 0x344a, 0x344b, 0x344c, 0x344d, 0x344e,
+ 0x344f, 0x3450, 0x3451, 0x3452, 0x3453, 0x3454, 0x3455, 0x3456,
+ 0x3457, 0x3458, 0x3459, 0x345a, 0x345b, 0x345c, 0x345d, 0x345e,
+ 0x345f, 0x3460, 0x3461, 0x3462, 0x3463, 0x3464, 0x3465, 0x3466,
+ 0x3467, 0x3468, 0x3469, 0x346a, 0x346b, 0x346c, 0x346d, 0x346e,
+ 0x346f, 0x3470, 0x3471, 0x3472, 0x3473, 0x3474, 0x3475, 0x3476,
+ 0x3477, 0x3478, 0x3479, 0x347a, 0x347b, 0x347c, 0x347d, 0x347e,
+ 0x3521, 0x3522, 0x3523, 0x3524, 0x3525, 0x3526, 0x3527, 0x3528,
+ 0x3529, 0x352a, 0x352b, 0x352c, 0x352d, 0x352e, 0x352f, 0x3530,
+ 0x3531, 0x3532, 0x3533, 0x3534, 0x3535, 0x3536, 0x3537, 0x3538,
+ 0x3539, 0x353a, 0x353b, 0x353c, 0x353d, 0x353e, 0x353f, 0x3540,
+ 0x3541, 0x3542, 0x3543, 0x3544, 0x3545, 0x3546, 0x3547, 0x3548,
+ 0x3549, 0x354a, 0x354b, 0x354c, 0x354d, 0x354e, 0x354f, 0x3550,
+ 0x3551, 0x3552, 0x3553, 0x3554, 0x3555, 0x3556, 0x3557, 0x3558,
+ 0x3559, 0x355a, 0x355b, 0x355c, 0x355d, 0x355e, 0x355f, 0x3560,
+ 0x3561, 0x3562, 0x3563, 0x3564, 0x3565, 0x3566, 0x3567, 0x3568,
+ 0x3569, 0x356a, 0x356b, 0x356c, 0x356d, 0x356e, 0x356f, 0x3570,
+ 0x3571, 0x3572, 0x3573, 0x3574, 0x3575, 0x3576, 0x3577, 0x3578,
+ 0x3579, 0x357a, 0x357b, 0x357c, 0x357d, 0x357e, 0x3621, 0x3622,
+ 0x3623, 0x3624, 0x3625, 0x3626, 0x3627, 0x3628, 0x3629, 0x362a,
+ 0x362b, 0x362c, 0x362d, 0x362e, 0x362f, 0x3630, 0x3631, 0x3632,
+ 0x3633, 0x3634, 0x3635, 0x3636, 0x3637, 0x3638, 0x3639, 0x363a,
+ 0x363b, 0x363c, 0x363d, 0x363e, 0x363f, 0x3640, 0x3641, 0x3642,
+ 0x3643, 0x3644, 0x3645, 0x3646, 0x3647, 0x3648, 0x3649, 0x364a,
+ 0x364b, 0x364c, 0x364d, 0x364e, 0x364f, 0x3650, 0x3651, 0x3652,
+ 0x3653, 0x3654, 0x3655, 0x3656, 0x3657, 0x3658, 0x3659, 0x365a,
+ 0x365b, 0x365c, 0x365d, 0x365e, 0x365f, 0x3660, 0x3661, 0x3662,
+ 0x3663, 0x3664, 0x3665, 0x3666, 0x3667, 0x3668, 0x3669, 0x366a,
+ 0x366b, 0x366c, 0x366d, 0x3670, 0x3671, 0x366e, 0x366f, 0x3672,
+ 0x3673, 0x3674, 0x3675, 0x3676, 0x3677, 0x3678, 0x3679, 0x367a,
+ 0x367b, 0x367d, 0x367e, 0x367c, 0x3721, 0x3722, 0x3723, 0x3724,
+ 0x3725, 0x3726, 0x3727, 0x3728, 0x3729, 0x372a, 0x372b, 0x372c,
+ 0x372d, 0x372e, 0x372f, 0x3730, 0x3731, 0x3732, 0x3733, 0x3734,
+ 0x3735, 0x3736, 0x3737, 0x3738, 0x3739, 0x373a, 0x373b, 0x373c,
+ 0x373d, 0x373e, 0x373f, 0x3740, 0x3741, 0x3742, 0x3743, 0x3744,
+ 0x3745, 0x3746, 0x3747, 0x3748, 0x3749, 0x374a, 0x374b, 0x374c,
+ 0x374d, 0x374e, 0x374f, 0x3750, 0x3751, 0x3752, 0x3753, 0x3754,
+ 0x3755, 0x3756, 0x3757, 0x3760, 0x3758, 0x3759, 0x375a, 0x375b,
+ 0x375c, 0x375d, 0x375e, 0x375f, 0x3761, 0x3762, 0x3763, 0x3764,
+ 0x3765, 0x3766, 0x3767, 0x3768, 0x3769, 0x376a, 0x376b, 0x376c,
+ 0x376d, 0x377e, 0x376e, 0x376f, 0x3770, 0x3771, 0x3772, 0x3773,
+ 0x3774, 0x3775, 0x3776, 0x3777, 0x3778, 0x3779, 0x377a, 0x377b,
+ 0x377c, 0x377d, 0x3821, 0x3822, 0x3823, 0x3824, 0x3825, 0x3826,
+ 0x3827, 0x3828, 0x3829, 0x382a, 0x382b, 0x382c, 0x382d, 0x382e,
+ 0x382f, 0x3830, 0x3831, 0x3832, 0x3833, 0x3834, 0x3835, 0x3836,
+ 0x3837, 0x3838, 0x3839, 0x383a, 0x383b, 0x383c, 0x383d, 0x383e,
+ 0x383f, 0x3840, 0x3841, 0x3842, 0x3843, 0x3844, 0x3845, 0x3846,
+ 0x3847, 0x3848, 0x3849, 0x384a, 0x384b, 0x384c, 0x384d, 0x384e,
+ 0x3850, 0x3851, 0x384f, 0x3852, 0x3853, 0x3854, 0x3855, 0x3856,
+ 0x3857, 0x3858, 0x3859, 0x385a, 0x385b, 0x385c, 0x385d, 0x385e,
+ 0x385f, 0x3860, 0x3861, 0x3862, 0x3863, 0x3864, 0x3865, 0x3867,
+ 0x3868, 0x3869, 0x386a, 0x386b, 0x386c, 0x386d, 0x386e, 0x386f,
+ 0x3870, 0x3871, 0x3872, 0x3873, 0x3874, 0x3875, 0x3876, 0x3877,
+ 0x3878, 0x3879, 0x387a, 0x387b, 0x387c, 0x387d, 0x387e, 0x3921,
+ 0x3922, 0x3923, 0x3924, 0x3925, 0x3926, 0x3927, 0x3928, 0x3929,
+ 0x392a, 0x392b, 0x392c, 0x392d, 0x392e, 0x392f, 0x3930, 0x3931,
+ 0x3932, 0x3933, 0x3934, 0x3935, 0x3936, 0x3937, 0x3938, 0x3939,
+ 0x393a, 0x393b, 0x393c, 0x393d, 0x393e, 0x393f, 0x3940, 0x3941,
+ 0x3942, 0x3943, 0x3944, 0x3945, 0x3946, 0x3947, 0x3948, 0x3949,
+ 0x394a, 0x394b, 0x394c, 0x394d, 0x394e, 0x394f, 0x3950, 0x3951,
+ 0x3952, 0x3953, 0x3954, 0x3955, 0x3956, 0x3957, 0x3958, 0x3959,
+ 0x395a, 0x395b, 0x395c, 0x395d, 0x395e, 0x395f, 0x3960, 0x3961,
+ 0x3962, 0x3963, 0x3964, 0x3965, 0x3966, 0x3967, 0x3968, 0x3969,
+ 0x396a, 0x396b, 0x396c, 0x396d, 0x396e, 0x396f, 0x3970, 0x3971,
+ 0x3972, 0x3973, 0x3974, 0x3975, 0x3976, 0x3977, 0x3978, 0x3979,
+ 0x397a, 0x397b, 0x397c, 0x397d, 0x397e, 0x3a21, 0x3a22, 0x3a23,
+ 0x3a24, 0x3a25, 0x3a26, 0x3a27, 0x3a28, 0x3a29, 0x3a2a, 0x3a2b,
+ 0x3a2c, 0x3a2d, 0x3a2e, 0x3a2f, 0x3a30, 0x3a31, 0x3a33, 0x3a34,
+ 0x3a35, 0x3a36, 0x3a37, 0x3a38, 0x3a32, 0x3a39, 0x3a3a, 0x3a3b,
+ 0x3a3c, 0x3a3d, 0x3a3e, 0x3a3f, 0x3a40, 0x3a41, 0x3a42, 0x3a43,
+ 0x3a44, 0x3a45, 0x3a46, 0x3a47, 0x3a48, 0x3a49, 0x3a4a, 0x3a4b,
+ 0x3a4c, 0x3a4d, 0x3a4e, 0x3a4f, 0x3a50, 0x3a51, 0x3a52, 0x3a53,
+ 0x3a54, 0x3a55, 0x3a56, 0x3a57, 0x3a58, 0x3a59, 0x3a5a, 0x3a5b,
+ 0x3a5c, 0x3a5d, 0x3a5e, 0x3a5f, 0x3a60, 0x3a61, 0x3a62, 0x3a63,
+ 0x3a64, 0x3a65, 0x3a66, 0x3a67, 0x3a68, 0x3a69, 0x3a6a, 0x3a6b,
+ 0x3a6c, 0x3a6d, 0x3a6e, 0x3a6f, 0x3a70, 0x3a71, 0x3a72, 0x3a73,
+ 0x3a74, 0x3a75, 0x3a76, 0x3a77, 0x3a78, 0x3a79, 0x3a7a, 0x3a7b,
+ 0x3a7c, 0x3a7d, 0x3a7e, 0x3b21, 0x3b22, 0x3b23, 0x3b24, 0x3b25,
+ 0x3b26, 0x3b27, 0x3b28, 0x3b29, 0x3b2a, 0x3b2b, 0x3b2c, 0x3b2d,
+ 0x3b2e, 0x3b2f, 0x3b30, 0x3b31, 0x3b32, 0x3b33, 0x3b34, 0x3b35,
+ 0x3b36, 0x3b37, 0x3b38, 0x3b39, 0x3b3a, 0x3b3b, 0x3b3d, 0x3b3c,
+ 0x3b3e, 0x3b3f, 0x3b40, 0x3b41, 0x3b42, 0x3b43, 0x3b44, 0x3b45,
+ 0x3b47, 0x3b48, 0x3b49, 0x3b4a, 0x3b46, 0x3b4b, 0x3b4c, 0x3b4d,
+ 0x3b4e, 0x3b4f, 0x3b50, 0x3b51, 0x3b52, 0x3b53, 0x3b57, 0x3b55,
+ 0x3b54, 0x3b56, 0x3b58, 0x3b59, 0x3b5a, 0x3b5b, 0x3b5c, 0x3b5d,
+ 0x3b5e, 0x3b5f, 0x3b60, 0x3b61, 0x3b62, 0x3b63, 0x3b64, 0x3b65,
+ 0x3b66, 0x3b67, 0x3b68, 0x3b69, 0x3b6a, 0x3b6b, 0x3b6c, 0x3b6d,
+ 0x3b6e, 0x3b6f, 0x3b70, 0x3b71, 0x3b72, 0x6674, 0x3b73, 0x3b74,
+ 0x3b75, 0x3b76, 0x3b77, 0x3b78, 0x3b7a, 0x3b79, 0x3b7b, 0x3b7c,
+ 0x3b7d, 0x3b7e, 0x3c21, 0x3c22, 0x3c23, 0x3c24, 0x3c25, 0x3c26,
+ 0x3c27, 0x3c28, 0x3c29, 0x3c2a, 0x3c2b, 0x3c2c, 0x3c2e, 0x3c2d,
+ 0x3c2f, 0x3c30, 0x3c31, 0x3c34, 0x3c32, 0x3c33, 0x3c35, 0x3c36,
+ 0x3c37, 0x3c38, 0x3c39, 0x3c3a, 0x3c3b, 0x3c3c, 0x3c3d, 0x3c3e,
+ 0x3c3f, 0x3c40, 0x3c41, 0x3c42, 0x3c43, 0x3c44, 0x3c45, 0x3c46,
+ 0x3c47, 0x3c48, 0x3c49, 0x3c4a, 0x3c4b, 0x3c4c, 0x3c4d, 0x3c4e,
+ 0x3c4f, 0x3c50, 0x3c52, 0x3c51, 0x3c53, 0x3c54, 0x3c55, 0x3c56,
+ 0x3c57, 0x3c58, 0x3c59, 0x3c5a, 0x3c5b, 0x3c5c, 0x3c5d, 0x3c5e,
+ 0x3c5f, 0x3c60, 0x3c61, 0x3c62, 0x3c63, 0x3c64, 0x3c65, 0x3c66,
+ 0x3c67, 0x3c68, 0x3c69, 0x3c6a, 0x3c6b, 0x3c6c, 0x3c6d, 0x3c6e,
+ 0x3c6f, 0x3c70, 0x3c71, 0x3c72, 0x3c73, 0x3c74, 0x3c75, 0x3c76,
+ 0x3c77, 0x3c78, 0x3c79, 0x3c7a, 0x3c7b, 0x3c7c, 0x3c7d, 0x3c7e,
+ 0x3d21, 0x3d22, 0x3d23, 0x3d24, 0x3d25, 0x3d26, 0x3d27, 0x3d28,
+ 0x3d29, 0x3d2a, 0x3d2b, 0x3d2c, 0x3d2d, 0x3d2e, 0x3d2f, 0x3d32,
+ 0x3d30, 0x3d31, 0x3d33, 0x3d34, 0x3d35, 0x3d36, 0x3d37, 0x3d38,
+ 0x3d39, 0x3d3a, 0x3d3b, 0x3d3c, 0x3d3d, 0x3d3e, 0x3d3f, 0x3d40,
+ 0x3d41, 0x3d42, 0x3d43, 0x3d44, 0x3d45, 0x3d46, 0x3d47, 0x3d48,
+ 0x3d49, 0x3d4a, 0x3d4b, 0x3d4c, 0x3d4d, 0x3d4e, 0x3d4f, 0x3d50,
+ 0x3d51, 0x3d52, 0x3d53, 0x3d54, 0x3d55, 0x3d56, 0x3d57, 0x3d58,
+ 0x3d59, 0x3d5a, 0x3d5b, 0x3d5c, 0x3d5d, 0x3d5e, 0x3d5f, 0x3d60,
+ 0x3d61, 0x3d62, 0x3d63, 0x3d64, 0x3d65, 0x3d66, 0x3d67, 0x3d68,
+ 0x3d69, 0x3d6a, 0x3d6b, 0x3d6c, 0x3d6d, 0x3d6e, 0x3d6f, 0x3d70,
+ 0x3d71, 0x3d72, 0x3d73, 0x3d74, 0x3d75, 0x3d76, 0x3d77, 0x3d78,
+ 0x3d79, 0x3d7a, 0x3d7b, 0x3d7c, 0x3d7d, 0x3d7e, 0x3e21, 0x3e22,
+ 0x3e23, 0x3e24, 0x3e25, 0x3e26, 0x3e27, 0x3e28, 0x3e29, 0x3e2a,
+ 0x3e2b, 0x3e2c, 0x3e2d, 0x3e2e, 0x3e2f, 0x3e30, 0x3e31, 0x3e32,
+ 0x3e33, 0x3e34, 0x3e35, 0x3e36, 0x3e37, 0x3e38, 0x3e39, 0x3e3a,
+ 0x3e3b, 0x3e3c, 0x3e3d, 0x3e3e, 0x3e3f, 0x3e40, 0x3e41, 0x3e42,
+ 0x3e43, 0x3e44, 0x3e45, 0x3e46, 0x3e47, 0x3e48, 0x3e49, 0x3e4a,
+ 0x3e4b, 0x3e4c, 0x3e4d, 0x3e4e, 0x3e4f, 0x3e50, 0x3e51, 0x3e52,
+ 0x3e53, 0x3e54, 0x3e55, 0x3e56, 0x3e57, 0x3e58, 0x3e59, 0x3e5a,
+ 0x3e5b, 0x3e5c, 0x3e5d, 0x3e5e, 0x3e5f, 0x3e60, 0x3e61, 0x3e62,
+ 0x3e63, 0x3e64, 0x3e65, 0x3e66, 0x3e67, 0x3e68, 0x3e69, 0x3e6a,
+ 0x3e6b, 0x3e6c, 0x3e6d, 0x3e6e, 0x3e6f, 0x3e70, 0x3e71, 0x3e72,
+ 0x3e73, 0x3e74, 0x3e75, 0x3e76, 0x3e77, 0x3e78, 0x3e79, 0x3e7a,
+ 0x3e7b, 0x3e7e, 0x3e7c, 0x3e7d, 0x3f21, 0x3f22, 0x3f23, 0x3f24,
+ 0x3f25, 0x3f26, 0x3f27, 0x3f28, 0x3f29, 0x3f2a, 0x3f2b, 0x3f2c,
+ 0x3f2d, 0x3f2e, 0x3f2f, 0x3f30, 0x3f31, 0x3f32, 0x3f33, 0x3f34,
+ 0x3f35, 0x3f36, 0x3f37, 0x3f38, 0x3f39, 0x3f3a, 0x3f3b, 0x3f3c,
+ 0x3f3d, 0x3f3e, 0x3f3f, 0x3f40, 0x3f41, 0x3f42, 0x3f43, 0x3f44,
+ 0x3f45, 0x3f46, 0x3f47, 0x3f48, 0x3f49, 0x3f4a, 0x3f4b, 0x3f4c,
+ 0x3f4d, 0x3f4e, 0x3f4f, 0x3f50, 0x3f51, 0x3f52, 0x3f53, 0x3f54,
+ 0x3f55, 0x3f56, 0x3f57, 0x3f58, 0x3f59, 0x3f5a, 0x3f5b, 0x3f5c,
+ 0x3f5d, 0x3f5e, 0x3f5f, 0x3f60, 0x3f61, 0x3f62, 0x3f63, 0x3f64,
+ 0x3f65, 0x3f66, 0x3f67, 0x3f68, 0x3f69, 0x3f6a, 0x3f6b, 0x3f6c,
+ 0x3f6d, 0x3f6e, 0x3f6f, 0x3f70, 0x3f71, 0x3f72, 0x3f73, 0x3f74,
+ 0x3f75, 0x3f76, 0x3f77, 0x3f78, 0x3f79, 0x3f7a, 0x3f7b, 0x3f7c,
+ 0x3f7d, 0x3f7e, 0x4021, 0x4022, 0x4023, 0x4024, 0x4025, 0x4026,
+ 0x4027, 0x4028, 0x4029, 0x402a, 0x402b, 0x402c, 0x402d, 0x402e,
+ 0x402f, 0x4030, 0x4031, 0x4032, 0x4033, 0x4034, 0x4035, 0x4036,
+ 0x4037, 0x4038, 0x4039, 0x403a, 0x403b, 0x403c, 0x403d, 0x403e,
+ 0x403f, 0x4040, 0x4041, 0x4042, 0x4043, 0x4044, 0x4045, 0x4046,
+ 0x4047, 0x4048, 0x4049, 0x404a, 0x404b, 0x404c, 0x404d, 0x404e,
+ 0x404f, 0x4050, 0x4051, 0x4052, 0x4053, 0x4054, 0x4055, 0x4056,
+ 0x4057, 0x4058, 0x4059, 0x405a, 0x405b, 0x405c, 0x405d, 0x405e,
+ 0x405f, 0x4060, 0x4061, 0x4062, 0x4063, 0x4064, 0x4065, 0x4066,
+ 0x4067, 0x4068, 0x4069, 0x406a, 0x406b, 0x406c, 0x406d, 0x406e,
+ 0x406f, 0x4070, 0x4071, 0x4072, 0x4073, 0x4074, 0x4075, 0x4076,
+ 0x4077, 0x4078, 0x4079, 0x407a, 0x407b, 0x407c, 0x407d, 0x407e,
+ 0x4121, 0x4122, 0x4123, 0x4124, 0x4125, 0x4126, 0x4127, 0x4128,
+ 0x4129, 0x412a, 0x412b, 0x412c, 0x412d, 0x412e, 0x412f, 0x4130,
+ 0x4131, 0x4132, 0x4133, 0x4134, 0x4135, 0x4136, 0x4137, 0x4138,
+ 0x4139, 0x413a, 0x413b, 0x413c, 0x413d, 0x413e, 0x413f, 0x4140,
+ 0x4141, 0x4142, 0x4143, 0x4144, 0x4145, 0x4146, 0x4147, 0x4148,
+ 0x4149, 0x414a, 0x414b, 0x414c, 0x414d, 0x414e, 0x414f, 0x4150,
+ 0x4151, 0x4152, 0x4153, 0x4154, 0x4155, 0x4156, 0x4157, 0x4158,
+ 0x4159, 0x415a, 0x415b, 0x415c, 0x415d, 0x415e, 0x415f, 0x4160,
+ 0x4161, 0x4162, 0x4163, 0x4164, 0x4165, 0x4166, 0x4167, 0x4168,
+ 0x4169, 0x416a, 0x416b, 0x416c, 0x416d, 0x416e, 0x416f, 0x4170,
+ 0x4171, 0x4172, 0x4173, 0x4174, 0x4175, 0x4176, 0x4177, 0x4178,
+ 0x4179, 0x417a, 0x417b, 0x417c, 0x417d, 0x417e, 0x4221, 0x4222,
+ 0x4223, 0x4224, 0x4225, 0x4226, 0x4227, 0x4228, 0x4229, 0x422a,
+ 0x422b, 0x422c, 0x422d, 0x422e, 0x4230, 0x422f, 0x4231, 0x4232,
+ 0x4233, 0x4234, 0x4235, 0x4237, 0x4236, 0x4238, 0x4239, 0x423a,
+ 0x423b, 0x423c, 0x423d, 0x423e, 0x4240, 0x4241, 0x4242, 0x4244,
+ 0x4245, 0x4247, 0x4248, 0x4249, 0x424a, 0x424c, 0x4243, 0x4246,
+ 0x424b, 0x424d, 0x424e, 0x424f, 0x4250, 0x4251, 0x4252, 0x4253,
+ 0x4254, 0x4255, 0x4256, 0x4257, 0x4258, 0x4259, 0x425a, 0x425b,
+ 0x425c, 0x425d, 0x425e, 0x425f, 0x4260, 0x4261, 0x4262, 0x4263,
+ 0x4264, 0x4265, 0x4266, 0x4267, 0x4268, 0x4269, 0x426a, 0x426b,
+ 0x426c, 0x426d, 0x423f, 0x426e, 0x426f, 0x4270, 0x4271, 0x4272,
+ 0x4273, 0x4274, 0x4275, 0x4276, 0x4277, 0x4278, 0x4279, 0x427a,
+ 0x427b, 0x427c, 0x427d, 0x427e, 0x4321, 0x4322, 0x4323, 0x4324,
+ 0x4325, 0x4326, 0x4327, 0x4328, 0x4329, 0x432a, 0x432b, 0x432c,
+ 0x432d, 0x432e, 0x432f, 0x4330, 0x4331, 0x4332, 0x4333, 0x4334,
+ 0x4335, 0x4336, 0x4337, 0x4339, 0x433a, 0x433b, 0x433c, 0x433d,
+ 0x433e, 0x433f, 0x4340, 0x4341, 0x4342, 0x4343, 0x4344, 0x4345,
+ 0x4346, 0x4347, 0x4348, 0x4338, 0x434a, 0x434b, 0x434c, 0x434d,
+ 0x434f, 0x434e, 0x4350, 0x4351, 0x4352, 0x4353, 0x4354, 0x4355,
+ 0x4356, 0x4357, 0x4358, 0x4359, 0x435a, 0x435b, 0x4349, 0x435c,
+ 0x435d, 0x435e, 0x435f, 0x4360, 0x4361, 0x4362, 0x4363, 0x4364,
+ 0x4365, 0x4366, 0x4367, 0x4368, 0x4369, 0x436a, 0x436b, 0x436c,
+ 0x436d, 0x436e, 0x436f, 0x4370, 0x4371, 0x4372, 0x4373, 0x4374,
+ 0x4375, 0x4376, 0x4377, 0x4378, 0x4379, 0x437a, 0x437b, 0x437c,
+ 0x437d, 0x437e, 0x4421, 0x4422, 0x4423, 0x4424, 0x4425, 0x4426,
+ 0x4427, 0x4428, 0x4429, 0x442a, 0x442b, 0x442c, 0x442d, 0x442e,
+ 0x442f, 0x4430, 0x4431, 0x4432, 0x4433, 0x4434, 0x4435, 0x4436,
+ 0x4437, 0x4438, 0x4439, 0x443a, 0x443b, 0x443c, 0x443d, 0x443e,
+ 0x443f, 0x4440, 0x4441, 0x4442, 0x4443, 0x4444, 0x4445, 0x4446,
+ 0x4447, 0x4448, 0x4449, 0x444a, 0x444b, 0x444c, 0x444d, 0x444e,
+ 0x444f, 0x4450, 0x4451, 0x4452, 0x4453, 0x4454, 0x4455, 0x4456,
+ 0x4457, 0x4458, 0x4459, 0x445a, 0x445b, 0x445c, 0x445d, 0x445e,
+ 0x445f, 0x4460, 0x4461, 0x4462, 0x4463, 0x4464, 0x4465, 0x4466,
+ 0x4467, 0x4468, 0x4469, 0x446a, 0x446b, 0x446c, 0x446d, 0x446e,
+ 0x446f, 0x4470, 0x4471, 0x4472, 0x4473, 0x4474, 0x4475, 0x4476,
+ 0x4477, 0x4478, 0x4479, 0x447a, 0x447b, 0x447c, 0x447d, 0x447e,
+ 0x4521, 0x4522, 0x4523, 0x4524, 0x4525, 0x4526, 0x4527, 0x4528,
+ 0x4529, 0x452a, 0x452b, 0x452c, 0x452d, 0x452e, 0x452f, 0x4530,
+ 0x4531, 0x4532, 0x4533, 0x4534, 0x4535, 0x4536, 0x4537, 0x4538,
+ 0x4539, 0x453a, 0x453b, 0x453c, 0x453d, 0x453e, 0x453f, 0x4540,
+ 0x4541, 0x4542, 0x4543, 0x4544, 0x4545, 0x4546, 0x4547, 0x4548,
+ 0x4549, 0x454a, 0x454b, 0x454d, 0x454c, 0x454e, 0x454f, 0x4550,
+ 0x4551, 0x4552, 0x4553, 0x4554, 0x4555, 0x4556, 0x4557, 0x4558,
+ 0x4559, 0x455a, 0x455b, 0x455c, 0x455d, 0x455e, 0x455f, 0x4560,
+ 0x4561, 0x4562, 0x4563, 0x4564, 0x4565, 0x4566, 0x4567, 0x4568,
+ 0x4569, 0x456a, 0x456b, 0x456c, 0x456d, 0x456e, 0x456f, 0x4570,
+ 0x4571, 0x4572, 0x4573, 0x4574, 0x4575, 0x4576, 0x4577, 0x4578,
+ 0x4579, 0x457a, 0x457b, 0x457c, 0x457d, 0x457e, 0x4621, 0x4622,
+ 0x4623, 0x4624, 0x4625, 0x4626, 0x4627, 0x4628, 0x4629, 0x462a,
+ 0x462b, 0x462c, 0x462d, 0x462e, 0x462f, 0x4630, 0x4631, 0x4632,
+ 0x4633, 0x4634, 0x4635, 0x4636, 0x4637, 0x4638, 0x4639, 0x463a,
+ 0x463b, 0x463c, 0x463d, 0x463e, 0x463f, 0x4640, 0x4641, 0x4642,
+ 0x4643, 0x4644, 0x4645, 0x4646, 0x4647, 0x4648, 0x4649, 0x464a,
+ 0x464b, 0x464c, 0x464d, 0x464e, 0x464f, 0x4650, 0x4651, 0x4652,
+ 0x4653, 0x4654, 0x4655, 0x4656, 0x4657, 0x4658, 0x4659, 0x465a,
+ 0x465b, 0x465c, 0x465d, 0x465e, 0x465f, 0x4660, 0x4736, 0x4661,
+ 0x4662, 0x4663, 0x4664, 0x4665, 0x4666, 0x4667, 0x4668, 0x4669,
+ 0x466a, 0x466b, 0x466c, 0x466d, 0x466e, 0x466f, 0x4670, 0x4671,
+ 0x4672, 0x4673, 0x4674, 0x4675, 0x4676, 0x4677, 0x4678, 0x4679,
+ 0x467a, 0x467b, 0x467c, 0x467d, 0x467e, 0x4721, 0x4722, 0x4723,
+ 0x4724, 0x4725, 0x4726, 0x4727, 0x4728, 0x4729, 0x472a, 0x472b,
+ 0x472c, 0x472d, 0x472e, 0x472f, 0x4730, 0x4731, 0x4732, 0x4733,
+ 0x4734, 0x4735, 0x4737, 0x4738, 0x4739, 0x473a, 0x473b, 0x473c,
+ 0x473d, 0x473e, 0x473f, 0x4740, 0x4741, 0x4742, 0x4743, 0x4744,
+ 0x4745, 0x4746, 0x4747, 0x4748, 0x4749, 0x474a, 0x474b, 0x474c,
+ 0x474d, 0x474e, 0x474f, 0x4750, 0x4751, 0x4752, 0x4753, 0x4754,
+ 0x4755, 0x4756, 0x4757, 0x4758, 0x4759, 0x475a, 0x475b, 0x475c,
+ 0x475d, 0x475e, 0x475f, 0x4760, 0x4761, 0x4762, 0x4763, 0x4764,
+ 0x4765, 0x4766, 0x4767, 0x4768, 0x4769, 0x476a, 0x476b, 0x476c,
+ 0x476d, 0x476e, 0x476f, 0x4770, 0x4771, 0x4772, 0x4773, 0x4774,
+ 0x4775, 0x4776, 0x4777, 0x4778, 0x4779, 0x477a, 0x477b, 0x477c,
+ 0x477d, 0x477e, 0x4821, 0x4822, 0x4823, 0x4824, 0x4825, 0x4826,
+ 0x4827, 0x4828, 0x4829, 0x482a, 0x482b, 0x482c, 0x482d, 0x482e,
+ 0x482f, 0x4830, 0x4831, 0x4832, 0x4833, 0x4834, 0x4835, 0x4836,
+ 0x4837, 0x4838, 0x4839, 0x483a, 0x483b, 0x483c, 0x483d, 0x483e,
+ 0x483f, 0x4840, 0x4841, 0x4842, 0x4843, 0x4844, 0x4845, 0x4846,
+ 0x4847, 0x4848, 0x4849, 0x484a, 0x484b, 0x484c, 0x4853, 0x484d,
+ 0x484e, 0x484f, 0x4850, 0x4851, 0x4852, 0x4854, 0x4855, 0x4856,
+ 0x4857, 0x4858, 0x4859, 0x485a, 0x485b, 0x485c, 0x485d, 0x485e,
+ 0x485f, 0x4860, 0x4861, 0x4862, 0x4863, 0x4864, 0x4865, 0x4866,
+ 0x4867, 0x4868, 0x4869, 0x486a, 0x486b, 0x486c, 0x486d, 0x486e,
+ 0x486f, 0x4870, 0x4871, 0x4872, 0x4873, 0x4874, 0x4875, 0x4876,
+ 0x4877, 0x4878, 0x4879, 0x487a, 0x487b, 0x487c, 0x487d, 0x487e,
+ 0x4921, 0x4922, 0x4923, 0x4924, 0x4925, 0x4926, 0x4927, 0x4928,
+ 0x4929, 0x492a, 0x492b, 0x492c, 0x492d, 0x492e, 0x492f, 0x4930,
+ 0x4931, 0x4932, 0x4933, 0x4934, 0x4935, 0x4936, 0x4937, 0x4938,
+ 0x4939, 0x493a, 0x493b, 0x493c, 0x4941, 0x493d, 0x493e, 0x493f,
+ 0x4940, 0x4942, 0x4943, 0x4944, 0x4945, 0x4946, 0x4947, 0x4948,
+ 0x4949, 0x494a, 0x494b, 0x494c, 0x494d, 0x494e, 0x494f, 0x4950,
+ 0x4951, 0x4952, 0x4953, 0x4954, 0x4955, 0x4956, 0x4957, 0x4958,
+ 0x4959, 0x495a, 0x495b, 0x495c, 0x495d, 0x495e, 0x495f, 0x4960,
+ 0x4961, 0x4962, 0x4963, 0x4964, 0x4965, 0x4966, 0x4967, 0x4968,
+ 0x4969, 0x496a, 0x496b, 0x496c, 0x496d, 0x496e, 0x496f, 0x4970,
+ 0x4971, 0x4972, 0x4973, 0x4974, 0x4975, 0x4976, 0x4977, 0x4978,
+ 0x4979, 0x497a, 0x497b, 0x497c, 0x497d, 0x497e, 0x4a21, 0x4a22,
+ 0x4a23, 0x4a24, 0x4a25, 0x4a26, 0x4a27, 0x4a28, 0x4a29, 0x4a2a,
+ 0x4a2b, 0x4a2c, 0x4a2d, 0x4a2e, 0x4a2f, 0x4a30, 0x4a31, 0x4a32,
+ 0x4a33, 0x4a34, 0x4a35, 0x4a36, 0x4a37, 0x4a38, 0x4a39, 0x4a3a,
+ 0x4a3b, 0x4a3c, 0x4a3d, 0x4a3e, 0x4a3f, 0x4a40, 0x4a41, 0x4a42,
+ 0x4a43, 0x4a44, 0x4a45, 0x4a46, 0x4a47, 0x4a48, 0x4a49, 0x4a4a,
+ 0x4a4b, 0x4a4c, 0x4a4d, 0x4a4e, 0x4a4f, 0x4a50, 0x4a51, 0x4a52,
+ 0x4a53, 0x4a54, 0x4a55, 0x4a56, 0x4a57, 0x4a58, 0x4a59, 0x4a5a,
+ 0x4a5b, 0x4a5c, 0x4a5d, 0x4a5e, 0x4a5f, 0x4a60, 0x4a61, 0x4a62,
+ 0x4a63, 0x4a64, 0x4a65, 0x4a66, 0x4a67, 0x4a68, 0x4a69, 0x4a6a,
+ 0x4a6b, 0x4a6c, 0x4a6d, 0x4a6e, 0x4a6f, 0x4a70, 0x4a71, 0x4a72,
+ 0x4a73, 0x4a74, 0x4a75, 0x4a76, 0x4a77, 0x4a78, 0x4a79, 0x4a7a,
+ 0x4a7b, 0x4a7c, 0x4a7d, 0x4a7e, 0x4b21, 0x4b22, 0x4b23, 0x4b24,
+ 0x4b25, 0x4b26, 0x4b27, 0x4b28, 0x4b29, 0x4b2a, 0x4b2b, 0x4b2c,
+ 0x4b2d, 0x4b2e, 0x4b2f, 0x4b30, 0x4b31, 0x4b32, 0x4b33, 0x4b34,
+ 0x4b35, 0x4b36, 0x4b37, 0x4b38, 0x4b39, 0x4b3a, 0x4b3b, 0x4b3c,
+ 0x4b3d, 0x4b3e, 0x4b3f, 0x4b40, 0x4b41, 0x4b42, 0x4b43, 0x4b44,
+ 0x4b45, 0x4b46, 0x4b47, 0x4b48, 0x4b49, 0x4b4a, 0x4b4b, 0x4b4c,
+ 0x4b4d, 0x4b4e, 0x4b4f, 0x4b50, 0x4b51, 0x4b52, 0x4b53, 0x4b54,
+ 0x4b55, 0x4b56, 0x4b57, 0x4b58, 0x4b59, 0x4b5a, 0x4b5b, 0x4b5c,
+ 0x4b5d, 0x4b5e, 0x4b5f, 0x4b60, 0x4b61, 0x4b62, 0x4b63, 0x4b64,
+ 0x4b65, 0x4b66, 0x4b67, 0x4b68, 0x4b69, 0x4b6a, 0x4b6b, 0x4b6c,
+ 0x4b6d, 0x4b6e, 0x4b6f, 0x4b70, 0x4b71, 0x4b72, 0x4b73, 0x4b74,
+ 0x4b75, 0x4b76, 0x4b77, 0x4b78, 0x4b79, 0x4b7a, 0x4b7b, 0x4b7c,
+ 0x4b7d, 0x4b7e, 0x4c21, 0x4c22, 0x4c23, 0x4c24, 0x4c25, 0x4c26,
+ 0x4c27, 0x4c28, 0x4c29, 0x4c2a, 0x4c2b, 0x4c2c, 0x4c2d, 0x4c2e,
+ 0x4c2f, 0x4c30, 0x4c31, 0x4c32, 0x4c33, 0x4c34, 0x4c35, 0x4c36,
+ 0x4c37, 0x4c38, 0x4c39, 0x4c3a, 0x4c3b, 0x4c3c, 0x4c3d, 0x4c3e,
+ 0x4c3f, 0x4c40, 0x4c41, 0x4c42, 0x4c43, 0x4c44, 0x4c45, 0x4c46,
+ 0x4c47, 0x4c48, 0x4c49, 0x4c4a, 0x4c4b, 0x4c4c, 0x4c4d, 0x4c4e,
+ 0x4c4f, 0x4c50, 0x4c51, 0x4c52, 0x4c53, 0x4c54, 0x4c55, 0x4c56,
+ 0x4c57, 0x4c58, 0x4c59, 0x4c5a, 0x4c5b, 0x4c5c, 0x4c5d, 0x4c5e,
+ 0x4c5f, 0x4c60, 0x4c61, 0x4c62, 0x4c63, 0x4c64, 0x4c65, 0x4c66,
+ 0x4c67, 0x4c68, 0x4c69, 0x4c6a, 0x4c6b, 0x4c6c, 0x4c6d, 0x4c6e,
+ 0x4c6f, 0x4c70, 0x4c71, 0x4c72, 0x4c73, 0x4c74, 0x4c75, 0x4c76,
+ 0x4c77, 0x4c78, 0x4c79, 0x4c7a, 0x4c7b, 0x4c7c, 0x4c7d, 0x4c7e,
+ 0x4d21, 0x4d22, 0x4d23, 0x4d24, 0x4d25, 0x4d26, 0x4d27, 0x4d28,
+ 0x4d29, 0x4d2a, 0x4d2b, 0x4d2c, 0x4d2d, 0x4d2e, 0x4d2f, 0x4d30,
+ 0x4d31, 0x4d32, 0x4d33, 0x4d34, 0x4d35, 0x4d36, 0x4d37, 0x4d38,
+ 0x4d39, 0x4d3a, 0x4d3b, 0x4d3c, 0x4d3d, 0x4d3e, 0x4d3f, 0x4d40,
+ 0x4d41, 0x4d42, 0x4d43, 0x4d44, 0x4d45, 0x4d46, 0x4d47, 0x4d48,
+ 0x4d49, 0x4d4a, 0x4d4b, 0x4d4c, 0x4d4d, 0x4d4e, 0x4d4f, 0x4d50,
+ 0x4d51, 0x4d52, 0x4d53, 0x4d54, 0x4d55, 0x4d56, 0x4d57, 0x4d58,
+ 0x4d59, 0x4d5a, 0x4d5b, 0x4d5c, 0x4d5d, 0x4d5e, 0x4d5f, 0x4d60,
+ 0x4d61, 0x4d62, 0x4d63, 0x4d64, 0x4d65, 0x4d66, 0x4d67, 0x4d68,
+ 0x4d69, 0x4d6a, 0x4d6b, 0x4d6c, 0x4d6d, 0x4d6e, 0x4d6f, 0x4d70,
+ 0x4d71, 0x4d72, 0x4d73, 0x4d74, 0x4d75, 0x4d76, 0x4d77, 0x4d78,
+ 0x4d79, 0x4d7a, 0x4d7b, 0x4d7c, 0x4d7d, 0x4d7e, 0x4e21, 0x4e22,
+ 0x4e24, 0x4e25, 0x4e26, 0x4e27, 0x4e28, 0x4e29, 0x4e23, 0x4e2a,
+ 0x4e2b, 0x4e2c, 0x4e2d, 0x4e2e, 0x4e2f, 0x4e30, 0x4e31, 0x4e32,
+ 0x4e33, 0x4e34, 0x4e35, 0x4e36, 0x4e37, 0x4e38, 0x4e39, 0x4e3a,
+ 0x4e3b, 0x4e3c, 0x4e3d, 0x4e3e, 0x4e3f, 0x4e40, 0x4e41, 0x4e42,
+ 0x4e43, 0x4e44, 0x4e45, 0x4e46, 0x4e47, 0x4e48, 0x4e49, 0x4e4a,
+ 0x4e4b, 0x4e4c, 0x4e4d, 0x4e4e, 0x4e4f, 0x4e50, 0x4e51, 0x4e52,
+ 0x4e53, 0x4e54, 0x4e55, 0x4e56, 0x4e57, 0x4e58, 0x4e59, 0x4e5a,
+ 0x4e5b, 0x4e5c, 0x4e5d, 0x4e5e, 0x4e5f, 0x4e60, 0x4e61, 0x4e62,
+ 0x4e63, 0x4e64, 0x4e65, 0x4e66, 0x4e67, 0x4e68, 0x4e69, 0x4e6a,
+ 0x4e6b, 0x4e6c, 0x4e6d, 0x4e6e, 0x4e6f, 0x4e70, 0x4e71, 0x4e72,
+ 0x4e73, 0x4e74, 0x4e75, 0x4e76, 0x4e77, 0x4e78, 0x4e79, 0x4e7a,
+ 0x4e7b, 0x4e7c, 0x4e7d, 0x4e7e, 0x4f21, 0x4f22, 0x4f23, 0x4f24,
+ 0x4f25, 0x4f26, 0x4f27, 0x4f28, 0x4f29, 0x4f2a, 0x4f2b, 0x4f2c,
+ 0x4f2d, 0x4f2e, 0x4f2f, 0x4f30, 0x4f31, 0x4f32, 0x4f33, 0x4f34,
+ 0x4f35, 0x4f36, 0x4f37, 0x4f38, 0x4f39, 0x4f3a, 0x4f3b, 0x4f3c,
+ 0x4f3d, 0x4f3e, 0x4f3f, 0x4f40, 0x4f41, 0x4f42, 0x4f43, 0x4f44,
+ 0x4f45, 0x4f46, 0x4f47, 0x4f48, 0x4f49, 0x4f4a, 0x4f4b, 0x4f4c,
+ 0x4f4d, 0x4f4e, 0x4f4f, 0x4f50, 0x4f51, 0x4f52, 0x4f53, 0x4f54,
+ 0x4f55, 0x4f56, 0x4f57, 0x4f58, 0x4f59, 0x4f5a, 0x4f5b, 0x4f5c,
+ 0x4f5d, 0x4f5e, 0x4f5f, 0x4f60, 0x4f61, 0x4f62, 0x4f63, 0x4f64,
+ 0x4f65, 0x4f66, 0x4f67, 0x4f68, 0x4f69, 0x4f6a, 0x4f6b, 0x4f6c,
+ 0x4f6d, 0x4f6e, 0x4f6f, 0x4f70, 0x4f71, 0x4f72, 0x4f74, 0x4f75,
+ 0x4f76, 0x4f73, 0x4f77, 0x4f78, 0x4f79, 0x4f7a, 0x4f7b, 0x4f7c,
+ 0x4f7d, 0x4f7e, 0x5021, 0x5022, 0x5023, 0x5024, 0x5025, 0x5026,
+ 0x5027, 0x5028, 0x5029, 0x502a, 0x502b, 0x502c, 0x502e, 0x502f,
+ 0x5030, 0x5031, 0x502d, 0x5032, 0x5033, 0x5034, 0x5035, 0x5037,
+ 0x5038, 0x5039, 0x503a, 0x503b, 0x5036, 0x503c, 0x503d, 0x503e,
+ 0x503f, 0x5040, 0x5041, 0x5042, 0x5043, 0x5044, 0x5045, 0x5046,
+ 0x5047, 0x5048, 0x5049, 0x504a, 0x504b, 0x504c, 0x504d, 0x504e,
+ 0x504f, 0x5050, 0x5051, 0x5052, 0x5053, 0x5054, 0x5055, 0x5056,
+ 0x5057, 0x5058, 0x5059, 0x505a, 0x505b, 0x505c, 0x505d, 0x505e,
+ 0x505f, 0x5060, 0x5061, 0x5062, 0x5063, 0x5064, 0x5065, 0x5066,
+ 0x5067, 0x5068, 0x5069, 0x506a, 0x506b, 0x506c, 0x506d, 0x506e,
+ 0x506f, 0x5070, 0x5071, 0x5072, 0x5073, 0x5074, 0x5075, 0x5076,
+ 0x5077, 0x5078, 0x5079, 0x507a, 0x507b, 0x507c, 0x507d, 0x507e,
+ 0x5121, 0x5122, 0x5123, 0x5124, 0x5125, 0x5126, 0x5127, 0x5128,
+ 0x5129, 0x512a, 0x512b, 0x512c, 0x512d, 0x512e, 0x512f, 0x5130,
+ 0x5131, 0x5132, 0x5133, 0x5134, 0x5135, 0x5136, 0x5137, 0x5138,
+ 0x5139, 0x513a, 0x513b, 0x513c, 0x513d, 0x513e, 0x513f, 0x5140,
+ 0x5141, 0x5142, 0x5143, 0x5144, 0x5145, 0x5146, 0x5147, 0x5148,
+ 0x5149, 0x514a, 0x514b, 0x514c, 0x514d, 0x514e, 0x514f, 0x5150,
+ 0x5151, 0x5152, 0x5153, 0x5154, 0x5155, 0x5156, 0x5157, 0x5158,
+ 0x5159, 0x515a, 0x515b, 0x515c, 0x515d, 0x515e, 0x515f, 0x5160,
+ 0x5161, 0x5162, 0x5163, 0x5164, 0x5165, 0x5166, 0x5167, 0x5168,
+ 0x5169, 0x516a, 0x516b, 0x516c, 0x516d, 0x516e, 0x516f, 0x5170,
+ 0x5171, 0x5172, 0x5173, 0x5174, 0x5175, 0x5176, 0x5177, 0x5178,
+ 0x5179, 0x517a, 0x517b, 0x517c, 0x517d, 0x517e, 0x5221, 0x5222,
+ 0x5223, 0x5224, 0x5225, 0x5226, 0x5227, 0x5228, 0x5229, 0x522a,
+ 0x522b, 0x522c, 0x522d, 0x522e, 0x522f, 0x5230, 0x5231, 0x5232,
+ 0x5233, 0x5234, 0x5235, 0x5236, 0x5237, 0x5238, 0x5239, 0x523a,
+ 0x523b, 0x523c, 0x523d, 0x523e, 0x523f, 0x5240, 0x5241, 0x5242,
+ 0x5243, 0x5244, 0x5245, 0x5246, 0x5247, 0x5248, 0x5249, 0x524a,
+ 0x524b, 0x524c, 0x524d, 0x524e, 0x524f, 0x5250, 0x5251, 0x5252,
+ 0x5253, 0x5254, 0x5255, 0x5256, 0x5257, 0x5258, 0x5259, 0x525a,
+ 0x525b, 0x525c, 0x525d, 0x525e, 0x525f, 0x5260, 0x5261, 0x5262,
+ 0x5263, 0x5264, 0x5265, 0x5266, 0x5267, 0x5268, 0x5269, 0x526a,
+ 0x526b, 0x526c, 0x526d, 0x526e, 0x526f, 0x5270, 0x5271, 0x5272,
+ 0x5273, 0x5274, 0x5276, 0x5277, 0x5278, 0x5275, 0x5279, 0x527a,
+ 0x527b, 0x527c, 0x527d, 0x527e, 0x5321, 0x5322, 0x5323, 0x5324,
+ 0x5325, 0x5326, 0x5327, 0x5328, 0x5329, 0x532a, 0x532b, 0x532c,
+ 0x532d, 0x532e, 0x532f, 0x5330, 0x5331, 0x5332, 0x5333, 0x5334,
+ 0x5335, 0x5336, 0x5337, 0x5338, 0x5339, 0x533a, 0x533b, 0x533c,
+ 0x533d, 0x533e, 0x533f, 0x5340, 0x5341, 0x5342, 0x5343, 0x5344,
+ 0x5345, 0x5346, 0x5347, 0x5348, 0x5349, 0x534a, 0x534b, 0x534c,
+ 0x534d, 0x534e, 0x534f, 0x5350, 0x5351, 0x5352, 0x5353, 0x5354,
+ 0x5355, 0x5356, 0x5357, 0x5358, 0x5359, 0x535a, 0x535b, 0x535c,
+ 0x535d, 0x535e, 0x535f, 0x5360, 0x5361, 0x5362, 0x5363, 0x5364,
+ 0x5365, 0x5366, 0x5367, 0x5368, 0x5369, 0x536a, 0x536b, 0x536c,
+ 0x536d, 0x536e, 0x536f, 0x5370, 0x5371, 0x5372, 0x5373, 0x5374,
+ 0x5375, 0x5376, 0x5377, 0x5378, 0x5379, 0x537a, 0x537b, 0x537c,
+ 0x537d, 0x537e, 0x5421, 0x5422, 0x5423, 0x5424, 0x5425, 0x5426,
+ 0x5427, 0x5428, 0x5429, 0x542a, 0x542b, 0x542c, 0x542d, 0x542e,
+ 0x542f, 0x5430, 0x5431, 0x5432, 0x5434, 0x5435, 0x5436, 0x5437,
+ 0x5438, 0x5439, 0x543a, 0x543b, 0x543c, 0x543d, 0x543e, 0x5433,
+ 0x543f, 0x5440, 0x5441, 0x5442, 0x5443, 0x5444, 0x5445, 0x5446,
+ 0x5447, 0x5448, 0x5449, 0x544a, 0x544b, 0x544c, 0x544d, 0x544e,
+ 0x544f, 0x5450, 0x5451, 0x5452, 0x5453, 0x5454, 0x5455, 0x5456,
+ 0x5457, 0x5458, 0x5459, 0x545a, 0x545b, 0x545c, 0x545d, 0x545e,
+ 0x545f, 0x5460, 0x5461, 0x5462, 0x5463, 0x5464, 0x5465, 0x5466,
+ 0x5467, 0x5468, 0x5469, 0x546a, 0x546c, 0x546b, 0x546d, 0x546e,
+ 0x546f, 0x5470, 0x5471, 0x5472, 0x5473, 0x5474, 0x5475, 0x5476,
+ 0x5477, 0x5478, 0x5479, 0x547a, 0x547b, 0x547c, 0x547d, 0x547e,
+ 0x5521, 0x5522, 0x5523, 0x5524, 0x5525, 0x5526, 0x5527, 0x5528,
+ 0x5529, 0x552a, 0x552b, 0x552c, 0x552d, 0x552e, 0x552f, 0x5530,
+ 0x5531, 0x5532, 0x5533, 0x5534, 0x5535, 0x5536, 0x5537, 0x5538,
+ 0x5539, 0x553a, 0x553b, 0x553c, 0x553d, 0x553e, 0x553f, 0x5540,
+ 0x5541, 0x5542, 0x5543, 0x5544, 0x5545, 0x5546, 0x5547, 0x5548,
+ 0x5549, 0x554a, 0x554b, 0x554c, 0x554d, 0x554e, 0x554f, 0x5550,
+ 0x5551, 0x5552, 0x5553, 0x5554, 0x5555, 0x5556, 0x5557, 0x5558,
+ 0x5559, 0x555a, 0x555b, 0x555c, 0x555d, 0x555e, 0x555f, 0x5560,
+ 0x5561, 0x5562, 0x5563, 0x5564, 0x5565, 0x5566, 0x5567, 0x5568,
+ 0x5569, 0x556a, 0x556b, 0x556c, 0x556d, 0x556e, 0x556f, 0x5570,
+ 0x5571, 0x5572, 0x5573, 0x5574, 0x5575, 0x5576, 0x5577, 0x5578,
+ 0x5579, 0x557a, 0x557b, 0x557c, 0x557d, 0x557e, 0x5621, 0x5622,
+ 0x5623, 0x5624, 0x5625, 0x5626, 0x5627, 0x5628, 0x5629, 0x562a,
+ 0x562b, 0x562c, 0x562d, 0x562e, 0x562f, 0x5630, 0x5631, 0x5632,
+ 0x5633, 0x5634, 0x5635, 0x5636, 0x5637, 0x5638, 0x5639, 0x563a,
+ 0x563b, 0x563c, 0x563d, 0x563e, 0x563f, 0x5640, 0x5641, 0x5642,
+ 0x5643, 0x5644, 0x5645, 0x5647, 0x5648, 0x5649, 0x564a, 0x564b,
+ 0x5646, 0x564c, 0x564d, 0x564e, 0x564f, 0x5650, 0x5651, 0x5652,
+ 0x5653, 0x5654, 0x5656, 0x5657, 0x5658, 0x5655, 0x5659, 0x565a,
+ 0x565b, 0x565c, 0x565d, 0x565e, 0x565f, 0x5660, 0x5661, 0x5662,
+ 0x5663, 0x5664, 0x5665, 0x5666, 0x5667, 0x5668, 0x5669, 0x566a,
+ 0x566b, 0x566c, 0x566d, 0x566e, 0x566f, 0x5670, 0x5671, 0x5672,
+ 0x5673, 0x5674, 0x5675, 0x5676, 0x5677, 0x5678, 0x5679, 0x567a,
+ 0x567b, 0x567c, 0x567d, 0x567e, 0x5721, 0x5722, 0x5723, 0x5724,
+ 0x5725, 0x5726, 0x5727, 0x5728, 0x5729, 0x572a, 0x572b, 0x572c,
+ 0x572d, 0x572e, 0x572f, 0x5730, 0x5731, 0x5732, 0x5733, 0x5734,
+ 0x5735, 0x5736, 0x5737, 0x5738, 0x5739, 0x573a, 0x573b, 0x573c,
+ 0x573d, 0x573e, 0x573f, 0x5740, 0x5741, 0x5742, 0x5743, 0x5744,
+ 0x5745, 0x5746, 0x5747, 0x5748, 0x5749, 0x574a, 0x574b, 0x574c,
+ 0x574d, 0x574e, 0x574f, 0x5750, 0x5751, 0x5752, 0x5753, 0x5754,
+ 0x5755, 0x5756, 0x5757, 0x5758, 0x5759, 0x575a, 0x575b, 0x575c,
+ 0x575d, 0x575e, 0x575f, 0x5760, 0x5761, 0x5762, 0x5764, 0x5765,
+ 0x5766, 0x5767, 0x5768, 0x5769, 0x576a, 0x576b, 0x576c, 0x576d,
+ 0x576e, 0x576f, 0x5770, 0x5771, 0x5772, 0x5773, 0x5774, 0x5775,
+ 0x5776, 0x5777, 0x5778, 0x5779, 0x583e, 0x5763, 0x577a, 0x577b,
+ 0x577c, 0x577d, 0x577e, 0x5821, 0x5822, 0x5823, 0x5824, 0x5825,
+ 0x5826, 0x5827, 0x5828, 0x5829, 0x582a, 0x582b, 0x582c, 0x582d,
+ 0x582e, 0x582f, 0x5830, 0x5831, 0x5832, 0x5833, 0x584c, 0x5834,
+ 0x5835, 0x5836, 0x5837, 0x5838, 0x5839, 0x583a, 0x583b, 0x583c,
+ 0x583d, 0x583f, 0x5840, 0x5841, 0x5842, 0x5843, 0x5844, 0x5845,
+ 0x5846, 0x5847, 0x5848, 0x5849, 0x584a, 0x584b, 0x584d, 0x584e,
+ 0x584f, 0x5850, 0x5851, 0x5852, 0x5853, 0x5854, 0x5855, 0x5856,
+ 0x5857, 0x5858, 0x5859, 0x585a, 0x585b, 0x585c, 0x585d, 0x585e,
+ 0x585f, 0x5860, 0x5861, 0x5862, 0x5863, 0x5864, 0x5865, 0x5866,
+ 0x5867, 0x5868, 0x5869, 0x586a, 0x586b, 0x586c, 0x586d, 0x586e,
+ 0x586f, 0x5870, 0x5871, 0x5872, 0x5873, 0x5874, 0x5875, 0x5876,
+ 0x5877, 0x5878, 0x5879, 0x587a, 0x587b, 0x587c, 0x587d, 0x587e,
+ 0x5921, 0x5922, 0x5923, 0x5924, 0x5925, 0x5926, 0x5927, 0x5928,
+ 0x592a, 0x592b, 0x592c, 0x592d, 0x592e, 0x592f, 0x5930, 0x5931,
+ 0x5932, 0x5933, 0x5934, 0x5935, 0x5936, 0x5937, 0x5938, 0x5939,
+ 0x593a, 0x593b, 0x593c, 0x5929, 0x593d, 0x593e, 0x593f, 0x5940,
+ 0x5941, 0x5942, 0x5943, 0x5944, 0x5945, 0x5946, 0x5947, 0x5948,
+ 0x5949, 0x594a, 0x594b, 0x594c, 0x594d, 0x594e, 0x594f, 0x5950,
+ 0x5951, 0x5952, 0x5953, 0x5954, 0x5955, 0x5956, 0x5957, 0x5958,
+ 0x5959, 0x595a, 0x595b, 0x595c, 0x595d, 0x595e, 0x595f, 0x5960,
+ 0x5961, 0x5962, 0x5963, 0x5964, 0x5965, 0x5966, 0x5974, 0x5967,
+ 0x5968, 0x5969, 0x596a, 0x596b, 0x596c, 0x596d, 0x596e, 0x596f,
+ 0x5970, 0x5971, 0x5972, 0x5973, 0x5975, 0x5976, 0x5977, 0x5978,
+ 0x5979, 0x597a, 0x597b, 0x597c, 0x597d, 0x597e, 0x5a21, 0x5a22,
+ 0x5a23, 0x5a24, 0x5a25, 0x5a26, 0x5a27, 0x5a28, 0x5a29, 0x5a2a,
+ 0x5a2b, 0x5a2c, 0x5a2d, 0x5a2e, 0x5a2f, 0x5a30, 0x5a31, 0x5a32,
+ 0x5a33, 0x5a34, 0x5a35, 0x5a36, 0x3866, 0x5a37, 0x5a38, 0x5a39,
+ 0x5a3a, 0x5a3b, 0x5a3c, 0x5a3d, 0x5a3e, 0x5a3f, 0x5a40, 0x5a41,
+ 0x5a42, 0x5a43, 0x5a44, 0x5a45, 0x5a46, 0x5a47, 0x5a48, 0x5a49,
+ 0x5a4a, 0x5a4b, 0x5a6d, 0x5a4c, 0x5a4d, 0x5a4e, 0x5a4f, 0x5a50,
+ 0x5a51, 0x5a52, 0x5a53, 0x5a54, 0x5a55, 0x5a56, 0x5a57, 0x5a58,
+ 0x5a59, 0x5a5a, 0x5a5b, 0x5a5c, 0x5a5d, 0x5a5e, 0x5a5f, 0x5a60,
+ 0x5a61, 0x5a62, 0x5a63, 0x5a64, 0x5a65, 0x5a66, 0x5a67, 0x5a68,
+ 0x5a69, 0x5a6a, 0x5a6b, 0x5a6c, 0x5a6e, 0x5a6f, 0x5a70, 0x5a71,
+ 0x5a72, 0x5a73, 0x5a74, 0x5a75, 0x5a76, 0x5a77, 0x5a78, 0x5a79,
+ 0x5a7a, 0x5a7b, 0x5a7c, 0x5a7d, 0x5a7e, 0x5b21, 0x5b22, 0x5b23,
+ 0x5b24, 0x5b25, 0x5b26, 0x5b27, 0x5b28, 0x5b29, 0x5b2a, 0x5b2b,
+ 0x5b2c, 0x5b2d, 0x5b2e, 0x5b2f, 0x5b30, 0x5b31, 0x5b32, 0x5b33,
+ 0x5b34, 0x5b35, 0x5b36, 0x5b37, 0x5b38, 0x5b39, 0x5b3a, 0x5b3b,
+ 0x5b3c, 0x5b3d, 0x5b3e, 0x5b3f, 0x5b40, 0x5b41, 0x5b42, 0x5b43,
+ 0x5b44, 0x5b45, 0x5b46, 0x5b47, 0x5b48, 0x5b49, 0x5b4a, 0x5b4b,
+ 0x5b4c, 0x5b4d, 0x5b4e, 0x5b4f, 0x5b50, 0x5b51, 0x5b52, 0x5b53,
+ 0x5b54, 0x5b55, 0x5b56, 0x5b57, 0x5b58, 0x5b59, 0x5b5a, 0x5b5b,
+ 0x5b5c, 0x5b5d, 0x5b5e, 0x5b5f, 0x5b60, 0x5b61, 0x5b62, 0x5b63,
+ 0x5b64, 0x5b65, 0x5b66, 0x5b67, 0x5b68, 0x5b69, 0x5b6a, 0x5b6b,
+ 0x5b6c, 0x5b6d, 0x5b6e, 0x5b70, 0x5b71, 0x5b72, 0x5b73, 0x5b6f,
+ 0x5b74, 0x5b75, 0x5b76, 0x5b77, 0x5b78, 0x5b79, 0x5b7a, 0x5b7b,
+ 0x5b7c, 0x5b7d, 0x5b7e, 0x5c21, 0x5c22, 0x5c23, 0x5c24, 0x5c25,
+ 0x5c26, 0x5c27, 0x5c28, 0x5c29, 0x5c2a, 0x5c2b, 0x5c2c, 0x5c2d,
+ 0x5c2e, 0x5c2f, 0x5c30, 0x5c31, 0x5c32, 0x5c33, 0x5c34, 0x5c35,
+ 0x5c36, 0x5c37, 0x5c38, 0x5c39, 0x5c3a, 0x5c3b, 0x5c3c, 0x5c3d,
+ 0x5c3e, 0x5c3f, 0x5c40, 0x5c41, 0x5c42, 0x5c43, 0x5c44, 0x5c45,
+ 0x5c46, 0x5c47, 0x5c48, 0x5c49, 0x5c4a, 0x5c4b, 0x5c4c, 0x5c4d,
+ 0x5c4e, 0x5c4f, 0x5c50, 0x5c51, 0x5c52, 0x5c53, 0x5c54, 0x5c55,
+ 0x5c56, 0x5c57, 0x5c58, 0x5c59, 0x5c5a, 0x5c5b, 0x5c5c, 0x5c5d,
+ 0x5c5e, 0x5c5f, 0x5c60, 0x5c61, 0x5c62, 0x5c63, 0x5c64, 0x5c65,
+ 0x5c66, 0x5c67, 0x5c68, 0x5c69, 0x5c6a, 0x5c6b, 0x5c6c, 0x5c6d,
+ 0x5c6e, 0x5c6f, 0x5c70, 0x5c71, 0x5c72, 0x5c73, 0x5c74, 0x5c75,
+ 0x5c76, 0x5c77, 0x5c78, 0x5c79, 0x5c7a, 0x5c7b, 0x5c7c, 0x5c7d,
+ 0x5c7e, 0x5d21, 0x5d22, 0x5d23, 0x5d24, 0x5d25, 0x5d26, 0x5d27,
+ 0x5d28, 0x5d29, 0x5d2a, 0x5d2b, 0x5d2c, 0x5d2d, 0x5d2e, 0x5d2f,
+ 0x5d30, 0x5d31, 0x5d32, 0x5d33, 0x5d34, 0x5d35, 0x5d36, 0x5d37,
+ 0x5d38, 0x5d39, 0x5d3a, 0x5d3b, 0x5d3c, 0x5d3d, 0x5d3e, 0x5d3f,
+ 0x5d40, 0x5d41, 0x5d42, 0x5d43, 0x5d44, 0x5d45, 0x5d46, 0x5d47,
+ 0x5d48, 0x5d49, 0x5d4a, 0x5d4b, 0x5d4c, 0x5d4d, 0x5d4e, 0x5d4f,
+ 0x5d50, 0x5d51, 0x5d52, 0x5d53, 0x5d54, 0x5d55, 0x5d56, 0x5d57,
+ 0x5d58, 0x5d59, 0x5d5a, 0x5d5b, 0x5d5c, 0x5d5d, 0x5d5e, 0x5d5f,
+ 0x5d60, 0x5d61, 0x5d62, 0x5d63, 0x5d64, 0x5d65, 0x5d66, 0x5d67,
+ 0x5d68, 0x5d69, 0x5d6a, 0x5d6b, 0x5d6c, 0x5d6d, 0x5d6e, 0x5d6f,
+ 0x5d70, 0x5d71, 0x5d72, 0x5d73, 0x5d74, 0x5d75, 0x5d76, 0x5d77,
+ 0x5d78, 0x5d79, 0x5d7a, 0x5d7b, 0x5d7c, 0x5d7d, 0x5d7e, 0x5e21,
+ 0x5e22, 0x5e23, 0x5e24, 0x5e25, 0x5e26, 0x5e27, 0x5e28, 0x5e29,
+ 0x5e2a, 0x5e2b, 0x5e2c, 0x5e2d, 0x5e2e, 0x5e2f, 0x5e30, 0x5e31,
+ 0x5e32, 0x5e33, 0x5e34, 0x5e35, 0x5e36, 0x5e37, 0x5e38, 0x5e39,
+ 0x5e3f, 0x5e3a, 0x5e3b, 0x5e3c, 0x5e3d, 0x5e3e, 0x5e40, 0x5e41,
+ 0x5e42, 0x5e43, 0x5e44, 0x5e45, 0x5e46, 0x5e47, 0x5e48, 0x5e49,
+ 0x5e4e, 0x5e4a, 0x5e4b, 0x5e4c, 0x5e4d, 0x5e4f, 0x5e50, 0x5e51,
+ 0x5e52, 0x5e53, 0x5e54, 0x5e55, 0x5e56, 0x5e57, 0x5e58, 0x5e59,
+ 0x5e5a, 0x5e5b, 0x5e5c, 0x5e5d, 0x5e5e, 0x5e5f, 0x5e60, 0x5e61,
+ 0x5e62, 0x5e63, 0x5e64, 0x5e65, 0x5e66, 0x5e67, 0x5e68, 0x5e69,
+ 0x5e6a, 0x5e6b, 0x5e6c, 0x5e6d, 0x5e6e, 0x5e6f, 0x5e72, 0x5e70,
+ 0x5e71, 0x5e73, 0x5e74, 0x5e75, 0x5e76, 0x5e77, 0x5e78, 0x5e79,
+ 0x5e7a, 0x5e7b, 0x5e7c, 0x5e7d, 0x5e7e, 0x5f21, 0x5f22, 0x5f23,
+ 0x5f24, 0x5f25, 0x5f26, 0x5f27, 0x5f28, 0x5f29, 0x5f2a, 0x5f2b,
+ 0x5f2c, 0x5f2d, 0x5f2e, 0x5f2f, 0x5f30, 0x5f32, 0x5f31, 0x5f33,
+ 0x5f34, 0x5f35, 0x5f36, 0x5f37, 0x5f38, 0x5f39, 0x5f3a, 0x5f3b,
+ 0x5f3c, 0x5f3d, 0x5f3e, 0x5f3f, 0x5f40, 0x5f41, 0x5f42, 0x5f43,
+ 0x5f44, 0x5f45, 0x5f46, 0x5f47, 0x5f48, 0x5f49, 0x5f4a, 0x5f4b,
+ 0x5f4c, 0x5f4d, 0x5f4e, 0x5f4f, 0x5f50, 0x5f51, 0x5f52, 0x5f53,
+ 0x5f54, 0x5f55, 0x5f56, 0x5f57, 0x5f58, 0x5f59, 0x5f5a, 0x5f5b,
+ 0x5f5c, 0x5f5d, 0x5f6f, 0x5f5e, 0x5f5f, 0x5f60, 0x5f61, 0x5f62,
+ 0x5f63, 0x5f64, 0x5f65, 0x5f66, 0x5f67, 0x5f68, 0x5f69, 0x5f6a,
+ 0x5f6b, 0x5f6c, 0x5f6d, 0x5f6e, 0x5f70, 0x5f71, 0x5f72, 0x5f73,
+ 0x5f74, 0x5f75, 0x5f76, 0x5f77, 0x5f78, 0x5f79, 0x5f7a, 0x5f7b,
+ 0x5f7c, 0x5f7d, 0x5f7e, 0x6021, 0x6022, 0x6023, 0x6024, 0x6025,
+ 0x6026, 0x6027, 0x6028, 0x6029, 0x602a, 0x602b, 0x602c, 0x602d,
+ 0x602e, 0x602f, 0x6030, 0x6031, 0x6032, 0x6033, 0x6034, 0x6035,
+ 0x6036, 0x6037, 0x6038, 0x6039, 0x603a, 0x603b, 0x603c, 0x603d,
+ 0x603e, 0x603f, 0x6040, 0x6041, 0x6042, 0x6043, 0x6044, 0x6045,
+ 0x6046, 0x6047, 0x6048, 0x6049, 0x604a, 0x604b, 0x604c, 0x604d,
+ 0x604e, 0x604f, 0x6050, 0x6051, 0x6052, 0x6053, 0x6054, 0x6055,
+ 0x6056, 0x6057, 0x6058, 0x6059, 0x605a, 0x605b, 0x605c, 0x605d,
+ 0x6064, 0x605e, 0x605f, 0x6060, 0x6061, 0x6062, 0x6063, 0x6065,
+ 0x6066, 0x6067, 0x6068, 0x6069, 0x606a, 0x606b, 0x606c, 0x606d,
+ 0x606e, 0x606f, 0x6070, 0x6071, 0x6072, 0x6073, 0x6074, 0x6075,
+ 0x6076, 0x6077, 0x6078, 0x6079, 0x607a, 0x607b, 0x607c, 0x607d,
+ 0x607e, 0x6121, 0x6122, 0x6123, 0x6124, 0x6125, 0x6126, 0x6127,
+ 0x6128, 0x6129, 0x612a, 0x612b, 0x612c, 0x612d, 0x612e, 0x612f,
+ 0x6130, 0x6131, 0x6132, 0x6133, 0x6134, 0x6135, 0x6136, 0x6137,
+ 0x6138, 0x6139, 0x613a, 0x613b, 0x613c, 0x613d, 0x613e, 0x613f,
+ 0x6140, 0x6141, 0x6142, 0x6143, 0x6144, 0x6145, 0x6146, 0x6147,
+ 0x6148, 0x6149, 0x614a, 0x614b, 0x614c, 0x614d, 0x614e, 0x614f,
+ 0x6150, 0x6151, 0x6152, 0x6154, 0x6155, 0x6156, 0x6153, 0x6157,
+ 0x6158, 0x6159, 0x615a, 0x615b, 0x615c, 0x615d, 0x615e, 0x615f,
+ 0x6160, 0x6161, 0x6162, 0x6163, 0x6164, 0x6165, 0x6166, 0x6167,
+ 0x6168, 0x6169, 0x616a, 0x616b, 0x616c, 0x616d, 0x616e, 0x616f,
+ 0x6170, 0x6171, 0x6172, 0x6173, 0x6174, 0x6175, 0x6176, 0x6177,
+ 0x6178, 0x6179, 0x617a, 0x617b, 0x617d, 0x617e, 0x6221, 0x6222,
+ 0x6223, 0x6224, 0x617c, 0x622d, 0x6225, 0x6226, 0x6227, 0x6228,
+ 0x6229, 0x622a, 0x622b, 0x622c, 0x622f, 0x6230, 0x6231, 0x6232,
+ 0x622e, 0x6233, 0x6234, 0x6235, 0x6236, 0x6237, 0x6238, 0x6239,
+ 0x623a, 0x623b, 0x623c, 0x623d, 0x623e, 0x623f, 0x6240, 0x6241,
+ 0x6242, 0x6243, 0x6245, 0x6246, 0x6244, 0x6247, 0x6248, 0x6249,
+ 0x624a, 0x624b, 0x624c, 0x624d, 0x624e, 0x624f, 0x6250, 0x6251,
+ 0x6252, 0x6253, 0x6254, 0x6255, 0x6256, 0x6257, 0x6258, 0x6259,
+ 0x625a, 0x625b, 0x625c, 0x625d, 0x625e, 0x625f, 0x6260, 0x6261,
+ 0x6262, 0x6263, 0x6264, 0x6265, 0x6266, 0x6267, 0x6268, 0x6269,
+ 0x626a, 0x626b, 0x626c, 0x626d, 0x626e, 0x626f, 0x6270, 0x6271,
+ 0x6272, 0x6273, 0x6274, 0x6275, 0x6276, 0x6277, 0x6278, 0x6279,
+ 0x627a, 0x627b, 0x627c, 0x627d, 0x627e, 0x6321, 0x6322, 0x6323,
+ 0x6324, 0x6325, 0x6326, 0x6327, 0x6328, 0x6329, 0x632a, 0x632b,
+ 0x632c, 0x632d, 0x632e, 0x632f, 0x6330, 0x6331, 0x6332, 0x6333,
+ 0x6334, 0x6335, 0x6336, 0x6337, 0x6338, 0x6339, 0x633a, 0x633b,
+ 0x633c, 0x633d, 0x633e, 0x633f, 0x6340, 0x6341, 0x6342, 0x6343,
+ 0x6344, 0x6345, 0x6346, 0x6347, 0x6348, 0x6349, 0x634a, 0x634b,
+ 0x634c, 0x634d, 0x634e, 0x634f, 0x6350, 0x6351, 0x6352, 0x6353,
+ 0x6354, 0x6355, 0x6356, 0x6357, 0x6358, 0x6359, 0x635a, 0x635b,
+ 0x635c, 0x635d, 0x635e, 0x635f, 0x6360, 0x6361, 0x6362, 0x6363,
+ 0x6364, 0x6365, 0x6366, 0x6367, 0x6368, 0x6369, 0x636a, 0x636b,
+ 0x636c, 0x636d, 0x636e, 0x636f, 0x6370, 0x6371, 0x6372, 0x6373,
+ 0x6374, 0x6375, 0x6376, 0x6377, 0x6378, 0x6379, 0x637a, 0x637b,
+ 0x637c, 0x637d, 0x637e, 0x6421, 0x6422, 0x6423, 0x6424, 0x6425,
+ 0x6426, 0x6427, 0x6428, 0x6429, 0x642a, 0x642b, 0x642c, 0x642d,
+ 0x642e, 0x642f, 0x6430, 0x6431, 0x6432, 0x6433, 0x6434, 0x6435,
+ 0x6436, 0x6437, 0x6438, 0x6439, 0x643a, 0x643b, 0x643c, 0x643d,
+ 0x643e, 0x643f, 0x6440, 0x6441, 0x6442, 0x6443, 0x6444, 0x6445,
+ 0x6446, 0x6447, 0x6448, 0x6449, 0x644a, 0x644b, 0x644c, 0x644d,
+ 0x644e, 0x644f, 0x6450, 0x6451, 0x6452, 0x6453, 0x6454, 0x6455,
+ 0x6456, 0x6457, 0x6458, 0x6459, 0x645a, 0x645b, 0x645c, 0x645d,
+ 0x645e, 0x645f, 0x6460, 0x6461, 0x6462, 0x6463, 0x6464, 0x6465,
+ 0x6466, 0x6467, 0x6468, 0x6469, 0x646a, 0x646b, 0x646c, 0x646d,
+ 0x646e, 0x646f, 0x6470, 0x6471, 0x6472, 0x6473, 0x6474, 0x6475,
+ 0x6476, 0x6477, 0x6478, 0x6479, 0x647a, 0x647b, 0x647c, 0x647d,
+ 0x647e, 0x6521, 0x6522, 0x6523, 0x6524, 0x6525, 0x6526, 0x6527,
+ 0x6528, 0x6529, 0x652a, 0x652b, 0x652c, 0x652d, 0x652e, 0x652f,
+ 0x6530, 0x6531, 0x6532, 0x6533, 0x6534, 0x6535, 0x653b, 0x6536,
+ 0x6537, 0x6538, 0x6539, 0x653a, 0x653c, 0x653d, 0x653e, 0x653f,
+ 0x6540, 0x6541, 0x6542, 0x6543, 0x6544, 0x6545, 0x6546, 0x6547,
+ 0x6548, 0x6549, 0x654a, 0x654b, 0x654c, 0x654d, 0x654f, 0x6550,
+ 0x654e, 0x6551, 0x6552, 0x6553, 0x6554, 0x6555, 0x6556, 0x6557,
+ 0x6558, 0x6559, 0x655a, 0x655b, 0x655c, 0x655d, 0x655e, 0x655f,
+ 0x6560, 0x6561, 0x6562, 0x6563, 0x6564, 0x6565, 0x6566, 0x6568,
+ 0x6567, 0x6569, 0x656a, 0x656b, 0x656c, 0x656d, 0x656e, 0x656f,
+ 0x6570, 0x6571, 0x6572, 0x6573, 0x6574, 0x6575, 0x6576, 0x6577,
+ 0x6578, 0x6579, 0x657a, 0x657c, 0x657b, 0x657d, 0x657e, 0x6621,
+ 0x6622, 0x6623, 0x6624, 0x6625, 0x6626, 0x6627, 0x6628, 0x6629,
+ 0x662a, 0x662b, 0x662c, 0x662d, 0x662e, 0x662f, 0x6630, 0x6631,
+ 0x6632, 0x6633, 0x6634, 0x6635, 0x6636, 0x6637, 0x6638, 0x6639,
+ 0x663a, 0x663b, 0x663c, 0x663d, 0x663e, 0x663f, 0x6640, 0x6641,
+ 0x6642, 0x6643, 0x6644, 0x6645, 0x6646, 0x6647, 0x6648, 0x6649,
+ 0x664a, 0x664b, 0x664c, 0x664d, 0x664e, 0x664f, 0x6650, 0x6651,
+ 0x6652, 0x6653, 0x6654, 0x6655, 0x6656, 0x6657, 0x6658, 0x6659,
+ 0x665a, 0x665b, 0x665c, 0x665d, 0x665e, 0x665f, 0x6660, 0x6661,
+ 0x6662, 0x6663, 0x6664, 0x6665, 0x6666, 0x6667, 0x6668, 0x6669,
+ 0x666a, 0x666b, 0x666c, 0x666d, 0x666e, 0x666f, 0x6670, 0x6671,
+ 0x6672, 0x6673, 0x6675, 0x6676, 0x6677, 0x6678, 0x6679, 0x667a,
+ 0x667b, 0x667c, 0x667d, 0x667e, 0x6721, 0x6722, 0x6723, 0x6724,
+ 0x6725, 0x6726, 0x6727, 0x6728, 0x6729, 0x672a, 0x672b, 0x672c,
+ 0x672d, 0x672e, 0x672f, 0x6730, 0x6731, 0x6732, 0x6733, 0x6734,
+ 0x6735, 0x6736, 0x6737, 0x6738, 0x6739, 0x673a, 0x673b, 0x673c,
+ 0x673d, 0x673e, 0x673f, 0x6740, 0x6741, 0x6742, 0x6743, 0x6744,
+ 0x6745, 0x6746, 0x6747, 0x6748, 0x6749, 0x674a, 0x674b, 0x674c,
+ 0x674d, 0x674e, 0x674f, 0x6750, 0x6751, 0x6752, 0x6753, 0x6754,
+ 0x6755, 0x6756, 0x6757, 0x6758, 0x6759, 0x675a, 0x675b, 0x675c,
+ 0x675d, 0x675e, 0x675f, 0x6760, 0x6761, 0x6762, 0x6763, 0x6764,
+ 0x6765, 0x6766, 0x676a, 0x6767, 0x6768, 0x6769, 0x676b, 0x676c,
+ 0x676d, 0x676e, 0x676f, 0x6770, 0x6771, 0x6772, 0x6773, 0x6774,
+ 0x6776, 0x6777, 0x6778, 0x6779, 0x6775, 0x677a, 0x677b, 0x677c,
+ 0x677d, 0x6828, 0x677e, 0x6821, 0x6822, 0x6823, 0x6824, 0x6825,
+ 0x6826, 0x6827, 0x6829, 0x682a, 0x682b, 0x682c, 0x682d, 0x682e,
+ 0x682f, 0x6830, 0x6831, 0x6832, 0x6833, 0x6834, 0x6835, 0x6836,
+ 0x6837, 0x6838, 0x6839, 0x683a, 0x683b, 0x683c, 0x683d, 0x683e,
+ 0x683f, 0x6840, 0x6841, 0x6842, 0x6843, 0x6844, 0x6845, 0x6846,
+ 0x6847, 0x6848, 0x6849, 0x684a, 0x684b, 0x684c, 0x684d, 0x684e,
+ 0x684f, 0x6850, 0x6851, 0x6852, 0x6853, 0x6854, 0x6855, 0x6856,
+ 0x6857, 0x6858, 0x6859, 0x685a, 0x685b, 0x685c, 0x685d, 0x685e,
+ 0x685f, 0x6860, 0x6861, 0x6862, 0x6863, 0x6864, 0x6865, 0x6866,
+ 0x6867, 0x6868, 0x6869, 0x686a, 0x686b, 0x686c, 0x686d, 0x686e,
+ 0x686f, 0x6870, 0x6871, 0x6872, 0x6873, 0x6874, 0x6875, 0x6876,
+ 0x6877, 0x6878, 0x6879, 0x687a, 0x687b, 0x687c, 0x687d, 0x687e,
+ 0x6921, 0x6922, 0x6923, 0x6924, 0x6925, 0x6926, 0x6927, 0x6928,
+ 0x6929, 0x692a, 0x692b, 0x692c, 0x692d, 0x692e, 0x692f, 0x6930,
+ 0x6931, 0x6932, 0x6933, 0x6934, 0x6935, 0x6936, 0x6937, 0x6938,
+ 0x6939, 0x693a, 0x693b, 0x693c, 0x693d, 0x693e, 0x693f, 0x6940,
+ 0x6941, 0x6942, 0x6943, 0x6944, 0x6945, 0x6946, 0x6947, 0x6948,
+ 0x6949, 0x694a, 0x694c, 0x694d, 0x694b, 0x694e, 0x694f, 0x6950,
+ 0x6951, 0x6952, 0x6953, 0x6954, 0x6955, 0x6956, 0x6957, 0x6958,
+ 0x6959, 0x695a, 0x695b, 0x695c, 0x695d, 0x695e, 0x695f, 0x6960,
+ 0x6961, 0x6962, 0x6963, 0x6964, 0x6965, 0x6966, 0x6967, 0x6968,
+ 0x6969, 0x696a, 0x696b, 0x696c, 0x696d, 0x696e, 0x696f, 0x6970,
+ 0x6971, 0x6972, 0x6973, 0x6974, 0x6975, 0x6976, 0x6977, 0x6978,
+ 0x6979, 0x697a, 0x697b, 0x697c, 0x697d, 0x697e, 0x6a21, 0x6a22,
+ 0x6a23, 0x6a24, 0x6a25, 0x6a26, 0x6a27, 0x6a28, 0x6a29, 0x6a2a,
+ 0x6a2b, 0x6a2c, 0x6a2d, 0x6a2e, 0x6a2f, 0x6a30, 0x6a31, 0x6a32,
+ 0x6a33, 0x6a34, 0x6a35, 0x6a36, 0x6a37, 0x6a38, 0x6a39, 0x6a3a,
+ 0x6a3b, 0x6a3c, 0x6a3d, 0x6a3e, 0x6a3f, 0x6a40, 0x6a41, 0x6a42,
+ 0x6a43, 0x6a44, 0x6a45, 0x6a46, 0x6a47, 0x6a48, 0x6a49, 0x6a4a,
+ 0x6a4b, 0x6a4c, 0x6a4d, 0x6a4e, 0x6a4f, 0x6a50, 0x6a51, 0x6a52,
+ 0x6a53, 0x6a54, 0x6a55, 0x6a56, 0x6a57, 0x6a58, 0x6a59, 0x6a5a,
+ 0x6a5b, 0x6a5c, 0x6a5d, 0x6a5e, 0x6a5f, 0x6a60, 0x6a61, 0x6a62,
+ 0x6a63, 0x6a64, 0x6a65, 0x6a66, 0x6a67, 0x6a68, 0x6a69, 0x6a6a,
+ 0x6a6b, 0x6a6c, 0x6a6d, 0x6a6e, 0x6a6f, 0x6a70, 0x6a71, 0x6a72,
+ 0x6a73, 0x6a74, 0x6a75, 0x6a76, 0x6a77, 0x6a78, 0x6a79, 0x6a7a,
+ 0x6a7b, 0x6a7c, 0x6a7d, 0x6a7e, 0x6b21, 0x6b22, 0x6b23, 0x6b24,
+ 0x6b25, 0x6b26, 0x6b27, 0x6b28, 0x6b29, 0x6b2a, 0x6b2b, 0x6b2c,
+ 0x6b2d, 0x6b2e, 0x6b2f, 0x6b30, 0x6b31, 0x6b32, 0x6b33, 0x6b34,
+ 0x6b35, 0x6b36, 0x6b37, 0x6b38, 0x6b39, 0x6b3a, 0x6b3b, 0x6b3c,
+ 0x6b3d, 0x6b3e, 0x6b3f, 0x6b40, 0x6b41, 0x6b42, 0x6b43, 0x6b44,
+ 0x6b45, 0x6b46, 0x6b47, 0x6b48, 0x6b49, 0x6b50, 0x6b4a, 0x6b4b,
+ 0x6b4c, 0x6b4d, 0x6b52, 0x6b4e, 0x6b4f, 0x6b51, 0x6b53, 0x6b54,
+ 0x6b55, 0x6b56, 0x6b57, 0x6b58, 0x6b59, 0x6b5a, 0x6b5b, 0x6b5c,
+ 0x6b5e, 0x6b5d, 0x6b5f, 0x6b60, 0x6b61, 0x6b62, 0x6b63, 0x6b64,
+ 0x6b65, 0x6b66, 0x6b67, 0x6b68, 0x6b69, 0x6b6a, 0x6b6b, 0x6b6d,
+ 0x6b6e, 0x6b6f, 0x6b6c, 0x6b70, 0x6b71, 0x6b72, 0x6b73, 0x6b74,
+ 0x6b76, 0x6b75, 0x6b77, 0x6b78, 0x6b79, 0x6b7a, 0x6b7b, 0x6b7c,
+ 0x6b7d, 0x6b7e, 0x6c21, 0x6c22, 0x6c23, 0x6c24, 0x6c25, 0x6c26,
+ 0x6c27, 0x6c28, 0x6c29, 0x6c2a, 0x6c2b, 0x6c2c, 0x6c2d, 0x6c2e,
+ 0x6c2f, 0x6c30, 0x6c31, 0x6c32, 0x6c33, 0x6c34, 0x6c35, 0x6c36,
+ 0x6c37, 0x6c38, 0x6c39, 0x6c3a, 0x6c3b, 0x6c3c, 0x6c3d, 0x6c3e,
+ 0x6c3f, 0x6c40, 0x6c41, 0x6c42, 0x6c43, 0x6c44, 0x6c45, 0x6c46,
+ 0x6c47, 0x6c48, 0x6c49, 0x6c4a, 0x6c4b, 0x6c4c, 0x6c4e, 0x6c4f,
+ 0x6c4d, 0x6c50, 0x6c51, 0x6c52, 0x6c53, 0x6c54, 0x6c55, 0x6c56,
+ 0x6c57, 0x6c58, 0x6c59, 0x6c5a, 0x6c5b, 0x6c5c, 0x6c5d, 0x6c5e,
+ 0x6c5f, 0x6c60, 0x6c61, 0x6c62, 0x6c63, 0x6c64, 0x6c65, 0x6c66,
+ 0x6c67, 0x6c68, 0x6c69, 0x6c6a, 0x6c6b, 0x6c6c, 0x6c6d, 0x6c6e,
+ 0x6c6f, 0x6c70, 0x6c71, 0x6c72, 0x6c73, 0x6c74, 0x6c75, 0x6c76,
+ 0x6c77, 0x6c78, 0x6c79, 0x6c7a, 0x6c7b, 0x6c7c, 0x6c7d, 0x6c7e,
+ 0x6d21, 0x6d22, 0x6d23, 0x6d24, 0x6d25, 0x6d26, 0x6d27, 0x6d28,
+ 0x6d29, 0x6d2a, 0x6d2b, 0x6d2c, 0x6d2d, 0x6d2e, 0x6d2f, 0x6d30,
+ 0x6d31, 0x6d32, 0x6d33, 0x6d34, 0x6d35, 0x6d36, 0x6d37, 0x6d38,
+ 0x6d39, 0x6d3a, 0x6d3b, 0x6d3c, 0x6d3d, 0x6d3e, 0x6d3f, 0x6d40,
+ 0x6d41, 0x6d42, 0x6d43, 0x6d44, 0x6d45, 0x6d46, 0x6d47, 0x6d48,
+ 0x6d49, 0x6d4a, 0x6d4b, 0x6d4c, 0x6d4d, 0x6d4e, 0x6d4f, 0x6d50,
+ 0x6d51, 0x6d52, 0x6d53, 0x6d54, 0x6d55, 0x6d56, 0x6d57, 0x6d58,
+ 0x6d59, 0x6d5a, 0x6d5b, 0x6d5c, 0x6d5d, 0x6d5e, 0x6d5f, 0x6d60,
+ 0x6d61, 0x6d62, 0x6d63,
+};
+
+static const Summary16 jisx0212_uni2indx_page00[70] = {
+ /* 0x0000 */
+ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
+ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x4000 },
+ { 1, 0x0000 }, { 1, 0x0000 }, { 1, 0xc652 }, { 8, 0x8500 },
+ { 11, 0xffff }, { 27, 0xff7e }, { 41, 0xffff }, { 57, 0xff7f },
+ /* 0x0100 */
+ { 72, 0xffff }, { 88, 0xffcf }, { 102, 0xcff7 }, { 115, 0xffff },
+ { 131, 0x3fff }, { 145, 0xffff }, { 161, 0xffff }, { 177, 0x7fff },
+ { 192, 0x0000 }, { 192, 0x0000 }, { 192, 0x0000 }, { 192, 0x0000 },
+ { 192, 0xe000 }, { 195, 0x1fff }, { 208, 0x0000 }, { 208, 0x0020 },
+ /* 0x0200 */
+ { 209, 0x0000 }, { 209, 0x0000 }, { 209, 0x0000 }, { 209, 0x0000 },
+ { 209, 0x0000 }, { 209, 0x0000 }, { 209, 0x0000 }, { 209, 0x0000 },
+ { 209, 0x0000 }, { 209, 0x0000 }, { 209, 0x0000 }, { 209, 0x0000 },
+ { 209, 0x0080 }, { 210, 0x2f00 }, { 215, 0x0000 }, { 215, 0x0000 },
+ /* 0x0300 */
+ { 215, 0x0000 }, { 215, 0x0000 }, { 215, 0x0000 }, { 215, 0x0000 },
+ { 215, 0x0000 }, { 215, 0x0000 }, { 215, 0x0000 }, { 215, 0x0000 },
+ { 215, 0xd770 }, { 224, 0x0001 }, { 225, 0xfc00 }, { 231, 0x0001 },
+ { 232, 0x7c04 }, { 238, 0x0000 }, { 238, 0x0000 }, { 238, 0x0000 },
+ /* 0x0400 */
+ { 238, 0xdffc }, { 251, 0x0000 }, { 251, 0x0000 }, { 251, 0x0000 },
+ { 251, 0x0000 }, { 251, 0xdffc },
+};
+static const Summary16 jisx0212_uni2indx_page21[3] = {
+ /* 0x2100 */
+ { 264, 0x0000 }, { 264, 0x0040 }, { 265, 0x0004 },
+};
+static const Summary16 jisx0212_uni2indx_page4e[1307] = {
+ /* 0x4e00 */
+ { 266, 0x1034 }, { 270, 0x8004 }, { 272, 0xc918 }, { 278, 0x0021 },
+ { 280, 0x0093 }, { 284, 0x1402 }, { 287, 0x0308 }, { 290, 0x8230 },
+ { 294, 0x2000 }, { 295, 0x20c0 }, { 298, 0x8000 }, { 299, 0x0200 },
+ { 300, 0x0008 }, { 301, 0x0c01 }, { 304, 0x8107 }, { 309, 0xe02a },
+ /* 0x4f00 */
+ { 315, 0x190d }, { 321, 0x02e4 }, { 326, 0x4000 }, { 327, 0x4aaa },
+ { 334, 0x1b05 }, { 340, 0x8154 }, { 345, 0x5409 }, { 350, 0x6782 },
+ { 357, 0x5636 }, { 365, 0xc69d }, { 374, 0x0000 }, { 374, 0x7a84 },
+ { 381, 0xbb63 }, { 391, 0x1004 }, { 393, 0x0005 }, { 395, 0xb005 },
+ /* 0x5000 */
+ { 400, 0x5493 }, { 407, 0x7989 }, { 415, 0x4084 }, { 418, 0x082d },
+ { 423, 0x5467 }, { 431, 0x828e }, { 437, 0x24cd }, { 444, 0x0003 },
+ { 446, 0xc45a }, { 453, 0xd85d }, { 462, 0x8407 }, { 467, 0x2601 },
+ { 471, 0x5099 }, { 477, 0xb119 }, { 484, 0x8354 }, { 490, 0x4446 },
+ /* 0x5100 */
+ { 495, 0x79c8 }, { 503, 0x7a81 }, { 510, 0xb188 }, { 516, 0x033a },
+ { 522, 0x8404 }, { 525, 0x81a8 }, { 530, 0x0050 }, { 532, 0x4000 },
+ { 533, 0x4818 }, { 537, 0x2100 }, { 539, 0x200a }, { 542, 0xd500 },
+ { 547, 0x8104 }, { 550, 0x412e }, { 556, 0x4024 }, { 559, 0x009c },
+ /* 0x5200 */
+ { 563, 0x0026 }, { 566, 0x016c }, { 571, 0x0104 }, { 573, 0x1026 },
+ { 577, 0x0220 }, { 579, 0x95a0 }, { 585, 0x4043 }, { 589, 0x0380 },
+ { 592, 0x1425 }, { 597, 0x15e8 }, { 604, 0x80f0 }, { 609, 0x2dc1 },
+ { 616, 0x9151 }, { 622, 0x1852 }, { 627, 0x1722 }, { 633, 0x00d3 },
+ /* 0x5300 */
+ { 638, 0x1c09 }, { 643, 0xd90a }, { 650, 0x3ba0 }, { 657, 0x7025 },
+ { 663, 0x1804 }, { 666, 0x0a00 }, { 668, 0x302a }, { 673, 0x4204 },
+ { 676, 0x4188 }, { 680, 0x2218 }, { 684, 0x8c12 }, { 689, 0x25b4 },
+ { 696, 0x8021 }, { 699, 0x642c }, { 705, 0x00c1 }, { 708, 0x0020 },
+ /* 0x5400 */
+ { 709, 0x0004 }, { 710, 0x0408 }, { 712, 0x8582 }, { 717, 0x0032 },
+ { 720, 0xa098 }, { 725, 0x4000 }, { 726, 0x6ad4 }, { 734, 0x8010 },
+ { 736, 0x232a }, { 742, 0x9062 }, { 747, 0x66c2 }, { 754, 0x8e82 },
+ { 760, 0x6440 }, { 764, 0x0000 }, { 764, 0x9401 }, { 768, 0xd040 },
+ /* 0x5500 */
+ { 772, 0x7323 }, { 780, 0x0020 }, { 781, 0x0c00 }, { 783, 0x3864 },
+ { 789, 0x2682 }, { 794, 0x4d03 }, { 800, 0x0053 }, { 804, 0x8000 },
+ { 805, 0xc146 }, { 811, 0x009e }, { 816, 0x2018 }, { 819, 0x8004 },
+ { 821, 0x5a4a }, { 828, 0x498e }, { 835, 0x0204 }, { 837, 0x8040 },
+ /* 0x5600 */
+ { 839, 0xe520 }, { 845, 0x0207 }, { 849, 0x1000 }, { 850, 0xbaa9 },
+ { 859, 0xaa5b }, { 868, 0x4010 }, { 870, 0xa24f }, { 878, 0x0026 },
+ { 881, 0x1930 }, { 886, 0xe620 }, { 892, 0x3bc0 }, { 899, 0x408a },
+ { 903, 0xbe20 }, { 910, 0xb201 }, { 915, 0x29f2 }, { 923, 0x00c2 },
+ /* 0x5700 */
+ { 926, 0x1486 }, { 931, 0x2c22 }, { 936, 0xd63d }, { 946, 0xe018 },
+ { 951, 0x3060 }, { 955, 0x0004 }, { 956, 0xe9a4 }, { 964, 0x5ebb },
+ { 975, 0x100a }, { 978, 0xf6b0 }, { 987, 0x1382 }, { 992, 0x2100 },
+ { 994, 0x9180 }, { 998, 0x6020 }, { 1001, 0x22d2 }, { 1007, 0xe161 },
+ /* 0x5800 */
+ { 1014, 0x3318 }, { 1020, 0xc800 }, { 1023, 0x20c1 }, { 1027, 0x8204 },
+ { 1030, 0xb200 }, { 1034, 0x8021 }, { 1037, 0x0192 }, { 1041, 0x9100 },
+ { 1044, 0xb783 }, { 1053, 0x2051 }, { 1057, 0x0247 }, { 1062, 0x1006 },
+ { 1065, 0x6114 }, { 1070, 0x2455 }, { 1076, 0x0206 }, { 1079, 0x0008 },
+ /* 0x5900 */
+ { 1080, 0x1860 }, { 1084, 0x201c }, { 1088, 0x811a }, { 1093, 0x8069 },
+ { 1098, 0x0048 }, { 1100, 0xea0c }, { 1107, 0xa80a }, { 1112, 0x1a64 },
+ { 1118, 0x5800 }, { 1121, 0x80a4 }, { 1125, 0xe090 }, { 1130, 0x1489 },
+ { 1135, 0x251a }, { 1141, 0xe004 }, { 1145, 0xc098 }, { 1150, 0x0096 },
+ /* 0x5a00 */
+ { 1154, 0x7011 }, { 1159, 0x400c }, { 1162, 0x2598 }, { 1168, 0x0001 },
+ { 1169, 0x11b0 }, { 1174, 0x4021 }, { 1177, 0x20a8 }, { 1181, 0x4c80 },
+ { 1185, 0x0800 }, { 1186, 0xd249 }, { 1193, 0x1085 }, { 1197, 0x8d2e },
+ { 1205, 0x8150 }, { 1209, 0x1400 }, { 1211, 0x4421 }, { 1215, 0x2060 },
+ /* 0x5b00 */
+ { 1218, 0x0103 }, { 1221, 0x2a80 }, { 1225, 0x2022 }, { 1228, 0x0110 },
+ { 1230, 0x1802 }, { 1233, 0x4044 }, { 1236, 0xc100 }, { 1239, 0xf000 },
+ { 1243, 0x4452 }, { 1248, 0x005b }, { 1253, 0xb300 }, { 1258, 0x1486 },
+ { 1263, 0xa003 }, { 1267, 0x07c0 }, { 1272, 0x8001 }, { 1274, 0x2012 },
+ /* 0x5c00 */
+ { 1277, 0x1000 }, { 1278, 0xc080 }, { 1281, 0x5a48 }, { 1287, 0x0065 },
+ { 1291, 0x0000 }, { 1291, 0x1600 }, { 1294, 0x238c }, { 1300, 0x3c31 },
+ { 1307, 0x8580 }, { 1311, 0xa004 }, { 1314, 0x044d }, { 1319, 0x0434 },
+ { 1323, 0x0a00 }, { 1325, 0x2084 }, { 1328, 0x4000 }, { 1329, 0x0016 },
+ /* 0x5d00 */
+ { 1332, 0x2042 }, { 1335, 0x0004 }, { 1336, 0x08d8 }, { 1341, 0xa212 },
+ { 1346, 0x054c }, { 1351, 0x8222 }, { 1355, 0x2417 }, { 1361, 0xc601 },
+ { 1366, 0x050a }, { 1370, 0x8a3c }, { 1377, 0x0881 }, { 1380, 0x0315 },
+ { 1385, 0x4888 }, { 1389, 0x0301 }, { 1392, 0x0211 }, { 1395, 0x0300 },
+ /* 0x5e00 */
+ { 1397, 0x2081 }, { 1400, 0x8134 }, { 1405, 0x4101 }, { 1408, 0x4024 },
+ { 1411, 0x0a00 }, { 1413, 0x5943 }, { 1420, 0x7d00 }, { 1426, 0x0001 },
+ { 1427, 0x4801 }, { 1430, 0x0000 }, { 1430, 0x1534 }, { 1436, 0xe00a },
+ { 1441, 0x5840 }, { 1445, 0x5036 }, { 1451, 0x0820 }, { 1453, 0x0000 },
+ /* 0x5f00 */
+ { 1453, 0x41c4 }, { 1458, 0x3200 }, { 1461, 0x591e }, { 1469, 0xa851 },
+ { 1475, 0x20b1 }, { 1480, 0x0911 }, { 1484, 0x8099 }, { 1489, 0x6534 },
+ { 1496, 0xa200 }, { 1499, 0x3040 }, { 1502, 0x9894 }, { 1508, 0x0103 },
+ { 1511, 0x0b90 }, { 1516, 0x401f }, { 1522, 0xf706 }, { 1531, 0x144c },
+ /* 0x6000 */
+ { 1536, 0x2480 }, { 1539, 0x8598 }, { 1545, 0x2010 }, { 1547, 0x0028 },
+ { 1549, 0x1381 }, { 1554, 0x20d2 }, { 1559, 0x0082 }, { 1561, 0xc002 },
+ { 1564, 0x4544 }, { 1569, 0x612a }, { 1575, 0x0134 }, { 1579, 0x4883 },
+ { 1584, 0xcf14 }, { 1592, 0x6a30 }, { 1598, 0x0024 }, { 1600, 0x3124 },
+ /* 0x6100 */
+ { 1605, 0x1484 }, { 1609, 0x52df }, { 1619, 0x0c04 }, { 1622, 0x02e3 },
+ { 1628, 0x0262 }, { 1632, 0x4000 }, { 1633, 0x1001 }, { 1635, 0x9904 },
+ { 1640, 0x281b }, { 1646, 0xb18c }, { 1653, 0x2521 }, { 1658, 0x1300 },
+ { 1661, 0xc007 }, { 1666, 0xf020 }, { 1671, 0xb2a6 }, { 1679, 0x0000 },
+ /* 0x6200 */
+ { 1679, 0x009a }, { 1683, 0x1028 }, { 1686, 0x0a8d }, { 1692, 0x2200 },
+ { 1694, 0x105c }, { 1699, 0x1457 }, { 1706, 0xa010 }, { 1709, 0x2408 },
+ { 1712, 0xe000 }, { 1715, 0x0001 }, { 1716, 0x0140 }, { 1718, 0xc4c8 },
+ { 1724, 0x4010 }, { 1726, 0x0460 }, { 1729, 0x0400 }, { 1730, 0x3014 },
+ /* 0x6300 */
+ { 1734, 0x2c18 }, { 1739, 0x0149 }, { 1743, 0x2600 }, { 1746, 0x1260 },
+ { 1750, 0x4c5e }, { 1758, 0x091c }, { 1763, 0x3060 }, { 1767, 0xb132 },
+ { 1774, 0x0494 }, { 1778, 0x4631 }, { 1784, 0xe050 }, { 1789, 0x2000 },
+ { 1790, 0x4122 }, { 1794, 0x103a }, { 1799, 0x1421 }, { 1803, 0x032c },
+ /* 0x6400 */
+ { 1808, 0x0600 }, { 1810, 0x4115 }, { 1815, 0x8635 }, { 1822, 0xa021 },
+ { 1826, 0x8800 }, { 1828, 0xbc1e }, { 1837, 0x200b }, { 1841, 0x2818 },
+ { 1845, 0x80a0 }, { 1848, 0xab03 }, { 1855, 0x114a }, { 1860, 0xe008 },
+ { 1864, 0x5e10 }, { 1870, 0x00a3 }, { 1874, 0x2630 }, { 1879, 0x88a1 },
+ /* 0x6500 */
+ { 1884, 0x8712 }, { 1890, 0xca58 }, { 1897, 0x4244 }, { 1901, 0x3402 },
+ { 1905, 0x0288 }, { 1908, 0x8015 }, { 1912, 0x0881 }, { 1915, 0x2400 },
+ { 1917, 0x0422 }, { 1920, 0x2124 }, { 1924, 0x4049 }, { 1928, 0x801c },
+ { 1932, 0x4304 }, { 1936, 0x8151 }, { 1941, 0x0000 }, { 1941, 0xc235 },
+ /* 0x6600 */
+ { 1948, 0x2311 }, { 1953, 0x6066 }, { 1959, 0x5e5e }, { 1969, 0x028b },
+ { 1974, 0x5461 }, { 1980, 0x1b82 }, { 1986, 0x1c03 }, { 1991, 0xdba8 },
+ { 2000, 0x3801 }, { 2004, 0x9e05 }, { 2011, 0x2011 }, { 2014, 0x8826 },
+ { 2019, 0xd10d }, { 2026, 0x8810 }, { 2029, 0x5900 }, { 2033, 0x0c00 },
+ /* 0x6700 */
+ { 2035, 0x40a0 }, { 2038, 0x1208 }, { 2041, 0x0005 }, { 2043, 0x4008 },
+ { 2045, 0x11a0 }, { 2049, 0x2030 }, { 2052, 0x5040 }, { 2055, 0x0850 },
+ { 2058, 0xc012 }, { 2062, 0x0b4a }, { 2068, 0x0000 }, { 2068, 0x3827 },
+ { 2075, 0x032d }, { 2081, 0x1284 }, { 2085, 0x0042 }, { 2087, 0x02c5 },
+ /* 0x6800 */
+ { 2092, 0x0000 }, { 2092, 0xa210 }, { 2096, 0xb180 }, { 2101, 0x880b },
+ { 2106, 0x1430 }, { 2110, 0x09a4 }, { 2115, 0xc800 }, { 2118, 0x1e27 },
+ { 2126, 0x0154 }, { 2130, 0x1540 }, { 2134, 0x462a }, { 2140, 0x0804 },
+ { 2142, 0x9120 }, { 2146, 0x324b }, { 2153, 0x3d20 }, { 2159, 0x3863 },
+ /* 0x6900 */
+ { 2166, 0x0640 }, { 2169, 0x00cb }, { 2174, 0x0000 }, { 2174, 0x092a },
+ { 2179, 0x4224 }, { 2183, 0x0880 }, { 2185, 0x1378 }, { 2192, 0x8c07 },
+ { 2198, 0x2001 }, { 2200, 0x0144 }, { 2203, 0xa962 }, { 2210, 0x1580 },
+ { 2214, 0x0120 }, { 2216, 0x00c2 }, { 2219, 0xc024 }, { 2223, 0x402a },
+ /* 0x6a00 */
+ { 2227, 0x800b }, { 2231, 0x2422 }, { 2235, 0x0111 }, { 2238, 0xc895 },
+ { 2245, 0x4660 }, { 2250, 0x0867 }, { 2256, 0x0490 }, { 2259, 0x400a },
+ { 2262, 0x0aca }, { 2268, 0xe802 }, { 2273, 0x8820 }, { 2276, 0xe013 },
+ { 2282, 0x1340 }, { 2286, 0x3071 }, { 2292, 0x1090 }, { 2295, 0x3007 },
+ /* 0x6b00 */
+ { 2300, 0x82cc }, { 2306, 0x4883 }, { 2311, 0x9910 }, { 2316, 0x8860 },
+ { 2320, 0x2440 }, { 2323, 0x2144 }, { 2327, 0x4881 }, { 2331, 0x6021 },
+ { 2335, 0x0024 }, { 2337, 0x8880 }, { 2340, 0x730d }, { 2348, 0x6301 },
+ { 2353, 0x1218 }, { 2357, 0x0440 }, { 2359, 0x40ca }, { 2364, 0x8282 },
+ /* 0x6c00 */
+ { 2368, 0x6234 }, { 2374, 0x8205 }, { 2378, 0x51c0 }, { 2383, 0x8c68 },
+ { 2389, 0xac00 }, { 2393, 0x1a14 }, { 2398, 0xa880 }, { 2402, 0x0b50 },
+ { 2407, 0x02e0 }, { 2411, 0x91b0 }, { 2417, 0x0000 }, { 2417, 0x0015 },
+ { 2420, 0xa044 }, { 2424, 0x1457 }, { 2431, 0x5a81 }, { 2437, 0x0014 },
+ /* 0x6d00 */
+ { 2439, 0xc490 }, { 2444, 0x040a }, { 2447, 0xc1c0 }, { 2452, 0x9202 },
+ { 2456, 0x0000 }, { 2456, 0xc080 }, { 2459, 0x80a2 }, { 2463, 0x1001 },
+ { 2465, 0x0084 }, { 2467, 0x01d6 }, { 2473, 0x1400 }, { 2475, 0xa290 },
+ { 2480, 0xc510 }, { 2485, 0xa840 }, { 2489, 0x8225 }, { 2494, 0x1051 },
+ /* 0x6e00 */
+ { 2498, 0x0011 }, { 2500, 0x4000 }, { 2501, 0x0084 }, { 2503, 0x1a44 },
+ { 2508, 0x8b30 }, { 2514, 0x709e }, { 2522, 0x010c }, { 2525, 0x2808 },
+ { 2528, 0x2000 }, { 2529, 0x0208 }, { 2531, 0x6081 }, { 2535, 0x880a },
+ { 2539, 0xe58b }, { 2548, 0x0000 }, { 2548, 0x6800 }, { 2551, 0x2a00 },
+ /* 0x6f00 */
+ { 2554, 0x3510 }, { 2559, 0x0d40 }, { 2563, 0xa640 }, { 2568, 0x1849 },
+ { 2573, 0x8000 }, { 2574, 0x668e }, { 2582, 0x1106 }, { 2586, 0x6000 },
+ { 2588, 0x3988 }, { 2594, 0x845d }, { 2601, 0xc1e1 }, { 2608, 0x1061 },
+ { 2612, 0x05a0 }, { 2616, 0x4400 }, { 2618, 0x0300 }, { 2620, 0x3221 },
+ /* 0x7000 */
+ { 2625, 0x20e1 }, { 2630, 0x0080 }, { 2631, 0x8009 }, { 2634, 0x1290 },
+ { 2638, 0x4f18 }, { 2645, 0x6030 }, { 2649, 0x5030 }, { 2653, 0x4060 },
+ { 2656, 0x0062 }, { 2659, 0x09f0 }, { 2665, 0x0810 }, { 2667, 0x0093 },
+ { 2671, 0x0400 }, { 2672, 0x117a }, { 2679, 0x0010 }, { 2680, 0x0400 },
+ /* 0x7100 */
+ { 2681, 0x98f8 }, { 2689, 0x4000 }, { 2690, 0xa801 }, { 2694, 0x0103 },
+ { 2697, 0x0ce2 }, { 2703, 0x5485 }, { 2709, 0x0101 }, { 2711, 0x0200 },
+ { 2712, 0x10a1 }, { 2716, 0x0c04 }, { 2719, 0x8005 }, { 2722, 0x840d },
+ { 2727, 0x1813 }, { 2732, 0x1648 }, { 2737, 0x0000 }, { 2737, 0x4100 },
+ /* 0x7200 */
+ { 2739, 0x0381 }, { 2743, 0xa488 }, { 2748, 0x8810 }, { 2751, 0x0310 },
+ { 2754, 0xc02e }, { 2760, 0x5469 }, { 2767, 0xc909 }, { 2773, 0x9982 },
+ { 2779, 0x6210 }, { 2783, 0x0808 }, { 2785, 0x6100 }, { 2788, 0x4012 },
+ { 2791, 0x1282 }, { 2795, 0x8160 }, { 2799, 0x0020 }, { 2800, 0x4c18 },
+ /* 0x7300 */
+ { 2805, 0x28b4 }, { 2811, 0x430c }, { 2816, 0x1194 }, { 2821, 0x2c26 },
+ { 2827, 0x2008 }, { 2829, 0xe145 }, { 2836, 0xdac1 }, { 2844, 0x1282 },
+ { 2848, 0x406b }, { 2854, 0xd1a9 }, { 2862, 0x2c65 }, { 2869, 0xb2a0 },
+ { 2875, 0x9a60 }, { 2881, 0x224c }, { 2886, 0x02ca }, { 2891, 0xaeb0 },
+ /* 0x7400 */
+ { 2899, 0x0493 }, { 2904, 0x0c02 }, { 2907, 0xff50 }, { 2917, 0x0203 },
+ { 2920, 0x28d9 }, { 2927, 0x2086 }, { 2931, 0x69c4 }, { 2938, 0x0006 },
+ { 2940, 0x82e3 }, { 2947, 0x9707 }, { 2955, 0xcf4b }, { 2965, 0x8a26 },
+ { 2971, 0x1300 }, { 2974, 0xcd09 }, { 2981, 0x8d10 }, { 2986, 0x9c10 },
+ /* 0x7500 */
+ { 2991, 0x0040 }, { 2992, 0x00c4 }, { 2995, 0x8693 }, { 3002, 0xe240 },
+ { 3007, 0x4189 }, { 3012, 0xc085 }, { 3017, 0x8002 }, { 3019, 0x7e02 },
+ { 3026, 0x0022 }, { 3028, 0x122d }, { 3034, 0x0014 }, { 3036, 0x8410 },
+ { 3039, 0xd053 }, { 3046, 0x9080 }, { 3049, 0xd093 }, { 3056, 0x0202 },
+ /* 0x7600 */
+ { 3058, 0x959d }, { 3067, 0x7a6c }, { 3076, 0x2268 }, { 3081, 0x172c },
+ { 3088, 0x0e3b }, { 3096, 0x8220 }, { 3099, 0xe030 }, { 3104, 0x0012 },
+ { 3106, 0x3022 }, { 3110, 0xb820 }, { 3115, 0x25fd }, { 3125, 0x2000 },
+ { 3126, 0x5a22 }, { 3132, 0x0210 }, { 3134, 0x1141 }, { 3138, 0x1243 },
+ /* 0x7700 */
+ { 3143, 0x4441 }, { 3147, 0x16b4 }, { 3154, 0xe104 }, { 3159, 0x6270 },
+ { 3165, 0xe464 }, { 3172, 0xd0c4 }, { 3178, 0x1495 }, { 3184, 0x241d },
+ { 3190, 0x3011 }, { 3194, 0x8470 }, { 3199, 0xc484 }, { 3204, 0x4022 },
+ { 3207, 0x0208 }, { 3209, 0xc226 }, { 3215, 0x1451 }, { 3220, 0x0913 },
+ /* 0x7800 */
+ { 3225, 0x6260 }, { 3230, 0x2002 }, { 3232, 0x600e }, { 3237, 0x00a1 },
+ { 3240, 0x5198 }, { 3246, 0x5004 }, { 3249, 0x451b }, { 3256, 0x4400 },
+ { 3258, 0x8400 }, { 3260, 0xe110 }, { 3265, 0x3112 }, { 3270, 0xa80f },
+ { 3277, 0x5380 }, { 3282, 0x886c }, { 3288, 0x0453 }, { 3293, 0x8ccc },
+ /* 0x7900 */
+ { 3300, 0x1041 }, { 3303, 0xd401 }, { 3308, 0x22a1 }, { 3313, 0xa832 },
+ { 3319, 0x8c70 }, { 3325, 0x1912 }, { 3330, 0x0a80 }, { 3333, 0x5a04 },
+ { 3338, 0x1800 }, { 3340, 0x197a }, { 3348, 0x8b02 }, { 3353, 0x0912 },
+ { 3357, 0x8594 }, { 3363, 0x6450 }, { 3368, 0x2c25 }, { 3374, 0x1102 },
+ /* 0x7a00 */
+ { 3377, 0x168c }, { 3383, 0x4822 }, { 3387, 0xa882 }, { 3392, 0x0731 },
+ { 3398, 0x11b0 }, { 3403, 0xb260 }, { 3409, 0x24a1 }, { 3414, 0x4120 },
+ { 3417, 0x0c65 }, { 3423, 0x4013 }, { 3427, 0x1009 }, { 3430, 0x1a28 },
+ { 3435, 0x5240 }, { 3439, 0x0802 }, { 3441, 0x1b00 }, { 3445, 0x6812 },
+ /* 0x7b00 */
+ { 3450, 0x0080 }, { 3451, 0x8010 }, { 3453, 0xee88 }, { 3461, 0xa013 },
+ { 3466, 0x4083 }, { 3470, 0x0020 }, { 3471, 0xa651 }, { 3478, 0x008c },
+ { 3481, 0x4210 }, { 3484, 0x4843 }, { 3489, 0x9021 }, { 3493, 0x3c65 },
+ { 3501, 0x0524 }, { 3505, 0x0ed0 }, { 3511, 0x0500 }, { 3513, 0x5734 },
+ /* 0x7c00 */
+ { 3521, 0xda5e }, { 3531, 0x0a00 }, { 3533, 0x1161 }, { 3538, 0x065a },
+ { 3544, 0x0440 }, { 3546, 0x7e2e }, { 3556, 0x628a }, { 3562, 0x3205 },
+ { 3567, 0x80c0 }, { 3570, 0x4010 }, { 3572, 0x0041 }, { 3574, 0x9cc1 },
+ { 3581, 0xa390 }, { 3587, 0x26b8 }, { 3594, 0x0a40 }, { 3597, 0x0020 },
+ /* 0x7d00 */
+ { 3598, 0x8388 }, { 3603, 0x604e }, { 3609, 0x2448 }, { 3613, 0x7002 },
+ { 3617, 0x2183 }, { 3622, 0x368a }, { 3629, 0x04a0 }, { 3632, 0x8d01 },
+ { 3637, 0x396e }, { 3646, 0x60c2 }, { 3651, 0x04c0 }, { 3654, 0x02c8 },
+ { 3658, 0x707c }, { 3666, 0x0280 }, { 3668, 0x2c64 }, { 3674, 0x0662 },
+ /* 0x7e00 */
+ { 3679, 0x0101 }, { 3681, 0x30a3 }, { 3687, 0xb181 }, { 3693, 0x8048 },
+ { 3696, 0x40b0 }, { 3700, 0x8105 }, { 3704, 0xc826 }, { 3710, 0x4108 },
+ { 3713, 0x24c2 }, { 3718, 0x6522 }, { 3724, 0x0000 }, { 3724, 0x0000 },
+ { 3724, 0x0000 }, { 3724, 0x0000 }, { 3724, 0x0000 }, { 3724, 0x0000 },
+ /* 0x7f00 */
+ { 3724, 0x0000 }, { 3724, 0x0000 }, { 3724, 0x0000 }, { 3724, 0xf800 },
+ { 3729, 0x8098 }, { 3733, 0x380c }, { 3738, 0x207a }, { 3744, 0xe002 },
+ { 3748, 0xa801 }, { 3752, 0x10c3 }, { 3757, 0x2446 }, { 3762, 0x9010 },
+ { 3765, 0xc109 }, { 3770, 0x8800 }, { 3772, 0xd128 }, { 3778, 0xe404 },
+ /* 0x8000 */
+ { 3783, 0xe580 }, { 3789, 0xe05a }, { 3796, 0x5051 }, { 3801, 0x56b1 },
+ { 3809, 0x0011 }, { 3811, 0x0000 }, { 3811, 0x2051 }, { 3815, 0x0022 },
+ { 3817, 0x4102 }, { 3820, 0x5000 }, { 3822, 0x08c0 }, { 3825, 0x0300 },
+ { 3827, 0xa100 }, { 3830, 0x01b4 }, { 3835, 0x6001 }, { 3838, 0x464d },
+ /* 0x8100 */
+ { 3845, 0x0808 }, { 3847, 0x51c0 }, { 3852, 0x1091 }, { 3856, 0x1421 },
+ { 3860, 0x14a0 }, { 3864, 0x0084 }, { 3866, 0xa383 }, { 3873, 0x0080 },
+ { 3874, 0x4872 }, { 3880, 0x4941 }, { 3885, 0x4004 }, { 3887, 0x0814 },
+ { 3890, 0xcc28 }, { 3896, 0x68a0 }, { 3901, 0x1812 }, { 3905, 0xa367 },
+ /* 0x8200 */
+ { 3914, 0x8009 }, { 3917, 0x2618 }, { 3922, 0x0106 }, { 3925, 0x0414 },
+ { 3928, 0xc878 }, { 3935, 0x1042 }, { 3938, 0x2089 }, { 3942, 0xa810 },
+ { 3946, 0x469b }, { 3954, 0x0d52 }, { 3960, 0x479b }, { 3969, 0xd495 },
+ { 3977, 0x0040 }, { 3978, 0x0421 }, { 3981, 0xa515 }, { 3988, 0x60c0 },
+ /* 0x8300 */
+ { 3992, 0x0d83 }, { 3998, 0xe800 }, { 4002, 0x7006 }, { 4007, 0x3489 },
+ { 4013, 0x609c }, { 4019, 0x00fa }, { 4025, 0x0000 }, { 4025, 0xa101 },
+ { 4029, 0x2055 }, { 4034, 0x3b34 }, { 4042, 0x32c0 }, { 4047, 0xc000 },
+ { 4049, 0x8281 }, { 4053, 0x2013 }, { 4057, 0x0500 }, { 4059, 0x1340 },
+ /* 0x8400 */
+ { 4063, 0x8442 }, { 4067, 0x0222 }, { 4070, 0x8000 }, { 4071, 0x0200 },
+ { 4072, 0xa5a0 }, { 4078, 0x1746 }, { 4085, 0x04b1 }, { 4090, 0x3159 },
+ { 4097, 0x0022 }, { 4099, 0x402c }, { 4103, 0x8740 }, { 4108, 0x6412 },
+ { 4113, 0x9185 }, { 4119, 0x1008 }, { 4121, 0x8480 }, { 4124, 0x2c87 },
+ /* 0x8500 */
+ { 4131, 0x508c }, { 4136, 0x5001 }, { 4139, 0x8cbc }, { 4147, 0x805c },
+ { 4152, 0x8040 }, { 4154, 0xf24f }, { 4164, 0x8817 }, { 4170, 0xae00 },
+ { 4175, 0x9a62 }, { 4182, 0xa108 }, { 4186, 0x20a5 }, { 4191, 0xf1d0 },
+ { 4199, 0x4c84 }, { 4204, 0x8500 }, { 4207, 0x2141 }, { 4211, 0x9048 },
+ /* 0x8600 */
+ { 4215, 0x6031 }, { 4220, 0x4b07 }, { 4227, 0x0282 }, { 4230, 0x3540 },
+ { 4235, 0x0047 }, { 4239, 0x23cc }, { 4246, 0x921f }, { 4254, 0x04e0 },
+ { 4258, 0x2100 }, { 4260, 0x1542 }, { 4265, 0x21c2 }, { 4270, 0x83ba },
+ { 4278, 0x002b }, { 4282, 0x14a6 }, { 4288, 0x00a9 }, { 4292, 0x3400 },
+ /* 0x8700 */
+ { 4295, 0xc8b0 }, { 4301, 0xc219 }, { 4307, 0xc10a }, { 4312, 0x7606 },
+ { 4319, 0x2029 }, { 4323, 0x2100 }, { 4325, 0x8032 }, { 4329, 0x0806 },
+ { 4332, 0x1bf8 }, { 4341, 0x43a9 }, { 4348, 0x7089 }, { 4354, 0xc022 },
+ { 4358, 0x4702 }, { 4363, 0x9660 }, { 4369, 0x2c1c }, { 4375, 0x850a },
+ /* 0x8800 */
+ { 4380, 0x0e4a }, { 4386, 0xdf1d }, { 4397, 0x6100 }, { 4400, 0x1425 },
+ { 4405, 0x4f2a }, { 4413, 0x9562 }, { 4420, 0x0211 }, { 4423, 0x0a02 },
+ { 4426, 0x0001 }, { 4427, 0x9d00 }, { 4432, 0x0501 }, { 4435, 0x6400 },
+ { 4438, 0x7c01 }, { 4444, 0x480e }, { 4449, 0x8080 }, { 4451, 0x00a3 },
+ /* 0x8900 */
+ { 4455, 0xe042 }, { 4460, 0x1760 }, { 4466, 0x01c1 }, { 4470, 0x4627 },
+ { 4477, 0x8265 }, { 4483, 0x1c84 }, { 4488, 0x480e }, { 4493, 0x3c29 },
+ { 4500, 0x2200 }, { 4502, 0x9831 }, { 4508, 0x0021 }, { 4510, 0x10f1 },
+ { 4516, 0x0000 }, { 4516, 0x01f0 }, { 4521, 0x2a20 }, { 4525, 0xa24a },
+ /* 0x8a00 */
+ { 4531, 0x80b0 }, { 4535, 0x4036 }, { 4540, 0x9855 }, { 4547, 0x60a0 },
+ { 4551, 0x62a9 }, { 4558, 0x31c8 }, { 4564, 0x00a2 }, { 4567, 0xcee0 },
+ { 4575, 0x8849 }, { 4580, 0x82c5 }, { 4586, 0xc280 }, { 4590, 0x48c8 },
+ { 4595, 0x0748 }, { 4600, 0xa0ba }, { 4607, 0x1000 }, { 4608, 0x9071 },
+ /* 0x8b00 */
+ { 4614, 0x0c60 }, { 4618, 0xd002 }, { 4622, 0x2000 }, { 4623, 0x1081 },
+ { 4626, 0x217c }, { 4633, 0x421c }, { 4638, 0x2008 }, { 4640, 0x5340 },
+ { 4645, 0xa832 }, { 4651, 0xd030 }, { 4656, 0x0000 }, { 4656, 0x0000 },
+ { 4656, 0x0000 }, { 4656, 0x0000 }, { 4656, 0x0000 }, { 4656, 0x0000 },
+ /* 0x8c00 */
+ { 4656, 0x0000 }, { 4656, 0x0000 }, { 4656, 0x0000 }, { 4656, 0x6300 },
+ { 4660, 0x8aa0 }, { 4665, 0x2b9a }, { 4673, 0x2358 }, { 4679, 0x4868 },
+ { 4684, 0x08c0 }, { 4687, 0x1a0d }, { 4693, 0x0010 }, { 4694, 0x0600 },
+ { 4696, 0x8a60 }, { 4701, 0x2260 }, { 4705, 0x9102 }, { 4709, 0xc1a5 },
+ /* 0x8d00 */
+ { 4716, 0x020a }, { 4719, 0x0884 }, { 4722, 0x0000 }, { 4722, 0x0000 },
+ { 4722, 0x0000 }, { 4722, 0x0000 }, { 4722, 0x5220 }, { 4726, 0x8000 },
+ { 4727, 0x2114 }, { 4731, 0xc023 }, { 4736, 0x9841 }, { 4741, 0x1aa4 },
+ { 4747, 0x45e1 }, { 4754, 0x02b2 }, { 4759, 0x10b0 }, { 4763, 0x2017 },
+ /* 0x8e00 */
+ { 4768, 0x0872 }, { 4773, 0x0052 }, { 4776, 0x00cf }, { 4782, 0x23ca },
+ { 4789, 0xe803 }, { 4795, 0x7810 }, { 4800, 0xb206 }, { 4806, 0x0e03 },
+ { 4811, 0x020c }, { 4814, 0x6c25 }, { 4821, 0x6284 }, { 4826, 0x0c28 },
+ { 4830, 0x809b }, { 4836, 0x1012 }, { 4839, 0x6100 }, { 4842, 0x0683 },
+ /* 0x8f00 */
+ { 4847, 0x8185 }, { 4852, 0x41c1 }, { 4857, 0x71ab }, { 4866, 0x04f0 },
+ { 4871, 0x808b }, { 4876, 0x613e }, { 4884, 0x0020 }, { 4885, 0x0000 },
+ { 4885, 0x0000 }, { 4885, 0x2000 }, { 4886, 0x0073 }, { 4891, 0x4160 },
+ { 4895, 0x2c43 }, { 4901, 0x002d }, { 4905, 0x4119 }, { 4910, 0x4862 },
+ /* 0x9000 */
+ { 4915, 0x1114 }, { 4919, 0x0900 }, { 4921, 0xb700 }, { 4927, 0x8098 },
+ { 4931, 0x1018 }, { 4934, 0x2800 }, { 4936, 0x10c4 }, { 4940, 0x0211 },
+ { 4943, 0x5920 }, { 4948, 0x0ba1 }, { 4954, 0x0027 }, { 4958, 0x605d },
+ { 4965, 0x11b8 }, { 4971, 0xb3a4 }, { 4979, 0x8820 }, { 4982, 0xc051 },
+ /* 0x9100 */
+ { 4987, 0x2171 }, { 4993, 0x55d1 }, { 5001, 0xc2ad }, { 5009, 0x36d2 },
+ { 5017, 0x8188 }, { 5021, 0x0e88 }, { 5026, 0x2092 }, { 5030, 0x0e10 },
+ { 5034, 0x446a }, { 5040, 0x413a }, { 5046, 0x7142 }, { 5052, 0xb84f },
+ { 5061, 0x002c }, { 5064, 0x4698 }, { 5070, 0xf630 }, { 5078, 0x2a83 },
+ /* 0x9200 */
+ { 5084, 0x16f3 }, { 5093, 0x314d }, { 5100, 0xc178 }, { 5107, 0x5769 },
+ { 5116, 0xe4cd }, { 5125, 0x3302 }, { 5130, 0xc3a3 }, { 5138, 0xbbe1 },
+ { 5148, 0x6700 }, { 5153, 0x8284 }, { 5157, 0x89b1 }, { 5164, 0xbd44 },
+ { 5172, 0x79ef }, { 5184, 0xb3a9 }, { 5193, 0x51ab }, { 5201, 0x8a01 },
+ /* 0x9300 */
+ { 5205, 0x2105 }, { 5209, 0xf032 }, { 5216, 0x06b2 }, { 5222, 0x00d8 },
+ { 5226, 0x0380 }, { 5229, 0x45a7 }, { 5237, 0xa6b0 }, { 5244, 0xa45b },
+ { 5252, 0xad07 }, { 5260, 0x4924 }, { 5265, 0x0b5a }, { 5272, 0x0470 },
+ { 5276, 0x3ef2 }, { 5286, 0xd208 }, { 5291, 0x00c4 }, { 5294, 0x2f80 },
+ /* 0x9400 */
+ { 5300, 0xe316 }, { 5308, 0x80e0 }, { 5312, 0xc000 }, { 5314, 0xa81e },
+ { 5321, 0x1528 }, { 5326, 0x9220 }, { 5330, 0xe90a }, { 5337, 0x0006 },
+ { 5339, 0x0018 }, { 5341, 0x0000 }, { 5341, 0x0000 }, { 5341, 0x0000 },
+ { 5341, 0x0000 }, { 5341, 0x0000 }, { 5341, 0x0000 }, { 5341, 0x0000 },
+ /* 0x9500 */
+ { 5341, 0x0000 }, { 5341, 0x0000 }, { 5341, 0x0000 }, { 5341, 0x0000 },
+ { 5341, 0x0000 }, { 5341, 0x0000 }, { 5341, 0x0000 }, { 5341, 0x4300 },
+ { 5344, 0x7110 }, { 5349, 0xe000 }, { 5352, 0x1a42 }, { 5357, 0xa450 },
+ { 5362, 0x0b40 }, { 5366, 0xe60f }, { 5375, 0x0051 }, { 5378, 0x0000 },
+ /* 0x9600 */
+ { 5378, 0x0000 }, { 5378, 0x6000 }, { 5380, 0x1074 }, { 5385, 0x378a },
+ { 5393, 0x0002 }, { 5394, 0x01d4 }, { 5399, 0x4002 }, { 5401, 0xd810 },
+ { 5406, 0x021e }, { 5411, 0xa442 }, { 5416, 0xc270 }, { 5422, 0x0408 },
+ { 5424, 0x0400 }, { 5425, 0xe504 }, { 5431, 0x8200 }, { 5433, 0x0402 },
+ /* 0x9700 */
+ { 5435, 0x022c }, { 5439, 0x2c00 }, { 5442, 0x010e }, { 5446, 0x000a },
+ { 5448, 0xc40a }, { 5453, 0x0da0 }, { 5458, 0x4488 }, { 5462, 0xa9c8 },
+ { 5469, 0x0201 }, { 5471, 0xc6e0 }, { 5478, 0x5004 }, { 5481, 0xd766 },
+ { 5491, 0x76b2 }, { 5500, 0x6b93 }, { 5509, 0x8013 }, { 5513, 0x0592 },
+ /* 0x9800 */
+ { 5518, 0x6480 }, { 5522, 0x5250 }, { 5527, 0xc869 }, { 5534, 0x402d },
+ { 5539, 0x0490 }, { 5542, 0x06ce }, { 5549, 0x146c }, { 5555, 0x0000 },
+ { 5555, 0x0000 }, { 5555, 0x0000 }, { 5555, 0x6800 }, { 5558, 0x8d91 },
+ { 5565, 0x1124 }, { 5569, 0x0000 }, { 5569, 0x04ea }, { 5575, 0x0048 },
+ /* 0x9900 */
+ { 5577, 0x0184 }, { 5580, 0x9ce2 }, { 5588, 0x08c4 }, { 5592, 0x1e3e },
+ { 5601, 0x61c3 }, { 5608, 0xdb10 }, { 5615, 0x0001 }, { 5616, 0x0000 },
+ { 5616, 0x0000 }, { 5616, 0xa800 }, { 5619, 0x0040 }, { 5620, 0xa627 },
+ { 5628, 0x0208 }, { 5630, 0x5618 }, { 5636, 0x1c80 }, { 5640, 0x6231 },
+ /* 0x9a00 */
+ { 5646, 0x181c }, { 5651, 0x4043 }, { 5655, 0x609d }, { 5662, 0x0168 },
+ { 5666, 0x5c92 }, { 5673, 0x2052 }, { 5677, 0x0000 }, { 5677, 0x0000 },
+ { 5677, 0x0000 }, { 5677, 0x0000 }, { 5677, 0xd400 }, { 5681, 0xca74 },
+ { 5689, 0x414a }, { 5694, 0x18e5 }, { 5701, 0x12b1 }, { 5707, 0xa62c },
+ /* 0x9b00 */
+ { 5714, 0x7b3f }, { 5726, 0x1a45 }, { 5732, 0x2841 }, { 5736, 0x26b8 },
+ { 5743, 0x1900 }, { 5746, 0x48e0 }, { 5751, 0x7d6a }, { 5761, 0x83a8 },
+ { 5767, 0xaef1 }, { 5777, 0x6411 }, { 5782, 0x12c0 }, { 5786, 0xd987 },
+ { 5795, 0x4182 }, { 5799, 0xa181 }, { 5804, 0x8ca0 }, { 5809, 0xa788 },
+ /* 0x9c00 */
+ { 5816, 0x8805 }, { 5820, 0x5742 }, { 5827, 0x07cc }, { 5834, 0x20e2 },
+ { 5839, 0xc63a }, { 5847, 0xf959 }, { 5857, 0x4f08 }, { 5863, 0x08a5 },
+ { 5868, 0x0000 }, { 5868, 0x0000 }, { 5868, 0x0000 }, { 5868, 0x0000 },
+ { 5868, 0x0000 }, { 5868, 0x0000 }, { 5868, 0x0040 }, { 5869, 0x0284 },
+ /* 0x9d00 */
+ { 5872, 0x0804 }, { 5874, 0x7182 }, { 5880, 0x8000 }, { 5881, 0x341d },
+ { 5888, 0x04ac }, { 5893, 0x8018 }, { 5896, 0x0e2c }, { 5902, 0x58c1 },
+ { 5908, 0x6458 }, { 5914, 0x01ec }, { 5920, 0x5402 }, { 5924, 0x9222 },
+ { 5929, 0x0688 }, { 5933, 0xc4f0 }, { 5940, 0x4aa1 }, { 5946, 0x4019 },
+ /* 0x9e00 */
+ { 5950, 0x4484 }, { 5954, 0x3267 }, { 5962, 0x0000 }, { 5962, 0x0000 },
+ { 5962, 0x0000 }, { 5962, 0x0000 }, { 5962, 0x0000 }, { 5962, 0x1c00 },
+ { 5965, 0xc0bd }, { 5973, 0x4940 }, { 5977, 0xd110 }, { 5982, 0x0039 },
+ { 5986, 0x0940 }, { 5989, 0x8020 }, { 5991, 0x7090 }, { 5996, 0x8127 },
+ /* 0x9f00 */
+ { 6002, 0x820c }, { 6006, 0x8ed7 }, { 6016, 0x8c44 }, { 6021, 0xb696 },
+ { 6030, 0x00fa }, { 6036, 0x65e8 }, { 6044, 0xe300 }, { 6049, 0x242b },
+ { 6055, 0x8000 }, { 6056, 0x40d7 }, { 6063, 0x002e },
+};
+
+static int
+jisx0212_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ if (n >= 2) {
+ const Summary16 *summary = NULL;
+ if (wc < 0x0460)
+ summary = &jisx0212_uni2indx_page00[(wc>>4)];
+ else if (wc >= 0x2100 && wc < 0x2130)
+ summary = &jisx0212_uni2indx_page21[(wc>>4)-0x210];
+ else if (wc >= 0x4e00 && wc < 0x9fb0)
+ summary = &jisx0212_uni2indx_page4e[(wc>>4)-0x4e0];
+ if (summary) {
+ unsigned short used = summary->used;
+ unsigned int i = wc & 0x0f;
+ if (used & ((unsigned short) 1 << i)) {
+ unsigned short c;
+ /* Keep in `used' only the bits 0..i-1. */
+ used &= ((unsigned short) 1 << i) - 1;
+ /* Add `summary->indx' and the number of bits set in `used'. */
+ used = (used & 0x5555) + ((used & 0xaaaa) >> 1);
+ used = (used & 0x3333) + ((used & 0xcccc) >> 2);
+ used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4);
+ used = (used & 0x00ff) + (used >> 8);
+ c = jisx0212_2charset[summary->indx + used];
+ r[0] = (c >> 8); r[1] = (c & 0xff);
+ return 2;
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOSMALL;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/koi8_c.h b/nx-X11/lib/X11/lcUniConv/koi8_c.h
new file mode 100644
index 000000000..504c2589c
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/koi8_c.h
@@ -0,0 +1,103 @@
+/* $XFree86: xc/lib/X11/lcUniConv/koi8_c.h,v 1.1 2000/10/27 20:26:08 dawes Exp $ */
+
+/*
+ * KOI8-C
+ */
+
+static const unsigned short koi8_c_2uni[128] = {
+ /* 0x80 */
+ 0x0493, 0x0497, 0x049b, 0x049d, 0x04a3, 0x04af, 0x04b1, 0x04b3,
+ 0x04b7, 0x04b9, 0x04bb, 0x2580, 0x04d9, 0x04e3, 0x04e9, 0x04ef,
+ /* 0x90 */
+ 0x0492, 0x0496, 0x049a, 0x049c, 0x04a2, 0x04ae, 0x04b0, 0x04b2,
+ 0x04b6, 0x04b8, 0x04ba, 0x2321, 0x04d8, 0x04e2, 0x04e8, 0x04ee,
+ /* 0xa0 */
+ 0x00a0, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x0491, 0x045e, 0x045f,
+ /* 0xb0 */
+ 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0486, 0x0409, 0x040a, 0x040b, 0x040c, 0x0490, 0x040e, 0x040f,
+ /* 0xc0 */
+ 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
+ 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e,
+ /* 0xd0 */
+ 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
+ 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a,
+ /* 0xe0 */
+ 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
+ 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e,
+ /* 0xf0 */
+ 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
+ 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a,
+};
+
+static int
+koi8_c_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0x80)
+ *pwc = (ucs4_t) c;
+ else
+ *pwc = (ucs4_t) koi8_c_2uni[c-0x80];
+ return 1;
+}
+
+static const unsigned char koi8_c_page00[1] = {
+ 0xa0, /* 0xa0-0xa7 */
+};
+static const unsigned char koi8_c_page04[240] = {
+ 0x00, 0xb3, 0xb1, 0xb2, 0xb4, 0xb5, 0xb6, 0xb7, /* 0x00-0x07 */
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0x00, 0xbe, 0xbf, /* 0x08-0x0f */
+ 0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, /* 0x10-0x17 */
+ 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, /* 0x18-0x1f */
+ 0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, /* 0x20-0x27 */
+ 0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, /* 0x28-0x2f */
+ 0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, /* 0x30-0x37 */
+ 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, /* 0x38-0x3f */
+ 0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, /* 0x40-0x47 */
+ 0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1, /* 0x48-0x4f */
+ 0x00, 0xa3, 0xa1, 0xa2, 0xa4, 0xa5, 0xa6, 0xa7, /* 0x50-0x57 */
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0x00, 0xae, 0xaf, /* 0x58-0x5f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+ 0xbd, 0xad, 0x90, 0x80, 0x00, 0x00, 0x91, 0x81, /* 0x90-0x97 */
+ 0x00, 0x00, 0x92, 0x82, 0x93, 0x83, 0x00, 0x00, /* 0x98-0x9f */
+ 0x00, 0x00, 0x94, 0x84, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x85, /* 0xa8-0xaf */
+ 0x96, 0x86, 0x97, 0x87, 0x00, 0x00, 0x98, 0x88, /* 0xb0-0xb7 */
+ 0x99, 0x89, 0x9a, 0x8a, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+ 0x9c, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+ 0x00, 0x00, 0x9d, 0x8d, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
+ 0x9e, 0x8e, 0x00, 0x00, 0x00, 0x00, 0x9f, 0x8f, /* 0xe8-0xef */
+};
+static const unsigned char koi8_c_page22[1] = {
+ 0xb0, /* 0x16-0x16 */
+};
+
+static int
+koi8_c_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0080) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x00a1)
+ c = koi8_c_page00[wc-0x00a0];
+ else if (wc >= 0x0400 && wc < 0x04ef)
+ c = koi8_c_page04[wc-0x0400];
+ else if (wc >= 0x2216 && wc < 0x2217)
+ c = koi8_c_page22[wc-0x2216];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/koi8_r.h b/nx-X11/lib/X11/lcUniConv/koi8_r.h
new file mode 100644
index 000000000..dfbbb8dc3
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/koi8_r.h
@@ -0,0 +1,135 @@
+/* $XFree86$ */
+
+/*
+ * KOI8-R
+ */
+
+/* Specification: RFC 1489 */
+
+static const unsigned short koi8_r_2uni[128] = {
+ /* 0x80 */
+ 0x2500, 0x2502, 0x250c, 0x2510, 0x2514, 0x2518, 0x251c, 0x2524,
+ 0x252c, 0x2534, 0x253c, 0x2580, 0x2584, 0x2588, 0x258c, 0x2590,
+ /* 0x90 */
+ 0x2591, 0x2592, 0x2593, 0x2320, 0x25a0, 0x2219, 0x221a, 0x2248,
+ 0x2264, 0x2265, 0x00a0, 0x2321, 0x00b0, 0x00b2, 0x00b7, 0x00f7,
+ /* 0xa0 */
+ 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556,
+ 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d, 0x255e,
+ /* 0xb0 */
+ 0x255f, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565,
+ 0x2566, 0x2567, 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x00a9,
+ /* 0xc0 */
+ 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
+ 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e,
+ /* 0xd0 */
+ 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
+ 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a,
+ /* 0xe0 */
+ 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
+ 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e,
+ /* 0xf0 */
+ 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
+ 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a,
+};
+
+static int
+koi8_r_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0x80)
+ *pwc = (ucs4_t) c;
+ else
+ *pwc = (ucs4_t) koi8_r_2uni[c-0x80];
+ return 1;
+}
+
+static const unsigned char koi8_r_page00[88] = {
+ 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+ 0x00, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
+ 0x9c, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x00, 0x9e, /* 0xb0-0xb7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9f, /* 0xf0-0xf7 */
+};
+static const unsigned char koi8_r_page04[88] = {
+ 0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */
+ 0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, /* 0x10-0x17 */
+ 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, /* 0x18-0x1f */
+ 0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, /* 0x20-0x27 */
+ 0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, /* 0x28-0x2f */
+ 0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, /* 0x30-0x37 */
+ 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, /* 0x38-0x3f */
+ 0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, /* 0x40-0x47 */
+ 0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1, /* 0x48-0x4f */
+ 0x00, 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+};
+static const unsigned char koi8_r_page22[80] = {
+ 0x00, 0x95, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
+ 0x97, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0x00, 0x00, 0x00, 0x00, 0x98, 0x99, 0x00, 0x00, /* 0x60-0x67 */
+};
+static const unsigned char koi8_r_page23[8] = {
+ 0x93, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+};
+static const unsigned char koi8_r_page25[168] = {
+ 0x80, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */
+ 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, /* 0x08-0x0f */
+ 0x83, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x85, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x00, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
+ 0xa0, 0xa1, 0xa2, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, /* 0x50-0x57 */
+ 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, /* 0x58-0x5f */
+ 0xb1, 0xb2, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, /* 0x60-0x67 */
+ 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+ 0x8b, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x8d, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+ 0x8f, 0x90, 0x91, 0x92, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
+ 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+};
+
+static int
+koi8_r_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0080) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x00f8)
+ c = koi8_r_page00[wc-0x00a0];
+ else if (wc >= 0x0400 && wc < 0x0458)
+ c = koi8_r_page04[wc-0x0400];
+ else if (wc >= 0x2218 && wc < 0x2268)
+ c = koi8_r_page22[wc-0x2218];
+ else if (wc >= 0x2320 && wc < 0x2328)
+ c = koi8_r_page23[wc-0x2320];
+ else if (wc >= 0x2500 && wc < 0x25a8)
+ c = koi8_r_page25[wc-0x2500];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/koi8_u.h b/nx-X11/lib/X11/lcUniConv/koi8_u.h
new file mode 100644
index 000000000..168d6a102
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/koi8_u.h
@@ -0,0 +1,143 @@
+/* $XFree86$ */
+
+/*
+ * KOI8-U
+ */
+
+/* Specification: RFC 2319 */
+
+static const unsigned short koi8_u_2uni[128] = {
+ /* 0x80 */
+ 0x2500, 0x2502, 0x250c, 0x2510, 0x2514, 0x2518, 0x251c, 0x2524,
+ 0x252c, 0x2534, 0x253c, 0x2580, 0x2584, 0x2588, 0x258c, 0x2590,
+ /* 0x90 */
+ 0x2591, 0x2592, 0x2593, 0x2320, 0x25a0, 0x2219, 0x221a, 0x2248,
+ 0x2264, 0x2265, 0x00a0, 0x2321, 0x00b0, 0x00b2, 0x00b7, 0x00f7,
+ /* 0xa0 */
+ 0x2550, 0x2551, 0x2552, 0x0451, 0x0454, 0x2554, 0x0456, 0x0457,
+ 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x0491, 0x255d, 0x255e,
+ /* 0xb0 */
+ 0x255f, 0x2560, 0x2561, 0x0401, 0x0404, 0x2563, 0x0406, 0x0407,
+ 0x2566, 0x2567, 0x2568, 0x2569, 0x256a, 0x0490, 0x256c, 0x00a9,
+ /* 0xc0 */
+ 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
+ 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e,
+ /* 0xd0 */
+ 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
+ 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a,
+ /* 0xe0 */
+ 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
+ 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e,
+ /* 0xf0 */
+ 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
+ 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a,
+};
+
+static int
+koi8_u_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0x80)
+ *pwc = (ucs4_t) c;
+ else
+ *pwc = (ucs4_t) koi8_u_2uni[c-0x80];
+ return 1;
+}
+
+static const unsigned char koi8_u_page00[88] = {
+ 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+ 0x00, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
+ 0x9c, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x00, 0x9e, /* 0xb0-0xb7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9f, /* 0xf0-0xf7 */
+};
+static const unsigned char koi8_u_page04[152] = {
+ 0x00, 0xb3, 0x00, 0x00, 0xb4, 0x00, 0xb6, 0xb7, /* 0x00-0x07 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */
+ 0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, /* 0x10-0x17 */
+ 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, /* 0x18-0x1f */
+ 0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, /* 0x20-0x27 */
+ 0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, /* 0x28-0x2f */
+ 0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, /* 0x30-0x37 */
+ 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, /* 0x38-0x3f */
+ 0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, /* 0x40-0x47 */
+ 0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1, /* 0x48-0x4f */
+ 0x00, 0xa3, 0x00, 0x00, 0xa4, 0x00, 0xa6, 0xa7, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+ 0xbd, 0xad, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+};
+static const unsigned char koi8_u_page22[80] = {
+ 0x00, 0x95, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
+ 0x97, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0x00, 0x00, 0x00, 0x00, 0x98, 0x99, 0x00, 0x00, /* 0x60-0x67 */
+};
+static const unsigned char koi8_u_page23[8] = {
+ 0x93, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+};
+static const unsigned char koi8_u_page25[168] = {
+ 0x80, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */
+ 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, /* 0x08-0x0f */
+ 0x83, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x85, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x00, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
+ 0xa0, 0xa1, 0xa2, 0x00, 0xa5, 0x00, 0x00, 0xa8, /* 0x50-0x57 */
+ 0xa9, 0xaa, 0xab, 0xac, 0x00, 0xae, 0xaf, 0xb0, /* 0x58-0x5f */
+ 0xb1, 0xb2, 0x00, 0xb5, 0x00, 0x00, 0xb8, 0xb9, /* 0x60-0x67 */
+ 0xba, 0xbb, 0xbc, 0x00, 0xbe, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+ 0x8b, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x8d, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+ 0x8f, 0x90, 0x91, 0x92, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
+ 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+};
+
+static int
+koi8_u_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0080) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x00f8)
+ c = koi8_u_page00[wc-0x00a0];
+ else if (wc >= 0x0400 && wc < 0x0498)
+ c = koi8_u_page04[wc-0x0400];
+ else if (wc >= 0x2218 && wc < 0x2268)
+ c = koi8_u_page22[wc-0x2218];
+ else if (wc >= 0x2320 && wc < 0x2328)
+ c = koi8_u_page23[wc-0x2320];
+ else if (wc >= 0x2500 && wc < 0x25a8)
+ c = koi8_u_page25[wc-0x2500];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/ksc5601.h b/nx-X11/lib/X11/lcUniConv/ksc5601.h
new file mode 100644
index 000000000..7e2a4623e
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/ksc5601.h
@@ -0,0 +1,3003 @@
+/* $XFree86: xc/lib/X11/lcUniConv/ksc5601.h,v 1.4tsi Exp $ */
+
+/*
+ * KSC5601.1987-0
+ */
+
+static const unsigned short ksc5601_2uni_page21[1115] = {
+ /* 0x21 */
+ 0x3000, 0x3001, 0x3002, 0x00b7, 0x2025, 0x2026, 0x00a8, 0x3003,
+ 0x00ad, 0x2015, 0x2225, 0xff3c, 0x223c, 0x2018, 0x2019, 0x201c,
+ 0x201d, 0x3014, 0x3015, 0x3008, 0x3009, 0x300a, 0x300b, 0x300c,
+ 0x300d, 0x300e, 0x300f, 0x3010, 0x3011, 0x00b1, 0x00d7, 0x00f7,
+ 0x2260, 0x2264, 0x2265, 0x221e, 0x2234, 0x00b0, 0x2032, 0x2033,
+ 0x2103, 0x212b, 0xffe0, 0xffe1, 0xffe5, 0x2642, 0x2640, 0x2220,
+ 0x22a5, 0x2312, 0x2202, 0x2207, 0x2261, 0x2252, 0x00a7, 0x203b,
+ 0x2606, 0x2605, 0x25cb, 0x25cf, 0x25ce, 0x25c7, 0x25c6, 0x25a1,
+ 0x25a0, 0x25b3, 0x25b2, 0x25bd, 0x25bc, 0x2192, 0x2190, 0x2191,
+ 0x2193, 0x2194, 0x3013, 0x226a, 0x226b, 0x221a, 0x223d, 0x221d,
+ 0x2235, 0x222b, 0x222c, 0x2208, 0x220b, 0x2286, 0x2287, 0x2282,
+ 0x2283, 0x222a, 0x2229, 0x2227, 0x2228, 0xffe2,
+ /* 0x22 */
+ 0x21d2, 0x21d4, 0x2200, 0x2203, 0x00b4, 0xff5e, 0x02c7, 0x02d8,
+ 0x02dd, 0x02da, 0x02d9, 0x00b8, 0x02db, 0x00a1, 0x00bf, 0x02d0,
+ 0x222e, 0x2211, 0x220f, 0x00a4, 0x2109, 0x2030, 0x25c1, 0x25c0,
+ 0x25b7, 0x25b6, 0x2664, 0x2660, 0x2661, 0x2665, 0x2667, 0x2663,
+ 0x2299, 0x25c8, 0x25a3, 0x25d0, 0x25d1, 0x2592, 0x25a4, 0x25a5,
+ 0x25a8, 0x25a7, 0x25a6, 0x25a9, 0x2668, 0x260f, 0x260e, 0x261c,
+ 0x261e, 0x00b6, 0x2020, 0x2021, 0x2195, 0x2197, 0x2199, 0x2196,
+ 0x2198, 0x266d, 0x2669, 0x266a, 0x266c, 0x327f, 0x321c, 0x2116,
+ 0x33c7, 0x2122, 0x33c2, 0x33d8, 0x2121, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x23 */
+ 0xff01, 0xff02, 0xff03, 0xff04, 0xff05, 0xff06, 0xff07, 0xff08,
+ 0xff09, 0xff0a, 0xff0b, 0xff0c, 0xff0d, 0xff0e, 0xff0f, 0xff10,
+ 0xff11, 0xff12, 0xff13, 0xff14, 0xff15, 0xff16, 0xff17, 0xff18,
+ 0xff19, 0xff1a, 0xff1b, 0xff1c, 0xff1d, 0xff1e, 0xff1f, 0xff20,
+ 0xff21, 0xff22, 0xff23, 0xff24, 0xff25, 0xff26, 0xff27, 0xff28,
+ 0xff29, 0xff2a, 0xff2b, 0xff2c, 0xff2d, 0xff2e, 0xff2f, 0xff30,
+ 0xff31, 0xff32, 0xff33, 0xff34, 0xff35, 0xff36, 0xff37, 0xff38,
+ 0xff39, 0xff3a, 0xff3b, 0xffe6, 0xff3d, 0xff3e, 0xff3f, 0xff40,
+ 0xff41, 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48,
+ 0xff49, 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50,
+ 0xff51, 0xff52, 0xff53, 0xff54, 0xff55, 0xff56, 0xff57, 0xff58,
+ 0xff59, 0xff5a, 0xff5b, 0xff5c, 0xff5d, 0xffe3,
+ /* 0x24 */
+ 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137, 0x3138,
+ 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f, 0x3140,
+ 0x3141, 0x3142, 0x3143, 0x3144, 0x3145, 0x3146, 0x3147, 0x3148,
+ 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e, 0x314f, 0x3150,
+ 0x3151, 0x3152, 0x3153, 0x3154, 0x3155, 0x3156, 0x3157, 0x3158,
+ 0x3159, 0x315a, 0x315b, 0x315c, 0x315d, 0x315e, 0x315f, 0x3160,
+ 0x3161, 0x3162, 0x3163, 0x3164, 0x3165, 0x3166, 0x3167, 0x3168,
+ 0x3169, 0x316a, 0x316b, 0x316c, 0x316d, 0x316e, 0x316f, 0x3170,
+ 0x3171, 0x3172, 0x3173, 0x3174, 0x3175, 0x3176, 0x3177, 0x3178,
+ 0x3179, 0x317a, 0x317b, 0x317c, 0x317d, 0x317e, 0x317f, 0x3180,
+ 0x3181, 0x3182, 0x3183, 0x3184, 0x3185, 0x3186, 0x3187, 0x3188,
+ 0x3189, 0x318a, 0x318b, 0x318c, 0x318d, 0x318e,
+ /* 0x25 */
+ 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177,
+ 0x2178, 0x2179, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x2160,
+ 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168,
+ 0x2169, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398,
+ 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, 0x03a0,
+ 0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, 0x03b8,
+ 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, 0x03c0,
+ 0x03c1, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x26 */
+ 0x2500, 0x2502, 0x250c, 0x2510, 0x2518, 0x2514, 0x251c, 0x252c,
+ 0x2524, 0x2534, 0x253c, 0x2501, 0x2503, 0x250f, 0x2513, 0x251b,
+ 0x2517, 0x2523, 0x2533, 0x252b, 0x253b, 0x254b, 0x2520, 0x252f,
+ 0x2528, 0x2537, 0x253f, 0x251d, 0x2530, 0x2525, 0x2538, 0x2542,
+ 0x2512, 0x2511, 0x251a, 0x2519, 0x2516, 0x2515, 0x250e, 0x250d,
+ 0x251e, 0x251f, 0x2521, 0x2522, 0x2526, 0x2527, 0x2529, 0x252a,
+ 0x252d, 0x252e, 0x2531, 0x2532, 0x2535, 0x2536, 0x2539, 0x253a,
+ 0x253d, 0x253e, 0x2540, 0x2541, 0x2543, 0x2544, 0x2545, 0x2546,
+ 0x2547, 0x2548, 0x2549, 0x254a, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x27 */
+ 0x3395, 0x3396, 0x3397, 0x2113, 0x3398, 0x33c4, 0x33a3, 0x33a4,
+ 0x33a5, 0x33a6, 0x3399, 0x339a, 0x339b, 0x339c, 0x339d, 0x339e,
+ 0x339f, 0x33a0, 0x33a1, 0x33a2, 0x33ca, 0x338d, 0x338e, 0x338f,
+ 0x33cf, 0x3388, 0x3389, 0x33c8, 0x33a7, 0x33a8, 0x33b0, 0x33b1,
+ 0x33b2, 0x33b3, 0x33b4, 0x33b5, 0x33b6, 0x33b7, 0x33b8, 0x33b9,
+ 0x3380, 0x3381, 0x3382, 0x3383, 0x3384, 0x33ba, 0x33bb, 0x33bc,
+ 0x33bd, 0x33be, 0x33bf, 0x3390, 0x3391, 0x3392, 0x3393, 0x3394,
+ 0x2126, 0x33c0, 0x33c1, 0x338a, 0x338b, 0x338c, 0x33d6, 0x33c5,
+ 0x33ad, 0x33ae, 0x33af, 0x33db, 0x33a9, 0x33aa, 0x33ab, 0x33ac,
+ 0x33dd, 0x33d0, 0x33d3, 0x33c3, 0x33c9, 0x33dc, 0x33c6, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x28 */
+ 0x00c6, 0x00d0, 0x00aa, 0x0126, 0xfffd, 0x0132, 0xfffd, 0x013f,
+ 0x0141, 0x00d8, 0x0152, 0x00ba, 0x00de, 0x0166, 0x014a, 0xfffd,
+ 0x3260, 0x3261, 0x3262, 0x3263, 0x3264, 0x3265, 0x3266, 0x3267,
+ 0x3268, 0x3269, 0x326a, 0x326b, 0x326c, 0x326d, 0x326e, 0x326f,
+ 0x3270, 0x3271, 0x3272, 0x3273, 0x3274, 0x3275, 0x3276, 0x3277,
+ 0x3278, 0x3279, 0x327a, 0x327b, 0x24d0, 0x24d1, 0x24d2, 0x24d3,
+ 0x24d4, 0x24d5, 0x24d6, 0x24d7, 0x24d8, 0x24d9, 0x24da, 0x24db,
+ 0x24dc, 0x24dd, 0x24de, 0x24df, 0x24e0, 0x24e1, 0x24e2, 0x24e3,
+ 0x24e4, 0x24e5, 0x24e6, 0x24e7, 0x24e8, 0x24e9, 0x2460, 0x2461,
+ 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, 0x2468, 0x2469,
+ 0x246a, 0x246b, 0x246c, 0x246d, 0x246e, 0x00bd, 0x2153, 0x2154,
+ 0x00bc, 0x00be, 0x215b, 0x215c, 0x215d, 0x215e,
+ /* 0x29 */
+ 0x00e6, 0x0111, 0x00f0, 0x0127, 0x0131, 0x0133, 0x0138, 0x0140,
+ 0x0142, 0x00f8, 0x0153, 0x00df, 0x00fe, 0x0167, 0x014b, 0x0149,
+ 0x3200, 0x3201, 0x3202, 0x3203, 0x3204, 0x3205, 0x3206, 0x3207,
+ 0x3208, 0x3209, 0x320a, 0x320b, 0x320c, 0x320d, 0x320e, 0x320f,
+ 0x3210, 0x3211, 0x3212, 0x3213, 0x3214, 0x3215, 0x3216, 0x3217,
+ 0x3218, 0x3219, 0x321a, 0x321b, 0x249c, 0x249d, 0x249e, 0x249f,
+ 0x24a0, 0x24a1, 0x24a2, 0x24a3, 0x24a4, 0x24a5, 0x24a6, 0x24a7,
+ 0x24a8, 0x24a9, 0x24aa, 0x24ab, 0x24ac, 0x24ad, 0x24ae, 0x24af,
+ 0x24b0, 0x24b1, 0x24b2, 0x24b3, 0x24b4, 0x24b5, 0x2474, 0x2475,
+ 0x2476, 0x2477, 0x2478, 0x2479, 0x247a, 0x247b, 0x247c, 0x247d,
+ 0x247e, 0x247f, 0x2480, 0x2481, 0x2482, 0x00b9, 0x00b2, 0x00b3,
+ 0x2074, 0x207f, 0x2081, 0x2082, 0x2083, 0x2084,
+ /* 0x2a */
+ 0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046, 0x3047, 0x3048,
+ 0x3049, 0x304a, 0x304b, 0x304c, 0x304d, 0x304e, 0x304f, 0x3050,
+ 0x3051, 0x3052, 0x3053, 0x3054, 0x3055, 0x3056, 0x3057, 0x3058,
+ 0x3059, 0x305a, 0x305b, 0x305c, 0x305d, 0x305e, 0x305f, 0x3060,
+ 0x3061, 0x3062, 0x3063, 0x3064, 0x3065, 0x3066, 0x3067, 0x3068,
+ 0x3069, 0x306a, 0x306b, 0x306c, 0x306d, 0x306e, 0x306f, 0x3070,
+ 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076, 0x3077, 0x3078,
+ 0x3079, 0x307a, 0x307b, 0x307c, 0x307d, 0x307e, 0x307f, 0x3080,
+ 0x3081, 0x3082, 0x3083, 0x3084, 0x3085, 0x3086, 0x3087, 0x3088,
+ 0x3089, 0x308a, 0x308b, 0x308c, 0x308d, 0x308e, 0x308f, 0x3090,
+ 0x3091, 0x3092, 0x3093, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x2b */
+ 0x30a1, 0x30a2, 0x30a3, 0x30a4, 0x30a5, 0x30a6, 0x30a7, 0x30a8,
+ 0x30a9, 0x30aa, 0x30ab, 0x30ac, 0x30ad, 0x30ae, 0x30af, 0x30b0,
+ 0x30b1, 0x30b2, 0x30b3, 0x30b4, 0x30b5, 0x30b6, 0x30b7, 0x30b8,
+ 0x30b9, 0x30ba, 0x30bb, 0x30bc, 0x30bd, 0x30be, 0x30bf, 0x30c0,
+ 0x30c1, 0x30c2, 0x30c3, 0x30c4, 0x30c5, 0x30c6, 0x30c7, 0x30c8,
+ 0x30c9, 0x30ca, 0x30cb, 0x30cc, 0x30cd, 0x30ce, 0x30cf, 0x30d0,
+ 0x30d1, 0x30d2, 0x30d3, 0x30d4, 0x30d5, 0x30d6, 0x30d7, 0x30d8,
+ 0x30d9, 0x30da, 0x30db, 0x30dc, 0x30dd, 0x30de, 0x30df, 0x30e0,
+ 0x30e1, 0x30e2, 0x30e3, 0x30e4, 0x30e5, 0x30e6, 0x30e7, 0x30e8,
+ 0x30e9, 0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ee, 0x30ef, 0x30f0,
+ 0x30f1, 0x30f2, 0x30f3, 0x30f4, 0x30f5, 0x30f6, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ /* 0x2c */
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0401, 0x0416,
+ 0x0417, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e,
+ 0x041f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426,
+ 0x0427, 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e,
+ 0x042f, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0451, 0x0436,
+ 0x0437, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e,
+ 0x043f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446,
+ 0x0447, 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e,
+ 0x044f,
+};
+static const unsigned short ksc5601_2uni_page30[2350] = {
+ /* 0x30 */
+ 0xac00, 0xac01, 0xac04, 0xac07, 0xac08, 0xac09, 0xac0a, 0xac10,
+ 0xac11, 0xac12, 0xac13, 0xac14, 0xac15, 0xac16, 0xac17, 0xac19,
+ 0xac1a, 0xac1b, 0xac1c, 0xac1d, 0xac20, 0xac24, 0xac2c, 0xac2d,
+ 0xac2f, 0xac30, 0xac31, 0xac38, 0xac39, 0xac3c, 0xac40, 0xac4b,
+ 0xac4d, 0xac54, 0xac58, 0xac5c, 0xac70, 0xac71, 0xac74, 0xac77,
+ 0xac78, 0xac7a, 0xac80, 0xac81, 0xac83, 0xac84, 0xac85, 0xac86,
+ 0xac89, 0xac8a, 0xac8b, 0xac8c, 0xac90, 0xac94, 0xac9c, 0xac9d,
+ 0xac9f, 0xaca0, 0xaca1, 0xaca8, 0xaca9, 0xacaa, 0xacac, 0xacaf,
+ 0xacb0, 0xacb8, 0xacb9, 0xacbb, 0xacbc, 0xacbd, 0xacc1, 0xacc4,
+ 0xacc8, 0xaccc, 0xacd5, 0xacd7, 0xace0, 0xace1, 0xace4, 0xace7,
+ 0xace8, 0xacea, 0xacec, 0xacef, 0xacf0, 0xacf1, 0xacf3, 0xacf5,
+ 0xacf6, 0xacfc, 0xacfd, 0xad00, 0xad04, 0xad06,
+ /* 0x31 */
+ 0xad0c, 0xad0d, 0xad0f, 0xad11, 0xad18, 0xad1c, 0xad20, 0xad29,
+ 0xad2c, 0xad2d, 0xad34, 0xad35, 0xad38, 0xad3c, 0xad44, 0xad45,
+ 0xad47, 0xad49, 0xad50, 0xad54, 0xad58, 0xad61, 0xad63, 0xad6c,
+ 0xad6d, 0xad70, 0xad73, 0xad74, 0xad75, 0xad76, 0xad7b, 0xad7c,
+ 0xad7d, 0xad7f, 0xad81, 0xad82, 0xad88, 0xad89, 0xad8c, 0xad90,
+ 0xad9c, 0xad9d, 0xada4, 0xadb7, 0xadc0, 0xadc1, 0xadc4, 0xadc8,
+ 0xadd0, 0xadd1, 0xadd3, 0xaddc, 0xade0, 0xade4, 0xadf8, 0xadf9,
+ 0xadfc, 0xadff, 0xae00, 0xae01, 0xae08, 0xae09, 0xae0b, 0xae0d,
+ 0xae14, 0xae30, 0xae31, 0xae34, 0xae37, 0xae38, 0xae3a, 0xae40,
+ 0xae41, 0xae43, 0xae45, 0xae46, 0xae4a, 0xae4c, 0xae4d, 0xae4e,
+ 0xae50, 0xae54, 0xae56, 0xae5c, 0xae5d, 0xae5f, 0xae60, 0xae61,
+ 0xae65, 0xae68, 0xae69, 0xae6c, 0xae70, 0xae78,
+ /* 0x32 */
+ 0xae79, 0xae7b, 0xae7c, 0xae7d, 0xae84, 0xae85, 0xae8c, 0xaebc,
+ 0xaebd, 0xaebe, 0xaec0, 0xaec4, 0xaecc, 0xaecd, 0xaecf, 0xaed0,
+ 0xaed1, 0xaed8, 0xaed9, 0xaedc, 0xaee8, 0xaeeb, 0xaeed, 0xaef4,
+ 0xaef8, 0xaefc, 0xaf07, 0xaf08, 0xaf0d, 0xaf10, 0xaf2c, 0xaf2d,
+ 0xaf30, 0xaf32, 0xaf34, 0xaf3c, 0xaf3d, 0xaf3f, 0xaf41, 0xaf42,
+ 0xaf43, 0xaf48, 0xaf49, 0xaf50, 0xaf5c, 0xaf5d, 0xaf64, 0xaf65,
+ 0xaf79, 0xaf80, 0xaf84, 0xaf88, 0xaf90, 0xaf91, 0xaf95, 0xaf9c,
+ 0xafb8, 0xafb9, 0xafbc, 0xafc0, 0xafc7, 0xafc8, 0xafc9, 0xafcb,
+ 0xafcd, 0xafce, 0xafd4, 0xafdc, 0xafe8, 0xafe9, 0xaff0, 0xaff1,
+ 0xaff4, 0xaff8, 0xb000, 0xb001, 0xb004, 0xb00c, 0xb010, 0xb014,
+ 0xb01c, 0xb01d, 0xb028, 0xb044, 0xb045, 0xb048, 0xb04a, 0xb04c,
+ 0xb04e, 0xb053, 0xb054, 0xb055, 0xb057, 0xb059,
+ /* 0x33 */
+ 0xb05d, 0xb07c, 0xb07d, 0xb080, 0xb084, 0xb08c, 0xb08d, 0xb08f,
+ 0xb091, 0xb098, 0xb099, 0xb09a, 0xb09c, 0xb09f, 0xb0a0, 0xb0a1,
+ 0xb0a2, 0xb0a8, 0xb0a9, 0xb0ab, 0xb0ac, 0xb0ad, 0xb0ae, 0xb0af,
+ 0xb0b1, 0xb0b3, 0xb0b4, 0xb0b5, 0xb0b8, 0xb0bc, 0xb0c4, 0xb0c5,
+ 0xb0c7, 0xb0c8, 0xb0c9, 0xb0d0, 0xb0d1, 0xb0d4, 0xb0d8, 0xb0e0,
+ 0xb0e5, 0xb108, 0xb109, 0xb10b, 0xb10c, 0xb110, 0xb112, 0xb113,
+ 0xb118, 0xb119, 0xb11b, 0xb11c, 0xb11d, 0xb123, 0xb124, 0xb125,
+ 0xb128, 0xb12c, 0xb134, 0xb135, 0xb137, 0xb138, 0xb139, 0xb140,
+ 0xb141, 0xb144, 0xb148, 0xb150, 0xb151, 0xb154, 0xb155, 0xb158,
+ 0xb15c, 0xb160, 0xb178, 0xb179, 0xb17c, 0xb180, 0xb182, 0xb188,
+ 0xb189, 0xb18b, 0xb18d, 0xb192, 0xb193, 0xb194, 0xb198, 0xb19c,
+ 0xb1a8, 0xb1cc, 0xb1d0, 0xb1d4, 0xb1dc, 0xb1dd,
+ /* 0x34 */
+ 0xb1df, 0xb1e8, 0xb1e9, 0xb1ec, 0xb1f0, 0xb1f9, 0xb1fb, 0xb1fd,
+ 0xb204, 0xb205, 0xb208, 0xb20b, 0xb20c, 0xb214, 0xb215, 0xb217,
+ 0xb219, 0xb220, 0xb234, 0xb23c, 0xb258, 0xb25c, 0xb260, 0xb268,
+ 0xb269, 0xb274, 0xb275, 0xb27c, 0xb284, 0xb285, 0xb289, 0xb290,
+ 0xb291, 0xb294, 0xb298, 0xb299, 0xb29a, 0xb2a0, 0xb2a1, 0xb2a3,
+ 0xb2a5, 0xb2a6, 0xb2aa, 0xb2ac, 0xb2b0, 0xb2b4, 0xb2c8, 0xb2c9,
+ 0xb2cc, 0xb2d0, 0xb2d2, 0xb2d8, 0xb2d9, 0xb2db, 0xb2dd, 0xb2e2,
+ 0xb2e4, 0xb2e5, 0xb2e6, 0xb2e8, 0xb2eb, 0xb2ec, 0xb2ed, 0xb2ee,
+ 0xb2ef, 0xb2f3, 0xb2f4, 0xb2f5, 0xb2f7, 0xb2f8, 0xb2f9, 0xb2fa,
+ 0xb2fb, 0xb2ff, 0xb300, 0xb301, 0xb304, 0xb308, 0xb310, 0xb311,
+ 0xb313, 0xb314, 0xb315, 0xb31c, 0xb354, 0xb355, 0xb356, 0xb358,
+ 0xb35b, 0xb35c, 0xb35e, 0xb35f, 0xb364, 0xb365,
+ /* 0x35 */
+ 0xb367, 0xb369, 0xb36b, 0xb36e, 0xb370, 0xb371, 0xb374, 0xb378,
+ 0xb380, 0xb381, 0xb383, 0xb384, 0xb385, 0xb38c, 0xb390, 0xb394,
+ 0xb3a0, 0xb3a1, 0xb3a8, 0xb3ac, 0xb3c4, 0xb3c5, 0xb3c8, 0xb3cb,
+ 0xb3cc, 0xb3ce, 0xb3d0, 0xb3d4, 0xb3d5, 0xb3d7, 0xb3d9, 0xb3db,
+ 0xb3dd, 0xb3e0, 0xb3e4, 0xb3e8, 0xb3fc, 0xb410, 0xb418, 0xb41c,
+ 0xb420, 0xb428, 0xb429, 0xb42b, 0xb434, 0xb450, 0xb451, 0xb454,
+ 0xb458, 0xb460, 0xb461, 0xb463, 0xb465, 0xb46c, 0xb480, 0xb488,
+ 0xb49d, 0xb4a4, 0xb4a8, 0xb4ac, 0xb4b5, 0xb4b7, 0xb4b9, 0xb4c0,
+ 0xb4c4, 0xb4c8, 0xb4d0, 0xb4d5, 0xb4dc, 0xb4dd, 0xb4e0, 0xb4e3,
+ 0xb4e4, 0xb4e6, 0xb4ec, 0xb4ed, 0xb4ef, 0xb4f1, 0xb4f8, 0xb514,
+ 0xb515, 0xb518, 0xb51b, 0xb51c, 0xb524, 0xb525, 0xb527, 0xb528,
+ 0xb529, 0xb52a, 0xb530, 0xb531, 0xb534, 0xb538,
+ /* 0x36 */
+ 0xb540, 0xb541, 0xb543, 0xb544, 0xb545, 0xb54b, 0xb54c, 0xb54d,
+ 0xb550, 0xb554, 0xb55c, 0xb55d, 0xb55f, 0xb560, 0xb561, 0xb5a0,
+ 0xb5a1, 0xb5a4, 0xb5a8, 0xb5aa, 0xb5ab, 0xb5b0, 0xb5b1, 0xb5b3,
+ 0xb5b4, 0xb5b5, 0xb5bb, 0xb5bc, 0xb5bd, 0xb5c0, 0xb5c4, 0xb5cc,
+ 0xb5cd, 0xb5cf, 0xb5d0, 0xb5d1, 0xb5d8, 0xb5ec, 0xb610, 0xb611,
+ 0xb614, 0xb618, 0xb625, 0xb62c, 0xb634, 0xb648, 0xb664, 0xb668,
+ 0xb69c, 0xb69d, 0xb6a0, 0xb6a4, 0xb6ab, 0xb6ac, 0xb6b1, 0xb6d4,
+ 0xb6f0, 0xb6f4, 0xb6f8, 0xb700, 0xb701, 0xb705, 0xb728, 0xb729,
+ 0xb72c, 0xb72f, 0xb730, 0xb738, 0xb739, 0xb73b, 0xb744, 0xb748,
+ 0xb74c, 0xb754, 0xb755, 0xb760, 0xb764, 0xb768, 0xb770, 0xb771,
+ 0xb773, 0xb775, 0xb77c, 0xb77d, 0xb780, 0xb784, 0xb78c, 0xb78d,
+ 0xb78f, 0xb790, 0xb791, 0xb792, 0xb796, 0xb797,
+ /* 0x37 */
+ 0xb798, 0xb799, 0xb79c, 0xb7a0, 0xb7a8, 0xb7a9, 0xb7ab, 0xb7ac,
+ 0xb7ad, 0xb7b4, 0xb7b5, 0xb7b8, 0xb7c7, 0xb7c9, 0xb7ec, 0xb7ed,
+ 0xb7f0, 0xb7f4, 0xb7fc, 0xb7fd, 0xb7ff, 0xb800, 0xb801, 0xb807,
+ 0xb808, 0xb809, 0xb80c, 0xb810, 0xb818, 0xb819, 0xb81b, 0xb81d,
+ 0xb824, 0xb825, 0xb828, 0xb82c, 0xb834, 0xb835, 0xb837, 0xb838,
+ 0xb839, 0xb840, 0xb844, 0xb851, 0xb853, 0xb85c, 0xb85d, 0xb860,
+ 0xb864, 0xb86c, 0xb86d, 0xb86f, 0xb871, 0xb878, 0xb87c, 0xb88d,
+ 0xb8a8, 0xb8b0, 0xb8b4, 0xb8b8, 0xb8c0, 0xb8c1, 0xb8c3, 0xb8c5,
+ 0xb8cc, 0xb8d0, 0xb8d4, 0xb8dd, 0xb8df, 0xb8e1, 0xb8e8, 0xb8e9,
+ 0xb8ec, 0xb8f0, 0xb8f8, 0xb8f9, 0xb8fb, 0xb8fd, 0xb904, 0xb918,
+ 0xb920, 0xb93c, 0xb93d, 0xb940, 0xb944, 0xb94c, 0xb94f, 0xb951,
+ 0xb958, 0xb959, 0xb95c, 0xb960, 0xb968, 0xb969,
+ /* 0x38 */
+ 0xb96b, 0xb96d, 0xb974, 0xb975, 0xb978, 0xb97c, 0xb984, 0xb985,
+ 0xb987, 0xb989, 0xb98a, 0xb98d, 0xb98e, 0xb9ac, 0xb9ad, 0xb9b0,
+ 0xb9b4, 0xb9bc, 0xb9bd, 0xb9bf, 0xb9c1, 0xb9c8, 0xb9c9, 0xb9cc,
+ 0xb9ce, 0xb9cf, 0xb9d0, 0xb9d1, 0xb9d2, 0xb9d8, 0xb9d9, 0xb9db,
+ 0xb9dd, 0xb9de, 0xb9e1, 0xb9e3, 0xb9e4, 0xb9e5, 0xb9e8, 0xb9ec,
+ 0xb9f4, 0xb9f5, 0xb9f7, 0xb9f8, 0xb9f9, 0xb9fa, 0xba00, 0xba01,
+ 0xba08, 0xba15, 0xba38, 0xba39, 0xba3c, 0xba40, 0xba42, 0xba48,
+ 0xba49, 0xba4b, 0xba4d, 0xba4e, 0xba53, 0xba54, 0xba55, 0xba58,
+ 0xba5c, 0xba64, 0xba65, 0xba67, 0xba68, 0xba69, 0xba70, 0xba71,
+ 0xba74, 0xba78, 0xba83, 0xba84, 0xba85, 0xba87, 0xba8c, 0xbaa8,
+ 0xbaa9, 0xbaab, 0xbaac, 0xbab0, 0xbab2, 0xbab8, 0xbab9, 0xbabb,
+ 0xbabd, 0xbac4, 0xbac8, 0xbad8, 0xbad9, 0xbafc,
+ /* 0x39 */
+ 0xbb00, 0xbb04, 0xbb0d, 0xbb0f, 0xbb11, 0xbb18, 0xbb1c, 0xbb20,
+ 0xbb29, 0xbb2b, 0xbb34, 0xbb35, 0xbb36, 0xbb38, 0xbb3b, 0xbb3c,
+ 0xbb3d, 0xbb3e, 0xbb44, 0xbb45, 0xbb47, 0xbb49, 0xbb4d, 0xbb4f,
+ 0xbb50, 0xbb54, 0xbb58, 0xbb61, 0xbb63, 0xbb6c, 0xbb88, 0xbb8c,
+ 0xbb90, 0xbba4, 0xbba8, 0xbbac, 0xbbb4, 0xbbb7, 0xbbc0, 0xbbc4,
+ 0xbbc8, 0xbbd0, 0xbbd3, 0xbbf8, 0xbbf9, 0xbbfc, 0xbbff, 0xbc00,
+ 0xbc02, 0xbc08, 0xbc09, 0xbc0b, 0xbc0c, 0xbc0d, 0xbc0f, 0xbc11,
+ 0xbc14, 0xbc15, 0xbc16, 0xbc17, 0xbc18, 0xbc1b, 0xbc1c, 0xbc1d,
+ 0xbc1e, 0xbc1f, 0xbc24, 0xbc25, 0xbc27, 0xbc29, 0xbc2d, 0xbc30,
+ 0xbc31, 0xbc34, 0xbc38, 0xbc40, 0xbc41, 0xbc43, 0xbc44, 0xbc45,
+ 0xbc49, 0xbc4c, 0xbc4d, 0xbc50, 0xbc5d, 0xbc84, 0xbc85, 0xbc88,
+ 0xbc8b, 0xbc8c, 0xbc8e, 0xbc94, 0xbc95, 0xbc97,
+ /* 0x3a */
+ 0xbc99, 0xbc9a, 0xbca0, 0xbca1, 0xbca4, 0xbca7, 0xbca8, 0xbcb0,
+ 0xbcb1, 0xbcb3, 0xbcb4, 0xbcb5, 0xbcbc, 0xbcbd, 0xbcc0, 0xbcc4,
+ 0xbccd, 0xbccf, 0xbcd0, 0xbcd1, 0xbcd5, 0xbcd8, 0xbcdc, 0xbcf4,
+ 0xbcf5, 0xbcf6, 0xbcf8, 0xbcfc, 0xbd04, 0xbd05, 0xbd07, 0xbd09,
+ 0xbd10, 0xbd14, 0xbd24, 0xbd2c, 0xbd40, 0xbd48, 0xbd49, 0xbd4c,
+ 0xbd50, 0xbd58, 0xbd59, 0xbd64, 0xbd68, 0xbd80, 0xbd81, 0xbd84,
+ 0xbd87, 0xbd88, 0xbd89, 0xbd8a, 0xbd90, 0xbd91, 0xbd93, 0xbd95,
+ 0xbd99, 0xbd9a, 0xbd9c, 0xbda4, 0xbdb0, 0xbdb8, 0xbdd4, 0xbdd5,
+ 0xbdd8, 0xbddc, 0xbde9, 0xbdf0, 0xbdf4, 0xbdf8, 0xbe00, 0xbe03,
+ 0xbe05, 0xbe0c, 0xbe0d, 0xbe10, 0xbe14, 0xbe1c, 0xbe1d, 0xbe1f,
+ 0xbe44, 0xbe45, 0xbe48, 0xbe4c, 0xbe4e, 0xbe54, 0xbe55, 0xbe57,
+ 0xbe59, 0xbe5a, 0xbe5b, 0xbe60, 0xbe61, 0xbe64,
+ /* 0x3b */
+ 0xbe68, 0xbe6a, 0xbe70, 0xbe71, 0xbe73, 0xbe74, 0xbe75, 0xbe7b,
+ 0xbe7c, 0xbe7d, 0xbe80, 0xbe84, 0xbe8c, 0xbe8d, 0xbe8f, 0xbe90,
+ 0xbe91, 0xbe98, 0xbe99, 0xbea8, 0xbed0, 0xbed1, 0xbed4, 0xbed7,
+ 0xbed8, 0xbee0, 0xbee3, 0xbee4, 0xbee5, 0xbeec, 0xbf01, 0xbf08,
+ 0xbf09, 0xbf18, 0xbf19, 0xbf1b, 0xbf1c, 0xbf1d, 0xbf40, 0xbf41,
+ 0xbf44, 0xbf48, 0xbf50, 0xbf51, 0xbf55, 0xbf94, 0xbfb0, 0xbfc5,
+ 0xbfcc, 0xbfcd, 0xbfd0, 0xbfd4, 0xbfdc, 0xbfdf, 0xbfe1, 0xc03c,
+ 0xc051, 0xc058, 0xc05c, 0xc060, 0xc068, 0xc069, 0xc090, 0xc091,
+ 0xc094, 0xc098, 0xc0a0, 0xc0a1, 0xc0a3, 0xc0a5, 0xc0ac, 0xc0ad,
+ 0xc0af, 0xc0b0, 0xc0b3, 0xc0b4, 0xc0b5, 0xc0b6, 0xc0bc, 0xc0bd,
+ 0xc0bf, 0xc0c0, 0xc0c1, 0xc0c5, 0xc0c8, 0xc0c9, 0xc0cc, 0xc0d0,
+ 0xc0d8, 0xc0d9, 0xc0db, 0xc0dc, 0xc0dd, 0xc0e4,
+ /* 0x3c */
+ 0xc0e5, 0xc0e8, 0xc0ec, 0xc0f4, 0xc0f5, 0xc0f7, 0xc0f9, 0xc100,
+ 0xc104, 0xc108, 0xc110, 0xc115, 0xc11c, 0xc11d, 0xc11e, 0xc11f,
+ 0xc120, 0xc123, 0xc124, 0xc126, 0xc127, 0xc12c, 0xc12d, 0xc12f,
+ 0xc130, 0xc131, 0xc136, 0xc138, 0xc139, 0xc13c, 0xc140, 0xc148,
+ 0xc149, 0xc14b, 0xc14c, 0xc14d, 0xc154, 0xc155, 0xc158, 0xc15c,
+ 0xc164, 0xc165, 0xc167, 0xc168, 0xc169, 0xc170, 0xc174, 0xc178,
+ 0xc185, 0xc18c, 0xc18d, 0xc18e, 0xc190, 0xc194, 0xc196, 0xc19c,
+ 0xc19d, 0xc19f, 0xc1a1, 0xc1a5, 0xc1a8, 0xc1a9, 0xc1ac, 0xc1b0,
+ 0xc1bd, 0xc1c4, 0xc1c8, 0xc1cc, 0xc1d4, 0xc1d7, 0xc1d8, 0xc1e0,
+ 0xc1e4, 0xc1e8, 0xc1f0, 0xc1f1, 0xc1f3, 0xc1fc, 0xc1fd, 0xc200,
+ 0xc204, 0xc20c, 0xc20d, 0xc20f, 0xc211, 0xc218, 0xc219, 0xc21c,
+ 0xc21f, 0xc220, 0xc228, 0xc229, 0xc22b, 0xc22d,
+ /* 0x3d */
+ 0xc22f, 0xc231, 0xc232, 0xc234, 0xc248, 0xc250, 0xc251, 0xc254,
+ 0xc258, 0xc260, 0xc265, 0xc26c, 0xc26d, 0xc270, 0xc274, 0xc27c,
+ 0xc27d, 0xc27f, 0xc281, 0xc288, 0xc289, 0xc290, 0xc298, 0xc29b,
+ 0xc29d, 0xc2a4, 0xc2a5, 0xc2a8, 0xc2ac, 0xc2ad, 0xc2b4, 0xc2b5,
+ 0xc2b7, 0xc2b9, 0xc2dc, 0xc2dd, 0xc2e0, 0xc2e3, 0xc2e4, 0xc2eb,
+ 0xc2ec, 0xc2ed, 0xc2ef, 0xc2f1, 0xc2f6, 0xc2f8, 0xc2f9, 0xc2fb,
+ 0xc2fc, 0xc300, 0xc308, 0xc309, 0xc30c, 0xc30d, 0xc313, 0xc314,
+ 0xc315, 0xc318, 0xc31c, 0xc324, 0xc325, 0xc328, 0xc329, 0xc345,
+ 0xc368, 0xc369, 0xc36c, 0xc370, 0xc372, 0xc378, 0xc379, 0xc37c,
+ 0xc37d, 0xc384, 0xc388, 0xc38c, 0xc3c0, 0xc3d8, 0xc3d9, 0xc3dc,
+ 0xc3df, 0xc3e0, 0xc3e2, 0xc3e8, 0xc3e9, 0xc3ed, 0xc3f4, 0xc3f5,
+ 0xc3f8, 0xc408, 0xc410, 0xc424, 0xc42c, 0xc430,
+ /* 0x3e */
+ 0xc434, 0xc43c, 0xc43d, 0xc448, 0xc464, 0xc465, 0xc468, 0xc46c,
+ 0xc474, 0xc475, 0xc479, 0xc480, 0xc494, 0xc49c, 0xc4b8, 0xc4bc,
+ 0xc4e9, 0xc4f0, 0xc4f1, 0xc4f4, 0xc4f8, 0xc4fa, 0xc4ff, 0xc500,
+ 0xc501, 0xc50c, 0xc510, 0xc514, 0xc51c, 0xc528, 0xc529, 0xc52c,
+ 0xc530, 0xc538, 0xc539, 0xc53b, 0xc53d, 0xc544, 0xc545, 0xc548,
+ 0xc549, 0xc54a, 0xc54c, 0xc54d, 0xc54e, 0xc553, 0xc554, 0xc555,
+ 0xc557, 0xc558, 0xc559, 0xc55d, 0xc55e, 0xc560, 0xc561, 0xc564,
+ 0xc568, 0xc570, 0xc571, 0xc573, 0xc574, 0xc575, 0xc57c, 0xc57d,
+ 0xc580, 0xc584, 0xc587, 0xc58c, 0xc58d, 0xc58f, 0xc591, 0xc595,
+ 0xc597, 0xc598, 0xc59c, 0xc5a0, 0xc5a9, 0xc5b4, 0xc5b5, 0xc5b8,
+ 0xc5b9, 0xc5bb, 0xc5bc, 0xc5bd, 0xc5be, 0xc5c4, 0xc5c5, 0xc5c6,
+ 0xc5c7, 0xc5c8, 0xc5c9, 0xc5ca, 0xc5cc, 0xc5ce,
+ /* 0x3f */
+ 0xc5d0, 0xc5d1, 0xc5d4, 0xc5d8, 0xc5e0, 0xc5e1, 0xc5e3, 0xc5e5,
+ 0xc5ec, 0xc5ed, 0xc5ee, 0xc5f0, 0xc5f4, 0xc5f6, 0xc5f7, 0xc5fc,
+ 0xc5fd, 0xc5fe, 0xc5ff, 0xc600, 0xc601, 0xc605, 0xc606, 0xc607,
+ 0xc608, 0xc60c, 0xc610, 0xc618, 0xc619, 0xc61b, 0xc61c, 0xc624,
+ 0xc625, 0xc628, 0xc62c, 0xc62d, 0xc62e, 0xc630, 0xc633, 0xc634,
+ 0xc635, 0xc637, 0xc639, 0xc63b, 0xc640, 0xc641, 0xc644, 0xc648,
+ 0xc650, 0xc651, 0xc653, 0xc654, 0xc655, 0xc65c, 0xc65d, 0xc660,
+ 0xc66c, 0xc66f, 0xc671, 0xc678, 0xc679, 0xc67c, 0xc680, 0xc688,
+ 0xc689, 0xc68b, 0xc68d, 0xc694, 0xc695, 0xc698, 0xc69c, 0xc6a4,
+ 0xc6a5, 0xc6a7, 0xc6a9, 0xc6b0, 0xc6b1, 0xc6b4, 0xc6b8, 0xc6b9,
+ 0xc6ba, 0xc6c0, 0xc6c1, 0xc6c3, 0xc6c5, 0xc6cc, 0xc6cd, 0xc6d0,
+ 0xc6d4, 0xc6dc, 0xc6dd, 0xc6e0, 0xc6e1, 0xc6e8,
+ /* 0x40 */
+ 0xc6e9, 0xc6ec, 0xc6f0, 0xc6f8, 0xc6f9, 0xc6fd, 0xc704, 0xc705,
+ 0xc708, 0xc70c, 0xc714, 0xc715, 0xc717, 0xc719, 0xc720, 0xc721,
+ 0xc724, 0xc728, 0xc730, 0xc731, 0xc733, 0xc735, 0xc737, 0xc73c,
+ 0xc73d, 0xc740, 0xc744, 0xc74a, 0xc74c, 0xc74d, 0xc74f, 0xc751,
+ 0xc752, 0xc753, 0xc754, 0xc755, 0xc756, 0xc757, 0xc758, 0xc75c,
+ 0xc760, 0xc768, 0xc76b, 0xc774, 0xc775, 0xc778, 0xc77c, 0xc77d,
+ 0xc77e, 0xc783, 0xc784, 0xc785, 0xc787, 0xc788, 0xc789, 0xc78a,
+ 0xc78e, 0xc790, 0xc791, 0xc794, 0xc796, 0xc797, 0xc798, 0xc79a,
+ 0xc7a0, 0xc7a1, 0xc7a3, 0xc7a4, 0xc7a5, 0xc7a6, 0xc7ac, 0xc7ad,
+ 0xc7b0, 0xc7b4, 0xc7bc, 0xc7bd, 0xc7bf, 0xc7c0, 0xc7c1, 0xc7c8,
+ 0xc7c9, 0xc7cc, 0xc7ce, 0xc7d0, 0xc7d8, 0xc7dd, 0xc7e4, 0xc7e8,
+ 0xc7ec, 0xc800, 0xc801, 0xc804, 0xc808, 0xc80a,
+ /* 0x41 */
+ 0xc810, 0xc811, 0xc813, 0xc815, 0xc816, 0xc81c, 0xc81d, 0xc820,
+ 0xc824, 0xc82c, 0xc82d, 0xc82f, 0xc831, 0xc838, 0xc83c, 0xc840,
+ 0xc848, 0xc849, 0xc84c, 0xc84d, 0xc854, 0xc870, 0xc871, 0xc874,
+ 0xc878, 0xc87a, 0xc880, 0xc881, 0xc883, 0xc885, 0xc886, 0xc887,
+ 0xc88b, 0xc88c, 0xc88d, 0xc894, 0xc89d, 0xc89f, 0xc8a1, 0xc8a8,
+ 0xc8bc, 0xc8bd, 0xc8c4, 0xc8c8, 0xc8cc, 0xc8d4, 0xc8d5, 0xc8d7,
+ 0xc8d9, 0xc8e0, 0xc8e1, 0xc8e4, 0xc8f5, 0xc8fc, 0xc8fd, 0xc900,
+ 0xc904, 0xc905, 0xc906, 0xc90c, 0xc90d, 0xc90f, 0xc911, 0xc918,
+ 0xc92c, 0xc934, 0xc950, 0xc951, 0xc954, 0xc958, 0xc960, 0xc961,
+ 0xc963, 0xc96c, 0xc970, 0xc974, 0xc97c, 0xc988, 0xc989, 0xc98c,
+ 0xc990, 0xc998, 0xc999, 0xc99b, 0xc99d, 0xc9c0, 0xc9c1, 0xc9c4,
+ 0xc9c7, 0xc9c8, 0xc9ca, 0xc9d0, 0xc9d1, 0xc9d3,
+ /* 0x42 */
+ 0xc9d5, 0xc9d6, 0xc9d9, 0xc9da, 0xc9dc, 0xc9dd, 0xc9e0, 0xc9e2,
+ 0xc9e4, 0xc9e7, 0xc9ec, 0xc9ed, 0xc9ef, 0xc9f0, 0xc9f1, 0xc9f8,
+ 0xc9f9, 0xc9fc, 0xca00, 0xca08, 0xca09, 0xca0b, 0xca0c, 0xca0d,
+ 0xca14, 0xca18, 0xca29, 0xca4c, 0xca4d, 0xca50, 0xca54, 0xca5c,
+ 0xca5d, 0xca5f, 0xca60, 0xca61, 0xca68, 0xca7d, 0xca84, 0xca98,
+ 0xcabc, 0xcabd, 0xcac0, 0xcac4, 0xcacc, 0xcacd, 0xcacf, 0xcad1,
+ 0xcad3, 0xcad8, 0xcad9, 0xcae0, 0xcaec, 0xcaf4, 0xcb08, 0xcb10,
+ 0xcb14, 0xcb18, 0xcb20, 0xcb21, 0xcb41, 0xcb48, 0xcb49, 0xcb4c,
+ 0xcb50, 0xcb58, 0xcb59, 0xcb5d, 0xcb64, 0xcb78, 0xcb79, 0xcb9c,
+ 0xcbb8, 0xcbd4, 0xcbe4, 0xcbe7, 0xcbe9, 0xcc0c, 0xcc0d, 0xcc10,
+ 0xcc14, 0xcc1c, 0xcc1d, 0xcc21, 0xcc22, 0xcc27, 0xcc28, 0xcc29,
+ 0xcc2c, 0xcc2e, 0xcc30, 0xcc38, 0xcc39, 0xcc3b,
+ /* 0x43 */
+ 0xcc3c, 0xcc3d, 0xcc3e, 0xcc44, 0xcc45, 0xcc48, 0xcc4c, 0xcc54,
+ 0xcc55, 0xcc57, 0xcc58, 0xcc59, 0xcc60, 0xcc64, 0xcc66, 0xcc68,
+ 0xcc70, 0xcc75, 0xcc98, 0xcc99, 0xcc9c, 0xcca0, 0xcca8, 0xcca9,
+ 0xccab, 0xccac, 0xccad, 0xccb4, 0xccb5, 0xccb8, 0xccbc, 0xccc4,
+ 0xccc5, 0xccc7, 0xccc9, 0xccd0, 0xccd4, 0xcce4, 0xccec, 0xccf0,
+ 0xcd01, 0xcd08, 0xcd09, 0xcd0c, 0xcd10, 0xcd18, 0xcd19, 0xcd1b,
+ 0xcd1d, 0xcd24, 0xcd28, 0xcd2c, 0xcd39, 0xcd5c, 0xcd60, 0xcd64,
+ 0xcd6c, 0xcd6d, 0xcd6f, 0xcd71, 0xcd78, 0xcd88, 0xcd94, 0xcd95,
+ 0xcd98, 0xcd9c, 0xcda4, 0xcda5, 0xcda7, 0xcda9, 0xcdb0, 0xcdc4,
+ 0xcdcc, 0xcdd0, 0xcde8, 0xcdec, 0xcdf0, 0xcdf8, 0xcdf9, 0xcdfb,
+ 0xcdfd, 0xce04, 0xce08, 0xce0c, 0xce14, 0xce19, 0xce20, 0xce21,
+ 0xce24, 0xce28, 0xce30, 0xce31, 0xce33, 0xce35,
+ /* 0x44 */
+ 0xce58, 0xce59, 0xce5c, 0xce5f, 0xce60, 0xce61, 0xce68, 0xce69,
+ 0xce6b, 0xce6d, 0xce74, 0xce75, 0xce78, 0xce7c, 0xce84, 0xce85,
+ 0xce87, 0xce89, 0xce90, 0xce91, 0xce94, 0xce98, 0xcea0, 0xcea1,
+ 0xcea3, 0xcea4, 0xcea5, 0xceac, 0xcead, 0xcec1, 0xcee4, 0xcee5,
+ 0xcee8, 0xceeb, 0xceec, 0xcef4, 0xcef5, 0xcef7, 0xcef8, 0xcef9,
+ 0xcf00, 0xcf01, 0xcf04, 0xcf08, 0xcf10, 0xcf11, 0xcf13, 0xcf15,
+ 0xcf1c, 0xcf20, 0xcf24, 0xcf2c, 0xcf2d, 0xcf2f, 0xcf30, 0xcf31,
+ 0xcf38, 0xcf54, 0xcf55, 0xcf58, 0xcf5c, 0xcf64, 0xcf65, 0xcf67,
+ 0xcf69, 0xcf70, 0xcf71, 0xcf74, 0xcf78, 0xcf80, 0xcf85, 0xcf8c,
+ 0xcfa1, 0xcfa8, 0xcfb0, 0xcfc4, 0xcfe0, 0xcfe1, 0xcfe4, 0xcfe8,
+ 0xcff0, 0xcff1, 0xcff3, 0xcff5, 0xcffc, 0xd000, 0xd004, 0xd011,
+ 0xd018, 0xd02d, 0xd034, 0xd035, 0xd038, 0xd03c,
+ /* 0x45 */
+ 0xd044, 0xd045, 0xd047, 0xd049, 0xd050, 0xd054, 0xd058, 0xd060,
+ 0xd06c, 0xd06d, 0xd070, 0xd074, 0xd07c, 0xd07d, 0xd081, 0xd0a4,
+ 0xd0a5, 0xd0a8, 0xd0ac, 0xd0b4, 0xd0b5, 0xd0b7, 0xd0b9, 0xd0c0,
+ 0xd0c1, 0xd0c4, 0xd0c8, 0xd0c9, 0xd0d0, 0xd0d1, 0xd0d3, 0xd0d4,
+ 0xd0d5, 0xd0dc, 0xd0dd, 0xd0e0, 0xd0e4, 0xd0ec, 0xd0ed, 0xd0ef,
+ 0xd0f0, 0xd0f1, 0xd0f8, 0xd10d, 0xd130, 0xd131, 0xd134, 0xd138,
+ 0xd13a, 0xd140, 0xd141, 0xd143, 0xd144, 0xd145, 0xd14c, 0xd14d,
+ 0xd150, 0xd154, 0xd15c, 0xd15d, 0xd15f, 0xd161, 0xd168, 0xd16c,
+ 0xd17c, 0xd184, 0xd188, 0xd1a0, 0xd1a1, 0xd1a4, 0xd1a8, 0xd1b0,
+ 0xd1b1, 0xd1b3, 0xd1b5, 0xd1ba, 0xd1bc, 0xd1c0, 0xd1d8, 0xd1f4,
+ 0xd1f8, 0xd207, 0xd209, 0xd210, 0xd22c, 0xd22d, 0xd230, 0xd234,
+ 0xd23c, 0xd23d, 0xd23f, 0xd241, 0xd248, 0xd25c,
+ /* 0x46 */
+ 0xd264, 0xd280, 0xd281, 0xd284, 0xd288, 0xd290, 0xd291, 0xd295,
+ 0xd29c, 0xd2a0, 0xd2a4, 0xd2ac, 0xd2b1, 0xd2b8, 0xd2b9, 0xd2bc,
+ 0xd2bf, 0xd2c0, 0xd2c2, 0xd2c8, 0xd2c9, 0xd2cb, 0xd2d4, 0xd2d8,
+ 0xd2dc, 0xd2e4, 0xd2e5, 0xd2f0, 0xd2f1, 0xd2f4, 0xd2f8, 0xd300,
+ 0xd301, 0xd303, 0xd305, 0xd30c, 0xd30d, 0xd30e, 0xd310, 0xd314,
+ 0xd316, 0xd31c, 0xd31d, 0xd31f, 0xd320, 0xd321, 0xd325, 0xd328,
+ 0xd329, 0xd32c, 0xd330, 0xd338, 0xd339, 0xd33b, 0xd33c, 0xd33d,
+ 0xd344, 0xd345, 0xd37c, 0xd37d, 0xd380, 0xd384, 0xd38c, 0xd38d,
+ 0xd38f, 0xd390, 0xd391, 0xd398, 0xd399, 0xd39c, 0xd3a0, 0xd3a8,
+ 0xd3a9, 0xd3ab, 0xd3ad, 0xd3b4, 0xd3b8, 0xd3bc, 0xd3c4, 0xd3c5,
+ 0xd3c8, 0xd3c9, 0xd3d0, 0xd3d8, 0xd3e1, 0xd3e3, 0xd3ec, 0xd3ed,
+ 0xd3f0, 0xd3f4, 0xd3fc, 0xd3fd, 0xd3ff, 0xd401,
+ /* 0x47 */
+ 0xd408, 0xd41d, 0xd440, 0xd444, 0xd45c, 0xd460, 0xd464, 0xd46d,
+ 0xd46f, 0xd478, 0xd479, 0xd47c, 0xd47f, 0xd480, 0xd482, 0xd488,
+ 0xd489, 0xd48b, 0xd48d, 0xd494, 0xd4a9, 0xd4cc, 0xd4d0, 0xd4d4,
+ 0xd4dc, 0xd4df, 0xd4e8, 0xd4ec, 0xd4f0, 0xd4f8, 0xd4fb, 0xd4fd,
+ 0xd504, 0xd508, 0xd50c, 0xd514, 0xd515, 0xd517, 0xd53c, 0xd53d,
+ 0xd540, 0xd544, 0xd54c, 0xd54d, 0xd54f, 0xd551, 0xd558, 0xd559,
+ 0xd55c, 0xd560, 0xd565, 0xd568, 0xd569, 0xd56b, 0xd56d, 0xd574,
+ 0xd575, 0xd578, 0xd57c, 0xd584, 0xd585, 0xd587, 0xd588, 0xd589,
+ 0xd590, 0xd5a5, 0xd5c8, 0xd5c9, 0xd5cc, 0xd5d0, 0xd5d2, 0xd5d8,
+ 0xd5d9, 0xd5db, 0xd5dd, 0xd5e4, 0xd5e5, 0xd5e8, 0xd5ec, 0xd5f4,
+ 0xd5f5, 0xd5f7, 0xd5f9, 0xd600, 0xd601, 0xd604, 0xd608, 0xd610,
+ 0xd611, 0xd613, 0xd614, 0xd615, 0xd61c, 0xd620,
+ /* 0x48 */
+ 0xd624, 0xd62d, 0xd638, 0xd639, 0xd63c, 0xd640, 0xd645, 0xd648,
+ 0xd649, 0xd64b, 0xd64d, 0xd651, 0xd654, 0xd655, 0xd658, 0xd65c,
+ 0xd667, 0xd669, 0xd670, 0xd671, 0xd674, 0xd683, 0xd685, 0xd68c,
+ 0xd68d, 0xd690, 0xd694, 0xd69d, 0xd69f, 0xd6a1, 0xd6a8, 0xd6ac,
+ 0xd6b0, 0xd6b9, 0xd6bb, 0xd6c4, 0xd6c5, 0xd6c8, 0xd6cc, 0xd6d1,
+ 0xd6d4, 0xd6d7, 0xd6d9, 0xd6e0, 0xd6e4, 0xd6e8, 0xd6f0, 0xd6f5,
+ 0xd6fc, 0xd6fd, 0xd700, 0xd704, 0xd711, 0xd718, 0xd719, 0xd71c,
+ 0xd720, 0xd728, 0xd729, 0xd72b, 0xd72d, 0xd734, 0xd735, 0xd738,
+ 0xd73c, 0xd744, 0xd747, 0xd749, 0xd750, 0xd751, 0xd754, 0xd756,
+ 0xd757, 0xd758, 0xd759, 0xd760, 0xd761, 0xd763, 0xd765, 0xd769,
+ 0xd76c, 0xd770, 0xd774, 0xd77c, 0xd77d, 0xd781, 0xd788, 0xd789,
+ 0xd78c, 0xd790, 0xd798, 0xd799, 0xd79b, 0xd79d,
+};
+static const unsigned short ksc5601_2uni_page4a[4888] = {
+ /* 0x4a */
+ 0x4f3d, 0x4f73, 0x5047, 0x50f9, 0x52a0, 0x53ef, 0x5475, 0x54e5,
+ 0x5609, 0x5ac1, 0x5bb6, 0x6687, 0x67b6, 0x67b7, 0x67ef, 0x6b4c,
+ 0x73c2, 0x75c2, 0x7a3c, 0x82db, 0x8304, 0x8857, 0x8888, 0x8a36,
+ 0x8cc8, 0x8dcf, 0x8efb, 0x8fe6, 0x99d5, 0x523b, 0x5374, 0x5404,
+ 0x606a, 0x6164, 0x6bbc, 0x73cf, 0x811a, 0x89ba, 0x89d2, 0x95a3,
+ 0x4f83, 0x520a, 0x58be, 0x5978, 0x59e6, 0x5e72, 0x5e79, 0x61c7,
+ 0x63c0, 0x6746, 0x67ec, 0x687f, 0x6f97, 0x764e, 0x770b, 0x78f5,
+ 0x7a08, 0x7aff, 0x7c21, 0x809d, 0x826e, 0x8271, 0x8aeb, 0x9593,
+ 0x4e6b, 0x559d, 0x66f7, 0x6e34, 0x78a3, 0x7aed, 0x845b, 0x8910,
+ 0x874e, 0x97a8, 0x52d8, 0x574e, 0x582a, 0x5d4c, 0x611f, 0x61be,
+ 0x6221, 0x6562, 0x67d1, 0x6a44, 0x6e1b, 0x7518, 0x75b3, 0x76e3,
+ 0x77b0, 0x7d3a, 0x90af, 0x9451, 0x9452, 0x9f95,
+ /* 0x4b */
+ 0x5323, 0x5cac, 0x7532, 0x80db, 0x9240, 0x9598, 0x525b, 0x5808,
+ 0x59dc, 0x5ca1, 0x5d17, 0x5eb7, 0x5f3a, 0x5f4a, 0x6177, 0x6c5f,
+ 0x757a, 0x7586, 0x7ce0, 0x7d73, 0x7db1, 0x7f8c, 0x8154, 0x8221,
+ 0x8591, 0x8941, 0x8b1b, 0x92fc, 0x964d, 0x9c47, 0x4ecb, 0x4ef7,
+ 0x500b, 0x51f1, 0x584f, 0x6137, 0x613e, 0x6168, 0x6539, 0x69ea,
+ 0x6f11, 0x75a5, 0x7686, 0x76d6, 0x7b87, 0x82a5, 0x84cb, 0xf900,
+ 0x93a7, 0x958b, 0x5580, 0x5ba2, 0x5751, 0xf901, 0x7cb3, 0x7fb9,
+ 0x91b5, 0x5028, 0x53bb, 0x5c45, 0x5de8, 0x62d2, 0x636e, 0x64da,
+ 0x64e7, 0x6e20, 0x70ac, 0x795b, 0x8ddd, 0x8e1e, 0xf902, 0x907d,
+ 0x9245, 0x92f8, 0x4e7e, 0x4ef6, 0x5065, 0x5dfe, 0x5efa, 0x6106,
+ 0x6957, 0x8171, 0x8654, 0x8e47, 0x9375, 0x9a2b, 0x4e5e, 0x5091,
+ 0x6770, 0x6840, 0x5109, 0x528d, 0x5292, 0x6aa2,
+ /* 0x4c */
+ 0x77bc, 0x9210, 0x9ed4, 0x52ab, 0x602f, 0x8ff2, 0x5048, 0x61a9,
+ 0x63ed, 0x64ca, 0x683c, 0x6a84, 0x6fc0, 0x8188, 0x89a1, 0x9694,
+ 0x5805, 0x727d, 0x72ac, 0x7504, 0x7d79, 0x7e6d, 0x80a9, 0x898b,
+ 0x8b74, 0x9063, 0x9d51, 0x6289, 0x6c7a, 0x6f54, 0x7d50, 0x7f3a,
+ 0x8a23, 0x517c, 0x614a, 0x7b9d, 0x8b19, 0x9257, 0x938c, 0x4eac,
+ 0x4fd3, 0x501e, 0x50be, 0x5106, 0x52c1, 0x52cd, 0x537f, 0x5770,
+ 0x5883, 0x5e9a, 0x5f91, 0x6176, 0x61ac, 0x64ce, 0x656c, 0x666f,
+ 0x66bb, 0x66f4, 0x6897, 0x6d87, 0x7085, 0x70f1, 0x749f, 0x74a5,
+ 0x74ca, 0x75d9, 0x786c, 0x78ec, 0x7adf, 0x7af6, 0x7d45, 0x7d93,
+ 0x8015, 0x803f, 0x811b, 0x8396, 0x8b66, 0x8f15, 0x9015, 0x93e1,
+ 0x9803, 0x9838, 0x9a5a, 0x9be8, 0x4fc2, 0x5553, 0x583a, 0x5951,
+ 0x5b63, 0x5c46, 0x60b8, 0x6212, 0x6842, 0x68b0,
+ /* 0x4d */
+ 0x68e8, 0x6eaa, 0x754c, 0x7678, 0x78ce, 0x7a3d, 0x7cfb, 0x7e6b,
+ 0x7e7c, 0x8a08, 0x8aa1, 0x8c3f, 0x968e, 0x9dc4, 0x53e4, 0x53e9,
+ 0x544a, 0x5471, 0x56fa, 0x59d1, 0x5b64, 0x5c3b, 0x5eab, 0x62f7,
+ 0x6537, 0x6545, 0x6572, 0x66a0, 0x67af, 0x69c1, 0x6cbd, 0x75fc,
+ 0x7690, 0x777e, 0x7a3f, 0x7f94, 0x8003, 0x80a1, 0x818f, 0x82e6,
+ 0x82fd, 0x83f0, 0x85c1, 0x8831, 0x88b4, 0x8aa5, 0xf903, 0x8f9c,
+ 0x932e, 0x96c7, 0x9867, 0x9ad8, 0x9f13, 0x54ed, 0x659b, 0x66f2,
+ 0x688f, 0x7a40, 0x8c37, 0x9d60, 0x56f0, 0x5764, 0x5d11, 0x6606,
+ 0x68b1, 0x68cd, 0x6efe, 0x7428, 0x889e, 0x9be4, 0x6c68, 0xf904,
+ 0x9aa8, 0x4f9b, 0x516c, 0x5171, 0x529f, 0x5b54, 0x5de5, 0x6050,
+ 0x606d, 0x62f1, 0x63a7, 0x653b, 0x73d9, 0x7a7a, 0x86a3, 0x8ca2,
+ 0x978f, 0x4e32, 0x5be1, 0x6208, 0x679c, 0x74dc,
+ /* 0x4e */
+ 0x79d1, 0x83d3, 0x8a87, 0x8ab2, 0x8de8, 0x904e, 0x934b, 0x9846,
+ 0x5ed3, 0x69e8, 0x85ff, 0x90ed, 0xf905, 0x51a0, 0x5b98, 0x5bec,
+ 0x6163, 0x68fa, 0x6b3e, 0x704c, 0x742f, 0x74d8, 0x7ba1, 0x7f50,
+ 0x83c5, 0x89c0, 0x8cab, 0x95dc, 0x9928, 0x522e, 0x605d, 0x62ec,
+ 0x9002, 0x4f8a, 0x5149, 0x5321, 0x58d9, 0x5ee3, 0x66e0, 0x6d38,
+ 0x709a, 0x72c2, 0x73d6, 0x7b50, 0x80f1, 0x945b, 0x5366, 0x639b,
+ 0x7f6b, 0x4e56, 0x5080, 0x584a, 0x58de, 0x602a, 0x6127, 0x62d0,
+ 0x69d0, 0x9b41, 0x5b8f, 0x7d18, 0x80b1, 0x8f5f, 0x4ea4, 0x50d1,
+ 0x54ac, 0x55ac, 0x5b0c, 0x5da0, 0x5de7, 0x652a, 0x654e, 0x6821,
+ 0x6a4b, 0x72e1, 0x768e, 0x77ef, 0x7d5e, 0x7ff9, 0x81a0, 0x854e,
+ 0x86df, 0x8f03, 0x8f4e, 0x90ca, 0x9903, 0x9a55, 0x9bab, 0x4e18,
+ 0x4e45, 0x4e5d, 0x4ec7, 0x4ff1, 0x5177, 0x52fe,
+ /* 0x4f */
+ 0x5340, 0x53e3, 0x53e5, 0x548e, 0x5614, 0x5775, 0x57a2, 0x5bc7,
+ 0x5d87, 0x5ed0, 0x61fc, 0x62d8, 0x6551, 0x67b8, 0x67e9, 0x69cb,
+ 0x6b50, 0x6bc6, 0x6bec, 0x6c42, 0x6e9d, 0x7078, 0x72d7, 0x7396,
+ 0x7403, 0x77bf, 0x77e9, 0x7a76, 0x7d7f, 0x8009, 0x81fc, 0x8205,
+ 0x820a, 0x82df, 0x8862, 0x8b33, 0x8cfc, 0x8ec0, 0x9011, 0x90b1,
+ 0x9264, 0x92b6, 0x99d2, 0x9a45, 0x9ce9, 0x9dd7, 0x9f9c, 0x570b,
+ 0x5c40, 0x83ca, 0x97a0, 0x97ab, 0x9eb4, 0x541b, 0x7a98, 0x7fa4,
+ 0x88d9, 0x8ecd, 0x90e1, 0x5800, 0x5c48, 0x6398, 0x7a9f, 0x5bae,
+ 0x5f13, 0x7a79, 0x7aae, 0x828e, 0x8eac, 0x5026, 0x5238, 0x52f8,
+ 0x5377, 0x5708, 0x62f3, 0x6372, 0x6b0a, 0x6dc3, 0x7737, 0x53a5,
+ 0x7357, 0x8568, 0x8e76, 0x95d5, 0x673a, 0x6ac3, 0x6f70, 0x8a6d,
+ 0x8ecc, 0x994b, 0xf906, 0x6677, 0x6b78, 0x8cb4,
+ /* 0x50 */
+ 0x9b3c, 0xf907, 0x53eb, 0x572d, 0x594e, 0x63c6, 0x69fb, 0x73ea,
+ 0x7845, 0x7aba, 0x7ac5, 0x7cfe, 0x8475, 0x898f, 0x8d73, 0x9035,
+ 0x95a8, 0x52fb, 0x5747, 0x7547, 0x7b60, 0x83cc, 0x921e, 0xf908,
+ 0x6a58, 0x514b, 0x524b, 0x5287, 0x621f, 0x68d8, 0x6975, 0x9699,
+ 0x50c5, 0x52a4, 0x52e4, 0x61c3, 0x65a4, 0x6839, 0x69ff, 0x747e,
+ 0x7b4b, 0x82b9, 0x83eb, 0x89b2, 0x8b39, 0x8fd1, 0x9949, 0xf909,
+ 0x4eca, 0x5997, 0x64d2, 0x6611, 0x6a8e, 0x7434, 0x7981, 0x79bd,
+ 0x82a9, 0x887e, 0x887f, 0x895f, 0xf90a, 0x9326, 0x4f0b, 0x53ca,
+ 0x6025, 0x6271, 0x6c72, 0x7d1a, 0x7d66, 0x4e98, 0x5162, 0x77dc,
+ 0x80af, 0x4f01, 0x4f0e, 0x5176, 0x5180, 0x55dc, 0x5668, 0x573b,
+ 0x57fa, 0x57fc, 0x5914, 0x5947, 0x5993, 0x5bc4, 0x5c90, 0x5d0e,
+ 0x5df1, 0x5e7e, 0x5fcc, 0x6280, 0x65d7, 0x65e3,
+ /* 0x51 */
+ 0x671e, 0x671f, 0x675e, 0x68cb, 0x68c4, 0x6a5f, 0x6b3a, 0x6c23,
+ 0x6c7d, 0x6c82, 0x6dc7, 0x7398, 0x7426, 0x742a, 0x7482, 0x74a3,
+ 0x7578, 0x757f, 0x7881, 0x78ef, 0x7941, 0x7947, 0x7948, 0x797a,
+ 0x7b95, 0x7d00, 0x7dba, 0x7f88, 0x8006, 0x802d, 0x808c, 0x8a18,
+ 0x8b4f, 0x8c48, 0x8d77, 0x9321, 0x9324, 0x98e2, 0x9951, 0x9a0e,
+ 0x9a0f, 0x9a65, 0x9e92, 0x7dca, 0x4f76, 0x5409, 0x62ee, 0x6854,
+ 0x91d1, 0x55ab, 0x513a, 0xf90b, 0xf90c, 0x5a1c, 0x61e6, 0xf90d,
+ 0x62cf, 0x62ff, 0xf90e, 0xf90f, 0xf910, 0xf911, 0xf912, 0xf913,
+ 0x90a3, 0xf914, 0xf915, 0xf916, 0xf917, 0xf918, 0x8afe, 0xf919,
+ 0xf91a, 0xf91b, 0xf91c, 0x6696, 0xf91d, 0x7156, 0xf91e, 0xf91f,
+ 0x96e3, 0xf920, 0x634f, 0x637a, 0x5357, 0xf921, 0x678f, 0x6960,
+ 0x6e73, 0xf922, 0x7537, 0xf923, 0xf924, 0xf925,
+ /* 0x52 */
+ 0x7d0d, 0xf926, 0xf927, 0x8872, 0x56ca, 0x5a18, 0xf928, 0xf929,
+ 0xf92a, 0xf92b, 0xf92c, 0x4e43, 0xf92d, 0x5167, 0x5948, 0x67f0,
+ 0x8010, 0xf92e, 0x5973, 0x5e74, 0x649a, 0x79ca, 0x5ff5, 0x606c,
+ 0x62c8, 0x637b, 0x5be7, 0x5bd7, 0x52aa, 0xf92f, 0x5974, 0x5f29,
+ 0x6012, 0xf930, 0xf931, 0xf932, 0x7459, 0xf933, 0xf934, 0xf935,
+ 0xf936, 0xf937, 0xf938, 0x99d1, 0xf939, 0xf93a, 0xf93b, 0xf93c,
+ 0xf93d, 0xf93e, 0xf93f, 0xf940, 0xf941, 0xf942, 0xf943, 0x6fc3,
+ 0xf944, 0xf945, 0x81bf, 0x8fb2, 0x60f1, 0xf946, 0xf947, 0x8166,
+ 0xf948, 0xf949, 0x5c3f, 0xf94a, 0xf94b, 0xf94c, 0xf94d, 0xf94e,
+ 0xf94f, 0xf950, 0xf951, 0x5ae9, 0x8a25, 0x677b, 0x7d10, 0xf952,
+ 0xf953, 0xf954, 0xf955, 0xf956, 0xf957, 0x80fd, 0xf958, 0xf959,
+ 0x5c3c, 0x6ce5, 0x533f, 0x6eba, 0x591a, 0x8336,
+ /* 0x53 */
+ 0x4e39, 0x4eb6, 0x4f46, 0x55ae, 0x5718, 0x58c7, 0x5f56, 0x65b7,
+ 0x65e6, 0x6a80, 0x6bb5, 0x6e4d, 0x77ed, 0x7aef, 0x7c1e, 0x7dde,
+ 0x86cb, 0x8892, 0x9132, 0x935b, 0x64bb, 0x6fbe, 0x737a, 0x75b8,
+ 0x9054, 0x5556, 0x574d, 0x61ba, 0x64d4, 0x66c7, 0x6de1, 0x6e5b,
+ 0x6f6d, 0x6fb9, 0x75f0, 0x8043, 0x81bd, 0x8541, 0x8983, 0x8ac7,
+ 0x8b5a, 0x931f, 0x6c93, 0x7553, 0x7b54, 0x8e0f, 0x905d, 0x5510,
+ 0x5802, 0x5858, 0x5e62, 0x6207, 0x649e, 0x68e0, 0x7576, 0x7cd6,
+ 0x87b3, 0x9ee8, 0x4ee3, 0x5788, 0x576e, 0x5927, 0x5c0d, 0x5cb1,
+ 0x5e36, 0x5f85, 0x6234, 0x64e1, 0x73b3, 0x81fa, 0x888b, 0x8cb8,
+ 0x968a, 0x9edb, 0x5b85, 0x5fb7, 0x60b3, 0x5012, 0x5200, 0x5230,
+ 0x5716, 0x5835, 0x5857, 0x5c0e, 0x5c60, 0x5cf6, 0x5d8b, 0x5ea6,
+ 0x5f92, 0x60bc, 0x6311, 0x6389, 0x6417, 0x6843,
+ /* 0x54 */
+ 0x68f9, 0x6ac2, 0x6dd8, 0x6e21, 0x6ed4, 0x6fe4, 0x71fe, 0x76dc,
+ 0x7779, 0x79b1, 0x7a3b, 0x8404, 0x89a9, 0x8ced, 0x8df3, 0x8e48,
+ 0x9003, 0x9014, 0x9053, 0x90fd, 0x934d, 0x9676, 0x97dc, 0x6bd2,
+ 0x7006, 0x7258, 0x72a2, 0x7368, 0x7763, 0x79bf, 0x7be4, 0x7e9b,
+ 0x8b80, 0x58a9, 0x60c7, 0x6566, 0x65fd, 0x66be, 0x6c8c, 0x711e,
+ 0x71c9, 0x8c5a, 0x9813, 0x4e6d, 0x7a81, 0x4edd, 0x51ac, 0x51cd,
+ 0x52d5, 0x540c, 0x61a7, 0x6771, 0x6850, 0x68df, 0x6d1e, 0x6f7c,
+ 0x75bc, 0x77b3, 0x7ae5, 0x80f4, 0x8463, 0x9285, 0x515c, 0x6597,
+ 0x675c, 0x6793, 0x75d8, 0x7ac7, 0x8373, 0xf95a, 0x8c46, 0x9017,
+ 0x982d, 0x5c6f, 0x81c0, 0x829a, 0x9041, 0x906f, 0x920d, 0x5f97,
+ 0x5d9d, 0x6a59, 0x71c8, 0x767b, 0x7b49, 0x85e4, 0x8b04, 0x9127,
+ 0x9a30, 0x5587, 0x61f6, 0xf95b, 0x7669, 0x7f85,
+ /* 0x55 */
+ 0x863f, 0x87ba, 0x88f8, 0x908f, 0xf95c, 0x6d1b, 0x70d9, 0x73de,
+ 0x7d61, 0x843d, 0xf95d, 0x916a, 0x99f1, 0xf95e, 0x4e82, 0x5375,
+ 0x6b04, 0x6b12, 0x703e, 0x721b, 0x862d, 0x9e1e, 0x524c, 0x8fa3,
+ 0x5d50, 0x64e5, 0x652c, 0x6b16, 0x6feb, 0x7c43, 0x7e9c, 0x85cd,
+ 0x8964, 0x89bd, 0x62c9, 0x81d8, 0x881f, 0x5eca, 0x6717, 0x6d6a,
+ 0x72fc, 0x7405, 0x746f, 0x8782, 0x90de, 0x4f86, 0x5d0d, 0x5fa0,
+ 0x840a, 0x51b7, 0x63a0, 0x7565, 0x4eae, 0x5006, 0x5169, 0x51c9,
+ 0x6881, 0x6a11, 0x7cae, 0x7cb1, 0x7ce7, 0x826f, 0x8ad2, 0x8f1b,
+ 0x91cf, 0x4fb6, 0x5137, 0x52f5, 0x5442, 0x5eec, 0x616e, 0x623e,
+ 0x65c5, 0x6ada, 0x6ffe, 0x792a, 0x85dc, 0x8823, 0x95ad, 0x9a62,
+ 0x9a6a, 0x9e97, 0x9ece, 0x529b, 0x66c6, 0x6b77, 0x701d, 0x792b,
+ 0x8f62, 0x9742, 0x6190, 0x6200, 0x6523, 0x6f23,
+ /* 0x56 */
+ 0x7149, 0x7489, 0x7df4, 0x806f, 0x84ee, 0x8f26, 0x9023, 0x934a,
+ 0x51bd, 0x5217, 0x52a3, 0x6d0c, 0x70c8, 0x88c2, 0x5ec9, 0x6582,
+ 0x6bae, 0x6fc2, 0x7c3e, 0x7375, 0x4ee4, 0x4f36, 0x56f9, 0xf95f,
+ 0x5cba, 0x5dba, 0x601c, 0x73b2, 0x7b2d, 0x7f9a, 0x7fce, 0x8046,
+ 0x901e, 0x9234, 0x96f6, 0x9748, 0x9818, 0x9f61, 0x4f8b, 0x6fa7,
+ 0x79ae, 0x91b4, 0x96b7, 0x52de, 0xf960, 0x6488, 0x64c4, 0x6ad3,
+ 0x6f5e, 0x7018, 0x7210, 0x76e7, 0x8001, 0x8606, 0x865c, 0x8def,
+ 0x8f05, 0x9732, 0x9b6f, 0x9dfa, 0x9e75, 0x788c, 0x797f, 0x7da0,
+ 0x83c9, 0x9304, 0x9e7f, 0x9e93, 0x8ad6, 0x58df, 0x5f04, 0x6727,
+ 0x7027, 0x74cf, 0x7c60, 0x807e, 0x5121, 0x7028, 0x7262, 0x78ca,
+ 0x8cc2, 0x8cda, 0x8cf4, 0x96f7, 0x4e86, 0x50da, 0x5bee, 0x5ed6,
+ 0x6599, 0x71ce, 0x7642, 0x77ad, 0x804a, 0x84fc,
+ /* 0x57 */
+ 0x907c, 0x9b27, 0x9f8d, 0x58d8, 0x5a41, 0x5c62, 0x6a13, 0x6dda,
+ 0x6f0f, 0x763b, 0x7d2f, 0x7e37, 0x851e, 0x8938, 0x93e4, 0x964b,
+ 0x5289, 0x65d2, 0x67f3, 0x69b4, 0x6d41, 0x6e9c, 0x700f, 0x7409,
+ 0x7460, 0x7559, 0x7624, 0x786b, 0x8b2c, 0x985e, 0x516d, 0x622e,
+ 0x9678, 0x4f96, 0x502b, 0x5d19, 0x6dea, 0x7db8, 0x8f2a, 0x5f8b,
+ 0x6144, 0x6817, 0xf961, 0x9686, 0x52d2, 0x808b, 0x51dc, 0x51cc,
+ 0x695e, 0x7a1c, 0x7dbe, 0x83f1, 0x9675, 0x4fda, 0x5229, 0x5398,
+ 0x540f, 0x550e, 0x5c65, 0x60a7, 0x674e, 0x68a8, 0x6d6c, 0x7281,
+ 0x72f8, 0x7406, 0x7483, 0xf962, 0x75e2, 0x7c6c, 0x7f79, 0x7fb8,
+ 0x8389, 0x88cf, 0x88e1, 0x91cc, 0x91d0, 0x96e2, 0x9bc9, 0x541d,
+ 0x6f7e, 0x71d0, 0x7498, 0x85fa, 0x8eaa, 0x96a3, 0x9c57, 0x9e9f,
+ 0x6797, 0x6dcb, 0x7433, 0x81e8, 0x9716, 0x782c,
+ /* 0x58 */
+ 0x7acb, 0x7b20, 0x7c92, 0x6469, 0x746a, 0x75f2, 0x78bc, 0x78e8,
+ 0x99ac, 0x9b54, 0x9ebb, 0x5bde, 0x5e55, 0x6f20, 0x819c, 0x83ab,
+ 0x9088, 0x4e07, 0x534d, 0x5a29, 0x5dd2, 0x5f4e, 0x6162, 0x633d,
+ 0x6669, 0x66fc, 0x6eff, 0x6f2b, 0x7063, 0x779e, 0x842c, 0x8513,
+ 0x883b, 0x8f13, 0x9945, 0x9c3b, 0x551c, 0x62b9, 0x672b, 0x6cab,
+ 0x8309, 0x896a, 0x977a, 0x4ea1, 0x5984, 0x5fd8, 0x5fd9, 0x671b,
+ 0x7db2, 0x7f54, 0x8292, 0x832b, 0x83bd, 0x8f1e, 0x9099, 0x57cb,
+ 0x59b9, 0x5a92, 0x5bd0, 0x6627, 0x679a, 0x6885, 0x6bcf, 0x7164,
+ 0x7f75, 0x8cb7, 0x8ce3, 0x9081, 0x9b45, 0x8108, 0x8c8a, 0x964c,
+ 0x9a40, 0x9ea5, 0x5b5f, 0x6c13, 0x731b, 0x76f2, 0x76df, 0x840c,
+ 0x51aa, 0x8993, 0x514d, 0x5195, 0x52c9, 0x68c9, 0x6c94, 0x7704,
+ 0x7720, 0x7dbf, 0x7dec, 0x9762, 0x9eb5, 0x6ec5,
+ /* 0x59 */
+ 0x8511, 0x51a5, 0x540d, 0x547d, 0x660e, 0x669d, 0x6927, 0x6e9f,
+ 0x76bf, 0x7791, 0x8317, 0x84c2, 0x879f, 0x9169, 0x9298, 0x9cf4,
+ 0x8882, 0x4fae, 0x5192, 0x52df, 0x59c6, 0x5e3d, 0x6155, 0x6478,
+ 0x6479, 0x66ae, 0x67d0, 0x6a21, 0x6bcd, 0x6bdb, 0x725f, 0x7261,
+ 0x7441, 0x7738, 0x77db, 0x8017, 0x82bc, 0x8305, 0x8b00, 0x8b28,
+ 0x8c8c, 0x6728, 0x6c90, 0x7267, 0x76ee, 0x7766, 0x7a46, 0x9da9,
+ 0x6b7f, 0x6c92, 0x5922, 0x6726, 0x8499, 0x536f, 0x5893, 0x5999,
+ 0x5edf, 0x63cf, 0x6634, 0x6773, 0x6e3a, 0x732b, 0x7ad7, 0x82d7,
+ 0x9328, 0x52d9, 0x5deb, 0x61ae, 0x61cb, 0x620a, 0x62c7, 0x64ab,
+ 0x65e0, 0x6959, 0x6b66, 0x6bcb, 0x7121, 0x73f7, 0x755d, 0x7e46,
+ 0x821e, 0x8302, 0x856a, 0x8aa3, 0x8cbf, 0x9727, 0x9d61, 0x58a8,
+ 0x9ed8, 0x5011, 0x520e, 0x543b, 0x554f, 0x6587,
+ /* 0x5a */
+ 0x6c76, 0x7d0a, 0x7d0b, 0x805e, 0x868a, 0x9580, 0x96ef, 0x52ff,
+ 0x6c95, 0x7269, 0x5473, 0x5a9a, 0x5c3e, 0x5d4b, 0x5f4c, 0x5fae,
+ 0x672a, 0x68b6, 0x6963, 0x6e3c, 0x6e44, 0x7709, 0x7c73, 0x7f8e,
+ 0x8587, 0x8b0e, 0x8ff7, 0x9761, 0x9ef4, 0x5cb7, 0x60b6, 0x610d,
+ 0x61ab, 0x654f, 0x65fb, 0x65fc, 0x6c11, 0x6cef, 0x739f, 0x73c9,
+ 0x7de1, 0x9594, 0x5bc6, 0x871c, 0x8b10, 0x525d, 0x535a, 0x62cd,
+ 0x640f, 0x64b2, 0x6734, 0x6a38, 0x6cca, 0x73c0, 0x749e, 0x7b94,
+ 0x7c95, 0x7e1b, 0x818a, 0x8236, 0x8584, 0x8feb, 0x96f9, 0x99c1,
+ 0x4f34, 0x534a, 0x53cd, 0x53db, 0x62cc, 0x642c, 0x6500, 0x6591,
+ 0x69c3, 0x6cee, 0x6f58, 0x73ed, 0x7554, 0x7622, 0x76e4, 0x76fc,
+ 0x78d0, 0x78fb, 0x792c, 0x7d46, 0x822c, 0x87e0, 0x8fd4, 0x9812,
+ 0x98ef, 0x52c3, 0x62d4, 0x64a5, 0x6e24, 0x6f51,
+ /* 0x5b */
+ 0x767c, 0x8dcb, 0x91b1, 0x9262, 0x9aee, 0x9b43, 0x5023, 0x508d,
+ 0x574a, 0x59a8, 0x5c28, 0x5e47, 0x5f77, 0x623f, 0x653e, 0x65b9,
+ 0x65c1, 0x6609, 0x678b, 0x699c, 0x6ec2, 0x78c5, 0x7d21, 0x80aa,
+ 0x8180, 0x822b, 0x82b3, 0x84a1, 0x868c, 0x8a2a, 0x8b17, 0x90a6,
+ 0x9632, 0x9f90, 0x500d, 0x4ff3, 0xf963, 0x57f9, 0x5f98, 0x62dc,
+ 0x6392, 0x676f, 0x6e43, 0x7119, 0x76c3, 0x80cc, 0x80da, 0x88f4,
+ 0x88f5, 0x8919, 0x8ce0, 0x8f29, 0x914d, 0x966a, 0x4f2f, 0x4f70,
+ 0x5e1b, 0x67cf, 0x6822, 0x767d, 0x767e, 0x9b44, 0x5e61, 0x6a0a,
+ 0x7169, 0x71d4, 0x756a, 0xf964, 0x7e41, 0x8543, 0x85e9, 0x98dc,
+ 0x4f10, 0x7b4f, 0x7f70, 0x95a5, 0x51e1, 0x5e06, 0x68b5, 0x6c3e,
+ 0x6c4e, 0x6cdb, 0x72af, 0x7bc4, 0x8303, 0x6cd5, 0x743a, 0x50fb,
+ 0x5288, 0x58c1, 0x64d8, 0x6a97, 0x74a7, 0x7656,
+ /* 0x5c */
+ 0x78a7, 0x8617, 0x95e2, 0x9739, 0xf965, 0x535e, 0x5f01, 0x8b8a,
+ 0x8fa8, 0x8faf, 0x908a, 0x5225, 0x77a5, 0x9c49, 0x9f08, 0x4e19,
+ 0x5002, 0x5175, 0x5c5b, 0x5e77, 0x661e, 0x663a, 0x67c4, 0x68c5,
+ 0x70b3, 0x7501, 0x75c5, 0x79c9, 0x7add, 0x8f27, 0x9920, 0x9a08,
+ 0x4fdd, 0x5821, 0x5831, 0x5bf6, 0x666e, 0x6b65, 0x6d11, 0x6e7a,
+ 0x6f7d, 0x73e4, 0x752b, 0x83e9, 0x88dc, 0x8913, 0x8b5c, 0x8f14,
+ 0x4f0f, 0x50d5, 0x5310, 0x535c, 0x5b93, 0x5fa9, 0x670d, 0x798f,
+ 0x8179, 0x832f, 0x8514, 0x8907, 0x8986, 0x8f39, 0x8f3b, 0x99a5,
+ 0x9c12, 0x672c, 0x4e76, 0x4ff8, 0x5949, 0x5c01, 0x5cef, 0x5cf0,
+ 0x6367, 0x68d2, 0x70fd, 0x71a2, 0x742b, 0x7e2b, 0x84ec, 0x8702,
+ 0x9022, 0x92d2, 0x9cf3, 0x4e0d, 0x4ed8, 0x4fef, 0x5085, 0x5256,
+ 0x526f, 0x5426, 0x5490, 0x57e0, 0x592b, 0x5a66,
+ /* 0x5d */
+ 0x5b5a, 0x5b75, 0x5bcc, 0x5e9c, 0xf966, 0x6276, 0x6577, 0x65a7,
+ 0x6d6e, 0x6ea5, 0x7236, 0x7b26, 0x7c3f, 0x7f36, 0x8150, 0x8151,
+ 0x819a, 0x8240, 0x8299, 0x83a9, 0x8a03, 0x8ca0, 0x8ce6, 0x8cfb,
+ 0x8d74, 0x8dba, 0x90e8, 0x91dc, 0x961c, 0x9644, 0x99d9, 0x9ce7,
+ 0x5317, 0x5206, 0x5429, 0x5674, 0x58b3, 0x5954, 0x596e, 0x5fff,
+ 0x61a4, 0x626e, 0x6610, 0x6c7e, 0x711a, 0x76c6, 0x7c89, 0x7cde,
+ 0x7d1b, 0x82ac, 0x8cc1, 0x96f0, 0xf967, 0x4f5b, 0x5f17, 0x5f7f,
+ 0x62c2, 0x5d29, 0x670b, 0x68da, 0x787c, 0x7e43, 0x9d6c, 0x4e15,
+ 0x5099, 0x5315, 0x532a, 0x5351, 0x5983, 0x5a62, 0x5e87, 0x60b2,
+ 0x618a, 0x6249, 0x6279, 0x6590, 0x6787, 0x69a7, 0x6bd4, 0x6bd6,
+ 0x6bd7, 0x6bd8, 0x6cb8, 0xf968, 0x7435, 0x75fa, 0x7812, 0x7891,
+ 0x79d5, 0x79d8, 0x7c83, 0x7dcb, 0x7fe1, 0x80a5,
+ /* 0x5e */
+ 0x813e, 0x81c2, 0x83f2, 0x871a, 0x88e8, 0x8ab9, 0x8b6c, 0x8cbb,
+ 0x9119, 0x975e, 0x98db, 0x9f3b, 0x56ac, 0x5b2a, 0x5f6c, 0x658c,
+ 0x6ab3, 0x6baf, 0x6d5c, 0x6ff1, 0x7015, 0x725d, 0x73ad, 0x8ca7,
+ 0x8cd3, 0x983b, 0x6191, 0x6c37, 0x8058, 0x9a01, 0x4e4d, 0x4e8b,
+ 0x4e9b, 0x4ed5, 0x4f3a, 0x4f3c, 0x4f7f, 0x4fdf, 0x50ff, 0x53f2,
+ 0x53f8, 0x5506, 0x55e3, 0x56db, 0x58eb, 0x5962, 0x5a11, 0x5beb,
+ 0x5bfa, 0x5c04, 0x5df3, 0x5e2b, 0x5f99, 0x601d, 0x6368, 0x659c,
+ 0x65af, 0x67f6, 0x67fb, 0x68ad, 0x6b7b, 0x6c99, 0x6cd7, 0x6e23,
+ 0x7009, 0x7345, 0x7802, 0x793e, 0x7940, 0x7960, 0x79c1, 0x7be9,
+ 0x7d17, 0x7d72, 0x8086, 0x820d, 0x838e, 0x84d1, 0x86c7, 0x88df,
+ 0x8a50, 0x8a5e, 0x8b1d, 0x8cdc, 0x8d66, 0x8fad, 0x90aa, 0x98fc,
+ 0x99df, 0x9e9d, 0x524a, 0xf969, 0x6714, 0xf96a,
+ /* 0x5f */
+ 0x5098, 0x522a, 0x5c71, 0x6563, 0x6c55, 0x73ca, 0x7523, 0x759d,
+ 0x7b97, 0x849c, 0x9178, 0x9730, 0x4e77, 0x6492, 0x6bba, 0x715e,
+ 0x85a9, 0x4e09, 0xf96b, 0x6749, 0x68ee, 0x6e17, 0x829f, 0x8518,
+ 0x886b, 0x63f7, 0x6f81, 0x9212, 0x98af, 0x4e0a, 0x50b7, 0x50cf,
+ 0x511f, 0x5546, 0x55aa, 0x5617, 0x5b40, 0x5c19, 0x5ce0, 0x5e38,
+ 0x5e8a, 0x5ea0, 0x5ec2, 0x60f3, 0x6851, 0x6a61, 0x6e58, 0x723d,
+ 0x7240, 0x72c0, 0x76f8, 0x7965, 0x7bb1, 0x7fd4, 0x88f3, 0x89f4,
+ 0x8a73, 0x8c61, 0x8cde, 0x971c, 0x585e, 0x74bd, 0x8cfd, 0x55c7,
+ 0xf96c, 0x7a61, 0x7d22, 0x8272, 0x7272, 0x751f, 0x7525, 0xf96d,
+ 0x7b19, 0x5885, 0x58fb, 0x5dbc, 0x5e8f, 0x5eb6, 0x5f90, 0x6055,
+ 0x6292, 0x637f, 0x654d, 0x6691, 0x66d9, 0x66f8, 0x6816, 0x68f2,
+ 0x7280, 0x745e, 0x7b6e, 0x7d6e, 0x7dd6, 0x7f72,
+ /* 0x60 */
+ 0x80e5, 0x8212, 0x85af, 0x897f, 0x8a93, 0x901d, 0x92e4, 0x9ecd,
+ 0x9f20, 0x5915, 0x596d, 0x5e2d, 0x60dc, 0x6614, 0x6673, 0x6790,
+ 0x6c50, 0x6dc5, 0x6f5f, 0x77f3, 0x78a9, 0x84c6, 0x91cb, 0x932b,
+ 0x4ed9, 0x50ca, 0x5148, 0x5584, 0x5b0b, 0x5ba3, 0x6247, 0x657e,
+ 0x65cb, 0x6e32, 0x717d, 0x7401, 0x7444, 0x7487, 0x74bf, 0x766c,
+ 0x79aa, 0x7dda, 0x7e55, 0x7fa8, 0x817a, 0x81b3, 0x8239, 0x861a,
+ 0x87ec, 0x8a75, 0x8de3, 0x9078, 0x9291, 0x9425, 0x994d, 0x9bae,
+ 0x5368, 0x5c51, 0x6954, 0x6cc4, 0x6d29, 0x6e2b, 0x820c, 0x859b,
+ 0x893b, 0x8a2d, 0x8aaa, 0x96ea, 0x9f67, 0x5261, 0x66b9, 0x6bb2,
+ 0x7e96, 0x87fe, 0x8d0d, 0x9583, 0x965d, 0x651d, 0x6d89, 0x71ee,
+ 0xf96e, 0x57ce, 0x59d3, 0x5bac, 0x6027, 0x60fa, 0x6210, 0x661f,
+ 0x665f, 0x7329, 0x73f9, 0x76db, 0x7701, 0x7b6c,
+ /* 0x61 */
+ 0x8056, 0x8072, 0x8165, 0x8aa0, 0x9192, 0x4e16, 0x52e2, 0x6b72,
+ 0x6d17, 0x7a05, 0x7b39, 0x7d30, 0xf96f, 0x8cb0, 0x53ec, 0x562f,
+ 0x5851, 0x5bb5, 0x5c0f, 0x5c11, 0x5de2, 0x6240, 0x6383, 0x6414,
+ 0x662d, 0x68b3, 0x6cbc, 0x6d88, 0x6eaf, 0x701f, 0x70a4, 0x71d2,
+ 0x7526, 0x758f, 0x758e, 0x7619, 0x7b11, 0x7be0, 0x7c2b, 0x7d20,
+ 0x7d39, 0x852c, 0x856d, 0x8607, 0x8a34, 0x900d, 0x9061, 0x90b5,
+ 0x92b7, 0x97f6, 0x9a37, 0x4fd7, 0x5c6c, 0x675f, 0x6d91, 0x7c9f,
+ 0x7e8c, 0x8b16, 0x8d16, 0x901f, 0x5b6b, 0x5dfd, 0x640d, 0x84c0,
+ 0x905c, 0x98e1, 0x7387, 0x5b8b, 0x609a, 0x677e, 0x6dde, 0x8a1f,
+ 0x8aa6, 0x9001, 0x980c, 0x5237, 0xf970, 0x7051, 0x788e, 0x9396,
+ 0x8870, 0x91d7, 0x4fee, 0x53d7, 0x55fd, 0x56da, 0x5782, 0x58fd,
+ 0x5ac2, 0x5b88, 0x5cab, 0x5cc0, 0x5e25, 0x6101,
+ /* 0x62 */
+ 0x620d, 0x624b, 0x6388, 0x641c, 0x6536, 0x6578, 0x6a39, 0x6b8a,
+ 0x6c34, 0x6d19, 0x6f31, 0x71e7, 0x72e9, 0x7378, 0x7407, 0x74b2,
+ 0x7626, 0x7761, 0x79c0, 0x7a57, 0x7aea, 0x7cb9, 0x7d8f, 0x7dac,
+ 0x7e61, 0x7f9e, 0x8129, 0x8331, 0x8490, 0x84da, 0x85ea, 0x8896,
+ 0x8ab0, 0x8b90, 0x8f38, 0x9042, 0x9083, 0x916c, 0x9296, 0x92b9,
+ 0x968b, 0x96a7, 0x96a8, 0x96d6, 0x9700, 0x9808, 0x9996, 0x9ad3,
+ 0x9b1a, 0x53d4, 0x587e, 0x5919, 0x5b70, 0x5bbf, 0x6dd1, 0x6f5a,
+ 0x719f, 0x7421, 0x74b9, 0x8085, 0x83fd, 0x5de1, 0x5f87, 0x5faa,
+ 0x6042, 0x65ec, 0x6812, 0x696f, 0x6a53, 0x6b89, 0x6d35, 0x6df3,
+ 0x73e3, 0x76fe, 0x77ac, 0x7b4d, 0x7d14, 0x8123, 0x821c, 0x8340,
+ 0x84f4, 0x8563, 0x8a62, 0x8ac4, 0x9187, 0x931e, 0x9806, 0x99b4,
+ 0x620c, 0x8853, 0x8ff0, 0x9265, 0x5d07, 0x5d27,
+ /* 0x63 */
+ 0x5d69, 0x745f, 0x819d, 0x8768, 0x6fd5, 0x62fe, 0x7fd2, 0x8936,
+ 0x8972, 0x4e1e, 0x4e58, 0x50e7, 0x52dd, 0x5347, 0x627f, 0x6607,
+ 0x7e69, 0x8805, 0x965e, 0x4f8d, 0x5319, 0x5636, 0x59cb, 0x5aa4,
+ 0x5c38, 0x5c4e, 0x5c4d, 0x5e02, 0x5f11, 0x6043, 0x65bd, 0x662f,
+ 0x6642, 0x67be, 0x67f4, 0x731c, 0x77e2, 0x793a, 0x7fc5, 0x8494,
+ 0x84cd, 0x8996, 0x8a66, 0x8a69, 0x8ae1, 0x8c55, 0x8c7a, 0x57f4,
+ 0x5bd4, 0x5f0f, 0x606f, 0x62ed, 0x690d, 0x6b96, 0x6e5c, 0x7184,
+ 0x7bd2, 0x8755, 0x8b58, 0x8efe, 0x98df, 0x98fe, 0x4f38, 0x4f81,
+ 0x4fe1, 0x547b, 0x5a20, 0x5bb8, 0x613c, 0x65b0, 0x6668, 0x71fc,
+ 0x7533, 0x795e, 0x7d33, 0x814e, 0x81e3, 0x8398, 0x85aa, 0x85ce,
+ 0x8703, 0x8a0a, 0x8eab, 0x8f9b, 0xf971, 0x8fc5, 0x5931, 0x5ba4,
+ 0x5be6, 0x6089, 0x5be9, 0x5c0b, 0x5fc3, 0x6c81,
+ /* 0x64 */
+ 0xf972, 0x6df1, 0x700b, 0x751a, 0x82af, 0x8af6, 0x4ec0, 0x5341,
+ 0xf973, 0x96d9, 0x6c0f, 0x4e9e, 0x4fc4, 0x5152, 0x555e, 0x5a25,
+ 0x5ce8, 0x6211, 0x7259, 0x82bd, 0x83aa, 0x86fe, 0x8859, 0x8a1d,
+ 0x963f, 0x96c5, 0x9913, 0x9d09, 0x9d5d, 0x580a, 0x5cb3, 0x5dbd,
+ 0x5e44, 0x60e1, 0x6115, 0x63e1, 0x6a02, 0x6e25, 0x9102, 0x9354,
+ 0x984e, 0x9c10, 0x9f77, 0x5b89, 0x5cb8, 0x6309, 0x664f, 0x6848,
+ 0x773c, 0x96c1, 0x978d, 0x9854, 0x9b9f, 0x65a1, 0x8b01, 0x8ecb,
+ 0x95bc, 0x5535, 0x5ca9, 0x5dd6, 0x5eb5, 0x6697, 0x764c, 0x83f4,
+ 0x95c7, 0x58d3, 0x62bc, 0x72ce, 0x9d28, 0x4ef0, 0x592e, 0x600f,
+ 0x663b, 0x6b83, 0x79e7, 0x9d26, 0x5393, 0x54c0, 0x57c3, 0x5d16,
+ 0x611b, 0x66d6, 0x6daf, 0x788d, 0x827e, 0x9698, 0x9744, 0x5384,
+ 0x627c, 0x6396, 0x6db2, 0x7e0a, 0x814b, 0x984d,
+ /* 0x65 */
+ 0x6afb, 0x7f4c, 0x9daf, 0x9e1a, 0x4e5f, 0x503b, 0x51b6, 0x591c,
+ 0x60f9, 0x63f6, 0x6930, 0x723a, 0x8036, 0xf974, 0x91ce, 0x5f31,
+ 0xf975, 0xf976, 0x7d04, 0x82e5, 0x846f, 0x84bb, 0x85e5, 0x8e8d,
+ 0xf977, 0x4f6f, 0xf978, 0xf979, 0x58e4, 0x5b43, 0x6059, 0x63da,
+ 0x6518, 0x656d, 0x6698, 0xf97a, 0x694a, 0x6a23, 0x6d0b, 0x7001,
+ 0x716c, 0x75d2, 0x760d, 0x79b3, 0x7a70, 0xf97b, 0x7f8a, 0xf97c,
+ 0x8944, 0xf97d, 0x8b93, 0x91c0, 0x967d, 0xf97e, 0x990a, 0x5704,
+ 0x5fa1, 0x65bc, 0x6f01, 0x7600, 0x79a6, 0x8a9e, 0x99ad, 0x9b5a,
+ 0x9f6c, 0x5104, 0x61b6, 0x6291, 0x6a8d, 0x81c6, 0x5043, 0x5830,
+ 0x5f66, 0x7109, 0x8a00, 0x8afa, 0x5b7c, 0x8616, 0x4ffa, 0x513c,
+ 0x56b4, 0x5944, 0x63a9, 0x6df9, 0x5daa, 0x696d, 0x5186, 0x4e88,
+ 0x4f59, 0xf97f, 0xf980, 0xf981, 0x5982, 0xf982,
+ /* 0x66 */
+ 0xf983, 0x6b5f, 0x6c5d, 0xf984, 0x74b5, 0x7916, 0xf985, 0x8207,
+ 0x8245, 0x8339, 0x8f3f, 0x8f5d, 0xf986, 0x9918, 0xf987, 0xf988,
+ 0xf989, 0x4ea6, 0xf98a, 0x57df, 0x5f79, 0x6613, 0xf98b, 0xf98c,
+ 0x75ab, 0x7e79, 0x8b6f, 0xf98d, 0x9006, 0x9a5b, 0x56a5, 0x5827,
+ 0x59f8, 0x5a1f, 0x5bb4, 0xf98e, 0x5ef6, 0xf98f, 0xf990, 0x6350,
+ 0x633b, 0xf991, 0x693d, 0x6c87, 0x6cbf, 0x6d8e, 0x6d93, 0x6df5,
+ 0x6f14, 0xf992, 0x70df, 0x7136, 0x7159, 0xf993, 0x71c3, 0x71d5,
+ 0xf994, 0x784f, 0x786f, 0xf995, 0x7b75, 0x7de3, 0xf996, 0x7e2f,
+ 0xf997, 0x884d, 0x8edf, 0xf998, 0xf999, 0xf99a, 0x925b, 0xf99b,
+ 0x9cf6, 0xf99c, 0xf99d, 0xf99e, 0x6085, 0x6d85, 0xf99f, 0x71b1,
+ 0xf9a0, 0xf9a1, 0x95b1, 0x53ad, 0xf9a2, 0xf9a3, 0xf9a4, 0x67d3,
+ 0xf9a5, 0x708e, 0x7130, 0x7430, 0x8276, 0x82d2,
+ /* 0x67 */
+ 0xf9a6, 0x95bb, 0x9ae5, 0x9e7d, 0x66c4, 0xf9a7, 0x71c1, 0x8449,
+ 0xf9a8, 0xf9a9, 0x584b, 0xf9aa, 0xf9ab, 0x5db8, 0x5f71, 0xf9ac,
+ 0x6620, 0x668e, 0x6979, 0x69ae, 0x6c38, 0x6cf3, 0x6e36, 0x6f41,
+ 0x6fda, 0x701b, 0x702f, 0x7150, 0x71df, 0x7370, 0xf9ad, 0x745b,
+ 0xf9ae, 0x74d4, 0x76c8, 0x7a4e, 0x7e93, 0xf9af, 0xf9b0, 0x82f1,
+ 0x8a60, 0x8fce, 0xf9b1, 0x9348, 0xf9b2, 0x9719, 0xf9b3, 0xf9b4,
+ 0x4e42, 0x502a, 0xf9b5, 0x5208, 0x53e1, 0x66f3, 0x6c6d, 0x6fca,
+ 0x730a, 0x777f, 0x7a62, 0x82ae, 0x85dd, 0x8602, 0xf9b6, 0x88d4,
+ 0x8a63, 0x8b7d, 0x8c6b, 0xf9b7, 0x92b3, 0xf9b8, 0x9713, 0x9810,
+ 0x4e94, 0x4f0d, 0x4fc9, 0x50b2, 0x5348, 0x543e, 0x5433, 0x55da,
+ 0x5862, 0x58ba, 0x5967, 0x5a1b, 0x5be4, 0x609f, 0xf9b9, 0x61ca,
+ 0x6556, 0x65ff, 0x6664, 0x68a7, 0x6c5a, 0x6fb3,
+ /* 0x68 */
+ 0x70cf, 0x71ac, 0x7352, 0x7b7d, 0x8708, 0x8aa4, 0x9c32, 0x9f07,
+ 0x5c4b, 0x6c83, 0x7344, 0x7389, 0x923a, 0x6eab, 0x7465, 0x761f,
+ 0x7a69, 0x7e15, 0x860a, 0x5140, 0x58c5, 0x64c1, 0x74ee, 0x7515,
+ 0x7670, 0x7fc1, 0x9095, 0x96cd, 0x9954, 0x6e26, 0x74e6, 0x7aa9,
+ 0x7aaa, 0x81e5, 0x86d9, 0x8778, 0x8a1b, 0x5a49, 0x5b8c, 0x5b9b,
+ 0x68a1, 0x6900, 0x6d63, 0x73a9, 0x7413, 0x742c, 0x7897, 0x7de9,
+ 0x7feb, 0x8118, 0x8155, 0x839e, 0x8c4c, 0x962e, 0x9811, 0x66f0,
+ 0x5f80, 0x65fa, 0x6789, 0x6c6a, 0x738b, 0x502d, 0x5a03, 0x6b6a,
+ 0x77ee, 0x5916, 0x5d6c, 0x5dcd, 0x7325, 0x754f, 0xf9ba, 0xf9bb,
+ 0x50e5, 0x51f9, 0x582f, 0x592d, 0x5996, 0x59da, 0x5be5, 0xf9bc,
+ 0xf9bd, 0x5da2, 0x62d7, 0x6416, 0x6493, 0x64fe, 0xf9be, 0x66dc,
+ 0xf9bf, 0x6a48, 0xf9c0, 0x71ff, 0x7464, 0xf9c1,
+ /* 0x69 */
+ 0x7a88, 0x7aaf, 0x7e47, 0x7e5e, 0x8000, 0x8170, 0xf9c2, 0x87ef,
+ 0x8981, 0x8b20, 0x9059, 0xf9c3, 0x9080, 0x9952, 0x617e, 0x6b32,
+ 0x6d74, 0x7e1f, 0x8925, 0x8fb1, 0x4fd1, 0x50ad, 0x5197, 0x52c7,
+ 0x57c7, 0x5889, 0x5bb9, 0x5eb8, 0x6142, 0x6995, 0x6d8c, 0x6e67,
+ 0x6eb6, 0x7194, 0x7462, 0x7528, 0x752c, 0x8073, 0x8338, 0x84c9,
+ 0x8e0a, 0x9394, 0x93de, 0xf9c4, 0x4e8e, 0x4f51, 0x5076, 0x512a,
+ 0x53c8, 0x53cb, 0x53f3, 0x5b87, 0x5bd3, 0x5c24, 0x611a, 0x6182,
+ 0x65f4, 0x725b, 0x7397, 0x7440, 0x76c2, 0x7950, 0x7991, 0x79b9,
+ 0x7d06, 0x7fbd, 0x828b, 0x85d5, 0x865e, 0x8fc2, 0x9047, 0x90f5,
+ 0x91ea, 0x9685, 0x96e8, 0x96e9, 0x52d6, 0x5f67, 0x65ed, 0x6631,
+ 0x682f, 0x715c, 0x7a36, 0x90c1, 0x980a, 0x4e91, 0xf9c5, 0x6a52,
+ 0x6b9e, 0x6f90, 0x7189, 0x8018, 0x82b8, 0x8553,
+ /* 0x6a */
+ 0x904b, 0x9695, 0x96f2, 0x97fb, 0x851a, 0x9b31, 0x4e90, 0x718a,
+ 0x96c4, 0x5143, 0x539f, 0x54e1, 0x5713, 0x5712, 0x57a3, 0x5a9b,
+ 0x5ac4, 0x5bc3, 0x6028, 0x613f, 0x63f4, 0x6c85, 0x6d39, 0x6e72,
+ 0x6e90, 0x7230, 0x733f, 0x7457, 0x82d1, 0x8881, 0x8f45, 0x9060,
+ 0xf9c6, 0x9662, 0x9858, 0x9d1b, 0x6708, 0x8d8a, 0x925e, 0x4f4d,
+ 0x5049, 0x50de, 0x5371, 0x570d, 0x59d4, 0x5a01, 0x5c09, 0x6170,
+ 0x6690, 0x6e2d, 0x7232, 0x744b, 0x7def, 0x80c3, 0x840e, 0x8466,
+ 0x853f, 0x875f, 0x885b, 0x8918, 0x8b02, 0x9055, 0x97cb, 0x9b4f,
+ 0x4e73, 0x4f91, 0x5112, 0x516a, 0xf9c7, 0x552f, 0x55a9, 0x5b7a,
+ 0x5ba5, 0x5e7c, 0x5e7d, 0x5ebe, 0x60a0, 0x60df, 0x6108, 0x6109,
+ 0x63c4, 0x6538, 0x6709, 0xf9c8, 0x67d4, 0x67da, 0xf9c9, 0x6961,
+ 0x6962, 0x6cb9, 0x6d27, 0xf9ca, 0x6e38, 0xf9cb,
+ /* 0x6b */
+ 0x6fe1, 0x7336, 0x7337, 0xf9cc, 0x745c, 0x7531, 0xf9cd, 0x7652,
+ 0xf9ce, 0xf9cf, 0x7dad, 0x81fe, 0x8438, 0x88d5, 0x8a98, 0x8adb,
+ 0x8aed, 0x8e30, 0x8e42, 0x904a, 0x903e, 0x907a, 0x9149, 0x91c9,
+ 0x936e, 0xf9d0, 0xf9d1, 0x5809, 0xf9d2, 0x6bd3, 0x8089, 0x80b2,
+ 0xf9d3, 0xf9d4, 0x5141, 0x596b, 0x5c39, 0xf9d5, 0xf9d6, 0x6f64,
+ 0x73a7, 0x80e4, 0x8d07, 0xf9d7, 0x9217, 0x958f, 0xf9d8, 0xf9d9,
+ 0xf9da, 0xf9db, 0x807f, 0x620e, 0x701c, 0x7d68, 0x878d, 0xf9dc,
+ 0x57a0, 0x6069, 0x6147, 0x6bb7, 0x8abe, 0x9280, 0x96b1, 0x4e59,
+ 0x541f, 0x6deb, 0x852d, 0x9670, 0x97f3, 0x98ee, 0x63d6, 0x6ce3,
+ 0x9091, 0x51dd, 0x61c9, 0x81ba, 0x9df9, 0x4f9d, 0x501a, 0x5100,
+ 0x5b9c, 0x610f, 0x61ff, 0x64ec, 0x6905, 0x6bc5, 0x7591, 0x77e3,
+ 0x7fa9, 0x8264, 0x858f, 0x87fb, 0x8863, 0x8abc,
+ /* 0x6c */
+ 0x8b70, 0x91ab, 0x4e8c, 0x4ee5, 0x4f0a, 0xf9dd, 0xf9de, 0x5937,
+ 0x59e8, 0xf9df, 0x5df2, 0x5f1b, 0x5f5b, 0x6021, 0xf9e0, 0xf9e1,
+ 0xf9e2, 0xf9e3, 0x723e, 0x73e5, 0xf9e4, 0x7570, 0x75cd, 0xf9e5,
+ 0x79fb, 0xf9e6, 0x800c, 0x8033, 0x8084, 0x82e1, 0x8351, 0xf9e7,
+ 0xf9e8, 0x8cbd, 0x8cb3, 0x9087, 0xf9e9, 0xf9ea, 0x98f4, 0x990c,
+ 0xf9eb, 0xf9ec, 0x7037, 0x76ca, 0x7fca, 0x7fcc, 0x7ffc, 0x8b1a,
+ 0x4eba, 0x4ec1, 0x5203, 0x5370, 0xf9ed, 0x54bd, 0x56e0, 0x59fb,
+ 0x5bc5, 0x5f15, 0x5fcd, 0x6e6e, 0xf9ee, 0xf9ef, 0x7d6a, 0x8335,
+ 0xf9f0, 0x8693, 0x8a8d, 0xf9f1, 0x976d, 0x9777, 0xf9f2, 0xf9f3,
+ 0x4e00, 0x4f5a, 0x4f7e, 0x58f9, 0x65e5, 0x6ea2, 0x9038, 0x93b0,
+ 0x99b9, 0x4efb, 0x58ec, 0x598a, 0x59d9, 0x6041, 0xf9f4, 0xf9f5,
+ 0x7a14, 0xf9f6, 0x834f, 0x8cc3, 0x5165, 0x5344,
+ /* 0x6d */
+ 0xf9f7, 0xf9f8, 0xf9f9, 0x4ecd, 0x5269, 0x5b55, 0x82bf, 0x4ed4,
+ 0x523a, 0x54a8, 0x59c9, 0x59ff, 0x5b50, 0x5b57, 0x5b5c, 0x6063,
+ 0x6148, 0x6ecb, 0x7099, 0x716e, 0x7386, 0x74f7, 0x75b5, 0x78c1,
+ 0x7d2b, 0x8005, 0x81ea, 0x8328, 0x8517, 0x85c9, 0x8aee, 0x8cc7,
+ 0x96cc, 0x4f5c, 0x52fa, 0x56bc, 0x65ab, 0x6628, 0x707c, 0x70b8,
+ 0x7235, 0x7dbd, 0x828d, 0x914c, 0x96c0, 0x9d72, 0x5b71, 0x68e7,
+ 0x6b98, 0x6f7a, 0x76de, 0x5c91, 0x66ab, 0x6f5b, 0x7bb4, 0x7c2a,
+ 0x8836, 0x96dc, 0x4e08, 0x4ed7, 0x5320, 0x5834, 0x58bb, 0x58ef,
+ 0x596c, 0x5c07, 0x5e33, 0x5e84, 0x5f35, 0x638c, 0x66b2, 0x6756,
+ 0x6a1f, 0x6aa3, 0x6b0c, 0x6f3f, 0x7246, 0xf9fa, 0x7350, 0x748b,
+ 0x7ae0, 0x7ca7, 0x8178, 0x81df, 0x81e7, 0x838a, 0x846c, 0x8523,
+ 0x8594, 0x85cf, 0x88dd, 0x8d13, 0x91ac, 0x9577,
+ /* 0x6e */
+ 0x969c, 0x518d, 0x54c9, 0x5728, 0x5bb0, 0x624d, 0x6750, 0x683d,
+ 0x6893, 0x6e3d, 0x6ed3, 0x707d, 0x7e21, 0x88c1, 0x8ca1, 0x8f09,
+ 0x9f4b, 0x9f4e, 0x722d, 0x7b8f, 0x8acd, 0x931a, 0x4f47, 0x4f4e,
+ 0x5132, 0x5480, 0x59d0, 0x5e95, 0x62b5, 0x6775, 0x696e, 0x6a17,
+ 0x6cae, 0x6e1a, 0x72d9, 0x732a, 0x75bd, 0x7bb8, 0x7d35, 0x82e7,
+ 0x83f9, 0x8457, 0x85f7, 0x8a5b, 0x8caf, 0x8e87, 0x9019, 0x90b8,
+ 0x96ce, 0x9f5f, 0x52e3, 0x540a, 0x5ae1, 0x5bc2, 0x6458, 0x6575,
+ 0x6ef4, 0x72c4, 0xf9fb, 0x7684, 0x7a4d, 0x7b1b, 0x7c4d, 0x7e3e,
+ 0x7fdf, 0x837b, 0x8b2b, 0x8cca, 0x8d64, 0x8de1, 0x8e5f, 0x8fea,
+ 0x8ff9, 0x9069, 0x93d1, 0x4f43, 0x4f7a, 0x50b3, 0x5168, 0x5178,
+ 0x524d, 0x526a, 0x5861, 0x587c, 0x5960, 0x5c08, 0x5c55, 0x5edb,
+ 0x609b, 0x6230, 0x6813, 0x6bbf, 0x6c08, 0x6fb1,
+ /* 0x6f */
+ 0x714e, 0x7420, 0x7530, 0x7538, 0x7551, 0x7672, 0x7b4c, 0x7b8b,
+ 0x7bad, 0x7bc6, 0x7e8f, 0x8a6e, 0x8f3e, 0x8f49, 0x923f, 0x9293,
+ 0x9322, 0x942b, 0x96fb, 0x985a, 0x986b, 0x991e, 0x5207, 0x622a,
+ 0x6298, 0x6d59, 0x7664, 0x7aca, 0x7bc0, 0x7d76, 0x5360, 0x5cbe,
+ 0x5e97, 0x6f38, 0x70b9, 0x7c98, 0x9711, 0x9b8e, 0x9ede, 0x63a5,
+ 0x647a, 0x8776, 0x4e01, 0x4e95, 0x4ead, 0x505c, 0x5075, 0x5448,
+ 0x59c3, 0x5b9a, 0x5e40, 0x5ead, 0x5ef7, 0x5f81, 0x60c5, 0x633a,
+ 0x653f, 0x6574, 0x65cc, 0x6676, 0x6678, 0x67fe, 0x6968, 0x6a89,
+ 0x6b63, 0x6c40, 0x6dc0, 0x6de8, 0x6e1f, 0x6e5e, 0x701e, 0x70a1,
+ 0x738e, 0x73fd, 0x753a, 0x775b, 0x7887, 0x798e, 0x7a0b, 0x7a7d,
+ 0x7cbe, 0x7d8e, 0x8247, 0x8a02, 0x8aea, 0x8c9e, 0x912d, 0x914a,
+ 0x91d8, 0x9266, 0x92cc, 0x9320, 0x9706, 0x9756,
+ /* 0x70 */
+ 0x975c, 0x9802, 0x9f0e, 0x5236, 0x5291, 0x557c, 0x5824, 0x5e1d,
+ 0x5f1f, 0x608c, 0x63d0, 0x68af, 0x6fdf, 0x796d, 0x7b2c, 0x81cd,
+ 0x85ba, 0x88fd, 0x8af8, 0x8e44, 0x918d, 0x9664, 0x969b, 0x973d,
+ 0x984c, 0x9f4a, 0x4fce, 0x5146, 0x51cb, 0x52a9, 0x5632, 0x5f14,
+ 0x5f6b, 0x63aa, 0x64cd, 0x65e9, 0x6641, 0x66fa, 0x66f9, 0x671d,
+ 0x689d, 0x68d7, 0x69fd, 0x6f15, 0x6f6e, 0x7167, 0x71e5, 0x722a,
+ 0x74aa, 0x773a, 0x7956, 0x795a, 0x79df, 0x7a20, 0x7a95, 0x7c97,
+ 0x7cdf, 0x7d44, 0x7e70, 0x8087, 0x85fb, 0x86a4, 0x8a54, 0x8abf,
+ 0x8d99, 0x8e81, 0x9020, 0x906d, 0x91e3, 0x963b, 0x96d5, 0x9ce5,
+ 0x65cf, 0x7c07, 0x8db3, 0x93c3, 0x5b58, 0x5c0a, 0x5352, 0x62d9,
+ 0x731d, 0x5027, 0x5b97, 0x5f9e, 0x60b0, 0x616b, 0x68d5, 0x6dd9,
+ 0x742e, 0x7a2e, 0x7d42, 0x7d9c, 0x7e31, 0x816b,
+ /* 0x71 */
+ 0x8e2a, 0x8e35, 0x937e, 0x9418, 0x4f50, 0x5750, 0x5de6, 0x5ea7,
+ 0x632b, 0x7f6a, 0x4e3b, 0x4f4f, 0x4f8f, 0x505a, 0x59dd, 0x80c4,
+ 0x546a, 0x5468, 0x55fe, 0x594f, 0x5b99, 0x5dde, 0x5eda, 0x665d,
+ 0x6731, 0x67f1, 0x682a, 0x6ce8, 0x6d32, 0x6e4a, 0x6f8d, 0x70b7,
+ 0x73e0, 0x7587, 0x7c4c, 0x7d02, 0x7d2c, 0x7da2, 0x821f, 0x86db,
+ 0x8a3b, 0x8a85, 0x8d70, 0x8e8a, 0x8f33, 0x9031, 0x914e, 0x9152,
+ 0x9444, 0x99d0, 0x7af9, 0x7ca5, 0x4fca, 0x5101, 0x51c6, 0x57c8,
+ 0x5bef, 0x5cfb, 0x6659, 0x6a3d, 0x6d5a, 0x6e96, 0x6fec, 0x710c,
+ 0x756f, 0x7ae3, 0x8822, 0x9021, 0x9075, 0x96cb, 0x99ff, 0x8301,
+ 0x4e2d, 0x4ef2, 0x8846, 0x91cd, 0x537d, 0x6adb, 0x696b, 0x6c41,
+ 0x847a, 0x589e, 0x618e, 0x66fe, 0x62ef, 0x70dd, 0x7511, 0x75c7,
+ 0x7e52, 0x84b8, 0x8b49, 0x8d08, 0x4e4b, 0x53ea,
+ /* 0x72 */
+ 0x54ab, 0x5730, 0x5740, 0x5fd7, 0x6301, 0x6307, 0x646f, 0x652f,
+ 0x65e8, 0x667a, 0x679d, 0x67b3, 0x6b62, 0x6c60, 0x6c9a, 0x6f2c,
+ 0x77e5, 0x7825, 0x7949, 0x7957, 0x7d19, 0x80a2, 0x8102, 0x81f3,
+ 0x829d, 0x82b7, 0x8718, 0x8a8c, 0xf9fc, 0x8d04, 0x8dbe, 0x9072,
+ 0x76f4, 0x7a19, 0x7a37, 0x7e54, 0x8077, 0x5507, 0x55d4, 0x5875,
+ 0x632f, 0x6422, 0x6649, 0x664b, 0x686d, 0x699b, 0x6b84, 0x6d25,
+ 0x6eb1, 0x73cd, 0x7468, 0x74a1, 0x755b, 0x75b9, 0x76e1, 0x771e,
+ 0x778b, 0x79e6, 0x7e09, 0x7e1d, 0x81fb, 0x852f, 0x8897, 0x8a3a,
+ 0x8cd1, 0x8eeb, 0x8fb0, 0x9032, 0x93ad, 0x9663, 0x9673, 0x9707,
+ 0x4f84, 0x53f1, 0x59ea, 0x5ac9, 0x5e19, 0x684e, 0x74c6, 0x75be,
+ 0x79e9, 0x7a92, 0x81a3, 0x86ed, 0x8cea, 0x8dcc, 0x8fed, 0x659f,
+ 0x6715, 0xf9fd, 0x57f7, 0x6f57, 0x7ddd, 0x8f2f,
+ /* 0x73 */
+ 0x93f6, 0x96c6, 0x5fb5, 0x61f2, 0x6f84, 0x4e14, 0x4f98, 0x501f,
+ 0x53c9, 0x55df, 0x5d6f, 0x5dee, 0x6b21, 0x6b64, 0x78cb, 0x7b9a,
+ 0xf9fe, 0x8e49, 0x8eca, 0x906e, 0x6349, 0x643e, 0x7740, 0x7a84,
+ 0x932f, 0x947f, 0x9f6a, 0x64b0, 0x6faf, 0x71e6, 0x74a8, 0x74da,
+ 0x7ac4, 0x7c12, 0x7e82, 0x7cb2, 0x7e98, 0x8b9a, 0x8d0a, 0x947d,
+ 0x9910, 0x994c, 0x5239, 0x5bdf, 0x64e6, 0x672d, 0x7d2e, 0x50ed,
+ 0x53c3, 0x5879, 0x6158, 0x6159, 0x61fa, 0x65ac, 0x7ad9, 0x8b92,
+ 0x8b96, 0x5009, 0x5021, 0x5275, 0x5531, 0x5a3c, 0x5ee0, 0x5f70,
+ 0x6134, 0x655e, 0x660c, 0x6636, 0x66a2, 0x69cd, 0x6ec4, 0x6f32,
+ 0x7316, 0x7621, 0x7a93, 0x8139, 0x8259, 0x83d6, 0x84bc, 0x50b5,
+ 0x57f0, 0x5bc0, 0x5be8, 0x5f69, 0x63a1, 0x7826, 0x7db5, 0x83dc,
+ 0x8521, 0x91c7, 0x91f5, 0x518a, 0x67f5, 0x7b56,
+ /* 0x74 */
+ 0x8cac, 0x51c4, 0x59bb, 0x60bd, 0x8655, 0x501c, 0xf9ff, 0x5254,
+ 0x5c3a, 0x617d, 0x621a, 0x62d3, 0x64f2, 0x65a5, 0x6ecc, 0x7620,
+ 0x810a, 0x8e60, 0x965f, 0x96bb, 0x4edf, 0x5343, 0x5598, 0x5929,
+ 0x5ddd, 0x64c5, 0x6cc9, 0x6dfa, 0x7394, 0x7a7f, 0x821b, 0x85a6,
+ 0x8ce4, 0x8e10, 0x9077, 0x91e7, 0x95e1, 0x9621, 0x97c6, 0x51f8,
+ 0x54f2, 0x5586, 0x5fb9, 0x64a4, 0x6f88, 0x7db4, 0x8f1f, 0x8f4d,
+ 0x9435, 0x50c9, 0x5c16, 0x6cbe, 0x6dfb, 0x751b, 0x77bb, 0x7c3d,
+ 0x7c64, 0x8a79, 0x8ac2, 0x581e, 0x59be, 0x5e16, 0x6377, 0x7252,
+ 0x758a, 0x776b, 0x8adc, 0x8cbc, 0x8f12, 0x5ef3, 0x6674, 0x6df8,
+ 0x807d, 0x83c1, 0x8acb, 0x9751, 0x9bd6, 0xfa00, 0x5243, 0x66ff,
+ 0x6d95, 0x6eef, 0x7de0, 0x8ae6, 0x902e, 0x905e, 0x9ad4, 0x521d,
+ 0x527f, 0x54e8, 0x6194, 0x6284, 0x62db, 0x68a2,
+ /* 0x75 */
+ 0x6912, 0x695a, 0x6a35, 0x7092, 0x7126, 0x785d, 0x7901, 0x790e,
+ 0x79d2, 0x7a0d, 0x8096, 0x8278, 0x82d5, 0x8349, 0x8549, 0x8c82,
+ 0x8d85, 0x9162, 0x918b, 0x91ae, 0x4fc3, 0x56d1, 0x71ed, 0x77d7,
+ 0x8700, 0x89f8, 0x5bf8, 0x5fd6, 0x6751, 0x90a8, 0x53e2, 0x585a,
+ 0x5bf5, 0x60a4, 0x6181, 0x6460, 0x7e3d, 0x8070, 0x8525, 0x9283,
+ 0x64ae, 0x50ac, 0x5d14, 0x6700, 0x589c, 0x62bd, 0x63a8, 0x690e,
+ 0x6978, 0x6a1e, 0x6e6b, 0x76ba, 0x79cb, 0x82bb, 0x8429, 0x8acf,
+ 0x8da8, 0x8ffd, 0x9112, 0x914b, 0x919c, 0x9310, 0x9318, 0x939a,
+ 0x96db, 0x9a36, 0x9c0d, 0x4e11, 0x755c, 0x795d, 0x7afa, 0x7b51,
+ 0x7bc9, 0x7e2e, 0x84c4, 0x8e59, 0x8e74, 0x8ef8, 0x9010, 0x6625,
+ 0x693f, 0x7443, 0x51fa, 0x672e, 0x9edc, 0x5145, 0x5fe0, 0x6c96,
+ 0x87f2, 0x885d, 0x8877, 0x60b4, 0x81b5, 0x8403,
+ /* 0x76 */
+ 0x8d05, 0x53d6, 0x5439, 0x5634, 0x5a36, 0x5c31, 0x708a, 0x7fe0,
+ 0x805a, 0x8106, 0x81ed, 0x8da3, 0x9189, 0x9a5f, 0x9df2, 0x5074,
+ 0x4ec4, 0x53a0, 0x60fb, 0x6e2c, 0x5c64, 0x4f88, 0x5024, 0x55e4,
+ 0x5cd9, 0x5e5f, 0x6065, 0x6894, 0x6cbb, 0x6dc4, 0x71be, 0x75d4,
+ 0x75f4, 0x7661, 0x7a1a, 0x7a49, 0x7dc7, 0x7dfb, 0x7f6e, 0x81f4,
+ 0x86a9, 0x8f1c, 0x96c9, 0x99b3, 0x9f52, 0x5247, 0x52c5, 0x98ed,
+ 0x89aa, 0x4e03, 0x67d2, 0x6f06, 0x4fb5, 0x5be2, 0x6795, 0x6c88,
+ 0x6d78, 0x741b, 0x7827, 0x91dd, 0x937c, 0x87c4, 0x79e4, 0x7a31,
+ 0x5feb, 0x4ed6, 0x54a4, 0x553e, 0x58ae, 0x59a5, 0x60f0, 0x6253,
+ 0x62d6, 0x6736, 0x6955, 0x8235, 0x9640, 0x99b1, 0x99dd, 0x502c,
+ 0x5353, 0x5544, 0x577c, 0xfa01, 0x6258, 0xfa02, 0x64e2, 0x666b,
+ 0x67dd, 0x6fc1, 0x6fef, 0x7422, 0x7438, 0x8a17,
+ /* 0x77 */
+ 0x9438, 0x5451, 0x5606, 0x5766, 0x5f48, 0x619a, 0x6b4e, 0x7058,
+ 0x70ad, 0x7dbb, 0x8a95, 0x596a, 0x812b, 0x63a2, 0x7708, 0x803d,
+ 0x8caa, 0x5854, 0x642d, 0x69bb, 0x5b95, 0x5e11, 0x6e6f, 0xfa03,
+ 0x8569, 0x514c, 0x53f0, 0x592a, 0x6020, 0x614b, 0x6b86, 0x6c70,
+ 0x6cf0, 0x7b1e, 0x80ce, 0x82d4, 0x8dc6, 0x90b0, 0x98b1, 0xfa04,
+ 0x64c7, 0x6fa4, 0x6491, 0x6504, 0x514e, 0x5410, 0x571f, 0x8a0e,
+ 0x615f, 0x6876, 0xfa05, 0x75db, 0x7b52, 0x7d71, 0x901a, 0x5806,
+ 0x69cc, 0x817f, 0x892a, 0x9000, 0x9839, 0x5078, 0x5957, 0x59ac,
+ 0x6295, 0x900f, 0x9b2a, 0x615d, 0x7279, 0x95d6, 0x5761, 0x5a46,
+ 0x5df4, 0x628a, 0x64ad, 0x64fa, 0x6777, 0x6ce2, 0x6d3e, 0x722c,
+ 0x7436, 0x7834, 0x7f77, 0x82ad, 0x8ddb, 0x9817, 0x5224, 0x5742,
+ 0x677f, 0x7248, 0x74e3, 0x8ca9, 0x8fa6, 0x9211,
+ /* 0x78 */
+ 0x962a, 0x516b, 0x53ed, 0x634c, 0x4f69, 0x5504, 0x6096, 0x6557,
+ 0x6c9b, 0x6d7f, 0x724c, 0x72fd, 0x7a17, 0x8987, 0x8c9d, 0x5f6d,
+ 0x6f8e, 0x70f9, 0x81a8, 0x610e, 0x4fbf, 0x504f, 0x6241, 0x7247,
+ 0x7bc7, 0x7de8, 0x7fe9, 0x904d, 0x97ad, 0x9a19, 0x8cb6, 0x576a,
+ 0x5e73, 0x67b0, 0x840d, 0x8a55, 0x5420, 0x5b16, 0x5e63, 0x5ee2,
+ 0x5f0a, 0x6583, 0x80ba, 0x853d, 0x9589, 0x965b, 0x4f48, 0x5305,
+ 0x530d, 0x530f, 0x5486, 0x54fa, 0x5703, 0x5e03, 0x6016, 0x629b,
+ 0x62b1, 0x6355, 0xfa06, 0x6ce1, 0x6d66, 0x75b1, 0x7832, 0x80de,
+ 0x812f, 0x82de, 0x8461, 0x84b2, 0x888d, 0x8912, 0x900b, 0x92ea,
+ 0x98fd, 0x9b91, 0x5e45, 0x66b4, 0x66dd, 0x7011, 0x7206, 0xfa07,
+ 0x4ff5, 0x527d, 0x5f6a, 0x6153, 0x6753, 0x6a19, 0x6f02, 0x74e2,
+ 0x7968, 0x8868, 0x8c79, 0x98c7, 0x98c4, 0x9a43,
+ /* 0x79 */
+ 0x54c1, 0x7a1f, 0x6953, 0x8af7, 0x8c4a, 0x98a8, 0x99ae, 0x5f7c,
+ 0x62ab, 0x75b2, 0x76ae, 0x88ab, 0x907f, 0x9642, 0x5339, 0x5f3c,
+ 0x5fc5, 0x6ccc, 0x73cc, 0x7562, 0x758b, 0x7b46, 0x82fe, 0x999d,
+ 0x4e4f, 0x903c, 0x4e0b, 0x4f55, 0x53a6, 0x590f, 0x5ec8, 0x6630,
+ 0x6cb3, 0x7455, 0x8377, 0x8766, 0x8cc0, 0x9050, 0x971e, 0x9c15,
+ 0x58d1, 0x5b78, 0x8650, 0x8b14, 0x9db4, 0x5bd2, 0x6068, 0x608d,
+ 0x65f1, 0x6c57, 0x6f22, 0x6fa3, 0x701a, 0x7f55, 0x7ff0, 0x9591,
+ 0x9592, 0x9650, 0x97d3, 0x5272, 0x8f44, 0x51fd, 0x542b, 0x54b8,
+ 0x5563, 0x558a, 0x6abb, 0x6db5, 0x7dd8, 0x8266, 0x929c, 0x9677,
+ 0x9e79, 0x5408, 0x54c8, 0x76d2, 0x86e4, 0x95a4, 0x95d4, 0x965c,
+ 0x4ea2, 0x4f09, 0x59ee, 0x5ae6, 0x5df7, 0x6052, 0x6297, 0x676d,
+ 0x6841, 0x6c86, 0x6e2f, 0x7f38, 0x809b, 0x822a,
+ /* 0x7a */
+ 0xfa08, 0xfa09, 0x9805, 0x4ea5, 0x5055, 0x54b3, 0x5793, 0x595a,
+ 0x5b69, 0x5bb3, 0x61c8, 0x6977, 0x6d77, 0x7023, 0x87f9, 0x89e3,
+ 0x8a72, 0x8ae7, 0x9082, 0x99ed, 0x9ab8, 0x52be, 0x6838, 0x5016,
+ 0x5e78, 0x674f, 0x8347, 0x884c, 0x4eab, 0x5411, 0x56ae, 0x73e6,
+ 0x9115, 0x97ff, 0x9909, 0x9957, 0x9999, 0x5653, 0x589f, 0x865b,
+ 0x8a31, 0x61b2, 0x6af6, 0x737b, 0x8ed2, 0x6b47, 0x96aa, 0x9a57,
+ 0x5955, 0x7200, 0x8d6b, 0x9769, 0x4fd4, 0x5cf4, 0x5f26, 0x61f8,
+ 0x665b, 0x6ceb, 0x70ab, 0x7384, 0x73b9, 0x73fe, 0x7729, 0x774d,
+ 0x7d43, 0x7d62, 0x7e23, 0x8237, 0x8852, 0xfa0a, 0x8ce2, 0x9249,
+ 0x986f, 0x5b51, 0x7a74, 0x8840, 0x9801, 0x5acc, 0x4fe0, 0x5354,
+ 0x593e, 0x5cfd, 0x633e, 0x6d79, 0x72f9, 0x8105, 0x8107, 0x83a2,
+ 0x92cf, 0x9830, 0x4ea8, 0x5144, 0x5211, 0x578b,
+ /* 0x7b */
+ 0x5f62, 0x6cc2, 0x6ece, 0x7005, 0x7050, 0x70af, 0x7192, 0x73e9,
+ 0x7469, 0x834a, 0x87a2, 0x8861, 0x9008, 0x90a2, 0x93a3, 0x99a8,
+ 0x516e, 0x5f57, 0x60e0, 0x6167, 0x66b3, 0x8559, 0x8e4a, 0x91af,
+ 0x978b, 0x4e4e, 0x4e92, 0x547c, 0x58d5, 0x58fa, 0x597d, 0x5cb5,
+ 0x5f27, 0x6236, 0x6248, 0x660a, 0x6667, 0x6beb, 0x6d69, 0x6dcf,
+ 0x6e56, 0x6ef8, 0x6f94, 0x6fe0, 0x6fe9, 0x705d, 0x72d0, 0x7425,
+ 0x745a, 0x74e0, 0x7693, 0x795c, 0x7cca, 0x7e1e, 0x80e1, 0x82a6,
+ 0x846b, 0x84bf, 0x864e, 0x865f, 0x8774, 0x8b77, 0x8c6a, 0x93ac,
+ 0x9800, 0x9865, 0x60d1, 0x6216, 0x9177, 0x5a5a, 0x660f, 0x6df7,
+ 0x6e3e, 0x743f, 0x9b42, 0x5ffd, 0x60da, 0x7b0f, 0x54c4, 0x5f18,
+ 0x6c5e, 0x6cd3, 0x6d2a, 0x70d8, 0x7d05, 0x8679, 0x8a0c, 0x9d3b,
+ 0x5316, 0x548c, 0x5b05, 0x6a3a, 0x706b, 0x7575,
+ /* 0x7c */
+ 0x798d, 0x79be, 0x82b1, 0x83ef, 0x8a71, 0x8b41, 0x8ca8, 0x9774,
+ 0xfa0b, 0x64f4, 0x652b, 0x78ba, 0x78bb, 0x7a6b, 0x4e38, 0x559a,
+ 0x5950, 0x5ba6, 0x5e7b, 0x60a3, 0x63db, 0x6b61, 0x6665, 0x6853,
+ 0x6e19, 0x7165, 0x74b0, 0x7d08, 0x9084, 0x9a69, 0x9c25, 0x6d3b,
+ 0x6ed1, 0x733e, 0x8c41, 0x95ca, 0x51f0, 0x5e4c, 0x5fa8, 0x604d,
+ 0x60f6, 0x6130, 0x614c, 0x6643, 0x6644, 0x69a5, 0x6cc1, 0x6e5f,
+ 0x6ec9, 0x6f62, 0x714c, 0x749c, 0x7687, 0x7bc1, 0x7c27, 0x8352,
+ 0x8757, 0x9051, 0x968d, 0x9ec3, 0x532f, 0x56de, 0x5efb, 0x5f8a,
+ 0x6062, 0x6094, 0x61f7, 0x6666, 0x6703, 0x6a9c, 0x6dee, 0x6fae,
+ 0x7070, 0x736a, 0x7e6a, 0x81be, 0x8334, 0x86d4, 0x8aa8, 0x8cc4,
+ 0x5283, 0x7372, 0x5b96, 0x6a6b, 0x9404, 0x54ee, 0x5686, 0x5b5d,
+ 0x6548, 0x6585, 0x66c9, 0x689f, 0x6d8d, 0x6dc6,
+ /* 0x7d */
+ 0x723b, 0x80b4, 0x9175, 0x9a4d, 0x4faf, 0x5019, 0x539a, 0x540e,
+ 0x543c, 0x5589, 0x55c5, 0x5e3f, 0x5f8c, 0x673d, 0x7166, 0x73dd,
+ 0x9005, 0x52db, 0x52f3, 0x5864, 0x58ce, 0x7104, 0x718f, 0x71fb,
+ 0x85b0, 0x8a13, 0x6688, 0x85a8, 0x55a7, 0x6684, 0x714a, 0x8431,
+ 0x5349, 0x5599, 0x6bc1, 0x5f59, 0x5fbd, 0x63ee, 0x6689, 0x7147,
+ 0x8af1, 0x8f1d, 0x9ebe, 0x4f11, 0x643a, 0x70cb, 0x7566, 0x8667,
+ 0x6064, 0x8b4e, 0x9df8, 0x5147, 0x51f6, 0x5308, 0x6d36, 0x80f8,
+ 0x9ed1, 0x6615, 0x6b23, 0x7098, 0x75d5, 0x5403, 0x5c79, 0x7d07,
+ 0x8a16, 0x6b20, 0x6b3d, 0x6b46, 0x5438, 0x6070, 0x6d3d, 0x7fd5,
+ 0x8208, 0x50d6, 0x51de, 0x559c, 0x566b, 0x56cd, 0x59ec, 0x5b09,
+ 0x5e0c, 0x6199, 0x6198, 0x6231, 0x665e, 0x66e6, 0x7199, 0x71b9,
+ 0x71ba, 0x72a7, 0x79a7, 0x7a00, 0x7fb2, 0x8a70,
+};
+
+static int
+ksc5601_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c1 = (s[0] & 0x7F);
+ if ((c1 >= 0x21 && c1 <= 0x2c) || (c1 >= 0x30 && c1 <= 0x48) || (c1 >= 0x4a && c1 <= 0x7d)) {
+ if (n >= 2) {
+ unsigned char c2 = (s[1] & 0x7F);
+ if (c2 >= 0x21 && c2 < 0x7f) {
+ unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21);
+ unsigned short wc = 0xfffd;
+ if (i < 1410) {
+ if (i < 1115)
+ wc = ksc5601_2uni_page21[i];
+ } else if (i < 3854) {
+ if (i < 3760)
+ wc = ksc5601_2uni_page30[i-1410];
+ } else {
+ if (i < 8742)
+ wc = ksc5601_2uni_page4a[i-3854];
+ }
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 2;
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOFEW(0);
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned short ksc5601_2charset[8224] = {
+ 0x222e, 0x2234, 0x2157, 0x2127, 0x2823, 0x2129, 0x2146, 0x213e,
+ 0x2977, 0x2978, 0x2225, 0x2252, 0x2124, 0x222c, 0x2976, 0x282c,
+ 0x2879, 0x2876, 0x287a, 0x222f, 0x2821, 0x2822, 0x213f, 0x282a,
+ 0x282d, 0x292c, 0x2921, 0x2923, 0x2140, 0x292a, 0x292d, 0x2922,
+ 0x2824, 0x2924, 0x2925, 0x2826, 0x2926, 0x2927, 0x2828, 0x2928,
+ 0x2829, 0x2929, 0x2930, 0x282f, 0x292f, 0x282b, 0x292b, 0x282e,
+ 0x292e, 0x2227, 0x2230, 0x2228, 0x222b, 0x222a, 0x222d, 0x2229,
+ 0x2541, 0x2542, 0x2543, 0x2544, 0x2545, 0x2546, 0x2547, 0x2548,
+ 0x2549, 0x254a, 0x254b, 0x254c, 0x254d, 0x254e, 0x254f, 0x2550,
+ 0x2551, 0x2552, 0x2553, 0x2554, 0x2555, 0x2556, 0x2557, 0x2558,
+ 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567, 0x2568,
+ 0x2569, 0x256a, 0x256b, 0x256c, 0x256d, 0x256e, 0x256f, 0x2570,
+ 0x2571, 0x2572, 0x2573, 0x2574, 0x2575, 0x2576, 0x2577, 0x2578,
+ 0x2c27, 0x2c21, 0x2c22, 0x2c23, 0x2c24, 0x2c25, 0x2c26, 0x2c28,
+ 0x2c29, 0x2c2a, 0x2c2b, 0x2c2c, 0x2c2d, 0x2c2e, 0x2c2f, 0x2c30,
+ 0x2c31, 0x2c32, 0x2c33, 0x2c34, 0x2c35, 0x2c36, 0x2c37, 0x2c38,
+ 0x2c39, 0x2c3a, 0x2c3b, 0x2c3c, 0x2c3d, 0x2c3e, 0x2c3f, 0x2c40,
+ 0x2c41, 0x2c51, 0x2c52, 0x2c53, 0x2c54, 0x2c55, 0x2c56, 0x2c58,
+ 0x2c59, 0x2c5a, 0x2c5b, 0x2c5c, 0x2c5d, 0x2c5e, 0x2c5f, 0x2c60,
+ 0x2c61, 0x2c62, 0x2c63, 0x2c64, 0x2c65, 0x2c66, 0x2c67, 0x2c68,
+ 0x2c69, 0x2c6a, 0x2c6b, 0x2c6c, 0x2c6d, 0x2c6e, 0x2c6f, 0x2c70,
+ 0x2c71, 0x2c57, 0x212a, 0x212e, 0x212f, 0x2130, 0x2131, 0x2253,
+ 0x2254, 0x2125, 0x2126, 0x2236, 0x2147, 0x2148, 0x2158, 0x2979,
+ 0x297a, 0x297b, 0x297c, 0x297d, 0x297e, 0x2149, 0x2235, 0x2724,
+ 0x2260, 0x2265, 0x2262, 0x2759, 0x214a, 0x2877, 0x2878, 0x287b,
+ 0x287c, 0x287d, 0x287e, 0x2530, 0x2531, 0x2532, 0x2533, 0x2534,
+ 0x2535, 0x2536, 0x2537, 0x2538, 0x2539, 0x2521, 0x2522, 0x2523,
+ 0x2524, 0x2525, 0x2526, 0x2527, 0x2528, 0x2529, 0x252a, 0x2167,
+ 0x2168, 0x2166, 0x2169, 0x216a, 0x2255, 0x2258, 0x2256, 0x2259,
+ 0x2257, 0x2221, 0x2222, 0x2223, 0x2153, 0x2224, 0x2154, 0x2174,
+ 0x2175, 0x2233, 0x2232, 0x216e, 0x2170, 0x2144, 0x2150, 0x212b,
+ 0x217c, 0x217d, 0x217b, 0x217a, 0x2172, 0x2173, 0x2231, 0x2145,
+ 0x2171, 0x212d, 0x216f, 0x2156, 0x2141, 0x2155, 0x2142, 0x2143,
+ 0x216c, 0x216d, 0x2178, 0x2179, 0x2176, 0x2177, 0x2241, 0x2151,
+ 0x2152, 0x2867, 0x2868, 0x2869, 0x286a, 0x286b, 0x286c, 0x286d,
+ 0x286e, 0x286f, 0x2870, 0x2871, 0x2872, 0x2873, 0x2874, 0x2875,
+ 0x2967, 0x2968, 0x2969, 0x296a, 0x296b, 0x296c, 0x296d, 0x296e,
+ 0x296f, 0x2970, 0x2971, 0x2972, 0x2973, 0x2974, 0x2975, 0x294d,
+ 0x294e, 0x294f, 0x2950, 0x2951, 0x2952, 0x2953, 0x2954, 0x2955,
+ 0x2956, 0x2957, 0x2958, 0x2959, 0x295a, 0x295b, 0x295c, 0x295d,
+ 0x295e, 0x295f, 0x2960, 0x2961, 0x2962, 0x2963, 0x2964, 0x2965,
+ 0x2966, 0x284d, 0x284e, 0x284f, 0x2850, 0x2851, 0x2852, 0x2853,
+ 0x2854, 0x2855, 0x2856, 0x2857, 0x2858, 0x2859, 0x285a, 0x285b,
+ 0x285c, 0x285d, 0x285e, 0x285f, 0x2860, 0x2861, 0x2862, 0x2863,
+ 0x2864, 0x2865, 0x2866, 0x2621, 0x262c, 0x2622, 0x262d, 0x2623,
+ 0x2648, 0x2647, 0x262e, 0x2624, 0x2642, 0x2641, 0x262f, 0x2626,
+ 0x2646, 0x2645, 0x2631, 0x2625, 0x2644, 0x2643, 0x2630, 0x2627,
+ 0x263c, 0x2649, 0x264a, 0x2637, 0x264b, 0x264c, 0x2632, 0x2629,
+ 0x263e, 0x264d, 0x264e, 0x2639, 0x264f, 0x2650, 0x2634, 0x2628,
+ 0x2651, 0x2652, 0x2638, 0x263d, 0x2653, 0x2654, 0x2633, 0x262a,
+ 0x2655, 0x2656, 0x263a, 0x263f, 0x2657, 0x2658, 0x2635, 0x262b,
+ 0x2659, 0x265a, 0x263b, 0x265b, 0x265c, 0x2640, 0x265d, 0x265e,
+ 0x265f, 0x2660, 0x2661, 0x2662, 0x2663, 0x2664, 0x2636, 0x2246,
+ 0x2161, 0x2160, 0x2243, 0x2247, 0x2248, 0x224b, 0x224a, 0x2249,
+ 0x224c, 0x2163, 0x2162, 0x223a, 0x2239, 0x2165, 0x2164, 0x2238,
+ 0x2237, 0x215f, 0x215e, 0x2242, 0x215b, 0x215d, 0x215c, 0x2244,
+ 0x2245, 0x215a, 0x2159, 0x224f, 0x224e, 0x2250, 0x2251, 0x214f,
+ 0x214e, 0x223c, 0x223d, 0x2240, 0x223b, 0x223e, 0x223f, 0x224d,
+ 0x225b, 0x225c, 0x225d, 0x225a, 0x2121, 0x2122, 0x2123, 0x2128,
+ 0x2134, 0x2135, 0x2136, 0x2137, 0x2138, 0x2139, 0x213a, 0x213b,
+ 0x213c, 0x213d, 0x216b, 0x2132, 0x2133, 0x2a21, 0x2a22, 0x2a23,
+ 0x2a24, 0x2a25, 0x2a26, 0x2a27, 0x2a28, 0x2a29, 0x2a2a, 0x2a2b,
+ 0x2a2c, 0x2a2d, 0x2a2e, 0x2a2f, 0x2a30, 0x2a31, 0x2a32, 0x2a33,
+ 0x2a34, 0x2a35, 0x2a36, 0x2a37, 0x2a38, 0x2a39, 0x2a3a, 0x2a3b,
+ 0x2a3c, 0x2a3d, 0x2a3e, 0x2a3f, 0x2a40, 0x2a41, 0x2a42, 0x2a43,
+ 0x2a44, 0x2a45, 0x2a46, 0x2a47, 0x2a48, 0x2a49, 0x2a4a, 0x2a4b,
+ 0x2a4c, 0x2a4d, 0x2a4e, 0x2a4f, 0x2a50, 0x2a51, 0x2a52, 0x2a53,
+ 0x2a54, 0x2a55, 0x2a56, 0x2a57, 0x2a58, 0x2a59, 0x2a5a, 0x2a5b,
+ 0x2a5c, 0x2a5d, 0x2a5e, 0x2a5f, 0x2a60, 0x2a61, 0x2a62, 0x2a63,
+ 0x2a64, 0x2a65, 0x2a66, 0x2a67, 0x2a68, 0x2a69, 0x2a6a, 0x2a6b,
+ 0x2a6c, 0x2a6d, 0x2a6e, 0x2a6f, 0x2a70, 0x2a71, 0x2a72, 0x2a73,
+ 0x2b21, 0x2b22, 0x2b23, 0x2b24, 0x2b25, 0x2b26, 0x2b27, 0x2b28,
+ 0x2b29, 0x2b2a, 0x2b2b, 0x2b2c, 0x2b2d, 0x2b2e, 0x2b2f, 0x2b30,
+ 0x2b31, 0x2b32, 0x2b33, 0x2b34, 0x2b35, 0x2b36, 0x2b37, 0x2b38,
+ 0x2b39, 0x2b3a, 0x2b3b, 0x2b3c, 0x2b3d, 0x2b3e, 0x2b3f, 0x2b40,
+ 0x2b41, 0x2b42, 0x2b43, 0x2b44, 0x2b45, 0x2b46, 0x2b47, 0x2b48,
+ 0x2b49, 0x2b4a, 0x2b4b, 0x2b4c, 0x2b4d, 0x2b4e, 0x2b4f, 0x2b50,
+ 0x2b51, 0x2b52, 0x2b53, 0x2b54, 0x2b55, 0x2b56, 0x2b57, 0x2b58,
+ 0x2b59, 0x2b5a, 0x2b5b, 0x2b5c, 0x2b5d, 0x2b5e, 0x2b5f, 0x2b60,
+ 0x2b61, 0x2b62, 0x2b63, 0x2b64, 0x2b65, 0x2b66, 0x2b67, 0x2b68,
+ 0x2b69, 0x2b6a, 0x2b6b, 0x2b6c, 0x2b6d, 0x2b6e, 0x2b6f, 0x2b70,
+ 0x2b71, 0x2b72, 0x2b73, 0x2b74, 0x2b75, 0x2b76, 0x2421, 0x2422,
+ 0x2423, 0x2424, 0x2425, 0x2426, 0x2427, 0x2428, 0x2429, 0x242a,
+ 0x242b, 0x242c, 0x242d, 0x242e, 0x242f, 0x2430, 0x2431, 0x2432,
+ 0x2433, 0x2434, 0x2435, 0x2436, 0x2437, 0x2438, 0x2439, 0x243a,
+ 0x243b, 0x243c, 0x243d, 0x243e, 0x243f, 0x2440, 0x2441, 0x2442,
+ 0x2443, 0x2444, 0x2445, 0x2446, 0x2447, 0x2448, 0x2449, 0x244a,
+ 0x244b, 0x244c, 0x244d, 0x244e, 0x244f, 0x2450, 0x2451, 0x2452,
+ 0x2453, 0x2454, 0x2455, 0x2456, 0x2457, 0x2458, 0x2459, 0x245a,
+ 0x245b, 0x245c, 0x245d, 0x245e, 0x245f, 0x2460, 0x2461, 0x2462,
+ 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, 0x2468, 0x2469, 0x246a,
+ 0x246b, 0x246c, 0x246d, 0x246e, 0x246f, 0x2470, 0x2471, 0x2472,
+ 0x2473, 0x2474, 0x2475, 0x2476, 0x2477, 0x2478, 0x2479, 0x247a,
+ 0x247b, 0x247c, 0x247d, 0x247e, 0x2931, 0x2932, 0x2933, 0x2934,
+ 0x2935, 0x2936, 0x2937, 0x2938, 0x2939, 0x293a, 0x293b, 0x293c,
+ 0x293d, 0x293e, 0x293f, 0x2940, 0x2941, 0x2942, 0x2943, 0x2944,
+ 0x2945, 0x2946, 0x2947, 0x2948, 0x2949, 0x294a, 0x294b, 0x294c,
+ 0x225f, 0x2831, 0x2832, 0x2833, 0x2834, 0x2835, 0x2836, 0x2837,
+ 0x2838, 0x2839, 0x283a, 0x283b, 0x283c, 0x283d, 0x283e, 0x283f,
+ 0x2840, 0x2841, 0x2842, 0x2843, 0x2844, 0x2845, 0x2846, 0x2847,
+ 0x2848, 0x2849, 0x284a, 0x284b, 0x284c, 0x225e, 0x2749, 0x274a,
+ 0x274b, 0x274c, 0x274d, 0x273a, 0x273b, 0x275c, 0x275d, 0x275e,
+ 0x2736, 0x2737, 0x2738, 0x2754, 0x2755, 0x2756, 0x2757, 0x2758,
+ 0x2721, 0x2722, 0x2723, 0x2725, 0x272b, 0x272c, 0x272d, 0x272e,
+ 0x272f, 0x2730, 0x2731, 0x2732, 0x2733, 0x2734, 0x2727, 0x2728,
+ 0x2729, 0x272a, 0x273d, 0x273e, 0x2765, 0x2766, 0x2767, 0x2768,
+ 0x2761, 0x2762, 0x2763, 0x273f, 0x2740, 0x2741, 0x2742, 0x2743,
+ 0x2744, 0x2745, 0x2746, 0x2747, 0x2748, 0x274e, 0x274f, 0x2750,
+ 0x2751, 0x2752, 0x2753, 0x275a, 0x275b, 0x2263, 0x276c, 0x2726,
+ 0x2760, 0x276f, 0x2261, 0x273c, 0x276d, 0x2735, 0x2739, 0x276a,
+ 0x276b, 0x275f, 0x2264, 0x2764, 0x276e, 0x2769, 0x6c69, 0x6f4b,
+ 0x7652, 0x5832, 0x6d5b, 0x5f32, 0x5f3e, 0x793b, 0x5c74, 0x7564,
+ 0x7326, 0x5d60, 0x6126, 0x4e78, 0x5c30, 0x632a, 0x7169, 0x4d7a,
+ 0x7c2f, 0x5321, 0x712b, 0x6751, 0x522c, 0x4e79, 0x717d, 0x5e3f,
+ 0x7b3a, 0x7939, 0x4e52, 0x632b, 0x6b60, 0x4e7a, 0x4b77, 0x6525,
+ 0x4a61, 0x544c, 0x6a61, 0x5c63, 0x5f2d, 0x4b6b, 0x552f, 0x5675,
+ 0x6578, 0x5e40, 0x6c23, 0x694d, 0x6a27, 0x6976, 0x7b3b, 0x6769,
+ 0x6f4c, 0x5066, 0x5e41, 0x642c, 0x584c, 0x7971, 0x4e5f, 0x7a24,
+ 0x6632, 0x7a7b, 0x7a3d, 0x4c48, 0x6f4d, 0x5555, 0x5322, 0x6c51,
+ 0x6427, 0x6c52, 0x7631, 0x4e7b, 0x5051, 0x4b3f, 0x6d24, 0x6d28,
+ 0x5e42, 0x7662, 0x6d5c, 0x5c75, 0x6039, 0x544e, 0x7435, 0x535b,
+ 0x5635, 0x6c24, 0x6466, 0x716a, 0x4b6c, 0x4b40, 0x6c72, 0x506a,
+ 0x7972, 0x6c25, 0x505f, 0x676a, 0x506b, 0x5c51, 0x5b69, 0x7d4c,
+ 0x5b57, 0x5a61, 0x5636, 0x635f, 0x5e43, 0x5e44, 0x4a21, 0x6e6c,
+ 0x5323, 0x6e37, 0x784f, 0x6a48, 0x6e38, 0x712c, 0x7125, 0x694e,
+ 0x793c, 0x6579, 0x6c6a, 0x5d56, 0x6d42, 0x7825, 0x653a, 0x5b58,
+ 0x4a22, 0x514d, 0x6e6d, 0x6c6b, 0x5e45, 0x6360, 0x4a49, 0x7269,
+ 0x554e, 0x7636, 0x4e42, 0x5647, 0x6334, 0x712d, 0x6a62, 0x5742,
+ 0x7327, 0x4d6a, 0x6b6e, 0x5932, 0x7d25, 0x7655, 0x5562, 0x7835,
+ 0x4c75, 0x7535, 0x642d, 0x676b, 0x7155, 0x703b, 0x6935, 0x4c49,
+ 0x7a55, 0x6154, 0x5756, 0x5c41, 0x5e46, 0x7a6f, 0x6361, 0x6173,
+ 0x5c76, 0x4e7c, 0x5b44, 0x7871, 0x5c64, 0x656f, 0x5c31, 0x5556,
+ 0x735a, 0x4b41, 0x5b43, 0x597a, 0x536e, 0x7a38, 0x7d26, 0x6b6f,
+ 0x7426, 0x4c4a, 0x7328, 0x735b, 0x5b27, 0x7637, 0x4f66, 0x7072,
+ 0x4b5a, 0x6752, 0x5743, 0x7670, 0x685e, 0x6526, 0x6567, 0x4a23,
+ 0x4c27, 0x6a49, 0x7836, 0x7a25, 0x712e, 0x6f4e, 0x4b6d, 0x7630,
+ 0x6f4f, 0x694f, 0x775e, 0x4e53, 0x5c77, 0x5b28, 0x4b78, 0x5f21,
+ 0x5d61, 0x754a, 0x6936, 0x676c, 0x6e6e, 0x7370, 0x5f3f, 0x4c4b,
+ 0x5041, 0x7452, 0x603a, 0x5f40, 0x4e60, 0x5c52, 0x7d6a, 0x5676,
+ 0x6a4a, 0x6869, 0x632c, 0x7350, 0x4a24, 0x5b78, 0x5e47, 0x6b70,
+ 0x7156, 0x6562, 0x4c4c, 0x4b7b, 0x6a63, 0x5f41, 0x566d, 0x6950,
+ 0x6e39, 0x5563, 0x5153, 0x6570, 0x6834, 0x6b43, 0x6a2a, 0x7a7c,
+ 0x7576, 0x703c, 0x7d54, 0x603b, 0x4e43, 0x503a, 0x773a, 0x5873,
+ 0x774d, 0x642e, 0x545f, 0x5067, 0x6c7d, 0x522e, 0x6e6f, 0x5557,
+ 0x6a64, 0x7822, 0x4d6b, 0x573f, 0x7b31, 0x4d6c, 0x5c32, 0x506c,
+ 0x4e7d, 0x6e70, 0x4c42, 0x506d, 0x6577, 0x737c, 0x6e22, 0x5933,
+ 0x5874, 0x6937, 0x4e2e, 0x5922, 0x5871, 0x544f, 0x6527, 0x5552,
+ 0x5629, 0x7422, 0x7157, 0x5558, 0x703d, 0x5750, 0x5450, 0x574f,
+ 0x6b6a, 0x7d6b, 0x5b6d, 0x7c45, 0x4b42, 0x7d55, 0x7448, 0x686a,
+ 0x7573, 0x795e, 0x536f, 0x6c53, 0x5d42, 0x6f37, 0x6754, 0x4a4a,
+ 0x597b, 0x7a7d, 0x562a, 0x7478, 0x7777, 0x5c2c, 0x5757, 0x5f22,
+ 0x4e3e, 0x5370, 0x7024, 0x616c, 0x4f67, 0x734b, 0x6d29, 0x4a3e,
+ 0x746f, 0x764e, 0x5e7b, 0x503b, 0x5537, 0x6e71, 0x7428, 0x5c78,
+ 0x4b27, 0x5a4e, 0x6066, 0x6d25, 0x6e72, 0x5c79, 0x795c, 0x735c,
+ 0x7872, 0x7479, 0x7c71, 0x503c, 0x5b79, 0x5731, 0x4b7c, 0x7025,
+ 0x4b7d, 0x5574, 0x4d6d, 0x4a25, 0x562b, 0x5042, 0x703e, 0x523d,
+ 0x4c24, 0x7a36, 0x4c4d, 0x5a7a, 0x764f, 0x6938, 0x5875, 0x4c4e,
+ 0x574d, 0x5451, 0x696d, 0x4a6b, 0x5962, 0x7d32, 0x632d, 0x564c,
+ 0x5934, 0x6127, 0x6e53, 0x5043, 0x7d33, 0x5564, 0x4f68, 0x6d43,
+ 0x5032, 0x4e7e, 0x5a28, 0x7850, 0x7d56, 0x7851, 0x7852, 0x5c53,
+ 0x5d62, 0x7b79, 0x5d41, 0x6335, 0x6d5d, 0x4e44, 0x4b21, 0x5d63,
+ 0x7c5d, 0x792f, 0x527b, 0x4f21, 0x6428, 0x7436, 0x6c7e, 0x632e,
+ 0x676d, 0x7d41, 0x5a62, 0x5833, 0x5d64, 0x706f, 0x7671, 0x7a70,
+ 0x5175, 0x5a4f, 0x5c54, 0x5c26, 0x6f3f, 0x4e4f, 0x6059, 0x5956,
+ 0x6c54, 0x6a4b, 0x4a3f, 0x5530, 0x4f69, 0x716d, 0x4c4f, 0x6478,
+ 0x646d, 0x5758, 0x7d27, 0x6a2b, 0x7632, 0x4f70, 0x793d, 0x6674,
+ 0x4b5b, 0x7351, 0x6951, 0x7329, 0x5060, 0x6952, 0x5a63, 0x6252,
+ 0x7622, 0x6174, 0x5a64, 0x6755, 0x753f, 0x4f22, 0x4d2f, 0x4f23,
+ 0x4d30, 0x717e, 0x5023, 0x612f, 0x7823, 0x4a26, 0x773b, 0x726a,
+ 0x5e48, 0x6953, 0x5e49, 0x7d5e, 0x4a40, 0x796a, 0x514e, 0x6e54,
+ 0x5452, 0x5923, 0x7d28, 0x5759, 0x774e, 0x7a3e, 0x4f56, 0x5770,
+ 0x6b61, 0x7845, 0x5c7a, 0x5d43, 0x795f, 0x676f, 0x7d65, 0x7623,
+ 0x597c, 0x7d29, 0x676e, 0x5565, 0x6f50, 0x4d31, 0x7722, 0x7132,
+ 0x7131, 0x4d32, 0x5a2b, 0x4a27, 0x6362, 0x7b3c, 0x5924, 0x6e3a,
+ 0x7853, 0x7b7a, 0x4f24, 0x5c7b, 0x7663, 0x6d2a, 0x7221, 0x4e61,
+ 0x7a26, 0x7960, 0x6c56, 0x646e, 0x7921, 0x7b6f, 0x796b, 0x6e23,
+ 0x6a2c, 0x4a28, 0x747a, 0x4d56, 0x7c76, 0x7449, 0x7854, 0x7826,
+ 0x5e4a, 0x7246, 0x575a, 0x5350, 0x5845, 0x6a66, 0x735d, 0x645a,
+ 0x7664, 0x7672, 0x5f42, 0x597d, 0x4c76, 0x533a, 0x642f, 0x7961,
+ 0x7026, 0x4b53, 0x603c, 0x744a, 0x547a, 0x7d2a, 0x7962, 0x7437,
+ 0x7d42, 0x7c30, 0x7d6c, 0x4a62, 0x7d3d, 0x6a67, 0x5f43, 0x5152,
+ 0x4e62, 0x5324, 0x7d2b, 0x5f60, 0x7247, 0x6770, 0x506e, 0x732a,
+ 0x5e4b, 0x7638, 0x6175, 0x7133, 0x7723, 0x4a29, 0x4f25, 0x5f44,
+ 0x6130, 0x703f, 0x7624, 0x6336, 0x7a46, 0x506f, 0x7d6d, 0x5d44,
+ 0x7c77, 0x663f, 0x5e2d, 0x7a3f, 0x6571, 0x6d44, 0x5225, 0x7d6e,
+ 0x7536, 0x6176, 0x5e4c, 0x7c5e, 0x6c57, 0x4d5d, 0x5637, 0x4d33,
+ 0x7855, 0x6558, 0x4f6a, 0x4f50, 0x6a4c, 0x6a2e, 0x6a2d, 0x5371,
+ 0x5325, 0x774f, 0x6e24, 0x5024, 0x7222, 0x5070, 0x7223, 0x7778,
+ 0x5033, 0x5b29, 0x533b, 0x4a6c, 0x7126, 0x4b55, 0x7767, 0x4d5e,
+ 0x7724, 0x7840, 0x535d, 0x4c50, 0x4f26, 0x7673, 0x6177, 0x535c,
+ 0x7a7e, 0x7a27, 0x6b59, 0x4f27, 0x6a2f, 0x646f, 0x6939, 0x7158,
+ 0x5858, 0x6072, 0x6634, 0x5c7c, 0x7371, 0x6350, 0x727b, 0x5b46,
+ 0x5071, 0x5072, 0x4f5c, 0x5351, 0x4c31, 0x7758, 0x4b28, 0x6b3c,
+ 0x643e, 0x745c, 0x5c42, 0x7027, 0x6640, 0x4a6d, 0x686b, 0x6568,
+ 0x5c43, 0x6d5e, 0x5372, 0x4c77, 0x4e54, 0x672b, 0x4b43, 0x6131,
+ 0x7732, 0x5373, 0x5352, 0x7540, 0x5f5d, 0x6e73, 0x6771, 0x7d34,
+ 0x7248, 0x7352, 0x6e74, 0x6253, 0x4c51, 0x5f6a, 0x693a, 0x5957,
+ 0x754d, 0x7172, 0x7a47, 0x5978, 0x5442, 0x7665, 0x5d45, 0x6772,
+ 0x6d5f, 0x4a4b, 0x5b7a, 0x6835, 0x5326, 0x7d35, 0x7949, 0x6462,
+ 0x7b3d, 0x5724, 0x4e45, 0x4e55, 0x5666, 0x653d, 0x5e4d, 0x6c73,
+ 0x6d60, 0x6c6c, 0x7b3e, 0x5f6b, 0x6178, 0x793e, 0x5073, 0x602a,
+ 0x6862, 0x6254, 0x527d, 0x6528, 0x5953, 0x535e, 0x7438, 0x773c,
+ 0x5c7d, 0x686c, 0x6467, 0x6377, 0x6c28, 0x7a71, 0x6572, 0x5074,
+ 0x522f, 0x5c65, 0x5025, 0x7134, 0x7c31, 0x4c78, 0x5d46, 0x7a51,
+ 0x775f, 0x7a28, 0x6e75, 0x5e4e, 0x6773, 0x772c, 0x6b44, 0x6d61,
+ 0x602b, 0x5d47, 0x5233, 0x523f, 0x4a4c, 0x7b3f, 0x657d, 0x5d65,
+ 0x584d, 0x6c74, 0x5075, 0x686d, 0x5052, 0x5958, 0x7666, 0x5b2a,
+ 0x7760, 0x5859, 0x7423, 0x745d, 0x6f51, 0x5935, 0x6d2b, 0x6337,
+ 0x6e3b, 0x4d34, 0x6073, 0x6a4d, 0x6c75, 0x686e, 0x4b29, 0x712f,
+ 0x4a4d, 0x6c29, 0x726b, 0x7d6f, 0x7973, 0x6641, 0x6c58, 0x6d2c,
+ 0x6a4e, 0x685f, 0x5e4f, 0x5226, 0x6774, 0x5156, 0x6642, 0x6363,
+ 0x6430, 0x5834, 0x7625, 0x735e, 0x5725, 0x7768, 0x6846, 0x7b66,
+ 0x5d66, 0x5c7e, 0x585a, 0x5a2c, 0x6a30, 0x6338, 0x4a2a, 0x6179,
+ 0x6a31, 0x726c, 0x7a6e, 0x6e55, 0x7974, 0x526c, 0x7b7b, 0x7d70,
+ 0x603d, 0x4e63, 0x7846, 0x5e2e, 0x5f45, 0x653e, 0x6d2d, 0x7a6a,
+ 0x4d6e, 0x6d26, 0x6d2e, 0x706d, 0x5d21, 0x6d2f, 0x7c78, 0x586b,
+ 0x4c79, 0x4d35, 0x7a29, 0x615d, 0x6255, 0x6d4f, 0x5d22, 0x794a,
+ 0x6a68, 0x656d, 0x536b, 0x6954, 0x617a, 0x644c, 0x6164, 0x6847,
+ 0x4e5b, 0x5c55, 0x7735, 0x7c73, 0x7073, 0x4e2f, 0x7135, 0x6f52,
+ 0x6848, 0x6b71, 0x4b54, 0x603e, 0x6378, 0x6a69, 0x7c32, 0x6074,
+ 0x4f60, 0x6e25, 0x7a2a, 0x6643, 0x6132, 0x4a2b, 0x6364, 0x693b,
+ 0x6256, 0x7372, 0x6e56, 0x6a32, 0x5076, 0x6c59, 0x5a4b, 0x4f28,
+ 0x5d23, 0x585b, 0x794e, 0x6955, 0x6351, 0x523c, 0x582c, 0x734c,
+ 0x4d7b, 0x7656, 0x6775, 0x686f, 0x6379, 0x523b, 0x7373, 0x637b,
+ 0x5e50, 0x4e30, 0x5677, 0x7159, 0x7541, 0x5c44, 0x753b, 0x5e51,
+ 0x5c66, 0x5e52, 0x6d62, 0x6e76, 0x6a4f, 0x706e, 0x637c, 0x535f,
+ 0x5374, 0x6133, 0x6134, 0x7453, 0x5f46, 0x6956, 0x5b2b, 0x7626,
+ 0x6339, 0x6b45, 0x7429, 0x4d36, 0x5279, 0x5a2d, 0x5263, 0x4f51,
+ 0x4b5c, 0x4c7a, 0x4f5d, 0x6829, 0x633b, 0x633a, 0x605a, 0x6e77,
+ 0x5c33, 0x5375, 0x5726, 0x7635, 0x575b, 0x6155, 0x546a, 0x5f23,
+ 0x7d5f, 0x5077, 0x6d54, 0x4b2a, 0x645b, 0x617b, 0x4b22, 0x5360,
+ 0x643f, 0x7b40, 0x5a3e, 0x644d, 0x5639, 0x6f40, 0x617c, 0x7639,
+ 0x5f47, 0x6431, 0x5c67, 0x5c68, 0x7a56, 0x5376, 0x715a, 0x7a72,
+ 0x627d, 0x554f, 0x5078, 0x4d5f, 0x754b, 0x6470, 0x4b2b, 0x5744,
+ 0x627e, 0x5d5a, 0x5a2e, 0x4a6e, 0x5539, 0x6321, 0x6863, 0x732b,
+ 0x4f29, 0x5377, 0x5471, 0x4e64, 0x6872, 0x6575, 0x672e, 0x563a,
+ 0x5f6c, 0x6440, 0x6864, 0x5835, 0x645c, 0x7439, 0x7136, 0x625e,
+ 0x6135, 0x4d6f, 0x7127, 0x4e65, 0x4b5d, 0x5963, 0x732c, 0x5079,
+ 0x6c2b, 0x5e53, 0x7769, 0x7975, 0x615e, 0x4b6e, 0x633c, 0x7856,
+ 0x5b6e, 0x7d71, 0x7736, 0x745e, 0x726d, 0x5b59, 0x7028, 0x617d,
+ 0x5e54, 0x602c, 0x6d63, 0x5361, 0x5f48, 0x5936, 0x7d2c, 0x6f53,
+ 0x6441, 0x786b, 0x5b2c, 0x7c46, 0x582d, 0x763a, 0x5b5f, 0x5353,
+ 0x7847, 0x4a4e, 0x7841, 0x5234, 0x5c34, 0x7a39, 0x4a4f, 0x7c33,
+ 0x6a6a, 0x6a6b, 0x507a, 0x6d64, 0x5d67, 0x5f49, 0x5f6d, 0x6e3c,
+ 0x6f41, 0x4c52, 0x5d24, 0x5f4a, 0x5378, 0x7128, 0x4d37, 0x6f54,
+ 0x645d, 0x5f6e, 0x4b2c, 0x693c, 0x6a6c, 0x5f4b, 0x793f, 0x562f,
+ 0x5546, 0x4f2a, 0x4e29, 0x5678, 0x7137, 0x6e78, 0x5959, 0x735f,
+ 0x7848, 0x4e46, 0x5566, 0x7466, 0x6645, 0x6f55, 0x4b6f, 0x7c5f,
+ 0x5c27, 0x5667, 0x7849, 0x6352, 0x633d, 0x4f61, 0x7040, 0x6c5a,
+ 0x5d57, 0x7b70, 0x6c2c, 0x7029, 0x7a57, 0x7b41, 0x5240, 0x6530,
+ 0x6d65, 0x4b2d, 0x7930, 0x7725, 0x4b2e, 0x5a2f, 0x5836, 0x5327,
+ 0x7b32, 0x7d44, 0x6c2d, 0x7b21, 0x6569, 0x696e, 0x7374, 0x7873,
+ 0x7041, 0x5e2f, 0x7830, 0x7360, 0x672f, 0x5b2d, 0x6635, 0x7928,
+ 0x5d58, 0x6859, 0x6f56, 0x5362, 0x625f, 0x7c60, 0x5748, 0x7d2d,
+ 0x5f6f, 0x4c53, 0x5379, 0x5470, 0x5b47, 0x5e55, 0x7074, 0x5550,
+ 0x6559, 0x7c47, 0x5c56, 0x6260, 0x5a30, 0x7323, 0x536c, 0x744b,
+ 0x7d45, 0x637d, 0x7931, 0x507b, 0x6c5b, 0x753c, 0x7224, 0x584e,
+ 0x584f, 0x7577, 0x7661, 0x5237, 0x7b6c, 0x5d48, 0x6468, 0x5241,
+ 0x7857, 0x563b, 0x5e56, 0x773d, 0x6c2e, 0x5061, 0x6075, 0x6a33,
+ 0x4e56, 0x4c25, 0x6c76, 0x6261, 0x633e, 0x7c48, 0x4d70, 0x7976,
+ 0x5f70, 0x653f, 0x4e3f, 0x7c61, 0x6d30, 0x7d51, 0x763b, 0x794f,
+ 0x6b5a, 0x4a41, 0x5238, 0x4d71, 0x6353, 0x7d66, 0x666d, 0x637a,
+ 0x702a, 0x7950, 0x7c62, 0x7827, 0x6165, 0x6e79, 0x6776, 0x6a6d,
+ 0x7c34, 0x7542, 0x575c, 0x7075, 0x5d68, 0x536d, 0x757c, 0x5a3f,
+ 0x4c7b, 0x537a, 0x7424, 0x6f57, 0x5443, 0x7b63, 0x7b6d, 0x602d,
+ 0x6a6e, 0x7b33, 0x6442, 0x7667, 0x525d, 0x5f4c, 0x7c49, 0x6529,
+ 0x6076, 0x7633, 0x617e, 0x4b70, 0x6a6f, 0x6a70, 0x5a40, 0x7834,
+ 0x6b72, 0x6443, 0x6957, 0x6471, 0x4a6f, 0x4e57, 0x7c4a, 0x7361,
+ 0x4b44, 0x6365, 0x4b45, 0x6a34, 0x693d, 0x5749, 0x6b5b, 0x6d31,
+ 0x4c43, 0x773e, 0x7c4b, 0x7874, 0x5937, 0x7353, 0x7354, 0x7764,
+ 0x7751, 0x5837, 0x4e31, 0x4a42, 0x7b34, 0x4b46, 0x7076, 0x5567,
+ 0x6a50, 0x4c54, 0x4b2f, 0x742a, 0x692f, 0x7543, 0x6958, 0x5d69,
+ 0x7173, 0x557b, 0x5e3b, 0x747b, 0x7d73, 0x7d72, 0x7726, 0x5d49,
+ 0x5453, 0x4c28, 0x5a41, 0x4c55, 0x5964, 0x7a4a, 0x6563, 0x533c,
+ 0x4a70, 0x5044, 0x4a50, 0x7a2b, 0x6b6b, 0x6778, 0x5965, 0x5157,
+ 0x7324, 0x547b, 0x7c63, 0x7a58, 0x7355, 0x4f2b, 0x6b73, 0x557c,
+ 0x5354, 0x4d7c, 0x5966, 0x6279, 0x6221, 0x6b54, 0x6077, 0x6432,
+ 0x4c7c, 0x7b64, 0x742b, 0x503d, 0x4a71, 0x6f38, 0x5740, 0x6e7a,
+ 0x7d74, 0x5363, 0x7b42, 0x5568, 0x5b2e, 0x6136, 0x7837, 0x603f,
+ 0x7b43, 0x5d6a, 0x6222, 0x6e26, 0x7668, 0x7675, 0x5d4a, 0x5062,
+ 0x5d26, 0x5d6b, 0x6479, 0x632f, 0x507c, 0x747c, 0x4c3c, 0x776a,
+ 0x6564, 0x5f71, 0x7761, 0x7977, 0x6f39, 0x7858, 0x7929, 0x7859,
+ 0x6e3d, 0x5846, 0x6463, 0x754e, 0x5d59, 0x5967, 0x5239, 0x5543,
+ 0x5a65, 0x5a50, 0x5159, 0x4e58, 0x4b5e, 0x742c, 0x5a7b, 0x7669,
+ 0x6873, 0x4f2c, 0x7070, 0x747d, 0x5b48, 0x4e40, 0x6354, 0x514f,
+ 0x7175, 0x4d72, 0x4f6b, 0x4d38, 0x6326, 0x515a, 0x7225, 0x7226,
+ 0x644e, 0x537b, 0x7129, 0x7249, 0x6f58, 0x6649, 0x5838, 0x7a73,
+ 0x7335, 0x7824, 0x5173, 0x6648, 0x785a, 0x5c69, 0x5e57, 0x4b5f,
+ 0x4f6c, 0x745f, 0x5174, 0x523a, 0x5f72, 0x6137, 0x6223, 0x537c,
+ 0x6d66, 0x5b49, 0x647a, 0x4f5e, 0x4e50, 0x5553, 0x7375, 0x772e,
+ 0x6f48, 0x4d73, 0x754f, 0x6573, 0x7042, 0x4a51, 0x6a71, 0x5026,
+ 0x595a, 0x702b, 0x6b67, 0x6540, 0x7c35, 0x6444, 0x4c29, 0x7d46,
+ 0x6a35, 0x652a, 0x5f3a, 0x615f, 0x5a51, 0x6138, 0x6874, 0x537d,
+ 0x6224, 0x724a, 0x5a66, 0x7733, 0x7d4d, 0x7336, 0x6e57, 0x7544,
+ 0x5824, 0x7227, 0x5938, 0x5939, 0x6f49, 0x564e, 0x774b, 0x5f2e,
+ 0x6875, 0x5235, 0x5355, 0x744c, 0x5a7c, 0x5968, 0x776b, 0x7549,
+ 0x733c, 0x5a52, 0x5335, 0x6836, 0x564f, 0x743a, 0x7749, 0x4c2a,
+ 0x7043, 0x4c56, 0x5053, 0x533d, 0x5b7b, 0x4b60, 0x5364, 0x7677,
+ 0x553a, 0x734d, 0x4b61, 0x6b74, 0x742d, 0x7c2a, 0x776c, 0x6876,
+ 0x5a67, 0x774c, 0x6541, 0x606e, 0x557d, 0x4e66, 0x7c2b, 0x553b,
+ 0x7228, 0x6225, 0x4d39, 0x6a72, 0x4b47, 0x4d74, 0x5b2f, 0x6f59,
+ 0x4d3a, 0x7c79, 0x5f73, 0x4e67, 0x5a42, 0x4f2d, 0x6779, 0x7828,
+ 0x7362, 0x4a72, 0x5f24, 0x5444, 0x4c57, 0x6542, 0x4d3b, 0x6f5a,
+ 0x6e58, 0x5d27, 0x6226, 0x6040, 0x5630, 0x784a, 0x7c7a, 0x597e,
+ 0x5e30, 0x5d6c, 0x5a68, 0x5460, 0x5679, 0x4d57, 0x5e58, 0x7278,
+ 0x6456, 0x5045, 0x742e, 0x5d28, 0x6d45, 0x7356, 0x5e59, 0x6366,
+ 0x5328, 0x5b30, 0x655a, 0x633f, 0x5b31, 0x5569, 0x6041, 0x6f5b,
+ 0x7069, 0x5732, 0x507d, 0x5969, 0x507e, 0x6c6d, 0x5329, 0x7229,
+ 0x7044, 0x6262, 0x696f, 0x7951, 0x6959, 0x685a, 0x5a43, 0x5a44,
+ 0x5445, 0x677a, 0x4d60, 0x6330, 0x5b32, 0x7b44, 0x7363, 0x5925,
+ 0x7b67, 0x5d4b, 0x5054, 0x6636, 0x602e, 0x7d5a, 0x5c35, 0x6078,
+ 0x6731, 0x7570, 0x585c, 0x6d46, 0x6139, 0x6340, 0x7940, 0x6970,
+ 0x595b, 0x7364, 0x5c36, 0x6469, 0x7045, 0x6341, 0x7c4c, 0x7c4d,
+ 0x724b, 0x724c, 0x644f, 0x715b, 0x7a59, 0x7138, 0x7d75, 0x6079,
+ 0x677b, 0x7c37, 0x7c64, 0x7b45, 0x6367, 0x5839, 0x7678, 0x5c45,
+ 0x4c58, 0x602f, 0x7467, 0x6f5c, 0x4f7c, 0x6f5d, 0x722a, 0x7d3e,
+ 0x4a2c, 0x7d3b, 0x7d47, 0x6732, 0x6a51, 0x5f74, 0x516c, 0x645e,
+ 0x6543, 0x5926, 0x4d3c, 0x7365, 0x6d55, 0x593a, 0x6d67, 0x7b35,
+ 0x786c, 0x6067, 0x4c59, 0x5446, 0x6725, 0x5575, 0x533e, 0x7c7b,
+ 0x6472, 0x5f75, 0x6878, 0x786d, 0x4e47, 0x7d76, 0x6858, 0x4d58,
+ 0x6756, 0x4c5a, 0x4a63, 0x5f76, 0x7047, 0x7046, 0x583a, 0x7174,
+ 0x7470, 0x754c, 0x7c65, 0x6a45, 0x6a73, 0x5d5b, 0x5c57, 0x5e7d,
+ 0x7279, 0x5547, 0x5850, 0x7048, 0x5121, 0x5122, 0x5954, 0x5668,
+ 0x594a, 0x5a31, 0x5847, 0x5c62, 0x734e, 0x7574, 0x7139, 0x5a53,
+ 0x766a, 0x4f75, 0x7d2e, 0x4a52, 0x5f34, 0x575d, 0x7a3a, 0x6e27,
+ 0x753d, 0x7875, 0x6d68, 0x5461, 0x5123, 0x6156, 0x7978, 0x5b4a,
+ 0x4b79, 0x5454, 0x595c, 0x6e3e, 0x776d, 0x526e, 0x6166, 0x7779,
+ 0x5d6d, 0x685b, 0x5b33, 0x5177, 0x6030, 0x5462, 0x7657, 0x5779,
+ 0x585d, 0x4d7d, 0x722b, 0x4d3d, 0x7842, 0x722c, 0x4a2d, 0x4a2e,
+ 0x4f2e, 0x6342, 0x5c37, 0x5b5a, 0x593b, 0x4a73, 0x7653, 0x6678,
+ 0x6a75, 0x6a76, 0x7679, 0x4f2f, 0x4a53, 0x4a2f, 0x5230, 0x713a,
+ 0x5733, 0x6343, 0x737d, 0x5e5a, 0x5e5b, 0x6f5e, 0x6263, 0x6e7b,
+ 0x5f77, 0x574a, 0x4e68, 0x5b5b, 0x713b, 0x6971, 0x7a37, 0x5046,
+ 0x4c2b, 0x6e28, 0x4b7a, 0x7979, 0x4c7d, 0x537e, 0x6450, 0x726e,
+ 0x5455, 0x5f4d, 0x7c38, 0x5150, 0x724d, 0x7752, 0x4a54, 0x5559,
+ 0x585e, 0x4d59, 0x6e29, 0x763c, 0x4c5b, 0x7049, 0x7c7c, 0x6849,
+ 0x747e, 0x677c, 0x575e, 0x5e5c, 0x702c, 0x4c7e, 0x4d61, 0x613a,
+ 0x5b6f, 0x5a32, 0x5125, 0x5c38, 0x5876, 0x5124, 0x4d62, 0x5c6a,
+ 0x7077, 0x704a, 0x503e, 0x5d5c, 0x5456, 0x5356, 0x6d50, 0x4d21,
+ 0x5f35, 0x5f78, 0x5421, 0x4e32, 0x684a, 0x6b75, 0x6355, 0x7550,
+ 0x7521, 0x5927, 0x652b, 0x664b, 0x7571, 0x6545, 0x7923, 0x605b,
+ 0x766b, 0x4b71, 0x596a, 0x7522, 0x5751, 0x5178, 0x6a78, 0x6a79,
+ 0x5a33, 0x6f5f, 0x716f, 0x6576, 0x6e3f, 0x6264, 0x503f, 0x7a2c,
+ 0x7551, 0x6733, 0x693e, 0x724e, 0x5b34, 0x7c4e, 0x5d6e, 0x6734,
+ 0x5734, 0x7734, 0x4d3e, 0x5a69, 0x4f30, 0x7759, 0x7366, 0x4e59,
+ 0x4e2a, 0x4b48, 0x5027, 0x704b, 0x5047, 0x6445, 0x5b60, 0x555a,
+ 0x5727, 0x6e40, 0x7876, 0x7552, 0x6d69, 0x593c, 0x6546, 0x7523,
+ 0x5a54, 0x6227, 0x7b7c, 0x715c, 0x4a74, 0x687a, 0x4e69, 0x6978,
+ 0x6265, 0x5039, 0x5472, 0x5126, 0x5f4e, 0x7c74, 0x532a, 0x4c2c,
+ 0x6f60, 0x6565, 0x5055, 0x5b7c, 0x7c66, 0x4b7e, 0x6d6a, 0x5e31,
+ 0x7963, 0x5422, 0x4f76, 0x5650, 0x556a, 0x716e, 0x7a4b, 0x6521,
+ 0x5531, 0x4f6d, 0x6d6b, 0x5532, 0x553c, 0x7d62, 0x732d, 0x7d5b,
+ 0x6930, 0x5127, 0x7d63, 0x4e33, 0x7d64, 0x7a4e, 0x4a30, 0x7727,
+ 0x4f31, 0x6622, 0x7c36, 0x722d, 0x6f61, 0x732e, 0x5c46, 0x596b,
+ 0x6860, 0x6128, 0x5576, 0x4f7d, 0x5e5d, 0x5951, 0x646a, 0x724f,
+ 0x773f, 0x6266, 0x6228, 0x6356, 0x6d51, 0x6979, 0x5631, 0x5e32,
+ 0x6068, 0x532b, 0x6b5c, 0x5f2f, 0x4a43, 0x6e7c, 0x7d43, 0x6b76,
+ 0x4f32, 0x596c, 0x593d, 0x585f, 0x5438, 0x6b3e, 0x5d6f, 0x5d70,
+ 0x5d71, 0x5d72, 0x593e, 0x7b46, 0x4f33, 0x6e7d, 0x642b, 0x5a45,
+ 0x586c, 0x5128, 0x6229, 0x5e3c, 0x6735, 0x5b70, 0x6f62, 0x7170,
+ 0x4f34, 0x5b71, 0x6031, 0x5f25, 0x7952, 0x677d, 0x6623, 0x7b71,
+ 0x4b30, 0x722e, 0x4d67, 0x685c, 0x6757, 0x7740, 0x5063, 0x5a21,
+ 0x4c3d, 0x5129, 0x5d4c, 0x637e, 0x512a, 0x682a, 0x6a36, 0x797a,
+ 0x664c, 0x7658, 0x5447, 0x594b, 0x5952, 0x534b, 0x5877, 0x5a29,
+ 0x7578, 0x5e5e, 0x722f, 0x7829, 0x5848, 0x6e41, 0x7941, 0x5d73,
+ 0x6a7a, 0x763d, 0x613b, 0x4d3f, 0x7454, 0x664d, 0x7c4f, 0x7b22,
+ 0x605c, 0x743b, 0x5a55, 0x7932, 0x7b72, 0x5b76, 0x5e5f, 0x5b72,
+ 0x785c, 0x776e, 0x6b68, 0x527a, 0x713c, 0x7a5a, 0x5a6a, 0x5a46,
+ 0x7741, 0x6736, 0x6547, 0x562c, 0x5c47, 0x6129, 0x622a, 0x5526,
+ 0x5457, 0x7250, 0x6a7b, 0x605d, 0x7b73, 0x713d, 0x6267, 0x7d57,
+ 0x4e48, 0x6a37, 0x7c40, 0x7d67, 0x776f, 0x5735, 0x6f3a, 0x715d,
+ 0x5e33, 0x684b, 0x785d, 0x7b47, 0x5548, 0x575f, 0x5d29, 0x6931,
+ 0x7a2d, 0x7659, 0x7a74, 0x782a, 0x666e, 0x4c5c, 0x613c, 0x606f,
+ 0x693f, 0x7c7d, 0x664e, 0x6157, 0x664f, 0x7471, 0x6473, 0x647b,
+ 0x7964, 0x6f63, 0x4f6e, 0x763e, 0x6032, 0x7c7e, 0x512b, 0x577a,
+ 0x7b48, 0x6257, 0x5423, 0x7078, 0x5728, 0x6167, 0x533f, 0x6f64,
+ 0x5745, 0x6b62, 0x7c67, 0x6422, 0x6268, 0x6650, 0x7b68, 0x7468,
+ 0x6574, 0x743c, 0x7455, 0x5f36, 0x7c39, 0x6e42, 0x4a75, 0x6f65,
+ 0x4b62, 0x5424, 0x5e60, 0x5a7d, 0x6446, 0x683e, 0x605e, 0x7634,
+ 0x6a52, 0x797b, 0x6042, 0x4a64, 0x6737, 0x6a7d, 0x595d, 0x5a34,
+ 0x6e2a, 0x7b69, 0x5b4b, 0x5a35, 0x713e, 0x532c, 0x7b49, 0x5f4f,
+ 0x5340, 0x6357, 0x6f66, 0x7c50, 0x6940, 0x7553, 0x6c5c, 0x7737,
+ 0x6a38, 0x5179, 0x5c48, 0x6a39, 0x715e, 0x5736, 0x4f35, 0x5928,
+ 0x6c6e, 0x5d2a, 0x4d22, 0x682e, 0x613d, 0x7251, 0x6941, 0x527c,
+ 0x5b35, 0x7367, 0x587e, 0x7c51, 0x6d32, 0x742f, 0x7b23, 0x7c41,
+ 0x6e2b, 0x5425, 0x7472, 0x6e59, 0x7b4a, 0x4d63, 0x583b, 0x655b,
+ 0x7877, 0x7654, 0x5729, 0x4b49, 0x6651, 0x704c, 0x582e, 0x7953,
+ 0x557e, 0x583c, 0x7230, 0x622b, 0x7368, 0x6f42, 0x6d6c, 0x6738,
+ 0x5a7e, 0x4c3e, 0x727c, 0x5a6b, 0x6258, 0x6d56, 0x5651, 0x6033,
+ 0x7c52, 0x6b48, 0x5341, 0x704d, 0x4f77, 0x6d52, 0x5458, 0x5c49,
+ 0x5771, 0x5f3b, 0x7325, 0x744d, 0x713f, 0x7831, 0x697a, 0x7b4b,
+ 0x4a55, 0x7954, 0x774a, 0x5648, 0x7c68, 0x733d, 0x6e7e, 0x677e,
+ 0x5342, 0x5336, 0x4c2d, 0x767a, 0x5632, 0x5258, 0x6758, 0x6325,
+ 0x6739, 0x702d, 0x7b4c, 0x6b21, 0x5426, 0x7b4d, 0x553d, 0x715f,
+ 0x767b, 0x5e34, 0x556b, 0x6548, 0x7b24, 0x5439, 0x5e61, 0x6423,
+ 0x5737, 0x786e, 0x5e35, 0x5652, 0x7955, 0x673a, 0x6b55, 0x5577,
+ 0x6f67, 0x613e, 0x7a2e, 0x5669, 0x566e, 0x673b, 0x6c4b, 0x5533,
+ 0x4e34, 0x7b25, 0x616e, 0x7728, 0x7b4e, 0x583d, 0x7b7d, 0x7c69,
+ 0x4f36, 0x6d47, 0x6e2c, 0x4c5d, 0x7627, 0x667a, 0x7524, 0x7d5c,
+ 0x6d33, 0x4e49, 0x6f68, 0x613f, 0x7a5b, 0x4b63, 0x7729, 0x7b26,
+ 0x5c39, 0x7140, 0x6d48, 0x6f43, 0x562d, 0x7d4e, 0x6821, 0x7b74,
+ 0x5527, 0x7176, 0x6653, 0x4c5e, 0x7832, 0x5c6b, 0x7d36, 0x656a,
+ 0x7160, 0x5b4c, 0x5d4d, 0x5448, 0x596d, 0x7525, 0x667b, 0x6654,
+ 0x7d48, 0x5621, 0x7d3f, 0x7c53, 0x6f21, 0x673c, 0x516e, 0x6655,
+ 0x6972, 0x5f30, 0x5860, 0x7c3a, 0x7d2f, 0x704e, 0x5b61, 0x6549,
+ 0x6d34, 0x6043, 0x6358, 0x697b, 0x6a28, 0x7d37, 0x7b27, 0x6942,
+ 0x7d77, 0x6259, 0x5c6c, 0x6822, 0x6670, 0x7d78, 0x7d79, 0x763f,
+ 0x6727, 0x6657, 0x5473, 0x5449, 0x567a, 0x5772, 0x6140, 0x5b62,
+ 0x6658, 0x673d, 0x704f, 0x733e, 0x622c, 0x7537, 0x6070, 0x7d38,
+ 0x6368, 0x5427, 0x687c, 0x7a52, 0x786f, 0x5653, 0x5534, 0x7050,
+ 0x7770, 0x6e33, 0x6a3a, 0x6a53, 0x6d49, 0x5d2b, 0x652c, 0x7d21,
+ 0x5f50, 0x6c33, 0x5f51, 0x6d6d, 0x7838, 0x777a, 0x782b, 0x7460,
+ 0x543a, 0x6433, 0x695a, 0x5e36, 0x593f, 0x5940, 0x566f, 0x594c,
+ 0x5a2a, 0x5f65, 0x7765, 0x4c32, 0x5f79, 0x5760, 0x543b, 0x7d7a,
+ 0x4c33, 0x5b73, 0x5f52, 0x4e4a, 0x6e5a, 0x6464, 0x7b4f, 0x4f37,
+ 0x6e43, 0x4e6a, 0x622d, 0x5761, 0x7a75, 0x5549, 0x782c, 0x6759,
+ 0x7369, 0x586d, 0x6344, 0x7071, 0x6865, 0x607a, 0x6e44, 0x595e,
+ 0x6b22, 0x6b23, 0x7c42, 0x6a3b, 0x682b, 0x5e62, 0x6d6f, 0x6823,
+ 0x4f71, 0x543c, 0x7c6a, 0x673e, 0x7c72, 0x5634, 0x622e, 0x5337,
+ 0x7a4c, 0x7a5c, 0x6d35, 0x6163, 0x682c, 0x685d, 0x6f69, 0x743d,
+ 0x4f38, 0x695b, 0x512c, 0x5a47, 0x6b49, 0x684c, 0x5e37, 0x563c,
+ 0x5365, 0x7a5d, 0x5a56, 0x4a31, 0x5a48, 0x5f26, 0x7933, 0x7252,
+ 0x4a44, 0x4e4b, 0x4d75, 0x7d30, 0x5528, 0x7141, 0x6269, 0x5c4a,
+ 0x6c34, 0x7a40, 0x7b28, 0x5028, 0x5a6c, 0x596e, 0x607b, 0x6f6a,
+ 0x7a5e, 0x6044, 0x4f39, 0x554a, 0x5762, 0x622f, 0x5738, 0x684d,
+ 0x765a, 0x6f22, 0x625a, 0x767c, 0x7b50, 0x512d, 0x4d64, 0x512e,
+ 0x5c6d, 0x684e, 0x7079, 0x4e35, 0x667c, 0x577b, 0x5056, 0x5d75,
+ 0x7771, 0x767d, 0x5b77, 0x7b6a, 0x695c, 0x5941, 0x7572, 0x6045,
+ 0x6a54, 0x7942, 0x6a3c, 0x5245, 0x7b51, 0x6740, 0x6b25, 0x5f7a,
+ 0x6322, 0x5739, 0x6943, 0x687d, 0x682f, 0x7253, 0x7b29, 0x5825,
+ 0x554b, 0x5048, 0x512f, 0x5763, 0x6046, 0x5622, 0x6d70, 0x5773,
+ 0x7c54, 0x5a57, 0x4c5f, 0x7254, 0x5130, 0x4c60, 0x5b7d, 0x733f,
+ 0x7051, 0x7c3b, 0x6230, 0x6625, 0x625b, 0x5f5e, 0x6047, 0x726f,
+ 0x4c61, 0x566a, 0x6742, 0x4e36, 0x7340, 0x4d7e, 0x7b52, 0x7878,
+ 0x777b, 0x683f, 0x6837, 0x6d36, 0x5c3a, 0x4c34, 0x7177, 0x6838,
+ 0x4a76, 0x6424, 0x7456, 0x5f66, 0x5f27, 0x5f67, 0x6141, 0x6944,
+ 0x5c4b, 0x6945, 0x6f23, 0x6b26, 0x4b23, 0x6369, 0x517b, 0x6f24,
+ 0x6f6b, 0x5034, 0x4d23, 0x6866, 0x6f25, 0x534c, 0x5a6d, 0x573a,
+ 0x7255, 0x7565, 0x596f, 0x7934, 0x5554, 0x7d4f, 0x5b63, 0x7161,
+ 0x6c36, 0x7b7e, 0x5357, 0x5131, 0x4b31, 0x5132, 0x4b32, 0x7142,
+ 0x7461, 0x7935, 0x6143, 0x6142, 0x6b77, 0x5f28, 0x4b4a, 0x6639,
+ 0x785e, 0x792a, 0x4a77, 0x6d37, 0x5338, 0x7256, 0x5459, 0x6e45,
+ 0x7270, 0x4a32, 0x5c3b, 0x7178, 0x6c37, 0x654a, 0x7640, 0x7d5d,
+ 0x5463, 0x4c62, 0x7754, 0x5765, 0x5343, 0x5826, 0x7641, 0x5d76,
+ 0x4d40, 0x655c, 0x654b, 0x6144, 0x6830, 0x7430, 0x736a, 0x5a6e,
+ 0x573b, 0x6231, 0x572a, 0x567b, 0x645f, 0x4a56, 0x6b28, 0x5b7e,
+ 0x7642, 0x6f3b, 0x547d, 0x6048, 0x6839, 0x6f26, 0x4d24, 0x5474,
+ 0x5b21, 0x5b5c, 0x5b5d, 0x6e5c, 0x4b4b, 0x7c55, 0x4e6b, 0x4d41,
+ 0x7b53, 0x792b, 0x7554, 0x5929, 0x695d, 0x5b4d, 0x5d4e, 0x6743,
+ 0x6c4c, 0x796c, 0x4b4c, 0x607c, 0x5428, 0x6d53, 0x586f, 0x7257,
+ 0x4a78, 0x5a6f, 0x5654, 0x594d, 0x586e, 0x7241, 0x5f53, 0x5a70,
+ 0x626a, 0x607d, 0x5878, 0x772f, 0x5a36, 0x4a57, 0x7258, 0x5879,
+ 0x7a5f, 0x4f6f, 0x5942, 0x7052, 0x6451, 0x7337, 0x7a60, 0x6f6c,
+ 0x6232, 0x543d, 0x594e, 0x7462, 0x5429, 0x4d42, 0x675a, 0x7259,
+ 0x592a, 0x583e, 0x5c2d, 0x626b, 0x567c, 0x4a79, 0x545a, 0x7457,
+ 0x4c21, 0x4f3a, 0x7538, 0x5943, 0x5068, 0x6345, 0x6b78, 0x7231,
+ 0x4f3b, 0x532d, 0x6861, 0x4e6c, 0x6034, 0x5e63, 0x5d77, 0x7232,
+ 0x7376, 0x765b, 0x577e, 0x785f, 0x7772, 0x5029, 0x665a, 0x7526,
+ 0x573c, 0x4c63, 0x665b, 0x5d5d, 0x5133, 0x6f6d, 0x565e, 0x6474,
+ 0x616f, 0x5d78, 0x684f, 0x4a65, 0x5c21, 0x6035, 0x7c2c, 0x7c2d,
+ 0x5827, 0x6d38, 0x5b36, 0x5670, 0x732f, 0x4d25, 0x5a71, 0x5828,
+ 0x4c64, 0x5134, 0x4a58, 0x5a72, 0x7527, 0x7528, 0x6626, 0x556c,
+ 0x5578, 0x5a73, 0x6346, 0x5e64, 0x5e65, 0x5135, 0x5136, 0x5137,
+ 0x7233, 0x695e, 0x7053, 0x7234, 0x7054, 0x4b64, 0x7b54, 0x7566,
+ 0x636a, 0x5e66, 0x5f54, 0x7879, 0x702e, 0x5138, 0x565f, 0x5057,
+ 0x7c21, 0x6f6e, 0x5c58, 0x695f, 0x655d, 0x7d7b, 0x6049, 0x5649,
+ 0x542a, 0x654c, 0x6960, 0x5058, 0x7c22, 0x543e, 0x6233, 0x5e67,
+ 0x5c3c, 0x5236, 0x7555, 0x4e21, 0x7529, 0x5d79, 0x5d7a, 0x7055,
+ 0x765f, 0x725a, 0x646b, 0x7271, 0x6c39, 0x7d7c, 0x612a, 0x4a59,
+ 0x6f6f, 0x752a, 0x6c79, 0x782d, 0x7242, 0x7643, 0x5752, 0x7922,
+ 0x7056, 0x707a, 0x7660, 0x6973, 0x7243, 0x542b, 0x4a33, 0x4d26,
+ 0x4d43, 0x4d5a, 0x594f, 0x7644, 0x6e5d, 0x6744, 0x6234, 0x5f62,
+ 0x675b, 0x6831, 0x7c2e, 0x654d, 0x7a6b, 0x4f3c, 0x4f62, 0x4d76,
+ 0x6f70, 0x743e, 0x544d, 0x7338, 0x6921, 0x7272, 0x736b, 0x7057,
+ 0x4f57, 0x4f5f, 0x6840, 0x6841, 0x4f63, 0x6922, 0x502a, 0x7341,
+ 0x502b, 0x5464, 0x6f3c, 0x5821, 0x595f, 0x7357, 0x5c3d, 0x4c65,
+ 0x6d71, 0x7162, 0x545b, 0x6235, 0x4a66, 0x532e, 0x4c66, 0x7153,
+ 0x7567, 0x4a5a, 0x7b6e, 0x6145, 0x5f69, 0x6e5e, 0x7742, 0x5822,
+ 0x5d2c, 0x702f, 0x563d, 0x612b, 0x7936, 0x5475, 0x5049, 0x6f27,
+ 0x626c, 0x5b6a, 0x4e4c, 0x7568, 0x7755, 0x534d, 0x737e, 0x5035,
+ 0x607e, 0x5f7b, 0x665d, 0x6824, 0x4b4d, 0x6f28, 0x6e34, 0x5a58,
+ 0x5139, 0x5f29, 0x7330, 0x4c44, 0x4e37, 0x6f29, 0x5f55, 0x6d57,
+ 0x6e46, 0x6f3d, 0x7c56, 0x5b74, 0x6f2a, 0x7839, 0x7569, 0x6359,
+ 0x6146, 0x543f, 0x5e68, 0x706a, 0x7342, 0x532f, 0x4a5b, 0x7c57,
+ 0x6d58, 0x6147, 0x7458, 0x5633, 0x5d2d, 0x553e, 0x7143, 0x6e5f,
+ 0x566b, 0x7459, 0x5766, 0x5a37, 0x5d7b, 0x5d4f, 0x5823, 0x5a59,
+ 0x7058, 0x6f44, 0x6158, 0x7154, 0x6d72, 0x555b, 0x555c, 0x7344,
+ 0x4b57, 0x6236, 0x6f71, 0x7b55, 0x5358, 0x5d50, 0x7059, 0x4b33,
+ 0x555d, 0x4d27, 0x502c, 0x513a, 0x7144, 0x6533, 0x7b75, 0x6961,
+ 0x7d60, 0x7c3c, 0x5a22, 0x5a23, 0x5221, 0x526f, 0x626d, 0x5e69,
+ 0x4e5c, 0x7235, 0x5064, 0x5d51, 0x6148, 0x5b37, 0x5f63, 0x6d39,
+ 0x7145, 0x734f, 0x572b, 0x612c, 0x636b, 0x6e47, 0x6149, 0x4a7a,
+ 0x707b, 0x7a61, 0x705a, 0x4c67, 0x5a74, 0x4c3f, 0x4e6d, 0x5529,
+ 0x7a62, 0x5065, 0x6b56, 0x6c5f, 0x5f7c, 0x7756, 0x5e6a, 0x4b34,
+ 0x6f3e, 0x4c35, 0x4f3d, 0x6f72, 0x6237, 0x4c68, 0x707c, 0x5660,
+ 0x7146, 0x6238, 0x6b2b, 0x4b35, 0x5851, 0x744e, 0x7377, 0x5746,
+ 0x513b, 0x772a, 0x6d4a, 0x5753, 0x587a, 0x7645, 0x514c, 0x5d7c,
+ 0x5f7d, 0x7965, 0x604a, 0x727d, 0x5330, 0x7473, 0x5a49, 0x665e,
+ 0x783a, 0x6850, 0x587b, 0x6a55, 0x5623, 0x7646, 0x725b, 0x647c,
+ 0x6832, 0x5a5a, 0x725c, 0x7b56, 0x6932, 0x6e2d, 0x7a63, 0x5c6e,
+ 0x756a, 0x6660, 0x707d, 0x572c, 0x7545, 0x6e60, 0x5b65, 0x5d5e,
+ 0x5970, 0x6923, 0x7179, 0x7244, 0x604b, 0x6924, 0x6239, 0x6331,
+ 0x7c6b, 0x4d28, 0x4c36, 0x705b, 0x663a, 0x4d29, 0x7343, 0x6159,
+ 0x6f2b, 0x6745, 0x6069, 0x7345, 0x5440, 0x553f, 0x5d2e, 0x797c,
+ 0x4c40, 0x6522, 0x4e38, 0x5852, 0x7956, 0x712a, 0x4e51, 0x7647,
+ 0x5b6b, 0x5f7e, 0x5861, 0x7773, 0x5767, 0x547e, 0x513c, 0x654f,
+ 0x4b36, 0x5a38, 0x4d44, 0x563e, 0x623a, 0x4f58, 0x604c, 0x6b79,
+ 0x7d7d, 0x5768, 0x4b58, 0x6962, 0x683a, 0x6347, 0x6c4d, 0x6c4e,
+ 0x563f, 0x6327, 0x5f56, 0x7d68, 0x6e61, 0x7628, 0x5d7d, 0x783b,
+ 0x6851, 0x7957, 0x4e6e, 0x6c4f, 0x6925, 0x5655, 0x4d45, 0x6d3a,
+ 0x513d, 0x4f3e, 0x6c3b, 0x5231, 0x4c69, 0x5944, 0x697c, 0x513e,
+ 0x6c3c, 0x652d, 0x7730, 0x4c6a, 0x5344, 0x5640, 0x567d, 0x6121,
+ 0x5e3d, 0x7629, 0x5a24, 0x5624, 0x7546, 0x6122, 0x6946, 0x7245,
+ 0x7469, 0x566c, 0x6b53, 0x6c3d, 0x625c, 0x5e6b, 0x705c, 0x6b3f,
+ 0x574e, 0x513f, 0x752b, 0x797d, 0x4a5c, 0x4d46, 0x7236, 0x5d7e,
+ 0x4c37, 0x5b38, 0x5069, 0x4e5d, 0x6b40, 0x7d22, 0x784b, 0x6a56,
+ 0x7130, 0x5b4e, 0x7743, 0x5b4f, 0x4b24, 0x7860, 0x7b57, 0x6b4a,
+ 0x6021, 0x4e4d, 0x545c, 0x7d58, 0x5276, 0x7237, 0x7a76, 0x762a,
+ 0x7a77, 0x5866, 0x7431, 0x6852, 0x4a45, 0x4c6b, 0x626e, 0x623b,
+ 0x772d, 0x7861, 0x736c, 0x5e21, 0x647d, 0x636c, 0x5d2f, 0x5d30,
+ 0x4b37, 0x6853, 0x6123, 0x5260, 0x707e, 0x6926, 0x4b72, 0x6d73,
+ 0x5c59, 0x604d, 0x775a, 0x5b39, 0x4c2e, 0x5a5b, 0x4d47, 0x5d31,
+ 0x582f, 0x6323, 0x4e6f, 0x7273, 0x7833, 0x604e, 0x757d, 0x6b6c,
+ 0x5345, 0x7c6c, 0x525b, 0x546b, 0x5e22, 0x6566, 0x7030, 0x5544,
+ 0x6d74, 0x636d, 0x6842, 0x6d75, 0x577c, 0x6d3b, 0x762b, 0x7238,
+ 0x7648, 0x5366, 0x725d, 0x4f3f, 0x6b2c, 0x4f40, 0x6628, 0x7d69,
+ 0x4f41, 0x605f, 0x5e6c, 0x6022, 0x743f, 0x626f, 0x5971, 0x7147,
+ 0x4b38, 0x797e, 0x5b3a, 0x5a75, 0x766c, 0x5a5c, 0x7a64, 0x604f,
+ 0x5d32, 0x6629, 0x6f73, 0x736d, 0x6b7a, 0x7966, 0x4a5d, 0x555e,
+ 0x4a5e, 0x5f64, 0x667d, 0x752c, 0x6475, 0x6963, 0x6d4b, 0x4f64,
+ 0x5853, 0x5d33, 0x546c, 0x7239, 0x5f37, 0x4b4e, 0x7b58, 0x5059,
+ 0x5d52, 0x7774, 0x675c, 0x6425, 0x7c23, 0x5b3b, 0x723a, 0x697d,
+ 0x504a, 0x7556, 0x5945, 0x6434, 0x6d27, 0x6a3d, 0x667e, 0x7744,
+ 0x752d, 0x5960, 0x4a34, 0x7862, 0x4f42, 0x6c3e, 0x6534, 0x4d48,
+ 0x6e48, 0x6748, 0x4d49, 0x7937, 0x7168, 0x5972, 0x5b75, 0x4a35,
+ 0x5946, 0x5849, 0x592b, 0x6d3c, 0x5854, 0x5c5a, 0x623c, 0x7c6d,
+ 0x6c60, 0x527e, 0x6947, 0x662a, 0x6270, 0x7a3b, 0x752e, 0x7b2a,
+ 0x6c7b, 0x6c3f, 0x7c58, 0x5465, 0x7943, 0x6e62, 0x5769, 0x6d76,
+ 0x5e6d, 0x4c6c, 0x636e, 0x6854, 0x7a78, 0x5d34, 0x6435, 0x5830,
+ 0x5855, 0x746a, 0x4e39, 0x5661, 0x4f52, 0x5036, 0x4e22, 0x736e,
+ 0x7378, 0x5c4c, 0x504b, 0x7c24, 0x4d4a, 0x5754, 0x5e23, 0x6460,
+ 0x6e49, 0x625d, 0x757e, 0x542c, 0x5551, 0x5870, 0x7843, 0x6a57,
+ 0x7557, 0x583f, 0x7d40, 0x6b2d, 0x552a, 0x6728, 0x6e4a, 0x4a67,
+ 0x7863, 0x545d, 0x6a58, 0x7b59, 0x6d77, 0x6535, 0x502d, 0x7171,
+ 0x623d, 0x6348, 0x5955, 0x5f2a, 0x5b3c, 0x7864, 0x717a, 0x6536,
+ 0x736f, 0x7b5a, 0x6160, 0x592c, 0x756b, 0x6036, 0x6948, 0x4b4f,
+ 0x6349, 0x5e6e, 0x623e, 0x5c6f, 0x5625, 0x6271, 0x567e, 0x5921,
+ 0x5840, 0x5c5b, 0x6d3d, 0x5f38, 0x6a25, 0x572d, 0x7379, 0x6d78,
+ 0x7547, 0x614a, 0x6b63, 0x725e, 0x784c, 0x6a59, 0x5346, 0x5b66,
+ 0x752f, 0x4e70, 0x697e, 0x7b36, 0x6272, 0x4f72, 0x7739, 0x5973,
+ 0x614b, 0x5a5d, 0x5a39, 0x6b7b, 0x4b39, 0x6d79, 0x6060, 0x7440,
+ 0x7d3c, 0x5f31, 0x636f, 0x6023, 0x7d39, 0x7031, 0x4d4b, 0x6d3e,
+ 0x5540, 0x6370, 0x6d7a, 0x6964, 0x556d, 0x675d, 0x5476, 0x6537,
+ 0x5b67, 0x623f, 0x6e4b, 0x5774, 0x705d, 0x4e2b, 0x675e, 0x5656,
+ 0x614c, 0x6833, 0x656e, 0x5c22, 0x6050, 0x5535, 0x5521, 0x7b5b,
+ 0x794b, 0x4b73, 0x7425, 0x7a48, 0x5657, 0x6965, 0x7b5c, 0x7d50,
+ 0x7b76, 0x5a25, 0x5b3d, 0x6c62, 0x4d77, 0x705e, 0x7649, 0x5e6f,
+ 0x5331, 0x7c6e, 0x6843, 0x7148, 0x4e71, 0x796d, 0x7274, 0x6436,
+ 0x7539, 0x5c70, 0x6371, 0x6825, 0x723b, 0x5e24, 0x5a4c, 0x4a69,
+ 0x635a, 0x7c59, 0x6a5a, 0x7944, 0x6324, 0x7b5d, 0x6f4a, 0x6844,
+ 0x554c, 0x6b57, 0x592d, 0x7b2b, 0x5359, 0x5522, 0x765e, 0x5a76,
+ 0x6051, 0x6928, 0x7579, 0x7a2f, 0x6b7c, 0x606a, 0x6332, 0x5545,
+ 0x7163, 0x556e, 0x4d4c, 0x6d59, 0x5841, 0x7a6c, 0x716b, 0x7a3c,
+ 0x6662, 0x7a65, 0x627a, 0x4a36, 0x6437, 0x6a5b, 0x757a, 0x7b2c,
+ 0x4f43, 0x6b7d, 0x787a, 0x5f39, 0x6171, 0x5224, 0x757b, 0x505a,
+ 0x505b, 0x6a3e, 0x5931, 0x4a37, 0x5367, 0x7865, 0x5332, 0x6240,
+ 0x725f, 0x4d65, 0x792c, 0x4d4d, 0x6e2e, 0x562e, 0x576a, 0x6760,
+ 0x6b2e, 0x4f59, 0x5c4d, 0x6d7b, 0x5e70, 0x576b, 0x5e25, 0x5f57,
+ 0x5b50, 0x5b51, 0x5523, 0x7032, 0x5c5c, 0x4a68, 0x7866, 0x5c4e,
+ 0x6a5c, 0x5b52, 0x6933, 0x775b, 0x6328, 0x572e, 0x6061, 0x4b3a,
+ 0x6551, 0x505c, 0x5541, 0x584a, 0x6329, 0x6024, 0x6929, 0x5347,
+ 0x5c5d, 0x782e, 0x4c38, 0x502e, 0x5872, 0x634a, 0x4c2f, 0x542d,
+ 0x7651, 0x504c, 0x4a46, 0x5542, 0x4e3a, 0x4a47, 0x7a30, 0x5f58,
+ 0x753a, 0x656b, 0x6f74, 0x5d35, 0x4d2a, 0x6372, 0x7b77, 0x7750,
+ 0x7d3a, 0x7d61, 0x767e, 0x5140, 0x6845, 0x6438, 0x6168, 0x4c41,
+ 0x526d, 0x5b3e, 0x6062, 0x7a49, 0x614d, 0x4a38, 0x7260, 0x7149,
+ 0x5e71, 0x705f, 0x7844, 0x6e4c, 0x5e72, 0x6749, 0x6273, 0x6761,
+ 0x634b, 0x634c, 0x4f78, 0x6f2c, 0x7d7e, 0x7c25, 0x7a31, 0x5f59,
+ 0x6052, 0x745a, 0x714a, 0x4e23, 0x723c, 0x6c63, 0x6025, 0x772b,
+ 0x6b2f, 0x655e, 0x6124, 0x4d2b, 0x5974, 0x6826, 0x4d4e, 0x6169,
+ 0x7c6f, 0x6063, 0x6241, 0x4e24, 0x5e26, 0x6b7e, 0x6b5d, 0x7060,
+ 0x745b, 0x6274, 0x5348, 0x746b, 0x6e35, 0x7558, 0x555f, 0x5665,
+ 0x6b30, 0x7463, 0x634d, 0x7474, 0x7a32, 0x6f75, 0x4a5f, 0x6b31,
+ 0x6d3f, 0x7d49, 0x6426, 0x7924, 0x7033, 0x656c, 0x5167, 0x5947,
+ 0x6457, 0x6a5d, 0x5477, 0x5a3a, 0x5a4d, 0x794c, 0x615a, 0x5b3f,
+ 0x4c45, 0x6c50, 0x4b3b, 0x5e73, 0x692a, 0x5948, 0x6e63, 0x573d,
+ 0x4f44, 0x504d, 0x7c26, 0x717b, 0x7d52, 0x5141, 0x635b, 0x5349,
+ 0x5c4f, 0x4c6d, 0x5e27, 0x663b, 0x6c21, 0x4c39, 0x7b5e, 0x6762,
+ 0x5441, 0x5c28, 0x6242, 0x7358, 0x6553, 0x7359, 0x7346, 0x4d5b,
+ 0x4d2c, 0x7c43, 0x5467, 0x5142, 0x7925, 0x6855, 0x634e, 0x544a,
+ 0x5f5a, 0x7b5f, 0x6763, 0x787b, 0x634f, 0x7530, 0x5867, 0x5949,
+ 0x782f, 0x6f76, 0x5d36, 0x6e2f, 0x4d78, 0x5e38, 0x7c27, 0x777c,
+ 0x7731, 0x4e3b, 0x7421, 0x6e4d, 0x612e, 0x6c43, 0x4f7e, 0x783f,
+ 0x5862, 0x5368, 0x5e28, 0x7464, 0x6c42, 0x5975, 0x7945, 0x5d53,
+ 0x5671, 0x6c7c, 0x7c70, 0x6d40, 0x4a39, 0x6e64, 0x7261, 0x5e39,
+ 0x5672, 0x5e74, 0x5f5b, 0x5b53, 0x7a67, 0x5863, 0x7441, 0x5d37,
+ 0x7275, 0x542e, 0x5673, 0x5d38, 0x4f45, 0x5f5f, 0x723e, 0x7621,
+ 0x6b4b, 0x717c, 0x7347, 0x606b, 0x6d7c, 0x615b, 0x6e65, 0x5e75,
+ 0x7a53, 0x714b, 0x502f, 0x5d39, 0x5143, 0x7531, 0x6a46, 0x7061,
+ 0x762c, 0x7559, 0x706b, 0x5d3a, 0x723f, 0x7745, 0x5b22, 0x7276,
+ 0x4a3a, 0x7775, 0x4b65, 0x6e66, 0x6053, 0x4e25, 0x5658, 0x542f,
+ 0x6949, 0x534e, 0x7442, 0x4b66, 0x7121, 0x6b32, 0x7122, 0x6b33,
+ 0x7034, 0x4b74, 0x5430, 0x7332, 0x7b37, 0x756c, 0x6e67, 0x7432,
+ 0x756d, 0x4f73, 0x7062, 0x6e4e, 0x714c, 0x6538, 0x5775, 0x6373,
+ 0x4f65, 0x4f46, 0x7333, 0x6458, 0x4f79, 0x4f5a, 0x7a4d, 0x6663,
+ 0x7262, 0x756e, 0x4a3b, 0x635c, 0x4e72, 0x5659, 0x6e30, 0x7465,
+ 0x5842, 0x5c50, 0x4c6e, 0x5560, 0x764a, 0x7d4a, 0x5856, 0x744f,
+ 0x5626, 0x5c3e, 0x5b54, 0x5747, 0x727e, 0x714d, 0x6243, 0x5c5e,
+ 0x5c5f, 0x6f2d, 0x662b, 0x795d, 0x6a3f, 0x6f2e, 0x7450, 0x4e73,
+ 0x662c, 0x4e5e, 0x5579, 0x6374, 0x4d50, 0x5538, 0x777d, 0x5c29,
+ 0x5e76, 0x5c2a, 0x7263, 0x6934, 0x525c, 0x6966, 0x6376, 0x674a,
+ 0x504e, 0x5a77, 0x4a3c, 0x6e68, 0x5a5e, 0x7277, 0x627b, 0x4c26,
+ 0x5a3b, 0x6e69, 0x755a, 0x775c, 0x616a, 0x4e41, 0x5431, 0x7d31,
+ 0x663d, 0x7b2d, 0x7867, 0x614e, 0x7762, 0x756f, 0x4f47, 0x5432,
+ 0x4c6f, 0x5468, 0x6e4f, 0x7757, 0x6026, 0x5641, 0x615c, 0x7063,
+ 0x7164, 0x5c71, 0x5627, 0x7475, 0x714e, 0x7264, 0x5030, 0x6c6f,
+ 0x793a, 0x6b35, 0x546d, 0x6244, 0x6967, 0x6b34, 0x6a21, 0x783c,
+ 0x4e26, 0x7946, 0x7c5a, 0x5433, 0x5339, 0x6a5e, 0x692b, 0x6161,
+ 0x534f, 0x7476, 0x6a40, 0x614f, 0x4c3a, 0x6e6a, 0x7064, 0x7334,
+ 0x546e, 0x7240, 0x7165, 0x7443, 0x6054, 0x6b36, 0x5721, 0x4b68,
+ 0x792d, 0x692d, 0x5864, 0x7a33, 0x6245, 0x7c3d, 0x6c44, 0x5831,
+ 0x5c2b, 0x5524, 0x6b69, 0x683b, 0x5857, 0x7b2e, 0x5161, 0x5b40,
+ 0x753e, 0x5e77, 0x4a7b, 0x7746, 0x4f48, 0x6150, 0x6e50, 0x6974,
+ 0x4e74, 0x554d, 0x4f5b, 0x5d3b, 0x4e2c, 0x6968, 0x5434, 0x6447,
+ 0x755b, 0x7a41, 0x5e29, 0x5478, 0x6f77, 0x5333, 0x6b37, 0x6f78,
+ 0x755c, 0x6d4c, 0x5b55, 0x714f, 0x7150, 0x7532, 0x592e, 0x552c,
+ 0x6246, 0x7d23, 0x7b65, 0x5f2b, 0x6275, 0x762d, 0x7533, 0x7035,
+ 0x6125, 0x755d, 0x6c22, 0x6d7d, 0x7534, 0x7b38, 0x5b23, 0x564a,
+ 0x4b59, 0x6554, 0x737a, 0x6b38, 0x6037, 0x576c, 0x716c, 0x652f,
+ 0x5561, 0x576d, 0x5151, 0x6172, 0x6f79, 0x5d3c, 0x765c, 0x7065,
+ 0x7444, 0x6969, 0x737b, 0x546f, 0x4c22, 0x777e, 0x5f3c, 0x6b4d,
+ 0x5037, 0x5642, 0x682d, 0x6f2f, 0x4b25, 0x4b69, 0x7a68, 0x4c46,
+ 0x6667, 0x6a47, 0x5b24, 0x4f49, 0x627c, 0x6f7a, 0x6b5e, 0x7548,
+ 0x545e, 0x6055, 0x6f30, 0x6247, 0x592f, 0x7967, 0x6765, 0x4f4a,
+ 0x6151, 0x6248, 0x6f7b, 0x7a79, 0x5c72, 0x6027, 0x7868, 0x4b6a,
+ 0x4b3c, 0x5662, 0x755e, 0x755f, 0x6e36, 0x6276, 0x534a, 0x6f7c,
+ 0x5144, 0x6f31, 0x5145, 0x505e, 0x5961, 0x6038, 0x4d51, 0x7339,
+ 0x674c, 0x5628, 0x4e27, 0x5435, 0x6448, 0x5334, 0x6b39, 0x4b75,
+ 0x765d, 0x7123, 0x4c47, 0x694a, 0x6170, 0x7560, 0x7b2f, 0x4b51,
+ 0x7b60, 0x7265, 0x6c70, 0x706c, 0x6e6b, 0x694b, 0x4c70, 0x572f,
+ 0x7321, 0x7c75, 0x7124, 0x6056, 0x6f32, 0x7451, 0x7721, 0x7151,
+ 0x4a7c, 0x4a7d, 0x4e4e, 0x7348, 0x733a, 0x6d7e, 0x5a26, 0x606c,
+ 0x784d, 0x4b52, 0x6b4e, 0x7958, 0x7959, 0x4a60, 0x5a4a, 0x4b26,
+ 0x4a48, 0x796e, 0x5b6c, 0x5031, 0x556f, 0x6673, 0x6722, 0x6459,
+ 0x6461, 0x7c44, 0x796f, 0x4f74, 0x7766, 0x4e3c, 0x7445, 0x5c23,
+ 0x5d3d, 0x7446, 0x7821, 0x6856, 0x5b41, 0x7066, 0x6439, 0x766d,
+ 0x792e, 0x5d3e, 0x5730, 0x5868, 0x4b3d, 0x795a, 0x784e, 0x7970,
+ 0x606d, 0x6333, 0x7433, 0x6a42, 0x7266, 0x7036, 0x5b56, 0x6b64,
+ 0x7267, 0x5755, 0x5436, 0x7968, 0x5741, 0x6555, 0x696a, 0x574c,
+ 0x5369, 0x6249, 0x7c5b, 0x4d2d, 0x4c30, 0x6a22, 0x6476, 0x5040,
+ 0x7037, 0x6e21, 0x5776, 0x624a, 0x624b, 0x7a4f, 0x6b5f, 0x564b,
+ 0x7434, 0x6d4d, 0x6452, 0x6a29, 0x643a, 0x7322, 0x4d52, 0x764b,
+ 0x7166, 0x6d41, 0x683c, 0x6e51, 0x7067, 0x624c, 0x642a, 0x7561,
+ 0x6d5a, 0x576e, 0x5171, 0x696b, 0x696c, 0x6064, 0x5a27, 0x5d54,
+ 0x6a23, 0x5643, 0x5674, 0x5a5f, 0x6f33, 0x624d, 0x6f7d, 0x7268,
+ 0x6f45, 0x6767, 0x577d, 0x674e, 0x5f5c, 0x7947, 0x5976, 0x5f2c,
+ 0x565a, 0x5c24, 0x7038, 0x557a, 0x6477, 0x5644, 0x746c, 0x6f7e,
+ 0x7021, 0x5e2a, 0x5a3c, 0x587c, 0x7a54, 0x6c65, 0x7c28, 0x6c66,
+ 0x584b, 0x7b39, 0x6453, 0x4d79, 0x4f53, 0x4a6a, 0x4f54, 0x783d,
+ 0x7447, 0x6a5f, 0x795b, 0x5437, 0x6b65, 0x6152, 0x6a24, 0x7a42,
+ 0x7b61, 0x7a6d, 0x7022, 0x4c71, 0x7a23, 0x6277, 0x624e, 0x6975,
+ 0x616b, 0x6768, 0x6857, 0x5a78, 0x544b, 0x7776, 0x5645, 0x5469,
+ 0x7a7a, 0x4c72, 0x775d, 0x5e3a, 0x4e28, 0x7039, 0x647e, 0x6449,
+ 0x6454, 0x6a43, 0x6f34, 0x573e, 0x7b62, 0x4d53, 0x6f35, 0x7a69,
+ 0x7926, 0x5f3d, 0x7747, 0x787d, 0x787c, 0x5e2b, 0x5b68, 0x635d,
+ 0x6162, 0x5146, 0x7650, 0x6b66, 0x5a79, 0x6c47, 0x5e78, 0x7869,
+ 0x635e, 0x4e75, 0x7a43, 0x6557, 0x6c48, 0x7349, 0x643b, 0x662e,
+ 0x6f36, 0x5c3f, 0x4e3d, 0x5843, 0x504f, 0x4f7a, 0x734a, 0x6057,
+ 0x5147, 0x692e, 0x683d, 0x7a44, 0x624f, 0x7a45, 0x7938, 0x5c60,
+ 0x7b30, 0x5829, 0x655f, 0x7927, 0x766e, 0x764c, 0x6278, 0x6c71,
+ 0x5a60, 0x7152, 0x524c, 0x4f4b, 0x4a3d, 0x5d3f, 0x766f, 0x5e79,
+ 0x7a34, 0x552d, 0x7167, 0x5e3e, 0x5c40, 0x5148, 0x5149, 0x783e,
+ 0x4b76, 0x5479, 0x7562, 0x6153, 0x5869, 0x787e, 0x4f4c, 0x7d24,
+ 0x4e76, 0x7a50, 0x4c73, 0x663e, 0x762e, 0x5570, 0x514a, 0x7c3e,
+ 0x5571, 0x4d69, 0x7a35, 0x6250, 0x7477, 0x4d54, 0x6723, 0x5b25,
+ 0x6251, 0x5722, 0x7763, 0x6a26, 0x5021, 0x4e5a, 0x7b6b, 0x5b26,
+ 0x5b5e, 0x5865, 0x6a60, 0x582a, 0x6560, 0x565b, 0x6f46, 0x786a,
+ 0x6455, 0x4e77, 0x6058, 0x576f, 0x746d, 0x4d66, 0x4c74, 0x7563,
+ 0x644a, 0x5c61, 0x7948, 0x7c3f, 0x6827, 0x5844, 0x4b3e, 0x5c2e,
+ 0x5777, 0x7068, 0x5d40, 0x4f4d, 0x5c73, 0x5930, 0x6669, 0x643c,
+ 0x6a44, 0x646c, 0x6465, 0x7b78, 0x4c3b, 0x643d, 0x4d5c, 0x5977,
+ 0x5d5f, 0x6d4e, 0x5950, 0x6523, 0x794d, 0x4d2e, 0x4f4e, 0x762f,
+ 0x7d53, 0x6b6d, 0x565c, 0x6524, 0x5536, 0x565d, 0x7969, 0x6724,
+ 0x5663, 0x514b, 0x5664, 0x5572, 0x5e7a, 0x5778, 0x586a, 0x4f55,
+ 0x587d, 0x582b, 0x7d4b, 0x7c5c, 0x6028, 0x5573, 0x7d59, 0x4c23,
+ 0x5979, 0x536a, 0x7575, 0x6f47, 0x535a, 0x5a3d, 0x6828, 0x5c2f,
+ 0x7023, 0x4d55, 0x6029, 0x5e2c, 0x703a, 0x6e31, 0x6e32, 0x764d,
+ 0x6e52, 0x5646, 0x6065, 0x733b, 0x6561, 0x644b, 0x5723, 0x5b42,
+ 0x4a7e, 0x4f4f, 0x3021, 0x3022, 0x3023, 0x3024, 0x3025, 0x3026,
+ 0x3027, 0x3028, 0x3029, 0x302a, 0x302b, 0x302c, 0x302d, 0x302e,
+ 0x302f, 0x3030, 0x3031, 0x3032, 0x3033, 0x3034, 0x3035, 0x3036,
+ 0x3037, 0x3038, 0x3039, 0x303a, 0x303b, 0x303c, 0x303d, 0x303e,
+ 0x303f, 0x3040, 0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046,
+ 0x3047, 0x3048, 0x3049, 0x304a, 0x304b, 0x304c, 0x304d, 0x304e,
+ 0x304f, 0x3050, 0x3051, 0x3052, 0x3053, 0x3054, 0x3055, 0x3056,
+ 0x3057, 0x3058, 0x3059, 0x305a, 0x305b, 0x305c, 0x305d, 0x305e,
+ 0x305f, 0x3060, 0x3061, 0x3062, 0x3063, 0x3064, 0x3065, 0x3066,
+ 0x3067, 0x3068, 0x3069, 0x306a, 0x306b, 0x306c, 0x306d, 0x306e,
+ 0x306f, 0x3070, 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076,
+ 0x3077, 0x3078, 0x3079, 0x307a, 0x307b, 0x307c, 0x307d, 0x307e,
+ 0x3121, 0x3122, 0x3123, 0x3124, 0x3125, 0x3126, 0x3127, 0x3128,
+ 0x3129, 0x312a, 0x312b, 0x312c, 0x312d, 0x312e, 0x312f, 0x3130,
+ 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137, 0x3138,
+ 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f, 0x3140,
+ 0x3141, 0x3142, 0x3143, 0x3144, 0x3145, 0x3146, 0x3147, 0x3148,
+ 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e, 0x314f, 0x3150,
+ 0x3151, 0x3152, 0x3153, 0x3154, 0x3155, 0x3156, 0x3157, 0x3158,
+ 0x3159, 0x315a, 0x315b, 0x315c, 0x315d, 0x315e, 0x315f, 0x3160,
+ 0x3161, 0x3162, 0x3163, 0x3164, 0x3165, 0x3166, 0x3167, 0x3168,
+ 0x3169, 0x316a, 0x316b, 0x316c, 0x316d, 0x316e, 0x316f, 0x3170,
+ 0x3171, 0x3172, 0x3173, 0x3174, 0x3175, 0x3176, 0x3177, 0x3178,
+ 0x3179, 0x317a, 0x317b, 0x317c, 0x317d, 0x317e, 0x3221, 0x3222,
+ 0x3223, 0x3224, 0x3225, 0x3226, 0x3227, 0x3228, 0x3229, 0x322a,
+ 0x322b, 0x322c, 0x322d, 0x322e, 0x322f, 0x3230, 0x3231, 0x3232,
+ 0x3233, 0x3234, 0x3235, 0x3236, 0x3237, 0x3238, 0x3239, 0x323a,
+ 0x323b, 0x323c, 0x323d, 0x323e, 0x323f, 0x3240, 0x3241, 0x3242,
+ 0x3243, 0x3244, 0x3245, 0x3246, 0x3247, 0x3248, 0x3249, 0x324a,
+ 0x324b, 0x324c, 0x324d, 0x324e, 0x324f, 0x3250, 0x3251, 0x3252,
+ 0x3253, 0x3254, 0x3255, 0x3256, 0x3257, 0x3258, 0x3259, 0x325a,
+ 0x325b, 0x325c, 0x325d, 0x325e, 0x325f, 0x3260, 0x3261, 0x3262,
+ 0x3263, 0x3264, 0x3265, 0x3266, 0x3267, 0x3268, 0x3269, 0x326a,
+ 0x326b, 0x326c, 0x326d, 0x326e, 0x326f, 0x3270, 0x3271, 0x3272,
+ 0x3273, 0x3274, 0x3275, 0x3276, 0x3277, 0x3278, 0x3279, 0x327a,
+ 0x327b, 0x327c, 0x327d, 0x327e, 0x3321, 0x3322, 0x3323, 0x3324,
+ 0x3325, 0x3326, 0x3327, 0x3328, 0x3329, 0x332a, 0x332b, 0x332c,
+ 0x332d, 0x332e, 0x332f, 0x3330, 0x3331, 0x3332, 0x3333, 0x3334,
+ 0x3335, 0x3336, 0x3337, 0x3338, 0x3339, 0x333a, 0x333b, 0x333c,
+ 0x333d, 0x333e, 0x333f, 0x3340, 0x3341, 0x3342, 0x3343, 0x3344,
+ 0x3345, 0x3346, 0x3347, 0x3348, 0x3349, 0x334a, 0x334b, 0x334c,
+ 0x334d, 0x334e, 0x334f, 0x3350, 0x3351, 0x3352, 0x3353, 0x3354,
+ 0x3355, 0x3356, 0x3357, 0x3358, 0x3359, 0x335a, 0x335b, 0x335c,
+ 0x335d, 0x335e, 0x335f, 0x3360, 0x3361, 0x3362, 0x3363, 0x3364,
+ 0x3365, 0x3366, 0x3367, 0x3368, 0x3369, 0x336a, 0x336b, 0x336c,
+ 0x336d, 0x336e, 0x336f, 0x3370, 0x3371, 0x3372, 0x3373, 0x3374,
+ 0x3375, 0x3376, 0x3377, 0x3378, 0x3379, 0x337a, 0x337b, 0x337c,
+ 0x337d, 0x337e, 0x3421, 0x3422, 0x3423, 0x3424, 0x3425, 0x3426,
+ 0x3427, 0x3428, 0x3429, 0x342a, 0x342b, 0x342c, 0x342d, 0x342e,
+ 0x342f, 0x3430, 0x3431, 0x3432, 0x3433, 0x3434, 0x3435, 0x3436,
+ 0x3437, 0x3438, 0x3439, 0x343a, 0x343b, 0x343c, 0x343d, 0x343e,
+ 0x343f, 0x3440, 0x3441, 0x3442, 0x3443, 0x3444, 0x3445, 0x3446,
+ 0x3447, 0x3448, 0x3449, 0x344a, 0x344b, 0x344c, 0x344d, 0x344e,
+ 0x344f, 0x3450, 0x3451, 0x3452, 0x3453, 0x3454, 0x3455, 0x3456,
+ 0x3457, 0x3458, 0x3459, 0x345a, 0x345b, 0x345c, 0x345d, 0x345e,
+ 0x345f, 0x3460, 0x3461, 0x3462, 0x3463, 0x3464, 0x3465, 0x3466,
+ 0x3467, 0x3468, 0x3469, 0x346a, 0x346b, 0x346c, 0x346d, 0x346e,
+ 0x346f, 0x3470, 0x3471, 0x3472, 0x3473, 0x3474, 0x3475, 0x3476,
+ 0x3477, 0x3478, 0x3479, 0x347a, 0x347b, 0x347c, 0x347d, 0x347e,
+ 0x3521, 0x3522, 0x3523, 0x3524, 0x3525, 0x3526, 0x3527, 0x3528,
+ 0x3529, 0x352a, 0x352b, 0x352c, 0x352d, 0x352e, 0x352f, 0x3530,
+ 0x3531, 0x3532, 0x3533, 0x3534, 0x3535, 0x3536, 0x3537, 0x3538,
+ 0x3539, 0x353a, 0x353b, 0x353c, 0x353d, 0x353e, 0x353f, 0x3540,
+ 0x3541, 0x3542, 0x3543, 0x3544, 0x3545, 0x3546, 0x3547, 0x3548,
+ 0x3549, 0x354a, 0x354b, 0x354c, 0x354d, 0x354e, 0x354f, 0x3550,
+ 0x3551, 0x3552, 0x3553, 0x3554, 0x3555, 0x3556, 0x3557, 0x3558,
+ 0x3559, 0x355a, 0x355b, 0x355c, 0x355d, 0x355e, 0x355f, 0x3560,
+ 0x3561, 0x3562, 0x3563, 0x3564, 0x3565, 0x3566, 0x3567, 0x3568,
+ 0x3569, 0x356a, 0x356b, 0x356c, 0x356d, 0x356e, 0x356f, 0x3570,
+ 0x3571, 0x3572, 0x3573, 0x3574, 0x3575, 0x3576, 0x3577, 0x3578,
+ 0x3579, 0x357a, 0x357b, 0x357c, 0x357d, 0x357e, 0x3621, 0x3622,
+ 0x3623, 0x3624, 0x3625, 0x3626, 0x3627, 0x3628, 0x3629, 0x362a,
+ 0x362b, 0x362c, 0x362d, 0x362e, 0x362f, 0x3630, 0x3631, 0x3632,
+ 0x3633, 0x3634, 0x3635, 0x3636, 0x3637, 0x3638, 0x3639, 0x363a,
+ 0x363b, 0x363c, 0x363d, 0x363e, 0x363f, 0x3640, 0x3641, 0x3642,
+ 0x3643, 0x3644, 0x3645, 0x3646, 0x3647, 0x3648, 0x3649, 0x364a,
+ 0x364b, 0x364c, 0x364d, 0x364e, 0x364f, 0x3650, 0x3651, 0x3652,
+ 0x3653, 0x3654, 0x3655, 0x3656, 0x3657, 0x3658, 0x3659, 0x365a,
+ 0x365b, 0x365c, 0x365d, 0x365e, 0x365f, 0x3660, 0x3661, 0x3662,
+ 0x3663, 0x3664, 0x3665, 0x3666, 0x3667, 0x3668, 0x3669, 0x366a,
+ 0x366b, 0x366c, 0x366d, 0x366e, 0x366f, 0x3670, 0x3671, 0x3672,
+ 0x3673, 0x3674, 0x3675, 0x3676, 0x3677, 0x3678, 0x3679, 0x367a,
+ 0x367b, 0x367c, 0x367d, 0x367e, 0x3721, 0x3722, 0x3723, 0x3724,
+ 0x3725, 0x3726, 0x3727, 0x3728, 0x3729, 0x372a, 0x372b, 0x372c,
+ 0x372d, 0x372e, 0x372f, 0x3730, 0x3731, 0x3732, 0x3733, 0x3734,
+ 0x3735, 0x3736, 0x3737, 0x3738, 0x3739, 0x373a, 0x373b, 0x373c,
+ 0x373d, 0x373e, 0x373f, 0x3740, 0x3741, 0x3742, 0x3743, 0x3744,
+ 0x3745, 0x3746, 0x3747, 0x3748, 0x3749, 0x374a, 0x374b, 0x374c,
+ 0x374d, 0x374e, 0x374f, 0x3750, 0x3751, 0x3752, 0x3753, 0x3754,
+ 0x3755, 0x3756, 0x3757, 0x3758, 0x3759, 0x375a, 0x375b, 0x375c,
+ 0x375d, 0x375e, 0x375f, 0x3760, 0x3761, 0x3762, 0x3763, 0x3764,
+ 0x3765, 0x3766, 0x3767, 0x3768, 0x3769, 0x376a, 0x376b, 0x376c,
+ 0x376d, 0x376e, 0x376f, 0x3770, 0x3771, 0x3772, 0x3773, 0x3774,
+ 0x3775, 0x3776, 0x3777, 0x3778, 0x3779, 0x377a, 0x377b, 0x377c,
+ 0x377d, 0x377e, 0x3821, 0x3822, 0x3823, 0x3824, 0x3825, 0x3826,
+ 0x3827, 0x3828, 0x3829, 0x382a, 0x382b, 0x382c, 0x382d, 0x382e,
+ 0x382f, 0x3830, 0x3831, 0x3832, 0x3833, 0x3834, 0x3835, 0x3836,
+ 0x3837, 0x3838, 0x3839, 0x383a, 0x383b, 0x383c, 0x383d, 0x383e,
+ 0x383f, 0x3840, 0x3841, 0x3842, 0x3843, 0x3844, 0x3845, 0x3846,
+ 0x3847, 0x3848, 0x3849, 0x384a, 0x384b, 0x384c, 0x384d, 0x384e,
+ 0x384f, 0x3850, 0x3851, 0x3852, 0x3853, 0x3854, 0x3855, 0x3856,
+ 0x3857, 0x3858, 0x3859, 0x385a, 0x385b, 0x385c, 0x385d, 0x385e,
+ 0x385f, 0x3860, 0x3861, 0x3862, 0x3863, 0x3864, 0x3865, 0x3866,
+ 0x3867, 0x3868, 0x3869, 0x386a, 0x386b, 0x386c, 0x386d, 0x386e,
+ 0x386f, 0x3870, 0x3871, 0x3872, 0x3873, 0x3874, 0x3875, 0x3876,
+ 0x3877, 0x3878, 0x3879, 0x387a, 0x387b, 0x387c, 0x387d, 0x387e,
+ 0x3921, 0x3922, 0x3923, 0x3924, 0x3925, 0x3926, 0x3927, 0x3928,
+ 0x3929, 0x392a, 0x392b, 0x392c, 0x392d, 0x392e, 0x392f, 0x3930,
+ 0x3931, 0x3932, 0x3933, 0x3934, 0x3935, 0x3936, 0x3937, 0x3938,
+ 0x3939, 0x393a, 0x393b, 0x393c, 0x393d, 0x393e, 0x393f, 0x3940,
+ 0x3941, 0x3942, 0x3943, 0x3944, 0x3945, 0x3946, 0x3947, 0x3948,
+ 0x3949, 0x394a, 0x394b, 0x394c, 0x394d, 0x394e, 0x394f, 0x3950,
+ 0x3951, 0x3952, 0x3953, 0x3954, 0x3955, 0x3956, 0x3957, 0x3958,
+ 0x3959, 0x395a, 0x395b, 0x395c, 0x395d, 0x395e, 0x395f, 0x3960,
+ 0x3961, 0x3962, 0x3963, 0x3964, 0x3965, 0x3966, 0x3967, 0x3968,
+ 0x3969, 0x396a, 0x396b, 0x396c, 0x396d, 0x396e, 0x396f, 0x3970,
+ 0x3971, 0x3972, 0x3973, 0x3974, 0x3975, 0x3976, 0x3977, 0x3978,
+ 0x3979, 0x397a, 0x397b, 0x397c, 0x397d, 0x397e, 0x3a21, 0x3a22,
+ 0x3a23, 0x3a24, 0x3a25, 0x3a26, 0x3a27, 0x3a28, 0x3a29, 0x3a2a,
+ 0x3a2b, 0x3a2c, 0x3a2d, 0x3a2e, 0x3a2f, 0x3a30, 0x3a31, 0x3a32,
+ 0x3a33, 0x3a34, 0x3a35, 0x3a36, 0x3a37, 0x3a38, 0x3a39, 0x3a3a,
+ 0x3a3b, 0x3a3c, 0x3a3d, 0x3a3e, 0x3a3f, 0x3a40, 0x3a41, 0x3a42,
+ 0x3a43, 0x3a44, 0x3a45, 0x3a46, 0x3a47, 0x3a48, 0x3a49, 0x3a4a,
+ 0x3a4b, 0x3a4c, 0x3a4d, 0x3a4e, 0x3a4f, 0x3a50, 0x3a51, 0x3a52,
+ 0x3a53, 0x3a54, 0x3a55, 0x3a56, 0x3a57, 0x3a58, 0x3a59, 0x3a5a,
+ 0x3a5b, 0x3a5c, 0x3a5d, 0x3a5e, 0x3a5f, 0x3a60, 0x3a61, 0x3a62,
+ 0x3a63, 0x3a64, 0x3a65, 0x3a66, 0x3a67, 0x3a68, 0x3a69, 0x3a6a,
+ 0x3a6b, 0x3a6c, 0x3a6d, 0x3a6e, 0x3a6f, 0x3a70, 0x3a71, 0x3a72,
+ 0x3a73, 0x3a74, 0x3a75, 0x3a76, 0x3a77, 0x3a78, 0x3a79, 0x3a7a,
+ 0x3a7b, 0x3a7c, 0x3a7d, 0x3a7e, 0x3b21, 0x3b22, 0x3b23, 0x3b24,
+ 0x3b25, 0x3b26, 0x3b27, 0x3b28, 0x3b29, 0x3b2a, 0x3b2b, 0x3b2c,
+ 0x3b2d, 0x3b2e, 0x3b2f, 0x3b30, 0x3b31, 0x3b32, 0x3b33, 0x3b34,
+ 0x3b35, 0x3b36, 0x3b37, 0x3b38, 0x3b39, 0x3b3a, 0x3b3b, 0x3b3c,
+ 0x3b3d, 0x3b3e, 0x3b3f, 0x3b40, 0x3b41, 0x3b42, 0x3b43, 0x3b44,
+ 0x3b45, 0x3b46, 0x3b47, 0x3b48, 0x3b49, 0x3b4a, 0x3b4b, 0x3b4c,
+ 0x3b4d, 0x3b4e, 0x3b4f, 0x3b50, 0x3b51, 0x3b52, 0x3b53, 0x3b54,
+ 0x3b55, 0x3b56, 0x3b57, 0x3b58, 0x3b59, 0x3b5a, 0x3b5b, 0x3b5c,
+ 0x3b5d, 0x3b5e, 0x3b5f, 0x3b60, 0x3b61, 0x3b62, 0x3b63, 0x3b64,
+ 0x3b65, 0x3b66, 0x3b67, 0x3b68, 0x3b69, 0x3b6a, 0x3b6b, 0x3b6c,
+ 0x3b6d, 0x3b6e, 0x3b6f, 0x3b70, 0x3b71, 0x3b72, 0x3b73, 0x3b74,
+ 0x3b75, 0x3b76, 0x3b77, 0x3b78, 0x3b79, 0x3b7a, 0x3b7b, 0x3b7c,
+ 0x3b7d, 0x3b7e, 0x3c21, 0x3c22, 0x3c23, 0x3c24, 0x3c25, 0x3c26,
+ 0x3c27, 0x3c28, 0x3c29, 0x3c2a, 0x3c2b, 0x3c2c, 0x3c2d, 0x3c2e,
+ 0x3c2f, 0x3c30, 0x3c31, 0x3c32, 0x3c33, 0x3c34, 0x3c35, 0x3c36,
+ 0x3c37, 0x3c38, 0x3c39, 0x3c3a, 0x3c3b, 0x3c3c, 0x3c3d, 0x3c3e,
+ 0x3c3f, 0x3c40, 0x3c41, 0x3c42, 0x3c43, 0x3c44, 0x3c45, 0x3c46,
+ 0x3c47, 0x3c48, 0x3c49, 0x3c4a, 0x3c4b, 0x3c4c, 0x3c4d, 0x3c4e,
+ 0x3c4f, 0x3c50, 0x3c51, 0x3c52, 0x3c53, 0x3c54, 0x3c55, 0x3c56,
+ 0x3c57, 0x3c58, 0x3c59, 0x3c5a, 0x3c5b, 0x3c5c, 0x3c5d, 0x3c5e,
+ 0x3c5f, 0x3c60, 0x3c61, 0x3c62, 0x3c63, 0x3c64, 0x3c65, 0x3c66,
+ 0x3c67, 0x3c68, 0x3c69, 0x3c6a, 0x3c6b, 0x3c6c, 0x3c6d, 0x3c6e,
+ 0x3c6f, 0x3c70, 0x3c71, 0x3c72, 0x3c73, 0x3c74, 0x3c75, 0x3c76,
+ 0x3c77, 0x3c78, 0x3c79, 0x3c7a, 0x3c7b, 0x3c7c, 0x3c7d, 0x3c7e,
+ 0x3d21, 0x3d22, 0x3d23, 0x3d24, 0x3d25, 0x3d26, 0x3d27, 0x3d28,
+ 0x3d29, 0x3d2a, 0x3d2b, 0x3d2c, 0x3d2d, 0x3d2e, 0x3d2f, 0x3d30,
+ 0x3d31, 0x3d32, 0x3d33, 0x3d34, 0x3d35, 0x3d36, 0x3d37, 0x3d38,
+ 0x3d39, 0x3d3a, 0x3d3b, 0x3d3c, 0x3d3d, 0x3d3e, 0x3d3f, 0x3d40,
+ 0x3d41, 0x3d42, 0x3d43, 0x3d44, 0x3d45, 0x3d46, 0x3d47, 0x3d48,
+ 0x3d49, 0x3d4a, 0x3d4b, 0x3d4c, 0x3d4d, 0x3d4e, 0x3d4f, 0x3d50,
+ 0x3d51, 0x3d52, 0x3d53, 0x3d54, 0x3d55, 0x3d56, 0x3d57, 0x3d58,
+ 0x3d59, 0x3d5a, 0x3d5b, 0x3d5c, 0x3d5d, 0x3d5e, 0x3d5f, 0x3d60,
+ 0x3d61, 0x3d62, 0x3d63, 0x3d64, 0x3d65, 0x3d66, 0x3d67, 0x3d68,
+ 0x3d69, 0x3d6a, 0x3d6b, 0x3d6c, 0x3d6d, 0x3d6e, 0x3d6f, 0x3d70,
+ 0x3d71, 0x3d72, 0x3d73, 0x3d74, 0x3d75, 0x3d76, 0x3d77, 0x3d78,
+ 0x3d79, 0x3d7a, 0x3d7b, 0x3d7c, 0x3d7d, 0x3d7e, 0x3e21, 0x3e22,
+ 0x3e23, 0x3e24, 0x3e25, 0x3e26, 0x3e27, 0x3e28, 0x3e29, 0x3e2a,
+ 0x3e2b, 0x3e2c, 0x3e2d, 0x3e2e, 0x3e2f, 0x3e30, 0x3e31, 0x3e32,
+ 0x3e33, 0x3e34, 0x3e35, 0x3e36, 0x3e37, 0x3e38, 0x3e39, 0x3e3a,
+ 0x3e3b, 0x3e3c, 0x3e3d, 0x3e3e, 0x3e3f, 0x3e40, 0x3e41, 0x3e42,
+ 0x3e43, 0x3e44, 0x3e45, 0x3e46, 0x3e47, 0x3e48, 0x3e49, 0x3e4a,
+ 0x3e4b, 0x3e4c, 0x3e4d, 0x3e4e, 0x3e4f, 0x3e50, 0x3e51, 0x3e52,
+ 0x3e53, 0x3e54, 0x3e55, 0x3e56, 0x3e57, 0x3e58, 0x3e59, 0x3e5a,
+ 0x3e5b, 0x3e5c, 0x3e5d, 0x3e5e, 0x3e5f, 0x3e60, 0x3e61, 0x3e62,
+ 0x3e63, 0x3e64, 0x3e65, 0x3e66, 0x3e67, 0x3e68, 0x3e69, 0x3e6a,
+ 0x3e6b, 0x3e6c, 0x3e6d, 0x3e6e, 0x3e6f, 0x3e70, 0x3e71, 0x3e72,
+ 0x3e73, 0x3e74, 0x3e75, 0x3e76, 0x3e77, 0x3e78, 0x3e79, 0x3e7a,
+ 0x3e7b, 0x3e7c, 0x3e7d, 0x3e7e, 0x3f21, 0x3f22, 0x3f23, 0x3f24,
+ 0x3f25, 0x3f26, 0x3f27, 0x3f28, 0x3f29, 0x3f2a, 0x3f2b, 0x3f2c,
+ 0x3f2d, 0x3f2e, 0x3f2f, 0x3f30, 0x3f31, 0x3f32, 0x3f33, 0x3f34,
+ 0x3f35, 0x3f36, 0x3f37, 0x3f38, 0x3f39, 0x3f3a, 0x3f3b, 0x3f3c,
+ 0x3f3d, 0x3f3e, 0x3f3f, 0x3f40, 0x3f41, 0x3f42, 0x3f43, 0x3f44,
+ 0x3f45, 0x3f46, 0x3f47, 0x3f48, 0x3f49, 0x3f4a, 0x3f4b, 0x3f4c,
+ 0x3f4d, 0x3f4e, 0x3f4f, 0x3f50, 0x3f51, 0x3f52, 0x3f53, 0x3f54,
+ 0x3f55, 0x3f56, 0x3f57, 0x3f58, 0x3f59, 0x3f5a, 0x3f5b, 0x3f5c,
+ 0x3f5d, 0x3f5e, 0x3f5f, 0x3f60, 0x3f61, 0x3f62, 0x3f63, 0x3f64,
+ 0x3f65, 0x3f66, 0x3f67, 0x3f68, 0x3f69, 0x3f6a, 0x3f6b, 0x3f6c,
+ 0x3f6d, 0x3f6e, 0x3f6f, 0x3f70, 0x3f71, 0x3f72, 0x3f73, 0x3f74,
+ 0x3f75, 0x3f76, 0x3f77, 0x3f78, 0x3f79, 0x3f7a, 0x3f7b, 0x3f7c,
+ 0x3f7d, 0x3f7e, 0x4021, 0x4022, 0x4023, 0x4024, 0x4025, 0x4026,
+ 0x4027, 0x4028, 0x4029, 0x402a, 0x402b, 0x402c, 0x402d, 0x402e,
+ 0x402f, 0x4030, 0x4031, 0x4032, 0x4033, 0x4034, 0x4035, 0x4036,
+ 0x4037, 0x4038, 0x4039, 0x403a, 0x403b, 0x403c, 0x403d, 0x403e,
+ 0x403f, 0x4040, 0x4041, 0x4042, 0x4043, 0x4044, 0x4045, 0x4046,
+ 0x4047, 0x4048, 0x4049, 0x404a, 0x404b, 0x404c, 0x404d, 0x404e,
+ 0x404f, 0x4050, 0x4051, 0x4052, 0x4053, 0x4054, 0x4055, 0x4056,
+ 0x4057, 0x4058, 0x4059, 0x405a, 0x405b, 0x405c, 0x405d, 0x405e,
+ 0x405f, 0x4060, 0x4061, 0x4062, 0x4063, 0x4064, 0x4065, 0x4066,
+ 0x4067, 0x4068, 0x4069, 0x406a, 0x406b, 0x406c, 0x406d, 0x406e,
+ 0x406f, 0x4070, 0x4071, 0x4072, 0x4073, 0x4074, 0x4075, 0x4076,
+ 0x4077, 0x4078, 0x4079, 0x407a, 0x407b, 0x407c, 0x407d, 0x407e,
+ 0x4121, 0x4122, 0x4123, 0x4124, 0x4125, 0x4126, 0x4127, 0x4128,
+ 0x4129, 0x412a, 0x412b, 0x412c, 0x412d, 0x412e, 0x412f, 0x4130,
+ 0x4131, 0x4132, 0x4133, 0x4134, 0x4135, 0x4136, 0x4137, 0x4138,
+ 0x4139, 0x413a, 0x413b, 0x413c, 0x413d, 0x413e, 0x413f, 0x4140,
+ 0x4141, 0x4142, 0x4143, 0x4144, 0x4145, 0x4146, 0x4147, 0x4148,
+ 0x4149, 0x414a, 0x414b, 0x414c, 0x414d, 0x414e, 0x414f, 0x4150,
+ 0x4151, 0x4152, 0x4153, 0x4154, 0x4155, 0x4156, 0x4157, 0x4158,
+ 0x4159, 0x415a, 0x415b, 0x415c, 0x415d, 0x415e, 0x415f, 0x4160,
+ 0x4161, 0x4162, 0x4163, 0x4164, 0x4165, 0x4166, 0x4167, 0x4168,
+ 0x4169, 0x416a, 0x416b, 0x416c, 0x416d, 0x416e, 0x416f, 0x4170,
+ 0x4171, 0x4172, 0x4173, 0x4174, 0x4175, 0x4176, 0x4177, 0x4178,
+ 0x4179, 0x417a, 0x417b, 0x417c, 0x417d, 0x417e, 0x4221, 0x4222,
+ 0x4223, 0x4224, 0x4225, 0x4226, 0x4227, 0x4228, 0x4229, 0x422a,
+ 0x422b, 0x422c, 0x422d, 0x422e, 0x422f, 0x4230, 0x4231, 0x4232,
+ 0x4233, 0x4234, 0x4235, 0x4236, 0x4237, 0x4238, 0x4239, 0x423a,
+ 0x423b, 0x423c, 0x423d, 0x423e, 0x423f, 0x4240, 0x4241, 0x4242,
+ 0x4243, 0x4244, 0x4245, 0x4246, 0x4247, 0x4248, 0x4249, 0x424a,
+ 0x424b, 0x424c, 0x424d, 0x424e, 0x424f, 0x4250, 0x4251, 0x4252,
+ 0x4253, 0x4254, 0x4255, 0x4256, 0x4257, 0x4258, 0x4259, 0x425a,
+ 0x425b, 0x425c, 0x425d, 0x425e, 0x425f, 0x4260, 0x4261, 0x4262,
+ 0x4263, 0x4264, 0x4265, 0x4266, 0x4267, 0x4268, 0x4269, 0x426a,
+ 0x426b, 0x426c, 0x426d, 0x426e, 0x426f, 0x4270, 0x4271, 0x4272,
+ 0x4273, 0x4274, 0x4275, 0x4276, 0x4277, 0x4278, 0x4279, 0x427a,
+ 0x427b, 0x427c, 0x427d, 0x427e, 0x4321, 0x4322, 0x4323, 0x4324,
+ 0x4325, 0x4326, 0x4327, 0x4328, 0x4329, 0x432a, 0x432b, 0x432c,
+ 0x432d, 0x432e, 0x432f, 0x4330, 0x4331, 0x4332, 0x4333, 0x4334,
+ 0x4335, 0x4336, 0x4337, 0x4338, 0x4339, 0x433a, 0x433b, 0x433c,
+ 0x433d, 0x433e, 0x433f, 0x4340, 0x4341, 0x4342, 0x4343, 0x4344,
+ 0x4345, 0x4346, 0x4347, 0x4348, 0x4349, 0x434a, 0x434b, 0x434c,
+ 0x434d, 0x434e, 0x434f, 0x4350, 0x4351, 0x4352, 0x4353, 0x4354,
+ 0x4355, 0x4356, 0x4357, 0x4358, 0x4359, 0x435a, 0x435b, 0x435c,
+ 0x435d, 0x435e, 0x435f, 0x4360, 0x4361, 0x4362, 0x4363, 0x4364,
+ 0x4365, 0x4366, 0x4367, 0x4368, 0x4369, 0x436a, 0x436b, 0x436c,
+ 0x436d, 0x436e, 0x436f, 0x4370, 0x4371, 0x4372, 0x4373, 0x4374,
+ 0x4375, 0x4376, 0x4377, 0x4378, 0x4379, 0x437a, 0x437b, 0x437c,
+ 0x437d, 0x437e, 0x4421, 0x4422, 0x4423, 0x4424, 0x4425, 0x4426,
+ 0x4427, 0x4428, 0x4429, 0x442a, 0x442b, 0x442c, 0x442d, 0x442e,
+ 0x442f, 0x4430, 0x4431, 0x4432, 0x4433, 0x4434, 0x4435, 0x4436,
+ 0x4437, 0x4438, 0x4439, 0x443a, 0x443b, 0x443c, 0x443d, 0x443e,
+ 0x443f, 0x4440, 0x4441, 0x4442, 0x4443, 0x4444, 0x4445, 0x4446,
+ 0x4447, 0x4448, 0x4449, 0x444a, 0x444b, 0x444c, 0x444d, 0x444e,
+ 0x444f, 0x4450, 0x4451, 0x4452, 0x4453, 0x4454, 0x4455, 0x4456,
+ 0x4457, 0x4458, 0x4459, 0x445a, 0x445b, 0x445c, 0x445d, 0x445e,
+ 0x445f, 0x4460, 0x4461, 0x4462, 0x4463, 0x4464, 0x4465, 0x4466,
+ 0x4467, 0x4468, 0x4469, 0x446a, 0x446b, 0x446c, 0x446d, 0x446e,
+ 0x446f, 0x4470, 0x4471, 0x4472, 0x4473, 0x4474, 0x4475, 0x4476,
+ 0x4477, 0x4478, 0x4479, 0x447a, 0x447b, 0x447c, 0x447d, 0x447e,
+ 0x4521, 0x4522, 0x4523, 0x4524, 0x4525, 0x4526, 0x4527, 0x4528,
+ 0x4529, 0x452a, 0x452b, 0x452c, 0x452d, 0x452e, 0x452f, 0x4530,
+ 0x4531, 0x4532, 0x4533, 0x4534, 0x4535, 0x4536, 0x4537, 0x4538,
+ 0x4539, 0x453a, 0x453b, 0x453c, 0x453d, 0x453e, 0x453f, 0x4540,
+ 0x4541, 0x4542, 0x4543, 0x4544, 0x4545, 0x4546, 0x4547, 0x4548,
+ 0x4549, 0x454a, 0x454b, 0x454c, 0x454d, 0x454e, 0x454f, 0x4550,
+ 0x4551, 0x4552, 0x4553, 0x4554, 0x4555, 0x4556, 0x4557, 0x4558,
+ 0x4559, 0x455a, 0x455b, 0x455c, 0x455d, 0x455e, 0x455f, 0x4560,
+ 0x4561, 0x4562, 0x4563, 0x4564, 0x4565, 0x4566, 0x4567, 0x4568,
+ 0x4569, 0x456a, 0x456b, 0x456c, 0x456d, 0x456e, 0x456f, 0x4570,
+ 0x4571, 0x4572, 0x4573, 0x4574, 0x4575, 0x4576, 0x4577, 0x4578,
+ 0x4579, 0x457a, 0x457b, 0x457c, 0x457d, 0x457e, 0x4621, 0x4622,
+ 0x4623, 0x4624, 0x4625, 0x4626, 0x4627, 0x4628, 0x4629, 0x462a,
+ 0x462b, 0x462c, 0x462d, 0x462e, 0x462f, 0x4630, 0x4631, 0x4632,
+ 0x4633, 0x4634, 0x4635, 0x4636, 0x4637, 0x4638, 0x4639, 0x463a,
+ 0x463b, 0x463c, 0x463d, 0x463e, 0x463f, 0x4640, 0x4641, 0x4642,
+ 0x4643, 0x4644, 0x4645, 0x4646, 0x4647, 0x4648, 0x4649, 0x464a,
+ 0x464b, 0x464c, 0x464d, 0x464e, 0x464f, 0x4650, 0x4651, 0x4652,
+ 0x4653, 0x4654, 0x4655, 0x4656, 0x4657, 0x4658, 0x4659, 0x465a,
+ 0x465b, 0x465c, 0x465d, 0x465e, 0x465f, 0x4660, 0x4661, 0x4662,
+ 0x4663, 0x4664, 0x4665, 0x4666, 0x4667, 0x4668, 0x4669, 0x466a,
+ 0x466b, 0x466c, 0x466d, 0x466e, 0x466f, 0x4670, 0x4671, 0x4672,
+ 0x4673, 0x4674, 0x4675, 0x4676, 0x4677, 0x4678, 0x4679, 0x467a,
+ 0x467b, 0x467c, 0x467d, 0x467e, 0x4721, 0x4722, 0x4723, 0x4724,
+ 0x4725, 0x4726, 0x4727, 0x4728, 0x4729, 0x472a, 0x472b, 0x472c,
+ 0x472d, 0x472e, 0x472f, 0x4730, 0x4731, 0x4732, 0x4733, 0x4734,
+ 0x4735, 0x4736, 0x4737, 0x4738, 0x4739, 0x473a, 0x473b, 0x473c,
+ 0x473d, 0x473e, 0x473f, 0x4740, 0x4741, 0x4742, 0x4743, 0x4744,
+ 0x4745, 0x4746, 0x4747, 0x4748, 0x4749, 0x474a, 0x474b, 0x474c,
+ 0x474d, 0x474e, 0x474f, 0x4750, 0x4751, 0x4752, 0x4753, 0x4754,
+ 0x4755, 0x4756, 0x4757, 0x4758, 0x4759, 0x475a, 0x475b, 0x475c,
+ 0x475d, 0x475e, 0x475f, 0x4760, 0x4761, 0x4762, 0x4763, 0x4764,
+ 0x4765, 0x4766, 0x4767, 0x4768, 0x4769, 0x476a, 0x476b, 0x476c,
+ 0x476d, 0x476e, 0x476f, 0x4770, 0x4771, 0x4772, 0x4773, 0x4774,
+ 0x4775, 0x4776, 0x4777, 0x4778, 0x4779, 0x477a, 0x477b, 0x477c,
+ 0x477d, 0x477e, 0x4821, 0x4822, 0x4823, 0x4824, 0x4825, 0x4826,
+ 0x4827, 0x4828, 0x4829, 0x482a, 0x482b, 0x482c, 0x482d, 0x482e,
+ 0x482f, 0x4830, 0x4831, 0x4832, 0x4833, 0x4834, 0x4835, 0x4836,
+ 0x4837, 0x4838, 0x4839, 0x483a, 0x483b, 0x483c, 0x483d, 0x483e,
+ 0x483f, 0x4840, 0x4841, 0x4842, 0x4843, 0x4844, 0x4845, 0x4846,
+ 0x4847, 0x4848, 0x4849, 0x484a, 0x484b, 0x484c, 0x484d, 0x484e,
+ 0x484f, 0x4850, 0x4851, 0x4852, 0x4853, 0x4854, 0x4855, 0x4856,
+ 0x4857, 0x4858, 0x4859, 0x485a, 0x485b, 0x485c, 0x485d, 0x485e,
+ 0x485f, 0x4860, 0x4861, 0x4862, 0x4863, 0x4864, 0x4865, 0x4866,
+ 0x4867, 0x4868, 0x4869, 0x486a, 0x486b, 0x486c, 0x486d, 0x486e,
+ 0x486f, 0x4870, 0x4871, 0x4872, 0x4873, 0x4874, 0x4875, 0x4876,
+ 0x4877, 0x4878, 0x4879, 0x487a, 0x487b, 0x487c, 0x487d, 0x487e,
+ 0x4b50, 0x4b56, 0x4b67, 0x4d4f, 0x4d68, 0x4e2d, 0x4f7b, 0x5022,
+ 0x5038, 0x5050, 0x505d, 0x5154, 0x5155, 0x5158, 0x515b, 0x515c,
+ 0x515d, 0x515e, 0x515f, 0x5160, 0x5162, 0x5163, 0x5164, 0x5165,
+ 0x5166, 0x5168, 0x5169, 0x516a, 0x516b, 0x516d, 0x516f, 0x5170,
+ 0x5172, 0x5176, 0x517a, 0x517c, 0x517d, 0x517e, 0x5222, 0x5223,
+ 0x5227, 0x5228, 0x5229, 0x522a, 0x522b, 0x522d, 0x5232, 0x523e,
+ 0x5242, 0x5243, 0x5244, 0x5246, 0x5247, 0x5248, 0x5249, 0x524a,
+ 0x524b, 0x524d, 0x524e, 0x524f, 0x5250, 0x5251, 0x5252, 0x5253,
+ 0x5254, 0x5255, 0x5256, 0x5257, 0x5259, 0x525a, 0x525e, 0x525f,
+ 0x5261, 0x5262, 0x5264, 0x5265, 0x5266, 0x5267, 0x5268, 0x5269,
+ 0x526a, 0x526b, 0x5270, 0x5271, 0x5272, 0x5273, 0x5274, 0x5275,
+ 0x5277, 0x5278, 0x5466, 0x547c, 0x5525, 0x552b, 0x552e, 0x5638,
+ 0x564d, 0x574b, 0x5764, 0x5b45, 0x5b64, 0x5c25, 0x5d25, 0x5d55,
+ 0x5d74, 0x5e7c, 0x5e7e, 0x5f33, 0x5f61, 0x5f68, 0x6071, 0x612d,
+ 0x616d, 0x6375, 0x6421, 0x6429, 0x652e, 0x6531, 0x6532, 0x6539,
+ 0x653b, 0x653c, 0x6544, 0x654e, 0x6550, 0x6552, 0x6556, 0x657a,
+ 0x657b, 0x657c, 0x657e, 0x6621, 0x6624, 0x6627, 0x662d, 0x662f,
+ 0x6630, 0x6631, 0x6633, 0x6637, 0x6638, 0x663c, 0x6644, 0x6646,
+ 0x6647, 0x664a, 0x6652, 0x6656, 0x6659, 0x665c, 0x665f, 0x6661,
+ 0x6664, 0x6665, 0x6666, 0x6668, 0x666a, 0x666b, 0x666c, 0x666f,
+ 0x6671, 0x6672, 0x6675, 0x6676, 0x6677, 0x6679, 0x6721, 0x6726,
+ 0x6729, 0x672a, 0x672c, 0x672d, 0x6730, 0x673f, 0x6741, 0x6746,
+ 0x6747, 0x674b, 0x674d, 0x674f, 0x6750, 0x6753, 0x675f, 0x6764,
+ 0x6766, 0x6777, 0x6867, 0x6868, 0x6870, 0x6871, 0x6877, 0x6879,
+ 0x687b, 0x687e, 0x6927, 0x692c, 0x694c, 0x6977, 0x6a41, 0x6a65,
+ 0x6a74, 0x6a77, 0x6a7c, 0x6a7e, 0x6b24, 0x6b27, 0x6b29, 0x6b2a,
+ 0x6b3a, 0x6b3b, 0x6b3d, 0x6b41, 0x6b42, 0x6b46, 0x6b47, 0x6b4c,
+ 0x6b4f, 0x6b50, 0x6b51, 0x6b52, 0x6b58, 0x6c26, 0x6c27, 0x6c2a,
+ 0x6c2f, 0x6c30, 0x6c31, 0x6c32, 0x6c35, 0x6c38, 0x6c3a, 0x6c40,
+ 0x6c41, 0x6c45, 0x6c46, 0x6c49, 0x6c4a, 0x6c55, 0x6c5d, 0x6c5e,
+ 0x6c61, 0x6c64, 0x6c67, 0x6c68, 0x6c77, 0x6c78, 0x6c7a, 0x6d21,
+ 0x6d22, 0x6d23, 0x6d6e, 0x6e5b, 0x723d, 0x727a, 0x7331, 0x7427,
+ 0x746e, 0x7674, 0x7676, 0x7738, 0x7748, 0x7753, 0x785b, 0x7870,
+ 0x7a21, 0x7a22, 0x7a66, 0x7c29, 0x2321, 0x2322, 0x2323, 0x2324,
+ 0x2325, 0x2326, 0x2327, 0x2328, 0x2329, 0x232a, 0x232b, 0x232c,
+ 0x232d, 0x232e, 0x232f, 0x2330, 0x2331, 0x2332, 0x2333, 0x2334,
+ 0x2335, 0x2336, 0x2337, 0x2338, 0x2339, 0x233a, 0x233b, 0x233c,
+ 0x233d, 0x233e, 0x233f, 0x2340, 0x2341, 0x2342, 0x2343, 0x2344,
+ 0x2345, 0x2346, 0x2347, 0x2348, 0x2349, 0x234a, 0x234b, 0x234c,
+ 0x234d, 0x234e, 0x234f, 0x2350, 0x2351, 0x2352, 0x2353, 0x2354,
+ 0x2355, 0x2356, 0x2357, 0x2358, 0x2359, 0x235a, 0x235b, 0x212c,
+ 0x235d, 0x235e, 0x235f, 0x2360, 0x2361, 0x2362, 0x2363, 0x2364,
+ 0x2365, 0x2366, 0x2367, 0x2368, 0x2369, 0x236a, 0x236b, 0x236c,
+ 0x236d, 0x236e, 0x236f, 0x2370, 0x2371, 0x2372, 0x2373, 0x2374,
+ 0x2375, 0x2376, 0x2377, 0x2378, 0x2379, 0x237a, 0x237b, 0x237c,
+ 0x237d, 0x2226, 0x214b, 0x214c, 0x217e, 0x237e, 0x214d, 0x235c,
+};
+
+static const Summary16 ksc5601_uni2indx_page00[70] = {
+ /* 0x0000 */
+ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
+ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
+ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x2592 }, { 6, 0xf7df },
+ { 20, 0x0040 }, { 21, 0xc181 }, { 26, 0x0040 }, { 27, 0x4181 },
+ /* 0x0100 */
+ { 31, 0x0000 }, { 31, 0x0002 }, { 32, 0x00c0 }, { 34, 0x810e },
+ { 39, 0x0e07 }, { 45, 0x000c }, { 47, 0x00c0 }, { 49, 0x0000 },
+ { 49, 0x0000 }, { 49, 0x0000 }, { 49, 0x0000 }, { 49, 0x0000 },
+ { 49, 0x0000 }, { 49, 0x0000 }, { 49, 0x0000 }, { 49, 0x0000 },
+ /* 0x0200 */
+ { 49, 0x0000 }, { 49, 0x0000 }, { 49, 0x0000 }, { 49, 0x0000 },
+ { 49, 0x0000 }, { 49, 0x0000 }, { 49, 0x0000 }, { 49, 0x0000 },
+ { 49, 0x0000 }, { 49, 0x0000 }, { 49, 0x0000 }, { 49, 0x0000 },
+ { 49, 0x0080 }, { 50, 0x2f01 }, { 56, 0x0000 }, { 56, 0x0000 },
+ /* 0x0300 */
+ { 56, 0x0000 }, { 56, 0x0000 }, { 56, 0x0000 }, { 56, 0x0000 },
+ { 56, 0x0000 }, { 56, 0x0000 }, { 56, 0x0000 }, { 56, 0x0000 },
+ { 56, 0x0000 }, { 56, 0xfffe }, { 71, 0x03fb }, { 80, 0xfffe },
+ { 95, 0x03fb }, { 104, 0x0000 }, { 104, 0x0000 }, { 104, 0x0000 },
+ /* 0x0400 */
+ { 104, 0x0002 }, { 105, 0xffff }, { 121, 0xffff }, { 137, 0xffff },
+ { 153, 0xffff }, { 169, 0x0002 },
+};
+static const Summary16 ksc5601_uni2indx_page20[103] = {
+ /* 0x2000 */
+ { 170, 0x0000 }, { 170, 0x3320 }, { 175, 0x0063 }, { 179, 0x080d },
+ { 183, 0x0000 }, { 183, 0x0000 }, { 183, 0x0000 }, { 183, 0x8010 },
+ { 185, 0x001e }, { 189, 0x0000 }, { 189, 0x0000 }, { 189, 0x0000 },
+ { 189, 0x0000 }, { 189, 0x0000 }, { 189, 0x0000 }, { 189, 0x0000 },
+ /* 0x2100 */
+ { 189, 0x0208 }, { 191, 0x0048 }, { 193, 0x0846 }, { 197, 0x0000 },
+ { 197, 0x0000 }, { 197, 0x7818 }, { 203, 0x03ff }, { 213, 0x03ff },
+ { 223, 0x0000 }, { 223, 0x03ff }, { 233, 0x0000 }, { 233, 0x0000 },
+ { 233, 0x0000 }, { 233, 0x0014 }, { 235, 0x0000 }, { 235, 0x0000 },
+ /* 0x2200 */
+ { 235, 0x898d }, { 242, 0x6402 }, { 246, 0x5fa1 }, { 255, 0x3030 },
+ { 259, 0x0000 }, { 259, 0x0004 }, { 260, 0x0c33 }, { 266, 0x0000 },
+ { 266, 0x00cc }, { 270, 0x0200 }, { 271, 0x0020 }, { 272, 0x0000 },
+ { 272, 0x0000 }, { 272, 0x0000 }, { 272, 0x0000 }, { 272, 0x0000 },
+ /* 0x2300 */
+ { 272, 0x0000 }, { 272, 0x0004 }, { 273, 0x0000 }, { 273, 0x0000 },
+ { 273, 0x0000 }, { 273, 0x0000 }, { 273, 0x0000 }, { 273, 0x0000 },
+ { 273, 0x0000 }, { 273, 0x0000 }, { 273, 0x0000 }, { 273, 0x0000 },
+ { 273, 0x0000 }, { 273, 0x0000 }, { 273, 0x0000 }, { 273, 0x0000 },
+ /* 0x2400 */
+ { 273, 0x0000 }, { 273, 0x0000 }, { 273, 0x0000 }, { 273, 0x0000 },
+ { 273, 0x0000 }, { 273, 0x0000 }, { 273, 0x7fff }, { 288, 0xfff0 },
+ { 300, 0x0007 }, { 303, 0xf000 }, { 307, 0xffff }, { 323, 0x003f },
+ { 329, 0x0000 }, { 329, 0xffff }, { 345, 0x03ff }, { 355, 0x0000 },
+ /* 0x2500 */
+ { 355, 0xf00f }, { 363, 0xffff }, { 379, 0xffff }, { 395, 0xffff },
+ { 411, 0x0fff }, { 423, 0x0000 }, { 423, 0x0000 }, { 423, 0x0000 },
+ { 423, 0x0000 }, { 423, 0x0004 }, { 424, 0x03fb }, { 433, 0x30cc },
+ { 439, 0xc9c3 }, { 447, 0x0003 }, { 449, 0x0000 }, { 449, 0x0000 },
+ /* 0x2600 */
+ { 449, 0xc060 }, { 453, 0x5000 }, { 455, 0x0000 }, { 455, 0x0000 },
+ { 455, 0x0005 }, { 457, 0x0000 }, { 457, 0x37bb },
+};
+static const Summary16 ksc5601_uni2indx_page30[62] = {
+ /* 0x3000 */
+ { 468, 0xff0f }, { 480, 0x003b }, { 485, 0x0000 }, { 485, 0x0000 },
+ { 485, 0xfffe }, { 500, 0xffff }, { 516, 0xffff }, { 532, 0xffff },
+ { 548, 0xffff }, { 564, 0x000f }, { 568, 0xfffe }, { 583, 0xffff },
+ { 599, 0xffff }, { 615, 0xffff }, { 631, 0xffff }, { 647, 0x007f },
+ /* 0x3100 */
+ { 654, 0x0000 }, { 654, 0x0000 }, { 654, 0x0000 }, { 654, 0xfffe },
+ { 669, 0xffff }, { 685, 0xffff }, { 701, 0xffff }, { 717, 0xffff },
+ { 733, 0x7fff }, { 748, 0x0000 }, { 748, 0x0000 }, { 748, 0x0000 },
+ { 748, 0x0000 }, { 748, 0x0000 }, { 748, 0x0000 }, { 748, 0x0000 },
+ /* 0x3200 */
+ { 748, 0xffff }, { 764, 0x1fff }, { 777, 0x0000 }, { 777, 0x0000 },
+ { 777, 0x0000 }, { 777, 0x0000 }, { 777, 0xffff }, { 793, 0x8fff },
+ { 806, 0x0000 }, { 806, 0x0000 }, { 806, 0x0000 }, { 806, 0x0000 },
+ { 806, 0x0000 }, { 806, 0x0000 }, { 806, 0x0000 }, { 806, 0x0000 },
+ /* 0x3300 */
+ { 806, 0x0000 }, { 806, 0x0000 }, { 806, 0x0000 }, { 806, 0x0000 },
+ { 806, 0x0000 }, { 806, 0x0000 }, { 806, 0x0000 }, { 806, 0x0000 },
+ { 806, 0xff1f }, { 819, 0xffff }, { 835, 0xffff }, { 851, 0xffff },
+ { 867, 0x87ff }, { 879, 0x3949 },
+};
+static const Summary16 ksc5601_uni2indx_page4e[1306] = {
+ /* 0x4e00 */
+ { 886, 0x2f8b }, { 895, 0x4372 }, { 902, 0x2000 }, { 903, 0x0b04 },
+ { 907, 0xe82c }, { 914, 0xe340 }, { 920, 0x2800 }, { 922, 0x40c8 },
+ { 926, 0x5944 }, { 932, 0x4937 }, { 940, 0x7976 }, { 950, 0x0440 },
+ { 952, 0x2c93 }, { 959, 0xa3f0 }, { 967, 0x0038 }, { 970, 0x08c5 },
+ /* 0x4f00 */
+ { 975, 0xee02 }, { 982, 0x0003 }, { 984, 0x8000 }, { 985, 0x3550 },
+ { 991, 0xe1c8 }, { 998, 0x1e23 }, { 1005, 0x8200 }, { 1007, 0xc449 },
+ { 1013, 0xad5a }, { 1022, 0x2942 }, { 1027, 0xc000 }, { 1029, 0x8060 },
+ { 1032, 0x461c }, { 1038, 0xa49a }, { 1045, 0xc003 }, { 1049, 0x052a },
+ /* 0x5000 */
+ { 1054, 0x2a44 }, { 1059, 0xd646 }, { 1067, 0x3dda }, { 1077, 0x0800 },
+ { 1078, 0x8388 }, { 1083, 0x1420 }, { 1086, 0x0020 }, { 1087, 0x0170 },
+ { 1091, 0x2021 }, { 1094, 0x0302 }, { 1097, 0x3000 }, { 1099, 0x40ac },
+ { 1104, 0x8620 }, { 1108, 0x4462 }, { 1113, 0x20a0 }, { 1116, 0x8a00 },
+ /* 0x5100 */
+ { 1119, 0x0253 }, { 1124, 0x8004 }, { 1126, 0x0402 }, { 1128, 0x1484 },
+ { 1132, 0x7bfb }, { 1145, 0x1004 }, { 1147, 0x7fa4 }, { 1157, 0x11e2 },
+ { 1163, 0x2441 }, { 1167, 0x00a4 }, { 1170, 0x1421 }, { 1174, 0x20c0 },
+ { 1177, 0x3a50 }, { 1183, 0x7000 }, { 1186, 0x0002 }, { 1187, 0x2743 },
+ /* 0x5200 */
+ { 1194, 0x45c9 }, { 1201, 0x2082 }, { 1204, 0x4630 }, { 1209, 0x0fc1 },
+ { 1216, 0x3c88 }, { 1222, 0x2850 }, { 1226, 0x8602 }, { 1230, 0xa024 },
+ { 1234, 0x2388 }, { 1239, 0x8806 }, { 1243, 0x0e19 }, { 1249, 0x4000 },
+ { 1250, 0x22aa }, { 1256, 0xeb64 }, { 1265, 0x001c }, { 1268, 0xcd28 },
+ /* 0x5300 */
+ { 1275, 0xa120 }, { 1279, 0x02e1 }, { 1284, 0x840b }, { 1289, 0x8200 },
+ { 1291, 0x279b }, { 1300, 0x549e }, { 1308, 0x8141 }, { 1312, 0xa0b3 },
+ { 1319, 0x0010 }, { 1320, 0x8508 }, { 1324, 0x2061 }, { 1328, 0x0800 },
+ { 1329, 0x2f08 }, { 1335, 0x08d0 }, { 1339, 0xbe3e }, { 1350, 0x010f },
+ /* 0x5400 */
+ { 1355, 0xf718 }, { 1364, 0xa803 }, { 1369, 0x0a41 }, { 1373, 0x5b08 },
+ { 1379, 0x0504 }, { 1382, 0x0002 }, { 1383, 0x0500 }, { 1385, 0x382a },
+ { 1391, 0x5041 }, { 1395, 0x0001 }, { 1396, 0x1910 }, { 1400, 0x2108 },
+ { 1403, 0x0313 }, { 1408, 0x0000 }, { 1408, 0x6122 }, { 1413, 0x0404 },
+ /* 0x5500 */
+ { 1415, 0x40d0 }, { 1419, 0x1001 }, { 1421, 0x8000 }, { 1422, 0x4022 },
+ { 1425, 0x8050 }, { 1428, 0x4048 }, { 1431, 0x0008 }, { 1432, 0x1000 },
+ { 1433, 0x06d1 }, { 1439, 0x3700 }, { 1444, 0x5e80 }, { 1450, 0x0000 },
+ { 1450, 0x00a0 }, { 1452, 0x9410 }, { 1456, 0x0018 }, { 1458, 0x6000 },
+ /* 0x5600 */
+ { 1460, 0x0240 }, { 1462, 0x0090 }, { 1464, 0x8000 }, { 1465, 0x0054 },
+ { 1468, 0x0000 }, { 1468, 0x0008 }, { 1469, 0x0900 }, { 1471, 0x0010 },
+ { 1472, 0x0040 }, { 1473, 0x0000 }, { 1473, 0x5020 }, { 1476, 0x1010 },
+ { 1478, 0x2400 }, { 1480, 0x4c02 }, { 1484, 0x0001 }, { 1485, 0x0601 },
+ /* 0x5700 */
+ { 1488, 0x2918 }, { 1493, 0x814c }, { 1498, 0x2100 }, { 1500, 0x0801 },
+ { 1502, 0x6485 }, { 1508, 0x0003 }, { 1510, 0x4452 }, { 1515, 0x1021 },
+ { 1518, 0x0904 }, { 1521, 0x0008 }, { 1522, 0x000d }, { 1525, 0x0000 },
+ { 1525, 0x4988 }, { 1530, 0x8000 }, { 1531, 0x0001 }, { 1532, 0x1691 },
+ /* 0x5800 */
+ { 1538, 0x0765 }, { 1545, 0x4000 }, { 1546, 0x8492 }, { 1551, 0x0433 },
+ { 1556, 0x8c00 }, { 1559, 0x4592 }, { 1565, 0x0016 }, { 1568, 0x5220 },
+ { 1572, 0x0228 }, { 1575, 0xd008 }, { 1579, 0x4300 }, { 1582, 0x4c08 },
+ { 1586, 0x40a2 }, { 1590, 0xc32a }, { 1597, 0x9810 }, { 1601, 0x2e00 },
+ /* 0x5900 */
+ { 1605, 0x8000 }, { 1606, 0x1670 }, { 1612, 0x6e84 }, { 1619, 0x4082 },
+ { 1622, 0xc390 }, { 1628, 0x04b3 }, { 1634, 0x7c85 }, { 1642, 0x2118 },
+ { 1646, 0x041c }, { 1650, 0x02c8 }, { 1654, 0x1120 }, { 1657, 0x4a00 },
+ { 1660, 0x0a48 }, { 1664, 0x361b }, { 1672, 0x5540 }, { 1677, 0x8900 },
+ /* 0x5a00 */
+ { 1680, 0x000a }, { 1682, 0x9902 }, { 1687, 0x0221 }, { 1690, 0x1040 },
+ { 1692, 0x0242 }, { 1695, 0x0400 }, { 1696, 0x0044 }, { 1698, 0x0000 },
+ { 1698, 0x0000 }, { 1698, 0x0c04 }, { 1701, 0x0010 }, { 1702, 0x0000 },
+ { 1702, 0x1216 }, { 1707, 0x0000 }, { 1707, 0x0242 }, { 1710, 0x0000 },
+ /* 0x5b00 */
+ { 1710, 0x1a20 }, { 1714, 0x0040 }, { 1715, 0x0400 }, { 1716, 0x0000 },
+ { 1716, 0x0009 }, { 1718, 0xb5b3 }, { 1728, 0x0a18 }, { 1732, 0x1523 },
+ { 1738, 0x9ba0 }, { 1745, 0x1fe8 }, { 1754, 0x507c }, { 1761, 0x8379 },
+ { 1769, 0x10fd }, { 1777, 0xc09d }, { 1784, 0xdbf6 }, { 1796, 0x0560 },
+ /* 0x5c00 */
+ { 1800, 0xef92 }, { 1810, 0x0242 }, { 1813, 0x0110 }, { 1815, 0xdf02 },
+ { 1823, 0x6961 }, { 1830, 0x0822 }, { 1833, 0x9035 }, { 1839, 0x0202 },
+ { 1841, 0x0000 }, { 1841, 0x0003 }, { 1843, 0x1a02 }, { 1847, 0x45aa },
+ { 1854, 0x0001 }, { 1855, 0x0200 }, { 1856, 0x8101 }, { 1859, 0x2851 },
+ /* 0x5d00 */
+ { 1864, 0x6080 }, { 1867, 0x02d2 }, { 1872, 0x0280 }, { 1874, 0x0000 },
+ { 1874, 0x1800 }, { 1876, 0x0001 }, { 1877, 0x9200 }, { 1880, 0x0000 },
+ { 1880, 0x0880 }, { 1882, 0x2000 }, { 1883, 0x0405 }, { 1886, 0x3500 },
+ { 1890, 0x2000 }, { 1891, 0x6044 }, { 1895, 0x49e6 }, { 1903, 0x609e },
+ /* 0x5e00 */
+ { 1910, 0x104c }, { 1914, 0x2a42 }, { 1919, 0x2820 }, { 1922, 0xa148 },
+ { 1927, 0x10b1 }, { 1932, 0x8020 }, { 1934, 0x000e }, { 1937, 0x7b9c },
+ { 1947, 0x8490 }, { 1951, 0x14a0 }, { 1955, 0x28c1 }, { 1960, 0x41e0 },
+ { 1965, 0x0704 }, { 1969, 0x8c49 }, { 1975, 0x100d }, { 1979, 0x0cc8 },
+ /* 0x5f00 */
+ { 1984, 0x8412 }, { 1988, 0x89ba }, { 1996, 0x02c0 }, { 1999, 0x1422 },
+ { 2003, 0x5500 }, { 2007, 0x0ac0 }, { 2011, 0x3ec4 }, { 2019, 0x9283 },
+ { 2025, 0x1ca3 }, { 2032, 0x4387 }, { 2039, 0x4703 }, { 2045, 0x22a0 },
+ { 2049, 0x3028 }, { 2053, 0x03c0 }, { 2057, 0x0801 }, { 2059, 0xa020 },
+ /* 0x6000 */
+ { 2062, 0x8000 }, { 2063, 0x3044 }, { 2067, 0x85a3 }, { 2074, 0x0000 },
+ { 2074, 0x200e }, { 2078, 0x2225 }, { 2083, 0xb73c }, { 2093, 0x0001 },
+ { 2094, 0x3220 }, { 2098, 0x8c50 }, { 2103, 0x0099 }, { 2107, 0x315d },
+ { 2115, 0x00a0 }, { 2117, 0x9402 }, { 2121, 0x0003 }, { 2123, 0x0e4b },
+ /* 0x6100 */
+ { 2130, 0xe342 }, { 2137, 0x8c20 }, { 2141, 0x0080 }, { 2142, 0xd091 },
+ { 2148, 0x1d94 }, { 2155, 0xa328 }, { 2161, 0x499c }, { 2168, 0x60c1 },
+ { 2173, 0x4406 }, { 2177, 0x0713 }, { 2183, 0x5a90 }, { 2189, 0x4444 },
+ { 2193, 0x0f88 }, { 2199, 0x0000 }, { 2199, 0x0040 }, { 2200, 0x95c4 },
+ /* 0x6200 */
+ { 2207, 0x7581 }, { 2214, 0x8447 }, { 2220, 0x4402 }, { 2223, 0xc053 },
+ { 2229, 0x2b83 }, { 2236, 0x0108 }, { 2238, 0x4000 }, { 2239, 0x9242 },
+ { 2244, 0x0611 }, { 2248, 0x09a6 }, { 2254, 0x0800 }, { 2255, 0x3222 },
+ { 2260, 0xb384 }, { 2267, 0x1bdd }, { 2277, 0xf000 }, { 2281, 0xc08a },
+ /* 0x6300 */
+ { 2286, 0x0282 }, { 2289, 0x0002 }, { 2290, 0x8800 }, { 2292, 0x6c00 },
+ { 2296, 0x9200 }, { 2299, 0x0021 }, { 2301, 0x4180 }, { 2304, 0x8c84 },
+ { 2309, 0x1308 }, { 2313, 0x0944 }, { 2317, 0x07a7 }, { 2325, 0x0000 },
+ { 2325, 0x8051 }, { 2329, 0x0c41 }, { 2333, 0x6002 }, { 2336, 0x00d0 },
+ /* 0x6400 */
+ { 2339, 0xa000 }, { 2341, 0x10d0 }, { 2345, 0x3004 }, { 2348, 0x4400 },
+ { 2350, 0x0000 }, { 2350, 0x0100 }, { 2351, 0x8201 }, { 2354, 0x0700 },
+ { 2357, 0x0100 }, { 2358, 0x440e }, { 2363, 0x6830 }, { 2368, 0x0805 },
+ { 2371, 0x64b2 }, { 2378, 0x0514 }, { 2382, 0x10e6 }, { 2388, 0x4414 },
+ /* 0x6500 */
+ { 2392, 0x0011 }, { 2394, 0x2100 }, { 2396, 0x9c08 }, { 2401, 0xcbc0 },
+ { 2408, 0xe120 }, { 2413, 0x40c2 }, { 2417, 0x304c }, { 2422, 0x41b4 },
+ { 2428, 0x10ac }, { 2433, 0x9a83 }, { 2440, 0x98b2 }, { 2447, 0x3281 },
+ { 2452, 0x9822 }, { 2457, 0x0084 }, { 2459, 0x3369 }, { 2467, 0xbc12 },
+ /* 0x6600 */
+ { 2474, 0xd6c0 }, { 2481, 0xc03b }, { 2488, 0xa1a1 }, { 2494, 0x0c53 },
+ { 2500, 0x8a1e }, { 2507, 0xea00 }, { 2512, 0xcbf0 }, { 2521, 0x05d8 },
+ { 2527, 0x4390 }, { 2532, 0x21c3 }, { 2538, 0x4805 }, { 2542, 0x4a1c },
+ { 2548, 0x02d0 }, { 2552, 0x3240 }, { 2556, 0x0041 }, { 2558, 0xd79d },
+ /* 0x6700 */
+ { 2569, 0x2b09 }, { 2575, 0xe8b0 }, { 2582, 0x7dc0 }, { 2590, 0x2452 },
+ { 2595, 0xc240 }, { 2599, 0xd04b }, { 2606, 0xa000 }, { 2608, 0xc8ab },
+ { 2616, 0x8a80 }, { 2620, 0x34a9 }, { 2627, 0x8000 }, { 2628, 0x41c9 },
+ { 2634, 0x8010 }, { 2636, 0x241f }, { 2643, 0x9200 }, { 2646, 0x487b },
+ /* 0x6800 */
+ { 2654, 0x0000 }, { 2654, 0x00cc }, { 2658, 0x8406 }, { 2662, 0x3300 },
+ { 2666, 0x410f }, { 2672, 0x001b }, { 2676, 0x2000 }, { 2677, 0x8040 },
+ { 2679, 0x8022 }, { 2682, 0xa098 }, { 2687, 0xa186 }, { 2693, 0x006b },
+ { 2698, 0x2a30 }, { 2703, 0x85a4 }, { 2709, 0x4181 }, { 2713, 0x0604 },
+ /* 0x6900 */
+ { 2716, 0x6021 }, { 2720, 0x0004 }, { 2721, 0x0080 }, { 2722, 0xa001 },
+ { 2725, 0x0400 }, { 2726, 0x46b8 }, { 2733, 0xe90f }, { 2742, 0x03a0 },
+ { 2746, 0x0000 }, { 2746, 0x1820 }, { 2749, 0x40a0 }, { 2752, 0x0810 },
+ { 2754, 0x380a }, { 2759, 0x0001 }, { 2760, 0x0500 }, { 2762, 0xa800 },
+ /* 0x6a00 */
+ { 2765, 0x0404 }, { 2767, 0xc28a }, { 2773, 0x000a }, { 2775, 0x2720 },
+ { 2780, 0x0910 }, { 2783, 0x830c }, { 2788, 0x0802 }, { 2790, 0x0000 },
+ { 2790, 0x6211 }, { 2795, 0x1080 }, { 2797, 0x000c }, { 2799, 0x0808 },
+ { 2801, 0x000c }, { 2803, 0x0c08 }, { 2806, 0x0000 }, { 2806, 0x0840 },
+ /* 0x6b00 */
+ { 2808, 0x1410 }, { 2811, 0x0044 }, { 2813, 0x000b }, { 2816, 0x6404 },
+ { 2820, 0x50c0 }, { 2824, 0x8001 }, { 2826, 0x047e }, { 2833, 0x8984 },
+ { 2838, 0x0658 }, { 2843, 0x4140 }, { 2846, 0xc000 }, { 2848, 0x94a4 },
+ { 2854, 0xa862 }, { 2860, 0x09dc }, { 2867, 0x1800 }, { 2869, 0x0000 },
+ /* 0x6c00 */
+ { 2869, 0x8100 }, { 2871, 0x000a }, { 2873, 0x0008 }, { 2874, 0x4190 },
+ { 2878, 0x4007 }, { 2882, 0xe4a1 }, { 2889, 0x2501 }, { 2893, 0x6445 },
+ { 2899, 0x11ee }, { 2907, 0x0e7d }, { 2916, 0x4800 }, { 2918, 0xfb08 },
+ { 2926, 0x1616 }, { 2932, 0x08a8 }, { 2936, 0xc92e }, { 2944, 0x0009 },
+ /* 0x6d00 */
+ { 2946, 0x1800 }, { 2948, 0x4a82 }, { 2953, 0x06a0 }, { 2957, 0x6b64 },
+ { 2965, 0x0002 }, { 2966, 0x1600 }, { 2969, 0x5648 }, { 2975, 0x8390 },
+ { 2980, 0x73a0 }, { 2987, 0x002a }, { 2990, 0x8000 }, { 2991, 0x0024 },
+ { 2993, 0x88f9 }, { 3001, 0x4702 }, { 3006, 0x4d02 }, { 3011, 0x0faa },
+ /* 0x6e00 */
+ { 3019, 0x0000 }, { 3019, 0x8e80 }, { 3024, 0xb87b }, { 3034, 0x7554 },
+ { 3042, 0x2418 }, { 3046, 0xd940 }, { 3052, 0xc880 }, { 3056, 0x040c },
+ { 3059, 0x0000 }, { 3059, 0xb041 }, { 3064, 0x8c24 }, { 3069, 0x0442 },
+ { 3072, 0x5a34 }, { 3079, 0x001a }, { 3082, 0x8000 }, { 3083, 0xc110 },
+ /* 0x6f00 */
+ { 3087, 0x8046 }, { 3091, 0x0032 }, { 3094, 0x180d }, { 3099, 0x8106 },
+ { 3103, 0x0002 }, { 3104, 0xcd92 }, { 3112, 0x6014 }, { 3116, 0x7401 },
+ { 3121, 0x6112 }, { 3126, 0x0091 }, { 3129, 0xc098 }, { 3134, 0x420a },
+ { 3138, 0x040f }, { 3143, 0x8420 }, { 3146, 0x9a13 }, { 3153, 0x4002 },
+ /* 0x7000 */
+ { 3155, 0x8a62 }, { 3161, 0xfd22 }, { 3170, 0x8188 }, { 3174, 0x4080 },
+ { 3176, 0x1000 }, { 3177, 0x2103 }, { 3181, 0x0808 }, { 3183, 0x3101 },
+ { 3187, 0x4420 }, { 3190, 0x0704 }, { 3194, 0xb812 }, { 3200, 0x0388 },
+ { 3204, 0x8900 }, { 3207, 0xa300 }, { 3211, 0x0000 }, { 3211, 0x2202 },
+ /* 0x7100 */
+ { 3214, 0x1210 }, { 3217, 0x4600 }, { 3220, 0x0042 }, { 3222, 0x0041 },
+ { 3224, 0x5680 }, { 3229, 0x5241 }, { 3234, 0x52f0 }, { 3241, 0x2000 },
+ { 3242, 0x8610 }, { 3246, 0x8214 }, { 3250, 0x1004 }, { 3252, 0x4602 },
+ { 3256, 0x430a }, { 3261, 0x8035 }, { 3266, 0x60e0 }, { 3271, 0xd800 },
+ /* 0x7200 */
+ { 3275, 0x0041 }, { 3277, 0x0801 }, { 3279, 0x3400 }, { 3282, 0x6c65 },
+ { 3290, 0x11c1 }, { 3295, 0xab04 }, { 3301, 0x0286 }, { 3305, 0x2204 },
+ { 3308, 0x0003 }, { 3310, 0x0000 }, { 3310, 0x9084 }, { 3314, 0x0000 },
+ { 3314, 0x4015 }, { 3318, 0x0281 }, { 3321, 0x0202 }, { 3323, 0x3300 },
+ /* 0x7300 */
+ { 3327, 0x0400 }, { 3328, 0x3840 }, { 3332, 0x0e20 }, { 3336, 0xc0c0 },
+ { 3340, 0x0030 }, { 3342, 0x0085 }, { 3345, 0x0500 }, { 3347, 0x0d25 },
+ { 3353, 0x4ad0 }, { 3359, 0x81d0 }, { 3364, 0x2280 }, { 3367, 0x020c },
+ { 3370, 0xb605 }, { 3377, 0x6240 }, { 3381, 0x2679 }, { 3389, 0x6280 },
+ /* 0x7400 */
+ { 3393, 0x02ea }, { 3399, 0x0808 }, { 3401, 0xdd67 }, { 3412, 0x8579 },
+ { 3420, 0x081b }, { 3425, 0xdea0 }, { 3433, 0x8735 }, { 3441, 0x4000 },
+ { 3442, 0x0a8c }, { 3447, 0xd100 }, { 3451, 0x05aa }, { 3457, 0xa225 },
+ { 3463, 0x8440 }, { 3466, 0x1510 }, { 3470, 0x404d }, { 3475, 0x0080 },
+ /* 0x7500 */
+ { 3476, 0x0012 }, { 3478, 0x8d22 }, { 3484, 0x1968 }, { 3490, 0x058f },
+ { 3497, 0x9080 }, { 3500, 0x3a1a }, { 3507, 0x8464 }, { 3512, 0x8561 },
+ { 3518, 0xccc0 }, { 3524, 0x2002 }, { 3526, 0x0820 }, { 3528, 0x732e },
+ { 3537, 0x20a4 }, { 3541, 0x0b34 }, { 3547, 0x0004 }, { 3548, 0x1415 },
+ /* 0x7600 */
+ { 3553, 0x2001 }, { 3555, 0x8200 }, { 3557, 0x0057 }, { 3562, 0x0800 },
+ { 3563, 0x5004 }, { 3566, 0x0044 }, { 3568, 0x1212 }, { 3572, 0x7905 },
+ { 3579, 0x40d0 }, { 3583, 0x0009 }, { 3585, 0x4000 }, { 3586, 0x8400 },
+ { 3588, 0x054c }, { 3593, 0xd844 }, { 3599, 0x409a }, { 3604, 0x5114 },
+ /* 0x7700 */
+ { 3609, 0x0b12 }, { 3614, 0x4000 }, { 3615, 0x0201 }, { 3617, 0x1580 },
+ { 3621, 0x2001 }, { 3623, 0x0800 }, { 3624, 0x084a }, { 3628, 0xc200 },
+ { 3631, 0x0800 }, { 3632, 0x4002 }, { 3634, 0x3020 }, { 3637, 0x9809 },
+ { 3642, 0x0000 }, { 3642, 0x1880 }, { 3645, 0xe22c }, { 3652, 0x0008 },
+ /* 0x7800 */
+ { 3653, 0x0004 }, { 3654, 0x0004 }, { 3655, 0x10e0 }, { 3659, 0x0014 },
+ { 3661, 0x8020 }, { 3663, 0x2000 }, { 3664, 0x9800 }, { 3667, 0x1000 },
+ { 3668, 0x7082 }, { 3673, 0x0082 }, { 3675, 0x0288 }, { 3678, 0x1c00 },
+ { 3681, 0x4c22 }, { 3686, 0x0001 }, { 3687, 0x9100 }, { 3690, 0x0820 },
+ /* 0x7900 */
+ { 3692, 0x4002 }, { 3694, 0x0040 }, { 3695, 0x1c00 }, { 3698, 0x4400 },
+ { 3700, 0x0383 }, { 3705, 0x7cc1 }, { 3713, 0x2121 }, { 3717, 0x8400 },
+ { 3719, 0xe002 }, { 3723, 0x0002 }, { 3724, 0x44c0 }, { 3728, 0xe20a },
+ { 3734, 0x0e03 }, { 3739, 0x8126 }, { 3744, 0x02d0 }, { 3748, 0x0800 },
+ /* 0x7a00 */
+ { 3749, 0x2921 }, { 3754, 0x9690 }, { 3760, 0x4001 }, { 3762, 0xb8c2 },
+ { 3769, 0x6241 }, { 3774, 0x0080 }, { 3775, 0x0a06 }, { 3779, 0xa651 },
+ { 3786, 0x0112 }, { 3789, 0x812c }, { 3794, 0xc600 }, { 3798, 0x0400 },
+ { 3799, 0x0cb0 }, { 3804, 0xa280 }, { 3808, 0xa429 }, { 3814, 0x8640 },
+ /* 0x7b00 */
+ { 3818, 0x8000 }, { 3819, 0x4a02 }, { 3823, 0x3041 }, { 3827, 0x0200 },
+ { 3828, 0xba40 }, { 3834, 0x0057 }, { 3839, 0x5001 }, { 3842, 0x2020 },
+ { 3844, 0x8880 }, { 3847, 0x24b0 }, { 3852, 0x2002 }, { 3854, 0x0112 },
+ { 3857, 0x02d3 }, { 3863, 0x0004 }, { 3864, 0x0211 }, { 3867, 0x0000 },
+ /* 0x7c00 */
+ { 3867, 0x0080 }, { 3868, 0x4004 }, { 3870, 0x0c82 }, { 3874, 0xe000 },
+ { 3877, 0x3008 }, { 3880, 0x0000 }, { 3880, 0x1011 }, { 3883, 0x0008 },
+ { 3884, 0x0208 }, { 3886, 0x81a4 }, { 3891, 0x40a0 }, { 3894, 0x420e },
+ { 3899, 0x0400 }, { 3900, 0xc040 }, { 3903, 0x0081 }, { 3905, 0x4800 },
+ /* 0x7d00 */
+ { 3907, 0x2df5 }, { 3917, 0x0f91 }, { 3924, 0xd807 }, { 3931, 0x0629 },
+ { 3936, 0x007c }, { 3941, 0x4001 }, { 3943, 0x4546 }, { 3949, 0x824e },
+ { 3955, 0xc000 }, { 3957, 0x1008 }, { 3959, 0x3005 }, { 3963, 0xed36 },
+ { 3973, 0x0c80 }, { 3976, 0x6540 }, { 3981, 0x930b }, { 3988, 0x0810 },
+ /* 0x7e00 */
+ { 3990, 0x0600 }, { 3992, 0xe820 }, { 3997, 0xc80a }, { 4002, 0x6082 },
+ { 4006, 0x00ca }, { 4010, 0x4034 }, { 4014, 0x2e02 }, { 4019, 0x1201 },
+ { 4022, 0x9004 }, { 4025, 0x1948 }, { 4030, 0x0000 }, { 4030, 0x0000 },
+ { 4030, 0x0000 }, { 4030, 0x0000 }, { 4030, 0x0000 }, { 4030, 0x0000 },
+ /* 0x7f00 */
+ { 4030, 0x0000 }, { 4030, 0x0000 }, { 4030, 0x0000 }, { 4030, 0x0540 },
+ { 4033, 0x1000 }, { 4034, 0x0031 }, { 4037, 0x4c00 }, { 4040, 0x02a5 },
+ { 4045, 0x5520 }, { 4050, 0x4410 }, { 4053, 0x0310 }, { 4056, 0x2304 },
+ { 4060, 0x5422 }, { 4065, 0x8034 }, { 4069, 0x0a03 }, { 4073, 0x1201 },
+ /* 0x8000 */
+ { 4076, 0x126b }, { 4083, 0x01a1 }, { 4087, 0x2000 }, { 4088, 0xa048 },
+ { 4092, 0x0448 }, { 4095, 0x4540 }, { 4099, 0x8000 }, { 4100, 0xe08d },
+ { 4107, 0x1af0 }, { 4114, 0x2840 }, { 4117, 0x8626 }, { 4123, 0x0416 },
+ { 4127, 0x5018 }, { 4131, 0x4c00 }, { 4134, 0x0032 }, { 4137, 0x2112 },
+ /* 0x8100 */
+ { 4141, 0x05e4 }, { 4147, 0x0d00 }, { 4150, 0x8a08 }, { 4154, 0x4200 },
+ { 4156, 0x4800 }, { 4158, 0x0033 }, { 4162, 0x0860 }, { 4165, 0x8703 },
+ { 4171, 0x8501 }, { 4175, 0x3400 }, { 4178, 0x0109 }, { 4181, 0xe428 },
+ { 4187, 0x2045 }, { 4191, 0x8100 }, { 4193, 0x25a8 }, { 4199, 0x5c18 },
+ /* 0x8200 */
+ { 4205, 0x35a0 }, { 4211, 0xd804 }, { 4216, 0x1c02 }, { 4220, 0x02e0 },
+ { 4224, 0x00a1 }, { 4227, 0x0200 }, { 4228, 0xc050 }, { 4232, 0x4146 },
+ { 4237, 0x6800 }, { 4240, 0xa604 }, { 4245, 0xf260 }, { 4252, 0xbb8a },
+ { 4261, 0x0000 }, { 4261, 0xc8b6 }, { 4269, 0x00e2 }, { 4273, 0x6002 },
+ /* 0x8300 */
+ { 4276, 0x023e }, { 4282, 0x0080 }, { 4283, 0x8900 }, { 4286, 0x0372 },
+ { 4292, 0x8681 }, { 4297, 0x0006 }, { 4299, 0x0000 }, { 4299, 0x0888 },
+ { 4302, 0x4600 }, { 4305, 0x4140 }, { 4308, 0x0e04 }, { 4312, 0x2000 },
+ { 4313, 0x1622 }, { 4318, 0x1048 }, { 4321, 0x8a00 }, { 4324, 0x2217 },
+ /* 0x8400 */
+ { 4330, 0x7418 }, { 4336, 0x0000 }, { 4336, 0x1200 }, { 4338, 0x2102 },
+ { 4341, 0x0200 }, { 4342, 0x0880 }, { 4344, 0x984a }, { 4350, 0x0420 },
+ { 4352, 0x0000 }, { 4352, 0x1211 }, { 4356, 0x0002 }, { 4357, 0x9904 },
+ { 4362, 0x2a55 }, { 4369, 0x0402 }, { 4371, 0x5000 }, { 4373, 0x1010 },
+ /* 0x8500 */
+ { 4375, 0x0000 }, { 4375, 0x459a }, { 4382, 0xb02a }, { 4388, 0xa000 },
+ { 4390, 0x420a }, { 4394, 0x0208 }, { 4396, 0x2708 }, { 4401, 0x0000 },
+ { 4401, 0x8090 }, { 4404, 0x0812 }, { 4407, 0x8740 }, { 4412, 0x0401 },
+ { 4414, 0xe202 }, { 4419, 0x3020 }, { 4422, 0x0630 }, { 4426, 0x8c80 },
+ /* 0x8600 */
+ { 4430, 0x04c4 }, { 4434, 0x04c0 }, { 4437, 0x2000 }, { 4438, 0x8000 },
+ { 4439, 0x4000 }, { 4440, 0xd831 }, { 4447, 0x0080 }, { 4448, 0x0200 },
+ { 4449, 0x1400 }, { 4451, 0x0008 }, { 4452, 0x0218 }, { 4455, 0x0000 },
+ { 4455, 0x0880 }, { 4457, 0x8a10 }, { 4461, 0x2010 }, { 4463, 0x4000 },
+ /* 0x8700 */
+ { 4464, 0x010d }, { 4468, 0x1500 }, { 4471, 0x0000 }, { 4471, 0x0000 },
+ { 4471, 0x4000 }, { 4472, 0x80a0 }, { 4475, 0x0140 }, { 4477, 0x0150 },
+ { 4480, 0x2004 }, { 4482, 0x8000 }, { 4483, 0x0004 }, { 4484, 0x0408 },
+ { 4486, 0x0010 }, { 4487, 0x0000 }, { 4487, 0x9001 }, { 4490, 0x4a04 },
+ /* 0x8800 */
+ { 4494, 0x0020 }, { 4495, 0x8000 }, { 4496, 0x000c }, { 4498, 0x0842 },
+ { 4501, 0x3041 }, { 4505, 0x2a8c }, { 4511, 0x090e }, { 4516, 0xc085 },
+ { 4521, 0x2906 }, { 4526, 0x40c4 }, { 4530, 0x0800 }, { 4531, 0x0010 },
+ { 4532, 0x8006 }, { 4535, 0xb230 }, { 4541, 0x0102 }, { 4543, 0x2138 },
+ /* 0x8900 */
+ { 4548, 0x0080 }, { 4549, 0x030d }, { 4554, 0x0420 }, { 4556, 0x0940 },
+ { 4559, 0x0012 }, { 4561, 0x8000 }, { 4562, 0x0410 }, { 4564, 0x8004 },
+ { 4566, 0x88ca }, { 4572, 0x0048 }, { 4574, 0x0602 }, { 4577, 0x2404 },
+ { 4580, 0x0001 }, { 4581, 0x0004 }, { 4582, 0x0008 }, { 4583, 0x0110 },
+ /* 0x8a00 */
+ { 4585, 0x550d }, { 4592, 0xa9c8 }, { 4599, 0x2428 }, { 4603, 0x0c52 },
+ { 4608, 0x0000 }, { 4608, 0x4831 }, { 4613, 0x624d }, { 4620, 0x022f },
+ { 4626, 0x30a0 }, { 4630, 0x4128 }, { 4634, 0x057b }, { 4642, 0xd205 },
+ { 4648, 0xa894 }, { 4654, 0x1844 }, { 4658, 0x6cc2 }, { 4665, 0x45c2 },
+ /* 0x8b00 */
+ { 4671, 0x4017 }, { 4676, 0x2ed1 }, { 4684, 0x1901 }, { 4688, 0x0208 },
+ { 4690, 0xc202 }, { 4694, 0x1500 }, { 4697, 0x9040 }, { 4700, 0x2091 },
+ { 4704, 0x0401 }, { 4706, 0x044d }, { 4711, 0x0000 }, { 4711, 0x0000 },
+ { 4711, 0x0000 }, { 4711, 0x0000 }, { 4711, 0x0000 }, { 4711, 0x0000 },
+ /* 0x8c00 */
+ { 4711, 0x0000 }, { 4711, 0x0000 }, { 4711, 0x0000 }, { 4711, 0x8080 },
+ { 4713, 0x1542 }, { 4718, 0x0420 }, { 4720, 0x0c02 }, { 4723, 0x0600 },
+ { 4725, 0x1404 }, { 4728, 0x6000 }, { 4730, 0x9f87 }, { 4740, 0xb9d9 },
+ { 4750, 0x059f }, { 4758, 0x540a }, { 4763, 0x245d }, { 4770, 0x3810 },
+ /* 0x8d00 */
+ { 4774, 0x25b0 }, { 4780, 0x0048 }, { 4782, 0x0000 }, { 4782, 0x0000 },
+ { 4782, 0x0000 }, { 4782, 0x0000 }, { 4782, 0x0850 }, { 4785, 0x0099 },
+ { 4789, 0x0420 }, { 4791, 0x0200 }, { 4792, 0x0108 }, { 4794, 0x4408 },
+ { 4797, 0x9840 }, { 4801, 0x2800 }, { 4803, 0x810a }, { 4807, 0x0008 },
+ /* 0x8e00 */
+ { 4808, 0x8400 }, { 4810, 0x4001 }, { 4812, 0x0400 }, { 4813, 0x0021 },
+ { 4815, 0x0794 }, { 4821, 0x8200 }, { 4823, 0x0001 }, { 4824, 0x0050 },
+ { 4826, 0x2482 }, { 4830, 0x0000 }, { 4830, 0x1c00 }, { 4833, 0x0000 },
+ { 4833, 0x3c01 }, { 4838, 0x8004 }, { 4840, 0x0800 }, { 4841, 0x4900 },
+ /* 0x8f00 */
+ { 4844, 0x0228 }, { 4847, 0xf83c }, { 4856, 0x86c0 }, { 4861, 0xcb08 },
+ { 4867, 0x6230 }, { 4872, 0xa000 }, { 4874, 0x0004 }, { 4875, 0x0000 },
+ { 4875, 0x0000 }, { 4875, 0x1800 }, { 4877, 0xa148 }, { 4882, 0x0007 },
+ { 4885, 0x4024 }, { 4888, 0x0012 }, { 4890, 0x2c40 }, { 4894, 0x2285 },
+ /* 0x9000 */
+ { 4899, 0xa96f }, { 4909, 0xe6b3 }, { 4919, 0x400f }, { 4924, 0x5126 },
+ { 4930, 0x6c86 }, { 4937, 0x723b }, { 4946, 0xe20b }, { 4953, 0xb5a4 },
+ { 4961, 0x859f }, { 4970, 0x0222 }, { 4973, 0x854c }, { 4979, 0x0123 },
+ { 4983, 0x0402 }, { 4985, 0x4000 }, { 4986, 0x2102 }, { 4989, 0x2020 },
+ /* 0x9100 */
+ { 4991, 0x0004 }, { 4992, 0x0224 }, { 4995, 0x2080 }, { 4997, 0x0004 },
+ { 4998, 0x7e00 }, { 5004, 0x0004 }, { 5005, 0x1604 }, { 5009, 0x01a0 },
+ { 5012, 0x2a80 }, { 5016, 0x1004 }, { 5018, 0xd800 }, { 5022, 0x0032 },
+ { 5025, 0xfa81 }, { 5033, 0x3183 }, { 5039, 0x0488 }, { 5042, 0x0020 },
+ /* 0x9200 */
+ { 5043, 0x2000 }, { 5044, 0x4087 }, { 5049, 0x0000 }, { 5049, 0x8410 },
+ { 5052, 0x0221 }, { 5055, 0x4880 }, { 5058, 0x0074 }, { 5062, 0x0000 },
+ { 5062, 0x0029 }, { 5065, 0x114a }, { 5070, 0x0000 }, { 5070, 0x02c8 },
+ { 5074, 0x9000 }, { 5076, 0x0004 }, { 5077, 0x0410 }, { 5079, 0x1100 },
+ /* 0x9300 */
+ { 5081, 0x0010 }, { 5082, 0xc501 }, { 5087, 0xc957 }, { 5096, 0x0000 },
+ { 5096, 0x2d00 }, { 5100, 0x0810 }, { 5102, 0x4000 }, { 5103, 0x5020 },
+ { 5106, 0x1000 }, { 5107, 0x0450 }, { 5110, 0x3088 }, { 5114, 0x0001 },
+ { 5115, 0x0008 }, { 5116, 0x4002 }, { 5118, 0x0012 }, { 5120, 0x0040 },
+ /* 0x9400 */
+ { 5121, 0x0010 }, { 5122, 0x0100 }, { 5123, 0x0820 }, { 5125, 0x0120 },
+ { 5127, 0x0010 }, { 5128, 0x0806 }, { 5131, 0x0000 }, { 5131, 0xa000 },
+ { 5133, 0x0000 }, { 5133, 0x0000 }, { 5133, 0x0000 }, { 5133, 0x0000 },
+ { 5133, 0x0000 }, { 5133, 0x0000 }, { 5133, 0x0000 }, { 5133, 0x0000 },
+ /* 0x9500 */
+ { 5133, 0x0000 }, { 5133, 0x0000 }, { 5133, 0x0000 }, { 5133, 0x0000 },
+ { 5133, 0x0000 }, { 5133, 0x0000 }, { 5133, 0x0000 }, { 5133, 0x0080 },
+ { 5134, 0x8a09 }, { 5139, 0x011e }, { 5144, 0x2138 }, { 5149, 0x1802 },
+ { 5152, 0x0480 }, { 5154, 0x1070 }, { 5158, 0x0006 }, { 5160, 0x0000 },
+ /* 0x9600 */
+ { 5160, 0x0000 }, { 5160, 0x1000 }, { 5161, 0x4402 }, { 5164, 0x8804 },
+ { 5167, 0x3815 }, { 5173, 0xf801 }, { 5179, 0x041c }, { 5183, 0x21e9 },
+ { 5190, 0x6c60 }, { 5196, 0x1b30 }, { 5202, 0x0588 }, { 5206, 0x0882 },
+ { 5209, 0x7af3 }, { 5220, 0x1a60 }, { 5225, 0x870c }, { 5231, 0x0ac5 },
+ /* 0x9700 */
+ { 5237, 0x00c1 }, { 5240, 0x524a }, { 5246, 0x0080 }, { 5247, 0x2205 },
+ { 5251, 0x0114 }, { 5254, 0x5042 }, { 5258, 0x2206 }, { 5262, 0x0490 },
+ { 5265, 0xa800 }, { 5268, 0x0000 }, { 5268, 0x2901 }, { 5272, 0x0000 },
+ { 5272, 0x0840 }, { 5274, 0x1008 }, { 5276, 0x0000 }, { 5276, 0x8848 },
+ /* 0x9800 */
+ { 5280, 0x156f }, { 5289, 0x018f }, { 5295, 0x2000 }, { 5296, 0x0b01 },
+ { 5300, 0x7040 }, { 5304, 0x4510 }, { 5308, 0x88a0 }, { 5312, 0x0000 },
+ { 5312, 0x0000 }, { 5312, 0x0000 }, { 5312, 0x8100 }, { 5314, 0x0002 },
+ { 5315, 0x0090 }, { 5317, 0x9800 }, { 5320, 0xe006 }, { 5325, 0x7010 },
+ /* 0x9900 */
+ { 5329, 0x1608 }, { 5333, 0x4109 }, { 5337, 0x0101 }, { 5339, 0x0000 },
+ { 5339, 0x3a20 }, { 5344, 0x0096 }, { 5348, 0x0000 }, { 5348, 0x0000 },
+ { 5348, 0x0000 }, { 5348, 0x2240 }, { 5351, 0x7120 }, { 5356, 0x021a },
+ { 5360, 0x0002 }, { 5361, 0xa227 }, { 5368, 0x2000 }, { 5369, 0x8002 },
+ /* 0x9a00 */
+ { 5371, 0xc102 }, { 5375, 0x0200 }, { 5376, 0x0800 }, { 5377, 0x00c1 },
+ { 5380, 0x2029 }, { 5384, 0x8ca0 }, { 5389, 0x0624 }, { 5393, 0x0000 },
+ { 5393, 0x0000 }, { 5393, 0x0000 }, { 5393, 0x0100 }, { 5394, 0x0100 },
+ { 5395, 0x0000 }, { 5395, 0x0118 }, { 5398, 0x4020 }, { 5400, 0x0000 },
+ /* 0x9b00 */
+ { 5400, 0x0000 }, { 5400, 0x0400 }, { 5401, 0x0480 }, { 5403, 0x1002 },
+ { 5405, 0x803e }, { 5411, 0x0410 }, { 5413, 0x8000 }, { 5414, 0x0000 },
+ { 5414, 0x4000 }, { 5415, 0x8002 }, { 5417, 0x4800 }, { 5419, 0x0000 },
+ { 5419, 0x0200 }, { 5420, 0x0040 }, { 5421, 0x0110 }, { 5423, 0x0000 },
+ /* 0x9c00 */
+ { 5423, 0x2000 }, { 5424, 0x0025 }, { 5427, 0x0020 }, { 5428, 0x0804 },
+ { 5430, 0x0280 }, { 5432, 0x0080 }, { 5433, 0x0000 }, { 5433, 0x0000 },
+ { 5433, 0x0000 }, { 5433, 0x0000 }, { 5433, 0x0000 }, { 5433, 0x0000 },
+ { 5433, 0x0000 }, { 5433, 0x0000 }, { 5433, 0x02a0 }, { 5436, 0x0058 },
+ /* 0x9d00 */
+ { 5439, 0x0200 }, { 5440, 0x0800 }, { 5441, 0x0140 }, { 5443, 0x0800 },
+ { 5444, 0x0000 }, { 5444, 0x2002 }, { 5446, 0x1003 }, { 5449, 0x0004 },
+ { 5450, 0x0000 }, { 5450, 0x0000 }, { 5450, 0x8200 }, { 5452, 0x0010 },
+ { 5453, 0x0010 }, { 5454, 0x0080 }, { 5455, 0x0000 }, { 5455, 0x0704 },
+ /* 0x9e00 */
+ { 5459, 0x0000 }, { 5459, 0x4400 }, { 5461, 0x0000 }, { 5461, 0x0000 },
+ { 5461, 0x0000 }, { 5461, 0x0000 }, { 5461, 0x0000 }, { 5461, 0xa220 },
+ { 5465, 0x0000 }, { 5465, 0xa08c }, { 5470, 0x0020 }, { 5471, 0x4830 },
+ { 5475, 0x6008 }, { 5478, 0x5912 }, { 5484, 0x0100 }, { 5485, 0x0010 },
+ /* 0x9f00 */
+ { 5486, 0x4180 }, { 5489, 0x0008 }, { 5490, 0x0001 }, { 5491, 0x0800 },
+ { 5492, 0x4c00 }, { 5495, 0x8004 }, { 5497, 0x1482 }, { 5501, 0x0080 },
+ { 5502, 0x2000 }, { 5503, 0x1021 },
+};
+static const Summary16 ksc5601_uni2indx_pageac[698] = {
+ /* 0xac00 */
+ { 5506, 0x0793 }, { 5513, 0x3eff }, { 5526, 0xb011 }, { 5531, 0x1303 },
+ { 5536, 0x2801 }, { 5539, 0x1110 }, { 5542, 0x0000 }, { 5542, 0x0593 },
+ { 5548, 0x1e7b }, { 5558, 0xb011 }, { 5563, 0x9703 }, { 5570, 0x3b01 },
+ { 5576, 0x1112 }, { 5580, 0x00a0 }, { 5582, 0x9593 }, { 5590, 0x306b },
+ /* 0xad00 */
+ { 5597, 0xb051 }, { 5603, 0x1102 }, { 5606, 0x3201 }, { 5610, 0x1130 },
+ { 5614, 0x02b0 }, { 5618, 0x0111 }, { 5621, 0x300a }, { 5625, 0xb879 },
+ { 5634, 0x1306 }, { 5639, 0x3001 }, { 5642, 0x0010 }, { 5643, 0x0080 },
+ { 5644, 0x0113 }, { 5648, 0x100b }, { 5652, 0x0011 }, { 5654, 0x9300 },
+ /* 0xae00 */
+ { 5658, 0x2b03 }, { 5664, 0x0010 }, { 5665, 0x0000 }, { 5665, 0x0593 },
+ { 5671, 0x746b }, { 5680, 0xb051 }, { 5686, 0x1323 }, { 5692, 0x3b01 },
+ { 5698, 0x1030 }, { 5701, 0x0000 }, { 5701, 0x0000 }, { 5701, 0x7000 },
+ { 5704, 0xb011 }, { 5709, 0x1303 }, { 5714, 0x2900 }, { 5717, 0x1110 },
+ /* 0xaf00 */
+ { 5720, 0x2180 }, { 5723, 0x0001 }, { 5724, 0x3000 }, { 5726, 0xb015 },
+ { 5732, 0x030e }, { 5737, 0x3001 }, { 5740, 0x0030 }, { 5742, 0x0200 },
+ { 5743, 0x0111 }, { 5746, 0x1023 }, { 5750, 0x0000 }, { 5750, 0x1300 },
+ { 5753, 0x6b81 }, { 5760, 0x1010 }, { 5762, 0x0300 }, { 5764, 0x0113 },
+ /* 0xb000 */
+ { 5768, 0x1013 }, { 5772, 0x3011 }, { 5776, 0x0100 }, { 5777, 0x0000 },
+ { 5777, 0x5530 }, { 5783, 0x22b8 }, { 5789, 0x0000 }, { 5789, 0x3000 },
+ { 5791, 0xb011 }, { 5796, 0x9702 }, { 5802, 0xfb07 }, { 5812, 0x113a },
+ { 5818, 0x03b0 }, { 5823, 0x0113 }, { 5827, 0x0021 }, { 5829, 0x0000 },
+ /* 0xb100 */
+ { 5829, 0x1b00 }, { 5833, 0x3b0d }, { 5841, 0x1138 }, { 5846, 0x03b0 },
+ { 5851, 0x0113 }, { 5855, 0x1133 }, { 5861, 0x0001 }, { 5862, 0x1300 },
+ { 5865, 0x2b05 }, { 5871, 0x111c }, { 5876, 0x0100 }, { 5877, 0x0000 },
+ { 5877, 0x1000 }, { 5878, 0xb011 }, { 5883, 0x1300 }, { 5886, 0x2a01 },
+ /* 0xb200 */
+ { 5890, 0x1930 }, { 5895, 0x02b0 }, { 5899, 0x0001 }, { 5900, 0x1010 },
+ { 5902, 0x0000 }, { 5902, 0x1100 }, { 5904, 0x0301 }, { 5907, 0x1030 },
+ { 5910, 0x0230 }, { 5913, 0x0713 }, { 5919, 0x146b }, { 5926, 0x0011 },
+ { 5928, 0x1300 }, { 5931, 0x2b05 }, { 5937, 0xf974 }, { 5947, 0x8fb8 },
+ /* 0xb300 */
+ { 5956, 0x0113 }, { 5960, 0x103b }, { 5966, 0x0000 }, { 5966, 0x0000 },
+ { 5966, 0x0000 }, { 5966, 0xd970 }, { 5974, 0x4ab0 }, { 5980, 0x0113 },
+ { 5984, 0x103b }, { 5990, 0x0011 }, { 5992, 0x1103 }, { 5996, 0x0000 },
+ { 5996, 0x5930 }, { 6002, 0x2ab1 }, { 6009, 0x0111 }, { 6012, 0x1000 },
+ /* 0xb400 */
+ { 6013, 0x0000 }, { 6013, 0x1101 }, { 6016, 0x0b01 }, { 6020, 0x0010 },
+ { 6021, 0x0000 }, { 6021, 0x0113 }, { 6025, 0x102b }, { 6030, 0x0000 },
+ { 6030, 0x0101 }, { 6032, 0x2000 }, { 6033, 0x1110 }, { 6036, 0x02a0 },
+ { 6039, 0x0111 }, { 6042, 0x3021 }, { 6046, 0xb059 }, { 6053, 0x0102 },
+ /* 0xb500 */
+ { 6055, 0x0000 }, { 6055, 0x1930 }, { 6060, 0x07b0 }, { 6066, 0x0113 },
+ { 6070, 0x383b }, { 6078, 0xb011 }, { 6083, 0x0003 }, { 6085, 0x0000 },
+ { 6085, 0x0000 }, { 6085, 0x0000 }, { 6085, 0x0d13 }, { 6091, 0x383b },
+ { 6099, 0xb011 }, { 6104, 0x0103 }, { 6107, 0x1000 }, { 6108, 0x0000 },
+ /* 0xb600 */
+ { 6108, 0x0000 }, { 6108, 0x0113 }, { 6112, 0x1020 }, { 6114, 0x0010 },
+ { 6115, 0x0100 }, { 6116, 0x0000 }, { 6116, 0x0110 }, { 6118, 0x0000 },
+ { 6118, 0x0000 }, { 6118, 0x3000 }, { 6120, 0x1811 }, { 6124, 0x0002 },
+ { 6125, 0x0000 }, { 6125, 0x0010 }, { 6126, 0x0000 }, { 6126, 0x0111 },
+ /* 0xb700 */
+ { 6129, 0x0023 }, { 6132, 0x0000 }, { 6132, 0x9300 }, { 6136, 0x0b01 },
+ { 6140, 0x1110 }, { 6143, 0x0030 }, { 6145, 0x0111 }, { 6148, 0x302b },
+ { 6154, 0xb011 }, { 6159, 0x13c7 }, { 6167, 0x3b01 }, { 6173, 0x0130 },
+ { 6176, 0x0280 }, { 6178, 0x0000 }, { 6178, 0x3000 }, { 6180, 0xb011 },
+ /* 0xb800 */
+ { 6185, 0x1383 }, { 6191, 0x2b01 }, { 6196, 0x1130 }, { 6200, 0x03b0 },
+ { 6205, 0x0011 }, { 6207, 0x300a }, { 6211, 0xb011 }, { 6216, 0x1102 },
+ { 6219, 0x2000 }, { 6220, 0x0000 }, { 6220, 0x0100 }, { 6221, 0x0111 },
+ { 6224, 0x102b }, { 6229, 0xa011 }, { 6233, 0x1302 }, { 6237, 0x2b01 },
+ /* 0xb900 */
+ { 6242, 0x0010 }, { 6243, 0x0100 }, { 6244, 0x0001 }, { 6245, 0x3000 },
+ { 6247, 0x9011 }, { 6251, 0x1302 }, { 6255, 0x2b01 }, { 6260, 0x1130 },
+ { 6264, 0x66b0 }, { 6271, 0x0000 }, { 6271, 0x3000 }, { 6273, 0xb011 },
+ { 6278, 0xd302 }, { 6284, 0x6b07 }, { 6292, 0x113a }, { 6298, 0x07b0 },
+ /* 0xba00 */
+ { 6304, 0x0103 }, { 6307, 0x0020 }, { 6308, 0x0000 }, { 6308, 0x1300 },
+ { 6311, 0x6b05 }, { 6318, 0x1138 }, { 6323, 0x03b0 }, { 6328, 0x0113 },
+ { 6332, 0x10b8 }, { 6337, 0x0000 }, { 6337, 0x1b00 }, { 6341, 0x2b05 },
+ { 6347, 0x0110 }, { 6349, 0x0300 }, { 6351, 0x0000 }, { 6351, 0x1000 },
+ /* 0xbb00 */
+ { 6352, 0xa011 }, { 6356, 0x1102 }, { 6359, 0x0a01 }, { 6362, 0x7970 },
+ { 6370, 0xa2b0 }, { 6376, 0x0111 }, { 6379, 0x100a }, { 6382, 0x0000 },
+ { 6382, 0x1100 }, { 6384, 0x0001 }, { 6385, 0x1110 }, { 6388, 0x0090 },
+ { 6390, 0x0111 }, { 6393, 0x0009 }, { 6395, 0x0000 }, { 6395, 0x9300 },
+ /* 0xbc00 */
+ { 6399, 0xbb05 }, { 6407, 0xf9f2 }, { 6418, 0x22b0 }, { 6423, 0x0113 },
+ { 6427, 0x323b }, { 6435, 0x2001 }, { 6437, 0x0000 }, { 6437, 0x0000 },
+ { 6437, 0x5930 }, { 6443, 0x06b0 }, { 6448, 0x0193 }, { 6453, 0x303b },
+ { 6460, 0xa011 }, { 6464, 0x1123 }, { 6469, 0x0000 }, { 6469, 0x1170 },
+ /* 0xbd00 */
+ { 6474, 0x02b0 }, { 6478, 0x0011 }, { 6480, 0x1010 }, { 6482, 0x0000 },
+ { 6482, 0x1301 }, { 6486, 0x0301 }, { 6489, 0x0110 }, { 6491, 0x0000 },
+ { 6491, 0x0793 }, { 6498, 0x162b }, { 6505, 0x0010 }, { 6506, 0x0101 },
+ { 6508, 0x0000 }, { 6508, 0x1130 }, { 6512, 0x0200 }, { 6513, 0x0111 },
+ /* 0xbe00 */
+ { 6516, 0x3029 }, { 6521, 0xb011 }, { 6526, 0x0000 }, { 6526, 0x0000 },
+ { 6526, 0x5130 }, { 6531, 0x0eb0 }, { 6537, 0x0513 }, { 6542, 0x383b },
+ { 6550, 0xb011 }, { 6555, 0x0303 }, { 6559, 0x0100 }, { 6560, 0x0000 },
+ { 6560, 0x0000 }, { 6560, 0x0193 }, { 6565, 0x1039 }, { 6570, 0x0000 },
+ /* 0xbf00 */
+ { 6570, 0x0302 }, { 6573, 0x3b00 }, { 6578, 0x0000 }, { 6578, 0x0000 },
+ { 6578, 0x0113 }, { 6582, 0x0023 }, { 6585, 0x0000 }, { 6585, 0x0000 },
+ { 6585, 0x0000 }, { 6585, 0x0010 }, { 6586, 0x0000 }, { 6586, 0x0001 },
+ { 6587, 0x3020 }, { 6590, 0x9011 }, { 6594, 0x0002 }, { 6595, 0x0000 },
+ /* 0xc000 */
+ { 6595, 0x0000 }, { 6595, 0x0000 }, { 6595, 0x0000 }, { 6595, 0x1000 },
+ { 6596, 0x0000 }, { 6596, 0x1102 }, { 6599, 0x0301 }, { 6602, 0x0000 },
+ { 6602, 0x0000 }, { 6602, 0x0113 }, { 6606, 0xb02b }, { 6613, 0xb079 },
+ { 6621, 0x1323 }, { 6627, 0x3b01 }, { 6633, 0x1130 }, { 6637, 0x02b0 },
+ /* 0xc100 */
+ { 6641, 0x0111 }, { 6644, 0xf021 }, { 6650, 0xb0d9 }, { 6658, 0x1343 },
+ { 6664, 0x3b01 }, { 6670, 0x1130 }, { 6674, 0x03b0 }, { 6679, 0x0111 },
+ { 6682, 0x7020 }, { 6686, 0xb051 }, { 6692, 0x1322 }, { 6697, 0x2001 },
+ { 6699, 0x1110 }, { 6702, 0x0190 }, { 6705, 0x0111 }, { 6708, 0x300b },
+ /* 0xc200 */
+ { 6713, 0xb011 }, { 6718, 0x9302 }, { 6723, 0xab01 }, { 6729, 0x0016 },
+ { 6732, 0x0100 }, { 6733, 0x0113 }, { 6737, 0x3021 }, { 6741, 0xb011 },
+ { 6746, 0x0302 }, { 6749, 0x2901 }, { 6753, 0x3130 }, { 6758, 0x02b0 },
+ { 6762, 0x0000 }, { 6762, 0x3000 }, { 6764, 0xb819 }, { 6771, 0x1b42 },
+ /* 0xc300 */
+ { 6777, 0x3301 }, { 6782, 0x1138 }, { 6787, 0x0330 }, { 6791, 0x0000 },
+ { 6791, 0x0020 }, { 6792, 0x0000 }, { 6792, 0x1300 }, { 6795, 0x3305 },
+ { 6801, 0x1110 }, { 6804, 0x0000 }, { 6804, 0x0000 }, { 6804, 0x0000 },
+ { 6804, 0x0001 }, { 6805, 0x9300 }, { 6809, 0x2305 }, { 6814, 0x0130 },
+ /* 0xc400 */
+ { 6817, 0x0100 }, { 6818, 0x0001 }, { 6819, 0x1010 }, { 6821, 0x3011 },
+ { 6825, 0x0100 }, { 6826, 0x0000 }, { 6826, 0x1130 }, { 6830, 0x0230 },
+ { 6833, 0x0001 }, { 6834, 0x1010 }, { 6836, 0x0000 }, { 6836, 0x1100 },
+ { 6838, 0x0000 }, { 6838, 0x0000 }, { 6838, 0x0200 }, { 6839, 0x8513 },
+ /* 0xc500 */
+ { 6845, 0x1003 }, { 6848, 0x1011 }, { 6851, 0x1300 }, { 6854, 0x2b01 },
+ { 6859, 0x7730 }, { 6867, 0x63b8 }, { 6875, 0x0113 }, { 6879, 0x303b },
+ { 6886, 0xb091 }, { 6892, 0x11a2 }, { 6897, 0x0201 }, { 6899, 0x7b30 },
+ { 6907, 0x57f0 }, { 6916, 0x0113 }, { 6920, 0x702b }, { 6927, 0xf0d1 },
+ /* 0xc600 */
+ { 6935, 0x11e3 }, { 6942, 0x1b01 }, { 6947, 0x7130 }, { 6953, 0x0ab9 },
+ { 6960, 0x0113 }, { 6964, 0x303b }, { 6971, 0x9001 }, { 6974, 0x1302 },
+ { 6978, 0x2b01 }, { 6983, 0x1130 }, { 6987, 0x02b0 }, { 6991, 0x0713 },
+ { 6997, 0x302b }, { 7003, 0x3011 }, { 7007, 0x1303 }, { 7012, 0x2301 },
+ /* 0xc700 */
+ { 7016, 0x1130 }, { 7020, 0x02b0 }, { 7024, 0x0113 }, { 7028, 0x30ab },
+ { 7035, 0xb411 }, { 7041, 0x11fe }, { 7050, 0x0901 }, { 7053, 0x7130 },
+ { 7059, 0x47b8 }, { 7067, 0x05d3 }, { 7074, 0x307b }, { 7082, 0xb011 },
+ { 7087, 0x5303 }, { 7093, 0x2101 }, { 7096, 0x1110 }, { 7099, 0x0000 },
+ /* 0xc800 */
+ { 7099, 0x0513 }, { 7104, 0x306b }, { 7111, 0xb011 }, { 7116, 0x1102 },
+ { 7119, 0x3301 }, { 7124, 0x0010 }, { 7125, 0x0000 }, { 7125, 0x0513 },
+ { 7130, 0x38eb }, { 7139, 0xa010 }, { 7142, 0x0102 }, { 7144, 0x3000 },
+ { 7146, 0x1110 }, { 7149, 0x02b0 }, { 7153, 0x0013 }, { 7156, 0x3020 },
+ /* 0xc900 */
+ { 7159, 0xb071 }, { 7166, 0x0102 }, { 7168, 0x1000 }, { 7169, 0x0010 },
+ { 7170, 0x0000 }, { 7170, 0x0113 }, { 7174, 0x100b }, { 7178, 0x1011 },
+ { 7181, 0x1300 }, { 7184, 0x2b01 }, { 7189, 0x0000 }, { 7189, 0x0000 },
+ { 7189, 0x0593 }, { 7195, 0x366b }, { 7204, 0xb095 }, { 7211, 0x1303 },
+ /* 0xca00 */
+ { 7216, 0x3b01 }, { 7222, 0x0110 }, { 7224, 0x0200 }, { 7225, 0x0000 },
+ { 7225, 0x3000 }, { 7227, 0xb011 }, { 7232, 0x0103 }, { 7235, 0x2000 },
+ { 7236, 0x0010 }, { 7237, 0x0100 }, { 7238, 0x0000 }, { 7238, 0x3000 },
+ { 7240, 0xb011 }, { 7245, 0x030a }, { 7249, 0x1001 }, { 7251, 0x0010 },
+ /* 0xcb00 */
+ { 7252, 0x0100 }, { 7253, 0x0111 }, { 7256, 0x0003 }, { 7258, 0x0000 },
+ { 7258, 0x1302 }, { 7262, 0x2301 }, { 7266, 0x0010 }, { 7267, 0x0300 },
+ { 7269, 0x0000 }, { 7269, 0x1000 }, { 7270, 0x0000 }, { 7270, 0x0100 },
+ { 7271, 0x0000 }, { 7271, 0x0010 }, { 7272, 0x0290 }, { 7275, 0x0000 },
+ /* 0xcc00 */
+ { 7275, 0x3000 }, { 7277, 0x3011 }, { 7281, 0x5386 }, { 7288, 0x7b01 },
+ { 7295, 0x1130 }, { 7299, 0x03b0 }, { 7304, 0x0151 }, { 7308, 0x0021 },
+ { 7310, 0x0000 }, { 7310, 0x1300 }, { 7313, 0x3b01 }, { 7319, 0x1130 },
+ { 7323, 0x02b0 }, { 7327, 0x0011 }, { 7329, 0x1010 }, { 7331, 0x0001 },
+ /* 0xcd00 */
+ { 7332, 0x1302 }, { 7336, 0x2b01 }, { 7341, 0x1110 }, { 7344, 0x0200 },
+ { 7345, 0x0000 }, { 7345, 0x1000 }, { 7346, 0xb011 }, { 7351, 0x0102 },
+ { 7353, 0x0100 }, { 7354, 0x1130 }, { 7358, 0x02b0 }, { 7362, 0x0001 },
+ { 7363, 0x1010 }, { 7365, 0x0001 }, { 7366, 0x1100 }, { 7368, 0x2b01 },
+ /* 0xce00 */
+ { 7373, 0x1110 }, { 7376, 0x0210 }, { 7378, 0x0113 }, { 7382, 0x002b },
+ { 7386, 0x0000 }, { 7386, 0x9300 }, { 7390, 0x2b03 }, { 7396, 0x1130 },
+ { 7400, 0x02b0 }, { 7404, 0x0113 }, { 7408, 0x303b }, { 7415, 0x0000 },
+ { 7415, 0x0002 }, { 7416, 0x0000 }, { 7416, 0x1930 }, { 7421, 0x03b0 },
+ /* 0xcf00 */
+ { 7426, 0x0113 }, { 7430, 0x102b }, { 7435, 0xb011 }, { 7440, 0x0103 },
+ { 7443, 0x0000 }, { 7443, 0x1130 }, { 7447, 0x02b0 }, { 7451, 0x0113 },
+ { 7455, 0x1021 }, { 7458, 0x0000 }, { 7458, 0x0102 }, { 7460, 0x0001 },
+ { 7461, 0x0010 }, { 7462, 0x0000 }, { 7462, 0x0113 }, { 7466, 0x102b },
+ /* 0xd000 */
+ { 7471, 0x0011 }, { 7473, 0x0102 }, { 7475, 0x2000 }, { 7476, 0x1130 },
+ { 7480, 0x02b0 }, { 7484, 0x0111 }, { 7487, 0x3001 }, { 7490, 0x3011 },
+ { 7494, 0x0002 }, { 7495, 0x0000 }, { 7495, 0x1130 }, { 7499, 0x02b0 },
+ { 7503, 0x0313 }, { 7508, 0x303b }, { 7515, 0xb011 }, { 7520, 0x0103 },
+ /* 0xd100 */
+ { 7523, 0x2000 }, { 7524, 0x0000 }, { 7524, 0x0000 }, { 7524, 0x0513 },
+ { 7529, 0x303b }, { 7536, 0xb011 }, { 7541, 0x1102 }, { 7544, 0x1000 },
+ { 7545, 0x0110 }, { 7547, 0x0000 }, { 7547, 0x0113 }, { 7551, 0x142b },
+ { 7557, 0x0001 }, { 7558, 0x0100 }, { 7559, 0x0000 }, { 7559, 0x0110 },
+ /* 0xd200 */
+ { 7561, 0x0280 }, { 7563, 0x0001 }, { 7564, 0x3000 }, { 7566, 0xb011 },
+ { 7571, 0x0102 }, { 7573, 0x1000 }, { 7574, 0x0010 }, { 7575, 0x0000 },
+ { 7575, 0x0113 }, { 7579, 0x1023 }, { 7583, 0x1011 }, { 7586, 0x9302 },
+ { 7591, 0x0b05 }, { 7596, 0x1110 }, { 7599, 0x0030 }, { 7601, 0x0113 },
+ /* 0xd300 */
+ { 7605, 0x702b }, { 7612, 0xb051 }, { 7618, 0x1323 }, { 7624, 0x3b01 },
+ { 7630, 0x0030 }, { 7632, 0x0000 }, { 7632, 0x0000 }, { 7632, 0x3000 },
+ { 7634, 0xb011 }, { 7639, 0x1303 }, { 7644, 0x2b01 }, { 7649, 0x1110 },
+ { 7652, 0x0330 }, { 7656, 0x0101 }, { 7658, 0x300a }, { 7662, 0xb011 },
+ /* 0xd400 */
+ { 7667, 0x0102 }, { 7669, 0x2000 }, { 7670, 0x0000 }, { 7670, 0x0000 },
+ { 7670, 0x0011 }, { 7672, 0x1000 }, { 7673, 0xa011 }, { 7677, 0x9300 },
+ { 7681, 0x2b05 }, { 7687, 0x0010 }, { 7688, 0x0200 }, { 7689, 0x0000 },
+ { 7689, 0x1000 }, { 7690, 0x9011 }, { 7694, 0x1100 }, { 7696, 0x2901 },
+ /* 0xd500 */
+ { 7700, 0x1110 }, { 7703, 0x00b0 }, { 7706, 0x0000 }, { 7706, 0x3000 },
+ { 7708, 0xb011 }, { 7713, 0x1302 }, { 7717, 0x2b21 }, { 7723, 0x1130 },
+ { 7727, 0x03b0 }, { 7732, 0x0001 }, { 7733, 0x0020 }, { 7734, 0x0000 },
+ { 7734, 0x1300 }, { 7737, 0x2b05 }, { 7743, 0x1130 }, { 7747, 0x02b0 },
+ /* 0xd600 */
+ { 7751, 0x0113 }, { 7755, 0x103b }, { 7761, 0x2011 }, { 7764, 0x1300 },
+ { 7767, 0x2b21 }, { 7773, 0x1132 }, { 7778, 0x0280 }, { 7780, 0x0013 },
+ { 7783, 0x3028 }, { 7787, 0xa011 }, { 7791, 0x1102 }, { 7794, 0x0a01 },
+ { 7797, 0x1130 }, { 7801, 0x0292 }, { 7805, 0x0111 }, { 7808, 0x3021 },
+ /* 0xd700 */
+ { 7812, 0x0011 }, { 7814, 0x1302 }, { 7818, 0x2b01 }, { 7823, 0x1130 },
+ { 7827, 0x0290 }, { 7830, 0x03d3 }, { 7837, 0x122b }, { 7843, 0x3011 },
+ { 7847, 0x1302 }, { 7851, 0x2b01 },
+};
+static const Summary16 ksc5601_uni2indx_pagef9[17] = {
+ /* 0xf900 */
+ { 7856, 0xffff }, { 7872, 0xffff }, { 7888, 0xffff }, { 7904, 0xffff },
+ { 7920, 0xffff }, { 7936, 0xffff }, { 7952, 0xffff }, { 7968, 0xffff },
+ { 7984, 0xffff }, { 8000, 0xffff }, { 8016, 0xffff }, { 8032, 0xffff },
+ { 8048, 0xffff }, { 8064, 0xffff }, { 8080, 0xffff }, { 8096, 0xffff },
+ /* 0xfa00 */
+ { 8112, 0x0fff },
+};
+static const Summary16 ksc5601_uni2indx_pageff[15] = {
+ /* 0xff00 */
+ { 8124, 0xfffe }, { 8139, 0xffff }, { 8155, 0xffff }, { 8171, 0xffff },
+ { 8187, 0xffff }, { 8203, 0x7fff }, { 8218, 0x0000 }, { 8218, 0x0000 },
+ { 8218, 0x0000 }, { 8218, 0x0000 }, { 8218, 0x0000 }, { 8218, 0x0000 },
+ { 8218, 0x0000 }, { 8218, 0x0000 }, { 8218, 0x006f },
+};
+
+static int
+ksc5601_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ if (n >= 2) {
+ const Summary16 *summary = NULL;
+ if (wc < 0x0460)
+ summary = &ksc5601_uni2indx_page00[(wc>>4)];
+ else if (wc >= 0x2000 && wc < 0x2670)
+ summary = &ksc5601_uni2indx_page20[(wc>>4)-0x200];
+ else if (wc >= 0x3000 && wc < 0x33e0)
+ summary = &ksc5601_uni2indx_page30[(wc>>4)-0x300];
+ else if (wc >= 0x4e00 && wc < 0x9fa0)
+ summary = &ksc5601_uni2indx_page4e[(wc>>4)-0x4e0];
+ else if (wc >= 0xac00 && wc < 0xd7a0)
+ summary = &ksc5601_uni2indx_pageac[(wc>>4)-0xac0];
+ else if (wc >= 0xf900 && wc < 0xfa10)
+ summary = &ksc5601_uni2indx_pagef9[(wc>>4)-0xf90];
+ else if (wc >= 0xff00 && wc < 0xfff0)
+ summary = &ksc5601_uni2indx_pageff[(wc>>4)-0xff0];
+ if (summary) {
+ unsigned short used = summary->used;
+ unsigned int i = wc & 0x0f;
+ if (used & ((unsigned short) 1 << i)) {
+ unsigned short c;
+ /* Keep in `used' only the bits 0..i-1. */
+ used &= ((unsigned short) 1 << i) - 1;
+ /* Add `summary->indx' and the number of bits set in `used'. */
+ used = (used & 0x5555) + ((used & 0xaaaa) >> 1);
+ used = (used & 0x3333) + ((used & 0xcccc) >> 2);
+ used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4);
+ used = (used & 0x00ff) + (used >> 8);
+ c = ksc5601_2charset[summary->indx + used];
+ r[0] = (c >> 8); r[1] = (c & 0xff);
+ return 2;
+ }
+ }
+ return RET_ILSEQ;
+ }
+ return RET_TOOSMALL;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/mulelao.h b/nx-X11/lib/X11/lcUniConv/mulelao.h
new file mode 100644
index 000000000..0e331f81a
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/mulelao.h
@@ -0,0 +1,78 @@
+/* $XFree86$ */
+
+/*
+ * MULELAO-1
+ */
+
+static const unsigned short mulelao_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0x0e81, 0x0e82, 0xfffd, 0x0e84, 0xfffd, 0xfffd, 0x0e87,
+ 0x0e88, 0xfffd, 0x0e8a, 0xfffd, 0xfffd, 0x0e8d, 0xfffd, 0xfffd,
+ /* 0xb0 */
+ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x0e94, 0x0e95, 0x0e96, 0x0e97,
+ 0xfffd, 0x0e99, 0x0e9a, 0x0e9b, 0x0e9c, 0x0e9d, 0x0e9e, 0x0e9f,
+ /* 0xc0 */
+ 0xfffd, 0x0ea1, 0x0ea2, 0x0ea3, 0xfffd, 0x0ea5, 0xfffd, 0x0ea7,
+ 0xfffd, 0xfffd, 0x0eaa, 0x0eab, 0xfffd, 0x0ead, 0x0eae, 0x0eaf,
+ /* 0xd0 */
+ 0x0eb0, 0x0eb1, 0x0eb2, 0x0eb3, 0x0eb4, 0x0eb5, 0x0eb6, 0x0eb7,
+ 0x0eb8, 0x0eb9, 0xfffd, 0x0ebb, 0x0ebc, 0x0ebd, 0xfffd, 0xfffd,
+ /* 0xe0 */
+ 0x0ec0, 0x0ec1, 0x0ec2, 0x0ec3, 0x0ec4, 0xfffd, 0x0ec6, 0xfffd,
+ 0x0ec8, 0x0ec9, 0x0eca, 0x0ecb, 0x0ecc, 0x0ecd, 0xfffd, 0xfffd,
+ /* 0xf0 */
+ 0x0ed0, 0x0ed1, 0x0ed2, 0x0ed3, 0x0ed4, 0x0ed5, 0x0ed6, 0x0ed7,
+ 0x0ed8, 0x0ed9, 0xfffd, 0xfffd, 0x0edc, 0x0edd, 0xfffd, 0xfffd,
+};
+
+static int
+mulelao_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0xa0) {
+ *pwc = (ucs4_t) c;
+ return 1;
+ }
+ else {
+ unsigned short wc = mulelao_2uni[c-0xa0];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 1;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned char mulelao_page0e[96] = {
+ 0x00, 0xa1, 0xa2, 0x00, 0xa4, 0x00, 0x00, 0xa7, /* 0x80-0x87 */
+ 0xa8, 0x00, 0xaa, 0x00, 0x00, 0xad, 0x00, 0x00, /* 0x88-0x8f */
+ 0x00, 0x00, 0x00, 0x00, 0xb4, 0xb5, 0xb6, 0xb7, /* 0x90-0x97 */
+ 0x00, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* 0x98-0x9f */
+ 0x00, 0xc1, 0xc2, 0xc3, 0x00, 0xc5, 0x00, 0xc7, /* 0xa0-0xa7 */
+ 0x00, 0x00, 0xca, 0xcb, 0x00, 0xcd, 0xce, 0xcf, /* 0xa8-0xaf */
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xb0-0xb7 */
+ 0xd8, 0xd9, 0x00, 0xdb, 0xdc, 0xdd, 0x00, 0x00, /* 0xb8-0xbf */
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0x00, 0xe6, 0x00, /* 0xc0-0xc7 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0x00, 0x00, /* 0xc8-0xcf */
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xd0-0xd7 */
+ 0xf8, 0xf9, 0x00, 0x00, 0xfc, 0xfd, 0x00, 0x00, /* 0xd8-0xdf */
+};
+
+static int
+mulelao_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc == 0x00a0)
+ c = 0xa0;
+ else if (wc >= 0x0e80 && wc < 0x0ee0)
+ c = mulelao_page0e[wc-0x0e80];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/tatar_cyr.h b/nx-X11/lib/X11/lcUniConv/tatar_cyr.h
new file mode 100644
index 000000000..5783fd925
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/tatar_cyr.h
@@ -0,0 +1,123 @@
+/* $XFree86: xc/lib/X11/lcUniConv/tatar_cyr.h,v 1.2 2000/11/28 16:10:31 dawes Exp $ */
+
+/*
+ * TATAR-CYR
+ */
+
+static const unsigned short tatar_cyr_2uni[128] = {
+ /* 0x80 */
+ 0x04d8, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x20ac, 0x2030, 0x04e8, 0x2039, 0x04ae, 0x0496, 0x04a2, 0x04ba,
+ /* 0x90 */
+ 0x04d9, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x98, 0x2122, 0x04e9, 0x203a, 0x04af, 0x0497, 0x04a3, 0x04bb,
+ /* 0xa0 */
+ 0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7,
+ 0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407,
+ /* 0xb0 */
+ 0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7,
+ 0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457,
+ /* 0xc0 */
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+ 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
+ /* 0xd0 */
+ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+ 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
+ /* 0xe0 */
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+ 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
+ /* 0xf0 */
+ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+ 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
+};
+
+static int
+tatar_cyr_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0x80)
+ *pwc = (ucs4_t) c;
+ else
+ *pwc = (ucs4_t) tatar_cyr_2uni[c-0x80];
+ return 1;
+}
+
+static const unsigned char tatar_cyr_page00[32] = {
+ 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */
+ 0x00, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0x00, /* 0xa8-0xaf */
+ 0xb0, 0xb1, 0x00, 0x00, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
+ 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+};
+static const unsigned char tatar_cyr_page04[240] = {
+ 0x00, 0xa8, 0x00, 0x81, 0xaa, 0xbd, 0xb2, 0xaf, /* 0x00-0x07 */
+ 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa1, 0x00, /* 0x08-0x0f */
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x10-0x17 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x18-0x1f */
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x20-0x27 */
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0x28-0x2f */
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x30-0x37 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x38-0x3f */
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x40-0x47 */
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0x48-0x4f */
+ 0x00, 0xb8, 0x00, 0x83, 0xba, 0xbe, 0xb3, 0xbf, /* 0x50-0x57 */
+ 0xbc, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa2, 0x00, /* 0x58-0x5f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+ 0xa5, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x8d, 0x9d, /* 0x90-0x97 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
+ 0x00, 0x00, 0x8e, 0x9e, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x9c, /* 0xa8-0xaf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
+ 0x00, 0x00, 0x8f, 0x9f, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+ 0x80, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
+ 0x8a, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
+};
+static const unsigned char tatar_cyr_page20[48] = {
+ 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */
+ 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+};
+static const unsigned char tatar_cyr_page21[24] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb9, 0x00, /* 0x10-0x17 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+};
+static const unsigned char tatar_cyr_page22[1] = {
+ 0xb0, /* 0x16-0x16 */
+};
+
+static int
+tatar_cyr_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0080) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x00bc)
+ c = tatar_cyr_page00[wc-0x00a0];
+ else if (wc >= 0x0400 && wc < 0x04ef)
+ c = tatar_cyr_page04[wc-0x0400];
+ else if (wc >= 0x2010 && wc < 0x203b)
+ c = tatar_cyr_page20[wc-0x2010];
+ else if (wc == 0x20ac)
+ c = 0x88;
+ else if (wc >= 0x2110 && wc < 0x2123)
+ c = tatar_cyr_page21[wc-0x2110];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/tcvn.h b/nx-X11/lib/X11/lcUniConv/tcvn.h
new file mode 100644
index 000000000..eb80ab3f7
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/tcvn.h
@@ -0,0 +1,134 @@
+/* $XFree86$ */
+
+/*
+ * TCVN-5712
+ */
+
+static const unsigned short tcvn_2uni_1[32] = {
+ /* 0x00 */
+ 0x0000, 0x00da, 0x1ee4, 0x0003, 0x1eea, 0x1eec, 0x1eee, 0x0007,
+ 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
+ /* 0x10 */
+ 0x0010, 0x1ee8, 0x1ef0, 0x1ef2, 0x1ef6, 0x1ef8, 0x00dd, 0x1ef4,
+ 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
+};
+static const unsigned short tcvn_2uni_2[128] = {
+ /* 0x80 */
+ 0x00c0, 0x1ea2, 0x00c3, 0x00c1, 0x1ea0, 0x1eb6, 0x1eac, 0x00c8,
+ 0x1eba, 0x1ebc, 0x00c9, 0x1eb8, 0x1ec6, 0x00cc, 0x1ec8, 0x0128,
+ /* 0x90 */
+ 0x00cd, 0x1eca, 0x00d2, 0x1ece, 0x00d5, 0x00d3, 0x1ecc, 0x1ed8,
+ 0x1edc, 0x1ede, 0x1ee0, 0x1eda, 0x1ee2, 0x00d9, 0x1ee6, 0x0168,
+ /* 0xa0 */
+ 0x00a0, 0x0102, 0x00c2, 0x00ca, 0x00d4, 0x01a0, 0x01af, 0x0110,
+ 0x0103, 0x00e2, 0x00ea, 0x00f4, 0x01a1, 0x01b0, 0x0111, 0x1eb0,
+ /* 0xb0 */
+ 0x0300, 0x0309, 0x0303, 0x0301, 0x0323, 0x00e0, 0x1ea3, 0x00e3,
+ 0x00e1, 0x1ea1, 0x1eb2, 0x1eb1, 0x1eb3, 0x1eb5, 0x1eaf, 0x1eb4,
+ /* 0xc0 */
+ 0x1eae, 0x1ea6, 0x1ea8, 0x1eaa, 0x1ea4, 0x1ec0, 0x1eb7, 0x1ea7,
+ 0x1ea9, 0x1eab, 0x1ea5, 0x1ead, 0x00e8, 0x1ec2, 0x1ebb, 0x1ebd,
+ /* 0xd0 */
+ 0x00e9, 0x1eb9, 0x1ec1, 0x1ec3, 0x1ec5, 0x1ebf, 0x1ec7, 0x00ec,
+ 0x1ec9, 0x1ec4, 0x1ebe, 0x1ed2, 0x0129, 0x00ed, 0x1ecb, 0x00f2,
+ /* 0xe0 */
+ 0x1ed4, 0x1ecf, 0x00f5, 0x00f3, 0x1ecd, 0x1ed3, 0x1ed5, 0x1ed7,
+ 0x1ed1, 0x1ed9, 0x1edd, 0x1edf, 0x1ee1, 0x1edb, 0x1ee3, 0x00f9,
+ /* 0xf0 */
+ 0x1ed6, 0x1ee7, 0x0169, 0x00fa, 0x1ee5, 0x1eeb, 0x1eed, 0x1eef,
+ 0x1ee9, 0x1ef1, 0x1ef3, 0x1ef7, 0x1ef9, 0x00fd, 0x1ef5, 0x1ed0,
+};
+
+static int
+tcvn_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0x20)
+ *pwc = (ucs4_t) tcvn_2uni_1[c];
+ else if (c < 0x80)
+ *pwc = (ucs4_t) c;
+ else
+ *pwc = (ucs4_t) tcvn_2uni_2[c-0x80];
+ return 1;
+}
+
+static const unsigned char tcvn_page00[96+184] = {
+ 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+ 0x80, 0x83, 0xa2, 0x82, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+ 0x87, 0x8a, 0xa3, 0x00, 0x8d, 0x90, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x92, 0x95, 0xa4, 0x94, 0x00, 0x00, /* 0xd0-0xd7 */
+ 0x00, 0x9d, 0x01, 0x00, 0x00, 0x16, 0x00, 0x00, /* 0xd8-0xdf */
+ 0xb5, 0xb8, 0xa9, 0xb7, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
+ 0xcc, 0xd0, 0xaa, 0x00, 0xd7, 0xdd, 0x00, 0x00, /* 0xe8-0xef */
+ 0x00, 0x00, 0xdf, 0xe3, 0xab, 0xe2, 0x00, 0x00, /* 0xf0-0xf7 */
+ 0x00, 0xef, 0xf3, 0x00, 0x00, 0xfd, 0x00, 0x00, /* 0xf8-0xff */
+ /* 0x0100 */
+ 0x00, 0x00, 0xa1, 0xa8, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */
+ 0xa7, 0xae, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0x8f, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x9f, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
+ 0xa5, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, /* 0xa8-0xaf */
+ 0xad, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
+};
+static const unsigned char tcvn_page03[40] = {
+ 0xb0, 0xb3, 0x00, 0xb2, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */
+ 0x00, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+};
+static const unsigned char tcvn_page1e[96] = {
+ 0x84, 0xb9, 0x81, 0xb6, 0xc4, 0xca, 0xc1, 0xc7, /* 0xa0-0xa7 */
+ 0xc2, 0xc8, 0xc3, 0xc9, 0x86, 0xcb, 0xc0, 0xbe, /* 0xa8-0xaf */
+ 0xaf, 0xbb, 0xba, 0xbc, 0xbf, 0xbd, 0x85, 0xc6, /* 0xb0-0xb7 */
+ 0x8b, 0xd1, 0x88, 0xce, 0x89, 0xcf, 0xda, 0xd5, /* 0xb8-0xbf */
+ 0xc5, 0xd2, 0xcd, 0xd3, 0xd9, 0xd4, 0x8c, 0xd6, /* 0xc0-0xc7 */
+ 0x8e, 0xd8, 0x91, 0xde, 0x96, 0xe4, 0x93, 0xe1, /* 0xc8-0xcf */
+ 0xff, 0xe8, 0xdb, 0xe5, 0xe0, 0xe6, 0xf0, 0xe7, /* 0xd0-0xd7 */
+ 0x97, 0xe9, 0x9b, 0xed, 0x98, 0xea, 0x99, 0xeb, /* 0xd8-0xdf */
+ 0x9a, 0xec, 0x9c, 0xee, 0x02, 0xf4, 0x9e, 0xf1, /* 0xe0-0xe7 */
+ 0x11, 0xf8, 0x04, 0xf5, 0x05, 0xf6, 0x06, 0xf7, /* 0xe8-0xef */
+ 0x12, 0xf9, 0x13, 0xfa, 0x17, 0xfe, 0x14, 0xfb, /* 0xf0-0xf7 */
+ 0x15, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */
+};
+
+static int
+tcvn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0080 && (wc >= 0x0020 || (0x00fe0076 & (1 << wc)) == 0)) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x01b8)
+ c = tcvn_page00[wc-0x00a0];
+ else if (wc >= 0x0300 && wc < 0x0328)
+ c = tcvn_page03[wc-0x0300];
+ else if (wc >= 0x1ea0 && wc < 0x1f00)
+ c = tcvn_page1e[wc-0x1ea0];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/tis620.h b/nx-X11/lib/X11/lcUniConv/tis620.h
new file mode 100644
index 000000000..deda9769d
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/tis620.h
@@ -0,0 +1,78 @@
+/* $XFree86: xc/lib/X11/lcUniConv/tis620.h,v 1.3 2000/11/29 17:40:35 dawes Exp $ */
+
+/*
+ * TIS620-0
+ */
+
+static const unsigned short tis620_2uni[96] = {
+ /* 0xa0 */
+ 0xfffd, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07,
+ 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f,
+ /* 0xb0 */
+ 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17,
+ 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f,
+ /* 0xc0 */
+ 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27,
+ 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f,
+ /* 0xd0 */
+ 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37,
+ 0x0e38, 0x0e39, 0x0e3a, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x0e3f,
+ /* 0xe0 */
+ 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47,
+ 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f,
+ /* 0xf0 */
+ 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57,
+ 0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+};
+
+static int
+tis620_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0x80) {
+ *pwc = (ucs4_t) c;
+ return 1;
+ }
+ else if (c < 0xa0) {
+ }
+ else {
+ unsigned short wc = tis620_2uni[c-0xa0];
+ if (wc != 0xfffd) {
+ *pwc = (ucs4_t) wc;
+ return 1;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static const unsigned char tis620_page0e[96] = {
+ 0x00, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0x00-0x07 */
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0x08-0x0f */
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0x10-0x17 */
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* 0x18-0x1f */
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x20-0x27 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x28-0x2f */
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x30-0x37 */
+ 0xd8, 0xd9, 0xda, 0x00, 0x00, 0x00, 0x00, 0xdf, /* 0x38-0x3f */
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x40-0x47 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x48-0x4f */
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x50-0x57 */
+ 0xf8, 0xf9, 0xfa, 0xfb, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+};
+
+static int
+tis620_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0080) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x0e00 && wc < 0x0e60)
+ c = tis620_page0e[wc-0x0e00];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/ucs2be.h b/nx-X11/lib/X11/lcUniConv/ucs2be.h
new file mode 100644
index 000000000..ff9acc39f
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/ucs2be.h
@@ -0,0 +1,32 @@
+/*
+ * UCS-2BE = UCS-2 big endian
+ */
+/* $XFree86$ */
+
+static int
+ucs2be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ if (n >= 2) {
+ if (s[0] >= 0xd8 && s[0] < 0xe0) {
+ return RET_ILSEQ;
+ } else {
+ *pwc = (s[0] << 8) + s[1];
+ return 2;
+ }
+ }
+ return RET_TOOFEW(0);
+}
+
+static int
+ucs2be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ if (wc < 0x10000 && !(wc >= 0xd800 && wc < 0xe000)) {
+ if (n >= 2) {
+ r[0] = (unsigned char) (wc >> 8);
+ r[1] = (unsigned char) wc;
+ return 2;
+ } else
+ return RET_TOOSMALL;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/utf8.h b/nx-X11/lib/X11/lcUniConv/utf8.h
new file mode 100644
index 000000000..f8c2a7d8a
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/utf8.h
@@ -0,0 +1,110 @@
+/* $XFree86: xc/lib/X11/lcUniConv/utf8.h,v 1.2 2000/11/28 16:10:32 dawes Exp $ */
+
+/*
+ * UTF-8
+ */
+
+/* Specification: RFC 2279 */
+
+static int
+utf8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = s[0];
+
+ if (c < 0x80) {
+ *pwc = c;
+ return 1;
+ } else if (c < 0xc2) {
+ return RET_ILSEQ;
+ } else if (c < 0xe0) {
+ if (n < 2)
+ return RET_TOOFEW(0);
+ if (!((s[1] ^ 0x80) < 0x40))
+ return RET_ILSEQ;
+ *pwc = ((ucs4_t) (c & 0x1f) << 6)
+ | (ucs4_t) (s[1] ^ 0x80);
+ return 2;
+ } else if (c < 0xf0) {
+ if (n < 3)
+ return RET_TOOFEW(0);
+ if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (c >= 0xe1 || s[1] >= 0xa0)))
+ return RET_ILSEQ;
+ *pwc = ((ucs4_t) (c & 0x0f) << 12)
+ | ((ucs4_t) (s[1] ^ 0x80) << 6)
+ | (ucs4_t) (s[2] ^ 0x80);
+ return 3;
+ } else if (c < 0xf8) {
+ if (n < 4)
+ return RET_TOOFEW(0);
+ if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40
+ && (c >= 0xf1 || s[1] >= 0x90)))
+ return RET_ILSEQ;
+ *pwc = ((ucs4_t) (c & 0x07) << 18)
+ | ((ucs4_t) (s[1] ^ 0x80) << 12)
+ | ((ucs4_t) (s[2] ^ 0x80) << 6)
+ | (ucs4_t) (s[3] ^ 0x80);
+ return 4;
+ } else if (c < 0xfc) {
+ if (n < 5)
+ return RET_TOOFEW(0);
+ if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (c >= 0xf9 || s[1] >= 0x88)))
+ return RET_ILSEQ;
+ *pwc = ((ucs4_t) (c & 0x03) << 24)
+ | ((ucs4_t) (s[1] ^ 0x80) << 18)
+ | ((ucs4_t) (s[2] ^ 0x80) << 12)
+ | ((ucs4_t) (s[3] ^ 0x80) << 6)
+ | (ucs4_t) (s[4] ^ 0x80);
+ return 5;
+ } else if (c < 0xfe) {
+ if (n < 6)
+ return RET_TOOFEW(0);
+ if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (s[5] ^ 0x80) < 0x40
+ && (c >= 0xfd || s[1] >= 0x84)))
+ return RET_ILSEQ;
+ *pwc = ((ucs4_t) (c & 0x01) << 30)
+ | ((ucs4_t) (s[1] ^ 0x80) << 24)
+ | ((ucs4_t) (s[2] ^ 0x80) << 18)
+ | ((ucs4_t) (s[3] ^ 0x80) << 12)
+ | ((ucs4_t) (s[4] ^ 0x80) << 6)
+ | (ucs4_t) (s[5] ^ 0x80);
+ return 6;
+ } else
+ return RET_ILSEQ;
+}
+
+static int
+utf8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) /* n == 0 is acceptable */
+{
+ int count;
+ if (wc < 0x80)
+ count = 1;
+ else if (wc < 0x800)
+ count = 2;
+ else if (wc < 0x10000)
+ count = 3;
+ else if (wc < 0x200000)
+ count = 4;
+ else if (wc < 0x4000000)
+ count = 5;
+ else if (wc <= 0x7fffffff)
+ count = 6;
+ else
+ return RET_ILSEQ;
+ if (n < count)
+ return RET_TOOSMALL;
+ switch (count) { /* note: code falls through cases! */
+ case 6: r[5] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x4000000;
+ case 5: r[4] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x200000;
+ case 4: r[3] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x10000;
+ case 3: r[2] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x800;
+ case 2: r[1] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0xc0;
+ case 1: r[0] = wc;
+ }
+ return count;
+}
diff --git a/nx-X11/lib/X11/lcUniConv/viscii.h b/nx-X11/lib/X11/lcUniConv/viscii.h
new file mode 100644
index 000000000..f7dfd4473
--- /dev/null
+++ b/nx-X11/lib/X11/lcUniConv/viscii.h
@@ -0,0 +1,123 @@
+/* $XFree86$ */
+
+/*
+ * VISCII1.1-1
+ */
+
+/* Specification: RFC 1456 */
+
+static const unsigned short viscii_2uni_1[32] = {
+ /* 0x00 */
+ 0x0000, 0x0001, 0x1eb2, 0x0003, 0x0004, 0x1eb4, 0x1eaa, 0x0007,
+ 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
+ /* 0x10 */
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x1ef6, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x1ef8, 0x001a, 0x001b, 0x001c, 0x001d, 0x1ef4, 0x001f,
+};
+static const unsigned short viscii_2uni_2[128] = {
+ /* 0x80 */
+ 0x1ea0, 0x1eae, 0x1eb0, 0x1eb6, 0x1ea4, 0x1ea6, 0x1ea8, 0x1eac,
+ 0x1ebc, 0x1eb8, 0x1ebe, 0x1ec0, 0x1ec2, 0x1ec4, 0x1ec6, 0x1ed0,
+ /* 0x90 */
+ 0x1ed2, 0x1ed4, 0x1ed6, 0x1ed8, 0x1ee2, 0x1eda, 0x1edc, 0x1ede,
+ 0x1eca, 0x1ece, 0x1ecc, 0x1ec8, 0x1ee6, 0x0168, 0x1ee4, 0x1ef2,
+ /* 0xa0 */
+ 0x00d5, 0x1eaf, 0x1eb1, 0x1eb7, 0x1ea5, 0x1ea7, 0x1ea9, 0x1ead,
+ 0x1ebd, 0x1eb9, 0x1ebf, 0x1ec1, 0x1ec3, 0x1ec5, 0x1ec7, 0x1ed1,
+ /* 0xb0 */
+ 0x1ed3, 0x1ed5, 0x1ed7, 0x1ee0, 0x01a0, 0x1ed9, 0x1edd, 0x1edf,
+ 0x1ecb, 0x1ef0, 0x1ee8, 0x1eea, 0x1eec, 0x01a1, 0x1edb, 0x01af,
+ /* 0xc0 */
+ 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x1ea2, 0x0102, 0x1eb3, 0x1eb5,
+ 0x00c8, 0x00c9, 0x00ca, 0x1eba, 0x00cc, 0x00cd, 0x0128, 0x1ef3,
+ /* 0xd0 */
+ 0x0110, 0x1ee9, 0x00d2, 0x00d3, 0x00d4, 0x1ea1, 0x1ef7, 0x1eeb,
+ 0x1eed, 0x00d9, 0x00da, 0x1ef9, 0x1ef5, 0x00dd, 0x1ee1, 0x01b0,
+ /* 0xe0 */
+ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x1ea3, 0x0103, 0x1eef, 0x1eab,
+ 0x00e8, 0x00e9, 0x00ea, 0x1ebb, 0x00ec, 0x00ed, 0x0129, 0x1ec9,
+ /* 0xf0 */
+ 0x0111, 0x1ef1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x1ecf, 0x1ecd,
+ 0x1ee5, 0x00f9, 0x00fa, 0x0169, 0x1ee7, 0x00fd, 0x1ee3, 0x1eee,
+};
+
+static int
+viscii_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0x20)
+ *pwc = (ucs4_t) viscii_2uni_1[c];
+ else if (c < 0x80)
+ *pwc = (ucs4_t) c;
+ else
+ *pwc = (ucs4_t) viscii_2uni_2[c-0x80];
+ return 1;
+}
+
+static const unsigned char viscii_page00[64+184] = {
+ 0xc0, 0xc1, 0xc2, 0xc3, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+ 0xc8, 0xc9, 0xca, 0x00, 0xcc, 0xcd, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0xd2, 0xd3, 0xd4, 0xa0, 0x00, 0x00, /* 0xd0-0xd7 */
+ 0x00, 0xd9, 0xda, 0x00, 0x00, 0xdd, 0x00, 0x00, /* 0xd8-0xdf */
+ 0xe0, 0xe1, 0xe2, 0xe3, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
+ 0xe8, 0xe9, 0xea, 0x00, 0xec, 0xed, 0x00, 0x00, /* 0xe8-0xef */
+ 0x00, 0x00, 0xf2, 0xf3, 0xf4, 0xf5, 0x00, 0x00, /* 0xf0-0xf7 */
+ 0x00, 0xf9, 0xfa, 0x00, 0x00, 0xfd, 0x00, 0x00, /* 0xf8-0xff */
+ /* 0x0100 */
+ 0x00, 0x00, 0xc5, 0xe5, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */
+ 0xd0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0xce, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x9d, 0xfb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
+ 0xb4, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf, /* 0xa8-0xaf */
+ 0xdf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
+};
+static const unsigned char viscii_page1e[96] = {
+ 0x80, 0xd5, 0xc4, 0xe4, 0x84, 0xa4, 0x85, 0xa5, /* 0xa0-0xa7 */
+ 0x86, 0xa6, 0x06, 0xe7, 0x87, 0xa7, 0x81, 0xa1, /* 0xa8-0xaf */
+ 0x82, 0xa2, 0x02, 0xc6, 0x05, 0xc7, 0x83, 0xa3, /* 0xb0-0xb7 */
+ 0x89, 0xa9, 0xcb, 0xeb, 0x88, 0xa8, 0x8a, 0xaa, /* 0xb8-0xbf */
+ 0x8b, 0xab, 0x8c, 0xac, 0x8d, 0xad, 0x8e, 0xae, /* 0xc0-0xc7 */
+ 0x9b, 0xef, 0x98, 0xb8, 0x9a, 0xf7, 0x99, 0xf6, /* 0xc8-0xcf */
+ 0x8f, 0xaf, 0x90, 0xb0, 0x91, 0xb1, 0x92, 0xb2, /* 0xd0-0xd7 */
+ 0x93, 0xb5, 0x95, 0xbe, 0x96, 0xb6, 0x97, 0xb7, /* 0xd8-0xdf */
+ 0xb3, 0xde, 0x94, 0xfe, 0x9e, 0xf8, 0x9c, 0xfc, /* 0xe0-0xe7 */
+ 0xba, 0xd1, 0xbb, 0xd7, 0xbc, 0xd8, 0xff, 0xe6, /* 0xe8-0xef */
+ 0xb9, 0xf1, 0x9f, 0xcf, 0x1e, 0xdc, 0x14, 0xd6, /* 0xf0-0xf7 */
+ 0x19, 0xdb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */
+};
+
+static int
+viscii_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x0080 && (wc >= 0x0020 || (0x42100064 & (1 << wc)) == 0)) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00c0 && wc < 0x01b8)
+ c = viscii_page00[wc-0x00c0];
+ else if (wc >= 0x1ea0 && wc < 0x1f00)
+ c = viscii_page1e[wc-0x1ea0];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/nx-X11/lib/X11/lcUtil.c b/nx-X11/lib/X11/lcUtil.c
new file mode 100644
index 000000000..ab1db0083
--- /dev/null
+++ b/nx-X11/lib/X11/lcUtil.c
@@ -0,0 +1,88 @@
+/* $Xorg: lcUtil.c,v 1.3 2000/08/17 19:45:20 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ * Bug fixes: Bruno Haible XFree86 Inc.
+ */
+/* $XFree86: xc/lib/X11/lcUtil.c,v 1.3 2000/11/29 17:40:24 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include "XlcPublic.h"
+
+/* Don't use <ctype.h> here because it is locale dependent. */
+
+#define set_toupper(ch) \
+ if (ch >= 'a' && ch <= 'z') \
+ ch = ch - 'a' + 'A';
+
+/* Compares two ISO 8859-1 strings, ignoring case of ASCII letters.
+ Like strcasecmp in an ASCII locale. */
+int
+_XlcCompareISOLatin1(
+ const char *str1,
+ const char *str2)
+{
+ unsigned char ch1, ch2;
+
+ for ( ; ; str1++, str2++) {
+ ch1 = *str1;
+ ch2 = *str2;
+ if (ch1 == '\0' || ch2 == '\0')
+ break;
+ set_toupper(ch1);
+ set_toupper(ch2);
+ if (ch1 != ch2)
+ break;
+ }
+
+ return ch1 - ch2;
+}
+
+/* Compares two ISO 8859-1 strings, at most len bytes of each, ignoring
+ case of ASCII letters. Like strncasecmp in an ASCII locale. */
+int
+_XlcNCompareISOLatin1(
+ const char *str1,
+ const char *str2,
+ int len)
+{
+ unsigned char ch1, ch2;
+
+ for ( ; ; str1++, str2++, len--) {
+ if (len == 0)
+ return 0;
+ ch1 = *str1;
+ ch2 = *str2;
+ if (ch1 == '\0' || ch2 == '\0')
+ break;
+ set_toupper(ch1);
+ set_toupper(ch2);
+ if (ch1 != ch2)
+ break;
+ }
+
+ return ch1 - ch2;
+}
diff --git a/nx-X11/lib/X11/lcWrap.c b/nx-X11/lib/X11/lcWrap.c
new file mode 100644
index 000000000..ea2623191
--- /dev/null
+++ b/nx-X11/lib/X11/lcWrap.c
@@ -0,0 +1,651 @@
+/* $Xorg: lcWrap.c,v 1.6 2001/02/09 02:03:39 xorgcvs Exp $ */
+/*
+
+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.
+
+*/
+/*
+ * 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 names of Open Software Foundation and TOSHIBA
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Open Software
+ * Foundation and TOSHIBA make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OPEN SOFTWARE FOUNDATION AND TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OPEN SOFTWARE FOUNDATIONN OR TOSHIBA 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.
+ */
+/* $XFree86: xc/lib/X11/lcWrap.c,v 3.15 2003/04/13 19:22:22 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdlib.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include <X11/Xlocale.h>
+#include <X11/Xos.h>
+#ifdef WIN32
+#undef close
+#endif
+#include <X11/Xutil.h>
+#include "XlcPubI.h"
+
+#ifdef XTHREADS
+LockInfoPtr _Xi18n_lock;
+#endif
+
+char *
+XSetLocaleModifiers(
+ const char *modifiers)
+{
+ XLCd lcd = _XlcCurrentLC();
+ char *user_mods;
+
+ if (!lcd)
+ return (char *) NULL;
+ if (!modifiers)
+ return lcd->core->modifiers;
+ user_mods = getenv("XMODIFIERS");
+ modifiers = (*lcd->methods->map_modifiers) (lcd,
+ user_mods, (char *)modifiers);
+ if (modifiers) {
+ if (lcd->core->modifiers)
+ Xfree(lcd->core->modifiers);
+ lcd->core->modifiers = (char *)modifiers;
+ }
+ return (char *)modifiers;
+}
+
+Bool
+XSupportsLocale()
+{
+ return _XlcCurrentLC() != (XLCd)NULL;
+}
+
+Bool _XlcValidModSyntax(
+ const char * mods,
+ const char * const *valid_mods)
+{
+ int i;
+ const char * const *ptr;
+
+ while (mods && (*mods == '@')) {
+ mods++;
+ if (*mods == '@')
+ break;
+ for (ptr = valid_mods; *ptr; ptr++) {
+ i = strlen(*ptr);
+ if (strncmp(mods, *ptr, i) || ((mods[i] != '=')
+#ifdef WIN32
+ && (mods[i] != '#')
+#endif
+ ))
+ continue;
+ mods = strchr(mods+i+1, '@');
+ break;
+ }
+ }
+ return !mods || !*mods;
+}
+
+static const char *im_valid[] = {"im", (const char *)NULL};
+
+/*ARGSUSED*/
+char *
+_XlcDefaultMapModifiers(
+ XLCd lcd,
+ const char *user_mods,
+ const char *prog_mods)
+{
+ int i;
+ char *mods;
+
+ if (!_XlcValidModSyntax(prog_mods, im_valid))
+ return (char *)NULL;
+ if (!_XlcValidModSyntax(user_mods, im_valid))
+ return (char *)NULL;
+ i = strlen(prog_mods) + 1;
+ if (user_mods)
+ i += strlen(user_mods);
+ mods = Xmalloc(i);
+ if (mods) {
+ strcpy(mods, prog_mods);
+ if (user_mods)
+ strcat(mods, user_mods);
+#ifdef WIN32
+ {
+ char *s;
+ for (s = mods; s = strchr(s, '@'); s++) {
+ for (s++; *s && *s != '='; s++) {
+ if (*s == '#') {
+ *s = '=';
+ break;
+ }
+ }
+ }
+ }
+#endif
+ }
+ return mods;
+}
+
+typedef struct _XLCdListRec {
+ struct _XLCdListRec *next;
+ XLCd lcd;
+ int ref_count;
+} XLCdListRec, *XLCdList;
+
+static XLCdList lcd_list = NULL;
+
+typedef struct _XlcLoaderListRec {
+ struct _XlcLoaderListRec *next;
+ XLCdLoadProc proc;
+} XlcLoaderListRec, *XlcLoaderList;
+
+static XlcLoaderList loader_list = NULL;
+
+void
+_XlcRemoveLoader(
+ XLCdLoadProc proc)
+{
+ XlcLoaderList loader, prev;
+
+ if (loader_list == NULL)
+ return;
+
+ prev = loader = loader_list;
+ if (loader->proc == proc) {
+ loader_list = loader->next;
+ Xfree(loader);
+ return;
+ }
+
+ while ((loader = loader->next)) {
+ if (loader->proc == proc) {
+ prev->next = loader->next;
+ Xfree(loader);
+ return;
+ }
+ prev = loader;
+ }
+
+ return;
+}
+
+Bool
+_XlcAddLoader(
+ XLCdLoadProc proc,
+ XlcPosition position)
+{
+ XlcLoaderList loader, last;
+
+ _XlcRemoveLoader(proc); /* remove old loader, if exist */
+
+ loader = (XlcLoaderList) Xmalloc(sizeof(XlcLoaderListRec));
+ if (loader == NULL)
+ return False;
+
+ loader->proc = proc;
+
+ if (loader_list == NULL)
+ position = XlcHead;
+
+ if (position == XlcHead) {
+ loader->next = loader_list;
+ loader_list = loader;
+ } else {
+ last = loader_list;
+ while (last->next)
+ last = last->next;
+
+ loader->next = NULL;
+ last->next = loader;
+ }
+
+ return True;
+}
+
+XLCd
+_XOpenLC(
+ char *name)
+{
+ XLCd lcd;
+ XlcLoaderList loader;
+ XLCdList cur;
+#if !defined(X_LOCALE)
+ int len;
+ char sinamebuf[256];
+ char* siname = sinamebuf;
+#endif
+
+ if (name == NULL) {
+ name = setlocale (LC_CTYPE, (char *)NULL);
+#if !defined(X_LOCALE)
+ /*
+ * _XlMapOSLocaleName will return the same string or a substring
+ * of name, so strlen(name) is okay
+ */
+ if ((len = strlen(name)) >= sizeof sinamebuf) {
+ siname = Xmalloc (len + 1);
+ if (siname == NULL)
+ return NULL;
+ }
+ name = _XlcMapOSLocaleName(name, siname);
+#endif
+ }
+
+ _XLockMutex(_Xi18n_lock);
+
+ /*
+ * search for needed lcd, if found return it
+ */
+ for (cur = lcd_list; cur; cur = cur->next) {
+ if (!strcmp (cur->lcd->core->name, name)) {
+ lcd = cur->lcd;
+ cur->ref_count++;
+ goto found;
+ }
+ }
+
+ if (!loader_list)
+ _XlcInitLoader();
+
+ /*
+ * not there, so try to get and add to list
+ */
+ for (loader = loader_list; loader; loader = loader->next) {
+ lcd = (*loader->proc)(name);
+ if (lcd) {
+ cur = (XLCdList) Xmalloc (sizeof(XLCdListRec));
+ if (cur) {
+ cur->lcd = lcd;
+ cur->ref_count = 1;
+ cur->next = lcd_list;
+ lcd_list = cur;
+ } else {
+ (*lcd->methods->close)(lcd);
+ lcd = (XLCd) NULL;
+ }
+ goto found;
+ }
+ }
+
+ lcd = NULL;
+
+found:
+ _XUnlockMutex(_Xi18n_lock);
+
+#if !defined(X_LOCALE)
+ if (siname != sinamebuf) Xfree(siname);
+#endif
+
+ return lcd;
+}
+
+void
+_XCloseLC(
+ XLCd lcd)
+{
+ XLCdList cur, *prev;
+
+ for (prev = &lcd_list; (cur = *prev); prev = &cur->next) {
+ if (cur->lcd == lcd) {
+ if (--cur->ref_count < 1) {
+ (*lcd->methods->close)(lcd);
+ *prev = cur->next;
+ Xfree(cur);
+ }
+ break;
+ }
+ }
+
+ if(loader_list) {
+ _XlcDeInitLoader();
+ loader_list = NULL;
+ }
+}
+
+/*
+ * Get the XLCd for the current locale
+ */
+
+XLCd
+_XlcCurrentLC()
+{
+ XLCd lcd;
+ static XLCd last_lcd = NULL;
+
+ lcd = _XOpenLC((char *) NULL);
+
+ if (last_lcd)
+ _XCloseLC(last_lcd);
+
+ last_lcd = lcd;
+
+ return lcd;
+}
+
+XrmMethods
+_XrmInitParseInfo(
+ XPointer *state)
+{
+ XLCd lcd = _XOpenLC((char *) NULL);
+
+ if (lcd == (XLCd) NULL)
+ return (XrmMethods) NULL;
+
+ return (*lcd->methods->init_parse_info)(lcd, state);
+}
+
+int
+XmbTextPropertyToTextList(
+ Display *dpy,
+ const XTextProperty *text_prop,
+ char ***list_ret,
+ int *count_ret)
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return XLocaleNotSupported;
+
+ return (*lcd->methods->mb_text_prop_to_list)(lcd, dpy, text_prop, list_ret,
+ count_ret);
+}
+
+int
+XwcTextPropertyToTextList(
+ Display *dpy,
+ const XTextProperty *text_prop,
+ wchar_t ***list_ret,
+ int *count_ret)
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return XLocaleNotSupported;
+
+ return (*lcd->methods->wc_text_prop_to_list)(lcd, dpy, text_prop, list_ret,
+ count_ret);
+}
+
+int
+Xutf8TextPropertyToTextList(
+ Display *dpy,
+ const XTextProperty *text_prop,
+ char ***list_ret,
+ int *count_ret)
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return XLocaleNotSupported;
+
+ return (*lcd->methods->utf8_text_prop_to_list)(lcd, dpy, text_prop,
+ list_ret, count_ret);
+}
+
+int
+XmbTextListToTextProperty(
+ Display *dpy,
+ char **list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty *text_prop)
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return XLocaleNotSupported;
+
+ return (*lcd->methods->mb_text_list_to_prop)(lcd, dpy, list, count, style,
+ text_prop);
+}
+
+int
+XwcTextListToTextProperty(
+ Display *dpy,
+ wchar_t **list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty *text_prop)
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return XLocaleNotSupported;
+
+ return (*lcd->methods->wc_text_list_to_prop)(lcd, dpy, list, count, style,
+ text_prop);
+}
+
+int
+Xutf8TextListToTextProperty(
+ Display *dpy,
+ char **list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty *text_prop)
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return XLocaleNotSupported;
+
+ return (*lcd->methods->utf8_text_list_to_prop)(lcd, dpy, list, count,
+ style, text_prop);
+}
+
+void
+XwcFreeStringList(
+ wchar_t **list)
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return;
+
+ (*lcd->methods->wc_free_string_list)(lcd, list);
+}
+
+const char *
+XDefaultString()
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return (char *) NULL;
+
+ return (*lcd->methods->default_string)(lcd);
+}
+
+void
+_XlcCopyFromArg(
+ char *src,
+ char *dst,
+ int size)
+{
+ if (size == sizeof(long))
+ *((long *) dst) = (long) src;
+#ifdef LONG64
+ else if (size == sizeof(int))
+ *((int *) dst) = (int)(long) src;
+#endif
+ else if (size == sizeof(short))
+ *((short *) dst) = (short)(long) src;
+ else if (size == sizeof(char))
+ *((char *) dst) = (char)(long) src;
+ else if (size == sizeof(XPointer))
+ *((XPointer *) dst) = (XPointer) src;
+ else if (size > sizeof(XPointer))
+ memcpy(dst, (char *) src, size);
+ else
+ memcpy(dst, (char *) &src, size);
+}
+
+void
+_XlcCopyToArg(
+ char *src,
+ char **dst,
+ int size)
+{
+ /* FIXME:
+ On Big Endian machines, this behaves differently than _XCopyToArg. */
+ if (size == sizeof(long))
+ *((long *) *dst) = *((long *) src);
+#ifdef LONG64
+ else if (size == sizeof(int))
+ *((int *) *dst) = *((int *) src);
+#endif
+ else if (size == sizeof(short))
+ *((short *) *dst) = *((short *) src);
+ else if (size == sizeof(char))
+ *((char *) *dst) = *((char *) src);
+ else if (size == sizeof(XPointer))
+ *((XPointer *) *dst) = *((XPointer *) src);
+ else
+ memcpy(*dst, src, size);
+}
+
+void
+_XlcCountVaList(
+ va_list var,
+ int *count_ret)
+{
+ int count;
+
+ for (count = 0; va_arg(var, char *); count++)
+ (void)va_arg(var, XPointer);
+
+ *count_ret = count;
+}
+
+void
+_XlcVaToArgList(
+ va_list var,
+ int count,
+ XlcArgList *args_ret)
+{
+ XlcArgList args;
+
+ *args_ret = args = (XlcArgList) Xmalloc(sizeof(XlcArg) * count);
+ if (args == (XlcArgList) NULL)
+ return;
+
+ for ( ; count-- > 0; args++) {
+ args->name = va_arg(var, char *);
+ args->value = va_arg(var, XPointer);
+ }
+}
+
+void
+_XlcCompileResourceList(
+ XlcResourceList resources,
+ int num_resources)
+{
+ for ( ; num_resources-- > 0; resources++)
+ resources->xrm_name = XrmPermStringToQuark(resources->name);
+}
+
+char *
+_XlcGetValues(
+ XPointer base,
+ XlcResourceList resources,
+ int num_resources,
+ XlcArgList args,
+ int num_args,
+ unsigned long mask)
+{
+ XlcResourceList res;
+ XrmQuark xrm_name;
+ int count;
+
+ for ( ; num_args-- > 0; args++) {
+ res = resources;
+ count = num_resources;
+ xrm_name = XrmPermStringToQuark(args->name);
+
+ for ( ; count-- > 0; res++) {
+ if (xrm_name == res->xrm_name && (mask & res->mask)) {
+ _XlcCopyToArg(base + res->offset, &args->value, res->size);
+ break;
+ }
+ }
+
+ if (count < 0)
+ return args->name;
+ }
+
+ return NULL;
+}
+
+char *
+_XlcSetValues(
+ XPointer base,
+ XlcResourceList resources,
+ int num_resources,
+ XlcArgList args,
+ int num_args,
+ unsigned long mask)
+{
+ XlcResourceList res;
+ XrmQuark xrm_name;
+ int count;
+
+ for ( ; num_args-- > 0; args++) {
+ res = resources;
+ count = num_resources;
+ xrm_name = XrmPermStringToQuark(args->name);
+
+ for ( ; count-- > 0; res++) {
+ if (xrm_name == res->xrm_name && (mask & res->mask)) {
+ _XlcCopyFromArg(args->value, base + res->offset, res->size);
+ break;
+ }
+ }
+
+ if (count < 0)
+ return args->name;
+ }
+
+ return NULL;
+}
diff --git a/nx-X11/lib/X11/libX11.elist b/nx-X11/lib/X11/libX11.elist
new file mode 100644
index 000000000..511a5edea
--- /dev/null
+++ b/nx-X11/lib/X11/libX11.elist
@@ -0,0 +1,42 @@
+/* $Xorg: libX11.elist,v 1.3 2000/08/17 19:45:20 cpqbld Exp $ */
+
+/*************************************************************************
+ * Export list for libX11
+ * This list *must* be updated whenever a change is made to the API.
+ *
+ * The syntax for the symbol declarations in this list is below.
+ * public sym => Public C symbol, i.e., publicized API
+ * publicC++ sym => Public C++ symbol, i.e., publicized API
+ * private sym => Private C symbol, i.e., unpublicized API
+ * privateC++ sym => Private C++ symbol, i.e., unpublicized API
+ * internal sym => Internal C symbol, i.e., not part of API
+ * internalC++ sym => Internal C++ symbol, i.e., not part of API
+ * force sym => symbol to be exported even if not found. Some
+ * restrictions may apply. Avoid this directive.
+ *
+ * Note that exporting C++ symbols is not portable; different
+ * compilers may use different name mangling schemes and different
+ * hidden name (e.g. virtual function table) generation schemes.
+ *
+ * In addition a single "default" directive may appear, specifying how
+ * unmentioned symbols should be treated. The possible options are:
+ * default Warn about implicit symbols and hide them.
+ * default public Export public symbols implicitly.
+ * default private Export public symbols implicitly.
+ * default internal Hide public symbols implicitly.
+ *
+ *
+ **************************************************************************/
+
+/* We will not be naming symbols; export all public symbols in the library. */
+default public
+
+#ifdef AIXV4
+/*
+ * In earlier releases of this library, IBM exported some standard
+ * symbols from the system libraries. We must keep re-exporting these
+ * symbols for binary compatibility.
+ */
+force setlocale
+force nl_langinfo
+#endif
diff --git a/nx-X11/lib/X11/locking.c b/nx-X11/lib/X11/locking.c
new file mode 100644
index 000000000..537ffa3f4
--- /dev/null
+++ b/nx-X11/lib/X11/locking.c
@@ -0,0 +1,653 @@
+/* $Xorg: locking.c,v 1.5 2001/02/09 02:03:40 xorgcvs Exp $ */
+/*
+
+Copyright 1992, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/X11/locking.c,v 1.5 2003/04/13 19:22:22 dawes Exp $ */
+
+/*
+ * Author: Stephen Gildea, MIT X Consortium
+ *
+ * locking.c - multi-thread locking routines implemented in C Threads
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#undef _XLockMutex
+#undef _XUnlockMutex
+#undef _XCreateMutex
+#undef _XFreeMutex
+
+#ifdef XTHREADS
+
+#ifdef __UNIXWARE__
+#include <dlfcn.h>
+#endif
+
+#include "locking.h"
+#ifdef XTHREADS_WARN
+#include <stdio.h> /* for warn/debug stuff */
+#endif
+
+#define NUM_FREE_CVLS 4
+
+/* in lcWrap.c */
+extern LockInfoPtr _Xi18n_lock;
+
+#ifdef WIN32
+static DWORD _X_TlsIndex = (DWORD)-1;
+
+_Xthread_init()
+{
+ if (_X_TlsIndex == (DWORD)-1)
+ _X_TlsIndex = TlsAlloc();
+}
+
+struct _xthread_waiter *
+_Xthread_waiter()
+{
+ struct _xthread_waiter *me;
+
+ if (!(me = TlsGetValue(_X_TlsIndex))) {
+ me = (struct _xthread_waiter *)xmalloc(sizeof(struct _xthread_waiter));
+ me->sem = CreateSemaphore(NULL, 0, 1, NULL);
+ me->next = NULL;
+ TlsSetValue(_X_TlsIndex, me);
+ }
+ return me;
+}
+#endif /* WIN32 */
+
+static xthread_t _Xthread_self(void)
+{
+ return xthread_self();
+}
+
+static LockInfoRec global_lock;
+static LockInfoRec i18n_lock;
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XLockMutex(lip,file,line)
+ LockInfoPtr lip;
+ char* file;
+ int line;
+#else
+static void _XLockMutex(
+ LockInfoPtr lip)
+#endif
+{
+ xmutex_lock(lip->lock);
+}
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XUnlockMutex(
+ LockInfoPtr lip,
+ char* file,
+ int line)
+#else
+static void _XUnlockMutex(
+ LockInfoPtr lip)
+#endif
+{
+ xmutex_unlock(lip->lock);
+}
+
+static void _XCreateMutex(
+ LockInfoPtr lip)
+{
+ lip->lock = xmutex_malloc();
+ if (lip->lock) {
+ xmutex_init(lip->lock);
+ xmutex_set_name(lip->lock, "Xlib");
+ }
+}
+
+static void _XFreeMutex(
+ LockInfoPtr lip)
+{
+ xmutex_clear(lip->lock);
+ xmutex_free(lip->lock);
+}
+
+#ifdef XTHREADS_WARN
+static char *locking_file;
+static int locking_line;
+static xthread_t locking_thread;
+static Bool xlibint_unlock = False; /* XlibInt.c may Unlock and re-Lock */
+
+/* history that is useful to examine in a debugger */
+#define LOCK_HIST_SIZE 21
+
+static struct {
+ Bool lockp; /* True for lock, False for unlock */
+ xthread_t thread;
+ char *file;
+ int line;
+} locking_history[LOCK_HIST_SIZE];
+
+int lock_hist_loc = 0; /* next slot to fill */
+
+static void _XLockDisplayWarn(
+ Display *dpy,
+ char *file, /* source file, from macro */
+ int line)
+{
+ xthread_t self;
+ xthread_t old_locker;
+
+ self = xthread_self();
+ old_locker = locking_thread;
+ if (xthread_have_id(old_locker)) {
+ if (xthread_equal(old_locker, self))
+ printf("Xlib ERROR: %s line %d thread %x: locking display already locked at %s line %d\n",
+ file, line, self, locking_file, locking_line);
+#ifdef XTHREADS_DEBUG
+ else
+ printf("%s line %d: thread %x waiting on lock held by %s line %d thread %x\n",
+ file, line, self,
+ locking_file, locking_line, old_locker);
+#endif /* XTHREADS_DEBUG */
+ }
+
+ xmutex_lock(dpy->lock->mutex);
+
+ if (strcmp(file, "XlibInt.c") == 0) {
+ if (!xlibint_unlock)
+ printf("Xlib ERROR: XlibInt.c line %d thread %x locking display it did not unlock\n",
+ line, self);
+ xlibint_unlock = False;
+ }
+
+#ifdef XTHREADS_DEBUG
+ /* if (old_locker && old_locker != self) */
+ if (strcmp("XClearArea.c", file) && strcmp("XDrSegs.c", file)) /* ico */
+ printf("%s line %d: thread %x got display lock\n", file, line, self);
+#endif /* XTHREADS_DEBUG */
+
+ locking_thread = self;
+ if (strcmp(file, "XlibInt.c") != 0) {
+ locking_file = file;
+ locking_line = line;
+ }
+ locking_history[lock_hist_loc].file = file;
+ locking_history[lock_hist_loc].line = line;
+ locking_history[lock_hist_loc].thread = self;
+ locking_history[lock_hist_loc].lockp = True;
+ lock_hist_loc++;
+ if (lock_hist_loc >= LOCK_HIST_SIZE)
+ lock_hist_loc = 0;
+}
+#endif /* XTHREADS_WARN */
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XUnlockDisplay(dpy,file,line)
+ Display *dpy;
+ char *file;
+ int line;
+#else
+static void _XUnlockDisplay(
+ Display *dpy)
+#endif
+{
+#ifdef XTHREADS_WARN
+ xthread_t self = xthread_self();
+
+#ifdef XTHREADS_DEBUG
+ if (strcmp("XClearArea.c", file) && strcmp("XDrSegs.c", file)) /* ico */
+ printf("%s line %d: thread %x unlocking display\n", file, line, self);
+#endif /* XTHREADS_DEBUG */
+
+ if (!xthread_have_id(locking_thread))
+ printf("Xlib ERROR: %s line %d thread %x: unlocking display that is not locked\n",
+ file, line, self);
+ else if (strcmp(file, "XlibInt.c") == 0)
+ xlibint_unlock = True;
+#ifdef XTHREADS_DEBUG
+ else if (strcmp(file, locking_file) != 0)
+ /* not always an error because locking_file is not per-thread */
+ printf("%s line %d: unlocking display locked from %s line %d (probably okay)\n",
+ file, line, locking_file, locking_line);
+#endif /* XTHREADS_DEBUG */
+ xthread_clear_id(locking_thread);
+
+ locking_history[lock_hist_loc].file = file;
+ locking_history[lock_hist_loc].line = line;
+ locking_history[lock_hist_loc].thread = self;
+ locking_history[lock_hist_loc].lockp = False;
+ lock_hist_loc++;
+ if (lock_hist_loc >= LOCK_HIST_SIZE)
+ lock_hist_loc = 0;
+#endif /* XTHREADS_WARN */
+ xmutex_unlock(dpy->lock->mutex);
+}
+
+
+static struct _XCVList *_XCreateCVL(
+ Display *dpy)
+{
+ struct _XCVList *cvl;
+
+ if ((cvl = dpy->lock->free_cvls) != NULL) {
+ dpy->lock->free_cvls = cvl->next;
+ dpy->lock->num_free_cvls--;
+ } else {
+ cvl = (struct _XCVList *)Xmalloc(sizeof(struct _XCVList));
+ if (!cvl)
+ return NULL;
+ cvl->cv = xcondition_malloc();
+ if (!cvl->cv) {
+ Xfree(cvl);
+ return NULL;
+ }
+ xcondition_init(cvl->cv);
+ xcondition_set_name(cvl->cv, "Xlib read queue");
+ }
+ cvl->next = NULL;
+ return cvl;
+}
+
+/* Put ourselves on the queue to read the connection.
+ Allocates and returns a queue element. */
+
+static struct _XCVList *
+_XPushReader(
+ Display *dpy,
+ struct _XCVList ***tail)
+{
+ struct _XCVList *cvl;
+
+ cvl = _XCreateCVL(dpy);
+#ifdef XTHREADS_DEBUG
+ printf("_XPushReader called in thread %x, pushing %x\n",
+ xthread_self(), cvl);
+#endif
+ **tail = cvl;
+ *tail = &cvl->next;
+ return cvl;
+}
+
+/* signal the next thread waiting to read the connection */
+
+static void _XPopReader(
+ Display *dpy,
+ struct _XCVList **list,
+ struct _XCVList ***tail)
+{
+ register struct _XCVList *front = *list;
+
+#ifdef XTHREADS_DEBUG
+ printf("_XPopReader called in thread %x, popping %x\n",
+ xthread_self(), front);
+#endif
+
+ if (dpy->flags & XlibDisplayProcConni)
+ /* we never added ourself in the first place */
+ return;
+
+ if (front) { /* check "front" for paranoia */
+ *list = front->next;
+ if (*tail == &front->next) /* did we free the last elt? */
+ *tail = list;
+ if (dpy->lock->num_free_cvls < NUM_FREE_CVLS) {
+ front->next = dpy->lock->free_cvls;
+ dpy->lock->free_cvls = front;
+ dpy->lock->num_free_cvls++;
+ } else {
+ xcondition_clear(front->cv);
+ Xfree((char *)front->cv);
+ Xfree((char *)front);
+ }
+ }
+
+ /* signal new front after it is in place */
+ if ((dpy->lock->reply_first = (dpy->lock->reply_awaiters != NULL))) {
+ ConditionSignal(dpy, dpy->lock->reply_awaiters->cv);
+ } else if (dpy->lock->event_awaiters) {
+ ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
+ }
+}
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XConditionWait(cv, mutex,file,line)
+ xcondition_t cv;
+ xmutex_t mutex;
+ char *file;
+ int line;
+#else
+static void _XConditionWait(
+ xcondition_t cv,
+ xmutex_t mutex)
+#endif
+{
+#ifdef XTHREADS_WARN
+ xthread_t self = xthread_self();
+ char *old_file = locking_file;
+ int old_line = locking_line;
+
+#ifdef XTHREADS_DEBUG
+ printf("line %d thread %x in condition wait\n", line, self);
+#endif
+ xthread_clear_id(locking_thread);
+
+ locking_history[lock_hist_loc].file = file;
+ locking_history[lock_hist_loc].line = line;
+ locking_history[lock_hist_loc].thread = self;
+ locking_history[lock_hist_loc].lockp = False;
+ lock_hist_loc++;
+ if (lock_hist_loc >= LOCK_HIST_SIZE)
+ lock_hist_loc = 0;
+#endif /* XTHREADS_WARN */
+
+ xcondition_wait(cv, mutex);
+
+#ifdef XTHREADS_WARN
+ locking_thread = self;
+ locking_file = old_file;
+ locking_line = old_line;
+
+ locking_history[lock_hist_loc].file = file;
+ locking_history[lock_hist_loc].line = line;
+ locking_history[lock_hist_loc].thread = self;
+ locking_history[lock_hist_loc].lockp = True;
+ lock_hist_loc++;
+ if (lock_hist_loc >= LOCK_HIST_SIZE)
+ lock_hist_loc = 0;
+#ifdef XTHREADS_DEBUG
+ printf("line %d thread %x was signaled\n", line, self);
+#endif /* XTHREADS_DEBUG */
+#endif /* XTHREADS_WARN */
+}
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XConditionSignal(cv,file,line)
+ xcondition_t cv;
+ char *file;
+ int line;
+#else
+static void _XConditionSignal(
+ xcondition_t cv)
+#endif
+{
+#ifdef XTHREADS_WARN
+#ifdef XTHREADS_DEBUG
+ printf("line %d thread %x is signalling\n", line, xthread_self());
+#endif
+#endif
+ xcondition_signal(cv);
+}
+
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XConditionBroadcast(cv,file,line)
+ xcondition_t cv;
+ char *file;
+ int line;
+#else
+static void _XConditionBroadcast(
+ xcondition_t cv)
+#endif
+{
+#ifdef XTHREADS_WARN
+#ifdef XTHREADS_DEBUG
+ printf("line %d thread %x is broadcasting\n", line, xthread_self());
+#endif
+#endif
+ xcondition_broadcast(cv);
+}
+
+
+static void _XFreeDisplayLock(
+ Display *dpy)
+{
+ struct _XCVList *cvl;
+
+ if (dpy->lock != NULL) {
+ if (dpy->lock->mutex != NULL) {
+ xmutex_clear(dpy->lock->mutex);
+ xmutex_free(dpy->lock->mutex);
+ }
+ if (dpy->lock->cv != NULL) {
+ xcondition_clear(dpy->lock->cv);
+ xcondition_free(dpy->lock->cv);
+ }
+ if (dpy->lock->writers != NULL) {
+ xcondition_clear(dpy->lock->writers);
+ xcondition_free(dpy->lock->writers);
+ }
+ while ((cvl = dpy->lock->free_cvls)) {
+ dpy->lock->free_cvls = cvl->next;
+ xcondition_clear(cvl->cv);
+ Xfree((char *)cvl->cv);
+ Xfree((char *)cvl);
+ }
+ Xfree((char *)dpy->lock);
+ dpy->lock = NULL;
+ }
+ if (dpy->lock_fns != NULL) {
+ Xfree((char *)dpy->lock_fns);
+ dpy->lock_fns = NULL;
+ }
+}
+
+/*
+ * wait for thread with user-level display lock to release it.
+ */
+
+static void _XDisplayLockWait(
+ Display *dpy)
+{
+ xthread_t self;
+
+ while (dpy->lock->locking_level > 0) {
+ self = xthread_self();
+ if (xthread_equal(dpy->lock->locking_thread, self))
+ break;
+ ConditionWait(dpy, dpy->lock->cv);
+ }
+}
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XLockDisplay(dpy, file, line)
+ Display *dpy;
+ char *file; /* source file, from macro */
+ int line;
+#else
+static void _XLockDisplay(
+ Display *dpy)
+#endif
+{
+#ifdef XTHREADS_WARN
+ _XLockDisplayWarn(dpy, file, line);
+#else
+ xmutex_lock(dpy->lock->mutex);
+#endif
+ if (dpy->lock->locking_level > 0)
+ _XDisplayLockWait(dpy);
+}
+
+/*
+ * _XReply is allowed to exit from select/poll and clean up even if a
+ * user-level lock is in force, so it uses this instead of _XFancyLockDisplay.
+ */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XInternalLockDisplay(dpy, wskip, file, line)
+ Display *dpy;
+ Bool wskip;
+ char *file; /* source file, from macro */
+ int line;
+#else
+static void _XInternalLockDisplay(
+ Display *dpy,
+ Bool wskip)
+#endif
+{
+#ifdef XTHREADS_WARN
+ _XLockDisplayWarn(dpy, file, line);
+#else
+ xmutex_lock(dpy->lock->mutex);
+#endif
+ if (!wskip && dpy->lock->locking_level > 0)
+ _XDisplayLockWait(dpy);
+}
+
+static void _XUserLockDisplay(
+ register Display* dpy)
+{
+ if (++dpy->lock->locking_level == 1) {
+ dpy->lock->lock_wait = _XDisplayLockWait;
+ dpy->lock->locking_thread = xthread_self();
+ }
+}
+
+static
+void _XUserUnlockDisplay(
+ register Display* dpy)
+{
+ if (dpy->lock->locking_level > 0 && --dpy->lock->locking_level == 0) {
+ /* signal other threads that might be waiting in XLockDisplay */
+ ConditionBroadcast(dpy, dpy->lock->cv);
+ dpy->lock->lock_wait = NULL;
+ xthread_clear_id(dpy->lock->locking_thread);
+ }
+}
+
+/* returns 0 if initialized ok, -1 if unable to allocate
+ a mutex or other memory */
+
+static int _XInitDisplayLock(
+ Display *dpy)
+{
+ dpy->lock_fns = (struct _XLockPtrs*)Xmalloc(sizeof(struct _XLockPtrs));
+ if (dpy->lock_fns == NULL)
+ return -1;
+ dpy->lock = (struct _XLockInfo *)Xmalloc(sizeof(struct _XLockInfo));
+ if (dpy->lock == NULL) {
+ _XFreeDisplayLock(dpy);
+ return -1;
+ }
+ dpy->lock->cv = xcondition_malloc();
+ dpy->lock->mutex = xmutex_malloc();
+ dpy->lock->writers = xcondition_malloc();
+ if (!dpy->lock->cv || !dpy->lock->mutex || !dpy->lock->writers) {
+ _XFreeDisplayLock(dpy);
+ return -1;
+ }
+
+ dpy->lock->reply_bytes_left = 0;
+ dpy->lock->reply_was_read = False;
+ dpy->lock->reply_awaiters = NULL;
+ dpy->lock->reply_awaiters_tail = &dpy->lock->reply_awaiters;
+ dpy->lock->event_awaiters = NULL;
+ dpy->lock->event_awaiters_tail = &dpy->lock->event_awaiters;
+ dpy->lock->reply_first = False;
+ dpy->lock->locking_level = 0;
+ dpy->lock->num_free_cvls = 0;
+ dpy->lock->free_cvls = NULL;
+ xthread_clear_id(dpy->lock->locking_thread);
+ xthread_clear_id(dpy->lock->reading_thread);
+ xthread_clear_id(dpy->lock->conni_thread);
+ xmutex_init(dpy->lock->mutex);
+ xmutex_set_name(dpy->lock->mutex, "Xlib Display");
+ xcondition_init(dpy->lock->cv);
+ xcondition_set_name(dpy->lock->cv, "XLockDisplay");
+ xcondition_init(dpy->lock->writers);
+ xcondition_set_name(dpy->lock->writers, "Xlib wait for writable");
+ dpy->lock_fns->lock_display = _XLockDisplay;
+ dpy->lock->internal_lock_display = _XInternalLockDisplay;
+ dpy->lock_fns->unlock_display = _XUnlockDisplay;
+ dpy->lock->user_lock_display = _XUserLockDisplay;
+ dpy->lock->user_unlock_display = _XUserUnlockDisplay;
+ dpy->lock->pop_reader = _XPopReader;
+ dpy->lock->push_reader = _XPushReader;
+ dpy->lock->condition_wait = _XConditionWait;
+ dpy->lock->condition_signal = _XConditionSignal;
+ dpy->lock->condition_broadcast = _XConditionBroadcast;
+ dpy->lock->create_cvl = _XCreateCVL;
+ dpy->lock->lock_wait = NULL; /* filled in by XLockDisplay() */
+
+ return 0;
+}
+
+#ifdef __UNIXWARE__
+xthread_t __x11_thr_self() { return 0; }
+xthread_t (*_x11_thr_self)() = __x11_thr_self;
+#endif
+
+
+Status XInitThreads()
+{
+ if (_Xglobal_lock)
+ return 1;
+#ifdef __UNIXWARE__
+ else {
+ void *dl_handle = dlopen(NULL, RTLD_LAZY);
+ if (!dl_handle ||
+ ((_x11_thr_self = (xthread_t(*)())dlsym(dl_handle,"thr_self")) == 0)) {
+ _x11_thr_self = __x11_thr_self;
+ (void) fprintf (stderr,
+ "XInitThreads called, but no libthread in the calling program!\n" );
+ }
+ }
+#endif /* __UNIXWARE__ */
+#ifdef xthread_init
+ xthread_init(); /* return value? */
+#endif
+ if (!(global_lock.lock = xmutex_malloc()))
+ return 0;
+ if (!(i18n_lock.lock = xmutex_malloc())) {
+ xmutex_free(global_lock.lock);
+ global_lock.lock = NULL;
+ return 0;
+ }
+ _Xglobal_lock = &global_lock;
+ xmutex_init(_Xglobal_lock->lock);
+ xmutex_set_name(_Xglobal_lock->lock, "Xlib global");
+ _Xi18n_lock = &i18n_lock;
+ xmutex_init(_Xi18n_lock->lock);
+ xmutex_set_name(_Xi18n_lock->lock, "Xlib i18n");
+ _XLockMutex_fn = _XLockMutex;
+ _XUnlockMutex_fn = _XUnlockMutex;
+ _XCreateMutex_fn = _XCreateMutex;
+ _XFreeMutex_fn = _XFreeMutex;
+ _XInitDisplayLock_fn = _XInitDisplayLock;
+ _XFreeDisplayLock_fn = _XFreeDisplayLock;
+ _Xthread_self_fn = _Xthread_self;
+
+#ifdef XTHREADS_WARN
+#ifdef XTHREADS_DEBUG
+ setlinebuf(stdout); /* for debugging messages */
+#endif
+#endif
+
+ return 1;
+}
+
+#else /* XTHREADS */
+Status XInitThreads()
+{
+ return 0;
+}
+#endif /* XTHREADS */
diff --git a/nx-X11/lib/X11/locking.h b/nx-X11/lib/X11/locking.h
new file mode 100644
index 000000000..96c99b972
--- /dev/null
+++ b/nx-X11/lib/X11/locking.h
@@ -0,0 +1,156 @@
+/* $Xorg: locking.h,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */
+/*
+
+Copyright 1992, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/X11/locking.h,v 1.4 2001/12/14 19:54:10 dawes Exp $ */
+
+/*
+ * Author: Stephen Gildea, MIT X Consortium
+ *
+ * locking.h - data types for C Threads locking.
+ * Used by XlibInt.c, locking.c, LockDis.c
+ */
+
+#ifndef _X_locking_H_
+#define _X_locking_H_
+
+#define xmalloc(s) Xmalloc(s)
+#define xfree(s) Xfree(s)
+#include <X11/Xthreads.h>
+
+struct _XCVList {
+ xcondition_t cv;
+ xReply *buf;
+ struct _XCVList *next;
+};
+
+extern xthread_t (*_Xthread_self_fn)( /* in XlibInt.c */
+ void
+);
+
+/* Display->lock is a pointer to one of these */
+
+struct _XLockInfo {
+ xmutex_t mutex; /* mutex for critical sections */
+ int reply_bytes_left; /* nbytes of the reply still to read */
+ Bool reply_was_read; /* _XReadEvents read a reply for _XReply */
+ struct _XCVList *reply_awaiters; /* list of CVs for _XReply */
+ struct _XCVList **reply_awaiters_tail;
+ struct _XCVList *event_awaiters; /* list of CVs for _XReadEvents */
+ struct _XCVList **event_awaiters_tail;
+ Bool reply_first; /* who may read, reply queue or event queue */
+ /* for XLockDisplay */
+ int locking_level; /* how many times into XLockDisplay we are */
+ xthread_t locking_thread; /* thread that did XLockDisplay */
+ xcondition_t cv; /* wait if another thread has XLockDisplay */
+ xthread_t reading_thread; /* cache */
+ xthread_t conni_thread; /* thread in XProcessInternalConnection */
+ xcondition_t writers; /* wait for writable */
+ int num_free_cvls;
+ struct _XCVList *free_cvls;
+ /* used only in XlibInt.c */
+ void (*pop_reader)(
+ Display* /* dpy */,
+ struct _XCVList** /* list */,
+ struct _XCVList*** /* tail */
+ );
+ struct _XCVList *(*push_reader)(
+ Display * /* dpy */,
+ struct _XCVList*** /* tail */
+ );
+ void (*condition_wait)(
+ xcondition_t /* cv */,
+ xmutex_t /* mutex */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char* /* file */,
+ int /* line */
+#endif
+ );
+ void (*internal_lock_display)(
+ Display* /* dpy */,
+ Bool /* wskip */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char* /* file */,
+ int /* line */
+#endif
+ );
+ /* used in XlibInt.c and locking.c */
+ void (*condition_signal)(
+ xcondition_t /* cv */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char* /* file */,
+ int /* line */
+#endif
+ );
+ void (*condition_broadcast)(
+ xcondition_t /* cv */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char* /* file */,
+ int /* line */
+#endif
+ );
+ /* used in XlibInt.c and XLockDis.c */
+ void (*lock_wait)(
+ Display* /* dpy */
+ );
+ void (*user_lock_display)(
+ Display* /* dpy */
+ );
+ void (*user_unlock_display)(
+ Display* /* dpy */
+ );
+ struct _XCVList *(*create_cvl)(
+ Display * /* dpy */
+ );
+};
+
+#define UnlockNextEventReader(d) if ((d)->lock) \
+ (*(d)->lock->pop_reader)((d),&(d)->lock->event_awaiters,&(d)->lock->event_awaiters_tail)
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+#define ConditionWait(d,c) if ((d)->lock) \
+ (*(d)->lock->condition_wait)(c, (d)->lock->mutex,__FILE__,__LINE__)
+#define ConditionSignal(d,c) if ((d)->lock) \
+ (*(d)->lock->condition_signal)(c,__FILE__,__LINE__)
+#define ConditionBroadcast(d,c) if ((d)->lock) \
+ (*(d)->lock->condition_broadcast)(c,__FILE__,__LINE__)
+#else
+#define ConditionWait(d,c) if ((d)->lock) \
+ (*(d)->lock->condition_wait)(c, (d)->lock->mutex)
+#define ConditionSignal(d,c) if ((d)->lock) \
+ (*(d)->lock->condition_signal)(c)
+#define ConditionBroadcast(d,c) if ((d)->lock) \
+ (*(d)->lock->condition_broadcast)(c)
+#endif
+
+typedef struct _LockInfoRec {
+ xmutex_t lock;
+} LockInfoRec;
+
+/* XOpenDis.c */
+extern int (*_XInitDisplayLock_fn)(Display *dpy);
+extern void (*_XFreeDisplayLock_fn)(Display *dpy);
+
+#endif /* _X_locking_H_ */
diff --git a/nx-X11/lib/X11/mbWMProps.c b/nx-X11/lib/X11/mbWMProps.c
new file mode 100644
index 000000000..a5f7732e4
--- /dev/null
+++ b/nx-X11/lib/X11/mbWMProps.c
@@ -0,0 +1,71 @@
+/* $Xorg: mbWMProps.c,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/X11/mbWMProps.c,v 1.5 2001/12/14 19:54:10 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Xlocale.h>
+
+void
+XmbSetWMProperties (
+ Display *dpy,
+ Window w,
+ _Xconst char *windowName,
+ _Xconst char *iconName,
+ char **argv,
+ int argc,
+ XSizeHints *sizeHints,
+ XWMHints *wmHints,
+ XClassHint *classHints)
+{
+ XTextProperty wname, iname;
+ XTextProperty *wprop = NULL;
+ XTextProperty *iprop = NULL;
+
+ if (windowName &&
+ XmbTextListToTextProperty(dpy, (char**)&windowName, 1,
+ XStdICCTextStyle, &wname) >= Success)
+ wprop = &wname;
+ if (iconName &&
+ XmbTextListToTextProperty(dpy, (char**)&iconName, 1,
+ XStdICCTextStyle, &iname) >= Success)
+ iprop = &iname;
+ XSetWMProperties(dpy, w, wprop, iprop, argv, argc,
+ sizeHints, wmHints, classHints);
+ if (wprop)
+ Xfree((char *)wname.value);
+ if (iprop)
+ Xfree((char *)iname.value);
+
+ /* Note: The WM_LOCALE_NAME property is set by XSetWMProperties. */
+}
diff --git a/nx-X11/lib/X11/mbWrap.c b/nx-X11/lib/X11/mbWrap.c
new file mode 100644
index 000000000..827c10b1c
--- /dev/null
+++ b/nx-X11/lib/X11/mbWrap.c
@@ -0,0 +1,165 @@
+/* $Xorg: mbWrap.c,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */
+/*
+
+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.
+
+*/
+/*
+ * Copyright 1991 by the Open Software Foundation
+ *
+ * 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 of 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
+ */
+/* $XFree86: xc/lib/X11/mbWrap.c,v 1.6 2001/12/14 19:54:10 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+void
+XmbDrawText(
+ Display *dpy,
+ Drawable d,
+ GC gc,
+ int x,
+ int y,
+ XmbTextItem *text_items,
+ int nitems)
+{
+ register XFontSet fs = NULL;
+ register XmbTextItem *p = text_items;
+ register int i = nitems;
+ register int esc;
+
+ /* ignore leading items with no fontset */
+ while (i && !p->font_set) {
+ i--;
+ p++;
+ }
+
+ for (; --i >= 0; p++) {
+ if (p->font_set)
+ fs = p->font_set;
+ x += p->delta;
+ esc = (*fs->methods->mb_draw_string) (dpy, d, fs, gc, x, y,
+ p->chars, p->nchars);
+ if (!esc)
+ esc = fs->methods->mb_escapement (fs, p->chars, p->nchars);
+ x += esc;
+ }
+}
+
+void
+XmbDrawString(
+ Display *dpy,
+ Drawable d,
+ XFontSet font_set,
+ GC gc,
+ int x,
+ int y,
+ _Xconst char *text,
+ int text_len)
+{
+ (void)(*font_set->methods->mb_draw_string) (dpy, d, font_set, gc, x, y,
+ (char *)text, text_len);
+}
+
+
+void
+XmbDrawImageString(
+ Display *dpy,
+ Drawable d,
+ XFontSet font_set,
+ GC gc,
+ int x,
+ int y,
+ _Xconst char *text,
+ int text_len)
+{
+ (*font_set->methods->mb_draw_image_string) (dpy, d, font_set, gc, x, y,
+ (char *)text, text_len);
+}
+
+int
+XmbTextEscapement(
+ XFontSet font_set,
+ _Xconst char *text,
+ int text_len)
+{
+ return (*font_set->methods->mb_escapement) (font_set,
+ (char *)text, text_len);
+}
+
+int
+XmbTextExtents(
+ XFontSet font_set,
+ _Xconst char *text,
+ int text_len,
+ XRectangle *overall_ink_extents,
+ XRectangle *overall_logical_extents)
+{
+ return (*font_set->methods->mb_extents) (font_set,
+ (char *)text, text_len,
+ overall_ink_extents,
+ overall_logical_extents);
+}
+
+Status
+XmbTextPerCharExtents(
+ XFontSet font_set,
+ _Xconst char *text,
+ int text_len,
+ XRectangle *ink_extents_buffer,
+ XRectangle *logical_extents_buffer,
+ int buffer_size,
+ int *num_chars,
+ XRectangle *max_ink_extents,
+ XRectangle *max_logical_extents)
+{
+ return (*font_set->methods->mb_extents_per_char)
+ (font_set, (char *)text, text_len,
+ ink_extents_buffer, logical_extents_buffer,
+ buffer_size, num_chars, max_ink_extents, max_logical_extents);
+}
diff --git a/nx-X11/lib/X11/omDefault.c b/nx-X11/lib/X11/omDefault.c
new file mode 100644
index 000000000..57dd975ad
--- /dev/null
+++ b/nx-X11/lib/X11/omDefault.c
@@ -0,0 +1,451 @@
+/* $Xorg: omDefault.c,v 1.3 2000/08/17 19:45:21 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * (c) Copyright 1995 FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+/* $XFree86: xc/lib/X11/omDefault.c,v 1.6 2003/04/13 19:22:22 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <X11/Xos.h>
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+#define DefineLocalBuf char local_buf[BUFSIZ]
+#define AllocLocalBuf(length) (length > BUFSIZ ? (char *)Xmalloc(length) : local_buf)
+#define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr)
+
+static Bool
+wcs_to_mbs(
+ XOC oc,
+ char *to,
+ _Xconst wchar_t *from,
+ int length)
+{
+ XlcConv conv;
+ int to_left, ret;
+
+ conv = _XomInitConverter(oc, XOMWideChar);
+ if (conv == NULL)
+ return False;
+
+ to_left = length;
+ ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to,
+ &to_left, NULL, 0);
+ if (ret != 0 || length > 0)
+ return False;
+
+ return True;
+}
+
+static Bool
+utf8_to_mbs(
+ XOC oc,
+ char *to,
+ _Xconst char *from,
+ int length)
+{
+ XlcConv conv;
+ int to_left, ret;
+
+ conv = _XomInitConverter(oc, XOMUtf8String);
+ if (conv == NULL)
+ return False;
+
+ to_left = length;
+ ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to,
+ &to_left, NULL, 0);
+ if (ret != 0 || length > 0)
+ return False;
+
+ return True;
+}
+
+int
+_XmbDefaultTextEscapement(XOC oc, _Xconst char *text, int length)
+{
+ return XTextWidth(*oc->core.font_info.font_struct_list, text, length);
+}
+
+int
+_XwcDefaultTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultTextEscapement(oc, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+int
+_Xutf8DefaultTextEscapement(XOC oc, _Xconst char *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (utf8_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultTextEscapement(oc, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+int
+_XmbDefaultTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ int direction, logical_ascent, logical_descent;
+ XCharStruct overall;
+
+ XTextExtents(*oc->core.font_info.font_struct_list, text, length, &direction,
+ &logical_ascent, &logical_descent, &overall);
+
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(logical_ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = logical_ascent + logical_descent;
+ }
+
+ return overall.width;
+}
+
+int
+_XwcDefaultTextExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+int
+_Xutf8DefaultTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (utf8_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+Status
+_XmbDefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ XFontStruct *font = *oc->core.font_info.font_struct_list;
+ XCharStruct *def, *cs, overall;
+ Bool first = True;
+
+ if (buf_size < length)
+ return 0;
+
+ bzero((char *) &overall, sizeof(XCharStruct));
+ *num_chars = 0;
+
+ CI_GET_DEFAULT_INFO_1D(font, def)
+
+ while (length-- > 0) {
+ CI_GET_CHAR_INFO_1D(font, *text, def, cs)
+ text++;
+ if (cs == NULL)
+ continue;
+
+ ink_buf->x = overall.width + cs->lbearing;
+ ink_buf->y = -(cs->ascent);
+ ink_buf->width = cs->rbearing - cs->lbearing;
+ ink_buf->height = cs->ascent + cs->descent;
+ ink_buf++;
+
+ logical_buf->x = overall.width;
+ logical_buf->y = -(font->ascent);
+ logical_buf->width = cs->width;
+ logical_buf->height = font->ascent + font->descent;
+ logical_buf++;
+
+ if (first) {
+ overall = *cs;
+ first = False;
+ } else {
+ overall.ascent = max(overall.ascent, cs->ascent);
+ overall.descent = max(overall.descent, cs->descent);
+ overall.lbearing = min(overall.lbearing, overall.width +
+ cs->lbearing);
+ overall.rbearing = max(overall.rbearing, overall.width +
+ cs->rbearing);
+ overall.width += cs->width;
+ }
+
+ (*num_chars)++;
+ }
+
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(font->ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = font->ascent + font->descent;
+ }
+
+ return 1;
+}
+
+Status
+_XwcDefaultTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ Status ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf,
+ buf_size, num_chars, overall_ink,
+ overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+Status
+_Xutf8DefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ Status ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (utf8_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf,
+ buf_size, num_chars, overall_ink,
+ overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+int
+_XmbDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length)
+{
+ XFontStruct *font = *oc->core.font_info.font_struct_list;
+
+ XSetFont(dpy, gc, font->fid);
+ XDrawString(dpy, d, gc, x, y, text, length);
+
+ return XTextWidth(font, text, length);
+}
+
+int
+_XwcDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst wchar_t *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+int
+_Xutf8DefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (utf8_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+void
+_XmbDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length)
+{
+ XSetFont(dpy, gc, (*oc->core.font_info.font_struct_list)->fid);
+ XDrawImageString(dpy, d, gc, x, y, text, length);
+}
+
+void
+_XwcDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst wchar_t *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+
+ if (buf == NULL)
+ return;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+}
+
+void
+_Xutf8DefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+
+ if (buf == NULL)
+ return;
+
+ if (utf8_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+}
diff --git a/nx-X11/lib/X11/omGeneric.c b/nx-X11/lib/X11/omGeneric.c
new file mode 100644
index 000000000..e6c23f4e2
--- /dev/null
+++ b/nx-X11/lib/X11/omGeneric.c
@@ -0,0 +1,2187 @@
+/* $Xorg: omGeneric.c,v 1.6 2000/08/17 19:45:21 cpqbld Exp $ */
+/* #define FONTDEBUG */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+/* $XFree86: xc/lib/X11/omGeneric.c,v 3.27 2003/05/27 22:26:27 tsi Exp $ */
+
+/*
+ * Fixed the algorithms in parse_fontname() and parse_fontdata()
+ * to improve the logic for determining which font should be
+ * returned for a given CharSet. We even added some comments
+ * so that you can figure out what in the heck we're doing. We
+ * realize this is a departure from the norm, but hey, we're
+ * rebels! :-) :-)
+ *
+ * Modifiers: Jeff Walls, Paul Anderson: HEWLETT-PACKARD
+ */
+/*
+ * Cleaned up mess, removed some blabla
+ * Egbert Eich, SuSE Linux AG
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include "XlcGeneric.h"
+#include <X11/Xos.h>
+#include <X11/Xatom.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#define MAXFONTS 100
+#define PIXEL_SIZE_FIELD 7
+#define POINT_SIZE_FIELD 8
+#define CHARSET_ENCODING_FIELD 14
+#define XLFD_MAX_LEN 255
+
+#if 0
+extern int _XmbDefaultTextEscapement(), _XwcDefaultTextEscapement(),
+ _Xutf8DefaultTextEscapement();
+extern int _XmbDefaultTextExtents(), _XwcDefaultTextExtents(),
+ _Xutf8DefaultTextExtents();
+extern Status _XmbDefaultTextPerCharExtents(), _XwcDefaultTextPerCharExtents(),
+ _Xutf8DefaultTextPerCharExtents();
+extern int _XmbDefaultDrawString(), _XwcDefaultDrawString(),
+ _Xutf8DefaultDrawString();
+extern void _XmbDefaultDrawImageString(), _XwcDefaultDrawImageString(),
+ _Xutf8DefaultDrawImageString();
+
+extern int _XmbGenericTextEscapement(), _XwcGenericTextEscapement(),
+ _Xutf8GenericTextEscapement();
+extern int _XmbGenericTextExtents(), _XwcGenericTextExtents(),
+ _Xutf8GenericTextExtents();
+extern Status _XmbGenericTextPerCharExtents(), _XwcGenericTextPerCharExtents(),
+ _Xutf8GenericTextPerCharExtents();
+extern int _XmbGenericDrawString(), _XwcGenericDrawString(),
+ _Xutf8GenericDrawString();
+extern void _XmbGenericDrawImageString(), _XwcGenericDrawImageString(),
+ _Xutf8GenericDrawImageString();
+
+extern void _XlcDbg_printValue (const char *str, char **value, int num);
+#endif
+
+/* For VW/UDC start */
+
+static FontData
+init_fontdata(
+ FontData font_data,
+ int font_data_count)
+{
+ FontData fd;
+ int i;
+
+ fd = (FontData)Xmalloc(sizeof(FontDataRec) * font_data_count);
+ if(fd == (FontData) NULL)
+ return False;
+
+ memset(fd, 0x00, sizeof(FontData) * font_data_count);
+ for(i = 0 ; i < font_data_count ; i++)
+ fd[i] = font_data[i];
+
+ return fd;
+}
+
+static VRotate
+init_vrotate(
+ FontData font_data,
+ int font_data_count,
+ int type,
+ CodeRange code_range,
+ int code_range_num)
+{
+ VRotate vrotate;
+ int i;
+
+ if(type == VROTATE_NONE)
+ return (VRotate)NULL;
+
+ vrotate = (VRotate)Xmalloc(sizeof(VRotateRec) * font_data_count);
+ if(vrotate == (VRotate) NULL)
+ return False;
+
+ memset(vrotate, 0x00, sizeof(VRotateRec) * font_data_count);
+ for(i = 0 ; i < font_data_count ; i++) {
+ vrotate[i].charset_name = font_data[i].name;
+ vrotate[i].side = font_data[i].side;
+ if(type == VROTATE_PART) {
+ vrotate[i].num_cr = code_range_num;
+ vrotate[i].code_range = code_range;
+ }
+ }
+
+ return vrotate;
+}
+
+static Bool
+init_fontset(
+ XOC oc)
+{
+ XOCGenericPart *gen;
+ FontSet font_set;
+ OMData data;
+ int count;
+
+ count = XOM_GENERIC(oc->core.om)->data_num;
+ data = XOM_GENERIC(oc->core.om)->data;
+
+ font_set = (FontSet) Xmalloc(sizeof(FontSetRec) * count);
+ if (font_set == NULL)
+ return False;
+ memset((char *) font_set, 0x00, sizeof(FontSetRec) * count);
+
+ gen = XOC_GENERIC(oc);
+ gen->font_set_num = count;
+ gen->font_set = font_set;
+
+ for ( ; count-- > 0; data++, font_set++) {
+ font_set->charset_count = data->charset_count;
+ font_set->charset_list = data->charset_list;
+
+ if((font_set->font_data = init_fontdata(data->font_data,
+ data->font_data_count)) == NULL)
+ goto err;
+ font_set->font_data_count = data->font_data_count;
+ if((font_set->substitute = init_fontdata(data->substitute,
+ data->substitute_num)) == NULL)
+ goto err;
+ font_set->substitute_num = data->substitute_num;
+ if((font_set->vmap = init_fontdata(data->vmap,
+ data->vmap_num)) == NULL)
+ goto err;
+ font_set->vmap_num = data->vmap_num;
+
+ if(data->vrotate_type != VROTATE_NONE) {
+ /* A vrotate member is specified primary font data */
+ /* as initial value. */
+ if((font_set->vrotate = init_vrotate(data->font_data,
+ data->font_data_count,
+ data->vrotate_type,
+ data->vrotate,
+ data->vrotate_num)) == NULL)
+ goto err;
+ font_set->vrotate_num = data->font_data_count;
+ }
+ }
+ return True;
+
+err:
+ if(font_set->font_data)
+ Xfree(font_set->font_data);
+ if(font_set->substitute)
+ Xfree(font_set->substitute);
+ if(font_set->vmap)
+ Xfree(font_set->vmap);
+ if(font_set->vrotate)
+ Xfree(font_set->vrotate);
+ if(font_set)
+ Xfree(font_set);
+ gen->font_set = (FontSet) NULL;
+ gen->font_set_num = 0;
+ return False;
+}
+
+/* For VW/UDC end */
+
+static char *
+get_prop_name(
+ Display *dpy,
+ XFontStruct *fs)
+{
+ unsigned long fp;
+
+ if (XGetFontProperty(fs, XA_FONT, &fp))
+ return XGetAtomName(dpy, fp);
+
+ return (char *) NULL;
+}
+
+/* For VW/UDC start */
+
+static Bool
+load_fontdata(
+ XOC oc,
+ FontData font_data,
+ int font_data_num)
+{
+ Display *dpy = oc->core.om->core.display;
+ FontData fd = font_data;
+
+ if(font_data == NULL) return(True);
+ for( ; font_data_num-- ; fd++) {
+ if(fd->xlfd_name != (char *) NULL && fd->font == NULL) {
+ fd->font = XLoadQueryFont(dpy, fd->xlfd_name);
+ if (fd->font == NULL){
+ return False;
+ }
+ }
+ }
+ return True;
+}
+
+static Bool
+load_fontset_data(
+ XOC oc,
+ FontSet font_set)
+{
+ Display *dpy = oc->core.om->core.display;
+
+ if(font_set->font_name == (char *)NULL) return False ;
+
+ /* If font_set->font is not NULL, it contains the *best*
+ * match font for this FontSet.
+ * -- jjw/pma (HP)
+ */
+ if(font_set->font == NULL) {
+ font_set->font = XLoadQueryFont(dpy, font_set->font_name);
+ if (font_set->font == NULL){
+ return False;
+ }
+ }
+ return True;
+}
+
+static Bool
+load_font(
+ XOC oc)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set = gen->font_set;
+ int num = gen->font_set_num;
+
+ for ( ; num-- > 0; font_set++) {
+ if (font_set->font_name == NULL)
+ continue;
+
+ if (load_fontset_data (oc, font_set) != True)
+ return False;
+#ifndef TESTVERSION
+ if(load_fontdata(oc, font_set->font_data,
+ font_set->font_data_count) != True)
+ return False;
+
+ if(load_fontdata(oc, font_set->substitute,
+ font_set->substitute_num) != True)
+ return False;
+#endif
+
+/* Add 1996.05.20 */
+ if( oc->core.orientation == XOMOrientation_TTB_RTL ||
+ oc->core.orientation == XOMOrientation_TTB_LTR ){
+ if (font_set->vpart_initialize == 0) {
+ load_fontdata(oc, font_set->vmap, font_set->vmap_num);
+ load_fontdata(oc, (FontData) font_set->vrotate,
+ font_set->vrotate_num);
+ font_set->vpart_initialize = 1;
+ }
+ }
+
+ if (font_set->font->min_byte1 || font_set->font->max_byte1)
+ font_set->is_xchar2b = True;
+ else
+ font_set->is_xchar2b = False;
+ }
+
+ return True;
+}
+
+/* For VW/UDC end */
+
+static Bool
+load_font_info(
+ XOC oc)
+{
+ Display *dpy = oc->core.om->core.display;
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set = gen->font_set;
+ char **fn_list;
+ int fn_num, num = gen->font_set_num;
+
+ for ( ; num-- > 0; font_set++) {
+ if (font_set->font_name == NULL)
+ continue;
+
+ if (font_set->info == NULL) {
+ fn_list = XListFontsWithInfo(dpy, font_set->font_name, 1, &fn_num,
+ &font_set->info);
+ if (font_set->info == NULL)
+ return False;
+
+ XFreeFontNames(fn_list);
+ }
+ }
+
+ return True;
+}
+
+/* For Vertical Writing start */
+
+static void
+check_fontset_extents(
+ XCharStruct *overall,
+ int *logical_ascent,
+ int *logical_descent,
+ XFontStruct *font)
+{
+ overall->lbearing = min(overall->lbearing, font->min_bounds.lbearing);
+ overall->rbearing = max(overall->rbearing, font->max_bounds.rbearing);
+ overall->ascent = max(overall->ascent, font->max_bounds.ascent);
+ overall->descent = max(overall->descent, font->max_bounds.descent);
+ overall->width = max(overall->width, font->max_bounds.width);
+ *logical_ascent = max(*logical_ascent, font->ascent);
+ *logical_descent = max(*logical_descent, font->descent);
+}
+
+/* For Vertical Writing end */
+
+static void
+set_fontset_extents(
+ XOC oc)
+{
+ XRectangle *ink = &oc->core.font_set_extents.max_ink_extent;
+ XRectangle *logical = &oc->core.font_set_extents.max_logical_extent;
+ XFontStruct **font_list, *font;
+ XCharStruct overall;
+ int logical_ascent, logical_descent;
+ int num = oc->core.font_info.num_font;
+
+ font_list = oc->core.font_info.font_struct_list;
+ font = *font_list++;
+ overall = font->max_bounds;
+ overall.lbearing = font->min_bounds.lbearing;
+ logical_ascent = font->ascent;
+ logical_descent = font->descent;
+
+ /* For Vertical Writing start */
+
+ while (--num > 0) {
+ font = *font_list++;
+ check_fontset_extents(&overall, &logical_ascent, &logical_descent,
+ font);
+ }
+
+ {
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set = gen->font_set;
+ FontData font_data;
+ int font_set_num = gen->font_set_num;
+ int font_data_count;
+
+ for( ; font_set_num-- ; font_set++) {
+ if(font_set->vmap_num > 0) {
+ font_data = font_set->vmap;
+ font_data_count = font_set->vmap_num;
+ for( ; font_data_count-- ; font_data++) {
+ if(font_data->font != NULL) {
+ check_fontset_extents(&overall, &logical_ascent,
+ &logical_descent,
+ font_data->font);
+ }
+ }
+ }
+
+ if(font_set->vrotate_num > 0) {
+ font_data = (FontData) font_set->vrotate;
+ font_data_count = font_set->vrotate_num;
+ for( ; font_data_count-- ; font_data++) {
+ if(font_data != NULL)
+ if(font_data->font != NULL) {
+ check_fontset_extents(&overall, &logical_ascent,
+ &logical_descent,
+ font_data->font);
+ }
+ }
+ }
+ }
+ }
+
+ /* For Vertical Writing start */
+
+ ink->x = overall.lbearing;
+ ink->y = -(overall.ascent);
+ ink->width = overall.rbearing - overall.lbearing;
+ ink->height = overall.ascent + overall.descent;
+
+ logical->x = 0;
+ logical->y = -(logical_ascent);
+ logical->width = overall.width;
+ logical->height = logical_ascent + logical_descent;
+}
+
+static Bool
+init_core_part(
+ XOC oc)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ int font_set_num;
+ XFontStruct **font_struct_list;
+ char **font_name_list, *font_name_buf;
+ int count, length;
+
+ font_set = gen->font_set;
+ font_set_num = gen->font_set_num;
+ count = length = 0;
+
+ for ( ; font_set_num-- > 0; font_set++) {
+ if (font_set->font_name == NULL)
+ continue;
+
+ length += strlen(font_set->font_name) + 1;
+
+ count++;
+ }
+ if (count == 0)
+ return False;
+
+ font_struct_list = (XFontStruct **) Xmalloc(sizeof(XFontStruct *) * count);
+ if (font_struct_list == NULL)
+ return False;
+
+ font_name_list = (char **) Xmalloc(sizeof(char *) * count);
+ if (font_name_list == NULL)
+ goto err;
+
+ font_name_buf = (char *) Xmalloc(length);
+ if (font_name_buf == NULL)
+ goto err;
+
+ oc->core.font_info.num_font = count;
+ oc->core.font_info.font_name_list = font_name_list;
+ oc->core.font_info.font_struct_list = font_struct_list;
+
+ font_set = gen->font_set;
+ font_set_num = gen->font_set_num;
+
+ for (count = 0; font_set_num-- > 0; font_set++) {
+ if (font_set->font_name == NULL)
+ continue;
+
+ font_set->id = count;
+ if (font_set->font)
+ *font_struct_list++ = font_set->font;
+ else
+ *font_struct_list++ = font_set->info;
+ strcpy(font_name_buf, font_set->font_name);
+ Xfree(font_set->font_name);
+ *font_name_list++ = font_set->font_name = font_name_buf;
+ font_name_buf += strlen(font_name_buf) + 1;
+
+ count++;
+ }
+
+ set_fontset_extents(oc);
+
+ return True;
+
+err:
+ if (font_name_list)
+ Xfree(font_name_list);
+ Xfree(font_struct_list);
+
+ return False;
+}
+
+static char *
+get_font_name(
+ XOC oc,
+ char *pattern)
+{
+ char **list, *name;
+ int count = 0;
+
+ list = XListFonts(oc->core.om->core.display, pattern, 1, &count);
+ if (list == NULL)
+ return NULL;
+
+ name = (char *) Xmalloc(strlen(*list) + 1);
+ if (name)
+ strcpy(name, *list);
+
+ XFreeFontNames(list);
+
+ return name;
+}
+
+/* For VW/UDC start*/
+
+static char *
+get_rotate_fontname(
+ char *font_name)
+{
+ char *pattern = NULL, *ptr = NULL;
+ char *fields[CHARSET_ENCODING_FIELD];
+ char str_pixel[32], str_point[4];
+ char *rotate_font_ptr = NULL;
+ int pixel_size = 0;
+ int field_num = 0, len = 0;
+
+ if(font_name == (char *) NULL || (len = strlen(font_name)) <= 0
+ || len > XLFD_MAX_LEN)
+ return NULL;
+
+ pattern = (char *)Xmalloc(len + 1);
+ if(!pattern)
+ return NULL;
+ strcpy(pattern, font_name);
+
+ memset(fields, 0, sizeof(char *) * 14);
+ ptr = pattern;
+ while(isspace(*ptr)) {
+ ptr++;
+ }
+ if(*ptr == '-')
+ ptr++;
+
+ for(field_num = 0 ; field_num < CHARSET_ENCODING_FIELD && ptr && *ptr ;
+ ptr++, field_num++) {
+ fields[field_num] = ptr;
+
+ if((ptr = strchr(ptr, '-'))) {
+ *ptr = '\0';
+ }
+ }
+
+ if(field_num < CHARSET_ENCODING_FIELD)
+ return NULL;
+
+ /* Pixel Size field : fields[6] */
+ for(ptr = fields[PIXEL_SIZE_FIELD - 1] ; ptr && *ptr; ptr++) {
+ if(!isdigit(*ptr)) {
+ if(*ptr == '['){ /* 960730 */
+ strcpy(pattern, font_name);
+ return(pattern);
+ }
+ if(pattern)
+ Xfree(pattern);
+ return NULL;
+ }
+ }
+ pixel_size = atoi(fields[PIXEL_SIZE_FIELD - 1]);
+ sprintf(str_pixel, "[ 0 ~%d %d 0 ]", pixel_size, pixel_size);
+ fields[6] = str_pixel;
+
+ /* Point Size field : fields[7] */
+ strcpy(str_point, "*");
+ fields[POINT_SIZE_FIELD - 1] = str_point;
+
+ len = 0;
+ for (field_num = 0; field_num < CHARSET_ENCODING_FIELD &&
+ fields[field_num]; field_num++) {
+ len += 1 + strlen(fields[field_num]);
+ }
+
+ /* Max XLFD length is 255 */
+ if (len > XLFD_MAX_LEN)
+ return NULL;
+
+ rotate_font_ptr = (char *)Xmalloc(len + 1);
+ if(!rotate_font_ptr)
+ return NULL;
+
+ rotate_font_ptr[0] = '\0';
+
+ for(field_num = 0 ; field_num < CHARSET_ENCODING_FIELD &&
+ fields[field_num] ; field_num++) {
+ sprintf(rotate_font_ptr, "%s-%s", rotate_font_ptr, fields[field_num]);
+ }
+
+ if(pattern)
+ Xfree(pattern);
+
+ return rotate_font_ptr;
+}
+
+static Bool
+is_match_charset(
+ FontData font_data,
+ char *font_name)
+{
+ char *last;
+ int length, name_len;
+
+ name_len = strlen(font_name);
+ last = font_name + name_len;
+
+ length = strlen(font_data->name);
+ if (length > name_len)
+ return False;
+
+ if (_XlcCompareISOLatin1(last - length, font_data->name) == 0)
+ return True;
+
+ return False;
+}
+
+#if 0
+static char *
+get_font_name_from_list(
+ XOC oc,
+ char *pattern,
+ FontData font_data)
+{
+ char **list, *name = (char *)NULL, *fname;
+ int count = 0, i;
+
+ list = XListFonts(oc->core.om->core.display, pattern, MAXFONTS, &count);
+ if (list == NULL)
+ return NULL;
+
+ for (i = 0; i < count; i++) {
+ fname = list[i];
+ if(is_match_charset(font_data, fname) == True) {
+ name = (char *) Xmalloc(strlen(fname) + 1);
+ if (name)
+ strcpy(name, fname);
+ break;
+ }
+ }
+
+ XFreeFontNames(list);
+
+ return name;
+}
+#endif
+
+static int
+parse_all_name(
+ XOC oc,
+ FontData font_data,
+ char *pattern)
+{
+
+#ifdef OLDCODE
+ if(is_match_charset(font_data, pattern) != True)
+ return False;
+
+ font_data->xlfd_name = (char *)Xmalloc(strlen(pattern)+1);
+ if(font_data->xlfd_name == NULL)
+ return (-1);
+
+ strcpy(font_data->xlfd_name, pattern);
+ return True;
+#else /* OLDCODE */
+ Display *dpy = oc->core.om->core.display;
+ char **fn_list = NULL, *prop_fname = NULL;
+ int list_num;
+ XFontStruct *fs_list;
+ if(is_match_charset(font_data, pattern) != True) {
+ /*
+ * pattern should not contain any wildcard (execpt '?')
+ * this was probably added to make this case insensitive.
+ */
+ if ((fn_list = XListFontsWithInfo(dpy, pattern,
+ MAXFONTS,
+ &list_num, &fs_list)) == NULL) {
+ return False;
+ }
+ /* shouldn't we loop here ? */
+ else if ((prop_fname = get_prop_name(dpy, fs_list)) == NULL) {
+ XFreeFontInfo(fn_list, fs_list, list_num);
+ return False;
+ }
+ else if ((is_match_charset(font_data, prop_fname) != True)) {
+ XFree(prop_fname);
+ XFreeFontInfo(fn_list, fs_list, list_num);
+ return False;
+ }
+ else {
+ font_data->xlfd_name = prop_fname;
+ XFreeFontInfo(fn_list, fs_list, list_num);
+ return True;
+ }
+ }
+
+ font_data->xlfd_name = (char *)Xmalloc(strlen(pattern)+1);
+ if(font_data->xlfd_name == NULL)
+ return (-1);
+
+ strcpy(font_data->xlfd_name, pattern);
+ return True;
+#endif /* OLDCODE */
+}
+
+static int
+parse_omit_name(
+ XOC oc,
+ FontData font_data,
+ char *pattern)
+{
+ char* last = (char *) NULL;
+ char* base_name;
+ char buf[XLFD_MAX_LEN + 1];
+ int length = 0;
+ int num_fields;
+ /*
+ * If the font specified by "pattern" is expandable to be
+ * a member of "font_data"'s FontSet, we've found a match.
+ */
+ if(is_match_charset(font_data, pattern) == True) {
+ if ((font_data->xlfd_name = get_font_name(oc, pattern)) != NULL) {
+ return True;
+ }
+ }
+
+ length = strlen (pattern);
+
+ if (length > XLFD_MAX_LEN)
+ return -1;
+
+ strcpy(buf, pattern);
+ last = buf + length - 1;
+
+ /* Replace the original encoding with the encoding for this FontSet. */
+
+ /* Figure out how many fields have been specified in this xlfd. */
+ for (num_fields = 0, base_name = buf; *base_name != '\0'; base_name++)
+ if (*base_name == '-') num_fields++;
+
+ switch (num_fields) {
+ case 12:
+ /* This is the best way to have specifed the fontset. In this
+ * case, there is no original encoding. E.g.,
+ * -*-*-*-*-*-*-14-*-*-*-*-*
+ * To this, we'll append a dash:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-
+ * then append the encoding to get:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-JISX0208.1990-0
+ */
+ /*
+ * Take care of:
+ * -*-*-*-*-*-*-14-*-*-*-*-
+ */
+ if (*(last) == '-')
+ *++last = '*';
+
+ *++last = '-';
+ break;
+ case 13:
+ /* Got the charset, not the encoding, zap the charset In this
+ * case, there is no original encoding, but there is a charset. E.g.,
+ * -*-*-*-*-*-*-14-*-*-*-*-*-jisx0212.1990
+ * To this, we remove the charset:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-
+ * then append the new encoding to get:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-JISX0208.1990-0
+ */
+ last = strrchr (buf, '-');
+ num_fields = 12;
+ break;
+ case 14:
+ /* Both the charset and the encoding are specified. Get rid
+ * of them so that we can append the new charset encoding. E.g.,
+ * -*-*-*-*-*-*-14-*-*-*-*-*-jisx0212.1990-0
+ * To this, we'll remove the encoding and charset to get:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-
+ * then append the new encoding to get:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-JISX0208.1990-0
+ */
+ last = strrchr (buf, '-');
+ *last = '\0';
+ last = strrchr (buf, '-');
+ num_fields = 12;
+ break;
+ default:
+ if (*last != '-')
+ *++last = '-';
+ break;
+ }
+
+ /* At this point, "last" is pointing to the last "-" in the
+ * xlfd, and all xlfd's at this point take a form similar to:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-
+ * (i.e., no encoding).
+ * After the strcpy, we'll end up with something similar to:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-JISX0208.1990-0
+ *
+ * If the modified font is found in the current FontSet,
+ * we've found a match.
+ */
+
+ last++;
+
+ if ((last - buf) + strlen(font_data->name) > XLFD_MAX_LEN)
+ return -1;
+
+ strcpy(last, font_data->name);
+ if ((font_data->xlfd_name = get_font_name(oc, buf)) != NULL)
+ return True;
+
+ /* This may mot be needed anymore as XListFonts() takes care of this */
+ while (num_fields < 12) {
+ if ((last - buf) > (XLFD_MAX_LEN - 2))
+ return -1;
+ *last = '*';
+ *(last + 1) = '-';
+ strcpy(last + 2, font_data->name);
+ num_fields++;
+ last+=2;
+ if ((font_data->xlfd_name = get_font_name(oc, buf)) != NULL)
+ return True;
+ }
+
+
+ return False;
+}
+
+
+typedef enum{C_PRIMARY, C_SUBSTITUTE, C_VMAP, C_VROTATE } ClassType;
+
+static int
+parse_fontdata(
+ XOC oc,
+ FontSet font_set,
+ FontData font_data,
+ int font_data_count,
+ char **name_list,
+ int name_list_count,
+ ClassType class,
+ FontDataRec *font_data_return)
+{
+
+ char **cur_name_list = name_list;
+ char *font_name = (char *) NULL;
+ char *pattern = (char *) NULL;
+ int found_num = 0, ret = 0;
+ int count = name_list_count;
+
+ if(name_list == NULL || count <= 0) {
+ return False;
+ }
+
+ if(font_data == NULL || font_data_count <= 0) {
+ return False;
+ }
+
+ /* Loop through each font encoding defined in the "font_data" FontSet. */
+ for ( ; font_data_count-- > 0; font_data++) {
+ Bool is_found = False;
+ font_name = (char *) NULL;
+ count = name_list_count;
+ cur_name_list = name_list;
+
+ /*
+ * Loop through each font specified by the user
+ * in the call to XCreateFontset().
+ */
+ while (count-- > 0) {
+ pattern = *cur_name_list++;
+ if (pattern == NULL || *pattern == '\0')
+ continue;
+#ifdef FONTDEBUG
+ fprintf(stderr,"Font pattern: %s %s\n",
+ pattern,font_data->name);
+#endif
+
+ /*
+ * If the current font is fully specified (i.e., the
+ * xlfd contains no wildcards) and the font exists on
+ * the X Server, we have a match.
+ */
+ if (strchr(pattern, '*') == NULL &&
+ (font_name = get_font_name(oc, pattern))) {
+ /*
+ * Find the full xlfd name for this font. If the font is
+ * already in xlfd format, it is simply returned. If the
+ * font is an alias for another font, the xlfd of the
+ * aliased font is returned.
+ */
+ ret = parse_all_name(oc, font_data, font_name);
+ Xfree(font_name);
+
+ if (ret == -1) return -1;
+ if (ret == False) continue;
+ /*
+ * Since there was an exact match of a fully-specified font
+ * or a font alias, we can return now since the desired font
+ * was found for the current font encoding for this FontSet.
+ *
+ * Previous implementations of this algorithm would
+ * not return here. Instead, they continued searching
+ * through the font encodings for this FontSet. The side-effect
+ * of that behavior is you may return a "substitute" match
+ * instead of an "exact" match. We believe there should be a
+ * preference on exact matches. Therefore, as soon as we
+ * find one, we bail.
+ *
+ * Also, previous implementations seemed to think it was
+ * important to find either a primary or substitute font
+ * for each Font encoding in the FontSet before returning an
+ * acceptable font. We don't believe this is necessary.
+ * All the client cares about is finding a reasonable font
+ * for what was passed in. If we find an exact match,
+ * there's no reason to look any further.
+ *
+ * -- jjw/pma (HP)
+ */
+ if (font_data_return) {
+ font_data_return->xlfd_name = (char *)Xmalloc
+ (strlen(font_data->xlfd_name) + 1);
+ if (!font_data_return->xlfd_name) return -1;
+
+ strcpy (font_data_return->xlfd_name, font_data->xlfd_name);
+
+ font_data_return->side = font_data->side;
+ }
+#ifdef FONTDEBUG
+ fprintf(stderr,"XLFD name: %s\n",font_data->xlfd_name);
+#endif
+
+ return True;
+ }
+ /*
+ * If the font name is not fully specified
+ * (i.e., it has wildcards), we have more work to do.
+ * See the comments in parse_omit_name()
+ * for the list of things to do.
+ */
+ ret = parse_omit_name(oc, font_data, pattern);
+
+ if (ret == -1) return -1;
+ if (ret == False) continue;
+
+ /*
+ * A font which matched the wild-carded specification was found.
+ * Only update the return data if a font has not yet been found.
+ * This maintains the convention that FontSets listed higher in
+ * a CodeSet in the Locale Database have higher priority than
+ * those FontSets listed lower in the CodeSet. In the following
+ * example:
+ *
+ * fs1 {
+ * charset HP-JIS:GR
+ * font JISX0208.1990-0:GL;\
+ * JISX0208.1990-1:GR;\
+ * JISX0208.1983-0:GL;\
+ * JISX0208.1983-1:GR
+ * }
+ *
+ * a font found in the JISX0208.1990-0 FontSet will have a
+ * higher priority than a font found in the JISX0208.1983-0
+ * FontSet.
+ */
+ if (font_data_return && font_data_return->xlfd_name == NULL) {
+
+#ifdef FONTDEBUG
+ fprintf(stderr,"XLFD name: %s\n",font_data->xlfd_name);
+#endif
+ font_data_return->xlfd_name = (char *)Xmalloc
+ (strlen(font_data->xlfd_name) + 1);
+ if (!font_data_return->xlfd_name) return -1;
+
+ strcpy (font_data_return->xlfd_name, font_data->xlfd_name);
+ font_data_return->side = font_data->side;
+ }
+
+ found_num++;
+ is_found = True;
+
+ break;
+ }
+
+ switch(class) {
+ case C_PRIMARY:
+ if(is_found == False) {
+ /*
+ * Did not find a font for the current FontSet. Check the
+ * FontSet's "substitute" font for a match. If we find a
+ * match, we'll keep searching in hopes of finding an exact
+ * match later down the FontSet list.
+ *
+ * when we return and we have found a font font_data_return
+ * contains the first (ie. best) match no matter if this
+ * is a C_PRIMARY or a C_SUBSTITUTE font
+ */
+ ret = parse_fontdata(oc, font_set, font_set->substitute,
+ font_set->substitute_num, name_list,
+ name_list_count, C_SUBSTITUTE,
+ font_data_return);
+ if (ret == -1) return -1;
+ if (ret == False) continue;
+
+ found_num++;
+ is_found = True;
+ }
+#ifdef TESTVERSION
+ else
+ return True;
+#endif
+ break;
+
+ case C_SUBSTITUTE:
+ case C_VMAP:
+ if(is_found == True)
+ return True;
+ break;
+
+ case C_VROTATE:
+ if(is_found == True) {
+ char *rotate_name;
+
+ if((rotate_name = get_rotate_fontname(font_data->xlfd_name))
+ != NULL) {
+ Xfree(font_data->xlfd_name);
+ font_data->xlfd_name = rotate_name;
+
+ return True;
+ }
+ Xfree(font_data->xlfd_name);
+ font_data->xlfd_name = NULL;
+ return False;
+ }
+ break;
+ }
+ }
+
+ if(class == C_PRIMARY && found_num >= 1)
+ return True;
+
+ return False;
+}
+
+
+static int
+parse_vw(
+ XOC oc,
+ FontSet font_set,
+ char **name_list,
+ int count)
+{
+ FontData vmap = font_set->vmap;
+ VRotate vrotate = font_set->vrotate;
+ int vmap_num = font_set->vmap_num;
+ int vrotate_num = font_set->vrotate_num;
+ int ret = 0, i = 0;
+
+ if(vmap_num > 0) {
+ if(parse_fontdata(oc, font_set, vmap, vmap_num, name_list,
+ count, C_VMAP,NULL) == -1)
+ return (-1);
+ }
+
+ if(vrotate_num > 0) {
+ ret = parse_fontdata(oc, font_set, (FontData) vrotate, vrotate_num,
+ name_list, count, C_VROTATE, NULL);
+ if(ret == -1) {
+ return (-1);
+ } else if(ret == False) {
+ CodeRange code_range;
+ int num_cr;
+ int sub_num = font_set->substitute_num;
+
+ code_range = vrotate[0].code_range; /* ? */
+ num_cr = vrotate[0].num_cr; /* ? */
+ for(i = 0 ; i < vrotate_num ; i++) {
+ if(vrotate[i].xlfd_name)
+ Xfree(vrotate[i].xlfd_name);
+ }
+ Xfree(vrotate);
+
+ if(sub_num > 0) {
+ vrotate = font_set->vrotate = (VRotate)Xmalloc
+ (sizeof(VRotateRec) * sub_num);
+ if(font_set->vrotate == (VRotate)NULL)
+ return (-1);
+ memset(font_set->vrotate, 0x00, sizeof(VRotateRec) * sub_num);
+
+ for(i = 0 ; i < sub_num ; i++) {
+ vrotate[i].charset_name = font_set->substitute[i].name;
+ vrotate[i].side = font_set->substitute[i].side;
+ vrotate[i].code_range = code_range;
+ vrotate[i].num_cr = num_cr;
+ }
+ vrotate_num = font_set->vrotate_num = sub_num;
+ } else {
+ vrotate = font_set->vrotate = (VRotate)NULL;
+ }
+
+ ret = parse_fontdata(oc, font_set, (FontData) vrotate, vrotate_num,
+ name_list, count, C_VROTATE, NULL);
+ if(ret == -1)
+ return (-1);
+ }
+ }
+
+ return True;
+}
+
+static int
+parse_fontname(
+ XOC oc)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ FontDataRec font_data_return;
+ char *base_name, **name_list;
+ int font_set_num = 0;
+ int found_num = 0;
+ int count = 0;
+ int ret;
+ int i;
+
+ name_list = _XParseBaseFontNameList(oc->core.base_name_list, &count);
+ if (name_list == NULL)
+ return -1;
+
+ font_set = gen->font_set;
+ font_set_num = gen->font_set_num;
+
+ /* Loop through all of the CharSets defined in the Locale
+ * database for the current Locale.
+ */
+ for( ; font_set_num-- > 0 ; font_set++) {
+ if(font_set->font_name)
+ continue;
+
+ if(font_set->font_data_count > 0) {
+
+ /*
+ * If there are a non-zero number of FontSets defined
+ * for this CharSet.
+ * Try to find a font for this CharSet. If we find an
+ * acceptable font, we save the information for return
+ * to the client. If we do not find an acceptable font,
+ * a "missing_charset" will be reported to the client
+ * for this CharSet.
+ */
+ font_data_return. xlfd_name = NULL;
+ font_data_return.side = XlcUnknown;
+
+ ret = parse_fontdata(oc, font_set, font_set->font_data,
+ font_set->font_data_count,
+ name_list, count, C_PRIMARY,
+ &font_data_return);
+ if(ret == -1) {
+ goto err;
+ } else if(ret == True) {
+ /*
+ * We can't just loop thru fontset->font_data to
+ * find the first (ie. best) match: parse_fontdata
+ * will try a substitute font if no primary one could
+ * be matched. It returns the required information in
+ * font_data_return.
+ */
+ font_set->font_name = (char *)Xmalloc
+ (strlen(font_data_return.xlfd_name) + 1);
+ if(font_set->font_name == (char *) NULL)
+ goto err;
+ strcpy(font_set->font_name, font_data_return.xlfd_name);
+ font_set->side = font_data_return.side;
+
+ Xfree (font_data_return.xlfd_name);
+ font_data_return.xlfd_name = NULL;
+
+ if(parse_vw(oc, font_set, name_list, count) == -1)
+ goto err;
+ found_num++;
+ }
+
+ } else if(font_set->substitute_num > 0) {
+ /*
+ * If there are no FontSets defined for this
+ * CharSet. We can only find "substitute" fonts.
+ */
+ ret = parse_fontdata(oc, font_set, font_set->substitute,
+ font_set->substitute_num,
+ name_list, count, C_SUBSTITUTE, NULL);
+ if(ret == -1) {
+ goto err;
+ } else if(ret == True) {
+ for(i=0;i<font_set->substitute_num;i++){
+ if(font_set->substitute[i].xlfd_name != NULL){
+ break;
+ }
+ }
+ font_set->font_name = (char *)Xmalloc
+ (strlen(font_set->substitute[i].xlfd_name) + 1);
+ if(font_set->font_name == (char *) NULL)
+ goto err;
+ strcpy(font_set->font_name,font_set->substitute[i].xlfd_name);
+ font_set->side = font_set->substitute[i].side;
+ if(parse_vw(oc, font_set, name_list, count) == -1)
+ goto err;
+
+ found_num++;
+ }
+ }
+ }
+
+ base_name = (char *) Xmalloc(strlen(oc->core.base_name_list) + 1);
+ if (base_name == NULL)
+ goto err;
+
+ strcpy(base_name, oc->core.base_name_list);
+ oc->core.base_name_list = base_name;
+
+ XFreeStringList(name_list);
+
+ return found_num;
+
+err:
+ XFreeStringList(name_list);
+ /* Prevent this from being freed twice */
+ oc->core.base_name_list = NULL;
+
+ return -1;
+}
+
+/* For VW/UDC end*/
+
+static Bool
+set_missing_list(
+ XOC oc)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ char **charset_list, *charset_buf;
+ int count, length, font_set_num;
+ int result = 1;
+
+ font_set = gen->font_set;
+ font_set_num = gen->font_set_num;
+ count = length = 0;
+
+ for ( ; font_set_num-- > 0; font_set++) {
+ if (font_set->info || font_set->font) {
+ continue;
+ }
+
+ /* Change 1996.01.23 start */
+ if(font_set->font_data_count <= 0 ||
+ font_set->font_data == (FontData)NULL) {
+ if(font_set->substitute_num <= 0 ||
+ font_set->substitute == (FontData)NULL) {
+ if(font_set->charset_list != NULL){
+ length +=
+ strlen(font_set->charset_list[0]->encoding_name) + 1;
+ } else {
+ length += 1;
+ }
+ } else {
+ length += strlen(font_set->substitute->name) + 1;
+ }
+ } else {
+ length += strlen(font_set->font_data->name) + 1;
+ }
+ /* Change 1996.01.23 end */
+ count++;
+ }
+
+ if (count < 1) {
+ return True;
+ }
+
+ charset_list = (char **) Xmalloc(sizeof(char *) * count);
+ if (charset_list == NULL) {
+ return False;
+ }
+
+ charset_buf = (char *) Xmalloc(length);
+ if (charset_buf == NULL) {
+ Xfree(charset_list);
+ return False;
+ }
+
+ oc->core.missing_list.charset_list = charset_list;
+ oc->core.missing_list.charset_count = count;
+
+ font_set = gen->font_set;
+ font_set_num = gen->font_set_num;
+
+ for ( ; font_set_num-- > 0; font_set++) {
+ if (font_set->info || font_set->font) {
+ continue;
+ }
+
+ /* Change 1996.01.23 start */
+ if(font_set->font_data_count <= 0 ||
+ font_set->font_data == (FontData)NULL) {
+ if(font_set->substitute_num <= 0 ||
+ font_set->substitute == (FontData)NULL) {
+ if(font_set->charset_list != NULL){
+ strcpy(charset_buf,
+ font_set->charset_list[0]->encoding_name);
+ } else {
+ strcpy(charset_buf, "");
+ }
+ result = 0;
+ } else {
+ strcpy(charset_buf, font_set->substitute->name);
+ }
+ } else {
+ strcpy(charset_buf, font_set->font_data->name);
+ }
+ /* Change 1996.01.23 end */
+ *charset_list++ = charset_buf;
+ charset_buf += strlen(charset_buf) + 1;
+ }
+
+ if(result == 0) {
+ return(False);
+ }
+
+ return True;
+}
+
+static Bool
+create_fontset(
+ XOC oc)
+{
+ XOMGenericPart *gen = XOM_GENERIC(oc->core.om);
+ int found_num;
+
+ if (init_fontset(oc) == False)
+ return False;
+
+ found_num = parse_fontname(oc);
+ if (found_num <= 0) {
+ if (found_num == 0)
+ set_missing_list(oc);
+ return False;
+ }
+
+ if (gen->on_demand_loading == True) {
+ if (load_font_info(oc) == False)
+ return False;
+ } else {
+ if (load_font(oc) == False)
+ return False;
+ }
+
+ if (init_core_part(oc) == False)
+ return False;
+
+ if (set_missing_list(oc) == False)
+ return False;
+
+ return True;
+}
+
+/* For VW/UDC start */
+static void
+free_fontdataOC(
+ Display *dpy,
+ FontData font_data,
+ int font_data_count)
+{
+ for( ; font_data_count-- ; font_data++) {
+ if(font_data->xlfd_name){
+ Xfree(font_data->xlfd_name);
+ font_data->xlfd_name = NULL;
+ }
+ if(font_data->font){ /* ADD 1996.01.7 */
+ if(font_data->font->fid) /* Add 1996.01.23 */
+ XFreeFont(dpy,font_data->font); /* ADD 1996.01.7 */
+ else /* Add 1996.01.23 */
+ XFreeFontInfo(NULL, font_data->font, 1);/* Add 1996.01.23 */
+ font_data->font = NULL;
+ }
+/*
+ * font_data->name and font_data->scopes belong to the OM not OC.
+ * To save space this data is shared between OM and OC. We are
+ * not allowed to free it here.
+ * It has been moved to free_fontdataOM()
+ */
+/*
+ if(font_data->scopes){
+ Xfree(font_data->scopes);
+ font_data->scopes = NULL;
+ }
+ if(font_data->name){
+ Xfree(font_data->name);
+ font_data->name = NULL;
+ }
+*/
+ }
+}
+
+static void destroy_fontdata(
+ XOCGenericPart *gen,
+ Display *dpy)
+{
+ FontSet font_set = (FontSet) NULL;
+ int font_set_num = 0;
+
+ if (gen->font_set) {
+ font_set = gen->font_set;
+ font_set_num = gen->font_set_num;
+ for( ; font_set_num-- ; font_set++) {
+ if (font_set->font) {
+ if(font_set->font->fid)
+ XFreeFont(dpy,font_set->font);
+ else
+ XFreeFontInfo(NULL, font_set->font, 1);
+ font_set->font = NULL;
+ }
+ if(font_set->font_data) {
+ if (font_set->info)
+ XFreeFontInfo(NULL, font_set->info, 1);
+ free_fontdataOC(dpy,
+ font_set->font_data, font_set->font_data_count);
+ Xfree(font_set->font_data);
+ font_set->font_data = NULL;
+ }
+ if(font_set->substitute) {
+ free_fontdataOC(dpy,
+ font_set->substitute, font_set->substitute_num);
+ Xfree(font_set->substitute);
+ font_set->substitute = NULL;
+ }
+ if(font_set->vmap) {
+ free_fontdataOC(dpy,
+ font_set->vmap, font_set->vmap_num);
+ Xfree(font_set->vmap);
+ font_set->vmap = NULL;
+ }
+ if(font_set->vrotate) {
+ free_fontdataOC(dpy,
+ (FontData)font_set->vrotate,
+ font_set->vrotate_num);
+ Xfree(font_set->vrotate);
+ font_set->vrotate = NULL;
+ }
+ }
+ Xfree(gen->font_set);
+ gen->font_set = NULL;
+ }
+}
+/* For VW/UDC end */
+
+static void
+destroy_oc(
+ XOC oc)
+{
+ Display *dpy = oc->core.om->core.display;
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+
+ if (gen->mbs_to_cs)
+ _XlcCloseConverter(gen->mbs_to_cs);
+
+ if (gen->wcs_to_cs)
+ _XlcCloseConverter(gen->wcs_to_cs);
+
+ if (gen->utf8_to_cs)
+ _XlcCloseConverter(gen->utf8_to_cs);
+
+/* For VW/UDC start */ /* Change 1996.01.8 */
+ destroy_fontdata(gen,dpy);
+/*
+*/
+/* For VW/UDC end */
+
+ if (oc->core.base_name_list)
+ Xfree(oc->core.base_name_list);
+
+ if (oc->core.font_info.font_name_list)
+ XFreeStringList(oc->core.font_info.font_name_list);
+
+ if (oc->core.font_info.font_struct_list) {
+ Xfree(oc->core.font_info.font_struct_list);
+ }
+
+ if (oc->core.missing_list.charset_list)
+ XFreeStringList(oc->core.missing_list.charset_list);
+
+#ifdef notdef
+ if (oc->core.res_name)
+ Xfree(oc->core.res_name);
+ if (oc->core.res_class)
+ Xfree(oc->core.res_class);
+#endif
+
+ Xfree(oc);
+}
+
+static char *
+set_oc_values(
+ XOC oc,
+ XlcArgList args,
+ int num_args)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set = gen->font_set;
+ char *ret;
+ int num = gen->font_set_num;
+
+ if (oc->core.resources == NULL)
+ return NULL;
+
+ ret = _XlcSetValues((XPointer) oc, oc->core.resources,
+ oc->core.num_resources, args, num_args, XlcSetMask);
+ if(ret != NULL){
+ return(ret);
+ } else {
+ for ( ; num-- > 0; font_set++) {
+ if (font_set->font_name == NULL)
+ continue;
+ if (font_set->vpart_initialize != 0)
+ continue;
+ if( oc->core.orientation == XOMOrientation_TTB_RTL ||
+ oc->core.orientation == XOMOrientation_TTB_LTR ){
+ load_fontdata(oc, font_set->vmap, font_set->vmap_num);
+ load_fontdata(oc, (FontData) font_set->vrotate,
+ font_set->vrotate_num);
+ font_set->vpart_initialize = 1;
+ }
+ }
+ return(NULL);
+ }
+}
+
+static char *
+get_oc_values(
+ XOC oc,
+ XlcArgList args,
+ int num_args)
+{
+ if (oc->core.resources == NULL)
+ return NULL;
+
+ return _XlcGetValues((XPointer) oc, oc->core.resources,
+ oc->core.num_resources, args, num_args, XlcGetMask);
+}
+
+static XOCMethodsRec oc_default_methods = {
+ destroy_oc,
+ set_oc_values,
+ get_oc_values,
+ _XmbDefaultTextEscapement,
+ _XmbDefaultTextExtents,
+ _XmbDefaultTextPerCharExtents,
+ _XmbDefaultDrawString,
+ _XmbDefaultDrawImageString,
+ _XwcDefaultTextEscapement,
+ _XwcDefaultTextExtents,
+ _XwcDefaultTextPerCharExtents,
+ _XwcDefaultDrawString,
+ _XwcDefaultDrawImageString,
+ _Xutf8DefaultTextEscapement,
+ _Xutf8DefaultTextExtents,
+ _Xutf8DefaultTextPerCharExtents,
+ _Xutf8DefaultDrawString,
+ _Xutf8DefaultDrawImageString
+};
+
+static XOCMethodsRec oc_generic_methods = {
+ destroy_oc,
+ set_oc_values,
+ get_oc_values,
+ _XmbGenericTextEscapement,
+ _XmbGenericTextExtents,
+ _XmbGenericTextPerCharExtents,
+ _XmbGenericDrawString,
+ _XmbGenericDrawImageString,
+ _XwcGenericTextEscapement,
+ _XwcGenericTextExtents,
+ _XwcGenericTextPerCharExtents,
+ _XwcGenericDrawString,
+ _XwcGenericDrawImageString,
+ _Xutf8GenericTextEscapement,
+ _Xutf8GenericTextExtents,
+ _Xutf8GenericTextPerCharExtents,
+ _Xutf8GenericDrawString,
+ _Xutf8GenericDrawImageString
+};
+
+typedef struct _XOCMethodsListRec {
+ char *name;
+ XOCMethods methods;
+} XOCMethodsListRec, *XOCMethodsList;
+
+static XOCMethodsListRec oc_methods_list[] = {
+ { "default", &oc_default_methods },
+ { "generic", &oc_generic_methods }
+};
+
+static XlcResource oc_resources[] = {
+ { XNBaseFontName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.base_name_list), XlcCreateMask | XlcGetMask },
+ { XNOMAutomatic, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XOCRec, core.om_automatic), XlcGetMask },
+ { XNMissingCharSet, NULLQUARK, sizeof(XOMCharSetList),
+ XOffsetOf(XOCRec, core.missing_list), XlcGetMask },
+ { XNDefaultString, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.default_string), XlcGetMask },
+ { XNOrientation, NULLQUARK, sizeof(XOrientation),
+ XOffsetOf(XOCRec, core.orientation), XlcDefaultMask | XlcSetMask | XlcGetMask },
+ { XNResourceName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.res_name), XlcSetMask | XlcGetMask },
+ { XNResourceClass, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.res_class), XlcSetMask | XlcGetMask },
+ { XNFontInfo, NULLQUARK, sizeof(XOMFontInfo),
+ XOffsetOf(XOCRec, core.font_info), XlcGetMask }
+};
+
+static XOC
+create_oc(
+ XOM om,
+ XlcArgList args,
+ int num_args)
+{
+ XOC oc;
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ XOCMethodsList methods_list = oc_methods_list;
+ int count;
+
+ oc = (XOC) Xmalloc(sizeof(XOCGenericRec));
+ if (oc == NULL)
+ return (XOC) NULL;
+ bzero((char *) oc, sizeof(XOCGenericRec));
+
+ oc->core.om = om;
+
+ if (oc_resources[0].xrm_name == NULLQUARK)
+ _XlcCompileResourceList(oc_resources, XlcNumber(oc_resources));
+
+ if (_XlcSetValues((XPointer) oc, oc_resources, XlcNumber(oc_resources),
+ args, num_args, XlcCreateMask | XlcDefaultMask))
+ goto err;
+
+ if (oc->core.base_name_list == NULL)
+ goto err;
+
+ oc->core.resources = oc_resources;
+ oc->core.num_resources = XlcNumber(oc_resources);
+
+ if (create_fontset(oc) == False)
+ goto err;
+
+ oc->methods = &oc_generic_methods;
+
+ if (gen->object_name) {
+ count = XlcNumber(oc_methods_list);
+
+ for ( ; count-- > 0; methods_list++) {
+ if (!_XlcCompareISOLatin1(gen->object_name, methods_list->name)) {
+ oc->methods = methods_list->methods;
+ break;
+ }
+ }
+ }
+
+ return oc;
+
+err:
+ destroy_oc(oc);
+
+ return (XOC) NULL;
+}
+
+static void
+free_fontdataOM(
+ FontData font_data,
+ int font_data_count)
+{
+ for( ; font_data_count-- ; font_data++) {
+ if(font_data->name){
+ Xfree(font_data->name);
+ font_data->name = NULL;
+ }
+ if(font_data->scopes){
+ Xfree(font_data->scopes);
+ font_data->scopes = NULL;
+ }
+ }
+}
+
+static Status
+close_om(
+ XOM om)
+{
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ OMData data;
+ int count;
+
+ if ((data = gen->data)) {
+ for (count = gen->data_num; count-- > 0; data++) {
+ if (data->charset_list){
+ Xfree(data->charset_list);
+ data->charset_list = NULL;
+ }
+ /* free font_data for om */
+ if (data->font_data) {
+ free_fontdataOM(data->font_data,data->font_data_count);
+ Xfree(data->font_data);
+ data->font_data = NULL;
+ }
+ /* free substitute for om */
+ if (data->substitute) {
+ free_fontdataOM(data->substitute,data->substitute_num);
+ Xfree(data->substitute);
+ data->substitute = NULL;
+ }
+ /* free vmap for om */
+ if (data->vmap) {
+ free_fontdataOM(data->vmap,data->vmap_num);
+ Xfree(data->vmap);
+ data->vmap = NULL;
+ }
+ /* free vrotate for om */
+ if (data->vrotate) {
+ Xfree(data->vrotate);
+ data->vrotate = NULL;
+ }
+ }
+ Xfree(gen->data);
+ gen->data = NULL;
+ }
+
+ if (gen->object_name){
+ Xfree(gen->object_name);
+ gen->object_name = NULL;
+ }
+
+ if (om->core.res_name){
+ Xfree(om->core.res_name);
+ om->core.res_name = NULL;
+ }
+ if (om->core.res_class){
+ Xfree(om->core.res_class);
+ om->core.res_class = NULL;
+ }
+ if (om->core.required_charset.charset_list &&
+ om->core.required_charset.charset_count > 0){
+ XFreeStringList(om->core.required_charset.charset_list);
+ om->core.required_charset.charset_list = NULL;
+ } else {
+ Xfree((char*)om->core.required_charset.charset_list);
+ om->core.required_charset.charset_list = NULL;
+ }
+ if (om->core.orientation_list.orientation){
+ Xfree(om->core.orientation_list.orientation);
+ om->core.orientation_list.orientation = NULL;
+ }
+
+ Xfree(om);
+
+ return 1;
+}
+
+static char *
+set_om_values(
+ XOM om,
+ XlcArgList args,
+ int num_args)
+{
+ if (om->core.resources == NULL)
+ return NULL;
+
+ return _XlcSetValues((XPointer) om, om->core.resources,
+ om->core.num_resources, args, num_args, XlcSetMask);
+}
+
+static char *
+get_om_values(
+ XOM om,
+ XlcArgList args,
+ int num_args)
+{
+ if (om->core.resources == NULL)
+ return NULL;
+
+ return _XlcGetValues((XPointer) om, om->core.resources,
+ om->core.num_resources, args, num_args, XlcGetMask);
+}
+
+static XOMMethodsRec methods = {
+ close_om,
+ set_om_values,
+ get_om_values,
+ create_oc
+};
+
+static XlcResource om_resources[] = {
+ { XNRequiredCharSet, NULLQUARK, sizeof(XOMCharSetList),
+ XOffsetOf(XOMRec, core.required_charset), XlcGetMask },
+ { XNQueryOrientation, NULLQUARK, sizeof(XOMOrientation),
+ XOffsetOf(XOMRec, core.orientation_list), XlcGetMask },
+ { XNDirectionalDependentDrawing, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XOMRec, core.directional_dependent), XlcGetMask },
+ { XNContextualDrawing, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XOMRec, core.contextual_drawing), XlcGetMask }
+};
+
+static XOM
+create_om(
+ XLCd lcd,
+ Display *dpy,
+ XrmDatabase rdb,
+ _Xconst char *res_name,
+ _Xconst char *res_class)
+{
+ XOM om;
+
+ om = (XOM) Xmalloc(sizeof(XOMGenericRec));
+ if (om == NULL)
+ return (XOM) NULL;
+ bzero((char *) om, sizeof(XOMGenericRec));
+
+ om->methods = &methods;
+ om->core.lcd = lcd;
+ om->core.display = dpy;
+ om->core.rdb = rdb;
+ if (res_name) {
+ om->core.res_name = (char *) Xmalloc(strlen(res_name) + 1);
+ if (om->core.res_name == NULL)
+ goto err;
+ strcpy(om->core.res_name, res_name);
+ }
+ if (res_class) {
+ om->core.res_class = (char *) Xmalloc(strlen(res_class) + 1);
+ if (om->core.res_class == NULL)
+ goto err;
+ strcpy(om->core.res_class, res_class);
+ }
+
+ if (om_resources[0].xrm_name == NULLQUARK)
+ _XlcCompileResourceList(om_resources, XlcNumber(om_resources));
+
+ om->core.resources = om_resources;
+ om->core.num_resources = XlcNumber(om_resources);
+
+ return om;
+
+err:
+ close_om(om);
+
+ return (XOM) NULL;
+}
+
+static OMData
+add_data(
+ XOM om)
+{
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ OMData new;
+ int num;
+
+ if ((num = gen->data_num))
+ new = (OMData) Xrealloc(gen->data, (num + 1) * sizeof(OMDataRec));
+ else
+ new = (OMData) Xmalloc(sizeof(OMDataRec));
+
+ if (new == NULL)
+ return NULL;
+
+ gen->data_num = num + 1;
+ gen->data = new;
+
+ new += num;
+ bzero((char *) new, sizeof(OMDataRec));
+
+ return new;
+}
+
+/* For VW/UDC */
+
+FontData
+read_EncodingInfo(
+ int count,
+ char **value)
+{
+ FontData font_data,ret;
+ char *buf, *bufptr,*scp;
+ int len;
+ font_data = (FontData) Xmalloc(sizeof(FontDataRec) * count);
+ if (font_data == NULL)
+ return NULL;
+ bzero((char *) font_data, sizeof(FontDataRec) * count);
+
+ ret = font_data;
+ for ( ; count-- > 0; font_data++) {
+/*
+ strcpy(buf, *value++);
+*/
+ buf = *value; value++;
+ if ((bufptr = strchr(buf, ':'))) {
+ len = (int)(bufptr - buf);
+ bufptr++ ;
+ } else
+ len = strlen(buf);
+ font_data->name = (char *) Xmalloc(len + 1);
+ if (font_data->name == NULL)
+ return NULL;
+ strncpy(font_data->name, buf,len);
+ font_data->name[len] = 0;
+ if (bufptr && _XlcCompareISOLatin1(bufptr, "GL") == 0)
+ font_data->side = XlcGL;
+ else if (bufptr && _XlcCompareISOLatin1(bufptr, "GR") == 0)
+ font_data->side = XlcGR;
+ else
+ font_data->side = XlcGLGR;
+
+ if (bufptr && (scp = strchr(bufptr, '['))){
+ font_data->scopes = _XlcParse_scopemaps(scp,&(font_data->scopes_num));
+ }
+ }
+ return(ret);
+}
+
+static CodeRange read_vrotate(
+ int count,
+ char **value,
+ int *type,
+ int *vrotate_num)
+{
+ CodeRange range;
+ if(!strcmp(value[0],"all")){
+ *type = VROTATE_ALL ;
+ *vrotate_num = 0 ;
+ return (NULL);
+ } else if(*(value[0]) == '['){
+ *type = VROTATE_PART ;
+ range = (CodeRange) _XlcParse_scopemaps(value[0],vrotate_num);
+ return (range);
+ } else {
+ *type = VROTATE_NONE ;
+ *vrotate_num = 0 ;
+ return (NULL);
+ }
+}
+
+static void read_vw(
+ XLCd lcd,
+ OMData font_set,
+ int num)
+{
+ char **value, buf[BUFSIZ];
+ int count;
+
+ sprintf(buf, "fs%d.font.vertical_map", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count > 0){
+ _XlcDbg_printValue(buf,value,count);
+ font_set->vmap_num = count;
+ font_set->vmap = read_EncodingInfo(count,value);
+ }
+
+ sprintf(buf, "fs%d.font.vertical_rotate", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count > 0){
+ _XlcDbg_printValue(buf,value,count);
+ font_set->vrotate = read_vrotate(count,value,&(font_set->vrotate_type),
+ &(font_set->vrotate_num));
+ }
+}
+/* VW/UDC end */
+static Bool
+init_om(
+ XOM om)
+{
+ XLCd lcd = om->core.lcd;
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ OMData data;
+ XlcCharSet *charset_list;
+ FontData font_data;
+ char **required_list;
+ XOrientation *orientation;
+ char **value, buf[BUFSIZ], *bufptr;
+ int count = 0, num = 0, length = 0;
+
+ _XlcGetResource(lcd, "XLC_FONTSET", "on_demand_loading", &value, &count);
+ if (count > 0 && _XlcCompareISOLatin1(*value, "True") == 0)
+ gen->on_demand_loading = True;
+
+ _XlcGetResource(lcd, "XLC_FONTSET", "object_name", &value, &count);
+ if (count > 0) {
+ gen->object_name = (char *) Xmalloc(strlen(*value) + 1);
+ if (gen->object_name == NULL)
+ return False;
+ strcpy(gen->object_name, *value);
+ }
+
+ for (num = 0; ; num++) {
+
+ sprintf(buf, "fs%d.charset.name", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+
+ if( count < 1){
+ sprintf(buf, "fs%d.charset", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1)
+ break;
+ }
+
+ data = add_data(om);
+ if (data == NULL)
+ return False;
+
+ charset_list = (XlcCharSet *) Xmalloc(sizeof(XlcCharSet) * count);
+ if (charset_list == NULL)
+ return False;
+ data->charset_list = charset_list;
+ data->charset_count = count;
+
+ while (count-- > 0){
+ *charset_list++ = _XlcGetCharSet(*value++);
+ }
+ sprintf(buf, "fs%d.charset.udc_area", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if( count > 0){
+ UDCArea udc;
+ int i,flag = 0;
+ udc = (UDCArea)Xmalloc(count * sizeof(UDCAreaRec));
+ if (udc == NULL)
+ return False;
+ for(i=0;i<count;i++){
+ sscanf(value[i],"\\x%lx,\\x%lx", &(udc[i].start),
+ &(udc[i].end));
+ }
+ for(i=0;i<data->charset_count;i++){
+ if(data->charset_list[i]->udc_area == NULL){
+ data->charset_list[i]->udc_area = udc;
+ data->charset_list[i]->udc_area_num = count;
+ flag = 1;
+ }
+ }
+ if(flag == 0){
+ Xfree(udc);
+ }
+ }
+
+ sprintf(buf, "fs%d.font.primary", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1){
+ sprintf(buf, "fs%d.font", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1)
+ return False;
+ }
+
+ font_data = read_EncodingInfo(count,value);
+ if (font_data == NULL)
+ return False;
+
+ data->font_data = font_data;
+ data->font_data_count = count;
+
+ sprintf(buf, "fs%d.font.substitute", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count > 0){
+ font_data = read_EncodingInfo(count,value);
+ if (font_data == NULL)
+ return False;
+ data->substitute = font_data;
+ data->substitute_num = count;
+ } else {
+ sprintf(buf, "fs%d.font", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1) {
+ data->substitute = NULL;
+ data->substitute_num = 0;
+ } else {
+ font_data = read_EncodingInfo(count,value);
+ data->substitute = font_data;
+ data->substitute_num = count;
+ }
+ }
+ read_vw(lcd,data,num);
+ length += strlen(data->font_data->name) + 1;
+ }
+
+ /* required charset list */
+ required_list = (char **) Xmalloc(sizeof(char *) * gen->data_num);
+ if (required_list == NULL)
+ return False;
+
+ bufptr = (char *) Xmalloc(length);
+ if (bufptr == NULL) {
+ Xfree(required_list);
+ return False;
+ }
+
+ om->core.required_charset.charset_list = required_list;
+ om->core.required_charset.charset_count = gen->data_num;
+
+ count = gen->data_num;
+ data = gen->data;
+
+ for ( ; count-- > 0; data++) {
+ strcpy(bufptr, data->font_data->name);
+ *required_list++ = bufptr;
+ bufptr += strlen(bufptr) + 1;
+ }
+
+ /* orientation list */
+ orientation = (XOrientation *) Xmalloc(sizeof(XOrientation) * 2);
+ if (orientation == NULL)
+ return False;
+
+ orientation[0] = XOMOrientation_LTR_TTB;
+ orientation[1] = XOMOrientation_TTB_RTL;
+ om->core.orientation_list.orientation = orientation;
+ om->core.orientation_list.num_orientation = 2;
+
+ /* directional dependent drawing */
+ om->core.directional_dependent = False;
+
+ /* contexual drawing */
+ om->core.contextual_drawing = False;
+
+ /* context dependent */
+ om->core.context_dependent = False;
+
+ return True;
+}
+
+XOM
+_XomGenericOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb,
+ _Xconst char *res_name, _Xconst char *res_class)
+{
+ XOM om;
+
+ om = create_om(lcd, dpy, rdb, res_name, res_class);
+ if (om == NULL)
+ return (XOM) NULL;
+
+ if (init_om(om) == False)
+ goto err;
+
+ return om;
+
+err:
+ close_om(om);
+
+ return (XOM) NULL;
+}
+
+Bool
+_XInitOM(
+ XLCd lcd)
+{
+ lcd->methods->open_om = _XomGenericOpenOM;
+
+ return True;
+}
diff --git a/nx-X11/lib/X11/omImText.c b/nx-X11/lib/X11/omImText.c
new file mode 100644
index 000000000..627c45b83
--- /dev/null
+++ b/nx-X11/lib/X11/omImText.c
@@ -0,0 +1,92 @@
+/* $Xorg: omImText.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/omImText.c,v 1.5 2003/04/13 19:22:22 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XomGeneric.h"
+
+#if 0
+extern int _XomGenericTextExtents(), _XomGenericDrawString();
+#endif
+
+#define GET_VALUE_MASK (GCFunction | GCForeground | GCBackground | GCFillStyle)
+#define SET_VALUE_MASK (GCFunction | GCForeground | GCFillStyle)
+
+static void
+_XomGenericDrawImageString(
+ Display *dpy,
+ Drawable d,
+ XOC oc,
+ GC gc,
+ int x, int y,
+ XOMTextType type,
+ XPointer text,
+ int length)
+{
+ XGCValues values;
+ XRectangle extent;
+
+ XGetGCValues(dpy, gc, GET_VALUE_MASK, &values);
+
+ XSetFunction(dpy, gc, GXcopy);
+ XSetForeground(dpy, gc, values.background);
+ XSetFillStyle(dpy, gc, FillSolid);
+
+ _XomGenericTextExtents(oc, type, text, length, 0, &extent);
+ XFillRectangle(dpy, d, gc, x + extent.x, y + extent.y, extent.width,
+ extent.height);
+
+ XChangeGC(dpy, gc, SET_VALUE_MASK, &values);
+
+ _XomGenericDrawString(dpy, d, oc, gc, x, y, type, text, length);
+}
+
+void
+_XmbGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length)
+{
+ _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMMultiByte,
+ (XPointer) text, length);
+}
+
+void
+_XwcGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst wchar_t *text, int length)
+{
+ _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMWideChar,
+ (XPointer) text, length);
+}
+
+void
+_Xutf8GenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length)
+{
+ _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMUtf8String,
+ (XPointer) text, length);
+}
diff --git a/nx-X11/lib/X11/omText.c b/nx-X11/lib/X11/omText.c
new file mode 100644
index 000000000..189aabd1e
--- /dev/null
+++ b/nx-X11/lib/X11/omText.c
@@ -0,0 +1,372 @@
+/* $Xorg: omText.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/omText.c,v 1.9 2003/04/22 13:57:45 pascal Exp $ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+/*
+ * Modifiers: Jeff Walls, Paul Anderson (HEWLETT-PACKARD)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+/* For VW/UDC */
+
+static int
+is_rotate(
+ XOC oc,
+ XFontStruct *font)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ VRotate vrotate;
+ int font_set_count;
+ int vrotate_num;
+
+ font_set = gen->font_set;
+ font_set_count = gen->font_set_num;
+ for( ; font_set_count-- ; font_set++) {
+ if((font_set->vrotate_num > 0) && (font_set->vrotate)) {
+ vrotate = font_set->vrotate;
+ vrotate_num = font_set->vrotate_num;
+ for( ; vrotate_num-- ; vrotate++)
+ if(vrotate->font == font)
+ return True;
+ }
+ }
+ return False;
+}
+
+static int
+is_codemap(
+ XOC oc,
+ XFontStruct *font)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ FontData vmap;
+ int font_set_count;
+ int vmap_num;
+
+ font_set = gen->font_set;
+ font_set_count = gen->font_set_num;
+ for( ; font_set_count-- ; font_set++) {
+ if(font_set->vmap_num > 0) {
+ vmap = font_set->vmap;
+ vmap_num = font_set->vmap_num;
+ for( ; vmap_num-- ; vmap++)
+ if(vmap->font == font)
+ return True;
+ }
+ }
+ return False;
+}
+
+static int
+draw_vertical(
+ Display *dpy,
+ Drawable d,
+ XOC oc,
+ GC gc,
+ XFontStruct *font,
+ Bool is_xchar2b,
+ int x, int y,
+ XPointer text,
+ int length)
+{
+ XChar2b *buf2b;
+ char *buf;
+ int wx = 0, wy = 0;
+ int direction = 0;
+ int font_ascent_return = 0, font_descent_return = 0;
+ int i;
+ XCharStruct overall;
+
+ wy = y;
+ if (is_xchar2b) {
+ for(i = 0, buf2b = (XChar2b *) text ; i < length ; i++, buf2b++) {
+ if(is_rotate(oc, font) == True) {
+ XTextExtents16(font, buf2b, 1,
+ &direction, &font_ascent_return,
+ &font_descent_return, &overall);
+ wx = x - (int)((overall.rbearing - overall.lbearing) >> 1) -
+ (int) overall.lbearing;
+ wy += overall.ascent;
+ XDrawString16(dpy, d, gc, wx, wy, buf2b, 1);
+ wy += overall.descent;
+ } else {
+ wx = x - (int)((font->max_bounds.rbearing -
+ font->min_bounds.lbearing) >> 1) -
+ (int) font->min_bounds.lbearing;
+ wy += font->max_bounds.ascent;
+ XDrawString16(dpy, d, gc, wx, wy, buf2b, 1);
+ wy += font->max_bounds.descent;
+ }
+ }
+ } else {
+ for(i = 0, buf = (char *)text ; i < length && *buf ; i++, buf++) {
+ if(is_rotate(oc, font) == True) {
+ XTextExtents(font, buf, 1,
+ &direction, &font_ascent_return,
+ &font_descent_return, &overall);
+ wx = x - (int)((overall.rbearing - overall.lbearing) >> 1) -
+ (int) overall.lbearing;
+ wy += overall.ascent;
+ XDrawString(dpy, d, gc, wx, wy, buf, 1);
+ wy += overall.descent;
+ } else {
+ wx = x - (int)((font->max_bounds.rbearing -
+ font->min_bounds.lbearing) >> 1) -
+ (int) font->min_bounds.lbearing;
+ wy += font->max_bounds.ascent;
+ XDrawString(dpy, d, gc, wx, wy, buf, 1);
+ wy += font->max_bounds.descent;
+ }
+ }
+ }
+ return wy;
+}
+
+#define VMAP 0
+#define VROTATE 1
+#define FONTSCOPE 2
+
+static int
+DrawStringWithFontSet(
+ Display *dpy,
+ Drawable d,
+ XOC oc,
+ FontSet fs,
+ GC gc,
+ int x, int y,
+ XPointer text,
+ int length)
+{
+ XFontStruct *font;
+ Bool is_xchar2b;
+ unsigned char *ptr;
+ int ptr_len, char_len = 0;
+ FontData fd;
+ int ret = 0;
+
+ ptr = (unsigned char *)text;
+ is_xchar2b = fs->is_xchar2b;
+
+ while (length > 0) {
+ fd = _XomGetFontDataFromFontSet(fs,
+ ptr,length,&ptr_len,is_xchar2b,FONTSCOPE);
+ if(ptr_len <= 0)
+ break;
+
+ /* First, see if the "Best Match" font for the FontSet was set.
+ * If it was, use that font. If it was not set, then use the
+ * font defined by font_set->font_data[0] (which is what
+ * _XomGetFontDataFromFontSet() always seems to return for
+ * non-VW text). Note that given the new algorithm in
+ * parse_fontname() and parse_fontdata(), fs->font will
+ * *always* contain good data. We should probably remove
+ * the check for "fd->font", but we won't :-) -- jjw/pma (HP)
+ */
+ if((font = fs->font) == (XFontStruct *) NULL){
+
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+ }
+
+ switch(oc->core.orientation) {
+ case XOMOrientation_LTR_TTB:
+ case XOMOrientation_RTL_TTB:
+ XSetFont(dpy, gc, font->fid);
+
+ if (is_xchar2b) {
+ char_len = ptr_len / sizeof(XChar2b);
+ XDrawString16(dpy, d, gc, x, y, (XChar2b *)ptr, char_len);
+ x += XTextWidth16(font, (XChar2b *)ptr, char_len);
+ } else {
+ char_len = ptr_len;
+ XDrawString(dpy, d, gc, x, y, (char *)ptr, char_len);
+ x += XTextWidth(font, (char *)ptr, char_len);
+ }
+ break;
+ case XOMOrientation_TTB_RTL:
+ case XOMOrientation_TTB_LTR:
+ if(fs->font == font) {
+ fd = _XomGetFontDataFromFontSet(fs,
+ ptr,length,&ptr_len,is_xchar2b,VMAP);
+ if(ptr_len <= 0)
+ break;
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+
+ if(is_codemap(oc, fd->font) == False) {
+ fd = _XomGetFontDataFromFontSet(fs,
+ ptr,length,&ptr_len,is_xchar2b,VROTATE);
+ if(ptr_len <= 0)
+ break;
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+ }
+ }
+
+ if(is_xchar2b)
+ char_len = ptr_len / sizeof(XChar2b);
+ else
+ char_len = ptr_len;
+ XSetFont(dpy, gc, font->fid);
+ y = draw_vertical(dpy, d, oc, gc, font, is_xchar2b, x, y,
+ (char *)ptr, char_len);
+ break;
+
+ case XOMOrientation_Context:
+ /* never used? */
+ break;
+ }
+
+ if(char_len <= 0)
+ break;
+
+ length -= char_len;
+ ptr += ptr_len;
+ }
+
+ switch(oc->core.orientation) {
+ case XOMOrientation_LTR_TTB:
+ case XOMOrientation_RTL_TTB:
+ ret = x;
+ break;
+ case XOMOrientation_TTB_RTL:
+ case XOMOrientation_TTB_LTR:
+ ret = y;
+ break;
+ case XOMOrientation_Context:
+ /* not used? */
+ break;
+ }
+ return ret;
+}
+
+/* For VW/UDC */
+
+int
+_XomGenericDrawString(
+ Display *dpy,
+ Drawable d,
+ XOC oc,
+ GC gc,
+ int x, int y,
+ XOMTextType type,
+ XPointer text,
+ int length)
+{
+ XlcConv conv;
+ XFontStruct *font;
+ Bool is_xchar2b;
+/* VW/UDC */
+ XPointer args[3];
+ FontSet fs;
+/* VW/UDC */
+ XChar2b xchar2b_buf[BUFSIZ], *buf;
+ int start_x = x;
+ int start_y = y;
+ int left = 0, buf_len = 0;
+ int next = 0;
+
+ conv = _XomInitConverter(oc, type);
+ if (conv == NULL)
+ return -1;
+
+ args[0] = (XPointer) &font;
+ args[1] = (XPointer) &is_xchar2b;
+ args[2] = (XPointer) &fs;
+
+ while (length > 0) {
+ buf = xchar2b_buf;
+ left = buf_len = BUFSIZ;
+
+ if (_XomConvert(oc, conv, (XPointer *) &text, &length,
+ (XPointer *) &buf, &left, args, 3) < 0)
+ break;
+ buf_len -= left;
+
+/* For VW/UDC */
+ next = DrawStringWithFontSet(dpy, d, oc, fs, gc, x, y,
+ (XPointer)xchar2b_buf, buf_len);
+
+ switch(oc->core.orientation) {
+ case XOMOrientation_LTR_TTB:
+ case XOMOrientation_RTL_TTB:
+ x = next;
+ break;
+ case XOMOrientation_TTB_RTL:
+ case XOMOrientation_TTB_LTR:
+ y = next;
+ break;
+ case XOMOrientation_Context:
+ /* not used */
+ break;
+ }
+/* For VW/UDC */
+ }
+
+ x -= start_x;
+ y -= start_y;
+
+ return x;
+}
+
+int
+_XmbGenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length)
+{
+ return _XomGenericDrawString(dpy, d, oc, gc, x, y, XOMMultiByte,
+ (XPointer) text, length);
+}
+
+int
+_XwcGenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst wchar_t *text, int length)
+{
+ return _XomGenericDrawString(dpy, d, oc, gc, x, y, XOMWideChar,
+ (XPointer) text, length);
+}
+
+int
+_Xutf8GenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length)
+{
+ return _XomGenericDrawString(dpy, d, oc, gc, x, y, XOMUtf8String,
+ (XPointer) text, length);
+}
diff --git a/nx-X11/lib/X11/omTextEsc.c b/nx-X11/lib/X11/omTextEsc.c
new file mode 100644
index 000000000..03b76d9f1
--- /dev/null
+++ b/nx-X11/lib/X11/omTextEsc.c
@@ -0,0 +1,302 @@
+/* $Xorg: omTextEsc.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/omTextEsc.c,v 1.6 2003/04/13 19:22:22 dawes Exp $ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+/* For VW/UDC start */
+
+#define VMAP 0
+#define VROTATE 1
+#define FONTSCOPE 2
+
+static int
+is_rotate(
+ XOC oc,
+ XFontStruct *font)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ VRotate vrotate;
+ int font_set_count;
+ int vrotate_num;
+
+ font_set = gen->font_set;
+ font_set_count = gen->font_set_num;
+ for( ; font_set_count-- ; font_set++) {
+ if((font_set->vrotate_num > 0) && (font_set->vrotate != NULL)) {
+ vrotate = font_set->vrotate;
+ vrotate_num = font_set->vrotate_num;
+ for( ; vrotate_num-- ; vrotate++)
+ if(vrotate->font == font)
+ return True;
+ }
+ }
+ return False;
+}
+
+static int
+is_codemap(
+ XOC oc,
+ XFontStruct *font)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ FontData vmap;
+ int font_set_count;
+ int vmap_num;
+
+ font_set = gen->font_set;
+ font_set_count = gen->font_set_num;
+ for( ; font_set_count-- ; font_set++) {
+ if(font_set->vmap_num > 0) {
+ vmap = font_set->vmap;
+ vmap_num = font_set->vmap_num;
+ for( ; vmap_num-- ; vmap++)
+ if(vmap->font == font)
+ return True;
+ }
+ }
+ return False;
+}
+
+static int
+escapement_vertical(
+ XOC oc,
+ XFontStruct *font,
+ Bool is_xchar2b,
+ XPointer text,
+ int length)
+{
+ XChar2b *buf2b;
+ char *buf;
+ int escapement = 0, i;
+
+ if(is_xchar2b) {
+ for(i = 0, buf2b = (XChar2b *) text ; i < length ; i++, buf2b++) {
+ if(is_rotate(oc, font) == True) {
+ escapement += _XTextHeight16(font, buf2b, 1);
+ } else {
+ escapement += (int) (font->max_bounds.ascent +
+ font->max_bounds.descent);
+ }
+ }
+ } else {
+ for(i = 0, buf = (char *)text ; i < length && *buf ; i++, buf++) {
+ if(is_rotate(oc, font) == True) {
+ escapement += _XTextHeight(font, buf, 1);
+ } else {
+ escapement += (int) (font->max_bounds.ascent +
+ font->max_bounds.descent);
+ }
+ }
+ }
+ return escapement;
+}
+
+
+static int
+TextWidthWithFontSet(
+ FontSet font_set,
+ XOC oc,
+ XPointer text,
+ int length)
+{
+ FontData fd;
+ XFontStruct *font;
+ unsigned char *ptr = (unsigned char *)text;
+ Bool is_xchar2b;
+ int ptr_len = length;
+ int escapement = 0, char_len = 0;
+
+ if(font_set == (FontSet) NULL)
+ return escapement;
+
+ is_xchar2b = font_set->is_xchar2b;
+
+ while(length > 0) {
+ fd = _XomGetFontDataFromFontSet(font_set, ptr, length, &ptr_len,
+ is_xchar2b, FONTSCOPE);
+ if(ptr_len <= 0)
+ break;
+
+ /*
+ * First, see if the "Best Match" font for the FontSet was set.
+ * If it was, use that font. If it was not set, then use the
+ * font defined by font_set->font_data[0] (which is what
+ * _XomGetFontDataFromFontSet() always seems to return for
+ * non-VW text). Note that given the new algorithm in
+ * parse_fontname() and parse_fontdata(), fs->font will
+ * *always* contain good data. We should probably remove
+ * the check for "fd->font", but we won't :-) -- jjw/pma (HP)
+ *
+ * Above comment and way this is done propagated from omText.c
+ * Note that fd->font is junk so using the result of the
+ * above call /needs/ to be ignored.
+ *
+ * Owen Taylor <otaylor@redhat.com> 12 Jul 2000
+ *
+ */
+
+ if(fd == (FontData) NULL ||
+ (font = font_set->font) == (XFontStruct *) NULL) {
+
+ if((font = fd->font) == (XFontStruct *) NULL)
+ break;
+ }
+
+ switch(oc->core.orientation) {
+ case XOMOrientation_LTR_TTB:
+ case XOMOrientation_RTL_TTB:
+ if (is_xchar2b) {
+ char_len = ptr_len / sizeof(XChar2b);
+ escapement += XTextWidth16(font, (XChar2b *)ptr, char_len);
+ } else {
+ char_len = ptr_len;
+ escapement += XTextWidth(font, (char *)ptr, char_len);
+ }
+ break;
+
+ case XOMOrientation_TTB_LTR:
+ case XOMOrientation_TTB_RTL:
+ if(font_set->font == font) {
+ fd = _XomGetFontDataFromFontSet(font_set, ptr, length, &ptr_len,
+ is_xchar2b, VMAP);
+ if(ptr_len <= 0)
+ break;
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+
+ if(is_codemap(oc, fd->font) == False) {
+ fd = _XomGetFontDataFromFontSet(font_set, ptr, length,
+ &ptr_len, is_xchar2b,
+ VROTATE);
+ if(ptr_len <= 0)
+ break;
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+ }
+ }
+
+ if(is_xchar2b)
+ char_len = ptr_len / sizeof(XChar2b);
+ else
+ char_len = ptr_len;
+ escapement += escapement_vertical(oc, font, is_xchar2b,
+ (XPointer) ptr, char_len);
+ break;
+
+ case XOMOrientation_Context:
+ /* not used? */
+ break;
+ }
+
+ if(char_len <= 0)
+ break;
+
+ length -= char_len;
+ ptr += ptr_len;
+ }
+
+ return escapement;
+}
+
+/* For VW/UDC end */
+
+static int
+_XomGenericTextEscapement(
+ XOC oc,
+ XOMTextType type,
+ XPointer text,
+ int length)
+{
+ XlcConv conv;
+ XFontStruct *font;
+ Bool is_xchar2b;
+/* VW/UDC */
+ XPointer args[3];
+ FontSet font_set;
+/* VW/UDC */
+ XChar2b xchar2b_buf[BUFSIZ], *buf;
+ int escapement = 0;
+ int buf_len = 0, left = 0;
+
+ conv = _XomInitConverter(oc, type);
+ if (conv == NULL)
+ return escapement;
+
+ args[0] = (XPointer) &font;
+ args[1] = (XPointer) &is_xchar2b;
+ args[2] = (XPointer) &font_set;
+
+ while (length > 0) {
+ buf = xchar2b_buf;
+ left = buf_len = BUFSIZ;
+
+ if (_XomConvert(oc, conv, (XPointer *) &text, &length,
+ (XPointer *) &buf, &left, args, 3) < 0)
+ break;
+ buf_len -= left;
+
+/* VW/UDC */
+ escapement += TextWidthWithFontSet(font_set, oc,
+ (XPointer) xchar2b_buf, buf_len);
+/* VW/UDC */
+ }
+
+ return escapement;
+}
+
+int
+_XmbGenericTextEscapement(XOC oc, _Xconst char *text, int length)
+{
+ return _XomGenericTextEscapement(oc, XOMMultiByte, (XPointer) text, length);
+}
+
+int
+_XwcGenericTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
+{
+ return _XomGenericTextEscapement(oc, XOMWideChar, (XPointer) text, length);
+}
+
+int
+_Xutf8GenericTextEscapement(XOC oc, _Xconst char *text, int length)
+{
+ return _XomGenericTextEscapement(oc, XOMUtf8String, (XPointer) text,
+ length);
+}
diff --git a/nx-X11/lib/X11/omTextExt.c b/nx-X11/lib/X11/omTextExt.c
new file mode 100644
index 000000000..4117e60f9
--- /dev/null
+++ b/nx-X11/lib/X11/omTextExt.c
@@ -0,0 +1,137 @@
+/* $Xorg: omTextExt.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/omTextExt.c,v 1.5 2003/04/13 19:22:22 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+int
+_XomGenericTextExtents(
+ XOC oc,
+ XOMTextType type,
+ XPointer text,
+ int length,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ XlcConv conv;
+ XFontStruct *font;
+ Bool is_xchar2b;
+ XPointer args[2];
+ XChar2b xchar2b_buf[BUFSIZ], *buf;
+ int direction, logical_ascent, logical_descent, tmp_ascent, tmp_descent;
+ XCharStruct overall, tmp_overall;
+ int buf_len, left;
+ Bool first = True;
+
+ conv = _XomInitConverter(oc, type);
+ if (conv == NULL)
+ return 0;
+
+ bzero((char *) &overall, sizeof(XCharStruct));
+ logical_ascent = logical_descent = 0;
+
+ args[0] = (XPointer) &font;
+ args[1] = (XPointer) &is_xchar2b;
+
+ while (length > 0) {
+ buf = xchar2b_buf;
+ left = buf_len = BUFSIZ;
+
+ if (_XomConvert(oc, conv, (XPointer *) &text, &length,
+ (XPointer *) &buf, &left, args, 2) < 0)
+ break;
+ buf_len -= left;
+
+ if (is_xchar2b)
+ XTextExtents16(font, xchar2b_buf, buf_len, &direction,
+ &tmp_ascent, &tmp_descent, &tmp_overall);
+ else
+ XTextExtents(font, (char *) xchar2b_buf, buf_len, &direction,
+ &tmp_ascent, &tmp_descent, &tmp_overall);
+
+ if (first) { /* initialize overall */
+ overall = tmp_overall;
+ logical_ascent = tmp_ascent;
+ logical_descent = tmp_descent;
+ first = False;
+ } else {
+ overall.lbearing = min(overall.lbearing,
+ overall.width + tmp_overall.lbearing);
+ overall.rbearing = max(overall.rbearing,
+ overall.width + tmp_overall.rbearing);
+ overall.ascent = max(overall.ascent, tmp_overall.ascent);
+ overall.descent = max(overall.descent, tmp_overall.descent);
+ overall.width += tmp_overall.width;
+ logical_ascent = max(logical_ascent, tmp_ascent);
+ logical_descent = max(logical_descent, tmp_descent);
+ }
+ }
+
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(logical_ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = logical_ascent + logical_descent;
+ }
+
+ return overall.width;
+}
+
+int
+_XmbGenericTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ return _XomGenericTextExtents(oc, XOMMultiByte, (XPointer) text, length,
+ overall_ink, overall_logical);
+}
+
+int
+_XwcGenericTextExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ return _XomGenericTextExtents(oc, XOMWideChar, (XPointer) text, length,
+ overall_ink, overall_logical);
+}
+
+int
+_Xutf8GenericTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ return _XomGenericTextExtents(oc, XOMUtf8String, (XPointer) text, length,
+ overall_ink, overall_logical);
+}
diff --git a/nx-X11/lib/X11/omTextPer.c b/nx-X11/lib/X11/omTextPer.c
new file mode 100644
index 000000000..17a186571
--- /dev/null
+++ b/nx-X11/lib/X11/omTextPer.c
@@ -0,0 +1,204 @@
+/* $Xorg: omTextPer.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/* $XFree86: xc/lib/X11/omTextPer.c,v 1.6 2003/04/13 19:22:22 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+static Status
+_XomGenericTextPerCharExtents(
+ XOC oc,
+ XOMTextType type,
+ XPointer text,
+ int length,
+ XRectangle *ink_buf,
+ XRectangle *logical_buf,
+ int buf_size,
+ int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ XlcConv conv;
+ XFontStruct *font;
+ Bool is_xchar2b;
+ XPointer args[2];
+ XChar2b xchar2b_buf[BUFSIZ], *xchar2b_ptr;
+ char *xchar_ptr = NULL;
+ XCharStruct *def, *cs, overall;
+ int buf_len, left, require_num;
+ int logical_ascent, logical_descent;
+ Bool first = True;
+
+ conv = _XomInitConverter(oc, type);
+ if (conv == NULL)
+ return 0;
+
+ bzero((char *) &overall, sizeof(XCharStruct));
+ logical_ascent = logical_descent = require_num = *num_chars = 0;
+
+ args[0] = (XPointer) &font;
+ args[1] = (XPointer) &is_xchar2b;
+
+ while (length > 0) {
+ xchar2b_ptr = xchar2b_buf;
+ left = buf_len = BUFSIZ;
+
+ if (_XomConvert(oc, conv, (XPointer *) &text, &length,
+ (XPointer *) &xchar2b_ptr, &left, args, 2) < 0)
+ break;
+ buf_len -= left;
+
+ if (require_num) {
+ require_num += buf_len;
+ continue;
+ }
+ if (buf_size < buf_len) {
+ require_num = *num_chars + buf_len;
+ continue;
+ }
+ buf_size -= buf_len;
+
+ if (first) {
+ logical_ascent = font->ascent;
+ logical_descent = font->descent;
+ } else {
+ logical_ascent = max(logical_ascent, font->ascent);
+ logical_descent = max(logical_descent, font->descent);
+ }
+
+ if (is_xchar2b) {
+ CI_GET_DEFAULT_INFO_2D(font, def)
+ xchar2b_ptr = xchar2b_buf;
+ } else {
+ CI_GET_DEFAULT_INFO_1D(font, def)
+ xchar_ptr = (char *) xchar2b_buf;
+ }
+
+ while (buf_len-- > 0) {
+ if (is_xchar2b) {
+ CI_GET_CHAR_INFO_2D(font, xchar2b_ptr->byte1,
+ xchar2b_ptr->byte2, def, cs)
+ xchar2b_ptr++;
+ } else {
+ CI_GET_CHAR_INFO_1D(font, *xchar_ptr, def, cs)
+ xchar_ptr++;
+ }
+ if (cs == NULL)
+ continue;
+
+ ink_buf->x = overall.width + cs->lbearing;
+ ink_buf->y = -(cs->ascent);
+ ink_buf->width = cs->rbearing - cs->lbearing;
+ ink_buf->height = cs->ascent + cs->descent;
+ ink_buf++;
+
+ logical_buf->x = overall.width;
+ logical_buf->y = -(font->ascent);
+ logical_buf->width = cs->width;
+ logical_buf->height = font->ascent + font->descent;
+ logical_buf++;
+
+ if (first) {
+ overall = *cs;
+ first = False;
+ } else {
+ overall.ascent = max(overall.ascent, cs->ascent);
+ overall.descent = max(overall.descent, cs->descent);
+ overall.lbearing = min(overall.lbearing,
+ overall.width + cs->lbearing);
+ overall.rbearing = max(overall.rbearing,
+ overall.width + cs->rbearing);
+ overall.width += cs->width;
+ }
+
+ (*num_chars)++;
+ }
+ }
+
+ if (require_num) {
+ *num_chars = require_num;
+ return 0;
+ } else {
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(logical_ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = logical_ascent + logical_descent;
+ }
+ }
+
+ return 1;
+}
+
+Status
+_XmbGenericTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ return _XomGenericTextPerCharExtents(oc, XOMMultiByte, (XPointer) text,
+ length, ink_buf, logical_buf, buf_size,
+ num_chars, overall_ink,
+ overall_logical);
+}
+
+Status
+_XwcGenericTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ return _XomGenericTextPerCharExtents(oc, XOMWideChar, (XPointer) text,
+ length, ink_buf, logical_buf, buf_size,
+ num_chars, overall_ink,
+ overall_logical);
+}
+
+Status
+_Xutf8GenericTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ return _XomGenericTextPerCharExtents(oc, XOMUtf8String, (XPointer) text,
+ length, ink_buf, logical_buf, buf_size,
+ num_chars, overall_ink,
+ overall_logical);
+}
diff --git a/nx-X11/lib/X11/omXChar.c b/nx-X11/lib/X11/omXChar.c
new file mode 100644
index 000000000..4afafd40f
--- /dev/null
+++ b/nx-X11/lib/X11/omXChar.c
@@ -0,0 +1,479 @@
+/* $Xorg: omXChar.c,v 1.3 2000/08/17 19:45:23 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+/*
+ * Modifiers: Jeff Walls, Paul Anderson (HEWLETT-PACKARD)
+ */
+/* $XFree86: xc/lib/X11/omXChar.c,v 1.6tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcPublic.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+/* for VW/UDC start */
+static Bool
+ismatch_scopes(
+ FontData fontdata,
+ unsigned long *value,
+ Bool is_shift)
+{
+ register int scopes_num = fontdata->scopes_num;
+ FontScope scopes = fontdata->scopes;
+ if (!scopes_num)
+ return False;
+
+ if(fontdata->font == NULL)
+ return False;
+
+ for(;scopes_num--;scopes++)
+ if ((scopes->start <= (*value & 0x7f7f)) &&
+ ((scopes->end) >= (*value & 0x7f7f))){
+ if(is_shift == True) {
+ if(scopes->shift){
+ if(scopes->shift_direction == '+'){
+ *value += scopes->shift ;
+ } else if( scopes->shift_direction == '-'){
+ *value -= scopes->shift ;
+ }
+ }
+ }
+ return True;
+ }
+
+ return False;
+}
+
+static int
+check_vertical_fonttype(
+ char *name)
+{
+ char *ptr;
+ int type = 0;
+
+ if(name == (char *)NULL || (int) strlen(name) <= 0)
+ return False;
+
+ /* Obtains the pointer of CHARSET_ENCODING_FIELD. */
+ if((ptr = strchr(name, '-')) == (char *) NULL)
+ return False;
+ ptr++;
+
+ /* Obtains the pointer of vertical_map font type. */
+ if((ptr = strchr(ptr, '.')) == (char *) NULL)
+ return False;
+ ptr++;
+
+ switch(*ptr) {
+ case '1':
+ type = 1; break;
+ case '2':
+ type = 2; break;
+ case '3':
+ type = 3; break;
+ }
+ return type;
+}
+
+/*
+*/
+#define VMAP 0
+#define VROTATE 1
+#define FONTSCOPE 2
+
+FontData
+_XomGetFontDataFromFontSet(
+ FontSet fs,
+ unsigned char *str,
+ int len,
+ int *len_ret,
+ int is2b,
+ int type) /* VMAP , VROTATE , else */
+{
+ unsigned long value;
+ int num,i,hit,csize;
+ FontData fontdata;
+ unsigned char *c;
+ int vfont_type;
+
+ c = str;
+ hit = -1;
+ if(type == VMAP){
+ fontdata = fs->vmap;
+ num = fs->vmap_num;
+ } else if(type == VROTATE){
+ fontdata = (FontData)fs->vrotate;
+ num = fs->vrotate_num;
+ } else {
+ if(fs->font_data_count <= 0 || fs->font_data == (FontData)NULL) {
+ fontdata = fs->substitute;
+ num = fs->substitute_num;
+ }else {
+ fontdata = fs->font_data;
+ num = fs->font_data_count;
+ }
+ /* CDExc20229 fix */
+ if(fontdata == NULL || num == 0){
+ return(NULL);
+ }
+ }
+
+
+ if(is2b){
+ csize = 2;
+ } else {
+ csize = 1;
+ }
+
+ for(;len;len--){
+ if(is2b){
+ value = (((unsigned long)*c) << 8)|(unsigned long)*(c + 1);
+ } else {
+ value = (unsigned long)*c;
+ }
+
+ /* ### NOTE: This routine DOES NOT WORK!
+ * ### We can work around the problem in the calling routine,
+ * ### but we really need to understand this better. As it
+ * ### stands, the algorithm ALWAYS returns "fontdata[0]"
+ * ### for non-VW text! This is clearly wrong. In fact,
+ * ### given the new parse_font[name|data]() algorithms,
+ * ### we may not even need this routine to do anything
+ * ### for non-VW text (since font_set->font always contains
+ * ### the best font for this fontset). -- jjw/pma (HP)
+ */
+ for (i=0;i<num;i++) {
+ if(type == VROTATE) {
+ if(fontdata[i].font) {
+ /* If the num_cr equal zero, all character is rotated. */
+ if(fontdata[i].scopes_num == 0) {
+ break;
+ } else {
+ /* The vertical rotate glyph is not have code shift. */
+ if (ismatch_scopes(&(fontdata[i]),&value,False)) {
+ break;
+ }
+ }
+ }
+ } else if(type == VMAP) {
+ if(fontdata[i].font) {
+ vfont_type = check_vertical_fonttype(fontdata[i].name);
+ if(vfont_type == 0 || vfont_type == 1) {
+ break;
+ } else if(vfont_type == 2 || vfont_type == 3) {
+ if(fontdata[i].scopes_num <= 0)
+ break;
+
+ if (ismatch_scopes(&(fontdata[i]),&value,True)) {
+ break;
+ }
+ }
+ }
+ } else { /* FONTSCOPE */
+ if(fontdata[i].font) {
+ if(fontdata[i].scopes_num <= 0)
+ break;
+ if (ismatch_scopes(&(fontdata[i]),&value,True)){
+ break;
+ }
+ }
+ }
+ }
+ if((hit != -1) && (i != hit)){
+ break;
+ }
+ if(i == num){
+ if( type == VROTATE || type == VMAP){
+ /* Change 1996.01.23 start */
+ if(fs->font_data_count <= 0 ||
+ fs->font_data == (FontData)NULL)
+ fontdata = fs->substitute;
+ else
+ fontdata = fs->font_data;
+ /* Change 1996.01.23 end */
+ }
+ hit = 0;
+ c += csize;
+ break;
+ }
+ if( hit == -1 ) hit = i;
+ if(is2b){
+ *c = (unsigned char)(value >> 8);
+ *(c + 1) = (unsigned char)(value);
+ } else {
+ *c = (unsigned char)value;
+ }
+ c += csize;
+ }
+ *len_ret = (c - str);
+ return(&(fontdata[hit]));
+}
+/* for VW/UDC end */
+
+static FontSet
+_XomGetFontSetFromCharSet(
+ XOC oc,
+ XlcCharSet charset)
+{
+ register FontSet font_set = XOC_GENERIC(oc)->font_set;
+ register int num = XOC_GENERIC(oc)->font_set_num;
+ XlcCharSet *charset_list;
+ int charset_count;
+
+ for ( ; num-- > 0; font_set++) {
+ charset_count = font_set->charset_count;
+ charset_list = font_set->charset_list;
+ for ( ; charset_count-- > 0; charset_list++)
+ if (*charset_list == charset)
+ return font_set;
+ }
+
+ return (FontSet) NULL;
+}
+
+#ifdef MUSTCOPY
+static void
+cs_to_xchar2b(
+ register char *from,
+ register XChar2b *to,
+ register length)
+{
+ while (length-- > 0) {
+ to->byte1 = *from++;
+ to->byte2 = *from++;
+ to++;
+ }
+}
+
+static void
+cs_to_xchar2b_gl(
+ register char *from,
+ register XChar2b *to,
+ register length)
+{
+ while (length-- > 0) {
+ to->byte1 = *from++ & 0x7f;
+ to->byte2 = *from++ & 0x7f;
+ to++;
+ }
+}
+
+static void
+cs_to_xchar2b_gr(
+ register char *from,
+ register XChar2b *to,
+ register length)
+{
+ while (length-- > 0) {
+ to->byte1 = *from++ | 0x80;
+ to->byte2 = *from++ | 0x80;
+ to++;
+ }
+}
+#endif
+
+static void
+shift_to_gl(
+ register char *text,
+ register int length)
+{
+ while (length-- > 0)
+ *text++ &= 0x7f;
+}
+
+static void
+shift_to_gr(
+ register char *text,
+ register int length)
+{
+ while (length-- > 0)
+ *text++ |= 0x80;
+}
+
+static Bool
+load_font(
+ XOC oc,
+ FontSet font_set)
+{
+ font_set->font = XLoadQueryFont(oc->core.om->core.display,
+ oc->core.font_info.font_name_list[font_set->id]);
+ if (font_set->font == NULL)
+ return False;
+
+ oc->core.font_info.font_struct_list[font_set->id] = font_set->font;
+ XFreeFontInfo(NULL, font_set->info, 1);
+ font_set->info = NULL;
+
+ if (font_set->font->min_byte1 || font_set->font->max_byte1)
+ font_set->is_xchar2b = True;
+ else
+ font_set->is_xchar2b = False;
+
+ return True;
+}
+
+int
+_XomConvert(
+ XOC oc,
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XPointer cs, lc_args[1];
+ XlcCharSet charset;
+ int length, cs_left, ret;
+ FontSet font_set;
+#ifdef MUSTCOPY
+ XChar2b *xchar2b;
+ char *buf, buf_local[BUFSIZ];
+#endif
+
+ cs = *to;
+ cs_left = *to_left;
+ lc_args[0] = (XPointer) &charset;
+
+ ret = _XlcConvert(conv, from, from_left, &cs, &cs_left, lc_args, 1);
+ if (ret < 0)
+ return -1;
+
+ font_set = _XomGetFontSetFromCharSet(oc, charset);
+ if (font_set == NULL)
+ return -1;
+
+ if (font_set->font == NULL && load_font(oc, font_set) == False)
+ return -1;
+
+ length = *to_left - cs_left;
+
+#ifdef MUSTCOPY
+ if (font_set->is_xchar2b) {
+ buf = (length > BUFSIZ) ? Xmalloc(length) : buf_local;
+ if (buf == NULL)
+ return -1;
+ memcpy(buf, (char *) *to, length);
+
+ xchar2b = (XChar2b *) *to;
+ length >>= 1;
+
+ if (font_set->side == charset->side)
+ cs_to_xchar2b(buf, xchar2b, length);
+ else if (font_set->side == XlcGL)
+ cs_to_xchar2b_gl(buf, xchar2b, length);
+ else if (font_set->side == XlcGR)
+ cs_to_xchar2b_gr(buf, xchar2b, length);
+ else
+ cs_to_xchar2b(buf, xchar2b, length);
+
+ if (buf != buf_local)
+ Xfree(buf);
+
+ *to = (XPointer) (xchar2b + length);
+ *to_left -= length;
+ } else
+#endif
+ {
+ if (font_set->side != charset->side) {
+ if (font_set->side == XlcGL)
+ shift_to_gl(*to, length);
+ else if (font_set->side == XlcGR)
+ shift_to_gr(*to, length);
+ }
+
+ if (font_set->is_xchar2b)
+ length >>= 1;
+ *to = cs;
+ *to_left -= length;
+ }
+
+ *((XFontStruct **) args[0]) = font_set->font;
+ *((Bool *) args[1]) = font_set->is_xchar2b;
+ if(num_args >= 3){
+ *((FontSet *) args[2]) = font_set;
+ }
+
+ return ret;
+}
+
+XlcConv
+_XomInitConverter(
+ XOC oc,
+ XOMTextType type)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ XlcConv *convp;
+ char *conv_type;
+ XlcConv conv;
+ XLCd lcd;
+
+ switch (type) {
+ case XOMWideChar:
+ convp = &gen->wcs_to_cs;
+ conv_type = XlcNWideChar;
+ break;
+ case XOMMultiByte:
+ convp = &gen->mbs_to_cs;
+ conv_type = XlcNMultiByte;
+ break;
+ case XOMUtf8String:
+ convp = &gen->utf8_to_cs;
+ conv_type = XlcNUtf8String;
+ break;
+ default:
+ return (XlcConv) NULL;
+ }
+
+ conv = *convp;
+ if (conv) {
+ _XlcResetConverter(conv);
+ return conv;
+ }
+
+ lcd = oc->core.om->core.lcd;
+
+ conv = _XlcOpenConverter(lcd, conv_type, lcd, XlcNFontCharSet);
+ if (conv == (XlcConv) NULL) {
+ conv = _XlcOpenConverter(lcd, conv_type, lcd, XlcNCharSet);
+ if (conv == (XlcConv) NULL)
+ return (XlcConv) NULL;
+ }
+
+ *convp = conv;
+ return conv;
+}
diff --git a/nx-X11/lib/X11/os2Stubs.c b/nx-X11/lib/X11/os2Stubs.c
new file mode 100644
index 000000000..9d109025c
--- /dev/null
+++ b/nx-X11/lib/X11/os2Stubs.c
@@ -0,0 +1,429 @@
+/*
+ * (c) Copyright 1996 by Sebastien Marineau and Holger Veit
+ * <marineau@genie.uottawa.ca>
+ * <Holger.Veit@gmd.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * HOLGER VEIT 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 Sebastien Marineau or Holger Veit
+ * shall not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from Holger Veit or
+ * Sebastien Marineau.
+ *
+ */
+
+/* $XFree86: xc/lib/X11/os2Stubs.c,v 3.0 1996/05/13 06:37:17 dawes Exp $ */
+
+/* A few OS/2 functions needed in the X11 lib. Mainly, the file path redirection
+ * functions and the "optimized" select() for the clients */
+
+#define I_NEED_OS2_H
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xpoll.h>
+#include <stdio.h>
+#include <sys/errno.h>
+#define INCL_DOSSEMAPHORES
+#define INCL_DOSNPIPES
+#define INCL_DOSMISC
+#define INCL_DOSMODULEMGR
+#undef BOOL
+#undef BYTE
+#include <os2.h>
+#include <sys/select.h>
+#include <sys/time.h>
+
+char *__XOS2RedirRoot(char *fname)
+{
+ /* This adds a further redirection by allowing the ProjectRoot
+ * to be prepended by the content of the envvar X11ROOT.
+ * This is for the purpose to move the whole X11 stuff to a different
+ * disk drive.
+ * The feature was added despite various environment variables
+ * because not all file opens respect them.
+ */
+ static char redirname[300]; /* enough for long filenames */
+ char *root;
+
+ /* if name does not start with /, assume it is not root-based */
+ if (fname==0 || !(fname[0]=='/' || fname[0]=='\\'))
+ return fname;
+
+ root = (char*)getenv("X11ROOT");
+ if (root==0 ||
+ (fname[1]==':' && isalpha(fname[0])) ||
+ (strlen(fname)+strlen(root)+2) > 300)
+ return fname;
+ sprintf(redirname,"%s%s",root,fname);
+ return redirname;
+}
+
+char *__XOS2RedirRoot1(char *format, char *arg1, char *arg2, char *arg3)
+{
+ /* this first constructs a name from a format and up to three
+ * components, then adds a path
+ */
+ char buf[300];
+ sprintf(buf,format,arg1,arg2,arg3);
+ return __XOS2RedirRoot(buf);
+}
+
+/* This below implements select() for the calls in this file. It has been */
+/* somewhat optimized for improved performance, but assumes a few */
+/* things so it cannot be used as a general select. If both pipes and */
+/* sockets are present, this may call the emx select */
+
+
+HEV hPipeSem;
+HMODULE hmod_so32dll;
+static int (*os2_tcp_select)(int*,int,int,int,long);
+ULONG os2_get_sys_millis();
+extern int _files[];
+
+#define MAX_TCP 256
+/* These lifted from sys/emx.h. Change if that changes there! */
+#define F_SOCKET 0x10000000
+#define F_PIPE 0x20000000
+
+struct select_data
+{
+ fd_set read_copy;
+ fd_set write_copy;
+ BOOL have_read;
+ BOOL have_write;
+ int tcp_select_mask[MAX_TCP];
+ int tcp_emx_handles[MAX_TCP];
+ int tcp_select_copy[MAX_TCP];
+ int socket_nread;
+ int socket_nwrite;
+ int socket_ntotal;
+ int pipe_ntotal;
+ int pipe_have_write;
+ int max_fds;
+};
+
+int os2ClientSelect(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+{
+static BOOL FirstTime=TRUE;
+static haveTCPIP=TRUE;
+ULONG timeout_ms;
+ULONG postCount, start_millis,now_millis;
+char faildata[16];
+struct select_data sd;
+BOOL any_ready;
+int np,ns, i,ready_handles,n;
+APIRET rc;
+
+sd.have_read=FALSE; sd.have_write=FALSE;
+sd.socket_nread=0; sd.socket_nwrite=0; sd.socket_ntotal=0;
+sd.max_fds=31; ready_handles=0; any_ready=FALSE;
+sd.pipe_ntotal=0; sd.pipe_have_write=FALSE;
+
+if(FirstTime){
+ /* First load the so32dll.dll module and get a pointer to the SELECT fn */
+
+ if((rc=DosLoadModule(faildata,sizeof(faildata),"SO32DLL",&hmod_so32dll))!=0){
+ fprintf(stderr, "Could not load module so32dll.dll, rc = %d. Error note %s\n",rc,faildata);
+ haveTCPIP=FALSE;
+ }
+ if((rc = DosQueryProcAddr(hmod_so32dll, 0, "SELECT", (PPFN)&os2_tcp_select))!=0){
+ fprintf(stderr, "Could not query address of SELECT, rc = %d.\n",rc);
+ haveTCPIP=FALSE;
+ }
+ /* Call these a first time to set the semaphore */
+ rc = DosCreateEventSem(NULL, &hPipeSem, DC_SEM_SHARED, FALSE);
+ if(rc) {
+ fprintf(stderr, "Could not create event semaphore, rc=%d\n",rc);
+ return(-1);
+ }
+ rc = DosResetEventSem(hPipeSem, &postCount);
+ FirstTime = FALSE;
+}
+
+/* Set up the time delay structs */
+
+ if(timeout!=NULL) {
+ timeout_ms=timeout->tv_sec*1000+timeout->tv_usec/1000;
+ }
+ else { timeout_ms=1000000; } /* This should be large enough... */
+ if(timeout_ms>0) start_millis=os2_get_sys_millis();
+
+/* Copy the masks */
+ {FD_ZERO(&sd.read_copy);}
+ {FD_ZERO(&sd.write_copy);}
+ if(readfds!=NULL){ XFD_COPYSET(readfds,&sd.read_copy); sd.have_read=TRUE;}
+ if(writefds!=NULL) {XFD_COPYSET(writefds,&sd.write_copy);sd.have_write=TRUE;}
+
+/* And zero the original masks */
+ if(sd.have_read){ FD_ZERO(readfds);}
+ if(sd.have_write) {FD_ZERO(writefds);}
+ if(exceptfds != NULL) {FD_ZERO(exceptfds);}
+
+/* Now we parse the fd_sets passed to select and separate pipe/sockets */
+ n = os2_parse_select(&sd,nfds);
+ if(n == -1) {
+ errno = EBADF;
+ return (-1);
+ }
+
+/* Now we have three cases: either we have sockets, pipes, or both */
+/* We handle all three cases differently to optimize things */
+
+/* Case 1: only pipes! */
+ if((sd.pipe_ntotal >0) && (!sd.socket_ntotal)){
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if(np > 0){
+ return (np);
+ }
+ else if (np == -1) { return(-1); }
+ while(!any_ready){
+ rc = DosWaitEventSem(hPipeSem, timeout_ms);
+ if(rc == 640) {
+ return(0);
+ }
+ if((rc != 0) && (rc != 95)) {errno= EBADF; return(-1);}
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if (np > 0){
+ return(np);
+ }
+ else if (np < 0){ return(-1); }
+ }
+ }
+
+/* Case 2: only sockets. Just let the os/2 tcp select do the work */
+ if((sd.socket_ntotal > 0) && (!sd.pipe_ntotal)){
+ ns = os2_check_sockets(&sd, readfds, writefds, timeout_ms);
+ return (ns);
+ }
+
+/* Case 3: combination of both */
+ if((sd.socket_ntotal > 0) && (sd.pipe_ntotal)){
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if(np > 0){
+ any_ready=TRUE;
+ ready_handles += np;
+ }
+ else if (np == -1) { return(-1); }
+
+ ns = os2_check_sockets(&sd,readfds,writefds, 0);
+ if(ns>0){
+ ready_handles+=ns;
+ any_ready = TRUE;
+ }
+ else if (ns == -1) {return(-1);}
+
+ while (!any_ready && timeout_ms){
+
+ rc = DosWaitEventSem(hPipeSem, 10L);
+ if(rc == 0){
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if(np > 0){
+ ready_handles+=np;
+ any_ready = TRUE;
+ }
+ else if (np == -1) {
+ return(-1); }
+ }
+
+ ns = os2_check_sockets(&sd,readfds,writefds,exceptfds, 0);
+ if(ns>0){
+ ready_handles+=ns;
+ any_ready = TRUE;
+ }
+ else if (ns == -1) {return(-1);}
+
+ if (i%8 == 0) {
+ now_millis = os2_get_sys_millis();
+ if((now_millis-start_millis) > timeout_ms) timeout_ms = 0;
+ }
+ i++;
+ }
+ }
+
+return(ready_handles);
+}
+
+
+ULONG os2_get_sys_millis()
+{
+ APIRET rc;
+ ULONG milli;
+
+ rc = DosQuerySysInfo(14, 14, &milli, sizeof(milli));
+ if(rc) {
+ fprintf(stderr,"Bad return code querying the millisecond counter! rc=%d\n",rc);
+ return(0);
+ }
+ return(milli);
+}
+
+int os2_parse_select(sd,nfds)
+struct select_data *sd;
+int nfds;
+{
+ int i;
+ APIRET rc;
+/* First we determine up to which descriptor we need to check. */
+/* No need to check up to 256 if we don't have to (and usually we dont...)*/
+/* Note: stuff here is hardcoded for fd_sets which are int[8] as in EMX!!! */
+
+ if(nfds > sd->max_fds){
+ for(i=0;i<((FD_SETSIZE+31)/32);i++){
+ if(sd->read_copy.fds_bits[i] ||
+ sd->write_copy.fds_bits[i])
+ sd->max_fds=(i*32) +32;
+ }
+ }
+ else { sd->max_fds = nfds; }
+/* Check if result is greater than specified in select() call */
+ if(sd->max_fds > nfds) sd->max_fds = nfds;
+
+ if (sd->have_read)
+ {
+ for (i = 0; i < sd->max_fds; ++i) {
+ if (FD_ISSET (i, &sd->read_copy)){
+ if(_files[i] & F_SOCKET)
+ {
+ sd->tcp_select_mask[sd->socket_ntotal]=_getsockhandle(i);
+ sd->tcp_emx_handles[sd->socket_ntotal]=i;
+ sd->socket_ntotal++; sd->socket_nread++;
+ }
+ else if (_files[i] & F_PIPE)
+ {
+ sd -> pipe_ntotal++;
+ rc = DosSetNPipeSem((HPIPE)i, (HSEM) hPipeSem, i);
+ if(rc) { fprintf(stderr,"Error SETNPIPE rc = %d\n",rc); return -1;}
+ }
+ }
+ }
+ }
+
+ if (sd->have_write)
+ {
+ for (i = 0; i < sd->max_fds; ++i) {
+ if (FD_ISSET (i, &sd->write_copy)){
+ if(_files[i] & F_SOCKET)
+ {
+ sd->tcp_select_mask[sd->socket_ntotal]=_getsockhandle(i);
+ sd->tcp_emx_handles[sd->socket_ntotal]=i;
+ sd->socket_ntotal++; sd->socket_nwrite++;
+ }
+ else if (_files[i] & F_PIPE)
+ {
+ sd -> pipe_ntotal++;
+ rc = DosSetNPipeSem((HPIPE)i, (HSEM) hPipeSem, i);
+ if(rc) { fprintf(stderr,"Error SETNPIPE rc = %d\n",rc); return -1;}
+ sd -> pipe_have_write=TRUE;
+ }
+ }
+ }
+ }
+
+
+return(sd->socket_ntotal);
+}
+
+
+int os2_check_sockets(sd,readfds,writefds)
+struct select_data *sd;
+fd_set *readfds,*writefds;
+{
+ int e,i;
+ int j,n;
+ memcpy(sd->tcp_select_copy,sd->tcp_select_mask,
+ sd->socket_ntotal*sizeof(int));
+
+ e = os2_tcp_select(sd->tcp_select_copy,sd->socket_nread,
+ sd->socket_nwrite, 0, 0);
+
+ if(e == 0) return(e);
+/* We have something ready? */
+ if(e>0){
+ j = 0; n = 0;
+ for (i = 0; i < sd->socket_nread; ++i, ++j)
+ if (sd->tcp_select_copy[j] != -1)
+ {
+ FD_SET (sd->tcp_emx_handles[j], readfds);
+ n ++;
+ }
+ for (i = 0; i < sd->socket_nwrite; ++i, ++j)
+ if (sd->tcp_select_copy[j] != -1)
+ {
+ FD_SET (sd->tcp_emx_handles[j], writefds);
+ n ++;
+ }
+ errno = 0;
+
+ return n;
+ }
+ if(e<0){
+ /*Error -- TODO */
+ fprintf(stderr,"Error in server select! e=%d\n",e);
+ errno = EBADF;
+ return (-1);
+ }
+ }
+
+/* Check to see if anything is ready on pipes */
+
+int os2_check_pipes(sd,readfds,writefds)
+struct select_data *sd;
+fd_set *readfds,*writefds;
+{
+int i,e;
+ULONG ulPostCount;
+PIPESEMSTATE pipeSemState[128];
+APIRET rc;
+ e = 0;
+ rc = DosResetEventSem(hPipeSem,&ulPostCount);
+ rc = DosQueryNPipeSemState((HSEM) hPipeSem, (PPIPESEMSTATE)&pipeSemState,
+ sizeof(pipeSemState));
+ if(rc) fprintf(stderr,"SELECT: rc from QueryNPipeSem: %d\n",rc);
+ i=0;
+ while (pipeSemState[i].fStatus != 0) {
+ /*fprintf(stderr,"SELECT: sem entry, stat=%d, flag=%d, key=%d,avail=%d\n",
+ pipeSemState[i].fStatus,pipeSemState[i].fFlag,pipeSemState[i].usKey,
+ pipeSemState[i].usAvail); */
+ if((pipeSemState[i].fStatus == 1) &&
+ (FD_ISSET(pipeSemState[i].usKey,&sd->read_copy))){
+ FD_SET(pipeSemState[i].usKey,readfds);
+ e++;
+ }
+ else if((pipeSemState[i].fStatus == 2) &&
+ (FD_ISSET(pipeSemState[i].usKey,&sd->write_copy))){
+ FD_SET(pipeSemState[i].usKey,writefds);
+ e++;
+ }
+ else if( (pipeSemState[i].fStatus == 3) &&
+ ( (FD_ISSET(pipeSemState[i].usKey,&sd->read_copy)) ||
+ (FD_ISSET(pipeSemState[i].usKey,&sd->write_copy)) )){
+ errno = EBADF;
+ return (-1);
+ }
+ i++;
+ } /* endwhile */
+ /*fprintf(stderr,"Done listing pipe sem entries, total %d entries, total ready entries %d\n",i,e);*/
+errno = 0;
+return(e);
+}
+
+
+
diff --git a/nx-X11/lib/X11/poly.h b/nx-X11/lib/X11/poly.h
new file mode 100644
index 000000000..0d82443c9
--- /dev/null
+++ b/nx-X11/lib/X11/poly.h
@@ -0,0 +1,295 @@
+/* $Xorg: poly.h,v 1.4 2001/02/09 02:03:40 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.
+
+************************************************************************/
+
+/*
+ * This file contains a few macros to help track
+ * the edge of a filled object. The object is assumed
+ * to be filled in scanline order, and thus the
+ * algorithm used is an extension of Bresenham's line
+ * drawing algorithm which assumes that y is always the
+ * major axis.
+ * Since these pieces of code are the same for any filled shape,
+ * it is more convenient to gather the library in one
+ * place, but since these pieces of code are also in
+ * the inner loops of output primitives, procedure call
+ * overhead is out of the question.
+ * See the author for a derivation if needed.
+ */
+
+
+/*
+ * In scan converting polygons, we want to choose those pixels
+ * which are inside the polygon. Thus, we add .5 to the starting
+ * x coordinate for both left and right edges. Now we choose the
+ * first pixel which is inside the pgon for the left edge and the
+ * first pixel which is outside the pgon for the right edge.
+ * Draw the left pixel, but not the right.
+ *
+ * How to add .5 to the starting x coordinate:
+ * If the edge is moving to the right, then subtract dy from the
+ * error term from the general form of the algorithm.
+ * If the edge is moving to the left, then add dy to the error term.
+ *
+ * The reason for the difference between edges moving to the left
+ * and edges moving to the right is simple: If an edge is moving
+ * to the right, then we want the algorithm to flip immediately.
+ * If it is moving to the left, then we don't want it to flip until
+ * we traverse an entire pixel.
+ */
+#define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2) { \
+ int dx; /* local storage */ \
+\
+ /* \
+ * if the edge is horizontal, then it is ignored \
+ * and assumed not to be processed. Otherwise, do this stuff. \
+ */ \
+ if ((dy) != 0) { \
+ xStart = (x1); \
+ dx = (x2) - xStart; \
+ if (dx < 0) { \
+ m = dx / (dy); \
+ m1 = m - 1; \
+ incr1 = -2 * dx + 2 * (dy) * m1; \
+ incr2 = -2 * dx + 2 * (dy) * m; \
+ d = 2 * m * (dy) - 2 * dx - 2 * (dy); \
+ } else { \
+ m = dx / (dy); \
+ m1 = m + 1; \
+ incr1 = 2 * dx - 2 * (dy) * m1; \
+ incr2 = 2 * dx - 2 * (dy) * m; \
+ d = -2 * m * (dy) + 2 * dx; \
+ } \
+ } \
+}
+
+#define BRESINCRPGON(d, minval, m, m1, incr1, incr2) { \
+ if (m1 > 0) { \
+ if (d > 0) { \
+ minval += m1; \
+ d += incr1; \
+ } \
+ else { \
+ minval += m; \
+ d += incr2; \
+ } \
+ } else {\
+ if (d >= 0) { \
+ minval += m1; \
+ d += incr1; \
+ } \
+ else { \
+ minval += m; \
+ d += incr2; \
+ } \
+ } \
+}
+
+
+/*
+ * This structure contains all of the information needed
+ * to run the bresenham algorithm.
+ * The variables may be hardcoded into the declarations
+ * instead of using this structure to make use of
+ * register declarations.
+ */
+typedef struct {
+ int minor_axis; /* minor axis */
+ int d; /* decision variable */
+ int m, m1; /* slope and slope+1 */
+ int incr1, incr2; /* error increments */
+} BRESINFO;
+
+
+#define BRESINITPGONSTRUCT(dmaj, min1, min2, bres) \
+ BRESINITPGON(dmaj, min1, min2, bres.minor_axis, bres.d, \
+ bres.m, bres.m1, bres.incr1, bres.incr2)
+
+#define BRESINCRPGONSTRUCT(bres) \
+ BRESINCRPGON(bres.d, bres.minor_axis, bres.m, bres.m1, bres.incr1, bres.incr2)
+
+
+
+/*
+ * These are the data structures needed to scan
+ * convert regions. Two different scan conversion
+ * methods are available -- the even-odd method, and
+ * the winding number method.
+ * The even-odd rule states that a point is inside
+ * the polygon if a ray drawn from that point in any
+ * direction will pass through an odd number of
+ * path segments.
+ * By the winding number rule, a point is decided
+ * to be inside the polygon if a ray drawn from that
+ * point in any direction passes through a different
+ * number of clockwise and counter-clockwise path
+ * segments.
+ *
+ * These data structures are adapted somewhat from
+ * the algorithm in (Foley/Van Dam) for scan converting
+ * polygons.
+ * The basic algorithm is to start at the top (smallest y)
+ * of the polygon, stepping down to the bottom of
+ * the polygon by incrementing the y coordinate. We
+ * keep a list of edges which the current scanline crosses,
+ * sorted by x. This list is called the Active Edge Table (AET)
+ * As we change the y-coordinate, we update each entry in
+ * in the active edge table to reflect the edges new xcoord.
+ * This list must be sorted at each scanline in case
+ * two edges intersect.
+ * We also keep a data structure known as the Edge Table (ET),
+ * which keeps track of all the edges which the current
+ * scanline has not yet reached. The ET is basically a
+ * list of ScanLineList structures containing a list of
+ * edges which are entered at a given scanline. There is one
+ * ScanLineList per scanline at which an edge is entered.
+ * When we enter a new edge, we move it from the ET to the AET.
+ *
+ * From the AET, we can implement the even-odd rule as in
+ * (Foley/Van Dam).
+ * The winding number rule is a little trickier. We also
+ * keep the EdgeTableEntries in the AET linked by the
+ * nextWETE (winding EdgeTableEntry) link. This allows
+ * the edges to be linked just as before for updating
+ * purposes, but only uses the edges linked by the nextWETE
+ * link as edges representing spans of the polygon to
+ * drawn (as with the even-odd rule).
+ */
+
+/*
+ * for the winding number rule
+ */
+#define CLOCKWISE 1
+#define COUNTERCLOCKWISE -1
+
+typedef struct _EdgeTableEntry {
+ int ymax; /* ycoord at which we exit this edge. */
+ BRESINFO bres; /* Bresenham info to run the edge */
+ struct _EdgeTableEntry *next; /* next in the list */
+ struct _EdgeTableEntry *back; /* for insertion sort */
+ struct _EdgeTableEntry *nextWETE; /* for winding num rule */
+ int ClockWise; /* flag for winding number rule */
+} EdgeTableEntry;
+
+
+typedef struct _ScanLineList{
+ int scanline; /* the scanline represented */
+ EdgeTableEntry *edgelist; /* header node */
+ struct _ScanLineList *next; /* next in the list */
+} ScanLineList;
+
+
+typedef struct {
+ int ymax; /* ymax for the polygon */
+ int ymin; /* ymin for the polygon */
+ ScanLineList scanlines; /* header node */
+} EdgeTable;
+
+
+/*
+ * Here is a struct to help with storage allocation
+ * so we can allocate a big chunk at a time, and then take
+ * pieces from this heap when we need to.
+ */
+#define SLLSPERBLOCK 25
+
+typedef struct _ScanLineListBlock {
+ ScanLineList SLLs[SLLSPERBLOCK];
+ struct _ScanLineListBlock *next;
+} ScanLineListBlock;
+
+
+
+/*
+ *
+ * a few macros for the inner loops of the fill code where
+ * performance considerations don't allow a procedure call.
+ *
+ * Evaluate the given edge at the given scanline.
+ * If the edge has expired, then we leave it and fix up
+ * the active edge table; otherwise, we increment the
+ * x value to be ready for the next scanline.
+ * The winding number rule is in effect, so we must notify
+ * the caller when the edge has been removed so he
+ * can reorder the Winding Active Edge Table.
+ */
+#define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) { \
+ if (pAET->ymax == y) { /* leaving this edge */ \
+ pPrevAET->next = pAET->next; \
+ pAET = pPrevAET->next; \
+ fixWAET = 1; \
+ if (pAET) \
+ pAET->back = pPrevAET; \
+ } \
+ else { \
+ BRESINCRPGONSTRUCT(pAET->bres); \
+ pPrevAET = pAET; \
+ pAET = pAET->next; \
+ } \
+}
+
+
+/*
+ * Evaluate the given edge at the given scanline.
+ * If the edge has expired, then we leave it and fix up
+ * the active edge table; otherwise, we increment the
+ * x value to be ready for the next scanline.
+ * The even-odd rule is in effect.
+ */
+#define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \
+ if (pAET->ymax == y) { /* leaving this edge */ \
+ pPrevAET->next = pAET->next; \
+ pAET = pPrevAET->next; \
+ if (pAET) \
+ pAET->back = pPrevAET; \
+ } \
+ else { \
+ BRESINCRPGONSTRUCT(pAET->bres); \
+ pPrevAET = pAET; \
+ pAET = pAET->next; \
+ } \
+}
diff --git a/nx-X11/lib/X11/udcInf.c b/nx-X11/lib/X11/udcInf.c
new file mode 100644
index 000000000..43b1cb024
--- /dev/null
+++ b/nx-X11/lib/X11/udcInf.c
@@ -0,0 +1,718 @@
+/* $Xorg: udcInf.c,v 1.7 2001/02/09 02:03:40 xorgcvs Exp $ */
+/*
+Copyright 1996, 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 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+
+/* $XFree86: xc/lib/X11/udcInf.c,v 1.6 2001/01/17 19:41:57 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <locale.h>
+#include <Xlib.h>
+#include <Xlibint.h>
+#include <Xlcint.h>
+#include <XlcPubI.h>
+#include <XlcGeneric.h>
+#include <XomGeneric.h>
+
+/*
+ external symbols
+*/
+extern FontData read_EncodingInfo();
+extern int _xudc_get_codeset();
+
+extern int _xudc_utyderror ;
+extern int _xudc_utyerror ;
+
+extern unsigned long _xudc_utyerrno ;
+
+#define _XUDC_ERROR -1
+
+
+/*
+ UDC structure define
+*/
+typedef struct __XUDCGlyphRegion {
+ unsigned long start;
+ unsigned long end;
+} _XUDCGlyphRegion ;
+
+/*
+ * "code" no jyoui "i" byte me wo "unsigned char" toshite kaesu.
+ */
+static unsigned char getbyte(code,i)
+unsigned long code;
+int i;
+{
+ unsigned long byteL;
+ unsigned char byte;
+ byteL = code >> (8*(3-i));
+ byte = (unsigned char)(0x000000ff & byteL);
+ return(byte);
+}
+/*
+ get codeset which described by charset_str and locale.
+ for examples ...
+ locale : ja_JP
+ charset_str : JISX0208.1983-0
+*/
+
+_xudc_get_codeset(locale,charset_str,codeset,num_codeset)
+char *locale;
+char *charset_str;
+int **codeset;
+int *num_codeset;
+{
+ XLCdRec lcdrec;
+ XLCd lcd;
+ XLCdPublicRec xlcdp;
+ XPointer rdb;
+ int num = 0,count,num_ret=0,i,*ret;
+ char **value,buf[128],*ptr;
+
+
+ _xudc_utyderror = 0;
+ _xudc_utyerror = 0;
+
+ if((locale == NULL) || (charset_str == NULL)){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 1;
+ _xudc_utyerrno = 0x04 ;
+ return(_XUDC_ERROR);
+ }
+ if(codeset == NULL){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 2;
+ _xudc_utyerrno = 0x04 ;
+ return(_XUDC_ERROR);
+ }
+
+ /* create XLCd */
+ xlcdp.pub.siname = locale;
+ lcdrec.core = (XLCdCore)&xlcdp;
+ lcd = &lcdrec;
+ /* create X RDB (X NLS DB) */
+ rdb = _XlcCreateLocaleDataBase(lcd);
+ if(rdb == NULL){
+ _xudc_utyerror = 1;
+ _xudc_utyerrno = 0x15 ;
+ return(_XUDC_ERROR);
+ }
+
+ for(num=0;;num++){
+ /* XLC_FONTSET */
+ sprintf(buf, "fs%d.font.primary", num);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count < 1){
+ break ;
+ }
+ for(i=0;i<count;i++){
+ if (strlen(value[i]) >= sizeof(buf))
+ continue;
+ strcpy(buf,value[i]);
+ ptr = (char *)strchr(buf,(int)':');
+ *ptr = 0;
+ if(!_XlcCompareISOLatin1(charset_str,buf)){
+ num_ret += 1;
+ if(num_ret == 1){
+ ret = (int *)Xmalloc(sizeof(int));
+ } else {
+ int *prev_ret = ret;
+
+ ret =
+ (int *)Xrealloc(ret,num_ret*sizeof(int));
+ if (ret == NULL){
+ Xfree(prev_ret);
+ }
+ }
+ if(ret == NULL){
+ _xudc_utyerrno = 0x03 ;
+ return(_XUDC_ERROR);
+ }
+ ret[num_ret-1]=num;
+ break ;
+ }
+ }
+ }
+ if(num_ret == 0){
+ *num_codeset = 0;
+ *codeset = NULL;
+ return (0xff);
+ }
+
+ *num_codeset = num_ret;
+ *codeset = ret;
+ return 0;
+}
+
+static Bool gi_to_vgi(gi,vgi,scope)
+unsigned long gi,*vgi;
+FontScope scope;
+{
+ if(scope->shift_direction == (unsigned long)'+'){
+ gi -= scope->shift;
+ } else {
+ gi += scope->shift;
+ }
+ if(gi >= scope->start && gi <= scope->end){
+ *vgi = gi;
+ return(True);
+ }
+ return(False);
+}
+
+static void shift_area(udc,scope)
+_XUDCGlyphRegion *udc;
+FontScope scope;
+{
+ if(scope->shift_direction == (unsigned long)'+'){
+ udc->start += scope->shift;
+ udc->end += scope->shift;
+ } else {
+ udc->start -= scope->shift;
+ udc->end -= scope->shift;
+ }
+}
+
+/*
+ get UDC area with glyph index.
+ for examples ...
+ locale : ja_JP
+ charset_str : JISX0208.1983-0
+*/
+_XUDCGetUDCGIArea(locale,codeset,charset_str,gr,num_gr)
+char *locale;
+int codeset;
+char *charset_str;
+_XUDCGlyphRegion **gr;
+int *num_gr;
+{
+ XLCdRec lcdrec;
+ XLCd lcd;
+ XLCdPublicRec xlcdp;
+ XPointer rdb;
+ _XUDCGlyphRegion *udc;
+ int num = 0,count,num_ret=0;
+ int i,j,k;
+ char **value,buf[128],ptr;
+ FontData font_data;
+
+
+ _xudc_utyderror = 0;
+ _xudc_utyerror = 0;
+ _xudc_utyerrno = 0x00 ;
+
+ if((locale == NULL) || (charset_str == NULL)){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 1;
+ _xudc_utyerrno = 0x04;
+ _xudc_utyerrno |= (0x0b<<8) ;
+ return(_XUDC_ERROR);
+ }
+ if(gr == NULL){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 1;
+ _xudc_utyerrno = 0x04;
+ _xudc_utyerrno |= (0x0b<<8) ;
+ return(_XUDC_ERROR);
+ }
+ if(num_gr == NULL){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 2;
+ _xudc_utyerrno = 0x04;
+ _xudc_utyerrno |= (0x0b<<8) ;
+ return(_XUDC_ERROR);
+ }
+
+ /* create XLCd */
+ xlcdp.pub.siname = locale;
+ lcdrec.core = (XLCdCore)&xlcdp;
+ lcd = &lcdrec;
+ /* create X RDB (X NLS DB) */
+ rdb = _XlcCreateLocaleDataBase(lcd);
+ if(rdb == NULL){
+ _xudc_utyerror = 1;
+ _xudc_utyerrno = 0x15 ;
+ _xudc_utyerrno |= (0x0b<<8) ;
+ return(_XUDC_ERROR);
+ }
+ udc = NULL;
+
+ /* XLC_FONTSET */
+ sprintf(buf, "fs%d.charset.udc_area", codeset-1);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ udc = (_XUDCGlyphRegion *)Xmalloc(count * sizeof(_XUDCGlyphRegion));
+ if(udc == NULL){
+ _xudc_utyerrno = 0x03 ;
+ _xudc_utyerrno |= (0x0b<<8) ;
+ return(_XUDC_ERROR);
+ }
+ for(i=0;i<count;i++){
+ sscanf(value[i],"\\x%lx,\\x%lx", &(udc[i].start), &(udc[i].end));
+ }
+ }
+
+ *num_gr = count;
+
+ sprintf(buf, "fs%d.font.primary", codeset-1);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ font_data = read_EncodingInfo(count,value);
+ for(i=0;i<count;i++){
+ if( !_XlcCompareISOLatin1(font_data[i].name,charset_str)){
+ for(j=0;j<(*num_gr);j++){
+ for(k=0;k<font_data[i].scopes_num;k++){
+ if(udc[j].start == font_data[i].scopes[k].start
+ && font_data[i].scopes[k].shift){
+ shift_area(&udc[j],&(font_data[i].scopes[k]));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ *gr = udc;
+ return 0;
+}
+
+/*
+ * Code convert wo tomonau UDC area no kakutoku
+ * GetUDCCPArea() / glyph_to_code()
+ *
+ */
+
+static int
+_xudc_gi_to_vgi(lcd,locale,charset_str,codeset,gi,vgi,charsetname,size)
+XLCd lcd;
+char *locale;
+char *charset_str;
+int codeset;
+unsigned long gi;
+unsigned long *vgi;
+char *charsetname;
+int size;
+{
+ _XUDCGlyphRegion *udc;
+ int num = 0,count,num_ret=0;
+ int i,j,k;
+ char **value,buf[128],ptr;
+ FontData font_data;
+
+
+ sprintf(buf, "fs%d.charset.name", codeset-1);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ strcpy(charsetname,value[0]);
+ }
+ if (count >= size)
+ return False;
+ sprintf(buf, "fs%d.font.primary", codeset-1);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ font_data = read_EncodingInfo(count,value);
+ for(i=0;i<count;i++){
+ if( !_XlcCompareISOLatin1(font_data[i].name,charset_str)){
+ for(k=0;k<font_data[i].scopes_num;k++){
+ if( gi_to_vgi(gi,vgi,&(font_data[i].scopes[k])) == True){
+ return(True);
+ }
+ }
+ }
+ }
+ }
+/*
+ free_fontdata(font_data);
+*/
+ *vgi = gi;
+ return(True);
+}
+
+Bool non_standard(lcd,charset)
+XLCd lcd;
+XlcCharSet charset;
+{
+ char buf[256];
+ int count,i;
+ char **value;
+ if(charset->ct_sequence == NULL){
+ return(False);
+ }
+ for(i=0;;i++){
+ sprintf(buf, "csd%d.charset_name", i);
+ _XlcGetLocaleDataBase(lcd, "XLC_CHARSET_DEFINE", buf, &value, &count);
+ if(count > 0){
+ if(!_XlcNCompareISOLatin1(value[0],
+ charset->name,strlen(value[0])) ){
+ return(True);
+ }
+ } else {
+ return(False);
+ }
+ }
+}
+
+static Bool
+make_none_standard(from,charset,src,size)
+char *from;
+XlcCharSet charset;
+char *src;
+int size;
+{
+ int name_len,seq_len,rest_len,i;
+ name_len = 2 + strlen(charset->encoding_name) + 1;
+ seq_len = strlen(charset->ct_sequence);
+ rest_len = strlen(charset->encoding_name) + 1 + strlen(src);
+ if (name_len + seq_len + strlen(src) >= size || rest_len >= 0x4000)
+ return False;
+ strcpy(from,charset->ct_sequence);
+ from[seq_len] = (rest_len >> 7) + 128;
+ from[seq_len+1] = (rest_len & 0x7f) + 128;
+ strcpy(&from[seq_len + 2],charset->encoding_name);
+ from[seq_len+name_len-1] = 0x02; /* STX */
+ strcpy(&from[seq_len + name_len],src);
+ return True;
+}
+int
+_xudc_glyph_to_code(locale,charset_str,codeset,glyph_index,codepoint)
+char *locale;
+char *charset_str;
+int codeset;
+unsigned long glyph_index;
+unsigned long *codepoint;
+{
+ XLCd lcd;
+ unsigned char *from; int from_left;
+ unsigned char *to ; int to_left = 10;
+ unsigned char *dst;
+ unsigned char byte;
+ unsigned long from32[25];
+ unsigned long to32[25];
+ int i,j;
+ char charsetname[256],src[10];
+ XlcConv conv;
+ XlcCharSet charset;
+ XPointer args[2];
+
+ from = (unsigned char *)from32;
+ to = (unsigned char *)to32;
+ dst = (unsigned char *)to32;
+
+ memset(dst,0,25);
+
+ lcd = (XLCd)_XlcGenericLoader(locale);
+
+ if (!_xudc_gi_to_vgi(lcd,locale,charset_str,codeset,
+ glyph_index,&glyph_index,charsetname,sizeof(charsetname)))
+ return(_XUDC_ERROR);
+
+ for(i=0,j=0;i<4;i++){
+ byte = getbyte(glyph_index,i);
+ if(byte){
+ src[j] = byte;
+ j ++;
+ }
+ }
+ src[j] = 0;
+
+
+ /* get charset */
+/*
+ sprintf(tmp,"%s%s",charset_str,":GL");
+ charset_name = strdup(tmp);
+*/
+ charset = _XlcGetCharSet(charsetname);
+ if(charset == NULL){
+ _xudc_utyerrno = 0x16 ;
+ return(_XUDC_ERROR);
+ }
+ /* make ct */
+ if( non_standard(lcd,charset)) {
+ if (!make_none_standard(from,charset,src,sizeof(from32)))
+ return(_XUDC_ERROR);
+ } else if(charset->ct_sequence){
+ if (strlen(charset->ct_sequence) + strlen(src) >= sizeof(from32))
+ return(_XUDC_ERROR);
+ sprintf((char *)from,"%s%s",charset->ct_sequence,src);
+ } else {
+ sprintf((char *)from,"%s\0",src);
+ }
+ /* compound text -> multi byte */
+ conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte);
+ from_left = strlen((char *)from);
+ _XlcConvert(conv,(XPointer *)&from,&from_left,
+ (XPointer *)&to, &to_left,args,0);
+ _XlcCloseConverter(conv);
+ _XlcDestroyLC(lcd);
+
+ *codepoint = 0;
+ for(i=0;dst[i];i++){
+ *codepoint = ((*codepoint << 8) | dst[i]) ;
+ }
+ return(0);
+}
+
+typedef struct __XUDCCodeRegion {
+ unsigned long start,end;
+} _XUDCCodeRegion ;
+
+int
+_XUDCGetUDCCPArea(locale,codeset,charset_str,cr,num_cr)
+char *locale;
+int codeset;
+char *charset_str;
+_XUDCCodeRegion **cr;
+int *num_cr;
+{
+ int i,num_gr,ret;
+ _XUDCGlyphRegion *gr;
+ _XUDCCodeRegion *crr;
+
+ _xudc_utyerror = 0;
+ _xudc_utyderror = 0;
+
+ if(cr == NULL){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 1;
+ _xudc_utyerrno = 0x04 ;
+ _xudc_utyerrno |= (0x0a<<8) ;
+ return(_XUDC_ERROR);
+ }
+ if(num_cr == NULL){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 2;
+ _xudc_utyerrno = 0x04 ;
+ _xudc_utyerrno |= (0x0a<<8) ;
+ return(_XUDC_ERROR);
+ }
+
+ ret = _XUDCGetUDCGIArea(locale,codeset,charset_str,&gr,&num_gr);
+ if(ret == _XUDC_ERROR){
+ _xudc_utyerrno &= 0xff ;
+ _xudc_utyerrno |= (0x0a<<8) ;
+ return(ret);
+ }
+
+ crr = (_XUDCCodeRegion *)Xmalloc(num_gr*sizeof(_XUDCCodeRegion));
+ if(crr == NULL){
+ Xfree(gr);
+ _xudc_utyerrno = 0x03 ;
+ _xudc_utyerrno |= (0x0a<<8) ;
+ return(_XUDC_ERROR);
+ }
+
+ for(i=0;i<num_gr;i++){
+ ret = _xudc_glyph_to_code(locale,charset_str,codeset,
+ gr[i].start, &(crr[i].start));
+ if(ret == _XUDC_ERROR){
+ _xudc_utyerrno |= (0x0a<<8) ;
+ Xfree(gr);
+ Xfree(crr);
+ return(ret);
+ }
+ ret = _xudc_glyph_to_code(locale,charset_str,codeset,
+ gr[i].end, &(crr[i].end));
+ if(ret == _XUDC_ERROR){
+ _xudc_utyerrno |= (0x0a<<8) ;
+ Xfree(gr);
+ Xfree(crr);
+ return(ret);
+ }
+ }
+ Xfree(gr);
+ *cr = crr;
+ *num_cr = num_gr;
+ return(0);
+}
+
+/*
+ * code_to_glyph()
+ *
+ */
+typedef struct __XUDCGIInf {
+ char *charset_str;
+ unsigned long glyph_index;
+} _XUDCGIInf ;
+
+/*
+ *
+ *
+ */
+static Bool vgi_to_gi(gi,vgi,scope)
+unsigned long *gi,vgi;
+FontScope scope;
+{
+ if(vgi >= scope->start && vgi <= scope->end){
+ if(scope->shift_direction == (unsigned long)'+'){
+ *gi = vgi + scope->shift;
+ } else {
+ *gi = vgi - scope->shift;
+ }
+ return(True);
+ }
+ return(False);
+}
+/*
+ *
+ *
+ */
+static Bool
+_xudc_vgi_to_gi(lcd,locale,vglyph,glyph,charset,charsetname,size)
+XLCd lcd;
+char *locale;
+unsigned long vglyph;
+unsigned long *glyph;
+XlcCharSet charset;
+char *charsetname;
+int size;
+{
+ int num = 0,count,num_ret=0;
+ int i,j,k;
+ char **value,buf[128],ptr;
+ FontData font_data;
+ CodeSet cs;
+
+
+ for(i=0;;i++){
+ sprintf(buf, "fs%d.charset.name",i);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ if(!_XlcNCompareISOLatin1(charset->name,value[0],
+ strlen(charset->name))){
+ break;
+ }
+ } else {
+ _xudc_utyerrno = 0x17 ;
+ return(False);
+ }
+ }
+/*
+ sprintf(buf, "fs%d.charset.name", codeset-1);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ strcpy(charsetname,value[0]);
+ }
+*/
+ sprintf(buf, "fs%d.font.primary", i);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ font_data = read_EncodingInfo(count,value);
+ for(i=0;i<count;i++){
+ for(k=0;k<font_data[i].scopes_num;k++){
+ if( vgi_to_gi(glyph,vglyph,&(font_data[i].scopes[k])) == True){
+ if (strlen(font_data[i].name) >= size)
+ return(False);
+ strcpy(charsetname,font_data[i].name);
+ return(True);
+ }
+ }
+ }
+ }
+ *glyph = vglyph;
+ return(True);
+}
+int
+_xudc_code_to_glyph(locale,codepoint,gi,num_gi)
+char *locale;
+unsigned long codepoint;
+_XUDCGIInf **gi;
+int *num_gi;
+{
+ XLCd lcd;
+ unsigned char *from; int from_left;
+ unsigned char *to ; int to_left = 10;
+ unsigned char *dst;
+ unsigned char byte;
+ unsigned int from32[25];
+ unsigned int to32[25];
+ int i,j;
+ char charsetname[256],src[10];
+ XlcConv conv;
+ XlcCharSet charset;
+ XPointer args[2];
+ unsigned long glyph,vglyph;
+
+ from = (unsigned char *)from32;
+ to = (unsigned char *)to32;
+ dst = (unsigned char *)to32;
+ memset(dst,0,25);
+
+ lcd = (XLCd)_XlcGenericLoader(locale);
+
+ for(i=0,j=0;i<4;i++){
+ byte = getbyte(codepoint,i);
+ if(byte){
+ src[j] = byte;
+ j ++;
+ }
+ }
+ src[j] = 0;
+ sprintf((char *)from,"%s\0",src);
+ /* multi byte -> vgi */
+ conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet);
+ from_left = strlen((char *)from);
+ args[0] = (XPointer) &charset;
+ _XlcConvert(conv,(XPointer *)&from,&from_left,
+ (XPointer *)&to, &to_left,args,1);
+
+ /* vgi -> gi */
+ vglyph = 0;
+ for(i=0;dst[i];i++){
+ vglyph = ((vglyph << 8) | dst[i]) ;
+ }
+ if(_xudc_vgi_to_gi(lcd,locale,vglyph,&glyph,charset,charsetname,
+ sizeof(charsetname))==False){
+ _XlcCloseConverter(conv);
+ _XlcDestroyLC(lcd);
+ *num_gi = 0;
+ return(0);
+ }
+
+ _XlcCloseConverter(conv);
+ _XlcDestroyLC(lcd);
+
+ *gi = (_XUDCGIInf *)Xmalloc(sizeof(_XUDCGIInf));
+ (*gi)->charset_str = (char *)Xmalloc(strlen(charsetname)+1);
+ strcpy((*gi)->charset_str,charsetname);
+ (*gi)->glyph_index = glyph;
+ if(*gi == NULL){
+ _xudc_utyerrno = 0x03 ;
+ return(_XUDC_ERROR);
+ }
+ *num_gi = 1;
+ return(0);
+}
+
diff --git a/nx-X11/lib/X11/utf8WMProps.c b/nx-X11/lib/X11/utf8WMProps.c
new file mode 100644
index 000000000..e3a329ac8
--- /dev/null
+++ b/nx-X11/lib/X11/utf8WMProps.c
@@ -0,0 +1,93 @@
+/* $TOG: mbWMProps.c /main/6 1998/02/06 17:44:24 kaleb $ */
+/*
+
+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.
+
+*/
+/*
+ * Copyright 2000 by Bruno Haible
+ *
+ * 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 of Bruno Haible not
+ * be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Bruno Haible
+ * makes no representations about the suitability of this software for
+ * any purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * Bruno Haible DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL Bruno Haible 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.
+ */
+/* $XFree86: xc/lib/X11/utf8WMProps.c,v 1.2 2001/12/14 19:54:11 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Xlocale.h>
+
+void
+Xutf8SetWMProperties (
+ Display *dpy,
+ Window w,
+ _Xconst char *windowName,
+ _Xconst char *iconName,
+ char **argv,
+ int argc,
+ XSizeHints *sizeHints,
+ XWMHints *wmHints,
+ XClassHint *classHints)
+{
+ XTextProperty wname, iname;
+ XTextProperty *wprop = NULL;
+ XTextProperty *iprop = NULL;
+
+ if (windowName &&
+ Xutf8TextListToTextProperty(dpy, (char**)&windowName, 1,
+ XStdICCTextStyle, &wname) >= Success)
+ wprop = &wname;
+ if (iconName &&
+ Xutf8TextListToTextProperty(dpy, (char**)&iconName, 1,
+ XStdICCTextStyle, &iname) >= Success)
+ iprop = &iname;
+ XSetWMProperties(dpy, w, wprop, iprop, argv, argc,
+ sizeHints, wmHints, classHints);
+ if (wprop)
+ Xfree((char *)wname.value);
+ if (iprop)
+ Xfree((char *)iname.value);
+
+ /* Note: The WM_LOCALE_NAME property is set by XSetWMProperties. */
+}
diff --git a/nx-X11/lib/X11/utf8Wrap.c b/nx-X11/lib/X11/utf8Wrap.c
new file mode 100644
index 000000000..bde3f041c
--- /dev/null
+++ b/nx-X11/lib/X11/utf8Wrap.c
@@ -0,0 +1,187 @@
+/* $TOG: mbWrap.c /main/7 1998/02/06 17:44:30 kaleb $ */
+/*
+
+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.
+
+*/
+/*
+ * Copyright 1991 by the Open Software Foundation
+ *
+ * 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 of 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
+ */
+/*
+ * Copyright 2000 by Bruno Haible
+ *
+ * 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 of Bruno Haible not
+ * be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Bruno Haible
+ * makes no representations about the suitability of this software for
+ * any purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * Bruno Haible DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL Bruno Haible 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.
+ */
+/* $XFree86: xc/lib/X11/utf8Wrap.c,v 1.3 2001/12/14 19:54:11 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+void
+Xutf8DrawText(
+ Display *dpy,
+ Drawable d,
+ GC gc,
+ int x,
+ int y,
+ XmbTextItem *text_items,
+ int nitems)
+{
+ register XFontSet fs = NULL;
+ register XmbTextItem *p = text_items;
+ register int i = nitems;
+ register int esc;
+
+ /* ignore leading items with no fontset */
+ while (i && !p->font_set) {
+ i--;
+ p++;
+ }
+
+ for (; --i >= 0; p++) {
+ if (p->font_set)
+ fs = p->font_set;
+ x += p->delta;
+ esc = (*fs->methods->utf8_draw_string) (dpy, d, fs, gc, x, y,
+ p->chars, p->nchars);
+ if (!esc)
+ esc = fs->methods->utf8_escapement (fs, p->chars, p->nchars);
+ x += esc;
+ }
+}
+
+void
+Xutf8DrawString(
+ Display *dpy,
+ Drawable d,
+ XFontSet font_set,
+ GC gc,
+ int x,
+ int y,
+ _Xconst char *text,
+ int text_len)
+{
+ (void)(*font_set->methods->utf8_draw_string) (dpy, d, font_set, gc, x, y,
+ (char *)text, text_len);
+}
+
+
+void
+Xutf8DrawImageString(
+ Display *dpy,
+ Drawable d,
+ XFontSet font_set,
+ GC gc,
+ int x,
+ int y,
+ _Xconst char *text,
+ int text_len)
+{
+ (*font_set->methods->utf8_draw_image_string) (dpy, d, font_set, gc, x, y,
+ (char *)text, text_len);
+}
+
+int
+Xutf8TextEscapement(
+ XFontSet font_set,
+ _Xconst char *text,
+ int text_len)
+{
+ return (*font_set->methods->utf8_escapement) (font_set,
+ (char *)text, text_len);
+}
+
+int
+Xutf8TextExtents(
+ XFontSet font_set,
+ _Xconst char *text,
+ int text_len,
+ XRectangle *overall_ink_extents,
+ XRectangle *overall_logical_extents)
+{
+ return (*font_set->methods->utf8_extents) (font_set,
+ (char *)text, text_len,
+ overall_ink_extents,
+ overall_logical_extents);
+}
+
+Status
+Xutf8TextPerCharExtents(
+ XFontSet font_set,
+ _Xconst char *text,
+ int text_len,
+ XRectangle *ink_extents_buffer,
+ XRectangle *logical_extents_buffer,
+ int buffer_size,
+ int *num_chars,
+ XRectangle *max_ink_extents,
+ XRectangle *max_logical_extents)
+{
+ return (*font_set->methods->utf8_extents_per_char)
+ (font_set, (char *)text, text_len,
+ ink_extents_buffer, logical_extents_buffer,
+ buffer_size, num_chars, max_ink_extents, max_logical_extents);
+}
diff --git a/nx-X11/lib/X11/util/makekeys.c b/nx-X11/lib/X11/util/makekeys.c
new file mode 100644
index 000000000..0b0ad9e2c
--- /dev/null
+++ b/nx-X11/lib/X11/util/makekeys.c
@@ -0,0 +1,274 @@
+/* $Xorg: makekeys.c,v 1.5 2001/02/09 02:03:40 $ */
+/* $XdotOrg: xc/lib/X11/util/makekeys.c,v 1.5 2005/07/03 07:00:56 daniels 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.
+
+*/
+/* $XFree86: $ */
+
+/* Constructs hash tables for XStringToKeysym and XKeysymToString. */
+
+#include <X11/X.h>
+#include <X11/Xos.h>
+#include <X11/keysymdef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */
+char *malloc();
+#endif /* macII */
+
+typedef unsigned long Signature;
+
+#define KTNUM 3000
+
+static struct info {
+ char *name;
+ KeySym val;
+} info[KTNUM];
+
+#define MIN_REHASH 10
+#define MATCHES 10
+
+char tab[KTNUM];
+unsigned short offsets[KTNUM];
+unsigned short indexes[KTNUM];
+KeySym values[KTNUM];
+char buf[1024];
+
+int
+main(int argc, char *argv[])
+{
+ int ksnum = 0;
+ int max_rehash;
+ Signature sig;
+ register int i, j, k, z;
+ register char *name;
+ register char c;
+ int first;
+ int best_max_rehash;
+ int best_z = 0;
+ int num_found;
+ KeySym val;
+ char key[128];
+ char alias[128];
+
+
+ while (fgets(buf, sizeof(buf), stdin)) {
+ i = sscanf(buf, "#define XK_%127s 0x%lx", key, &info[ksnum].val);
+ if (i != 2) {
+ i = sscanf(buf, "#define XK_%127s XK_%127s", key, alias);
+ if (i != 2)
+ continue;
+ for (i = ksnum - 1; i >= 0; i--) {
+ if (strcmp(info[i].name, alias) == 0) {
+ info[ksnum].val = info[i].val;
+ break;
+ }
+ }
+ if (i < 0) { /* Didn't find a match */
+ fprintf(stderr,
+ "can't find matching definition %s for keysym %s\n",
+ alias, key);
+ continue;
+ }
+ }
+ if (info[ksnum].val == XK_VoidSymbol)
+ info[ksnum].val = 0;
+ if (info[ksnum].val > 0x1fffffff) {
+ fprintf(stderr,
+ "ignoring illegal keysym (%s), remove it from .h file!\n",
+ key);
+ continue;
+ }
+ name = malloc((unsigned)strlen(key)+1);
+ if (!name) {
+ fprintf(stderr, "makekeys: out of memory!\n");
+ exit(1);
+ }
+ (void)strcpy(name, key);
+ info[ksnum].name = name;
+ ksnum++;
+ if (ksnum == KTNUM) {
+ fprintf(stderr, "makekeys: too many keysyms!\n");
+ exit(1);
+ }
+ }
+
+ printf("/* This file is generated from keysymdef.h. */\n");
+ printf("/* Do not edit. */\n");
+ printf("\n");
+
+ best_max_rehash = ksnum;
+ num_found = 0;
+ for (z = ksnum; z < KTNUM; z++) {
+ max_rehash = 0;
+ for (name = tab, i = z; --i >= 0;)
+ *name++ = 0;
+ for (i = 0; i < ksnum; i++) {
+ name = info[i].name;
+ sig = 0;
+ while ((c = *name++))
+ sig = (sig << 1) + c;
+ first = j = sig % z;
+ for (k = 0; tab[j]; k++) {
+ j += first + 1;
+ if (j >= z)
+ j -= z;
+ if (j == first)
+ goto next1;
+ }
+ tab[j] = 1;
+ if (k > max_rehash)
+ max_rehash = k;
+ }
+ if (max_rehash < MIN_REHASH) {
+ if (max_rehash < best_max_rehash) {
+ best_max_rehash = max_rehash;
+ best_z = z;
+ }
+ num_found++;
+ if (num_found >= MATCHES)
+ break;
+ }
+next1: ;
+ }
+
+ z = best_z;
+ printf("#ifdef NEEDKTABLE\n");
+ printf("const unsigned char _XkeyTable[] = {\n");
+ printf("0,\n");
+ k = 1;
+ for (i = 0; i < ksnum; i++) {
+ name = info[i].name;
+ sig = 0;
+ while ((c = *name++))
+ sig = (sig << 1) + c;
+ first = j = sig % z;
+ while (offsets[j]) {
+ j += first + 1;
+ if (j >= z)
+ j -= z;
+ }
+ offsets[j] = k;
+ indexes[i] = k;
+ val = info[i].val;
+ printf("0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, ",
+ (sig >> 8) & 0xff, sig & 0xff,
+ (val >> 24) & 0xff, (val >> 16) & 0xff,
+ (val >> 8) & 0xff, val & 0xff);
+ for (name = info[i].name, k += 7; (c = *name++); k++)
+ printf("'%c',", c);
+ printf((i == (ksnum-1)) ? "0\n" : "0,\n");
+ }
+ printf("};\n");
+ printf("\n");
+ printf("#define KTABLESIZE %d\n", z);
+ printf("#define KMAXHASH %d\n", best_max_rehash + 1);
+ printf("\n");
+ printf("static const unsigned short hashString[KTABLESIZE] = {\n");
+ for (i = 0; i < z;) {
+ printf("0x%.4x", offsets[i]);
+ i++;
+ if (i == z)
+ break;
+ printf((i & 7) ? ", " : ",\n");
+ }
+ printf("\n");
+ printf("};\n");
+ printf("#endif /* NEEDKTABLE */\n");
+
+ best_max_rehash = ksnum;
+ num_found = 0;
+ for (z = ksnum; z < KTNUM; z++) {
+ max_rehash = 0;
+ for (name = tab, i = z; --i >= 0;)
+ *name++ = 0;
+ for (i = 0; i < ksnum; i++) {
+ val = info[i].val;
+ first = j = val % z;
+ for (k = 0; tab[j]; k++) {
+ if (values[j] == val)
+ goto skip1;
+ j += first + 1;
+ if (j >= z)
+ j -= z;
+ if (j == first)
+ goto next2;
+ }
+ tab[j] = 1;
+ values[j] = val;
+ if (k > max_rehash)
+ max_rehash = k;
+skip1: ;
+ }
+ if (max_rehash < MIN_REHASH) {
+ if (max_rehash < best_max_rehash) {
+ best_max_rehash = max_rehash;
+ best_z = z;
+ }
+ num_found++;
+ if (num_found >= MATCHES)
+ break;
+ }
+next2: ;
+ }
+
+ z = best_z;
+ for (i = z; --i >= 0;)
+ offsets[i] = 0;
+ for (i = 0; i < ksnum; i++) {
+ val = info[i].val;
+ first = j = val % z;
+ while (offsets[j]) {
+ if (values[j] == val)
+ goto skip2;
+ j += first + 1;
+ if (j >= z)
+ j -= z;
+ }
+ offsets[j] = indexes[i] + 2;
+ values[j] = val;
+skip2: ;
+ }
+ printf("\n");
+ printf("#ifdef NEEDVTABLE\n");
+ printf("#define VTABLESIZE %d\n", z);
+ printf("#define VMAXHASH %d\n", best_max_rehash + 1);
+ printf("\n");
+ printf("static const unsigned short hashKeysym[VTABLESIZE] = {\n");
+ for (i = 0; i < z;) {
+ printf("0x%.4x", offsets[i]);
+ i++;
+ if (i == z)
+ break;
+ printf((i & 7) ? ", " : ",\n");
+ }
+ printf("\n");
+ printf("};\n");
+ printf("#endif /* NEEDVTABLE */\n");
+
+ exit(0);
+}
diff --git a/nx-X11/lib/X11/util/mkks.sh b/nx-X11/lib/X11/util/mkks.sh
new file mode 100644
index 000000000..262cc9540
--- /dev/null
+++ b/nx-X11/lib/X11/util/mkks.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+cat $* | awk 'BEGIN { \
+ printf "/*\n * This file is generated from %s. Do not edit.\n */\n", \
+ "$(INCLUDESRC)/keysymdef.h";\
+} \
+/^#define/ { \
+ len = length($2)-3; \
+ printf("{ \"%s\", %s },\n", substr($2,4,len), $3); \
+}'
+
diff --git a/nx-X11/lib/X11/uvY.c b/nx-X11/lib/X11/uvY.c
new file mode 100644
index 000000000..d7c3e6ab2
--- /dev/null
+++ b/nx-X11/lib/X11/uvY.c
@@ -0,0 +1,408 @@
+/* $Xorg: uvY.c,v 1.3 2000/08/17 19:45:23 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * CIEuvy.c
+ *
+ * DESCRIPTION
+ * This file contains routines that support the CIE u'v'Y
+ * color space to include conversions to and from the CIE
+ * XYZ space.
+ *
+ * DOCUMENTATION
+ * "TekColor Color Management System, System Implementor's Manual"
+ */
+/* $XFree86: xc/lib/X11/uvY.c,v 1.3 2001/01/17 19:41:57 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+#include <stdio.h>
+
+/*
+ * FORWARD DECLARATIONS
+ */
+static int CIEuvY_ParseString(register char *spec, XcmsColor *pColor);
+
+/*
+ * DEFINES
+ * Internal definitions that need NOT be exported to any package
+ * or program using this package.
+ */
+#ifdef DBL_EPSILON
+# define XMY_DBL_EPSILON DBL_EPSILON
+#else
+# define XMY_DBL_EPSILON 0.00001
+#endif
+
+
+/*
+ * LOCAL VARIABLES
+ */
+
+ /*
+ * NULL terminated list of functions applied to get from CIEuvY to CIEXYZ
+ */
+static XcmsConversionProc Fl_CIEuvY_to_CIEXYZ[] = {
+ XcmsCIEuvYToCIEXYZ,
+ NULL
+};
+
+ /*
+ * NULL terminated list of functions applied to get from CIEXYZ to CIEuvY
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_CIEuvY[] = {
+ XcmsCIEXYZToCIEuvY,
+ NULL
+};
+
+
+/*
+ * GLOBALS
+ */
+
+ /*
+ * CIE uvY Color Space
+ */
+XcmsColorSpace XcmsCIEuvYColorSpace =
+ {
+ _XcmsCIEuvY_prefix, /* prefix */
+ XcmsCIEuvYFormat, /* id */
+ CIEuvY_ParseString, /* parseString */
+ Fl_CIEuvY_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_CIEuvY, /* from_CIEXYZ */
+ 1
+ };
+
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CIEuvY_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+CIEuvY_ParseString(
+ register char *spec,
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsCIEuvYFormat.
+ * The assumed CIEuvY string syntax is:
+ * CIEuvY:<u>/<v>/<Y>
+ * Where u, v, and Y are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ * 0 if failed, non-zero otherwise.
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsCIEuvY_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.CIEuvY.u_prime,
+ &pColor->spec.CIEuvY.v_prime,
+ &pColor->spec.CIEuvY.Y) != 3) {
+ return(XcmsFailure);
+ }
+ pColor->format = XcmsCIEuvYFormat;
+ pColor->pixel = 0;
+ return(_XcmsCIEuvY_ValidSpec(pColor));
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIEuvY_ValidSpec
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsCIEuvY_ValidSpec(
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * Checks if color specification valid for CIE u'v'Y.
+ *
+ * RETURNS
+ * XcmsFailure if invalid,
+ * XcmsSuccess if valid.
+ *
+ */
+{
+ if (pColor->format != XcmsCIEuvYFormat
+ ||
+ (pColor->spec.CIEuvY.Y < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIEuvY.Y > 1.0 + XMY_DBL_EPSILON)) {
+ return(XcmsFailure);
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEuvYToCIEXYZ - convert CIEuvY to CIEXYZ
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIEuvYToCIEXYZ(ccc, puvY_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *puvY_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIEuvY format to CIEXYZ format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsCIEXYZ XYZ_return;
+ XcmsColor whitePt;
+ int i;
+ XcmsColor *pColor = pColors_in_out;
+ XcmsFloat div, x, y, z, Y;
+
+ /*
+ * Check arguments
+ * Postpone checking puvY_WhitePt until it is actually needed
+ * otherwise converting between XYZ and uvY will fail.
+ */
+ if (pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ /* Make sure original format is CIEuvY */
+ if (!_XcmsCIEuvY_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Convert to CIEXYZ
+ */
+
+ Y = pColor->spec.CIEuvY.Y;
+
+ /* Convert color u'v' to xyz space */
+ div = (6.0 * pColor->spec.CIEuvY.u_prime) - (16.0 * pColor->spec.CIEuvY.v_prime) + 12.0;
+ if (div == 0.0) {
+ /* use white point since div == 0 */
+ if (puvY_WhitePt == NULL ) {
+ return(XcmsFailure);
+ }
+ /*
+ * Make sure white point is in CIEuvY form
+ */
+ if (puvY_WhitePt->format != XcmsCIEuvYFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)puvY_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL, 1,
+ XcmsCIEuvYFormat)) {
+ return(XcmsFailure);
+ }
+ puvY_WhitePt = &whitePt;
+ }
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (puvY_WhitePt->spec.CIEuvY.Y != 1.0) {
+ return(XcmsFailure);
+ }
+ div = (6.0 * puvY_WhitePt->spec.CIEuvY.u_prime) -
+ (16.0 * puvY_WhitePt->spec.CIEuvY.v_prime) + 12.0;
+ if (div == 0) {
+ /* internal error */
+ return(XcmsFailure);
+ }
+ x = 9.0 * puvY_WhitePt->spec.CIEuvY.u_prime / div;
+ y = 4.0 * puvY_WhitePt->spec.CIEuvY.v_prime / div;
+ } else {
+ x = 9.0 * pColor->spec.CIEuvY.u_prime / div;
+ y = 4.0 * pColor->spec.CIEuvY.v_prime / div;
+ }
+ z = 1.0 - x - y;
+
+ /* Convert from xyz to XYZ */
+ /* Conversion uses color normalized lightness based on Y */
+ if (y != 0.0) {
+ XYZ_return.X = x * Y / y;
+ } else {
+ XYZ_return.X = x;
+ }
+ XYZ_return.Y = Y;
+ if (y != 0.0) {
+ XYZ_return.Z = z * Y / y;
+ } else {
+ XYZ_return.Z = z;
+ }
+
+ memcpy((char *)&pColor->spec.CIEXYZ, (char *)&XYZ_return, sizeof(XcmsCIEXYZ));
+ /* Identify that format is now CIEXYZ */
+ pColor->format = XcmsCIEXYZFormat;
+ }
+
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEXYZToCIEuvY - convert CIEXYZ to CIEuvY
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIEXYZToCIEuvY(ccc, puvY_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *puvY_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIEXYZ format to CIEuvY format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsCIEuvY uvY_return;
+ XcmsColor whitePt;
+ int i;
+ XcmsColor *pColor = pColors_in_out;
+ XcmsFloat div;
+
+ /*
+ * Check arguments
+ * Postpone checking puvY_WhitePt until it is actually needed
+ * otherwise converting between XYZ and uvY will fail.
+ */
+ if (pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEuvY form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ /* Make sure original format is CIEXYZ */
+ if (!_XcmsCIEXYZ_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ /* Convert to CIEuvY */
+ div = pColor->spec.CIEXYZ.X + (15.0 * pColor->spec.CIEXYZ.Y) +
+ (3.0 * pColor->spec.CIEXYZ.Z);
+ if (div == 0.0) {
+ /* Use white point since div == 0.0 */
+ if (puvY_WhitePt == NULL ) {
+ return(XcmsFailure);
+ }
+ /*
+ * Make sure white point is in CIEuvY form
+ */
+ if (puvY_WhitePt->format != XcmsCIEuvYFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)puvY_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL, 1,
+ XcmsCIEuvYFormat)) {
+ return(XcmsFailure);
+ }
+ puvY_WhitePt = &whitePt;
+ }
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (puvY_WhitePt->spec.CIEuvY.Y != 1.0) {
+ return(XcmsFailure);
+ }
+ uvY_return.Y = pColor->spec.CIEXYZ.Y;
+ uvY_return.u_prime = puvY_WhitePt->spec.CIEuvY.u_prime;
+ uvY_return.v_prime = puvY_WhitePt->spec.CIEuvY.v_prime;
+ } else {
+ uvY_return.u_prime = 4.0 * pColor->spec.CIEXYZ.X / div;
+ uvY_return.v_prime = 9.0 * pColor->spec.CIEXYZ.Y / div;
+ uvY_return.Y = pColor->spec.CIEXYZ.Y;
+ }
+
+ memcpy((char *)&pColor->spec.CIEuvY, (char *)&uvY_return, sizeof(XcmsCIEuvY));
+ /* Identify that format is now CIEuvY */
+ pColor->format = XcmsCIEuvYFormat;
+ }
+
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/X11/wcWrap.c b/nx-X11/lib/X11/wcWrap.c
new file mode 100644
index 000000000..a0314da7f
--- /dev/null
+++ b/nx-X11/lib/X11/wcWrap.c
@@ -0,0 +1,163 @@
+/* $Xorg: wcWrap.c,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */
+/*
+
+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.
+
+*/
+
+/*
+ * Copyright 1991 by the Open Software Foundation
+ *
+ * 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 of 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
+ */
+/* $XFree86: xc/lib/X11/wcWrap.c,v 1.6 2001/12/14 19:54:11 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+void
+XwcDrawText(
+ Display *dpy,
+ Drawable d,
+ GC gc,
+ int x,
+ int y,
+ XwcTextItem *text_items,
+ int nitems)
+{
+ register XFontSet fs = NULL;
+ register XwcTextItem *p = text_items;
+ register int i = nitems;
+ register int esc;
+
+ /* ignore leading items with no fontset */
+ while (i && !p->font_set) {
+ i--;
+ p++;
+ }
+
+ for (; --i >= 0; p++) {
+ if (p->font_set)
+ fs = p->font_set;
+ x += p->delta;
+ esc = (*fs->methods->wc_draw_string) (dpy, d, fs, gc, x, y,
+ p->chars, p->nchars);
+ if (!esc)
+ esc = fs->methods->wc_escapement (fs, p->chars, p->nchars);
+ x += esc;
+ }
+}
+
+void
+XwcDrawString(
+ Display *dpy,
+ Drawable d,
+ XFontSet font_set,
+ GC gc,
+ int x,
+ int y,
+ _Xconst wchar_t *text,
+ int text_len)
+{
+ (void)(*font_set->methods->wc_draw_string) (dpy, d, font_set, gc, x, y,
+ text, text_len);
+}
+
+void
+XwcDrawImageString(
+ Display *dpy,
+ Drawable d,
+ XFontSet font_set,
+ GC gc,
+ int x,
+ int y,
+ _Xconst wchar_t *text,
+ int text_len)
+{
+ (*font_set->methods->wc_draw_image_string) (dpy, d, font_set, gc, x, y,
+ text, text_len);
+}
+
+int
+XwcTextEscapement(
+ XFontSet font_set,
+ _Xconst wchar_t *text,
+ int text_len)
+{
+ return (*font_set->methods->wc_escapement) (font_set, text, text_len);
+}
+
+int
+XwcTextExtents(
+ XFontSet font_set,
+ _Xconst wchar_t *text,
+ int text_len,
+ XRectangle *overall_ink_extents,
+ XRectangle *overall_logical_extents)
+{
+ return (*font_set->methods->wc_extents) (font_set, text, text_len,
+ overall_ink_extents,
+ overall_logical_extents);
+}
+
+Status
+XwcTextPerCharExtents(
+ XFontSet font_set,
+ _Xconst wchar_t *text,
+ int text_len,
+ XRectangle *ink_extents_buffer,
+ XRectangle *logical_extents_buffer,
+ int buffer_size,
+ int *num_chars,
+ XRectangle *max_ink_extents,
+ XRectangle *max_logical_extents)
+{
+ return (*font_set->methods->wc_extents_per_char)
+ (font_set, text, text_len,
+ ink_extents_buffer, logical_extents_buffer,
+ buffer_size, num_chars, max_ink_extents, max_logical_extents);
+}
diff --git a/nx-X11/lib/X11/xlibi18n/Imakefile b/nx-X11/lib/X11/xlibi18n/Imakefile
new file mode 100644
index 000000000..6074f9fd3
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/Imakefile
@@ -0,0 +1,9 @@
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = lc im om
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(LINTSUBDIRS))
+MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln)
diff --git a/nx-X11/lib/X11/xlibi18n/Xi18nLib.conf b/nx-X11/lib/X11/xlibi18n/Xi18nLib.conf
new file mode 100644
index 000000000..04d953a77
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/Xi18nLib.conf
@@ -0,0 +1,105 @@
+XCOMM $XFree86: Xi18nLib.conf,v 1.8 2002/11/25 14:04:54 eich Exp $
+XCOMM $XdotOrg: xc/lib/X11/xlibi18n/Xi18nLib.conf,v 1.4 2004/08/26 17:57:19 eich Exp $
+
+#define DoNormalLib NO
+#define DoSharedLib YES
+#define DoDebugLib DebugLibX11
+#define DoProfileLib ProfileLibX11
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+#include <Threads.tmpl>
+
+ SOXI18NREV = 2
+ POSTLOCALE = common
+#if defined (LibDirName)
+ POSTLOCALELIB = LibDirName
+#else
+ POSTLOCALELIB = lib
+#endif
+
+#if Malloc0ReturnsNull
+ MALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+#if NeedLibInsideFlag
+ LIB_DEFINES = -D_XLIBINT_
+#endif
+
+DYNAMIC_DEFINES = -DDYNAMIC_LOAD
+ DEFINES = $(MALLOC_DEFINES) $(LIB_DEFINES) $(SUNSOFT_DEFINES)
+
+#include <Library.tmpl>
+
+#if defined(HPArchitecture) && OSMajorVersion > 9
+ EXTRA_SHLIBLDFLAGS = +s +b $(USRLIBDIR)
+#else
+ EXTRA_SHLIBLDFLAGS =
+#endif
+
+#if defined(SparcArchitecture)
+#if defined(HasSunC) && HasSunC
+CFLAGS += -xregs=no%appl
+#endif
+#if HasGcc
+CFLAGS += -mno-app-regs
+#endif
+#endif
+
+all::
+ $(_NULLCMD_)
+.c.o:
+ $(_NULLCMD_)
+ $(_NULLCMD_)
+ $(_NULLCMD_)
+ $(RM) $@
+ $(CC) -c $(CFLAGS) $(_NOOP_) $(SHLIBDEF) $(SHAREDCODEDEF) $(PICFLAGS) $*.c
+
+clean::
+ rm -rf *.so.$(SOXI18NREV)
+
+lint::
+ $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
+
+#ifndef BuildI18NTop
+# define BuildI18NTop $(BUILDLIBTOP)/../../..
+#endif
+
+BUILDI18NTOP = BuildI18NTop
+
+#ifndef LinkBuildXi18nLibrary
+# ifdef UseInstalled
+# define LinkBuildXi18nLibrary(libname,rev)
+# else
+# define LinkBuildXi18nLibrary(libname,rev) @@\
+AllTarget(AllTarget(Concat(lib,libname.so.rev))) @@\
+ MakeDir($(BUILDI18NDIR)/$(POSTLOCALELIB)/$(POSTLOCALE)) @@\
+ RemoveFile($(BUILDI18NDIR)/$(POSTLOCALELIB)/$(POSTLOCALE)/libname.so.$(SOXI18NREV)) @@\
+ cd $(BUILDI18NDIR)/$(POSTLOCALELIB)/$(POSTLOCALE) && $(LN) $(BUILDI18NTOP)/$(CURRENT_DIR)/Concat(lib,libname.so.rev) ./libname.so.rev
+# endif
+#endif
+
+#ifndef Xi18nLibraryTarget
+# if 0 /* !CrossCompiling */
+# define Xi18nLibraryTarget(libname) @@\
+all:: libname.so.$(SOXI18NREV) @@\
+libname.so.$(SOXI18NREV): $(OBJS) @@\
+ $(RM) $@~ @@\
+ (cd .; T=`echo $@ | sed 's/\.[^\.]*$$//'`; $(LD) -o ./$@~ $(SHLIBLDFLAGS) $(OBJS) $(REQUIREDLIBS) $(EXTRA_SHLIBLDFLAGS); $(RM) $$T && $(LN) $@ $$T) @@\
+ $(RM) $@ @@\
+ $(MV) $@~ $@ @@\
+install:: libname.so.$(SOXI18NREV) @@\
+ @if [ -d $(DESTDIR)$(XLOCALEDIR)/$(POSTLOCALELIB)/$(POSTLOCALE) ]; then set +x; \ @@\
+ else (set -x; $(MKDIRHIER) $(DESTDIR)$(XLOCALEDIR)/$(POSTLOCALELIB)/$(POSTLOCALE)); fi @@\
+ $(RM) $(DESTDIR)$(XLOCALEDIR)/$(POSTLOCALELIB)/$(POSTLOCALE)/libname.so.$(SOXI18NREV) @@\
+ $(INSTALL) $(INSTALLFLAGS) $(INSTLIBFLAGS) libname.so.$(SOXI18NREV) $(DESTDIR)$(XLOCALEDIR)/$(POSTLOCALELIB)/$(POSTLOCALE)
+# else
+# define Xi18nLibraryTarget(libname) @@\
+DependTarget() @@\
+SharedLibraryTarget(libname,$(SOXI18NREV),$(OBJS),.,.) @@\
+LinkBuildXi18nLibrary(libname,$(SOXI18NREV)) @@\
+install:: Concat(lib,libname.so.$(SOXI18NREV)) @@\
+ MakeDir($(DESTDIR)$(XLOCALEDIR)/$(POSTLOCALELIB)/$(POSTLOCALE)) @@\
+ $(RM) $(DESTDIR)$(XLOCALEDIR)/$(POSTLOCALELIB)/$(POSTLOCALE)/libname.so.$(SOXI18NREV) @@\
+ $(INSTALL) $(INSTALLFLAGS) $(INSTLIBFLAGS) Concat(lib,libname.so.$(SOXI18NREV)) $(DESTDIR)$(XLOCALEDIR)/$(POSTLOCALELIB)/$(POSTLOCALE)/libname.so.$(SOXI18NREV)
+
+# endif
+#endif
diff --git a/nx-X11/lib/X11/xlibi18n/im/Imakefile b/nx-X11/lib/X11/xlibi18n/im/Imakefile
new file mode 100644
index 000000000..3c638b1a8
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/im/Imakefile
@@ -0,0 +1,10 @@
+XCOMM $XConsortium: Imakefile,v 1.27 94/04/07 15:01:48 rws Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = ximcp
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(LINTSUBDIRS))
+MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln)
diff --git a/nx-X11/lib/X11/xlibi18n/im/ximcp/Imakefile b/nx-X11/lib/X11/xlibi18n/im/ximcp/Imakefile
new file mode 100644
index 000000000..f3b85ac84
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/im/ximcp/Imakefile
@@ -0,0 +1,53 @@
+XCOMM $XFree86$
+
+#include "../../Xi18nLib.conf"
+
+ EXTRA_INCLUDES = -I../../..
+ SRCS = imCallbk.c imDefFlt.c imDefIc.c \
+ imDefIm.c imDefLkup.c imDispch.c imEvToWire.c \
+ imExten.c imImSw.c imInsClbk.c imInt.c \
+ imLcFlt.c imLcGIc.c imLcIc.c imLcIm.c imLcLkup.c \
+ imLcPrs.c imLcSIc.c \
+ imRm.c imRmAttr.c \
+ imThaiFlt.c imThaiIc.c imThaiIm.c \
+ imTrX.c imTransR.c imTrans.c
+ OBJS = ${SRCS:.c=.o}
+
+ CONN_DEFINES = ConnectionFlags
+ XTRANS_XIM_DEFINES = -DXIM_t -DTRANS_CLIENT
+ REQUIREDLIBS = SharedXlibi18nReqs
+
+LinkSourceFile(imCallbk.c, ../../..)
+LinkSourceFile(imDefFlt.c, ../../..)
+LinkSourceFile(imDefIc.c, ../../..)
+LinkSourceFile(imDefIm.c, ../../..)
+LinkSourceFile(imDefLkup.c, ../../..)
+LinkSourceFile(imDispch.c, ../../..)
+LinkSourceFile(imEvToWire.c, ../../..)
+LinkSourceFile(imExten.c, ../../..)
+LinkSourceFile(imImSw.c, ../../..)
+LinkSourceFile(imInsClbk.c, ../../..)
+LinkSourceFile(imInt.c, ../../..)
+LinkSourceFile(imLcFlt.c, ../../..)
+LinkSourceFile(imLcGIc.c, ../../..)
+LinkSourceFile(imLcIc.c, ../../..)
+LinkSourceFile(imLcIm.c, ../../..)
+LinkSourceFile(imLcLkup.c, ../../..)
+LinkSourceFile(imLcPrs.c, ../../..)
+LinkSourceFile(imLcSIc.c, ../../..)
+LinkSourceFile(imThaiFlt.c, ../../..)
+LinkSourceFile(imThaiIc.c, ../../..)
+LinkSourceFile(imThaiIm.c, ../../..)
+LinkSourceFile(imRm.c, ../../..)
+LinkSourceFile(imRmAttr.c, ../../..)
+LinkSourceFile(imTrX.c, ../../..)
+LinkSourceFile(imTransR.c, ../../..)
+LinkSourceFile(imTrans.c, ../../..)
+
+SpecialCLibObjectRule(imTransR,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES))
+SpecialCLibObjectRule(imTrans,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES))
+#if BuildXKBlib
+SpecialCLibObjectRule(imConv,$(ICONFIGFILES),$(XKB_DEFINES))
+#endif
+
+Xi18nLibraryTarget(ximcp)
diff --git a/nx-X11/lib/X11/xlibi18n/im/ximcp/Ximcp.mapfile b/nx-X11/lib/X11/xlibi18n/im/ximcp/Ximcp.mapfile
new file mode 100644
index 000000000..ab2f1a30f
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/im/ximcp/Ximcp.mapfile
@@ -0,0 +1,6 @@
+{
+ local:
+ *;
+ global:
+ _XimOpenIM;
+};
diff --git a/nx-X11/lib/X11/xlibi18n/lc/Imakefile b/nx-X11/lib/X11/xlibi18n/lc/Imakefile
new file mode 100644
index 000000000..a4eaeeb6f
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/lc/Imakefile
@@ -0,0 +1,10 @@
+XCOMM $XConsortium: Imakefile,v 1.27 94/04/07 15:01:48 rws Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = gen def Utf8 xlocale
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(LINTSUBDIRS))
+MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln)
diff --git a/nx-X11/lib/X11/xlibi18n/lc/Utf8/Imakefile b/nx-X11/lib/X11/xlibi18n/lc/Utf8/Imakefile
new file mode 100644
index 000000000..9ba460bdb
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/lc/Utf8/Imakefile
@@ -0,0 +1,13 @@
+XCOMM $XFree86$
+
+#include "../../Xi18nLib.conf"
+
+ EXTRA_INCLUDES = -I../../..
+ XI18NLIBNAME = xlibi18n
+ SRCS = lcUTF8Load.c
+ OBJS = ${SRCS:.c=.o}
+ REQUIREDLIBS = SharedXlibi18nReqs
+
+LinkSourceFile(lcUTF8Load.c, ../../..)
+
+Xi18nLibraryTarget(xlcUTF8Load)
diff --git a/nx-X11/lib/X11/xlibi18n/lc/def/Imakefile b/nx-X11/lib/X11/xlibi18n/lc/def/Imakefile
new file mode 100644
index 000000000..2188d237b
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/lc/def/Imakefile
@@ -0,0 +1,13 @@
+XCOMM $XFree86$
+
+#include "../../Xi18nLib.conf"
+
+ EXTRA_INCLUDES = -I../../..
+ XI18NLIBNAME = xlcDef
+ SRCS = lcDefConv.c
+ OBJS = ${SRCS:.c=.o}
+ REQUIREDLIBS = SharedXlibi18nReqs
+
+LinkSourceFile(lcDefConv.c, ../../..)
+
+Xi18nLibraryTarget(xlcDef)
diff --git a/nx-X11/lib/X11/xlibi18n/lc/def/Xlc.mapfile b/nx-X11/lib/X11/xlibi18n/lc/def/Xlc.mapfile
new file mode 100644
index 000000000..ce4fc69bd
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/lc/def/Xlc.mapfile
@@ -0,0 +1,6 @@
+{
+ local:
+ *;
+ global:
+ _XlcDefaultLoader;
+};
diff --git a/nx-X11/lib/X11/xlibi18n/lc/gen/Imakefile b/nx-X11/lib/X11/xlibi18n/lc/gen/Imakefile
new file mode 100644
index 000000000..7f54ff1b3
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/lc/gen/Imakefile
@@ -0,0 +1,13 @@
+XCOMM $XFree86$
+
+#include "../../Xi18nLib.conf"
+
+ EXTRA_INCLUDES = -I../../..
+ XI18NLIBNAME = xlibi18n
+ SRCS = lcGenConv.c
+ OBJS = ${SRCS:.c=.o}
+ REQUIREDLIBS = SharedXlibi18nReqs
+
+LinkSourceFile(lcGenConv.c, ../../..)
+
+Xi18nLibraryTarget(xlibi18n)
diff --git a/nx-X11/lib/X11/xlibi18n/lc/gen/Xlc.mapfile b/nx-X11/lib/X11/xlibi18n/lc/gen/Xlc.mapfile
new file mode 100644
index 000000000..cd6ba7569
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/lc/gen/Xlc.mapfile
@@ -0,0 +1,6 @@
+{
+ local:
+ *;
+ global:
+ _XlcGenericLoader;
+};
diff --git a/nx-X11/lib/X11/xlibi18n/lc/xlocale/Imakefile b/nx-X11/lib/X11/xlibi18n/lc/xlocale/Imakefile
new file mode 100644
index 000000000..1ece955fc
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/lc/xlocale/Imakefile
@@ -0,0 +1,15 @@
+XCOMM $XFree86$
+
+#include "../../Xi18nLib.conf"
+
+ EXTRA_INCLUDES = -I../../..
+ XI18NLIBNAME = xlocale
+ SRCS = lcEuc.c lcSjis.c lcJis.c
+ OBJS = ${SRCS:.c=.o}
+ REQUIREDLIBS = SharedXlibi18nReqs
+
+LinkSourceFile(lcEuc.c, ../../..)
+LinkSourceFile(lcSjis.c, ../../..)
+LinkSourceFile(lcJis.c, ../../..)
+
+Xi18nLibraryTarget(xlocale)
diff --git a/nx-X11/lib/X11/xlibi18n/om/Imakefile b/nx-X11/lib/X11/xlibi18n/om/Imakefile
new file mode 100644
index 000000000..fc8335e9a
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/om/Imakefile
@@ -0,0 +1,10 @@
+XCOMM $XConsortium: Imakefile,v 1.27 94/04/07 15:01:48 rws Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = generic
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(LINTSUBDIRS))
+MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln)
diff --git a/nx-X11/lib/X11/xlibi18n/om/generic/Imakefile b/nx-X11/lib/X11/xlibi18n/om/generic/Imakefile
new file mode 100644
index 000000000..70e009be6
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/om/generic/Imakefile
@@ -0,0 +1,21 @@
+XCOMM $XFree86$
+
+#include "../../Xi18nLib.conf"
+
+ EXTRA_INCLUDES = -I../../..
+ SRCS = omDefault.c omGeneric.c omImText.c omText.c \
+ omTextEsc.c omTextExt.c omTextPer.c omXChar.c
+
+ OBJS = ${SRCS:.c=.o}
+ REQUIREDLIBS = SharedXlibi18nReqs
+
+LinkSourceFile(omDefault.c, ../../..)
+LinkSourceFile(omGeneric.c, ../../..)
+LinkSourceFile(omImText.c, ../../..)
+LinkSourceFile(omText.c, ../../..)
+LinkSourceFile(omTextEsc.c, ../../..)
+LinkSourceFile(omTextExt.c, ../../..)
+LinkSourceFile(omTextPer.c, ../../..)
+LinkSourceFile(omXChar.c, ../../..)
+
+Xi18nLibraryTarget(xomGeneric)
diff --git a/nx-X11/lib/X11/xlibi18n/om/generic/Xom.mapfile b/nx-X11/lib/X11/xlibi18n/om/generic/Xom.mapfile
new file mode 100644
index 000000000..8b710460f
--- /dev/null
+++ b/nx-X11/lib/X11/xlibi18n/om/generic/Xom.mapfile
@@ -0,0 +1,6 @@
+{
+ local:
+ *;
+ global:
+ _XomGenericOpenOM;
+};
diff --git a/nx-X11/lib/X11/xyY.c b/nx-X11/lib/X11/xyY.c
new file mode 100644
index 000000000..63e80bc59
--- /dev/null
+++ b/nx-X11/lib/X11/xyY.c
@@ -0,0 +1,380 @@
+/* $Xorg: xyY.c,v 1.3 2000/08/17 19:45:23 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIExyY.c
+ *
+ * DESCRIPTION
+ * This file contains routines that support the CIE xyY
+ * color space to include conversions to and from the CIE
+ * XYZ space.
+ *
+ * DOCUMENTATION
+ * "TekColor Color Management System, System Implementor's Manual"
+ */
+/* $XFree86: xc/lib/X11/xyY.c,v 1.3 2001/01/17 19:41:57 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+/*
+ * DEFINES
+ */
+#define EPS 0.00001 /* some extremely small number */
+#ifdef DBL_EPSILON
+# define XMY_DBL_EPSILON DBL_EPSILON
+#else
+# define XMY_DBL_EPSILON 0.00001
+#endif
+
+/*
+ * FORWARD DECLARATIONS
+ */
+
+static int CIExyY_ParseString(register char *spec, XcmsColor *pColor);
+static Status XcmsCIExyY_ValidSpec(XcmsColor *pColor);
+
+
+/*
+ * LOCAL VARIABLES
+ */
+
+ /*
+ * NULL terminated list of functions applied to get from CIExyY to CIEXYZ
+ */
+static XcmsConversionProc Fl_CIExyY_to_CIEXYZ[] = {
+ XcmsCIExyYToCIEXYZ,
+ NULL
+};
+
+ /*
+ * NULL terminated list of functions applied to get from CIEXYZ to CIExyY
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_CIExyY[] = {
+ XcmsCIEXYZToCIExyY,
+ NULL
+};
+
+
+/*
+ * GLOBALS
+ */
+
+ /*
+ * CIE xyY Color Space
+ */
+XcmsColorSpace XcmsCIExyYColorSpace =
+ {
+ _XcmsCIExyY_prefix, /* prefix */
+ XcmsCIExyYFormat, /* id */
+ CIExyY_ParseString, /* parseString */
+ Fl_CIExyY_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_CIExyY, /* from_CIEXYZ */
+ 1
+ };
+
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CIExyY_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+CIExyY_ParseString(
+ register char *spec,
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsCIExyYFormat.
+ * The assumed CIExyY string syntax is:
+ * CIExyY:<x>/<y>/<Y>
+ * Where x, y, and Y are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ * 0 if failed, non-zero otherwise.
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsCIExyY_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.CIExyY.x,
+ &pColor->spec.CIExyY.y,
+ &pColor->spec.CIExyY.Y) != 3) {
+ return(XcmsFailure);
+ }
+ pColor->format = XcmsCIExyYFormat;
+ pColor->pixel = 0;
+ return(XcmsCIExyY_ValidSpec(pColor));
+}
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CIExyY_ValidSpec()
+ *
+ * SYNOPSIS
+ */
+static Status
+XcmsCIExyY_ValidSpec(
+ XcmsColor *pColor)
+/*
+ * DESCRIPTION
+ * Checks a valid CIExyY color specification.
+ *
+ * RETURNS
+ * XcmsFailure if invalid.
+ * XcmsSuccess if valid.
+ *
+ */
+{
+ if (pColor->format != XcmsCIExyYFormat
+ ||
+ (pColor->spec.CIExyY.x < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIExyY.x > 1.0 + XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIExyY.y < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIExyY.y > 1.0 + XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIExyY.Y < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIExyY.Y > 1.0 + XMY_DBL_EPSILON)) {
+ return(XcmsFailure);
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIExyYToCIEXYZ - convert CIExyY to CIEXYZ
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIExyYToCIEXYZ(ccc, pxyY_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pxyY_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIExyY format to CIEXYZ format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ */
+{
+ XcmsColor *pColor = pColors_in_out;
+ XcmsColor whitePt;
+ XcmsCIEXYZ XYZ_return;
+ XcmsFloat div; /* temporary storage in case divisor is zero */
+ XcmsFloat u, v, x, y, z; /* temporary storage */
+ register int i;
+
+ /*
+ * Check arguments
+ */
+ if (pxyY_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+ /* Make sure original format is CIExyY and valid */
+ if (!XcmsCIExyY_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ if ((div = (-2 * pColor->spec.CIExyY.x) + (12 * pColor->spec.CIExyY.y) + 3) == 0.0) {
+ /* Note that the divisor is zero */
+ /* This return is abitrary. */
+ XYZ_return.X = 0;
+ XYZ_return.Y = 0;
+ XYZ_return.Z = 0;
+ } else {
+ /*
+ * Make sure white point is in CIEXYZ form
+ */
+ if (pxyY_WhitePt->format != XcmsCIEXYZFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pxyY_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL, 1,
+ XcmsCIEXYZFormat)) {
+ return(XcmsFailure);
+ }
+ pxyY_WhitePt = &whitePt;
+ }
+
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (pxyY_WhitePt->spec.CIEXYZ.Y != 1.0) {
+ return(XcmsFailure);
+ }
+
+ /* Convert from xyY to uvY to XYZ */
+ u = (4 * pColor->spec.CIExyY.x) / div;
+ v = (9 * pColor->spec.CIExyY.y) / div;
+ div = (6.0 * u) - (16.0 * v) + 12.0;
+ if (div == 0.0) {
+ /* Note that the divisor is zero */
+ /* This return is abitrary. */
+ if ((div = (6.0 * whitePt.spec.CIEuvY.u_prime) -
+ (16.0 * whitePt.spec.CIEuvY.v_prime) + 12.0) == 0.0) {
+ div = EPS;
+ }
+ x = 9.0 * whitePt.spec.CIEuvY.u_prime / div;
+ y = 4.0 * whitePt.spec.CIEuvY.u_prime / div;
+ } else {
+ /* convert u, v to small xyz */
+ x = 9.0 * u / div;
+ y = 4.0 * v / div;
+ }
+ z = 1.0 - x - y;
+ if (y == 0.0) y = EPS; /* Have to worry about divide by 0 */
+ XYZ_return.Y = pColor->spec.CIExyY.Y;
+ XYZ_return.X = x * XYZ_return.Y / y;
+ XYZ_return.Z = z * XYZ_return.Y / y;
+ }
+
+ /* Copy result to pColor */
+ memcpy ((char *)&pColor->spec, (char *)&XYZ_return, sizeof(XcmsCIEXYZ));
+
+ /* Identify that the format is now CIEXYZ */
+ pColor->format = XcmsCIEXYZFormat;
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEXYZToCIExyY - convert CIEXYZ to CIExyY
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIEXYZToCIExyY(ccc, pxyY_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pxyY_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIEXYZ format to CIExyY format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsColor *pColor = pColors_in_out;
+ XcmsCIExyY xyY_return;
+ XcmsFloat div; /* temporary storage in case divisor is zero */
+ register int i;
+
+ /*
+ * Check arguments
+ * pxyY_WhitePt ignored
+ */
+ if (pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ if (!_XcmsCIEXYZ_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+ /* Now convert for XYZ to xyY */
+ if ((div = pColor->spec.CIEXYZ.X + pColor->spec.CIEXYZ.Y + pColor->spec.CIEXYZ.Z) == 0.0) {
+ div = EPS;
+ }
+ xyY_return.x = pColor->spec.CIEXYZ.X / div;
+ xyY_return.y = pColor->spec.CIEXYZ.Y / div;
+ xyY_return.Y = pColor->spec.CIEXYZ.Y;
+
+ /* Copy result to pColor */
+ memcpy ((char *)&pColor->spec, (char *)&xyY_return, sizeof(XcmsCIExyY));
+
+ /* Identify that the format is now CIEXYZ */
+ pColor->format = XcmsCIExyYFormat;
+ }
+ return(XcmsSuccess);
+}
diff --git a/nx-X11/lib/XRes/Imakefile b/nx-X11/lib/XRes/Imakefile
new file mode 100644
index 000000000..410f57ff5
--- /dev/null
+++ b/nx-X11/lib/XRes/Imakefile
@@ -0,0 +1,34 @@
+XCOMM $XFree86: xc/lib/XRes/Imakefile,v 1.3 2003/10/13 21:19:28 herrb Exp $
+
+#define DoNormalLib NormalLibXRes
+#define DoSharedLib SharedLibXRes
+#define DoDebugLib DebugLibXRes
+#define DoProfileLib ProfileLibXRes
+#define LibName XRes
+#define SoRev SOXRESREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXResReqs
+REQUIREDLIBS = SharedXResReqs
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ SRCS = XRes.c
+ OBJS = XRes.o
+ LINTLIBS = $(LINTXLIB)
+
+#include <Library.tmpl>
+
+MANSUFFIX=$(LIBMANSUFFIX)
+InstallManPage(LibName,$(LIBMANDIR))
+#if ExpandManNames
+InstallManPageAliases(LibName,$(LIBMANDIR),XResQueryExtension XResQueryVersion XResQueryClients XResQueryClientResources XResQueryClientPixmapBytes)
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/XRes/XRes-def.cpp b/nx-X11/lib/XRes/XRes-def.cpp
new file mode 100644
index 000000000..1da4ccc16
--- /dev/null
+++ b/nx-X11/lib/XRes/XRes-def.cpp
@@ -0,0 +1,9 @@
+LIBRARY XRes
+VERSION LIBRARY_VERSION
+EXPORTS
+ XResQueryClientPixmapBytes
+ XResQueryClientResources
+ XResQueryClients
+ XResQueryExtension
+ XResQueryVersion
+/* $XFree86$ */
diff --git a/nx-X11/lib/XRes/XRes.c b/nx-X11/lib/XRes/XRes.c
new file mode 100644
index 000000000..06cc78d12
--- /dev/null
+++ b/nx-X11/lib/XRes/XRes.c
@@ -0,0 +1,233 @@
+/*
+ Copyright (c) 2002 XFree86 Inc
+*/
+/* $XFree86: xc/lib/XRes/XRes.c,v 1.3 2002/03/10 22:06:53 mvojkovi Exp $ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdlib.h>
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/XResproto.h>
+#include <X11/extensions/XRes.h>
+
+
+static XExtensionInfo _xres_ext_info_data;
+static XExtensionInfo *xres_ext_info = &_xres_ext_info_data;
+static char *xres_extension_name = XRES_NAME;
+
+#define XResCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xres_extension_name, val)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xres_ext_info)
+
+static XExtensionHooks xres_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xres_ext_info,
+ xres_extension_name,
+ &xres_extension_hooks,
+ 0, NULL)
+
+Bool XResQueryExtension (
+ Display *dpy,
+ int *event_basep,
+ int *error_basep
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+Status XResQueryVersion(
+ Display *dpy,
+ int *major_versionp,
+ int *minor_versionp
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXResQueryVersionReply rep;
+ xXResQueryVersionReq *req;
+
+ XResCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (XResQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->XResReqType = X_XResQueryVersion;
+ req->client_major = XRES_MAJOR_VERSION;
+ req->client_minor = XRES_MINOR_VERSION;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ *major_versionp = rep.server_major;
+ *minor_versionp = rep.server_minor;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
+
+Status XResQueryClients (
+ Display *dpy,
+ int *num_clients,
+ XResClient **clients
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXResQueryClientsReq *req;
+ xXResQueryClientsReply rep;
+ XResClient *clnts;
+ int result = 0;
+
+ *num_clients = 0;
+ *clients = NULL;
+
+ XResCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (XResQueryClients, req);
+ req->reqType = info->codes->major_opcode;
+ req->XResReqType = X_XResQueryClients;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+
+ if(rep.num_clients) {
+ if((clnts = Xmalloc(sizeof(XResClient) * rep.num_clients))) {
+ xXResClient scratch;
+ int i;
+
+ for(i = 0; i < rep.num_clients; i++) {
+ _XRead(dpy, (char*)&scratch, sz_xXResClient);
+ clnts[i].resource_base = scratch.resource_base;
+ clnts[i].resource_mask = scratch.resource_mask;
+ }
+ *clients = clnts;
+ *num_clients = rep.num_clients;
+ result = 1;
+ } else {
+ _XEatData(dpy, rep.length << 2);
+ }
+ }
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return result;
+}
+
+Status XResQueryClientResources (
+ Display *dpy,
+ XID xid,
+ int *num_types,
+ XResType **types
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXResQueryClientResourcesReq *req;
+ xXResQueryClientResourcesReply rep;
+ XResType *typs;
+ int result = 0;
+
+ *num_types = 0;
+ *types = NULL;
+
+ XResCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (XResQueryClientResources, req);
+ req->reqType = info->codes->major_opcode;
+ req->XResReqType = X_XResQueryClientResources;
+ req->xid = xid;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+
+ if(rep.num_types) {
+ if((typs = Xmalloc(sizeof(XResType) * rep.num_types))) {
+ xXResType scratch;
+ int i;
+
+ for(i = 0; i < rep.num_types; i++) {
+ _XRead(dpy, (char*)&scratch, sz_xXResType);
+ typs[i].resource_type = scratch.resource_type;
+ typs[i].count = scratch.count;
+ }
+ *types = typs;
+ *num_types = rep.num_types;
+ result = 1;
+ } else {
+ _XEatData(dpy, rep.length << 2);
+ }
+ }
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return result;
+}
+
+Status XResQueryClientPixmapBytes (
+ Display *dpy,
+ XID xid,
+ unsigned long *bytes
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXResQueryClientPixmapBytesReq *req;
+ xXResQueryClientPixmapBytesReply rep;
+
+ *bytes = 0;
+
+ XResCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (XResQueryClientPixmapBytes, req);
+ req->reqType = info->codes->major_opcode;
+ req->XResReqType = X_XResQueryClientPixmapBytes;
+ req->xid = xid;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+
+#ifdef LONG64
+ *bytes = (rep.bytes_overflow * 4294967295) + rep.bytes;
+#else
+ *bytes = rep.bytes_overflow ? 0xffffffff : rep.bytes;
+#endif
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
diff --git a/nx-X11/lib/XRes/XRes.man b/nx-X11/lib/XRes/XRes.man
new file mode 100644
index 000000000..25c27b997
--- /dev/null
+++ b/nx-X11/lib/XRes/XRes.man
@@ -0,0 +1,140 @@
+.\"
+.\" $XdotOrg: xc/lib/XRes/XRes.man,v 1.2 2004/04/23 18:43:36 eich Exp $
+.\" $XFree86: xc/lib/XRes/XRes.man,v 1.2 2003/10/13 21:22:54 herrb Exp $
+.\"
+.\" Copyright (C) 1994-2003 The XFree86 Project, Inc. All Rights Reserved.
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" 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 NON-INFRINGEMENT.
+.\" IN NO EVENT SHALL THE XFREE86 PROJECT 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 XFree86 Project
+.\" 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 XFree86 Project.
+.\"
+.TH XRes 3 __vendorversion__
+.SH NAME
+XRes \- X-Resource extension client library
+.SH SYNOPSIS
+.B #include <X11/extension/XRes.h>
+.PP
+.nf
+.ta .5i 2i
+typedef struct {
+ XID resource_base;
+ XID resource_mask;
+} XResClient;
+
+typedef struct {
+ Atom resource_type;
+ unsigned int count;
+} XResType;
+.fi
+.HP
+Bool XResQueryExtension(Display *\fIdpy\fP,
+int *\fIevent_basep\fP, int *\fIerror_basep\fP\^);
+.HP
+Status XResQueryVersion(Display *\fIdpy\fP, int *\fImajor_versionp\fP,
+int *\fIminor_versionp\fP\^);
+.HP
+Status XResQueryClients(Display *\fIdpy\fP, int *\fInum_clients\fP,
+XResClient **\fIclients\fP\^);
+.HP
+Status XResQueryClientResources(Display *\fIdpy\fP, XID \fIxid\fP,
+int *\fInum_types\fP, XResType **\fItypes\fP\^);
+.HP
+Status XResQueryClientPixmapBytes(Display *\fIdpy\fP, XID \fIxid\fP,
+unsigned long *\fIbytes\fP\^);
+.PP
+.SH DESCRIPTION
+.B X-Resource
+is an extension that allows a client to query the X
+server about its usage of various resources. It should not be mixed
+with the X resource database access functions.
+.PP
+.B XResQueryExtension
+returns
+.B True
+if the
+.I XRes
+extension is available on the given display.
+A client must call
+.B XResQueryExtension
+before calling any other XRes function in order
+to negotiate a compatible protocol version; otherwise the client will
+get undefined behavior (XRes may or may not work).
+.PP
+.B XResQueryVersion
+returns
+.B True
+if the request succeeded; the values of the major and minor protocol
+versions supported by the server are returned in
+.I major_versionp
+and
+.I minor_versionp .
+.PP
+.PP
+.B XResQueryClients
+fills a list of clients of the given display. For each client it
+returns in the
+.I XResClient
+structure a mask and a base value of the resources used by these
+clients.
+Returns
+.B True
+on success or
+.B False
+on failure.
+.PP
+.B XResQueryClientResources
+fills a list of
+XResType
+structures, indicating for each resource type allocated by the client its
+name (as an Atom) and the number of resources of this type allocated.
+Returns
+.B True
+on success or
+.B False
+on failure.
+.PP
+.B XresQueryClientPixmapBytes
+gives, for resources of type
+.I PIXMAP
+the total number of bytes allocated in the X server by the given
+client.
+Returns
+.B True
+on success or
+.B False
+on failure.
+.SH "ERRORS"
+.B XResQueryClientResources
+and
+.B XResQueryClientPixmapBytes
+will return
+.I BadValue
+if passed an illegal client identifier.
+.SH "SEE ALSO"
+X(__miscmansuffix__)
+.SH AUTHOR
+Mark Vojkovich, originally for The XFree86 Project Inc.
+.SH STABILITY
+This API is considered as experimental. The XRes library major
+revision may be incremented whenever incompatible changes are done to
+the API without notice. Use with care.
diff --git a/nx-X11/lib/XTrap/Imakefile b/nx-X11/lib/XTrap/Imakefile
new file mode 100644
index 000000000..54bfdd6dd
--- /dev/null
+++ b/nx-X11/lib/XTrap/Imakefile
@@ -0,0 +1,30 @@
+XCOMM $XFree86$
+
+#define DoNormalLib NormalLibXTrap
+#define DoSharedLib SharedLibXTrap
+#define DoDebugLib DebugLibXTrap
+#define DoProfileLib ProfileLibXTrap
+#define LibName XTrap
+#define SoRev SOXTRAPREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXmuReqs
+REQUIREDLIBS = SharedXmuReqs
+#endif
+
+XCOMM wish this weren't necessary, but need xlib and xt internals...
+INCLUDES=-I$(TOP)/include -I$(TOOLKITSRC)
+
+
+ SRCS = XECallBcks.c XEConTxt.c XEDsptch.c XEPrInfo.c \
+ XERqsts.c XEStrMap.c XETrapInit.c XEWrappers.c
+ OBJS = XECallBcks.o XEConTxt.o XEDsptch.o XEPrInfo.o \
+ XERqsts.o XEStrMap.o XETrapInit.o XEWrappers.o
+
+LINTLIBS = $(LINTXLIB)
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/XTrap/XECallBcks.c b/nx-X11/lib/XTrap/XECallBcks.c
new file mode 100644
index 000000000..fb1e0893e
--- /dev/null
+++ b/nx-X11/lib/XTrap/XECallBcks.c
@@ -0,0 +1,175 @@
+/* $XFree86$ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
+
+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.
+
+*****************************************************************************/
+/*
+ *
+ * CONTRIBUTORS:
+ *
+ * Dick Annicchiarico
+ * Robert Chesler
+ * Dan Coutu
+ * Gene Durso
+ * Marc Evans
+ * Alan Jamison
+ * Mark Henry
+ * Ken Miller
+ *
+ */
+/*
+ * This file contains XETrap Callback initilization routines.
+ * The callback data hang off of the TC and are freed as part of the
+ * XEFreeTC routine.
+ */
+
+#include <X11/Xos.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+
+int XEAddRequestCB(XETC *tc, CARD8 req, void_function func, BYTE *data)
+{
+ if (!tc->values.req_cb)
+ { /* This is the first time for this particular TC, need to malloc */
+ if ((tc->values.req_cb =
+ (XETrapCB *)XtCalloc(256L,sizeof(XETrapCB))) == NULL)
+ {
+ /* XtCalloc already reported the error */
+ return(False);
+ }
+ }
+ tc->values.req_cb[req].func = func;
+ tc->values.req_cb[req].data = data;
+
+ return(True);
+}
+
+int XEAddRequestCBs(XETC *tc, ReqFlags req_flags, void_function func,
+ BYTE *data)
+{
+ int i;
+ int status = True;
+
+ for (i=0; i<=255L; i++)
+ {
+ if (BitIsTrue(req_flags, i))
+ {
+ status = XEAddRequestCB(tc, (CARD8)i, func, data);
+ }
+ }
+ return(status);
+}
+
+int XEAddEventCB(XETC *tc, CARD8 evt, void_function func, BYTE *data)
+{
+ if (!tc->values.evt_cb)
+ { /* This is the first time for this particular TC, need to malloc */
+ if ((tc->values.evt_cb =
+ (XETrapCB *)XtCalloc(XETrapCoreEvents,sizeof(XETrapCB))) == NULL)
+ {
+ /* XtCalloc already reported the error */
+ return(False);
+ }
+ }
+ tc->values.evt_cb[evt].func = func;
+ tc->values.evt_cb[evt].data = data;
+
+ return(True);
+}
+
+int XEAddEventCBs(XETC *tc, EventFlags evt_flags, void_function func,
+ BYTE *data)
+{
+ int i;
+ int status = True;
+
+ for (i=KeyPress; i<=MotionNotify; i++)
+ {
+ if (BitIsTrue(evt_flags, i))
+ {
+ status = XEAddEventCB(tc, (CARD8)i, func, data);
+ }
+ }
+ return(status);
+}
+
+void XERemoveRequestCB(XETC *tc, CARD8 req)
+{
+ if (!tc->values.req_cb)
+ { /* We gotta problem! CB struct not allocated! */
+ return;
+ }
+ tc->values.req_cb[req].func = (void_function)NULL;
+ tc->values.req_cb[req].data = (BYTE *)NULL;
+ return;
+}
+void XERemoveRequestCBs(XETC *tc, ReqFlags req_flags)
+{
+ int i;
+
+ for (i=0; i<=255L; i++)
+ {
+ if (BitIsTrue(req_flags, i))
+ {
+ XERemoveRequestCB(tc, (CARD8)i);
+ }
+ }
+}
+
+void XERemoveAllRequestCBs(XETC *tc)
+{
+ if (!tc->values.req_cb)
+ { /* We gotta problem! CB struct not allocated! */
+ return;
+ }
+ XtFree((XtPointer)tc->values.req_cb);
+}
+
+void XERemoveEventCB(XETC *tc, CARD8 evt)
+{
+ if (!tc->values.evt_cb)
+ { /* We gotta problem! CB struct not allocated! */
+ return;
+ }
+ tc->values.evt_cb[evt].func = (void_function)NULL;
+ tc->values.evt_cb[evt].data = (BYTE *)NULL;
+ return;
+}
+
+void XERemoveEventCBs(XETC *tc, EventFlags evt_flags)
+{
+ int i;
+
+ for (i=KeyPress; i<=MotionNotify; i++)
+ {
+ if (BitIsTrue(evt_flags, i))
+ {
+ XERemoveEventCB(tc, (CARD8)i);
+ }
+ }
+}
+
+void XERemoveAllEventCBs(XETC *tc)
+{
+ if (!tc->values.evt_cb)
+ { /* We gotta problem! CB struct not allocated! */
+ return;
+ }
+ XtFree((XtPointer)tc->values.evt_cb);
+}
diff --git a/nx-X11/lib/XTrap/XEConTxt.c b/nx-X11/lib/XTrap/XEConTxt.c
new file mode 100644
index 000000000..7da96894b
--- /dev/null
+++ b/nx-X11/lib/XTrap/XEConTxt.c
@@ -0,0 +1,589 @@
+/* $XFree86: xc/lib/XTrap/XEConTxt.c,v 1.1 2001/11/02 23:29:27 dawes Exp $ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991, 1994 by Digital Equipment Corp.,
+Maynard, MA
+
+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.
+
+*****************************************************************************/
+/*
+ *
+ * CONTRIBUTORS:
+ *
+ * Dick Annicchiarico
+ * Robert Chesler
+ * Dan Coutu
+ * Gene Durso
+ * Marc Evans
+ * Alan Jamison
+ * Mark Henry
+ * Ken Miller
+ *
+ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+
+
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+
+#ifndef TRUE
+# define TRUE 1L
+#endif
+#ifndef FALSE
+# define FALSE 0L
+#endif
+
+extern char *extensionData;
+
+static XETC TC;
+
+/*
+ * This function is used to create a new XTrap context structure. The new
+ * context is initialized to a hard coded default, then modified by the
+ * valuemask and values passed in by the caller.
+ */
+
+XETC *XECreateTC(Display *dpy, CARD32 valuemask, XETCValues *value)
+{
+ static Bool firsttime = True;
+ register XETC *tc = &TC;
+ register XETC *last_tc;
+ XETrapGetAvailRep rep;
+
+ /* If this is the first time here, then initialize the default TC */
+ if (firsttime == True)
+ {
+ firsttime = False;
+ /* The first Trap Context is the Template (default) TC */
+ (void)memset(tc,0L,sizeof(tc));
+ tc->eventBase = 0x7FFFFFFFL;
+ tc->errorBase = 0x7FFFFFFFL;
+ tc->values.v.max_pkt_size = 0x7FFFL;
+ }
+
+ /* Position to the end of the list */
+ for (;tc->next != NULL; tc = tc->next);
+
+ /* Allocate memory for the new context */
+ last_tc = tc; /* save the address of the last on the list */
+ if ((tc = (tc->next = (XETC *)XtMalloc(sizeof(*tc)))) == NULL)
+ { /* No memory to build TC, XtMalloc has already reported the error */
+ return(NULL);
+ }
+
+ /* Use the original TC as the template to start from */
+ (void)memcpy(tc,&TC,sizeof(TC));
+ tc->next = NULL;
+ tc->dpy = dpy;
+ tc->xmax_size = XMaxRequestSize(tc->dpy);
+
+ /* Initialize Extension */
+ if (!XETrapQueryExtension(dpy,&(tc->eventBase),&(tc->errorBase),
+ &(tc->extOpcode)))
+ {
+ char *params = XTrapExtName;
+ unsigned int num_params = 1L;
+ XtWarningMsg("CantLoadExt", "XECreateTC", "XTrapToolkitError",
+ "Can't load %s extension", &params, &num_params);
+ (void)XtFree((XtPointer)tc);
+ last_tc->next = NULL; /* Clear now nonexistant forward pointer */
+ return(NULL);
+ }
+
+ /* Allocate memory for the XLIB transport */
+ if ((tc->xbuff = (BYTE *)XtMalloc(tc->xmax_size * sizeof(CARD32) +
+ SIZEOF(XETrapHeader))) == NULL)
+ { /* No memory to build TC, XtMalloc has already reported the error */
+ (void)XtFree((XtPointer)tc); /* free the allocated TC */
+ last_tc->next = NULL; /* Clear now nonexistant forward pointer */
+ return(NULL);
+ }
+
+ /* Decide on a protocol version to communicate with */
+ /* would *like* to use XEGetVersionRequest() but it's broken in V3.1 */
+ if (XEGetAvailableRequest(tc,&rep) == True)
+ {
+ /* stow the protocol number */
+ switch (rep.xtrap_protocol)
+ {
+ /* known acceptable protocols */
+ case 31:
+ case XETrapProtocol:
+ tc->protocol = rep.xtrap_protocol;
+ break;
+ /* all else */
+ default: /* stay backwards compatible */
+ tc->protocol = 31;
+ break;
+ }
+ /* TC to contain *oldest* release/version/revision */
+ if (XETrapGetAvailRelease(&rep) <= XETrapRelease)
+ {
+ tc->release = XETrapGetAvailRelease(&rep);
+ if (XETrapGetAvailVersion(&rep) <= XETrapVersion)
+ {
+ tc->version = XETrapGetAvailVersion(&rep);
+ tc->revision = (XETrapGetAvailRevision(&rep) <= XETrapRevision ?
+ XETrapGetAvailRevision(&rep) : XETrapRevision);
+ }
+ else
+ {
+ tc->version = XETrapVersion;
+ tc->revision = XETrapRevision;
+ }
+ }
+ else
+ {
+ tc->release = XETrapRelease;
+ tc->version = XETrapVersion;
+ tc->revision = XETrapRevision;
+ }
+ }
+ else
+ { /* We can't seem to communicate with the extension! */
+ char *params = XTrapExtName;
+ unsigned int num_params = 1L;
+ XtWarningMsg("CantComm", "XECreateTC", "XTrapToolkitError",
+ "Can't communicate with extension %s", &params, &num_params);
+ (void)XtFree((XtPointer)tc->xbuff);/* de-allocate memory just alloc'd */
+ (void)XtFree((XtPointer)tc); /* free the allocated TC */
+ last_tc->next = NULL; /* Clear now nonexistant forward pointer */
+ return(NULL);
+ }
+
+ /* Assign the context values the caller provided */
+ (void)XEChangeTC(tc, valuemask, value);
+
+ return (tc);
+}
+
+
+static int CheckChangeBits(XETrapFlags *dest, XETrapFlags *src, INT32 bit)
+{
+ int chg_flag = False;
+
+ if (!(BitIsFalse(dest->valid,bit) && BitIsFalse(src->valid,bit)) ||
+ !(BitIsTrue(dest->valid,bit) && BitIsTrue(src->valid,bit)))
+ {
+ BitCopy(dest->valid, src->valid, bit);
+ chg_flag = True;
+ }
+ if (!(BitIsFalse(dest->data,bit) && BitIsFalse(src->data,bit)) ||
+ !(BitIsTrue(dest->data,bit) && BitIsTrue(src->data,bit)))
+ {
+ BitCopy(dest->data, src->data, bit);
+ chg_flag = True;
+ }
+ return(chg_flag);
+}
+
+/*
+ * This function is called to change one or more parameters used to define
+ * a context in which XTrap is or will be running.
+ */
+int XEChangeTC(XETC *tc, CARD32 mask, XETCValues *values)
+{
+ int status = True;
+ register XETCValues *tval = &(tc->values);
+ register int i;
+
+ if (mask & TCStatistics)
+ { /* Statistics need changing */
+ if(CheckChangeBits(&(tval->v.flags), &(values->v.flags),
+ XETrapStatistics))
+ {
+ tc->dirty |= TCStatistics;
+ }
+ }
+ if (mask & TCRequests)
+ { /* Requests need changing */
+ CheckChangeBits(&(tval->v.flags), &(values->v.flags), XETrapRequest);
+ for (i=0; i<256L; i++)
+ {
+ XETrapSetCfgFlagReq(tval, i, BitValue(values->v.flags.req,i));
+ }
+ tc->dirty |= TCRequests;
+ }
+ if (mask & TCEvents)
+ { /* Events need changing */
+ CheckChangeBits(&(tval->v.flags), &(values->v.flags), XETrapEvent);
+ for (i=KeyPress; i<=MotionNotify; i++)
+ {
+ XETrapSetCfgFlagEvt(tval, i, BitValue(values->v.flags.event,i));
+ }
+ tc->dirty |= TCEvents;
+ }
+ if (mask & TCMaxPacket)
+ { /* MaxPacket needs changing */
+ CheckChangeBits(&(tval->v.flags), &(values->v.flags), XETrapMaxPacket);
+ XETrapSetCfgMaxPktSize(tval, values->v.max_pkt_size);
+ tc->dirty |= TCMaxPacket;
+ }
+ if (mask & TCCmdKey)
+ { /* CmdKey needs changing */
+ CheckChangeBits(&(tval->v.flags), &(values->v.flags), XETrapCmd);
+ tval->v.cmd_key = values->v.cmd_key;
+ CheckChangeBits(&(tval->v.flags), &(values->v.flags), XETrapCmdKeyMod);
+ tc->dirty |= TCCmdKey;
+ }
+ if (mask & TCTimeStamps)
+ { /* TimeStamps needs changing */
+ if (CheckChangeBits(&(tval->v.flags), &(values->v.flags), XETrapTimestamp))
+ {
+ tc->dirty |= TCTimeStamps;
+ }
+ BitCopy(tval->tc_flags, values->tc_flags, XETCDeltaTimes);
+ }
+ if (mask & TCWinXY)
+ { /* Window XY's need changing */
+ if (CheckChangeBits(&(tval->v.flags), &(values->v.flags), XETrapWinXY))
+ {
+ tc->dirty |= TCWinXY;
+ }
+ }
+ if (mask & TCCursor)
+ { /* Window XY's need changing */
+ if (CheckChangeBits(&(tval->v.flags), &(values->v.flags),XETrapCursor))
+ {
+ tc->dirty |= TCCursor;
+ }
+ }
+ if (mask & TCXInput)
+ { /* XInput flag needs changing */
+ if (CheckChangeBits(&(tval->v.flags), &(values->v.flags),XETrapXInput))
+ {
+ tc->dirty |= TCXInput;
+ }
+ }
+ if (mask & TCColorReplies)
+ { /* ColorReplies flag needs changing */
+ if (CheckChangeBits(&(tval->v.flags), &(values->v.flags),
+ XETrapColorReplies))
+ {
+ tc->dirty |= TCColorReplies;
+ }
+ }
+ if (mask & TCGrabServer )
+ { /* GrabServer flag needs changing */
+ if (CheckChangeBits(&(tval->v.flags), &(values->v.flags),
+ XETrapGrabServer ))
+ {
+ tc->dirty |= TCGrabServer;
+ }
+ }
+ if (XETrapGetTCFlagTrapActive(tc))
+ {
+ status = XEFlushConfig(tc);
+ }
+#ifdef VMS
+ sys$setast(True); /* Make sure AST's are enabled */
+#endif /* VMS */
+ return(status);
+}
+
+
+void XEFreeTC(XETC *tc)
+{
+ register XETC *list = &TC;
+
+ if (tc)
+ {
+ while(list->next != NULL)
+ {
+ if (list->next == tc)
+ list->next = list->next->next; /* Got it, remove from list */
+ else
+ list = list->next; /* Update the list pointer */
+ }
+ if (tc->values.req_cb)
+ {
+ XtFree((XtPointer)tc->values.req_cb);
+ }
+ if (tc->values.evt_cb)
+ {
+ XtFree((XtPointer)tc->values.evt_cb);
+ }
+ if (tc->xbuff != NULL)
+ {
+ XtFree((XtPointer)tc->xbuff);
+ }
+
+ XtFree((XtPointer)tc);
+ if (extensionData)
+ {
+ XtFree(extensionData);
+ }
+ }
+ return;
+}
+
+/* The following are Convenience routines for setting values within
+ * the Trap Context. These are analogous to the GC's Convenience
+ * Functions such as XSetState & XSetForeground
+ */
+int XETrapSetMaxPacket(XETC *tc, Bool set_flag, CARD16 size)
+{
+ XETCValues tcv;
+ int status = True;
+
+ (void)memset((char *)&tcv,0L,sizeof(tcv));
+ XETrapSetCfgFlagMaxPacket(&tcv, valid, True);
+ XETrapSetCfgFlagMaxPacket(&tcv, data, set_flag);
+ XETrapSetCfgMaxPktSize(&tcv, size);
+ status = XEChangeTC(tc, TCMaxPacket, &tcv);
+ return(status);
+}
+int XETrapSetCommandKey(XETC *tc, Bool set_flag, KeySym cmd_key, Bool mod_flag)
+{
+ XETCValues tcv;
+ int status = True;
+ KeyCode cmd_keycode;
+
+ (void)memset((char *)&tcv,0L,sizeof(tcv));
+ XETrapSetCfgFlagCmd(&tcv, valid, True);
+ XETrapSetCfgFlagCmd(&tcv, data, set_flag);
+ if (set_flag == True)
+ {
+ XETrapSetCfgFlagCmdKeyMod(&tcv, valid, True);
+ XETrapSetCfgFlagCmdKeyMod(&tcv, data, mod_flag);
+ if (!(cmd_keycode = XKeysymToKeycode(XETrapGetDpy(tc), cmd_key)))
+ {
+ status = False;
+ }
+ else
+ {
+ XETrapSetCfgCmdKey(&tcv, cmd_keycode);
+ }
+ }
+ else
+ { /* Clear command key */
+ XETrapSetCfgFlagCmdKeyMod(&tcv, valid, True);
+ XETrapSetCfgFlagCmdKeyMod(&tcv, data, False);
+ XETrapSetCfgCmdKey(&tcv, 0);
+ }
+ if (status == True)
+ {
+ status = XEChangeTC(tc, TCCmdKey, &tcv);
+ }
+ return(status);
+}
+
+int XETrapSetTimestamps(XETC *tc, Bool set_flag, Bool delta_flag)
+{
+ XETCValues tcv;
+ int status = True;
+
+ (void)memset((char *)&tcv,0L,sizeof(tcv));
+ XETrapSetCfgFlagTimestamp(&tcv, valid, True);
+ XETrapSetCfgFlagTimestamp(&tcv, data, set_flag);
+ XETrapSetValFlagDeltaTimes(&tcv, delta_flag);
+ status = XEChangeTC(tc, TCTimeStamps, &tcv);
+ return(status);
+}
+
+int XETrapSetWinXY(XETC *tc, Bool set_flag)
+{
+ XETCValues tcv;
+ int status = True;
+
+ (void)memset((char *)&tcv,0L,sizeof(tcv));
+ XETrapSetCfgFlagWinXY(&tcv, valid, True);
+ XETrapSetCfgFlagWinXY(&tcv, data, set_flag);
+ status = XEChangeTC(tc, TCWinXY, &tcv);
+ return(status);
+}
+
+int XETrapSetCursor(XETC *tc, Bool set_flag)
+{
+ XETCValues tcv;
+ int status = True;
+
+ (void)memset((char *)&tcv,0L,sizeof(tcv));
+ XETrapSetCfgFlagCursor(&tcv, valid, True);
+ XETrapSetCfgFlagCursor(&tcv, data, set_flag);
+ status = XEChangeTC(tc, TCCursor, &tcv);
+ return(status);
+}
+
+int XETrapSetXInput(XETC *tc, Bool set_flag)
+{
+ XETCValues tcv;
+ int status = True;
+
+ (void)memset((char *)&tcv,0L,sizeof(tcv));
+ XETrapSetCfgFlagXInput(&tcv, valid, True);
+ XETrapSetCfgFlagXInput(&tcv, data, set_flag);
+ status = XEChangeTC(tc, TCXInput, &tcv);
+ return(status);
+}
+
+int XETrapSetColorReplies(XETC *tc, Bool set_flag)
+{
+ XETCValues tcv;
+ int status = True;
+
+ (void)memset((char *)&tcv,0L,sizeof(tcv));
+ XETrapSetCfgFlagColorReplies(&tcv, valid, True);
+ XETrapSetCfgFlagColorReplies(&tcv, data, set_flag);
+ status = XEChangeTC(tc, TCColorReplies, &tcv);
+ return(status);
+}
+
+int XETrapSetGrabServer(XETC *tc, Bool set_flag)
+{
+ XETCValues tcv;
+ int status = True;
+
+ (void)memset((char *)&tcv,0L,sizeof(tcv));
+ XETrapSetCfgFlagGrabServer(&tcv, valid, True);
+ XETrapSetCfgFlagGrabServer(&tcv, data, set_flag);
+ status = XEChangeTC(tc, TCGrabServer, &tcv);
+ return(status);
+}
+
+int XETrapSetStatistics(XETC *tc, Bool set_flag)
+{
+ XETCValues tcv;
+ int status = True;
+
+ (void)memset((char *)&tcv,0L,sizeof(tcv));
+ XETrapSetCfgFlagStatistics(&tcv, valid, True);
+ XETrapSetCfgFlagStatistics(&tcv, data, set_flag);
+ status = XEChangeTC(tc, TCStatistics, &tcv);
+ return(status);
+}
+
+int XETrapSetRequests(XETC *tc, Bool set_flag, ReqFlags requests)
+{
+ XETCValues tcv;
+ int status = True;
+ int i;
+
+ (void)memset((char *)&tcv,0L,sizeof(tcv));
+ XETrapSetCfgFlagRequest(&tcv, valid, True);
+ XETrapSetCfgFlagRequest(&tcv, data, set_flag);
+ for (i=0; i<256L; i++)
+ {
+ XETrapSetCfgFlagReq(&tcv, i, BitValue(requests, i));
+ }
+ status = XEChangeTC(tc, TCRequests, &tcv);
+ return(status);
+}
+
+int XETrapSetEvents(XETC *tc, Bool set_flag, EventFlags events)
+{
+ XETCValues tcv;
+ int status = True;
+ int i;
+
+ (void)memset((char *)&tcv,0L,sizeof(tcv));
+ XETrapSetCfgFlagEvent(&tcv, valid, True);
+ XETrapSetCfgFlagEvent(&tcv, data, set_flag);
+ for (i=KeyPress; i<=MotionNotify; i++)
+ {
+ XETrapSetCfgFlagEvt(&tcv, i, BitValue(events, i));
+ }
+ status = XEChangeTC(tc, (CARD32)TCEvents, &tcv);
+ return(status);
+}
+
+Bool XESetCmdGateState(XETC *tc, CARD8 type, Bool *gate_closed,
+ CARD8 *next_key, Bool *key_ignore)
+{
+
+ *key_ignore = False;
+ if (XETrapGetTCFlagCmdKeyMod(tc,data) == True)
+ {
+ switch (type)
+ {
+ case KeyPress:
+ if (*next_key == XEKeyIsEcho)
+ {
+ break;
+ }
+ *gate_closed = True;
+ *next_key = XEKeyIsClear;
+ break;
+
+ case KeyRelease:
+ if (*next_key == XEKeyIsEcho)
+ {
+ *next_key = XEKeyIsClear;
+ break;
+ }
+ if (*next_key == XEKeyIsClear)
+ {
+ *next_key = XEKeyIsEcho;
+ }
+ else
+ { /* it's XEKeyIsOther, so Clear it */
+ *next_key = XEKeyIsClear;
+ }
+ *gate_closed = False;
+ *key_ignore = True;
+ break;
+
+ default: break;
+ }
+ }
+ else
+ {
+ switch (type)
+ {
+ case KeyPress:
+ if (*next_key == XEKeyIsEcho)
+ {
+ *gate_closed = False;
+ break;
+ }
+ /* Open gate on cmd key release */
+ if ((*next_key == XEKeyIsOther) &&
+ *gate_closed == True)
+ {
+ break;
+ }
+ *gate_closed = True;
+ *next_key = XEKeyIsClear;
+ break;
+
+ case KeyRelease:
+ if (*next_key == XEKeyIsClear)
+ {
+ *next_key = XEKeyIsEcho;
+ break;
+ }
+
+ if (*next_key == XEKeyIsEcho)
+ {
+ *next_key = XEKeyIsClear;
+ break;
+ }
+
+ *gate_closed = False;
+ *key_ignore = True;
+ *next_key = XEKeyIsClear;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return(*gate_closed);
+}
diff --git a/nx-X11/lib/XTrap/XEDsptch.c b/nx-X11/lib/XTrap/XEDsptch.c
new file mode 100644
index 000000000..b50392638
--- /dev/null
+++ b/nx-X11/lib/XTrap/XEDsptch.c
@@ -0,0 +1,111 @@
+/* $XFree86$ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
+
+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.
+
+*****************************************************************************/
+/*
+ *
+ * CONTRIBUTORS:
+ *
+ * Dick Annicchiarico
+ * Robert Chesler
+ * Dan Coutu
+ * Gene Durso
+ * Marc Evans
+ * Alan Jamison
+ * Mark Henry
+ * Ken Miller
+ *
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+
+static void XETrapDispatchCB(XETC *tc, XETrapDatum *pdatum)
+{
+ void_function pfunc = NULL;
+ BYTE *userp = NULL;
+
+ /* Need to deal with Delta Timestamps here before calling client CB */
+ if (XETrapGetTCFlagDeltaTimes(tc))
+ {
+ CARD32 last_time = XETrapGetTCTime(tc);
+ if (XETrapHeaderIsEvent(&pdatum->hdr))
+ { /* then we can play with the timestamps */
+ pdatum->hdr.timestamp =
+ pdatum->u.event.u.keyButtonPointer.time;
+ }
+ else
+ { /*
+ * the current one from GetTimeInMillis is worthless
+ * as it's only updated during event instances (e.g. not
+ * wall clock).
+ */
+ pdatum->hdr.timestamp = last_time;
+ }
+ if (!pdatum->hdr.timestamp)
+ { /* for dual monitor bug */
+ pdatum->hdr.timestamp = last_time;
+ }
+ if (!last_time)
+ { /* first one! Prime it! */
+ last_time = pdatum->hdr.timestamp;
+ }
+ tc->values.last_time = pdatum->hdr.timestamp; /* no macro! */
+ if (pdatum->hdr.timestamp < last_time)
+ { /* for clock rollover */
+ pdatum->hdr.timestamp = 0;
+ }
+ else
+ { /* the real delta */
+ pdatum->hdr.timestamp = pdatum->hdr.timestamp - last_time;
+ }
+ }
+ /* Get the user supplied callback function */
+ if (XETrapHeaderIsEvent(&pdatum->hdr))
+ {
+ pfunc = tc->values.evt_cb[pdatum->u.event.u.u.type].func;
+ userp = tc->values.evt_cb[pdatum->u.event.u.u.type].data;
+ }
+ else if (XETrapHeaderIsRequest(&pdatum->hdr) ||
+ XETrapHeaderIsReply(&pdatum->hdr))
+ {
+ pfunc = tc->values.req_cb[pdatum->u.req.reqType].func;
+ userp = tc->values.req_cb[pdatum->u.req.reqType].data;
+ }
+
+ /* If there is a callback then call it with the data */
+ if (pfunc != NULL)
+ {
+ (*pfunc)(tc,pdatum,userp);
+ }
+}
+
+Boolean XETrapDispatchXLib(XETrapDataEvent *event, XETC *tc)
+{
+ memcpy(&tc->xbuff[event->idx*sz_EventData], event->data, sz_EventData);
+
+ if (event->detail == XETrapDataLast)
+ {
+ XETrapDispatchCB(tc, (XETrapDatum *)tc->xbuff);
+ }
+ return True;
+}
diff --git a/nx-X11/lib/XTrap/XEPrInfo.c b/nx-X11/lib/XTrap/XEPrInfo.c
new file mode 100644
index 000000000..908ca3ad9
--- /dev/null
+++ b/nx-X11/lib/XTrap/XEPrInfo.c
@@ -0,0 +1,274 @@
+/* $XFree86$ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991, 1994 by Digital Equipment Corp.,
+Maynard, MA
+
+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/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+
+#ifndef TRUE
+# define TRUE 1L
+#endif
+#ifndef FALSE
+# define FALSE 0L
+#endif
+
+void XEPrintRelease( FILE *ofp, XETrapGetAvailRep *pavail)
+{
+
+ fprintf(ofp,"\tRelease: %d.%d-%d\n", XETrapGetAvailRelease(pavail),
+ XETrapGetAvailVersion(pavail), XETrapGetAvailRevision(pavail));
+}
+void XEPrintTkRelease( FILE *ofp, XETC *tc)
+{
+ fprintf(ofp,"\tRelease: %d.%d-%d\n", XEGetRelease(tc), XEGetVersion(tc),
+ XEGetRevision(tc));
+}
+
+void XEPrintPlatform( FILE *ofp, XETrapGetAvailRep *pavail)
+{
+ fprintf(ofp,"\tPlatform: %s (0x%02x)\n",
+ XEPlatformIDToString(XETrapGetAvailPFIdent(pavail)),
+ (int)XETrapGetAvailPFIdent(pavail));
+}
+
+void XEPrintAvailFlags( FILE *ofp, XETrapGetAvailRep *pavail)
+{
+
+ CARD8 f[4L];
+
+ XETrapGetAvailFlags(pavail,f);
+ fprintf(ofp,"\tFlags: ");
+ if (XETrapGetAvailFlagTimestamp(pavail)) fputs("Timestamps ", ofp);
+ if (XETrapGetAvailFlagCmd(pavail)) fputs("CmdKey ", ofp);
+ if (XETrapGetAvailFlagCmdKeyMod(pavail)) fputs("CmdKeyMod ", ofp);
+ if (XETrapGetAvailFlagRequest(pavail)) fputs("Requests ", ofp);
+ if (XETrapGetAvailFlagEvent(pavail)) fputs("Events ", ofp);
+ if (XETrapGetAvailFlagMaxPacket(pavail)) fputs("MaxPkt ", ofp);
+ if (XETrapGetAvailFlagStatistics(pavail)) fputs("Statistics ", ofp);
+ if (XETrapGetAvailFlagWinXY(pavail)) fputs("WinXY ", ofp);
+ if (XETrapGetAvailFlagCursor(pavail)) fputs("Cursor ", ofp);
+ if (XETrapGetAvailFlagXInput(pavail)) fputs("XInput ", ofp);
+ if (XETrapGetAvailFlagVecEvt(pavail)) fputs("Vect_Evnts ", ofp);
+ if (XETrapGetAvailFlagColorReplies(pavail)) fputs("ColorRep ", ofp);
+ if (XETrapGetAvailFlagGrabServer(pavail)) fputs("GrabServer ", ofp);
+ fprintf(ofp," (0x%02x%02x%02x%02x)\n", f[0], f[1], f[2], f[3]);
+}
+
+void XEPrintAvailPktSz( FILE *ofp, XETrapGetAvailRep *pavail)
+{
+
+ fprintf(ofp,"\tMax Packet Size: %d\n", XETrapGetAvailMaxPktSize(pavail));
+}
+void XEPrintStateFlags( FILE *ofp, XETrapGetCurRep *pcur)
+{
+
+ CARD8 f[2];
+ XETrapGetCurSFlags(pcur, f);
+ fputs("\tFlags: ",ofp);
+ if (BitIsTrue(f,XETrapTrapActive)) fputs("I/O Active ", ofp);
+ fprintf(ofp," (0x%02x%02x)\n", f[0], f[1]);
+}
+
+void XEPrintMajOpcode( FILE *ofp, XETrapGetAvailRep *pavail)
+{
+
+ fprintf(ofp,"\tMajor Opcode: %d\n", (int)XETrapGetAvailOpCode(pavail));
+}
+void XEPrintCurXY( FILE *ofp, XETrapGetAvailRep *pavail)
+{
+
+ fprintf(ofp,"\tCurrent (x,y): (%d,%d)\n", XETrapGetCurX(pavail),
+ XETrapGetCurY(pavail));
+}
+
+void XEPrintTkFlags( FILE *ofp, XETC *tc)
+{
+
+ CARD8 f[2];
+ XETrapGetTCLFlags(tc, f);
+ fputs("\tFlags: ",ofp);
+ if (XETrapGetTCFlagDeltaTimes(tc)) fputs("Delta Times ", ofp);
+ if (XETrapGetTCFlagTrapActive(tc)) fputs("Trap Active ", ofp);
+ fprintf(ofp," (0x%02x%02x)\n", f[0], f[1]);
+}
+
+void XEPrintLastTime( FILE *ofp, XETC *tc)
+{
+
+ fprintf(ofp,"\tLast Relative Time: %d\n", (int)XETrapGetTCTime(tc));
+}
+
+void XEPrintCfgFlags( FILE *ofp, XETrapGetCurRep *pcur)
+{
+
+ CARD8 f[4L];
+
+ XETrapGetCurCFlags(pcur,data,f);
+ fprintf(ofp,"\tFlags: ");
+ if (XETrapGetCurFlagTimestamp(pcur,data)) fputs("Timestamps ", ofp);
+ if (XETrapGetCurFlagCmd(pcur,data)) fputs("CmdKey ", ofp);
+ if (XETrapGetCurFlagCmdKeyMod(pcur,data)) fputs("CmdKeyMod ", ofp);
+ if (XETrapGetCurFlagRequest(pcur,data)) fputs("Requests ", ofp);
+ if (XETrapGetCurFlagEvent(pcur,data)) fputs("Events ", ofp);
+ if (XETrapGetCurFlagMaxPacket(pcur,data)) fputs("MaxPkt ", ofp);
+ if (XETrapGetCurFlagStatistics(pcur,data)) fputs("Statistics ", ofp);
+ if (XETrapGetCurFlagWinXY(pcur,data)) fputs("WinXY ", ofp);
+ if (XETrapGetCurFlagCursor(pcur,data)) fputs("Cursor ", ofp);
+ if (XETrapGetCurFlagXInput(pcur,data)) fputs("XInput ", ofp);
+ if (XETrapGetCurFlagColorReplies(pcur,data)) fputs("ColorReplies ", ofp);
+ if (XETrapGetCurFlagGrabServer(pcur,data)) fputs("GrabServer ", ofp);
+ fprintf(ofp," (0x%02x%02x%02x%02x)\n", f[0], f[1], f[2], f[3]);
+}
+
+void XEPrintRequests( FILE *ofp, XETrapGetCurRep *pcur)
+{
+
+ long i;
+ fprintf(ofp,"\tX Requests: ");
+ for (i=0L; i<=XETrapMaxRequest-1; i++)
+ { /* Not using the macro cause we're doing things
+ * a byte at a time rather than a bit.
+ */
+ fprintf(ofp,"%02x ", pcur->config.flags.req[i]);
+ if ((i+1L)%4L == 0L)
+ {
+ fprintf(ofp," ");
+ }
+ if ((i+1L)%16L == 0L)
+ {
+ fprintf(ofp,"\n\t\t ");
+ }
+ }
+ fprintf(ofp,"\n");
+}
+
+void XEPrintEvents( FILE *ofp, XETrapGetCurRep *pcur)
+{
+
+ int i;
+ fprintf(ofp,"\tX Events: ");
+ for (i=0L; i<XETrapMaxEvent; i++)
+ { /* Not using the macro cause we're doing things
+ * a byte at a time rather than a bit.
+ */
+ fprintf(ofp,"%02x ", pcur->config.flags.event[i]);
+ if ((i+1L)%4L == 0L)
+ {
+ fprintf(ofp," ");
+ }
+ if ((i+1L)%16L == 0L)
+ {
+ fprintf(ofp,"\n\t\t ");
+ }
+ }
+ fprintf(ofp,"\n");
+}
+
+void XEPrintCurPktSz( FILE *ofp, XETrapGetCurRep *pcur)
+{
+
+ fprintf(ofp,"\tMax Packet Size: %d\n", XETrapGetCurMaxPktSize(pcur));
+}
+
+void XEPrintCmdKey( FILE *ofp, XETrapGetCurRep *pcur)
+{
+
+ fprintf(ofp,"\tcmd_key: 0x%02x\n", XETrapGetCurCmdKey(pcur));
+}
+
+void XEPrintEvtStats( FILE *ofp, XETrapGetStatsRep *pstats, XETC *tc)
+{
+
+ int i;
+ fprintf(ofp,"\tX Events:\n");
+ for (i=0; i<XETrapCoreEvents; i++)
+ {
+ if (XETrapGetStatsEvt(pstats,i))
+ {
+ fprintf(ofp,"\t %-20s : %d\n", XEEventIDToString(i,tc),
+ (int)XETrapGetStatsEvt(pstats,i));
+ }
+ }
+ fprintf(ofp,"\n");
+}
+
+void XEPrintReqStats( FILE *ofp, XETrapGetStatsRep *pstats, XETC *tc)
+{
+
+ int i;
+ fprintf(ofp,"\tX Requests:\n");
+ for (i=0L; i<256L; i++)
+ {
+ if (XETrapGetStatsReq(pstats,i))
+ {
+ fprintf(ofp,"\t %-20s : %d\n", XERequestIDToString(i,tc),
+ (int)XETrapGetStatsReq(pstats,i));
+ }
+ }
+ fprintf(ofp,"\n");
+}
+
+
+void XEPrintAvail( FILE *ofp, XETrapGetAvailRep *pavail)
+{
+
+ fprintf(ofp,"Available Information:\n");
+ XEPrintRelease(ofp, pavail);
+ XEPrintPlatform(ofp, pavail);
+ XEPrintMajOpcode(ofp, pavail);
+ XEPrintAvailFlags(ofp, pavail);
+ XEPrintAvailPktSz(ofp, pavail);
+ XEPrintCurXY(ofp, pavail);
+ return;
+}
+
+void XEPrintTkState( FILE *ofp, XETC *tc)
+{
+
+ fprintf(ofp,"Toolkit State:\n");
+ XEPrintTkFlags(ofp, tc);
+ XEPrintLastTime(ofp, tc);
+ XEPrintTkRelease(ofp, tc);
+}
+
+void XEPrintCurrent( FILE *ofp, XETrapGetCurRep *pcur)
+{
+
+ fprintf(ofp,"Current State:\n");
+ XEPrintStateFlags(ofp, pcur);
+ fprintf(ofp,"Current Config:\n");
+ XEPrintCfgFlags(ofp, pcur);
+ XEPrintRequests(ofp, pcur);
+ XEPrintEvents(ofp, pcur);
+ XEPrintCurPktSz(ofp, pcur);
+ XEPrintCmdKey(ofp, pcur);
+}
+
+void XEPrintStatistics( FILE *ofp, XETrapGetStatsRep *pstats, XETC *tc)
+{
+
+ fprintf(ofp,"Statistics:\n");
+ XEPrintEvtStats(ofp, pstats, tc);
+ XEPrintReqStats(ofp, pstats, tc);
+}
+
diff --git a/nx-X11/lib/XTrap/XERqsts.c b/nx-X11/lib/XTrap/XERqsts.c
new file mode 100644
index 000000000..dbecea33a
--- /dev/null
+++ b/nx-X11/lib/XTrap/XERqsts.c
@@ -0,0 +1,412 @@
+/* $XFree86$ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
+
+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.
+
+*****************************************************************************/
+#ifndef NO_DEC_ADDED_VALUE
+#ifdef SMT
+#define NEED_EVENTS
+#define NEED_REPLIES
+#endif
+#include <X11/Xlib.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#else /* NO_DEC_BUG_FIX */
+#include <X11/Xlib.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#endif /* NO_DEC_BUG_FIX */
+/* the following's a hack to support V3.1 protocol */
+#if defined(__STDC__) && !defined(UNIXCPP)
+#define GetOldReq(name, req, old_length) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = old_length>>2;\
+ dpy->bufptr += old_length;\
+ dpy->request++
+
+#else /* non-ANSI C uses empty comment instead of "##" for token concat */
+#define GetOldReq(name, req, old_length) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = old_length>>2;\
+ dpy->bufptr += old_length;\
+ dpy->request++
+#endif
+
+#ifndef vms
+#include <X11/Xlibint.h>
+#else /* vms */
+#define SyncHandle() \
+ if (dpy->synchandler) (*dpy->synchandler)(dpy)
+/*
+ * LockDisplay uses an undocumented feature in V5 of VMS that allows
+ * disabling ASTs without calling $SETAST. A bit is set in P1 space
+ * that disables a user mode AST from being delivered to this process.
+ *
+ */
+#define LockDisplay(dis) \
+{ globalref char ctl$gb_soft_ast_disable; \
+ globalref char ctl$gb_lib_lock; \
+ globalref short ctl$gw_soft_ast_lock_depth; \
+ if ( ctl$gb_soft_ast_disable == 0 ) { \
+ ctl$gb_soft_ast_disable = 1; \
+ ctl$gb_lib_lock = 1; \
+ ctl$gw_soft_ast_lock_depth = 1; \
+ } \
+ else ctl$gw_soft_ast_lock_depth++; \
+}
+
+/*
+ * UnlockDisplay clears the AST disable bit, then checks to see if an
+ * AST delivery attempt was made during the critical section. If so,
+ * reenable_ASTs is set, and $SETAST must be called to turn AST delivery
+ * back on.
+ *
+ * Note that it assumed that LockDisplay and UnlockDisplay appear in
+ * matched sets within a single routine.
+ */
+#define UnlockDisplay(dis) \
+{ globalref char ctl$gb_reenable_asts; \
+ globalref char ctl$gb_soft_ast_disable; \
+ globalref char ctl$gb_lib_lock; \
+ globalref short ctl$gw_soft_ast_lock_depth; \
+ if (!--ctl$gw_soft_ast_lock_depth) \
+ if ( ctl$gb_lib_lock ) { \
+ ctl$gb_lib_lock = 0; \
+ ctl$gb_soft_ast_disable = 0; \
+ if (ctl$gb_reenable_asts != 0) \
+ sys$setast(1); \
+ } \
+}
+
+#define WORD64ALIGN
+#if defined(__STDC__) && !defined(UNIXCPP)
+#define GetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = (SIZEOF(x##name##Req))>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req);\
+ dpy->request++
+
+#else /* non-ANSI C uses empty comment instead of "##" for token concat */
+#define GetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = (SIZEOF(x/**/name/**/Req))>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req);\
+ dpy->request++
+#endif
+#endif /* vms */
+
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+
+/* Returns the all important protocol number to be used.
+ * The only request guaranteed to be of the same request/reply
+ * size is XEGetVersionRequest. All others need the protocol
+ * number to determine how to communicate.
+ * Unfortunately, this was broken for V3.1 so GetAvailable will
+ * have to be used to determine the protocol version.
+ */
+int XEGetVersionRequest(XETC *tc, XETrapGetVersRep *ret)
+{
+ int status = True;
+ Display *dpy = tc->dpy;
+ CARD32 X_XTrapGet = tc->extOpcode;
+ xXTrapGetReq *reqptr;
+ xXTrapGetVersReply rep;
+ int numlongs = (SIZEOF(xXTrapGetVersReply) -
+ SIZEOF(xReply) + SIZEOF(CARD32) -1 ) / SIZEOF(CARD32);
+ LockDisplay(dpy);
+ GetReq(XTrapGet,reqptr);
+ reqptr->minor_opcode = XETrap_GetVersion;
+ reqptr->protocol = XETrapProtocol;
+ status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
+ SyncHandle();
+ UnlockDisplay(dpy);
+ memcpy((char *)ret,&(rep.data),sizeof(XETrapGetVersRep));
+ return(status);
+}
+
+int XEGetAvailableRequest(XETC *tc, XETrapGetAvailRep *ret)
+{
+ int status = True;
+ Display *dpy = tc->dpy;
+ CARD32 X_XTrapGet = tc->extOpcode;
+ xXTrapGetReq *reqptr;
+ xXTrapGetAvailReply rep;
+ int numlongs = (SIZEOF(xXTrapGetAvailReply) -
+ SIZEOF(xReply) + SIZEOF(CARD32) -1 ) / SIZEOF(CARD32);
+ LockDisplay(dpy);
+ GetReq(XTrapGet,reqptr);
+ reqptr->minor_opcode = XETrap_GetAvailable;
+ reqptr->protocol = XETrapProtocol;
+ status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
+ SyncHandle();
+ UnlockDisplay(dpy);
+ memcpy((char *)ret,&(rep.data),sizeof(XETrapGetAvailRep));
+ return(status);
+}
+
+/* should not be called directly by clients */
+static int XEConfigRequest(XETC *tc)
+{ /* protocol changed between V3.1 and V3.2! */
+ int status = True;
+ Display *dpy = tc->dpy;
+ CARD32 X_XTrapConfig = tc->extOpcode;
+ xXTrapConfigReq *reqptr;
+ if (tc->protocol == 31)
+ { /* hack to allocate the old request length */
+ GetOldReq(XTrapConfig,reqptr,276);
+ }
+ else
+ {
+ GetReq(XTrapConfig,reqptr);
+ }
+ reqptr->minor_opcode = XETrap_Config;
+
+ memcpy((char *)reqptr->config_flags_valid,
+ (char *)tc->values.v.flags.valid,4);
+ memcpy((char *)reqptr->config_flags_data,
+ (char *)tc->values.v.flags.data,4);
+ memcpy((char *)reqptr->config_flags_req,
+ (char *)tc->values.v.flags.req,XETrapMaxRequest);
+ memcpy((char *)reqptr->config_flags_event,
+ (char *)tc->values.v.flags.event,XETrapMaxEvent);
+ reqptr->config_max_pkt_size=tc->values.v.max_pkt_size;
+ reqptr->config_cmd_key=tc->values.v.cmd_key;
+
+ XFlush(dpy);
+ SyncHandle();
+ tc->dirty = 0L; /* Configuration is no longer dirty */
+ return(status);
+}
+
+/* Flush out any pending configuration */
+int XEFlushConfig(XETC *tc)
+{
+ return((tc->dirty) ? XEConfigRequest(tc) : True);
+}
+int XEResetRequest(XETC *tc)
+{
+ int status = True;
+ Display *dpy = tc->dpy;
+ CARD32 X_XTrap = tc->extOpcode;
+ xXTrapReq *reqptr;
+ status = XEFlushConfig(tc); /* Flushout any pending configuration first */
+ if (status == True)
+ {
+ GetReq(XTrap,reqptr);
+ reqptr->minor_opcode = XETrap_Reset;
+ XFlush(dpy);
+ SyncHandle();
+ }
+ return(status);
+}
+
+
+int XEGetLastInpTimeRequest(XETC *tc, XETrapGetLastInpTimeRep *ret)
+{ /* this was broken in V3.1! */
+ int status = True;
+ Display *dpy = tc->dpy;
+ CARD32 X_XTrap = tc->extOpcode;
+ xXTrapReq *reqptr;
+ xXTrapGetLITimReply rep;
+ int numlongs = (SIZEOF(xXTrapGetLITimReply) -
+ SIZEOF(xReply) + SIZEOF(CARD32) - 1) / SIZEOF(CARD32);
+ LockDisplay(dpy);
+ GetReq(XTrap,reqptr);
+ reqptr->minor_opcode = XETrap_GetLastInpTime;
+ status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
+ SyncHandle();
+ UnlockDisplay(dpy);
+
+ ret->last_time=rep.data_last_time;
+
+ return(status);
+}
+
+int XEStartTrapRequest(XETC *tc)
+{
+ int status = True;
+ Display *dpy = tc->dpy;
+ CARD32 X_XTrap = tc->extOpcode;
+ xXTrapReq *reqptr;
+ status = XEFlushConfig(tc); /* Flushout any pending configuration first */
+ if (status == True)
+ {
+ /* Add our event handler for the XLib transport */
+ XETrapSetEventHandler(tc, XETrapData, XETrapDispatchXLib);
+ GetReq(XTrap,reqptr);
+ reqptr->minor_opcode = XETrap_StartTrap;
+ XFlush(dpy);
+ SyncHandle();
+ BitTrue(tc->values.tc_flags, XETCTrapActive);
+ }
+ return(status);
+}
+int XEStopTrapRequest(XETC *tc)
+{
+ int status = True;
+ Display *dpy = tc->dpy;
+ CARD32 X_XTrap = tc->extOpcode;
+ xXTrapReq *reqptr;
+ status = XEFlushConfig(tc); /* Flushout any pending configuration first */
+ if (status == True)
+ {
+ GetReq(XTrap,reqptr);
+ reqptr->minor_opcode = XETrap_StopTrap;
+ XFlush(dpy);
+ SyncHandle();
+ BitFalse(tc->values.tc_flags, XETCTrapActive);
+ /* Remove our event handler for the XLib transport */
+ XETrapSetEventHandler(tc, XETrapData, NULL);
+ }
+
+ return(status);
+}
+
+#ifndef _XINPUT
+int XESimulateXEventRequest(XETC *tc, CARD8 type, CARD8 detail,
+ CARD16 x, CARD16 y, CARD8 screen)
+{
+ int status = True;
+ Display *dpy = tc->dpy;
+ CARD32 X_XTrapInput = tc->extOpcode;
+ xXTrapInputReq *reqptr;
+ status = XEFlushConfig(tc); /* Flushout any pending configuration first */
+ if (status == True)
+ { /* write out the input event */
+ GetReq(XTrapInput,reqptr);
+ reqptr->minor_opcode = XETrap_SimulateXEvent;
+ reqptr->input.type = type;
+ reqptr->input.detail = detail;
+ reqptr->input.x = x;
+ reqptr->input.y = y;
+ reqptr->input.screen = screen;
+ XFlush(dpy);
+ }
+ return(status);
+}
+#endif
+int XEGetCurrentRequest(XETC *tc, XETrapGetCurRep *ret)
+{
+ int status = True;
+ Display *dpy = tc->dpy;
+ CARD32 X_XTrap = tc->extOpcode;
+ xXTrapReq *reqptr;
+ xXTrapGetCurReply rep;
+ int numlongs = (SIZEOF(xXTrapGetCurReply) -
+ SIZEOF(xReply) + SIZEOF(CARD32) -1 ) / SIZEOF(CARD32);
+ status = XEFlushConfig(tc); /* Flushout any pending configuration first */
+ if (status == True)
+ {
+ LockDisplay(dpy);
+ GetReq(XTrap,reqptr);
+ reqptr->minor_opcode = XETrap_GetCurrent;
+ /* to support comm. w/ V3.1 extensions */
+ if (tc->protocol == 31)
+ {
+ char tmp[284]; /* need space for the big *old* reply */
+ numlongs = (284-sizeof(xReply)+sizeof(long)-1)/sizeof(long);
+ status = _XReply(dpy,(xReply *)tmp,numlongs,xTrue);
+ memcpy(&rep,tmp,sizeof(rep)); /* move just what's needed */
+ }
+ else
+ {
+ status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
+ }
+ SyncHandle();
+ UnlockDisplay(dpy);
+
+ memcpy((char *)ret->state_flags,rep.data_state_flags,2);
+ memcpy((char *)ret->config.flags.valid,rep.data_config_flags_valid,4);
+ memcpy((char *)ret->config.flags.data,rep.data_config_flags_data,4);
+ memcpy((char *)ret->config.flags.req,rep.data_config_flags_req,
+ XETrapMaxRequest);
+ memcpy((char *)ret->config.flags.event,rep.data_config_flags_event,
+ XETrapMaxEvent);
+ ret->config.max_pkt_size=rep.data_config_max_pkt_size;
+ ret->config.cmd_key=rep.data_config_cmd_key;
+
+ }
+ return(status);
+}
+
+int XEGetStatisticsRequest(XETC *tc, XETrapGetStatsRep *ret)
+{
+ int status = True;
+ Display *dpy = tc->dpy;
+ CARD32 X_XTrap = tc->extOpcode;
+ xXTrapReq *reqptr;
+ xXTrapGetStatsReply rep;
+ status = XEFlushConfig(tc); /* Flushout any pending configuration first */
+ if (status == True)
+ {
+ LockDisplay(dpy);
+ GetReq(XTrap,reqptr);
+ reqptr->minor_opcode = XETrap_GetStatistics;
+ /* to support comm. w/ V3.1 extensions */
+#ifndef CRAY
+ if (tc->protocol == 31)
+ { /* this is the way we used to do it which breaks Cray's */
+#ifndef VECTORED_EVENTS
+ int numlongs = (1060-sizeof(xReply)+sizeof(long)-1)/sizeof(long);
+#else
+ int numlongs = (1544-sizeof(xReply)+sizeof(long)-1)/sizeof(long);
+#endif
+ status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
+ if (status == True)
+ { /* need to shift it back into the data struct */
+ xXTrapGetStatsReply tmp;
+ tmp = rep;
+ memcpy(&(rep.data),&(tmp.pad0), sizeof(rep.data));
+ }
+ }
+ else
+#endif /* CRAY */
+ { /* this is the way we do it for V3.2 */
+ int numbytes = SIZEOF(xXTrapGetStatsReply) - SIZEOF(xReply);
+ status = _XReply(dpy, (xReply *)&rep, 0, xFalse);
+ if (status == True)
+ {
+ status = _XRead(dpy, (char *)&rep.data, numbytes);
+ }
+ }
+ SyncHandle();
+ UnlockDisplay(dpy);
+ memcpy(ret,&(rep.data),sizeof(XETrapGetStatsRep));
+ }
+ return(status);
+}
diff --git a/nx-X11/lib/XTrap/XEStrMap.c b/nx-X11/lib/XTrap/XEStrMap.c
new file mode 100644
index 000000000..2a97f13f4
--- /dev/null
+++ b/nx-X11/lib/XTrap/XEStrMap.c
@@ -0,0 +1,284 @@
+/* $XFree86: xc/lib/XTrap/XEStrMap.c,v 1.1 2001/11/02 23:29:27 dawes Exp $ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1994 by Digital Equipment Corp.,
+Maynard, MA
+
+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 <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+
+static char *eventName[] = {
+ "", "",
+ "KeyPress", "KeyRelease", "ButtonPress",
+ "ButtonRelease", "MotionNotify", "EnterNotify",
+ "LeaveNotify", "FocusIn", "FocusOut",
+ "KeymapNotify", "Expose", "GraphicsExpose",
+ "NoExpose", "VisibilityNotify", "CreateNotify",
+ "DestroyNotify", "UnmapNotify", "MapNotify",
+ "MapRequest", "ReparentNotify", "ConfigureNotify",
+ "ConfigureRequest", "GravityNotify", "ResizeRequest",
+ "CirculateNotify", "CirculateRequest", "PropertyNotify",
+ "SelectionClear", "SelectionRequest", "SelectionNotify",
+ "ColormapNotify", "ClientMessage", "MappingNotify",
+ "LASTEvent",
+};
+
+static char *requestName[] = {
+ "Invalid",
+ "X_CreateWindow", "X_ChangeWindowAttributes",
+ "X_GetWindowAttributes", "X_DestroyWindow",
+ "X_DestroySubwindows", "X_ChangeSaveSet",
+ "X_ReparentWindow", "X_MapWindow",
+ "X_MapSubwindows", "X_UnmapWindow",
+ "X_UnmapSubwindows", "X_ConfigureWindow",
+ "X_CirculateWindow", "X_GetGeometry",
+ "X_QueryTree", "X_InternAtom",
+ "X_GetAtomName", "X_ChangeProperty",
+ "X_DeleteProperty", "X_GetProperty",
+ "X_ListProperties", "X_SetSelectionOwner",
+ "X_GetSelectionOwner", "X_ConvertSelection",
+ "X_SendEvent", "X_GrabPointer",
+ "X_UngrabPointer", "X_GrabButton",
+ "X_UngrabButton", "X_ChangeActivePointerGrab",
+ "X_GrabKeyboard", "X_UngrabKeyboard",
+ "X_GrabKey", "X_UngrabKey",
+ "X_AllowEvents", "X_GrabServer",
+ "X_UngrabServer", "X_QueryPointer",
+ "X_GetMotionEvents", "X_TranslateCoords",
+ "X_WarpPointer", "X_SetInputFocus",
+ "X_GetInputFocus", "X_QueryKeymap",
+ "X_OpenFont", "X_CloseFont",
+ "X_QueryFont", "X_QueryTextExtents",
+ "X_ListFonts", "X_ListFontsWithInfo",
+ "X_SetFontPath", "X_GetFontPath",
+ "X_CreatePixmap", "X_FreePixmap",
+ "X_CreateGC", "X_ChangeGC",
+ "X_CopyGC", "X_SetDashes",
+ "X_SetClipRectangles", "X_FreeGC",
+ "X_ClearArea", "X_CopyArea",
+ "X_CopyPlane", "X_PolyPoint",
+ "X_PolyLine", "X_PolySegment",
+ "X_PolyRectangle", "X_PolyArc",
+ "X_FillPoly", "X_PolyFillRectangle",
+ "X_PolyFillArc", "X_PutImage",
+ "X_GetImage", "X_PolyText8",
+ "X_PolyText16", "X_ImageText8",
+ "X_ImageText16", "X_CreateColormap",
+ "X_FreeColormap", "X_CopyColormapAndFree",
+ "X_InstallColormap", "X_UninstallColormap",
+ "X_ListInstalledColormaps", "X_AllocColor",
+ "X_AllocNamedColor", "X_AllocColorCells",
+ "X_AllocColorPlanes", "X_FreeColors",
+ "X_StoreColors", "X_StoreNamedColor",
+ "X_QueryColors", "X_LookupColor",
+ "X_CreateCursor", "X_CreateGlyphCursor",
+ "X_FreeCursor", "X_RecolorCursorSize",
+ "X_QueryBestSize", "X_QueryExtension",
+ "X_ListExtensions", "X_ChangeKeyboardMapping",
+ "X_GetKeyboardMapping", "X_ChangeKeyboardControl",
+ "X_GetKeyboardControl", "X_Bell",
+ "X_ChangePointerControl", "X_GetPointerControl",
+ "X_SetScreenSaver", "X_GetScreenSaver",
+ "X_ChangeHosts", "X_ListHosts",
+ "X_SetAccessControl", "X_SetCloseDownMode",
+ "X_KillClient", "X_RotateProperties",
+ "X_ForceScreenSaver", "X_SetPointerMapping",
+ "X_GetPointerMapping", "X_SetModifierMapping",
+ "X_GetModifierMapping", "Invalid",
+ "Invalid", "Invalid",
+ "Invalid", "Invalid",
+ "Invalid", "Invalid",
+ "X_NoOperation",
+};
+
+typedef struct
+{
+ char *extName;
+ int extEvent;
+} _extensionData;
+_extensionData *extensionData;
+int numExtension = -1;
+
+static struct _pf_tbl {CARD32 id; char *str;} pf_tbl[] =
+{
+ {PF_Apollo, "Apollo"},
+ {PF_ATT, "ATT"},
+ {PF_Cray1, "Cray1"},
+ {PF_Cray2, "Cray2"},
+ {PF_DECUltrix, "DECUltrix"},
+ {PF_DECVMS, "DECVMS"},
+ {PF_DECELN, "DECELN"},
+ {PF_DECOSF1, "DECOSF1"},
+ {PF_DECVT1000, "DECVT1000"},
+ {PF_DECXTerm, "DECXTerm"},
+ {PF_HP9000s800, "HP9000s800"},
+ {PF_HP9000s300, "HP9000s300"},
+ {PF_IBMAT, "IBMAT"},
+ {PF_IBMRT, "IBMRT"},
+ {PF_IBMPS2, "IBMPS2"},
+ {PF_IBMRS, "IBMRS"},
+ {PF_MacII, "MacII"},
+ {PF_Pegasus, "Pegasus"},
+ {PF_SGI, "SGI"},
+ {PF_Sony, "Sony"},
+ {PF_Sun3, "Sun3"},
+ {PF_Sun386i, "Sun386i"},
+ {PF_SunSparc, "SunSparc"},
+ {PF_Other, "Other"} /* always the last one! */
+};
+
+static char unknown[] = "unknown";
+
+#define ASize(array) (sizeof(array)/sizeof((array)[0]))
+
+static INT16 _StringToID(register char *match, register char **strings,
+ INT16 nstrings)
+{
+ register INT16 id = nstrings;
+
+ if (match && *match)
+ { while ((--id >= 0L) && (strcmp(match,strings[id]) != 0L)); }
+ else
+ { id = -1L; }
+
+ return(id);
+}
+static void loadExtStrings(XETC *tc)
+{
+ char **extensionName=XListExtensions(tc->dpy,&numExtension);
+ if (numExtension)
+ {
+ int i;
+ extensionData = (_extensionData *)XtCalloc(numExtension,
+ sizeof(_extensionData));
+ for (i = 0; i < numExtension; i++)
+ { /* Arrange extensions in opcode order */
+ int opcode,event,error;
+ if (XQueryExtension(tc->dpy,extensionName[i],&opcode,&event,
+ &error))
+ {
+ extensionData[opcode-128].extName = extensionName[i];
+ extensionData[opcode-128].extEvent = event;
+ }
+ else
+ { /* This extension didn't load! Error! */
+ extensionData[opcode-128].extName = "Invalid_Extension";
+ }
+ }
+ XFreeExtensionList(extensionName);
+ }
+}
+
+INT16 XEEventStringToID(register char *string)
+{
+ return(_StringToID(string,eventName,ASize(eventName)));
+}
+
+INT16 XERequestStringToID(register char *string)
+{
+ return(_StringToID(string,requestName,ASize(requestName)));
+}
+
+CARD32 XEPlatformStringToID(register char *string)
+{
+ struct _pf_tbl *ptr = &(pf_tbl[0]);
+ while(ptr->id != PF_Other)
+ {
+ if (!strncmp(ptr->str, string, strlen(ptr->str)))
+ {
+ return(ptr->id);
+ }
+ ptr++;
+ }
+ return((!strncmp(ptr->str,string,strlen(ptr->str))) ? ptr->id : -1L);
+}
+
+char *XEEventIDToString(register CARD8 id, XETC *tc)
+{
+ int i;
+ if (id < ASize(eventName))
+ return(eventName[id]);
+ /* either erroneous or an extension event */
+ if (numExtension < 0)
+ { /*
+ * This is unfortunate, but necessary. The client
+ * program has requested the string identifier for
+ * an extension request/event. Since there's no Xlib
+ * equivalent for this, we have to query *all* the
+ * extensions looking for a match. Chances are
+ * if a client wants one, it'll want them all,
+ * so just go through and initialize the extension
+ * list once.
+ */
+ loadExtStrings(tc);
+ }
+ /* Find id within extensionData */
+ for (i=0; i<numExtension; i++)
+ {
+ if (extensionData[i].extEvent == id)
+ return(extensionData[i].extName);
+ }
+ return(unknown);
+}
+
+char *XERequestIDToExtString(register CARD8 id, XETC *tc)
+{
+ int extid;
+
+ extid = id - ASize(requestName);
+
+ if (numExtension < 0)
+ { /*
+ * This is unfortunate, but necessary. The client
+ * program has requested the string identifier for
+ * an extension request/event. Since there's no Xlib
+ * equivalent for this, we have to query *all* the
+ * extensions looking for a match. Chances are
+ * if a client wants one, it'll want them all,
+ * so just go through and initialize the extension
+ * list once.
+ */
+ loadExtStrings(tc);
+ }
+ return((extid >=0 && extid < numExtension) ?
+ extensionData[extid].extName : unknown);
+}
+
+
+char *XERequestIDToString(register CARD8 id, XETC *tc)
+{
+ return((id < ASize(requestName)) ? requestName[id] :
+ XERequestIDToExtString(id,tc));
+}
+
+char *XEPlatformIDToString(register CARD32 id)
+{
+ struct _pf_tbl *ptr = &(pf_tbl[0]);
+ while((ptr->id != PF_Other) || (id == ptr->id))
+ {
+ if (id == ptr->id)
+ {
+ return(ptr->str);
+ }
+ ptr++;
+ }
+ return(unknown);
+}
diff --git a/nx-X11/lib/XTrap/XETrapInit.c b/nx-X11/lib/XTrap/XETrapInit.c
new file mode 100644
index 000000000..a4a04310f
--- /dev/null
+++ b/nx-X11/lib/XTrap/XETrapInit.c
@@ -0,0 +1,218 @@
+/* $XFree86: xc/lib/XTrap/XETrapInit.c,v 1.2 2001/11/08 04:00:12 tsi Exp $ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991, 1992 by Digital Equipment Corp.,
+Maynard, MA
+
+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.
+
+*****************************************************************************/
+#define NEED_EVENTS
+#define NEED_REPLIES
+
+#include <stdio.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+#ifndef XETrapNumberErrors
+#define XETrapNumberErrors 0
+#endif
+
+#ifdef UWS40
+#define _XSetLastRequestRead _SetLastRequestRead
+#endif
+#ifndef vms
+extern unsigned long _XSetLastRequestRead(Display *dpy, xGenericReply *rep);
+#else
+static unsigned long _XSetLastRequestRead(Display *dpy, xGenericReply *rep);
+#endif
+
+static XExtensionInfo *xtrap_info = NULL;
+static /* const */ char *xtrap_extension_name = XTrapExtName;
+
+#define XTrapCheckExtension(dpy,i,val) \
+ XextCheckExtension(dpy, i, xtrap_extension_name, val)
+#define XTrapSimpleCheckExtension(dpy,i) \
+ XextSimpleCheckExtension(dpy, i, xtrap_extension_name)
+
+static XEXT_CLOSE_DISPLAY_PROTO(close_display);
+static Bool wire_to_event(Display *dpy, XEvent *event, xEvent *wire_ev);
+static Status event_to_wire(Display *dpy, XEvent *event, xEvent *wire_ev);
+
+#ifdef X11R3
+static int error_string();
+#else
+static XEXT_ERROR_STRING_PROTO(error_string);
+#endif
+static /* const */ XExtensionHooks xtrap_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ error_string /* error_string */
+};
+
+static /* const */ char *xtrap_error_list[] = {
+ "BadTransport (I/O transport not available)",
+ "BadMailbox (Cannot connect/disconnect to mailbox)",
+ "BadIO (I/O error while reading/writing in extension)",
+ "BadHostname (Cannot locate requested host)",
+ "BadStatistics (Statistics not configured/available)",
+ "BadDevices (Devices not properly vectored)",
+ "BadSocket (Cannot connect to INTERNET socket)",
+ "BadScreen (Cannot send event to given screen)",
+ "BadSwapReq (Cannot trap extension requests for swapped client)",
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xtrap_info,
+ xtrap_extension_name,
+ &xtrap_extension_hooks,
+ XETrapNumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xtrap_info)
+
+static XEXT_GENERATE_ERROR_STRING (error_string, xtrap_extension_name,
+ XETrapNumErrors, xtrap_error_list)
+
+static Bool event_to_wire(Display *dpy, XEvent *libevent, xEvent *netevent)
+{
+ Bool status = False;
+ XExtDisplayInfo *info = find_display(dpy);
+
+ XTrapCheckExtension(dpy,info,False);
+
+ /* If we had more then one event */
+#if XETrapNumberErrors > 1
+ switch((netevent->u.u.type & 0x7f) - info->codes->first_event)
+ { case XETrapData:
+#endif
+ {
+ XETrapDataEvent *ev = (XETrapDataEvent *) libevent;
+ xETrapDataEvent *event = (xETrapDataEvent *) netevent;
+
+ event->type = ev->type;
+ event->detail = ev->detail;
+ event->sequenceNumber = (ev->serial & 0xFFFF);
+ event->idx = ev->idx;
+ (void)memcpy(event->data,ev->data,sizeof(event->data));
+ status = True;
+ }
+#if XETrapNumberErrors > 1
+ }
+#endif
+ return(status);
+}
+
+static Bool wire_to_event(Display *dpy, XEvent *libevent, xEvent *netevent)
+{
+ Bool status = False;
+ XExtDisplayInfo *info = find_display(dpy);
+
+ XTrapCheckExtension(dpy,info,False);
+
+ /* If we had more then one event */
+#if XETrapNumberErrors > 1
+ switch((netevent->u.u.type & 0x7f) - info->codes->first_event)
+ { case XETrapData:
+#endif
+ {
+ XETrapDataEvent *ev = (XETrapDataEvent *) libevent;
+ xETrapDataEvent *event = (xETrapDataEvent *) netevent;
+
+ ev->type = event->type & 0x7F;
+ ev->detail = event->detail;
+ ev->serial = _XSetLastRequestRead(dpy,(xGenericReply *)netevent);
+ ev->synthetic = ((event->type & 0x80) != 0);
+ ev->display = dpy;
+ ev->idx = event->idx;
+ (void)memcpy(ev->data,event->data,sizeof(ev->data));
+ status = True;
+ }
+#if XETrapNumberErrors > 1
+ }
+#endif
+ return(status);
+}
+
+/*
+ * XETrapQueryExtension -
+ * Returns True if the DEC-XTRAP extension is available
+ * on the given display. If the extension exists, the value of the
+ * first event code is stored into event_base and the value of the first
+ * error code is stored into error_base.
+ */
+Bool XETrapQueryExtension(Display *dpy,INT32 *event_base_return,
+ INT32 *error_base_return, INT32 *opcode_return)
+{
+ Bool status = True;
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension (info))
+ {
+ *event_base_return = (INT32)(info->codes->first_event);
+ *error_base_return = (INT32)(info->codes->first_error);
+ *opcode_return = (INT32)(info->codes->major_opcode);
+ }
+ else
+ {
+ status = False;
+ }
+ return(status);
+}
+
+#ifdef vms
+/* Hard-coded since this didn't make it into XLibShr's xfer vector */
+/* From [.XLIBEL.SRC]XLibInt.c in VMS Source Pool */
+unsigned long _XSetLastRequestRead(Display *dpy, xGenericReply *rep)
+{
+ register unsigned long newseq, lastseq;
+
+ /*
+ * KeymapNotify has no sequence number, but is always guaranteed
+ * to immediately follow another event, except when generated via
+ * SendEvent (hmmm).
+ */
+ if ((rep->type & 0x7f) == KeymapNotify)
+ return(dpy->last_request_read);
+
+ newseq = (dpy->last_request_read & ~((unsigned long)0xffff)) |
+ rep->sequenceNumber;
+ lastseq = dpy->last_request_read;
+ while (newseq < lastseq) {
+ newseq += 0x10000;
+ if (newseq > dpy->request) {
+ (void) fprintf (stderr,
+ "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
+ newseq, dpy->request,
+ (unsigned int) rep->type);
+ newseq -= 0x10000;
+ break;
+ }
+ }
+
+ dpy->last_request_read = newseq;
+ return(newseq);
+}
+#endif
+
diff --git a/nx-X11/lib/XTrap/XEWrappers.c b/nx-X11/lib/XTrap/XEWrappers.c
new file mode 100644
index 000000000..40b7e211e
--- /dev/null
+++ b/nx-X11/lib/XTrap/XEWrappers.c
@@ -0,0 +1,325 @@
+/* $XFree86$ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991, 1994 by Digital Equipment Corp.,
+Maynard, MA
+X11R6 Changes Copyright (c) 1994 by Robert Chesler of Absol-Puter, Hudson, NH.
+
+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 AND ABSOL-PUTER DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL DIGITAL OR ABSOL-PUTER 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 <stdio.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+#ifdef vms
+#define IS_AT_OR_AFTER(t1, t2) (((t2).high > (t1).high) \
+ || (((t2).high == (t1).high)&& ((t2).low >= (t1).low)))
+typedef struct _vms_time {
+ unsigned long low;
+ unsigned long high;
+}vms_time; /* from IntrinsicP.h */
+#ifdef VMSDW_V3
+typedef struct _ModToKeysymTable {
+ Modifiers mask;
+ int count;
+ int index;
+} ModToKeysymTable; /* from TranslateI.h */
+typedef struct _ConverterRec **ConverterTable; /* from ConvertI.h */
+#include "libdef.h"
+typedef struct _CallbackRec *CallbackList; /* from CallbackI.h */
+typedef struct _XtGrabRec *XtGrabList; /* from EventI.h */
+#include <X11/PassivGraI.h>
+#include <X11/InitialI.h>
+#else /* VMSDW_V3 */
+typedef struct _ModToKeysymTable {
+ Modifiers mask;
+ int count;
+ int index;
+} ModToKeysymTable; /* from TranslateI.h */
+typedef struct _ConverterRec **ConverterTable; /* from ConvertI.h */
+#include "libdef.h"
+#define NFDBITS (sizeof(fd_mask) * 8)
+typedef long fd_mask;
+#ifndef howmany
+#define howmany(x, y) (((x)+((y)-1))/(y))
+#endif /* howmany */
+typedef struct Fd_set {
+ fd_mask fds_bits[howmany(256, NFDBITS)];
+} Fd_set; /* from fd.h */
+#include <X11/InitializeI.h>
+#endif /* VMSDW_V3 */
+#else /* !vms */
+#include <X11/IntrinsicI.h>
+#define IS_AT_OR_AFTER(t1, t2) (((t2).tv_sec > (t1).tv_sec) \
+ || (((t2).tv_sec == (t1).tv_sec)&& ((t2).tv_usec >= (t1).tv_usec)))
+#endif /* vms */
+
+/* The following has been lifted from NextEvent.c in X11R4 */
+
+#ifndef NEEDS_NTPD_FIXUP
+# ifdef sun
+# define NEEDS_NTPD_FIXUP 1
+# else
+# define NEEDS_NTPD_FIXUP 0
+# endif
+#endif
+
+#if NEEDS_NTPD_FIXUP
+#define FIXUP_TIMEVAL(t) { \
+ while ((t).tv_usec >= 1000000) { \
+ (t).tv_usec -= 1000000; \
+ (t).tv_sec++; \
+ } \
+ while ((t).tv_usec < 0) { \
+ if ((t).tv_sec > 0) { \
+ (t).tv_usec += 1000000; \
+ (t).tv_sec--; \
+ } else { \
+ (t).tv_usec = 0; \
+ break; \
+ } \
+ }}
+#else
+#define FIXUP_TIMEVAL(t)
+#endif /*NEEDS_NTPD_FIXUP*/
+
+
+/* The following code is required for the use of the XLIB transport of XTrap
+ * events. This is in line with what MIT wants to see proper extension
+ * implementations do, as compared to using one of the core input event masks.
+ */
+
+Boolean (*XETrapGetEventHandler(XETC *tc, CARD32 id))(XETrapDataEvent *event, XETC *tc)
+{
+ return((id < XETrapNumberEvents) ? tc->eventFunc[id] : NULL);
+}
+
+Boolean (*XETrapSetEventHandler(XETC *tc, CARD32 id,
+ Boolean (*pfunc)(XETrapDataEvent *event, XETC *tc)))(XETrapDataEvent *event, XETC *tc)
+{
+ register Boolean (*rfunc)(XETrapDataEvent *event, XETC *tc) = NULL;
+
+ if (id < XETrapNumberEvents)
+ {
+ rfunc = XETrapGetEventHandler(tc,id);
+ tc->eventFunc[id] = pfunc;
+ }
+ return(rfunc);
+}
+
+Boolean XETrapDispatchEvent(XEvent *pevent, XETC *tc)
+{
+ Boolean status = False;
+ register CARD32 id = pevent->type;
+ register CARD32 firstEvent = tc->eventBase;
+ register CARD32 lastEvent = tc->eventBase + XETrapNumberEvents - 1L;
+
+ /* If it is our extension event, handle it specially, otherwise, pass
+ * it off to Xt.
+ */
+ if (firstEvent != 0 && id >= firstEvent && id <= lastEvent)
+ {
+ /* We may be ignoring the event */
+ if (tc->eventFunc[id - firstEvent] != NULL)
+ {
+ status = (*tc->eventFunc[id - firstEvent])((XETrapDataEvent*)pevent,tc);
+ }
+ }
+ else
+ {
+ status = XtDispatchEvent(pevent);
+ }
+ return(status);
+}
+
+XtInputMask XETrapAppPending(XtAppContext app)
+{
+ TimerEventRec *te_ptr;
+#ifndef VMS
+ struct timeval cur_time;
+#else /* vms */
+ vms_time cur_time;
+ long efnMask = 0L;
+ int status;
+#endif /* vms */
+ XtInputMask retmask = XtAppPending(app); /* Prime XtIMEvent */
+
+ retmask &= ~(XtIMTimer | XtIMAlternateInput); /* clear timer & input */
+ /* Now test for timer */
+ te_ptr = app->timerQueue;
+ while (te_ptr != NULL)
+ {
+#ifndef vms
+ (void)gettimeofday(&cur_time, NULL);
+ FIXUP_TIMEVAL(cur_time);
+#else
+ sys$gettim(&cur_time);
+#endif /* vms */
+ if (IS_AT_OR_AFTER(te_ptr->te_timer_value, cur_time))
+ { /* this timer is due to fire */
+ retmask |= XtIMTimer;
+ break;
+ }
+ te_ptr = te_ptr->te_next;
+ }
+
+ /* Now test for alternate input */
+#ifndef vms
+ if (app->outstandingQueue != NULL)
+ {
+ retmask |= XtIMAlternateInput;
+ }
+#else /* vms */
+ if ((app->Input_EF_Mask != 0L) && ((status=SYS$READEF(1,&efnMask)) == 1))
+ { /* we have input configured & retrieved the efn cluster 0 */
+ efnMask &= app->Input_EF_Mask; /* mask out non-input */
+ if (efnMask) /* any left? */
+ { /* yes, an alt-input efn is set */
+ retmask |= XtIMAlternateInput;
+ }
+ }
+#endif /* vms */
+ return(retmask);
+}
+
+void XETrapAppMainLoop(XtAppContext app, XETC *tc)
+{
+ XEvent event;
+ XtInputMask imask;
+
+ while (1)
+ {
+ imask = XETrapAppPending(app);
+ /* Check to see what's going on so that we don't block
+ * in either NextEvent or ProcessEvent since neither
+ * of these routines can correctly deal with XTrap Events
+ */
+ if (imask & XtIMXEvent)
+ {
+ (void)XtAppNextEvent(app,&event);
+ (void)XETrapDispatchEvent(&event,tc);
+ }
+ else if (imask & (XtIMTimer | XtIMAlternateInput))
+ {
+ XtAppProcessEvent(app, (XtIMTimer | XtIMAlternateInput));
+ }
+ else
+ { /* Nothing going on, so we need to block */
+ (void)XETrapWaitForSomething(app);
+ }
+ }
+}
+
+int XETrapAppWhileLoop(XtAppContext app, XETC *tc, Bool *done)
+{
+ XEvent event;
+ XtInputMask imask;
+ int status = True;
+
+ if(done)
+ {
+ while (!(*done))
+ {
+ imask = XETrapAppPending(app);
+ /* Check to see what's going on so that we don't block
+ * in either NextEvent or ProcessEvent since neither
+ * of these routines can correctly deal with XTrap Events
+ */
+ if (imask & XtIMXEvent)
+ {
+ (void)XtAppNextEvent(app, &event);
+ (void)XETrapDispatchEvent(&event,tc);
+ }
+ else if (imask & (XtIMTimer | XtIMAlternateInput))
+ {
+ XtAppProcessEvent(app, (XtIMTimer | XtIMAlternateInput));
+ }
+ else
+ { /* Nothing going on, so we need to block */
+ (void)XETrapWaitForSomething(app);
+ }
+ }
+ }
+ else
+ {
+ status = False;
+ }
+ return(status);
+}
+
+/* Wait for either Timer, Alternate Input, or an X Event to arrive */
+int XETrapWaitForSomething(XtAppContext app)
+{
+#ifndef vms
+ return(_XtWaitForSomething(app, FALSE, FALSE, FALSE, FALSE, TRUE
+#ifdef XTHREADS
+ , FALSE
+#endif /* XTHREADS */
+ , 0L));
+#else /* vms */
+#define IS_AFTER(t1,t2) (((t2).high > (t1).high) \
+ ||(((t2).high == (t1).high)&& ((t2).low > (t1).low)))
+ long retval = 0L;
+ TimerEventRec *te_ptr;
+ vms_time cur_time,result_time;
+ int status = 0;
+ long quotient, remainder = 0;
+ int d;
+
+ if (app->timerQueue!= NULL)
+ { /* check timeout queue */
+ cur_time.low = cur_time.high = result_time.low = result_time.high = 0;
+ te_ptr = app->timerQueue;
+ sys$gettim(&cur_time);
+ if ((IS_AFTER(app->timerQueue->te_timer_value, cur_time)) &&
+ (app->timerQueue->te_proc != 0))
+ { /* it's fired! return! */
+ return(0);
+ }
+ /* Jump through hoops to get the time specified in the queue into
+ * milliseconds
+ */
+ status = lib$sub_times (&(te_ptr->te_timer_value.low), &cur_time,
+ &result_time);
+ /*
+ * See if this timer has expired. A timer is considered expired
+ * if it's value in the past (the NEGTIM case) or if there is
+ * less than one integral milli second before it would go off.
+ */
+
+ if (status == LIB$_NEGTIM ||
+ (result_time.high == -1 && result_time.low > -10000))
+ { /* We've got a timer and it's ready to fire! */
+ return(0);
+ }
+ else if ((status & 1) == 1)
+ {
+ lib$ediv (&(10000), &result_time, &quotient, &remainder);
+ quotient *= -1; /* flip the sign bit */
+
+ return(XMultiplexInput(app->count, &(app->list[0L]),
+ app->Input_EF_Mask, quotient, 0L, &retval));
+ }
+ else
+ {
+ status = -1;
+ }
+ }
+
+ return((status == -1 ? -1 : XMultiplexInput(app->count, &(app->list[0L]),
+ app->Input_EF_Mask, 0L, 0L, &retval)));
+#endif /* vms */
+}
diff --git a/nx-X11/lib/XTrap/XTrap-def.cpp b/nx-X11/lib/XTrap/XTrap-def.cpp
new file mode 100644
index 000000000..dc8a65a1a
--- /dev/null
+++ b/nx-X11/lib/XTrap/XTrap-def.cpp
@@ -0,0 +1,76 @@
+/* $XFree86$ */
+LIBRARY XTrap
+VERSION LIBRARY_VERSION
+EXPORTS
+ XEAddEventCB
+ XEAddEventCBs
+ XEAddRequestCB
+ XEAddRequestCBs
+ XERemoveAllEventCBs
+ XERemoveAllRequestCBs
+ XERemoveEventCB
+ XERemoveEventCBs
+ XERemoveRequestCB
+ XERemoveRequestCBs
+ XEChangeTC
+ XECreateTC
+ XEFreeTC
+ XESetCmdGateState
+ XETrapSetColorReplies
+ XETrapSetCommandKey
+ XETrapSetCursor
+ XETrapSetEvents
+ XETrapSetGrabServer
+ XETrapSetMaxPacket
+ XETrapSetRequests
+ XETrapSetStatistics
+ XETrapSetTimestamps
+ XETrapSetWinXY
+ XETrapSetXInput
+ XETrapDispatchXLib
+ XEPrintAvail
+ XEPrintAvailFlags
+ XEPrintAvailPktSz
+ XEPrintCfgFlags
+ XEPrintCmdKey
+ XEPrintCurPktSz
+ XEPrintCurXY
+ XEPrintCurrent
+ XEPrintEvents
+ XEPrintEvtStats
+ XEPrintLastTime
+ XEPrintMajOpcode
+ XEPrintPlatform
+ XEPrintRelease
+ XEPrintReqStats
+ XEPrintRequests
+ XEPrintStateFlags
+ XEPrintStatistics
+ XEPrintTkFlags
+ XEPrintTkRelease
+ XEPrintTkState
+ XEFlushConfig
+ XEGetAvailableRequest
+ XEGetCurrentRequest
+ XEGetLastInpTimeRequest
+ XEGetStatisticsRequest
+ XEGetVersionRequest
+ XEResetRequest
+ XESimulateXEventRequest
+ XEStartTrapRequest
+ XEStopTrapRequest
+ XEEventIDToString
+ XEEventStringToID
+ XEPlatformIDToString
+ XEPlatformStringToID
+ XERequestIDToExtString
+ XERequestIDToString
+ XERequestStringToID
+ XETrapQueryExtension
+ XETrapAppMainLoop
+ XETrapAppPending
+ XETrapAppWhileLoop
+ XETrapDispatchEvent
+ XETrapGetEventHandler
+ XETrapSetEventHandler
+ XETrapWaitForSomething
diff --git a/nx-X11/lib/Xau/AuDispose.c b/nx-X11/lib/Xau/AuDispose.c
new file mode 100644
index 000000000..58ffd61e7
--- /dev/null
+++ b/nx-X11/lib/Xau/AuDispose.c
@@ -0,0 +1,51 @@
+/* $Xorg: AuDispose.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuDispose.c,v 1.4 2001/07/25 15:04:48 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <stdlib.h>
+
+void
+XauDisposeAuth (auth)
+Xauth *auth;
+{
+ if (auth) {
+ if (auth->address) (void) free (auth->address);
+ if (auth->number) (void) free (auth->number);
+ if (auth->name) (void) free (auth->name);
+ if (auth->data) {
+ (void) bzero (auth->data, auth->data_length);
+ (void) free (auth->data);
+ }
+ free ((char *) auth);
+ }
+ return;
+}
diff --git a/nx-X11/lib/Xau/AuFileName.c b/nx-X11/lib/Xau/AuFileName.c
new file mode 100644
index 000000000..a51fc3bff
--- /dev/null
+++ b/nx-X11/lib/Xau/AuFileName.c
@@ -0,0 +1,75 @@
+/* $Xorg: AuFileName.c,v 1.5 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuFileName.c,v 3.6 2001/07/25 15:04:48 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <X11/Xos.h>
+#include <stdlib.h>
+
+char *
+XauFileName ()
+{
+ char *slashDotXauthority = "/.Xauthority";
+ char *name;
+ static char *buf;
+ static int bsize;
+#ifdef WIN32
+ char dir[128];
+#endif
+ int size;
+
+ if ((name = getenv ("XAUTHORITY")))
+ return name;
+ name = getenv ("HOME");
+ if (!name) {
+#ifdef WIN32
+ (void) strcpy (dir, "/users/");
+ if ((name = getenv("USERNAME"))) {
+ (void) strcat (dir, name);
+ name = dir;
+ }
+ if (!name)
+#endif
+ return 0;
+ }
+ size = strlen (name) + strlen(&slashDotXauthority[1]) + 2;
+ if (size > bsize) {
+ if (buf)
+ free (buf);
+ buf = malloc ((unsigned) size);
+ if (!buf)
+ return 0;
+ bsize = size;
+ }
+ strcpy (buf, name);
+ strcat (buf, slashDotXauthority + (name[1] == '\0' ? 1 : 0));
+ return buf;
+}
diff --git a/nx-X11/lib/Xau/AuGetAddr.c b/nx-X11/lib/Xau/AuGetAddr.c
new file mode 100644
index 000000000..ab13cb630
--- /dev/null
+++ b/nx-X11/lib/Xau/AuGetAddr.c
@@ -0,0 +1,112 @@
+/* $Xorg: AuGetAddr.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuGetAddr.c,v 1.5 2001/12/14 19:54:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <X11/Xos.h>
+
+static int
+binaryEqual (_Xconst char *a, _Xconst char *b, int len)
+{
+ while (len--)
+ if (*a++ != *b++)
+ return 0;
+ return 1;
+}
+
+Xauth *
+XauGetAuthByAddr (
+#if NeedWidePrototypes
+unsigned int family,
+unsigned int address_length,
+#else
+unsigned short family,
+unsigned short address_length,
+#endif
+_Xconst char* address,
+#if NeedWidePrototypes
+unsigned int number_length,
+#else
+unsigned short number_length,
+#endif
+_Xconst char* number,
+#if NeedWidePrototypes
+unsigned int name_length,
+#else
+unsigned short name_length,
+#endif
+_Xconst char* name)
+{
+ FILE *auth_file;
+ char *auth_name;
+ Xauth *entry;
+
+ auth_name = XauFileName ();
+ if (!auth_name)
+ return 0;
+ if (access (auth_name, R_OK) != 0) /* checks REAL id */
+ return 0;
+ auth_file = fopen (auth_name, "rb");
+ if (!auth_file)
+ return 0;
+ for (;;) {
+ entry = XauReadAuth (auth_file);
+ if (!entry)
+ break;
+ /*
+ * Match when:
+ * either family or entry->family are FamilyWild or
+ * family and entry->family are the same and
+ * address and entry->address are the same
+ * and
+ * either number or entry->number are empty or
+ * number and entry->number are the same
+ * and
+ * either name or entry->name are empty or
+ * name and entry->name are the same
+ */
+
+ if ((family == FamilyWild || entry->family == FamilyWild ||
+ (entry->family == family &&
+ address_length == entry->address_length &&
+ binaryEqual (entry->address, address, (int)address_length))) &&
+ (number_length == 0 || entry->number_length == 0 ||
+ (number_length == entry->number_length &&
+ binaryEqual (entry->number, number, (int)number_length))) &&
+ (name_length == 0 || entry->name_length == 0 ||
+ (entry->name_length == name_length &&
+ binaryEqual (entry->name, name, (int)name_length))))
+ break;
+ XauDisposeAuth (entry);
+ }
+ (void) fclose (auth_file);
+ return entry;
+}
diff --git a/nx-X11/lib/Xau/AuGetBest.c b/nx-X11/lib/Xau/AuGetBest.c
new file mode 100644
index 000000000..5ff1c7cd3
--- /dev/null
+++ b/nx-X11/lib/Xau/AuGetBest.c
@@ -0,0 +1,173 @@
+/* $Xorg: AuGetBest.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuGetBest.c,v 1.7 2001/12/14 19:54:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <X11/Xos.h>
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+#ifdef hpux
+#define X_INCLUDE_NETDB_H
+#define XOS_USE_NO_LOCKING
+#include <X11/Xos_r.h>
+#endif
+
+static int
+binaryEqual (_Xconst char *a, _Xconst char *b, int len)
+{
+ while (len--)
+ if (*a++ != *b++)
+ return 0;
+ return 1;
+}
+
+Xauth *
+XauGetBestAuthByAddr (
+#if NeedWidePrototypes
+ unsigned int family,
+ unsigned int address_length,
+#else
+ unsigned short family,
+ unsigned short address_length,
+#endif
+ _Xconst char* address,
+#if NeedWidePrototypes
+ unsigned int number_length,
+#else
+ unsigned short number_length,
+#endif
+ _Xconst char* number,
+ int types_length,
+ char** types,
+ _Xconst int* type_lengths)
+{
+ FILE *auth_file;
+ char *auth_name;
+ Xauth *entry;
+ Xauth *best;
+ int best_type;
+ int type;
+#ifdef hpux
+ char *fully_qual_address;
+ unsigned short fully_qual_address_length;
+#endif
+
+ auth_name = XauFileName ();
+ if (!auth_name)
+ return 0;
+ if (access (auth_name, R_OK) != 0) /* checks REAL id */
+ return 0;
+ auth_file = fopen (auth_name, "rb");
+ if (!auth_file)
+ return 0;
+
+#ifdef hpux
+ if (family == FamilyLocal) {
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ struct hostent *hostp;
+
+ /* make sure we try fully-qualified hostname */
+ if ((hostp = _XGethostbyname(address,hparams)) != NULL) {
+ fully_qual_address = hostp->h_name;
+ fully_qual_address_length = strlen(fully_qual_address);
+ }
+ else
+ {
+ fully_qual_address = NULL;
+ fully_qual_address_length = 0;
+ }
+ }
+#endif /* hpux */
+
+ best = 0;
+ best_type = types_length;
+ for (;;) {
+ entry = XauReadAuth (auth_file);
+ if (!entry)
+ break;
+ /*
+ * Match when:
+ * either family or entry->family are FamilyWild or
+ * family and entry->family are the same and
+ * address and entry->address are the same
+ * and
+ * either number or entry->number are empty or
+ * number and entry->number are the same
+ * and
+ * either name or entry->name are empty or
+ * name and entry->name are the same
+ */
+
+ if ((family == FamilyWild || entry->family == FamilyWild ||
+ (entry->family == family &&
+ ((address_length == entry->address_length &&
+ binaryEqual (entry->address, address, (int)address_length))
+#ifdef hpux
+ || (family == FamilyLocal &&
+ fully_qual_address_length == entry->address_length &&
+ binaryEqual (entry->address, fully_qual_address,
+ (int) fully_qual_address_length))
+#endif
+ ))) &&
+ (number_length == 0 || entry->number_length == 0 ||
+ (number_length == entry->number_length &&
+ binaryEqual (entry->number, number, (int)number_length))))
+ {
+ if (best_type == 0)
+ {
+ best = entry;
+ break;
+ }
+ for (type = 0; type < best_type; type++)
+ if (type_lengths[type] == entry->name_length &&
+ !(strncmp (types[type], entry->name, entry->name_length)))
+ {
+ break;
+ }
+ if (type < best_type)
+ {
+ if (best)
+ XauDisposeAuth (best);
+ best = entry;
+ best_type = type;
+ if (type == 0)
+ break;
+ continue;
+ }
+ }
+ XauDisposeAuth (entry);
+ }
+ (void) fclose (auth_file);
+ return best;
+}
diff --git a/nx-X11/lib/Xau/AuLock.c b/nx-X11/lib/Xau/AuLock.c
new file mode 100644
index 000000000..001235607
--- /dev/null
+++ b/nx-X11/lib/Xau/AuLock.c
@@ -0,0 +1,106 @@
+/* $Xorg: AuLock.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuLock.c,v 3.6 2002/05/31 18:45:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <X11/Xos.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <time.h>
+#define Time_t time_t
+#ifndef X_NOT_POSIX
+#include <unistd.h>
+#else
+#ifndef WIN32
+extern unsigned sleep ();
+#else
+#include <X11/Xwindows.h>
+#define link rename
+#endif
+#endif
+#ifdef __UNIXOS2__
+#define link rename
+#endif
+
+int
+XauLockAuth (
+_Xconst char *file_name,
+int retries,
+int timeout,
+long dead)
+{
+ char creat_name[1025], link_name[1025];
+ struct stat statb;
+ Time_t now;
+ int creat_fd = -1;
+
+ if (strlen (file_name) > 1022)
+ return LOCK_ERROR;
+ (void) strcpy (creat_name, file_name);
+ (void) strcat (creat_name, "-c");
+ (void) strcpy (link_name, file_name);
+ (void) strcat (link_name, "-l");
+ if (stat (creat_name, &statb) != -1) {
+ now = time ((Time_t *) 0);
+ /*
+ * NFS may cause ctime to be before now, special
+ * case a 0 deadtime to force lock removal
+ */
+ if (dead == 0 || now - statb.st_ctime > dead) {
+ (void) unlink (creat_name);
+ (void) unlink (link_name);
+ }
+ }
+
+ while (retries > 0) {
+ if (creat_fd == -1) {
+ creat_fd = open (creat_name, O_WRONLY | O_CREAT | O_EXCL, 0600);
+ if (creat_fd == -1) {
+ if (errno != EACCES)
+ return LOCK_ERROR;
+ } else
+ (void) close (creat_fd);
+ }
+ if (creat_fd != -1) {
+ if (link (creat_name, link_name) != -1)
+ return LOCK_SUCCESS;
+ if (errno == ENOENT) {
+ creat_fd = -1; /* force re-creat next time around */
+ continue;
+ }
+ if (errno != EEXIST)
+ return LOCK_ERROR;
+ }
+ (void) sleep ((unsigned) timeout);
+ --retries;
+ }
+ return LOCK_TIMEOUT;
+}
diff --git a/nx-X11/lib/Xau/AuRead.c b/nx-X11/lib/Xau/AuRead.c
new file mode 100644
index 000000000..60a0d747f
--- /dev/null
+++ b/nx-X11/lib/Xau/AuRead.c
@@ -0,0 +1,137 @@
+/* $Xorg: AuRead.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuRead.c,v 1.5 2001/07/25 15:04:48 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <stdlib.h>
+#include <errno.h>
+
+static int
+read_short (unsigned short *shortp, FILE *file)
+{
+ unsigned char file_short[2];
+
+ /*
+ * Added a check on EINTR to prevent the fread() call to be
+ * interrupted by any signal not blocked by OsBlockSignals().
+ */
+
+ for (;;) {
+ if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1) {
+ if (errno == EINTR && ferror (file)) {
+ perror ("Reading from auth file");
+ clearerr (file);
+ continue;
+ }
+ return 0;
+ }
+ break;
+ }
+ *shortp = file_short[0] * 256 + file_short[1];
+ return 1;
+}
+
+static int
+read_counted_string (unsigned short *countp, char **stringp, FILE *file)
+{
+ unsigned short len;
+ char *data;
+
+ if (read_short (&len, file) == 0)
+ return 0;
+ if (len == 0) {
+ data = 0;
+ } else {
+ data = malloc ((unsigned) len);
+ if (!data)
+ return 0;
+ for (;;)
+ {
+ if (fread (data, (int) sizeof (char), (int) len, file) != len)
+ {
+ if (errno == EINTR && ferror (file))
+ {
+ perror ("Reading from auth file");
+ clearerr (file);
+ continue;
+ }
+ bzero (data, len);
+ free (data);
+ return 0;
+ }
+ break;
+ }
+ }
+ *stringp = data;
+ *countp = len;
+ return 1;
+}
+
+Xauth *
+XauReadAuth (auth_file)
+FILE *auth_file;
+{
+ Xauth local;
+ Xauth *ret;
+
+ if (read_short (&local.family, auth_file) == 0)
+ return 0;
+ if (read_counted_string (&local.address_length, &local.address, auth_file) == 0)
+ return 0;
+ if (read_counted_string (&local.number_length, &local.number, auth_file) == 0) {
+ if (local.address) free (local.address);
+ return 0;
+ }
+ if (read_counted_string (&local.name_length, &local.name, auth_file) == 0) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ return 0;
+ }
+ if (read_counted_string (&local.data_length, &local.data, auth_file) == 0) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ if (local.name) free (local.name);
+ return 0;
+ }
+ ret = (Xauth *) malloc (sizeof (Xauth));
+ if (!ret) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ if (local.name) free (local.name);
+ if (local.data) {
+ bzero (local.data, local.data_length);
+ free (local.data);
+ }
+ return 0;
+ }
+ *ret = local;
+ return ret;
+}
diff --git a/nx-X11/lib/Xau/AuRead.c.NX.original b/nx-X11/lib/Xau/AuRead.c.NX.original
new file mode 100644
index 000000000..60a0d747f
--- /dev/null
+++ b/nx-X11/lib/Xau/AuRead.c.NX.original
@@ -0,0 +1,137 @@
+/* $Xorg: AuRead.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuRead.c,v 1.5 2001/07/25 15:04:48 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <stdlib.h>
+#include <errno.h>
+
+static int
+read_short (unsigned short *shortp, FILE *file)
+{
+ unsigned char file_short[2];
+
+ /*
+ * Added a check on EINTR to prevent the fread() call to be
+ * interrupted by any signal not blocked by OsBlockSignals().
+ */
+
+ for (;;) {
+ if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1) {
+ if (errno == EINTR && ferror (file)) {
+ perror ("Reading from auth file");
+ clearerr (file);
+ continue;
+ }
+ return 0;
+ }
+ break;
+ }
+ *shortp = file_short[0] * 256 + file_short[1];
+ return 1;
+}
+
+static int
+read_counted_string (unsigned short *countp, char **stringp, FILE *file)
+{
+ unsigned short len;
+ char *data;
+
+ if (read_short (&len, file) == 0)
+ return 0;
+ if (len == 0) {
+ data = 0;
+ } else {
+ data = malloc ((unsigned) len);
+ if (!data)
+ return 0;
+ for (;;)
+ {
+ if (fread (data, (int) sizeof (char), (int) len, file) != len)
+ {
+ if (errno == EINTR && ferror (file))
+ {
+ perror ("Reading from auth file");
+ clearerr (file);
+ continue;
+ }
+ bzero (data, len);
+ free (data);
+ return 0;
+ }
+ break;
+ }
+ }
+ *stringp = data;
+ *countp = len;
+ return 1;
+}
+
+Xauth *
+XauReadAuth (auth_file)
+FILE *auth_file;
+{
+ Xauth local;
+ Xauth *ret;
+
+ if (read_short (&local.family, auth_file) == 0)
+ return 0;
+ if (read_counted_string (&local.address_length, &local.address, auth_file) == 0)
+ return 0;
+ if (read_counted_string (&local.number_length, &local.number, auth_file) == 0) {
+ if (local.address) free (local.address);
+ return 0;
+ }
+ if (read_counted_string (&local.name_length, &local.name, auth_file) == 0) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ return 0;
+ }
+ if (read_counted_string (&local.data_length, &local.data, auth_file) == 0) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ if (local.name) free (local.name);
+ return 0;
+ }
+ ret = (Xauth *) malloc (sizeof (Xauth));
+ if (!ret) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ if (local.name) free (local.name);
+ if (local.data) {
+ bzero (local.data, local.data_length);
+ free (local.data);
+ }
+ return 0;
+ }
+ *ret = local;
+ return ret;
+}
diff --git a/nx-X11/lib/Xau/AuRead.c.X.original b/nx-X11/lib/Xau/AuRead.c.X.original
new file mode 100644
index 000000000..f7cdf8f3a
--- /dev/null
+++ b/nx-X11/lib/Xau/AuRead.c.X.original
@@ -0,0 +1,111 @@
+/* $Xorg: AuRead.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuRead.c,v 1.5 2001/07/25 15:04:48 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <stdlib.h>
+
+static int
+read_short (unsigned short *shortp, FILE *file)
+{
+ unsigned char file_short[2];
+
+ if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1)
+ return 0;
+ *shortp = file_short[0] * 256 + file_short[1];
+ return 1;
+}
+
+static int
+read_counted_string (unsigned short *countp, char **stringp, FILE *file)
+{
+ unsigned short len;
+ char *data;
+
+ if (read_short (&len, file) == 0)
+ return 0;
+ if (len == 0) {
+ data = 0;
+ } else {
+ data = malloc ((unsigned) len);
+ if (!data)
+ return 0;
+ if (fread (data, (int) sizeof (char), (int) len, file) != len) {
+ bzero (data, len);
+ free (data);
+ return 0;
+ }
+ }
+ *stringp = data;
+ *countp = len;
+ return 1;
+}
+
+Xauth *
+XauReadAuth (auth_file)
+FILE *auth_file;
+{
+ Xauth local;
+ Xauth *ret;
+
+ if (read_short (&local.family, auth_file) == 0)
+ return 0;
+ if (read_counted_string (&local.address_length, &local.address, auth_file) == 0)
+ return 0;
+ if (read_counted_string (&local.number_length, &local.number, auth_file) == 0) {
+ if (local.address) free (local.address);
+ return 0;
+ }
+ if (read_counted_string (&local.name_length, &local.name, auth_file) == 0) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ return 0;
+ }
+ if (read_counted_string (&local.data_length, &local.data, auth_file) == 0) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ if (local.name) free (local.name);
+ return 0;
+ }
+ ret = (Xauth *) malloc (sizeof (Xauth));
+ if (!ret) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ if (local.name) free (local.name);
+ if (local.data) {
+ bzero (local.data, local.data_length);
+ free (local.data);
+ }
+ return 0;
+ }
+ *ret = local;
+ return ret;
+}
diff --git a/nx-X11/lib/Xau/AuUnlock.c b/nx-X11/lib/Xau/AuUnlock.c
new file mode 100644
index 000000000..460effe86
--- /dev/null
+++ b/nx-X11/lib/Xau/AuUnlock.c
@@ -0,0 +1,62 @@
+/* $Xorg: AuUnlock.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuUnlock.c,v 1.4 2001/12/14 19:54:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <X11/Xos.h>
+
+int
+XauUnlockAuth (
+_Xconst char *file_name)
+{
+#ifndef WIN32
+ char creat_name[1025];
+#endif
+ char link_name[1025];
+
+ if (strlen (file_name) > 1022)
+ return 0;
+#ifndef WIN32
+ (void) strcpy (creat_name, file_name);
+ (void) strcat (creat_name, "-c");
+#endif
+ (void) strcpy (link_name, file_name);
+ (void) strcat (link_name, "-l");
+ /*
+ * I think this is the correct order
+ */
+#ifndef WIN32
+ (void) unlink (creat_name);
+#endif
+ (void) unlink (link_name);
+
+ return 1;
+}
diff --git a/nx-X11/lib/Xau/AuWrite.c b/nx-X11/lib/Xau/AuWrite.c
new file mode 100644
index 000000000..f25abc9e6
--- /dev/null
+++ b/nx-X11/lib/Xau/AuWrite.c
@@ -0,0 +1,73 @@
+/* $Xorg: AuWrite.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuWrite.c,v 1.3 2001/01/17 19:42:24 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+
+static int
+write_short (unsigned short s, FILE *file)
+{
+ unsigned char file_short[2];
+
+ file_short[0] = (s & (unsigned)0xff00) >> 8;
+ file_short[1] = s & 0xff;
+ if (fwrite ((char *) file_short, (int) sizeof (file_short), 1, file) != 1)
+ return 0;
+ return 1;
+}
+
+static int
+write_counted_string (unsigned short count, char *string, FILE *file)
+{
+ if (write_short (count, file) == 0)
+ return 0;
+ if (fwrite (string, (int) sizeof (char), (int) count, file) != count)
+ return 0;
+ return 1;
+}
+
+int
+XauWriteAuth (auth_file, auth)
+FILE *auth_file;
+Xauth *auth;
+{
+ if (write_short (auth->family, auth_file) == 0)
+ return 0;
+ if (write_counted_string (auth->address_length, auth->address, auth_file) == 0)
+ return 0;
+ if (write_counted_string (auth->number_length, auth->number, auth_file) == 0)
+ return 0;
+ if (write_counted_string (auth->name_length, auth->name, auth_file) == 0)
+ return 0;
+ if (write_counted_string (auth->data_length, auth->data, auth_file) == 0)
+ return 0;
+ return 1;
+}
diff --git a/nx-X11/lib/Xau/Autest.c b/nx-X11/lib/Xau/Autest.c
new file mode 100644
index 000000000..298464908
--- /dev/null
+++ b/nx-X11/lib/Xau/Autest.c
@@ -0,0 +1,71 @@
+/* $Xorg: Autest.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+
+main (argc, argv)
+char **argv;
+{
+ Xauth test_data;
+ char *name, *data, *file;
+ int state = 0;
+ FILE *output;
+
+ while (*++argv) {
+ if (!strcmp (*argv, "-file"))
+ file = *++argv;
+ else if (state == 0) {
+ name = *argv;
+ ++state;
+ } else if (state == 1) {
+ data = *argv;
+ ++state;
+ }
+ }
+ if(!file) {
+ fprintf (stderr, "No file\n");
+ exit (1);
+ }
+ test_data.family = 0;
+ test_data.address_length = 0;
+ test_data.address = "";
+ test_data.number_length = 0;
+ test_data.number = "";
+ test_data.name_length = strlen (name);
+ test_data.name = name;
+ test_data.data_length = strlen (data);
+ test_data.data = data;
+ output = fopen (file, "w");
+ if (output) {
+ XauWriteAuth (output, &test_data);
+ fclose (output);
+ }
+}
diff --git a/nx-X11/lib/Xau/Imakefile b/nx-X11/lib/Xau/Imakefile
new file mode 100644
index 000000000..49cb7dcd3
--- /dev/null
+++ b/nx-X11/lib/Xau/Imakefile
@@ -0,0 +1,49 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:45:29 cpqbld Exp $
+XCOMM $XdotOrg: xc/lib/Xau/Imakefile,v 1.4 2005/09/22 23:54:18 alanc Exp $
+
+
+
+XCOMM $XFree86: xc/lib/Xau/Imakefile,v 3.5 1999/04/17 09:08:11 dawes Exp $
+
+#define DoNormalLib NormalLibXau
+#define DoSharedLib SharedLibXau
+#define DoExtraLib SharedLibXau
+#define DoDebugLib DebugLibXau
+#define DoProfileLib ProfileLibXau
+#define LibName Xau
+#define SoRev SOXAUTHREV
+#define IncSubdir X11
+
+#include <Threads.tmpl>
+
+#ifdef SharedXauReqs
+REQUIREDLIBS = SharedXauReqs
+#endif
+
+ LINTLIBS = $(LINTXLIB)
+
+#if HasKrb5
+K5ENCSRC = k5encode.c
+K5ENCOBJ = k5encode.o
+INCLUDES = Krb5Includes
+#else
+K5ENCSRC =
+K5ENCOBJ =
+INCLUDES =
+#endif
+
+HEADERS = \
+ Xauth.h
+
+SRCS = AuDispose.c AuFileName.c AuGetAddr.c AuGetBest.c AuLock.c \
+ AuRead.c AuUnlock.c AuWrite.c $(K5ENCSRC)
+
+OBJS = AuDispose.o AuFileName.o AuGetAddr.o AuGetBest.o AuLock.o \
+ AuRead.o AuUnlock.o AuWrite.o $(K5ENCOBJ)
+
+#define IncludeSharedObjectInNormalLib
+#define UnsharedLibObjCompile(options) LibObjCompile(unshared,$(CDEBUGFLAGS) $(CLIBDEBUGFLAGS) options $(PICFLAGS))
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/Xau/README b/nx-X11/lib/Xau/README
new file mode 100644
index 000000000..404eef079
--- /dev/null
+++ b/nx-X11/lib/Xau/README
@@ -0,0 +1,184 @@
+
+
+ A Sample Authorization Protocol for X
+
+
+Overview
+
+The following note describes a very simple mechanism for providing individual
+access to an X Window System display. It uses existing core protocol and
+library hooks for specifying authorization data in the connection setup block
+to restrict use of the display to only those clients that show that they
+know a server-specific key called a "magic cookie". This mechanism is *not*
+being proposed as an addition to the Xlib standard; among other reasons, a
+protocol extension is needed to support more flexible mechanisms. We have
+implemented this mechanism already; if you have comments, please send them
+to us.
+
+This scheme involves changes to the following parts of the sample release:
+
+ o xdm
+ - generate random magic cookie and store in protected file
+ - pass name of magic cookie file to server
+ - when user logs in, add magic cookie to user's auth file
+ - when user logs out, generate a new cookie for server
+
+ o server
+ - a new command line option to specify cookie file
+ - check client authorization data against magic cookie
+ - read in cookie whenever the server resets
+ - do not add local machine to host list if magic cookie given
+
+ o Xlib
+ - read in authorization data from file
+ - find data for appropriate server
+ - send authorization data if found
+
+ o xauth [new program to manage user auth file]
+ - add entries to user's auth file
+ - remove entries from user's auth file
+
+This mechanism assumes that the superuser and the transport layer between
+the client and the server is secure. Organizations that desire stricter
+security are encouraged to look at systems such as Kerberos (at Project
+Athena).
+
+
+Description
+
+The sample implementation will use the xdm Display Manager to set up and
+control the server's authorization file. Sites that do not run xdm will
+need to build their own mechanisms.
+
+Xdm uses a random key (seeded by the system time and check sum of /dev/kmem)
+to generate a unique sequence of characters at 16 bytes long. This sequence
+will be written to a file which is made readable only by the server. The
+server will then be started with a command line option instructing it to use
+the contents of the file as the magic cookie for connections that include
+authorization data. This will also disable the server from adding the local
+machine's address to the initial host list. Note that the actual cookie must
+not be stored on the command line or in an environment variable, to prevent
+it from being publicly obtainable by the "ps" command.
+
+If a client presents an authorization name of "MIT-MAGIC-COOKIE-1" and
+authorization data that matches the magic cookie, that client is allowed
+access. If the name or data does not match and the host list is empty,
+that client will be denied access. Otherwise, the existing host-based access
+control will be used. Since any client that is making a connection from a
+machine on the host list will be granted access even if their authorization
+data is incorrect, sites are strongly urged not to set up any default hosts
+using the /etc/X*.hosts files. Granting access to other machines should be
+done by the user's session manager instead.
+
+Assuming the server is configured with an empty host list, the existence of the
+cookie is sufficient to ensure there will be no unauthorized access to the
+display. However, xdm will (continue to) work to minimize the chances of
+spoofing on servers that do not support this authorization mechanism. This
+will be done by grabbing the server and the keyboard after opening the display.
+This action will be surrounded by a timer which will kill the server if the
+grabs cannot be done within several seconds. [This level of security is now
+implemented in patches already sent out.]
+
+After the user logs in, xdm will add authorization entries for each of the
+server machine's network addresses to the user's authorization file (the format
+of which is described below). This file will usually be named .Xauthority in
+the users's home directory; will be owned by the user (as specified by the
+pw_uid and pw_gid fields in the user's password entry), and will be accessible
+only to the user (no group access). This file will contain authorization data
+for all of the displays opened by the user.
+
+When the session terminates, xdm will generate and store a new magic cookie
+for the server. Then, xdm will shutdown its own connection and send a
+SIGHUP to the server process, which should cause the server to reset. The
+server will then read in the new magic cookie.
+
+To support accesses (both read and write) from multiple machines (for use in
+environments that use distributed file systems), file locking is done using
+hard links. This is done by creat'ing (sic) a lock file and then linking it
+to another name in the same directory. If the link-target already exists,
+the link will fail, indicating failure to obtain the lock. Linking is used
+instead of just creating the file read-only since link will fail even for
+the superuser.
+
+Problems and Solutions
+
+There are a few problems with .Xauthority as described. If no home directory
+exists, or if xdm cannot create a file there (disk full), xdm stores the
+cookie in a file in a resource-specified back-up directory, and sets an
+environment variable in the user's session (called XAUTHORITY) naming this
+file. There is also the problem that the locking attempts will need to be
+timed out, due to a leftover lock. Xdm, again, creates a file and set an
+environment variable. Finally, the back-up directory might be full. Xdm,
+as a last resort, provides a function key binding that allows a user to log
+in without having the authorization data stored, and with host-based access
+control disabled.
+
+Xlib
+
+XOpenDisplay in Xlib was enhanced to allow specification of authorization
+information. As implied above, Xlib looks for the data in the
+.Xauthority file of the home directory, or in the file pointed at by the
+XAUTHORITY environment variable instead if that is defined. This required
+no programmatic interface change to Xlib. In addition, a new Xlib routine
+is provided to explicitly specify authorization.
+
+ XSetAuthorization(name, namelen, data, datalen)
+ int namelen, datalen;
+ char *name, *data;
+
+There are three types of input:
+
+ name NULL, data don't care - use default authorization mechanism.
+ name non-NULL, data NULL - use the named authorization; get
+ data from that mechanism's default.
+ name non-NULL, data non-NULL - use the given authorization and data.
+
+This interface is used by xdm and might also be used by any other
+applications that wish to explicitly set the authorization information.
+
+Authorization File
+
+The .Xauthority file is a binary file consisting of a sequence of entries
+in the following format:
+
+ 2 bytes Family value (second byte is as in protocol HOST)
+ 2 bytes address length (always MSB first)
+ A bytes host address (as in protocol HOST)
+ 2 bytes display "number" length (always MSB first)
+ S bytes display "number" string
+ 2 bytes name length (always MSB first)
+ N bytes authorization name string
+ 2 bytes data length (always MSB first)
+ D bytes authorization data string
+
+The format is binary for easy processing, since authorization information
+usually consists of arbitrary data. Host addresses are used instead of
+names to eliminate potentially time-consuming name resolutions in
+XOpenDisplay. Programs, such as xdm, that initialize the user's
+authorization file will have to do the same work as the server in finding
+addresses for all network interfaces. If more than one entry matches the
+desired address, the entry that is chosen is implementation-dependent. In
+our implementation, it is always the first in the file.
+
+The Family is specified in two bytes to allow out-of-band values
+(i.e. values not in the Protocol) to be used. In particular,
+two new values "FamilyLocal" and "FamilyWild" are defined. FamilyLocal
+refers to any connections using a non-network method of connetion from the
+local machine (Unix domain sockets, shared memory, loopback serial line).
+In this case the host address is specified by the data returned from
+gethostname() and better be unique in a collection of machines
+which share NFS directories. FamilyWild is currently used only
+by xdm to communicate authorization data to the server. It matches
+any family/host address pair.
+
+For FamilyInternet, the host address is the 4 byte internet address, for
+FamilyDecnet, the host address is the byte decnet address, for FamilyChaos
+the address is also two bytes.
+
+The Display Number is the ascii representation of the display number
+portion of the display name. It is in ascii to allow future expansion
+to PseudoRoots or anything else that might happen.
+
+A utility called "xauth" will be provided for editing and viewing the
+contents of authorization files. Note that the user's authorization file is
+not the same as the server's magic cookie file.
diff --git a/nx-X11/lib/Xau/Xauth.h b/nx-X11/lib/Xau/Xauth.h
new file mode 100644
index 000000000..fa9c96bf8
--- /dev/null
+++ b/nx-X11/lib/Xau/Xauth.h
@@ -0,0 +1,162 @@
+/* $Xorg: Xauth.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+
+/* $XFree86: xc/lib/Xau/Xauth.h,v 1.5 2001/12/14 19:54:36 dawes Exp $ */
+
+#ifndef _Xauth_h
+#define _Xauth_h
+
+typedef struct xauth {
+ unsigned short family;
+ unsigned short address_length;
+ char *address;
+ unsigned short number_length;
+ char *number;
+ unsigned short name_length;
+ char *name;
+ unsigned short data_length;
+ char *data;
+} Xauth;
+
+#ifndef _XAUTH_STRUCT_ONLY
+
+# include <X11/Xfuncproto.h>
+# include <X11/Xfuncs.h>
+
+# include <stdio.h>
+
+# define FamilyLocal (256) /* not part of X standard (i.e. X.h) */
+# define FamilyWild (65535)
+# define FamilyNetname (254) /* not part of X standard */
+# define FamilyKrb5Principal (253) /* Kerberos 5 principal name */
+# define FamilyLocalHost (252) /* for local non-net authentication */
+
+
+_XFUNCPROTOBEGIN
+
+char *XauFileName(void);
+
+Xauth *XauReadAuth(
+FILE* /* auth_file */
+);
+
+int XauLockAuth(
+_Xconst char* /* file_name */,
+int /* retries */,
+int /* timeout */,
+long /* dead */
+);
+
+int XauUnlockAuth(
+_Xconst char* /* file_name */
+);
+
+int XauWriteAuth(
+FILE* /* auth_file */,
+Xauth* /* auth */
+);
+
+Xauth *XauGetAuthByName(
+_Xconst char* /* display_name */
+);
+
+Xauth *XauGetAuthByAddr(
+#if NeedWidePrototypes
+unsigned int /* family */,
+unsigned int /* address_length */,
+#else
+unsigned short /* family */,
+unsigned short /* address_length */,
+#endif
+_Xconst char* /* address */,
+#if NeedWidePrototypes
+unsigned int /* number_length */,
+#else
+unsigned short /* number_length */,
+#endif
+_Xconst char* /* number */,
+#if NeedWidePrototypes
+unsigned int /* name_length */,
+#else
+unsigned short /* name_length */,
+#endif
+_Xconst char* /* name */
+);
+
+Xauth *XauGetBestAuthByAddr(
+#if NeedWidePrototypes
+unsigned int /* family */,
+unsigned int /* address_length */,
+#else
+unsigned short /* family */,
+unsigned short /* address_length */,
+#endif
+_Xconst char* /* address */,
+#if NeedWidePrototypes
+unsigned int /* number_length */,
+#else
+unsigned short /* number_length */,
+#endif
+_Xconst char* /* number */,
+int /* types_length */,
+char** /* type_names */,
+_Xconst int* /* type_lengths */
+);
+
+void XauDisposeAuth(
+Xauth* /* auth */
+);
+
+#ifdef K5AUTH
+#include <krb5/krb5.h>
+/* 9/93: krb5.h leaks some symbols */
+#undef BITS32
+#undef xfree
+
+int XauKrb5Encode(
+ krb5_principal /* princ */,
+ krb5_data * /* outbuf */
+);
+
+int XauKrb5Decode(
+ krb5_data /* inbuf */,
+ krb5_principal * /* princ */
+);
+#endif /* K5AUTH */
+
+_XFUNCPROTOEND
+
+/* Return values from XauLockAuth */
+
+# define LOCK_SUCCESS 0 /* lock succeeded */
+# define LOCK_ERROR 1 /* lock unexpectely failed, check errno */
+# define LOCK_TIMEOUT 2 /* lock failed, timeouts expired */
+
+#endif /* _XAUTH_STRUCT_ONLY */
+
+#endif /* _Xauth_h */
diff --git a/nx-X11/lib/Xau/k5encode.c b/nx-X11/lib/Xau/k5encode.c
new file mode 100644
index 000000000..a3c6c09b1
--- /dev/null
+++ b/nx-X11/lib/Xau/k5encode.c
@@ -0,0 +1,186 @@
+/* $Xorg: k5encode.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * functions to encode/decode Kerberos V5 principals
+ * into something that can be reasonable spewed over
+ * the wire
+ *
+ * Author: Tom Yu <tlyu@MIT.EDU>
+ *
+ * Still needs to be fixed up wrt signed/unsigned lengths, but we'll worry
+ * about that later.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <krb5/krb5.h>
+/* 9/93: krb5.h leaks some symbols */
+#undef BITS32
+#undef xfree
+
+#include <X11/X.h>
+#include <X11/Xos.h>
+#include <X11/Xmd.h>
+#include <X11/Xfuncs.h>
+
+/*
+ * XauKrb5Encode
+ *
+ * this function encodes the principal passed to it in a format that can
+ * easily be dealt with by stuffing it into an X packet. Encoding is as
+ * follows:
+ * length count of the realm name
+ * realm
+ * component count
+ * length of component
+ * actual principal component
+ * etc....
+ *
+ * Note that this function allocates a hunk of memory, which must be
+ * freed to avoid nasty memory leak type things. All counts are
+ * byte-swapped if needed. (except for the total length returned)
+ *
+ * nevermind.... stuffing the encoded packet in net byte order just to
+ * always do the right thing. Don't have to frob with alignment that way.
+ */
+int
+XauKrb5Encode(princ, outbuf)
+ krb5_principal princ; /* principal to encode */
+ krb5_data *outbuf; /* output buffer */
+{
+ CARD16 i, numparts, totlen = 0, plen, rlen;
+ char *cp, *pdata;
+
+ rlen = krb5_princ_realm(princ)->length;
+ numparts = krb5_princ_size(princ);
+ totlen = 2 + rlen + 2; /* include room for realm length
+ and component count */
+ for (i = 0; i < numparts; i++)
+ totlen += krb5_princ_component(princ, i)->length + 2;
+ /* add 2 bytes each time for length */
+ if ((outbuf->data = (char *)malloc(totlen)) == NULL)
+ return -1;
+ cp = outbuf->data;
+ *cp++ = (char)((int)(0xff00 & rlen) >> 8);
+ *cp++ = (char)(0x00ff & rlen);
+ memcpy(cp, krb5_princ_realm(princ)->data, rlen);
+ cp += rlen;
+ *cp++ = (char)((int)(0xff00 & numparts) >> 8);
+ *cp++ = (char)(0x00ff & numparts);
+ for (i = 0; i < numparts; i++)
+ {
+ plen = krb5_princ_component(princ, i)->length;
+ pdata = krb5_princ_component(princ, i)->data;
+ *cp++ = (char)((int)(0xff00 & plen) >> 8);
+ *cp++ = (char)(0x00ff & plen);
+ memcpy(cp, pdata, plen);
+ cp += plen;
+ }
+ outbuf->length = totlen;
+ return 0;
+}
+
+/*
+ * XauKrb5Decode
+ *
+ * This function essentially reverses what XauKrb5Encode does.
+ * return value: 0 if okay, -1 if malloc fails, -2 if inbuf format bad
+ */
+int
+XauKrb5Decode(inbuf, princ)
+ krb5_data inbuf;
+ krb5_principal *princ;
+{
+ CARD16 i, numparts, plen, rlen;
+ CARD8 *cp, *pdata;
+
+ if (inbuf.length < 4)
+ {
+ return -2;
+ }
+ *princ = (krb5_principal)malloc(sizeof (krb5_principal_data));
+ if (*princ == NULL)
+ return -1;
+ bzero(*princ, sizeof (krb5_principal_data));
+ cp = (CARD8 *)inbuf.data;
+ rlen = *cp++ << 8;
+ rlen |= *cp++;
+ if (inbuf.length < 4 + (int)rlen + 2)
+ {
+ krb5_free_principal(*princ);
+ return -2;
+ }
+ krb5_princ_realm(*princ)->data = (char *)malloc(rlen);
+ if (krb5_princ_realm(*princ)->data == NULL)
+ {
+ krb5_free_principal(*princ);
+ return -1;
+ }
+ krb5_princ_realm(*princ)->length = rlen;
+ memcpy(krb5_princ_realm(*princ)->data, cp, rlen);
+ cp += rlen;
+ numparts = *cp++ << 8;
+ numparts |= *cp++;
+ krb5_princ_name(*princ) =
+ (krb5_data *)malloc(numparts * sizeof (krb5_data));
+ if (krb5_princ_name(*princ) == NULL)
+ {
+ krb5_free_principal(*princ);
+ return -1;
+ }
+ krb5_princ_size(*princ) = 0;
+ for (i = 0; i < numparts; i++)
+ {
+ if (cp + 2 > (CARD8 *)inbuf.data + inbuf.length)
+ {
+ krb5_free_principal(*princ);
+ return -2;
+ }
+ plen = *cp++ << 8;
+ plen |= *cp++;
+ if (cp + plen > (CARD8 *)inbuf.data + inbuf.length)
+ {
+ krb5_free_principal(*princ);
+ return -2;
+ }
+ pdata = (CARD8 *)malloc(plen);
+ if (pdata == NULL)
+ {
+ krb5_free_principal(*princ);
+ return -1;
+ }
+ krb5_princ_component(*princ, i)->data = (char *)pdata;
+ krb5_princ_component(*princ, i)->length = plen;
+ memcpy(pdata, cp, plen);
+ cp += plen;
+ krb5_princ_size(*princ)++;
+ }
+ return 0;
+}
diff --git a/nx-X11/lib/Xaw/Actions.c b/nx-X11/lib/Xaw/Actions.c
new file mode 100644
index 000000000..a65308b6a
--- /dev/null
+++ b/nx-X11/lib/Xaw/Actions.c
@@ -0,0 +1,1139 @@
+/*
+ * Copyright (c) 1998 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+
+/* $XFree86: xc/lib/Xaw/Actions.c,v 3.17 2003/03/25 04:18:10 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <X11/Xmd.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/CoreP.h>
+#include <X11/Constraint.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xfuncs.h>
+#include "Private.h"
+
+#ifdef __UNIXOS2__
+static char dummy;
+#endif
+
+#ifndef OLDXAW
+
+/*
+ * Definitions
+ */
+#define ERROR -2
+#define END -1
+#define BOOLEAN 0
+#define AND '&'
+#define OR '|'
+#define XOR '^'
+#define NOT '~'
+#define LP '('
+#define RP ')'
+
+/*
+ * Types
+ */
+/* boolean expressions */
+typedef struct _XawEvalInfo {
+ Widget widget;
+ XawActionResList *rlist;
+ XawActionVarList *vlist;
+ XawParseBooleanProc parse_proc;
+ XEvent *event;
+ char *cp, *lp;
+ int token;
+ Bool value;
+} XawEvalInfo;
+
+/* resources */
+typedef struct _XawActionRes {
+ XrmQuark qname;
+ XrmQuark qtype;
+ Cardinal size;
+} XawActionRes;
+
+struct _XawActionResList {
+ WidgetClass widget_class;
+ XawActionRes **resources;
+ Cardinal num_common_resources;
+ Cardinal num_constraint_resources;
+};
+
+/* variables */
+typedef struct _XawActionVar {
+ XrmQuark qname;
+ XrmQuark qvalue;
+} XawActionVar;
+
+struct _XawActionVarList {
+ Widget widget;
+ Cardinal num_variables;
+ XawActionVar **variables;
+};
+
+/*
+ * Private methods
+ */
+/* expressions */
+static int get_token(XawEvalInfo*);
+static Bool expr(XawEvalInfo*);
+static Bool and(XawEvalInfo*);
+static Bool prim(XawEvalInfo*);
+
+/* resources */
+static String XawConvertActionRes(XawActionResList*, Widget w, String);
+
+static String _XawEscapeActionVarValue(String);
+static String _XawUnescapeActionVarValue(String);
+static XawActionResList *_XawCreateActionResList(WidgetClass);
+static XawActionResList *_XawFindActionResList(WidgetClass);
+static void _XawBindActionResList(XawActionResList*);
+static XawActionRes *_XawFindActionRes(XawActionResList*, Widget, String);
+static int qcmp_action_resource_list(_Xconst void*, _Xconst void*);
+static int bcmp_action_resource_list(_Xconst void*, _Xconst void*);
+static int qcmp_action_resource(_Xconst void*, _Xconst void*);
+static int bcmp_action_resource(_Xconst void*, _Xconst void*);
+
+/* variables */
+static String XawConvertActionVar(XawActionVarList*, String);
+static void XawDeclareActionVar(XawActionVarList*, String, String);
+
+static XawActionVarList *_XawCreateActionVarList(Widget);
+static XawActionVarList *_XawFindActionVarList(Widget);
+static XawActionVar *_XawCreateActionVar(XawActionVarList*, String);
+static XawActionVar *_XawFindActionVar(XawActionVarList*, String);
+static void _XawDestroyActionVarList(Widget, XtPointer, XtPointer);
+
+/*
+ * Initialization
+ */
+/* resources */
+static XawActionResList **resource_list;
+static Cardinal num_resource_list;
+
+/* variables */
+static XawActionVarList **variable_list;
+static Cardinal num_variable_list;
+
+/*
+ * Implementation
+ */
+/*
+ * Start of Boolean Expression Evaluation Implementation Code
+ */
+Bool
+XawParseBoolean(Widget w, String param, XEvent *event, Bool *succed)
+{
+ char *tmp = param;
+ int value;
+
+ if (!param)
+ return (False);
+
+ value = (int)strtod(param, &tmp);
+ if (*tmp == '\0')
+ return (value);
+
+ if (XmuCompareISOLatin1(param, "true") == 0
+ || XmuCompareISOLatin1(param, "yes") == 0
+ || XmuCompareISOLatin1(param, "on") == 0
+ || XmuCompareISOLatin1(param, "in") == 0
+ || XmuCompareISOLatin1(param, "up") == 0)
+ return (True);
+ else if (XmuCompareISOLatin1(param, "false") == 0
+ || XmuCompareISOLatin1(param, "no") == 0
+ || XmuCompareISOLatin1(param, "off") == 0
+ || XmuCompareISOLatin1(param, "out") == 0
+ || XmuCompareISOLatin1(param, "down") == 0)
+ ;
+ else if (XmuCompareISOLatin1(param, "my") == 0
+ || XmuCompareISOLatin1(param, "mine") == 0)
+ return (event->xany.window == XtWindow(w));
+ else if (XmuCompareISOLatin1(param, "faked") == 0)
+ return (event->xany.send_event != 0);
+ else
+ *succed = False;
+
+ return (False);
+}
+
+Bool
+XawBooleanExpression(Widget w, String param, XEvent *event)
+{
+ XawEvalInfo info;
+ Bool retval;
+
+ if (!param)
+ return (False);
+
+ info.widget = w;
+
+ info.rlist = XawGetActionResList(XtClass(w));
+ info.vlist = XawGetActionVarList(w);
+
+ /*
+ * Verify widget class, in case we will allow the parse proc procedure
+ * as a widget class element, or if we allow overriding the default
+ * parse boolean proc.
+ */
+ info.parse_proc = XawParseBoolean;
+
+ info.event = event;
+ info.cp = info.lp = param;
+
+#ifdef DIAGNOSTIC
+ fprintf(stderr, "(*) Parsing expression \"%s\"\n", param);
+#endif
+
+ (void)get_token(&info);
+ if (info.token == ERROR)
+ return (False);
+ retval = expr(&info);
+
+ return (info.token != ERROR ? retval : False);
+}
+
+static int
+get_token(XawEvalInfo *info)
+{
+ int ch;
+ char *p, name[256];
+
+ info->lp = info->cp;
+
+ /*COSTCOND*/
+ while (1) /* eat white spaces */
+ {
+ ch = *info->cp++;
+ if (isspace(ch))
+ continue;
+ break;
+ }
+
+ switch (ch)
+ {
+ case AND: case OR: case XOR: case NOT: case LP: case RP:
+ return (info->token = ch);
+ }
+
+ /* It's a symbol name, resolve it. */
+ if (ch == XAW_PRIV_VAR_PREFIX || isalnum(ch) || ch == '_' || ch == '\\')
+ {
+ Bool succed = True;
+
+ p = info->cp - 1;
+
+ while ((ch = *info->cp) && (isalnum(ch) || ch == '_'))
+ ++info->cp;
+
+ strncpy(name, p, XawMin((int)sizeof(name) - 1,
+ (unsigned)(info->cp - p)));
+ name[XawMin((int)sizeof(name) -1, info->cp - p)] = '\0';
+
+ if (name[0] == XAW_PRIV_VAR_PREFIX)
+ {
+ String value = XawConvertActionVar(info->vlist, name);
+
+ info->value = info->parse_proc(info->widget, value, info->event,
+ &succed) & 1;
+ }
+ else
+ {
+ info->value = info->parse_proc(info->widget, name, info->event,
+ &succed) & 1;
+ if (!succed)
+ {
+ String value =
+ XawConvertActionRes(info->rlist, info->widget,
+ name[0] == '\\' ? &name[1] : name);
+ /* '\\' may have been used to escape a resource name.
+ */
+
+ succed = True;
+ info->value = info->parse_proc(info->widget, value, info->event,
+ &succed) & 1;
+ if (!succed)
+ {
+ /* not a numeric value or boolean string */
+ info->value = True;
+ succed = True;
+ }
+ }
+ }
+ if (succed)
+ return (info->token = BOOLEAN);
+ }
+ else if (ch == '\0')
+ return (info->token = END);
+
+ {
+ char msg[256];
+
+ XmuSnprintf(msg, sizeof(msg),
+ "evaluate(): bad token \"%c\" at \"%s\"", ch, info->cp - 1);
+
+ XtAppWarning(XtWidgetToApplicationContext(info->widget), msg);
+ }
+
+ return (info->token = ERROR);
+}
+
+static Bool
+expr(XawEvalInfo *info)
+{
+ Bool left = and(info);
+
+ for (;;)
+ switch (info->token)
+ {
+ case OR:
+ (void)get_token(info);
+ left |= and(info);
+ break;
+ case XOR:
+ (void)get_token(info);
+ left ^= and(info);
+ break;
+ default:
+ return (left);
+ }
+ /* NOTREACHED */
+}
+
+static Bool
+and(XawEvalInfo *info)
+{
+ Bool left = prim(info);
+
+ for (;;)
+ switch (info->token)
+ {
+ case AND:
+ (void)get_token(info);
+ left &= prim(info);
+ break;
+ default:
+ return (left);
+ }
+ /* NOTREACHED */
+}
+
+static Bool
+prim(XawEvalInfo *info)
+{
+ Bool e;
+
+ switch (info->token)
+ {
+ case BOOLEAN:
+ e = info->value;
+ (void)get_token(info);
+ return (e);
+ case NOT:
+ (void)get_token(info);
+ return (!prim(info));
+ case LP:
+ (void)get_token(info);
+ e = expr(info);
+ if (info->token != RP)
+ {
+ char msg[256];
+
+ info->token = ERROR;
+ XmuSnprintf(msg, sizeof(msg),
+ "evaluate(): expecting ), at \"%s\"", info->lp);
+ XtAppWarning(XtWidgetToApplicationContext(info->widget), msg);
+ return (False);
+ }
+ (void)get_token(info);
+ return (e);
+ case END:
+ return (True);
+ default:
+ {
+ char msg[256];
+
+ info->token = ERROR;
+ XmuSnprintf(msg, sizeof(msg),
+ "evaluate(): sintax error, at \"%s\"", info->lp);
+ XtAppWarning(XtWidgetToApplicationContext(info->widget), msg);
+ } return (False);
+ }
+ /* NOTREACHED */
+}
+
+/*
+ * Start of Resources Implementation Code
+ */
+void
+XawSetValuesAction(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ Arg *arglist;
+ Cardinal num_args, count;
+ XawActionResList *rlist;
+ XawActionVarList *vlist;
+ XawActionRes *resource;
+ XrmValue from, to;
+ String value;
+ char c_1;
+ short c_2;
+ int c_4;
+#ifdef LONG64
+ long c_8;
+#endif
+
+ if (!(*num_params & 1))
+ {
+ XawPrintActionErrorMsg("set-values", w, params, num_params);
+ return;
+ }
+
+ if (!XawBooleanExpression(w, params[0], event))
+ return;
+
+ rlist = XawGetActionResList(XtClass(w));
+ vlist = XawGetActionVarList(w);
+
+ num_args = 0;
+ arglist = (Arg *)XtMalloc(sizeof(Arg) * ((*num_params) >> 1));
+
+ for (count = 1; count < *num_params; count += 2)
+ {
+ if ((resource = _XawFindActionRes(rlist, w, params[count])) == NULL)
+ {
+ char msg[256];
+
+ XmuSnprintf(msg, sizeof(msg),
+ "set-values(): bad resource name \"%s\"",
+ params[count]);
+ XtAppWarning(XtWidgetToApplicationContext(w), msg);
+ continue;
+ }
+ value = XawConvertActionVar(vlist, params[count + 1]);
+ from.size = strlen(value) + 1;
+ from.addr = value;
+ to.size = resource->size;
+ switch (to.size)
+ {
+ case 1: to.addr = (XPointer)&c_1; break;
+ case 2: to.addr = (XPointer)&c_2; break;
+ case 4: to.addr = (XPointer)&c_4; break;
+#ifdef LONG64
+ case 8: to.addr = (XPointer)&c_8; break;
+#endif
+ default:
+ {
+ char msg[256];
+
+ XmuSnprintf(msg, sizeof(msg),
+ "set-values(): bad resource size for \"%s\"",
+ params[count]);
+ XtAppWarning(XtWidgetToApplicationContext(w), msg);
+ } continue;
+ }
+
+ if (strcmp(XtRString, XrmQuarkToString(resource->qtype)) == 0)
+#ifdef LONG64
+ c_8 = (long)from.addr;
+#else
+ c_4 = (int)from.addr;
+#endif
+ else if (!XtConvertAndStore(w, XtRString, &from,
+ XrmQuarkToString(resource->qtype), &to))
+ continue;
+
+ switch (to.size)
+ {
+ case 1:
+ XtSetArg(arglist[num_args], XrmQuarkToString(resource->qname), c_1);
+ break;
+ case 2:
+ XtSetArg(arglist[num_args], XrmQuarkToString(resource->qname), c_2);
+ break;
+ case 4:
+ XtSetArg(arglist[num_args], XrmQuarkToString(resource->qname), c_4);
+ break;
+#ifdef LONG64
+ case 8:
+ XtSetArg(arglist[num_args], XrmQuarkToString(resource->qname), c_8);
+ break;
+#endif
+ }
+ ++num_args;
+ }
+
+ XtSetValues(w, arglist, num_args);
+ XtFree((char *)arglist);
+}
+
+void
+XawGetValuesAction(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ XawActionResList *rlist;
+ XawActionVarList *vlist;
+ String value;
+ Cardinal count;
+
+ if (!(*num_params & 1))
+ {
+ XawPrintActionErrorMsg("get-values", w, params, num_params);
+ return;
+ }
+ if (!XawBooleanExpression(w, params[0], event))
+ return;
+
+ rlist = XawGetActionResList(XtClass(w));
+ vlist = XawGetActionVarList(w);
+
+ for (count = 1; count < *num_params; count += 2)
+ {
+ if ((value = XawConvertActionRes(rlist, w, params[count + 1])) == NULL)
+ continue;
+ XawDeclareActionVar(vlist, params[count], value);
+ }
+}
+
+void
+XawDeclareAction(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ XawActionVarList *vlist;
+ Cardinal count;
+
+ if (!(*num_params & 1))
+ {
+ XawPrintActionErrorMsg("declare", w, params, num_params);
+ return;
+ }
+ if (!XawBooleanExpression(w, params[0], event))
+ return;
+
+ vlist = XawGetActionVarList(w);
+
+ for (count = 1; count < *num_params; count += 2)
+ XawDeclareActionVar(vlist, params[count], params[count + 1]);
+}
+
+void
+XawCallProcAction(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ String *args;
+ Cardinal num_args;
+
+ if (*num_params < 2)
+ {
+ XawPrintActionErrorMsg("call-proc", w, params, num_params);
+ return;
+ }
+
+ if (*num_params && !XawBooleanExpression(w, params[0], event))
+ return;
+
+ if (*num_params > 2)
+ {
+ args = &params[2];
+ num_args = *num_params - 2;
+ }
+ else
+ {
+ args = NULL;
+ num_args = 0;
+ }
+
+ XtCallActionProc(w, params[1], event, args, num_args);
+}
+
+static String
+XawConvertActionRes(XawActionResList *list, Widget w, String name)
+{
+ XawActionRes *resource;
+ XrmValue from, to;
+ Arg arg;
+ char c_1;
+ short c_2;
+ int c_4;
+#ifdef LONG64
+ long c_8;
+#endif
+
+ if ((resource = _XawFindActionRes(list, w, name)) == NULL)
+ {
+ char msg[256];
+
+ XmuSnprintf(msg, sizeof(msg),
+ "convert(): bad resource name \"%s\"", name);
+ XtAppWarning(XtWidgetToApplicationContext(w), msg);
+ return (NULL);
+ }
+
+ from.size = resource->size;
+ switch (from.size)
+ {
+ case 1:
+ XtSetArg(arg, XrmQuarkToString(resource->qname),
+ from.addr = (XPointer)&c_1);
+ break;
+ case 2:
+ XtSetArg(arg, XrmQuarkToString(resource->qname),
+ from.addr = (XPointer)&c_2);
+ break;
+ case 4:
+ XtSetArg(arg, XrmQuarkToString(resource->qname),
+ from.addr = (XPointer)&c_4);
+ break;
+#ifdef LONG64
+ case 8:
+ XtSetArg(arg, XrmQuarkToString(resource->qname),
+ from.addr = (XPointer)&c_8);
+ break;
+#endif
+ default:
+ {
+ char msg[256];
+
+ XmuSnprintf(msg, sizeof(msg),
+ "convert(): bad resource size for \"%s\"", name);
+ XtAppWarning(XtWidgetToApplicationContext(w), name);
+ } return (NULL);
+ }
+
+ XtGetValues(w, &arg, 1);
+ to.size = sizeof(String);
+ to.addr = NULL;
+
+ if (strcmp(XtRString, XrmQuarkToString(resource->qtype)) == 0)
+ to.addr = *(char **)from.addr;
+ else if (!XtConvertAndStore(w, XrmQuarkToString(resource->qtype),
+ &from, XtRString, &to))
+ return (NULL);
+
+ return ((String)to.addr);
+}
+
+void
+XawPrintActionErrorMsg(String action_name, Widget w,
+ String *params, Cardinal *num_params)
+{
+ char msg[1024];
+ unsigned int size, idx;
+
+ size = XmuSnprintf(msg, sizeof(msg), "%s(): bad number of parameters.\n\t(",
+ action_name);
+
+ idx = 0;
+ while (idx < *num_params - 1 && size < sizeof(msg))
+ size += XmuSnprintf(&msg[size], sizeof(msg) - size, "%s, ",
+ params[idx++]);
+ if (*num_params)
+ XmuSnprintf(&msg[size], sizeof(msg) - size, "%s)", params[idx]);
+ else
+ XmuSnprintf(&msg[size], sizeof(msg) - size, ")");
+ XtAppWarning(XtWidgetToApplicationContext(w), msg);
+}
+
+XawActionResList *
+XawGetActionResList(WidgetClass wc)
+{
+ XawActionResList *list;
+
+ list = _XawFindActionResList(wc);
+
+ if (!list)
+ list = _XawCreateActionResList(wc);
+
+ return (list);
+}
+
+static int
+qcmp_action_resource_list(register _Xconst void *left,
+ register _Xconst void *right)
+{
+ return ((char *)((*(XawActionResList **)left)->widget_class) -
+ (char *)((*(XawActionResList **)right)->widget_class));
+}
+
+static XawActionResList *
+_XawCreateActionResList(WidgetClass wc)
+{
+ XawActionResList *list;
+
+ list = (XawActionResList *)XtMalloc(sizeof(XawActionResList));
+ list->widget_class = wc;
+ list->num_common_resources = list->num_constraint_resources = 0;
+ list->resources = NULL;
+
+ if (!resource_list)
+ {
+ num_resource_list = 1;
+ resource_list = (XawActionResList **)XtMalloc(sizeof(XawActionResList*));
+ resource_list[0] = list;
+ }
+ else
+ {
+ ++num_resource_list;
+ resource_list = (XawActionResList **)XtRealloc((char *)resource_list,
+ sizeof(XawActionResList*)
+ * num_resource_list);
+ resource_list[num_resource_list - 1] = list;
+ qsort(resource_list, num_resource_list, sizeof(XawActionResList*),
+ qcmp_action_resource_list);
+ }
+
+ _XawBindActionResList(list);
+
+ return (list);
+}
+
+static int
+bcmp_action_resource_list(register _Xconst void *wc,
+ register _Xconst void *list)
+{
+ return ((char *)wc - (char *)((*(XawActionResList **)list)->widget_class));
+}
+
+static XawActionResList *
+_XawFindActionResList(WidgetClass wc)
+{
+ XawActionResList **list;
+
+ if (!resource_list)
+ return (NULL);
+
+ list = (XawActionResList **)bsearch(wc, resource_list,
+ num_resource_list,
+ sizeof(XawActionResList*),
+ bcmp_action_resource_list);
+
+ return (list ? *list : NULL);
+}
+
+static int
+qcmp_action_resource(register _Xconst void *left,
+ register _Xconst void *right)
+{
+ return (strcmp(XrmQuarkToString((*(XawActionRes **)left)->qname),
+ XrmQuarkToString((*(XawActionRes **)right)->qname)));
+}
+
+static void
+_XawBindActionResList(XawActionResList *list)
+{
+ XtResourceList xt_list, cons_list;
+ Cardinal i, num_xt, num_cons;
+
+#ifdef DIAGNOSTIC
+ fprintf(stderr, "(*) Creating resource list for class \'%s\'\n---------\n",
+ list->widget_class->core_class.class_name);
+#endif
+
+ XtGetResourceList(list->widget_class, &xt_list, &num_xt);
+ XtGetConstraintResourceList(list->widget_class, &cons_list, &num_cons);
+ list->num_common_resources = num_xt;
+ list->num_constraint_resources = num_cons;
+
+ list->resources = (XawActionRes **)
+ XtMalloc(sizeof(XawActionRes*) * (num_xt + num_cons));
+
+#ifdef DIAGNOSTIC
+ fprintf(stderr, "Common resources\n---\n");
+#endif
+
+ for (i = 0; i < num_xt; i++)
+ {
+ list->resources[i] = (XawActionRes *)XtMalloc(sizeof(XawActionRes));
+ list->resources[i]->qname =
+ XrmPermStringToQuark(xt_list[i].resource_name);
+ list->resources[i]->qtype =
+ XrmPermStringToQuark(xt_list[i].resource_type);
+ list->resources[i]->size = xt_list[i].resource_size;
+
+#ifdef DIAGNOSTIC
+ fprintf(stderr, "%-20s\t%-20s\t(%d)\n",
+ xt_list[i].resource_name,
+ xt_list[i].resource_type,
+ xt_list[i].resource_size);
+#endif
+ }
+
+#ifdef DIAGNOSTIC
+ fprintf(stderr, "---\nContraint resources\n---");
+#endif
+
+ for (; i < num_xt + num_cons; i++)
+ {
+ list->resources[i] = (XawActionRes *)XtMalloc(sizeof(XawActionRes));
+ list->resources[i]->qname =
+ XrmPermStringToQuark(cons_list[i - num_xt].resource_name);
+ list->resources[i]->qtype =
+ XrmPermStringToQuark(cons_list[i - num_xt].resource_type);
+ list->resources[i]->size = cons_list[i - num_xt].resource_size;
+
+#ifdef DIAGNOSTIC
+ fprintf(stderr, "%-20s\t%-20s\t(%d)\n",
+ cons_list[i - num_xt].resource_name,
+ cons_list[i - num_xt].resource_type,
+ cons_list[i - num_xt].resource_size);
+#endif
+ }
+
+#ifdef DIAGNOSTIC
+ fprintf(stderr, "---\n");
+#endif
+
+ XtFree((char *)xt_list);
+ if (cons_list)
+ XtFree((char *)cons_list);
+
+ qsort(list->resources, list->num_common_resources, sizeof(XawActionRes*),
+ qcmp_action_resource);
+ if (num_cons)
+ qsort(&list->resources[num_xt], list->num_constraint_resources,
+ sizeof(XawActionRes*), qcmp_action_resource);
+}
+
+static int
+bcmp_action_resource(register _Xconst void *string,
+ register _Xconst void *resource)
+{
+ return (strcmp((String)string,
+ XrmQuarkToString((*(XawActionRes **)resource)->qname)));
+}
+
+static XawActionRes *
+_XawFindActionRes(XawActionResList *list, Widget detail, String name)
+{
+ XawActionRes **res;
+
+ if (!list->resources)
+ return (NULL);
+
+ res = (XawActionRes **)bsearch(name, list->resources,
+ list->num_common_resources,
+ sizeof(XawActionRes*), bcmp_action_resource);
+
+ if (!res && XtParent(detail)
+ && XtIsSubclass(XtParent(detail), constraintWidgetClass))
+ {
+ XawActionResList *cons = XawGetActionResList(XtClass(XtParent(detail)));
+
+ if (cons)
+ res = (XawActionRes **)
+ bsearch(name, &cons->resources[cons->num_common_resources],
+ cons->num_constraint_resources,
+ sizeof(XawActionRes*), bcmp_action_resource);
+ }
+
+ return (res ? *res : NULL);
+}
+
+/*
+ * Start of Variables Implementation Code
+ */
+/* For speed, only does memory allocation when really required */
+static String
+_XawEscapeActionVarValue(String value)
+{
+ String escape;
+
+ if (value[0] == '$' || value[0] == '\\')
+ {
+ escape = XtMalloc(strlen(value) + 2);
+ escape[0] = '\\';
+ strcpy(escape + 1, value);
+ return (escape);
+ }
+ return (NULL);
+}
+
+/* For speed, only does memory allocation when really required */
+static String
+_XawUnescapeActionVarValue(String value)
+{
+ String unescape;
+
+ if (value[0] == '\\')
+ {
+ unescape = XtMalloc(strlen(value));
+ strcpy(unescape, value + 1);
+ return (unescape);
+ }
+ return (NULL);
+}
+
+static void
+XawDeclareActionVar(XawActionVarList *list, String name, String value)
+{
+ XawActionVar *variable;
+ String escape = NULL;
+
+ if (name[0] != XAW_PRIV_VAR_PREFIX)
+ {
+ char msg[256];
+
+ XmuSnprintf(msg, sizeof(msg), "declare(): variable name must begin with "
+ "\'%c\', at %s = %s", XAW_PRIV_VAR_PREFIX, name, value);
+ XtAppWarning(XtWidgetToApplicationContext(list->widget), msg);
+ return;
+ }
+ variable = _XawFindActionVar(list, name);
+ if (!variable)
+ variable = _XawCreateActionVar(list, name);
+ if (value)
+ escape = _XawEscapeActionVarValue(value);
+
+ if (variable->qvalue)
+ {
+ String val = escape ? escape : value;
+
+ if (strcmp(XrmQuarkToString(variable->qvalue), val) == 0)
+ {
+ if (escape)
+ XtFree(escape);
+ return;
+ }
+ }
+ variable->qvalue = (escape ? XrmStringToQuark(escape) :
+ (value ? XrmStringToQuark(value) : NULLQUARK));
+ if (escape)
+ XtFree(escape);
+}
+
+static String
+XawConvertActionVar(XawActionVarList *list, String name)
+{
+ XawActionVar *variable;
+ String unescape;
+ XrmQuark quark;
+
+ if (name[0] != XAW_PRIV_VAR_PREFIX)
+ return (name);
+
+ variable = _XawFindActionVar(list, name);
+ if (!variable || variable->qvalue == NULLQUARK)
+ return (name);
+ unescape = _XawUnescapeActionVarValue(XrmQuarkToString(variable->qvalue));
+ if (unescape)
+ {
+ quark = XrmStringToQuark(unescape);
+ XtFree(unescape);
+ }
+ else
+ quark = variable->qvalue;
+
+ return (XrmQuarkToString(quark));
+}
+
+XawActionVarList *
+XawGetActionVarList(Widget w)
+{
+ XawActionVarList *list;
+
+ list = _XawFindActionVarList(w);
+ if (!list)
+ list = _XawCreateActionVarList(w);
+
+ return (list);
+}
+
+static int
+qcmp_action_variable_list(register _Xconst void *left,
+ register _Xconst void *right)
+{
+ return ((char *)((*(XawActionVarList **)left)->widget) -
+ (char *)((*(XawActionVarList **)right)->widget));
+}
+
+static XawActionVarList *
+_XawCreateActionVarList(Widget w)
+{
+ XawActionVarList *list;
+
+#ifdef DIAGNOSTIC
+ fprintf(stderr, "(*) Creating action variable list for widget %s (%p)\n",
+ XtName(w), w);
+#endif
+
+ list = (XawActionVarList *)XtMalloc(sizeof(XawActionVarList));
+ list->widget = w;
+ list->num_variables = 0;
+ list->variables = NULL;
+
+ if (!variable_list)
+ {
+ num_variable_list = 1;
+ variable_list = (XawActionVarList **)XtMalloc(sizeof(XawActionVarList*));
+ variable_list[0] = list;
+ }
+ else
+ {
+ ++num_variable_list;
+ variable_list = (XawActionVarList **)
+ XtRealloc((char *)variable_list,
+ sizeof(XawActionVarList *) * num_variable_list);
+ variable_list[num_variable_list - 1] = list;
+ qsort(variable_list, num_variable_list, sizeof(XawActionVarList*),
+ qcmp_action_variable_list);
+ }
+
+ XtAddCallback(w, XtNdestroyCallback, _XawDestroyActionVarList,
+ (XtPointer)list);
+
+ return (list);
+}
+
+static int
+bcmp_action_variable_list(register _Xconst void *widget,
+ register _Xconst void *list)
+{
+ return ((char *)widget - (char *)((*(XawActionVarList **)list)->widget));
+}
+
+static XawActionVarList *
+_XawFindActionVarList(Widget w)
+{
+ XawActionVarList **list;
+
+ if (!num_variable_list)
+ return (NULL);
+
+ list = (XawActionVarList **)bsearch(w, variable_list, num_variable_list,
+ sizeof(XawActionVarList*),
+ bcmp_action_variable_list);
+
+ return (list ? *list : NULL);
+}
+
+static int
+qcmp_action_variable(register _Xconst void *left,
+ register _Xconst void *right)
+{
+ return (strcmp(XrmQuarkToString((*(XawActionVar **)left)->qname),
+ XrmQuarkToString((*(XawActionVar **)right)->qname)));
+}
+
+static XawActionVar *
+_XawCreateActionVar(XawActionVarList *list, String name)
+{
+ XawActionVar *variable;
+
+#ifdef DIAGNOSTIC
+ fprintf(stderr, "(*) Creating action variable '%s' for widget %s (%p)\n",
+ name, XtName(list->widget), list->widget);
+#endif
+
+ variable = (XawActionVar *)XtMalloc(sizeof(XawActionVar));
+ variable->qname = XrmStringToQuark(name);
+ variable->qvalue = NULLQUARK;
+
+ if (!list->variables)
+ {
+ list->num_variables = 1;
+ list->variables = (XawActionVar **)XtMalloc(sizeof(XawActionVar*));
+ list->variables[0] = variable;
+ }
+ else
+ {
+ ++list->num_variables;
+ list->variables = (XawActionVar **)XtRealloc((char *)list->variables,
+ sizeof(XawActionVar *) *
+ list->num_variables);
+ list->variables[list->num_variables - 1] = variable;
+ qsort(list->variables, list->num_variables, sizeof(XawActionVar*),
+ qcmp_action_variable);
+ }
+ return (variable);
+}
+
+static int
+bcmp_action_variable(register _Xconst void *string,
+ register _Xconst void *variable)
+{
+ return (strcmp((String)string,
+ XrmQuarkToString((*(XawActionVar **)variable)->qname)));
+}
+
+static XawActionVar *
+_XawFindActionVar(XawActionVarList *list, String name)
+{
+ XawActionVar **var;
+
+ if (!list->variables)
+ return (NULL);
+
+ var = (XawActionVar **)bsearch(name, list->variables, list->num_variables,
+ sizeof(XawActionVar*), bcmp_action_variable);
+
+ return (var ? *var : NULL);
+}
+
+/*ARGSUSED*/
+static void
+_XawDestroyActionVarList(Widget w, XtPointer client_data, XtPointer call_data)
+{
+ XawActionVarList *list = (XawActionVarList *)client_data;
+ Cardinal i;
+
+ for (i = 0; i < num_variable_list; i++)
+ if (variable_list[i] == list)
+ break;
+ if (i >= num_variable_list || list->widget != w
+ || variable_list[i]->widget != w)
+ {
+ XtWarning("destroy-variable-list(): Bad widget argument.");
+ return;
+ }
+ if (--num_variable_list > 0)
+ {
+ memmove(&variable_list[i], &variable_list[i + 1],
+ (num_variable_list - i) * sizeof(XawActionVarList *));
+ variable_list = (XawActionVarList **)
+ XtRealloc((char *)variable_list, sizeof(XawActionVarList *) *
+ num_variable_list);
+ }
+ else
+ {
+ XtFree((char *)variable_list);
+ variable_list = NULL;
+ }
+
+ XtFree((char *)list->variables);
+ XtFree((char *)list);
+}
+
+#endif /* OLDXAW */
diff --git a/nx-X11/lib/Xaw/AllWidgets.c b/nx-X11/lib/Xaw/AllWidgets.c
new file mode 100644
index 000000000..c943630b1
--- /dev/null
+++ b/nx-X11/lib/Xaw/AllWidgets.c
@@ -0,0 +1,126 @@
+/* $Xorg: AllWidgets.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+Copyright (c) 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xaw/AllWidgets.c,v 1.3 2001/08/23 21:49:51 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/Xmu/WidgetNode.h>
+
+extern WidgetClass applicationShellWidgetClass;
+extern WidgetClass asciiSinkObjectClass;
+extern WidgetClass asciiSrcObjectClass;
+extern WidgetClass asciiTextWidgetClass;
+extern WidgetClass boxWidgetClass;
+extern WidgetClass commandWidgetClass;
+extern WidgetClass dialogWidgetClass;
+extern WidgetClass formWidgetClass;
+extern WidgetClass gripWidgetClass;
+extern WidgetClass labelWidgetClass;
+extern WidgetClass listWidgetClass;
+extern WidgetClass menuButtonWidgetClass;
+extern WidgetClass multiSinkObjectClass;
+extern WidgetClass multiSrcObjectClass;
+extern WidgetClass overrideShellWidgetClass;
+extern WidgetClass panedWidgetClass;
+extern WidgetClass pannerWidgetClass;
+extern WidgetClass portholeWidgetClass;
+extern WidgetClass repeaterWidgetClass;
+extern WidgetClass scrollbarWidgetClass;
+extern WidgetClass shellWidgetClass;
+extern WidgetClass simpleMenuWidgetClass;
+extern WidgetClass simpleWidgetClass;
+extern WidgetClass smeBSBObjectClass;
+extern WidgetClass smeLineObjectClass;
+extern WidgetClass smeObjectClass;
+extern WidgetClass stripChartWidgetClass;
+extern WidgetClass textSinkObjectClass;
+extern WidgetClass textSrcObjectClass;
+extern WidgetClass textWidgetClass;
+extern WidgetClass toggleWidgetClass;
+extern WidgetClass topLevelShellWidgetClass;
+extern WidgetClass transientShellWidgetClass;
+extern WidgetClass treeWidgetClass;
+extern WidgetClass vendorShellWidgetClass;
+extern WidgetClass viewportWidgetClass;
+extern WidgetClass wmShellWidgetClass;
+#if !defined(OLDXAW) && !defined(XAW7)
+extern WidgetClass xawPrintShellWidgetClass;
+#endif
+
+XmuWidgetNode XawWidgetArray[] = {
+{ "applicationShell", &applicationShellWidgetClass },
+{ "asciiSink", &asciiSinkObjectClass },
+{ "asciiSrc", &asciiSrcObjectClass },
+{ "asciiText", &asciiTextWidgetClass },
+{ "box", &boxWidgetClass },
+{ "command", &commandWidgetClass },
+{ "composite", &compositeWidgetClass },
+{ "constraint", &constraintWidgetClass },
+{ "core", &coreWidgetClass },
+{ "dialog", &dialogWidgetClass },
+{ "form", &formWidgetClass },
+{ "grip", &gripWidgetClass },
+{ "label", &labelWidgetClass },
+{ "list", &listWidgetClass },
+{ "menuButton", &menuButtonWidgetClass },
+{ "multiSink", &multiSinkObjectClass },
+{ "multiSrc", &multiSrcObjectClass },
+{ "object", &objectClass },
+{ "overrideShell", &overrideShellWidgetClass },
+{ "paned", &panedWidgetClass },
+{ "panner", &pannerWidgetClass },
+{ "porthole", &portholeWidgetClass },
+{ "rect", &rectObjClass },
+{ "repeater", &repeaterWidgetClass },
+{ "scrollbar", &scrollbarWidgetClass },
+{ "shell", &shellWidgetClass },
+{ "simpleMenu", &simpleMenuWidgetClass },
+{ "simple", &simpleWidgetClass },
+{ "smeBSB", &smeBSBObjectClass },
+{ "smeLine", &smeLineObjectClass },
+{ "sme", &smeObjectClass },
+{ "stripChart", &stripChartWidgetClass },
+{ "textSink", &textSinkObjectClass },
+{ "textSrc", &textSrcObjectClass },
+{ "text", &textWidgetClass },
+{ "toggle", &toggleWidgetClass },
+{ "topLevelShell", &topLevelShellWidgetClass },
+{ "transientShell", &transientShellWidgetClass },
+{ "tree", &treeWidgetClass },
+{ "vendorShell", &vendorShellWidgetClass },
+{ "viewport", &viewportWidgetClass },
+{ "wmShell", &wmShellWidgetClass },
+#if !defined(OLDXAW) && !defined(XAW7)
+{ "printShell", &xawPrintShellWidgetClass },
+#endif
+};
+
+int XawWidgetCount = XtNumber(XawWidgetArray);
+
diff --git a/nx-X11/lib/Xaw/AllWidgets.h b/nx-X11/lib/Xaw/AllWidgets.h
new file mode 100644
index 000000000..0200ac4cc
--- /dev/null
+++ b/nx-X11/lib/Xaw/AllWidgets.h
@@ -0,0 +1,38 @@
+/*
+ * $Xorg: AllWidgets.h,v 1.5 2001/02/09 02:03:42 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.
+ */
+
+#ifndef _XawAllWidgets_h
+#define _XawAllWidgets_h
+
+#include <X11/Xmu/WidgetNode.h>
+
+/*
+ * This file matches the generated AllWidgets.c
+ */
+extern XmuWidgetNode XawWidgetArray[];
+extern int XawWidgetCount;
+
+#endif /* _XawAllWidgets_h */
diff --git a/nx-X11/lib/Xaw/AsciiSink.c b/nx-X11/lib/Xaw/AsciiSink.c
new file mode 100644
index 000000000..ad35a127c
--- /dev/null
+++ b/nx-X11/lib/Xaw/AsciiSink.c
@@ -0,0 +1,1951 @@
+/* $Xorg: AsciiSink.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/AsciiSink.c,v 1.26 2001/12/14 19:54:38 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xatom.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/AsciiSinkP.h>
+#include <X11/Xaw/AsciiSrcP.h>
+#include <X11/Xaw/TextP.h>
+#include "Private.h"
+
+#ifdef GETLASTPOS
+#undef GETLASTPOS /* We will use our own GETLASTPOS */
+#endif
+
+#define GETLASTPOS \
+ XawTextSourceScan(source, 0, XawstAll, XawsdRight, 1, True)
+
+/*
+ * Class Methods
+ */
+static void XawAsciiSinkClassPartInitialize(WidgetClass);
+static void XawAsciiSinkInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawAsciiSinkDestroy(Widget);
+static void XawAsciiSinkResize(Widget);
+static Boolean XawAsciiSinkSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+static int MaxLines(Widget, unsigned int);
+static int MaxHeight(Widget, int);
+static void SetTabs(Widget, int, short*);
+static void DisplayText(Widget, int, int,
+ XawTextPosition, XawTextPosition, Bool);
+static void InsertCursor(Widget, int, int, XawTextInsertState);
+static void FindPosition(Widget, XawTextPosition, int, int, Bool,
+ XawTextPosition*, int*, int*);
+static void FindDistance(Widget, XawTextPosition, int, XawTextPosition, int*,
+ XawTextPosition*, int*);
+static void Resolve(Widget, XawTextPosition, int, int, XawTextPosition*);
+static void GetCursorBounds(Widget, XRectangle*);
+#ifndef OLDXAW
+static void AsciiPreparePaint(Widget, int, int,
+ XawTextPosition, XawTextPosition, Bool);
+static void AsciiDoPaint(Widget);
+#endif
+
+/*
+ * Prototypes
+ */
+static void GetGC(AsciiSinkObject);
+static int CharWidth(AsciiSinkObject, XFontStruct*, int, unsigned int);
+static unsigned int PaintText(Widget w, GC gc, int x, int y,
+ char *buf, int len, Bool);
+
+/*
+ * Defined in TextSink.c
+ */
+void _XawTextSinkClearToBackground(Widget, int, int, unsigned, unsigned);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(AsciiSinkRec, ascii_sink.field)
+static XtResource resources[] = {
+ {
+ XtNfont,
+ XtCFont,
+ XtRFontStruct,
+ sizeof(XFontStruct*),
+ offset(font),
+ XtRString,
+ XtDefaultFont
+ },
+ {
+ XtNecho,
+ XtCOutput,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(echo),
+ XtRImmediate,
+ (XtPointer)True
+ },
+ {
+ XtNdisplayNonprinting,
+ XtCOutput,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(display_nonprinting),
+ XtRImmediate,
+ (XtPointer)
+ True
+ },
+};
+#undef offset
+
+#define Superclass (&textSinkClassRec)
+AsciiSinkClassRec asciiSinkClassRec = {
+ /* object */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "AsciiSink", /* class_name */
+ sizeof(AsciiSinkRec), /* widget_size */
+ XawInitializeWidgetSet, /* class_initialize */
+ XawAsciiSinkClassPartInitialize, /* class_part_initialize */
+ False, /* class_inited */
+ XawAsciiSinkInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ NULL, /* obj1 */
+ NULL, /* obj2 */
+ 0, /* obj3 */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ False, /* obj4 */
+ False, /* obj5 */
+ False, /* obj6 */
+ False, /* obj7 */
+ XawAsciiSinkDestroy, /* destroy */
+ (XtProc)XawAsciiSinkResize, /* obj8 */
+ NULL, /* obj9 */
+ XawAsciiSinkSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ NULL, /* obj10 */
+ NULL, /* get_values_hook */
+ NULL, /* obj11 */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* obj12 */
+ NULL, /* obj13 */
+ NULL, /* obj14 */
+ NULL, /* extension */
+ },
+ /* text_sink */
+ {
+ DisplayText, /* DisplayText */
+ InsertCursor, /* InsertCursor */
+ XtInheritClearToBackground, /* ClearToBackground */
+ FindPosition, /* FindPosition */
+ FindDistance, /* FindDistance */
+ Resolve, /* Resolve */
+ MaxLines, /* MaxLines */
+ MaxHeight, /* MaxHeight */
+ SetTabs, /* SetTabs */
+ GetCursorBounds, /* GetCursorBounds */
+#ifndef OLDXAW
+ NULL /* extension */
+#endif
+ },
+ /* ascii_sink */
+ {
+ NULL, /* extension */
+ }
+};
+
+WidgetClass asciiSinkObjectClass = (WidgetClass)&asciiSinkClassRec;
+
+/*
+ * Implementation
+ */
+static void
+XawAsciiSinkClassPartInitialize(WidgetClass wc)
+{
+#ifndef OLDXAW
+ AsciiSinkObjectClass cclass = (AsciiSinkObjectClass)wc;
+ XrmQuark record_type = XrmPermStringToQuark("TextSink");
+ TextSinkExt ext = cclass->text_sink_class.extension;
+
+ while (ext) {
+ if (ext->record_type == record_type &&
+ ext->version == 1) {
+ ext->PreparePaint = AsciiPreparePaint;
+ ext->DoPaint = AsciiDoPaint;
+ break;
+ }
+ ext = (TextSinkExt)ext->next_extension;
+ }
+ if (ext == NULL)
+ XtError("TextSinkClass: cannot resolve extension.\n");
+#endif
+}
+
+static int
+CharWidth(AsciiSinkObject sink, XFontStruct *font, int x, unsigned int c)
+{
+ int width = 0;
+
+ if (c == XawLF)
+ return (0);
+
+ if (c == XawTAB) {
+ int i;
+ Position *tab;
+
+ width = x;
+ /* Adjust for Left Margin */
+ x -= ((TextWidget)XtParent((Widget)sink))->text.left_margin;
+
+ i = 0;
+ tab = sink->text_sink.tabs;
+ /*CONSTCOND*/
+ while (1) {
+ if (x >= 0 && x < *tab)
+ return (*tab - x);
+ /* Start again */
+ if (++i >= sink->text_sink.tab_count) {
+ x -= *tab;
+ i = 0;
+ tab = sink->text_sink.tabs;
+ if (width == x)
+ return (0);
+ }
+ else
+ ++tab;
+ }
+ /*NOTREACHED*/
+ }
+
+ if ((c & 0177) < XawSP || c == 0177) {
+ if (sink->ascii_sink.display_nonprinting) {
+ if (c > 0177) {
+ width = CharWidth(sink, font, x, '\\');
+ width += CharWidth(sink, font, x, ((c >> 6) & 7) + '0');
+ width += CharWidth(sink, font, x, ((c >> 3) & 7) + '0');
+ c = (c & 7) + '0';
+ }
+ else {
+ width = CharWidth(sink, font, x, '^');
+ if ((c |= 0100) == 0177)
+ c = '?';
+ }
+ }
+ else
+ c = XawSP;
+ }
+
+ if (font->per_char
+ && (c >= font->min_char_or_byte2 && c <= font->max_char_or_byte2))
+ width += font->per_char[c - font->min_char_or_byte2].width;
+ else
+ width += font->min_bounds.width;
+
+ return (width);
+}
+
+#ifndef OLDXAW
+static int
+GetTextWidth(TextWidget ctx, int current_width, XFontStruct *font,
+ XawTextPosition from, int length)
+{
+ int i, width = 0;
+ XawTextBlock block;
+ XawTextPosition pos = from;
+
+ while (length > 0) {
+ pos = XawTextSourceRead(ctx->text.source, from, &block, length);
+ length -= pos - from;
+ from = pos;
+ for (i = 0; i < block.length; i++)
+ width += CharWidth((AsciiSinkObject)ctx->text.sink, font,
+ current_width + width,
+ (unsigned char)block.ptr[i]);
+ }
+
+ return (width);
+}
+
+static
+void CalculateBearing(TextWidget ctx, XawTextPosition position, int x, int y,
+ int ascent, int descent, Bool highlight, Bool right)
+{
+/*
+ * Sample case:
+ *
+ * lbearing| width |rbearing
+ * | |
+ * | ####
+ * | ### |
+ * | #### |
+ * | #### |
+ * | ########## |
+ * | #### |
+ * | #### |
+ * | #### |
+ * | #### |
+ * |### |
+ * #### |
+ * | |
+ *
+ */
+ AsciiSinkObject sink = (AsciiSinkObject)ctx->text.sink;
+ XawTextAnchor *anchor;
+ XawTextEntity *entity;
+ XawTextProperty *property;
+ XawTextPaintStruct *paint;
+ XawTextBlock block;
+ XFontStruct *font;
+
+ property = NULL;
+ if (XawTextSourceAnchorAndEntity(ctx->text.source, position,
+ &anchor, &entity) &&
+ (property = XawTextSinkGetProperty((Widget)sink,
+ entity->property)) != NULL &&
+ (property->mask & XAW_TPROP_FONT))
+ font = property->font;
+ else
+ font = sink->ascii_sink.font;
+ if (right) {
+ if (font->max_bounds.rbearing > 0) {
+ int rbearing = font->max_bounds.rbearing - font->max_bounds.width;
+ unsigned char c;
+
+ (void)XawTextSourceRead(ctx->text.source, position, &block, 1);
+ c = *(unsigned char*)block.ptr;
+ if (c == '\t' || c == '\n')
+ c = ' ';
+ else if ((c & 0177) < XawSP || c == 0177) {
+ if (sink->ascii_sink.display_nonprinting)
+ c = c > 0177 ? (c & 7) + '0' : c + '@';
+ else
+ c = ' ';
+ }
+ if (font->per_char &&
+ (c >= font->min_char_or_byte2 && c <= font->max_char_or_byte2))
+ rbearing = font->per_char[c - font->min_char_or_byte2].rbearing -
+ font->per_char[c - font->min_char_or_byte2].width;
+ if (rbearing > 0) {
+ paint = XtNew(XawTextPaintStruct);
+ paint->next = sink->text_sink.paint->bearings;
+ sink->text_sink.paint->bearings = paint;
+ paint->x = x - (paint->width = CharWidth(sink, font, 0, c));
+ paint->y = y + ascent;
+ paint->property = property;
+ paint->max_ascent = ascent;
+ paint->max_descent = descent;
+ paint->backtabs = NULL;
+ paint->highlight = highlight;
+ paint->length = 1;
+ paint->text = XtMalloc(1);
+ paint->text[0] = c;
+ }
+ }
+ }
+ else {
+ if (font->min_bounds.lbearing < 0) {
+ int lbearing = font->min_bounds.lbearing;
+ unsigned char c;
+
+ (void)XawTextSourceRead(ctx->text.source, position, &block, 1);
+ c = *(unsigned char*)block.ptr;
+ if (c == '\t' || c == '\n')
+ c = ' ';
+ else if ((c & 0177) < XawSP || c == 0177) {
+ if (sink->ascii_sink.display_nonprinting)
+ c = c > 0177 ? '\\' : c + '^';
+ else
+ c = ' ';
+ }
+ if (font->per_char &&
+ (c >= font->min_char_or_byte2 && c <= font->max_char_or_byte2))
+ lbearing = font->per_char[c - font->min_char_or_byte2].lbearing;
+ if (lbearing < 0) {
+ paint = XtNew(XawTextPaintStruct);
+ paint->next = sink->text_sink.paint->bearings;
+ sink->text_sink.paint->bearings = paint;
+ paint->x = x;
+ paint->width = -CharWidth(sink, font, 0, c);
+ paint->y = y + ascent;
+ paint->property = property;
+ paint->max_ascent = ascent;
+ paint->max_descent = descent;
+ paint->backtabs = NULL;
+ paint->highlight = highlight;
+ paint->length = 1;
+ paint->text = XtMalloc(1);
+ paint->text[0] = c;
+ }
+ }
+ }
+}
+
+static void
+AsciiPreparePaint(Widget w, int y, int line,
+ XawTextPosition from, XawTextPosition to, Bool highlight)
+{
+ static XmuSegment segment;
+ static XmuScanline next;
+ static XmuScanline scanline = {0, &segment, &next};
+ static XmuArea area = {&scanline};
+
+ TextWidget ctx = (TextWidget)XtParent(w);
+ AsciiSinkObject sink = (AsciiSinkObject)ctx->text.sink;
+ XawTextPosition left, right, pos, pos2, tmp, length;
+ XawTextAnchor *anchor;
+ XawTextEntity *entity;
+ XawTextProperty *property;
+ int i, ascent = 0, descent = 0, xl, xr, x = ctx->text.left_margin, bufsiz;
+ XawTextBlock block;
+ XFontStruct *font;
+ XawTextPaintStruct *paint;
+
+ if (!sink->ascii_sink.echo)
+ return;
+
+ /* pass 1: calculate ascent/descent values and x coordinate */
+ /* XXX the MAX ascent/descent value should be in the line table XXX */
+ /* XXX the x coordinate can be a parameter, but since it is required
+ to calculate the ascent/descent, do it here to avoid an extra
+ search in the entities */
+ pos = tmp = left = ctx->text.lt.info[line].position;
+ right = ctx->text.lt.info[line + 1].position;
+ right = XawMin(right, ctx->text.lastPos + 1);
+ while (pos < right) {
+ if (XawTextSourceAnchorAndEntity(ctx->text.source, pos,
+ &anchor, &entity)) {
+ if ((property = XawTextSinkGetProperty((Widget)sink,
+ entity->property)) != NULL &&
+ (property->mask & XAW_TPROP_FONT))
+ font = property->font;
+ else
+ font = sink->ascii_sink.font;
+ tmp = pos;
+ pos = anchor->position + entity->offset + entity->length;
+ if ((length = XawMin(from, pos) - tmp) > 0)
+ x += GetTextWidth(ctx, x, font, tmp, length);
+ ascent = XawMax(font->ascent, ascent);
+ descent = XawMax(font->descent, descent);
+ }
+ else if (anchor) {
+ ascent = XawMax(sink->ascii_sink.font->ascent, ascent);
+ descent = XawMax(sink->ascii_sink.font->descent, descent);
+ while (entity && pos < right) {
+ tmp = pos;
+ if ((pos = anchor->position + entity->offset) < tmp)
+ pos = tmp;
+ else {
+ if ((length = XawMin(from, pos) - tmp) > 0) {
+ x += GetTextWidth(ctx, x, sink->ascii_sink.font, tmp,
+ length);
+ tmp += length;
+ }
+ if (pos < right) {
+ pos += entity->length;
+ if ((property = XawTextSinkGetProperty((Widget)sink,
+ entity->property)) != NULL &&
+ (property->mask & XAW_TPROP_FONT))
+ font = property->font;
+ else
+ font = sink->ascii_sink.font;
+ if ((length = XawMin(from, pos) - tmp) > 0)
+ x += GetTextWidth(ctx, x, font, tmp, length);
+ ascent = XawMax(font->ascent, ascent);
+ descent = XawMax(font->descent, descent);
+ }
+ }
+ entity = entity->next;
+ }
+
+ if (anchor->entities == NULL) {
+ tmp = XawMin(pos, from);
+ if ((length = from - tmp) > 0)
+ x += GetTextWidth(ctx, x, sink->ascii_sink.font, tmp, length);
+ break;
+ }
+ }
+ else {
+ tmp = XawMin(pos, from);
+ if ((length = from - tmp) > 0)
+ x += GetTextWidth(ctx, x, sink->ascii_sink.font, tmp, length);
+ ascent = XawMax(sink->ascii_sink.font->ascent, ascent);
+ descent = XawMax(sink->ascii_sink.font->descent, descent);
+ break;
+ }
+ }
+ if (!ascent)
+ ascent = sink->ascii_sink.font->ascent;
+ if (!descent)
+ descent = sink->ascii_sink.font->descent;
+
+ xl = x;
+
+ /* pass 2: feed the XawTextPaintStruct lists */
+ pos = from;
+ while (pos < to) {
+ paint = XtNew(XawTextPaintStruct);
+ paint->next = sink->text_sink.paint->paint;
+ sink->text_sink.paint->paint = paint;
+ paint->x = x;
+ paint->y = y + ascent;
+ paint->property = NULL;
+ paint->max_ascent = ascent;
+ paint->max_descent = descent;
+ paint->backtabs = NULL;
+ paint->highlight = highlight;
+
+ tmp = pos;
+ if (XawTextSourceAnchorAndEntity(ctx->text.source, pos,
+ &anchor, &entity)) {
+ pos = anchor->position + entity->offset + entity->length;
+ if ((paint->property = XawTextSinkGetProperty((Widget)sink,
+ entity->property)) != NULL &&
+ (paint->property->mask & XAW_TPROP_FONT))
+ font = paint->property->font;
+ else
+ font = sink->ascii_sink.font;
+ }
+ else {
+ if (anchor) {
+ while (entity && anchor->position + entity->offset < pos)
+ entity = entity->next;
+ if (entity)
+ pos = anchor->position + entity->offset;
+ else
+ pos = to;
+ }
+ else
+ pos = to;
+ font = sink->ascii_sink.font;
+ }
+ pos = XawMin(pos, to);
+ length = pos - tmp;
+
+ paint->text = XtMalloc(bufsiz = pos - tmp + 4);
+ paint->length = 0;
+ segment.x1 = x;
+
+ pos2 = tmp;
+ while (length > 0) {
+ pos2 = XawTextSourceRead(ctx->text.source, tmp, &block, length);
+ length = pos - pos2;
+ tmp = pos2;
+ for (i = 0; i < block.length; i++) {
+ unsigned char c = (unsigned char)block.ptr[i];
+
+ if (paint->length + 4 > bufsiz)
+ paint->text = XtRealloc(paint->text, bufsiz += 32);
+ paint->text[paint->length] = c;
+ if (c == '\n') {
+ x += CharWidth(sink, font, 0, ' ');
+ continue;
+ }
+ if (c == '\t') {
+ x += XTextWidth(font, paint->text, paint->length);
+ segment.x2 = x + CharWidth(sink, font, x, '\t');
+
+ if (XmuValidSegment(&segment)) {
+ if (!highlight && (paint->property &&
+ (paint->property->mask & XAW_TPROP_BACKGROUND))) {
+ if (ascent > font->ascent) {
+ scanline.y = y;
+ next.y = y + ascent - font->ascent;
+ XmuAreaOr(sink->text_sink.paint->clip, &area);
+ }
+ if (descent >= font->descent) {
+ scanline.y = y + ascent + font->descent;
+ next.y = scanline.y + descent - font->descent + 1;
+ XmuAreaOr(sink->text_sink.paint->clip, &area);
+ }
+ if (paint->backtabs == NULL)
+ paint->backtabs = XmuCreateArea();
+ scanline.y = y + ascent - font->ascent;
+ next.y = y + ascent + font->descent;
+ XmuAreaOr(paint->backtabs, &area);
+ }
+ else {
+ scanline.y = y;
+ next.y = ctx->text.lt.info[line + 1].y;
+ if (highlight) {
+ if (!sink->text_sink.paint->hightabs)
+ sink->text_sink.paint->hightabs =
+ XmuCreateArea();
+ XmuAreaOr(sink->text_sink.paint->hightabs, &area);
+ }
+ else
+ XmuAreaOr(sink->text_sink.paint->clip, &area);
+ }
+ }
+
+ paint->width = segment.x2 - segment.x1;
+ x = segment.x1 = segment.x2;
+
+ if (paint->length == 0) {
+ paint->x = x;
+ continue;
+ }
+ paint->text = XtRealloc(paint->text, paint->length);
+ property = paint->property;
+ paint = XtNew(XawTextPaintStruct);
+ paint->next = sink->text_sink.paint->paint;
+ sink->text_sink.paint->paint = paint;
+ paint->x = x;
+ paint->y = y + ascent;
+ paint->property = property;
+ paint->max_ascent = ascent;
+ paint->max_descent = descent;
+ paint->backtabs = NULL;
+ paint->highlight = highlight;
+ paint->text = XtMalloc(bufsiz = pos - tmp - length +
+ block.length - i + 4);
+ paint->length = 0;
+ continue;
+ }
+ if ((c & 0177) < XawSP || c == 0177) {
+ if (sink->ascii_sink.display_nonprinting) {
+ if (c > 0177) {
+ paint->text[paint->length++] = '\\';
+ paint->text[paint->length++] = ((c >> 6) & 7) + '0';
+ paint->text[paint->length++] = ((c >> 3) & 7) + '0';
+ paint->text[paint->length] = (c & 7) + '0';
+ }
+ else {
+ c |= 0100;
+ paint->text[paint->length++] = '^';
+ paint->text[paint->length] = c == 0177 ? '?' : c;
+ }
+ }
+ else
+ paint->text[paint->length] = ' ';
+ }
+ paint->length++;
+ }
+ }
+
+ x += XTextWidth(font, paint->text, paint->length);
+ segment.x2 = x;
+ if (XmuValidSegment(&segment)) {
+ /* erase only what really is needed */
+ /*if (!highlight || (paint->property &&
+ (paint->property->mask & XAW_TPROP_BACKGROUND))) {
+ if (ascent > font->ascent) {
+ scanline.y = y;
+ next.y = y + ascent - font->ascent;
+ XmuAreaOr(sink->text_sink.paint->clip, &area);
+ }
+ if (descent > font->descent) {
+ scanline.y = y + ascent + font->descent;
+ next.y = scanline.y + descent - font->descent;
+ XmuAreaOr(sink->text_sink.paint->clip, &area);
+ }
+ }
+ else*/ {
+ scanline.y = y;
+ next.y = ctx->text.lt.info[line + 1].y;
+ XmuAreaOr(sink->text_sink.paint->clip, &area);
+ }
+ }
+
+ paint->width = x - segment.x1;
+ }
+
+ xr = x;
+
+ /* pass 3: bearing clipping */
+ if (left < from) {
+ CalculateBearing(ctx, from - 1, xl, y, ascent, descent, highlight, True);
+ if (ctx->text.s.left < ctx->text.s.right) {
+ if (ctx->text.s.right == from)
+ CalculateBearing(ctx, from, xl, y, ascent, descent, True, False);
+ else if (ctx->text.s.left == from)
+ CalculateBearing(ctx, from, xl, y, ascent, descent, False, False);
+ }
+ }
+ right = XawMin(right, ctx->text.lastPos);
+ if (right >= to && to > from) {
+ if (to < right)
+ CalculateBearing(ctx, to, xr, y, ascent, descent, highlight, False);
+ if (ctx->text.s.left < ctx->text.s.right) {
+ if (ctx->text.s.right == to)
+ CalculateBearing(ctx, to - 1, xr, y, ascent, descent, False, True);
+ else if (ctx->text.s.left == to)
+ CalculateBearing(ctx, to - 1, xr, y, ascent, descent, True, True);
+ }
+ }
+}
+
+static int
+qcmp_paint_struct(_Xconst void *left, _Xconst void *right)
+{
+ return ((*(XawTextPaintStruct**)left)->property -
+ (*(XawTextPaintStruct**)right)->property);
+}
+
+static void
+AsciiDoPaint(Widget w)
+{
+ TextWidget ctx = (TextWidget)XtParent(w);
+ AsciiSinkObject sink = (AsciiSinkObject)ctx->text.sink;
+ XmuScanline *scan;
+ XmuSegment *seg;
+ XawTextPaintList *list = sink->text_sink.paint;
+#if 0
+ XawTextPaintStruct *base, *head;
+#endif
+ XawTextPaintStruct *paint = list->paint;
+ XawTextProperty *property;
+ XFontStruct *font = NULL;
+ XRectangle *rects;
+ int n_rects, i_rects;
+ GC gc;
+ Bool highlight;
+ XRectangle rect;
+ int width, height, line_width = -1;
+ XGCValues values;
+
+ /* pass 1: clear clipping areas */
+ /* XXX Don't use XDrawImageString because the font may be italic, and
+ will get incorrectly drawn. Probably, it could be a good idea to
+ check if this is the case, and do special processing. But this
+ will need to be checked if required. */
+ for (scan = list->clip->scanline; scan && scan->next; scan = scan->next)
+ for (seg = scan->segment; seg; seg = seg->next)
+ _XawTextSinkClearToBackground(ctx->text.sink,
+ seg->x1, scan->y,
+ seg->x2 - seg->x1,
+ scan->next->y - scan->y);
+
+ /* pass 2: optimize drawing list to avoid too much GC change requests */
+ /* XXX this assumes there will not exist entities drawn over other
+ entities. */
+#if 0
+ while (paint) {
+ base = paint;
+ head = paint->next;
+ while (head) {
+ if (head->property == paint->property) {
+ base->next = head->next;
+ head->next = paint->next;
+ paint->next = head;
+ paint = head;
+ }
+ base = head;
+ head = head->next;
+ }
+ paint = paint->next;
+ }
+#endif
+ if (paint && paint->next) {
+ XawTextPaintStruct **paints;
+ int i = 0, n_paints = 0;
+
+ while (paint) {
+ paint = paint->next;
+ ++n_paints;
+ }
+ paints = (XawTextPaintStruct**)
+ XtMalloc(n_paints * sizeof(XawTextPaintStruct));
+ paint = list->paint;
+ while (paint) {
+ paints[i++] = paint;
+ paint = paint->next;
+ }
+ qsort((void*)paints, n_paints, sizeof(XawTextPaintStruct*),
+ qcmp_paint_struct);
+ list->paint = paints[0];
+ for (i = 0; i < n_paints - 1; i++)
+ paints[i]->next = paints[i + 1];
+ paints[i]->next = NULL;
+ XtFree((XtPointer)paints);
+ }
+
+ /* pass 3: clip gc */
+ gc = sink->ascii_sink.normgc;
+
+ rect.x = ctx->text.r_margin.left;
+ rect.y = ctx->text.r_margin.top;
+ width = (int)XtWidth(ctx) - RHMargins(ctx);
+ height = (int)XtHeight(ctx) - RVMargins(ctx);
+ rect.width = width;
+ rect.height = height;
+ if (width >= 0 && height >= 0)
+ XSetClipRectangles(XtDisplay((Widget)ctx), gc,
+ 0, 0, &rect, 1, Unsorted);
+ else
+ XSetClipMask(XtDisplay((Widget)ctx), gc, None);
+
+ /* pass 4: draw backgrounds */
+ paint = list->paint;
+ property = NULL;
+ rects = NULL;
+ i_rects = n_rects = 0;
+ while (paint) {
+ if (paint->property && (paint->property->mask & XAW_TPROP_BACKGROUND)) {
+ if (property != paint->property) {
+ if (i_rects)
+ XFillRectangles(XtDisplay(ctx), XtWindow(ctx), gc,
+ rects, i_rects);
+ i_rects = 0;
+ property = paint->property;
+ if (property->mask & XAW_TPROP_FONT)
+ font = property->font;
+ else
+ font = sink->ascii_sink.font;
+ XSetForeground(XtDisplay(ctx), gc, property->background);
+ }
+ if (i_rects <= n_rects)
+ rects = (XRectangle*)
+ XtRealloc((XtPointer)rects, sizeof(XRectangle) *
+ ++n_rects);
+ rects[i_rects].x = paint->x;
+ rects[i_rects].y = paint->y - font->ascent;
+ rects[i_rects].width = paint->width;
+ rects[i_rects++].height = font->ascent + font->descent;
+
+ if (paint->backtabs) {
+ for (scan = paint->backtabs->scanline; scan && scan->next;
+ scan = scan->next)
+ for (seg = scan->segment; seg; seg = seg->next) {
+ if (i_rects <= n_rects)
+ rects = (XRectangle*)
+ XtRealloc((XtPointer)rects, sizeof(XRectangle) *
+ ++n_rects);
+ rects[i_rects].x = seg->x1;
+ rects[i_rects].y = scan->y;
+ rects[i_rects].width = seg->x2 - seg->x1;
+ rects[i_rects++].height = scan->next->y - scan->y;
+ }
+ }
+
+
+ }
+ paint = paint->next;
+ }
+ if (i_rects)
+ XFillRectangles(XtDisplay(ctx), XtWindow(ctx), gc, rects, i_rects);
+
+ paint = list->paint;
+ i_rects = 0;
+ while (paint) {
+ if (paint->highlight) {
+ if (i_rects == 0)
+ XSetForeground(XtDisplay(ctx), gc, sink->text_sink.cursor_color);
+ if (i_rects <= n_rects)
+ rects = (XRectangle*)
+ XtRealloc((XtPointer)rects, sizeof(XRectangle) *
+ ++n_rects);
+ rects[i_rects].x = paint->x;
+ rects[i_rects].y = paint->y - paint->max_ascent;
+ rects[i_rects].width = paint->width;
+ rects[i_rects++].height = paint->max_ascent + paint->max_descent + 1;
+ }
+ paint = paint->next;
+ }
+ if (list->hightabs) {
+ for (scan = list->hightabs->scanline; scan && scan->next;
+ scan = scan->next)
+ for (seg = scan->segment; seg; seg = seg->next) {
+ if (i_rects == 0)
+ XSetForeground(XtDisplay(ctx), gc,
+ sink->text_sink.cursor_color);
+ if (i_rects <= n_rects)
+ rects = (XRectangle*)
+ XtRealloc((XtPointer)rects, sizeof(XRectangle) *
+ ++n_rects);
+ rects[i_rects].x = seg->x1;
+ rects[i_rects].y = scan->y;
+ rects[i_rects].width = seg->x2 - seg->x1;
+ rects[i_rects++].height = scan->next->y - scan->y;
+ }
+ }
+
+ if (i_rects)
+ XFillRectangles(XtDisplay(ctx), XtWindow(ctx), gc, rects, i_rects);
+ if (rects)
+ XtFree((XtPointer)rects);
+
+ /* pass 5: draw text! */
+ paint = list->paint;
+ if (paint && (property = paint->property) == NULL) {
+ font = sink->ascii_sink.font;
+ XSetFont(XtDisplay(ctx), gc, font->fid);
+ if (!paint->highlight)
+ XSetForeground(XtDisplay(ctx), gc, sink->text_sink.foreground);
+ }
+ else
+ property = NULL;
+ highlight = False;
+ while (paint) {
+ if (!highlight && paint->highlight)
+ XSetForeground(XtDisplay(ctx), gc, sink->text_sink.background);
+ if (highlight || paint->highlight || paint->property != property) {
+ if (!paint->property || !(paint->property->mask & XAW_TPROP_FONT))
+ font = sink->ascii_sink.font;
+ else
+ font = paint->property->font;
+ XSetFont(XtDisplay(ctx), gc, font->fid);
+ if (!paint->highlight) {
+ if (!paint->property ||
+ !(paint->property->mask & XAW_TPROP_FOREGROUND))
+ XSetForeground(XtDisplay(ctx), gc,
+ sink->text_sink.foreground);
+ else
+ XSetForeground(XtDisplay(ctx), gc,
+ paint->property->foreground);
+ }
+ highlight = paint->highlight;
+ property = paint->property;
+ }
+
+ if (paint->x < XtWidth(ctx) && paint->x + paint->width > 0) {
+ XDrawString(XtDisplay(ctx), XtWindow(ctx), gc, paint->x, paint->y,
+ paint->text, paint->length);
+ if (property) {
+ if (property->mask & XAW_TPROP_UNDERLINE) {
+ if (line_width != property->underline_thickness) {
+ values.line_width = line_width =
+ property->underline_thickness;
+ XChangeGC(XtDisplay(ctx), gc, GCLineWidth, &values);
+ }
+
+ XDrawLine(XtDisplay(ctx), XtWindow(ctx), gc, paint->x,
+ paint->y + property->underline_position,
+ paint->x + paint->width,
+ paint->y + property->underline_position);
+ }
+ if (property->mask & XAW_TPROP_OVERSTRIKE) {
+ if (line_width != property->underline_thickness) {
+ values.line_width = line_width =
+ property->underline_thickness;
+ XChangeGC(XtDisplay(ctx), gc, GCLineWidth, &values);
+ }
+
+ XDrawLine(XtDisplay(ctx), XtWindow(ctx), gc, paint->x,
+ paint->y - (font->ascent>>1) + (font->descent>>1),
+ paint->x + paint->width,
+ paint->y - (font->ascent>>1) + (font->descent>>1));
+ }
+ }
+ }
+
+ paint = paint->next;
+ }
+
+ /* pass 6: bearing clipping */
+ /* dont care on order of drawing or caching of state (by now) */
+ paint = list->bearings;
+ while (paint) {
+ XRectangle rect;
+
+ if (paint->highlight)
+ XSetForeground(XtDisplay(ctx), gc, sink->text_sink.background);
+ if (!paint->property || !(paint->property->mask & XAW_TPROP_FONT))
+ font = sink->ascii_sink.font;
+ else
+ font = paint->property->font;
+ XSetFont(XtDisplay(ctx), gc, font->fid);
+ if (!paint->highlight) {
+ if (!paint->property ||
+ !(paint->property->mask & XAW_TPROP_FOREGROUND))
+ XSetForeground(XtDisplay(ctx), gc, sink->text_sink.foreground);
+ else
+ XSetForeground(XtDisplay(ctx), gc, paint->property->foreground);
+ }
+ if (paint->x < XtWidth(ctx) && paint->x + paint->width > 0) {
+ rect.x = paint->x + paint->width;
+ rect.width = XawAbs(paint->width); /* more than enough */
+ rect.y = paint->y - font->ascent;
+ rect.height = rect.y + font->ascent + font->descent;
+ XSetClipRectangles(XtDisplay((Widget)ctx), gc,
+ 0, 0, &rect, 1, Unsorted);
+ XDrawString(XtDisplay(ctx), XtWindow(ctx), gc, paint->x, paint->y,
+ paint->text, paint->length);
+ }
+ paint = paint->next;
+ }
+}
+#endif
+
+/*
+ * Function:
+ * PaintText
+ *
+ * Parameters:
+ * w - text sink object
+ * gc - gc to paint text with
+ * x - location to paint the text
+ * y - ""
+ * buf - buffer and length of text to paint.
+ * len - ""
+ * clear_bg - clear background before drawing ?
+ *
+ * Description:
+ * Actually paints the text into the window.
+ *
+ * Returns:
+ * the width of the text painted
+ */
+static unsigned int
+PaintText(Widget w, GC gc, int x, int y, char *buf, int len, Bool clear_bg)
+{
+ AsciiSinkObject sink = (AsciiSinkObject)w;
+ TextWidget ctx = (TextWidget)XtParent(w);
+ int width = XTextWidth(sink->ascii_sink.font, buf, len);
+
+ if ((x > XtWidth(ctx)) || width <= -x) /* Don't draw if we can't see it */
+ return (width);
+
+ if (clear_bg) {
+ _XawTextSinkClearToBackground(w, x, y - sink->ascii_sink.font->ascent,
+ width, sink->ascii_sink.font->ascent
+ + sink->ascii_sink.font->descent);
+ XDrawString(XtDisplay(ctx), XtWindow(ctx), gc, x, y, buf, len);
+ }
+ else
+ XDrawImageString(XtDisplay(ctx), XtWindow(ctx), gc, x, y, buf, len);
+
+ return (width);
+}
+
+static void
+DisplayText(Widget w, int x, int y,
+ XawTextPosition pos1, XawTextPosition pos2, Bool highlight)
+{
+ TextWidget ctx = (TextWidget)XtParent(w);
+ AsciiSinkObject sink = (AsciiSinkObject)w;
+ XFontStruct *font = sink->ascii_sink.font;
+ Widget source = XawTextGetSource(XtParent(w));
+ unsigned char buf[260];
+ int j, k;
+ XawTextBlock blk;
+ GC gc, invgc, tabgc;
+ int max_x;
+ Bool clear_bg;
+
+ if (!sink->ascii_sink.echo || !ctx->text.lt.lines)
+ return;
+
+ max_x = (int)XtWidth(ctx) - ctx->text.r_margin.right;
+ clear_bg = !highlight && ctx->core.background_pixmap != XtUnspecifiedPixmap;
+
+ gc = highlight ? sink->ascii_sink.invgc : sink->ascii_sink.normgc;
+ invgc = highlight ? sink->ascii_sink.normgc : sink->ascii_sink.invgc;
+
+ if (highlight && sink->ascii_sink.xorgc)
+ tabgc = sink->ascii_sink.xorgc;
+ else
+ tabgc = invgc;
+
+ y += sink->ascii_sink.font->ascent;
+ for (j = 0; pos1 < pos2;) {
+ pos1 = XawTextSourceRead(source, pos1, &blk, pos2 - pos1);
+ for (k = 0; k < blk.length; k++) {
+ if (j >= sizeof(buf) - 4) { /* buffer full, dump the text */
+ if ((x += PaintText(w, gc, x, y, (char*)buf, j, clear_bg))
+ >= max_x)
+ return;
+ j = 0;
+ }
+ buf[j] = blk.ptr[k];
+ if (buf[j] == XawLF) /* line feeds ('\n') are not printed */
+ continue;
+
+ else if (buf[j] == '\t') {
+ int width;
+
+ if (j != 0
+ && (x += PaintText(w, gc, x, y, (char*)buf, j, clear_bg))
+ >= max_x)
+ return;
+
+ if ((width = CharWidth(sink, font, x, '\t')) > -x) {
+ if (clear_bg)
+ _XawTextSinkClearToBackground(w, x, y-font->ascent, width,
+ font->ascent+font->descent);
+ else
+ XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
+ tabgc, x, y - font->ascent, width,
+ font->ascent + font->descent);
+ }
+
+ if ((x += width) >= max_x)
+ return;
+
+ j = -1;
+ }
+ else if ((buf[j] & 0177) < XawSP || buf[j] == 0177) {
+ if (sink->ascii_sink.display_nonprinting) {
+ unsigned char c = buf[j];
+
+ if (c > 0177) {
+ buf[j++] = '\\';
+ buf[j++] = ((c >> 6) & 7) + '0';
+ buf[j++] = ((c >> 3) & 7) + '0';
+ buf[j] = (c & 7) + '0';
+ }
+ else {
+ c |= 0100;
+ buf[j++] = '^';
+ buf[j] = c == 0177 ? '?' : c;
+ }
+ }
+ else
+ buf[j] = ' ';
+ }
+ j++;
+ }
+ }
+
+ if (j > 0)
+ (void)PaintText(w, gc, x, y, (char*)buf, j, clear_bg);
+}
+
+/*
+ * Function:
+ * GetCursorBounds
+ *
+ * Parameters:
+ * w - text sink object
+ * rect - X rectangle to return the cursor bounds
+ *
+ * Description:
+ * Returns the size and location of the cursor.
+ */
+static void
+GetCursorBounds(Widget w, XRectangle *rect)
+{
+ AsciiSinkObject sink = (AsciiSinkObject)w;
+ XFontStruct *font = sink->ascii_sink.font;
+ unsigned char ch;
+#ifndef OLDXAW
+ TextWidget ctx = (TextWidget)XtParent(w);
+ XawTextBlock block;
+ XawTextAnchor *anchor;
+ XawTextEntity *entity;
+ XawTextProperty *property;
+
+ if (XawTextSourceAnchorAndEntity(XawTextGetSource(XtParent(w)),
+ sink->ascii_sink.cursor_position,
+ &anchor, &entity)) {
+ if ((property = XawTextSinkGetProperty((Widget)sink,
+ entity->property)) != NULL &&
+ (property->mask & XAW_TPROP_FONT))
+ font = property->font;
+ }
+ (void)XawTextSourceRead(XawTextGetSource((Widget)ctx),
+ ctx->text.insertPos, &block, 1);
+ if (!block.length || block.ptr[0] == '\n' || block.ptr[0] == '\t')
+ ch = ' ';
+ else if ((*((unsigned char*)block.ptr) & 0177) < XawSP ||
+ *(unsigned char*)block.ptr == 0177) {
+ if (sink->ascii_sink.display_nonprinting)
+ ch = *((unsigned char*)block.ptr) > 0177 ? '\\' : '^';
+ else
+ ch = ' ';
+ }
+ else
+ ch = *(unsigned char*)block.ptr;
+#else
+ ch = ' ';
+#endif
+
+ rect->width = CharWidth(sink, font, 0, ch);
+ rect->height = font->descent + font->ascent + 1;
+
+ rect->x = sink->ascii_sink.cursor_x;
+ rect->y = sink->ascii_sink.cursor_y - font->ascent;
+}
+
+/* this function is required to support diferent fonts and correctly place
+ * the cursor. There are better ways to calculate the base line, but there is
+ * no place/code (yet) to store this information.
+ */
+static int
+FindCursorY(TextWidget ctx, XawTextPosition position)
+{
+ int y, line, ascent;
+ AsciiSinkObject sink = (AsciiSinkObject)ctx->text.sink;
+#ifndef OLDXAW
+ XawTextAnchor *anchor;
+ XawTextEntity *entity;
+ XawTextProperty *property;
+ XawTextPosition left, right;
+#endif
+
+ for (line = 0; line < ctx->text.lt.lines; line++)
+ if (position < ctx->text.lt.info[line + 1].position)
+ break;
+
+ y = ctx->text.lt.info[line].y;
+#ifndef OLDXAW
+ ascent = 0;
+ left = ctx->text.lt.info[line].position;
+ right = ctx->text.lt.info[line + 1].position;
+ right = XawMin(right, ctx->text.lastPos + 1);
+ while (left < right) {
+ if (XawTextSourceAnchorAndEntity(ctx->text.source, left,
+ &anchor, &entity)) {
+ if ((property = XawTextSinkGetProperty((Widget)sink,
+ entity->property)) != NULL &&
+ (property->mask & XAW_TPROP_FONT))
+ ascent = XawMax(property->font->ascent, ascent);
+ else
+ ascent = XawMax(sink->ascii_sink.font->ascent, ascent);
+ left = anchor->position + entity->offset + entity->length;
+ }
+ else if (anchor) {
+ ascent = XawMax(sink->ascii_sink.font->ascent, ascent);
+ while (entity) {
+ XawTextPosition tmp = anchor->position + entity->offset + entity->length;
+
+ if (tmp > left && tmp < right) {
+ left = tmp;
+ if ((property = XawTextSinkGetProperty((Widget)sink,
+ entity->property)) != NULL &&
+ (property->mask & XAW_TPROP_FONT))
+ ascent = XawMax(property->font->ascent, ascent);
+ else
+ ascent = XawMax(sink->ascii_sink.font->ascent, ascent);
+ }
+ entity = entity->next;
+ }
+ if (entity == NULL)
+ break;
+ }
+ else {
+ ascent = XawMax(sink->ascii_sink.font->ascent, ascent);
+ break;
+ }
+ }
+ if (!ascent)
+ ascent = sink->ascii_sink.font->ascent;
+#else
+ ascent = sink->ascii_sink.font->ascent;
+#endif
+
+ return (y + ascent);
+}
+
+static void
+InsertCursor(Widget w, int x, int y, XawTextInsertState state)
+{
+ AsciiSinkObject sink = (AsciiSinkObject)w;
+ XFontStruct *font = sink->ascii_sink.font;
+ TextWidget ctx = (TextWidget)XtParent(w);
+ XawTextPosition position = XawTextGetInsertionPoint((Widget)ctx);
+ Boolean overflow = (x & 0xffff8000) != 0;
+#ifndef OLDXAW
+ XawTextAnchor *anchor;
+ XawTextEntity *entity;
+ XawTextProperty *property;
+#endif
+
+ if (XtIsRealized((Widget)ctx)) {
+ int fheight;
+ XawTextBlock block;
+ XawTextPosition selection_start, selection_end;
+ Boolean has_selection;
+
+ if (!sink->ascii_sink.echo) {
+ if (sink->ascii_sink.laststate != state) {
+ int width = CharWidth(sink, font, 0, ' ') - 1;
+
+ x = ctx->text.margin.left;
+ y = ctx->text.margin.top;
+ font = sink->ascii_sink.font;
+ fheight = font->ascent + font->descent;
+ if (state == XawisOn) {
+ if (ctx->text.hasfocus)
+ XFillRectangle(XtDisplay(ctx), XtWindow(ctx),
+ sink->ascii_sink.xorgc, x, y,
+ width + 1, fheight + 1);
+ else
+ XDrawRectangle(XtDisplay(ctx), XtWindow(ctx),
+ sink->ascii_sink.xorgc, x, y,
+ width, fheight);
+
+ }
+ else
+ _XawTextSinkClearToBackground(w, x, y,
+ width + 1, fheight + 1);
+ }
+ sink->ascii_sink.cursor_x = x;
+ sink->ascii_sink.cursor_y = y;
+ sink->ascii_sink.laststate = state;
+ return;
+ }
+
+
+ XawTextGetSelectionPos((Widget)ctx, &selection_start, &selection_end);
+ has_selection = selection_start != selection_end;
+
+ if (sink->ascii_sink.laststate != state) {
+ unsigned char ch;
+
+#ifndef OLDXAW
+ if (XawTextSourceAnchorAndEntity(ctx->text.source,
+ position, &anchor, &entity) &&
+ (property = XawTextSinkGetProperty((Widget)sink,
+ entity->property)) != NULL &&
+ (property->mask & XAW_TPROP_FONT))
+ font = property->font;
+ else
+ font = sink->ascii_sink.font;
+#endif
+
+ fheight = font->ascent + font->descent;
+ (void)XawTextSourceRead(XawTextGetSource((Widget)ctx),
+ position, &block, 1);
+ if (!block.length || block.ptr[0] == '\n' || block.ptr[0] == '\t')
+ ch = ' ';
+ else if ((*((unsigned char*)block.ptr) & 0177) < XawSP
+ || *(unsigned char*)block.ptr == 0177) {
+ if (sink->ascii_sink.display_nonprinting)
+ ch = *((unsigned char*)block.ptr) > 0177 ? '\\' : '^';
+ else
+ ch = ' ';
+ }
+ else
+ ch = *(unsigned char*)block.ptr;
+
+ y = FindCursorY(ctx, position);
+ if (ctx->text.hasfocus && !has_selection)
+ XFillRectangle(XtDisplay(ctx), XtWindow(ctx),
+ sink->ascii_sink.xorgc, x, y - font->ascent,
+ CharWidth(sink, font, 0, ch), fheight + 1);
+ else
+ XDrawRectangle(XtDisplay(ctx), XtWindow(ctx),
+ sink->ascii_sink.xorgc, x, y - font->ascent,
+ CharWidth(sink, font, 0, ch) - 1, fheight);
+ }
+ }
+
+ sink->ascii_sink.cursor_x = overflow ? -16384 : x;
+ sink->ascii_sink.cursor_y = y;
+ sink->ascii_sink.laststate = state;
+ sink->ascii_sink.cursor_position = position;
+}
+
+/*
+ * Given two positions, find the distance between them
+ */
+static void
+FindDistance(Widget w, XawTextPosition fromPos, int fromx,
+ XawTextPosition toPos, int *resWidth,
+ XawTextPosition *resPos, int *resHeight)
+{
+#ifndef OLDXAW
+ AsciiSinkObject sink = (AsciiSinkObject)w;
+ TextWidget ctx = (TextWidget)XtParent(w);
+ XFontStruct *font = sink->ascii_sink.font;
+ Widget source = ctx->text.source;
+ XawTextPosition idx, pos;
+ unsigned char c;
+ XawTextBlock blk;
+ int i, rWidth, ascent = 0, descent = 0;
+ XawTextAnchor *anchor;
+ XawTextEntity *entity;
+ XawTextProperty *property;
+ Cardinal length;
+ Bool done = False;
+
+ pos = idx = fromPos;
+ rWidth = 0;
+ c = 0;
+
+ while (!done) {
+ if (XawTextSourceAnchorAndEntity(source, pos, &anchor, &entity)) {
+ length = anchor->position + entity->offset + entity->length;
+ length = XawMin(toPos, length) - pos;
+ if ((property = XawTextSinkGetProperty((Widget)sink,
+ entity->property)) != NULL &&
+ (property->mask & XAW_TPROP_FONT))
+ font = property->font;
+ else
+ font = sink->ascii_sink.font;
+ }
+ else {
+ if (anchor) {
+ while (entity && anchor->position + entity->offset < pos)
+ entity = entity->next;
+ if (entity) {
+ length = anchor->position + entity->offset;
+ length = XawMin(toPos, length) - pos;
+ }
+ else
+ length = XawMin(toPos - pos, 4096);
+ }
+ else
+ length = XawMin(toPos - pos, 4096);
+ font = sink->ascii_sink.font;
+ }
+
+ ascent = XawMax(font->ascent, ascent);
+ descent = XawMax(font->descent, descent);
+
+ pos = XawTextSourceRead(source, pos, &blk, length);
+ if (blk.length == 0 && pos == idx) /* eof reached */
+ break;
+
+ idx = blk.firstPos;
+ for (i = 0; idx < toPos; i++, idx++) {
+ if (i >= blk.length)
+ break;
+ c = blk.ptr[i];
+ rWidth += CharWidth(sink, font, fromx + rWidth, c);
+ if (c == XawLF) {
+ idx++;
+ done = True;
+ break;
+ }
+ }
+ if (idx >= toPos)
+ break;
+ }
+
+ *resPos = idx;
+ *resWidth = rWidth;
+ *resHeight = ascent + descent + 1;
+#else
+ AsciiSinkObject sink = (AsciiSinkObject)w;
+ TextWidget ctx = (TextWidget)XtParent(w);
+ XFontStruct *font = sink->ascii_sink.font;
+ Widget source = ctx->text.source;
+ XawTextPosition idx, pos;
+ unsigned char c;
+ XawTextBlock blk;
+ int i, rWidth;
+
+ pos = XawTextSourceRead(source, fromPos, &blk, toPos - fromPos);
+ rWidth = 0;
+ for (i = 0, idx = fromPos; idx < toPos; i++, idx++) {
+ if (i >= blk.length) {
+ i = 0;
+ pos = XawTextSourceRead(source, pos, &blk, toPos - pos);
+ if (blk.length == 0)
+ break;
+ }
+ c = blk.ptr[i];
+ rWidth += CharWidth(sink, font, fromx + rWidth, c);
+ if (c == XawLF) {
+ idx++;
+ break;
+ }
+ }
+
+ *resPos = idx;
+ *resWidth = rWidth;
+ *resHeight = font->ascent + font->descent + 1;
+#endif
+}
+
+static void
+FindPosition(Widget w, XawTextPosition fromPos, int fromx, int width,
+ Bool stopAtWordBreak, XawTextPosition *resPos,
+ int *resWidth, int *resHeight)
+{
+#ifndef OLDXAW
+ AsciiSinkObject sink = (AsciiSinkObject)w;
+ TextWidget ctx = (TextWidget)XtParent(w);
+ Widget source = ctx->text.source;
+ XFontStruct *font = sink->ascii_sink.font;
+ XawTextPosition idx, pos, whiteSpacePosition = 0;
+ int i, lastWidth, whiteSpaceWidth, rWidth, ascent = 0, descent = 0;
+ Boolean whiteSpaceSeen;
+ unsigned char c;
+ XawTextBlock blk;
+ XawTextAnchor *anchor;
+ XawTextEntity *entity;
+ XawTextProperty *property;
+ Cardinal length;
+ Bool done = False;
+
+ pos = idx = fromPos;
+ rWidth = lastWidth = whiteSpaceWidth = 0;
+ whiteSpaceSeen = False;
+ c = 0;
+
+ while (!done) {
+ font = sink->ascii_sink.font;
+ if (XawTextSourceAnchorAndEntity(source, pos, &anchor, &entity)) {
+ length = anchor->position + entity->offset + entity->length - pos;
+ if ((property = XawTextSinkGetProperty((Widget)sink,
+ entity->property)) != NULL &&
+ (property->mask & XAW_TPROP_FONT))
+ font = property->font;
+ }
+ else {
+ if (anchor) {
+ while (entity && anchor->position + entity->offset < pos)
+ entity = entity->next;
+ if (entity)
+ length = anchor->position + entity->offset - pos;
+ else
+ length = 4096;
+ }
+ else
+ length = 4096;
+ }
+
+ ascent = XawMax(font->ascent, ascent);
+ descent = XawMax(font->descent, descent);
+
+ pos = XawTextSourceRead(source, pos, &blk, length);
+ if (blk.length == 0 && pos == idx) /* eof reached */
+ break;
+
+ idx = blk.firstPos;
+ for (i = 0; rWidth <= width && i < blk.length; i++, idx++) {
+ c = blk.ptr[i];
+ lastWidth = rWidth;
+ rWidth += CharWidth(sink, font, fromx + rWidth, c);
+
+ if (c == XawLF) {
+ idx++;
+ done = True;
+ break;
+ }
+ else if ((c == XawSP || c == XawTAB) && rWidth <= width) {
+ whiteSpaceSeen = True;
+ whiteSpacePosition = idx;
+ whiteSpaceWidth = rWidth;
+ }
+ }
+ if (rWidth > width)
+ break;
+ }
+
+ if (rWidth > width && idx > fromPos) {
+ idx--;
+ rWidth = lastWidth;
+ if (stopAtWordBreak && whiteSpaceSeen) {
+ idx = whiteSpacePosition + 1;
+ rWidth = whiteSpaceWidth;
+ }
+ }
+
+ if (idx >= ctx->text.lastPos && c != XawLF)
+ idx = ctx->text.lastPos + 1;
+
+ *resPos = idx;
+ *resWidth = rWidth;
+ *resHeight = ascent + descent + 1;
+#else
+ AsciiSinkObject sink = (AsciiSinkObject)w;
+ TextWidget ctx = (TextWidget)XtParent(w);
+ Widget source = ctx->text.source;
+ XFontStruct *font = sink->ascii_sink.font;
+ XawTextPosition idx, pos, whiteSpacePosition = 0;
+ int i, lastWidth, whiteSpaceWidth, rWidth;
+ Boolean whiteSpaceSeen;
+ unsigned char c;
+ XawTextBlock blk;
+
+ pos = XawTextSourceRead(source, fromPos, &blk, BUFSIZ);
+ rWidth = lastWidth = whiteSpaceWidth = 0;
+ whiteSpaceSeen = False;
+ c = 0;
+
+ for (i = 0, idx = fromPos; rWidth <= width; i++, idx++) {
+ if (i >= blk.length) {
+ i = 0;
+ pos = XawTextSourceRead(source, pos, &blk, BUFSIZ);
+ if (blk.length == 0)
+ break;
+ }
+ c = blk.ptr[i];
+ lastWidth = rWidth;
+ rWidth += CharWidth(sink, font, fromx + rWidth, c);
+
+ if (c == XawLF) {
+ idx++;
+ break;
+ }
+ else if ((c == XawSP || c == XawTAB) && rWidth <= width) {
+ whiteSpaceSeen = True;
+ whiteSpacePosition = idx;
+ whiteSpaceWidth = rWidth;
+ }
+ }
+
+ if (rWidth > width && idx > fromPos) {
+ idx--;
+ rWidth = lastWidth;
+ if (stopAtWordBreak && whiteSpaceSeen) {
+ idx = whiteSpacePosition + 1;
+ rWidth = whiteSpaceWidth;
+ }
+ }
+
+ if (idx >= ctx->text.lastPos && c != XawLF)
+ idx = ctx->text.lastPos + 1;
+
+ *resPos = idx;
+ *resWidth = rWidth;
+ *resHeight = font->ascent + font->descent + 1;
+#endif
+}
+
+static void
+Resolve(Widget w, XawTextPosition pos, int fromx, int width,
+ XawTextPosition *pos_return)
+{
+ int resWidth, resHeight;
+ Widget source = XawTextGetSource(XtParent(w));
+
+ FindPosition(w, pos, fromx, width, False, pos_return, &resWidth, &resHeight);
+ if (*pos_return > GETLASTPOS)
+ *pos_return = GETLASTPOS;
+}
+
+static void
+GetGC(AsciiSinkObject sink)
+{
+ XtGCMask valuemask = (GCFont | GCGraphicsExposures | GCClipXOrigin |
+ GCForeground | GCBackground);
+ XGCValues values;
+
+ /* XXX We dont want do share a gc that will change the clip-mask */
+ values.clip_x_origin = (long)sink;
+ values.clip_mask = None;
+ values.font = sink->ascii_sink.font->fid;
+ values.graphics_exposures = False;
+
+ values.foreground = sink->text_sink.foreground;
+ values.background = sink->text_sink.background;
+ sink->ascii_sink.normgc = XtAllocateGC((Widget)sink, 0, valuemask, &values,
+ GCClipMask | GCFont | GCForeground |
+ GCBackground, 0);
+
+ values.foreground = sink->text_sink.background;
+#ifndef OLDXAW
+ values.background = sink->text_sink.cursor_color;
+#else
+ values.background = sink->text_sink.foreground;
+#endif
+ sink->ascii_sink.invgc = XtAllocateGC((Widget)sink, 0, valuemask, &values,
+ GCClipMask | GCFont, 0);
+
+ valuemask |= GCFunction;
+ values.function = GXxor;
+#ifndef OLDXAW
+ values.foreground = sink->text_sink.background ^ sink->text_sink.cursor_color;
+#else
+ values.foreground = sink->text_sink.background ^ sink->text_sink.foreground;
+#endif
+ values.background = 0L;
+ sink->ascii_sink.xorgc = XtAllocateGC((Widget)sink, 0, valuemask,
+ &values, GCClipMask | GCFont, 0);
+
+ XawAsciiSinkResize((Widget)sink);
+}
+
+/* Function:
+ * XawAsciiSinkInitialize
+ *
+ * Parameters:
+ * request - the requested and new values for the object instance
+ * cnew - ""
+ *
+ * Description:
+ * Initializes the TextSink Object.
+ */
+/*ARGSUSED*/
+static void
+XawAsciiSinkInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ AsciiSinkObject sink = (AsciiSinkObject)cnew;
+
+ GetGC(sink);
+
+ if (!sink->ascii_sink.font) XtError("Aborting: no font found\n");
+
+ sink->ascii_sink.cursor_position = 0;
+ sink->ascii_sink.laststate = XawisOff;
+ sink->ascii_sink.cursor_x = sink->ascii_sink.cursor_y = 0;
+}
+
+/*
+ * Function:
+ * XawAsciiSinkDestroy
+ *
+ * Parameters:
+ * w - AsciiSink Object
+ *
+ * Description:
+ * This function cleans up when the object is destroyed.
+ */
+static void
+XawAsciiSinkDestroy(Widget w)
+{
+ AsciiSinkObject sink = (AsciiSinkObject)w;
+
+ XtReleaseGC(w, sink->ascii_sink.normgc);
+ XtReleaseGC(w, sink->ascii_sink.invgc);
+ XtReleaseGC(w, sink->ascii_sink.xorgc);
+
+ sink->ascii_sink.normgc =
+ sink->ascii_sink.invgc =
+ sink->ascii_sink.xorgc = NULL;
+}
+
+static void
+XawAsciiSinkResize(Widget w)
+{
+ TextWidget ctx = (TextWidget)XtParent(w);
+ AsciiSinkObject sink = (AsciiSinkObject)w;
+ XRectangle rect;
+ int width, height;
+
+ if (w->core.widget_class != asciiSinkObjectClass)
+ return;
+
+ rect.x = ctx->text.r_margin.left;
+ rect.y = ctx->text.r_margin.top;
+ width = (int)XtWidth(ctx) - RHMargins(ctx);
+ height = (int)XtHeight(ctx) - RVMargins(ctx);
+ rect.width = width;
+ rect.height = height;
+
+ if (sink->ascii_sink.normgc) {
+ if (width >= 0 && height >= 0)
+ XSetClipRectangles(XtDisplay((Widget)ctx), sink->ascii_sink.normgc,
+ 0, 0, &rect, 1, Unsorted);
+ else
+ XSetClipMask(XtDisplay((Widget)ctx), sink->ascii_sink.normgc, None);
+ }
+ if (sink->ascii_sink.invgc) {
+ if (width >= 0 && height >= 0)
+ XSetClipRectangles(XtDisplay((Widget)ctx), sink->ascii_sink.invgc,
+ 0, 0, &rect, 1, Unsorted);
+ else
+ XSetClipMask(XtDisplay((Widget)ctx), sink->ascii_sink.invgc, None);
+ }
+ if (sink->ascii_sink.xorgc) {
+ if (width >= 0 && height >= 0)
+ XSetClipRectangles(XtDisplay((Widget)ctx), sink->ascii_sink.xorgc,
+ 0, 0, &rect, 1, Unsorted);
+ else
+ XSetClipMask(XtDisplay((Widget)ctx), sink->ascii_sink.xorgc, None);
+ }
+}
+
+/*
+ * Function:
+ * XawAsciiSinkSetValues
+ *
+ * Parameters:
+ * current - current state of the object
+ * request - what was requested
+ * cnew - what the object will become
+ *
+ * Description:
+ * Sets the values for the AsciiSink.
+ *
+ * Returns:
+ * True if redisplay is needed
+ */
+/*ARGSUSED*/
+static Boolean
+XawAsciiSinkSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ AsciiSinkObject w = (AsciiSinkObject)cnew;
+ AsciiSinkObject old_w = (AsciiSinkObject)current;
+
+ if (w->ascii_sink.font != old_w->ascii_sink.font
+ || w->text_sink.background != old_w->text_sink.background
+ || w->text_sink.foreground != old_w->text_sink.foreground
+#ifndef OLDXAW
+ || w->text_sink.cursor_color != old_w->text_sink.cursor_color
+ || w->text_sink.properties != old_w->text_sink.properties
+#endif
+ ) {
+#ifdef OLDXAW
+ XtReleaseGC(cnew, w->ascii_sink.normgc);
+ XtReleaseGC(cnew, w->ascii_sink.invgc);
+ XtReleaseGC(cnew, w->ascii_sink.xorgc);
+ GetGC(w);
+#endif
+ ((TextWidget)XtParent(cnew))->text.redisplay_needed = True;
+ }
+ else if (w->ascii_sink.echo != old_w->ascii_sink.echo
+ || w->ascii_sink.display_nonprinting
+ != old_w->ascii_sink.display_nonprinting)
+ ((TextWidget)XtParent(cnew))->text.redisplay_needed = True;
+#ifndef OLDXAW
+ if (w->text_sink.properties != old_w->text_sink.properties) {
+ XawTextProperty *property =
+ XawTextSinkGetProperty(cnew, XrmStringToQuark("default"));
+
+ if (property) {
+ if (property->mask & XAW_TPROP_FONT)
+ w->ascii_sink.font = property->font;
+ if (property->mask & XAW_TPROP_FOREGROUND)
+ w->text_sink.foreground = property->foreground;
+ if (property->mask & XAW_TPROP_BACKGROUND)
+ w->text_sink.background = property->background;
+ }
+ }
+#endif
+
+ return (False);
+}
+
+/*
+ * Function:
+ * MaxLines
+ *
+ * Parameters:
+ * w - AsciiSink Object
+ * height - height to fit lines into
+ *
+ * Description:
+ * Finds the Maximum number of lines that will fit in a given height.
+ *
+ * Returns:
+ * The number of lines that will fit
+ */
+/*ARGSUSED*/
+static int
+MaxLines(Widget w, unsigned int height)
+{
+ AsciiSinkObject sink = (AsciiSinkObject)w;
+ int font_height;
+
+ font_height = sink->ascii_sink.font->ascent + sink->ascii_sink.font->descent + 1;
+
+ return ((int)height / font_height);
+}
+
+/*
+ * Function:
+ * MaxHeight
+ *
+ * Parameters:
+ * w - AsciiSink Object
+ * lines - number of lines
+ *
+ * Description:
+ * Finds the Minium height that will contain a given number lines.
+ *
+ * Returns:
+ * the height
+ */
+static int
+MaxHeight(Widget w, int lines)
+{
+ AsciiSinkObject sink = (AsciiSinkObject)w;
+
+ return (lines * (sink->ascii_sink.font->ascent +
+ sink->ascii_sink.font->descent + 1));
+}
+
+/*
+ * Function:
+ * SetTabs
+ *
+ * Parameters:
+ * w - AsciiSink Object
+ * tab_count - number of tabs in the list
+ * tabs - text positions of the tabs
+ *
+ * Description:
+ * Sets the Tab stops.
+ */
+static void
+SetTabs(Widget w, int tab_count, short *tabs)
+{
+ AsciiSinkObject sink = (AsciiSinkObject)w;
+ int i;
+ Atom XA_FIGURE_WIDTH;
+ unsigned long figure_width = 0;
+ XFontStruct *font = sink->ascii_sink.font;
+
+ /*
+ * Find the figure width of the current font
+ */
+ XA_FIGURE_WIDTH = XInternAtom(XtDisplayOfObject(w), "FIGURE_WIDTH", False);
+ if (XA_FIGURE_WIDTH != None
+ && (!XGetFontProperty(font, XA_FIGURE_WIDTH, &figure_width)
+ || figure_width == 0)) {
+ if (font->per_char && font->min_char_or_byte2 <= '$'
+ && font->max_char_or_byte2 >= '$')
+ figure_width = font->per_char['$' - font->min_char_or_byte2].width;
+ else
+ figure_width = font->max_bounds.width;
+ }
+
+ if (tab_count > sink->text_sink.tab_count) {
+ sink->text_sink.tabs = (Position *)
+ XtRealloc((char*)sink->text_sink.tabs, tab_count * sizeof(Position));
+ sink->text_sink.char_tabs = (short *)
+ XtRealloc((char*)sink->text_sink.char_tabs, tab_count * sizeof(short));
+ }
+
+ for (i = 0 ; i < tab_count ; i++) {
+ sink->text_sink.tabs[i] = tabs[i] * figure_width;
+ sink->text_sink.char_tabs[i] = tabs[i];
+ }
+
+ sink->text_sink.tab_count = tab_count;
+
+#ifndef NO_TAB_FIX
+ {
+ TextWidget ctx = (TextWidget)XtParent(w);
+ ctx->text.redisplay_needed = True;
+ _XawTextBuildLineTable(ctx, ctx->text.lt.top, True);
+ }
+#endif
+}
diff --git a/nx-X11/lib/Xaw/AsciiSink.h b/nx-X11/lib/Xaw/AsciiSink.h
new file mode 100644
index 000000000..234927493
--- /dev/null
+++ b/nx-X11/lib/Xaw/AsciiSink.h
@@ -0,0 +1,82 @@
+/*
+ * $Xorg: AsciiSink.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/AsciiSink.h,v 1.5 2001/01/17 19:42:25 dawes Exp $ */
+
+#ifndef _XawAsciiSink_h
+#define _XawAsciiSink_h
+
+/*
+ * AsciiSink Object
+ */
+
+#include <X11/Xaw/TextSink.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ echo Output Boolean True
+ displayNonprinting Output Boolean True
+
+*/
+
+#define XtCOutput "Output"
+
+#define XtNdisplayNonprinting "displayNonprinting"
+#define XtNecho "echo"
+
+/* Class record constants */
+extern WidgetClass asciiSinkObjectClass;
+
+typedef struct _AsciiSinkClassRec *AsciiSinkObjectClass;
+typedef struct _AsciiSinkRec *AsciiSinkObject;
+
+#endif /* _XawAsciiSink_h */
diff --git a/nx-X11/lib/Xaw/AsciiSinkP.h b/nx-X11/lib/Xaw/AsciiSinkP.h
new file mode 100644
index 000000000..b160092f3
--- /dev/null
+++ b/nx-X11/lib/Xaw/AsciiSinkP.h
@@ -0,0 +1,101 @@
+/*
+* $Xorg: AsciiSinkP.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/AsciiSinkP.h,v 1.9 2001/01/17 19:42:25 dawes Exp $ */
+
+#ifndef _XawAsciiSinkP_h
+#define _XawAsciiSinkP_h
+
+/*
+ * AsciiSink Object Private Data
+ */
+#include <X11/Xaw/TextSinkP.h>
+#include <X11/Xaw/AsciiSink.h>
+
+/* New fields for the AsciiSink object class record */
+typedef struct _AsciiSinkClassPart {
+ XtPointer extension;
+} AsciiSinkClassPart;
+
+/* Full class record declaration */
+typedef struct _AsciiSinkClassRec {
+ ObjectClassPart object_class;
+ TextSinkClassPart text_sink_class;
+ AsciiSinkClassPart ascii_sink_class;
+} AsciiSinkClassRec;
+
+extern AsciiSinkClassRec asciiSinkClassRec;
+
+/* New fields for the AsciiSink object record */
+typedef struct {
+ /* resources */
+ XFontStruct *font; /* Font to draw in. */
+ Boolean echo;
+ Boolean display_nonprinting;
+
+ /* private */
+ GC normgc, invgc, xorgc;
+ XawTextPosition cursor_position;
+ XawTextInsertState laststate;
+ short cursor_x, cursor_y; /* Cursor Location. */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} AsciiSinkPart;
+
+/* Full instance record declaration */
+typedef struct _AsciiSinkRec {
+ ObjectPart object;
+ TextSinkPart text_sink;
+ AsciiSinkPart ascii_sink;
+} AsciiSinkRec;
+
+#endif /* _XawAsciiSinkP_h */
diff --git a/nx-X11/lib/Xaw/AsciiSrc.c b/nx-X11/lib/Xaw/AsciiSrc.c
new file mode 100644
index 000000000..b23ba4fca
--- /dev/null
+++ b/nx-X11/lib/Xaw/AsciiSrc.c
@@ -0,0 +1,1886 @@
+/* $Xorg: AsciiSrc.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* $XFree86: xc/lib/Xaw/AsciiSrc.c,v 1.33 2002/07/04 17:04:20 paulo Exp $ */
+
+/*
+ * AsciiSrc.c - AsciiSrc object. (For use with the text widget).
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <errno.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/AsciiSrcP.h>
+#include <X11/Xaw/MultiSrcP.h>
+#ifndef OLDXAW
+#include <X11/Xaw/TextSinkP.h>
+#include <X11/Xaw/AsciiSinkP.h>
+#endif
+#include "Private.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#if (defined(ASCII_STRING) || defined(ASCII_DISK))
+#include <X11/Xaw/AsciiText.h> /* for Widget Classes */
+#endif
+
+#ifdef X_NOT_POSIX
+#define Off_t long
+#define Size_t unsigned int
+#else
+#define Off_t off_t
+#define Size_t size_t
+#endif
+
+#define MAGIC_VALUE ((XawTextPosition)-1)
+#define streq(a, b) (strcmp((a), (b)) == 0)
+
+/*
+ * Class Methods
+ */
+static void XawAsciiSrcClassInitialize(void);
+static void XawAsciiSrcDestroy(Widget);
+static void XawAsciiSrcGetValuesHook(Widget, ArgList, Cardinal*);
+static void XawAsciiSrcInitialize(Widget, Widget, ArgList, Cardinal*);
+static Boolean XawAsciiSrcSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+static XawTextPosition ReadText(Widget, XawTextPosition, XawTextBlock*, int);
+static int ReplaceText(Widget, XawTextPosition, XawTextPosition,
+ XawTextBlock*);
+static XawTextPosition Scan(Widget, XawTextPosition, XawTextScanType,
+ XawTextScanDirection, int, Bool);
+static XawTextPosition Search(Widget, XawTextPosition, XawTextScanDirection,
+ XawTextBlock*);
+
+/*
+ * Prototypes
+ */
+static Piece *AllocNewPiece(AsciiSrcObject, Piece*);
+static void BreakPiece(AsciiSrcObject, Piece*);
+static Boolean CvtAsciiTypeToString(Display*, XrmValuePtr, Cardinal*,
+ XrmValuePtr, XrmValuePtr, XtPointer*);
+static void CvtStringToAsciiType(XrmValuePtr, Cardinal*,
+ XrmValuePtr, XrmValuePtr);
+static Piece *FindPiece(AsciiSrcObject, XawTextPosition, XawTextPosition*);
+static void FreeAllPieces(AsciiSrcObject);
+static FILE *InitStringOrFile(AsciiSrcObject, Bool);
+static void LoadPieces(AsciiSrcObject, FILE*, char*);
+static void RemoveOldStringOrFile(AsciiSrcObject, Bool);
+static void RemovePiece(AsciiSrcObject, Piece*);
+static String StorePiecesInString(AsciiSrcObject);
+static Bool WriteToFile(String, String, unsigned);
+static Bool WritePiecesToFile(AsciiSrcObject, String);
+static void GetDefaultPieceSize(Widget, int, XrmValue*);
+
+/*
+ * More Prototypes
+ */
+#ifdef ASCII_DISK
+Widget XawAsciiDiskSourceCreate(Widget, ArgList, Cardinal);
+#endif
+#ifdef ASCII_STRING
+Widget XawStringSourceCreate(Widget, ArgList, Cardinal);
+void XawTextSetLastPos(Widget, XawTextPosition);
+#endif
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(AsciiSrcRec, ascii_src.field)
+static XtResource resources[] = {
+ {
+ XtNstring,
+ XtCString,
+ XtRString,
+ sizeof(char*),
+ offset(string),
+ XtRString,
+ NULL
+ },
+ {
+ XtNtype,
+ XtCType,
+ XtRAsciiType,
+ sizeof(XawAsciiType),
+ offset(type),
+ XtRImmediate,
+ (XtPointer)XawAsciiString
+ },
+ {
+ XtNdataCompression,
+ XtCDataCompression,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(data_compression),
+ XtRImmediate,
+ (XtPointer)True
+ },
+ {
+ XtNpieceSize,
+ XtCPieceSize,
+ XtRInt,
+ sizeof(XawTextPosition),
+ offset(piece_size),
+ XtRCallProc,
+ (XtPointer)GetDefaultPieceSize
+ },
+#ifdef OLDXAW
+ {
+ XtNcallback,
+ XtCCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(callback),
+ XtRCallback,
+ (XtPointer)NULL
+ },
+#endif
+ {
+ XtNuseStringInPlace,
+ XtCUseStringInPlace,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(use_string_in_place),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNlength,
+ XtCLength,
+ XtRInt,
+ sizeof(int),
+ offset(ascii_length),
+ XtRImmediate,
+ (XtPointer)MAGIC_VALUE
+ },
+#ifdef ASCII_DISK
+ {
+ XtNfile,
+ XtCFile,
+ XtRString,
+ sizeof(String),
+ offset(filename),
+ XtRString,
+ NULL
+ },
+#endif /* ASCII_DISK */
+};
+#undef offset
+
+
+#define Superclass (&textSrcClassRec)
+AsciiSrcClassRec asciiSrcClassRec = {
+ /* object */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "AsciiSrc", /* class_name */
+ sizeof(AsciiSrcRec), /* widget_size */
+ XawAsciiSrcClassInitialize, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ XawAsciiSrcInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ NULL, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ False, /* compress_motion */
+ False, /* compress_exposure */
+ False, /* compress_enterleave */
+ False, /* visible_interest */
+ XawAsciiSrcDestroy, /* destroy */
+ NULL, /* resize */
+ NULL, /* expose */
+ XawAsciiSrcSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ NULL, /* set_values_almost */
+ XawAsciiSrcGetValuesHook, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ NULL, /* query_geometry */
+ NULL, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* text_src */
+ {
+ ReadText, /* Read */
+ ReplaceText, /* Replace */
+ Scan, /* Scan */
+ Search, /* Search */
+ XtInheritSetSelection, /* SetSelection */
+ XtInheritConvertSelection, /* ConvertSelection */
+ },
+ /* ascii_src */
+ {
+ NULL, /* extension */
+ },
+};
+
+WidgetClass asciiSrcObjectClass = (WidgetClass)&asciiSrcClassRec;
+
+static XrmQuark Qstring, Qfile;
+
+/*
+ * Implementation
+ */
+/*
+ * Function:
+ * XawAsciiSrcClassInitialize()
+ *
+ * Description:
+ * Initializes the asciiSrcObjectClass and install the converters for
+ * AsciiType <-> String.
+ */
+static void
+XawAsciiSrcClassInitialize(void)
+{
+ XawInitializeWidgetSet();
+ Qstring = XrmPermStringToQuark(XtEstring);
+ Qfile = XrmPermStringToQuark(XtEfile);
+ XtAddConverter(XtRString, XtRAsciiType, CvtStringToAsciiType, NULL, 0);
+ XtSetTypeConverter(XtRAsciiType, XtRString, CvtAsciiTypeToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+
+/*
+ * Function:
+ * XawAsciiSrcInitialize
+ *
+ * Parameters:
+ * request - widget requested by the argument list
+ * cnew - new widget with both resource and non resource values
+ * args - (unused)
+ * num_args - (unused)
+ *
+ * Description:
+ * Initializes the ascii src object.
+ */
+/*ARGSUSED*/
+static void
+XawAsciiSrcInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ AsciiSrcObject src = (AsciiSrcObject)cnew;
+ FILE *file;
+
+ /*
+ * Set correct flags (override resources) depending upon widget class
+ */
+ src->text_src.text_format = XawFmt8Bit;
+
+#ifdef ASCII_DISK
+ if (XtIsSubclass(XtParent(cnew), asciiDiskWidgetClass)) {
+ src->ascii_src.type = XawAsciiFile;
+ src->ascii_src.string = src->ascii_src.filename;
+ }
+#endif
+
+#ifdef ASCII_STRING
+ if (XtIsSubclass(XtParent(cnew), asciiStringWidgetClass)) {
+ src->ascii_src.use_string_in_place = True;
+ src->ascii_src.type = XawAsciiString;
+ }
+#endif
+
+#ifdef OLDXAW
+ src->ascii_src.changes = False;
+#else
+ src->text_src.changed = False;
+#endif
+ src->ascii_src.allocated_string = False;
+
+ if (src->ascii_src.use_string_in_place && src->ascii_src.string == NULL)
+ src->ascii_src.use_string_in_place = False;
+
+ file = InitStringOrFile(src, src->ascii_src.type == XawAsciiFile);
+ LoadPieces(src, file, NULL);
+
+ if (file != NULL)
+ fclose(file);
+}
+
+/*
+ * Function:
+ * ReadText
+ *
+ * Parameters:
+ * w - AsciiSource widget
+ * pos - position of the text to retreive.
+ * text - text block that will contain returned text
+ * length - maximum number of characters to read
+ *
+ * Description:
+ * This function reads the source.
+ *
+ * Returns:
+ * The character position following the retrieved text.
+ */
+static XawTextPosition
+ReadText(Widget w, XawTextPosition pos, XawTextBlock *text, int length)
+{
+ AsciiSrcObject src = (AsciiSrcObject)w;
+ XawTextPosition count, start;
+ Piece *piece;
+#ifndef OLDXAW
+ XawTextAnchor *anchor;
+ XawTextEntity *entity;
+ XawTextPosition offset, end = pos + length;
+ Bool state;
+
+ end = XawMin(end, src->ascii_src.length);
+ while ((state = XawTextSourceAnchorAndEntity(w, pos, &anchor, &entity)) &&
+ (entity->flags & XAW_TENTF_HIDE))
+ pos = anchor->position + entity->offset + entity->length;
+ if (state == False ||
+ !(entity->flags & XAW_TENTF_REPLACE)) {
+ while (entity) {
+ offset = anchor->position + entity->offset;
+ if (offset >= end)
+ break;
+ if (offset > pos &&
+ (entity->flags & (XAW_TENTF_HIDE | XAW_TENTF_REPLACE))) {
+ end = XawMin(end, offset);
+ break;
+ }
+ if ((entity = entity->next) == NULL &&
+ (anchor = XawTextSourceNextAnchor(w, anchor)) != NULL)
+ entity = anchor->entities;
+ }
+ }
+ else if (state && (entity->flags & XAW_TENTF_REPLACE) && pos < end) {
+ XawTextBlock *block = (XawTextBlock*)entity->data;
+
+ offset = anchor->position + entity->offset;
+ end = XawMin(end, offset + block->length);
+ if ((length = end - pos) < 0)
+ length = 0;
+ text->length = length;
+ text->format = XawFmt8Bit;
+ if (length == 0) {
+ text->firstPos = end = offset + entity->length;
+ text->ptr = "";
+ }
+ else {
+ text->firstPos = pos;
+ text->ptr = block->ptr + (pos - offset);
+ if (pos + length < offset + block->length)
+ end = pos + length; /* there is data left to be read */
+ else
+ end = offset + entity->length;
+ }
+
+ return (end);
+ }
+
+ if ((length = end - pos) < 0)
+ length = 0;
+#endif
+
+ piece = FindPiece(src, pos, &start);
+ text->firstPos = pos;
+ text->ptr = piece->text + (pos - start);
+ count = piece->used - (pos - start);
+ text->length = Max(0, (length > count) ? count : length);
+ text->format = XawFmt8Bit;
+
+ return (pos + text->length);
+}
+
+/*
+ * Function:
+ * ReplaceText
+ *
+ * Parameters:
+ * w - AsciiSource object
+ * startPos - ends of text that will be replaced
+ * endPos - ""
+ * text - new text to be inserted into buffer at startPos
+ *
+ * Description:
+ * Replaces a block of text with new text.
+ *
+ * Returns:
+ * XawEditDone on success, XawEditError otherwise
+ */
+/*ARGSUSED*/
+static int
+ReplaceText(Widget w, XawTextPosition startPos, XawTextPosition endPos,
+ XawTextBlock *text)
+{
+ AsciiSrcObject src = (AsciiSrcObject)w;
+ Piece *start_piece, *end_piece, *temp_piece;
+ XawTextPosition start_first, end_first;
+ int length, firstPos;
+
+ /*
+ * Editing a read only source is not allowed
+ */
+ if (src->text_src.edit_mode == XawtextRead)
+ return (XawEditError);
+
+ start_piece = FindPiece(src, startPos, &start_first);
+ end_piece = FindPiece(src, endPos, &end_first);
+
+#ifndef OLDXAW
+ /*
+ * This is a big hack, but I can't think about a clever way to know
+ * if the character being moved forward has a negative lbearing.
+ *
+ */
+ if (start_piece->used) {
+ int i;
+
+ for (i = 0; i < src->text_src.num_text; i++) {
+ int line;
+ TextWidget ctx = (TextWidget)src->text_src.text[i];
+
+ for (line = 0; line < ctx->text.lt.lines; line++)
+ if (startPos < ctx->text.lt.info[line + 1].position)
+ break;
+ if (i < ctx->text.lt.lines &&
+ startPos > ctx->text.lt.info[i].position) {
+ AsciiSinkObject sink = (AsciiSinkObject)ctx->text.sink;
+ XawTextAnchor *anchor;
+ XawTextEntity *entity;
+ XawTextProperty *property;
+ XFontStruct *font;
+
+ if (XawTextSourceAnchorAndEntity(w, startPos, &anchor, &entity) &&
+ (property = XawTextSinkGetProperty(ctx->text.sink,
+ entity->property)) != NULL &&
+ (property->mask & XAW_TPROP_FONT))
+ font = property->font;
+ else
+ font = sink->ascii_sink.font;
+
+ if (font->min_bounds.lbearing < 0) {
+ int lbearing = font->min_bounds.lbearing;
+ unsigned char c = *(unsigned char*)
+ (start_piece->text + (startPos - start_first));
+
+ if (c == '\t' || c == '\n')
+ c = ' ';
+ else if ((c & 0177) < XawSP || c == 0177) {
+ if (sink->ascii_sink.display_nonprinting)
+ c = c > 0177 ? '\\' : c + '^';
+ else
+ c = ' ';
+ }
+ if (font->per_char &&
+ (c >= font->min_char_or_byte2 && c <= font->max_char_or_byte2))
+ lbearing = font->per_char[c - font->min_char_or_byte2].lbearing;
+ if (lbearing < 0)
+ _XawTextNeedsUpdating(ctx, startPos - 1, startPos);
+ }
+ }
+ }
+ }
+
+
+#endif
+
+ /*
+ * Remove Old Stuff
+ */
+ if (start_piece != end_piece) {
+ temp_piece = start_piece->next;
+
+ /*
+ * If empty and not the only piece then remove it.
+ */
+ if (((start_piece->used = startPos - start_first) == 0)
+ && !(start_piece->next == NULL && start_piece->prev == NULL))
+ RemovePiece(src, start_piece);
+
+ while (temp_piece != end_piece) {
+ temp_piece = temp_piece->next;
+ RemovePiece(src, temp_piece->prev);
+ }
+
+ end_piece->used -= endPos - end_first;
+ if (end_piece->used != 0)
+ memmove(end_piece->text, end_piece->text + endPos - end_first,
+ (unsigned)end_piece->used);
+ }
+ else { /* We are fully in one piece */
+ if ((start_piece->used -= endPos - startPos) == 0) {
+ if (!(start_piece->next == NULL && start_piece->prev == NULL))
+ RemovePiece(src, start_piece);
+ }
+ else {
+ memmove(start_piece->text + (startPos - start_first),
+ start_piece->text + (endPos - start_first),
+ (unsigned)(start_piece->used - (startPos - start_first)));
+ if (src->ascii_src.use_string_in_place
+ && src->ascii_src.length - (endPos - startPos)
+ < src->ascii_src.piece_size - 1)
+ start_piece->text[src->ascii_src.length - (endPos - startPos)] =
+ '\0';
+ }
+ }
+
+ src->ascii_src.length += -(endPos - startPos) + text->length;
+
+ if ( text->length != 0) {
+ /*
+ * Put in the New Stuff
+ */
+ start_piece = FindPiece(src, startPos, &start_first);
+
+ length = text->length;
+ firstPos = text->firstPos;
+
+ while (length > 0) {
+ char *ptr;
+ int fill;
+
+ if (src->ascii_src.use_string_in_place) {
+ if (start_piece->used == src->ascii_src.piece_size - 1) {
+ /*
+ * If we are in ascii string emulation mode. Then the
+ * string is not allowed to grow
+ */
+ start_piece->used = src->ascii_src.length =
+ src->ascii_src.piece_size - 1;
+ start_piece->text[src->ascii_src.length] = '\0';
+ return (XawEditError);
+ }
+ }
+
+ if (start_piece->used == src->ascii_src.piece_size) {
+ BreakPiece(src, start_piece);
+ start_piece = FindPiece(src, startPos, &start_first);
+ }
+
+ fill = Min((int)(src->ascii_src.piece_size - start_piece->used),
+ length);
+
+ ptr = start_piece->text + (startPos - start_first);
+ memmove(ptr + fill, ptr,
+ (unsigned)(start_piece->used - (startPos - start_first)));
+ memcpy(ptr, text->ptr + firstPos, (unsigned)fill);
+
+ startPos += fill;
+ firstPos += fill;
+ start_piece->used += fill;
+ length -= fill;
+ }
+ }
+
+ if (src->ascii_src.use_string_in_place)
+ start_piece->text[start_piece->used] = '\0';
+
+#ifdef OLDXAW
+ src->ascii_src.changes = True;
+ XtCallCallbacks(w, XtNcallback, NULL);
+#endif
+
+ return (XawEditDone);
+}
+
+/*
+ * Function:
+ * Scan
+ *
+ * Parameters:
+ * w - AsciiSource object
+ * position - position to start scanning
+ * type - type of thing to scan for
+ * dir - direction to scan
+ * count - which occurance if this thing to search for.
+ * include - whether or not to include the character found in
+ * the position that is returned
+ *
+ * Description:
+ * Scans the text source for the number and type of item specified.
+ *
+ * Returns:
+ * The position of the item found
+ *
+ * Note:
+ * While there are only 'n' characters in the file there are n+1
+ * possible cursor positions (one before the first character and
+ * one after the last character
+ */
+static XawTextPosition
+Scan(Widget w, register XawTextPosition position, XawTextScanType type,
+ XawTextScanDirection dir, int count, Bool include)
+{
+ AsciiSrcObject src = (AsciiSrcObject)w;
+ Piece *piece;
+ XawTextPosition first, first_eol_position = 0;
+ register char *ptr, *lim;
+ register int cnt = count;
+ register unsigned char c;
+
+ if (dir == XawsdLeft) {
+ if (position <= 0)
+ return (0);
+ --position;
+ }
+ else if (position >= src->ascii_src.length)
+ return (src->ascii_src.length);
+
+ piece = FindPiece(src, position, &first);
+ if (piece->used == 0)
+ return (0);
+
+ ptr = (position - first) + piece->text;
+
+ if (dir == XawsdRight) {
+ lim = piece->text + piece->used;
+ switch (type) {
+ case XawstEOL:
+ case XawstParagraph:
+ case XawstWhiteSpace:
+ case XawstAlphaNumeric:
+ for (; cnt > 0; cnt--) {
+ Bool non_space = False, first_eol = True;
+
+ /*CONSTCOND*/
+ while (True) {
+ if (ptr >= lim) {
+ piece = piece->next;
+ if (piece == NULL) /* End of text */
+ return (src->ascii_src.length);
+ ptr = piece->text;
+ lim = piece->text + piece->used;
+ }
+
+ c = *ptr++;
+ ++position;
+
+ if (type == XawstEOL) {
+ if (c == '\n')
+ break;
+ }
+ else if (type == XawstAlphaNumeric) {
+ if (!isalnum(c)) {
+ if (non_space)
+ break;
+ }
+ else
+ non_space = True;
+ }
+ else if (type == XawstWhiteSpace) {
+ if (isspace(c)) {
+ if (non_space)
+ break;
+ }
+ else
+ non_space = True;
+ }
+ else { /* XawstParagraph */
+ if (first_eol) {
+ if (c == '\n') {
+ first_eol_position = position;
+ first_eol = False;
+ }
+ }
+ else if (c == '\n')
+ break;
+ else if (!isspace(c))
+ first_eol = True;
+ }
+ }
+ }
+ break;
+ case XawstPositions:
+ position += count;
+ return (position < src->ascii_src.length ?
+ position : src->ascii_src.length);
+ case XawstAll:
+ return (src->ascii_src.length);
+ default:
+ break;
+ }
+ if (!include) {
+ if (type == XawstParagraph)
+ position = first_eol_position;
+ if (count)
+ --position;
+ }
+ }
+ else {
+ lim = piece->text;
+ switch (type) {
+ case XawstEOL:
+ case XawstParagraph:
+ case XawstWhiteSpace:
+ case XawstAlphaNumeric:
+ for (; cnt > 0; cnt--) {
+ Bool non_space = False, first_eol = True;
+
+ /*CONSTCOND*/
+ while (True) {
+ if (ptr < lim) {
+ piece = piece->prev;
+ if (piece == NULL) /* Begining of text */
+ return (0);
+ ptr = piece->text + piece->used - 1;
+ lim = piece->text;
+ }
+
+ c = *ptr--;
+ --position;
+
+ if (type == XawstEOL) {
+ if (c == '\n')
+ break;
+ }
+ else if (type == XawstAlphaNumeric) {
+ if (!isalnum(c)) {
+ if (non_space)
+ break;
+ }
+ else
+ non_space = True;
+ }
+ else if (type == XawstWhiteSpace) {
+ if (isspace(c)) {
+ if (non_space)
+ break;
+ }
+ else
+ non_space = True;
+ }
+ else { /* XawstParagraph */
+ if (first_eol) {
+ if (c == '\n') {
+ first_eol_position = position;
+ first_eol = False;
+ }
+ }
+ else if (c == '\n')
+ break;
+ else if (!isspace(c))
+ first_eol = True;
+ }
+ }
+ }
+ break;
+ case XawstPositions:
+ position -= count - 1;
+ return (position > 0 ? position : 0);
+ case XawstAll:
+ return (0);
+ default:
+ break;
+ }
+ if (!include) {
+ if (type == XawstParagraph)
+ position = first_eol_position;
+ if (count)
+ ++position;
+ }
+ position++;
+ }
+
+ return (position);
+}
+
+/*
+ * Function:
+ * Search
+ *
+ * Parameters:
+ * w - AsciiSource object
+ * position - the position to start scanning
+ * dir - direction to scan
+ * text - text block to search for
+ *
+ * Description:
+ * Searchs the text source for the text block passed.
+ *
+ * Returns:
+ * The position of the item found
+ */
+static XawTextPosition
+Search(Widget w, register XawTextPosition position, XawTextScanDirection dir,
+ XawTextBlock *text)
+{
+ AsciiSrcObject src = (AsciiSrcObject)w;
+ register int count = 0;
+ register char *ptr, c;
+ char *str;
+ Piece *piece;
+ char *buf;
+ XawTextPosition first;
+ int cnt, case_sensitive;
+
+ if (dir == XawsdLeft) {
+ if (position == 0)
+ return (XawTextSearchError);
+ position--;
+ }
+
+ buf = XtMalloc((unsigned)sizeof(unsigned char) * text->length);
+ memcpy(buf, text->ptr, (unsigned)text->length);
+ piece = FindPiece(src, position, &first);
+ ptr = (position - first) + piece->text;
+ case_sensitive = text->firstPos;
+
+ if (dir == XawsdRight) {
+ str = buf;
+ c = *str;
+ /*CONSTCOND*/
+ while (1) {
+ if (*ptr++ == c
+ || (case_sensitive && isalpha(c) && isalpha(ptr[-1])
+ && toupper(c) == toupper(ptr[-1]))) {
+ if (++count == text->length)
+ break;
+ c = *++str;
+ }
+ else if (count) {
+ ptr -= count;
+ str -= count;
+ position -= count;
+ count = 0;
+ c = *str;
+
+ if (ptr < piece->text) {
+ do {
+ cnt = piece->text - ptr;
+ piece = piece->prev;
+ if (piece == NULL) {
+ XtFree(buf);
+ return (XawTextSearchError);
+ }
+ ptr = piece->text + piece->used - cnt;
+ } while (ptr < piece->text);
+ }
+ }
+ position++;
+ if (ptr >= (piece->text + piece->used)) {
+ do {
+ cnt = ptr - (piece->text + piece->used);
+ piece = piece->next;
+ if (piece == NULL) {
+ XtFree(buf);
+ return (XawTextSearchError);
+ }
+ ptr = piece->text + cnt;
+ } while (ptr >= (piece->text + piece->used));
+ }
+ }
+
+ position -= text->length - 1;
+ }
+ else {
+ str = buf + text->length - 1;
+ c = *str;
+ /*CONSTCOND*/
+ while (1) {
+ if (*ptr-- == c
+ || (case_sensitive && isalpha(c) && isalpha(ptr[1])
+ && toupper(c) == toupper(ptr[1]))) {
+ if (++count == text->length)
+ break;
+ c = *--str;
+ }
+ else if (count) {
+ ptr += count;
+ str += count;
+ position += count;
+ count = 0;
+ c = *str;
+
+ if (ptr >= (piece->text + piece->used)) {
+ do {
+ cnt = ptr - (piece->text + piece->used);
+ piece = piece->next;
+ if (piece == NULL) {
+ XtFree(buf);
+ return (XawTextSearchError);
+ }
+ ptr = piece->text + cnt;
+ } while (ptr >= (piece->text + piece->used));
+ }
+ }
+ position--;
+ if (ptr < piece->text) {
+ do {
+ cnt = piece->text - ptr;
+ piece = piece->prev;
+ if (piece == NULL) {
+ XtFree(buf);
+ return (XawTextSearchError);
+ }
+ ptr = piece->text + piece->used - cnt;
+ } while (ptr < piece->text);
+ }
+ }
+ }
+
+ XtFree(buf);
+
+ return (position);
+}
+
+/*
+ * Function:
+ * XawAsciiSrcSetValues
+ *
+ * Parameters:
+ * current - current state of the widget
+ * request - what was requested
+ * cnew - what the widget will become
+ * args - representation of changed resources
+ * num_args - number of resources that have changed
+ *
+ * Description:
+ * Sets the values for the AsciiSource.
+ *
+ * Returns:
+ * True if redisplay is needed
+ */
+static Boolean
+XawAsciiSrcSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ AsciiSrcObject src = (AsciiSrcObject)cnew;
+ AsciiSrcObject old_src = (AsciiSrcObject)current;
+ Bool total_reset = False, string_set = False;
+ FILE *file;
+ unsigned int i;
+
+ if (old_src->ascii_src.use_string_in_place
+ != src->ascii_src.use_string_in_place) {
+ XtAppWarning(XtWidgetToApplicationContext(cnew),
+ "AsciiSrc: The XtNuseStringInPlace resource may "
+ "not be changed.");
+ src->ascii_src.use_string_in_place =
+ old_src->ascii_src.use_string_in_place;
+ }
+
+ for (i = 0; i < *num_args ; i++)
+ if (streq(args[i].name, XtNstring)) {
+ string_set = True;
+ break;
+ }
+
+ if (string_set || (old_src->ascii_src.type != src->ascii_src.type)) {
+ RemoveOldStringOrFile(old_src, string_set); /* remove old info */
+ file = InitStringOrFile(src, string_set); /* Init new info */
+ LoadPieces(src, file, NULL); /* load new info into internal buffers */
+ if (file != NULL)
+ fclose(file);
+#ifndef OLDXAW
+ for (i = 0; i < src->text_src.num_text; i++)
+ /* Tell text widget what happened */
+ XawTextSetSource(src->text_src.text[i], cnew, 0);
+#else
+ XawTextSetSource(XtParent(cnew), cnew, 0);
+#endif
+ total_reset = True;
+ }
+
+ if (old_src->ascii_src.ascii_length != src->ascii_src.ascii_length)
+ src->ascii_src.piece_size = src->ascii_src.ascii_length + 1;
+
+ if (!total_reset &&
+ old_src->ascii_src.piece_size != src->ascii_src.piece_size) {
+ String string = StorePiecesInString(old_src);
+
+ FreeAllPieces(old_src);
+ LoadPieces(src, NULL, string);
+ XtFree(string);
+ }
+
+ return (False);
+}
+
+/*
+ * Function:
+ * XawAsciiSrcGetValuesHook
+ *
+ * Parameters:
+ * w - AsciiSource Widget
+ * args - argument list
+ * num_args - number of args
+ *
+ * Description:
+ * This is a get values hook routine that sets the
+ * values specific to the ascii source.
+ */
+static void
+XawAsciiSrcGetValuesHook(Widget w, ArgList args, Cardinal *num_args)
+{
+ AsciiSrcObject src = (AsciiSrcObject)w;
+ unsigned int i;
+
+ if (src->ascii_src.type == XawAsciiString) {
+ for (i = 0; i < *num_args ; i++)
+ if (streq(args[i].name, XtNstring)) {
+ if (src->ascii_src.use_string_in_place)
+ *((char **)args[i].value) = src->ascii_src.first_piece->text;
+ else if (XawAsciiSave(w)) /* If save sucessful */
+ *((char **)args[i].value) = src->ascii_src.string;
+ break;
+ }
+ }
+ }
+
+/*
+ * Function:
+ * XawAsciiSrcDestroy
+ *
+ * Parameters:
+ * src - Ascii source object to free
+ *
+ * Description:
+ * Destroys an ascii source (frees all data)
+ */
+static void
+XawAsciiSrcDestroy(Widget w)
+{
+ RemoveOldStringOrFile((AsciiSrcObject) w, True);
+}
+
+/*
+ * Public routines
+ */
+/*
+ * Function:
+ * XawAsciiSourceFreeString
+ *
+ * Parameters:
+ * w - AsciiSrc widget
+ *
+ * Description:
+ * Frees the string returned by a get values call
+ * on the string when the source is of type string.
+ */
+void
+XawAsciiSourceFreeString(Widget w)
+{
+ AsciiSrcObject src = (AsciiSrcObject)w;
+
+ /* If the src is really a multi, call the multi routine */
+ if (XtIsSubclass(w, multiSrcObjectClass)) {
+ _XawMultiSourceFreeString(w);
+ return;
+ }
+ else if (!XtIsSubclass(w, asciiSrcObjectClass)) {
+ XtErrorMsg("bad argument", "asciiSource", "XawError",
+ "XawAsciiSourceFreeString's parameter must be "
+ "an asciiSrc or multiSrc.",
+ NULL, NULL);
+ }
+
+ if (src->ascii_src.allocated_string && src->ascii_src.type != XawAsciiFile) {
+ src->ascii_src.allocated_string = False;
+ XtFree(src->ascii_src.string);
+ src->ascii_src.string = NULL;
+ }
+}
+
+/*
+ * Function:
+ * XawAsciiSave
+ *
+ * Parameters:
+ * w - asciiSrc Widget
+ *
+ * Description:
+ * Saves all the pieces into a file or string as required.
+ *
+ * Returns:
+ * True if the save was successful
+ */
+Bool
+XawAsciiSave(Widget w)
+{
+ AsciiSrcObject src = (AsciiSrcObject)w;
+
+ /* If the src is really a multi, call the multi save */
+ if (XtIsSubclass(w, multiSrcObjectClass ))
+ return (_XawMultiSave(w));
+
+ else if (!XtIsSubclass(w, asciiSrcObjectClass))
+ XtErrorMsg("bad argument", "asciiSource", "XawError",
+ "XawAsciiSave's parameter must be an asciiSrc or multiSrc.",
+ NULL, NULL);
+
+ /*
+ * If using the string in place then there is no need to play games
+ * to get the internal info into a readable string.
+ */
+ if (src->ascii_src.use_string_in_place)
+ return (True);
+
+ if (src->ascii_src.type == XawAsciiFile) {
+#ifdef OLDXAW
+ if (!src->ascii_src.changes)
+#else
+ if (!src->text_src.changed) /* No changes to save */
+#endif
+ return (True);
+
+ if (WritePiecesToFile(src, src->ascii_src.string) == False)
+ return (False);
+ }
+ else {
+ if (src->ascii_src.allocated_string == True)
+ XtFree(src->ascii_src.string);
+ else
+ src->ascii_src.allocated_string = True;
+
+ src->ascii_src.string = StorePiecesInString(src);
+ }
+#ifdef OLDXAW
+ src->ascii_src.changes = False;
+#else
+ src->text_src.changed = False;
+#endif
+
+ return (True);
+}
+
+/*
+ * Function:
+ * XawAsciiSaveAsFile
+ *
+ * Arguments:
+ * w - AsciiSrc widget
+ * name - name of the file to save this file into
+ *
+ * Description:
+ * Save the current buffer as a file.
+ *
+ * Returns:
+ * True if the save was sucessful
+ */
+Bool
+XawAsciiSaveAsFile(Widget w, _Xconst char *name)
+{
+ AsciiSrcObject src = (AsciiSrcObject)w;
+ Bool ret;
+
+ /* If the src is really a multi, call the multi save */
+
+ if (XtIsSubclass( w, multiSrcObjectClass))
+ return (_XawMultiSaveAsFile(w, name));
+
+ else if (!XtIsSubclass(w, asciiSrcObjectClass))
+ XtErrorMsg("bad argument", "asciiSource", "XawError",
+ "XawAsciiSaveAsFile's 1st parameter must be an "
+ "asciiSrc or multiSrc.",
+ NULL, NULL);
+
+ if (src->ascii_src.type == XawAsciiFile)
+ ret = WritePiecesToFile(src, (String)name);
+ else {
+ String string = StorePiecesInString(src);
+
+ ret = WriteToFile(string, (String)name, src->ascii_src.length);
+ XtFree(string);
+ }
+
+ return (ret);
+}
+
+/*
+ * Function:
+ * XawAsciiSourceChanged
+ *
+ * Parameters:
+ * w - ascii source widget
+ *
+ * Description:
+ * Returns true if the source has changed since last saved.
+ *
+ * Returns:
+ * A Boolean (see description).
+ */
+Bool
+XawAsciiSourceChanged(Widget w)
+{
+#ifdef OLDXAW
+ if (XtIsSubclass(w, multiSrcObjectClass))
+ return (((MultiSrcObject)w)->multi_src.changes);
+
+ if (XtIsSubclass(w, asciiSrcObjectClass))
+ return (((AsciiSrcObject)w)->ascii_src.changes);
+#else
+ if (XtIsSubclass(w, textSrcObjectClass))
+ return (((TextSrcObject)w)->textSrc.changed);
+#endif
+ XtErrorMsg("bad argument", "asciiSource", "XawError",
+ "XawAsciiSourceChanged parameter must be an "
+ "asciiSrc or multiSrc.",
+ NULL, NULL);
+
+ return (True);
+}
+
+/*
+ * Private Functions
+ */
+static void
+RemoveOldStringOrFile(AsciiSrcObject src, Bool checkString)
+{
+ FreeAllPieces(src);
+
+ if (checkString && src->ascii_src.allocated_string) {
+ XtFree(src->ascii_src.string);
+ src->ascii_src.allocated_string = False;
+ src->ascii_src.string = NULL;
+ }
+}
+
+/*
+ * Function:
+ * WriteToFile
+ *
+ * Parameters:
+ * string - string to write
+ * name - the name of the file
+ *
+ * Description:
+ * Write the string specified to the begining of the file specified.
+ *
+ * Returns:
+ * returns True if sucessful, False otherwise
+ */
+static Bool
+WriteToFile(String string, String name, unsigned length)
+{
+ int fd;
+
+ if ((fd = creat(name, 0666)) == -1
+ || write(fd, string, length) == -1)
+ return (False);
+
+ if (close(fd) == -1)
+ return (False);
+
+ return (True);
+}
+
+/*
+ * Function:
+ * WritePiecesToFile
+ *
+ * Parameters:
+ * src - ascii source object
+ * name - name of the file
+ *
+ * Description:
+ * Almost identical to WriteToFile, but only works for ascii src objects
+ * of type XawAsciiFile. This function avoids allocating temporary memory,
+ * what can be useful when editing very large files.
+ *
+ * Returns:
+ * returns True if sucessful, False otherwise
+ */
+static Bool
+WritePiecesToFile(AsciiSrcObject src, String name)
+{
+ Piece *piece;
+ int fd;
+
+ if (src->ascii_src.data_compression) {
+ Piece *tmp;
+
+ piece = src->ascii_src.first_piece;
+ while (piece) {
+ int bytes = src->ascii_src.piece_size - piece->used;
+
+ if (bytes > 0 && (tmp = piece->next) != NULL) {
+ bytes = XawMin(bytes, tmp->used);
+ memcpy(piece->text + piece->used, tmp->text, bytes);
+ memmove(tmp->text, tmp->text + bytes, tmp->used - bytes);
+ piece->used += bytes;
+ if ((tmp->used -= bytes) == 0) {
+ RemovePiece(src, tmp);
+ continue;
+ }
+ }
+ piece = piece->next;
+ }
+ }
+
+ if ((fd = creat(name, 0666)) == -1)
+ return (False);
+
+ for (piece = src->ascii_src.first_piece; piece; piece = piece->next)
+ if (write(fd, piece->text, piece->used) == -1)
+ return (False);
+
+ if (close(fd) == -1)
+ return (False);
+
+ return (True);
+}
+
+/*
+ * Function:
+ * StorePiecesInString
+ *
+ * Parameters:
+ * data - ascii pointer data
+ *
+ * Description:
+ * Store the pieces in memory into a standard ascii string.
+ */
+static String
+StorePiecesInString(AsciiSrcObject src)
+{
+ String string;
+ XawTextPosition first;
+ Piece *piece;
+
+ string = XtMalloc((unsigned)(src->ascii_src.length + 1));
+
+ for (first = 0, piece = src->ascii_src.first_piece ; piece != NULL;
+ first += piece->used, piece = piece->next)
+ memcpy(string + first, piece->text, (unsigned)piece->used);
+
+ string[src->ascii_src.length] = '\0';
+
+ /*
+ * This will refill all pieces to capacity
+ */
+ if (src->ascii_src.data_compression) {
+ FreeAllPieces(src);
+ LoadPieces(src, NULL, string);
+ }
+
+ return (string);
+}
+
+/*
+ * Function:
+ * InitStringOrFile
+ *
+ * Parameters:
+ * src - AsciiSource
+ *
+ * Description:
+ * Initializes the string or file.
+ */
+static FILE *
+InitStringOrFile(AsciiSrcObject src, Bool newString)
+{
+ mode_t open_mode = 0;
+ const char *fdopen_mode = NULL;
+ int fd;
+ FILE *file;
+
+ if (src->ascii_src.type == XawAsciiString) {
+ if (src->ascii_src.string == NULL)
+ src->ascii_src.length = 0;
+
+ else if (!src->ascii_src.use_string_in_place) {
+ src->ascii_src.string = XtNewString(src->ascii_src.string);
+ src->ascii_src.allocated_string = True;
+ src->ascii_src.length = strlen(src->ascii_src.string);
+ }
+
+ if (src->ascii_src.use_string_in_place) {
+ if (src->ascii_src.string != NULL)
+ src->ascii_src.length = strlen(src->ascii_src.string);
+ /* In case the length resource is incorrectly set */
+ if (src->ascii_src.length > src->ascii_src.ascii_length)
+ src->ascii_src.ascii_length = src->ascii_src.length;
+
+ if (src->ascii_src.ascii_length == MAGIC_VALUE)
+ src->ascii_src.piece_size = src->ascii_src.length;
+ else
+ src->ascii_src.piece_size = src->ascii_src.ascii_length + 1;
+ }
+
+ return (NULL);
+ }
+
+ /*
+ * type is XawAsciiFile
+ */
+ src->ascii_src.is_tempfile = False;
+
+ switch (src->text_src.edit_mode) {
+ case XawtextRead:
+ if (src->ascii_src.string == NULL)
+ XtErrorMsg("NoFile", "asciiSourceCreate", "XawError",
+ "Creating a read only disk widget and no file specified.",
+ NULL, 0);
+ open_mode = O_RDONLY;
+ fdopen_mode = "r";
+ break;
+ case XawtextAppend:
+ case XawtextEdit:
+ if (src->ascii_src.string == NULL) {
+ src->ascii_src.string = "*ascii-src*";
+ src->ascii_src.is_tempfile = True;
+ }
+ else {
+/* O_NOFOLLOW is a FreeBSD & Linux extension */
+#ifdef O_NOFOLLOW
+ open_mode = O_RDWR | O_NOFOLLOW;
+#else
+ open_mode = O_RDWR; /* unsafe; subject to race conditions */
+#endif /* O_NOFOLLOW */
+ fdopen_mode = "r+";
+ }
+ break;
+ default:
+ XtErrorMsg("badMode", "asciiSourceCreate", "XawError",
+ "Bad editMode for ascii source; must be Read, "
+ "Append or Edit.",
+ NULL, NULL);
+ }
+
+ /* If is_tempfile, allocate a private copy of the text
+ * Unlikely to be changed, just to set allocated_string */
+ if (newString || src->ascii_src.is_tempfile) {
+ src->ascii_src.string = XtNewString(src->ascii_src.string);
+ src->ascii_src.allocated_string = True;
+ }
+
+ if (!src->ascii_src.is_tempfile) {
+ if ((fd = open(src->ascii_src.string, open_mode, 0666)) != -1) {
+ if ((file = fdopen(fd, fdopen_mode))) {
+ (void)fseek(file, 0, SEEK_END);
+ src->ascii_src.length = (XawTextPosition)ftell(file);
+ return (file);
+ }
+ }
+ {
+ String params[2];
+ Cardinal num_params = 2;
+
+ params[0] = src->ascii_src.string;
+ params[1] = strerror(errno);
+ XtAppWarningMsg(XtWidgetToApplicationContext((Widget)src),
+ "openError", "asciiSourceCreate", "XawWarning",
+ "Cannot open file %s; %s", params, &num_params);
+ }
+ }
+ src->ascii_src.length = 0;
+ return (NULL);
+}
+
+static void
+LoadPieces(AsciiSrcObject src, FILE *file, char *string)
+{
+ char *ptr;
+ Piece *piece = NULL;
+ XawTextPosition left;
+
+ if (string == NULL) {
+ if (src->ascii_src.type == XawAsciiFile) {
+ if (src->ascii_src.length != 0) {
+ int len;
+
+ left = 0;
+ fseek(file, 0, 0);
+ while (left < src->ascii_src.length) {
+ ptr = XtMalloc((unsigned)src->ascii_src.piece_size);
+ if ((len = fread(ptr, (Size_t)sizeof(unsigned char),
+ (Size_t)src->ascii_src.piece_size, file)) < 0)
+ XtErrorMsg("readError", "asciiSourceCreate", "XawError",
+ "fread returned error.", NULL, NULL);
+ piece = AllocNewPiece(src, piece);
+ piece->text = ptr;
+ piece->used = XawMin(len, src->ascii_src.piece_size);
+ left += piece->used;
+ }
+ }
+ else {
+ piece = AllocNewPiece(src, NULL);
+ piece->text = XtMalloc((unsigned)src->ascii_src.piece_size);
+ piece->used = 0;
+ }
+ return;
+ }
+ else
+ string = src->ascii_src.string;
+ }
+
+ if (src->ascii_src.use_string_in_place) {
+ piece = AllocNewPiece(src, piece);
+ piece->used = XawMin(src->ascii_src.length, src->ascii_src.piece_size);
+ piece->text = src->ascii_src.string;
+ return;
+ }
+
+ ptr = string;
+ left = src->ascii_src.length;
+ do {
+ piece = AllocNewPiece(src, piece);
+
+ piece->text = XtMalloc((unsigned)src->ascii_src.piece_size);
+ piece->used = XawMin(left, src->ascii_src.piece_size);
+ if (piece->used != 0)
+ memcpy(piece->text, ptr, (unsigned)piece->used);
+
+ left -= piece->used;
+ ptr += piece->used;
+ } while (left > 0);
+}
+
+/*
+ * Function:
+ * AllocNewPiece
+ *
+ * Parameters:
+ * src - AsciiSrc Widget
+ * prev - piece just before this one, or NULL
+ *
+ * Description:
+ * Allocates a new piece of memory.
+ *
+ * Returns:
+ * The allocated piece
+ */
+static Piece *
+AllocNewPiece(AsciiSrcObject src, Piece *prev)
+{
+ Piece *piece = XtNew(Piece);
+
+ if (prev == NULL) {
+ src->ascii_src.first_piece = piece;
+ piece->next = NULL;
+ }
+ else {
+ if (prev->next != NULL)
+ (prev->next)->prev = piece;
+ piece->next = prev->next;
+ prev->next = piece;
+ }
+
+ piece->prev = prev;
+
+ return (piece);
+}
+
+/*
+ * Function:
+ * FreeAllPieces
+ *
+ * Parameters:
+ * src - AsciiSrc Widget
+ *
+ * Description:
+ * Frees all the pieces.
+ */
+static void
+FreeAllPieces(AsciiSrcObject src)
+{
+ Piece *next, * first = src->ascii_src.first_piece;
+
+#ifdef DEBUG
+ if (first->prev != NULL)
+ printf("Xaw AsciiSrc Object: possible memory leak in FreeAllPieces().\n");
+#endif
+
+ for (; first != NULL ; first = next) {
+ next = first->next;
+ RemovePiece(src, first);
+ }
+}
+
+/*
+ * Function:
+ * RemovePiece
+ *
+ * Parameters:
+ * piece - piece to remove
+ *
+ * Description:
+ * Removes a piece from the list.
+ */
+static void
+RemovePiece(AsciiSrcObject src, Piece *piece)
+{
+ if (piece->prev == NULL)
+ src->ascii_src.first_piece = piece->next;
+ else
+ piece->prev->next = piece->next;
+
+ if (piece->next != NULL)
+ piece->next->prev = piece->prev;
+
+ if (!src->ascii_src.use_string_in_place)
+ XtFree(piece->text);
+
+ XtFree((char *)piece);
+}
+
+/*
+ * Function:
+ * FindPiece
+ *
+ * Parameters:
+ * src - AsciiSrc Widget
+ * position - position that we are searching for
+ * first - position of the first character in this piece (return)
+ *
+ * Description:
+ * Finds the piece containing the position indicated.
+ *
+ * Returns:
+ * the piece that contains this position
+ */
+static Piece *
+FindPiece(AsciiSrcObject src, XawTextPosition position, XawTextPosition *first)
+{
+ Piece *old_piece, *piece;
+ XawTextPosition temp;
+
+ for (old_piece = NULL, piece = src->ascii_src.first_piece, temp = 0;
+ piece; old_piece = piece, piece = piece->next)
+ if ((temp += piece->used) > position) {
+ *first = temp - piece->used;
+ return (piece);
+ }
+
+ *first = temp - (old_piece ? old_piece->used : 0);
+
+ return (old_piece); /* if we run off the end the return the last piece */
+}
+
+/*
+ * Function:
+ * BreakPiece
+ *
+ * Parameters:
+ * src - AsciiSrc Widget
+ * piece - piece to break
+ *
+ * Description:
+ * Breaks a full piece into two new pieces.
+ */
+#define HALF_PIECE (src->ascii_src.piece_size >> 1)
+static void
+BreakPiece(AsciiSrcObject src, Piece *piece)
+{
+ Piece *cnew = AllocNewPiece(src, piece);
+
+ cnew->text = XtMalloc((unsigned)src->ascii_src.piece_size);
+ memcpy(cnew->text, piece->text + HALF_PIECE,
+ (unsigned)(src->ascii_src.piece_size - HALF_PIECE));
+ piece->used = HALF_PIECE;
+ cnew->used = src->ascii_src.piece_size - HALF_PIECE;
+}
+
+/*ARGSUSED*/
+static void
+CvtStringToAsciiType(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static XawAsciiType type;
+ XrmQuark q;
+ char name[7];
+
+ XmuNCopyISOLatin1Lowered(name, (char *)fromVal->addr, sizeof(name));
+ q = XrmStringToQuark(name);
+
+ if (q == Qstring)
+ type = XawAsciiString;
+ else if (q == Qfile)
+ type = XawAsciiFile;
+ else {
+ toVal->size = 0;
+ toVal->addr = NULL;
+ XtStringConversionWarning((char *)fromVal->addr, XtRAsciiType);
+ }
+
+ toVal->size = sizeof(XawAsciiType);
+ toVal->addr = (XPointer)&type;
+}
+
+/*ARGSUSED*/
+static Boolean
+CvtAsciiTypeToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal,
+ XtPointer *data)
+{
+ static String buffer;
+ Cardinal size;
+
+ switch (*(XawAsciiType *)fromVal->addr) {
+ case XawAsciiFile:
+ buffer = XtEfile;
+ break;
+ case XawAsciiString:
+ buffer = XtEstring;
+ break;
+ default:
+ XawTypeToStringWarning(dpy, XtRAsciiType);
+ toVal->addr = NULL;
+ toVal->size = 0;
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL) {
+ if (toVal->size < size) {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
+
+/*ARGSUSED*/
+static void
+GetDefaultPieceSize(Widget w, int offset, XrmValue *value)
+{
+ static XPointer pagesize;
+
+ if (pagesize == 0) {
+ pagesize = (XPointer)((long)_XawGetPageSize());
+ if (pagesize < (XPointer)BUFSIZ)
+ pagesize = (XPointer)BUFSIZ;
+ }
+
+ value->addr = (XPointer)&pagesize;
+}
+
+#if (defined(ASCII_STRING) || defined(ASCII_DISK))
+# include <X11/Xaw/Cardinals.h>
+#endif
+
+#ifdef ASCII_STRING
+/*
+ * Compatability functions.
+ */
+/*
+ * Function:
+ * AsciiStringSourceCreate
+ *
+ * Parameters:
+ * parent - widget that will own this source
+ * args - the argument list
+ * num_args - ""
+ *
+ * Description:
+ * Creates a string source.
+ *
+ * Returns:
+ * A pointer to the new text source.
+ */
+Widget
+XawStringSourceCreate(Widget parent, ArgList args, Cardinal num_args)
+{
+ XawTextSource src;
+ ArgList ascii_args;
+ Arg temp[2];
+
+ XtSetArg(temp[0], XtNtype, XawAsciiString);
+ XtSetArg(temp[1], XtNuseStringInPlace, True);
+ ascii_args = XtMergeArgLists(temp, TWO, args, num_args);
+
+ src = XtCreateWidget("genericAsciiString", asciiSrcObjectClass, parent,
+ ascii_args, num_args + TWO);
+ XtFree((char *)ascii_args);
+
+ return (src);
+}
+
+/*
+ * This is hacked up to try to emulate old functionality, it
+ * may not work, as I have not old code to test it on.
+ *
+ * Chris D. Peterson 8/31/89.
+ */
+void
+XawTextSetLastPos(Widget w, XawTextPosition lastPos)
+{
+ AsciiSrcObject src = (AsciiSrcObject)XawTextGetSource(w);
+
+ src->ascii_src.piece_size = lastPos;
+}
+#endif /* ASCII_STRING */
+
+#ifdef ASCII_DISK
+/*
+ * Function:
+ * AsciiDiskSourceCreate
+ *
+ * Parameters:
+ * parent - widget that will own this source
+ * args - argument list
+ * num_args - ""
+ *
+ * Description:
+ * Creates a disk source.
+ *
+ * Returns:
+ * A pointer to the new text source
+ */
+Widget
+XawDiskSourceCreate(Widget parent, ArgList args, Cardinal num_args)
+{
+ XawTextSource src;
+ ArgList ascii_args;
+ Arg temp[1];
+ int i;
+
+ XtSetArg(temp[0], XtNtype, XawAsciiFile);
+ ascii_args = XtMergeArgLists(temp, ONE, args, num_args);
+ num_args++;
+
+ for (i = 0; i < num_args; i++)
+ if (streq(ascii_args[i].name, XtNfile)
+ || streq(ascii_args[i].name, XtCFile))
+ ascii_args[i].name = XtNstring;
+
+ src = XtCreateWidget("genericAsciiDisk", asciiSrcObjectClass, parent,
+ ascii_args, num_args);
+ XtFree((char *)ascii_args);
+
+ return (src);
+}
+#endif /* ASCII_DISK */
diff --git a/nx-X11/lib/Xaw/AsciiSrc.h b/nx-X11/lib/Xaw/AsciiSrc.h
new file mode 100644
index 000000000..8728dd9ea
--- /dev/null
+++ b/nx-X11/lib/Xaw/AsciiSrc.h
@@ -0,0 +1,175 @@
+/* $Xorg: AsciiSrc.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xaw/AsciiSrc.h,v 1.7 2001/01/17 19:42:25 dawes Exp $ */
+
+
+/*
+ * AsciiSrc.h - Public Header file for Ascii Text Source.
+ *
+ * This is the public header file for the Ascii Text Source.
+ * It is intended to be used with the Text widget, the simplest way to use
+ * this text source is to use the AsciiText Object.
+ *
+ * Date: June 29, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+
+#ifndef _XawAsciiSrc_h
+#define _XawAsciiSrc_h
+
+#include <X11/Xaw/TextSrc.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ dataCompression DataCompression Boolean True
+ length Length int (internal)
+ pieceSize PieceSize int BUFSIZ
+ string String String NULL
+ type Type XawAsciiType XawAsciiString
+ useStringInPlace UseStringInPlace Boolean False
+
+*/
+
+extern WidgetClass asciiSrcObjectClass;
+
+typedef struct _AsciiSrcClassRec *AsciiSrcObjectClass;
+typedef struct _AsciiSrcRec *AsciiSrcObject;
+
+#define AsciiSourceObjectClass AsciiSrcObjectClass
+#define AsciiSourceObject AsciiSrcObject
+
+/*
+ * Resource Definitions
+ */
+#define XtCDataCompression "DataCompression"
+#define XtCPieceSize "PieceSize"
+#define XtCType "Type"
+#define XtCUseStringInPlace "UseStringInPlace"
+
+#define XtNdataCompression "dataCompression"
+#define XtNpieceSize "pieceSize"
+#define XtNtype "type"
+#define XtNuseStringInPlace "useStringInPlace"
+
+#define XtRAsciiType "AsciiType"
+
+#define XtEstring "string"
+#define XtEfile "file"
+
+typedef enum {
+ XawAsciiFile,
+ XawAsciiString
+} XawAsciiType;
+
+/*
+ * Public routines
+ */
+
+_XFUNCPROTOBEGIN
+
+/*
+ * Function:
+ * XawAsciiSourceFreeString
+ *
+ * Parameters:
+ * w - AsciiSrc object
+ *
+ * Description:
+ * Frees the string returned by a get values call
+ * on the string when the source is of type string.
+ */
+void XawAsciiSourceFreeString
+(
+ Widget w
+ );
+
+/*
+ * Function:
+ * XawAsciiSave
+ *
+ * Arguments:
+ * w - asciiSrc Object.
+ *
+ * Description:
+ * Saves all the pieces into a file or string as required.
+ *
+ * Returns:
+ * True if the save was successful
+ */
+Bool XawAsciiSave
+(
+ Widget w
+ );
+
+/*
+ * Function:
+ * XawAsciiSaveAsFile
+ *
+ * Parameters:
+ * w - asciiSrc object
+ * name - name of the file to save this file into
+ *
+ * Description:
+ * Save the current buffer as a file.
+ *
+ * Returns:
+ * True if the save was successful
+ */
+Bool XawAsciiSaveAsFile
+(
+ Widget w,
+ _Xconst char *name
+ );
+
+/*
+ * Function:
+ * XawAsciiSourceChanged
+ *
+ * Parameters:
+ * w - asciiSource object
+ *
+ * Description:
+ * Returns true if the source has changed since last saved.
+ *
+ * Returns:
+ * a Boolean (see description)
+ */
+Bool XawAsciiSourceChanged
+(
+ Widget w
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XawAsciiSrc_h */
diff --git a/nx-X11/lib/Xaw/AsciiSrcP.h b/nx-X11/lib/Xaw/AsciiSrcP.h
new file mode 100644
index 000000000..22d30082a
--- /dev/null
+++ b/nx-X11/lib/Xaw/AsciiSrcP.h
@@ -0,0 +1,145 @@
+/*
+* $Xorg: AsciiSrcP.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/AsciiSrcP.h,v 1.8 2001/01/17 19:42:25 dawes Exp $ */
+
+/*
+ * AsciiSrcP.h - Private Header for Ascii Text Source.
+ *
+ * This is the private header file for the Ascii Text Source.
+ * It is intended to be used with the Text widget, the simplest way to use
+ * this text source is to use the AsciiText Object.
+ *
+ * Date: June 29, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _XawAsciiSrcP_h
+#define _XawAsciiSrcP_h
+
+#include <X11/Xaw/TextSrcP.h>
+#include <X11/Xaw/AsciiSrc.h>
+
+#ifdef L_tmpnam
+#define TMPSIZ L_tmpnam
+#else
+#ifdef PATH_MAX
+#define TMPSIZ PATH_MAX
+#else
+#define TMPSIZ 1024 /* bytes to allocate for tmpnam */
+#endif
+#endif
+
+typedef struct _Piece { /* Piece of the text file of BUFSIZ allocated
+ characters */
+ char *text; /* The text in this buffer */
+ XawTextPosition used; /* The number of characters of this buffer
+ that have been used */
+ struct _Piece *prev, *next; /* linked list pointers */
+} Piece;
+
+typedef struct _AsciiSrcClassPart {
+ XtPointer extension;
+} AsciiSrcClassPart;
+
+/* Full class record */
+typedef struct _AsciiSrcClassRec {
+ ObjectClassPart object_class;
+ TextSrcClassPart text_src_class;
+ AsciiSrcClassPart ascii_src_class;
+} AsciiSrcClassRec;
+
+extern AsciiSrcClassRec asciiSrcClassRec;
+
+/* New fields for the AsciiSrc object */
+typedef struct _AsciiSrcPart {
+ /* resources */
+ char *string; /* either the string, or the
+ file name, depending upon the type */
+ XawAsciiType type; /* either string or disk */
+ XawTextPosition piece_size; /* Size of text buffer for each piece */
+ Boolean data_compression; /* compress to minimum memory automatically
+ on save? */
+#ifdef OLDXAW
+ XtCallbackList callback;
+#endif
+ Boolean use_string_in_place;/* Use the string passed in place */
+ int ascii_length; /* length field for ascii string emulation */
+
+#ifdef ASCII_DISK
+ String filename; /* name of file for Compatability */
+#endif /* ASCII_DISK */
+
+ /* private */
+ Boolean is_tempfile; /* Is this a temporary file? */
+#ifdef OLDXAW
+ Boolean changes;
+#endif
+ Boolean allocated_string; /* Have I allocated the
+ string in ascii_src->string? */
+ XawTextPosition length; /* length of file */
+ Piece *first_piece; /* first piece of the text */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} AsciiSrcPart;
+
+/* instance record */
+typedef struct _AsciiSrcRec {
+ ObjectPart object;
+ TextSrcPart text_src;
+ AsciiSrcPart ascii_src;
+} AsciiSrcRec;
+
+#endif /* _XawAsciiSrcP_h */
diff --git a/nx-X11/lib/Xaw/AsciiText.c b/nx-X11/lib/Xaw/AsciiText.c
new file mode 100644
index 000000000..7305100f6
--- /dev/null
+++ b/nx-X11/lib/Xaw/AsciiText.c
@@ -0,0 +1,360 @@
+/* $Xorg: AsciiText.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xaw/AsciiText.c,v 3.9 2001/01/17 19:42:25 dawes Exp $ */
+
+/*
+ * AsciiText.c - Source code for AsciiText Widget
+ *
+ * This Widget is intended to be used as a simple front end to the
+ * text widget with an ascii source and ascii sink attached to it
+ *
+ * Date: June 29, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/AsciiTextP.h>
+#include <X11/Xaw/AsciiSrcP.h>
+#include <X11/Xaw/AsciiSink.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xaw/MultiSinkP.h>
+#include <X11/Xaw/MultiSrc.h>
+#include <X11/Xaw/XawImP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+#define TAB_COUNT 32
+
+/*
+ * Class Methods
+ */
+static void XawAsciiInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawAsciiDestroy(Widget);
+
+/*
+ * From TextSrc.c
+ */
+void _XawSourceAddText(Widget, Widget);
+void _XawSourceRemoveText(Widget, Widget, Bool);
+
+#define Superclass (&textClassRec)
+AsciiTextClassRec asciiTextClassRec = {
+ /* core */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "Text", /* class_name */
+ sizeof(AsciiRec), /* widget_size */
+ XawInitializeWidgetSet, /* class_initialize */
+ NULL, /* class_part_init */
+ False, /* class_inited */
+ XawAsciiInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ NULL, /* resources */
+ 0, /* num_resource */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ XtExposeGraphicsExpose | /* compress_exposure */
+ XtExposeNoExpose,
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ XawAsciiDestroy, /* destroy */
+ XtInheritResize, /* resize */
+ XtInheritExpose, /* expose */
+ NULL, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ XtInheritAcceptFocus, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ XtInheritTranslations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ },
+ /* simple */
+ {
+ XtInheritChangeSensitive, /* change_sensitive */
+ },
+ /* text */
+ {
+ NULL, /* extension */
+ },
+ /* ascii */
+ {
+ NULL, /* extension */
+ },
+};
+
+WidgetClass asciiTextWidgetClass = (WidgetClass)&asciiTextClassRec;
+
+#ifdef ASCII_STRING
+AsciiStringClassRec asciiStringClassRec = {
+ /* core */
+ {
+ (WidgetClass)&asciiTextClassRec, /* superclass */
+ "Text", /* class_name */
+ sizeof(AsciiStringRec), /* widget_size */
+ NULL, /* class_initialize */
+ NULL, /* class_part_init */
+ False, /* class_inited */
+ NULL, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ NULL, /* resources */
+ 0, /* num_resource */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ XtExposeGraphicsExpose | /* compress_exposure */
+ XtExposeNoExpose,
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ NULL, /* destroy */
+ XtInheritResize, /* resize */
+ XtInheritExpose, /* expose */
+ NULL, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ XtInheritAcceptFocus, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ XtInheritTranslations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ },
+ /* simple */
+ {
+ XtInheritChangeSensitive, /* change_sensitive */
+ },
+ /* text */
+ {
+ NULL, /* extension */
+ },
+ /* ascii */
+ {
+ NULL, /* extension */
+ },
+ /* string */
+ {
+ NULL, /* extension */
+ },
+};
+
+WidgetClass asciiStringWidgetClass = (WidgetClass)&asciiStringClassRec;
+#endif /* ASCII_STRING */
+
+#ifdef ASCII_DISK
+AsciiDiskClassRec asciiDiskClassRec = {
+ /* core */
+ {
+ (WidgetClass)&asciiTextClassRec, /* superclass */
+ "Text", /* class_name */
+ sizeof(AsciiDiskRec), /* widget_size */
+ NULL, /* class_initialize */
+ NULL, /* class_part_init */
+ False, /* class_inited */
+ NULL, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ NULL, /* resources */
+ 0, /* num_resource */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ XtExposeGraphicsExpose | /* compress_enterleave */
+ XtExposeNoExpose,
+ False, /* visible_interest */
+ NULL, /* destroy */
+ XtInheritResize, /* resize */
+ XtInheritExpose, /* expose */
+ NULL, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ XtInheritAcceptFocus, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ XtInheritTranslations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ },
+ /* simple */
+ {
+ XtInheritChangeSensitive, /* change_sensitive */
+ },
+ /* text */
+ {
+ NULL, /* extension */
+ },
+ /* ascii */
+ {
+ NULL, /* extension */
+ },
+ /* disk */
+ {
+ NULL, /* extension */
+ },
+};
+
+WidgetClass asciiDiskWidgetClass = (WidgetClass)&asciiDiskClassRec;
+#endif /* ASCII_DISK */
+
+/*
+ * Implementation
+ */
+static void
+XawAsciiInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ AsciiWidget w = (AsciiWidget)cnew;
+ int i;
+ int tabs[TAB_COUNT], tab;
+
+ MultiSinkObject sink;
+
+ /* superclass Initialize can't set the following,
+ * as it didn't know the source or sink when it was called
+ */
+ if (XtHeight(request) == DEFAULT_TEXT_HEIGHT)
+ XtHeight(cnew) = DEFAULT_TEXT_HEIGHT;
+
+ /* This is the main change for internationalization */
+ if (w->simple.international == True) { /* The multi* are international */
+ if (w->text.sink == NULL)
+ w->text.sink = XtCreateWidget("textSink", multiSinkObjectClass,
+ cnew, args, *num_args);
+ else if (!XtIsSubclass(w->text.sink, multiSinkObjectClass))
+ XtError("Sink object is not a subclass of multiSink");
+
+ if (w->text.source == NULL)
+ w->text.source = XtCreateWidget("textSource", multiSrcObjectClass,
+ cnew, args, *num_args);
+ else if (!XtIsSubclass(w->text.source, multiSrcObjectClass))
+ XtError("Source object is not a subclass of multiSrc");
+#ifndef OLDXAW
+ else
+ _XawSourceAddText(w->text.source, cnew);
+#endif
+ }
+ else {
+ if (w->text.sink == NULL)
+ w->text.sink = XtCreateWidget("textSink", asciiSinkObjectClass,
+ cnew, args, *num_args);
+ else if (!XtIsSubclass(w->text.source, asciiSinkObjectClass))
+ XtError("Sink object is not a subclass of asciiSink");
+
+ if (w->text.source == NULL)
+ w->text.source = XtCreateWidget("textSource", asciiSrcObjectClass,
+ cnew, args, *num_args);
+ else if (!XtIsSubclass(w->text.source, asciiSrcObjectClass))
+ XtError("Source object is not a subclass of asciiSrc");
+#ifndef OLDXAW
+ else
+ _XawSourceAddText(w->text.source, cnew);
+#endif
+ }
+
+ if (XtHeight(w) == DEFAULT_TEXT_HEIGHT)
+ XtHeight(w) = VMargins(w) + XawTextSinkMaxHeight(w->text.sink, 1);
+
+ for (i = 0, tab = 0; i < TAB_COUNT; i++)
+ tabs[i] = (tab += 8);
+
+ XawTextSinkSetTabs(w->text.sink, TAB_COUNT, tabs);
+
+ XawTextDisableRedisplay(cnew);
+ XawTextEnableRedisplay(cnew);
+
+ _XawImRegister(cnew);
+
+ /* If we are using a MultiSink we need to tell the input method stuff */
+ if (w->simple.international == True) {
+ Arg list[4];
+ Cardinal ac = 0;
+
+ sink = (MultiSinkObject)w->text.sink;
+ XtSetArg(list[ac], XtNfontSet, sink->multi_sink.fontset); ac++;
+ XtSetArg(list[ac], XtNinsertPosition, w->text.insertPos); ac++;
+ XtSetArg(list[ac], XtNforeground, sink->text_sink.foreground); ac++;
+ XtSetArg(list[ac], XtNbackground, sink->text_sink.background); ac++;
+ _XawImSetValues(cnew, list, ac);
+ }
+}
+
+static void
+XawAsciiDestroy(Widget w)
+{
+ AsciiWidget ascii = (AsciiWidget)w;
+
+ _XawImUnregister(w);
+
+ if (w == XtParent(ascii->text.sink))
+ XtDestroyWidget(ascii->text.sink);
+
+#ifdef OLDXAW
+ if (w == XtParent(ascii->text.source))
+ XtDestroyWidget(ascii->text.source);
+#else
+ _XawSourceRemoveText(ascii->text.source, w,
+ ascii->text.source &&
+ w == XtParent(ascii->text.source));
+#endif
+}
diff --git a/nx-X11/lib/Xaw/AsciiText.h b/nx-X11/lib/Xaw/AsciiText.h
new file mode 100644
index 000000000..e6b4bc863
--- /dev/null
+++ b/nx-X11/lib/Xaw/AsciiText.h
@@ -0,0 +1,128 @@
+/*
+ * $Xorg: AsciiText.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/AsciiText.h,v 1.5 2001/01/17 19:42:25 dawes Exp $ */
+
+/*
+ * AsciiText.h - Public header file for AsciiText Widget
+ *
+ * This Widget is intended to be used as a simple front end to the
+ * text widget with an ascii source and ascii sink attached to it
+ *
+ * Date: June 29, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+#ifndef _AsciiText_h
+#define _AsciiText_h
+
+#include <X11/Xaw/Text.h>
+#include <X11/Xaw/AsciiSrc.h>
+#include <X11/Xaw/MultiSrc.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ autoFill AutoFill Boolean False
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ bottomMargin Margin Position 2
+ cursor Cursor Cursor xterm
+ destroyCallback Callback Pointer NULL
+ displayCaret Output Boolean True
+ displayPosition TextPosition int 0
+ editType EditType XawTextEditType XawtextRead
+ font Font XFontStruct* Fixed
+ foreground Foreground Pixel Black
+ height Height Dimension font height
+ insertPosition TextPosition int 0
+ international International Boolean false
+ leftMargin Margin Position 2
+ mappedWhenManaged MappedWhenManaged Boolean True
+ resize Resize XawTextResizeMode XawtextResizeNever
+ rightMargin Margin Position 4
+ scrollHorizontal Scroll XawTextScrollMode XawtextScrollNever
+ scrollVertical Scroll XawTextScrollMode XawtextScrollNever
+ selectTypes SelectTypes Pointer pos/word/line/par/all
+ selection Selection Pointer (empty selection)
+ sensitive Sensitive Boolean True
+ sink TextSink Widget (none)
+ source TextSource Widget (none)
+ string String String NULL
+ topMargin Margin Position 2
+ width Width Dimension 100
+ wrap Wrap XawTextWrapMode XawtextWrapNever
+ x Position Position 0
+ y Position Position 0
+
+ (see also *Src.h and *Sink.h)
+*/
+
+typedef struct _AsciiTextClassRec *AsciiTextWidgetClass;
+typedef struct _AsciiRec *AsciiWidget;
+
+extern WidgetClass asciiTextWidgetClass;
+
+/*
+ * Disk and String Emulation Info
+ */
+#ifdef ASCII_STRING
+extern WidgetClass asciiStringWidgetClass;
+#endif
+
+#ifdef ASCII_DISK
+extern WidgetClass asciiDiskWidgetClass;
+#endif
+
+#endif /* _AsciiText_h */
diff --git a/nx-X11/lib/Xaw/AsciiTextP.h b/nx-X11/lib/Xaw/AsciiTextP.h
new file mode 100644
index 000000000..25e3eeeab
--- /dev/null
+++ b/nx-X11/lib/Xaw/AsciiTextP.h
@@ -0,0 +1,169 @@
+/*
+ * $Xorg: AsciiTextP.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/AsciiTextP.h,v 1.8 2001/01/17 19:42:25 dawes Exp $ */
+
+/*
+ * AsciiText.c - Private header file for AsciiText Widget.
+ *
+ * This Widget is intended to be used as a simple front end to the
+ * text widget with an ascii source and ascii sink attached to it.
+ *
+ * Date: June 29, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _AsciiTextP_h
+#define _AsciiTextP_h
+
+#include <X11/Xaw/TextP.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/AsciiSrc.h>
+#include <X11/Xaw/MultiSrc.h>
+
+typedef struct {
+ XtPointer extension;
+} AsciiClassPart;
+
+typedef struct _AsciiTextClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ TextClassPart text_class;
+ AsciiClassPart ascii_class;
+} AsciiTextClassRec;
+
+extern AsciiTextClassRec asciiTextClassRec;
+
+typedef struct {
+ int resource;
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} AsciiPart;
+
+typedef struct _AsciiRec {
+ CorePart core;
+ SimplePart simple;
+ TextPart text;
+ AsciiPart ascii;
+} AsciiRec;
+
+/*
+ * Ascii String Emulation widget
+ */
+#ifdef ASCII_STRING
+typedef struct {
+ XtPointer extension;
+} AsciiStringClassPart;
+
+typedef struct _AsciiStringClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ TextClassPart text_class;
+ AsciiClassPart ascii_class;
+ AsciiStringClassPart string_class;
+} AsciiStringClassRec;
+
+extern AsciiStringClassRec asciiStringClassRec;
+
+typedef struct {
+ int resource;
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} AsciiStringPart;
+
+typedef struct _AsciiStringRec {
+ CorePart core;
+ SimplePart simple;
+ TextPart text;
+ AsciiPart ascii;
+ AsciiStringPart ascii_str;
+} AsciiStringRec;
+#endif /* ASCII_STRING */
+
+#ifdef ASCII_DISK
+/*
+ * Ascii Disk Emulation widget
+ */
+typedef struct {
+ XtPointer extension;
+} AsciiDiskClassPart;
+
+typedef struct _AsciiDiskClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ TextClassPart text_class;
+ AsciiClassPart ascii_class;
+ AsciiDiskClassPart disk_class;
+} AsciiDiskClassRec;
+
+extern AsciiDiskClassRec asciiDiskClassRec;
+
+typedef struct {
+ char resource;
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} AsciiDiskPart;
+
+typedef struct _AsciiDiskRec {
+ CorePart core;
+ SimplePart simple;
+ TextPart text;
+ AsciiPart ascii;
+ AsciiDiskPart ascii_disk;
+} AsciiDiskRec;
+#endif /* ASCII_DISK */
+
+#endif /* _AsciiTextP_h */
diff --git a/nx-X11/lib/Xaw/Box.c b/nx-X11/lib/Xaw/Box.c
new file mode 100644
index 000000000..f4f293926
--- /dev/null
+++ b/nx-X11/lib/Xaw/Box.c
@@ -0,0 +1,675 @@
+/* $Xorg: Box.c,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Box.c,v 1.14 2001/01/17 19:42:25 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xaw/BoxP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+/*
+ * Class Methods
+ */
+static void XawBoxChangeManaged(Widget);
+static void XawBoxClassInitialize(void);
+#ifndef OLDXAW
+static void XawBoxExpose(Widget, XEvent*, Region);
+#endif
+static XtGeometryResult XawBoxGeometryManager(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawBoxInitialize(Widget, Widget, ArgList, Cardinal*);
+static XtGeometryResult XawBoxQueryGeometry(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawBoxRealize(Widget, Mask*, XSetWindowAttributes*);
+static void XawBoxResize(Widget);
+static Boolean XawBoxSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static void DoLayout(BoxWidget, unsigned int, unsigned int,
+ Dimension*, Dimension*, Bool);
+static Bool TryNewLayout(BoxWidget);
+
+/*
+ * Initialization
+ */
+#ifndef OLDXAW
+static XtActionsRec actions[] = {
+ {"set-values", XawSetValuesAction},
+ {"get-values", XawGetValuesAction},
+ {"declare", XawDeclareAction},
+ {"call-proc", XawCallProcAction},
+};
+#endif
+
+static XtResource resources[] = {
+ {
+ XtNhSpace,
+ XtCHSpace,
+ XtRDimension,
+ sizeof(Dimension),
+ XtOffsetOf(BoxRec, box.h_space),
+ XtRImmediate,
+ (XtPointer)4
+ },
+ {
+ XtNvSpace,
+ XtCVSpace,
+ XtRDimension,
+ sizeof(Dimension),
+ XtOffsetOf(BoxRec, box.v_space),
+ XtRImmediate,
+ (XtPointer)4
+ },
+ {
+ XtNorientation,
+ XtCOrientation,
+ XtROrientation,
+ sizeof(XtOrientation),
+ XtOffsetOf(BoxRec, box.orientation),
+ XtRImmediate,
+ (XtPointer)XtorientVertical
+ },
+#ifndef OLDXAW
+ {
+ XawNdisplayList,
+ XawCDisplayList,
+ XawRDisplayList,
+ sizeof(XawDisplayList*),
+ XtOffsetOf(BoxRec, box.display_list),
+ XtRImmediate,
+ NULL
+ },
+#endif
+};
+
+BoxClassRec boxClassRec = {
+ /* core */
+ {
+ (WidgetClass)&compositeClassRec, /* superclass */
+ "Box", /* class_name */
+ sizeof(BoxRec), /* widget_size */
+ XawBoxClassInitialize, /* class_initialize */
+ NULL, /* class_part_init */
+ False, /* class_inited */
+ XawBoxInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XawBoxRealize, /* realize */
+#ifndef OLDXAW
+ actions, /* actions */
+ XtNumber(actions), /* num_actions */
+#else
+ NULL, /* actions */
+ 0, /* num_actions */
+#endif
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ NULL, /* destroy */
+ XawBoxResize, /* resize */
+#ifndef OLDXAW
+ XawBoxExpose, /* expose */
+#else
+ NULL, /* expose */
+#endif
+ XawBoxSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ XawBoxQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* composite */
+ {
+ XawBoxGeometryManager, /* geometry_manager */
+ XawBoxChangeManaged, /* change_managed */
+ XtInheritInsertChild, /* insert_child */
+ XtInheritDeleteChild, /* delete_child */
+ NULL, /* extension */
+ },
+ /* box */
+ {
+ NULL, /* extension */
+ },
+};
+
+WidgetClass boxWidgetClass = (WidgetClass)&boxClassRec;
+
+/*
+ * Do a layout, either actually assigning positions, or just calculating size.
+ * Returns minimum width and height that will preserve the same layout.
+ */
+static void
+DoLayout(BoxWidget bbw, unsigned int width, unsigned int height,
+ Dimension *reply_width, Dimension *reply_height, Bool position)
+{
+ Boolean vbox = (bbw->box.orientation == XtorientVertical);
+ Cardinal i;
+ Dimension w, h; /* Width and height needed for box */
+ Dimension lw, lh; /* Width and height needed for current line */
+ Dimension bw, bh; /* Width and height needed for current widget */
+ Dimension h_space; /* Local copy of bbw->box.h_space */
+ Widget widget; /* Current widget */
+ unsigned int num_mapped_children = 0;
+
+ /* Box width and height */
+ h_space = bbw->box.h_space;
+
+ w = 0;
+ for (i = 0; i < bbw->composite.num_children; i++) {
+ if (XtIsManaged(bbw->composite.children[i])
+ && bbw->composite.children[i]->core.width > w)
+ w = bbw->composite.children[i]->core.width;
+ }
+ w += h_space;
+ if (w > width)
+ width = w;
+ h = bbw->box.v_space;
+
+ /* Line width and height */
+ lh = 0;
+ lw = h_space;
+
+ for (i = 0; i < bbw->composite.num_children; i++) {
+ widget = bbw->composite.children[i];
+ if (widget->core.managed) {
+ if (widget->core.mapped_when_managed)
+ num_mapped_children++;
+ /* Compute widget width */
+ bw = XtWidth(widget) + (XtBorderWidth(widget)<<1) + h_space;
+ if ((Dimension)(lw + bw) > width) {
+ if (lw > h_space) {
+ /* At least one widget on this line, and
+ * can't fit any more. Start new line if vbox
+ */
+ AssignMax(w, lw);
+ if (vbox) {
+ h += lh + bbw->box.v_space;
+ lh = 0;
+ lw = h_space;
+ }
+ }
+ else if (!position) {
+ /* too narrow for this widget; we'll assume we can grow */
+ DoLayout(bbw, (unsigned)(lw + bw), height, reply_width,
+ reply_height, position);
+ return;
+ }
+ }
+ if (position && (lw != XtX(widget) || h != XtY(widget))) {
+ /* It would be nice to use window gravity, but there isn't
+ * sufficient fine-grain control to nicely handle all
+ * situations (e.g. when only the height changes --
+ * a common case). Explicit unmapping is a cheap hack
+ * to speed things up & avoid the visual jitter as
+ * things slide around.
+ *
+ * %%% perhaps there should be a client resource to
+ * control this. If so, we'll have to optimize to
+ * perform the moves from the correct end so we don't
+ * force extra exposures as children occlude each other.
+ */
+ if (XtIsRealized(widget) && widget->core.mapped_when_managed)
+ XUnmapWindow( XtDisplay(widget), XtWindow(widget));
+ XtMoveWidget(widget, (int)lw, (int)h);
+ }
+ lw += bw;
+ bh = XtHeight(widget) + (XtBorderWidth(widget) << 1);
+ AssignMax(lh, bh);
+ }
+ }
+
+ if (!vbox && width && lw > width && lh < height) {
+ /* reduce width if too wide and height not filled */
+ Dimension sw = lw, sh = lh;
+ Dimension width_needed = width;
+ XtOrientation orientation = bbw->box.orientation;
+
+ bbw->box.orientation = XtorientVertical;
+ while (sh < height && sw > width) {
+ width_needed = sw;
+ DoLayout(bbw, (unsigned)(sw-1), height, &sw, &sh, False);
+ }
+ if (sh < height)
+ width_needed = sw;
+ if (width_needed != lw) {
+ DoLayout(bbw, width_needed, height,
+ reply_width, reply_height, position);
+ bbw->box.orientation = orientation;
+ return;
+ }
+ bbw->box.orientation = orientation;
+ }
+ if (vbox && (width < w || width < lw)) {
+ AssignMax(w, lw);
+ DoLayout(bbw, w, height, reply_width, reply_height, position);
+ return;
+ }
+ if (position && XtIsRealized((Widget)bbw)) {
+ if (bbw->composite.num_children == num_mapped_children)
+ XMapSubwindows(XtDisplay((Widget)bbw), XtWindow((Widget)bbw));
+ else {
+ int ii = bbw->composite.num_children;
+ Widget *childP = bbw->composite.children;
+
+ for (; ii > 0; childP++, ii--)
+ if (XtIsRealized(*childP) && XtIsManaged(*childP)
+ && (*childP)->core.mapped_when_managed)
+ XtMapWidget(*childP);
+ }
+ }
+
+ /* Finish off last line */
+ if (lw > h_space) {
+ AssignMax(w, lw);
+ h += lh + bbw->box.v_space;
+ }
+
+ *reply_width = Max(w, 1);
+ *reply_height = Max(h, 1);
+}
+
+/*
+ * Calculate preferred size, given constraining box, caching it in the widget
+ */
+static XtGeometryResult
+XawBoxQueryGeometry(Widget widget, XtWidgetGeometry *constraint,
+ XtWidgetGeometry *preferred)
+{
+ BoxWidget w = (BoxWidget)widget;
+ Dimension width;
+ Dimension preferred_width = w->box.preferred_width;
+ Dimension preferred_height = w->box.preferred_height;
+
+ constraint->request_mode &= CWWidth | CWHeight;
+
+ if (constraint->request_mode == 0)
+ /* parent isn't going to change w or h, so nothing to re-compute */
+ return (XtGeometryYes);
+
+ if (constraint->request_mode == w->box.last_query_mode
+ && (!(constraint->request_mode & CWWidth)
+ || constraint->width == w->box.last_query_width)
+ && (!(constraint->request_mode & CWHeight)
+ || constraint->height == w->box.last_query_height)) {
+ /* same query; current preferences are still valid */
+ preferred->request_mode = CWWidth | CWHeight;
+ preferred->width = preferred_width;
+ preferred->height = preferred_height;
+ if (constraint->request_mode == (CWWidth | CWHeight)
+ && constraint->width == preferred_width
+ && constraint->height == preferred_height)
+ return (XtGeometryYes);
+ else
+ return (XtGeometryAlmost);
+ }
+
+ /* else gotta do it the long way...
+ I have a preference for tall and narrow, so if my width is
+ constrained, I'll accept it; otherwise, I'll compute the minimum
+ width that will fit me within the height constraint */
+
+ w->box.last_query_mode = constraint->request_mode;
+ w->box.last_query_width = constraint->width;
+ w->box.last_query_height= constraint->height;
+
+ if (constraint->request_mode & CWWidth)
+ width = constraint->width;
+ else { /* if (constraint->request_mode & CWHeight) */
+ /* let's see if I can become any narrower */
+ width = 0;
+ constraint->width = 65535;
+ }
+
+ /* height is currently ignored by DoLayout.
+ height = (constraint->request_mode & CWHeight) ? constraint->height
+ : *preferred_height;
+ */
+ DoLayout(w, width, 0, &preferred_width, &preferred_height, False);
+
+ if (constraint->request_mode & CWHeight
+ && preferred_height > constraint->height) {
+ /* find minimum width for this height */
+ if (preferred_width <= constraint->width) {
+ width = preferred_width;
+ do { /* find some width big enough to stay within this height */
+ width <<= 1;
+ if (width > constraint->width)
+ width = constraint->width;
+ DoLayout(w, width, 0, &preferred_width, &preferred_height, False);
+ } while (preferred_height > constraint->height
+ && width < constraint->width);
+ if (width != constraint->width) {
+ do { /* find minimum width */
+ width = preferred_width;
+ DoLayout(w, (unsigned)(preferred_width - 1), 0,
+ &preferred_width, &preferred_height, False);
+ } while (preferred_height < constraint->height);
+ /* one last time */
+ DoLayout(w, width, 0, &preferred_width, &preferred_height, False);
+ }
+ }
+ }
+
+ preferred->request_mode = CWWidth | CWHeight;
+ preferred->width = w->box.preferred_width = preferred_width;
+ preferred->height = w->box.preferred_height = preferred_height;
+
+ if (constraint->request_mode == (CWWidth|CWHeight)
+ && constraint->width == preferred_width
+ && constraint->height == preferred_height)
+ return (XtGeometryYes);
+
+ return (XtGeometryAlmost);
+}
+
+/*
+ * Actually layout the box
+ */
+static void
+XawBoxResize(Widget w)
+{
+ Dimension tmp;
+
+ DoLayout((BoxWidget)w, XtWidth(w), XtHeight(w), &tmp, &tmp, True);
+}
+
+/*
+ * Try to do a new layout within the current width and height;
+ * if that fails try to resize and do it within the box returne
+ * by XawBoxQueryGeometry
+ *
+ * TryNewLayout just says if it's possible, and doesn't actually move the kids
+ */
+static Bool
+TryNewLayout(BoxWidget bbw)
+{
+ Dimension preferred_width, preferred_height;
+ Dimension proposed_width, proposed_height;
+ int iterations;
+
+ DoLayout(bbw, bbw->core.width, bbw->core.height,
+ &preferred_width, &preferred_height, False);
+
+ /* at this point, preferred_width is guaranteed to not be greater
+ than bbw->core.width unless some child is larger, so there's no
+ point in re-computing another layout */
+
+ if (XtWidth(bbw) == preferred_width && XtHeight(bbw) == preferred_height)
+ return (True);
+
+ /* let's see if our parent will go for a new size */
+ iterations = 0;
+ proposed_width = preferred_width;
+ proposed_height = preferred_height;
+ do {
+ switch (XtMakeResizeRequest((Widget)bbw,proposed_width,proposed_height,
+ &proposed_width, &proposed_height)) {
+ case XtGeometryYes:
+ return (True);
+ case XtGeometryNo:
+ if (iterations > 0)
+ /* protect from malicious parents who change their minds */
+ DoLayout(bbw, bbw->core.width, bbw->core.height,
+ &preferred_width, &preferred_height, False);
+ if (preferred_width <= XtWidth(bbw)
+ && preferred_height <= XtHeight(bbw))
+ return (True);
+ else
+ return (False);
+ case XtGeometryAlmost:
+ if (proposed_height >= preferred_height &&
+ proposed_width >= preferred_width) {
+ /*
+ * Take it, and assume the parent knows what it is doing.
+ *
+ * The parent must accept this since it was returned in
+ * almost.
+ */
+ (void)XtMakeResizeRequest((Widget)bbw,
+ proposed_width, proposed_height,
+ &proposed_width, &proposed_height);
+ return (True);
+ }
+ else if (proposed_width != preferred_width) {
+ /* recalc bounding box; height might change */
+ DoLayout(bbw, proposed_width, 0,
+ &preferred_width, &preferred_height, False);
+ proposed_height = preferred_height;
+ }
+ else { /* proposed_height != preferred_height */
+ XtWidgetGeometry constraints, reply;
+
+ constraints.request_mode = CWHeight;
+ constraints.height = proposed_height;
+ (void)XawBoxQueryGeometry((Widget)bbw, &constraints, &reply);
+ proposed_width = preferred_width;
+ }
+ /*FALLTHROUGH*/
+ default:
+ break;
+ }
+ iterations++;
+ } while (iterations < 10);
+
+ return (False);
+}
+
+/*
+ * Geometry Manager
+ *
+ * 'reply' is unused; we say only yeay or nay, never almost.
+ */
+/*ARGSUSED*/
+static XtGeometryResult
+XawBoxGeometryManager(Widget w, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+ Dimension width, height, borderWidth;
+ BoxWidget bbw;
+
+ /* Position request always denied */
+ if (((request->request_mode & CWX) && request->x != XtX(w))
+ || ((request->request_mode & CWY) && request->y != XtY(w)))
+ return (XtGeometryNo);
+
+ /* Size changes must see if the new size can be accomodated */
+ if (request->request_mode & (CWWidth | CWHeight | CWBorderWidth)) {
+ /* Make all three fields in the request valid */
+ if ((request->request_mode & CWWidth) == 0)
+ request->width = XtWidth(w);
+ if ((request->request_mode & CWHeight) == 0)
+ request->height = XtHeight(w);
+ if ((request->request_mode & CWBorderWidth) == 0)
+ request->border_width = XtBorderWidth(w);
+
+ /* Save current size and set to new size */
+ width = XtWidth(w);
+ height = XtHeight(w);
+ borderWidth = XtBorderWidth(w);
+ XtWidth(w) = request->width;
+ XtHeight(w) = request->height;
+ XtBorderWidth(w) = request->border_width;
+
+ /* Decide if new layout works:
+ (1) new widget is smaller,
+ (2) new widget fits in existing Box,
+ (3) Box can be expanded to allow new widget to fit
+ */
+
+ bbw = (BoxWidget) w->core.parent;
+
+ if (TryNewLayout(bbw)) {
+ /* Fits in existing or new space, relayout */
+ (*XtClass((Widget)bbw)->core_class.resize)((Widget)bbw);
+ return (XtGeometryYes);
+ }
+ else {
+ /* Cannot satisfy request, change back to original geometry */
+ XtWidth(w) = width;
+ XtHeight(w) = height;
+ XtBorderWidth(w) = borderWidth;
+ return (XtGeometryNo);
+ }
+ }
+
+ /* Any stacking changes don't make a difference, so allow if that's all */
+ return (XtGeometryYes);
+}
+
+static void
+XawBoxChangeManaged(Widget w)
+{
+ /* Reconfigure the box */
+ (void)TryNewLayout((BoxWidget)w);
+ XawBoxResize(w);
+}
+
+static void
+XawBoxClassInitialize(void)
+{
+ XawInitializeWidgetSet();
+ XtAddConverter(XtRString, XtROrientation, XmuCvtStringToOrientation,
+ NULL, 0);
+ XtSetTypeConverter(XtROrientation, XtRString, XmuCvtOrientationToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+
+/*ARGSUSED*/
+static void
+XawBoxInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ BoxWidget newbbw = (BoxWidget)cnew;
+
+ newbbw->box.last_query_mode = CWWidth | CWHeight;
+ newbbw->box.last_query_width = newbbw->box.last_query_height = 0;
+ newbbw->box.preferred_width = Max(newbbw->box.h_space, 1);
+ newbbw->box.preferred_height = Max(newbbw->box.v_space, 1);
+
+ if (XtWidth(newbbw) == 0)
+ XtWidth(newbbw) = newbbw->box.preferred_width;
+
+ if (XtHeight(newbbw) == 0)
+ XtHeight(newbbw) = newbbw->box.preferred_height;
+}
+
+static void
+XawBoxRealize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
+{
+#ifndef OLDXAW
+ XawPixmap *pixmap;
+#endif
+
+ XtCreateWindow(w, InputOutput, (Visual *)CopyFromParent,
+ *valueMask, attributes);
+
+#ifndef OLDXAW
+ if (w->core.background_pixmap > XtUnspecifiedPixmap) {
+ pixmap = XawPixmapFromXPixmap(w->core.background_pixmap, XtScreen(w),
+ w->core.colormap, w->core.depth);
+ if (pixmap && pixmap->mask)
+ XawReshapeWidget(w, pixmap);
+ }
+#endif
+}
+
+/*ARGSUSED*/
+static Boolean
+XawBoxSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ /* need to relayout if h_space or v_space change */
+#ifndef OLDXAW
+ BoxWidget b_old = (BoxWidget)current;
+ BoxWidget b_new = (BoxWidget)cnew;
+
+ if (b_old->core.background_pixmap != b_new->core.background_pixmap) {
+ XawPixmap *opix, *npix;
+
+ opix = XawPixmapFromXPixmap(b_old->core.background_pixmap,
+ XtScreen(b_old), b_old->core.colormap,
+ b_old->core.depth);
+ npix = XawPixmapFromXPixmap(b_new->core.background_pixmap,
+ XtScreen(b_new), b_new->core.colormap,
+ b_new->core.depth);
+ if ((npix && npix->mask) || (opix && opix->mask))
+ XawReshapeWidget(cnew, npix);
+ }
+#endif /* OLDXAW */
+
+ return (False);
+}
+
+#ifndef OLDXAW
+static void
+XawBoxExpose(Widget w, XEvent *event, Region region)
+{
+ BoxWidget xaw = (BoxWidget)w;
+
+ if (xaw->box.display_list)
+ XawRunDisplayList(w, xaw->box.display_list, event, region);
+}
+#endif /* OLDXAW */
diff --git a/nx-X11/lib/Xaw/Box.h b/nx-X11/lib/Xaw/Box.h
new file mode 100644
index 000000000..17db281d6
--- /dev/null
+++ b/nx-X11/lib/Xaw/Box.h
@@ -0,0 +1,108 @@
+/*
+* $Xorg: Box.h,v 1.4 2001/02/09 02:03:43 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Box.h,v 1.7 2001/01/17 19:42:25 dawes Exp $ */
+
+#ifndef _XawBox_h
+#define _XawBox_h
+
+#include <X11/Xmu/Converters.h>
+
+/*
+ * Box Widget (subclass of CompositeClass)
+ */
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ destroyCallback Callback Pointer NULL
+ displayList DisplayList XawDisplayList* NULL
+ hSpace HSpace Dimension 4
+ height Height Dimension 0
+ mappedWhenManaged MappedWhenManaged Boolean True
+ orientation Orientation XtOrientation vertical
+ vSpace VSpace Dimension 4
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#ifndef _XtStringDefs_h_
+#define XtNhSpace "hSpace"
+#define XtNvSpace "vSpace"
+#endif
+
+#ifndef OLDXAW
+#ifndef XawNdisplayList
+#define XawNdisplayList "displayList"
+#endif
+
+#ifndef XawCDisplayList
+#define XawCDisplayList "DisplayList"
+#endif
+
+#ifndef XawRDisplayList
+#define XawRDisplayList "XawDisplayList"
+#endif
+#endif /* OLDXAW */
+
+/* Class record constants */
+extern WidgetClass boxWidgetClass;
+
+typedef struct _BoxClassRec *BoxWidgetClass;
+typedef struct _BoxRec *BoxWidget;
+
+#endif /* _XawBox_h */
diff --git a/nx-X11/lib/Xaw/BoxP.h b/nx-X11/lib/Xaw/BoxP.h
new file mode 100644
index 000000000..a64142e7d
--- /dev/null
+++ b/nx-X11/lib/Xaw/BoxP.h
@@ -0,0 +1,103 @@
+/*
+* $Xorg: BoxP.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/BoxP.h,v 1.10 2001/01/17 19:42:25 dawes Exp $ */
+
+#ifndef _XawBoxP_h
+#define _XawBoxP_h
+
+/*
+ * Box Widget Private Data
+ */
+#include <X11/Xaw/Box.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xaw/XawInit.h>
+
+/* New fields for the Box widget class record */
+typedef struct {
+ XtPointer extension;
+} BoxClassPart;
+
+/* Full class record declaration */
+typedef struct _BoxClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ BoxClassPart box_class;
+} BoxClassRec;
+
+extern BoxClassRec boxClassRec;
+
+/* New fields for the Box widget record */
+typedef struct {
+ /* resources */
+ Dimension h_space, v_space;
+ XtOrientation orientation;
+
+ /* private state */
+ Dimension preferred_width, preferred_height;
+ Dimension last_query_width, last_query_height;
+ XtGeometryMask last_query_mode;
+#ifndef OLDXAW
+ XawDisplayList *display_list;
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} BoxPart;
+
+/*
+ * Full instance record declaration
+ */
+typedef struct _BoxRec {
+ CorePart core;
+ CompositePart composite;
+ BoxPart box;
+} BoxRec;
+
+#endif /* _XawBoxP_h */
diff --git a/nx-X11/lib/Xaw/CHANGES b/nx-X11/lib/Xaw/CHANGES
new file mode 100644
index 000000000..2eb316abb
--- /dev/null
+++ b/nx-X11/lib/Xaw/CHANGES
@@ -0,0 +1,153 @@
+
+ These changes have been made to Xaw since X11R4.
+
+
+
+Documentation:
+ Fixed definition of XtAppInitialize().
+
+ Changed all references to XawOrient* and XtOrient* to Xtorient*.
+
+ Many other corrections and clarifications.
+
+Everywhere:
+ Function prototypes for public interfaces.
+
+ Many bugs not mentioned here have been fixed.
+
+AllWidgets:
+ Add WidgetNode table for use with listres and viewres.
+
+AsciiSrc (Text):
+ No warning message is printed when the file can not be
+ written to, the return value should be enough info.
+
+ GetValues on the string resource was failing when
+ "useStringInPlace" was set to true.
+
+ Memory leak when freeing pieces in a source of type "ascii String"
+ has been plugged.
+
+ Buffer is now updated whenever the "string" resource is set using
+ XtSetValues(). If type is file then the file is read in again.
+
+Box:
+ The public header file now includes Xmu/Converters.h for the
+ orientation resources.
+
+Clock:
+ Made subclass of simple instead of Core
+
+Command:
+ Fixed bug in changing shape style to Rectangular.
+
+Dialog:
+ Resource Type of Icon changed from Pixmap -> Bitmap.
+
+Form:
+ The geometry handler now will now disallow geometry management
+ reqests that will force the child outside the Form's window.
+
+ Fixed missing parens typo in PreferredGeometry.
+
+ Fixed EdgeTypes to be Xaw* instead of Xt*, but left the
+ old definitions around with #define so that code will still work.
+
+ StringToWidget converter no longer caches resources.
+
+Logo:
+ Made subclass of simple instead of Core.
+ Fixed reverse video.
+
+Mailbox:
+ Made subclass of simple instead of Core.
+ Fixed reverse video and many other bugs.
+
+MenuButton:
+* The MenuButton widget no longer places a server grab on itself.
+ Instead, PopupMenu is registered as a grab action. As a result
+ of this, clients which popped up menus without using XtMenuPopup
+ or MenuPopup or PopupMenu in the menu button translations will
+ fail to have a grab active. They should make a call to
+ XtRegisterGrabAction on the appropriate action in the application
+ initialization routine, or use a different translation.
+
+Paned:
+ The public header file now includes Xmu/Converters.h for the
+ orientation resources.
+
+Panner: This widget is new in R5.
+
+Porthole:
+ New for R5.
+
+Scrollbar:
+ Fixed bug that could call XtReleaseGC() with garbage
+ Made subclass of simple instead of Core
+
+ Type of thumb resource is XtRBitmap; it used to be XtRPixmap.
+ However, if applications provide the resource conversion, the
+ Scrollbar's SetValues can still handle pixmaps of correct depth.
+
+Simple:
+ Added a color cursor converter. and the new resource types:
+ XtNpointerColor
+ XtNpointerColorBackground
+ XtNcursorName
+
+SmeBSB:
+ Right bitmaps are now painted in the correct location.
+
+ Right and Left Bitmaps can be specified in resource files, and
+ at startup time.
+
+Text:
+ If there is no current selection the the selection extends
+ from the insert point, rather than some random location.
+
+ Forward (Backward) Paragraph works at the paragraph boundaries now.
+
+ Selecting a word now transitions correctly at BOTH end points.
+
+ Infinite loop when using fill paragraph in a read only text widget
+ has been found and fixed.
+
+ When the "resize" resource is set the text will start up with
+ exactly enough space to contain the text in the widget.
+
+ Fixed a bug that could cause an infinite loop when Meta-Q was used
+ to invoke the form-paragraph function on a read-only text widget.
+
+ Exposures fixed.
+
+TextP.h:
+ Symbolic constants private to the Text widget should not conflict
+ with operating system headers files. The names of these symbolic
+ constants have each had the prefix Xaw added to them:
+ #define XawLF 0x0a
+ #define XawCR 0x0d
+ #define XawTAB 0x09
+ #define XawBS 0x08
+ #define XawSP 0x20
+ #define XawDEL 0x7f
+ #define XawBSLASH '\\'
+
+
+Toggle:
+* Toggle widget state is preserved across changes in sensitivity.
+
+ A string to widget converter is regisetered for radio groups.
+
+Tree:
+ New for R5.
+
+Paned:
+ Fixed bug that caused XtGeometryYes returns to have bogus values,
+ causes panes to get random sizes.
+
+Vendor:
+ Added support for the Resource Editor.
+ Fixed bug causing Shell to ignore all but first child.
+
+Viewport:
+ Added XawPannerReport support.
diff --git a/nx-X11/lib/Xaw/Cardinals.h b/nx-X11/lib/Xaw/Cardinals.h
new file mode 100644
index 000000000..a8b3dfc41
--- /dev/null
+++ b/nx-X11/lib/Xaw/Cardinals.h
@@ -0,0 +1,43 @@
+/* $Xorg: Cardinals.h,v 1.4 2001/02/09 02:03:43 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.
+
+*/
+
+#ifndef _Cardinals_h
+#define _Cardinals_h
+
+#define ZERO ((Cardinal)0)
+#define ONE ((Cardinal)1)
+#define TWO ((Cardinal)2)
+#define THREE ((Cardinal)3)
+#define FOUR ((Cardinal)4)
+#define FIVE ((Cardinal)5)
+#define SIX ((Cardinal)6)
+#define SEVEN ((Cardinal)7)
+#define EIGHT ((Cardinal)8)
+#define NINE ((Cardinal)9)
+#define TEN ((Cardinal)10)
+
+#endif /* _Cardinals_h */
diff --git a/nx-X11/lib/Xaw/Changelog b/nx-X11/lib/Xaw/Changelog
new file mode 100644
index 000000000..263ae04d5
--- /dev/null
+++ b/nx-X11/lib/Xaw/Changelog
@@ -0,0 +1,1370 @@
+Patch 1 (#1655) 15 April 1998
+
+ Description of the actions system:
+--------------------------------------------------------------------
+ All the actions have the syntax:
+
+action-name(boolean-expression, args)
+
+ Where:
+action-name:
+ Any string with a translation binding in the binary for the widget.
+
+boolean-expression:
+ [{~}]variable-name|resource-name|constant-name[{&|^}[[{~}]variable-name|resource-name|constant-name]]...
+
+variable-name:
+ Any string starting with a '$' character (actually it's not possible
+ to mask this character; I'll fix it). Variables are actually created
+ with the translations 'declare' and 'get-values'. Example:
+ get-values(1, $x, x)
+ declare(1, $armed, true)
+
+resource-name:
+ Any resource name of the widget. Note that it requires a <TYPE> to
+ string converter in the code (I added some on the patches), since
+ all variables values are stored in a 'String' format. Example:
+ borderWidth
+ height
+ font
+ background
+
+constant-name:
+ Especial values. They aren't normally contants, but a special state
+ not triggered with resources or variables (They have the highest
+ precedence, so, to allow these strings as resource names I'll need
+ to allow some sort of escape sequences). Examples:
+ mine # event->xany.window == XtWindow(widget)
+ faked # event->xany.send_event != 0
+ true # you know
+ false # " "
+
+args:
+ Special strings values interpreted by the translation binding.
+
+The operators (currently) understood are:
+ ~ - NOT
+ & - AND
+ | - OR
+ ^ - XOR
+ ( - RP
+ ) - LP
+ The final result value is and'ed with 1.
+
+Sample translation to make a label widget behave like a button:
+<Map>:\
+ get-values(1, $fg, foreground, $bg, background)\n\
+<Btn1Down>:\
+ set-values(1, foreground, yellow, background, gray30)\n\
+<Btn1Up>:\
+ set-values(1, foreground, $fg, background, $bg)\n
+
+
+ Description of the displayList system:
+--------------------------------------------------------------------
+ The display list has the syntax:
+
+[class-name:]function-name args[{;|\n}]...
+
+ Where:
+class-name:
+ Any registered set of functions. The code registers the class 'xlib',
+ and if the class name is not specified, this class is assumed.
+
+function-name:
+ A string binding to the correct function to be called.
+
+args:
+ A set of converted and shareable arguments, to the function. The
+ positioning/sizing arguments currently implemented have the syntax:
+{+-}<integer> or <integer>/<integer>. Examples:
+ +0,+0 top, left
+ -0,-0 bottom, right
+ -+10,-+10 bottom+10, right+10
+ +0,1/2 left, vcenter
+
+ All displayLists are shared by:
+ widget->core.screen
+ widget->core.colormap
+ widget->core.depth
+ I have added only partial code for handling non-windowed widgets (gadgets).
+I'll fix it.
+
+ Example for drawing two lines crossing the widget:
+foreground black;\
+line +0,+0,-0,-0;\
+line +0,-0,-0,+0
+
+
+
+Patch 2 (#1660) 19 April 1998
+
+ + More functions for displayList's
+ + Fixes for simpleMenuWidget, xfontsel should work very better now. Try
+ this with the newer patches to verify the changes:
+ xfontsel -xrm '*XFontSel*SimpleMenu*font:
+-*-helvetica-medium-r-*-*-16-*-*-*-*-*-*-1'
+ + Small bug fix to boxWidget, viewres should work better now. Try this
+ to verify the changes:
+ viewres -xrm '*Viewres*Box.borderWidth: 1'
+ + Small bug fix to panedWidget, when pressing in a gripWidget but not
+ moving the pointer, or releasing at the same coordinates.
+
+Patch 3 (#1673) 25 April 1998
+
+ + Changes in layout code for the Form widget. To see the changes, run xcalc
+ and resize it several times (try giving it a very small size and the
+ restore the size). The new code uses a 'known' reference size/position
+ to avoid integer rounding problems.
+ + A optimization for the Form widget. Now it unmaps itself before resizing
+ the child widgets. This way the layout process is very faster.
+ + The List widget will try to fit in a 32767x32767 window size. It checks
+ if the width or height will become bigger than 32767 and if will, changes
+ the number of columns. This fixes xman (at least for me, that have several
+ entries in the section 3 of the manpages).
+ + New functions to displayList's and fixes to some bad bugs (I'm yet working
+ on that file).
+ + Change in the Scrollbar functionality. It was redrawing the thumb when
+ triggering the MoveThumb action. This is bad because several programs
+ choose to recalculate the thumb position with XawScrollbarSetThumb, causing
+ screen flickering. Now it redraws the thumb when triggering the NotifyThumb
+ action. To verify the changes, run xfm or xman and try to scroll past the
+ end of a window; it will keep erasing and redrawing the thumb.
+ + Other change in the Scrollbar is that it will only draw in the rectangle:
+ 1, 1, core.width - 1, core.height - 1. It is better when creatting a 3d
+ effect with displayList's.
+
+
+Patch 4 (#1678) 3 May 1998
+
+Included the patches for the recent problems with libXaw.
+Several 'gratuitous' small changes, to compile cleanly with gcc -Wall.
+Some bug fixes for DisplayList.c.
+Colored pixmaps support. I'm building a abstraction layer for the colored
+ pixmaps, so that it should be easy to support more pixmap formats
+ (actually, only X bitmaps).
+
+
+Patch 5 (#1686) 11 May 1998
+
+ + Patch to libXmu, so that the StringToCursor converter will understand the
+ string 'None', that means not to use a cursor. This is useful when
+ overriding resource settings, and the user wants to use the parent window
+ cursor, or the root window cursor. Any unrecognized name will generate
+ a 'None' cursor, but then with a warning message.
+ + SimpleWidget was modified to allow setting the cursor to none, when it
+ was a valid cursor.
+ + Modification in the Actions.c,
+ from:
+ typedef struct _XawActionVar {
+ XrmQuark qname;
+ String value;
+ } XawActionVar;
+ to:
+ typedef struct _XawActionVar {
+ XrmQuark qname;
+ XrmQuark qvalue;
+ } XawActionVar;
+ This does not cause any problems, since the exported interface remains
+ the same. This is required to avoid to much copies of the same string.
+ + Values of action variables can start with '$'.
+ + If a resource name clashes with a special constant name when evaluating
+ a boolean expression (in the translations code), it's enough
+ start the resource name with '\\' (it can always be used, but is
+ only useful if there is a name clash :).
+ + The only code that loads data files actually is the pixmap code. To avoid
+ security problems, the code only loads files that are group readable,
+ regular file, non suid and non sgid.
+ + If the code to load a pixmap does not find a match, and the pixmap name
+ has a extension, try without the extension.
+ + Function 'line-with' added to displayList code.
+ + Added DisplayListToString and PixmapToString converters.
+ + Bug fixes in the pixmap name interpretation.
+
+
+Patch 6 (#1701) 24 May 1998
+
+ Xaw
+ ------
+ + Allows setting the resources label_x and label_y inherited from labelWidget.
+ This is useful for moving the contents of a button when it is pressed
+ ( I included a simple test for it )
+ + Added OS/2 patchs
+ + The buffer overflow problems were resolved in a different way. I added
+ a function XmuSnprintf, that is used by Xaw and Xmu.
+ + Correction of a problem in SimpleMenu, when it tries to optimize the
+ space used by the menu.
+
+ Xmu
+ -----
+ + Function XmuNCopyISOLatin1Lowered, defined in <X11/Xmu/CharSet.h>
+ + Function XmuSnprintf, defined in <X11/Xmu/SysUtil.h>
+ + All ocurrences of sprintf were replaced by XmuSnprintf and all ocurrences
+ of XmuCopyISOLatin1Lowered were replaced by XmuNCopyISOLation1Lowered.
+
+
+Patch 7 (#1738) 21 June 1998
+
+ + Corrected problem with the Command widget, when it was made insensitive
+ without calling the 'reset' action.
+ + Rework of the SimpleMenu code for optimizing the space used. Now it
+ really works as intended.
+ + Fixed portability problems with my previous patches.
+ + Corrected problem pointed by 'grano@cs.Helsinki.FI'. He have followed up
+ a bug report to the devel mailing list. While the problem exist, his
+ patch was not complete, so I did a rework of the AsciiSrc.c:Scan() and
+ MultiSrc.c:Scan() functions.
+ + I added clipping code to the {Ascii,Multi}Sink widgets, to allow use of
+ displayList's as decoration. The best solution I found to avoid too much
+ server requests, and keep full binary compatability was to use the resize
+ method of these widgets, to tell them to the parent widget have changed
+ it's size.
+ + Now the TextWidget has a xterm/emacs like cursor. And it is possible to
+ especify a cursor color.
+ + Fixed several problems caused by code assuming a line of text will be
+ shown as one line in the TextWidget. This is not always true when
+ it uses XawtextWrapLine or XawTextWrapWord, the most common problem was
+ the cursor becomming invisible, after calling the function
+ Text.c:_XawTextShowPosition() that is called to make sure it is visible ;)
+ + Added code that it will not forget the cursor distance from the left of
+ the window while moving the cursor one line up or down.
+ + Ansification of the text code (not yet complete). Private routines now
+ uses prototypes and wide parameters. External routines were kept
+ as before (but with prototypes not masked by NeedFunctionPrototypes),
+ to avoid binary compatability problems. The bigger problem I found in the
+ ansification was a function with 6 parameters being called with only 5.
+ + Several routines were rewritten, sometimes from scratch.
+ + The cursor navigation of the TextWidget was completely reviewed. It
+ should be very familiar to Emacs users. The most Emacs like behaviour is
+ when the cursor in move one line up or down and becomes invisible; the
+ text will be scrolled so that the line with the cursor will be centered
+ in the screen. Also, when doing page up, the cursor will be positioned
+ in the bottom-left, instead of allways in the top-left.
+
+Patch 8 (#1752) 27 June 1998
+
+ + There was a problem with the previous patch regarding to portability.
+ The problem was strcasecmp. I was planning to provide the funcionality
+ in libXmu, and forgot when creating the previous patch :(. There is
+ already a strcasecmp equivalent in libXmu, that is
+ Lower.c:XmuCompareISOLatin1(), so I used that function.
+ + The previous patch was working correctly for viewing text, but there were
+ some cases the text window could end not displaying correctly the text.
+ This problem was fixed.
+ + Now, the only real need of scrollbars is when doing long jumps on the
+ text, because the cursor will be always visible since this new patch
+ does horizontal scrolling automatically.
+
+
+Patch 9 (#1755) 28 June 1998
+
+ + Removed all my RCS idents in the files.
+ + Declared functions as static in the prototype and in the definition
+ (this basically reverts a previous patch, but should help when applying
+ the patches sequentially).
+ + Changed the code in Pixmap.c to use strtok instead of strsep, that is
+ not portable.
+ + Corrected problem with previous patch that would cause trouble when
+ a text widget had more than 32K bytes, and would also cause offset
+ mismatches if a program access private structures (AsciiSinkP.h).
+
+
+#1776 6 July 1998
+
+Corrected problem when moving the cursor over a non-printing character,
+ i.e. ^Q ^X
+Does not allow anymore scrolling of the text width Ctrl+Z if the text has
+ only one line, or only one line of text.
+Several changes in the TextWidget. I did not gratuitously break binary
+ compatability. Source compatability is only granted to programs that
+ do not access private structures. This is required because there are
+ several changes in the behaviour of the TextWidget, and if a program
+ becomes non compilable, it is because it will not work properly with
+ the changes in the text widget (please read bellow for a explanation)
+Better cursor navigation when moving line-up or line-down over a tab:
+ cursor
+ |
+ v
+ spaces | |#| | | |text
+ tab | |text
+ Move one line down:
+ before:
+ tab |# |text
+ now:
+ tab | |#ext
+There were several problems in the Text.c:_XawTextReplace(), when deleting
+ a character and the cursor (shoud be) moved to the previous line. This
+ problem was corrected.
+The text code was doing too much redrawing! When typping text, it would
+ redraw all the current line at each character typped, and also redraw the
+ entire window till the bottom. Now it only redraws the minimum necessary
+ (and makes a minimum of requests for the Xserver, when clearing areas),
+ most of these problems were related to Text.c:_XawTextReplace() (rewritten
+ from scratch), Text.c:_BuildLineTable() (mostly rewritten) and
+ Text.c:DisplayText() (mostly rewritten).
+Now, when selecting text, with: button1-down, button1-move, the window will
+ be scrolled automatically, if the mouse is moved to the top or bottom of
+ the text window, making it easier to extend selections.
+Added a set-keyboard-focus translation to the text code, and in the
+ default translation, it is called when pressing the left mouse button over
+ a text widget (so that the mouse does not need to be over the text window
+ when typping)
+
+These are the changes to Xaw that made it not fully source compatable (I'm
+open to comments, to make it source compatable, but as I said above, if
+a program does not compile anymore, it is because it is not granted it will
+work properly):
+scrollMode set to WhenNeeded is not supported anymore. I spent several
+ hours fighting side-effects caused when a scrollbar is created or destroyed
+ 'on demand', and have (after tired of long debug sessions) choosed that
+ it is not required (it saves a lot of potencial unespected conditions
+ being found by a user). I changed the 'type' of the scroll mode to Boolean,
+ so, to have a scrollbar, is enough to say: *Text.scrollVertical: True.
+ Since the type now is Boolean, Xt will print warning messages when the
+ scroll is set to 'Always', 'Never' or 'WhenNeeded'
+automatic resize is nonsense since the text does automatic horizontal
+ scrolling. IMHO, to be useful, automatic resize should also shrink the
+ text window when needed, anyway, it's not required anymore
+
+Comments:
+auto-fill mode does not work properly (never did)
+wrap-mode set to line may not work properly
+wrap-mode set to word does not work properly always (never did)
+the multiply should be setable to a variable value; the default value
+ is 4, i.e. Ctrl+U <text+action>
+I will work on the itens listed above, and I'm also planning:
+one level undo, for text actions
+C style indentation and 'jumping' the cursor to show matching '(', '['
+ and '{'
+other things that I don't remember now :)
+
+
+-- XMU --
+Moved the code clipping code I have put in Text.c in my previous patch to
+ Xmu/Clip.c. There was a bug in the code I have put in Text.c (this is what
+ I get by cutting and pasting code under a #if 0 :(), but it was corrected.
+ The code in the new file 'Clip.c' is very useful for creating clipiing lists
+ and thus, avoiding too much server requests, or code for the same
+ functionality (poorly) repeteated in several places around the libary. This
+ code is now heavily used by the TextWidget.
+
+
+-- XEDIT --
+Removed a XDefineCursor in xedit.c:main(). There are several ways to specify
+ a cursor for a program (most times inherited from the wm decoration window),
+ so, it is better to let the user choose one.
+Before starting the main loop, now xedit sets the keyboard focus to the
+ text window if a file was loaded, or to the prompt for a file name if
+ none was especified in the command line (do not use the new xedit without
+ the new Xaw library, or you will not be able to change the keyboard focus).
+Updated the Scrollbar configurations in Xedit.ad
+
+
+#1788 12 July 1998
+
+-- TextWidget --
+ + Corrected problem whem moving the cursor over a non-printing character
+ + Now, does not allow scroll with ^Z when there is only one line of text
+ + Automatic resize was removed, it is not required with automatic horizontal
+ scroll, but I will look for programs that rely on it; the only program
+ affected (that I know) is xmh, because it popups dialogs of a small size,
+ and expects that the text widget (with a warning message) do a geometry
+ request.
+ + Scroll mode set to "WhenNeeded" was removed. It generates several unespected
+ conditions when editing text, and the new feature of automatic scrolling
+ the text widget while typping is more useful.
+ + Removed a leak in TextAction.c:AutoFill(), generated by the code
+ text.ptr = (char *)XtMalloc(sizeof(wchar_t) * 2);
+ that memory was never released, but the fix was simple, since the amount
+ of memory requested is fixed.
+ + Several optimizations in the redisplay of the text.
+ + Now, wrap mode set to word or line is expected to work, while typping text.
+ + AutoFill will only break lines in word boundaries now.
+ + Added a set-keyboard-focus action to TextAction.c, so that when pressing
+ the left button over a text widget, it will receive the keyboard focus.
+ This behaviour is the default, but can be disabled, with something like:
+ *Text.translations: #override\n<Btn1Down>: select-start()\n
+ in your .Xdefaults.
+ + Corrected several cases that would left the text widget showing incorrect
+ data. All the problems should have been fixed, but in case you find one,
+ a quick fix is:
+ *Text.backgroundPixmap: black?foreground=<some-color>
+ because it does not try to optimize the redrawing when using a background
+ pixmap, and thus, avoid several possible problems.
+
+
+-- XAW --
+ + I had added a XawStackAlloc definition to "Private.h", to avoid a XtMalloc
+ request for every character typped in TextAction.c:InsertChar(), but
+ when syncing with 3.9Aj, saw that the file "XawAlloc.h" is no longer
+ required. Please, remove XawAlloc.h from 3.9Aj.
+
+
+-- XMU --
+ + Added the file Clip.c, with clipping code, that, now is being used by
+ the text widget, but can be used by other widgets.
+
+-- xedit --
+ + Removed a XDefineCursor from xedit.c:main()
+ + I have added a XtSetKeyboardFocus in xedit.c:main(), but comented it
+ because it would make xedit unusable with previous versions of Xaw,
+ or with the Xaw replacements (Xaw3d, Xaw95 ...)
+
+Comments:
+ I wrote a lot of code to work properly with italic fonts in the text widget,
+that code made the cursor do not erase portions of the text while moving the
+it, but it was failing at some places that would need that the TextWidget,
+and not only the {Ascii,Multi}SinkObject had access to the fonts, so I
+choosed to left it to the future (and keep the sources simple, by now).
+The text widget is useable with italic fonts, but fonts with:
+ f->per_char[<char> - f->min_char_or_byte2].rbearing
+ > f->per_char[<char> - f->min_char_or_byte2].width
+or
+ f->per_char[<char> - f->min_char_or_byte2].lbearing < 0
+will not allways be displayed correctly.
+
+ I haved also added a xedit configuration file to this mail.
+
+
+#1842 27 July 1998
+
+Fixed problem with the default macro for type conversion, where it was
+ possible to the code tell the wrong size of a string, since it was
+ returning the string size with 'strlen' but making the copy with strcpy.
+Complete ansification of Xaw (and Xmu).
+Corrected some problems caused due to an alteration in the text code, to
+ make the cursor always visible when the wrap mode is 'line' or 'word'.
+Text.c:VJump() was made a bit smarter and a problem that would cause it
+ to jump incorrectly was also corrected so that now the jumping should be
+ very smooth.
+Corrected problem that would cause a coredump due to the
+ Text.c:_XawTextReplace() deferencing a NULL pointer. Now ctx->text.lt.info
+ is initialized when the text widget is created, solving this problem.
+All the variables with name 'new' and 'class' where renamed to 'cnew' and
+ 'cclass'. This allows even building Xaw with 'gcc -x c++'.
+Variables shadowing other variables or functions where also renamed.
+Static functions were changed to use wide parameters, where applicable.
+(Almost) every time a StringTo<Type> converter is installed in the class
+ initialization of a widget, the code also installs a <Type>ToString converter
+ since now editres seens to work better.
+Complete reestilization of the indentation. See the files Template*.{c,h}.
+Corrected problem with the 'virtual' function Layout of the Form widget. That
+ function requires 4 parameters, but the Viewport widget (a Form subclass) was
+ calling that function with only 3 parameters; the ansification flagred that
+ error.
+TextTr.c was modified to have only one string. I believe that that weird
+ thing was due to the inheritance of compatability with some very old and
+ probably buggy ld.
+Xaw is expected to be binary compatable with R6.3; there are some
+ preprocessor macros that keeps binary compatability, and unless the gains
+ of breaking binary compatability show worth enough (and people think) it
+ is good that code would be made default, otherwise it will be forgotten.
+I have also added a XFree86 copyright notice to Text.c, since there is
+ a very large amount of work in that file (and it is not yet ready).
+---------------------
+
+-------- Xmu --------
+Complete ansification of Xmu.
+Rework of EditresCom.c to allow editres working correctly. It was also
+ added a new feature, that allows editres finding some extra child widgets,
+ i.e. widgets that aren't a child of a subclass of composite and aren't in
+ the popup list. This modification is not enough, since it does not find
+ child widgets that don't a XtRWidget resource in the parent widget.
+Rework of ShapeWidg.c, so that it will give the correct feeling to the
+ ellipse shape, and inversion of the oval, if shape is oval and
+ height > width. To see these changes, run a program with:
+ <prog> -xrm '*shapeStyle: ellipse'
+ and/or
+ <prog> -xrm '*shapeStyle: oval'
+Revision of DrRndRect.c to make the widget looks 'more correct' when using:
+ <prog> -xrm '*shapeStyle: roundedRectangle'
+---------------------
+
+------ editres ------
+Added small patch to bug in handler.c so that editres will correctly now.
+---------------------
+
+------- xedit -------
+Changed the resources file, to avoid a problem when resizing xedit to a
+ very small size and than restoring it's size. Probably the culprit is the
+ Paned widget, but the new resource file is at least a good workaround for
+ the problem.
+The resource file was also modified so that the default xedit size will
+ give a 80x25 rows/columns when using the default font.
+---------------------
+
+-------- xgc --------
+Small patch to clear correctly the status text window, when pressing the
+ 'Clear window' button. Note that this patch showed a bug in
+ Xaw/{Ascii,Multi}Src.c; only apply this patch with the latest Xaw, or
+ be sure that Xaw/{Ascii,Multi}Src.c:*SetValues() has something like:
+ if (old_src->ascii_src.ascii_length != src->ascii_src.ascii_length)
+ src->ascii_src.piece_size = src->ascii_src.ascii_length + 1;
+ instead of:
+ if (old_src->ascii_src.ascii_length != src->ascii_src.ascii_length)
+ src->ascii_src.piece_size = src->ascii_src.ascii_length;
+ or it will enter a infinite XtMalloc(0) loop :(
+also fixed a possible buffer overflow while searching the source of the
+ bug described above.
+---------------------
+
+#1945, 31 Aug 1998
+
+-- XAW --
+ + Corrected bug in Viewport.c:ComputeLayout(), that would put the scrollbar
+ in the incorrect position, if w->viewport.useright == True
+ + Corrected bug in Converters.c:_XawCvtCARD32ToString(), so that now it
+ will correctly format the converted value.
+ + Corrected problem in {Ascii,Multi}Src.c:Search(), that would cause a
+ incorrect offset to be returned, if the searched text (or a substring of
+ it) were in a 'Piece' boundary.
+ + Some small patches to other sections of the code, to reduce the number
+ of warnings generated by gcc, when using more restrictive warning options.
+
+-- XMU --
+ + Corrected a problem in Atoms.c:GetAtomName(), to return a NULL pointer,
+ instead of a const if the given atom is 0.
+ + Corrected a typo in Xmu.h
+ + Several 'ansification' patches, to get function definitions and avoid
+ unecessary definitions.
+
+
+#2028, 2033, 7 Oct 1998
+
+-- Xaw --
+Added a delete translation to the text widget, that deletes the current
+ selection if any, else the backwards char.
+Corrected bug that would not update correctly the screen if page-up or
+ page-down was pressed while there was an selection.
+Added a ^Q<any-char> translation to the text widget, to be able to insert
+ any char in the text.
+Changed TextAction.c:Move() to set ctx->text.showposition, so that even
+ if the cursor did not change the position, it will become visible.
+Corrected problem with the 'form-paragraph' translation, so that the
+ text will be always correclty shown.
+Modified the automatic scrolling of the text to one line at a time, to
+ make it easier to see what is being selected.
+Added a 'hack' to be able to type ^U<any-numeric-sequence> to be able
+ set the multiply of the text widget. Since it is a hack (besides seens
+ to work very well) it can be disabled with -DNO_NUMERIC_HACK
+Corrected a nasty bug in Text.c:CvtStringToScrollMode(); XtConvertAndStore
+ can't be called from a type converter!
+added UNDO/REDO to the text widget. Please try it, I think it is very nice.
+ Undo is enabled by the new resource 'enableUndo', and, by default is
+ triggered with 'Ctrl+_'.
+
+-- editres --
+Resubmitting a patch to editres/handler.c, to make editres work properly.
+
+-- xedit --
+NOTE that with this patch, xedit probably will not work with Xaw3d, neXtaw...
+ this surelly can be fixed, or in the xedit side or the *Xaw* side, but
+ the patch seens to be necessary.
+Changed the defaults file to be more user friendly and previsible.
+ Added some 'Emacs like' binding translations.
+Added file completion in the filename prompt. This is a very nice
+ feature, but I'm not sure if the code is portable to all the XFree86
+ supported platforms (surely it will not work 'as is' with OS/2).
+
+
+#2083 18 Oct 1998
+
+-- XAW --
+Changed the functions {Ascii,Multi}Sink.c:CharWidth and PaintText, to
+ improve speed, and avoid too much recalculations. On normal files, it
+ becames about 5:1 faster, but can go up to 20:1 when editting files with
+ very large lines. Besides this speed improvement, I believe it can
+ surely be made faster (based on comparition with some popular X editors).
+Changed the way the AsciiSink prints characters with value bigger than
+ 126 decimal. Now it prints DEL as ^?, and the other characters as \XXX
+ where 'X' is an octal digit. The MultiSink widget was unchanged in this
+ respect, i.e. when calling xedit with something like:
+ xedit -xrm '*international: true'
+Converted all calls to strncpy, in AsciiSrc.c to memcpy, so that the (ascii)
+ text widget will work properly with data containing nulls.
+Added a experimental 'Xaw Scan Type' XawstAlphaNumeric, that shoud make
+ edition of C (or any other language) easier in xedit (i.e. the text widget).
+ It can be tested with Ctrl-Left and Ctrl-Right, by now.
+Changed the TextWidget to handle text lines that would result in more than
+ 32767 pixels. Besides the text widget is not meant to be used in the
+ edition of binary files, this change allows it.
+Changed Text.c:TextScroll() to be smarter when calculating the offset of
+ the line table on scroll up.
+Added a nice feature, to show the matching '(', '[' or '{', when a ')',
+ ']' or '}' is typped.
+Changed TextAction.c:FormParagraph() to generate only one undo/redo step.
+
+-- xedit --
+Changed the defaults file to enable backups and made the backup suffix
+ the character '~'.
+Replaced all instances of sprintf by XmuSnprintf.
+Changed xedit to set the label when saving a file also, to reflect what
+ is being edited correctly.
+Corrected a bug in the new action 'file-completion', to replace correctly
+ the home directory, and keep correctly whatever was after the '~'. This
+ isn't the correct place to this code (xedit/commands.c), since there are
+ several other file name prompt windows in Xaw, but since it is required
+ another window to show the possible matches, I'll study a better way to
+ implement it.
+Added a 'hints' feature to xedit. Instead of a 'dead'
+ "Use Control-S and Control-R to Search." label, now it allows the label
+ string being changed at user settable intervals.
+
+
+#2205 10 Nov 1998
+
+-- xaw --
+ + Fixed some 16 bit overflows in AsciiSink.c and some cases where it would draw
+ past the end of the text window (a no-op), the overflows were not a
+ problem, but could left the text window with incorrect data.
+ + Moved the undo/redo code to TextSrc.c, and some code/data from
+ {Ascii,Multi}Src.c to TextSrc.c. The callback now is called when the
+ source is changed, or becames unchanged due to an undo/redo. Also
+ changed the Scan procedure to be a bit faster.
+ + The asciiTextWidget will now accept a source or sink object being set at
+ creation time.
+ + Fixed the 'struct XawDisplayList' being redefined when compiling Xaw under
+ SunOS.
+ + Several changes to the SimpleMenuWidget to make the geometry management
+ work correctly when adding/removing/changing menu entries at run-time.
+ + Added a 'kill-ring' feature to the TextWidget. The behaviour is identical
+ to Emacs. Pressing C-K repeteadely will merge the lines being killed, so
+ that a C-Y latter will paste all the killed lines.
+ + Added the enough glue code (and as backwards compatible as possible) to
+ allow the *src object be shared between several TextWidgets. My initial idea
+ was to make the TextWidget be able to have more than one source, but, to
+ be backwards compatible, I did the reverse (the source can have more than
+ one TextWidget).
+ + Fixed a automatic wrap bug (TextWidget) that could eat non white space
+ characters (my previous patch to this problem was completely wrong).
+
+-- xedit --
+ + Added a split-window feature to xedit. To keep xedit simple, it only allows
+ two windows at the same time: or subdivides in the vertical or horizontal.
+ + Added more some key-bindings, that should do the same as Emacs.
+
+#2291 5 Dec 1998
+
+-- Xaw (only changes to the 'text' code) --
+ + Changed the default 'piece size' from BUFSIZ to the value returned by
+ the getpagesize() function (or keep BUFSIZ if that value is smaller).
+ + Added a case sensitive option to the search popup. This is a 'hack' by
+ now, but should not cause trouble to anybody.
+ + Fixed a bug inserted when changing the code for the search, the only side
+ effect I saw was that the jumping cursor to show the matching '(', '[' or '{'
+ stopped working in my last patch.
+ + Moved back my change to the function XawTextSetSource. The 'correct' function
+ is _XawTextSetSource. This is only to make sure old code should compile
+ cleanly.
+ + Added line and column number calculation code (and a callback to tell when
+ that information changed) to the TextWidget. This was not an easy task,
+ because I tried to optimize as much as possible the code, and do relative
+ calculations, instead of scanning the entire file to count the number of
+ lines (there are several special cases, when removing/inserting text).
+ + Added the selection type XawselectAlphaNumeric. This adds one step in
+ the sequence word-line-all when doing multiclick in the text.
+ + Fixed some bugs in the 'kill ring' feature added in the last patch. Now
+ it is expected to never fail.
+ + Corrected the indentation of TextP.h, and changed more some fields. The
+ internal data of the TextWidget changed a lot, so it is not expected that
+ program code read directly the private data, at the price of requiring the
+ correct library version.
+ + Fixed a small bug in the undo code, that would 'think' the file was unchanged
+ in the incorrect position in the undo buffer.
+ + Changed the default key bindings for delete/kill word functions to use the
+ alpha numeric versions (this is better for coding, and more compatible with
+ other text editors).
+
+-- xedit --
+ + Changed the labelWindow, to show the current line number (but it is also
+ possible to show the current column number, offset or file size).
+ + Fixed bug when saving the *scratch* buffer with a new name.
+ + The 'changedBitmap' is now correctly displayed on all the windows showing a
+ changed file.
+ + Small changes to the xedit man page.
+
+
+
+#2371 8 Jan 1999
+
+--- Xaw ---
+ + More some changes to AsciiSrc.c:Scan(). This improves a bit the speed when
+ scanning text.
+ + Added sanity checking for AsciiSrc.c:Search(), to avoid the risk of
+ deferecing a null pointer (or reading memory out of the text piece) if the
+ searched text happens to be larger than a "piece size".
+ + Fixed bug when trying to optimize line number calculation, due to a typo,
+ while meaning XawTextWrapNever I wrote XawTextWrapLine.
+ + Fixed a problem shown by xclipboard, when setting the "string" resource
+ of the text source, the sink object was keeping the insertPosition in the
+ old text contents, and then, when showing the cursor, it was incorrectly
+ 'erasing' the old cursor position.
+ + Fixed problem in XawTextReplace, that would not update correctly all the
+ TextWidget's sharing the same source.
+ + Added a kill ring list to the text code. This works like the emacs feature,
+ but, unlike emacs, it is not required to press C-Y before M-Y, to start
+ looping through the kill ring list. To use it, just press M-Y repeteadly,
+ and all the text that was killed will be inserted, one at a time, so that
+ you can choose one. Note that the text inserted from the kill ring list
+ will also enter in the undo list.
+ + Changed the Move{Backward,Forward}Paragraph actions to make the cursor always
+ stop in a blank line. This makes only one step moving from a paragragh to
+ another, instead of two.
+ + Added code to check for overflows in the C-U<number> sequence.
+ + Changed the FormParagraph action to keep the cursor at the correct position.
+ + Changed the default translations in TextTr.c to get a more emacs like
+ behaviour with the kill ring list.
+
+--- xedit ---
+ + Added a few more resource settings to the Xedit-sample file.
+ + Added some sanity checkings when trying to save a file. This avoids the
+ case of saving a file with the name of a directory (but moving the directoy
+ to other name before). A possible case is: have a directory named 'dir',
+ saves a file as 'dir', but before saving, renames the directory as 'dir~'.
+ + Allows saving a file that xedit thinks is not changed (the file may have
+ changed on the disk, but the user really wants to rewrite it).
+ + Corrected several bugs in the FileCompletion action, and added a new
+ feature, that is to complete the partial names, when there is a '/' or '.'
+ after the cursor position.
+
+
+#2479 19 Feb 1999
+
+-- Xaw --
+ + Fixed bug in the line numbering code, when removing lines before the
+ top position.
+ + Changed code to form regions to always show the cursor after formatting the
+ text.
+
+-- xedit --
+ + Added code to keep the file mode, after saving. This is useful when editting
+ scripts, so that the executable flag will not be lost after edition.
+
+
+#2544 12 Mar 1999
+
+-- Xaw --
+ Mostly changes to add support to latin-* languages in the text code, when not
+ using the international resource.
+Actions.c:
+ + Corrected some bugs in the boolean expression parser. The old version would
+ not parse correclty parenthized expressions, and was giving equal precedence
+ to AND, OR and XOR (what is incorrect).
+AsciiSink.c:
+ + Changed to display characters in the range 0x32-0x7e and 0xa0-0xff literally.
+ The other characters are represented as control-codes, as before. This is
+ better for edition of Latin-* text files.
+AsciiText.c:
+ + Changed the code, so that even if the *international resource is not set,
+ _XawImRegister and _XawImUnregister are called for the text widget. This is
+ useful for latin-* locales, that use one byte wide characters, and makes Xaw
+ more compatable with modern toolkits, like qt and gtk.
+List.c:
+ + Added code to work correctly with a background pixmap.
+ + Added a smarter code for list window size calculation, that is used if the
+ number of columns is especified to be zero (automatic).
+MultiSink.c:
+ + Fixed a core-dump problem caused when passing a null pointer to
+ XwcTextEscapement.
+Text.c:
+ + Removed the resource adjustScrollbars. This resource was not used, and its
+ funcionality was not finished, and by now, it is not required.
+TextAction.c:
+ + Does not call XLookpupString in InsertChar any more, but the new function
+ _XawLookupString (in XawIm.c) to work correclty with composed characters.
+XawIm.c:
+ + Added the private function _XawLookupString, that just calls XmbLookupString,
+ or in case of any initialization error, XLookupString.
+
+-- xedit --
+ The most important change is the addition of a new functionality, that allows
+ the user to navigate the file system, in a 'ls -a' like list widget, if
+ the file is not a directory it is loaded for edition, else, the list widget
+ is rebuilt with the contents of the selected directory. To test it, just
+ type: C-X d, or tab when 'finding a file'. To exit the dirwindow without
+ loading a file, type C-G or Escape.
+Xedit-sample:
+ + Added more some resource entries, to use the new 'emacs dired like' feature.
+Xedit.ad:
+ + Same as for Xedit-sample, but more important resource settings.
+commands.c:
+ + The code now checks if the filename is a directory and calls the dirwindow
+ code in that case, when trying to open a file.
+ + Changed the function IsDir from static to global, to use it from xedit.c.
+ + Most of the code for the filesystem navigation window was added to this file.
+util.c:
+ + Fixed a bug that was causing core dump due to passing garbage to XtGetValues
+ as the widget address.
+ + Added the code for managing the dirwindow and its relationship with the
+ text windows to this file.
+xedit.c:
+ + Added the code for creation the dirwindow to this file.
+
+
+#2638 2 Apr 1999
+-- Xaw --
+ + Added xpm pixmaps support to the library. This time, it is required to
+ compile Xaw with -DUSE_XPM.
+ + If the xpm image has a mask, the widget will be automatically reshaped
+ to the pixmap mask.
+ + Changed the kill_ring code in TextAction.c to always end in a text block
+ of zero length, this way, it is easier to know when one traversed the
+ entire kill ring (it may be interesting to forget the undo sequences
+ while traversing the kill ring list).
+
+-- xedit --
+ + Changed the Xedit.ad file to avoid overriding a translation that would
+ make the search window do not respond to WM_DELETE_WINODW messages.
+ + Fixed a core dump condition in the new code for listing files and
+ directories, due to deferencing a null pointer.
+
+
+#2662 10 Apr 1999
+-- Xaw --
+ + Corrected the problems gererated in my last patch. I was compiling with
+ -DUSE_XPM defined, and did'nt realize that the patch would not compile
+ without it. Just ifdef'ed again the code to avoid warnings or dead code.
+
+-- xedit --
+ + Added a ispell interface to xedit. Sorry for not documenting enough about it
+ the man page, but here is a small explanation of the new funcionality:
+ Replace: Replace's the selected word.
+ All (right side of Replace button): Replaces all occurrences of the selected
+ word.
+ Undo: When this button is sensitive, allow undoing the last replace,
+ this is useful when doing a incorrect "Replace All" action.
+ Ignore: Ignore this word, and continues spell checking.
+ All (right side of Ignore button): Ignore any further ocurrences of the
+ selected word.
+ Add: Add's the selected word to the user's private dictionary.
+ Suspend: Go back to text edition, but does not kill the ispell process,
+ This is useful if you have a really big dictionary or slow
+ machine. I believe it is mostly useful to keep in memory
+ the words selected to be ignored, but that you don't want to
+ add to your private dictionary.
+ Close: Kill the ispell process, and go back to text edition.
+ Automatically saves the user's private dictionary.
+ When pressing the Add button, the word in the "Mispelled word:" field is
+ added to the user private dictionary (normally ~/.ispell_*). When pressing
+ the Replace button, the text in the "Replace with:" field is used.
+ If no word is selected in the "Suggestions:" field, this mean that the
+ selected word was not found in the ispell dictionary.
+
+
+#2716 24 Apr 1999
+-- Xaw --
+ + Minor changes to AsciiSrc.c to try to get more speed in the FindPiece
+ function. Xedit may become very slow when editing files bigger than 1M,
+ and I'm studing ways to get more speed in the Scan and FindPiece functions.
+ The FindPosition function in *Sink.c also can consume a lot of cpu time,
+ and may need some rework.
+ + Added submenus support to the SimpleMenuWidget. This is something essencial
+ to a widget toolkit. Just plugged in the code of a menu widget I wrote some
+ time ago. Xedit uses submenus now. To use it, set the resource menuName
+ of a SmeBSBObject to the name of the submenu.
+ + Added code for text justification to the TextWidget. To use the justification,
+ set the resources autoFill, leftColumn and rightColumn. If autoFill is set,
+ and leftColumn is smaller than rightColumn, an alternate code will be
+ used in the form-paragrpah action, normally triggered with M-Q. The values
+ for justification can be left, right, center and full.
+ + Added a overwrite mode to the TextWidget. The default translation is to
+ press the Insert key, that will toggle the overwrite mode.
+ + Made the TextWidget understand negative values for the multiply. This is
+ like the emacs feature, to indent text to the left. To set a negative value
+ to the multiply, just start the numeric sequence with a '-'. Like C-U -1.
+ + The code for justification added several new functions to TextAction.c.
+ Functions to tabify, untabify, get block boundaries, verify if a line
+ is completely blank, and strip excess of spaces.
+ + Added a indent action to the TextWidget. The default translation, only
+ used by xedit, is C-X Tab, did this way, to make it fully compatable with
+ emacs, but other translations can be used. The multiply value is used to
+ calculate the amount of spaces to move to the left or right.
+ + Corrected a very hard to find (and reproduce) bug in the undo code, that
+ would easily cause core dumps. The problem would happen when starting
+ editing exactly in the moment the redo automatically reverts to undo.
+ + Added translations for toggling the overwriting mode with the Insert key,
+ and to paste the selection with S-Insert.
+
+-- xedit --
+ + Corrected all the known bugs in the ispell code (including a memory leak).
+ And added a compile time limit of 16 levels of undo, for all the actions,
+ that include Add, Ignore and Replace. 16 levels is more than enough, but
+ more than this can be done with the undo action, but then, only to revert
+ replaced text, to remove added words that the undo code forgot, it is
+ required to edit the personal dictionary file. The code now also understands
+ root/affix combinations, that ispell normally returns when using the
+ -m option. The ispell code should now also work when using the international
+ resource of the edit window.
+ + Added a new file, called options.c, that holds the code for the editMenu,
+ to enabling setting the wrap, autoFill, justify, leftColumn, rightColumn,
+ verticalScroll and horizontalScroll resources of the current edit window.
+
+
+#2746 1 May 1999
+-- Xaw --
+ + Reverted most of the #if NeedWidePrototypes definitions, only two
+ functions were kept, to not break some of the new features, but these
+ functions aren't called by any program: XawTextSinkDisplayText and
+ XawTextSinkClearToBackground.
+ + Rewrite of the functions *Sink.c:FindPosition() and FindDistance() to
+ try to get more speed.
+ + Reworked the function Text.c:_BuildLineTable, to correct some strange
+ code, and to avoid unecessary recalculations.
+ + Made negative values of the multiply work for all the actions, not only
+ for negative indentations. This makes the TextWidget behaviour more
+ compatable with emacs.
+ + Optimization of the new code for text justification, to avoid a call to
+ malloc on every char typped, when undo is enabled.
+ + Reorganized the offsets of the fields of the TextWidget, trying to make
+ xxgdb work again with the new Xaw code, but, unfortunately, the SimpleWidget
+ (a subclass of the TextWidget) have growed by 4 bytes (a XawDisplayList*)
+ added at the end of the structure, and xxgdb incorrectly reads the text.sink
+ field. Old xxgdb binaries dont work with the current code.
+ + Removed several XtIsSubclass checks in TextSrc.c. While those checks could
+ be useful for debugging, the functions are called so frequently that it is
+ a big waste of time for running programs.
+
+-- xedit --
+ + Added/Changed some translations to work correctly when CapsLock and/or NumLock
+ are pressed.
+ + Fixed some bugs in the ispell code. The biggest bug was that it was not
+ correctly saving the Add'ed words in the user dictionary when pressing the
+ Close button.
+
+
+#2764 8 May 1999
+-- Xaw --
+ + Create two new private functions, to replace internally the public interfaces.
+ These two functions are XawTextSinkClearToBackground and
+ XawTextSinkDisplayText. These two functions use wide prototypes, and
+ are required to support text lines that are represented by more than
+ 32767 pixels. This was done to make sure that the public interfaces remain
+ 100% backwards compatible.
+ + Fixed the deferencing of a null pointer when the source object of a text
+ widget is not initialized. I noticed this problem when recompiling xcolorsel.
+ + Added a new type converter to Converters.c, that is Short -> String.
+ + Added a new compile time option, called NO_BIN_COMPAT_HACK. If defined,
+ it will break some programs that access private data. It only works with
+ programs that access private data structures, but don't subclassify any
+ widget. It fixed old binaries of chimera1, the Offix editor and xxgdb.
+ There is no way to fix old binaries of chimera2, xcolorsel and xmh, these
+ programs need to be recompiled. I would like to know of other programs that
+ became broken, to try to fix them with the NO_BIN_COMPAT_HACK option.
+ + Fixed some compile warnings, with shadowed, uninitialized and unused
+ variables.
+ + Fixed a inifite loop problem that could happen when the text widget window
+ was resized to a very small width.
+ + Reverted some of the text widget translations, to avoid conflicts when
+ setting the input focus and programs that do so.
+
+-- xedit --
+ + Fixed a problem in the file-completion code, that would insert the partial
+ match in the incorrect position, if the cursor was not at the end of the
+ string.
+ + Changed ispell.c to use only one hash for ignored and added words. Also
+ changed the IspellSend function to not call itself recursively, what is
+ a big problem when spell checking big files that are correct or have too
+ few errors.
+
+-- editres --
+ + Changed Editres.ad in several places, to try to avoid resource setting
+ problems. Most of them were changed to address more directly the resource,
+ and avoid confusion. Also, added some new resource settings to configure
+ the code I added to widgets.c.
+ + Changed widgets.c to make sure the resource setting dialog is allways
+ entirely in the screen, and if it does not fit, scrollbars will be created.
+
+
+#2793 15 May 1999
+-- Xaw --
+ + Changed AsciiSrc.c:LoadPieces to load the file incrementally, instead of
+ allocating a big buffer.
+ + Added several new functions to DisplayList.c. Almost all gc and painting
+ related functions were mapped to displayList functions. There are
+ several optimizations that can yet be done to the displayList code, and
+ I'm working on it. That code is clearly not finished yet, but is stable.
+ Also, changed some functions to be more exigent with it's parameters,
+ because it is better to receive a warning message than see the program
+ core dumping. The functions are documented in Xaw.man.
+ + Corrected a problem in the SimpleMenu code, to make the sub menus popup
+ more 'visually' correct, when popping up in the left side.
+ + Added a optimization in Text.c, to avoid unnecessarily recalculating
+ the line and column number when scrolling text. A big speed up should
+ be seen when scrolling large files.
+ + Modified all code that expected TAB_SIZE to be equal to 8, to read the
+ TextSink resources, and work properly with whatever value the program
+ had set to the tab stops.
+ + Fixed a very bad bug in the form-paragraph function. It was very hard
+ to find because I was looking at the wrong places. If the text was
+ allready formatted, or did not need formatting, the code was not
+ reenabling undo, making the undo/redo behaviour imprevisible.
+
+-- xedit --
+ + Added Xedit-color.ad file, to show some of the new features of Xaw.
+ Tried to keep it simple, but since it uses gradients, maybe it should
+ better be called Xedit-TrueColor. The better way to see the functionality
+ of this file is (if you don't have it already) add to your .Xdefaults:
+#ifdef COLOR
+*customization: -color
+#endif
+ and make sure xrdb parses it.
+ + Changed a bit Xedit.ad, to work properly when Caps Lock is pressed.
+ + Several changes to ispell.c. It should run very faster now, because
+ the code keeps information about words already ignored or correct
+ in the xedit side, instead of asking ispell every time. Added also
+ a terseMode resource, and made the interface ask for user interaction
+ allways ispell does not say the word is completely correct; the
+ terseMode resource makes ispell itself decide what words are correct
+ or not.
+
+-- editres --
+ + Small patch to Edit-col.ad, to use a default text cursor color of 'Azure'
+ in text fields, instead of the default 'black'.
+
+
+#2811 22 May 1999
+-- Xaw --
+ + Removed the 'NO_NUMERIC_HACK' preprocessor definition, and renamed the
+ 'doing_numeric_hack' field of the text widget to 'numeric'.
+ + Changed the code to always create the horizontal scrollbar, if requested.
+ + Small changes to TextPop.c, to automatically scroll horizontally the
+ text window when the text found in a search/replace action is not visible.
+ + Added a optimization when editting large files, to rebuild the line table
+ if the region containing the text being added/replaced overlaps the lt.top
+ field of the text widget.
+ + Changed the undo code to also merge text typed when overwrite mode is
+ active. The new behaviour is not like emacs (that generates a undo step
+ for every character), but uses less memory, making only one undo/redo step.
+
+-- xedit --
+ + Added a new file, hook.c that is intended to be used for the addition of
+ some new features to xedit, like auto indentation of program files. The
+ first feature added is the 'autoReplace' resource, described in the xedit
+ man page.
+ + Corrected a bug in ispell.c, that would make the code alocate lots of
+ memory unnecessarily, due to an uninitialized variable. Thanks to David
+ Dawes that found the bug. The bug was not in 3.9Pn, but the solution in
+ the later release was not completely correct.
+
+
+#2834 29 May 1999
+-- Xaw --
+ + Added a ChangeSensitive function to Command.c, to avoid it creating an
+ incorrect insensitive border if the button is set. This is a side effect of
+ the function XawCommandToggle I added some time ago. The solution for the
+ problem is not very elegant, since it copies almost verbatim the code from
+ Simple.c, but it works as expected.
+ + Moved some calls to _XawTextSetLineAndColumnNumber in Text.c to other places,
+ to make sure it is safe to change the text when the positionCallback is
+ called (like what is done by the new xedit file hook.c).
+ + Another optimization was added to the undo/redo code. Now it also merge
+ erases, needing yet less memory for undo, and this way, generating less
+ undo/redo steps.
+ + Removed the default translation to call the toggle-overwrite action from
+ TextTr.c. Only the xedit edit windows calls this translation now, instead of
+ every text widget.
+
+-- xedit --
+ + Changed the auto replace feature to be a bit more easier to use. The new
+ behaviour is almost identical, but if the user types some text, and it is
+ auto replaced, only one undo step is enough to correct it. Example:
+ 1) user types 'nto.'
+ 2) text is auto replaced by 'not.'
+ 3) user call undo action
+ 4) text is converted to 'nto.'
+ It should be a very infrequent problem, but makes the xedit behaviour
+ identical to a "well known text editor", from where this feature was borrowed.
+ + Added a 'Check' button to the ispell interface. This button allows
+ checking the word in the text field. This feature was borrowed from the spell
+ checking interface of the Netscape html editor.
+ + The ispell checking interface now also asks for user interaction if there are
+ two identical words togheter.
+ + Added a status bar to the ispell interface, to give feedback to the user
+ about what is happening.
+ + Added some new resources, to let easier customization of the ispell status
+ bar strings. The new resources are documented in xedit.man.
+
+#2849 5 Jun 1999
+-- Xaw --
+ + Add a OLDXAW define, to enable building a binary compatible version with
+ 6.1, and changes to the Imakefile, to try to keep the changes only in Xaw.
+ I hope it can be removed in the future.
+ + Add a XawVendor define, with the value "XFree86". If this is not a good
+ idea, please correct it an let me know.
+ + Add a XawVersion define. The value for the new xaw is 7000L, and for the
+ compatible one is 6700L (same comments as for the XawVendor define).
+ + Bug fixes to the undo/redo code, and code to merge erases generated by
+ ^H and ^D. Also, if the cursor is moved, it stops merging the text typped
+ in the undo buffer.
+ + Bug fixes to the Form widget geometry management code, to work correctly
+ when child widgets are removed or added at run time.
+ + Xaw now links with XPM by default, and the config files where changed to
+ enable newly compiled programs to do so.
+ + Added 16 pad bytes to every widget, to try to avoid binary compatability
+ problems in the future.
+ + Added a displayList resource to the Tree Widget.
+ + Added the functions XawTextGetSink and XawTextLastPosition, to enable a
+ public way to get the <TextWidget>->text.sink and <TextWidget>->text.lastPos,
+ since these are the most commonly private fields the programs access in
+ the text widget.
+ + Added the actions 'capitalize-word', 'donwcase-word' and 'upcase-word' to
+ TextAction.c. The bindings are the same as of Emacs (and the way it works).
+ + Corrected some problems with negative values of the <TextWidget>->text.mult.
+
+-- xedit --
+ + Correct possible problem in the file hook.c, when interpreting the auto
+ replace list, that is, it was not checking the buffer size when finding
+ the '\' character.
+ + Updates for the configuration files.
+ + Added a 'Look' button the the ispell interface, that will by default run
+ "/usr/bin/bin/egrep -i '^<VALUE OF TEXT FIELD>.*$' /usr/share/dict/words"
+ and put up to 256 returned words in the ispell list. The behavior is
+ almost identical to the one in the terminal interface of ispell.
+ + The ispell interface works correctly with aspell now.
+ + Added some resources and a popup to enable changing the dictionaries in
+ run time.
+ + Added a toggle button to the ispell interface to allow changing the terse
+ mode in run-time.
+ + Added a 'Uncap' button, to allow adding an uncapitalized word to the
+ private dictionary, and enough code to do the capitalization checks inside
+ of xedit (to enable undo actions).
+ + Added a "text mode" and a "html mode". The html mode is not yet completely
+ finished. It must work correctly with some html specific things like
+ converting internally "&aacute;" to "á" and so on. I'm planning also, at
+ least a nroff mode too.
+ + The wordChars resource is set by dictionary now.
+ To set the word chars for the br dictionary, write something like:
+ *ispell*options.dictionaries.br.wordChars: <VALUE>
+ or
+ *ispell*br.wordChars: <VALUE>
+ or simply
+ *ispell*wordChars: <VALUE>
+ + The skipLines resource is set only for the text mode now.
+ To set it, write something like:
+ *ispell*options.formats.text.skipLines: <VALUE>
+ or
+ *ispell*options*text.skipLines: <VALUE>
+ or simply
+ *ispell*skipLines: <VALUE>
+
+
+#2877 12 Jun 1999
+-- Xaw --
+ + Note: The compatible old version of Xaw is not fully compatible. There
+ a few things that are not equal to the standard old Xaw. These are:
+ + The cursor code in the *Sink.c files is not identical, and the
+ field insertCursorOn (type Pixmap) was replaced by the field
+ cursor_position (type XawTextPosition).
+ + There are some changes in TextP.h, that include changes to the fields:
+ options -> left_margin
+ unrealize_callbacks -> pad1
+ updateFrom -> update
+ updateTo -> pad2
+ numranges -> pad3
+ maxranges -> from_left
+ copy_area_offsets -> pad4
+ + The text window does not increase its size when text is typed past
+ the end of the window, instead of it, it is automatically scrolled
+ horizontally, but this may not be enough to every usage of this
+ feature; xmh uses that code to make the text widget auto resize
+ warning popup widgets. I dont know what is better in this case,
+ if re-enabling the auto resize code of changing xmh to use label
+ widgets in the warning popups.
+ It is very unlikely that exists code that will have problems with these
+ changes in the fields of the TextWidget and the *SinkObject, but if any
+ code that has trouble with it exists, I will promptly make the required
+ changes to correct it (at least for the compatible version of Xaw).
+ + Several optimizations for the code to redisplay the text window in the
+ TextWidget. Including fixes for bugs in the XawTextScroll function, and
+ making it really works. Previous versions of the library have made this
+ function ineffective, because it was always redrawing everything when
+ the text window was scrolled. The optimizations should be more noticeable
+ when running some application that uses the TextWidget (like xedit) on
+ slow hardware, or over slow connections.
+ + Corrections for the FormWidget geometry management code, to work correctly
+ in the old version of Xaw, and some bug fixes for the new Xaw. Also added
+ 8 pad bytes to the FormConstraintsPart structure, to have space for extra
+ information on possible future optimizations for the FormWidget geometry
+ management code.
+ + Some fixes for the OLDXAW define in the SimpleMenuWidget code, that was
+ not hiding some of the new fields introduced in the new Xaw code.
+ + Some corrections for the code handling the necessity of having scrollbars
+ in the text widget, and bug fixes for cases where the scrollbars were not
+ being updated when the text window contents were changed.
+ + Re-enabled code to also process GraphicsExpose events in the text code. It
+ became required due to the optimizations in the text redisplay code.
+ + Several fixes in TextAction.c, for symbols that were not being included
+ in the compatible version of the library, and for symbols that were being
+ included with no need.
+ + Fixes for the form-paragraph action, in the old Xaw code.
+
+-- xedit --
+ + Some bug fixes for the ispell undo code, to avoid deferencing a NULL pointer
+ in the function IspellCheckUndo.
+ + Added code to handle correctly &<VALUE>; in ispell.c, when using the html
+ mode.
+ + Fixed some compile time warnings, and updated the code for setting the
+ scrollbars in options.c.
+
+
+#2899 19 Jun 1999
+-- Xaw --
+ + Changed all the 'char pad[<number>]' to 'XtPointer pad[<number>/4]' to
+ make sure 64 bit machines will not have binary compatibility problems before
+ the 32 bit ones.
+ + Added a new static function 'WritePiecesToFile' to AsciiSrc.c, to avoid
+ allocation of temporary memory. This is useful when editing very large
+ files (I have some people using xedit on text files that can have up to
+ 80,000 lines).
+ + Added more some optimizations to AsciiSrc.c:Scan, to try to get the maximum
+ speed of this function.
+ + Added a new function to the displayList's, called 'image', that will tile
+ pixmaps on the widget. It is documented in Xaw.man.
+ + Several widget classes did not have a 'extension' field. I added it to them.
+ The first usage of this field that I'm planning is to extend the *Src and
+ *Sink objects to handle formatted text, and add text properties, like
+ foreground, background, font and so on.
+ + Fixed a bug in MultiSrc.c, that was crashing Xaw after the first character
+ was typed, or if text was removed.
+ + Some minor changes to SimpleMenu.c, to work properly with very large menus.
+ + Fixed some bugs that were caused by my previous optimizations of the text
+ redisplay code.
+ + Bug fixes and optimizations to TextPop.c, there were some cases that the
+ function XawTextDisableRediplay was being called, but XawTextEnableRedisplay
+ was not being called later because of a error condition (the error
+ conditions were only warnings).
++ Updates to Xaw.man.
+
+-- xedit --
+ + Fixed a memory leak when freeing list widget strings. The code was not
+ releasing the memory of the string at offset 0, in the list.
+ + Changed the way the ispell undo code handles the terse mode, to not need
+ to make the toggle button insensitive.
+ + Updated xedit.man.
+
+
+#2932 26 Jun 1999
+-- Xaw --
+ + Added a new tip resource to the SimpleWidget. This may also be seen as
+ a test of the binary compatibility issues. Besides of being a new feature,
+ it cannot cause problems with old binaries, because the code is only
+ called if the tip resource is set to any SimpleWidget subclass. If the
+ tip resource is set or reset, the SimpleWidget code will call one of the
+ two new functions XawTipEnable or XawTipDisable.
+ + Added 3 new files: Tip.c, Tip.h and TipP.h. These files are used only
+ by the new Xaw.
+ + Updates to Xaw.man, including a problem with accented characters on SunOS.
+
+-- xedit --
+ + Added resource configurations to show the new tip code in Xaw.
+ + Some fixes to ispell.c, to make it more previsible/user-friendly.
+ + Fixes xedit.man to avoid problems with accented characters.
+
+
+#2964 3 Jul 1999
+-- Xaw --
+ + Fix for problem found in the search/replace dialog when using splitted
+ windows in xedit.
+ + Added initialization for the display_list field of the Tree widget.
+
+-- xedit --
+ + Fixed some problems in the undo code of ispell interface.
+
+
+#2999 10 Jul 1999
+-- Xaw --
+ + Added code to check the return value of XAllocColor and XAllocNamedColor in
+ Pixmap.c.
+ + Reverted back some code, and did a carefull review of the code in TextPop.c
+ to avoid the possibility of calling XawTextDisableRedisplay, and not calling
+ XawTextEnableRedisplay later (due to errors or end of file reached).
+ + Added code to TextSrc.c, to use two static variables, that represent a new
+ line in 8 bits and wchar_t, to avoid allocating memory in the undo buffers
+ to store only a new line.
+ + Small change in the behavior of the Tip widget, to not unmap the tip window
+ when the cursor is moved.
+
+-- Xmu --
+ + Fixed a bug and a typo in the XmuToupper macro.
+
+-- xedit --
+ + Small update to the Xedit-sample file.
+ + Fixed a bug in the ispell code that checks for repeated words.
+
+
+#3122 14 Aug 1999
+-- Xaw --
+ + Mixed fonts and colors can be used in the text widget (currently only
+ in the Ascii*Object).
+ + Added the XawTextAnchor, XawTextEntity, XawTextProperty, XawTextPropertyList,
+ XawTextPaintStruct, XawTextPaintList and XawTextPropertyInfo structures to
+ Xaw, to be used in the new text code.
+ + Added the functions XawTextSourceAddAnchor, XawTextSourceNextAnchor,
+ XawTextSourcePrevAnchor, XawTextSourceRemoveAnchor and
+ XawTextSinkConvertPropertyList, that probably should not be used outside of
+ Xaw.
+ + Added the functions XawTextSourceFindAnchor, XawTextSourceAnchorAndEntity,
+ XawTextSourceAddEntity, XawTextSourceClearEntities and XawTextSinkGetProperty
+ that are probably the ones that should be most used in programs.
+ + Italic fonts should be always displayed correctly.
+ + The text widget cursor is now displayed with a gc with the Xor function, to
+ avoid unnecessary computation/redrawing.
+ + Most changes were done in the {Ascii,Text}{Src,Sink}Object, but the text
+ widget was also a bit modified for things like automatically changing the
+ number of lines in the line table when needed.
+
+-- Xmu --
+ + Fixed bug in Clip.c, that could cause a SEGV.
+
+-- xedit --
+ + Added the file c-mode.c, to interface with the new Xaw text code, and show
+ what can be done when interfacing that new code.
+ + Added the necessary code to util.c and options.c to let the user select
+ if he or she wants to use the color/font syntax highlight in the C/C++ mode.
+
+
+# 26 Aug 1999
+
+--Xaw--
+ + Added initial support for two new XawTextEntity attributes, that enable
+ hidden text and replaced text. This initial support was the minimum
+ required to get the new html mode in xedit working. A lot of code does
+ math with text positions, and became broken with the addition of these
+ two attributes. Since only code that knows about these two attributes
+ should use it, it is only a question to fix the remaining code in
+ Xaw/xedit.
+ + Bug fixes to AsciiSink.c:PreparePaint to work correctly with tabs and
+ the two new entity attributes.
+ + Disabled the translation "c<Key>q,<Key>Tab" of the search/replace popup.
+ This action is already done by the translation "<Ctrl>Q,<Key>" that I added
+ to TextTr.c. Disabling that translation has the advantage that now it
+ is possible to replace ^Ms by nothing.
+ + Added some new functions to TextSink.c. The functions XawTextSinkCopyProperty,
+ XawTextSinkAddProperty and XawTextSinkCombineProperty are candidates to being
+ public in the future, but, there is a problem when using
+ XawTextSinkCombineProperty, that requires the AsciiSinkObject having the
+ correct XawTextPropertyList, what can generate a "chicken and egg" like
+ problem (I did some hacks in xedit to have the first html-mode version
+ working).
+ + Added several new flags to the XawTextProperty attributes, and a new field,
+ called xlfd_mask.
+ + Some bug fixes to XawTextSourceReplace and to the code to manage the
+ XawTextAnchor e XawTextEntity structures. The form-paragraph, called with
+ M-Q does several consecutive text changes, and was very useful to find bugs.
+ + The flag XAW_TENTF_REPLACE is a hack for XawTextSourceAddEntity currently.
+ The function XawTextSourceAddEntity will probably change its parameters
+ to receive a structure pointer, or a pointer parameter.
+
+--xedit--
+ + Fixed some bugs in c-mode.c. Again, this patch fixes all the bugs I have
+ found.
+ + Added the html-mode.c file to xedit. The html-mode is in its initial steps.
+ It is not usable yet, but should not core-dump or leak memory (unless you
+ try to edit the file, then, I cannot say what will happen). The html mode
+ should be used only to see a rendered version of the file, but, there are
+ several markups not implemented. To be usable, it must yet understand at
+ least <ul>, <ol>, <li>, <dl>, <dd>, <hr> and the table tags.
+
+
+
+$XFree86: xc/lib/Xaw/Changelog,v 3.31 1999/08/15 13:00:31 dawes Exp $
diff --git a/nx-X11/lib/Xaw/Command.c b/nx-X11/lib/Xaw/Command.c
new file mode 100644
index 000000000..fdab1b1ba
--- /dev/null
+++ b/nx-X11/lib/Xaw/Command.c
@@ -0,0 +1,660 @@
+/* $Xorg: Command.c,v 1.5 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Command.c,v 1.15tsi Exp $ */
+
+/*
+ * Command.c - Command button widget
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/extensions/shape.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Drawing.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xaw/CommandP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+#define DEFAULT_HIGHLIGHT_THICKNESS 2
+#define DEFAULT_SHAPE_HIGHLIGHT 32767
+#define STR_EQUAL(str1, str2) (str1 == str2 || strcmp(str1, str2) == 0)
+
+/*
+ * Class Methods
+ */
+static void XawCommandClassInitialize(void);
+static void XawCommandDestroy(Widget);
+static void XawCommandInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawCommandRealize(Widget, Mask*, XSetWindowAttributes*);
+static void XawCommandResize(Widget);
+static void XawCommandRedisplay(Widget, XEvent*, Region);
+static Boolean XawCommandSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
+static void XawCommandGetValuesHook(Widget, ArgList, Cardinal*);
+static Bool ChangeSensitive(Widget);
+
+/*
+ * Prototypes
+ */
+static GC Get_GC(CommandWidget, Pixel, Pixel);
+static void PaintCommandWidget(Widget, XEvent*, Region, Bool);
+static Region HighlightRegion(CommandWidget);
+static Bool ShapeButton(CommandWidget, Bool);
+static void XawCommandToggle(Widget);
+
+/*
+ * Actions
+ */
+static void Highlight(Widget, XEvent*, String*, Cardinal*);
+static void Notify(Widget, XEvent*, String*, Cardinal*);
+static void Reset(Widget, XEvent*, String*, Cardinal*);
+static void Set(Widget, XEvent*, String*, Cardinal*);
+static void Unhighlight(Widget, XEvent*, String*, Cardinal*);
+static void Unset(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * Initialization
+ */
+static char defaultTranslations[] =
+"<Enter>:" "highlight()\n"
+"<Leave>:" "reset()\n"
+"<Btn1Down>:" "set()\n"
+"<Btn1Up>:" "notify() unset()\n"
+;
+
+#define offset(field) XtOffsetOf(CommandRec, field)
+static XtResource resources[] = {
+ {
+ XtNcallback,
+ XtCCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(command.callbacks),
+ XtRCallback,
+ NULL
+ },
+ {
+ XtNhighlightThickness,
+ XtCThickness,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(command.highlight_thickness),
+ XtRImmediate,
+ (XtPointer)DEFAULT_SHAPE_HIGHLIGHT
+ },
+ {
+ XtNshapeStyle,
+ XtCShapeStyle,
+ XtRShapeStyle,
+ sizeof(int),
+ offset(command.shape_style),
+ XtRImmediate,
+ (XtPointer)XawShapeRectangle
+ },
+ {
+ XtNcornerRoundPercent,
+ XtCCornerRoundPercent,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(command.corner_round),
+ XtRImmediate,
+ (XtPointer)25
+ },
+};
+#undef offset
+
+static XtActionsRec actionsList[] = {
+ {"set", Set},
+ {"notify", Notify},
+ {"highlight", Highlight},
+ {"reset", Reset},
+ {"unset", Unset},
+ {"unhighlight", Unhighlight}
+};
+
+#define SuperClass ((LabelWidgetClass)&labelClassRec)
+
+CommandClassRec commandClassRec = {
+ /* core */
+ {
+ (WidgetClass)SuperClass, /* superclass */
+ "Command", /* class_name */
+ sizeof(CommandRec), /* size */
+ XawCommandClassInitialize, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ XawCommandInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XawCommandRealize, /* realize */
+ actionsList, /* actions */
+ XtNumber(actionsList), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ False, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ XawCommandDestroy, /* destroy */
+ XawCommandResize, /* resize */
+ XawCommandRedisplay, /* expose */
+ XawCommandSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ XawCommandGetValuesHook, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ defaultTranslations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* simple */
+ {
+ ChangeSensitive, /* change_sensitive */
+ },
+ /* label */
+ {
+ 0, /* not used */
+ },
+ /* command */
+ {
+ 0, /* not used */
+ },
+};
+
+WidgetClass commandWidgetClass = (WidgetClass)&commandClassRec;
+
+/*
+ * Implementation
+ */
+static GC
+Get_GC(CommandWidget cbw, Pixel fg, Pixel bg)
+{
+ XGCValues values;
+
+ values.foreground = fg;
+ values.background = bg;
+ values.font = cbw->label.font->fid;
+ values.cap_style = CapProjecting;
+
+ if (cbw->command.highlight_thickness > 1)
+ values.line_width = cbw->command.highlight_thickness;
+ else
+ values.line_width = 0;
+
+ if (cbw->simple.international == True)
+ return (XtAllocateGC((Widget)cbw, 0,
+ GCForeground | GCBackground | GCLineWidth |
+ GCCapStyle, &values, GCFont, 0));
+ else
+ return (XtGetGC((Widget)cbw,
+ GCForeground | GCBackground | GCFont | GCLineWidth |
+ GCCapStyle, &values));
+}
+
+/*ARGSUSED*/
+static void
+XawCommandInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ CommandWidget cbw = (CommandWidget)cnew;
+ int shape_event_base, shape_error_base;
+
+ if (!cbw->label.font) XtError("Aborting: no font found\n");
+
+ if (cbw->command.shape_style != XawShapeRectangle &&
+ !XShapeQueryExtension(XtDisplay(cnew), &shape_event_base,
+ &shape_error_base))
+ cbw->command.shape_style = XawShapeRectangle;
+
+ if (cbw->command.highlight_thickness == DEFAULT_SHAPE_HIGHLIGHT) {
+ if (cbw->command.shape_style != XawShapeRectangle)
+ cbw->command.highlight_thickness = 0;
+ else
+ cbw->command.highlight_thickness = DEFAULT_HIGHLIGHT_THICKNESS;
+ }
+
+ cbw->command.normal_GC = Get_GC(cbw, cbw->label.foreground,
+ cbw->core.background_pixel);
+ cbw->command.inverse_GC = Get_GC(cbw, cbw->core.background_pixel,
+ cbw->label.foreground);
+ XtReleaseGC(cnew, cbw->label.normal_GC);
+ cbw->label.normal_GC = cbw->command.normal_GC;
+
+ cbw->command.set = False;
+ cbw->command.highlighted = HighlightNone;
+}
+
+static Region
+HighlightRegion(CommandWidget cbw)
+{
+ static Region outerRegion = NULL, innerRegion, emptyRegion;
+ XRectangle rect;
+
+ if (cbw->command.highlight_thickness == 0 ||
+ cbw->command.highlight_thickness > Min(XtWidth(cbw), XtHeight(cbw)) / 2)
+ return (NULL);
+
+ if (outerRegion == NULL) {
+ /* save time by allocating scratch regions only once. */
+ outerRegion = XCreateRegion();
+ innerRegion = XCreateRegion();
+ emptyRegion = XCreateRegion();
+ }
+
+ rect.x = rect.y = 0;
+ rect.width = XtWidth(cbw);
+ rect.height = XtHeight(cbw);
+ XUnionRectWithRegion(&rect, emptyRegion, outerRegion);
+ rect.x = rect.y = cbw->command.highlight_thickness;
+ rect.width -= cbw->command.highlight_thickness * 2;
+ rect.height -= cbw->command.highlight_thickness * 2;
+ XUnionRectWithRegion(&rect, emptyRegion, innerRegion);
+ XSubtractRegion(outerRegion, innerRegion, outerRegion);
+
+ return (outerRegion);
+}
+
+/***************************
+* Action Procedures
+***************************/
+static void
+XawCommandToggle(Widget w)
+{
+ CommandWidget xaw = (CommandWidget)w;
+ Arg args[2];
+ Cardinal num_args;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNbackground,
+ xaw->label.foreground); ++num_args;
+ XtSetArg(args[num_args], XtNforeground,
+ xaw->core.background_pixel); ++num_args;
+ XtSetValues(w, args, num_args);
+}
+
+/*ARGSUSED*/
+static void
+Set(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ if (cbw->command.set)
+ return;
+
+ XawCommandToggle(w);
+ cbw->command.set= True;
+}
+
+/*ARGSUSED*/
+static void
+Unset(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ if (!cbw->command.set)
+ return;
+
+ cbw->command.set = False;
+ XawCommandToggle(w);
+}
+
+/*ARGSUSED*/
+static void
+Reset(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ if (cbw->command.set) {
+ cbw->command.highlighted = HighlightNone;
+ Unset(w, event, params, num_params);
+ }
+ else
+ Unhighlight(w, event, params, num_params);
+}
+
+/*ARGSUSED*/
+static void
+Highlight(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ if (*num_params == (Cardinal)0)
+ cbw->command.highlighted = HighlightWhenUnset;
+ else {
+ if (*num_params != (Cardinal)1)
+ XtWarning("Too many parameters passed to highlight action table.");
+ switch (params[0][0]) {
+ case 'A':
+ case 'a':
+ cbw->command.highlighted = HighlightAlways;
+ break;
+ default:
+ cbw->command.highlighted = HighlightWhenUnset;
+ break;
+ }
+ }
+
+ if (XtIsRealized(w))
+ PaintCommandWidget(w, event, HighlightRegion(cbw), True);
+}
+
+/*ARGSUSED*/
+static void
+Unhighlight(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ cbw->command.highlighted = HighlightNone;
+ if (XtIsRealized(w))
+ PaintCommandWidget(w, event, HighlightRegion(cbw), True);
+}
+
+/*ARGSUSED*/
+static void
+Notify(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ /* check to be sure state is still Set so that user can cancel
+ the action (e.g. by moving outside the window, in the default
+ bindings.
+ */
+ if (cbw->command.set)
+ XtCallCallbackList(w, cbw->command.callbacks, (XtPointer) NULL);
+}
+
+static void
+XawCommandRedisplay(Widget w, XEvent *event, Region region)
+{
+ PaintCommandWidget(w, event, region, False);
+}
+
+/*
+ * Function:
+ * PaintCommandWidget
+ * Parameters:
+ * w - command widget
+ * region - region to paint (passed to the superclass)
+ * change - did it change either set or highlight state?
+ */
+static void
+PaintCommandWidget(Widget w, XEvent *event, Region region, Bool change)
+{
+ CommandWidget cbw = (CommandWidget)w;
+ Bool very_thick;
+ GC rev_gc;
+
+ very_thick = cbw->command.highlight_thickness
+ > Min(XtWidth(cbw), XtHeight(cbw)) / 2;
+
+ if (cbw->command.highlight_thickness == 0) {
+ (*SuperClass->core_class.expose) (w, event, region);
+ return;
+ }
+
+ /*
+ * If we are set then use the same colors as if we are not highlighted
+ */
+
+ if (cbw->command.highlighted != HighlightNone) {
+ rev_gc = cbw->command.normal_GC;
+ }
+ else {
+ rev_gc = cbw->command.inverse_GC;
+ }
+
+ if (!((!change && cbw->command.highlighted == HighlightNone)
+ || (cbw->command.highlighted == HighlightWhenUnset
+ && cbw->command.set))) {
+ if (very_thick)
+ XFillRectangle(XtDisplay(w),XtWindow(w), rev_gc,
+ 0, 0, XtWidth(cbw), XtHeight(cbw));
+ else {
+ /* wide lines are centered on the path, so indent it */
+ if (cbw->core.background_pixmap != XtUnspecifiedPixmap &&
+ rev_gc == cbw->command.inverse_GC) {
+ XClearArea(XtDisplay(w), XtWindow(w),
+ 0, 0, XtWidth(cbw), cbw->command.highlight_thickness,
+ False);
+ XClearArea(XtDisplay(w), XtWindow(w),
+ 0, cbw->command.highlight_thickness,
+ cbw->command.highlight_thickness,
+ XtHeight(cbw) - (cbw->command.highlight_thickness<<1),
+ False);
+ XClearArea(XtDisplay(w), XtWindow(w),
+ XtWidth(cbw) - cbw->command.highlight_thickness,
+ cbw->command.highlight_thickness,
+ cbw->command.highlight_thickness,
+ XtHeight(cbw) - (cbw->command.highlight_thickness<<1),
+ False);
+ XClearArea(XtDisplay(w), XtWindow(w),
+ 0, XtHeight(cbw) - cbw->command.highlight_thickness,
+ XtWidth(cbw), cbw->command.highlight_thickness,
+ False);
+ }
+ else {
+ int offset = cbw->command.highlight_thickness / 2;
+
+ XDrawRectangle(XtDisplay(w),XtWindow(w), rev_gc, offset, offset,
+ XtWidth(cbw) - cbw->command.highlight_thickness,
+ XtHeight(cbw) - cbw->command.highlight_thickness);
+ }
+ }
+ }
+
+ (*SuperClass->core_class.expose)(w, event, region);
+}
+
+static void
+XawCommandDestroy(Widget w)
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ /* Label will release cbw->command.normal_GC */
+ XtReleaseGC(w, cbw->command.inverse_GC);
+}
+
+/*ARGSUSED*/
+static Boolean
+XawCommandSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ CommandWidget oldcbw = (CommandWidget)current;
+ CommandWidget cbw = (CommandWidget)cnew;
+ Boolean redisplay = False;
+
+ if (oldcbw->core.sensitive != cbw->core.sensitive && !cbw->core.sensitive) {
+ cbw->command.highlighted = HighlightNone;
+ redisplay = True;
+ }
+
+ if (cbw->command.set) {
+ unsigned int i;
+ Pixel foreground, background;
+
+ foreground = oldcbw->label.foreground;
+ background = oldcbw->core.background_pixel;
+ for (i = 0; i < *num_args; i++) {
+ if (STR_EQUAL(args[i].name, XtNforeground))
+ background = cbw->label.foreground;
+ else if (STR_EQUAL(args[i].name, XtNbackground))
+ foreground = cbw->core.background_pixel;
+ }
+ cbw->label.foreground = foreground;
+ cbw->core.background_pixel = background;
+ }
+
+ if (oldcbw->label.foreground != cbw->label.foreground
+ || oldcbw->core.background_pixel != cbw->core.background_pixel
+ || oldcbw->command.highlight_thickness
+ != cbw->command.highlight_thickness
+ || oldcbw->label.font != cbw->label.font) {
+ XtReleaseGC(cnew, cbw->command.inverse_GC);
+
+ cbw->command.normal_GC = Get_GC(cbw, cbw->label.foreground,
+ cbw->core.background_pixel);
+ cbw->command.inverse_GC = Get_GC(cbw, cbw->core.background_pixel,
+ cbw->label.foreground);
+ XtReleaseGC(cnew, cbw->label.normal_GC);
+ cbw->label.normal_GC = cbw->command.normal_GC;
+
+ redisplay = True;
+ }
+
+ if (XtIsRealized(cnew)
+ && oldcbw->command.shape_style != cbw->command.shape_style
+ && !ShapeButton(cbw, True))
+ cbw->command.shape_style = oldcbw->command.shape_style;
+
+ return (redisplay);
+}
+
+static void
+XawCommandGetValuesHook(Widget w, ArgList args, Cardinal *num_args)
+{
+ CommandWidget cbw = (CommandWidget)w;
+ unsigned int i;
+
+ for (i = 0; i < *num_args; i++) {
+ if (STR_EQUAL(args[i].name, XtNforeground))
+ *((String*)args[i].value) = cbw->command.set ?
+ (String)cbw->core.background_pixel : (String)cbw->label.foreground;
+ else if (STR_EQUAL(args[i].name, XtNbackground))
+ *((String*)args[i].value) = cbw->command.set ?
+ (String)cbw->label.foreground : (String)cbw->core.background_pixel;
+ }
+}
+
+static void
+XawCommandClassInitialize(void)
+{
+ XawInitializeWidgetSet();
+ XtSetTypeConverter(XtRString, XtRShapeStyle, XmuCvtStringToShapeStyle,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRShapeStyle, XtRString, XmuCvtShapeStyleToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+
+static Bool
+ShapeButton(CommandWidget cbw, Bool checkRectangular)
+{
+ Dimension corner_size = 0;
+
+ if (cbw->command.shape_style == XawShapeRoundedRectangle) {
+ corner_size = XtWidth(cbw) < XtHeight(cbw) ?
+ XtWidth(cbw) : XtHeight(cbw);
+ corner_size = (corner_size * cbw->command.corner_round) / 100;
+ }
+
+ if (checkRectangular || cbw->command.shape_style != XawShapeRectangle) {
+ if (!XmuReshapeWidget((Widget)cbw, cbw->command.shape_style,
+ corner_size, corner_size)) {
+ cbw->command.shape_style = XawShapeRectangle;
+ return (False);
+ }
+ }
+
+ return (True);
+}
+
+static void
+XawCommandRealize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
+{
+ (*commandWidgetClass->core_class.superclass->core_class.realize)
+ (w, valueMask, attributes);
+
+ ShapeButton((CommandWidget)w, False);
+}
+
+static void
+XawCommandResize(Widget w)
+{
+ if (XtIsRealized(w))
+ ShapeButton((CommandWidget)w, False);
+
+ (*commandWidgetClass->core_class.superclass->core_class.resize)(w);
+}
+
+static Bool
+ChangeSensitive(Widget w)
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ if (XtIsRealized(w)) {
+ if (XtIsSensitive(w)) {
+ if (w->core.border_pixmap != XtUnspecifiedPixmap)
+ XSetWindowBorderPixmap(XtDisplay(w), XtWindow(w),
+ w->core.border_pixmap);
+ else
+ XSetWindowBorder(XtDisplay(w), XtWindow(w),
+ w->core.border_pixel);
+ }
+ else {
+ if (cbw->simple.insensitive_border == None)
+ cbw->simple.insensitive_border =
+ XmuCreateStippledPixmap(XtScreen(w),
+ w->core.border_pixel,
+ cbw->command.set ?
+ cbw->label.foreground :
+ w->core.background_pixel,
+ w->core.depth);
+ XSetWindowBorderPixmap(XtDisplay(w), XtWindow(w),
+ cbw->simple.insensitive_border);
+ }
+ }
+
+ return (False);
+}
diff --git a/nx-X11/lib/Xaw/Command.h b/nx-X11/lib/Xaw/Command.h
new file mode 100644
index 000000000..49eb99122
--- /dev/null
+++ b/nx-X11/lib/Xaw/Command.h
@@ -0,0 +1,119 @@
+/* $Xorg: Command.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Command.h,v 1.5 2001/01/17 19:42:26 dawes Exp $ */
+
+#ifndef _XawCommand_h
+#define _XawCommand_h
+
+#include <X11/Xaw/Label.h>
+
+/* Command widget resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ accelerators Accelerators AcceleratorTable NULL
+ ancestorSensitive AncestorSensitive Boolean True
+ background Background Pixel XtDefaultBackground
+ backgroundPixmap Pixmap Pixmap XtUnspecifiedPixmap
+ bitmap Pixmap Pixmap None
+ borderColor BorderColor Pixel XtDefaultForeground
+ borderPixmap Pixmap Pixmap XtUnspecifiedPixmap
+ borderWidth BorderWidth Dimension 1
+ callback Callback XtCallbackList NULL
+ colormap Colormap Colormap parent's colormap
+ cornerRoundPercent CornerRoundPercent Dimension 25
+ cursor Cursor Cursor None
+ cursorName Cursor String NULL
+ depth Depth int parent's depth
+ destroyCallback Callback XtCallbackList NULL
+ displayList DisplayList XawDisplayList* NULL
+ encoding Encoding UnsignedChar XawTextEncoding8bit
+ font Font XFontStruct* XtDefaultFont
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension text height
+ highlightThickness Thickness Dimension 0 if shaped, else 2
+ insensitiveBorder Insensitive Pixmap Gray
+ internalHeight Height Dimension 2
+ internalWidth Width Dimension 4
+ justify Justify XtJustify XtJustifyCenter
+ label Label String NULL
+ leftBitmap LeftBitmap Pixmap None
+ mappedWhenManaged MappedWhenManaged Boolean True
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ resize Resize Boolean True
+ screen Screen Screen parent's Screen
+ sensitive Sensitive Boolean True
+ shapeStyle ShapeStyle ShapeStyle Rectangle
+ translations Translations TranslationTable see doc or source
+ width Width Dimension text width
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XtNhighlightThickness "highlightThickness"
+
+#define XtNshapeStyle "shapeStyle"
+#define XtCShapeStyle "ShapeStyle"
+#define XtRShapeStyle "ShapeStyle"
+#define XtNcornerRoundPercent "cornerRoundPercent"
+#define XtCCornerRoundPercent "CornerRoundPercent"
+
+#define XawShapeRectangle XmuShapeRectangle
+#define XawShapeOval XmuShapeOval
+#define XawShapeEllipse XmuShapeEllipse
+#define XawShapeRoundedRectangle XmuShapeRoundedRectangle
+
+extern WidgetClass commandWidgetClass;
+
+typedef struct _CommandClassRec *CommandWidgetClass;
+typedef struct _CommandRec *CommandWidget;
+
+#endif /* _XawCommand_h */
diff --git a/nx-X11/lib/Xaw/CommandP.h b/nx-X11/lib/Xaw/CommandP.h
new file mode 100644
index 000000000..bc639f825
--- /dev/null
+++ b/nx-X11/lib/Xaw/CommandP.h
@@ -0,0 +1,117 @@
+/*
+* $Xorg: CommandP.h,v 1.4 2001/02/09 02:03:43 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/CommandP.h,v 1.7 2001/01/17 19:42:26 dawes Exp $ */
+
+#ifndef _XawCommandP_h
+#define _XawCommandP_h
+
+/*
+ * Command Widget Private Data
+ */
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/LabelP.h>
+
+typedef enum {
+ HighlightNone, /* Do not highlight */
+ HighlightWhenUnset, /* Highlight only when unset, this is
+ to preserve current command widget
+ functionality */
+ HighlightAlways /* Always highlight, lets the toggle widget
+ and other subclasses do the right thing */
+} XtCommandHighlight;
+
+/* New fields for the Command widget class record */
+typedef struct _CommandClass {
+ XtPointer extension;
+} CommandClassPart;
+
+/* Full class record declaration */
+typedef struct _CommandClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ LabelClassPart label_class;
+ CommandClassPart command_class;
+} CommandClassRec;
+
+extern CommandClassRec commandClassRec;
+
+/* New fields for the Command widget record */
+typedef struct {
+ /* resources */
+ Dimension highlight_thickness;
+ XtCallbackList callbacks;
+
+ /* private state */
+ Pixmap gray_pixmap;
+ GC normal_GC;
+ GC inverse_GC;
+ Boolean set;
+ XtCommandHighlight highlighted;
+
+ /* more resources */
+ int shape_style;
+ Dimension corner_round;
+
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} CommandPart;
+
+/* Full widget declaration */
+typedef struct _CommandRec {
+ CorePart core;
+ SimplePart simple;
+ LabelPart label;
+ CommandPart command;
+} CommandRec;
+
+#endif /* _XawCommandP_h */
diff --git a/nx-X11/lib/Xaw/Converters.c b/nx-X11/lib/Xaw/Converters.c
new file mode 100644
index 000000000..24c01ca14
--- /dev/null
+++ b/nx-X11/lib/Xaw/Converters.c
@@ -0,0 +1,701 @@
+/*
+ * Copyright (c) 1998 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+
+/* $XFree86: xc/lib/Xaw/Converters.c,v 3.13 1999/06/06 08:47:54 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xaw/Simple.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+#ifndef OLDXAW
+
+/*
+ * Definitions
+ */
+#define done(type, value) \
+{ \
+ if (toVal->addr != NULL) \
+ { \
+ if (toVal->size < sizeof(type)) \
+ { \
+ toVal->size = sizeof(type); \
+ return (False); \
+ } \
+ *(type *)(toVal->addr) = (value); \
+ } \
+ else \
+ { \
+ static type static_val; \
+ \
+ static_val = (value); \
+ toVal->addr = (XPointer)&static_val; \
+ } \
+ toVal->size = sizeof(type); \
+ return (True); \
+}
+
+#define string_done(value) \
+{ \
+ if (toVal->addr != NULL) \
+ { \
+ if (toVal->size < size) \
+ { \
+ toVal->size = size; \
+ return (False); \
+ } \
+ strcpy((char *)toVal->addr, (value)); \
+ } \
+ else \
+ toVal->addr = (XPointer)(value); \
+ toVal->size = size; \
+ return (True); \
+}
+
+/*
+ * Prototypes
+ */
+static Boolean _XawCvtAtomToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtBooleanToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtBoolToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtCARD32ToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtCardinalToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtDimensionToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtDisplayListToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtFontStructToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtIntToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtPixelToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtPixmapToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtShortToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtPositionToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtStringToDisplayList(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtStringToPixmap(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean _XawCvtUnsignedCharToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static void TypeToStringNoArgsWarning(Display*, String);
+
+/*
+ * Initialization
+ */
+static XtConvertArgRec PixelArgs[] = {
+ {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.colormap),
+ sizeof(Colormap)},
+};
+
+static XtConvertArgRec DLArgs[] = {
+ {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.screen),
+ sizeof(Screen *)},
+ {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.colormap),
+ sizeof(Colormap)},
+ {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.depth),
+ sizeof(int)},
+};
+#endif /* OLDXAW */
+
+static String XtCToolkitError = "ToolkitError";
+static String XtNconversionError = "conversionError";
+
+#ifndef OLDXAW
+static String XtNwrongParameters = "wrongParameters";
+
+/*
+ * Implementation
+ */
+void
+XawInitializeDefaultConverters(void)
+{
+ static Boolean first_time = True;
+
+ if (first_time == False)
+ return;
+
+ first_time = False;
+
+ /* Replace with more apropriate converters */
+ XtSetTypeConverter(XtRCallback, XtRString, _XawCvtCARD32ToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRColormap, XtRString, _XawCvtCARD32ToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRFunction, XtRString, _XawCvtCARD32ToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRPointer, XtRString, _XawCvtCARD32ToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRScreen, XtRString, _XawCvtCARD32ToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRStringArray, XtRString, _XawCvtCARD32ToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRVisual, XtRString, _XawCvtCARD32ToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRWidget, XtRString, _XawCvtCARD32ToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRWidgetList, XtRString, _XawCvtCARD32ToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRWindow, XtRString, _XawCvtCARD32ToString,
+ NULL, 0, XtCacheNone, NULL);
+
+ XtSetTypeConverter(XtRAtom, XtRString, _XawCvtAtomToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRBool, XtRString, _XawCvtBoolToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRBoolean, XtRString, _XawCvtBooleanToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRCardinal, XtRString, _XawCvtCardinalToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRDimension, XtRString, _XawCvtDimensionToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XawRDisplayList, XtRString, _XawCvtDisplayListToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRFontStruct, XtRString, _XawCvtFontStructToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRInt, XtRString, _XawCvtIntToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRPixel, XtRString, _XawCvtPixelToString,
+ &PixelArgs[0], XtNumber(PixelArgs), XtCacheNone, NULL);
+ XtSetTypeConverter(XtRPixmap, XtRString, _XawCvtPixmapToString,
+ &DLArgs[0], XtNumber(DLArgs), XtCacheNone, NULL);
+ XtSetTypeConverter(XtRPosition, XtRString, _XawCvtPositionToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRShort, XtRString, _XawCvtShortToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRString, XawRDisplayList, _XawCvtStringToDisplayList,
+ &DLArgs[0], XtNumber(DLArgs), XtCacheAll, NULL);
+ XtSetTypeConverter(XtRString, XtRPixmap, _XawCvtStringToPixmap,
+ &DLArgs[0], XtNumber(DLArgs), XtCacheAll, NULL);
+ XtSetTypeConverter(XtRUnsignedChar, XtRString, _XawCvtUnsignedCharToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+#endif /* OLDXAW */
+
+void
+XawTypeToStringWarning(Display *dpy, String type)
+{
+ char fname[64];
+ String params[1];
+ Cardinal num_params;
+
+ XmuSnprintf(fname, sizeof(fname), "cvt%sToString", type);
+
+ params[0] = type;
+ num_params = 1;
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNconversionError, fname, XtCToolkitError,
+ "Cannot convert %s to String",
+ params, &num_params);
+}
+
+#ifndef OLDXAW
+static void
+TypeToStringNoArgsWarning(Display *dpy, String type)
+{
+ char fname[64];
+ String params[1];
+ Cardinal num_params;
+
+ XmuSnprintf(fname, sizeof(fname), "cvt%sToString", type);
+
+ params[0] = type;
+ num_params = 1;
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNconversionError, fname,
+ XtCToolkitError,
+ "%s to String conversion needs no extra arguments",
+ params, &num_params);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtBooleanToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static char buffer[6];
+ Cardinal size;
+
+ if (*num_args != 0)
+ TypeToStringNoArgsWarning(dpy, XtRBoolean);
+
+ XmuSnprintf(buffer, sizeof(buffer), "%s",
+ *(Boolean *)fromVal->addr ? XtEtrue : XtEfalse);
+ size = strlen(buffer) + 1;
+
+ string_done(buffer);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtBoolToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static char buffer[6];
+ Cardinal size;
+
+ if (*num_args != 0)
+ TypeToStringNoArgsWarning(dpy, XtRBool);
+
+ XmuSnprintf(buffer, sizeof(buffer), "%s",
+ *(Bool *)fromVal->addr ? XtEtrue : XtEfalse);
+ size = strlen(buffer) + 1;
+
+ string_done(buffer);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtPositionToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static char buffer[7];
+ Cardinal size;
+
+ if (*num_args != 0)
+ TypeToStringNoArgsWarning(dpy, XtRPosition);
+
+ XmuSnprintf(buffer, sizeof(buffer), "%d", *(Position *)fromVal->addr);
+ size = strlen(buffer) + 1;
+
+ string_done(buffer);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtShortToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static char buffer[7];
+ Cardinal size;
+
+ if (*num_args != 0)
+ TypeToStringNoArgsWarning(dpy, XtRShort);
+
+ XmuSnprintf(buffer, sizeof(buffer), "%d", *(short *)fromVal->addr);
+ size = strlen(buffer) + 1;
+
+ string_done(buffer);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtDimensionToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static char buffer[6];
+ Cardinal size;
+
+ if (*num_args != 0)
+ TypeToStringNoArgsWarning(dpy, XtRDimension);
+
+ XmuSnprintf(buffer, sizeof(buffer), "%u", *(Dimension *)fromVal->addr);
+ size = strlen(buffer) + 1;
+
+ string_done(buffer);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtCARD32ToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static char buffer[11];
+ Cardinal size;
+
+ if (*num_args != 0)
+ TypeToStringNoArgsWarning(dpy, "CARD32");
+
+ XmuSnprintf(buffer, sizeof(buffer), "0x%08hx", *(int *)fromVal->addr);
+ size = strlen(buffer) + 1;
+
+ string_done(buffer);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtIntToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static char buffer[12];
+ Cardinal size;
+
+ if (*num_args != 0)
+ TypeToStringNoArgsWarning(dpy, XtRInt);
+
+ XmuSnprintf(buffer, sizeof(buffer), "%d", *(int *)fromVal->addr);
+ size = strlen(buffer) + 1;
+
+ string_done(buffer);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtCardinalToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static char buffer[11];
+ Cardinal size;
+
+ if (*num_args != 0)
+ TypeToStringNoArgsWarning(dpy, XtRCardinal);
+
+ XmuSnprintf(buffer, sizeof(buffer), "%u", *(Cardinal *)fromVal->addr);
+ size = strlen(buffer) + 1;
+
+ string_done(buffer);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtAtomToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static char *buffer = NULL;
+ static char *nullatom = "NULL";
+ Cardinal size;
+ Atom atom;
+
+ if (*num_args != 0)
+ TypeToStringNoArgsWarning(dpy, XtRAtom);
+
+ if (buffer && buffer != nullatom)
+ XFree(buffer);
+
+ atom = *(Atom *)fromVal[0].addr;
+ if (atom == 0)
+ buffer = nullatom;
+ else if ((buffer = XGetAtomName(dpy, *(Atom *)fromVal[0].addr)) == NULL)
+ {
+ XawTypeToStringWarning(dpy, XtRAtom);
+ toVal->addr = NULL;
+ toVal->size = sizeof(String);
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+
+ string_done(buffer);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtPixelToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static char buffer[19];
+ Cardinal size;
+ Colormap colormap;
+ XColor color;
+
+ if (*num_args != 1)
+ {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters, "cvtPixelToString",
+ XtCToolkitError,
+ "Pixel to String conversion needs colormap argument",
+ NULL, NULL);
+ return (False);
+ }
+
+ colormap = *(Colormap *)args[0].addr;
+ color.pixel = *(Pixel *)fromVal->addr;
+
+ /* Note:
+ * If we know the visual type, we can calculate the xcolor
+ * without asking Xlib.
+ */
+ XQueryColor(dpy, colormap, &color);
+ XmuSnprintf(buffer, sizeof(buffer), "rgb:%04hx/%04hx/%04hx",
+ color.red, color.green, color.blue);
+ size = strlen(buffer) + 1;
+
+ string_done(buffer);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtFontStructToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static char buffer[128];
+ Cardinal size;
+ Atom atom;
+ unsigned long value;
+
+ if (*num_args != 0)
+ TypeToStringNoArgsWarning(dpy, XtRFontStruct);
+
+ if ((atom = XInternAtom(dpy, "FONT", True)) == None)
+ return (False);
+
+ size = 0;
+
+ if (XGetFontProperty(*(XFontStruct **)fromVal->addr, atom, &value))
+ {
+ char *tmp = XGetAtomName(dpy, value);
+
+ if (tmp)
+ {
+ XmuSnprintf(buffer, sizeof(buffer), "%s", tmp);
+ size = strlen(tmp);
+ XFree(tmp);
+ }
+ }
+
+ if (size)
+ {
+ ++size;
+ string_done(buffer);
+ }
+
+ XawTypeToStringWarning(dpy, XtRFontStruct);
+
+ return (False);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtUnsignedCharToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static char buffer[4];
+ Cardinal size;
+
+ if (*num_args != 0)
+ TypeToStringNoArgsWarning(dpy, XtRUnsignedChar);
+
+ XmuSnprintf(buffer, sizeof(buffer), "%u",
+ *(unsigned char *)fromVal->addr);
+ size = strlen(buffer) + 1;
+
+ string_done(buffer);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtStringToDisplayList(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ XawDisplayList *dlist;
+ Screen *screen;
+ Colormap colormap;
+ int depth;
+ String commands;
+
+ if (*num_args != 3)
+ {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters, "cvtStringToDisplayList",
+ XtCToolkitError,
+ "String to DisplayList conversion needs screen, "
+ "colormap, and depth arguments",
+ NULL, NULL);
+ return (False);
+ }
+
+ screen = *(Screen **)args[0].addr;
+ colormap = *(Colormap *)args[1].addr;
+ depth = *(int *)args[2].addr;
+
+ commands = (String)(fromVal[0].addr);
+
+ dlist = XawCreateDisplayList(commands, screen, colormap, depth);
+
+ if (!dlist)
+ {
+ XtDisplayStringConversionWarning(dpy, (String)fromVal->addr,
+ XawRDisplayList);
+ toVal->addr = NULL;
+ toVal->size = sizeof(XawDisplayList*);
+ return (False);
+ }
+
+ done(XawDisplayList*, dlist);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtDisplayListToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ String buffer;
+ Cardinal size;
+
+ if (*num_args != 0)
+ TypeToStringNoArgsWarning(dpy, XawRDisplayList);
+
+ buffer = XawDisplayListString(*(XawDisplayList **)(fromVal[0].addr));
+ size = strlen(buffer) + 1;
+
+ string_done(buffer);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtStringToPixmap(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ XawPixmap *xaw_pixmap;
+ Pixmap pixmap;
+ Screen *screen;
+ Colormap colormap;
+ int depth;
+ String name;
+
+ if (*num_args != 3)
+ {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters, "cvtStringToPixmap",
+ XtCToolkitError,
+ "String to Pixmap conversion needs screen, "
+ "colormap, and depth arguments",
+ NULL, NULL);
+ return (False);
+ }
+
+ screen = *(Screen **)args[0].addr;
+ colormap = *(Colormap *)args[1].addr;
+ depth = *(int *)args[2].addr;
+
+ name = (String)(fromVal[0].addr);
+
+ if (XmuCompareISOLatin1(name, "None") == 0)
+ pixmap = None;
+ else if (XmuCompareISOLatin1(name, "ParentRelative") == 0)
+ pixmap = ParentRelative;
+ else if (XmuCompareISOLatin1(name, "XtUnspecifiedPixmap") == 0)
+ pixmap = XtUnspecifiedPixmap;
+ else
+ {
+ xaw_pixmap = XawLoadPixmap(name, screen, colormap, depth);
+ if (!xaw_pixmap)
+ {
+ XtDisplayStringConversionWarning(dpy, (String)fromVal->addr,
+ XtRPixmap);
+ toVal->addr = (XtPointer)XtUnspecifiedPixmap;
+ toVal->size = sizeof(Pixmap);
+ return (False);
+ }
+ else
+ pixmap = xaw_pixmap->pixmap;
+ }
+
+ done(Pixmap, pixmap);
+}
+
+/*ARGSUSED*/
+static Boolean
+_XawCvtPixmapToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ XawPixmap *xaw_pixmap;
+ Pixmap pixmap;
+ Screen *screen;
+ Colormap colormap;
+ int depth;
+ String buffer = NULL;
+ Cardinal size;
+
+ if (*num_args != 3)
+ {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters, "cvtPixmapToString",
+ XtCToolkitError,
+ "Pixmap to String conversion needs screen, "
+ "colormap, and depth arguments",
+ NULL, NULL);
+ return (False);
+ }
+
+ screen = *(Screen **)args[0].addr;
+ colormap = *(Colormap *)args[1].addr;
+ depth = *(int *)args[2].addr;
+
+ pixmap = *(Pixmap *)(fromVal[0].addr);
+
+ switch (pixmap)
+ {
+ case None:
+ buffer = "None";
+ break;
+ case ParentRelative:
+ buffer = "ParentRelative";
+ break;
+ case XtUnspecifiedPixmap:
+ buffer = "XtUnspecifiedPixmap";
+ break;
+ default:
+ xaw_pixmap = XawPixmapFromXPixmap(pixmap, screen, colormap, depth);
+ if (xaw_pixmap)
+ buffer = xaw_pixmap->name;
+ break;
+ }
+
+ if (!buffer)
+ /* Bad Pixmap or Pixmap was not loaded by XawLoadPixmap() */
+ return (_XawCvtCARD32ToString(dpy, args, num_args, fromVal, toVal,
+ converter_data));
+
+ size = strlen(buffer) + 1;
+
+ string_done(buffer);
+}
+
+#endif /* OLDXAW */
diff --git a/nx-X11/lib/Xaw/Dialog.c b/nx-X11/lib/Xaw/Dialog.c
new file mode 100644
index 000000000..0c8b82faf
--- /dev/null
+++ b/nx-X11/lib/Xaw/Dialog.c
@@ -0,0 +1,463 @@
+/* $Xorg: Dialog.c,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Dialog.c,v 1.7 2001/01/17 19:42:26 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xos.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/DialogP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+/*
+ * After we have set the string in the value widget we set the
+ * string to a magic value. So that when a SetValues request is made
+ * on the dialog value we will notice it, and reset the string
+ */
+#define MAGIC_VALUE ((char *)3)
+
+#define streq(a,b) (strcmp((a), (b)) == 0)
+
+/*
+ * Class Methods
+ */
+static void XawDialogConstraintInitialize(Widget, Widget,
+ ArgList, Cardinal*);
+static void XawDialogGetValuesHook(Widget, ArgList, Cardinal*);
+static void XawDialogInitialize(Widget, Widget, ArgList, Cardinal*);
+static Boolean XawDialogSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static void CreateDialogValueWidget(Widget);
+
+/*
+ * Initialization
+ */
+static XtResource resources[] = {
+ {
+ XtNlabel,
+ XtCLabel,
+ XtRString,
+ sizeof(String),
+ XtOffsetOf(DialogRec, dialog.label),
+ XtRString,
+ NULL
+ },
+ {
+ XtNvalue,
+ XtCValue,
+ XtRString,
+ sizeof(String),
+ XtOffsetOf(DialogRec, dialog.value),
+ XtRString,
+ NULL
+ },
+ {
+ XtNicon,
+ XtCIcon,
+ XtRBitmap,
+ sizeof(Pixmap),
+ XtOffsetOf(DialogRec, dialog.icon),
+ XtRImmediate,
+ 0
+ },
+};
+
+DialogClassRec dialogClassRec = {
+ /* core */
+ {
+ (WidgetClass)&formClassRec, /* superclass */
+ "Dialog", /* class_name */
+ sizeof(DialogRec), /* widget_size */
+ XawInitializeWidgetSet, /* class_initialize */
+ NULL, /* class_part init */
+ False, /* class_inited */
+ XawDialogInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ NULL, /* destroy */
+ XtInheritResize, /* resize */
+ XtInheritExpose, /* expose */
+ XawDialogSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ XawDialogGetValuesHook, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* composite */
+ {
+ XtInheritGeometryManager, /* geometry_manager */
+ XtInheritChangeManaged, /* change_managed */
+ XtInheritInsertChild, /* insert_child */
+ XtInheritDeleteChild, /* delete_child */
+ NULL, /* extension */
+ },
+ /* constraint */
+ {
+ NULL, /* subresourses */
+ 0, /* subresource_count */
+ sizeof(DialogConstraintsRec), /* constraint_size */
+ XawDialogConstraintInitialize, /* initialize */
+ NULL, /* destroy */
+ NULL, /* set_values */
+ NULL, /* extension */
+ },
+ /* form */
+ {
+ XtInheritLayout, /* layout */
+ },
+ /* dialog */
+ {
+ NULL, /* extension */
+ }
+};
+
+WidgetClass dialogWidgetClass = (WidgetClass)&dialogClassRec;
+
+/*
+ * Implementation
+ */
+/*ARGSUSED*/
+static void
+XawDialogInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ DialogWidget dw = (DialogWidget)cnew;
+ Arg arglist[9];
+ Cardinal arg_cnt = 0;
+
+ XtSetArg(arglist[arg_cnt], XtNborderWidth, 0); arg_cnt++;
+ XtSetArg(arglist[arg_cnt], XtNleft, XtChainLeft); arg_cnt++;
+
+ if (dw->dialog.icon != (Pixmap)0) {
+ XtSetArg(arglist[arg_cnt], XtNbitmap, dw->dialog.icon); arg_cnt++;
+ XtSetArg(arglist[arg_cnt], XtNright, XtChainLeft); arg_cnt++;
+ dw->dialog.iconW = XtCreateManagedWidget("icon", labelWidgetClass,
+ cnew, arglist, arg_cnt);
+ arg_cnt = 2;
+ XtSetArg(arglist[arg_cnt], XtNfromHoriz, dw->dialog.iconW); arg_cnt++;
+ }
+ else
+ dw->dialog.iconW = NULL;
+
+ XtSetArg(arglist[arg_cnt], XtNlabel, dw->dialog.label); arg_cnt++;
+ XtSetArg(arglist[arg_cnt], XtNright, XtChainRight); arg_cnt++;
+
+ dw->dialog.labelW = XtCreateManagedWidget("label", labelWidgetClass,
+ cnew, arglist, arg_cnt);
+
+ if (dw->dialog.iconW != NULL &&
+ XtHeight(dw->dialog.labelW) < XtHeight(dw->dialog.iconW)) {
+ XtSetArg(arglist[0], XtNheight, XtHeight(dw->dialog.iconW));
+ XtSetValues(dw->dialog.labelW, arglist, 1);
+ }
+ if (dw->dialog.value != NULL)
+ CreateDialogValueWidget((Widget)dw);
+ else
+ dw->dialog.valueW = NULL;
+}
+
+/*ARGSUSED*/
+static void
+XawDialogConstraintInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ DialogWidget dw = (DialogWidget)cnew->core.parent;
+ DialogConstraints constraint = (DialogConstraints)cnew->core.constraints;
+
+ if (!XtIsSubclass(cnew, commandWidgetClass)) /* if not a button */
+ return; /* then just use defaults */
+
+ constraint->form.left = constraint->form.right = XtChainLeft;
+ if (dw->dialog.valueW == NULL)
+ constraint->form.vert_base = dw->dialog.labelW;
+ else
+ constraint->form.vert_base = dw->dialog.valueW;
+
+ if (dw->composite.num_children > 1) {
+ WidgetList children = dw->composite.children;
+ Widget *childP;
+
+ for (childP = children + dw->composite.num_children - 1;
+ childP >= children; childP-- ) {
+ if (*childP == dw->dialog.labelW || *childP == dw->dialog.valueW)
+ break;
+ if (XtIsManaged(*childP) &&
+ XtIsSubclass(*childP, commandWidgetClass)) {
+ constraint->form.horiz_base = *childP;
+ break;
+ }
+ }
+ }
+}
+
+#define ICON 0
+#define LABEL 1
+#define NUM_CHECKS 2
+/*ARGSUSED*/
+static Boolean
+XawDialogSetValues(Widget current, Widget request, Widget cnew,
+ ArgList in_args, Cardinal *in_num_args)
+{
+ DialogWidget w = (DialogWidget)cnew;
+ DialogWidget old = (DialogWidget)current;
+ Arg args[5];
+ Cardinal num_args;
+ unsigned int i;
+ Bool checks[NUM_CHECKS];
+
+ for (i = 0; i < NUM_CHECKS; i++)
+ checks[i] = False;
+
+ for (i = 0; i < *in_num_args; i++) {
+ if (streq(XtNicon, in_args[i].name))
+ checks[ICON] = True;
+ else if (streq(XtNlabel, in_args[i].name))
+ checks[LABEL] = True;
+ }
+
+ if (checks[ICON]) {
+ if (w->dialog.icon != 0) {
+ XtSetArg(args[0], XtNbitmap, w->dialog.icon);
+ if (old->dialog.iconW != NULL)
+ XtSetValues(old->dialog.iconW, args, 1);
+ else {
+ XtSetArg(args[1], XtNborderWidth, 0);
+ XtSetArg(args[2], XtNleft, XtChainLeft);
+ XtSetArg(args[3], XtNright, XtChainLeft);
+ w->dialog.iconW = XtCreateWidget("icon", labelWidgetClass,
+ cnew, args, 4);
+ ((DialogConstraints)w->dialog.labelW->core.constraints)->
+ form.horiz_base = w->dialog.iconW;
+ XtManageChild(w->dialog.iconW);
+ }
+ }
+ else if (old->dialog.icon != 0) {
+ ((DialogConstraints)w->dialog.labelW->core.constraints)->
+ form.horiz_base = NULL;
+ XtDestroyWidget(old->dialog.iconW);
+ w->dialog.iconW = NULL;
+ }
+ }
+
+ if (checks[LABEL]) {
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, w->dialog.label); num_args++;
+ if (w->dialog.iconW != NULL &&
+ XtHeight(w->dialog.labelW) <= XtHeight(w->dialog.iconW)) {
+ XtSetArg(args[num_args], XtNheight, XtHeight(w->dialog.iconW));
+ num_args++;
+ }
+ XtSetValues(w->dialog.labelW, args, num_args);
+ }
+
+ if (w->dialog.value != old->dialog.value) {
+ if (w->dialog.value == NULL) /* only get here if it
+ wasn't NULL before */
+ XtDestroyWidget(old->dialog.valueW);
+ else if (old->dialog.value == NULL) { /* create a new value widget */
+ XtWidth(w) = XtWidth(old);
+ XtHeight(w) = XtHeight(old);
+ CreateDialogValueWidget(cnew);
+ }
+ else { /* Widget ok, just change string */
+ Arg nargs[1];
+
+ XtSetArg(nargs[0], XtNstring, w->dialog.value);
+ XtSetValues(w->dialog.valueW, nargs, 1);
+ w->dialog.value = MAGIC_VALUE;
+ }
+ }
+
+ return (False);
+}
+
+/*
+ * Function:
+ * XawDialogGetValuesHook
+ *
+ * Parameters:
+ * w - Dialog Widget
+ * args - argument list
+ * num_args - number of args
+ *
+ * Description:
+ * This is a get values hook routine that gets the values in the dialog.
+ */
+static void
+XawDialogGetValuesHook(Widget w, ArgList args, Cardinal *num_args)
+{
+ Arg a[1];
+ String s;
+ DialogWidget src = (DialogWidget)w;
+ unsigned int i;
+
+ for (i = 0; i < *num_args; i++)
+ if (streq(args[i].name, XtNvalue)) {
+ XtSetArg(a[0], XtNstring, &s);
+ XtGetValues(src->dialog.valueW, a, 1);
+ *((char **)args[i].value) = s;
+ }
+ else if (streq(args[i].name, XtNlabel)) {
+ XtSetArg(a[0], XtNlabel, &s);
+ XtGetValues(src->dialog.labelW, a, 1);
+ *((char **)args[i].value) = s;
+ }
+}
+
+/*
+ * Function:
+ * CreateDialogValueWidget
+ *
+ * Parameters:
+ * w - dialog widget
+ *
+ * Description:
+ * Creates the dialog widgets value widget.
+ *
+ * Note
+ * Must be called only when w->dialog.value is non-nil
+ */
+static void
+CreateDialogValueWidget(Widget w)
+{
+ DialogWidget dw = (DialogWidget)w;
+ Arg arglist[10];
+ Cardinal num_args = 0;
+
+ XtSetArg(arglist[num_args], XtNstring, dw->dialog.value); num_args++;
+ XtSetArg(arglist[num_args], XtNresizable, True); num_args++;
+ XtSetArg(arglist[num_args], XtNeditType, XawtextEdit); num_args++;
+ XtSetArg(arglist[num_args], XtNfromVert, dw->dialog.labelW); num_args++;
+ XtSetArg(arglist[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(arglist[num_args], XtNright, XtChainRight); num_args++;
+
+ dw->dialog.valueW = XtCreateWidget("value", asciiTextWidgetClass,
+ w, arglist, num_args);
+
+ /* if the value widget is being added after buttons,
+ * then the buttons need new layout constraints
+ */
+ if (dw->composite.num_children > 1) {
+ WidgetList children = dw->composite.children;
+ Widget *childP;
+
+ for (childP = children + dw->composite.num_children - 1;
+ childP >= children; childP-- ) {
+ if (*childP == dw->dialog.labelW || *childP == dw->dialog.valueW)
+ continue;
+
+ if (XtIsManaged(*childP) &&
+ XtIsSubclass(*childP, commandWidgetClass)) {
+ ((DialogConstraints)(*childP)->core.constraints)->
+ form.vert_base = dw->dialog.valueW;
+ }
+ }
+ }
+ XtManageChild(dw->dialog.valueW);
+
+ /*
+ * Value widget gets the keyboard focus
+ */
+ XtSetKeyboardFocus(w, dw->dialog.valueW);
+ dw->dialog.value = MAGIC_VALUE;
+}
+
+void
+XawDialogAddButton(Widget dialog, _Xconst char* name, XtCallbackProc function,
+ XtPointer param)
+{
+ /*
+ * Correct Constraints are all set in ConstraintInitialize()
+ */
+ Widget button;
+
+ button = XtCreateManagedWidget(name, commandWidgetClass, dialog, NULL, 0);
+
+ if (function != NULL) /* don't add NULL callback func */
+ XtAddCallback(button, XtNcallback, function, param);
+}
+
+char *
+XawDialogGetValueString(Widget w)
+{
+ Arg args[1];
+ char *value;
+
+ XtSetArg(args[0], XtNstring, &value);
+ XtGetValues(((DialogWidget)w)->dialog.valueW, args, 1);
+
+ return(value);
+}
diff --git a/nx-X11/lib/Xaw/Dialog.h b/nx-X11/lib/Xaw/Dialog.h
new file mode 100644
index 000000000..96fd36d38
--- /dev/null
+++ b/nx-X11/lib/Xaw/Dialog.h
@@ -0,0 +1,101 @@
+/* $Xorg: Dialog.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Dialog.h,v 1.5 2001/01/17 19:42:26 dawes Exp $ */
+
+#ifndef _XawDialog_h
+#define _XawDialog_h
+
+#include <X11/Xaw/Form.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ borderColor BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ destroyCallback Callback Pointer NULL
+ height Height Dimension computed at create
+ icon Icon Pixmap 0
+ label Label String NULL
+ mappedWhenManaged MappedWhenManaged Boolean True
+ sensitive Sensitive Boolean True
+ value Value String NULL
+ width Width Dimension computed at create
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XtCIcon "Icon"
+#define XtNicon "icon"
+
+typedef struct _DialogClassRec *DialogWidgetClass;
+typedef struct _DialogRec *DialogWidget;
+
+extern WidgetClass dialogWidgetClass;
+
+_XFUNCPROTOBEGIN
+
+void XawDialogAddButton
+(
+ Widget dialog,
+ _Xconst char *name,
+ XtCallbackProc function,
+ XtPointer client_data
+ );
+
+char *XawDialogGetValueString
+(
+ Widget w
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawDialog_h */
diff --git a/nx-X11/lib/Xaw/DialogP.h b/nx-X11/lib/Xaw/DialogP.h
new file mode 100644
index 000000000..fcc2240d7
--- /dev/null
+++ b/nx-X11/lib/Xaw/DialogP.h
@@ -0,0 +1,104 @@
+/* $Xorg: DialogP.h,v 1.4 2001/02/09 02:03:43 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/DialogP.h,v 1.8 2001/01/17 19:42:26 dawes Exp $ */
+
+#ifndef _DialogP_h
+#define _DialogP_h
+
+#include <X11/Xaw/Dialog.h>
+#include <X11/Xaw/FormP.h>
+
+typedef struct {
+ XtPointer extension;
+} DialogClassPart;
+
+typedef struct _DialogClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ConstraintClassPart constraint_class;
+ FormClassPart form_class;
+ DialogClassPart dialog_class;
+} DialogClassRec;
+
+extern DialogClassRec dialogClassRec;
+
+typedef struct _DialogPart {
+ /* resources */
+ String label; /* description of the dialog */
+ String value; /* for the user response */
+ Pixmap icon; /* icon bitmap */
+
+ /* private */
+ Widget iconW; /* widget to display the icon */
+ Widget labelW; /* widget to display description */
+ Widget valueW; /* user response TextWidget */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} DialogPart;
+
+typedef struct _DialogRec {
+ CorePart core;
+ CompositePart composite;
+ ConstraintPart constraint;
+ FormPart form;
+ DialogPart dialog;
+} DialogRec;
+
+typedef struct {
+ XtPointer extension;
+} DialogConstraintsPart;
+
+typedef struct _DialogConstraintsRec {
+ FormConstraintsPart form;
+ DialogConstraintsPart dialog;
+} DialogConstraintsRec, *DialogConstraints;
+
+#endif /* _DialogP_h */
diff --git a/nx-X11/lib/Xaw/DisplayList.c b/nx-X11/lib/Xaw/DisplayList.c
new file mode 100644
index 000000000..e43621b21
--- /dev/null
+++ b/nx-X11/lib/Xaw/DisplayList.c
@@ -0,0 +1,2257 @@
+/*
+ * Copyright (c) 1998 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ *
+ * Author: Paulo César Pereira de Andrade
+ */
+
+/* $XFree86: xc/lib/Xaw/DisplayList.c,v 3.18 2003/05/23 14:51:15 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <ctype.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/CoreP.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/SysUtil.h>
+#include "Private.h"
+
+#ifdef __UNIXOS2__
+static char dummy;
+#endif
+
+#ifndef OLDXAW
+
+/*
+ * Types
+ */
+typedef struct _XawDLProc XawDLProc;
+typedef struct _XawDLData XawDLData;
+typedef struct _XawDLInfo XawDLInfo;
+
+struct _XawDLProc {
+ XrmQuark qname;
+ String *params;
+ Cardinal num_params;
+ XawDisplayListProc proc;
+ XtPointer args;
+ XawDLData *data;
+};
+
+struct _XawDLData {
+ XawDLClass *dlclass;
+ XtPointer data;
+};
+
+struct _XawDLInfo {
+ String name;
+ XrmQuark qname;
+ XawDisplayListProc proc;
+};
+
+struct _XawDL {
+ XawDLProc **procs;
+ Cardinal num_procs;
+ XawDLData **data;
+ Cardinal num_data;
+ Screen *screen;
+ Colormap colormap;
+ int depth;
+ XrmQuark qrep; /* for cache lookup */
+};
+
+struct _XawDLClass {
+ String name;
+ XawDLInfo **infos;
+ Cardinal num_infos;
+ XawDLArgsInitProc args_init;
+ XawDLArgsDestructor args_destructor;
+ XawDLDataInitProc data_init;
+ XawDLDataDestructor data_destructor;
+};
+
+/*
+ * Private Methods
+ */
+static XawDLClass *_XawFindDLClass(String);
+static int qcmp_dlist_class(_Xconst void*, _Xconst void*);
+static int bcmp_dlist_class(_Xconst void*, _Xconst void*);
+static XawDLInfo *_XawFindDLInfo(XawDLClass*, String);
+static int qcmp_dlist_info(_Xconst void*, _Xconst void*);
+static int bcmp_dlist_info(_Xconst void*, _Xconst void*);
+static void *_Xaw_Xlib_ArgsInitProc(String, String*, Cardinal*,
+ Screen*, Colormap, int);
+static void _Xaw_Xlib_ArgsDestructor(Display*, String, XtPointer,
+ String*, Cardinal*);
+static void *_Xaw_Xlib_DataInitProc(String, Screen*, Colormap, int);
+static void _Xaw_Xlib_DataDestructor(Display*, String, XtPointer);
+
+/*
+ * Initialization
+ */
+static XawDLClass **classes;
+static Cardinal num_classes;
+static String xlib = "xlib";
+
+/*
+ * Implementation
+ */
+void
+XawRunDisplayList(Widget w, _XawDisplayList *list,
+ XEvent *event, Region region)
+{
+ XawDLProc *proc;
+ Cardinal i;
+
+ if (!XtIsRealized(w))
+ return;
+
+ for (i = 0; i < list->num_procs; i++)
+ {
+ proc = list->procs[i];
+ proc->proc(w, proc->args, proc->data->data, event, region);
+ }
+}
+
+#define DLERR -2
+#define DLEOF -1
+#define DLEND 1
+#define DLNAME 2
+#define DLARG 3
+static char *
+read_token(char *src, char *dst, Cardinal size, int *status)
+{
+ int ch;
+ Bool esc, quote;
+ Cardinal i;
+
+ i = 0;
+ esc = quote = False;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ ch = *src;
+ if (ch != '\n' && isspace(ch))
+ ++src;
+ else
+ break;
+ }
+
+ for (; i < size - 1; src++)
+ {
+ ch = *src;
+ if (ch == '"')
+ {
+ if (quote)
+ {
+ quote = False;
+ continue;
+ }
+ quote = True;
+ continue;
+ }
+ if (ch == '\\')
+ {
+ if (esc)
+ {
+ dst[i++] = ch;
+ esc = False;
+ continue;
+ }
+ esc = True;
+ continue;
+ }
+ if (ch == '\0')
+ {
+ *status = DLEOF;
+ dst[i] = '\0';
+ return (src);
+ }
+ else if (!esc)
+ {
+ if (!quote)
+ {
+ if (ch == ',')
+ {
+ *status = DLARG;
+ dst[i] = '\0';
+ return (++src);
+ }
+ else if (ch == ' ' || ch == '\t')
+ {
+ *status = DLNAME;
+ dst[i] = '\0';
+ return (++src);
+ }
+ else if (ch == ';' || ch == '\n')
+ {
+ *status = DLEND;
+ dst[i] = '\0';
+ return (++src);
+ }
+ }
+ }
+ else
+ esc = False;
+ dst[i++] = ch;
+ }
+
+ *status = DLERR;
+ dst[i] = '\0';
+
+ return (src);
+}
+
+_XawDisplayList *XawCreateDisplayList(String string, Screen *screen,
+ Colormap colormap, int depth)
+{
+ _XawDisplayList *dlist;
+ XawDLClass *lc, *xlibc;
+ XawDLData *data;
+ XawDLInfo *info;
+ XawDLProc *proc;
+ char cname[64], fname[64], aname[1024];
+ Cardinal i;
+ char *cp, *fp, *lp;
+ int status;
+
+ xlibc = XawGetDisplayListClass(xlib);
+ if (!xlibc)
+ {
+ XawDisplayListInitialize();
+ xlibc = XawGetDisplayListClass(xlib);
+ }
+
+ dlist = (_XawDisplayList *)XtMalloc(sizeof(_XawDisplayList));
+ dlist->procs = NULL;
+ dlist->num_procs = 0;
+ dlist->data = NULL;
+ dlist->num_data = 0;
+ dlist->screen = screen;
+ dlist->colormap = colormap;
+ dlist->depth = depth;
+ dlist->qrep = NULLQUARK;
+ if (!string || !string[0])
+ return (dlist);
+
+ cp = string;
+
+ status = 0;
+ while (status != DLEOF)
+ {
+ lp = cp;
+ cp = read_token(cp, fname, sizeof(fname), &status);
+
+ if (status != DLNAME && status != DLEND && status != DLEOF)
+ {
+ char msg[256];
+
+ XmuSnprintf(msg, sizeof(msg),
+ "Error parsing displayList at \"%s\"", lp);
+ XtAppWarning(XtDisplayToApplicationContext(DisplayOfScreen(screen)),
+ msg);
+ XawDestroyDisplayList(dlist);
+ return (NULL);
+ }
+ fp = fname;
+ /*CONSTCOND*/
+ while (1)
+ {
+ fp = strchr(fp, ':');
+ if (!fp || (fp == cp || fp[-1] != '\\'))
+ break;
+ ++fp;
+ }
+ if (fp)
+ {
+ XmuSnprintf(cname, fp - fname + 1, fname);
+ memmove(fname, fp + 1, strlen(fp));
+ lc = cname[0] ? XawGetDisplayListClass(cname) : xlibc;
+ if (!lc)
+ {
+ char msg[256];
+
+ XmuSnprintf(msg, sizeof(msg),
+ "Cannot find displayList class \"%s\"", cname);
+ XtAppWarning(XtDisplayToApplicationContext
+ (DisplayOfScreen(screen)), msg);
+ XawDestroyDisplayList(dlist);
+ return (NULL);
+ }
+ }
+ else
+ lc = xlibc;
+
+ if (status == DLEOF && !fname[0])
+ break;
+
+ if ((info = _XawFindDLInfo(lc, fname)) == NULL)
+ {
+ char msg[256];
+
+ XmuSnprintf(msg, sizeof(msg),
+ "Cannot find displayList procedure \"%s\"", fname);
+ XtAppWarning(XtDisplayToApplicationContext(DisplayOfScreen(screen)),
+ msg);
+ XawDestroyDisplayList(dlist);
+ return (NULL);
+ }
+
+ proc = (XawDLProc *)XtMalloc(sizeof(XawDLProc));
+ proc->qname = info->qname;
+ proc->params = NULL;
+ proc->num_params = 0;
+ proc->proc = info->proc;
+ proc->args = NULL;
+ proc->data = NULL;
+
+ if (!dlist->procs)
+ {
+ dlist->num_procs = 1;
+ dlist->procs = (XawDLProc**)XtMalloc(sizeof(XawDLProc*));
+ }
+ else
+ {
+ ++dlist->num_procs;
+ dlist->procs = (XawDLProc**)
+ XtRealloc((char *)dlist->procs, sizeof(XawDLProc*) *
+ dlist->num_procs);
+ }
+ dlist->procs[dlist->num_procs - 1] = proc;
+
+ while (status != DLEND && status != DLEOF)
+ {
+ lp = cp;
+ cp = read_token(cp, aname, sizeof(aname), &status);
+
+ if (status != DLARG && status != DLEND && status != DLEOF)
+ {
+ char msg[256];
+
+ XmuSnprintf(msg, sizeof(msg),
+ "Error parsing displayList at \"%s\"", lp);
+ XtAppWarning(XtDisplayToApplicationContext
+ (DisplayOfScreen(screen)), msg);
+ XawDestroyDisplayList(dlist);
+ return (NULL);
+ }
+
+ if (!proc->num_params)
+ {
+ proc->num_params = 1;
+ proc->params = (String *)XtMalloc(sizeof(String));
+ }
+ else
+ {
+ ++proc->num_params;
+ proc->params = (String *)XtRealloc((char *)proc->params,
+ sizeof(String) *
+ proc->num_params);
+ }
+ proc->params[proc->num_params - 1] = XtNewString(aname);
+ }
+
+ /* verify if data is already created for lc */
+ data = NULL;
+ for (i = 0; i < dlist->num_data; i++)
+ if (dlist->data[i]->dlclass == lc)
+ {
+ data = dlist->data[i];
+ break;
+ }
+
+ if (!data)
+ {
+ data = (XawDLData *)XtMalloc(sizeof(XawDLData));
+ data->dlclass = lc;
+ if (lc->data_init)
+ data->data = lc->data_init(lc->name, screen, colormap, depth);
+ else
+ data->data = NULL;
+
+ if (!dlist->data)
+ {
+ dlist->num_data = 1;
+ dlist->data = (XawDLData **)XtMalloc(sizeof(XawDLData*));
+ }
+ else
+ {
+ ++dlist->num_data;
+ dlist->data = (XawDLData **)
+ XtRealloc((char *)dlist->data, sizeof(XawDLData*) *
+ dlist->num_data);
+ }
+ dlist->data[dlist->num_data - 1] = data;
+ }
+
+ if (lc->args_init)
+ {
+ proc->args = lc->args_init(fname, proc->params, &proc->num_params,
+ screen, colormap, depth);
+ if (proc->args == XAWDL_CONVERT_ERROR)
+ {
+ char msg[256];
+
+ proc->args = NULL;
+ XmuSnprintf(msg, sizeof(msg),
+ "Cannot convert arguments to displayList function \"%s\"", fname);
+ XtAppWarning(XtDisplayToApplicationContext
+ (DisplayOfScreen(screen)), msg);
+ XawDestroyDisplayList(dlist);
+ return (NULL);
+ }
+ }
+ else
+ proc->args = NULL;
+
+ proc->data = data;
+ }
+
+ dlist->qrep = XrmStringToQuark(string);
+ return (dlist);
+}
+
+String
+XawDisplayListString(_XawDisplayList *dlist)
+{
+ if (!dlist || dlist->qrep == NULLQUARK)
+ return ("");
+ return (XrmQuarkToString(dlist->qrep));
+}
+
+void
+XawDestroyDisplayList(_XawDisplayList *dlist)
+{
+ Cardinal i, j;
+ XawDLProc *proc;
+ XawDLData *data;
+
+ if (!dlist)
+ return;
+
+ for (i = 0; i < dlist->num_procs; i++)
+ {
+ proc = dlist->procs[i];
+ data = proc->data;
+
+ if (data)
+ {
+ if (data->dlclass->args_destructor)
+ data->dlclass->args_destructor(DisplayOfScreen(dlist->screen),
+ XrmQuarkToString(proc->qname),
+ proc->args,
+ proc->params, &proc->num_params);
+ if (data->data)
+ {
+ if (data->dlclass->data_destructor)
+ {
+ data->dlclass
+ ->data_destructor(DisplayOfScreen(dlist->screen),
+ data->dlclass->name, data->data);
+ data->data = NULL;
+ }
+ }
+ }
+
+ for (j = 0; j < proc->num_params; j++)
+ XtFree(proc->params[j]);
+ if (proc->num_params)
+ XtFree((char *)proc->params);
+ XtFree((char *)proc);
+ }
+
+ if (dlist->num_procs)
+ XtFree((char *)dlist->procs);
+
+ XtFree((char *)dlist);
+}
+
+/**********************************************************************
+ * If you want to implement your own class of procedures, look at
+ * the code bellow.
+ **********************************************************************/
+/* Start of Implementation of class "xlib" */
+typedef struct _XawXlibData {
+ GC gc;
+ unsigned long mask;
+ XGCValues values;
+ int shape;
+ int mode;
+ char *dashes;
+ /* these fields can be used for optimization, to
+ * avoid unnecessary coordinates recalculation.
+ */
+ Position x, y;
+ Dimension width, height;
+} XawXlibData;
+
+typedef struct _XawDLPosition {
+ Position pos;
+ short denom;
+ Boolean high;
+} XawDLPosition;
+
+typedef struct _XawDLPositionPtr {
+ XawDLPosition *pos;
+ Cardinal num_pos;
+} XawDLPositionPtr;
+
+typedef struct _XawDLArcArgs {
+ XawDLPosition pos[4];
+ int angle1;
+ int angle2;
+} XawDLArcArgs;
+
+typedef struct _XawDLStringArgs {
+ XawDLPosition pos[2];
+ char *string;
+ int length;
+} XawDLStringArgs;
+
+typedef struct _XawDLCopyArgs {
+ XawPixmap *pixmap;
+ XawDLPosition pos[6];
+ int plane;
+} XawDLCopyArgs;
+
+typedef struct _XawDLImageArgs {
+ XawPixmap *pixmap;
+ XawDLPosition pos[4];
+ int depth;
+} XawDLImageArgs;
+
+#define X_ARG(x) (Position)(((x).denom != 0) ? \
+ ((float)XtWidth(w) * ((float)(x).pos / (float)(x).denom)) : \
+ ((x).high ? XtWidth(w) - (x).pos : (x).pos))
+#define Y_ARG(x) (Position)(((x).denom != 0) ? \
+ ((float)XtHeight(w) * ((float)(x).pos / (float)(x).denom)): \
+ ((x).high ? XtHeight(w) - (x).pos : (x).pos))
+#define DRECT 0
+#define FRECT 1
+#define LINE 2
+#define GCFG 3
+#define GCBG 4
+#define FPOLY 5
+#define DARC 6
+#define FARC 7
+#define DLINES 8
+#define MASK 9
+#define UMASK 10
+#define LWIDTH 11
+#define POINT 12
+#define POINTS 13
+#define SEGMENTS 14
+#define ARCMODE 15
+#define COORDMODE 16
+#define SHAPEMODE 17
+#define LINESTYLE 18
+#define CAPSTYLE 19
+#define JOINSTYLE 20
+#define FILLSTYLE 21
+#define FILLRULE 22
+#define TILE 23
+#define STIPPLE 24
+#define TSORIGIN 25
+#define FUNCTION 26
+#define PLANEMASK 27
+#define DSTRING 28
+#define PSTRING 29
+#define FONT 30
+#define DASHES 31
+#define SUBWMODE 32
+#define EXPOSURES 33
+#define CLIPORIGIN 34
+#define CLIPMASK 35
+#define CLIPRECTS 36
+#define COPYAREA 37
+#define COPYPLANE 38
+#define IMAGE 39
+
+static void
+Dl1Point(Widget w, XtPointer args, XtPointer data, int id)
+{
+ XawDLPosition *pos = (XawDLPosition *)args;
+ XawXlibData *xdata = (XawXlibData *)data;
+ Display *display;
+ Window window;
+ Position x, y;
+
+ x = X_ARG(pos[0]);
+ y = Y_ARG(pos[1]);
+
+ if (!XtIsWidget(w))
+ {
+ Position xpad, ypad;
+
+ xpad = XtX(w) + XtBorderWidth(w);
+ ypad = XtY(w) + XtBorderWidth(w);
+ x += xpad;
+ y += ypad;
+ display = XtDisplayOfObject(w);
+ window = XtWindowOfObject(w);
+ }
+ else
+ {
+ display = XtDisplay(w);
+ window = XtWindow(w);
+ }
+
+ if (id == POINT)
+ XDrawPoint(display, window, xdata->gc, x, y);
+ else if (id == TSORIGIN)
+ {
+ xdata->values.ts_x_origin = x;
+ xdata->values.ts_y_origin = y;
+ xdata->mask |= GCTileStipXOrigin | GCTileStipYOrigin;
+ XSetTSOrigin(display, xdata->gc, x, y);
+ }
+ else if (id == CLIPORIGIN)
+ {
+ xdata->values.clip_x_origin = x;
+ xdata->values.clip_y_origin = y;
+ xdata->mask |= GCClipXOrigin | GCClipYOrigin;
+ XSetClipOrigin(display, xdata->gc, x, y);
+ }
+}
+
+static void
+Dl2Points(Widget w, XtPointer args, XtPointer data, int id)
+{
+ XawDLPosition *pos = (XawDLPosition *)args;
+ XawXlibData *xdata = (XawXlibData *)data;
+ Display *display;
+ Window window;
+ Position x1, y1, x2, y2;
+
+ x1 = X_ARG(pos[0]);
+ y1 = Y_ARG(pos[1]);
+ x2 = X_ARG(pos[2]);
+ y2 = Y_ARG(pos[3]);
+
+ if (!XtIsWidget(w))
+ {
+ Position xpad, ypad;
+
+ xpad = XtX(w) + XtBorderWidth(w);
+ ypad = XtY(w) + XtBorderWidth(w);
+ x1 += xpad; y1 += ypad;
+ x2 += xpad; y2 += ypad;
+ display = XtDisplayOfObject(w);
+ window = XtWindowOfObject(w);
+ }
+ else
+ {
+ display = XtDisplay(w);
+ window = XtWindow(w);
+ }
+
+ if (id == DRECT)
+ XDrawRectangle(display, window, xdata->gc, x1, y1, x2 - x1, y2 - y1);
+ else if (id == FRECT)
+ XFillRectangle(display, window, xdata->gc, x1, y1, x2 - x1, y2 - y1);
+ else if (id == LINE)
+ XDrawLine(display, window, xdata->gc, x1, y1, x2, y2);
+}
+
+/* ARGSUSED */
+static void
+DlLine(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region)
+{
+ Dl2Points(w, args, data, LINE);
+}
+
+/* ARGSUSED */
+static void
+DlDrawRectangle(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ Dl2Points(w, args, data, DRECT);
+}
+
+/* ARGSUSED */
+static void
+DlFillRectangle(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ Dl2Points(w, args, data, FRECT);
+}
+
+static void
+DlXPoints(Widget w, XtPointer args, XtPointer data, int id)
+{
+ XawDLPositionPtr *pos_ptr = (XawDLPositionPtr *)args;
+ XawXlibData *xdata = (XawXlibData *)data;
+ XawDLPosition *pos;
+ XPoint points_buf[16];
+ XPoint *points;
+ Display *display;
+ Window window;
+ Cardinal num_points, i, j;
+
+ num_points = pos_ptr->num_pos>>1;
+ points = (XPoint *)XawStackAlloc(sizeof(XPoint) * num_points, points_buf);
+
+ for (i = j = 0; i < num_points; i++, j = i << 1)
+ {
+ pos = &pos_ptr->pos[j];
+ points[i].x = X_ARG(pos[0]);
+ points[i].y = Y_ARG(pos[1]);
+ }
+
+ if (!XtIsWidget(w))
+ {
+ Position xpad, ypad;
+
+ xpad = XtX(w) + XtBorderWidth(w);
+ ypad = XtY(w) + XtBorderWidth(w);
+ if (xdata->mode != CoordModePrevious)
+ {
+ for (i = 0; i < num_points; i++)
+ {
+ points[i].x += xpad;
+ points[i].y += ypad;
+ }
+ }
+ else
+ {
+ points[0].x += xpad;
+ points[0].y += ypad;
+ }
+ display = XtDisplayOfObject(w);
+ window = XtWindowOfObject(w);
+ }
+ else
+ {
+ display = XtDisplay(w);
+ window = XtWindow(w);
+ }
+
+ if (id == FPOLY)
+ XFillPolygon(display, window, xdata->gc, points, num_points,
+ xdata->shape, xdata->mode);
+ else if (id == DLINES)
+ XDrawLines(display, window, xdata->gc, points, num_points, xdata->mode);
+ else if (id == POINTS)
+ XDrawPoints(display, window, xdata->gc, points, num_points, xdata->mode);
+
+ XawStackFree(points, points_buf);
+}
+
+/* ARGSUSED */
+static void
+DlFillPolygon(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ DlXPoints(w, args, data, FPOLY);
+}
+
+/* ARGSUSED */
+static void
+DlDrawLines(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ DlXPoints(w, args, data, DLINES);
+}
+
+/* ARGSUSED */
+static void
+DlDrawPoints(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ DlXPoints(w, args, data, POINTS);
+}
+
+/* ARGSUSED */
+static void
+DlForeground(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ Pixel foreground = (Pixel)args;
+
+ if (xdata->values.foreground != foreground)
+ {
+ xdata->mask |= GCForeground;
+ xdata->values.foreground = foreground;
+ XSetForeground(XtDisplayOfObject(w), xdata->gc, foreground);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlBackground(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ Pixel background = (Pixel)args;
+
+ if (xdata->values.background != background)
+ {
+ xdata->mask |= GCBackground;
+ xdata->values.background = background;
+ XSetBackground(XtDisplayOfObject(w), xdata->gc, background);
+ }
+}
+
+static void
+DlArc(Widget w, XtPointer args, XtPointer data, Bool fill)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ XawDLArcArgs *arc = (XawDLArcArgs *)args;
+ Position x1, y1, x2, y2;
+ Display *display;
+ Window window;
+
+ x1 = X_ARG(arc->pos[0]);
+ y1 = Y_ARG(arc->pos[1]);
+ x2 = X_ARG(arc->pos[2]);
+ y2 = Y_ARG(arc->pos[3]);
+
+ if (!XtIsWidget(w))
+ {
+ Position xpad, ypad;
+
+ xpad = XtX(w) + XtBorderWidth(w);
+ ypad = XtY(w) + XtBorderWidth(w);
+ x1 += xpad;
+ y1 += ypad;
+ x2 += xpad;
+ y2 += ypad;
+ display = XtDisplayOfObject(w);
+ window = XtWindowOfObject(w);
+ }
+ else
+ {
+ display = XtDisplay(w);
+ window = XtWindow(w);
+ }
+
+ if (fill)
+ XFillArc(display, window, xdata->gc, x1, y1, x2 - x1, y2 - y1,
+ arc->angle1, arc->angle2);
+ else
+ XDrawArc(display, window, xdata->gc, x1, y1, x2 - x1, y2 - y1,
+ arc->angle1, arc->angle2);
+}
+
+/* ARGSUSED */
+static void
+DlDrawArc(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ DlArc(w, args, data, False);
+}
+
+/* ARGSUSED */
+static void
+DlFillArc(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ DlArc(w, args, data, True);
+}
+
+/*ARGSUSED*/
+static void
+DlMask(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ Display *display = XtDisplayOfObject(w);
+
+ if (region)
+ XSetRegion(display, xdata->gc, region);
+ else if (event)
+ {
+ XRectangle rect;
+
+ rect.x = event->xexpose.x;
+ rect.y = event->xexpose.y;
+ rect.width = event->xexpose.width;
+ rect.height = event->xexpose.height;
+ XSetClipRectangles(display, xdata->gc, 0, 0, &rect, 1, Unsorted);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlUmask(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+
+ XSetClipMask(XtDisplayOfObject(w), xdata->gc, None);
+}
+
+/* ARGSUSED */
+static void
+DlLineWidth(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ unsigned line_width = (unsigned long)args;
+
+ if (xdata->values.line_width != line_width)
+ {
+ xdata->mask |= GCLineWidth;
+ xdata->values.line_width = line_width;
+ XChangeGC(XtDisplayOfObject(w), xdata->gc, GCLineWidth, &xdata->values);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlDrawPoint(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region)
+{
+ Dl1Point(w, args, data, POINT);
+}
+
+/* ARGSUSED */
+static void
+DlDrawSegments(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawDLPositionPtr *pos_ptr = (XawDLPositionPtr *)args;
+ XawXlibData *xdata = (XawXlibData *)data;
+ XawDLPosition *pos;
+ XSegment *segments;
+ XSegment segments_buf[8];
+ Display *display;
+ Window window;
+ Cardinal num_segments, i, j;
+
+ num_segments = pos_ptr->num_pos>>2;
+ segments = (XSegment *)XawStackAlloc(sizeof(XSegment) * num_segments, segments_buf);
+
+ for (i = j = 0; i < num_segments; i++, j = i << 2)
+ {
+ pos = &pos_ptr->pos[j];
+ segments[i].x1 = X_ARG(pos[0]);
+ segments[i].y1 = Y_ARG(pos[1]);
+ segments[i].x2 = X_ARG(pos[2]);
+ segments[i].y2 = Y_ARG(pos[3]);
+ }
+
+ if (!XtIsWidget(w))
+ {
+ Position xpad, ypad;
+
+ xpad = XtX(w) + XtBorderWidth(w);
+ ypad = XtY(w) + XtBorderWidth(w);
+ for (i = 0; i < num_segments; i++)
+ {
+ segments[i].x1 += xpad;
+ segments[i].y1 += ypad;
+ segments[i].x2 += xpad;
+ segments[i].y2 += ypad;
+ }
+ display = XtDisplayOfObject(w);
+ window = XtWindowOfObject(w);
+ }
+ else
+ {
+ display = XtDisplay(w);
+ window = XtWindow(w);
+ }
+
+ XDrawSegments(display, window, xdata->gc, segments, num_segments);
+
+ XawStackFree(segments, segments_buf);
+}
+
+/* ARGSUSED */
+static void
+DlArcMode(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ int arc_mode = (long)args;
+
+ if (xdata->values.arc_mode != arc_mode)
+ {
+ xdata->mask |= GCArcMode;
+ xdata->values.arc_mode = arc_mode;
+ XSetArcMode(XtDisplayOfObject(w), xdata->gc, arc_mode);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlCoordMode(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ int mode = (long)args;
+
+ xdata->mode = mode;
+}
+
+/* ARGSUSED */
+static void
+DlShapeMode(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ int shape = (long)args;
+
+ xdata->shape = shape;
+}
+
+/* ARGSUSED */
+static void
+DlLineStyle(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ int line_style = (long)args;
+
+ if (xdata->values.line_style != line_style)
+ {
+ xdata->mask |= GCLineStyle;
+ xdata->values.line_style = line_style;
+ XChangeGC(XtDisplayOfObject(w), xdata->gc, GCLineStyle, &xdata->values);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlCapStyle(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ int cap_style = (long)args;
+
+ if (xdata->values.cap_style != cap_style)
+ {
+ xdata->mask |= GCCapStyle;
+ xdata->values.cap_style = cap_style;
+ XChangeGC(XtDisplayOfObject(w), xdata->gc, GCCapStyle, &xdata->values);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlJoinStyle(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ int join_style = (long)args;
+
+ if (xdata->values.join_style != join_style)
+ {
+ xdata->mask |= GCJoinStyle;
+ xdata->values.join_style = join_style;
+ XChangeGC(XtDisplayOfObject(w), xdata->gc, GCJoinStyle, &xdata->values);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlFillStyle(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ int fill_style = (long)args;
+
+ if (xdata->values.fill_style != fill_style)
+ {
+ xdata->mask |= GCFillStyle;
+ xdata->values.fill_style = fill_style;
+ XSetFillStyle(XtDisplayOfObject(w), xdata->gc, fill_style);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlFillRule(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ int fill_rule = (long)args;
+
+ if (xdata->values.fill_rule != fill_rule)
+ {
+ xdata->mask |= GCFillRule;
+ xdata->values.fill_rule = fill_rule;
+ XSetFillRule(XtDisplayOfObject(w), xdata->gc, fill_rule);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlTile(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ XawPixmap *pixmap = (XawPixmap *)args;
+
+ if (pixmap && xdata->values.tile != pixmap->pixmap)
+ {
+ xdata->mask |= GCTile;
+ xdata->values.tile = pixmap->pixmap;
+ XSetTile(XtDisplayOfObject(w), xdata->gc, xdata->values.tile);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlStipple(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ XawPixmap *pixmap = (XawPixmap *)args;
+
+ if (pixmap && xdata->values.stipple != pixmap->pixmap)
+ {
+ xdata->mask |= GCStipple;
+ xdata->values.stipple = pixmap->pixmap;
+ XSetStipple(XtDisplayOfObject(w), xdata->gc, xdata->values.stipple);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlTSOrigin(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region)
+{
+ Dl1Point(w, args, data, TSORIGIN);
+}
+
+/* ARGSUSED */
+static void
+DlFunction(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ int function = (long)args;
+
+ if (function != xdata->values.function)
+ {
+ xdata->mask |= GCFunction;
+ xdata->values.function = function;
+ XSetFunction(XtDisplayOfObject(w), xdata->gc, function);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlPlaneMask(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ unsigned long plane_mask = (unsigned long)args;
+
+ if (xdata->values.plane_mask != plane_mask)
+ {
+ xdata->mask |= GCPlaneMask;
+ xdata->values.plane_mask = plane_mask;
+ XSetPlaneMask(XtDisplayOfObject(w), xdata->gc, plane_mask);
+ }
+}
+
+static void
+DlString(Widget w, XtPointer args, XtPointer data, Bool image)
+{
+ XawDLStringArgs *string = (XawDLStringArgs *)args;
+ XawXlibData *xdata = (XawXlibData *)data;
+ Display *display;
+ Window window;
+ Position x, y;
+
+ x = X_ARG(string->pos[0]);
+ y = Y_ARG(string->pos[1]);
+
+ if (!XtIsWidget(w))
+ {
+ Position xpad, ypad;
+
+ xpad = XtX(w) + XtBorderWidth(w);
+ ypad = XtY(w) + XtBorderWidth(w);
+ x += xpad;
+ y += ypad;
+ display = XtDisplayOfObject(w);
+ window = XtWindowOfObject(w);
+ }
+ else
+ {
+ display = XtDisplay(w);
+ window = XtWindow(w);
+ }
+
+ if (image)
+ XDrawImageString(display, window, xdata->gc, x, y, string->string, string->length);
+ else
+ XDrawString(display, window, xdata->gc, x, y, string->string, string->length);
+}
+
+/* ARGSUSED */
+static void
+DlDrawString(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ DlString(w, args, data, False);
+}
+
+/* ARGSUSED */
+static void
+DlPaintString(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ DlString(w, args, data, True);
+}
+
+/* ARGSUSED */
+static void
+DlFont(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ Font font = (Font)args;
+
+ if (xdata->values.font != font)
+ {
+ xdata->mask |= GCFont;
+ xdata->values.font = font;
+ XSetFont(XtDisplayOfObject(w), xdata->gc, font);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlDashes(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ char *dashes = args;
+
+ if (xdata->dashes != dashes)
+ {
+ xdata->mask |= GCDashOffset | GCDashList;
+ xdata->dashes = dashes;
+ XSetDashes(XtDisplayOfObject(w), xdata->gc, 0, dashes + 1, *dashes);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlSubwindowMode(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ int subwindow_mode = (long)args;
+
+ if (xdata->values.subwindow_mode != subwindow_mode)
+ {
+ xdata->mask |= GCSubwindowMode;
+ xdata->values.subwindow_mode = subwindow_mode;
+ XSetSubwindowMode(XtDisplayOfObject(w), xdata->gc, subwindow_mode);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlExposures(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ Bool graphics_exposures = (Bool)(long)args;
+
+ if (xdata->values.graphics_exposures != graphics_exposures)
+ {
+ xdata->mask |= GCGraphicsExposures;
+ xdata->values.graphics_exposures = graphics_exposures;
+ XSetGraphicsExposures(XtDisplayOfObject(w), xdata->gc, graphics_exposures);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlClipOrigin(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region)
+{
+ Dl1Point(w, args, data, CLIPORIGIN);
+}
+
+/* ARGSUSED */
+static void
+DlClipMask(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawXlibData *xdata = (XawXlibData *)data;
+ XawPixmap *pixmap = (XawPixmap *)args;
+ Pixmap clip_mask;
+
+ if (pixmap)
+ clip_mask = pixmap->mask ? pixmap->mask : pixmap->pixmap;
+ else
+ clip_mask = None;
+
+ if (xdata->values.clip_mask != clip_mask)
+ {
+ xdata->mask |= GCClipMask;
+ XSetClipMask(XtDisplayOfObject(w), xdata->gc, clip_mask);
+ }
+}
+
+/* ARGSUSED */
+static void
+DlClipRectangles(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ XawDLPositionPtr *pos_ptr = (XawDLPositionPtr *)args;
+ XawXlibData *xdata = (XawXlibData *)data;
+ XawDLPosition *pos;
+ XRectangle *rects;
+ XRectangle rects_buf[8];
+ Position x1, y1, x2, y2;
+ Cardinal num_rects, i, j;
+
+ num_rects = pos_ptr->num_pos>>2;
+ rects = (XRectangle *)XawStackAlloc(sizeof(XRectangle) * num_rects, rects_buf);
+
+ for (i = j = 0; i < num_rects; i++, j = i << 2)
+ {
+ pos = &pos_ptr->pos[j];
+ x1 = X_ARG(pos[0]);
+ y1 = Y_ARG(pos[1]);
+ x2 = X_ARG(pos[2]);
+ y2 = Y_ARG(pos[3]);
+ rects[i].x = XawMin(x1, x2);
+ rects[i].y = XawMin(y1, y2);
+ rects[i].width = XawMax(x1, x2) - rects[i].x;
+ rects[i].height = XawMax(y1, y2) - rects[i].y;
+ }
+
+ if (!XtIsWidget(w))
+ {
+ Position xpad, ypad;
+
+ xpad = XtX(w) + XtBorderWidth(w);
+ ypad = XtY(w) + XtBorderWidth(w);
+ for (i = 0; i < num_rects; i++)
+ {
+ rects[i].x += xpad;
+ rects[i].y += ypad;
+ }
+ }
+
+ XSetClipRectangles(XtDisplayOfObject(w), xdata->gc, 0, 0, rects, num_rects, Unsorted);
+
+ XawStackFree(rects, rects_buf);
+}
+
+static void
+DlCopy(Widget w, XtPointer args, XtPointer data, Bool plane)
+{
+ XawDLCopyArgs *copy = (XawDLCopyArgs *)args;
+ XawXlibData *xdata = (XawXlibData *)data;
+ int src_x, src_y, dst_x, dst_y, width, height, tmp1, tmp2;
+
+ tmp1 = X_ARG(copy->pos[0]);
+ tmp2 = X_ARG(copy->pos[2]);
+ dst_x = XawMin(tmp1, tmp2);
+ width = XawMax(tmp1, tmp2) - dst_x;
+
+ tmp1 = Y_ARG(copy->pos[1]);
+ tmp2 = Y_ARG(copy->pos[3]);
+ dst_y = XawMin(tmp1, tmp2);
+ height = XawMax(tmp1, tmp2) - dst_y;
+
+ src_x = X_ARG(copy->pos[4]);
+ src_y = Y_ARG(copy->pos[5]);
+
+ if (width <= 0)
+ {
+ if (copy->pixmap)
+ width = copy->pixmap->width;
+ else
+ {
+ if ((width = XtWidth(w) - src_x) < 0)
+ width = 0;
+ }
+ }
+ if (height <= 0)
+ {
+ if (copy->pixmap)
+ height = copy->pixmap->height;
+ else
+ {
+ if ((height = XtHeight(w) - src_y) < 0)
+ height = 0;
+ }
+ }
+
+ if (!XtIsWidget(w))
+ {
+ Position xpad, ypad;
+
+ xpad = XtX(w) + XtBorderWidth(w);
+ ypad = XtY(w) + XtBorderWidth(w);
+ src_x += xpad;
+ src_y += ypad;
+ dst_x += xpad;
+ dst_y += ypad;
+ }
+
+ if (plane)
+ XCopyPlane(XtDisplayOfObject(w), XtWindowOfObject(w),
+ copy->pixmap ? copy->pixmap->pixmap : XtWindowOfObject(w),
+ xdata->gc, src_x, src_y, width, height, dst_x, dst_y,
+ copy->plane ? copy->plane : 1);
+ else
+ XCopyArea(XtDisplayOfObject(w),
+ copy->pixmap ? copy->pixmap->pixmap : XtWindowOfObject(w),
+ XtWindowOfObject(w), xdata->gc, src_x, src_y, width, height, dst_x, dst_y);
+}
+
+/* ARGSUSED */
+static void
+DlCopyArea(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ DlCopy(w, args, data, False);
+}
+
+/* ARGSUSED */
+static void
+DlCopyPlane(Widget w, XtPointer args, XtPointer data,
+ XEvent *event, Region region)
+{
+ DlCopy(w, args, data, True);
+}
+
+/*ARGSUSED*/
+/* Note:
+ * This function is destructive if you set the ts_x_origin, ts_y_origin,
+ * and/or clip-mask. It is meant to be the only function used in a display
+ * list. If you need to use other functions (and those values), be sure to
+ * set them after calling this function.
+ */
+static void
+DlImage(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region)
+{
+ XawDLImageArgs *image = (XawDLImageArgs *)args;
+ XawXlibData *xdata = (XawXlibData *)data;
+ int x, y, xs, ys, xe, ye, width, height;
+ Display *display;
+ Window window;
+
+ width = image->pixmap->width;
+ height = image->pixmap->height;
+ xs = X_ARG(image->pos[0]);
+ ys = Y_ARG(image->pos[1]);
+ xe = X_ARG(image->pos[2]);
+ ye = Y_ARG(image->pos[3]);
+
+ if (xe <= 0)
+ xe = xs + width;
+ if (ye <= 0)
+ ye = ys + height;
+
+ if (!XtIsWidget(w))
+ {
+ Position xpad, ypad;
+
+ xpad = XtX(w) + XtBorderWidth(w);
+ ypad = XtY(w) + XtBorderWidth(w);
+ xe += xpad;
+ ye += ypad;
+ xe += xpad;
+ ye += ypad;
+ display = XtDisplayOfObject(w);
+ window = XtWindowOfObject(w);
+ }
+ else
+ {
+ display = XtDisplay(w);
+ window = XtWindow(w);
+ }
+
+ for (y = ys; y < ye; y += height)
+ for (x = xs; x < xe; x += width)
+ {
+ XSetClipOrigin(display, xdata->gc, x, y);
+ if (image->pixmap->mask)
+ XSetClipMask(display, xdata->gc, image->pixmap->mask);
+ if (image->depth == 1)
+ XCopyPlane(display, image->pixmap->pixmap, window, xdata->gc,
+ 0, 0, XawMin(width, xe - x), XawMin(height, ye - y),
+ x, y, 1L);
+ else
+ XCopyArea(display, image->pixmap->pixmap, window, xdata->gc, 0, 0,
+ XawMin(width, xe - x), XawMin(height, ye - y), x, y);
+ }
+
+ XSetClipMask(display, xdata->gc, None);
+}
+
+typedef struct _Dl_init Dl_init;
+struct _Dl_init {
+ String name;
+ XawDisplayListProc proc;
+ Cardinal id;
+};
+
+static Dl_init dl_init[] =
+{
+ {"arc-mode", DlArcMode, ARCMODE},
+ {"background", DlBackground, GCBG},
+ {"bg", DlBackground, GCBG},
+ {"cap-style", DlCapStyle, CAPSTYLE},
+ {"clip-mask", DlClipMask, CLIPMASK},
+ {"clip-origin", DlClipOrigin, CLIPORIGIN},
+ {"clip-rectangles", DlClipRectangles, CLIPRECTS},
+ {"clip-rects", DlClipRectangles, CLIPRECTS},
+ {"coord-mode", DlCoordMode, COORDMODE},
+ {"copy-area", DlCopyArea, COPYAREA},
+ {"copy-plane", DlCopyPlane, COPYPLANE},
+ {"dashes", DlDashes, DASHES},
+ {"draw-arc", DlDrawArc, DARC},
+ {"draw-line", DlLine, LINE},
+ {"draw-lines", DlDrawLines, DLINES},
+ {"draw-point", DlDrawPoint, POINT},
+ {"draw-points", DlDrawPoints, POINTS},
+ {"draw-rect", DlDrawRectangle, DRECT},
+ {"draw-rectangle", DlDrawRectangle, DRECT},
+ {"draw-segments", DlDrawSegments, SEGMENTS},
+ {"draw-string", DlDrawString, DSTRING},
+ {"exposures", DlExposures, EXPOSURES},
+ {"fg", DlForeground, GCFG},
+ {"fill-arc", DlFillArc, FARC},
+ {"fill-poly", DlFillPolygon, FPOLY},
+ {"fill-polygon", DlFillPolygon, FPOLY},
+ {"fill-rect", DlFillRectangle, FRECT},
+ {"fill-rectangle", DlFillRectangle, FRECT},
+ {"fill-rule", DlFillRule, FILLRULE},
+ {"fill-style", DlFillStyle, FILLSTYLE},
+ {"font", DlFont, FONT},
+ {"foreground", DlForeground, GCFG},
+ {"function", DlFunction, FUNCTION},
+ {"image", DlImage, IMAGE},
+ {"join-style", DlJoinStyle, JOINSTYLE},
+ {"line", DlLine, LINE},
+ {"line-style", DlLineStyle, LINESTYLE},
+ {"line-width", DlLineWidth, LWIDTH},
+ {"lines", DlDrawLines, DLINES},
+ {"mask", DlMask, MASK},
+ {"paint-string", DlPaintString, PSTRING},
+ {"plane-mask", DlPlaneMask, PLANEMASK},
+ {"point", DlDrawPoint, POINT},
+ {"points", DlDrawPoints, POINTS},
+ {"segments", DlDrawSegments, SEGMENTS},
+ {"shape-mode", DlShapeMode, SHAPEMODE},
+ {"stipple", DlStipple, STIPPLE},
+ {"subwindow-mode", DlSubwindowMode, SUBWMODE},
+ {"tile", DlTile, TILE},
+ {"ts-origin", DlTSOrigin, TSORIGIN},
+ {"umask", DlUmask, UMASK},
+};
+
+void
+XawDisplayListInitialize(void)
+{
+ static Bool first_time = True;
+ XawDLClass *lc;
+ Cardinal i;
+
+ if (first_time == False)
+ return;
+
+ first_time = False;
+
+ lc = XawCreateDisplayListClass(xlib,
+ _Xaw_Xlib_ArgsInitProc,
+ _Xaw_Xlib_ArgsDestructor,
+ _Xaw_Xlib_DataInitProc,
+ _Xaw_Xlib_DataDestructor);
+ for (i = 0; i < sizeof(dl_init) / sizeof(dl_init[0]); i++)
+ (void)XawDeclareDisplayListProc(lc, dl_init[i].name, dl_init[i].proc);
+}
+
+static int
+bcmp_cvt_proc(register _Xconst void *string,
+ register _Xconst void *dlinfo)
+{
+ return (strcmp((String)string, ((Dl_init*)dlinfo)->name));
+}
+
+static long
+read_int(char *cp, char **cpp)
+{
+ long value = 0, sign = 1;
+
+ if (*cp == '-')
+ {
+ sign = -1;
+ ++cp;
+ }
+ else if (*cp == '+')
+ ++cp;
+ value = 0;
+ while (*cp >= '0' && *cp <= '9')
+ {
+ value = value * 10 + *cp - '0';
+ ++cp;
+ }
+ if (cpp)
+ *cpp = cp;
+ return (value * sign);
+}
+
+static void
+read_position(char *arg, XawDLPosition *pos)
+{
+ int ch;
+ char *str = arg;
+
+ ch = *str;
+ if (ch == '-' || ch == '+')
+ {
+ ++str;
+ if (ch == '-')
+ pos->high = True;
+ pos->pos = read_int(str, NULL);
+ }
+ else if (isdigit(ch))
+ {
+ pos->pos = read_int(str, &str);
+ ch = *str++;
+ if (ch == '/')
+ pos->denom = read_int(str, NULL);
+ }
+}
+
+/* ARGSUSED */
+static void *
+_Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params,
+ Screen *screen, Colormap colormap, int depth)
+{
+ Cardinal id, i;
+ Dl_init *init;
+ void *retval = XAWDL_CONVERT_ERROR;
+
+ init = (Dl_init *)bsearch(proc_name, dl_init,
+ sizeof(dl_init) / sizeof(dl_init[0]),
+ sizeof(dl_init[0]),
+ bcmp_cvt_proc);
+
+ id = init->id;
+
+ switch (id)
+ {
+ case LINE:
+ case DRECT:
+ case FRECT:
+ if (*num_params == 4)
+ {
+ XawDLPosition *pos = (XawDLPosition *)XtCalloc(1, sizeof(XawDLPosition) * 4);
+
+ for (i = 0; i < 4; i++)
+ read_position(params[i], &pos[i]);
+ retval = (void *)pos;
+ }
+ break;
+ case POINT:
+ case TSORIGIN:
+ case CLIPORIGIN:
+ if (*num_params == 2)
+ {
+ XawDLPosition *pos = (XawDLPosition *)XtCalloc(1, sizeof(XawDLPosition) * 2);
+
+ read_position(params[0], &pos[0]);
+ read_position(params[1], &pos[1]);
+ retval = (void *)pos;
+ }
+ break;
+ case DLINES:
+ case FPOLY:
+ case POINTS:
+ if (*num_params >= 4 && !(*num_params & 1))
+ {
+ XawDLPositionPtr *pos = XtNew(XawDLPositionPtr);
+
+ pos->pos = (XawDLPosition *)XtCalloc(1, sizeof(XawDLPosition) *
+ *num_params);
+ pos->num_pos = *num_params;
+ for (i = 0; i < *num_params; i++)
+ read_position(params[i], &pos->pos[i]);
+ retval = (void *)pos;
+ }
+ break;
+ case SEGMENTS:
+ case CLIPRECTS:
+ if (*num_params >= 4 && !(*num_params % 4))
+ {
+ XawDLPositionPtr *pos = XtNew(XawDLPositionPtr);
+
+ pos->pos = (XawDLPosition *)XtCalloc(1, sizeof(XawDLPosition) *
+ *num_params);
+ pos->num_pos = *num_params;
+ for (i = 0; i < *num_params; i++)
+ read_position(params[i], &pos->pos[i]);
+ retval = (void *)pos;
+ }
+ break;
+ case DARC:
+ case FARC:
+ if (*num_params >= 4 && *num_params <= 6)
+ {
+ XawDLArcArgs *args = (XawDLArcArgs *)XtCalloc(1, sizeof(XawDLArcArgs));
+
+ args->angle1 = 0;
+ args->angle2 = 360;
+ for (i = 0; i < 4; i++)
+ read_position(params[i], &args->pos[i]);
+ if (*num_params > 4)
+ args->angle1 = read_int(params[4], NULL);
+ if (*num_params > 5)
+ args->angle2 = read_int(params[5], NULL);
+ args->angle1 *= 64;
+ args->angle2 *= 64;
+ retval = (void *)args;
+ }
+ break;
+ case GCFG:
+ case GCBG:
+ {
+ XColor xcolor;
+
+ if (*num_params == 1 &&
+ XAllocNamedColor(DisplayOfScreen(screen), colormap,
+ params[0], &xcolor, &xcolor))
+ retval = (void *)xcolor.pixel;
+ } break;
+ case MASK:
+ case UMASK:
+ if (*num_params == 0)
+ retval = NULL;
+ break;
+ case LWIDTH:
+ if (*num_params == 1)
+ retval = (void *)read_int(params[0], NULL);
+ break;
+ case ARCMODE:
+ if (*num_params == 1)
+ {
+ if (XmuCompareISOLatin1(params[0], "pieslice") == 0)
+ retval = (void *)ArcPieSlice;
+ else if (XmuCompareISOLatin1(params[0], "chord") == 0)
+ retval = (void *)ArcChord;
+ }
+ break;
+ case COORDMODE:
+ if (*num_params == 1)
+ {
+ if (XmuCompareISOLatin1(params[0], "origin") == 0)
+ retval = (void *)CoordModeOrigin;
+ else if (XmuCompareISOLatin1(params[0], "previous") == 0)
+ retval = (void *)CoordModePrevious;
+ }
+ break;
+ case SHAPEMODE:
+ if (*num_params == 1)
+ {
+ if (XmuCompareISOLatin1(params[0], "complex") == 0)
+ retval = (void *)Complex;
+ else if (XmuCompareISOLatin1(params[0], "convex") == 0)
+ retval = (void *)Convex;
+ else if (XmuCompareISOLatin1(params[0], "nonconvex") == 0)
+ retval = (void *)Nonconvex;
+ }
+ break;
+ case LINESTYLE:
+ if (*num_params == 1)
+ {
+ if (XmuCompareISOLatin1(params[0], "solid") == 0)
+ retval = (void *)LineSolid;
+ else if (XmuCompareISOLatin1(params[0], "onoffdash") == 0)
+ retval = (void *)LineOnOffDash;
+ else if (XmuCompareISOLatin1(params[0], "doubledash") == 0)
+ retval = (void *)LineDoubleDash;
+ }
+ break;
+ case CAPSTYLE:
+ if (*num_params == 1)
+ {
+ if (XmuCompareISOLatin1(params[0], "notlast") == 0)
+ retval = (void *)CapNotLast;
+ else if (XmuCompareISOLatin1(params[0], "butt") == 0)
+ retval = (void *)CapButt;
+ else if (XmuCompareISOLatin1(params[0], "round") == 0)
+ retval = (void *)CapRound;
+ else if (XmuCompareISOLatin1(params[0], "projecting") == 0)
+ retval = (void *)CapProjecting;
+ }
+ break;
+ case JOINSTYLE:
+ if (*num_params == 1)
+ {
+ if (XmuCompareISOLatin1(params[0], "miter") == 0)
+ retval = (void *)JoinMiter;
+ else if (XmuCompareISOLatin1(params[0], "round") == 0)
+ retval = (void *)JoinRound;
+ else if (XmuCompareISOLatin1(params[0], "bevel") == 0)
+ retval = (void *)JoinBevel;
+ }
+ break;
+ case FILLSTYLE:
+ if (*num_params == 1)
+ {
+ if (*num_params && XmuCompareISOLatin1(params[0], "solid") == 0)
+ retval = (void *)FillSolid;
+ else if (*num_params && XmuCompareISOLatin1(params[0], "tiled") == 0)
+ retval = (void *)FillTiled;
+ else if (*num_params && XmuCompareISOLatin1(params[0], "stippled") == 0)
+ retval = (void *)FillStippled;
+ else if (*num_params && XmuCompareISOLatin1(params[0], "opaquestippled") == 0)
+ retval = (void *)FillOpaqueStippled;
+ }
+ break;
+ case FILLRULE:
+ if (*num_params == 1)
+ {
+ if (XmuCompareISOLatin1(params[0], "evenodd") == 0)
+ retval = (void *)EvenOddRule;
+ else if (XmuCompareISOLatin1(params[0], "winding") == 0)
+ retval = (void *)WindingRule;
+ }
+ break;
+ case TILE:
+ if (*num_params == 1)
+ retval = (void *)XawLoadPixmap(params[0], screen, colormap, depth);
+ if (retval == NULL)
+ {
+ XtDisplayStringConversionWarning(DisplayOfScreen(screen), (String)params[0],
+ XtRPixmap);
+ retval = XAWDL_CONVERT_ERROR;
+ }
+ break;
+ case STIPPLE:
+ if (*num_params == 1)
+ retval = (void *)XawLoadPixmap(params[0], screen, colormap, 1);
+ if (retval == NULL)
+ {
+ XtDisplayStringConversionWarning(DisplayOfScreen(screen), (String)params[0],
+ XtRBitmap);
+ retval = XAWDL_CONVERT_ERROR;
+ }
+ break;
+ case FUNCTION:
+ if (*num_params == 1)
+ {
+ if (XmuCompareISOLatin1(params[0], "set") == 0)
+ retval = (void *)GXset;
+ else if (XmuCompareISOLatin1(params[0], "clear") == 0)
+ retval = (void *)GXclear;
+ else if (XmuCompareISOLatin1(params[0], "and") == 0)
+ retval = (void *)GXand;
+ else if (XmuCompareISOLatin1(params[0], "andreverse") == 0)
+ retval = (void *)GXandReverse;
+ else if (XmuCompareISOLatin1(params[0], "copy") == 0)
+ retval = (void *)GXcopy;
+ else if (XmuCompareISOLatin1(params[0], "andinverted") == 0)
+ retval = (void *)GXandInverted;
+ else if (XmuCompareISOLatin1(params[0], "noop") == 0)
+ retval = (void *)GXnoop;
+ else if (XmuCompareISOLatin1(params[0], "xor") == 0)
+ retval = (void *)GXxor;
+ else if (XmuCompareISOLatin1(params[0], "or") == 0)
+ retval = (void *)GXor;
+ else if (XmuCompareISOLatin1(params[0], "nor") == 0)
+ retval = (void *)GXnor;
+ else if (XmuCompareISOLatin1(params[0], "equiv") == 0)
+ retval = (void *)GXequiv;
+ else if (XmuCompareISOLatin1(params[0], "invert") == 0)
+ retval = (void *)GXinvert;
+ else if (XmuCompareISOLatin1(params[0], "orreverse") == 0)
+ retval = (void *)GXorReverse;
+ else if (XmuCompareISOLatin1(params[0], "copyinverted") == 0)
+ retval = (void *)GXcopyInverted;
+ else if (XmuCompareISOLatin1(params[0], "nand") == 0)
+ retval = (void *)GXnand;
+ }
+ break;
+ case PLANEMASK:
+ if (*num_params == 1)
+ retval = (void *)read_int(params[0], NULL);
+ break;
+ case DSTRING:
+ case PSTRING:
+ if (*num_params == 3)
+ {
+ XawDLStringArgs *string = (XawDLStringArgs *)
+ XtCalloc(1, sizeof(XawDLStringArgs));
+
+ read_position(params[0], &string->pos[0]);
+ read_position(params[1], &string->pos[1]);
+ string->string = XtNewString(params[2]);
+ string->length = strlen(string->string);
+ retval = string;
+ }
+ break;
+ case FONT:
+ if (*num_params == 1)
+ retval = (void *)XLoadFont(DisplayOfScreen(screen), params[0]);
+ break;
+ case DASHES:
+ if (*num_params && *num_params < 127)
+ {
+ char *dashes;
+
+ dashes = XtMalloc(*num_params + 1);
+
+ for (i = 0; i < *num_params; i++)
+ dashes[i + 1] = read_int(params[i], NULL);
+ *dashes = *num_params;
+ retval = dashes;
+ }
+ break;
+ case SUBWMODE:
+ if (*num_params == 1)
+ {
+ if (XmuCompareISOLatin1(params[0], "clipbychildren") == 0)
+ retval = (void *)ClipByChildren;
+ else if (XmuCompareISOLatin1(params[0], "includeinferiors") == 0)
+ retval = (void *)IncludeInferiors;
+ }
+ break;
+ case EXPOSURES:
+ if (*num_params == 1)
+ {
+ if (isdigit(params[0][0]) || params[0][0] == '+' || params[0][0] == '-')
+ retval = (void *)read_int(params[0], NULL);
+ else if (XmuCompareISOLatin1(params[0], "true") == 0 ||
+ XmuCompareISOLatin1(params[0], "on") == 0)
+ retval = (void *)True;
+ else if (XmuCompareISOLatin1(params[0], "false") == 0 ||
+ XmuCompareISOLatin1(params[0], "off") == 0)
+ retval = (void *)False;
+ }
+ break;
+ case CLIPMASK:
+ if (*num_params == 1)
+ retval = (void *)XawLoadPixmap(params[0], screen, colormap, 1);
+ if (retval == NULL)
+ {
+ retval = XAWDL_CONVERT_ERROR;
+ XtDisplayStringConversionWarning(DisplayOfScreen(screen), (String)params[0],
+ XtRPixmap);
+ }
+ break;
+ case COPYAREA:
+ case COPYPLANE:
+ if (*num_params > 2 && *num_params <= 7 + (id == COPYPLANE))
+ {
+ XawDLCopyArgs *args = (XawDLCopyArgs *)
+ XtCalloc(1, sizeof(XawDLCopyArgs));
+
+ retval = args;
+ if (params[0][0] == '\0' || strcmp(params[0], ".") == 0)
+ args->pixmap = NULL;
+ else
+ {
+ args->pixmap = XawLoadPixmap(params[0], screen, colormap, id == COPYPLANE ? 1 : depth);
+ if (args->pixmap == NULL)
+ {
+ XtDisplayStringConversionWarning(DisplayOfScreen(screen), (String)params[0],
+ XtRBitmap);
+ retval = XAWDL_CONVERT_ERROR;
+ XtFree((char *)args);
+ }
+ }
+ if (retval != XAWDL_CONVERT_ERROR)
+ {
+ for (i = 1; i < *num_params && i < 7; i++)
+ read_position(params[i], &args->pos[i - 1]);
+ if (*num_params > 7)
+ args->plane = read_int(params[7], NULL);
+ }
+ }
+ break;
+ case IMAGE:
+ if (*num_params > 2 && *num_params <= 7)
+ {
+ XawDLImageArgs *args = (XawDLImageArgs *)
+ XtCalloc(1, sizeof(XawDLImageArgs));
+
+ retval = args;
+ args->pixmap = XawLoadPixmap(params[0], screen, colormap, depth);
+ if (args->pixmap == NULL)
+ {
+ XtDisplayStringConversionWarning(DisplayOfScreen(screen),
+ (String)params[0], XtRPixmap);
+ retval = XAWDL_CONVERT_ERROR;
+ XtFree((char *)args);
+ }
+ else
+ {
+ args->depth = depth;
+ for (i = 1; i < *num_params && i < 5; i++)
+ read_position(params[i], &args->pos[i - 1]);
+ }
+ }
+ break;
+ }
+
+ return (retval);
+}
+
+/* ARGSUSED */
+static void *
+_Xaw_Xlib_DataInitProc(String class_name,
+ Screen *screen, Colormap colormap, int depth)
+{
+ XawXlibData *data;
+ Window tmp_win;
+
+ data = (XawXlibData *)XtMalloc(sizeof(XawXlibData));
+
+ tmp_win = XCreateWindow(DisplayOfScreen(screen),
+ RootWindowOfScreen(screen),
+ 0, 0, 1, 1, 1, depth,
+ InputOutput, CopyFromParent, 0, NULL);
+ data->mask = 0;
+ data->gc = XCreateGC(DisplayOfScreen(screen), tmp_win, 0, &data->values);
+ XDestroyWindow(DisplayOfScreen(screen), tmp_win);
+ data->shape = Complex;
+ data->mode = CoordModeOrigin;
+ data->dashes = NULL;
+
+ return ((void *)data);
+}
+
+/* ARGSUSED */
+static void
+_Xaw_Xlib_ArgsDestructor(Display *display, String proc_name, XtPointer args,
+ String *params, Cardinal *num_params)
+{
+ Cardinal id;
+ Dl_init *init;
+
+ init = (Dl_init *)bsearch(proc_name, dl_init,
+ sizeof(dl_init) / sizeof(dl_init[0]),
+ sizeof(dl_init[0]),
+ bcmp_cvt_proc);
+
+ id = init->id;
+
+ switch (id)
+ {
+ case LINE:
+ case DRECT:
+ case FRECT:
+ case DARC:
+ case FARC:
+ case POINT:
+ case TSORIGIN:
+ case DASHES:
+ case CLIPORIGIN:
+ case COPYAREA:
+ case COPYPLANE:
+ case IMAGE:
+ XtFree(args);
+ break;
+ case DSTRING:
+ case PSTRING:
+ {
+ XawDLStringArgs *string = (XawDLStringArgs *)args;
+ XtFree(string->string);
+ XtFree(args);
+ } break;
+ case DLINES:
+ case FPOLY:
+ case POINTS:
+ case SEGMENTS:
+ case CLIPRECTS:
+ {
+ XawDLPositionPtr *ptr = (XawDLPositionPtr *)args;
+
+ XtFree((char *)ptr->pos);
+ XtFree(args);
+ } break;
+ }
+}
+
+/* ARGSUSED */
+static void
+_Xaw_Xlib_DataDestructor(Display *display, String class_name, XtPointer data)
+{
+ if (data)
+ {
+ XawXlibData *xdata = (XawXlibData *)data;
+
+ XFreeGC(display, xdata->gc);
+ if (xdata->dashes)
+ XtFree(xdata->dashes);
+ XtFree((char *)data);
+ }
+}
+
+/* Start of DLInfo Management Functions */
+static int
+qcmp_dlist_info(register _Xconst void *left, register _Xconst void *right)
+{
+ return (strcmp((*(XawDLInfo **)left)->name, (*(XawDLInfo **)right)->name));
+}
+
+Bool XawDeclareDisplayListProc(XawDLClass *lc, String name,
+ XawDisplayListProc proc)
+{
+ XawDLInfo *info;
+
+ if (!lc || !proc || !name || name[0] == '\0')
+ return (False);
+
+ if ((info = _XawFindDLInfo(lc, name)) != NULL)
+ /* Since the data structures to the displayList classes are(should be)
+ * opaque, it is not a good idea to allow overriding a displayList
+ * procedure; it's better to choose another name or class name!
+ */
+ return (False);
+
+ info = (XawDLInfo *)XtMalloc(sizeof(XawDLInfo));
+ info->name = XtNewString(name);
+ info->qname = XrmStringToQuark(info->name);
+ info->proc = proc;
+
+ if (!lc->num_infos)
+ {
+ lc->num_infos = 1;
+ lc->infos = (XawDLInfo **)XtMalloc(sizeof(XawDLInfo*));
+ }
+ else
+ {
+ ++lc->num_infos;
+ lc->infos = (XawDLInfo **)
+ XtRealloc((char *)lc->infos, sizeof(XawDLInfo*) * lc->num_infos);
+ }
+ lc->infos[lc->num_infos - 1] = info;
+
+ if (lc->num_infos > 1)
+ qsort(lc->infos, lc->num_infos, sizeof(XawDLInfo*), qcmp_dlist_info);
+
+ return (True);
+}
+
+static int
+bcmp_dlist_info(register _Xconst void *string,
+ register _Xconst void *dlinfo)
+{
+ return (strcmp((String)string, (*(XawDLClass **)dlinfo)->name));
+}
+
+static XawDLInfo *
+_XawFindDLInfo(XawDLClass *lc, String name)
+{
+ XawDLInfo **info;
+
+ if (!lc->infos)
+ return (NULL);
+
+ info = (XawDLInfo **)bsearch(name, lc->infos, lc->num_infos,
+ sizeof(XawDLInfo*), bcmp_dlist_info);
+
+ return (info ? *info : NULL);
+}
+
+/* Start of DLClass Management Functions */
+XawDLClass *
+XawGetDisplayListClass(String name)
+{
+ return (_XawFindDLClass(name));
+}
+
+static int
+qcmp_dlist_class(register _Xconst void *left, register _Xconst void *right)
+{
+ return (strcmp((*(XawDLClass **)left)->name, (*(XawDLClass **)right)->name));
+}
+
+XawDLClass *
+XawCreateDisplayListClass(String name,
+ XawDLArgsInitProc args_init,
+ XawDLArgsDestructor args_destructor,
+ XawDLDataInitProc data_init,
+ XawDLDataDestructor data_destructor)
+{
+ XawDLClass *lc;
+
+ if (!name || name[0] == '\0')
+ return (NULL);
+
+ lc = (XawDLClass *)XtMalloc(sizeof(XawDLClass));
+ lc->name = XtNewString(name);
+ lc->infos = NULL;
+ lc->num_infos = 0;
+ lc->args_init = args_init;
+ lc->args_destructor = args_destructor;
+ lc->data_init = data_init;
+ lc->data_destructor = data_destructor;
+
+ if (!classes)
+ {
+ num_classes = 1;
+ classes = (XawDLClass **)XtMalloc(sizeof(XawDLClass));
+ }
+ else
+ {
+ ++num_classes;
+ classes = (XawDLClass **)XtRealloc((char *)classes,
+ sizeof(XawDLClass) * num_classes);
+ }
+ classes[num_classes - 1] = lc;
+
+ if (num_classes > 1)
+ qsort(&classes[0], num_classes, sizeof(XawDLClass*), qcmp_dlist_class);
+
+ return (lc);
+}
+
+static int
+bcmp_dlist_class(register _Xconst void *string,
+ register _Xconst void *dlist)
+{
+ return (strcmp((String)string, (*(XawDLClass **)dlist)->name));
+}
+
+static XawDLClass *
+_XawFindDLClass(String name)
+{
+ XawDLClass **lc;
+
+ if (!classes)
+ return (NULL);
+
+ lc = (XawDLClass **)bsearch(name, &classes[0], num_classes,
+ sizeof(XawDLClass*), bcmp_dlist_class);
+
+ return (lc ? *lc : NULL);
+}
+
+#endif /* OLDXAW */
diff --git a/nx-X11/lib/Xaw/Form.c b/nx-X11/lib/Xaw/Form.c
new file mode 100644
index 000000000..1d162407b
--- /dev/null
+++ b/nx-X11/lib/Xaw/Form.c
@@ -0,0 +1,1110 @@
+/* $Xorg: Form.c,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+
+/* $XFree86: xc/lib/Xaw/Form.c,v 1.20 2001/02/05 22:38:04 paulo Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xaw/FormP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+/*
+ * Class Methods
+ */
+static void XawFormChangeManaged(Widget);
+static void XawFormClassInitialize(void);
+static void XawFormClassPartInitialize(WidgetClass);
+static void XawFormConstraintInitialize(Widget, Widget, ArgList, Cardinal*);
+static Boolean XawFormConstraintSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+static XtGeometryResult XawFormGeometryManager(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawFormInitialize(Widget, Widget, ArgList, Cardinal*);
+#ifndef OLDXAW
+static void XawFormRealize(Widget, Mask*, XSetWindowAttributes*);
+static void XawFormRedisplay(Widget, XEvent*, Region);
+#endif
+static XtGeometryResult XawFormQueryGeometry(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawFormResize(Widget);
+static Boolean XawFormSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
+static Boolean Layout(FormWidget, unsigned int, unsigned int, Bool);
+
+/*
+ * Prototypes
+ */
+static void _CvtStringToEdgeType(XrmValuePtr, Cardinal*,
+ XrmValuePtr, XrmValuePtr);
+static Bool ChangeFormGeometry(Widget, Bool, unsigned int, unsigned int,
+ Dimension*, Dimension*);
+Boolean CvtEdgeTypeToString(Display*, XrmValuePtr, Cardinal*,
+ XrmValuePtr, XrmValuePtr, XtPointer*);
+static void LayoutChild(Widget);
+static int TransformCoord(int, unsigned int, unsigned int, XtEdgeType);
+static void ResizeChildren(Widget);
+
+/*
+ * Initialization
+ */
+#ifndef OLDXAW
+static XtActionsRec actions[] = {
+ {"set-values", XawSetValuesAction},
+ {"get-values", XawGetValuesAction},
+ {"declare", XawDeclareAction},
+ {"call-proc", XawCallProcAction},
+};
+#endif
+
+static XrmQuark QchainLeft, QchainRight, QchainTop, QchainBottom, Qrubber;
+
+#define default_value -99999
+#define Offset(field) XtOffsetOf(FormRec, form.field)
+static XtResource resources[] = {
+ {
+ XtNdefaultDistance,
+ XtCThickness,
+ XtRInt,
+ sizeof(int),
+ Offset(default_spacing),
+ XtRImmediate,
+ (XtPointer)4
+ },
+#ifndef OLDXAW
+ {
+ XawNdisplayList,
+ XawCDisplayList,
+ XawRDisplayList,
+ sizeof(XawDisplayList*),
+ Offset(display_list),
+ XtRImmediate,
+ NULL
+ },
+#endif
+};
+#undef Offset
+
+#define defEdge XtRubber
+
+#define Offset(field) XtOffsetOf(FormConstraintsRec, form.field)
+static XtResource formConstraintResources[] = {
+ {
+ XtNtop,
+ XtCEdge,
+ XtREdgeType,
+ sizeof(XtEdgeType),
+ Offset(top),
+ XtRImmediate,
+ (XtPointer)defEdge
+ },
+ {
+ XtNbottom,
+ XtCEdge,
+ XtREdgeType,
+ sizeof(XtEdgeType),
+ Offset(bottom),
+ XtRImmediate,
+ (XtPointer)defEdge
+ },
+ {
+ XtNleft,
+ XtCEdge,
+ XtREdgeType,
+ sizeof(XtEdgeType),
+ Offset(left),
+ XtRImmediate,
+ (XtPointer)defEdge
+ },
+ {
+ XtNright,
+ XtCEdge,
+ XtREdgeType,
+ sizeof(XtEdgeType),
+ Offset(right),
+ XtRImmediate,
+ (XtPointer)defEdge
+ },
+ {
+ XtNhorizDistance,
+ XtCThickness,
+ XtRInt,
+ sizeof(int),
+ Offset(dx),
+ XtRImmediate,
+ (XtPointer)default_value
+ },
+ {
+ XtNfromHoriz,
+ XtCWidget,
+ XtRWidget,
+ sizeof(Widget),
+ Offset(horiz_base),
+ XtRWidget,
+ NULL
+ },
+ {
+ XtNvertDistance,
+ XtCThickness,
+ XtRInt,
+ sizeof(int),
+ Offset(dy),
+ XtRImmediate,
+ (XtPointer)default_value
+ },
+ {
+ XtNfromVert,
+ XtCWidget,
+ XtRWidget,
+ sizeof(Widget),
+ Offset(vert_base),
+ XtRWidget,
+ NULL
+ },
+ {
+ XtNresizable,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ Offset(allow_resize),
+ XtRImmediate,
+ (XtPointer)False
+ },
+};
+#undef Offset
+
+FormClassRec formClassRec = {
+ /* core */
+ {
+ (WidgetClass)&constraintClassRec, /* superclass */
+ "Form", /* class_name */
+ sizeof(FormRec), /* widget_size */
+ XawFormClassInitialize, /* class_initialize */
+ XawFormClassPartInitialize, /* class_part_init */
+ False, /* class_inited */
+ XawFormInitialize, /* initialize */
+ NULL, /* initialize_hook */
+#ifndef OLDXAW
+ XawFormRealize, /* realize */
+ actions, /* actions */
+ XtNumber(actions), /* num_actions */
+#else
+ XtInheritRealize, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+#endif
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ NULL, /* destroy */
+ XawFormResize, /* resize */
+#ifndef OLDXAW
+ XawFormRedisplay, /* expose */
+#else
+ XtInheritExpose, /* expose */
+#endif
+ XawFormSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ XawFormQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* composite */
+ {
+ XawFormGeometryManager, /* geometry_manager */
+ XawFormChangeManaged, /* change_managed */
+ XtInheritInsertChild, /* insert_child */
+ XtInheritDeleteChild, /* delete_child */
+ NULL, /* extension */
+ },
+ /* constraint */
+ {
+ formConstraintResources, /* subresourses */
+ XtNumber(formConstraintResources), /* subresource_count */
+ sizeof(FormConstraintsRec), /* constraint_size */
+ XawFormConstraintInitialize, /* initialize */
+ NULL, /* destroy */
+ XawFormConstraintSetValues, /* set_values */
+ NULL, /* extension */
+ },
+ /* form */
+ {
+ Layout, /* layout */
+ },
+};
+
+WidgetClass formWidgetClass = (WidgetClass)&formClassRec;
+
+/*
+ * Implementation
+ */
+#ifndef OLDXAW
+static void
+XawFormRealize(Widget w, Mask *mask, XSetWindowAttributes *attr)
+{
+ XawPixmap *pixmap;
+
+ (*formWidgetClass->core_class.superclass->core_class.realize)(w, mask, attr);
+
+ if (w->core.background_pixmap > XtUnspecifiedPixmap) {
+ pixmap = XawPixmapFromXPixmap(w->core.background_pixmap, XtScreen(w),
+ w->core.colormap, w->core.depth);
+ if (pixmap && pixmap->mask)
+ XawReshapeWidget(w, pixmap);
+ }
+}
+
+static void
+XawFormRedisplay(Widget w, XEvent *event, Region region)
+{
+ FormWidget xaw = (FormWidget)w;
+
+ if (xaw->form.display_list)
+ XawRunDisplayList(w, xaw->form.display_list, event, region);
+}
+#endif
+
+/*ARGSUSED*/
+static void
+_CvtStringToEdgeType(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static XtEdgeType edgeType;
+ XrmQuark q;
+ char name[12];
+
+ XmuNCopyISOLatin1Lowered(name, (char*)fromVal->addr, sizeof(name));
+ q = XrmStringToQuark(name);
+
+ if (q == QchainLeft)
+ edgeType = XtChainLeft;
+ else if (q == QchainRight)
+ edgeType = XtChainRight;
+ else if (q == QchainTop)
+ edgeType = XtChainTop;
+ else if (q == QchainBottom)
+ edgeType = XtChainBottom;
+ else if (q == Qrubber)
+ edgeType = XtRubber;
+ else {
+ XtStringConversionWarning(fromVal->addr, XtREdgeType);
+ toVal->size = 0;
+ toVal->addr = NULL;
+ return;
+ }
+
+ toVal->size = sizeof(XtEdgeType);
+ toVal->addr = (XPointer)&edgeType;
+}
+
+/*ARGSUSED*/
+Boolean
+CvtEdgeTypeToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal, XtPointer *data)
+{
+ static String buffer;
+ Cardinal size;
+
+ switch (*(XtEdgeType *)fromVal->addr) {
+ case XtChainLeft:
+ buffer = XtEchainLeft;
+ break;
+ case XtChainRight:
+ buffer = XtEchainRight;
+ break;
+ case XtChainTop:
+ buffer = XtEchainTop;
+ break;
+ case XtChainBottom:
+ buffer = XtEchainBottom;
+ break;
+ case XtRubber:
+ buffer = XtErubber;
+ break;
+ default:
+ XawTypeToStringWarning(dpy, XtREdgeType);
+ toVal->addr = NULL;
+ toVal->size = 0;
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL) {
+ if (toVal->size < size) {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
+
+static void
+XawFormClassInitialize(void)
+{
+ static XtConvertArgRec parentCvtArgs[] = {
+ {XtBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.parent),
+ sizeof(Widget)}
+ };
+
+ char name[12];
+
+ XawInitializeWidgetSet();
+ XmuNCopyISOLatin1Lowered(name, XtEchainLeft, sizeof(name));
+ QchainLeft = XrmStringToQuark(name);
+ XmuNCopyISOLatin1Lowered(name, XtEchainRight, sizeof(name));
+ QchainRight = XrmStringToQuark(name);
+ XmuNCopyISOLatin1Lowered(name, XtEchainTop, sizeof(name));
+ QchainTop = XrmStringToQuark(name);
+ XmuNCopyISOLatin1Lowered(name, XtEchainBottom, sizeof(name));
+ QchainBottom = XrmStringToQuark(name);
+ XmuNCopyISOLatin1Lowered(name, XtErubber, sizeof(name));
+ Qrubber = XrmStringToQuark(name);
+
+ XtAddConverter(XtRString, XtREdgeType, _CvtStringToEdgeType, NULL, 0);
+ XtSetTypeConverter(XtREdgeType, XtRString, CvtEdgeTypeToString,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRString, XtRWidget, XmuNewCvtStringToWidget,
+ parentCvtArgs, XtNumber(parentCvtArgs), XtCacheNone,
+ NULL);
+ XtSetTypeConverter(XtRWidget, XtRString, XmuCvtWidgetToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+
+static void
+XawFormClassPartInitialize(WidgetClass cclass)
+{
+ FormWidgetClass c = (FormWidgetClass)cclass;
+ FormWidgetClass super = (FormWidgetClass)c->core_class.superclass;
+
+ if (c->form_class.layout == XtInheritLayout)
+ c->form_class.layout = super->form_class.layout;
+}
+
+/*ARGSUSED*/
+static void
+XawFormInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ FormWidget fw = (FormWidget)cnew;
+
+ fw->form.old_width = fw->form.old_height = 0;
+ fw->form.no_refigure = False;
+ fw->form.needs_relayout = False;
+ fw->form.resize_in_layout = True;
+ fw->form.resize_is_no_op = False;
+}
+
+/*
+ * Function:
+ * ChangeFormGeometry
+ *
+ * Parameters:
+ * w - Form widget
+ * query_only - is only a query?
+ * width - new width and height
+ * height - ""
+ * ret_width - actual size the form is allowed to resize to (return)
+ * ret_height - ""
+ *
+ * Description:
+ * Ask the parent to change the form widget's geometry.
+ *
+ * Returns:
+ * True of children may always be resized
+ */
+static Bool
+ChangeFormGeometry(Widget w, Bool query_only,
+ unsigned int width, unsigned int height,
+ Dimension *ret_width, Dimension *ret_height)
+{
+ FormWidget fw = (FormWidget)w;
+ Boolean always_resize_children;
+ XtGeometryResult result;
+ XtWidgetGeometry request, return_request;
+
+ /*
+ * If we are already at the desired size then there is no need
+ * to ask our parent of we can change size
+ */
+ if (width == XtWidth(fw) && height == XtHeight(fw))
+ return (True);
+
+ request.width = width;
+ request.height = height;
+ request.request_mode = CWWidth | CWHeight;
+ if (query_only)
+ request.request_mode |= XtCWQueryOnly;
+
+ /*
+ * Do no invoke the resize rules if our size changes here
+ */
+ fw->form.resize_is_no_op = True;
+
+ result = XtMakeGeometryRequest(w, &request, &return_request);
+ if (result == XtGeometryAlmost) {
+ request = return_request;
+ (void)XtMakeGeometryRequest(w, &request, &return_request);
+ always_resize_children = False;
+ }
+ else
+ always_resize_children = result == XtGeometryYes;
+
+ fw->form.resize_is_no_op = False;
+
+ if (ret_width != NULL)
+ *ret_width = request.width;
+ if (ret_height != NULL)
+ *ret_height = request.height;
+
+ return (always_resize_children);
+}
+
+/*
+ * Function:
+ * Layout
+ *
+ * Parameters:
+ * fw - Form widget
+ * width - unused
+ * height - ""
+ * force_relayout - will force the children to be moved, even if some
+ * go past the edge of the form
+ *
+ * Description:
+ * Moves all the children around.
+ *
+ * Returns:
+ * True if the children are allowed to move from their
+ * current locations to the new ones.
+ */
+/*ARGSUSED*/
+static Boolean
+Layout(FormWidget fw, unsigned int width, unsigned int height,
+ Bool force_relayout)
+{
+ int num_children = fw->composite.num_children;
+ WidgetList children = fw->composite.children;
+ Widget *childP;
+ Dimension maxx, maxy;
+ Boolean ret_val;
+
+ for (childP = children; childP - children < num_children; childP++) {
+ FormConstraints form = (FormConstraints)(*childP)->core.constraints;
+ form->form.layout_state = LayoutPending;
+ }
+
+ maxx = maxy = 1;
+ for (childP = children; childP - children < num_children; childP++) {
+ if (XtIsManaged(*childP)) {
+ FormConstraints form;
+ Position x, y;
+
+ form = (FormConstraints)(*childP)->core.constraints;
+
+ LayoutChild(*childP);
+
+ x = form->form.new_x + XtWidth(*childP)
+ + (XtBorderWidth(*childP) << 1);
+ if (x > (int)maxx)
+ maxx = x;
+
+ y = form->form.new_y + XtHeight(*childP)
+ + (XtBorderWidth(*childP) << 1);
+ if (y > (int)maxy)
+ maxy = y;
+ }
+ }
+
+ fw->form.preferred_width = (maxx += fw->form.default_spacing);
+ fw->form.preferred_height = (maxy += fw->form.default_spacing);
+
+ if (fw->form.resize_in_layout) {
+ Boolean always_resize_children;
+
+ always_resize_children =
+ ChangeFormGeometry((Widget)fw, False, maxx, maxy, NULL, NULL);
+
+#ifdef OLDXAW
+ fw->form.old_width = fw->core.width;
+ fw->form.old_height = fw->core.height;
+#endif
+
+ if (force_relayout)
+ ret_val = True;
+ else
+ ret_val = always_resize_children ||
+ (XtWidth(fw) >= maxx && XtHeight(fw) >= maxy);
+
+ if (ret_val)
+ ResizeChildren((Widget)fw);
+ }
+ else
+ ret_val = False;
+
+ fw->form.needs_relayout = False;
+
+ return (ret_val);
+}
+
+/*
+ * Function:
+ * ResizeChildren
+ *
+ * Parameters:
+ * w - form widget
+ *
+ * Description:
+ * Resizes all children to new_x and new_y.
+ */
+static void
+ResizeChildren(Widget w)
+{
+ FormWidget fw = (FormWidget)w;
+ int num_children = fw->composite.num_children;
+ WidgetList children = fw->composite.children;
+ Widget *childP;
+
+ for (childP = children; childP - children < num_children; childP++) {
+ FormConstraints form;
+ Position x, y;
+
+ if (!XtIsManaged(*childP))
+ continue;
+
+ form = (FormConstraints)(*childP)->core.constraints;
+
+ if (fw->form.old_width && fw->form.old_height) {
+ x = TransformCoord(form->form.new_x, fw->form.old_width,
+ XtWidth(fw), form->form.left);
+ y = TransformCoord(form->form.new_y, fw->form.old_height,
+ XtHeight(fw), form->form.top);
+ }
+ else {
+ x = form->form.new_x;
+ y = form->form.new_y;
+ }
+
+ if (fw->form.no_refigure) {
+ /*
+ * I am changing the widget wrapper w/o modifing the window. This is
+ * risky, but I can get away with it since I am the parent of this
+ * widget, and he must ask me for any geometry changes
+ *
+ * The window will be updated when no_refigure is set back to False
+ */
+ XtX(*childP) = x;
+ XtY(*childP) = y;
+ }
+ else
+ XtMoveWidget(*childP, x, y);
+ }
+}
+
+static void
+LayoutChild(Widget w)
+{
+ FormConstraints form = (FormConstraints)w->core.constraints;
+ Widget ref;
+
+ switch (form->form.layout_state) {
+ case LayoutPending:
+ form->form.layout_state = LayoutInProgress;
+ break;
+ case LayoutDone:
+ return;
+ case LayoutInProgress: {
+ String subs[2];
+ Cardinal num_subs = 2;
+ subs[0] = w->core.name;
+ subs[1] = w->core.parent->core.name;
+
+ XtAppWarningMsg(XtWidgetToApplicationContext(w),
+ "constraintLoop", "xawFormLayout", "XawToolkitError",
+ "constraint loop detected while laying out "
+ "child '%s' in FormWidget '%s'",
+ subs, &num_subs);
+ } return;
+ }
+
+ form->form.new_x = form->form.dx;
+ form->form.new_y = form->form.dy;
+ if ((ref = form->form.horiz_base) != NULL) {
+ FormConstraints ref_form = (FormConstraints)ref->core.constraints;
+
+ LayoutChild(ref);
+ form->form.new_x += ref_form->form.new_x + XtWidth(ref) +
+ (XtBorderWidth(ref) << 1);
+ }
+ if ((ref = form->form.vert_base) != NULL) {
+ FormConstraints ref_form = (FormConstraints)ref->core.constraints;
+
+ LayoutChild(ref);
+ form->form.new_y += ref_form->form.new_y + XtHeight(ref) +
+ (XtBorderWidth(ref) << 1);
+ }
+
+ form->form.layout_state = LayoutDone;
+}
+
+static int
+TransformCoord(int loc, unsigned int old, unsigned int cnew, XtEdgeType type)
+{
+ if (type == XtRubber) {
+ if ((int)old > 0)
+ loc = (int)(loc * ((double)cnew / (double)old));
+ }
+ else if (type == XtChainBottom || type == XtChainRight)
+ loc += (int)cnew - (int)old;
+
+ return (loc);
+}
+
+static void
+XawFormResize(Widget w)
+{
+ FormWidget fw = (FormWidget)w;
+ WidgetList children = fw->composite.children;
+ int num_children = fw->composite.num_children;
+ Widget *childP;
+ int x, y;
+ int width, height;
+ Boolean unmap = XtIsRealized(w) && w->core.mapped_when_managed &&
+ XtIsManaged(w);
+
+ if (unmap)
+ XtUnmapWidget(w);
+
+ if (!fw->form.resize_is_no_op)
+ for (childP = children; childP - children < num_children; childP++) {
+ FormConstraints form = (FormConstraints)(*childP)->core.constraints;
+
+ if (!XtIsManaged(*childP))
+ continue;
+
+#ifndef OLDXAW
+ x = TransformCoord(form->form.virtual_x, fw->form.old_width,
+ XtWidth(fw), form->form.left);
+ y = TransformCoord(form->form.virtual_y, fw->form.old_height,
+ XtHeight(fw), form->form.top);
+ width = TransformCoord(form->form.virtual_x +
+ form->form.virtual_width +
+ (XtBorderWidth(*childP) << 1),
+ fw->form.old_width, XtWidth(fw),
+ form->form.right) -
+ (x + (XtBorderWidth(*childP) << 1));
+ height = TransformCoord(form->form.virtual_y +
+ form->form.virtual_height +
+ (XtBorderWidth(*childP) << 1),
+ fw->form.old_height, XtHeight(fw),
+ form->form.bottom) -
+ (y + (XtBorderWidth(*childP) << 1));
+#else
+ x = TransformCoord(XtX(*childP), fw->form.old_width,
+ XtWidth(fw), form->form.left);
+ y = TransformCoord(XtY(*childP), fw->form.old_height,
+ XtHeight(fw), form->form.top);
+ width = TransformCoord(XtX(*childP) + form->form.virtual_width +
+ (XtBorderWidth(*childP) << 1),
+ fw->form.old_width, XtWidth(fw),
+ form->form.right) -
+ (x + (XtBorderWidth(*childP) << 1));
+ height = TransformCoord(XtY(*childP) + form->form.virtual_height +
+ (XtBorderWidth(*childP) << 1),
+ fw->form.old_height, XtHeight(fw),
+ form->form.bottom) -
+ (y + (XtBorderWidth(*childP) << 1));
+ form->form.virtual_width = width;
+ form->form.virtual_height = height;
+#endif
+
+ width = width < 1 ? 1 : width;
+ height = height < 1 ? 1 : height;
+
+ XtConfigureWidget(*childP, x, y, width, height,
+ XtBorderWidth(*childP));
+ }
+
+ if (unmap)
+ XtMapWidget(w);
+
+#ifdef OLDXAW
+ fw->form.old_width = XtWidth(fw);
+ fw->form.old_height = XtHeight(fw);
+#endif
+}
+
+/*ARGSUSED*/
+static XtGeometryResult
+XawFormGeometryManager(Widget w, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+ Dimension old_width, old_height;
+ FormWidget fw = (FormWidget)XtParent(w);
+ FormConstraints form = (FormConstraints)w->core.constraints;
+ XtWidgetGeometry allowed;
+ XtGeometryResult ret_val;
+
+ if ((request->request_mode & (unsigned)~(XtCWQueryOnly | CWWidth | CWHeight))
+ || !form->form.allow_resize) {
+ /* If GeometryManager is invoked during a SetValues call on a child
+ * then it is necessary to compute a new layout if ConstraintSetValues
+ * allowed any constraint changes
+ */
+ if (fw->form.needs_relayout)
+ (*((FormWidgetClass)fw->core.widget_class)->form_class.layout)
+ (fw, 0, 0, True);
+ return (XtGeometryNo);
+ }
+
+ if (request->request_mode & CWWidth)
+ allowed.width = request->width;
+ else
+ allowed.width = XtWidth(w);
+
+ if (request->request_mode & CWHeight)
+ allowed.height = request->height;
+ else
+ allowed.height = XtHeight(w);
+
+ if (allowed.width == XtWidth(w) && allowed.height == XtHeight(w)) {
+ /* If GeometryManager is invoked during a SetValues call on a child
+ * then it is necessary to compute a new layout if ConstraintSetValues
+ * allowed any constraint changes
+ */
+ if (fw->form.needs_relayout)
+ (*((FormWidgetClass)fw->core.widget_class)->form_class.layout)
+ (fw, 0, 0, True);
+ return (XtGeometryNo);
+ }
+
+ /*
+ * Remember the old size, and then set the size to the requested size
+ */
+ old_width = XtWidth(w);
+ old_height = XtHeight(w);
+ XtWidth(w) = allowed.width;
+ XtHeight(w) = allowed.height;
+
+ if (request->request_mode & XtCWQueryOnly) {
+ Boolean always_resize_children;
+ Dimension ret_width, ret_height;
+
+ fw->form.resize_in_layout = False;
+
+ (*((FormWidgetClass)fw->core.widget_class)->form_class.layout)
+ (fw, XtWidth(w), XtHeight(w), False);
+
+ /*
+ * Reset the size of this child back to what it used to be
+ */
+ XtWidth(w) = old_width;
+ XtHeight(w) = old_height;
+
+ fw->form.resize_in_layout = True;
+
+ always_resize_children = ChangeFormGeometry(w, True,
+ fw->form.preferred_width,
+ fw->form.preferred_height,
+ &ret_width, &ret_height);
+
+ if (always_resize_children
+ || (ret_width >= fw->form.preferred_width
+ && ret_height >= fw->form.preferred_height))
+ ret_val = XtGeometryYes;
+ else
+ ret_val = XtGeometryNo;
+ }
+ else {
+ if ((*((FormWidgetClass)fw->core.widget_class)->form_class.layout)
+ (fw, XtWidth(w), XtHeight(w), False)) {
+ Widget *childP;
+ int num_children = fw->composite.num_children;
+ WidgetList children = fw->composite.children;
+
+ if (fw->form.no_refigure) {
+ /*
+ * I am changing the widget wrapper w/o modifing the window.
+ * This is risky, but I can get away with it since I am the
+ * parent of this widget, and he must ask me for any geometry
+ * changes
+ *
+ * The window will be updated when no_refigure is set back
+ * to False
+ */
+ form->form.deferred_resize = True;
+ ret_val = XtGeometryDone;
+ }
+ else
+ ret_val = XtGeometryYes;
+
+ /*
+ * Resets everything.
+ */
+ fw->form.old_width = XtWidth(fw);
+ fw->form.old_height = XtHeight(fw);
+ for (childP = children; childP - children < num_children; childP++) {
+ Widget nw = *childP;
+
+ if (XtIsManaged(nw)) {
+ FormConstraints nform = (FormConstraints)nw->core.constraints;
+
+#ifndef OLDXAW
+ nform->form.virtual_x = XtX(nw);
+ nform->form.virtual_y = XtY(nw);
+#endif
+ nform->form.virtual_width = XtWidth(nw);
+ nform->form.virtual_height = XtHeight(nw);
+ }
+ }
+ }
+ else {
+ XtWidth(w) = old_width;
+ XtHeight(w) = old_height;
+ ret_val = XtGeometryNo;
+ }
+ }
+
+ return (ret_val);
+}
+
+/*ARGSUSED*/
+static Boolean
+XawFormSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+#ifndef OLDXAW
+ FormWidget f_old = (FormWidget)current;
+ FormWidget f_new = (FormWidget)cnew;
+
+ if (f_old->core.background_pixmap != f_new->core.background_pixmap) {
+ XawPixmap *opix, *npix;
+
+ opix = XawPixmapFromXPixmap(f_old->core.background_pixmap, XtScreen(f_old),
+ f_old->core.colormap, f_old->core.depth);
+ npix = XawPixmapFromXPixmap(f_new->core.background_pixmap, XtScreen(f_new),
+ f_new->core.colormap, f_new->core.depth);
+ if ((npix && npix->mask) || (opix && opix->mask))
+ XawReshapeWidget(cnew, npix);
+ }
+#endif /* OLDXAW */
+
+ return (False);
+}
+
+/* ARGSUSED */
+static void
+XawFormConstraintInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ FormConstraints form = (FormConstraints)cnew->core.constraints;
+ FormWidget fw = (FormWidget)cnew->core.parent;
+
+#ifndef OLDXAW
+ form->form.virtual_x = XtX(cnew);
+ form->form.virtual_y = XtY(cnew);
+#endif
+ form->form.virtual_width = XtWidth(cnew);
+ form->form.virtual_height = XtHeight(cnew);
+
+ if (form->form.dx == default_value)
+ form->form.dx = fw->form.default_spacing;
+
+ if (form->form.dy == default_value)
+ form->form.dy = fw->form.default_spacing;
+
+ form->form.deferred_resize = False;
+}
+
+/*ARGSUSED*/
+static Boolean
+XawFormConstraintSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ FormConstraints cfc = (FormConstraints)current->core.constraints;
+ FormConstraints nfc = (FormConstraints)cnew->core.constraints;
+
+ if (cfc->form.top != nfc->form.top || cfc->form.bottom != nfc->form.bottom
+ || cfc->form.left != nfc->form.left || cfc->form.right != nfc->form.right
+ || cfc->form.dx != nfc->form.dx || cfc->form.dy != nfc->form.dy
+ || cfc->form.horiz_base != nfc->form.horiz_base
+ || cfc->form.vert_base != nfc->form.vert_base) {
+ FormWidget fp = (FormWidget)XtParent(cnew);
+
+ /* If there are no subclass ConstraintSetValues procedures remaining
+ * to be invoked, and if there is no geometry request about to be
+ * made, then invoke the new layout now; else defer it
+ */
+ if (XtClass(XtParent(cnew)) == formWidgetClass
+ && XtX(current) == XtX(cnew)
+ && XtY(current) == XtY(cnew)
+ && XtWidth(current) == XtWidth(cnew)
+ && XtHeight(current) == XtHeight(cnew)
+ && XtBorderWidth(current) == XtBorderWidth(cnew))
+ Layout(fp, 0, 0, True);
+ else
+ fp->form.needs_relayout = True;
+ }
+
+ return (False);
+}
+
+static void
+XawFormChangeManaged(Widget w)
+{
+ FormWidget fw = (FormWidget)w;
+ FormConstraints form;
+ WidgetList children, childP;
+ int num_children = fw->composite.num_children;
+ Widget child;
+
+ (*((FormWidgetClass)w->core.widget_class)->form_class.layout)
+ (fw, XtWidth(w), XtHeight(w), True);
+
+ fw->form.old_width = XtWidth(w);
+ fw->form.old_height = XtHeight(w);
+ for (children = childP = fw->composite.children;
+ childP - children < num_children;
+ childP++) {
+ child = *childP;
+ if (!XtIsManaged(child))
+ continue;
+ form = (FormConstraints)child->core.constraints;
+#ifndef OLDXAW
+ form->form.virtual_x = XtX(child);
+ form->form.virtual_y = XtY(child);
+#endif
+ form->form.virtual_width = XtWidth(child);
+ form->form.virtual_height = XtHeight(child);
+ }
+}
+
+static XtGeometryResult
+XawFormQueryGeometry(Widget widget, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+ FormWidget w = (FormWidget)widget;
+
+ reply->width = w->form.preferred_width;
+ reply->height = w->form.preferred_height;
+ reply->request_mode = CWWidth | CWHeight;
+
+ if ((request->request_mode & (CWWidth | CWHeight)) == (CWWidth | CWHeight)
+ && request->width == reply->width
+ && request->height == reply->height)
+ return (XtGeometryYes);
+ else if (reply->width == XtWidth(w) && reply->height == XtHeight(w))
+ return (XtGeometryNo);
+
+ return (XtGeometryAlmost);
+}
+
+/*
+ * Public routines
+ */
+/*
+ * Set or reset figuring (ignored if not realized)
+ */
+void
+XawFormDoLayout(Widget w,
+#if NeedWidePrototypes
+ Bool force
+#else
+ Boolean force
+#endif
+)
+{
+ Widget *childP;
+ FormWidget fw = (FormWidget)w;
+ int num_children = fw->composite.num_children;
+ WidgetList children = fw->composite.children;
+
+ if ((fw->form.no_refigure = !force) == True || !XtIsRealized(w))
+ return;
+
+ for (childP = children; childP - children < num_children; childP++) {
+ Widget nw = *childP;
+
+ if (XtIsManaged(nw)) {
+ FormConstraints form = (FormConstraints)nw->core.constraints;
+
+ /*
+ * Xt Configure widget is too smart, and optimizes out
+ * my changes
+ */
+ XMoveResizeWindow(XtDisplay(nw), XtWindow(nw),
+ XtX(nw), XtY(nw), XtWidth(nw), XtHeight(nw));
+
+ if (form)
+ if (form->form.deferred_resize &&
+ XtClass(nw)->core_class.resize != NULL) {
+ (*(XtClass(nw)->core_class.resize))(nw);
+ form->form.deferred_resize = False;
+ }
+ }
+ }
+}
diff --git a/nx-X11/lib/Xaw/Form.h b/nx-X11/lib/Xaw/Form.h
new file mode 100644
index 000000000..9eb1ad7d6
--- /dev/null
+++ b/nx-X11/lib/Xaw/Form.h
@@ -0,0 +1,171 @@
+/* $Xorg: Form.h,v 1.5 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Form.h,v 1.8 2001/01/17 19:42:26 dawes Exp $ */
+
+#ifndef _XawForm_h
+#define _XawForm_h
+
+#include <X11/Intrinsic.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ defaultDistance Thickness int 4
+ destroyCallback Callback Pointer NULL
+ displayList DisplayList XawDisplayList* NULL
+ height Height Dimension computed at realize
+ mappedWhenManaged MappedWhenManaged Boolean True
+ sensitive Sensitive Boolean True
+ width Width Dimension computed at realize
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+/* Constraint parameters:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ bottom Edge XtEdgeType XtRubber
+ fromHoriz Widget Widget (left edge of form)
+ fromVert Widget Widget (top of form)
+ horizDistance Thickness int defaultDistance
+ left Edge XtEdgeType XtRubber
+ resizable Boolean Boolean False
+ right Edge XtEdgeType XtRubber
+ top Edge XtEdgeType XtRubber
+ vertDistance Thickness int defaultDistance
+
+*/
+
+
+#ifndef _XtStringDefs_h_
+#define XtNtop "top"
+#define XtRWidget "Widget"
+#endif
+
+#define XtNdefaultDistance "defaultDistance"
+#define XtNbottom "bottom"
+#define XtNleft "left"
+#define XtNright "right"
+#define XtNfromHoriz "fromHoriz"
+#define XtNfromVert "fromVert"
+#define XtNhorizDistance "horizDistance"
+#define XtNvertDistance "vertDistance"
+#define XtNresizable "resizable"
+
+#define XtCEdge "Edge"
+#define XtCWidget "Widget"
+
+typedef enum {
+ XawChainTop, /* Keep this edge a constant distance from
+ the top of the form */
+ XawChainBottom, /* Keep this edge a constant distance from
+ the bottom of the form */
+ XawChainLeft, /* Keep this edge a constant distance from
+ the left of the form */
+ XawChainRight, /* Keep this edge a constant distance from
+ the right of the form */
+ XawRubber /* Keep this edge a proportional distance
+ from the edges of the form */
+} XawEdgeType;
+
+#define XtEdgeType XawEdgeType
+
+#define XtChainTop XawChainTop
+#define XtChainBottom XawChainBottom
+#define XtChainLeft XawChainLeft
+#define XtChainRight XawChainRight
+#define XtRubber XawRubber
+
+#define XtEchainLeft "chainLeft"
+#define XtEchainRight "chainRight"
+#define XtEchainTop "chainTop"
+#define XtEchainBottom "chainBottom"
+#define XtErubber "rubber"
+
+#ifndef OLDXAW
+#ifndef XawNdisplayList
+#define XawNdisplayList "displayList"
+#endif
+
+#ifndef XawCDisplayList
+#define XawCDisplayList "DisplayList"
+#endif
+
+#ifndef XawRDisplayList
+#define XawRDisplayList "XawDisplayList"
+#endif
+#endif
+
+typedef struct _FormClassRec *FormWidgetClass;
+typedef struct _FormRec *FormWidget;
+
+extern WidgetClass formWidgetClass;
+
+_XFUNCPROTOBEGIN
+
+void XawFormDoLayout
+(
+ Widget w,
+#if NeedWidePrototypes
+ Bool do_layout
+#else
+ Boolean do_layout
+#endif
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XawForm_h */
diff --git a/nx-X11/lib/Xaw/FormP.h b/nx-X11/lib/Xaw/FormP.h
new file mode 100644
index 000000000..7203dda0c
--- /dev/null
+++ b/nx-X11/lib/Xaw/FormP.h
@@ -0,0 +1,142 @@
+/* $Xorg: FormP.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/FormP.h,v 1.13 2001/12/14 19:54:40 dawes Exp $ */
+
+/* Form widget private definitions */
+
+#ifndef _XawFormP_h
+#define _XawFormP_h
+
+#include <X11/Xfuncproto.h>
+
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/XawInit.h>
+
+_XFUNCPROTOBEGIN
+
+#define XtREdgeType "EdgeType"
+
+typedef enum {
+ LayoutPending,
+ LayoutInProgress,
+ LayoutDone
+} LayoutState;
+
+#define XtInheritLayout \
+((Boolean (*)(FormWidget, unsigned int, unsigned int, Bool))_XtInherit)
+
+typedef struct {
+ Boolean(*layout)(FormWidget, unsigned int, unsigned int, Bool);
+#ifndef OLDXAW
+ XtPointer extension;
+#endif
+} FormClassPart;
+
+typedef struct _FormClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ConstraintClassPart constraint_class;
+ FormClassPart form_class;
+} FormClassRec;
+
+extern FormClassRec formClassRec;
+
+typedef struct _FormPart {
+ /* resources */
+ int default_spacing; /* default distance between children */
+
+ /* private */
+ Dimension old_width, old_height; /* reference value for *_virtual */
+ int no_refigure; /* no re-layout while > 0 */
+ Boolean needs_relayout; /* next time no_refigure == 0 */
+ Boolean resize_in_layout; /* should layout() do geom request? */
+ Dimension preferred_width, preferred_height; /* cached from layout */
+ Boolean resize_is_no_op; /* Causes resize to take not action */
+#ifndef OLDXAW
+ XawDisplayList *display_list;
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} FormPart;
+
+typedef struct _FormRec {
+ CorePart core;
+ CompositePart composite;
+ ConstraintPart constraint;
+ FormPart form;
+} FormRec;
+
+typedef struct _FormConstraintsPart {
+ /* resources */
+ XtEdgeType top, bottom, left, right;/* where to drag edge on resize */
+ int dx; /* desired horiz offset */
+ int dy; /* desired vertical offset */
+ Widget horiz_base; /* measure dx from here if non-null */
+ Widget vert_base; /* measure dy from here if non-null */
+ Boolean allow_resize; /* True if child may request resize */
+
+ /* private */
+ short virtual_width, virtual_height;
+ Position new_x, new_y;
+ LayoutState layout_state; /* temporary layout state */
+ Boolean deferred_resize;/* was resized while no_refigure is set */
+#ifndef OLDXAW
+ short virtual_x, virtual_y;
+ XtPointer pad[2]; /* leave some space for further optimizations
+ * in the form widget geometry
+ */
+#endif
+} FormConstraintsPart;
+
+typedef struct _FormConstraintsRec {
+ FormConstraintsPart form;
+} FormConstraintsRec, *FormConstraints;
+
+_XFUNCPROTOEND
+
+#endif /* _XawFormP_h */
diff --git a/nx-X11/lib/Xaw/Grip.c b/nx-X11/lib/Xaw/Grip.c
new file mode 100644
index 000000000..c9d418368
--- /dev/null
+++ b/nx-X11/lib/Xaw/Grip.c
@@ -0,0 +1,188 @@
+/* $Xorg: Grip.c,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Grip.c,v 1.7 2001/01/17 19:42:26 dawes Exp $ */
+
+/*
+ * Grip.c - Grip Widget (Used by Paned Widget)
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/GripP.h>
+#include <X11/Xaw/XawInit.h>
+
+/*
+ * Prototypes
+ */
+static void
+GripAction(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * Initialization
+ */
+static XtResource resources[] = {
+ {
+ XtNwidth,
+ XtCWidth,
+ XtRDimension,
+ sizeof(Dimension),
+ XtOffsetOf(GripRec, core.width),
+ XtRImmediate,
+ (XtPointer)DEFAULT_GRIP_SIZE
+ },
+ {
+ XtNheight,
+ XtCHeight,
+ XtRDimension,
+ sizeof(Dimension),
+ XtOffsetOf(GripRec, core.height),
+ XtRImmediate,
+ (XtPointer)DEFAULT_GRIP_SIZE
+ },
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ XtOffsetOf(GripRec, core.background_pixel),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XtNborderWidth,
+ XtCBorderWidth,
+ XtRDimension,
+ sizeof(Dimension),
+ XtOffsetOf(GripRec, core.border_width),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNcallback,
+ XtCCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ XtOffsetOf(GripRec, grip.grip_action),
+ XtRCallback,
+ NULL
+ },
+};
+
+static XtActionsRec actionsList[] =
+{
+ {"GripAction", GripAction},
+};
+
+#define Superclass (&simpleClassRec)
+
+GripClassRec gripClassRec = {
+ /* core */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "Grip", /* class name */
+ sizeof(GripRec), /* size */
+ XawInitializeWidgetSet, /* class initialize */
+ NULL, /* class_part_init */
+ False, /* class_inited */
+ NULL, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ actionsList, /* actions */
+ XtNumber(actionsList), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ NULL, /* destroy */
+ NULL, /* resize */
+ XtInheritExpose, /* expose */
+ NULL, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* simple */
+ {
+ XtInheritChangeSensitive, /* change_sensitive */
+ },
+ /* grip */
+ {
+ NULL, /* extension */
+ }
+};
+
+WidgetClass gripWidgetClass = (WidgetClass)&gripClassRec;
+
+/*
+ * Implementation
+ */
+static void
+GripAction(Widget widget, XEvent *event, String *params, Cardinal *num_params)
+{
+ XawGripCallDataRec call_data;
+
+ call_data.event = event;
+ call_data.params = params;
+ call_data.num_params = *num_params;
+
+ XtCallCallbacks(widget, XtNcallback, (XtPointer)&call_data);
+}
diff --git a/nx-X11/lib/Xaw/Grip.h b/nx-X11/lib/Xaw/Grip.h
new file mode 100644
index 000000000..1c19f6043
--- /dev/null
+++ b/nx-X11/lib/Xaw/Grip.h
@@ -0,0 +1,99 @@
+/* $Xorg: Grip.h,v 1.4 2001/02/09 02:03:43 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Grip.h,v 1.6 2001/01/17 19:42:26 dawes Exp $ */
+
+/*
+ * Grip.h - Public Definitions for Grip widget (used by VPane Widget)
+ *
+ */
+
+#ifndef _XawGrip_h
+#define _XawGrip_h
+
+#include <X11/Xaw/Simple.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ foreground Foreground Pixel XtDefaultForeground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 0
+ callback Callback Pointer GripAction
+ cursor Cursor Cursor None
+ cursorName Cursor String NULL
+ destroyCallback Callback Pointer NULL
+ height Height Dimension 8
+ mappedWhenManaged MappedWhenManaged Boolean True
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ sensitive Sensitive Boolean True
+ width Width Dimension 8
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XtNgripTranslations "gripTranslations"
+
+typedef struct _XawGripCallData {
+ XEvent *event; /* the event causing the GripAction */
+ String *params; /* the TranslationTable params */
+ Cardinal num_params; /* count of params */
+} XawGripCallDataRec, *XawGripCallData,
+ GripCallDataRec, *GripCallData; /* supported for R4 compatibility */
+
+/* Class Record Constant */
+
+extern WidgetClass gripWidgetClass;
+
+typedef struct _GripClassRec *GripWidgetClass;
+typedef struct _GripRec *GripWidget;
+
+#endif /* _XawGrip_h */
diff --git a/nx-X11/lib/Xaw/GripP.h b/nx-X11/lib/Xaw/GripP.h
new file mode 100644
index 000000000..f40a8d1e7
--- /dev/null
+++ b/nx-X11/lib/Xaw/GripP.h
@@ -0,0 +1,91 @@
+/*
+* $Xorg: GripP.h,v 1.4 2001/02/09 02:03:43 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/GripP.h,v 1.7 2001/01/17 19:42:26 dawes Exp $ */
+
+#ifndef _XawGripP_h
+#define _XawGripP_h
+
+#include <X11/Xaw/Grip.h>
+#include <X11/Xaw/SimpleP.h>
+
+#define DEFAULT_GRIP_SIZE 8
+
+/* New fields for the Grip widget class */
+typedef struct {
+ XtPointer extension;
+} GripClassPart;
+
+/* Full Class record */
+typedef struct _GripClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ GripClassPart grip_class;
+} GripClassRec;
+
+extern GripClassRec gripClassRec;
+
+/* New fields for the Grip widget */
+typedef struct {
+ XtCallbackList grip_action;
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} GripPart;
+
+/* Full instance record */
+typedef struct _GripRec {
+ CorePart core;
+ SimplePart simple;
+ GripPart grip;
+} GripRec;
+
+#endif /* _XawGripP_h */
diff --git a/nx-X11/lib/Xaw/Imakefile b/nx-X11/lib/Xaw/Imakefile
new file mode 100644
index 000000000..23842b71f
--- /dev/null
+++ b/nx-X11/lib/Xaw/Imakefile
@@ -0,0 +1,209 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:45:33 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/Xaw/Imakefile,v 1.10 2001/01/17 19:42:27 dawes Exp $
+
+#define DoNormalLib NormalLibXaw
+#define DoSharedLib SharedLibXaw
+#define DoExtraLib SharedLibXaw
+#define DoDebugLib DebugLibXaw
+#define DoProfileLib ProfileLibXaw
+#define HasSharedData YES
+#define LibName Xaw
+#define SoRev SOXAWREV
+#define IncSubdir X11
+#define IncSubSubdir Xaw
+
+#ifdef SharedXawReqs
+REQUIREDLIBS = SharedXawReqs
+#endif
+
+DEFINES = XawI18nDefines -DPROJECT_ROOT=\"$(PROJECTROOT)\" $(VENDOR_DEFINES)
+
+ LINTLIBS = $(LINTXLIB) $(LINTXTOOL)
+
+HEADERS = \
+ AllWidgets.h \
+ AsciiSink.h \
+ AsciiSinkP.h \
+ AsciiSrc.h \
+ AsciiSrcP.h \
+ AsciiText.h \
+ AsciiTextP.h \
+ Box.h \
+ BoxP.h \
+ Cardinals.h \
+ Command.h \
+ CommandP.h \
+ Dialog.h \
+ DialogP.h \
+ Form.h \
+ FormP.h \
+ Grip.h \
+ GripP.h \
+ Label.h \
+ LabelP.h \
+ List.h \
+ ListP.h \
+ MenuButton.h \
+ MenuButtoP.h \
+ MultiSrc.h \
+ MultiSrcP.h \
+ MultiSink.h \
+ MultiSinkP.h \
+ Paned.h \
+ PanedP.h \
+ Panner.h \
+ PannerP.h \
+ Porthole.h \
+ PortholeP.h \
+ Print.h \
+ PrintSP.h \
+ Repeater.h \
+ RepeaterP.h \
+ Reports.h \
+ Scrollbar.h \
+ ScrollbarP.h \
+ Simple.h \
+ SimpleP.h \
+ SimpleMenu.h \
+ SimpleMenP.h \
+ Sme.h \
+ SmeP.h \
+ SmeBSB.h \
+ SmeBSBP.h \
+ SmeLine.h \
+ SmeLineP.h \
+ StripChart.h \
+ StripCharP.h \
+ Template.c \
+ Template.h \
+ TemplateP.h \
+ Text.h \
+ TextP.h \
+ TextSink.h \
+ TextSinkP.h \
+ TextSrc.h \
+ TextSrcP.h \
+ Tip.h \
+ TipP.h \
+ Toggle.h \
+ ToggleP.h \
+ Tree.h \
+ TreeP.h \
+ VendorEP.h \
+ Viewport.h \
+ ViewportP.h \
+ XawImP.h \
+ XawInit.h
+
+SRCS = \
+ Actions.c \
+ AllWidgets.c \
+ AsciiSink.c \
+ AsciiSrc.c \
+ AsciiText.c \
+ Box.c \
+ Command.c \
+ Converters.c \
+ Dialog.c \
+ DisplayList.c \
+ Form.c \
+ Grip.c \
+ Label.c \
+ List.c \
+ MenuButton.c \
+ MultiSrc.c \
+ MultiSink.c \
+ OS.c \
+ Paned.c \
+ Panner.c \
+ Pixmap.c \
+ Porthole.c \
+ PrintShell.c \
+ Repeater.c \
+ Scrollbar.c \
+ Simple.c \
+ SimpleMenu.c \
+ Sme.c \
+ SmeBSB.c \
+ SmeLine.c \
+ StripChart.c \
+ Text.c \
+ TextSink.c \
+ TextSrc.c \
+ TextAction.c \
+ TextPop.c \
+ TextTr.c \
+ Tip.c \
+ Toggle.c \
+ Tree.c \
+ Vendor.c \
+ Viewport.c \
+ XawIm.c \
+ XawInit.c \
+ XawI18n.c \
+ sharedlib.c
+
+#if SharedDataSeparation
+UNSHAREDOBJS = AllWidgets.o sharedlib.o
+#endif
+
+OBJS = \
+ Actions.o \
+ AllWidgets.o \
+ AsciiSink.o \
+ AsciiSrc.o \
+ AsciiText.o \
+ Box.o \
+ Command.o \
+ Converters.o \
+ Dialog.o \
+ DisplayList.o \
+ Form.o \
+ Grip.o \
+ Label.o \
+ List.o \
+ MenuButton.o \
+ MultiSrc.o \
+ MultiSink.o \
+ OS.o \
+ Paned.o \
+ Panner.o \
+ Pixmap.o \
+ Porthole.o \
+ PrintShell.o \
+ Repeater.o \
+ Scrollbar.o \
+ Simple.o \
+ SimpleMenu.o \
+ Sme.o \
+ SmeBSB.o \
+ SmeLine.o \
+ StripChart.o \
+ Text.o \
+ TextSink.o \
+ TextSrc.o \
+ TextAction.o \
+ TextPop.o \
+ TextTr.o \
+ Tip.o \
+ Toggle.o \
+ Tree.o \
+ Vendor.o \
+ Viewport.o \
+ XawIm.o \
+ XawI18n.o \
+ XawInit.o
+
+#include <Library.tmpl>
+
+#if DoSharedLib && SharedDataSeparation
+SpecialCObjectRule(sharedlib,NullParameter,$(SHLIBDEF))
+#endif
+
+MANSUFFIX = $(LIBMANSUFFIX)
+InstallManPage(Xaw,$(LIBMANDIR))
+DependTarget()
diff --git a/nx-X11/lib/Xaw/Label.c b/nx-X11/lib/Xaw/Label.c
new file mode 100644
index 000000000..0a4c6ea2a
--- /dev/null
+++ b/nx-X11/lib/Xaw/Label.c
@@ -0,0 +1,824 @@
+/* $Xorg: Label.c,v 1.5 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Label.c,v 1.12 2001/01/17 19:42:27 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <ctype.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xos.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Drawing.h>
+#include <X11/Xaw/LabelP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+#define streq(a, b) (strcmp((a), (b)) == 0)
+
+#define MULTI_LINE_LABEL 32767
+
+#ifdef CRAY
+#define WORD64
+#endif
+
+/*
+ * Class Methods
+ */
+static void XawLabelClassInitialize(void);
+static void XawLabelDestroy(Widget);
+static void XawLabelInitialize(Widget, Widget, ArgList, Cardinal*);
+static XtGeometryResult XawLabelQueryGeometry(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawLabelRedisplay(Widget, XEvent*, Region);
+static void XawLabelResize(Widget);
+static Boolean XawLabelSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+#ifdef WORD64
+static int _XawLabelWidth16(XFontStruct*, char*, int);
+static void _XawLabelDraw16(Display*, Drawable, GC, int, int, char*, int);
+#endif
+static void compute_bitmap_offsets(LabelWidget);
+static void GetGrayGC(LabelWidget);
+static void GetNormalGC(LabelWidget);
+static void _Reposition(LabelWidget, unsigned int, unsigned int,
+ Position*, Position*);
+static void set_bitmap_info(LabelWidget);
+static void SetTextWidthAndHeight(LabelWidget);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(LabelRec, field)
+static XtResource resources[] = {
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(label.foreground),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XtNfont,
+ XtCFont,
+ XtRFontStruct,
+ sizeof(XFontStruct*),
+ offset(label.font),
+ XtRString,
+ XtDefaultFont
+ },
+ {
+ XtNfontSet,
+ XtCFontSet,
+ XtRFontSet,
+ sizeof(XFontSet),
+ offset(label.fontset),
+ XtRString,
+ XtDefaultFontSet
+ },
+ {
+ XtNlabel,
+ XtCLabel,
+ XtRString,
+ sizeof(String),
+ offset(label.label),
+ XtRString,
+ NULL
+ },
+ {
+ XtNencoding,
+ XtCEncoding,
+ XtRUnsignedChar,
+ sizeof(unsigned char),
+ offset(label.encoding),
+ XtRImmediate,
+ (XtPointer)XawTextEncoding8bit
+ },
+ {
+ XtNjustify,
+ XtCJustify,
+ XtRJustify,
+ sizeof(XtJustify),
+ offset(label.justify),
+ XtRImmediate,
+ (XtPointer)XtJustifyCenter
+ },
+ {
+ XtNinternalWidth,
+ XtCWidth,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(label.internal_width),
+ XtRImmediate,
+ (XtPointer)4
+ },
+ {
+ XtNinternalHeight,
+ XtCHeight,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(label.internal_height),
+ XtRImmediate,
+ (XtPointer)2
+ },
+ {
+ XtNleftBitmap,
+ XtCLeftBitmap,
+ XtRBitmap,
+ sizeof(Pixmap),
+ offset(label.left_bitmap),
+ XtRImmediate,
+ (XtPointer)None
+ },
+ {
+ XtNbitmap,
+ XtCPixmap,
+ XtRBitmap,
+ sizeof(Pixmap),
+ offset(label.pixmap),
+ XtRImmediate,
+ (XtPointer)None
+ },
+ {
+ XtNresize,
+ XtCResize,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(label.resize),
+ XtRImmediate,
+ (XtPointer)True
+ },
+ {
+ XtNlabelX,
+ XtCPosition,
+ XtRPosition,
+ sizeof(Position),
+ offset(label.label_x),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNlabelY,
+ XtCPosition,
+ XtRPosition,
+ sizeof(Position),
+ offset(label.label_y),
+ XtRImmediate,
+ (XtPointer)0
+ },
+};
+#undef offset
+
+#define Superclass (&simpleClassRec)
+LabelClassRec labelClassRec = {
+ /* core */
+ {
+ (WidgetClass)&simpleClassRec, /* superclass */
+ "Label", /* class_name */
+ sizeof(LabelRec), /* widget_size */
+ XawLabelClassInitialize, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ XawLabelInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ XawLabelDestroy, /* destroy */
+ XawLabelResize, /* resize */
+ XawLabelRedisplay, /* expose */
+ XawLabelSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ XawLabelQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* simple */
+ {
+ XtInheritChangeSensitive, /* change_sensitive */
+ },
+ /* label */
+ {
+ NULL, /* extension */
+ }
+};
+
+WidgetClass labelWidgetClass = (WidgetClass)&labelClassRec;
+
+/*
+ * Implementation
+ */
+static void
+XawLabelClassInitialize(void)
+{
+ XawInitializeWidgetSet();
+ XtAddConverter(XtRString, XtRJustify, XmuCvtStringToJustify, NULL, 0);
+ XtSetTypeConverter(XtRJustify, XtRString, XmuCvtJustifyToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+
+#ifndef WORD64
+#define TXT16 XChar2b
+#else
+#define TXT16 char
+
+static XChar2b *buf2b;
+static int buf2blen = 0;
+
+static int
+_XawLabelWidth16(XFontStruct *fs, char *str, int n)
+{
+ int i;
+ XChar2b *ptr;
+
+ if (n > buf2blen) {
+ buf2b = (XChar2b *)XtRealloc((char *)buf2b, n * sizeof(XChar2b));
+ buf2blen = n;
+ }
+ for (ptr = buf2b, i = n; --i >= 0; ptr++) {
+ ptr->byte1 = *str++;
+ ptr->byte2 = *str++;
+ }
+
+ return (XTextWidth16(fs, buf2b, n));
+}
+
+static void
+_XawLabelDraw16(Display *dpy, Drawable d, GC gc, int x, int y,
+ char *str, int n)
+{
+ int i;
+ XChar2b *ptr;
+
+ if (n > buf2blen) {
+ buf2b = (XChar2b *)XtRealloc((char *)buf2b, n * sizeof(XChar2b));
+ buf2blen = n;
+ }
+ for (ptr = buf2b, i = n; --i >= 0; ptr++) {
+ ptr->byte1 = *str++;
+ ptr->byte2 = *str++;
+ }
+ XDrawString16(dpy, d, gc, x, y, buf2b, n);
+}
+
+#define XTextWidth16 _XawLabelWidth16
+#define XDrawString16 _XawLabelDraw16
+#endif /* WORD64 */
+
+/*
+ * Calculate width and height of displayed text in pixels
+ */
+static void
+SetTextWidthAndHeight(LabelWidget lw)
+{
+ XFontStruct *fs = lw->label.font;
+ char *nl;
+
+ if (lw->label.pixmap != None) {
+ Window root;
+ int x, y;
+ unsigned int width, height, bw, depth;
+
+ if (XGetGeometry(XtDisplay(lw), lw->label.pixmap, &root, &x, &y,
+ &width, &height, &bw, &depth)) {
+ lw->label.label_height = height;
+ lw->label.label_width = width;
+ lw->label.label_len = depth;
+ return;
+ }
+ }
+ if (lw->simple.international == True) {
+ XFontSet fset = lw->label.fontset;
+ XFontSetExtents *ext = XExtentsOfFontSet(fset);
+
+ lw->label.label_height = ext->max_ink_extent.height;
+ if (lw->label.label == NULL) {
+ lw->label.label_len = 0;
+ lw->label.label_width = 0;
+ }
+ else if ((nl = index(lw->label.label, '\n')) != NULL) {
+ char *label;
+
+ lw->label.label_len = MULTI_LINE_LABEL;
+ lw->label.label_width = 0;
+ for (label = lw->label.label; nl != NULL; nl = index(label, '\n')) {
+ int width = XmbTextEscapement(fset, label, (int)(nl - label));
+
+ if (width > (int)lw->label.label_width)
+ lw->label.label_width = width;
+ label = nl + 1;
+ if (*label)
+ lw->label.label_height += ext->max_ink_extent.height;
+ }
+ if (*label) {
+ int width = XmbTextEscapement(fset, label, strlen(label));
+
+ if (width > (int)lw->label.label_width)
+ lw->label.label_width = width;
+ }
+ }
+ else {
+ lw->label.label_len = strlen(lw->label.label);
+ lw->label.label_width =
+ XmbTextEscapement(fset, lw->label.label, lw->label.label_len);
+ }
+ }
+ else {
+ lw->label.label_height = fs->max_bounds.ascent + fs->max_bounds.descent;
+ if (lw->label.label == NULL) {
+ lw->label.label_len = 0;
+ lw->label.label_width = 0;
+ }
+ else if ((nl = index(lw->label.label, '\n')) != NULL) {
+ char *label;
+
+ lw->label.label_len = MULTI_LINE_LABEL;
+ lw->label.label_width = 0;
+ for (label = lw->label.label; nl != NULL; nl = index(label, '\n')) {
+ int width;
+
+ if (lw->label.encoding)
+ width = XTextWidth16(fs, (TXT16*)label, (int)(nl - label) / 2);
+ else
+ width = XTextWidth(fs, label, (int)(nl - label));
+ if (width > (int)lw->label.label_width)
+ lw->label.label_width = width;
+ label = nl + 1;
+ if (*label)
+ lw->label.label_height +=
+ fs->max_bounds.ascent + fs->max_bounds.descent;
+ }
+ if (*label) {
+ int width = XTextWidth(fs, label, strlen(label));
+
+ if (lw->label.encoding)
+ width = XTextWidth16(fs, (TXT16*)label, strlen(label) / 2);
+ else
+ width = XTextWidth(fs, label, strlen(label));
+ if (width > (int) lw->label.label_width)
+ lw->label.label_width = width;
+ }
+ }
+ else {
+ lw->label.label_len = strlen(lw->label.label);
+ if (lw->label.encoding)
+ lw->label.label_width =
+ XTextWidth16(fs, (TXT16*)lw->label.label,
+ (int)lw->label.label_len / 2);
+ else
+ lw->label.label_width =
+ XTextWidth(fs, lw->label.label, (int)lw->label.label_len);
+ }
+ }
+}
+
+static void
+GetNormalGC(LabelWidget lw)
+{
+ XGCValues values;
+
+ values.foreground = lw->label.foreground;
+ values.background = lw->core.background_pixel;
+ values.font = lw->label.font->fid;
+ values.graphics_exposures = False;
+
+ if (lw->simple.international == True)
+ /* Since Xmb/wcDrawString eats the font, I must use XtAllocateGC */
+ lw->label.normal_GC = XtAllocateGC((Widget)lw, 0,
+ GCForeground | GCBackground |
+ GCGraphicsExposures,
+ &values, GCFont, 0);
+ else
+ lw->label.normal_GC = XtGetGC((Widget)lw,
+ GCForeground | GCBackground | GCFont |
+ GCGraphicsExposures, &values);
+}
+
+static void
+GetGrayGC(LabelWidget lw)
+{
+ XGCValues values;
+
+ values.foreground = lw->label.foreground;
+ values.background = lw->core.background_pixel;
+ values.font = lw->label.font->fid;
+ values.fill_style = FillTiled;
+ values.tile = XmuCreateStippledPixmap(XtScreen((Widget)lw),
+ lw->label.foreground,
+ lw->core.background_pixel,
+ lw->core.depth);
+ values.graphics_exposures = False;
+
+ lw->label.stipple = values.tile;
+ if (lw->simple.international == True)
+ /* Since Xmb/wcDrawString eats the font, I must use XtAllocateGC */
+ lw->label.gray_GC = XtAllocateGC((Widget)lw, 0,
+ GCForeground | GCBackground |
+ GCTile | GCFillStyle |
+ GCGraphicsExposures,
+ &values, GCFont, 0);
+ else
+ lw->label.gray_GC = XtGetGC((Widget)lw,
+ GCForeground | GCBackground |
+ GCFont | GCTile | GCFillStyle |
+ GCGraphicsExposures,
+ &values);
+}
+
+static void
+compute_bitmap_offsets(LabelWidget lw)
+{
+ /*
+ * bitmap will be eventually be displayed at
+ * (internal_width, internal_height + lbm_y)
+ */
+ if (lw->label.lbm_height != 0)
+ lw->label.lbm_y = (XtHeight(lw) - (lw->label.internal_height * 2 +
+ lw->label.lbm_height)) / 2;
+ else
+ lw->label.lbm_y = 0;
+}
+
+static void
+set_bitmap_info(LabelWidget lw)
+{
+ Window root;
+ int x, y;
+ unsigned int bw, depth;
+
+ if (!(lw->label.left_bitmap
+ && XGetGeometry(XtDisplay(lw), lw->label.left_bitmap, &root, &x, &y,
+ &lw->label.lbm_width, &lw->label.lbm_height,
+ &bw, &depth)))
+ lw->label.lbm_width = lw->label.lbm_height = 0;
+
+ compute_bitmap_offsets(lw);
+}
+
+/*ARGSUSED*/
+static void
+XawLabelInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ LabelWidget lw = (LabelWidget)cnew;
+
+ if (!lw->label.font) XtError("Aborting: no font found\n");
+ if (lw->simple.international && !lw->label.fontset)
+ XtError("Aborting: no fontset found\n");
+
+ if (lw->label.label == NULL)
+ lw->label.label = XtNewString(lw->core.name);
+ else
+ lw->label.label = XtNewString(lw->label.label);
+
+ GetNormalGC(lw);
+ GetGrayGC(lw);
+
+ SetTextWidthAndHeight(lw);
+
+ if (XtHeight(lw) == 0)
+ XtHeight(lw) = lw->label.label_height + 2 * lw->label.internal_height;
+
+ set_bitmap_info(lw); /* need core.height */
+
+ if (XtWidth(lw) == 0) /* need label.lbm_width */
+ XtWidth(lw) = lw->label.label_width + 2 * lw->label.internal_width +
+ LEFT_OFFSET(lw);
+
+ lw->label.label_x = lw->label.label_y = 0;
+ (*XtClass(cnew)->core_class.resize)((Widget)lw);
+}
+
+/*ARGSUSED*/
+static void
+XawLabelRedisplay(Widget gw, XEvent *event, Region region)
+{
+ LabelWidget w = (LabelWidget)gw;
+ GC gc;
+
+ if (*Superclass->core_class.expose != NULL)
+ (*Superclass->core_class.expose)(gw, event, region);
+
+ gc = XtIsSensitive(gw) ? w->label.normal_GC : w->label.gray_GC;
+#ifdef notdef
+ if (region != NULL)
+ XSetRegion(XtDisplay(gw), gc, region);
+#endif /*notdef*/
+
+ if (w->label.pixmap == None) {
+ int len = w->label.label_len;
+ char *label = w->label.label;
+ Position y = w->label.label_y + w->label.font->max_bounds.ascent;
+ Position ksy = w->label.label_y;
+
+ /* display left bitmap */
+ if (w->label.left_bitmap && w->label.lbm_width != 0)
+ XCopyPlane (XtDisplay(gw), w->label.left_bitmap, XtWindow(gw), gc,
+ 0, 0, w->label.lbm_width, w->label.lbm_height,
+ w->label.internal_width,
+ w->label.internal_height + w->label.lbm_y, 1L);
+
+ if (w->simple.international == True) {
+ XFontSetExtents *ext = XExtentsOfFontSet(w->label.fontset);
+
+ ksy += XawAbs(ext->max_ink_extent.y);
+
+ if (len == MULTI_LINE_LABEL) {
+ char *nl;
+
+ while ((nl = index(label, '\n')) != NULL) {
+ XmbDrawString(XtDisplay(w), XtWindow(w), w->label.fontset,
+ gc, w->label.label_x, ksy, label,
+ (int)(nl - label));
+ ksy += ext->max_ink_extent.height;
+ label = nl + 1;
+ }
+ len = strlen(label);
+ }
+ if (len)
+ XmbDrawString(XtDisplay(w), XtWindow(w), w->label.fontset, gc,
+ w->label.label_x, ksy, label, len);
+ }
+ else {
+ if (len == MULTI_LINE_LABEL) {
+ char *nl;
+
+ while ((nl = index(label, '\n')) != NULL) {
+ if (w->label.encoding)
+ XDrawString16(XtDisplay(gw), XtWindow(gw), gc,
+ w->label.label_x, y,
+ (TXT16*)label, (int)(nl - label) / 2);
+ else
+ XDrawString(XtDisplay(gw), XtWindow(gw), gc,
+ w->label.label_x, y, label, (int)(nl - label));
+ y += w->label.font->max_bounds.ascent +
+ w->label.font->max_bounds.descent;
+ label = nl + 1;
+ }
+ len = strlen(label);
+ }
+ if (len) {
+ if (w->label.encoding)
+ XDrawString16(XtDisplay(gw), XtWindow(gw), gc,
+ w->label.label_x, y, (TXT16*)label, len / 2);
+ else
+ XDrawString(XtDisplay(gw), XtWindow(gw), gc,
+ w->label.label_x, y, label, len);
+ }
+ }
+ }
+ else if (w->label.label_len == 1)
+ XCopyPlane(XtDisplay(gw), w->label.pixmap, XtWindow(gw), gc,
+ 0, 0, w->label.label_width, w->label.label_height,
+ w->label.label_x, w->label.label_y, 1L);
+ else
+ XCopyArea(XtDisplay(gw), w->label.pixmap, XtWindow(gw), gc,
+ 0, 0, w->label.label_width, w->label.label_height,
+ w->label.label_x, w->label.label_y);
+
+#ifdef notdef
+ if (region != NULL)
+ XSetClipMask(XtDisplay(gw), gc, (Pixmap)None);
+#endif /* notdef */
+}
+
+static void
+_Reposition(LabelWidget lw, unsigned int width, unsigned int height,
+ Position *dx, Position *dy)
+{
+ Position newPos;
+ Position leftedge = lw->label.internal_width + LEFT_OFFSET(lw);
+
+ switch (lw->label.justify) {
+ case XtJustifyLeft:
+ newPos = leftedge;
+ break;
+ case XtJustifyRight:
+ newPos = width - (lw->label.label_width + lw->label.internal_width);
+ break;
+ case XtJustifyCenter:
+ /*FALLTRHOUGH*/
+ default:
+ newPos = (int)(width - lw->label.label_width) >> 1;
+ break;
+ }
+ if (newPos < (Position)leftedge)
+ newPos = leftedge;
+ *dx = newPos - lw->label.label_x;
+ lw->label.label_x = newPos;
+
+ newPos = (height - lw->label.label_height) >> 1;
+ *dy = newPos - lw->label.label_y;
+ lw->label.label_y = newPos;
+}
+
+static void
+XawLabelResize(Widget w)
+{
+ LabelWidget lw = (LabelWidget)w;
+ Position dx, dy;
+
+ _Reposition(lw, XtWidth(w), XtHeight(w), &dx, &dy);
+ compute_bitmap_offsets(lw);
+}
+
+#define PIXMAP 0
+#define WIDTH 1
+#define HEIGHT 2
+#define NUM_CHECKS 3
+static Boolean
+XawLabelSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ LabelWidget curlw = (LabelWidget)current;
+ LabelWidget reqlw = (LabelWidget)request;
+ LabelWidget newlw = (LabelWidget)cnew;
+ unsigned int i;
+ Boolean was_resized = False, redisplay = False, checks[NUM_CHECKS];
+
+ for (i = 0; i < NUM_CHECKS; i++)
+ checks[i] = False;
+
+ for (i = 0; i < *num_args; i++) {
+ if (streq(XtNbitmap, args[i].name))
+ checks[PIXMAP] = True;
+ else if (streq(XtNwidth, args[i].name))
+ checks[WIDTH] = True;
+ else if (streq(XtNheight, args[i].name))
+ checks[HEIGHT] = True;
+ }
+
+ if (newlw->label.label == NULL)
+ newlw->label.label = newlw->core.name;
+
+ /*
+ * resize on bitmap change
+ */
+ if (curlw->label.left_bitmap != newlw->label.left_bitmap)
+ was_resized = True;
+
+ if (curlw->label.encoding != newlw->label.encoding)
+ was_resized = True;
+
+ if (curlw->simple.international
+ && curlw->label.fontset != newlw->label.fontset)
+ was_resized = True;
+
+ if (curlw->label.label != newlw->label.label) {
+ if (curlw->label.label != curlw->core.name)
+ XtFree((char *)curlw->label.label);
+
+ if (newlw->label.label != newlw->core.name)
+ newlw->label.label = XtNewString(newlw->label.label);
+
+ was_resized = True;
+ }
+
+ if (was_resized || (curlw->label.font != newlw->label.font) ||
+ curlw->label.justify != newlw->label.justify || checks[PIXMAP]) {
+ SetTextWidthAndHeight(newlw);
+ was_resized = True;
+ }
+
+ /* recalculate the window size if something has changed */
+ if (newlw->label.resize && was_resized) {
+ if (XtHeight(curlw) == XtHeight(reqlw) && !checks[HEIGHT])
+ XtHeight(newlw) = newlw->label.label_height +
+ (newlw->label.internal_height << 1);
+
+ set_bitmap_info(newlw);
+
+ if (XtWidth(curlw) == XtWidth(reqlw) && !checks[WIDTH])
+ XtWidth(newlw) = newlw->label.label_width + LEFT_OFFSET(newlw) +
+ (newlw->label.internal_width << 1);
+ }
+
+ if (curlw->label.foreground != newlw->label.foreground
+ || curlw->core.background_pixel != newlw->core.background_pixel
+ || curlw->label.font->fid != newlw->label.font->fid) {
+ /* The Fontset is not in the GC - don't make a new GC if FS changes! */
+ XtReleaseGC(cnew, curlw->label.normal_GC);
+ XtReleaseGC(cnew, curlw->label.gray_GC);
+ XmuReleaseStippledPixmap(XtScreen(current), curlw->label.stipple);
+ GetNormalGC(newlw);
+ GetGrayGC(newlw);
+ redisplay = True;
+ }
+
+ if (curlw->label.label_x != newlw->label.label_x ||
+ curlw->label.label_y != newlw->label.label_y)
+ redisplay = True;
+
+ if (curlw->label.internal_width != newlw->label.internal_width
+ || curlw->label.internal_height != newlw->label.internal_height
+ || was_resized) {
+ /* Resize() will be called if geometry changes succeed */
+ Position dx, dy;
+
+ _Reposition(newlw, XtWidth(curlw), XtHeight(curlw), &dx, &dy);
+ }
+
+ return (was_resized || redisplay ||
+ XtIsSensitive(current) != XtIsSensitive(cnew));
+}
+
+static void
+XawLabelDestroy(Widget w)
+{
+ LabelWidget lw = (LabelWidget)w;
+
+ if (lw->label.label != lw->core.name)
+ XtFree(lw->label.label);
+ XtReleaseGC(w, lw->label.normal_GC);
+ XtReleaseGC(w, lw->label.gray_GC);
+ XmuReleaseStippledPixmap(XtScreen(w), lw->label.stipple);
+}
+
+static XtGeometryResult
+XawLabelQueryGeometry(Widget w, XtWidgetGeometry *intended,
+ XtWidgetGeometry *preferred)
+{
+ LabelWidget lw = (LabelWidget)w;
+
+ preferred->request_mode = CWWidth | CWHeight;
+ preferred->width = lw->label.label_width +
+ (lw->label.internal_width << 1) + LEFT_OFFSET(lw);
+ preferred->height = lw->label.label_height +
+ (lw->label.internal_height << 1);
+
+ if (((intended->request_mode & (CWWidth | CWHeight)) == (CWWidth | CWHeight))
+ && intended->width == preferred->width
+ && intended->height == preferred->height)
+ return (XtGeometryYes);
+ else if (preferred->width == XtWidth(w) && preferred->height == XtHeight(w))
+ return (XtGeometryNo);
+
+ return (XtGeometryAlmost);
+}
diff --git a/nx-X11/lib/Xaw/Label.h b/nx-X11/lib/Xaw/Label.h
new file mode 100644
index 000000000..fc3942b01
--- /dev/null
+++ b/nx-X11/lib/Xaw/Label.h
@@ -0,0 +1,135 @@
+/* $Xorg: Label.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Label.h,v 1.6 2001/01/17 19:42:27 dawes Exp $ */
+
+#ifndef _XawLabel_h
+#define _XawLabel_h
+
+/*
+ * Label Widget
+ */
+
+#include <X11/Xaw/Simple.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ bitmap Pixmap Pixmap None
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ cursor Cursor Cursor None
+ cursorName Cursor String NULL
+ destroyCallback Callback XtCallbackList NULL
+ encoding Encoding UnsignedChar XawTextEncoding8bit
+ font Font XFontStruct* XtDefaultFont
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension text height
+ insensitiveBorder Insensitive Pixmap Gray
+ internalHeight Height Dimension 2
+ internalWidth Width Dimension 4
+ justify Justify XtJustify XtJustifyCenter
+ label Label String NULL
+ leftBitmap LeftBitmap Pixmap None
+ mappedWhenManaged MappedWhenManaged Boolean True
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ resize Resize Boolean True
+ sensitive Sensitive Boolean True
+ width Width Dimension text width
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XawTextEncoding8bit 0
+#define XawTextEncodingChar2b 1
+
+#define XtNleftBitmap "leftBitmap"
+#define XtCLeftBitmap "LeftBitmap"
+#define XtNencoding "encoding"
+#define XtCEncoding "Encoding"
+
+#ifndef XtNfontSet
+#define XtNfontSet "fontSet"
+#endif
+
+#ifndef XtCFontSet
+#define XtCFontSet "FontSet"
+#endif
+
+#ifndef _XtStringDefs_h_
+#define XtNbitmap "bitmap"
+#define XtNforeground "foreground"
+#define XtNlabel "label"
+#define XtNfont "font"
+#define XtNinternalWidth "internalWidth"
+#define XtNinternalHeight "internalHeight"
+#define XtNresize "resize"
+#define XtCResize "Resize"
+#define XtCBitmap "Bitmap"
+#endif
+
+#ifndef XtNlabelX
+#define XtNlabelX "labelX"
+#endif
+
+#ifndef XtNlabelY
+#define XtNlabelY "labelY"
+#endif
+
+/* Class record constants */
+
+extern WidgetClass labelWidgetClass;
+
+typedef struct _LabelClassRec *LabelWidgetClass;
+typedef struct _LabelRec *LabelWidget;
+
+#endif /* _XawLabel_h */
diff --git a/nx-X11/lib/Xaw/LabelP.h b/nx-X11/lib/Xaw/LabelP.h
new file mode 100644
index 000000000..9f49fdd4f
--- /dev/null
+++ b/nx-X11/lib/Xaw/LabelP.h
@@ -0,0 +1,121 @@
+/*
+* $Xorg: LabelP.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/LabelP.h,v 1.7 2001/01/17 19:42:27 dawes Exp $ */
+
+#ifndef _XawLabelP_h
+#define _XawLabelP_h
+
+/*
+ * Label Widget Private Data
+ */
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/SimpleP.h>
+
+/* New fields for the Label widget class record */
+typedef struct {
+ XtPointer extension;
+} LabelClassPart;
+
+/* Full class record declaration */
+typedef struct _LabelClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ LabelClassPart label_class;
+} LabelClassRec;
+
+extern LabelClassRec labelClassRec;
+
+/* New fields for the Label widget record */
+typedef struct {
+ /* resources */
+ Pixel foreground;
+ XFontStruct *font;
+ XFontSet fontset;
+ char *label;
+ XtJustify justify;
+ Dimension internal_width;
+ Dimension internal_height;
+ Pixmap pixmap;
+ Boolean resize;
+ unsigned char encoding;
+ Pixmap left_bitmap;
+
+ /* private state */
+ GC normal_GC;
+ GC gray_GC;
+ Pixmap stipple;
+ Position label_x;
+ Position label_y;
+ Dimension label_width;
+ Dimension label_height;
+ Dimension label_len;
+ int lbm_y; /* where in label */
+ unsigned int lbm_width, lbm_height; /* size of pixmap */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} LabelPart;
+
+/*
+ * Full instance record declaration
+ */
+typedef struct _LabelRec {
+ CorePart core;
+ SimplePart simple;
+ LabelPart label;
+} LabelRec;
+
+#define LEFT_OFFSET(lw) ((lw)->label.left_bitmap \
+ ? (lw)->label.lbm_width + (lw)->label.internal_width \
+ : 0)
+
+#endif /* _XawLabelP_h */
diff --git a/nx-X11/lib/Xaw/List.c b/nx-X11/lib/Xaw/List.c
new file mode 100644
index 000000000..54ca5168f
--- /dev/null
+++ b/nx-X11/lib/Xaw/List.c
@@ -0,0 +1,1273 @@
+/* $Xorg: List.c,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+/* $XFree86: xc/lib/Xaw/List.c,v 1.16 2001/01/17 19:42:27 dawes Exp $ */
+
+/*
+ * List.c - List widget
+ *
+ * This is a List widget. It allows the user to select an item in a list and
+ * notifies the application through a callback function.
+ *
+ * Created: 8/13/88
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <ctype.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Drawing.h>
+#include <X11/Xaw/ListP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+#define HeightLock 1
+#define WidthLock 2
+#define LongestLock 4
+
+#define HeightFree(w) !(((ListWidget)(w))->list.freedoms & HeightLock)
+#define WidthFree(w) !(((ListWidget)(w))->list.freedoms & WidthLock)
+#define LongestFree(w) !(((ListWidget)(w))->list.freedoms & LongestLock)
+
+#define MaxSize 32767
+
+/*
+ * Class Methods
+ */
+static void XawListDestroy(Widget);
+static void XawListInitialize(Widget, Widget, ArgList, Cardinal*);
+static XtGeometryResult XawListQueryGeometry(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawListRedisplay(Widget, XEvent*, Region);
+static void XawListResize(Widget);
+static Boolean XawListSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static void CalculatedValues(Widget);
+static void ChangeSize(Widget, unsigned int, unsigned int);
+static void ClipToShadowInteriorAndLongest(ListWidget, GC*, unsigned int);
+static int CvtToItem(Widget, int, int, int*);
+static void FindCornerItems(Widget, XEvent*, int*, int*);
+static void GetGCs(Widget);
+static void HighlightBackground(Widget, int, int, GC);
+static Bool ItemInRectangle(Widget, int, int, int);
+static Bool Layout(Widget, Bool, Bool, Dimension*, Dimension*);
+static void PaintItemName(Widget, int);
+static void ResetList(Widget, Bool, Bool);
+
+/*
+ * Actions
+ */
+static void Notify(Widget, XEvent*, String*, Cardinal*);
+static void Set(Widget, XEvent*, String*, Cardinal*);
+static void Unset(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * Initialization
+ */
+static char defaultTranslations[] =
+"<Btn1Down>:" "Set()\n"
+"<Btn1Up>:" "Notify()\n"
+;
+
+#define offset(field) XtOffsetOf(ListRec, field)
+static XtResource resources[] = {
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(list.foreground),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XtNcursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(simple.cursor),
+ XtRString,
+ "left_ptr"
+ },
+ {
+ XtNfont,
+ XtCFont,
+ XtRFontStruct,
+ sizeof(XFontStruct*),
+ offset(list.font),
+ XtRString,
+ XtDefaultFont
+ },
+ {
+ XtNfontSet,
+ XtCFontSet,
+ XtRFontSet,
+ sizeof(XFontSet),
+ offset(list.fontset),
+ XtRString,
+ XtDefaultFontSet
+ },
+ {
+ XtNlist,
+ XtCList,
+ XtRPointer,
+ sizeof(char**),
+ offset(list.list),
+#ifdef notyet
+ XtRStringArray,
+#else
+ XtRString,
+#endif
+ NULL
+ },
+ {
+ XtNdefaultColumns,
+ XtCColumns,
+ XtRInt,
+ sizeof(int),
+ offset(list.default_cols),
+ XtRImmediate,
+ (XtPointer)2
+ },
+ {
+ XtNlongest,
+ XtCLongest,
+ XtRInt,
+ sizeof(int),
+ offset(list.longest),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNnumberStrings,
+ XtCNumberStrings,
+ XtRInt,
+ sizeof(int),
+ offset(list.nitems),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNpasteBuffer,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(list.paste),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNforceColumns,
+ XtCColumns,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(list.force_cols),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNverticalList,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(list.vertical_cols),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNinternalWidth,
+ XtCWidth,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(list.internal_width),
+ XtRImmediate,
+ (XtPointer)2
+ },
+ {
+ XtNinternalHeight,
+ XtCHeight,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(list.internal_height),
+ XtRImmediate,
+ (XtPointer)2
+ },
+ {
+ XtNcolumnSpacing,
+ XtCSpacing,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(list.column_space),
+ XtRImmediate,
+ (XtPointer)6
+ },
+ {
+ XtNrowSpacing,
+ XtCSpacing,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(list.row_space),
+ XtRImmediate,
+ (XtPointer)2
+ },
+ {
+ XtNcallback,
+ XtCCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(list.callback),
+ XtRCallback,
+ NULL
+ },
+#ifndef OLDXAW
+ {
+ XtNshowCurrent,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(list.show_current),
+ XtRImmediate,
+ (XtPointer)False
+ },
+#endif
+};
+#undef offset
+
+static XtActionsRec actions[] = {
+ {"Notify", Notify},
+ {"Set", Set},
+ {"Unset", Unset},
+};
+
+#define Superclass (&simpleClassRec)
+ListClassRec listClassRec = {
+ /* core */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "List", /* class_name */
+ sizeof(ListRec), /* widget_size */
+ XawInitializeWidgetSet, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ XawListInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ actions, /* actions */
+ XtNumber(actions), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ False, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ XawListDestroy, /* destroy */
+ XawListResize, /* resize */
+ XawListRedisplay, /* expose */
+ XawListSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ defaultTranslations, /* tm_table */
+ XawListQueryGeometry, /* query_geometry */
+ },
+ /* simple */
+ {
+ XtInheritChangeSensitive, /* change_sensitive */
+ },
+ /* list */
+ {
+ NULL, /* extension */
+ },
+};
+
+WidgetClass listWidgetClass = (WidgetClass)&listClassRec;
+
+/*
+ * Implementation
+ */
+static void
+GetGCs(Widget w)
+{
+ XGCValues values;
+ ListWidget lw = (ListWidget)w;
+
+ values.foreground = lw->list.foreground;
+ values.font = lw->list.font->fid;
+
+ if (lw->simple.international == True)
+ lw->list.normgc = XtAllocateGC(w, 0, GCForeground, &values, GCFont, 0);
+ else
+ lw->list.normgc = XtGetGC(w, GCForeground | GCFont, &values);
+
+ values.foreground = lw->core.background_pixel;
+
+ if (lw->simple.international == True)
+ lw->list.revgc = XtAllocateGC(w, 0, GCForeground, &values, GCFont, 0);
+ else
+ lw->list.revgc = XtGetGC(w, GCForeground | GCFont, &values);
+
+ values.tile = XmuCreateStippledPixmap(XtScreen(w),
+ lw->list.foreground,
+ lw->core.background_pixel,
+ lw->core.depth);
+ values.fill_style = FillTiled;
+
+ if (lw->simple.international == True)
+ lw->list.graygc = XtAllocateGC(w, 0, GCTile | GCFillStyle,
+ &values, GCFont, 0);
+ else
+ lw->list.graygc = XtGetGC(w, GCFont | GCTile | GCFillStyle, &values);
+}
+
+static void
+CalculatedValues(Widget w)
+{
+ int i, len;
+ ListWidget lw = (ListWidget)w;
+
+ /* If list is NULL then the list will just be the name of the widget */
+ if (lw->list.list == NULL) {
+ lw->list.list = &lw->core.name;
+ lw->list.nitems = 1;
+ }
+
+ /* Get number of items */
+ if (lw->list.nitems == 0)
+ for (; lw->list.list[lw->list.nitems] != NULL ; lw->list.nitems++)
+ ;
+
+ /* Get column width */
+ if (LongestFree(lw)) {
+ lw->list.longest = 0; /* so it will accumulate real longest below */
+
+ for (i = 0 ; i < lw->list.nitems; i++) {
+ if (lw->simple.international == True)
+ len = XmbTextEscapement(lw->list.fontset, lw->list.list[i],
+ strlen(lw->list.list[i]));
+ else
+ len = XTextWidth(lw->list.font, lw->list.list[i],
+ strlen(lw->list.list[i]));
+ if (len > lw->list.longest)
+ lw->list.longest = len;
+ }
+ }
+
+ lw->list.col_width = lw->list.longest + lw->list.column_space;
+}
+
+/*
+ * Function:
+ * ResetList
+ *
+ * Parameters:
+ * w - list widget
+ * changex - allow the height or width to change?
+ * changey - ""
+ *
+ * Description:
+ * Resets the new list when important things change.
+ *
+ * Returns:
+ * True if width or height have been changed
+ */
+static void
+ResetList(Widget w, Bool changex, Bool changey)
+{
+ Dimension width = XtWidth(w);
+ Dimension height = XtHeight(w);
+
+ CalculatedValues(w);
+
+ if (Layout(w, changex, changey, &width, &height)) {
+ if (XtIsComposite(XtParent(w)))
+ ChangeSize(w, width, height);
+ else {
+ XtWidth(w) = width;
+ XtHeight(w) = height;
+ }
+ }
+}
+
+/*
+ * Function:
+ * ChangeSize
+ *
+ * Parameters:
+ * w - widget to try change the size of
+ *
+ * Description:
+ * Laysout the widget.
+ */
+static void
+ChangeSize(Widget w, unsigned int width, unsigned int height)
+{
+ XtWidgetGeometry request, reply;
+
+ request.request_mode = CWWidth | CWHeight;
+ request.width = width;
+ request.height = height;
+
+ switch (XtMakeGeometryRequest(w, &request, &reply)) {
+ case XtGeometryYes:
+ case XtGeometryNo:
+ break;
+ case XtGeometryAlmost:
+ Layout(w, request.height != reply.height,
+ request.width != reply.width, &reply.width, &reply.height);
+ request = reply;
+ switch (XtMakeGeometryRequest(w, &request, &reply)) {
+ case XtGeometryYes:
+ case XtGeometryNo:
+ break;
+ case XtGeometryAlmost:
+ request = reply;
+ Layout(w, False, False, &request.width, &request.height);
+ request.request_mode = CWWidth | CWHeight;
+ XtMakeGeometryRequest(w, &request, &reply);
+ /*FALLTROUGH*/
+ default:
+ break;
+ }
+ /*FALLTROUGH*/
+ default:
+ break;
+ }
+}
+
+/*ARGSUSED*/
+static void
+XawListInitialize(Widget temp1, Widget cnew, ArgList args, Cardinal *num_args)
+{
+ ListWidget lw = (ListWidget)cnew;
+
+ if (!lw->list.font) XtError("Aborting: no font found\n");
+ if (lw->simple.international && !lw->list.fontset)
+ XtError("Aborting: no fontset found\n");
+
+ /*
+ * Initialize all private resources
+ */
+ /* record for posterity if we are free */
+ lw->list.freedoms = ((XtWidth(lw) != 0) * WidthLock +
+ (XtHeight(lw) != 0) * HeightLock +
+ (lw->list.longest != 0) * LongestLock);
+
+ GetGCs(cnew);
+
+ /* Set row height, based on font or fontset */
+ if (lw->simple.international == True)
+ lw->list.row_height =
+ XExtentsOfFontSet(lw->list.fontset)->max_ink_extent.height +
+ lw->list.row_space;
+ else
+ lw->list.row_height = lw->list.font->max_bounds.ascent +
+ lw->list.font->max_bounds.descent +
+ lw->list.row_space;
+
+ ResetList(cnew, WidthFree(lw), HeightFree(lw));
+
+ lw->list.highlight = lw->list.is_highlighted = NO_HIGHLIGHT;
+}
+
+/*
+ * Function:
+ * CvtToItem
+ *
+ * Parameters:
+ * w - list widget
+ * xloc - x location
+ * yloc - y location
+ *
+ * Description:
+ * Converts Xcoord to item number of item containing that point.
+ *
+ * Returns:
+ * Item number
+ */
+static int
+CvtToItem(Widget w, int xloc, int yloc, int *item)
+{
+ int one, another;
+ ListWidget lw = (ListWidget)w;
+ int ret_val = OKAY;
+
+ if (lw->list.vertical_cols) {
+ one = lw->list.nrows * ((xloc - (int)lw->list.internal_width)
+ / lw->list.col_width);
+ another = (yloc - (int)lw->list.internal_height) / lw->list.row_height;
+ /* If out of range, return minimum possible value */
+ if (another >= lw->list.nrows) {
+ another = lw->list.nrows - 1;
+ ret_val = OUT_OF_RANGE;
+ }
+ }
+ else {
+ one = (lw->list.ncols * ((yloc - (int)lw->list.internal_height)
+ / lw->list.row_height));
+ /* If in right margin handle things right */
+ another = (xloc - (int)lw->list.internal_width) / lw->list.col_width;
+ if (another >= lw->list.ncols) {
+ another = lw->list.ncols - 1;
+ ret_val = OUT_OF_RANGE;
+ }
+ }
+ if (xloc < 0 || yloc < 0)
+ ret_val = OUT_OF_RANGE;
+ if (one < 0)
+ one = 0;
+ if (another < 0)
+ another = 0;
+ *item = one + another;
+ if (*item >= lw->list.nitems)
+ return (OUT_OF_RANGE);
+
+ return (ret_val);
+}
+
+/*
+ * Function:
+ * FindCornerItems
+ *
+ * Arguments:
+ * w - list widget
+ * event - event structure that has the rectangle it it
+ * ul_ret - the corners (return)
+ * lr_ret - ""
+ *
+ * Description:
+ * Find the corners of the rectangle in item space.
+ */
+static void
+FindCornerItems(Widget w, XEvent *event, int *ul_ret, int *lr_ret)
+{
+ int xloc, yloc;
+
+ xloc = event->xexpose.x;
+ yloc = event->xexpose.y;
+ CvtToItem(w, xloc, yloc, ul_ret);
+ xloc += event->xexpose.width;
+ yloc += event->xexpose.height;
+ CvtToItem(w, xloc, yloc, lr_ret);
+}
+
+/*
+ * Function:
+ * ItemInRectangle
+ *
+ * Parameters:
+ * w - list widget
+ * ul - corners of the rectangle in item space
+ * lr - ""
+ * item - item to check
+ *
+ * Returns:
+ * True if the item passed is in the given rectangle
+ */
+static Bool
+ItemInRectangle(Widget w, int ul, int lr, int item)
+{
+ ListWidget lw = (ListWidget)w;
+ int mod_item;
+ int things;
+
+ if (item < ul || item > lr)
+ return (False);
+ if (lw->list.vertical_cols)
+ things = lw->list.nrows;
+ else
+ things = lw->list.ncols;
+
+ mod_item = item % things;
+ if ((mod_item >= ul % things) && (mod_item <= lr % things))
+ return (True);
+
+ return (False);
+}
+
+/* HighlightBackground()
+ *
+ * Paints the color of the background for the given item. It performs
+ * clipping to the interior of internal_width/height by hand, as its a
+ * simple calculation and probably much faster than using Xlib and a clip mask.
+ *
+ * x, y - ul corner of the area item occupies.
+ * gc - the gc to use to paint this rectangle
+ */
+static void
+HighlightBackground(Widget w, int x, int y, GC gc)
+{
+ ListWidget lw = (ListWidget)w;
+ Dimension width = lw->list.col_width;
+ Dimension height = lw->list.row_height;
+ Dimension frame_limited_width = XtWidth(w) - lw->list.internal_width - x;
+ Dimension frame_limited_height= XtHeight(w) - lw->list.internal_height - y;
+
+ /* Clip the rectangle width and height to the edge of the drawable area */
+ if (width > frame_limited_width)
+ width = frame_limited_width;
+ if (height > frame_limited_height)
+ height = frame_limited_height;
+
+ /* Clip the rectangle x and y to the edge of the drawable area */
+ if (x < lw->list.internal_width) {
+ width = width - (lw->list.internal_width - x);
+ x = lw->list.internal_width;
+ }
+ if (y < lw->list.internal_height) {
+ height = height - (lw->list.internal_height - y);
+ y = lw->list.internal_height;
+ }
+
+ if (gc == lw->list.revgc && lw->core.background_pixmap != XtUnspecifiedPixmap)
+ XClearArea(XtDisplay(w), XtWindow(w), x, y, width, height, False);
+ else
+ XFillRectangle(XtDisplay(w), XtWindow(w), gc, x, y, width, height);
+}
+
+
+/* ClipToShadowInteriorAndLongest()
+ *
+ * Converts the passed gc so that any drawing done with that GC will not
+ * write in the empty margin (specified by internal_width/height) (which also
+ * prevents erasing the shadow. It also clips against the value longest.
+ * If the user doesn't set longest, this has no effect (as longest is the
+ * maximum of all item lengths). If the user does specify, say, 80 pixel
+ * columns, though, this prevents items from overwriting other items.
+ */
+static void
+ClipToShadowInteriorAndLongest(ListWidget lw, GC *gc_p, unsigned int x)
+{
+ XRectangle rect;
+
+ rect.x = x;
+ rect.y = lw->list.internal_height;
+ rect.height = XtHeight(lw) - (lw->list.internal_height << 1);
+ rect.width = XtWidth(lw) - lw->list.internal_width - x;
+ if (rect.width > lw->list.longest)
+ rect.width = lw->list.longest;
+
+ XSetClipRectangles(XtDisplay((Widget)lw), *gc_p, 0, 0, &rect, 1, YXBanded);
+}
+
+static void
+PaintItemName(Widget w, int item)
+{
+ char *str;
+ GC gc;
+ int x, y, str_y;
+ ListWidget lw = (ListWidget)w;
+ XFontSetExtents *ext = XExtentsOfFontSet(lw->list.fontset);
+
+ if (!XtIsRealized(w) || item > lw->list.nitems)
+ return;
+
+ if (lw->list.vertical_cols) {
+ x = lw->list.col_width * (item / lw->list.nrows)
+ + lw->list.internal_width;
+ y = lw->list.row_height * (item % lw->list.nrows)
+ + lw->list.internal_height;
+ }
+ else {
+ x = lw->list.col_width * (item % lw->list.ncols)
+ + lw->list.internal_width;
+ y = lw->list.row_height * (item / lw->list.ncols)
+ + lw->list.internal_height;
+ }
+
+ if ( lw->simple.international == True )
+ str_y = y + XawAbs(ext->max_ink_extent.y);
+ else
+ str_y = y + lw->list.font->max_bounds.ascent;
+
+ if (item == lw->list.is_highlighted) {
+ if (item == lw->list.highlight) {
+ gc = lw->list.revgc;
+ HighlightBackground(w, x, y, lw->list.normgc);
+ }
+ else {
+ if (XtIsSensitive(w))
+ gc = lw->list.normgc;
+ else
+ gc = lw->list.graygc;
+ HighlightBackground(w, x, y, lw->list.revgc);
+ lw->list.is_highlighted = NO_HIGHLIGHT;
+ }
+ }
+ else {
+ if (item == lw->list.highlight) {
+ gc = lw->list.revgc;
+ HighlightBackground(w, x, y, lw->list.normgc);
+ lw->list.is_highlighted = item;
+ }
+ else {
+ if (XtIsSensitive(w))
+ gc = lw->list.normgc;
+ else
+ gc = lw->list.graygc;
+ }
+ }
+
+ /* List's overall width contains the same number of inter-column
+ column_space's as columns. There should thus be a half
+ column_width margin on each side of each column.
+ The row case is symmetric */
+
+ x += lw->list.column_space >> 1;
+ str_y += lw->list.row_space >> 1;
+
+ str = lw->list.list[item]; /* draw it */
+
+ ClipToShadowInteriorAndLongest(lw, &gc, x);
+
+ if (lw->simple.international == True)
+ XmbDrawString(XtDisplay(w), XtWindow(w), lw->list.fontset,
+ gc, x, str_y, str, strlen(str));
+ else
+ XDrawString(XtDisplay(w), XtWindow(w), gc, x, str_y, str, strlen(str));
+
+ XSetClipMask(XtDisplay(w), gc, None);
+}
+
+static void
+XawListRedisplay(Widget w, XEvent *event, Region region)
+{
+ int item; /* an item to work with */
+ int ul_item, lr_item; /* corners of items we need to paint */
+ ListWidget lw = (ListWidget)w;
+
+ if (event == NULL) {
+ ul_item = 0;
+ lr_item = lw->list.nrows * lw->list.ncols - 1;
+ XClearWindow(XtDisplay(w), XtWindow(w));
+ }
+ else
+ FindCornerItems(w, event, &ul_item, &lr_item);
+
+ if (Superclass->core_class.expose)
+ (Superclass->core_class.expose)(w, event, region);
+
+ for (item = ul_item; item <= lr_item && item < lw->list.nitems; item++)
+ if (ItemInRectangle(w, ul_item, lr_item, item))
+ PaintItemName(w, item);
+}
+
+/* XawListQueryGeometry()
+ *
+ * This tells the parent what size we would like to be
+ * given certain constraints.
+ * w - the widget.
+ * intended - what the parent intends to do with us.
+ * requested - what we want to happen */
+static XtGeometryResult
+XawListQueryGeometry(Widget w, XtWidgetGeometry *intended,
+ XtWidgetGeometry *requested)
+{
+ Dimension new_width, new_height;
+ Bool change, width_req, height_req;
+
+ width_req = intended->request_mode & CWWidth;
+ height_req = intended->request_mode & CWHeight;
+
+ if (width_req)
+ new_width = intended->width;
+ else
+ new_width = XtWidth(w);
+
+ if (height_req)
+ new_height = intended->height;
+ else
+ new_height = XtHeight(w);
+
+ requested->request_mode = 0;
+
+ /*
+ * We only care about our height and width
+ */
+ if (!width_req && !height_req)
+ return (XtGeometryYes);
+
+ change = Layout(w, !width_req, !height_req, &new_width, &new_height);
+
+ requested->request_mode |= CWWidth;
+ requested->width = new_width;
+ requested->request_mode |= CWHeight;
+ requested->height = new_height;
+
+ if (change)
+ return (XtGeometryAlmost);
+
+ return (XtGeometryYes);
+}
+
+static void
+XawListResize(Widget w)
+{
+ Dimension width, height;
+
+ width = XtWidth(w);
+ height = XtHeight(w);
+
+ if (Layout(w, False, False, &width, &height))
+ XtAppWarning(XtWidgetToApplicationContext(w),
+ "List Widget: Size changed when it shouldn't "
+ "have when resising.");
+}
+
+/* Layout()
+ *
+ * lays out the item in the list.
+ * w - the widget.
+ * xfree, yfree - True if we are free to resize the widget in
+ * this direction.
+ * width, height- the is the current width and height that we are going
+ * we are going to layout the list widget to,
+ * depending on xfree and yfree of course.
+ *
+ * Return:
+ * True if width or height have been changed */
+static Bool
+Layout(Widget w, Bool xfree, Bool yfree, Dimension *width, Dimension *height)
+{
+ ListWidget lw = (ListWidget)w;
+ Bool change = False;
+ unsigned long width2 = 0, height2 = 0;
+
+ /*
+ * If force columns is set then always use number of columns specified
+ * by default_cols
+ */
+ if (lw->list.force_cols) {
+ lw->list.ncols = lw->list.default_cols;
+ if (lw->list.ncols <= 0)
+ lw->list.ncols = 1;
+ lw->list.nrows = ((lw->list.nitems - 1) / lw->list.ncols) + 1;
+ if (xfree) {
+ /* this counts the same number
+ of inter-column column_space 's as columns. There should thus
+ be a half column_space margin on each side of each column...*/
+ width2 = lw->list.ncols * lw->list.col_width +
+ (lw->list.internal_width << 1);
+ change = True;
+ }
+ if (yfree) {
+ height2 = lw->list.nrows * lw->list.row_height +
+ (lw->list.internal_height << 1);
+ change = True;
+ }
+ }
+
+ /*
+ * If both width and height are free to change the use default_cols
+ * to determine the number columns and set new width and height to
+ * just fit the window
+ */
+ else if (xfree && yfree) {
+ lw->list.ncols = lw->list.default_cols;
+ if (lw->list.ncols <= 0) {
+ int wid = (int)XtWidth(lw) - (int)(lw->list.internal_width << 1)
+ + (int)lw->list.column_space;
+
+ if (wid <= 0 || lw->list.col_width <= 0
+ || (lw->list.ncols = wid / lw->list.col_width) <= 0)
+ lw->list.ncols = 1;
+ }
+ width2 = lw->list.ncols * lw->list.col_width
+ + (lw->list.internal_width << 1);
+ height2 = (lw->list.nrows * lw->list.row_height)
+ + (lw->list.internal_height << 1);
+ change = True;
+ }
+
+ /*
+ * If the width is fixed then use it to determine the number of columns.
+ * If the height is free to move (width still fixed) then resize the height
+ * of the widget to fit the current list exactly
+ */
+ else if (!xfree) {
+ lw->list.ncols = ((int)(*width - (lw->list.internal_width << 1))
+ / (int)lw->list.col_width);
+ if (lw->list.ncols <= 0)
+ lw->list.ncols = 1;
+ lw->list.nrows = ((lw->list.nitems - 1) / lw->list.ncols) + 1;
+ if (yfree) {
+ height2 = lw->list.nrows * lw->list.row_height +
+ (lw->list.internal_height << 1);
+ change = True;
+ }
+ }
+
+ /*
+ * The last case is xfree and !yfree we use the height to determine
+ * the number of rows and then set the width to just fit the resulting
+ * number of columns
+ */
+ else if (!yfree) {
+ lw->list.nrows = ((int)(*height - (lw->list.internal_height << 1))
+ / (int)lw->list.row_height);
+ if (lw->list.nrows <= 0)
+ lw->list.nrows = 1;
+ lw->list.ncols = ((lw->list.nitems - 1) / lw->list.nrows) + 1;
+ width2 = lw->list.ncols * lw->list.col_width +
+ (lw->list.internal_width << 1);
+ change = True;
+ }
+
+ if (!lw->list.force_cols && lw->list.nrows) {
+ /*CONSTCOND*/
+ while (1) {
+ lw->list.nrows = ((lw->list.nitems - 1) / lw->list.ncols) + 1;
+ width2 = lw->list.ncols * lw->list.col_width +
+ (lw->list.internal_width << 1);
+ height2 = lw->list.nrows * lw->list.row_height +
+ (lw->list.internal_height << 1);
+ if (width2 >= MaxSize && height2 >= MaxSize)
+ break;
+ if (height2 > MaxSize)
+ ++lw->list.ncols;
+ else if (width2 > MaxSize && lw->list.ncols > 1)
+ --lw->list.ncols;
+ else
+ break;
+ }
+ }
+ if (width2)
+ *width = width2;
+ if (height2)
+ *height = height2;
+
+ return (change);
+}
+
+/* Notify() - Action
+ *
+ * Notifies the user that a button has been pressed, and
+ * calls the callback; if the XtNpasteBuffer resource is true
+ * then the name of the item is also put in CUT_BUFFER0 */
+/*ARGSUSED*/
+static void
+Notify(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ ListWidget lw = (ListWidget)w;
+ int item, item_len;
+ XawListReturnStruct ret_value;
+
+ /*
+ * Find item and if out of range then unhighlight and return
+ *
+ * If the current item is unhighlighted then the user has aborted the
+ * notify, so unhighlight and return
+ */
+ if ((CvtToItem(w, event->xbutton.x, event->xbutton.y, &item) == OUT_OF_RANGE)
+ || lw->list.highlight != item) {
+#ifndef OLDXAW
+ if (!lw->list.show_current || lw->list.selected == NO_HIGHLIGHT)
+ XawListUnhighlight(w);
+ else
+ XawListHighlight(w, lw->list.selected);
+#else
+ XawListUnhighlight(w);
+#endif
+ return;
+ }
+
+ item_len = strlen(lw->list.list[item]);
+
+ if (lw->list.paste) /* if XtNpasteBuffer set then paste it */
+ XStoreBytes(XtDisplay(w), lw->list.list[item], item_len);
+
+#ifndef OLDXAW
+ lw->list.selected = item;
+#endif
+ /*
+ * Call Callback function
+ */
+ ret_value.string = lw->list.list[item];
+ ret_value.list_index = item;
+
+ XtCallCallbacks(w, XtNcallback, (XtPointer)&ret_value);
+}
+
+/* Unset() - Action
+ *
+ * unhighlights the current element */
+/*ARGSUSED*/
+static void
+Unset(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ XawListUnhighlight(w);
+}
+
+/* Set() - Action
+ *
+ * Highlights the current element */
+/*ARGSUSED*/
+static void
+Set(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ int item;
+ ListWidget lw = (ListWidget)w;
+
+#ifndef OLDXAW
+ lw->list.selected = lw->list.highlight;
+#endif
+ if (CvtToItem(w, event->xbutton.x, event->xbutton.y, &item) == OUT_OF_RANGE)
+ XawListUnhighlight(w); /* Unhighlight current item */
+ else if (lw->list.is_highlighted != item) /* If this item is not */
+ XawListHighlight(w, item); /* highlighted then do it */
+}
+
+/*
+ * Set specified arguments into widget
+ */
+/*ARGSUSED*/
+static Boolean
+XawListSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ ListWidget cl = (ListWidget)current;
+ ListWidget rl = (ListWidget)request;
+ ListWidget nl = (ListWidget)cnew;
+ Bool redraw = False;
+ XFontSetExtents *ext = XExtentsOfFontSet(nl->list.fontset);
+
+ /* If the request height/width is different, lock it. Unless its 0. If
+ neither new nor 0, leave it as it was. Not in R5 */
+ if (XtWidth(nl) != XtWidth(cl))
+ nl->list.freedoms |= WidthLock;
+ if (XtWidth(nl) == 0)
+ nl->list.freedoms &= ~WidthLock;
+
+ if (XtHeight(nl) != XtHeight(cl))
+ nl->list.freedoms |= HeightLock;
+ if (XtHeight(nl) == 0)
+ nl->list.freedoms &= ~HeightLock;
+
+ if (nl->list.longest != cl->list.longest)
+ nl->list.freedoms |= LongestLock;
+ if (nl->list.longest == 0)
+ nl->list.freedoms &= ~LongestLock;
+
+ if (cl->list.foreground != nl->list.foreground ||
+ cl->core.background_pixel != nl->core.background_pixel ||
+ cl->list.font != nl->list.font) {
+ XGCValues values;
+
+ XGetGCValues(XtDisplay(current), cl->list.graygc, GCTile, &values);
+ XmuReleaseStippledPixmap(XtScreen(current), values.tile);
+ XtReleaseGC(current, cl->list.graygc);
+ XtReleaseGC(current, cl->list.revgc);
+ XtReleaseGC(current, cl->list.normgc);
+ GetGCs(cnew);
+ redraw = True;
+ }
+
+ if (cl->list.font != nl->list.font && cl->simple.international == False)
+ nl->list.row_height = nl->list.font->max_bounds.ascent
+ + nl->list.font->max_bounds.descent
+ + nl->list.row_space;
+ else if (cl->list.fontset != nl->list.fontset
+ && cl->simple.international == True)
+ nl->list.row_height = ext->max_ink_extent.height + nl->list.row_space;
+
+ /* ...If the above two font(set) change checkers above both failed, check
+ if row_space was altered. If one of the above passed, row_height will
+ already have been re-calculated */
+ else if (cl->list.row_space != nl->list.row_space) {
+ if (cl->simple.international == True)
+ nl->list.row_height = ext->max_ink_extent.height + nl->list.row_space;
+ else
+ nl->list.row_height = nl->list.font->max_bounds.ascent
+ + nl->list.font->max_bounds.descent
+ + nl->list.row_space;
+ }
+
+ if (XtWidth(cl) != XtWidth(nl) || XtHeight(cl) != XtHeight(nl)
+ || cl->list.internal_width != nl->list.internal_width
+ || cl->list.internal_height != nl->list.internal_height
+ || cl->list.column_space != nl->list.column_space
+ || cl->list.row_space != nl->list.row_space
+ || cl->list.default_cols != nl->list.default_cols
+ || (cl->list.force_cols != nl->list.force_cols
+ && rl->list.force_cols != nl->list.ncols)
+ || cl->list.vertical_cols != nl->list.vertical_cols
+ || cl->list.longest != nl->list.longest
+ || cl->list.nitems != nl->list.nitems
+ || cl->list.font != nl->list.font
+ /* Equiv. fontsets might have different values, but the same fonts,
+ so the next comparison is sloppy but not dangerous */
+ || cl->list.fontset != nl->list.fontset
+ || cl->list.list != nl->list.list) {
+ CalculatedValues(cnew);
+ Layout(cnew, WidthFree(nl), HeightFree(nl),
+ &nl->core.width, &nl->core.height);
+ redraw = True;
+ }
+
+ if (cl->list.list != nl->list.list || cl->list.nitems != nl->list.nitems)
+ nl->list.is_highlighted = nl->list.highlight = NO_HIGHLIGHT;
+
+ if (cl->core.sensitive != nl->core.sensitive
+ || cl->core.ancestor_sensitive != nl->core.ancestor_sensitive) {
+ nl->list.highlight = NO_HIGHLIGHT;
+ redraw = True;
+ }
+
+ return (redraw);
+}
+
+static void
+XawListDestroy(Widget w)
+{
+ ListWidget lw = (ListWidget)w;
+ XGCValues values;
+
+ XGetGCValues(XtDisplay(w), lw->list.graygc, GCTile, &values);
+ XmuReleaseStippledPixmap(XtScreen(w), values.tile);
+ XtReleaseGC(w, lw->list.graygc);
+ XtReleaseGC(w, lw->list.revgc);
+ XtReleaseGC(w, lw->list.normgc);
+}
+
+/*
+ * Function:
+ * XawListChange
+ *
+ * Parameters:
+ * w - list widget
+ * list - new list
+ * nitems - number of items in the list
+ * longest - length (in Pixels) of the longest element in the list
+ * resize - if True the the list widget will try to resize itself
+ *
+ * Description:
+ * Changes the list being used and shown.
+ *
+ * Note:
+ * If nitems of longest are <= 0 then they will be calculated
+ * If nitems is <= 0 then the list needs to be NULL terminated
+ */
+void
+XawListChange(Widget w, char **list, int nitems, int longest,
+#if NeedWidePrototypes
+ int resize_it
+#else
+ Boolean resize_it
+#endif
+)
+{
+ ListWidget lw = (ListWidget)w;
+ Dimension new_width = XtWidth(w);
+ Dimension new_height = XtHeight(w);
+
+ lw->list.list = list;
+
+ if (nitems <= 0)
+ nitems = 0;
+ lw->list.nitems = nitems;
+ if (longest <= 0)
+ longest = 0;
+
+ /* If the user passes 0 meaning "calculate it", it must be free */
+ if (longest != 0)
+ lw->list.freedoms |= LongestLock;
+ else
+ lw->list.freedoms &= ~LongestLock;
+
+ if (resize_it)
+ lw->list.freedoms &= ~WidthLock & ~HeightLock;
+
+ lw->list.longest = longest;
+
+ CalculatedValues(w);
+
+ if (Layout(w, WidthFree(w), HeightFree(w), &new_width, &new_height))
+ ChangeSize(w, new_width, new_height);
+
+ lw->list.is_highlighted = lw->list.highlight = NO_HIGHLIGHT;
+ if (XtIsRealized(w))
+ XawListRedisplay(w, NULL, NULL);
+}
+
+void
+XawListUnhighlight(Widget w)
+{
+ ListWidget lw = (ListWidget)w;
+
+ lw->list.highlight = NO_HIGHLIGHT;
+ if (lw->list.is_highlighted != NO_HIGHLIGHT)
+ PaintItemName(w, lw->list.is_highlighted);
+}
+
+void
+XawListHighlight(Widget w, int item)
+{
+ ListWidget lw = (ListWidget)w;
+
+ if (XtIsSensitive(w)) {
+ lw->list.highlight = item;
+ if (lw->list.is_highlighted != NO_HIGHLIGHT)
+ PaintItemName(w, lw->list.is_highlighted);
+ PaintItemName(w, item);
+ }
+}
+
+/*
+ * Function:
+ * XawListShowCurrent
+ *
+ * Parameters:
+ * w - list widget
+ *
+ * Returns:
+ * Info about the currently highlighted object
+ */
+XawListReturnStruct *
+XawListShowCurrent(Widget w)
+{
+ ListWidget lw = (ListWidget)w;
+ XawListReturnStruct *ret_val;
+
+ ret_val = (XawListReturnStruct *)XtMalloc(sizeof(XawListReturnStruct));
+
+ ret_val->list_index = lw->list.highlight;
+ if (ret_val->list_index == XAW_LIST_NONE)
+ ret_val->string = "";
+ else
+ ret_val->string = lw->list.list[ret_val->list_index];
+
+ return (ret_val);
+}
diff --git a/nx-X11/lib/Xaw/List.h b/nx-X11/lib/Xaw/List.h
new file mode 100644
index 000000000..2115eefd4
--- /dev/null
+++ b/nx-X11/lib/Xaw/List.h
@@ -0,0 +1,237 @@
+/* $Xorg: List.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+/* $XFree86: xc/lib/Xaw/List.h,v 1.7 2001/01/17 19:42:27 dawes Exp $ */
+
+/* This is the List widget, it is useful to display a list, without the
+ * overhead of having a widget for each item in the list. It allows
+ * the user to select an item in a list and notifies the application through
+ * a callback function.
+ *
+ * Created: 8/13/88
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ */
+
+#ifndef _XawList_h
+#define _XawList_h
+
+#include <X11/Xaw/Simple.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ borderColor BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ callback Callback XtCallbackList NULL **6
+ columnSpacing Spacing Dimension 6
+ cursor Cursor Cursor left_ptr
+ cursorName Cursor String NULL
+ defaultColumns Columns int 2 **5
+ destroyCallback Callback Pointer NULL
+ font Font XFontStruct* XtDefaultFont
+ forceColumns Columns Boolean False **5
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension 0 **1
+ insensitiveBorder Insensitive Pixmap Gray
+ internalHeight Height Dimension 2
+ internalWidth Width Dimension 4
+ list List String* NULL **2
+ longest Longest int 0 **3 **4
+ mappedWhenManaged MappedWhenManaged Boolean True
+ numberStrings NumberStrings int 0 **4
+ pasteBuffer Boolean Boolean False
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ rowSpacing Spacing Dimension 4
+ sensitive Sensitive Boolean True
+ verticalList Boolean Boolean False
+ width Width Dimension 0 **1
+ x Position Position 0
+ y Position Position 0
+
+ **1 - If the Width or Height of the list widget is zero (0) then the value
+ is set to the minimum size necessay to fit the entire list.
+
+ If both Width and Height are zero then they are adjusted to fit the
+ entire list that is created width the number of default columns
+ specified in the defaultColumns resource.
+
+ **2 - This is an array of strings the specify elements of the list.
+ This resource must be specified.
+ (What good is a list widget without a list?? :-)
+
+ **3 - Longest is the length of the widest string in pixels.
+
+ **4 - If either of these values are zero (0) then the list widget calculates
+ the correct value.
+
+ (This allows you to make startup faster if you already have
+ this information calculated)
+
+ NOTE: If the numberStrings value is zero the list must
+ be NULL terminated.
+
+ **5 - By setting the List.Columns resource you can force the application to
+ have a given number of columns.
+
+ **6 - This returns the name and index of the item selected in an
+ XawListReturnStruct that is pointed to by the client_data
+ in the CallbackProc.
+
+*/
+
+/*
+ * Value returned when there are no highlighted objects
+ */
+#define XAW_LIST_NONE -1
+
+#define XtCList "List"
+#define XtCSpacing "Spacing"
+#define XtCColumns "Columns"
+#define XtCLongest "Longest"
+#define XtCNumberStrings "NumberStrings"
+
+#define XtNcursor "cursor"
+#define XtNcolumnSpacing "columnSpacing"
+#define XtNdefaultColumns "defaultColumns"
+#define XtNforceColumns "forceColumns"
+#define XtNlist "list"
+#define XtNlongest "longest"
+#define XtNnumberStrings "numberStrings"
+#define XtNpasteBuffer "pasteBuffer"
+#define XtNrowSpacing "rowSpacing"
+#define XtNverticalList "verticalList"
+#define XtNshowCurrent "showCurrent"
+
+#ifndef XtNfontSet
+#define XtNfontSet "fontSet"
+#endif
+
+#ifndef XtCFontSet
+#define XtCFontSet "FontSet"
+#endif
+
+extern WidgetClass listWidgetClass;
+
+typedef struct _ListClassRec *ListWidgetClass;
+typedef struct _ListRec *ListWidget;
+
+/* list return structure */
+typedef struct _XawListReturnStruct {
+ String string;
+ int list_index;
+} XawListReturnStruct;
+
+_XFUNCPROTOBEGIN
+
+/*
+ * Function:
+ * XawListChange
+ *
+ * Parameters:
+ * w - list widget
+ * list - new list
+ * nitems - number of items in the list
+ * longest - length (in Pixels) of the longest element in the list
+ * resize - if True the the list widget will try to resize itself
+ *
+ * Description:
+ * Changes the list being used and shown.
+ *
+ * Note:
+ * If nitems of longest are <= 0 then they will be caluculated
+ * If nitems is <= 0 then the list needs to be NULL terminated
+ */
+void XawListChange
+(
+ Widget w,
+ String *list,
+ int nitems,
+ int longest,
+#if NeedWidePrototypes
+ int resize
+#else
+ Boolean resize
+#endif
+ );
+
+/*
+ * Function:
+ * XawListUnhighlight
+ *
+ * Parameters:
+ * w - list widget
+ *
+ * Description:
+ * Unlights the current highlighted element.
+ */
+void XawListUnhighlight
+(
+ Widget w
+ );
+
+/*
+ * Function:
+ * XawListHighlight
+ *
+ * Parameters:
+ * w - list widget
+ * item - item to highlight
+ *
+ * Description:
+ * Highlights the given item.
+ */
+void XawListHighlight
+(
+ Widget w,
+ int item
+ );
+
+
+/*
+ * Function:
+ * XawListShowCurrent
+ *
+ * Paraneters:
+ * w - list widget
+ *
+ * Description:
+ * Returns the currently highlighted object.
+ *
+ * Returns:
+ * The info about the currently highlighted object
+ */
+
+XawListReturnStruct *XawListShowCurrent
+(
+ Widget w
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XawList_h */
diff --git a/nx-X11/lib/Xaw/ListP.h b/nx-X11/lib/Xaw/ListP.h
new file mode 100644
index 000000000..2b8fc4639
--- /dev/null
+++ b/nx-X11/lib/Xaw/ListP.h
@@ -0,0 +1,118 @@
+/* $Xorg: ListP.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+/* $XFree86: xc/lib/Xaw/ListP.h,v 1.8 2001/01/17 19:42:27 dawes Exp $ */
+
+
+/*
+ * This is a List widget. It allows the user to select an item in a list and
+ * notifies the application through a callback function.
+ *
+ * Created: 8/13/88
+ * By: Chris D. Peterson
+ * MIT - Project Athena
+ */
+
+#ifndef _XawListP_h
+#define _XawListP_h
+
+/*
+ * List Widget Private Data
+ */
+#include <X11/Xaw/SimpleP.h>
+#include <X11/Xaw/List.h>
+
+#define NO_HIGHLIGHT XAW_LIST_NONE
+#define OUT_OF_RANGE -1
+#define OKAY 0
+
+/* New fields for the List widget class */
+typedef struct {
+ XtPointer extension;
+} ListClassPart;
+
+/* Full class record */
+typedef struct _ListClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ ListClassPart list_class;
+} ListClassRec;
+
+extern ListClassRec listClassRec;
+
+/* New fields for the List widget */
+typedef struct {
+ /* resources */
+ Pixel foreground;
+ Dimension internal_width; /* if not 3d, user sets directly */
+ Dimension internal_height;
+ Dimension column_space; /* half of *_space is add on
+ top/bot/left of */
+ Dimension row_space; /* each item's text bounding box
+ half added to longest for right */
+ int default_cols;
+ Boolean force_cols;
+ Boolean paste;
+ Boolean vertical_cols;
+ int longest; /* in pixels */
+ int nitems;
+ XFontStruct *font;
+ XFontSet fontset; /* Sheeran, Omron KK, 93/03/05 */
+ String *list; /* for i18n, always in multibyte
+ format */
+ XtCallbackList callback;
+
+ /* private */
+ int is_highlighted; /* set to the item currently
+ highlighted */
+ int highlight; /* set to the item that should be
+ highlighted */
+ int col_width; /* width of each column */
+ int row_height; /* height of each row */
+ int nrows; /* number of rows in the list */
+ int ncols; /* number of columns in the list */
+ GC normgc;
+ GC revgc;
+ GC graygc;
+ int freedoms; /* flags for resizing height
+ and width */
+#ifndef OLDXAW
+ int selected;
+ Boolean show_current;
+ char pad1[(sizeof(XtPointer) - sizeof(Boolean)) +
+ (sizeof(XtPointer) - sizeof(int))];
+ XtPointer pad2[2]; /* for future use and keep binary compatability */
+#endif
+} ListPart;
+
+
+/* Full instance record */
+typedef struct _ListRec {
+ CorePart core;
+ SimplePart simple;
+ ListPart list;
+} ListRec;
+
+#endif /* _XawListP_h */
diff --git a/nx-X11/lib/Xaw/MenuButtoP.h b/nx-X11/lib/Xaw/MenuButtoP.h
new file mode 100644
index 000000000..416fdf9b5
--- /dev/null
+++ b/nx-X11/lib/Xaw/MenuButtoP.h
@@ -0,0 +1,80 @@
+/* $Xorg: MenuButtoP.h,v 1.4 2001/02/09 02:03:44 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.
+ */
+/* $XFree86: xc/lib/Xaw/MenuButtoP.h,v 1.7 2001/01/17 19:42:27 dawes Exp $ */
+
+/*
+ * MenuButtonP.h - Private Header file for MenuButton widget.
+ *
+ * This is the private header file for the Athena MenuButton widget.
+ * It is intended to provide an easy method of activating pulldown menus.
+ *
+ * Date: May 2, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _XawMenuButtonP_h
+#define _XawMenuButtonP_h
+
+#include <X11/Xaw/MenuButton.h>
+#include <X11/Xaw/CommandP.h>
+
+/* New fields for the MenuButton widget class */
+typedef struct _MenuButtonClass {
+ XtPointer extension;
+} MenuButtonClassPart;
+
+/* class record declaration */
+typedef struct _MenuButtonClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ LabelClassPart label_class;
+ CommandClassPart command_class;
+ MenuButtonClassPart menuButton_class;
+} MenuButtonClassRec;
+
+extern MenuButtonClassRec menuButtonClassRec;
+
+/* New fields for the MenuButton widget */
+typedef struct {
+ /* resources */
+ String menu_name;
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} MenuButtonPart;
+
+/* widget declaration */
+typedef struct _MenuButtonRec {
+ CorePart core;
+ SimplePart simple;
+ LabelPart label;
+ CommandPart command;
+ MenuButtonPart menu_button;
+} MenuButtonRec;
+
+#endif /* _XawMenuButtonP_h */
diff --git a/nx-X11/lib/Xaw/MenuButton.c b/nx-X11/lib/Xaw/MenuButton.c
new file mode 100644
index 000000000..6c5da154a
--- /dev/null
+++ b/nx-X11/lib/Xaw/MenuButton.c
@@ -0,0 +1,276 @@
+/* $Xorg: MenuButton.c,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ */
+
+/* $XFree86: xc/lib/Xaw/MenuButton.c,v 3.9 2001/10/11 21:17:00 paulo Exp $ */
+
+/*
+ * MenuButton.c - Source code for MenuButton widget.
+ *
+ * This is the source code for the Athena MenuButton widget.
+ * It is intended to provide an easy method of activating pulldown menus.
+ *
+ * Date: May 2, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xaw/MenuButtoP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+/*
+ * Class Methods
+ */
+static void XawMenuButtonClassInitialize(void);
+static void XawMenuButtonInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawMenuButtonDestroy(Widget);
+static Boolean XawMenuButtonSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
+
+/*
+ * Actions
+ */
+static void PopupMenu(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * Initialization
+ */
+#define superclass ((CommandWidgetClass)&commandClassRec)
+
+static char defaultTranslations[] =
+"<Enter>:" "highlight()\n"
+"<Leave>:" "reset()\n"
+"Any<BtnDown>:" "reset() PopupMenu()\n";
+
+static char default_menu_name[] = "menu";
+
+#define offset(field) XtOffsetOf(MenuButtonRec, field)
+static XtResource resources[] = {
+ {
+ XtNmenuName,
+ XtCMenuName,
+ XtRString,
+ sizeof(String),
+ offset(menu_button.menu_name),
+ XtRString,
+ (XtPointer)default_menu_name
+ },
+};
+#undef offset
+
+static XtActionsRec actionsList[] =
+{
+ {"PopupMenu", PopupMenu},
+};
+
+MenuButtonClassRec menuButtonClassRec = {
+ /* core */
+ {
+ (WidgetClass)superclass, /* superclass */
+ "MenuButton", /* class_name */
+ sizeof(MenuButtonRec), /* size */
+ XawMenuButtonClassInitialize, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ XawMenuButtonInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ actionsList, /* actions */
+ XtNumber(actionsList), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ False, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ XawMenuButtonDestroy, /* destroy */
+ XtInheritResize, /* resize */
+ XtInheritExpose, /* expose */
+ XawMenuButtonSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ defaultTranslations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* simple */
+ {
+ XtInheritChangeSensitive /* change_sensitive */
+ },
+ /* label */
+ {
+ NULL, /* extension */
+ },
+ /* command */
+ {
+ NULL, /* extension */
+ },
+ /* menu_button */
+ {
+ NULL, /* extension */
+ },
+};
+
+WidgetClass menuButtonWidgetClass = (WidgetClass)&menuButtonClassRec;
+
+/*
+ * Implementation
+ */
+static void
+XawMenuButtonClassInitialize(void)
+{
+ XawInitializeWidgetSet();
+ XtRegisterGrabAction(PopupMenu, True,
+ ButtonPressMask | ButtonReleaseMask,
+ GrabModeAsync, GrabModeAsync);
+}
+
+/*ARGSUSED*/
+static void
+XawMenuButtonInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ MenuButtonWidget mbw = (MenuButtonWidget)cnew;
+
+ if (mbw->menu_button.menu_name != default_menu_name)
+ mbw->menu_button.menu_name = XtNewString(mbw->menu_button.menu_name);
+}
+
+static void
+XawMenuButtonDestroy(Widget w)
+{
+ MenuButtonWidget mbw = (MenuButtonWidget)w;
+
+ if (mbw->menu_button.menu_name != default_menu_name)
+ XtFree(mbw->menu_button.menu_name);
+}
+
+/*ARGSUSED*/
+static Boolean
+XawMenuButtonSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ MenuButtonWidget mbw_old = (MenuButtonWidget)current;
+ MenuButtonWidget mbw_new = (MenuButtonWidget)cnew;
+
+ if (mbw_old->menu_button.menu_name != mbw_new->menu_button.menu_name) {
+ if (mbw_old->menu_button.menu_name != default_menu_name)
+ XtFree(mbw_old->menu_button.menu_name);
+ if (mbw_new->menu_button.menu_name != default_menu_name)
+ mbw_new->menu_button.menu_name =
+ XtNewString(mbw_new->menu_button.menu_name);
+ }
+
+ return (False);
+}
+
+/*ARGSUSED*/
+static void
+PopupMenu(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ MenuButtonWidget mbw = (MenuButtonWidget)w;
+ Widget menu = NULL, temp;
+ Arg arglist[2];
+ Cardinal num_args;
+ int menu_x, menu_y, menu_width, menu_height, button_height;
+ Position button_x, button_y;
+
+ temp = w;
+ while(temp != NULL) {
+ menu = XtNameToWidget(temp, mbw->menu_button.menu_name);
+ if (menu == NULL)
+ temp = XtParent(temp);
+ else
+ break;
+ }
+
+ if (menu == NULL) {
+ char error_buf[BUFSIZ];
+
+ (void)XmuSnprintf(error_buf, sizeof(error_buf),
+ "MenuButton: Could not find menu widget named %s.",
+ mbw->menu_button.menu_name);
+ XtAppWarning(XtWidgetToApplicationContext(w), error_buf);
+ return;
+ }
+
+ if (!XtIsRealized(menu))
+ XtRealizeWidget(menu);
+
+ menu_width = XtWidth(menu) + (XtBorderWidth(menu) << 1);
+ button_height = XtHeight(w) + (XtBorderWidth(w) << 1);
+ menu_height = XtHeight(menu) + (XtBorderWidth(menu) << 1);
+
+ XtTranslateCoords(w, 0, 0, &button_x, &button_y);
+ menu_x = button_x;
+ menu_y = button_y + button_height;
+
+ if (menu_y >= 0) {
+ int scr_height = HeightOfScreen(XtScreen(menu));
+
+ if (menu_y + menu_height > scr_height)
+ menu_y = button_y - menu_height;
+ if (menu_y < 0) {
+ menu_y = scr_height - menu_height;
+ menu_x = button_x + XtWidth(w) + (XtBorderWidth(w) << 1);
+ if (menu_x + menu_width > WidthOfScreen(XtScreen(menu)))
+ menu_x = button_x - menu_width;
+ }
+ }
+ if (menu_y < 0)
+ menu_y = 0;
+
+ if (menu_x >= 0) {
+ int scr_width = WidthOfScreen(XtScreen(menu));
+
+ if (menu_x + menu_width > scr_width)
+ menu_x = scr_width - menu_width;
+ }
+ if (menu_x < 0)
+ menu_x = 0;
+
+ num_args = 0;
+ XtSetArg(arglist[num_args], XtNx, menu_x); num_args++;
+ XtSetArg(arglist[num_args], XtNy, menu_y); num_args++;
+ XtSetValues(menu, arglist, num_args);
+
+ XtPopupSpringLoaded(menu);
+}
diff --git a/nx-X11/lib/Xaw/MenuButton.h b/nx-X11/lib/Xaw/MenuButton.h
new file mode 100644
index 000000000..59744c26c
--- /dev/null
+++ b/nx-X11/lib/Xaw/MenuButton.h
@@ -0,0 +1,91 @@
+/*
+ * $Xorg: MenuButton.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+/* $XFree86: xc/lib/Xaw/MenuButton.h,v 1.5 2001/01/17 19:42:27 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * MenuButton Widget
+ *
+ ***********************************************************************/
+
+/*
+ * MenuButton.h - Public Header file for MenuButton widget.
+ *
+ * This is the public header file for the Athena MenuButton widget.
+ * It is intended to provide an easy method of activating pulldown menus.
+ *
+ * Date: May 2, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _XawMenuButton_h
+#define _XawMenuButton_h
+
+#include <X11/Xaw/Command.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ bitmap Pixmap Pixmap None
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ callback Callback Pointer NULL
+ cursor Cursor Cursor None
+ destroyCallback Callback Pointer NULL
+ displayList DisplayList XawDisplayList* NULL
+ font Font XFontStruct* XtDefaultFont
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension text height
+ highlightThickness Thickness Dimension 2
+ insensitiveBorder Insensitive Pixmap Gray
+ internalHeight Height Dimension 2
+ internalWidth Width Dimension 4
+ justify Justify XtJustify XtJustifyCenter
+ label Label String NULL
+ mappedWhenManaged MappedWhenManaged Boolean True
+ menuName MenuName String "menu"
+ resize Resize Boolean True
+ sensitive Sensitive Boolean True
+ width Width Dimension text width
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XtNmenuName "menuName"
+#define XtCMenuName "MenuName"
+
+extern WidgetClass menuButtonWidgetClass;
+
+typedef struct _MenuButtonClassRec *MenuButtonWidgetClass;
+typedef struct _MenuButtonRec *MenuButtonWidget;
+
+#endif /* _XawMenuButton_h */
diff --git a/nx-X11/lib/Xaw/MultiSink.c b/nx-X11/lib/Xaw/MultiSink.c
new file mode 100644
index 000000000..8abe2dedd
--- /dev/null
+++ b/nx-X11/lib/Xaw/MultiSink.c
@@ -0,0 +1,978 @@
+/* $Xorg: MultiSink.c,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+ * Copyright 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 of 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: Li Yuhong OMRON Corporation
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/MultiSink.c,v 1.19 2001/01/17 19:42:27 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xatom.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/MultiSinkP.h>
+#include <X11/Xaw/MultiSrcP.h>
+#include <X11/Xaw/TextP.h>
+#include "XawI18n.h"
+#include <stdio.h>
+#include <ctype.h>
+#include "Private.h"
+
+#ifdef GETLASTPOS
+#undef GETLASTPOS /* We will use our own GETLASTPOS */
+#endif
+
+#define GETLASTPOS \
+ XawTextSourceScan(source, 0, XawstAll, XawsdRight, 1, True)
+
+/*
+ * Class Methods
+ */
+static void XawMultiSinkClassInitialize(void);
+static void XawMultiSinkInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawMultiSinkDestroy(Widget);
+static void XawMultiSinkResize(Widget);
+static Boolean XawMultiSinkSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+static int MaxLines(Widget, unsigned int);
+static int MaxHeight(Widget, int);
+static void SetTabs(Widget, int, short*);
+static void DisplayText(Widget, int, int,
+ XawTextPosition, XawTextPosition, Bool);
+static void InsertCursor(Widget, int, int, XawTextInsertState);
+static void FindPosition(Widget, XawTextPosition, int, int, Bool,
+ XawTextPosition*, int*, int*);
+static void FindDistance(Widget, XawTextPosition, int, XawTextPosition, int*,
+ XawTextPosition*, int*);
+static void Resolve(Widget, XawTextPosition, int, int, XawTextPosition*);
+static void GetCursorBounds(Widget, XRectangle*);
+
+/*
+ * Prototypes
+ */
+static void GetGC(MultiSinkObject);
+static int CharWidth(MultiSinkObject, XFontSet, int, wchar_t);
+static unsigned int PaintText(Widget w, GC gc, int x, int y,
+ wchar_t *buf, int len, Bool);
+
+/*
+ * Defined in TextSink.c
+ */
+void _XawTextSinkClearToBackground(Widget, int, int, unsigned, unsigned);
+
+/*
+ * Initialization
+ */
+static wchar_t wspace[2];
+
+#define offset(field) XtOffsetOf(MultiSinkRec, multi_sink.field)
+static XtResource resources[] = {
+ {
+ XtNfontSet,
+ XtCFontSet,
+ XtRFontSet,
+ sizeof(XFontSet),
+ offset(fontset),
+ XtRString,
+ XtDefaultFontSet
+ },
+ {
+ XtNecho,
+ XtCOutput,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(echo),
+ XtRImmediate,
+ (XtPointer)True
+ },
+ {
+ XtNdisplayNonprinting,
+ XtCOutput,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(display_nonprinting),
+ XtRImmediate,
+ (XtPointer)True
+ },
+};
+#undef offset
+
+#define SuperClass (&textSinkClassRec)
+MultiSinkClassRec multiSinkClassRec = {
+ /* object */
+ {
+ (WidgetClass)SuperClass, /* superclass */
+ "MultiSink", /* class_name */
+ sizeof(MultiSinkRec), /* widget_size */
+ XawMultiSinkClassInitialize, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ XawMultiSinkInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ NULL, /* obj1 */
+ NULL, /* obj2 */
+ 0, /* obj3 */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ False, /* obj4 */
+ False, /* obj5 */
+ False, /* obj6 */
+ False, /* obj7 */
+ XawMultiSinkDestroy, /* destroy */
+ (XtProc)XawMultiSinkResize, /* obj8 */
+ NULL, /* obj9 */
+ XawMultiSinkSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ NULL, /* obj10 */
+ NULL, /* get_values_hook */
+ NULL, /* obj11 */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* obj12 */
+ NULL, /* obj13 */
+ NULL, /* obj14 */
+ NULL, /* extension */
+ },
+ /* text_sink */
+ {
+ DisplayText, /* DisplayText */
+ InsertCursor, /* InsertCursor */
+ XtInheritClearToBackground, /* ClearToBackground */
+ FindPosition, /* FindPosition */
+ FindDistance, /* FindDistance */
+ Resolve, /* Resolve */
+ MaxLines, /* MaxLines */
+ MaxHeight, /* MaxHeight */
+ SetTabs, /* SetTabs */
+ GetCursorBounds, /* GetCursorBounds */
+ },
+ /* multi_sink */
+ {
+ NULL, /* extension */
+ }
+};
+
+WidgetClass multiSinkObjectClass = (WidgetClass)&multiSinkClassRec;
+
+/*
+ * Implementation
+ */
+static int
+CharWidth(MultiSinkObject sink, XFontSet fontset, int x, wchar_t c)
+{
+ int width = 0;
+
+ if (c == _Xaw_atowc(XawLF))
+ return (0);
+
+ if (c == _Xaw_atowc(XawTAB)) {
+ int i;
+ Position *tab;
+
+ width = x;
+ /* Adjust for Left Margin. */
+ x -= ((TextWidget)XtParent((Widget)sink))->text.left_margin;
+
+ i = 0;
+ tab = sink->text_sink.tabs;
+ /*CONSTCOND*/
+ while (1) {
+ if (x < *tab)
+ return (*tab - x);
+ /* Start again */
+ if (++i >= sink->text_sink.tab_count) {
+ x -= *tab;
+ i = 0;
+ tab = sink->text_sink.tabs;
+ if (width == x)
+ return (0);
+ }
+ else
+ ++tab;
+ }
+ /*NOTREACHED*/
+ }
+
+ if (XwcTextEscapement(fontset, &c, 1) == 0) {
+ if (sink->multi_sink.display_nonprinting)
+ c = _Xaw_atowc('@');
+ else
+ c = _Xaw_atowc(XawSP);
+ }
+
+ /*
+ * if more efficiency(suppose one column is one ASCII char)
+
+ width = XwcGetColumn(fontset->font_charset, fontset->num_of_fonts, c) *
+ fontset->font_struct_list[0]->min_bounds.width;
+ *
+ * WARNING: Very Slower!!!
+ *
+ * Li Yuhong.
+ */
+
+ width = XwcTextEscapement(fontset, &c, 1);
+
+ return (width);
+}
+
+/*
+ * Function:
+ * PaintText
+ *
+ * Parameters:
+ * w - text sink object
+ * gc - gc to paint text
+ * x - location to paint the text
+ * y - ""
+ * buf - buffer and length of text to paint
+ * len - ""
+ * clear_bg - clear background before drawing ?
+ *
+ * Description:
+ * Actually paints the text into the window.
+ *
+ * Returns:
+ * The width of the text painted
+ */
+static unsigned int
+PaintText(Widget w, GC gc, int x, int y, wchar_t *buf, int len, Bool clear_bg)
+{
+ MultiSinkObject sink = (MultiSinkObject)w;
+ TextWidget ctx = (TextWidget)XtParent(w);
+ XFontSet fontset = sink->multi_sink.fontset;
+ unsigned int width = XwcTextEscapement(fontset, buf, len);
+
+ if (((int)width) <= -x) /* Don't draw if we can't see it */
+ return (width);
+
+ if (clear_bg) {
+ XFontSetExtents *ext = XExtentsOfFontSet(fontset);
+
+ _XawTextSinkClearToBackground(w, x, y - abs(ext->max_logical_extent.y),
+ width, ext->max_logical_extent.height);
+ XwcDrawString(XtDisplay(ctx), XtWindow(ctx), fontset, gc, x, y, buf, len);
+ }
+ else
+ XwcDrawImageString(XtDisplay(ctx), XtWindow(ctx), fontset, gc,
+ x, y, buf, len);
+
+ return (width);
+}
+
+/* Sink Object Functions */
+/*
+ * This function does not know about drawing more than one line of text
+ */
+static void
+DisplayText(Widget w, int x, int y,
+ XawTextPosition pos1, XawTextPosition pos2, Bool highlight)
+{
+ TextWidget ctx = (TextWidget)XtParent(w);
+ MultiSinkObject sink = (MultiSinkObject)w;
+ XFontSet fontset = sink->multi_sink.fontset;
+ Widget source = XawTextGetSource(XtParent(w));
+ wchar_t buf[256];
+ XFontSetExtents *ext = XExtentsOfFontSet(fontset);
+ int j, k;
+ XawTextBlock blk;
+ GC gc, invgc, tabgc;
+ int max_x;
+ Bool clear_bg;
+
+ if (!sink->multi_sink.echo || !ctx->text.lt.lines)
+ return;
+
+ max_x = (int)XtWidth(ctx) - ctx->text.r_margin.right;
+ clear_bg = !highlight && ctx->core.background_pixmap != XtUnspecifiedPixmap;
+
+ gc = highlight ? sink->multi_sink.invgc : sink->multi_sink.normgc;
+ invgc = highlight ? sink->multi_sink.normgc : sink->multi_sink.invgc;
+
+ if (highlight && sink->multi_sink.xorgc)
+ tabgc = sink->multi_sink.xorgc;
+ else
+ tabgc = invgc;
+
+ y += abs(ext->max_logical_extent.y);
+ for (j = 0; pos1 < pos2;) {
+ pos1 = XawTextSourceRead(source, pos1, &blk, (int) pos2 - pos1);
+ for (k = 0; k < blk.length; k++) {
+ if ((unsigned) j >= (sizeof(buf) / sizeof(wchar_t)) - 1) {
+ /* buffer full, dump the text */
+ if ((x += PaintText(w, gc, x, y, buf, j, clear_bg)) >= max_x)
+ return;
+ j = 0;
+ }
+ buf[j] = ((wchar_t *)blk.ptr)[k];
+ if (buf[j] == _Xaw_atowc(XawLF))
+ continue;
+
+ else if (buf[j] == _Xaw_atowc(XawTAB)) {
+ unsigned int width;
+
+ if (j != 0 &&
+ (x += PaintText(w, gc, x, y, buf, j, clear_bg)) >= max_x)
+ return;
+
+ width = CharWidth(sink, fontset, x, _Xaw_atowc(XawTAB));
+ if (clear_bg)
+ _XawTextSinkClearToBackground(w,
+ x, y - abs(ext->max_logical_extent.y),
+ width, ext->max_logical_extent.height);
+ else
+ XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
+ tabgc, x,
+ y - abs(ext->max_logical_extent.y),
+ width,
+ ext->max_logical_extent.height);
+ x += width;
+ j = -1;
+ }
+ else if (XwcTextEscapement(sink->multi_sink.fontset, &buf[j], 1)
+ == 0) {
+ if (sink->multi_sink.display_nonprinting)
+ buf[j] = _Xaw_atowc('@');
+ else
+ buf[j] = _Xaw_atowc(XawSP);
+ }
+ j++;
+ }
+ }
+
+ if (j > 0)
+ (void)PaintText(w, gc, x, y, buf, j, clear_bg);
+}
+
+/*
+ * Function:
+ * GetCursorBounds
+ *
+ * Parameters:
+ * w - text sink object
+ * rect - X rectangle to return the cursor bounds
+ *
+ * Description:
+ * Returns the size and location of the cursor.
+ */
+static void
+GetCursorBounds(Widget w, XRectangle *rect)
+{
+ MultiSinkObject sink = (MultiSinkObject)w;
+
+ rect->width = CharWidth(sink, sink->multi_sink.fontset, 0, _Xaw_atowc(XawSP));
+ rect->height = (XExtentsOfFontSet(sink->multi_sink.fontset)
+ ->max_logical_extent.height);
+ rect->x = sink->multi_sink.cursor_x;
+ rect->y = sink->multi_sink.cursor_y - (short)rect->height;
+}
+
+/*
+ * The following procedure manages the "insert" cursor
+ */
+static void
+InsertCursor(Widget w, int x, int y, XawTextInsertState state)
+{
+ MultiSinkObject sink = (MultiSinkObject)w;
+ XFontSet fontset = sink->multi_sink.fontset;
+ Widget ctx = XtParent(w);
+ XawTextPosition position = XawTextGetInsertionPoint(ctx);
+
+ if (XtIsRealized(ctx)) {
+ int fheight, fdiff;
+ XawTextBlock block;
+ wchar_t c;
+ XawTextPosition selection_start, selection_end;
+ Boolean has_selection;
+ XFontSetExtents *ext = XExtentsOfFontSet(fontset);
+
+ XawTextGetSelectionPos((Widget)ctx, &selection_start, &selection_end);
+ has_selection = selection_start != selection_end;
+
+ fheight = ext->max_logical_extent.height;
+ fdiff = fheight - abs(ext->max_logical_extent.y);
+
+ if ((sink->multi_sink.cursor_position != position || state == XawisOff)
+ && !has_selection && sink->multi_sink.laststate != XawisOff) {
+ wchar_t *ochar;
+
+ (void)XawTextSourceRead(XawTextGetSource(ctx),
+ sink->multi_sink.cursor_position,
+ &block, 1);
+ if (!block.length)
+ ochar = NULL;
+ else {
+ c = ((wchar_t *)block.ptr)[0];
+ if (c == _Xaw_atowc(XawLF))
+ ochar = NULL;
+ else if (c == _Xaw_atowc(XawTAB))
+ ochar = wspace;
+ else
+ ochar = (wchar_t *)block.ptr;
+ }
+
+ if (!ochar)
+ _XawTextSinkClearToBackground(w, sink->multi_sink.cursor_x,
+ (sink->multi_sink.cursor_y - 1 -
+ fheight), CharWidth(sink, fontset,
+ 0, wspace[0]),
+ fheight);
+ else {
+ if (XwcTextEscapement(sink->multi_sink.fontset, ochar, 1) != 0)
+ DisplayText(w, sink->multi_sink.cursor_x,
+ sink->multi_sink.cursor_y - 1 - fheight,
+ sink->multi_sink.cursor_position,
+ sink->multi_sink.cursor_position + 1,
+ False);
+ else
+ PaintText(w, sink->multi_sink.normgc,
+ sink->multi_sink.cursor_x,
+ sink->multi_sink.cursor_y - 1 - fdiff,
+ ochar, 1,
+ ctx->core.background_pixmap != XtUnspecifiedPixmap);
+ }
+ }
+
+ if (!has_selection && state != XawisOff) {
+ wchar_t *nchar;
+ Boolean focus = ((TextWidget)ctx)->text.hasfocus;
+
+ (void)XawTextSourceRead(XawTextGetSource(ctx),
+ position, &block, 1);
+ c = ((wchar_t *)block.ptr)[0];
+ if (!block.length || c == _Xaw_atowc(XawLF)
+ || c == _Xaw_atowc(XawTAB))
+ nchar = wspace;
+ else
+ nchar = (wchar_t *)block.ptr;
+
+ if (focus) {
+ if (XwcTextEscapement(sink->multi_sink.fontset, nchar, 1) != 0)
+ XwcDrawImageString(XtDisplay(ctx), XtWindow(ctx),
+ fontset, sink->multi_sink.invgc,
+ x, (y - 1 - fdiff), nchar, 1);
+ else
+ DisplayText(w, x, y - 1 - fheight,
+ position, position + 1, True);
+ }
+ else
+ XDrawRectangle(XtDisplay(ctx), XtWindow(ctx),
+ sink->multi_sink.xorgc ?
+ sink->multi_sink.xorgc : sink->multi_sink.normgc,
+ x, y - 1 - fheight,
+ CharWidth(sink, fontset, 0, *nchar) - 1,
+ fheight - 1);
+ }
+ }
+
+ sink->multi_sink.cursor_x = x;
+ sink->multi_sink.cursor_y = y;
+ sink->multi_sink.laststate = state;
+ sink->multi_sink.cursor_position = position;
+}
+
+/*
+ * Given two positions, find the distance between them
+ */
+static void
+FindDistance(Widget w, XawTextPosition fromPos, int fromx,
+ XawTextPosition toPos, int *resWidth,
+ XawTextPosition *resPos, int *resHeight)
+{
+ MultiSinkObject sink = (MultiSinkObject)w;
+ XFontSet fontset = sink->multi_sink.fontset;
+ TextWidget ctx = (TextWidget)XtParent(w);
+ Widget source = ctx->text.source;
+ XawTextPosition idx, pos;
+ wchar_t c;
+ XFontSetExtents *ext = XExtentsOfFontSet(fontset);
+ XawTextBlock blk;
+ int i, rWidth;
+
+ pos = XawTextSourceRead(source, fromPos, &blk, toPos - fromPos);
+ rWidth = 0;
+ for (i = 0, idx = fromPos; idx < toPos; i++, idx++) {
+ if (i >= blk.length) {
+ i = 0;
+ XawTextSourceRead(source, pos, &blk, toPos - pos);
+ if (blk.length == 0)
+ break;
+ }
+ c = ((wchar_t *)blk.ptr)[i];
+ rWidth += CharWidth(sink, fontset, fromx + rWidth, c);
+ if (c == _Xaw_atowc(XawLF)) {
+ idx++;
+ break;
+ }
+ }
+
+ *resPos = idx;
+ *resWidth = rWidth;
+ *resHeight = ext->max_logical_extent.height;
+}
+
+static void
+FindPosition(Widget w, XawTextPosition fromPos, int fromx, int width,
+ Bool stopAtWordBreak, XawTextPosition *resPos, int *resWidth,
+ int *resHeight)
+{
+ MultiSinkObject sink = (MultiSinkObject)w;
+ TextWidget ctx = (TextWidget)XtParent(w);
+ Widget source = ctx->text.source;
+ XFontSet fontset = sink->multi_sink.fontset;
+ XawTextPosition idx, pos, whiteSpacePosition = 0;
+ int i, lastWidth, whiteSpaceWidth, rWidth;
+ Boolean whiteSpaceSeen;
+ wchar_t c;
+ XFontSetExtents *ext = XExtentsOfFontSet(fontset);
+ XawTextBlock blk;
+
+ pos = XawTextSourceRead(source, fromPos, &blk, BUFSIZ);
+ rWidth = lastWidth = whiteSpaceWidth = 0;
+ whiteSpaceSeen = False;
+ c = 0;
+
+ for (i = 0, idx = fromPos; rWidth <= width; i++, idx++) {
+ if (i >= blk.length) {
+ i = 0;
+ pos = XawTextSourceRead(source, pos, &blk, BUFSIZ);
+ if (blk.length == 0)
+ break;
+ }
+ c = ((wchar_t *)blk.ptr)[i];
+ lastWidth = rWidth;
+ rWidth += CharWidth(sink, fontset, fromx + rWidth, c);
+
+ if (c == _Xaw_atowc(XawLF)) {
+ idx++;
+ break;
+ }
+ else if ((c == _Xaw_atowc(XawSP) || c == _Xaw_atowc(XawTAB))
+ && rWidth <= width) {
+ whiteSpaceSeen = True;
+ whiteSpacePosition = idx;
+ whiteSpaceWidth = rWidth;
+ }
+ }
+
+ if (rWidth > width && idx > fromPos) {
+ idx--;
+ rWidth = lastWidth;
+ if (stopAtWordBreak && whiteSpaceSeen) {
+ idx = whiteSpacePosition + 1;
+ rWidth = whiteSpaceWidth;
+ }
+ }
+
+ if (idx >= ctx->text.lastPos && c != _Xaw_atowc(XawLF))
+ idx = ctx->text.lastPos + 1;
+
+ *resPos = idx;
+ *resWidth = rWidth;
+ *resHeight = ext->max_logical_extent.height;
+}
+
+static void
+Resolve(Widget w, XawTextPosition pos, int fromx, int width,
+ XawTextPosition *pos_return)
+{
+ int resWidth, resHeight;
+ Widget source = XawTextGetSource(XtParent(w));
+
+ FindPosition(w, pos, fromx, width, False, pos_return, &resWidth, &resHeight);
+ if (*pos_return > GETLASTPOS)
+ *pos_return = GETLASTPOS;
+}
+
+static void
+GetGC(MultiSinkObject sink)
+{
+ XtGCMask valuemask = (GCGraphicsExposures | GCClipXOrigin |
+ GCForeground | GCBackground);
+ XGCValues values;
+
+ /* XXX We dont want do share a gc that will change the clip-mask */
+ values.clip_x_origin = (long)sink;
+ values.clip_mask = None;
+ values.graphics_exposures = False;
+
+ values.foreground = sink->text_sink.foreground;
+ values.background = sink->text_sink.background;
+
+ sink->multi_sink.normgc = XtAllocateGC((Widget)sink, 0, valuemask, &values,
+ GCFont | GCClipMask, 0);
+
+ values.foreground = sink->text_sink.background;
+#ifndef OLDXAW
+ values.background = sink->text_sink.cursor_color;
+#else
+ values.background = sink->text_sink.foreground;
+#endif
+ sink->multi_sink.invgc = XtAllocateGC((Widget)sink, 0, valuemask, &values,
+ GCFont | GCClipMask, 0);
+#ifndef OLDXAW
+ if (sink->text_sink.cursor_color != sink->text_sink.foreground) {
+ values.foreground = sink->text_sink.cursor_color;
+ values.background = sink->text_sink.foreground;
+ sink->multi_sink.xorgc = XtAllocateGC((Widget)sink, 0, valuemask,
+ &values, GCFont | GCClipMask, 0);
+ }
+ else
+#endif /* OLDXAW */
+ sink->multi_sink.xorgc = NULL;
+
+ XawMultiSinkResize((Widget)sink);
+}
+
+static void
+XawMultiSinkClassInitialize(void)
+{
+ wspace[0] = _Xaw_atowc(XawSP);
+ XawInitializeWidgetSet();
+}
+
+/*
+ * Function:
+ * XawMultiSinkInitialize
+ *
+ * Parameters:
+ * request - requested and new values for the object instance
+ * cnew - ""
+ *
+ * Description:
+ * Initializes the TextSink Object.
+ */
+/* ARGSUSED */
+static void
+XawMultiSinkInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ MultiSinkObject sink = (MultiSinkObject)cnew;
+
+ GetGC(sink);
+
+ if (!sink->multi_sink.fontset) XtError("Aborting: no fontset found\n");
+
+ sink->multi_sink.cursor_position = 0;
+ sink->multi_sink.laststate = XawisOff;
+ sink->multi_sink.cursor_x = sink->multi_sink.cursor_y = 0;
+}
+
+/*
+ * Function:
+ * XawMultiSinkDestroy
+ *
+ * Parameters:
+ * w - MultiSink Object
+ *
+ * Description:
+ * This function cleans up when the object is destroyed.
+ */
+static void
+XawMultiSinkDestroy(Widget w)
+{
+ MultiSinkObject sink = (MultiSinkObject)w;
+
+ XtReleaseGC(w, sink->multi_sink.normgc);
+ XtReleaseGC(w, sink->multi_sink.invgc);
+ if (sink->multi_sink.xorgc)
+ XtReleaseGC(w, sink->multi_sink.xorgc);
+ sink->multi_sink.normgc =
+ sink->multi_sink.invgc =
+ sink->multi_sink.xorgc = NULL;
+}
+
+static void
+XawMultiSinkResize(Widget w)
+{
+ TextWidget ctx = (TextWidget)XtParent(w);
+ MultiSinkObject sink = (MultiSinkObject)w;
+ XRectangle rect;
+ int width, height;
+
+ if (w->core.widget_class != multiSinkObjectClass)
+ return;
+
+ rect.x = ctx->text.r_margin.left;
+ rect.y = ctx->text.r_margin.top;
+ width = (int)XtWidth(ctx) -
+ (int)ctx->text.r_margin.right - (int)ctx->text.r_margin.left;
+ height = (int)XtHeight(ctx) -
+ (int)ctx->text.r_margin.top - (int)ctx->text.r_margin.bottom;
+ rect.width = width;
+ rect.height = height;
+
+ if (sink->multi_sink.normgc) {
+ if (width >= 0 && height >= 0)
+ XSetClipRectangles(XtDisplay((Widget)ctx), sink->multi_sink.normgc,
+ 0, 0, &rect, 1, Unsorted);
+ else
+ XSetClipMask(XtDisplay((Widget)ctx), sink->multi_sink.normgc, None);
+ }
+ if (sink->multi_sink.invgc) {
+ if (width >= 0 && height >= 0)
+ XSetClipRectangles(XtDisplay((Widget)ctx), sink->multi_sink.invgc,
+ 0, 0, &rect, 1, Unsorted);
+ else
+ XSetClipMask(XtDisplay((Widget)ctx), sink->multi_sink.invgc, None);
+ }
+ if (sink->multi_sink.xorgc) {
+ if (width >= 0 && height >= 0)
+ XSetClipRectangles(XtDisplay((Widget)ctx), sink->multi_sink.xorgc,
+ 0, 0, &rect, 1, Unsorted);
+ else
+ XSetClipMask(XtDisplay((Widget)ctx), sink->multi_sink.xorgc, None);
+ }
+}
+
+/*
+ * Function:
+ * XawMultiSinkSetValues
+ *
+ * Parameters:
+ * current - current state of the object
+ * request - what was requested
+ * cnew - what the object will become
+ *
+ * Description:
+ * Sets the values for the MultiSink.
+ *
+ * Returns:
+ * True if redisplay is needed
+ */
+/*ARGSUSED*/
+static Boolean
+XawMultiSinkSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ MultiSinkObject w = (MultiSinkObject)cnew;
+ MultiSinkObject old_w = (MultiSinkObject)current;
+
+ /* Font set is not in the GC! Do not make a new GC when font set changes! */
+
+ if (w->multi_sink.fontset != old_w->multi_sink.fontset) {
+ ((TextWidget)XtParent(cnew))->text.redisplay_needed = True;
+#ifndef NO_TAB_FIX
+ SetTabs((Widget)w, w->text_sink.tab_count, w->text_sink.char_tabs);
+#endif
+ }
+
+ if (w->text_sink.background != old_w->text_sink.background
+ || w->text_sink.foreground != old_w->text_sink.foreground
+#ifndef OLDXAW
+ || w->text_sink.cursor_color != old_w->text_sink.cursor_color
+#endif
+ ) {
+ XtReleaseGC(cnew, w->multi_sink.normgc);
+ XtReleaseGC(cnew, w->multi_sink.invgc);
+ if (w->multi_sink.xorgc)
+ XtReleaseGC(cnew, w->multi_sink.xorgc);
+ GetGC(w);
+ ((TextWidget)XtParent(cnew))->text.redisplay_needed = True;
+ }
+ else if (w->multi_sink.echo != old_w->multi_sink.echo
+ || w->multi_sink.display_nonprinting
+ != old_w->multi_sink.display_nonprinting)
+ ((TextWidget)XtParent(cnew))->text.redisplay_needed = True;
+
+ return (False);
+}
+
+/*
+ * Function:
+ * MaxLines
+ *
+ * Parameters:
+ * w - MultiSink Object
+ * height - height to fit lines into
+ *
+ * Description:
+ * Finds the Maximum number of lines that will fit in a given height.
+ *
+ * Returns:
+ * The number of lines that will fit
+ */
+/*ARGSUSED*/
+static int
+MaxLines(Widget w, unsigned int height)
+{
+ MultiSinkObject sink = (MultiSinkObject)w;
+ int font_height;
+ XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset);
+
+ font_height = ext->max_logical_extent.height;
+ return (height / font_height);
+}
+
+/*
+ * Function:
+ * MaxHeight
+ *
+ * Parameters:
+ * w - MultiSink Object
+ * lines - number of lines
+ *
+ * Description:
+ * Finds the Minium height that will contain a given number lines.
+ * Returns:
+ * The height
+ */
+/*ARGSUSED*/
+static int
+MaxHeight(Widget w, int lines)
+{
+ MultiSinkObject sink = (MultiSinkObject)w;
+ XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset);
+
+ return (lines * ext->max_logical_extent.height);
+}
+
+/*
+ * Function:
+ * SetTabs
+ *
+ * Arguments:
+ * w - MultiSink Object
+ * tab_count - number of tabs in the list
+ * tabs - text positions of the tabs
+ *
+ * Description:
+ * Sets the Tab stops.
+ */
+static void
+SetTabs(Widget w, int tab_count, short* tabs)
+{
+ MultiSinkObject sink = (MultiSinkObject)w;
+ int i;
+ Atom XA_FIGURE_WIDTH;
+ unsigned long figure_width = 0;
+ XFontStruct *font;
+
+ /*
+ * Bug:
+ * Suppose the first font of fontset stores the unit of column.
+ *
+ * By Li Yuhong, Mar. 14, 1991
+ */
+ {
+ XFontStruct **f_list;
+ char **f_name;
+
+ (void)XFontsOfFontSet(sink->multi_sink.fontset, &f_list, &f_name);
+ font = f_list[0];
+ }
+
+ /*
+ * Find the figure width of the current font
+ */
+ XA_FIGURE_WIDTH = XInternAtom(XtDisplayOfObject(w), "FIGURE_WIDTH", False);
+ if (XA_FIGURE_WIDTH != None
+ && (!XGetFontProperty(font, XA_FIGURE_WIDTH, &figure_width)
+ || figure_width == 0)) {
+ if (font->per_char && font->min_char_or_byte2 <= '$'
+ && font->max_char_or_byte2 >= '$')
+ figure_width = font->per_char['$' - font->min_char_or_byte2].width;
+ else
+ figure_width = font->max_bounds.width;
+ }
+
+ if (tab_count > sink->text_sink.tab_count) {
+ sink->text_sink.tabs = (Position *)
+ XtRealloc((char *)sink->text_sink.tabs,
+ (Cardinal)(tab_count * sizeof(Position)));
+ sink->text_sink.char_tabs = (short *)
+ XtRealloc((char *)sink->text_sink.char_tabs,
+ (Cardinal)(tab_count * sizeof(short)));
+ }
+
+ for (i = 0 ; i < tab_count ; i++) {
+ sink->text_sink.tabs[i] = tabs[i] * figure_width;
+ sink->text_sink.char_tabs[i] = tabs[i];
+ }
+
+ sink->text_sink.tab_count = tab_count;
+
+#ifndef NO_TAB_FIX
+ ((TextWidget)XtParent(w))->text.redisplay_needed = True;
+#endif
+}
+
+void
+_XawMultiSinkPosToXY(Widget w, XawTextPosition pos, Position *x, Position *y)
+{
+ MultiSinkObject sink = (MultiSinkObject)((TextWidget)w)->text.sink;
+ XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset);
+
+ _XawTextPosToXY(w, pos, x, y);
+ *y += abs(ext->max_logical_extent.y);
+}
diff --git a/nx-X11/lib/Xaw/MultiSink.h b/nx-X11/lib/Xaw/MultiSink.h
new file mode 100644
index 000000000..49ef1df2e
--- /dev/null
+++ b/nx-X11/lib/Xaw/MultiSink.h
@@ -0,0 +1,113 @@
+/* $Xorg: MultiSink.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+ * Copyright 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 is 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: Li Yuhong OMRON Corporation
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/MultiSink.h,v 1.5 2001/01/17 19:42:27 dawes Exp $ */
+
+#ifndef _XawMultiSink_h
+#define _XawMultiSink_h
+
+/*
+ * MultiSink Object
+ */
+
+#include <X11/Xaw/TextSink.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ echo Output Boolean True
+ displayNonprinting Output Boolean True
+ fontSet FontSet XFontSet XtDefaultFontSet
+
+*/
+
+#define XtCOutput "Output"
+
+#define XtNdisplayNonprinting "displayNonprinting"
+#define XtNecho "echo"
+
+#ifndef XtNfontSet /*Sheeran, Omron KK, 93/03/04*/
+#define XtNfontSet "fontSet"
+#endif
+
+#ifndef XtCFontSet /*Sheeran, Omron KK, 93/03/04*/
+#define XtCFontSet "FontSet"
+#endif
+
+/* Class record constants */
+extern WidgetClass multiSinkObjectClass;
+
+typedef struct _MultiSinkClassRec *MultiSinkObjectClass;
+typedef struct _MultiSinkRec *MultiSinkObject;
+
+#endif /* _XawMultiSink_h */
diff --git a/nx-X11/lib/Xaw/MultiSinkP.h b/nx-X11/lib/Xaw/MultiSinkP.h
new file mode 100644
index 000000000..537e0b12a
--- /dev/null
+++ b/nx-X11/lib/Xaw/MultiSinkP.h
@@ -0,0 +1,141 @@
+/* $Xorg: MultiSinkP.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+ * Copyright 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 make 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: Li Yuhong OMRON Corporation
+ */
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/MultiSinkP.h,v 1.8 2001/01/17 19:42:28 dawes Exp $ */
+
+#ifndef _XawMultiSinkP_h
+#define _XawMultiSinkP_h
+
+#include <X11/Xfuncproto.h>
+
+/*
+ * MultiSink Object Private Data
+ */
+#include <X11/Xaw/TextSinkP.h>
+#include <X11/Xaw/MultiSink.h>
+
+/* new fields for the MultiSink object class */
+typedef struct _MultiSinkClassPart {
+ XtPointer extension;
+} MultiSinkClassPart;
+
+/* Full class record declaration */
+typedef struct _MultiSinkClassRec {
+ ObjectClassPart object_class;
+ TextSinkClassPart text_sink_class;
+ MultiSinkClassPart multi_sink_class;
+} MultiSinkClassRec;
+
+extern MultiSinkClassRec multiSinkClassRec;
+
+/* New fields for the MultiSink object record */
+typedef struct {
+ /* resources */
+ Boolean echo;
+ Boolean display_nonprinting;
+
+ /* private */
+ GC normgc, invgc, xorgc;
+ XawTextPosition cursor_position;
+ XawTextInsertState laststate;
+ short cursor_x, cursor_y; /* Cursor Location */
+ XFontSet fontset; /* font set to draw */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} MultiSinkPart;
+
+/* Full instance record declaration */
+typedef struct _MultiSinkRec {
+ ObjectPart object;
+ TextSinkPart text_sink;
+ MultiSinkPart multi_sink;
+} MultiSinkRec;
+
+/*
+ * Semi-private functions
+ * for use by other Xaw modules only
+ */
+_XFUNCPROTOBEGIN
+
+void _XawMultiSinkPosToXY
+(
+ Widget w,
+ XawTextPosition pos,
+ Position *x,
+ Position *y
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawMultiSinkP_h */
diff --git a/nx-X11/lib/Xaw/MultiSrc.c b/nx-X11/lib/Xaw/MultiSrc.c
new file mode 100644
index 000000000..2daf0f6e8
--- /dev/null
+++ b/nx-X11/lib/Xaw/MultiSrc.c
@@ -0,0 +1,1620 @@
+/* $Xorg: MultiSrc.c,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+ * Copyright 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.
+ *
+ * Authors: Chris Peterson MIT X Consortium
+ * Li Yuhong OMRON Corporation
+ * Frank Sheeran OMRON Corporation
+ *
+ * Much code taken from X11R3 String and Disk Sources.
+ */
+/* $XFree86: xc/lib/Xaw/MultiSrc.c,v 1.28 2002/11/21 16:22:52 paulo Exp $ */
+
+/*
+
+Copyright 1991, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <errno.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xos.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/MultiSrcP.h>
+#include <X11/Xaw/XawImP.h>
+#include "XawI18n.h"
+#include "Private.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#define MAGIC_VALUE ((XawTextPosition)-1)
+#define streq(a, b) (strcmp((a), (b)) == 0)
+
+#ifdef X_NOT_POSIX
+#define Off_t long
+#define Size_t unsigned int
+#else
+#define Off_t off_t
+#define Size_t size_t
+#endif
+
+
+/*
+ * Class Methods
+ */
+static XawTextPosition ReadText(Widget, XawTextPosition, XawTextBlock*, int);
+static int ReplaceText(Widget, XawTextPosition, XawTextPosition,
+ XawTextBlock*);
+static XawTextPosition Scan(Widget, XawTextPosition, XawTextScanType,
+ XawTextScanDirection, int, Bool);
+static XawTextPosition Search(Widget, XawTextPosition, XawTextScanDirection,
+ XawTextBlock*);
+static void XawMultiSrcClassInitialize(void);
+static void XawMultiSrcDestroy(Widget);
+static void XawMultiSrcInitialize(Widget, Widget, ArgList, Cardinal*);
+static Boolean XawMultiSrcSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+static void XawMultiSrcGetValuesHook(Widget, ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static MultiPiece *AllocNewPiece(MultiSrcObject, MultiPiece*);
+static void BreakPiece(MultiSrcObject, MultiPiece*);
+static Boolean CvtMultiTypeToString(Display*, XrmValuePtr, Cardinal*,
+ XrmValuePtr, XrmValuePtr, XtPointer*);
+static void CvtStringToMultiType(XrmValuePtr, Cardinal*,
+ XrmValuePtr, XrmValuePtr);
+static MultiPiece *FindPiece(MultiSrcObject, XawTextPosition,
+ XawTextPosition*);
+static void FreeAllPieces(MultiSrcObject);
+static FILE *InitStringOrFile(MultiSrcObject, Bool);
+static void LoadPieces(MultiSrcObject, FILE*, char*);
+static void RemovePiece(MultiSrcObject, MultiPiece*);
+static void RemoveOldStringOrFile(MultiSrcObject, Bool);
+static String StorePiecesInString(MultiSrcObject);
+static Bool WriteToFile(String, String);
+static void GetDefaultPieceSize(Widget, int, XrmValue*);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(MultiSrcRec, multi_src.field)
+static XtResource resources[] = {
+ {
+ XtNstring,
+ XtCString,
+ XtRString,
+ sizeof(XtPointer),
+ offset(string),
+ XtRPointer,
+ NULL
+ },
+ {
+ XtNtype,
+ XtCType,
+ XtRMultiType,
+ sizeof(XawAsciiType),
+ offset(type),
+ XtRImmediate,
+ (XtPointer)XawAsciiString
+ },
+ {
+ XtNdataCompression,
+ XtCDataCompression,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(data_compression),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNpieceSize,
+ XtCPieceSize,
+ XtRInt,
+ sizeof(XawTextPosition),
+ offset(piece_size),
+ XtRCallProc,
+ (XtPointer)GetDefaultPieceSize
+ },
+#ifdef OLDXAW
+ {
+ XtNcallback,
+ XtCCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(callback),
+ XtRCallback,
+ (XtPointer)NULL
+ },
+#endif
+ {
+ XtNuseStringInPlace,
+ XtCUseStringInPlace,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(use_string_in_place),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNlength,
+ XtCLength,
+ XtRInt,
+ sizeof(int),
+ offset(multi_length),
+ XtRImmediate,
+ (XtPointer)MAGIC_VALUE
+ },
+};
+#undef offset
+
+#define superclass (&textSrcClassRec)
+MultiSrcClassRec multiSrcClassRec = {
+ /* object */
+ {
+ (WidgetClass)superclass, /* superclass */
+ "MultiSrc", /* class_name */
+ sizeof(MultiSrcRec), /* widget_size */
+ XawMultiSrcClassInitialize, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ XawMultiSrcInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ NULL, /* obj1 */
+ NULL, /* obj2 */
+ 0, /* obj3 */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ False, /* obj4 */
+ False, /* obj5 */
+ False, /* obj6 */
+ False, /* obj7 */
+ XawMultiSrcDestroy, /* destroy */
+ NULL, /* obj8 */
+ NULL, /* obj9 */
+ XawMultiSrcSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ NULL, /* obj10 */
+ XawMultiSrcGetValuesHook, /* get_values_hook */
+ NULL, /* obj11 */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* obj12 */
+ NULL, /* obj13 */
+ NULL, /* obj14 */
+ NULL, /* extension */
+ },
+ /* text_src */
+ {
+ ReadText, /* Read */
+ ReplaceText, /* Replace */
+ Scan, /* Scan */
+ Search, /* Search */
+ XtInheritSetSelection, /* SetSelection */
+ XtInheritConvertSelection, /* ConvertSelection */
+ },
+ /* multi_src */
+ {
+ NULL, /* extension */
+ },
+};
+
+WidgetClass multiSrcObjectClass = (WidgetClass)&multiSrcClassRec;
+
+static XrmQuark Qstring, Qfile;
+
+/*
+ * Implementation
+ */
+static void
+XawMultiSrcClassInitialize(void)
+{
+ XawInitializeWidgetSet();
+ Qstring = XrmPermStringToQuark(XtEstring);
+ Qfile = XrmPermStringToQuark(XtEfile);
+ XtAddConverter(XtRString, XtRMultiType, CvtStringToMultiType, NULL, 0);
+ XtSetTypeConverter(XtRMultiType, XtRString, CvtMultiTypeToString, NULL, 0,
+ XtCacheNone, NULL);
+}
+
+/*
+ * Function:
+ * XawMultiSrcInitialize
+ *
+ * Parameters:
+ * request - widget requested by the argument list
+ * cnew - the new widget with both resource and non resource values
+ * args - (unused)
+ * num_args - (unused)
+ *
+ * Description:
+ * Initializes the multi src object
+ */
+/*ARGSUSED*/
+static void
+XawMultiSrcInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ MultiSrcObject src = (MultiSrcObject)cnew;
+ FILE *file;
+
+ /*
+ * Set correct flags (override resources) depending upon widget class
+ */
+#ifdef OLDXAW
+ src->multi_src.changes = False;
+#else
+ src->text_src.changed = False;
+#endif
+ src->multi_src.allocated_string = False;
+
+ if (src->multi_src.use_string_in_place && src->multi_src.string == NULL)
+ src->multi_src.use_string_in_place = False;
+
+ file = InitStringOrFile(src, src->multi_src.type == XawAsciiFile);
+ LoadPieces(src, file, NULL);
+
+ if (file != NULL)
+ fclose(file);
+ src->text_src.text_format = XawFmtWide;
+}
+
+/*
+ * Function:
+ * ReadText
+ *
+ * Parameters:
+ * w - MultiSource object
+ * pos - position of the text to retrieve
+ * text - text block that will contain returned text
+ * length - maximum number of characters to read
+ *
+ * Description:
+ * This function reads the source.
+ *
+ * Returns:
+ * The character position following the retrieved text.
+ */
+static XawTextPosition
+ReadText(Widget w, XawTextPosition pos, XawTextBlock *text, int length)
+{
+ MultiSrcObject src = (MultiSrcObject)w;
+ XawTextPosition count, start;
+ MultiPiece *piece = FindPiece(src, pos, &start);
+
+ text->format = XawFmtWide;
+ text->firstPos = pos;
+ text->ptr = (char *)(piece->text + (pos - start));
+ count = piece->used - (pos - start);
+ text->length = Max(0, (length > count) ? count : length);
+
+ return (pos + text->length);
+}
+
+/*
+ * Function:
+ * ReplaceText
+ *
+ * Parameters:
+ * w - MultiSource object
+ * startPos - ends of text that will be removed
+ * endPos - ""
+ * text - new text to be inserted into buffer at startPos
+ *
+ * Description:
+ * Replaces a block of text with new text.
+ *
+ * Returns:
+ * XawEditDone on success, XawEditError otherwise
+ */
+/*ARGSUSED*/
+static int
+ReplaceText(Widget w, XawTextPosition startPos, XawTextPosition endPos,
+ XawTextBlock *u_text_p)
+{
+ MultiSrcObject src = (MultiSrcObject)w;
+ MultiPiece *start_piece, *end_piece, *temp_piece;
+ XawTextPosition start_first, end_first;
+ int length, firstPos;
+ wchar_t *wptr;
+ Bool local_artificial_block = False;
+ XawTextBlock text;
+
+ /* STEP 1: The user handed me a text block called `u_text' that may be
+ * in either FMTWIDE or FMT8BIT (ie MB.) Later code needs the block
+ * `text' to hold FMTWIDE. So, this copies `u_text' to `text', and if
+ * `u_text' was MB, I knock it up to WIDE
+ */
+ if (u_text_p->length == 0) /* if so, the block contents never ref'd */
+ text.length = 0;
+
+ else if (u_text_p->format == XawFmtWide) {
+ local_artificial_block = False; /* don't have to free it ourselves */
+ text.firstPos = u_text_p->firstPos;
+ text.length = u_text_p->length;
+ text.ptr = u_text_p->ptr;
+ }
+ else {
+ /*
+ * WARNING! u_text->firstPos and length are in units of CHAR,
+ * not CHARACTERS!
+ */
+ local_artificial_block = True; /* have to free it ourselves */
+ text.firstPos = 0;
+ text.length = u_text_p->length; /* _XawTextMBToWC converts this
+ * to wchar len
+ */
+
+ text.ptr = (char*)_XawTextMBToWC(XtDisplay(XtParent(w)),
+ &u_text_p->ptr[u_text_p->firstPos],
+ &text.length);
+
+ /* I assert the following assignment is not needed - since Step 4
+ depends on length, it has no need of a terminating NULL. I think
+ the ASCII-version has the same needless NULL. */
+ /*((wchar_t*)text.ptr)[ text.length ] = NULL;*/
+ }
+
+ /* STEP 2: some initialization... */
+ if (src->text_src.edit_mode == XawtextRead)
+ return (XawEditError);
+
+ start_piece = FindPiece(src, startPos, &start_first);
+ end_piece = FindPiece(src, endPos, &end_first);
+
+ /* STEP 3: remove the empty pieces... */
+ if (start_piece != end_piece) {
+ temp_piece = start_piece->next;
+
+ /* If empty and not the only piece then remove it */
+ if (((start_piece->used = startPos - start_first) == 0)
+ && !(start_piece->next == NULL && start_piece->prev == NULL))
+ RemovePiece(src, start_piece);
+
+ while (temp_piece != end_piece) {
+ temp_piece = temp_piece->next;
+ RemovePiece(src, temp_piece->prev);
+ }
+ end_piece->used -= endPos - end_first;
+ if (end_piece->used != 0)
+ memmove(end_piece->text, end_piece->text + endPos - end_first,
+ end_piece->used * sizeof(wchar_t));
+ }
+ else { /* We are fully in one piece */
+ if ((start_piece->used -= endPos - startPos) == 0) {
+ if (!(start_piece->next == NULL && start_piece->prev == NULL))
+ RemovePiece(src, start_piece);
+ }
+ else {
+ memmove(start_piece->text + (startPos - start_first),
+ start_piece->text + (endPos - start_first),
+ (start_piece->used - (startPos - start_first)) *
+ sizeof(wchar_t));
+ if (src->multi_src.use_string_in_place &&
+ ((src->multi_src.length - (endPos - startPos))
+ < src->multi_src.piece_size - 1))
+ start_piece->text[src->multi_src.length - (endPos - startPos)] =
+ (wchar_t)0;
+ }
+ }
+
+ src->multi_src.length += text.length -(endPos - startPos);
+
+ /* STEP 4: insert the new stuff */
+ if ( text.length != 0) {
+ start_piece = FindPiece(src, startPos, &start_first);
+ length = text.length;
+ firstPos = text.firstPos;
+
+ while (length > 0) {
+ wchar_t *ptr;
+ int fill;
+
+ if (src->multi_src.use_string_in_place) {
+ if (start_piece->used == src->multi_src.piece_size - 1) {
+
+ /*
+ * The string is used in place, then the string
+ * is not allowed to grow
+ */
+ start_piece->used = src->multi_src.length =
+ src->multi_src.piece_size - 1;
+
+ start_piece->text[src->multi_src.length] = (wchar_t)0;
+ return (XawEditError);
+ }
+ }
+
+ if (start_piece->used == src->multi_src.piece_size) {
+ BreakPiece(src, start_piece);
+ start_piece = FindPiece(src, startPos, &start_first);
+ }
+
+ fill = Min((int)(src->multi_src.piece_size - start_piece->used), length);
+
+ ptr = start_piece->text + (startPos - start_first);
+ memmove(ptr + fill, ptr, (start_piece->used -
+ (startPos - start_first)) * sizeof(wchar_t));
+ wptr =(wchar_t *)text.ptr;
+ (void)wcsncpy(ptr, wptr + firstPos, fill);
+
+ startPos += fill;
+ firstPos += fill;
+ start_piece->used += fill;
+ length -= fill;
+ }
+ }
+
+ if (local_artificial_block == True)
+ /* In other words, text is not the u_text that the user handed me but
+ one I made myself. I only care, because I need to free the string */
+ XtFree(text.ptr);
+
+ if (src->multi_src.use_string_in_place)
+ start_piece->text[start_piece->used] = (wchar_t)0;
+
+#ifdef OLDXAW
+ src->multi_src.changes = True;
+ XtCallCallbacks(w, XtNcallback, NULL);
+#endif
+
+ return (XawEditDone);
+}
+
+/*
+ * Function:
+ * Scan
+ *
+ * Parameters:
+ * w - MultiSource widget
+ * position - position to start scanning
+ * type - type of thing to scan for
+ * dir - direction to scan
+ * count - which occurance if this thing to search for
+ * include - whether or not to include the character found in
+ * the position that is returned
+ *
+ * Description:
+ * Scans the text source for the number and type of item specified.
+ *
+ * Returns:
+ * The position of the item found
+ *
+ * Note:
+ * While there are only 'n' characters in the file there are n+1
+ * possible cursor positions (one before the first character and
+ * one after the last character
+ */
+static XawTextPosition
+Scan(Widget w, register XawTextPosition position, XawTextScanType type,
+ XawTextScanDirection dir, int count, Bool include)
+{
+ MultiSrcObject src = (MultiSrcObject)w;
+ register char inc;
+ MultiPiece *piece;
+ XawTextPosition first, first_eol_position = position;
+ register wchar_t *ptr;
+ int cnt = count;
+
+ if (type == XawstAll) {
+ if (dir == XawsdRight)
+ return (src->multi_src.length);
+ return (0);
+ }
+
+ /* STEP 1: basic sanity checks */
+ if (position > src->multi_src.length)
+ position = src->multi_src.length;
+
+ if (dir == XawsdRight) {
+ if (position == src->multi_src.length)
+ return (src->multi_src.length);
+ inc = 1;
+ }
+ else {
+ if (position == 0)
+ return (0);
+ inc = -1;
+ position--;
+ }
+
+ piece = FindPiece(src, position, &first);
+
+ if (piece->used == 0)
+ return (0);
+
+ ptr = (position - first) + piece->text;
+
+ switch (type) {
+ case XawstEOL:
+ case XawstParagraph:
+ case XawstWhiteSpace:
+ case XawstAlphaNumeric:
+ for (; cnt > 0 ; cnt--) {
+ Bool non_space = False, first_eol = True;
+
+ /*CONSTCOND*/
+ while (True) {
+ register wchar_t c;
+
+ if (ptr < piece->text) {
+ piece = piece->prev;
+ if (piece == NULL) /* Begining of text */
+ return (0);
+ ptr = piece->text + piece->used - 1;
+ c = *ptr;
+ }
+ else if (ptr >= piece->text + piece->used) {
+ piece = piece->next;
+ if (piece == NULL) /* End of text */
+ return (src->multi_src.length);
+ ptr = piece->text;
+ }
+
+ c = *ptr;
+ ptr += inc;
+ position += inc;
+
+ if (type == XawstAlphaNumeric) {
+ if (!iswalnum(c)) {
+ if (non_space)
+ break;
+ }
+ else
+ non_space = True;
+ }
+ else if (type == XawstWhiteSpace) {
+ if (iswspace(c)) {
+ if (non_space)
+ break;
+ }
+ else
+ non_space = True;
+ }
+ else if (type == XawstEOL) {
+ if (c == _Xaw_atowc(XawLF))
+ break;
+ }
+ else { /* XawstParagraph */
+ if (first_eol) {
+ if (c == _Xaw_atowc(XawLF)) {
+ first_eol_position = position;
+ first_eol = False;
+ }
+ }
+ else
+ if (c == _Xaw_atowc(XawLF))
+ break;
+ else if (!iswspace(c))
+ first_eol = True;
+ }
+ }
+ }
+ if (!include) {
+ if (type == XawstParagraph)
+ position = first_eol_position;
+ if (count)
+ position -= inc;
+ }
+ break;
+ case XawstPositions:
+ position += count * inc;
+ break;
+ default:
+ break;
+ }
+
+ if (dir == XawsdLeft)
+ position++;
+
+ if (position >= src->multi_src.length)
+ return (src->multi_src.length);
+ if (position < 0)
+ return (0);
+
+ return (position);
+}
+
+/*
+ * Function:
+ * Search
+ *
+ * Parameters:
+ * w - MultiSource objecy
+ * position - position to start scanning
+ * dir - direction to scan
+ * text - text block to search for
+ *
+ * Description:
+ * Searchs the text source for the text block passed.
+ *
+ * Returns:
+ * The position of the item found
+ */
+static XawTextPosition
+Search(Widget w, register XawTextPosition position, XawTextScanDirection dir,
+ XawTextBlock *text)
+{
+ MultiSrcObject src = (MultiSrcObject)w;
+ register int count = 0;
+ wchar_t *ptr;
+ wchar_t *wtarget;
+ int wtarget_len;
+ Display *d = XtDisplay(XtParent(w));
+ MultiPiece *piece;
+ wchar_t *buf;
+ XawTextPosition first;
+ register char inc;
+ int cnt;
+
+ /* STEP 1: First, a brief sanity check */
+ if (dir == XawsdRight)
+ inc = 1;
+ else {
+ inc = -1;
+ if (position == 0)
+ return (XawTextSearchError);
+ position--;
+ }
+
+ /* STEP 2: Ensure I have a local wide string.. */
+
+ /* Since this widget stores 32bit chars, I check here to see if
+ I'm being passed a string claiming to be 8bit chars (ie, MB text.)
+ If that is the case, naturally I convert to 32bit format */
+
+ /*if the block was FMT8BIT, length will convert to REAL wchar count bellow */
+ wtarget_len = text->length;
+
+ if (text->format == XawFmtWide)
+ wtarget = &(((wchar_t*)text->ptr) [text->firstPos]);
+ else {
+ /* The following converts wtarget_len from byte len to wchar count */
+ wtarget = _XawTextMBToWC(d, &text->ptr[text->firstPos], &wtarget_len);
+ }
+
+ /* OK, I can now assert that wtarget holds wide characters, wtarget_len
+ holds an accurate count of those characters, and that firstPos has been
+ effectively factored out of the following computations */
+
+ /* STEP 3: SEARCH! */
+ buf = (wchar_t *)XtMalloc(sizeof(wchar_t) * wtarget_len);
+ (void)wcsncpy(buf, wtarget, wtarget_len);
+ piece = FindPiece(src, position, &first);
+ ptr = (position - first) + piece->text;
+
+ /*CONSTCOND*/
+ while (True) {
+ if (*ptr == (dir == XawsdRight ? *(buf + count)
+ : *(buf + wtarget_len - count - 1))) {
+ if (count == text->length - 1)
+ break;
+ else
+ count++;
+ }
+ else {
+ if (count != 0) {
+ position -=inc * count;
+ ptr -= inc * count;
+ }
+ count = 0;
+ }
+
+ ptr += inc;
+ position += inc;
+
+ while (ptr < piece->text) {
+ cnt = piece->text - ptr;
+
+ piece = piece->prev;
+ if (piece == NULL) { /* Begining of text */
+ XtFree((char *)buf);
+ return (XawTextSearchError);
+ }
+ ptr = piece->text + piece->used - cnt;
+ }
+
+ while (ptr >= piece->text + piece->used) {
+ cnt = ptr - (piece->text + piece->used);
+
+ piece = piece->next;
+ if (piece == NULL) { /* End of text */
+ XtFree((char *)buf);
+ return (XawTextSearchError);
+ }
+ ptr = piece->text + cnt;
+ }
+ }
+
+ XtFree((char *)buf);
+ if (dir == XawsdLeft)
+ return(position);
+
+ return(position - (wtarget_len - 1));
+}
+
+/*
+ * Function:
+ * XawMultiSrcSetValues
+ *
+ * Parameters:
+ * current - current state of the widget
+ * request - what was requested
+ * cnew - what the widget will become
+ * args - representation of resources that have changed
+ * num_args - number of changed resources
+ *
+ * Description:
+ * Sets the values for the MultiSource.
+ *
+ * Returns:
+ * True if redisplay is needed
+ */
+static Boolean
+XawMultiSrcSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ MultiSrcObject src = (MultiSrcObject)cnew;
+ MultiSrcObject old_src = (MultiSrcObject)current;
+ XtAppContext app_con = XtWidgetToApplicationContext(cnew);
+ Bool total_reset = False, string_set = False;
+ FILE *file;
+ unsigned int i;
+
+ if (old_src->multi_src.use_string_in_place
+ != src->multi_src.use_string_in_place) {
+ XtAppWarning(app_con,
+ "MultiSrc: The XtNuseStringInPlace resources "
+ "may not be changed.");
+ src->multi_src.use_string_in_place =
+ old_src->multi_src.use_string_in_place;
+ }
+
+ for (i = 0; i < *num_args ; i++)
+ if (streq(args[i].name, XtNstring)) {
+ string_set = True;
+ break;
+ }
+
+ if (string_set || old_src->multi_src.type != src->multi_src.type) {
+ RemoveOldStringOrFile(old_src, string_set);
+ src->multi_src.allocated_string = old_src->multi_src.allocated_string;
+ file = InitStringOrFile(src, string_set);
+
+ LoadPieces(src, file, NULL);
+ if (file != NULL)
+ fclose(file);
+#ifndef OLDXAW
+ for (i = 0; i < src->text_src.num_text; i++)
+ /* Tell text widget what happened */
+ XawTextSetSource(src->text_src.text[i], cnew, 0);
+#else
+ XawTextSetSource(XtParent(cnew), cnew, 0);
+#endif
+ total_reset = True;
+ }
+
+ if (old_src->multi_src.multi_length != src->multi_src.multi_length)
+ src->multi_src.piece_size = src->multi_src.multi_length + 1;
+
+ if ( !total_reset && old_src->multi_src.piece_size
+ != src->multi_src.piece_size) {
+ String mb_string = StorePiecesInString(old_src);
+
+ if (mb_string != 0) {
+ FreeAllPieces(old_src);
+ LoadPieces(src, NULL, mb_string);
+ XtFree(mb_string);
+ }
+ else {
+ /* If the buffer holds bad chars, don't touch it... */
+ XtAppWarningMsg(app_con,
+ "convertError", "multiSource", "XawError",
+ XtName(XtParent((Widget)old_src)), NULL, NULL);
+ XtAppWarningMsg(app_con,
+ "convertError", "multiSource", "XawError",
+ "Non-character code(s) in buffer.", NULL, NULL);
+ }
+ }
+
+ return (False);
+}
+
+static void
+XawMultiSrcGetValuesHook(Widget w, ArgList args, Cardinal *num_args)
+{
+ MultiSrcObject src = (MultiSrcObject)w;
+ unsigned int i;
+
+ if (src->multi_src.type == XawAsciiString) {
+ for (i = 0; i < *num_args ; i++) {
+ if (streq(args[i].name, XtNstring)) {
+ if (src->multi_src.use_string_in_place)
+ *((char **)args[i].value) = (char *)
+ src->multi_src.first_piece->text;
+ else if (_XawMultiSave(w)) /* If save sucessful */
+ *((char **)args[i].value) = (char *)src->multi_src.string;
+ break;
+ }
+ }
+ }
+}
+
+static void
+XawMultiSrcDestroy(Widget w)
+{
+ RemoveOldStringOrFile((MultiSrcObject) w, True);
+}
+
+/*
+ * Public routines
+ */
+/*
+ * Function:
+ * XawMultiSourceFreeString
+ *
+ * Parameters:
+ * w - MultiSrc widget
+ *
+ * Description:
+ * Frees the string returned by a get values call
+ * on the string when the source is of type string.
+ *
+ * Note:
+ * The public interface is XawAsciiSourceFreeString!
+ */
+void
+_XawMultiSourceFreeString(Widget w)
+{
+ MultiSrcObject src = (MultiSrcObject)w;
+
+ if (src->multi_src.allocated_string) {
+ XtFree((char *)src->multi_src.string);
+ src->multi_src.allocated_string = False;
+ src->multi_src.string = NULL;
+ }
+}
+
+/*
+ * Function:
+ * _XawMultiSave
+ *
+ * Parameters:
+ * w - multiSrc Widget
+ *
+ * Description:
+ * Saves all the pieces into a file or string as required.
+ *
+ * Returns:
+ * True if the save was successful
+ *
+ * Note:
+ * The public interface is XawAsciiSave(w)!
+ */
+Bool
+_XawMultiSave(Widget w)
+{
+ MultiSrcObject src = (MultiSrcObject)w;
+ XtAppContext app_con = XtWidgetToApplicationContext(w);
+ char *mb_string;
+
+ /*
+ * If using the string in place then there is no need to play games
+ * to get the internal info into a readable string
+ */
+ if (src->multi_src.use_string_in_place)
+ return (True);
+
+ if (src->multi_src.type == XawAsciiFile) {
+#ifdef OLDXAW
+ if (!src->multi_src.changes)
+#else
+ if (!src->text_src.changed) /* No changes to save */
+#endif
+ return (True);
+
+ mb_string = StorePiecesInString(src);
+
+ if (mb_string != 0) {
+ if (WriteToFile(mb_string, (String)src->multi_src.string) == False) {
+ XtFree(mb_string);
+ return (False);
+ }
+ XtFree(mb_string);
+#ifndef OLDXAW
+ src->text_src.changed = False;
+#else
+ src->multi_src.changes = False;
+#endif
+ return (True);
+ }
+ else {
+ /* If the buffer holds bad chars, don't touch it... */
+ XtAppWarningMsg(app_con,
+ "convertError", "multiSource", "XawError",
+ "Due to illegal characters, file not saved.",
+ NULL, NULL);
+ return (False);
+ }
+ }
+ else {
+ /* THIS FUNCTIONALITY IS UNDOCUMENTED, probably UNNEEDED? The manual
+ says this routine's only function is to save files to
+ disk. -Sheeran */
+ mb_string = StorePiecesInString(src);
+
+ if (mb_string == 0) {
+ /* If the buffer holds bad chars, don't touch it... */
+ XtAppWarningMsg(app_con,
+ "convertError", "multiSource", "XawError",
+ XtName(XtParent((Widget)src)), NULL, NULL);
+ return (False);
+ }
+
+ /* assert: mb_string holds good characters so the buffer is fine */
+ if (src->multi_src.allocated_string == True)
+ XtFree((char *)src->multi_src.string);
+ else
+ src->multi_src.allocated_string = True;
+
+ src->multi_src.string = mb_string;
+ }
+#ifdef OLDXAW
+ src->multi_src.changes = False;
+#else
+ src->text_src.changed = False;
+#endif
+
+ return (True);
+}
+
+/*
+ * Function:
+ * XawMultiSaveAsFile
+ *
+ * Parameters:
+ * w - MultiSrc widget
+ * name - name of the file to save this file into
+ *
+ * Description:
+ * Save the current buffer as a file.
+ *
+ * Returns:
+ * True if the save was sucessful
+ *
+ * Note:
+ * The public interface is XawAsciiSaveAsFile!
+ */
+Bool
+_XawMultiSaveAsFile(Widget w, _Xconst char* name)
+{
+ MultiSrcObject src = (MultiSrcObject)w;
+ String mb_string;
+ Bool ret;
+
+ mb_string = StorePiecesInString(src);
+
+ if (mb_string != 0) {
+ ret = WriteToFile(mb_string, (char *)name);
+ XtFree(mb_string);
+
+ return (ret);
+ }
+
+ /* otherwise there was a conversion error. So print widget name too */
+ XtAppWarningMsg(XtWidgetToApplicationContext(w),
+ "convertError", "multiSource", "XawError",
+ XtName(XtParent(w)), NULL, NULL);
+
+ return (False);
+}
+
+/*
+ * Private Functions
+ */
+static void
+RemoveOldStringOrFile(MultiSrcObject src, Bool checkString)
+{
+ FreeAllPieces(src);
+
+ if (checkString && src->multi_src.allocated_string) {
+ XtFree((char *)src->multi_src.string);
+ src->multi_src.allocated_string = False;
+ src->multi_src.string = NULL;
+ }
+}
+
+/*
+ * Function:
+ * WriteToFile
+ *
+ * Parameters:
+ * string - string to write
+ * name - name of the file
+ *
+ * Description:
+ * Write the string specified to the begining of the file specified.
+ *
+ * Returns:
+ * Returns True if sucessful, False otherwise
+ */
+static Bool
+WriteToFile(String string, String name)
+{
+ int fd;
+
+ if (((fd = creat(name, 0666)) == -1)
+ || (write(fd, string, strlen(string)) == -1))
+ return (False);
+
+ if (close(fd) == -1)
+ return (False);
+
+ return (True);
+}
+
+
+/*
+ * Function:
+ * StorePiecesInString
+ *
+ * Parameters:
+ * src - the multiSrc object to gather data from
+ *
+ * Description:
+ * Store the pieces in memory into a char string.
+ *
+ * Returns:
+ * mb_string: Caller must free
+ * (or)
+ * NULL: conversion error
+ */
+static String
+StorePiecesInString(MultiSrcObject src)
+{
+ wchar_t *wc_string;
+ char *mb_string;
+ int char_count = src->multi_src.length;
+ XawTextPosition first;
+ MultiPiece *piece;
+
+ /* I believe the char_count + 1 and the NULL termination are unneeded! FS */
+ wc_string = (wchar_t*)XtMalloc((char_count + 1) * sizeof(wchar_t));
+
+ for (first = 0, piece = src->multi_src.first_piece ; piece != NULL;
+ first += piece->used, piece = piece->next)
+ (void)wcsncpy(wc_string + first, piece->text, piece->used);
+
+ wc_string[char_count] = 0;
+
+ /* This will refill all pieces to capacity */
+ if (src->multi_src.data_compression) {
+ FreeAllPieces(src);
+ LoadPieces(src, NULL, (char *)wc_string);
+ }
+
+ /* Lastly, convert it to a MB format and send it back */
+ mb_string = _XawTextWCToMB(XtDisplayOfObject((Widget)src),
+ wc_string, &char_count);
+
+ /* NOTE THAT mb_string MAY BE ZERO IF THE CONVERSION FAILED */
+ XtFree((char*)wc_string);
+
+ return (mb_string);
+}
+
+/*
+ * Function:
+ * InitStringOrFile
+ *
+ * Parameters:
+ * src - MultiSource
+ *
+ * Description:
+ * Initializes the string or file.
+ */
+static FILE *
+InitStringOrFile(MultiSrcObject src, Bool newString)
+{
+ mode_t open_mode = 0;
+ const char *fdopen_mode = NULL;
+ int fd;
+ FILE *file;
+ Display *d = XtDisplayOfObject((Widget)src);
+
+ if (src->multi_src.type == XawAsciiString) {
+ if (src->multi_src.string == NULL)
+ src->multi_src.length = 0;
+
+ else if (!src->multi_src.use_string_in_place) {
+ int length;
+ String temp = XtNewString((char *)src->multi_src.string);
+
+ if (src->multi_src.allocated_string)
+ XtFree((char *)src->multi_src.string);
+ src->multi_src.allocated_string = True;
+ src->multi_src.string = temp;
+
+ length = strlen((char *)src->multi_src.string);
+
+ /* Wasteful, throwing away the WC string, but need side effect! */
+ (void)_XawTextMBToWC(d, (char *)src->multi_src.string, &length);
+ src->multi_src.length = (XawTextPosition)length;
+ }
+ else {
+ src->multi_src.length = strlen((char *)src->multi_src.string);
+ /* In case the length resource is incorrectly set */
+ if (src->multi_src.length > src->multi_src.multi_length)
+ src->multi_src.multi_length = src->multi_src.length;
+
+ if (src->multi_src.multi_length == MAGIC_VALUE)
+ src->multi_src.piece_size = src->multi_src.length;
+ else
+ src->multi_src.piece_size = src->multi_src.multi_length + 1;
+ }
+
+ return (NULL);
+ }
+
+ /*
+ * type is XawAsciiFile
+ */
+ src->multi_src.is_tempfile = False;
+
+ switch (src->text_src.edit_mode) {
+ case XawtextRead:
+ if (src->multi_src.string == NULL)
+ XtErrorMsg("NoFile", "multiSourceCreate", "XawError",
+ "Creating a read only disk widget and no file specified.",
+ NULL, 0);
+ open_mode = O_RDONLY;
+ fdopen_mode = "r";
+ break;
+ case XawtextAppend:
+ case XawtextEdit:
+ if (src->multi_src.string == NULL) {
+ src->multi_src.string = "*multi-src*";
+ src->multi_src.is_tempfile = True;
+ }
+ else {
+/* O_NOFOLLOW is a BSD & Linux extension */
+#ifdef O_NOFOLLOW
+ open_mode = O_RDWR | O_NOFOLLOW;
+#else
+ open_mode = O_RDWR; /* unsafe; subject to race conditions */
+#endif
+ fdopen_mode = "r+";
+ }
+ break;
+ default:
+ XtErrorMsg("badMode", "multiSourceCreate", "XawError",
+ "Bad editMode for multi source; must be "
+ "Read, Append or Edit.", NULL, NULL);
+ }
+
+ /* If is_tempfile, allocate a private copy of the text
+ * Unlikely to be changed, just to set allocated_string */
+ if (newString || src->multi_src.is_tempfile) {
+ String temp = XtNewString((char *)src->multi_src.string);
+
+ if (src->multi_src.allocated_string)
+ XtFree((char *)src->multi_src.string);
+ src->multi_src.string = temp;
+ src->multi_src.allocated_string = True;
+ }
+
+ if (!src->multi_src.is_tempfile) {
+ if ((fd = open((char *)src->multi_src.string, open_mode, 0666)) != -1) {
+ if ((file = fdopen(fd, fdopen_mode)) != NULL) {
+ (void)fseek(file, 0, SEEK_END);
+ src->multi_src.length = (XawTextPosition)ftell(file);
+ return(file);
+ }
+ }
+ {
+ String params[2];
+ Cardinal num_params = 2;
+
+ params[0] = (String)src->multi_src.string;
+ params[1] = strerror(errno);
+ XtAppWarningMsg(XtWidgetToApplicationContext((Widget)src),
+ "openError", "multiSourceCreate", "XawWarning",
+ "Cannot open file %s; %s", params, &num_params);
+ }
+ }
+ src->multi_src.length = 0;
+ return (NULL);
+}
+
+/* LoadPieces: This routine takes either the MB contents of open file
+ `file' or the MB contents of string or the MB contents of
+ src->multi_src.string and places them in Pieces in WC format.
+
+ CAUTION: You must have src->multi_src.length set to file length bytes
+ when src->multi_src.type == XawAsciiFile. src->multi_src.length must be
+ the length of the parameter string if string is non-NULL
+*/
+static void
+LoadPieces(MultiSrcObject src, FILE *file, char *string)
+{
+ Display *d = XtDisplayOfObject((Widget)src);
+ wchar_t* local_str, *ptr;
+ MultiPiece* piece = NULL;
+ XawTextPosition left;
+ int bytes = sizeof(wchar_t);
+ char* temp_mb_holder = NULL;
+
+ /*
+ * This is tricky - the _XawTextMBtoWC converter uses its 3rd arg
+ * in as MB length, out as WC length. We want local_length to be
+ * WC count.
+ */
+ int local_length = src->multi_src.length;
+
+ if (string != NULL) {
+ /*
+ * ASSERT: IF our caller passed a non-null string, THEN
+ * src->multi_src.length is currently string's * byte count,
+ * AND string is in a MB format
+ */
+ local_str = _XawTextMBToWC(d, (char *)string, &local_length);
+ src->multi_src.length = (XawTextPosition) local_length;
+ }
+ else if (src->multi_src.type != XawAsciiFile) {
+ /*
+ * here, we are not changing the contents, just reloading,
+ * so don't change len...
+ */
+ local_length = src->multi_src.string ?
+ strlen((char *)src->multi_src.string) : 0;
+ local_str = _XawTextMBToWC(d, (char *)src->multi_src.string,
+ &local_length);
+ }
+ else {
+ if (src->multi_src.length != 0) {
+ temp_mb_holder =
+ XtMalloc((src->multi_src.length + 1) * sizeof(unsigned char));
+ fseek(file, 0, 0);
+ src->multi_src.length = fread(temp_mb_holder,
+ (Size_t)sizeof(unsigned char),
+ (Size_t)src->multi_src.length, file);
+ if (src->multi_src.length <= 0)
+ XtAppErrorMsg(XtWidgetToApplicationContext ((Widget) src),
+ "readError", "multiSource", "XawError",
+ "fread returned error.", NULL, NULL);
+ local_length = src->multi_src.length;
+ local_str = _XawTextMBToWC(d, temp_mb_holder, &local_length);
+ src->multi_src.length = local_length;
+
+ if (local_str == 0) {
+ String params[2];
+ Cardinal num_params;
+ static char err_text[] =
+ "<<< FILE CONTENTS NOT REPRESENTABLE IN THIS LOCALE >>>";
+
+ params[0] = XtName(XtParent((Widget)src));
+ params[1] = src->multi_src.string;
+ num_params = 2;
+
+ XtAppWarningMsg(XtWidgetToApplicationContext((Widget)src),
+ "readLocaleError", "multiSource", "XawError",
+ "%s: The file `%s' contains characters "
+ "not representable in this locale.",
+ params, &num_params);
+ src->multi_src.length = sizeof err_text;
+ local_length = src->multi_src.length;
+ local_str = _XawTextMBToWC(d, err_text, &local_length);
+ src->multi_src.length = local_length;
+ }
+ }
+ else
+ /* ASSERT that since following while loop looks at local_length
+ this isn't needed. Sheeran, Omron KK, 1993/07/15
+ temp_mb_holder[src->multi_src.length] = '\0'; */
+ local_str = (wchar_t*)temp_mb_holder;
+ }
+
+ if (src->multi_src.use_string_in_place) {
+ piece = AllocNewPiece(src, piece);
+ piece->used = Min(src->multi_src.length, src->multi_src.piece_size);
+ piece->text = (wchar_t*)src->multi_src.string;
+ return;
+ }
+
+ ptr = local_str;
+ left = local_length;
+
+ do {
+ piece = AllocNewPiece(src, piece);
+
+ piece->text = (wchar_t*)XtMalloc((unsigned)(src->multi_src.piece_size
+ * bytes));
+ piece->used = Min(left, src->multi_src.piece_size);
+ if (piece->used != 0)
+ (void)wcsncpy(piece->text, ptr, piece->used);
+
+ left -= piece->used;
+ ptr += piece->used;
+ } while (left > 0);
+
+ if (temp_mb_holder)
+ XtFree((char*)temp_mb_holder);
+}
+
+/*
+ * Function:
+ * AllocNewPiece
+ *
+ * Parameters:
+ * src - MultiSrc Widget
+ * prev - the piece just before this one, or NULL
+ *
+ * Description:
+ * Allocates a new piece of memory.
+ *
+ * Returns:
+ * The allocated piece
+ */
+static MultiPiece *
+AllocNewPiece(MultiSrcObject src, MultiPiece *prev)
+{
+ MultiPiece *piece = XtNew(MultiPiece);
+
+ if (prev == NULL) {
+ src->multi_src.first_piece = piece;
+ piece->next = NULL;
+ }
+ else {
+ if (prev->next != NULL)
+ (prev->next)->prev = piece;
+ piece->next = prev->next;
+ prev->next = piece;
+ }
+
+ piece->prev = prev;
+
+ return (piece);
+}
+
+/*
+ * Function:
+ * FreeAllPieces
+ *
+ * Parameters:
+ * src - MultiSrc Widget
+ *
+ * Description:
+ * Frees all the pieces
+ */
+static void
+FreeAllPieces(MultiSrcObject src)
+{
+ MultiPiece *next, *first = src->multi_src.first_piece;
+
+#ifdef DEBUG
+ if (first->prev != NULL)
+ printf("Xaw MultiSrc Object: possible memory leak in FreeAllPieces().\n");
+#endif
+
+ for (; first != NULL ; first = next) {
+ next = first->next;
+ RemovePiece(src, first);
+ }
+}
+
+/*
+ * Function:
+ * RemovePiece
+ *
+ * Parameters:
+ * piece - piece to remove
+ *
+ * Description:
+ * Removes a piece from the list.
+ */
+static void
+RemovePiece(MultiSrcObject src, MultiPiece *piece)
+{
+ if (piece->prev == NULL)
+ src->multi_src.first_piece = piece->next;
+ else
+ piece->prev->next = piece->next;
+
+ if (piece->next != NULL)
+ piece->next->prev = piece->prev;
+
+ if (!src->multi_src.use_string_in_place)
+ XtFree((char *)piece->text);
+
+ XtFree((char *)piece);
+}
+
+/*
+ * Function:
+ * FindPiece
+ *
+ * Parameters:
+ * src - MultiSrc Widget
+ * position - position that we are searching for
+ * first - position of the first character in this piece (return)
+ *
+ * Description:
+ * Finds the piece containing the position indicated.
+ *
+ * Returns:
+ * Piece that contains this position
+ */
+static MultiPiece *
+FindPiece(MultiSrcObject src, XawTextPosition position, XawTextPosition *first)
+{
+ MultiPiece *old_piece, *piece;
+ XawTextPosition temp;
+
+ for (old_piece = NULL, piece = src->multi_src.first_piece, temp = 0;
+ piece; old_piece = piece, piece = piece->next)
+ if ((temp += piece->used) > position) {
+ *first = temp - piece->used;
+ return (piece);
+ }
+
+ *first = temp - (old_piece ? old_piece->used : 0);
+
+ return (old_piece); /* if we run off the end the return the last piece */
+}
+
+/*
+ * Function:
+ * BreakPiece
+ *
+ * Parameters:
+ * src - MultiSrc Widget
+ * piece - piece to break
+ *
+ * Description:
+ * Breaks a full piece into two new pieces.
+ */
+#define HALF_PIECE (src->multi_src.piece_size >> 1)
+static void
+BreakPiece(MultiSrcObject src, MultiPiece *piece)
+{
+ MultiPiece *cnew = AllocNewPiece(src, piece);
+
+ cnew->text = (wchar_t *)
+ XtMalloc(src->multi_src.piece_size * sizeof(wchar_t));
+ (void)wcsncpy(cnew->text, piece->text + HALF_PIECE,
+ src->multi_src.piece_size - HALF_PIECE);
+ piece->used = HALF_PIECE;
+ cnew->used = src->multi_src.piece_size - HALF_PIECE;
+}
+
+/*ARGSUSED*/
+static void
+CvtStringToMultiType(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static XawAsciiType type = XawAsciiString;
+ XrmQuark q;
+ char name[7];
+
+ XmuNCopyISOLatin1Lowered(name, (char *)fromVal->addr, sizeof(name));
+ q = XrmStringToQuark(name);
+
+ if (q == Qstring)
+ type = XawAsciiString;
+ if (q == Qfile)
+ type = XawAsciiFile;
+ else {
+ toVal->size = 0;
+ toVal->addr = NULL;
+ XtStringConversionWarning((char *)fromVal->addr, XtRAsciiType);
+ }
+
+ toVal->size = sizeof(XawAsciiType);
+ toVal->addr = (XPointer)&type;
+}
+
+/*ARGSUSED*/
+static Boolean
+CvtMultiTypeToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal,
+ XtPointer *data)
+{
+ static String buffer;
+ Cardinal size;
+
+ switch (*(XawAsciiType *)fromVal->addr) {
+ case XawAsciiFile:
+ buffer = XtEfile;
+ break;
+ case XawAsciiString:
+ buffer = XtEstring;
+ break;
+ default:
+ XawTypeToStringWarning(dpy, XtRAsciiType);
+ toVal->addr = NULL;
+ toVal->size = 0;
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL) {
+ if (toVal->size < size) {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
+
+/*ARGSUSED*/
+static void
+GetDefaultPieceSize(Widget w, int offset, XrmValue *value)
+{
+ static XPointer pagesize;
+
+ if (pagesize == 0) {
+ pagesize = (XPointer)((long)_XawGetPageSize());
+ if (pagesize < (XPointer)BUFSIZ)
+ pagesize = (XPointer)BUFSIZ;
+ }
+
+ value->addr = (XPointer)&pagesize;
+}
diff --git a/nx-X11/lib/Xaw/MultiSrc.h b/nx-X11/lib/Xaw/MultiSrc.h
new file mode 100644
index 000000000..00c27f6c7
--- /dev/null
+++ b/nx-X11/lib/Xaw/MultiSrc.h
@@ -0,0 +1,133 @@
+/* $Xorg: MultiSrc.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+ * Copyright 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: Li Yuhong OMRON Corporation
+ */
+
+/*
+
+Copyright 1989, 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xaw/MultiSrc.h,v 1.6 2001/01/17 19:42:28 dawes Exp $ */
+
+/*
+ * This file was modified from AsciiSrc.h.
+ *
+ * By Li Yuhong, Sept. 18, 1990
+ */
+
+#ifndef _XawMultiSrc_h
+#define _XawMultiSrc_h
+
+#include <X11/Xaw/TextSrc.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ dataCompression DataCompression Boolean True
+ length Length int (internal)
+ pieceSize PieceSize int BUFSIZ
+ string String String NULL
+ type Type XawAsciiType XawAsciiString
+ useStringInPlace UseStringInPlace Boolean False
+
+*/
+
+extern WidgetClass multiSrcObjectClass;
+
+typedef struct _MultiSrcClassRec *MultiSrcObjectClass;
+typedef struct _MultiSrcRec *MultiSrcObject;
+
+#define MultiSourceObjectClass MultiSrcObjectClass
+#define MultiSourceObject MultiSrcObject
+
+#define XtCDataCompression "DataCompression"
+#define XtCPieceSize "PieceSize"
+#define XtCType "Type"
+#define XtCUseStringInPlace "UseStringInPlace"
+
+#define XtNdataCompression "dataCompression"
+#define XtNpieceSize "pieceSize"
+#define XtNtype "type"
+#define XtNuseStringInPlace "useStringInPlace"
+
+#define XtRMultiType "MultiType"
+
+#define XtEstring "string"
+#define XtEfile "file"
+
+/************************************************************
+ *
+ * THESE ROUTINES ARE NOT PUBLIC: Source should call
+ *
+ * the AsciiSrc API which currently forwards requests here.
+ *
+ * future versions (like theres going to be an R7 Xaw!) may
+ *
+ * eliminate this file or at least these functions entirely.
+ *
+ ************************************************************/
+
+_XFUNCPROTOBEGIN
+
+void XawMultiSourceFreeString
+(
+ Widget w
+ );
+
+Bool _XawMultiSave
+(
+ Widget w
+);
+
+Bool _XawMultiSaveAsFile
+(
+ Widget w,
+ _Xconst char *name
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XawMultiSrc_h */
diff --git a/nx-X11/lib/Xaw/MultiSrcP.h b/nx-X11/lib/Xaw/MultiSrcP.h
new file mode 100644
index 000000000..49f7abc3a
--- /dev/null
+++ b/nx-X11/lib/Xaw/MultiSrcP.h
@@ -0,0 +1,182 @@
+/* $Xorg: MultiSrcP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/*
+ * Copyright 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 make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * OMRON DISCLAIM 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: Li Yuhong OMRON Corporation
+ */
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1991, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/MultiSrcP.h,v 1.8 2001/01/17 19:42:28 dawes Exp $ */
+
+/*
+ * MultiSrcP.h - Private Header for Multi Text Source.
+ *
+ * This is the private header file for the Multi Text Source.
+ * It is intended to be used with the Text widget, the simplest way to use
+ * this text source is to use the MultiText Object.
+ *
+ * Date: June 29, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+/*
+ * This file was changed from AsciiSrcP.h.
+ *
+ * By Li Yuhong, Sept. 18, 1990
+ */
+
+#ifndef _XawMultiSrcP_h
+#define _XawMultiSrcP_h
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xaw/TextSrcP.h>
+#include <X11/Xaw/MultiSrc.h>
+
+#ifdef L_tmpnam
+#define TMPSIZ L_tmpnam
+#else
+#ifdef PATH_MAX
+#define TMPSIZ PATH_MAX
+#else
+#define TMPSIZ 1024 /* bytes to allocate for tmpnam */
+#endif
+#endif
+
+typedef struct _MultiPiece { /* Piece of the text file of BUFSIZ allocated
+ characters */
+ wchar_t* text; /* The text in this buffer */
+ XawTextPosition used; /* The number of characters of this buffer
+ that have been used */
+ struct _MultiPiece *prev, *next; /* linked list pointers */
+} MultiPiece;
+
+/* New fields for the MultiSrc object class */
+typedef struct _MultiSrcClassPart {
+ XtPointer extension;
+} MultiSrcClassPart;
+
+/* Full class record */
+typedef struct _MultiSrcClassRec {
+ ObjectClassPart object_class;
+ TextSrcClassPart text_src_class;
+ MultiSrcClassPart multi_src_class;
+} MultiSrcClassRec;
+
+extern MultiSrcClassRec multiSrcClassRec;
+
+/* New fields for the MultiSrc object */
+typedef struct _MultiSrcPart {
+ /* resources */
+ XIC ic; /* for X Input Method */
+ XtPointer string; /* either the string, or the file name, depend-
+ ing upon the `type'. ALWAYS IN MB FORMAT */
+ XawAsciiType type; /* either string or disk */
+ XawTextPosition piece_size; /* Size of text buffer for each piece */
+ Boolean data_compression; /* compress to minimum memory automatically
+ on save? */
+#ifdef OLDXAW
+ XtCallbackList callback;
+#endif
+ Boolean use_string_in_place;/* Use the string passed in place */
+ int multi_length; /* length field for multi string emulation */
+
+ /* private */
+
+ Boolean is_tempfile; /* Is this a temporary file? */
+#ifdef OLDXAW
+ Boolean changes;
+#endif
+ Boolean allocated_string; /* Have I allocated the
+ string in multi_src->string? */
+ XawTextPosition length; /* length of file - IN CHARACTERS, NOT BYTES */
+ MultiPiece *first_piece; /* first piece of the text */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} MultiSrcPart;
+
+/* Full instance record */
+typedef struct _MultiSrcRec {
+ ObjectPart object;
+ TextSrcPart text_src;
+ MultiSrcPart multi_src;
+} MultiSrcRec;
+
+_XFUNCPROTOBEGIN
+
+void _XawMultiSourceFreeString
+(
+ Widget w
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XawMultiSrcP_h */
diff --git a/nx-X11/lib/Xaw/OS.c b/nx-X11/lib/Xaw/OS.c
new file mode 100644
index 000000000..ec80e63ff
--- /dev/null
+++ b/nx-X11/lib/Xaw/OS.c
@@ -0,0 +1,64 @@
+/* $XFree86: xc/lib/Xaw/OS.c,v 1.1 1998/12/06 10:44:34 dawes Exp $ */
+
+/* Some OS-dependent utility code */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xosdefs.h>
+#include <X11/IntrinsicP.h>
+#include "Private.h"
+
+#ifndef X_NOT_POSIX
+#include <unistd.h> /* for sysconf(), and getpagesize() */
+#endif
+
+#if defined(linux)
+/* kernel header doesn't work with -ansi */
+/* #include <asm/page.h> *//* for PAGE_SIZE */
+#define HAS_GETPAGESIZE
+#define HAS_SC_PAGESIZE /* _SC_PAGESIZE may be an enum for Linux */
+#endif
+
+#if defined(CSRG_BASED)
+#define HAS_GETPAGESIZE
+#endif
+
+#if defined(sun)
+#define HAS_GETPAGESIZE
+#endif
+
+int
+_XawGetPageSize()
+{
+ static int pagesize = -1;
+
+ if (pagesize != -1)
+ return pagesize;
+
+ /* Try each supported method in the preferred order */
+
+#if defined(_SC_PAGESIZE) || defined(HAS_SC_PAGESIZE)
+ pagesize = sysconf(_SC_PAGESIZE);
+#endif
+
+#ifdef _SC_PAGE_SIZE
+ if (pagesize == -1)
+ pagesize = sysconf(_SC_PAGE_SIZE);
+#endif
+
+#ifdef HAS_GETPAGESIZE
+ if (pagesize == -1)
+ pagesize = getpagesize();
+#endif
+
+#ifdef PAGE_SIZE
+ if (pagesize == -1)
+ pagesize = PAGE_SIZE;
+#endif
+
+ if (pagesize == -1)
+ pagesize = 0;
+
+ return pagesize;
+}
diff --git a/nx-X11/lib/Xaw/Paned.c b/nx-X11/lib/Xaw/Paned.c
new file mode 100644
index 000000000..4dbdb3017
--- /dev/null
+++ b/nx-X11/lib/Xaw/Paned.c
@@ -0,0 +1,2067 @@
+/* $Xorg: Paned.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Paned.c,v 1.11 2001/08/23 00:03:19 dawes Exp $ */
+
+/*
+ * Updated and significantly modified from the Athena VPaned Widget.
+ *
+ * Date: March 1, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/cursorfont.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xaw/Grip.h>
+#include <X11/Xaw/PanedP.h>
+#include <X11/Xaw/XawImP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+typedef enum {
+ UpLeftPane = 'U',
+ LowRightPane = 'L',
+ ThisBorderOnly = 'T',
+ AnyPane = 'A'
+} Direction;
+
+#define NO_INDEX -100
+#define IS_GRIP NULL
+
+#define PaneInfo(w) ((Pane)(w)->core.constraints)
+#define HasGrip(w) (PaneInfo(w)->grip != NULL)
+#define IsPane(w) ((w)->core.widget_class != gripWidgetClass)
+#define PaneIndex(w) (PaneInfo(w)->position)
+#define IsVert(w) ((w)->paned.orientation == XtorientVertical)
+
+#define ForAllPanes(pw, childP) \
+for ((childP) = (pw)->composite.children; \
+ (childP) < (pw)->composite.children + (pw)->paned.num_panes; \
+ (childP)++)
+
+#define ForAllChildren(pw, childP) \
+for ((childP) = (pw)->composite.children; \
+ (childP) < (pw)->composite.children + (pw)->composite.num_children; \
+ (childP)++)
+
+#define PaneSize(paned, vertical) \
+ ((vertical) ? XtHeight(paned) : XtWidth(paned))
+
+#define GetRequestInfo(geo, vertical) \
+ ((vertical) ? (geo)->height : (geo)->width)
+
+#define SatisfiesRule1(pane, shrink) \
+ (((shrink) && ((pane)->size != (pane)->min)) \
+ || (!(shrink) && ((pane)->size != (pane)->max)))
+
+#define SatisfiesRule2(pane) \
+ (!(pane)->skip_adjust || (pane)->paned_adjusted_me)
+
+#define SatisfiesRule3(pane, shrink) \
+ ((pane)->paned_adjusted_me \
+ && (((shrink) && ((int)(pane)->wp_size <= (pane)->size)) \
+ || (!(shrink) && ((int)(pane)->wp_size >= (pane)->size))))
+
+
+/*
+ * Class Methods
+ */
+static void XawPanedClassInitialize(void);
+static void XawPanedChangeManaged(Widget);
+static void XawPanedDeleteChild(Widget);
+static void XawPanedDestroy(Widget);
+static XtGeometryResult XawPanedGeometryManager(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawPanedInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawPanedInsertChild(Widget);
+static Boolean XawPanedPaneSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+static void XawPanedRealize(Widget, Mask*, XSetWindowAttributes*);
+static void XawPanedRedisplay(Widget, XEvent*, Region);
+static void XawPanedResize(Widget);
+static Boolean XawPanedSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static void _DrawInternalBorders(PanedWidget, GC);
+static void _DrawRect(PanedWidget, GC, int, int, unsigned int, unsigned int);
+static void _DrawTrackLines(PanedWidget, Bool);
+static void AdjustPanedSize(PanedWidget, unsigned int, XtGeometryResult*,
+ Dimension*, Dimension*);
+static void ChangeAllGripCursors(PanedWidget);
+static Pane ChoosePaneToResize(PanedWidget, int, Direction, Bool);
+static void ClearPaneStack(PanedWidget);
+static void CommitGripAdjustment(PanedWidget);
+static void CreateGrip(Widget);
+static int GetEventLocation(PanedWidget, XEvent*);
+static void GetGCs(Widget);
+static void GetPaneStack(PanedWidget, Bool, Pane*, int*);
+static void HandleGrip(Widget, XtPointer, XtPointer);
+static void LoopAndRefigureChildren(PanedWidget, int, Direction, int*);
+static void ManageAndUnmanageGrips(PanedWidget);
+static void MoveGripAdjustment(PanedWidget, Widget, Direction, int);
+static Bool PopPaneStack(PanedWidget);
+static void PushPaneStack(PanedWidget, Pane);
+static void RefigureLocations(PanedWidget, int, Direction);
+static void RefigureLocationsAndCommit(Widget);
+static void ReleaseGCs(Widget);
+static void ResortChildren(PanedWidget);
+static void SetChildrenPrefSizes(PanedWidget, unsigned int);
+static void StartGripAdjustment(PanedWidget, Widget, Direction);
+
+/*
+ * Initialization
+ */
+static char defGripTranslations[] =
+"<Btn1Down>:" "GripAction(Start,UpLeftPane)\n"
+"<Btn2Down>:" "GripAction(Start,ThisBorderOnly)\n"
+"<Btn3Down>:" "GripAction(Start,LowRightPane)\n"
+"<Btn1Motion>:" "GripAction(Move,UpLeft)\n"
+"<Btn2Motion>:" "GripAction(Move,ThisBorder)\n"
+"<Btn3Motion>:" "GripAction(Move,LowRight)\n"
+"Any<BtnUp>:" "GripAction(Commit)\n"
+;
+
+#define offset(field) XtOffsetOf(PanedRec, paned.field)
+static XtResource resources[] = {
+ {
+ XtNinternalBorderColor,
+ XtCBorderColor,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(internal_bp),
+ XtRString,
+ (XtPointer)XtDefaultForeground
+ },
+ {
+ XtNinternalBorderWidth,
+ XtCBorderWidth,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(internal_bw),
+ XtRImmediate,
+ (XtPointer)1
+ },
+ {
+ XtNgripIndent,
+ XtCGripIndent,
+ XtRPosition,
+ sizeof(Position),
+ offset(grip_indent),
+ XtRImmediate,
+ (XtPointer)10
+ },
+ {
+ XtNrefigureMode,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(refiguremode),
+ XtRImmediate,
+ (XtPointer)True
+ },
+ {
+ XtNgripTranslations,
+ XtCTranslations,
+ XtRTranslationTable,
+ sizeof(XtTranslations),
+ offset(grip_translations),
+ XtRString,
+ (XtPointer)defGripTranslations
+ },
+ {
+ XtNorientation,
+ XtCOrientation,
+ XtROrientation,
+ sizeof(XtOrientation),
+ offset(orientation),
+ XtRImmediate,
+ (XtPointer)XtorientVertical
+ },
+ {
+ XtNcursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(cursor),
+ XtRImmediate,
+ None
+ },
+ {
+ XtNgripCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(grip_cursor),
+ XtRImmediate,
+ None
+ },
+ {
+ XtNverticalGripCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(v_grip_cursor),
+ XtRString,
+ "sb_v_double_arrow"
+ },
+ {
+ XtNhorizontalGripCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(h_grip_cursor),
+ XtRString,
+ "sb_h_double_arrow"
+ },
+ {
+ XtNbetweenCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(adjust_this_cursor),
+ XtRString,
+ None
+ },
+ {
+ XtNverticalBetweenCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(v_adjust_this_cursor),
+ XtRString,
+ "sb_left_arrow"
+ },
+ {
+ XtNhorizontalBetweenCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(h_adjust_this_cursor),
+ XtRString,
+ "sb_up_arrow"
+ },
+ {
+ XtNupperCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(adjust_upper_cursor),
+ XtRString,
+ "sb_up_arrow"
+ },
+ {
+ XtNlowerCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(adjust_lower_cursor),
+ XtRString,
+ "sb_down_arrow"
+ },
+ {
+ XtNleftCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(adjust_left_cursor),
+ XtRString,
+ "sb_left_arrow"
+ },
+ {
+ XtNrightCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(adjust_right_cursor),
+ XtRString,
+ "sb_right_arrow"
+ },
+};
+#undef offset
+
+#define offset(field) XtOffsetOf(PanedConstraintsRec, paned.field)
+static XtResource subresources[] = {
+ {
+ XtNallowResize,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(allow_resize),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNposition,
+ XtCPosition,
+ XtRInt,
+ sizeof(int),
+ offset(position),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNmin,
+ XtCMin,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(min),
+ XtRImmediate,
+ (XtPointer)PANED_GRIP_SIZE
+ },
+ {
+ XtNmax,
+ XtCMax,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(max),
+ XtRImmediate,
+ (XtPointer)~0
+ },
+ {
+ XtNpreferredPaneSize,
+ XtCPreferredPaneSize,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(preferred_size),
+ XtRImmediate,
+ (XtPointer)PANED_ASK_CHILD
+ },
+ {
+ XtNresizeToPreferred,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(resize_to_pref),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNskipAdjust,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(skip_adjust),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNshowGrip,
+ XtCShowGrip,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(show_grip),
+ XtRImmediate,
+ (XtPointer)True
+ },
+};
+#undef offset
+
+#define SuperClass ((ConstraintWidgetClass)&constraintClassRec)
+
+PanedClassRec panedClassRec = {
+ /* core */
+ {
+ (WidgetClass)SuperClass, /* superclass */
+ "Paned", /* class name */
+ sizeof(PanedRec), /* size */
+ XawPanedClassInitialize, /* class_initialize */
+ NULL, /* class_part init */
+ False, /* class_inited */
+ XawPanedInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XawPanedRealize, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ XawPanedDestroy, /* destroy */
+ XawPanedResize, /* resize */
+ XawPanedRedisplay, /* expose */
+ XawPanedSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* composite */
+ {
+ XawPanedGeometryManager, /* geometry_manager */
+ XawPanedChangeManaged, /* change_managed */
+ XawPanedInsertChild, /* insert_child */
+ XawPanedDeleteChild, /* delete_child */
+ NULL, /* extension */
+ },
+ /* constraint */
+ {
+ subresources, /* subresources */
+ XtNumber(subresources), /* subresource_count */
+ sizeof(PanedConstraintsRec), /* constraint_size */
+ NULL, /* initialize */
+ NULL, /* destroy */
+ XawPanedPaneSetValues, /* set_values */
+ NULL, /* extension */
+ },
+};
+
+WidgetClass panedWidgetClass = (WidgetClass)&panedClassRec;
+WidgetClass vPanedWidgetClass = (WidgetClass)&panedClassRec;
+
+/*
+ * Implementation
+ */
+/* Function:
+ * AdjustPanedSize
+ *
+ * Parameters:
+ * pw - paned widget to adjust
+ * off_size - new off_size to use
+ * result_ret - result of query (return)
+ * on_size_ret - new on_size (return)
+ * off_size_ret - new off_size (return)
+ *
+ * Description:
+ * Adjusts the size of the pane.
+ *
+ * Returns:
+ * amount of change in size
+ */
+static void
+AdjustPanedSize(PanedWidget pw, unsigned int off_size,
+ XtGeometryResult *result_ret,
+ Dimension *on_size_ret, Dimension *off_size_ret)
+{
+ Dimension old_size = PaneSize((Widget)pw, IsVert(pw));
+ Dimension newsize = 0;
+ Widget *childP;
+ XtWidgetGeometry request, reply;
+
+ request.request_mode = CWWidth | CWHeight;
+
+ ForAllPanes(pw, childP) {
+ int size = Max(PaneInfo(*childP)->size, (int)PaneInfo(*childP)->min);
+
+ AssignMin(size, (int)PaneInfo(*childP)->max);
+ newsize += size + pw->paned.internal_bw;
+ }
+ newsize -= pw->paned.internal_bw;
+
+ if (newsize < 1)
+ newsize = 1;
+
+ if (IsVert(pw)) {
+ request.width = off_size;
+ request.height = newsize;
+ }
+ else {
+ request.width = newsize;
+ request.height = off_size;
+ }
+
+ if (result_ret != NULL) {
+ request.request_mode |= XtCWQueryOnly;
+
+ *result_ret = XtMakeGeometryRequest((Widget)pw, &request, &reply);
+ _XawImCallVendorShellExtResize((Widget)pw);
+
+ if (newsize == old_size || *result_ret == XtGeometryNo) {
+ *on_size_ret = old_size;
+ *off_size_ret = off_size;
+ return;
+ }
+ if (*result_ret != XtGeometryAlmost) {
+ *on_size_ret = GetRequestInfo(&request, IsVert(pw));
+ *off_size_ret = GetRequestInfo(&request, !IsVert(pw));
+ return;
+ }
+ *on_size_ret = GetRequestInfo(&reply, IsVert(pw));
+ *off_size_ret = GetRequestInfo(&reply, !IsVert(pw));
+ return;
+ }
+
+ if (newsize == old_size)
+ return;
+
+ if (XtMakeGeometryRequest((Widget)pw, &request, &reply) == XtGeometryAlmost)
+ XtMakeGeometryRequest((Widget)pw, &reply, &request);
+}
+
+/*
+ * Function:
+ * ChoosePaneToResize.
+ *
+ * Parameters:
+ * pw - paned widget
+ * paneindex - index of the current pane
+ * dir - direction to search first
+ * shrink - True if we need to shrink a pane, False otherwise
+ *
+ * Description:
+ * This function chooses a pane to resize.
+ They are chosen using the following rules:
+ *
+ * 1) size < max && size > min
+ * 2) skip adjust == False
+ * 3) widget not its prefered height
+ * && this change will bring it closer
+ * && The user has not resized this pane.
+ *
+ * If no widgets are found that fits all the rules then
+ * rule #3 is broken.
+ * If there are still no widgets found than
+ * rule #2 is broken.
+ * Rule #1 is never broken.
+ * If no widgets are found then NULL is returned.
+ *
+ * Returns:
+ * pane to resize or NULL
+ */
+static Pane
+ChoosePaneToResize(PanedWidget pw, int paneindex, Direction dir, Bool shrink)
+{
+ Widget *childP;
+ int rules = 3;
+ Direction _dir = dir;
+ int _index = paneindex;
+
+ if (paneindex == NO_INDEX || dir == AnyPane) { /* Use defaults */
+ _dir = LowRightPane; /* Go up - really */
+ _index = pw->paned.num_panes - 1; /* Start the last pane, and work
+ backwards */
+ }
+ childP = pw->composite.children + _index;
+
+ /*CONSTCOND*/
+ while(True) {
+ Pane pane = PaneInfo(*childP);
+
+ if ((rules < 3 || SatisfiesRule3(pane, shrink))
+ && (rules < 2 || SatisfiesRule2(pane))
+ && SatisfiesRule1(pane, shrink)
+ && (paneindex != PaneIndex(*childP) || dir == AnyPane))
+ return (pane);
+
+ /*
+ * This is counter-intuitive, but if we are resizing the pane
+ * above the grip we want to choose a pane below the grip to lose,
+ * and visa-versa
+ */
+ if (_dir == LowRightPane)
+ --childP;
+ else
+ ++childP;
+
+ /*
+ * If we have come to and edge then reduce the rule set, and try again
+ * If we are reduced the rules to none, then return NULL
+ */
+ if ((childP - pw->composite.children) < 0 ||
+ (childP - pw->composite.children) >= pw->paned.num_panes) {
+ if (--rules < 1) /* less strict rules */
+ return (NULL);
+ childP = pw->composite.children + _index;
+ }
+ }
+}
+
+/*
+ * Function:
+ * LoopAndRefigureChildren
+ *
+ * Parameters:
+ * pw - paned widget
+ * paneindex - number of the pane border we are moving
+ * dir - pane to move (either UpLeftPane or LowRightPane)
+ * sizeused - current amount of space used (used and returned)
+ *
+ * Description:
+ * If we are resizing either the UpleftPane or LowRight Pane loop
+ * through all the children to see if any will allow us to resize them.
+ */
+static void
+LoopAndRefigureChildren(PanedWidget pw, int paneindex, Direction dir,
+ int *sizeused)
+{
+ int pane_size = (int)PaneSize((Widget)pw, IsVert(pw));
+ Boolean shrink = (*sizeused > pane_size);
+
+ if (dir == LowRightPane)
+ paneindex++;
+
+ /* While all panes do not fit properly */
+ while (*sizeused != pane_size) {
+ /*
+ * Choose a pane to resize
+ * First look on the Pane Stack, and then go hunting for another one
+ * If we fail to find a pane to resize then give up
+ */
+ Pane pane;
+ int start_size;
+ Dimension old;
+ Boolean rule3_ok = False, from_stack = True;
+
+ GetPaneStack(pw, shrink, &pane, &start_size);
+ if (pane == NULL) {
+ pane = ChoosePaneToResize(pw, paneindex, dir, shrink);
+ if (pane == NULL)
+ return; /* no one to resize, give up */
+
+ rule3_ok = SatisfiesRule3(pane, shrink);
+ from_stack = False;
+ PushPaneStack(pw, pane);
+ }
+
+ /*
+ * Try to resize this pane so that all panes will fit, take min and max
+ * into account
+ */
+ old = pane->size;
+ pane->size += pane_size - *sizeused;
+
+ if (from_stack) {
+ if (shrink) {
+ AssignMax(pane->size, start_size);
+ } /* don't remove these braces */
+ else
+ AssignMin(pane->size, start_size);
+
+ if (pane->size == start_size)
+ (void)PopPaneStack(pw);
+ }
+ else if (rule3_ok) {
+ if (shrink) {
+ AssignMax(pane->size, (int)pane->wp_size);
+ } /* don't remove these braces */
+ else
+ AssignMin(pane->size, (int)pane->wp_size);
+ }
+
+ pane->paned_adjusted_me = pane->size != pane->wp_size;
+ AssignMax(pane->size, (int)pane->min);
+ AssignMin(pane->size, (int)pane->max);
+ *sizeused += (pane->size - old);
+ }
+}
+
+/*
+ * Function:
+ * RefigureLocations
+ *
+ * Parameters:
+ * pw - paned widget
+ * paneindex - child to start refiguring at
+ * dir - direction to move from child
+ *
+ * Description:
+ * Refigures all locations of children.
+ * There are special arguments to paneindex and dir, they are:
+ * paneindex - NO_INDEX.
+ * dir - AnyPane.
+ *
+ * If either of these is true then all panes may be resized and
+ * the choosing of panes procedes in reverse order starting with the
+ * last child.
+ */
+static void
+RefigureLocations(PanedWidget pw, int paneindex, Direction dir)
+{
+ Widget *childP;
+ int pane_size = (int)PaneSize((Widget)pw, IsVert(pw));
+ int sizeused = 0;
+ Position loc = 0;
+
+ if (pw->paned.num_panes == 0 || !pw->paned.refiguremode)
+ return;
+
+ /*
+ * Get an initial estimate of the size we will use
+ */
+ ForAllPanes(pw, childP) {
+ Pane pane = PaneInfo(*childP);
+
+ AssignMax(pane->size, (int) pane->min);
+ AssignMin(pane->size, (int) pane->max);
+ sizeused += (int)pane->size + (int)pw->paned.internal_bw;
+ }
+ sizeused -= (int)pw->paned.internal_bw;
+
+ if (dir != ThisBorderOnly && sizeused != pane_size)
+ LoopAndRefigureChildren(pw, paneindex, dir, &sizeused);
+
+ /*
+ * If we still are not the right size, then tell the pane that
+ * wanted to resize that it can't
+ */
+ if (paneindex != NO_INDEX && dir != AnyPane) {
+ Pane pane = PaneInfo(*(pw->composite.children + paneindex));
+ Dimension old = pane->size;
+
+ pane->size += pane_size - sizeused;
+ AssignMax(pane->size, (int) pane->min);
+ AssignMin(pane->size, (int) pane->max);
+ sizeused += pane->size - old;
+ }
+
+ /*
+ * It is possible that the panes will not fit inside the vpaned widget, but
+ * we have tried out best
+ *
+ * Assign each pane a location
+ */
+ ForAllPanes(pw, childP) {
+ PaneInfo(*childP)->delta = loc;
+ loc += PaneInfo(*childP)->size + pw->paned.internal_bw;
+ }
+}
+
+/*
+ * Function:
+ * CommitNewLocations
+ *
+ * Parameters:
+ * pw - paned widget
+ *
+ * Description:
+ * Commits all of the previously figured locations.
+ */
+static void
+CommitNewLocations(PanedWidget pw)
+{
+ Widget *childP;
+ XWindowChanges changes;
+
+ changes.stack_mode = Above;
+
+ ForAllPanes(pw, childP) {
+ Pane pane = PaneInfo(*childP);
+ Widget grip = pane->grip; /* may be NULL */
+
+ if (IsVert(pw)) {
+ XtMoveWidget(*childP, (Position) 0, pane->delta);
+ XtResizeWidget(*childP, XtWidth(pw), pane->size, 0);
+
+ if (HasGrip(*childP)) { /* Move and Display the Grip */
+ changes.x = XtWidth(pw) - pw->paned.grip_indent -
+ XtWidth(grip) - (XtBorderWidth(grip) << 1);
+ changes.y = XtY(*childP) + XtHeight(*childP) -
+ (XtHeight(grip) >> 1) - XtBorderWidth(grip) +
+ (pw->paned.internal_bw >> 1);
+ }
+ }
+ else {
+ XtMoveWidget(*childP, pane->delta, 0);
+ XtResizeWidget(*childP, pane->size, XtHeight(pw), 0);
+
+ if (HasGrip(*childP)) { /* Move and Display the Grip */
+ changes.x = XtX(*childP) + XtWidth(*childP) -
+ (XtWidth(grip) >> 1) - XtBorderWidth(grip) +
+ (pw->paned.internal_bw >> 1);
+ changes.y = XtHeight(pw) - pw->paned.grip_indent -
+ XtHeight(grip) - (XtBorderWidth(grip) << 1);
+ }
+ }
+
+ /*
+ * This should match XtMoveWidget, except that we're also insuring the
+ * grip is Raised in the same request
+ */
+
+ if (HasGrip(*childP)) {
+ XtX(grip) = changes.x;
+ XtY(grip) = changes.y;
+
+ if (XtIsRealized(pane->grip))
+ XConfigureWindow(XtDisplay(pane->grip), XtWindow(pane->grip),
+ CWX | CWY | CWStackMode, &changes);
+ }
+ }
+ ClearPaneStack(pw);
+}
+
+/*
+ * Function:
+ * RefigureLocationsAndCommit
+ *
+ * Parameters:
+ * pw - paned widget
+ *
+ * Description:
+ * Refigures all locations in a paned widget and commits them immediately.
+ *
+ * This function does nothing if any of the following are true.
+ * o refiguremode is false.
+ * o The widget is unrealized.
+ * o There are no panes is the paned widget.
+ */
+static void
+RefigureLocationsAndCommit(Widget w)
+{
+ PanedWidget pw = (PanedWidget)w;
+
+ if (pw->paned.refiguremode && XtIsRealized(w) && pw->paned.num_panes > 0) {
+ RefigureLocations(pw, NO_INDEX, AnyPane);
+ CommitNewLocations(pw);
+ }
+}
+
+/*
+ * Function:
+ * _DrawRect
+ *
+ * Parameters:
+ * pw - paned widget
+ * gc - gc to used for the draw
+ * on_olc - location of upper left corner of rect
+ * off_loc - ""
+ * on_size - size of rectangle
+ * off_size - ""
+ *
+ * Description:
+ * Draws a rectangle in the proper orientation.
+ */
+static void
+_DrawRect(PanedWidget pw, GC gc, int on_loc, int off_loc,
+ unsigned int on_size, unsigned int off_size)
+{
+ if (IsVert(pw))
+ XFillRectangle(XtDisplay((Widget)pw), XtWindow((Widget)pw), gc,
+ off_loc, on_loc, off_size, on_size);
+ else
+ XFillRectangle(XtDisplay((Widget)pw), XtWindow((Widget)pw), gc,
+ on_loc, off_loc, on_size, off_size);
+}
+
+/*
+ * Function:
+ * _DrawInternalBorders
+ *
+ * Parameters:
+ * pw - paned widget
+ * gc - GC to use to draw the borders
+ *
+ * Description:
+ * Draws the internal borders into the paned widget.
+ */
+static void
+_DrawInternalBorders(PanedWidget pw, GC gc)
+{
+ Widget *childP;
+ int on_loc, off_loc;
+ unsigned int on_size, off_size;
+
+ /*
+ * This is an optimization. Do not paint the internal borders if
+ * they are the same color as the background
+ */
+ if (pw->core.background_pixel == pw->paned.internal_bp)
+ return;
+
+ off_loc = 0;
+ off_size = (unsigned int) PaneSize((Widget)pw, !IsVert(pw));
+ on_size = (unsigned int)pw->paned.internal_bw;
+
+ ForAllPanes(pw, childP) {
+ on_loc = IsVert(pw) ? XtY(*childP) : XtX(*childP);
+ on_loc -= (int)on_size;
+
+ _DrawRect(pw, gc, on_loc, off_loc, on_size, off_size);
+ }
+}
+
+#define DrawInternalBorders(pw) \
+ _DrawInternalBorders((pw), (pw)->paned.normgc)
+#define EraseInternalBorders(pw) \
+ _DrawInternalBorders((pw), (pw)->paned.invgc)
+/*
+ * Function Name:
+ * _DrawTrackLines
+ *
+ * Parameters:
+ * pw - Paned widget
+ * erase - if True then just erase track lines, else draw them in
+ *
+ * Description:
+ * Draws the lines that animate the pane borders when the grips are moved.
+ */
+static void
+_DrawTrackLines(PanedWidget pw, Bool erase)
+{
+ Widget *childP;
+ Pane pane;
+ int on_loc, off_loc;
+ unsigned int on_size, off_size;
+
+ off_loc = 0;
+ off_size = PaneSize((Widget)pw, !IsVert(pw));
+
+ ForAllPanes(pw, childP) {
+ pane = PaneInfo(*childP);
+ if (erase || pane->olddelta != pane->delta) {
+ on_size = pw->paned.internal_bw;
+ if (!erase) {
+ on_loc = PaneInfo(*childP)->olddelta - (int) on_size;
+ _DrawRect(pw, pw->paned.flipgc,
+ on_loc, off_loc, on_size, off_size);
+ }
+
+ on_loc = PaneInfo(*childP)->delta - (int)on_size;
+
+ _DrawRect(pw, pw->paned.flipgc,
+ on_loc, off_loc, on_size, off_size);
+
+ pane->olddelta = pane->delta;
+ }
+ }
+}
+
+#define DrawTrackLines(pw) _DrawTrackLines((pw), False);
+#define EraseTrackLines(pw) _DrawTrackLines((pw), True);
+/*
+ * Function:
+ * GetEventLocation
+ *
+ * Parameters:
+ * pw - the paned widget
+ * event - pointer to an event
+ *
+ * Description:
+ * Converts and event to an x and y location.
+ *
+ * Returns:
+ * if this is a vertical pane then (y) else (x)
+ */
+static int
+GetEventLocation(PanedWidget pw, XEvent *event)
+{
+ int x, y;
+
+ switch (event->xany.type) {
+ case ButtonPress:
+ case ButtonRelease:
+ x = event->xbutton.x_root;
+ y = event->xbutton.y_root;
+ break;
+ case KeyPress:
+ case KeyRelease:
+ x = event->xkey.x_root;
+ y = event->xkey.y_root;
+ break;
+ case MotionNotify:
+ x = event->xmotion.x_root;
+ y = event->xmotion.y_root;
+ break;
+ default:
+ x = pw->paned.start_loc;
+ y = pw->paned.start_loc;
+ }
+
+ if (IsVert(pw))
+ return (y);
+
+ return (x);
+}
+
+/*
+ * Function:
+ * StartGripAdjustment
+ *
+ * Parameters:
+ * pw - paned widget
+ * grip - grip widget selected
+ * dir - direction that we are to be moving
+ *
+ * Description:
+ * Starts the grip adjustment procedure.
+ */
+static void
+StartGripAdjustment(PanedWidget pw, Widget grip, Direction dir)
+{
+ Widget *childP;
+ Cursor cursor;
+
+ pw->paned.whichadd = pw->paned.whichsub = NULL;
+
+ if (dir == ThisBorderOnly || dir == UpLeftPane)
+ pw->paned.whichadd = pw->composite.children[PaneIndex(grip)];
+ if (dir == ThisBorderOnly || dir == LowRightPane)
+ pw->paned.whichsub = pw->composite.children[PaneIndex(grip) + 1];
+
+ /*
+ * Change the cursor
+ */
+ if (XtIsRealized(grip)) {
+ if (IsVert(pw)) {
+ if (dir == UpLeftPane)
+ cursor = pw->paned.adjust_upper_cursor;
+ else if (dir == LowRightPane)
+ cursor = pw->paned.adjust_lower_cursor;
+ else {
+ if (pw->paned.adjust_this_cursor == None)
+ cursor = pw->paned.v_adjust_this_cursor;
+ else
+ cursor = pw->paned.adjust_this_cursor;
+ }
+ }
+ else {
+ if (dir == UpLeftPane)
+ cursor = pw->paned.adjust_left_cursor;
+ else if (dir == LowRightPane)
+ cursor = pw->paned.adjust_right_cursor;
+ else {
+ if (pw->paned.adjust_this_cursor == None)
+ cursor = pw->paned.h_adjust_this_cursor;
+ else
+ cursor = pw->paned.adjust_this_cursor;
+ }
+ }
+
+ XDefineCursor(XtDisplay(grip), XtWindow(grip), cursor);
+ }
+
+ EraseInternalBorders(pw);
+ ForAllPanes(pw, childP)
+ PaneInfo(*childP)->olddelta = -99;
+
+ EraseTrackLines(pw);
+}
+
+/*
+ * Function:
+ * MoveGripAdjustment
+ *
+ * Parameters:
+ * pw - paned widget
+ * grip - grip that we are moving
+ * dir - direction the pane we are interested is w.r.t the grip
+ * loc - location of pointer in proper direction
+ *
+ * Description:
+ * This routine moves all panes around when a grip is moved.
+ */
+static void
+MoveGripAdjustment(PanedWidget pw, Widget grip, Direction dir, int loc)
+{
+ int diff, add_size = 0, sub_size = 0;
+
+ diff = loc - pw->paned.start_loc;
+
+ if (pw->paned.whichadd)
+ add_size = PaneSize(pw->paned.whichadd, IsVert(pw)) + diff;
+
+ if (pw->paned.whichsub)
+ sub_size = PaneSize(pw->paned.whichsub, IsVert(pw)) - diff;
+
+ /*
+ * If moving this border only then do not allow either of the borders
+ * to go beyond the min or max size allowed
+ */
+ if (dir == ThisBorderOnly) {
+ int old_add_size = add_size, old_sub_size;
+
+ AssignMax(add_size, (int)PaneInfo(pw->paned.whichadd)->min);
+ AssignMin(add_size, (int)PaneInfo(pw->paned.whichadd)->max);
+ if (add_size != old_add_size)
+ sub_size += old_add_size - add_size;
+
+ old_sub_size = sub_size;
+ AssignMax(sub_size, (int)PaneInfo(pw->paned.whichsub)->min);
+ AssignMin(sub_size, (int)PaneInfo(pw->paned.whichsub)->max);
+ if (sub_size != old_sub_size)
+ return; /* Abort to current sizes */
+ }
+
+ if (add_size != 0)
+ PaneInfo(pw->paned.whichadd)->size = add_size;
+ if (sub_size != 0)
+ PaneInfo(pw->paned.whichsub)->size = sub_size;
+ RefigureLocations(pw, PaneIndex(grip), dir);
+ DrawTrackLines(pw);
+}
+
+/*
+ * Function:
+ * CommitGripAdjustment
+ *
+ * Parameters:
+ * pw - paned widget
+ *
+ * Description:
+ * Commits the grip adjustment.
+ */
+static void
+CommitGripAdjustment(PanedWidget pw)
+{
+ EraseTrackLines(pw);
+ CommitNewLocations(pw);
+ DrawInternalBorders(pw);
+
+ /*
+ * Since the user selected this size then use it as the preferred size
+ */
+ if (pw->paned.whichadd) {
+ Pane pane = PaneInfo(pw->paned.whichadd);
+
+ pane->wp_size = pane->size;
+ }
+ if (pw->paned.whichsub) {
+ Pane pane = PaneInfo(pw->paned.whichsub);
+
+ pane->wp_size = pane->size;
+ }
+}
+
+/*
+ * Function:
+ * HandleGrip
+ *
+ * Parameters:
+ * grip - grip widget that has been moved
+ * temp - (not used)
+ * call_data - data passed to us from the grip widget
+ *
+ * Description:
+ * Handles the grip manipulations.
+ */
+/*ARGSUSED*/
+static void
+HandleGrip(Widget grip, XtPointer temp, XtPointer callData)
+{
+ XawGripCallData call_data = (XawGripCallData)callData;
+ PanedWidget pw = (PanedWidget) XtParent(grip);
+ int loc;
+ char action_type[2], direction[2];
+ Cursor cursor;
+ Arg arglist[1];
+
+ if (call_data->num_params)
+ XmuNCopyISOLatin1Uppered(action_type, call_data->params[0],
+ sizeof(action_type));
+
+ if (call_data->num_params == 0
+ || (action_type[0] == 'C' && call_data->num_params != 1)
+ || (action_type[0] != 'C' && call_data->num_params != 2))
+ XtAppError(XtWidgetToApplicationContext(grip),
+ "Paned GripAction has been passed incorrect parameters.");
+
+ loc = GetEventLocation(pw, (XEvent *)call_data->event);
+
+ if (action_type[0] != 'C')
+ XmuNCopyISOLatin1Uppered(direction, call_data->params[1],
+ sizeof(direction));
+
+ switch (action_type[0]) {
+ case 'S': /* Start adjustment */
+ pw->paned.resize_children_to_pref = False;
+ StartGripAdjustment(pw, grip, (Direction)direction[0]);
+ pw->paned.start_loc = loc;
+ break;
+ case 'M':
+ MoveGripAdjustment(pw, grip, (Direction)direction[0], loc);
+ break;
+ case 'C':
+ XtSetArg(arglist[0], XtNcursor, &cursor);
+ XtGetValues(grip, arglist, 1);
+ XDefineCursor(XtDisplay(grip), XtWindow(grip), cursor);
+ CommitGripAdjustment(pw);
+ break;
+ default:
+ XtAppError(XtWidgetToApplicationContext(grip),
+ "Paned GripAction(); 1st parameter invalid");
+ break;
+ }
+}
+
+/*
+ * Function:
+ * ResortChildren
+ *
+ * Arguments:
+ * pw - paned widget
+ *
+ * Description:
+ * Resorts the children so that all managed children are first.
+ */
+static void
+ResortChildren(PanedWidget pw)
+{
+ Widget *unmanagedP, *childP;
+
+ unmanagedP = NULL;
+ ForAllChildren(pw, childP) {
+ if (!IsPane(*childP) || !XtIsManaged(*childP)) {
+ /*
+ * We only keep track of the first unmanaged pane
+ */
+ if (unmanagedP == NULL)
+ unmanagedP = childP;
+ }
+ else { /* must be a managed pane */
+ /*
+ * If an earlier widget was not a managed pane, then swap
+ */
+ if (unmanagedP != NULL) {
+ Widget child = *unmanagedP;
+
+ *unmanagedP = *childP;
+ *childP = child;
+ childP = unmanagedP; /* easiest to just back-track */
+ unmanagedP = NULL; /* in case there is another managed */
+ }
+ }
+ }
+}
+
+/*
+ * Function:
+ * ManageAndUnmanageGrips
+ *
+ * Parameters:
+ * pw - paned widget
+ *
+ * Description:
+ * This function manages and unmanages the grips so that
+ * the managed state of each grip matches that of its pane.
+ */
+static void
+ManageAndUnmanageGrips(PanedWidget pw)
+{
+ WidgetList managed_grips, unmanaged_grips;
+ Widget *managedP, *unmanagedP, *childP;
+ Cardinal alloc_size;
+
+ alloc_size = sizeof(Widget) * (pw->composite.num_children >> 1);
+ managedP = managed_grips = (WidgetList)XtMalloc(alloc_size);
+ unmanagedP = unmanaged_grips = (WidgetList)XtMalloc(alloc_size);
+
+ ForAllChildren(pw, childP)
+ if (IsPane(*childP) && HasGrip(*childP)) {
+ if (XtIsManaged(*childP))
+ *managedP++ = PaneInfo(*childP)->grip;
+ else
+ *unmanagedP++ = PaneInfo(*childP)->grip;
+ }
+
+ if (managedP != managed_grips) {
+ *unmanagedP++ = *--managedP; /* Last grip is never managed */
+ XtManageChildren(managed_grips, managedP - managed_grips);
+ }
+
+ if (unmanagedP != unmanaged_grips)
+ XtUnmanageChildren(unmanaged_grips, unmanagedP - unmanaged_grips);
+
+ XtFree((char *)managed_grips);
+ XtFree((char *)unmanaged_grips);
+}
+
+/*
+ * Function:
+ * CreateGrip
+ *
+ * Parameters:
+ * child - child that wants a grip to be created for it
+ *
+ * Description:
+ * Creates a grip widget.
+ */
+static void
+CreateGrip(Widget child)
+{
+ PanedWidget pw = (PanedWidget)XtParent(child);
+ Arg arglist[2];
+ Cardinal num_args = 0;
+ Cursor cursor;
+
+ XtSetArg(arglist[num_args], XtNtranslations, pw->paned.grip_translations);
+ num_args++;
+ if ((cursor = pw->paned.grip_cursor) == None) {
+ if (IsVert(pw))
+ cursor = pw->paned.v_grip_cursor;
+ else
+ cursor = pw->paned.h_grip_cursor;
+ }
+
+ XtSetArg(arglist[num_args], XtNcursor, cursor);
+ num_args++;
+ PaneInfo(child)->grip = XtCreateWidget("grip", gripWidgetClass, (Widget)pw,
+ arglist, num_args);
+
+ XtAddCallback(PaneInfo(child)->grip, XtNcallback,
+ HandleGrip, (XtPointer)child);
+}
+
+/*
+ * Function:
+ * GetGCs
+ *
+ * Parameters:
+ * w - paned widget
+ */
+static void
+GetGCs(Widget w)
+{
+ PanedWidget pw = (PanedWidget)w;
+ XtGCMask valuemask;
+ XGCValues values;
+
+ /*
+ * Draw pane borders in internal border color
+ */
+ values.foreground = pw->paned.internal_bp;
+ valuemask = GCForeground;
+ pw->paned.normgc = XtGetGC(w, valuemask, &values);
+
+ /*
+ * Erase pane borders with background color
+ */
+ values.foreground = pw->core.background_pixel;
+ valuemask = GCForeground;
+ pw->paned.invgc = XtGetGC(w, valuemask, &values);
+
+ /*
+ * Draw Track lines (animate pane borders) in
+ * internal border color ^ bg color
+ */
+ values.function = GXinvert;
+ values.plane_mask = pw->paned.internal_bp ^ pw->core.background_pixel;
+ values.subwindow_mode = IncludeInferiors;
+ valuemask = GCPlaneMask | GCFunction | GCSubwindowMode;
+ pw->paned.flipgc = XtGetGC(w, valuemask, &values);
+}
+
+/*
+ * Function:
+ * SetChildrenPrefSizes
+ *
+ * Parameters:
+ * pw - paned widget
+ *
+ * Description:
+ * Sets the preferred sizes of the children.
+ */
+static void
+SetChildrenPrefSizes(PanedWidget pw, unsigned int off_size)
+{
+ Widget *childP;
+ Boolean vert = IsVert(pw);
+ XtWidgetGeometry request, reply;
+
+ ForAllPanes(pw, childP)
+ if (pw->paned.resize_children_to_pref || PaneInfo(*childP)->size == 0 ||
+ PaneInfo(*childP)->resize_to_pref) {
+ if (PaneInfo(*childP)->preferred_size != PANED_ASK_CHILD)
+ PaneInfo(*childP)->wp_size = PaneInfo(*childP)->preferred_size;
+ else {
+ if(vert) {
+ request.request_mode = CWWidth;
+ request.width = off_size;
+ }
+ else {
+ request.request_mode = CWHeight;
+ request.height = off_size;
+ }
+
+ if ((XtQueryGeometry(*childP, &request, &reply)
+ == XtGeometryAlmost)
+ && (reply.request_mode = (vert ? CWHeight : CWWidth)))
+ PaneInfo(*childP)->wp_size = GetRequestInfo(&reply, vert);
+ else
+ PaneInfo(*childP)->wp_size = PaneSize(*childP, vert);
+ }
+
+ PaneInfo(*childP)->size = PaneInfo(*childP)->wp_size;
+ }
+}
+
+/*
+ * Function:
+ * ChangeAllGripCursors
+ *
+ * Parameters:
+ * pw - paned widget
+ *
+ * Description:
+ * Changes all the grip cursors.
+ */
+static void
+ChangeAllGripCursors(PanedWidget pw)
+{
+ Widget *childP;
+
+ ForAllPanes(pw, childP) {
+ Arg arglist[1];
+ Cursor cursor;
+
+ if ((cursor = pw->paned.grip_cursor) == None) {
+ if (IsVert(pw))
+ cursor = pw->paned.v_grip_cursor;
+ else
+ cursor = pw->paned.h_grip_cursor;
+ }
+
+ if (HasGrip(*childP)) {
+ XtSetArg(arglist[0], XtNcursor, cursor);
+ XtSetValues(PaneInfo(*childP)->grip, arglist, 1);
+ }
+ }
+}
+
+/*
+ * Function:
+ * PushPaneStack
+ *
+ * Parameters:
+ * pw - paned widget
+ * pane - pane that we are pushing
+ *
+ * Description:
+ * Pushes a value onto the pane stack.
+ */
+static void
+PushPaneStack(PanedWidget pw, Pane pane)
+{
+ PaneStack *stack = (PaneStack *)XtMalloc(sizeof(PaneStack));
+
+ stack->next = pw->paned.stack;
+ stack->pane = pane;
+ stack->start_size = pane->size;
+
+ pw->paned.stack = stack;
+}
+
+/*
+ * Function:
+ * GetPaneStack
+ *
+ * Parameters:
+ * pw - paned widget
+ * shrink - True if we want to shrink this pane, False otherwise
+ * pane - pane that we are popping (return)
+ * start_size - size that this pane started at (return)
+ *
+ * Description:
+ * Gets the top value from the pane stack.
+ */
+static void
+GetPaneStack(PanedWidget pw, Bool shrink, Pane *pane, int *start_size)
+{
+ if (pw->paned.stack == NULL) {
+ *pane = NULL;
+ return;
+ }
+
+ *pane = pw->paned.stack->pane;
+ *start_size = pw->paned.stack->start_size;
+
+ if (shrink != ((*pane)->size > *start_size))
+ *pane = NULL;
+}
+
+/*
+ * Function:
+ * PopPaneStack
+ *
+ * Parameters:
+ * pw - paned widget
+ *
+ * Description:
+ * Pops the top item off the pane stack.
+ *
+ * Returns: True if this is not the last element on the stack
+ */
+static Bool
+PopPaneStack(PanedWidget pw)
+{
+ PaneStack *stack = pw->paned.stack;
+
+ if (stack == NULL)
+ return (False);
+
+ pw->paned.stack = stack->next;
+ XtFree((char *)stack);
+
+ if (pw->paned.stack == NULL)
+ return (False);
+
+ return (True);
+}
+
+/*
+ * Function:
+ * ClearPaneStack
+ *
+ * Parameters:
+ * pw - paned widget
+ *
+ * Description:
+ * Removes all entries from the pane stack.
+ */
+static void
+ClearPaneStack(PanedWidget pw)
+{
+ while(PopPaneStack(pw))
+ ;
+}
+
+static void
+XawPanedClassInitialize(void)
+{
+ XawInitializeWidgetSet();
+ XtAddConverter(XtRString, XtROrientation, XmuCvtStringToOrientation,
+ NULL, 0);
+ XtSetTypeConverter(XtROrientation, XtRString, XmuCvtOrientationToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+
+/* The Geometry Manager only allows changes after Realize if
+ * allow_resize is True in the constraints record.
+ *
+ * For vertically paned widgets:
+ *
+ * It only allows height changes, but offers the requested height
+ * as a compromise if both width and height changes were requested.
+ *
+ * For horizontal widgets the converse is true.
+ * As all good Geometry Managers should, we will return No if the
+ * request will have no effect; i.e. when the requestor is already
+ * of the desired geometry.
+ */
+static XtGeometryResult
+XawPanedGeometryManager(Widget w, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+ PanedWidget pw = (PanedWidget)XtParent(w);
+ XtGeometryMask mask = request->request_mode;
+ Dimension old_size, old_wpsize, old_paned_size;
+ Pane pane = PaneInfo(w);
+ Boolean vert = IsVert(pw);
+ Dimension on_size, off_size;
+ XtGeometryResult result;
+ Boolean almost = False;
+
+ /*
+ * If any of the following is true, disallow the geometry change
+ *
+ * o The paned widget is realized and allow_resize is false for the pane
+ * o The child did not ask to change the on_size
+ * o The request is not a width or height request
+ * o The requested size is the same as the current size
+ */
+
+ if ((XtIsRealized((Widget)pw) && !pane->allow_resize)
+ || !(mask & (vert ? CWHeight : CWWidth))
+ ||(mask & ~(CWWidth | CWHeight))
+ || GetRequestInfo(request, vert) == PaneSize(w, vert))
+ return (XtGeometryNo);
+
+ old_paned_size = PaneSize((Widget)pw, vert);
+ old_wpsize = pane->wp_size;
+ old_size = pane->size;
+
+ pane->wp_size = pane->size = GetRequestInfo(request, vert);
+
+ AdjustPanedSize(pw, PaneSize((Widget)pw, !vert), &result, &on_size,
+ &off_size);
+
+ /*
+ * Fool the Refigure Locations proc to thinking that we are
+ * a different on_size
+ */
+
+ if (result != XtGeometryNo) {
+ if (vert)
+ XtHeight(pw) = on_size;
+ else
+ XtWidth(pw) = on_size;
+ }
+
+ RefigureLocations(pw, PaneIndex(w), AnyPane);
+
+ /*
+ * Set up reply struct and reset core on_size
+ */
+ if (vert) {
+ XtHeight(pw) = old_paned_size;
+ reply->height = pane->size;
+ reply->width = off_size;
+ }
+ else {
+ XtWidth(pw) = old_paned_size;
+ reply->height = off_size;
+ reply->width = pane->size;
+ }
+
+ /*
+ * IF either of the following is true
+ *
+ * o There was a "off_size" request and the new "off_size" is different
+ * from that requested
+ * o There was no "off_size" request and the new "off_size" is different
+ *
+ * o The "on_size" we will allow is different from that requested
+ *
+ * THEN: set almost
+ */
+ if (!((vert ? CWWidth : CWHeight) & mask)) {
+ if (vert)
+ request->width = XtWidth(w);
+ else
+ request->height = XtHeight(w);
+ }
+
+ almost = GetRequestInfo(request, !vert) != GetRequestInfo(reply, !vert);
+ almost |= (GetRequestInfo(request, vert) != GetRequestInfo(reply, vert));
+
+ if ((mask & XtCWQueryOnly) || almost) {
+ pane->wp_size = old_wpsize;
+ pane->size = old_size;
+ RefigureLocations(pw, PaneIndex(w), AnyPane);
+ reply->request_mode = CWWidth | CWHeight;
+ if (almost)
+ return (XtGeometryAlmost);
+ }
+ else {
+ AdjustPanedSize(pw, PaneSize((Widget) pw, !vert), NULL, NULL, NULL);
+ CommitNewLocations(pw); /* layout already refigured */
+ }
+
+ return (XtGeometryDone);
+}
+
+/*ARGSUSED*/
+static void
+XawPanedInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ PanedWidget pw = (PanedWidget)cnew;
+
+ GetGCs((Widget)pw);
+
+ pw->paned.recursively_called = False;
+ pw->paned.stack = NULL;
+ pw->paned.resize_children_to_pref = True;
+ pw->paned.num_panes = 0;
+}
+
+static void
+XawPanedRealize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
+{
+ PanedWidget pw = (PanedWidget)w;
+ Widget *childP;
+
+ if ((attributes->cursor = pw->paned.cursor) != None)
+ *valueMask |= CWCursor;
+
+ (*SuperClass->core_class.realize)(w, valueMask, attributes);
+
+ /*
+ * Before we commit the new locations we need to realize all the panes and
+ * their grips
+ */
+ ForAllPanes(pw, childP) {
+ XtRealizeWidget(*childP);
+ if (HasGrip(*childP))
+ XtRealizeWidget(PaneInfo(*childP)->grip);
+ }
+
+ RefigureLocationsAndCommit(w);
+ pw->paned.resize_children_to_pref = False;
+}
+
+static void
+XawPanedDestroy(Widget w)
+{
+ ReleaseGCs(w);
+}
+
+static void
+ReleaseGCs(Widget w)
+{
+ PanedWidget pw = (PanedWidget)w;
+
+ XtReleaseGC(w, pw->paned.normgc);
+ XtReleaseGC(w, pw->paned.invgc);
+ XtReleaseGC(w, pw->paned.flipgc);
+}
+
+static void
+XawPanedInsertChild(Widget w)
+{
+ Pane pane = PaneInfo(w);
+
+ /* insert the child widget in the composite children list with the
+ superclass insert_child routine
+ */
+ (*SuperClass->composite_class.insert_child)(w);
+
+ if (!IsPane(w))
+ return;
+
+ if (pane->show_grip == True) {
+ CreateGrip(w);
+ if (pane->min == PANED_GRIP_SIZE)
+ pane->min = PaneSize(pane->grip, IsVert((PanedWidget)XtParent(w)));
+ }
+ else {
+ if (pane->min == PANED_GRIP_SIZE)
+ pane->min = 1;
+ pane->grip = NULL;
+ }
+
+ pane->size = 0;
+ pane->paned_adjusted_me = False;
+}
+
+static void
+XawPanedDeleteChild(Widget w)
+{
+ /* remove the subwidget info and destroy the grip */
+ if (IsPane(w) && HasGrip(w))
+ XtDestroyWidget(PaneInfo(w)->grip);
+
+ /* delete the child widget in the composite children list with the
+ superclass delete_child routine
+ */
+ (*SuperClass->composite_class.delete_child)(w);
+}
+
+static void
+XawPanedChangeManaged(Widget w)
+{
+ PanedWidget pw = (PanedWidget)w;
+ Boolean vert = IsVert(pw);
+ Dimension size;
+ Widget *childP;
+
+ if (pw->paned.recursively_called++)
+ return;
+
+ /*
+ * If the size is zero then set it to the size of the widest or tallest pane
+ */
+
+ if ((size = PaneSize((Widget)pw, !vert)) == 0) {
+ size = 1;
+ ForAllChildren(pw, childP)
+ if (XtIsManaged(*childP) && (PaneSize(*childP, !vert) > size))
+ size = PaneSize(*childP, !vert);
+ }
+
+ ManageAndUnmanageGrips(pw);
+ pw->paned.recursively_called = False;
+ ResortChildren(pw);
+
+ pw->paned.num_panes = 0;
+ ForAllChildren(pw, childP)
+ if (IsPane(*childP)) {
+ if (XtIsManaged(*childP)) {
+ Pane pane = PaneInfo(*childP);
+
+ if (HasGrip(*childP))
+ PaneInfo(pane->grip)->position = pw->paned.num_panes;
+ pane->position = pw->paned.num_panes; /* TEMPORY -CDP 3/89 */
+ pw->paned.num_panes++;
+ }
+ else
+ break; /* This list is already sorted */
+ }
+
+ SetChildrenPrefSizes((PanedWidget) w, size);
+
+ /*
+ * ForAllPanes can now be used
+ */
+ if (PaneSize((Widget) pw, vert) == 0)
+ AdjustPanedSize(pw, size, NULL, NULL, NULL);
+
+ if (XtIsRealized((Widget)pw))
+ RefigureLocationsAndCommit((Widget)pw);
+}
+
+static void
+XawPanedResize(Widget w)
+{
+ SetChildrenPrefSizes((PanedWidget)w,
+ PaneSize(w, !IsVert((PanedWidget)w)));
+ RefigureLocationsAndCommit(w);
+}
+
+/*ARGSUSED*/
+static void
+XawPanedRedisplay(Widget w, XEvent *event, Region region)
+{
+ DrawInternalBorders((PanedWidget)w);
+}
+
+/*ARGSUSED*/
+static Boolean
+XawPanedSetValues(Widget old, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ PanedWidget old_pw = (PanedWidget)old;
+ PanedWidget new_pw = (PanedWidget)cnew;
+ Boolean redisplay = False;
+
+ if ((old_pw->paned.cursor != new_pw->paned.cursor) && XtIsRealized(cnew))
+ XDefineCursor(XtDisplay(cnew), XtWindow(cnew), new_pw->paned.cursor);
+
+ if (old_pw->paned.internal_bp != new_pw->paned.internal_bp ||
+ old_pw->core.background_pixel != new_pw->core.background_pixel) {
+ ReleaseGCs(old);
+ GetGCs(cnew);
+ redisplay = True;
+ }
+
+ if (old_pw->paned.grip_cursor != new_pw->paned.grip_cursor ||
+ old_pw->paned.v_grip_cursor != new_pw->paned.v_grip_cursor ||
+ old_pw->paned.h_grip_cursor != new_pw->paned.h_grip_cursor)
+ ChangeAllGripCursors(new_pw);
+
+ if (IsVert(old_pw) != IsVert(new_pw)) {
+ /*
+ * We are fooling the paned widget into thinking that is needs to
+ * fully refigure everything, which is what we want
+ */
+ if (IsVert(new_pw))
+ XtWidth(new_pw) = 0;
+ else
+ XtHeight(new_pw) = 0;
+
+ new_pw->paned.resize_children_to_pref = True;
+ XawPanedChangeManaged(cnew); /* Seems weird, but does the right thing */
+ new_pw->paned.resize_children_to_pref = False;
+ if (new_pw->paned.grip_cursor == None)
+ ChangeAllGripCursors(new_pw);
+ return (True);
+ }
+
+ if (old_pw->paned.internal_bw != new_pw->paned.internal_bw) {
+ AdjustPanedSize(new_pw, PaneSize(cnew, !IsVert(old_pw)),
+ NULL, NULL, NULL);
+ RefigureLocationsAndCommit(cnew);
+ return (True); /* We have done a full configuration, return */
+ }
+
+ if (old_pw->paned.grip_indent != new_pw->paned.grip_indent &&
+ XtIsRealized(cnew)) {
+ CommitNewLocations(new_pw);
+ redisplay = True;
+ }
+
+ return (redisplay);
+}
+
+/*ARGSUSED*/
+static Boolean
+XawPanedPaneSetValues(Widget old, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ Pane old_pane = PaneInfo(old);
+ Pane new_pane = PaneInfo(cnew);
+ Boolean redisplay = False;
+
+ /* Check for new min and max */
+ if (old_pane->min != new_pane->min || old_pane->max != new_pane->max)
+ XawPanedSetMinMax(cnew, (int)new_pane->min, (int)new_pane->max);
+
+ /* Check for change in XtNshowGrip */
+ if (old_pane->show_grip != new_pane->show_grip) {
+ if (new_pane->show_grip == True) {
+ CreateGrip(cnew);
+ if (XtIsRealized(XtParent(cnew))) {
+ if (XtIsManaged(cnew)) /* if paned is unrealized this will
+ happen automatically at realize time
+ */
+ XtManageChild(PaneInfo(cnew)->grip); /* manage the grip */
+ XtRealizeWidget(PaneInfo(cnew)->grip); /* realize the grip */
+ CommitNewLocations((PanedWidget)XtParent(cnew));
+ }
+ }
+ else if (HasGrip(old)) {
+ XtDestroyWidget(old_pane->grip);
+ new_pane->grip = NULL;
+ redisplay = True;
+ }
+ }
+
+ return (redisplay);
+}
+
+/*
+ * Public routines
+ */
+/*
+ * Function:
+ * XawPanedSetMinMax
+ *
+ * Parameters:
+ * widget - widget that is a child of the Paned widget
+ * min - new min and max size for the pane
+ * max - ""
+ *
+ * Description:
+ * Sets the min and max size for a pane.
+ */
+void
+XawPanedSetMinMax(Widget widget, int min, int max)
+{
+ Pane pane = PaneInfo(widget);
+
+ pane->min = min;
+ pane->max = max;
+ RefigureLocationsAndCommit(widget->core.parent);
+}
+
+/*
+ * Function:
+ * XawPanedGetMinMax
+ *
+ * Parameters:
+ * widget - widget that is a child of the Paned widget
+ * min - current min and max size for the pane (return)
+ * max - ""
+ *
+ * Description:
+ * Gets the min and max size for a pane.
+ */
+void
+XawPanedGetMinMax(Widget widget, int *min, int *max)
+{
+ Pane pane = PaneInfo(widget);
+
+ *min = pane->min;
+ *max = pane->max;
+}
+
+/*
+ * Function:
+ * XawPanedSetRefigureMode
+ *
+ * Parameters:
+ * w - paned widget
+ * mode - if False then inhibit refigure
+ *
+ * Description:
+ * Allows a flag to be set the will inhibit
+ * the paned widgets relayout routine.
+ */
+void
+XawPanedSetRefigureMode(Widget w,
+#if NeedWidePrototypes
+ int mode
+#else
+ Boolean mode
+#endif
+)
+{
+ ((PanedWidget)w)->paned.refiguremode = mode;
+ RefigureLocationsAndCommit(w);
+}
+
+/*
+ * Function:
+ * XawPanedGetNumSub
+ *
+ * Parameters:
+ * w - paned widget
+ *
+ * Description:
+ * Returns the number of panes in the paned widget.
+ * Returns:
+ * the number of panes in the paned widget
+ */
+int
+XawPanedGetNumSub(Widget w)
+{
+ return (((PanedWidget)w)->paned.num_panes);
+}
+
+/*
+ * Function:
+ * XawPanedAllowResize
+ *
+ * Parameters:
+ * widget - child of the paned widget
+ *
+ * Description:
+ * Allows a flag to be set that determines if the paned
+ * widget will allow geometry requests from this child.
+ */
+void
+XawPanedAllowResize(Widget widget,
+#if NeedWidePrototypes
+ int allow_resize
+#else
+ Boolean allow_resize
+#endif
+)
+{
+ PaneInfo(widget)->allow_resize = allow_resize;
+}
diff --git a/nx-X11/lib/Xaw/Paned.h b/nx-X11/lib/Xaw/Paned.h
new file mode 100644
index 000000000..aaa532030
--- /dev/null
+++ b/nx-X11/lib/Xaw/Paned.h
@@ -0,0 +1,264 @@
+/*
+* $Xorg: Paned.h,v 1.5 2001/02/09 02:03:45 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Paned.h,v 1.6 2001/01/17 19:42:28 dawes Exp $ */
+
+/*
+ * Paned.h - Paned Composite Widget's public header file.
+ *
+ * Updated and significantly modifided from the Athena VPaned Widget.
+ *
+ * Date: March 1, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _XawPaned_h
+#define _XawPaned_h
+
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Converters.h>
+
+/* RESOURCES:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ betweenCursor Cursor Cursor **
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ cursor Cursor Cursor None
+ destroyCallback Callback Pointer NULL
+ height Height Dimension 0
+ gripIndent GripIndent Position 16
+ gripCursor Cursor Cursor **
+ horizontalGripCursol Cursor Cursor sb_h_double_arrow
+ horizontalBetweencursor Cursor Cursor sb_up_arrow
+ internalBorderColor BorderColor Pixel XtDefaultForeground
+ internalBorderWidth BorderWidth Position 1
+ leftCursor Cursor Cursor sb_left_arrow
+ lowerCursor Cursor Cursor sb_down_arrow
+ mappedWhenManaged MappedWhenManaged Boolean True
+ orientation Orientation XtOrientation XtorientVertical
+ refigureMode Boolean Boolean On
+ rightCursor Cursor Cursor sb_right_arrow
+ sensitive Sensitive Boolean True
+ upperCursor Cursor Cursor sb_up_arrow
+ verticalBetweenCursor Cursor Cursor sb_left_arrow
+ verticalGripCursor Cursor Cursor sb_v_double_arrow
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+** These resources now are set to the vertical or horizontal cursor
+ depending upon orientation, by default. If a value is specified here
+ then that cursor will be used reguardless of orientation.
+
+
+CONSTRAINT RESOURCES:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ allowResize Boolean Boolean False
+ max Max Dimension unlimited
+ min Min Dimension Grip Size
+ preferredPaneSize PreferredPaneSize Dimension PANED_ASK_CHILD
+ resizeToPreferred Boolean Boolean False
+ showGrip ShowGrip Boolean True
+ skipAdjust Boolean Boolean False
+
+*/
+
+#define PANED_ASK_CHILD 0
+#define PANED_GRIP_SIZE 0
+
+#define XtNallowResize "allowResize"
+#define XtNbetweenCursor "betweenCursor"
+#define XtNverticalBetweenCursor "verticalBetweenCursor"
+#define XtNhorizontalBetweenCursor "horizontalBetweenCursor"
+#define XtNgripCursor "gripCursor"
+#define XtNgripIndent "gripIndent"
+#define XtNhorizontalGripCursor "horizontalGripCursor"
+#define XtNinternalBorderColor "internalBorderColor"
+#define XtNinternalBorderWidth "internalBorderWidth"
+#define XtNleftCursor "leftCursor"
+#define XtNlowerCursor "lowerCursor"
+#define XtNrefigureMode "refigureMode"
+#define XtNposition "position"
+#define XtNmin "min"
+#define XtNmax "max"
+#define XtNpreferredPaneSize "preferredPaneSize"
+#define XtNresizeToPreferred "resizeToPreferred"
+#define XtNrightCursor "rightCursor"
+#define XtNshowGrip "showGrip"
+#define XtNskipAdjust "skipAdjust"
+#define XtNupperCursor "upperCursor"
+#define XtNverticalGripCursor "verticalGripCursor"
+
+#define XtCGripIndent "GripIndent"
+#define XtCMin "Min"
+#define XtCMax "Max"
+#define XtCPreferredPaneSize "PreferredPaneSize"
+#define XtCShowGrip "ShowGrip"
+
+/* Class record constant */
+extern WidgetClass panedWidgetClass;
+
+typedef struct _PanedClassRec *PanedWidgetClass;
+typedef struct _PanedRec *PanedWidget;
+
+/*
+ * Public Procedures
+ */
+
+_XFUNCPROTOBEGIN
+
+/*
+ * Function:
+ * XawPanedSetMinMax
+ *
+ * Parameters:
+ * widget - widget that is a child of the Paned widget
+ * min - new min and max size for the pane
+ * max - ""
+ *
+ * Description:
+ * Sets the min and max size for a pane.
+ */
+void XawPanedSetMinMax
+(
+ Widget w,
+ int min,
+ int max
+ );
+
+/*
+ * Function:
+ * XawPanedGetMinMax
+ *
+ * Parameters:
+ * widget - widget that is a child of the Paned widget
+ * min - return the current min and max size for the pane
+ * max - ""
+ *
+ * Description:
+ * Gets the min and max size for a pane.
+ */
+void XawPanedGetMinMax
+(
+ Widget w,
+ int *min_return,
+ int *max_return
+ );
+
+/*
+ * Function:
+ * XawPanedSetRefigureMode
+ *
+ * Parameters:
+ * w - paned widget
+ * mode - if False then inhibit refigure
+ *
+ * Description:
+ * Allows a flag to be set the will inhibit the paned widgets
+ * relayout routine.
+ */
+void XawPanedSetRefigureMode
+(
+ Widget w,
+#if NeedWidePrototypes
+ int mode
+#else
+ Boolean mode
+#endif
+ );
+
+/*
+ * Function:
+ * XawPanedGetNumSub
+ *
+ * Parameters:
+ * w - paned widget
+ *
+ * Returns:
+ * Number of panes in the paned widget.
+ */
+int XawPanedGetNumSub
+(
+ Widget w
+ );
+
+/*
+ * Function:
+ * XawPanedAllowResize
+ *
+ * Parameters:
+ * widget - child of the paned widget
+ *
+ * Description:
+ * Allows a flag to be set that determines if the paned widget will
+ * allow geometry requests from this child
+ */
+void XawPanedAllowResize
+(
+ Widget w,
+#if NeedWidePrototypes
+ int allow_resize
+#else
+ Boolean allow_resize
+#endif
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XawPaned_h */
diff --git a/nx-X11/lib/Xaw/PanedP.h b/nx-X11/lib/Xaw/PanedP.h
new file mode 100644
index 000000000..a94b0f34d
--- /dev/null
+++ b/nx-X11/lib/Xaw/PanedP.h
@@ -0,0 +1,180 @@
+/***********************************************************
+
+ $Xorg: PanedP.h,v 1.4 2001/02/09 02:03:45 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/PanedP.h,v 1.7 2001/01/17 19:42:28 dawes Exp $ */
+
+/*
+ * Updated and significantly modified from the Athena VPaned Widget.
+ *
+ * Date: March 1, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _XawPanedP_h
+#define _XawPanedP_h
+
+#include <X11/Xaw/Paned.h>
+
+/* New fields for the Paned widget class record */
+typedef struct _PanedClassPart {
+ XtPointer extension;
+} PanedClassPart;
+
+/* Full Class record declaration */
+typedef struct _PanedClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ConstraintClassPart constraint_class;
+ PanedClassPart paned_class;
+} PanedClassRec;
+
+extern PanedClassRec panedClassRec;
+
+/* Paned constraint record */
+typedef struct _PanedConstraintsPart {
+ /* Resources */
+ Dimension min; /* Minimum height */
+ Dimension max; /* Maximum height */
+ Boolean allow_resize; /* True if child resize requests are ok */
+ Boolean show_grip; /* True if child will have grip below it,
+ when it is not the bottom pane */
+ Boolean skip_adjust; /* True if child's height should not be
+ changed without explicit user action */
+ int position; /* position location in Paned (relative to
+ other children) ** NIY ** */
+ Dimension preferred_size; /* The Preferred size of the pane.
+ If this is zero then ask child for size*/
+ Boolean resize_to_pref; /* resize this pane to its preferred size
+ on a resize or change managed after
+ realize */
+
+ /* Private state */
+ Position delta; /* Desired Location */
+ Position olddelta; /* The last value of dy */
+ Boolean paned_adjusted_me; /* Has the vpaned adjusted this widget w/o
+ user interaction to make things fit? */
+ Dimension wp_size; /* widget's preferred size */
+ int size; /* the size the widget will actually get */
+ Widget grip; /* The grip for this child */
+} PanedConstraintsPart, *Pane;
+
+typedef struct _PanedConstraintsRec {
+ PanedConstraintsPart paned;
+} PanedConstraintsRec, *PanedConstraints;
+
+/*
+ * The Pane Stack Structure
+ */
+typedef struct _PaneStack {
+ struct _PaneStack *next; /* The next element on the stack */
+ Pane pane; /* The pane in this element on the stack */
+ int start_size; /* The size of this element when it
+ was pushed onto the stack */
+} PaneStack;
+
+/* New Fields for the Paned widget record */
+typedef struct {
+ /* resources */
+ Position grip_indent; /* Location of grips (offset
+ from right margin) */
+ Boolean refiguremode; /* Whether to refigure changes
+ right now */
+ XtTranslations grip_translations; /* grip translation table */
+ Pixel internal_bp; /* color of internal borders */
+ Dimension internal_bw; /* internal border width */
+ XtOrientation orientation; /* Orientation of paned widget */
+
+ Cursor cursor; /* Cursor for paned window */
+ Cursor grip_cursor; /* inactive grip cursor */
+ Cursor v_grip_cursor; /* inactive vert grip cursor */
+ Cursor h_grip_cursor; /* inactive horiz grip cursor */
+ Cursor adjust_this_cursor; /* active grip cursor: T */
+ Cursor v_adjust_this_cursor; /* active vert grip cursor: T */
+ Cursor h_adjust_this_cursor; /* active horiz grip cursor: T */
+
+ /* vertical */
+ Cursor adjust_upper_cursor; /* active grip cursor: U */
+ Cursor adjust_lower_cursor; /* active grip cursor: D */
+
+ /* horizontal */
+ Cursor adjust_left_cursor; /* active grip cursor: U */
+ Cursor adjust_right_cursor; /* active grip cursor: D */
+
+ /* private */
+ Boolean recursively_called; /* for ChangeManaged */
+ Boolean resize_children_to_pref; /* override constrain resources
+ and resize all children to
+ preferred size */
+ int start_loc; /* mouse origin when adjusting */
+ Widget whichadd; /* Which pane to add changes to */
+ Widget whichsub; /* Which pane to sub changes from */
+ GC normgc; /* GC to use when drawing borders */
+ GC invgc; /* GC to use when erasing borders */
+ GC flipgc; /* GC to use when animating borders */
+ int num_panes; /* count of managed panes */
+ PaneStack *stack; /* The pane stack for this widget */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} PanedPart;
+
+/*
+ * Full instance record declaration
+ */
+typedef struct _PanedRec {
+ CorePart core;
+ CompositePart composite;
+ ConstraintPart constraint;
+ PanedPart paned;
+} PanedRec;
+
+#endif /* _XawPanedP_h */
diff --git a/nx-X11/lib/Xaw/Panner.c b/nx-X11/lib/Xaw/Panner.c
new file mode 100644
index 000000000..e0ae2c20a
--- /dev/null
+++ b/nx-X11/lib/Xaw/Panner.c
@@ -0,0 +1,1082 @@
+/*
+ * $Xorg: Panner.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 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.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xaw/Panner.c,v 3.8 2001/07/25 15:04:49 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <ctype.h>
+#include <math.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xos.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/Drawing.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xaw/PannerP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+#if defined(ISC) && __STDC__ && !defined(ISC30)
+extern double atof(char *);
+#else
+#include <stdlib.h> /* for atof() */
+#endif
+
+/*
+ * Class Methods
+ */
+static void XawPannerDestroy(Widget);
+static void XawPannerInitialize(Widget, Widget, ArgList, Cardinal*);
+static XtGeometryResult XawPannerQueryGeometry(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawPannerRealize(Widget, XtValueMask*, XSetWindowAttributes*);
+static void XawPannerRedisplay(Widget, XEvent*, Region);
+static void XawPannerResize(Widget);
+static Boolean XawPannerSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
+static void XawPannerSetValuesAlmost(Widget, Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+
+/*
+ * Prototypes
+ */
+static void check_knob(PannerWidget, Bool);
+static void get_default_size(PannerWidget, Dimension*, Dimension*);
+static Bool get_event_xy(PannerWidget, XEvent*, int*, int*);
+static void move_shadow(PannerWidget);
+static int parse_page_string(char*, int, int, Bool*);
+static void rescale(PannerWidget);
+static void reset_shadow_gc(PannerWidget);
+static void reset_slider_gc(PannerWidget);
+static void reset_xor_gc(PannerWidget);
+static void scale_knob(PannerWidget, Bool, Bool);
+
+/*
+ * Actions
+ */
+static void ActionAbort(Widget, XEvent*, String*, Cardinal*);
+static void ActionMove(Widget, XEvent*, String*, Cardinal*);
+static void ActionNotify(Widget, XEvent*, String*, Cardinal*);
+static void ActionPage(Widget, XEvent*, String*, Cardinal*);
+static void ActionSet(Widget, XEvent*, String*, Cardinal*);
+static void ActionStart(Widget, XEvent*, String*, Cardinal*);
+static void ActionStop(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * From Xmu/Distinct.c
+ */
+Bool XmuDistinguishablePixels(Display*, Colormap, unsigned long*, int);
+
+/*
+ * Initialization
+ */
+static char defaultTranslations[] =
+"<Btn1Down>:" "start()\n"
+"<Btn1Motion>:" "move()\n"
+"<Btn1Up>:" "notify() stop()\n"
+"<Btn2Down>:" "abort()\n"
+":<Key>KP_Enter:" "set(rubberband,toggle)\n"
+"<Key>space:" "page(+1p,+1p)\n"
+"<Key>Delete:" "page(-1p,-1p)\n"
+":<Key>KP_Delete:" "page(-1p,-1p)\n"
+"<Key>BackSpace:" "page(-1p,-1p)\n"
+"<Key>Left:" "page(-.5p,+0)\n"
+":<Key>KP_Left:" "page(-.5p,+0)\n"
+"<Key>Right:" "page(+.5p,+0)\n"
+":<Key>KP_Right:" "page(+.5p,+0)\n"
+"<Key>Up:" "page(+0,-.5p)\n"
+":<Key>KP_Up:" "page(+0,-.5p)\n"
+"<Key>Down:" "page(+0,+.5p)\n"
+":<Key>KP_Down:" "page(+0,+.5p)\n"
+"<Key>Home:" "page(0,0)\n"
+":<Key>KP_Home:" "page(0,0)\n"
+;
+
+static XtActionsRec actions[] = {
+ {"start", ActionStart}, /* start tmp graphics */
+ {"stop", ActionStop}, /* stop tmp graphics */
+ {"abort", ActionAbort}, /* punt */
+ {"move", ActionMove}, /* move tmp graphics on Motion event */
+ {"page", ActionPage}, /* page around usually from keyboard */
+ {"notify", ActionNotify}, /* callback new position */
+ {"set", ActionSet}, /* set various parameters */
+};
+
+#define offset(field) XtOffsetOf(PannerRec, panner.field)
+static XtResource resources[] = {
+ {
+ XtNallowOff,
+ XtCAllowOff,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(allow_off),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNresize,
+ XtCResize,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(resize_to_pref),
+ XtRImmediate,
+ (XtPointer)True
+ },
+ {
+ XtNreportCallback,
+ XtCReportCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(report_callbacks),
+ XtRCallback,
+ NULL
+ },
+ {
+ XtNdefaultScale,
+ XtCDefaultScale,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(default_scale),
+ XtRImmediate,
+ (XtPointer)PANNER_DEFAULT_SCALE
+ },
+ {
+ XtNrubberBand,
+ XtCRubberBand,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(rubber_band),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(foreground),
+ XtRString,
+ (XtPointer)XtDefaultBackground
+ },
+ {
+ XtNinternalSpace,
+ XtCInternalSpace,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(internal_border),
+ XtRImmediate,
+ (XtPointer)4
+ },
+ {
+ XtNlineWidth,
+ XtCLineWidth,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(line_width),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNcanvasWidth,
+ XtCCanvasWidth,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(canvas_width),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNcanvasHeight,
+ XtCCanvasHeight,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(canvas_height),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNsliderX,
+ XtCSliderX,
+ XtRPosition,
+ sizeof(Position),
+ offset(slider_x),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNsliderY,
+ XtCSliderY,
+ XtRPosition,
+ sizeof(Position),
+ offset(slider_y),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNsliderWidth,
+ XtCSliderWidth,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(slider_width),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNsliderHeight,
+ XtCSliderHeight,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(slider_height),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNshadowColor,
+ XtCShadowColor,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(shadow_color),
+ XtRString,
+ (XtPointer)XtDefaultForeground
+ },
+ {
+ XtNshadowThickness,
+ XtCShadowThickness,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(shadow_thickness),
+ XtRImmediate,
+ (XtPointer)2
+ },
+ {
+ XtNbackgroundStipple,
+ XtCBackgroundStipple,
+ XtRString,
+ sizeof(String),
+ offset(stipple_name),
+ XtRImmediate,
+ NULL
+ },
+};
+#undef offset
+
+#define Superclass (&simpleClassRec)
+PannerClassRec pannerClassRec = {
+ /* core */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "Panner", /* class_name */
+ sizeof(PannerRec), /* widget_size */
+ XawInitializeWidgetSet, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ XawPannerInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XawPannerRealize, /* realize */
+ actions, /* actions */
+ XtNumber(actions), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ XawPannerDestroy, /* destroy */
+ XawPannerResize, /* resize */
+ XawPannerRedisplay, /* expose */
+ XawPannerSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XawPannerSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ defaultTranslations, /* tm_table */
+ XawPannerQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* simple */
+ {
+ XtInheritChangeSensitive, /* change_sensitive */
+ },
+ /* panner */
+ {
+ NULL, /* extension */
+ }
+};
+
+WidgetClass pannerWidgetClass = (WidgetClass) &pannerClassRec;
+
+
+/*
+ * Implementation
+ */
+static void
+reset_shadow_gc(PannerWidget pw)
+{
+ XtGCMask valuemask = GCForeground;
+ XGCValues values;
+ unsigned long pixels[3];
+
+ if (pw->panner.shadow_gc)
+ XtReleaseGC((Widget)pw, pw->panner.shadow_gc);
+
+ pixels[0] = pw->panner.foreground;
+ pixels[1] = pw->core.background_pixel;
+ pixels[2] = pw->panner.shadow_color;
+
+ if (!pw->panner.stipple_name &&
+ !XmuDistinguishablePixels(XtDisplay(pw), pw->core.colormap,
+ pixels, 3) &&
+ XmuDistinguishablePixels(XtDisplay(pw), pw->core.colormap,
+ pixels, 2)) {
+ valuemask = GCTile | GCFillStyle;
+ values.fill_style = FillTiled;
+ values.tile = XmuCreateStippledPixmap(XtScreen((Widget)pw),
+ pw->panner.foreground,
+ pw->core.background_pixel,
+ pw->core.depth);
+ }
+ else {
+ if (!pw->panner.line_width &&
+ !XmuDistinguishablePixels(XtDisplay(pw), pw->core.colormap,
+ pixels, 2))
+ pw->panner.line_width = 1;
+ valuemask = GCForeground;
+ values.foreground = pw->panner.shadow_color;
+ }
+ if (pw->panner.line_width > 0) {
+ values.line_width = pw->panner.line_width;
+ valuemask |= GCLineWidth;
+ }
+
+ pw->panner.shadow_gc = XtGetGC((Widget)pw, valuemask, &values);
+}
+
+static void
+reset_slider_gc(PannerWidget pw)
+{
+ XtGCMask valuemask = GCForeground;
+ XGCValues values;
+
+ if (pw->panner.slider_gc)
+ XtReleaseGC((Widget)pw, pw->panner.slider_gc);
+
+ values.foreground = pw->panner.foreground;
+
+ pw->panner.slider_gc = XtGetGC((Widget)pw, valuemask, &values);
+}
+
+static void
+reset_xor_gc(PannerWidget pw)
+{
+ if (pw->panner.xor_gc)
+ XtReleaseGC((Widget)pw, pw->panner.xor_gc);
+
+ if (pw->panner.rubber_band) {
+ XtGCMask valuemask = (GCForeground | GCFunction);
+ XGCValues values;
+ Pixel tmp;
+
+ tmp = (pw->panner.foreground == pw->core.background_pixel ?
+ pw->panner.shadow_color : pw->panner.foreground);
+ values.foreground = tmp ^ pw->core.background_pixel;
+ values.function = GXxor;
+ if (pw->panner.line_width > 0) {
+ valuemask |= GCLineWidth;
+ values.line_width = pw->panner.line_width;
+ }
+ pw->panner.xor_gc = XtGetGC((Widget)pw, valuemask, &values);
+ }
+ else
+ pw->panner.xor_gc = NULL;
+}
+
+static void
+check_knob(PannerWidget pw, Bool knob)
+{
+ Position pad = pw->panner.internal_border << 1;
+ Position maxx = (Position)XtWidth(pw) - pad -
+ (Position)pw->panner.knob_width;
+ Position maxy = (Position)XtHeight(pw) - pad -
+ (Position)pw->panner.knob_height;
+ Position *x = knob ? &pw->panner.knob_x : &pw->panner.tmp.x;
+ Position *y = knob ? &pw->panner.knob_y : &pw->panner.tmp.y;
+
+ /*
+ * note that positions are already normalized (i.e. internal_border
+ * has been subtracted out)
+ */
+ if (*x < 0)
+ *x = 0;
+ if (*x > maxx)
+ *x = maxx;
+
+ if (*y < 0)
+ *y = 0;
+ if (*y > maxy)
+ *y = maxy;
+
+ if (knob) {
+ pw->panner.slider_x = (Position)((double)pw->panner.knob_x
+ / pw->panner.haspect + 0.5);
+ pw->panner.slider_y = (Position)((double)pw->panner.knob_y
+ / pw->panner.vaspect + 0.5);
+ pw->panner.last_x = pw->panner.last_y = PANNER_OUTOFRANGE;
+ }
+}
+
+static void
+move_shadow(PannerWidget pw)
+{
+ if (pw->panner.shadow_thickness > 0) {
+ int lw = pw->panner.shadow_thickness + (pw->panner.line_width << 1);
+ int pad = pw->panner.internal_border;
+
+ if (pw->panner.knob_height > lw && pw->panner.knob_width > lw) {
+ XRectangle *r = pw->panner.shadow_rects;
+
+ r->x = pw->panner.knob_x + pad + pw->panner.knob_width;
+ r->y = pw->panner.knob_y + pad + lw;
+ r->width = pw->panner.shadow_thickness;
+ r->height = pw->panner.knob_height - lw;
+ r++;
+ r->x = pw->panner.knob_x + pad + lw;
+ r->y = pw->panner.knob_y + pad + pw->panner.knob_height;
+ r->width = pw->panner.knob_width - lw + pw->panner.shadow_thickness;
+ r->height = pw->panner.shadow_thickness;
+ pw->panner.shadow_valid = True;
+ return;
+ }
+ }
+ pw->panner.shadow_valid = False;
+}
+
+static void
+scale_knob(PannerWidget pw, Bool location, Bool size)
+{
+ if (location) {
+ pw->panner.knob_x = (Position)PANNER_HSCALE(pw, pw->panner.slider_x);
+ pw->panner.knob_y = (Position)PANNER_VSCALE(pw, pw->panner.slider_y);
+ }
+ if (size) {
+ Dimension width, height;
+
+ if (pw->panner.slider_width < 1)
+ pw->panner.slider_width = pw->panner.canvas_width;
+ if (pw->panner.slider_height < 1)
+ pw->panner.slider_height = pw->panner.canvas_height;
+ width = Min(pw->panner.slider_width, pw->panner.canvas_width);
+ height = Min(pw->panner.slider_height, pw->panner.canvas_height);
+
+ pw->panner.knob_width = (Dimension)PANNER_HSCALE(pw, width);
+ pw->panner.knob_height = (Dimension)PANNER_VSCALE(pw, height);
+ }
+ if (!pw->panner.allow_off)
+ check_knob(pw, True);
+ move_shadow(pw);
+}
+
+static void
+rescale(PannerWidget pw)
+{
+ int hpad = pw->panner.internal_border << 1;
+ int vpad = hpad;
+
+ if (pw->panner.canvas_width < 1)
+ pw->panner.canvas_width = XtWidth(pw);
+ if (pw->panner.canvas_height < 1)
+ pw->panner.canvas_height = XtHeight(pw);
+
+ if (XtWidth(pw) <= hpad)
+ hpad = 0;
+ if (XtHeight(pw) <= vpad)
+ vpad = 0;
+
+ pw->panner.haspect = ((double)XtWidth(pw) - hpad + .5)
+ / (double)pw->panner.canvas_width;
+ pw->panner.vaspect = ((double)XtHeight(pw) - vpad + .5)
+ / (double)pw->panner.canvas_height;
+ scale_knob(pw, True, True);
+}
+
+static void
+get_default_size(PannerWidget pw, Dimension *wp, Dimension *hp)
+{
+ Dimension pad = pw->panner.internal_border << 1;
+
+ *wp = PANNER_DSCALE(pw, pw->panner.canvas_width) + pad;
+ *hp = PANNER_DSCALE(pw, pw->panner.canvas_height) + pad;
+}
+
+static Bool
+get_event_xy(PannerWidget pw, XEvent *event, int *x, int *y)
+{
+ int pad = pw->panner.internal_border;
+
+ switch (event->type) {
+ case ButtonPress:
+ case ButtonRelease:
+ *x = event->xbutton.x - pad;
+ *y = event->xbutton.y - pad;
+ return (True);
+ case KeyPress:
+ case KeyRelease:
+ *x = event->xkey.x - pad;
+ *y = event->xkey.y - pad;
+ return (True);
+ case EnterNotify:
+ case LeaveNotify:
+ *x = event->xcrossing.x - pad;
+ *y = event->xcrossing.y - pad;
+ return (True);
+ case MotionNotify:
+ *x = event->xmotion.x - pad;
+ *y = event->xmotion.y - pad;
+ return (True);
+ }
+
+ return (False);
+}
+
+static int
+parse_page_string(char *s, int pagesize, int canvassize, Bool *relative)
+{
+ char *cp;
+ double val = 1.0;
+ Bool rel = False;
+
+ /*
+ * syntax: spaces [+-] number spaces [pc\0] spaces
+ */
+ for (; isascii(*s) && isspace(*s); s++) /* skip white space */
+ ;
+
+ if (*s == '+' || *s == '-') { /* deal with signs */
+ rel = True;
+ if (*s == '-')
+ val = -1.0;
+ s++;
+ }
+ if (!*s) { /* if null then return nothing */
+ *relative = True;
+ return (0);
+ }
+
+ /* skip over numbers */
+ for (cp = s; isascii(*s) && (isdigit(*s) || *s == '.'); s++)
+ ;
+ val *= atof(cp);
+
+ /* skip blanks */
+ for (; isascii(*s) && isspace(*s); s++)
+ ;
+
+ if (*s) { /* if units */
+ switch (s[0]) {
+ case 'p':
+ case 'P':
+ val *= (double)pagesize;
+ break;
+ case 'c':
+ case 'C':
+ val *= (double)canvassize;
+ break;
+ }
+ }
+ *relative = rel;
+
+ return ((int)val);
+}
+
+#define DRAW_TMP(pw) \
+{ \
+ XDrawRectangle(XtDisplay(pw), XtWindow(pw), \
+ pw->panner.xor_gc, \
+ pw->panner.tmp.x + pw->panner.internal_border, \
+ pw->panner.tmp.y + pw->panner.internal_border, \
+ pw->panner.knob_width - 1, \
+ pw->panner.knob_height - 1); \
+ pw->panner.tmp.showing = !pw->panner.tmp.showing; \
+}
+
+#define UNDRAW_TMP(pw) \
+{ \
+ if (pw->panner.tmp.showing) \
+ DRAW_TMP(pw); \
+}
+
+#define BACKGROUND_STIPPLE(pw) \
+XmuLocatePixmapFile(pw->core.screen, pw->panner.stipple_name, \
+ pw->panner.shadow_color, pw->core.background_pixel, \
+ pw->core.depth, NULL, 0, NULL, NULL, NULL, NULL)
+
+#define PIXMAP_OKAY(pm) ((pm) != None && (pm) != XtUnspecifiedPixmap)
+
+/*ARGSUSED*/
+static void
+XawPannerInitialize(Widget greq, Widget gnew, ArgList args, Cardinal *num_args)
+{
+ PannerWidget req = (PannerWidget)greq, cnew = (PannerWidget)gnew;
+ Dimension defwidth, defheight;
+
+ if (req->panner.canvas_width < 1)
+ cnew->panner.canvas_width = 1;
+ if (req->panner.canvas_height < 1)
+ cnew->panner.canvas_height = 1;
+ if (req->panner.default_scale < 1)
+ cnew->panner.default_scale = PANNER_DEFAULT_SCALE;
+
+ get_default_size(req, &defwidth, &defheight);
+ if (XtWidth(req) < 1)
+ XtWidth(cnew) = defwidth;
+ if (XtHeight(req) < 1)
+ XtHeight(cnew) = defheight;
+
+ cnew->panner.shadow_gc = NULL;
+ reset_shadow_gc(cnew); /* shadowColor */
+ cnew->panner.slider_gc = NULL;
+ reset_slider_gc(cnew); /* foreground */
+ cnew->panner.xor_gc = NULL;
+ reset_xor_gc(cnew); /* foreground ^ background */
+
+ rescale(cnew); /* does a position check */
+ cnew->panner.shadow_valid = False;
+ cnew->panner.tmp.doing = False;
+ cnew->panner.tmp.showing = False;
+ }
+
+static void
+XawPannerRealize(Widget gw, XtValueMask *valuemaskp,
+ XSetWindowAttributes *attr)
+{
+ PannerWidget pw = (PannerWidget)gw;
+ Pixmap pm = XtUnspecifiedPixmap;
+ Bool gotpm = False;
+
+ if (pw->core.background_pixmap == XtUnspecifiedPixmap) {
+ if (pw->panner.stipple_name)
+ pm = BACKGROUND_STIPPLE(pw);
+
+ if (PIXMAP_OKAY(pm)) {
+ attr->background_pixmap = pm;
+ *valuemaskp |= CWBackPixmap;
+ *valuemaskp &= ~CWBackPixel;
+ gotpm = True;
+ }
+ }
+ (*pannerWidgetClass->core_class.superclass->core_class.realize)
+ (gw, valuemaskp, attr);
+
+ if (gotpm)
+ XFreePixmap(XtDisplay(gw), pm);
+}
+
+static void
+XawPannerDestroy(Widget gw)
+{
+ PannerWidget pw = (PannerWidget)gw;
+
+ XtReleaseGC(gw, pw->panner.shadow_gc);
+ XtReleaseGC(gw, pw->panner.slider_gc);
+ XtReleaseGC(gw, pw->panner.xor_gc);
+}
+
+static void
+XawPannerResize(Widget gw)
+{
+ rescale((PannerWidget)gw);
+}
+
+static void
+XawPannerRedisplay(Widget gw, XEvent *event, Region region)
+{
+ PannerWidget pw = (PannerWidget)gw;
+ Display *dpy = XtDisplay(gw);
+ Window w = XtWindow(gw);
+ int pad = pw->panner.internal_border;
+ Dimension lw = pw->panner.line_width;
+ Dimension extra = pw->panner.shadow_thickness + (lw << 1);
+ int kx = pw->panner.knob_x + pad, ky = pw->panner.knob_y + pad;
+
+ if (Superclass->core_class.expose)
+ (Superclass->core_class.expose)(gw, event, region);
+
+ pw->panner.tmp.showing = False;
+ XClearArea(XtDisplay(pw), XtWindow(pw),
+ (int)pw->panner.last_x - ((int)lw) + pad,
+ (int)pw->panner.last_y - ((int)lw) + pad,
+ pw->panner.knob_width + extra,
+ pw->panner.knob_height + extra,
+ False);
+ pw->panner.last_x = pw->panner.knob_x;
+ pw->panner.last_y = pw->panner.knob_y;
+
+ XFillRectangle(dpy, w, pw->panner.slider_gc, kx, ky,
+ pw->panner.knob_width - 1, pw->panner.knob_height - 1);
+
+ if (lw)
+ XDrawRectangle(dpy, w, pw->panner.shadow_gc, kx, ky,
+ pw->panner.knob_width - 1, pw->panner.knob_height - 1);
+
+ if (pw->panner.shadow_valid)
+ XFillRectangles(dpy, w, pw->panner.shadow_gc, pw->panner.shadow_rects, 2);
+
+ if (pw->panner.tmp.doing && pw->panner.rubber_band)
+ DRAW_TMP(pw);
+}
+
+/*ARGSUSED*/
+static Boolean
+XawPannerSetValues(Widget gcur, Widget greq, Widget gnew,
+ ArgList args, Cardinal *num_args)
+{
+ PannerWidget cur = (PannerWidget)gcur;
+ PannerWidget cnew = (PannerWidget)gnew;
+ Bool redisplay = False;
+
+ if (cur->panner.foreground != cnew->panner.foreground) {
+ reset_slider_gc(cnew);
+ if (cur->panner.foreground != cur->core.background_pixel)
+ reset_xor_gc(cnew);
+ redisplay = True;
+ }
+ else if (cur->panner.line_width != cnew->panner.line_width ||
+ cur->core.background_pixel != cnew->core.background_pixel) {
+ reset_xor_gc(cnew);
+ redisplay = True;
+ }
+ if (cur->panner.shadow_color != cnew->panner.shadow_color) {
+ reset_shadow_gc(cnew);
+ if (cur->panner.foreground == cur->core.background_pixel)
+ reset_xor_gc(cnew);
+ redisplay = True;
+ }
+ if (cur->panner.shadow_thickness != cnew->panner.shadow_thickness) {
+ move_shadow(cnew);
+ redisplay = True;
+ }
+ if (cur->panner.rubber_band != cnew->panner.rubber_band) {
+ reset_xor_gc(cnew);
+ if (cnew->panner.tmp.doing)
+ redisplay = True;
+ }
+
+ if ((cur->panner.stipple_name != cnew->panner.stipple_name
+ || cur->panner.shadow_color != cnew->panner.shadow_color
+ || cur->core.background_pixel != cnew->core.background_pixel)
+ && XtIsRealized(gnew)) {
+ Pixmap pm = cnew->panner.stipple_name ?
+ BACKGROUND_STIPPLE(cnew) : XtUnspecifiedPixmap;
+
+ if (PIXMAP_OKAY(pm)) {
+ XSetWindowBackgroundPixmap(XtDisplay(cnew), XtWindow(cnew), pm);
+ XFreePixmap(XtDisplay(cnew), pm);
+ }
+ else
+ XSetWindowBackground(XtDisplay(cnew), XtWindow(cnew),
+ cnew->core.background_pixel);
+
+ redisplay = True;
+ }
+
+ if (cnew->panner.resize_to_pref &&
+ (cur->panner.canvas_width != cnew->panner.canvas_width
+ || cur->panner.canvas_height != cnew->panner.canvas_height
+ || cur->panner.resize_to_pref != cnew->panner.resize_to_pref)) {
+ get_default_size(cnew, &cnew->core.width, &cnew->core.height);
+ redisplay = True;
+ }
+ else if (cur->panner.canvas_width != cnew->panner.canvas_width
+ || cur->panner.canvas_height != cnew->panner.canvas_height
+ || cur->panner.internal_border != cnew->panner.internal_border) {
+ rescale(cnew); /* does a scale_knob as well */
+ redisplay = True;
+ }
+ else {
+ Bool loc = cur->panner.slider_x != cnew->panner.slider_x ||
+ cur->panner.slider_y != cnew->panner.slider_y;
+ Bool siz = cur->panner.slider_width != cnew->panner.slider_width ||
+ cur->panner.slider_height != cnew->panner.slider_height;
+ if (loc || siz || (cur->panner.allow_off != cnew->panner.allow_off
+ && cnew->panner.allow_off)) {
+ scale_knob(cnew, loc, siz);
+ redisplay = True;
+ }
+ }
+
+ return (redisplay);
+}
+
+static void
+XawPannerSetValuesAlmost(Widget gold, Widget gnew, XtWidgetGeometry *req,
+ XtWidgetGeometry *reply)
+{
+ if (reply->request_mode == 0) /* got turned down, so cope */
+ XawPannerResize(gnew);
+
+ (*pannerWidgetClass->core_class.superclass->core_class.set_values_almost)
+ (gold, gnew, req, reply);
+}
+
+static XtGeometryResult
+XawPannerQueryGeometry(Widget gw, XtWidgetGeometry *intended,
+ XtWidgetGeometry *pref)
+{
+ PannerWidget pw = (PannerWidget)gw;
+
+ pref->request_mode = (CWWidth | CWHeight);
+ get_default_size(pw, &pref->width, &pref->height);
+
+ if (((intended->request_mode & (CWWidth | CWHeight)) == (CWWidth | CWHeight))
+ && intended->width == pref->width && intended->height == pref->height)
+ return (XtGeometryYes);
+ else if (pref->width == XtWidth(pw) && pref->height == XtHeight(pw))
+ return (XtGeometryNo);
+
+ return (XtGeometryAlmost);
+}
+
+
+/*ARGSUSED*/
+static void
+ActionStart(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ PannerWidget pw = (PannerWidget)gw;
+ int x, y;
+
+ if (!get_event_xy(pw, event, &x, &y)) {
+ XBell(XtDisplay(gw), 0);
+ return;
+ }
+
+ pw->panner.tmp.doing = True;
+ pw->panner.tmp.startx = pw->panner.knob_x;
+ pw->panner.tmp.starty = pw->panner.knob_y;
+ pw->panner.tmp.dx = x - pw->panner.knob_x;
+ pw->panner.tmp.dy = y - pw->panner.knob_y;
+ pw->panner.tmp.x = pw->panner.knob_x;
+ pw->panner.tmp.y = pw->panner.knob_y;
+ if (pw->panner.rubber_band)
+ DRAW_TMP(pw);
+}
+
+/*ARGSUSED*/
+static void
+ActionStop(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ PannerWidget pw = (PannerWidget)gw;
+ int x, y;
+
+ if (get_event_xy(pw, event, &x, &y)) {
+ pw->panner.tmp.x = x - pw->panner.tmp.dx;
+ pw->panner.tmp.y = y - pw->panner.tmp.dy;
+ if (!pw->panner.allow_off)
+ check_knob(pw, False);
+ }
+ if (pw->panner.rubber_band)
+ DRAW_TMP(pw);
+ pw->panner.tmp.doing = False;
+}
+
+static void
+ActionAbort(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ PannerWidget pw = (PannerWidget)gw;
+
+ if (!pw->panner.tmp.doing)
+ return;
+
+ if (pw->panner.rubber_band)
+ UNDRAW_TMP(pw);
+
+ if (!pw->panner.rubber_band) { /* restore old position */
+ pw->panner.tmp.x = pw->panner.tmp.startx;
+ pw->panner.tmp.y = pw->panner.tmp.starty;
+ ActionNotify(gw, event, params, num_params);
+ }
+ pw->panner.tmp.doing = False;
+}
+
+static void
+ActionMove(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ PannerWidget pw = (PannerWidget)gw;
+ int x, y;
+
+ if (!pw->panner.tmp.doing)
+ return;
+
+ if (!get_event_xy(pw, event, &x, &y)) {
+ XBell(XtDisplay(gw), 0); /* should do error message */
+ return;
+ }
+
+ if (pw->panner.rubber_band)
+ UNDRAW_TMP(pw);
+ pw->panner.tmp.x = x - pw->panner.tmp.dx;
+ pw->panner.tmp.y = y - pw->panner.tmp.dy;
+
+ if (!pw->panner.rubber_band)
+ ActionNotify(gw, event, params, num_params);
+ else {
+ if (!pw->panner.allow_off)
+ check_knob(pw, False);
+ DRAW_TMP(pw);
+ }
+}
+
+
+static void
+ActionPage(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ PannerWidget pw = (PannerWidget)gw;
+ Cardinal zero = 0;
+ Bool isin = pw->panner.tmp.doing;
+ int x, y;
+ Bool relx, rely;
+ int pad = pw->panner.internal_border << 1;
+
+ if (*num_params != 2) {
+ XBell(XtDisplay(gw), 0);
+ return;
+ }
+
+ x = parse_page_string(params[0], pw->panner.knob_width,
+ (int)XtWidth(pw) - pad, &relx);
+ y = parse_page_string(params[1], pw->panner.knob_height,
+ (int)XtHeight(pw) - pad, &rely);
+
+ if (relx)
+ x += pw->panner.knob_x;
+ if (rely)
+ y += pw->panner.knob_y;
+
+ if (isin) { /* if in, then use move */
+ XEvent ev;
+
+ ev.xbutton.type = ButtonPress;
+ ev.xbutton.x = x;
+ ev.xbutton.y = y;
+ ActionMove(gw, &ev, NULL, &zero);
+ }
+ else {
+ pw->panner.tmp.doing = True;
+ pw->panner.tmp.x = x;
+ pw->panner.tmp.y = y;
+ ActionNotify(gw, event, NULL, &zero);
+ pw->panner.tmp.doing = False;
+ }
+}
+
+/*ARGSUSED*/
+static void
+ActionNotify(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ PannerWidget pw = (PannerWidget)gw;
+
+ if (!pw->panner.tmp.doing)
+ return;
+
+ if (!pw->panner.allow_off)
+ check_knob(pw, False);
+ pw->panner.knob_x = pw->panner.tmp.x;
+ pw->panner.knob_y = pw->panner.tmp.y;
+ move_shadow(pw);
+
+ pw->panner.slider_x = (Position)((double)pw->panner.knob_x
+ / pw->panner.haspect + 0.5);
+ pw->panner.slider_y = (Position)((double) pw->panner.knob_y
+ / pw->panner.vaspect + 0.5);
+ if (!pw->panner.allow_off) {
+ Position tmp;
+
+ if (pw->panner.slider_x
+ > (tmp = (Position)pw->panner.canvas_width -
+ (Position)pw->panner.slider_width))
+ pw->panner.slider_x = tmp;
+ if (pw->panner.slider_x < 0)
+ pw->panner.slider_x = 0;
+ if (pw->panner.slider_y
+ > (tmp = (Position)pw->panner.canvas_height -
+ (Position)pw->panner.slider_height))
+ pw->panner.slider_y = tmp;
+ if (pw->panner.slider_y < 0)
+ pw->panner.slider_y = 0;
+ }
+
+ if (pw->panner.last_x != pw->panner.knob_x ||
+ pw->panner.last_y != pw->panner.knob_y) {
+ XawPannerReport rep;
+
+ XawPannerRedisplay(gw, NULL, NULL);
+ rep.changed = XawPRSliderX | XawPRSliderY;
+ rep.slider_x = pw->panner.slider_x;
+ rep.slider_y = pw->panner.slider_y;
+ rep.slider_width = pw->panner.slider_width;
+ rep.slider_height = pw->panner.slider_height;
+ rep.canvas_width = pw->panner.canvas_width;
+ rep.canvas_height = pw->panner.canvas_height;
+ XtCallCallbackList(gw, pw->panner.report_callbacks, (XtPointer)&rep);
+ }
+}
+
+/*ARGSUSED*/
+static void
+ActionSet(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ PannerWidget pw = (PannerWidget)gw;
+ Bool rb;
+
+ if (*num_params < 2 ||
+ XmuCompareISOLatin1(params[0], "rubberband") != 0) {
+ XBell(XtDisplay(gw), 0);
+ return;
+ }
+
+ if (XmuCompareISOLatin1(params[1], "on") == 0)
+ rb = True;
+ else if (XmuCompareISOLatin1(params[1], "off") == 0)
+ rb = False;
+ else if (XmuCompareISOLatin1(params[1], "toggle") == 0)
+ rb = !pw->panner.rubber_band;
+ else {
+ XBell(XtDisplay(gw), 0);
+ return;
+ }
+
+ if (rb != pw->panner.rubber_band) {
+ Arg args[1];
+
+ XtSetArg(args[0], XtNrubberBand, rb);
+ XtSetValues(gw, args, 1);
+ }
+}
diff --git a/nx-X11/lib/Xaw/Panner.h b/nx-X11/lib/Xaw/Panner.h
new file mode 100644
index 000000000..594e2eb47
--- /dev/null
+++ b/nx-X11/lib/Xaw/Panner.h
@@ -0,0 +1,107 @@
+/*
+ * $Xorg: Panner.h,v 1.5 2001/02/09 02:03:45 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.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xaw/Panner.h,v 1.5 2001/01/17 19:42:28 dawes Exp $ */
+
+#ifndef _XawPanner_h
+#define _XawPanner_h
+
+#include <X11/Intrinsic.h>
+#include <X11/Xaw/Reports.h>
+
+/*****************************************************************************
+ *
+ * Panner Widget (subclass of Simple)
+ *
+ * This widget is used to represent navigation in a 2d coordinate system
+ *
+ * Resources:
+ *
+ * Name Class Type Default
+ * ---- ----- ---- -------
+ *
+ * allowOff AllowOff Boolean FALSE
+ * background Background Pixel XtDefaultBackground
+ * backgroundStipple BackgroundStipple String NULL
+ * canvasWidth CanvasWidth Dimension 0
+ * canvasHeight CanvasHeight Dimension 0
+ * defaultScale DefaultScale Dimension 8 percent
+ * foreground Foreground Pixel XtDefaultBackground
+ * internalSpace InternalSpace Dimension 4
+ * lineWidth LineWidth Dimension 0
+ * reportCallback ReportCallback XtCallbackList NULL
+ * resize Resize Boolean TRUE
+ * rubberBand RubberBand Boolean FALSE
+ * shadowColor ShadowColor Pixel XtDefaultForeground
+ * shadowThickness ShadowThickness Dimension 2
+ * sliderX SliderX Position 0
+ * sliderY SliderY Position 0
+ * sliderWidth SliderWidth Dimension 0
+ * sliderHeight SliderHeight Dimension 0
+ *
+ *****************************************************************************/
+
+#ifndef _XtStringDefs_h_
+#define XtNresize "resize"
+#define XtCResize "Resize"
+#endif
+
+#define XtNallowOff "allowOff"
+#define XtCAllowOff "AllowOff"
+#define XtNbackgroundStipple "backgroundStipple"
+#define XtCBackgroundStipple "BackgroundStipple"
+#define XtNdefaultScale "defaultScale"
+#define XtCDefaultScale "DefaultScale"
+#define XtNcanvasWidth "canvasWidth"
+#define XtCCanvasWidth "CanvasWidth"
+#define XtNcanvasHeight "canvasHeight"
+#define XtCCanvasHeight "CanvasHeight"
+#define XtNinternalSpace "internalSpace"
+#define XtCInternalSpace "InternalSpace"
+#define XtNlineWidth "lineWidth"
+#define XtCLineWidth "LineWidth"
+#define XtNrubberBand "rubberBand"
+#define XtCRubberBand "RubberBand"
+#define XtNshadowThickness "shadowThickness"
+#define XtCShadowThickness "ShadowThickness"
+#define XtNshadowColor "shadowColor"
+#define XtCShadowColor "ShadowColor"
+#define XtNsliderX "sliderX"
+#define XtCSliderX "SliderX"
+#define XtNsliderY "sliderY"
+#define XtCSliderY "SliderY"
+#define XtNsliderWidth "sliderWidth"
+#define XtCSliderWidth "SliderWidth"
+#define XtNsliderHeight "sliderHeight"
+#define XtCSliderHeight "SliderHeight"
+
+extern WidgetClass pannerWidgetClass;
+
+typedef struct _PannerClassRec *PannerWidgetClass;
+typedef struct _PannerRec *PannerWidget;
+
+#endif /* _XawPanner_h */
diff --git a/nx-X11/lib/Xaw/PannerP.h b/nx-X11/lib/Xaw/PannerP.h
new file mode 100644
index 000000000..aacf2e26c
--- /dev/null
+++ b/nx-X11/lib/Xaw/PannerP.h
@@ -0,0 +1,108 @@
+/*
+ * $Xorg: PannerP.h,v 1.4 2001/02/09 02:03:45 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.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xaw/PannerP.h,v 1.7 2001/01/17 19:42:29 dawes Exp $ */
+
+#ifndef _XawPannerP_h
+#define _XawPannerP_h
+
+#include <X11/Xaw/Panner.h>
+#include <X11/Xaw/SimpleP.h>
+
+/* new fields in widget class */
+typedef struct {
+ XtPointer extension;
+} PannerClassPart;
+
+/* Panner widget class */
+typedef struct _PannerClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ PannerClassPart panner_class;
+} PannerClassRec;
+
+/* new fields in widget */
+typedef struct {
+ /* resources */
+ XtCallbackList report_callbacks; /* callback/Callback */
+ Boolean allow_off; /* allowOff/AllowOff */
+ Boolean resize_to_pref; /* resizeToPreferred/Boolean */
+ Pixel foreground; /* foreground/Foreground */
+ Pixel shadow_color; /* shadowColor/ShadowColor */
+ Dimension shadow_thickness; /* shadowThickness/ShadowThickness */
+ Dimension default_scale; /* defaultScale/DefaultScale */
+ Dimension line_width; /* lineWidth/LineWidth */
+ Dimension canvas_width; /* canvasWidth/CanvasWidth */
+ Dimension canvas_height; /* canvasHeight/CanvasHeight */
+ Position slider_x; /* sliderX/SliderX */
+ Position slider_y; /* sliderY/SliderY */
+ Dimension slider_width; /* sliderWidth/SliderWidth */
+ Dimension slider_height; /* sliderHeight/SliderHeight */
+ Dimension internal_border; /* internalBorderWidth/BorderWidth */
+ String stipple_name; /* backgroundStipple/BackgroundStipple
+ */
+ /* private */
+ GC slider_gc; /* background of slider */
+ GC shadow_gc; /* edge of slider and shadow */
+ GC xor_gc; /* for doing XOR tmp graphics */
+ double haspect, vaspect; /* aspect ratio of core to canvas */
+ Boolean rubber_band; /* true = rubber band, false = move */
+ struct {
+ Boolean doing; /* tmp graphics in progress */
+ Boolean showing; /* true if tmp graphics displayed */
+ Position startx, starty; /* initial position of slider */
+ Position dx, dy; /* offset loc for tmp graphics */
+ Position x, y; /* location for tmp graphics */
+ } tmp;
+ Position knob_x, knob_y; /* real upper left of knob in canvas */
+ Dimension knob_width, knob_height; /* real size of knob in canvas */
+ Boolean shadow_valid; /* true if rects are valid */
+ XRectangle shadow_rects[2]; /* location of shadows */
+ Position last_x, last_y; /* previous location of knob */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} PannerPart;
+
+typedef struct _PannerRec {
+ CorePart core;
+ SimplePart simple;
+ PannerPart panner;
+} PannerRec;
+
+#define PANNER_HSCALE(pw,val) ((pw)->panner.haspect * ((double)(val)))
+#define PANNER_VSCALE(pw,val) ((pw)->panner.vaspect * ((double)(val)))
+
+#define PANNER_DSCALE(pw,val) (Dimension) \
+((((unsigned long)(val)) * (unsigned long)pw->panner.default_scale) / 100L)
+
+#define PANNER_DEFAULT_SCALE 8 /* percent */
+#define PANNER_OUTOFRANGE -30000
+
+extern PannerClassRec pannerClassRec;
+
+#endif /* _XawPannerP_h */
diff --git a/nx-X11/lib/Xaw/Pixmap.c b/nx-X11/lib/Xaw/Pixmap.c
new file mode 100644
index 000000000..06e326a74
--- /dev/null
+++ b/nx-X11/lib/Xaw/Pixmap.c
@@ -0,0 +1,993 @@
+/*
+ * Copyright (c) 1998 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+
+/* $XFree86: xc/lib/Xaw/Pixmap.c,v 3.17 2002/05/18 02:05:39 paulo Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/IntrinsicP.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xfuncs.h>
+#include <X11/extensions/shape.h>
+#ifndef OLDXAW
+#include <X11/xpm.h>
+#endif
+#include "Private.h"
+
+#ifdef __UNIXOS2__
+static char dummy;
+#endif
+
+#ifndef OLDXAW
+
+/*
+ * Types
+ */
+typedef struct _XawCache {
+ long value;
+ XtPointer *elems;
+ unsigned int num_elems;
+} XawCache;
+
+typedef struct _XawPixmapLoaderInfo {
+ XawPixmapLoader loader;
+ String type;
+ String ext;
+} XawPixmapLoaderInfo;
+
+/*
+ * Private Methods
+ */
+static Bool BitmapLoader(XawParams*, Screen*, Colormap, int,
+ Pixmap*, Pixmap*, Dimension*, Dimension*);
+static Bool GradientLoader(XawParams*, Screen*, Colormap, int,
+ Pixmap*, Pixmap*, Dimension*, Dimension*);
+static Bool XPixmapLoader(XawParams*, Screen*, Colormap, int,
+ Pixmap*, Pixmap*, Dimension*, Dimension*);
+static XawPixmap *_XawFindPixmap(String, Screen*, Colormap, int);
+static void _XawCachePixmap(XawPixmap*, Screen*, Colormap, int);
+static int _XawFindPixmapLoaderIndex(String, String);
+static int qcmp_long(register _Xconst void*, register _Xconst void *);
+static int bcmp_long(register _Xconst void*, register _Xconst void *);
+static int qcmp_string(register _Xconst void*, register _Xconst void *);
+static int bcmp_string(register _Xconst void*, register _Xconst void *);
+static void GetResourcePixmapPath(Display*);
+
+/*
+ * Initialization
+ */
+static XawCache xaw_pixmaps;
+static XawCache x_pixmaps; /* for fast reverse search */
+static XawPixmapLoaderInfo **loader_info;
+static Cardinal num_loader_info;
+
+/*
+ * Implementation
+ */
+Bool
+XawPixmapsInitialize(void)
+{
+ static Boolean first_time = True;
+
+ if (!first_time)
+ return (False);
+
+ (void)XawAddPixmapLoader(NULL, NULL, BitmapLoader);
+ (void)XawAddPixmapLoader("bitmap", NULL, BitmapLoader);
+ (void)XawAddPixmapLoader("gradient", NULL, GradientLoader);
+ (void)XawAddPixmapLoader("xpm", "xpm", XPixmapLoader);
+
+ return (True);
+}
+
+XawParams *
+XawParseParamsString(String name)
+{
+ XawParams *xaw_params;
+ char *tok, *str, *type = NULL, *ext = NULL, *params = NULL;
+
+ if (!name)
+ return (NULL);
+
+ xaw_params = (XawParams *)XtMalloc(sizeof(XawParams));
+
+ str = XtNewString(name);
+
+ /* Find type */
+ tok = str;
+ while (tok = strchr(tok, ':'), tok)
+ {
+ if (tok == str || tok[-1] != '\\')
+ break;
+ memmove(&tok[-1], tok, strlen(tok) + 1);
+ }
+ if (tok)
+ {
+ *tok = '\0';
+ if (strchr(str, '?'))
+ {
+ *tok = ':';
+ }
+ else
+ {
+ ++tok;
+ type = XtNewString(str);
+ memmove(str, tok, strlen(tok) + 1);
+ }
+ }
+
+ /* Find params */
+ tok = str;
+ while (tok = strchr(tok, '?'), tok)
+ {
+ if (tok == str || tok[-1] != '\\')
+ params = tok;
+ if (tok != str && tok[-1] == '\\')
+ memmove(&tok[-1], tok, strlen(tok) + 1);
+ else
+ break;
+ }
+ if (params)
+ {
+ *params = '\0';
+ ++params;
+ }
+
+ /* Find ext */
+ tok = str;
+ while (tok = strchr(tok, '.'), tok)
+ {
+ if (tok == str || tok[-1] != '\\')
+ ext = tok;
+ if (tok != str && tok[-1] == '\\')
+ memmove(&tok[-1], tok, strlen(tok) + 1);
+ else
+ break;
+ }
+ if (ext)
+ {
+ ++ext;
+ if (strchr(ext, '/'))
+ ext = NULL;
+ }
+
+ xaw_params->name = XtNewString(str);
+ xaw_params->type = type;
+ xaw_params->ext = ext ? XtNewString(ext) : ext;
+ xaw_params->args = NULL;
+ xaw_params->num_args = 0;
+
+ /* Parse params */
+ if (params)
+ {
+ char *arg, *val;
+ XawArgVal *xaw_arg;
+
+ for (tok = strtok(params, "&"); tok; tok = strtok(NULL, "&"))
+ {
+ val = strchr(tok, '=');
+ if (val)
+ {
+ *val = '\0';
+ ++val;
+ if (*val != '\0')
+ val = XtNewString(val);
+ else
+ val = NULL;
+ }
+ arg = XtNewString(tok);
+ xaw_arg = (XawArgVal *)XtMalloc(sizeof(XawArgVal));
+ xaw_arg->name = arg;
+ xaw_arg->value = val;
+ if (!xaw_params->num_args)
+ {
+ xaw_params->num_args = 1;
+ xaw_params->args = (XawArgVal **)
+ XtMalloc(sizeof(XawArgVal*));
+ }
+ else
+ {
+ ++xaw_params->num_args;
+ xaw_params->args = (XawArgVal **)
+ XtRealloc((char *)xaw_params->args,
+ sizeof(XawArgVal*) * xaw_params->num_args);
+ }
+ xaw_params->args[xaw_params->num_args - 1] = xaw_arg;
+ }
+ }
+
+ if (xaw_params->num_args > 1)
+ qsort(xaw_params->args, xaw_params->num_args, sizeof(XtPointer),
+ qcmp_string);
+
+ XtFree(str);
+
+ return (xaw_params);
+}
+
+void
+XawFreeParamsStruct(XawParams *params)
+{
+ unsigned int i;
+
+ if (!params)
+ return;
+
+ for (i = 0; i < params->num_args; i++)
+ {
+ XtFree(params->args[i]->name);
+ if (params->args[i]->value)
+ XtFree(params->args[i]->value);
+ XtFree((char *)params->args[i]);
+ }
+
+ if (params->args)
+ XtFree((char *)params->args);
+ XtFree((char *)params);
+}
+
+XawArgVal *
+XawFindArgVal(XawParams *params, String name)
+{
+ XawArgVal **arg_val;
+
+ if (!params->args)
+ return (NULL);
+
+ arg_val = (XawArgVal **)bsearch((void *)name, params->args,
+ params->num_args, sizeof(XtPointer*),
+ bcmp_string);
+ if (!arg_val)
+ return (NULL);
+
+ return (*arg_val);
+}
+
+XawPixmap *
+XawLoadPixmap(String name, Screen *screen, Colormap colormap, int depth)
+{
+ int idx;
+ Bool success;
+ XawPixmap *xaw_pixmap;
+ Pixmap pixmap, mask;
+ Dimension width, height;
+ XawParams *xaw_params;
+
+ if (!name)
+ return (False);
+
+ xaw_pixmap = _XawFindPixmap(name, screen, colormap, depth);
+
+ if (xaw_pixmap)
+ return (xaw_pixmap);
+
+ if ((xaw_params = XawParseParamsString(name)) == NULL)
+ return (NULL);
+
+ idx = _XawFindPixmapLoaderIndex(xaw_params->type, xaw_params->ext);
+ if (idx < 0)
+ return (NULL);
+
+#ifdef DIAGNOSTIC
+ fprintf(stderr, "(*) Loading pixmap \"%s\": ", name);
+#endif
+
+ success = loader_info[idx]->loader(xaw_params, screen, colormap, depth,
+ &pixmap, &mask, &width, &height);
+ if (success)
+ {
+ xaw_pixmap = (XawPixmap *)XtMalloc(sizeof(XawPixmap));
+ xaw_pixmap->name = XtNewString(name);
+ xaw_pixmap->pixmap = pixmap;
+ xaw_pixmap->mask = mask;
+ xaw_pixmap->width = width;
+ xaw_pixmap->height = height;
+ _XawCachePixmap(xaw_pixmap, screen, colormap, depth);
+ }
+
+ XawFreeParamsStruct(xaw_params);
+
+#ifdef DIAGNOSTIC
+ fprintf(stderr, "%s", success ? "success\n" : "failed\n");
+#endif
+
+ return (success ? xaw_pixmap : NULL);
+}
+
+Bool
+XawAddPixmapLoader(String type, String ext, XawPixmapLoader loader)
+{
+ XawPixmapLoaderInfo *info;
+ int i;
+
+ if (!loader)
+ return (False);
+
+ i = _XawFindPixmapLoaderIndex(type, ext);
+
+ if (i >= 0)
+ {
+ loader_info[i]->loader = loader;
+ if (loader_info[i]->type)
+ XtFree(loader_info[i]->type);
+ if (loader_info[i]->ext)
+ XtFree(loader_info[i]->ext);
+ loader_info[i]->type = type ? XtNewString(type) : NULL;
+ loader_info[i]->ext = ext ? XtNewString(ext) : NULL;
+ return (True);
+ }
+
+ if ((info = (XawPixmapLoaderInfo *)XtMalloc(sizeof(XawPixmapLoaderInfo)))
+ == NULL)
+ return (False);
+
+ info->loader = loader;
+ info->type = type ? XtNewString(type) : NULL;
+ info->ext = ext ? XtNewString(ext) : NULL;
+
+ if (!loader_info)
+ {
+ num_loader_info = 1;
+ loader_info = (XawPixmapLoaderInfo**)
+ XtMalloc(sizeof(XawPixmapLoaderInfo*));
+ }
+ else
+ {
+ ++num_loader_info;
+ loader_info = (XawPixmapLoaderInfo**)
+ XtRealloc((char *)loader_info,
+ sizeof(XawPixmapLoaderInfo) * num_loader_info);
+ }
+ loader_info[num_loader_info - 1] = info;
+
+ return (True);
+}
+
+static int
+_XawFindPixmapLoaderIndex(String type, String ext)
+{
+ Cardinal i;
+
+ if (!loader_info)
+ return (-1);
+
+ for (i = 0; i < num_loader_info; i++)
+ if ((type && loader_info[i]->type && strcmp(type, loader_info[i]->type) == 0)
+ || (ext && loader_info[i]->ext && strcmp(ext, loader_info[i]->ext) == 0))
+ return ((int)i);
+
+ if (!type)
+ return (0); /* try a bitmap */
+
+ return (-1);
+}
+
+static int
+qcmp_x_cache(register _Xconst void *left, register _Xconst void *right)
+{
+ return ((int)((*(XawPixmap **)left)->pixmap) -
+ (int)((*(XawPixmap **)right)->pixmap));
+}
+
+static int
+bcmp_x_cache(register _Xconst void *pixmap, register _Xconst void *xaw)
+{
+ return (int)((long)pixmap - (long)((*(XawPixmap **)xaw)->pixmap));
+}
+
+static int
+qcmp_long(register _Xconst void *left, register _Xconst void *right)
+{
+ return ((long)((*(XawCache **)left)->value) -
+ (long)((*(XawCache **)right)->value));
+}
+
+static int
+qcmp_string(register _Xconst void *left, register _Xconst void *right)
+{
+ return (strcmp((String)((*(XawCache **)left)->value),
+ (String)((*(XawCache **)right)->value)));
+}
+
+static int
+bcmp_long(register _Xconst void *value, register _Xconst void *cache)
+{
+ return ((long)value - (long)((*(XawCache **)cache)->value));
+}
+
+static int
+bcmp_string(register _Xconst void *string,
+ register _Xconst void *cache)
+{
+ return (strcmp((String)string, (String)((*(XawCache **)cache)->value)));
+}
+
+#define FIND_ALL 0
+#define FIND_SCREEN 1
+#define FIND_COLORMAP 2
+#define FIND_DEPTH 3
+static XawCache *
+_XawFindCache(XawCache *xaw,
+ Screen *screen, Colormap colormap, int depth, int flags)
+{
+ XawCache **cache;
+
+ if (!xaw->num_elems)
+ return (NULL);
+
+ /* Screen */
+ cache = (XawCache **)bsearch(screen, xaw->elems,
+ xaw->num_elems, sizeof(XtPointer),
+ bcmp_long);
+ if (!cache || !(*cache)->num_elems)
+ return (NULL);
+ if (flags == FIND_SCREEN)
+ return (*cache);
+
+ /* Colormap */
+ cache = (XawCache **)bsearch((void *)colormap, (*cache)->elems,
+ (*cache)->num_elems, sizeof(XtPointer),
+ bcmp_long);
+ if (!cache || !(*cache)->num_elems)
+ return (NULL);
+ if (flags == FIND_COLORMAP)
+ return (*cache);
+
+ /* Depth */
+ cache = (XawCache **)bsearch((void *)(long)depth, (*cache)->elems,
+ (*cache)->num_elems, sizeof(XtPointer),
+ bcmp_long);
+
+ if (!cache || !(*cache)->num_elems)
+ return (NULL);
+ return (*cache);
+}
+
+static XawCache *
+_XawGetCache(XawCache *xaw, Screen *screen, Colormap colormap, int depth)
+{
+ XawCache *s_cache, *c_cache, *d_cache, *cache, *pcache;
+
+ cache = _XawFindCache(xaw, screen, colormap, depth, FIND_ALL);
+
+ if (!cache)
+ {
+ s_cache = _XawFindCache(xaw,
+ screen, colormap, depth, FIND_SCREEN);
+ if (!s_cache)
+ {
+ pcache = (XawCache *)XtMalloc(sizeof(XawCache));
+ if (!xaw->num_elems)
+ {
+ xaw->num_elems = 1;
+ xaw->elems = (XtPointer*)XtMalloc(sizeof(XtPointer));
+ }
+ else
+ {
+ ++xaw->num_elems;
+ xaw->elems = (XtPointer*)
+ XtRealloc((char *)xaw->elems,
+ sizeof(XtPointer) * xaw->num_elems);
+ }
+ pcache->value = (long)screen;
+ pcache->elems = NULL;
+ pcache->num_elems = 0;
+ xaw->elems[xaw->num_elems - 1] = (XtPointer)pcache;
+ s_cache = (XawCache *)xaw->elems[xaw->num_elems - 1];
+ if (xaw->num_elems > 1)
+ qsort(xaw->elems, xaw->num_elems, sizeof(XtPointer), qcmp_long);
+ }
+
+ c_cache = _XawFindCache(xaw,
+ screen, colormap, depth, FIND_COLORMAP);
+ if (!c_cache)
+ {
+ pcache = (XawCache *)XtMalloc(sizeof(XawCache));
+ if (!s_cache->num_elems)
+ {
+ s_cache->num_elems = 1;
+ s_cache->elems = (XtPointer*)XtMalloc(sizeof(XtPointer));
+ }
+ else
+ {
+ ++s_cache->num_elems;
+ s_cache->elems = (XtPointer*)
+ XtRealloc((char *)s_cache->elems,
+ sizeof(XtPointer) * s_cache->num_elems);
+ }
+ pcache->value = (long)colormap;
+ pcache->elems = NULL;
+ pcache->num_elems = 0;
+ s_cache->elems[s_cache->num_elems - 1] = (XtPointer)pcache;
+ c_cache = (XawCache *)s_cache->elems[s_cache->num_elems - 1];
+ if (s_cache->num_elems > 1)
+ qsort(s_cache->elems, s_cache->num_elems,
+ sizeof(XtPointer), qcmp_long);
+ }
+
+ d_cache = _XawFindCache(xaw,
+ screen, colormap, depth, FIND_DEPTH);
+ if (!d_cache)
+ {
+ pcache = (XawCache *)XtMalloc(sizeof(XawCache));
+ if (!c_cache->num_elems)
+ {
+ c_cache->num_elems = 1;
+ c_cache->elems = (XtPointer*)XtMalloc(sizeof(XtPointer));
+ }
+ else
+ {
+ ++c_cache->num_elems;
+ c_cache->elems = (XtPointer*)
+ XtRealloc((char *)c_cache->elems,
+ sizeof(XtPointer) * c_cache->num_elems);
+ }
+ pcache->value = (long)depth;
+ pcache->elems = NULL;
+ pcache->num_elems = 0;
+ c_cache->elems[c_cache->num_elems - 1] = (XtPointer)pcache;
+ d_cache = (XawCache *)c_cache->elems[c_cache->num_elems - 1];
+ if (c_cache->num_elems > 1)
+ qsort(c_cache->elems, c_cache->num_elems,
+ sizeof(XtPointer), qcmp_long);
+ }
+
+ cache = d_cache;
+ }
+
+ return (cache);
+}
+
+static XawPixmap *
+_XawFindPixmap(String name, Screen *screen, Colormap colormap, int depth)
+{
+ XawCache *cache;
+ XawPixmap **pixmap;
+
+ cache = _XawFindCache(&xaw_pixmaps, screen, colormap, depth, FIND_ALL);
+
+ if (!cache)
+ return (NULL);
+
+ /* Name */
+ pixmap = (XawPixmap **)bsearch((void *)name, cache->elems,
+ cache->num_elems, sizeof(XtPointer),
+ bcmp_string);
+ if (!pixmap)
+ return (NULL);
+
+ return (*pixmap);
+}
+
+XawPixmap *
+XawPixmapFromXPixmap(Pixmap pixmap,
+ Screen *screen, Colormap colormap, int depth)
+{
+ XawCache *cache;
+ XawPixmap **x_pixmap;
+
+ cache = _XawFindCache(&x_pixmaps, screen, colormap, depth, FIND_ALL);
+
+ if (!cache)
+ return (NULL);
+
+ /* Pixmap */
+ x_pixmap = (XawPixmap **)bsearch((void *)pixmap, cache->elems,
+ cache->num_elems, sizeof(XtPointer),
+ bcmp_x_cache);
+ if (!x_pixmap)
+ return (NULL);
+
+ return (*x_pixmap);
+}
+
+static void
+_XawCachePixmap(XawPixmap *pixmap,
+ Screen *screen, Colormap colormap, int depth)
+{
+ XawCache *xaw_cache, *x_cache;
+
+ xaw_cache = _XawGetCache(&xaw_pixmaps, screen, colormap, depth);
+ x_cache = _XawGetCache(&x_pixmaps, screen, colormap, depth);
+
+ if (!xaw_cache->num_elems)
+ {
+ xaw_cache->num_elems = 1;
+ xaw_cache->elems = (XtPointer*)XtMalloc(sizeof(XtPointer));
+ }
+ else
+ {
+ ++xaw_cache->num_elems;
+ xaw_cache->elems = (XtPointer*)XtRealloc((char *)xaw_cache->elems,
+ sizeof(XtPointer) *
+ xaw_cache->num_elems);
+ }
+
+ xaw_cache->elems[xaw_cache->num_elems - 1] = (XtPointer)pixmap;
+ if (xaw_cache->num_elems > 1)
+ qsort(xaw_cache->elems, xaw_cache->num_elems,
+ sizeof(XtPointer), qcmp_string);
+
+
+ if (!x_cache->num_elems)
+ {
+ x_cache->num_elems = 1;
+ x_cache->elems = (XtPointer*)XtMalloc(sizeof(XtPointer));
+ }
+ else
+ {
+ ++x_cache->num_elems;
+ x_cache->elems = (XtPointer*)XtRealloc((char *)x_cache->elems,
+ sizeof(XtPointer) *
+ x_cache->num_elems);
+ }
+
+ x_cache->elems[x_cache->num_elems - 1] = (XtPointer)pixmap;
+ if (x_cache->num_elems > 1)
+ qsort(x_cache->elems, x_cache->num_elems, sizeof(XtPointer), qcmp_x_cache);
+}
+
+#ifndef PROJECT_ROOT
+#define PROJECT_ROOT "/usr/X11R6"
+#endif
+
+static char *pixmap_path = NULL;
+
+static void
+GetResourcePixmapPath(Display *display)
+{
+ XrmName xrm_name[2];
+ XrmClass xrm_class[2];
+ XrmRepresentation rep_type;
+ XrmValue value;
+ static char *default_path =
+ "%H/%T/%N:%P/include/X11/%T/%N:/usr/X11R6/include/X11/%T/%N:/usr/include/X11/%T/%N:%N";
+
+ xrm_name[0] = XrmPermStringToQuark("pixmapFilePath");
+ xrm_name[1] = NULLQUARK;
+ xrm_class[0] = XrmPermStringToQuark("PixmapFilePath");
+ xrm_class[1] = NULLQUARK;
+ if (!XrmGetDatabase(display))
+ (void) XGetDefault(display, "", "");
+ if (XrmQGetResource(XrmGetDatabase(display), xrm_name, xrm_class,
+ &rep_type, &value) &&
+ rep_type == XrmPermStringToQuark("String")) {
+ int length = 0;
+ char *tok, *buffer = XtNewString(value.addr);
+
+ for (tok = strtok(buffer, ":"); tok; tok = strtok(NULL, ":")) {
+ int toklen = strlen(tok);
+
+ if (toklen) {
+ pixmap_path = XtRealloc(pixmap_path, length + toklen + 5);
+ strcpy(pixmap_path + length, tok);
+ if (length)
+ pixmap_path[length++] = ':';
+ sprintf(pixmap_path + length, "%s/%%N", tok);
+ length += strlen(tok) + 3;
+ }
+ }
+ pixmap_path = XtRealloc(pixmap_path, length + strlen(default_path) + 2);
+ if (length)
+ pixmap_path[length++] = ':';
+ strcpy(pixmap_path + length, default_path);
+ }
+ else
+ pixmap_path = default_path;
+}
+
+static Bool
+BitmapLoader(XawParams *params, Screen *screen, Colormap colormap, int depth,
+ Pixmap *pixmap_return, Pixmap *mask_return,
+ Dimension *width_return, Dimension *height_return)
+{
+ Pixel fg, bg;
+ XColor color, exact;
+ Pixmap pixmap;
+ unsigned int width, height;
+ unsigned char *data = NULL;
+ int hotX, hotY;
+ XawArgVal *argval;
+ Bool retval = False;
+ static SubstitutionRec sub[] = {
+ {'H', NULL},
+ {'N', NULL},
+ {'T', "bitmaps"},
+ {'P', PROJECT_ROOT},
+ };
+ char *filename;
+
+ fg = BlackPixelOfScreen(screen);
+ bg = WhitePixelOfScreen(screen);
+
+ if ((argval = XawFindArgVal(params, "foreground")) != NULL
+ && argval->value)
+ {
+ if (XAllocNamedColor(DisplayOfScreen(screen), colormap, argval->value,
+ &color, &exact))
+ fg = color.pixel;
+ else
+ return (False);
+ }
+ if ((argval = XawFindArgVal(params, "background")) != NULL
+ && argval->value)
+ {
+ if (XAllocNamedColor(DisplayOfScreen(screen), colormap, argval->value,
+ &color, &exact))
+ bg = color.pixel;
+ else
+ return (False);
+ }
+
+ if (params->name[0] != '/' && params->name[0] != '.')
+ {
+ if (!sub[0].substitution)
+ sub[0].substitution = getenv("HOME");
+ sub[1].substitution = params->name;
+ if (pixmap_path == NULL)
+ GetResourcePixmapPath(DisplayOfScreen(screen));
+ filename = XtFindFile(pixmap_path, sub, XtNumber(sub), NULL);
+ if (!filename)
+ return (FALSE);
+ }
+ else
+ filename = params->name;
+
+ if (XReadBitmapFileData(filename, &width, &height, &data,
+ &hotX, &hotY) == BitmapSuccess)
+ {
+ pixmap = XCreatePixmapFromBitmapData(DisplayOfScreen(screen),
+ RootWindowOfScreen(screen),
+ (char *)data,
+ width, height, fg, bg, depth);
+ if (data)
+ XFree(data);
+ *pixmap_return = pixmap;
+ *mask_return = None;
+ *width_return = width;
+ *height_return = height;
+
+ retval = True;
+ }
+
+ if (filename != params->name)
+ XtFree(filename);
+
+ return (retval);
+}
+
+#define VERTICAL 1
+#define HORIZONTAL 2
+static Bool
+GradientLoader(XawParams *params, Screen *screen, Colormap colormap, int depth,
+ Pixmap *pixmap_return, Pixmap *mask_return,
+ Dimension *width_return, Dimension *height_return)
+{
+ double ired, igreen, iblue, red, green, blue;
+ XColor start, end, color;
+ XGCValues values;
+ GC gc;
+ double i, inc, x, y, xend, yend;
+ Pixmap pixmap;
+ XawArgVal *argval;
+ int orientation, dimension, steps;
+ char *value;
+
+ if (XmuCompareISOLatin1(params->name, "vertical") == 0)
+ orientation = VERTICAL;
+ else if (XmuCompareISOLatin1(params->name, "horizontal") == 0)
+ orientation = HORIZONTAL;
+ else
+ return (False);
+
+ if ((argval = XawFindArgVal(params, "dimension")) != NULL
+ && argval->value)
+ {
+ dimension = atoi(argval->value);
+ if (dimension <= 0)
+ return (False);
+ }
+ else
+ dimension = 50;
+
+ if ((argval = XawFindArgVal(params, "steps")) != NULL
+ && argval->value)
+ {
+ steps = atoi(argval->value);
+ if (steps <= 0)
+ return (False);
+ }
+ else
+ steps = dimension;
+
+ steps = XawMin(steps, dimension);
+
+ value = NULL;
+ if ((argval = XawFindArgVal(params, "start")) != NULL)
+ value = argval->value;
+ if (value && !XAllocNamedColor(DisplayOfScreen(screen), colormap, value,
+ &start, &color))
+ return (False);
+ else if (!value)
+ {
+ start.pixel = WhitePixelOfScreen(screen);
+ XQueryColor(DisplayOfScreen(screen), colormap, &start);
+ }
+ value = NULL;
+ if ((argval = XawFindArgVal(params, "end")) != NULL)
+ value = argval->value;
+ if (value && !XAllocNamedColor(DisplayOfScreen(screen), colormap, value,
+ &end, &color))
+ return (False);
+ else if (!value)
+ {
+ end.pixel = BlackPixelOfScreen(screen);
+ XQueryColor(DisplayOfScreen(screen), colormap, &end);
+ }
+
+ if ((pixmap = XCreatePixmap(DisplayOfScreen(screen),
+ RootWindowOfScreen(screen),
+ orientation == VERTICAL ? 1 : dimension,
+ orientation == VERTICAL ? dimension : 1, depth))
+ == 0)
+ return (False);
+
+ ired = (double)(end.red - start.red) / (double)steps;
+ igreen = (double)(end.green - start.green) / (double)steps;
+ iblue = (double)(end.blue - start.blue) / (double)steps;
+
+ red = color.red = start.red;
+ green = color.green = start.green;
+ blue = color.blue = start.blue;
+
+ inc = (double)dimension / (double)steps;
+
+ gc = XCreateGC(DisplayOfScreen(screen), pixmap, 0, &values);
+
+ x = y = 0.0;
+ if (orientation == VERTICAL)
+ {
+ xend = 1;
+ yend = 0;
+ }
+ else
+ {
+ xend = 0;
+ yend = 1;
+ }
+
+ color.flags = DoRed | DoGreen | DoBlue;
+
+ XSetForeground(DisplayOfScreen(screen), gc, start.pixel);
+ for (i = 0.0; i < dimension; i += inc)
+ {
+ if ((int)color.red != (int)red || (int)color.green != (int)green
+ || (int)color.blue != (int)blue)
+ {
+ XFillRectangle(DisplayOfScreen(screen), pixmap, gc, (int)x, (int)y,
+ (unsigned int)xend, (unsigned int)yend);
+ color.red = (unsigned short)red;
+ color.green = (unsigned short)green;
+ color.blue = (unsigned short)blue;
+ if (!XAllocColor(DisplayOfScreen(screen), colormap, &color))
+ {
+ XFreePixmap(DisplayOfScreen(screen), pixmap);
+ return (False);
+ }
+ XSetForeground(DisplayOfScreen(screen), gc, color.pixel);
+ if (orientation == VERTICAL)
+ y = yend;
+ else
+ x = xend;
+ }
+ red += ired;
+ green += igreen;
+ blue += iblue;
+ if (orientation == VERTICAL)
+ yend += inc;
+ else
+ xend += inc;
+ }
+ XFillRectangle(DisplayOfScreen(screen), pixmap, gc, (int)x, (int)y,
+ (unsigned int)xend, (unsigned int)yend);
+
+ *pixmap_return = pixmap;
+ *mask_return = None;
+ *width_return = orientation == VERTICAL ? 1 : dimension;
+ *height_return = orientation == VERTICAL ? dimension : 1;
+
+ XFreeGC(DisplayOfScreen(screen), gc);
+
+ return (True);
+}
+
+static Bool
+XPixmapLoader(XawParams *params, Screen *screen, Colormap colormap, int depth,
+ Pixmap *pixmap_return, Pixmap *mask_return,
+ Dimension *width_return, Dimension *height_return)
+{
+ XpmAttributes xpm_attributes;
+ XawArgVal *argval;
+ unsigned int closeness = 4000;
+ static SubstitutionRec sub[] = {
+ {'H', NULL},
+ {'N', NULL},
+ {'T', "pixmaps"},
+ {'P', PROJECT_ROOT},
+ };
+ char *filename;
+
+ if ((argval = XawFindArgVal(params, "closeness")) != NULL
+ && argval->value)
+ closeness = atoi(argval->value);
+
+ if (params->name[0] != '/' && params->name[0] != '.')
+ {
+ if (!sub[0].substitution)
+ sub[0].substitution = getenv("HOME");
+ sub[1].substitution = params->name;
+ if (pixmap_path == NULL)
+ GetResourcePixmapPath(DisplayOfScreen(screen));
+ filename = XtFindFile(pixmap_path, sub, XtNumber(sub), NULL);
+ if (!filename)
+ return (False);
+ }
+ else
+ filename = params->name;
+
+ xpm_attributes.colormap = colormap;
+ xpm_attributes.closeness = closeness;
+ xpm_attributes.valuemask = XpmSize | XpmColormap | XpmCloseness;
+ if (XpmReadFileToPixmap(DisplayOfScreen(screen),
+ RootWindowOfScreen(screen), filename, pixmap_return,
+ mask_return, &xpm_attributes) == XpmSuccess)
+ {
+ *width_return = xpm_attributes.width;
+ *height_return = xpm_attributes.height;
+
+ return (True);
+ }
+
+ return (False);
+}
+
+void
+XawReshapeWidget(Widget w, XawPixmap *pixmap)
+{
+ if (!pixmap || pixmap->mask == None)
+ XShapeCombineMask(XtDisplay(w), XtWindow(w), ShapeBounding, 0, 0,
+ None, ShapeSet);
+ else
+ XShapeCombineMask(XtDisplay(w), XtWindow(w), ShapeBounding, 0, 0,
+ pixmap->mask, ShapeSet);
+}
+
+#endif /* OLDXAW */
diff --git a/nx-X11/lib/Xaw/Porthole.c b/nx-X11/lib/Xaw/Porthole.c
new file mode 100644
index 000000000..3bf161592
--- /dev/null
+++ b/nx-X11/lib/Xaw/Porthole.c
@@ -0,0 +1,378 @@
+/*
+ * $Xorg: Porthole.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 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.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ *
+ * This widget is a trivial clipping widget. It is typically used with a
+ * panner or scrollbar to navigate.
+ */
+/* $XFree86: xc/lib/Xaw/Porthole.c,v 1.6 2001/01/17 19:42:29 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xaw/PortholeP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+/*
+ * Class Methods
+ */
+static void XawPortholeChangeManaged(Widget);
+static XtGeometryResult XawPortholeGeometryManager(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static XtGeometryResult XawPortholeQueryGeometry(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawPortholeRealize(Widget, Mask*, XSetWindowAttributes*);
+static void XawPortholeResize(Widget);
+
+/*
+ * Prototypes
+ */
+static Widget find_child(PortholeWidget);
+static void layout_child(PortholeWidget, Widget, XtWidgetGeometry*,
+ Position*, Position*, Dimension*, Dimension*);
+static void SendReport(PortholeWidget, unsigned int);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(PortholeRec, porthole.field)
+static XtResource resources[] = {
+ {
+ XtNreportCallback,
+ XtCReportCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(report_callbacks),
+ XtRCallback,
+ NULL
+ },
+};
+#undef offset
+
+#define Superclass (&compositeClassRec)
+PortholeClassRec portholeClassRec = {
+ /* core */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "Porthole", /* class_name */
+ sizeof(PortholeRec), /* widget_size */
+ XawInitializeWidgetSet, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ NULL, /* initialize */
+ NULL, /* initialize_hook */
+ XawPortholeRealize, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ NULL, /* destroy */
+ XawPortholeResize, /* resize */
+ NULL, /* expose */
+ NULL, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ XawPortholeQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* composite */
+ {
+ XawPortholeGeometryManager, /* geometry_manager */
+ XawPortholeChangeManaged, /* change_managed */
+ XtInheritInsertChild, /* insert_child */
+ XtInheritDeleteChild, /* delete_child */
+ NULL, /* extension */
+ },
+ { /* porthole */
+ NULL, /* extension */
+ },
+};
+
+WidgetClass portholeWidgetClass = (WidgetClass)&portholeClassRec;
+
+/*
+ * Implementation
+ */
+static Widget
+find_child(PortholeWidget pw)
+{
+ Widget *children;
+ unsigned int i;
+
+ /*
+ * Find the managed child on which we should operate. Ignore multiple
+ * managed children
+ */
+ for (i = 0, children = pw->composite.children;
+ i < pw->composite.num_children; i++, children++)
+ if (XtIsManaged(*children))
+ return (*children);
+
+ return (NULL);
+}
+
+static void
+SendReport(PortholeWidget pw, unsigned int changed)
+{
+ Widget child = find_child(pw);
+
+ if (pw->porthole.report_callbacks && child) {
+ XawPannerReport prep;
+
+ prep.changed = changed;
+ prep.slider_x = -XtX(child); /* porthole is "inner" */
+ prep.slider_y = -XtY(child); /* child is outer since it is larger */
+ prep.slider_width = XtWidth(pw);
+ prep.slider_height = XtHeight(pw);
+ prep.canvas_width = XtWidth(child);
+ prep.canvas_height = XtHeight(child);
+ XtCallCallbackList((Widget)pw, pw->porthole.report_callbacks,
+ (XtPointer)&prep);
+ }
+}
+
+static void
+layout_child(PortholeWidget pw, Widget child, XtWidgetGeometry *geomp,
+ Position *xp, Position *yp, Dimension *widthp, Dimension *heightp)
+{
+ Position minx, miny;
+
+ *xp = XtX(child); /* default to current values */
+ *yp = XtY(child);
+ *widthp = XtWidth(child);
+ *heightp = XtHeight(child);
+ if (geomp) { /* mix in any requested changes */
+ if (geomp->request_mode & CWX)
+ *xp = geomp->x;
+ if (geomp->request_mode & CWY)
+ *yp = geomp->y;
+ if (geomp->request_mode & CWWidth)
+ *widthp = geomp->width;
+ if (geomp->request_mode & CWHeight)
+ *heightp = geomp->height;
+ }
+
+ /*
+ * Make sure that the child is at least as large as the porthole; there
+ * is no maximum size
+ */
+ if (*widthp < XtWidth(pw)) *widthp = XtWidth(pw);
+ if (*heightp < XtHeight(pw)) *heightp = XtHeight(pw);
+
+ /*
+ * Make sure that the child is still on the screen. Note that this must
+ * be done *after* the size computation so that we know where to put it
+ */
+ minx = (Position)XtWidth(pw) - (Position)*widthp;
+ miny = (Position)XtHeight(pw) - (Position)*heightp;
+
+ if (*xp < minx)
+ *xp = minx;
+ if (*yp < miny)
+ *yp = miny;
+
+ if (*xp > 0)
+ *xp = 0;
+ if (*yp > 0)
+ *yp = 0;
+}
+
+static void
+XawPortholeRealize(Widget gw, Mask *valueMask, XSetWindowAttributes *attr)
+{
+ attr->bit_gravity = NorthWestGravity;
+ *valueMask |= CWBitGravity;
+
+ if (XtWidth(gw) < 1)
+ XtWidth(gw) = 1;
+ if (XtHeight(gw) < 1)
+ XtHeight(gw) = 1;
+ (*portholeWidgetClass->core_class.superclass->core_class.realize)
+ (gw, valueMask, attr);
+}
+
+static void
+XawPortholeResize(Widget gw)
+{
+ PortholeWidget pw = (PortholeWidget)gw;
+ Widget child = find_child(pw);
+
+ /*
+ * If we have a child, we need to make sure that it is at least as big
+ * as we are and in the right place
+ */
+ if (child) {
+ Position x, y;
+ Dimension width, height;
+
+ layout_child(pw, child, NULL, &x, &y, &width, &height);
+ XtConfigureWidget(child, x, y, width, height, 0);
+ }
+
+ SendReport(pw, XawPRCanvasWidth | XawPRCanvasHeight);
+}
+
+static XtGeometryResult
+XawPortholeQueryGeometry(Widget gw, XtWidgetGeometry *intended,
+ XtWidgetGeometry *preferred)
+{
+ PortholeWidget pw = (PortholeWidget)gw;
+ Widget child = find_child(pw);
+
+ if (child) {
+#define SIZEONLY (CWWidth | CWHeight)
+ preferred->request_mode = SIZEONLY;
+ preferred->width = XtWidth(child);
+ preferred->height = XtHeight(child);
+
+ if ((intended->request_mode & SIZEONLY) == SIZEONLY &&
+ intended->width == preferred->width &&
+ intended->height == preferred->height)
+ return (XtGeometryYes);
+ else if (preferred->width == XtWidth(pw) &&
+ preferred->height == XtHeight(pw))
+ return (XtGeometryNo);
+
+ return (XtGeometryAlmost);
+#undef SIZEONLY
+ }
+
+ return (XtGeometryNo);
+}
+
+static XtGeometryResult
+XawPortholeGeometryManager(Widget w, XtWidgetGeometry *req,
+ XtWidgetGeometry *reply)
+{
+ PortholeWidget pw = (PortholeWidget) w->core.parent;
+ Widget child = find_child(pw);
+ Bool okay = True;
+
+ if (child != w)
+ return (XtGeometryNo);
+
+ *reply = *req; /* assume we'll grant everything */
+
+ if ((req->request_mode & CWBorderWidth) && req->border_width != 0) {
+ reply->border_width = 0;
+ okay = False;
+ }
+
+ layout_child(pw, child, req, &reply->x, &reply->y,
+ &reply->width, &reply->height);
+
+ if ((req->request_mode & CWX) && req->x != reply->x)
+ okay = False;
+ if ((req->request_mode & CWY) && req->x != reply->x)
+ okay = False;
+ if ((req->request_mode & CWWidth) && req->width != reply->width)
+ okay = False;
+ if ((req->request_mode & CWHeight) && req->height != reply->height)
+ okay = False;
+
+ /*
+ * If we failed on anything, simply return without touching widget
+ */
+ if (!okay)
+ return (XtGeometryAlmost);
+
+ /*
+ * If not just doing a query, update widget and send report. Note that
+ * we will often set fields that weren't requested because we want to keep
+ * the child visible
+ */
+ if (!(req->request_mode & XtCWQueryOnly)) {
+ unsigned int changed = 0;
+
+ if (XtX(child) != reply->x) {
+ changed |= XawPRSliderX;
+ XtX(child) = reply->x;
+ }
+ if (XtY(child) != reply->y) {
+ changed |= XawPRSliderY;
+ XtY(child) = reply->y;
+ }
+ if (XtWidth(child) != reply->width) {
+ changed |= XawPRSliderWidth;
+ XtWidth(child) = reply->width;
+ }
+ if (XtHeight(child) != reply->height) {
+ changed |= XawPRSliderHeight;
+ XtHeight(child) = reply->height;
+ }
+ if (changed)
+ SendReport(pw, changed);
+ }
+
+ return (XtGeometryYes); /* success! */
+}
+
+static void
+XawPortholeChangeManaged(Widget gw)
+{
+ PortholeWidget pw = (PortholeWidget)gw;
+ Widget child = find_child (pw); /* ignore extra children */
+
+ if (child) {
+ if (!XtIsRealized (gw)) {
+ XtWidgetGeometry geom, retgeom;
+
+ geom.request_mode = 0;
+ if (XtWidth(pw) == 0) {
+ geom.width = XtWidth(child);
+ geom.request_mode |= CWWidth;
+ }
+ if (XtHeight(pw) == 0) {
+ geom.height = XtHeight(child);
+ geom.request_mode |= CWHeight;
+ }
+ if (geom.request_mode &&
+ XtMakeGeometryRequest (gw, &geom, &retgeom)
+ == XtGeometryAlmost)
+ (void)XtMakeGeometryRequest(gw, &retgeom, NULL);
+ }
+
+ XtResizeWidget(child, Max(XtWidth(child), XtWidth(pw)),
+ Max(XtHeight(child), XtHeight(pw)), 0);
+
+ SendReport(pw, XawPRAll);
+ }
+}
diff --git a/nx-X11/lib/Xaw/Porthole.h b/nx-X11/lib/Xaw/Porthole.h
new file mode 100644
index 000000000..68274d886
--- /dev/null
+++ b/nx-X11/lib/Xaw/Porthole.h
@@ -0,0 +1,63 @@
+/*
+ * $Xorg: Porthole.h,v 1.5 2001/02/09 02:03:45 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.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xaw/Porthole.h,v 1.5 2001/01/17 19:42:29 dawes Exp $ */
+
+#ifndef _XawPorthole_h
+#define _XawPorthole_h
+
+#include <X11/Intrinsic.h>
+#include <X11/Xaw/Reports.h>
+
+/*****************************************************************************
+ *
+ * Porthole Widget (subclass of Composite)
+ *
+ * This widget is similar to a viewport without scrollbars. Child movement
+ * is done by external panners or scrollbars.
+ *
+ * Parameters:
+ *
+ * Name Class Type Default
+ * ---- ----- ---- -------
+ *
+ * background Background Pixel XtDefaultBackground
+ * border BorderColor Pixel XtDefaultForeground
+ * borderWidth BorderWidth Dimension 1
+ * height Height Dimension 0
+ * reportCallback ReportCallback Pointer NULL
+ * width Width Dimension 0
+ * x Position Position 0
+ * y Position Position 0
+ *
+ *****************************************************************************/
+
+extern WidgetClass portholeWidgetClass;
+typedef struct _PortholeClassRec *PortholeWidgetClass;
+typedef struct _PortholeRec *PortholeWidget;
+
+#endif /* _XawPorthole_h */
diff --git a/nx-X11/lib/Xaw/PortholeP.h b/nx-X11/lib/Xaw/PortholeP.h
new file mode 100644
index 000000000..39dcbdc53
--- /dev/null
+++ b/nx-X11/lib/Xaw/PortholeP.h
@@ -0,0 +1,64 @@
+/*
+ * $Xorg: PortholeP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 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.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xaw/PortholeP.h,v 1.7 2001/01/17 19:42:29 dawes Exp $ */
+
+#ifndef _XawPortholeP_h
+#define _XawPortholeP_h
+
+#include <X11/Xaw/Porthole.h>
+
+/* new fields in widget class */
+typedef struct {
+ XtPointer extension;
+} PortholeClassPart;
+
+/* widget class */
+typedef struct _PortholeClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ PortholeClassPart porthole_class;
+} PortholeClassRec;
+
+/* new fields in widget */
+typedef struct {
+ /* resources */
+ XtCallbackList report_callbacks; /* callback/Callback */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} PortholePart;
+
+typedef struct _PortholeRec {
+ CorePart core;
+ CompositePart composite;
+ PortholePart porthole;
+} PortholeRec;
+
+extern PortholeClassRec portholeClassRec;
+
+#endif /* _XawPortholeP_h */
diff --git a/nx-X11/lib/Xaw/Print.h b/nx-X11/lib/Xaw/Print.h
new file mode 100644
index 000000000..7946e8a57
--- /dev/null
+++ b/nx-X11/lib/Xaw/Print.h
@@ -0,0 +1,132 @@
+/* $Xorg: Print.h,v 1.1 2003/07/11 19:46:06 gisburn Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 2003 Danny Backx <danny.backx@skynet.be>
+ ** (c) Copyright 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+
+
+#ifndef _XAW_PRINT_H
+#define _XAW_PRINT_H 1
+
+#include <X11/extensions/Print.h>
+
+/* Resources:
+ NOT WRITTEN YET
+*/
+
+/* XawPrintConfigureLayoutMode - define how the shell resizes/moves itself
+ * to match the paper size
+ * Values:
+ * - XawPrintLAYOUTMODE_NONE
+ * do nothing
+ * - XawPrintLAYOUTMODE_PAGESIZE
+ * set width/height to page size
+ * (this is the default (mainly for compatibilty to XmPrintShell))
+ * - XawPrintLAYOUTMODE_DRAWABLEAREA
+ * set x/y/width/height to drawable area of pag
+ */
+typedef
+enum
+{
+ XawPrintLAYOUTMODE_NONE,
+ XawPrintLAYOUTMODE_PAGESIZE,
+ XawPrintLAYOUTMODE_DRAWABLEAREA
+} XawPrintConfigureLayoutMode;
+
+
+#define XawNstartJobCallback "startJobCallback"
+#define XawNendJobCallback "endJobCallback"
+#define XawNdocSetupCallback "docSetupCallback"
+#define XawNpageSetupCallback "pageSetupCallback"
+#define XawNlayoutMode "layoutMode"
+#define XawCLayoutMode "LayoutMode"
+#define XawNminX "minX"
+#define XawCMinX "MinX"
+#define XawNminY "minY"
+#define XawCMinY "MinY"
+#define XawNmaxX "maxX"
+#define XawCMaxX "MaxX"
+#define XawNmaxY "maxY"
+#define XawCMaxY "MaxY"
+#define XawNcurrDocNumInJob "currDocNumInJob"
+#define XawCCurrDocNumInJob "CurrDocNumInJob"
+#define XawNcurrPageNumInDoc "currPageNumInDoc"
+#define XawCCurrPageNumInDoc "CurrPageNumInDoc"
+#define XawNcurrPageNumInJob "currPageNumInJob"
+#define XawCCurrPageNumInJob "CurrPageNumInJob"
+#define XawNdefaultPixmapResolution "defaultPixmapResolution"
+#define XawCDefaultPixmapResolution "DefaultPixmapResolution"
+
+#define XawCR_START_JOB 70
+#define XawCR_END_JOB 71
+#define XawCR_DOC_SETUP 72
+#define XawCR_PAGE_SETUP 73
+
+typedef struct
+{
+ int reason;
+ XEvent *event;
+ XPContext context;
+ Boolean last_page_in_doc;
+ Boolean last_page_in_job;
+ XtPointer detail;
+} XawPrintShellCallbackStruct;
+
+extern WidgetClass xawPrintShellWidgetClass;
+typedef struct XawPrintShellRec *XawPrintShellWidget;
+
+/************************************************************
+ *
+ * Public Functions.
+ *
+ ************************************************************/
+
+_XFUNCPROTOBEGIN
+
+/* Returns whether the widget passed in is a print shell or "print shell"-like
+ * widget (e.g. print preview).
+ * Note that this will return |True| for more classes than |XawPrintShell| in
+ * the future (like for |XmPrintShell| etc.)
+ */
+extern Boolean XawIsPrintShell(
+#if NeedFunctionPrototypes
+ Widget w
+#endif
+);
+
+extern void XawPrintRedisplayWidget(
+#if NeedFunctionPrototypes
+ Widget w /* Widget */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* !_XAW_PRINT_H */
+
diff --git a/nx-X11/lib/Xaw/PrintSP.h b/nx-X11/lib/Xaw/PrintSP.h
new file mode 100644
index 000000000..e0aca277b
--- /dev/null
+++ b/nx-X11/lib/Xaw/PrintSP.h
@@ -0,0 +1,135 @@
+/* $Xorg: PrintSP.h,v 1.1 2003/07/11 19:46:06 gisburn Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 2003 Danny Backx <danny.backx@skynet.be>
+ ** (c) Copyright 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+
+#ifndef _XAW_PRINTSP_H
+#define _XAW_PRINTSP_H 1
+
+#include <X11/CoreP.h>
+#include <X11/ShellP.h>
+
+_XFUNCPROTOBEGIN
+
+/* New fields for the XawPrintShell widget class record */
+
+typedef struct {
+ XtPointer extension; /* pointer to extension record */
+} XawPrintShellClassPart;
+
+typedef struct XawPrintShellClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ShellClassPart shell_class;
+ WMShellClassPart wm_shell_class;
+ VendorShellClassPart vendor_shell_class;
+ TopLevelShellClassPart top_level_shell_class;
+ ApplicationShellClassPart application_shell_class;
+ XawPrintShellClassPart print_shell_class;
+} XawPrintShellClassRec;
+
+extern XawPrintShellClassRec xawPrintShellClassRec;
+
+/* New fields for the XawPrint shell widget */
+
+typedef struct {
+ XtCallbackList start_job_callback,
+ end_job_callback,
+ doc_setup_callback,
+ page_setup_callback;
+ XtEnum layoutmode; /* see XawPrintConfigureLayoutMode */
+ unsigned short page_width,
+ page_height;
+ Dimension min_x,
+ min_y,
+ max_x,
+ max_y;
+ unsigned int curr_doc_num_in_job, /* Current document number in job */
+ curr_page_num_in_doc, /* Current page number in doc */
+ curr_page_num_in_job; /* Current page number in job */
+ unsigned short default_pixmap_resolution;
+ long print_resolution;
+ Boolean last_page_in_doc;
+ Boolean last_page_in_job;
+} XawPrintShellPart;
+
+typedef struct XawPrintShellRec {
+ CorePart core;
+ CompositePart composite;
+ ShellPart shell;
+ WMShellPart wm;
+ VendorShellPart vendor;
+ TopLevelShellPart topLevel;
+ ApplicationShellPart application;
+ XawPrintShellPart print;
+} XawPrintShellRec;
+extern WidgetClass xawPrintShellWidgetClass;
+
+#define PS_StartJobCallback(w) \
+ (((XawPrintShellWidget) (w))->print.start_job_callback)
+#define PS_EndJobCallback(w) \
+ (((XawPrintShellWidget) (w))->print.end_job_callback)
+#define PS_DocSetupCallback(w) \
+ (((XawPrintShellWidget) (w))->print.doc_setup_callback)
+#define PS_PageSetupCallback(w) \
+ (((XawPrintShellWidget) (w))->print.page_setup_callback)
+#define PS_LayoutMode(w) \
+ (((XawPrintShellWidget) (w))->print.layoutmode)
+#define PS_PageWidth(w) \
+ (((XawPrintShellWidget) (w))->print.page_width)
+#define PS_PageHeight(w) \
+ (((XawPrintShellWidget) (w))->print.page_height)
+#define PS_MinX(w) \
+ (((XawPrintShellWidget) (w))->print.min_x)
+#define PS_MinY(w) \
+ (((XawPrintShellWidget) (w))->print.min_y)
+#define PS_MaxX(w) \
+ (((XawPrintShellWidget) (w))->print.max_x)
+#define PS_MaxY(w) \
+ (((XawPrintShellWidget) (w))->print.max_y)
+#define PS_CurrDocNumInJob(w) \
+ (((XawPrintShellWidget) (w))->print.curr_doc_num_in_job)
+#define PS_CurrPageNumInDoc(w) \
+ (((XawPrintShellWidget) (w))->print.curr_page_num_in_doc)
+#define PS_CurrPageNumInJob(w) \
+ (((XawPrintShellWidget) (w))->print.curr_page_num_in_job)
+#define PS_DefaultPixmapResolution(w) \
+ (((XawPrintShellWidget) (w))->print.default_pixmap_resolution)
+#define PS_PrintResolution(w) \
+ (((XawPrintShellWidget) (w))->print.print_resolution)
+#define PS_LastPageInDoc(w) \
+ (((XawPrintShellWidget) (w))->print.last_page_in_doc)
+#define PS_LastPageInJob(w) \
+ (((XawPrintShellWidget) (w))->print.last_page_in_job)
+
+_XFUNCPROTOEND
+
+#endif /* !_XAW_PRINTSP_H */
+
diff --git a/nx-X11/lib/Xaw/PrintShell.c b/nx-X11/lib/Xaw/PrintShell.c
new file mode 100644
index 000000000..26cb86d1d
--- /dev/null
+++ b/nx-X11/lib/Xaw/PrintShell.c
@@ -0,0 +1,750 @@
+/* $Xorg: PrintShell.c,v 1.1 2003/07/11 19:46:06 gisburn Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 2003 Danny Backx <danny.backx@skynet.be>
+ ** (c) Copyright 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+
+#include "Print.h"
+#include "PrintSP.h"
+
+/* Local prototypes */
+static void class_initialize(void);
+static void class_part_initialize(WidgetClass w_class);
+static void initialize(Widget request, Widget new_w, ArgList args, Cardinal *num_args);
+static void destroy(Widget w);
+static Boolean set_values(Widget current, Widget request, Widget new_w, ArgList args, Cardinal *num_args);
+static void XawPrintNotify(Widget w, XtPointer client, XEvent *evp, Boolean *cont);
+static void XawAttributesNotify(Widget w, XtPointer client, XEvent *evp, Boolean *cont);
+static void XawUpdateLayout(Widget w);
+static void XawUpdateResources(Widget w, XPContext pcontext);
+
+#define Offset(field) XtOffsetOf(XawPrintShellRec, print.field)
+
+#ifdef XAWDEBUG
+#define DEBUGOUT(x) XawDebug x ;
+
+static void
+XawDebug(const char *fn, Widget w, const char *fmt, ...)
+{
+ va_list ap;
+
+ if (w) {
+ fprintf(stderr, "%s %s: ",
+ w->core.widget_class->core_class.class_name, XtName(w));
+ } else {
+ fprintf(stderr, "(null widget): ");
+ }
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+#else
+#define DEBUGOUT(x)
+#endif /* XAWDEBUG */
+
+/* Resources for the PrintShell class */
+static XtResource resources[] =
+{
+ {
+ XawNstartJobCallback, XtCCallback, XtRCallback,
+ sizeof(XtCallbackList), Offset(start_job_callback),
+ XtRImmediate, (XtPointer)NULL
+ },
+ {
+ XawNendJobCallback, XtCCallback, XtRCallback,
+ sizeof(XtCallbackList), Offset(end_job_callback),
+ XtRImmediate, (XtPointer)NULL
+ },
+ {
+ XawNdocSetupCallback, XtCCallback, XtRCallback,
+ sizeof(XtCallbackList), Offset(doc_setup_callback),
+ XtRImmediate, (XtPointer)NULL
+ },
+ {
+ XawNpageSetupCallback, XtCCallback, XtRCallback,
+ sizeof(XtCallbackList), Offset(page_setup_callback),
+ XtRImmediate, (XtPointer)NULL
+ },
+ {
+ XawNlayoutMode, XawCLayoutMode, XtREnum,
+ sizeof(XtEnum), Offset(layoutmode),
+ XtRImmediate, (XtPointer)XawPrintLAYOUTMODE_PAGESIZE
+ },
+ {
+ XawNminX, XawCMinX, XtRDimension,
+ sizeof(Dimension), Offset(min_x),
+ XtRImmediate, (XtPointer)NULL /* dynamic */
+ },
+ {
+ XawNminY, XawCMinY, XtRDimension,
+ sizeof(Dimension), Offset(min_y),
+ XtRImmediate, (XtPointer)NULL /* dynamic */
+ },
+ {
+ XawNmaxX, XawCMaxX, XtRDimension,
+ sizeof(Dimension), Offset(max_x),
+ XtRImmediate, (XtPointer)NULL /* dynamic */
+ },
+ {
+ XawNmaxY, XawCMaxY, XtRDimension,
+ sizeof(Dimension), Offset(max_y),
+ XtRImmediate, (XtPointer)NULL /* dynamic */
+ },
+ {
+ XawNcurrDocNumInJob, XawCCurrDocNumInJob, XtRInt,
+ sizeof(unsigned int), Offset(curr_doc_num_in_job),
+ XtRImmediate, (XtPointer)NULL /* dynamic */
+ },
+ {
+ XawNcurrPageNumInDoc, XawCCurrPageNumInDoc, XtRInt,
+ sizeof(unsigned int), Offset(curr_page_num_in_doc),
+ XtRImmediate, (XtPointer)NULL /* dynamic */
+ },
+ {
+ XawNcurrPageNumInJob, XawCCurrPageNumInJob, XtRInt,
+ sizeof(unsigned int), Offset(curr_page_num_in_job),
+ XtRImmediate, (XtPointer)NULL /* dynamic */
+ },
+ {
+ XawNdefaultPixmapResolution, XawCDefaultPixmapResolution, XtRShort,
+ sizeof(unsigned short), Offset(default_pixmap_resolution),
+ XtRImmediate, (XtPointer)0
+ },
+};
+
+static XtActionsRec actions[] =
+{
+ { NULL, NULL }
+};
+
+XawPrintShellClassRec xawPrintShellClassRec = {
+ /* Core class part */
+ {
+ /* superclass */ (WidgetClass) &applicationShellClassRec,
+ /* class_name */ "XawPrintShell",
+ /* widget_size */ sizeof(XawPrintShellRec),
+ /* class_initialize */ class_initialize,
+ /* class_part_initialize */ class_part_initialize,
+ /* class_inited */ False,
+ /* initialize */ initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ False,
+ /* compress_exposure */ XtExposeCompressSeries,
+ /* compress_enterleave */ False,
+ /* visible_interest */ False,
+ /* destroy */ destroy,
+ /* resize */ XtInheritResize,
+ /* expose */ XtInheritExpose,
+ /* set_values */ set_values,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ XtInheritTranslations,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL /* (XtPointer)&_XawPrintShellCoreClassExtRec */
+ },
+ /* Composite class part */
+ {
+ /* geometry manager */ XtInheritGeometryManager,
+ /* change_managed */ XtInheritChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL,
+ },
+ /* Shell class part */
+ {
+ /* extension */ NULL,
+ },
+ /* WM Shell class part */
+ {
+ /* extension */ NULL,
+ },
+ /* VendorShell class part */
+ {
+ /* extension */ NULL,
+ },
+ /* TopLevelShell class part */
+ {
+ /* extension */ NULL,
+ },
+ /* ApplicationShell class part */
+ {
+ /* extension */ NULL,
+ },
+ {
+ /* ?? */ NULL,
+ },
+};
+
+WidgetClass xawPrintShellWidgetClass = (WidgetClass)&xawPrintShellClassRec;
+
+
+static void
+class_initialize(void)
+{
+}
+
+
+static void
+class_part_initialize(WidgetClass widget_class)
+{
+}
+
+/*
+ * This is a static table to keep the link between widgets and XPContexts.
+ * Yeah - this is probably not a very bright idea. Maybe it should also
+ * contain the Display.
+ */
+typedef struct {
+ Widget w;
+ XPContext c;
+} WidgetContext;
+static WidgetContext *w_ctxt = NULL;
+static int wc_nfields = 0;
+
+static void
+XawStoreWidgetContext(Widget w, XPContext c)
+{
+ wc_nfields++;
+ w_ctxt = (WidgetContext *)XtRealloc((XtPointer)w_ctxt, sizeof(WidgetContext) * wc_nfields);
+ w_ctxt[wc_nfields-1].w = w;
+ w_ctxt[wc_nfields-1].c = c;
+}
+
+/* FIXME: This is not threadsafe... */
+static Widget
+XawPrintContextToWidget(XPContext c)
+{
+ int i;
+
+ for( i = 0 ; i < wc_nfields ; i++ ) {
+ if( w_ctxt[i].c == c ) {
+ return w_ctxt[i].w;
+ }
+ }
+ return NULL;
+}
+
+/* FIXME: This is not threadsafe... */
+static XPContext
+XawPrintWidgetToContext(Widget w)
+{
+ int i;
+
+ for( i = 0 ; i < wc_nfields ; i++ ) {
+ if (w_ctxt[i].w == w) {
+ return w_ctxt[i].c;
+ }
+ }
+ return (XPContext)None;
+}
+
+/* FIXME: This is not threadsafe... */
+static void
+XawPrintDeleteWidgetContext(Widget w)
+{
+ int i;
+
+ for( i = 0 ; i < wc_nfields ; i++ ) {
+ if( w_ctxt[i].w == w ) {
+ w_ctxt[i].w = NULL;
+ w_ctxt[i].c = None;
+ }
+ }
+}
+
+static void
+SelectNotify(Widget w, int *e, XtPointer *s, int n, XtPointer client)
+{
+ XPContext c = XpGetContext(XtDisplay(w));
+
+ if (!c) {
+ XtAppWarning(XtWidgetToApplicationContext(w),
+ "XawPrintShell: SelectNotify: no print context\n");
+ return;
+ }
+
+ XpSelectInput(XtDisplay(w), c, XPPrintMask|XPAttributeMask);
+}
+
+
+static Boolean
+DispatchEvent(XEvent *evp)
+{
+ XPPrintEvent *e = (XPPrintEvent*)evp;
+
+ Widget w = XawPrintContextToWidget(e->context);
+
+ /* Make sure this event is really for this window... */
+ if (XFilterEvent(evp, XtWindow(w)))
+ {
+ DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent *** filter XFilterEvent() matched.\n"));
+ return True;
+ }
+
+ /* Only for debugging */
+#ifdef XAWDEBUG
+ {
+ int error_base,
+ event_base;
+
+ if (!XpQueryExtension(XtDisplay(w), &event_base, &error_base)) {
+ return False;
+ }
+
+ if (e->type == event_base + XPPrintNotify) {
+ switch (e->detail) {
+ case XPStartJobNotify:
+ DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent XPStartJobNotify\n"));
+ break;
+ case XPEndJobNotify:
+ DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent XPEndJobNotify\n"));
+ break;
+ case XPStartDocNotify:
+ DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent XPStartDocNotify\n"));
+ break;
+ case XPStartPageNotify:
+ DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent XPStartPageNotify\n"));
+ break;
+ case XPEndPageNotify:
+ DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent XPEndPageNotify\n"));
+ break;
+ case XPEndDocNotify:
+ DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent XPEndDocNotify\n"));
+ break;
+ default:
+ DEBUGOUT((__FILE__, w, "XawPrintShell DispatchEvent\n"));
+ }
+ }
+ }
+#endif /* XAWDEBUG */
+
+ return XtDispatchEventToWidget(w, evp);
+}
+
+
+static void
+initialize(Widget request, Widget new_w, ArgList args, Cardinal *num_args)
+{
+ int error_base,
+ event_base;
+ XPContext pcontext;
+
+ DEBUGOUT((__FILE__, new_w, "XawPrintShell Initialize\n"));
+
+ if (!XpQueryExtension(XtDisplay(new_w), &event_base, &error_base)) {
+ DEBUGOUT((__FILE__, new_w, "XawPrintShell initialize: failed!!\n"));
+ XtAppWarning(XtWidgetToApplicationContext(new_w),
+ "XawPrintShell: initialize: XpQueryExtension() failed. BAD.\n");
+ return;
+ }
+
+ DEBUGOUT((__FILE__, new_w, "XawPrintShell Initialize event_base %d error_base %d\n",
+ event_base, error_base));
+
+ pcontext = XpGetContext(XtDisplay(new_w));
+
+ if( pcontext == None ) {
+ XtAppWarning(XtWidgetToApplicationContext(new_w),
+ "XawPrintShell: initialize: No print content. BAD.\n");
+ return;
+ }
+
+ /* Make sure that the Xt machinery is really using the right screen (assertion) */
+ if( XpGetScreenOfContext(XtDisplay(new_w), pcontext) != XtScreen(new_w) ) {
+ XtAppWarning(XtWidgetToApplicationContext(new_w),
+ "XawPrintShell: initialize: Widget's screen != print screen. BAD.\n");
+ return;
+ }
+
+ XawStoreWidgetContext(new_w, pcontext);
+
+ XtInsertEventTypeHandler(new_w,
+ event_base + XPPrintNotify,
+ (XtPointer)XPPrintMask,
+ XawPrintNotify, NULL,
+ XtListTail);
+ XtInsertEventTypeHandler(new_w,
+ event_base + XPAttributeNotify,
+ (XtPointer)XPAttributeMask,
+ XawAttributesNotify, NULL,
+ XtListTail);
+
+ XtRegisterExtensionSelector(XtDisplay(new_w),
+ event_base + XPPrintNotify,
+ event_base + XPAttributeNotify,
+ SelectNotify,
+ NULL);
+
+ XtSetEventDispatcher(XtDisplay(new_w),
+ event_base + XPPrintNotify,
+ DispatchEvent);
+ XtSetEventDispatcher(XtDisplay(new_w),
+ event_base + XPAttributeNotify,
+ DispatchEvent);
+
+ PS_LastPageInDoc(new_w) = False;
+ PS_LastPageInJob(new_w) = False;
+
+ XawUpdateResources(new_w, pcontext);
+ XawUpdateLayout(new_w);
+
+ DEBUGOUT((__FILE__, new_w, "XawPrintShell Initialize x %d y %d wid %d ht %d\n",
+ new_w->core.x,
+ new_w->core.y,
+ new_w->core.width,
+ new_w->core.height));
+}
+
+
+static void
+destroy(Widget w)
+{
+ DEBUGOUT((__FILE__, w, "XawPrintShell Destroy\n"));
+ XawPrintDeleteWidgetContext(w);
+}
+
+static Boolean
+set_values(Widget current, Widget request, Widget new_w,
+ ArgList args, Cardinal *num_args)
+{
+ DEBUGOUT((__FILE__, new_w, "XawPrintShell SetValues\n"));
+ return True;
+}
+
+void XawPrintRedisplayWidget(Widget w)
+{
+ XExposeEvent xev;
+ Region region;
+
+ xev.type = Expose;
+ xev.serial = XLastKnownRequestProcessed(XtDisplay(w));
+ xev.send_event = False;
+ xev.display = XtDisplay(w);
+ xev.window = XtWindowOfObject(w);
+ xev.x = 0;
+ xev.y = 0;
+ xev.width = w->core.width;
+ xev.height = w->core.height;
+ xev.count = 0;
+
+ region = XCreateRegion();
+ if (!region)
+ return;
+
+ XtAddExposureToRegion((XEvent*)&xev, region);
+
+ if (w->core.widget_class->core_class.expose)
+ (*(w->core.widget_class->core_class.expose))(w, (XEvent *)&xev, region);
+
+ XDestroyRegion(region);
+}
+
+/* Returns whether the widget passed in is a print shell or "print shell"-like
+ * widget (e.g. print preview).
+ * Note that this will return |True| for more classes than |XawPrintShell| in
+ * the future (like for |XmPrintShell| etc.)
+ */
+Boolean
+XawIsPrintShell(Widget w)
+{
+ return XtIsSubclass(w, xawPrintShellWidgetClass);
+}
+
+
+static void
+XawPrintNotify(Widget w, XtPointer client, XEvent *evp, Boolean *cont)
+{
+ XPPrintEvent *e = (XPPrintEvent *)evp;
+ XawPrintShellCallbackStruct cbs;
+
+ switch (e->detail) {
+ case XPStartPageNotify:
+ DEBUGOUT((__FILE__, w, "XPStartPageNotify\n"));
+
+ /* Re do not have to call |XawPrintRedisplayWidget(w)| here since
+ * Xprint triggers an expose event anyway
+ */
+
+ DEBUGOUT((__FILE__, w, "XpEndPage\n"));
+ XpEndPage(XtDisplay(w));
+ break;
+
+ case XPEndPageNotify:
+ DEBUGOUT((__FILE__, w, "XPEndPageNotify\n"));
+
+ if (PS_LastPageInDoc(w) || PS_LastPageInJob(w)) {
+ DEBUGOUT((__FILE__, w, "XpEndDoc\n"));
+ XpEndDoc(XtDisplay(w));
+ }
+ else {
+ /* Increment page numbers... */
+ PS_CurrPageNumInDoc(w) += 1;
+ PS_CurrPageNumInJob(w) += 1;
+
+ /* ... do the page setup callback ... */
+ cbs.reason = XawCR_PAGE_SETUP;
+ cbs.event = evp;
+ cbs.detail = NULL;
+ cbs.context = XawPrintWidgetToContext(w);
+ cbs.last_page_in_doc = False;
+ cbs.last_page_in_job = False;
+
+ if (PS_PageSetupCallback(w))
+ XtCallCallbackList(w, PS_PageSetupCallback(w), &cbs);
+
+ PS_LastPageInDoc(w) = cbs.last_page_in_doc;
+ PS_LastPageInJob(w) = cbs.last_page_in_job;
+
+ /* ... and start the new page */
+ DEBUGOUT((__FILE__, w, "XpStartPage\n"));
+ XpStartPage(XtDisplay(w), XtWindow(w));
+ }
+ break;
+
+ case XPStartDocNotify:
+ DEBUGOUT((__FILE__, w, "XPStartDocNotify\n"));
+
+ cbs.reason = XawCR_PAGE_SETUP;
+ cbs.event = evp;
+ cbs.detail = NULL;
+ cbs.context = XawPrintWidgetToContext(w);
+ cbs.last_page_in_doc = False;
+ cbs.last_page_in_job = False;
+
+ if (PS_PageSetupCallback(w))
+ XtCallCallbackList(w, PS_PageSetupCallback(w), &cbs);
+
+ PS_LastPageInDoc(w) = cbs.last_page_in_doc;
+ PS_LastPageInJob(w) = cbs.last_page_in_job;
+
+ DEBUGOUT((__FILE__, w, "XpStartPage\n"));
+ XpStartPage(XtDisplay(w), XtWindow(w));
+ break;
+
+ case XPEndDocNotify:
+ DEBUGOUT((__FILE__, w, "XPEndDocNotify\n"));
+
+ /* Start a new document (via XpStartDoc()) if we are not done with the job yet,
+ * otherwise finish the job (via XpEndJob())
+ */
+ if (PS_LastPageInJob(w)) {
+ DEBUGOUT((__FILE__, w, "XpEndJob\n"));
+ XpEndJob(XtDisplay(w));
+ }
+ else {
+ PS_CurrDocNumInJob(w) += 1;
+ PS_CurrPageNumInDoc(w) = 1;
+
+ cbs.reason = XawCR_DOC_SETUP;
+ cbs.event = evp;
+ cbs.detail = NULL;
+ cbs.context = XawPrintWidgetToContext(w);
+ cbs.last_page_in_doc = False;
+ cbs.last_page_in_job = False;
+
+ if (PS_DocSetupCallback(w))
+ XtCallCallbackList(w, PS_DocSetupCallback(w), &cbs);
+
+ PS_LastPageInDoc(w) = cbs.last_page_in_doc;
+ PS_LastPageInJob(w) = cbs.last_page_in_job;
+
+ DEBUGOUT((__FILE__, w, "XpStartDoc\n"));
+ XpStartDoc(XtDisplay(w), XPDocNormal);
+ }
+ break;
+
+ case XPStartJobNotify:
+ DEBUGOUT((__FILE__, w, "XPStartJobNotify\n"));
+ PS_LastPageInJob(w) = False;
+ PS_LastPageInDoc(w) = False;
+ PS_CurrDocNumInJob(w) = 1;
+ PS_CurrPageNumInDoc(w) = 1;
+ PS_CurrPageNumInJob(w) = 1;
+
+ cbs.reason = XawCR_START_JOB;
+ cbs.event = evp;
+ cbs.detail = NULL;
+ cbs.context = XawPrintWidgetToContext(w);
+ cbs.last_page_in_doc = False;
+ cbs.last_page_in_job = False;
+
+ if (PS_StartJobCallback(w))
+ XtCallCallbackList(w, PS_StartJobCallback(w), &cbs);
+
+ PS_LastPageInDoc(w) = cbs.last_page_in_doc;
+ PS_LastPageInJob(w) = cbs.last_page_in_job;
+
+ /* Start a document (which will trigger the first page in
+ * |XPStartDocNotify| above) */
+ if (PS_LastPageInDoc(w) || PS_LastPageInJob(w)) {
+ DEBUGOUT((__FILE__, w, "XpEndJob\n"));
+ XpEndJob(XtDisplay(w));
+ }
+ else
+ {
+ cbs.reason = XawCR_DOC_SETUP;
+ cbs.event = evp;
+ cbs.detail = NULL;
+ cbs.context = XawPrintWidgetToContext(w);
+ cbs.last_page_in_doc = False;
+ cbs.last_page_in_job = False;
+
+ if (PS_DocSetupCallback(w))
+ XtCallCallbackList(w, PS_DocSetupCallback(w), &cbs);
+
+ PS_LastPageInDoc(w) = cbs.last_page_in_doc;
+ PS_LastPageInJob(w) = cbs.last_page_in_job;
+
+ DEBUGOUT((__FILE__, w, "XpStartDoc\n"));
+ XpStartDoc(XtDisplay(w), XPDocNormal);
+ }
+ break;
+
+ case XPEndJobNotify:
+ DEBUGOUT((__FILE__, w, "XPEndJobNotify\n"));
+ cbs.reason = XawCR_END_JOB;
+ cbs.event = evp;
+ cbs.detail = NULL;
+ cbs.context = None;
+ cbs.last_page_in_doc = True;
+ cbs.last_page_in_job = True;
+
+ if (PS_EndJobCallback(w))
+ XtCallCallbackList(w, PS_EndJobCallback(w), &cbs);
+ break;
+
+ default:
+ DEBUGOUT((__FILE__, w, "XawPrintNotify(default)\n"));
+ break;
+ }
+}
+
+static void
+XawUpdateResources(Widget w, XPContext pcontext)
+{
+ XawPrintShellWidget print_shell = (XawPrintShellWidget)w;
+ String string_resolution;
+ XRectangle drawable_paper_area;
+
+ string_resolution = XpGetOneAttribute(XtDisplay(w), pcontext, XPDocAttr, "default-printer-resolution");
+ if (!string_resolution) {
+ XtAppWarning(XtWidgetToApplicationContext(w),
+ "XawPrintShell: XawUpdateResources: Could not get 'default-printer-resolution' XPDocAttr\n");
+ }
+ print_shell->print.print_resolution = atol(string_resolution);
+ XFree(string_resolution);
+
+ if (print_shell->print.print_resolution == 0) {
+ XtAppWarning(XtWidgetToApplicationContext(w),
+ "XawPrintShell: XawUpdateResources: Resolution '0' invalid\n");
+ }
+
+ /* Get the paper size... */
+ XpGetPageDimensions(XtDisplay(w), pcontext,
+ &print_shell->print.page_width, &print_shell->print.page_height,
+ &drawable_paper_area);
+ /* ... and store it in the widget */
+ print_shell->print.min_x = drawable_paper_area.x;
+ print_shell->print.min_y = drawable_paper_area.y;
+ print_shell->print.max_x = drawable_paper_area.x + drawable_paper_area.width;
+ print_shell->print.max_y = drawable_paper_area.y + drawable_paper_area.height;
+}
+
+static void
+XawUpdateLayout(Widget w)
+{
+ XawPrintShellWidget print_shell = (XawPrintShellWidget)w;
+
+ switch( print_shell->print.layoutmode )
+ {
+ case XawPrintLAYOUTMODE_NONE:
+ break;
+ case XawPrintLAYOUTMODE_PAGESIZE:
+ XtResizeWidget(w,
+ print_shell->print.page_width,
+ print_shell->print.page_height,
+ w->core.border_width);
+ break;
+ case XawPrintLAYOUTMODE_DRAWABLEAREA:
+ XtConfigureWidget(w,
+ print_shell->print.min_x,
+ print_shell->print.min_y,
+ print_shell->print.max_x - print_shell->print.min_x,
+ print_shell->print.max_y - print_shell->print.min_y,
+ w->core.border_width);
+ break;
+ default:
+ XtAppWarning(XtWidgetToApplicationContext(w),
+ "XawPrintShell: XawUpdateResources: Invalid layout mode\n");
+ break;
+ }
+}
+
+
+/* Update widget attributes+properties when the we receive
+ * "Xp attribute change"-events (e.g. paper (size/orientation/etc.)
+ * changed etc.) */
+static void
+XawAttributesNotify(Widget w,
+ XtPointer client,
+ XEvent *evp,
+ Boolean *cont)
+{
+ XawPrintShellWidget print_shell = (XawPrintShellWidget)w;
+ XPAttributeEvent *xpevp = (XPAttributeEvent *)evp;
+
+ XawUpdateResources(w, xpevp->context);
+ XawUpdateLayout(w);
+}
+
+
+
diff --git a/nx-X11/lib/Xaw/Private.h b/nx-X11/lib/Xaw/Private.h
new file mode 100644
index 000000000..a76207a4d
--- /dev/null
+++ b/nx-X11/lib/Xaw/Private.h
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 1998 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+
+/* $XFree86: xc/lib/Xaw/Private.h,v 3.9 1999/05/16 10:12:48 dawes Exp $ */
+
+#ifndef _XawPrivate_h
+#define _XawPrivate_h
+
+#define XawMax(a, b) ((a) > (b) ? (a) : (b))
+#define XawMin(a, b) ((a) < (b) ? (a) : (b))
+#define XawAbs(a) ((a) < 0 ? -(a) : (a))
+
+#define XawStackAlloc(size, stk_buffer) \
+((size) <= sizeof(stk_buffer) \
+ ? (XtPointer)(stk_buffer) \
+ : XtMalloc((unsigned)(size)))
+
+#define XawStackFree(pointer, stk_buffer) \
+do { \
+ if ((pointer) != (XtPointer)(stk_buffer)) \
+ XtFree((char *)pointer); \
+} while (0)
+
+#ifndef XtX
+#define XtX(w) (((RectObj)w)->rectangle.x)
+#endif
+#ifndef XtY
+#define XtY(w) (((RectObj)w)->rectangle.y)
+#endif
+#ifndef XtWidth
+#define XtWidth(w) (((RectObj)w)->rectangle.width)
+#endif
+#ifndef XtHeight
+#define XtHeight(w) (((RectObj)w)->rectangle.height)
+#endif
+#ifndef XtBorderWidth
+#define XtBorderWidth(w) (((RectObj)w)->rectangle.border_width)
+#endif
+
+#ifndef OLDXAW
+#define XAW_PRIV_VAR_PREFIX '$'
+
+typedef Bool (*XawParseBooleanProc)(Widget, String, XEvent*, Bool*);
+
+typedef struct _XawActionVarList XawActionVarList;
+typedef struct _XawActionResList XawActionResList;
+
+/* Boolean expressions */
+Bool XawParseBoolean(Widget, String, XEvent*, Bool*);
+Bool XawBooleanExpression(Widget, String, XEvent*);
+
+/* actions */
+void XawPrintActionErrorMsg(String, Widget, String*, Cardinal*);
+XawActionResList *XawGetActionResList(WidgetClass);
+XawActionVarList *XawGetActionVarList(Widget);
+
+void XawSetValuesAction(Widget, XEvent*, String*, Cardinal*);
+void XawGetValuesAction(Widget, XEvent*, String*, Cardinal*);
+void XawDeclareAction(Widget, XEvent*, String*, Cardinal*);
+void XawCallProcAction(Widget, XEvent*, String*, Cardinal*);
+
+/* display lists */
+#define XAWDL_CONVERT_ERROR (XtPointer)-1
+typedef struct _XawDL _XawDisplayList;
+typedef struct _XawDLClass XawDLClass, XawDisplayListClass;
+
+typedef void (*XawDisplayListProc)(Widget, XtPointer, XtPointer,
+ XEvent*, Region);
+typedef void *(*XawDLArgsInitProc)(String, String*, Cardinal*,
+ Screen*, Colormap, int);
+typedef void *(*XawDLDataInitProc)(String,
+ Screen*, Colormap, int);
+typedef void (*XawDLArgsDestructor)(Display*, String, XtPointer,
+ String*, Cardinal*);
+typedef void (*XawDLDataDestructor)(Display*, String, XtPointer);
+
+void XawRunDisplayList(Widget, _XawDisplayList*, XEvent*, Region);
+void XawDisplayListInitialize(void);
+
+_XawDisplayList *XawCreateDisplayList(String, Screen*, Colormap, int);
+void XawDestroyDisplayList(_XawDisplayList*);
+String XawDisplayListString(_XawDisplayList*);
+XawDLClass *XawGetDisplayListClass(String);
+XawDLClass *XawCreateDisplayListClass(String,
+ XawDLArgsInitProc, XawDLArgsDestructor,
+ XawDLDataInitProc, XawDLDataDestructor);
+Bool XawDeclareDisplayListProc(XawDLClass*, String, XawDisplayListProc);
+
+/* pixmaps */
+typedef struct _XawArgVal {
+ String name;
+ String value;
+} XawArgVal;
+
+typedef struct _XawParams {
+ String name;
+ String type;
+ String ext;
+ XawArgVal **args;
+ Cardinal num_args;
+} XawParams;
+
+typedef struct _XawPixmap {
+ String name;
+ Pixmap pixmap;
+ Pixmap mask;
+ Dimension width;
+ Dimension height;
+} XawPixmap;
+
+typedef Bool (*XawPixmapLoader)(XawParams*, Screen*, Colormap, int,
+ Pixmap*, Pixmap*,
+ Dimension*, Dimension*);
+Bool XawPixmapsInitialize(void);
+Bool XawAddPixmapLoader(String, String, XawPixmapLoader);
+XawPixmap *XawLoadPixmap(String, Screen*, Colormap, int);
+XawPixmap *XawPixmapFromXPixmap(Pixmap, Screen*, Colormap, int);
+XawParams *XawParseParamsString(String name);
+void XawFreeParamsStruct(XawParams *params);
+XawArgVal *XawFindArgVal(XawParams *params, String name);
+void XawReshapeWidget(Widget, XawPixmap*);
+#endif /* OLDXAW */
+
+/* misc */
+void XawTypeToStringWarning(Display*, String);
+
+/* OS.c */
+int _XawGetPageSize(void);
+
+#endif /* _XawPrivate_h */
diff --git a/nx-X11/lib/Xaw/Repeater.c b/nx-X11/lib/Xaw/Repeater.c
new file mode 100644
index 000000000..52ae2959e
--- /dev/null
+++ b/nx-X11/lib/Xaw/Repeater.c
@@ -0,0 +1,300 @@
+/*
+ * $Xorg: Repeater.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 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.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ *
+ * This widget is used for press-and-hold style buttons.
+ */
+/* $XFree86: xc/lib/Xaw/Repeater.c,v 1.6 2001/01/17 19:42:29 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/RepeaterP.h>
+#include <X11/Xaw/XawInit.h>
+
+#define DO_CALLBACK(rw) \
+XtCallCallbackList((Widget)rw, rw->command.callbacks, NULL)
+
+#define ADD_TIMEOUT(rw, delay) \
+XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)rw), \
+ delay, tic, (XtPointer)rw)
+
+#define CLEAR_TIMEOUT(rw) \
+if ((rw)->repeater.timer) { \
+ XtRemoveTimeOut((rw)->repeater.timer); \
+ (rw)->repeater.timer = 0; \
+}
+
+/*
+ * Class Methods
+ */
+static void XawRepeaterInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawRepeaterDestroy(Widget);
+static Boolean XawRepeaterSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static void tic(XtPointer, XtIntervalId*);
+
+/*
+ * Actions
+ */
+static void ActionStart(Widget, XEvent*, String*, Cardinal*);
+static void ActionStop(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * Initialization
+ */
+static char defaultTranslations[] =
+"<Enter>:" "highlight()\n"
+"<Leave>:" "unhighlight()\n"
+"<Btn1Down>:" "set() start()\n"
+"<Btn1Up>:" "stop() unset()\n"
+;
+
+static XtActionsRec actions[] = {
+ {"start", ActionStart},
+ {"stop", ActionStop},
+};
+
+#define offset(field) XtOffsetOf(RepeaterRec, repeater.field)
+static XtResource resources[] = {
+ {
+ XtNdecay,
+ XtCDecay,
+ XtRInt,
+ sizeof(int),
+ offset(decay),
+ XtRImmediate,
+ (XtPointer)REP_DEF_DECAY
+ },
+ {
+ XtNinitialDelay,
+ XtCDelay,
+ XtRInt,
+ sizeof(int),
+ offset(initial_delay),
+ XtRImmediate,
+ (XtPointer)REP_DEF_INITIAL_DELAY
+ },
+ {
+ XtNminimumDelay,
+ XtCMinimumDelay,
+ XtRInt,
+ sizeof(int),
+ offset(minimum_delay),
+ XtRImmediate,
+ (XtPointer)REP_DEF_MINIMUM_DELAY
+ },
+ {
+ XtNrepeatDelay,
+ XtCDelay,
+ XtRInt,
+ sizeof(int),
+ offset(repeat_delay),
+ XtRImmediate,
+ (XtPointer)REP_DEF_REPEAT_DELAY
+ },
+ {
+ XtNflash,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(flash),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNstartCallback,
+ XtCStartCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(start_callbacks),
+ XtRImmediate,
+ NULL
+ },
+ {
+ XtNstopCallback,
+ XtCStopCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(stop_callbacks),
+ XtRImmediate,
+ NULL
+ },
+};
+#undef offset
+
+#define Superclass (&commandClassRec)
+RepeaterClassRec repeaterClassRec = {
+ /* core */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "Repeater", /* class_name */
+ sizeof(RepeaterRec), /* widget_size */
+ XawInitializeWidgetSet, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ XawRepeaterInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ actions, /* actions */
+ XtNumber(actions), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ XawRepeaterDestroy, /* destroy */
+ XtInheritResize, /* resize */
+ XtInheritExpose, /* expose */
+ XawRepeaterSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ defaultTranslations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* simple */
+ {
+ XtInheritChangeSensitive, /* change_sensitive */
+ },
+ /* label */
+ {
+ NULL, /* extension */
+ },
+ /* command */
+ {
+ NULL, /* extension */
+ },
+ /* repeater */
+ {
+ NULL, /* extension */
+ },
+};
+
+WidgetClass repeaterWidgetClass = (WidgetClass) &repeaterClassRec;
+
+
+/*
+ * Implementation
+ */
+/*ARGSUSED*/
+static void
+tic(XtPointer client_data, XtIntervalId *id)
+{
+ RepeaterWidget rw = (RepeaterWidget)client_data;
+
+ rw->repeater.timer = 0; /* timer is removed */
+ if (rw->repeater.flash) {
+ Widget w = (Widget)rw;
+
+ XClearWindow(XtDisplay(w), XtWindow(w));
+ XtCallActionProc(w, "reset", NULL, NULL, 0);
+ XClearWindow(XtDisplay(w), XtWindow(w));
+ XtCallActionProc(w, "set", NULL, NULL, 0);
+ }
+ DO_CALLBACK(rw);
+
+ rw->repeater.timer = ADD_TIMEOUT(rw, rw->repeater.next_delay);
+
+ if (rw->repeater.decay) {
+ rw->repeater.next_delay -= rw->repeater.decay;
+ if (rw->repeater.next_delay < rw->repeater.minimum_delay)
+ rw->repeater.next_delay = rw->repeater.minimum_delay;
+ }
+}
+
+/*ARGSUSED*/
+static void
+XawRepeaterInitialize(Widget greq, Widget gnew,
+ ArgList args, Cardinal *num_args)
+{
+ RepeaterWidget cnew = (RepeaterWidget)gnew;
+
+ if (cnew->repeater.minimum_delay < 0)
+ cnew->repeater.minimum_delay = 0;
+ cnew->repeater.timer = 0;
+}
+
+static void
+XawRepeaterDestroy(Widget gw)
+{
+ CLEAR_TIMEOUT((RepeaterWidget)gw);
+}
+
+/*ARGSUSED*/
+static Boolean
+XawRepeaterSetValues(Widget gcur, Widget greq, Widget gnew,
+ ArgList args, Cardinal *num_args)
+{
+ RepeaterWidget cur = (RepeaterWidget)gcur;
+ RepeaterWidget cnew = (RepeaterWidget)gnew;
+
+ if (cur->repeater.minimum_delay != cnew->repeater.minimum_delay) {
+ if (cnew->repeater.next_delay < cnew->repeater.minimum_delay)
+ cnew->repeater.next_delay = cnew->repeater.minimum_delay;
+ }
+
+ return (False);
+}
+
+/*ARGSUSED*/
+static void
+ActionStart(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ RepeaterWidget rw = (RepeaterWidget)gw;
+
+ CLEAR_TIMEOUT(rw);
+ if (rw->repeater.start_callbacks)
+ XtCallCallbackList(gw, rw->repeater.start_callbacks, NULL);
+
+ DO_CALLBACK(rw);
+ rw->repeater.timer = ADD_TIMEOUT(rw, rw->repeater.initial_delay);
+ rw->repeater.next_delay = rw->repeater.repeat_delay;
+}
+
+/*ARGSUSED*/
+static void
+ActionStop(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ RepeaterWidget rw = (RepeaterWidget)gw;
+
+ CLEAR_TIMEOUT((RepeaterWidget)gw);
+ if (rw->repeater.stop_callbacks)
+ XtCallCallbackList(gw, rw->repeater.stop_callbacks, NULL);
+}
diff --git a/nx-X11/lib/Xaw/Repeater.h b/nx-X11/lib/Xaw/Repeater.h
new file mode 100644
index 000000000..cfb2c5313
--- /dev/null
+++ b/nx-X11/lib/Xaw/Repeater.h
@@ -0,0 +1,75 @@
+/*
+ * $Xorg: Repeater.h,v 1.4 2001/02/09 02:03:45 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.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xaw/Repeater.h,v 1.5 2001/01/17 19:42:29 dawes Exp $ */
+
+#ifndef _XawRepeater_h
+#define _XawRepeater_h
+
+#include <X11/Xaw/Command.h>
+
+/*****************************************************************************
+ *
+ * Repeater Widget (subclass of Command)
+ *
+ * This widget is a push button that repeatedly fires when held down
+ *
+ * Parameters:
+ *
+ * Name Class Type Default
+ * ---- ----- ---- -------
+ *
+ * decay Decay int 5 milliseconds
+ * flash Boolean Boolean FALSE
+ * initialDelay Delay int 200 milliseconds
+ * minimumDelay MinimumDelay int 10 milliseconds
+ * repeatDelay Delay int 50 milliseconds
+ * startCallback StartCallback XtCallbackList NULL
+ * stopCallback StopCallback XtCallbackList NULL
+ *
+ *****************************************************************************/
+
+#define XtNdecay "decay"
+#define XtCDecay "Decay"
+#define XtNinitialDelay "initialDelay"
+#define XtCDelay "Delay"
+#define XtNminimumDelay "minimumDelay"
+#define XtCMinimumDelay "MinimumDelay"
+#define XtNrepeatDelay "repeatDelay"
+#define XtNflash "flash"
+#define XtNstartCallback "startCallback"
+#define XtCStartCallback "StartCallback"
+#define XtNstopCallback "stopCallback"
+#define XtCStopCallback "StopCallback"
+
+
+extern WidgetClass repeaterWidgetClass;
+
+typedef struct _RepeaterClassRec *RepeaterWidgetClass;
+typedef struct _RepeaterRec *RepeaterWidget;
+
+#endif /* _XawRepeater_h */
diff --git a/nx-X11/lib/Xaw/RepeaterP.h b/nx-X11/lib/Xaw/RepeaterP.h
new file mode 100644
index 000000000..3ce0a498c
--- /dev/null
+++ b/nx-X11/lib/Xaw/RepeaterP.h
@@ -0,0 +1,84 @@
+/*
+ * $Xorg: RepeaterP.h,v 1.4 2001/02/09 02:03:45 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.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xaw/RepeaterP.h,v 1.7 2001/01/17 19:42:29 dawes Exp $ */
+
+#ifndef _XawRepeaterP_h
+#define _XawRepeaterP_h
+
+#include <X11/Xaw/CommandP.h>
+#include <X11/Xaw/Repeater.h>
+
+/* new fields in widget class */
+typedef struct {
+ XtPointer extension;
+} RepeaterClassPart;
+
+/* repeater widget class */
+typedef struct _RepeaterClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ LabelClassPart label_class;
+ CommandClassPart command_class;
+ RepeaterClassPart repeater_class;
+} RepeaterClassRec;
+
+typedef struct {
+ /* resources */
+ int initial_delay; /* initialDelay/Delay */
+ int repeat_delay; /* repeatDelay/Delay */
+ int minimum_delay; /* minimumDelay/MinimumDelay */
+ int decay; /* decay to minimum delay */
+ Boolean flash; /* flash/Boolean */
+ XtCallbackList start_callbacks; /* startCallback/StartCallback */
+ XtCallbackList stop_callbacks; /* stopCallback/StopCallback */
+
+ /* private */
+ int next_delay; /* next amount for timer */
+ XtIntervalId timer; /* timer that will fire */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} RepeaterPart;
+
+typedef struct _RepeaterRec {
+ CorePart core;
+ SimplePart simple;
+ LabelPart label;
+ CommandPart command;
+ RepeaterPart repeater;
+} RepeaterRec;
+
+ /* milliseconds */
+#define REP_DEF_DECAY 5
+#define REP_DEF_INITIAL_DELAY 200
+#define REP_DEF_MINIMUM_DELAY 10
+#define REP_DEF_REPEAT_DELAY 50
+
+extern RepeaterClassRec repeaterClassRec;
+
+#endif /* _XawRepeaterP_h */
diff --git a/nx-X11/lib/Xaw/Reports.h b/nx-X11/lib/Xaw/Reports.h
new file mode 100644
index 000000000..33f18d187
--- /dev/null
+++ b/nx-X11/lib/Xaw/Reports.h
@@ -0,0 +1,56 @@
+/*
+ * $Xorg: Reports.h,v 1.5 2001/02/09 02:03:45 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.
+ */
+
+#ifndef _Xaw_Reports_h
+#define _Xaw_Reports_h
+
+#include <X11/Intrinsic.h>
+
+/*
+ * XawPannerReport - this structure is used by the reportCallback of the
+ * Panner, Porthole, Viewport, and Scrollbar widgets to report its position.
+ * All fields must be filled in, although the changed field may be used as
+ * a hint as to which fields have been altered since the last report.
+ */
+typedef struct {
+ unsigned int changed; /* mask, see below */
+ Position slider_x, slider_y; /* location of slider within outer */
+ Dimension slider_width, slider_height; /* size of slider */
+ Dimension canvas_width, canvas_height; /* size of canvas */
+} XawPannerReport;
+
+#define XawPRSliderX (1 << 0)
+#define XawPRSliderY (1 << 1)
+#define XawPRSliderWidth (1 << 2)
+#define XawPRSliderHeight (1 << 3)
+#define XawPRCanvasWidth (1 << 4)
+#define XawPRCanvasHeight (1 << 5)
+#define XawPRAll (63) /* union of above */
+
+#define XtNreportCallback "reportCallback"
+#define XtCReportCallback "reportCallback"
+
+#endif /* _Xaw_Reports_h */
diff --git a/nx-X11/lib/Xaw/Scrollbar.c b/nx-X11/lib/Xaw/Scrollbar.c
new file mode 100644
index 000000000..e6dea9c41
--- /dev/null
+++ b/nx-X11/lib/Xaw/Scrollbar.c
@@ -0,0 +1,885 @@
+/* $Xorg: Scrollbar.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Scrollbar.c,v 1.12 2001/01/17 19:42:29 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Drawing.h>
+#include <X11/Xaw/ScrollbarP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+#define NoButton -1
+#define PICKLENGTH(widget, x, y) \
+(((widget)->scrollbar.orientation == XtorientHorizontal) ? (x) : (y))
+
+/*
+ * Class Methods
+ */
+static void XawScrollbarClassInitialize(void);
+static void XawScrollbarDestroy(Widget);
+static void XawScrollbarInitialize(Widget, Widget, ArgList, Cardinal*_args);
+static void XawScrollbarRealize(Widget, Mask*, XSetWindowAttributes*);
+static void XawScrollbarRedisplay(Widget, XEvent*, Region);
+static void XawScrollbarResize(Widget);
+static Boolean XawScrollbarSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static Boolean CompareEvents(XEvent*, XEvent*);
+static void CreateGC(Widget);
+static float FloatInRange(float, float, float);
+static float FractionLoc(ScrollbarWidget, int, int);
+static void ExtractPosition(XEvent*, Position*, Position*);
+static int InRange(int, int, int);
+static void FillArea(ScrollbarWidget, int, int, int);
+static Bool LookAhead(Widget, XEvent*);
+static void PaintThumb(ScrollbarWidget);
+static Bool PeekNotifyEvent(Display*, XEvent*, char*);
+static void SetDimensions(ScrollbarWidget);
+
+/*
+ * Actions
+ */
+static void EndScroll(Widget, XEvent*, String*, Cardinal*);
+static void MoveThumb(Widget, XEvent*, String*, Cardinal*);
+static void NotifyScroll(Widget, XEvent*, String*, Cardinal*);
+static void NotifyThumb(Widget, XEvent*, String*, Cardinal*);
+static void StartScroll(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * Initialization
+ */
+static char defaultTranslations[] =
+"<Btn1Down>:" "StartScroll(Forward)\n"
+"<Btn2Down>:" "StartScroll(Continuous) MoveThumb() NotifyThumb()\n"
+"<Btn3Down>:" "StartScroll(Backward)\n"
+"<Btn2Motion>:" "MoveThumb() NotifyThumb()\n"
+"<BtnUp>:" "NotifyScroll(Proportional) EndScroll()\n";
+
+static float floatZero = 0.0;
+
+#define Offset(field) XtOffsetOf(ScrollbarRec, field)
+
+static XtResource resources[] = {
+ {
+ XtNlength,
+ XtCLength,
+ XtRDimension,
+ sizeof(Dimension),
+ Offset(scrollbar.length),
+ XtRImmediate,
+ (XtPointer)1
+ },
+ {
+ XtNthickness,
+ XtCThickness,
+ XtRDimension,
+ sizeof(Dimension),
+ Offset(scrollbar.thickness),
+ XtRImmediate,
+ (XtPointer)14
+ },
+ {
+ XtNorientation,
+ XtCOrientation,
+ XtROrientation,
+ sizeof(XtOrientation),
+ Offset(scrollbar.orientation),
+ XtRImmediate,
+ (XtPointer)XtorientVertical
+ },
+ {
+ XtNscrollProc,
+ XtCCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ Offset(scrollbar.scrollProc),
+ XtRCallback,
+ NULL
+ },
+ {
+ XtNthumbProc,
+ XtCCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ Offset(scrollbar.thumbProc),
+ XtRCallback,
+ NULL
+ },
+ {
+ XtNjumpProc,
+ XtCCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ Offset(scrollbar.jumpProc),
+ XtRCallback,
+ NULL
+ },
+ {
+ XtNthumb,
+ XtCThumb,
+ XtRBitmap,
+ sizeof(Pixmap),
+ Offset(scrollbar.thumb),
+ XtRImmediate,
+ (XtPointer)XtUnspecifiedPixmap
+ },
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ Offset(scrollbar.foreground),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XtNshown,
+ XtCShown,
+ XtRFloat,
+ sizeof(float),
+ Offset(scrollbar.shown),
+ XtRFloat,
+ (XtPointer)&floatZero
+ },
+ {
+ XtNtopOfThumb,
+ XtCTopOfThumb,
+ XtRFloat,
+ sizeof(float),
+ Offset(scrollbar.top),
+ XtRFloat,
+ (XtPointer)&floatZero
+ },
+ {
+ XtNscrollVCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ Offset(scrollbar.verCursor),
+ XtRString,
+ "sb_v_double_arrow"
+ },
+ {
+ XtNscrollHCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ Offset(scrollbar.horCursor),
+ XtRString,
+ "sb_h_double_arrow"
+ },
+ {
+ XtNscrollUCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ Offset(scrollbar.upCursor),
+ XtRString,
+ "sb_up_arrow"
+ },
+ {
+ XtNscrollDCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ Offset(scrollbar.downCursor),
+ XtRString,
+ "sb_down_arrow"
+ },
+ {
+ XtNscrollLCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ Offset(scrollbar.leftCursor),
+ XtRString,
+ "sb_left_arrow"
+ },
+ {
+ XtNscrollRCursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ Offset(scrollbar.rightCursor),
+ XtRString,
+ "sb_right_arrow"
+ },
+ {
+ XtNminimumThumb,
+ XtCMinimumThumb,
+ XtRDimension,
+ sizeof(Dimension),
+ Offset(scrollbar.min_thumb),
+ XtRImmediate,
+ (XtPointer)7
+ },
+};
+#undef Offset
+
+static XtActionsRec actions[] = {
+ {"StartScroll", StartScroll},
+ {"MoveThumb", MoveThumb},
+ {"NotifyThumb", NotifyThumb},
+ {"NotifyScroll", NotifyScroll},
+ {"EndScroll", EndScroll},
+};
+
+#define Superclass (&simpleClassRec)
+ScrollbarClassRec scrollbarClassRec = {
+ /* core */
+ {
+ (WidgetClass)&simpleClassRec, /* superclass */
+ "Scrollbar", /* class_name */
+ sizeof(ScrollbarRec), /* widget_size */
+ XawScrollbarClassInitialize, /* class_initialize */
+ NULL, /* class_part_init */
+ False, /* class_inited */
+ XawScrollbarInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XawScrollbarRealize, /* realize */
+ actions, /* actions */
+ XtNumber(actions), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ XawScrollbarDestroy, /* destroy */
+ XawScrollbarResize, /* resize */
+ XawScrollbarRedisplay, /* expose */
+ XawScrollbarSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ defaultTranslations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* simple */
+ {
+ XtInheritChangeSensitive, /* change_sensitive */
+ },
+ /* scrollbar */
+ {
+ NULL, /* extension */
+ },
+};
+
+WidgetClass scrollbarWidgetClass = (WidgetClass)&scrollbarClassRec;
+
+/*
+ * Implementation
+ */
+static void
+XawScrollbarClassInitialize(void)
+{
+ XawInitializeWidgetSet();
+ XtAddConverter(XtRString, XtROrientation, XmuCvtStringToOrientation,
+ NULL, 0);
+ XtSetTypeConverter(XtROrientation, XtRString, XmuCvtOrientationToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+
+/*
+ * Make sure the first number is within the range specified by the other
+ * two numbers.
+ */
+static int
+InRange(int num, int small, int big)
+{
+ return ((num < small) ? small : ((num > big) ? big : num));
+}
+
+/*
+ * Same as above, but for floating numbers
+ */
+static float
+FloatInRange(float num, float small, float big)
+{
+ return ((num < small) ? small : ((num > big) ? big : num));
+}
+
+/* Fill the area specified by top and bottom with the given pattern */
+static float
+FractionLoc(ScrollbarWidget w, int x, int y)
+{
+ float result;
+
+ result = PICKLENGTH(w, x / (float)XtWidth(w), y / (float)XtHeight(w));
+
+ return (FloatInRange(result, 0.0, 1.0));
+}
+
+static void
+FillArea(ScrollbarWidget w, int top, int bottom, int thumb)
+{
+ Dimension length;
+
+ top = XawMax(1, top);
+ if (w->scrollbar.orientation == XtorientHorizontal)
+ bottom = XawMin(bottom, XtWidth(w) - 1);
+ else
+ bottom = XawMin(bottom, XtHeight(w) - 1);
+
+ if (bottom <= top)
+ return;
+
+ length = bottom - top;
+
+ switch(thumb) {
+ /* Fill the new Thumb location */
+ case 1:
+ if (w->scrollbar.orientation == XtorientHorizontal)
+ XFillRectangle(XtDisplay(w), XtWindow(w), w->scrollbar.gc,
+ top, 1, length, XtHeight(w) - 2);
+ else
+ XFillRectangle(XtDisplay(w), XtWindow(w), w->scrollbar.gc,
+ 1, top, XtWidth(w) - 2, length);
+ break;
+ /* Clear the old Thumb location */
+ case 0:
+ if (w->scrollbar.orientation == XtorientHorizontal)
+ XClearArea(XtDisplay(w), XtWindow(w),
+ top, 1, length, XtHeight(w) - 2, False);
+ else
+ XClearArea(XtDisplay(w), XtWindow(w),
+ 1, top, XtWidth(w) - 2, length, False);
+ break;
+ }
+}
+
+
+/* Paint the thumb in the area specified by w->top and
+ w->shown. The old area is erased. The painting and
+ erasing is done cleverly so that no flickering will occur. */
+static void
+PaintThumb(ScrollbarWidget w)
+{
+ Position oldtop, oldbot, newtop, newbot;
+
+ oldtop = w->scrollbar.topLoc;
+ oldbot = oldtop + w->scrollbar.shownLength;
+ newtop = w->scrollbar.length * w->scrollbar.top;
+ newbot = newtop + (int)(w->scrollbar.length * w->scrollbar.shown);
+ if (newbot < newtop + (int)w->scrollbar.min_thumb)
+ newbot = newtop + w->scrollbar.min_thumb;
+ w->scrollbar.topLoc = newtop;
+ w->scrollbar.shownLength = newbot - newtop;
+
+ if (XtIsRealized((Widget)w)) {
+ if (newtop < oldtop)
+ FillArea(w, newtop, XawMin(newbot, oldtop), 1);
+ if (newtop > oldtop)
+ FillArea(w, oldtop, XawMin(newtop, oldbot), 0);
+ if (newbot < oldbot)
+ FillArea(w, XawMax(newbot, oldtop), oldbot, 0);
+ if (newbot > oldbot)
+ FillArea(w, XawMax(newtop, oldbot), newbot, 1);
+ }
+}
+
+static void
+SetDimensions(ScrollbarWidget w)
+{
+ if (w->scrollbar.orientation == XtorientVertical) {
+ w->scrollbar.length = XtHeight(w);
+ w->scrollbar.thickness = XtWidth(w);
+ }
+ else {
+ w->scrollbar.length = XtWidth(w);
+ w->scrollbar.thickness = XtHeight(w);
+ }
+}
+
+static void
+XawScrollbarDestroy(Widget w)
+{
+ ScrollbarWidget sbw = (ScrollbarWidget)w;
+
+ XtReleaseGC(w, sbw->scrollbar.gc);
+}
+
+static void
+CreateGC(Widget w)
+{
+ ScrollbarWidget sbw = (ScrollbarWidget)w;
+ XGCValues gcValues;
+ XtGCMask mask;
+ unsigned int depth = 1;
+
+ if (sbw->scrollbar.thumb == XtUnspecifiedPixmap)
+ sbw->scrollbar.thumb = XmuCreateStippledPixmap(XtScreen(w),
+ (Pixel)1, (Pixel)0,
+ depth);
+ else if (sbw->scrollbar.thumb != None) {
+ Window root;
+ int x, y;
+ unsigned int width, height, bw;
+
+ XGetGeometry(XtDisplay(w), sbw->scrollbar.thumb, &root, &x, &y,
+ &width, &height, &bw, &depth);
+ }
+
+ gcValues.foreground = sbw->scrollbar.foreground;
+ gcValues.background = sbw->core.background_pixel;
+ mask = GCForeground | GCBackground;
+
+ if (sbw->scrollbar.thumb != None) {
+ if (depth == 1) {
+ gcValues.fill_style = FillOpaqueStippled;
+ gcValues.stipple = sbw->scrollbar.thumb;
+ mask |= GCFillStyle | GCStipple;
+ }
+ else {
+ gcValues.fill_style = FillTiled;
+ gcValues.tile = sbw->scrollbar.thumb;
+ mask |= GCFillStyle | GCTile;
+ }
+ }
+ sbw->scrollbar.gc = XtGetGC(w, mask, &gcValues);
+}
+
+/* ARGSUSED */
+static void
+XawScrollbarInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ ScrollbarWidget w = (ScrollbarWidget)cnew;
+
+ CreateGC(cnew);
+
+ if (XtWidth(w) == 0)
+ XtWidth(w) = w->scrollbar.orientation == XtorientVertical ?
+ w->scrollbar.thickness : w->scrollbar.length;
+
+ if (XtHeight(w) == 0)
+ XtHeight(w) = w->scrollbar.orientation == XtorientHorizontal ?
+ w->scrollbar.thickness : w->scrollbar.length;
+
+ SetDimensions(w);
+ w->scrollbar.direction = 0;
+ w->scrollbar.topLoc = 0;
+ w->scrollbar.shownLength = w->scrollbar.min_thumb;
+}
+
+static void
+XawScrollbarRealize(Widget gw, Mask *valueMask,
+ XSetWindowAttributes *attributes)
+{
+ ScrollbarWidget w = (ScrollbarWidget)gw;
+
+ w->scrollbar.inactiveCursor = w->scrollbar.orientation == XtorientVertical ?
+ w->scrollbar.verCursor : w->scrollbar.horCursor;
+
+ XtVaSetValues(gw, XtNcursor, w->scrollbar.inactiveCursor, NULL);
+
+ /*
+ * The Simple widget actually stuffs the value in the valuemask
+ */
+ (*scrollbarWidgetClass->core_class.superclass->core_class.realize)
+ (gw, valueMask, attributes);
+}
+
+/*ARGSUSED*/
+static Boolean
+XawScrollbarSetValues(Widget current, Widget request, Widget desired,
+ ArgList args, Cardinal *num_args)
+{
+ ScrollbarWidget w = (ScrollbarWidget)current;
+ ScrollbarWidget dw = (ScrollbarWidget)desired;
+ Boolean redraw = False;
+
+ /*
+ * If these values are outside the acceptable range ignore them...
+ */
+ if (dw->scrollbar.top < 0.0 || dw->scrollbar.top > 1.0)
+ dw->scrollbar.top = w->scrollbar.top;
+
+ if (dw->scrollbar.shown < 0.0 || dw->scrollbar.shown > 1.0)
+ dw->scrollbar.shown = w->scrollbar.shown;
+
+ if (XtIsRealized (desired)) {
+ if (w->scrollbar.foreground != dw->scrollbar.foreground ||
+ w->core.background_pixel != dw->core.background_pixel ||
+ w->scrollbar.thumb != dw->scrollbar.thumb) {
+ XtReleaseGC((Widget)dw, w->scrollbar.gc);
+ CreateGC((Widget)dw);
+ redraw = True;
+ }
+ if (w->scrollbar.top != dw->scrollbar.top ||
+ w->scrollbar.shown != dw->scrollbar.shown)
+ redraw = True;
+ }
+
+ return (redraw);
+}
+
+static void
+XawScrollbarResize(Widget gw)
+{
+ /* ForgetGravity has taken care of background, but thumb may
+ * have to move as a result of the new size. */
+ SetDimensions((ScrollbarWidget)gw);
+ XawScrollbarRedisplay(gw, NULL, NULL);
+}
+
+/*ARGSUSED*/
+static void
+XawScrollbarRedisplay(Widget gw, XEvent *event, Region region)
+{
+ ScrollbarWidget w = (ScrollbarWidget)gw;
+ int x, y;
+ unsigned int width, height;
+
+ if (Superclass->core_class.expose)
+ (*Superclass->core_class.expose)(gw, event, region);
+
+ if (w->scrollbar.orientation == XtorientHorizontal) {
+ x = w->scrollbar.topLoc;
+ y = 1;
+ width = w->scrollbar.shownLength;
+ height = XtHeight(w) - 2;
+ }
+ else {
+ x = 1;
+ y = w->scrollbar.topLoc;
+ width = XtWidth(w) - 2;
+ height = w->scrollbar.shownLength;
+ }
+
+ if (region == NULL ||
+ XRectInRegion(region, x, y, width, height) != RectangleOut) {
+ /* Forces entire thumb to be painted */
+ w->scrollbar.topLoc = -(w->scrollbar.length + 1);
+ PaintThumb(w);
+ }
+}
+
+/*ARGSUSED*/
+static void
+StartScroll(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ ScrollbarWidget w = (ScrollbarWidget)gw;
+ Cursor cursor;
+ char direction;
+
+ if (w->scrollbar.direction != 0) /* if we're already scrolling */
+ return;
+ if (*num_params > 0)
+ direction = *params[0];
+ else
+ direction = 'C';
+
+ w->scrollbar.direction = direction;
+
+ switch(direction) {
+ case 'B':
+ case 'b':
+ cursor = w->scrollbar.orientation == XtorientVertical ?
+ w->scrollbar.downCursor : w->scrollbar.rightCursor;
+ break;
+ case 'F':
+ case 'f':
+ cursor = w->scrollbar.orientation == XtorientVertical ?
+ w->scrollbar.upCursor : w->scrollbar.leftCursor;
+ break;
+ case 'C':
+ case 'c':
+ cursor = w->scrollbar.orientation == XtorientVertical ?
+ w->scrollbar.rightCursor : w->scrollbar.upCursor;
+ break;
+ default:
+ return; /* invalid invocation */
+ }
+
+ XtVaSetValues(gw, XtNcursor, cursor, NULL);
+
+ XFlush(XtDisplay(w));
+}
+
+static Boolean
+CompareEvents(XEvent *oldEvent, XEvent *newEvent)
+{
+#define Check(field) if (newEvent->field != oldEvent->field) return (False)
+
+ Check(xany.display);
+ Check(xany.type);
+ Check(xany.window);
+
+ switch(newEvent->type) {
+ case MotionNotify:
+ Check(xmotion.state);
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ Check(xbutton.state);
+ Check(xbutton.button);
+ break;
+ case KeyPress:
+ case KeyRelease:
+ Check(xkey.state);
+ Check(xkey.keycode);
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ Check(xcrossing.mode);
+ Check(xcrossing.detail);
+ Check(xcrossing.state);
+ break;
+ }
+#undef Check
+
+ return (True);
+}
+
+struct EventData {
+ XEvent *oldEvent;
+ int count;
+};
+
+static Bool
+PeekNotifyEvent(Display *dpy, XEvent *event, char *args)
+{
+ struct EventData *eventData = (struct EventData*)args;
+
+ return (++eventData->count == QLength(dpy) /* since PeekIf blocks */
+ || CompareEvents(event, eventData->oldEvent));
+}
+
+static Bool
+LookAhead(Widget w, XEvent *event)
+{
+ XEvent newEvent;
+ struct EventData eventData;
+
+ if (QLength(XtDisplay(w)) == 0)
+ return (False);
+
+ eventData.count = 0;
+ eventData.oldEvent = event;
+
+ XPeekIfEvent(XtDisplay(w), &newEvent, PeekNotifyEvent, (char*)&eventData);
+
+ if (CompareEvents(event, &newEvent))
+ return (True);
+
+ return (False);
+}
+
+static void
+ExtractPosition(XEvent *event, Position *x, Position *y)
+{
+ switch(event->type) {
+ case MotionNotify:
+ *x = event->xmotion.x;
+ *y = event->xmotion.y;
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ *x = event->xbutton.x;
+ *y = event->xbutton.y;
+ break;
+ case KeyPress:
+ case KeyRelease:
+ *x = event->xkey.x;
+ *y = event->xkey.y;
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ *x = event->xcrossing.x;
+ *y = event->xcrossing.y;
+ break;
+ default:
+ *x = 0;
+ *y = 0;
+ break;
+ }
+}
+
+static void
+NotifyScroll(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ ScrollbarWidget w = (ScrollbarWidget)gw;
+ long call_data = 0;
+ char style;
+ Position x, y;
+
+ if (w->scrollbar.direction == 0) /* if no StartScroll */
+ return;
+
+ if (LookAhead(gw, event))
+ return;
+
+ if (*num_params > 0)
+ style = *params[0];
+ else
+ style = 'P';
+
+ switch(style) {
+ case 'P': /* Proportional */
+ case 'p':
+ ExtractPosition(event, &x, &y);
+ call_data = InRange(PICKLENGTH(w, x, y), 0, (int)w->scrollbar.length);
+ break;
+ case 'F': /* FullLength */
+ case 'f':
+ call_data = w->scrollbar.length;
+ break;
+ }
+
+ switch(w->scrollbar.direction) {
+ case 'B':
+ case 'b':
+ call_data = -call_data;
+ /*FALLTHROUGH*/
+ case 'F':
+ case 'f':
+ XtCallCallbacks(gw, XtNscrollProc, (XtPointer)call_data);
+ break;
+ case 'C':
+ case 'c': /* NotifyThumb has already called the thumbProc(s) */
+ break;
+ }
+}
+
+/*ARGSUSED*/
+static void
+EndScroll(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ ScrollbarWidget w = (ScrollbarWidget)gw;
+
+ XtVaSetValues(gw, XtNcursor, w->scrollbar.inactiveCursor, NULL);
+ XFlush(XtDisplay(w)); /* make sure it get propogated */
+
+ w->scrollbar.direction = 0;
+}
+
+/*ARGSUSED*/
+static void
+MoveThumb(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ ScrollbarWidget w = (ScrollbarWidget)gw;
+ Position x, y;
+
+ if (w->scrollbar.direction == 0) /* if no StartScroll */
+ return;
+
+ if (LookAhead(gw, event))
+ return;
+
+ if (!event->xmotion.same_screen)
+ return;
+
+ ExtractPosition(event, &x, &y);
+ w->scrollbar.top = FractionLoc(w, x, y);
+}
+
+/*ARGSUSED*/
+static void
+NotifyThumb(Widget gw, XEvent *event, String *params, Cardinal *num_params)
+{
+ ScrollbarWidget w = (ScrollbarWidget)gw;
+ union {
+ XtPointer xtp;
+ float xtf;
+ } xtpf;
+
+ if (w->scrollbar.direction == 0) /* if no StartScroll */
+ return;
+
+ if (LookAhead(gw, event))
+ return;
+
+ /* thumbProc is not pretty, but is necessary for backwards
+ compatibility on those architectures for which it work{s,ed};
+ the intent is to pass a (truncated) float by value. */
+ xtpf.xtf = w->scrollbar.top;
+ XtCallCallbacks(gw, XtNthumbProc, xtpf.xtp);
+ XtCallCallbacks(gw, XtNjumpProc, (XtPointer)&w->scrollbar.top);
+
+ PaintThumb(w);
+}
+
+/*
+ * Public routines
+ */
+/* Set the scroll bar to the given location. */
+void
+XawScrollbarSetThumb(Widget gw,
+#if NeedWidePrototypes
+ double top, double shown
+#else
+ float top, float shown
+#endif
+ )
+{
+ ScrollbarWidget w = (ScrollbarWidget)gw;
+
+ if (w->scrollbar.direction == 'c') /* if still thumbing */
+ return;
+
+ w->scrollbar.top = top > 1.0 ? 1.0 : top >= 0.0 ? top : w->scrollbar.top;
+
+ w->scrollbar.shown = shown > 1.0 ? 1.0 : shown >= 0.0 ?
+ shown : w->scrollbar.shown;
+ PaintThumb(w);
+}
diff --git a/nx-X11/lib/Xaw/Scrollbar.h b/nx-X11/lib/Xaw/Scrollbar.h
new file mode 100644
index 000000000..c776d41e2
--- /dev/null
+++ b/nx-X11/lib/Xaw/Scrollbar.h
@@ -0,0 +1,137 @@
+/* $Xorg: Scrollbar.h,v 1.4 2001/02/09 02:03:45 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Scrollbar.h,v 1.6 2001/01/17 19:42:29 dawes Exp $ */
+
+#ifndef _Scrollbar_h
+#define _Scrollbar_h
+
+/*
+ * Scrollbar Widget
+ */
+
+#include <X11/Xmu/Converters.h>
+#include <X11/Xfuncproto.h>
+
+/* Scrollbar resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ accelerators Accelerators AcceleratorTable NULL
+ ancestorSensitive AncestorSensitive Boolean True
+ background Background Pixel XtDefaultBackground
+ backgroundPixmap Pixmap Pixmap XtUnspecifiedPixmap
+ borderColor BorderColor Pixel XtDefaultForeground
+ borderPixmap Pixmap Pixmap XtUnspecifiedPixmap
+ borderWidth BorderWidth Dimension 1
+ colormap Colormap Colormap parent's colormap
+ cursor Cursor Cursor None
+ cursorName Cursor String NULL
+ depth Depth int parent's depth
+ destroyCallback Callback XtCallbackList NULL
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension length or thickness
+ insensitiveBorder Insensitive Pixmap GreyPixmap
+ jumpProc Callback XtCallbackList NULL
+ length Length Dimension 1
+ mappedWhenManaged MappedWhenManaged Boolean True
+ minimumThumb MinimumThumb Dimension 7
+ orientation Orientation XtOrientation XtorientVertical
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ screen Screen Screen parent's screen
+ scrollDCursor Cursor Cursor XC_sb_down_arrow
+ scrollHCursor Cursor Cursor XC_sb_h_double_arrow
+ scrollLCursor Cursor Cursor XC_sb_left_arrow
+ scrollProc Callback XtCallbackList NULL
+ scrollRCursor Cursor Cursor XC_sb_right_arrow
+ scrollUCursor Cursor Cursor XC_sb_up_arrow
+ scrollVCursor Cursor Cursor XC_sb_v_double_arrow
+ sensitive Sensitive Boolean True
+ shown Shown Float 0.0
+ thickness Thickness Dimension 14
+ thumb Thumb Bitmap GreyPixmap
+ thumbProc Callback XtCallbackList NULL
+ topOfThumb TopOfThumb Float 0.0
+ translations Translations TranslationTable see source or doc
+ width Width Dimension thickness or length
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XtCMinimumThumb "MinimumThumb"
+#define XtCShown "Shown"
+#define XtCTopOfThumb "TopOfThumb"
+
+#define XtNminimumThumb "minimumThumb"
+#define XtNtopOfThumb "topOfThumb"
+
+typedef struct _ScrollbarRec *ScrollbarWidget;
+typedef struct _ScrollbarClassRec *ScrollbarWidgetClass;
+
+extern WidgetClass scrollbarWidgetClass;
+
+_XFUNCPROTOBEGIN
+
+void XawScrollbarSetThumb
+(
+ Widget scrollbar,
+#if NeedWidePrototypes
+ double top,
+ double shown
+#else
+ float top,
+ float shown
+#endif
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _Scrollbar_h */
diff --git a/nx-X11/lib/Xaw/ScrollbarP.h b/nx-X11/lib/Xaw/ScrollbarP.h
new file mode 100644
index 000000000..ec3af46f8
--- /dev/null
+++ b/nx-X11/lib/Xaw/ScrollbarP.h
@@ -0,0 +1,109 @@
+/*
+ * $Xorg: ScrollbarP.h,v 1.4 2001/02/09 02:03:45 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/ScrollbarP.h,v 1.7 2001/01/17 19:42:29 dawes Exp $ */
+
+#ifndef _ScrollbarP_h
+#define _ScrollbarP_h
+
+#include <X11/Xaw/Scrollbar.h>
+#include <X11/Xaw/SimpleP.h>
+
+typedef struct {
+ /* resources */
+ Pixel foreground; /* thumb foreground color */
+ XtOrientation orientation; /* horizontal or vertical */
+ XtCallbackList scrollProc; /* proportional scroll */
+ XtCallbackList thumbProc; /* jump (to position) scroll */
+ XtCallbackList jumpProc; /* same as thumbProc but pass data by ref */
+ Pixmap thumb; /* thumb pixmap */
+ Cursor upCursor; /* scroll up cursor */
+ Cursor downCursor; /* scroll down cursor */
+ Cursor leftCursor; /* scroll left cursor */
+ Cursor rightCursor; /* scroll right cursor */
+ Cursor verCursor; /* scroll vertical cursor */
+ Cursor horCursor; /* scroll horizontal cursor */
+ float top;
+ float shown;
+ Dimension length; /* either height or width */
+ Dimension thickness; /* either width or height */
+ Dimension min_thumb; /* minium size for the thumb */
+
+ /* private */
+ Cursor inactiveCursor; /* The normal cursor for scrollbar */
+ char direction; /* a scroll has started; which direction */
+ GC gc; /* a (shared) gc */
+ Position topLoc; /* Pixel that corresponds to top */
+ Dimension shownLength; /* Num pixels corresponding to shown */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} ScrollbarPart;
+
+typedef struct _ScrollbarRec {
+ CorePart core;
+ SimplePart simple;
+ ScrollbarPart scrollbar;
+} ScrollbarRec;
+
+typedef struct {
+ XtPointer extension;
+} ScrollbarClassPart;
+
+typedef struct _ScrollbarClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ ScrollbarClassPart scrollbar_class;
+} ScrollbarClassRec;
+
+extern ScrollbarClassRec scrollbarClassRec;
+
+#endif /* _ScrollbarP_h */
diff --git a/nx-X11/lib/Xaw/Simple.c b/nx-X11/lib/Xaw/Simple.c
new file mode 100644
index 000000000..95b7a1aa1
--- /dev/null
+++ b/nx-X11/lib/Xaw/Simple.c
@@ -0,0 +1,504 @@
+/* $Xorg: Simple.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+
+/* $XFree86: xc/lib/Xaw/Simple.c,v 1.16 2001/09/29 04:36:02 paulo Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Drawing.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xaw/SimpleP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+#ifndef OLDXAW
+#include <X11/Xaw/Tip.h>
+#endif
+
+/*
+ * Class Methods
+ */
+static Bool ChangeSensitive(Widget);
+static void XawSimpleClassInitialize(void);
+static void XawSimpleClassPartInitialize(WidgetClass);
+#ifndef OLDXAW
+static void XawSimpleInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawSimpleDestroy(Widget);
+static void XawSimpleExpose(Widget, XEvent*, Region);
+#endif
+static void XawSimpleRealize(Widget, Mask*, XSetWindowAttributes*);
+static Boolean XawSimpleSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static void ConvertCursor(Widget);
+
+/*
+ * Initialization
+ */
+#ifndef OLDXAW
+static XtActionsRec actions[] = {
+ {"set-values", XawSetValuesAction},
+ {"get-values", XawGetValuesAction},
+ {"declare", XawDeclareAction},
+ {"call-proc", XawCallProcAction},
+};
+#endif
+
+#define offset(field) XtOffsetOf(SimpleRec, simple.field)
+static XtResource resources[] = {
+ {
+ XtNcursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(cursor),
+ XtRImmediate,
+ (XtPointer)None
+ },
+ {
+ XtNinsensitiveBorder,
+ XtCInsensitive,
+ XtRPixmap,
+ sizeof(Pixmap),
+ offset(insensitive_border),
+ XtRImmediate,
+ NULL
+ },
+ {
+ XtNpointerColor,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(pointer_fg),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XtNpointerColorBackground,
+ XtCBackground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(pointer_bg),
+ XtRString,
+ XtDefaultBackground
+ },
+ {
+ XtNcursorName,
+ XtCCursor,
+ XtRString,
+ sizeof(String),
+ offset(cursor_name),
+ XtRString,
+ NULL
+ },
+ {
+ XtNinternational,
+ XtCInternational,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(international),
+ XtRImmediate,
+ (XtPointer)False
+ },
+#ifndef OLDXAW
+ {
+ XawNdisplayList,
+ XawCDisplayList,
+ XawRDisplayList,
+ sizeof(XawDisplayList*),
+ offset(display_list),
+ XtRImmediate,
+ NULL
+ },
+ {
+ XtNtip,
+ XtCTip,
+ XtRString,
+ sizeof(String),
+ offset(tip),
+ XtRImmediate,
+ NULL
+ },
+#endif
+#undef offset
+};
+
+SimpleClassRec simpleClassRec = {
+ /* core */
+ {
+ (WidgetClass)&widgetClassRec, /* superclass */
+ "Simple", /* class_name */
+ sizeof(SimpleRec), /* widget_size */
+ XawSimpleClassInitialize, /* class_initialize */
+ XawSimpleClassPartInitialize, /* class_part_initialize */
+ False, /* class_inited */
+#ifndef OLDXAW
+ XawSimpleInitialize, /* initialize */
+#else
+ NULL, /* initialize */
+#endif
+ NULL, /* initialize_hook */
+ XawSimpleRealize, /* realize */
+#ifndef OLDXAW
+ actions, /* actions */
+ XtNumber(actions), /* num_actions */
+#else
+ NULL, /* actions */
+ 0, /* num_actions */
+#endif
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+#ifndef OLDXAW
+ XawSimpleDestroy, /* destroy */
+#else
+ NULL, /* destroy */
+#endif
+ NULL, /* resize */
+#ifndef OLDXAW
+ XawSimpleExpose, /* expose */
+#else
+ NULL, /* expose */
+#endif
+ XawSimpleSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* simple */
+ {
+ ChangeSensitive, /* change_sensitive */
+ },
+};
+
+WidgetClass simpleWidgetClass = (WidgetClass)&simpleClassRec;
+
+static void
+XawSimpleClassInitialize(void)
+{
+ static XtConvertArgRec convertArg[] = {
+ {
+ XtWidgetBaseOffset,
+ (XtPointer)XtOffsetOf(WidgetRec, core.screen),
+ sizeof(Screen *)
+ },
+ {
+ XtResourceString,
+ (XtPointer)XtNpointerColor,
+ sizeof(Pixel)
+ },
+ {
+ XtResourceString,
+ (XtPointer)XtNpointerColorBackground,
+ sizeof(Pixel)
+ },
+ {
+ XtWidgetBaseOffset,
+ (XtPointer)XtOffsetOf(WidgetRec, core.colormap),
+ sizeof(Colormap)
+ },
+ };
+
+ XawInitializeWidgetSet();
+ XtSetTypeConverter(XtRString, XtRColorCursor, XmuCvtStringToColorCursor,
+ convertArg, XtNumber(convertArg), XtCacheByDisplay, NULL);
+}
+
+static void
+XawSimpleClassPartInitialize(WidgetClass cclass)
+{
+ SimpleWidgetClass c = (SimpleWidgetClass)cclass;
+ SimpleWidgetClass super = (SimpleWidgetClass)c->core_class.superclass;
+
+ if (c->simple_class.change_sensitive == NULL) {
+ char buf[BUFSIZ];
+
+ (void)XmuSnprintf(buf, sizeof(buf),
+ "%s Widget: The Simple Widget class method "
+ "'change_sensitive' is undefined.\nA function "
+ "must be defined or inherited.",
+ c->core_class.class_name);
+ XtWarning(buf);
+ c->simple_class.change_sensitive = ChangeSensitive;
+ }
+
+ if (c->simple_class.change_sensitive == XtInheritChangeSensitive)
+ c->simple_class.change_sensitive = super->simple_class.change_sensitive;
+}
+
+#ifndef OLDXAW
+/*ARGSUSED*/
+static void
+XawSimpleInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ SimpleWidget simple = (SimpleWidget)cnew;
+
+ if (simple->simple.tip)
+ simple->simple.tip = XtNewString(simple->simple.tip);
+}
+
+static void
+XawSimpleDestroy(Widget w)
+{
+ SimpleWidget simple = (SimpleWidget)w;
+
+ if (simple->simple.tip)
+ XtFree((XtPointer)simple->simple.tip);
+}
+#endif
+
+static void
+XawSimpleRealize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
+{
+#ifndef OLDXAW
+ XawPixmap *pixmap;
+#endif
+ Pixmap border_pixmap = CopyFromParent;
+
+ if (!XtIsSensitive(w))
+ {
+ /* change border to gray; have to remember the old one,
+ * so XtDestroyWidget deletes the proper one */
+ if (((SimpleWidget)w)->simple.insensitive_border == None)
+ ((SimpleWidget)w)->simple.insensitive_border =
+ XmuCreateStippledPixmap(XtScreen(w),
+ w->core.border_pixel,
+ w->core.background_pixel,
+ w->core.depth);
+ border_pixmap = w->core.border_pixmap;
+ attributes->border_pixmap =
+ w->core.border_pixmap = ((SimpleWidget)w)->simple.insensitive_border;
+
+ *valueMask |= CWBorderPixmap;
+ *valueMask &= ~CWBorderPixel;
+ }
+
+ ConvertCursor(w);
+
+ if ((attributes->cursor = ((SimpleWidget)w)->simple.cursor) != None)
+ *valueMask |= CWCursor;
+
+ XtCreateWindow(w, InputOutput, (Visual *)CopyFromParent,
+ *valueMask, attributes);
+
+ if (!XtIsSensitive(w))
+ w->core.border_pixmap = border_pixmap;
+
+#ifndef OLDXAW
+ if (w->core.background_pixmap > XtUnspecifiedPixmap) {
+ pixmap = XawPixmapFromXPixmap(w->core.background_pixmap, XtScreen(w),
+ w->core.colormap, w->core.depth);
+ if (pixmap && pixmap->mask)
+ XawReshapeWidget(w, pixmap);
+ }
+
+ if (((SimpleWidget)w)->simple.tip)
+ XawTipEnable(w);
+#endif
+}
+
+/*
+ * Function:
+ * ConvertCursor
+ *
+ * Parameters:
+ * w - simple widget
+ *
+ * Description:
+ * Converts a name to a new cursor.
+ */
+static void
+ConvertCursor(Widget w)
+{
+ SimpleWidget simple = (SimpleWidget) w;
+ XrmValue from, to;
+ Cursor cursor = None;
+
+ if (simple->simple.cursor_name == NULL)
+ return;
+
+ from.addr = (XPointer)simple->simple.cursor_name;
+ from.size = strlen((char *)from.addr) + 1;
+
+ to.size = sizeof(Cursor);
+ to.addr = (XPointer)&cursor;
+
+ if (XtConvertAndStore(w, XtRString, &from, XtRColorCursor, &to))
+ simple->simple.cursor = cursor;
+ else
+ XtAppErrorMsg(XtWidgetToApplicationContext(w),
+ "convertFailed","ConvertCursor","XawError",
+ "Simple: ConvertCursor failed.",
+ NULL, NULL);
+}
+
+
+/*ARGSUSED*/
+static Boolean
+XawSimpleSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ SimpleWidget s_old = (SimpleWidget)current;
+ SimpleWidget s_new = (SimpleWidget)cnew;
+ Bool new_cursor = False;
+
+ /* this disables user changes after creation */
+ s_new->simple.international = s_old->simple.international;
+
+ if (XtIsSensitive(current) != XtIsSensitive(cnew))
+ (*((SimpleWidgetClass)XtClass(cnew))->simple_class.change_sensitive)
+ (cnew);
+
+ if (s_old->simple.cursor != s_new->simple.cursor)
+ new_cursor = True;
+
+ /*
+ * We are not handling the string cursor_name correctly here
+ */
+
+ if (s_old->simple.pointer_fg != s_new->simple.pointer_fg ||
+ s_old->simple.pointer_bg != s_new->simple.pointer_bg ||
+ s_old->simple.cursor_name != s_new->simple.cursor_name) {
+ ConvertCursor(cnew);
+ new_cursor = True;
+ }
+
+ if (new_cursor && XtIsRealized(cnew)) {
+ if (s_new->simple.cursor != None)
+ XDefineCursor(XtDisplay(cnew), XtWindow(cnew), s_new->simple.cursor);
+ else
+ XUndefineCursor(XtDisplay(cnew), XtWindow(cnew));
+ }
+
+#ifndef OLDXAW
+ if (s_old->core.background_pixmap != s_new->core.background_pixmap) {
+ XawPixmap *opix, *npix;
+
+ opix = XawPixmapFromXPixmap(s_old->core.background_pixmap,
+ XtScreen(s_old), s_old->core.colormap,
+ s_old->core.depth);
+ npix = XawPixmapFromXPixmap(s_new->core.background_pixmap,
+ XtScreen(s_new), s_new->core.colormap,
+ s_new->core.depth);
+ if ((npix && npix->mask) || (opix && opix->mask))
+ XawReshapeWidget(cnew, npix);
+ }
+
+ if (s_old->simple.tip != s_new->simple.tip) {
+ if (s_old->simple.tip)
+ XtFree((XtPointer)s_old->simple.tip);
+ if (s_new->simple.tip)
+ s_new->simple.tip = XtNewString(s_new->simple.tip);
+ }
+
+ if (s_old->simple.tip && !s_new->simple.tip)
+ XawTipDisable(cnew);
+ else if (!s_old->simple.tip && s_new->simple.tip)
+ XawTipEnable(cnew);
+
+ if (s_old->simple.display_list != s_new->simple.display_list)
+ return (True);
+#endif /* OLDXAW */
+
+ return (False);
+}
+
+#ifndef OLDXAW
+static void
+XawSimpleExpose(Widget w, XEvent *event, Region region)
+{
+ SimpleWidget xaw = (SimpleWidget)w;
+
+ if (xaw->simple.display_list)
+ XawRunDisplayList(w, xaw->simple.display_list, event, region);
+}
+#endif
+
+static Bool
+ChangeSensitive(Widget w)
+{
+ if (XtIsRealized(w)) {
+ if (XtIsSensitive(w))
+ if (w->core.border_pixmap != XtUnspecifiedPixmap)
+ XSetWindowBorderPixmap(XtDisplay(w), XtWindow(w),
+ w->core.border_pixmap);
+ else
+ XSetWindowBorder(XtDisplay(w), XtWindow(w),
+ w->core.border_pixel);
+ else {
+ if (((SimpleWidget)w)->simple.insensitive_border == None)
+ ((SimpleWidget)w)->simple.insensitive_border =
+ XmuCreateStippledPixmap(XtScreen(w),
+ w->core.border_pixel,
+ w->core.background_pixel,
+ w->core.depth);
+ XSetWindowBorderPixmap(XtDisplay(w), XtWindow(w),
+ ((SimpleWidget)w)->simple.insensitive_border);
+ }
+ }
+
+ return (False);
+}
diff --git a/nx-X11/lib/Xaw/Simple.h b/nx-X11/lib/Xaw/Simple.h
new file mode 100644
index 000000000..7ba9354b9
--- /dev/null
+++ b/nx-X11/lib/Xaw/Simple.h
@@ -0,0 +1,116 @@
+/* $Xorg: Simple.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Simple.h,v 1.8 2001/01/17 19:42:30 dawes Exp $ */
+
+#ifndef _Simple_h
+#define _Simple_h
+
+#include <X11/Xmu/Converters.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ cursor Cursor Cursor None
+ cursorName Cursor String NULL
+ destroyCallback Callback Pointer NULL
+ displayList DisplayList XawDisplayList* NULL
+ height Height Dimension 0
+ insensitiveBorder Insensitive Pixmap Gray
+ mappedWhenManaged MappedWhenManaged Boolean True
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ sensitive Sensitive Boolean True
+ tip Tip String NULL
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XtNcursor "cursor"
+#define XtNcursorName "cursorName"
+#define XtNinsensitiveBorder "insensitiveBorder"
+
+#define XtCInsensitive "Insensitive"
+
+#ifndef XtCInternational
+#define XtCInternational "International"
+#endif
+
+#ifndef XtNinternational
+#define XtNinternational "international"
+#endif
+
+#ifndef OLDXAW
+#ifndef XawNdisplayList
+#define XawNdisplayList "displayList"
+#endif
+
+#ifndef XawCDisplayList
+#define XawCDisplayList "DisplayList"
+#endif
+
+#ifndef XawRDisplayList
+#define XawRDisplayList "XawDisplayList"
+#endif
+
+#define XtNtip "tip"
+#define XtCTip "Tip"
+#endif /* OLDXAW */
+
+typedef struct _SimpleClassRec *SimpleWidgetClass;
+typedef struct _SimpleRec *SimpleWidget;
+
+extern WidgetClass simpleWidgetClass;
+
+#endif /* _Simple_h */
diff --git a/nx-X11/lib/Xaw/SimpleMenP.h b/nx-X11/lib/Xaw/SimpleMenP.h
new file mode 100644
index 000000000..46102059e
--- /dev/null
+++ b/nx-X11/lib/Xaw/SimpleMenP.h
@@ -0,0 +1,101 @@
+/*
+ * $Xorg: SimpleMenP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ */
+/* $XFree86: xc/lib/Xaw/SimpleMenP.h,v 1.12 2001/01/17 19:42:30 dawes Exp $ */
+
+/*
+ * SimpleMenuP.h - Private Header file for SimpleMenu widget.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _SimpleMenuP_h
+#define _SimpleMenuP_h
+
+#include <X11/Xaw/SimpleMenu.h>
+#include <X11/Xaw/SmeP.h>
+#include <X11/ShellP.h>
+#include <X11/Xaw/XawInit.h>
+
+typedef struct {
+ XtPointer extension; /* For future needs */
+} SimpleMenuClassPart;
+
+typedef struct _SimpleMenuClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ShellClassPart shell_class;
+ OverrideShellClassPart override_shell_class;
+ SimpleMenuClassPart simpleMenu_class;
+} SimpleMenuClassRec;
+
+extern SimpleMenuClassRec simpleMenuClassRec;
+
+typedef struct _SimpleMenuPart {
+ /* resources */
+ String label_string; /* The string for the label or NULL */
+ SmeObject label; /* If label_string is non-NULL then this is
+ the label widget */
+ WidgetClass label_class; /* Widget Class of the menu label object */
+ Dimension top_margin; /* Top and bottom margins */
+ Dimension bottom_margin;
+ Dimension row_height; /* height of each row (menu entry) */
+ Cursor cursor; /* The menu's cursor */
+ SmeObject popup_entry; /* The entry to position the cursor on for
+ when using XawPositionSimpleMenu */
+ Boolean menu_on_screen; /* Force the menus to be fully on the screen*/
+ int backing_store; /* What type of backing store to use */
+
+ /* private */
+ Boolean recursive_set_values; /* contain a possible infinite loop */
+ Boolean menu_width; /* If true then force width to remain
+ core.width */
+ Boolean menu_height; /* Just like menu_width, but for height */
+ SmeObject entry_set; /* The entry that is currently set or
+ highlighted */
+#ifndef OLDXAW
+ Dimension left_margin;
+ Dimension right_margin;
+ XawDisplayList *display_list;
+ Widget sub_menu;
+ unsigned char state;
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} SimpleMenuPart;
+
+typedef struct _SimpleMenuRec {
+ CorePart core;
+ CompositePart composite;
+ ShellPart shell;
+ OverrideShellPart override;
+ SimpleMenuPart simple_menu;
+} SimpleMenuRec;
+
+#endif /* _SimpleMenuP_h */
diff --git a/nx-X11/lib/Xaw/SimpleMenu.c b/nx-X11/lib/Xaw/SimpleMenu.c
new file mode 100644
index 000000000..b7ed28651
--- /dev/null
+++ b/nx-X11/lib/Xaw/SimpleMenu.c
@@ -0,0 +1,1834 @@
+/* $Xorg: SimpleMenu.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+
+/* $XFree86: xc/lib/Xaw/SimpleMenu.c,v 3.21 2001/03/23 23:59:15 paulo Exp $ */
+
+/*
+ * SimpleMenu.c - Source code file for SimpleMenu widget.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Initer.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xaw/SimpleMenP.h>
+#include <X11/Xaw/SmeBSBP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+#define streq(a, b) (strcmp((a), (b)) == 0)
+
+#define ForAllChildren(smw, childP) \
+for ((childP) = (SmeObject *)(smw)->composite.children; \
+ (childP) < (SmeObject *)((smw)->composite.children \
+ + (smw)->composite.num_children); \
+ (childP)++)
+
+#ifndef OLDXAW
+#define SMW_UNMAPPING 0x01
+#define SMW_POPLEFT 0x02
+#endif
+
+/*
+ * Class Methods
+ */
+static void XawSimpleMenuChangeManaged(Widget);
+static void XawSimpleMenuClassInitialize(void);
+static void XawSimpleMenuClassPartInitialize(WidgetClass);
+static XtGeometryResult XawSimpleMenuGeometryManager(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawSimpleMenuInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawSimpleMenuRealize(Widget, XtValueMask*, XSetWindowAttributes*);
+static void XawSimpleMenuRedisplay(Widget, XEvent*, Region);
+static void XawSimpleMenuResize(Widget);
+static Boolean XawSimpleMenuSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+static Boolean XawSimpleMenuSetValuesHook(Widget, ArgList, Cardinal*);
+#ifndef OLDXAW
+static void PopupSubMenu(SimpleMenuWidget);
+static void PopdownSubMenu(SimpleMenuWidget);
+static void PopupCB(Widget, XtPointer, XtPointer);
+#endif
+
+/*
+ * Prototypes
+ */
+static void AddPositionAction(XtAppContext, XPointer);
+static void CalculateNewSize(Widget, Dimension*, Dimension*);
+static void ChangeCursorOnGrab(Widget, XtPointer, XtPointer);
+static void CreateLabel(Widget);
+static SmeObject DoGetEventEntry(Widget, int, int);
+static Widget FindMenu(Widget, String);
+static SmeObject GetEventEntry(Widget, XEvent*);
+static void Layout(Widget, Dimension*, Dimension*);
+static void MakeResizeRequest(Widget);
+static void MakeSetValuesRequest(Widget, unsigned int, unsigned int);
+static void MoveMenu(Widget, int, int);
+static void PositionMenu(Widget, XPoint*);
+
+/*
+ * Actions
+ */
+static void Highlight(Widget, XEvent*, String*, Cardinal*);
+static void Notify(Widget, XEvent*, String*, Cardinal*);
+#ifndef OLDXAW
+static void Popdown(Widget, XEvent*, String*, Cardinal*);
+#endif
+static void PositionMenuAction(Widget, XEvent*, String*, Cardinal*);
+static void Unhighlight(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(SimpleMenuRec, simple_menu.field)
+
+static XtResource resources[] = {
+ /* label */
+ {
+ XtNlabel,
+ XtCLabel,
+ XtRString,
+ sizeof(String),
+ offset(label_string),
+ XtRString,
+ NULL
+ },
+ {
+ XtNlabelClass,
+ XtCLabelClass,
+ XtRPointer,
+ sizeof(WidgetClass),
+ offset(label_class),
+ XtRImmediate,
+ NULL
+ },
+
+ /* layout */
+ {
+ XtNrowHeight,
+ XtCRowHeight,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(row_height),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNtopMargin,
+ XtCVerticalMargins,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(top_margin),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNbottomMargin,
+ XtCVerticalMargins,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(bottom_margin),
+ XtRImmediate,
+ (XtPointer)0
+ },
+#ifndef OLDXAW
+ {
+ XtNleftMargin,
+ XtCHorizontalMargins,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(left_margin),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNrightMargin,
+ XtCHorizontalMargins,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(right_margin),
+ XtRImmediate,
+ (XtPointer)0
+ },
+#endif
+
+ /* misc */
+ {
+ XtNallowShellResize,
+ XtCAllowShellResize,
+ XtRBoolean,
+ sizeof(Boolean),
+ XtOffsetOf(SimpleMenuRec, shell.allow_shell_resize),
+ XtRImmediate,
+ (XtPointer)True
+ },
+ {
+ XtNcursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(cursor),
+ XtRImmediate,
+ (XtPointer)None
+ },
+ {
+ XtNmenuOnScreen,
+ XtCMenuOnScreen,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(menu_on_screen),
+ XtRImmediate,
+ (XtPointer)True
+ },
+ {
+ XtNpopupOnEntry,
+ XtCPopupOnEntry,
+ XtRWidget,
+ sizeof(Widget),
+ offset(popup_entry),
+ XtRWidget,
+ NULL
+ },
+ {
+ XtNbackingStore,
+ XtCBackingStore,
+ XtRBackingStore,
+ sizeof(int),
+ offset(backing_store),
+ XtRImmediate,
+ (XtPointer)(Always + WhenMapped + NotUseful)
+ },
+#ifndef OLDXAW
+ {
+ XawNdisplayList,
+ XawCDisplayList,
+ XawRDisplayList,
+ sizeof(XawDisplayList*),
+ offset(display_list),
+ XtRImmediate,
+ NULL
+ },
+#endif
+};
+#undef offset
+
+static char defaultTranslations[] =
+"<Enter>:" "highlight()\n"
+"<Leave>:" "unhighlight()\n"
+"<BtnMotion>:" "highlight()\n"
+#ifndef OLDXAW
+"<BtnUp>:" "popdown() notify() unhighlight()\n"
+#else
+"<BtnUp>:" "MenuPopdown() notify() unhighlight()\n"
+#endif
+;
+
+static XtActionsRec actionsList[] =
+{
+ {"notify", Notify},
+ {"highlight", Highlight},
+ {"unhighlight", Unhighlight},
+#ifndef OLDXAW
+ {"popdown", Popdown},
+ {"set-values", XawSetValuesAction},
+ {"get-values", XawGetValuesAction},
+ {"declare", XawDeclareAction},
+ {"call-proc", XawCallProcAction},
+#endif
+};
+
+static CompositeClassExtensionRec extension_rec = {
+ NULL, /* next_extension */
+ NULLQUARK, /* record_type */
+ XtCompositeExtensionVersion, /* version */
+ sizeof(CompositeClassExtensionRec), /* record_size */
+ True, /* accepts_objects */
+};
+
+#define Superclass (&overrideShellClassRec)
+SimpleMenuClassRec simpleMenuClassRec = {
+ /* core */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "SimpleMenu", /* class_name */
+ sizeof(SimpleMenuRec), /* size */
+ XawSimpleMenuClassInitialize, /* class_initialize */
+ XawSimpleMenuClassPartInitialize, /* class_part_initialize */
+ False, /* class_inited */
+ XawSimpleMenuInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XawSimpleMenuRealize, /* realize */
+ actionsList, /* actions */
+ XtNumber(actionsList), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ NULL, /* destroy */
+ XawSimpleMenuResize, /* resize */
+ XawSimpleMenuRedisplay, /* expose */
+ XawSimpleMenuSetValues, /* set_values */
+ XawSimpleMenuSetValuesHook, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* intrinsics version */
+ NULL, /* callback offsets */
+ defaultTranslations, /* tm_table */
+ NULL, /* query_geometry */
+ NULL, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* composite */
+ {
+ XawSimpleMenuGeometryManager, /* geometry_manager */
+ XawSimpleMenuChangeManaged, /* change_managed */
+ XtInheritInsertChild, /* insert_child */
+ XtInheritDeleteChild, /* delete_child */
+ NULL, /* extension */
+ },
+ /* shell */
+ {
+ NULL, /* extension */
+ },
+ /* override */
+ {
+ NULL, /* extension */
+ },
+ /* simple_menu */
+ {
+ NULL, /* extension */
+ },
+};
+
+WidgetClass simpleMenuWidgetClass = (WidgetClass)&simpleMenuClassRec;
+
+/*
+ * Implementation
+ */
+/*
+ * Function:
+ * XawSimpleMenuClassInitialize
+ *
+ * Description:
+ * Class Initialize routine, called only once.
+ */
+static void
+XawSimpleMenuClassInitialize(void)
+{
+ XawInitializeWidgetSet();
+ XtAddConverter(XtRString, XtRBackingStore, XmuCvtStringToBackingStore,
+ NULL, 0);
+ XtSetTypeConverter(XtRBackingStore, XtRString, XmuCvtBackingStoreToString,
+ NULL, 0, XtCacheNone, NULL);
+ XmuAddInitializer(AddPositionAction, NULL);
+}
+
+/*
+ * Function:
+ * XawSimpleMenuClassPartInitialize
+ * Arguments: wc - the widget class of the subclass.
+ *
+ * Description:
+ * Class Part Initialize routine, called for every subclass. Makes
+ * sure that the subclasses pick up the extension record.
+ */
+static void
+XawSimpleMenuClassPartInitialize(WidgetClass wc)
+{
+ SimpleMenuWidgetClass smwc = (SimpleMenuWidgetClass)wc;
+
+ /*
+ * Make sure that our subclass gets the extension rec too
+ */
+ extension_rec.next_extension = smwc->composite_class.extension;
+ smwc->composite_class.extension = (XtPointer) &extension_rec;
+}
+
+/*
+ * Function:
+ * XawSimpleMenuInitialize
+ *
+ * Parameters:
+ * request - widget requested by the argument list
+ * cnew - new widget with both resource and non resource values
+ *
+ * Description:
+ * Initializes the simple menu widget.
+ */
+/*ARGSUSED*/
+static void
+XawSimpleMenuInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)cnew;
+ Dimension width, height;
+
+ XmuCallInitializers(XtWidgetToApplicationContext(cnew));
+
+ if (smw->simple_menu.label_class == NULL)
+ smw->simple_menu.label_class = smeBSBObjectClass;
+
+ smw->simple_menu.label = NULL;
+ smw->simple_menu.entry_set = NULL;
+ smw->simple_menu.recursive_set_values = False;
+#ifndef OLDXAW
+ smw->simple_menu.sub_menu = NULL;
+ smw->simple_menu.state = 0;
+
+ XtAddCallback(cnew, XtNpopupCallback, PopupCB, NULL);
+#endif
+
+ if (smw->simple_menu.label_string != NULL)
+ CreateLabel(cnew);
+
+ width = height = 0;
+ CalculateNewSize(cnew, &width, &height);
+
+ smw->simple_menu.menu_width = True;
+
+ if (XtWidth(smw) == 0) {
+ smw->simple_menu.menu_width = False;
+ XtWidth(smw) = width;
+ }
+
+ smw->simple_menu.menu_height = True;
+
+ if (XtHeight(smw) == 0) {
+ smw->simple_menu.menu_height = False;
+ XtHeight(smw) = height;
+ }
+
+ /*
+ * Add a popup_callback routine for changing the cursor
+ */
+ XtAddCallback(cnew, XtNpopupCallback, ChangeCursorOnGrab, NULL);
+}
+
+/*
+ * Function:
+ * XawSimpleMenuRedisplay
+ *
+ * Parameters:
+ * w - simple menu widget
+ * event - X event that caused this redisplay
+ * region - region the needs to be repainted
+ *
+ * Description:
+ * Redisplays the contents of the widget.
+ */
+/*ARGSUSED*/
+static void
+XawSimpleMenuRedisplay(Widget w, XEvent *event, Region region)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+ SmeObject *entry;
+ SmeObjectClass cclass;
+
+ if (region == NULL)
+ XClearWindow(XtDisplay(w), XtWindow(w));
+
+#ifndef OLDXAW
+ if (smw->simple_menu.display_list)
+ XawRunDisplayList(w, smw->simple_menu.display_list, event, region);
+#endif
+
+ /*
+ * Check and Paint each of the entries - including the label
+ */
+ ForAllChildren(smw, entry) {
+ if (!XtIsManaged((Widget)*entry))
+ continue;
+
+ if (region != NULL)
+ switch(XRectInRegion(region, XtX(*entry),XtY(*entry),
+ XtWidth(*entry), XtHeight(*entry))) {
+ case RectangleIn:
+ case RectanglePart:
+ break;
+ default:
+ continue;
+ }
+
+ cclass = (SmeObjectClass)(*entry)->object.widget_class;
+
+ if (cclass->rect_class.expose != NULL)
+ (cclass->rect_class.expose)((Widget)*entry, NULL, NULL);
+ }
+}
+
+/*
+ * Function:
+ * XawSimpleMenuRealize
+ *
+ * Parameters:
+ * w - simple menu widget
+ * mask - value mask for the window to create
+ * attrs - attributes for the window to create
+ *
+ * Description:
+ * Realizes the widget.
+ */
+static void
+XawSimpleMenuRealize(Widget w, XtValueMask *mask, XSetWindowAttributes *attrs)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+#ifndef OLDXAW
+ XawPixmap *pixmap;
+#endif
+
+ attrs->cursor = smw->simple_menu.cursor;
+ *mask |= CWCursor;
+ if (smw->simple_menu.backing_store == Always ||
+ smw->simple_menu.backing_store == NotUseful ||
+ smw->simple_menu.backing_store == WhenMapped) {
+ *mask |= CWBackingStore;
+ attrs->backing_store = smw->simple_menu.backing_store;
+ }
+ else
+ *mask &= ~CWBackingStore;
+
+ (*Superclass->core_class.realize)(w, mask, attrs);
+
+#ifndef OLDXAW
+ if (w->core.background_pixmap > XtUnspecifiedPixmap) {
+ pixmap = XawPixmapFromXPixmap(w->core.background_pixmap, XtScreen(w),
+ w->core.colormap, w->core.depth);
+ if (pixmap && pixmap->mask)
+ XawReshapeWidget(w, pixmap);
+ }
+#endif
+}
+
+/*
+ * Function:
+ * XawSimpleMenuResize
+ *
+ * Parameters:
+ * w - simple menu widget
+ *
+ * Description:
+ * Handle the menu being resized.
+ */
+static void
+XawSimpleMenuResize(Widget w)
+{
+ if (!XtIsRealized(w))
+ return;
+
+ Layout(w, NULL, NULL);
+
+ XawSimpleMenuRedisplay(w, NULL, NULL);
+}
+
+/*
+ * Function:
+ * XawSimpleMenuSetValues
+ *
+ * Parameters:
+ * current - current state of the widget
+ * request - what was requested
+ * cnew - what the widget will become
+ *
+ * Description:
+ * Relayout the menu when one of the resources is changed.
+ */
+/*ARGSUSED*/
+static Boolean
+XawSimpleMenuSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ SimpleMenuWidget smw_old = (SimpleMenuWidget)current;
+ SimpleMenuWidget smw_new = (SimpleMenuWidget)cnew;
+ Boolean ret_val = False, layout = False;
+
+ if (!XtIsRealized(current))
+ return (False);
+
+ if (!smw_new->simple_menu.recursive_set_values) {
+ if (XtWidth(smw_new) != XtWidth(smw_old)) {
+ smw_new->simple_menu.menu_width = XtWidth(smw_new) != 0;
+ layout = True;
+ }
+ if (XtHeight(smw_new) != XtHeight(smw_old)) {
+ smw_new->simple_menu.menu_height = XtHeight(smw_new) != 0;
+ layout = True;
+ }
+ }
+
+ if (smw_old->simple_menu.cursor != smw_new->simple_menu.cursor)
+ XDefineCursor(XtDisplay(cnew), XtWindow(cnew),
+ smw_new->simple_menu.cursor);
+
+ if (smw_old->simple_menu.label_string !=smw_new->simple_menu.label_string) {
+ if (smw_new->simple_menu.label_string == NULL) /* Destroy */
+ XtDestroyWidget((Widget)smw_old->simple_menu.label);
+ else if (smw_old->simple_menu.label_string == NULL) /* Create */
+ CreateLabel(cnew);
+ else { /* Change */
+ Arg arglist[1];
+
+ XtSetArg(arglist[0], XtNlabel, smw_new->simple_menu.label_string);
+ XtSetValues((Widget)smw_new->simple_menu.label, arglist, ONE);
+ }
+ }
+
+ if (smw_old->simple_menu.label_class != smw_new->simple_menu.label_class)
+ XtAppWarning(XtWidgetToApplicationContext(cnew),
+ "No Dynamic class change of the SimpleMenu Label.");
+
+ if (smw_old->simple_menu.top_margin != smw_new->simple_menu.top_margin
+ || smw_old->simple_menu.bottom_margin
+ != smw_new->simple_menu.bottom_margin) {
+ layout = True;
+ ret_val = True;
+ }
+
+#ifndef OLDXAW
+ if (smw_old->core.background_pixmap != smw_new->core.background_pixmap) {
+ XawPixmap *opix, *npix;
+
+ opix = XawPixmapFromXPixmap(smw_old->core.background_pixmap,
+ XtScreen(smw_old), smw_old->core.colormap,
+ smw_old->core.depth);
+ npix = XawPixmapFromXPixmap(smw_new->core.background_pixmap,
+ XtScreen(smw_new), smw_new->core.colormap,
+ smw_new->core.depth);
+ if ((npix && npix->mask) || (opix && opix->mask))
+ XawReshapeWidget(cnew, npix);
+ }
+#endif
+
+ if (layout)
+ Layout(cnew, NULL, NULL);
+
+ return (ret_val);
+}
+
+/*
+ * Function:
+ * XawSimpleMenuSetValuesHook
+ *
+ * Parameters:
+ * w - menu widget
+ * arglist - argument list passed to XtSetValues
+ * num_args - number of args
+ *
+ * Description:
+ * To handle a special case, this is passed the actual arguments.
+ */
+static Boolean
+XawSimpleMenuSetValuesHook(Widget w, ArgList arglist, Cardinal *num_args)
+{
+ Cardinal i;
+ Dimension width, height;
+
+ width = XtWidth(w);
+ height = XtHeight(w);
+
+ for (i = 0 ; i < *num_args ; i++) {
+ if (streq(arglist[i].name, XtNwidth))
+ width = (Dimension)arglist[i].value;
+ if (streq(arglist[i].name, XtNheight))
+ height = (Dimension) arglist[i].value;
+ }
+
+ if (width != XtWidth(w) || height != XtHeight(w))
+ MakeSetValuesRequest(w, width, height);
+
+ return (False);
+}
+
+/*
+ * Geometry Management routines
+ */
+/*
+ * Function:
+ * XawSimpleMenuGeometryManager
+ *
+ * Parameters:
+ * w - Menu Entry making the request
+ * request - requested new geometry
+ * reply - the allowed geometry.
+ *
+ * Description:
+ * This is the SimpleMenu Widget's Geometry Manager.
+ *
+ * Returns:
+ * XtGeometry{Yes, No, Almost}
+ */
+static XtGeometryResult
+XawSimpleMenuGeometryManager(Widget w, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)XtParent(w);
+ SmeObject entry = (SmeObject)w;
+ XtGeometryMask mode = request->request_mode;
+ XtGeometryResult answer;
+ Dimension old_height, old_width;
+
+ if (!(mode & CWWidth) && !(mode & CWHeight))
+ return (XtGeometryNo);
+
+ reply->width = request->width;
+ reply->height = request->height;
+
+ old_width = XtWidth(entry);
+ old_height = XtHeight(entry);
+
+ Layout(w, &reply->width, &reply->height);
+
+ /*
+ * Since we are an override shell and have no parent there is no one to
+ * ask to see if this geom change is okay, so I am just going to assume
+ * we can do whatever we want. If you subclass be very careful with this
+ * assumption, it could bite you.
+ *
+ * Chris D. Peterson - Sept. 1989.
+ */
+ if ((!(mode & CWWidth) || reply->width == request->width)
+ && (!(mode & CWHeight) || reply->height == request->height)) {
+ if (mode & XtCWQueryOnly) { /* Actually perform the layout */
+ XtWidth(entry) = old_width;
+ XtHeight(entry) = old_height;
+ }
+ else
+ Layout((Widget)smw, NULL, NULL);
+ answer = XtGeometryDone;
+ }
+ else {
+ XtWidth(entry) = old_width;
+ XtHeight(entry) = old_height;
+
+ if ((reply->width == request->width && !(mode & CWHeight))
+ || (reply->height == request->height && !(mode & CWWidth))
+ || (reply->width == request->width
+ && reply->height == request->height))
+ answer = XtGeometryNo;
+ else {
+ answer = XtGeometryAlmost;
+ reply->request_mode = 0;
+ if (reply->width != request->width)
+ reply->request_mode |= CWWidth;
+ if (reply->height != request->height)
+ reply->request_mode |= CWHeight;
+ }
+ }
+
+ return (answer);
+}
+
+/*
+ * Function:
+ * XawSimpleMenuChangeManaged
+ *
+ * Parameters:
+ * w - simple menu widget
+ *
+ * Description:
+ * Called whenever a new child is managed.
+ */
+static void
+XawSimpleMenuChangeManaged(Widget w)
+{
+ Layout(w, NULL, NULL);
+}
+
+/*
+ * Global Action Routines
+ *
+ * These actions routines will be added to the application's
+ * global action list
+ */
+/*
+ * Function:
+ * PositionMenuAction
+ *
+ * Parameters:
+ * w - a widget (no the simple menu widget)
+ * event - the event that caused this action
+ * params - parameters passed to the routine.
+ * we expect the name of the menu here.
+ * num_params - ""
+ *
+ * Description:
+ * Positions the simple menu widget.
+ */
+/*ARGSUSED*/
+static void
+PositionMenuAction(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ Widget menu;
+ XPoint loc;
+
+ if (*num_params != 1) {
+ XtAppWarning(XtWidgetToApplicationContext(w),
+ "SimpleMenuWidget: position menu action expects "
+ "only one parameter which is the name of the menu.");
+ return;
+ }
+
+ if ((menu = FindMenu(w, params[0])) == NULL) {
+ char error_buf[BUFSIZ];
+
+ (void)XmuSnprintf(error_buf, sizeof(error_buf),
+ "SimpleMenuWidget: could not find menu named %s.",
+ params[0]);
+ XtAppWarning(XtWidgetToApplicationContext(w), error_buf);
+ return;
+ }
+
+ switch (event->type) {
+ case ButtonPress:
+ case ButtonRelease:
+ loc.x = event->xbutton.x_root;
+ loc.y = event->xbutton.y_root;
+ PositionMenu(menu, &loc);
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ loc.x = event->xcrossing.x_root;
+ loc.y = event->xcrossing.y_root;
+ PositionMenu(menu, &loc);
+ break;
+ case MotionNotify:
+ loc.x = event->xmotion.x_root;
+ loc.y = event->xmotion.y_root;
+ PositionMenu(menu, &loc);
+ break;
+ default:
+ PositionMenu(menu, NULL);
+ break;
+ }
+}
+
+/*
+ * Widget Action Routines
+ */
+/*
+ * Function:
+ * Unhighlight
+ *
+ * Parameters:
+ * w - simple menu widget
+ * event - event that caused this action
+ * params - not used
+ * num_params - ""
+ *
+ * Description:
+ * Unhighlights current entry.
+ */
+/*ARGSUSED*/
+static void
+Unhighlight(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+ SmeObject entry = smw->simple_menu.entry_set;
+
+ if (entry == NULL)
+ return;
+
+#ifndef OLDXAW
+ if (!smw->simple_menu.sub_menu)
+#endif
+ {
+ SmeObjectClass cclass;
+
+ smw->simple_menu.entry_set = NULL;
+ cclass = (SmeObjectClass)entry->object.widget_class;
+ (cclass->sme_class.unhighlight)((Widget)entry);
+ }
+}
+
+/*
+ * Function:
+ * Highlight
+ *
+ * Parameters:
+ * w - simple menu widget
+ * event - event that caused this action
+ * params - not used
+ * num_params - ""
+ *
+ * Description:
+ * Highlights current entry.
+ */
+/*ARGSUSED*/
+static void
+Highlight(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+ SmeObject entry;
+
+ if (!XtIsSensitive(w))
+ return;
+
+ entry = GetEventEntry(w, event);
+
+ if (entry == smw->simple_menu.entry_set)
+ return;
+
+#ifndef OLDXAW
+ if (!smw->simple_menu.sub_menu)
+#endif
+ Unhighlight(w, event, params, num_params);
+
+ if (entry == NULL)
+ return;
+
+ if (!XtIsSensitive((Widget)entry))
+ return;
+
+#ifndef OLDXAW
+ if (smw->simple_menu.sub_menu)
+ PopdownSubMenu(smw);
+#endif
+
+ Unhighlight(w, event, params, num_params);
+
+#ifndef OLDXAW
+ if (!(smw->simple_menu.state & SMW_UNMAPPING))
+#endif
+ {
+ SmeObjectClass cclass;
+
+ smw->simple_menu.entry_set = entry;
+ cclass = (SmeObjectClass)entry->object.widget_class;
+
+ (cclass->sme_class.highlight)((Widget)entry);
+
+#ifndef OLDXAW
+ if (XtIsSubclass((Widget)entry, smeBSBObjectClass))
+ PopupSubMenu(smw);
+#endif
+ }
+}
+
+/*
+ * Function:
+ * Notify
+ *
+ * Parameters:
+ * w - simple menu widget
+ * event - event that caused this action
+ * params - not used
+ * num_params - ""
+ *
+ * Description:
+ * Notify user of current entry.
+ */
+/*ARGSUSED*/
+static void
+Notify(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ SmeObject entry;
+ SmeObjectClass cclass;
+
+ /* may be a propagated event from a sub menu, need to check it */
+ if (XtWindow(w) != event->xany.window)
+ return;
+ entry = GetEventEntry(w, event);
+ if (entry == NULL || !XtIsSensitive((Widget)entry))
+ return;
+
+ cclass = (SmeObjectClass) entry->object.widget_class;
+ (cclass->sme_class.notify)((Widget)entry);
+}
+
+/*
+ * Public Functions
+ */
+/*
+ * Function:
+ * XawSimpleMenuAddGlobalActions
+ *
+ * Arguments:
+ * app_con - appcontext
+ *
+ * Description:
+ * Adds the global actions to the simple menu widget.
+ */
+void
+XawSimpleMenuAddGlobalActions(XtAppContext app_con)
+{
+ XtInitializeWidgetClass(simpleMenuWidgetClass);
+ XmuCallInitializers(app_con);
+}
+
+/*
+ * Function:
+ * XawSimpleMenuGetActiveEntry
+ *
+ * Parameters:
+ * w - smw widget
+ *
+ * Description:
+ * Gets the currently active (set) entry.
+ *
+ * Returns:
+ * The currently set entry or NULL if none is set
+ */
+Widget
+XawSimpleMenuGetActiveEntry(Widget w)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+
+ return ((Widget)smw->simple_menu.entry_set);
+}
+
+/*
+ * Function:
+ * XawSimpleMenuClearActiveEntry
+ *
+ * Parameters:
+ * w - smw widget
+ *
+ * Description:
+ * Unsets the currently active (set) entry.
+ */
+void
+XawSimpleMenuClearActiveEntry(Widget w)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+
+ smw->simple_menu.entry_set = NULL;
+}
+
+/*
+ * Private Functions
+ */
+/*
+ * Function:
+ * CreateLabel
+ *
+ * Parameters:
+ * w - smw widget
+ *
+ * Description:
+ * Creates the label object and makes sure it is the first child in
+ * in the list.
+ */
+static void
+CreateLabel(Widget w)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+ Widget *child, *next_child;
+ int i;
+ Arg args[2];
+
+ if (smw->simple_menu.label_string == NULL ||
+ smw->simple_menu.label != NULL) {
+ XtAppWarning(XtWidgetToApplicationContext(w),
+ "Xaw Simple Menu Widget: label string is NULL or "
+ "label already exists, no label is being created.");
+ return;
+ }
+
+ XtSetArg(args[0], XtNlabel, smw->simple_menu.label_string);
+ XtSetArg(args[1], XtNjustify, XtJustifyCenter);
+ smw->simple_menu.label = (SmeObject)
+ XtCreateManagedWidget("menuLabel",
+ smw->simple_menu.label_class, w, args, TWO);
+
+ next_child = NULL;
+ for (child = smw->composite.children + smw->composite.num_children,
+ i = smw->composite.num_children; i > 0; i--, child--) {
+ if (next_child != NULL)
+ *next_child = *child;
+ next_child = child;
+ }
+ *child = (Widget)smw->simple_menu.label;
+}
+
+/*
+ * Function:
+ * Layout
+ *
+ * Arguments:
+ * w - See below
+ * width_ret - returned width
+ * height_ret - returned height
+ *
+ * Note:
+ * if width == NULL || height == NULL then it assumes the you do not care
+ * about the return values, and just want a relayout.
+ *
+ * if this is not the case then it will set width_ret and height_ret
+ * to be width and height that the child would get if it were layed out
+ * at this time.
+ *
+ * "w" can be the simple menu widget or any of its object children.
+ */
+static void
+Layout(Widget w, Dimension *width_ret, Dimension *height_ret)
+{
+ SmeObject current_entry;
+ SimpleMenuWidget smw;
+ Dimension width, height;
+ Boolean allow_change_size;
+ Widget kid;
+ Cardinal i, count, n;
+ int width_kid, height_kid, tmp_w, tmp_h;
+ short vadd, hadd, x_ins, y_ins;
+ Dimension *widths;
+
+ height = 0;
+
+ if (XtIsSubclass(w, simpleMenuWidgetClass)) {
+ smw = (SimpleMenuWidget)w;
+ current_entry = NULL;
+ }
+ else {
+ smw = (SimpleMenuWidget)XtParent(w);
+ current_entry = (SmeObject)w;
+ }
+
+ allow_change_size = (!XtIsRealized((Widget)smw)
+ || smw->shell.allow_shell_resize);
+
+ for (i = smw->simple_menu.label ? 1 : 0;
+ i < smw->composite.num_children;
+ i++) {
+ XtWidgetGeometry preferred;
+
+ kid = smw->composite.children[i];
+ if (!XtIsManaged(kid))
+ continue;
+ if (smw->simple_menu.row_height != 0)
+ XtHeight(kid) = smw->simple_menu.row_height;
+ XtQueryGeometry(kid, NULL, &preferred);
+ if (preferred.request_mode & CWWidth)
+ XtWidth(kid) = preferred.width;
+ }
+
+ if (smw->simple_menu.label
+ && XtIsManaged((Widget)smw->simple_menu.label)) {
+ XtWidgetGeometry preferred;
+
+ kid = (Widget)smw->simple_menu.label;
+ XtQueryGeometry(kid, NULL, &preferred);
+ if (preferred.request_mode & CWWidth)
+ XtWidth(kid) = preferred.width;
+ if (preferred.request_mode & CWHeight)
+ XtHeight(kid) = preferred.height;
+ }
+
+ /* reset */
+ if (!smw->simple_menu.menu_width)
+ XtWidth(smw) = 0;
+ if (!smw->simple_menu.menu_height)
+ XtHeight(smw) = 0;
+ if (!XtWidth(smw) || !XtHeight(smw))
+ MakeResizeRequest((Widget)smw);
+
+ widths = (Dimension *)XtMalloc(sizeof(Dimension));
+#ifndef OLDXAW
+ hadd = smw->simple_menu.left_margin;
+#else
+ hadd = 0;
+#endif
+ vadd = smw->simple_menu.top_margin;
+ if (smw->simple_menu.label)
+ vadd += XtHeight(smw->simple_menu.label);
+
+ count = 1;
+ width = tmp_w = tmp_h = n = 0;
+ height = vadd;
+
+ for (i = smw->simple_menu.label ? 1 : 0;
+ i < smw->composite.num_children;
+ i++) {
+ kid = smw->composite.children[i];
+ if (!XtIsManaged(kid))
+ continue;
+ width_kid = XtWidth(kid);
+ height_kid = XtHeight(kid);
+
+ if (n && (height + height_kid + smw->simple_menu.bottom_margin
+ > XtHeight(smw))) {
+ ++count;
+ widths = (Dimension *)XtRealloc((char *)widths,
+ sizeof(Dimension) * count);
+ widths[count - 1] = width_kid;
+ width += tmp_w;
+ tmp_w = width_kid;
+ height = height_kid + vadd;
+ }
+ else
+ height += height_kid;
+ if (height > tmp_h)
+ tmp_h = height;
+ if (width_kid > tmp_w)
+ widths[count - 1] = tmp_w = width_kid;
+ ++n;
+ }
+
+ height = tmp_h + smw->simple_menu.bottom_margin;
+ width += tmp_w;
+
+ if (smw->simple_menu.label && width < XtWidth(smw->simple_menu.label)) {
+ float inc;
+
+ inc = (XtWidth(smw->simple_menu.label) - width) / (float)count;
+ width = XtWidth(smw->simple_menu.label);
+ for (n = 0; n < count; n++)
+ widths[n] += inc;
+ }
+
+#ifndef OLDXAW
+ width += hadd + smw->simple_menu.right_margin;
+#endif
+
+ x_ins = n = count = 0;
+ tmp_w = widths[0];
+ tmp_h = vadd;
+
+ for (i = smw->simple_menu.label ? 1 : 0;
+ i < smw->composite.num_children;
+ i++) {
+ kid = smw->composite.children[i];
+ if (!XtIsManaged(kid))
+ continue;
+
+ height_kid = XtHeight(kid);
+
+ if (n && (tmp_h + height_kid + smw->simple_menu.bottom_margin
+ > XtHeight(smw))) {
+ x_ins = tmp_w;
+ y_ins = vadd;
+ ++count;
+ tmp_w += widths[count];
+ tmp_h = height_kid + vadd;
+ }
+ else {
+ y_ins = tmp_h;
+ tmp_h += height_kid;
+ }
+ ++n;
+
+ XtX(kid) = x_ins + hadd;
+ XtY(kid) = y_ins;
+ XtWidth(kid) = widths[count];
+ }
+
+ XtFree((char *)widths);
+
+ if (allow_change_size)
+ MakeSetValuesRequest((Widget) smw, width, height);
+
+ if (smw->simple_menu.label) {
+ XtX(smw->simple_menu.label) = 0;
+ XtY(smw->simple_menu.label) = smw->simple_menu.top_margin;
+ XtWidth(smw->simple_menu.label) = XtWidth(smw)
+#ifndef OLDXAW
+ - (smw->simple_menu.left_margin + smw->simple_menu.right_margin)
+#endif
+ ;
+ }
+ if (current_entry) {
+ if (width_ret)
+ *width_ret = XtWidth(current_entry);
+ if (height_ret)
+ *height_ret = XtHeight(current_entry);
+ }
+}
+
+/*
+ * Function:
+ * AddPositionAction
+ *
+ * Parameters:
+ * app_con - application context
+ * data - (not used)
+ *
+ * Description:
+ * Adds the XawPositionSimpleMenu action to the global
+ * action list for this appcon.
+ */
+/*ARGSUSED*/
+static void
+AddPositionAction(XtAppContext app_con, XPointer data)
+{
+ static XtActionsRec pos_action[] = {
+ {"XawPositionSimpleMenu", PositionMenuAction},
+ };
+
+ XtAppAddActions(app_con, pos_action, XtNumber(pos_action));
+}
+
+/*
+ * Function:
+ * FindMenu
+ *
+ * Parameters:
+ * widget - reference widget
+ * name - menu widget's name
+ *
+ * Description:
+ * Find the menu give a name and reference widget
+ *
+ * Returns:
+ * The menu widget or NULL.
+ */
+static Widget
+FindMenu(Widget widget, String name)
+{
+ Widget w, menu;
+
+ for (w = widget; w != NULL; w = XtParent(w))
+ if ((menu = XtNameToWidget(w, name)) != NULL)
+ return (menu);
+
+ return (NULL);
+}
+
+/*
+ * Function:
+ * PositionMenu
+ *
+ * Parameters:
+ * w - simple menu widget
+ * location - pointer the the position or NULL
+ *
+ * Description:
+ * Places the menu
+ */
+static void
+PositionMenu(Widget w, XPoint *location)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+ SmeObject entry;
+ XPoint t_point;
+
+ if (location == NULL) {
+ Window temp1, temp2;
+ int root_x, root_y, tempX, tempY;
+ unsigned int tempM;
+
+ location = &t_point;
+ if (XQueryPointer(XtDisplay(w), XtWindow(w), &temp1, &temp2,
+ &root_x, &root_y, &tempX, &tempY, &tempM) == False) {
+ XtAppWarning(XtWidgetToApplicationContext(w),
+ "Xaw Simple Menu Widget: "
+ "Could not find location of mouse pointer");
+ return;
+ }
+ location->x = (short) root_x;
+ location->y = (short) root_y;
+ }
+
+ /*
+ * The width will not be correct unless it is realized
+ */
+ XtRealizeWidget(w);
+
+ location->x -= XtWidth(w) >> 1;
+
+ if (smw->simple_menu.popup_entry == NULL)
+ entry = smw->simple_menu.label;
+ else
+ entry = smw->simple_menu.popup_entry;
+
+ if (entry != NULL)
+ location->y -= XtY(entry) + (XtHeight(entry) >> 1);
+
+ MoveMenu(w, location->x, location->y);
+}
+
+/*
+ * Function:
+ * MoveMenu
+ *
+ * Parameters:
+ * w - simple menu widget
+ * x - current location of the widget
+ * y - ""
+ *
+ * Description:
+ * Actually moves the menu, may force it to
+ * to be fully visable if menu_on_screen is True.
+ */
+static void
+MoveMenu(Widget w, int x, int y)
+{
+ Arg arglist[2];
+ Cardinal num_args = 0;
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+
+ if (smw->simple_menu.menu_on_screen) {
+ int width = XtWidth(w) + (XtBorderWidth(w) << 1);
+ int height = XtHeight(w) + (XtBorderWidth(w) << 1);
+
+ if (x >= 0) {
+ int scr_width = WidthOfScreen(XtScreen(w));
+
+ if (x + width > scr_width)
+ x = scr_width - width;
+ }
+ if (x < 0)
+ x = 0;
+
+ if (y >= 0) {
+ int scr_height = HeightOfScreen(XtScreen(w));
+
+ if (y + height > scr_height)
+ y = scr_height - height;
+ }
+ if (y < 0)
+ y = 0;
+ }
+
+ XtSetArg(arglist[num_args], XtNx, x); num_args++;
+ XtSetArg(arglist[num_args], XtNy, y); num_args++;
+ XtSetValues(w, arglist, num_args);
+}
+
+/*
+ * Function:
+ * ChangeCursorOnGrab
+ *
+ * Parameters:
+ * w - menu widget
+ * temp1 - not used
+ * temp2 - ""
+ *
+ * Description:
+ * Changes the cursor on the active grab to the one
+ * specified in out resource list.
+ */
+/*ARGSUSED*/
+static void
+ChangeCursorOnGrab(Widget w, XtPointer temp1, XtPointer temp2)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+
+ /*
+ * The event mask here is what is currently in the MIT implementation.
+ * There really needs to be a way to get the value of the mask out
+ * of the toolkit (CDP 5/26/89).
+ */
+ XChangeActivePointerGrab(XtDisplay(w), ButtonPressMask | ButtonReleaseMask,
+ smw->simple_menu.cursor,
+ XtLastTimestampProcessed(XtDisplay(w)));
+}
+
+/*
+ * Function:
+ * MakeSetValuesRequest
+ *
+ * Parameters:
+ * w - simple menu widget
+ * width - size requested
+ * height - ""
+ */
+static void
+MakeSetValuesRequest(Widget w, unsigned int width, unsigned int height)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+ Arg arglist[2];
+ Cardinal num_args = 0;
+
+ if (!smw->simple_menu.recursive_set_values) {
+ if (XtWidth(smw) != width || XtHeight(smw) != height) {
+ smw->simple_menu.recursive_set_values = True;
+ XtSetArg(arglist[num_args], XtNwidth, width); num_args++;
+ XtSetArg(arglist[num_args], XtNheight, height); num_args++;
+ XtSetValues(w, arglist, num_args);
+ }
+ else if (XtIsRealized((Widget)smw))
+ XawSimpleMenuRedisplay((Widget)smw, NULL, NULL);
+ }
+ smw->simple_menu.recursive_set_values = False;
+}
+
+static SmeObject
+DoGetEventEntry(Widget w, int x_loc, int y_loc)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+ SmeObject *entry;
+
+ ForAllChildren(smw, entry) {
+ if (!XtIsManaged((Widget)*entry))
+ continue;
+
+ if (x_loc > XtX(*entry)
+ && x_loc <= XtX(*entry) + XtWidth(*entry)
+ && y_loc > XtY(*entry)
+ && y_loc <= XtY(*entry) + XtHeight(*entry)) {
+ if (*entry == smw->simple_menu.label)
+ return (NULL); /* cannot select the label */
+ else
+ return (*entry);
+ }
+ }
+
+ return (NULL);
+}
+
+/*
+ * Function:
+ * GetEventEntry
+ *
+ * Parameters:
+ * w - simple menu widget
+ * event - X event
+ *
+ * Description:
+ * Gets an entry given an event that has X and Y coords.
+ *
+ * Returns:
+ * The entry that this point is in
+ */
+static SmeObject
+GetEventEntry(Widget w, XEvent *event)
+{
+ int x_loc, y_loc, x_root;
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+ SmeObject entry;
+ int warp, move;
+
+ switch (event->type) {
+ case MotionNotify:
+ x_loc = event->xmotion.x;
+ y_loc = event->xmotion.y;
+ x_root = event->xmotion.x_root;
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ x_loc = event->xcrossing.x;
+ y_loc = event->xcrossing.y;
+ x_root = event->xcrossing.x_root;
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ x_loc = event->xbutton.x;
+ y_loc = event->xbutton.y;
+ x_root = event->xbutton.x_root;
+ break;
+ default:
+ XtAppError(XtWidgetToApplicationContext(w),
+ "Unknown event type in GetEventEntry().");
+ return (NULL);
+ }
+
+ if (x_loc < 0 || x_loc >= XtWidth(smw) ||
+ y_loc < 0 || y_loc >= XtHeight(smw))
+ return (NULL);
+
+ /* Move the menu if it's outside the screen, does not check
+ * smw->simple_menu.menu_on_screen because menus is bigger than screen
+ */
+ if (x_root == WidthOfScreen(XtScreen(w)) - 1 &&
+ XtX(w) + XtWidth(w) + (XtBorderWidth(w)) > x_root) {
+ warp = -8;
+ if (smw->simple_menu.entry_set) {
+ entry = DoGetEventEntry(w,
+ XtX(smw->simple_menu.entry_set)
+ + XtWidth(smw->simple_menu.entry_set) + 1,
+ y_loc);
+ Unhighlight(w, event, NULL, NULL);
+ if (entry) {
+ warp = -(int)XtWidth(entry) >> 1;
+ move = x_loc - XtWidth(entry) - XtX(entry) + XtBorderWidth(w);
+ }
+ else {
+ warp = 0;
+ move = WidthOfScreen(XtScreen(w)) -
+ (XtX(w) + XtWidth(w) + (XtBorderWidth(w) << 1));
+ }
+ }
+ else {
+ warp = 0;
+ move = WidthOfScreen(XtScreen(w)) -
+ (XtX(w) + XtWidth(w) + (XtBorderWidth(w) << 1));
+ }
+ }
+ else if (x_root == 0 && XtX(w) < 0) {
+ warp = 8;
+ if (smw->simple_menu.entry_set) {
+ entry = DoGetEventEntry(w, XtX(smw->simple_menu.entry_set) - 1,
+ y_loc);
+ Unhighlight(w, event, NULL, NULL);
+ if (entry) {
+ warp = XtWidth(entry) >> 1;
+ move = x_loc - XtX(entry);
+ }
+ else
+ move = x_loc + XtBorderWidth(w);
+ }
+ else
+ move = x_loc + XtBorderWidth(w);
+ }
+ else
+ move = warp = 0;
+
+ if (move)
+ XtMoveWidget(w, XtX(w) + move, XtY(w));
+ if (warp)
+ XWarpPointer(XtDisplay(w), None, None, 0, 0, 0, 0, warp, 0);
+
+ return (DoGetEventEntry(w, x_loc, y_loc));
+}
+
+static void
+CalculateNewSize(Widget w, Dimension *width_return, Dimension *height_return)
+{
+ SimpleMenuWidget xaw = (SimpleMenuWidget)w;
+ Widget kid;
+ Cardinal i;
+ int width_kid, height_kid;
+ int width, height, tmp_w, tmp_h, max_dim;
+ short vadd, hadd;
+ int n, columns, test_h, num_children = 0;
+ Boolean try_layout = False;
+
+#ifndef OLDXAW
+ hadd = xaw->simple_menu.left_margin + xaw->simple_menu.right_margin;
+#else
+ hadd = 0;
+#endif
+ vadd = xaw->simple_menu.top_margin + xaw->simple_menu.bottom_margin;
+ if (xaw->simple_menu.label)
+ vadd += XtHeight(xaw->simple_menu.label);
+
+ if (*height_return)
+ max_dim = *height_return;
+ else if (!XtHeight(w)) {
+ max_dim = HeightOfScreen(XtScreen(w));
+ try_layout = True;
+ }
+ else
+ max_dim = XtHeight(w);
+ max_dim -= vadd;
+
+ width = height = tmp_w = tmp_h = n = test_h = 0;
+ columns = 1;
+ for (i = xaw->simple_menu.label ? 1 : 0;
+ i < xaw->composite.num_children;
+ i++) {
+ kid = xaw->composite.children[i];
+ if (!XtIsManaged(kid))
+ continue;
+ ++num_children;
+ width_kid = XtWidth(kid);
+ height_kid = XtHeight(kid);
+
+ if (try_layout) {
+ if (!test_h)
+ test_h = height_kid;
+ else if (test_h != height_kid)
+ try_layout = False;
+ }
+
+ if (n && (height + height_kid > max_dim)) {
+ ++columns;
+ width += tmp_w;
+ tmp_w = width_kid;
+ height = height_kid;
+ }
+ else
+ height += height_kid;
+ if (height > tmp_h)
+ tmp_h = height;
+ if (width_kid > tmp_w)
+ tmp_w = width_kid;
+ ++n;
+ }
+
+ height = tmp_h + vadd;
+ width += tmp_w + hadd;
+
+ if (xaw->simple_menu.label)
+ width = XawMax(width, XtWidth(xaw->simple_menu.label) + hadd);
+
+ *width_return = width;
+ *height_return = height;
+
+ if (try_layout && columns > 1 && num_children > 2) {
+ int space;
+
+ height = test_h * (xaw->simple_menu.label ?
+ num_children - 1 :
+ num_children);
+
+ max_dim -= max_dim % test_h;
+ space = max_dim - (height % max_dim);
+ if (space >= test_h * columns) {
+ height = max_dim - space / columns;
+ if (height % test_h)
+ height += test_h - (height % test_h);
+ *height_return = height + vadd;
+ CalculateNewSize(w, width_return, height_return);
+ }
+ }
+}
+
+static void
+MakeResizeRequest(Widget w)
+{
+ int tries;
+ Dimension width, height;
+
+ width = XtWidth(w);
+ height = XtHeight(w);
+
+ for (tries = 0; tries < 100; tries++) {
+ CalculateNewSize(w, &width, &height);
+ if (width == XtWidth(w) && height == XtHeight(w))
+ break;
+ if (XtMakeResizeRequest(w, width, height, &width, &height) ==
+ XtGeometryNo)
+ break;
+ }
+}
+
+#ifndef OLDXAW
+static void
+Popdown(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+
+ while (XtParent(w) &&
+ XtIsSubclass(XtParent(w), simpleMenuWidgetClass)) {
+ if (((SimpleMenuWidget)XtParent(w))->simple_menu.sub_menu == (Widget)w) {
+ w = XtParent(w);
+ smw = (SimpleMenuWidget)w;
+ smw->simple_menu.entry_set = NULL;
+ }
+ else
+ break;
+ }
+
+ smw->simple_menu.state |= SMW_UNMAPPING;
+ if (smw->simple_menu.sub_menu)
+ PopdownSubMenu(smw);
+ XtCallActionProc(w, "XtMenuPopdown", event, params, *num_params);
+}
+
+static void
+PopupSubMenu(SimpleMenuWidget smw)
+{
+ Arg args[2];
+ Cardinal num_args;
+ Widget menu;
+ SmeBSBObject entry = (SmeBSBObject)smw->simple_menu.entry_set;
+ Position menu_x, menu_y;
+ Bool popleft;
+
+ if (entry->sme_bsb.menu_name == NULL)
+ return;
+
+ if ((menu = FindMenu((Widget)smw, entry->sme_bsb.menu_name)) == NULL)
+ return;
+
+ smw->simple_menu.sub_menu = menu;
+
+ if (!XtIsRealized(menu))
+ XtRealizeWidget(menu);
+
+ popleft = (smw->simple_menu.state & SMW_POPLEFT) != 0;
+
+ if (popleft)
+ XtTranslateCoords((Widget)smw, -(int)XtWidth(menu),
+ XtY(entry) - XtBorderWidth(menu), &menu_x, &menu_y);
+ else
+ XtTranslateCoords((Widget)smw, XtWidth(smw), XtY(entry)
+ - XtBorderWidth(menu), &menu_x, &menu_y);
+
+ if (!popleft && menu_x >= 0) {
+ int scr_width = WidthOfScreen(XtScreen(menu));
+
+ if (menu_x + XtWidth(menu) > scr_width) {
+ menu_x -= XtWidth(menu) + XtWidth(smw);
+ popleft = True;
+ }
+ }
+ else if (popleft && menu_x < 0) {
+ menu_x = 0;
+ popleft = False;
+ }
+ if (menu_y >= 0) {
+ int scr_height = HeightOfScreen(XtScreen(menu));
+
+ if (menu_y + XtHeight(menu) > scr_height)
+ menu_y = scr_height - XtHeight(menu) - XtBorderWidth(menu);
+ }
+ if (menu_y < 0)
+ menu_y = 0;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNx, menu_x); num_args++;
+ XtSetArg(args[num_args], XtNy, menu_y); num_args++;
+ XtSetValues(menu, args, num_args);
+
+ if (popleft)
+ ((SimpleMenuWidget)menu)->simple_menu.state |= SMW_POPLEFT;
+ else
+ ((SimpleMenuWidget)menu)->simple_menu.state &= ~SMW_POPLEFT;
+
+ XtPopup(menu, XtGrabNone);
+}
+
+static void
+PopdownSubMenu(SimpleMenuWidget smw)
+{
+ SimpleMenuWidget menu = (SimpleMenuWidget)smw->simple_menu.sub_menu;
+
+ if (!menu)
+ return;
+
+ menu->simple_menu.state |= SMW_UNMAPPING;
+ PopdownSubMenu(menu);
+
+ XtPopdown((Widget)menu);
+
+ smw->simple_menu.sub_menu = NULL;
+}
+
+/*ARGSUSED*/
+static void
+PopupCB(Widget w, XtPointer client_data, XtPointer call_data)
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget)w;
+
+ smw->simple_menu.state &= ~(SMW_UNMAPPING | SMW_POPLEFT);
+}
+#endif /* OLDXAW */
diff --git a/nx-X11/lib/Xaw/SimpleMenu.h b/nx-X11/lib/Xaw/SimpleMenu.h
new file mode 100644
index 000000000..0ee689683
--- /dev/null
+++ b/nx-X11/lib/Xaw/SimpleMenu.h
@@ -0,0 +1,173 @@
+/*
+ * $Xorg: SimpleMenu.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 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.
+ *
+ * Author: Chris D. Peterson, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xaw/SimpleMenu.h,v 1.7 2001/01/17 19:42:30 dawes Exp $ */
+
+/*
+ * SimpleMenu.h - Public Header file for SimpleMenu widget.
+ *
+ * This is the public header file for the Athena SimpleMenu widget.
+ * It is intended to provide one pane pulldown and popup menus within
+ * the framework of the X Toolkit. As the name implies it is a first and
+ * by no means complete implementation of menu code. It does not attempt to
+ * fill the needs of all applications, but does allow a resource oriented
+ * interface to menus.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _SimpleMenu_h
+#define _SimpleMenu_h
+
+#include <X11/Shell.h>
+#include <X11/Xmu/Converters.h>
+
+/*
+ * SimpleMenu widget
+ */
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ backgroundPixmap BackgroundPixmap Pixmap None
+ borderColor BorderColor Pixel XtDefaultForeground
+ borderPixmap BorderPixmap Pixmap None
+ borderWidth BorderWidth Dimension 1
+ bottomMargin VerticalMargins Dimension VerticalSpace
+ columnWidth ColumnWidth Dimension Width of widest text
+ cursor Cursor Cursor None
+ destroyCallback Callback Pointer NULL
+ displayList DisplayList XawDisplayList* NULL
+ height Height Dimension 0
+ label Label String NULL (No label)
+ labelClass LabelClass Pointer smeBSBObjectClass
+ leftMargin HorizontalMargins Dimension 0
+ mappedWhenManaged MappedWhenManaged Boolean True
+ rightMargin HorizontalMargins Dimension 0
+ rowHeight RowHeight Dimension Height of Font
+ sensitive Sensitive Boolean True
+ topMargin VerticalMargins Dimension VerticalSpace
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+typedef struct _SimpleMenuClassRec* SimpleMenuWidgetClass;
+typedef struct _SimpleMenuRec* SimpleMenuWidget;
+
+extern WidgetClass simpleMenuWidgetClass;
+
+#define XtNcursor "cursor"
+#define XtNbottomMargin "bottomMargin"
+#define XtNcolumnWidth "columnWidth"
+#define XtNlabelClass "labelClass"
+#define XtNmenuOnScreen "menuOnScreen"
+#define XtNpopupOnEntry "popupOnEntry"
+#define XtNrowHeight "rowHeight"
+#define XtNtopMargin "topMargin"
+#define XtNleftMargin "leftMargin"
+#define XtNrightMargin "rightMargin"
+
+#define XtCColumnWidth "ColumnWidth"
+#define XtCLabelClass "LabelClass"
+#define XtCMenuOnScreen "MenuOnScreen"
+#define XtCPopupOnEntry "PopupOnEntry"
+#define XtCRowHeight "RowHeight"
+
+#define XtCVerticalMargins "VerticalMargins"
+
+#ifndef OLDXAW
+#define XtCHorizontalMargins "HorizontalMargins"
+#define XawNdisplayList "displayList"
+#define XawCDisplayList "DisplayList"
+#define XawRDisplayList "XawDisplayList"
+#endif
+
+/*
+ * Public Functions
+ */
+
+_XFUNCPROTOBEGIN
+
+/*
+ * Function:
+ * XawSimpleMenuAddGlobalActions
+ *
+ * Parameters:
+ * app_con - appcontext
+ *
+ * Description:
+ * Adds the global actions to the simple menu widget.
+ */
+void XawSimpleMenuAddGlobalActions
+(
+ XtAppContext app_con
+ );
+
+/*
+ * Function:
+ * XawSimpleMenuGetActiveEntry
+ *
+ * Parameters:
+ * w - smw widget
+ *
+ * Description:
+ * Gets the currently active (set) entry.
+ *
+ * Returns:
+ * The currently set entry or NULL if none is set
+ */
+Widget XawSimpleMenuGetActiveEntry
+(
+ Widget w
+ );
+
+/*
+ * Function:
+ * XawSimpleMenuClearActiveEntry
+ *
+ * Parameters:
+ * w - smw widget
+ *
+ * Description:
+ * Unsets the currently active (set) entry.
+ */
+void XawSimpleMenuClearActiveEntry
+(
+ Widget w
+);
+
+_XFUNCPROTOEND
+
+#endif /* _SimpleMenu_h */
diff --git a/nx-X11/lib/Xaw/SimpleP.h b/nx-X11/lib/Xaw/SimpleP.h
new file mode 100644
index 000000000..f2fa3fa22
--- /dev/null
+++ b/nx-X11/lib/Xaw/SimpleP.h
@@ -0,0 +1,102 @@
+/***********************************************************
+
+ $Xorg: SimpleP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/SimpleP.h,v 1.12 2001/12/14 19:54:43 dawes Exp $ */
+
+#ifndef _SimpleP_h
+#define _SimpleP_h
+
+#include <X11/Xfuncproto.h>
+
+#include <X11/Xaw/Simple.h>
+
+_XFUNCPROTOBEGIN
+
+#include <X11/Xaw/XawInit.h>
+
+typedef struct {
+ Bool (*change_sensitive)(Widget);
+#ifndef OLDXAW
+ XtPointer extension;
+#endif
+} SimpleClassPart;
+
+#define XtInheritChangeSensitive ((Bool (*)(Widget))_XtInherit)
+
+typedef struct _SimpleClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+} SimpleClassRec;
+
+extern SimpleClassRec simpleClassRec;
+
+typedef struct {
+ /* resources */
+ Cursor cursor;
+ Pixmap insensitive_border;
+ String cursor_name; /* cursor specified by name */
+ Pixel pointer_fg, pointer_bg; /* Pointer colors */
+ Boolean international;
+
+ /* private */
+#ifndef OLDXAW
+ XawDisplayList *display_list;
+ String tip;
+ XtPointer pad[3]; /* for future use and keep binary compatability */
+#endif
+} SimplePart;
+
+typedef struct _SimpleRec {
+ CorePart core;
+ SimplePart simple;
+} SimpleRec;
+
+_XFUNCPROTOEND
+
+#endif /* _SimpleP_h */
diff --git a/nx-X11/lib/Xaw/Sme.c b/nx-X11/lib/Xaw/Sme.c
new file mode 100644
index 000000000..a4af577d8
--- /dev/null
+++ b/nx-X11/lib/Xaw/Sme.c
@@ -0,0 +1,272 @@
+/* $Xorg: Sme.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+/* $XFree86: xc/lib/Xaw/Sme.c,v 1.6 2001/01/17 19:42:31 dawes Exp $ */
+
+/*
+ * Date: September 26, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xaw/SmeP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+/*
+ * Class Methods
+ */
+static void Highlight(Widget);
+static void Notify(Widget);
+static void Unhighlight(Widget);
+static void XawSmeClassPartInitialize(WidgetClass);
+static void XawSmeInitialize(Widget, Widget, ArgList, Cardinal*);
+static XtGeometryResult XawSmeQueryGeometry(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(SmeRec, sme.field)
+static XtResource resources[] = {
+ {
+ XtNcallback,
+ XtCCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(callbacks),
+ XtRCallback,
+ NULL
+ },
+ {
+ XtNinternational,
+ XtCInternational,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(international),
+ XtRImmediate,
+ (XtPointer)False
+ },
+};
+#undef offset
+
+#define Superclass (&rectObjClassRec)
+SmeClassRec smeClassRec = {
+ /* rectangle */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "Sme", /* class_name */
+ sizeof(SmeRec), /* widget_size */
+ XawInitializeWidgetSet, /* class_initialize */
+ XawSmeClassPartInitialize, /* class_part_initialize */
+ False, /* class_initialized */
+ XawSmeInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ NULL, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ False, /* compress_motion */
+ False, /* compress_exposure */
+ False, /* compress_enterleave */
+ False, /* visible_interest */
+ NULL, /* destroy */
+ NULL, /* resize */
+ NULL, /* expose */
+ NULL, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* intrinsics_version */
+ NULL, /* callback offsets */
+ NULL, /* tm_table */
+ XawSmeQueryGeometry, /* query_geometry */
+ NULL, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* sme */
+ {
+ Highlight, /* highlight */
+ Unhighlight, /* unhighlight */
+ Notify, /* notify */
+ NULL, /* extension */
+ }
+};
+
+WidgetClass smeObjectClass = (WidgetClass)&smeClassRec;
+
+/*
+ * Implementation
+ */
+/*
+ * Function:
+ * XawSmeClassPartInitialize
+ *
+ * Parameters:
+ * cclass - widget classs of this widget
+ *
+ * Description:
+ * Handles inheritance of class functions.
+ */
+static void
+XawSmeClassPartInitialize(WidgetClass cclass)
+{
+ SmeObjectClass m_ent, superC;
+
+ m_ent = (SmeObjectClass)cclass;
+ superC = (SmeObjectClass)m_ent->rect_class.superclass;
+
+ if (m_ent->sme_class.highlight == XtInheritHighlight)
+ m_ent->sme_class.highlight = superC->sme_class.highlight;
+
+ if (m_ent->sme_class.unhighlight == XtInheritUnhighlight)
+ m_ent->sme_class.unhighlight = superC->sme_class.unhighlight;
+
+ if (m_ent->sme_class.notify == XtInheritNotify)
+ m_ent->sme_class.notify = superC->sme_class.notify;
+}
+
+/*
+ * Function:
+ * XawSmeInitialize
+ *
+ * Parameters:
+ * request - widget requested by the argument list
+ * cnew - new widget with both resource and non resource values
+ *
+ * Description:
+ * Initializes the simple menu widget entry
+ */
+/*ARGSUSED*/
+static void
+XawSmeInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ SmeObject entry = (SmeObject)cnew;
+
+ entry->rectangle.border_width = 0;
+}
+
+/*
+ * Function:
+ * Highlight
+ *
+ * Parameters:
+ * w - menu entry
+ *
+ * Description:
+ * Default highlight proceedure for menu entries.
+ */
+/*ARGSUSED*/
+static void
+Highlight(Widget w)
+{
+}
+
+/*
+ * Function:
+ * Unhighlight
+ *
+ * Parameters:
+ * w - menu entry
+ *
+ * Description:
+ * Default unhighlight proceedure for menu entries.
+ */
+/*ARGSUSED*/
+static void
+Unhighlight(Widget w)
+{
+}
+
+/*
+ * Function:
+ * Notify
+ *
+ * Parameters:
+ * w - menu entry
+ *
+ * Description:
+ * Calls the callback proceedures for this entry.
+ */
+static void
+Notify(Widget w)
+{
+ XtCallCallbacks(w, XtNcallback, NULL);
+}
+
+/*
+ * Function:
+ * QueryGeometry
+ *
+ * Parameeters:
+ * w - menu entry object
+ * itended - intended and return geometry info
+ * return_val -
+ *
+ * Description:
+ * Returns the preferred geometry for this widget.
+ *
+ * Returns:
+ * Geometry Result
+ *
+ * Note:
+ * See the Intrinsics manual for details on what this function is for.
+ */
+static XtGeometryResult
+XawSmeQueryGeometry(Widget w, XtWidgetGeometry *intended,
+ XtWidgetGeometry *return_val)
+{
+ SmeObject entry = (SmeObject)w;
+ Dimension width;
+ XtGeometryResult ret_val = XtGeometryYes;
+ XtGeometryMask mode = intended->request_mode;
+
+ width = 1;
+
+ if (((mode & CWWidth) && intended->width != width) || !(mode & CWWidth)) {
+ return_val->request_mode |= CWWidth;
+ return_val->width = width;
+ mode = return_val->request_mode;
+
+ if ((mode & CWWidth) && width == XtWidth(entry))
+ return (XtGeometryNo);
+ return (XtGeometryAlmost);
+ }
+
+ return (ret_val);
+}
diff --git a/nx-X11/lib/Xaw/Sme.h b/nx-X11/lib/Xaw/Sme.h
new file mode 100644
index 000000000..fb87b0073
--- /dev/null
+++ b/nx-X11/lib/Xaw/Sme.h
@@ -0,0 +1,73 @@
+/*
+ * $Xorg: Sme.h,v 1.5 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+/* $XFree86: xc/lib/Xaw/Sme.h,v 1.5 2001/01/17 19:42:31 dawes Exp $ */
+
+/*
+ * This is the public header file for the Athena Sme object.
+ * It is intended to be used with the simple menu widget.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _Sme_h
+#define _Sme_h
+
+#include <X11/Intrinsic.h>
+#include <X11/RectObj.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ callback Callback Pointer NULL
+ destroyCallback Callback Pointer NULL
+ height Height Dimension 0
+ sensitive Sensitive Boolean True
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#ifndef XtCInternational
+#define XtCInternational "International"
+#endif
+
+#ifndef XtNinternational
+#define XtNinternational "international"
+#endif
+
+
+typedef struct _SmeClassRec *SmeObjectClass;
+typedef struct _SmeRec *SmeObject;
+
+extern WidgetClass smeObjectClass;
+
+#endif /* _Sme_h */
diff --git a/nx-X11/lib/Xaw/SmeBSB.c b/nx-X11/lib/Xaw/SmeBSB.c
new file mode 100644
index 000000000..0d77278ab
--- /dev/null
+++ b/nx-X11/lib/Xaw/SmeBSB.c
@@ -0,0 +1,774 @@
+/* $Xorg: SmeBSB.c,v 1.5 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+
+/* $XFree86: xc/lib/Xaw/SmeBSB.c,v 1.11 2001/01/17 19:42:31 dawes Exp $ */
+
+/*
+ * SmeBSB.c - Source code file for BSB Menu Entry object.
+ *
+ * Date: September 26, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xos.h>
+#include <X11/Xmu/Drawing.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xaw/SimpleMenu.h>
+#include <X11/Xaw/SmeBSBP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+#define ONE_HUNDRED 100
+
+/*
+ * Class Methods
+ */
+static void FlipColors(Widget);
+static void XawSmeBSBClassInitialize(void);
+static void XawSmeBSBInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawSmeBSBDestroy(Widget);
+static XtGeometryResult XawSmeBSBQueryGeometry(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawSmeBSBRedisplay(Widget, XEvent*, Region);
+static Boolean XawSmeBSBSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static void CreateGCs(Widget);
+static void GetBitmapInfo(Widget, Bool);
+static void GetDefaultSize(Widget, Dimension*, Dimension*);
+static void DestroyGCs(Widget);
+static void DrawBitmaps(Widget, GC);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(SmeBSBRec, sme_bsb.field)
+static XtResource resources[] = {
+ {
+ XtNlabel,
+ XtCLabel,
+ XtRString,
+ sizeof(String),
+ offset(label),
+ XtRString,
+ NULL
+ },
+ {
+ XtNvertSpace,
+ XtCVertSpace,
+ XtRInt,
+ sizeof(int),
+ offset(vert_space),
+ XtRImmediate,
+ (XtPointer)25
+ },
+ {
+ XtNleftBitmap,
+ XtCLeftBitmap,
+ XtRBitmap,
+ sizeof(Pixmap),
+ offset(left_bitmap),
+ XtRImmediate,
+ (XtPointer)None
+ },
+ {
+ XtNjustify,
+ XtCJustify,
+ XtRJustify,
+ sizeof(XtJustify),
+ offset(justify),
+ XtRImmediate,
+ (XtPointer)XtJustifyLeft
+ },
+ {
+ XtNrightBitmap,
+ XtCRightBitmap,
+ XtRBitmap,
+ sizeof(Pixmap),
+ offset(right_bitmap),
+ XtRImmediate,
+ (XtPointer)None
+ },
+ {
+ XtNleftMargin,
+ XtCHorizontalMargins,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(left_margin),
+ XtRImmediate,
+ (XtPointer)4
+ },
+ {
+ XtNrightMargin,
+ XtCHorizontalMargins,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(right_margin),
+ XtRImmediate,
+ (XtPointer)4
+ },
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(foreground),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XtNfont,
+ XtCFont,
+ XtRFontStruct,
+ sizeof(XFontStruct*),
+ offset(font),
+ XtRString,
+ XtDefaultFont
+ },
+ {
+ XtNfontSet,
+ XtCFontSet,
+ XtRFontSet,
+ sizeof(XFontSet),
+ offset(fontset),
+ XtRString,
+ XtDefaultFontSet
+ },
+#ifndef OLDXAW
+ {
+ XtNmenuName,
+ XtCMenuName,
+ XtRString,
+ sizeof(String),
+ offset(menu_name),
+ XtRImmediate,
+ (XtPointer)NULL
+ },
+#endif
+};
+#undef offset
+
+#define superclass (&smeClassRec)
+SmeBSBClassRec smeBSBClassRec = {
+ /* rectangle */
+ {
+ (WidgetClass)superclass, /* superclass */
+ "SmeBSB", /* class_name */
+ sizeof(SmeBSBRec), /* size */
+ XawSmeBSBClassInitialize, /* class_init */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ XawSmeBSBInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ NULL, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ False, /* compress_motion */
+ False, /* compress_exposure */
+ False, /* compress_enterleave */
+ False, /* visible_interest */
+ XawSmeBSBDestroy, /* destroy */
+ NULL, /* resize */
+ XawSmeBSBRedisplay, /* expose */
+ XawSmeBSBSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* intrinsics version */
+ NULL, /* callback offsets */
+ NULL, /* tm_table */
+ XawSmeBSBQueryGeometry, /* query_geometry */
+ NULL, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* sme */
+ {
+ FlipColors, /* highlight */
+ FlipColors, /* unhighlight */
+ XtInheritNotify, /* notify */
+ NULL, /* extension */
+ },
+ /* sme_bsb */
+ {
+ NULL, /* extension */
+ },
+};
+WidgetClass smeBSBObjectClass = (WidgetClass)&smeBSBClassRec;
+
+/*
+ * Function:
+ * XawSmeBSBClassInitialize
+ *
+ * Description:
+ * Initializes the SmeBSBObject.
+ */
+static void
+XawSmeBSBClassInitialize(void)
+{
+ XawInitializeWidgetSet();
+ XtAddConverter(XtRString, XtRJustify, XmuCvtStringToJustify, NULL, 0);
+ XtSetTypeConverter(XtRJustify, XtRString, XmuCvtJustifyToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+
+/*
+ * Function:
+ * XawSmeBSBInitialize
+ *
+ * Parameters:
+ * request - widget requested by the argument list
+ * cnew - new widget with both resource and non resource values
+ *
+ * Description:
+ * Initializes the simple menu widget entry.
+ */
+/*ARGSUSED*/
+static void
+XawSmeBSBInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ SmeBSBObject entry = (SmeBSBObject)cnew;
+
+ if (!entry->sme_bsb.font) XtError("Aborting: no font found\n");
+
+ if (entry->sme_bsb.label == NULL)
+ entry->sme_bsb.label = XtName(cnew);
+ else
+ entry->sme_bsb.label = XtNewString(entry->sme_bsb.label);
+
+ GetDefaultSize(cnew, &entry->rectangle.width, &entry->rectangle.height);
+ CreateGCs(cnew);
+
+ entry->sme_bsb.left_bitmap_width = entry->sme_bsb.left_bitmap_height = 0;
+ entry->sme_bsb.right_bitmap_width = entry->sme_bsb.right_bitmap_height = 0;
+
+ GetBitmapInfo(cnew, True); /* Left Bitmap Info */
+ GetBitmapInfo(cnew, False); /* Right Bitmap Info */
+}
+
+/*
+ * Function:
+ * XawSmeBSBDestroy
+ *
+ * Parameters:
+ * w - simple menu widget entry
+ */
+static void
+XawSmeBSBDestroy(Widget w)
+{
+ SmeBSBObject entry = (SmeBSBObject)w;
+
+ DestroyGCs(w);
+ if (entry->sme_bsb.label != XtName(w))
+ XtFree(entry->sme_bsb.label);
+}
+
+/*
+ * Function:
+ * XawSmeBSBRedisplay
+ *
+ * Parameters:
+ * w - simple menu widget entry
+ * event - X event that caused this redisplay
+ * region - region the needs to be repainted
+ *
+ * Description:
+ * Redisplays the contents of the widget.
+ */
+/* ARGSUSED */
+static void
+XawSmeBSBRedisplay(Widget w, XEvent *event, Region region)
+{
+ GC gc;
+ SmeBSBObject entry = (SmeBSBObject)w;
+ int font_ascent, font_descent, y_loc;
+ int fontset_ascent, fontset_descent;
+ XFontSetExtents *ext = XExtentsOfFontSet(entry->sme_bsb.fontset);
+
+ font_ascent = font_descent = fontset_ascent = fontset_descent = 0;
+ entry->sme_bsb.set_values_area_cleared = False;
+
+ if (entry->sme.international == True) {
+ fontset_ascent = XawAbs(ext->max_ink_extent.y);
+ fontset_descent = ext->max_ink_extent.height - fontset_ascent;
+ }
+ else {
+ font_ascent = entry->sme_bsb.font->max_bounds.ascent;
+ font_descent = entry->sme_bsb.font->max_bounds.descent;
+ }
+ y_loc = XtY(entry);
+
+ if (XtIsSensitive(w) && XtIsSensitive(XtParent(w))) {
+ if (w == XawSimpleMenuGetActiveEntry(XtParent(w))) {
+ XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
+ entry->sme_bsb.norm_gc, XtX(w), y_loc,
+ XtWidth(entry), XtHeight(entry));
+ gc = entry->sme_bsb.rev_gc;
+ }
+ else
+ gc = entry->sme_bsb.norm_gc;
+ }
+ else
+ gc = entry->sme_bsb.norm_gray_gc;
+
+ if (entry->sme_bsb.label != NULL) {
+ int x_loc = entry->sme_bsb.left_margin;
+ int len = strlen(entry->sme_bsb.label);
+ char *label = entry->sme_bsb.label;
+ int width, t_width;
+
+ switch(entry->sme_bsb.justify) {
+ case XtJustifyCenter:
+ if (entry->sme.international == True) {
+ t_width = XmbTextEscapement(entry->sme_bsb.fontset,label,
+ len);
+ width = XtWidth(entry) - (entry->sme_bsb.left_margin +
+ entry->sme_bsb.right_margin);
+ }
+ else {
+ t_width = XTextWidth(entry->sme_bsb.font, label, len);
+ width = XtWidth(entry) - (entry->sme_bsb.left_margin +
+ entry->sme_bsb.right_margin);
+ }
+ x_loc += (width - t_width) >> 1;
+ break;
+ case XtJustifyRight:
+ if (entry->sme.international == True) {
+ t_width = XmbTextEscapement(entry->sme_bsb.fontset,label,
+ len);
+ x_loc = XtWidth(entry) - (entry->sme_bsb.right_margin +
+ t_width);
+ }
+ else {
+ t_width = XTextWidth(entry->sme_bsb.font, label, len);
+ x_loc = XtWidth(entry) - (entry->sme_bsb.right_margin +
+ t_width);
+ }
+ break;
+ case XtJustifyLeft:
+ /*FALLTHROUGH*/
+ default:
+ break;
+ }
+
+ /* this will center the text in the gadget top-to-bottom */
+ if (entry->sme.international == True) {
+ y_loc += ((XtHeight(entry) -
+ (fontset_ascent + fontset_descent)) >> 1) +
+ fontset_ascent;
+
+ XmbDrawString(XtDisplayOfObject(w), XtWindowOfObject(w),
+ entry->sme_bsb.fontset, gc,
+ XtX(w) + x_loc, y_loc, label, len);
+ }
+ else {
+ y_loc += ((XtHeight(entry) -
+ (font_ascent + font_descent)) >> 1) + font_ascent;
+
+ XDrawString(XtDisplayOfObject(w), XtWindowOfObject(w), gc,
+ XtX(w) + x_loc, y_loc, label, len);
+ }
+ }
+
+ DrawBitmaps(w, gc);
+}
+
+
+/*
+ * Function:
+ * XawSmeBSBSetValues
+ *
+ * Parameters:
+ * current - current state of the widget
+ * request - what was requested
+ * cnew - what the widget will become
+ *
+ * Description:
+ * Relayout the menu when one of the resources is changed.
+ */
+
+/*ARGSUSED*/
+static Boolean
+XawSmeBSBSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ SmeBSBObject entry = (SmeBSBObject)cnew;
+ SmeBSBObject old_entry = (SmeBSBObject)current;
+ Boolean ret_val = False;
+
+ if (old_entry->sme_bsb.label != entry->sme_bsb.label) {
+ if (old_entry->sme_bsb.label != XtName(cnew))
+ XtFree((char *)old_entry->sme_bsb.label);
+
+ if (entry->sme_bsb.label != XtName(cnew))
+ entry->sme_bsb.label = XtNewString(entry->sme_bsb.label);
+
+ ret_val = True;
+ }
+
+ if (entry->rectangle.sensitive != old_entry->rectangle.sensitive)
+ ret_val = True;
+
+ if (entry->sme_bsb.left_bitmap != old_entry->sme_bsb.left_bitmap) {
+ GetBitmapInfo(cnew, True);
+ ret_val = True;
+ }
+
+ if (entry->sme_bsb.right_bitmap != old_entry->sme_bsb.right_bitmap) {
+ GetBitmapInfo(cnew, False);
+ ret_val = True;
+ }
+
+ if ((old_entry->sme_bsb.font != entry->sme_bsb.font
+ && old_entry->sme.international == False)
+ || old_entry->sme_bsb.foreground != entry->sme_bsb.foreground) {
+ DestroyGCs(current);
+ CreateGCs(cnew);
+ ret_val = True;
+ }
+
+ if (old_entry->sme_bsb.fontset != entry->sme_bsb.fontset &&
+ old_entry->sme.international == True)
+ /* DONT changes the GCs, because the fontset is not in them */
+ ret_val = True;
+
+ if (ret_val) {
+ Dimension width, height;
+
+ GetDefaultSize(cnew, &width, &height);
+ entry->sme_bsb.set_values_area_cleared = True;
+ XtMakeResizeRequest(cnew, width, height, NULL, NULL);
+ }
+
+ return (ret_val);
+}
+
+/*
+ * Function:
+ * XawSmeBSBQueryGeometry
+ *
+ * Parameters:
+ * w - menu entry object
+ * itended - intended and return geometry info
+ * return_val - ""
+ *
+ * Returns:
+ * Geometry Result
+ *
+ * Description:
+ * Returns the preferred geometry for this widget.
+ * See the Intrinsics manual for details on what this function is for.
+ */
+static XtGeometryResult
+XawSmeBSBQueryGeometry(Widget w, XtWidgetGeometry *intended,
+ XtWidgetGeometry *return_val)
+{
+ SmeBSBObject entry = (SmeBSBObject)w;
+ Dimension width, height;
+ XtGeometryResult ret_val = XtGeometryYes;
+ XtGeometryMask mode = intended->request_mode;
+
+ GetDefaultSize(w, &width, &height);
+
+ if (((mode & CWWidth) && intended->width != width) || !(mode & CWWidth)) {
+ return_val->request_mode |= CWWidth;
+ return_val->width = width;
+ ret_val = XtGeometryAlmost;
+ }
+
+ if (((mode & CWHeight) && intended->height != height) || !(mode & CWHeight)) {
+ return_val->request_mode |= CWHeight;
+ return_val->height = height;
+ ret_val = XtGeometryAlmost;
+ }
+
+ if (ret_val == XtGeometryAlmost) {
+ mode = return_val->request_mode;
+ if (((mode & CWWidth) && width == XtWidth(entry)) &&
+ ((mode & CWHeight) && height == XtHeight(entry)))
+ return (XtGeometryNo);
+ }
+
+ return (ret_val);
+}
+
+/*
+ * Function:
+ * FlipColors
+ *
+ * Parameters:
+ * w - bsb menu entry widget
+ *
+ * Description:
+ * Invert the colors of the current entry.
+ */
+static void
+FlipColors(Widget w)
+{
+ SmeBSBObject entry = (SmeBSBObject)w;
+
+ if (entry->sme_bsb.set_values_area_cleared)
+ return;
+
+ XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
+ entry->sme_bsb.invert_gc,
+ XtX(w), XtY(entry), XtWidth(entry), XtHeight(entry));
+}
+
+/*
+ * Function:
+ * GetDefaultSize
+ *
+ * Parameters:
+ * w - menu entry widget.
+ * width - default width (return)
+ * height - default height (return)
+ *
+ * Description:
+ * Calculates the Default (preferred) size of this menu entry.
+ */
+static void
+GetDefaultSize(Widget w, Dimension *width, Dimension *height)
+{
+ SmeBSBObject entry = (SmeBSBObject)w;
+
+ if (entry->sme.international == True) {
+ XFontSetExtents *ext = XExtentsOfFontSet(entry->sme_bsb.fontset);
+
+ if (entry->sme_bsb.label == NULL)
+ *width = 0;
+ else
+ *width = XmbTextEscapement(entry->sme_bsb.fontset,
+ entry->sme_bsb.label,
+ strlen(entry->sme_bsb.label));
+ *width += entry->sme_bsb.left_margin + entry->sme_bsb.right_margin;
+ *height = ext->max_ink_extent.height;
+ *height = ((int)*height * (ONE_HUNDRED +
+ entry->sme_bsb.vert_space)) / ONE_HUNDRED;
+ }
+ else {
+ if (entry->sme_bsb.label == NULL)
+ *width = 0;
+ else
+ *width = XTextWidth(entry->sme_bsb.font, entry->sme_bsb.label,
+ strlen(entry->sme_bsb.label));
+
+ *width += entry->sme_bsb.left_margin + entry->sme_bsb.right_margin;
+
+ *height = entry->sme_bsb.font->max_bounds.ascent +
+ entry->sme_bsb.font->max_bounds.descent;
+
+ *height = ((int)*height * (ONE_HUNDRED +
+ entry->sme_bsb.vert_space)) / ONE_HUNDRED;
+ }
+}
+
+/*
+ * Function:
+ * DrawBitmaps
+ *
+ * Parameters:
+ * w - simple menu widget entry
+ * gc - graphics context to use for drawing
+ *
+ * Description:
+ * Draws left and right bitmaps.
+ */
+static void
+DrawBitmaps(Widget w, GC gc)
+{
+ int x_loc, y_loc;
+ SmeBSBObject entry = (SmeBSBObject)w;
+
+ if (entry->sme_bsb.left_bitmap == None &&
+ entry->sme_bsb.right_bitmap == None)
+ return;
+
+ /*
+ * Draw Left Bitmap
+ */
+ if (entry->sme_bsb.left_bitmap != None) {
+ x_loc = ((entry->sme_bsb.left_margin -
+ entry->sme_bsb.left_bitmap_width) >> 1) + XtX(w);
+
+ y_loc = XtY(entry) + ((XtHeight(entry) -
+ entry->sme_bsb.left_bitmap_height) >> 1);
+
+ XCopyPlane(XtDisplayOfObject(w), entry->sme_bsb.left_bitmap,
+ XtWindowOfObject(w), gc, 0, 0,
+ entry->sme_bsb.left_bitmap_width,
+ entry->sme_bsb.left_bitmap_height, x_loc, y_loc, 1);
+ }
+
+ /*
+ * Draw Right Bitmap
+ */
+ if (entry->sme_bsb.right_bitmap != None) {
+ x_loc = XtWidth(entry) - ((entry->sme_bsb.right_margin +
+ entry->sme_bsb.right_bitmap_width) >> 1) +
+ XtX(w);
+ y_loc = XtY(entry) + ((XtHeight(entry) -
+ entry->sme_bsb.right_bitmap_height) >> 1);
+
+ XCopyPlane(XtDisplayOfObject(w), entry->sme_bsb.right_bitmap,
+ XtWindowOfObject(w), gc, 0, 0,
+ entry->sme_bsb.right_bitmap_width,
+ entry->sme_bsb.right_bitmap_height, x_loc, y_loc, 1);
+ }
+}
+
+/*
+ * Function:
+ * GetBitmapInfo
+ *
+ * Parameters:
+ * w - bsb menu entry object
+ * is_left - True: if we are testing left bitmap
+ * False: if we are testing the right bitmap
+ *
+ * Description:
+ * Gets the bitmap information from either of the bitmaps.
+ */
+static void
+GetBitmapInfo(Widget w, Bool is_left)
+{
+ SmeBSBObject entry = (SmeBSBObject)w;
+ unsigned int depth, bw;
+ Window root;
+ int x, y;
+ unsigned int width, height;
+
+ if (is_left) {
+ if (entry->sme_bsb.left_bitmap != None &&
+ XGetGeometry(XtDisplayOfObject(w),
+ entry->sme_bsb.left_bitmap, &root,
+ &x, &y, &width, &height, &bw, &depth)) {
+ entry->sme_bsb.left_bitmap_width = width;
+ entry->sme_bsb.left_bitmap_height = height;
+ }
+ }
+ else if (entry->sme_bsb.right_bitmap != None &&
+ XGetGeometry(XtDisplayOfObject(w),
+ entry->sme_bsb.right_bitmap, &root,
+ &x, &y, &width, &height, &bw, &depth)) {
+ entry->sme_bsb.right_bitmap_width = width;
+ entry->sme_bsb.right_bitmap_height = height;
+ }
+}
+
+/*
+ * Function:
+ * CreateGCs
+ *
+ * Parameters:
+ * w - simple menu widget entry
+ *
+ * Description:
+ * Creates all gc's for the simple menu widget.
+ */
+static void
+CreateGCs(Widget w)
+{
+ SmeBSBObject entry = (SmeBSBObject)w;
+ XGCValues values;
+ XtGCMask mask, mask_i18n;
+
+ values.foreground = XtParent(w)->core.background_pixel;
+ values.background = entry->sme_bsb.foreground;
+ values.font = entry->sme_bsb.font->fid;
+ values.graphics_exposures = False;
+ mask = GCForeground | GCBackground | GCGraphicsExposures | GCFont;
+ mask_i18n = GCForeground | GCBackground | GCGraphicsExposures;
+ if (entry->sme.international == True)
+ entry->sme_bsb.rev_gc = XtAllocateGC(w, 0, mask_i18n, &values, GCFont, 0);
+ else
+ entry->sme_bsb.rev_gc = XtGetGC(w, mask, &values);
+
+ values.foreground = entry->sme_bsb.foreground;
+ values.background = XtParent(w)->core.background_pixel;
+ if (entry->sme.international == True)
+ entry->sme_bsb.norm_gc = XtAllocateGC(w, 0, mask_i18n, &values, GCFont, 0);
+ else
+ entry->sme_bsb.norm_gc = XtGetGC(w, mask, &values);
+
+ values.fill_style = FillTiled;
+ values.tile = XmuCreateStippledPixmap(XtScreenOfObject(w),
+ entry->sme_bsb.foreground,
+ XtParent(w)->core.background_pixel,
+ XtParent(w)->core.depth);
+ values.graphics_exposures = False;
+ mask |= GCTile | GCFillStyle;
+ mask_i18n |= GCTile | GCFillStyle;
+ if (entry->sme.international == True)
+ entry->sme_bsb.norm_gray_gc = XtAllocateGC(w, 0, mask_i18n, &values,
+ GCFont, 0);
+ else
+ entry->sme_bsb.norm_gray_gc = XtGetGC(w, mask, &values);
+
+ values.foreground ^= values.background;
+ values.background = 0;
+ values.function = GXxor;
+ mask = GCForeground | GCBackground | GCGraphicsExposures | GCFunction;
+ entry->sme_bsb.invert_gc = XtGetGC(w, mask, &values);
+}
+
+/*
+ * Function:
+ * DestroyGCs
+ *
+ * Parameters:
+ * w - simple menu widget entry
+ *
+ * Description:
+ * Removes all gc's for the simple menu widget.
+ */
+static void
+DestroyGCs(Widget w)
+{
+ SmeBSBObject entry = (SmeBSBObject)w;
+
+ XtReleaseGC(w, entry->sme_bsb.norm_gc);
+ XtReleaseGC(w, entry->sme_bsb.norm_gray_gc);
+ XtReleaseGC(w, entry->sme_bsb.rev_gc);
+ XtReleaseGC(w, entry->sme_bsb.invert_gc);
+}
diff --git a/nx-X11/lib/Xaw/SmeBSB.h b/nx-X11/lib/Xaw/SmeBSB.h
new file mode 100644
index 000000000..094b558c3
--- /dev/null
+++ b/nx-X11/lib/Xaw/SmeBSB.h
@@ -0,0 +1,98 @@
+/*
+ * $Xorg: SmeBSB.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+/* $XFree86: xc/lib/Xaw/SmeBSB.h,v 1.6 2001/01/17 19:42:31 dawes Exp $ */
+
+/*
+ * SmeBSB.h - Public Header file for SmeBSB object.
+ *
+ * This is the public header file for the Athena BSB Sme object.
+ * It is intended to be used with the simple menu widget. This object
+ * provides bitmap - string - bitmap style entries.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _SmeBSB_h
+#define _SmeBSB_h
+
+#include <X11/Xmu/Converters.h>
+#include <X11/Xaw/Sme.h>
+
+/* BSB Menu Entry Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ callback Callback Callback NULL
+ destroyCallback Callback Pointer NULL
+ font Font XFontStruct * XtDefaultFont
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension 0
+ label Label String Name of entry
+ leftBitmap LeftBitmap Pixmap None
+ leftMargin HorizontalMargins Dimension 4
+ menuName MenuName String NULL
+ rightBitmap RightBitmap Pixmap None
+ rightMargin HorizontalMargins Dimension 4
+ sensitive Sensitive Boolean True
+ vertSpace VertSpace int 25
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+typedef struct _SmeBSBClassRec *SmeBSBObjectClass;
+typedef struct _SmeBSBRec *SmeBSBObject;
+
+extern WidgetClass smeBSBObjectClass;
+
+#define XtNleftBitmap "leftBitmap"
+#define XtNleftMargin "leftMargin"
+#define XtNrightBitmap "rightBitmap"
+#define XtNrightMargin "rightMargin"
+#define XtNvertSpace "vertSpace"
+
+#define XtNmenuName "menuName"
+#define XtCMenuName "MenuName"
+
+#ifndef XtNfontSet
+#define XtNfontSet "fontSet"
+#endif
+
+#ifndef XtCFontSet
+#define XtCFontSet "FontSet"
+#endif
+
+#define XtCLeftBitmap "LeftBitmap"
+#define XtCHorizontalMargins "HorizontalMargins"
+#define XtCRightBitmap "RightBitmap"
+#define XtCVertSpace "VertSpace"
+
+#endif /* _SmeBSB_h */
diff --git a/nx-X11/lib/Xaw/SmeBSBP.h b/nx-X11/lib/Xaw/SmeBSBP.h
new file mode 100644
index 000000000..6b263e7a8
--- /dev/null
+++ b/nx-X11/lib/Xaw/SmeBSBP.h
@@ -0,0 +1,94 @@
+/*
+ * $Xorg: SmeBSBP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 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.
+ *
+ * Author: Chris D. Peterson, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xaw/SmeBSBP.h,v 1.8 2001/01/17 19:42:31 dawes Exp $ */
+
+#ifndef _XawSmeBSBP_h
+#define _XawSmeBSBP_h
+
+/*
+ * Sme Object Private Data
+ */
+#include <X11/Xaw/SmeP.h>
+#include <X11/Xaw/SmeBSB.h>
+
+typedef struct _SmeBSBClassPart {
+ XtPointer extension;
+} SmeBSBClassPart;
+
+/* Full class record declaration */
+typedef struct _SmeBSBClassRec {
+ RectObjClassPart rect_class;
+ SmeClassPart sme_class;
+ SmeBSBClassPart sme_bsb_class;
+} SmeBSBClassRec;
+
+extern SmeBSBClassRec smeBSBClassRec;
+
+/* New fields for the Sme Object record */
+typedef struct {
+ /* resources */
+ String label; /* The entry label */
+ int vert_space; /* extra vert space to leave, as a
+ percentage of the font height of
+ the label */
+ Pixmap left_bitmap, right_bitmap; /* bitmaps to show */
+ Dimension left_margin, right_margin;/* left and right margins */
+ Pixel foreground; /* foreground color */
+ XFontStruct *font; /* The font to show label in */
+ XFontSet fontset; /* or fontset */
+ XtJustify justify; /* Justification for the label. */
+
+ /* private */
+ Boolean set_values_area_cleared; /* do we need to unhighlight? */
+ GC norm_gc; /* noral color gc */
+ GC rev_gc; /* reverse color gc */
+ GC norm_gray_gc; /* Normal color (grayed out) gc */
+ GC invert_gc; /* gc for flipping colors */
+ Dimension left_bitmap_width; /* size of each bitmap */
+ Dimension left_bitmap_height;
+ Dimension right_bitmap_width;
+ Dimension right_bitmap_height;
+
+#ifndef OLDXAW
+ /* new resources */
+ String menu_name; /* name of nested sub menu or NULL */
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} SmeBSBPart;
+
+/*
+ * Full instance record declaration
+ */
+typedef struct _SmeBSBRec {
+ ObjectPart object;
+ RectObjPart rectangle;
+ SmePart sme;
+ SmeBSBPart sme_bsb;
+} SmeBSBRec;
+
+#endif /* _XawSmeBSBP_h */
diff --git a/nx-X11/lib/Xaw/SmeLine.c b/nx-X11/lib/Xaw/SmeLine.c
new file mode 100644
index 000000000..88a6e9ce5
--- /dev/null
+++ b/nx-X11/lib/Xaw/SmeLine.c
@@ -0,0 +1,267 @@
+/* $Xorg: SmeLine.c,v 1.4 2001/02/09 02:03:45 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.
+ *
+ * Author: Chris D. Peterson, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xaw/SmeLine.c,v 1.7 2001/01/17 19:42:31 dawes Exp $ */
+
+/*
+ * Sme.c - Source code for the generic menu entry
+ *
+ * Date: September 26, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xaw/SmeLineP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+/*
+ * Class Methods
+ */
+static void XawSmeLineDestroy(Widget);
+static void XawSmeLineInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawSmeLineRedisplay(Widget, XEvent*, Region);
+static Boolean XawSmeLineSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static void CreateGC(Widget);
+static void DestroyGC(Widget);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(SmeLineRec, sme_line.field)
+static XtResource resources[] = {
+ {
+ XtNlineWidth,
+ XtCLineWidth,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(line_width),
+ XtRImmediate,
+ (XtPointer)1
+ },
+ {
+ XtNstipple,
+ XtCStipple,
+ XtRBitmap,
+ sizeof(Pixmap),
+ offset(stipple),
+ XtRImmediate,
+ (XtPointer)XtUnspecifiedPixmap
+ },
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(foreground),
+ XtRString,
+ XtDefaultForeground
+ },
+};
+#undef offset
+
+#define Superclass (&smeClassRec)
+SmeLineClassRec smeLineClassRec = {
+ /* rectangle */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "SmeLine", /* class_name */
+ sizeof(SmeLineRec), /* widget_size */
+ XawInitializeWidgetSet, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class inited */
+ XawSmeLineInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ NULL, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ False, /* compress_motion */
+ False, /* compress_exposure */
+ False, /* compress_enterleave */
+ False, /* visible_interest */
+ XawSmeLineDestroy, /* destroy */
+ NULL, /* resize */
+ XawSmeLineRedisplay, /* expose */
+ XawSmeLineSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* intrinsics version */
+ NULL, /* callback offsets */
+ NULL, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ NULL, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* sme */
+ {
+ XtInheritHighlight, /* highlight */
+ XtInheritUnhighlight, /* unhighlight */
+ XtInheritNotify, /* notify */
+ NULL, /* extension */
+ },
+ /* sme_line */
+ {
+ NULL, /* extension */
+ }
+};
+
+WidgetClass smeLineObjectClass = (WidgetClass)&smeLineClassRec;
+
+/*
+ * Implementation
+ */
+/*ARGSUSED*/
+static void
+XawSmeLineInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ SmeLineObject entry = (SmeLineObject)cnew;
+
+ if (XtHeight(entry) == 0)
+ XtHeight(entry) = entry->sme_line.line_width;
+
+ CreateGC(cnew);
+}
+
+/*
+ * Function:
+ * CreateGC
+ *
+ * Parameters:
+ * w - Line entry widget
+ *
+ * Description:
+ * Creates the GC for the line entry widget.
+ *
+ * Note:
+ * We can only share the GC if there is no stipple, because
+ * we need to change the stipple origin when drawing
+ */
+static void
+CreateGC(Widget w)
+{
+ SmeLineObject entry = (SmeLineObject)w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCGraphicsExposures | GCLineWidth;
+
+ values.foreground = entry->sme_line.foreground;
+ values.graphics_exposures = False;
+ values.line_width = entry->sme_line.line_width;
+
+ if (entry->sme_line.stipple != XtUnspecifiedPixmap) {
+ values.stipple = entry->sme_line.stipple;
+ values.fill_style = FillStippled;
+ mask |= GCStipple | GCFillStyle;
+
+ entry->sme_line.gc = XCreateGC(XtDisplayOfObject(w),
+ RootWindowOfScreen(XtScreenOfObject(w)),
+ mask, &values);
+ }
+ else
+ entry->sme_line.gc = XtGetGC(w, mask, &values);
+}
+
+static void
+XawSmeLineDestroy(Widget w)
+{
+ DestroyGC(w);
+}
+
+static void
+DestroyGC(Widget w)
+{
+ SmeLineObject entry = (SmeLineObject)w;
+
+ if (entry->sme_line.stipple != XtUnspecifiedPixmap)
+ XFreeGC(XtDisplayOfObject(w), entry->sme_line.gc);
+ else
+ XtReleaseGC(w, entry->sme_line.gc);
+}
+
+/*ARGSUSED*/
+static void
+XawSmeLineRedisplay(Widget w, XEvent *event, Region region)
+{
+ SmeLineObject entry = (SmeLineObject)w;
+ int y = XtY(w) + (((int)XtHeight(w) - entry->sme_line.line_width) >> 1);
+
+ if (entry->sme_line.stipple != XtUnspecifiedPixmap)
+ XSetTSOrigin(XtDisplayOfObject(w), entry->sme_line.gc, 0, y);
+
+ XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
+ entry->sme_line.gc, XtX(w), y,
+ XtWidth(w), entry->sme_line.line_width);
+}
+
+/*
+ * Function:
+ * XawSmeLineSetValues
+ *
+ * Parameters:
+ * current - current state of the widget
+ * request - what was requested
+ * cnew - what the widget will become
+ *
+ * Description:
+ * Relayout the menu when one of the resources is changed.
+ */
+/*ARGSUSED*/
+static Boolean
+XawSmeLineSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ SmeLineObject entry = (SmeLineObject)cnew;
+ SmeLineObject old_entry = (SmeLineObject)current;
+
+ if (entry->sme_line.line_width != old_entry->sme_line.line_width &&
+ entry->sme_line.stipple != old_entry->sme_line.stipple) {
+ DestroyGC(current);
+ CreateGC(cnew);
+ return (True);
+ }
+
+ return (False);
+}
diff --git a/nx-X11/lib/Xaw/SmeLine.h b/nx-X11/lib/Xaw/SmeLine.h
new file mode 100644
index 000000000..7c9d4e41a
--- /dev/null
+++ b/nx-X11/lib/Xaw/SmeLine.h
@@ -0,0 +1,71 @@
+/*
+ * $Xorg: SmeLine.h,v 1.4 2001/02/09 02:03:45 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.
+ *
+ */
+/* $XFree86: xc/lib/Xaw/SmeLine.h,v 1.5 2001/01/17 19:42:31 dawes Exp $ */
+
+/*
+ * This is the public header file for the Athena SmeLine object.
+ * It is intended to be used with the simple menu widget.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _SmeLine_h
+#define _SmeLine_h
+
+#include <X11/Xaw/Sme.h>
+#include <X11/Xmu/Converters.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ callback Callback Pointer NULL
+ destroyCallback Callback Pointer NULL
+ height Height Dimension 0
+ sensitive Sensitive Boolean True
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XtCLineWidth "LineWidth"
+#define XtCStipple "Stipple"
+
+#define XtNlineWidth "lineWidth"
+#define XtNstipple "stipple"
+
+typedef struct _SmeLineClassRec *SmeLineObjectClass;
+typedef struct _SmeLineRec *SmeLineObject;
+
+extern WidgetClass smeLineObjectClass;
+
+#endif /* _SmeLine_h */
diff --git a/nx-X11/lib/Xaw/SmeLineP.h b/nx-X11/lib/Xaw/SmeLineP.h
new file mode 100644
index 000000000..7102d03f9
--- /dev/null
+++ b/nx-X11/lib/Xaw/SmeLineP.h
@@ -0,0 +1,75 @@
+/*
+ * $Xorg: SmeLineP.h,v 1.4 2001/02/09 02:03:46 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.
+ *
+ * Author: Chris D. Peterson, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xaw/SmeLineP.h,v 1.7 2001/01/17 19:42:31 dawes Exp $ */
+
+#ifndef _XawSmeLineP_h
+#define _XawSmeLineP_h
+
+/*
+ * SmeLine Widget Private Data
+ */
+#include <X11/Xaw/SmeP.h>
+#include <X11/Xaw/SmeLine.h>
+
+/* New fields for the SmeLine widget class */
+typedef struct _SmeLineClassPart {
+ XtPointer extension;
+} SmeLineClassPart;
+
+/* Full class record */
+typedef struct _SmeLineClassRec {
+ RectObjClassPart rect_class;
+ SmeClassPart sme_class;
+ SmeLineClassPart sme_line_class;
+} SmeLineClassRec;
+
+extern SmeLineClassRec smeLineClassRec;
+
+/* New fields for the SmeLine widget */
+typedef struct {
+ /* resources */
+ Pixel foreground; /* Foreground color */
+ Pixmap stipple; /* Line Stipple */
+ Dimension line_width; /* Width of the line */
+
+ /* private */
+ GC gc; /* Graphics context for drawing line */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} SmeLinePart;
+
+/* Full instance record */
+typedef struct _SmeLineRec {
+ ObjectPart object;
+ RectObjPart rectangle;
+ SmePart sme;
+ SmeLinePart sme_line;
+} SmeLineRec;
+
+#endif /* _XawSmeLineP_h */
diff --git a/nx-X11/lib/Xaw/SmeP.h b/nx-X11/lib/Xaw/SmeP.h
new file mode 100644
index 000000000..94342fffd
--- /dev/null
+++ b/nx-X11/lib/Xaw/SmeP.h
@@ -0,0 +1,90 @@
+/*
+ * $Xorg: SmeP.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+/* $XFree86: xc/lib/Xaw/SmeP.h,v 1.8 2001/12/14 19:54:43 dawes Exp $ */
+
+/*
+ * This is the private header file for the Athena Sme object.
+ * This object is intended to be used with the simple menu widget.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _XawSmeP_h
+#define _XawSmeP_h
+
+/*
+ * Sme Widget Private Data
+ */
+#include <X11/Xfuncproto.h>
+
+#include <X11/Xaw/Sme.h>
+
+_XFUNCPROTOBEGIN
+
+/* New fields for the Sme widget class */
+typedef struct _SmeClassPart {
+ XtWidgetProc highlight;
+ XtWidgetProc unhighlight;
+ XtWidgetProc notify;
+ XtPointer extension;
+} SmeClassPart;
+
+/* Full class record */
+typedef struct _SmeClassRec {
+ RectObjClassPart rect_class;
+ SmeClassPart sme_class;
+} SmeClassRec;
+
+extern SmeClassRec smeClassRec;
+
+/* New fields for the Sme widget */
+typedef struct {
+ /* resources */
+ XtCallbackList callbacks;
+ Boolean international;
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} SmePart;
+
+/* Full instance record */
+typedef struct _SmeRec {
+ ObjectPart object;
+ RectObjPart rectangle;
+ SmePart sme;
+} SmeRec;
+
+#define XtInheritHighlight ((XtWidgetProc)_XtInherit)
+#define XtInheritUnhighlight XtInheritHighlight
+#define XtInheritNotify XtInheritHighlight
+
+_XFUNCPROTOEND
+
+#endif /* _XawSmeP_h */
diff --git a/nx-X11/lib/Xaw/StripCharP.h b/nx-X11/lib/Xaw/StripCharP.h
new file mode 100644
index 000000000..50ed74c98
--- /dev/null
+++ b/nx-X11/lib/Xaw/StripCharP.h
@@ -0,0 +1,110 @@
+/*
+* $Xorg: StripCharP.h,v 1.4 2001/02/09 02:03:46 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/StripCharP.h,v 1.7 2001/01/17 19:42:32 dawes Exp $ */
+
+#ifndef _XawStripChartP_h
+#define _XawStripChartP_h
+
+#include <X11/Xaw/StripChart.h>
+#include <X11/Xaw/SimpleP.h>
+
+#define NO_GCS 0
+#define FOREGROUND (1 << 0)
+#define HIGHLIGHT (1 << 1)
+#define ALL_GCS (FOREGROUND | HIGHLIGHT)
+
+/* new fields for the stripChart widget */
+typedef struct {
+ /* resources */
+ Pixel fgpixel; /* color index for graph */
+ Pixel hipixel; /* color index for lines */
+ GC fgGC; /* graphics context for fgpixel */
+ GC hiGC; /* graphics context for hipixel */
+
+ /* private */
+ int update; /* update frequence */
+ int scale; /* scale factor */
+ int min_scale; /* smallest scale factor */
+ int interval; /* data point interval */
+ XPoint *points; /* Poly point for repairing graph lines */
+ double max_value; /* Max Value in window */
+ double valuedata[2048]; /* record of data points */
+ XtIntervalId interval_id;
+ XtCallbackList get_value; /* proc to call to fetch load pt */
+ int jump_val; /* Amount to jump on each scroll */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} StripChartPart;
+
+/* instance record declaration */
+typedef struct _StripChartRec {
+ CorePart core;
+ SimplePart simple;
+ StripChartPart strip_chart;
+} StripChartRec;
+
+/* new fields for the StripChart widget class record */
+typedef struct {
+ XtPointer extension;
+} StripChartClassPart;
+
+/* class record declaration */
+typedef struct _StripChartClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ StripChartClassPart strip_chart_class;
+} StripChartClassRec;
+
+extern StripChartClassRec stripChartClassRec;
+
+#endif /* _XawStripChartP_h */
diff --git a/nx-X11/lib/Xaw/StripChart.c b/nx-X11/lib/Xaw/StripChart.c
new file mode 100644
index 000000000..ada85f172
--- /dev/null
+++ b/nx-X11/lib/Xaw/StripChart.c
@@ -0,0 +1,579 @@
+/* $Xorg: StripChart.c,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/StripChart.c,v 1.7 2001/01/17 19:42:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xaw/StripCharP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+#define MS_PER_SEC 1000
+
+/*
+ * Class Methods
+ */
+static void XawStripChartInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawStripChartDestroy(Widget);
+static void XawStripChartRedisplay(Widget, XEvent*, Region);
+static void XawStripChartResize(Widget);
+static Boolean XawStripChartSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static void CreateGC(StripChartWidget, unsigned int);
+static void DestroyGC(StripChartWidget, unsigned int);
+static void draw_it(XtPointer, XtIntervalId*);
+static void MoveChart(StripChartWidget, Bool);
+static int repaint_window(StripChartWidget, int, int);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(StripChartRec, field)
+static XtResource resources[] = {
+ {
+ XtNwidth,
+ XtCWidth,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(core.width),
+ XtRImmediate,
+ (XtPointer)
+ 120
+ },
+ {
+ XtNheight,
+ XtCHeight,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(core.height),
+ XtRImmediate,
+ (XtPointer)120
+ },
+ {
+ XtNupdate,
+ XtCInterval,
+ XtRInt,
+ sizeof(int),
+ offset(strip_chart.update),
+ XtRImmediate,
+ (XtPointer)10
+ },
+ {
+ XtNminScale,
+ XtCScale,
+ XtRInt,
+ sizeof(int),
+ offset(strip_chart.min_scale),
+ XtRImmediate,
+ (XtPointer)1
+ },
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(strip_chart.fgpixel),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XtNhighlight,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(strip_chart.hipixel),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XtNgetValue,
+ XtCCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(strip_chart.get_value),
+ XtRImmediate,
+ NULL
+ },
+ {
+ XtNjumpScroll,
+ XtCJumpScroll,
+ XtRInt,
+ sizeof(int),
+ offset(strip_chart.jump_val),
+ XtRImmediate,
+ (XtPointer)DEFAULT_JUMP
+ },
+};
+#undef offset
+
+StripChartClassRec stripChartClassRec = {
+ /* core */
+ {
+ (WidgetClass)&simpleClassRec, /* superclass */
+ "StripChart", /* class_name */
+ sizeof(StripChartRec), /* widget_size */
+ XawInitializeWidgetSet, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ XawStripChartInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ XtExposeCompressMultiple /* compress_exposure */
+ | XtExposeGraphicsExposeMerged,
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ XawStripChartDestroy, /* destroy */
+ XawStripChartResize, /* resize */
+ XawStripChartRedisplay, /* expose */
+ XawStripChartSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ NULL, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* simple */
+ {
+ XtInheritChangeSensitive, /* change_sensitive */
+ }
+};
+
+WidgetClass stripChartWidgetClass = (WidgetClass)&stripChartClassRec;
+
+/*
+ * Implementation
+ */
+/*
+ * Function:
+ * CreateGC
+ *
+ * Parameters:
+ * w - strip chart widget
+ * which - GC's to create
+ *
+ * Description:
+ * Creates the GC's
+ */
+static void
+CreateGC(StripChartWidget w, unsigned int which)
+{
+ XGCValues myXGCV;
+
+ if (which & FOREGROUND) {
+ myXGCV.foreground = w->strip_chart.fgpixel;
+ w->strip_chart.fgGC = XtGetGC((Widget)w, GCForeground, &myXGCV);
+ }
+
+ if (which & HIGHLIGHT) {
+ myXGCV.foreground = w->strip_chart.hipixel;
+ w->strip_chart.hiGC = XtGetGC((Widget)w, GCForeground, &myXGCV);
+ }
+}
+
+/*
+ * Function:
+ * DestroyGC
+ *
+ * Arguments:
+ * w - strip chart widget
+ * which - which GC's to destroy
+ *
+ * Description:
+ * Destroys the GC's
+ */
+static void
+DestroyGC(StripChartWidget w, unsigned int which)
+{
+ if (which & FOREGROUND)
+ XtReleaseGC((Widget)w, w->strip_chart.fgGC);
+
+ if (which & HIGHLIGHT)
+ XtReleaseGC((Widget)w, w->strip_chart.hiGC);
+}
+
+/*ARGSUSED*/
+static void
+XawStripChartInitialize(Widget greq, Widget gnew,
+ ArgList args, Cardinal *num_args)
+{
+ StripChartWidget w = (StripChartWidget)gnew;
+
+ if (w->strip_chart.update > 0)
+ w->strip_chart.interval_id =
+ XtAppAddTimeOut(XtWidgetToApplicationContext(gnew),
+ w->strip_chart.update * MS_PER_SEC,
+ draw_it, (XtPointer)gnew);
+ CreateGC(w, ALL_GCS);
+
+ w->strip_chart.scale = w->strip_chart.min_scale;
+ w->strip_chart.interval = 0;
+ w->strip_chart.max_value = 0.0;
+ w->strip_chart.points = NULL;
+ XawStripChartResize(gnew);
+}
+
+static void
+XawStripChartDestroy(Widget gw)
+{
+ StripChartWidget w = (StripChartWidget)gw;
+
+ if (w->strip_chart.update > 0)
+ XtRemoveTimeOut(w->strip_chart.interval_id);
+ if (w->strip_chart.points)
+ XtFree((char *)w->strip_chart.points);
+ DestroyGC(w, ALL_GCS);
+}
+
+/*
+ * NOTE: This function really needs to recieve graphics exposure
+ * events, but since this is not easily supported until R4 I am
+ * going to hold off until then.
+ */
+/*ARGSUSED*/
+static void
+XawStripChartRedisplay(Widget w, XEvent *event, Region region)
+{
+ if (event->type == GraphicsExpose)
+ (void)repaint_window((StripChartWidget)w, event->xgraphicsexpose.x,
+ event->xgraphicsexpose.width);
+ else
+ (void)repaint_window((StripChartWidget)w, event->xexpose.x,
+ event->xexpose.width);
+}
+
+/*ARGSUSED*/
+static void
+draw_it(XtPointer client_data, XtIntervalId *id)
+{
+ StripChartWidget w = (StripChartWidget)client_data;
+ double value;
+
+ if (w->strip_chart.update > 0)
+ w->strip_chart.interval_id =
+ XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)w),
+ w->strip_chart.update * MS_PER_SEC,draw_it,
+ client_data);
+
+ if (w->strip_chart.interval >= XtWidth(w))
+ MoveChart((StripChartWidget)w, True);
+
+ /* Get the value, stash the point and draw corresponding line */
+ if (w->strip_chart.get_value == NULL)
+ return;
+
+ XtCallCallbacks((Widget)w, XtNgetValue, (XtPointer)&value);
+
+ /*
+ * Keep w->strip_chart.max_value up to date, and if this data
+ * point is off the graph, change the scale to make it fit
+ */
+ if (value > w->strip_chart.max_value) {
+ w->strip_chart.max_value = value;
+ if (XtIsRealized((Widget)w) &&
+ w->strip_chart.max_value > w->strip_chart.scale) {
+ XClearWindow(XtDisplay(w), XtWindow(w));
+ w->strip_chart.interval = repaint_window(w, 0, XtWidth(w));
+ }
+ }
+
+ w->strip_chart.valuedata[w->strip_chart.interval] = value;
+ if (XtIsRealized((Widget)w)) {
+ int y = (int)(XtHeight(w) - XtHeight(w) * value
+ / w->strip_chart.scale);
+
+ XFillRectangle(XtDisplay(w), XtWindow(w), w->strip_chart.fgGC,
+ w->strip_chart.interval, y,
+ 1, XtHeight(w) - y);
+
+ /*
+ * Fill in the graph lines we just painted over
+ */
+ if (w->strip_chart.points != NULL) {
+ w->strip_chart.points[0].x = w->strip_chart.interval;
+ XDrawPoints(XtDisplay(w), XtWindow(w), w->strip_chart.hiGC,
+ w->strip_chart.points, w->strip_chart.scale - 1,
+ CoordModePrevious);
+ }
+
+ XFlush(XtDisplay(w)); /* Flush output buffers */
+ }
+ w->strip_chart.interval++; /* Next point */
+}
+
+/* Blts data according to current size, then redraws the stripChart window
+ * Next represents the number of valid points in data. Returns the (possibly)
+ * adjusted value of next. If next is 0, this routine draws an empty window
+ * (scale - 1 lines for graph). If next is less than the current window width,
+ * the returned value is identical to the initial value of next and data is
+ * unchanged. Otherwise keeps half a window's worth of data. If data is
+ * changed, then w->strip_chart.max_value is updated to reflect the
+ * largest data point
+ */
+static int
+repaint_window(StripChartWidget w, int left, int width)
+{
+ int i, j;
+ int next = w->strip_chart.interval;
+ int scale = w->strip_chart.scale;
+ int scalewidth = 0;
+
+ /* Compute the minimum scale required to graph the data, but don't go
+ lower than min_scale */
+ if (w->strip_chart.interval != 0 || scale <= w->strip_chart.max_value)
+ scale = w->strip_chart.max_value + 1;
+ if (scale < w->strip_chart.min_scale)
+ scale = w->strip_chart.min_scale;
+
+ if (scale != w->strip_chart.scale) {
+ w->strip_chart.scale = scale;
+ left = 0;
+ width = next;
+ scalewidth = XtWidth(w);
+
+ XawStripChartResize((Widget)w);
+
+ if (XtIsRealized((Widget)w))
+ XClearWindow(XtDisplay(w), XtWindow(w));
+ }
+
+ if (XtIsRealized((Widget)w)) {
+ Display *dpy = XtDisplay(w);
+ Window win = XtWindow(w);
+
+ width += left - 1;
+ if (!scalewidth)
+ scalewidth = width;
+
+ if (next < ++width)
+ width = next;
+
+ /* Draw data point lines */
+ for (i = left; i < width; i++) {
+ int y = XtHeight(w) - (XtHeight(w) * w->strip_chart.valuedata[i])
+ / w->strip_chart.scale;
+
+ XFillRectangle(dpy, win, w->strip_chart.fgGC,
+ i, y, 1, XtHeight(w) - y);
+ }
+
+ /* Draw graph reference lines */
+ for (i = 1; i < w->strip_chart.scale; i++) {
+ j = i * ((int)XtHeight(w) / w->strip_chart.scale);
+ XDrawLine(dpy, win, w->strip_chart.hiGC, left, j, scalewidth, j);
+ }
+ }
+ return (next);
+}
+
+/*
+ * Function:
+ * MoveChart
+ *
+ * Parameters:
+ * w - chart widget
+ * blit - blit the bits?
+ *
+ * Description:
+ * Moves the chart over when it would run off the end.
+ */
+static void
+MoveChart(StripChartWidget w, Bool blit)
+{
+ double old_max;
+ int left, i, j;
+ int next = w->strip_chart.interval;
+
+ if (!XtIsRealized((Widget)w))
+ return;
+
+ if (w->strip_chart.jump_val < 0)
+ w->strip_chart.jump_val = DEFAULT_JUMP;
+ if (w->strip_chart.jump_val == DEFAULT_JUMP)
+ j = XtWidth(w) >> 1;
+ else {
+ j = (int)XtWidth(w) - w->strip_chart.jump_val;
+ if (j < 0)
+ j = 0;
+ }
+
+ (void)memmove((char *)w->strip_chart.valuedata,
+ (char *)(w->strip_chart.valuedata + next - j),
+ j * sizeof(double));
+ next = w->strip_chart.interval = j;
+
+ /*
+ * Since we just lost some data, recompute the
+ * w->strip_chart.max_value
+ */
+ old_max = w->strip_chart.max_value;
+ w->strip_chart.max_value = 0.0;
+ for (i = 0; i < next; i++) {
+ if (w->strip_chart.valuedata[i] > w->strip_chart.max_value)
+ w->strip_chart.max_value = w->strip_chart.valuedata[i];
+ }
+
+ if (!blit)
+ return;
+
+ if (old_max != w->strip_chart.max_value) {
+ XClearWindow(XtDisplay(w), XtWindow(w));
+ repaint_window(w, 0, XtWidth(w));
+ return;
+ }
+
+ XCopyArea(XtDisplay((Widget)w), XtWindow((Widget)w), XtWindow((Widget)w),
+ w->strip_chart.hiGC, (int)XtWidth(w) - j, 0, j, XtHeight(w), 0, 0);
+
+ XClearArea(XtDisplay((Widget)w), XtWindow((Widget)w),
+ j, 0, XtWidth(w) - j, XtHeight(w), False);
+
+ /* Draw graph reference lines */
+ left = j;
+ for (i = 1; i < w->strip_chart.scale; i++) {
+ j = i * (XtHeight(w) / w->strip_chart.scale);
+ XDrawLine(XtDisplay((Widget)w), XtWindow((Widget)w),
+ w->strip_chart.hiGC, left, j, XtWidth(w), j);
+ }
+}
+
+/*ARGSUSED*/
+static Boolean
+XawStripChartSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ StripChartWidget old = (StripChartWidget)current;
+ StripChartWidget w = (StripChartWidget)cnew;
+ Bool ret_val = False;
+ unsigned int new_gc = NO_GCS;
+
+ if (w->strip_chart.update != old->strip_chart.update) {
+ if (old->strip_chart.update > 0)
+ XtRemoveTimeOut(old->strip_chart.interval_id);
+ if (w->strip_chart.update > 0)
+ w->strip_chart.interval_id =
+ XtAppAddTimeOut(XtWidgetToApplicationContext(cnew),
+ w->strip_chart.update * MS_PER_SEC,
+ draw_it, (XtPointer)w);
+ }
+
+ if (w->strip_chart.min_scale > w->strip_chart.max_value + 1)
+ ret_val = True;
+
+ if (w->strip_chart.fgpixel != old->strip_chart.fgpixel) {
+ new_gc |= FOREGROUND;
+ ret_val = True;
+ }
+
+ if (w->strip_chart.hipixel != old->strip_chart.hipixel) {
+ new_gc |= HIGHLIGHT;
+ ret_val = True;
+ }
+
+ DestroyGC(old, new_gc);
+ CreateGC(w, new_gc);
+
+ return (ret_val);
+}
+
+/*
+ * Function:
+ * XawStripChartResize
+ *
+ * Parameters:
+ * w - StripChart widget
+ *
+ * Description:
+ * Sets up the polypoint that will be used to draw in the graph lines.
+ */
+static void
+XawStripChartResize(Widget widget)
+{
+ StripChartWidget w = (StripChartWidget)widget;
+ XPoint *points;
+ Cardinal size;
+ int i;
+
+ if (w->strip_chart.scale <= 1) {
+ XtFree((char *)w->strip_chart.points);
+ w->strip_chart.points = NULL;
+ return;
+ }
+
+ size = sizeof(XPoint) * (w->strip_chart.scale - 1);
+
+ points = (XPoint *)XtRealloc((XtPointer)w->strip_chart.points, size);
+ w->strip_chart.points = points;
+
+ /* Draw graph reference lines into clip mask */
+
+ for (i = 1; i < w->strip_chart.scale; i++) {
+ points[i - 1].x = 0;
+ points[i - 1].y = XtHeight(w) / w->strip_chart.scale;
+ }
+}
diff --git a/nx-X11/lib/Xaw/StripChart.h b/nx-X11/lib/Xaw/StripChart.h
new file mode 100644
index 000000000..b6c6f212a
--- /dev/null
+++ b/nx-X11/lib/Xaw/StripChart.h
@@ -0,0 +1,119 @@
+/* $Xorg: StripChart.h,v 1.5 2001/02/09 02:03:46 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/StripChart.h,v 1.5 2001/01/17 19:42:32 dawes Exp $ */
+
+#ifndef _XawStripChart_h
+#define _XawStripChart_h
+
+#include <X11/Intrinsic.h>
+
+/***********************************************************************
+ *
+ * StripChart Widget
+ *
+ ***********************************************************************/
+
+/* StripChart resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ accelerators Accelerators AcceleratorTable NULL
+ ancestorSensitive AncestorSensitive Boolean True
+ background Background Pixel XtDefaultBackground
+ backgroundPixmap Pixmap Pixmap XtUnspecifiedPixmap
+ borderColor BorderColor Pixel XtDefaultForeground
+ borderPixmap Pixmap Pixmap XtUnspecifiedPixmap
+ borderWidth BorderWidth Dimension 1
+ colormap Colormap Colormap parent's colormap
+ cursor Cursor Cursor None
+ cursorName Cursor String NULL
+ depth Depth int parent's depth
+ destroyCallback Callback XtCallbackList NULL
+ foreground Foreground Pixel XtDefaultForeground
+ getValue Callback XtCallbackList NULL
+ height Height Dimension 120
+ highlight Foreground Pixel XtDefaultForeground
+ insensitiveBorder Insensitive Pixmap GreyPixmap
+ jumpScroll JumpScroll int 1/2 width
+ mappedWhenManaged MappedWhenManaged Boolean True
+ minScale Scale int 1
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ screen Screen Screen parent's screen
+ sensitive Sensitive Boolean True
+ translations Translations TranslationTable NULL
+ update Interval int 10 (seconds)
+ width Width Dimension 120
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define DEFAULT_JUMP -1
+
+#ifndef _XtStringDefs_h_
+#define XtNhighlight "highlight"
+#define XtNupdate "update"
+#endif
+
+#define XtCJumpScroll "JumpScroll"
+#define XtCScale "Scale"
+
+#define XtNgetValue "getValue"
+#define XtNjumpScroll "jumpScroll"
+#define XtNminScale "minScale"
+#define XtNscale "scale"
+#define XtNvmunix "vmunix"
+
+typedef struct _StripChartRec *StripChartWidget;
+typedef struct _StripChartClassRec *StripChartWidgetClass;
+
+extern WidgetClass stripChartWidgetClass;
+
+#endif /* _XawStripChart_h */
diff --git a/nx-X11/lib/Xaw/Template.c b/nx-X11/lib/Xaw/Template.c
new file mode 100644
index 000000000..9c3763b52
--- /dev/null
+++ b/nx-X11/lib/Xaw/Template.c
@@ -0,0 +1,198 @@
+/* $Xorg: Template.c,v 1.4 2001/02/09 02:03:46 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.
+
+*/
+/* $XFree86: xc/lib/Xaw/Template.c,v 1.8 2001/08/01 00:44:39 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/TemplateP.h>
+
+/*
+ * Class Methods
+ */
+static void TemplateInitialize(Widget, Widget, ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static Bool TemplateFunction(TemplateWidget, int, int, Bool);
+
+/*
+ * Actions
+ */
+static void TemplateAction(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(TemplateRec, template.field)
+static XtResource resources[] = {
+/*{
+ name,
+ class,
+ type,
+ size,
+ offset,
+ default_type,
+ default_addr
+ },*/
+ {
+ XtNtemplateResource,
+ XtCTemplateResource,
+ XtRTemplateResource,
+ sizeof(char*),
+ offset(resource),
+ XtRString,
+ (XtPointer)"default"
+ },
+};
+#undef offset
+
+static XtActionsRec actions[] =
+{
+ /*{name, procedure},*/
+ {"template", TemplateAction},
+};
+
+static char translations[] =
+"<Key>:" "template()\n"
+;
+
+#define Superclass (&widgetClassRec)
+TemplateClassRec templateClassRec = {
+ /* core */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "Template", /* class_name */
+ sizeof(TemplateRec), /* widget_size */
+ NULL, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ TemplateInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ actions, /* actions */
+ XtNumber(actions), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ NULL, /* destroy */
+ NULL, /* resize */
+ NULL, /* expose */
+ NULL, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ translations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* template */
+ {
+ NULL, /* extension */
+ }
+};
+
+WidgetClass templateWidgetClass = (WidgetClass)&templateClassRec;
+
+/*
+ * Implementation
+ */
+/*
+ * Function:
+ * TemplateInitialize
+ *
+ * Parameters:
+ * request - requested widget
+ * w - the widget
+ * args - arguments
+ * num_args - number of arguments
+ *
+ * Description:
+ * Initializes widget instance.
+ */
+/*ARGSUSED*/
+static void
+TemplateInitialize(Widget request, Widget w, ArgList args, Cardinal *num_args)
+{
+ TemplateWidget tw = (TemplateWidget)w;
+
+ tw->template.private = NULL;
+}
+
+/*
+ * Function:
+ * TemplateFunction
+ *
+ * Parameters:
+ * tw - template widget
+ * x - x coordinate
+ * y - y coordinate
+ * force - force action
+ *
+ * Description:
+ * This function does nothing.
+ *
+ * Return:
+ * Parameter force
+ */
+/*ARGSUSED*/
+static Bool
+TemplateFunction(TemplateWidget tw, int x, int y, Bool force)
+{
+ return (force);
+}
+
+/*
+ * Function:
+ * TemplateAction
+ *
+ * Parameters:
+ * w - template widget
+ * event - event that caused this action
+ * params - parameters
+ * num_params - number of parameters
+ *
+ * Description:
+ * This function does nothing.
+ */
+/*ARGSUSED*/
+static void
+TemplateAction(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+}
diff --git a/nx-X11/lib/Xaw/Template.h b/nx-X11/lib/Xaw/Template.h
new file mode 100644
index 000000000..5ec0974cf
--- /dev/null
+++ b/nx-X11/lib/Xaw/Template.h
@@ -0,0 +1,70 @@
+/* $Xorg: Template.h,v 1.5 2001/02/09 02:03:46 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.
+
+*/
+/* $XFree86: xc/lib/Xaw/Template.h,v 1.5 2001/01/17 19:42:32 dawes Exp $ */
+
+#ifndef _Template_h
+#define _Template_h
+
+#include <X11/Intrinsic.h>
+
+/****************************************************************
+ *
+ * Template widget
+ *
+ ****************************************************************/
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ destroyCallback Callback Pointer NULL
+ height Height Dimension 0
+ mappedWhenManaged MappedWhenManaged Boolean True
+ sensitive Sensitive Boolean True
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+/* define any special resource names here that are not in <X11/StringDefs.h> */
+#define XtNtemplateResource "templateResource"
+
+#define XtCTemplateResource "TemplateResource"
+
+/* declare specific TemplateWidget class and instance datatypes */
+typedef struct _TemplateClassRec *TemplateWidgetClass;
+typedef struct _TemplateRec *TemplateWidget;
+
+/* declare the class constant */
+extern WidgetClass templateWidgetClass;
+
+#endif /* _Template_h */
diff --git a/nx-X11/lib/Xaw/TemplateP.h b/nx-X11/lib/Xaw/TemplateP.h
new file mode 100644
index 000000000..f3e3d67d5
--- /dev/null
+++ b/nx-X11/lib/Xaw/TemplateP.h
@@ -0,0 +1,68 @@
+/* $Xorg: TemplateP.h,v 1.5 2001/02/09 02:03:46 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.
+
+*/
+/* $XFree86: xc/lib/Xaw/TemplateP.h,v 1.6 2001/01/17 19:42:32 dawes Exp $ */
+
+#ifndef _TemplateP_h
+#define _TemplateP_h
+
+#include <X11/Xaw/Template.h>
+
+/* include superclass private header file */
+#include <X11/CoreP.h>
+
+/* define unique representation types not found in <X11/StringDefs.h> */
+#define XtRTemplateResource "TemplateResource"
+
+typedef struct {
+ XtPointer extension;
+} TemplateClassPart;
+
+typedef struct _TemplateClassRec {
+ CoreClassPart core_class;
+ TemplateClassPart template_class;
+} TemplateClassRec;
+
+extern TemplateClassRec templateClassRec;
+
+typedef struct {
+ /* resources */
+ char* resource;
+ /* private */
+ char *private;
+} TemplatePart;
+
+typedef struct _TemplateRec {
+ CorePart core;
+#if defined(__cplusplus) || defined(c_plusplus)
+ TemplatePart c_template;
+#else
+ TemplatePart template;
+#endif
+} TemplateRec;
+
+#endif /* _TemplateP_h */
diff --git a/nx-X11/lib/Xaw/Text.c b/nx-X11/lib/Xaw/Text.c
new file mode 100644
index 000000000..7d7dd2e61
--- /dev/null
+++ b/nx-X11/lib/Xaw/Text.c
@@ -0,0 +1,4164 @@
+/* $Xorg: Text.c,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+
+/*
+ * Copyright (c) 1998 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+
+/* $XFree86: xc/lib/Xaw/Text.c,v 3.53tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+#include <X11/Xatom.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xmu/Xmu.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xaw/MultiSinkP.h>
+#include <X11/Xaw/TextP.h>
+#include <X11/Xaw/TextSrcP.h>
+#include <X11/Xaw/TextSinkP.h>
+#include <X11/Xaw/Scrollbar.h>
+#include <X11/Xaw/XawImP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+#include "XawI18n.h"
+
+#ifndef MAX_LEN_CT
+#define MAX_LEN_CT 6 /* for sequence: ESC $ ( A \xx \xx */
+#endif
+
+unsigned long FMT8BIT = 0L;
+unsigned long XawFmt8Bit = 0L;
+unsigned long XawFmtWide = 0L;
+
+#define SinkClearToBG _XawTextSinkClearToBackground
+
+#define SrcScan XawTextSourceScan
+#define SrcRead XawTextSourceRead
+#define SrcReplace XawTextSourceReplace
+#define SrcSearch XawTextSourceSearch
+#define SrcCvtSel XawTextSourceConvertSelection
+#define SrcSetSelection XawTextSourceSetSelection
+
+#define MULTI_CLICK_TIME 500L
+
+#define SRC_CHANGE_NONE 0
+#define SRC_CHANGE_AFTER 1
+#define SRC_CHANGE_BEFORE 2
+#define SRC_CHANGE_OVERLAP 3
+
+#define Superclass (&simpleClassRec)
+
+/*
+ * Compute a the maximum length of a cut buffer that we can pass at any
+ * time. The 64 allows for the overhead of the Change Property request.
+ */
+#define MAX_CUT_LEN(dpy) (XMaxRequestSize(dpy) - 64)
+
+#define ClearWindow(ctx) \
+ _XawTextNeedsUpdating((ctx), \
+ (ctx)->text.lt.top, \
+ (ctx)->text.lt.info[ctx->text.lt.lines].position)
+
+/*
+ * Class Methods
+ */
+static void XawTextClassInitialize(void);
+static void XawTextInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawTextRealize(Widget, XtValueMask*, XSetWindowAttributes*);
+static void XawTextDestroy(Widget);
+static void XawTextResize(Widget);
+static void XawTextExpose(Widget, XEvent*, Region);
+static Boolean XawTextSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
+static void XawTextGetValuesHook(Widget, ArgList, Cardinal*);
+static Bool XawTextChangeSensitive(Widget);
+
+/*
+ * Prototypes
+ */
+static XawTextPosition _BuildLineTable(TextWidget, XawTextPosition, int);
+static void _CreateCutBuffers(Display*);
+static Boolean TextConvertSelection(Widget, Atom*, Atom*, Atom*, XtPointer*,
+ unsigned long*, int*);
+static int CountLines(TextWidget, XawTextPosition, XawTextPosition);
+static void CreateHScrollBar(TextWidget);
+static void CreateVScrollBar(TextWidget);
+static void CvtStringToScrollMode(XrmValuePtr, Cardinal*,
+ XrmValuePtr, XrmValuePtr);
+static Boolean CvtScrollModeToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static void CvtStringToWrapMode(XrmValuePtr, Cardinal*,
+ XrmValuePtr, XrmValuePtr);
+static Boolean CvtWrapModeToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean CvtStringToJustifyMode(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean CvtJustifyModeToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static void DestroyHScrollBar(TextWidget);
+static void DestroyVScrollBar(TextWidget);
+#ifndef OLDXAW
+static void DisplayText(Widget, XawTextPosition, XawTextPosition);
+#endif
+static void OldDisplayText(Widget, XawTextPosition, XawTextPosition);
+static void DisplayTextWindow(Widget);
+static void DoCopyArea(TextWidget, int, int, unsigned int, unsigned int,
+ int, int);
+static void DoSelection(TextWidget, XawTextPosition, Time, Bool);
+static void ExtendSelection(TextWidget, XawTextPosition, Bool);
+static XawTextPosition FindGoodPosition(TextWidget, XawTextPosition);
+static void FlushUpdate(TextWidget);
+static int GetCutBufferNumber(Atom);
+static int GetMaxTextWidth(TextWidget);
+static unsigned int GetWidestLine(TextWidget);
+static void HScroll(Widget, XtPointer, XtPointer);
+static void HJump(Widget, XtPointer, XtPointer);
+static void InsertCursor(Widget, XawTextInsertState);
+static Bool LineAndXYForPosition(TextWidget, XawTextPosition, int*,
+ int*, int*);
+static int LineForPosition(TextWidget, XawTextPosition);
+static void TextLoseSelection(Widget, Atom*);
+static Bool MatchSelection(Atom, XawTextSelection*);
+static void ModifySelection(TextWidget, XawTextPosition, XawTextPosition);
+static XawTextPosition PositionForXY(TextWidget, int, int);
+static void PositionHScrollBar(TextWidget);
+static void PositionVScrollBar(TextWidget);
+#ifndef OLDXAW
+static int ResolveColumnNumber(TextWidget);
+static int ResolveLineNumber(TextWidget);
+#endif
+static void _SetSelection(TextWidget, XawTextPosition, XawTextPosition,
+ Atom*, Cardinal);
+static void TextSinkResize(Widget);
+static void UpdateTextInRectangle(TextWidget, XRectangle*);
+static void UpdateTextInLine(TextWidget, int, int, int);
+static void VScroll(Widget, XtPointer, XtPointer);
+static void VJump(Widget, XtPointer, XtPointer);
+
+/*
+ * External
+ */
+void _XawTextAlterSelection(TextWidget,
+ XawTextSelectionMode, XawTextSelectionAction,
+ String*, Cardinal*);
+void _XawTextCheckResize(TextWidget);
+void _XawTextClearAndCenterDisplay(TextWidget);
+void _XawTextExecuteUpdate(TextWidget);
+char *_XawTextGetText(TextWidget, XawTextPosition, XawTextPosition);
+void _XawTextPrepareToUpdate(TextWidget);
+int _XawTextReplace(TextWidget, XawTextPosition, XawTextPosition,
+ XawTextBlock*);
+Atom *_XawTextSelectionList(TextWidget, String*, Cardinal);
+void _XawTextSetScrollBars(TextWidget);
+void _XawTextSetSelection(TextWidget, XawTextPosition, XawTextPosition,
+ String*, Cardinal);
+void _XawTextVScroll(TextWidget, int);
+void XawTextScroll(TextWidget, int, int);
+void _XawTextSetSource(Widget, Widget, XawTextPosition, XawTextPosition);
+#ifndef OLDXAW
+void _XawTextSetLineAndColumnNumber(TextWidget, Bool);
+#endif
+void _XawTextSourceChanged(Widget, XawTextPosition, XawTextPosition,
+ XawTextBlock*, int);
+
+/* Not used by other modules, but were extern on previous versions
+ * of the library
+ */
+void _XawTextShowPosition(TextWidget);
+
+/*
+ * From TextAction.c
+ */
+extern void _XawTextZapSelection(TextWidget, XEvent*, Bool);
+
+/*
+ * From TextSrc.c
+ */
+void _XawSourceAddText(Widget, Widget);
+void _XawSourceRemoveText(Widget, Widget, Bool);
+Bool _XawTextSourceNewLineAtEOF(Widget);
+
+/*
+ * From TextSink.c
+ */
+void _XawTextSinkClearToBackground(Widget, int, int, unsigned, unsigned);
+void _XawTextSinkDisplayText(Widget, int, int, XawTextPosition, XawTextPosition,
+ Bool);
+
+/****************************************************************
+ *
+ * Full class record constant
+ *
+ ****************************************************************/
+/*
+ * From TextTr.c
+ */
+extern char _XawDefaultTextTranslations[];
+
+static XawTextSelectType defaultSelectTypes[] = {
+ XawselectPosition, XawselectAlphaNumeric, XawselectWord, XawselectLine,
+ XawselectParagraph, XawselectAll, XawselectNull,
+};
+
+static XPointer defaultSelectTypesPtr = (XPointer)defaultSelectTypes;
+static Dimension defWidth = 100;
+static Dimension defHeight = DEFAULT_TEXT_HEIGHT;
+
+#define offset(field) XtOffsetOf(TextRec, field)
+static XtResource resources[] = {
+ {
+ XtNwidth,
+ XtCWidth,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(core.width),
+ XtRDimension,
+ (XtPointer)&defWidth
+ },
+ {
+ XtNcursor,
+ XtCCursor,
+ XtRCursor,
+ sizeof(Cursor),
+ offset(simple.cursor),
+ XtRString,
+ "xterm"
+ },
+ {
+ XtNheight,
+ XtCHeight,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(core.height),
+ XtRDimension,
+ (XtPointer)&defHeight
+ },
+ {
+ XtNdisplayPosition,
+ XtCTextPosition,
+ XtRInt,
+ sizeof(XawTextPosition),
+ offset(text.lt.top),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNinsertPosition,
+ XtCTextPosition,
+ XtRInt,
+ sizeof(XawTextPosition),
+ offset(text.insertPos),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNleftMargin,
+ XtCMargin,
+ XtRPosition,
+ sizeof(Position),
+ offset(text.r_margin.left),
+ XtRImmediate,
+ (XtPointer)2
+ },
+ {
+ XtNrightMargin,
+ XtCMargin,
+ XtRPosition,
+ sizeof(Position),
+ offset(text.r_margin.right),
+ XtRImmediate,
+ (XtPointer)4
+ },
+ {
+ XtNtopMargin,
+ XtCMargin,
+ XtRPosition,
+ sizeof(Position),
+ offset(text.r_margin.top),
+ XtRImmediate,
+ (XtPointer)2
+ },
+ {
+ XtNbottomMargin,
+ XtCMargin,
+ XtRPosition,
+ sizeof(Position),
+ offset(text.r_margin.bottom),
+ XtRImmediate,
+ (XtPointer)2
+ },
+ {
+ XtNselectTypes,
+ XtCSelectTypes,
+ XtRPointer,
+ sizeof(XawTextSelectType*),
+ offset(text.sarray),
+ XtRPointer,
+ (XtPointer)&defaultSelectTypesPtr
+ },
+ {
+ XtNtextSource,
+ XtCTextSource,
+ XtRWidget,
+ sizeof(Widget),
+ offset(text.source),
+ XtRImmediate,
+ NULL
+ },
+ {
+ XtNtextSink,
+ XtCTextSink,
+ XtRWidget,
+ sizeof(Widget),
+ offset(text.sink),
+ XtRImmediate,
+ NULL
+ },
+ {
+ XtNdisplayCaret,
+ XtCOutput,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(text.display_caret),
+ XtRImmediate,
+ (XtPointer)True
+ },
+ {
+ XtNscrollVertical,
+ XtCScroll,
+ XtRScrollMode,
+ sizeof(XawTextScrollMode),
+ offset(text.scroll_vert),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNscrollHorizontal,
+ XtCScroll,
+ XtRScrollMode,
+ sizeof(XawTextScrollMode),
+ offset(text.scroll_horiz),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNwrap,
+ XtCWrap,
+ XtRWrapMode,
+ sizeof(XawTextWrapMode),
+ offset(text.wrap),
+ XtRImmediate,
+ (XtPointer)XawtextWrapNever
+ },
+ {
+ XtNautoFill,
+ XtCAutoFill,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(text.auto_fill),
+ XtRImmediate,
+ (XtPointer)False
+ },
+#ifndef OLDXAW
+ {
+ XtNpositionCallback,
+ XtCCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(text.position_callbacks),
+ XtRCallback,
+ NULL
+ },
+ {
+ XtNleftColumn,
+ XtCColumn,
+ XtRShort,
+ sizeof(short),
+ offset(text.left_column),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNrightColumn,
+ XtCColumn,
+ XtRShort,
+ sizeof(short),
+ offset(text.right_column),
+ XtRImmediate,
+ (XtPointer)0
+ },
+ {
+ XtNjustifyMode,
+ XtCJustifyMode,
+ XtRJustifyMode,
+ sizeof(XawTextJustifyMode),
+ offset(text.justify),
+ XtRImmediate,
+ (XtPointer)XawjustifyLeft
+ },
+#endif /* OLDXAW */
+};
+#undef offset
+
+#define done(address, type) \
+ { toVal->size = sizeof(type); toVal->addr = (XPointer)address; }
+
+static XrmQuark QWrapNever, QWrapLine, QWrapWord;
+#ifndef notdef
+static XrmQuark QScrollNever, QScrollWhenNeeded, QScrollAlways;
+#endif
+static XrmQuark QJustifyLeft, QJustifyRight, QJustifyCenter, QJustifyFull;
+
+/*ARGSUSED*/
+static void
+CvtStringToScrollMode(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static XawTextScrollMode scrollMode = XawtextScrollNever;
+ XrmQuark q;
+ char name[32];
+
+ XmuNCopyISOLatin1Lowered(name, (char *)fromVal->addr, sizeof(name));
+ q = XrmStringToQuark(name);
+
+ if (q == QScrollNever || q == QScrollWhenNeeded)
+ scrollMode = XawtextScrollNever;
+ else if (q == QScrollAlways)
+ scrollMode = XawtextScrollAlways;
+ else if (strcmp(name, "true") == 0 || strcmp(name, "1") == 0)
+ scrollMode = XawtextScrollAlways;
+ else if (strcmp(name, "false") == 0 || strcmp(name, "0") == 0)
+ scrollMode = XawtextScrollNever;
+ else
+ XtStringConversionWarning((char *)fromVal->addr, XtRScrollMode);
+
+ done(&scrollMode, XawTextScrollMode);
+}
+
+/*ARGSUSED*/
+static Boolean
+CvtScrollModeToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal, XtPointer *data)
+{
+ static char *buffer;
+ Cardinal size;
+
+ switch (*(XawTextScrollMode *)fromVal->addr) {
+ case XawtextScrollNever:
+ case XawtextScrollWhenNeeded:
+ buffer = XtEtextScrollNever;
+ break;
+ case XawtextScrollAlways:
+ buffer = XtEtextScrollAlways;
+ break;
+ default:
+ XawTypeToStringWarning(dpy, XtRScrollMode);
+ toVal->addr = NULL;
+ toVal->size = 0;
+ return (False);
+ }
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL) {
+ if (toVal->size < size) {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
+
+/*ARGSUSED*/
+static void
+CvtStringToWrapMode(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static XawTextWrapMode wrapMode = XawtextWrapNever;
+ XrmQuark q;
+ char lowerName[6];
+
+ XmuNCopyISOLatin1Lowered(lowerName, (char *)fromVal->addr,
+ sizeof(lowerName));
+ q = XrmStringToQuark(lowerName);
+
+ if (q == QWrapNever)
+ wrapMode = XawtextWrapNever;
+ else if (q == QWrapLine)
+ wrapMode = XawtextWrapLine;
+ else if (q == QWrapWord)
+ wrapMode = XawtextWrapWord;
+ else
+ XtStringConversionWarning((char *)fromVal->addr, XtRWrapMode);
+
+ done(&wrapMode, XawTextWrapMode);
+}
+
+/*ARGSUSED*/
+static Boolean
+CvtWrapModeToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal, XtPointer *data)
+{
+ static char *buffer;
+ Cardinal size;
+
+ switch (*(XawTextWrapMode *)fromVal->addr) {
+ case XawtextWrapNever:
+ buffer = XtEtextWrapNever;
+ break;
+ case XawtextWrapLine:
+ buffer = XtEtextWrapLine;
+ break;
+ case XawtextWrapWord:
+ buffer = XtEtextWrapWord;
+ break;
+ default:
+ XawTypeToStringWarning(dpy, XtRWrapMode);
+ toVal->addr = NULL;
+ toVal->size = 0;
+ return (False);
+ }
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL) {
+ if (toVal->size < size) {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
+
+/*ARGSUSED*/
+static Boolean
+CvtStringToJustifyMode(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal, XtPointer *data)
+{
+ XawTextJustifyMode justify;
+ XrmQuark q;
+ char lowerName[8];
+
+ XmuNCopyISOLatin1Lowered(lowerName, (char *)fromVal->addr,
+ sizeof(lowerName));
+ q = XrmStringToQuark(lowerName);
+
+ if (q == QJustifyLeft)
+ justify = XawjustifyLeft;
+ else if (q == QJustifyRight)
+ justify = XawjustifyRight;
+ else if (q == QJustifyCenter)
+ justify = XawjustifyCenter;
+ else if(q == QJustifyFull)
+ justify = XawjustifyFull;
+ else {
+ XtStringConversionWarning((char *)fromVal->addr, XtRJustifyMode);
+ return (False);
+ }
+
+ toVal->size = sizeof(XawTextJustifyMode);
+ *(XawTextJustifyMode *)(toVal->addr) = justify;
+
+ return (True);
+}
+
+
+/*ARGSUSED*/
+static Boolean
+CvtJustifyModeToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal, XtPointer *data)
+{
+ static char *buffer;
+ Cardinal size;
+
+ switch (*(XawTextJustifyMode *)fromVal->addr) {
+ case XawjustifyLeft:
+ buffer = XtEtextJustifyLeft;
+ break;
+ case XawjustifyRight:
+ buffer = XtEtextJustifyRight;
+ break;
+ case XawjustifyCenter:
+ buffer = XtEtextJustifyCenter;
+ break;
+ case XawjustifyFull:
+ buffer = XtEtextJustifyFull;
+ break;
+ default:
+ XawTypeToStringWarning(dpy, XtRJustifyMode);
+ toVal->addr = NULL;
+ toVal->size = 0;
+ return (False);
+ }
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL) {
+ if (toVal->size < size) {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
+
+#undef done
+
+static void
+XawTextClassInitialize(void)
+{
+ if (!XawFmt8Bit)
+ FMT8BIT = XawFmt8Bit = XrmPermStringToQuark("FMT8BIT");
+ if (!XawFmtWide)
+ XawFmtWide = XrmPermStringToQuark("FMTWIDE");
+
+ XawInitializeWidgetSet();
+
+ textClassRec.core_class.num_actions = _XawTextActionsTableCount;
+
+ QWrapNever = XrmPermStringToQuark(XtEtextWrapNever);
+ QWrapLine = XrmPermStringToQuark(XtEtextWrapLine);
+ QWrapWord = XrmPermStringToQuark(XtEtextWrapWord);
+ XtAddConverter(XtRString, XtRWrapMode, CvtStringToWrapMode, NULL, 0);
+ XtSetTypeConverter(XtRWrapMode, XtRString, CvtWrapModeToString,
+ NULL, 0, XtCacheNone, NULL);
+ QScrollNever = XrmPermStringToQuark(XtEtextScrollNever);
+ QScrollWhenNeeded = XrmPermStringToQuark(XtEtextScrollWhenNeeded);
+ QScrollAlways = XrmPermStringToQuark(XtEtextScrollAlways);
+ XtAddConverter(XtRString, XtRScrollMode, CvtStringToScrollMode,
+ NULL, 0);
+ XtSetTypeConverter(XtRScrollMode, XtRString, CvtScrollModeToString,
+ NULL, 0, XtCacheNone, NULL);
+ QJustifyLeft = XrmPermStringToQuark(XtEtextJustifyLeft);
+ QJustifyRight = XrmPermStringToQuark(XtEtextJustifyRight);
+ QJustifyCenter = XrmPermStringToQuark(XtEtextJustifyCenter);
+ QJustifyFull = XrmPermStringToQuark(XtEtextJustifyFull);
+ XtSetTypeConverter(XtRString, XtRJustifyMode, CvtStringToJustifyMode,
+ NULL, 0, XtCacheNone, NULL);
+ XtSetTypeConverter(XtRJustifyMode, XtRString, CvtJustifyModeToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+
+/*
+ * Function:
+ * PositionHScrollBar
+ *
+ * Parameters:
+ * ctx - text widget
+ *
+ * Description:
+ * Positions the Horizontal scrollbar.
+ */
+static void
+PositionHScrollBar(TextWidget ctx)
+{
+ Widget hbar = ctx->text.hbar, vbar = ctx->text.vbar;
+ Position x, y;
+ Dimension width, height;
+
+ if (ctx->text.hbar == NULL)
+ return;
+
+ if (vbar != NULL)
+ x = XtWidth(vbar);
+ else
+ x = -XtBorderWidth(hbar);
+ y = XtHeight(ctx) - XtHeight(hbar) - XtBorderWidth(hbar);
+ if (vbar != NULL) {
+ width = XtWidth(ctx) - XtWidth(vbar) - XtBorderWidth(vbar);
+ if (width > XtWidth(ctx))
+ width = XtWidth(ctx);
+ }
+ else
+ width = XtWidth(ctx);
+ height = XtHeight(hbar);
+
+ XtConfigureWidget(hbar, x, y, width, height, XtBorderWidth(hbar));
+}
+
+/*
+ * Function:
+ * PositionVScrollBar
+ *
+ * Parameters:
+ * ctx - text widget
+ *
+ * Description:
+ * Positions the Vertical scrollbar.
+ */
+static void
+PositionVScrollBar(TextWidget ctx)
+{
+ Widget vbar = ctx->text.vbar;
+ Position x, y;
+ Dimension width, height;
+
+ if (vbar == NULL)
+ return;
+
+ x = y = -XtBorderWidth(vbar);
+ height = XtHeight(ctx);
+ width = XtWidth(vbar);
+
+ XtConfigureWidget(vbar, x, y, width, height, XtBorderWidth(vbar));
+}
+
+static void
+CreateVScrollBar(TextWidget ctx)
+{
+ Widget vbar;
+
+ if (ctx->text.vbar != NULL)
+ return;
+
+ ctx->text.vbar = vbar =
+ XtCreateWidget("vScrollbar", scrollbarWidgetClass, (Widget)ctx, NULL, 0);
+ XtAddCallback(vbar, XtNscrollProc, VScroll, (XtPointer)ctx);
+ XtAddCallback(vbar, XtNjumpProc, VJump, (XtPointer)ctx);
+
+ ctx->text.r_margin.left += XtWidth(vbar) + XtBorderWidth(vbar);
+ ctx->text.left_margin = ctx->text.margin.left = ctx->text.r_margin.left;
+
+ PositionVScrollBar(ctx);
+ PositionHScrollBar(ctx);
+ TextSinkResize(ctx->text.sink);
+
+ if (XtIsRealized((Widget)ctx)) {
+ XtRealizeWidget(vbar);
+ XtMapWidget(vbar);
+ }
+ XtSetKeyboardFocus(vbar, (Widget)ctx);
+}
+
+/*
+ * Function:
+ * DestroyVScrollBar
+ *
+ * Parameters:
+ * ctx - parent text widget
+ *
+ * Description:
+ * Removes vertical ScrollBar.
+ */
+static void
+DestroyVScrollBar(TextWidget ctx)
+{
+ Widget vbar = ctx->text.vbar;
+
+ if (vbar == NULL)
+ return;
+
+ ctx->text.r_margin.left -= XtWidth(vbar) + XtBorderWidth(vbar);
+ ctx->text.left_margin = ctx->text.margin.left = ctx->text.r_margin.left;
+
+ XtDestroyWidget(vbar);
+ ctx->text.vbar = NULL;
+ if (!ctx->core.being_destroyed) {
+ PositionHScrollBar(ctx);
+ TextSinkResize(ctx->text.sink);
+ }
+}
+
+static void
+CreateHScrollBar(TextWidget ctx)
+{
+ Arg args[1];
+ Widget hbar;
+ int bottom;
+
+ if (ctx->text.hbar != NULL)
+ return;
+
+ XtSetArg(args[0], XtNorientation, XtorientHorizontal);
+ ctx->text.hbar = hbar =
+ XtCreateWidget("hScrollbar", scrollbarWidgetClass, (Widget)ctx, args, 1);
+ XtAddCallback(hbar, XtNscrollProc, HScroll, (XtPointer)ctx);
+ XtAddCallback(hbar, XtNjumpProc, HJump, (XtPointer)ctx);
+
+ bottom = ctx->text.r_margin.bottom + XtHeight(hbar) + XtBorderWidth(hbar);
+
+ ctx->text.margin.bottom = ctx->text.r_margin.bottom = bottom;
+
+ PositionHScrollBar(ctx);
+ TextSinkResize(ctx->text.sink);
+
+ if (XtIsRealized((Widget)ctx)) {
+ XtRealizeWidget(hbar);
+ XtMapWidget(hbar);
+ }
+ XtSetKeyboardFocus(hbar, (Widget)ctx);
+}
+
+/*
+ * Function:
+ * DestroyHScrollBar
+ *
+ * Parameters:
+ * ctx - parent text widget
+ *
+ * Description:
+ * Removes horizontal ScrollBar.
+ */
+static void
+DestroyHScrollBar(TextWidget ctx)
+{
+ Widget hbar = ctx->text.hbar;
+
+ if (hbar == NULL)
+ return;
+
+ ctx->text.r_margin.bottom -= XtHeight(hbar) + XtBorderWidth(hbar);
+ ctx->text.margin.bottom = ctx->text.r_margin.bottom;
+
+ XtDestroyWidget(hbar);
+ ctx->text.hbar = NULL;
+ if (!ctx->core.being_destroyed)
+ TextSinkResize(ctx->text.sink);
+}
+
+/*ARGSUSED*/
+static void
+XawTextInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ TextWidget ctx = (TextWidget)cnew;
+
+ ctx->text.lt.lines = 0;
+ ctx->text.lt.info = (XawTextLineTableEntry *)
+ XtCalloc(1, sizeof(XawTextLineTableEntry));
+#ifndef OLDXAW
+ ctx->text.lt.base_line = 1;
+#endif
+ (void)bzero(&ctx->text.origSel, sizeof(XawTextSelection));
+ (void)bzero(&ctx->text.s, sizeof(XawTextSelection));
+ ctx->text.s.type = XawselectPosition;
+ ctx->text.salt = NULL;
+ ctx->text.hbar = ctx->text.vbar = NULL;
+ ctx->text.lasttime = 0;
+ ctx->text.time = 0;
+ ctx->text.showposition = True;
+ ctx->text.lastPos = ctx->text.source != NULL ?
+ XawTextGetLastPosition(ctx) : 0;
+ ctx->text.file_insert = NULL;
+ ctx->text.search = NULL;
+ ctx->text.update = XmuNewScanline(0, 0, 0);
+ ctx->text.gc = XtGetGC(cnew, 0, 0);
+ ctx->text.hasfocus = False;
+ ctx->text.margin = ctx->text.r_margin; /* Strucure copy */
+ ctx->text.left_margin = ctx->text.r_margin.left;
+ ctx->text.update_disabled = False;
+ ctx->text.clear_to_eol = True;
+ ctx->text.old_insert = -1;
+ ctx->text.mult = 1;
+ ctx->text.salt2 = NULL;
+ ctx->text.from_left = -1;
+
+#ifndef OLDXAW
+ ctx->text.numeric = False;
+ ctx->text.selection_state = False;
+ ctx->text.kill_ring = 0;
+
+ ctx->text.line_number = -1;
+ ctx->text.column_number = -1;
+ ctx->text.source_changed = SRC_CHANGE_NONE;
+
+ ctx->text.kill_ring_ptr = NULL;
+ ctx->text.overwrite = False;
+#endif
+
+ if (XtHeight(ctx) == DEFAULT_TEXT_HEIGHT) {
+ XtHeight(ctx) = VMargins(ctx);
+ if (ctx->text.sink != NULL)
+ XtHeight(ctx) += XawTextSinkMaxHeight(ctx->text.sink, 1);
+ }
+
+ if (ctx->text.scroll_vert == XawtextScrollAlways)
+ CreateVScrollBar(ctx);
+ if (ctx->text.scroll_horiz == XawtextScrollAlways)
+ CreateHScrollBar(ctx);
+
+#ifndef OLDXAW
+ if (ctx->text.left_column < 0)
+ ctx->text.left_column = 0;
+ if (ctx->text.right_column < 0)
+ ctx->text.right_column = 0;
+#endif
+}
+
+static void
+XawTextRealize(Widget w, XtValueMask *mask, XSetWindowAttributes *attr)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ (*textClassRec.core_class.superclass->core_class.realize)(w, mask, attr);
+
+ if (ctx->text.hbar != NULL) {
+ XtRealizeWidget(ctx->text.hbar);
+ XtMapWidget(ctx->text.hbar);
+ }
+
+ if (ctx->text.vbar != NULL) {
+ XtRealizeWidget(ctx->text.vbar);
+ XtMapWidget(ctx->text.vbar);
+ }
+
+ _XawTextBuildLineTable(ctx, ctx->text.lt.top, True);
+
+#ifndef OLDXAW
+ _XawTextSetLineAndColumnNumber(ctx, True);
+#endif
+}
+
+/* Utility routines for support of Text */
+static void
+_CreateCutBuffers(Display *d)
+{
+ static struct _DisplayRec {
+ struct _DisplayRec *next;
+ Display *dpy;
+ } *dpy_list = NULL;
+ struct _DisplayRec *dpy_ptr;
+
+ for (dpy_ptr = dpy_list; dpy_ptr != NULL; dpy_ptr = dpy_ptr->next)
+ if (dpy_ptr->dpy == d)
+ return;
+
+ dpy_ptr = XtNew(struct _DisplayRec);
+ dpy_ptr->next = dpy_list;
+ dpy_ptr->dpy = d;
+ dpy_list = dpy_ptr;
+
+#define Create(buffer) \
+ XChangeProperty(d, RootWindow(d, 0), buffer, XA_STRING, 8, \
+ PropModeAppend, NULL, 0);
+
+ Create(XA_CUT_BUFFER0);
+ Create(XA_CUT_BUFFER1);
+ Create(XA_CUT_BUFFER2);
+ Create(XA_CUT_BUFFER3);
+ Create(XA_CUT_BUFFER4);
+ Create(XA_CUT_BUFFER5);
+ Create(XA_CUT_BUFFER6);
+ Create(XA_CUT_BUFFER7);
+
+#undef Create
+}
+
+/*
+ * Procedure to manage insert cursor visibility for editable text. It uses
+ * the value of ctx->insertPos and an implicit argument. In the event that
+ * position is immediately preceded by an eol graphic, then the insert cursor
+ * is displayed at the beginning of the next line.
+ */
+static void
+InsertCursor(Widget w, XawTextInsertState state)
+{
+ TextWidget ctx = (TextWidget)w;
+ int x, y;
+ int line;
+
+ if (ctx->text.lt.lines < 1)
+ return;
+
+ if (ctx->text.display_caret &&
+ LineAndXYForPosition(ctx, ctx->text.insertPos, &line, &x, &y)) {
+ if (line < ctx->text.lt.lines)
+ y += (ctx->text.lt.info[line + 1].y - ctx->text.lt.info[line].y) + 1;
+ else
+ y += (ctx->text.lt.info[line].y - ctx->text.lt.info[line - 1].y) + 1;
+
+ XawTextSinkInsertCursor(ctx->text.sink, x, y, state);
+ }
+
+ /* Keep Input Method up to speed */
+ if (ctx->simple.international) {
+ Arg list[1];
+
+ XtSetArg(list[0], XtNinsertPosition, ctx->text.insertPos);
+ _XawImSetValues(w, list, 1);
+ }
+}
+
+/*
+ * Procedure to register a span of text that is no longer valid on the display
+ * It is used to avoid a number of small, and potentially overlapping, screen
+ * updates.
+*/
+void
+_XawTextNeedsUpdating(TextWidget ctx,
+ XawTextPosition left, XawTextPosition right)
+{
+ XmuSegment segment;
+
+ if (left >= right)
+ return;
+
+ segment.x1 = (int)left;
+ segment.x2 = (int)right;
+ (void)XmuScanlineOrSegment(ctx->text.update, &segment);
+}
+
+/*
+ * Procedure to read a span of text in Ascii form. This is purely a hack and
+ * we probably need to add a function to sources to provide this functionality.
+ * [note: this is really a private procedure but is used in multiple modules].
+ */
+char *
+_XawTextGetText(TextWidget ctx, XawTextPosition left, XawTextPosition right)
+{
+ char *result, *tempResult;
+ XawTextBlock text;
+ int bytes;
+
+ if (XawTextFormat(ctx, XawFmt8Bit))
+ bytes = sizeof(unsigned char);
+ else if (XawTextFormat(ctx, XawFmtWide))
+ bytes = sizeof(wchar_t);
+ else /* if there is another fomat, add here */
+ bytes = 1;
+
+ /* leave space for ZERO */
+ tempResult = result = XtMalloc((unsigned)(right - left + ONE) * bytes);
+
+ while (left < right) {
+ left = SrcRead(ctx->text.source, left, &text, (int)(right - left));
+ if (!text.length)
+ break;
+ memmove(tempResult, text.ptr, (unsigned)(text.length * bytes));
+ tempResult += text.length * bytes;
+ }
+
+ if (bytes == sizeof(wchar_t))
+ *((wchar_t*)tempResult) = (wchar_t)0;
+ else
+ *tempResult = '\0';
+
+ return (result);
+}
+
+/* Like _XawTextGetText, but enforces ICCCM STRING type encoding. This
+ * routine is currently used to put just the ASCII chars in the selection
+ * into a cut buffer.
+ */
+char *
+_XawTextGetSTRING(TextWidget ctx, XawTextPosition left, XawTextPosition right)
+{
+ unsigned char *s;
+ unsigned char c;
+ long i, j, n;
+ wchar_t *ws, wc;
+
+ /* allow ESC in accordance with ICCCM */
+ if (XawTextFormat(ctx, XawFmtWide)) {
+ MultiSinkObject sink = (MultiSinkObject)ctx->text.sink;
+ ws = (wchar_t *)_XawTextGetText(ctx, left, right);
+ n = wcslen(ws);
+ for (j = 0, i = 0; j < n; j++) {
+ wc = ws[j];
+ if (XwcTextEscapement (sink->multi_sink.fontset, &wc, 1)
+ || (wc == _Xaw_atowc(XawTAB)) || (wc == _Xaw_atowc(XawLF))
+ || (wc == _Xaw_atowc(XawESC)))
+ ws[i++] = wc;
+ }
+ ws[i] = (wchar_t)0;
+ return ((char *)ws);
+ }
+ else {
+ s = (unsigned char *)_XawTextGetText(ctx, left, right);
+ /* only HT and NL control chars are allowed, strip out others */
+ n = strlen((char *)s);
+ i = 0;
+ for (j = 0; j < n; j++) {
+ c = s[j];
+ if (((c >= 0x20) && c <= 0x7f)
+ ||(c >= 0xa0) || (c == XawTAB) || (c == XawLF)
+ || (c == XawESC)) {
+ s[i] = c;
+ i++;
+ }
+ }
+ s[i] = 0;
+
+ return ((char *)s);
+ }
+}
+
+/*
+ * This routine maps an x and y position in a window that is displaying text
+ * into the corresponding position in the source.
+ */
+static XawTextPosition
+PositionForXY(TextWidget ctx, int x, int y)
+{
+ int fromx, line, width, height;
+ XawTextPosition position;
+
+ if (ctx->text.lt.lines == 0)
+ return (0);
+
+ for (line = 0; line < ctx->text.lt.lines - 1; line++) {
+ if (y <= ctx->text.lt.info[line + 1].y)
+ break;
+ }
+ position = ctx->text.lt.info[line].position;
+ if (position >= ctx->text.lastPos)
+ return (ctx->text.lastPos);
+ fromx = ctx->text.left_margin;
+ XawTextSinkFindPosition(ctx->text.sink, position, fromx, x - fromx,
+ False, &position, &width, &height);
+
+ if (position > ctx->text.lastPos)
+ return (ctx->text.lastPos);
+
+ if (position >= ctx->text.lt.info[line + 1].position)
+ position = SrcScan(ctx->text.source, ctx->text.lt.info[line + 1].position,
+ XawstPositions, XawsdLeft, 1, True);
+
+ return (position);
+}
+
+/*
+ * This routine maps a source position in to the corresponding line number
+ * of the text that is displayed in the window.
+ */
+static int
+LineForPosition(TextWidget ctx, XawTextPosition position)
+{
+ int line;
+
+ for (line = 0; line < ctx->text.lt.lines; line++)
+ if (position < ctx->text.lt.info[line + 1].position)
+ break;
+
+ return (line);
+}
+
+/*
+ * This routine maps a source position into the corresponding line number
+ * and the x, y coordinates of the text that is displayed in the window.
+ */
+static Bool
+LineAndXYForPosition(TextWidget ctx, XawTextPosition pos,
+ int *line, int *x, int *y)
+{
+ XawTextPosition linePos, endPos;
+ Boolean visible;
+ int realW, realH;
+
+ *line = 0;
+ *x = ctx->text.left_margin;
+ *y = ctx->text.margin.top + 1;
+ if ((visible = IsPositionVisible(ctx, pos)) != False) {
+ *line = LineForPosition(ctx, pos);
+ *y = ctx->text.lt.info[*line].y;
+ linePos = ctx->text.lt.info[*line].position;
+ XawTextSinkFindDistance(ctx->text.sink, linePos,
+ *x, pos, &realW, &endPos, &realH);
+ *x += realW;
+ }
+
+ return (visible);
+}
+
+/*
+ * This routine builds a line table. It does this by starting at the
+ * specified position and measuring text to determine the staring position
+ * of each line to be displayed. It also determines and saves in the
+ * linetable all the required metrics for displaying a given line (e.g.
+ * x offset, y offset, line length, etc.).
+ */
+void
+_XawTextBuildLineTable(TextWidget ctx, XawTextPosition position,
+ _XtBoolean force_rebuild)
+{
+ Dimension height = 0;
+ int lines = 0;
+ Cardinal size;
+
+ if ((int)XtHeight(ctx) > VMargins(ctx)) {
+ height = XtHeight(ctx) - VMargins(ctx);
+ lines = XawTextSinkMaxLines(ctx->text.sink, height);
+ }
+ size = sizeof(XawTextLineTableEntry) * (lines + 1);
+
+ if (lines != ctx->text.lt.lines || ctx->text.lt.info == NULL) {
+ ctx->text.lt.info = (XawTextLineTableEntry *)
+ XtRealloc((char *)ctx->text.lt.info, size);
+ ctx->text.lt.lines = lines;
+ force_rebuild = True;
+ }
+
+ if (force_rebuild) {
+ (void)bzero((char *)ctx->text.lt.info, size);
+ /* force a text update in the first text line if it is visible */
+ ctx->text.lt.info[0].position = (XawTextPosition)-1;
+ }
+ if (position != ctx->text.lt.info[0].position) {
+ (void)_BuildLineTable(ctx, position, 0);
+ ctx->text.clear_to_eol = True;
+ }
+}
+
+/*
+ * We may need to resize the line table here, since there maybe lines with
+ * different fonts (that can be shorter or taller than the default one)
+ */
+static XawTextPosition
+_BuildLineTable(TextWidget ctx, XawTextPosition position, int line)
+{
+ XawTextLineTableEntry *lt = ctx->text.lt.info + line;
+ XawTextPosition end, update_from = -1;
+ Position y;
+ int wwidth, width, height;
+#ifndef OLDXAW
+ Widget src = ctx->text.source;
+#endif
+ int max_y = (int)XtHeight(ctx) - (int)ctx->text.margin.bottom;
+
+ if (ctx->text.wrap == XawtextWrapNever)
+ wwidth = 0x7fffffff;
+ else
+ wwidth = GetMaxTextWidth(ctx);
+
+ /* XXX y may change, due to font size changes. See later */
+ y = line == 0 ? ctx->text.margin.top : lt->y;
+
+#ifndef OLDXAW
+ if (ctx->text.lt.base_line < 0) {
+ if (line == 0)
+ ctx->text.lt.top = position;
+ }
+ else if (line == 0) {
+ XawTextPosition pos = ctx->text.lt.top;
+ int base_line = ctx->text.lt.base_line;
+
+ if (position == 0)
+ base_line = 1;
+ else if (ctx->text.lt.base_line == 0 ||
+ ctx->text.source_changed == SRC_CHANGE_OVERLAP) {
+ pos = 0;
+ base_line = 1;
+
+ while (pos < position) {
+ pos = SrcScan(src, pos, XawstEOL, XawsdRight, 1, True);
+ if (pos <= position) {
+ ++base_line;
+ if (pos == ctx->text.lastPos) {
+ base_line -= !_XawTextSourceNewLineAtEOF(src);
+ break;
+ }
+ }
+ }
+ }
+ else if (ctx->text.wrap == XawtextWrapNever
+ && IsPositionVisible(ctx, position))
+ base_line += LineForPosition(ctx, position);
+ else if (pos < position) {
+ while (pos < position) {
+ pos = SrcScan(src, pos, XawstEOL, XawsdRight, 1, True);
+ if (pos <= position) {
+ ++base_line;
+ if (pos == ctx->text.lastPos) {
+ base_line -= !_XawTextSourceNewLineAtEOF(src);
+ break;
+ }
+ }
+ }
+ }
+ else if (pos > position) {
+ while (pos > position) {
+ pos = SrcScan(src, pos, XawstEOL, XawsdLeft, 1, False);
+ if (--pos >= position)
+ --base_line;
+ }
+ }
+
+ ctx->text.lt.top = position;
+ ctx->text.lt.base_line = base_line;
+ }
+#else
+ if (line == 0)
+ ctx->text.lt.top = position;
+#endif
+
+ /* CONSTCOND */
+ while (True) {
+ XawTextSinkFindPosition(ctx->text.sink, position, ctx->text.left_margin,
+ wwidth, ctx->text.wrap == XawtextWrapWord,
+ &end, &width, &height);
+
+ if (lt->position != position) {
+ _XawTextNeedsUpdating(ctx, position,
+ end <= position ? position + 1 : end);
+ ctx->text.clear_to_eol = True;
+ lt->position = position;
+ }
+ if (lt->y != y) {
+ if (update_from < 0)
+ update_from = line == 0 ?
+ ctx->text.lt.info[0].position :
+ ctx->text.lt.info[line - 1].position;
+ lt->y = y;
+ ctx->text.clear_to_eol = True;
+ }
+ if (lt->textWidth != width) {
+ if (lt->textWidth > width)
+ ctx->text.clear_to_eol = True;
+ lt->textWidth = width;
+ }
+ y += height;
+
+ if (end > ctx->text.lastPos) {
+ position = end;
+ ctx->text.clear_to_eol = True;
+ _XawTextNeedsUpdating(ctx, end, end + ctx->text.lt.lines - line);
+ while (line++ < ctx->text.lt.lines) {
+ if (line > 1 && y > max_y) {
+ ctx->text.lt.lines = line - 1;
+ break;
+ }
+ ++lt;
+ if (lt->y != y) {
+ if (update_from < 0)
+ update_from = line < 2 ?
+ ctx->text.lt.info[0].position :
+ ctx->text.lt.info[line - 2].position;
+ lt->y = y;
+ }
+ lt->position = ++position;
+ lt->textWidth = 0;
+ y += height;
+ }
+ if (update_from >= 0)
+ _XawTextNeedsUpdating(ctx, update_from,
+ ctx->text.lt.info[ctx->text.lt.lines].position);
+ _XawTextSetScrollBars(ctx);
+
+ return (ctx->text.lastPos);
+ }
+
+ if (line && y > max_y)
+ /* will return in the next loop */
+ ctx->text.lt.lines = line;
+
+ if (++line > ctx->text.lt.lines && y < max_y) {
+ /* grow the line table */
+ ctx->text.lt.info = (XawTextLineTableEntry *)
+ XtRealloc((char *)ctx->text.lt.info,
+ sizeof(XawTextLineTableEntry) * (line + 1));
+ lt = ctx->text.lt.info + line;
+ bzero(lt, sizeof(XawTextLineTableEntry));
+ ++ctx->text.lt.lines;
+ }
+ else
+ ++lt;
+ if (position == end)
+ ++position;
+ else
+ position = end;
+
+ if (line > ctx->text.lt.lines) {
+ if (update_from >= 0)
+ _XawTextNeedsUpdating(ctx, update_from,
+ ctx->text.lt.info[ctx->text.lt.lines].position);
+ _XawTextSetScrollBars(ctx);
+
+ return (position);
+ }
+ }
+ /*NOTREACHED*/
+}
+
+/*
+ * Function:
+ * GetWidestLine
+ *
+ * Parameters:
+ * ctx - text widget
+ *
+ * Description:
+ * Returns the width (in pixels) of the widest line that
+ * is currently visable.
+ *
+ * Returns:
+ * The width of the widest line
+ */
+static unsigned int
+GetWidestLine(TextWidget ctx)
+{
+ int i;
+ unsigned int widest;
+ XawTextLineTablePtr lt = &(ctx->text.lt);
+
+ for (i = 0, widest = 0; i < lt->lines; i++)
+ if (widest < lt->info[i].textWidth)
+ widest = lt->info[i].textWidth;
+
+ return (widest);
+}
+
+/*
+ * This routine is used by Text to notify an associated scrollbar of the
+ * correct metrics (position and shown fraction) for the text being currently
+ * displayed in the window.
+ */
+void
+_XawTextSetScrollBars(TextWidget ctx)
+{
+ float first, last, denom, widest;
+
+ if (ctx->text.scroll_vert == XawtextScrollAlways) {
+ if (ctx->text.lastPos == 0)
+ first = 0.0;
+ else
+ first = ctx->text.lt.top / (float)ctx->text.lastPos;
+
+ if (ctx->text.lt.info[ctx->text.lt.lines].position < ctx->text.lastPos)
+ last = ctx->text.lt.info[ctx->text.lt.lines].position /
+ (float)ctx->text.lastPos;
+ else
+ last = 1.0;
+
+ XawScrollbarSetThumb(ctx->text.vbar, first, last - first);
+ }
+
+ if (ctx->text.scroll_horiz == XawtextScrollAlways) {
+ denom = GetWidestLine(ctx);
+ if (denom <= 0)
+ denom = (int)XtWidth(ctx) - RHMargins(ctx);
+ if (denom <= 0)
+ denom = 1;
+ widest = ((int)XtWidth(ctx) - RHMargins(ctx)) / denom;
+ first = ctx->text.r_margin.left - ctx->text.left_margin;
+ first /= denom;
+
+ XawScrollbarSetThumb(ctx->text.hbar, first, widest);
+ }
+}
+
+static void
+DoCopyArea(TextWidget ctx, int src_x, int src_y,
+ unsigned int width, unsigned int height, int dst_x, int dst_y)
+{
+ int x1, y1, x2, y2;
+
+ x1 = ctx->text.r_margin.left;
+ y1 = ctx->text.r_margin.top;
+ x2 = XtWidth(ctx) - ctx->text.r_margin.right;
+ y2 = XtHeight(ctx) - ctx->text.r_margin.bottom;
+
+ if (x1 >= x2 || y1 >= y2)
+ return;
+
+ src_x = XawMax(x1, XawMin(src_x, x2));
+ src_y = XawMax(y1, XawMin(src_y, y2));
+ dst_x = XawMax(x1, XawMin(dst_x, x2));
+ dst_y = XawMax(y1, XawMin(dst_y, y2));
+ width = XawMax(0, XawMin(x2 - dst_x, (int)width));
+ height = XawMax(0, XawMin(y2 - dst_y, (int)height));
+
+ XCopyArea(XtDisplay(ctx), XtWindow(ctx), XtWindow(ctx), ctx->text.gc,
+ src_x, src_y, width, height, dst_x, dst_y);
+}
+
+/*
+ * Function:
+ * XawTextScroll
+ *
+ * Parameters:
+ * ctx - text widget
+ * vlines - number of lines to scroll vertically
+ * hpixels - number of pixels to scroll horizontally
+ *
+ * Description:
+ * Generic function for scrolling the text window.
+ * Allows vertical and horizontal scroll at the same time.
+ */
+void
+XawTextScroll(TextWidget ctx, int vlines, int hpixels)
+{
+ XawTextPosition top, tmp, update_from, update_to;
+ XawTextLineTable *lt;
+ Arg arglist[1];
+ int y0, y1, y2, count, dim, wwidth, lines = ctx->text.lt.lines;
+ int vwidth, vheight; /* visible width and height */
+ Bool scroll;
+
+ vwidth = (int)XtWidth(ctx) - RHMargins(ctx);
+ vheight = (int)XtHeight(ctx) - RVMargins(ctx);
+ lt = &ctx->text.lt;
+
+ if (!lt || vwidth <= 0 || vheight <= 0)
+ return;
+
+ if ((scroll = ctx->core.background_pixmap == XtUnspecifiedPixmap) == True) {
+ dim = lt->info[1].y - lt->info[0].y;
+ for (count = 1; count < lt->lines - 1; count++)
+ if (lt->info[count + 1].y - lt->info[count].y != dim) {
+ scroll = False;
+ break;
+ }
+ }
+
+ wwidth = GetMaxTextWidth(ctx);
+
+ /*
+ * Do the horizontall scrolling
+ */
+ if (hpixels < 0 && ctx->text.left_margin - hpixels > ctx->text.r_margin.left)
+ hpixels = ctx->text.left_margin - ctx->text.r_margin.left;
+ ctx->text.left_margin -= hpixels;
+
+ update_from = lt->top; /* remember the old value */
+ /*
+ * Checks the requested number of lines and calculates the top
+ * of the line table
+ */
+ if (vlines < 0) { /* VScroll Up */
+ if (IsPositionVisible(ctx, 0))
+ vlines = 0;
+ else if (ctx->text.wrap != XawtextWrapNever) {
+ XawTextPosition end;
+ int n_lines = 0;
+
+ count = -vlines;
+ end = lt->top;
+ while (n_lines < count) {
+ top = SrcScan(ctx->text.source, end, XawstEOL,
+ XawsdLeft, 2, False);
+ n_lines += CountLines(ctx, top, end);
+ end = top;
+ }
+
+ while (count++ < n_lines) {
+ tmp = top;
+ XawTextSinkFindPosition(ctx->text.sink, top,
+ ctx->text.left_margin,
+ wwidth,ctx->text.wrap == XawtextWrapWord,
+ &top, &dim, &dim);
+ if (tmp == top)
+ ++top;
+ }
+ }
+ else
+ top = SrcScan(ctx->text.source, lt->top, XawstEOL,
+ XawsdLeft, -vlines + 1, False);
+ if (-vlines >= ctx->text.lt.lines)
+ scroll = False;
+ }
+ else if (vlines > 0) { /* VScroll Down */
+ if (LineForPosition(ctx, ctx->text.lastPos) == 0)
+ vlines = 0;
+ if (vlines < lt->lines)
+ top = XawMin(lt->info[vlines].position, ctx->text.lastPos);
+ else if (ctx->text.wrap == XawtextWrapNever)
+ top = SrcScan(ctx->text.source,
+ SrcScan(ctx->text.source, lt->top,
+ XawstEOL, XawsdRight, vlines,
+ True),
+ XawstEOL, XawsdLeft, 1, False);
+ else {
+ top = lt->top;
+ count = 0;
+ while (count++ < vlines) {
+ tmp = top;
+ XawTextSinkFindPosition(ctx->text.sink, top,
+ ctx->text.left_margin,
+ wwidth, ctx->text.wrap == XawtextWrapWord,
+ &top, &dim, &dim);
+ if (tmp == top)
+ ++top;
+ }
+ }
+ if (vlines >= ctx->text.lt.lines
+ || lt->info[vlines].position >= ctx->text.lastPos)
+ scroll = False;
+ }
+
+ if (!vlines) {
+ if (hpixels) {
+ ClearWindow(ctx);
+ ctx->text.clear_to_eol = True;
+ }
+ _XawTextSetScrollBars(ctx);
+ return;
+ }
+
+ /* Flushes any pending updates. Normally, there may be a call to
+ * XawTextUnsetSelection not yet updated.
+ */
+ if (!hpixels && scroll) {
+ ctx->text.clear_to_eol = True;
+ FlushUpdate(ctx);
+ }
+
+ /*
+ * Rebuild the line table, doing the vertical scroll
+ */
+ (void)_BuildLineTable(ctx, top, 0);
+ lt = &ctx->text.lt;
+ if (scroll) {
+ for (count = 0; count < lt->lines - 1; count++)
+ if (lt->info[count + 1].y - lt->info[count].y != dim) {
+ scroll = False;
+ break;
+ }
+ }
+
+ XtSetArg(arglist[0], XtNinsertPosition, lt->top + lt->lines);
+ _XawImSetValues((Widget)ctx, arglist, 1);
+
+ if (hpixels || !scroll || lines != lt->lines)
+ return;
+
+ /* _BuildLineTable updates everything if the top position changes.
+ * It is not required here.
+ */
+ (void)XmuScanlineXor(ctx->text.update, ctx->text.update);
+ if (vlines < 0 && IsPositionVisible(ctx, 0))
+ vlines = -LineForPosition(ctx, update_from);
+
+ y0 = ctx->text.r_margin.top;
+ if (vlines < 0) {
+ update_from = lt->top;
+ update_to = lt->info[-vlines + 1].position - 1;
+ y1 = lt->info[lt->lines + vlines].y;
+ y2 = lt->info[-vlines].y;
+ DoCopyArea(ctx, ctx->text.r_margin.left, y0, vwidth,
+ y1 - y0,
+ ctx->text.r_margin.left, y2);
+ }
+ else {
+ update_from = lt->info[lt->lines - vlines].position;
+ update_to = lt->info[lt->lines].position;
+ y1 = lt->info[lt->lines - vlines].y;
+ y2 = lt->info[vlines].y;
+ DoCopyArea(ctx, ctx->text.r_margin.left, y2,
+ vwidth, lt->info[lt->lines].y - y2,
+ ctx->text.r_margin.left, y0);
+ }
+ _XawTextNeedsUpdating(ctx, update_from, update_to);
+ ctx->text.clear_to_eol = True;
+}
+
+/*
+ * The routine will scroll the displayed text by lines. If the arg is
+ * positive, move up; otherwise, move down. [note: this is really a private
+ * procedure but is used in multiple modules].
+ */
+void
+_XawTextVScroll(TextWidget ctx, int n)
+{
+ XawTextScroll(ctx, n, 0);
+}
+
+/*ARGSUSED*/
+static void
+HScroll(Widget w, XtPointer closure, XtPointer callData)
+{
+ TextWidget ctx = (TextWidget)closure;
+ long pixels = (long)callData;
+
+ if (pixels > 0) {
+ long max;
+
+ max = (int)GetWidestLine(ctx) + ctx->text.left_margin -
+ ctx->text.r_margin.left;
+ max = XawMax(0, max);
+ pixels = XawMin(pixels, max);
+ }
+
+ if (pixels) {
+ _XawTextPrepareToUpdate(ctx);
+ XawTextScroll(ctx, 0, pixels);
+ _XawTextExecuteUpdate(ctx);
+ }
+}
+
+/*ARGSUSED*/
+static void
+HJump(Widget w, XtPointer closure, XtPointer callData)
+{
+ TextWidget ctx = (TextWidget)closure;
+ float percent = *(float *)callData;
+ long pixels;
+
+ pixels = ctx->text.left_margin -
+ (ctx->text.r_margin.left - (int)(percent * GetWidestLine(ctx)));
+
+ HScroll(w, (XtPointer)ctx, (XtPointer)pixels);
+}
+
+/*
+ * Function:
+ * UpdateTextInLine
+ *
+ * Parameters:
+ * ctx - text widget
+ * line - line to update
+ * x1 - left pixel
+ * x2 - right pixel
+ *
+ * Description:
+ * Updates the text in the given line and pixel interval
+ */
+static void
+UpdateTextInLine(TextWidget ctx, int line, int x1, int x2)
+{
+ XawTextLineTableEntry *lt = ctx->text.lt.info + line;
+ XawTextPosition left, right;
+ int from_x, width, height;
+
+ if (lt->position >= ctx->text.lastPos
+ || ctx->text.left_margin > x2
+ || (int)lt->textWidth + ctx->text.left_margin < x1) {
+ /* Mark line to be cleared */
+ if (ctx->text.clear_to_eol)
+ _XawTextNeedsUpdating(ctx, lt->position, lt->position + 1);
+ return;
+ }
+
+ from_x = ctx->text.left_margin;
+ XawTextSinkFindPosition(ctx->text.sink, lt->position,
+ from_x, x1 - from_x,
+ False, &left, &width, &height);
+ if (line == ctx->text.lt.lines)
+ right = -1;
+ else if (x2 >= lt->textWidth - from_x)
+ right = lt[1].position - 1;
+ else {
+ from_x += width;
+ XawTextSinkFindPosition(ctx->text.sink, left,
+ from_x, x2 - from_x,
+ False, &right, &width, &height);
+ }
+
+ if ((right < 0) || (right + 1 <= lt[1].position))
+ ++right;
+
+ /* Mark text interval to be repainted */
+ _XawTextNeedsUpdating(ctx, left, right);
+}
+
+/*
+ * The routine will scroll the displayed text by pixels. If the calldata is
+ * positive, move up; otherwise, move down.
+ */
+/*ARGSUSED*/
+static void
+VScroll(Widget w, XtPointer closure, XtPointer callData)
+{
+ TextWidget ctx = (TextWidget)closure;
+ long height, lines = (long)callData;
+
+ height = XtHeight(ctx) - VMargins(ctx);
+ if (height < 1)
+ height = 1;
+ lines = (lines * ctx->text.lt.lines) / height;
+ _XawTextPrepareToUpdate(ctx);
+ XawTextScroll(ctx, lines, 0);
+ _XawTextExecuteUpdate(ctx);
+}
+
+/*ARGSUSED*/
+static void
+VJump(Widget w, XtPointer closure, XtPointer callData)
+{
+ float percent = *(float *)callData;
+ TextWidget ctx = (TextWidget)closure;
+ XawTextPosition top, last, position, tmp;
+ XawTextLineTable *lt = &(ctx->text.lt);
+ int dim, vlines = 0, wwidth = GetMaxTextWidth(ctx);
+ Bool scroll = True;
+
+ position = percent * ctx->text.lastPos;
+ top = lt->top;
+
+ if (!lt->lines || (position >= lt->top && position < lt->info[1].position)) {
+ _XawTextSetScrollBars(ctx);
+ return;
+ }
+
+#ifndef OLDXAW
+ ctx->text.lt.base_line = -1;
+#endif
+
+ if (position > lt->top) { /* VScroll Up */
+ if (position > lt->top && position < lt->info[lt->lines].position)
+ vlines = LineForPosition(ctx, position);
+ else {
+ scroll = False;
+ top = SrcScan(ctx->text.source, position, XawstEOL,
+ XawsdLeft, 1, False);
+ if (ctx->text.wrap != XawtextWrapNever) {
+ last = top;
+ while (last < position) {
+ tmp = last;
+ XawTextSinkFindPosition(ctx->text.sink, last,
+ ctx->text.left_margin, wwidth,
+ ctx->text.wrap == XawtextWrapWord,
+ &last, &dim, &dim);
+ if (last == tmp)
+ ++last;
+ if (last < position)
+ top = last;
+ }
+ }
+ }
+ }
+ else { /* VScroll Down */
+ /*
+ * Calculates the number of lines
+ */
+ while (top > position) {
+ last = top;
+ top = SrcScan(ctx->text.source, top, XawstEOL,
+ XawsdLeft, 2, False);
+ vlines -= CountLines(ctx, top, last);
+ if (-vlines >= ctx->text.lt.lines) {
+ scroll = False;
+ top = SrcScan(ctx->text.source, position, XawstEOL,
+ XawsdLeft, 1, False);
+ break;
+ }
+ }
+ /*
+ * Normalize
+ */
+ if (ctx->text.wrap != XawtextWrapNever) {
+ last = top;
+ while (last < position) {
+ tmp = last;
+ XawTextSinkFindPosition(ctx->text.sink, last,
+ ctx->text.left_margin,
+ wwidth,
+ ctx->text.wrap == XawtextWrapWord,
+ &last, &dim, &dim);
+ if (last == tmp)
+ ++last;
+ if (last < position)
+ top = last;
+ ++vlines;
+ }
+ }
+ }
+
+ if (vlines || !scroll) {
+ _XawTextPrepareToUpdate(ctx);
+ if (scroll)
+ XawTextScroll(ctx, vlines, 0);
+ else
+ _BuildLineTable(ctx, top, 0);
+ _XawTextExecuteUpdate(ctx);
+ }
+}
+
+static Bool
+MatchSelection(Atom selection, XawTextSelection *s)
+{
+ Atom *match;
+ int count;
+
+ for (count = 0, match = s->selections; count < s->atom_count;
+ match++, count++)
+ if (*match == selection)
+ return (True);
+
+ return (False);
+}
+
+static Boolean
+TextConvertSelection(Widget w, Atom *selection, Atom *target, Atom *type,
+ XtPointer *value, unsigned long *length, int *format)
+{
+ Display *d = XtDisplay(w);
+ TextWidget ctx = (TextWidget)w;
+ Widget src = ctx->text.source;
+ XawTextEditType edit_mode;
+ Arg args[1];
+ XawTextSelectionSalt *salt = NULL;
+ XawTextSelection *s;
+
+ if (*target == XA_TARGETS(d)) {
+ Atom *targetP, *std_targets;
+ unsigned long std_length;
+
+ if (SrcCvtSel(src, selection, target, type, value, length, format))
+ return (True);
+
+ XtSetArg(args[0], XtNeditType, &edit_mode);
+ XtGetValues(src, args, ONE);
+
+ XmuConvertStandardSelection(w, ctx->text.time, selection,
+ target, type, (XPointer*)&std_targets,
+ &std_length, format);
+
+ *length = 7 + (edit_mode == XawtextEdit) + std_length;
+ *value = XtMalloc((unsigned)sizeof(Atom)*(*length));
+ targetP = *(Atom**)value;
+ *targetP++ = XA_STRING;
+ *targetP++ = XA_TEXT(d);
+ *targetP++ = XA_UTF8_STRING(d);
+ *targetP++ = XA_COMPOUND_TEXT(d);
+ *targetP++ = XA_LENGTH(d);
+ *targetP++ = XA_LIST_LENGTH(d);
+ *targetP++ = XA_CHARACTER_POSITION(d);
+ if (edit_mode == XawtextEdit) {
+ *targetP++ = XA_DELETE(d);
+ }
+ (void)memmove((char*)targetP, (char*)std_targets,
+ sizeof(Atom) * std_length);
+ XtFree((char*)std_targets);
+ *type = XA_ATOM;
+ *format = 32;
+ return (True);
+ }
+
+ if (SrcCvtSel(src, selection, target, type, value, length, format))
+ return (True);
+
+ if (MatchSelection(*selection, &ctx->text.s))
+ s = &ctx->text.s;
+ else {
+ for (salt = ctx->text.salt; salt; salt = salt->next)
+ if (MatchSelection(*selection, &salt->s))
+ break;
+ if (!salt)
+ return (False);
+ s = &salt->s;
+ }
+ if (*target == XA_STRING
+ || *target == XA_TEXT(d)
+ || *target == XA_UTF8_STRING(d)
+ || *target == XA_COMPOUND_TEXT(d)) {
+ if (*target == XA_TEXT(d)) {
+ if (XawTextFormat(ctx, XawFmtWide))
+ *type = XA_COMPOUND_TEXT(d);
+ else
+ *type = XA_STRING;
+ }
+ else
+ *type = *target;
+ /*
+ * If salt is True, the salt->contents stores CT string,
+ * its length is measured in bytes.
+ * Refer to _XawTextSaltAwaySelection().
+ *
+ * by Li Yuhong, Mar. 20, 1991.
+ */
+ if (!salt) {
+ *value = _XawTextGetSTRING(ctx, s->left, s->right);
+ if (XawTextFormat(ctx, XawFmtWide)) {
+ XTextProperty textprop;
+ if (XwcTextListToTextProperty(d, (wchar_t **)value, 1,
+ XCompoundTextStyle, &textprop)
+ < Success) {
+ XtFree((char *)*value);
+ return (False);
+ }
+ XtFree((char *)*value);
+ *value = (XtPointer)textprop.value;
+ *length = textprop.nitems;
+ }
+ else
+ *length = strlen((char *)*value);
+ }
+ else {
+ *value = XtMalloc((salt->length + 1) * sizeof(unsigned char));
+ strcpy ((char *)*value, salt->contents);
+ *length = salt->length;
+ }
+ /* Got *value,*length, now in COMPOUND_TEXT format. */
+ if (XawTextFormat(ctx, XawFmtWide) && *type == XA_STRING) {
+ XTextProperty textprop;
+ wchar_t **wlist;
+ int count;
+
+ textprop.encoding = XA_COMPOUND_TEXT(d);
+ textprop.value = (unsigned char *)*value;
+ textprop.nitems = strlen(*value);
+ textprop.format = 8;
+ if (XwcTextPropertyToTextList(d, &textprop, &wlist, &count)
+ < Success
+ || count < 1) {
+ XtFree((char *)*value);
+ return (False);
+ }
+ XtFree((char *)*value);
+ if (XwcTextListToTextProperty(d, wlist, 1, XStringStyle, &textprop)
+ < Success) {
+ XwcFreeStringList((wchar_t**) wlist);
+ return (False);
+ }
+ *value = (XtPointer)textprop.value;
+ *length = textprop.nitems;
+ XwcFreeStringList(wlist);
+ } else if (*type == XA_UTF8_STRING(d)) {
+ XTextProperty textprop;
+ char **list;
+ int count;
+
+ textprop.encoding = XA_COMPOUND_TEXT(d);
+ textprop.value = (unsigned char *)*value;
+ textprop.nitems = strlen(*value);
+ textprop.format = 8;
+ if (Xutf8TextPropertyToTextList(d, &textprop, &list, &count)
+ < Success
+ || count < 1) {
+ XtFree((char *)*value);
+ return (False);
+ }
+ XtFree((char *)*value);
+ *value = *list;
+ *length = strlen(*list);
+ XFree(list);
+ }
+ *format = 8;
+ return (True);
+ }
+
+ if ((*target == XA_LIST_LENGTH(d)) || (*target == XA_LENGTH(d))) {
+ long * temp;
+
+ temp = (long *)XtMalloc((unsigned)sizeof(long));
+ if (*target == XA_LIST_LENGTH(d))
+ *temp = 1L;
+ else /* *target == XA_LENGTH(d) */
+ *temp = (long) (s->right - s->left);
+
+ *value = (XPointer)temp;
+ *type = XA_INTEGER;
+ *length = 1L;
+ *format = 32;
+ return (True);
+ }
+
+ if (*target == XA_CHARACTER_POSITION(d)) {
+ long * temp;
+
+ temp = (long *)XtMalloc((unsigned)(2 * sizeof(long)));
+ temp[0] = (long)(s->left + 1);
+ temp[1] = s->right;
+ *value = (XPointer)temp;
+ *type = XA_SPAN(d);
+ *length = 2L;
+ *format = 32;
+ return (True);
+ }
+
+ if (*target == XA_DELETE(d)) {
+ if (!salt)
+ _XawTextZapSelection(ctx, NULL, True);
+ *value = NULL;
+ *type = XA_NULL(d);
+ *length = 0;
+ *format = 32;
+ return (True);
+ }
+
+ if (XmuConvertStandardSelection(w, ctx->text.time, selection, target, type,
+ (XPointer *)value, length, format))
+ return (True);
+
+ /* else */
+ return (False);
+}
+
+/*
+ * Function:
+ * GetCutBuffferNumber
+ *
+ * Parameters:
+ * atom - atom to check
+ *
+ * Description:
+ * Returns the number of the cut buffer.
+ *
+ * Returns:
+ * The number of the cut buffer representing this atom or NOT_A_CUT_BUFFER
+ */
+#define NOT_A_CUT_BUFFER -1
+static int
+GetCutBufferNumber(Atom atom)
+{
+ if (atom == XA_CUT_BUFFER0) return (0);
+ if (atom == XA_CUT_BUFFER1) return (1);
+ if (atom == XA_CUT_BUFFER2) return (2);
+ if (atom == XA_CUT_BUFFER3) return (3);
+ if (atom == XA_CUT_BUFFER4) return (4);
+ if (atom == XA_CUT_BUFFER5) return (5);
+ if (atom == XA_CUT_BUFFER6) return (6);
+ if (atom == XA_CUT_BUFFER7) return (7);
+ return (NOT_A_CUT_BUFFER);
+}
+
+static void
+TextLoseSelection(Widget w, Atom *selection)
+{
+ TextWidget ctx = (TextWidget)w;
+ Atom *atomP;
+ int i;
+ XawTextSelectionSalt*salt, *prevSalt, *nextSalt;
+
+ atomP = ctx->text.s.selections;
+ for (i = 0 ; i < ctx->text.s.atom_count; i++, atomP++)
+ if ((*selection == *atomP)
+ || (GetCutBufferNumber(*atomP) != NOT_A_CUT_BUFFER))
+ *atomP = (Atom)0;
+
+ while (ctx->text.s.atom_count
+ && ctx->text.s.selections[ctx->text.s.atom_count - 1] == 0)
+ ctx->text.s.atom_count--;
+
+ /*
+ * Must walk the selection list in opposite order from UnsetSelection
+ */
+ atomP = ctx->text.s.selections;
+ for (i = 0 ; i < ctx->text.s.atom_count; i++, atomP++)
+ if (*atomP == (Atom)0) {
+ *atomP = ctx->text.s.selections[--ctx->text.s.atom_count];
+ while (ctx->text.s.atom_count
+ && ctx->text.s.selections[ctx->text.s.atom_count-1] == 0)
+ ctx->text.s.atom_count--;
+ }
+
+ if (ctx->text.s.atom_count == 0)
+ ModifySelection(ctx, ctx->text.insertPos, ctx->text.insertPos);
+
+ prevSalt = 0;
+ for (salt = ctx->text.salt; salt; salt = nextSalt) {
+ atomP = salt->s.selections;
+ nextSalt = salt->next;
+ for (i = 0 ; i < salt->s.atom_count; i++, atomP++)
+ if (*selection == *atomP)
+ *atomP = (Atom)0;
+
+ while (salt->s.atom_count
+ && salt->s.selections[salt->s.atom_count-1] == 0)
+ salt->s.atom_count--;
+
+ /*
+ * Must walk the selection list in opposite order from UnsetSelection
+ */
+ atomP = salt->s.selections;
+ for (i = 0 ; i < salt->s.atom_count; i++, atomP++)
+ if (*atomP == (Atom)0) {
+ *atomP = salt->s.selections[--salt->s.atom_count];
+ while (salt->s.atom_count
+ && salt->s.selections[salt->s.atom_count-1] == 0)
+ salt->s.atom_count--;
+ }
+
+ if (salt->s.atom_count == 0) {
+ XtFree ((char *) salt->s.selections);
+ XtFree (salt->contents);
+ if (prevSalt)
+ prevSalt->next = nextSalt;
+ else
+ ctx->text.salt = nextSalt;
+ XtFree((char *)salt);
+ }
+ else
+ prevSalt = salt;
+ }
+}
+
+void
+_XawTextSaltAwaySelection(TextWidget ctx, Atom *selections, int num_atoms)
+{
+ XawTextSelectionSalt *salt;
+ int i, j;
+
+ for (i = 0; i < num_atoms; i++)
+ TextLoseSelection((Widget)ctx, selections + i);
+ if (num_atoms == 0)
+ return;
+ salt = (XawTextSelectionSalt *)
+ XtMalloc((unsigned)sizeof(XawTextSelectionSalt));
+ if (!salt)
+ return;
+ salt->s.selections = (Atom *)XtMalloc((unsigned)(num_atoms * sizeof(Atom)));
+ if (!salt->s.selections) {
+ XtFree((char *)salt);
+ return;
+ }
+ salt->s.left = ctx->text.s.left;
+ salt->s.right = ctx->text.s.right;
+ salt->s.type = ctx->text.s.type;
+ salt->contents = _XawTextGetSTRING(ctx, ctx->text.s.left, ctx->text.s.right);
+ if (XawTextFormat(ctx, XawFmtWide)) {
+ XTextProperty textprop;
+ if (XwcTextListToTextProperty(XtDisplay((Widget)ctx),
+ (wchar_t**)(&(salt->contents)), 1,
+ XCompoundTextStyle,
+ &textprop) < Success) {
+ XtFree(salt->contents);
+ salt->length = 0;
+ return;
+ }
+ XtFree(salt->contents);
+ salt->contents = (char *)textprop.value;
+ salt->length = textprop.nitems;
+ }
+ else
+ salt->length = strlen (salt->contents);
+ salt->next = ctx->text.salt;
+ ctx->text.salt = salt;
+ j = 0;
+ for (i = 0; i < num_atoms; i++) {
+ if (GetCutBufferNumber (selections[i]) == NOT_A_CUT_BUFFER) {
+ salt->s.selections[j++] = selections[i];
+ XtOwnSelection((Widget)ctx, selections[i], ctx->text.time,
+ TextConvertSelection, TextLoseSelection, NULL);
+ }
+ }
+ salt->s.atom_count = j;
+}
+
+static void
+_SetSelection(TextWidget ctx, XawTextPosition left, XawTextPosition right,
+ Atom *selections, Cardinal count)
+{
+#ifndef OLDXAW
+ Cardinal i;
+ XawTextPosition pos;
+ TextSrcObject src = (TextSrcObject)ctx->text.source;
+
+ for (i = 0; i < src->textSrc.num_text; i++) {
+ TextWidget tw = (TextWidget)src->textSrc.text[i];
+ Bool needs_updating = tw->text.old_insert < 0;
+ Bool showposition = tw->text.showposition;
+
+ if (needs_updating) {
+ tw->text.showposition = False;
+ _XawTextPrepareToUpdate(tw);
+ }
+#else
+ TextWidget tw = ctx;
+ XawTextPosition pos;
+#endif /* OLDXAW */
+
+ if (left < tw->text.s.left) {
+ pos = Min(right, tw->text.s.left);
+ _XawTextNeedsUpdating(tw, left, pos);
+ }
+ if (left > tw->text.s.left) {
+ pos = Min(left, tw->text.s.right);
+ _XawTextNeedsUpdating(tw, tw->text.s.left, pos);
+ }
+ if (right < tw->text.s.right) {
+ pos = Max(right, tw->text.s.left);
+ _XawTextNeedsUpdating(tw, pos, tw->text.s.right);
+ }
+ if (right > tw->text.s.right) {
+ pos = Max(left, tw->text.s.right);
+ _XawTextNeedsUpdating(tw, pos, right);
+ }
+
+ tw->text.s.left = left;
+ tw->text.s.right = right;
+
+#ifndef OLDXAW
+ if (needs_updating) {
+ _XawTextExecuteUpdate(tw);
+ tw->text.showposition = showposition;
+ }
+ }
+#endif /* OLDXAW */
+
+ SrcSetSelection(ctx->text.source, left, right,
+ (count == 0) ? None : selections[0]);
+
+ if (left < right) {
+ Widget w = (Widget)ctx;
+ int buffer;
+
+ while (count) {
+ Atom selection = selections[--count];
+
+ /*
+ * If this is a cut buffer
+ */
+ if ((buffer = GetCutBufferNumber(selection)) != NOT_A_CUT_BUFFER) {
+ unsigned char *ptr, *tptr;
+ unsigned int amount, max_len = MAX_CUT_LEN(XtDisplay(w));
+ unsigned long len;
+
+ tptr= ptr= (unsigned char *)_XawTextGetSTRING(ctx,
+ ctx->text.s.left,
+ ctx->text.s.right);
+ if (XawTextFormat(ctx, XawFmtWide)) {
+ /*
+ * Only XA_STRING(Latin 1) is allowed in CUT_BUFFER,
+ * so we get it from wchar string, then free the wchar string
+ */
+ XTextProperty textprop;
+
+ if (XwcTextListToTextProperty(XtDisplay(w), (wchar_t**)&ptr,
+ 1, XStringStyle, &textprop)
+ < Success){
+ XtFree((char *)ptr);
+ return;
+ }
+ XtFree((char *)ptr);
+ tptr = ptr = textprop.value;
+ }
+ if (buffer == 0) {
+ _CreateCutBuffers(XtDisplay(w));
+ XRotateBuffers(XtDisplay(w), 1);
+ }
+ amount = Min ((len = strlen((char *)ptr)), max_len);
+ XChangeProperty(XtDisplay(w), RootWindow(XtDisplay(w), 0),
+ selection, XA_STRING, 8, PropModeReplace,
+ ptr, amount);
+
+ while (len > max_len) {
+ len -= max_len;
+ tptr += max_len;
+ amount = Min (len, max_len);
+ XChangeProperty(XtDisplay(w), RootWindow(XtDisplay(w), 0),
+ selection, XA_STRING, 8, PropModeAppend,
+ tptr, amount);
+ }
+ XtFree ((char *)ptr);
+ }
+ else /* This is a real selection */
+ XtOwnSelection(w, selection, ctx->text.time, TextConvertSelection,
+ TextLoseSelection, NULL);
+ }
+ }
+ else
+ XawTextUnsetSelection((Widget)ctx);
+}
+
+#ifndef OLDXAW
+void
+_XawTextSetLineAndColumnNumber(TextWidget ctx, Bool force)
+{
+ int line_number, column_number;
+
+ if (ctx->text.old_insert != ctx->text.insertPos &&
+ ctx->text.lt.base_line < 0) {
+ ctx->text.lt.base_line = 0;
+ (void)_BuildLineTable(ctx, ctx->text.lt.top, 0);
+ }
+
+ line_number = ResolveLineNumber(ctx);
+ column_number = ResolveColumnNumber(ctx);
+
+ if (force || (ctx->text.column_number != column_number
+ || ctx->text.line_number != line_number)) {
+ XawTextPositionInfo info;
+
+ ctx->text.line_number = info.line_number = line_number;
+ ctx->text.column_number = info.column_number = column_number;
+ info.insert_position = ctx->text.insertPos;
+ info.last_position = ctx->text.lastPos;
+ info.overwrite_mode = ctx->text.overwrite;
+
+ XtCallCallbacks((Widget)ctx, XtNpositionCallback, (XtPointer)&info);
+ }
+}
+
+static int
+ResolveColumnNumber(TextWidget ctx)
+{
+ Widget src = ctx->text.source;
+ short column_number = 0;
+ XawTextPosition position;
+ XawTextBlock block;
+ unsigned long format = _XawTextFormat(ctx);
+ TextSinkObject sink = (TextSinkObject)ctx->text.sink;
+ short *char_tabs = sink->text_sink.char_tabs;
+ int tab_count = sink->text_sink.tab_count;
+ int tab_index = 0, tab_column = 0, tab_base = 0;
+
+ if (ctx->text.lt.base_line < 1)
+ return (ctx->text.column_number);
+
+ position = SrcScan(src, ctx->text.insertPos, XawstEOL, XawsdLeft, 1, False);
+ XawTextSourceRead(src, position, &block, ctx->text.insertPos - position);
+
+ for (; position < ctx->text.insertPos; position++) {
+ if (position - block.firstPos >= block.length)
+ XawTextSourceRead(src, position, &block, ctx->text.insertPos - position);
+ if ((format == XawFmt8Bit && block.ptr[position - block.firstPos] == '\t') ||
+ (format == XawFmtWide && ((wchar_t*)block.ptr)[position - block.firstPos] == _Xaw_atowc(XawTAB))) {
+ while (tab_base + tab_column <= column_number) {
+ if (tab_count) {
+ for (; tab_index < tab_count; ++tab_index)
+ if (tab_base + char_tabs[tab_index] > column_number) {
+ tab_column = char_tabs[tab_index];
+ break;
+ }
+ if (tab_index >= tab_count) {
+ tab_base += char_tabs[tab_count - 1];
+ tab_column = tab_index = 0;
+ }
+ }
+ else
+ tab_column += DEFAULT_TAB_SIZE;
+ }
+ column_number = tab_base + tab_column;
+ }
+ else
+ ++column_number;
+ if (column_number >= 16384) {
+ column_number = 16383;
+ break;
+ }
+ }
+
+ return (column_number);
+}
+#endif /* OLDXAW */
+
+void
+_XawTextSourceChanged(Widget w, XawTextPosition left, XawTextPosition right,
+ XawTextBlock *block, int lines)
+{
+ TextWidget ctx = (TextWidget)w;
+ Widget src = ctx->text.source;
+ XawTextPosition update_from, update_to, top;
+ Boolean update_disabled;
+ int delta, line, line_from;
+
+ if (left < ctx->text.old_insert) {
+ XawTextPosition old_insert = ctx->text.old_insert;
+
+ if (right < ctx->text.old_insert)
+ old_insert -= right - left;
+ else
+ old_insert = left;
+
+ ctx->text.insertPos = old_insert + block->length;
+ }
+#ifndef OLDXAW
+ if (left <= ctx->text.lt.top) {
+ if (left + block->length - (right - left) < ctx->text.lt.top) {
+ ctx->text.source_changed = SRC_CHANGE_BEFORE;
+ ctx->text.lt.base_line += lines;
+ }
+ else
+ ctx->text.source_changed = SRC_CHANGE_OVERLAP;
+ }
+ else
+ ctx->text.source_changed = SRC_CHANGE_AFTER;
+#endif
+
+ update_from = left;
+ update_to = left + block->length;
+ update_to = SrcScan(src, update_to, XawstEOL, XawsdRight, 1, False);
+ delta = block->length - (right - left);
+ if (delta < 0)
+ ctx->text.clear_to_eol = True;
+ if (update_to == update_from)
+ ++update_to;
+ update_disabled = ctx->text.update_disabled;
+ ctx->text.update_disabled = True;
+ ctx->text.lastPos = XawTextGetLastPosition(ctx);
+ top = ctx->text.lt.info[0].position;
+
+ XawTextUnsetSelection((Widget)ctx);
+
+ if (delta) {
+ int i;
+ XmuSegment *seg;
+
+ for (seg = ctx->text.update->segment; seg; seg = seg->next) {
+ if (seg->x1 > (int)left)
+ break;
+ else if (seg->x2 > (int)left) {
+ seg->x2 += delta;
+ seg = seg->next;
+ break;
+ }
+ }
+ for (; seg; seg = seg->next) {
+ seg->x1 += delta;
+ seg->x2 += delta;
+ }
+ XmuOptimizeScanline(ctx->text.update);
+
+ for (i = 0; i <= ctx->text.lt.lines; i++)
+ if (ctx->text.lt.info[i].position > left)
+ break;
+ for (; i <= ctx->text.lt.lines; i++)
+ ctx->text.lt.info[i].position += delta;
+ }
+
+ if (top != ctx->text.lt.info[0].position) {
+ line_from = line = 0;
+ ctx->text.lt.top = top = SrcScan(src, ctx->text.lt.info[0].position,
+ XawstEOL, XawsdLeft, 1, False);
+ update_from = top;
+ }
+ else {
+ line_from = line = LineForPosition(ctx, update_from + delta);
+ top = ctx->text.lt.info[line].position;
+ }
+
+ if (line > 0 && ctx->text.wrap == XawtextWrapWord) {
+ --line;
+ top = ctx->text.lt.info[line].position;
+ }
+
+ (void)_BuildLineTable(ctx, top, line);
+
+ if (ctx->text.wrap == XawtextWrapWord) {
+ if (line_from != LineForPosition(ctx, update_from)
+ || line_from != LineForPosition(ctx, update_to)) {
+ ctx->text.clear_to_eol = True;
+ update_from = SrcScan(src, update_from,
+ XawstWhiteSpace, XawsdLeft, 1, True);
+ if (update_to >= ctx->text.lastPos)
+ /* this is not an error, it just tells _BuildLineTable to
+ * clear to the bottom of the window. The value of update_to
+ * should not be > ctx->text.lastPos.
+ */
+ ++update_to;
+ }
+ }
+ else if (!ctx->text.clear_to_eol) {
+ if (LineForPosition(ctx, update_from)
+ != LineForPosition(ctx, update_to))
+ ctx->text.clear_to_eol = True;
+ }
+
+ _XawTextNeedsUpdating(ctx, update_from, update_to);
+ ctx->text.update_disabled = update_disabled;
+}
+
+/*
+ * Function:
+ * _XawTextReplace
+ *
+ * Parameters:
+ * ctx - text widget
+ * left - left offset
+ * right - right offset
+ * block - text block
+ *
+ * Description:
+ * Replaces the text between left and right by the text in block.
+ * Does all the required calculations of offsets, and rebuild the
+ * the line table, from the insertion point (or previous line, if
+ * wrap mode is 'word').
+ *
+ * Returns:
+ * XawEditDone - success
+ * any other value - error code
+ */
+int
+_XawTextReplace(TextWidget ctx, XawTextPosition left, XawTextPosition right,
+ XawTextBlock *block)
+{
+ Arg args[1];
+ Widget src;
+ XawTextEditType edit_mode;
+
+ if (left == right && block->length == 0)
+ return (XawEditDone);
+
+ src = ctx->text.source;
+ XtSetArg(args[0], XtNeditType, &edit_mode);
+ XtGetValues(src, args, 1);
+
+ if (edit_mode == XawtextAppend) {
+ if (block->length == 0)
+ return (XawEditError);
+ ctx->text.insertPos = ctx->text.lastPos;
+ }
+
+#ifndef OLDXAW
+ return (SrcReplace(src, left, right, block));
+#else
+ if (SrcReplace(src, left, right, block) == XawEditDone) {
+ _XawTextSourceChanged((Widget)ctx, left, right, block, 0);
+
+ return (XawEditDone);
+ }
+
+ return (XawEditError);
+#endif
+}
+
+/*
+ * This routine will display text between two arbitrary source positions.
+ * In the event that this span contains highlighted text for the selection,
+ * only that portion will be displayed highlighted.
+ */
+static void
+OldDisplayText(Widget w, XawTextPosition left, XawTextPosition right)
+{
+ static XmuSegment segment;
+ static XmuScanline next;
+ static XmuScanline scanline = {0, &segment, &next};
+ static XmuArea area = {&scanline};
+
+ TextWidget ctx = (TextWidget)w;
+ int x, y, line;
+ XawTextPosition start, end, last, final;
+ XmuScanline *scan;
+ XmuSegment *seg;
+ XmuArea *clip = NULL;
+ Bool cleol = ctx->text.clear_to_eol;
+ Bool has_selection = ctx->text.s.right > ctx->text.s.left;
+
+ left = left < ctx->text.lt.top ? ctx->text.lt.top : left;
+
+ if (left > right || !LineAndXYForPosition(ctx, left, &line, &x, &y))
+ return;
+
+ last = XawTextGetLastPosition(ctx);
+ segment.x2 = (int)XtWidth(ctx) - ctx->text.r_margin.right;
+
+ if (cleol)
+ clip = XmuCreateArea();
+
+ for (start = left; start < right && line < ctx->text.lt.lines; line++) {
+ if ((end = ctx->text.lt.info[line + 1].position) > right)
+ end = right;
+
+ final = end;
+ if (end > last)
+ end = last;
+
+ if (end > start) {
+ if (!has_selection
+ || (start >= ctx->text.s.right || end <= ctx->text.s.left))
+ _XawTextSinkDisplayText(ctx->text.sink, x, y, start, end, False);
+ else if (start >= ctx->text.s.left && end <= ctx->text.s.right)
+ _XawTextSinkDisplayText(ctx->text.sink, x, y, start, end, True);
+ else {
+ OldDisplayText(w, start, ctx->text.s.left);
+ OldDisplayText(w, Max(start, ctx->text.s.left),
+ Min(end, ctx->text.s.right));
+ OldDisplayText(w, ctx->text.s.right, end);
+ }
+ }
+
+ x = ctx->text.left_margin;
+ if (cleol) {
+ segment.x1 = ctx->text.lt.info[line].textWidth + x;
+ if (XmuValidSegment(&segment)) {
+ scanline.y = y;
+ next.y = ctx->text.lt.info[line + 1].y;
+ XmuAreaOr(clip, &area);
+ }
+ }
+
+ start = final;
+ y = ctx->text.lt.info[line + 1].y;
+ }
+
+ if (cleol) {
+ for (scan = clip->scanline; scan && scan->next; scan = scan->next)
+ for (seg = scan->segment; seg; seg = seg->next)
+ SinkClearToBG(ctx->text.sink,
+ seg->x1, scan->y,
+ seg->x2 - seg->x1, scan->next->y - scan->y);
+ XmuDestroyArea(clip);
+ }
+}
+
+#ifndef OLDXAW
+/*ARGSUSED*/
+static void
+DisplayText(Widget w, XawTextPosition left, XawTextPosition right)
+{
+ static XmuSegment segment;
+ static XmuScanline next;
+ static XmuScanline scanline = {0, &segment, &next};
+ static XmuArea area = {&scanline};
+
+ TextWidget ctx = (TextWidget)w;
+ int y, line;
+ XawTextPosition from, to, lastPos;
+ Bool cleol = ctx->text.clear_to_eol;
+ Bool has_selection = ctx->text.s.right > ctx->text.s.left;
+ XawTextPaintList *paint_list;
+
+ left = left < ctx->text.lt.top ? ctx->text.lt.top : left;
+
+ if (left > right || !IsPositionVisible(ctx, left))
+ return;
+
+ line = LineForPosition(ctx, left);
+ y = ctx->text.lt.info[line].y;
+ segment.x2 = (int)XtWidth(ctx) - ctx->text.r_margin.right;
+ lastPos = XawTextGetLastPosition(ctx);
+
+ paint_list = ((TextSinkObject)ctx->text.sink)->text_sink.paint;
+
+ for (from = left; from < right && line < ctx->text.lt.lines; line++) {
+ if ((to = ctx->text.lt.info[line + 1].position) > right)
+ to = right;
+
+ if (to > lastPos)
+ to = lastPos;
+
+ if (from < to) {
+ if (!has_selection
+ || (from >= ctx->text.s.right || to <= ctx->text.s.left))
+ XawTextSinkPreparePaint(ctx->text.sink, y, line, from, to, False);
+ else if (from >= ctx->text.s.left && to <= ctx->text.s.right)
+ XawTextSinkPreparePaint(ctx->text.sink, y, line, from, to, True);
+ else {
+ XawTextSinkPreparePaint(ctx->text.sink, y, line, from,
+ ctx->text.s.left, False);
+ XawTextSinkPreparePaint(ctx->text.sink, y, line,
+ XawMax(from, ctx->text.s.left),
+ XawMin(to, ctx->text.s.right), True);
+ XawTextSinkPreparePaint(ctx->text.sink, y, line,
+ ctx->text.s.right, to, False);
+ }
+ }
+
+ if (cleol) {
+ segment.x1 = ctx->text.lt.info[line].textWidth + ctx->text.left_margin;
+ if (XmuValidSegment(&segment)) {
+ scanline.y = y;
+ next.y = ctx->text.lt.info[line + 1].y;
+ XmuAreaOr(paint_list->clip, &area);
+ }
+ }
+ y = ctx->text.lt.info[line + 1].y;
+ from = to;
+ }
+
+ /* clear to the bottom of the window */
+ if (cleol && line >= ctx->text.lt.lines) {
+ segment.x1 = ctx->text.left_margin;
+ if (XmuValidSegment(&segment)) {
+ scanline.y = y;
+ next.y = (int)XtHeight(ctx) - (int)ctx->text.margin.bottom;
+ XmuAreaOr(paint_list->clip, &area);
+ }
+ }
+}
+#endif
+
+/*
+ * This routine implements multi-click selection in a hardwired manner.
+ * It supports multi-click entity cycling (char, word, line, file) and mouse
+ * motion adjustment of the selected entitie (i.e. select a word then, with
+ * button still down, adjust wich word you really meant by moving the mouse).
+ * [NOTE: This routine is to be replaced by a set of procedures that
+ * will allows clients to implements a wide class of draw through and
+ * multi-click selection user interfaces.]
+ */
+static void
+DoSelection(TextWidget ctx, XawTextPosition pos, Time time, Bool motion)
+{
+ XawTextPosition newLeft, newRight;
+ XawTextSelectType newType, *sarray;
+ Widget src = ctx->text.source;
+
+ if (motion)
+ newType = ctx->text.s.type;
+ else {
+ if ((abs((long) time - (long) ctx->text.lasttime) < MULTI_CLICK_TIME)
+ && (pos >= ctx->text.s.left && pos <= ctx->text.s.right)) {
+ sarray = ctx->text.sarray;
+ for (; *sarray != XawselectNull && *sarray != ctx->text.s.type;
+ sarray++)
+ ;
+ if (*sarray == XawselectNull)
+ newType = *(ctx->text.sarray);
+ else {
+ newType = *(sarray + 1);
+ if (newType == XawselectNull)
+ newType = *(ctx->text.sarray);
+ }
+ }
+ else /* single-click event */
+ newType = *(ctx->text.sarray);
+
+ ctx->text.lasttime = time;
+ }
+ switch (newType) {
+ case XawselectPosition:
+ newLeft = newRight = pos;
+ break;
+ case XawselectChar:
+ newLeft = pos;
+ newRight = SrcScan(src, pos, XawstPositions, XawsdRight, 1, False);
+ break;
+ case XawselectWord:
+ case XawselectParagraph:
+ case XawselectAlphaNumeric: {
+ XawTextScanType stype;
+
+ if (newType == XawselectWord)
+ stype = XawstWhiteSpace;
+ else if (newType == XawselectParagraph)
+ stype = XawstParagraph;
+ else
+ stype = XawstAlphaNumeric;
+
+ /*
+ * Somewhat complicated, but basically I treat the space between
+ * two objects as another object. The object that I am currently
+ * in then becomes the end of the selection.
+ *
+ * Chris Peterson - 4/19/90.
+ */
+ newRight = SrcScan(ctx->text.source, pos, stype,
+ XawsdRight, 1, False);
+ newRight = SrcScan(ctx->text.source, newRight, stype,
+ XawsdLeft, 1, False);
+
+ if (pos != newRight)
+ newLeft = SrcScan(ctx->text.source, pos, stype,
+ XawsdLeft, 1, False);
+ else
+ newLeft = pos;
+
+ newLeft =SrcScan(ctx->text.source, newLeft, stype,
+ XawsdRight, 1, False);
+
+ if (newLeft > newRight) {
+ XawTextPosition temp = newLeft;
+ newLeft = newRight;
+ newRight = temp;
+ }
+ } break;
+ case XawselectLine:
+ newLeft = SrcScan(src, pos, XawstEOL, XawsdLeft, 1, False);
+ newRight = SrcScan(src, pos, XawstEOL, XawsdRight, 1, False);
+ break;
+ case XawselectAll:
+ newLeft = SrcScan(src, pos, XawstAll, XawsdLeft, 1, False);
+ newRight = SrcScan(src, pos, XawstAll, XawsdRight, 1, False);
+ break;
+ default:
+ XtAppWarning(XtWidgetToApplicationContext((Widget) ctx),
+ "Text Widget: empty selection array.");
+ return;
+ }
+
+ if (newLeft != ctx->text.s.left || newRight != ctx->text.s.right
+ || newType != ctx->text.s.type) {
+ ModifySelection(ctx, newLeft, newRight);
+ if (pos - ctx->text.s.left < ctx->text.s.right - pos)
+ ctx->text.insertPos = newLeft;
+ else
+ ctx->text.insertPos = newRight;
+ ctx->text.s.type = newType;
+ }
+ if (!motion) { /* setup so we can freely mix select extend calls*/
+ ctx->text.origSel.type = ctx->text.s.type;
+ ctx->text.origSel.left = ctx->text.s.left;
+ ctx->text.origSel.right = ctx->text.s.right;
+
+ if (pos >= ctx->text.s.left + (ctx->text.s.right - ctx->text.s.left) / 2)
+ ctx->text.extendDir = XawsdRight;
+ else
+ ctx->text.extendDir = XawsdLeft;
+ }
+}
+
+/*
+ * This routine implements extension of the currently selected text in
+ * the "current" mode (i.e. char word, line, etc.). It worries about
+ * extending from either end of the selection and handles the case when you
+ * cross through the "center" of the current selection (e.g. switch which
+ * end you are extending!).
+ */
+static void
+ExtendSelection(TextWidget ctx, XawTextPosition pos, Bool motion)
+{
+ XawTextScanDirection dir;
+
+ if (!motion) { /* setup for extending selection */
+ if (ctx->text.s.left == ctx->text.s.right) /* no current selection. */
+ ctx->text.s.left = ctx->text.s.right = ctx->text.insertPos;
+ else {
+ ctx->text.origSel.left = ctx->text.s.left;
+ ctx->text.origSel.right = ctx->text.s.right;
+ }
+
+ ctx->text.origSel.type = ctx->text.s.type;
+
+ if (pos >= ctx->text.s.left + (ctx->text.s.right - ctx->text.s.left) / 2)
+ ctx->text.extendDir = XawsdRight;
+ else
+ ctx->text.extendDir = XawsdLeft;
+ }
+ else /* check for change in extend direction */
+ if ((ctx->text.extendDir == XawsdRight &&
+ pos <= ctx->text.origSel.left) ||
+ (ctx->text.extendDir == XawsdLeft &&
+ pos >= ctx->text.origSel.right)) {
+ ctx->text.extendDir = (ctx->text.extendDir == XawsdRight) ?
+ XawsdLeft : XawsdRight;
+ ModifySelection(ctx, ctx->text.origSel.left, ctx->text.origSel.right);
+ }
+
+ dir = ctx->text.extendDir;
+ switch (ctx->text.s.type) {
+ case XawselectWord:
+ case XawselectParagraph:
+ case XawselectAlphaNumeric: {
+ XawTextPosition left_pos, right_pos;
+ XawTextScanType stype;
+
+ if (ctx->text.s.type == XawselectWord)
+ stype = XawstWhiteSpace;
+ else if (ctx->text.s.type == XawselectParagraph)
+ stype = XawstParagraph;
+ else
+ stype = XawstAlphaNumeric;
+
+ /*
+ * Somewhat complicated, but basically I treat the space between
+ * two objects as another object. The object that I am currently
+ * in then becomes the end of the selection.
+ *
+ * Chris Peterson - 4/19/90.
+ */
+ right_pos = SrcScan(ctx->text.source, pos, stype,
+ XawsdRight, 1, False);
+ right_pos =SrcScan(ctx->text.source, right_pos, stype,
+ XawsdLeft, 1, False);
+
+ if (pos != right_pos)
+ left_pos = SrcScan(ctx->text.source, pos, stype,
+ XawsdLeft, 1, False);
+ else
+ left_pos = pos;
+
+ left_pos =SrcScan(ctx->text.source, left_pos, stype,
+ XawsdRight, 1, False);
+
+ if (dir == XawsdLeft)
+ pos = Min(left_pos, right_pos);
+ else /* dir == XawsdRight */
+ pos = Max(left_pos, right_pos);
+ } break;
+ case XawselectLine:
+ pos = SrcScan(ctx->text.source, pos, XawstEOL,
+ dir, 1, dir == XawsdRight);
+ break;
+ case XawselectAll:
+ pos = ctx->text.insertPos;
+ /*FALLTHROUGH*/
+ case XawselectPosition:
+ default:
+ break;
+ }
+
+ if (dir == XawsdRight)
+ ModifySelection(ctx, ctx->text.s.left, pos);
+ else
+ ModifySelection(ctx, pos, ctx->text.s.right);
+
+ ctx->text.insertPos = pos;
+}
+
+/*
+ * Function:
+ * _XawTextClearAndCenterDisplay
+ *
+ * Parameters:
+ * ctx - text widget
+ *
+ * Description:
+ * Redraws the display with the cursor in insert point
+ * centered vertically.
+ */
+void
+_XawTextClearAndCenterDisplay(TextWidget ctx)
+{
+ int left_margin = ctx->text.left_margin;
+ Bool visible = IsPositionVisible(ctx, ctx->text.insertPos);
+
+ _XawTextShowPosition(ctx);
+
+ if (XtIsRealized((Widget)ctx) && visible &&
+ left_margin == ctx->text.left_margin) {
+ int insert_line = LineForPosition(ctx, ctx->text.insertPos);
+ int scroll_by = insert_line - (ctx->text.lt.lines >> 1);
+ Boolean clear_to_eol = ctx->text.clear_to_eol;
+
+ XawTextScroll(ctx, scroll_by, 0);
+ SinkClearToBG(ctx->text.sink, 0, 0, XtWidth(ctx), XtHeight(ctx));
+ ClearWindow(ctx);
+ clear_to_eol = ctx->text.clear_to_eol;
+ ctx->text.clear_to_eol = False;
+ FlushUpdate(ctx);
+ ctx->text.clear_to_eol = clear_to_eol;
+ }
+}
+
+/*
+ * Internal redisplay entire window
+ * Legal to call only if widget is realized
+ */
+static void
+DisplayTextWindow(Widget w)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ _XawTextBuildLineTable(ctx, ctx->text.lt.top, False);
+ ClearWindow(ctx);
+}
+
+static void
+TextSinkResize(Widget w)
+{
+ if (w && XtClass(w)->core_class.resize)
+ XtClass(w)->core_class.resize(w);
+}
+
+/* ARGSUSED */
+void
+_XawTextCheckResize(TextWidget ctx)
+{
+ return;
+}
+
+/*
+ * Converts (params, num_params) to a list of atoms & caches the
+ * list in the TextWidget instance.
+ */
+Atom *
+_XawTextSelectionList(TextWidget ctx, String *list, Cardinal nelems)
+{
+ Atom *sel = ctx->text.s.selections;
+ Display *dpy = XtDisplay((Widget)ctx);
+ int n;
+
+ if (nelems > (Cardinal)ctx->text.s.array_size) {
+ sel = (Atom *)XtRealloc((char *)sel, sizeof(Atom) * nelems);
+ ctx->text.s.array_size = nelems;
+ ctx->text.s.selections = sel;
+ }
+ for (n = nelems; --n >= 0; sel++, list++)
+ *sel = XInternAtom(dpy, *list, False);
+ ctx->text.s.atom_count = nelems;
+
+ return (ctx->text.s.selections);
+}
+
+/*
+ * Function:
+ * SetSelection
+ *
+ * Parameters:
+ * ctx - text widget
+ * defaultSel - default selection
+ * l - left and right ends of the selection
+ * r - ""
+ * list - the selection list (as strings).
+ * nelems - ""
+ *
+ * Description:
+ * Sets the current selection.
+ *
+ * Note:
+ * if (ctx->text.s.left >= ctx->text.s.right) then the selection is unset
+ */
+void
+_XawTextSetSelection(TextWidget ctx, XawTextPosition l, XawTextPosition r,
+ String *list, Cardinal nelems)
+{
+ if (nelems == 1 && !strcmp (list[0], "none"))
+ return;
+ if (nelems == 0) {
+ String defaultSel = "PRIMARY";
+ list = &defaultSel;
+ nelems = 1;
+ }
+ _SetSelection(ctx, l, r, _XawTextSelectionList(ctx, list, nelems), nelems);
+}
+
+/*
+ * Function:
+ * ModifySelection
+ *
+ * Parameters:
+ * ctx - text widget
+ * left - left and right ends of the selection
+ * right - ""
+ *
+ * Description:
+ * Modifies the current selection.
+ *
+ * Note:
+ * if (ctx->text.s.left >= ctx->text.s.right) then the selection is unset
+ */
+static void
+ModifySelection(TextWidget ctx, XawTextPosition left, XawTextPosition right)
+{
+ if (left == right)
+ ctx->text.insertPos = left;
+ _SetSelection(ctx, left, right, NULL, 0);
+}
+
+/*
+ * This routine is used to perform various selection functions. The goal is
+ * to be able to specify all the more popular forms of draw-through and
+ * multi-click selection user interfaces from the outside.
+ */
+void
+_XawTextAlterSelection(TextWidget ctx, XawTextSelectionMode mode,
+ XawTextSelectionAction action, String *params,
+ Cardinal *num_params)
+{
+ XawTextPosition position;
+ Boolean flag;
+
+ /*
+ * This flag is used by TextPop.c:DoReplace() to determine if the selection
+ * is okay to use, or if it has been modified.
+ */
+ if (ctx->text.search != NULL)
+ ctx->text.search->selection_changed = True;
+
+ position = PositionForXY(ctx, (int) ctx->text.ev_x, (int) ctx->text.ev_y);
+
+ flag = (action != XawactionStart);
+ if (mode == XawsmTextSelect)
+ DoSelection(ctx, position, ctx->text.time, flag);
+ else /* mode == XawsmTextExtend */
+ ExtendSelection (ctx, position, flag);
+
+ if (action == XawactionEnd)
+ _XawTextSetSelection(ctx, ctx->text.s.left, ctx->text.s.right,
+ params, *num_params);
+}
+
+/*
+ * Function:
+ * UpdateTextInRectangle
+ *
+ * Parameters:
+ * ctx - the text widget
+ * rect - rectangle
+ *
+ * Description:
+ * Updates the text in the given rectangle
+ */
+static void
+UpdateTextInRectangle(TextWidget ctx, XRectangle *rect)
+{
+ XawTextLineTable *lt;
+ int line, y1, y2, x2;
+
+ y1 = rect->y;
+ y2 = y1 + rect->height;
+ x2 = rect->x + rect->width;
+
+ for (line = 0, lt = &ctx->text.lt; line < lt->lines; line++)
+ if (lt->info[line + 1].y > y1)
+ break;
+ for (; line <= lt->lines; line++) {
+ if (lt->info[line].y > y2)
+ break;
+ UpdateTextInLine(ctx, line, rect->x, x2);
+ }
+}
+
+/*
+ * This routine processes all "expose region" XEvents. In general, its job
+ * is to the best job at minimal re-paint of the text, displayed in the
+ * window, that it can.
+ */
+/* ARGSUSED */
+static void
+XawTextExpose(Widget w, XEvent *event, Region region)
+{
+ TextWidget ctx = (TextWidget)w;
+ Boolean clear_to_eol;
+ XRectangle expose;
+
+ if (event->type == Expose) {
+ expose.x = event->xexpose.x;
+ expose.y = event->xexpose.y;
+ expose.width = event->xexpose.width;
+ expose.height = event->xexpose.height;
+ }
+ else if (event->type == GraphicsExpose) {
+ expose.x = event->xgraphicsexpose.x;
+ expose.y = event->xgraphicsexpose.y;
+ expose.width = event->xgraphicsexpose.width;
+ expose.height = event->xgraphicsexpose.height;
+ }
+ else
+ return;
+
+ _XawTextPrepareToUpdate(ctx);
+
+ if (Superclass->core_class.expose)
+ (*Superclass->core_class.expose)(w, event, region);
+
+ clear_to_eol = ctx->text.clear_to_eol;
+ ctx->text.clear_to_eol = False;
+
+ UpdateTextInRectangle(ctx, &expose);
+ XawTextSinkGetCursorBounds(ctx->text.sink, &expose);
+ UpdateTextInRectangle(ctx, &expose);
+ SinkClearToBG(ctx->text.sink, expose.x, expose.y,
+ expose.width, expose.height);
+ _XawTextExecuteUpdate(ctx);
+ ctx->text.clear_to_eol = clear_to_eol;
+}
+
+/*
+ * This routine does all setup required to syncronize batched screen updates
+ */
+void
+_XawTextPrepareToUpdate(TextWidget ctx)
+{
+ if (ctx->text.old_insert < 0) {
+ InsertCursor((Widget)ctx, XawisOff);
+ ctx->text.showposition = False;
+ ctx->text.old_insert = ctx->text.insertPos;
+ ctx->text.clear_to_eol = False;
+#ifndef OLDXAW
+ ctx->text.source_changed = SRC_CHANGE_NONE;
+#endif
+ }
+}
+
+/*
+ * This is a private utility routine used by _XawTextExecuteUpdate. It
+ * processes all the outstanding update requests and merges update
+ * ranges where possible.
+ */
+static void
+FlushUpdate(TextWidget ctx)
+{
+ XmuSegment *seg;
+ void (*display_text)(Widget, XawTextPosition, XawTextPosition);
+
+ if (XtIsRealized((Widget)ctx)) {
+ ctx->text.s.right = XawMin(ctx->text.s.right, ctx->text.lastPos);
+ ctx->text.s.left = XawMin(ctx->text.s.left, ctx->text.s.right);
+
+#ifndef OLDXAW
+ if (XawTextSinkBeginPaint(ctx->text.sink) == False)
+#endif
+ display_text = OldDisplayText;
+#ifndef OLDXAW
+ else
+ display_text = DisplayText;
+#endif
+ for (seg = ctx->text.update->segment; seg; seg = seg->next)
+ (*display_text)((Widget)ctx,
+ (XawTextPosition)seg->x1,
+ (XawTextPosition)seg->x2);
+#ifndef OLDXAW
+ if (display_text != OldDisplayText) {
+ XawTextSinkDoPaint(ctx->text.sink);
+ XawTextSinkEndPaint(ctx->text.sink);
+ }
+#endif
+ }
+ (void)XmuScanlineXor(ctx->text.update, ctx->text.update);
+}
+
+static int
+CountLines(TextWidget ctx, XawTextPosition left, XawTextPosition right)
+{
+ if (ctx->text.wrap == XawtextWrapNever || left >= right)
+ return (1);
+ else {
+ XawTextPosition tmp;
+ int dim, lines = 0, wwidth = GetMaxTextWidth(ctx);
+
+ while (left < right) {
+ tmp = left;
+ XawTextSinkFindPosition(ctx->text.sink, left,
+ ctx->text.left_margin,
+ wwidth, ctx->text.wrap == XawtextWrapWord,
+ &left, &dim, &dim);
+ ++lines;
+ if (tmp == left)
+ ++left;
+ }
+
+ return (lines);
+ }
+ /*NOTREACHED*/
+}
+
+static int
+GetMaxTextWidth(TextWidget ctx)
+{
+ XRectangle cursor;
+ int width;
+
+ XawTextSinkGetCursorBounds(ctx->text.sink, &cursor);
+ width = (int)XtWidth(ctx) - RHMargins(ctx) - cursor.width;
+
+ return (XawMax(0, width));
+}
+
+/*
+ * Function:
+ * _XawTextShowPosition
+ *
+ * Parameters:
+ * ctx - the text widget to show the position
+ *
+ * Description:
+ * Makes sure the text cursor visible, scrolling the text window
+ * if required.
+ */
+void
+_XawTextShowPosition(TextWidget ctx)
+{
+ /*
+ * Variable scroll is used to avoid scanning large files to calculate
+ * line offsets
+ */
+ int hpixels, vlines;
+ XawTextPosition first, last, top, tmp;
+ Bool visible, scroll;
+
+ if (!XtIsRealized((Widget)ctx))
+ return;
+
+ /*
+ * Checks if a horizontal scroll is required
+ */
+ if (ctx->text.wrap == XawtextWrapNever) {
+ int x, vwidth, distance, dim;
+ XRectangle rect;
+
+ vwidth = (int)XtWidth(ctx) - RHMargins(ctx);
+ last = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstEOL, XawsdLeft, 1, False);
+ XawTextSinkFindDistance(ctx->text.sink, last,
+ ctx->text.left_margin,
+ ctx->text.insertPos,
+ &distance, &first, &dim);
+ XawTextSinkGetCursorBounds(ctx->text.sink, &rect);
+ x = ctx->text.left_margin - ctx->text.r_margin.left;
+
+ if (x + distance + rect.width > vwidth)
+ hpixels = x + distance + rect.width - vwidth + (vwidth >> 2);
+ else if (x + distance < 0)
+ hpixels = x + distance - (vwidth >> 2);
+ else
+ hpixels = 0;
+ }
+ else
+ hpixels = 0;
+
+ visible = IsPositionVisible(ctx, ctx->text.insertPos);
+
+ /*
+ * If the cursor is already visible
+ */
+ if (!hpixels && visible)
+ return;
+
+ scroll = ctx->core.background_pixmap == XtUnspecifiedPixmap && !hpixels;
+ vlines = 0;
+ first = ctx->text.lt.top;
+
+ /*
+ * Needs to scroll the text window
+ */
+ if (visible)
+ top = ctx->text.lt.top;
+ else {
+ top = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstEOL, XawsdLeft, 1, False);
+
+ /*
+ * Finds the nearest left position from ctx->text.insertPos
+ */
+ if (ctx->text.wrap != XawtextWrapNever) {
+ int dim, vwidth = GetMaxTextWidth(ctx);
+
+ last = top;
+ /*CONSTCOND*/
+ while (1) {
+ tmp = last;
+ XawTextSinkFindPosition(ctx->text.sink, last,
+ ctx->text.left_margin, vwidth,
+ ctx->text.wrap == XawtextWrapWord,
+ &last, &dim, &dim);
+ if (last == tmp)
+ ++last;
+ if (last <= ctx->text.insertPos)
+ top = last;
+ else
+ break;
+ }
+ }
+ }
+
+ if (scroll) {
+ if (ctx->text.insertPos < first) { /* Scroll Down */
+ while (first > top) {
+ last = first;
+ first = SrcScan(ctx->text.source, first,
+ XawstEOL, XawsdLeft, 2, False);
+ vlines -= CountLines(ctx, first, last);
+ if (-vlines >= ctx->text.lt.lines) {
+ scroll = False;
+ break;
+ }
+ }
+ }
+ else if (!visible) { /* Scroll Up */
+ while (first < top) {
+ last = first;
+ first = SrcScan(ctx->text.source, first,
+ XawstEOL, XawsdRight, 1, True);
+ vlines += CountLines(ctx, last, first);
+ if (vlines > ctx->text.lt.lines) {
+ scroll = False;
+ break;
+ }
+ }
+ }
+ else
+ scroll = False;
+ }
+
+ /*
+ * If a portion of the text that will be scrolled is visible
+ */
+ if (scroll)
+ XawTextScroll(ctx, vlines ? vlines - (ctx->text.lt.lines >> 1) : 0, 0);
+ /*
+ * Else redraw the entire text window
+ */
+ else {
+ ctx->text.left_margin -= hpixels;
+ if (ctx->text.left_margin > ctx->text.r_margin.left)
+ ctx->text.left_margin = ctx->text.margin.left =
+ ctx->text.r_margin.left;
+
+ if (!visible) {
+ vlines = ctx->text.lt.lines >> 1;
+ if (vlines)
+ top = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstEOL, XawsdLeft, vlines + 1, False);
+
+ if (ctx->text.wrap != XawtextWrapNever) {
+ int dim;
+ int n_lines = CountLines(ctx, top, ctx->text.insertPos);
+ int vwidth = GetMaxTextWidth(ctx);
+
+ while (n_lines-- > vlines) {
+ tmp = top;
+ XawTextSinkFindPosition(ctx->text.sink, top,
+ ctx->text.left_margin,
+ vwidth,
+ ctx->text.wrap == XawtextWrapWord,
+ &top, &dim, &dim);
+ if (tmp == top)
+ ++top;
+ }
+ }
+ _XawTextBuildLineTable(ctx, top, True);
+ }
+ else
+ ClearWindow(ctx);
+ }
+ ctx->text.clear_to_eol = True;
+}
+
+#ifndef OLDXAW
+static int
+ResolveLineNumber(TextWidget ctx)
+{
+ int line_number = ctx->text.lt.base_line;
+ XawTextPosition position = ctx->text.lt.top;
+
+ if (ctx->text.lt.base_line < 1)
+ return (ctx->text.line_number);
+
+ if (ctx->text.wrap == XawtextWrapNever
+ && IsPositionVisible(ctx, ctx->text.insertPos))
+ line_number += LineForPosition(ctx, ctx->text.insertPos);
+ else if (position < ctx->text.insertPos) {
+ while (position < ctx->text.insertPos) {
+ position = SrcScan(ctx->text.source, position,
+ XawstEOL, XawsdRight, 1, True);
+ if (position <= ctx->text.insertPos) {
+ ++line_number;
+ if (position == ctx->text.lastPos) {
+ line_number -= !_XawTextSourceNewLineAtEOF(ctx->text.source);
+ break;
+ }
+ }
+ }
+ }
+ else if (position > ctx->text.insertPos) {
+ while (position > ctx->text.insertPos) {
+ position = SrcScan(ctx->text.source, position,
+ XawstEOL, XawsdLeft, 1, False);
+ if (--position >= ctx->text.insertPos)
+ --line_number;
+ }
+ }
+
+ return (line_number);
+}
+#endif
+
+/*
+ * This routine causes all batched screen updates to be performed
+ */
+void
+_XawTextExecuteUpdate(TextWidget ctx)
+{
+ if (ctx->text.update_disabled || ctx->text.old_insert < 0)
+ return;
+
+ if(ctx->text.old_insert != ctx->text.insertPos || ctx->text.showposition)
+ _XawTextShowPosition(ctx);
+
+ FlushUpdate(ctx);
+ InsertCursor((Widget)ctx, XawisOn);
+ ctx->text.old_insert = -1;
+#ifndef OLDXAW
+ _XawTextSetLineAndColumnNumber(ctx, False);
+#endif
+}
+
+static void
+XawTextDestroy(Widget w)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ DestroyHScrollBar(ctx);
+ DestroyVScrollBar(ctx);
+
+ XtFree((char *)ctx->text.s.selections);
+ XtFree((char *)ctx->text.lt.info);
+ XtFree((char *)ctx->text.search);
+ XmuDestroyScanline(ctx->text.update);
+ XtReleaseGC((Widget)ctx, ctx->text.gc);
+}
+
+/*
+ * by the time we are managed (and get this far) we had better
+ * have both a source and a sink
+ */
+static void
+XawTextResize(Widget w)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ PositionVScrollBar(ctx);
+ PositionHScrollBar(ctx);
+ TextSinkResize(ctx->text.sink);
+
+ ctx->text.showposition = True;
+ _XawTextBuildLineTable(ctx, ctx->text.lt.top, True);
+}
+
+/*
+ * This routine allow the application program to Set attributes.
+ */
+/*ARGSUSED*/
+static Boolean
+XawTextSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ TextWidget oldtw = (TextWidget)current;
+ TextWidget newtw = (TextWidget)cnew;
+ Boolean redisplay = False;
+ Boolean display_caret = newtw->text.display_caret;
+#ifndef OLDXAW
+ Boolean show_lc = False;
+#endif
+
+ newtw->text.display_caret = oldtw->text.display_caret;
+ _XawTextPrepareToUpdate(newtw);
+ newtw->text.display_caret = display_caret;
+
+ if (oldtw->text.r_margin.left != newtw->text.r_margin.left) {
+ newtw->text.left_margin = newtw->text.margin.left =
+ newtw->text.r_margin.left;
+ if (newtw->text.vbar != NULL) {
+ newtw->text.left_margin += XtWidth(newtw->text.vbar) +
+ XtBorderWidth(newtw->text.vbar);
+ }
+ redisplay = True;
+ }
+
+ if (oldtw->text.scroll_vert != newtw->text.scroll_vert) {
+ if (newtw->text.scroll_vert == XawtextScrollAlways)
+ CreateVScrollBar(newtw);
+ else
+ DestroyVScrollBar(newtw);
+
+ redisplay = True;
+ }
+
+ if (oldtw->text.r_margin.bottom != newtw->text.r_margin.bottom) {
+ newtw->text.margin.bottom = newtw->text.r_margin.bottom;
+ if (newtw->text.hbar != NULL)
+ newtw->text.margin.bottom += newtw->text.hbar->core.height +
+ newtw->text.hbar->core.border_width;
+ redisplay = True;
+ }
+
+ if (oldtw->text.scroll_horiz != newtw->text.scroll_horiz) {
+ if (newtw->text.scroll_horiz == XawtextScrollAlways)
+ CreateHScrollBar(newtw);
+ else
+ DestroyHScrollBar(newtw);
+
+ redisplay = True;
+ }
+
+ if (oldtw->text.source != newtw->text.source) {
+#ifndef OLDXAW
+ show_lc = True;
+ _XawSourceRemoveText(oldtw->text.source, cnew,
+ oldtw->text.source &&
+ XtParent(oldtw->text.source) == cnew);
+ _XawSourceAddText(newtw->text.source, cnew);
+#endif
+ _XawTextSetSource((Widget)newtw, newtw->text.source, newtw->text.lt.top,
+ newtw->text.insertPos);
+ }
+
+ newtw->text.redisplay_needed = False;
+ XtSetValues((Widget)newtw->text.source, args, *num_args);
+ XtSetValues((Widget)newtw->text.sink, args, *num_args);
+
+ if (oldtw->text.wrap != newtw->text.wrap
+ || oldtw->text.lt.top != newtw->text.lt.top
+ || oldtw->text.insertPos != newtw->text.insertPos
+ || oldtw->text.r_margin.right != newtw->text.r_margin.right
+ || oldtw->text.r_margin.top != newtw->text.r_margin.top
+ || oldtw->text.sink != newtw->text.sink
+ || newtw->text.redisplay_needed) {
+ if (oldtw->text.wrap != newtw->text.wrap) {
+ newtw->text.left_margin = newtw->text.margin.left =
+ newtw->text.r_margin.left;
+ if (oldtw->text.lt.top == newtw->text.lt.top)
+ newtw->text.lt.top = SrcScan(newtw->text.source, 0, XawstEOL,
+ XawsdLeft, 1, False);
+ }
+ newtw->text.showposition = True;
+#ifndef OLDXAW
+ show_lc = True;
+ newtw->text.source_changed = SRC_CHANGE_OVERLAP;
+#endif
+ _XawTextBuildLineTable(newtw, newtw->text.lt.top, True);
+ redisplay = True;
+ }
+
+#ifndef OLDXAW
+ if (newtw->text.left_column < 0)
+ newtw->text.left_column = 0;
+ if (newtw->text.right_column < 0)
+ newtw->text.right_column = 0;
+#endif
+
+ _XawTextExecuteUpdate(newtw);
+
+#ifndef OLDXAW
+ if (show_lc)
+ _XawTextSetLineAndColumnNumber(newtw, True);
+#endif
+
+ if (redisplay)
+ _XawTextSetScrollBars(newtw);
+
+ return (redisplay);
+}
+
+/* invoked by the Simple widget's SetValues */
+static Bool
+XawTextChangeSensitive(Widget w)
+{
+ Arg args[1];
+ TextWidget tw = (TextWidget)w;
+
+ (*(&simpleClassRec)->simple_class.change_sensitive)(w);
+
+ XtSetArg(args[0], XtNancestorSensitive,
+ (tw->core.ancestor_sensitive && tw->core.sensitive));
+ if (tw->text.vbar)
+ XtSetValues(tw->text.vbar, args, ONE);
+ if (tw->text.hbar)
+ XtSetValues(tw->text.hbar, args, ONE);
+ return (False);
+}
+
+/*
+ * Function:
+ * XawTextGetValuesHook
+ *
+ * Parameters:
+ * w - Text Widget
+ * args - argument list
+ * num_args - number of args
+ *
+ * Description:
+ * This is a get values hook routine that gets the
+ * values in the text source and sink.
+ */
+static void
+XawTextGetValuesHook(Widget w, ArgList args, Cardinal *num_args)
+{
+ XtGetValues(((TextWidget)w)->text.source, args, *num_args);
+ XtGetValues(((TextWidget)w)->text.sink, args, *num_args);
+}
+
+/*
+ * Function:
+ * FindGoodPosition
+ *
+ * Parameters:
+ * pos - any position
+ *
+ * Description:
+ * Returns a valid position given any postition.
+ *
+ * Returns:
+ * A position between (0 and lastPos)
+ */
+static XawTextPosition
+FindGoodPosition(TextWidget ctx, XawTextPosition pos)
+{
+ if (pos < 0)
+ return (0);
+ return (((pos > ctx->text.lastPos) ? ctx->text.lastPos : pos));
+}
+
+/* Li wrote this so the IM can find a given text position's screen position */
+void
+_XawTextPosToXY(Widget w, XawTextPosition pos, Position *x, Position *y)
+{
+ int line, ix, iy;
+
+ LineAndXYForPosition((TextWidget)w, pos, &line, &ix, &iy);
+ *x = ix;
+ *y = iy;
+}
+
+/*******************************************************************
+The following routines provide procedural interfaces to Text window state
+setting and getting. They need to be redone so than the args code can use
+them. I suggest we create a complete set that takes the context as an
+argument and then have the public version lookup the context and call the
+internal one. The major value of this set is that they have actual application
+clients and therefore the functionality provided is required for any future
+version of Text.
+********************************************************************/
+void
+XawTextDisplay(Widget w)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ if (!XtIsRealized(w))
+ return;
+
+ _XawTextPrepareToUpdate(ctx);
+ ctx->text.clear_to_eol = True;
+ DisplayTextWindow(w);
+ _XawTextExecuteUpdate(ctx);
+}
+
+void
+XawTextSetSelectionArray(Widget w, XawTextSelectType *sarray)
+{
+ ((TextWidget)w)->text.sarray = sarray;
+}
+
+void
+XawTextGetSelectionPos(Widget w, XawTextPosition *left, XawTextPosition *right)
+{
+ *left = ((TextWidget)w)->text.s.left;
+ *right = ((TextWidget)w)->text.s.right;
+}
+
+void
+_XawTextSetSource(Widget w, Widget source,
+ XawTextPosition top, XawTextPosition startPos)
+{
+ TextWidget ctx = (TextWidget)w;
+#ifndef OLDXAW
+ Bool resolve = False;
+#endif
+
+#ifndef OLDXAW
+ if (source != ctx->text.source)
+ _XawSourceRemoveText(ctx->text.source, w, ctx->text.source &&
+ XtParent(ctx->text.source) == w);
+ _XawSourceAddText(source, w);
+
+ if (source != ctx->text.source || ctx->text.insertPos != startPos)
+ resolve = True;
+
+ ctx->text.source_changed = SRC_CHANGE_OVERLAP;
+#endif
+ ctx->text.source = source;
+ ctx->text.s.left = ctx->text.s.right = 0;
+ ctx->text.lastPos = GETLASTPOS;
+ top = FindGoodPosition(ctx, top);
+ startPos = FindGoodPosition(ctx, startPos);
+ ctx->text.insertPos = ctx->text.old_insert = startPos;
+ _XawTextPrepareToUpdate(ctx);
+
+ _XawTextBuildLineTable(ctx, top, True);
+
+ _XawTextExecuteUpdate(ctx);
+#ifndef OLDXAW
+ if (resolve)
+ _XawTextSetLineAndColumnNumber(ctx, True);
+#endif
+}
+
+void
+XawTextSetSource(Widget w, Widget source, XawTextPosition top)
+{
+ _XawTextSetSource(w, source, top, top);
+}
+
+/*
+ * This public routine deletes the text from startPos to endPos in a source and
+ * then inserts, at startPos, the text that was passed. As a side effect it
+ * "invalidates" that portion of the displayed text (if any), so that things
+ * will be repainted properly.
+ */
+int
+XawTextReplace(Widget w, XawTextPosition startPos, XawTextPosition endPos,
+ XawTextBlock *text)
+{
+ TextWidget ctx = (TextWidget)w;
+ int result;
+#ifndef OLDXAW
+ Cardinal i;
+ TextSrcObject src = (TextSrcObject)ctx->text.source;
+
+ for (i = 0; i < src->textSrc.num_text; i++)
+ _XawTextPrepareToUpdate((TextWidget)src->textSrc.text[i]);
+#else
+ _XawTextPrepareToUpdate(ctx);
+#endif
+
+ endPos = FindGoodPosition(ctx, endPos);
+ startPos = FindGoodPosition(ctx, startPos);
+ result = _XawTextReplace(ctx, startPos, endPos, text);
+
+#ifndef OLDXAW
+ for (i = 0; i < src->textSrc.num_text; i++)
+ _XawTextExecuteUpdate((TextWidget)src->textSrc.text[i]);
+#else
+ _XawTextExecuteUpdate(ctx);
+#endif
+
+ return (result);
+}
+
+XawTextPosition
+XawTextTopPosition(Widget w)
+{
+ return (((TextWidget)w)->text.lt.top);
+}
+
+XawTextPosition
+XawTextLastPosition(Widget w)
+{
+ return (((TextWidget)w)->text.lastPos);
+}
+
+void
+XawTextSetInsertionPoint(Widget w, XawTextPosition position)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ _XawTextPrepareToUpdate(ctx);
+ ctx->text.insertPos = FindGoodPosition(ctx, position);
+ ctx->text.showposition = True;
+ ctx->text.from_left = -1;
+
+ _XawTextExecuteUpdate(ctx);
+#ifndef OLDXAW
+ _XawTextSetLineAndColumnNumber(ctx, False);
+#endif
+}
+
+XawTextPosition
+XawTextGetInsertionPoint(Widget w)
+{
+ return (((TextWidget)w)->text.insertPos);
+}
+
+/*
+ * Note: Must walk the selection list in opposite order from TextLoseSelection
+ */
+void
+XawTextUnsetSelection(Widget w)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ while (ctx->text.s.atom_count != 0) {
+ Atom sel = ctx->text.s.selections[ctx->text.s.atom_count - 1];
+
+ if (sel != (Atom) 0) {
+ /*
+ * As selections are lost the atom_count will decrement
+ */
+ if (GetCutBufferNumber(sel) == NOT_A_CUT_BUFFER)
+ XtDisownSelection(w, sel, ctx->text.time);
+ TextLoseSelection(w, &sel); /* In case this is a cut buffer, or
+ XtDisownSelection failed to call us */
+ }
+ }
+}
+
+void
+XawTextSetSelection(Widget w, XawTextPosition left, XawTextPosition right)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ _XawTextPrepareToUpdate(ctx);
+ _XawTextSetSelection(ctx, FindGoodPosition(ctx, left),
+ FindGoodPosition(ctx, right), NULL, 0);
+ _XawTextExecuteUpdate(ctx);
+}
+
+void
+XawTextInvalidate(Widget w, XawTextPosition from, XawTextPosition to)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ from = FindGoodPosition(ctx, from);
+ to = FindGoodPosition(ctx, to);
+ ctx->text.lastPos = GETLASTPOS;
+ _XawTextPrepareToUpdate(ctx);
+ _XawTextNeedsUpdating(ctx, from, to);
+ _XawTextExecuteUpdate(ctx);
+}
+
+/*ARGSUSED*/
+void
+XawTextDisableRedisplay(Widget w)
+{
+ ((TextWidget)w)->text.update_disabled = True;
+ _XawTextPrepareToUpdate((TextWidget)w);
+}
+
+void
+XawTextEnableRedisplay(Widget w)
+{
+ TextWidget ctx = (TextWidget)w;
+ XawTextPosition lastPos;
+
+ if (!ctx->text.update_disabled)
+ return;
+
+ ctx->text.update_disabled = False;
+ lastPos = ctx->text.lastPos = GETLASTPOS;
+ ctx->text.lt.top = FindGoodPosition(ctx, ctx->text.lt.top);
+ ctx->text.insertPos = FindGoodPosition(ctx, ctx->text.insertPos);
+
+ if (ctx->text.s.left > lastPos || ctx->text.s.right > lastPos)
+ ctx->text.s.left = ctx->text.s.right = 0;
+
+ _XawTextExecuteUpdate(ctx);
+}
+
+Widget
+XawTextGetSource(Widget w)
+{
+ return (((TextWidget)w)->text.source);
+}
+
+Widget
+XawTextGetSink(Widget w)
+{
+ return (((TextWidget)w)->text.sink);
+}
+
+void
+XawTextDisplayCaret(Widget w,
+#if NeedWidePrototypes
+ int display_caret
+#else
+ Boolean display_caret
+#endif
+)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ if (XtIsRealized(w)) {
+ _XawTextPrepareToUpdate(ctx);
+ ctx->text.display_caret = display_caret;
+ _XawTextExecuteUpdate(ctx);
+ }
+ else
+ ctx->text.display_caret = display_caret;
+}
+
+/*
+ * Function:
+ * XawTextSearch
+ *
+ * Parameters:
+ * w - text widget
+ * dir - direction to search
+ * text - text block containing info about the string to search for
+ *
+ * Description:
+ * Searches for the given text block.
+ *
+ * Returns:
+ * The position of the text found, or XawTextSearchError on an error
+ */
+XawTextPosition
+XawTextSearch(Widget w,
+#if NeedWidePrototypes
+ int dir,
+#else
+ XawTextScanDirection dir,
+#endif
+ XawTextBlock *text)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ return (SrcSearch(ctx->text.source, ctx->text.insertPos, dir, text));
+}
+
+TextClassRec textClassRec = {
+ /* core */
+ {
+ (WidgetClass)&simpleClassRec, /* superclass */
+ "Text", /* class_name */
+ sizeof(TextRec), /* widget_size */
+ XawTextClassInitialize, /* class_initialize */
+ NULL, /* class_part_init */
+ False, /* class_inited */
+ XawTextInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XawTextRealize, /* realize */
+ _XawTextActionsTable, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resource */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ XtExposeGraphicsExpose | /* compress_exposure */
+ XtExposeNoExpose,
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ XawTextDestroy, /* destroy */
+ XawTextResize, /* resize */
+ XawTextExpose, /* expose */
+ XawTextSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ XawTextGetValuesHook, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ _XawDefaultTextTranslations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* simple */
+ {
+ XawTextChangeSensitive, /* change_sensitive */
+ },
+ /* text */
+ {
+ NULL, /* extension */
+ }
+};
+
+WidgetClass textWidgetClass = (WidgetClass)&textClassRec;
diff --git a/nx-X11/lib/Xaw/Text.h b/nx-X11/lib/Xaw/Text.h
new file mode 100644
index 000000000..af80ffcdb
--- /dev/null
+++ b/nx-X11/lib/Xaw/Text.h
@@ -0,0 +1,373 @@
+/* $Xorg: Text.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Text.h,v 1.14 2001/01/17 19:42:34 dawes Exp $ */
+
+#ifndef _XawText_h
+#define _XawText_h
+
+#include <X11/Xaw/Simple.h>
+
+/*
+
+ Class: textWidgetClass
+ Class Name: Text
+ Superclass: Simple
+
+ Resources added by the Text widget:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ autoFill AutoFill Boolean False
+ bottomMargin Margin Position 2
+ displayPosition TextPosition XawTextPosition 0
+ insertPosition TextPosition XawTextPosition 0
+ justify JustifyMode JustifyMode left
+ leftColumn Column Column 0
+ rightColumn Column Column 0
+ leftMargin Margin Position 2
+ rightMargin Margin Position 4
+ positionCallback Callback Callback NULL
+ scrollHorizontal Scroll Boolean False
+ scrollVertical Scroll Boolean False
+ selectTypes SelectTypes Pointer see documentation
+ textSink TextSink Widget NULL
+ textSource TextSource Widget NULL
+ topMargin Margin Position 2
+ unrealizeCallback Callback Callback NULL
+ wrap Wrap XawTextWrapMode XawTextWrapNever
+
+*/
+
+typedef long XawTextPosition;
+
+#ifndef notdef
+typedef enum {
+ XawtextScrollNever,
+ XawtextScrollWhenNeeded,
+ XawtextScrollAlways
+} XawTextScrollMode;
+
+typedef enum {
+ XawtextResizeNever,
+ XawtextResizeWidth,
+ XawtextResizeHeight,
+ XawtextResizeBoth
+} XawTextResizeMode;
+#endif
+
+typedef enum {
+ XawtextWrapNever,
+ XawtextWrapLine,
+ XawtextWrapWord
+} XawTextWrapMode;
+
+typedef enum {
+ XawsdLeft,
+ XawsdRight
+} XawTextScanDirection;
+
+typedef enum {
+ XawtextRead,
+ XawtextAppend,
+ XawtextEdit
+} XawTextEditType;
+
+typedef enum {
+ XawselectNull,
+ XawselectPosition,
+ XawselectChar,
+ XawselectWord,
+ XawselectLine,
+ XawselectParagraph,
+ XawselectAll,
+ XawselectAlphaNumeric
+} XawTextSelectType;
+
+typedef enum {
+ XawjustifyLeft,
+ XawjustifyRight,
+ XawjustifyCenter,
+ XawjustifyFull
+} XawTextJustifyMode;
+
+typedef struct {
+ int firstPos;
+ int length;
+ char *ptr;
+ unsigned long format;
+} XawTextBlock, *XawTextBlockPtr;
+
+#ifndef OLDXAW
+typedef struct {
+ int line_number;
+ int column_number;
+ XawTextPosition insert_position;
+ XawTextPosition last_position;
+ Boolean overwrite_mode;
+} XawTextPositionInfo;
+
+typedef struct {
+ XawTextPosition left, right;
+ XawTextBlock *block;
+} XawTextPropertyInfo;
+
+typedef struct _XawTextAnchor XawTextAnchor;
+typedef struct _XawTextEntity XawTextEntity;
+typedef struct _XawTextProperty XawTextProperty;
+typedef struct _XawTextPropertyList XawTextPropertyList;
+#endif
+
+#include <X11/Xaw/TextSink.h>
+#include <X11/Xaw/TextSrc.h>
+
+#define XtEtextScrollNever "never"
+#define XtEtextScrollWhenNeeded "whenneeded"
+#define XtEtextScrollAlways "always"
+#define XtEtextResizeNever "never"
+#define XtEtextResizeWidth "width"
+#define XtEtextResizeHeight "height"
+#define XtEtextResizeBoth "both"
+
+#define XtEtextWrapNever "never"
+#define XtEtextWrapLine "line"
+#define XtEtextWrapWord "word"
+
+#define XtNautoFill "autoFill"
+#define XtNbottomMargin "bottomMargin"
+#define XtNdialogHOffset "dialogHOffset"
+#define XtNdialogVOffset "dialogVOffset"
+#define XtNdisplayCaret "displayCaret"
+#define XtNdisplayPosition "displayPosition"
+#define XtNleftMargin "leftMargin"
+#define XtNrightMargin "rightMargin"
+#define XtNpositionCallback "positionCallback"
+#define XtNscrollVertical "scrollVertical"
+#define XtNscrollHorizontal "scrollHorizontal"
+#define XtNselectTypes "selectTypes"
+#define XtNtopMargin "topMargin"
+#define XtNwrap "wrap"
+
+#define XtCColumn "Column"
+#define XtNleftColumn "leftColumn"
+#define XtNrightColumn "rightColumn"
+
+#define XtCJustifyMode XtCJustify
+#define XtNjustifyMode XtNjustify
+#define XtEtextJustifyLeft "left"
+#define XtEtextJustifyRight "right"
+#define XtEtextJustifyCenter "center"
+#define XtEtextJustifyFull "full"
+
+#define XtCAutoFill "AutoFill"
+#define XtCSelectTypes "SelectTypes"
+#define XtCWrap "Wrap"
+#ifndef notdef
+#define XtCScroll "Scroll"
+#endif
+
+#ifndef _XtStringDefs_h_
+#define XtNinsertPosition "insertPosition"
+#ifndef notdef
+#define XtNresize "resize"
+#define XtCResize "Resize"
+#endif
+#define XtNselection "selection"
+#endif
+
+/* return Error code for XawTextSearch */
+#define XawTextSearchError (-12345L)
+
+/* return codes from XawTextReplace */
+#define XawReplaceError -1
+#define XawEditDone 0
+#define XawEditError 1
+#define XawPositionError 2
+
+/* XrmQuark is not unsigned long */
+#define XawTextFormat(tw,fmt) ((unsigned long)_XawTextFormat(tw) == (fmt))
+
+extern unsigned long FMT8BIT;
+extern unsigned long XawFmt8Bit;
+extern unsigned long XawFmtWide;
+
+extern WidgetClass textWidgetClass;
+
+typedef struct _TextClassRec *TextWidgetClass;
+typedef struct _TextRec *TextWidget;
+
+_XFUNCPROTOBEGIN
+
+XrmQuark _XawTextFormat
+(
+ TextWidget tw
+ );
+
+void XawTextDisplay
+(
+ Widget w
+ );
+
+void XawTextEnableRedisplay
+(
+ Widget w
+ );
+
+void XawTextDisableRedisplay
+(
+ Widget w
+ );
+
+void XawTextSetSelectionArray
+(
+ Widget w,
+ XawTextSelectType *sarray
+ );
+
+void XawTextGetSelectionPos
+(
+ Widget w,
+ XawTextPosition *begin_return,
+ XawTextPosition *end_return
+ );
+
+void XawTextSetSource
+(
+ Widget w,
+ Widget source,
+ XawTextPosition top
+ );
+
+int XawTextReplace
+(
+ Widget w,
+ XawTextPosition start,
+ XawTextPosition end,
+ XawTextBlock *text
+ );
+
+XawTextPosition XawTextTopPosition
+(
+ Widget w
+ );
+
+XawTextPosition XawTextLastPosition
+(
+ Widget w
+ );
+
+void XawTextSetInsertionPoint
+(
+ Widget w,
+ XawTextPosition position
+ );
+
+XawTextPosition XawTextGetInsertionPoint
+(
+ Widget w
+ );
+
+void XawTextUnsetSelection
+(
+ Widget w
+ );
+
+void XawTextSetSelection
+(
+ Widget w,
+ XawTextPosition left,
+ XawTextPosition right
+ );
+
+void XawTextInvalidate
+(
+ Widget w,
+ XawTextPosition from,
+ XawTextPosition to
+);
+
+Widget XawTextGetSource
+(
+ Widget w
+ );
+
+Widget XawTextGetSink
+(
+ Widget w
+ );
+
+XawTextPosition XawTextSearch
+(
+ Widget w,
+#if NeedWidePrototypes
+ int dir,
+#else
+ XawTextScanDirection dir,
+#endif
+ XawTextBlock *text
+ );
+
+void XawTextDisplayCaret
+(
+ Widget w,
+#if NeedWidePrototypes
+ int visible
+#else
+ Boolean visible
+#endif
+ );
+
+_XFUNCPROTOEND
+
+/*
+ * For R3 compatability only
+ */
+#include <X11/Xaw/AsciiSrc.h>
+#include <X11/Xaw/AsciiSink.h>
+
+#endif /* _XawText_h */
diff --git a/nx-X11/lib/Xaw/TextAction.c b/nx-X11/lib/Xaw/TextAction.c
new file mode 100644
index 000000000..2da0a9ff5
--- /dev/null
+++ b/nx-X11/lib/Xaw/TextAction.c
@@ -0,0 +1,4428 @@
+/* $Xorg: TextAction.c,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xaw/TextAction.c,v 3.46tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xos.h> /* for select() and struct timeval */
+#include <ctype.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xatom.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/Atoms.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xmu/StdSel.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xaw/MultiSinkP.h>
+#include <X11/Xaw/MultiSrcP.h>
+#include <X11/Xaw/TextP.h>
+#include <X11/Xaw/TextSrcP.h>
+#include <X11/Xaw/XawImP.h>
+#include "Private.h"
+#include "XawI18n.h"
+
+#define SrcScan XawTextSourceScan
+#define FindDist XawTextSinkFindDistance
+#define FindPos XawTextSinkFindPosition
+#define MULT(w) (w->text.mult == 0 ? 4 : \
+ w->text.mult == 32767 ? -4 : w->text.mult)
+
+#define KILL_RING_APPEND 2
+#define KILL_RING_BEGIN 3
+#define KILL_RING_YANK 100
+#define KILL_RING_YANK_DONE 98
+
+#define XawTextActionMaxHexChars 100
+
+/*
+ * Prototypes
+ */
+static void _DeleteOrKill(TextWidget, XawTextPosition, XawTextPosition, Bool);
+static void _SelectionReceived(Widget, XtPointer, Atom*, Atom*, XtPointer,
+ unsigned long*, int*);
+static void _LoseSelection(Widget, Atom*, char**, int*);
+static void AutoFill(TextWidget);
+static Boolean ConvertSelection(Widget, Atom*, Atom*, Atom*, XtPointer*,
+ unsigned long*, int*);
+static void DeleteOrKill(TextWidget, XEvent*, XawTextScanDirection,
+ XawTextScanType, Bool, Bool);
+static void EndAction(TextWidget);
+#ifndef OLDXAW
+static Bool BlankLine(Widget, XawTextPosition, int*);
+static int DoFormatText(TextWidget, XawTextPosition, Bool, int,
+ XawTextBlock*, XawTextPosition*, int, Bool);
+static int FormatText(TextWidget, XawTextPosition, Bool,
+ XawTextPosition*, int);
+static Bool GetBlockBoundaries(TextWidget, XawTextPosition*, XawTextPosition*);
+#endif
+static int FormRegion(TextWidget, XawTextPosition, XawTextPosition,
+ XawTextPosition*, int);
+static void GetSelection(Widget, Time, String*, Cardinal);
+static char *IfHexConvertHexElseReturnParam(char*, int*);
+static void InsertNewCRs(TextWidget, XawTextPosition, XawTextPosition,
+ XawTextPosition*, int);
+static int InsertNewLineAndBackupInternal(TextWidget);
+static int LocalInsertNewLine(TextWidget, XEvent*);
+static void LoseSelection(Widget, Atom*);
+static void ParameterError(Widget, String);
+static Bool MatchSelection(Atom, XawTextSelection*);
+static void ModifySelection(TextWidget, XEvent*, XawTextSelectionMode,
+ XawTextSelectionAction, String*, Cardinal*);
+static void Move(TextWidget, XEvent*, XawTextScanDirection, XawTextScanType,
+ Bool);
+static void NotePosition(TextWidget, XEvent*);
+static void StartAction(TextWidget, XEvent*);
+static XawTextPosition StripOutOldCRs(TextWidget, XawTextPosition,
+ XawTextPosition, XawTextPosition*, int);
+#ifndef OLDXAW
+static Bool StripSpaces(TextWidget, XawTextPosition, XawTextPosition,
+ XawTextPosition*, int, XawTextBlock*);
+static Bool Tabify(TextWidget, XawTextPosition, XawTextPosition,
+ XawTextPosition*, int, XawTextBlock*);
+static Bool Untabify(TextWidget, XawTextPosition, XawTextPosition,
+ XawTextPosition*, int, XawTextBlock*);
+#endif
+
+/*
+ * Actions
+ */
+static void CapitalizeWord(Widget, XEvent*, String*, Cardinal*);
+static void DisplayCaret(Widget, XEvent*, String*, Cardinal*);
+static void Delete(Widget, XEvent*, String*, Cardinal*);
+static void DeleteBackwardChar(Widget, XEvent*, String*, Cardinal*);
+static void DeleteBackwardWord(Widget, XEvent*, String*, Cardinal*);
+static void DeleteCurrentSelection(Widget, XEvent*, String*, Cardinal*);
+static void DeleteForwardChar(Widget, XEvent*, String*, Cardinal*);
+static void DeleteForwardWord(Widget, XEvent*, String*, Cardinal*);
+static void DowncaseWord(Widget, XEvent*, String*, Cardinal*);
+static void ExtendAdjust(Widget, XEvent*, String*, Cardinal*);
+static void ExtendEnd(Widget, XEvent*, String*, Cardinal*);
+static void ExtendStart(Widget, XEvent*, String*, Cardinal*);
+static void FormParagraph(Widget, XEvent*, String*, Cardinal*);
+#ifndef OLDXAW
+static void Indent(Widget, XEvent*, String*, Cardinal*);
+#endif
+static void InsertChar(Widget, XEvent*, String*, Cardinal*);
+static void InsertNewLine(Widget, XEvent*, String*, Cardinal*);
+static void InsertNewLineAndBackup(Widget, XEvent*, String*, Cardinal*);
+static void InsertNewLineAndIndent(Widget, XEvent*, String*, Cardinal*);
+static void InsertSelection(Widget, XEvent*, String*, Cardinal*);
+static void InsertString(Widget, XEvent*, String*, Cardinal*);
+#ifndef OLDXAW
+static void KeyboardReset(Widget, XEvent*, String*, Cardinal*);
+#endif
+static void KillBackwardWord(Widget, XEvent*, String*, Cardinal*);
+static void KillCurrentSelection(Widget, XEvent*, String*, Cardinal*);
+static void KillForwardWord(Widget, XEvent*, String*, Cardinal*);
+#ifndef OLDXAW
+static void KillRingYank(Widget, XEvent*, String*, Cardinal*);
+#endif
+static void KillToEndOfLine(Widget, XEvent*, String*, Cardinal*);
+static void KillToEndOfParagraph(Widget, XEvent*, String*, Cardinal*);
+static void MoveBackwardChar(Widget, XEvent*, String*, Cardinal*);
+static void MoveBackwardWord(Widget, XEvent*, String*, Cardinal*);
+static void MoveBackwardParagraph(Widget, XEvent*, String*, Cardinal*);
+static void MoveBeginningOfFile(Widget, XEvent*, String*, Cardinal*);
+static void MoveEndOfFile(Widget, XEvent*, String*, Cardinal*);
+static void MoveForwardChar(Widget, XEvent*, String*, Cardinal*);
+static void MoveForwardWord(Widget, XEvent*, String*, Cardinal*);
+static void MoveForwardParagraph(Widget, XEvent*, String*, Cardinal*);
+static void MoveNextLine(Widget, XEvent*, String*, Cardinal*);
+static void MoveNextPage(Widget, XEvent*, String*, Cardinal*);
+static void MovePage(TextWidget, XEvent*, XawTextScanDirection);
+static void MovePreviousLine(Widget, XEvent*, String*, Cardinal*);
+static void MovePreviousPage(Widget, XEvent*, String*, Cardinal*);
+static void MoveLine(TextWidget, XEvent*, XawTextScanDirection);
+static void MoveToLineEnd(Widget, XEvent*, String*, Cardinal*);
+static void MoveToLineStart(Widget, XEvent*, String*, Cardinal*);
+static void Multiply(Widget, XEvent*, String*, Cardinal*);
+static void NoOp(Widget, XEvent*, String*, Cardinal*);
+#ifndef OLDXAW
+static void Numeric(Widget, XEvent*, String*, Cardinal*);
+#endif
+static void Reconnect(Widget, XEvent*, String*, Cardinal*);
+static void RedrawDisplay(Widget, XEvent*, String*, Cardinal*);
+static void Scroll(TextWidget, XEvent*, XawTextScanDirection);
+static void ScrollOneLineDown(Widget, XEvent*, String*, Cardinal*);
+static void ScrollOneLineUp(Widget, XEvent*, String*, Cardinal*);
+static void SelectAdjust(Widget, XEvent*, String*, Cardinal*);
+static void SelectAll(Widget, XEvent*, String*, Cardinal*);
+static void SelectEnd(Widget, XEvent*, String*, Cardinal*);
+static void SelectSave(Widget, XEvent*, String*, Cardinal*);
+static void SelectStart(Widget, XEvent*, String*, Cardinal*);
+static void SelectWord(Widget, XEvent*, String*, Cardinal*);
+static void SetKeyboardFocus(Widget, XEvent*, String*, Cardinal*);
+static void TextEnterWindow(Widget, XEvent*, String*, Cardinal*);
+static void TextFocusIn(Widget, XEvent*, String*, Cardinal*);
+static void TextFocusOut(Widget, XEvent*, String*, Cardinal*);
+static void TextLeaveWindow(Widget, XEvent*, String*, Cardinal*);
+static void TransposeCharacters(Widget, XEvent*, String*, Cardinal*);
+#ifndef OLDXAW
+static void ToggleOverwrite(Widget, XEvent*, String*, Cardinal*);
+static void Undo(Widget, XEvent*, String*, Cardinal*);
+#endif
+static void UpcaseWord(Widget, XEvent*, String*, Cardinal*);
+static void DestroyFocusCallback(Widget, XtPointer, XtPointer);
+
+/*
+ * External
+ */
+void _XawTextZapSelection(TextWidget, XEvent*, Bool);
+
+/*
+ * Defined in TextPop.c
+ */
+void _XawTextInsertFileAction(Widget, XEvent*, String*, Cardinal*);
+void _XawTextInsertFile(Widget, XEvent*, String*, Cardinal*);
+void _XawTextSearch(Widget, XEvent*, String*, Cardinal*);
+void _XawTextDoSearchAction(Widget, XEvent*, String*, Cardinal*);
+void _XawTextDoReplaceAction(Widget, XEvent*, String*, Cardinal*);
+void _XawTextSetField(Widget, XEvent*, String*, Cardinal*);
+void _XawTextPopdownSearchAction(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * These are defined in Text.c
+ */
+void _XawTextAlterSelection(TextWidget, XawTextSelectionMode,
+ XawTextSelectionAction, String*, Cardinal*);
+void _XawTextClearAndCenterDisplay(TextWidget);
+void _XawTextExecuteUpdate(TextWidget);
+char *_XawTextGetText(TextWidget, XawTextPosition, XawTextPosition);
+void _XawTextPrepareToUpdate(TextWidget);
+int _XawTextReplace(TextWidget, XawTextPosition, XawTextPosition,
+ XawTextBlock*);
+Atom *_XawTextSelectionList(TextWidget, String*, Cardinal);
+void _XawTextSetSelection(TextWidget, XawTextPosition, XawTextPosition,
+ String*, Cardinal);
+void _XawTextVScroll(TextWidget, int);
+void XawTextScroll(TextWidget, int, int);
+void _XawTextSetLineAndColumnNumber(TextWidget, Bool);
+
+#ifndef OLDXAW
+/*
+ * Defined in TextSrc.c
+ */
+Bool _XawTextSrcUndo(TextSrcObject, XawTextPosition*);
+Bool _XawTextSrcToggleUndo(TextSrcObject);
+void _XawSourceSetUndoErase(TextSrcObject, int);
+void _XawSourceSetUndoMerge(TextSrcObject, Bool);
+#endif /* OLDXAW */
+
+/*
+ * Initialization
+ */
+#ifndef OLDXAW
+#define MAX_KILL_RINGS 1024
+XawTextKillRing *xaw_text_kill_ring;
+static XawTextKillRing kill_ring_prev, kill_ring_null = { &kill_ring_prev, };
+static unsigned num_kill_rings;
+#endif
+
+/*
+ * Implementation
+ */
+static void
+ParameterError(Widget w, String param)
+{
+ String params[2];
+ Cardinal num_params = 2;
+ params[0] = XtName(w);
+ params[1] = param;
+
+ XtAppWarningMsg(XtWidgetToApplicationContext(w),
+ "parameterError", "textAction", "XawError",
+ "Widget: %s Parameter: %s",
+ params, &num_params);
+ XBell(XtDisplay(w), 50);
+}
+
+static void
+StartAction(TextWidget ctx, XEvent *event)
+{
+#ifndef OLDXAW
+ Cardinal i;
+ TextSrcObject src = (TextSrcObject)ctx->text.source;
+
+ for (i = 0; i < src->textSrc.num_text; i++)
+ _XawTextPrepareToUpdate((TextWidget)src->textSrc.text[i]);
+ _XawSourceSetUndoMerge(src, False);
+#else
+ _XawTextPrepareToUpdate(ctx);
+#endif
+
+ if (event != NULL) {
+ switch (event->type) {
+ case ButtonPress:
+ case ButtonRelease:
+ ctx->text.time = event->xbutton.time;
+ break;
+ case KeyPress:
+ case KeyRelease:
+ ctx->text.time = event->xkey.time;
+ break;
+ case MotionNotify:
+ ctx->text.time = event->xmotion.time;
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ ctx->text.time = event->xcrossing.time;
+ }
+ }
+}
+
+static void
+NotePosition(TextWidget ctx, XEvent *event)
+{
+ switch (event->type) {
+ case ButtonPress:
+ case ButtonRelease:
+ ctx->text.ev_x = event->xbutton.x;
+ ctx->text.ev_y = event->xbutton.y;
+ break;
+ case KeyPress:
+ case KeyRelease: {
+ XRectangle cursor;
+ XawTextSinkGetCursorBounds(ctx->text.sink, &cursor);
+ ctx->text.ev_x = cursor.x + cursor.width / 2;
+ ctx->text.ev_y = cursor.y + cursor.height / 2;
+ } break;
+ case MotionNotify:
+ ctx->text.ev_x = event->xmotion.x;
+ ctx->text.ev_y = event->xmotion.y;
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ ctx->text.ev_x = event->xcrossing.x;
+ ctx->text.ev_y = event->xcrossing.y;
+ }
+}
+
+static void
+EndAction(TextWidget ctx)
+{
+#ifndef OLDXAW
+ Cardinal i;
+ TextSrcObject src = (TextSrcObject)ctx->text.source;
+
+ for (i = 0; i < src->textSrc.num_text; i++)
+ _XawTextExecuteUpdate((TextWidget)src->textSrc.text[i]);
+
+ ctx->text.mult = 1;
+ ctx->text.numeric = False;
+ if (ctx->text.kill_ring) {
+ if (--ctx->text.kill_ring == KILL_RING_YANK_DONE) {
+ if (ctx->text.kill_ring_ptr) {
+ --ctx->text.kill_ring_ptr->refcount;
+ ctx->text.kill_ring_ptr = NULL;
+ }
+ }
+ }
+#else
+ ctx->text.mult = 1;
+ _XawTextExecuteUpdate(ctx);
+#endif /* OLDXAW */
+}
+
+struct _SelectionList {
+ String* params;
+ Cardinal count;
+ Time time;
+ int asked; /* which selection currently has been asked for:
+ 0 = UTF8_STRING, 1 = COMPOUND_TEXT, 2 = STRING */
+ Atom selection; /* selection atom (normally XA_PRIMARY) */
+};
+
+/*ARGSUSED*/
+static void
+_SelectionReceived(Widget w, XtPointer client_data, Atom *selection,
+ Atom *type, XtPointer value, unsigned long *length,
+ int *format)
+{
+ Display *d = XtDisplay(w);
+ TextWidget ctx = (TextWidget)w;
+ XawTextBlock text;
+
+ if (*type == 0 /*XT_CONVERT_FAIL*/ || *length == 0) {
+ struct _SelectionList* list = (struct _SelectionList*)client_data;
+
+ if (list != NULL) {
+ if (list->asked == 0) {
+ /* If we just asked for XA_UTF8_STRING and got no response,
+ we'll ask again, this time for XA_COMPOUND_TEXT. */
+ list->asked++;
+ XtGetSelectionValue(w, list->selection, XA_COMPOUND_TEXT(d),
+ _SelectionReceived,
+ (XtPointer)list, list->time);
+ } else if (list->asked == 1) {
+ /* If we just asked for XA_COMPOUND_TEXT and got no response,
+ we'll ask again, this time for XA_STRING. */
+ list->asked++;
+ XtGetSelectionValue(w, list->selection, XA_STRING,
+ _SelectionReceived,
+ (XtPointer)list, list->time);
+ } else {
+ /* We tried all possible text targets in this param.
+ Recurse on the tail of the params list. */
+ GetSelection(w, list->time, list->params, list->count);
+ XtFree(client_data);
+ }
+ }
+ return;
+ }
+
+ StartAction(ctx, NULL);
+ if (XawTextFormat(ctx, XawFmtWide)) {
+ XTextProperty textprop;
+ wchar_t **wlist;
+ int count;
+
+ textprop.encoding = *type;
+ textprop.value = (unsigned char *)value;
+ textprop.nitems = strlen(value);
+ textprop.format = 8;
+
+ if (XwcTextPropertyToTextList(d, &textprop, &wlist, &count)
+ != Success
+ || count < 1) {
+ XwcFreeStringList(wlist);
+
+ /* Notify the user on strerr and in the insertion :) */
+ fprintf(stderr, "Xaw Text Widget: An attempt was made to insert "
+ "an illegal selection.\n");
+
+ textprop.value = (unsigned char *)" >> ILLEGAL SELECTION << ";
+ textprop.nitems = strlen((char *) textprop.value);
+ if (XwcTextPropertyToTextList(d, &textprop, &wlist, &count)
+ != Success
+ || count < 1)
+ return;
+ }
+
+ XFree(value);
+ value = (XPointer)wlist[0];
+
+ *length = wcslen(wlist[0]);
+ XtFree((XtPointer)wlist);
+ text.format = XawFmtWide;
+ } else {
+ XTextProperty textprop;
+ char **list;
+ int count;
+
+ textprop.encoding = *type;
+ textprop.value = (unsigned char *)value;
+ textprop.nitems = strlen(value);
+ textprop.format = 8;
+
+ if (XmbTextPropertyToTextList(d, &textprop, &list, &count)
+ != Success
+ || count < 1) {
+ XFreeStringList(list);
+
+ /* Notify the user on strerr and in the insertion :) */
+ fprintf(stderr, "Xaw Text Widget: An attempt was made to insert "
+ "an illegal selection.\n");
+
+ textprop.value = (unsigned char *)" >> ILLEGAL SELECTION << ";
+ textprop.nitems = strlen((char *) textprop.value);
+ if (XmbTextPropertyToTextList(d, &textprop, &list, &count)
+ != Success
+ || count < 1)
+ return;
+ }
+
+ XFree(value);
+ value = (XPointer)list[0];
+
+ *length = strlen(list[0]);
+ XtFree((XtPointer)list);
+ text.format = XawFmt8Bit;
+ }
+ text.ptr = (char*)value;
+ text.firstPos = 0;
+ text.length = *length;
+ if (_XawTextReplace(ctx, ctx->text.insertPos, ctx->text.insertPos, &text)) {
+ XBell(XtDisplay(ctx), 0);
+ EndAction(ctx);
+ return;
+ }
+
+ ctx->text.from_left = -1;
+ ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.old_insert,
+ XawstPositions, XawsdRight, text.length, True);
+
+ EndAction(ctx);
+ XtFree(client_data);
+ XFree(value); /* the selection value should be freed with XFree */
+}
+
+static void
+GetSelection(Widget w, Time timev, String *params, Cardinal num_params)
+{
+ Atom selection;
+ int buffer;
+
+ selection = XInternAtom(XtDisplay(w), *params, False);
+ switch (selection) {
+ case XA_CUT_BUFFER0: buffer = 0; break;
+ case XA_CUT_BUFFER1: buffer = 1; break;
+ case XA_CUT_BUFFER2: buffer = 2; break;
+ case XA_CUT_BUFFER3: buffer = 3; break;
+ case XA_CUT_BUFFER4: buffer = 4; break;
+ case XA_CUT_BUFFER5: buffer = 5; break;
+ case XA_CUT_BUFFER6: buffer = 6; break;
+ case XA_CUT_BUFFER7: buffer = 7; break;
+ default: buffer = -1;
+ }
+ if (buffer >= 0) {
+ int nbytes;
+ unsigned long length;
+ int fmt8 = 8;
+ Atom type = XA_STRING;
+ char *line = XFetchBuffer(XtDisplay(w), &nbytes, buffer);
+
+ if ((length = nbytes) != 0L)
+ _SelectionReceived(w, NULL, &selection, &type, line, &length, &fmt8);
+ else if (num_params > 1)
+ GetSelection(w, timev, params+1, num_params-1);
+ }
+ else {
+ struct _SelectionList* list;
+
+ if (--num_params) {
+ list = XtNew(struct _SelectionList);
+ list->params = params + 1;
+ list->count = num_params;
+ list->time = timev;
+ list->asked = 0;
+ list->selection = selection;
+ }
+ else
+ list = NULL;
+ XtGetSelectionValue(w, selection, XA_UTF8_STRING(XtDisplay(w)),
+ _SelectionReceived, (XtPointer)list, timev);
+ }
+}
+
+static void
+InsertSelection(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ StartAction((TextWidget)w, event); /* Get Time. */
+ GetSelection(w, ((TextWidget)w)->text.time, params, *num_params);
+ EndAction((TextWidget)w);
+}
+
+/*
+ * Routines for Moving Around
+ */
+static void
+Move(TextWidget ctx, XEvent *event, XawTextScanDirection dir,
+ XawTextScanType type, Bool include)
+{
+ XawTextPosition insertPos;
+ short mult = MULT(ctx);
+
+ if (mult < 0) {
+ mult = -mult;
+ dir = dir == XawsdLeft ? XawsdRight : XawsdLeft;
+ }
+
+ insertPos = SrcScan(ctx->text.source, ctx->text.insertPos,
+ type, dir, mult, include);
+
+ StartAction(ctx, event);
+
+ if (ctx->text.s.left != ctx->text.s.right)
+ XawTextUnsetSelection((Widget)ctx);
+
+#ifndef OLDXAW
+ ctx->text.numeric = False;
+#endif
+ ctx->text.mult = 1;
+ ctx->text.showposition = True;
+ ctx->text.from_left = -1;
+ ctx->text.insertPos = insertPos;
+ EndAction(ctx);
+}
+
+/*ARGSUSED*/
+static void
+MoveForwardChar(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ Move((TextWidget)w, event, XawsdRight, XawstPositions, True);
+}
+
+/*ARGSUSED*/
+static void
+MoveBackwardChar(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ Move((TextWidget)w, event, XawsdLeft, XawstPositions, True);
+}
+
+static void
+MoveForwardWord(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ if (*n && (p[0][0] == 'A' || p[0][0] == 'a'))
+ Move((TextWidget)w, event, XawsdRight, XawstAlphaNumeric, False);
+ else
+ Move((TextWidget)w, event, XawsdRight, XawstWhiteSpace, False);
+}
+
+static void
+MoveBackwardWord(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ if (*n && (p[0][0] == 'A' || p[0][0] == 'a'))
+ Move((TextWidget)w, event, XawsdLeft, XawstAlphaNumeric, False);
+ else
+ Move((TextWidget)w, event, XawsdLeft, XawstWhiteSpace, False);
+}
+
+static void
+MoveForwardParagraph(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ TextWidget ctx = (TextWidget)w;
+ XawTextPosition position = ctx->text.insertPos;
+ short mult = MULT(ctx);
+
+ if (mult < 0) {
+ ctx->text.mult = -mult;
+ MoveBackwardParagraph(w, event, p, n);
+ return;
+ }
+
+ while (mult--) {
+ position = SrcScan(ctx->text.source, position,
+ XawstEOL, XawsdRight, 1, False) - 1;
+
+ while (position == SrcScan(ctx->text.source, position,
+ XawstEOL, XawsdRight, 1, False))
+ if (++position > ctx->text.lastPos) {
+ mult = 0;
+ break;
+ }
+
+ position = SrcScan(ctx->text.source, position,
+ XawstParagraph, XawsdRight, 1, True);
+ if (position != ctx->text.lastPos)
+ position = SrcScan(ctx->text.source, position - 1,
+ XawstEOL, XawsdLeft, 1, False);
+ else
+ break;
+ }
+
+ if (position != ctx->text.insertPos) {
+ XawTextUnsetSelection(w);
+ StartAction(ctx, event);
+ ctx->text.showposition = True;
+ ctx->text.from_left = -1;
+ ctx->text.insertPos = position;
+ EndAction(ctx);
+ }
+ else
+ ctx->text.mult = 1;
+}
+
+/*ARGSUSED*/
+static void
+MoveBackwardParagraph(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ TextWidget ctx = (TextWidget)w;
+ XawTextPosition position = ctx->text.insertPos;
+ short mult = MULT(ctx);
+
+ if (mult < 0) {
+ ctx->text.mult = -mult;
+ MoveForwardParagraph(w, event, p, n);
+ return;
+ }
+
+ while (mult--) {
+ position = SrcScan(ctx->text.source, position,
+ XawstEOL, XawsdLeft, 1, False) + 1;
+
+ while (position == SrcScan(ctx->text.source, position,
+ XawstEOL, XawsdLeft, 1, False))
+ if (--position < 0) {
+ mult = 0;
+ break;
+ }
+
+ position = SrcScan(ctx->text.source, position,
+ XawstParagraph, XawsdLeft, 1, True);
+ if (position > 0 && position < ctx->text.lastPos)
+ ++position;
+ else
+ break;
+ }
+
+ if (position != ctx->text.insertPos) {
+ XawTextUnsetSelection(w);
+ StartAction(ctx, event);
+ ctx->text.showposition = True;
+ ctx->text.from_left = -1;
+ ctx->text.insertPos = position;
+ EndAction(ctx);
+ }
+ else
+ ctx->text.mult = 1;
+}
+
+/*ARGSUSED*/
+static void
+MoveToLineEnd(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ Move((TextWidget)w, event, XawsdRight, XawstEOL, False);
+}
+
+/*ARGSUSED*/
+static void
+MoveToLineStart(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ Move((TextWidget)w, event, XawsdLeft, XawstEOL, False);
+}
+
+static void
+MoveLine(TextWidget ctx, XEvent *event, XawTextScanDirection dir)
+{
+ XawTextPosition cnew, next_line, ltemp;
+ int itemp, from_left;
+ short mult = MULT(ctx);
+
+ StartAction(ctx, event);
+
+ XawTextUnsetSelection((Widget)ctx);
+
+ if (dir == XawsdLeft)
+ mult = mult == 0 ? 5 : mult + 1;
+
+ cnew = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstEOL, XawsdLeft, 1, False);
+
+ if (ctx->text.from_left < 0)
+ FindDist(ctx->text.sink, cnew, ctx->text.left_margin, ctx->text.insertPos,
+ &ctx->text.from_left, &ltemp, &itemp);
+
+ cnew = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL, dir,
+ mult, (dir == XawsdRight));
+
+ next_line = SrcScan(ctx->text.source, cnew, XawstEOL, XawsdRight, 1, False);
+
+ FindPos(ctx->text.sink, cnew, ctx->text.left_margin, ctx->text.from_left,
+ False, &ctx->text.insertPos, &from_left, &itemp);
+
+ if (from_left < ctx->text.from_left) {
+ XawTextBlock block;
+
+ XawTextSourceRead(ctx->text.source, ctx->text.insertPos, &block, 1);
+ if (block.length) {
+ if (XawTextFormat(ctx, XawFmtWide)) {
+ if (*(wchar_t *)block.ptr == _Xaw_atowc(XawTAB))
+ ++ctx->text.insertPos;
+ }
+ else if (block.ptr[0] == XawTAB)
+ ++ctx->text.insertPos;
+ }
+ }
+
+ if (ctx->text.insertPos > next_line)
+ ctx->text.insertPos = next_line;
+
+ EndAction(ctx);
+}
+
+static void
+MoveNextLine(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ TextWidget ctx = (TextWidget)w;
+ short mult = MULT(ctx);
+
+ if (mult < 0) {
+ ctx->text.mult = -mult;
+ MovePreviousLine(w, event, p, n);
+ return;
+ }
+
+ if (ctx->text.insertPos < ctx->text.lastPos)
+ MoveLine(ctx, event, XawsdRight);
+ else
+ ctx->text.mult = 1;
+}
+
+static void
+MovePreviousLine(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ TextWidget ctx = (TextWidget)w;
+ short mult = MULT(ctx);
+
+ if (mult < 0) {
+ ctx->text.mult = -mult;
+ MoveNextLine(w, event, p, n);
+ return;
+ }
+
+ if (ctx->text.lt.top != 0 || (ctx->text.lt.lines > 1 &&
+ ctx->text.insertPos >= ctx->text.lt.info[1].position))
+ MoveLine(ctx, event, XawsdLeft);
+ else
+ ctx->text.mult = 1;
+}
+
+/*ARGSUSED*/
+static void
+MoveBeginningOfFile(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ Move((TextWidget)w, event, XawsdLeft, XawstAll, True);
+}
+
+/*ARGSUSED*/
+static void
+MoveEndOfFile(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ Move((TextWidget)w, event, XawsdRight, XawstAll, True);
+}
+
+static void
+Scroll(TextWidget ctx, XEvent *event, XawTextScanDirection dir)
+{
+ short mult = MULT(ctx);
+
+ if (mult < 0) {
+ mult = -mult;
+ dir = dir == XawsdLeft ? XawsdRight : XawsdLeft;
+ }
+
+ if (ctx->text.lt.lines > 1
+ && (dir == XawsdRight
+ || ctx->text.lastPos >= ctx->text.lt.info[1].position)) {
+ StartAction(ctx, event);
+
+ if (dir == XawsdLeft)
+ _XawTextVScroll(ctx, mult);
+ else
+ _XawTextVScroll(ctx, -mult);
+
+ EndAction(ctx);
+ }
+ else {
+ ctx->text.mult = 1;
+#ifndef OLDXAW
+ ctx->text.numeric = False;
+#endif
+ }
+}
+
+/*ARGSUSED*/
+static void
+ScrollOneLineUp(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ Scroll((TextWidget)w, event, XawsdLeft);
+}
+
+/*ARGSUSED*/
+static void
+ScrollOneLineDown(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ Scroll((TextWidget)w, event, XawsdRight);
+}
+
+static void
+MovePage(TextWidget ctx, XEvent *event, XawTextScanDirection dir)
+{
+ int scroll_val = 0;
+ XawTextPosition old_pos;
+
+ ctx->text.from_left = -1;
+ switch (dir) {
+ case XawsdLeft:
+ if (ctx->text.lt.top != 0)
+ scroll_val = -Max(1, ctx->text.lt.lines - 1);
+ break;
+ case XawsdRight:
+ if (!IsPositionVisible(ctx, Max(0, ctx->text.lastPos)))
+ scroll_val = Max(1, ctx->text.lt.lines - 1);
+ break;
+ }
+
+ if (scroll_val)
+ XawTextScroll(ctx, scroll_val,
+ ctx->text.left_margin - ctx->text.r_margin.left);
+
+ old_pos = ctx->text.insertPos;
+ switch (dir) {
+ case XawsdRight:
+ if (IsPositionVisible(ctx, Max(0, ctx->text.lastPos)))
+ ctx->text.insertPos = Max(0, ctx->text.lastPos);
+ else
+ ctx->text.insertPos = ctx->text.lt.top;
+ if (ctx->text.insertPos < old_pos)
+ ctx->text.insertPos = SrcScan(ctx->text.source, old_pos,
+ XawstEOL, XawsdLeft, 1, False);
+ break;
+ case XawsdLeft:
+ if (IsPositionVisible(ctx, 0))
+ ctx->text.insertPos = 0;
+ else if (ctx->text.lt.lines)
+ ctx->text.insertPos =
+ ctx->text.lt.info[ctx->text.lt.lines - 1].position;
+ else
+ ctx->text.insertPos = ctx->text.lt.top;
+ if (ctx->text.insertPos > old_pos)
+ ctx->text.insertPos = SrcScan(ctx->text.source, old_pos,
+ XawstEOL, XawsdLeft, 1, False);
+ break;
+ }
+}
+
+static void
+MoveNextPage(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ TextWidget ctx = (TextWidget)w;
+ short mult = MULT(ctx);
+
+ if (mult < 0) {
+ ctx->text.mult = -mult;
+ MovePreviousPage(w, event, p, n);
+ return;
+ }
+
+ if (ctx->text.insertPos < ctx->text.lastPos) {
+ XawTextUnsetSelection(w);
+ StartAction(ctx, event);
+ ctx->text.clear_to_eol = True;
+ while (mult-- && ctx->text.insertPos < ctx->text.lastPos)
+ MovePage(ctx, event, XawsdRight);
+ EndAction(ctx);
+ }
+ else
+ ctx->text.mult = 1;
+}
+
+/*ARGSUSED*/
+static void
+MovePreviousPage(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ TextWidget ctx = (TextWidget)w;
+ short mult = MULT(ctx);
+
+ if (mult < 0) {
+ ctx->text.mult = -mult;
+ MoveNextPage(w, event, p, n);
+ return;
+ }
+
+ if (ctx->text.insertPos > 0) {
+ XawTextUnsetSelection(w);
+ StartAction(ctx, event);
+ ctx->text.clear_to_eol = True;
+ while (mult-- && ctx->text.insertPos > 0)
+ MovePage(ctx, event, XawsdLeft);
+ EndAction(ctx);
+ }
+ else
+ ctx->text.mult = 1;
+}
+
+/*
+ * Delete Routines
+ */
+static Bool
+MatchSelection(Atom selection, XawTextSelection *s)
+{
+ Atom *match;
+ int count;
+
+ for (count = 0, match = s->selections; count < s->atom_count;
+ match++, count++)
+ if (*match == selection)
+ return (True);
+
+ return (False);
+}
+
+#define SrcCvtSel XawTextSourceConvertSelection
+
+static Boolean
+ConvertSelection(Widget w, Atom *selection, Atom *target, Atom *type,
+ XtPointer *value, unsigned long *length, int *format)
+{
+ Display *d = XtDisplay(w);
+ TextWidget ctx = (TextWidget)w;
+ Widget src = ctx->text.source;
+ XawTextEditType edit_mode;
+ Arg args[1];
+ XawTextSelectionSalt *salt = NULL;
+ XawTextSelection *s;
+
+ if (*target == XA_TARGETS(d)) {
+ Atom *targetP, *std_targets;
+ unsigned long std_length;
+
+ if (SrcCvtSel(src, selection, target, type, value, length, format))
+ return (True);
+
+ XtSetArg(args[0], XtNeditType,&edit_mode);
+ XtGetValues(src, args, 1);
+
+ XmuConvertStandardSelection(w, ctx->text.time, selection,
+ target, type, (XPointer *)&std_targets,
+ &std_length, format);
+
+ *length = 7 + (edit_mode == XawtextEdit) + std_length;
+ *value = XtMalloc((unsigned)sizeof(Atom)*(*length));
+ targetP = *(Atom**)value;
+ *targetP++ = XA_STRING;
+ *targetP++ = XA_TEXT(d);
+ *targetP++ = XA_UTF8_STRING(d);
+ *targetP++ = XA_COMPOUND_TEXT(d);
+ *targetP++ = XA_LENGTH(d);
+ *targetP++ = XA_LIST_LENGTH(d);
+ *targetP++ = XA_CHARACTER_POSITION(d);
+ if (edit_mode == XawtextEdit) {
+ *targetP++ = XA_DELETE(d);
+ }
+ memcpy((char*)targetP, (char*)std_targets, sizeof(Atom)*std_length);
+ XtFree((char*)std_targets);
+ *type = XA_ATOM;
+ *format = 32;
+ return (True);
+ }
+
+ if (SrcCvtSel(src, selection, target, type, value, length, format))
+ return (True);
+
+ for (salt = ctx->text.salt2; salt; salt = salt->next)
+ if (MatchSelection (*selection, &salt->s))
+ break;
+ if (!salt)
+ return (False);
+ s = &salt->s;
+ if (*target == XA_STRING
+ || *target == XA_TEXT(d)
+ || *target == XA_UTF8_STRING(d)
+ || *target == XA_COMPOUND_TEXT(d)) {
+ if (*target == XA_TEXT(d)) {
+ if (XawTextFormat(ctx, XawFmtWide))
+ *type = XA_COMPOUND_TEXT(d);
+ else
+ *type = XA_STRING;
+ }
+ else
+ *type = *target;
+
+ /*
+ * If salt is True, the salt->contents stores CT string,
+ * its length is measured in bytes.
+ * Refer to _XawTextSaltAwaySelection()
+ *
+ * by Li Yuhong, Mar. 20, 1991.
+ */
+ if (!salt) {
+ *value = (char *)_XawTextGetSTRING(ctx, s->left, s->right);
+ if (XawTextFormat(ctx, XawFmtWide)) {
+ XTextProperty textprop;
+ if (XwcTextListToTextProperty(d, (wchar_t**)value, 1,
+ XCompoundTextStyle, &textprop)
+ < Success) {
+ XtFree(*value);
+ return (False);
+ }
+ XtFree(*value);
+ *value = (XtPointer)textprop.value;
+ *length = textprop.nitems;
+ }
+ else
+ *length = strlen(*value);
+ }
+ else {
+ *value = XtMalloc((salt->length + 1) * sizeof(unsigned char));
+ strcpy (*value, salt->contents);
+ *length = salt->length;
+ }
+ /* Got *value,*length, now in COMPOUND_TEXT format. */
+ if (XawTextFormat(ctx, XawFmtWide) && *type == XA_STRING) {
+ XTextProperty textprop;
+ wchar_t **wlist;
+ int count;
+
+ textprop.encoding = XA_COMPOUND_TEXT(d);
+ textprop.value = (unsigned char *)*value;
+ textprop.nitems = strlen(*value);
+ textprop.format = 8;
+ if (XwcTextPropertyToTextList(d, &textprop, &wlist, &count)
+ < Success
+ || count < 1) {
+ XtFree(*value);
+ return (False);
+ }
+ XtFree(*value);
+ if (XwcTextListToTextProperty(d, wlist, 1, XStringStyle, &textprop)
+ < Success) {
+ XwcFreeStringList((wchar_t**)wlist);
+ return (False);
+ }
+ *value = (XtPointer)textprop.value;
+ *length = textprop.nitems;
+ XwcFreeStringList((wchar_t**) wlist);
+ } else if (*type == XA_UTF8_STRING(d)) {
+ XTextProperty textprop;
+ char **list;
+ int count;
+
+ textprop.encoding = XA_COMPOUND_TEXT(d);
+ textprop.value = (unsigned char *)*value;
+ textprop.nitems = strlen(*value);
+ textprop.format = 8;
+ if (Xutf8TextPropertyToTextList(d, &textprop, &list, &count)
+ < Success
+ || count < 1) {
+ XtFree(*value);
+ return (False);
+ }
+ XtFree(*value);
+ *value = *list;
+ *length = strlen(*list);
+ XFree(list);
+ }
+ *format = 8;
+ return (True);
+ }
+
+ if (*target == XA_LIST_LENGTH(d) || *target == XA_LENGTH(d)) {
+ long *temp;
+
+ temp = (long *)XtMalloc(sizeof(long));
+ if (*target == XA_LIST_LENGTH(d))
+ *temp = 1L;
+ else /* *target == XA_LENGTH(d) */
+ *temp = (long)(s->right - s->left);
+
+ *value = (XPointer)temp;
+ *type = XA_INTEGER;
+ *length = 1L;
+ *format = 32;
+ return (True);
+ }
+
+ if (*target == XA_CHARACTER_POSITION(d)) {
+ long *temp;
+
+ temp = (long *) XtMalloc(2 * sizeof(long));
+ temp[0] = (long)(s->left + 1);
+ temp[1] = s->right;
+ *value = (XPointer)temp;
+ *type = XA_SPAN(d);
+ *length = 2L;
+ *format = 32;
+ return (True);
+ }
+
+ if (*target == XA_DELETE(d)) {
+ if (!salt)
+ _XawTextZapSelection(ctx, NULL, True);
+ *value = NULL;
+ *type = XA_NULL(d);
+ *length = 0;
+ *format = 32;
+ return (True);
+ }
+
+ if (XmuConvertStandardSelection(w, ctx->text.time, selection, target, type,
+ (XPointer *)value, length, format))
+ return (True);
+
+ return (False);
+}
+
+static void
+LoseSelection(Widget w, Atom *selection)
+{
+ _LoseSelection(w, selection, NULL, NULL);
+}
+
+static void
+_LoseSelection(Widget w, Atom *selection, char **contents, int *length)
+{
+ TextWidget ctx = (TextWidget)w;
+ Atom *atomP;
+ int i;
+ XawTextSelectionSalt *salt, *prevSalt, *nextSalt;
+
+ prevSalt = 0;
+ for (salt = ctx->text.salt2; salt; salt = nextSalt) {
+ atomP = salt->s.selections;
+ nextSalt = salt->next;
+ for (i = 0 ; i < salt->s.atom_count; i++, atomP++)
+ if (*selection == *atomP)
+ *atomP = (Atom)0;
+
+ while (salt->s.atom_count
+ && salt->s.selections[salt->s.atom_count-1] == 0)
+ salt->s.atom_count--;
+
+ /*
+ * Must walk the selection list in opposite order from UnsetSelection.
+ */
+ atomP = salt->s.selections;
+ for (i = 0 ; i < salt->s.atom_count; i++, atomP++)
+ if (*atomP == (Atom)0) {
+ *atomP = salt->s.selections[--salt->s.atom_count];
+
+ while (salt->s.atom_count
+ && salt->s.selections[salt->s.atom_count-1] == 0)
+ salt->s.atom_count--;
+ }
+ if (salt->s.atom_count == 0) {
+#ifndef OLDXAW
+ if (contents == NULL) {
+ XawTextKillRing *kill_ring = XtNew(XawTextKillRing);
+
+ kill_ring->next = xaw_text_kill_ring;
+ kill_ring->contents = salt->contents;
+ kill_ring->length = salt->length;
+ kill_ring->format = XawFmt8Bit;
+ xaw_text_kill_ring = kill_ring;
+ kill_ring_prev.next = xaw_text_kill_ring;
+
+ if (++num_kill_rings > MAX_KILL_RINGS) {
+ XawTextKillRing *tail = NULL;
+
+ while (kill_ring->next) {
+ tail = kill_ring;
+ kill_ring = kill_ring->next;
+ }
+ if (kill_ring->refcount == 0) {
+ --num_kill_rings;
+ tail->next = NULL;
+ XtFree(kill_ring->contents);
+ XtFree((char*)kill_ring);
+ }
+ }
+ }
+ else {
+ *contents = salt->contents;
+ *length = salt->length;
+ }
+#endif
+ if (prevSalt)
+ prevSalt->next = nextSalt;
+ else
+ ctx->text.salt2 = nextSalt;
+
+ XtFree((char *)salt->s.selections);
+ XtFree((char *)salt);
+ }
+ else
+ prevSalt = salt;
+ }
+}
+
+static void
+_DeleteOrKill(TextWidget ctx, XawTextPosition from, XawTextPosition to,
+ Bool kill)
+{
+ XawTextBlock text;
+
+#ifndef OLDXAW
+ if (ctx->text.kill_ring_ptr) {
+ --ctx->text.kill_ring_ptr->refcount;
+ ctx->text.kill_ring_ptr = NULL;
+ }
+#endif
+ if (kill && from < to) {
+#ifndef OLDXAW
+ Bool append = False;
+ char *ring = NULL;
+ XawTextPosition old_from = from;
+#endif
+ char *string;
+ int size = 0, length;
+ XawTextSelectionSalt *salt;
+ Atom selection = XInternAtom(XtDisplay(ctx), "SECONDARY", False);
+
+#ifndef OLDXAW
+ if (ctx->text.kill_ring == KILL_RING_APPEND) {
+ old_from = ctx->text.salt2->s.left;
+ append = True;
+ }
+ else
+ ctx->text.kill_ring = KILL_RING_BEGIN;
+
+ if (append)
+ _LoseSelection((Widget)ctx, &selection, &ring, &size);
+ else
+#endif
+ LoseSelection((Widget)ctx, &selection);
+
+ salt = (XawTextSelectionSalt*)XtMalloc(sizeof(XawTextSelectionSalt));
+ salt->s.selections = (Atom *)XtMalloc(sizeof(Atom));
+ salt->s.left = from;
+ salt->s.right = to;
+
+ string = (char *)_XawTextGetSTRING(ctx, from, to);
+
+ if (XawTextFormat(ctx, XawFmtWide)) {
+ XTextProperty textprop;
+
+ if (XwcTextListToTextProperty(XtDisplay((Widget)ctx),
+ (wchar_t**)(&string),
+ 1, XCompoundTextStyle,
+ &textprop) < Success) {
+ XtFree(string);
+ XtFree((char*)salt->s.selections);
+ XtFree((char*)salt);
+ return;
+ }
+ XtFree(string);
+ string = (char *)textprop.value;
+ length = textprop.nitems;
+ }
+ else
+ length = strlen(string);
+
+ salt->length = length + size;
+
+#ifndef OLDXAW
+ if (!append)
+ salt->contents = string;
+ else {
+ salt->contents = XtMalloc(length + size + 1);
+ if (from >= old_from) {
+ strncpy(salt->contents, ring, size);
+ salt->contents[size] = '\0';
+ strncat(salt->contents, string, length);
+ }
+ else {
+ strncpy(salt->contents, string, length);
+ salt->contents[length] = '\0';
+ strncat(salt->contents, ring, size);
+ }
+ salt->contents[length + size] = '\0';
+ XtFree(ring);
+ XtFree(string);
+ }
+
+ kill_ring_prev.contents = salt->contents;
+ kill_ring_prev.length = salt->length;
+ kill_ring_prev.format = XawFmt8Bit;
+#else
+ salt->contents = string;
+#endif
+
+ salt->next = ctx->text.salt2;
+ ctx->text.salt2 = salt;
+
+#ifndef OLDXAW
+ if (append)
+ ctx->text.kill_ring = KILL_RING_BEGIN;
+#endif
+
+ salt->s.selections[0] = selection;
+
+ XtOwnSelection((Widget)ctx, selection, ctx->text.time,
+ ConvertSelection, LoseSelection, NULL);
+ salt->s.atom_count = 1;
+ }
+ text.length = 0;
+ text.firstPos = 0;
+
+ text.format = _XawTextFormat(ctx);
+ text.ptr = "";
+
+ if (_XawTextReplace(ctx, from, to, &text)) {
+ XBell(XtDisplay(ctx), 50);
+ return;
+ }
+ ctx->text.from_left = -1;
+ ctx->text.insertPos = from;
+ ctx->text.showposition = TRUE;
+}
+
+static void
+DeleteOrKill(TextWidget ctx, XEvent *event, XawTextScanDirection dir,
+ XawTextScanType type, Bool include, Bool kill)
+{
+ XawTextPosition from, to;
+ short mult = MULT(ctx);
+
+ if (mult < 0) {
+ mult = -mult;
+ dir = dir == XawsdLeft ? XawsdRight : XawsdLeft;
+ }
+
+ StartAction(ctx, event);
+#ifndef OLDXAW
+ if (mult == 1)
+ _XawSourceSetUndoMerge((TextSrcObject)ctx->text.source, True);
+#endif
+ to = SrcScan(ctx->text.source, ctx->text.insertPos,
+ type, dir, mult, include);
+
+ /*
+ * If no movement actually happened, then bump the count and try again.
+ * This causes the character position at the very beginning and end of
+ * a boundary to act correctly
+ */
+ if (to == ctx->text.insertPos)
+ to = SrcScan(ctx->text.source, ctx->text.insertPos,
+ type, dir, mult + 1, include);
+
+ if (dir == XawsdLeft) {
+ from = to;
+ to = ctx->text.insertPos;
+ }
+ else
+ from = ctx->text.insertPos;
+
+ _DeleteOrKill(ctx, from, to, kill);
+ EndAction(ctx);
+}
+
+static void
+Delete(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ if (ctx->text.s.left != ctx->text.s.right)
+ DeleteCurrentSelection(w, event, p, n);
+ else
+ DeleteBackwardChar(w, event, p, n);
+}
+
+static void
+DeleteChar(Widget w, XEvent *event, XawTextScanDirection dir)
+{
+ TextWidget ctx = (TextWidget)w;
+ short mul = MULT(ctx);
+
+ if (mul < 0) {
+ ctx->text.mult = mul = -mul;
+ dir = dir == XawsdLeft ? XawsdRight : XawsdLeft;
+ }
+ DeleteOrKill(ctx, event, dir, XawstPositions, True, False);
+#ifndef OLDXAW
+ if (mul == 1)
+ _XawSourceSetUndoErase((TextSrcObject)ctx->text.source,
+ dir == XawsdLeft ? -1 : 1);
+#endif
+}
+
+/*ARGSUSED*/
+static void
+DeleteForwardChar(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ DeleteChar(w, event, XawsdRight);
+}
+
+/*ARGSUSED*/
+static void
+DeleteBackwardChar(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ DeleteChar(w, event, XawsdLeft);
+}
+
+static void
+DeleteForwardWord(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ XawTextScanType type;
+
+ if (*num_params && (*params[0] == 'A' || *params[0] == 'a'))
+ type = XawstAlphaNumeric;
+ else
+ type = XawstWhiteSpace;
+
+ DeleteOrKill((TextWidget)w, event, XawsdRight, type, False, False);
+}
+
+static void
+DeleteBackwardWord(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ XawTextScanType type;
+
+ if (*num_params && (*params[0] == 'A' || *params[0] == 'a'))
+ type = XawstAlphaNumeric;
+ else
+ type = XawstWhiteSpace;
+
+ DeleteOrKill((TextWidget)w, event, XawsdLeft, type, False, False);
+}
+
+static void
+KillForwardWord(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ XawTextScanType type;
+
+ if (*num_params && (*params[0] == 'A' || *params[0] == 'a'))
+ type = XawstAlphaNumeric;
+ else
+ type = XawstWhiteSpace;
+
+ DeleteOrKill((TextWidget)w, event, XawsdRight, type, False, True);
+}
+
+static void
+KillBackwardWord(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ XawTextScanType type;
+
+ if (*num_params && (*params[0] == 'A' || *params[0] == 'a'))
+ type = XawstAlphaNumeric;
+ else
+ type = XawstWhiteSpace;
+
+ DeleteOrKill((TextWidget) w, event, XawsdLeft, type, False, True);
+}
+
+/*ARGSUSED*/
+static void
+KillToEndOfLine(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ TextWidget ctx = (TextWidget)w;
+ XawTextPosition end_of_line;
+ XawTextScanDirection dir = XawsdRight;
+ short mult = MULT(ctx);
+
+ if (mult < 0) {
+ dir = XawsdLeft;
+ mult = -mult;
+ }
+
+ StartAction(ctx, event);
+ end_of_line = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL,
+ dir, mult, False);
+ if (end_of_line == ctx->text.insertPos)
+ end_of_line = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL,
+ dir, mult, True);
+
+ if (dir == XawsdRight)
+ _DeleteOrKill(ctx, ctx->text.insertPos, end_of_line, True);
+ else
+ _DeleteOrKill(ctx, end_of_line, ctx->text.insertPos, True);
+ EndAction(ctx);
+}
+
+/*ARGSUSED*/
+static void
+KillToEndOfParagraph(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ DeleteOrKill((TextWidget)w, event, XawsdRight, XawstParagraph, False, True);
+}
+
+void
+_XawTextZapSelection(TextWidget ctx, XEvent *event, Bool kill)
+{
+ StartAction(ctx, event);
+ _DeleteOrKill(ctx, ctx->text.s.left, ctx->text.s.right, kill);
+ EndAction(ctx);
+}
+
+/*ARGSUSED*/
+static void
+KillCurrentSelection(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ _XawTextZapSelection((TextWidget) w, event, True);
+}
+
+#ifndef OLDXAW
+/*ARGSUSED*/
+static void
+KillRingYank(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+ XawTextPosition insertPos = ctx->text.insertPos;
+ Bool first_yank = False;
+
+ if (ctx->text.s.left != ctx->text.s.right)
+ XawTextUnsetSelection((Widget)ctx);
+
+ StartAction(ctx, event);
+
+ if (ctx->text.kill_ring_ptr == NULL) {
+ ctx->text.kill_ring_ptr = &kill_ring_prev;
+ ++ctx->text.kill_ring_ptr->refcount;
+ ctx->text.s.left = ctx->text.s.right = insertPos;
+ first_yank = True;
+ }
+ if (ctx->text.kill_ring_ptr) {
+ int mul = MULT(ctx);
+ XawTextBlock text;
+
+ if (!first_yank) {
+ if (mul < 0)
+ mul = 1;
+ --ctx->text.kill_ring_ptr->refcount;
+ while (mul--) {
+ if ((ctx->text.kill_ring_ptr = ctx->text.kill_ring_ptr->next) == NULL)
+ ctx->text.kill_ring_ptr = &kill_ring_null;
+ }
+ ++ctx->text.kill_ring_ptr->refcount;
+ }
+ text.firstPos = 0;
+ text.length = ctx->text.kill_ring_ptr->length;
+ text.ptr = ctx->text.kill_ring_ptr->contents;
+ text.format = ctx->text.kill_ring_ptr->format;
+
+ if (_XawTextReplace(ctx, ctx->text.s.left, insertPos, &text) == XawEditDone) {
+ ctx->text.kill_ring = KILL_RING_YANK;
+ ctx->text.insertPos = ctx->text.s.left + text.length;
+ }
+ }
+ else
+ XBell(XtDisplay(w), 0);
+
+ EndAction(ctx);
+}
+#endif /* OLDXAW */
+
+/*ARGSUSED*/
+static void
+DeleteCurrentSelection(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ _XawTextZapSelection((TextWidget)w, event, False);
+}
+
+#ifndef OLDXAW
+#define CHECK_SAVE() \
+ if (save && !save->ptr) \
+ save->ptr = _XawTextGetText(ctx, save->firstPos, \
+ save->firstPos + save->length)
+static Bool
+StripSpaces(TextWidget ctx, XawTextPosition left, XawTextPosition right,
+ XawTextPosition *pos, int num_pos, XawTextBlock *save)
+{
+ Bool done, space;
+ int i, cpos, count = 0;
+ XawTextBlock block, text;
+ XawTextPosition ipos, position = left, tmp = left;
+
+ text.firstPos = 0;
+ text.format = XawFmt8Bit;
+ text.ptr = " ";
+ text.length = 1;
+
+ position = XawTextSourceRead(ctx->text.source, position,
+ &block, right - left);
+ done = False;
+ space = False;
+ /* convert tabs and returns to spaces */
+ while (!done) {
+ if (XawTextFormat(ctx, XawFmt8Bit)) {
+ for (i = 0; i < block.length; i++)
+ if (block.ptr[i] == '\t' || block.ptr[i] == '\n') {
+ space = True;
+ break;
+ }
+ }
+ else {
+ wchar_t *wptr = (wchar_t*)block.ptr;
+ for (i = 0; i < block.length; i++)
+ if (wptr[i] == _Xaw_atowc('\t') || wptr[i] == _Xaw_atowc('\n')) {
+ space = True;
+ break;
+ }
+ }
+ if (space) {
+ CHECK_SAVE();
+ if (_XawTextReplace(ctx, tmp + i, tmp + i + 1, &text))
+ return (False);
+ space = False;
+ }
+ tmp += i;
+ position = XawTextSourceRead(ctx->text.source, tmp,
+ &block, right - tmp);
+ if (block.length == 0 || tmp == position || tmp >= right)
+ done = True;
+ }
+
+ text.ptr = "";
+ text.length = 0;
+ position = tmp = left;
+ position = XawTextSourceRead(ctx->text.source, position,
+ &block, right - left);
+ ipos = ctx->text.insertPos;
+ done = False;
+ while (!done) {
+ if (XawTextFormat(ctx, XawFmt8Bit)) {
+ for (i = 0; i < block.length; i++)
+ if (block.ptr[i] == ' ')
+ ++count;
+ else if (count == 1)
+ count = 0;
+ else if (count)
+ break;
+ }
+ else {
+ wchar_t *wptr = (wchar_t*)block.ptr;
+ for (i = 0; i < block.length; i++)
+ if (wptr[i] == _Xaw_atowc(' '))
+ ++count;
+ else if (count == 1)
+ count = 0;
+ else if (count)
+ break;
+ }
+ if (--count > 0) {
+ CHECK_SAVE();
+ if (_XawTextReplace(ctx, tmp + i - count, tmp + i, &text))
+ return (False);
+ right -= count;
+ if (num_pos) {
+ for (cpos = 0; cpos < num_pos; cpos++) {
+ if (tmp + i - count < pos[cpos]) {
+ if (tmp + i < pos[cpos])
+ pos[cpos] -= count;
+ else
+ pos[cpos] = tmp + i - count;
+ }
+ }
+ }
+ else {
+ if (tmp + i - count < ipos) {
+ if (tmp + i < ipos)
+ ipos -= count;
+ else
+ ipos = tmp + i - count;
+ }
+ }
+ tmp += i - count;
+ }
+ else
+ tmp += i + 1;
+ count = 0;
+ position = XawTextSourceRead(ctx->text.source, tmp,
+ &block, right - tmp);
+ if (block.length == 0 || tmp == position || tmp >= right)
+ done = True;
+ }
+ if (!num_pos)
+ ctx->text.insertPos = ipos;
+
+ return (True);
+}
+
+static Bool
+Tabify(TextWidget ctx, XawTextPosition left, XawTextPosition right,
+ XawTextPosition *pos, int num_pos, XawTextBlock *save)
+{
+ Bool done, zero;
+ int i, cpos, count = 0, column = 0, offset = 0;
+ XawTextBlock text, block;
+ XawTextPosition ipos, position = left, tmp = left;
+ TextSinkObject sink = (TextSinkObject)ctx->text.sink;
+ short *char_tabs = sink->text_sink.char_tabs;
+ int tab_count = sink->text_sink.tab_count;
+ int tab_index = 0, tab_column = 0, TAB_SIZE = DEFAULT_TAB_SIZE;
+
+ text.firstPos = 0;
+ text.ptr = "\t";
+ text.format = XawFmt8Bit;
+ text.length = 1;
+
+ position = XawTextSourceRead(ctx->text.source, position,
+ &block, right - left);
+ ipos = ctx->text.insertPos;
+ done = zero = False;
+ if (tab_count)
+ TAB_SIZE = *char_tabs;
+ while (!done) {
+ if (XawTextFormat(ctx, XawFmt8Bit)) {
+ for (i = 0; i < block.length; i++) {
+ ++offset;
+ ++column;
+ if (tab_count) {
+ if (column > tab_column + char_tabs[tab_index]) {
+ TAB_SIZE = tab_index < tab_count - 1 ? char_tabs[tab_index + 1] - char_tabs[tab_index] : *char_tabs;
+ if (++tab_index >= tab_count) {
+ tab_column += char_tabs[tab_count - 1];
+ tab_index = 0;
+ }
+ }
+ }
+ if (block.ptr[i] == ' ') {
+ if (++count > TAB_SIZE)
+ count %= TAB_SIZE;
+ if ((tab_count && column == tab_column + char_tabs[tab_index]) ||
+ (!tab_count && column % TAB_SIZE == 0)) {
+ if (count % (TAB_SIZE + 1) > 1)
+ break;
+ else
+ count = 0;
+ }
+ }
+ else {
+ if (block.ptr[i] == '\n') {
+ zero = True;
+ break;
+ }
+ count = 0;
+ }
+ }
+ }
+ else {
+ wchar_t *wptr = (wchar_t*)block.ptr;
+ for (i = 0; i < block.length; i++) {
+ ++offset;
+ ++column;
+ if (tab_count) {
+ if (column > tab_column + char_tabs[tab_index]) {
+ TAB_SIZE = tab_index < tab_count - 1 ? char_tabs[tab_index + 1] - char_tabs[tab_index] : *char_tabs;
+ if (++tab_index >= tab_count) {
+ tab_column += char_tabs[tab_count - 1];
+ tab_index = 0;
+ }
+ }
+ }
+ if (wptr[i] == _Xaw_atowc(' ')) {
+ if (++count > TAB_SIZE)
+ count %= TAB_SIZE;
+ if ((tab_count && column == tab_column + char_tabs[tab_index]) ||
+ (!tab_count && column % TAB_SIZE == 0)) {
+ if (count % (TAB_SIZE + 1) > 1)
+ break;
+ else
+ count = 0;
+ }
+ }
+ else {
+ if (wptr[i] == _Xaw_atowc('\n')) {
+ zero = True;
+ break;
+ }
+ count = 0;
+ }
+ }
+ }
+ count %= TAB_SIZE + 1;
+ if (!zero && count > 1 && i < block.length) {
+ CHECK_SAVE();
+ if (_XawTextReplace(ctx, tmp + i - count + 1, tmp + i + 1, &text))
+ return (False);
+ right -= count - 1;
+ offset -= count - 1;
+ if (num_pos) {
+ for (cpos = 0; cpos < num_pos; cpos++) {
+ if (tmp + i - count + 1 < pos[cpos]) {
+ if (tmp + i + 1 < pos[cpos])
+ pos[cpos] -= count;
+ else
+ pos[cpos] = tmp + i - count + 1;
+ ++pos[cpos];
+ }
+ }
+ }
+ else {
+ if (tmp + i - count + 1 < ipos) {
+ if (tmp + i + 1 < ipos)
+ ipos -= count;
+ else
+ ipos = tmp + i - count + 1;
+ ++ipos;
+ }
+ }
+ }
+ if (count)
+ --count;
+ if (zero) {
+ count = column = 0;
+ zero = False;
+ if (tab_count) {
+ tab_column = tab_index = 0;
+ TAB_SIZE = *char_tabs;
+ }
+ }
+ else if (i < block.length)
+ count = 0;
+ tmp = left + offset;
+ position = XawTextSourceRead(ctx->text.source, tmp,
+ &block, right - tmp);
+ if (tmp == position || tmp >= right)
+ done = True;
+ }
+ if (!num_pos)
+ ctx->text.insertPos = ipos;
+
+ return (True);
+}
+
+static Bool
+Untabify(TextWidget ctx, XawTextPosition left, XawTextPosition right,
+ XawTextPosition *pos, int num_pos, XawTextBlock *save)
+{
+ Bool done, zero;
+ int i, cpos, count = 0, diff = 0;
+ XawTextBlock block, text;
+ XawTextPosition ipos, position = left, tmp = left;
+ TextSinkObject sink = (TextSinkObject)ctx->text.sink;
+ short *char_tabs = sink->text_sink.char_tabs;
+ int tab_count = sink->text_sink.tab_count;
+ int tab_index = 0, tab_column = 0, tab_base = 0;
+ static char *tabs = " ";
+
+ text.firstPos = 0;
+ text.format = XawFmt8Bit;
+ text.ptr = tabs;
+
+ position = XawTextSourceRead(ctx->text.source, position,
+ &block, right - left);
+ ipos = ctx->text.insertPos;
+ done = False;
+ zero = False;
+ while (!done) {
+ if (XawTextFormat(ctx, XawFmt8Bit))
+ for (i = 0; i < block.length; i++) {
+ if (block.ptr[i] != '\t') {
+ ++count;
+ if (block.ptr[i] == '\n') {
+ zero = True;
+ break;
+ }
+ }
+ else
+ break;
+ }
+ else {
+ wchar_t *wptr = (wchar_t*)block.ptr;
+ for (i = 0; i < block.length; i++)
+ if (wptr[i] != _Xaw_atowc('\t')) {
+ ++count;
+ if (wptr[i] != _Xaw_atowc('\n')) {
+ zero = True;
+ break;
+ }
+ }
+ else
+ break;
+ }
+ if (!zero && i < block.length) {
+ if (tab_count) {
+ while (tab_base + tab_column <= count) {
+ for (; tab_index < tab_count; ++tab_index)
+ if (tab_base + char_tabs[tab_index] > count) {
+ tab_column = char_tabs[tab_index];
+ break;
+ }
+ if (tab_index >= tab_count) {
+ tab_base += char_tabs[tab_count - 1];
+ tab_column = tab_index = 0;
+ }
+ }
+ text.length = (tab_base + tab_column) - count;
+ if (text.length > 8) {
+ int j;
+
+ text.ptr = XtMalloc(text.length);
+ for (j = 0; j < text.length; j++)
+ text.ptr[j] = ' ';
+ }
+ else
+ text.ptr = tabs;
+ }
+ else
+ text.length = DEFAULT_TAB_SIZE - (count % DEFAULT_TAB_SIZE);
+ CHECK_SAVE();
+ if (_XawTextReplace(ctx, tmp + i, tmp + i + 1, &text)) {
+ if (tab_count && text.length > 8)
+ XtFree(text.ptr);
+ return (False);
+ }
+ if (tab_count && text.length > 8)
+ XtFree(text.ptr);
+ count += text.length;
+ right += text.length - 1;
+ if (num_pos) {
+ for (cpos = 0; cpos < num_pos; cpos++) {
+ if (tmp + i < pos[cpos]) {
+ if (tmp + i + 1 < pos[cpos])
+ --pos[cpos];
+ else
+ pos[cpos] = tmp + i;
+ pos[cpos] += text.length;
+ }
+ }
+ }
+ else {
+ if (tmp + i < ipos) {
+ if (tmp + i + 1 < ipos)
+ --ipos;
+ else
+ ipos = tmp + i;
+ ipos += text.length;
+ }
+ }
+ }
+ tmp = left + count + diff;
+ if (zero) {
+ diff += count;
+ count = 0;
+ zero = False;
+ if (tab_count)
+ tab_base = tab_column = tab_index = 0;
+ }
+ position = XawTextSourceRead(ctx->text.source, tmp,
+ &block, right - tmp);
+ if (tmp == position || tmp >= right)
+ done = True;
+ }
+ if (!num_pos)
+ ctx->text.insertPos = ipos;
+
+ return (True);
+}
+
+static int
+FormatText(TextWidget ctx, XawTextPosition left, Bool force,
+ XawTextPosition *pos, int num_pos)
+{
+ char *ptr = NULL;
+ Bool freepos = False, undo, paragraph = pos != NULL;
+ int i, result;
+ XawTextBlock block, *text;
+ XawTextPosition end = ctx->text.lastPos, buf[32];
+ TextSrcObject src = (TextSrcObject)ctx->text.source;
+ XawTextPosition right = SrcScan(ctx->text.source, left, XawstEOL,
+ XawsdRight, 1, False);
+
+ undo = src->textSrc.enable_undo && src->textSrc.undo_state == False;
+ if (undo) {
+ if (!pos) {
+ num_pos = src->textSrc.num_text;
+ pos = XawStackAlloc(sizeof(XawTextPosition) * num_pos, buf);
+ for (i = 0; i < num_pos; i++)
+ pos[i] = ((TextWidget)src->textSrc.text[i])->text.insertPos;
+ freepos = True;
+ }
+ else
+ freepos = False;
+ src->textSrc.undo_state = True;
+ block.ptr = NULL;
+ block.firstPos = left;
+ block.length = right - left;
+ text = &block;
+ }
+ else
+ text = NULL;
+
+ result = DoFormatText(ctx, left, force, 1, text, pos, num_pos, paragraph);
+ if (undo && result == XawEditDone && block.ptr) {
+ char *lbuf, *rbuf;
+ unsigned llen, rlen, size;
+
+ ptr = lbuf = block.ptr;
+ llen = block.length;
+ rlen = llen + (ctx->text.lastPos - end);
+
+ block.firstPos = 0;
+ block.format = _XawTextFormat(ctx);
+
+ rbuf = _XawTextGetText(ctx, left, left + rlen);
+
+ size = XawTextFormat(ctx, XawFmtWide) ? sizeof(wchar_t) : sizeof(char);
+ if (llen != rlen || memcmp(lbuf, rbuf, llen * size)) {
+ block.ptr = lbuf;
+ block.length = llen;
+ _XawTextReplace(ctx, left, left + rlen, &block);
+
+ src->textSrc.undo_state = False;
+ block.ptr = rbuf;
+ block.length = rlen;
+ _XawTextReplace(ctx, left, left + llen, &block);
+ }
+ else
+ src->textSrc.undo_state = False;
+ XtFree(rbuf);
+ }
+ if (undo) {
+ src->textSrc.undo_state = False;
+ if (freepos) {
+ for (i = 0; i < num_pos; i++) {
+ TextWidget tw = (TextWidget)src->textSrc.text[i];
+ tw->text.insertPos = XawMin(XawMax(0, pos[i]), tw->text.lastPos);
+ }
+ XawStackFree(pos, buf);
+ }
+ if (ptr)
+ XtFree(ptr);
+ }
+
+ return (result);
+}
+
+static int
+DoFormatText(TextWidget ctx, XawTextPosition left, Bool force, int level,
+ XawTextBlock *save, XawTextPosition *pos, int num_pos,
+ Bool paragraph)
+{
+ XawTextPosition right = SrcScan(ctx->text.source, left, XawstEOL,
+ XawsdRight, 1, False);
+ XawTextPosition position, tmp, ipos;
+ XawTextBlock block, text;
+ char buf[128];
+ wchar_t *wptr;
+ int i, count, cpos;
+ Bool done, force2 = force, recurse = False;
+
+ position = XawTextSourceRead(ctx->text.source, left, &block, right - left);
+ if (block.length == 0 || left >= right ||
+ (level == 1 && ((XawTextFormat(ctx, XawFmt8Bit) &&
+ block.ptr[0] != ' ' &&
+ block.ptr[0] != '\t' &&
+ !isalnum(*(unsigned char*)block.ptr)) ||
+ (XawTextFormat(ctx, XawFmtWide) &&
+ _Xaw_atowc(XawSP) != *(wchar_t*)block.ptr &&
+ _Xaw_atowc(XawTAB) != *(wchar_t*)block.ptr &&
+ !iswalnum(*(wchar_t*)block.ptr)))))
+ return (XawEditDone);
+
+ if (level == 1 && !paragraph) {
+ tmp = ctx->text.lastPos;
+ if (Untabify(ctx, left, right, pos, num_pos, save) == False)
+ return (XawEditError);
+ right += ctx->text.lastPos - tmp;
+ position = XawTextSourceRead(ctx->text.source, left, &block,
+ right - left);
+ }
+
+ text.firstPos = 0;
+ text.format = XawFmt8Bit;
+
+ ipos = ctx->text.insertPos;
+ count = 0;
+ done = False;
+ while (!done) {
+ if (XawTextFormat(ctx, XawFmt8Bit)) {
+ for (i = 0; i < block.length; i++)
+ if (block.ptr[i] == ' ')
+ ++count;
+ else {
+ done = True;
+ break;
+ }
+ }
+ else {
+ wptr = (wchar_t*)block.ptr;
+ for (i = 0; i < block.length; i++)
+ if (wptr[i] == _Xaw_atowc(' '))
+ ++count;
+ else {
+ done = True;
+ break;
+ }
+ }
+ tmp = position;
+ position = XawTextSourceRead(ctx->text.source, position,
+ &block, right - position);
+ if (tmp == position)
+ done = True;
+ }
+ position = left + count;
+ if (count < ctx->text.left_column) {
+ int bytes = ctx->text.left_column - count;
+
+ text.ptr = XawStackAlloc(bytes, buf);
+ text.length = bytes;
+ for (i = 0; i < bytes; i++)
+ text.ptr[i] = ' ';
+ CHECK_SAVE();
+ if (_XawTextReplace(ctx, left, left, &text)) {
+ XawStackFree(text.ptr, buf);
+ return (XawEditError);
+ }
+ XawStackFree(text.ptr, buf);
+ right += bytes;
+ if (num_pos) {
+ for (cpos = 0; cpos < num_pos; cpos++)
+ if (pos[cpos] >= left)
+ pos[cpos] += bytes;
+ }
+ if (ipos >= left)
+ ipos += bytes;
+ count += bytes;
+ }
+
+ done = False;
+ if (!paragraph && level == 1
+ && ipos <= right && ipos - left > ctx->text.right_column) {
+ XawTextPosition len = ctx->text.lastPos;
+ int skip = ctx->text.justify == XawjustifyRight
+ || ctx->text.justify == XawjustifyCenter ?
+ ctx->text.left_column : count;
+
+ if (pos)
+ for (i = 0; i < num_pos; i++)
+ if (pos[i] == ipos)
+ break;
+
+ StripSpaces(ctx, left + skip, right, pos, num_pos, save);
+ right += ctx->text.lastPos - len;
+ if (pos && i < num_pos)
+ ipos = pos[i];
+ else
+ ipos = ctx->text.insertPos;
+ done = ipos - left > ctx->text.right_column;
+ count = skip + (count == skip + 1);
+ }
+ if ((paragraph || done) && right - left > ctx->text.right_column) {
+ position = tmp = right;
+ XawTextSourceRead(ctx->text.source, position - 1, &block, 1);
+ if (block.length &&
+ ((XawTextFormat(ctx, XawFmt8Bit) &&
+ block.ptr[0] == ' ') ||
+ (XawTextFormat(ctx, XawFmtWide) &&
+ _Xaw_atowc(XawSP) == *(wchar_t*)block.ptr)))
+ --position;
+ while (position - left > ctx->text.right_column) {
+ tmp = position;
+ position = SrcScan(ctx->text.source, position,
+ XawstWhiteSpace, XawsdLeft, 1, True);
+ }
+ if (position <= left + ctx->text.left_column)
+ position = tmp;
+ if (position > left && position - left > ctx->text.left_column
+ && position != right) {
+ text.ptr = "\n";
+ text.length = 1;
+ CHECK_SAVE();
+ if (_XawTextReplace(ctx, position, position + 1, &text))
+ return (XawEditError);
+ right = position;
+ recurse = True;
+ force = True;
+ }
+ }
+
+ if (force) {
+ if (ctx->text.justify == XawjustifyCenter)
+ count = ctx->text.right_column - (count - ctx->text.left_column);
+ else
+ count = ctx->text.right_column;
+ if (count > right - left)
+ count -= right - left;
+ else
+ count = 0;
+ }
+ else
+ count = 0;
+ if (count > 0) {
+ switch (ctx->text.justify) {
+ case XawjustifyLeft:
+ break;
+ case XawjustifyRight:
+ case XawjustifyCenter:
+ if (ctx->text.justify == XawjustifyCenter) {
+ int alnum = 0;
+
+ if (!(count & 1)) {
+ XawTextSourceRead(ctx->text.source, right, &block, 1);
+ if ((XawTextFormat(ctx, XawFmt8Bit)
+ && isalnum(*(unsigned char*)block.ptr)) ||
+ (XawTextFormat(ctx, XawFmtWide)
+ && iswalnum(*(wchar_t*)block.ptr)))
+ alnum = 1;
+ }
+ count = (count + alnum) >> 1;
+ }
+ text.ptr = XawStackAlloc(count, buf);
+ text.length = count;
+ for (i = 0; i < count; i++)
+ text.ptr[i] = ' ';
+ CHECK_SAVE();
+ if (_XawTextReplace(ctx, left, left, &text)) {
+ XawStackFree(text.ptr, buf);
+ return (XawEditError);
+ }
+ XawStackFree(text.ptr, buf);
+ position += count;
+ right += count;
+ if (num_pos) {
+ for (cpos = 0; cpos < num_pos; cpos++)
+ if (pos[cpos] > left)
+ pos[cpos] += count;
+ }
+ else if (ipos > left)
+ ipos += count;
+ break;
+ case XawjustifyFull:
+ i = 0;
+ tmp = left;
+ /*CONSTCOND*/
+ while (True) {
+ tmp = SrcScan(ctx->text.source, tmp, XawstWhiteSpace,
+ XawsdRight, 1, True);
+ if (tmp < right)
+ ++i;
+ else
+ break;
+ }
+ if (i) {
+ double inc, ii;
+ int bytes, steps;
+
+ bytes = count;
+ inc = ii = (count + .5) / (double)i;
+
+ steps = count;
+ text.ptr = XawStackAlloc(steps, buf);
+ for (i = 0; i < steps; i++)
+ text.ptr[i] = ' ';
+ tmp = left;
+ CHECK_SAVE();
+ while (bytes) {
+ steps = 1;
+ while (inc + ii < 1) {
+ ++steps;
+ inc += ii;
+ }
+ tmp = SrcScan(ctx->text.source, tmp, XawstWhiteSpace,
+ XawsdRight, steps, True);
+ if (bytes > inc)
+ text.length = (int)inc;
+ else
+ text.length = bytes;
+ bytes -= text.length;
+ if (_XawTextReplace(ctx, tmp, tmp, &text)) {
+ XawStackFree(buf, text.ptr);
+ return (XawEditError);
+ }
+ if (num_pos) {
+ for (cpos = 0; cpos < num_pos; cpos++)
+ if (tmp <= pos[cpos])
+ pos[cpos] += text.length;
+ }
+ else if (tmp <= ipos)
+ ipos += text.length;
+ inc -= (int)inc;
+ inc += ii;
+ }
+ position += count;
+ right += count;
+ XawStackFree(buf, text.ptr);
+ }
+ break;
+ }
+ }
+
+ if (!num_pos)
+ ctx->text.insertPos = XawMin(ipos, ctx->text.lastPos);
+
+ return (recurse ? DoFormatText(ctx, position + 1,
+ ctx->text.justify != XawjustifyFull
+ && (force2 || paragraph),
+ ++level, save, pos, num_pos, paragraph)
+ : XawEditDone);
+}
+#undef CHECK_SAVE
+
+/*ARGSUSED*/
+static void
+Indent(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+ TextSrcObject src = (TextSrcObject)ctx->text.source;
+ XawTextPosition from, to, tmp, end = 0, *pos, *posbuf[32];
+ char buf[32];
+ XawTextBlock text;
+ int i, spaces = MULT(ctx);
+ char *lbuf = NULL, *rbuf;
+ unsigned llen = 0, rlen, size;
+ Bool undo = src->textSrc.enable_undo && src->textSrc.undo_state == False;
+ Bool format = ctx->text.auto_fill
+ && ctx->text.left_column < ctx->text.right_column;
+
+ text.firstPos = 0;
+ text.format = XawFmt8Bit;
+ text.ptr = "";
+
+ StartAction(ctx, event);
+
+ pos = XawStackAlloc(sizeof(XawTextPosition) * src->textSrc.num_text, posbuf);
+ for (i = 0; i < src->textSrc.num_text; i++)
+ pos[i] = ((TextWidget)src->textSrc.text[i])->text.insertPos;
+
+ if (!GetBlockBoundaries(ctx, &from, &to)) {
+ EndAction(ctx);
+ XawStackFree(pos, posbuf);
+ return;
+ }
+
+ if (undo) {
+ llen = to - from;
+ end = ctx->text.lastPos;
+ lbuf = _XawTextGetText(ctx, from, to);
+ src->textSrc.undo_state = True;
+ }
+
+ tmp = ctx->text.lastPos;
+ if (!Untabify(ctx, from, to, pos, src->textSrc.num_text, NULL)) {
+ XBell(XtDisplay(ctx), 0);
+ EndAction(ctx);
+ XawStackFree(pos, posbuf);
+ if (undo) {
+ src->textSrc.undo_state = True;
+ XtFree(lbuf);
+ }
+ return;
+ }
+ to += ctx->text.lastPos - tmp;
+
+ tmp = from;
+
+ if (spaces > 0) {
+ text.ptr = XawStackAlloc(spaces, buf);
+ for (i = 0; i < spaces; i++)
+ text.ptr[i] = ' ';
+
+ text.length = spaces;
+ while (tmp < to) {
+ _XawTextReplace(ctx, tmp, tmp, &text);
+
+ for (i = 0; i < src->textSrc.num_text; i++)
+ if (tmp < pos[i])
+ pos[i] += spaces;
+
+ to += spaces;
+ tmp = SrcScan(ctx->text.source, tmp, XawstEOL, XawsdRight, 1, True);
+ }
+ XawStackFree(text.ptr, buf);
+ }
+ else {
+ int min = 32767;
+
+ text.length = 0;
+ tmp = from;
+
+ /* find the amount of spaces to cut */
+ while (tmp < to) {
+ (void)BlankLine(w, tmp, &i);
+ if (i < min)
+ min = i;
+ tmp = SrcScan(ctx->text.source, tmp, XawstEOL, XawsdRight, 1, True);
+ }
+ spaces = XawMin(-spaces, min);
+
+ /* cut the spaces */
+ tmp = from;
+ while (tmp < to) {
+ _XawTextReplace(ctx, tmp, tmp + spaces, &text);
+
+ for (i = 0; i < src->textSrc.num_text; i++)
+ if (tmp < pos[i]) {
+ if (tmp + spaces < pos[i])
+ pos[i] -= spaces;
+ else
+ pos[i] = tmp;
+ }
+
+ to -= spaces;
+ tmp = SrcScan(ctx->text.source, tmp, XawstEOL, XawsdRight, 1, True);
+ }
+ }
+
+ if (!format)
+ Tabify(ctx, from, to, pos, src->textSrc.num_text, NULL);
+
+ if (undo) {
+ rlen = llen + (ctx->text.lastPos - end);
+ rbuf = _XawTextGetText(ctx, from, from + rlen);
+
+ text.format = _XawTextFormat(ctx);
+ size = XawTextFormat(ctx, XawFmtWide) ? sizeof(wchar_t) : sizeof(char);
+ if (llen != rlen || memcmp(lbuf, rbuf, llen * size)) {
+ text.ptr = lbuf;
+ text.length = llen;
+ _XawTextReplace(ctx, from, from + rlen, &text);
+
+ src->textSrc.undo_state = False;
+ text.ptr = rbuf;
+ text.length = rlen;
+ _XawTextReplace(ctx, from, from + llen, &text);
+ }
+ else
+ src->textSrc.undo_state = False;
+ XtFree(lbuf);
+ XtFree(rbuf);
+ }
+
+ for (i = 0; i < src->textSrc.num_text; i++) {
+ TextWidget tw = (TextWidget)src->textSrc.text[i];
+
+ tw->text.insertPos = XawMin(XawMax(0, pos[i]), tw->text.lastPos);
+ }
+ XawStackFree(pos, posbuf);
+ ctx->text.showposition = True;
+
+ EndAction(ctx);
+}
+
+/*ARGSUSED*/
+static void
+ToggleOverwrite(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ ctx->text.overwrite = !ctx->text.overwrite;
+
+ /* call information callback */
+ _XawTextSetLineAndColumnNumber(ctx, True);
+}
+#endif /* OLDXAW */
+
+/*
+ * Insertion Routines
+ */
+static int
+InsertNewLineAndBackupInternal(TextWidget ctx)
+{
+ int count, error = XawEditDone, mult = MULT(ctx);
+#ifndef OLDXAW
+ XawTextPosition position;
+#endif
+ XawTextBlock text;
+ char buf[32];
+
+ if (mult < 0) {
+ ctx->text.mult = 1;
+ return (XawEditError);
+ }
+
+ text.format = _XawTextFormat(ctx);
+ text.length = mult;
+ text.firstPos = 0;
+
+ if (text.format == XawFmtWide) {
+ wchar_t *wptr;
+
+ text.ptr = XawStackAlloc(sizeof(wchar_t) * mult, buf);
+ wptr = (wchar_t *)text.ptr;
+ for (count = 0; count < mult; count++)
+ wptr[count] = _Xaw_atowc(XawLF);
+ }
+ else {
+ text.ptr = XawStackAlloc(sizeof(char) * mult, buf);
+ for (count = 0; count < mult; count++)
+ text.ptr[count] = XawLF;
+ }
+
+#ifndef OLDXAW
+ position = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstEOL, XawsdLeft, 1, False);
+#endif
+ if (_XawTextReplace(ctx, ctx->text.insertPos, ctx->text.insertPos, &text)) {
+ XBell( XtDisplay(ctx), 50);
+ error = XawEditError;
+ }
+ else {
+ ctx->text.showposition = TRUE;
+ ctx->text.insertPos += text.length;
+ }
+
+ XawStackFree(text.ptr, buf);
+
+#ifndef OLDXAW
+ if (ctx->text.auto_fill && error == XawEditDone)
+ (void)FormatText(ctx, position, ctx->text.justify != XawjustifyFull,
+ NULL, 0);
+#endif
+
+ return (error);
+}
+
+/*ARGSUSED*/
+static void
+InsertNewLineAndBackup(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ TextWidget ctx = (TextWidget)w;
+ XawTextPosition insertPos = ctx->text.insertPos;
+
+ StartAction((TextWidget)w, event);
+ (void)InsertNewLineAndBackupInternal(ctx);
+ ctx->text.insertPos = SrcScan(ctx->text.source, insertPos, XawstEOL,
+ XawsdRight, 1, False);
+ EndAction((TextWidget)w);
+}
+
+static int
+LocalInsertNewLine(TextWidget ctx, XEvent *event)
+{
+ int error;
+
+ StartAction(ctx, event);
+ error = InsertNewLineAndBackupInternal(ctx);
+ ctx->text.from_left = -1;
+ EndAction(ctx);
+
+ return (error);
+}
+
+/*ARGSUSED*/
+static void
+InsertNewLine(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ (void)LocalInsertNewLine((TextWidget)w, event);
+}
+
+/*ARGSUSED*/
+static void
+InsertNewLineAndIndent(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ XawTextBlock text;
+ XawTextPosition pos1;
+ int length;
+ TextWidget ctx = (TextWidget)w;
+ String line_to_ip;
+
+ StartAction(ctx, event);
+ pos1 = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstEOL, XawsdLeft, 1, False);
+
+ line_to_ip = _XawTextGetText(ctx, pos1, ctx->text.insertPos);
+
+ text.format = _XawTextFormat(ctx);
+ text.firstPos = 0;
+
+ if (text.format == XawFmtWide) {
+ wchar_t *ptr;
+
+ text.ptr = XtMalloc((2 + wcslen((wchar_t*)line_to_ip))
+ * sizeof(wchar_t));
+ ptr = (wchar_t*)text.ptr;
+ ptr[0] = _Xaw_atowc(XawLF);
+ wcscpy((wchar_t*)++ptr, (wchar_t*)line_to_ip);
+
+ length = wcslen((wchar_t*)text.ptr);
+ while (length && (iswspace(*ptr) || *ptr == _Xaw_atowc(XawTAB)))
+ ptr++, length--;
+ *ptr = (wchar_t)0;
+ text.length = wcslen((wchar_t*)text.ptr);
+ }
+ else {
+ char *ptr;
+
+ length = strlen(line_to_ip);
+ text.ptr = XtMalloc((2 + length) * sizeof(char));
+ ptr = text.ptr;
+ ptr[0] = XawLF;
+ strcpy(++ptr, line_to_ip);
+
+ length++;
+ while (length && (isspace(*ptr) || (*ptr == XawTAB)))
+ ptr++, length--;
+ *ptr = '\0';
+ text.length = strlen(text.ptr);
+ }
+ XtFree(line_to_ip);
+
+ if (_XawTextReplace(ctx,ctx->text.insertPos, ctx->text.insertPos, &text)) {
+ XBell(XtDisplay(ctx), 50);
+ XtFree(text.ptr);
+ EndAction(ctx);
+ return;
+ }
+
+ XtFree(text.ptr);
+ ctx->text.from_left = -1;
+ ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.old_insert,
+ XawstPositions, XawsdRight, text.length, True);
+ EndAction(ctx);
+}
+
+/*
+ * Selection Routines
+ */
+static void
+SelectWord(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+ XawTextPosition l, r;
+
+ StartAction(ctx, event);
+ l = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstWhiteSpace, XawsdLeft, 1, False);
+ r = SrcScan(ctx->text.source, l, XawstWhiteSpace, XawsdRight, 1, False);
+ _XawTextSetSelection(ctx, l, r, params, *num_params);
+ EndAction(ctx);
+}
+
+static void
+SelectAll(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ StartAction(ctx, event);
+ _XawTextSetSelection(ctx,zeroPosition,ctx->text.lastPos,params,*num_params);
+ EndAction(ctx);
+}
+
+static void
+ModifySelection(TextWidget ctx, XEvent *event,
+ XawTextSelectionMode mode,
+ XawTextSelectionAction action,
+ String *params, Cardinal *num_params)
+{
+#ifndef OLDXAW
+ int old_y = ctx->text.ev_y;
+#endif
+
+ StartAction(ctx, event);
+ NotePosition(ctx, event);
+
+#ifndef OLDXAW
+ if (event->type == MotionNotify) {
+ if (ctx->text.ev_y <= ctx->text.margin.top) {
+ if (old_y >= ctx->text.ev_y)
+ XawTextScroll(ctx, -1, 0);
+ }
+ else if (ctx->text.ev_y >= XtHeight(ctx) - ctx->text.margin.bottom) {
+ if (old_y <= ctx->text.ev_y
+ && !IsPositionVisible(ctx, ctx->text.lastPos))
+ XawTextScroll(ctx, 1, 0);
+ }
+ }
+#endif
+ ctx->text.from_left = -1;
+ _XawTextAlterSelection(ctx, mode, action, params, num_params);
+
+ EndAction(ctx);
+}
+
+static void
+SelectStart(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+
+#ifndef OLDXAW
+ if (!ctx->text.selection_state) {
+ ctx->text.selection_state = True;
+#endif
+ ModifySelection(ctx, event,
+ XawsmTextSelect, XawactionStart, params, num_params);
+#ifndef OLDXAW
+ }
+#endif
+}
+
+static void
+SelectAdjust(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+
+#ifndef OLDXAW
+ if (ctx->text.selection_state)
+#endif
+ ModifySelection(ctx, event,
+ XawsmTextSelect, XawactionAdjust, params, num_params);
+}
+
+static void
+SelectEnd(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+
+#ifndef OLDXAW
+ if (ctx->text.selection_state) {
+ ctx->text.selection_state = False;
+#endif
+ ModifySelection(ctx, event,
+ XawsmTextSelect, XawactionEnd, params, num_params);
+#ifndef OLDXAW
+ }
+#endif
+}
+
+static void
+ExtendStart(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+
+#ifndef OLDXAW
+ if (!ctx->text.selection_state) {
+ ctx->text.selection_state = True;
+#endif
+ ModifySelection(ctx, event,
+ XawsmTextExtend, XawactionStart, params, num_params);
+#ifndef OLDXAW
+ }
+#endif
+}
+
+static void
+ExtendAdjust(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+
+#ifndef OLDXAW
+ if (ctx->text.selection_state)
+#endif
+ ModifySelection(ctx, event,
+ XawsmTextExtend, XawactionAdjust, params, num_params);
+}
+
+static void
+ExtendEnd(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+
+#ifndef OLDXAW
+ if (ctx->text.selection_state) {
+ ctx->text.selection_state = False;
+#endif
+ ModifySelection(ctx, event,
+ XawsmTextExtend, XawactionEnd, params, num_params);
+#ifndef OLDXAW
+ }
+#endif
+}
+
+static void
+SelectSave(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ int num_atoms;
+ Atom *sel;
+ Display *dpy = XtDisplay(w);
+ Atom selections[256];
+
+ StartAction((TextWidget)w, event);
+ num_atoms = *num_params;
+ if (num_atoms > 256)
+ num_atoms = 256;
+ for (sel=selections; --num_atoms >= 0; sel++, params++)
+ *sel = XInternAtom(dpy, *params, False);
+ num_atoms = *num_params;
+ _XawTextSaltAwaySelection((TextWidget)w, selections, num_atoms);
+ EndAction((TextWidget)w);
+}
+
+/*
+ * Misc. Routines
+ */
+/*ARGSUSED*/
+static void
+SetKeyboardFocus(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ Widget shell, parent;
+
+ shell = parent = w;
+ while (parent) {
+ if (XtIsShell(shell = parent))
+ break;
+ parent = XtParent(parent);
+ }
+ XtSetKeyboardFocus(shell, w);
+}
+
+/*ARGSUSED*/
+static void
+RedrawDisplay(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ StartAction((TextWidget)w, event);
+ _XawTextClearAndCenterDisplay((TextWidget)w);
+ EndAction((TextWidget)w);
+}
+
+/* This is kind of a hack, but, only one text widget can have focus at
+ * a time on one display. There is a problem in the implementation of the
+ * text widget, the scrollbars can not be adressed via editres, since they
+ * are not children of a subclass of composite.
+ * The focus variable is required to make sure only one text window will
+ * show a block cursor at one time.
+ */
+struct _focus { Display *display; Widget widget; };
+static struct _focus *focus;
+static Cardinal num_focus;
+
+/*ARGSUSED*/
+static void
+DestroyFocusCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+ struct _focus *f = (struct _focus*)(user_data);
+
+ if (f->widget == w)
+ f->widget = NULL;
+}
+
+/*ARGSUSED*/
+static void
+TextFocusIn(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ TextWidget ctx = (TextWidget)w;
+ Bool display_caret = ctx->text.display_caret;
+ int i;
+
+ if (event->xfocus.detail == NotifyPointer)
+ return;
+
+ if (event->xfocus.send_event) {
+ Window root, child;
+ int rootx, rooty, x, y;
+ unsigned int mask;
+
+ if (ctx->text.hasfocus)
+ return;
+
+ if (XQueryPointer(XtDisplay(w), XtWindow(w), &root, &child,
+ &rootx, &rooty, &x, &y, &mask)) {
+ if (child)
+ return;
+ }
+ }
+
+ /* Let the input method know focus has arrived. */
+ _XawImSetFocusValues(w, NULL, 0);
+
+ if (display_caret)
+ StartAction(ctx, event);
+ ctx->text.hasfocus = TRUE;
+ if (display_caret)
+ EndAction(ctx);
+
+ for (i = 0; i < num_focus; i++)
+ if (focus[i].display == XtDisplay(w))
+ break;
+ if (i >= num_focus) {
+ focus = (struct _focus*)
+ XtRealloc((XtPointer)focus, sizeof(struct _focus) * (num_focus + 1));
+ i = num_focus;
+ focus[i].widget = NULL;
+ focus[i].display = XtDisplay(w);
+ num_focus++;
+ }
+ if (focus[i].widget != w) {
+ Widget old = focus[i].widget;
+
+ focus[i].widget = w;
+ if (old != NULL) {
+ TextFocusOut(old, event, p, n);
+ /* TextFocusOut may set it to NULL */
+ focus[i].widget = w;
+ }
+ XtAddCallback(w, XtNdestroyCallback,
+ DestroyFocusCallback, (XtPointer)&focus[i]);
+ }
+}
+
+/*ARGSUSED*/
+static void
+TextFocusOut(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ TextWidget ctx = (TextWidget)w;
+ Bool display_caret = ctx->text.display_caret;
+ Widget shell;
+ Window window;
+ int i, revert;
+
+ shell = w;
+ while (shell) {
+ if (XtIsShell(shell))
+ break;
+ shell = XtParent(shell);
+ }
+
+ for (i = 0; i < num_focus; i++)
+ if (focus[i].display == XtDisplay(w))
+ break;
+ XGetInputFocus(XtDisplay(w), &window, &revert);
+ if ((XtWindow(shell) == window &&
+ (i < num_focus && focus[i].widget == w))
+ || event->xfocus.detail == NotifyPointer)
+ return;
+
+ if (i < num_focus && focus[i].widget) {
+ XtRemoveCallback(focus[i].widget, XtNdestroyCallback,
+ DestroyFocusCallback, (XtPointer)&focus[i]);
+ focus[i].widget = NULL;
+ }
+
+ /* Let the input method know focus has left.*/
+ _XawImUnsetFocus(w);
+
+ if (display_caret)
+ StartAction(ctx, event);
+ ctx->text.hasfocus = FALSE;
+ if (display_caret)
+ EndAction(ctx);
+}
+
+/*ARGSUSED*/
+static void
+TextEnterWindow(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ if ((event->xcrossing.detail != NotifyInferior) && event->xcrossing.focus
+ && !ctx->text.hasfocus)
+ _XawImSetFocusValues(w, NULL, 0);
+}
+
+/*ARGSUSED*/
+static void
+TextLeaveWindow(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ if ((event->xcrossing.detail != NotifyInferior) && event->xcrossing.focus
+ && !ctx->text.hasfocus)
+ _XawImUnsetFocus(w);
+}
+
+/*
+ * Function:
+ * AutoFill
+ * Arguments: ctx - The text widget.
+ *
+ * Description:
+ * Breaks the line at the previous word boundry when
+ * called inside InsertChar.
+ */
+static void
+AutoFill(TextWidget ctx)
+{
+ int width, height, x, line_num, max_width;
+ XawTextPosition ret_pos;
+ XawTextBlock text;
+ XRectangle cursor;
+ wchar_t wc_buf[2];
+
+ for (line_num = 0; line_num < ctx->text.lt.lines ; line_num++)
+ if (ctx->text.lt.info[line_num].position >= ctx->text.insertPos)
+ break;
+ if (line_num)
+ line_num--; /* backup a line. */
+
+ XawTextSinkGetCursorBounds(ctx->text.sink, &cursor);
+ max_width = Max(0, (int)XtWidth(ctx) - RHMargins(ctx) - cursor.width);
+
+ x = ctx->text.r_margin.left;
+ XawTextSinkFindPosition(ctx->text.sink, ctx->text.lt.info[line_num].position,
+ x, max_width, True, &ret_pos,
+ &width, &height);
+
+ if (ret_pos <= ctx->text.lt.info[line_num].position
+ || ret_pos >= ctx->text.insertPos || ret_pos < 1)
+ return;
+
+ XawTextSourceRead(ctx->text.source, ret_pos - 1, &text, 1);
+
+ if (XawTextFormat(ctx, XawFmtWide)) {
+ wc_buf[0] = *(wchar_t *)text.ptr;
+ if (wc_buf[0] != _Xaw_atowc(XawSP) && wc_buf[0] != _Xaw_atowc(XawTAB))
+ /* Only eats white spaces */
+ return;
+
+ text.format = XawFmtWide;
+ text.ptr = (char *)wc_buf;
+ wc_buf[0] = _Xaw_atowc(XawLF);
+ wc_buf[1] = 0;
+ }
+ else {
+ if (text.ptr[0] != XawSP && text.ptr[0] != XawTAB)
+ /* Only eats white spaces */
+ return;
+
+ text.format = XawFmt8Bit;
+ text.ptr = "\n";
+ }
+ text.length = 1;
+ text.firstPos = 0;
+
+ if (_XawTextReplace(ctx, ret_pos - 1, ret_pos, &text))
+ XBell(XtDisplay((Widget)ctx), 0);
+
+ if (++ctx->text.insertPos > ctx->text.lastPos)
+ ctx->text.insertPos = ctx->text.lastPos;
+}
+
+/*ARGSUSED*/
+static void
+InsertChar(Widget w, XEvent *event, String *p, Cardinal *n)
+{
+ TextWidget ctx = (TextWidget)w;
+ char *ptr, strbuf[128], ptrbuf[512];
+ int count, error, mult = MULT(ctx);
+ KeySym keysym;
+ XawTextBlock text;
+#ifndef OLDXAW
+ Bool format = False;
+#endif
+ XawTextPosition from, to;
+
+ if (XtIsSubclass (ctx->text.source, (WidgetClass) multiSrcObjectClass))
+ text.length = _XawImWcLookupString(w, &event->xkey, (wchar_t*)strbuf,
+ sizeof(strbuf), &keysym);
+ else
+ text.length = _XawLookupString(w, (XKeyEvent*)event, strbuf,
+ sizeof(strbuf), &keysym);
+
+ if (text.length == 0)
+ return;
+
+ if (mult < 0) {
+ ctx->text.mult = 1;
+ return;
+ }
+
+ text.format = _XawTextFormat(ctx);
+ if (text.format == XawFmtWide) {
+ text.ptr = ptr = XawStackAlloc(sizeof(wchar_t) * text.length
+ * mult, ptrbuf);
+ for (count = 0; count < mult; count++) {
+ memcpy((char*)ptr, (char *)strbuf, sizeof(wchar_t) * text.length);
+ ptr += sizeof(wchar_t) * text.length;
+ }
+#ifndef OLDXAW
+ if (mult == 1)
+ format = ctx->text.left_column < ctx->text.right_column;
+#endif
+ }
+ else { /* == XawFmt8Bit */
+ text.ptr = ptr = XawStackAlloc(text.length * mult, ptrbuf);
+ for (count = 0; count < mult; count++) {
+ strncpy(ptr, strbuf, text.length);
+ ptr += text.length;
+ }
+#ifndef OLDXAW
+ if (mult == 1)
+ format = ctx->text.left_column < ctx->text.right_column;
+#endif
+ }
+
+ text.length = text.length * mult;
+ text.firstPos = 0;
+
+ StartAction(ctx, event);
+#ifndef OLDXAW
+ if (mult == 1)
+ _XawSourceSetUndoMerge((TextSrcObject)ctx->text.source, True);
+#endif
+
+ from = ctx->text.insertPos;
+#ifndef OLDXAW
+ if (ctx->text.overwrite) {
+ XawTextPosition tmp;
+
+ to = from + mult;
+ tmp = SrcScan(ctx->text.source, from, XawstEOL, XawsdRight, 1, False);
+ if (to > tmp)
+ to = tmp;
+ }
+ else
+#endif
+ to = from;
+
+ error = _XawTextReplace(ctx, from , to, &text);
+
+ if (error == XawEditDone) {
+ ctx->text.from_left = -1;
+ ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.old_insert,
+ XawstPositions, XawsdRight,
+ text.length, True);
+ if (ctx->text.auto_fill) {
+#ifndef OLDXAW
+ if (format)
+ (void)FormatText(ctx, SrcScan(ctx->text.source,
+ ctx->text.insertPos, XawstEOL,
+ XawsdLeft, 1, False), False,
+ NULL, 0);
+ else
+#endif
+ AutoFill(ctx);
+ }
+ }
+ else
+ XBell(XtDisplay(ctx), 50);
+
+ XawStackFree(text.ptr, ptrbuf);
+ EndAction(ctx);
+
+ if (error == XawEditDone && text.format == XawFmt8Bit && text.length == 1
+ && (text.ptr[0] == ')' || text.ptr[0] == ']' || text.ptr[0] == '}')
+ && ctx->text.display_caret) {
+ static struct timeval tmval = {0, 500000};
+ fd_set fds;
+ Widget source = ctx->text.source;
+ XawTextPosition insertPos = ctx->text.insertPos, pos, tmp, last;
+ char left, right = text.ptr[0];
+ int level = 0;
+ XtAppContext app_context = XtWidgetToApplicationContext(w);
+
+ left = right == ')' ? '(' : right == ']' ? '[' : '{';
+
+ last = insertPos - 1;
+ do {
+ text.ptr[0] = left;
+ pos = XawTextSourceSearch(source, last, XawsdLeft, &text);
+ if (pos == XawTextSearchError || !IsPositionVisible(ctx, pos))
+ return;
+ text.ptr[0] = right;
+ tmp = pos;
+ do {
+ tmp = XawTextSourceSearch(source, tmp, XawsdRight, &text);
+ if (tmp == XawTextSearchError)
+ return;
+ if (tmp <= last)
+ ++level;
+ } while (++tmp <= last);
+ --level;
+ last = pos;
+ } while (level);
+
+ StartAction(ctx, NULL);
+#ifndef OLDXAW
+ _XawSourceSetUndoMerge((TextSrcObject)ctx->text.source, True);
+#endif
+ ctx->text.insertPos = pos;
+ EndAction(ctx);
+
+ XSync(XtDisplay(w), False);
+ while (XtAppPending(app_context) & XtIMXEvent) {
+ XEvent ev;
+ if (! XtAppPeekEvent(app_context, &ev))
+ break;
+ if (ev.type == KeyPress || ev.type == ButtonPress)
+ break;
+ XtAppProcessEvent(app_context, XtIMXEvent);
+ }
+ FD_ZERO(&fds);
+ FD_SET(ConnectionNumber(XtDisplay(w)), &fds);
+ (void)select(FD_SETSIZE, &fds, NULL, NULL, &tmval);
+ if (tmval.tv_usec != 500000)
+ usleep(40000);
+
+ StartAction(ctx, NULL);
+#ifndef OLDXAW
+ _XawSourceSetUndoMerge((TextSrcObject)ctx->text.source, True);
+#endif
+ ctx->text.insertPos = insertPos;
+ EndAction(ctx);
+ }
+}
+
+/* IfHexConvertHexElseReturnParam() - called by InsertString
+ *
+ * i18n requires the ability to specify multiple characters in a hexa-
+ * decimal string at once. Since Insert was already too long, I made
+ * this a seperate routine.
+ *
+ * A legal hex string in MBNF: '0' 'x' ( HEX-DIGIT HEX-DIGIT )+ '\0'
+ *
+ * WHEN: the passed param is a legal hex string
+ * RETURNS: a pointer to that converted, null terminated hex string;
+ * len_return holds the character count of conversion result
+ *
+ * WHEN: the passed param is not a legal hex string:
+ * RETURNS: the parameter passed;
+ * len_return holds the char count of param.
+ *
+ * NOTE: In neither case will there be strings to free. */
+static char *
+IfHexConvertHexElseReturnParam(char *param, int *len_return)
+{
+ char *p; /* steps through param char by char */
+ char c; /* holds the character pointed to by p */
+ int ind; /* steps through hexval buffer char by char */
+ static char hexval[XawTextActionMaxHexChars];
+ Boolean first_digit;
+
+ /* reject if it doesn't begin with 0x and at least one more character. */
+ if ((param[0] != '0') || (param[1] != 'x') || (param[2] == '\0')) {
+ *len_return = strlen(param);
+ return(param);
+ }
+
+ /* Skip the 0x; go character by character shifting and adding. */
+ first_digit = True;
+ ind = 0;
+ hexval[ind] = '\0';
+
+ for (p = param+2; (c = *p) != '\0'; p++) {
+ hexval[ind] *= 16;
+ if (c >= '0' && c <= '9')
+ hexval[ind] += c - '0';
+ else if (c >= 'a' && c <= 'f')
+ hexval[ind] += c - 'a' + 10;
+ else if (c >= 'A' && c <= 'F')
+ hexval[ind] += c - 'A' + 10;
+ else
+ break;
+
+ /* If we didn't break in preceding line, it was a good hex char. */
+ if (first_digit)
+ first_digit = False;
+ else {
+ first_digit = True;
+ if (++ind < XawTextActionMaxHexChars)
+ hexval[ind] = '\0';
+ else {
+ *len_return = strlen(param);
+ return(param);
+ }
+ }
+ }
+
+ /* We quit the above loop becasue we hit a non hex. If that char is \0... */
+ if ((c == '\0') && first_digit) {
+ *len_return = strlen(hexval);
+ return (hexval); /* ...it was a legal hex string, so return it */
+ }
+
+ /* Else, there were non-hex chars or odd digit count, so... */
+
+ *len_return = strlen(param);
+ return (param); /* ...return the verbatim string. */
+}
+
+/* InsertString() - action
+ *
+ * Mostly rewritten for R6 i18n.
+ *
+ * Each parameter, in turn, will be insert at the inputPos
+ * and the inputPos advances to the insertion's end.
+ *
+ * The exception is that parameters composed of the two
+ * characters 0x, followed only by an even number of
+ * hexadecimal digits will be converted to characters */
+/*ARGSUSED*/
+static void
+InsertString(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+ XtAppContext app_con = XtWidgetToApplicationContext(w);
+ XawTextBlock text;
+ int i;
+
+ text.firstPos = 0;
+ text.format = _XawTextFormat(ctx);
+
+ StartAction(ctx, event);
+ for (i = *num_params; i; i--, params++) { /* DO FOR EACH PARAMETER */
+ text.ptr = IfHexConvertHexElseReturnParam(*params, &text.length);
+
+ if (text.length == 0)
+ continue;
+
+ if (XawTextFormat(ctx, XawFmtWide)) { /* convert to WC */
+ int temp_len;
+
+ text.ptr = (char*)_XawTextMBToWC(XtDisplay(w), text.ptr,
+ &text.length);
+
+ if (text.ptr == NULL) { /* conversion error */
+ XtAppWarningMsg(app_con,
+ "insertString", "textAction", "XawError",
+ "insert-string()'s parameter contents "
+ "not legal in this locale.",
+ NULL, NULL);
+ ParameterError(w, *params);
+ continue;
+ }
+
+ /* Double check that the new input is legal: try to convert to MB. */
+
+ temp_len = text.length; /* _XawTextWCToMB's 3rd arg is in_out */
+ if (_XawTextWCToMB(XtDisplay(w), (wchar_t*)text.ptr, &temp_len)
+ == NULL) {
+ XtAppWarningMsg( app_con,
+ "insertString", "textAction", "XawError",
+ "insert-string()'s parameter contents "
+ "not legal in this locale.",
+ NULL, NULL);
+ ParameterError(w, *params);
+ continue;
+ }
+ } /* convert to WC */
+
+ if (_XawTextReplace(ctx, ctx->text.insertPos,
+ ctx->text.insertPos, &text)) {
+ XBell(XtDisplay(ctx), 50);
+ EndAction(ctx);
+ return;
+ }
+
+ ctx->text.from_left = -1;
+ /* Advance insertPos to the end of the string we just inserted. */
+ ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.old_insert,
+ XawstPositions, XawsdRight, text.length,
+ True);
+
+ } /* DO FOR EACH PARAMETER */
+
+ EndAction(ctx);
+}
+
+/* DisplayCaret() - action
+ *
+ * The parameter list should contain one boolean value. If the
+ * argument is true, the cursor will be displayed. If false, not.
+ *
+ * The exception is that EnterNotify and LeaveNotify events may
+ * have a second argument, "always". If they do not, the cursor
+ * is only affected if the focus member of the event is true. */
+static void
+DisplayCaret(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+ Bool display_caret = True;
+
+ if ((event->type == EnterNotify || event->type == LeaveNotify)
+ && ((*num_params >= 2) && (strcmp(params[1], "always") == 0))
+ && (!event->xcrossing.focus))
+ return;
+
+ if (*num_params > 0) { /* default arg is "True" */
+ XrmValue from, to;
+ from.size = strlen(from.addr = params[0]);
+ XtConvert(w, XtRString, &from, XtRBoolean, &to);
+
+ if (to.addr != NULL)
+ display_caret = *(Boolean*)to.addr;
+ if (ctx->text.display_caret == display_caret)
+ return;
+ }
+ StartAction(ctx, event);
+ ctx->text.display_caret = display_caret;
+ EndAction(ctx);
+}
+
+#ifndef OLDXAW
+static void
+Numeric(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ if (ctx->text.numeric) {
+ long mult = ctx->text.mult;
+
+ if (*num_params != 1 || strlen(params[0]) != 1
+ || (!isdigit(params[0][0])
+ && (params[0][0] != '-' || mult != 0))) {
+ char err_buf[256];
+
+ if (event && (event->type == KeyPress || event->type == KeyRelease)
+ && params[0][0] == '-') {
+ InsertChar(w, event, params, num_params);
+ return;
+ }
+ XmuSnprintf(err_buf, sizeof(err_buf),
+ "numeric: Invalid argument%s'%s'",
+ *num_params ? ", " : "", *num_params ? params[0] : "");
+ XtAppWarning(XtWidgetToApplicationContext(w), err_buf);
+ ctx->text.numeric = False;
+ ctx->text.mult = 1;
+ return;
+ }
+ if (params[0][0] == '-') {
+ ctx->text.mult = 32767;
+ return;
+ }
+ else if (mult == 32767) {
+ mult = ctx->text.mult = - (params[0][0] - '0');
+ return;
+ }
+ else {
+ mult = mult * 10 + (params[0][0] - '0') * (mult < 0 ? -1 : 1);
+ ctx->text.mult = ctx->text.mult * 10 + (params[0][0] - '0') *
+ (mult < 0 ? -1 : 1);
+ }
+ if (mult != ctx->text.mult || mult >= 32767) { /* checks for overflow */
+ XBell(XtDisplay(w), 0);
+ ctx->text.mult = 1;
+ ctx->text.numeric = False;
+ return;
+ }
+ }
+ else
+ InsertChar(w, event, params, num_params);
+}
+
+/*ARGSUSED*/
+static void
+KeyboardReset(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+
+ ctx->text.numeric = False;
+ ctx->text.mult = 1;
+
+ (void)_XawTextSrcToggleUndo((TextSrcObject)ctx->text.source);
+
+ if (ctx->text.kill_ring_ptr) {
+ --ctx->text.kill_ring_ptr->refcount;
+ ctx->text.kill_ring_ptr = NULL;
+ }
+ ctx->text.kill_ring = 0;
+
+ XBell(XtDisplay(w), 0);
+}
+#endif /* OLDXAW */
+
+/* Multiply() - action
+ *
+ * The parameter list may contain either a number or the string 'Reset'.
+ *
+ * A number will multiply the current multiplication factor by that number.
+ * Many of the text widget actions will will perform n actions, where n is
+ * the multiplication factor.
+ *
+ * The string reset will reset the mutiplication factor to 1. */
+/*ARGSUSED*/
+static void
+Multiply(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+ int mult;
+
+ if (*num_params != 1) {
+ XtAppError(XtWidgetToApplicationContext(w),
+ "Xaw Text Widget: multiply() takes exactly one argument.");
+ XBell(XtDisplay(w), 0);
+ return;
+ }
+
+ if ((params[0][0] == 'r') || (params[0][0] == 'R')) {
+ XBell(XtDisplay(w), 0);
+#ifndef OLDXAW
+ ctx->text.numeric = False;
+#endif
+ ctx->text.mult = 1;
+ return;
+ }
+
+#ifndef OLDXAW
+ if (params[0][0] == 's' || params[0][0] == 'S') {
+ ctx->text.numeric = True;
+ ctx->text.mult = 0;
+ return;
+ }
+ else
+#endif
+ if ((mult = atoi(params[0])) == 0) {
+ char buf[BUFSIZ];
+
+ XmuSnprintf(buf, sizeof(buf),
+ "%s %s", "Xaw Text Widget: multiply() argument",
+ "must be a number greater than zero, or 'Reset'.");
+ XtAppError(XtWidgetToApplicationContext(w), buf);
+ XBell(XtDisplay(w), 50);
+ return;
+ }
+
+ ctx->text.mult *= mult;
+}
+
+/* StripOutOldCRs() - called from FormRegion
+ *
+ * removes CRs in widget ctx, from from to to.
+ *
+ * RETURNS: the new ending location (we may add some characters),
+ * or XawReplaceError if the widget can't be written to. */
+static XawTextPosition
+StripOutOldCRs(TextWidget ctx, XawTextPosition from, XawTextPosition to,
+ XawTextPosition *pos, int num_pos)
+{
+ XawTextPosition startPos, endPos, eop_begin, eop_end, temp;
+ Widget src = ctx->text.source;
+ XawTextBlock text;
+ char *buf;
+ static wchar_t wc_two_spaces[3];
+ int idx;
+
+ /* Initialize our TextBlock with two spaces. */
+ text.firstPos = 0;
+ text.format = _XawTextFormat(ctx);
+ if (text.format == XawFmt8Bit)
+ text.ptr= " ";
+ else {
+ wc_two_spaces[0] = _Xaw_atowc(XawSP);
+ wc_two_spaces[1] = _Xaw_atowc(XawSP);
+ wc_two_spaces[2] = 0;
+ text.ptr = (char*)wc_two_spaces;
+ }
+
+ /* Strip out CR's. */
+ eop_begin = eop_end = startPos = endPos = from;
+
+ /* CONSTCOND */
+ while (TRUE) {
+ endPos=SrcScan(src, startPos, XawstEOL, XawsdRight, 1, False);
+
+ temp = SrcScan(src, endPos, XawstWhiteSpace, XawsdLeft, 1, False);
+ temp = SrcScan(src, temp, XawstWhiteSpace, XawsdRight,1, False);
+
+ if (temp > startPos)
+ endPos = temp;
+
+ if (endPos >= to)
+ break;
+
+ if (endPos >= eop_begin) {
+ startPos = eop_end;
+ eop_begin=SrcScan(src, startPos, XawstParagraph,
+ XawsdRight, 1,False);
+ eop_end = SrcScan(src, startPos, XawstParagraph,
+ XawsdRight, 1, True);
+ }
+ else {
+ XawTextPosition periodPos, next_word;
+ int i, len;
+
+ periodPos = SrcScan(src, endPos, XawstPositions,
+ XawsdLeft, 1, True);
+ next_word = SrcScan(src, endPos, XawstWhiteSpace,
+ XawsdRight, 1, False);
+
+ len = next_word - periodPos;
+
+ text.length = 1;
+ buf = _XawTextGetText(ctx, periodPos, next_word);
+ if (text.format == XawFmtWide) {
+ if (periodPos < endPos && ((wchar_t*)buf)[0] == _Xaw_atowc('.'))
+ text.length++;
+ }
+ else
+ if (periodPos < endPos && buf[0] == '.')
+ text.length++; /* Put in two spaces. */
+
+ /*
+ * Remove all extra spaces.
+ */
+ for (i = 1 ; i < len; i++)
+ if (text.format == XawFmtWide) {
+ if (!iswspace(((wchar_t*)buf)[i]) || ((periodPos + i) >= to))
+ break;
+ }
+ else if (!isspace(buf[i]) || (periodPos + i) >= to)
+ break;
+
+ XtFree(buf);
+
+ to -= (i - text.length - 1);
+ startPos = SrcScan(src, periodPos, XawstPositions,
+ XawsdRight, i, True);
+ if (_XawTextReplace(ctx, endPos, startPos, &text) != XawEditDone)
+ return (XawReplaceError);
+
+ for (idx = 0; idx < num_pos; idx++) {
+ if (endPos < pos[idx]) {
+ if (startPos < pos[idx])
+ pos[idx] -= startPos - endPos;
+ else
+ pos[idx] = endPos;
+ pos[idx] += text.length;
+ }
+ }
+
+ startPos -= i - text.length;
+ }
+ }
+
+ return (to);
+}
+
+/* InsertNewCRs() - called from FormRegion
+ *
+ * inserts new CRs for FormRegion, thus for FormParagraph action */
+static void
+InsertNewCRs(TextWidget ctx, XawTextPosition from, XawTextPosition to,
+ XawTextPosition *pos, int num_pos)
+{
+ XawTextPosition startPos, endPos, space, eol;
+ XawTextBlock text;
+ int i, width, height, len, wwidth, idx;
+ char *buf;
+ static wchar_t wide_CR[2];
+
+ text.firstPos = 0;
+ text.length = 1;
+ text.format = _XawTextFormat(ctx);
+
+ if (text.format == XawFmt8Bit)
+ text.ptr = "\n";
+ else {
+ wide_CR[0] = _Xaw_atowc(XawLF);
+ wide_CR[1] = 0;
+ text.ptr = (char*)wide_CR;
+ }
+
+ startPos = from;
+
+ wwidth = (int)XtWidth(ctx) - (int)HMargins(ctx);
+ if (ctx->text.wrap != XawtextWrapNever) {
+ XRectangle cursor;
+
+ XawTextSinkGetCursorBounds(ctx->text.sink, &cursor);
+ wwidth -= (int)cursor.width;
+ }
+ wwidth = XawMax(0, wwidth);
+
+ /* CONSTCOND */
+ while (TRUE) {
+ XawTextSinkFindPosition(ctx->text.sink, startPos,
+ (int)ctx->text.r_margin.left, wwidth,
+ True, &eol, &width, &height);
+ if (eol == startPos)
+ ++eol;
+ if (eol >= to)
+ break;
+
+ eol = SrcScan(ctx->text.source, eol, XawstPositions,
+ XawsdLeft, 1, True);
+ space = SrcScan(ctx->text.source, eol, XawstWhiteSpace,
+ XawsdRight,1, True);
+
+ startPos = endPos = eol;
+ if (eol == space)
+ return;
+
+ len = (int)(space - eol);
+ buf = _XawTextGetText(ctx, eol, space);
+ for (i = 0 ; i < len ; i++)
+ if (text.format == XawFmtWide) {
+ if (!iswspace(((wchar_t*)buf)[i]))
+ break;
+ }
+ else if (!isspace(buf[i]))
+ break;
+
+ to -= (i - 1);
+ endPos = SrcScan(ctx->text.source, endPos,
+ XawstPositions, XawsdRight, i, True);
+ XtFree(buf);
+
+ if (_XawTextReplace(ctx, startPos, endPos, &text))
+ return;
+
+ for (idx = 0; idx < num_pos; idx++) {
+ if (startPos < pos[idx]) {
+ if (endPos < pos[idx])
+ pos[idx] -= endPos - startPos;
+ else
+ pos[idx] = startPos;
+ pos[idx] += text.length;
+ }
+ }
+
+ startPos = SrcScan(ctx->text.source, startPos,
+ XawstPositions, XawsdRight, 1, True);
+ }
+}
+
+/* FormRegion() - called by FormParagraph
+ *
+ * oversees the work of paragraph-forming a region
+ *
+ * Return:
+ * XawEditDone if successful, or XawReplaceError
+ */
+static int
+FormRegion(TextWidget ctx, XawTextPosition from, XawTextPosition to,
+ XawTextPosition *pos, int num_pos)
+{
+#ifndef OLDXAW
+ Bool format = ctx->text.auto_fill
+ && ctx->text.left_column < ctx->text.right_column;
+#endif
+
+ if (from >= to)
+ return (XawEditDone);
+
+#ifndef OLDXAW
+ if (format) {
+ XawTextPosition len = ctx->text.lastPos;
+ int inc = 0;
+
+ if (ctx->text.justify == XawjustifyLeft ||
+ ctx->text.justify == XawjustifyFull) {
+ Untabify(ctx, from, to, pos, num_pos, NULL);
+ to += ctx->text.lastPos - len;
+ len = ctx->text.insertPos;
+ (void)BlankLine((Widget)ctx, from, &inc);
+ if (from + inc >= to)
+ return (XawEditDone);
+ }
+ if (!StripSpaces(ctx, from + inc, to, pos, num_pos, NULL))
+ return (XawReplaceError);
+ to += ctx->text.lastPos - len;
+
+ FormatText(ctx, from, ctx->text.justify != XawjustifyFull, pos, num_pos);
+ }
+ else {
+#endif
+ if ((to = StripOutOldCRs(ctx, from, to, pos, num_pos)) == XawReplaceError)
+ return (XawReplaceError);
+ InsertNewCRs(ctx, from, to, pos, num_pos);
+#ifndef OLDXAW
+ }
+#endif
+ ctx->text.from_left = -1;
+
+ return (XawEditDone);
+}
+
+#ifndef OLDXAW
+static Bool
+BlankLine(Widget w, XawTextPosition pos, int *blanks_return)
+{
+ int i, blanks = 0;
+ XawTextBlock block;
+ Widget src = XawTextGetSource(w);
+ XawTextPosition l = SrcScan(src, pos, XawstEOL, XawsdLeft, 1, False);
+ XawTextPosition r = SrcScan(src, pos, XawstEOL, XawsdRight, 1, False);
+
+ while (l < r) {
+ l = XawTextSourceRead(src, l, &block, r - l);
+ if (block.length == 0) {
+ if (blanks_return)
+ *blanks_return = blanks;
+ return (True);
+ }
+ if (XawTextFormat((TextWidget)w, XawFmt8Bit)) {
+ for (i = 0; i < block.length; i++, blanks++)
+ if (block.ptr[i] != ' ' &&
+ block.ptr[i] != '\t') {
+ if (blanks_return)
+ *blanks_return = blanks;
+ return (block.ptr[i] == '\n');
+ }
+ }
+ else if (XawTextFormat((TextWidget)w, XawFmtWide)) {
+ for (i = 0; i < block.length; i++, blanks++)
+ if (_Xaw_atowc(XawSP) != ((wchar_t*)block.ptr)[i] &&
+ _Xaw_atowc(XawTAB) != ((wchar_t*)block.ptr)[i]) {
+ if (blanks_return)
+ *blanks_return = blanks;
+ return (_Xaw_atowc(XawLF) == ((wchar_t*)block.ptr)[i]);
+ }
+ }
+ }
+
+ return (True);
+}
+
+static Bool
+GetBlockBoundaries(TextWidget ctx,
+ XawTextPosition *from_return, XawTextPosition *to_return)
+{
+ XawTextPosition from, to;
+
+ if (ctx->text.auto_fill && ctx->text.left_column < ctx->text.right_column) {
+ if (ctx->text.s.left != ctx->text.s.right) {
+ from = SrcScan(ctx->text.source,
+ XawMin(ctx->text.s.left, ctx->text.s.right),
+ XawstEOL, XawsdLeft, 1, False);
+ to = SrcScan(ctx->text.source,
+ XawMax(ctx->text.s.right, ctx->text.s.right),
+ XawstEOL, XawsdRight, 1, False);
+ }
+ else {
+ XawTextBlock block;
+ XawTextPosition tmp;
+ Bool first;
+
+ from = to = ctx->text.insertPos;
+
+ /* find from position */
+ first = True;
+ while (1) {
+ tmp = from;
+ from = SrcScan(ctx->text.source, from, XawstEOL, XawsdLeft,
+ 1 + !first, False);
+ XawTextSourceRead(ctx->text.source, from, &block, 1);
+ if (block.length == 0 ||
+ (XawTextFormat(ctx, XawFmt8Bit) &&
+ block.ptr[0] != ' ' &&
+ block.ptr[0] != '\t' &&
+ !isalnum(*(unsigned char*)block.ptr)) ||
+ (XawTextFormat(ctx, XawFmtWide) &&
+ _Xaw_atowc(XawSP) != *(wchar_t*)block.ptr &&
+ _Xaw_atowc(XawTAB) != *(wchar_t*)block.ptr &&
+ !iswalnum(*(wchar_t*)block.ptr)) ||
+ BlankLine((Widget)ctx, from, NULL)) {
+ from = tmp;
+ break;
+ }
+ if (from == tmp && !first)
+ break;
+ first = False;
+ }
+ if (first)
+ return (False);
+
+ /* find to position */
+ first = True;
+ while (1) {
+ tmp = to;
+ to = SrcScan(ctx->text.source, to, XawstEOL, XawsdRight,
+ 1 + !first, False);
+ XawTextSourceRead(ctx->text.source, to + (to < ctx->text.lastPos),
+ &block, 1);
+ if (block.length == 0 ||
+ (XawTextFormat(ctx, XawFmt8Bit) &&
+ block.ptr[0] != ' ' &&
+ block.ptr[0] != '\t' &&
+ !isalnum(*(unsigned char*)block.ptr)) ||
+ (XawTextFormat(ctx, XawFmtWide) &&
+ _Xaw_atowc(XawSP) != *(wchar_t*)block.ptr &&
+ _Xaw_atowc(XawTAB) != *(wchar_t*)block.ptr &&
+ !iswalnum(*(wchar_t*)block.ptr)) ||
+ BlankLine((Widget)ctx, to, NULL))
+ break;
+ if (to == tmp && !first)
+ break;
+ first = False;
+ }
+ }
+ }
+ else {
+ from = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL,
+ XawsdLeft, 1, False);
+ if (BlankLine((Widget)ctx, from, NULL))
+ return (False);
+ from = SrcScan(ctx->text.source, from, XawstParagraph,
+ XawsdLeft, 1, False);
+ if (BlankLine((Widget)ctx, from, NULL))
+ from = SrcScan(ctx->text.source, from, XawstEOL,
+ XawsdRight, 1, True);
+ to = SrcScan(ctx->text.source, from, XawstParagraph,
+ XawsdRight, 1, False);
+ }
+
+ if (from < to) {
+ *from_return = from;
+ *to_return = to;
+ return (True);
+ }
+
+ return (False);
+}
+#endif /* OLDXAW */
+
+/* FormParagraph() - action
+ *
+ * removes and reinserts CRs to maximize line length without clipping */
+/*ARGSUSED*/
+static void
+FormParagraph(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+ XawTextPosition from, to, buf[32], *pos;
+#ifndef OLDXAW
+ XawTextPosition endPos = 0;
+ char *lbuf = NULL, *rbuf;
+ TextSrcObject src = (TextSrcObject)ctx->text.source;
+ Cardinal i;
+ Bool undo = src->textSrc.enable_undo && src->textSrc.undo_state == False;
+#endif
+
+ StartAction(ctx, event);
+
+#ifndef OLDXAW
+ pos = XawStackAlloc(sizeof(XawTextPosition) * src->textSrc.num_text, buf);
+ for (i = 0; i < src->textSrc.num_text; i++)
+ pos[i] = ((TextWidget)src->textSrc.text[i])->text.old_insert;
+#else
+ pos = buf;
+ *pos = ctx->text.old_insert;
+#endif
+
+#ifndef OLDXAW
+ if (!GetBlockBoundaries(ctx, &from, &to)) {
+ EndAction(ctx);
+ XawStackFree(pos, buf);
+ return;
+ }
+
+ if (undo) {
+ src->textSrc.undo_state = True;
+ lbuf = _XawTextGetText(ctx, from, to);
+ endPos = ctx->text.lastPos;
+ }
+
+ if (FormRegion(ctx, from, to, pos, src->textSrc.num_text) == XawReplaceError) {
+#else
+ from = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstParagraph, XawsdLeft, 1, False);
+ to = SrcScan(ctx->text.source, from,
+ XawstParagraph, XawsdRight, 1, False);
+
+ if (FormRegion(ctx, from, to, pos, 1) == XawReplaceError) {
+#endif
+ XawStackFree(pos, buf);
+ XBell(XtDisplay(w), 0);
+#ifndef OLDXAW
+ if (undo) {
+ src->textSrc.undo_state = False;
+ XtFree(lbuf);
+ }
+#endif
+ }
+#ifndef OLDXAW
+ else if (undo) {
+ /* makes the form-paragraph only one undo/redo step */
+ unsigned llen, rlen, size;
+ XawTextBlock block;
+
+ llen = to - from;
+ rlen = llen + (ctx->text.lastPos - endPos);
+
+ block.firstPos = 0;
+ block.format = _XawTextFormat(ctx);
+
+ rbuf = _XawTextGetText(ctx, from, from + rlen);
+
+ size = XawTextFormat(ctx, XawFmtWide) ? sizeof(wchar_t) : sizeof(char);
+ if (llen != rlen || memcmp(lbuf, rbuf, llen * size)) {
+ block.ptr = lbuf;
+ block.length = llen;
+ _XawTextReplace(ctx, from, from + rlen, &block);
+
+ src->textSrc.undo_state = False;
+ block.ptr = rbuf;
+ block.length = rlen;
+ _XawTextReplace(ctx, from, from + llen, &block);
+ }
+ else
+ src->textSrc.undo_state = False;
+ XtFree(lbuf);
+ XtFree(rbuf);
+ }
+
+ for (i = 0; i < src->textSrc.num_text; i++) {
+ TextWidget tw = (TextWidget)src->textSrc.text[i];
+
+ tw->text.old_insert = tw->text.insertPos = pos[i];
+ _XawTextBuildLineTable(tw, SrcScan((Widget)src, tw->text.lt.top, XawstEOL,
+ XawsdLeft, 1, False), False);
+ tw->text.clear_to_eol = True;
+ }
+#else
+ ctx->text.old_insert = ctx->text.insertPos = *pos;
+ _XawTextBuildLineTable(ctx, SrcScan(ctx->text.source, ctx->text.lt.top,
+ XawstEOL, XawsdLeft, 1, False), False);
+ ctx->text.clear_to_eol = True;
+#endif
+ XawStackFree(pos, buf);
+ ctx->text.showposition = True;
+
+ EndAction(ctx);
+}
+
+/* TransposeCharacters() - action
+ *
+ * Swaps the character to the left of the mark
+ * with the character to the right of the mark */
+/*ARGSUSED*/
+static void
+TransposeCharacters(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+ XawTextPosition start, end;
+ XawTextBlock text;
+ char *buf;
+ int i, mult = MULT(ctx);
+
+ if (mult < 0) {
+ ctx->text.mult = 1;
+ return;
+ }
+
+ StartAction(ctx, event);
+
+ /* Get bounds. */
+
+ start = SrcScan(ctx->text.source, ctx->text.insertPos, XawstPositions,
+ XawsdLeft, 1, True);
+ end = SrcScan(ctx->text.source, ctx->text.insertPos, XawstPositions,
+ XawsdRight, mult, True);
+
+ /* Make sure we aren't at the very beginning or end of the buffer. */
+
+ if (start == ctx->text.insertPos || end == ctx->text.insertPos) {
+ XBell(XtDisplay(w), 0); /* complain. */
+ EndAction(ctx);
+ return;
+ }
+
+ ctx->text.from_left = -1;
+ ctx->text.insertPos = end;
+
+ text.firstPos = 0;
+ text.format = _XawTextFormat(ctx);
+
+ /* Retrieve text and swap the characters. */
+ if (text.format == XawFmtWide) {
+ wchar_t wc;
+ wchar_t *wbuf;
+
+ wbuf = (wchar_t*)_XawTextGetText(ctx, start, end);
+ text.length = wcslen(wbuf);
+ wc = wbuf[0];
+ for (i = 1; i < text.length; i++)
+ wbuf[i - 1] = wbuf[i];
+ wbuf[i - 1] = wc;
+ buf = (char*)wbuf; /* so that it gets assigned and freed */
+ }
+ else { /* thus text.format == XawFmt8Bit */
+ char c;
+
+ buf = _XawTextGetText(ctx, start, end);
+ text.length = strlen(buf);
+ c = buf[0];
+ for (i = 1; i < text.length; i++)
+ buf[i - 1] = buf[i];
+ buf[i - 1] = c;
+ }
+
+ text.ptr = buf;
+
+ /* Store new text in source. */
+
+ if (_XawTextReplace (ctx, start, end, &text))
+ XBell(XtDisplay(w), 0);
+ XtFree((char *)buf);
+ EndAction(ctx);
+}
+
+#ifndef OLDXAW
+/*ARGSUSED*/
+static void
+Undo(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+ int mul = MULT(ctx);
+ Bool toggle = False;
+
+ if (mul < 0) {
+ toggle = True;
+ _XawTextSrcToggleUndo((TextSrcObject)ctx->text.source);
+ ctx->text.mult = mul = -mul;
+ }
+
+ StartAction(ctx, event);
+ for (; mul; --mul)
+ if (!_XawTextSrcUndo((TextSrcObject)ctx->text.source, &ctx->text.insertPos))
+ break;
+ ctx->text.showposition = True;
+
+ if (toggle)
+ _XawTextSrcToggleUndo((TextSrcObject)ctx->text.source);
+ EndAction(ctx);
+}
+#endif
+
+/* NoOp() - action
+ * This action performs no action, and allows the user or
+ * application programmer to unbind a translation.
+ *
+ * Note: If the parameter list contains the string "RingBell" then
+ * this action will ring the bell.
+ */
+/*ARGSUSED*/
+static void
+NoOp(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ if (*num_params != 1)
+ return;
+
+ switch(params[0][0]) {
+ case 'R':
+ case 'r':
+ XBell(XtDisplay(w), 0);
+ /*FALLTROUGH*/
+ default:
+ break;
+ }
+}
+
+/* Reconnect() - action
+ * This reconnects to the input method. The user will typically call
+ * this action if/when connection has been severed, or when the app
+ * was started up before an IM was started up
+ */
+/*ARGSUSED*/
+static void
+Reconnect(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ _XawImReconnect(w);
+}
+
+#define CAPITALIZE 1
+#define DOWNCASE 2
+#define UPCASE 3
+
+#ifdef NO_LIBC_I18N
+static int
+ToLower(int ch)
+{
+ char buf[2];
+
+ *buf = ch;
+ XmuNCopyISOLatin1Lowered(buf, buf, sizeof(buf));
+
+ return (*buf);
+}
+
+static int
+ToUpper(int ch)
+{
+ char buf[2];
+
+ *buf = ch;
+ XmuNCopyISOLatin1Uppered(buf, buf, sizeof(buf));
+
+ return (*buf);
+}
+
+static int
+IsAlnum(int ch)
+{
+ return ((ch >= '0' && ch <= '9') || ToUpper(ch) != ch || ToLower(ch) != ch);
+}
+
+static int
+IsLower(int ch)
+{
+ char upbuf[2];
+ char lobuf[2];
+
+ *upbuf = *lobuf = ch;
+ XmuNCopyISOLatin1Lowered(lobuf, lobuf, sizeof(lobuf));
+ XmuNCopyISOLatin1Uppered(upbuf, upbuf, sizeof(upbuf));
+
+ return (*lobuf != *upbuf && ch == *lobuf);
+}
+
+static int
+IsUpper(int ch)
+{
+ char upbuf[2];
+ char lobuf[2];
+
+ *upbuf = *lobuf = ch;
+ XmuNCopyISOLatin1Lowered(lobuf, lobuf, sizeof(lobuf));
+ XmuNCopyISOLatin1Uppered(upbuf, upbuf, sizeof(upbuf));
+
+ return (*lobuf != *upbuf && ch == *upbuf);
+}
+#else
+#define ToLower tolower
+#define ToUpper toupper
+#define IsAlnum isalnum
+#define IsLower islower
+#define IsUpper isupper
+#endif
+
+static void
+CaseProc(Widget w, XEvent *event, int cmd)
+{
+ TextWidget ctx = (TextWidget)w;
+ short mul = MULT(ctx);
+ XawTextPosition left, right;
+ XawTextBlock block;
+ Bool changed = False;
+ unsigned char ch, mb[sizeof(wchar_t)];
+ int i, count;
+
+ if (mul > 0)
+ right = SrcScan(ctx->text.source, left = ctx->text.insertPos,
+ XawstAlphaNumeric, XawsdRight, mul, False);
+ else
+ left = SrcScan(ctx->text.source, right = ctx->text.insertPos,
+ XawstAlphaNumeric, XawsdLeft, 1 + -mul, False);
+ block.firstPos = 0;
+ block.format = _XawTextFormat(ctx);
+ block.length = right - left;
+ block.ptr = _XawTextGetText(ctx, left, right);
+
+ count = 0;
+ if (block.format == XawFmt8Bit)
+ for (i = 0; i < block.length; i++) {
+ if (!IsAlnum(*mb = (unsigned char)block.ptr[i]))
+ count = 0;
+ else if (++count == 1 || cmd != CAPITALIZE) {
+ ch = cmd == DOWNCASE ? ToLower(*mb) : ToUpper(*mb);
+ if (ch != *mb) {
+ changed = True;
+ block.ptr[i] = ch;
+ }
+ }
+ else if (cmd == CAPITALIZE) {
+ if ((ch = ToLower(*mb)) != *mb) {
+ changed = True;
+ block.ptr[i] = ch;
+ }
+ }
+ }
+ else
+ for (i = 0; i < block.length; i++) {
+ wctomb((char*)mb, ((wchar_t*)block.ptr)[i]);
+ if (!IsAlnum(*mb))
+ count = 0;
+ else if (++count == 1 || cmd != CAPITALIZE) {
+ ch = cmd == DOWNCASE ? ToLower(*mb) : ToUpper(*mb);
+ if (ch != *mb) {
+ changed = True;
+ ((wchar_t*)block.ptr)[i] = _Xaw_atowc(ch);
+ }
+ }
+ else if (cmd == CAPITALIZE) {
+ if ((ch = ToLower(*mb)) != *mb) {
+ changed = True;
+ ((wchar_t*)block.ptr)[i] = _Xaw_atowc(ch);
+ }
+ }
+ }
+
+ StartAction(ctx, event);
+ if (changed && _XawTextReplace(ctx, left, right, &block) != XawEditDone)
+ XBell(XtDisplay(ctx), 0);
+ ctx->text.insertPos = right;
+ EndAction(ctx);
+
+ XtFree(block.ptr);
+}
+
+/*ARGSUSED*/
+static void
+CapitalizeWord(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ CaseProc(w, event, CAPITALIZE);
+}
+
+/*ARGSUSED*/
+static void
+DowncaseWord(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ CaseProc(w, event, DOWNCASE);
+}
+
+/*ARGSUSED*/
+static void
+UpcaseWord(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ CaseProc(w, event, UPCASE);
+}
+#undef CAPITALIZE
+#undef DOWNCASE
+#undef UPCASE
+
+XtActionsRec _XawTextActionsTable[] = {
+ /* motion */
+ {"forward-character", MoveForwardChar},
+ {"backward-character", MoveBackwardChar},
+ {"forward-word", MoveForwardWord},
+ {"backward-word", MoveBackwardWord},
+ {"forward-paragraph", MoveForwardParagraph},
+ {"backward-paragraph", MoveBackwardParagraph},
+ {"beginning-of-line", MoveToLineStart},
+ {"end-of-line", MoveToLineEnd},
+ {"next-line", MoveNextLine},
+ {"previous-line", MovePreviousLine},
+ {"next-page", MoveNextPage},
+ {"previous-page", MovePreviousPage},
+ {"beginning-of-file", MoveBeginningOfFile},
+ {"end-of-file", MoveEndOfFile},
+ {"scroll-one-line-up", ScrollOneLineUp},
+ {"scroll-one-line-down", ScrollOneLineDown},
+
+ /* delete */
+ {"delete-next-character", DeleteForwardChar},
+ {"delete-previous-character", DeleteBackwardChar},
+ {"delete-next-word", DeleteForwardWord},
+ {"delete-previous-word", DeleteBackwardWord},
+ {"delete-selection", DeleteCurrentSelection},
+ {"delete", Delete},
+
+ /* kill */
+ {"kill-word", KillForwardWord},
+ {"backward-kill-word", KillBackwardWord},
+ {"kill-selection", KillCurrentSelection},
+ {"kill-to-end-of-line", KillToEndOfLine},
+ {"kill-to-end-of-paragraph", KillToEndOfParagraph},
+
+ /* new line */
+ {"newline-and-indent", InsertNewLineAndIndent},
+ {"newline-and-backup", InsertNewLineAndBackup},
+ {"newline", InsertNewLine},
+
+ /* selection */
+ {"select-word", SelectWord},
+ {"select-all", SelectAll},
+ {"select-start", SelectStart},
+ {"select-adjust", SelectAdjust},
+ {"select-end", SelectEnd},
+ {"select-save", SelectSave},
+ {"extend-start", ExtendStart},
+ {"extend-adjust", ExtendAdjust},
+ {"extend-end", ExtendEnd},
+ {"insert-selection", InsertSelection},
+
+ /* miscellaneous */
+ {"redraw-display", RedrawDisplay},
+ {"insert-file", _XawTextInsertFile},
+ {"search", _XawTextSearch},
+ {"insert-char", InsertChar},
+ {"insert-string", InsertString},
+ {"focus-in", TextFocusIn},
+ {"focus-out", TextFocusOut},
+ {"enter-window", TextEnterWindow},
+ {"leave-window", TextLeaveWindow},
+ {"display-caret", DisplayCaret},
+ {"multiply", Multiply},
+ {"form-paragraph", FormParagraph},
+ {"transpose-characters", TransposeCharacters},
+ {"set-keyboard-focus", SetKeyboardFocus},
+#ifndef OLDXAW
+ {"numeric", Numeric},
+ {"undo", Undo},
+ {"keyboard-reset", KeyboardReset},
+ {"kill-ring-yank", KillRingYank},
+ {"toggle-overwrite", ToggleOverwrite},
+ {"indent", Indent},
+#endif
+ {"no-op", NoOp},
+
+ /* case transformations */
+ {"capitalize-word", CapitalizeWord},
+ {"downcase-word", DowncaseWord},
+ {"upcase-word", UpcaseWord},
+
+ /* action to bind translations for text dialogs */
+ {"InsertFileAction", _XawTextInsertFileAction},
+ {"DoSearchAction", _XawTextDoSearchAction},
+ {"DoReplaceAction", _XawTextDoReplaceAction},
+ {"SetField", _XawTextSetField},
+ {"PopdownSearchAction", _XawTextPopdownSearchAction},
+
+ /* reconnect to Input Method */
+ {"reconnect-im", Reconnect} /* Li Yuhong, Omron KK, 1991 */
+};
+
+Cardinal _XawTextActionsTableCount = XtNumber(_XawTextActionsTable);
diff --git a/nx-X11/lib/Xaw/TextP.h b/nx-X11/lib/Xaw/TextP.h
new file mode 100644
index 000000000..0edbdd29b
--- /dev/null
+++ b/nx-X11/lib/Xaw/TextP.h
@@ -0,0 +1,321 @@
+/*
+* $Xorg: TextP.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/TextP.h,v 3.21 2001/12/14 19:54:44 dawes Exp $ */
+
+#ifndef _XawTextP_h
+#define _XawTextP_h
+
+#include <X11/Xfuncproto.h>
+
+#include <X11/Xaw/Text.h>
+#include <X11/Xaw/SimpleP.h>
+
+_XFUNCPROTOBEGIN
+
+#define MAXCUT 30000 /* Maximum number of characters that can be cut */
+
+#define XawTextGetLastPosition(ctx) \
+ XawTextSourceScan((ctx)->text.source, 0, \
+ XawstAll, XawsdRight, 1, True)
+#define GETLASTPOS XawTextGetLastPosition(ctx)
+
+#define zeroPosition ((XawTextPosition)0)
+
+extern XtActionsRec _XawTextActionsTable[];
+extern Cardinal _XawTextActionsTableCount;
+
+#define XawLF 0x0a
+#define XawCR 0x0d
+#define XawTAB 0x09
+#define XawBS 0x08
+#define XawSP 0x20
+#define XawDEL 0x7f
+#define XawESC 0x1b
+#define XawBSLASH '\\'
+
+/* constants that subclasses may want to know */
+#define DEFAULT_TEXT_HEIGHT ((Dimension)~0)
+#define DEFAULT_TAB_SIZE 8
+
+/* displayable text management data structures */
+typedef struct {
+ XawTextPosition position;
+ Position y;
+#ifndef OLDXAW
+ unsigned int textWidth;
+#else
+ Dimension textWidth;
+#endif
+} XawTextLineTableEntry, *XawTextLineTableEntryPtr;
+
+typedef struct {
+ XawTextPosition left, right;
+ XawTextSelectType type;
+ Atom *selections;
+ int atom_count;
+ int array_size;
+} XawTextSelection;
+
+typedef struct _XawTextSelectionSalt {
+ struct _XawTextSelectionSalt *next;
+ XawTextSelection s;
+ /*
+ * The element "contents" stores the CT string which is gotten in the
+ * function _XawTextSaltAwaySelection()
+ */
+ char *contents;
+ int length;
+} XawTextSelectionSalt;
+
+#ifndef OLDXAW
+typedef struct _XawTextKillRing {
+ struct _XawTextKillRing *next;
+ char *contents;
+ int length;
+ unsigned refcount;
+ unsigned long format;
+} XawTextKillRing;
+
+extern XawTextKillRing *xaw_text_kill_ring;
+#endif
+
+/* Line Tables are n+1 long - last position displayed is in last lt entry */
+typedef struct {
+ XawTextPosition top; /* Top of the displayed text */
+ int lines; /* How many lines in this table */
+#ifndef OLDXAW
+ int base_line; /* line number of first entry */
+#endif
+ XawTextLineTableEntry *info; /* A dynamic array, one entry per line */
+} XawTextLineTable, *XawTextLineTablePtr;
+
+typedef struct _XawTextMargin {
+ Position left, right, top, bottom;
+} XawTextMargin;
+
+typedef struct _XmuScanline XmuTextUpdate;
+
+#define VMargins(ctx) ((ctx)->text.margin.top + (ctx)->text.margin.bottom)
+#define HMargins(ctx) ((ctx)->text.left_margin + (ctx)->text.margin.right)
+#define RVMargins(ctx) ((ctx)->text.r_margin.top + (ctx)->text.r_margin.bottom)
+#define RHMargins(ctx) ((ctx)->text.r_margin.left + (ctx)->text.r_margin.right)
+
+#define IsPositionVisible(ctx, pos) \
+(pos >= ctx->text.lt.info[0].position && \
+ pos < ctx->text.lt.info[ctx->text.lt.lines].position)
+
+/*
+ * Search & Replace data structure
+ */
+struct SearchAndReplace {
+ Boolean selection_changed; /* flag so that the selection cannot be
+ changed out from underneath query-replace.*/
+ Widget search_popup; /* The poppup widget that allows searches.*/
+ Widget label1; /* The label widgets for the search window. */
+ Widget label2;
+ Widget left_toggle; /* The left search toggle radioGroup. */
+ Widget right_toggle; /* The right search toggle radioGroup. */
+ Widget rep_label; /* The Replace label string. */
+ Widget rep_text; /* The Replace text field. */
+ Widget search_text; /* The Search text field. */
+ Widget rep_one; /* The Replace one button. */
+ Widget rep_all; /* The Replace all button. */
+#ifndef OLDXAW
+ Widget case_sensitive; /* The "Case Sensitive" toggle */
+#endif
+};
+
+/* New fields for the Text widget class record */
+typedef struct {
+ XtPointer extension;
+} TextClassPart;
+
+/* Full class record declaration */
+typedef struct _TextClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ TextClassPart text_class;
+} TextClassRec;
+
+extern TextClassRec textClassRec;
+
+/* New fields for the Text widget record */
+typedef struct _TextPart {
+ /* resources */
+ Widget source, sink;
+ XawTextPosition insertPos;
+ XawTextSelection s;
+ XawTextSelectType *sarray; /* Array to cycle for selections */
+ XawTextSelectionSalt *salt; /* salted away selections */
+ int left_margin;
+ int dialog_horiz_offset, dialog_vert_offset; /* position for popup dialog */
+ Boolean display_caret; /* insertion pt visible iff T */
+ Boolean auto_fill; /* Auto fill mode? */
+ XawTextScrollMode scroll_vert, scroll_horiz;
+ XawTextWrapMode wrap; /* The type of wrapping */
+ XawTextResizeMode resize;
+ XawTextMargin r_margin; /* The real margins */
+#ifndef OLDXAW
+ XtCallbackList position_callbacks;
+#else
+ XtPointer pad1;
+#endif
+
+ /* private state */
+ XawTextMargin margin; /* The current margins */
+ XawTextLineTable lt;
+ XawTextScanDirection extendDir;
+ XawTextSelection origSel; /* the selection being modified */
+ Time lasttime; /* timestamp of last processed action */
+ Time time; /* time of last key or button action */
+ Position ev_x, ev_y; /* x, y coords for key or button action */
+ Widget vbar, hbar; /* The scroll bars (none = NULL) */
+ struct SearchAndReplace *search; /* Search and replace structure */
+ Widget file_insert; /* The file insert popup widget */
+ XmuTextUpdate *update; /* Position intervals to update */
+#ifndef OLDXAW
+ int line_number;
+ short column_number;
+ unsigned char kill_ring;
+ Boolean selection_state;
+#else
+ XtPointer pad2;
+ int pad3;
+#endif
+ int from_left; /* Cursor position */
+ XawTextPosition lastPos; /* Last position of source */
+ GC gc;
+ Boolean showposition; /* True if we need to show the position */
+ Boolean hasfocus; /* TRUE if we currently have input focus*/
+ Boolean update_disabled; /* TRUE if display updating turned off */
+ Boolean clear_to_eol; /* Clear to eol when painting text? */
+ XawTextPosition old_insert; /* Last insertPos for batched updates */
+ short mult; /* Multiplier */
+#ifndef OLDXAW
+ XawTextKillRing *kill_ring_ptr;
+#else
+ XtPointer pad4;
+#endif
+
+ /* private state, shared w/Source and Sink */
+ Boolean redisplay_needed; /* in SetValues */
+ XawTextSelectionSalt *salt2; /* salted away selections */
+
+#ifndef OLDXAW
+ char numeric;
+ char source_changed;
+ Boolean overwrite; /* Overwrite mode */
+
+ /* new resources and states, for text edition
+ * Note: a fixed width font is required for these resources/states.
+ */
+ short left_column, right_column;
+ XawTextJustifyMode justify;
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} TextPart;
+
+#define XtRWrapMode "WrapMode"
+#define XtRScrollMode "ScrollMode"
+#define XtRResizeMode "ResizeMode"
+#define XtRJustifyMode "JustifyMode"
+
+/* full instance record */
+typedef struct _TextRec {
+ CorePart core;
+ SimplePart simple;
+ TextPart text;
+} TextRec;
+
+/*
+ * Semi-private functions
+ * for use by other Xaw modules only
+ */
+void _XawTextBuildLineTable
+(
+ TextWidget ctx,
+ XawTextPosition top_pos,
+ _XtBoolean force_rebuild
+ );
+
+char *_XawTextGetSTRING
+(
+ TextWidget ctx,
+ XawTextPosition left,
+ XawTextPosition right
+ );
+
+void _XawTextSaltAwaySelection
+(
+ TextWidget ctx,
+ Atom *selections,
+ int num_atoms
+ );
+
+void _XawTextPosToXY
+(
+ Widget w,
+ XawTextPosition pos,
+ Position *x,
+ Position *y
+ );
+
+void _XawTextNeedsUpdating
+(
+ TextWidget ctx,
+ XawTextPosition left,
+ XawTextPosition right
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XawTextP_h */
diff --git a/nx-X11/lib/Xaw/TextPop.c b/nx-X11/lib/Xaw/TextPop.c
new file mode 100644
index 000000000..dd67ef4a1
--- /dev/null
+++ b/nx-X11/lib/Xaw/TextPop.c
@@ -0,0 +1,1554 @@
+/* $Xorg: TextPop.c,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* $XFree86: xc/lib/Xaw/TextPop.c,v 1.20tsi Exp $ */
+
+/*
+ * This file is broken up into three sections one dealing with
+ * each of the three popups created here:
+ *
+ * FileInsert, Search, and Replace.
+ *
+ * There is also a section at the end for utility functions
+ * used by all more than one of these dialogs.
+ *
+ * The following functions are the only non-static ones defined
+ * in this module. They are located at the begining of the
+ * section that contains this dialog box that uses them.
+ *
+ * void _XawTextInsertFileAction(w, event, params, num_params);
+ * void _XawTextDoSearchAction(w, event, params, num_params);
+ * void _XawTextDoReplaceAction(w, event, params, num_params);
+ * void _XawTextInsertFile(w, event, params, num_params);
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <errno.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+#include <X11/Xos.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xaw/TextP.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Toggle.h>
+#include "XawI18n.h"
+
+static char* INSERT_FILE = "Enter Filename:";
+static char* SEARCH_LABEL_1 = "Use <Tab> to change fields.";
+static char* SEARCH_LABEL_2 = "Use ^q<Tab> for <Tab>.";
+static char* DISMISS_NAME = "cancel";
+#define DISMISS_NAME_LEN 6
+static char* FORM_NAME = "form";
+static char* LABEL_NAME = "label";
+static char* TEXT_NAME = "text";
+
+#define R_OFFSET 1
+
+typedef void (*AddFunc)(Widget, char*, Widget);
+
+/*
+ * Prototypes
+ */
+static void _SetField(Widget, Widget);
+static void AddSearchChildren(Widget, char*, Widget);
+static void AddInsertFileChildren(Widget, char*, Widget);
+static void CenterWidgetOnPoint(Widget, XEvent*);
+static Widget CreateDialog(Widget, String, String, AddFunc);
+static void DoInsert(Widget, XtPointer, XtPointer);
+static void DoReplaceAll(Widget, XtPointer, XtPointer);
+static void DoReplaceOne(Widget, XtPointer, XtPointer);
+static Bool DoSearch(struct SearchAndReplace*);
+static Widget GetShell(Widget);
+static String GetString(Widget);
+static String GetStringRaw(Widget);
+static void InitializeSearchWidget(struct SearchAndReplace*,
+ XawTextScanDirection, Bool);
+static Bool InParams(String, String*, unsigned int);
+static Bool InsertFileNamed(Widget, char*);
+static void PopdownFileInsert(Widget, XtPointer, XtPointer);
+static void PopdownSearch(Widget, XtPointer, XtPointer);
+static Bool Replace(struct SearchAndReplace*, Bool, Bool);
+static void SearchButton(Widget, XtPointer, XtPointer);
+static void SetResource(Widget, char*, XtArgVal);
+static Bool SetResourceByName(Widget, char*, char*, XtArgVal);
+static void SetSearchLabels(struct SearchAndReplace*, String, String, Bool);
+static void SetWMProtocolTranslations(Widget);
+
+/*
+ * Actions
+ */
+static void WMProtocols(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * External Actions
+ */
+void _XawTextDoReplaceAction(Widget, XEvent*, String*, Cardinal*);
+void _XawTextDoSearchAction(Widget, XEvent*, String*, Cardinal*);
+void _XawTextInsertFile(Widget, XEvent*, String*, Cardinal*);
+void _XawTextInsertFileAction(Widget, XEvent*, String*, Cardinal*);
+void _XawTextPopdownSearchAction(Widget, XEvent*, String*, Cardinal*);
+void _XawTextSearch(Widget, XEvent*, String*, Cardinal*);
+void _XawTextSetField(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * From Text.c
+ */
+char *_XawTextGetText(TextWidget, XawTextPosition, XawTextPosition);
+void _XawTextShowPosition(TextWidget);
+
+/*
+ * Initialization
+ */
+static char radio_trans_string[] =
+"<Btn1Down>,<Btn1Up>:" "set() notify()\n"
+;
+
+static char search_text_trans[] =
+"~s<Key>Return:" "DoSearchAction(Popdown)\n"
+"s<Key>Return:" "DoSearchAction() SetField(Replace)\n"
+"c<Key>c:" "PopdownSearchAction()\n"
+"<Btn1Down>:" "select-start() SetField(Search)\n"
+"<Key>Tab:" "DoSearchAction() SetField(Replace)\n"
+;
+
+static char rep_text_trans[] =
+"~s<Key>Return:" "DoReplaceAction(Popdown)\n"
+"s<Key>Return:" "SetField(Search)\n"
+"c<Key>c:" "PopdownSearchAction()\n"
+"<Btn1Down>:" "select-start() DoSearchAction() SetField(Replace)\n"
+"<Key>Tab:" "SetField(Search)\n"
+;
+
+/*
+ * Implementation
+ */
+/*
+ * This section of the file contains all the functions that
+ * the file insert dialog box uses
+ */
+
+/*
+ * Function:
+ * _XawTextInsertFileAction
+ *
+ * Description:
+ * Action routine that can be bound to dialog box's Text Widget
+ * that will insert a file into the main Text Widget.
+ */
+/*ARGSUSED*/
+void
+_XawTextInsertFileAction(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ DoInsert(w, (XtPointer)XtParent(XtParent(XtParent(w))), NULL);
+}
+
+/*
+ * Function:
+ * _XawTextInsertFile
+ *
+ * Parameters:
+ * w - text widget
+ * event - X Event (used to get x and y location)
+ * params - parameter list
+ * num_params - ""
+ *
+ * Description:
+ * Action routine that can be bound to the text widget
+ * it will popup the insert file dialog box.
+ *
+ * Note:
+ * The parameter list may contain one entry
+ *
+ * Entry:
+ * This entry is optional and contains the value of the default
+ * file to insert
+ */
+void
+_XawTextInsertFile(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+ char *ptr;
+ XawTextEditType edit_mode;
+ Arg args[1];
+
+ XtSetArg(args[0], XtNeditType, &edit_mode);
+ XtGetValues(ctx->text.source, args, 1);
+
+ if (edit_mode != XawtextEdit) {
+ XBell(XtDisplay(w), 0);
+ return;
+ }
+
+ if (*num_params == 0)
+ ptr = "";
+ else
+ ptr = params[0];
+
+ if (!ctx->text.file_insert) {
+ ctx->text.file_insert = CreateDialog(w, ptr, "insertFile",
+ AddInsertFileChildren);
+ XtRealizeWidget(ctx->text.file_insert);
+ SetWMProtocolTranslations(ctx->text.file_insert);
+ }
+
+ CenterWidgetOnPoint(ctx->text.file_insert, event);
+ XtPopup(ctx->text.file_insert, XtGrabNone);
+}
+
+/*
+ * Function:
+ * PopdownFileInsert
+ *
+ * Parameters:
+ * w - widget that caused this action
+ * closure - pointer to the main text widget that popped up this dialog
+ * call_data - (not used)
+ *
+ * Description:
+ * Pops down the file insert button
+ */
+/*ARGSUSED*/
+static void
+PopdownFileInsert(Widget w, XtPointer closure, XtPointer call_data)
+{
+ TextWidget ctx = (TextWidget)closure;
+
+ XtPopdown(ctx->text.file_insert);
+ (void)SetResourceByName(ctx->text.file_insert, LABEL_NAME,
+ XtNlabel, (XtArgVal)INSERT_FILE);
+}
+
+/*
+ * Function:
+ * DoInsert
+ *
+ * Parameters:
+ * w - widget that activated this callback
+ * closure - pointer to the text widget to insert the file into
+ *
+ * Description:
+ * Actually insert the file named in the text widget of the file dialog
+ */
+/*ARGSUSED*/
+static void
+DoInsert(Widget w, XtPointer closure, XtPointer call_data)
+{
+ TextWidget ctx = (TextWidget)closure;
+ char buf[BUFSIZ], msg[BUFSIZ];
+ Widget temp_widget;
+
+ (void)XmuSnprintf(buf, sizeof(buf), "%s.%s", FORM_NAME, TEXT_NAME);
+ if ((temp_widget = XtNameToWidget(ctx->text.file_insert, buf)) == NULL) {
+ (void)strcpy(msg,
+ "Error: Could not get text widget from file insert popup");
+ }
+ else if (InsertFileNamed((Widget)ctx, GetString(temp_widget))) {
+ PopdownFileInsert(w, closure, call_data);
+ return;
+ }
+ else
+ (void)XmuSnprintf(msg, sizeof(msg), "Error: %s", strerror(errno));
+
+ (void)SetResourceByName(ctx->text.file_insert,
+ LABEL_NAME, XtNlabel, (XtArgVal)msg);
+ XBell(XtDisplay(w), 0);
+}
+
+/*
+ * Function:
+ * InsertFileNamed
+ *
+ * Parameters:
+ * tw - text widget to insert this file into
+ * str - name of the file to insert
+ *
+ * Description:
+ * Inserts a file into the text widget.
+ *
+ * Returns:
+ * True if the insert was sucessful, False otherwise.
+ */
+static Bool
+InsertFileNamed(Widget tw, char *str)
+{
+ FILE *file;
+ XawTextBlock text;
+ XawTextPosition pos;
+
+ if (str == NULL || strlen(str) == 0 || (file = fopen(str, "r")) == NULL)
+ return (False);
+
+ pos = XawTextGetInsertionPoint(tw);
+
+ fseek(file, 0L, 2);
+
+ text.firstPos = 0;
+ text.length = ftell(file);
+ text.ptr = XtMalloc(text.length + 1);
+ text.format = XawFmt8Bit;
+
+ fseek(file, 0L, 0);
+ if (fread(text.ptr, 1, text.length, file) != text.length)
+ XtErrorMsg("readError", "insertFileNamed", "XawError",
+ "fread returned error", NULL, NULL);
+
+ if (XawTextReplace(tw, pos, pos, &text) != XawEditDone) {
+ XtFree(text.ptr);
+ fclose(file);
+ return (False);
+ }
+ pos += text.length;
+ XtFree(text.ptr);
+ fclose(file);
+ XawTextSetInsertionPoint(tw, pos);
+ _XawTextShowPosition((TextWidget)tw);
+
+ return (True);
+}
+
+/*
+ * Function:
+ * AddInsertFileChildren
+ *
+ * Parameters:
+ * form - form widget for the insert dialog widget
+ * ptr - pointer to the initial string for the Text Widget
+ * tw - main text widget
+ *
+ * Description:
+ * Adds all children to the InsertFile dialog widget.
+ */
+static void
+AddInsertFileChildren(Widget form, char *ptr, Widget tw)
+{
+ Arg args[10];
+ Cardinal num_args;
+ Widget label, text, cancel, insert;
+ XtTranslations trans;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, INSERT_FILE); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNresizable, True); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, 0); num_args++;
+ label = XtCreateManagedWidget(LABEL_NAME, labelWidgetClass, form,
+ args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNfromVert, label); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainRight); num_args++;
+ XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++;
+ XtSetArg(args[num_args], XtNresizable, True); num_args++;
+ XtSetArg(args[num_args], XtNstring, ptr); num_args++;
+ text = XtCreateManagedWidget(TEXT_NAME, asciiTextWidgetClass, form,
+ args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Insert File"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, text); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ insert = XtCreateManagedWidget("insert", commandWidgetClass, form,
+ args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Cancel"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, text); num_args++;
+ XtSetArg(args[num_args], XtNfromHoriz, insert); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ cancel = XtCreateManagedWidget(DISMISS_NAME, commandWidgetClass, form,
+ args, num_args);
+
+ XtAddCallback(cancel, XtNcallback, PopdownFileInsert, (XtPointer)tw);
+ XtAddCallback(insert, XtNcallback, DoInsert, (XtPointer)tw);
+
+ XtSetKeyboardFocus(form, text);
+
+ /*
+ * Bind <CR> to insert file
+ */
+ trans = XtParseTranslationTable("<Key>Return:InsertFileAction()");
+ XtOverrideTranslations(text, trans);
+}
+
+/*
+ * This section of the file contains all the functions that
+ * the search dialog box uses
+ */
+/*
+ * Function:
+ * _XawTextDoSearchAction
+ *
+ * Description:
+ * Action routine that can be bound to dialog box's Text Widget that
+ * will search for a string in the main Text Widget.
+ *
+ * Note:
+ * If the search was sucessful and the argument popdown is passed to
+ * this action routine then the widget will automatically popdown the
+ * search widget
+ */
+/*ARGSUSED*/
+void
+_XawTextDoSearchAction(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ TextWidget tw = (TextWidget)XtParent(XtParent(XtParent(w)));
+ Bool popdown = False;
+
+ if (*num_params == 1 && (params[0][0] == 'p' || params[0][0] == 'P'))
+ popdown = True;
+
+ if (DoSearch(tw->text.search) && popdown)
+ PopdownSearch(w, (XtPointer)tw->text.search, NULL);
+}
+
+/*
+ * Function:
+ * _XawTextPopdownSearchAction
+ *
+ * Description:
+ * Action routine that can be bound to dialog box's Text Widget that
+ * will popdown the search widget.
+ */
+/*ARGSUSED*/
+void
+_XawTextPopdownSearchAction(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ TextWidget tw = (TextWidget)XtParent(XtParent(XtParent(w)));
+
+ PopdownSearch(w, (XtPointer)tw->text.search, NULL);
+}
+
+/*
+ * Function:
+ * PopdownSearch
+ *
+ * Parameters:
+ * w - (not used)
+ * closure - pointer to the search structure
+ * call_data - (not used)
+ *
+ * Description:
+ * Pops down the search widget and resets it
+ */
+/*ARGSUSED*/
+static void
+PopdownSearch(Widget w, XtPointer closure, XtPointer call_data)
+{
+ struct SearchAndReplace *search = (struct SearchAndReplace *)closure;
+
+ XtPopdown(search->search_popup);
+ SetSearchLabels(search, SEARCH_LABEL_1, SEARCH_LABEL_2, False);
+}
+
+/*
+ * Function:
+ * SearchButton
+ *
+ * Arguments:
+ * w - (not used)
+ * closure - pointer to the search info
+ * call_data - (not used)
+ *
+ * Description:
+ * Performs a search when the button is clicked.
+ */
+/*ARGSUSED*/
+static void
+SearchButton(Widget w, XtPointer closure, XtPointer call_data)
+{
+ (void)DoSearch((struct SearchAndReplace *)closure);
+}
+
+/*
+ * Function:
+ * _XawTextSearch
+ *
+ * Parameters:
+ * w - text widget
+ * event - X Event (used to get x and y location)
+ * params - parameter list
+ * num_params - ""
+ *
+ * Description:
+ * Action routine that can be bound to the text widget
+ * it will popup the search dialog box.
+ *
+ * Note:
+ * The parameter list contains one or two entries that may be
+ * the following.
+ *
+ * First Entry:
+ * The first entry is the direction to search by default.
+ * This arguement must be specified and may have a value of
+ * "left" or "right".
+ *
+ * Second Entry:
+ * This entry is optional and contains the value of the default
+ * string to search for.
+ */
+
+#define SEARCH_HEADER "Text Widget - Search():"
+void
+_XawTextSearch(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)w;
+ XawTextScanDirection dir;
+ char *ptr, buf[BUFSIZ];
+ XawTextEditType edit_mode;
+ Arg args[1];
+ wchar_t wcs[1];
+
+ if (*num_params < 1 || *num_params > 2) {
+ (void)XmuSnprintf(buf, sizeof(buf), "%s %s\n%s", SEARCH_HEADER,
+ "This action must have only",
+ "one or two parameters");
+ XtAppWarning(XtWidgetToApplicationContext(w), buf);
+ return;
+ }
+
+ if (*num_params == 2)
+ ptr = params[1];
+ else if (XawTextFormat(ctx, XawFmtWide)) {
+ /* This just does the equivalent of
+ ptr = ""L, a waste because params[1] isnt W aligned */
+ ptr = (char *)wcs;
+ wcs[0] = 0;
+ }
+ else
+ ptr = "";
+
+ switch(params[0][0]) {
+ case 'b': /* Left */
+ case 'B':
+ dir = XawsdLeft;
+ break;
+ case 'f': /* Right */
+ case 'F':
+ dir = XawsdRight;
+ break;
+ default:
+ (void)XmuSnprintf(buf, sizeof(buf), "%s %s\n%s", SEARCH_HEADER,
+ "The first parameter must be",
+ "Either 'backward' or 'forward'");
+ XtAppWarning(XtWidgetToApplicationContext(w), buf);
+ return;
+ }
+
+ if (ctx->text.search== NULL) {
+ ctx->text.search = XtNew(struct SearchAndReplace);
+ ctx->text.search->search_popup = CreateDialog(w, ptr, "search",
+ AddSearchChildren);
+ XtRealizeWidget(ctx->text.search->search_popup);
+ SetWMProtocolTranslations(ctx->text.search->search_popup);
+ }
+ else if (*num_params > 1)
+ XtVaSetValues(ctx->text.search->search_text, XtNstring, ptr, NULL);
+
+ XtSetArg(args[0], XtNeditType,&edit_mode);
+ XtGetValues(ctx->text.source, args, 1);
+
+ InitializeSearchWidget(ctx->text.search, dir, (edit_mode == XawtextEdit));
+
+ CenterWidgetOnPoint(ctx->text.search->search_popup, event);
+ XtPopup(ctx->text.search->search_popup, XtGrabNone);
+}
+
+/*
+ * Function:
+ * InitializeSearchWidget
+ *
+ * Parameters:
+ * search - search widget structure
+ * dir - direction to search
+ * replace_active - state of the sensitivity for the replace button
+ *
+ * Description:
+ * This function initializes the search widget and
+ * is called each time the search widget is poped up.
+ */
+static void
+InitializeSearchWidget(struct SearchAndReplace *search,
+ XawTextScanDirection dir, Bool replace_active)
+{
+ SetResource(search->rep_one, XtNsensitive, (XtArgVal)replace_active);
+ SetResource(search->rep_all, XtNsensitive, (XtArgVal)replace_active);
+ SetResource(search->rep_label, XtNsensitive, (XtArgVal)replace_active);
+ SetResource(search->rep_text, XtNsensitive, (XtArgVal)replace_active);
+
+ switch (dir) {
+ case XawsdLeft:
+ SetResource(search->left_toggle, XtNstate, (XtArgVal)True);
+ break;
+ case XawsdRight:
+ SetResource(search->right_toggle, XtNstate, (XtArgVal)True);
+ break;
+ }
+}
+
+/*
+ * Function:
+ * AddSearchChildren
+ *
+ * Parameters:
+ * form - form widget for the search widget
+ * ptr - pointer to the initial string for the Text Widget
+ * tw - main text widget
+ *
+ * Description:
+ * Adds all children to the Search Dialog Widget.
+ */
+static void
+AddSearchChildren(Widget form, char *ptr, Widget tw)
+{
+ Arg args[10];
+ Cardinal num_args;
+ Widget cancel, search_button, s_label, s_text, r_text;
+ XtTranslations trans;
+ struct SearchAndReplace *search = ((TextWidget)tw)->text.search;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNresizable, True); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, 0); num_args++;
+ search->label1 = XtCreateManagedWidget("label1", labelWidgetClass, form,
+ args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNfromVert, search->label1); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNresizable, True); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, 0); num_args++;
+ search->label2 = XtCreateManagedWidget("label2", labelWidgetClass, form,
+ args, num_args);
+
+ /*
+ * We need to add R_OFFSET to the radio_data, because the value zero (0)
+ * has special meaning
+ */
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Backward"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, search->label2); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNradioData, (XPointer)XawsdLeft + R_OFFSET);
+ num_args++;
+ search->left_toggle = XtCreateManagedWidget("backwards", toggleWidgetClass,
+ form, args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Forward"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, search->label2); num_args++;
+ XtSetArg(args[num_args], XtNfromHoriz, search->left_toggle); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNradioGroup, search->left_toggle); num_args++;
+ XtSetArg(args[num_args], XtNradioData, (XPointer)XawsdRight + R_OFFSET);
+ num_args++;
+ search->right_toggle = XtCreateManagedWidget("forwards", toggleWidgetClass,
+ form, args, num_args);
+
+ {
+ XtTranslations radio_translations;
+
+ radio_translations = XtParseTranslationTable(radio_trans_string);
+ XtOverrideTranslations(search->left_toggle, radio_translations);
+ XtOverrideTranslations(search->right_toggle, radio_translations);
+ }
+
+#ifndef OLDXAW
+ if (XawTextFormat((TextWidget)tw, XawFmt8Bit)) {
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Case Sensitive"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, search->label2); num_args++;
+ XtSetArg(args[num_args], XtNfromHoriz, search->right_toggle); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNstate, True); num_args++;
+ search->case_sensitive = XtCreateManagedWidget("case", toggleWidgetClass,
+ form, args, num_args);
+ }
+ else
+ search->case_sensitive = NULL;
+#endif
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNfromVert, search->left_toggle); num_args++;
+ XtSetArg(args[num_args], XtNlabel, "Search for: "); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++;
+ s_label = XtCreateManagedWidget("searchLabel", labelWidgetClass, form,
+ args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNfromVert, search->left_toggle); num_args++;
+ XtSetArg(args[num_args], XtNfromHoriz, s_label); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainRight); num_args++;
+ XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++;
+ XtSetArg(args[num_args], XtNresizable, True); num_args++;
+ XtSetArg(args[num_args], XtNstring, ptr); num_args++;
+ s_text = XtCreateManagedWidget("searchText", asciiTextWidgetClass, form,
+ args, num_args);
+ search->search_text = s_text;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNfromVert, s_text); num_args++;
+ XtSetArg(args[num_args], XtNlabel, "Replace with:"); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, 0); num_args++;
+ search->rep_label = XtCreateManagedWidget("replaceLabel", labelWidgetClass,
+ form, args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNfromHoriz, s_label); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, s_text); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainRight); num_args++;
+ XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++;
+ XtSetArg(args[num_args], XtNresizable, True); num_args++;
+ XtSetArg(args[num_args], XtNstring, ""); num_args++;
+ r_text = XtCreateManagedWidget("replaceText", asciiTextWidgetClass,
+ form, args, num_args);
+ search->rep_text = r_text;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Search"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, r_text); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ search_button = XtCreateManagedWidget("search", commandWidgetClass, form,
+ args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Replace"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, r_text); num_args++;
+ XtSetArg(args[num_args], XtNfromHoriz, search_button); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ search->rep_one = XtCreateManagedWidget("replaceOne", commandWidgetClass,
+ form, args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Replace All"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, r_text); num_args++;
+ XtSetArg(args[num_args], XtNfromHoriz, search->rep_one); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ search->rep_all = XtCreateManagedWidget("replaceAll", commandWidgetClass,
+ form, args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Cancel"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, r_text); num_args++;
+ XtSetArg(args[num_args], XtNfromHoriz, search->rep_all); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ cancel = XtCreateManagedWidget(DISMISS_NAME, commandWidgetClass, form,
+ args, num_args);
+
+ XtAddCallback(search_button, XtNcallback, SearchButton, (XtPointer)search);
+ XtAddCallback(search->rep_one, XtNcallback, DoReplaceOne, (XtPointer)search);
+ XtAddCallback(search->rep_all, XtNcallback, DoReplaceAll, (XtPointer)search);
+ XtAddCallback(cancel, XtNcallback, PopdownSearch, (XtPointer)search);
+
+ /*
+ * Initialize the text entry fields
+ */
+ {
+ Pixel color;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNbackground, &color); num_args++;
+ XtGetValues(search->rep_text, args, num_args);
+ num_args = 0;
+ XtSetArg(args[num_args], XtNborderColor, color); num_args++;
+ XtSetValues(search->rep_text, args, num_args);
+ XtSetKeyboardFocus(form, search->search_text);
+ }
+
+ SetSearchLabels(search, SEARCH_LABEL_1, SEARCH_LABEL_2, False);
+
+ /*
+ * Bind Extra translations
+ */
+ trans = XtParseTranslationTable(search_text_trans);
+ XtOverrideTranslations(search->search_text, trans);
+
+ trans = XtParseTranslationTable(rep_text_trans);
+ XtOverrideTranslations(search->rep_text, trans);
+}
+
+/*
+ * Function:
+ * DoSearch
+ *
+ * Parameters:
+ * search - search structure
+ *
+ * Description:
+ * Performs a search
+ *
+ * Returns:
+ * True if sucessful
+ */
+/*ARGSUSED*/
+static Bool
+DoSearch(struct SearchAndReplace *search)
+{
+ char msg[37];
+ Widget tw = XtParent(search->search_popup);
+ XawTextPosition pos;
+ XawTextScanDirection dir;
+ XawTextBlock text;
+ TextWidget ctx = (TextWidget)tw;
+
+ text.firstPos = 0;
+ text.ptr = GetStringRaw(search->search_text);
+ if ((text.format = _XawTextFormat(ctx)) == XawFmtWide)
+ text.length = wcslen((wchar_t*)text.ptr);
+ else {
+ text.length = strlen(text.ptr);
+
+#ifndef OLDXAW
+ if (search->case_sensitive) {
+ /* text.firstPos isn't useful here, so I'll use it as an
+ * options flag.
+ */
+ Arg args[1];
+ Boolean case_sensitive;
+
+ XtSetArg(args[0], XtNstate, &case_sensitive);
+ XtGetValues(search->case_sensitive, args, 1);
+ text.firstPos = !case_sensitive;
+ }
+#endif /* OLDXAW */
+ }
+
+ dir = (XawTextScanDirection)(unsigned long)
+ ((XPointer)XawToggleGetCurrent(search->left_toggle) - R_OFFSET);
+
+ pos = XawTextSearch(tw, dir, &text);
+
+ /* The Raw string in find.ptr may be WC I can't use here, so I re - call
+ GetString to get a tame version */
+
+ if (pos == XawTextSearchError) {
+ char *ptr;
+ int len;
+
+ ptr = GetString(search->search_text);
+ len = strlen(ptr);
+ (void)XmuSnprintf(msg, sizeof(msg), "%s", ptr);
+
+ ptr = strchr(msg, '\n');
+ if (ptr != NULL || sizeof(msg) - 1 < len) {
+ if (ptr != NULL)
+ len = ptr - msg + 4;
+ else
+ len = strlen(msg);
+
+ if (len < 4)
+ strcpy(msg, "...");
+ else
+ strcpy(msg + len - 4, "...");
+ }
+ XawTextUnsetSelection(tw);
+ SetSearchLabels(search, "Could not find string", msg, True);
+
+ return (False);
+ }
+ XawTextDisableRedisplay(tw);
+ XawTextSetSelection(tw, pos, pos + text.length);
+ search->selection_changed = False; /* selection is good */
+
+ if (dir == XawsdRight)
+ XawTextSetInsertionPoint(tw, pos + text.length);
+ else
+ XawTextSetInsertionPoint(tw, pos);
+ _XawTextShowPosition(ctx);
+ XawTextEnableRedisplay(tw);
+
+ return (True);
+}
+
+/*
+ * This section of the file contains all the functions that
+ * the replace dialog box uses
+ */
+/*
+ * Function:
+ * _XawTextDoReplaceAction
+ *
+ * Description:
+ * Action routine that can be bound to dialog box's
+ * Text Widget that will replace a string in the main Text Widget.
+ */
+/*ARGSUSED*/
+void
+_XawTextDoReplaceAction(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ TextWidget ctx = (TextWidget)XtParent(XtParent(XtParent(w)));
+ Bool popdown = False;
+
+ if (*num_params == 1 && (params[0][0] == 'p' || params[0][0] == 'P'))
+ popdown = True;
+
+ if (Replace( ctx->text.search, True, popdown) && popdown)
+ PopdownSearch(w, (XtPointer)ctx->text.search, NULL);
+}
+
+/*
+ * Function:
+ * DoReplaceOne
+ *
+ * Arguments:
+ * w - *** Not Used ***
+ * closure - a pointer to the search structure
+ * call_data - *** Not Used ***
+ *
+ * Description:
+ * Replaces the first instance of the string in the search
+ * dialog's text widget with the one in the replace dialog's text widget.
+ */
+/*ARGSUSED*/
+static void
+DoReplaceOne(Widget w, XtPointer closure, XtPointer call_data)
+{
+ Replace((struct SearchAndReplace *)closure, True, False);
+}
+
+/*
+ * Function:
+ * DoReplaceAll
+ *
+ * Parameters:
+ * w - (not used)
+ * closure - pointer to the search structure
+ * call_data - (not used)
+ *
+ * Description:
+ * Replaces every instance of the string in the search dialog's
+ * text widget with the one in the replace dialog's text widget.
+ */
+/*ARGSUSED*/
+static void
+DoReplaceAll(Widget w, XtPointer closure, XtPointer call_data)
+{
+ Replace((struct SearchAndReplace *)closure, False, False);
+}
+
+/*
+ * Function:
+ * Replace
+ *
+ * Parameters:
+ * tw - Text Widget to replce the string in
+ * once_only - if True then only replace the first one found,
+ * else replace all of them
+ * show_current - if true then leave the selection on the
+ * string that was just replaced, otherwise
+ * move it onto the next one
+ *
+ * Description:
+ * This is the function that does the real work of
+ * replacing strings in the main text widget.
+ */
+static Bool
+Replace(struct SearchAndReplace *search, Bool once_only, Bool show_current)
+{
+ XawTextPosition pos, new_pos, end_pos, ipos;
+ XawTextScanDirection dir;
+ XawTextBlock find, replace;
+ Widget tw = XtParent(search->search_popup);
+ int count = 0;
+ TextWidget ctx = (TextWidget)tw;
+ Bool redisplay;
+
+ find.ptr = GetStringRaw(search->search_text);
+ if ((find.format = _XawTextFormat(ctx)) == XawFmtWide)
+ find.length = (XawTextPosition)wcslen((wchar_t*)find.ptr);
+ else
+ find.length = (XawTextPosition)strlen(find.ptr);
+ find.firstPos = 0;
+
+ replace.ptr = GetStringRaw(search->rep_text);
+ replace.firstPos = 0;
+ if ((replace.format = _XawTextFormat(ctx)) == XawFmtWide)
+ replace.length = wcslen((wchar_t*)replace.ptr);
+ else
+ replace.length = strlen(replace.ptr);
+
+ dir = (XawTextScanDirection)(unsigned long)
+ ((XPointer)XawToggleGetCurrent(search->left_toggle) - R_OFFSET);
+
+ redisplay = !once_only || (once_only && !show_current);
+ ipos = XawTextGetInsertionPoint(tw);
+ if (redisplay)
+ XawTextDisableRedisplay(tw);
+ /*CONSTCOND*/
+ while (True) {
+ if (count != 0) {
+ new_pos = XawTextSearch(tw, dir, &find);
+
+ if (new_pos == XawTextSearchError) {
+ if (count == 0) {
+ char msg[37];
+ char *ptr;
+ int len;
+
+ ptr = GetString(search->search_text);
+ len = strlen(ptr);
+ (void)XmuSnprintf(msg, sizeof(msg), "%s", ptr);
+ ptr = strchr(msg, '\n');
+ if (ptr != NULL || sizeof(msg) - 1 < len) {
+ if (ptr != NULL)
+ len = ptr - msg + 4;
+ else
+ len = strlen(msg);
+
+ if (len < 4)
+ strcpy(msg, "...");
+ else
+ strcpy(msg + len - 4, "...");
+ }
+ SetSearchLabels(search, "Could not find string", msg, True);
+
+ if (redisplay) {
+ XawTextSetInsertionPoint(tw, ipos);
+ _XawTextShowPosition(ctx);
+ XawTextEnableRedisplay(tw);
+ }
+
+ return (False);
+ }
+ else
+ break;
+ }
+ pos = new_pos;
+ end_pos = pos + find.length;
+ }
+ else {
+ XawTextGetSelectionPos(tw, &pos, &end_pos);
+
+ if (search->selection_changed) {
+ SetSearchLabels(search, "Selection modified, aborting.",
+ "", True);
+ if (redisplay) {
+ XawTextSetInsertionPoint(tw, ipos);
+ XawTextEnableRedisplay(tw);
+ }
+
+ return (False);
+ }
+ if (pos == end_pos) {
+ if (redisplay) {
+ XawTextSetInsertionPoint(tw, ipos);
+ XawTextEnableRedisplay(tw);
+ }
+
+ return (False);
+ }
+ }
+
+ if (XawTextReplace(tw, pos, end_pos, &replace) != XawEditDone) {
+ SetSearchLabels(search, "Error while replacing.", "", True);
+ if (redisplay) {
+ XawTextSetInsertionPoint(tw, ipos);
+ XawTextEnableRedisplay(tw);
+ }
+
+ return (False);
+ }
+
+ if (dir == XawsdRight)
+ ipos = pos + replace.length;
+ else
+ ipos = pos;
+
+ if (once_only) {
+ if (show_current)
+ break;
+ else {
+ DoSearch(search);
+ XawTextEnableRedisplay(tw);
+
+ return (True);
+ }
+ }
+ else
+ ctx->text.insertPos = ipos;
+ count++;
+ }
+
+ if (replace.length == 0)
+ XawTextUnsetSelection(tw);
+ else
+ XawTextSetSelection(tw, pos, pos + replace.length);
+
+ XawTextSetInsertionPoint(tw, ipos);
+ _XawTextShowPosition(ctx);
+ XawTextEnableRedisplay(tw);
+
+ return (True);
+}
+
+/*
+ * Function:
+ * SetSearchLabels
+ *
+ * Parameters:
+ * search - search structure
+ * msg1 - message to put in each search label
+ * msg2 - ""
+ * bell - if True then ring bell
+ *
+ * Description:
+ * Sets both the search labels, and also rings the bell.
+ */
+static void
+SetSearchLabels(struct SearchAndReplace *search, String msg1, String msg2,
+ Bool bell)
+{
+ (void)SetResource(search->label1, XtNlabel, (XtArgVal)msg1);
+ (void)SetResource(search->label2, XtNlabel, (XtArgVal)msg2);
+ if (bell)
+ XBell(XtDisplay(search->search_popup), 0);
+}
+
+/*
+ * This section of the file contains utility routines used by
+ * other functions in this file
+ */
+/*
+ * Function:
+ * _XawTextSetField
+ *
+ * Description:
+ * Action routine that can be bound to dialog box's
+ * Text Widget that will send input to the field specified.
+ */
+/*ARGSUSED*/
+void
+_XawTextSetField(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ struct SearchAndReplace *search;
+ Widget cnew, old;
+
+ search = ((TextWidget)XtParent(XtParent(XtParent(w))))->text.search;
+
+ if (*num_params != 1) {
+ SetSearchLabels(search, "Error: SetField Action must have",
+ "exactly one argument", True);
+ return;
+ }
+ switch (params[0][0]) {
+ case 's':
+ case 'S':
+ cnew = search->search_text;
+ old = search->rep_text;
+ break;
+ case 'r':
+ case 'R':
+ old = search->search_text;
+ cnew = search->rep_text;
+ break;
+ default:
+ SetSearchLabels(search,
+ "Error: SetField Action's first Argument must",
+ "be either 'Search' or 'Replace'", True);
+ return;
+ }
+ _SetField(cnew, old);
+}
+
+/*
+ * Function:
+ * _SetField
+ *
+ * Parameters:
+ * cnew - new and old text fields
+ * old - ""
+ *
+ * Description:
+ * Sets the current text field.
+ */
+static void
+_SetField(Widget cnew, Widget old)
+{
+ Arg args[2];
+ Pixel new_border, old_border, old_bg;
+
+ if (!XtIsSensitive(cnew)) {
+ XBell(XtDisplay(old), 0); /* Don't set field to an inactive Widget */
+ return;
+ }
+
+ XtSetKeyboardFocus(XtParent(cnew), cnew);
+
+ XtSetArg(args[0], XtNborderColor, &old_border);
+ XtSetArg(args[1], XtNbackground, &old_bg);
+ XtGetValues(cnew, args, 2);
+
+ XtSetArg(args[0], XtNborderColor, &new_border);
+ XtGetValues(old, args, 1);
+
+ if (old_border != old_bg) /* Colors are already correct, return */
+ return;
+
+ SetResource(old, XtNborderColor, (XtArgVal)old_border);
+ SetResource(cnew, XtNborderColor, (XtArgVal)new_border);
+}
+
+/*
+ * Function:
+ * SetResourceByName
+ *
+ * Parameters:
+ * shell - shell widget of the popup
+ * name - name of the child
+ * res_name - name of the resource
+ * value - value of the resource
+ *
+ * Description:
+ * Sets a resource in any of the dialog children given
+ * name of the child and the shell widget of the dialog.
+ *
+ * Returns:
+ * True if sucessful
+ */
+static Bool
+SetResourceByName(Widget shell, char *name, char *res_name, XtArgVal value)
+{
+ Widget temp_widget;
+ char buf[BUFSIZ];
+
+ (void)XmuSnprintf(buf, sizeof(buf), "%s.%s", FORM_NAME, name);
+
+ if ((temp_widget = XtNameToWidget(shell, buf)) != NULL) {
+ SetResource(temp_widget, res_name, value);
+ return (True);
+ }
+ return (False);
+}
+
+/*
+ * Function:
+ * SetResource
+ *
+ * Parameters:
+ * w - widget
+ * res_name - name of the resource
+ * value - value of the resource
+ *
+ * Description:
+ * Sets a resource in a widget
+ */
+static void
+SetResource(Widget w, char *res_name, XtArgVal value)
+{
+ Arg args[1];
+
+ XtSetArg(args[0], res_name, value);
+ XtSetValues( w, args, 1);
+}
+
+/*
+ * Function:
+ * GetString{Raw}
+ *
+ * Parameters:
+ * text - text widget whose string we will get
+ *
+ * Description:
+ * Gets the value for the string in the popup.
+ *
+ * Returns:
+ * GetString: the string as a MB
+ * GetStringRaw: the exact buffer contents suitable for a search
+ */
+static String
+GetString(Widget text)
+{
+ String string;
+ Arg args[1];
+
+ XtSetArg(args[0], XtNstring, &string);
+ XtGetValues(text, args, 1);
+
+ return (string);
+}
+
+static String
+GetStringRaw(Widget tw)
+{
+ TextWidget ctx = (TextWidget)tw;
+ XawTextPosition last;
+
+ last = XawTextSourceScan(ctx->text.source, 0, XawstAll, XawsdRight,
+ ctx->text.mult, True);
+ return (_XawTextGetText(ctx, 0, last));
+}
+
+/*
+ * Function:
+ * CenterWidgetOnPoint
+ *
+ * Parameters:
+ * w - shell widget
+ * event - event containing the location of the point
+ *
+ * Description:
+ * Centers a shell widget on a point relative to the root window.
+ *
+ * Note:
+ * The widget is not allowed to go off the screen
+ */
+static void
+CenterWidgetOnPoint(Widget w, XEvent *event)
+{
+ Arg args[3];
+ Cardinal num_args;
+ Dimension width, height, b_width;
+ Position x, y, max_x, max_y;
+
+ if (event != NULL) {
+ switch (event->type) {
+ case ButtonPress:
+ case ButtonRelease:
+ x = event->xbutton.x_root;
+ y = event->xbutton.y_root;
+ break;
+ case KeyPress:
+ case KeyRelease:
+ x = event->xkey.x_root;
+ y = event->xkey.y_root;
+ break;
+ default:
+ return;
+ }
+ }
+ else
+ return;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNwidth, &width); num_args++;
+ XtSetArg(args[num_args], XtNheight, &height); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, &b_width); num_args++;
+ XtGetValues(w, args, num_args);
+
+ width += b_width << 1;
+ height += b_width << 1;
+
+ x -= (Position)(width >> 1);
+ if (x < 0)
+ x = 0;
+ if (x > (max_x = (Position)(XtScreen(w)->width - width)))
+ x = max_x;
+
+ y -= (Position)(height >> 1);
+ if (y < 0)
+ y = 0;
+ if (y > (max_y = (Position)(XtScreen(w)->height - height)))
+ y = max_y;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNx, x); num_args++;
+ XtSetArg(args[num_args], XtNy, y); num_args++;
+ XtSetValues(w, args, num_args);
+}
+
+/*
+ * Function:
+ * CreateDialog
+ *
+ * Parameters:
+ * parent - parent of the dialog - the main text widget
+ * ptr - initial_string for the dialog
+ * name - name of the dialog
+ * func - function to create the children of the dialog
+ *
+ * Returns:
+ * Popup shell of the dialog
+ *
+ * Note:
+ * The function argument is passed the following arguments:
+ * form - from widget that is the dialog
+ * ptr - initial string for the dialog's text widget
+ * parent - parent of the dialog - the main text widget
+ */
+static Widget
+CreateDialog(Widget parent, String ptr, String name, AddFunc func)
+{
+ Widget popup, form;
+ Arg args[5];
+ Cardinal num_args;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNiconName, name); num_args++;
+ XtSetArg(args[num_args], XtNgeometry, NULL); num_args++;
+ XtSetArg(args[num_args], XtNallowShellResize, True); num_args++;
+ XtSetArg(args[num_args], XtNtransientFor, GetShell(parent));num_args++;
+ popup = XtCreatePopupShell(name, transientShellWidgetClass,
+ parent, args, num_args);
+
+ form = XtCreateManagedWidget(FORM_NAME, formWidgetClass, popup, NULL, 0);
+ XtManageChild (form);
+
+ (*func)(form, ptr, parent);
+
+ return (popup);
+}
+
+/*
+ * Function
+ * GetShell
+ * nearest shell widget.
+ *
+ * Parameters:
+ * w - widget whose parent shell should be returned
+ *
+ * Returns:
+ * The shell widget among the ancestors of w that is the
+ * fewest levels up in the widget hierarchy.
+ *
+ * Description:
+ * Walks up the widget hierarchy to find the topmost shell widget.
+ */
+static Widget
+GetShell(Widget w)
+{
+ while (w != NULL && !XtIsShell(w))
+ w = XtParent(w);
+
+ return (w);
+}
+
+static Bool
+InParams(String str, String *p, unsigned int n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; p++, i++)
+ if (!XmuCompareISOLatin1(*p, str))
+ return (True);
+ return (False);
+}
+
+static char *WM_DELETE_WINDOW = "WM_DELETE_WINDOW";
+
+static void
+WMProtocols(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ Atom wm_delete_window;
+ Atom wm_protocols;
+
+ wm_delete_window = XInternAtom(XtDisplay(w), WM_DELETE_WINDOW, True);
+ wm_protocols = XInternAtom(XtDisplay(w), "WM_PROTOCOLS", True);
+
+ /* Respond to a recognized WM protocol request if
+ * event type is ClientMessage and no parameters are passed, or
+ * event type is ClientMessage and event data is matched to parameters, or
+ * event type isn't ClientMessage and parameters make a request
+ */
+#define DO_DELETE_WINDOW InParams(WM_DELETE_WINDOW, params, *num_params)
+
+ if ((event->type == ClientMessage
+ && event->xclient.message_type == wm_protocols
+ && event->xclient.data.l[0] == wm_delete_window
+ && (*num_params == 0 || DO_DELETE_WINDOW))
+ || (event->type != ClientMessage && DO_DELETE_WINDOW)) {
+#undef DO_DELETE_WINDOW
+ Widget cancel;
+ char descendant[DISMISS_NAME_LEN + 2];
+
+ (void)XmuSnprintf(descendant, sizeof(descendant), "*%s", DISMISS_NAME);
+ cancel = XtNameToWidget(w, descendant);
+ if (cancel)
+ XtCallCallbacks(cancel, XtNcallback, NULL);
+ }
+}
+
+static void
+SetWMProtocolTranslations(Widget w)
+{
+ static XtTranslations compiled_table;
+ static XtAppContext *app_context_list;
+ static Cardinal list_size;
+
+ unsigned int i;
+ XtAppContext app_context;
+ Atom wm_delete_window;
+
+ app_context = XtWidgetToApplicationContext(w);
+
+ /* parse translation table once */
+ if (!compiled_table)
+ compiled_table =
+ XtParseTranslationTable("<Message>WM_PROTOCOLS:XawWMProtocols()\n");
+
+ /* add actions once per application context */
+ for (i = 0; i < list_size && app_context_list[i] != app_context; i++)
+ ;
+ if (i == list_size) {
+ XtActionsRec actions[1];
+
+ actions[0].string = "XawWMProtocols";
+ actions[0].proc = WMProtocols;
+ list_size++;
+ app_context_list = (XtAppContext *)XtRealloc
+ ((char *)app_context_list, list_size * sizeof(XtAppContext));
+ XtAppAddActions(app_context, actions, 1);
+ app_context_list[i] = app_context;
+ }
+
+ /* establish communication between the window manager and each shell */
+ XtAugmentTranslations(w, compiled_table);
+ wm_delete_window = XInternAtom(XtDisplay(w), WM_DELETE_WINDOW, False);
+ (void)XSetWMProtocols(XtDisplay(w), XtWindow(w), &wm_delete_window, 1);
+}
diff --git a/nx-X11/lib/Xaw/TextSink.c b/nx-X11/lib/Xaw/TextSink.c
new file mode 100644
index 000000000..75f952fff
--- /dev/null
+++ b/nx-X11/lib/Xaw/TextSink.c
@@ -0,0 +1,1829 @@
+/* $Xorg: TextSink.c,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xaw/TextSink.c,v 1.21 2002/06/03 21:39:24 paulo Exp $ */
+
+/*
+ * Author: Chris Peterson, MIT X Consortium.
+ *
+ * Much code taken from X11R3 AsciiSink.
+ */
+
+/*
+ * TextSink.c - TextSink object. (For use with the text widget).
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/TextP.h>
+#include <X11/Xaw/TextSinkP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+/*
+ * Prototypes
+ */
+static void XawTextSinkClassPartInitialize(WidgetClass);
+static void XawTextSinkInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawTextSinkDestroy(Widget);
+static Boolean XawTextSinkSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+
+static int MaxLines(Widget, unsigned int);
+static int MaxHeight(Widget, int);
+static void DisplayText(Widget, int, int, XawTextPosition, XawTextPosition,
+ Bool);
+static void InsertCursor(Widget, int, int, XawTextInsertState);
+static void ClearToBackground(Widget, int, int, unsigned int, unsigned int);
+static void FindPosition(Widget, XawTextPosition, int, int, Bool,
+ XawTextPosition*, int*, int*);
+static void FindDistance(Widget, XawTextPosition, int, XawTextPosition, int*,
+ XawTextPosition*, int*);
+static void Resolve(Widget, XawTextPosition, int, int, XawTextPosition*);
+static void SetTabs(Widget, int, short*);
+static void GetCursorBounds(Widget, XRectangle*);
+
+#ifndef OLDXAW
+static Boolean CvtStringToPropertyList(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Boolean CvtPropertyListToString(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static Bool BeginPaint(Widget);
+static Bool EndPaint(Widget);
+static void SetXlfdDefaults(Display*, XawTextProperty*);
+#endif
+
+/*
+ * External
+ */
+void _XawTextSinkClearToBackground(Widget, int, int, unsigned, unsigned);
+void _XawTextSinkDisplayText(Widget, int, int, XawTextPosition, XawTextPosition,
+ Bool);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(TextSinkRec, text_sink.field)
+static XtResource resources[] = {
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(foreground),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XtNbackground,
+ XtCBackground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(background),
+ XtRString,
+ XtDefaultBackground
+ },
+#ifndef OLDXAW
+ {
+ XtNcursorColor,
+ XtCColor,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(cursor_color),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XawNtextProperties,
+ XawCTextProperties,
+ XawRTextProperties,
+ sizeof(XawTextPropertyList*),
+ offset(properties),
+ XtRImmediate,
+ NULL
+ },
+#endif
+};
+#undef offset
+
+#ifndef OLDXAW
+static TextSinkExtRec extension_rec = {
+ NULL, /* next_extension */
+ NULLQUARK, /* record_type */
+ 1, /* version */
+ sizeof(TextSinkExtRec), /* record_size */
+ BeginPaint,
+ NULL,
+ NULL,
+ EndPaint
+};
+
+static XrmQuark Qdefault;
+#endif
+
+#define Superclass (&objectClassRec)
+TextSinkClassRec textSinkClassRec = {
+ /* object */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "TextSink", /* class_name */
+ sizeof(TextSinkRec), /* widget_size */
+ XawInitializeWidgetSet, /* class_initialize */
+ XawTextSinkClassPartInitialize, /* class_part_initialize */
+ False, /* class_inited */
+ XawTextSinkInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ NULL, /* obj1 */
+ NULL, /* obj2 */
+ 0, /* obj3 */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ False, /* obj4 */
+ False, /* obj5 */
+ False, /* obj6 */
+ False, /* obj7 */
+ XawTextSinkDestroy, /* destroy */
+ NULL, /* obj8 */
+ NULL, /* obj9 */
+ XawTextSinkSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ NULL, /* obj10 */
+ NULL, /* get_values_hook */
+ NULL, /* obj11 */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* obj12 */
+ NULL, /* obj13 */
+ NULL, /* obj14 */
+ NULL, /* extension */
+ },
+ /* text_sink */
+ {
+ DisplayText, /* DisplayText */
+ InsertCursor, /* InsertCursor */
+ ClearToBackground, /* ClearToBackground */
+ FindPosition, /* FindPosition */
+ FindDistance, /* FindDistance */
+ Resolve, /* Resolve */
+ MaxLines, /* MaxLines */
+ MaxHeight, /* MaxHeight */
+ SetTabs, /* SetTabs */
+ GetCursorBounds, /* GetCursorBounds */
+ },
+};
+
+WidgetClass textSinkObjectClass = (WidgetClass)&textSinkClassRec;
+
+/*
+ * Implementation
+ */
+static void
+XawTextSinkClassPartInitialize(WidgetClass wc)
+{
+ TextSinkObjectClass t_src, superC;
+#ifndef OLDXAW
+ static XtConvertArgRec CvtArgs[] = {
+ {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.self),
+ sizeof(Widget)},
+ };
+#endif
+
+ t_src = (TextSinkObjectClass) wc;
+ superC = (TextSinkObjectClass) t_src->object_class.superclass;
+
+#ifndef OLDXAW
+ extension_rec.record_type = XrmPermStringToQuark("TextSink");
+ extension_rec.next_extension = (XtPointer)t_src->text_sink_class.extension;
+ t_src->text_sink_class.extension = &extension_rec;
+
+ Qdefault = XrmPermStringToQuark("default");
+#endif
+
+ /*
+ * We don't need to check for null super since we'll get to TextSink
+ * eventually.
+ */
+ if (t_src->text_sink_class.DisplayText == XtInheritDisplayText)
+ t_src->text_sink_class.DisplayText =
+ superC->text_sink_class.DisplayText;
+
+ if (t_src->text_sink_class.InsertCursor == XtInheritInsertCursor)
+ t_src->text_sink_class.InsertCursor =
+ superC->text_sink_class.InsertCursor;
+
+ if (t_src->text_sink_class.ClearToBackground== XtInheritClearToBackground)
+ t_src->text_sink_class.ClearToBackground =
+ superC->text_sink_class.ClearToBackground;
+
+ if (t_src->text_sink_class.FindPosition == XtInheritFindPosition)
+ t_src->text_sink_class.FindPosition =
+ superC->text_sink_class.FindPosition;
+
+ if (t_src->text_sink_class.FindDistance == XtInheritFindDistance)
+ t_src->text_sink_class.FindDistance =
+ superC->text_sink_class.FindDistance;
+
+ if (t_src->text_sink_class.Resolve == XtInheritResolve)
+ t_src->text_sink_class.Resolve =
+ superC->text_sink_class.Resolve;
+
+ if (t_src->text_sink_class.MaxLines == XtInheritMaxLines)
+ t_src->text_sink_class.MaxLines =
+ superC->text_sink_class.MaxLines;
+
+ if (t_src->text_sink_class.MaxHeight == XtInheritMaxHeight)
+ t_src->text_sink_class.MaxHeight =
+ superC->text_sink_class.MaxHeight;
+
+ if (t_src->text_sink_class.SetTabs == XtInheritSetTabs)
+ t_src->text_sink_class.SetTabs =
+ superC->text_sink_class.SetTabs;
+
+ if (t_src->text_sink_class.GetCursorBounds == XtInheritGetCursorBounds)
+ t_src->text_sink_class.GetCursorBounds =
+ superC->text_sink_class.GetCursorBounds;
+
+#ifndef OLDXAW
+ XtSetTypeConverter(XtRString, XawRTextProperties, CvtStringToPropertyList,
+ &CvtArgs[0], XtNumber(CvtArgs), XtCacheNone, NULL);
+ XtSetTypeConverter(XawRTextProperties, XtRString, CvtPropertyListToString,
+ NULL, 0, XtCacheNone, NULL);
+#endif
+}
+
+/*
+ * Function:
+ * XawTextSinkInitialize
+ *
+ * Parameters:
+ * request - requested and new values for the object instance
+ * cnew - ""
+ *
+ * Description:
+ * Initializes the TextSink Object.
+ */
+/*ARGSUSED*/
+static void
+XawTextSinkInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ TextSinkObject sink = (TextSinkObject)cnew;
+
+ sink->text_sink.tab_count = 0; /* Initialize the tab stops. */
+ sink->text_sink.tabs = NULL;
+ sink->text_sink.char_tabs = NULL;
+#ifndef OLDXAW
+ sink->text_sink.paint = NULL;
+#endif
+}
+
+/*
+ * Function:
+ * XawTextSinkDestroy
+ *
+ * Parameters:
+ * w - TextSink Object
+ *
+ * Description:
+ * This function cleans up when the object is destroyed.
+ */
+static void
+XawTextSinkDestroy(Widget w)
+{
+ TextSinkObject sink = (TextSinkObject) w;
+
+ XtFree((char *)sink->text_sink.tabs);
+ XtFree((char *)sink->text_sink.char_tabs);
+}
+
+/*
+ * Function:
+ * XawTextSinkSetValues
+ *
+ * Parameters:
+ * current - current state of the object
+ * request - what was requested
+ * cnew - what the object will become
+ *
+ * Description:
+ * Sets the values for the TextSink.
+ *
+ * Returns:
+ * True if redisplay is needed
+ */
+/*ARGSUSED*/
+static Boolean
+XawTextSinkSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ TextSinkObject w = (TextSinkObject)cnew;
+ TextSinkObject old_w = (TextSinkObject)current;
+
+ if (w->text_sink.foreground != old_w->text_sink.foreground)
+ ((TextWidget)XtParent(cnew))->text.redisplay_needed = True;
+
+ return (False);
+}
+
+/*
+ * Function:
+ * DisplayText
+ *
+ * Parameters:
+ * w - TextSink Object
+ * x - location to start drawing text
+ * y - ""
+ * pos1 - location of starting and ending points in the text buffer
+ * pos2 - ""
+ * highlight - hightlight this text?
+ *
+ * Description:
+ * Stub function that in subclasses will display text.
+ */
+/*ARGSUSED*/
+static void
+DisplayText(Widget w, int x, int y,
+ XawTextPosition pos1, XawTextPosition pos2, Bool highlight)
+{
+ return;
+}
+
+/*
+ * Function:
+ * InsertCursor
+ *
+ * Parameters:
+ * w - TextSink Object
+ * x - location for the cursor
+ * y - ""
+ * state - whether to turn the cursor on, or off
+ *
+ * Description:
+ * Places the InsertCursor.
+ */
+/*ARGSUSED*/
+static void
+InsertCursor(Widget w, int x, int y, XawTextInsertState state)
+{
+ return;
+}
+
+/*
+ * Function:
+ * ClearToBackground
+ *
+ * Parameters:
+ * w - TextSink Object
+ * x - location of area to clear
+ * y - ""
+ * width - size of area to clear
+ * height - ""
+ *
+ * Description:
+ * Clears a region of the sink to the background color.
+ */
+/*ARGSUSED*/
+static void
+ClearToBackground(Widget w, int x, int y,
+ unsigned int width, unsigned int height)
+{
+ /*
+ * Don't clear in height or width are zero
+ * XClearArea() has special semantic for these values
+ */
+ TextWidget xaw = (TextWidget)XtParent(w);
+ Position x1, y1, x2, y2;
+
+ x1 = XawMax(x, xaw->text.r_margin.left);
+ y1 = XawMax(y, xaw->text.r_margin.top);
+ x2 = XawMin(x + (int)width, (int)XtWidth(xaw) - xaw->text.r_margin.right);
+ y2 = XawMin(y + (int)height, (int)XtHeight(xaw) - xaw->text.r_margin.bottom);
+
+ x = x1;
+ y = y1;
+ width = XawMax(0, x2 - x1);
+ height = XawMax(0, y2 - y1);
+
+ if (height != 0 && width != 0)
+ XClearArea(XtDisplayOfObject(w), XtWindowOfObject(w),
+ x, y, width, height, False);
+}
+
+/*
+ * Function:
+ * FindPosition
+ *
+ * Parameters:
+ * w - TextSink Object
+ * fromPos - reference position
+ * fromX - reference location
+ * width - width of section to paint text
+ * stopAtWordBreak - returned position is a word break?
+ * resPos - position found (return)
+ * resWidth - Width actually used (return)
+ * resHeight - Height actually used (return)
+ *
+ * Description:
+ * Finds a position in the text.
+ */
+/*ARGSUSED*/
+static void
+FindPosition(Widget w, XawTextPosition fromPos, int fromx, int width,
+ Bool stopAtWordBreak, XawTextPosition *resPos,
+ int *resWidth, int *resHeight)
+{
+ *resPos = fromPos;
+ *resHeight = *resWidth = 0;
+}
+
+/*
+ * Function:
+ * FindDistance
+ *
+ * Parameters:
+ * w - TextSink Object
+ * fromPos - starting Position
+ * fromX - x location of starting Position
+ * toPos - end Position
+ * resWidth - Distance between fromPos and toPos
+ * resPos - Acutal toPos used
+ * resHeight - Height required by this text
+ *
+ * Description:
+ * Find the Pixel Distance between two text Positions.
+ */
+/*ARGSUSED*/
+static void
+FindDistance(Widget w, XawTextPosition fromPos, int fromx,
+ XawTextPosition toPos, int *resWidth,
+ XawTextPosition *resPos, int *resHeight)
+{
+ *resWidth = *resHeight = 0;
+ *resPos = fromPos;
+}
+
+/*
+ * Function:
+ * Resolve
+ *
+ * Parameters:
+ * w - TextSink Object
+ * pos - reference Position
+ * fromx - reference Location
+ * width - width to move
+ * resPos - resulting position
+ *
+ * Description:
+ * Resloves a location to a position.
+ */
+/*ARGSUSED*/
+static void
+Resolve(Widget w, XawTextPosition pos, int fromx, int width,
+ XawTextPosition *resPos)
+{
+ *resPos = pos;
+}
+
+/*
+ * Function:
+ * MaxLines
+ *
+ * Parameters:
+ * w - TextSink Object
+ * height - height to fit lines into
+ *
+ * Description:
+ * Finds the Maximum number of lines that will fit in a given height.
+ *
+ * Returns:
+ * Number of lines that will fit
+ */
+/*ARGSUSED*/
+static int
+MaxLines(Widget w, unsigned int height)
+{
+ /*
+ * The fontset has gone down to descent Sink Widget, so
+ * the functions such MaxLines, SetTabs... are bound to the descent.
+ *
+ * by Li Yuhong, Jan. 15, 1991
+ */
+ return (0);
+}
+
+/*
+ * Function:
+ * MaxHeight
+ *
+ * Parameters:
+ * w - TextSink Object
+ * lines - number of lines
+ *
+ * Description:
+ * Finds the Minium height that will contain a given number lines.
+ *
+ * Returns:
+ * the height
+ */
+/*ARGSUSED*/
+static int
+MaxHeight(Widget w, int lines)
+{
+ return (0);
+}
+
+/*
+ * Function:
+ * SetTabs
+ *
+ * Parameters:
+ * w - TextSink Object
+ * tab_count - the number of tabs in the list
+ * tabs - text positions of the tabs
+ * Description:
+ * Sets the Tab stops.
+ */
+/*ARGSUSED*/
+static void
+SetTabs(Widget w, int tab_count, short *tabs)
+{
+ return;
+}
+
+/*
+ * Function:
+ * GetCursorBounds
+ *
+ * Parameters:
+ * w - TextSinkObject.
+ * rect - X rectangle containing the cursor bounds
+ *
+ * Description:
+ * Finds the bounding box for the insert cursor (caret)
+ */
+/*ARGSUSED*/
+static void
+GetCursorBounds(Widget w, XRectangle *rect)
+{
+ rect->x = rect->y = rect->width = rect->height = 0;
+}
+
+/*
+ * Public Functions
+ */
+/*
+ * Function:
+ * XawTextSinkDisplayText
+ *
+ * Parameters:
+ * w - TextSink Object
+ * x - location to start drawing text
+ * y - ""
+ * pos1 - location of starting and ending points in the text buffer
+ * pos2 - ""
+ * highlight - hightlight this text?
+ */
+/*ARGSUSED*/
+void
+XawTextSinkDisplayText(Widget w,
+#if NeedWidePrototypes
+ int x, int y,
+#else
+ Position x, Position y,
+#endif
+ XawTextPosition pos1, XawTextPosition pos2,
+#if NeedWidePrototypes
+ int highlight
+#else
+ Boolean highlight
+#endif
+)
+{
+ _XawTextSinkDisplayText(w, x, y, pos1, pos2, highlight);
+}
+
+void
+_XawTextSinkDisplayText(Widget w, int x, int y,
+ XawTextPosition pos1, XawTextPosition pos2,
+ Bool highlight)
+{
+ TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class;
+
+ (*cclass->text_sink_class.DisplayText)(w, x, y, pos1, pos2, highlight);
+}
+
+/*
+ * Function:
+ * XawTextSinkInsertCursor
+ *
+ * Parameters:
+ * w - TextSink Object
+ * x - location for the cursor
+ * y - ""
+ * state - whether to turn the cursor on, or off
+ *
+ * Description:
+ * Places the InsertCursor.
+ */
+/*ARGSUSED*/
+void
+#if NeedWidePrototypes
+XawTextSinkInsertCursor(Widget w, int x, int y, int state)
+#else
+XawTextSinkInsertCursor(Widget w, Position x, Position y, XawTextInsertState state)
+#endif
+{
+ TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class;
+
+ (*cclass->text_sink_class.InsertCursor)(w, x, y, state);
+}
+
+/*
+ * Function:
+ * XawTextSinkClearToBackground
+ *
+ * Parameters:
+ * w - TextSink Object
+ * x - location of area to clear
+ * y - ""
+ * width - size of area to clear
+ * height - ""
+ *
+ * Description:
+ * Clears a region of the sink to the background color.
+ */
+/*ARGSUSED*/
+void
+XawTextSinkClearToBackground(Widget w,
+#if NeedWidePrototypes
+ int x, int y,
+ unsigned int width, unsigned int height
+#else
+ Position x, Position y,
+ Dimension width, Dimension height
+#endif
+)
+{
+ _XawTextSinkClearToBackground(w, x, y, width, height);
+}
+
+void
+_XawTextSinkClearToBackground(Widget w,
+ int x, int y,
+ unsigned int width, unsigned int height)
+{
+ TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class;
+
+ (*cclass->text_sink_class.ClearToBackground)(w, x, y, width, height);
+}
+
+/*
+ * Function:
+ * XawTextSinkFindPosition
+ *
+ * Parameters:
+ * w - TextSink Object
+ * fromPos - reference position
+ * fromX - reference location
+ * width - width of section to paint text
+ * stopAtWordBreak - returned position is a word break?
+ * resPos - position found (return)
+ * resWidth - Width actually used (return)
+ * resHeight - Height actually used (return)
+ *
+ * Description:
+ * Finds a position in the text.
+ */
+/*ARGSUSED*/
+void
+XawTextSinkFindPosition(Widget w, XawTextPosition fromPos, int fromx, int width,
+#if NeedWidePrototypes
+ int stopAtWordBreak,
+#else
+ Boolean stopAtWordBreak,
+#endif
+ XawTextPosition *resPos, int *resWidth, int *resHeight)
+{
+ TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class;
+
+ (*cclass->text_sink_class.FindPosition)(w, fromPos, fromx, width,
+ stopAtWordBreak,
+ resPos, resWidth, resHeight);
+}
+
+/*
+ * Function:
+ * XawTextSinkFindDistance
+ *
+ * Parameters:
+ * w - TextSink Object
+ * fromPos - starting Position
+ * fromX - x location of starting Position
+ * toPos - end Position
+ * resWidth - Distance between fromPos and toPos
+ * resPos - Acutal toPos used
+ * resHeight - Height required by this text
+ *
+ * Description:
+ * Find the Pixel Distance between two text Positions.
+ */
+/*ARGSUSED*/
+void
+XawTextSinkFindDistance(Widget w, XawTextPosition fromPos, int fromx,
+ XawTextPosition toPos, int *resWidth,
+ XawTextPosition *resPos, int *resHeight)
+{
+ TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class;
+
+ (*cclass->text_sink_class.FindDistance)(w, fromPos, fromx, toPos,
+ resWidth, resPos, resHeight);
+}
+
+/*
+ * Function:
+ * XawTextSinkResolve
+ *
+ * Parameters:
+ * w - TextSink Object
+ * pos - reference Position
+ * fromx - reference Location
+ * width - width to move
+ * resPos - resulting position
+ *
+ * Description:
+ * Resloves a location to a position.
+ */
+/*ARGSUSED*/
+void
+XawTextSinkResolve(Widget w, XawTextPosition pos, int fromx, int width,
+ XawTextPosition *resPos)
+{
+ TextSinkObjectClass cclass = (TextSinkObjectClass) w->core.widget_class;
+
+ (*cclass->text_sink_class.Resolve)(w, pos, fromx, width, resPos);
+}
+
+/*
+ * Function:
+ * XawTextSinkMaxLines
+ *
+ * Parameters:
+ * w - TextSink Object
+ * height - height to fit lines into
+ *
+ * Description:
+ * Finds the Maximum number of lines that will fit in a given height.
+ *
+ * Returns:
+ * Number of lines that will fit
+ */
+/*ARGSUSED*/
+int
+#if NeedWidePrototypes
+XawTextSinkMaxLines(Widget w, unsigned int height)
+#else
+XawTextSinkMaxLines(Widget w, Dimension height)
+#endif
+{
+ TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class;
+
+ return((*cclass->text_sink_class.MaxLines)(w, height));
+}
+
+/*
+ * Function:
+ * XawTextSinkMaxHeight
+ *
+ * Parameters:
+ * w - TextSink Object
+ * lines - number of lines
+ *
+ * Description:
+ * Finds the Minium height that will contain a given number lines.
+ *
+ * Returns:
+ * the height
+ */
+/*ARGSUSED*/
+int
+XawTextSinkMaxHeight(Widget w, int lines)
+{
+ TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class;
+
+ return((*cclass->text_sink_class.MaxHeight)(w, lines));
+}
+
+/*
+ * Function:
+ * XawTextSinkSetTabs
+ *
+ * Parameters:
+ * w - TextSink Object
+ * tab_count - the number of tabs in the list
+ * tabs - text positions of the tabs
+ * Description:
+ * Sets the Tab stops.
+ */
+void
+XawTextSinkSetTabs(Widget w, int tab_count, int *tabs)
+{
+ if (tab_count > 0) {
+ TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class;
+ short *char_tabs = (short*)XtMalloc((unsigned)tab_count * sizeof(short));
+ short *tab, len = 0;
+ int i;
+
+ for (i = tab_count, tab = char_tabs; i; i--) {
+ if ((short)*tabs > len)
+ *tab++ = (len = (short)*tabs++);
+ else {
+ tabs++;
+ --tab_count;
+ }
+ }
+
+ if (tab_count > 0)
+ (*cclass->text_sink_class.SetTabs)(w, tab_count, char_tabs);
+ XtFree((char *)char_tabs);
+ }
+}
+
+/*
+ * Function:
+ * XawTextSinkGetCursorBounds
+ *
+ * Parameters:
+ * w - TextSinkObject
+ * rect - X rectance containing the cursor bounds
+ *
+ * Description:
+ * Finds the bounding box for the insert cursor (caret).
+ */
+/*ARGSUSED*/
+void
+XawTextSinkGetCursorBounds(Widget w, XRectangle *rect)
+{
+ TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class;
+
+ (*cclass->text_sink_class.GetCursorBounds)(w, rect);
+}
+
+#ifndef OLDXAW
+Bool
+XawTextSinkBeginPaint(Widget w)
+{
+ TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class;
+
+ if (cclass->text_sink_class.extension->BeginPaint == NULL ||
+ cclass->text_sink_class.extension->PreparePaint == NULL ||
+ cclass->text_sink_class.extension->DoPaint == NULL ||
+ cclass->text_sink_class.extension->EndPaint == NULL)
+ return (False);
+
+ return ((*cclass->text_sink_class.extension->BeginPaint)(w));
+}
+
+static Bool
+BeginPaint(Widget w)
+{
+ TextSinkObject sink = (TextSinkObject)w;
+
+ if (sink->text_sink.paint != NULL)
+ return (False);
+
+ sink->text_sink.paint = XtNew(XawTextPaintList);
+ sink->text_sink.paint->clip = XmuCreateArea();
+ sink->text_sink.paint->hightabs = NULL;
+ sink->text_sink.paint->paint = NULL;
+ sink->text_sink.paint->bearings = NULL;
+
+ return (True);
+}
+
+void
+XawTextSinkPreparePaint(Widget w, int y, int line, XawTextPosition from,
+ XawTextPosition to, Bool highlight)
+{
+ TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class;
+
+ (*cclass->text_sink_class.extension->PreparePaint)
+ (w, y, line, from, to, highlight);
+}
+
+#if 0
+/*ARGSUSED*/
+static void
+PreparePaint(Widget w, int y, int line, XawTextPosition from, XawTextPosition to,
+ Bool highlight)
+{
+}
+#endif
+
+void
+XawTextSinkDoPaint(Widget w)
+{
+ TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class;
+
+ (*cclass->text_sink_class.extension->DoPaint)(w);
+}
+
+#if 0
+/*ARGSUSED*/
+static void
+DoPaint(Widget w)
+{
+}
+#endif
+
+Bool
+XawTextSinkEndPaint(Widget w)
+{
+ TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class;
+
+ return ((*cclass->text_sink_class.extension->EndPaint)(w));
+}
+
+static Bool
+EndPaint(Widget w)
+{
+ TextSinkObject sink = (TextSinkObject)w;
+ XawTextPaintStruct *paint, *next;
+
+ if (sink->text_sink.paint == NULL)
+ return (False);
+
+ XmuDestroyArea(sink->text_sink.paint->clip);
+ if (sink->text_sink.paint->hightabs)
+ XmuDestroyArea(sink->text_sink.paint->hightabs);
+ paint = sink->text_sink.paint->paint;
+ while (paint) {
+ next = paint->next;
+ if (paint->text)
+ XtFree((XtPointer)paint->text);
+ if (paint->backtabs)
+ XmuDestroyArea(paint->backtabs);
+ XtFree((XtPointer)paint);
+ paint = next;
+ }
+
+ paint = sink->text_sink.paint->bearings;
+ while (paint) {
+ next = paint->next;
+ if (paint->text)
+ XtFree((XtPointer)paint->text);
+ XtFree((XtPointer)paint);
+ paint = next;
+ }
+
+ XtFree((XtPointer)sink->text_sink.paint);
+ sink->text_sink.paint = NULL;
+ return (True);
+}
+
+static XawTextPropertyList **prop_lists;
+static Cardinal num_prop_lists;
+
+static int
+bcmp_qident(_Xconst void *left, _Xconst void *right)
+{
+ return ((long)left - (*(XawTextProperty**)right)->identifier);
+}
+
+static int
+qcmp_qident(_Xconst void *left, _Xconst void *right)
+{
+ return ((*(XawTextProperty**)left)->identifier -
+ (*(XawTextProperty**)right)->identifier);
+}
+
+static void
+SetXlfdDefaults(Display *display, XawTextProperty *property)
+{
+ Atom atom = XInternAtom(display, "FONT", True);
+ unsigned long value;
+ char *str;
+
+ if (XGetFontProperty(property->font, atom, &value)) {
+ char *xlfd = XGetAtomName(display, value);
+
+ if (xlfd) {
+ char *sep = xlfd + 1;
+ char *name = sep;
+
+ property->xlfd = XrmStringToQuark(xlfd);
+
+ sep = strchr(sep, '-'); *sep++ = '\0';
+ property->foundry = XrmStringToQuark(name);
+ name = sep;
+
+ sep = strchr(sep, '-'); *sep++ = '\0';
+ property->family = XrmStringToQuark(name);
+ name = sep;
+
+ sep = strchr(sep, '-'); *sep++ = '\0';
+ property->weight = XrmStringToQuark(name);
+ name = sep;
+
+ sep = strchr(sep, '-'); *sep++ = '\0';
+ property->slant = XrmStringToQuark(name);
+ name = sep;
+
+ sep = strchr(sep, '-'); *sep++ = '\0';
+ property->setwidth = XrmStringToQuark(name);
+ name = sep;
+
+ sep = strchr(sep, '-'); *sep++ = '\0';
+ property->addstyle = XrmStringToQuark(name);
+ name = sep;
+
+ sep = strchr(sep, '-'); *sep++ = '\0';
+ property->pixel_size = XrmStringToQuark(name);
+ name = sep;
+
+ sep = strchr(sep, '-'); *sep++ = '\0';
+ property->point_size = XrmStringToQuark(name);
+ name = sep;
+
+ sep = strchr(sep, '-'); *sep++ = '\0';
+ property->res_x = XrmStringToQuark(name);
+ name = sep;
+
+ sep = strchr(sep, '-'); *sep++ = '\0';
+ property->res_y = XrmStringToQuark(name);
+ name = sep;
+
+ sep = strchr(sep, '-'); *sep++ = '\0';
+ property->spacing = XrmStringToQuark(name);
+ name = sep;
+
+ sep = strchr(sep, '-'); *sep++ = '\0';
+ property->avgwidth = XrmStringToQuark(name);
+ name = sep;
+
+ sep = strchr(sep, '-'); *sep++ = '\0';
+ property->registry = XrmStringToQuark(name);
+ name = sep;
+
+ property->encoding = XrmStringToQuark(name);
+
+ XFree(xlfd);
+ }
+ }
+
+ atom = XInternAtom(display, "UNDERLINE_THICKNESS", True);
+ if (XGetFontProperty(property->font, atom, &value) &&
+ (str = XGetAtomName(display, value)) != NULL) {
+ property->underline_thickness = atoi(str);
+ XFree(str);
+ }
+ else {
+ /* XLFD says:
+ * CapStemWidth = average width of the stems of capitals
+ * if (UNDERLINE_THICKNESS undefined) then
+ * UNDERLINE_THICKNESS = CapStemWidth
+ *
+ * How do I know the value of CapStemWidth??
+ */
+ if (property->pixel_size != NULLQUARK) {
+ property->underline_thickness =
+ atoi(XrmQuarkToString(property->pixel_size)) / 10;
+ property->underline_thickness =
+ XawMax(1, property->underline_thickness);
+ }
+ else
+ property->underline_thickness = 1;
+ }
+
+ atom = XInternAtom(display, "UNDERLINE_POSITION", True);
+ if (XGetFontProperty(property->font, atom, &value) &&
+ (str = XGetAtomName(display, value)) != NULL) {
+ property->underline_position = atoi(str);
+ XFree(str);
+ }
+ else
+ /* XLFD says:
+ * if (UNDERLINE_POSITION undefined) then
+ * UNDERLINE_POSITION = ROUND((maximum_descent) / 2)
+ */
+ property->underline_position =
+ property->font->max_bounds.descent >> 1;
+
+ /* I am assuming xlfd does not consider that lines are
+ * centered in the path */
+ property->underline_position += property->underline_thickness >> 1;
+
+}
+
+static void
+DestroyTextPropertyList(XawTextPropertyList *list)
+{
+ int i;
+
+ for (i = 0; i < list->num_properties; i++) {
+ if (list->properties[i]->font)
+ XFreeFont(DisplayOfScreen(list->screen), list->properties[i]->font);
+ XtFree((char*)list->properties[i]);
+ }
+ if (list->properties)
+ XtFree((char*)list->properties);
+ XtFree((char*)list);
+}
+
+static XawTextProperty *
+_XawTextSinkGetProperty(XawTextPropertyList *list, XrmQuark property)
+{
+ if (property != NULLQUARK && list && list->properties) {
+ XawTextProperty **ptr = (XawTextProperty**)
+ bsearch((void*)(long)property,
+ list->properties, list->num_properties,
+ sizeof(XawTextProperty*), bcmp_qident);
+
+ if (ptr)
+ return (*ptr);
+ }
+
+ return (NULL);
+}
+
+XawTextProperty *
+XawTextSinkGetProperty(Widget w, XrmQuark property)
+{
+ TextSinkObject sink = (TextSinkObject)w;
+ XawTextPropertyList *list = sink->text_sink.properties;
+
+ return (_XawTextSinkGetProperty(list, property));
+}
+
+XawTextProperty *
+XawTextSinkCopyProperty(Widget w, XrmQuark property)
+{
+ XawTextProperty *cur, *ret;
+
+ if ((cur = XawTextSinkGetProperty(w, property)) == NULL)
+ cur = XawTextSinkGetProperty(w, Qdefault);
+ ret = (XawTextProperty*)XtCalloc(1, sizeof(XawTextProperty));
+ if (cur)
+ memcpy(ret, cur, sizeof(XawTextProperty));
+ ret->identifier = NULLQUARK;
+ ret->mask &= ~XAW_TPROP_FONT;
+
+ return (ret);
+}
+
+static XawTextProperty *
+_XawTextSinkAddProperty(XawTextPropertyList *list, XawTextProperty *property,
+ Bool replace)
+{
+ XawTextProperty *result;
+ XColor color;
+ char identifier[1024];
+ char foreground[16];
+ char background[16];
+ char *foundry, *family, *weight, *slant, *setwidth, *addstyle, *pixel_size,
+ *point_size, *res_x, *res_y, *spacing, *avgwidth, *registry, *encoding;
+ char *xlfd;
+ static char *asterisk = "*", *null = "";
+ XrmQuark quark;
+
+ if (list == NULL || property == NULL)
+ return (NULL);
+
+ if (property->mask & XAW_TPROP_FOREGROUND) {
+ color.pixel = property->foreground;
+ XQueryColor(DisplayOfScreen(list->screen), list->colormap, &color);
+ XmuSnprintf(foreground, sizeof(foreground), "%04x%04x%04x",
+ color.red, color.green, color.blue);
+ }
+ else
+ strcpy(foreground, asterisk);
+ if (property->mask & XAW_TPROP_BACKGROUND) {
+ color.pixel = property->background;
+ XQueryColor(DisplayOfScreen(list->screen), list->colormap, &color);
+ XmuSnprintf(background, sizeof(background), "%04x%04x%04x",
+ color.red, color.green, color.blue);
+ }
+ else
+ strcpy(background, asterisk);
+
+ if (property->xlfd_mask & XAW_TPROP_FOUNDRY)
+ foundry = XrmQuarkToString(property->foundry);
+ else
+ foundry = asterisk;
+
+ /* use default, or what was requested */
+ if (property->family != NULLQUARK)
+ family = XrmQuarkToString(property->family);
+ else
+ family = asterisk;
+ if (property->weight != NULLQUARK)
+ weight = XrmQuarkToString(property->weight);
+ else
+ weight = asterisk;
+ if (property->slant != NULLQUARK) {
+ slant = XrmQuarkToString(property->slant);
+ if (toupper(*slant) != 'R')
+ slant = asterisk; /* X defaults to italics, so, don't
+ care in resolving between `I' and `O' */
+ }
+ else
+ slant = asterisk;
+
+ if (property->xlfd_mask & XAW_TPROP_SETWIDTH)
+ setwidth = XrmQuarkToString(property->setwidth);
+ else
+ setwidth = asterisk;
+ if (property->xlfd_mask & XAW_TPROP_ADDSTYLE)
+ addstyle = XrmQuarkToString(property->addstyle);
+ else
+ addstyle = null;
+
+ /* use default, or what was requested */
+ if (!(property->mask & XAW_TPROP_POINTSIZE) &&
+ property->pixel_size != NULLQUARK)
+ pixel_size = XrmQuarkToString(property->pixel_size);
+ else
+ pixel_size = asterisk;
+
+ if (property->xlfd_mask & XAW_TPROP_POINTSIZE)
+ point_size = XrmQuarkToString(property->point_size);
+ else
+ point_size = asterisk;
+ if (property->xlfd_mask & XAW_TPROP_RESX)
+ res_x = XrmQuarkToString(property->res_x);
+ else
+ res_x = asterisk;
+ if (property->xlfd_mask & XAW_TPROP_RESY)
+ res_y = XrmQuarkToString(property->res_y);
+ else
+ res_y = asterisk;
+ if (property->xlfd_mask & XAW_TPROP_SPACING)
+ spacing = XrmQuarkToString(property->spacing);
+ else
+ spacing = asterisk;
+ if (property->xlfd_mask & XAW_TPROP_AVGWIDTH)
+ avgwidth = XrmQuarkToString(property->avgwidth);
+ else
+ avgwidth = asterisk;
+
+ /* use default, or what that was requested */
+ if (property->registry != NULLQUARK)
+ registry = XrmQuarkToString(property->registry);
+ else
+ registry = asterisk;
+ if (property->encoding != NULLQUARK)
+ encoding = XrmQuarkToString(property->encoding);
+ else
+ encoding = asterisk;
+
+ if (replace) {
+ result = XtNew(XawTextProperty);
+ memcpy(result, property, sizeof(XawTextProperty));
+ }
+ else
+ result = property;
+
+ /* XXX should do the best to load a suitable font here */
+ if (!(result->mask & XAW_TPROP_FONT)) {
+ XmuSnprintf(identifier, sizeof(identifier),
+ "-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s",
+ foundry, family, weight, slant, setwidth, addstyle, pixel_size,
+ point_size, res_x, res_y, spacing, avgwidth, registry, encoding);
+ if ((result->font = XLoadQueryFont(DisplayOfScreen(list->screen),
+ identifier)) != NULL) {
+ result->mask |= XAW_TPROP_FONT;
+ SetXlfdDefaults(DisplayOfScreen(list->screen), result);
+ }
+ else
+ result->mask &= ~XAW_TPROP_FONT;
+ }
+
+ if (result->font)
+ xlfd = XrmQuarkToString(result->xlfd);
+ else
+ xlfd = null;
+
+ XmuSnprintf(identifier, sizeof(identifier), "%08lx%08lx%s%s%d%d%d%d%s",
+ property->mask, property->xlfd_mask,
+ foreground, background,
+ (result->mask & XAW_TPROP_UNDERLINE) != 0,
+ (result->mask & XAW_TPROP_OVERSTRIKE) != 0,
+ (result->mask & XAW_TPROP_SUBSCRIPT) != 0,
+ (result->mask & XAW_TPROP_SUPERSCRIPT) != 0,
+ xlfd);
+
+ quark = XrmStringToQuark(identifier);
+ if (result->identifier == NULLQUARK)
+ result->identifier = quark;
+ result->code = quark;
+
+ if ((property = _XawTextSinkGetProperty(list, result->identifier)) != NULL) {
+ if (result->font)
+ XFreeFont(DisplayOfScreen(list->screen), result->font);
+ if (replace)
+ XtFree((XtPointer)result);
+
+ return (property);
+ }
+
+ list->properties = (XawTextProperty**)
+ XtRealloc((XtPointer)list->properties, sizeof(XawTextProperty*) *
+ (list->num_properties + 1));
+ list->properties[list->num_properties++] = result;
+ qsort((void*)list->properties, list->num_properties,
+ sizeof(XawTextProperty*), qcmp_qident);
+
+ return (result);
+}
+
+XawTextProperty *
+XawTextSinkAddProperty(Widget w, XawTextProperty *property)
+{
+ TextSinkObject sink = (TextSinkObject)w;
+ XawTextPropertyList *list = sink->text_sink.properties;
+
+ return (_XawTextSinkAddProperty(list, property, True));
+}
+
+XawTextProperty *
+XawTextSinkCombineProperty(Widget w,
+ XawTextProperty *property, XawTextProperty *combine,
+ Bool override)
+{
+ if (property == NULL || combine == NULL)
+ return (property);
+
+ if ((override || !(property->mask & XAW_TPROP_FOREGROUND)) &&
+ (combine->mask & XAW_TPROP_FOREGROUND)) {
+ property->mask |= XAW_TPROP_FOREGROUND;
+ property->foreground = combine->foreground;
+ }
+ if ((override || !(property->mask & XAW_TPROP_BACKGROUND)) &&
+ (combine->mask & XAW_TPROP_BACKGROUND)) {
+ property->mask |= XAW_TPROP_BACKGROUND;
+ property->background = combine->background;
+ }
+ if ((override || !(property->mask & XAW_TPROP_FPIXMAP)) &&
+ (combine->mask & XAW_TPROP_FPIXMAP)) {
+ property->mask |= XAW_TPROP_FPIXMAP;
+ property->foreground_pixmap = combine->foreground_pixmap;
+ }
+ if ((override || !(property->mask & XAW_TPROP_BPIXMAP)) &&
+ (combine->mask & XAW_TPROP_BPIXMAP)) {
+ property->mask |= XAW_TPROP_BPIXMAP;
+ property->background_pixmap = combine->background_pixmap;
+ }
+ if (combine->mask & XAW_TPROP_UNDERLINE)
+ property->mask |= XAW_TPROP_UNDERLINE;
+ if (combine->mask & XAW_TPROP_OVERSTRIKE)
+ property->mask |= XAW_TPROP_OVERSTRIKE;
+ if ((override || !(property->mask & XAW_TPROP_SUPERSCRIPT)) &&
+ (combine->mask & XAW_TPROP_SUBSCRIPT))
+ property->mask |= XAW_TPROP_SUBSCRIPT;
+ if ((property->mask & XAW_TPROP_SUBSCRIPT) &&
+ (combine->mask & XAW_TPROP_SUPERSCRIPT))
+ property->mask |= XAW_TPROP_SUPERSCRIPT;
+ if ((override || !(property->xlfd_mask & XAW_TPROP_FOUNDRY)) &&
+ (combine->xlfd_mask & XAW_TPROP_FOUNDRY)) {
+ property->xlfd_mask |= XAW_TPROP_FOUNDRY;
+ property->foundry = combine->foundry;
+ }
+ if ((override || !(property->xlfd_mask & XAW_TPROP_FAMILY)) &&
+ (combine->xlfd_mask & XAW_TPROP_FAMILY)) {
+ property->xlfd_mask |= XAW_TPROP_FAMILY;
+ property->family = combine->family;
+ }
+ if ((override || !(property->xlfd_mask & XAW_TPROP_WEIGHT)) &&
+ (combine->xlfd_mask & XAW_TPROP_WEIGHT)) {
+ property->xlfd_mask |= XAW_TPROP_WEIGHT;
+ property->weight = combine->weight;
+ }
+ if ((override || !(property->xlfd_mask & XAW_TPROP_SLANT)) &&
+ (combine->xlfd_mask & XAW_TPROP_SLANT)) {
+ property->xlfd_mask |= XAW_TPROP_SLANT;
+ property->slant = combine->slant;
+ }
+ if ((override || !(property->xlfd_mask & XAW_TPROP_SETWIDTH)) &&
+ (combine->xlfd_mask & XAW_TPROP_SETWIDTH)) {
+ property->xlfd_mask |= XAW_TPROP_SETWIDTH;
+ property->setwidth = combine->setwidth;
+ }
+ if ((override || !(property->xlfd_mask & XAW_TPROP_ADDSTYLE)) &&
+ (combine->xlfd_mask & XAW_TPROP_ADDSTYLE)) {
+ property->xlfd_mask |= XAW_TPROP_ADDSTYLE;
+ property->addstyle = combine->addstyle;
+ }
+ if ((override || !(property->xlfd_mask & XAW_TPROP_PIXELSIZE)) &&
+ (combine->xlfd_mask & XAW_TPROP_PIXELSIZE)) {
+ property->xlfd_mask |= XAW_TPROP_PIXELSIZE;
+ property->pixel_size = combine->pixel_size;
+ }
+ if ((override || !(property->xlfd_mask & XAW_TPROP_POINTSIZE)) &&
+ (combine->xlfd_mask & XAW_TPROP_POINTSIZE)) {
+ property->xlfd_mask |= XAW_TPROP_POINTSIZE;
+ property->point_size = combine->point_size;
+ }
+ if ((override || !(property->xlfd_mask & XAW_TPROP_RESX)) &&
+ (combine->xlfd_mask & XAW_TPROP_RESX)) {
+ property->xlfd_mask |= XAW_TPROP_RESX;
+ property->res_x = combine->res_x;
+ }
+ if ((override || !(property->xlfd_mask & XAW_TPROP_RESY)) &&
+ (combine->xlfd_mask & XAW_TPROP_RESY)) {
+ property->xlfd_mask |= XAW_TPROP_RESY;
+ property->res_y = combine->res_y;
+ }
+ if ((override || !(property->xlfd_mask & XAW_TPROP_SPACING)) &&
+ (combine->xlfd_mask & XAW_TPROP_SPACING)) {
+ property->xlfd_mask |= XAW_TPROP_SPACING;
+ property->spacing = combine->spacing;
+ }
+ if ((override || !(property->xlfd_mask & XAW_TPROP_AVGWIDTH)) &&
+ (combine->xlfd_mask & XAW_TPROP_AVGWIDTH)) {
+ property->xlfd_mask |= XAW_TPROP_AVGWIDTH;
+ property->avgwidth = combine->avgwidth;
+ }
+ if ((override || !(property->xlfd_mask & XAW_TPROP_REGISTRY)) &&
+ (combine->xlfd_mask & XAW_TPROP_REGISTRY)) {
+ property->xlfd_mask |= XAW_TPROP_REGISTRY;
+ property->registry = combine->registry;
+ }
+ if ((override || !(property->xlfd_mask & XAW_TPROP_ENCODING)) &&
+ (combine->xlfd_mask & XAW_TPROP_ENCODING)) {
+ property->xlfd_mask |= XAW_TPROP_ENCODING;
+ property->encoding = combine->encoding;
+ }
+
+ return (property);
+}
+
+/*
+ * The default property must be defined first, if the code is willing to
+ * combine properties.
+ */
+XawTextPropertyList *
+XawTextSinkConvertPropertyList(String name, String spec, Screen *screen,
+ Colormap colormap, int depth)
+{
+ XrmQuark qname = XrmStringToQuark(name);
+ XawTextPropertyList **ptr = NULL;
+ XawTextPropertyList *propl, *prev = NULL;
+ XawTextProperty *def_prop = NULL;
+ String str, tok, tmp;
+ char buffer[BUFSIZ];
+
+ if (prop_lists) ptr = (XawTextPropertyList**)
+ bsearch((void*)(long)qname, prop_lists, num_prop_lists,
+ sizeof(XawTextPropertyList*), bcmp_qident);
+ if (ptr) {
+ propl = *ptr;
+ while (propl) {
+ prev = propl;
+ if (propl->screen == screen &&
+ propl->colormap == colormap &&
+ propl->depth == depth)
+ return (propl);
+ propl = propl->next;
+ }
+ }
+
+ propl = XtNew(XawTextPropertyList);
+ propl->identifier = qname;
+ propl->screen = screen;
+ propl->colormap = colormap;
+ propl->depth = depth;
+ propl->next = NULL;
+
+ if (prev)
+ prev->next = propl;
+
+ propl->properties = NULL;
+ propl->num_properties = 0;
+
+ str = XtNewString(spec);
+ for (tok = str; tok; tok = tmp) {
+ XawTextProperty *prop;
+ XawParams *params;
+ XrmQuark ident;
+ XawArgVal *argval;
+ XColor color, exact;
+
+ if (def_prop == NULL && propl->num_properties)
+ def_prop = _XawTextSinkGetProperty(propl, Qdefault);
+ tmp = strchr(tok, ',');
+ if (tmp) {
+ *tmp = '\0';
+ if (*++tmp == '\0')
+ tmp = NULL;
+ }
+ params = XawParseParamsString(tok);
+ ident = XrmStringToQuark(params->name);
+ if (ident == NULLQUARK) {
+ XmuSnprintf(buffer, sizeof(buffer),
+ "Bad text property name \"%s\".", params->name);
+ XtAppWarning(XtDisplayToApplicationContext
+ (DisplayOfScreen(screen)), buffer);
+ DestroyTextPropertyList(propl);
+ if (prev)
+ prev->next = NULL;
+ XawFreeParamsStruct(params);
+ return (NULL);
+ }
+ else if (_XawTextSinkGetProperty(propl, ident) != NULL) {
+ XawFreeParamsStruct(params);
+ continue;
+ }
+
+ prop = (XawTextProperty*)XtCalloc(1, sizeof(XawTextProperty));
+ prop->identifier = ident;
+
+ if ((argval = XawFindArgVal(params, "font")) != NULL &&
+ argval->value) {
+
+ if ((prop->font = XLoadQueryFont(DisplayOfScreen(screen),
+ argval->value)) == NULL) {
+ XmuSnprintf(buffer, sizeof(buffer),
+ "Cannot load font \"%s\".", argval->value);
+ XtAppWarning(XtDisplayToApplicationContext
+ (DisplayOfScreen(screen)), buffer);
+ DestroyTextPropertyList(propl);
+ if (prev)
+ prev->next = NULL;
+ XawFreeParamsStruct(params);
+ return (NULL);
+ }
+ prop->mask |= XAW_TPROP_FONT;
+ SetXlfdDefaults(DisplayOfScreen(screen), prop);
+ }
+ /* fontset processing here */
+
+ if ((argval = XawFindArgVal(params, "foreground")) != NULL &&
+ argval->value) {
+ if (!XAllocNamedColor(DisplayOfScreen(screen), colormap,
+ argval->value, &color, &exact)) {
+ XmuSnprintf(buffer, sizeof(buffer),
+ "Cannot allocate color \"%s\".", argval->value);
+ XtAppWarning(XtDisplayToApplicationContext
+ (DisplayOfScreen(screen)), buffer);
+ DestroyTextPropertyList(propl);
+ if (prev)
+ prev->next = NULL;
+ XawFreeParamsStruct(params);
+ return (NULL);
+ }
+ prop->foreground = color.pixel;
+ prop->mask |= XAW_TPROP_FOREGROUND;
+ }
+ if ((argval = XawFindArgVal(params, "background")) != NULL &&
+ argval->value) {
+ if (!XAllocNamedColor(DisplayOfScreen(screen), colormap,
+ argval->value, &color, &exact)) {
+ XmuSnprintf(buffer, sizeof(buffer),
+ "Cannot allocate color \"%s\".", argval->value);
+ XtAppWarning(XtDisplayToApplicationContext
+ (DisplayOfScreen(screen)), buffer);
+ DestroyTextPropertyList(propl);
+ if (prev)
+ prev->next = NULL;
+ XawFreeParamsStruct(params);
+ return (NULL);
+ }
+ prop->background = color.pixel;
+ prop->mask |= XAW_TPROP_BACKGROUND;
+ }
+ /* foreground_pixmap and background_pixmap processing here */
+
+ if (XawFindArgVal(params, "underline"))
+ prop->mask |= XAW_TPROP_UNDERLINE;
+ if (XawFindArgVal(params, "overstrike"))
+ prop->mask |= XAW_TPROP_OVERSTRIKE;
+
+ if (XawFindArgVal(params, "subscript"))
+ prop->mask |= XAW_TPROP_SUBSCRIPT;
+ else if (XawFindArgVal(params, "superscript"))
+ prop->mask |= XAW_TPROP_SUPERSCRIPT;
+
+ /* xlfd */
+ if ((argval = XawFindArgVal(params, "foundry")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_FOUNDRY;
+ prop->foundry = XrmStringToQuark(argval->value);
+ }
+ if ((argval = XawFindArgVal(params, "family")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_FAMILY;
+ prop->family = XrmStringToQuark(argval->value);
+ }
+ if ((argval = XawFindArgVal(params, "weight")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_WEIGHT;
+ prop->weight = XrmStringToQuark(argval->value);
+ }
+ if ((argval = XawFindArgVal(params, "slant")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_SLANT;
+ prop->slant = XrmStringToQuark(argval->value);
+ }
+ if ((argval = XawFindArgVal(params, "setwidth")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_SETWIDTH;
+ prop->setwidth = XrmStringToQuark(argval->value);
+ }
+ if ((argval = XawFindArgVal(params, "addstyle")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_ADDSTYLE;
+ prop->addstyle = XrmStringToQuark(argval->value);
+ }
+ if ((argval = XawFindArgVal(params, "pixelsize")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_PIXELSIZE;
+ prop->pixel_size = XrmStringToQuark(argval->value);
+ }
+ if ((argval = XawFindArgVal(params, "pointsize")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_POINTSIZE;
+ prop->point_size = XrmStringToQuark(argval->value);
+ }
+ if ((argval = XawFindArgVal(params, "resx")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_RESX;
+ prop->res_x = XrmStringToQuark(argval->value);
+ }
+ if ((argval = XawFindArgVal(params, "resy")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_RESY;
+ prop->res_y = XrmStringToQuark(argval->value);
+ }
+ if ((argval = XawFindArgVal(params, "spacing")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_SPACING;
+ prop->spacing = XrmStringToQuark(argval->value);
+ }
+ if ((argval = XawFindArgVal(params, "avgwidth")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_AVGWIDTH;
+ prop->avgwidth = XrmStringToQuark(argval->value);
+ }
+ if ((argval = XawFindArgVal(params, "registry")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_REGISTRY;
+ prop->registry = XrmStringToQuark(argval->value);
+ }
+ if ((argval = XawFindArgVal(params, "encoding")) != NULL &&
+ argval->value) {
+ prop->xlfd_mask |= XAW_TPROP_ENCODING;
+ prop->encoding = XrmStringToQuark(argval->value);
+ }
+
+ if (def_prop)
+ (void)XawTextSinkCombineProperty(NULL, prop, def_prop, False);
+ (void)_XawTextSinkAddProperty(propl, prop, False);
+
+ XawFreeParamsStruct(params);
+ }
+
+ prop_lists = (XawTextPropertyList**)
+ XtRealloc((XtPointer)prop_lists, sizeof(XawTextPropertyList*) *
+ (num_prop_lists + 1));
+ prop_lists[num_prop_lists++] = propl;
+ qsort((void*)prop_lists, num_prop_lists, sizeof(XawTextPropertyList*),
+ qcmp_qident);
+
+ XtFree(str);
+
+ return (propl);
+}
+
+/*ARGSUSED*/
+static Boolean
+CvtStringToPropertyList(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ XawTextPropertyList *propl = NULL;
+ String name;
+ Widget w;
+
+ if (*num_args != 1) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "wrongParameters", "cvtStringToTextProperties",
+ "ToolkitError",
+ "String to textProperties conversion needs widget argument",
+ NULL, NULL);
+ return (False);
+ }
+
+ w = *(Widget*)args[0].addr;
+ while (w && !XtIsWidget(w))
+ w = XtParent(w);
+
+ name = (String)(fromVal[0].addr);
+
+ if (w) {
+ XawTextPropertyList **ptr = NULL;
+ if (prop_lists) ptr = (XawTextPropertyList**)
+ bsearch((void*)(long)XrmStringToQuark(name),
+ prop_lists, num_prop_lists,
+ sizeof(XawTextPropertyList*), bcmp_qident);
+
+ if (ptr) {
+ Screen *screen = w->core.screen;
+ Colormap colormap = w->core.colormap;
+ int depth = w->core.depth;
+
+ propl = *ptr;
+ while (propl) {
+ if (propl->screen == screen &&
+ propl->colormap == colormap &&
+ propl->depth == depth)
+ break;
+ propl = propl->next;
+ }
+ }
+ }
+
+ if (!propl) {
+ XtDisplayStringConversionWarning(dpy, (String)fromVal->addr,
+ XawRTextProperties);
+ toVal->addr = NULL;
+ toVal->size = sizeof(XawTextPropertyList*);
+ return (False);
+ }
+
+ if (toVal->addr != NULL) {
+ if (toVal->size < sizeof(XawTextPropertyList*)) {
+ toVal->size = sizeof(XawTextPropertyList*);
+ return (False);
+ }
+ *(XawTextPropertyList**)(toVal->addr) = propl;
+ }
+ else {
+ static XawTextPropertyList *static_val;
+
+ static_val = propl;
+ toVal->addr = (XPointer)&static_val;
+ }
+ toVal->size = sizeof(XawTextProperty*);
+
+ return (True);
+}
+
+/*ARGSUSED*/
+static Boolean
+CvtPropertyListToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static char *buffer;
+ Cardinal size;
+ XawTextPropertyList *propl;
+
+ propl = *(XawTextPropertyList**)fromVal[0].addr;
+
+ buffer = XrmQuarkToString(propl->identifier);
+ size = strlen(buffer) + 1;
+
+ if (toVal->addr != NULL) {
+ if (toVal->size < size) {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = buffer;
+ toVal->size = size;
+
+ return (True);
+}
+#endif
diff --git a/nx-X11/lib/Xaw/TextSink.h b/nx-X11/lib/Xaw/TextSink.h
new file mode 100644
index 000000000..291b9600d
--- /dev/null
+++ b/nx-X11/lib/Xaw/TextSink.h
@@ -0,0 +1,364 @@
+/*
+ * $Xorg: TextSink.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/TextSink.h,v 1.9 2001/01/17 19:42:35 dawes Exp $ */
+
+#ifndef _XawTextSink_h
+#define _XawTextSink_h
+
+#include <X11/Xaw/Text.h>
+
+/***********************************************************************
+ *
+ * TextSink Object
+ *
+ ***********************************************************************/
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ font Font XFontStruct * XtDefaultFont
+ foreground Foreground Pixel XtDefaultForeground
+ background Background Pixel XtDefaultBackground
+ cursorColor Color Pixel XtDefaultForeground
+*/
+
+/* Class record constants */
+
+extern WidgetClass textSinkObjectClass;
+
+typedef struct _TextSinkClassRec *TextSinkObjectClass;
+typedef struct _TextSinkRec *TextSinkObject;
+
+typedef enum {XawisOn, XawisOff} XawTextInsertState;
+
+#ifndef OLDXAW
+#ifndef XtNcursorColor
+#define XtNcursorColor "cursorColor"
+#endif
+
+#define XawNtextProperties "textProperties"
+#define XawCTextProperties "TextProperties"
+#define XawRTextProperties "XawTextProperties"
+#endif
+
+/*
+ * Public Functions
+ */
+_XFUNCPROTOBEGIN
+
+/*
+ * Function:
+ * XawTextSinkDisplayText
+ *
+ * Parameters:
+ * w - the TextSink Object
+ * x - location to start drawing text
+ * y - ""
+ * pos1 - location of starting and ending points in the text buffer
+ * pos2 - ""
+ * highlight - hightlight this text?
+ *
+ * Description:
+ * Stub function that in subclasses will display text.
+ *
+ * Note:
+ * This function doesn't actually display anything, it is only a place
+ * holder.
+ */
+void XawTextSinkDisplayText
+(
+ Widget w,
+#if NeedWidePrototypes
+ int x,
+ int y,
+#else
+ Position x,
+ Position y,
+#endif
+ XawTextPosition pos1,
+ XawTextPosition pos2,
+#if NeedWidePrototypes
+ int highlight
+#else
+ Boolean highlight
+#endif
+ );
+
+/*
+ * Function:
+ * XawTextSinkInsertCursor
+ *
+ * Parameters:
+ * w - the TextSink Object.
+ * x - location for the cursor.
+ * y - ""
+ * state - whether to turn the cursor on, or off
+ *
+ * Description:
+ * Places the InsertCursor.
+ *
+ * Note:
+ * This function doesn't actually display anything, it is only a place
+ * holder.
+ */
+void XawTextSinkInsertCursor
+(
+ Widget w,
+#if NeedWidePrototypes
+ int x,
+ int y,
+ int state
+#else
+ Position x,
+ Position y,
+ XawTextInsertState state
+#endif
+ );
+
+/*
+ * Function:
+ * XawTextSinkClearToBackground
+ *
+ * Parameters:
+ * w - TextSink Object
+ * x - location of area to clear
+ * y - ""
+ * width - size of area to clear
+ * height - ""
+ *
+ * Description:
+ * Clears a region of the sink to the background color.
+ *
+ * Note:
+ * This function doesn't actually display anything, it is only a place
+ * holder.
+ */
+void XawTextSinkClearToBackground
+(
+ Widget w,
+#if NeedWidePrototypes
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height
+#else
+ Position x,
+ Position y,
+ Dimension width,
+ Dimension height
+#endif
+ );
+
+/*
+ * Function:
+ * XawTextSinkFindPosition
+ *
+ * Parameters:
+ * w - TextSink Object
+ * fromPos - reference position
+ * fromX - reference location
+ * width - width of section to paint text
+ * stopAtWordBreak - returned position is a word break?
+ * resPos - Position to return
+ * resWidth - Width actually used
+ * resHeight - Height actually used
+ *
+ * Description:
+ * Finds a position in the text.
+ */
+void XawTextSinkFindPosition
+(
+ Widget w,
+ XawTextPosition fromPos,
+ int fromX,
+ int width,
+#if NeedWidePrototypes
+ int stopAtWordBreak,
+#else
+ Boolean stopAtWordBreak,
+#endif
+ XawTextPosition* pos_return,
+ int *width_return,
+ int *height_return
+ );
+
+/*
+ * Function:
+ * XawTextSinkFindDistance
+ *
+ * Parameters:
+ * w - TextSink Object
+ * fromPos - starting Position
+ * fromX - x location of starting Position
+ * toPos - end Position
+ * resWidth - Distance between fromPos and toPos
+ * resPos - Acutal toPos used
+ * resHeight - Height required by this text
+ *
+ * Description:
+ * Find the Pixel Distance between two text Positions.
+ */
+void XawTextSinkFindDistance
+(
+ Widget w,
+ XawTextPosition fromPos,
+ int fromX,
+ XawTextPosition toPos,
+ int *width_return,
+ XawTextPosition *pos_return,
+ int *height_return
+ );
+
+/*
+ * Function:
+ * XawTextSinkResolve
+ *
+ * Parameters:
+ * w - TextSink Object
+ * pos - reference Position
+ * fromx - reference Location
+ * width - width to move
+ * resPos - resulting position
+ *
+ * Description:
+ * Resloves a location to a position.
+ */
+void XawTextSinkResolve
+(
+ Widget w,
+ XawTextPosition fromPos,
+ int fromX,
+ int width,
+ XawTextPosition *pos_return
+ );
+
+/*
+ * Function:
+ * XawTextSinkMaxLines
+ *
+ * Parameters:
+ * w - TextSink Object
+ * height - height to fit lines into
+ *
+ * Returns:
+ * Number of lines that will fit
+ *
+ * Description:
+ * Finds the Maximum number of lines that will fit in a given height.
+ */
+int XawTextSinkMaxLines
+(
+ Widget w,
+#if NeedWidePrototypes
+ unsigned int height
+#else
+ Dimension height
+#endif
+ );
+
+/*
+ * Function:
+ * XawTextSinkMaxHeight
+ *
+ * Parameters:
+ * w - TextSink Object
+ * lines - number of lines
+ *
+ * Returns:
+ * Height
+ *
+ * Description:
+ * Finds the Minium height that will contain a given number lines.
+ */
+int XawTextSinkMaxHeight
+(
+ Widget w,
+ int lines
+);
+
+/*
+ * Function:
+ * XawTextSinkSetTabs
+ *
+ * Parameters:
+ * w - TextSink Object
+ * tab_count - number of tabs in the list
+ * tabs - text positions of the tabs
+ * Description:
+ * Sets the Tab stops.
+ */
+void XawTextSinkSetTabs
+(
+ Widget w,
+ int tab_count,
+ int *tabs
+);
+
+/*
+ * Function:
+ * XawTextSinkGetCursorBounds
+ *
+ * Parameters:
+ * w - TextSink Object
+ * rect - X rectance containing the cursor bounds
+ * Description:
+ * Finds the bounding box for the insert curor (caret).
+ */
+void XawTextSinkGetCursorBounds
+(
+ Widget w,
+ XRectangle *rect_return
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawTextSink_h */
diff --git a/nx-X11/lib/Xaw/TextSinkP.h b/nx-X11/lib/Xaw/TextSinkP.h
new file mode 100644
index 000000000..6cc873328
--- /dev/null
+++ b/nx-X11/lib/Xaw/TextSinkP.h
@@ -0,0 +1,306 @@
+/*
+* $Xorg: TextSinkP.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/TextSinkP.h,v 1.11 2001/01/17 19:42:35 dawes Exp $ */
+
+#ifndef _XawTextSinkP_h
+#define _XawTextSinkP_h
+
+/*
+ * TextSink Object Private Data
+ */
+#include <X11/Xaw/TextSink.h>
+#include <X11/Xaw/TextP.h> /* This sink works with the Text widget */
+#include <X11/Xaw/TextSrcP.h> /* This sink works with the Text Source */
+#include <X11/Xmu/Xmu.h>
+
+#ifndef OLDXAW
+/* font/fontset defined? */
+#define XAW_TPROP_FONT (1<<0)
+#define XAW_TPROP_FONTSET (1<<1)
+
+/* extra attributes */
+#define XAW_TPROP_FOREGROUND (1<<2)
+#define XAW_TPROP_BACKGROUND (1<<3)
+#define XAW_TPROP_FPIXMAP (1<<4)
+#define XAW_TPROP_BPIXMAP (1<<5)
+#define XAW_TPROP_UNDERLINE (1<<6)
+#define XAW_TPROP_OVERSTRIKE (1<<7)
+#define XAW_TPROP_SUBSCRIPT (1<<8)
+#define XAW_TPROP_SUPERSCRIPT (1<<9)
+
+/* xlfd attributes */
+#define XAW_TPROP_FOUNDRY (1<<0)
+#define XAW_TPROP_FAMILY (1<<1)
+#define XAW_TPROP_WEIGHT (1<<2)
+#define XAW_TPROP_SLANT (1<<3)
+#define XAW_TPROP_SETWIDTH (1<<4)
+#define XAW_TPROP_ADDSTYLE (1<<5)
+#define XAW_TPROP_PIXELSIZE (1<<6)
+#define XAW_TPROP_POINTSIZE (1<<7)
+#define XAW_TPROP_RESX (1<<8)
+#define XAW_TPROP_RESY (1<<9)
+#define XAW_TPROP_SPACING (1<<10)
+#define XAW_TPROP_AVGWIDTH (1<<11)
+#define XAW_TPROP_REGISTRY (1<<12)
+#define XAW_TPROP_ENCODING (1<<13)
+struct _XawTextProperty { /* to be extended/modified */
+ XrmQuark identifier, code;
+ unsigned long mask;
+ XFontStruct *font;
+ XFontSet fontset;
+ Pixel foreground, background;
+ Pixmap foreground_pixmap, background_pixmap;
+ XrmQuark xlfd;
+
+ unsigned long xlfd_mask;
+ XrmQuark foundry, family, weight, slant, setwidth, addstyle, pixel_size,
+ point_size, res_x, res_y, spacing, avgwidth, registry, encoding;
+
+ short underline_position, underline_thickness;
+};
+
+struct _XawTextPropertyList {
+ XrmQuark identifier;
+ Screen *screen;
+ Colormap colormap;
+ int depth;
+ XawTextProperty **properties;
+ Cardinal num_properties;
+ XawTextPropertyList *next;
+};
+
+typedef struct _XawTextPaintStruct XawTextPaintStruct;
+struct _XawTextPaintStruct {
+ XawTextPaintStruct *next;
+ int x, y, width;
+ char *text; /* formatted text */
+ Cardinal length; /* length of text */
+ XawTextProperty *property;
+ int max_ascent, max_descent;
+ XmuArea *backtabs;
+ Boolean highlight;
+};
+
+typedef struct {
+ XmuArea *clip, *hightabs; /* clip list */
+ XawTextPaintStruct *paint, *bearings; /* drawing information */
+} XawTextPaintList;
+
+typedef struct {
+ XtPointer next_extension;
+ XrmQuark record_type;
+ long version;
+ Cardinal record_size;
+ Bool (*BeginPaint)(Widget);
+ void (*PreparePaint)(Widget, int, int,
+ XawTextPosition, XawTextPosition, Bool);
+ void (*DoPaint)(Widget);
+ Bool (*EndPaint)(Widget);
+} TextSinkExtRec, *TextSinkExt;
+#endif
+
+typedef void (*_XawSinkDisplayTextProc)
+ (Widget, int, int, XawTextPosition, XawTextPosition, Bool);
+
+typedef void (*_XawSinkInsertCursorProc)
+ (Widget, int, int, XawTextInsertState);
+
+typedef void (*_XawSinkClearToBackgroundProc)
+ (Widget, int, int, unsigned int, unsigned int);
+
+typedef void (*_XawSinkFindPositionProc)
+ (Widget, XawTextPosition, int, int, Bool, XawTextPosition*, int*, int*);
+
+typedef void (*_XawSinkFindDistanceProc)
+ (Widget, XawTextPosition, int, XawTextPosition, int*,
+ XawTextPosition*, int*);
+
+typedef void (*_XawSinkResolveProc)
+ (Widget, XawTextPosition, int, int, XawTextPosition*);
+
+typedef int (*_XawSinkMaxLinesProc)
+ (Widget, unsigned int);
+
+typedef int (*_XawSinkMaxHeightProc)
+ (Widget, int);
+
+typedef void (*_XawSinkSetTabsProc)
+ (Widget, int, short*);
+
+typedef void (*_XawSinkGetCursorBoundsProc)
+ (Widget, XRectangle*);
+
+typedef struct _TextSinkClassPart {
+ _XawSinkDisplayTextProc DisplayText;
+ _XawSinkInsertCursorProc InsertCursor;
+ _XawSinkClearToBackgroundProc ClearToBackground;
+ _XawSinkFindPositionProc FindPosition;
+ _XawSinkFindDistanceProc FindDistance;
+ _XawSinkResolveProc Resolve;
+ _XawSinkMaxLinesProc MaxLines;
+ _XawSinkMaxHeightProc MaxHeight;
+ _XawSinkSetTabsProc SetTabs;
+ _XawSinkGetCursorBoundsProc GetCursorBounds;
+#ifndef OLDXAW
+ TextSinkExt extension;
+#endif
+} TextSinkClassPart;
+
+/* Full class record */
+typedef struct _TextSinkClassRec {
+ ObjectClassPart object_class;
+ TextSinkClassPart text_sink_class;
+} TextSinkClassRec;
+
+extern TextSinkClassRec textSinkClassRec;
+
+/* New fields for the TextSink object */
+typedef struct {
+ /* resources */
+ Pixel foreground; /* Foreground color */
+ Pixel background; /* Background color */
+
+ /* private */
+ Position *tabs; /* The tab stops as pixel values */
+ short *char_tabs; /* The tabs stops as character values */
+ int tab_count; /* number of items in tabs */
+
+#ifndef OLDXAW
+ /* more resources */
+ Pixel cursor_color;
+ XawTextPropertyList *properties;
+ XawTextPaintList *paint;
+ XtPointer pad[2]; /* for future use and keep binary compatability */
+#endif
+} TextSinkPart;
+
+/* Full instance record */
+typedef struct _TextSinkRec {
+ ObjectPart object;
+ TextSinkPart text_sink;
+} TextSinkRec;
+
+/* Semi private routines */
+#ifndef OLDXAW
+XawTextPropertyList *XawTextSinkConvertPropertyList
+(
+ String name,
+ String spec,
+ Screen *screen,
+ Colormap Colormap,
+ int depth
+ );
+
+XawTextProperty *XawTextSinkGetProperty
+(
+ Widget w,
+ XrmQuark property
+ );
+
+XawTextProperty *XawTextSinkCopyProperty
+(
+ Widget w,
+ XrmQuark property
+ );
+
+XawTextProperty *XawTextSinkAddProperty
+(
+ Widget w,
+ XawTextProperty *property
+ );
+
+XawTextProperty *XawTextSinkCombineProperty
+(
+ Widget w,
+ XawTextProperty *result_in_out,
+ XawTextProperty *property,
+ Bool override
+ );
+
+Bool XawTextSinkBeginPaint
+(
+ Widget w
+ );
+
+void XawTextSinkPreparePaint
+(
+ Widget w,
+ int y,
+ int line,
+ XawTextPosition from,
+ XawTextPosition to,
+ Bool highlight
+);
+
+void XawTextSinkDoPaint
+(
+ Widget w
+ );
+
+Bool XawTextSinkEndPaint
+(
+ Widget w
+ );
+#endif
+
+#define XtInheritDisplayText ((_XawSinkDisplayTextProc)_XtInherit)
+#define XtInheritInsertCursor ((_XawSinkInsertCursorProc)_XtInherit)
+#define XtInheritClearToBackground ((_XawSinkClearToBackgroundProc)_XtInherit)
+#define XtInheritFindPosition ((_XawSinkFindPositionProc)_XtInherit)
+#define XtInheritFindDistance ((_XawSinkFindDistanceProc)_XtInherit)
+#define XtInheritResolve ((_XawSinkResolveProc)_XtInherit)
+#define XtInheritMaxLines ((_XawSinkMaxLinesProc)_XtInherit)
+#define XtInheritMaxHeight ((_XawSinkMaxHeightProc)_XtInherit)
+#define XtInheritSetTabs ((_XawSinkSetTabsProc)_XtInherit)
+#define XtInheritGetCursorBounds ((_XawSinkGetCursorBoundsProc)_XtInherit)
+
+#endif /* _XawTextSinkP_h */
diff --git a/nx-X11/lib/Xaw/TextSrc.c b/nx-X11/lib/Xaw/TextSrc.c
new file mode 100644
index 000000000..0fd6bd36d
--- /dev/null
+++ b/nx-X11/lib/Xaw/TextSrc.c
@@ -0,0 +1,1981 @@
+/* $Xorg: TextSrc.c,v 1.5 2001/02/09 02:03:47 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* $XFree86: xc/lib/Xaw/TextSrc.c,v 1.33 2002/09/08 02:29:47 paulo Exp $ */
+
+/*
+ * Author: Chris Peterson, MIT X Consortium.
+ * Much code taken from X11R3 String and Disk Sources.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <ctype.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/Atoms.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xaw/TextSrcP.h>
+#include <X11/Xaw/XawInit.h>
+#include "XawI18n.h"
+#include "Private.h"
+
+#ifndef OLDXAW
+#define UNDO_DEPTH 16384
+
+#define ANCHORS_DIST 4096 /* default distance between anchors */
+
+/*
+ * Types
+ */
+typedef struct {
+ XawTextPosition position;
+ char *buffer;
+ unsigned length;
+ unsigned refcount;
+ unsigned long format;
+} XawTextUndoBuffer;
+
+typedef struct _XawTextUndoList XawTextUndoList;
+struct _XawTextUndoList {
+ XawTextUndoBuffer *left, *right;
+ XawTextUndoList *undo, *redo;
+};
+
+struct _XawTextUndo {
+ XawTextUndoBuffer **undo;
+ unsigned num_undo;
+ XawTextUndoList *list, *pointer, *end_mark, *head;
+ unsigned num_list;
+ XawTextScanDirection dir;
+ XawTextUndoBuffer *l_save, *r_save;
+ XawTextUndoList *u_save;
+ XawTextUndoBuffer *l_no_change, *r_no_change;
+ int merge;
+ int erase; /* there are two types of erases */
+};
+#endif /* OLDXAW */
+
+/*
+ * Class Methods
+ */
+static Boolean ConvertSelection(Widget, Atom*, Atom*, Atom*, XtPointer*,
+ unsigned long*, int*);
+static XawTextPosition Read(Widget, XawTextPosition, XawTextBlock*, int);
+static int Replace(Widget, XawTextPosition, XawTextPosition, XawTextBlock*);
+static XawTextPosition Scan(Widget, XawTextPosition, XawTextScanType,
+ XawTextScanDirection, int, Bool);
+static XawTextPosition Search(Widget, XawTextPosition, XawTextScanDirection,
+ XawTextBlock*);
+static void SetSelection(Widget, XawTextPosition, XawTextPosition, Atom);
+static void XawTextSrcClassInitialize(void);
+static void XawTextSrcClassPartInitialize(WidgetClass);
+static void XawTextSrcInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawTextSrcDestroy(Widget);
+static Boolean XawTextSrcSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
+/*
+ * Prototypes
+ */
+static void CvtStringToEditMode(XrmValuePtr, Cardinal*,
+ XrmValuePtr, XrmValuePtr);
+static Boolean CvtEditModeToString(Display*, XrmValuePtr, Cardinal*,
+ XrmValuePtr, XrmValuePtr, XtPointer*);
+#ifndef OLDXAW
+static void FreeUndoBuffer(XawTextUndo*);
+static void UndoGC(XawTextUndo*);
+static void TellSourceChanged(TextSrcObject, XawTextPosition, XawTextPosition,
+ XawTextBlock*, int);
+Bool _XawTextSrcUndo(TextSrcObject, XawTextPosition*);
+Bool _XawTextSrcToggleUndo(TextSrcObject);
+XawTextAnchor *_XawTextSourceFindAnchor(Widget, XawTextPosition);
+
+/*
+ * External
+ */
+void _XawSourceAddText(Widget, Widget);
+void _XawSourceRemoveText(Widget, Widget, Bool);
+Bool _XawTextSourceNewLineAtEOF(Widget);
+void _XawSourceSetUndoErase(TextSrcObject, int);
+void _XawSourceSetUndoMerge(TextSrcObject, Bool);
+#endif /* OLDXAW */
+
+/*
+ * Defined in Text.c
+ */
+char *_XawTextGetText(TextWidget, XawTextPosition, XawTextPosition);
+void _XawTextSourceChanged(Widget, XawTextPosition, XawTextPosition,
+ XawTextBlock*, int);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(TextSrcRec, textSrc.field)
+static XtResource resources[] = {
+ {
+ XtNeditType,
+ XtCEditType,
+ XtREditMode,
+ sizeof(XawTextEditType),
+ offset(edit_mode),
+ XtRString,
+ "read"
+ },
+#ifndef OLDXAW
+ {
+ XtNcallback,
+ XtCCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(callback),
+ XtRCallback,
+ NULL
+ },
+ {
+ XtNsourceChanged,
+ XtCChanged,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(changed),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNenableUndo,
+ XtCUndo,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(enable_undo),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNpropertyCallback,
+ XtCCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(property_callback),
+ XtRCallback,
+ NULL
+ },
+#endif /* OLDXAW */
+};
+#undef offset
+
+#define Superclass (&objectClassRec)
+TextSrcClassRec textSrcClassRec = {
+ /* object */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "TextSrc", /* class_name */
+ sizeof(TextSrcRec), /* widget_size */
+ XawTextSrcClassInitialize, /* class_initialize */
+ XawTextSrcClassPartInitialize, /* class_part_initialize */
+ False, /* class_inited */
+ XawTextSrcInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ NULL, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ False, /* compress_motion */
+ False, /* compress_exposure */
+ False, /* compress_enterleave */
+ False, /* visible_interest */
+ XawTextSrcDestroy, /* destroy */
+ NULL, /* resize */
+ NULL, /* expose */
+ XawTextSrcSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ NULL, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ NULL, /* query_geometry */
+ NULL, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* text_src */
+ {
+ Read, /* Read */
+ Replace, /* Replace */
+ Scan, /* Scan */
+ Search, /* Search */
+ SetSelection, /* SetSelection */
+ ConvertSelection, /* ConvertSelection */
+ },
+};
+
+WidgetClass textSrcObjectClass = (WidgetClass)&textSrcClassRec;
+
+static XrmQuark QRead, QAppend, QEdit;
+#ifndef OLDXAW
+static char *SrcNL = "\n";
+static wchar_t SrcWNL[2];
+#endif
+
+/*
+ * Implementation
+ */
+static void
+XawTextSrcClassInitialize(void)
+{
+ XawInitializeWidgetSet();
+
+#ifndef OLDXAW
+ SrcWNL[0] = _Xaw_atowc(XawLF);
+ SrcWNL[1] = 0;
+#endif
+ QRead = XrmPermStringToQuark(XtEtextRead);
+ QAppend = XrmPermStringToQuark(XtEtextAppend);
+ QEdit = XrmPermStringToQuark(XtEtextEdit);
+ XtAddConverter(XtRString, XtREditMode, CvtStringToEditMode, NULL, 0);
+ XtSetTypeConverter(XtREditMode, XtRString, CvtEditModeToString, NULL, 0,
+ XtCacheNone, NULL);
+}
+
+static void
+XawTextSrcClassPartInitialize(WidgetClass wc)
+{
+ TextSrcObjectClass t_src, superC;
+
+ t_src = (TextSrcObjectClass)wc;
+ superC = (TextSrcObjectClass)t_src->object_class.superclass;
+
+ /*
+ * We don't need to check for null super since we'll get to TextSrc
+ * eventually
+ */
+ if (t_src->textSrc_class.Read == XtInheritRead)
+ t_src->textSrc_class.Read = superC->textSrc_class.Read;
+
+ if (t_src->textSrc_class.Replace == XtInheritReplace)
+ t_src->textSrc_class.Replace = superC->textSrc_class.Replace;
+
+ if (t_src->textSrc_class.Scan == XtInheritScan)
+ t_src->textSrc_class.Scan = superC->textSrc_class.Scan;
+
+ if (t_src->textSrc_class.Search == XtInheritSearch)
+ t_src->textSrc_class.Search = superC->textSrc_class.Search;
+
+ if (t_src->textSrc_class.SetSelection == XtInheritSetSelection)
+ t_src->textSrc_class.SetSelection = superC->textSrc_class.SetSelection;
+
+ if (t_src->textSrc_class.ConvertSelection == XtInheritConvertSelection)
+ t_src->textSrc_class.ConvertSelection =
+ superC->textSrc_class.ConvertSelection;
+}
+
+/*ARGSUSED*/
+static void
+XawTextSrcInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+#ifndef OLDXAW
+ TextSrcObject src = (TextSrcObject)cnew;
+
+ if (src->textSrc.enable_undo) {
+ src->textSrc.undo = (XawTextUndo*)XtCalloc(1, sizeof(XawTextUndo));
+ src->textSrc.undo->dir = XawsdLeft;
+ }
+ else
+ src->textSrc.undo = NULL;
+ src->textSrc.undo_state = False;
+ if (XtIsSubclass(XtParent(cnew), textWidgetClass)) {
+ src->textSrc.text = (WidgetList)XtMalloc(sizeof(Widget*));
+ src->textSrc.text[0] = XtParent(cnew);
+ src->textSrc.num_text = 1;
+ }
+ else {
+ src->textSrc.text = NULL;
+ src->textSrc.num_text = 0;
+ }
+
+ src->textSrc.anchors = NULL;
+ src->textSrc.num_anchors = 0;
+ (void)XawTextSourceAddAnchor(cnew, 0);
+#endif /* OLDXAW */
+}
+
+static void
+XawTextSrcDestroy(Widget w)
+{
+#ifndef OLDXAW
+ TextSrcObject src = (TextSrcObject)w;
+
+ if (src->textSrc.enable_undo) {
+ FreeUndoBuffer(src->textSrc.undo);
+ XtFree((char*)src->textSrc.undo);
+ }
+ XtFree((char*)src->textSrc.text);
+
+ if (src->textSrc.num_anchors) {
+ XawTextEntity *entity, *enext;
+ int i;
+
+ for (i = 0; i < src->textSrc.num_anchors; i++) {
+ entity = src->textSrc.anchors[i]->entities;
+ while (entity) {
+ enext = entity->next;
+ XtFree((XtPointer)entity);
+ entity = enext;
+ }
+ XtFree((XtPointer)src->textSrc.anchors[i]);
+ }
+ XtFree((XtPointer)src->textSrc.anchors);
+ }
+#endif /* OLDXAW */
+}
+
+/*ARGSUSED*/
+static Boolean
+XawTextSrcSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+#ifndef OLDXAW
+ TextSrcObject oldtw = (TextSrcObject)current;
+ TextSrcObject newtw = (TextSrcObject)cnew;
+
+ if (oldtw->textSrc.enable_undo != newtw->textSrc.enable_undo) {
+ if (newtw->textSrc.enable_undo) {
+ newtw->textSrc.undo = (XawTextUndo*)
+ XtCalloc(1, sizeof(XawTextUndo));
+ newtw->textSrc.undo->dir = XawsdLeft;
+ }
+ else {
+ FreeUndoBuffer(newtw->textSrc.undo);
+ XtFree((char*)newtw->textSrc.undo);
+ newtw->textSrc.undo = NULL;
+ }
+ }
+ if (oldtw->textSrc.changed != newtw->textSrc.changed) {
+ if (newtw->textSrc.enable_undo) {
+ if (newtw->textSrc.undo->list) {
+ newtw->textSrc.undo->l_no_change =
+ newtw->textSrc.undo->list->left;
+ newtw->textSrc.undo->r_no_change =
+ newtw->textSrc.undo->list->right;
+ }
+ else
+ newtw->textSrc.undo->l_no_change =
+ newtw->textSrc.undo->r_no_change = NULL;
+ }
+ }
+#endif /* OLDXAW */
+ return (False);
+}
+
+/*
+ * Function:
+ * Read
+ *
+ * Parameters:
+ * w - TextSrc Object
+ * pos - position of the text to retreive
+ * text - text block that will contain returned text
+ * length - maximum number of characters to read
+ *
+ * Description:
+ * This function reads the source.
+ *
+ * Returns:
+ * The character position following the retrieved text.
+ */
+/*ARGSUSED*/
+static XawTextPosition
+Read(Widget w, XawTextPosition pos, XawTextBlock *text, int length)
+{
+ return ((XawTextPosition)0);
+}
+
+/*
+ * Function:
+ * Replace
+ *
+ * Parameters:
+ * src - Text Source Object
+ * startPos - ends of text that will be removed
+ * endPos - ""
+ * text - new text to be inserted into buffer at startPos
+ *
+ * Description:
+ * Replaces a block of text with new text.
+ */
+/*ARGSUSED*/
+static int
+Replace(Widget w, XawTextPosition startPos, XawTextPosition endPos,
+ XawTextBlock *text)
+{
+ return (XawEditError);
+}
+
+/*
+ * Function:
+ * Scan
+ *
+ * Parameters:
+ * w - TextSrc Object
+ * position - position to start scanning
+ * type - type of thing to scan for
+ * dir - direction to scan
+ * count - which occurance if this thing to search for
+ * include - whether or not to include the character found in
+ * the position that is returned
+ *
+ * Description:
+ * Scans the text source for the number and type of item specified.
+ */
+/*ARGSUSED*/
+static XawTextPosition
+Scan(Widget w, XawTextPosition position, XawTextScanType type,
+ XawTextScanDirection dir, int count, Bool include)
+{
+ return ((XawTextPosition)0);
+}
+
+/*
+ * Function:
+ * Search
+ *
+ * Parameters:
+ * w - TextSource Object
+ * position - position to start searching
+ * dir - direction to search
+ * text - the text block to search for
+ *
+ * Description:
+ * Searchs the text source for the text block passed
+ */
+/*ARGSUSED*/
+static XawTextPosition
+Search(Widget w, XawTextPosition position, XawTextScanDirection dir,
+ XawTextBlock *text)
+{
+ return (XawTextSearchError);
+}
+
+/*ARGSUSED*/
+static Boolean
+ConvertSelection(Widget w, Atom *selection, Atom *target, Atom *type,
+ XtPointer *value, unsigned long *length, int *format)
+{
+ return (False);
+}
+
+/*ARGSUSED*/
+static void
+SetSelection(Widget w, XawTextPosition left, XawTextPosition right,
+ Atom selection)
+{
+}
+
+/*ARGSUSED*/
+static void
+CvtStringToEditMode(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static XawTextEditType editType;
+ XrmQuark q;
+ char name[7];
+
+ XmuNCopyISOLatin1Lowered(name, (char *)fromVal->addr, sizeof(name));
+ q = XrmStringToQuark(name);
+
+ if (q == QRead)
+ editType = XawtextRead;
+ else if (q == QAppend)
+ editType = XawtextAppend;
+ else if (q == QEdit)
+ editType = XawtextEdit;
+ else {
+ toVal->size = 0;
+ toVal->addr = NULL;
+ XtStringConversionWarning((char *)fromVal->addr, XtREditMode);
+ }
+ toVal->size = sizeof(XawTextEditType);
+ toVal->addr = (XPointer)&editType;
+}
+
+/*ARGSUSED*/
+static Boolean
+CvtEditModeToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal,
+ XtPointer *data)
+{
+ static String buffer;
+ Cardinal size;
+
+ switch (*(XawTextEditType *)fromVal->addr) {
+ case XawtextAppend:
+ case XawtextRead:
+ buffer = XtEtextRead;
+ break;
+ buffer = XtEtextAppend;
+ break;
+ case XawtextEdit:
+ buffer = XtEtextEdit;
+ break;
+ default:
+ XawTypeToStringWarning(dpy, XtREditMode);
+ toVal->addr = NULL;
+ toVal->size = 0;
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL) {
+ if (toVal->size < size) {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
+
+#ifndef OLDXAW
+Bool
+_XawTextSourceNewLineAtEOF(Widget w)
+{
+ TextSrcObject src = (TextSrcObject)w;
+ XawTextBlock text;
+
+ text.firstPos = 0;
+ if ((text.format = src->textSrc.text_format) == XawFmt8Bit)
+ text.ptr = SrcNL;
+ else
+ text.ptr = (char*)SrcWNL;
+ text.length = 1;
+
+ return (XawTextSourceSearch(w, XawTextSourceScan(w, 0, XawstAll,
+ XawsdRight, 1, True) - 1,
+ XawsdRight, &text) != XawTextSearchError);
+}
+
+void
+_XawSourceAddText(Widget source, Widget text)
+{
+ TextSrcObject src = (TextSrcObject)source;
+ Bool found = False;
+ Cardinal i;
+
+ for (i = 0; i < src->textSrc.num_text; i++)
+ if (src->textSrc.text[i] == text) {
+ found = True;
+ break;
+ }
+
+ if (!found) {
+ src->textSrc.text = (WidgetList)
+ XtRealloc((char*)src->textSrc.text,
+ sizeof(Widget) * (src->textSrc.num_text + 1));
+ src->textSrc.text[src->textSrc.num_text++] = text;
+ }
+}
+
+void
+_XawSourceRemoveText(Widget source, Widget text, Bool destroy)
+{
+ TextSrcObject src = (TextSrcObject)source;
+ Bool found = False;
+ Cardinal i;
+
+ if (src == NULL)
+ return;
+
+ for (i = 0; i < src->textSrc.num_text; i++)
+ if (src->textSrc.text[i] == text) {
+ found = True;
+ break;
+ }
+
+ if (found) {
+ if (--src->textSrc.num_text == 0) {
+ if (destroy) {
+ XtDestroyWidget(source);
+ return;
+ }
+ else {
+ XtFree((char*)src->textSrc.text);
+ src->textSrc.text = NULL; /* for realloc "magic" */
+ }
+ }
+ else if (i < src->textSrc.num_text)
+ memmove(&src->textSrc.text[i], &src->textSrc.text[i + 1],
+ sizeof(Widget) * (src->textSrc.num_text - i));
+ }
+}
+#endif /* OLDXAW */
+
+/*
+ * Function:
+ * XawTextSourceRead
+ *
+ * Parameters:
+ * w - TextSrc Object
+ * pos - position of the text to retrieve
+ * text - text block that will contain returned text (return)
+ * length - maximum number of characters to read
+ *
+ * Description:
+ * This function reads the source.
+ *
+ * Returns:
+ * The number of characters read into the buffer
+ */
+XawTextPosition
+XawTextSourceRead(Widget w, XawTextPosition pos, XawTextBlock *text,
+ int length)
+{
+ TextSrcObjectClass cclass = (TextSrcObjectClass)w->core.widget_class;
+
+ return ((*cclass->textSrc_class.Read)(w, pos, text, length));
+}
+
+#ifndef OLDXAW
+static void
+TellSourceChanged(TextSrcObject src, XawTextPosition left,
+ XawTextPosition right, XawTextBlock *block, int lines)
+{
+ Cardinal i;
+
+ for (i = 0; i < src->textSrc.num_text; i++)
+ _XawTextSourceChanged(src->textSrc.text[i], left, right, block, lines);
+}
+
+/*
+ * This function is required because there is no way to diferentiate
+ * if the first erase was generated by a backward-kill-char and the
+ * second by a forward-kill-char (or vice-versa) from XawTextSourceReplace.
+ * It is only possible to diferentiate after the second character is
+ * killed, but then, it is too late.
+ */
+void
+_XawSourceSetUndoErase(TextSrcObject src, int value)
+{
+ if (src && src->textSrc.enable_undo)
+ src->textSrc.undo->erase = value;
+}
+
+/*
+ * To diferentiate insert-char's separeted by cursor movements.
+ */
+void
+_XawSourceSetUndoMerge(TextSrcObject src, Bool state)
+{
+ if (src && src->textSrc.enable_undo)
+ src->textSrc.undo->merge += state ? 1 : -1;
+}
+#endif /* OLDXAW */
+
+/*
+ * Public Functions
+ */
+/*
+ * Function:
+ * XawTextSourceReplace
+ *
+ * Parameters:
+ * src - Text Source Object
+ * startPos - ends of text that will be removed
+ * endPos - ""
+ * text - new text to be inserted into buffer at startPos
+ *
+ * Description:
+ * Replaces a block of text with new text.
+ *
+ * Returns:
+ * XawEditError or XawEditDone.
+ */
+/*ARGSUSED*/
+int
+XawTextSourceReplace(Widget w, XawTextPosition left,
+ XawTextPosition right, XawTextBlock *block)
+{
+ TextSrcObjectClass cclass = (TextSrcObjectClass)w->core.widget_class;
+#ifndef OLDXAW
+ TextSrcObject src = (TextSrcObject)w;
+ XawTextUndoBuffer *l_state, *r_state;
+ XawTextUndoList *undo;
+ Bool enable_undo;
+ XawTextPosition start, end;
+ int i, error, lines = 0;
+
+ if (src->textSrc.edit_mode == XawtextRead)
+ return (XawEditError);
+
+ enable_undo = src->textSrc.enable_undo && src->textSrc.undo_state == False;
+ if (enable_undo) {
+ unsigned size, total;
+
+ if (src->textSrc.undo->l_save) {
+ l_state = src->textSrc.undo->l_save;
+ src->textSrc.undo->l_save = NULL;
+ }
+ else
+ l_state = XtNew(XawTextUndoBuffer);
+ l_state->refcount = 1;
+ l_state->position = left;
+ if (left < right) {
+ Widget ctx = NULL;
+
+ for (i = 0; i < src->textSrc.num_text; i++)
+ if (XtIsSubclass(src->textSrc.text[i], textWidgetClass)) {
+ ctx = src->textSrc.text[i];
+ break;
+ }
+ l_state->buffer = _XawTextGetText((TextWidget)ctx, left, right);
+ l_state->length = right - left;
+ }
+ else {
+ l_state->length = 0;
+ l_state->buffer = NULL;
+ }
+ l_state->format = src->textSrc.text_format;
+ if (l_state->length == 1) {
+ if (l_state->format == XawFmtWide &&
+ *(wchar_t*)l_state->buffer == *SrcWNL) {
+ XtFree(l_state->buffer);
+ l_state->buffer = (char*)SrcWNL;
+ }
+ else if (*l_state->buffer == '\n') {
+ XtFree(l_state->buffer);
+ l_state->buffer = SrcNL;
+ }
+ }
+
+ if (src->textSrc.undo->r_save) {
+ r_state = src->textSrc.undo->r_save;
+ src->textSrc.undo->r_save = NULL;
+ }
+ else
+ r_state = XtNew(XawTextUndoBuffer);
+ r_state->refcount = 1;
+ r_state->position = left;
+ r_state->format = block->format;
+ size = block->format == XawFmtWide ? sizeof(wchar_t) : sizeof(char);
+ total = size * block->length;
+ r_state->length = block->length;
+ r_state->buffer = NULL;
+ if (total == size) {
+ if (r_state->format == XawFmtWide &&
+ *(wchar_t*)block->ptr == *SrcWNL)
+ r_state->buffer = (char*)SrcWNL;
+ else if (*block->ptr == '\n')
+ r_state->buffer = SrcNL;
+ }
+ if (total && !r_state->buffer) {
+ r_state->buffer = XtMalloc(total);
+ memcpy(r_state->buffer, block->ptr, total);
+ }
+
+ if (src->textSrc.undo->u_save) {
+ undo = src->textSrc.undo->u_save;
+ src->textSrc.undo->u_save = NULL;
+ }
+ else
+ undo = XtNew(XawTextUndoList);
+ undo->left = l_state;
+ undo->right = r_state;
+ undo->undo = src->textSrc.undo->list;
+ undo->redo = NULL;
+ }
+ else {
+ undo = NULL;
+ l_state = r_state = NULL;
+ }
+
+#define LARGE_VALUE 262144 /* 256 K */
+ /* optimization, to avoid long delays recalculating the line number
+ * when editing huge files
+ */
+ if (left > LARGE_VALUE) {
+ start = XawTextSourceScan(w, left, XawstEOL, XawsdLeft, 2, False);
+ for (i = 0; i < src->textSrc.num_text; i++) {
+ TextWidget tw = (TextWidget)src->textSrc.text[i];
+
+ if (left <= tw->text.lt.top &&
+ left + block->length - (right - left) > tw->text.lt.top)
+ _XawTextBuildLineTable(tw, start, False);
+ }
+ }
+#undef LARGE_VALUE
+
+ start = left;
+ end = right;
+ while (start < end) {
+ start = XawTextSourceScan(w, start, XawstEOL, XawsdRight, 1, True);
+ if (start <= end) {
+ --lines;
+ if (start == XawTextSourceScan(w, 0, XawstAll, XawsdRight, 1, True)) {
+ lines += !_XawTextSourceNewLineAtEOF(w);
+ break;
+ }
+ }
+ }
+#else
+ int error;
+#endif /* OLDXAW */
+
+ error = (*cclass->textSrc_class.Replace)(w, left, right, block);
+
+#ifndef OLDXAW
+ if (error != XawEditDone) {
+ if (enable_undo) {
+ if (l_state->buffer) {
+ if (l_state->buffer != SrcNL && l_state->buffer != (char*)SrcWNL)
+ XtFree(l_state->buffer);
+ l_state->buffer = NULL;
+ }
+ src->textSrc.undo->l_save = l_state;
+ if (r_state->buffer) {
+ if (r_state->buffer != SrcNL && r_state->buffer != (char*)SrcWNL)
+ XtFree(r_state->buffer);
+ r_state->buffer = NULL;
+ }
+ src->textSrc.undo->r_save = r_state;
+
+ src->textSrc.undo->u_save = undo;
+ }
+ }
+ else if (enable_undo) {
+ XawTextUndoList *list = src->textSrc.undo->list;
+ XawTextUndoBuffer *unl, *lnl;
+ int erase = undo->right->length == 0 && undo->left->length == 1 && list
+ && list->right->length == 0;
+
+ if (erase) {
+ erase = list->left->position - 1 == undo->left->position ? -1 :
+ list->left->position == undo->left->position ? 1 : 0;
+ if (src->textSrc.undo->erase && erase != src->textSrc.undo->erase)
+ erase = 0;
+ else
+ src->textSrc.undo->erase = erase;
+ }
+
+ if (erase) {
+ unl = l_state;
+ lnl = list->left;
+ }
+ else {
+ unl = r_state;
+ lnl = list ? list->right : NULL;
+ }
+
+ /* Try to merge the undo buffers */
+ if (src->textSrc.undo->merge > 0 && ((erase ||
+ (list && ((list->left->length == 0 && undo->left->length == 0) ||
+ (list->left->length == list->right->length &&
+ undo->left->length == 1)) &&
+ undo->right->length == 1 &&
+ list->right->position + list->right->length
+ == undo->right->position))
+ && src->textSrc.undo->pointer == list
+ && unl->format == list->right->format
+ && ((unl->format == XawFmt8Bit && unl->buffer[0] != XawLF) ||
+ (unl->format == XawFmtWide &&
+ *(wchar_t*)(unl->buffer) != _Xaw_atowc(XawLF)))
+ && ((lnl->format == XawFmt8Bit && lnl->buffer[0] != XawLF) ||
+ (lnl->format == XawFmtWide &&
+ *(wchar_t*)(lnl->buffer) != _Xaw_atowc(XawLF))))) {
+ unsigned size = lnl->format == XawFmtWide ?
+ sizeof(wchar_t) : sizeof(char);
+
+ if (!erase) {
+ list->right->buffer = XtRealloc(list->right->buffer,
+ (list->right->length + 1) * size);
+ memcpy(list->right->buffer + list->right->length * size,
+ undo->right->buffer, size);
+ ++list->right->length;
+ XtFree(r_state->buffer);
+ }
+ else if (erase < 0) {
+ --list->left->position;
+ --list->right->position;
+ }
+
+ src->textSrc.undo->l_save = l_state;
+ src->textSrc.undo->r_save = r_state;
+ src->textSrc.undo->u_save = undo;
+
+ if (list->left->length) {
+ list->left->buffer = XtRealloc(list->left->buffer,
+ (list->left->length + 1) * size);
+ if (erase >= 0)
+ memcpy(list->left->buffer + list->left->length * size,
+ undo->left->buffer, size);
+ else {
+ /* use memmove, since strings overlap */
+ memmove(list->left->buffer + size, list->left->buffer,
+ list->left->length * size);
+ memcpy(list->left->buffer, undo->left->buffer, size);
+ }
+ ++list->left->length;
+ if (l_state->buffer != SrcNL && l_state->buffer != (char*)SrcWNL)
+ XtFree(l_state->buffer);
+ }
+
+ if (src->textSrc.undo->num_list >= UNDO_DEPTH)
+ UndoGC(src->textSrc.undo);
+ }
+ else {
+ src->textSrc.undo->undo = (XawTextUndoBuffer**)
+ XtRealloc((char*)src->textSrc.undo->undo,
+ (2 + src->textSrc.undo->num_undo)
+ * sizeof(XawTextUndoBuffer));
+ src->textSrc.undo->undo[src->textSrc.undo->num_undo++] = l_state;
+ src->textSrc.undo->undo[src->textSrc.undo->num_undo++] = r_state;
+
+ if (src->textSrc.undo->list)
+ src->textSrc.undo->list->redo = undo;
+ else
+ src->textSrc.undo->head = undo;
+
+ src->textSrc.undo->merge = l_state->length <= 1 &&
+ r_state->length <= 1;
+
+ src->textSrc.undo->list = src->textSrc.undo->pointer =
+ src->textSrc.undo->end_mark = undo;
+
+ if (++src->textSrc.undo->num_list >= UNDO_DEPTH)
+ UndoGC(src->textSrc.undo);
+ }
+ src->textSrc.undo->dir = XawsdLeft;
+ if (!src->textSrc.changed) {
+ src->textSrc.undo->l_no_change = src->textSrc.undo->list->right;
+ src->textSrc.undo->r_no_change = src->textSrc.undo->list->left;
+ src->textSrc.changed = True;
+ }
+ }
+ else if (!src->textSrc.enable_undo)
+ src->textSrc.changed = True;
+
+ if (error == XawEditDone) {
+ XawTextPropertyInfo info;
+ XawTextAnchor *anchor;
+
+ /* find anchor and index */
+ /* XXX index (i) could be returned by XawTextSourceFindAnchor
+ * or similar function, to speed up */
+ if ((anchor = XawTextSourceFindAnchor(w, left))) {
+ XawTextEntity *eprev, *entity, *enext;
+ XawTextPosition offset = 0, diff = block->length - (right - left);
+
+ for (i = 0; i < src->textSrc.num_anchors; i++)
+ if (src->textSrc.anchors[i] == anchor)
+ break;
+ if (anchor->cache && anchor->position + anchor->cache->offset +
+ anchor->cache->length <= left)
+ eprev = entity = anchor->cache;
+ else
+ eprev = entity = anchor->entities;
+ while (entity) {
+ offset = anchor->position + entity->offset;
+
+ if (offset > left)
+ break;
+ if (offset + entity->length > left)
+ break;
+
+ eprev = entity;
+ entity = entity->next;
+ }
+
+ /* try to do the right thing here (and most likely correct), but
+ * other code needs to check what was done */
+
+ /* adjust entity length */
+ if (entity && offset <= left) {
+ if (offset + entity->length < right)
+ entity->length = left - offset + block->length;
+ else
+ entity->length += diff;
+
+ if (entity->length == 0) {
+ enext = entity->next;
+ eprev->next = enext;
+ anchor->cache = NULL;
+ XtFree((XtPointer)entity);
+ if (entity == anchor->entities) {
+ if ((anchor->entities = enext) == NULL) {
+ eprev = NULL;
+ anchor = XawTextSourceRemoveAnchor(w, anchor);
+ entity = anchor ? anchor->entities : NULL;
+ }
+ else
+ eprev = entity = enext;
+ }
+ else
+ entity = enext;
+ }
+ else {
+ eprev = entity;
+ entity = entity->next;
+ }
+ }
+
+ while (anchor) {
+ while (entity) {
+ offset = anchor->position + entity->offset + entity->length;
+
+ if (offset > right) {
+ entity->length = XawMin(entity->length, offset - right);
+ goto exit_anchor_loop;
+ }
+
+ enext = entity->next;
+ if (eprev)
+ eprev->next = enext;
+ XtFree((XtPointer)entity);
+ anchor->cache = NULL;
+ if (entity == anchor->entities) {
+ eprev = NULL;
+ if ((anchor->entities = enext) == NULL) {
+ if (i == 0)
+ ++i;
+ else if (i < --src->textSrc.num_anchors) {
+ memmove(&src->textSrc.anchors[i],
+ &src->textSrc.anchors[i + 1],
+ (src->textSrc.num_anchors - i) *
+ sizeof(XawTextAnchor*));
+ XtFree((XtPointer)anchor);
+ }
+ if (i >= src->textSrc.num_anchors) {
+ anchor = NULL;
+ entity = NULL;
+ break;
+ }
+ anchor = src->textSrc.anchors[i];
+ entity = anchor->entities;
+ continue;
+ }
+ }
+ entity = enext;
+ }
+ if (i + 1 < src->textSrc.num_anchors) {
+ anchor = src->textSrc.anchors[++i];
+ entity = anchor->entities;
+ eprev = NULL;
+ }
+ else
+ break;
+ eprev = NULL;
+ }
+
+exit_anchor_loop:
+ if (anchor) {
+ XawTextAnchor *aprev;
+
+ if (anchor->position >= XawMax(right, left + block->length))
+ anchor->position += diff;
+ else if (anchor->position > left &&
+ (aprev = XawTextSourcePrevAnchor(w, anchor))) {
+ XawTextPosition tmp = anchor->position - aprev->position;
+
+ if (diff) {
+ while (entity) {
+ entity->offset += diff;
+ entity = entity->next;
+ }
+ }
+ entity = anchor->entities;
+ while (entity) {
+ entity->offset += tmp;
+ entity = entity->next;
+ }
+ if ((entity = aprev->entities) == NULL)
+ aprev->entities = anchor->entities;
+ else {
+ while (entity->next)
+ entity = entity->next;
+ entity->next = anchor->entities;
+ }
+ anchor->entities = NULL;
+ (void)XawTextSourceRemoveAnchor(w, anchor);
+ --i;
+ }
+ else if (diff) {
+ while (entity) {
+ entity->offset += diff;
+ entity = entity->next;
+ }
+ }
+ }
+
+ if (diff) {
+ for (++i; i < src->textSrc.num_anchors; i++)
+ src->textSrc.anchors[i]->position += diff;
+ }
+ }
+
+ start = left;
+ end = start + block->length;
+ while (start < end) {
+ start = XawTextSourceScan(w, start, XawstEOL, XawsdRight, 1, True);
+ if (start <= end) {
+ ++lines;
+ if (start == XawTextSourceScan(w, 0, XawstAll, XawsdRight, 1, True)) {
+ lines -= !_XawTextSourceNewLineAtEOF(w);
+ break;
+ }
+ }
+ }
+
+ info.left = left;
+ info.right = right;
+ info.block = block;
+ XtCallCallbacks(w, XtNpropertyCallback, &info);
+
+ TellSourceChanged(src, left, right, block, lines);
+ /* Call callbacks, we have changed the buffer */
+ XtCallCallbacks(w, XtNcallback,
+ (XtPointer)((long)src->textSrc.changed));
+ }
+
+#endif /* OLDXAW */
+ return (error);
+}
+
+#ifndef OLDXAW
+Bool
+_XawTextSrcUndo(TextSrcObject src, XawTextPosition *insert_pos)
+{
+ static wchar_t wnull = 0;
+ XawTextBlock block;
+ XawTextUndoList *list, *nlist;
+ XawTextUndoBuffer *l_state, *r_state;
+ Boolean changed = src->textSrc.changed;
+
+ if (!src->textSrc.enable_undo || !src->textSrc.undo->num_undo)
+ return (False);
+
+ list = src->textSrc.undo->pointer;
+
+ if (src->textSrc.undo->dir == XawsdLeft) {
+ l_state = list->right;
+ r_state = list->left;
+ }
+ else {
+ l_state = list->left;
+ r_state = list->right;
+ }
+
+ if (src->textSrc.undo->l_no_change == l_state
+ && src->textSrc.undo->r_no_change == r_state)
+ src->textSrc.changed = False;
+ else
+ src->textSrc.changed = True;
+
+ block.firstPos = 0;
+ block.length = r_state->length;
+ block.ptr = r_state->buffer ? r_state->buffer : (char*)&wnull;
+ block.format = r_state->format;
+
+ src->textSrc.undo_state = True;
+ if (XawTextSourceReplace((Widget)src, l_state->position, l_state->position
+ + l_state->length, &block) != XawEditDone) {
+ src->textSrc.undo_state = False;
+ src->textSrc.changed = changed;
+ return (False);
+ }
+ src->textSrc.undo_state = False;
+
+ ++l_state->refcount;
+ ++r_state->refcount;
+ nlist = XtNew(XawTextUndoList);
+ nlist->left = l_state;
+ nlist->right = r_state;
+ nlist->undo = src->textSrc.undo->list;
+ nlist->redo = NULL;
+
+ if (list == src->textSrc.undo->list)
+ src->textSrc.undo->end_mark = nlist;
+
+ if (src->textSrc.undo->dir == XawsdLeft) {
+ if (list->undo == NULL)
+ src->textSrc.undo->dir = XawsdRight;
+ else
+ list = list->undo;
+ }
+ else {
+ if (list->redo == NULL || list->redo == src->textSrc.undo->end_mark)
+ src->textSrc.undo->dir = XawsdLeft;
+ else
+ list = list->redo;
+ }
+ *insert_pos = r_state->position + r_state->length;
+ src->textSrc.undo->pointer = list;
+ src->textSrc.undo->list->redo = nlist;
+ src->textSrc.undo->list = nlist;
+ src->textSrc.undo->merge = src->textSrc.undo->erase = 0;
+
+ if (++src->textSrc.undo->num_list >= UNDO_DEPTH)
+ UndoGC(src->textSrc.undo);
+
+ return (True);
+}
+
+Bool
+_XawTextSrcToggleUndo(TextSrcObject src)
+{
+ if (!src->textSrc.enable_undo || !src->textSrc.undo->num_undo)
+ return (False);
+
+ if (src->textSrc.undo->pointer != src->textSrc.undo->list) {
+ if (src->textSrc.undo->dir == XawsdLeft) {
+ if (src->textSrc.undo->pointer->redo
+ && (src->textSrc.undo->pointer->redo
+ != src->textSrc.undo->end_mark)) {
+ src->textSrc.undo->pointer = src->textSrc.undo->pointer->redo;
+ src->textSrc.undo->dir = XawsdRight;
+ }
+ }
+ else {
+ if (src->textSrc.undo->pointer->undo
+ && (src->textSrc.undo->pointer != src->textSrc.undo->head)) {
+ src->textSrc.undo->pointer = src->textSrc.undo->pointer->undo;
+ src->textSrc.undo->dir = XawsdLeft;
+ }
+ }
+ }
+
+ return (True);
+}
+
+static void
+FreeUndoBuffer(XawTextUndo *undo)
+{
+ unsigned i;
+ XawTextUndoList *head, *del;
+
+ for (i = 0; i < undo->num_undo; i++) {
+ if (undo->undo[i]->buffer && undo->undo[i]->buffer != SrcNL &&
+ undo->undo[i]->buffer != (char*)SrcWNL)
+ XtFree(undo->undo[i]->buffer);
+ XtFree((char*)undo->undo[i]);
+ }
+ XtFree((char*)undo->undo);
+ head = undo->head;
+
+ del = head;
+ while (head) {
+ head = head->redo;
+ XtFree((char*)del);
+ del = head;
+ }
+
+ if (undo->l_save) {
+ XtFree((char*)undo->l_save);
+ undo->l_save = NULL;
+ }
+ if (undo->r_save) {
+ XtFree((char*)undo->r_save);
+ undo->r_save = NULL;
+ }
+ if (undo->u_save) {
+ XtFree((char*)undo->u_save);
+ undo->u_save = NULL;
+ }
+
+ undo->list = undo->pointer = undo->head = undo->end_mark = NULL;
+ undo->l_no_change = undo->r_no_change = NULL;
+ undo->undo = NULL;
+ undo->dir = XawsdLeft;
+ undo->num_undo = undo->num_list = undo->erase = undo->merge = 0;
+}
+
+static void
+UndoGC(XawTextUndo *undo)
+{
+ unsigned i;
+ XawTextUndoList *head = undo->head, *redo = head->redo;
+
+ if (head == undo->pointer || head == undo->end_mark
+ || undo->l_no_change == NULL
+ || head->left == undo->l_no_change || head->right == undo->l_no_change)
+ return;
+
+ undo->head = redo;
+ redo->undo = NULL;
+
+ --head->left->refcount;
+ if (--head->right->refcount == 0) {
+ for (i = 0; i < undo->num_undo; i+= 2)
+ if (head->left == undo->undo[i] || head->left == undo->undo[i+1]) {
+ if (head->left == undo->undo[i+1]) {
+ XawTextUndoBuffer *tmp = redo->left;
+
+ redo->left = redo->right;
+ redo->right = tmp;
+ }
+ if (head->left->buffer && head->left->buffer != SrcNL &&
+ head->left->buffer != (char*)SrcWNL)
+ XtFree(head->left->buffer);
+ XtFree((char*)head->left);
+ if (head->right->buffer && head->right->buffer != SrcNL &&
+ head->right->buffer != (char*)SrcWNL)
+ XtFree(head->right->buffer);
+ XtFree((char*)head->right);
+
+ undo->num_undo -= 2;
+ memmove(&undo->undo[i], &undo->undo[i + 2],
+ (undo->num_undo - i) * sizeof(XawTextUndoBuffer*));
+ break;
+ }
+ }
+ XtFree((char*)head);
+ --undo->num_list;
+}
+#endif /* OLDXAW */
+
+/*
+ * Function:
+ * XawTextSourceScan
+ *
+ * Parameters:
+ * w - TextSrc Object
+ * position - position to start scanning
+ * type - type of thing to scan for
+ * dir - direction to scan
+ * count - which occurance if this thing to search for
+ * include - whether or not to include the character found in
+ * the position that is returned.
+ *
+ * Description:
+ * Scans the text source for the number and type of item specified.
+ *
+ * Returns:
+ * The position of the text
+ */
+XawTextPosition
+XawTextSourceScan(Widget w, XawTextPosition position,
+#if NeedWidePrototypes
+ int type, int dir, int count, int include
+#else
+ XawTextScanType type, XawTextScanDirection dir,
+ int count, Boolean include
+#endif
+)
+{
+ TextSrcObjectClass cclass = (TextSrcObjectClass)w->core.widget_class;
+
+ return ((*cclass->textSrc_class.Scan)
+ (w, position, type, dir, count, include));
+}
+
+/*
+ * Function:
+ * XawTextSourceSearch
+ *
+ * Parameters:
+ * w - TextSource Object
+ * position - position to start scanning
+ * dir - direction to scan
+ * text - the text block to search for.
+ *
+ * Returns:
+ * The position of the text we are searching for or XawTextSearchError.
+ *
+ * Description:
+ * Searchs the text source for the text block passed
+ */
+XawTextPosition
+XawTextSourceSearch(Widget w, XawTextPosition position,
+#if NeedWidePrototypes
+ int dir,
+#else
+ XawTextScanDirection dir,
+#endif
+ XawTextBlock *text)
+{
+ TextSrcObjectClass cclass = (TextSrcObjectClass)w->core.widget_class;
+
+ return ((*cclass->textSrc_class.Search)(w, position, dir, text));
+}
+
+/*
+ * Function:
+ * XawTextSourceConvertSelection
+ *
+ * Parameters:
+ * w - TextSrc object
+ * selection - current selection atom
+ * target - current target atom
+ * type - type to conver the selection to
+ * value - return value that has been converted
+ * length - ""
+ * format - format of the returned value
+ *
+ * Returns:
+ * True if the selection has been converted
+ */
+Boolean
+XawTextSourceConvertSelection(Widget w, Atom *selection, Atom *target,
+ Atom *type, XtPointer *value,
+ unsigned long *length, int *format)
+{
+ TextSrcObjectClass cclass = (TextSrcObjectClass)w->core.widget_class;
+
+ return((*cclass->textSrc_class.ConvertSelection)
+ (w, selection, target, type, value, length, format));
+}
+
+/*
+ * Function:
+ * XawTextSourceSetSelection
+ *
+ * Parameters:
+ * w - TextSrc object
+ * left - bounds of the selection
+ * rigth - ""
+ * selection - selection atom
+ *
+ * Description:
+ * Allows special setting of the selection.
+ */
+void
+XawTextSourceSetSelection(Widget w, XawTextPosition left,
+ XawTextPosition right, Atom selection)
+{
+ TextSrcObjectClass cclass = (TextSrcObjectClass)w->core.widget_class;
+
+ (*cclass->textSrc_class.SetSelection)(w, left, right, selection);
+}
+
+/*
+ * External Functions for Multi Text
+ */
+/*
+ * TextFormat():
+ * returns the format of text: FMT8BIT or FMTWIDE
+ */
+XrmQuark
+_XawTextFormat(TextWidget tw)
+{
+ return (((TextSrcObject)(tw->text.source))->textSrc.text_format);
+}
+
+/* _XawTextWCToMB():
+ * Convert the wchar string to external encoding
+ * The caller is responsible for freeing both the source and ret string
+ *
+ * wstr - source wchar string
+ * len_in_out - lengh of string.
+ * As In, length of source wchar string, measured in wchar
+ * As Out, length of returned string
+ */
+char *
+_XawTextWCToMB(Display *d, wchar_t *wstr, int *len_in_out)
+{
+ XTextProperty textprop;
+
+ if (XwcTextListToTextProperty(d, (wchar_t**)&wstr, 1,
+ XTextStyle, &textprop) < Success) {
+ XtWarningMsg("convertError", "textSource", "XawError",
+ "Non-character code(s) in buffer.", NULL, NULL);
+ *len_in_out = 0;
+ return (NULL);
+ }
+ *len_in_out = textprop.nitems;
+
+ return ((char *)textprop.value);
+}
+
+/* _XawTextMBToWC():
+ * Convert the string to internal processing codeset WC.
+ * The caller is responsible for freeing both the source and ret string.
+ *
+ * str - source string
+ * len_in_out - lengh of string
+ * As In, it is length of source string
+ * As Out, it is length of returned string, measured in wchar
+ */
+wchar_t *
+_XawTextMBToWC(Display *d, char *str, int *len_in_out)
+{
+ XTextProperty textprop;
+ char *buf;
+ wchar_t **wlist, *wstr;
+ int count;
+
+ if (*len_in_out == 0)
+ return (NULL);
+
+ buf = XtMalloc(*len_in_out + 1);
+
+ strncpy(buf, str, *len_in_out);
+ *(buf + *len_in_out) = '\0';
+ if (XmbTextListToTextProperty(d, &buf, 1, XTextStyle, &textprop) != Success) {
+ XtWarningMsg("convertError", "textSource", "XawError",
+ "No Memory, or Locale not supported.", NULL, NULL);
+ XtFree(buf);
+ *len_in_out = 0;
+ return (NULL);
+ }
+
+ XtFree(buf);
+ if (XwcTextPropertyToTextList(d, &textprop,
+ (wchar_t***)&wlist, &count) != Success) {
+ XtWarningMsg("convertError", "multiSourceCreate", "XawError",
+ "Non-character code(s) in source.", NULL, NULL);
+ *len_in_out = 0;
+ return (NULL);
+ }
+ wstr = wlist[0];
+ *len_in_out = wcslen(wstr);
+ XtFree((XtPointer)wlist);
+
+ return (wstr);
+}
+
+#ifndef OLDXAW
+static int
+qcmp_anchors(_Xconst void *left, _Xconst void *right)
+{
+ return ((*(XawTextAnchor**)left)->position -
+ (*(XawTextAnchor**)right)->position);
+}
+
+XawTextAnchor *
+XawTextSourceAddAnchor(Widget w, XawTextPosition position)
+{
+ TextSrcObject src = (TextSrcObject)w;
+ XawTextAnchor *anchor, *panchor;
+
+ if ((panchor = XawTextSourceFindAnchor(w, position)) != NULL) {
+ XawTextEntity *pentity, *entity;
+
+ if (position - panchor->position < ANCHORS_DIST)
+ return (panchor);
+
+ if (panchor->cache && panchor->position + panchor->cache->offset +
+ panchor->cache->length < position)
+ pentity = entity = panchor->cache;
+ else
+ pentity = entity = panchor->entities;
+
+ while (entity && panchor->position + entity->offset +
+ entity->length < position) {
+ pentity = entity;
+ entity = entity->next;
+ }
+ if (entity) {
+ XawTextPosition diff;
+
+ if (panchor->position + entity->offset < position)
+ position = panchor->position + entity->offset;
+
+ if (position == panchor->position)
+ return (panchor);
+
+ anchor = XtNew(XawTextAnchor);
+ diff = position - panchor->position;
+
+ panchor->cache = NULL;
+ anchor->entities = entity;
+ if (pentity != entity)
+ pentity->next = NULL;
+ else
+ panchor->entities = NULL;
+ while (entity) {
+ entity->offset -= diff;
+ entity = entity->next;
+ }
+ }
+ else {
+ anchor = XtNew(XawTextAnchor);
+ anchor->entities = NULL;
+ }
+ }
+ else {
+ anchor = XtNew(XawTextAnchor);
+ anchor->entities = NULL;
+ }
+
+ anchor->position = position;
+ anchor->cache = NULL;
+
+ src->textSrc.anchors = (XawTextAnchor**)
+ XtRealloc((XtPointer)src->textSrc.anchors, sizeof(XawTextAnchor*) *
+ (src->textSrc.num_anchors + 1));
+ src->textSrc.anchors[src->textSrc.num_anchors++] = anchor;
+ qsort((void*)src->textSrc.anchors, src->textSrc.num_anchors,
+ sizeof(XawTextAnchor*), qcmp_anchors);
+
+ return (anchor);
+}
+
+XawTextAnchor *
+XawTextSourceFindAnchor(Widget w, XawTextPosition position)
+{
+ TextSrcObject src = (TextSrcObject)w;
+ int i = 0, left, right, nmemb = src->textSrc.num_anchors;
+ XawTextAnchor *anchor, **anchors = src->textSrc.anchors;
+
+ left = 0;
+ right = nmemb - 1;
+ while (left <= right) {
+ anchor = anchors[i = (left + right) >> 1];
+ if (anchor->position == position)
+ return (anchor);
+ else if (position < anchor->position)
+ right = i - 1;
+ else
+ left = i + 1;
+ }
+
+ if (nmemb)
+ return (right < 0 ? anchors[0] : anchors[right]);
+
+ return (NULL);
+}
+
+Bool
+XawTextSourceAnchorAndEntity(Widget w, XawTextPosition position,
+ XawTextAnchor **anchor_return,
+ XawTextEntity **entity_return)
+{
+ XawTextAnchor *anchor = XawTextSourceFindAnchor(w, position);
+ XawTextEntity *pentity, *entity;
+ XawTextPosition offset;
+ Bool next_anchor = True, retval = False;
+
+ if (anchor->cache && anchor->position + anchor->cache->offset +
+ anchor->cache->length <= position)
+ pentity = entity = anchor->cache;
+ else
+ pentity = entity = anchor->entities;
+ while (entity) {
+ offset = anchor->position + entity->offset;
+
+ if (offset > position) {
+ retval = next_anchor = False;
+ break;
+ }
+ if (offset + entity->length > position) {
+ retval = True;
+ next_anchor = False;
+ break;
+ }
+ pentity = entity;
+ entity = entity->next;
+ }
+
+ if (next_anchor) {
+ *anchor_return = anchor = XawTextSourceNextAnchor(w, anchor);
+ *entity_return = anchor ? anchor->entities : NULL;
+ }
+ else {
+ *anchor_return = anchor;
+ *entity_return = retval ? entity : pentity;
+ }
+
+ if (*anchor_return)
+ (*anchor_return)->cache = *entity_return;
+
+ return (retval);
+}
+
+XawTextAnchor *
+XawTextSourceNextAnchor(Widget w, XawTextAnchor *anchor)
+{
+ int i;
+ TextSrcObject src = (TextSrcObject)w;
+
+ for (i = 0; i < src->textSrc.num_anchors - 1; i++)
+ if (src->textSrc.anchors[i] == anchor)
+ return (src->textSrc.anchors[i + 1]);
+
+ return (NULL);
+}
+
+XawTextAnchor *
+XawTextSourcePrevAnchor(Widget w, XawTextAnchor *anchor)
+{
+ int i;
+ TextSrcObject src = (TextSrcObject)w;
+
+ for (i = src->textSrc.num_anchors - 1; i > 0; i--)
+ if (src->textSrc.anchors[i] == anchor)
+ return (src->textSrc.anchors[i - 1]);
+
+ return (NULL);
+}
+
+XawTextAnchor *
+XawTextSourceRemoveAnchor(Widget w, XawTextAnchor *anchor)
+{
+ int i;
+ TextSrcObject src = (TextSrcObject)w;
+
+ for (i = 0; i < src->textSrc.num_anchors; i++)
+ if (src->textSrc.anchors[i] == anchor)
+ break;
+
+ if (i == 0)
+ return (src->textSrc.num_anchors > 1 ? src->textSrc.anchors[1] : NULL);
+
+ if (i < src->textSrc.num_anchors) {
+ XtFree((XtPointer)anchor);
+ if (i < --src->textSrc.num_anchors) {
+ memmove(&src->textSrc.anchors[i],
+ &src->textSrc.anchors[i + 1],
+ (src->textSrc.num_anchors - i) *
+ sizeof(XawTextAnchor*));
+
+ return (src->textSrc.anchors[i]);
+ }
+ }
+
+ return (NULL);
+}
+
+XawTextEntity *
+XawTextSourceAddEntity(Widget w, int type, int flags, XtPointer data,
+ XawTextPosition position, Cardinal length,
+ XrmQuark property)
+{
+ XawTextAnchor *next, *anchor = _XawTextSourceFindAnchor(w, position);
+ XawTextEntity *entity, *eprev;
+
+ /* There is no support for zero length entities for now */
+ if (length == 0)
+ return (NULL);
+
+ if (anchor->cache && anchor->position + anchor->cache->offset +
+ anchor->cache->length <= position)
+ eprev = entity = anchor->cache;
+ else
+ eprev = entity = anchor->entities;
+
+ while (entity && anchor->position + entity->offset + entity->length <=
+ position) {
+ eprev = entity;
+ entity = entity->next;
+ }
+ if (entity && anchor->position + entity->offset < position + length) {
+ fprintf(stderr, "Cannot (yet) add more than one entity to same region.\n");
+ return (NULL);
+ }
+
+ next = XawTextSourceFindAnchor(w, position + length);
+ if (next && next != anchor) {
+ if ((entity = next->entities) != NULL) {
+ if (next->position + entity->offset < position + length) {
+ fprintf(stderr, "Cannot (yet) add more than one entity to same region.\n");
+ return (NULL);
+ }
+ }
+ if (position + length > next->position) {
+ XawTextPosition diff = position + length - next->position;
+
+ next->position += diff;
+ entity = next->entities;
+ while (entity) {
+ entity->offset -= diff;
+ entity = entity->next;
+ }
+ entity = anchor->entities;
+ while (entity && entity->offset < 0)
+ entity = entity->next;
+ if (entity && entity->offset < 0) {
+ if (eprev)
+ eprev->next = next->entities;
+ else
+ anchor->entities = next->entities;
+ if ((next->entities = entity->next) == NULL)
+ (void)XawTextSourceRemoveAnchor(w, next);
+ entity->next = NULL;
+
+ return (XawTextSourceAddEntity(w, type, flags, data, position,
+ length, property));
+ }
+ }
+ }
+
+ /* Automatically join sequential entities if possible */
+ if (eprev &&
+ anchor->position + eprev->offset + eprev->length == position &&
+ eprev->property == property && eprev->type == type &&
+ eprev->flags == flags && eprev->data == data) {
+ eprev->length += length;
+ return (eprev);
+ }
+
+ entity = XtNew(XawTextEntity);
+ entity->type = type;
+ entity->flags = flags;
+ entity->data = data;
+ entity->offset = position - anchor->position;
+ entity->length = length;
+ entity->property = property;
+
+ if (eprev == NULL) {
+ anchor->entities = entity;
+ entity->next = NULL;
+ anchor->cache = NULL;
+ }
+ else if (eprev->offset > entity->offset) {
+ anchor->cache = NULL;
+ anchor->entities = entity;
+ entity->next = eprev;
+ }
+ else {
+ anchor->cache = eprev;
+ entity->next = eprev->next;
+ eprev->next = entity;
+ }
+
+ return (entity);
+}
+
+void
+XawTextSourceClearEntities(Widget w, XawTextPosition left, XawTextPosition right)
+{
+ XawTextAnchor *anchor = XawTextSourceFindAnchor(w, left);
+ XawTextEntity *entity, *eprev, *enext;
+ XawTextPosition offset;
+ int length;
+
+ while (anchor && anchor->entities == NULL)
+ anchor = XawTextSourceRemoveAnchor(w, anchor);
+
+ if (anchor == NULL || left >= right)
+ return;
+
+ if (anchor->cache && anchor->position + anchor->cache->offset +
+ anchor->cache->length < left)
+ eprev = entity = anchor->cache;
+ else
+ eprev = entity = anchor->entities;
+
+ /* find first entity before left position */
+ while (anchor->position + entity->offset + entity->length < left) {
+ eprev = entity;
+ if ((entity = entity->next) == NULL) {
+ if ((anchor = XawTextSourceNextAnchor(w, anchor)) == NULL)
+ return;
+ if ((eprev = entity = anchor->entities) == NULL) {
+ fprintf(stderr, "Bad anchor found!\n");
+ return;
+ }
+ }
+ }
+
+ offset = anchor->position + entity->offset;
+ if (offset <= left) {
+ length = XawMin(entity->length, left - offset);
+
+ if (length <= 0) {
+ enext = entity->next;
+ eprev->next = enext;
+ XtFree((XtPointer)entity);
+ anchor->cache = NULL;
+ if (entity == anchor->entities) {
+ eprev = NULL;
+ if ((anchor->entities = enext) == NULL) {
+ if ((anchor = XawTextSourceRemoveAnchor(w, anchor)) == NULL)
+ return;
+ entity = anchor->entities;
+ }
+ else
+ entity = enext;
+ }
+ else
+ entity = enext;
+ }
+ else {
+ entity->length = length;
+ eprev = entity;
+ entity = entity->next;
+ }
+ }
+
+ /* clean everything until right position is reached */
+ while (anchor) {
+ while (entity) {
+ offset = anchor->position + entity->offset + entity->length;
+
+ if (offset > right) {
+ anchor->cache = NULL;
+ entity->offset = XawMax(entity->offset, right - anchor->position);
+ entity->length = XawMin(entity->length, offset - right);
+ return;
+ }
+
+ enext = entity->next;
+ if (eprev)
+ eprev->next = enext;
+ XtFree((XtPointer)entity);
+ if (entity == anchor->entities) {
+ eprev = anchor->cache = NULL;
+ if ((anchor->entities = enext) == NULL) {
+ if ((anchor = XawTextSourceRemoveAnchor(w, anchor)) == NULL)
+ return;
+ entity = anchor->entities;
+ continue;
+ }
+ }
+ entity = enext;
+ }
+ if (anchor)
+ anchor->cache = NULL;
+ if ((anchor = XawTextSourceNextAnchor(w, anchor)) != NULL)
+ entity = anchor->entities;
+ eprev = NULL;
+ }
+}
+
+/* checks the anchors up to position, and create an appropriate anchor
+ * at position, if required.
+ */
+XawTextAnchor *
+_XawTextSourceFindAnchor(Widget w, XawTextPosition position)
+{
+ XawTextAnchor *anchor;
+
+ anchor = XawTextSourceFindAnchor(w, position);
+
+ position -= position % ANCHORS_DIST;
+
+ if (position - anchor->position >= ANCHORS_DIST)
+ return (XawTextSourceAddAnchor(w, position));
+
+ return (anchor);
+}
+#endif
diff --git a/nx-X11/lib/Xaw/TextSrc.h b/nx-X11/lib/Xaw/TextSrc.h
new file mode 100644
index 000000000..817132d48
--- /dev/null
+++ b/nx-X11/lib/Xaw/TextSrc.h
@@ -0,0 +1,280 @@
+/*
+ * $Xorg: TextSrc.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/TextSrc.h,v 1.11 2001/01/17 19:42:35 dawes Exp $ */
+
+#ifndef _XawTextSrc_h
+#define _XawTextSrc_h
+
+#include <X11/Xaw/Text.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ callback Callback Callback NULL
+ editType EditType XawTextEditType XawtextRead
+ enableUndo Undo Boolean False
+ sourceChanged Changed Boolean False
+
+*/
+
+/* Class record constants */
+extern WidgetClass textSrcObjectClass;
+
+typedef struct _TextSrcClassRec *TextSrcObjectClass;
+typedef struct _TextSrcRec *TextSrcObject;
+
+typedef enum {
+ XawstPositions,
+ XawstWhiteSpace,
+ XawstEOL,
+ XawstParagraph,
+ XawstAll,
+ XawstAlphaNumeric
+ } XawTextScanType;
+
+typedef enum {
+ Normal,
+ Selected
+} highlightType;
+
+typedef enum {
+ XawsmTextSelect,
+ XawsmTextExtend
+} XawTextSelectionMode;
+
+typedef enum {
+ XawactionStart,
+ XawactionAdjust,
+ XawactionEnd
+} XawTextSelectionAction;
+
+#define XawTextReadError -1
+#define XawTextScanError -1
+
+#ifndef OLDXAW
+#define XtNenableUndo "enableUndo"
+#define XtCUndo "Undo"
+
+#define XtNsourceChanged "sourceChanged"
+#define XtCChanged "Changed"
+
+#define XtNpropertyCallback "propertyCallback"
+#endif
+
+/*
+ * Public Functions
+ */
+_XFUNCPROTOBEGIN
+
+/*
+ * Function:
+ * XawTextSourceRead
+ *
+ * Parameters:
+ * w - TextSrc Object
+ * pos - position of the text to retreive
+ * text - text block that will contain returned text
+ * length - maximum number of characters to read
+ *
+ * Description:
+ * This function reads the source.
+ *
+ * Returns:
+ * The number of characters read into the buffer
+ */
+XawTextPosition XawTextSourceRead
+(
+ Widget w,
+ XawTextPosition pos,
+ XawTextBlock *text_return,
+ int length
+ );
+
+/*
+ * Function:
+ * XawTextSourceReplace
+ *
+ * Parameters:
+ * src - Text Source Object
+ * startPos - ends of text that will be removed
+ * endPos - ""
+ * text - new text to be inserted into buffer at startPos
+ *
+ * Description:
+ * Replaces a block of text with new text
+ *
+ * Returns:
+ * XawEditError or XawEditDone
+ */
+int XawTextSourceReplace
+(
+ Widget w,
+ XawTextPosition start,
+ XawTextPosition end,
+ XawTextBlock *text
+ );
+
+/*
+ * Function:
+ * XawTextSourceScan
+ *
+ * Parameters:
+ * w - TextSrc Object
+ * position - position to start scanning
+ * type - type of thing to scan for
+ * dir - direction to scan
+ * count - which occurance if this thing to search for
+ * include - whether or not to include the character found in
+ * the position that is returned.
+ *
+ * Description:
+ * Scans the text source for the number and type of item specified.
+ *
+ * Returns:
+ * The position of the text
+ */
+XawTextPosition XawTextSourceScan
+(
+ Widget w,
+ XawTextPosition position,
+#if NeedWidePrototypes
+ int type,
+ int dir,
+ int count,
+ int include
+#else
+ XawTextScanType type,
+ XawTextScanDirection dir,
+ int count,
+ Boolean include
+#endif
+ );
+
+/*
+ * Function:
+ * XawTextSourceSearch
+ *
+ * Parameters:
+ * w - TextSource Object
+ * position - position to start scanning
+ * dir - direction to search
+ * text - the text block to search for
+ *
+ * Description:
+ * Searchs the text source for the text block passed.
+ *
+ * Returns:
+ * The position of the text we are searching for or XawTextSearchError
+ */
+XawTextPosition XawTextSourceSearch
+(
+ Widget w,
+ XawTextPosition position,
+#if NeedWidePrototypes
+ int dir,
+#else
+ XawTextScanDirection dir,
+#endif
+ XawTextBlock *text
+ );
+
+/*
+ * Function:
+ * XawTextSourceConvertSelection
+ *
+ * Parameters:
+ * w - TextSrc object
+ * selection - current selection atom
+ * target - current target atom
+ * type - type to conver the selection to
+ * value - return value that has been converted
+ * length - ""
+ * format - format of the returned value
+ *
+ * Returns:
+ * True if the selection has been converted
+ */
+Boolean XawTextSourceConvertSelection
+(
+ Widget w,
+ Atom *selection,
+ Atom *target,
+ Atom *type,
+ XtPointer *value_return,
+ unsigned long *length_return,
+ int *format_return
+ );
+
+/*
+ * Function:
+ * XawTextSourceSetSelection
+ *
+ * Parameters:
+ * w - TextSrc object
+ * left - bounds of the selection
+ * right - ""
+ * selection - selection atom
+ *
+ * Description:
+ * Allows special setting of the selection.
+ */
+void XawTextSourceSetSelection
+(
+ Widget w,
+ XawTextPosition start,
+ XawTextPosition end,
+ Atom selection
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XawTextSrc_h */
diff --git a/nx-X11/lib/Xaw/TextSrcP.h b/nx-X11/lib/Xaw/TextSrcP.h
new file mode 100644
index 000000000..e26557b90
--- /dev/null
+++ b/nx-X11/lib/Xaw/TextSrcP.h
@@ -0,0 +1,264 @@
+/*
+* $Xorg: TextSrcP.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/TextSrcP.h,v 1.14 2001/12/14 19:54:45 dawes Exp $ */
+
+#ifndef _XawTextSrcP_h
+#define _XawTextSrcP_h
+
+/*
+ * TextSrc Object Private Data
+ */
+#include <X11/Xfuncproto.h>
+
+#include <X11/Xaw/TextSrc.h>
+#include <X11/Xaw/TextP.h> /* This source works with the Text widget */
+
+_XFUNCPROTOBEGIN
+
+#ifndef OLDXAW
+struct _XawTextAnchor {
+ XawTextPosition position;
+ XawTextEntity *entities, *cache;
+};
+
+#define XAW_TENTF_HIDE 0x0001
+#define XAW_TENTF_READ 0x0002
+#define XAW_TENTF_REPLACE 0x0004
+struct _XawTextEntity {
+ short type;
+ short flags;
+ XawTextEntity *next;
+ XtPointer data;
+ XawTextPosition offset; /* from the anchor */
+ Cardinal length;
+ XrmQuark property;
+};
+#endif
+
+#if 0 /* no longer used */
+/* New fields for the TextSrc object class */
+typedef struct {
+ XtPointer next_extension;
+ XrmQuark record_type;
+ long version;
+ Cardinal record_size;
+ int (*Input)();
+} TextSrcExtRec, *TextSrcExt;
+#endif
+
+typedef XawTextPosition (*_XawSrcReadProc)
+ (Widget, XawTextPosition, XawTextBlock*, int);
+
+typedef int (*_XawSrcReplaceProc)
+ (Widget, XawTextPosition, XawTextPosition, XawTextBlock*);
+
+typedef XawTextPosition (*_XawSrcScanProc)
+ (Widget, XawTextPosition, XawTextScanType, XawTextScanDirection,
+ int, Bool);
+
+typedef XawTextPosition (*_XawSrcSearchProc)
+ (Widget, XawTextPosition, XawTextScanDirection, XawTextBlock*);
+
+typedef void (*_XawSrcSetSelectionProc)
+ (Widget, XawTextPosition, XawTextPosition, Atom);
+
+typedef Boolean (*_XawSrcConvertSelectionProc)
+ (Widget, Atom*, Atom*, Atom*, XtPointer*, unsigned long*, int*);
+
+typedef struct _TextSrcClassPart {
+ _XawSrcReadProc Read;
+ _XawSrcReplaceProc Replace;
+ _XawSrcScanProc Scan;
+ _XawSrcSearchProc Search;
+ _XawSrcSetSelectionProc SetSelection;
+ _XawSrcConvertSelectionProc ConvertSelection;
+#ifndef OLDXAW
+ XtPointer extension;
+#endif
+} TextSrcClassPart;
+
+/* Full class record */
+typedef struct _TextSrcClassRec {
+ ObjectClassPart object_class;
+ TextSrcClassPart textSrc_class;
+} TextSrcClassRec;
+
+extern TextSrcClassRec textSrcClassRec;
+
+#ifndef OLDXAW
+typedef struct _XawTextUndo XawTextUndo;
+#endif
+
+/* New fields for the TextSrc object */
+typedef struct {
+ /* resources */
+ XawTextEditType edit_mode;
+ XrmQuark text_format; /* 2 formats: FMT8BIT for Ascii
+ FMTWIDE for ISO 10646 */
+#ifndef OLDXAW
+ XtCallbackList callback; /* A callback list to call when the
+ source is changed */
+ Boolean changed;
+ Boolean enable_undo;
+
+ /* private state */
+ Boolean undo_state; /* to protect undo manipulation */
+ XawTextUndo *undo;
+ WidgetList text; /* TextWidget's using this source */
+ Cardinal num_text;
+ XtCallbackList property_callback;
+ XawTextAnchor **anchors;
+ int num_anchors;
+ XtPointer pad[1]; /* for future use and keep binary compatability */
+#endif
+} TextSrcPart;
+
+/* Full instance record */
+typedef struct _TextSrcRec {
+ ObjectPart object;
+ TextSrcPart textSrc;
+} TextSrcRec;
+
+/*
+ * Semiprivate declarations of functions used in other modules
+ */
+char* _XawTextWCToMB
+(
+ Display *display,
+ wchar_t *wstr,
+ int *len_in_out
+ );
+
+wchar_t* _XawTextMBToWC
+(
+ Display *display,
+ char *str,
+ int *len_in_out
+ );
+
+#ifndef OLDXAW
+XawTextAnchor *XawTextSourceAddAnchor
+(
+ Widget source,
+ XawTextPosition position
+ );
+
+XawTextAnchor *XawTextSourceFindAnchor
+(
+ Widget source,
+ XawTextPosition position
+ );
+
+XawTextAnchor *XawTextSourceNextAnchor
+(
+ Widget source,
+ XawTextAnchor *anchor
+ );
+
+XawTextAnchor *XawTextSourcePrevAnchor
+(
+ Widget source,
+ XawTextAnchor *anchor
+ );
+
+XawTextAnchor *XawTextSourceRemoveAnchor
+(
+ Widget source,
+ XawTextAnchor *anchor
+ );
+
+Bool XawTextSourceAnchorAndEntity
+(
+ Widget w,
+ XawTextPosition position,
+ XawTextAnchor **anchor_return,
+ XawTextEntity **entity_return
+ );
+
+XawTextEntity *XawTextSourceAddEntity
+(
+ Widget source,
+ int type,
+ int flags,
+ XtPointer data,
+ XawTextPosition position,
+ Cardinal length,
+ XrmQuark property
+ );
+
+void XawTextSourceClearEntities
+(
+ Widget w,
+ XawTextPosition left,
+ XawTextPosition right
+ );
+#endif
+
+#if 0 /* no longer used */
+typedef XawTextPosition (*_XawTextPositionFunc)();
+#endif
+
+#define XtInheritInput ((_XawTextPositionFunc)_XtInherit)
+#define XtInheritRead ((_XawSrcReadProc)_XtInherit)
+#define XtInheritReplace ((_XawSrcReplaceProc)_XtInherit)
+#define XtInheritScan ((_XawSrcScanProc)_XtInherit)
+#define XtInheritSearch ((_XawSrcSearchProc)_XtInherit)
+#define XtInheritSetSelection ((_XawSrcSetSelectionProc)_XtInherit)
+#define XtInheritConvertSelection ((_XawSrcConvertSelectionProc)_XtInherit)
+#if 0
+#define XtTextSrcExtVersion 1
+#define XtTextSrcExtTypeString "XT_TEXTSRC_EXT"
+#endif
+
+_XFUNCPROTOEND
+
+#endif /* _XawTextSrcP_h */
diff --git a/nx-X11/lib/Xaw/TextTr.c b/nx-X11/lib/Xaw/TextTr.c
new file mode 100644
index 000000000..c918ee6db
--- /dev/null
+++ b/nx-X11/lib/Xaw/TextTr.c
@@ -0,0 +1,159 @@
+/* $Xorg: TextTr.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xaw/TextTr.c,v 3.15 2001/01/17 19:42:35 dawes Exp $ */
+
+/* INTERNATIONALIZATION:
+
+The OMRON R5 contrib added the following action to the old TextTr:
+
+ Ctrl<Key>backslash: reconnect-im()
+
+This is needed when the im is killed or otherwise becomes unreachable.
+This keystroke is evil (inconvenient, hard-to-remember, not obvious)
+so I am adding one more translation:
+
+ <Key>Kanji: reconnect-im()
+
+The Japanese user typically hits their Kanji key when they want to do
+input. This merely makes sure the input is connected.
+*/
+
+char _XawDefaultTextTranslations[] =
+"c<Key>A:" "beginning-of-line()\n"
+"c<Key>B:" "backward-character()\n"
+"c<Key>C:" "insert-selection(CUT_BUFFER0)\n"
+"c<Key>D:" "delete-next-character()\n"
+"c<Key>E:" "end-of-line()\n"
+"c<Key>F:" "forward-character()\n"
+#ifndef OLDXAW
+"c<Key>G:" "keyboard-reset()\n"
+#else
+"c<Key>G:" "multiply(Reset)\n"
+#endif
+"c<Key>H:" "delete-previous-character()\n"
+"c<Key>J:" "newline-and-indent()\n"
+"c<Key>K:" "kill-to-end-of-line()\n"
+"c<Key>L:" "redraw-display()\n"
+"c<Key>M:" "newline()\n"
+"c<Key>N:" "next-line()\n"
+"c<Key>O:" "newline-and-backup()\n"
+"c<Key>P:" "previous-line()\n"
+"c<Key>R:" "search(backward)\n"
+"c<Key>S:" "search(forward)\n"
+"c<Key>T:" "transpose-characters()\n"
+#ifndef OLDXAW
+"c<Key>U:" "multiply(Start)\n"
+#else
+"c<Key>U:" "multiply(4)\n"
+#endif
+"c<Key>V:" "next-page()\n"
+"c<Key>W:" "kill-selection()\n"
+"c<Key>Y:" "insert-selection(SECONDARY)\n"
+"c<Key>Z:" "scroll-one-line-up()\n"
+"m<Key>B:" "backward-word()\n"
+"m<Key>C:" "capitalize-word()\n"
+"m<Key>F:" "forward-word()\n"
+"m<Key>I:" "insert-file()\n"
+"m<Key>K:" "kill-to-end-of-paragraph()\n"
+"m<Key>L:" "downcase-word()\n"
+"m<Key>Q:" "form-paragraph()\n"
+"m<Key>U:" "upcase-word()\n"
+"m<Key>V:" "previous-page()\n"
+#ifndef OLDXAW
+"m<Key>Y:" "kill-ring-yank()\n"
+#endif
+"m<Key>Z:" "scroll-one-line-down()\n"
+"~s m<Key>d:" "kill-word(alnum)\n"
+"s m<Key>d:" "delete-next-word(alnum)\n"
+"~s m<Key>h:" "backward-kill-word(alnum)\n"
+"s m<Key>h:" "delete-previous-word(alnum)\n"
+":m<Key>\\<:" "beginning-of-file()\n"
+":m<Key>\\>:" "end-of-file()\n"
+":m<Key>]:" "forward-paragraph()\n"
+":m<Key>[:" "backward-paragraph()\n"
+"~s m<Key>Delete:" "backward-kill-word(alnum)\n"
+"s m<Key>Delete:" "delete-previous-word(alnum)\n"
+"~s m<Key>BackSpace:" "backward-kill-word(alnum)\n"
+"s m<Key>BackSpace:" "delete-previous-word(alnum)\n"
+"c<Key>Left:" "backward-word(alnum)\n"
+"c<Key>Right:" "forward-word(alnum)\n"
+"c<Key>Up:" "backward-paragraph()\n"
+"c<Key>Down:" "forward-paragraph()\n"
+"<Key>Home:" "beginning-of-file()\n"
+":<Key>KP_Home:" "beginning-of-file()\n"
+"<Key>End:" "end-of-file()\n"
+":<Key>KP_End:" "end-of-file()\n"
+"<Key>Next:" "next-page()\n"
+":<Key>KP_Next:" "next-page()\n"
+"<Key>Prior:" "previous-page()\n"
+":<Key>KP_Prior:" "previous-page()\n"
+"<Key>Right:" "forward-character()\n"
+":<Key>KP_Right:" "forward-character()\n"
+"<Key>Left:" "backward-character()\n"
+":<Key>KP_Left:" "backward-character()\n"
+"<Key>Down:" "next-line()\n"
+":<Key>KP_Down:" "next-line()\n"
+"<Key>Up:" "previous-line()\n"
+":<Key>KP_Up:" "previous-line()\n"
+"<Key>Delete:" "delete()\n"
+":<Key>KP_Delete:" "delete()\n"
+"<Key>BackSpace:" "delete-previous-character()\n"
+"<Key>Linefeed:" "newline-and-indent()\n"
+"<Key>Return:" "newline()\n"
+":<Key>KP_Enter:" "newline()\n"
+"c<Key>backslash:" "reconnect-im()\n"
+"<Key>Kanji:" "reconnect-im()\n"
+#ifndef OLDXAW
+":<Key>0:" "numeric(0)\n"
+":<Key>1:" "numeric(1)\n"
+":<Key>2:" "numeric(2)\n"
+":<Key>3:" "numeric(3)\n"
+":<Key>4:" "numeric(4)\n"
+":<Key>5:" "numeric(5)\n"
+":<Key>6:" "numeric(6)\n"
+":<Key>7:" "numeric(7)\n"
+":<Key>8:" "numeric(8)\n"
+":<Key>9:" "numeric(9)\n"
+":<Key>-:" "numeric(-)\n"
+":c<Key>_:" "undo()\n"
+#endif
+"s <Key>Insert:" "insert-selection(PRIMARY, CUT_BUFFER0)\n"
+"<Ctrl>Q,<Key>:" "insert-char()\n"
+"<Key>:" "insert-char()\n"
+"<Enter>:" "enter-window()\n"
+"<Leave>:" "leave-window()\n"
+"<FocusIn>:" "focus-in()\n"
+"<FocusOut>:" "focus-out()\n"
+"<Btn1Down>:" "select-start()\n"
+"<Btn1Motion>:" "extend-adjust()\n"
+"<Btn1Up>:" "extend-end(PRIMARY, CUT_BUFFER0)\n"
+"<Btn2Down>:" "insert-selection(PRIMARY, CUT_BUFFER0)\n"
+"<Btn3Down>:" "extend-start()\n"
+"<Btn3Motion>:" "extend-adjust()\n"
+"<Btn3Up>:" "extend-end(PRIMARY, CUT_BUFFER0)\n"
+;
diff --git a/nx-X11/lib/Xaw/Tip.c b/nx-X11/lib/Xaw/Tip.c
new file mode 100644
index 000000000..3c4b79437
--- /dev/null
+++ b/nx-X11/lib/Xaw/Tip.c
@@ -0,0 +1,638 @@
+/*
+ * Copyright (c) 1999 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ *
+ * Author: Paulo César Pereira de Andrade
+ */
+
+/* $XFree86: xc/lib/Xaw/Tip.c,v 1.4 1999/07/11 08:49:16 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xos.h>
+#include <X11/Xaw/TipP.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xmu/Converters.h>
+#include "Private.h"
+
+#define TIP_EVENT_MASK (ButtonPressMask | \
+ ButtonReleaseMask | \
+ PointerMotionMask | \
+ ButtonMotionMask | \
+ KeyPressMask | \
+ KeyReleaseMask | \
+ EnterWindowMask | \
+ LeaveWindowMask)
+
+/*
+ * Types
+ */
+typedef struct _XawTipInfo {
+ Screen *screen;
+ TipWidget tip;
+ Widget widget;
+ Bool mapped;
+ struct _XawTipInfo *next;
+} XawTipInfo;
+
+/*
+ * Class Methods
+ */
+static void XawTipClassInitialize(void);
+static void XawTipInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawTipDestroy(Widget);
+static void XawTipExpose(Widget, XEvent*, Region);
+static void XawTipRealize(Widget, Mask*, XSetWindowAttributes*);
+static Boolean XawTipSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static void TipEventHandler(Widget, XtPointer, XEvent*, Boolean*);
+static void TipShellEventHandler(Widget, XtPointer, XEvent*, Boolean*);
+static XawTipInfo *CreateTipInfo(Widget);
+static XawTipInfo *FindTipInfo(Widget);
+static void ResetTip(XawTipInfo*, Bool);
+static void TipTimeoutCallback(XtPointer, XtIntervalId*);
+static void TipLayout(XawTipInfo*);
+static void TipPosition(XawTipInfo*);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(TipRec, tip.field)
+static XtResource resources[] = {
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(foreground),
+ XtRString,
+ XtDefaultForeground,
+ },
+ {
+ XtNfont,
+ XtCFont,
+ XtRFontStruct,
+ sizeof(XFontStruct*),
+ offset(font),
+ XtRString,
+ XtDefaultFont
+ },
+ {
+ XtNfontSet,
+ XtCFontSet,
+ XtRFontSet,
+ sizeof(XFontSet),
+ offset(fontset),
+ XtRString,
+ XtDefaultFontSet
+ },
+ {
+ XtNtopMargin,
+ XtCVerticalMargins,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(top_margin),
+ XtRImmediate,
+ (XtPointer)2
+ },
+ {
+ XtNbottomMargin,
+ XtCVerticalMargins,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(bottom_margin),
+ XtRImmediate,
+ (XtPointer)2
+ },
+ {
+ XtNleftMargin,
+ XtCHorizontalMargins,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(left_margin),
+ XtRImmediate,
+ (XtPointer)6
+ },
+ {
+ XtNrightMargin,
+ XtCHorizontalMargins,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(right_margin),
+ XtRImmediate,
+ (XtPointer)6
+ },
+ {
+ XtNbackingStore,
+ XtCBackingStore,
+ XtRBackingStore,
+ sizeof(int),
+ offset(backing_store),
+ XtRImmediate,
+ (XtPointer)(Always + WhenMapped + NotUseful)
+ },
+ {
+ XtNtimeout,
+ XtCTimeout,
+ XtRInt,
+ sizeof(int),
+ offset(timeout),
+ XtRImmediate,
+ (XtPointer)500
+ },
+ {
+ XawNdisplayList,
+ XawCDisplayList,
+ XawRDisplayList,
+ sizeof(XawDisplayList*),
+ offset(display_list),
+ XtRImmediate,
+ NULL
+ },
+};
+#undef offset
+
+TipClassRec tipClassRec = {
+ /* core */
+ {
+ (WidgetClass)&widgetClassRec, /* superclass */
+ "Tip", /* class_name */
+ sizeof(TipRec), /* widget_size */
+ XawTipClassInitialize, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ XawTipInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XawTipRealize, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ XawTipDestroy, /* destroy */
+ NULL, /* resize */
+ XawTipExpose, /* expose */
+ XawTipSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* tip */
+ {
+ NULL, /* extension */
+ },
+};
+
+WidgetClass tipWidgetClass = (WidgetClass)&tipClassRec;
+
+static XawTipInfo *first_tip;
+
+/*
+ * Implementation
+ */
+static void
+XawTipClassInitialize(void)
+{
+ XawInitializeWidgetSet();
+ XtAddConverter(XtRString, XtRBackingStore, XmuCvtStringToBackingStore,
+ NULL, 0);
+ XtSetTypeConverter(XtRBackingStore, XtRString, XmuCvtBackingStoreToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+
+/*ARGSUSED*/
+static void
+XawTipInitialize(Widget req, Widget w, ArgList args, Cardinal *num_args)
+{
+ TipWidget tip = (TipWidget)w;
+ XGCValues values;
+
+ if (!tip->tip.font) XtError("Aborting: no font found\n");
+ if (tip->tip.international && !tip->tip.fontset)
+ XtError("Aborting: no fontset found\n");
+
+ tip->tip.timer = 0;
+
+ values.foreground = tip->tip.foreground;
+ values.background = tip->core.background_pixel;
+ values.font = tip->tip.font->fid;
+ values.graphics_exposures = False;
+
+ tip->tip.gc = XtAllocateGC(w, 0, GCForeground | GCBackground | GCFont |
+ GCGraphicsExposures, &values, GCFont, 0);
+}
+
+static void
+XawTipDestroy(Widget w)
+{
+ XawTipInfo *info = FindTipInfo(w);
+ TipWidget tip = (TipWidget)w;
+
+ if (tip->tip.timer)
+ XtRemoveTimeOut(tip->tip.timer);
+
+ XtReleaseGC(w, tip->tip.gc);
+
+ XtRemoveEventHandler(XtParent(w), KeyPressMask, False, TipShellEventHandler,
+ (XtPointer)NULL);
+ if (info == first_tip)
+ first_tip = first_tip->next;
+ else {
+ XawTipInfo *p = first_tip;
+
+ while (p && p->next != info)
+ p = p->next;
+ if (p)
+ p->next = info->next;
+ }
+ XtFree((char*)info);
+}
+
+static void
+XawTipRealize(Widget w, Mask *mask, XSetWindowAttributes *attr)
+{
+ TipWidget tip = (TipWidget)w;
+
+ if (tip->tip.backing_store == Always ||
+ tip->tip.backing_store == NotUseful ||
+ tip->tip.backing_store == WhenMapped) {
+ *mask |= CWBackingStore;
+ attr->backing_store = tip->tip.backing_store;
+ }
+ else
+ *mask &= ~CWBackingStore;
+ *mask |= CWOverrideRedirect;
+ attr->override_redirect = True;
+
+ XtWindow(w) = XCreateWindow(DisplayOfScreen(XtScreen(w)),
+ RootWindowOfScreen(XtScreen(w)),
+ XtX(w), XtY(w),
+ XtWidth(w) ? XtWidth(w) : 1,
+ XtHeight(w) ? XtHeight(w) : 1,
+ XtBorderWidth(w),
+ DefaultDepthOfScreen(XtScreen(w)),
+ InputOutput,
+ CopyFromParent,
+ *mask, attr);
+}
+
+static void
+XawTipExpose(Widget w, XEvent *event, Region region)
+{
+ TipWidget tip = (TipWidget)w;
+ GC gc = tip->tip.gc;
+ char *nl, *label = tip->tip.label;
+ Position y = tip->tip.top_margin + tip->tip.font->max_bounds.ascent;
+ int len;
+
+ if (tip->tip.display_list)
+ XawRunDisplayList(w, tip->tip.display_list, event, region);
+
+ if (tip->tip.international == True) {
+ Position ksy = tip->tip.top_margin;
+ XFontSetExtents *ext = XExtentsOfFontSet(tip->tip.fontset);
+
+ ksy += XawAbs(ext->max_ink_extent.y);
+
+ while ((nl = index(label, '\n')) != NULL) {
+ XmbDrawString(XtDisplay(w), XtWindow(w), tip->tip.fontset,
+ gc, tip->tip.left_margin, ksy, label,
+ (int)(nl - label));
+ ksy += ext->max_ink_extent.height;
+ label = nl + 1;
+ }
+ len = strlen(label);
+ if (len)
+ XmbDrawString(XtDisplay(w), XtWindow(w), tip->tip.fontset, gc,
+ tip->tip.left_margin, ksy, label, len);
+ }
+ else {
+ while ((nl = index(label, '\n')) != NULL) {
+ if (tip->tip.encoding)
+ XDrawString16(XtDisplay(w), XtWindow(w), gc,
+ tip->tip.left_margin, y,
+ (XChar2b*)label, (int)(nl - label) >> 1);
+ else
+ XDrawString(XtDisplay(w), XtWindow(w), gc,
+ tip->tip.left_margin, y, label, (int)(nl - label));
+ y += tip->tip.font->max_bounds.ascent +
+ tip->tip.font->max_bounds.descent;
+ label = nl + 1;
+ }
+ len = strlen(label);
+ if (len) {
+ if (tip->tip.encoding)
+ XDrawString16(XtDisplay(w), XtWindow(w), gc,
+ tip->tip.left_margin, y, (XChar2b*)label, len >> 1);
+ else
+ XDrawString(XtDisplay(w), XtWindow(w), gc,
+ tip->tip.left_margin, y, label, len);
+ }
+ }
+}
+
+/*ARGSUSED*/
+static Boolean
+XawTipSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ TipWidget curtip = (TipWidget)current;
+ TipWidget newtip = (TipWidget)cnew;
+ Boolean redisplay = False;
+
+ if (curtip->tip.font->fid != newtip->tip.font->fid ||
+ curtip->tip.foreground != newtip->tip.foreground) {
+ XGCValues values;
+
+ values.foreground = newtip->tip.foreground;
+ values.background = newtip->core.background_pixel;
+ values.font = newtip->tip.font->fid;
+ values.graphics_exposures = False;
+ XtReleaseGC(cnew, curtip->tip.gc);
+ newtip->tip.gc = XtAllocateGC(cnew, 0, GCForeground | GCBackground |
+ GCFont | GCGraphicsExposures, &values,
+ GCFont, 0);
+ redisplay = True;
+ }
+ if (curtip->tip.display_list != newtip->tip.display_list)
+ redisplay = True;
+
+ return (redisplay);
+}
+
+static void
+TipLayout(XawTipInfo *info)
+{
+ XFontStruct *fs = info->tip->tip.font;
+ int width = 0, height;
+ char *nl, *label = info->tip->tip.label;
+
+ if (info->tip->tip.international == True) {
+ XFontSet fset = info->tip->tip.fontset;
+ XFontSetExtents *ext = XExtentsOfFontSet(fset);
+
+ height = ext->max_ink_extent.height;
+ if ((nl = index(label, '\n')) != NULL) {
+ /*CONSTCOND*/
+ while (True) {
+ int w = XmbTextEscapement(fset, label, (int)(nl - label));
+
+ if (w > width)
+ width = w;
+ if (*nl == '\0')
+ break;
+ label = nl + 1;
+ if (*label)
+ height += ext->max_ink_extent.height;
+ if ((nl = index(label, '\n')) == NULL)
+ nl = index(label, '\0');
+ }
+ }
+ else
+ width = XmbTextEscapement(fset, label, strlen(label));
+ }
+ else {
+ height = fs->max_bounds.ascent + fs->max_bounds.descent;
+ if ((nl = index(label, '\n')) != NULL) {
+ /*CONSTCOND*/
+ while (True) {
+ int w = info->tip->tip.encoding ?
+ XTextWidth16(fs, (XChar2b*)label, (int)(nl - label) >> 1) :
+ XTextWidth(fs, label, (int)(nl - label));
+ if (w > width)
+ width = w;
+ if (*nl == '\0')
+ break;
+ label = nl + 1;
+ if (*label)
+ height += fs->max_bounds.ascent + fs->max_bounds.descent;
+ if ((nl = index(label, '\n')) == NULL)
+ nl = index(label, '\0');
+ }
+ }
+ else
+ width = info->tip->tip.encoding ?
+ XTextWidth16(fs, (XChar2b*)label, strlen(label) >> 1) :
+ XTextWidth(fs, label, strlen(label));
+ }
+ XtWidth(info->tip) = width + info->tip->tip.left_margin +
+ info->tip->tip.right_margin;
+ XtHeight(info->tip) = height + info->tip->tip.top_margin +
+ info->tip->tip.bottom_margin;
+}
+
+#define DEFAULT_TIP_Y_OFFSET 12
+static void
+TipPosition(XawTipInfo *info)
+{
+ Window r, c;
+ int rx, ry, wx, wy;
+ unsigned mask;
+ Position x, y;
+
+ XQueryPointer(XtDisplay((Widget)info->tip), XtWindow((Widget)info->tip),
+ &r, &c, &rx, &ry, &wx, &wy, &mask);
+ x = rx - (XtWidth(info->tip) >> 1);
+ y = ry + DEFAULT_TIP_Y_OFFSET;
+
+ if (x >= 0) {
+ int scr_width = WidthOfScreen(XtScreen(info->tip));
+
+ if (x + XtWidth(info->tip) + XtBorderWidth(info->tip) > scr_width)
+ x = scr_width - XtWidth(info->tip) - XtBorderWidth(info->tip);
+ }
+ if (x < 0)
+ x = 0;
+ if (y >= 0) {
+ int scr_height = HeightOfScreen(XtScreen(info->tip));
+
+ if (y + XtHeight(info->tip) + XtBorderWidth(info->tip) > scr_height)
+ y -= XtHeight(info->tip) + XtBorderWidth(info->tip) +
+ (DEFAULT_TIP_Y_OFFSET << 1);
+ }
+ if (y < 0)
+ y = 0;
+
+ XMoveResizeWindow(XtDisplay(info->tip), XtWindow(info->tip),
+ (int)(XtX(info->tip) = x), (int)(XtY(info->tip) = y),
+ (unsigned)XtWidth(info->tip), (unsigned)XtHeight(info->tip));
+}
+
+static XawTipInfo *
+CreateTipInfo(Widget w)
+{
+ XawTipInfo *info = XtNew(XawTipInfo);
+ Widget shell = w;
+
+ info->screen = XtScreen(w);
+
+ while (XtParent(shell))
+ shell = XtParent(shell);
+
+ info->tip = (TipWidget)XtCreateWidget("tip", tipWidgetClass, shell, NULL, 0);
+ XtRealizeWidget((Widget)info->tip);
+ info->widget = NULL;
+ info->mapped = False;
+ info->next = NULL;
+ XtAddEventHandler(shell, KeyPressMask, False, TipShellEventHandler,
+ (XtPointer)NULL);
+
+ return (info);
+}
+
+static XawTipInfo *
+FindTipInfo(Widget w)
+{
+ XawTipInfo *ptip, *tip = first_tip;
+ Screen *screen = XtScreenOfObject(w);
+
+ if (tip == NULL)
+ return (first_tip = tip = CreateTipInfo(w));
+
+ for (ptip = tip; tip; ptip = tip, tip = tip->next)
+ if (tip->screen == screen)
+ return (tip);
+
+ return (ptip->next = CreateTipInfo(w));
+}
+
+static void
+ResetTip(XawTipInfo *info, Bool add_timeout)
+{
+ if (info->tip->tip.timer) {
+ XtRemoveTimeOut(info->tip->tip.timer);
+ info->tip->tip.timer = 0;
+ }
+ if (info->mapped) {
+ XtRemoveGrab(XtParent((Widget)info->tip));
+ XUnmapWindow(XtDisplay((Widget)info->tip), XtWindow((Widget)info->tip));
+ info->mapped = False;
+ }
+ if (add_timeout) {
+ info->tip->tip.timer =
+ XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)info->tip),
+ info->tip->tip.timeout, TipTimeoutCallback,
+ (XtPointer)info);
+ }
+}
+
+static void
+TipTimeoutCallback(XtPointer closure, XtIntervalId *id)
+{
+ XawTipInfo *info = (XawTipInfo*)closure;
+ Arg args[3];
+
+ info->tip->tip.label = NULL;
+ info->tip->tip.international = False;
+ info->tip->tip.encoding = 0;
+ XtSetArg(args[0], XtNtip, &info->tip->tip.label);
+ XtSetArg(args[1], XtNinternational, &info->tip->tip.international);
+ XtSetArg(args[2], XtNencoding, &info->tip->tip.encoding);
+ XtGetValues(info->widget, args, 3);
+
+ if (info->tip->tip.label) {
+ TipLayout(info);
+ TipPosition(info);
+ XMapRaised(XtDisplay((Widget)info->tip), XtWindow((Widget)info->tip));
+ XtAddGrab(XtParent((Widget)info->tip), True, True);
+ info->mapped = True;
+ }
+}
+
+/*ARGSUSED*/
+static void
+TipShellEventHandler(Widget w, XtPointer client_data, XEvent *event,
+ Boolean *continue_to_dispatch)
+{
+ ResetTip(FindTipInfo(w), False);
+}
+
+/*ARGSUSED*/
+static void
+TipEventHandler(Widget w, XtPointer client_data, XEvent *event,
+ Boolean *continue_to_dispatch)
+{
+ XawTipInfo *info = FindTipInfo(w);
+ Boolean add_timeout;
+
+ if (info->widget != w) {
+ ResetTip(info, False);
+ info->widget = w;
+ }
+
+ switch (event->type) {
+ case EnterNotify:
+ add_timeout = True;
+ break;
+ case MotionNotify:
+ /* If any button is pressed, timer is 0 */
+ if (info->mapped)
+ return;
+ add_timeout = info->tip->tip.timer != 0;
+ break;
+ default:
+ add_timeout = False;
+ break;
+ }
+ ResetTip(info, add_timeout);
+}
+
+/*
+ * Public routines
+ */
+void
+XawTipEnable(Widget w)
+{
+ XtAddEventHandler(w, TIP_EVENT_MASK, False, TipEventHandler,
+ (XtPointer)NULL);
+}
+
+void
+XawTipDisable(Widget w)
+{
+ XawTipInfo *info = FindTipInfo(w);
+
+ XtRemoveEventHandler(w, TIP_EVENT_MASK, False, TipEventHandler,
+ (XtPointer)NULL);
+ if (info->widget == w)
+ ResetTip(info, False);
+}
diff --git a/nx-X11/lib/Xaw/Tip.h b/nx-X11/lib/Xaw/Tip.h
new file mode 100644
index 000000000..f5b8d9be5
--- /dev/null
+++ b/nx-X11/lib/Xaw/Tip.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 1999 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ *
+ * Author: Paulo César Pereira de Andrade
+ */
+
+/* $XFree86$ */
+
+#ifndef _XawTip_h
+#define _XawTip_h
+
+/*
+ * Tip Widget
+ */
+
+#include <X11/Xaw/Simple.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ backgroundPixmap BackgroundPixmap Pixmap XtUnspecifiedPixmap
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ bottomMargin VerticalMargins Dimension 2
+ destroyCallback Callback XtCallbackList NULL
+ displayList DisplayList XawDisplayList* NULL
+ font Font XFontStruct* XtDefaultFont
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension text height
+ leftMargin HorizontalMargins Dimension 6
+ rightMargin HorizontalMargins Dimension 6
+ timeout Timeout Int 500
+ topMargin VerticalMargins Dimension 2
+ width Width Dimension text width
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+typedef struct _TipClassRec *TipWidgetClass;
+typedef struct _TipRec *TipWidget;
+
+extern WidgetClass tipWidgetClass;
+
+#define XtNbottomMargin "bottomMargin"
+#define XawNdisplayList "displayList"
+#define XtNencoding "encoding"
+#define XtNleftMargin "leftMargin"
+#define XtNrightMargin "rightMargin"
+#define XtNtimeout "timeout"
+#define XtNtopMargin "topMargin"
+#define XtNtip "tip"
+
+#define XawCDisplayList "DisplayList"
+#define XtCHorizontalMargins "HorizontalMargins"
+#define XtCTimeout "Timeout"
+#define XtCVerticalMargins "VerticalMargins"
+#define XtCTip "Tip"
+
+#define XawRDisplayList "XawDisplayList"
+
+/*
+ * Public Functions
+ */
+/*
+ * Function:
+ * XawTipEnable
+ *
+ * Parameters:
+ * w - widget
+ *
+ * Description:
+ * Enables the tip event handler for this widget.
+ */
+void XawTipEnable
+(
+ Widget w
+ );
+
+/*
+ * Function:
+ * XawTipEnable
+ *
+ * Parameters:
+ * w - widget
+ *
+ * Description:
+ * Disables the tip event handler for this widget.
+ */
+void XawTipDisable
+(
+ Widget w
+ );
+
+#endif /* _XawTip_h */
diff --git a/nx-X11/lib/Xaw/TipP.h b/nx-X11/lib/Xaw/TipP.h
new file mode 100644
index 000000000..2b9e12619
--- /dev/null
+++ b/nx-X11/lib/Xaw/TipP.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 1999 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ *
+ * Author: Paulo César Pereira de Andrade
+ */
+
+/* $XFree86$ */
+
+#ifndef _XawTipP_h
+#define _XawTipP_h
+
+#include <X11/Xaw/Tip.h>
+#include <X11/CoreP.h>
+#include <X11/Xaw/XawInit.h>
+
+typedef struct {
+ XtPointer extension;
+} TipClassPart;
+
+typedef struct _TipClassRec {
+ CoreClassPart core_class;
+ TipClassPart tip_class;
+} TipClassRec;
+
+extern TipClassRec tipClassRec;
+
+typedef struct _TipPart {
+ /* resources */
+ Pixel foreground;
+ XFontStruct *font;
+ XFontSet fontset;
+ Dimension top_margin;
+ Dimension bottom_margin;
+ Dimension left_margin;
+ Dimension right_margin;
+ int backing_store;
+ int timeout;
+ XawDisplayList *display_list;
+
+ /* private */
+ GC gc;
+ XtIntervalId timer;
+ String label;
+ Boolean international;
+ unsigned char encoding;
+ XtPointer pad[4];
+} TipPart;
+
+typedef struct _TipRec {
+ CorePart core;
+ TipPart tip;
+} TipRec;
+
+#endif /* _XawTipP_h */
diff --git a/nx-X11/lib/Xaw/Toggle.c b/nx-X11/lib/Xaw/Toggle.c
new file mode 100644
index 000000000..dfbcf7677
--- /dev/null
+++ b/nx-X11/lib/Xaw/Toggle.c
@@ -0,0 +1,632 @@
+/* $Xorg: Toggle.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xaw/Toggle.c,v 1.8 2001/08/23 00:03:20 dawes Exp $ */
+
+/*
+ * Author: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ *
+ * Date: January 12, 1989
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xaw/ToggleP.h>
+#include <X11/Xaw/XawInit.h>
+
+/*
+ * Class Methods
+ */
+static void XawToggleClassInitialize(void);
+static void XawToggleInitialize(Widget, Widget, ArgList, Cardinal*);
+static Boolean XawToggleSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static void AddToRadioGroup(RadioGroup*, Widget);
+static void CreateRadioGroup(Widget, Widget);
+static RadioGroup *GetRadioGroup(Widget);
+static void RemoveFromRadioGroup(Widget);
+static void TurnOffRadioSiblings(Widget);
+static void XawToggleDestroy(Widget, XtPointer, XtPointer);
+
+/*
+ * Actions
+ */
+static void Notify(Widget, XEvent*, String*, Cardinal*);
+static void Toggle(Widget, XEvent*, String*, Cardinal*);
+static void ToggleSet(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * Initialization
+ */
+/*
+ * The order of toggle and notify are important, as the state has
+ * to be set when we call the notify proc
+ */
+static char defaultTranslations[] =
+"<Enter>:" "highlight(Always)\n"
+"<Leave>:" "unhighlight()\n"
+"<Btn1Down>,<Btn1Up>:" "toggle() notify()\n"
+;
+
+#define offset(field) XtOffsetOf(ToggleRec, field)
+static XtResource resources[] = {
+ {
+ XtNstate,
+ XtCState,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(command.set),
+ XtRString,
+ "off"
+ },
+ {
+ XtNradioGroup,
+ XtCWidget,
+ XtRWidget,
+ sizeof(Widget),
+ offset(toggle.widget),
+ XtRWidget,
+ NULL
+ },
+ {
+ XtNradioData,
+ XtCRadioData,
+ XtRPointer,
+ sizeof(XtPointer),
+ offset(toggle.radio_data),
+ XtRPointer,
+ NULL
+ },
+};
+#undef offset
+
+static XtActionsRec actionsList[] = {
+ {"toggle", Toggle},
+ {"notify", Notify},
+ {"set", ToggleSet},
+};
+
+#define Superclass ((CommandWidgetClass)&commandClassRec)
+ToggleClassRec toggleClassRec = {
+ /* core */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "Toggle", /* class_name */
+ sizeof(ToggleRec), /* size */
+ XawToggleClassInitialize, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ XawToggleInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ actionsList, /* actions */
+ XtNumber(actionsList), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* resource_count */
+ NULLQUARK, /* xrm_class */
+ False, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ NULL, /* destroy */
+ XtInheritResize, /* resize */
+ XtInheritExpose, /* expose */
+ XawToggleSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ defaultTranslations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* simple */
+ {
+ XtInheritChangeSensitive, /* change_sensitive */
+ },
+ /* label */
+ {
+ NULL, /* extension */
+ },
+ /* command */
+ {
+ NULL, /* extension */
+ },
+ /* toggle */
+ {
+ NULL, /* Set */
+ NULL, /* Unset */
+ NULL, /* extension */
+ }
+};
+
+WidgetClass toggleWidgetClass = (WidgetClass)&toggleClassRec;
+
+/*
+ * Impelementation
+ */
+static void
+XawToggleClassInitialize(void)
+{
+ XtActionList actions;
+ Cardinal num_actions;
+ Cardinal i;
+ ToggleWidgetClass cclass = (ToggleWidgetClass)toggleWidgetClass;
+ static XtConvertArgRec parentCvtArgs[] = {
+ {XtBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.parent),
+ sizeof(Widget)}
+ };
+
+ XawInitializeWidgetSet();
+ XtSetTypeConverter(XtRString, XtRWidget, XmuNewCvtStringToWidget,
+ parentCvtArgs, XtNumber(parentCvtArgs),
+ XtCacheNone, NULL);
+ XtSetTypeConverter(XtRWidget, XtRString, XmuCvtWidgetToString,
+ NULL, 0, XtCacheNone, NULL);
+
+ /*
+ * Find the set and unset actions in the command widget's action table
+ */
+ XtGetActionList(commandWidgetClass, &actions, &num_actions);
+
+ for (i = 0 ; i < num_actions ; i++) {
+ if (streq(actions[i].string, "set"))
+ cclass->toggle_class.Set = actions[i].proc;
+ if (streq(actions[i].string, "unset"))
+ cclass->toggle_class.Unset = actions[i].proc;
+
+ if (cclass->toggle_class.Set != NULL &&
+ cclass->toggle_class.Unset != NULL) {
+ XtFree((char *)actions);
+ return;
+ }
+ }
+
+ /* We should never get here */
+ XtError("Aborting, due to errors resolving bindings in the Toggle widget.");
+}
+
+/*ARGSUSED*/
+static void
+XawToggleInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ ToggleWidget tw = (ToggleWidget)cnew;
+ ToggleWidget tw_req = (ToggleWidget)request;
+
+ tw->toggle.radio_group = NULL;
+
+ if (tw->toggle.radio_data == NULL)
+ tw->toggle.radio_data = (XtPointer)cnew->core.name;
+
+ if (tw->toggle.widget != NULL) {
+ if (GetRadioGroup(tw->toggle.widget) == NULL)
+ CreateRadioGroup(cnew, tw->toggle.widget);
+ else
+ AddToRadioGroup(GetRadioGroup(tw->toggle.widget), cnew);
+ }
+ XtAddCallback(cnew, XtNdestroyCallback, XawToggleDestroy, NULL);
+
+ /*
+ * Command widget assumes that the widget is unset, so we only
+ * have to handle the case where it needs to be set
+ *
+ * If this widget is in a radio group then it may cause another
+ * widget to be unset, thus calling the notify proceedure
+ *
+ * I want to set the toggle if the user set the state to "On" in
+ * the resource group, reguardless of what my ancestors did
+ */
+ if (tw_req->command.set)
+ ToggleSet(cnew, NULL, NULL, NULL);
+}
+
+/*ARGSUSED*/
+static void
+ToggleSet(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ ToggleWidgetClass cclass = (ToggleWidgetClass)w->core.widget_class;
+
+ TurnOffRadioSiblings(w);
+ cclass->toggle_class.Set(w, event, NULL, NULL);
+}
+
+static void
+Toggle(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ ToggleWidget tw = (ToggleWidget)w;
+ ToggleWidgetClass cclass = (ToggleWidgetClass)w->core.widget_class;
+
+ if (tw->command.set)
+ cclass->toggle_class.Unset(w, event, NULL, NULL);
+ else
+ ToggleSet(w, event, params, num_params);
+}
+
+/*ARGSUSED*/
+static void
+Notify(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+ ToggleWidget tw = (ToggleWidget)w;
+ long antilint = tw->command.set;
+
+ XtCallCallbacks(w, XtNcallback, (XtPointer)antilint);
+}
+
+/*ARGSUSED*/
+static Boolean
+XawToggleSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ ToggleWidget oldtw = (ToggleWidget)current;
+ ToggleWidget tw = (ToggleWidget)cnew;
+ ToggleWidget rtw = (ToggleWidget)request;
+
+ if (oldtw->toggle.widget != tw->toggle.widget)
+ XawToggleChangeRadioGroup(cnew, tw->toggle.widget);
+
+ if (!tw->core.sensitive && oldtw->core.sensitive && rtw->command.set)
+ tw->command.set = True;
+
+ if (oldtw->command.set != tw->command.set) {
+ tw->command.set = oldtw->command.set;
+ Toggle(cnew, NULL, NULL, NULL);
+ }
+
+ return (False);
+}
+
+/*
+ * Function:
+ * XawToggleDestroy
+ *
+ * Parameters:
+ * w - toggle widget that is being destroyed
+ * temp1 - not used
+ * temp2 - ""
+ *
+ * Description:
+ * Destroy Callback for toggle widget.
+ */
+/*ARGSUSED*/
+static void
+XawToggleDestroy(Widget w, XtPointer temp1, XtPointer temp2)
+{
+ RemoveFromRadioGroup(w);
+}
+
+/*
+ * Function:
+ * GetRadioGroup
+ *
+ * Parameters:
+ * w - toggle widget who's radio group we are getting
+ *
+ * Description:
+ * Gets the radio group associated with a give toggle widget.
+ *
+ * Returns:
+ * The radio group associated with this toggle group
+ */
+static RadioGroup *
+GetRadioGroup(Widget w)
+{
+ ToggleWidget tw = (ToggleWidget)w;
+
+ if (tw == NULL)
+ return (NULL);
+
+ return (tw->toggle.radio_group);
+}
+
+/*
+ * Function:
+ * CreateRadioGroup
+ *
+ * Parameters:
+ * w1 - toggle widgets to add to the radio group
+ * w2 - ""
+ *
+ * Description:
+ * Creates a radio group. give two widgets.
+ *
+ * Note:
+ * A pointer to the group is added to each widget's radio_group field.
+ */
+static void
+CreateRadioGroup(Widget w1, Widget w2)
+{
+ ToggleWidget tw1 = (ToggleWidget)w1;
+ ToggleWidget tw2 = (ToggleWidget) w2;
+
+ if (tw1->toggle.radio_group != NULL || tw2->toggle.radio_group != NULL)
+ XtAppWarning(XtWidgetToApplicationContext(w1),
+ "Toggle Widget Error - Attempting to create a "
+ "new toggle group, when one already exists.");
+
+ AddToRadioGroup(NULL, w1);
+ AddToRadioGroup(GetRadioGroup(w1), w2);
+}
+
+/*
+ * Function:
+ * AddToRadioGroup
+ *
+ * Parameters:
+ * group - element of the radio group the we are adding to
+ * w - new toggle widget to add to the group
+ *
+ * Description:
+ * Adds a toggle to the radio group.
+ */
+static void
+AddToRadioGroup(RadioGroup *group, Widget w)
+{
+ ToggleWidget tw = (ToggleWidget)w;
+ RadioGroup *local;
+
+ local = (RadioGroup *)XtMalloc(sizeof(RadioGroup));
+ local->widget = w;
+ tw->toggle.radio_group = local;
+
+ if (group == NULL) { /* Creating new group */
+ group = local;
+ group->next = NULL;
+ group->prev = NULL;
+ return;
+ }
+ local->prev = group; /* Adding to previous group */
+ if ((local->next = group->next) != NULL)
+ local->next->prev = local;
+ group->next = local;
+}
+
+/*
+ * Function:
+ * TurnOffRadioSiblings
+ *
+ * Parameters:
+ * widget - toggle widget
+ *
+ * Description:
+ * Deactivates all radio siblings.
+ */
+static void
+TurnOffRadioSiblings(Widget w)
+{
+ RadioGroup *group;
+ ToggleWidgetClass cclass = (ToggleWidgetClass)w->core.widget_class;
+
+ if ((group = GetRadioGroup(w)) == NULL) /* Punt if there is no group */
+ return;
+
+ /* Go to the top of the group */
+ for (; group->prev != NULL ; group = group->prev)
+ ;
+
+ while (group != NULL) {
+ ToggleWidget local_tog = (ToggleWidget)group->widget;
+
+ if (local_tog->command.set) {
+ cclass->toggle_class.Unset(group->widget, NULL, NULL, NULL);
+ Notify(group->widget, NULL, NULL, NULL);
+ }
+ group = group->next;
+ }
+}
+
+/*
+ * Function:
+ * RemoveFromRadioGroup
+ *
+ * Parameters:
+ * w - toggle widget to remove
+ *
+ * Description:
+ * Removes a toggle from a RadioGroup.
+ */
+static void
+RemoveFromRadioGroup(Widget w)
+{
+ RadioGroup *group = GetRadioGroup(w);
+ if (group != NULL) {
+ if (group->prev != NULL)
+ (group->prev)->next = group->next;
+ if (group->next != NULL)
+ (group->next)->prev = group->prev;
+ XtFree((char *)group);
+ }
+}
+
+/*
+ * Function:
+ * XawToggleChangeRadioGroup
+ *
+ * Parameters:
+ * w - toggle widget to change groups
+ * radio_group - any widget in the new group
+ *
+ * Description:
+ * Allows a toggle widget to change radio groups.
+ */
+void
+XawToggleChangeRadioGroup(Widget w, Widget radio_group)
+{
+ ToggleWidget tw = (ToggleWidget)w;
+ RadioGroup *group;
+
+ RemoveFromRadioGroup(w);
+
+ /*
+ * If the toggle that we are about to add is set then we will
+ * unset all toggles in the new radio group
+ */
+
+ if (tw->command.set && radio_group != NULL)
+ XawToggleUnsetCurrent(radio_group);
+
+ if (radio_group != NULL) {
+ if ((group = GetRadioGroup(radio_group)) == NULL)
+ CreateRadioGroup(w, radio_group);
+ else
+ AddToRadioGroup(group, w);
+ }
+}
+
+/*
+ * Function:
+ * XawToggleGetCurrent
+ *
+ * Parameters:
+ * w - any toggle widget in the toggle group
+ *
+ * Description:
+ * Returns the RadioData associated with the toggle
+ * widget that is currently active in a toggle group.
+ *
+ * Returns:
+ * The XtNradioData associated with the toggle widget
+ */
+XtPointer
+XawToggleGetCurrent(Widget w)
+{
+ RadioGroup *group;
+
+ if ((group = GetRadioGroup(w)) == NULL)
+ return (NULL);
+
+ for (; group->prev != NULL ; group = group->prev)
+ ;
+
+ while (group != NULL) {
+ ToggleWidget local_tog = (ToggleWidget)group->widget;
+
+ if (local_tog->command.set)
+ return (local_tog->toggle.radio_data);
+ group = group->next;
+ }
+
+ return (NULL);
+}
+
+/*
+ * Function:
+ * XawToggleSetCurrent
+ *
+ * Parameters:
+ * radio_group - any toggle widget in the toggle group
+ * radio_data - radio data of the toggle widget to set
+ *
+ * Description:
+ * Sets the Toggle widget associated with the radio_data specified.
+ */
+void
+XawToggleSetCurrent(Widget radio_group, XtPointer radio_data)
+{
+ RadioGroup *group;
+ ToggleWidget local_tog;
+
+ /* Special case of no radio group */
+
+ if ((group = GetRadioGroup(radio_group)) == NULL) {
+ local_tog = (ToggleWidget)radio_group;
+
+ if (local_tog->toggle.radio_data == radio_data &&
+ !local_tog->command.set) {
+ ToggleSet(radio_group, NULL, NULL, NULL);
+ Notify(radio_group, NULL, NULL, NULL);
+ }
+ return;
+ }
+
+ /*
+ * find top of radio_roup
+ */
+ for (; group->prev != NULL ; group = group->prev)
+ ;
+
+ /*
+ * search for matching radio data
+ */
+ while (group != NULL) {
+ local_tog = (ToggleWidget)group->widget;
+
+ if (local_tog->toggle.radio_data == radio_data) {
+ if (!local_tog->command.set) { /* if not already set */
+ ToggleSet(group->widget, NULL, NULL, NULL);
+ Notify(group->widget, NULL, NULL, NULL);
+ }
+ return; /* found it, done */
+ }
+ group = group->next;
+ }
+}
+
+/*
+ * Function:
+ * XawToggleUnsetCurrent
+ *
+ * Parameters:
+ * radio_group - any toggle widget in the toggle group
+ *
+ * Description:
+ * Unsets all Toggles in the radio_group specified.
+ */
+void
+XawToggleUnsetCurrent(Widget radio_group)
+{
+ ToggleWidgetClass cclass;
+ ToggleWidget local_tog = (ToggleWidget)radio_group;
+
+ /* Special Case no radio group */
+
+ if (local_tog->command.set) {
+ cclass = (ToggleWidgetClass)local_tog->core.widget_class;
+ cclass->toggle_class.Unset(radio_group, NULL, NULL, NULL);
+ Notify(radio_group, NULL, NULL, NULL);
+ }
+ if (GetRadioGroup(radio_group) == NULL)
+ return;
+
+ TurnOffRadioSiblings(radio_group);
+}
diff --git a/nx-X11/lib/Xaw/Toggle.h b/nx-X11/lib/Xaw/Toggle.h
new file mode 100644
index 000000000..4858961f2
--- /dev/null
+++ b/nx-X11/lib/Xaw/Toggle.h
@@ -0,0 +1,181 @@
+/*
+ * $Xorg: Toggle.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+/* $XFree86: xc/lib/Xaw/Toggle.h,v 1.5 2001/01/17 19:42:35 dawes Exp $ */
+
+/*
+ * ToggleP.h - Private definitions for Toggle widget
+ *
+ * Author: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ *
+ * Date: January 12, 1989
+ */
+
+#ifndef _XawToggle_h
+#define _XawToggle_h
+
+#include <X11/Xaw/Command.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ radioGroup RadioGroup Widget NULL +
+ radioData RadioData Pointer (XPointer) Widget ++
+ state State Boolean Off
+
+ background Background Pixel XtDefaultBackground
+ bitmap Pixmap Pixmap None
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ callback Callback Pointer NULL
+ cursor Cursor Cursor None
+ destroyCallback Callback Pointer NULL
+ displayList DisplayList XawDisplayList* NULL
+ font Font XFontStructx* XtDefaultFont
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension text height
+ highlightThickness Thickness Dimension 2
+ insensitiveBorder Insensitive Pixmap Gray
+ internalHeight Height Dimension 2
+ internalWidth Width Dimension 4
+ justify Justify XtJustify XtJustifyCenter
+ label Label String NULL
+ mappedWhenManaged MappedWhenManaged Boolean True
+ resize Resize Boolean True
+ sensitive Sensitive Boolean True
+ width Width Dimension text width
+ x Position Position 0
+ y Position Position 0
+
++ To use the toggle as a radio toggle button, set this resource to point to
+ any other widget in the radio group.
+
+++ This is the data returned from a call to XtToggleGetCurrent, by default
+ this is set to the name of toggle widget.
+
+*/
+
+/*
+ * These should be in StringDefs.h but aren't so we will define
+ * them here if they are needed
+ */
+#define XtCWidget "Widget"
+#define XtCState "State"
+#define XtCRadioGroup "RadioGroup"
+#define XtCRadioData "RadioData"
+
+#ifndef _XtStringDefs_h_
+#define XtRWidget "Widget"
+#endif
+
+#define XtNstate "state"
+#define XtNradioGroup "radioGroup"
+#define XtNradioData "radioData"
+
+extern WidgetClass toggleWidgetClass;
+
+typedef struct _ToggleClassRec *ToggleWidgetClass;
+typedef struct _ToggleRec *ToggleWidget;
+
+/*
+ * Public Functions
+ */
+
+_XFUNCPROTOBEGIN
+
+/*
+ * Function:
+ * XawToggleChangeRadioGroup
+ *
+ * Parameters:
+ * w - toggle widget to change lists
+ * radio_group - any widget in the new list
+ *
+ * Description:
+ * Allows a toggle widget to change radio lists.
+ */
+void XawToggleChangeRadioGroup
+(
+ Widget w,
+ Widget radio_group
+ );
+
+/*
+ * Function:
+ * XawToggleGetCurrent
+ *
+ * Parameters:
+ * radio_group - any toggle widget in the toggle list
+ *
+ * Description:
+ * Returns the RadioData associated with the toggle
+ * widget that is currently active in a toggle list.
+ * Returns:
+ * The XtNradioData associated with the toggle widget
+ */
+
+XtPointer XawToggleGetCurrent
+(
+ Widget radio_group
+ );
+
+/*
+ * Function:
+ * XawToggleSetCurrent
+ *
+ * Parameters:
+ * radio_group - any toggle widget in the toggle list
+ * radio_data - radio data of the toggle widget to set
+ *
+ * Description:
+ * Sets the Toggle widget associated with the radio_data specified.
+ */
+void XawToggleSetCurrent
+(
+ Widget radio_group,
+ XtPointer radio_data
+ );
+
+/*
+ * Function:
+ * XawToggleUnsetCurrent
+ *
+ * Parameters:
+ * radio_group - any toggle widget in the toggle list
+ *
+ * Description:
+ * Unsets all Toggles in the radio_group specified.
+ */
+void XawToggleUnsetCurrent
+(
+ Widget radio_group
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XawToggle_h */
diff --git a/nx-X11/lib/Xaw/ToggleP.h b/nx-X11/lib/Xaw/ToggleP.h
new file mode 100644
index 000000000..c1477379d
--- /dev/null
+++ b/nx-X11/lib/Xaw/ToggleP.h
@@ -0,0 +1,95 @@
+/* $Xorg: ToggleP.h,v 1.4 2001/02/09 02:03:47 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.
+
+*/
+/* $XFree86: xc/lib/Xaw/ToggleP.h,v 1.7 2001/01/17 19:42:35 dawes Exp $ */
+
+/*
+ * Author: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ *
+ * Date: January 12, 1989
+ *
+ */
+
+#ifndef _XawToggleP_h
+#define _XawToggleP_h
+
+#include <X11/Xaw/Toggle.h>
+#include <X11/Xaw/CommandP.h>
+
+/*
+ * Toggle Widget Private Data
+ */
+#define streq(a, b) (strcmp((a), (b)) == 0)
+
+typedef struct _RadioGroup {
+ struct _RadioGroup *prev, *next; /* Pointers to other elements in group */
+ Widget widget; /* Widget corrosponding to this element */
+} RadioGroup;
+
+/* New fields for the Toggle widget class */
+typedef struct _ToggleClass {
+ XtActionProc Set;
+ XtActionProc Unset;
+ XtPointer extension;
+} ToggleClassPart;
+
+/* class record declaration */
+typedef struct _ToggleClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ LabelClassPart label_class;
+ CommandClassPart command_class;
+ ToggleClassPart toggle_class;
+} ToggleClassRec;
+
+extern ToggleClassRec toggleClassRec;
+
+/* New fields for the Toggle widget */
+typedef struct {
+ /* resources */
+ Widget widget;
+ XtPointer radio_data;
+
+ /* private */
+ RadioGroup *radio_group;
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} TogglePart;
+
+/* Full widget declaration */
+typedef struct _ToggleRec {
+ CorePart core;
+ SimplePart simple;
+ LabelPart label;
+ CommandPart command;
+ TogglePart toggle;
+} ToggleRec;
+
+#endif /* _XawToggleP_h */
diff --git a/nx-X11/lib/Xaw/Tree.c b/nx-X11/lib/Xaw/Tree.c
new file mode 100644
index 000000000..88bd51f90
--- /dev/null
+++ b/nx-X11/lib/Xaw/Tree.c
@@ -0,0 +1,1017 @@
+/*
+ * $Xorg: Tree.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+ *
+
+Copyright 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.
+
+ * Copyright 1989 Prentice Hall
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation.
+ *
+ * Prentice Hall and the authors disclaim all warranties with regard
+ * to this software, including all implied warranties of merchantability and
+ * fitness. In no event shall Prentice Hall or the authors be liable
+ * for any special, indirect or cosequential 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.
+ *
+ * Authors: Jim Fulton, MIT X Consortium,
+ * based on a version by Douglas Young, Prentice Hall
+ *
+ * This widget is based on the Tree widget described on pages 397-419 of
+ * Douglas Young's book "The X Window System, Programming and Applications
+ * with Xt OSF/Motif Edition." The layout code has been rewritten to use
+ * additional blank space to make the structure of the graph easier to see
+ * as well as to support vertical trees.
+ */
+/* $XFree86: xc/lib/Xaw/Tree.c,v 1.9 2001/01/17 19:42:35 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xaw/TreeP.h>
+#include "Private.h"
+
+#define IsHorizontal(tw) ((tw)->tree.gravity == WestGravity || \
+ (tw)->tree.gravity == EastGravity)
+
+/*
+ * Class Methods
+ */
+static void XawTreeChangeManaged(Widget);
+static void XawTreeClassInitialize(void);
+static void XawTreeConstraintDestroy(Widget);
+static void XawTreeConstraintInitialize(Widget, Widget, ArgList, Cardinal*);
+static Boolean XawTreeConstraintSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+static void XawTreeDestroy(Widget);
+static XtGeometryResult XawTreeGeometryManager(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawTreeInitialize(Widget, Widget, ArgList, Cardinal*);
+static XtGeometryResult XawTreeQueryGeometry(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawTreeRedisplay(Widget, XEvent*, Region);
+static Boolean XawTreeSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static void arrange_subtree(TreeWidget, Widget, int, int, int);
+static void check_gravity(TreeWidget, XtGravity);
+static void compute_bounding_box_subtree(TreeWidget, Widget, int);
+static void delete_node(Widget, Widget);
+static GC get_tree_gc(TreeWidget);
+static void initialize_dimensions(Dimension**, int*, int);
+static void insert_node(Widget, Widget);
+static void layout_tree(TreeWidget, Bool);
+static void set_positions(TreeWidget, Widget, int);
+static void set_tree_size(TreeWidget, Bool, unsigned int, unsigned int);
+
+/*
+ * Initialization
+ */
+
+/*
+ * resources of the tree itself
+ */
+static XtResource resources[] = {
+ { XtNautoReconfigure, XtCAutoReconfigure, XtRBoolean, sizeof (Boolean),
+ XtOffsetOf(TreeRec, tree.auto_reconfigure), XtRImmediate,
+ (XtPointer) FALSE },
+ { XtNhSpace, XtCHSpace, XtRDimension, sizeof (Dimension),
+ XtOffsetOf(TreeRec, tree.hpad), XtRImmediate, (XtPointer) 0 },
+ { XtNvSpace, XtCVSpace, XtRDimension, sizeof (Dimension),
+ XtOffsetOf(TreeRec, tree.vpad), XtRImmediate, (XtPointer) 0 },
+ { XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel),
+ XtOffsetOf(TreeRec, tree.foreground), XtRString,
+ XtDefaultForeground},
+ { XtNlineWidth, XtCLineWidth, XtRDimension, sizeof (Dimension),
+ XtOffsetOf(TreeRec, tree.line_width), XtRImmediate, (XtPointer) 0 },
+ { XtNgravity, XtCGravity, XtRGravity, sizeof (XtGravity),
+ XtOffsetOf(TreeRec, tree.gravity), XtRImmediate,
+ (XtPointer) WestGravity },
+#ifndef OLDXAW
+ { XawNdisplayList, XawCDisplayList, XawRDisplayList, sizeof(XawDisplayList*),
+ XtOffsetOf(TreeRec, tree.display_list), XtRImmediate,
+ NULL },
+#endif
+};
+
+
+/*
+ * resources that are attached to all children of the tree
+ */
+static XtResource treeConstraintResources[] = {
+ { XtNtreeParent, XtCTreeParent, XtRWidget, sizeof (Widget),
+ XtOffsetOf(TreeConstraintsRec, tree.parent), XtRImmediate, NULL },
+ { XtNtreeGC, XtCTreeGC, XtRGC, sizeof(GC),
+ XtOffsetOf(TreeConstraintsRec, tree.gc), XtRImmediate, NULL },
+};
+
+
+TreeClassRec treeClassRec = {
+ {
+ /* core_class fields */
+ (WidgetClass) &constraintClassRec, /* superclass */
+ "Tree", /* class_name */
+ sizeof(TreeRec), /* widget_size */
+ XawTreeClassInitialize, /* class_init */
+ NULL, /* class_part_init */
+ FALSE, /* class_inited */
+ XawTreeInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ TRUE, /* compress_motion */
+ TRUE, /* compress_exposure */
+ TRUE, /* compress_enterleave*/
+ TRUE, /* visible_interest */
+ XawTreeDestroy, /* destroy */
+ NULL, /* resize */
+ XawTreeRedisplay, /* expose */
+ XawTreeSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ XawTreeQueryGeometry, /* query_geometry */
+ NULL, /* display_accelerator*/
+ NULL, /* extension */
+ },
+ {
+ /* composite_class fields */
+ XawTreeGeometryManager, /* geometry_manager */
+ XawTreeChangeManaged, /* change_managed */
+ XtInheritInsertChild, /* insert_child */
+ XtInheritDeleteChild, /* delete_child */
+ NULL, /* extension */
+ },
+ {
+ /* constraint_class fields */
+ treeConstraintResources, /* subresources */
+ XtNumber(treeConstraintResources), /* subresource_count */
+ sizeof(TreeConstraintsRec), /* constraint_size */
+ XawTreeConstraintInitialize, /* initialize */
+ XawTreeConstraintDestroy, /* destroy */
+ XawTreeConstraintSetValues, /* set_values */
+ NULL, /* extension */
+ },
+ {
+ /* Tree class fields */
+ 0, /* ignore */
+ }
+};
+
+WidgetClass treeWidgetClass = (WidgetClass) &treeClassRec;
+
+
+/*****************************************************************************
+ * *
+ * tree utility routines *
+ * *
+ *****************************************************************************/
+
+static void
+initialize_dimensions(Dimension **listp, int *sizep, int n)
+{
+ int i;
+ Dimension *l;
+
+ if (!*listp) {
+ *listp = (Dimension *) XtCalloc ((unsigned int) n,
+ (unsigned int) sizeof(Dimension));
+ *sizep = ((*listp) ? n : 0);
+ return;
+ }
+ if (n > *sizep) {
+ *listp = (Dimension *) XtRealloc((char *) *listp,
+ (unsigned int) (n*sizeof(Dimension)));
+ if (!*listp) {
+ *sizep = 0;
+ return;
+ }
+ for (i = *sizep, l = (*listp) + i; i < n; i++, l++) *l = 0;
+ *sizep = n;
+ }
+ return;
+}
+
+static GC
+get_tree_gc(TreeWidget w)
+{
+ XtGCMask valuemask = GCBackground | GCForeground;
+ XGCValues values;
+
+ values.background = w->core.background_pixel;
+ values.foreground = w->tree.foreground;
+ if (w->tree.line_width != 0) {
+ valuemask |= GCLineWidth;
+ values.line_width = w->tree.line_width;
+ }
+
+ return XtGetGC ((Widget) w, valuemask, &values);
+}
+
+static void
+insert_node(Widget parent, Widget node)
+{
+ TreeConstraints pc;
+ TreeConstraints nc = TREE_CONSTRAINT(node);
+ int nindex;
+
+ nc->tree.parent = parent;
+
+ if (parent == NULL) return;
+
+ /*
+ * If there isn't more room in the children array,
+ * allocate additional space.
+ */
+ pc = TREE_CONSTRAINT(parent);
+ nindex = pc->tree.n_children;
+
+ if (pc->tree.n_children == pc->tree.max_children) {
+ pc->tree.max_children += (pc->tree.max_children / 2) + 2;
+ pc->tree.children = (WidgetList) XtRealloc ((char *)pc->tree.children,
+ (unsigned int)
+ ((pc->tree.max_children) *
+ sizeof(Widget)));
+ }
+
+ /*
+ * Add the sub_node in the next available slot and
+ * increment the counter.
+ */
+ pc->tree.children[nindex] = node;
+ pc->tree.n_children++;
+}
+
+static void
+delete_node(Widget parent, Widget node)
+{
+ TreeConstraints pc;
+ int pos, i;
+
+ /*
+ * Make sure the parent exists.
+ */
+ if (!parent) return;
+
+ pc = TREE_CONSTRAINT(parent);
+
+ /*
+ * Find the sub_node on its parent's list.
+ */
+ for (pos = 0; pos < pc->tree.n_children; pos++)
+ if (pc->tree.children[pos] == node) break;
+
+ if (pos == pc->tree.n_children) return;
+
+ /*
+ * Decrement the number of children
+ */
+ pc->tree.n_children--;
+
+ /*
+ * Fill in the gap left by the sub_node.
+ * Zero the last slot for good luck.
+ */
+ for (i = pos; i < pc->tree.n_children; i++)
+ pc->tree.children[i] = pc->tree.children[i+1];
+
+ pc->tree.children[pc->tree.n_children]=0;
+}
+
+static void
+check_gravity(TreeWidget tw, XtGravity grav)
+{
+ switch (tw->tree.gravity) {
+ case WestGravity: case NorthGravity: case EastGravity: case SouthGravity:
+ break;
+ default:
+ tw->tree.gravity = grav;
+ break;
+ }
+}
+
+
+/*****************************************************************************
+ * *
+ * tree class methods *
+ * *
+ *****************************************************************************/
+
+static void
+XawTreeClassInitialize(void)
+{
+ XawInitializeWidgetSet();
+ XtAddConverter(XtRString, XtRGravity, XmuCvtStringToGravity, NULL, 0);
+ XtSetTypeConverter(XtRGravity, XtRString, XmuCvtGravityToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+
+
+/*ARGSUSED*/
+static void
+XawTreeInitialize(Widget grequest, Widget gnew,
+ ArgList args, Cardinal *num_args)
+{
+ TreeWidget request = (TreeWidget) grequest, cnew = (TreeWidget) gnew;
+ Arg arglist[2];
+
+ /*
+ * Make sure the widget's width and height are
+ * greater than zero.
+ */
+ if (request->core.width <= 0) cnew->core.width = 5;
+ if (request->core.height <= 0) cnew->core.height = 5;
+
+ /*
+ * Set the padding according to the orientation
+ */
+ if (request->tree.hpad == 0 && request->tree.vpad == 0) {
+ if (IsHorizontal (request)) {
+ cnew->tree.hpad = TREE_HORIZONTAL_DEFAULT_SPACING;
+ cnew->tree.vpad = TREE_VERTICAL_DEFAULT_SPACING;
+ } else {
+ cnew->tree.hpad = TREE_VERTICAL_DEFAULT_SPACING;
+ cnew->tree.vpad = TREE_HORIZONTAL_DEFAULT_SPACING;
+ }
+ }
+
+ /*
+ * Create a graphics context for the connecting lines.
+ */
+ cnew->tree.gc = get_tree_gc (cnew);
+
+ /*
+ * Create the hidden root widget.
+ */
+ cnew->tree.tree_root = (Widget) NULL;
+ XtSetArg(arglist[0], XtNwidth, 1);
+ XtSetArg(arglist[1], XtNheight, 1);
+ cnew->tree.tree_root = XtCreateWidget ("root", widgetClass, gnew,
+ arglist,TWO);
+
+ /*
+ * Allocate the array used to hold the widest values per depth
+ */
+ cnew->tree.largest = NULL;
+ cnew->tree.n_largest = 0;
+ initialize_dimensions (&cnew->tree.largest, &cnew->tree.n_largest,
+ TREE_INITIAL_DEPTH);
+
+ /*
+ * make sure that our gravity is one of the acceptable values
+ */
+ check_gravity (cnew, WestGravity);
+}
+
+
+/* ARGSUSED */
+static void
+XawTreeConstraintInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ TreeConstraints tc = TREE_CONSTRAINT(cnew);
+ TreeWidget tw = (TreeWidget) cnew->core.parent;
+
+ /*
+ * Initialize the widget to have no sub-nodes.
+ */
+ tc->tree.n_children = 0;
+ tc->tree.max_children = 0;
+ tc->tree.children = (Widget *) NULL;
+ tc->tree.x = tc->tree.y = 0;
+ tc->tree.bbsubwidth = 0;
+ tc->tree.bbsubheight = 0;
+
+
+ /*
+ * If this widget has a super-node, add it to that
+ * widget' sub-nodes list. Otherwise make it a sub-node of
+ * the tree_root widget.
+ */
+ if (tc->tree.parent)
+ insert_node (tc->tree.parent, cnew);
+ else if (tw->tree.tree_root)
+ insert_node (tw->tree.tree_root, cnew);
+}
+
+
+/* ARGSUSED */
+static Boolean
+XawTreeSetValues(Widget gcurrent, Widget grequest, Widget gnew,
+ ArgList args, Cardinal *num_args)
+{
+ TreeWidget current = (TreeWidget) gcurrent, cnew = (TreeWidget) gnew;
+ Boolean redraw = FALSE;
+
+ /*
+ * If the foreground color has changed, redo the GC's
+ * and indicate a redraw.
+ */
+ if (cnew->tree.foreground != current->tree.foreground ||
+ cnew->core.background_pixel != current->core.background_pixel ||
+ cnew->tree.line_width != current->tree.line_width) {
+ XtReleaseGC (gnew, cnew->tree.gc);
+ cnew->tree.gc = get_tree_gc (cnew);
+ redraw = TRUE;
+ }
+
+ /*
+ * If the minimum spacing has changed, recalculate the
+ * tree layout. layout_tree() does a redraw, so we don't
+ * need SetValues to do another one.
+ */
+ if (cnew->tree.gravity != current->tree.gravity) {
+ check_gravity (cnew, current->tree.gravity);
+ }
+
+ if (IsHorizontal(cnew) != IsHorizontal(current)) {
+ if (cnew->tree.vpad == current->tree.vpad &&
+ cnew->tree.hpad == current->tree.hpad) {
+ cnew->tree.vpad = current->tree.hpad;
+ cnew->tree.hpad = current->tree.vpad;
+ }
+ }
+
+ if (cnew->tree.vpad != current->tree.vpad ||
+ cnew->tree.hpad != current->tree.hpad ||
+ cnew->tree.gravity != current->tree.gravity) {
+ layout_tree (cnew, TRUE);
+ redraw = FALSE;
+ }
+ return redraw;
+}
+
+
+/* ARGSUSED */
+static Boolean
+XawTreeConstraintSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ TreeConstraints newc = TREE_CONSTRAINT(cnew);
+ TreeConstraints curc = TREE_CONSTRAINT(current);
+ TreeWidget tw = (TreeWidget) cnew->core.parent;
+
+ /*
+ * If the parent field has changed, remove the widget
+ * from the old widget's children list and add it to the
+ * new one.
+ */
+ if (curc->tree.parent != newc->tree.parent){
+ if (curc->tree.parent)
+ delete_node (curc->tree.parent, cnew);
+ if (newc->tree.parent)
+ insert_node(newc->tree.parent, cnew);
+
+ /*
+ * If the Tree widget has been realized,
+ * compute new layout.
+ */
+ if (XtIsRealized((Widget)tw))
+ layout_tree (tw, FALSE);
+ }
+ return False;
+}
+
+
+static void
+XawTreeConstraintDestroy(Widget w)
+{
+ TreeConstraints tc = TREE_CONSTRAINT(w);
+ TreeWidget tw = (TreeWidget) XtParent(w);
+ int i;
+
+ /*
+ * Remove the widget from its parent's sub-nodes list and
+ * make all this widget's sub-nodes sub-nodes of the parent.
+ */
+
+ if (tw->tree.tree_root == w) {
+ if (tc->tree.n_children > 0)
+ tw->tree.tree_root = tc->tree.children[0];
+ else
+ tw->tree.tree_root = NULL;
+ }
+
+ delete_node (tc->tree.parent, (Widget) w);
+ for (i = 0; i< tc->tree.n_children; i++)
+ insert_node (tc->tree.parent, tc->tree.children[i]);
+
+ layout_tree ((TreeWidget) (w->core.parent), FALSE);
+}
+
+/* ARGSUSED */
+static XtGeometryResult
+XawTreeGeometryManager(Widget w, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+
+ TreeWidget tw = (TreeWidget) w->core.parent;
+
+ /*
+ * No position changes allowed!.
+ */
+ if ((request->request_mode & CWX && request->x!=w->core.x)
+ ||(request->request_mode & CWY && request->y!=w->core.y))
+ return (XtGeometryNo);
+
+ /*
+ * Allow all resize requests.
+ */
+
+ if (request->request_mode & CWWidth)
+ w->core.width = request->width;
+ if (request->request_mode & CWHeight)
+ w->core.height = request->height;
+ if (request->request_mode & CWBorderWidth)
+ w->core.border_width = request->border_width;
+
+ if (tw->tree.auto_reconfigure) layout_tree (tw, FALSE);
+ return (XtGeometryYes);
+}
+
+static void
+XawTreeChangeManaged(Widget gw)
+{
+ layout_tree ((TreeWidget) gw, FALSE);
+}
+
+
+static void
+XawTreeDestroy(Widget gw)
+{
+ TreeWidget w = (TreeWidget) gw;
+
+ XtReleaseGC (gw, w->tree.gc);
+ if (w->tree.largest) XtFree ((char *) w->tree.largest);
+}
+
+
+/* ARGSUSED */
+static void
+XawTreeRedisplay(Widget gw, XEvent *event, Region region)
+{
+ TreeWidget tw = (TreeWidget) gw;
+
+#ifndef OLDXAW
+ if (tw->tree.display_list)
+ XawRunDisplayList(gw, tw->tree.display_list, event, region);
+#endif
+
+ /*
+ * If the Tree widget is visible, visit each managed child.
+ */
+ if (tw->core.visible) {
+ Cardinal i;
+ int j;
+ Display *dpy = XtDisplay (tw);
+ Window w = XtWindow (tw);
+
+ for (i = 0; i < tw->composite.num_children; i++) {
+ Widget child = tw->composite.children[i];
+ TreeConstraints tc = TREE_CONSTRAINT(child);
+
+ /*
+ * Don't draw lines from the fake tree_root.
+ */
+ if (child != tw->tree.tree_root && tc->tree.n_children) {
+ int srcx = child->core.x + child->core.border_width;
+ int srcy = child->core.y + child->core.border_width;
+
+ switch (tw->tree.gravity) {
+ case WestGravity:
+ srcx += child->core.width + child->core.border_width;
+ /* fall through */
+ case EastGravity:
+ srcy += child->core.height / 2;
+ break;
+
+ case NorthGravity:
+ srcy += child->core.height + child->core.border_width;
+ /* fall through */
+ case SouthGravity:
+ srcx += child->core.width / 2;
+ break;
+ }
+
+ for (j = 0; j < tc->tree.n_children; j++) {
+ Widget k = tc->tree.children[j];
+ GC gc = (tc->tree.gc ? tc->tree.gc : tw->tree.gc);
+
+ switch (tw->tree.gravity) {
+ case WestGravity:
+ /*
+ * right center to left center
+ */
+ XDrawLine (dpy, w, gc, srcx, srcy,
+ (int) k->core.x,
+ (k->core.y + ((int) k->core.border_width) +
+ ((int) k->core.height) / 2));
+ break;
+
+ case NorthGravity:
+ /*
+ * bottom center to top center
+ */
+ XDrawLine (dpy, w, gc, srcx, srcy,
+ (k->core.x + ((int) k->core.border_width) +
+ ((int) k->core.width) / 2),
+ (int) k->core.y);
+ break;
+
+ case EastGravity:
+ /*
+ * left center to right center
+ */
+ XDrawLine (dpy, w, gc, srcx, srcy,
+ (k->core.x +
+ (((int) k->core.border_width) << 1) +
+ (int) k->core.width),
+ (k->core.y + ((int) k->core.border_width) +
+ ((int) k->core.height) / 2));
+ break;
+
+ case SouthGravity:
+ /*
+ * top center to bottom center
+ */
+ XDrawLine (dpy, w, gc, srcx, srcy,
+ (k->core.x + ((int) k->core.border_width) +
+ ((int) k->core.width) / 2),
+ (k->core.y +
+ (((int) k->core.border_width) << 1) +
+ (int) k->core.height));
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+static XtGeometryResult
+XawTreeQueryGeometry(Widget w, XtWidgetGeometry *intended,
+ XtWidgetGeometry *preferred)
+{
+ TreeWidget tw = (TreeWidget) w;
+
+ preferred->request_mode = (CWWidth | CWHeight);
+ preferred->width = tw->tree.maxwidth;
+ preferred->height = tw->tree.maxheight;
+
+ if (((intended->request_mode & (CWWidth | CWHeight)) ==
+ (CWWidth | CWHeight)) &&
+ intended->width == preferred->width &&
+ intended->height == preferred->height)
+ return XtGeometryYes;
+ else if (preferred->width == w->core.width &&
+ preferred->height == w->core.height)
+ return XtGeometryNo;
+ else
+ return XtGeometryAlmost;
+}
+
+
+/*****************************************************************************
+ * *
+ * tree layout algorithm *
+ * *
+ * Each node in the tree is "shrink-wrapped" with a minimal bounding *
+ * rectangle, laid next to its siblings (with a small about of padding in *
+ * between) and then wrapped with their parent. Parents are centered about *
+ * their children (or vice versa if the parent is larger than the children). *
+ * *
+ *****************************************************************************/
+
+static void
+compute_bounding_box_subtree(TreeWidget tree, Widget w, int depth)
+{
+ TreeConstraints tc = TREE_CONSTRAINT(w); /* info attached to all kids */
+ int i;
+ Bool horiz = IsHorizontal (tree);
+ Dimension newwidth, newheight;
+ Dimension bw2 = w->core.border_width * 2;
+
+ /*
+ * Set the max-size per level.
+ */
+ if (depth >= tree->tree.n_largest) {
+ initialize_dimensions (&tree->tree.largest,
+ &tree->tree.n_largest, depth + 1);
+ }
+ newwidth = ((horiz ? w->core.width : w->core.height) + bw2);
+ if (tree->tree.largest[depth] < newwidth)
+ tree->tree.largest[depth] = newwidth;
+
+
+ /*
+ * initialize
+ */
+ tc->tree.bbwidth = w->core.width + bw2;
+ tc->tree.bbheight = w->core.height + bw2;
+
+ if (tc->tree.n_children == 0) return;
+
+ /*
+ * Figure the size of the opposite dimension (vertical if tree is
+ * horizontal, else vice versa). The other dimension will be set
+ * in the second pass once we know the maximum dimensions.
+ */
+ newwidth = 0;
+ newheight = 0;
+ for (i = 0; i < tc->tree.n_children; i++) {
+ Widget child = tc->tree.children[i];
+ TreeConstraints cc = TREE_CONSTRAINT(child);
+
+ compute_bounding_box_subtree (tree, child, depth + 1);
+
+ if (horiz) {
+ if (newwidth < cc->tree.bbwidth) newwidth = cc->tree.bbwidth;
+ newheight += tree->tree.vpad + cc->tree.bbheight;
+ } else {
+ if (newheight < cc->tree.bbheight) newheight = cc->tree.bbheight;
+ newwidth += tree->tree.hpad + cc->tree.bbwidth;
+ }
+ }
+
+
+ tc->tree.bbsubwidth = newwidth;
+ tc->tree.bbsubheight = newheight;
+
+ /*
+ * Now fit parent onto side (or top) of bounding box and correct for
+ * extra padding. Be careful of unsigned arithmetic.
+ */
+ if (horiz) {
+ tc->tree.bbwidth += tree->tree.hpad + newwidth;
+ newheight -= tree->tree.vpad;
+ if (newheight > tc->tree.bbheight) tc->tree.bbheight = newheight;
+ } else {
+ tc->tree.bbheight += tree->tree.vpad + newheight;
+ newwidth -= tree->tree.hpad;
+ if (newwidth > tc->tree.bbwidth) tc->tree.bbwidth = newwidth;
+ }
+}
+
+
+static void
+set_positions(TreeWidget tw, Widget w, int level)
+{
+ int i;
+
+ if (w) {
+ TreeConstraints tc = TREE_CONSTRAINT(w);
+
+ if (level > 0) {
+ /*
+ * mirror if necessary
+ */
+ switch (tw->tree.gravity) {
+ case EastGravity:
+ tc->tree.x = (((Position) tw->tree.maxwidth) -
+ ((Position) w->core.width) - tc->tree.x);
+ break;
+
+ case SouthGravity:
+ tc->tree.y = (((Position) tw->tree.maxheight) -
+ ((Position) w->core.height) - tc->tree.y);
+ break;
+ }
+
+ /*
+ * Move the widget into position.
+ */
+ XtMoveWidget (w, tc->tree.x, tc->tree.y);
+ }
+
+ /*
+ * Set the positions of all children.
+ */
+ for (i = 0; i < tc->tree.n_children; i++)
+ set_positions (tw, tc->tree.children[i], level + 1);
+ }
+}
+
+
+static void
+arrange_subtree(TreeWidget tree, Widget w, int depth, int x, int y)
+{
+ TreeConstraints tc = TREE_CONSTRAINT(w); /* info attached to all kids */
+ TreeConstraints firstcc, lastcc;
+ int i;
+ int newx, newy;
+ Bool horiz = IsHorizontal (tree);
+ Widget child = NULL;
+ Dimension tmp;
+ Dimension bw2 = w->core.border_width * 2;
+ Bool relayout = True;
+
+
+ /*
+ * If no children, then just lay out where requested.
+ */
+ tc->tree.x = x;
+ tc->tree.y = y;
+
+ if (horiz) {
+ int myh = (w->core.height + bw2);
+
+ if (myh > (int)tc->tree.bbsubheight) {
+ y += (myh - (int)tc->tree.bbsubheight) / 2;
+ relayout = False;
+ }
+ } else {
+ int myw = (w->core.width + bw2);
+
+ if (myw > (int)tc->tree.bbsubwidth) {
+ x += (myw - (int)tc->tree.bbsubwidth) / 2;
+ relayout = False;
+ }
+ }
+
+ if ((tmp = ((Dimension) x) + tc->tree.bbwidth) > tree->tree.maxwidth)
+ tree->tree.maxwidth = tmp;
+ if ((tmp = ((Dimension) y) + tc->tree.bbheight) > tree->tree.maxheight)
+ tree->tree.maxheight = tmp;
+
+ if (tc->tree.n_children == 0) return;
+
+
+ /*
+ * Have children, so walk down tree laying out children, then laying
+ * out parents.
+ */
+ if (horiz) {
+ newx = x + tree->tree.largest[depth];
+ if (depth > 0) newx += tree->tree.hpad;
+ newy = y;
+ } else {
+ newx = x;
+ newy = y + tree->tree.largest[depth];
+ if (depth > 0) newy += tree->tree.vpad;
+ }
+
+ for (i = 0; i < tc->tree.n_children; i++) {
+ TreeConstraints cc;
+
+ child = tc->tree.children[i]; /* last value is used outside loop */
+ cc = TREE_CONSTRAINT(child);
+
+ arrange_subtree (tree, child, depth + 1, newx, newy);
+ if (horiz) {
+ newy += tree->tree.vpad + cc->tree.bbheight;
+ } else {
+ newx += tree->tree.hpad + cc->tree.bbwidth;
+ }
+ }
+
+ /*
+ * now layout parent between first and last children
+ */
+ if (relayout) {
+ Position adjusted;
+ firstcc = TREE_CONSTRAINT (tc->tree.children[0]);
+ lastcc = TREE_CONSTRAINT (child);
+
+ /* Adjustments are disallowed if they result in a position above
+ * or to the left of the originally requested position, because
+ * this could collide with the position of the previous sibling.
+ */
+ if (horiz) {
+ tc->tree.x = x;
+ adjusted = firstcc->tree.y +
+ ((lastcc->tree.y + (Position) child->core.height +
+ (Position) child->core.border_width * 2 -
+ firstcc->tree.y - (Position) w->core.height -
+ (Position) w->core.border_width * 2 + 1) / 2);
+ if (adjusted > tc->tree.y) tc->tree.y = adjusted;
+ } else {
+ adjusted = firstcc->tree.x +
+ ((lastcc->tree.x + (Position) child->core.width +
+ (Position) child->core.border_width * 2 -
+ firstcc->tree.x - (Position) w->core.width -
+ (Position) w->core.border_width * 2 + 1) / 2);
+ if (adjusted > tc->tree.x) tc->tree.x = adjusted;
+ tc->tree.y = y;
+ }
+ }
+}
+
+static void
+set_tree_size(TreeWidget tw, Bool insetvalues,
+ unsigned int width, unsigned int height)
+{
+ if (insetvalues) {
+ tw->core.width = width;
+ tw->core.height = height;
+ } else {
+ Dimension replyWidth = 0, replyHeight = 0;
+ XtGeometryResult result = XtMakeResizeRequest ((Widget) tw,
+ width, height,
+ &replyWidth,
+ &replyHeight);
+ /*
+ * Accept any compromise.
+ */
+ if (result == XtGeometryAlmost)
+ XtMakeResizeRequest ((Widget) tw, replyWidth, replyHeight,
+ (Dimension *) NULL, (Dimension *) NULL);
+ }
+ return;
+}
+
+static void
+layout_tree(TreeWidget tw, Bool insetvalues)
+{
+ int i;
+ Dimension *dp;
+
+ /*
+ * Do a depth-first search computing the width and height of the bounding
+ * box for the tree at that position (and below). Then, walk again using
+ * this information to layout the children at each level.
+ */
+
+ if (tw->tree.tree_root == NULL)
+ return;
+
+ tw->tree.maxwidth = tw->tree.maxheight = 0;
+ for (i = 0, dp = tw->tree.largest; i < tw->tree.n_largest; i++, dp++)
+ *dp = 0;
+ initialize_dimensions (&tw->tree.largest, &tw->tree.n_largest,
+ tw->tree.n_largest);
+ compute_bounding_box_subtree (tw, tw->tree.tree_root, 0);
+
+ /*
+ * Second pass to do final layout. Each child's bounding box is stacked
+ * on top of (if horizontal, else next to) on top of its siblings. The
+ * parent is centered between the first and last children.
+ */
+ arrange_subtree (tw, tw->tree.tree_root, 0, 0, 0);
+
+ /*
+ * Move each widget into place.
+ */
+ set_tree_size (tw, insetvalues, tw->tree.maxwidth, tw->tree.maxheight);
+ set_positions (tw, tw->tree.tree_root, 0);
+
+ /*
+ * And redisplay.
+ */
+ if (XtIsRealized ((Widget) tw)) {
+ XClearArea (XtDisplay(tw), XtWindow((Widget)tw), 0, 0, 0, 0, True);
+ }
+}
+
+
+
+/*****************************************************************************
+ * *
+ * Public Routines *
+ * *
+ *****************************************************************************/
+
+void
+XawTreeForceLayout(Widget tree)
+{
+ layout_tree ((TreeWidget) tree, FALSE);
+}
+
diff --git a/nx-X11/lib/Xaw/Tree.h b/nx-X11/lib/Xaw/Tree.h
new file mode 100644
index 000000000..ae0990aa5
--- /dev/null
+++ b/nx-X11/lib/Xaw/Tree.h
@@ -0,0 +1,138 @@
+/*
+ * $Xorg: Tree.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+ *
+
+Copyright 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.
+
+ * Copyright 1989 Prentice Hall
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation.
+ *
+ * Prentice Hall and the authors disclaim all warranties with regard
+ * to this software, including all implied warranties of merchantability and
+ * fitness. In no event shall Prentice Hall or the authors be liable
+ * for any special, indirect or cosequential 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.
+ *
+ * Authors: Jim Fulton, MIT X Consortium,
+ * based on a version by Douglas Young, Prentice Hall
+ *
+ * This widget is based on the Tree widget described on pages 397-419 of
+ * Douglas Young's book "The X Window System, Programming and Applications
+ * with Xt OSF/Motif Edition." The layout code has been rewritten to use
+ * additional blank space to make the structure of the graph easier to see
+ * as well as to support vertical trees.
+ */
+/* $XFree86: xc/lib/Xaw/Tree.h,v 1.6 2001/01/17 19:42:35 dawes Exp $ */
+
+
+#ifndef _XawTree_h
+#define _XawTree_h
+
+#include <X11/Xmu/Converters.h>
+
+/******************************************************************************
+ *
+ * Tree Widget (subclass of ConstraintClass)
+ *
+ ******************************************************************************
+ *
+ * Parameters:
+ *
+ * Name Class Type Default
+ * ---- ----- ---- -------
+ *
+ * autoReconfigure AutoReconfigure Boolean FALSE
+ * background Background Pixel XtDefaultBackground
+ * foreground Foreground Pixel XtDefaultForeground
+ * gravity Gravity XtGravity West
+ * hSpace HSpace Dimension 20
+ * lineWidth LineWidth Dimension 0
+ * vSpace VSpace Dimension 6
+ *
+ *
+ * Constraint Resources attached to children:
+ *
+ * treeGC TreeGC GC NULL
+ * treeParent TreeParent Widget NULL
+ *
+ *
+ *****************************************************************************/
+
+ /* new instance field names */
+#ifndef _XtStringDefs_h_
+#define XtNhSpace "hSpace"
+#define XtNvSpace "vSpace"
+#define XtCHSpace "HSpace"
+#define XtCVSpace "VSpace"
+#endif
+
+#define XtNautoReconfigure "autoReconfigure"
+#define XtNlineWidth "lineWidth"
+#define XtNtreeGC "treeGC"
+#define XtNtreeParent "treeParent"
+#define XtNgravity "gravity"
+
+ /* new class field names */
+#define XtCAutoReconfigure "AutoReconfigure"
+#define XtCLineWidth "LineWidth"
+#define XtCTreeGC "TreeGC"
+#define XtCTreeParent "TreeParent"
+#define XtCGravity "Gravity"
+
+#define XtRGC "GC"
+
+#ifndef OLDXAW
+#ifndef XawNdisplayList
+#define XawNdisplayList "displayList"
+#endif
+
+#ifndef XawCDisplayList
+#define XawCDisplayList "DisplayList"
+#endif
+
+#ifndef XawRDisplayList
+#define XawRDisplayList "XawDisplayList"
+#endif
+#endif
+ /* external declarations */
+extern WidgetClass treeWidgetClass;
+
+typedef struct _TreeClassRec *TreeWidgetClass;
+typedef struct _TreeRec *TreeWidget;
+
+_XFUNCPROTOBEGIN
+
+void XawTreeForceLayout
+(
+ Widget tree
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XawTree_h */
diff --git a/nx-X11/lib/Xaw/TreeP.h b/nx-X11/lib/Xaw/TreeP.h
new file mode 100644
index 000000000..00e59c0a4
--- /dev/null
+++ b/nx-X11/lib/Xaw/TreeP.h
@@ -0,0 +1,141 @@
+/*
+ * $Xorg: TreeP.h,v 1.4 2001/02/09 02:03:47 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.
+
+ * Copyright 1989 Prentice Hall
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation.
+ *
+ * Prentice Hall and the authors disclaim all warranties with regard
+ * to this software, including all implied warranties of merchantability and
+ * fitness. In no event shall Prentice Hall or the authors be liable
+ * for any special, indirect or cosequential 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.
+ *
+ * Authors: Jim Fulton, MIT X Consortium,
+ * based on a version by Douglas Young, Prentice Hall
+ *
+ * This widget is based on the Tree widget described on pages 397-419 of
+ * Douglas Young's book "The X Window System, Programming and Applications
+ * with Xt OSF/Motif Edition." The layout code has been rewritten to use
+ * additional blank space to make the structure of the graph easier to see
+ * as well as to support vertical trees.
+ */
+/* $XFree86: xc/lib/Xaw/TreeP.h,v 1.6 2001/01/17 19:42:35 dawes Exp $ */
+
+
+#ifndef _XawTreeP_h
+#define _XawTreeP_h
+
+#include <X11/Xaw/Tree.h>
+
+typedef struct _TreeClassPart {
+ XtPointer extension;
+} TreeClassPart;
+
+typedef struct _TreeClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ConstraintClassPart constraint_class;
+ TreeClassPart tree_class;
+} TreeClassRec;
+
+extern TreeClassRec treeClassRec;
+
+typedef struct {
+ /* fields available through resources */
+ Dimension hpad; /* hSpace/HSpace */
+ Dimension vpad; /* vSpace/VSpace */
+ Dimension line_width; /* lineWidth/LineWidth */
+ Pixel foreground; /* foreground/Foreground */
+ XtGravity gravity; /* gravity/Gravity */
+ Boolean auto_reconfigure; /* autoReconfigure/AutoReconfigure */
+ /* private fields */
+ GC gc; /* used to draw lines */
+ Widget tree_root; /* hidden root off all children */
+ Dimension *largest; /* list of largest per depth */
+ int n_largest; /* number of elements in largest */
+ Dimension maxwidth, maxheight; /* for shrink wrapping */
+#ifndef OLDXAW
+ XawDisplayList *display_list;
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} TreePart;
+
+
+typedef struct _TreeRec {
+ CorePart core;
+ CompositePart composite;
+ ConstraintPart constraint;
+ TreePart tree;
+} TreeRec;
+
+
+/*
+ * structure attached to all children
+ */
+typedef struct _TreeConstraintsPart {
+ /* resources */
+ Widget parent; /* treeParent/TreeParent */
+ GC gc; /* treeGC/TreeGC */
+ /* private data */
+ Widget *children;
+ int n_children;
+ int max_children;
+ Dimension bbsubwidth, bbsubheight; /* bounding box of sub tree */
+ Dimension bbwidth, bbheight; /* bounding box including node */
+ Position x, y;
+#ifndef OLDXAW
+ XtPointer pad[2]; /* leave some space for future optimizations, and
+ * keep binary compatability
+ */
+#endif
+} TreeConstraintsPart;
+
+typedef struct _TreeConstraintsRec {
+ TreeConstraintsPart tree;
+} TreeConstraintsRec, *TreeConstraints;
+
+
+/*
+ * useful macros
+ */
+
+#define TREE_CONSTRAINT(w) \
+ ((TreeConstraints)((w)->core.constraints))
+
+#define TREE_INITIAL_DEPTH 10 /* for allocating largest array */
+#define TREE_HORIZONTAL_DEFAULT_SPACING 20
+#define TREE_VERTICAL_DEFAULT_SPACING 6
+
+#endif /* _XawTreeP_h */
+
+
+
diff --git a/nx-X11/lib/Xaw/Vendor.c b/nx-X11/lib/Xaw/Vendor.c
new file mode 100644
index 000000000..930c4485a
--- /dev/null
+++ b/nx-X11/lib/Xaw/Vendor.c
@@ -0,0 +1,527 @@
+/* $Xorg: Vendor.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Vendor.c,v 1.8 2001/12/14 19:54:45 dawes Exp $ */
+
+/*
+ * This is a copy of Xt/Vendor.c with an additional ClassInitialize
+ * procedure to register Xmu resource type converters, and all the
+ * monkey business associated with input methods...
+ *
+ */
+
+/* Make sure all wm properties can make it out of the resource manager */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/ShellP.h>
+#include <X11/VendorP.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Atoms.h>
+#include <X11/Xmu/Editres.h>
+#include <X11/Xmu/ExtAgent.h>
+
+/* The following two headers are for the input method. */
+
+#include <X11/Xaw/VendorEP.h>
+#include <X11/Xaw/XawImP.h>
+
+/*
+ * Class Methods
+ */
+static void XawVendorShellChangeManaged(Widget);
+static Boolean XawCvtCompoundTextToString(Display*, XrmValuePtr, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static void XawVendorShellClassInitialize(void);
+static XtGeometryResult XawVendorShellGeometryManager(Widget,
+ XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawVendorShellExtClassInitialize(void);
+static void XawVendorShellExtDestroy(Widget);
+static void XawVendorShellExtInitialize(Widget, Widget, ArgList, Cardinal*);
+void XawVendorShellExtResize(Widget);
+static Boolean XawVendorShellExtSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+static void XawVendorShellClassPartInit(WidgetClass);
+static void XawVendorShellInitialize(Widget, Widget, ArgList, Cardinal*);
+static void XawVendorShellRealize(Widget, Mask*, XSetWindowAttributes*);
+static Boolean XawVendorShellSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+
+/*
+ * External
+ */
+void XawVendorStructureNotifyHandler(Widget, XtPointer, XEvent*, Boolean*);
+
+static XtResource resources[] = {
+ {XtNinput, XtCInput, XtRBool, sizeof(Bool),
+ XtOffsetOf(VendorShellRec, wm.wm_hints.input),
+ XtRImmediate, (XtPointer)True}
+};
+
+/***************************************************************************
+ *
+ * Vendor shell class record
+ *
+ ***************************************************************************/
+
+#if defined(__UNIXOS2__) || defined(__CYGWIN__)
+/* to fix the EditRes problem because of wrong linker semantics */
+extern WidgetClass vendorShellWidgetClass; /* from Xt/Vendor.c */
+extern VendorShellClassRec _XawVendorShellClassRec;
+extern void _XawFixupVendorShell();
+
+#if defined(__UNIXOS2__)
+unsigned long _DLL_InitTerm(unsigned long mod,unsigned long flag)
+{
+ switch (flag) {
+ case 0: /*called on init*/
+ _CRT_init();
+ vendorShellWidgetClass = (WidgetClass)(&_XawVendorShellClassRec);
+ _XawFixupVendorShell();
+ return 1;
+ case 1: /*called on exit*/
+ return 1;
+ default:
+ return 0;
+ }
+}
+#endif
+
+#if defined(__CYGWIN__)
+int __stdcall
+DllMain(unsigned long mod_handle, unsigned long flag, void *routine)
+{
+ switch (flag)
+ {
+ case 1: /* DLL_PROCESS_ATTACH - process attach */
+ vendorShellWidgetClass = (WidgetClass)(&_XawVendorShellClassRec);
+ _XawFixupVendorShell();
+ break;
+ case 0: /* DLL_PROCESS_DETACH - process detach */
+ break;
+ }
+ return 1;
+}
+#endif
+
+#define vendorShellClassRec _XawVendorShellClassRec
+
+#endif
+
+static CompositeClassExtensionRec vendorCompositeExt = {
+ /* next_extension */ NULL,
+ /* record_type */ NULLQUARK,
+ /* version */ XtCompositeExtensionVersion,
+ /* record_size */ sizeof (CompositeClassExtensionRec),
+ /* accepts_objects */ TRUE,
+ /* allows_change_managed_set */ FALSE
+};
+
+#define SuperClass (&wmShellClassRec)
+externaldef(vendorshellclassrec) VendorShellClassRec vendorShellClassRec = {
+ {
+ /* superclass */ (WidgetClass)SuperClass,
+ /* class_name */ "VendorShell",
+ /* size */ sizeof(VendorShellRec),
+ /* class_initialize */ XawVendorShellClassInitialize,
+ /* class_part_init */ XawVendorShellClassPartInit,
+ /* Class init'ed ? */ FALSE,
+ /* initialize */ XawVendorShellInitialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XawVendorShellRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* resource_count */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ XawVendorShellExtResize,
+ /* expose */ NULL,
+ /* set_values */ XawVendorShellSetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator*/ NULL,
+ /* extension */ NULL
+ },{
+ /* geometry_manager */ XawVendorShellGeometryManager,
+ /* change_managed */ XawVendorShellChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ (XtPointer) &vendorCompositeExt
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ }
+};
+
+#ifndef __UNIXOS2__
+externaldef(vendorshellwidgetclass) WidgetClass vendorShellWidgetClass =
+ (WidgetClass) (&vendorShellClassRec);
+#endif
+
+/***************************************************************************
+ *
+ * The following section is for the Vendor shell Extension class record
+ *
+ ***************************************************************************/
+
+static XtResource ext_resources[] = {
+ {XtNinputMethod, XtCInputMethod, XtRString, sizeof(String),
+ XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.input_method),
+ XtRString, (XtPointer)NULL},
+ {XtNpreeditType, XtCPreeditType, XtRString, sizeof(String),
+ XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.preedit_type),
+ XtRString, (XtPointer)"OverTheSpot,OffTheSpot,Root"},
+ {XtNopenIm, XtCOpenIm, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.open_im),
+ XtRImmediate, (XtPointer)TRUE},
+ {XtNsharedIc, XtCSharedIc, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XawVendorShellExtRec, vendor_ext.ic.shared_ic),
+ XtRImmediate, (XtPointer)FALSE}
+};
+
+externaldef(vendorshellextclassrec) XawVendorShellExtClassRec
+ xawvendorShellExtClassRec = {
+ {
+ /* superclass */ (WidgetClass)&objectClassRec,
+ /* class_name */ "VendorShellExt",
+ /* size */ sizeof(XawVendorShellExtRec),
+ /* class_initialize */ XawVendorShellExtClassInitialize,
+ /* class_part_initialize*/ NULL,
+ /* Class init'ed ? */ FALSE,
+ /* initialize */ XawVendorShellExtInitialize,
+ /* initialize_hook */ NULL,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* pad */ 0,
+ /* resources */ ext_resources,
+ /* resource_count */ XtNumber(ext_resources),
+ /* xrm_class */ NULLQUARK,
+ /* pad */ FALSE,
+ /* pad */ FALSE,
+ /* pad */ FALSE,
+ /* pad */ FALSE,
+ /* destroy */ XawVendorShellExtDestroy,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* set_values */ XawVendorShellExtSetValues,
+ /* set_values_hook */ NULL,
+ /* pad */ NULL,
+ /* get_values_hook */ NULL,
+ /* pad */ NULL,
+ /* version */ XtVersion,
+ /* callback_offsets */ NULL,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ }
+};
+
+externaldef(xawvendorshellwidgetclass) WidgetClass
+ xawvendorShellExtWidgetClass = (WidgetClass) (&xawvendorShellExtClassRec);
+
+
+/*ARGSUSED*/
+static Boolean
+XawCvtCompoundTextToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *cvt_data)
+{
+ XTextProperty prop;
+ char **list;
+ int count;
+ static char *mbs = NULL;
+ int len;
+
+ prop.value = (unsigned char *)fromVal->addr;
+ prop.encoding = XA_COMPOUND_TEXT(dpy);
+ prop.format = 8;
+ prop.nitems = fromVal->size;
+
+ if(XmbTextPropertyToTextList(dpy, &prop, &list, &count) < Success) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "converter", "XmbTextPropertyToTextList", "XawError",
+ "conversion from CT to MB failed.", NULL, 0);
+ return False;
+ }
+ len = strlen(*list);
+ toVal->size = len;
+ mbs = XtRealloc(mbs, len + 1); /* keep buffer because no one call free :( */
+ strcpy(mbs, *list);
+ XFreeStringList(list);
+ toVal->addr = (XtPointer)mbs;
+ return True;
+}
+
+static void
+XawVendorShellClassInitialize(void)
+{
+ static XtConvertArgRec screenConvertArg[] = {
+ {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
+ sizeof(Screen *)}
+ };
+
+ XtAddConverter(XtRString, XtRCursor, XmuCvtStringToCursor,
+ screenConvertArg, XtNumber(screenConvertArg));
+
+ XtAddConverter(XtRString, XtRBitmap, XmuCvtStringToBitmap,
+ screenConvertArg, XtNumber(screenConvertArg));
+
+ XtSetTypeConverter("CompoundText", XtRString, XawCvtCompoundTextToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+
+static void
+XawVendorShellClassPartInit(WidgetClass cclass)
+{
+ CompositeClassExtension ext;
+ VendorShellWidgetClass vsclass = (VendorShellWidgetClass)cclass;
+
+ if ((ext = (CompositeClassExtension)
+ XtGetClassExtension (cclass,
+ XtOffsetOf(CompositeClassRec,
+ composite_class.extension),
+ NULLQUARK, 1L, (Cardinal) 0)) == NULL) {
+ ext = (CompositeClassExtension) XtNew (CompositeClassExtensionRec);
+ if (ext != NULL) {
+ ext->next_extension = vsclass->composite_class.extension;
+ ext->record_type = NULLQUARK;
+ ext->version = XtCompositeExtensionVersion;
+ ext->record_size = sizeof (CompositeClassExtensionRec);
+ ext->accepts_objects = TRUE;
+ ext->allows_change_managed_set = FALSE;
+ vsclass->composite_class.extension = (XtPointer) ext;
+ }
+ }
+}
+
+#if defined(__osf__) || defined(__UNIXOS2__) || defined(__CYGWIN__)
+/* stupid OSF/1 shared libraries have the wrong semantics */
+/* symbols do not get resolved external to the shared library */
+void _XawFixupVendorShell()
+{
+ transientShellWidgetClass->core_class.superclass =
+ (WidgetClass) &vendorShellClassRec;
+ topLevelShellWidgetClass->core_class.superclass =
+ (WidgetClass) &vendorShellClassRec;
+}
+#endif
+
+/* ARGSUSED */
+static void
+XawVendorShellInitialize(Widget req, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ XtAddEventHandler(cnew, (EventMask) 0, TRUE, _XEditResCheckMessages, NULL);
+ XtAddEventHandler(cnew, (EventMask) 0, TRUE, XmuRegisterExternalAgent, NULL);
+ XtCreateWidget("shellext", xawvendorShellExtWidgetClass,
+ cnew, args, *num_args);
+}
+
+/* ARGSUSED */
+static Boolean
+XawVendorShellSetValues(Widget old, Widget ref, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ return FALSE;
+}
+
+static void
+XawVendorShellRealize(Widget wid, Mask *vmask, XSetWindowAttributes *attr)
+{
+ WidgetClass super = wmShellWidgetClass;
+
+ /* Make my superclass do all the dirty work */
+
+ (*super->core_class.realize) (wid, vmask, attr);
+ _XawImRealize(wid);
+}
+
+
+static void
+XawVendorShellExtClassInitialize(void)
+{
+}
+
+/* ARGSUSED */
+static void
+XawVendorShellExtInitialize(Widget req, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ _XawImInitialize(cnew->core.parent, cnew);
+}
+
+/* ARGSUSED */
+static void
+XawVendorShellExtDestroy(Widget w)
+{
+ _XawImDestroy( w->core.parent, w );
+}
+
+/* ARGSUSED */
+static Boolean
+XawVendorShellExtSetValues(Widget old, Widget ref, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ return FALSE;
+}
+
+void
+XawVendorShellExtResize(Widget w)
+{
+ ShellWidget sw = (ShellWidget) w;
+ Widget childwid;
+ Cardinal i;
+ int core_height;
+
+ _XawImResizeVendorShell( w );
+ core_height = _XawImGetShellHeight( w );
+ for( i = 0; i < sw->composite.num_children; i++ ) {
+ if( XtIsManaged( sw->composite.children[ i ] ) ) {
+ childwid = sw->composite.children[ i ];
+ XtResizeWidget( childwid, sw->core.width, core_height,
+ childwid->core.border_width );
+ }
+ }
+}
+
+/*ARGSUSED*/
+void
+XawVendorStructureNotifyHandler(Widget w, XtPointer closure, XEvent *event,
+ Boolean *continue_to_dispatch)
+{
+ XawVendorShellExtResize(w);
+}
+
+/*ARGSUSED*/
+static XtGeometryResult
+XawVendorShellGeometryManager(Widget wid, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+ ShellWidget shell = (ShellWidget)(wid->core.parent);
+ XtWidgetGeometry my_request;
+
+ if(shell->shell.allow_shell_resize == FALSE && XtIsRealized(wid))
+ return(XtGeometryNo);
+
+ if (request->request_mode & (CWX | CWY))
+ return(XtGeometryNo);
+
+ /* %%% worry about XtCWQueryOnly */
+ my_request.request_mode = 0;
+ if (request->request_mode & CWWidth) {
+ my_request.width = request->width;
+ my_request.request_mode |= CWWidth;
+ }
+ if (request->request_mode & CWHeight) {
+ my_request.height = request->height
+ + _XawImGetImAreaHeight( wid );
+ my_request.request_mode |= CWHeight;
+ }
+ if (request->request_mode & CWBorderWidth) {
+ my_request.border_width = request->border_width;
+ my_request.request_mode |= CWBorderWidth;
+ }
+ if (XtMakeGeometryRequest((Widget)shell, &my_request, NULL)
+ == XtGeometryYes) {
+ /* assert: if (request->request_mode & CWWidth) then
+ * shell->core.width == request->width
+ * assert: if (request->request_mode & CWHeight) then
+ * shell->core.height == request->height
+ *
+ * so, whatever the WM sized us to (if the Shell requested
+ * only one of the two) is now the correct child size
+ */
+
+ wid->core.width = shell->core.width;
+ wid->core.height = shell->core.height;
+ if (request->request_mode & CWBorderWidth) {
+ wid->core.x = wid->core.y = -request->border_width;
+ }
+ _XawImCallVendorShellExtResize(wid);
+ return XtGeometryYes;
+ } else return XtGeometryNo;
+}
+
+static void
+XawVendorShellChangeManaged(Widget wid)
+{
+ ShellWidget w = (ShellWidget) wid;
+ Widget* childP;
+ int i;
+
+ (*SuperClass->composite_class.change_managed)(wid);
+ for (i = w->composite.num_children, childP = w->composite.children;
+ i; i--, childP++) {
+ if (XtIsManaged(*childP)) {
+ XtSetKeyboardFocus(wid, *childP);
+ break;
+ }
+ }
+}
diff --git a/nx-X11/lib/Xaw/VendorEP.h b/nx-X11/lib/Xaw/VendorEP.h
new file mode 100644
index 000000000..dc85b3644
--- /dev/null
+++ b/nx-X11/lib/Xaw/VendorEP.h
@@ -0,0 +1,84 @@
+/* $Xorg: VendorEP.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/*
+ * Copyright 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 of 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 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xaw/VendorEP.h,v 1.5 2001/01/17 19:42:36 dawes Exp $ */
+
+#ifndef _VendorEP_h
+#define _VendorEP_h
+
+#include <X11/Xaw/XawImP.h>
+
+typedef struct {
+ XtPointer extension;
+} XawVendorShellExtClassPart;
+
+typedef struct _VendorShellExtClassRec {
+ ObjectClassPart object_class;
+ XawVendorShellExtClassPart vendor_shell_ext_class;
+} XawVendorShellExtClassRec;
+
+typedef struct {
+ Widget parent;
+ XawImPart im;
+ XawIcPart ic;
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} XawVendorShellExtPart;
+
+typedef struct XawVendorShellExtRec {
+ ObjectPart object;
+ XawVendorShellExtPart vendor_ext;
+} XawVendorShellExtRec, *XawVendorShellExtWidget;
+
+#endif /* _VendorEP_h */
diff --git a/nx-X11/lib/Xaw/Viewport.c b/nx-X11/lib/Xaw/Viewport.c
new file mode 100644
index 000000000..90c909e10
--- /dev/null
+++ b/nx-X11/lib/Xaw/Viewport.c
@@ -0,0 +1,1102 @@
+/* $Xorg: Viewport.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xaw/Viewport.c,v 1.10 2001/08/23 00:03:20 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xaw/Scrollbar.h>
+#include <X11/Xaw/ViewportP.h>
+#include <X11/Xaw/XawInit.h>
+#include "Private.h"
+
+/*
+ * Class Methods
+ */
+static Boolean Layout(FormWidget, unsigned int, unsigned int, Bool);
+static void XawViewportChangeManaged(Widget);
+static void XawViewportInitialize(Widget, Widget, ArgList, Cardinal*);
+static void
+XawViewportConstraintInitialize(Widget, Widget, ArgList, Cardinal*);
+static XtGeometryResult XawViewportGeometryManager(Widget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static XtGeometryResult XawViewportQueryGeometry(Widget,
+ XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void XawViewportRealize(Widget, XtValueMask*, XSetWindowAttributes*);
+static void XawViewportResize(Widget);
+static Boolean XawViewportSetValues(Widget, Widget, Widget,
+ ArgList, Cardinal*);
+
+/*
+ * Prototypes
+ */
+static void ComputeLayout(Widget, Bool, Bool);
+static void ComputeWithForceBars(Widget, Bool, XtWidgetGeometry*,
+ int*, int*);
+static Widget CreateScrollbar(ViewportWidget, Bool);
+static XtGeometryResult GeometryRequestPlusScrollbar(ViewportWidget, Bool,
+ XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static Bool GetGeometry(Widget, unsigned int, unsigned int);
+static void MoveChild(ViewportWidget, int, int);
+static XtGeometryResult QueryGeometry(ViewportWidget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void RedrawThumbs(ViewportWidget);
+static void ScrollUpDownProc(Widget, XtPointer, XtPointer);
+static void SendReport(ViewportWidget, unsigned int);
+static void SetBar(Widget, int, unsigned int, unsigned int);
+static XtGeometryResult TestSmaller(ViewportWidget, XtWidgetGeometry*,
+ XtWidgetGeometry*);
+static void ThumbProc(Widget, XtPointer, XtPointer);
+
+/*
+ * Initialization
+ */
+#define offset(field) XtOffsetOf(ViewportRec, viewport.field)
+static XtResource resources[] = {
+ {
+ XtNforceBars,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(forcebars),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNallowHoriz,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(allowhoriz),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNallowVert,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(allowvert),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNuseBottom,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(usebottom),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNuseRight,
+ XtCBoolean,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(useright),
+ XtRImmediate,
+ (XtPointer)False
+ },
+ {
+ XtNreportCallback,
+ XtCReportCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(report_callbacks),
+ XtRImmediate,
+ NULL
+ },
+};
+#undef offset
+
+#define Superclass (&formClassRec)
+ViewportClassRec viewportClassRec = {
+ /* core */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "Viewport", /* class_name */
+ sizeof(ViewportRec), /* widget_size */
+ XawInitializeWidgetSet, /* class_initialize */
+ NULL, /* class_part_init */
+ False, /* class_inited */
+ XawViewportInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XawViewportRealize, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ NULL, /* destroy */
+ XawViewportResize, /* resize */
+ XtInheritExpose, /* expose */
+ XawViewportSetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ XawViewportQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* composite */
+ {
+ XawViewportGeometryManager, /* geometry_manager */
+ XawViewportChangeManaged, /* change_managed */
+ XtInheritInsertChild, /* insert_child */
+ XtInheritDeleteChild, /* delete_child */
+ NULL, /* extension */
+ },
+ /* constraint */
+ {
+ NULL, /* subresourses */
+ 0, /* subresource_count */
+ sizeof(ViewportConstraintsRec), /* constraint_size */
+ XawViewportConstraintInitialize, /* initialize */
+ NULL, /* destroy */
+ NULL, /* set_values */
+ NULL, /* extension */
+ },
+ /* form */
+ {
+ Layout, /* layout */
+ },
+ /* viewport */
+ {
+ NULL, /* extension */
+ },
+};
+
+WidgetClass viewportWidgetClass = (WidgetClass)&viewportClassRec;
+
+/*
+ * Implementation
+ */
+static Widget
+CreateScrollbar(ViewportWidget w, Bool horizontal)
+{
+ static Arg barArgs[] = {
+ {XtNorientation, 0},
+ {XtNlength, 0},
+ {XtNleft, 0},
+ {XtNright, 0},
+ {XtNtop, 0},
+ {XtNbottom, 0},
+ {XtNmappedWhenManaged, False},
+ };
+ Widget clip = w->viewport.clip;
+ ViewportConstraints constraints =
+ (ViewportConstraints)clip->core.constraints;
+ Widget bar;
+
+ XtSetArg(barArgs[0], XtNorientation,
+ horizontal ? XtorientHorizontal : XtorientVertical);
+ XtSetArg(barArgs[1], XtNlength,
+ horizontal ? XtWidth(clip) : XtHeight(clip));
+ XtSetArg(barArgs[2], XtNleft,
+ !horizontal && w->viewport.useright ? XtChainRight : XtChainLeft);
+ XtSetArg(barArgs[3], XtNright,
+ !horizontal && !w->viewport.useright ? XtChainLeft : XtChainRight);
+ XtSetArg(barArgs[4], XtNtop,
+ horizontal && w->viewport.usebottom ? XtChainBottom: XtChainTop);
+ XtSetArg(barArgs[5], XtNbottom,
+ horizontal && !w->viewport.usebottom ? XtChainTop: XtChainBottom);
+
+ bar = XtCreateWidget(horizontal ? "horizontal" : "vertical",
+ scrollbarWidgetClass, (Widget)w,
+ barArgs, XtNumber(barArgs));
+ XtAddCallback(bar, XtNscrollProc, ScrollUpDownProc, (XtPointer)w);
+ XtAddCallback(bar, XtNjumpProc, ThumbProc, (XtPointer)w);
+
+ if (horizontal) {
+ w->viewport.horiz_bar = bar;
+ constraints->form.vert_base = bar;
+ }
+ else {
+ w->viewport.vert_bar = bar;
+ constraints->form.horiz_base = bar;
+ }
+
+ XtManageChild(bar);
+
+ return (bar);
+}
+
+/*ARGSUSED*/
+static void
+XawViewportInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ ViewportWidget w = (ViewportWidget)cnew;
+ static Arg clip_args[8];
+ Cardinal arg_cnt;
+ Widget h_bar, v_bar;
+ Dimension clip_height, clip_width;
+
+ w->form.default_spacing = 0; /* Reset the default spacing to 0 pixels */
+
+ /*
+ * Initialize all widget pointers to NULL
+ */
+ w->viewport.child = NULL;
+ w->viewport.horiz_bar = w->viewport.vert_bar = NULL;
+
+ /*
+ * Create Clip Widget
+ */
+ arg_cnt = 0;
+ XtSetArg(clip_args[arg_cnt], XtNbackgroundPixmap, None); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNborderWidth, 0); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNleft, XtChainLeft); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNright, XtChainRight); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNtop, XtChainTop); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNbottom, XtChainBottom); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNwidth, XtWidth(w)); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNheight, XtHeight(w)); arg_cnt++;
+
+ w->viewport.clip = XtCreateManagedWidget("clip", widgetClass, cnew,
+ clip_args, arg_cnt);
+
+ if (!w->viewport.forcebars)
+ return; /* If we are not forcing the bars then we are done */
+
+ if (w->viewport.allowhoriz)
+ (void)CreateScrollbar(w, True);
+ if (w->viewport.allowvert)
+ (void)CreateScrollbar(w, False);
+
+ h_bar = w->viewport.horiz_bar;
+ v_bar = w->viewport.vert_bar;
+
+ /*
+ * Set the clip widget to the correct height
+ */
+ clip_width = XtWidth(w);
+ clip_height = XtHeight(w);
+
+ if (h_bar != NULL && XtWidth(w) > XtWidth(h_bar) + XtBorderWidth(h_bar))
+ clip_width -= XtWidth(h_bar) + XtBorderWidth(h_bar);
+
+ if (v_bar != NULL && XtHeight(w) > XtHeight(v_bar) + XtBorderWidth(v_bar))
+ clip_height -= XtHeight(v_bar) + XtBorderWidth(v_bar);
+
+ arg_cnt = 0;
+ XtSetArg(clip_args[arg_cnt], XtNwidth, clip_width); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNheight, clip_height); arg_cnt++;
+ XtSetValues(w->viewport.clip, clip_args, arg_cnt);
+}
+
+/*ARGSUSED*/
+static void
+XawViewportConstraintInitialize(Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ ((ViewportConstraints)cnew->core.constraints)->viewport.reparented = False;
+}
+
+static void
+XawViewportRealize(Widget widget, XtValueMask *value_mask,
+ XSetWindowAttributes *attributes)
+{
+ ViewportWidget w = (ViewportWidget)widget;
+ Widget child = w->viewport.child;
+ Widget clip = w->viewport.clip;
+
+ *value_mask |= CWBitGravity;
+ attributes->bit_gravity = NorthWestGravity;
+ (*Superclass->core_class.realize)(widget, value_mask, attributes);
+
+ (*w->core.widget_class->core_class.resize)(widget); /* turn on bars */
+
+ if (child != NULL) {
+ XtMoveWidget(child, 0, 0);
+ XtRealizeWidget(clip);
+ XtRealizeWidget(child);
+ XReparentWindow(XtDisplay(w), XtWindow(child), XtWindow(clip), 0, 0);
+ XtMapWidget(child);
+ }
+}
+
+/*ARGSUSED*/
+static Boolean
+XawViewportSetValues(Widget current, Widget request, Widget cnew,
+ ArgList args, Cardinal *num_args)
+{
+ ViewportWidget w = (ViewportWidget)cnew;
+ ViewportWidget cw = (ViewportWidget)current;
+
+ if (w->viewport.forcebars != cw->viewport.forcebars
+ || w->viewport.allowvert != cw->viewport.allowvert
+ || w->viewport.allowhoriz != cw->viewport.allowhoriz
+ || w->viewport.useright != cw->viewport.useright
+ || w->viewport.usebottom != cw->viewport.usebottom)
+ (*w->core.widget_class->core_class.resize)(cnew); /* Recompute layout */
+
+ return (False);
+}
+
+static void
+XawViewportChangeManaged(Widget widget)
+{
+ ViewportWidget w = (ViewportWidget)widget;
+ int num_children = w->composite.num_children;
+ Widget child, *childP;
+ int i;
+
+ child = NULL;
+ for (childP = w->composite.children,
+ i = 0; i < num_children;
+ childP++, i++) {
+ if (XtIsManaged(*childP)
+ && *childP != w->viewport.clip
+ && *childP != w->viewport.horiz_bar
+ && *childP != w->viewport.vert_bar) {
+ child = *childP;
+ break;
+ }
+ }
+
+ if (child != w->viewport.child) {
+ w->viewport.child = child;
+ if (child != NULL) {
+ XtResizeWidget(child, XtWidth(child), XtHeight(child), 0);
+ if (XtIsRealized(widget)) {
+ ViewportConstraints constraints =
+ (ViewportConstraints)child->core.constraints;
+ if (!XtIsRealized(child)) {
+ Window window = XtWindow(w);
+
+ XtMoveWidget(child, 0, 0);
+ w->core.window = XtWindow(w->viewport.clip);
+ XtRealizeWidget(child);
+ w->core.window = window;
+ constraints->viewport.reparented = True;
+ }
+ else if (!constraints->viewport.reparented) {
+ XReparentWindow(XtDisplay(w), XtWindow(child),
+ XtWindow(w->viewport.clip), 0, 0);
+ constraints->viewport.reparented = True;
+ if (child->core.mapped_when_managed)
+ XtMapWidget(child);
+ }
+ }
+ GetGeometry(widget, XtWidth(child), XtHeight(child));
+ (*((ViewportWidgetClass)w->core.widget_class)->form_class.layout)
+ ((FormWidget)w, XtWidth(w), XtHeight(w), True /* True? */);
+ }
+ }
+
+#ifdef notdef
+ (*Superclass->composite_class.change_managed)(widget);
+#endif
+}
+
+static void
+SetBar(Widget w, int top, unsigned int length, unsigned int total)
+{
+ XawScrollbarSetThumb(w, (float)top / (float)total,
+ (float)length / (float)total);
+}
+
+static void
+RedrawThumbs(ViewportWidget w)
+{
+ Widget child = w->viewport.child;
+ Widget clip = w->viewport.clip;
+
+ if (w->viewport.horiz_bar != NULL)
+ SetBar(w->viewport.horiz_bar, -(int)XtX(child),
+ XtWidth(clip), XtWidth(child));
+
+ if (w->viewport.vert_bar != NULL)
+ SetBar(w->viewport.vert_bar, -(int)XtY(child),
+ XtHeight(clip), XtHeight(child));
+}
+
+static void
+SendReport(ViewportWidget w, unsigned int changed)
+{
+ XawPannerReport rep;
+
+ if (w->viewport.report_callbacks) {
+ Widget child = w->viewport.child;
+ Widget clip = w->viewport.clip;
+
+ rep.changed = changed;
+ rep.slider_x = -XtX(child); /* child is canvas */
+ rep.slider_y = -XtY(child); /* clip is slider */
+ rep.slider_width = XtWidth(clip);
+ rep.slider_height = XtHeight(clip);
+ rep.canvas_width = XtWidth(child);
+ rep.canvas_height = XtHeight(child);
+ XtCallCallbackList((Widget)w, w->viewport.report_callbacks,
+ (XtPointer)&rep);
+ }
+}
+
+static void
+MoveChild(ViewportWidget w, int x, int y)
+{
+ Widget child = w->viewport.child;
+ Widget clip = w->viewport.clip;
+
+ /* make sure we never move past right/bottom borders */
+ if (-x + (int)XtWidth(clip) > XtWidth(child))
+ x = -(int)(XtWidth(child) - XtWidth(clip));
+
+ if (-y + (int)XtHeight(clip) > XtHeight(child))
+ y = -(int)(XtHeight(child) - XtHeight(clip));
+
+ /* make sure we never move past left/top borders */
+ if (x >= 0)
+ x = 0;
+ if (y >= 0)
+ y = 0;
+
+ XtMoveWidget(child, x, y);
+ SendReport(w, (XawPRSliderX | XawPRSliderY));
+
+ RedrawThumbs(w);
+}
+
+static void
+ComputeLayout(Widget widget, Bool query, Bool destroy_scrollbars)
+{
+ ViewportWidget w = (ViewportWidget)widget;
+ Widget child = w->viewport.child;
+ Widget clip = w->viewport.clip;
+ ViewportConstraints constraints =
+ (ViewportConstraints)clip->core.constraints;
+ Bool needshoriz, needsvert;
+ int clip_width, clip_height;
+ XtWidgetGeometry intended;
+
+ if (child == NULL)
+ return;
+
+ clip_width = XtWidth(w);
+ clip_height = XtHeight(w);
+ intended.request_mode = CWBorderWidth;
+ intended.border_width = 0;
+
+ if (w->viewport.forcebars) {
+ needsvert = w->viewport.allowvert;
+ needshoriz = w->viewport.allowhoriz;
+ ComputeWithForceBars(widget, query, &intended,
+ &clip_width, &clip_height);
+ }
+ else {
+ Dimension prev_width, prev_height;
+ XtGeometryMask prev_mode;
+ XtWidgetGeometry preferred;
+
+ needshoriz = needsvert = False;
+
+ /*
+ * intended.{width,height} caches the eventual child dimensions,
+ * but we don't set the mode bits until after we decide that the
+ * child's preferences are not acceptable
+ */
+ if (!w->viewport.allowhoriz)
+ intended.request_mode |= CWWidth;
+
+ if (XtWidth(child) < clip_width)
+ intended.width = clip_width;
+ else
+ intended.width = XtWidth(child);
+
+ if (XtHeight(child) < clip_height)
+ intended.height = clip_height;
+ else
+ intended.height = XtHeight(child);
+
+ if (!w->viewport.allowvert)
+ intended.request_mode |= CWHeight;
+
+ if (!query) {
+ preferred.width = XtWidth(child);
+ preferred.height = XtHeight(child);
+ }
+ do { /* while intended != prev */
+ if (query) {
+ (void)XtQueryGeometry(child, &intended, &preferred);
+ if (!(preferred.request_mode & CWWidth))
+ preferred.width = intended.width;
+ if (!(preferred.request_mode & CWHeight))
+ preferred.height = intended.height;
+ }
+ prev_width = intended.width;
+ prev_height = intended.height;
+ prev_mode = intended.request_mode;
+ /*
+ * note that having once decided to turn on either bar
+ * we'll not change our mind until we're next resized,
+ * thus avoiding potential oscillations
+ */
+#define CheckHoriz() \
+ if (w->viewport.allowhoriz && \
+ preferred.width > clip_width) { \
+ if (!needshoriz) { \
+ Widget bar; \
+ \
+ needshoriz = True; \
+ if ((bar = w->viewport.horiz_bar) == NULL) \
+ bar = CreateScrollbar(w, True); \
+ clip_height -= XtHeight(bar) + XtBorderWidth(bar); \
+ if (clip_height < 1) \
+ clip_height = 1; \
+ } \
+ intended.width = preferred.width; \
+ }
+
+ CheckHoriz();
+ if (w->viewport.allowvert && preferred.height > clip_height) {
+ if (!needsvert) {
+ Widget bar;
+ needsvert = True;
+ if ((bar = w->viewport.vert_bar) == NULL)
+ bar = CreateScrollbar(w, False);
+ clip_width -= XtWidth(bar) + XtBorderWidth(bar);
+ if (clip_width < 1)
+ clip_width = 1;
+ CheckHoriz();
+ }
+ intended.height = preferred.height;
+ }
+ if (!w->viewport.allowhoriz || preferred.width < clip_width) {
+ intended.width = clip_width;
+ intended.request_mode |= CWWidth;
+ }
+ if (!w->viewport.allowvert || preferred.height < clip_height) {
+ intended.height = clip_height;
+ intended.request_mode |= CWHeight;
+ }
+ } while (intended.request_mode != prev_mode
+ || (intended.request_mode & CWWidth
+ && intended.width != prev_width)
+ || (intended.request_mode & CWHeight
+ && intended.height != prev_height));
+ }
+
+ if (XtIsRealized(clip))
+ XRaiseWindow(XtDisplay(clip), XtWindow(clip));
+
+ XtMoveWidget(clip,
+ needsvert ? w->viewport.useright ? 0 :
+ XtWidth(w->viewport.vert_bar)
+ + XtBorderWidth(w->viewport.vert_bar) : 0,
+ needshoriz ? w->viewport.usebottom ? 0 :
+ XtHeight(w->viewport.horiz_bar)
+ + XtBorderWidth(w->viewport.horiz_bar) : 0);
+ XtResizeWidget(clip, clip_width, clip_height, 0);
+
+ if (w->viewport.horiz_bar != NULL) {
+ Widget bar = w->viewport.horiz_bar;
+
+ if (!needshoriz) {
+ constraints->form.vert_base = NULL;
+ if (destroy_scrollbars) {
+ XtDestroyWidget(bar);
+ w->viewport.horiz_bar = NULL;
+ }
+ }
+ else {
+ int bw = XtBorderWidth(bar);
+
+ XtResizeWidget(bar, clip_width, XtHeight(bar), bw);
+ XtMoveWidget(bar,
+ needsvert && !w->viewport.useright
+ ? XtWidth(w->viewport.vert_bar) : -bw,
+ w->viewport.usebottom
+ ? XtHeight(w) - XtHeight(bar) - bw : -bw);
+ XtSetMappedWhenManaged(bar, True);
+ }
+ }
+
+ if (w->viewport.vert_bar != NULL) {
+ Widget bar = w->viewport.vert_bar;
+
+ if (!needsvert) {
+ constraints->form.horiz_base = NULL;
+ if (destroy_scrollbars) {
+ XtDestroyWidget(bar);
+ w->viewport.vert_bar = NULL;
+ }
+ }
+ else {
+ int bw = bar->core.border_width;
+
+ XtResizeWidget(bar, XtWidth(bar), clip_height, bw);
+ XtMoveWidget(bar,
+ w->viewport.useright
+ ? XtWidth(w) - XtWidth(bar) - bw : -bw,
+ needshoriz && !w->viewport.usebottom
+ ? XtHeight(w->viewport.horiz_bar) : -bw);
+ XtSetMappedWhenManaged(bar, True);
+ }
+ }
+
+ if (child != NULL) {
+ XtResizeWidget(child, intended.width, intended.height, 0);
+ MoveChild(w, needshoriz ? XtX(child) : 0, needsvert ? XtY(child) : 0);
+ }
+
+ SendReport (w, XawPRAll);
+}
+
+/*
+ * Function:
+ * ComputeWithForceBars
+ *
+ * Parameters:
+ * widget - viewport widget
+ * query - whether or not to query the child
+ * intended - cache of the childs height is stored here
+ * (used and returned)
+ * clip_width - size of clip window (used and returned)
+ * clip_height - ""
+ *
+ * Description:
+ * Computes the layout give forcebars is set.
+ */
+static void
+ComputeWithForceBars(Widget widget, Bool query, XtWidgetGeometry *intended,
+ int *clip_width, int *clip_height)
+{
+ ViewportWidget w = (ViewportWidget)widget;
+ Widget child = w->viewport.child;
+ XtWidgetGeometry preferred;
+
+ /*
+ * If forcebars then needs = allows = has
+ * Thus if needsvert is set it MUST have a scrollbar
+ */
+ if (w->viewport.allowvert) {
+ if (w->viewport.vert_bar == NULL)
+ w->viewport.vert_bar = CreateScrollbar(w, False);
+
+ *clip_width -= XtWidth(w->viewport.vert_bar) +
+ XtBorderWidth(w->viewport.vert_bar);
+ }
+
+ if (w->viewport.allowhoriz) {
+ if (w->viewport.horiz_bar == NULL)
+ w->viewport.horiz_bar = CreateScrollbar(w, True);
+
+ *clip_height -= XtHeight(w->viewport.horiz_bar) +
+ XtBorderWidth(w->viewport.horiz_bar);
+ }
+
+ AssignMax(*clip_width, 1);
+ AssignMax(*clip_height, 1);
+
+ if (!w->viewport.allowvert) {
+ intended->height = *clip_height;
+ intended->request_mode = CWHeight;
+ }
+ if (!w->viewport.allowhoriz) {
+ intended->width = *clip_width;
+ intended->request_mode = CWWidth;
+ }
+
+ if (query) {
+ if (w->viewport.allowvert || w->viewport.allowhoriz) {
+ XtQueryGeometry(child, intended, &preferred);
+
+ if (!(intended->request_mode & CWWidth)) {
+ if (preferred.request_mode & CWWidth)
+ intended->width = preferred.width;
+ else
+ intended->width = XtWidth(child);
+ }
+
+ if (!(intended->request_mode & CWHeight)) {
+ if (preferred.request_mode & CWHeight)
+ intended->height = preferred.height;
+ else
+ intended->height = XtHeight(child);
+ }
+ }
+ }
+ else {
+ if (w->viewport.allowvert)
+ intended->height = XtHeight(child);
+ if (w->viewport.allowhoriz)
+ intended->width = XtWidth(child);
+ }
+
+ if (*clip_width > (int)intended->width)
+ intended->width = *clip_width;
+ if (*clip_height > (int)intended->height)
+ intended->height = *clip_height;
+}
+
+static void
+XawViewportResize(Widget widget)
+{
+ ComputeLayout(widget, True, True);
+}
+
+/*ARGSUSED*/
+static Boolean
+Layout(FormWidget w, unsigned int width, unsigned int height, Bool force)
+{
+ ComputeLayout((Widget)w, True, True);
+ w->form.preferred_width = XtWidth(w);
+ w->form.preferred_height = XtHeight(w);
+
+ return (False);
+}
+
+static void
+ScrollUpDownProc(Widget widget, XtPointer closure, XtPointer call_data)
+{
+ ViewportWidget w = (ViewportWidget)closure;
+ Widget child = w->viewport.child;
+ int pix = (long)call_data;
+ int x, y;
+
+ if (child == NULL)
+ return;
+
+ x = XtX(child) - (widget == w->viewport.horiz_bar ? pix : 0);
+ y = XtY(child) - (widget == w->viewport.vert_bar ? pix : 0);
+ MoveChild(w, x, y);
+}
+
+/*ARGSUSED*/
+static void
+ThumbProc(Widget widget, XtPointer closure, XtPointer call_data)
+{
+ ViewportWidget w = (ViewportWidget)closure;
+ Widget child = w->viewport.child;
+ float percent = *(float *)call_data;
+ int x, y;
+
+ if (child == NULL)
+ return;
+
+ if (widget == w->viewport.horiz_bar)
+ x = -percent * XtWidth(child);
+ else
+ x = XtX(child);
+
+ if (widget == w->viewport.vert_bar)
+ y = -percent * XtHeight(child);
+ else
+ y = XtY(child);
+
+ MoveChild(w, x, y);
+}
+
+static XtGeometryResult
+TestSmaller(ViewportWidget w, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply_return)
+{
+ if (request->width < XtWidth(w) || request->height < XtHeight(w))
+ return (XtMakeGeometryRequest((Widget)w, request, reply_return));
+
+ return (XtGeometryYes);
+}
+
+static XtGeometryResult
+GeometryRequestPlusScrollbar(ViewportWidget w, Bool horizontal,
+ XtWidgetGeometry *request,
+ XtWidgetGeometry *reply_return)
+{
+ Widget sb;
+ XtWidgetGeometry plusScrollbars;
+
+ plusScrollbars = *request;
+ if ((sb = w->viewport.horiz_bar) == NULL)
+ sb = CreateScrollbar(w, horizontal);
+ request->width += XtWidth(sb);
+ request->height += XtHeight(sb);
+ XtDestroyWidget(sb);
+ return (XtMakeGeometryRequest((Widget)w, &plusScrollbars, reply_return));
+}
+
+#define WidthChange() (request->width != XtWidth(w))
+#define HeightChange() (request->height != XtHeight(w))
+static XtGeometryResult
+QueryGeometry(ViewportWidget w, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply_return)
+{
+ if (w->viewport.allowhoriz && w->viewport.allowvert)
+ return (TestSmaller(w, request, reply_return));
+
+ else if (w->viewport.allowhoriz && !w->viewport.allowvert) {
+ if (WidthChange() && !HeightChange())
+ return (TestSmaller(w, request, reply_return));
+ else if (!WidthChange() && HeightChange())
+ return (XtMakeGeometryRequest((Widget)w, request, reply_return));
+ else if (WidthChange() && HeightChange())
+ return (GeometryRequestPlusScrollbar(w, True, request, reply_return));
+ else /* !WidthChange() && !HeightChange() */
+ return (XtGeometryYes);
+ }
+ else if (!w->viewport.allowhoriz && w->viewport.allowvert) {
+ if (!WidthChange() && HeightChange())
+ return (TestSmaller(w, request, reply_return));
+ else if (WidthChange() && !HeightChange())
+ return (XtMakeGeometryRequest((Widget)w, request, reply_return));
+ else if (WidthChange() && HeightChange())
+ return (GeometryRequestPlusScrollbar(w, False, request, reply_return));
+ else /* !WidthChange() && !HeightChange() */
+ return (XtGeometryYes);
+ }
+ else /* (!w->viewport.allowhoriz && !w->viewport.allowvert) */
+ return (XtMakeGeometryRequest((Widget)w, request, reply_return));
+}
+#undef WidthChange
+#undef HeightChange
+
+static XtGeometryResult
+XawViewportGeometryManager(Widget child, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+ ViewportWidget w = (ViewportWidget)child->core.parent;
+ Bool rWidth = (request->request_mode & CWWidth) != 0;
+ Bool rHeight = (request->request_mode & CWHeight) != 0;
+ XtWidgetGeometry allowed;
+ XtGeometryResult result;
+ Bool reconfigured;
+ Bool child_changed_size;
+ unsigned int height_remaining;
+
+ if (request->request_mode & XtCWQueryOnly)
+ return (QueryGeometry(w, request, reply));
+
+ if (child != w->viewport.child
+ || request->request_mode & ~(CWWidth | CWHeight | CWBorderWidth)
+ || ((request->request_mode & CWBorderWidth)
+ && request->border_width > 0))
+ return (XtGeometryNo);
+
+ allowed = *request;
+
+ reconfigured = GetGeometry((Widget)w,
+ rWidth ? request->width : XtWidth(w),
+ rHeight ? request->height : XtHeight(w));
+
+ child_changed_size = (rWidth && XtWidth(child) != request->width) ||
+ (rHeight && XtHeight(child) != request->height);
+
+ height_remaining = XtHeight(w);
+ if (rWidth && XtWidth(w) != request->width) {
+ if (w->viewport.allowhoriz && request->width > XtWidth(w)) {
+ /* horizontal scrollbar will be needed so possibly reduce height */
+ Widget bar;
+
+ if ((bar = w->viewport.horiz_bar) == NULL)
+ bar = CreateScrollbar(w, True);
+ height_remaining -= XtHeight(bar) + XtBorderWidth(bar);
+ reconfigured = True;
+ }
+ else
+ allowed.width = XtWidth(w);
+ }
+ if (rHeight && height_remaining != request->height) {
+ if (w->viewport.allowvert && request->height > height_remaining) {
+ /* vertical scrollbar will be needed, so possibly reduce width */
+ if (!w->viewport.allowhoriz || request->width < XtWidth(w)) {
+ Widget bar;
+
+ if ((bar = w->viewport.vert_bar) == NULL)
+ bar = CreateScrollbar(w, False);
+ if (!rWidth) {
+ allowed.width = XtWidth(w);
+ allowed.request_mode |= CWWidth;
+ }
+ if (allowed.width > XtWidth(bar) + XtBorderWidth(bar))
+ allowed.width -= XtWidth(bar) + XtBorderWidth(bar);
+ else
+ allowed.width = 1;
+ reconfigured = True;
+ }
+ }
+ else
+ allowed.height = height_remaining;
+ }
+
+ if (allowed.width != request->width || allowed.height != request->height) {
+ *reply = allowed;
+ result = XtGeometryAlmost;
+ }
+ else {
+ if (rWidth)
+ XtWidth(child) = request->width;
+ if (rHeight)
+ XtHeight(child) = request->height;
+ result = XtGeometryYes;
+ }
+
+ if (reconfigured || child_changed_size)
+ ComputeLayout((Widget)w, False, result == XtGeometryYes);
+
+ return (result);
+}
+
+static Bool
+GetGeometry(Widget w, unsigned int width, unsigned int height)
+{
+ XtWidgetGeometry geometry, return_geom;
+ XtGeometryResult result;
+
+ if (width == XtWidth(w) && height == XtHeight(w))
+ return (False);
+
+ geometry.request_mode = CWWidth | CWHeight;
+ geometry.width = width;
+ geometry.height = height;
+
+ if (XtIsRealized(w)) {
+ if (((ViewportWidget)w)->viewport.allowhoriz && width > XtWidth(w))
+ geometry.width = XtWidth(w);
+ if (((ViewportWidget)w)->viewport.allowvert && height > XtHeight(w))
+ geometry.height = XtHeight(w);
+ }
+ else {
+ /* This is the Realize call; we'll inherit a w&h iff none currently */
+ if (XtWidth(w) != 0) {
+ if (XtHeight(w) != 0)
+ return (False);
+ geometry.width = XtWidth(w);
+ }
+ if (XtHeight(w) != 0)
+ geometry.height = XtHeight(w);
+ }
+
+ result = XtMakeGeometryRequest(w, &geometry, &return_geom);
+ if (result == XtGeometryAlmost)
+ result = XtMakeGeometryRequest(w, &return_geom, NULL);
+
+ return (result == XtGeometryYes);
+}
+
+static XtGeometryResult
+XawViewportQueryGeometry(Widget w, XtWidgetGeometry *constraints,
+ XtWidgetGeometry *reply)
+{
+ if (((ViewportWidget)w)->viewport.child != NULL)
+ return (XtQueryGeometry(((ViewportWidget)w)->viewport.child,
+ constraints, reply));
+
+ return (XtGeometryYes);
+}
+
+void
+XawViewportSetLocation
+(
+ Widget gw,
+#if NeedWidePrototypes
+ double xoff, double yoff
+#else
+ float xoff, float yoff
+#endif
+ )
+{
+ ViewportWidget w = (ViewportWidget)gw;
+ Widget child = w->viewport.child;
+ int x, y;
+
+ if (xoff > 1.0) /* scroll to right */
+ x = XtWidth(child);
+ else if (xoff < 0.0) /* if the offset is < 0.0 nothing */
+ x = XtX(child);
+ else
+ x = (float)XtWidth(child) * xoff;
+
+ if (yoff > 1.0)
+ y = XtHeight(child);
+ else if (yoff < 0.0)
+ y = XtY(child);
+ else
+ y = (float)XtHeight(child) * yoff;
+
+ MoveChild (w, -x, -y);
+}
+
+void
+XawViewportSetCoordinates(Widget gw,
+#if NeedWidePrototypes
+ int x, int y
+#else
+ Position x, Position y
+#endif
+)
+{
+ ViewportWidget w = (ViewportWidget)gw;
+ Widget child = w->viewport.child;
+
+ if (x > XtWidth(child))
+ x = XtWidth(child);
+ else if (x < 0)
+ x = XtX(child);
+
+ if (y > XtHeight(child))
+ y = XtHeight(child);
+ else if (y < 0)
+ y = XtY(child);
+
+ MoveChild (w, -x, -y);
+}
diff --git a/nx-X11/lib/Xaw/Viewport.h b/nx-X11/lib/Xaw/Viewport.h
new file mode 100644
index 000000000..a4b678c83
--- /dev/null
+++ b/nx-X11/lib/Xaw/Viewport.h
@@ -0,0 +1,121 @@
+/* $Xorg: Viewport.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1987, 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.
+
+
+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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xaw/Viewport.h,v 1.6 2001/01/17 19:42:36 dawes Exp $ */
+
+#ifndef _XawViewport_h
+#define _XawViewport_h
+
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Reports.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ allowHoriz Boolean Boolean False
+ allowVert Boolean Boolean False
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ destroyCallback Callback Pointer NULL
+ forceBars Boolean Boolean False
+ height Height Dimension 0
+ mappedWhenManaged MappedWhenManaged Boolean True
+ reportCallback ReportCallback Pointer NULL
+ sensitive Sensitive Boolean True
+ useBottom Boolean Boolean False
+ useRight Boolean Boolean False
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#ifndef _XtStringDefs_h_
+#define XtNforceBars "forceBars"
+#define XtNallowHoriz "allowHoriz"
+#define XtNallowVert "allowVert"
+#define XtNuseBottom "useBottom"
+#define XtNuseRight "useRight"
+#endif
+
+extern WidgetClass viewportWidgetClass;
+
+typedef struct _ViewportClassRec *ViewportWidgetClass;
+typedef struct _ViewportRec *ViewportWidget;
+
+_XFUNCPROTOBEGIN
+
+void XawViewportSetLocation
+(
+ Widget gw,
+#if NeedWidePrototypes
+ double xoff,
+ double yoff
+#else
+ float xoff,
+ float yoff
+#endif
+ );
+
+void XawViewportSetCoordinates
+(
+ Widget gw,
+#if NeedWidePrototypes
+ int x,
+ int y
+#else
+ Position x,
+ Position y
+#endif
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XawViewport_h */
diff --git a/nx-X11/lib/Xaw/ViewportP.h b/nx-X11/lib/Xaw/ViewportP.h
new file mode 100644
index 000000000..9de6eaed8
--- /dev/null
+++ b/nx-X11/lib/Xaw/ViewportP.h
@@ -0,0 +1,109 @@
+/*
+ * $Xorg: ViewportP.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+ * Private declarations for ViewportWidgetClass
+ */
+
+/************************************************************
+
+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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xaw/ViewportP.h,v 1.7 2001/01/17 19:42:36 dawes Exp $ */
+
+#ifndef _ViewportP_h
+#define _ViewportP_h
+
+#include <X11/Xaw/Viewport.h>
+#include <X11/Xaw/FormP.h>
+
+typedef struct {
+ XtPointer extension;
+} ViewportClassPart;
+
+typedef struct _ViewportClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ConstraintClassPart constraint_class;
+ FormClassPart form_class;
+ ViewportClassPart viewport_class;
+} ViewportClassRec;
+
+extern ViewportClassRec viewportClassRec;
+
+typedef struct _ViewportPart {
+ /* resources */
+ Boolean forcebars; /* Whether we should always display
+ the selected scrollbars */
+ Boolean allowhoriz; /* Whether we allow horizontal scrollbars */
+ Boolean allowvert; /* Whether we allow vertical scrollbars */
+ Boolean usebottom; /* True if horiz bars appear at bottom */
+ Boolean useright; /* True if vert bars appear at right */
+ XtCallbackList report_callbacks;/* when size/position changes */
+
+ /* private */
+ Widget clip, child; /* The clipping and (scrolled) child widgets */
+ Widget horiz_bar, vert_bar; /* What scrollbars we currently have */
+#ifndef OLDXAW
+ XtPointer pad[4]; /* for future use and keep binary compatability */
+#endif
+} ViewportPart;
+
+typedef struct _ViewportRec {
+ CorePart core;
+ CompositePart composite;
+ ConstraintPart constraint;
+ FormPart form;
+ ViewportPart viewport;
+} ViewportRec;
+
+typedef struct {
+ Bool reparented; /* True if child has been re-parented */
+} ViewportConstraintsPart;
+
+typedef struct _ViewportConstraintsRec {
+ FormConstraintsPart form;
+ ViewportConstraintsPart viewport;
+} ViewportConstraintsRec, *ViewportConstraints;
+
+#endif /* _ViewportP_h */
diff --git a/nx-X11/lib/Xaw/Xaw-def.cpp b/nx-X11/lib/Xaw/Xaw-def.cpp
new file mode 100644
index 000000000..45666d378
--- /dev/null
+++ b/nx-X11/lib/Xaw/Xaw-def.cpp
@@ -0,0 +1,157 @@
+LIBRARY Xaw
+VERSION LIBRARY_VERSION
+EXPORTS
+ asciiSinkClassRec DATA
+ asciiSinkObjectClass DATA
+ asciiSrcClassRec DATA
+ asciiSrcObjectClass DATA
+ asciiTextClassRec DATA
+ asciiTextWidgetClass DATA
+ boxClassRec DATA
+ boxWidgetClass DATA
+ commandClassRec DATA
+ commandWidgetClass DATA
+ dialogClassRec DATA
+ dialogWidgetClass DATA
+ FMT8BIT DATA
+ formClassRec DATA
+ formWidgetClass DATA
+ gripClassRec DATA
+ gripWidgetClass DATA
+ labelClassRec DATA
+ labelWidgetClass DATA
+ listClassRec DATA
+ listWidgetClass DATA
+ menuButtonClassRec DATA
+ menuButtonWidgetClass DATA
+ multiSinkClassRec DATA
+ multiSinkObjectClass DATA
+ multiSrcClassRec DATA
+ multiSrcObjectClass DATA
+ panedClassRec DATA
+ panedWidgetClass DATA
+ pannerClassRec DATA
+ pannerWidgetClass DATA
+ portholeClassRec DATA
+ portholeWidgetClass DATA
+ repeaterClassRec DATA
+ repeaterWidgetClass DATA
+ scrollbarClassRec DATA
+ scrollbarWidgetClass DATA
+ simpleClassRec DATA
+ simpleMenuClassRec DATA
+ simpleMenuWidgetClass DATA
+ simpleWidgetClass DATA
+ smeBSBClassRec DATA
+ smeBSBObjectClass DATA
+ smeClassRec DATA
+ smeLineClassRec DATA
+ smeLineObjectClass DATA
+ smeObjectClass DATA
+ stripChartClassRec DATA
+ stripChartWidgetClass DATA
+ textClassRec DATA
+ textSinkClassRec DATA
+ textSinkObjectClass DATA
+ textSrcClassRec DATA
+ textSrcObjectClass DATA
+ textWidgetClass DATA
+ toggleClassRec DATA
+ toggleWidgetClass DATA
+ treeClassRec DATA
+ treeWidgetClass DATA
+#ifndef __UNIXOS2__
+ vendorShellClassRec DATA
+ vendorShellWidgetClass DATA
+#endif
+ viewportClassRec DATA
+ viewportWidgetClass DATA
+ XawAsciiSave
+ XawAsciiSaveAsFile
+ XawAsciiSourceChanged
+ XawAsciiSourceFreeString
+ XawDialogAddButton
+ XawDialogGetValueString
+ XawFmt8Bit
+ XawFmtWide
+ XawFormDoLayout
+ XawInitializeWidgetSet
+ XawListChange
+ XawListHighlight
+ XawListShowCurrent
+ XawListUnhighlight
+ XawPanedAllowResize
+ XawPanedGetMinMax
+ XawPanedGetNumSub
+ XawPanedSetMinMax
+ XawPanedSetRefigureMode
+ XawScrollbarSetThumb
+ XawSimpleMenuAddGlobalActions
+ XawSimpleMenuClearActiveEntry
+ XawSimpleMenuGetActiveEntry
+ XawTextDisableRedisplay
+ XawTextDisplay
+ XawTextDisplayCaret
+ XawTextEnableRedisplay
+ XawTextGetInsertionPoint
+ XawTextGetSelectionPos
+ XawTextGetSource
+ XawTextInvalidate
+ XawTextReplace
+ XawTextSearch
+ XawTextSetInsertionPoint
+ XawTextSetSelection
+ XawTextSetSelectionArray
+ XawTextSetSource
+ XawTextSinkClearToBackground
+ XawTextSinkDisplayText
+ XawTextSinkFindDistance
+ XawTextSinkFindPosition
+ XawTextSinkGetCursorBounds
+ XawTextSinkInsertCursor
+ XawTextSinkMaxHeight
+ XawTextSinkMaxLines
+ XawTextSinkResolve
+ XawTextSinkSetTabs
+ XawTextSourceConvertSelection
+ XawTextSourceRead
+ XawTextSourceReplace
+ XawTextSourceScan
+ XawTextSourceSearch
+ XawTextSourceSetSelection
+ XawTextTopPosition
+ XawTextUnsetSelection
+ XawToggleChangeRadioGroup
+ XawToggleGetCurrent
+ XawToggleSetCurrent
+ XawToggleUnsetCurrent
+ XawTreeForceLayout
+ xawvendorShellExtClassRec
+ XawVendorShellExtResize
+ xawvendorShellExtWidgetClass
+ XawViewportSetCoordinates
+ XawViewportSetLocation
+ XawWidgetArray
+ XawWidgetCount
+#ifdef __UNIXOS2__ /* xconsole */
+ _XawTextGetSTRING
+ XawTextSourceAddEntity
+ XawTextSourceAnchorAndEntity
+ XawTextSourceNextAnchor
+ XawTextSourcePrevAnchor
+ XawTextSourceFindAnchor
+ _XawTextShowPosition
+ _XawTextSrcUndo
+ XawTextSinkConvertPropertyList
+ XawTextGetSink
+ _XawTextBuildLineTable
+ XawTextSourceClearEntities
+ _XawTextNeedsUpdating
+ XawTextSinkCopyProperty
+ XawTextSinkGetProperty
+ XawTextSinkCombineProperty
+ XawTextSinkAddProperty
+ XawTextLastPosition
+#endif
+/* $Xorg: Xaw-def.cpp,v 1.3 2000/08/17 19:45:44 cpqbld Exp $ */
+/* $XFree86: xc/lib/Xaw/Xaw-def.cpp,v 1.2 2002/05/31 18:45:44 dawes Exp $ */
diff --git a/nx-X11/lib/Xaw/Xaw.man b/nx-X11/lib/Xaw/Xaw.man
new file mode 100644
index 000000000..8803f10f9
--- /dev/null
+++ b/nx-X11/lib/Xaw/Xaw.man
@@ -0,0 +1,588 @@
+.\"
+.\" Copyright (c) 1999 by The XFree86 Project, Inc.
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining a
+.\" copy of this software and associated documentation files (the "Software"),
+.\" to deal in the Software without restriction, including without limitation
+.\" the rights to use, copy, modify, merge, publish, distribute, sublicense,
+.\" and/or sell copies of the Software, and to permit persons to whom the
+.\" Software is furnished to do so, subject to the following conditions:
+.\"
+.\" 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 XFREE86 PROJECT 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 XFree86 Project 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
+.\" XFree86 Project.
+.\"
+.\" Author: Paulo César Pereira de Andrade
+.\"
+.\" $XFree86: xc/lib/Xaw/Xaw.man,v 1.7 2001/11/04 21:16:39 paulo Exp $
+.\"
+.de TQ
+.br
+.ns
+.TP \\$1
+..
+.TH Xaw 3 __vendorversion__
+.SH NAME
+ Xaw \- X Athena Widgets
+.SH DESCRIPTION
+.B Xaw
+is a widget set based on the X Toolkit Intrinsics (Xt) Library. This
+release by the X.org Foundation includes additions and modifications
+originally made for The XFree86 Project, Inc. This manual page describes
+these changes as well as some of the common interfaces between its version
+and the previous X Consortium release (Xaw6).
+.SH ACTIONS
+All of the \fIXaw\fR widgets now have the additional translations
+.B call-proc, declare, get-values
+and \fBset-values\fP. The syntax for these actions is:
+.PP
+.I action-name \fP(\fIboolean-expression\fP, \fIarguments\fP)
+.PP
+\fBAction-name\fP is one of \fIcall-proc\fP, \fIdeclare\fP,
+\fIget-values\fP or \fIset-values\fP.
+.PP
+\fBBoolean-expression\fP is composed with the operators \fI|\fR (or), \fI&\fR
+(and), \fI^\fR (xor), and \fI~\fR (not). The operands can be a variable name,
+which starts with a \fI$\fR; a resource name without the bindings \fI.\fP
+or \fI*\fP; or a constant name, including \fImine\fP (event->xany.window
+== XtWindow(widget)), \fIfaked\fP (event->xany.send_event != 0), \fItrue\fP (1)
+and \fIfalse\fP (0).
+.PP
+\fBArguments\fP are self-explanatory; when starting with a \fI$\fP they name
+a variable, otherwise, they indicate a resource name.
+.TP 8
+.B call-proc \fP(\fIboolean-expression\fP, \fIprocedure-name\fP)
+This action allows the evaluation of a boolean expression in the first
+parameter before calling a action procedure. The procedure is only called
+if the expression evaluates as true. Example:
+.br
+.I call-proc("$inside & $pressed", notify)
+.TP 8
+.B declare \fP(\fIboolean-expression\fP, \fIvariable\fP, \fIvalue\fP, ...)
+This action is used to create new variables or change their values. Any
+number of variable-value tuples may be specified. Example:
+.br
+.I declare(1, $pressed, 1)
+.TP 8
+.B get-values \fP(\fIboolean-expression\fP, \fIvariable\fP, \fIvalue\fP, ...)
+This action reads a widget resource value into a variable. Any number of
+variable-value tuples may be specified. Example:
+.br
+.I get-values(1, $fg, foreground, $bg, background)
+.TP 8
+.B set-values \fP(\fIboolean-expression\fP, \fIvariable\fP, \fIvalue\fP, ...)
+This action sets a widget resource to the given value, which may be a
+variable. Any number of variable-value tuples may be specified. Example:
+.br
+.I set-values(1, foreground, $bg, background, $fg)
+.PP
+Here is a sample translation to make a label widget behave like a button:
+.PP
+.nf
+<Map>: get-values(1, $fg, foreground, $bg, background)\\n\\
+<Btn1Down>: set-values(1, foreground, yellow, background, gray30)\\n\\
+<Btn1Up>: set-values(1, foreground, $fg, background, $bg)
+.fi
+.SH DISPLAY LISTS
+All of the \fBXaw\fP widgets have now the additional resource
+\fIdisplayList\fP. This resource allows drawing the widget decorations
+using commands embedded in a resource string. The displayList resource has
+the syntax:
+.PP
+\fI[class-name:]function-name arguments[[{;\\n}]...]\fP
+.PP
+\fBClass-name\fP is any registered set of functions to draw in the widget.
+Currently the only existing class is \fIxlib\fP, which provides access to
+the Xlib drawing primitives.
+.PP
+\fBFunction-name\fP is the drawing or configuration function to be called,
+described bellow.
+.PP
+\fBArguments\fP may be anything suitable to the displayList function being
+called. When the function requires a coordinate, the syntax is
+\fI{+-}<integer>\fP or \fI<integer>/<integer>\fP. Examples:
+.nf
+ +0,+0 top, left
+ -0,-0 bottom, right
+ -+10,-+10 bottom+10, right+10
+ +0,1/2 left, vertical-center
+.fi
+.TP 8
+.B arc-mode \fPmode
+Sets the arc mode. Accepted \fImode\fPs are "pieslice" and "chord", which
+set the arc to ArcPieSlice or ArcChord, respectively. Example:
+.br
+.I arc-mode chord
+.TP 8
+.B bg \fPcolor-spec
+.TQ
+.B background \fPcolor-spec
+Sets the background color. \fIcolor-spec\fP must a valid color
+specification. Example:
+.br
+.I background red
+.TP 8
+.B cap-style \fPstyle
+Sets the cap style. Accepted \fIstyle\fPs are "notlast", "butt", "round",
+and "projecting", which set the cap style to CapNotLast, CapBut, CapRound
+or CapProjecting, respectively. Example:
+.br
+.I cap-style round
+.TP 8
+.B clip-mask \fPpixmap-spec
+Sets the pixmap for the clip mask. Requires a pixmap parameter, as
+described in the \fBPIXMAPS\fP section below. Example:
+.br
+.I clip-mask xlogo11
+.TP 8
+.B clip-origin \fPx,y
+Sets the clip x and y origin. Requires two arguments, the x and y
+coordinates. Example:
+.br
+.I clip-origin 10,10
+.TP 8
+.B clip-rects \fPx1,y1,x2,y2 [...,xn,yn]
+.TQ
+.B clip-rectangles \fPx1,y1,x2,y2 [...,xn,yn]
+Sets a list of rectangles to the clip mask. The number of arguments must
+be a multiple of four. The arguments are coordinates. The parser
+calculates the width and height of the rectangles. Example:
+.br
+.I clip-rects 0,0,10,20, 20,10,30,30
+.TP 8
+.B coord-mode \fPmode
+Changes the coord mode for \fIfill-polygon\fP, \fIdraw-lines\fP, and
+\fIdraw-points\fP. Accepted parameters are "modeorigin" and "previous",
+that sets the coord mode to CoordModeOrigin or CoordModePrevious,
+respectively. Example:
+.br
+.I coord-mode previous
+.TP 8
+.B copy-area \fP{pixmap-spec|.},dstx,dsty[,x2,y2,srcx,srcy]
+Calls XCopyArea. The character \fI.\fP means copy the window contents;
+pixmap-spec is as defined in the \fBPIXMAPS\fP section below. \fIX2\fP and
+\fIy2\fP are the coordinates of the end copy, not the width and height; if
+not defined, the parser calculates them. \fIsrc_x\fP and \fIsrc_y\fP
+default to zero. Example:
+.br
+.I copy-area Term,10,10
+.TP 8
+.B copy-plane \fP{pixmap-spec|.},dstx,dsty[,x2,y2,srcx,srcy,plane]
+Calls XCopyPlane. The character \fI.\fP means copy the window contents;
+pixmap-spec is as defined in the \fBPIXMAPS\fP section below. \fIX2\fP and
+\fIy2\fP are the coordinates of the end copy, not the width and height; if
+not defined, the parser calculates them. \fIsrc_x\fP and \fIsrc_y\fP
+default to zero. \fIPlane\fP defaults to one. Example:
+.br
+.I copy-plane star,10,10
+.TP 8
+.B dashes \fPi1[...,in]
+Sets the dashes for line drawing. Accepts up to 127 arguments. Example:
+.br
+.I dashes 3,7 9,10
+.TP 8
+.B draw-arc \fPx1,y1,x2,y2[,start-angle,end-angle]
+Draws an arc. The four first arguments are the rectangle enclosing the
+arc. The two remaining arguments, if specified, are the start and end
+angle, in degrees. Example:
+.br
+.I draw-arc +0,+0,-1,-1,0,90
+.TP 8
+.B draw-rect \fPx1,y1,x2,y2
+.TQ
+.B draw-rectangle \fPx1,y1,x2,y2
+Draws a rectangle. Requires four arguments, which are the start and end
+coordinate pairs. Example:
+.br
+.I draw-rect +1,+1,-5,-5
+.TP 8
+.B draw-string \fPx,y,"string"
+Draws a text string. Requires three arguments, a x coordinate, a y
+coordinate, and a string. Strings that have white space can be quoted with
+the \fI"\fP character; the backslash character \fI\\\fP can also be used,
+but it will be necessary escape it twice. Example:
+.br
+\fI draw-string 10,10, "Hello world!"\fP
+.TP 8
+.B exposures \fPboolean
+Sets graphics exposures in the GC. Allowed parameters are a integer or the
+strings "true", "false", "on" and "off". Example:
+.br
+.I exposures true
+.TP 8
+.B fill-arc \fPx1,y1,x2,y2[,start-angle,end-angle]
+Like \fIdraw-arc\fP, but fills the contents of the arc with the currently
+selected foreground. Example:
+.br
+.I fill-arc +0,+0,-1,-1,0,180
+.TP 8
+.B fill-poly \fPx1,y1 [...,xn,yn]
+.TQ
+.B fill-polygon \fPx1,y1 [...,xn,yn]
+Like \fIdraw-lines\fP, but fills the enclosed polygon and joins the first
+and last point, if they are not at the same position. Example:
+.br
+.I fill-poly +0,+10, +10,+20, +30,+0
+.TP
+.B fill-rect \fPx1,y1,x2,y2
+.TQ
+.B fill-rectangle \fPx1,y1,x2,y2
+Like \fIdraw-rect\fP, but fills the contents of the rectangle with the
+selected foreground color. Example:
+.br
+.I fill-rect +10,+10,-20,-20
+.TP 8
+.B fill-rule \fPrule
+Sets the fill rule. Accepted parameters are "evenodd" and "winding", which
+set the fill rule to EvenOddRule or WindingRule, respectively. Example:
+.br
+.I
+fill-rule winding
+.TP 8
+.B fill-style \fPstyle
+Sets the fill style. Allowed parameters are "solid", "tiled", "stippled" and
+"opaquestippled", which set the fill style to FillSolid, FillTiled,
+FillStippled or FillOpaqueStippled, respectively. Example:
+.br
+.I fill-style tiled
+.TP 8
+.B font \fPfont-spec
+Sets the font for text functions. Example:
+.br
+.I font -*-*-*-R-*-*-*-120-*-*-*-*-ISO8859-1
+.TP 8
+.B fg \fPcolor-spec
+.TQ
+.B foreground \fPcolor-spec
+Like \fIbackground\fP, but sets the current foreground color. Example:
+.br
+.I foreground blue
+.TP 8
+.B mask
+This command is useful when you want to draw only in the region that really
+needs to be repainted. Requires no arguments.
+.TP 8
+.B function \fPfunction-spec
+Sets the specific GC function. Allowed parameters are "set", "clear", "and",
+"andreverse", "copy", "andinverted", "noop", "xor", "or", "nor", "equiv",
+"invert", "orreverse", "copyinverted" and "nand", which set the function to
+GXset, GXclear, GXand, GXandReverse, GXcopy, GXandInverted, GXnoop, GXxor,
+GXor, GXnor, GXequiv, GXinvert, GXorReverse, GXcopyInverted or GXnand,
+respectively. Example:
+.br
+.I function xor
+.TP 8
+.B join-style \fPstyle
+Sets the join style. Allowed parameters are "miter", "round" and "bevel",
+which set the join style to JoinMiter, JoinRound and JoinBevel,
+respectively. Example:
+.br
+.I join-style round
+.TP 8
+.B image \fP{pixmap-spec},xs,ys,[xe,ye]
+This function is implemented as a way to quickly compose complex
+decorations in widgets. \fIPixmap-spec\fP is as defined in the
+\fBPIXMAPS\fP section below. \fIxs\fP and \fIys\fP are the coordinates from
+where to start copying the pixmap; \fIxe\fP and \fIye\fP are optional (they
+default to xs + pixmap.width and ys + pixmap.height, respectively). If the
+pixmap has a mask, the copy is masked accordingly. Example:
+.br
+.I image pixmap.xpm,0,0,20,20
+.TP 8
+.B line \fPx1,y1,x2,y2
+.TQ
+.B draw-line \fPx1,y1,x2,y2
+Draws a line with the current foreground color. Requires four arguments,
+the starting and ending coordinate pairs. Example:
+.br
+.I line +0,+0, -1,-1
+.TP 8
+.B line-width \fPinteger
+Selects a line width for drawing. Example:
+.br
+.I line-width 2
+.TP 8
+.B line-style \fPstyle
+Sets the line style. Accepted parameters are "solid", "onoffdash" and
+"doubledash", which set the line style to LineSolid, LineOnOffDash or
+LineDoubleDash, respectively. Example:
+.br
+.I line-style onoffdash
+.TP 8
+.B lines \fPx1,y1,x2,y2 [...,xn,yn]
+.TQ
+.B draw-lines \fPx1,y1,x2,y2 [...,xn,yn]
+Draws a list of lines. Any number of argument pairs may be supplied.
+Example:
+.br
+.I lines +0,-1, -1,-1, -1,+0
+.TP 8
+.B paint-string \fPx,y,"string"
+Identical to draw-string, but also uses the background color. Example:
+.br
+\fI paint-string 10,20, "Sample text"\fP
+.TP 8
+.B point \fPx,y
+.TQ
+.B draw-point \fPx,y
+Draws a point. Requires two arguments, a coordinate pair. Example:
+.br
+.I point +10,+10
+.TP 8
+.B plane-mask \fPinteger
+Sets the plane mask. Requires an integer parameter. Example:
+.br
+.I plane-mask -1
+.TP 8
+.B points \fPx1,y1 [...,xn,yn]
+.TQ
+.B draw-points \fPx1,y1 [...,xn,yn]
+Draws a list of points at the specified coordinates. Example:
+.br
+.I points +1,+2, +1,+4, +1,+6
+.TP 8
+.B segments \fPx1,y1,x2,y2 [...,xn,yn]
+.TQ
+.B draw-segments \fPx1,y1,x2,y2 [...,xn,yn]
+Draws a list of segment lines. The number of parameters must be multiple
+of 4. Example:
+.br
+.I segments +1,+2,+1,-3, +2,-2,-3,-2
+.TP 8
+.B shape-mode \fPmode
+Sets the shape mode used in \fIfill-polygon\fP. Accepted parameters are
+"complex", "convex" or "nonconvex", which set the shape mode to Complex,
+Convex or Nonconvex, accordingly. Example:
+.br
+.I shape-mode convex
+.TP 8
+.B stipple \fPpixmap-spec
+Sets the pixmap for a stipple. Requires a pixmap parameter, as described
+in the \fBPIXMAPS\fP section below. Example:
+.br
+.I stipple plaid
+.TP 8
+.B subwindow-mode \fPmode
+Sets the subwindow mode in the GC. Accepted parameters are
+"includeinferiors" and "clipbychildren", which set the subwindow mode to
+IncludeInferiors or ClipByChildren, respectively. Example:
+.br
+.I subwindow-mode includeinferiors
+.TP 8
+.B tile \fPpixmap-spec
+Sets the pixmap for a tile. Requires a pixmap parameter, as described
+in the \fBPIXMAPS\fP section below. Example:
+.br
+.I tile xlogo11?foreground=red&background=gray80
+.TP 8
+.B ts-origin \fPx,y
+Sets the tile stipple x and y origin. Requires two arguments, a x and y
+coordinate. Example:
+.br
+.I ts-origin 10,10
+.TP 8
+.B umask
+Disables the GC mask, if it has been set with the command \fImask\fP.
+Requires no arguments.
+.PP
+Example for drawing a shadow effect in a widget:
+.nf
+foreground gray30;\\
+draw-lines +1,-1,-1,-1,-1,+1;\\
+foreground gray85;\\
+draw-lines -1,+0,+0,+0,+0,-1
+.fi
+.SH PIXMAPS
+A String to Pixmap converter has been added to \fBXaw\fP. This converter
+is meant to be extended, and has enough abstraction to allow loading
+several image formats. It uses a format that resembles a \fIURL\fP, with
+the syntax:
+.PP
+.I [type:]name[?arg=val[{&}...]]
+.PP
+\fBType\fP can be one of \fIbitmap\fP, \fIgradient\fP or \fIxpm\fP.
+.PP
+\fBName\fP may be a file name, or, in the case of type \fIgradient\fP, may be
+either \fIvertical\fP or \fIhorizontal\fP.
+.PP
+\fBArg=val\fP is a list of arguments to the converter. An argument list is
+preceded by a question mark, and multiple arguments are separated by
+ampersands. The most common arguments are \fIforeground\fP and
+\fIbackground\fP. Gradients also support the arguments \fIstart\fP and
+\fIend\fP (colors with which to start and end the gradient); the
+\fPsteps\fP argument, to allow using less colors; and the \fIdimension\fP
+argument to specify the size of the gradient. The \fIxpm\fP converter
+understands the \fIcloseness\fP argument, which aids in using fewer colors
+(useful if you have a limited colormap).
+.SH TEXT WIDGET
+Most of the changes to this version of the Xaw library were done in the
+TextWidget, TextSrcObject, TextSinkObject and related files.
+.PP
+A couple of highly visible changes in the Text widget are due to many bugs
+in the Xaw6 implementation involving scrollbars and auto-resizing.
+Scrollbars being added or removed caused several problems in keeping the
+text cursor visible, and in Xaw6 it was very easy to have a widget thinking
+the cursor was visible, when it was not. Also, permitting automatic
+resizing of the widget to a larger geometry created other problems, making
+it difficult to have a consistent layout in the application, and, if the
+window manager did not interfere, windows larger than the screen could
+result. Therefore, some functionality involving scrollbars and
+auto-resizing has been disabled; see the section on new and modified
+Text widget resources below.
+.PP
+The Text widget's default key bindings were originally based on the Emacs
+text editor. In this release, even more operations familiar to Emacs users
+have been added. New text actions include:
+.TP 8
+.B indent
+Indents text blocks. Not bound by default. The Text widget also does not
+attempt to perform auto-indentation of its source object by default.
+.TP 8
+.B keyboard-reset
+Resets the keyboard state. Reverts the action multiplier to 1, and if undo
+is enabled, toggles between undo and redo. Bound by default to
+\fIControl<Key>G\fP.
+.TP 8
+.B kill-ring-yank
+In this version of Xaw, text killed in any text field is kept in memory,
+allowing cut and paste operations internally to the program between text
+fields. Bound by default to \fIMeta<Key>Y\fP.
+.TP 8
+.B numeric
+Listed here only for purposes of documentation. Called by default when one
+of the characters \fI1, 2, 3, 4, 5, 6, 7, 8, 9, 0,\fP or \fI-\fP is typed,
+allowing composition of the multiplication number of text actions.
+.TP 8
+.B set-keyboard-focus
+Sets the input focus of the top level widget to the text field. Not
+enabled by default, but bound to the \fI<Btn1Down>\fP event.
+.TP 8
+.B toggle-overwrite
+Toggles overwrite mode. In overwrite mode, any text inserted in a text
+field will replace existing text. Bound by default to \fI<Key>Insert\fP.
+.TP 8
+.B undo
+Sets the \fIenableUndo\fP resource of the textSrcObject. Not enabled by
+default, but bound to \fIControl<Key>_\fP.
+.PP
+New and modified Text widget resources include:
+.TP 8
+.B justify (\fPClass\fB Justify)
+Sets the text justification. Can be one of \fIleft, right, center\fP, or
+\fIfull\fP. Only enabled when the \fIautoFill\fP resource is set, and the
+resources \fIleftColumn\fP and \fIrightColumn\fP are correctly set.
+.TP 8
+.B leftColumn (\fPClass\fB Column)
+Specifies the left column at which to break text. Text lines started with
+an alphanumeric character will automatically start at this column.
+.TP 8
+.B positionCallback (\fPClass\fB Callback)
+Allows installation of a callback to be called every time the cursor is
+moved, and/or the file changes its size. The callback is called with a
+pointer to a structure containing the following data:
+.nf
+typedef struct {
+ int line_number;
+ int column_number;
+ XawTextPosition insert_position;
+ XawTextPosition last_position;
+ Boolean overwrite_mode;
+} XawTextPositionInfo;
+.fi
+This callback is intended to help programmers write text editors based
+on the Xaw widget set.
+.TP 8
+.B resize (\fPClass\fB Resize)
+No longer supported, but recognized for backward compatibility with
+resource specifications written for the Xaw6 Text widget.
+.TP 8
+.B rightColumn (\fPClass\fB Column)
+Specifies the right column at which to break text. Text lines started with
+an alphanumeric character will automatically end at this column.
+.TP 8
+.B scrollHorizontal (\fPClass\fB Scroll)
+.TQ
+.B scrollVertical (\fPClass\fB Scroll)
+These resources control the placement of scrollbars on the left and bottom
+edges of the Text widget. They accept the values \fIXawtextScrollAlways\fP
+and \fIXawtextScrollNever\fP. A converter is registered for this resource
+that will convert the following strings: \fIalways\fP and \fInever\fP. The
+value \fIXawtextScrollWhenNeeded\fP (and \fIwhenNeeded\fP, recognized by
+the converter), is accepted for backwards compatibility with resource
+specifications written for the Xaw6 Text widget, but ignored (effectively
+treated as \fIXawtextScrollNever\fP).
+.SH TEXT SOURCE OBJECT
+The textSrcObject allows display of its contents to more than one window,
+and also stores undo information. The new resources for the textSrcObject
+are:
+.TP 8
+.B callback (\fPClass\fB Callback)
+Previous versions of Xaw had this resource in subclasses of the TextSource
+object. This was changed to make it possible to tell the callback the
+state of the text when undo is enabled.
+.TP 8
+.B enableUndo (\fPClass\fB Undo)
+A boolean resource that enables or disables the undo function. The default
+value is False.
+.TP 8
+.B sourceChanged (\fPClass\fB Changed)
+Like the callback resource, this resource was previously in subclasses of
+the TextSource object. It is now in the textSrcObject to control the
+changed/unchanged state when undo is enabled.
+.SH TEXT SINK OBJECT
+The textSinkObject subclasses asciiSinkObject and multiSinkObject have been
+changed slightly to use a new cursor shape (no longer a caret at the
+baseline) that indicates the input focus of the text widget, and allow
+specification of the cursor color. The new resource is:
+.TP 8
+.B cursorColor (\fPClass\fB Color)
+Sets the cursor color of the text. This color is also used to draw
+selected text.
+.SH SIMPLE MENU WIDGET
+The simpleMenuWidget algorithm to lay out menu entries has been changed to
+enable multiple columns when a single column does not fit on the screen.
+It was also modified to enable submenus.
+.SH SME BSB OBJECT
+A new resource has been added to the smeBSBObject to allow binding submenus
+to it. The new resource is:
+.TP 8
+.B menuName (\fPClass\fB MenuName)
+Specifies the name of the popup widget to be popped up when the pointer is
+over the menu entry, or NULL. Note that the named menu must be a child of
+the popup parent of the smeBSBObject.
+.SH RESTRICTIONS
+.B Xaw
+is actively being developed. Programs intending to be fully compatible
+with future releases of the Xaw library should use only the public
+interfaces. While widget subclassification is not a bad thing, and
+sometimes an encouraged programming practice, programs that access private
+data structures may have problems with newer releases in the current stage
+of
+.I Xaw
+development. Efforts are being made to avoid such problems and to guarantee
+that newer releases will be source and binary compatible.
+.SH AUTHORS
+The original X Consortium version of the Athena Widget Set and its
+documentation were the work of many people, including Chris D. Peterson,
+Ralph Swick, Mark Ackerman, Donna Converse, Jim Fulton, Loretta
+Guarino-Reid, Charles Haynes, Rich Hyde, Mary Larson, Joel McCormack, Ron
+Newman, Jeanne Rich, Terry Weissman, Mike Gancarz, Phil Karlton, Kathleen
+Langone, Ram Rao, Smokey Wallace, Al Mento, and Jean Diaz.
+.PP
+The additions and modifications to \fIXaw\fR which were
+originally made for XFree86 were written by Paulo
+C\('esar Pereira de Andrade.
+.SH SEE ALSO
+.I Athena Widget Set - C Language Interface
diff --git a/nx-X11/lib/Xaw/XawI18n.c b/nx-X11/lib/Xaw/XawI18n.c
new file mode 100644
index 000000000..ca95866e5
--- /dev/null
+++ b/nx-X11/lib/Xaw/XawI18n.c
@@ -0,0 +1,104 @@
+/* $Xorg: XawI18n.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/* Copyright 1991 NCR Corporation - Dayton, Ohio, USA */
+
+/*
+ * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
+ * and Nippon Telegraph and Telephone 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 names of OMRON, NTT Software, and NTT
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. OMRON, NTT Software,
+ * and NTT make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OMRON, NTT SOFTWARE, AND NTT, DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL OMRON, NTT SOFTWARE, OR NTT 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.
+ *
+ * Author: Li Yuhong OMRON Corporation
+ */
+
+/*
+
+Copyright 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xaw/XawI18n.c,v 1.7 2001/01/17 19:42:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include "XawI18n.h"
+
+wchar_t
+#if NeedWidePrototypes
+_Xaw_atowc(int c)
+#else
+_Xaw_atowc(unsigned char c)
+#endif
+{
+ wchar_t wc;
+ char str[2];
+
+ str[0] = c;
+ str[1] = '\0';
+
+ mbtowc(&wc, str, 1);
+
+ return (wc);
+}
+
+#ifdef NCR
+int
+_Xaw_iswspace(wchar_t w)
+{
+ int ret = 0;
+ wchar_t s = _Xaw_atowc(' ');
+
+ if (s == w)
+ ret = 1;
+
+ return (ret);
+}
+#endif
+
+int
+_Xaw_iswalnum(wchar_t ch)
+{
+ unsigned char mb[sizeof(wchar_t)];
+
+ wctomb((char*)mb, ch);
+
+ return (isalnum(*mb));
+}
diff --git a/nx-X11/lib/Xaw/XawI18n.h b/nx-X11/lib/Xaw/XawI18n.h
new file mode 100644
index 000000000..481f78a6f
--- /dev/null
+++ b/nx-X11/lib/Xaw/XawI18n.h
@@ -0,0 +1,122 @@
+/* $XdotOrg: xc/lib/Xaw/XawI18n.h,v 1.4 2005/11/08 06:33:25 jkj Exp $ */
+/* $Xorg: XawI18n.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+********************************************************/
+/* $XFree86: xc/lib/Xaw/XawI18n.h,v 3.14 2001/12/14 19:54:46 dawes Exp $ */
+
+#ifdef HAS_WCTYPE_H
+#include <wctype.h>
+#ifndef NO_WIDEC_H
+#include <widec.h>
+#define wcslen(c) wslen(c)
+#define wcscpy(d, s) wscpy(d, s)
+#define wcsncpy(d, s, l) wsncpy(d, s, l)
+#endif
+#endif
+
+#ifdef HAS_WCHAR_H
+#include <wchar.h>
+#endif
+
+#if defined(AIXV3) || defined(__SCO__)
+#include <ctype.h>
+#endif
+
+#ifdef NCR
+#define iswspace(c) _Xaw_iswspace(c)
+int _Xaw_iswspace
+(
+ wchar_t c
+ );
+#endif
+
+#ifdef sony
+#ifndef SVR4
+#include <jctype.h>
+#define iswspace(c) jisspace(c)
+#endif
+#endif
+
+#ifdef QNX4
+#define toascii( c ) ((unsigned)(c) & 0x007f)
+#endif
+
+#include <stdlib.h>
+
+#ifdef USE_XWCHAR_STRING
+int _Xwcslen
+(
+ wchar_t *wstr
+ );
+
+#define wcslen(c) _Xwcslen(c)
+
+wchar_t *_Xwcscpy
+(
+ wchar_t *wstr1,
+ wchar_t *wstr2
+ );
+
+#define wcscpy(d,s) _Xwcscpy(d,s)
+
+wchar_t *_Xwcsncpy
+(
+ wchar_t *wstr1,
+ wchar_t *wstr2,
+ int len
+ );
+
+#define wcsncpy(d, s, l) _Xwcsncpy(d, s, l)
+
+#ifdef USE_XMBTOWC
+#define mbtowc(wc, s, l) _Xmbtowc(wc, s, l)
+#endif
+#endif
+
+wchar_t _Xaw_atowc
+(
+#if NeedWidePrototypes
+ int c
+#else
+ unsigned char c
+#endif
+ );
+
+#ifndef HAS_ISW_FUNCS
+#include <ctype.h>
+#ifndef iswspace
+#define iswspace(c) (isascii(c) && isspace(toascii(c)))
+#endif
+#endif
+
+#ifndef iswalnum
+#define iswalnum(c) _Xaw_iswalnum(c)
+int _Xaw_iswalnum
+(
+ wchar_t c
+ );
+#endif
diff --git a/nx-X11/lib/Xaw/XawIm.c b/nx-X11/lib/Xaw/XawIm.c
new file mode 100644
index 000000000..24b647d81
--- /dev/null
+++ b/nx-X11/lib/Xaw/XawIm.c
@@ -0,0 +1,1613 @@
+/* $Xorg: XawIm.c,v 1.6 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/*
+ * Copyright 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 of 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 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xaw/XawIm.c,v 1.14tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+#include <X11/ShellP.h>
+#include <X11/Xaw/TextP.h>
+#include <X11/Xaw/MultiSrc.h>
+#include <X11/Xaw/MultiSinkP.h>
+#include <X11/Xaw/XawImP.h>
+#include <X11/Xaw/VendorEP.h>
+#include "XawI18n.h"
+#include <ctype.h>
+
+#include <stdarg.h>
+
+#define maxAscentOfFontSet(fontset) \
+ ( - (XExtentsOfFontSet((fontset)))->max_logical_extent.y)
+
+#define maxHeightOfFontSet(fontset) \
+ ((XExtentsOfFontSet((fontset)))->max_logical_extent.height)
+
+#define maxDescentOfFontSet(fontset) \
+ (maxHeightOfFontSet(fontset) - maxAscentOfFontSet(fontset))
+
+#define Offset(field) (XtOffsetOf(XawIcTablePart, field))
+
+/*****************************************************
+ *
+ * Forward reference prototypes
+ *
+ *****************************************************/
+
+/*
+ * Prototypes
+ */
+static void AllCreateIC(XawVendorShellExtPart*);
+static void CloseIM(XawVendorShellExtPart*);
+static void CompileResourceList(XtResourceList, unsigned int);
+static void ConfigureCB(Widget, XtPointer, XEvent*, Boolean*);
+static void CreateIC(Widget, XawVendorShellExtPart*);
+static XawIcTableList CreateIcTable(Widget, XawVendorShellExtPart*);
+static XawIcTableList CurrentSharedIcTable(XawVendorShellExtPart*);
+static void Destroy(Widget, XawVendorShellExtPart*);
+static void DestroyAllIM(XawVendorShellExtPart*);
+static void DestroyIC(Widget, XawVendorShellExtPart*);
+static void FreeAllDataOfVendorShell(XawVendorShellExtPart*,
+ VendorShellWidget);
+static XawVendorShellExtPart *GetExtPart(VendorShellWidget);
+static XawIcTableList GetIcTable(Widget, XawVendorShellExtPart*);
+static XawIcTableList GetIcTableShared(Widget, XawVendorShellExtPart*);
+static XIMStyle GetInputStyleOfIC(XawVendorShellExtPart*);
+static Bool Initialize(VendorShellWidget, XawVendorShellExtPart*);
+static Bool IsCreatedIC(Widget, XawVendorShellExtPart*);
+static Bool IsRegistered(Widget, XawVendorShellExtPart*);
+static Bool IsSharedIC(XawVendorShellExtPart*);
+static Bool NoRegistered(XawVendorShellExtPart*);
+static void OpenIM(XawVendorShellExtPart*);
+static void Reconnect(XawVendorShellExtPart*);
+static void Register(Widget, XawVendorShellExtPart*);
+static Bool RegisterToVendorShell(Widget, XawVendorShellExtPart*);
+static void ResizeVendorShell(VendorShellWidget, XawVendorShellExtPart*);
+static Bool ResizeVendorShell_Core(VendorShellWidget, XawVendorShellExtPart*,
+ XawIcTableList);
+static VendorShellWidget SearchVendorShell(Widget);
+static Widget SetErrCnxt(Widget, XIM);
+static XawVendorShellExtPart *SetExtPart(VendorShellWidget,
+ XawVendorShellExtWidget);
+static void SetFocus(Widget, XawVendorShellExtPart*);
+static void SetFocusValues(Widget, ArgList, Cardinal, Bool);
+static void SetICFocus(Widget, XawVendorShellExtPart*);
+static void SetICValues(Widget, XawVendorShellExtPart*, Bool);
+static void SetICValuesShared(Widget, XawVendorShellExtPart*, XawIcTableList,
+ Bool);
+static void SetValues(Widget, XawVendorShellExtPart*, ArgList, Cardinal);
+static unsigned int SetVendorShellHeight(XawVendorShellExtPart*,
+ unsigned int);
+static void SharedICChangeFocusWindow(Widget, XawVendorShellExtPart*,
+ XawIcTableList);
+static void SizeNegotiation(XawIcTableList, unsigned int, unsigned int);
+static void Unregister(Widget, XawVendorShellExtPart*);
+static void UnregisterFromVendorShell(Widget, XawVendorShellExtPart*);
+static void UnsetFocus(Widget);
+static void UnsetICFocus(Widget, XawVendorShellExtPart*);
+static void VendorShellDestroyed(Widget, XtPointer, XtPointer);
+
+/*
+ * From Vendor.c
+ */
+void XawVendorShellExtResize(Widget);
+void XawVendorStructureNotifyHandler(Widget, XtPointer, XEvent*, Boolean*);
+
+
+/*
+ * From Xt/Resources.c
+ */
+void _XtCopyFromArg(XtArgVal src, char*, unsigned int);
+
+static XtResource resources[] =
+{
+ {
+ XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
+ Offset (font_set), XtRString, XtDefaultFontSet
+ },
+ {
+ XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
+ Offset (foreground), XtRString, (XtPointer)"XtDefaultForeground"
+ },
+ {
+ XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
+ Offset (background), XtRString, (XtPointer)"XtDefaultBackground"
+ },
+ {
+ XtNbackgroundPixmap, XtCPixmap, XtRPixmap, sizeof(Pixmap),
+ Offset (bg_pixmap), XtRImmediate, (XtPointer) XtUnspecifiedPixmap
+ },
+ {
+ XtNinsertPosition, XtCTextPosition, XtRInt, sizeof (XawTextPosition),
+ Offset (cursor_position), XtRImmediate, (XtPointer) 0
+ }
+};
+#undef Offset
+
+
+static VendorShellWidget SearchVendorShell( w )
+ Widget w;
+{
+ while(w && !XtIsShell(w)) w = XtParent(w);
+ if (w && XtIsVendorShell(w)) return((VendorShellWidget)w);
+ return(NULL);
+}
+
+static XContext extContext = (XContext)NULL;
+
+static XawVendorShellExtPart *
+SetExtPart(VendorShellWidget w, XawVendorShellExtWidget vew)
+{
+ contextDataRec *contextData;
+
+ if (extContext == (XContext)NULL) extContext = XUniqueContext();
+
+ contextData = XtNew(contextDataRec);
+ contextData->parent = (Widget)w;
+ contextData->ve = (Widget)vew;
+ if (XSaveContext(XtDisplay(w), (Window)w, extContext, (char *)contextData)) {
+ return(NULL);
+ }
+ return(&(vew->vendor_ext));
+}
+
+static XawVendorShellExtPart *
+GetExtPart(VendorShellWidget w)
+{
+ contextDataRec *contextData;
+ XawVendorShellExtWidget vew;
+
+ if (XFindContext(XtDisplay(w), (Window)w, extContext,
+ (XPointer*)&contextData)) {
+ return(NULL);
+ }
+ vew = (XawVendorShellExtWidget)contextData->ve;
+ return(&(vew->vendor_ext));
+}
+
+static Bool
+IsSharedIC(XawVendorShellExtPart * ve)
+{
+ return( ve->ic.shared_ic );
+}
+
+static XawIcTableList
+GetIcTableShared(Widget w, XawVendorShellExtPart *ve)
+{
+ XawIcTableList p;
+
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ if (p->widget == w) {
+ if (IsSharedIC(ve)) {
+ return(ve->ic.shared_ic_table);
+ } else {
+ return(p);
+ }
+ }
+ }
+ return(NULL);
+}
+
+static XawIcTableList
+GetIcTable(Widget w, XawVendorShellExtPart *ve)
+{
+ XawIcTableList p;
+
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ if (p->widget == w) {
+ return(p);
+ }
+ }
+ return(NULL);
+}
+
+static XIMStyle
+GetInputStyleOfIC(XawVendorShellExtPart *ve)
+{
+
+ if (!ve) return((XIMStyle)0);
+ return(ve->ic.input_style);
+}
+
+/*ARGSUSED*/
+static void
+ConfigureCB(Widget w, XtPointer closure, XEvent *event, Boolean *unused)
+{
+ XawIcTableList p;
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+ XVaNestedList pe_attr;
+ XRectangle pe_area;
+ XawTextMargin *margin;
+
+ if (event->type != ConfigureNotify) return;
+
+ if ((vw = SearchVendorShell(w)) == NULL) return;
+
+ if ((ve = GetExtPart(vw)) != NULL) {
+ if (IsSharedIC(ve)) return;
+ if ((ve->im.xim == NULL) ||
+ ((p = GetIcTableShared(w, ve)) == NULL) ||
+ (p->xic == NULL) || !(p->input_style & XIMPreeditPosition)) return;
+ pe_area.x = 0;
+ pe_area.y = 0;
+ pe_area.width = w->core.width;
+ pe_area.height = w->core.height;
+ margin = &(((TextWidget)w)->text.margin);
+ pe_area.x += margin->left;
+ pe_area.y += margin->top;
+ pe_area.width -= (margin->left + margin->right - 1);
+ pe_area.height -= (margin->top + margin->bottom - 1);
+
+ pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL);
+ XSetICValues(p->xic, XNPreeditAttributes, pe_attr, NULL);
+ XtFree(pe_attr);
+ }
+}
+
+static XContext errContext = (XContext)NULL;
+
+static Widget SetErrCnxt(Widget w, XIM xim)
+{
+ contextErrDataRec *contextErrData;
+
+ if (errContext == (XContext)NULL) errContext = XUniqueContext();
+
+ contextErrData = XtNew(contextErrDataRec);
+ contextErrData->widget = w;
+ contextErrData->xim = xim;
+ if (XSaveContext(XtDisplay(w), (Window)xim, errContext,
+ (char *)contextErrData)) {
+ return(NULL);
+ }
+ return(contextErrData->widget);
+}
+
+#if 0
+static Widget
+GetErrCnxt(XIM error_im)
+{
+ contextErrDataRec *contextErrData;
+
+ if (XFindContext(XDisplayOfIM(error_im), (Window)error_im, errContext,
+ (XPointer*)&contextErrData)) {
+ return(NULL);
+ }
+ return(contextErrData->widget);
+}
+#endif
+
+static void
+CloseIM(XawVendorShellExtPart *ve)
+{
+ if (ve->im.xim)
+ XCloseIM(ve->im.xim);
+}
+
+static unsigned int
+SetVendorShellHeight(XawVendorShellExtPart* ve, unsigned int height)
+{
+ Arg args[2];
+ Cardinal i = 0;
+
+ if (ve->im.area_height < height || height == 0) {
+ XtSetArg(args[i], XtNheight,
+ (ve->parent->core.height + height - ve->im.area_height));
+ ve->im.area_height = height;
+ XtSetValues(ve->parent, args, 1);
+ }
+ return(ve->im.area_height);
+}
+
+static void
+DestroyAllIM(XawVendorShellExtPart *ve)
+{
+ XawIcTableList p;
+ contextErrDataRec *contextErrData;
+
+ /*
+ * Destory all ICs
+ */
+ if (IsSharedIC(ve)) {
+ if ((p = ve->ic.shared_ic_table) && p->xic) {
+ DestroyIC(p->widget, ve);
+ p->xic = NULL;
+ p->ic_focused = FALSE;
+ }
+ } else {
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ if (p->xic == NULL) continue;
+ DestroyIC(p->widget, ve);
+ p->xic = NULL;
+ p->ic_focused = FALSE;
+ }
+ }
+ if (!ve->im.xim) return;
+ /*
+ * Close Input Method
+ */
+ if (!XFindContext(XDisplayOfIM(ve->im.xim), (Window)ve->im.xim, errContext,
+ (XPointer*)&contextErrData)) {
+ if (contextErrData) XtFree((char *)contextErrData);
+ }
+ XDeleteContext(XDisplayOfIM(ve->im.xim), (Window)ve->im.xim, errContext);
+ CloseIM(ve);
+ ve->im.xim = NULL;
+
+ /*
+ * resize vendor shell to core size
+ */
+ (void) SetVendorShellHeight(ve, 0);
+ /*
+ XawVendorShellExtResize(vw);
+ */
+ return;
+}
+
+static void
+FreeAllDataOfVendorShell(XawVendorShellExtPart *ve, VendorShellWidget vw)
+{
+ XawIcTableList p, next;
+ contextErrDataRec *contextErrData;
+
+ if (!XFindContext(XtDisplay(vw), (Window)vw, extContext,
+ (XPointer*)&contextErrData)) {
+ if (contextErrData) XtFree((char *)contextErrData);
+ }
+ XDeleteContext(XtDisplay(vw), (Window)vw, extContext);
+ if (ve->ic.shared_ic_table)
+ XtFree((char *)ve->ic.shared_ic_table);
+ if (ve->im.resources) XtFree((char *)ve->im.resources);
+ for (p = ve->ic.ic_table; p; p = next) {
+ next = p->next;
+ XtFree((char *)p);
+ }
+}
+
+static void
+VendorShellDestroyed(Widget w, XtPointer cl_data, XtPointer ca_data)
+{
+ XawVendorShellExtPart *ve;
+
+ if ( ( ve = GetExtPart( (VendorShellWidget) w ) ) == NULL ) return;
+ DestroyAllIM( ve );
+ FreeAllDataOfVendorShell( ve, (VendorShellWidget) w );
+ return;
+}
+
+#if 0
+static int
+IOErrorHandler(XIM error_im)
+{
+ VendorShellWidget vw;
+ XawVendorShellExtPart * ve;
+
+ if ((vw = (VendorShellWidget)GetErrCnxt(error_im)) == NULL
+ || (ve = GetExtPart(vw)) == NULL) return(0);
+
+ DestroyAllIM(ve);
+ return(0);
+}
+#endif
+
+/*
+ * Attempt to open an input method
+ */
+
+static void
+OpenIM(XawVendorShellExtPart *ve)
+{
+ int i;
+ char *p, *s, *ns, *end, *pbuf, buf[32];
+ XIM xim = NULL;
+ XIMStyles *xim_styles;
+ XIMStyle input_style = 0;
+ Boolean found;
+
+ if (ve->im.open_im == False) return;
+ ve->im.xim = NULL;
+ if (ve->im.input_method == NULL) {
+ if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p)
+ xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL);
+ } else {
+ /* no fragment can be longer than the whole string */
+ Cardinal len = strlen (ve->im.input_method) + 5;
+
+ if (len < sizeof buf) pbuf = buf;
+ else pbuf = XtMalloc (len);
+
+ if (pbuf == NULL) return;
+
+ for(ns=s=ve->im.input_method; ns && *s;) {
+ /* skip any leading blanks */
+ while (*s && isspace(*s)) s++;
+ if (!*s) break;
+ if ((ns = end = strchr(s, ',')) == NULL)
+ end = s + strlen(s);
+ /* If there is a spurious comma end can be the same as s */
+ if (end > s) {
+ /* strip any trailing blanks */
+ while (isspace(*(end - 1))) end--;
+
+ strcpy (pbuf, "@im=");
+ strncat (pbuf, s, end - s);
+ pbuf[end - s + 4] = '\0';
+ }
+
+ if ((p = XSetLocaleModifiers(pbuf)) != NULL && *p
+ && (xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL)) != NULL)
+ break;
+
+ s = ns + 1;
+ }
+
+ if (pbuf != buf) XtFree (pbuf);
+ }
+ if (xim == NULL) {
+ if ((p = XSetLocaleModifiers("")) != NULL) {
+ xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL);
+ }
+ }
+ if (xim == NULL) {
+ XtAppWarning(XtWidgetToApplicationContext(ve->parent),
+ "Input Method Open Failed");
+ return;
+ }
+ if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL)
+ || !xim_styles) {
+ XtAppWarning(XtWidgetToApplicationContext(ve->parent),
+ "input method doesn't support any style");
+ XCloseIM(xim);
+ return;
+ }
+ found = False;
+ for(ns = s = ve->im.preedit_type; s && !found;) {
+ while (*s && isspace(*s)) s++;
+ if (!*s) break;
+ if ((ns = end = strchr(s, ',')) == NULL)
+ end = s + strlen(s);
+ else
+ ns++;
+ if (end > s)
+ while (isspace(*(end - 1))) end--;
+
+ if (!strncmp(s, "OverTheSpot", end - s)) {
+ input_style = (XIMPreeditPosition | XIMStatusArea);
+ } else if (!strncmp(s, "OffTheSpot", end - s)) {
+ input_style = (XIMPreeditArea | XIMStatusArea);
+ } else if (!strncmp(s, "Root", end - s)) {
+ input_style = (XIMPreeditNothing | XIMStatusNothing);
+ }
+ for (i = 0; (unsigned short)i < xim_styles->count_styles; i++)
+ if (input_style == xim_styles->supported_styles[i]) {
+ ve->ic.input_style = input_style;
+ SetErrCnxt(ve->parent, xim);
+ ve->im.xim = xim;
+ found = True;
+ break;
+ }
+
+ s = ns;
+ }
+ XFree(xim_styles);
+
+ if (!found) {
+ XCloseIM(xim);
+ XtAppWarning(XtWidgetToApplicationContext(ve->parent),
+ "input method doesn't support my input style");
+ }
+}
+
+static Bool
+ResizeVendorShell_Core(VendorShellWidget vw, XawVendorShellExtPart *ve,
+ XawIcTableList p)
+{
+ XVaNestedList pe_attr, st_attr;
+ XRectangle pe_area, st_area;
+ XRectangle *get_pe_area = NULL, *get_st_area = NULL;
+
+ st_area.width = 0;
+ if (p->input_style & XIMStatusArea) {
+ st_attr = XVaCreateNestedList(0, XNArea, &get_st_area, NULL);
+ XGetICValues(p->xic, XNStatusAttributes, st_attr, NULL);
+ XFree(st_attr);
+ if (p->xic == NULL) {
+ return(FALSE);
+ }
+ st_area.x = 0;
+ st_area.y = vw->core.height - ve->im.area_height;
+ st_area.width = get_st_area->width;
+ st_area.height = get_st_area->height;
+ XFree(get_st_area);
+ st_attr = XVaCreateNestedList(0, XNArea, &st_area, NULL);
+ XSetICValues(p->xic, XNStatusAttributes, st_attr, NULL);
+ XFree(st_attr);
+ if (p->xic == NULL) {
+ return(FALSE);
+ }
+ }
+ if (p->input_style & XIMPreeditArea) {
+ pe_attr = XVaCreateNestedList(0, XNArea, &get_pe_area, NULL);
+ XGetICValues(p->xic, XNPreeditAttributes, pe_attr, NULL);
+ XFree(pe_attr);
+ if (p->xic == NULL) {
+ return(FALSE);
+ }
+ pe_area.x = st_area.width;
+ pe_area.y = vw->core.height - ve->im.area_height;
+ pe_area.width = vw->core.width;
+ pe_area.height = get_pe_area->height;
+ if (p->input_style & XIMStatusArea) {
+ pe_area.width -= st_area.width;
+ }
+ XFree(get_pe_area);
+ pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL);
+ XSetICValues(p->xic, XNPreeditAttributes, pe_attr, NULL);
+ XFree(pe_attr);
+ }
+ return(TRUE);
+}
+
+static void
+ResizeVendorShell(VendorShellWidget vw, XawVendorShellExtPart *ve)
+{
+ XawIcTableList p;
+
+ if (IsSharedIC(ve)) {
+ p = ve->ic.shared_ic_table;
+ if (p->xic == NULL) return;
+ ResizeVendorShell_Core(vw, ve, p);
+ return;
+ }
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ if (p->xic == NULL) continue;
+ if (ResizeVendorShell_Core(vw, ve, p) == FALSE) return;
+ }
+}
+
+static XawIcTableList
+CreateIcTable(Widget w, XawVendorShellExtPart *ve)
+{
+ XawIcTableList table;
+
+ table = (XawIcTableList) XtMalloc(sizeof(XawIcTablePart));
+ if (table == NULL) return(NULL);
+ table->widget = w;
+ table->xic = NULL;
+ table->flg = table->prev_flg = 0;
+ table->font_set = NULL;
+ table->foreground = table->background = 0xffffffff;
+ table->bg_pixmap = 0;
+ table->cursor_position = 0xffff;
+ table->line_spacing = 0;
+ table->ic_focused = FALSE;
+ table->openic_error = FALSE;
+ return(table);
+}
+
+static Bool
+RegisterToVendorShell(Widget w, XawVendorShellExtPart *ve)
+{
+ XawIcTableList table;
+
+ if ((table = CreateIcTable(w, ve)) == NULL) return(FALSE);
+ table->next = ve->ic.ic_table;
+ ve->ic.ic_table = table;
+ return(TRUE);
+}
+
+static void
+UnregisterFromVendorShell(Widget w, XawVendorShellExtPart *ve)
+{
+ XawIcTableList *prev, p;
+
+ for (prev = &ve->ic.ic_table; (p = *prev) != NULL; prev = &p->next) {
+ if (p->widget == w) {
+ *prev = p->next;
+ XtFree((char *)p);
+ break;
+ }
+ }
+ return;
+}
+
+static void
+SetICValuesShared(Widget w, XawVendorShellExtPart *ve,
+ XawIcTableList p, Bool check)
+{
+ XawIcTableList pp;
+
+ if ((pp = GetIcTable(w, ve)) == NULL) return;
+ if (check == TRUE && CurrentSharedIcTable(ve) != pp) return;
+
+ if (pp->prev_flg & CICursorP && p->cursor_position != pp->cursor_position) {
+ p->cursor_position = pp->cursor_position;
+ p->flg |= CICursorP;
+ }
+ if (pp->prev_flg & CIFontSet && p->font_set != pp->font_set) {
+ p->font_set = pp->font_set;
+ p->flg |= (CIFontSet|CICursorP);
+ }
+ if (pp->prev_flg & CIFg && p->foreground != pp->foreground) {
+ p->foreground = pp->foreground;
+ p->flg |= CIFg;
+ }
+ if (pp->prev_flg & CIBg && p->background != pp->background) {
+ p->background = pp->background;
+ p->flg |= CIBg;
+ }
+ if (pp->prev_flg & CIBgPixmap && p->bg_pixmap != pp->bg_pixmap) {
+ p->bg_pixmap = pp->bg_pixmap;
+ p->flg |= CIBgPixmap;
+ }
+ if (pp->prev_flg & CILineS && p->line_spacing != pp->line_spacing) {
+ p->line_spacing = pp->line_spacing;
+ p->flg |= CILineS;
+ }
+}
+
+static Bool
+IsCreatedIC(Widget w, XawVendorShellExtPart *ve)
+{
+ XawIcTableList p;
+
+ if (ve->im.xim == NULL) return(FALSE);
+ if ((p = GetIcTableShared(w, ve)) == NULL) return(FALSE);
+ if (p->xic == NULL) return(FALSE);
+ return(TRUE);
+}
+
+static void
+SizeNegotiation(XawIcTableList p, unsigned int width, unsigned int height)
+{
+ XRectangle pe_area, st_area;
+ XVaNestedList pe_attr = NULL, st_attr = NULL;
+ int ic_cnt = 0;
+ XRectangle *pe_area_needed = NULL, *st_area_needed = NULL;
+ XPointer ic_a[5];
+
+ if (p->input_style & XIMPreeditArea) {
+ pe_attr = XVaCreateNestedList(0, XNAreaNeeded, &pe_area_needed, NULL);
+ ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
+ }
+ if (p->input_style & XIMStatusArea) {
+ st_attr = XVaCreateNestedList(0, XNAreaNeeded, &st_area_needed, NULL);
+ ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
+ }
+ ic_a[ic_cnt] = (XPointer) NULL;
+
+ if (ic_cnt > 0) {
+ XGetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], NULL);
+ if (pe_attr) XFree(pe_attr);
+ if (st_attr) XFree(st_attr);
+ if (p->xic == NULL) {
+ p->openic_error = True;
+ return;
+ }
+ pe_attr = st_attr = NULL;
+ ic_cnt = 0;
+ if (p->input_style & XIMStatusArea) {
+ st_area.height = st_area_needed->height;
+ st_area.x = 0;
+ st_area.y = height - st_area.height;
+ if (p->input_style & XIMPreeditArea) {
+ st_area.width = st_area_needed->width;
+ } else {
+ st_area.width = width;
+ }
+
+ XFree(st_area_needed);
+ st_attr = XVaCreateNestedList(0, XNArea, &st_area, NULL);
+ ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
+ }
+ if (p->input_style & XIMPreeditArea) {
+ if (p->input_style & XIMStatusArea) {
+ pe_area.x = st_area.width;
+ pe_area.width = width - st_area.width;
+ } else {
+ pe_area.x = 0;
+ pe_area.width = width;
+ }
+ pe_area.height = pe_area_needed->height;
+ XFree(pe_area_needed);
+ pe_area.y = height - pe_area.height;
+ pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL);
+ ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
+ }
+ ic_a[ic_cnt] = (XPointer) NULL;
+ XSetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], NULL);
+ if (pe_attr) XFree(pe_attr);
+ if (st_attr) XFree(st_attr);
+ if (p->xic == NULL) {
+ p->openic_error = True;
+ return;
+ }
+ }
+}
+
+static void
+CreateIC(Widget w, XawVendorShellExtPart *ve)
+{
+ XawIcTableList p;
+ XPoint position;
+ XRectangle pe_area, st_area;
+ XVaNestedList pe_attr = NULL, st_attr = NULL;
+ XPointer ic_a[20], pe_a[20], st_a[20];
+ Dimension height = 0;
+ int ic_cnt = 0, pe_cnt = 0, st_cnt = 0;
+ XawTextMargin *margin;
+
+ if (!XtIsRealized(w)) return;
+ if (((ve->im.xim == NULL) || (p = GetIcTableShared(w, ve)) == NULL) ||
+ p->xic || (p->openic_error != FALSE)) return;
+
+ p->input_style = GetInputStyleOfIC(ve);
+
+ if (IsSharedIC(ve)) SetICValuesShared(w, ve, p, FALSE);
+ XFlush(XtDisplay(w));
+
+ if (p->input_style & (XIMPreeditArea|XIMPreeditPosition|XIMStatusArea)) {
+ if (p->flg & CIFontSet) {
+ pe_a[pe_cnt] = (XPointer) XNFontSet; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) p->font_set; pe_cnt++;
+ st_a[st_cnt] = (XPointer) XNFontSet; st_cnt++;
+ st_a[st_cnt] = (XPointer) p->font_set; st_cnt++;
+ if (p->font_set) {
+ height = maxAscentOfFontSet(p->font_set)
+ + maxDescentOfFontSet(p->font_set);
+ }
+ height = SetVendorShellHeight(ve, height);
+ }
+ if (p->flg & CIFg) {
+ pe_a[pe_cnt] = (XPointer) XNForeground; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) p->foreground; pe_cnt++;
+ st_a[st_cnt] = (XPointer) XNForeground; st_cnt++;
+ st_a[st_cnt] = (XPointer) p->foreground; st_cnt++;
+ }
+ if (p->flg & CIBg) {
+ pe_a[pe_cnt] = (XPointer) XNBackground; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) p->background; pe_cnt++;
+ st_a[st_cnt] = (XPointer) XNBackground; st_cnt++;
+ st_a[st_cnt] = (XPointer) p->background; st_cnt++;
+ }
+ if (p->flg & CIBgPixmap) {
+ pe_a[pe_cnt] = (XPointer) XNBackgroundPixmap; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) p->bg_pixmap; pe_cnt++;
+ st_a[st_cnt] = (XPointer) XNBackgroundPixmap; st_cnt++;
+ st_a[st_cnt] = (XPointer) p->bg_pixmap; st_cnt++;
+ }
+ if (p->flg & CILineS) {
+ pe_a[pe_cnt] = (XPointer) XNLineSpace; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) p->line_spacing; pe_cnt++;
+ st_a[st_cnt] = (XPointer) XNLineSpace; st_cnt++;
+ st_a[st_cnt] = (XPointer) p->line_spacing; st_cnt++;
+ }
+ }
+ if (p->input_style & XIMPreeditArea) {
+ pe_area.x = 0;
+ pe_area.y = ve->parent->core.height - height;
+ pe_area.width = ve->parent->core.width;
+ pe_area.height = height;
+ pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++;
+ }
+ if (p->input_style & XIMPreeditPosition) {
+ pe_area.x = 0;
+ pe_area.y = 0;
+ pe_area.width = w->core.width;
+ pe_area.height = w->core.height;
+ margin = &(((TextWidget)w)->text.margin);
+ pe_area.x += margin->left;
+ pe_area.y += margin->top;
+ pe_area.width -= (margin->left + margin->right - 1);
+ pe_area.height -= (margin->top + margin->bottom - 1);
+ pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++;
+ if (p->flg & CICursorP) {
+ _XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
+ } else {
+ position.x = position.y = 0;
+ }
+ pe_a[pe_cnt] = (XPointer) XNSpotLocation; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) &position; pe_cnt++;
+ }
+ if (p->input_style & XIMStatusArea) {
+ st_area.x = 0;
+ st_area.y = ve->parent->core.height - height;
+ st_area.width = ve->parent->core.width;
+ st_area.height = height;
+ st_a[st_cnt] = (XPointer) XNArea; st_cnt++;
+ st_a[st_cnt] = (XPointer) &st_area; st_cnt++;
+ }
+
+ ic_a[ic_cnt] = (XPointer) XNInputStyle; ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) p->input_style; ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) XNClientWindow; ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) XtWindow(ve->parent); ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) XNFocusWindow; ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) XtWindow(w); ic_cnt++;
+
+ if (pe_cnt > 0) {
+ pe_a[pe_cnt] = (XPointer) NULL;
+ pe_attr = XVaCreateNestedList(0, pe_a[0], pe_a[1], pe_a[2], pe_a[3],
+ pe_a[4], pe_a[5], pe_a[6], pe_a[7], pe_a[8],
+ pe_a[9], pe_a[10], pe_a[11], pe_a[12],
+ pe_a[13], pe_a[14], pe_a[15], pe_a[16],
+ pe_a[17], pe_a[18], NULL);
+ ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
+ }
+
+ if (st_cnt > 0) {
+ st_a[st_cnt] = (XPointer) NULL;
+ st_attr = XVaCreateNestedList(0, st_a[0], st_a[1], st_a[2], st_a[3],
+ st_a[4], st_a[5], st_a[6], st_a[7], st_a[8],
+ st_a[9], st_a[10], st_a[11], st_a[12],
+ st_a[13], st_a[14], st_a[15], st_a[16],
+ st_a[17], st_a[18], NULL);
+ ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
+ }
+ ic_a[ic_cnt] = (XPointer) NULL;
+
+ p->xic = XCreateIC(ve->im.xim, ic_a[0], ic_a[1], ic_a[2], ic_a[3],
+ ic_a[4], ic_a[5], ic_a[6], ic_a[7], ic_a[8], ic_a[9],
+ ic_a[10], ic_a[11], ic_a[12], ic_a[13], ic_a[14],
+ ic_a[15], ic_a[16], ic_a[17], ic_a[18], NULL);
+ if (pe_attr) XtFree(pe_attr);
+ if (st_attr) XtFree(st_attr);
+
+ if (p->xic == NULL) {
+ p->openic_error = True;
+ return;
+ }
+
+ SizeNegotiation(p, ve->parent->core.width, ve->parent->core.height);
+
+ p->flg &= ~(CIFontSet | CIFg | CIBg | CIBgPixmap | CICursorP | CILineS);
+
+ if (!IsSharedIC(ve)) {
+ if (p->input_style & XIMPreeditPosition) {
+ XtAddEventHandler(w, (EventMask)StructureNotifyMask, FALSE,
+ (XtEventHandler)ConfigureCB, (Opaque)NULL);
+ }
+ }
+}
+
+static void
+SetICValues(Widget w, XawVendorShellExtPart *ve, Bool focus)
+{
+ XawIcTableList p;
+ XPoint position;
+ XRectangle pe_area;
+ XVaNestedList pe_attr = NULL, st_attr = NULL;
+ XPointer ic_a[20], pe_a[20], st_a[20];
+ int ic_cnt = 0, pe_cnt = 0, st_cnt = 0;
+ XawTextMargin *margin;
+ int height = 0;
+
+ if ((ve->im.xim == NULL) || ((p = GetIcTableShared(w, ve)) == NULL) ||
+ (p->xic == NULL)) return;
+
+ if (IsSharedIC(ve)) SetICValuesShared(w, ve, p, TRUE);
+ XFlush(XtDisplay(w));
+ if (focus == FALSE &&
+ !(p->flg & (CIFontSet | CIFg | CIBg |
+ CIBgPixmap | CICursorP | CILineS))) return;
+#ifdef SPOT
+ if ((p->input_style & XIMPreeditPosition)
+ && ((!IsSharedIC(ve) && ((p->flg & ~CIICFocus) == CICursorP))
+ || (IsSharedIC(ve) && p->flg == CICursorP))) {
+ _XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
+ _XipChangeSpot(p->xic, position.x, position.y);
+ p->flg &= ~CICursorP;
+ return;
+ }
+#endif
+
+ if (p->input_style & (XIMPreeditArea|XIMPreeditPosition|XIMStatusArea)) {
+ if (p->flg & CIFontSet) {
+ pe_a[pe_cnt] = (XPointer) XNFontSet; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) p->font_set; pe_cnt++;
+ st_a[st_cnt] = (XPointer) XNFontSet; st_cnt++;
+ st_a[st_cnt] = (XPointer) p->font_set; st_cnt++;
+ if (p->font_set) {
+ height = maxAscentOfFontSet(p->font_set)
+ + maxDescentOfFontSet(p->font_set);
+ }
+ height = SetVendorShellHeight(ve, height);
+ }
+ if (p->flg & CIFg) {
+ pe_a[pe_cnt] = (XPointer) XNForeground; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) p->foreground; pe_cnt++;
+ st_a[st_cnt] = (XPointer) XNForeground; st_cnt++;
+ st_a[st_cnt] = (XPointer) p->foreground; st_cnt++;
+ }
+ if (p->flg & CIBg) {
+ pe_a[pe_cnt] = (XPointer) XNBackground; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) p->background; pe_cnt++;
+ st_a[st_cnt] = (XPointer) XNBackground; st_cnt++;
+ st_a[st_cnt] = (XPointer) p->background; st_cnt++;
+ }
+ if (p->flg & CIBgPixmap) {
+ pe_a[pe_cnt] = (XPointer) XNBackgroundPixmap; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) p->bg_pixmap; pe_cnt++;
+ st_a[st_cnt] = (XPointer) XNBackgroundPixmap; st_cnt++;
+ st_a[st_cnt] = (XPointer) p->bg_pixmap; st_cnt++;
+ }
+ if (p->flg & CILineS) {
+ pe_a[pe_cnt] = (XPointer) XNLineSpace; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) p->line_spacing; pe_cnt++;
+ st_a[st_cnt] = (XPointer) XNLineSpace; st_cnt++;
+ st_a[st_cnt] = (XPointer) p->line_spacing; st_cnt++;
+ }
+ }
+ if (p->input_style & XIMPreeditPosition) {
+ if (p->flg & CICursorP) {
+ _XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
+ pe_a[pe_cnt] = (XPointer) XNSpotLocation; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) &position; pe_cnt++;
+ }
+ }
+ if (IsSharedIC(ve)) {
+ if (p->input_style & XIMPreeditPosition) {
+ pe_area.x = 0;
+ pe_area.y = 0;
+ pe_area.width = w->core.width;
+ pe_area.height = w->core.height;
+ margin = &(((TextWidget)w)->text.margin);
+ pe_area.x += margin->left;
+ pe_area.y += margin->top;
+ pe_area.width -= (margin->left + margin->right - 1);
+ pe_area.height -= (margin->top + margin->bottom - 1);
+ pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++;
+ pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++;
+ }
+ }
+
+ if (pe_cnt > 0) {
+ pe_a[pe_cnt] = (XPointer) NULL;
+ pe_attr = XVaCreateNestedList(0, pe_a[0], pe_a[1], pe_a[2], pe_a[3],
+ pe_a[4], pe_a[5], pe_a[6], pe_a[7],
+ pe_a[8], pe_a[9], pe_a[10], pe_a[11],
+ pe_a[12], pe_a[13], pe_a[14], pe_a[15],
+ pe_a[16], pe_a[17], pe_a[18], NULL);
+ ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
+ }
+ if (st_cnt > 0) {
+ st_a[st_cnt] = (XPointer) NULL;
+ st_attr = XVaCreateNestedList(0, st_a[0], st_a[1], st_a[2], st_a[3],
+ st_a[4], st_a[5], st_a[6], st_a[7],
+ st_a[8], st_a[9], st_a[10], st_a[11],
+ st_a[12], st_a[13], st_a[14], st_a[15],
+ st_a[16], st_a[17], st_a[18], NULL);
+ ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
+ }
+ if (focus == TRUE) {
+ ic_a[ic_cnt] = (XPointer) XNFocusWindow; ic_cnt++;
+ ic_a[ic_cnt] = (XPointer) XtWindow(w); ic_cnt++;
+ }
+ if (ic_cnt > 0) {
+ ic_a[ic_cnt] = (XPointer) NULL;
+ XSetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], ic_a[4],
+ ic_a[5], ic_a[6], ic_a[7], ic_a[8], ic_a[9], ic_a[10],
+ ic_a[11], ic_a[12], ic_a[13], ic_a[14], ic_a[15],
+ ic_a[16], ic_a[17], ic_a[18], NULL);
+ if (pe_attr) XtFree(pe_attr);
+ if (st_attr) XtFree(st_attr);
+ }
+
+ if (IsSharedIC(ve) && p->flg & CIFontSet)
+ SizeNegotiation(p, ve->parent->core.width, ve->parent->core.height);
+
+ p->flg &= ~(CIFontSet | CIFg | CIBg | CIBgPixmap | CICursorP | CILineS);
+}
+
+static void
+SharedICChangeFocusWindow(Widget w, XawVendorShellExtPart *ve,
+ XawIcTableList p)
+{
+ XawIcTableList pp;
+
+ if (w == NULL) {
+ ve->ic.current_ic_table = NULL;
+ return;
+ }
+ if ((pp = GetIcTable(w, ve)) == NULL) return;
+ ve->ic.current_ic_table = pp;
+ SetICValues(w, ve, TRUE);
+}
+
+static XawIcTableList
+CurrentSharedIcTable(XawVendorShellExtPart *ve)
+{
+ return(ve->ic.current_ic_table);
+}
+
+static void
+SetICFocus(Widget w, XawVendorShellExtPart *ve)
+{
+ XawIcTableList p, pp;
+
+ if ((ve->im.xim == NULL) || ((p = GetIcTableShared(w, ve)) == NULL) ||
+ (p->xic == NULL)) return;
+
+ if (IsSharedIC(ve)) {
+ pp = CurrentSharedIcTable(ve);
+ if (pp == NULL || pp->widget != w) {
+ SharedICChangeFocusWindow(w, ve, p);
+ }
+ }
+ if (p->flg & CIICFocus && p->ic_focused == FALSE) {
+ p->ic_focused = TRUE;
+ XSetICFocus(p->xic);
+ }
+ p->flg &= ~CIICFocus;
+}
+
+static void
+UnsetICFocus(Widget w, XawVendorShellExtPart *ve)
+{
+ XawIcTableList p, pp;
+
+ if ((ve->im.xim == NULL) || ((p = GetIcTableShared(w, ve)) == NULL) ||
+ (p->xic == NULL)) return;
+
+ if (IsSharedIC(ve) && (pp = CurrentSharedIcTable(ve))) {
+ if (pp->widget != w) {
+ return;
+ }
+ SharedICChangeFocusWindow(NULL, ve, p);
+ }
+ if (p->ic_focused == TRUE) {
+ XUnsetICFocus(p->xic);
+ p->ic_focused = FALSE;
+ }
+}
+
+static void
+SetValues(Widget w, XawVendorShellExtPart *ve,
+ ArgList args, Cardinal num_args)
+{
+ ArgList arg;
+
+ XrmName argName;
+ XrmResourceList xrmres;
+ Cardinal i;
+ XawIcTablePart *p, save_tbl;
+
+ if ((p = GetIcTable(w, ve)) == NULL) return;
+
+ memcpy(&save_tbl, p, sizeof(XawIcTablePart));
+
+ for (arg = args ; num_args != 0; num_args--, arg++) {
+ argName = XrmStringToName(arg->name);
+ for (xrmres = (XrmResourceList)ve->im.resources, i = 0;
+ i < ve->im.num_resources; i++, xrmres++) {
+ if (argName == xrmres->xrm_name) {
+ _XtCopyFromArg(arg->value,
+ (char *)p - xrmres->xrm_offset - 1,
+ xrmres->xrm_size);
+ break;
+ }
+ }
+ }
+ if (p->font_set != save_tbl.font_set) {
+ p->flg |= CIFontSet;
+ }
+ if (p->foreground != save_tbl.foreground) {
+ p->flg |= CIFg;
+ }
+ if (p->background !=save_tbl.background) {
+ p->flg |= CIBg;
+ }
+ if (p->bg_pixmap != save_tbl.bg_pixmap) {
+ p->flg |= CIBgPixmap;
+ }
+ if (p->cursor_position != save_tbl.cursor_position) {
+ p->flg |= CICursorP;
+ }
+ if (p->line_spacing != save_tbl.line_spacing) {
+ p->flg |= CILineS;
+ }
+ p->prev_flg |= p->flg;
+}
+
+static void
+SetFocus(Widget w, XawVendorShellExtPart *ve)
+{
+ XawIcTableList p;
+ if ((p = GetIcTableShared(w, ve)) == NULL) return;
+
+ if ( p->ic_focused == FALSE || IsSharedIC(ve)) {
+ p->flg |= CIICFocus;
+ }
+ p->prev_flg |= p->flg;
+}
+
+static void
+DestroyIC(Widget w, XawVendorShellExtPart *ve)
+{
+ XawIcTableList p;
+
+ if ((ve->im.xim == NULL) || ((p = GetIcTableShared(w, ve)) == NULL) ||
+ (p->xic == NULL)) return;
+ if (IsSharedIC(ve)) {
+ if (GetIcTable(w, ve) == ve->ic.current_ic_table) {
+ UnsetICFocus(w, ve);
+ }
+ return;
+ }
+ XDestroyIC(p->xic);
+ if (!IsSharedIC(ve)) {
+ if (p->input_style & XIMPreeditPosition) {
+ XtRemoveEventHandler(w, (EventMask)StructureNotifyMask, FALSE,
+ (XtEventHandler)ConfigureCB, (Opaque)NULL);
+ }
+ }
+}
+
+static void
+SetFocusValues(Widget inwidg, ArgList args, Cardinal num_args, Bool focus)
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+
+ if ((vw = SearchVendorShell(inwidg)) == NULL) return;
+ if ((ve = GetExtPart(vw)) != NULL) {
+ if (num_args > 0) SetValues(inwidg, ve, args, num_args);
+ if (focus) SetFocus(inwidg, ve);
+ if (XtIsRealized((Widget)vw) && ve->im.xim) {
+ if (IsCreatedIC(inwidg, ve)) {
+ SetICValues(inwidg, ve, FALSE);
+ if (focus) SetICFocus(inwidg, ve);
+ } else {
+ CreateIC(inwidg, ve);
+ SetICFocus(inwidg, ve);
+ }
+ }
+ }
+}
+
+static void
+UnsetFocus(Widget inwidg)
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+ XawIcTableList p;
+
+ if ((vw = SearchVendorShell(inwidg)) == NULL) return;
+ if ((ve = GetExtPart(vw)) != NULL) {
+ if ((p = GetIcTableShared(inwidg, ve)) == NULL) return;
+ if (p->flg & CIICFocus) {
+ p->flg &= ~CIICFocus;
+ }
+ p->prev_flg &= ~CIICFocus;
+ if (ve->im.xim && XtIsRealized((Widget)vw) && p->xic) {
+ UnsetICFocus(inwidg, ve);
+ }
+ }
+}
+
+static Bool
+IsRegistered(Widget w, XawVendorShellExtPart* ve)
+{
+ XawIcTableList p;
+
+ for (p = ve->ic.ic_table; p; p = p->next)
+ {
+ if (p->widget == w) return(TRUE);
+ }
+ return(FALSE);
+}
+
+static void
+Register(Widget inwidg, XawVendorShellExtPart* ve)
+{
+ if (ve->im.xim == NULL)
+ {
+ OpenIM(ve);
+ }
+
+ if (IsRegistered(inwidg, ve)) return;
+
+ if (RegisterToVendorShell(inwidg, ve) == FALSE) return;
+
+ if (ve->im.xim == NULL) return;
+
+ if (XtIsRealized(ve->parent))
+ {
+ CreateIC(inwidg, ve);
+ SetICFocus(inwidg, ve);
+ }
+}
+
+static Bool
+NoRegistered(XawVendorShellExtPart* ve)
+{
+ if (ve->ic.ic_table == NULL) return(TRUE);
+ return(FALSE);
+}
+
+static void
+Unregister(Widget inwidg, XawVendorShellExtPart *ve)
+{
+ if (!IsRegistered(inwidg, ve)) return;
+
+ DestroyIC(inwidg, ve);
+
+ UnregisterFromVendorShell(inwidg, ve);
+
+ if (NoRegistered(ve))
+ {
+ CloseIM(ve);
+ ve->im.xim = NULL;
+ /*
+ * resize vendor shell to core size
+ */
+ (void) SetVendorShellHeight(ve, 0);
+ }
+}
+
+static void
+AllCreateIC(XawVendorShellExtPart *ve)
+{
+ XawIcTableList p;
+
+ if (ve->im.xim == NULL) return;
+ if (IsSharedIC(ve) && ve->ic.ic_table[0].widget) {
+ p = ve->ic.shared_ic_table;
+ if (p->xic == NULL)
+ CreateIC(ve->ic.ic_table[0].widget, ve);
+ SetICFocus(ve->ic.ic_table[0].widget, ve);
+ return;
+ }
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ if (p->xic == NULL)
+ CreateIC(p->widget, ve);
+ }
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ SetICFocus(p->widget, ve);
+ }
+}
+
+
+static void
+Reconnect(XawVendorShellExtPart *ve)
+{
+ XawIcTableList p;
+
+ ve->im.open_im = True;
+ if (ve->im.xim == NULL) {
+ OpenIM(ve);
+ }
+ if (ve->im.xim == NULL) return;
+
+ if (IsSharedIC(ve)) {
+ p = ve->ic.shared_ic_table;
+ p->flg = p->prev_flg;
+ p->openic_error = FALSE;
+ } else {
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ p->flg = p->prev_flg;
+ p->openic_error = FALSE;
+ }
+ }
+ AllCreateIC(ve);
+}
+
+
+static void
+CompileResourceList(XtResourceList res, unsigned int num_res)
+{
+ unsigned int count;
+
+#define xrmres ((XrmResourceList) res)
+ for (count = 0; count < num_res; res++, count++) {
+ xrmres->xrm_name = XrmPermStringToQuark(res->resource_name);
+ xrmres->xrm_class = XrmPermStringToQuark(res->resource_class);
+ xrmres->xrm_type = XrmPermStringToQuark(res->resource_type);
+ xrmres->xrm_offset = -res->resource_offset - 1;
+ xrmres->xrm_default_type = XrmPermStringToQuark(res->default_type);
+ }
+#undef xrmres
+}
+
+static Bool
+Initialize(VendorShellWidget vw, XawVendorShellExtPart *ve)
+{
+ if (!XtIsVendorShell((Widget)vw)) return(FALSE);
+ ve->parent = (Widget)vw;
+ ve->im.xim = NULL;
+ ve->im.area_height = 0;
+ ve->im.resources = (XrmResourceList)XtMalloc(sizeof(resources));
+ if (ve->im.resources == NULL) return(FALSE);
+ memcpy((char *)ve->im.resources, (char *)resources, sizeof(resources));
+ ve->im.num_resources = XtNumber(resources);
+ CompileResourceList( (XtResourceList) ve->im.resources,
+ ve->im.num_resources );
+ if ((ve->ic.shared_ic_table = CreateIcTable( (Widget)vw, ve)) == NULL)
+ return(FALSE);
+ ve->ic.current_ic_table = NULL;
+ ve->ic.ic_table = NULL;
+ return(TRUE);
+}
+
+
+/* Destroy()
+ *
+ * This frees all (most?) of the resources malloced by XawIm.
+ * It is called by _XawImDestroy, which is called by Vendor.c's
+ * VendorExt's Destroy method. Sheeran, Omron KK, 93/08/05 */
+
+static void
+Destroy(Widget w, XawVendorShellExtPart *ve)
+{
+ contextDataRec *contextData;
+ contextErrDataRec *contextErrData;
+
+ if (!XtIsVendorShell( w ) )
+ return;
+ XtFree( (char*) ve->im.resources );
+
+ if (extContext != (XContext)NULL &&
+ !XFindContext (XtDisplay (w), (Window)w,
+ extContext, (XPointer*)&contextData))
+ XtFree( (char*) contextData );
+
+ if (errContext != (XContext)NULL &&
+ !XFindContext (XDisplayOfIM( ve->im.xim ), (Window) ve->im.xim,
+ errContext, (XPointer*) &contextErrData))
+ XtFree( (char*) contextErrData );
+}
+
+/*********************************************
+ *
+ * SEMI-PRIVATE FUNCTIONS
+ * For use by other Xaw modules
+ *
+ ********************************************/
+
+void
+_XawImResizeVendorShell(Widget w)
+{
+ XawVendorShellExtPart *ve;
+
+ if ( ( ve = GetExtPart( (VendorShellWidget) w ) ) && ve->im.xim ) {
+ ResizeVendorShell( (VendorShellWidget) w, ve );
+ }
+}
+
+
+Dimension
+_XawImGetShellHeight(Widget w)
+{
+ XawVendorShellExtPart *ve;
+
+ if (!XtIsVendorShell( w ) ) return( w->core.height );
+ if ( (ve = GetExtPart( (VendorShellWidget) w )) != NULL ) {
+ return( w->core.height - ve->im.area_height );
+ }
+ return( w->core.height );
+}
+
+void
+_XawImRealize(Widget w)
+{
+ XawVendorShellExtPart *ve;
+
+ if ( !XtIsRealized( w ) || !XtIsVendorShell( w ) ) return;
+ if ( (ve = GetExtPart( (VendorShellWidget) w )) != NULL ) {
+ XtAddEventHandler( w, (EventMask)StructureNotifyMask, FALSE,
+ XawVendorStructureNotifyHandler, (XtPointer)NULL );
+ AllCreateIC(ve);
+ }
+}
+
+void
+_XawImInitialize(Widget w, Widget ext)
+{
+ XawVendorShellExtPart *ve;
+
+ if ( !XtIsVendorShell( w ) ) return;
+ if ( (ve = SetExtPart( (VendorShellWidget) w, (XawVendorShellExtWidget)ext )) != NULL ) {
+ if ( Initialize( (VendorShellWidget) w, ve ) == FALSE ) return;
+ XtAddCallback( w, XtNdestroyCallback, VendorShellDestroyed,
+ (XtPointer) NULL );
+ }
+}
+
+void
+_XawImReconnect(Widget inwidg)
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+
+ if ((vw = SearchVendorShell(inwidg)) == NULL) return;
+ if ((ve = GetExtPart(vw)) != NULL) {
+ Reconnect(ve);
+ }
+}
+
+void
+_XawImRegister(Widget inwidg)
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+
+ if ((vw = SearchVendorShell(inwidg)) == NULL) return;
+ if ((ve = GetExtPart(vw)) != NULL) {
+ Register(inwidg, ve);
+ }
+}
+
+void
+_XawImUnregister(Widget inwidg)
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+
+ if ((vw = SearchVendorShell(inwidg)) == NULL) return;
+ if ((ve = GetExtPart(vw)) != NULL) {
+ Unregister(inwidg, ve);
+ }
+}
+
+void
+_XawImSetValues(Widget inwidg, ArgList args, Cardinal num_args)
+{
+ SetFocusValues( inwidg, args, num_args, FALSE );
+}
+
+void
+_XawImSetFocusValues(Widget inwidg, ArgList args, Cardinal num_args)
+{
+ SetFocusValues(inwidg, args, num_args, TRUE);
+}
+
+void
+_XawImUnsetFocus(Widget inwidg)
+{
+ UnsetFocus(inwidg);
+}
+
+int
+_XawImWcLookupString(Widget inwidg, XKeyPressedEvent *event,
+ wchar_t* buffer_return, int bytes_buffer,
+ KeySym *keysym_return)
+{
+ XawVendorShellExtPart* ve;
+ VendorShellWidget vw;
+ XawIcTableList p;
+ int i, ret;
+ char tmp_buf[64], *tmp_p;
+ wchar_t* buf_p;
+
+ if ((vw = SearchVendorShell(inwidg)) && (ve = GetExtPart(vw)) &&
+ ve->im.xim && (p = GetIcTableShared(inwidg, ve)) && p->xic) {
+ return(XwcLookupString(p->xic, event, buffer_return, bytes_buffer/sizeof(wchar_t),
+ keysym_return, NULL));
+ }
+ ret = XLookupString( event, tmp_buf, sizeof(tmp_buf), keysym_return,
+ NULL );
+ for ( i = 0, tmp_p = tmp_buf, buf_p = buffer_return; i < ret; i++ ) {
+ *buf_p++ = _Xaw_atowc(*tmp_p++);
+ }
+ return( ret );
+}
+
+int
+_XawLookupString(Widget w, XKeyEvent *event, char *buffer_return, int buffer_size,
+ KeySym *keysym_return)
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+ XawIcTableList p;
+
+ if ((vw = SearchVendorShell(w)) && (ve = GetExtPart(vw))
+ && ve->im.xim && (p = GetIcTableShared(w, ve)) && p->xic)
+ return (XmbLookupString(p->xic, event, buffer_return, buffer_size,
+ keysym_return, NULL));
+
+ return (XLookupString(event, buffer_return, buffer_size,
+ keysym_return, NULL));
+}
+
+int
+_XawImGetImAreaHeight(Widget w)
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+
+ if ((vw = SearchVendorShell(w)) && (ve = GetExtPart(vw))) {
+ return(ve->im.area_height);
+ }
+ return(0);
+}
+
+void
+_XawImCallVendorShellExtResize(Widget w)
+{
+ VendorShellWidget vw;
+
+ if ((vw = SearchVendorShell(w)) && GetExtPart(vw)) {
+ XawVendorShellExtResize((Widget)vw);
+ }
+}
+
+
+/* _XawImDestroy()
+ *
+ * This should be called by the VendorExt from its
+ * core Destroy method. Sheeran, Omron KK 93/08/05 */
+
+void
+_XawImDestroy(Widget w, Widget ext)
+{
+ XawVendorShellExtPart *ve;
+
+ if ( !XtIsVendorShell( w ) ) return;
+ if ( (ve = GetExtPart( (VendorShellWidget) w )) != NULL )
+ Destroy( w, ve );
+}
diff --git a/nx-X11/lib/Xaw/XawImP.h b/nx-X11/lib/Xaw/XawImP.h
new file mode 100644
index 000000000..e36f5050f
--- /dev/null
+++ b/nx-X11/lib/Xaw/XawImP.h
@@ -0,0 +1,213 @@
+/* $Xorg: XawImP.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/*
+ * Copyright 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 of 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 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xaw/XawImP.h,v 3.8 2001/01/17 19:42:36 dawes Exp $ */
+
+#ifndef _XawImP_h
+#define _XawImP_h
+
+#define XtNinputMethod "inputMethod"
+#define XtCInputMethod "InputMethod"
+#define XtNpreeditType "preeditType"
+#define XtCPreeditType "PreeditType"
+#define XtNopenIm "openIm"
+#define XtCOpenIm "OpenIm"
+#define XtNsharedIc "sharedIc"
+#define XtCSharedIc "SharedIc"
+
+#include <X11/Xaw/Text.h>
+
+#define CIICFocus (1 << 0)
+#define CIFontSet (1 << 1)
+#define CIFg (1 << 2)
+#define CIBg (1 << 3)
+#define CIBgPixmap (1 << 4)
+#define CICursorP (1 << 5)
+#define CILineS (1 << 6)
+
+typedef struct _XawImPart {
+ XIM xim;
+ XrmResourceList resources;
+ Cardinal num_resources;
+ Boolean open_im;
+ Boolean initialized;
+ Dimension area_height;
+ String input_method;
+ String preedit_type;
+} XawImPart;
+
+typedef struct _XawIcTablePart {
+ Widget widget;
+ XIC xic;
+ XIMStyle input_style;
+ unsigned long flg;
+ unsigned long prev_flg;
+ Boolean ic_focused;
+ XFontSet font_set;
+ Pixel foreground;
+ Pixel background;
+ Pixmap bg_pixmap;
+ XawTextPosition cursor_position;
+ unsigned long line_spacing;
+ Boolean openic_error;
+ struct _XawIcTablePart *next;
+} XawIcTablePart, *XawIcTableList;
+
+typedef struct _XawIcPart {
+ XIMStyle input_style;
+ Boolean shared_ic;
+ XawIcTableList shared_ic_table;
+ XawIcTableList current_ic_table;
+ XawIcTableList ic_table;
+} XawIcPart;
+
+typedef struct _contextDataRec {
+ Widget parent;
+ Widget ve;
+} contextDataRec;
+
+typedef struct _contextErrDataRec {
+ Widget widget;
+ XIM xim;
+} contextErrDataRec;
+
+void _XawImResizeVendorShell
+(
+ Widget w
+ );
+
+Dimension _XawImGetShellHeight
+(
+ Widget w
+);
+
+void _XawImRealize
+(
+ Widget w
+ );
+
+void _XawImInitialize
+(
+ Widget w,
+ Widget ext
+ );
+
+void _XawImReconnect
+(
+ Widget w
+ );
+
+void _XawImRegister
+(
+ Widget w
+ );
+
+void _XawImUnregister
+(
+ Widget w
+ );
+
+void _XawImSetValues
+(
+ Widget w,
+ ArgList args,
+ Cardinal num_args
+ );
+
+void _XawImSetFocusValues
+(
+ Widget w,
+ ArgList args,
+ Cardinal num_args
+);
+
+void _XawImUnsetFocus
+(
+ Widget w
+ );
+
+int _XawImWcLookupString
+(
+ Widget w,
+ XKeyPressedEvent *event,
+ wchar_t *buffer_return,
+ int bytes_buffer,
+ KeySym *keysym_return
+ );
+
+int _XawLookupString
+(
+ Widget w,
+ XKeyEvent *event,
+ char *buffer_return,
+ int buffer_size,
+ KeySym *keysym_return
+ );
+
+int _XawImGetImAreaHeight
+(
+ Widget w
+ );
+
+void _XawImCallVendorShellExtResize
+(
+ Widget w
+ );
+
+void _XawImDestroy
+(
+ Widget w,
+ Widget ext
+ );
+
+#endif /* _XawImP_h */
diff --git a/nx-X11/lib/Xaw/XawInit.c b/nx-X11/lib/Xaw/XawInit.c
new file mode 100644
index 000000000..79bc78a5e
--- /dev/null
+++ b/nx-X11/lib/Xaw/XawInit.c
@@ -0,0 +1,100 @@
+/*
+ * $Xorg: XawInit.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+ *
+Copyright 1989, 1998 The Open Group
+Copyright 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
+
+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.
+ *
+ *
+ * XawInitializeWidgetSet
+ *
+ * This routine forces a reference to vendor shell so that the one in this
+ * widget is installed. Any other cross-widget set initialization should be
+ * done here as well. All Athena widgets should include "XawInit.h" and
+ * call this routine from their ClassInitialize procs (this routine may be
+ * used as the class init proc).
+ */
+/* $XFree86: xc/lib/Xaw/XawInit.c,v 1.9 2001/01/17 19:42:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/Vendor.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include "Private.h"
+
+void
+XawInitializeWidgetSet(void)
+{
+ static Boolean firsttime = True;
+
+ if (firsttime) {
+ firsttime = False;
+#ifndef OLDXAW
+ XawPixmapsInitialize();
+ XawInitializeDefaultConverters();
+#endif
+ XtInitializeWidgetClass(vendorShellWidgetClass);
+ }
+}
+
+/* XawOpenApplication() - mainly identical to XtOpenApplication() but
+ * takes a |Display *| and |Screen *| as arguments, too... */
+Widget XawOpenApplication(XtAppContext *app_context_return,
+ Display *dpy,
+ Screen *screen,
+ String application_name,
+ String application_class,
+ WidgetClass widget_class,
+ int *argc,
+ String *argv)
+{
+ Widget toplevel;
+ Cardinal n;
+ Arg args[2];
+
+ XtToolkitInitialize();
+ *app_context_return = XtCreateApplicationContext();
+ if( *app_context_return == NULL )
+ return NULL;
+
+ XtDisplayInitialize(*app_context_return, dpy,
+ application_name, application_class,
+ NULL, 0,
+ argc, argv);
+
+ n = 0;
+ if (screen) {
+ XtSetArg(args[n], XtNscreen, screen); n++;
+ }
+ toplevel = XtAppCreateShell(application_name,
+ application_class,
+ widget_class,
+ dpy,
+ args, n);
+
+ return toplevel;
+}
+
diff --git a/nx-X11/lib/Xaw/XawInit.h b/nx-X11/lib/Xaw/XawInit.h
new file mode 100644
index 000000000..31852e283
--- /dev/null
+++ b/nx-X11/lib/Xaw/XawInit.h
@@ -0,0 +1,64 @@
+/* $Xorg: XawInit.h,v 1.5 2001/02/09 02:03:47 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+Copyright 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+/* $XFree86: xc/lib/Xaw/XawInit.h,v 1.12 2001/01/17 19:42:36 dawes Exp $ */
+
+/* $XdotOrg: xc/lib/Xaw/XawInit.h,v 1.3 2005/07/03 07:00:56 daniels Exp $ */
+#ifndef _XawInit_h
+#define _XawInit_h
+
+#define XawVendor XVENDORNAMESHORT
+
+#ifdef OLDXAW
+#define XawVersion 6700002L
+#else
+#define XawVersion 7000002L
+
+typedef struct _XawDL XawDisplayList;
+#endif /* OLDXAW */
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+void XawInitializeWidgetSet(void);
+#ifndef OLDXAW
+void XawInitializeDefaultConverters(void);
+#endif
+
+extern Widget XawOpenApplication(
+ XtAppContext *app_context_return,
+ Display *dpy,
+ Screen *screen,
+ String application_name,
+ String application_class,
+ WidgetClass widget_class,
+ int *argc,
+ String *argv
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawInit_h */
diff --git a/nx-X11/lib/Xaw/genlist.sh b/nx-X11/lib/Xaw/genlist.sh
new file mode 100644
index 000000000..e920337fd
--- /dev/null
+++ b/nx-X11/lib/Xaw/genlist.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+tmp=/tmp/gl.$$
+nm $* | egrep '(Widget|Obj|Object)Class' | \
+awk '{ if ($2 == "D" || $2 == "G") print $3; }' | sed -e 's/^_//' | \
+(cat - ; echo "objectClass") | sort -u | egrep -v 'ClassRec$' | \
+egrep -v 'vPanedWidgetClass$' | \
+egrep -v 'ascii(Disk|String)WidgetClass$' | \
+awk '
+{
+ printf "extern WidgetClass %s;\n", $1;
+ printf "{ \"%s\", &%s },\n", $1, $1;
+}' | sed -e 's/WidgetClass"/"/' -e 's/ObjClass"/"/' \
+ -e 's/ObjectClass"/"/' -e 's/objectClass"/object"/' \
+ -e 's/widgetClass"/widget"/' >$tmp
+
+cat <<EOF
+/*
+ * This file is generated by the genlist.sh script and contains an array of
+ * all the widgets in Athena widget set.
+ *
+ * \$XConsortium\$
+ */
+#include <X11/IntrinsicP.h>
+#include <X11/Xmu/WidgetNode.h>
+
+EOF
+egrep '^extern WidgetClass' $tmp
+echo ""
+cat <<EOF
+XmuWidgetNode XawWidgetArray[] = {
+EOF
+egrep '^{' $tmp
+cat <<EOF
+};
+
+int XawWidgetCount = XtNumber(XawWidgetArray);
+
+EOF
+
+rm $tmp
diff --git a/nx-X11/lib/Xaw/jump_funcs b/nx-X11/lib/Xaw/jump_funcs
new file mode 100644
index 000000000..d43f60973
--- /dev/null
+++ b/nx-X11/lib/Xaw/jump_funcs
@@ -0,0 +1,117 @@
+# $Xorg: jump_funcs,v 1.3 2000/08/17 19:45:44 cpqbld Exp $
+#
+#
+#
+#
+# $XFree86: xc/lib/Xaw/jump_funcs,v 3.2 1996/02/12 11:11:15 dawes Exp $
+#
+00000000 T _XawAsciiSourceFreeString libXaw AsciiSrc
+00000000 T _XawAsciiSave libXaw AsciiSrc
+00000000 T _XawAsciiSaveAsFile libXaw AsciiSrc
+00000000 T _XawAsciiSourceChanged libXaw AsciiSrc
+00000000 T _XawDialogAddButton libXaw Dialog
+00000000 T _XawDialogGetValueString libXaw Dialog
+00000000 T _XawFormDoLayout libXaw Form
+00000000 T _XawListChange libXaw List
+00000000 T _XawListUnhighlight libXaw List
+00000000 T _XawListHighlight libXaw List
+00000000 T _XawListShowCurrent libXaw List
+00000000 T _XawPanedSetMinMax libXaw Paned
+00000000 T _XawPanedGetMinMax libXaw Paned
+00000000 T _XawPanedSetRefigureMode libXaw Paned
+00000000 T _XawPanedGetNumSub libXaw Paned
+00000000 T _XawPanedAllowResize libXaw Paned
+00000000 T _XawScrollbarSetThumb libXaw Scrollbar
+00000000 T _XawSimpleMenuAddGlobalActions libXaw SimpleMenu
+00000000 T _XawSimpleMenuGetActiveEntry libXaw SimpleMenu
+00000000 T _XawSimpleMenuClearActiveEntry libXaw SimpleMenu
+00000000 T __XawTextNeedsUpdating libXaw Text
+00000000 T __XawTextGetText libXaw Text
+00000000 T __XawTextGetSTRING libXaw Text
+00000000 T __XawTextBuildLineTable libXaw Text
+00000000 T __XawTextSetScrollBars libXaw Text
+00000000 T __XawTextVScroll libXaw Text
+00000000 T __XawTextSaltAwaySelection libXaw Text
+00000000 T __XawTextReplace libXaw Text
+00000000 T __XawTextClearAndCenterDisplay libXaw Text
+00000000 T __XawTextCheckResize libXaw Text
+00000000 T __XawTextSelectionList libXaw Text
+00000000 T __XawTextSetSelection libXaw Text
+00000000 T __XawTextAlterSelection libXaw Text
+00000000 T __XawTextPrepareToUpdate libXaw Text
+00000000 T __XawTextShowPosition libXaw Text
+00000000 T __XawTextExecuteUpdate libXaw Text
+00000000 T _XawTextDisplay libXaw Text
+00000000 T _XawTextSetSelectionArray libXaw Text
+00000000 T _XawTextGetSelectionPos libXaw Text
+00000000 T _XawTextSetSource libXaw Text
+00000000 T _XawTextReplace libXaw Text
+00000000 T _XawTextTopPosition libXaw Text
+00000000 T _XawTextSetInsertionPoint libXaw Text
+00000000 T _XawTextGetInsertionPoint libXaw Text
+00000000 T _XawTextUnsetSelection libXaw Text
+00000000 T _XawTextSetSelection libXaw Text
+00000000 T _XawTextInvalidate libXaw Text
+00000000 T _XawTextDisableRedisplay libXaw Text
+00000000 T _XawTextEnableRedisplay libXaw Text
+00000000 T _XawTextGetSource libXaw Text
+00000000 T _XawTextDisplayCaret libXaw Text
+00000000 T _XawTextSearch libXaw Text
+00000000 T _XawTextSinkDisplayText libXaw TextSink
+00000000 T _XawTextSinkInsertCursor libXaw TextSink
+00000000 T _XawTextSinkClearToBackground libXaw TextSink
+00000000 T _XawTextSinkFindPosition libXaw TextSink
+00000000 T _XawTextSinkFindDistance libXaw TextSink
+00000000 T _XawTextSinkResolve libXaw TextSink
+00000000 T _XawTextSinkMaxLines libXaw TextSink
+00000000 T _XawTextSinkMaxHeight libXaw TextSink
+00000000 T _XawTextSinkSetTabs libXaw TextSink
+00000000 T _XawTextSinkGetCursorBounds libXaw TextSink
+00000000 T _XawTextSourceRead libXaw TextSrc
+00000000 T _XawTextSourceReplace libXaw TextSrc
+00000000 T _XawTextSourceScan libXaw TextSrc
+00000000 T _XawTextSourceSearch libXaw TextSrc
+00000000 T _XawTextSourceConvertSelection libXaw TextSrc
+00000000 T _XawTextSourceSetSelection libXaw TextSrc
+00000000 T __XawTextZapSelection libXaw TextAction
+00000000 T __XawTextInsertFileAction libXaw TextPop
+00000000 T __XawTextInsertFile libXaw TextPop
+00000000 T __XawTextDoSearchAction libXaw TextPop
+00000000 T __XawTextPopdownSearchAction libXaw TextPop
+00000000 T __XawTextSearch libXaw TextPop
+00000000 T __XawTextDoReplaceAction libXaw TextPop
+00000000 T __XawTextSetField libXaw TextPop
+00000000 T _XawToggleChangeRadioGroup libXaw Toggle
+00000000 T _XawToggleGetCurrent libXaw Toggle
+00000000 T _XawToggleSetCurrent libXaw Toggle
+00000000 T _XawToggleUnsetCurrent libXaw Toggle
+00000000 T _XawTreeForceLayout libXaw Tree
+00000000 T _XawViewportSetLocation libXaw Viewport
+00000000 T _XawViewportSetCoordinates libXaw Viewport
+00000000 T _XawInitializeWidgetSet libXaw XawInit
+00000000 T __XawMultiSourceFreeString libXaw MultiSrc
+00000000 T __XawMultiSave libXaw MultiSrc
+00000000 T __XawMultiSaveAsFile libXaw MultiSrc
+00000000 T __XawMultiSinkPosToXY libXaw MultiSink
+00000000 T __XawTextPosToXY libXaw Text
+00000000 T __XawTextFormat libXaw TextSrc
+00000000 T __XawTextWCToMB libXaw TextSrc
+00000000 T __XawTextMBToWC libXaw TextSrc
+00000000 T _XawVendorShellExtResize libXaw Vendor
+00000000 T __XawImResizeVendorShell libXaw XawIm
+00000000 T __XawImGetShellHeight libXaw XawIm
+00000000 T __XawImRealize libXaw XawIm
+00000000 T __XawImInitialize libXaw XawIm
+00000000 T __XawImReconnect libXaw XawIm
+00000000 T __XawImRegister libXaw XawIm
+00000000 T __XawImUnregister libXaw XawIm
+00000000 T __XawImSetValues libXaw XawIm
+00000000 T __DUMMY__ libXaw XawIm
+00000000 T __XawImSetFocusValues libXaw XawIm
+00000000 T __DUMMY__ libXaw XawIm
+00000000 T __XawImUnsetFocus libXaw XawIm
+00000000 T __XawImWcLookupString libXaw XawIm
+00000000 T __XawImGetImAreaHeight libXaw XawIm
+00000000 T __XawImCallVendorShellExtResize libXaw XawIm
+00000000 T __XawImDestroy libXaw XawIm
+00000000 T __Xaw_atowc libXaw XawI18n
diff --git a/nx-X11/lib/Xaw/jump_ignore b/nx-X11/lib/Xaw/jump_ignore
new file mode 100644
index 000000000..179bf92da
--- /dev/null
+++ b/nx-X11/lib/Xaw/jump_ignore
@@ -0,0 +1,7 @@
+# $Xorg: jump_ignore,v 1.3 2000/08/17 19:45:45 cpqbld Exp $
+#
+#
+#
+#
+# $XFree86: xc/lib/Xaw/jump_ignore,v 3.1 1995/01/28 15:43:32 dawes Exp $
+# jump_ignore
diff --git a/nx-X11/lib/Xaw/jump_vars b/nx-X11/lib/Xaw/jump_vars
new file mode 100644
index 000000000..dbb9023e2
--- /dev/null
+++ b/nx-X11/lib/Xaw/jump_vars
@@ -0,0 +1,83 @@
+# $Xorg: jump_vars,v 1.3 2000/08/17 19:45:45 cpqbld Exp $
+#
+#
+#
+#
+# $XFree86: xc/lib/Xaw/jump_vars,v 3.1 1995/01/28 15:43:33 dawes Exp $
+#
+00001400 D _XawWidgetArray libXaw AllWidgets
+00000004 D _XawWidgetCount libXaw AllWidgets
+00000140 D _asciiSinkClassRec libXaw AsciiSink
+00000004 D _asciiSinkObjectClass libXaw AsciiSink
+00000120 D _asciiSrcClassRec libXaw AsciiSrc
+00000004 D _asciiSrcObjectClass libXaw AsciiSrc
+00000100 D _asciiTextClassRec libXaw AsciiText
+00000004 D _asciiTextWidgetClass libXaw AsciiText
+00000100 D _boxClassRec libXaw Box
+00000004 D _boxWidgetClass libXaw Box
+00000100 D _commandClassRec libXaw Command
+00000004 D _commandWidgetClass libXaw Command
+00000140 D _dialogClassRec libXaw Dialog
+00000004 D _dialogWidgetClass libXaw Dialog
+00000140 D _formClassRec libXaw Form
+00000004 D _formWidgetClass libXaw Form
+00000100 D _gripClassRec libXaw Grip
+00000004 D _gripWidgetClass libXaw Grip
+00000100 D _labelClassRec libXaw Label
+00000004 D _labelWidgetClass libXaw Label
+00000100 D _listClassRec libXaw List
+00000004 D _listWidgetClass libXaw List
+00000100 D _menuButtonClassRec libXaw MenuButton
+00000004 D _menuButtonWidgetClass libXaw MenuButton
+00000140 D _panedClassRec libXaw Paned
+00000004 D _panedWidgetClass libXaw Paned
+00000004 D _vPanedWidgetClass libXaw Paned
+00000100 D _pannerClassRec libXaw Panner
+00000004 D _pannerWidgetClass libXaw Panner
+00000100 D _portholeClassRec libXaw Porthole
+00000004 D _portholeWidgetClass libXaw Porthole
+00000100 D _repeaterClassRec libXaw Repeater
+00000004 D _repeaterWidgetClass libXaw Repeater
+00000100 D _scrollbarClassRec libXaw Scrollbar
+00000004 D _scrollbarWidgetClass libXaw Scrollbar
+00000100 D _simpleClassRec libXaw Simple
+00000004 D _simpleWidgetClass libXaw Simple
+00000100 D _simpleMenuClassRec libXaw SimpleMenu
+00000004 D _simpleMenuWidgetClass libXaw SimpleMenu
+00000100 D _smeClassRec libXaw Sme
+00000004 D _smeObjectClass libXaw Sme
+00000100 D _smeBSBClassRec libXaw SmeBSB
+00000004 D _smeBSBObjectClass libXaw SmeBSB
+00000100 D _smeLineClassRec libXaw SmeLine
+00000004 D _smeLineObjectClass libXaw SmeLine
+00000100 D _stripChartClassRec libXaw StripChart
+00000004 D _stripChartWidgetClass libXaw StripChart
+00000004 D _FMT8BIT libXaw Text
+00000100 D _textClassRec libXaw Text
+00000004 D _textWidgetClass libXaw Text
+00000100 D _textSinkClassRec libXaw TextSink
+00000004 D _textSinkObjectClass libXaw TextSink
+00000100 D _textSrcClassRec libXaw TextSrc
+00000004 D _textSrcObjectClass libXaw TextSrc
+00000300 D __XawTextActionsTable libXaw TextAction
+00000004 D __XawTextActionsTableCount libXaw TextAction
+00000004 D __XawDefaultTextTranslations1 libXaw TextTr
+00000004 D __XawDefaultTextTranslations2 libXaw TextTr
+00000004 D __XawDefaultTextTranslations3 libXaw TextTr
+00000100 D _toggleClassRec libXaw Toggle
+00000004 D _toggleWidgetClass libXaw Toggle
+00000140 D _treeClassRec libXaw Tree
+00000004 D _treeWidgetClass libXaw Tree
+00000100 D _vendorShellClassRec libXaw Vendor
+00000004 D _vendorShellWidgetClass libXaw Vendor
+00000140 D _viewportClassRec libXaw Viewport
+00000004 D _viewportWidgetClass libXaw Viewport
+00000140 D _multiSrcClassRec libXaw MultiSrc
+00000004 D _multiSrcObjectClass libXaw MultiSrc
+00000140 D _multiSinkClassRec libXaw MultiSink
+00000004 D _multiSinkObjectClass libXaw MultiSink
+00000004 D __XawDefaultTextTranslations4 libXaw TextTr
+00000140 D _xawvendorShellExtClassRec libXaw Vendor
+00000004 D _xawvendorShellExtWidgetClass libXaw Vendor
+00000004 D _XawFmt8Bit libXaw Text
+00000004 D _XawFmtWide libXaw Text
diff --git a/nx-X11/lib/Xaw/sharedlib.c b/nx-X11/lib/Xaw/sharedlib.c
new file mode 100644
index 000000000..d107f9fcb
--- /dev/null
+++ b/nx-X11/lib/Xaw/sharedlib.c
@@ -0,0 +1,182 @@
+/* $Xorg: sharedlib.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 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.
+
+*/
+
+#if defined(SUNSHLIB) && !defined(SHAREDCODE)
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/Xaw/AsciiSinkP.h>
+#include <X11/Xaw/AsciiSrcP.h>
+#include <X11/Xaw/AsciiTextP.h>
+#include <X11/Xaw/MultiSinkP.h>
+#include <X11/Xaw/MultiSrcP.h>
+#include <X11/Xaw/BoxP.h>
+#include <X11/Xaw/CommandP.h>
+#include <X11/Xaw/DialogP.h>
+#include <X11/Xaw/FormP.h>
+#include <X11/Xaw/GripP.h>
+#include <X11/Xaw/LabelP.h>
+#include <X11/Xaw/ListP.h>
+#include <X11/Xaw/MenuButtoP.h>
+#include <X11/Xaw/PanedP.h>
+#include <X11/Xaw/PannerP.h>
+#include <X11/Xaw/PortholeP.h>
+#include <X11/Xaw/RepeaterP.h>
+#include <X11/Xaw/ScrollbarP.h>
+#include <X11/Xaw/SimpleP.h>
+#include <X11/Xaw/SimpleMenP.h>
+#include <X11/Xaw/SmeP.h>
+#include <X11/Xaw/SmeBSBP.h>
+#include <X11/Xaw/SmeLineP.h>
+#include <X11/Xaw/StripCharP.h>
+#include <X11/Xaw/TextP.h>
+#include <X11/Xaw/TextSinkP.h>
+#include <X11/Xaw/TextSrcP.h>
+#include <X11/Xaw/ToggleP.h>
+#include <X11/Xaw/TreeP.h>
+#include <X11/VendorP.h>
+#include <X11/Xaw/ViewportP.h>
+#if !defined(OLDXAW) && !defined(XAW7)
+#include <X11/Xaw/PrintSP.h>
+#endif
+
+extern AsciiSinkClassRec asciiSinkClassRec;
+WidgetClass asciiSinkObjectClass = (WidgetClass)&asciiSinkClassRec;
+
+extern AsciiSrcClassRec asciiSrcClassRec;
+WidgetClass asciiSrcObjectClass = (WidgetClass)&asciiSrcClassRec;
+
+extern AsciiTextClassRec asciiTextClassRec;
+WidgetClass asciiTextWidgetClass = (WidgetClass)&asciiTextClassRec;
+
+#ifdef ASCII_STRING
+extern AsciiStringClassRec asciiStringClassRec;
+WidgetClass asciiStringWidgetClass = (WidgetClass)&asciiStringClassRec;
+#endif
+
+#ifdef ASCII_DISK
+extern AsciiDiskClassRec asciiDiskClassRec;
+WidgetClass asciiDiskWidgetClass = (WidgetClass)&asciiDiskClassRec;
+#endif
+
+extern MultiSinkClassRec multiSinkClassRec;
+WidgetClass multiSinkObjectClass = (WidgetClass)&multiSinkClassRec;
+
+extern MultiSrcClassRec multiSrcClassRec;
+WidgetClass multiSrcObjectClass = (WidgetClass)&multiSrcClassRec;
+
+extern BoxClassRec boxClassRec;
+WidgetClass boxWidgetClass = (WidgetClass)&boxClassRec;
+
+extern CommandClassRec commandClassRec;
+WidgetClass commandWidgetClass = (WidgetClass) &commandClassRec;
+
+extern DialogClassRec dialogClassRec;
+WidgetClass dialogWidgetClass = (WidgetClass)&dialogClassRec;
+
+extern FormClassRec formClassRec;
+WidgetClass formWidgetClass = (WidgetClass)&formClassRec;
+
+extern GripClassRec gripClassRec;
+WidgetClass gripWidgetClass = (WidgetClass) &gripClassRec;
+
+extern LabelClassRec labelClassRec;
+WidgetClass labelWidgetClass = (WidgetClass)&labelClassRec;
+
+extern ListClassRec listClassRec;
+WidgetClass listWidgetClass = (WidgetClass)&listClassRec;
+
+extern MenuButtonClassRec menuButtonClassRec;
+WidgetClass menuButtonWidgetClass = (WidgetClass) &menuButtonClassRec;
+
+extern PanedClassRec panedClassRec;
+WidgetClass panedWidgetClass = (WidgetClass) &panedClassRec;
+WidgetClass vPanedWidgetClass = (WidgetClass) &panedClassRec;
+
+extern PannerClassRec pannerClassRec;
+WidgetClass pannerWidgetClass = (WidgetClass) &pannerClassRec;
+
+extern PortholeClassRec portholeClassRec;
+WidgetClass portholeWidgetClass = (WidgetClass) &portholeClassRec;
+
+extern RepeaterClassRec repeaterClassRec;
+WidgetClass repeaterWidgetClass = (WidgetClass) &repeaterClassRec;
+
+extern ScrollbarClassRec scrollbarClassRec;
+WidgetClass scrollbarWidgetClass = (WidgetClass)&scrollbarClassRec;
+
+extern SimpleClassRec simpleClassRec;
+WidgetClass simpleWidgetClass = (WidgetClass)&simpleClassRec;
+
+extern SimpleMenuClassRec simpleMenuClassRec;
+WidgetClass simpleMenuWidgetClass = (WidgetClass)&simpleMenuClassRec;
+
+extern SmeClassRec smeClassRec;
+WidgetClass smeObjectClass = (WidgetClass) &smeClassRec;
+
+extern SmeBSBClassRec smeBSBClassRec;
+WidgetClass smeBSBObjectClass = (WidgetClass) &smeBSBClassRec;
+
+extern SmeLineClassRec smeLineClassRec;
+WidgetClass smeLineObjectClass = (WidgetClass) &smeLineClassRec;
+
+extern StripChartClassRec stripChartClassRec;
+WidgetClass stripChartWidgetClass = (WidgetClass) &stripChartClassRec;
+
+extern TextClassRec textClassRec;
+WidgetClass textWidgetClass = (WidgetClass)&textClassRec;
+
+unsigned long FMT8BIT = 0L;
+unsigned long XawFmt8Bit = 0L;
+unsigned long XawFmtWide = 0L;
+
+extern TextSinkClassRec textSinkClassRec;
+WidgetClass textSinkObjectClass = (WidgetClass)&textSinkClassRec;
+
+extern TextSrcClassRec textSrcClassRec;
+WidgetClass textSrcObjectClass = (WidgetClass)&textSrcClassRec;
+
+extern ToggleClassRec toggleClassRec;
+WidgetClass toggleWidgetClass = (WidgetClass) &toggleClassRec;
+
+extern TreeClassRec treeClassRec;
+WidgetClass treeWidgetClass = (WidgetClass) &treeClassRec;
+
+extern VendorShellClassRec vendorShellClassRec;
+WidgetClass vendorShellWidgetClass = (WidgetClass) &vendorShellClassRec;
+
+extern ViewportClassRec viewportClassRec;
+WidgetClass viewportWidgetClass = (WidgetClass)&viewportClassRec;
+
+#if !defined(OLDXAW) && !defined(XAW7)
+extern XawPrintShellClassRec xawPrintShellClassRec;
+WidgetClass xawPrintShellWidgetClass = (WidgetClass) &xawPrintShellClassRec;
+#endif
+
+#endif /* SUNSHLIB */
diff --git a/nx-X11/lib/Xaw6/Imakefile b/nx-X11/lib/Xaw6/Imakefile
new file mode 100644
index 000000000..58b54b228
--- /dev/null
+++ b/nx-X11/lib/Xaw6/Imakefile
@@ -0,0 +1,170 @@
+XCOMM $XFree86: xc/lib/Xaw6/Imakefile,v 1.2 1999/06/06 14:05:55 dawes Exp $
+#define DoNormalLib NormalLibXaw6
+#define DoSharedLib SharedLibXaw6
+#define DoExtraLib SharedLibXaw6
+#define DoDebugLib DebugLibXaw6
+#define DoProfileLib ProfileLibXaw6
+#define HasSharedData YES
+#define LibName Xaw
+#define SoRev SOXAW6REV
+#define LibHeaders NO
+#define NoSoSymlink
+
+#ifdef SharedXaw6Reqs
+REQUIREDLIBS = SharedXaw6Reqs
+#endif
+
+DEFINES = XawI18nDefines -DOLDXAW
+
+ LINTLIBS = $(LINTXLIB) $(LINTXTOOL)
+
+SRCS = \
+ Actions.c \
+ AllWidgets.c \
+ AsciiSink.c \
+ AsciiSrc.c \
+ AsciiText.c \
+ Box.c \
+ Command.c \
+ Converters.c \
+ Dialog.c \
+ DisplayList.c \
+ Form.c \
+ Grip.c \
+ Label.c \
+ List.c \
+ MenuButton.c \
+ MultiSrc.c \
+ MultiSink.c \
+ OS.c \
+ Paned.c \
+ Panner.c \
+ Pixmap.c \
+ Porthole.c \
+ Repeater.c \
+ Scrollbar.c \
+ Simple.c \
+ SimpleMenu.c \
+ Sme.c \
+ SmeBSB.c \
+ SmeLine.c \
+ StripChart.c \
+ Text.c \
+ TextSink.c \
+ TextSrc.c \
+ TextAction.c \
+ TextPop.c \
+ TextTr.c \
+ Toggle.c \
+ Tree.c \
+ Vendor.c \
+ Viewport.c \
+ XawIm.c \
+ XawInit.c \
+ XawI18n.c \
+ sharedlib.c
+
+#if SharedDataSeparation
+UNSHAREDOBJS = AllWidgets.o sharedlib.o
+#endif
+
+OBJS = \
+ Actions.o \
+ AllWidgets.o \
+ AsciiSink.o \
+ AsciiSrc.o \
+ AsciiText.o \
+ Box.o \
+ Command.o \
+ Converters.o \
+ Dialog.o \
+ DisplayList.o \
+ Form.o \
+ Grip.o \
+ Label.o \
+ List.o \
+ MenuButton.o \
+ MultiSrc.o \
+ MultiSink.o \
+ OS.o \
+ Paned.o \
+ Panner.o \
+ Pixmap.o \
+ Porthole.o \
+ Repeater.o \
+ Scrollbar.o \
+ Simple.o \
+ SimpleMenu.o \
+ Sme.o \
+ SmeBSB.o \
+ SmeLine.o \
+ StripChart.o \
+ Text.o \
+ TextSink.o \
+ TextSrc.o \
+ TextAction.o \
+ TextPop.o \
+ TextTr.o \
+ Toggle.o \
+ Tree.o \
+ Vendor.o \
+ Viewport.o \
+ XawIm.o \
+ XawI18n.o \
+ XawInit.o $(OSOBJS)
+
+INCLUDES = -I$(AWIDGETSRC)
+
+#include <Library.tmpl>
+
+#if DoSharedLib && SharedDataSeparation
+SpecialCObjectRule(sharedlib,NullParameter,$(SHLIBDEF))
+#endif
+
+LinkSourceFile(Actions.c,$(AWIDGETSRC))
+LinkSourceFile(AllWidgets.c,$(AWIDGETSRC))
+LinkSourceFile(AsciiSink.c,$(AWIDGETSRC))
+LinkSourceFile(AsciiSrc.c,$(AWIDGETSRC))
+LinkSourceFile(AsciiText.c,$(AWIDGETSRC))
+LinkSourceFile(Box.c,$(AWIDGETSRC))
+LinkSourceFile(Command.c,$(AWIDGETSRC))
+LinkSourceFile(Converters.c,$(AWIDGETSRC))
+LinkSourceFile(Dialog.c,$(AWIDGETSRC))
+LinkSourceFile(DisplayList.c,$(AWIDGETSRC))
+LinkSourceFile(Form.c,$(AWIDGETSRC))
+LinkSourceFile(Grip.c,$(AWIDGETSRC))
+LinkSourceFile(Label.c,$(AWIDGETSRC))
+LinkSourceFile(List.c,$(AWIDGETSRC))
+LinkSourceFile(MenuButton.c,$(AWIDGETSRC))
+LinkSourceFile(MultiSrc.c,$(AWIDGETSRC))
+LinkSourceFile(MultiSink.c,$(AWIDGETSRC))
+LinkSourceFile(OS.c,$(AWIDGETSRC))
+LinkSourceFile(Paned.c,$(AWIDGETSRC))
+LinkSourceFile(Panner.c,$(AWIDGETSRC))
+LinkSourceFile(Pixmap.c,$(AWIDGETSRC))
+LinkSourceFile(Porthole.c,$(AWIDGETSRC))
+LinkSourceFile(Repeater.c,$(AWIDGETSRC))
+LinkSourceFile(Scrollbar.c,$(AWIDGETSRC))
+LinkSourceFile(Simple.c,$(AWIDGETSRC))
+LinkSourceFile(SimpleMenu.c,$(AWIDGETSRC))
+LinkSourceFile(Sme.c,$(AWIDGETSRC))
+LinkSourceFile(SmeBSB.c,$(AWIDGETSRC))
+LinkSourceFile(SmeLine.c,$(AWIDGETSRC))
+LinkSourceFile(StripChart.c,$(AWIDGETSRC))
+LinkSourceFile(Text.c,$(AWIDGETSRC))
+LinkSourceFile(TextSink.c,$(AWIDGETSRC))
+LinkSourceFile(TextSrc.c,$(AWIDGETSRC))
+LinkSourceFile(TextAction.c,$(AWIDGETSRC))
+LinkSourceFile(TextPop.c,$(AWIDGETSRC))
+LinkSourceFile(TextTr.c,$(AWIDGETSRC))
+LinkSourceFile(Toggle.c,$(AWIDGETSRC))
+LinkSourceFile(Tree.c,$(AWIDGETSRC))
+LinkSourceFile(Vendor.c,$(AWIDGETSRC))
+LinkSourceFile(Viewport.c,$(AWIDGETSRC))
+LinkSourceFile(XawIm.c,$(AWIDGETSRC))
+LinkSourceFile(XawInit.c,$(AWIDGETSRC))
+LinkSourceFile(XawI18n.c,$(AWIDGETSRC))
+LinkSourceFile(sharedlib.c,$(AWIDGETSRC))
+
+DependTarget()
+
diff --git a/nx-X11/lib/Xaw6/Xaw-def.cpp b/nx-X11/lib/Xaw6/Xaw-def.cpp
new file mode 100644
index 000000000..5fcdc9352
--- /dev/null
+++ b/nx-X11/lib/Xaw6/Xaw-def.cpp
@@ -0,0 +1,144 @@
+LIBRARY Xaw
+VERSION LIBRARY_VERSION
+EXPORTS
+ asciiSinkClassRec DATA
+ asciiSinkObjectClass DATA
+ asciiSrcClassRec DATA
+ asciiSrcObjectClass DATA
+ asciiTextClassRec DATA
+ asciiTextWidgetClass DATA
+ boxClassRec DATA
+ boxWidgetClass DATA
+ commandClassRec DATA
+ commandWidgetClass DATA
+ dialogClassRec DATA
+ dialogWidgetClass DATA
+ FMT8BIT DATA
+ formClassRec DATA
+ formWidgetClass DATA
+ gripClassRec DATA
+ gripWidgetClass DATA
+ labelClassRec DATA
+ labelWidgetClass DATA
+ listClassRec DATA
+ listWidgetClass DATA
+ menuButtonClassRec DATA
+ menuButtonWidgetClass DATA
+ multiSinkClassRec DATA
+ multiSinkObjectClass DATA
+ multiSrcClassRec DATA
+ multiSrcObjectClass DATA
+ panedClassRec DATA
+ panedWidgetClass DATA
+ pannerClassRec DATA
+ pannerWidgetClass DATA
+ portholeClassRec DATA
+ portholeWidgetClass DATA
+ repeaterClassRec DATA
+ repeaterWidgetClass DATA
+ scrollbarClassRec DATA
+ scrollbarWidgetClass DATA
+ simpleClassRec DATA
+ simpleMenuClassRec DATA
+ simpleMenuWidgetClass DATA
+ simpleWidgetClass DATA
+ smeBSBClassRec DATA
+ smeBSBObjectClass DATA
+ smeClassRec DATA
+ smeLineClassRec DATA
+ smeLineObjectClass DATA
+ smeObjectClass DATA
+ stripChartClassRec DATA
+ stripChartWidgetClass DATA
+ textClassRec DATA
+ textSinkClassRec DATA
+ textSinkObjectClass DATA
+ textSrcClassRec DATA
+ textSrcObjectClass DATA
+ textWidgetClass DATA
+ toggleClassRec DATA
+ toggleWidgetClass DATA
+ treeClassRec DATA
+ treeWidgetClass DATA
+#ifndef __UNIXOS2__
+ vendorShellClassRec DATA
+ vendorShellWidgetClass DATA
+#endif
+ viewportClassRec DATA
+ viewportWidgetClass DATA
+ XawAsciiSave
+ XawAsciiSaveAsFile
+ XawAsciiSourceChanged
+ XawAsciiSourceFreeString
+ XawDialogAddButton
+ XawDialogGetValueString
+ XawFmt8Bit
+ XawFmtWide
+ XawFormDoLayout
+ XawInitializeWidgetSet
+ XawListChange
+ XawListHighlight
+ XawListShowCurrent
+ XawListUnhighlight
+ XawPanedAllowResize
+ XawPanedGetMinMax
+ XawPanedGetNumSub
+ XawPanedSetMinMax
+ XawPanedSetRefigureMode
+ XawScrollbarSetThumb
+ XawSimpleMenuAddGlobalActions
+ XawSimpleMenuClearActiveEntry
+ XawSimpleMenuGetActiveEntry
+ XawTextDisableRedisplay
+ XawTextDisplay
+ XawTextDisplayCaret
+ XawTextEnableRedisplay
+ XawTextGetInsertionPoint
+ XawTextGetSelectionPos
+ XawTextGetSource
+ XawTextInvalidate
+ XawTextReplace
+ XawTextSearch
+ XawTextSetInsertionPoint
+ XawTextSetSelection
+ XawTextSetSelectionArray
+ XawTextSetSource
+ XawTextSinkClearToBackground
+ XawTextSinkDisplayText
+ XawTextSinkFindDistance
+ XawTextSinkFindPosition
+ XawTextSinkGetCursorBounds
+ XawTextSinkInsertCursor
+ XawTextSinkMaxHeight
+ XawTextSinkMaxLines
+ XawTextSinkResolve
+ XawTextSinkSetTabs
+ XawTextSourceConvertSelection
+ XawTextSourceRead
+ XawTextSourceReplace
+ XawTextSourceScan
+ XawTextSourceSearch
+ XawTextSourceSetSelection
+ XawTextTopPosition
+ XawTextUnsetSelection
+ XawToggleChangeRadioGroup
+ XawToggleGetCurrent
+ XawToggleSetCurrent
+ XawToggleUnsetCurrent
+ XawTreeForceLayout
+ xawvendorShellExtClassRec
+ XawVendorShellExtResize
+ xawvendorShellExtWidgetClass
+ XawViewportSetCoordinates
+ XawViewportSetLocation
+ XawWidgetArray
+ XawWidgetCount
+#ifdef __UNIXOS2__ /* xconsole */
+ _XawTextGetSTRING
+ _XawTextShowPosition
+ XawTextGetSink
+ _XawTextBuildLineTable
+ _XawTextNeedsUpdating
+#endif
+/* $Xorg: Xaw-def.cpp,v 1.3 2000/08/17 19:45:44 cpqbld Exp $ */
+/* $XFree86$ */
diff --git a/nx-X11/lib/Xaw7/Imakefile b/nx-X11/lib/Xaw7/Imakefile
new file mode 100644
index 000000000..d6dcc2e9a
--- /dev/null
+++ b/nx-X11/lib/Xaw7/Imakefile
@@ -0,0 +1,336 @@
+XCOMM $Xorg$
+#define DoNormalLib NormalLibXaw7
+#define DoSharedLib SharedLibXaw7
+#define DoExtraLib SharedLibXaw7
+#define DoDebugLib DebugLibXaw7
+#define DoProfileLib ProfileLibXaw7
+#define HasSharedData YES
+#define LibName Xaw
+#define SoRev SOXAW7REV
+
+#if BuildXaw
+# define LibHeaders NO
+# define NoSoSymlink
+#else /* !BuildXaw */
+# define IncSubdir X11
+# define IncSubSubdir Xaw
+
+HEADERS = \
+ AllWidgets.h \
+ AsciiSink.h \
+ AsciiSinkP.h \
+ AsciiSrc.h \
+ AsciiSrcP.h \
+ AsciiText.h \
+ AsciiTextP.h \
+ Box.h \
+ BoxP.h \
+ Cardinals.h \
+ Command.h \
+ CommandP.h \
+ Dialog.h \
+ DialogP.h \
+ Form.h \
+ FormP.h \
+ Grip.h \
+ GripP.h \
+ Label.h \
+ LabelP.h \
+ List.h \
+ ListP.h \
+ MenuButton.h \
+ MenuButtoP.h \
+ MultiSrc.h \
+ MultiSrcP.h \
+ MultiSink.h \
+ MultiSinkP.h \
+ Paned.h \
+ PanedP.h \
+ Panner.h \
+ PannerP.h \
+ Porthole.h \
+ PortholeP.h \
+ Repeater.h \
+ RepeaterP.h \
+ Reports.h \
+ Scrollbar.h \
+ ScrollbarP.h \
+ Simple.h \
+ SimpleP.h \
+ SimpleMenu.h \
+ SimpleMenP.h \
+ Sme.h \
+ SmeP.h \
+ SmeBSB.h \
+ SmeBSBP.h \
+ SmeLine.h \
+ SmeLineP.h \
+ StripChart.h \
+ StripCharP.h \
+ Template.c \
+ Template.h \
+ TemplateP.h \
+ Text.h \
+ TextP.h \
+ TextSink.h \
+ TextSinkP.h \
+ TextSrc.h \
+ TextSrcP.h \
+ Tip.h \
+ TipP.h \
+ Toggle.h \
+ ToggleP.h \
+ Tree.h \
+ TreeP.h \
+ VendorEP.h \
+ Viewport.h \
+ ViewportP.h \
+ XawImP.h \
+ XawInit.h
+#endif /* !BuildXaw */
+
+#ifdef SharedXaw7Reqs
+REQUIREDLIBS = SharedXaw7Reqs
+#endif
+
+DEFINES = XawI18nDefines -DXAW7 -DPROJECT_ROOT=\"$(PROJECTROOT)\" $(VENDOR_DEFINES)
+
+ LINTLIBS = $(LINTXLIB) $(LINTXTOOL)
+
+SRCS = \
+ Actions.c \
+ AllWidgets.c \
+ AsciiSink.c \
+ AsciiSrc.c \
+ AsciiText.c \
+ Box.c \
+ Command.c \
+ Converters.c \
+ Dialog.c \
+ DisplayList.c \
+ Form.c \
+ Grip.c \
+ Label.c \
+ List.c \
+ MenuButton.c \
+ MultiSrc.c \
+ MultiSink.c \
+ OS.c \
+ Paned.c \
+ Panner.c \
+ Pixmap.c \
+ Porthole.c \
+ Repeater.c \
+ Scrollbar.c \
+ Simple.c \
+ SimpleMenu.c \
+ Sme.c \
+ SmeBSB.c \
+ SmeLine.c \
+ StripChart.c \
+ Text.c \
+ TextSink.c \
+ TextSrc.c \
+ TextAction.c \
+ TextPop.c \
+ TextTr.c \
+ Tip.c \
+ Toggle.c \
+ Tree.c \
+ Vendor.c \
+ Viewport.c \
+ XawIm.c \
+ XawInit.c \
+ XawI18n.c \
+ sharedlib.c
+
+#if SharedDataSeparation
+UNSHAREDOBJS = AllWidgets.o sharedlib.o
+#endif
+
+OBJS = \
+ Actions.o \
+ AllWidgets.o \
+ AsciiSink.o \
+ AsciiSrc.o \
+ AsciiText.o \
+ Box.o \
+ Command.o \
+ Converters.o \
+ Dialog.o \
+ DisplayList.o \
+ Form.o \
+ Grip.o \
+ Label.o \
+ List.o \
+ MenuButton.o \
+ MultiSrc.o \
+ MultiSink.o \
+ OS.o \
+ Paned.o \
+ Panner.o \
+ Pixmap.o \
+ Porthole.o \
+ Repeater.o \
+ Scrollbar.o \
+ Simple.o \
+ SimpleMenu.o \
+ Sme.o \
+ SmeBSB.o \
+ SmeLine.o \
+ StripChart.o \
+ Text.o \
+ TextSink.o \
+ TextSrc.o \
+ TextAction.o \
+ TextPop.o \
+ TextTr.o \
+ Tip.o \
+ Toggle.o \
+ Tree.o \
+ Vendor.o \
+ Viewport.o \
+ XawIm.o \
+ XawI18n.o \
+ XawInit.o
+
+#include <Library.tmpl>
+
+#if DoSharedLib && SharedDataSeparation
+SpecialCObjectRule(sharedlib,NullParameter,$(SHLIBDEF))
+#endif
+
+#if !BuildXaw
+MANSUFFIX = $(LIBMANSUFFIX)
+InstallManPage(Xaw,$(LIBMANDIR))
+#endif
+
+#if SharedDataSeparation
+UNSHAREDOBJS = AllWidgets.o sharedlib.o
+#endif
+
+LinkSourceFile(Actions.c,$(AWIDGETSRC))
+LinkSourceFile(AllWidgets.c,$(AWIDGETSRC))
+LinkSourceFile(AsciiSink.c,$(AWIDGETSRC))
+LinkSourceFile(AsciiSrc.c,$(AWIDGETSRC))
+LinkSourceFile(AsciiText.c,$(AWIDGETSRC))
+LinkSourceFile(Box.c,$(AWIDGETSRC))
+LinkSourceFile(Command.c,$(AWIDGETSRC))
+LinkSourceFile(Converters.c,$(AWIDGETSRC))
+LinkSourceFile(Dialog.c,$(AWIDGETSRC))
+LinkSourceFile(DisplayList.c,$(AWIDGETSRC))
+LinkSourceFile(Form.c,$(AWIDGETSRC))
+LinkSourceFile(Grip.c,$(AWIDGETSRC))
+LinkSourceFile(Label.c,$(AWIDGETSRC))
+LinkSourceFile(List.c,$(AWIDGETSRC))
+LinkSourceFile(MenuButton.c,$(AWIDGETSRC))
+LinkSourceFile(MultiSrc.c,$(AWIDGETSRC))
+LinkSourceFile(MultiSink.c,$(AWIDGETSRC))
+LinkSourceFile(OS.c,$(AWIDGETSRC))
+LinkSourceFile(Paned.c,$(AWIDGETSRC))
+LinkSourceFile(Panner.c,$(AWIDGETSRC))
+LinkSourceFile(Pixmap.c,$(AWIDGETSRC))
+LinkSourceFile(Porthole.c,$(AWIDGETSRC))
+LinkSourceFile(Repeater.c,$(AWIDGETSRC))
+LinkSourceFile(Scrollbar.c,$(AWIDGETSRC))
+LinkSourceFile(Simple.c,$(AWIDGETSRC))
+LinkSourceFile(SimpleMenu.c,$(AWIDGETSRC))
+LinkSourceFile(Sme.c,$(AWIDGETSRC))
+LinkSourceFile(SmeBSB.c,$(AWIDGETSRC))
+LinkSourceFile(SmeLine.c,$(AWIDGETSRC))
+LinkSourceFile(StripChart.c,$(AWIDGETSRC))
+LinkSourceFile(Text.c,$(AWIDGETSRC))
+LinkSourceFile(TextSink.c,$(AWIDGETSRC))
+LinkSourceFile(TextSrc.c,$(AWIDGETSRC))
+LinkSourceFile(TextAction.c,$(AWIDGETSRC))
+LinkSourceFile(TextPop.c,$(AWIDGETSRC))
+LinkSourceFile(TextTr.c,$(AWIDGETSRC))
+LinkSourceFile(Tip.c,$(AWIDGETSRC))
+LinkSourceFile(Toggle.c,$(AWIDGETSRC))
+LinkSourceFile(Tree.c,$(AWIDGETSRC))
+LinkSourceFile(Vendor.c,$(AWIDGETSRC))
+LinkSourceFile(Viewport.c,$(AWIDGETSRC))
+LinkSourceFile(XawIm.c,$(AWIDGETSRC))
+LinkSourceFile(XawInit.c,$(AWIDGETSRC))
+LinkSourceFile(XawI18n.c,$(AWIDGETSRC))
+LinkSourceFile(sharedlib.c,$(AWIDGETSRC))
+
+LinkSourceFile(AllWidgets.h,$(AWIDGETSRC))
+LinkSourceFile(AsciiSink.h,$(AWIDGETSRC))
+LinkSourceFile(AsciiSinkP.h,$(AWIDGETSRC))
+LinkSourceFile(AsciiSrc.h,$(AWIDGETSRC))
+LinkSourceFile(AsciiSrcP.h,$(AWIDGETSRC))
+LinkSourceFile(AsciiText.h,$(AWIDGETSRC))
+LinkSourceFile(AsciiTextP.h,$(AWIDGETSRC))
+LinkSourceFile(Box.h,$(AWIDGETSRC))
+LinkSourceFile(BoxP.h,$(AWIDGETSRC))
+LinkSourceFile(Cardinals.h,$(AWIDGETSRC))
+LinkSourceFile(Command.h,$(AWIDGETSRC))
+LinkSourceFile(CommandP.h,$(AWIDGETSRC))
+LinkSourceFile(Dialog.h,$(AWIDGETSRC))
+LinkSourceFile(DialogP.h,$(AWIDGETSRC))
+LinkSourceFile(Form.h,$(AWIDGETSRC))
+LinkSourceFile(FormP.h,$(AWIDGETSRC))
+LinkSourceFile(Grip.h,$(AWIDGETSRC))
+LinkSourceFile(GripP.h,$(AWIDGETSRC))
+LinkSourceFile(Label.h,$(AWIDGETSRC))
+LinkSourceFile(LabelP.h,$(AWIDGETSRC))
+LinkSourceFile(List.h,$(AWIDGETSRC))
+LinkSourceFile(ListP.h,$(AWIDGETSRC))
+LinkSourceFile(MenuButton.h,$(AWIDGETSRC))
+LinkSourceFile(MenuButtoP.h,$(AWIDGETSRC))
+LinkSourceFile(MultiSrc.h,$(AWIDGETSRC))
+LinkSourceFile(MultiSrcP.h,$(AWIDGETSRC))
+LinkSourceFile(MultiSink.h,$(AWIDGETSRC))
+LinkSourceFile(MultiSinkP.h,$(AWIDGETSRC))
+LinkSourceFile(Paned.h,$(AWIDGETSRC))
+LinkSourceFile(PanedP.h,$(AWIDGETSRC))
+LinkSourceFile(Panner.h,$(AWIDGETSRC))
+LinkSourceFile(PannerP.h,$(AWIDGETSRC))
+LinkSourceFile(Porthole.h,$(AWIDGETSRC))
+LinkSourceFile(PortholeP.h,$(AWIDGETSRC))
+LinkSourceFile(Private.h,$(AWIDGETSRC))
+LinkSourceFile(Repeater.h,$(AWIDGETSRC))
+LinkSourceFile(RepeaterP.h,$(AWIDGETSRC))
+LinkSourceFile(Reports.h,$(AWIDGETSRC))
+LinkSourceFile(Scrollbar.h,$(AWIDGETSRC))
+LinkSourceFile(ScrollbarP.h,$(AWIDGETSRC))
+LinkSourceFile(Simple.h,$(AWIDGETSRC))
+LinkSourceFile(SimpleP.h,$(AWIDGETSRC))
+LinkSourceFile(SimpleMenu.h,$(AWIDGETSRC))
+LinkSourceFile(SimpleMenP.h,$(AWIDGETSRC))
+LinkSourceFile(Sme.h,$(AWIDGETSRC))
+LinkSourceFile(SmeP.h,$(AWIDGETSRC))
+LinkSourceFile(SmeBSB.h,$(AWIDGETSRC))
+LinkSourceFile(SmeBSBP.h,$(AWIDGETSRC))
+LinkSourceFile(SmeLine.h,$(AWIDGETSRC))
+LinkSourceFile(SmeLineP.h,$(AWIDGETSRC))
+LinkSourceFile(StripChart.h,$(AWIDGETSRC))
+LinkSourceFile(StripCharP.h,$(AWIDGETSRC))
+LinkSourceFile(Template.c,$(AWIDGETSRC))
+LinkSourceFile(Template.h,$(AWIDGETSRC))
+LinkSourceFile(TemplateP.h,$(AWIDGETSRC))
+LinkSourceFile(Text.h,$(AWIDGETSRC))
+LinkSourceFile(TextP.h,$(AWIDGETSRC))
+LinkSourceFile(TextSink.h,$(AWIDGETSRC))
+LinkSourceFile(TextSinkP.h,$(AWIDGETSRC))
+LinkSourceFile(TextSrc.h,$(AWIDGETSRC))
+LinkSourceFile(TextSrcP.h,$(AWIDGETSRC))
+LinkSourceFile(Tip.h,$(AWIDGETSRC))
+LinkSourceFile(TipP.h,$(AWIDGETSRC))
+LinkSourceFile(Toggle.h,$(AWIDGETSRC))
+LinkSourceFile(ToggleP.h,$(AWIDGETSRC))
+LinkSourceFile(Tree.h,$(AWIDGETSRC))
+LinkSourceFile(TreeP.h,$(AWIDGETSRC))
+LinkSourceFile(VendorEP.h,$(AWIDGETSRC))
+LinkSourceFile(Viewport.h,$(AWIDGETSRC))
+LinkSourceFile(ViewportP.h,$(AWIDGETSRC))
+LinkSourceFile(XawI18n.h,$(AWIDGETSRC))
+LinkSourceFile(XawImP.h,$(AWIDGETSRC))
+LinkSourceFile(XawInit.h,$(AWIDGETSRC))
+
+#if !BuildXaw
+LinkSourceFile(Xaw.man,$(AWIDGETSRC))
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/Xaw7/Xaw-def.cpp b/nx-X11/lib/Xaw7/Xaw-def.cpp
new file mode 100644
index 000000000..5b504d4fa
--- /dev/null
+++ b/nx-X11/lib/Xaw7/Xaw-def.cpp
@@ -0,0 +1,156 @@
+LIBRARY Xaw
+VERSION LIBRARY_VERSION
+EXPORTS
+ asciiSinkClassRec DATA
+ asciiSinkObjectClass DATA
+ asciiSrcClassRec DATA
+ asciiSrcObjectClass DATA
+ asciiTextClassRec DATA
+ asciiTextWidgetClass DATA
+ boxClassRec DATA
+ boxWidgetClass DATA
+ commandClassRec DATA
+ commandWidgetClass DATA
+ dialogClassRec DATA
+ dialogWidgetClass DATA
+ FMT8BIT DATA
+ formClassRec DATA
+ formWidgetClass DATA
+ gripClassRec DATA
+ gripWidgetClass DATA
+ labelClassRec DATA
+ labelWidgetClass DATA
+ listClassRec DATA
+ listWidgetClass DATA
+ menuButtonClassRec DATA
+ menuButtonWidgetClass DATA
+ multiSinkClassRec DATA
+ multiSinkObjectClass DATA
+ multiSrcClassRec DATA
+ multiSrcObjectClass DATA
+ panedClassRec DATA
+ panedWidgetClass DATA
+ pannerClassRec DATA
+ pannerWidgetClass DATA
+ portholeClassRec DATA
+ portholeWidgetClass DATA
+ repeaterClassRec DATA
+ repeaterWidgetClass DATA
+ scrollbarClassRec DATA
+ scrollbarWidgetClass DATA
+ simpleClassRec DATA
+ simpleMenuClassRec DATA
+ simpleMenuWidgetClass DATA
+ simpleWidgetClass DATA
+ smeBSBClassRec DATA
+ smeBSBObjectClass DATA
+ smeClassRec DATA
+ smeLineClassRec DATA
+ smeLineObjectClass DATA
+ smeObjectClass DATA
+ stripChartClassRec DATA
+ stripChartWidgetClass DATA
+ textClassRec DATA
+ textSinkClassRec DATA
+ textSinkObjectClass DATA
+ textSrcClassRec DATA
+ textSrcObjectClass DATA
+ textWidgetClass DATA
+ toggleClassRec DATA
+ toggleWidgetClass DATA
+ treeClassRec DATA
+ treeWidgetClass DATA
+#ifndef __UNIXOS2__
+ vendorShellClassRec DATA
+ vendorShellWidgetClass DATA
+#endif
+ viewportClassRec DATA
+ viewportWidgetClass DATA
+ XawAsciiSave
+ XawAsciiSaveAsFile
+ XawAsciiSourceChanged
+ XawAsciiSourceFreeString
+ XawDialogAddButton
+ XawDialogGetValueString
+ XawFmt8Bit
+ XawFmtWide
+ XawFormDoLayout
+ XawInitializeWidgetSet
+ XawListChange
+ XawListHighlight
+ XawListShowCurrent
+ XawListUnhighlight
+ XawPanedAllowResize
+ XawPanedGetMinMax
+ XawPanedGetNumSub
+ XawPanedSetMinMax
+ XawPanedSetRefigureMode
+ XawScrollbarSetThumb
+ XawSimpleMenuAddGlobalActions
+ XawSimpleMenuClearActiveEntry
+ XawSimpleMenuGetActiveEntry
+ XawTextDisableRedisplay
+ XawTextDisplay
+ XawTextDisplayCaret
+ XawTextEnableRedisplay
+ XawTextGetInsertionPoint
+ XawTextGetSelectionPos
+ XawTextGetSource
+ XawTextInvalidate
+ XawTextReplace
+ XawTextSearch
+ XawTextSetInsertionPoint
+ XawTextSetSelection
+ XawTextSetSelectionArray
+ XawTextSetSource
+ XawTextSinkClearToBackground
+ XawTextSinkDisplayText
+ XawTextSinkFindDistance
+ XawTextSinkFindPosition
+ XawTextSinkGetCursorBounds
+ XawTextSinkInsertCursor
+ XawTextSinkMaxHeight
+ XawTextSinkMaxLines
+ XawTextSinkResolve
+ XawTextSinkSetTabs
+ XawTextSourceConvertSelection
+ XawTextSourceRead
+ XawTextSourceReplace
+ XawTextSourceScan
+ XawTextSourceSearch
+ XawTextSourceSetSelection
+ XawTextTopPosition
+ XawTextUnsetSelection
+ XawToggleChangeRadioGroup
+ XawToggleGetCurrent
+ XawToggleSetCurrent
+ XawToggleUnsetCurrent
+ XawTreeForceLayout
+ xawvendorShellExtClassRec
+ XawVendorShellExtResize
+ xawvendorShellExtWidgetClass
+ XawViewportSetCoordinates
+ XawViewportSetLocation
+ XawWidgetArray
+ XawWidgetCount
+#ifdef __UNIXOS2__ /* xconsole */
+ _XawTextGetSTRING
+ XawTextSourceAddEntity
+ XawTextSourceAnchorAndEntity
+ XawTextSourceNextAnchor
+ XawTextSourcePrevAnchor
+ XawTextSourceFindAnchor
+ _XawTextShowPosition
+ _XawTextSrcUndo
+ XawTextSinkConvertPropertyList
+ XawTextGetSink
+ _XawTextBuildLineTable
+ XawTextSourceClearEntities
+ _XawTextNeedsUpdating
+ XawTextSinkCopyProperty
+ XawTextSinkGetProperty
+ XawTextSinkCombineProperty
+ XawTextSinkAddProperty
+ XawTextLastPosition
+#endif
+/* $Xorg$ */
diff --git a/nx-X11/lib/Xbsd/Berklib.c b/nx-X11/lib/Xbsd/Berklib.c
new file mode 100644
index 000000000..0e36c2e61
--- /dev/null
+++ b/nx-X11/lib/Xbsd/Berklib.c
@@ -0,0 +1,331 @@
+/* $Xorg: Berklib.c,v 1.4 2001/02/09 02:03:48 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.
+
+*/
+/* $XFree86: xc/lib/Xbsd/Berklib.c,v 3.8 2001/07/25 15:04:49 dawes Exp $ */
+
+
+/*
+ * These are routines found in BSD but not on all other systems. The core
+ * MIT distribution does not use them except for ffs in the server, unless
+ * the system is seriously deficient. You should enable only the ones that
+ * you need for your system. Use Xfuncs.h in clients to avoid using the
+ * slow versions of bcopy, bcmp, and bzero provided here.
+ */
+
+#include <sys/types.h>
+
+#ifdef hpux
+#define WANT_RANDOM
+#define WANT_QUE
+#endif
+
+#ifdef macII
+/* silly bcopy in A/UX does not handle overlaps */
+#define WANT_BFUNCS
+#define WANT_MEMMOVE
+#define NO_BZERO
+#define WANT_RANDOM
+#endif
+
+#if defined(SVR4) && !defined(__UNIXWARE__)
+#define WANT_BFUNCS
+#define WANT_FFS
+#define WANT_RANDOM
+#endif
+
+#ifdef hcx
+#define WANT_FFS
+#endif
+
+#ifdef SYSV
+#ifdef i386
+#if !defined(__SCO__) && !defined(__UNIXWARE__)
+#define WANT_FFS
+#define WANT_MEMMOVE
+#endif
+#endif
+#endif
+
+#ifdef _SEQUENT_
+#define WANT_GTOD
+#define WANT_FFS
+#endif /* _SEQUENT_ */
+
+/* you should use Xfuncs.h in code instead of relying on Berklib */
+#ifdef WANT_BFUNCS
+
+#include <X11/Xosdefs.h>
+
+#if (__STDC__) || defined(SVR4) || defined(hpux)
+
+#include <string.h>
+
+void bcopy (b1, b2, length)
+ register char *b1, *b2;
+ register int length;
+{
+ memmove(b2, b1, (size_t)length);
+}
+
+int bcmp (b1, b2, length)
+ register char *b1, *b2;
+ register int length;
+{
+ return memcmp(b1, b2, (size_t)length);
+}
+
+void bzero (b, length)
+ register char *b;
+ register int length;
+{
+ memset(b, 0, (size_t)length);
+}
+
+#else
+
+void bcopy (b1, b2, length)
+ register char *b1, *b2;
+ register int length;
+{
+ if (b1 < b2) {
+ b2 += length;
+ b1 += length;
+ while (length--)
+ *--b2 = *--b1;
+ } else {
+ while (length--)
+ *b2++ = *b1++;
+ }
+}
+
+#if defined(SYSV)
+
+#include <memory.h>
+
+int bcmp (b1, b2, length)
+ register char *b1, *b2;
+ register int length;
+{
+ return memcmp(b1, b2, length);
+}
+
+#ifndef NO_BZERO
+
+bzero (b, length)
+ register char *b;
+ register int length;
+{
+ memset(b, 0, length);
+}
+
+#endif
+
+#else
+
+int bcmp (b1, b2, length)
+ register char *b1, *b2;
+ register int length;
+{
+ while (length--) {
+ if (*b1++ != *b2++) return 1;
+ }
+ return 0;
+}
+
+void bzero (b, length)
+ register char *b;
+ register int length;
+{
+ while (length--)
+ *b++ = '\0';
+}
+
+#endif
+#endif
+#endif /* WANT_BFUNCS */
+
+#ifdef WANT_MEMMOVE
+char *memmove (b1, b2, length)
+ register char *b1, *b2;
+ register int length;
+{
+ char *sb1 = b1;
+
+ if (b2 < b1) {
+ b1 += length;
+ b2 += length;
+ while (length--)
+ *--b1 = *--b2;
+ } else {
+ while (length--)
+ *b1++ = *b2++;
+ }
+ return sb1;
+}
+#endif
+
+#ifdef WANT_FFS
+int
+ffs(mask)
+unsigned int mask;
+{
+ register i;
+
+ if ( ! mask ) return 0;
+ i = 1;
+ while (! (mask & 1)) {
+ i++;
+ mask = mask >> 1;
+ }
+ return i;
+}
+#endif
+
+#ifdef WANT_RANDOM
+#if defined(SYSV) || defined(SVR4) || defined(hpux)
+
+long lrand48();
+
+long random()
+{
+ return (lrand48());
+}
+
+void srandom(seed)
+ int seed;
+{
+ srand48(seed);
+}
+
+#else
+
+long random()
+{
+ return (rand());
+}
+
+void srandom(seed)
+ int seed;
+{
+ srand(seed);
+}
+
+#endif
+#endif /* WANT_RANDOM */
+
+/*
+ * insque, remque - insert/remove element from a queue
+ *
+ * DESCRIPTION
+ * Insque and remque manipulate queues built from doubly linked
+ * lists. Each element in the queue must in the form of
+ * ``struct qelem''. Insque inserts elem in a queue immedi-
+ * ately after pred; remque removes an entry elem from a queue.
+ *
+ * SEE ALSO
+ * ``VAX Architecture Handbook'', pp. 228-235.
+ */
+
+#ifdef WANT_QUE
+struct qelem {
+ struct qelem *q_forw;
+ struct qelem *q_back;
+ char *q_data;
+ };
+
+insque(elem, pred)
+register struct qelem *elem, *pred;
+{
+ register struct qelem *q;
+ /* Insert locking code here */
+ if ( elem->q_forw = q = (pred ? pred->q_forw : pred) )
+ q->q_back = elem;
+ if ( elem->q_back = pred )
+ pred->q_forw = elem;
+ /* Insert unlocking code here */
+}
+
+remque(elem)
+register struct qelem *elem;
+{
+ register struct qelem *q;
+ if ( ! elem ) return;
+ /* Insert locking code here */
+
+ if ( q = elem->q_back ) q->q_forw = elem->q_forw;
+ if ( q = elem->q_forw ) q->q_back = elem->q_back;
+
+ /* insert unlocking code here */
+}
+#endif /* WANT_QUE */
+
+/*
+ * gettimeofday emulation
+ * Caution -- emulation is incomplete
+ * - has only second, not microsecond, resolution.
+ * - does not return timezone info.
+ */
+
+#ifdef WANT_GTOD
+
+#ifdef _SEQUENT_
+#include <X11/Xos.h>
+#endif /* _SEQUENT_ */
+
+int gettimeofday (tvp, tzp)
+ struct timeval *tvp;
+ struct timezone *tzp;
+{
+#ifdef _SEQUENT_
+ /*
+ * Sequent has microsecond resolution. Need to link with -lseq
+ */
+ get_process_stats (tvp, -1, NULL, NULL);
+#ifndef SVR4
+ if (tzp)
+ {
+ tzset ();
+ tzp->tz_minuteswest = timezone / 60;
+ tzp->tz_dsttime = daylight;
+ }
+#endif /* SVR4 */
+ return (0);
+#else /* _SEQUENT_ */
+ time (&tvp->tv_sec);
+ tvp->tv_usec = 0L;
+
+#ifndef SVR4
+ if (tzp) {
+ fprintf( stderr,
+ "Warning: gettimeofday() emulation does not return timezone\n"
+ );
+ }
+#endif /* SVR4 */
+#endif /* _SEQUENT_ */
+}
+#endif /* WANT_GTOD */
diff --git a/nx-X11/lib/Xbsd/Imakefile b/nx-X11/lib/Xbsd/Imakefile
new file mode 100644
index 000000000..19b7c2b8c
--- /dev/null
+++ b/nx-X11/lib/Xbsd/Imakefile
@@ -0,0 +1,16 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:45:46 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/Xbsd/Imakefile,v 3.2 1999/04/17 09:08:11 dawes Exp $
+
+SRCS = Berklib.c
+OBJS = Berklib.o
+
+#undef _LinkBuildLibrary
+#define _LinkBuildLibrary(lib) LinkBuildLibrary(lib)
+NormalLibraryTarget(Xbsd,$(OBJS))
+InstallLibrary(Xbsd,$(USRLIBDIR))
+
+DependTarget()
diff --git a/nx-X11/lib/Xcomposite/.cvsignore b/nx-X11/lib/Xcomposite/.cvsignore
new file mode 100644
index 000000000..d3b5c438e
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/.cvsignore
@@ -0,0 +1,24 @@
+.deps
+.libs
+Makefile
+Makefile.in
+Xcomposite.lo
+aclocal.m4
+autom4te.cache
+config.guess
+config.h
+config.h.in
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+libXcomposite.la
+libtool
+ltmain.sh
+missing
+mkinstalldirs
+stamp-h1
+xcomposite.pc
+
diff --git a/nx-X11/lib/Xcomposite/AUTHORS b/nx-X11/lib/Xcomposite/AUTHORS
new file mode 100644
index 000000000..8e18f9b42
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/AUTHORS
@@ -0,0 +1 @@
+Keith Packard, HP
diff --git a/nx-X11/lib/Xcomposite/COPYING b/nx-X11/lib/Xcomposite/COPYING
new file mode 100644
index 000000000..e85d981e7
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/COPYING
@@ -0,0 +1,22 @@
+$Id: COPYING,v 1.1 2004/07/31 05:50:39 anholt Exp $
+
+Copyright © 2001,2003 Keith Packard
+
+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 of Keith Packard not be used in
+advertising or publicity pertaining to distribution of the software without
+specific, written prior permission. Keith Packard makes no
+representations about the suitability of this software for any purpose. It
+is provided "as is" without express or implied warranty.
+
+KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL KEITH PACKARD 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.
+
diff --git a/nx-X11/lib/Xcomposite/ChangeLog b/nx-X11/lib/Xcomposite/ChangeLog
new file mode 100644
index 000000000..f70ce6605
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/ChangeLog
@@ -0,0 +1,19 @@
+2004-07-08 Keith Packard <keithp@keithp.com>
+
+ * Makefile.am:
+ * Xcomposite.c: (XCompositeVersion), (XCompositeNameWindowPixmap):
+ * Xcomposite.h:
+ * configure.ac:
+ Add library API for Composite 0.2 changes
+ Add XCompositeVersion to get the run-time library version number
+ Fix package version number in configure.ac and Xcomposite.h
+
+2004-02-03 Jim Gettys <jg@handhelds.org>
+
+ * AUTHORS: Add authors to AUTHORS file
+
+2004-01-15 Daniel Stone <daniel@fooishbar.org>
+ * Tag release 1.0 for first freedesktop.org clientside lib release.
+
+2004-01-15 Harold L Hunt II <huntharo@msu.edu>
+ * Makefile.am: Pass -no-undefined to libtool via LDFLAGS.
diff --git a/nx-X11/lib/Xcomposite/INSTALL b/nx-X11/lib/Xcomposite/INSTALL
new file mode 100644
index 000000000..25a014e2e
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/INSTALL
@@ -0,0 +1,8 @@
+Xcomposite is built with the traditional configure script:
+
+ $ ./configure --prefix=/usr/X11R6
+
+This should generate valid Makefiles, then:
+
+ $ make
+ $ make install
diff --git a/nx-X11/lib/Xcomposite/Imakefile b/nx-X11/lib/Xcomposite/Imakefile
new file mode 100644
index 000000000..053df3d70
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/Imakefile
@@ -0,0 +1,68 @@
+XCOMM $XdotOrg: xc/lib/Xcomposite/Imakefile,v 1.1 2004/07/31 05:50:39 anholt Exp $
+
+#ifndef NormalLibXcomposite
+#define NormalLibXcomposite YES
+SOXCOMPOSITEREV=1.0.0
+#endif
+
+#ifndef SharedLibXcomposite
+#define SharedLibXcomposite YES
+#endif
+
+#define DoNormalLib NormalLibXcomposite
+#define DoSharedLib SharedLibXcomposite
+#define DoDebugLib DebugLibXcomposite
+#define DoProfileLib ProfileLibXcomposite
+
+#define LibName Xcomposite
+#define SoRev SOXCOMPOSITEREV
+#define IncSubdir X11
+#define IncSubSubdir extensions
+
+#include <Threads.tmpl>
+
+#ifdef SharedXcompositeReqs
+REQUIREDLIBS = SharedXcompositeReqs
+#endif
+
+XCOMPOSITE_VERSION=1.0.0
+
+X_LIBS=-L$(SHLIBDIR) $(XONLYLIB)
+X_CFLAGS=-I$(INCROOT) $(THREADS_DEFINES)
+XCOMPOSITE_LIBS = $(XFIXESLIB) $(XDAMAGELIB)
+XCOMPOSITE_CFLAGS =
+
+RPATH_CFLAG = HardCodeLibdirFlag
+
+SRCS = Xcomposite.c
+
+OBJS = Xcomposite.o
+
+HEADERS = Xcomposite.h
+
+SUBSTVARS=prefix="$(PROJECTROOT)" \
+ exec_prefix="$(BINDIR)" \
+ libdir="$(USRLIBDIR)" \
+ hardcode_libdir_flag_spec="$(RPATH_CFLAG)" \
+ includedir="$(INCROOT)" \
+ X_LIBS="$(X_LIBS)" \
+ X_CFLAGS="$(X_CFLAGS)" \
+ XCOMPOSITE_LIBS="$(XCOMPOSITE_LIBS)" \
+ XCOMPOSITE_CFLAGS="$(XCOMPOSITE_CFLAGS)" \
+ VERSION="$(XCOMPOSITE_VERSION)"
+
+#include <Library.tmpl>
+
+DependTarget()
+
+all:: xcomposite.pc
+
+xcomposite.pc: xcomposite.pc.in
+ RemoveFile($@)
+ sh ../Xcursor/config-subst $(SUBSTVARS) < xcomposite.pc.in > $@
+
+InstallNonExecFile(xcomposite.pc,$(USRLIBDIR)/pkgconfig)
+
+clean::
+ RemoveFile(xcomposite.pc)
+
diff --git a/nx-X11/lib/Xcomposite/Makefile.am b/nx-X11/lib/Xcomposite/Makefile.am
new file mode 100644
index 000000000..da962e802
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/Makefile.am
@@ -0,0 +1,52 @@
+#
+# $Id: Makefile.am,v 1.1 2004/07/31 05:50:39 anholt Exp $
+#
+# Copyright © 2003 Keith Packard, Noah Levitt
+#
+# 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 of Keith Packard not be used in
+# advertising or publicity pertaining to distribution of the software without
+# specific, written prior permission. Keith Packard makes no
+# representations about the suitability of this software for any purpose. It
+# is provided "as is" without express or implied warranty.
+#
+# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+# EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+# CONSEQUENTIAL COMPOSITES OR ANY COMPOSITES 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.
+
+AM_CFLAGS = $(XCOMPOSITE_CFLAGS) $(X_CFLAGS)
+
+lib_LTLIBRARIES = libXcomposite.la
+
+libXcomposite_la_SOURCES = \
+ xcompositeint.h \
+ Xcomposite.c
+
+libXcomposite_la_LIBADD = $(XCOMPOSITE_LIBS) $(X_LIBS)
+
+#
+# Library version info. Check the libtool docs for
+# instructions on when and how to change this value
+#
+# bump when the ABI changes
+XCOMPOSITE_CURRENT=2
+# bump for non-ABI changes, reset to zero when CURRENT changes
+XCOMPOSITE_REVISION=0
+# bump when the ABI changes in backward-compatible fashion
+XCOMPOSITE_AGE=1
+libXcomposite_la_LDFLAGS = -version-info ${XCOMPOSITE_CURRENT}:${XCOMPOSITE_REVISION}:${XCOMPOSITE_AGE} -no-undefined
+
+libXcompositeincludedir = $(includedir)/X11/extensions
+libXcompositeinclude_HEADERS = Xcomposite.h
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = xcomposite.pc
+
+EXTRA_DIST = xcomposite.pc.in autogen.sh
diff --git a/nx-X11/lib/Xcomposite/NEWS b/nx-X11/lib/Xcomposite/NEWS
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/NEWS
diff --git a/nx-X11/lib/Xcomposite/README b/nx-X11/lib/Xcomposite/README
new file mode 100644
index 000000000..9968c6bdf
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/README
@@ -0,0 +1,10 @@
+ RandR
+ X RandR Extension
+ Version 1.0
+ 2002-10-4
+
+This package contains header files and documentation for the X RandR
+extension. Library and server implementations are separate.
+
+Keith Packard
+keithp@keithp.com
diff --git a/nx-X11/lib/Xcomposite/Xcomposite.c b/nx-X11/lib/Xcomposite/Xcomposite.c
new file mode 100644
index 000000000..cd10f8ed6
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/Xcomposite.c
@@ -0,0 +1,333 @@
+/*
+ * $Id: Xcomposite.c,v 1.2 2005/07/03 07:00:56 daniels Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xcompositeint.h"
+
+XCompositeExtInfo XCompositeExtensionInfo;
+
+const char XCompositeExtensionName[] = COMPOSITE_NAME;
+
+/*
+ * XCompositeExtRemoveDisplay - remove the indicated display from the
+ * extension object. (Replaces XextRemoveDisplay.)
+ */
+static int
+XCompositeExtRemoveDisplay (XCompositeExtInfo *extinfo, Display *dpy)
+{
+ XCompositeExtDisplayInfo *info, *prev;
+
+ /*
+ * locate this display and its back link so that it can be removed
+ */
+ _XLockMutex(_Xglobal_lock);
+ prev = NULL;
+ for (info = extinfo->head; info; info = info->next) {
+ if (info->display == dpy) break;
+ prev = info;
+ }
+ if (!info) {
+ _XUnlockMutex(_Xglobal_lock);
+ return 0; /* hmm, actually an error */
+ }
+
+ /*
+ * remove the display from the list; handles going to zero
+ */
+ if (prev)
+ prev->next = info->next;
+ else
+ extinfo->head = info->next;
+
+ extinfo->ndisplays--;
+ if (info == extinfo->cur) extinfo->cur = NULL; /* flush cache */
+ _XUnlockMutex(_Xglobal_lock);
+
+ Xfree ((char *) info);
+ return 1;
+}
+
+static int
+XCompositeCloseDisplay (Display *dpy, XExtCodes *codes)
+{
+ return XCompositeExtRemoveDisplay (&XCompositeExtensionInfo, dpy);
+}
+
+/*
+ * XCompositeExtAddDisplay - add a display to this extension. (Replaces
+ * XextAddDisplay)
+ */
+static XCompositeExtDisplayInfo *
+XCompositeExtAddDisplay (XCompositeExtInfo *extinfo,
+ Display *dpy,
+ const char *ext_name)
+{
+ XCompositeExtDisplayInfo *info;
+ int ev;
+
+ info = (XCompositeExtDisplayInfo *) Xmalloc (sizeof (XCompositeExtDisplayInfo));
+ if (!info) return NULL;
+ info->display = dpy;
+
+ info->codes = XInitExtension (dpy, ext_name);
+
+ /*
+ * if the server has the extension, then we can initialize the
+ * appropriate function vectors
+ */
+ if (info->codes) {
+ xCompositeQueryVersionReply rep;
+ xCompositeQueryVersionReq *req;
+ XESetCloseDisplay (dpy, info->codes->extension,
+ XCompositeCloseDisplay);
+ /*
+ * Get the version info
+ */
+ LockDisplay (dpy);
+ GetReq (CompositeQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->compositeReqType = X_CompositeQueryVersion;
+ req->majorVersion = COMPOSITE_MAJOR;
+ req->minorVersion = COMPOSITE_MINOR;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue))
+ {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ info->major_version = rep.majorVersion;
+ info->minor_version = rep.minorVersion;
+ UnlockDisplay (dpy);
+ } else {
+ /* The server doesn't have this extension.
+ * Use a private Xlib-internal extension to hang the close_display
+ * hook on so that the "cache" (extinfo->cur) is properly cleaned.
+ * (XBUG 7955)
+ */
+ XExtCodes *codes = XAddExtension(dpy);
+ if (!codes) {
+ XFree(info);
+ return NULL;
+ }
+ XESetCloseDisplay (dpy, codes->extension, XCompositeCloseDisplay);
+ }
+
+ /*
+ * now, chain it onto the list
+ */
+ _XLockMutex(_Xglobal_lock);
+ info->next = extinfo->head;
+ extinfo->head = info;
+ extinfo->cur = info;
+ extinfo->ndisplays++;
+ _XUnlockMutex(_Xglobal_lock);
+ return info;
+}
+
+/*
+ * XCompositeExtFindDisplay - look for a display in this extension; keeps a
+ * cache of the most-recently used for efficiency. (Replaces
+ * XextFindDisplay.)
+ */
+static XCompositeExtDisplayInfo *
+XCompositeExtFindDisplay (XCompositeExtInfo *extinfo,
+ Display *dpy)
+{
+ XCompositeExtDisplayInfo *info;
+
+ /*
+ * see if this was the most recently accessed display
+ */
+ if ((info = extinfo->cur) && info->display == dpy)
+ return info;
+
+ /*
+ * look for display in list
+ */
+ _XLockMutex(_Xglobal_lock);
+ for (info = extinfo->head; info; info = info->next) {
+ if (info->display == dpy) {
+ extinfo->cur = info; /* cache most recently used */
+ _XUnlockMutex(_Xglobal_lock);
+ return info;
+ }
+ }
+ _XUnlockMutex(_Xglobal_lock);
+
+ return NULL;
+}
+
+XCompositeExtDisplayInfo *
+XCompositeFindDisplay (Display *dpy)
+{
+ XCompositeExtDisplayInfo *info;
+
+ info = XCompositeExtFindDisplay (&XCompositeExtensionInfo, dpy);
+ if (!info)
+ info = XCompositeExtAddDisplay (&XCompositeExtensionInfo, dpy,
+ XCompositeExtensionName);
+ return info;
+}
+
+
+Bool
+XCompositeQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XCompositeExtDisplayInfo *info = XCompositeFindDisplay (dpy);
+
+ if (XCompositeHasExtension(info))
+ {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ }
+ else
+ return False;
+}
+
+Status
+XCompositeQueryVersion (Display *dpy,
+ int *major_versionp,
+ int *minor_versionp)
+{
+ XCompositeExtDisplayInfo *info = XCompositeFindDisplay (dpy);
+
+ XCompositeCheckExtension (dpy, info, 0);
+ *major_versionp = info->major_version;
+ *minor_versionp = info->minor_version;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
+int
+XCompositeVersion (void)
+{
+ return XCOMPOSITE_VERSION;
+}
+
+void
+XCompositeRedirectWindow (Display *dpy, Window window, int update)
+{
+ XCompositeExtDisplayInfo *info = XCompositeFindDisplay (dpy);
+ xCompositeRedirectWindowReq *req;
+
+ XCompositeSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (CompositeRedirectWindow, req);
+ req->reqType = info->codes->major_opcode;
+ req->compositeReqType = X_CompositeRedirectWindow;
+ req->window = window;
+ req->update = update;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+void
+XCompositeRedirectSubwindows (Display *dpy, Window window, int update)
+{
+ XCompositeExtDisplayInfo *info = XCompositeFindDisplay (dpy);
+ xCompositeRedirectSubwindowsReq *req;
+
+ XCompositeSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (CompositeRedirectSubwindows, req);
+ req->reqType = info->codes->major_opcode;
+ req->compositeReqType = X_CompositeRedirectSubwindows;
+ req->window = window;
+ req->update = update;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+void
+XCompositeUnredirectWindow (Display *dpy, Window window, int update)
+{
+ XCompositeExtDisplayInfo *info = XCompositeFindDisplay (dpy);
+ xCompositeUnredirectWindowReq *req;
+
+ XCompositeSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (CompositeUnredirectWindow, req);
+ req->reqType = info->codes->major_opcode;
+ req->compositeReqType = X_CompositeUnredirectWindow;
+ req->window = window;
+ req->update = update;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+void
+XCompositeUnredirectSubwindows (Display *dpy, Window window, int update)
+{
+ XCompositeExtDisplayInfo *info = XCompositeFindDisplay (dpy);
+ xCompositeUnredirectSubwindowsReq *req;
+
+ XCompositeSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (CompositeUnredirectSubwindows, req);
+ req->reqType = info->codes->major_opcode;
+ req->compositeReqType = X_CompositeUnredirectSubwindows;
+ req->window = window;
+ req->update = update;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+XserverRegion
+XCompositeCreateRegionFromBorderClip (Display *dpy, Window window)
+{
+ XCompositeExtDisplayInfo *info = XCompositeFindDisplay (dpy);
+ xCompositeCreateRegionFromBorderClipReq *req;
+ XserverRegion region;
+
+ XCompositeCheckExtension (dpy, info, 0);
+ LockDisplay (dpy);
+ GetReq (CompositeCreateRegionFromBorderClip, req);
+ req->reqType = info->codes->major_opcode;
+ req->compositeReqType = X_CompositeCreateRegionFromBorderClip;
+ req->window = window;
+ region = req->region = XAllocID (dpy);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return region;
+}
+
+Pixmap
+XCompositeNameWindowPixmap (Display *dpy, Window window)
+{
+ XCompositeExtDisplayInfo *info = XCompositeFindDisplay (dpy);
+ xCompositeNameWindowPixmapReq *req;
+ Pixmap pixmap;
+
+ XCompositeCheckExtension (dpy, info, 0);
+ LockDisplay (dpy);
+ GetReq (CompositeNameWindowPixmap, req);
+ req->reqType = info->codes->major_opcode;
+ req->compositeReqType = X_CompositeNameWindowPixmap;
+ req->window = window;
+ pixmap = req->pixmap = XAllocID (dpy);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return pixmap;
+}
diff --git a/nx-X11/lib/Xcomposite/Xcomposite.h b/nx-X11/lib/Xcomposite/Xcomposite.h
new file mode 100644
index 000000000..3604141bb
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/Xcomposite.h
@@ -0,0 +1,71 @@
+/*
+ * $Id: Xcomposite.h,v 1.5 2005/11/09 21:31:19 kem Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _XCOMPOSITE_H_
+#define _XCOMPOSITE_H_
+
+#include <X11/extensions/composite.h>
+#include <X11/extensions/Xfixes.h>
+#include <X11/Xfuncproto.h>
+
+/*
+ * This revision number also appears in configure.ac, they have
+ * to be manually synchronized
+ */
+#define XCOMPOSITE_MAJOR COMPOSITE_MAJOR
+#define XCOMPOSITE_MINOR COMPOSITE_MINOR
+#define XCOMPOSITE_REVISION 2
+#define XCOMPOSITE_VERSION ((XCOMPOSITE_MAJOR * 10000) + (XCOMPOSITE_MINOR * 100) + (XCOMPOSITE_REVISION))
+
+_XFUNCPROTOBEGIN
+
+Bool XCompositeQueryExtension (Display *dpy, int *event_basep, int *error_basep);
+
+Status XCompositeQueryVersion (Display *dpy,
+ int *major_versionp,
+ int *minor_versionp);
+
+int XCompositeVersion (void);
+
+void
+XCompositeRedirectWindow (Display *dpy, Window window, int update);
+
+void
+XCompositeRedirectSubwindows (Display *dpy, Window window, int update);
+
+void
+XCompositeUnredirectWindow (Display *dpy, Window window, int update);
+
+void
+XCompositeUnredirectSubwindows (Display *dpy, Window window, int update);
+
+XserverRegion
+XCompositeCreateRegionFromBorderClip (Display *dpy, Window window);
+
+Pixmap
+XCompositeNameWindowPixmap (Display *dpy, Window window);
+
+_XFUNCPROTOEND
+
+#endif /* _XCOMPOSITE_H_ */
diff --git a/nx-X11/lib/Xcomposite/autogen.sh b/nx-X11/lib/Xcomposite/autogen.sh
new file mode 100755
index 000000000..b1376df5a
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/autogen.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+autoreconf -v --install || exit 1
+./configure --enable-maintainer-mode "$@"
diff --git a/nx-X11/lib/Xcomposite/configure.ac b/nx-X11/lib/Xcomposite/configure.ac
new file mode 100644
index 000000000..8e8848194
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/configure.ac
@@ -0,0 +1,102 @@
+dnl
+dnl $Id: configure.ac,v 1.1 2004/07/31 05:50:39 anholt Exp $
+dnl
+dnl Copyright © 2003 Keith Packard, Noah Levitt
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this software and its
+dnl documentation for any purpose is hereby granted without fee, provided that
+dnl the above copyright notice appear in all copies and that both that
+dnl copyright notice and this permission notice appear in supporting
+dnl documentation, and that the name of Keith Packard not be used in
+dnl advertising or publicity pertaining to distribution of the software without
+dnl specific, written prior permission. Keith Packard makes no
+dnl representations about the suitability of this software for any purpose. It
+dnl is provided "as is" without express or implied warranty.
+dnl
+dnl KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+dnl EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+dnl PERFORMANCE OF THIS SOFTWARE.
+dnl
+dnl Process this file with autoconf to create configure.
+
+AC_PREREQ([2.57])
+
+dnl
+dnl Version should match the current XComposite version. XCompositeQueryVersion
+dnl returns the version from xcompositewire.h, NOT the version we set here. But we
+dnl try to keep these the same. Note that the library has an extra
+dnl digit in the version number to track changes which don't affect the
+dnl protocol, so Xcomposite version l.n.m corresponds to protocol version l.n
+dnl that 'revision' number appears in Xcomposite.h and has to be manually
+dnl synchronized.
+dnl
+AC_INIT(libXcomposite, 0.2.0, [keithp@keithp.com], libXcomposite)
+AM_INIT_AUTOMAKE([dist-bzip2])
+AM_MAINTAINER_MODE
+
+AM_CONFIG_HEADER(config.h)
+AC_CONFIG_AUX_DIR(.)
+
+# Check for progs
+AC_PROG_CC
+AC_PROG_LIBTOOL
+
+# Check for X
+PKG_CHECK_MODULES(X, x11,
+ [x_found_with_pkgconfig=yes],
+ [x_found_with_pkgconfig=no])
+AC_SUBST(X_CFLAGS)
+AC_SUBST(X_LIBS)
+
+if test "$x_found_with_pkgconfig" = "no"
+then
+ AC_PATH_XTRA
+ X_LIBS="$X_LIBS -lX11"
+
+ if test "x$no_x" = "xyes"
+ then
+ AC_MSG_ERROR([X is required, but it was either disabled or not found.])
+ fi
+
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $X_CFLAGS"
+ LIBS="$LIBS $X_LIBS"
+
+ AC_MSG_CHECKING([for XTHREADS in Xlib])
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
+ [[return XInitThreads() == 0 ? 0 : 1;]])],
+ [xthreads=no],
+ [xthreads=yes],
+ [xthreads=yes])
+
+ AC_MSG_RESULT($xthreads)
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ if test "x$xthreads" = "xyes"
+ then
+ X_CFLAGS="$X_CFLAGS -DXTHREADS"
+ fi
+fi
+
+# Check compositeext configuration, strip extra digits from package version to
+# find the required protocol version
+
+if test "$VERSION" = "" ; then
+ VERSION=$PACKAGE_VERSION;
+fi
+COMPOSITEEXT_VERSION=[`echo $VERSION | sed 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`]
+PKG_CHECK_MODULES(XCOMPOSITE, [compositeext >= $COMPOSITEEXT_VERSION] xfixes)
+AC_SUBST(XCOMPOSITE_CFLAGS)
+AC_SUBST(XCOMPOSITE_LIBS)
+
+AC_OUTPUT([Makefile
+ xcomposite.pc])
+
diff --git a/nx-X11/lib/Xcomposite/xcomposite.pc.in b/nx-X11/lib/Xcomposite/xcomposite.pc.in
new file mode 100644
index 000000000..770adf515
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/xcomposite.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Xcomposite
+Description: X Composite Library
+Version: @VERSION@
+Cflags: -I${includedir} @XCOMPOSITE_CFLAGS@ @X_CFLAGS@
+Libs: -L${libdir} -lXcomposite @XCOMPOSITE_LIBS@ @X_LIBS@
diff --git a/nx-X11/lib/Xcomposite/xcompositeint.h b/nx-X11/lib/Xcomposite/xcompositeint.h
new file mode 100644
index 000000000..af5f57500
--- /dev/null
+++ b/nx-X11/lib/Xcomposite/xcompositeint.h
@@ -0,0 +1,66 @@
+/*
+ * $Id: xcompositeint.h,v 1.3 2005/07/12 03:10:35 keithp Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _XDAMAGEINT_H_
+#define _XDAMAGEINT_H_
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/compositeproto.h>
+#include <X11/extensions/Xcomposite.h>
+
+typedef struct _XCompositeExtDisplayInfo {
+ struct _XCompositeExtDisplayInfo *next; /* keep a linked list */
+ Display *display; /* which display this is */
+ XExtCodes *codes; /* the extension protocol codes */
+ int major_version; /* -1 means we don't know */
+ int minor_version; /* -1 means we don't know */
+} XCompositeExtDisplayInfo;
+
+/* replaces XExtensionInfo */
+typedef struct _XCompositeExtInfo {
+ XCompositeExtDisplayInfo *head; /* start of the list */
+ XCompositeExtDisplayInfo *cur; /* most recently used */
+ int ndisplays; /* number of displays */
+} XCompositeExtInfo;
+
+extern XCompositeExtInfo XCompositeExtensionInfo;
+extern const char XCompositeExtensionName[];
+
+XCompositeExtDisplayInfo *
+XCompositeFindDisplay (Display *dpy);
+
+#define XCompositeHasExtension(i) ((i) && ((i)->codes))
+
+#define XCompositeCheckExtension(dpy,i,val) \
+ if (!XCompositeHasExtension(i)) { return val; }
+
+#define XCompositeSimpleCheckExtension(dpy,i) \
+ if (!XCompositeHasExtension(i)) { return; }
+
+#endif /* _XDAMAGEINT_H_ */
diff --git a/nx-X11/lib/Xcursor/AUTHORS b/nx-X11/lib/Xcursor/AUTHORS
new file mode 100644
index 000000000..57c4efd4e
--- /dev/null
+++ b/nx-X11/lib/Xcursor/AUTHORS
@@ -0,0 +1,2 @@
+Keith Packard, HP
+
diff --git a/nx-X11/lib/Xcursor/COPYING b/nx-X11/lib/Xcursor/COPYING
new file mode 100644
index 000000000..6d9f423cd
--- /dev/null
+++ b/nx-X11/lib/Xcursor/COPYING
@@ -0,0 +1,19 @@
+Copyright © 2002 Keith Packard
+
+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 of Keith Packard not be used in
+advertising or publicity pertaining to distribution of the software without
+specific, written prior permission. Keith Packard makes no
+representations about the suitability of this software for any purpose. It
+is provided "as is" without express or implied warranty.
+
+KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL KEITH PACKARD 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.
diff --git a/nx-X11/lib/Xcursor/ChangeLog b/nx-X11/lib/Xcursor/ChangeLog
new file mode 100644
index 000000000..8d5721187
--- /dev/null
+++ b/nx-X11/lib/Xcursor/ChangeLog
@@ -0,0 +1,202 @@
+2005-06-30 Daniel Stone <daniel@freedesktop.org>
+
+ * lib/Xcursor/file.c:
+ * lib/Xcursor/library.c:
+ * lib/Xcursor/xlib.c:
+ Check arguments for validity on almost all functions.
+
+2005-06-17 Branden Robinson <branden@deadbeast.net>
+
+ Merge changes from freedesktop.org xorg CVS trunk.
+
+ * cursor.c:
+ * library.c:
+ Add preprocessor test for HAVE_XFIXES being defined before testing
+ its value. [merged by Egbert Eich; author unknown]
+
+ * COPYING:
+ * ChangeLog:
+ * Xcursor.3:
+ * Xcursor.h:
+ * cursor.c:
+ * display.c:
+ * file.c:
+ * library.c:
+ * xcursorint.h:
+ * xlib.c:
+ Encoding of numerous files changed to UTF-8 [Markus Kuhn]
+
+ * cursor.c:
+ Bug #1043: Fix leak when creating animated cursors. [Daniel Stone]
+
+Tue Feb 8 14:26:32 2005 Owen Taylor <otaylor@redhat.com>
+
+ * configure.ac: Remove AC_CONFIG_AUX_DIR()
+
+2004-04-13 Daniel Stone <daniel@freedesktop.org>
+
+ * ChangeLog:
+ Tag 1.1.3, for xlibs 1.0.1.
+
+2004-04-07 Keith Packard <keithp@keithp.com>
+
+ reviewed by: Michel Dänzer <michel@daenzer.net>
+
+ * configure.ac:
+ Make sure X_CFLAGS/X_LIBS are substituted in the xcursor.pc file
+
+2004-02-24 Fredrik Höglund <fredrik@kde.org>
+
+ * configure.ac:
+ * xcursorint.h:
+ Make the Xfixes code actually work by including the Xfixes.h
+ header file.
+
+2004-02-03 Jim Gettys <jg@freedesktop.org>
+
+ * AUTHORS: Add contents to author's file
+
+2004-01-17 Daniel Stone <daniel@fooishbar.org>
+ * Xcursor.h:
+ * configure.ac:
+ Bump package version to 1.1.2, slated for first fd.o platform release.
+
+2004-01-15 Harold L Hunt II <huntharo@msu.edu>
+ * Makefile.am: Pass -no-undefined to libtool via LDFLAGS.
+
+2003-11-10 Keith Packard <keithp@keithp.com>
+
+ * library.c: (_XcursorBuildThemeDir):
+ Make sure the allocated path has space for directory separators
+
+2003-10-29 Keith Packard <keithp@keithp.com>
+
+ * Xcursor.h:
+ * configure.ac:
+ Bump package version to 1.1.1 and library info to 1.2.0 as
+ the library exports new name-based APIs and uses Xfixes
+
+2003-10-28 Keith Packard <keithp@keithp.com>
+
+ * Makefile.am:
+ * Xcursor.h:
+ * configure.ac:
+ * cursor.c: (XcursorImagesLoadCursor):
+ * file.c: (XcursorImagesCreate), (XcursorImagesDestroy),
+ (XcursorImagesSetName):
+ * library.c: (XcursorLibraryLoadImages),
+ (XcursorLibraryLoadCursor):
+ Add support for XFixes version 2 cursor naming functions
+
+2003-10-16 23:45 fredrik
+
+ * Xcursor-def.cpp, Xcursor.h, configure.ac, library.c:
+ Rename _XcursorLibraryPath() to XcursorLibraryPath() and make
+ it a public function, since it's useful for theme selectors.
+ Bump version to 1.1.0
+
+2003-05-21 10:21 keithp
+
+ * Makefile.am, Xcursor.h, configure.ac, xcursorint.h: Package
+ Xcursor.3, bump version to 1.0.2
+
+2003-05-06 11:20 keithp
+
+ * ChangeLog: Add initial change log
+
+2003-05-06 11:09 keithp
+
+ * .cvsignore, Makefile.am, Xcursor-def.cpp, Xcursor.3, Xcursor.h,
+ Xcursor.man, cursor.c, display.c, file.c, library.c, xcursorint.h,
+ xlib.c: Update .cvsignore, move manual and install, fix CVS ident
+ lines
+
+2003-05-06 11:00 keithp
+
+ * configure.ac: replace Xrender test with fragment from Xft
+
+2003-05-06 10:52 keithp
+
+ * Makefile.am: Add xcursorint.h to library sources list
+
+2003-05-06 10:49 keithp
+
+ * Imakefile, Makefile.am, Xcursor.h, autogen.sh, configure.ac,
+ file.c, xcursor.pc.in: Convert Xcursor to autotools
+
+2003-02-21 22:16 dawes
+
+ * xlib.c: 941. Fix a problem where a malformed Ximage can cause
+ Xcursor to step
+ outside the image data (#A.1636, Keith Packard, reported by
+ Michel Dänzer).
+
+2003-02-19 19:13 dawes
+
+ * display.c: 924. Fix a memory leak in XCloseDisplay, and a
+ potential race condition
+ when multiple threads attempt to initialize the Xcursor
+ library
+ simultaneously (#A.1623, Keith Packard).
+
+2003-02-12 19:09 dawes
+
+ * Xcursor.man: 880. Fix the Xcursor include path in the man page
+ (#5617, Kevin Brosius).
+
+2003-01-25 19:22 eich
+
+ * Xcursor.h, cursor.c, library.c, xcursorint.h: 787. Add "core"
+ theme to Xcursor to force old behaviour (Keith Packard).
+
+2002-11-26 21:35 keithp
+
+ * display.c: Fix XcursorSetTheme to permit NULL theme
+
+2002-11-22 18:34 keithp
+
+ * Xcursor.h, cursor.c, display.c, xcursorint.h, xlib.c: Add animate
+ cursor support, client side
+
+2002-10-11 10:06 keithp
+
+ * cursor.c: Off by one in XcursorAnimateNext (from Anders Carlsson)
+
+2002-09-30 15:02 alanh
+
+ * Xcursor-def.cpp: add Xv-def.cpp file add $XFree86$ tags
+
+2002-09-26 00:52 alanh
+
+ * Imakefile: #elif -> #else
+
+2002-09-25 16:27 alanh
+
+ * Xcursor-def.cpp: #5350, add Xcursor-def.cpp
+
+2002-09-25 09:10 torrey
+
+ * Imakefile: Add SharedXcursorReqs for operating systems that
+ require it.
+
+2002-09-18 10:11 tsi
+
+ * file.c: Pacify gcc 3.2
+
+2002-09-05 00:55 keithp
+
+ * display.c: Clean up parsing of option that forces use of core
+ cursors
+
+2002-09-05 00:29 keithp
+
+ * Xcursor.h, cursor.c, display.c, xcursorint.h, xlib.c: Add
+ themeable app-specific cursors. Add dithers for core cursors.
+ Dont theme servers without Render by default
+
+2002-08-28 21:40 keithp
+
+ * Imakefile, Xcursor.h, Xcursor.man, config-subst, cursor.c,
+ display.c, file.c, library.c, xcursor-config.in, xcursor.pc.in,
+ xcursorint.h, xlib.c: Add Xcursor library and Xlib hooks for it
+
diff --git a/nx-X11/lib/Xcursor/INSTALL b/nx-X11/lib/Xcursor/INSTALL
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/lib/Xcursor/INSTALL
diff --git a/nx-X11/lib/Xcursor/Imakefile b/nx-X11/lib/Xcursor/Imakefile
new file mode 100644
index 000000000..3e50841ff
--- /dev/null
+++ b/nx-X11/lib/Xcursor/Imakefile
@@ -0,0 +1,100 @@
+XCOMM $XdotOrg: xc/lib/Xcursor/Imakefile,v 1.5 2005/10/09 21:52:42 alanc Exp $
+XCOMM $XFree86: xc/lib/Xcursor/Imakefile,v 1.3 2002/09/26 07:52:01 alanh Exp $
+
+#ifndef NormalLibXcursor
+#define NormalLibXcursor YES
+SOXCURSORREV=1.0.2
+#endif
+
+#ifndef SharedLibXcursor
+#define SharedLibXcursor YES
+#endif
+
+#define DoNormalLib NormalLibXcursor
+#define DoSharedLib SharedLibXcursor
+#define DoDebugLib DebugLibXcursor
+#define DoProfileLib ProfileLibXcursor
+
+#define LibName Xcursor
+#define SoRev SOXCURSORREV
+#define IncSubdir X11
+#define IncSubSubdir Xcursor
+
+#include <Threads.tmpl>
+
+#ifdef SharedXcursorReqs
+REQUIREDLIBS = SharedXcursorReqs
+#else
+REQUIREDLIBS = $(LDPRELIB) $(XRENDERLIB)
+#endif
+
+XCURSOR_VERSION=1.1.4
+
+XRENDER_LIBS=$(XRENDERLIB)
+XRENDER_CFLAGS=$(XRENDERINCLUDES)
+
+X_LIBS=-L$(SHLIBDIR) $(XONLYLIB)
+X_CFLAGS=-I$(INCROOT) $(THREADS_DEFINES)
+
+#if BuildRenderLibrary
+XRENDER_LIBS=-L$(USRLIBDIR) $(XRENDERLIB)
+XRENDER_CFLAGS=-I$(INCROOT)
+#endif
+
+#if BuildXfixesLibrary
+XFIXES_DEFINES = -DHAVE_XFIXES
+REQUIREDLIBS += $(XFIXESLIB)
+#endif
+
+RPATH_CFLAG = HardCodeLibdirFlag
+
+ICONDIR=$(LIBDIR)/icons
+
+DEFINES=-DICONDIR=\"$(ICONDIR)\" $(XFIXES_DEFINES)
+
+SRCS = cursor.c display.c file.c library.c xlib.c
+
+OBJS = cursor.o display.o file.o library.o xlib.o
+
+HEADERS = Xcursor.h
+
+SUBSTVARS=prefix="$(PROJECTROOT)" \
+ exec_prefix="$(BINDIR)" \
+ libdir="$(USRLIBDIR)" \
+ hardcode_libdir_flag_spec="$(RPATH_CFLAG)" \
+ includedir="$(INCROOT)" \
+ XRENDER_LIBS="$(XRENDER_LIBS)"\
+ XRENDER_CFLAGS="$(XRENDER_CFLAGS)"\
+ X_LIBS="$(X_LIBS)" \
+ X_CFLAGS="$(X_CFLAGS)" \
+ VERSION="$(XCURSOR_VERSION)"
+
+#include <Library.tmpl>
+
+MANSUFFIX=$(LIBMANSUFFIX)
+InstallManPage(Xcursor,$(LIBMANDIR))
+
+DependTarget()
+
+all:: xcursor-config.script
+
+xcursor-config.script: xcursor-config.in
+ RemoveFile($@)
+ sh config-subst $(SUBSTVARS) < xcursor-config.in > $@
+
+InstallScript(xcursor-config,$(BINDIR))
+
+clean::
+ RemoveFile(xcursor-config.script)
+
+all:: xcursor.pc
+
+xcursor.pc: xcursor.pc.in
+ RemoveFile($@)
+ sh config-subst $(SUBSTVARS) < xcursor.pc.in > $@
+
+InstallNonExecFile(xcursor.pc,$(USRLIBDIR)/pkgconfig)
+
+clean::
+ RemoveFile(xcursor.pc)
+
diff --git a/nx-X11/lib/Xcursor/Makefile.am b/nx-X11/lib/Xcursor/Makefile.am
new file mode 100644
index 000000000..995f86886
--- /dev/null
+++ b/nx-X11/lib/Xcursor/Makefile.am
@@ -0,0 +1,45 @@
+#
+# $Id: Makefile.am,v 1.3 2005/06/29 18:46:53 daniels Exp $
+#
+# Copyright © 2003 Keith Packard, Noah Levitt
+#
+# 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 of Keith Packard not be used in
+# advertising or publicity pertaining to distribution of the software without
+# specific, written prior permission. Keith Packard makes no
+# representations about the suitability of this software for any purpose. It
+# is provided "as is" without express or implied warranty.
+#
+# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+# EVENT SHALL KEITH PACKARD 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.
+
+AM_CFLAGS = $(XRENDER_CFLAGS) $(XFIXES_CFLAGS) $(X_CFLAGS)
+
+lib_LTLIBRARIES = libXcursor.la
+
+man_MANS = Xcursor.3
+
+libXcursor_la_SOURCES = xcursorint.h cursor.c display.c file.c library.c xlib.c
+
+libXcursor_la_LIBADD = $(XRENDER_LIBS) $(XFIXES_LIBS) $(X_LIBS)
+
+#
+# Shared library version info. This is not the same as the package version
+#
+libXcursor_la_LDFLAGS = -version-info @LT_VERSION_INFO@ -no-undefined
+
+libXcursorincludedir = $(includedir)/X11/Xcursor
+libXcursorinclude_HEADERS = Xcursor.h
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = xcursor.pc
+
+EXTRA_DIST = $(man_MANS) xcursor.pc.in autogen.sh
diff --git a/nx-X11/lib/Xcursor/NEWS b/nx-X11/lib/Xcursor/NEWS
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/lib/Xcursor/NEWS
diff --git a/nx-X11/lib/Xcursor/README b/nx-X11/lib/Xcursor/README
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/lib/Xcursor/README
diff --git a/nx-X11/lib/Xcursor/Xcursor-def.cpp b/nx-X11/lib/Xcursor/Xcursor-def.cpp
new file mode 100644
index 000000000..e60212f01
--- /dev/null
+++ b/nx-X11/lib/Xcursor/Xcursor-def.cpp
@@ -0,0 +1,54 @@
+LIBRARY Xcursor
+VERSION LIBRARY_VERSION
+EXPORTS
+XcursorAnimateCreate
+XcursorAnimateDestroy
+XcursorAnimateNext
+XcursorCursorsCreate
+XcursorCursorsDestroy
+XcursorFilenameLoadCursor
+XcursorFilenameLoadCursors
+XcursorImageLoadCursor
+XcursorImagesLoadCursors
+XcursorLibraryLoadCursor
+XcursorLibraryLoadCursors
+XcursorShapeLoadCursor
+XcursorShapeLoadCursors
+_XcursorCreateGlyphCursor
+XcursorGetDefaultSize
+XcursorGetTheme
+XcursorSetDefaultSize
+XcursorSetTheme
+XcursorSupportsARGB
+_XcursorGetDisplayInfo
+XcursorCommentCreate
+XcursorCommentDestroy
+XcursorCommentsCreate
+XcursorCommentsDestroy
+XcursorFileLoad
+XcursorFileLoadAllImages
+XcursorFileLoadImage
+XcursorFileLoadImages
+XcursorFileSave
+XcursorFileSaveImages
+XcursorFilenameLoad
+XcursorFilenameLoadAllImages
+XcursorFilenameLoadImage
+XcursorFilenameLoadImages
+XcursorFilenameSave
+XcursorFilenameSaveImages
+XcursorImageCreate
+XcursorImageDestroy
+XcursorImagesCreate
+XcursorImagesDestroy
+XcursorXcFileLoad
+XcursorXcFileLoadAllImages
+XcursorXcFileLoadImage
+XcursorXcFileLoadImages
+XcursorXcFileSave
+XcursorLibraryPath
+XcursorLibraryLoadImage
+XcursorLibraryLoadImages
+XcursorShapeLoadImage
+XcursorShapeLoadImages
+XcursorTryShapeCursor
diff --git a/nx-X11/lib/Xcursor/Xcursor.h b/nx-X11/lib/Xcursor/Xcursor.h
new file mode 100644
index 000000000..d8a7ac320
--- /dev/null
+++ b/nx-X11/lib/Xcursor/Xcursor.h
@@ -0,0 +1,501 @@
+/*
+ * $Id: Xcursor.h,v 1.6 2005/11/09 21:31:19 kem Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _XCURSOR_H_
+#define _XCURSOR_H_
+#include <stdio.h>
+#include <X11/Xfuncproto.h>
+
+typedef int XcursorBool;
+typedef unsigned int XcursorUInt;
+
+typedef XcursorUInt XcursorDim;
+typedef XcursorUInt XcursorPixel;
+
+#define XcursorTrue 1
+#define XcursorFalse 0
+
+/*
+ * Cursor files start with a header. The header
+ * contains a magic number, a version number and a
+ * table of contents which has type and offset information
+ * for the remaining tables in the file.
+ *
+ * File minor versions increment for compatible changes
+ * File major versions increment for incompatible changes (never, we hope)
+ *
+ * Chunks of the same type are always upward compatible. Incompatible
+ * changes are made with new chunk types; the old data can remain under
+ * the old type. Upward compatible changes can add header data as the
+ * header lengths are specified in the file.
+ *
+ * File:
+ * FileHeader
+ * LISTofChunk
+ *
+ * FileHeader:
+ * CARD32 magic magic number
+ * CARD32 header bytes in file header
+ * CARD32 version file version
+ * CARD32 ntoc number of toc entries
+ * LISTofFileToc toc table of contents
+ *
+ * FileToc:
+ * CARD32 type entry type
+ * CARD32 subtype entry subtype (size for images)
+ * CARD32 position absolute file position
+ */
+
+#define XCURSOR_MAGIC 0x72756358 /* "Xcur" LSBFirst */
+
+/*
+ * Current Xcursor version number. This same number
+ * must appear in the Xcursor configure.ac file. Yes,
+ * it'a a pain to synchronize version numbers like this.
+ */
+
+#define XCURSOR_LIB_MAJOR 1
+#define XCURSOR_LIB_MINOR 1
+#define XCURSOR_LIB_REVISION 5
+#define XCURSOR_LIB_VERSION ((XCURSOR_LIB_MAJOR * 10000) + \
+ (XCURSOR_LIB_MINOR * 100) + \
+ (XCURSOR_LIB_REVISION))
+
+/*
+ * This version number is stored in cursor files; changes to the
+ * file format require updating this version number
+ */
+#define XCURSOR_FILE_MAJOR 1
+#define XCURSOR_FILE_MINOR 0
+#define XCURSOR_FILE_VERSION ((XCURSOR_FILE_MAJOR << 16) | (XCURSOR_FILE_MINOR))
+#define XCURSOR_FILE_HEADER_LEN (4 * 4)
+#define XCURSOR_FILE_TOC_LEN (3 * 4)
+
+typedef struct _XcursorFileToc {
+ XcursorUInt type; /* chunk type */
+ XcursorUInt subtype; /* subtype (size for images) */
+ XcursorUInt position; /* absolute position in file */
+} XcursorFileToc;
+
+typedef struct _XcursorFileHeader {
+ XcursorUInt magic; /* magic number */
+ XcursorUInt header; /* byte length of header */
+ XcursorUInt version; /* file version number */
+ XcursorUInt ntoc; /* number of toc entries */
+ XcursorFileToc *tocs; /* table of contents */
+} XcursorFileHeader;
+
+/*
+ * The rest of the file is a list of chunks, each tagged by type
+ * and version.
+ *
+ * Chunk:
+ * ChunkHeader
+ * <extra type-specific header fields>
+ * <type-specific data>
+ *
+ * ChunkHeader:
+ * CARD32 header bytes in chunk header + type header
+ * CARD32 type chunk type
+ * CARD32 subtype chunk subtype
+ * CARD32 version chunk type version
+ */
+
+#define XCURSOR_CHUNK_HEADER_LEN (4 * 4)
+
+typedef struct _XcursorChunkHeader {
+ XcursorUInt header; /* bytes in chunk header */
+ XcursorUInt type; /* chunk type */
+ XcursorUInt subtype; /* chunk subtype (size for images) */
+ XcursorUInt version; /* version of this type */
+} XcursorChunkHeader;
+
+/*
+ * Here's a list of the known chunk types
+ */
+
+/*
+ * Comments consist of a 4-byte length field followed by
+ * UTF-8 encoded text
+ *
+ * Comment:
+ * ChunkHeader header chunk header
+ * CARD32 length bytes in text
+ * LISTofCARD8 text UTF-8 encoded text
+ */
+
+#define XCURSOR_COMMENT_TYPE 0xfffe0001
+#define XCURSOR_COMMENT_VERSION 1
+#define XCURSOR_COMMENT_HEADER_LEN (XCURSOR_CHUNK_HEADER_LEN + (1 *4))
+#define XCURSOR_COMMENT_COPYRIGHT 1
+#define XCURSOR_COMMENT_LICENSE 2
+#define XCURSOR_COMMENT_OTHER 3
+#define XCURSOR_COMMENT_MAX_LEN 0x100000
+
+typedef struct _XcursorComment {
+ XcursorUInt version;
+ XcursorUInt comment_type;
+ char *comment;
+} XcursorComment;
+
+/*
+ * Each cursor image occupies a separate image chunk.
+ * The length of the image header follows the chunk header
+ * so that future versions can extend the header without
+ * breaking older applications
+ *
+ * Image:
+ * ChunkHeader header chunk header
+ * CARD32 width actual width
+ * CARD32 height actual height
+ * CARD32 xhot hot spot x
+ * CARD32 yhot hot spot y
+ * CARD32 delay animation delay
+ * LISTofCARD32 pixels ARGB pixels
+ */
+
+#define XCURSOR_IMAGE_TYPE 0xfffd0002
+#define XCURSOR_IMAGE_VERSION 1
+#define XCURSOR_IMAGE_HEADER_LEN (XCURSOR_CHUNK_HEADER_LEN + (5*4))
+#define XCURSOR_IMAGE_MAX_SIZE 0x7fff /* 32767x32767 max cursor size */
+
+typedef struct _XcursorImage {
+ XcursorUInt version; /* version of the image data */
+ XcursorDim size; /* nominal size for matching */
+ XcursorDim width; /* actual width */
+ XcursorDim height; /* actual height */
+ XcursorDim xhot; /* hot spot x (must be inside image) */
+ XcursorDim yhot; /* hot spot y (must be inside image) */
+ XcursorUInt delay; /* animation delay to next frame (ms) */
+ XcursorPixel *pixels; /* pointer to pixels */
+} XcursorImage;
+
+/*
+ * Other data structures exposed by the library API
+ */
+typedef struct _XcursorImages {
+ int nimage; /* number of images */
+ XcursorImage **images; /* array of XcursorImage pointers */
+ char *name; /* name used to load images */
+} XcursorImages;
+
+typedef struct _XcursorCursors {
+ Display *dpy; /* Display holding cursors */
+ int ref; /* reference count */
+ int ncursor; /* number of cursors */
+ Cursor *cursors; /* array of cursors */
+} XcursorCursors;
+
+typedef struct _XcursorAnimate {
+ XcursorCursors *cursors; /* list of cursors to use */
+ int sequence; /* which cursor is next */
+} XcursorAnimate;
+
+typedef struct _XcursorFile XcursorFile;
+
+struct _XcursorFile {
+ void *closure;
+ int (*read) (XcursorFile *file, unsigned char *buf, int len);
+ int (*write) (XcursorFile *file, unsigned char *buf, int len);
+ int (*seek) (XcursorFile *file, long offset, int whence);
+};
+
+typedef struct _XcursorComments {
+ int ncomment; /* number of comments */
+ XcursorComment **comments; /* array of XcursorComment pointers */
+} XcursorComments;
+
+#define XCURSOR_CORE_THEME "core"
+
+_XFUNCPROTOBEGIN
+
+/*
+ * Manage Image objects
+ */
+XcursorImage *
+XcursorImageCreate (int width, int height);
+
+void
+XcursorImageDestroy (XcursorImage *image);
+
+/*
+ * Manage Images objects
+ */
+XcursorImages *
+XcursorImagesCreate (int size);
+
+void
+XcursorImagesDestroy (XcursorImages *images);
+
+void
+XcursorImagesSetName (XcursorImages *images, const char *name);
+
+/*
+ * Manage Cursor objects
+ */
+XcursorCursors *
+XcursorCursorsCreate (Display *dpy, int size);
+
+void
+XcursorCursorsDestroy (XcursorCursors *cursors);
+
+/*
+ * Manage Animate objects
+ */
+XcursorAnimate *
+XcursorAnimateCreate (XcursorCursors *cursors);
+
+void
+XcursorAnimateDestroy (XcursorAnimate *animate);
+
+Cursor
+XcursorAnimateNext (XcursorAnimate *animate);
+
+/*
+ * Manage Comment objects
+ */
+XcursorComment *
+XcursorCommentCreate (XcursorUInt comment_type, int length);
+
+void
+XcursorCommentDestroy (XcursorComment *comment);
+
+XcursorComments *
+XcursorCommentsCreate (int size);
+
+void
+XcursorCommentsDestroy (XcursorComments *comments);
+
+/*
+ * XcursorFile/Image APIs
+ */
+XcursorImage *
+XcursorXcFileLoadImage (XcursorFile *file, int size);
+
+XcursorImages *
+XcursorXcFileLoadImages (XcursorFile *file, int size);
+
+XcursorImages *
+XcursorXcFileLoadAllImages (XcursorFile *file);
+
+XcursorBool
+XcursorXcFileLoad (XcursorFile *file,
+ XcursorComments **commentsp,
+ XcursorImages **imagesp);
+
+XcursorBool
+XcursorXcFileSave (XcursorFile *file,
+ const XcursorComments *comments,
+ const XcursorImages *images);
+
+/*
+ * FILE/Image APIs
+ */
+XcursorImage *
+XcursorFileLoadImage (FILE *file, int size);
+
+XcursorImages *
+XcursorFileLoadImages (FILE *file, int size);
+
+XcursorImages *
+XcursorFileLoadAllImages (FILE *file);
+
+XcursorBool
+XcursorFileLoad (FILE *file,
+ XcursorComments **commentsp,
+ XcursorImages **imagesp);
+
+XcursorBool
+XcursorFileSaveImages (FILE *file, const XcursorImages *images);
+
+XcursorBool
+XcursorFileSave (FILE * file,
+ const XcursorComments *comments,
+ const XcursorImages *images);
+
+/*
+ * Filename/Image APIs
+ */
+XcursorImage *
+XcursorFilenameLoadImage (const char *filename, int size);
+
+XcursorImages *
+XcursorFilenameLoadImages (const char *filename, int size);
+
+XcursorImages *
+XcursorFilenameLoadAllImages (const char *filename);
+
+XcursorBool
+XcursorFilenameLoad (const char *file,
+ XcursorComments **commentsp,
+ XcursorImages **imagesp);
+
+XcursorBool
+XcursorFilenameSaveImages (const char *filename, const XcursorImages *images);
+
+XcursorBool
+XcursorFilenameSave (const char *file,
+ const XcursorComments *comments,
+ const XcursorImages *images);
+
+/*
+ * Library/Image APIs
+ */
+XcursorImage *
+XcursorLibraryLoadImage (const char *library, const char *theme, int size);
+
+XcursorImages *
+XcursorLibraryLoadImages (const char *library, const char *theme, int size);
+
+/*
+ * Library/shape API
+ */
+
+const char *
+XcursorLibraryPath (void);
+
+int
+XcursorLibraryShape (const char *library);
+
+/*
+ * Image/Cursor APIs
+ */
+
+Cursor
+XcursorImageLoadCursor (Display *dpy, const XcursorImage *image);
+
+XcursorCursors *
+XcursorImagesLoadCursors (Display *dpy, const XcursorImages *images);
+
+Cursor
+XcursorImagesLoadCursor (Display *dpy, const XcursorImages *images);
+
+/*
+ * Filename/Cursor APIs
+ */
+Cursor
+XcursorFilenameLoadCursor (Display *dpy, const char *file);
+
+XcursorCursors *
+XcursorFilenameLoadCursors (Display *dpy, const char *file);
+
+/*
+ * Library/Cursor APIs
+ */
+Cursor
+XcursorLibraryLoadCursor (Display *dpy, const char *file);
+
+XcursorCursors *
+XcursorLibraryLoadCursors (Display *dpy, const char *file);
+
+/*
+ * Shape/Image APIs
+ */
+
+XcursorImage *
+XcursorShapeLoadImage (unsigned int shape, const char *theme, int size);
+
+XcursorImages *
+XcursorShapeLoadImages (unsigned int shape, const char *theme, int size);
+
+/*
+ * Shape/Cursor APIs
+ */
+Cursor
+XcursorShapeLoadCursor (Display *dpy, unsigned int shape);
+
+XcursorCursors *
+XcursorShapeLoadCursors (Display *dpy, unsigned int shape);
+
+/*
+ * This is the function called by Xlib when attempting to
+ * load cursors from XCreateGlyphCursor. The interface must
+ * not change as Xlib loads 'libXcursor.so' instead of
+ * a specific major version
+ */
+Cursor
+XcursorTryShapeCursor (Display *dpy,
+ Font source_font,
+ Font mask_font,
+ unsigned int source_char,
+ unsigned int mask_char,
+ XColor _Xconst *foreground,
+ XColor _Xconst *background);
+
+void
+XcursorNoticeCreateBitmap (Display *dpy,
+ Pixmap pid,
+ unsigned int width,
+ unsigned int height);
+
+void
+XcursorNoticePutBitmap (Display *dpy,
+ Drawable draw,
+ XImage *image);
+
+Cursor
+XcursorTryShapeBitmapCursor (Display *dpy,
+ Pixmap source,
+ Pixmap mask,
+ XColor *foreground,
+ XColor *background,
+ unsigned int x,
+ unsigned int y);
+
+#define XCURSOR_BITMAP_HASH_SIZE 16
+
+void
+XcursorImageHash (XImage *image,
+ unsigned char hash[XCURSOR_BITMAP_HASH_SIZE]);
+
+/*
+ * Display information APIs
+ */
+XcursorBool
+XcursorSupportsARGB (Display *dpy);
+
+XcursorBool
+XcursorSupportsAnim (Display *dpy);
+
+XcursorBool
+XcursorSetDefaultSize (Display *dpy, int size);
+
+int
+XcursorGetDefaultSize (Display *dpy);
+
+XcursorBool
+XcursorSetTheme (Display *dpy, const char *theme);
+
+char *
+XcursorGetTheme (Display *dpy);
+
+XcursorBool
+XcursorGetThemeCore (Display *dpy);
+
+XcursorBool
+XcursorSetThemeCore (Display *dpy, XcursorBool theme_core);
+
+_XFUNCPROTOEND
+
+#endif
diff --git a/nx-X11/lib/Xcursor/Xcursor.man b/nx-X11/lib/Xcursor/Xcursor.man
new file mode 100644
index 000000000..99b7213d9
--- /dev/null
+++ b/nx-X11/lib/Xcursor/Xcursor.man
@@ -0,0 +1,379 @@
+.\"
+.\" $Id: Xcursor.man,v 1.4 2005/10/13 02:22:47 alanc Exp $
+.\"
+.\" Copyright © 2002 Keith Packard
+.\"
+.\" 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 of Keith Packard not be used in
+.\" advertising or publicity pertaining to distribution of the software without
+.\" specific, written prior permission. Keith Packard makes no
+.\" representations about the suitability of this software for any purpose. It
+.\" is provided "as is" without express or implied warranty.
+.\"
+.\" KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+.\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+.\" EVENT SHALL KEITH PACKARD 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.
+.\"
+.de TQ
+.br
+.ns
+.TP \\$1
+..
+.TH XCURSOR 3 "Version 1.0" "Keith Packard"
+
+.SH NAME
+XCURSOR \- Cursor management library
+
+.SH SYNOPSIS
+.nf
+.B #include <X11/Xcursor/Xcursor.h>
+.fi
+.SH DESCRIPTION
+.B Xcursor
+is a simple library designed to help locate and load cursors. Cursors can
+be loaded from files or memory. A library of common cursors exists which
+map to the standard X cursor names. Cursors can exist in several sizes and
+the library automatically picks the best size.
+
+.SH FUNCTIONAL OVERVIEW
+Xcursor is built in a couple of layers; at the bottom layer is code which
+can load cursor images from files. Above that is a layer which locates
+cursor files based on the library path and theme. At the top is a layer
+which builds cursors either out of an image loaded from a file or one of the
+standard X cursors. When using images loaded from files, Xcursor prefers
+to use the Render extension CreateCursor request if supported by the X
+server. Where not supported, Xcursor maps the cursor image to a standard X
+cursor and uses the core CreateCursor request.
+
+.SS CURSOR FILES
+Xcursor defines a new format for cursors on disk. Each file holds
+one or more cursor images. Each cursor image is tagged with a nominal size
+so that the best size can be selected automatically. Multiple cursors of
+the same nominal size can be loaded together; applications are expected to
+use them as an animated sequence.
+.P
+Cursor files are stored as a header containing a table of contents followed
+by a sequence of chunks. The table of contents indicates the type, subtype
+and position in the file of each chunk. The file header looks like:
+.LP
+.in +.2i
+\fImagic\fP\^: CARD32 'Xcur' (0x58, 0x63, 0x75, 0x72)
+.br
+\fIheader\fP\^: CARD32 bytes in this header
+.br
+\fIversion\fP\^: CARD32 file version number
+.br
+\fIntoc\fP\^: CARD32 number of toc entries
+\fItoc\fP\^: LISTofTOC table of contents
+.in -.2i
+.P
+Each table of contents entry looks like:
+.LP
+.in +.2i
+\fItype\fP\^: CARD32 entry type
+\fIsubtype\fP\^: CARD32 type-specific label - size for images
+\fIposition\fP\^: CARD32 absolute byte position of table in file
+.in -.2i
+.P
+.P
+Each chunk in the file has set of common header fields followed by
+additional type-specific fields:
+.LP
+.in +.2i
+\fIheader\fP\^: CARD32 bytes in chunk header (including type-specific fields)
+.br
+\fItype\fP\^: CARD32 must match type in TOC for this chunk
+.br
+\fIsubtype\fP\^: CARD32 must match subtype in TOC for this chunk
+.br
+\fIversion\fP\^: CARD32 version number for this chunk type
+.in -.2i
+.P
+There are currently two chunk types defined for cursor files; comments and
+images. Comments look like:
+.LP
+.in +.2i
+\fIheader\fP\^: 20 Comment headers are 20 bytes
+.br
+\fItype\fP\^: 0xfffe0001 Comment type is 0xfffe0001
+.br
+\fIsubtype\fP\^: { 1 (COPYRIGHT), 2 (LICENSE), 3 (OTHER) }
+.br
+\fIversion\fP\^: 1
+.br
+\fIlength\fP\^: CARD32 byte length of UTF-8 string
+.br
+\fIstring\fP\^: LISTofCARD8 UTF-8 string
+.in -.2i
+.P
+Images look like:
+.LP
+.in +.2i
+\fIheader\fP\^: 36 Image headers are 36 bytes
+.br
+\fItype\fP\^: 0xfffd0002 Image type is 0xfffd0002
+.br
+\fIsubtype\fP\^: CARD32 Image subtype is the nominal size
+.br
+\fIversion\fP\^: 1
+.br
+\fIwidth\fP\^: CARD32 Must be less than or equal to 0x7fff
+.br
+\fIheight\fP\^: CARD32 Must be less than or equal to 0x7fff
+.br
+\fIxhot\fP\^: CARD32 Must be less than or equal to width
+.br
+\fIyhot\fP\^: CARD32 Must be less than or equal to height
+.br
+\fIdelay\fP\^: CARD32 Delay between animation frames in milliseconds
+.br
+\fIpixels\fP\^: LISTofCARD32 Packed ARGB format pixels
+.in -.2i
+
+.SS THEMES
+Xcursor (mostly) follows the freedesktop.org spec for theming icons. The
+default search path it uses is $HOME/.icons, /usr/share/icons,
+/usr/share/pimaps, /usr/X11R6/lib/X11/icons. Within each of these
+directorys, it searches for a directory using the theme name. Within the
+theme directory, it looks for cursor files in the 'cursors' subdirectory.
+It uses the first cursor file found along the path.
+.PP
+If necessary, Xcursor also looks for a "index.theme" file in each theme
+directory to find inherited themes and searches along the path for those
+themes as well.
+.PP
+If no theme is set, or if no cursor is found for the specified theme,
+Xcursor checks the "default" theme.
+
+.SH DATATYPES
+
+.TP
+.B XcursorImage
+holds a single cursor image in memory. Each pixel in the cursor is a 32-bit
+value containing ARGB with A in the high byte.
+.sp
+.nf
+.ft CR
+ typedef struct _XcursorImage {
+ XcursorDim size; /\(** nominal size for matching */
+ XcursorDim width; /\(** actual width */
+ XcursorDim height; /\(** actual height */
+ XcursorDim xhot; /\(** hot spot x (must be inside image) */
+ XcursorDim yhot; /\(** hot spot y (must be inside image) */
+ XcursorPixel *pixels; /\(** pointer to pixels */
+ } XcursorImage;
+.ft
+.fi
+
+.TP
+.B XcursorImages
+holds multiple XcursorImage structures. They're all freed when the
+XcursorImages is freed.
+.sp
+.nf
+.ft CR
+ typedef struct _XcursorImages {
+ int nimage; /\(** number of images */
+ XcursorImage **images; /\(** array of XcursorImage pointers */
+ } XcursorImages;
+.ft
+.fi
+
+.TP
+.B XcursorCursors
+Holds multiple Cursor objects. They're all freed when the XcursorCursors is
+freed. These are reference counted so that multiple XcursorAnimate
+structures can use the same XcursorCursors.
+.sp
+.nf
+.ft CR
+ typedef struct _XcursorCursors {
+ Display *dpy; /\(** Display holding cursors */
+ int ref; /\(** reference count */
+ int ncursor; /\(** number of cursors */
+ Cursor *cursors; /\(** array of cursors */
+ } XcursorCursors;
+.ft
+.fi
+
+.TP
+.B XcursorAnimate
+References a set of cursors and a sequence within that set. Multiple
+XcursorAnimate structures may reference the same XcursorCursors; each
+holds a reference which is removed when the XcursorAnimate is freed.
+.sp
+.nf
+.ft CR
+ typedef struct _XcursorAnimate {
+ XcursorCursors *cursors; /\(** list of cursors to use */
+ int sequence; /\(** which cursor is next */
+ } XcursorAnimate;
+.ft
+.fi
+
+.TP
+.B XcursorFile
+Xcursor provides an abstract API for accessing the file data. Xcursor
+provides a stdio implementation of this abstract API; applications
+are free to create additional implementations. These functions
+parallel the stdio functions in return value and expected argument values;
+the read and write functions flip the arguments around to match the POSIX
+versions.
+.sp
+.nf
+.ft CR
+ typedef struct _XcursorFile {
+ void *closure;
+ int (*read) (XcursorFile *file, unsigned char *buf, int len);
+ int (*write) (XcursorFile *file, unsigned char *buf, int len);
+ int (*seek) (XcursorFile *file, long offset, int whence);
+ };
+.ft
+.fi
+
+.SH FUNCTIONS
+
+.SS Object Management
+.TP
+XcursorImage *XcursorImageCreate (int width, int height)
+.TQ
+void XcursorImageDestroy (XcursorImage *image)
+Allocate and free images. On allocation, the hotspot and the pixels are
+left uninitialized. The size is set to the maximum of width and height.
+
+.TP
+XcursorImages *XcursorImagesCreate (int size)
+.TQ
+void XcursorImagesDestroy (XcursorImages *images)
+Allocate and free arrays to hold multiple cursor images. On allocation,
+nimage is set to zero.
+
+.TP
+XcursorCursors *XcursorCursorsCreate (Display *dpy, int size)
+.TQ
+void XcursorCursorsDestroy (XcursorCursors *cursors)
+Allocate and free arrays to hold multiple cursors. On allocation,
+ncursor is set to zero, ref is set to one.
+
+.SS Reading and writing images.
+
+.TP
+XcursorImage *XcursorXcFileLoadImage (XcursorFile *file, int size)
+.TQ
+XcursorImages *XcursorXcFileLoadImages (XcursorFile *file, int size)
+.TQ
+XcursorImages *XcursorXcFileLoadAllImages (XcursorFile *file)
+.TQ
+XcursorBool XcursorXcFileLoad (XcursorFile *file, XcursorComments **commentsp, XcursorImages **imagesp)
+.TQ
+XcursorBool XcursorXcFileSave (XcursorFile *file, const XcursorComments *comments, const XcursorImages *images)
+These read and write cursors from an XcursorFile handle. After reading, the
+file pointer will be left at some random place in the file.
+
+.TP
+XcursorImage *XcursorFileLoadImage (FILE *file, int size)
+.TQ
+XcursorImages *XcursorFileLoadImages (FILE *file, int size)
+.TQ
+XcursorImages *XcursorFileLoadAllImages (FILE *file)
+.TQ
+XcursorBool XcursorFileLoad (FILE *file, XcursorComments **commentsp, XcursorImages **imagesp)
+.TQ
+XcursorBool XcursorFileSaveImages (FILE *file, const XcursorImages *images)
+.TQ
+XcursorBool XcursorFileSave (FILE * file, const XcursorComments *comments, const XcursorImages *images)
+These read and write cursors from a stdio FILE handle. Writing flushes
+before returning so that any errors should be detected.
+
+.TP
+XcursorImage *XcursorFilenameLoadImage (const char *filename, int size)
+.TQ
+XcursorImages *XcursorFilenameLoadImages (const char *filename, int size)
+.TQ
+XcursorImages *XcursorFilenameLoadAllImages (FILE *file)
+.TQ
+XcursorBool XcursorFilenameLoad (const char *file, XcursorComments **commentsp, XcursorImages **imagesp)
+.TQ
+XcursorBool XcursorFilenameSaveImages (const char *filename, const XcursorImages *images)
+.TQ
+XcursorBool XcursorFilenameSave (const char *file, const XcursorComments *comments, const XcursorImages *images)
+These parallel the stdio FILE interfaces above, but take filenames.
+
+.SS Reading library images
+.TP
+XcursorImage *XcursorLibraryLoadImage (const char *name, const char *theme, int size)
+.TQ
+XcursorImages *XcursorLibraryLoadImages (const char *name, const char *theme, int size)
+These search the library path, loading the first file found. If 'theme' is
+not NULL, these functions first try appending -theme to name and then
+name alone.
+
+.SS Cursor APIs
+
+.TP
+Cursor XcursorFilenameLoadCursor (Display *dpy, const char *file)
+.TQ
+XcursorCursors *XcursorFilenameLoadCursors (Display *dpy, const char *file)
+These load cursors from the specified file.
+
+.TP
+Cursor XcursorLibraryLoadCursor (Display *dpy, const char *name)
+.TQ
+XcursorCursors *XcursorLibraryLoadCursors (Display *dpy, const char *name)
+These load cursors using the specified library name. The theme
+comes from the display.
+
+.SS X Cursor Name APIs
+
+.TP
+XcursorImage *XcursorShapeLoadImage (unsigned int shape, const char *theme, int size)
+.TQ
+XcursorImages *XcursorShapeLoadImages (unsigned int shape, const char *theme, int size)
+These map 'shape' to a library name using the standard X cursor names and
+then load the images.
+
+.TP
+Cursor XcursorShapeLoadCursor (Display *dpy, unsigned int shape)
+.TQ
+XcursorCursors *XcursorShapeLoadCursors (Display *dpy, unsigned int shape)
+These map 'shape' to a library name and then load the cursors.
+
+.SS Display Information APIs
+
+.TP
+XcursorBool XcursorSupportsARGB (Display *dpy)
+Returns whether the display supports ARGB cursors or whether cursors will be
+mapped to a core X cursor.
+
+.TP
+XcursorBool XcursorSetDefaultSize (Display *dpy, int size)
+Sets the default size for cursors on the specified display. When loading
+cursors, those who's nominal size is closest to this size will be preferred.
+
+.TP
+int XcursorGetDefaultSize (Display *dpy)
+Gets the default cursor size.
+
+.TP
+XcursorBool
+XcursorSetTheme (Display *dpy, const char *theme)
+Sets the current theme name.
+
+char *
+XcursorGetTheme (Display *dpy)
+Gets the current theme name.
+
+.SH RESTRICTIONS
+.B Xcursor
+will probably change radically in the future; weak attempts will be made to
+retain some level of source-file compatibility.
+
+.SH AUTHOR
+Keith Packard
diff --git a/nx-X11/lib/Xcursor/autogen.sh b/nx-X11/lib/Xcursor/autogen.sh
new file mode 100755
index 000000000..904cd6746
--- /dev/null
+++ b/nx-X11/lib/Xcursor/autogen.sh
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+autoreconf -v --install || exit 1
+cd $ORIGDIR || exit $?
+
+$srcdir/configure --enable-maintainer-mode "$@"
diff --git a/nx-X11/lib/Xcursor/config-subst b/nx-X11/lib/Xcursor/config-subst
new file mode 100644
index 000000000..5907e0328
--- /dev/null
+++ b/nx-X11/lib/Xcursor/config-subst
@@ -0,0 +1,10 @@
+#!/bin/sh
+script=config-subst.$$
+trap "rm $script" 0
+rm -f $script
+for i in ${1+"$@"}; do
+ var="`echo "$i" | sed 's/=.*$//'`"
+ val="`echo "$i" | sed 's/^[^=]*=//'`"
+ echo "s;@$var@;$val;" >> $script
+done
+sed -f $script
diff --git a/nx-X11/lib/Xcursor/config.h b/nx-X11/lib/Xcursor/config.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/lib/Xcursor/config.h
diff --git a/nx-X11/lib/Xcursor/configure.ac b/nx-X11/lib/Xcursor/configure.ac
new file mode 100644
index 000000000..8ec0d2e71
--- /dev/null
+++ b/nx-X11/lib/Xcursor/configure.ac
@@ -0,0 +1,143 @@
+dnl
+dnl $Id: configure.ac,v 1.3 2005/06/29 18:46:53 daniels Exp $
+dnl
+dnl Copyright © 2003 Keith Packard
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this software and its
+dnl documentation for any purpose is hereby granted without fee, provided that
+dnl the above copyright notice appear in all copies and that both that
+dnl copyright notice and this permission notice appear in supporting
+dnl documentation, and that the name of Keith Packard not be used in
+dnl advertising or publicity pertaining to distribution of the software without
+dnl specific, written prior permission. Keith Packard makes no
+dnl representations about the suitability of this software for any purpose. It
+dnl is provided "as is" without express or implied warranty.
+dnl
+dnl KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+dnl EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+dnl PERFORMANCE OF THIS SOFTWARE.
+dnl
+dnl Process this file with autoconf to create configure.
+
+AC_PREREQ([2.57])
+dnl
+dnl This is the package version number, not the shared library
+dnl version. This same version number must appear in Xcursor.h
+dnl Yes, it is a pain to synchronize version numbers. Unfortunately, it's
+dnl not possible to extract the version number here from Xcursor.h
+dnl
+AC_INIT([libXcursor],1.1.4,[keithp@keithp.com],[libXcursor])
+AM_INIT_AUTOMAKE([dist-bzip2])
+AC_CONFIG_SRCDIR([Makefile.am])
+AM_MAINTAINER_MODE
+AM_CONFIG_HEADER(config.h)
+
+dnl libtool versioning
+
+LT_CURRENT=1
+LT_REVISION=2
+LT_AGE=0
+
+AC_SUBST(LT_CURRENT)
+AC_SUBST(LT_REVISION)
+LT_AGE=0
+
+LT_VERSION_INFO="$LT_CURRENT:$LT_REVISION:$LT_AGE"
+AC_SUBST(LT_VERSION_INFO)
+
+LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE`
+AC_SUBST(LT_CURRENT_MINUS_AGE)
+
+# Check for progs
+AC_PROG_CC
+AC_PROG_LIBTOOL
+
+# Check for X
+PKG_CHECK_MODULES(X, x11,
+ [x_found_with_pkgconfig=yes],
+ [x_found_with_pkgconfig=no])
+
+if test "$x_found_with_pkgconfig" = "no"
+then
+ AC_PATH_XTRA
+ X_LIBS="$X_LIBS -lX11"
+
+ if test "x$no_x" = "xyes"
+ then
+ AC_MSG_ERROR([X is required, but it was either disabled or not found.])
+ fi
+ # Check for XTHREADS
+
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $X_CFLAGS"
+ LIBS="$LIBS $X_LIBS"
+
+ AC_MSG_CHECKING([for XTHREADS in Xlib])
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
+ [[return XInitThreads() == 0 ? 0 : 1;]])],
+ [xthreads=no],
+ [xthreads=yes],
+ [xthreads=yes])
+
+ AC_MSG_RESULT($xthreads)
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ if test "x$xthreads" = "xyes"
+ then
+ X_CFLAGS="$X_CFLAGS -DXTHREADS"
+ fi
+
+ if test "x$no_x" = "xyes"
+ then
+ AC_MSG_ERROR([X is required, but it was either disabled or not found.])
+ fi
+fi
+
+AC_SUBST(X_CFLAGS)
+AC_SUBST(X_LIBS)
+
+PKG_CHECK_MODULES(XRENDER, xrender >= 0.8.2, [xrender_found_with_pkgconfig=yes],
+ [xrender_found_with_pkgconfig=no])
+case "$xrender_found_with_pkgconfig" in
+no)
+ PKG_CHECK_MODULES(XRENDER, xrender >= 0.8, [old_xrender_found_with_pkgconfig=yes],
+ [old_xrender_found_with_pkgconfig=no])
+ case "$old_xrender_found_with_pkgconfig" in
+ no)
+ # checks for X
+ AC_PATH_X
+
+ XRENDER_CFLAGS="-I$x_includes"
+ XRENDER_LIBS="-L$x_libraries -lXrender -lXext -lX11"
+
+ saved_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $XRENDER_CFLAGS"
+ AC_CHECK_HEADERS([X11/extensions/Xrender.h], [], [AC_MSG_ERROR([Xrender.h not found.])])
+ CPPFLAGS="$saved_CPPFLAGS"
+
+ saved_LIBS="$LIBS"
+ LIBS="$LIBS $XRENDER_LIBS"
+ AC_CHECK_FUNCS([XRenderCreateAnimCursor], [], [AC_MSG_ERROR([libXrender not found.])])
+ LIBS="$saved_LIBS"
+ ;;
+ yes)
+ XRENDER_LIBS="$XRENDER_LIBS -lXext -lX11"
+ ;;
+ esac
+ ;;
+esac
+PKG_CHECK_MODULES(XFIXES, xfixes, [AC_DEFINE_UNQUOTED(HAVE_XFIXES, 1, [Define to 1 if you have Xfixes])])
+
+AC_SUBST(XRENDER_LIBS)
+AC_SUBST(XRENDER_CFLAGS)
+
+AC_OUTPUT([Makefile
+ xcursor.pc])
diff --git a/nx-X11/lib/Xcursor/cursor.c b/nx-X11/lib/Xcursor/cursor.c
new file mode 100644
index 000000000..df9610625
--- /dev/null
+++ b/nx-X11/lib/Xcursor/cursor.c
@@ -0,0 +1,815 @@
+/*
+ * $Id: cursor.c,v 1.6 2005/07/03 07:00:56 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xcursorint.h"
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+
+XcursorCursors *
+XcursorCursorsCreate (Display *dpy, int size)
+{
+ XcursorCursors *cursors;
+
+ cursors = malloc (sizeof (XcursorCursors) +
+ size * sizeof (Cursor));
+ if (!cursors)
+ return 0;
+ cursors->ref = 1;
+ cursors->dpy = dpy;
+ cursors->ncursor = 0;
+ cursors->cursors = (Cursor *) (cursors + 1);
+ return cursors;
+}
+
+void
+XcursorCursorsDestroy (XcursorCursors *cursors)
+{
+ int n;
+
+ --cursors->ref;
+ if (cursors->ref > 0)
+ return;
+
+ for (n = 0; n < cursors->ncursor; n++)
+ XFreeCursor (cursors->dpy, cursors->cursors[n]);
+ free (cursors);
+}
+
+XcursorAnimate *
+XcursorAnimateCreate (XcursorCursors *cursors)
+{
+ XcursorAnimate *animate;
+
+ animate = malloc (sizeof (XcursorAnimate));
+ if (!animate)
+ return 0;
+ animate->cursors = cursors;
+ cursors->ref++;
+ animate->sequence = 0;
+ return animate;
+}
+
+void
+XcursorAnimateDestroy (XcursorAnimate *animate)
+{
+ XcursorCursorsDestroy (animate->cursors);
+ free (animate);
+}
+
+Cursor
+XcursorAnimateNext (XcursorAnimate *animate)
+{
+ Cursor cursor = animate->cursors->cursors[animate->sequence++];
+
+ if (animate->sequence >= animate->cursors->ncursor)
+ animate->sequence = 0;
+ return cursor;
+}
+
+static int
+nativeByteOrder (void)
+{
+ int x = 1;
+
+ return (*((char *) &x) == 1) ? LSBFirst : MSBFirst;
+}
+
+static XcursorUInt
+_XcursorPixelBrightness (XcursorPixel p)
+{
+ XcursorPixel alpha = p >> 24;
+ XcursorPixel r, g, b;
+
+ if (!alpha)
+ return 0;
+ r = ((p >> 8) & 0xff00) / alpha;
+ if (r > 0xff) r = 0xff;
+ g = ((p >> 0) & 0xff00) / alpha;
+ if (g > 0xff) g = 0xff;
+ b = ((p << 8) & 0xff00) / alpha;
+ if (b > 0xff) b = 0xff;
+ return (r * 153 + g * 301 + b * 58) >> 9;
+}
+
+static unsigned short
+_XcursorDivideAlpha (XcursorUInt value, XcursorUInt alpha)
+{
+ if (!alpha)
+ return 0;
+ value = value * 255 / alpha;
+ if (value > 255)
+ value = 255;
+ return value | (value << 8);
+}
+
+static void
+_XcursorPixelToColor (XcursorPixel p, XColor *color)
+{
+ XcursorPixel alpha = p >> 24;
+
+ color->pixel = 0;
+ color->red = _XcursorDivideAlpha ((p >> 16) & 0xff, alpha);
+ color->green = _XcursorDivideAlpha ((p >> 8) & 0xff, alpha);
+ color->blue = _XcursorDivideAlpha ((p >> 0) & 0xff, alpha);
+ color->flags = DoRed|DoGreen|DoBlue;
+}
+
+#undef DEBUG_IMAGE
+#ifdef DEBUG_IMAGE
+static void
+_XcursorDumpImage (XImage *image)
+{
+ FILE *f = fopen ("/tmp/images", "a");
+ int x, y;
+ if (!f)
+ return;
+ fprintf (f, "%d x %x\n", image->width, image->height);
+ for (y = 0; y < image->height; y++)
+ {
+ for (x = 0; x < image->width; x++)
+ fprintf (f, "%c", XGetPixel (image, x, y) ? '*' : ' ');
+ fprintf (f, "\n");
+ }
+ fflush (f);
+ fclose (f);
+}
+
+static void
+_XcursorDumpColor (XColor *color, char *name)
+{
+ FILE *f = fopen ("/tmp/images", "a");
+ fprintf (f, "%s: %x %x %x\n", name,
+ color->red, color->green, color->blue);
+ fflush (f);
+ fclose (f);
+}
+#endif
+
+static int
+_XcursorCompareRed (const void *a, const void *b)
+{
+ const XcursorPixel *ap = a, *bp = b;
+
+ return (int) (((*ap >> 16) & 0xff) - ((*bp >> 16) & 0xff));
+}
+
+static int
+_XcursorCompareGreen (const void *a, const void *b)
+{
+ const XcursorPixel *ap = a, *bp = b;
+
+ return (int) (((*ap >> 8) & 0xff) - ((*bp >> 8) & 0xff));
+}
+
+static int
+_XcursorCompareBlue (const void *a, const void *b)
+{
+ const XcursorPixel *ap = a, *bp = b;
+
+ return (int) (((*ap >> 0) & 0xff) - ((*bp >> 0) & 0xff));
+}
+
+static XcursorPixel
+_XcursorAverageColor (XcursorPixel *pixels, int npixels)
+{
+ XcursorPixel p;
+ XcursorPixel red, green, blue;
+ int n = npixels;
+
+ blue = green = red = 0;
+ while (n--)
+ {
+ p = *pixels++;
+ red += (p >> 16) & 0xff;
+ green += (p >> 8) & 0xff;
+ blue += (p >> 0) & 0xff;
+ }
+ if (!n)
+ return 0;
+ return (0xff << 24) | ((red/npixels) << 16) | ((green/npixels) << 8) | (blue/npixels);
+}
+
+typedef struct XcursorCoreCursor {
+ XImage *src_image;
+ XImage *msk_image;
+ XColor on_color;
+ XColor off_color;
+} XcursorCoreCursor;
+
+static Bool
+_XcursorHeckbertMedianCut (const XcursorImage *image, XcursorCoreCursor *core)
+{
+ XImage *src_image = core->src_image, *msk_image = core->msk_image;
+ int npixels = image->width * image->height;
+ int ncolors;
+ int n;
+ XcursorPixel *po, *pn, *pc;
+ XcursorPixel p;
+ XcursorPixel red, green, blue, alpha;
+ XcursorPixel max_red, min_red, max_green, min_green, max_blue, min_blue;
+ XcursorPixel *temp, *pixels, *colors;
+ int split;
+ XcursorPixel leftColor, centerColor, rightColor;
+ int (*compare) (const void *, const void *);
+ int x, y;
+
+ /*
+ * Temp space for converted image and converted colors
+ */
+ temp = malloc (npixels * sizeof (XcursorPixel) * 2);
+ if (!temp)
+ return False;
+
+ pixels = temp;
+ colors = pixels + npixels;
+
+ /*
+ * Convert to 2-value alpha and build
+ * array of opaque color values and an
+ */
+ po = image->pixels;
+ pn = pixels;
+ pc = colors;
+ max_blue = max_green = max_red = 0;
+ min_blue = min_green = min_red = 255;
+ n = npixels;
+ while (n--)
+ {
+ p = *po++;
+ alpha = (p >> 24) & 0xff;
+ red = (p >> 16) & 0xff;
+ green = (p >> 8) & 0xff;
+ blue = (p >> 0) & 0xff;
+ if (alpha >= 0x80)
+ {
+ red = red * 255 / alpha;
+ green = green * 255 / alpha;
+ blue = blue * 255 / alpha;
+ if (red < min_red) min_red = red;
+ if (red > max_red) max_red = red;
+ if (green < min_green) min_green = green;
+ if (green > max_green) max_green = green;
+ if (blue < min_blue) min_blue = blue;
+ if (blue > max_blue) max_blue = blue;
+ p = ((0xff << 24) | (red << 16) |
+ (green << 8) | (blue << 0));
+ *pc++ = p;
+ }
+ else
+ p = 0;
+ *pn++ = p;
+ }
+ ncolors = pc - colors;
+
+ /*
+ * Compute longest dimension and sort
+ */
+ if ((max_green - min_green) >= (max_red - min_red) &&
+ (max_green - min_green) >= (max_blue - min_blue))
+ compare = _XcursorCompareGreen;
+ else if ((max_red - min_red) >= (max_blue - min_blue))
+ compare = _XcursorCompareRed;
+ else
+ compare = _XcursorCompareBlue;
+ qsort (colors, ncolors, sizeof (XcursorPixel), compare);
+ /*
+ * Compute average colors on both sides of the cut
+ */
+ split = ncolors >> 1;
+ leftColor = _XcursorAverageColor (colors, split);
+ centerColor = colors[split];
+ rightColor = _XcursorAverageColor (colors + split, ncolors - split);
+ /*
+ * Select best color for each pixel
+ */
+ pn = pixels;
+ for (y = 0; y < image->height; y++)
+ for (x = 0; x < image->width; x++)
+ {
+ p = *pn++;
+ if (p & 0xff000000)
+ {
+ XPutPixel (msk_image, x, y, 1);
+ if ((*compare) (&p, &centerColor) >= 0)
+ XPutPixel (src_image, x, y, 0);
+ else
+ XPutPixel (src_image, x, y, 1);
+ }
+ else
+ {
+ XPutPixel (msk_image, x, y, 0);
+ XPutPixel (src_image, x, y, 0);
+ }
+ }
+ free (temp);
+ _XcursorPixelToColor (rightColor, &core->off_color);
+ _XcursorPixelToColor (leftColor, &core->on_color);
+ return True;
+}
+
+#if 0
+#define DITHER_DIM 4
+static XcursorPixel orderedDither[4][4] = {
+ { 1, 9, 3, 11 },
+ { 13, 5, 15, 7 },
+ { 4, 12, 2, 10 },
+ { 16, 8, 14, 6 }
+};
+#else
+#define DITHER_DIM 2
+static XcursorPixel orderedDither[2][2] = {
+ { 1, 3, },
+ { 4, 2, },
+};
+#endif
+
+#define DITHER_SIZE ((sizeof orderedDither / sizeof orderedDither[0][0]) + 1)
+
+static Bool
+_XcursorBayerOrderedDither (const XcursorImage *image, XcursorCoreCursor *core)
+{
+ int x, y;
+ XcursorPixel *pixel, p;
+ XcursorPixel a, i, d;
+
+ pixel = image->pixels;
+ for (y = 0; y < image->height; y++)
+ for (x = 0; x < image->width; x++)
+ {
+ p = *pixel++;
+ a = ((p >> 24) * DITHER_SIZE + 127) / 255;
+ i = (_XcursorPixelBrightness (p) * DITHER_SIZE + 127) / 255;
+ d = orderedDither[y&(DITHER_DIM-1)][x&(DITHER_DIM-1)];
+ if (a > d)
+ {
+ XPutPixel (core->msk_image, x, y, 1);
+ if (i > d)
+ XPutPixel (core->src_image, x, y, 0); /* white */
+ else
+ XPutPixel (core->src_image, x, y, 1); /* black */
+ }
+ else
+ {
+ XPutPixel (core->msk_image, x, y, 0);
+ XPutPixel (core->src_image, x, y, 0);
+ }
+ }
+ core->on_color.red = 0;
+ core->on_color.green = 0;
+ core->on_color.blue = 0;
+ core->off_color.red = 0xffff;
+ core->off_color.green = 0xffff;
+ core->off_color.blue = 0xffff;
+ return True;
+}
+
+static Bool
+_XcursorFloydSteinberg (const XcursorImage *image, XcursorCoreCursor *core)
+{
+ int *aPicture, *iPicture, *aP, *iP;
+ XcursorPixel *pixel, p;
+ int aR, iR, aA, iA;
+ int npixels = image->width * image->height;
+ int n;
+ int right = 1;
+ int belowLeft = image->width - 1;
+ int below = image->width;
+ int belowRight = image->width + 1;
+ int iError, aError;
+ int iErrorRight, aErrorRight;
+ int iErrorBelowLeft, aErrorBelowLeft;
+ int iErrorBelow, aErrorBelow;
+ int iErrorBelowRight, aErrorBelowRight;
+ int x, y;
+ int max_inten, min_inten, mean_inten;
+
+ iPicture = malloc (npixels * sizeof (int) * 2);
+ if (!iPicture)
+ return False;
+ aPicture = iPicture + npixels;
+
+ /*
+ * Compute raw gray and alpha arrays
+ */
+ pixel = image->pixels;
+ iP = iPicture;
+ aP = aPicture;
+ n = npixels;
+ max_inten = 0;
+ min_inten = 0xff;
+ while (n--)
+ {
+ p = *pixel++;
+ *aP++ = (int) (p >> 24);
+ iR = (int) _XcursorPixelBrightness (p);
+ if (iR > max_inten) max_inten = iR;
+ if (iR < min_inten) min_inten = iR;
+ *iP++ = iR;
+ }
+ /*
+ * Draw the image while diffusing the error
+ */
+ iP = iPicture;
+ aP = aPicture;
+ mean_inten = (max_inten + min_inten + 1) >> 1;
+ for (y = 0; y < image->height; y++)
+ for (x = 0; x < image->width; x++)
+ {
+ aR = *aP;
+ iR = *iP;
+ if (aR >= 0x80)
+ {
+ XPutPixel (core->msk_image, x, y, 1);
+ aA = 0xff;
+ }
+ else
+ {
+ XPutPixel (core->msk_image, x, y, 0);
+ aA = 0x00;
+ }
+ if (iR >= mean_inten)
+ {
+ XPutPixel (core->src_image, x, y, 0);
+ iA = max_inten;
+ }
+ else
+ {
+ XPutPixel (core->src_image, x, y, 1);
+ iA = min_inten;
+ }
+ iError = iR - iA;
+ aError = aR - aA;
+ iErrorRight = (iError * 7) >> 4;
+ iErrorBelowLeft = (iError * 3) >> 4;
+ iErrorBelow = (iError * 5) >> 4;
+ iErrorBelowRight = (iError - iErrorRight -
+ iErrorBelowLeft - iErrorBelow);
+ aErrorRight = (aError * 7) >> 4;
+ aErrorBelowLeft = (aError * 3) >> 4;
+ aErrorBelow = (aError * 5) >> 4;
+ aErrorBelowRight = (aError - aErrorRight -
+ aErrorBelowLeft - aErrorBelow);
+ if (x < image->width - 1)
+ {
+ iP[right] += iErrorRight;
+ aP[right] += aErrorRight;
+ }
+ if (y < image->height - 1)
+ {
+ if (x)
+ {
+ iP[belowLeft] += iErrorBelowLeft;
+ aP[belowLeft] += aErrorBelowLeft;
+ }
+ iP[below] += iErrorBelow;
+ aP[below] += aErrorBelow;
+ if (x < image->width - 1)
+ {
+ iP[belowRight] += iErrorBelowRight;
+ aP[belowRight] += aErrorBelowRight;
+ }
+ }
+ aP++;
+ iP++;
+ }
+ free (iPicture);
+ core->on_color.red =
+ core->on_color.green =
+ core->on_color.blue = (min_inten | min_inten << 8);
+ core->off_color.red =
+ core->off_color.green =
+ core->off_color.blue = (max_inten | max_inten << 8);
+ return True;
+}
+
+static Bool
+_XcursorThreshold (const XcursorImage *image, XcursorCoreCursor *core)
+{
+ XcursorPixel *pixel, p;
+ int x, y;
+
+ /*
+ * Draw the image, picking black for dark pixels and white for light
+ */
+ pixel = image->pixels;
+ for (y = 0; y < image->height; y++)
+ for (x = 0; x < image->width; x++)
+ {
+ p = *pixel++;
+ if ((p >> 24) >= 0x80)
+ {
+ XPutPixel (core->msk_image, x, y, 1);
+ if (_XcursorPixelBrightness (p) > 0x80)
+ XPutPixel (core->src_image, x, y, 0);
+ else
+ XPutPixel (core->src_image, x, y, 1);
+ }
+ else
+ {
+ XPutPixel (core->msk_image, x, y, 0);
+ XPutPixel (core->src_image, x, y, 0);
+ }
+ }
+ core->on_color.red =
+ core->on_color.green =
+ core->on_color.blue = 0;
+ core->off_color.red =
+ core->off_color.green =
+ core->off_color.blue = 0xffff;
+ return True;
+}
+
+Cursor
+XcursorImageLoadCursor (Display *dpy, const XcursorImage *image)
+{
+ Cursor cursor;
+
+#if RENDER_MAJOR > 0 || RENDER_MINOR >= 5
+ if (XcursorSupportsARGB (dpy))
+ {
+ XImage ximage;
+ int screen = DefaultScreen (dpy);
+ Pixmap pixmap;
+ Picture picture;
+ GC gc;
+ XRenderPictFormat *format;
+
+ ximage.width = image->width;
+ ximage.height = image->height;
+ ximage.xoffset = 0;
+ ximage.format = ZPixmap;
+ ximage.data = (char *) image->pixels;
+ ximage.byte_order = nativeByteOrder ();
+ ximage.bitmap_unit = 32;
+ ximage.bitmap_bit_order = ximage.byte_order;
+ ximage.bitmap_pad = 32;
+ ximage.depth = 32;
+ ximage.bits_per_pixel = 32;
+ ximage.bytes_per_line = image->width * 4;
+ ximage.red_mask = 0xff0000;
+ ximage.green_mask = 0x00ff00;
+ ximage.blue_mask = 0x0000ff;
+ ximage.obdata = 0;
+ if (!XInitImage (&ximage))
+ return None;
+ pixmap = XCreatePixmap (dpy, RootWindow (dpy, screen),
+ image->width, image->height, 32);
+ gc = XCreateGC (dpy, pixmap, 0, 0);
+ XPutImage (dpy, pixmap, gc, &ximage,
+ 0, 0, 0, 0, image->width, image->height);
+ XFreeGC (dpy, gc);
+ format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
+ picture = XRenderCreatePicture (dpy, pixmap, format, 0, 0);
+ XFreePixmap (dpy, pixmap);
+ cursor = XRenderCreateCursor (dpy, picture,
+ image->xhot, image->yhot);
+ XRenderFreePicture (dpy, picture);
+ }
+ else
+#endif
+ {
+ XcursorDisplayInfo *info = _XcursorGetDisplayInfo (dpy);
+ int screen = DefaultScreen (dpy);
+ XcursorCoreCursor core;
+ Pixmap src_pixmap, msk_pixmap;
+ GC gc;
+ XGCValues gcv;
+
+ core.src_image = XCreateImage (dpy, 0, 1, ZPixmap,
+ 0, 0, image->width, image->height,
+ 32, 0);
+ core.src_image->data = Xmalloc (image->height *
+ core.src_image->bytes_per_line);
+ core.msk_image = XCreateImage (dpy, 0, 1, ZPixmap,
+ 0, 0, image->width, image->height,
+ 32, 0);
+ core.msk_image->data = Xmalloc (image->height *
+ core.msk_image->bytes_per_line);
+
+ switch (info->dither) {
+ case XcursorDitherThreshold:
+ if (!_XcursorThreshold (image, &core))
+ return 0;
+ break;
+ case XcursorDitherMedian:
+ if (!_XcursorHeckbertMedianCut (image, &core))
+ return 0;
+ break;
+ case XcursorDitherOrdered:
+ if (!_XcursorBayerOrderedDither (image, &core))
+ return 0;
+ break;
+ case XcursorDitherDiffuse:
+ if (!_XcursorFloydSteinberg (image, &core))
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+
+ /*
+ * Create the cursor
+ */
+ src_pixmap = XCreatePixmap (dpy, RootWindow (dpy, screen),
+ image->width, image->height, 1);
+ msk_pixmap = XCreatePixmap (dpy, RootWindow (dpy, screen),
+ image->width, image->height, 1);
+ gcv.foreground = 1;
+ gcv.background = 0;
+ gc = XCreateGC (dpy, src_pixmap,
+ GCForeground|GCBackground,
+ &gcv);
+ XPutImage (dpy, src_pixmap, gc, core.src_image,
+ 0, 0, 0, 0, image->width, image->height);
+
+ XPutImage (dpy, msk_pixmap, gc, core.msk_image,
+ 0, 0, 0, 0, image->width, image->height);
+ XFreeGC (dpy, gc);
+
+#ifdef DEBUG_IMAGE
+ _XcursorDumpColor (&core.on_color, "on_color");
+ _XcursorDumpColor (&core.off_color, "off_color");
+ _XcursorDumpImage (core.src_image);
+ _XcursorDumpImage (core.msk_image);
+#endif
+ XDestroyImage (core.src_image);
+ XDestroyImage (core.msk_image);
+
+ cursor = XCreatePixmapCursor (dpy, src_pixmap, msk_pixmap,
+ &core.on_color, &core.off_color,
+ image->xhot, image->yhot);
+ XFreePixmap (dpy, src_pixmap);
+ XFreePixmap (dpy, msk_pixmap);
+ }
+ return cursor;
+}
+
+XcursorCursors *
+XcursorImagesLoadCursors (Display *dpy, const XcursorImages *images)
+{
+ XcursorCursors *cursors = XcursorCursorsCreate (dpy, images->nimage);
+ int n;
+
+ if (!cursors)
+ return 0;
+ for (n = 0; n < images->nimage; n++)
+ {
+ cursors->cursors[n] = XcursorImageLoadCursor (dpy, images->images[n]);
+ if (!cursors->cursors[n])
+ {
+ XcursorCursorsDestroy (cursors);
+ return 0;
+ }
+ cursors->ncursor++;
+ }
+ return cursors;
+}
+
+Cursor
+XcursorImagesLoadCursor (Display *dpy, const XcursorImages *images)
+{
+ Cursor cursor;
+ if (images->nimage == 1 || !XcursorSupportsAnim (dpy))
+ cursor = XcursorImageLoadCursor (dpy, images->images[0]);
+ else
+ {
+ XcursorCursors *cursors = XcursorImagesLoadCursors (dpy, images);
+ XAnimCursor *anim;
+ int n;
+
+ if (!cursors)
+ return 0;
+ anim = malloc (cursors->ncursor * sizeof (XAnimCursor));
+ if (!anim)
+ {
+ XcursorCursorsDestroy (cursors);
+ return 0;
+ }
+ for (n = 0; n < cursors->ncursor; n++)
+ {
+ anim[n].cursor = cursors->cursors[n];
+ anim[n].delay = images->images[n]->delay;
+ }
+ cursor = XRenderCreateAnimCursor (dpy, cursors->ncursor, anim);
+ XcursorCursorsDestroy(cursors);
+ free (anim);
+ }
+#if defined HAVE_XFIXES && XFIXES_MAJOR >= 2
+ if (images->name)
+ XFixesSetCursorName (dpy, cursor, images->name);
+#endif
+ return cursor;
+}
+
+
+Cursor
+XcursorFilenameLoadCursor (Display *dpy, const char *file)
+{
+ int size = XcursorGetDefaultSize (dpy);
+ XcursorImages *images = XcursorFilenameLoadImages (file, size);
+ Cursor cursor;
+
+ if (!images)
+ return None;
+ cursor = XcursorImagesLoadCursor (dpy, images);
+ XcursorImagesDestroy (images);
+ return cursor;
+}
+
+XcursorCursors *
+XcursorFilenameLoadCursors (Display *dpy, const char *file)
+{
+ int size = XcursorGetDefaultSize (dpy);
+ XcursorImages *images = XcursorFilenameLoadImages (file, size);
+ XcursorCursors *cursors;
+
+ if (!images)
+ return 0;
+ cursors = XcursorImagesLoadCursors (dpy, images);
+ XcursorImagesDestroy (images);
+ return cursors;
+}
+
+/*
+ * Stolen from XCreateGlyphCursor (which we cruelly override)
+ */
+
+Cursor
+_XcursorCreateGlyphCursor(Display *dpy,
+ Font source_font,
+ Font mask_font,
+ unsigned int source_char,
+ unsigned int mask_char,
+ XColor _Xconst *foreground,
+ XColor _Xconst *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);
+}
+
+/*
+ * Stolen from XCreateFontCursor (which we cruelly override)
+ */
+
+Cursor
+_XcursorCreateFontCursor (Display *dpy, unsigned int shape)
+{
+ static XColor _Xconst foreground = { 0, 0, 0, 0 }; /* black */
+ static XColor _Xconst background = { 0, 65535, 65535, 65535 }; /* white */
+
+ /*
+ * 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 _XcursorCreateGlyphCursor (dpy, dpy->cursor_font, dpy->cursor_font,
+ shape, shape + 1, &foreground, &background);
+}
+
diff --git a/nx-X11/lib/Xcursor/display.c b/nx-X11/lib/Xcursor/display.c
new file mode 100644
index 000000000..ef941257f
--- /dev/null
+++ b/nx-X11/lib/Xcursor/display.c
@@ -0,0 +1,382 @@
+/*
+ * $Id: display.c,v 1.6 2005/10/19 22:26:55 ajax Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xcursorint.h"
+#include <X11/Xlibint.h>
+#include <ctype.h>
+
+static XcursorDisplayInfo *_XcursorDisplayInfo;
+
+static void
+_XcursorFreeDisplayInfo (XcursorDisplayInfo *info)
+{
+ if (info->theme)
+ free (info->theme);
+
+ if (info->theme_from_config)
+ free (info->theme_from_config);
+
+ free (info);
+}
+
+static int
+_XcursorCloseDisplay (Display *dpy, XExtCodes *codes)
+{
+ XcursorDisplayInfo *info, **prev;
+
+ /*
+ * Unhook from the global list
+ */
+ _XLockMutex (_Xglobal_lock);
+ for (prev = &_XcursorDisplayInfo; (info = *prev); prev = &(*prev)->next)
+ if (info->display == dpy)
+ {
+ *prev = info->next;
+ break;
+ }
+ _XUnlockMutex (_Xglobal_lock);
+
+ _XcursorFreeDisplayInfo (info);
+ return 0;
+}
+
+static int
+_XcursorDefaultParseBool (char *v)
+{
+ char c0, c1;
+
+ c0 = *v;
+ if (isupper ((int)c0))
+ c0 = tolower (c0);
+ if (c0 == 't' || c0 == 'y' || c0 == '1')
+ return 1;
+ if (c0 == 'f' || c0 == 'n' || c0 == '0')
+ return 0;
+ if (c0 == 'o')
+ {
+ c1 = v[1];
+ if (isupper ((int)c1))
+ c1 = tolower (c1);
+ if (c1 == 'n')
+ return 1;
+ if (c1 == 'f')
+ return 0;
+ }
+ return -1;
+}
+
+XcursorDisplayInfo *
+_XcursorGetDisplayInfo (Display *dpy)
+{
+ XcursorDisplayInfo *info, **prev, *old;
+ int event_base, error_base;
+ int major, minor;
+ char *v;
+ int i;
+
+ _XLockMutex (_Xglobal_lock);
+ for (prev = &_XcursorDisplayInfo; (info = *prev); prev = &(*prev)->next)
+ {
+ if (info->display == dpy)
+ {
+ /*
+ * MRU the list
+ */
+ if (prev != &_XcursorDisplayInfo)
+ {
+ *prev = info->next;
+ info->next = _XcursorDisplayInfo;
+ _XcursorDisplayInfo = info;
+ }
+ break;
+ }
+ }
+ _XUnlockMutex (_Xglobal_lock);
+ if (info)
+ return info;
+ info = (XcursorDisplayInfo *) malloc (sizeof (XcursorDisplayInfo));
+ if (!info)
+ return 0;
+ info->next = 0;
+ info->display = dpy;
+
+ info->codes = XAddExtension (dpy);
+ if (!info->codes)
+ {
+ free (info);
+ return 0;
+ }
+ (void) XESetCloseDisplay (dpy, info->codes->extension, _XcursorCloseDisplay);
+
+ /*
+ * Check whether the display supports the Render CreateCursor request
+ */
+ info->has_render_cursor = XcursorFalse;
+ info->has_anim_cursor = XcursorFalse;
+ if (XRenderQueryExtension (dpy, &event_base, &error_base) &&
+ XRenderQueryVersion (dpy, &major, &minor))
+ {
+ if (major > 0 || minor >= 5)
+ {
+ info->has_render_cursor = XcursorTrue;
+ v = getenv ("XCURSOR_CORE");
+ if (!v)
+ v = XGetDefault (dpy, "Xcursor", "core");
+ if (v && _XcursorDefaultParseBool (v) == 1)
+ info->has_render_cursor = XcursorFalse;
+ }
+ if (info->has_render_cursor && (major > 0 || minor >= 8))
+ {
+ info->has_anim_cursor = XcursorTrue;
+ v = getenv ("XCURSOR_ANIM");
+ if (!v)
+ v = XGetDefault (dpy, "Xcursor", "anim");
+ if (v && _XcursorDefaultParseBool (v) == 0)
+ info->has_anim_cursor = XcursorFalse;
+ }
+ }
+
+ info->size = 0;
+
+ /*
+ * Get desired cursor size
+ */
+ v = getenv ("XCURSOR_SIZE");
+ if (!v)
+ v = XGetDefault (dpy, "Xcursor", "size");
+ if (v)
+ info->size = atoi (v);
+
+ /*
+ * Use the Xft size to guess a size; make cursors 16 "points" tall
+ */
+ if (info->size == 0)
+ {
+ int dpi = 0;
+ v = XGetDefault (dpy, "Xft", "dpi");
+ if (v)
+ dpi = atoi (v);
+ if (dpi)
+ info->size = dpi * 16 / 72;
+ }
+
+ /*
+ * Use display size to guess a size
+ */
+ if (info->size == 0)
+ {
+ int dim;
+
+ if (DisplayHeight (dpy, DefaultScreen (dpy)) <
+ DisplayWidth (dpy, DefaultScreen (dpy)))
+ dim = DisplayHeight (dpy, DefaultScreen (dpy));
+ else
+ dim = DisplayWidth (dpy, DefaultScreen (dpy));
+ /*
+ * 16 pixels on a display of dimension 768
+ */
+ info->size = dim / 48;
+ }
+
+ info->theme = 0;
+ info->theme_from_config = 0;
+
+ /*
+ * Get the desired theme
+ */
+ v = getenv ("XCURSOR_THEME");
+ if (!v)
+ v = XGetDefault (dpy, "Xcursor", "theme");
+ if (v)
+ {
+ int len;
+
+ len = strlen (v) + 1;
+
+ info->theme = malloc (len);
+ if (info->theme)
+ strcpy (info->theme, v);
+
+ info->theme_from_config = malloc (len);
+ if (info->theme_from_config)
+ strcpy (info->theme_from_config, v);
+ }
+
+ /*
+ * Get the desired dither
+ */
+ info->dither = XcursorDitherThreshold;
+ v = getenv ("XCURSOR_DITHER");
+ if (!v)
+ v = XGetDefault (dpy, "Xcursor", "dither");
+ if (v)
+ {
+ if (!strcmp (v, "threshold"))
+ info->dither = XcursorDitherThreshold;
+ if (!strcmp (v, "median"))
+ info->dither = XcursorDitherMedian;
+ if (!strcmp (v, "ordered"))
+ info->dither = XcursorDitherOrdered;
+ if (!strcmp (v, "diffuse"))
+ info->dither = XcursorDitherDiffuse;
+ }
+
+ info->theme_core = False;
+ /*
+ * Find out if core cursors should
+ * be themed
+ */
+ v = getenv ("XCURSOR_THEME_CORE");
+ if (!v)
+ v = XGetDefault (dpy, "Xcursor", "theme_core");
+ if (v)
+ {
+ i = _XcursorDefaultParseBool (v);
+ if (i >= 0)
+ info->theme_core = i;
+ }
+
+ info->fonts = 0;
+ for (i = 0; i < NUM_BITMAPS; i++)
+ info->bitmaps[i].bitmap = None;
+
+ /*
+ * Link new info info list, making sure another
+ * thread hasn't inserted something into the list while
+ * this one was busy setting up the data
+ */
+ _XLockMutex (_Xglobal_lock);
+ for (old = _XcursorDisplayInfo; old; old = old->next)
+ if (old->display == dpy)
+ break;
+ if (old)
+ {
+ _XcursorFreeDisplayInfo (info);
+ info = old;
+ }
+ else
+ {
+ info->next = _XcursorDisplayInfo;
+ _XcursorDisplayInfo = info;
+ }
+ _XUnlockMutex (_Xglobal_lock);
+
+ return info;
+}
+
+XcursorBool
+XcursorSupportsARGB (Display *dpy)
+{
+ XcursorDisplayInfo *info = _XcursorGetDisplayInfo (dpy);
+
+ return info && info->has_render_cursor;
+}
+
+XcursorBool
+XcursorSupportsAnim (Display *dpy)
+{
+ XcursorDisplayInfo *info = _XcursorGetDisplayInfo (dpy);
+
+ return info && info->has_anim_cursor;
+}
+
+XcursorBool
+XcursorSetDefaultSize (Display *dpy, int size)
+{
+ XcursorDisplayInfo *info = _XcursorGetDisplayInfo (dpy);
+
+ if (!info)
+ return XcursorFalse;
+ info->size = size;
+ return XcursorTrue;
+}
+
+int
+XcursorGetDefaultSize (Display *dpy)
+{
+ XcursorDisplayInfo *info = _XcursorGetDisplayInfo (dpy);
+
+ if (!info)
+ return 0;
+ return info->size;
+}
+
+XcursorBool
+XcursorSetTheme (Display *dpy, const char *theme)
+{
+ XcursorDisplayInfo *info = _XcursorGetDisplayInfo (dpy);
+ char *copy;
+
+ if (!info)
+ return XcursorFalse;
+
+ if (!theme)
+ theme = info->theme_from_config;
+
+ if (theme)
+ {
+ copy = malloc (strlen (theme) + 1);
+ if (!copy)
+ return XcursorFalse;
+ strcpy (copy, theme);
+ }
+ else
+ copy = 0;
+ if (info->theme)
+ free (info->theme);
+ info->theme = copy;
+ return XcursorTrue;
+}
+
+char *
+XcursorGetTheme (Display *dpy)
+{
+ XcursorDisplayInfo *info = _XcursorGetDisplayInfo (dpy);
+
+ if (!info)
+ return 0;
+ return info->theme;
+}
+
+XcursorBool
+XcursorGetThemeCore (Display *dpy)
+{
+ XcursorDisplayInfo *info = _XcursorGetDisplayInfo (dpy);
+
+ if (!info)
+ return XcursorFalse;
+ return info->theme_core;
+
+}
+
+XcursorBool
+XcursorSetThemeCore (Display *dpy, XcursorBool theme_core)
+{
+ XcursorDisplayInfo *info = _XcursorGetDisplayInfo (dpy);
+
+ if (!info)
+ return XcursorFalse;
+ info->theme_core = theme_core;
+ return XcursorTrue;
+}
diff --git a/nx-X11/lib/Xcursor/file.c b/nx-X11/lib/Xcursor/file.c
new file mode 100644
index 000000000..175676cc3
--- /dev/null
+++ b/nx-X11/lib/Xcursor/file.c
@@ -0,0 +1,1101 @@
+/*
+ * $Id: file.c,v 1.5 2005/07/03 07:00:56 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xcursorint.h"
+#include <stdlib.h>
+#include <string.h>
+
+XcursorImage *
+XcursorImageCreate (int width, int height)
+{
+ XcursorImage *image;
+
+ image = malloc (sizeof (XcursorImage) +
+ width * height * sizeof (XcursorPixel));
+ if (!image)
+ return 0;
+ image->version = XCURSOR_IMAGE_VERSION;
+ image->pixels = (XcursorPixel *) (image + 1);
+ image->size = width > height ? width : height;
+ image->width = width;
+ image->height = height;
+ image->delay = 0;
+ return image;
+}
+
+void
+XcursorImageDestroy (XcursorImage *image)
+{
+ if (image)
+ free (image);
+}
+
+XcursorImages *
+XcursorImagesCreate (int size)
+{
+ XcursorImages *images;
+
+ images = malloc (sizeof (XcursorImages) +
+ size * sizeof (XcursorImage *));
+ if (!images)
+ return 0;
+ images->nimage = 0;
+ images->images = (XcursorImage **) (images + 1);
+ images->name = 0;
+ return images;
+}
+
+void
+XcursorImagesDestroy (XcursorImages *images)
+{
+ int n;
+
+ if (!images)
+ return;
+
+ for (n = 0; n < images->nimage; n++)
+ XcursorImageDestroy (images->images[n]);
+ if (images->name)
+ free (images->name);
+ free (images);
+}
+
+void
+XcursorImagesSetName (XcursorImages *images, const char *name)
+{
+ char *new;
+
+ if (!images || !name)
+ return;
+
+ new = malloc (strlen (name) + 1);
+
+ if (!new)
+ return;
+
+ strcpy (new, name);
+ if (images->name)
+ free (images->name);
+ images->name = new;
+}
+
+XcursorComment *
+XcursorCommentCreate (XcursorUInt comment_type, int length)
+{
+ XcursorComment *comment;
+
+ if (length > XCURSOR_COMMENT_MAX_LEN)
+ return 0;
+
+ comment = malloc (sizeof (XcursorComment) + length + 1);
+ if (!comment)
+ return 0;
+ comment->version = XCURSOR_COMMENT_VERSION;
+ comment->comment_type = comment_type;
+ comment->comment = (char *) (comment + 1);
+ comment->comment[0] = '\0';
+ return comment;
+}
+
+void
+XcursorCommentDestroy (XcursorComment *comment)
+{
+ if (!comment)
+ free (comment);
+}
+
+XcursorComments *
+XcursorCommentsCreate (int size)
+{
+ XcursorComments *comments;
+
+ comments = malloc (sizeof (XcursorComments) +
+ size * sizeof (XcursorComment *));
+ if (!comments)
+ return 0;
+ comments->ncomment = 0;
+ comments->comments = (XcursorComment **) (comments + 1);
+ return comments;
+}
+
+void
+XcursorCommentsDestroy (XcursorComments *comments)
+{
+ int n;
+
+ if (!comments)
+ return;
+
+ for (n = 0; n < comments->ncomment; n++)
+ XcursorCommentDestroy (comments->comments[n]);
+ free (comments);
+}
+
+static XcursorBool
+_XcursorReadUInt (XcursorFile *file, XcursorUInt *u)
+{
+ unsigned char bytes[4];
+
+ if (!file || !u)
+ return XcursorFalse;
+
+ if ((*file->read) (file, bytes, 4) != 4)
+ return XcursorFalse;
+ *u = ((bytes[0] << 0) |
+ (bytes[1] << 8) |
+ (bytes[2] << 16) |
+ (bytes[3] << 24));
+ return XcursorTrue;
+}
+
+static XcursorBool
+_XcursorReadBytes (XcursorFile *file, char *bytes, int length)
+{
+ if (!file || !bytes || (*file->read) (file, (unsigned char *) bytes, length) != length)
+ return XcursorFalse;
+ return XcursorTrue;
+}
+
+static XcursorBool
+_XcursorWriteUInt (XcursorFile *file, XcursorUInt u)
+{
+ unsigned char bytes[4];
+
+ if (!file)
+ return XcursorFalse;
+
+ bytes[0] = u;
+ bytes[1] = u >> 8;
+ bytes[2] = u >> 16;
+ bytes[3] = u >> 24;
+ if ((*file->write) (file, bytes, 4) != 4)
+ return XcursorFalse;
+ return XcursorTrue;
+}
+
+static XcursorBool
+_XcursorWriteBytes (XcursorFile *file, char *bytes, int length)
+{
+ if (!file || !bytes || (*file->write) (file, (unsigned char *) bytes, length) != length)
+ return XcursorFalse;
+ return XcursorTrue;
+}
+
+static void
+_XcursorFileHeaderDestroy (XcursorFileHeader *fileHeader)
+{
+ if (!fileHeader)
+ free (fileHeader);
+}
+
+static XcursorFileHeader *
+_XcursorFileHeaderCreate (int ntoc)
+{
+ XcursorFileHeader *fileHeader;
+
+ if (ntoc > 0x10000)
+ return 0;
+ fileHeader = malloc (sizeof (XcursorFileHeader) +
+ ntoc * sizeof (XcursorFileToc));
+ if (!fileHeader)
+ return 0;
+ fileHeader->magic = XCURSOR_MAGIC;
+ fileHeader->header = XCURSOR_FILE_HEADER_LEN;
+ fileHeader->version = XCURSOR_FILE_VERSION;
+ fileHeader->ntoc = ntoc;
+ fileHeader->tocs = (XcursorFileToc *) (fileHeader + 1);
+ return fileHeader;
+}
+
+static XcursorFileHeader *
+_XcursorReadFileHeader (XcursorFile *file)
+{
+ XcursorFileHeader head, *fileHeader;
+ XcursorUInt skip;
+ int n;
+
+ if (!file)
+ return NULL;
+
+ if (!_XcursorReadUInt (file, &head.magic))
+ return 0;
+ if (head.magic != XCURSOR_MAGIC)
+ return 0;
+ if (!_XcursorReadUInt (file, &head.header))
+ return 0;
+ if (!_XcursorReadUInt (file, &head.version))
+ return 0;
+ if (!_XcursorReadUInt (file, &head.ntoc))
+ return 0;
+ skip = head.header - XCURSOR_FILE_HEADER_LEN;
+ if (skip)
+ if ((*file->seek) (file, skip, SEEK_CUR) == EOF)
+ return 0;
+ fileHeader = _XcursorFileHeaderCreate (head.ntoc);
+ if (!fileHeader)
+ return 0;
+ fileHeader->magic = head.magic;
+ fileHeader->header = head.header;
+ fileHeader->version = head.version;
+ fileHeader->ntoc = head.ntoc;
+ for (n = 0; n < fileHeader->ntoc; n++)
+ {
+ if (!_XcursorReadUInt (file, &fileHeader->tocs[n].type))
+ break;
+ if (!_XcursorReadUInt (file, &fileHeader->tocs[n].subtype))
+ break;
+ if (!_XcursorReadUInt (file, &fileHeader->tocs[n].position))
+ break;
+ }
+ if (n != fileHeader->ntoc)
+ {
+ _XcursorFileHeaderDestroy (fileHeader);
+ return 0;
+ }
+ return fileHeader;
+}
+
+static XcursorUInt
+_XcursorFileHeaderLength (XcursorFileHeader *fileHeader)
+{
+ return (XCURSOR_FILE_HEADER_LEN +
+ fileHeader->ntoc * XCURSOR_FILE_TOC_LEN);
+}
+
+static XcursorBool
+_XcursorWriteFileHeader (XcursorFile *file, XcursorFileHeader *fileHeader)
+{
+ int toc;
+
+ if (!file || !fileHeader)
+ return XcursorFalse;
+
+ if (!_XcursorWriteUInt (file, fileHeader->magic))
+ return XcursorFalse;
+ if (!_XcursorWriteUInt (file, fileHeader->header))
+ return XcursorFalse;
+ if (!_XcursorWriteUInt (file, fileHeader->version))
+ return XcursorFalse;
+ if (!_XcursorWriteUInt (file, fileHeader->ntoc))
+ return XcursorFalse;
+ for (toc = 0; toc < fileHeader->ntoc; toc++)
+ {
+ if (!_XcursorWriteUInt (file, fileHeader->tocs[toc].type))
+ return XcursorFalse;
+ if (!_XcursorWriteUInt (file, fileHeader->tocs[toc].subtype))
+ return XcursorFalse;
+ if (!_XcursorWriteUInt (file, fileHeader->tocs[toc].position))
+ return XcursorFalse;
+ }
+ return XcursorTrue;
+}
+
+static XcursorBool
+_XcursorSeekToToc (XcursorFile *file,
+ XcursorFileHeader *fileHeader,
+ int toc)
+{
+ if (!file || !fileHeader || \
+ (*file->seek) (file, fileHeader->tocs[toc].position, SEEK_SET) == EOF)
+ return XcursorFalse;
+ return XcursorTrue;
+}
+
+static XcursorBool
+_XcursorFileReadChunkHeader (XcursorFile *file,
+ XcursorFileHeader *fileHeader,
+ int toc,
+ XcursorChunkHeader *chunkHeader)
+{
+ if (!file || !fileHeader || !chunkHeader)
+ return XcursorFalse;
+ if (!_XcursorSeekToToc (file, fileHeader, toc))
+ return XcursorFalse;
+ if (!_XcursorReadUInt (file, &chunkHeader->header))
+ return XcursorFalse;
+ if (!_XcursorReadUInt (file, &chunkHeader->type))
+ return XcursorFalse;
+ if (!_XcursorReadUInt (file, &chunkHeader->subtype))
+ return XcursorFalse;
+ if (!_XcursorReadUInt (file, &chunkHeader->version))
+ return XcursorFalse;
+ /* sanity check */
+ if (chunkHeader->type != fileHeader->tocs[toc].type ||
+ chunkHeader->subtype != fileHeader->tocs[toc].subtype)
+ return XcursorFalse;
+ return XcursorTrue;
+}
+
+static XcursorBool
+_XcursorFileWriteChunkHeader (XcursorFile *file,
+ XcursorFileHeader *fileHeader,
+ int toc,
+ XcursorChunkHeader *chunkHeader)
+{
+ if (!file || !fileHeader || !chunkHeader)
+ return XcursorFalse;
+ if (!_XcursorSeekToToc (file, fileHeader, toc))
+ return XcursorFalse;
+ if (!_XcursorWriteUInt (file, chunkHeader->header))
+ return XcursorFalse;
+ if (!_XcursorWriteUInt (file, chunkHeader->type))
+ return XcursorFalse;
+ if (!_XcursorWriteUInt (file, chunkHeader->subtype))
+ return XcursorFalse;
+ if (!_XcursorWriteUInt (file, chunkHeader->version))
+ return XcursorFalse;
+ return XcursorTrue;
+}
+
+#define dist(a,b) ((a) > (b) ? (a) - (b) : (b) - (a))
+
+static XcursorDim
+_XcursorFindBestSize (XcursorFileHeader *fileHeader,
+ XcursorDim size,
+ int *nsizesp)
+{
+ int n;
+ int nsizes = 0;
+ XcursorDim bestSize = 0;
+ XcursorDim thisSize;
+
+ if (!fileHeader || !nsizesp)
+ return 0;
+
+ for (n = 0; n < fileHeader->ntoc; n++)
+ {
+ if (fileHeader->tocs[n].type != XCURSOR_IMAGE_TYPE)
+ continue;
+ thisSize = fileHeader->tocs[n].subtype;
+ if (!bestSize || dist (thisSize, size) < dist (bestSize, size))
+ {
+ bestSize = thisSize;
+ nsizes = 1;
+ }
+ else if (thisSize == bestSize)
+ nsizes++;
+ }
+ *nsizesp = nsizes;
+ return bestSize;
+}
+
+static int
+_XcursorFindImageToc (XcursorFileHeader *fileHeader,
+ XcursorDim size,
+ int count)
+{
+ int toc;
+ XcursorDim thisSize;
+
+ if (!fileHeader)
+ return 0;
+
+ for (toc = 0; toc < fileHeader->ntoc; toc++)
+ {
+ if (fileHeader->tocs[toc].type != XCURSOR_IMAGE_TYPE)
+ continue;
+ thisSize = fileHeader->tocs[toc].subtype;
+ if (thisSize != size)
+ continue;
+ if (!count)
+ break;
+ count--;
+ }
+ if (toc == fileHeader->ntoc)
+ return -1;
+ return toc;
+}
+
+static XcursorImage *
+_XcursorReadImage (XcursorFile *file,
+ XcursorFileHeader *fileHeader,
+ int toc)
+{
+ XcursorChunkHeader chunkHeader;
+ XcursorImage head;
+ XcursorImage *image;
+ int n;
+ XcursorPixel *p;
+
+ if (!file || !fileHeader)
+ return NULL;
+
+ if (!_XcursorFileReadChunkHeader (file, fileHeader, toc, &chunkHeader))
+ return 0;
+ if (!_XcursorReadUInt (file, &head.width))
+ return 0;
+ if (!_XcursorReadUInt (file, &head.height))
+ return 0;
+ if (!_XcursorReadUInt (file, &head.xhot))
+ return 0;
+ if (!_XcursorReadUInt (file, &head.yhot))
+ return 0;
+ if (!_XcursorReadUInt (file, &head.delay))
+ return 0;
+ /* sanity check data */
+ if (head.width >= 0x10000 || head.height > 0x10000)
+ return 0;
+ if (head.width == 0 || head.height == 0)
+ return 0;
+ if (head.xhot > head.width || head.yhot > head.height)
+ return 0;
+
+ /* Create the image and initialize it */
+ image = XcursorImageCreate (head.width, head.height);
+ if (chunkHeader.version < image->version)
+ image->version = chunkHeader.version;
+ image->size = chunkHeader.subtype;
+ image->xhot = head.xhot;
+ image->yhot = head.yhot;
+ image->delay = head.delay;
+ n = image->width * image->height;
+ p = image->pixels;
+ while (n--)
+ {
+ if (!_XcursorReadUInt (file, p))
+ {
+ XcursorImageDestroy (image);
+ return 0;
+ }
+ p++;
+ }
+ return image;
+}
+
+static XcursorUInt
+_XcursorImageLength (XcursorImage *image)
+{
+ if (!image)
+ return 0;
+
+ return XCURSOR_IMAGE_HEADER_LEN + (image->width * image->height) * 4;
+}
+
+static XcursorBool
+_XcursorWriteImage (XcursorFile *file,
+ XcursorFileHeader *fileHeader,
+ int toc,
+ XcursorImage *image)
+{
+ XcursorChunkHeader chunkHeader;
+ int n;
+ XcursorPixel *p;
+
+ if (!file || !fileHeader || !image)
+ return XcursorFalse;
+
+ /* sanity check data */
+ if (image->width > XCURSOR_IMAGE_MAX_SIZE ||
+ image->height > XCURSOR_IMAGE_MAX_SIZE)
+ return XcursorFalse;
+ if (image->width == 0 || image->height == 0)
+ return XcursorFalse;
+ if (image->xhot > image->width || image->yhot > image->height)
+ return XcursorFalse;
+
+ /* write chunk header */
+ chunkHeader.header = XCURSOR_IMAGE_HEADER_LEN;
+ chunkHeader.type = XCURSOR_IMAGE_TYPE;
+ chunkHeader.subtype = image->size;
+ chunkHeader.version = XCURSOR_IMAGE_VERSION;
+
+ if (!_XcursorFileWriteChunkHeader (file, fileHeader, toc, &chunkHeader))
+ return XcursorFalse;
+
+ /* write extra image header fields */
+ if (!_XcursorWriteUInt (file, image->width))
+ return XcursorFalse;
+ if (!_XcursorWriteUInt (file, image->height))
+ return XcursorFalse;
+ if (!_XcursorWriteUInt (file, image->xhot))
+ return XcursorFalse;
+ if (!_XcursorWriteUInt (file, image->yhot))
+ return XcursorFalse;
+ if (!_XcursorWriteUInt (file, image->delay))
+ return XcursorFalse;
+
+ /* write the image */
+ n = image->width * image->height;
+ p = image->pixels;
+ while (n--)
+ {
+ if (!_XcursorWriteUInt (file, *p))
+ return XcursorFalse;
+ p++;
+ }
+ return XcursorTrue;
+}
+
+static XcursorComment *
+_XcursorReadComment (XcursorFile *file,
+ XcursorFileHeader *fileHeader,
+ int toc)
+{
+ XcursorChunkHeader chunkHeader;
+ XcursorUInt length;
+ XcursorComment *comment;
+
+ if (!file || !fileHeader)
+ return NULL;
+
+ /* read chunk header */
+ if (!_XcursorFileReadChunkHeader (file, fileHeader, toc, &chunkHeader))
+ return 0;
+ /* read extra comment header fields */
+ if (!_XcursorReadUInt (file, &length))
+ return 0;
+ comment = XcursorCommentCreate (chunkHeader.subtype, length);
+ if (!comment)
+ return 0;
+ if (!_XcursorReadBytes (file, comment->comment, length))
+ {
+ XcursorCommentDestroy (comment);
+ return 0;
+ }
+ comment->comment[length] = '\0';
+ return comment;
+}
+
+static XcursorUInt
+_XcursorCommentLength (XcursorComment *comment)
+{
+ return XCURSOR_COMMENT_HEADER_LEN + strlen (comment->comment);
+}
+
+static XcursorBool
+_XcursorWriteComment (XcursorFile *file,
+ XcursorFileHeader *fileHeader,
+ int toc,
+ XcursorComment *comment)
+{
+ XcursorChunkHeader chunkHeader;
+ XcursorUInt length;
+
+ if (!file || !fileHeader || !comment || !comment->comment)
+ return XcursorFalse;
+
+ length = strlen (comment->comment);
+
+ /* sanity check data */
+ if (length > XCURSOR_COMMENT_MAX_LEN)
+ return XcursorFalse;
+
+ /* read chunk header */
+ chunkHeader.header = XCURSOR_COMMENT_HEADER_LEN;
+ chunkHeader.type = XCURSOR_COMMENT_TYPE;
+ chunkHeader.subtype = comment->comment_type;
+ chunkHeader.version = XCURSOR_COMMENT_VERSION;
+
+ if (!_XcursorFileWriteChunkHeader (file, fileHeader, toc, &chunkHeader))
+ return XcursorFalse;
+
+ /* write extra comment header fields */
+ if (!_XcursorWriteUInt (file, length))
+ return XcursorFalse;
+
+ if (!_XcursorWriteBytes (file, comment->comment, length))
+ return XcursorFalse;
+ return XcursorTrue;
+}
+
+XcursorImage *
+XcursorXcFileLoadImage (XcursorFile *file, int size)
+{
+ XcursorFileHeader *fileHeader;
+ XcursorDim bestSize;
+ int nsize;
+ int toc;
+ XcursorImage *image;
+
+ if (size < 0)
+ return 0;
+ fileHeader = _XcursorReadFileHeader (file);
+ if (!fileHeader)
+ return 0;
+ bestSize = _XcursorFindBestSize (fileHeader, (XcursorDim) size, &nsize);
+ if (!bestSize)
+ return 0;
+ toc = _XcursorFindImageToc (fileHeader, bestSize, 0);
+ if (toc < 0)
+ return 0;
+ image = _XcursorReadImage (file, fileHeader, toc);
+ _XcursorFileHeaderDestroy (fileHeader);
+ return image;
+}
+
+XcursorImages *
+XcursorXcFileLoadImages (XcursorFile *file, int size)
+{
+ XcursorFileHeader *fileHeader;
+ XcursorDim bestSize;
+ int nsize;
+ XcursorImages *images;
+ int n;
+ int toc;
+
+ if (!file || size < 0)
+ return 0;
+ fileHeader = _XcursorReadFileHeader (file);
+ if (!fileHeader)
+ return 0;
+ bestSize = _XcursorFindBestSize (fileHeader, (XcursorDim) size, &nsize);
+ if (!bestSize)
+ return 0;
+ images = XcursorImagesCreate (nsize);
+ if (!images)
+ return 0;
+ for (n = 0; n < nsize; n++)
+ {
+ toc = _XcursorFindImageToc (fileHeader, bestSize, n);
+ if (toc < 0)
+ break;
+ images->images[images->nimage] = _XcursorReadImage (file, fileHeader,
+ toc);
+ if (!images->images[images->nimage])
+ break;
+ images->nimage++;
+ }
+ _XcursorFileHeaderDestroy (fileHeader);
+ if (images->nimage != nsize)
+ {
+ XcursorImagesDestroy (images);
+ images = 0;
+ }
+ return images;
+}
+
+XcursorImages *
+XcursorXcFileLoadAllImages (XcursorFile *file)
+{
+ XcursorFileHeader *fileHeader;
+ XcursorImage *image;
+ XcursorImages *images;
+ int nimage;
+ int n;
+ int toc;
+
+ if (!file)
+ return 0;
+
+ fileHeader = _XcursorReadFileHeader (file);
+ if (!fileHeader)
+ return 0;
+ nimage = 0;
+ for (n = 0; n < fileHeader->ntoc; n++)
+ {
+ switch (fileHeader->tocs[n].type) {
+ case XCURSOR_IMAGE_TYPE:
+ nimage++;
+ break;
+ }
+ }
+ images = XcursorImagesCreate (nimage);
+ if (!images)
+ return 0;
+ for (toc = 0; toc < fileHeader->ntoc; toc++)
+ {
+ switch (fileHeader->tocs[toc].type) {
+ case XCURSOR_IMAGE_TYPE:
+ image = _XcursorReadImage (file, fileHeader, toc);
+ if (image)
+ {
+ images->images[images->nimage] = image;
+ images->nimage++;
+ }
+ break;
+ }
+ }
+ _XcursorFileHeaderDestroy (fileHeader);
+ if (images->nimage != nimage)
+ {
+ XcursorImagesDestroy (images);
+ images = 0;
+ }
+ return images;
+}
+
+XcursorBool
+XcursorXcFileLoad (XcursorFile *file,
+ XcursorComments **commentsp,
+ XcursorImages **imagesp)
+{
+ XcursorFileHeader *fileHeader;
+ int nimage;
+ int ncomment;
+ XcursorImages *images;
+ XcursorImage *image;
+ XcursorComment *comment;
+ XcursorComments *comments;
+ int toc;
+
+ if (!file)
+ return 0;
+ fileHeader = _XcursorReadFileHeader (file);
+ if (!fileHeader)
+ return 0;
+ nimage = 0;
+ ncomment = 0;
+ for (toc = 0; toc < fileHeader->ntoc; toc++)
+ {
+ switch (fileHeader->tocs[toc].type) {
+ case XCURSOR_COMMENT_TYPE:
+ ncomment++;
+ break;
+ case XCURSOR_IMAGE_TYPE:
+ nimage++;
+ break;
+ }
+ }
+ images = XcursorImagesCreate (nimage);
+ if (!images)
+ return 0;
+ comments = XcursorCommentsCreate (ncomment);
+ if (!comments)
+ {
+ XcursorImagesDestroy (images);
+ return 0;
+ }
+ for (toc = 0; toc < fileHeader->ntoc; toc++)
+ {
+ switch (fileHeader->tocs[toc].type) {
+ case XCURSOR_COMMENT_TYPE:
+ comment = _XcursorReadComment (file, fileHeader, toc);
+ if (comment)
+ {
+ comments->comments[comments->ncomment] = comment;
+ comments->ncomment++;
+ }
+ break;
+ case XCURSOR_IMAGE_TYPE:
+ image = _XcursorReadImage (file, fileHeader, toc);
+ if (image)
+ {
+ images->images[images->nimage] = image;
+ images->nimage++;
+ }
+ break;
+ }
+ }
+ _XcursorFileHeaderDestroy (fileHeader);
+ if (images->nimage != nimage || comments->ncomment != ncomment)
+ {
+ XcursorImagesDestroy (images);
+ XcursorCommentsDestroy (comments);
+ images = 0;
+ comments = 0;
+ return XcursorFalse;
+ }
+ *imagesp = images;
+ *commentsp = comments;
+ return XcursorTrue;
+}
+
+XcursorBool
+XcursorXcFileSave (XcursorFile *file,
+ const XcursorComments *comments,
+ const XcursorImages *images)
+{
+ XcursorFileHeader *fileHeader;
+ XcursorUInt position;
+ int n;
+ int toc;
+
+ if (!file || !comments || !images)
+ return XcursorFalse;
+
+ fileHeader = _XcursorFileHeaderCreate (comments->ncomment + images->nimage);
+ if (!fileHeader)
+ return XcursorFalse;
+
+ position = _XcursorFileHeaderLength (fileHeader);
+
+ /*
+ * Compute the toc. Place the images before the comments
+ * as they're more often read
+ */
+
+ toc = 0;
+ for (n = 0; n < images->nimage; n++)
+ {
+ fileHeader->tocs[toc].type = XCURSOR_IMAGE_TYPE;
+ fileHeader->tocs[toc].subtype = images->images[n]->size;
+ fileHeader->tocs[toc].position = position;
+ position += _XcursorImageLength (images->images[n]);
+ toc++;
+ }
+
+ for (n = 0; n < comments->ncomment; n++)
+ {
+ fileHeader->tocs[toc].type = XCURSOR_COMMENT_TYPE;
+ fileHeader->tocs[toc].subtype = comments->comments[n]->comment_type;
+ fileHeader->tocs[toc].position = position;
+ position += _XcursorCommentLength (comments->comments[n]);
+ toc++;
+ }
+
+ /*
+ * Write the header and the toc
+ */
+ if (!_XcursorWriteFileHeader (file, fileHeader))
+ goto bail;
+
+ /*
+ * Write the images
+ */
+ toc = 0;
+ for (n = 0; n < images->nimage; n++)
+ {
+ if (!_XcursorWriteImage (file, fileHeader, toc, images->images[n]))
+ goto bail;
+ toc++;
+ }
+
+ /*
+ * Write the comments
+ */
+ for (n = 0; n < comments->ncomment; n++)
+ {
+ if (!_XcursorWriteComment (file, fileHeader, toc, comments->comments[n]))
+ goto bail;
+ toc++;
+ }
+
+ _XcursorFileHeaderDestroy (fileHeader);
+ return XcursorTrue;
+bail:
+ _XcursorFileHeaderDestroy (fileHeader);
+ return XcursorFalse;
+}
+
+static int
+_XcursorStdioFileRead (XcursorFile *file, unsigned char *buf, int len)
+{
+ FILE *f = file->closure;
+ return fread (buf, 1, len, f);
+}
+
+static int
+_XcursorStdioFileWrite (XcursorFile *file, unsigned char *buf, int len)
+{
+ FILE *f = file->closure;
+ return fwrite (buf, 1, len, f);
+}
+
+static int
+_XcursorStdioFileSeek (XcursorFile *file, long offset, int whence)
+{
+ FILE *f = file->closure;
+ return fseek (f, offset, whence);
+}
+
+static void
+_XcursorStdioFileInitialize (FILE *stdfile, XcursorFile *file)
+{
+ file->closure = stdfile;
+ file->read = _XcursorStdioFileRead;
+ file->write = _XcursorStdioFileWrite;
+ file->seek = _XcursorStdioFileSeek;
+}
+
+XcursorImage *
+XcursorFileLoadImage (FILE *file, int size)
+{
+ XcursorFile f;
+
+ if (!file)
+ return NULL;
+
+ _XcursorStdioFileInitialize (file, &f);
+ return XcursorXcFileLoadImage (&f, size);
+}
+
+XcursorImages *
+XcursorFileLoadImages (FILE *file, int size)
+{
+ XcursorFile f;
+
+ if (!file)
+ return NULL;
+
+ _XcursorStdioFileInitialize (file, &f);
+ return XcursorXcFileLoadImages (&f, size);
+}
+
+XcursorImages *
+XcursorFileLoadAllImages (FILE *file)
+{
+ XcursorFile f;
+
+ if (!file)
+ return NULL;
+
+ _XcursorStdioFileInitialize (file, &f);
+ return XcursorXcFileLoadAllImages (&f);
+}
+
+XcursorBool
+XcursorFileLoad (FILE *file,
+ XcursorComments **commentsp,
+ XcursorImages **imagesp)
+{
+ XcursorFile f;
+
+ if (!file || !commentsp || !imagesp)
+ return XcursorFalse;
+
+ _XcursorStdioFileInitialize (file, &f);
+ return XcursorXcFileLoad (&f, commentsp, imagesp);
+}
+
+XcursorBool
+XcursorFileSaveImages (FILE *file, const XcursorImages *images)
+{
+ XcursorComments *comments = XcursorCommentsCreate (0);
+ XcursorFile f;
+ XcursorBool ret;
+ if (!comments || !file || !images)
+ return 0;
+ _XcursorStdioFileInitialize (file, &f);
+ ret = XcursorXcFileSave (&f, comments, images) && fflush (file) != EOF;
+ XcursorCommentsDestroy (comments);
+ return ret;
+}
+
+XcursorBool
+XcursorFileSave (FILE * file,
+ const XcursorComments *comments,
+ const XcursorImages *images)
+{
+ XcursorFile f;
+
+ if (!file || !comments || !images)
+ return XcursorFalse;
+
+ _XcursorStdioFileInitialize (file, &f);
+ return XcursorXcFileSave (&f, comments, images) && fflush (file) != EOF;
+}
+
+XcursorImage *
+XcursorFilenameLoadImage (const char *file, int size)
+{
+ FILE *f;
+ XcursorImage *image;
+
+ if (!file || size < 0)
+ return NULL;
+
+ f = fopen (file, "r");
+ if (!f)
+ return 0;
+ image = XcursorFileLoadImage (f, size);
+ fclose (f);
+ return image;
+}
+
+XcursorImages *
+XcursorFilenameLoadImages (const char *file, int size)
+{
+ FILE *f;
+ XcursorImages *images;
+
+ if (!file || size < 0)
+ return NULL;
+
+ f = fopen (file, "r");
+ if (!f)
+ return 0;
+ images = XcursorFileLoadImages (f, size);
+ fclose (f);
+ return images;
+}
+
+XcursorImages *
+XcursorFilenameLoadAllImages (const char *file)
+{
+ FILE *f;
+ XcursorImages *images;
+
+ if (!file)
+ return NULL;
+
+ f = fopen (file, "r");
+ if (!f)
+ return 0;
+ images = XcursorFileLoadAllImages (f);
+ fclose (f);
+ return images;
+}
+
+XcursorBool
+XcursorFilenameLoad (const char *file,
+ XcursorComments **commentsp,
+ XcursorImages **imagesp)
+{
+ FILE *f;
+ XcursorBool ret;
+
+ if (!file)
+ return XcursorFalse;
+
+ f = fopen (file, "r");
+ if (!f)
+ return 0;
+ ret = XcursorFileLoad (f, commentsp, imagesp);
+ fclose (f);
+ return ret;
+}
+
+XcursorBool
+XcursorFilenameSaveImages (const char *file, const XcursorImages *images)
+{
+ FILE *f;
+ XcursorBool ret;
+
+ if (!file || !images)
+ return XcursorFalse;
+
+ f = fopen (file, "w");
+ if (!f)
+ return 0;
+ ret = XcursorFileSaveImages (f, images);
+ return fclose (f) != EOF && ret;
+}
+
+XcursorBool
+XcursorFilenameSave (const char *file,
+ const XcursorComments *comments,
+ const XcursorImages *images)
+{
+ FILE *f;
+ XcursorBool ret;
+
+ if (!file || !comments || !images)
+ return XcursorFalse;
+
+ f = fopen (file, "w");
+ if (!f)
+ return 0;
+ ret = XcursorFileSave (f, comments, images);
+ return fclose (f) != EOF && ret;
+}
diff --git a/nx-X11/lib/Xcursor/library.c b/nx-X11/lib/Xcursor/library.c
new file mode 100644
index 000000000..6774f802f
--- /dev/null
+++ b/nx-X11/lib/Xcursor/library.c
@@ -0,0 +1,495 @@
+/*
+ * $Id: library.c,v 1.6 2005/12/08 17:54:40 kem Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xcursorint.h"
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef ICONDIR
+#define ICONDIR "/usr/X11R6/lib/X11/icons"
+#endif
+
+#ifndef XCURSORPATH
+#define XCURSORPATH "~/.icons:/usr/share/icons:/usr/share/pixmaps:"ICONDIR
+#endif
+
+const char *
+XcursorLibraryPath (void)
+{
+ static const char *path;
+
+ if (!path)
+ {
+ path = getenv ("XCURSOR_PATH");
+ if (!path)
+ path = XCURSORPATH;
+ }
+ return path;
+}
+
+static void
+_XcursorAddPathElt (char *path, const char *elt, int len)
+{
+ int pathlen = strlen (path);
+
+ /* append / if the path doesn't currently have one */
+ if (path[0] == '\0' || path[pathlen - 1] != '/')
+ {
+ strcat (path, "/");
+ pathlen++;
+ }
+ if (len == -1)
+ len = strlen (elt);
+ /* strip leading slashes */
+ while (len && elt[0] == '/')
+ {
+ elt++;
+ len--;
+ }
+ strncpy (path + pathlen, elt, len);
+ path[pathlen + len] = '\0';
+}
+
+static char *
+_XcursorBuildThemeDir (const char *dir, const char *theme)
+{
+ const char *colon;
+ const char *tcolon;
+ char *full;
+ char *home;
+ int dirlen;
+ int homelen;
+ int themelen;
+ int len;
+
+ if (!dir || !theme)
+ return NULL;
+
+ colon = strchr (dir, ':');
+ if (!colon)
+ colon = dir + strlen (dir);
+
+ dirlen = colon - dir;
+
+ tcolon = strchr (theme, ':');
+ if (!tcolon)
+ tcolon = theme + strlen (theme);
+
+ themelen = tcolon - theme;
+
+ home = 0;
+ homelen = 0;
+ if (*dir == '~')
+ {
+ home = getenv ("HOME");
+ if (!home)
+ return 0;
+ homelen = strlen (home);
+ dir++;
+ dirlen--;
+ }
+
+ /*
+ * add space for any needed directory separators, one per component,
+ * and one for the trailing null
+ */
+ len = 1 + homelen + 1 + dirlen + 1 + themelen + 1;
+
+ full = malloc (len);
+ if (!full)
+ return 0;
+ full[0] = '\0';
+
+ if (home)
+ _XcursorAddPathElt (full, home, -1);
+ _XcursorAddPathElt (full, dir, dirlen);
+ _XcursorAddPathElt (full, theme, themelen);
+ return full;
+}
+
+static char *
+_XcursorBuildFullname (const char *dir, const char *subdir, const char *file)
+{
+ char *full;
+
+ if (!dir || !subdir || !file)
+ return NULL;
+
+ full = malloc (strlen (dir) + 1 + strlen (subdir) + 1 + strlen (file) + 1);
+ if (!full)
+ return 0;
+ full[0] = '\0';
+ _XcursorAddPathElt (full, dir, -1);
+ _XcursorAddPathElt (full, subdir, -1);
+ _XcursorAddPathElt (full, file, -1);
+ return full;
+}
+
+static const char *
+_XcursorNextPath (const char *path)
+{
+ char *colon = strchr (path, ':');
+
+ if (!colon)
+ return 0;
+ return colon + 1;
+}
+
+#define XcursorWhite(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
+#define XcursorSep(c) ((c) == ';' || (c) == ',')
+
+static char *
+_XcursorThemeInherits (const char *full)
+{
+ char line[8192];
+ char *result = 0;
+ FILE *f;
+
+ if (!full)
+ return NULL;
+
+ f = fopen (full, "r");
+ if (f)
+ {
+ while (fgets (line, sizeof (line), f))
+ {
+ if (!strncmp (line, "Inherits", 8))
+ {
+ char *l = line + 8;
+ char *r;
+ while (*l == ' ') l++;
+ if (*l != '=') continue;
+ l++;
+ while (*l == ' ') l++;
+ result = malloc (strlen (l));
+ if (result)
+ {
+ r = result;
+ while (*l)
+ {
+ while (XcursorSep(*l) || XcursorWhite (*l)) l++;
+ if (!*l)
+ break;
+ if (r != result)
+ *r++ = ':';
+ while (*l && !XcursorWhite(*l) &&
+ !XcursorSep(*l))
+ *r++ = *l++;
+ }
+ *r++ = '\0';
+ }
+ break;
+ }
+ }
+ fclose (f);
+ }
+ return result;
+}
+
+#define XCURSOR_SCAN_CORE ((FILE *) 1)
+
+static FILE *
+XcursorScanTheme (const char *theme, const char *name)
+{
+ FILE *f = 0;
+ char *full;
+ char *dir;
+ const char *path;
+ char *inherits = 0;
+ const char *i;
+
+ if (!theme || !name)
+ return NULL;
+
+ /*
+ * XCURSOR_CORE_THEME is a magic name; cursors from the core set
+ * are never found in any directory. Instead, a magic value is
+ * returned which truncates any search so that overlying functions
+ * can switch to equivalent core cursors
+ */
+ if (!strcmp (theme, XCURSOR_CORE_THEME) && XcursorLibraryShape (name) >= 0)
+ return XCURSOR_SCAN_CORE;
+ /*
+ * Scan this theme
+ */
+ for (path = XcursorLibraryPath ();
+ path && f == 0;
+ path = _XcursorNextPath (path))
+ {
+ dir = _XcursorBuildThemeDir (path, theme);
+ if (dir)
+ {
+ full = _XcursorBuildFullname (dir, "cursors", name);
+ if (full)
+ {
+ f = fopen (full, "r");
+ free (full);
+ }
+ if (!f && !inherits)
+ {
+ full = _XcursorBuildFullname (dir, "", "index.theme");
+ if (full)
+ {
+ inherits = _XcursorThemeInherits (full);
+ free (full);
+ }
+ }
+ free (dir);
+ }
+ }
+ /*
+ * Recurse to scan inherited themes
+ */
+ for (i = inherits; i && f == 0; i = _XcursorNextPath (i))
+ f = XcursorScanTheme (i, name);
+ if (inherits)
+ free (inherits);
+ return f;
+}
+
+XcursorImage *
+XcursorLibraryLoadImage (const char *file, const char *theme, int size)
+{
+ FILE *f = 0;
+ XcursorImage *image = 0;
+
+ if (!file)
+ return NULL;
+
+ if (theme)
+ f = XcursorScanTheme (theme, file);
+ if (!f)
+ f = XcursorScanTheme ("default", file);
+ if (f == XCURSOR_SCAN_CORE)
+ return 0;
+ if (f)
+ {
+ image = XcursorFileLoadImage (f, size);
+ fclose (f);
+ }
+ return image;
+}
+
+XcursorImages *
+XcursorLibraryLoadImages (const char *file, const char *theme, int size)
+{
+ FILE *f = 0;
+ XcursorImages *images = 0;
+
+ if (!file)
+ return NULL;
+
+ if (theme)
+ f = XcursorScanTheme (theme, file);
+ if (!f)
+ f = XcursorScanTheme ("default", file);
+ if (f == XCURSOR_SCAN_CORE)
+ return 0;
+ if (f)
+ {
+ images = XcursorFileLoadImages (f, size);
+ if (images)
+ XcursorImagesSetName (images, file);
+ fclose (f);
+ }
+ return images;
+}
+
+Cursor
+XcursorLibraryLoadCursor (Display *dpy, const char *file)
+{
+ int size = XcursorGetDefaultSize (dpy);
+ char *theme = XcursorGetTheme (dpy);
+ XcursorImages *images = XcursorLibraryLoadImages (file, theme, size);
+ Cursor cursor;
+
+ if (!file)
+ return 0;
+
+ if (!images)
+ {
+ int id = XcursorLibraryShape (file);
+
+ if (id >= 0)
+ return _XcursorCreateFontCursor (dpy, id);
+ else
+ return 0;
+ }
+ cursor = XcursorImagesLoadCursor (dpy, images);
+ XcursorImagesDestroy (images);
+#if defined HAVE_XFIXES && XFIXES_MAJOR >= 2
+ XFixesSetCursorName (dpy, cursor, file);
+#endif
+ return cursor;
+}
+
+XcursorCursors *
+XcursorLibraryLoadCursors (Display *dpy, const char *file)
+{
+ int size = XcursorGetDefaultSize (dpy);
+ char *theme = XcursorGetTheme (dpy);
+ XcursorImages *images = XcursorLibraryLoadImages (file, theme, size);
+ XcursorCursors *cursors;
+
+ if (!file)
+ return NULL;
+
+ if (!images)
+ {
+ int id = XcursorLibraryShape (file);
+
+ if (id >= 0)
+ {
+ cursors = XcursorCursorsCreate (dpy, 1);
+ if (cursors)
+ {
+ cursors->cursors[0] = _XcursorCreateFontCursor (dpy, id);
+ if (cursors->cursors[0] == None)
+ {
+ XcursorCursorsDestroy (cursors);
+ cursors = 0;
+ }
+ else
+ cursors->ncursor = 1;
+ }
+ }
+ else
+ cursors = 0;
+ }
+ else
+ {
+ cursors = XcursorImagesLoadCursors (dpy, images);
+ XcursorImagesDestroy (images);
+ }
+ return cursors;
+}
+
+const static char *_XcursorStandardNames[] = {
+ /* 0 */
+ "X_cursor", "arrow", "based_arrow_down", "based_arrow_up",
+ "boat", "bogosity", "bottom_left_corner", "bottom_right_corner",
+ "bottom_side", "bottom_tee", "box_spiral", "center_ptr",
+ "circle", "clock", "coffee_mug", "cross",
+
+ /* 32 */
+ "cross_reverse", "crosshair", "diamond_cross", "dot",
+ "dotbox", "double_arrow", "draft_large", "draft_small",
+ "draped_box", "exchange", "fleur", "gobbler",
+ "gumby", "hand1", "hand2", "heart",
+
+ /* 64 */
+ "icon", "iron_cross", "left_ptr", "left_side",
+ "left_tee", "leftbutton", "ll_angle", "lr_angle",
+ "man", "middlebutton", "mouse", "pencil",
+ "pirate", "plus", "question_arrow", "right_ptr",
+
+ /* 96 */
+ "right_side", "right_tee", "rightbutton", "rtl_logo",
+ "sailboat", "sb_down_arrow", "sb_h_double_arrow", "sb_left_arrow",
+ "sb_right_arrow", "sb_up_arrow", "sb_v_double_arrow", "shuttle",
+ "sizing", "spider", "spraycan", "star",
+
+ /* 128 */
+ "target", "tcross", "top_left_arrow", "top_left_corner",
+ "top_right_corner", "top_side", "top_tee", "trek",
+ "ul_angle", "umbrella", "ur_angle", "watch",
+ "xterm",
+};
+
+#define NUM_STANDARD_NAMES (sizeof _XcursorStandardNames / sizeof _XcursorStandardNames[0])
+
+XcursorImage *
+XcursorShapeLoadImage (unsigned int shape, const char *theme, int size)
+{
+ unsigned int id = shape >> 1;
+
+ if (id < NUM_STANDARD_NAMES)
+ return XcursorLibraryLoadImage (_XcursorStandardNames[id],
+ theme, size);
+ else
+ return 0;
+}
+
+XcursorImages *
+XcursorShapeLoadImages (unsigned int shape, const char *theme, int size)
+{
+ unsigned int id = shape >> 1;
+
+ if (id < NUM_STANDARD_NAMES)
+ return XcursorLibraryLoadImages (_XcursorStandardNames[id],
+ theme, size);
+ else
+ return 0;
+}
+
+Cursor
+XcursorShapeLoadCursor (Display *dpy, unsigned int shape)
+{
+ unsigned int id = shape >> 1;
+
+ if (id < NUM_STANDARD_NAMES)
+ return XcursorLibraryLoadCursor (dpy, _XcursorStandardNames[id]);
+ else
+ return 0;
+}
+
+XcursorCursors *
+XcursorShapeLoadCursors (Display *dpy, unsigned int shape)
+{
+ unsigned int id = shape >> 1;
+
+ if (id < NUM_STANDARD_NAMES)
+ return XcursorLibraryLoadCursors (dpy, _XcursorStandardNames[id]);
+ else
+ return 0;
+}
+
+int
+XcursorLibraryShape (const char *library)
+{
+ int low, high;
+ int mid;
+ int c;
+
+ low = 0;
+ high = NUM_STANDARD_NAMES - 1;
+ while (low < high - 1)
+ {
+ mid = (low + high) >> 1;
+ c = strcmp (library, _XcursorStandardNames[mid]);
+ if (c == 0)
+ return (mid << 1);
+ if (c > 0)
+ low = mid;
+ else
+ high = mid;
+ }
+ while (low <= high)
+ {
+ if (!strcmp (library, _XcursorStandardNames[low]))
+ return (low << 1);
+ low++;
+ }
+ return -1;
+}
diff --git a/nx-X11/lib/Xcursor/xcursor-config.in b/nx-X11/lib/Xcursor/xcursor-config.in
new file mode 100644
index 000000000..af59f9974
--- /dev/null
+++ b/nx-X11/lib/Xcursor/xcursor-config.in
@@ -0,0 +1,95 @@
+#! /bin/sh
+
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
+libdir="@libdir@"
+hardcode_libdir_flag_spec=@hardcode_libdir_flag_spec@
+includedir="@includedir@"
+version="@VERSION@"
+
+usage()
+{
+ cat <<EOF
+Usage: xcursor-config [OPTIONS] [LIBRARIES]
+Options:
+ [--prefix[=DIR]]
+ [--exec-prefix[=DIR]]
+ [--version]
+ [--libs]
+ [--cflags]
+EOF
+ exit $1
+}
+
+if test $# -eq 0 ; then
+ usage 1 1>&2
+fi
+
+while test $# -gt 0 ; do
+ case "$1" in
+ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
+ esac
+
+ case $1 in
+ --prefix=*)
+ prefix=$optarg
+ local_prefix=yes
+ ;;
+ --prefix)
+ echo_prefix=yes
+ ;;
+ --exec-prefix=*)
+ exec_prefix=$optarg
+ exec_prefix_set=yes
+ local_prefix=yes
+ ;;
+ --exec-prefix)
+ echo_exec_prefix=yes
+ ;;
+ --version)
+ echo $version
+ exit 0
+ ;;
+ --cflags)
+ echo_cflags=yes
+ ;;
+ --libs)
+ echo_libs=yes
+ ;;
+ *)
+ usage 1 1>&2
+ ;;
+ esac
+ shift
+done
+
+if test "$local_prefix" = "yes" ; then
+ if test "$exec_prefix_set" != "yes" ; then
+ exec_prefix=$prefix
+ fi
+fi
+
+if test "$echo_prefix" = "yes" ; then
+ echo $prefix
+fi
+
+if test "$echo_exec_prefix" = "yes" ; then
+ echo $exec_prefix
+fi
+
+if test "$echo_cflags" = "yes" ; then
+ cflags="-I${includedir}"
+ echo $cflags
+fi
+
+if test "$echo_libs" = "yes" ; then
+ libs="-lXcursor"
+ if test "${libdir}" != "/usr/lib" ; then
+ echo ${hardcode_libdir_flag_spec} -L${libdir} $libs
+ else
+ echo $libs
+ fi
+fi
+
+# EOF
diff --git a/nx-X11/lib/Xcursor/xcursor.pc.in b/nx-X11/lib/Xcursor/xcursor.pc.in
new file mode 100644
index 000000000..c39fce712
--- /dev/null
+++ b/nx-X11/lib/Xcursor/xcursor.pc.in
@@ -0,0 +1,15 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+xrenderlibs=@XRENDER_LIBS@
+xrendercflags=@XRENDER_CFLAGS@
+xlibs=@X_LIBS@
+xcflags=@X_CFLAGS@
+
+Name: Xcursor
+Description: X Cursor Library
+Version: @VERSION@
+Requires: xrender
+Cflags: -I${includedir} ${xrendercflags} ${xcflags}
+Libs: -L${libdir} -lXcursor ${xrenderlibs} ${xlibs}
diff --git a/nx-X11/lib/Xcursor/xcursorint.h b/nx-X11/lib/Xcursor/xcursorint.h
new file mode 100644
index 000000000..83913a094
--- /dev/null
+++ b/nx-X11/lib/Xcursor/xcursorint.h
@@ -0,0 +1,109 @@
+/*
+ * $Id: xcursorint.h,v 1.6 2005/10/19 22:26:55 ajax Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _XCURSORINT_H_
+#define _XCURSORINT_H_
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <X11/Xlib.h>
+#include <X11/cursorfont.h>
+#include <X11/extensions/Xrender.h>
+
+#ifdef HAVE_XFIXES
+#include <X11/extensions/Xfixes.h>
+#endif
+
+#include "Xcursor.h"
+#include "config.h"
+
+typedef struct _XcursorFontInfo {
+ struct _XcursorFontInfo *next;
+ Font font;
+ XcursorBool is_cursor_font;
+} XcursorFontInfo;
+
+/*
+ * Track a few recently created bitmaps to see
+ * if they get used to create cursors. This
+ * is done by hooking into Xlib and watching
+ * for XCreatePixmap, XPutImage, XCreatePixmapCursor
+ * with appropriate arguments. When this happens
+ * Xcursor computes a hash value for the source image
+ * and tries to load a library cursor of that name.
+ */
+
+/* large bitmaps are unlikely to be cursors */
+#define MAX_BITMAP_CURSOR_SIZE 64
+/* don't need to remember very many; in fact, 2 is likely sufficient */
+#define NUM_BITMAPS 8
+
+typedef struct _XcursorBitmapInfo {
+ Pixmap bitmap;
+ unsigned long sequence;
+ unsigned int width, height;
+ Bool has_image;
+ unsigned char hash[XCURSOR_BITMAP_HASH_SIZE];
+} XcursorBitmapInfo;
+
+typedef enum _XcursorDither {
+ XcursorDitherThreshold,
+ XcursorDitherMedian,
+ XcursorDitherOrdered,
+ XcursorDitherDiffuse
+} XcursorDither;
+
+typedef struct _XcursorDisplayInfo {
+ struct _XcursorDisplayInfo *next;
+ Display *display;
+ XExtCodes *codes;
+ XcursorBool has_render_cursor;
+ XcursorBool has_anim_cursor;
+ XcursorBool theme_core;
+ int size;
+ XcursorFontInfo *fonts;
+ char *theme;
+ char *theme_from_config;
+ XcursorDither dither;
+ XcursorBitmapInfo bitmaps[NUM_BITMAPS];
+} XcursorDisplayInfo;
+
+XcursorDisplayInfo *
+_XcursorGetDisplayInfo (Display *dpy);
+
+Cursor
+_XcursorCreateGlyphCursor(Display *dpy,
+ Font source_font,
+ Font mask_font,
+ unsigned int source_char,
+ unsigned int mask_char,
+ XColor _Xconst *foreground,
+ XColor _Xconst *background);
+
+Cursor
+_XcursorCreateFontCursor (Display *dpy, unsigned int shape);
+
+#endif /* _XCURSORINT_H_ */
diff --git a/nx-X11/lib/Xcursor/xlib.c b/nx-X11/lib/Xcursor/xlib.c
new file mode 100644
index 000000000..7d10caf18
--- /dev/null
+++ b/nx-X11/lib/Xcursor/xlib.c
@@ -0,0 +1,422 @@
+/*
+ * $Id: xlib.c,v 1.5 2005/07/03 07:00:56 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xcursorint.h"
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <stdlib.h>
+
+static XcursorBool
+_XcursorFontIsCursor (Display *dpy, Font font)
+{
+ XcursorFontInfo *fi;
+ XcursorDisplayInfo *info;
+ XcursorBool ret;
+ XFontStruct *fs;
+ int n;
+ Atom cursor;
+
+ if (!dpy || !font)
+ return XcursorFalse;
+
+ if (font == dpy->cursor_font)
+ return XcursorTrue;
+
+ info = _XcursorGetDisplayInfo (dpy);
+ if (!info)
+ return XcursorFalse;
+ LockDisplay (dpy);
+ for (fi = info->fonts; fi; fi = fi->next)
+ if (fi->font == font)
+ {
+ ret = fi->is_cursor_font;
+ UnlockDisplay (dpy);
+ return ret;
+ }
+ UnlockDisplay (dpy);
+ ret = XcursorFalse;
+ fs = XQueryFont (dpy, font);
+ if (fs)
+ {
+ cursor = XInternAtom (dpy, "cursor", False);
+ for (n = 0; n < fs->n_properties; n++)
+ if (fs->properties[n].name == XA_FONT)
+ {
+ ret = (fs->properties[n].card32 == cursor);
+ break;
+ }
+ }
+ fi = malloc (sizeof (XcursorFontInfo));
+ if (fi)
+ {
+ fi->font = font;
+ fi->is_cursor_font = ret;
+ LockDisplay (dpy);
+ fi->next = info->fonts;
+ info->fonts = fi;
+ UnlockDisplay (dpy);
+ }
+ return ret;
+}
+
+Cursor
+XcursorTryShapeCursor (Display *dpy,
+ Font source_font,
+ Font mask_font,
+ unsigned int source_char,
+ unsigned int mask_char,
+ XColor _Xconst *foreground,
+ XColor _Xconst *background)
+{
+ Cursor cursor = None;
+
+ if (!dpy || !source_font || !mask_font || !foreground || !background)
+ return 0;
+
+ if (!XcursorSupportsARGB (dpy) && !XcursorGetThemeCore (dpy))
+ return None;
+
+ if (source_font == mask_font &&
+ _XcursorFontIsCursor (dpy, source_font) &&
+ source_char + 1 == mask_char)
+ {
+ int size = XcursorGetDefaultSize (dpy);
+ char *theme = XcursorGetTheme (dpy);
+ XcursorImages *images = XcursorShapeLoadImages (source_char, theme, size);
+
+ if (images)
+ {
+ cursor = XcursorImagesLoadCursor (dpy, images);
+ XcursorImagesDestroy (images);
+ }
+ }
+ return cursor;
+}
+
+void
+XcursorNoticeCreateBitmap (Display *dpy,
+ Pixmap pid,
+ unsigned int width,
+ unsigned int height)
+{
+ XcursorDisplayInfo *info;
+ unsigned long oldest;
+ unsigned long now;
+ int i;
+ int replace = 0;
+ XcursorBitmapInfo *bmi;
+
+ if (!dpy)
+ return;
+
+ if (!XcursorSupportsARGB (dpy) && !XcursorGetThemeCore (dpy))
+ return;
+
+ if (width > MAX_BITMAP_CURSOR_SIZE || height > MAX_BITMAP_CURSOR_SIZE)
+ return;
+
+ info = _XcursorGetDisplayInfo (dpy);
+ if (!info)
+ return;
+
+ LockDisplay (dpy);
+ replace = 0;
+ now = dpy->request;
+ oldest = now;
+ for (i = 0; i < NUM_BITMAPS; i++)
+ {
+ if (!info->bitmaps[i].bitmap)
+ {
+ replace = i;
+ break;
+ }
+ if ((long) (now - info->bitmaps[i].sequence) >
+ (long) (now - oldest))
+ {
+ replace = i;
+ oldest = info->bitmaps[i].sequence;
+ }
+ }
+ bmi = &info->bitmaps[replace];
+ bmi->bitmap = pid;
+ bmi->sequence = now;
+ bmi->width = width;
+ bmi->height = height;
+ bmi->has_image = False;
+ UnlockDisplay (dpy);
+}
+
+static XcursorBitmapInfo *
+_XcursorGetBitmap (Display *dpy, Pixmap bitmap)
+{
+ XcursorDisplayInfo *info;
+ int i;
+
+ if (!dpy || !bitmap)
+ return NULL;
+
+ info = _XcursorGetDisplayInfo (dpy);
+
+ if (!info)
+ return 0;
+ LockDisplay (dpy);
+ for (i = 0; i < NUM_BITMAPS; i++)
+ if (info->bitmaps[i].bitmap == bitmap)
+ {
+ info->bitmaps[i].sequence = dpy->request;
+ UnlockDisplay (dpy);
+ return &info->bitmaps[i];
+ }
+ UnlockDisplay (dpy);
+ return 0;
+}
+
+static Bool
+_XcursorClientLSB (void)
+{
+ int v = 1;
+ return *((char *) &v) == 1;
+}
+
+/* stolen from Xlib */
+static unsigned char const _reverse_byte[0x100] = {
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
+};
+
+#define RotByte(t,i) (((t) << (i)) | ((t) >> (8 - (i))))
+
+void
+XcursorImageHash (XImage *image,
+ unsigned char hash[XCURSOR_BITMAP_HASH_SIZE])
+{
+ int i;
+ int x, y;
+ unsigned char *line;
+ unsigned char t;
+ int low_addr;
+ Bool bit_swap;
+
+ if (!image)
+ return;
+
+ for (i = 0; i < XCURSOR_BITMAP_HASH_SIZE; i++)
+ hash[i] = 0;
+ /*
+ * Flip byte order on MSB machines where the bitmap_unit isn't
+ * in bytes
+ */
+ low_addr = 0;
+ if (image->bitmap_unit != 8)
+ {
+ if (!_XcursorClientLSB())
+ switch (image->bitmap_unit) {
+ case 16:
+ low_addr = 1;
+ break;
+ case 32:
+ low_addr = 3;
+ break;
+ }
+ }
+ /*
+ * Flip bit order on MSB images
+ */
+ bit_swap = (image->bitmap_bit_order != LSBFirst);
+
+ line = (unsigned char *) image->data;
+ i = 0;
+ /*
+ * Compute the hash. Yes, it might be nice to use
+ * a stronger hash function, but MD5 and SHA1 are both
+ * a bit to expensive in time and space for this,
+ * and cursors are generally small enough that a weak
+ * hash is sufficient to distinguish among them.
+ */
+ for (y = 0; y < image->height; y++)
+ {
+ for (x = 0; x < image->bytes_per_line; x++)
+ {
+ t = line[x^low_addr];
+ if (bit_swap)
+ t = _reverse_byte[t];
+ if (t)
+ hash[(i++) & (XCURSOR_BITMAP_HASH_SIZE - 1)] ^= RotByte (t, y & 7);
+ }
+ line += image->bytes_per_line;
+ }
+}
+
+static Bool
+_XcursorLogDiscover (void)
+{
+ static Bool been_here;
+ static Bool log;
+
+ if (!been_here)
+ {
+ been_here = True;
+
+ if (getenv ("XCURSOR_DISCOVER"))
+ log = True;
+ }
+ return log;
+}
+
+void
+XcursorNoticePutBitmap (Display *dpy,
+ Drawable draw,
+ XImage *image)
+{
+ XcursorBitmapInfo *bmi;
+
+ if (!dpy || !image)
+ return;
+
+ if (!XcursorSupportsARGB (dpy) && !XcursorGetThemeCore (dpy))
+ return;
+
+ if (image->width > MAX_BITMAP_CURSOR_SIZE ||
+ image->height > MAX_BITMAP_CURSOR_SIZE)
+ return;
+
+ bmi = _XcursorGetBitmap (dpy, (Pixmap) draw);
+ if (!bmi)
+ return;
+ /*
+ * Make sure the image fills the bitmap
+ */
+ if (image->width != bmi->width || image->height != bmi->height)
+ {
+ bmi->bitmap = 0;
+ return;
+ }
+ /*
+ * If multiple images are placed in the same bitmap,
+ * assume it's not going to be a cursor
+ */
+ if (bmi->has_image)
+ {
+ bmi->bitmap = 0;
+ return;
+ }
+ /*
+ * Make sure the image is valid
+ */
+ if (image->bytes_per_line & ((image->bitmap_unit >> 3) - 1))
+ {
+ bmi->bitmap = 0;
+ return;
+ }
+ /*
+ * Hash the image
+ */
+ XcursorImageHash (image, bmi->hash);
+ /*
+ * Display the hash value and the image if
+ * requested so that users can find out what
+ * cursor name is associated with each image
+ */
+ if (_XcursorLogDiscover())
+ {
+ int x, y;
+ int i;
+ XImage t = *image;
+
+ XInitImage (&t);
+
+ printf ("Cursor image name: ");
+ for (i = 0; i < XCURSOR_BITMAP_HASH_SIZE; i++)
+ printf ("%02x", bmi->hash[i]);
+ printf ("\n");
+ for (y = 0; y < image->height; y++)
+ {
+ for (x = 0; x < image->width; x++)
+ putchar (XGetPixel (&t, x, y) ? '*' : ' ');
+ putchar ('\n');
+ }
+ }
+ bmi->has_image = True;
+}
+
+Cursor
+XcursorTryShapeBitmapCursor (Display *dpy,
+ Pixmap source,
+ Pixmap mask,
+ XColor *foreground,
+ XColor *background,
+ unsigned int x,
+ unsigned int y)
+{
+ XcursorBitmapInfo *bmi;
+ char name[8 * XCURSOR_BITMAP_HASH_SIZE];
+ int i;
+ Cursor cursor;
+
+ if (!dpy || !foreground || !background)
+ return 0;
+
+ if (!XcursorSupportsARGB (dpy) && !XcursorGetThemeCore (dpy))
+ return None;
+
+ bmi = _XcursorGetBitmap (dpy, source);
+ if (!bmi || !bmi->has_image)
+ return None;
+ for (i = 0; i < XCURSOR_BITMAP_HASH_SIZE; i++)
+ sprintf (name + 2 * i, "%02x", bmi->hash[i]);
+ cursor = XcursorLibraryLoadCursor (dpy, name);
+ if (_XcursorLogDiscover())
+ printf ("Cursor hash %s returns 0x%x\n", name, (unsigned int) cursor);
+ return cursor;
+}
diff --git a/nx-X11/lib/Xdamage/.cvsignore b/nx-X11/lib/Xdamage/.cvsignore
new file mode 100644
index 000000000..b44ca97f0
--- /dev/null
+++ b/nx-X11/lib/Xdamage/.cvsignore
@@ -0,0 +1,24 @@
+.deps
+.libs
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+config.guess
+config.h
+config.h.in
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+libtool
+ltmain.sh
+missing
+mkinstalldirs
+stamp-h1
+xdamage.pc
+*.lo
+*.la
+confdefs.h
diff --git a/nx-X11/lib/Xdamage/AUTHORS b/nx-X11/lib/Xdamage/AUTHORS
new file mode 100644
index 000000000..57c4efd4e
--- /dev/null
+++ b/nx-X11/lib/Xdamage/AUTHORS
@@ -0,0 +1,2 @@
+Keith Packard, HP
+
diff --git a/nx-X11/lib/Xdamage/COPYING b/nx-X11/lib/Xdamage/COPYING
new file mode 100644
index 000000000..e85d981e7
--- /dev/null
+++ b/nx-X11/lib/Xdamage/COPYING
@@ -0,0 +1,22 @@
+$Id: COPYING,v 1.1 2004/07/31 05:50:39 anholt Exp $
+
+Copyright © 2001,2003 Keith Packard
+
+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 of Keith Packard not be used in
+advertising or publicity pertaining to distribution of the software without
+specific, written prior permission. Keith Packard makes no
+representations about the suitability of this software for any purpose. It
+is provided "as is" without express or implied warranty.
+
+KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL KEITH PACKARD 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.
+
diff --git a/nx-X11/lib/Xdamage/ChangeLog b/nx-X11/lib/Xdamage/ChangeLog
new file mode 100644
index 000000000..427091447
--- /dev/null
+++ b/nx-X11/lib/Xdamage/ChangeLog
@@ -0,0 +1,13 @@
+Tue May 17 12:59:47 2005 Søren Sandmann <sandmann@redhat.com>
+
+ * Xdamage.c: Conditionally include config.h
+
+2004-02-03 Jim Gettys <jg@freedesktop.org>
+
+ * AUTHORS: Add authors.
+
+2004-01-15 Daniel Stone <daniel@fooishbar.org>
+ * Tag release 1.0.1 for first freedesktop.org clientside lib release.
+
+2004-01-15 Harold L Hunt II <huntharo@msu.edu>
+ * Makefile.am: Pass -no-undefined to libtool via LDFLAGS.
diff --git a/nx-X11/lib/Xdamage/INSTALL b/nx-X11/lib/Xdamage/INSTALL
new file mode 100644
index 000000000..b94098a95
--- /dev/null
+++ b/nx-X11/lib/Xdamage/INSTALL
@@ -0,0 +1,8 @@
+Render is built with the traditional configure script:
+
+ $ ./configure --prefix=/usr/X11R6
+
+This should generate valid Makefiles, then:
+
+ $ make
+ $ make install
diff --git a/nx-X11/lib/Xdamage/Imakefile b/nx-X11/lib/Xdamage/Imakefile
new file mode 100644
index 000000000..260dfeb56
--- /dev/null
+++ b/nx-X11/lib/Xdamage/Imakefile
@@ -0,0 +1,68 @@
+XCOMM $XdotOrg: xc/lib/Xdamage/Imakefile,v 1.1 2004/07/31 05:50:39 anholt Exp $
+
+#ifndef NormalLibXdamage
+#define NormalLibXdamage YES
+SOXDAMAGEREV=1.0.1
+#endif
+
+#ifndef SharedLibXdamage
+#define SharedLibXdamage YES
+#endif
+
+#define DoNormalLib NormalLibXdamage
+#define DoSharedLib SharedLibXdamage
+#define DoDebugLib DebugLibXdamage
+#define DoProfileLib ProfileLibXdamage
+
+#define LibName Xdamage
+#define SoRev SOXDAMAGEREV
+#define IncSubdir X11
+#define IncSubSubdir extensions
+
+#include <Threads.tmpl>
+
+#ifdef SharedXdamageReqs
+REQUIREDLIBS = SharedXdamageReqs
+#endif
+
+XDAMAGE_VERSION=1.0.1
+
+X_LIBS=-L$(SHLIBDIR) $(XONLYLIB)
+X_CFLAGS=-I$(INCROOT) $(THREADS_DEFINES)
+XDAMAGE_LIBS = $(XFIXESLIB)
+XDAMAGE_CFLAGS =
+
+RPATH_CFLAG = HardCodeLibdirFlag
+
+SRCS = Xdamage.c
+
+OBJS = Xdamage.o
+
+HEADERS = Xdamage.h
+
+SUBSTVARS=prefix="$(PROJECTROOT)" \
+ exec_prefix="$(BINDIR)" \
+ libdir="$(USRLIBDIR)" \
+ hardcode_libdir_flag_spec="$(RPATH_CFLAG)" \
+ includedir="$(INCROOT)" \
+ X_LIBS="$(X_LIBS)" \
+ X_CFLAGS="$(X_CFLAGS)" \
+ XDAMAGE_LIBS="$(XDAMAGE_LIBS)" \
+ XDAMAGE_CFLAGS="$(XDAMAGE_CFLAGS)" \
+ VERSION="$(XDAMAGE_VERSION)"
+
+#include <Library.tmpl>
+
+DependTarget()
+
+all:: xdamage.pc
+
+xdamage.pc: xdamage.pc.in
+ RemoveFile($@)
+ sh ../Xcursor/config-subst $(SUBSTVARS) < xdamage.pc.in > $@
+
+InstallNonExecFile(xdamage.pc,$(USRLIBDIR)/pkgconfig)
+
+clean::
+ RemoveFile(xdamage.pc)
+
diff --git a/nx-X11/lib/Xdamage/Makefile.am b/nx-X11/lib/Xdamage/Makefile.am
new file mode 100644
index 000000000..cdcd23b49
--- /dev/null
+++ b/nx-X11/lib/Xdamage/Makefile.am
@@ -0,0 +1,52 @@
+#
+# $Id: Makefile.am,v 1.1 2004/07/31 05:50:39 anholt Exp $
+#
+# Copyright © 2003 Keith Packard, Noah Levitt
+#
+# 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 of Keith Packard not be used in
+# advertising or publicity pertaining to distribution of the software without
+# specific, written prior permission. Keith Packard makes no
+# representations about the suitability of this software for any purpose. It
+# is provided "as is" without express or implied warranty.
+#
+# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+# EVENT SHALL KEITH PACKARD 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.
+
+AM_CFLAGS = $(XDAMAGE_CFLAGS) $(X_CFLAGS)
+
+lib_LTLIBRARIES = libXdamage.la
+
+libXdamage_la_SOURCES = \
+ xdamageint.h \
+ Xdamage.c
+
+libXdamage_la_LIBADD = $(XDAMAGE_LIBS) $(X_LIBS)
+
+#
+# Library version info. Check the libtool docs for
+# instructions on when and how to change this value
+#
+# bump when the ABI changes
+XDAMAGE_CURRENT=1
+# bump for non-ABI changes, reset to zero when CURRENT changes
+XDAMAGE_REVISION=0
+# bump when the ABI changes in backward-compatible fashion
+XDAMAGE_AGE=1
+libXdamage_la_LDFLAGS = -version-info ${XDAMAGE_CURRENT}:${XDAMAGE_REVISION}:${XDAMAGE_AGE} -no-undefined
+
+libXdamageincludedir = $(includedir)/X11/extensions
+libXdamageinclude_HEADERS = Xdamage.h
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = xdamage.pc
+
+EXTRA_DIST = xdamage.pc.in autogen.sh
diff --git a/nx-X11/lib/Xdamage/NEWS b/nx-X11/lib/Xdamage/NEWS
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/lib/Xdamage/NEWS
diff --git a/nx-X11/lib/Xdamage/README b/nx-X11/lib/Xdamage/README
new file mode 100644
index 000000000..9968c6bdf
--- /dev/null
+++ b/nx-X11/lib/Xdamage/README
@@ -0,0 +1,10 @@
+ RandR
+ X RandR Extension
+ Version 1.0
+ 2002-10-4
+
+This package contains header files and documentation for the X RandR
+extension. Library and server implementations are separate.
+
+Keith Packard
+keithp@keithp.com
diff --git a/nx-X11/lib/Xdamage/Xdamage.c b/nx-X11/lib/Xdamage/Xdamage.c
new file mode 100644
index 000000000..48ffa68a9
--- /dev/null
+++ b/nx-X11/lib/Xdamage/Xdamage.c
@@ -0,0 +1,365 @@
+/*
+ * $Id: Xdamage.c,v 1.3 2005/07/03 07:00:56 daniels Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "xdamageint.h"
+
+XDamageExtInfo XDamageExtensionInfo;
+
+const char XDamageExtensionName[] = DAMAGE_NAME;
+
+static int
+XDamageCloseDisplay (Display *dpy, XExtCodes *codes);
+
+static Bool
+XDamageWireToEvent(Display *dpy, XEvent *event, xEvent *wire);
+
+static Status
+XDamageEventToWire(Display *dpy, XEvent *event, xEvent *wire);
+
+/*
+ * XDamageExtAddDisplay - add a display to this extension. (Replaces
+ * XextAddDisplay)
+ */
+static XDamageExtDisplayInfo *
+XDamageExtAddDisplay (XDamageExtInfo *extinfo,
+ Display *dpy,
+ const char *ext_name)
+{
+ XDamageExtDisplayInfo *info;
+ int ev;
+
+ info = (XDamageExtDisplayInfo *) Xmalloc (sizeof (XDamageExtDisplayInfo));
+ if (!info) return NULL;
+ info->display = dpy;
+
+ info->codes = XInitExtension (dpy, ext_name);
+
+ /*
+ * if the server has the extension, then we can initialize the
+ * appropriate function vectors
+ */
+ if (info->codes) {
+ xDamageQueryVersionReply rep;
+ xDamageQueryVersionReq *req;
+ XESetCloseDisplay (dpy, info->codes->extension,
+ XDamageCloseDisplay);
+ for (ev = info->codes->first_event;
+ ev < info->codes->first_event + XDamageNumberEvents;
+ ev++)
+ {
+ XESetWireToEvent (dpy, ev, XDamageWireToEvent);
+ XESetEventToWire (dpy, ev, XDamageEventToWire);
+ }
+ /*
+ * Get the version info
+ */
+ LockDisplay (dpy);
+ GetReq (DamageQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->damageReqType = X_DamageQueryVersion;
+ req->majorVersion = DAMAGE_MAJOR;
+ req->minorVersion = DAMAGE_MINOR;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue))
+ {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ info->major_version = rep.majorVersion;
+ info->minor_version = rep.minorVersion;
+ UnlockDisplay (dpy);
+ } else {
+ /* The server doesn't have this extension.
+ * Use a private Xlib-internal extension to hang the close_display
+ * hook on so that the "cache" (extinfo->cur) is properly cleaned.
+ * (XBUG 7955)
+ */
+ XExtCodes *codes = XAddExtension(dpy);
+ if (!codes) {
+ XFree(info);
+ return NULL;
+ }
+ XESetCloseDisplay (dpy, codes->extension, XDamageCloseDisplay);
+ }
+
+ /*
+ * now, chain it onto the list
+ */
+ _XLockMutex(_Xglobal_lock);
+ info->next = extinfo->head;
+ extinfo->head = info;
+ extinfo->cur = info;
+ extinfo->ndisplays++;
+ _XUnlockMutex(_Xglobal_lock);
+ return info;
+}
+
+
+/*
+ * XDamageExtRemoveDisplay - remove the indicated display from the
+ * extension object. (Replaces XextRemoveDisplay.)
+ */
+static int
+XDamageExtRemoveDisplay (XDamageExtInfo *extinfo, Display *dpy)
+{
+ XDamageExtDisplayInfo *info, *prev;
+
+ /*
+ * locate this display and its back link so that it can be removed
+ */
+ _XLockMutex(_Xglobal_lock);
+ prev = NULL;
+ for (info = extinfo->head; info; info = info->next) {
+ if (info->display == dpy) break;
+ prev = info;
+ }
+ if (!info) {
+ _XUnlockMutex(_Xglobal_lock);
+ return 0; /* hmm, actually an error */
+ }
+
+ /*
+ * remove the display from the list; handles going to zero
+ */
+ if (prev)
+ prev->next = info->next;
+ else
+ extinfo->head = info->next;
+
+ extinfo->ndisplays--;
+ if (info == extinfo->cur) extinfo->cur = NULL; /* flush cache */
+ _XUnlockMutex(_Xglobal_lock);
+
+ Xfree ((char *) info);
+ return 1;
+}
+
+/*
+ * XDamageExtFindDisplay - look for a display in this extension; keeps a
+ * cache of the most-recently used for efficiency. (Replaces
+ * XextFindDisplay.)
+ */
+static XDamageExtDisplayInfo *
+XDamageExtFindDisplay (XDamageExtInfo *extinfo,
+ Display *dpy)
+{
+ XDamageExtDisplayInfo *info;
+
+ /*
+ * see if this was the most recently accessed display
+ */
+ if ((info = extinfo->cur) && info->display == dpy)
+ return info;
+
+ /*
+ * look for display in list
+ */
+ _XLockMutex(_Xglobal_lock);
+ for (info = extinfo->head; info; info = info->next) {
+ if (info->display == dpy) {
+ extinfo->cur = info; /* cache most recently used */
+ _XUnlockMutex(_Xglobal_lock);
+ return info;
+ }
+ }
+ _XUnlockMutex(_Xglobal_lock);
+
+ return NULL;
+}
+
+XDamageExtDisplayInfo *
+XDamageFindDisplay (Display *dpy)
+{
+ XDamageExtDisplayInfo *info;
+
+ info = XDamageExtFindDisplay (&XDamageExtensionInfo, dpy);
+ if (!info)
+ info = XDamageExtAddDisplay (&XDamageExtensionInfo, dpy,
+ XDamageExtensionName);
+ return info;
+}
+
+static int
+XDamageCloseDisplay (Display *dpy, XExtCodes *codes)
+{
+ return XDamageExtRemoveDisplay (&XDamageExtensionInfo, dpy);
+}
+
+static Bool
+XDamageWireToEvent(Display *dpy, XEvent *event, xEvent *wire)
+{
+ XDamageExtDisplayInfo *info = XDamageFindDisplay(dpy);
+
+ XDamageCheckExtension(dpy, info, False);
+
+ switch ((wire->u.u.type & 0x7F) - info->codes->first_event)
+ {
+ case XDamageNotify: {
+ XDamageNotifyEvent *aevent = (XDamageNotifyEvent *) event;
+ xDamageNotifyEvent *awire = (xDamageNotifyEvent *) wire;
+
+ aevent->type = awire->type & 0x7F;
+ aevent->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *) wire);
+ aevent->send_event = (awire->type & 0x80) != 0;
+ aevent->display = dpy;
+ aevent->drawable = awire->drawable;
+ aevent->damage = awire->damage;
+ aevent->level = awire->level;
+ aevent->timestamp = awire->timestamp;
+ aevent->area.x = awire->area.x;
+ aevent->area.y = awire->area.y;
+ aevent->area.width = awire->area.width;
+ aevent->area.height = awire->area.height;
+ aevent->geometry.x = awire->geometry.x;
+ aevent->geometry.y = awire->geometry.y;
+ aevent->geometry.width = awire->geometry.width;
+ aevent->geometry.height = awire->geometry.height;
+ return True;
+ }
+ }
+ return False;
+}
+
+static Status
+XDamageEventToWire(Display *dpy, XEvent *event, xEvent *wire)
+{
+ XDamageExtDisplayInfo *info = XDamageFindDisplay(dpy);
+
+ XDamageCheckExtension(dpy, info, False);
+
+ switch ((event->type & 0x7F) - info->codes->first_event)
+ {
+ case XDamageNotify: {
+ XDamageNotifyEvent *aevent;
+ xDamageNotifyEvent *awire;
+ awire = (xDamageNotifyEvent *) wire;
+ aevent = (XDamageNotifyEvent *) event;
+ awire->type = aevent->type | (aevent->send_event ? 0x80 : 0);
+ awire->drawable = aevent->drawable;
+ awire->damage = aevent->damage;
+ awire->level = aevent->level;
+ awire->timestamp = aevent->timestamp;
+ awire->area.x = aevent->area.x;
+ awire->area.y = aevent->area.y;
+ awire->area.width = aevent->area.width;
+ awire->area.height = aevent->area.height;
+ awire->geometry.x = aevent->geometry.x;
+ awire->geometry.y = aevent->geometry.y;
+ awire->geometry.width = aevent->geometry.width;
+ awire->geometry.height = aevent->geometry.height;
+ return True;
+ }
+ }
+ return False;
+}
+
+Bool
+XDamageQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XDamageExtDisplayInfo *info = XDamageFindDisplay (dpy);
+
+ if (XDamageHasExtension(info))
+ {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ }
+ else
+ return False;
+}
+
+Status
+XDamageQueryVersion (Display *dpy,
+ int *major_versionp,
+ int *minor_versionp)
+{
+ XDamageExtDisplayInfo *info = XDamageFindDisplay (dpy);
+
+ XDamageCheckExtension (dpy, info, 0);
+
+ *major_versionp = info->major_version;
+ *minor_versionp = info->minor_version;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
+Damage
+XDamageCreate (Display *dpy, Drawable drawable, int level)
+{
+ XDamageExtDisplayInfo *info = XDamageFindDisplay (dpy);
+ xDamageCreateReq *req;
+ Damage damage;
+
+ XDamageCheckExtension (dpy, info, 0);
+ LockDisplay (dpy);
+ GetReq (DamageCreate, req);
+ req->reqType = info->codes->major_opcode;
+ req->damageReqType = X_DamageCreate;
+ req->damage = damage = XAllocID (dpy);
+ req->drawable = drawable;
+ req->level = level;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return damage;
+}
+
+void
+XDamageDestroy (Display *dpy, Damage damage)
+{
+ XDamageExtDisplayInfo *info = XDamageFindDisplay (dpy);
+ xDamageDestroyReq *req;
+
+ XDamageSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (DamageDestroy, req);
+ req->reqType = info->codes->major_opcode;
+ req->damageReqType = X_DamageDestroy;
+ req->damage = damage;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+void
+XDamageSubtract (Display *dpy, Damage damage,
+ XserverRegion repair, XserverRegion parts)
+{
+ XDamageExtDisplayInfo *info = XDamageFindDisplay (dpy);
+ xDamageSubtractReq *req;
+
+ XDamageSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (DamageSubtract, req);
+ req->reqType = info->codes->major_opcode;
+ req->damageReqType = X_DamageSubtract;
+ req->damage = damage;
+ req->repair = repair;
+ req->parts = parts;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
diff --git a/nx-X11/lib/Xdamage/Xdamage.h b/nx-X11/lib/Xdamage/Xdamage.h
new file mode 100644
index 000000000..3da0606cb
--- /dev/null
+++ b/nx-X11/lib/Xdamage/Xdamage.h
@@ -0,0 +1,68 @@
+/*
+ * $Id: Xdamage.h,v 1.3 2005/07/03 07:00:56 daniels Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _XDAMAGE_H_
+#define _XDAMAGE_H_
+
+#include <X11/extensions/damagewire.h>
+#include <X11/extensions/Xfixes.h>
+#include <X11/Xfuncproto.h>
+
+typedef XID Damage;
+
+typedef struct {
+ int type; /* event base */
+ unsigned long serial;
+ Bool send_event;
+ Display *display;
+ Drawable drawable;
+ Damage damage;
+ int level;
+ Bool more; /* more events will be delivered immediately */
+ Time timestamp;
+ XRectangle area;
+ XRectangle geometry;
+} XDamageNotifyEvent;
+
+_XFUNCPROTOBEGIN
+
+Bool XDamageQueryExtension (Display *dpy, int *event_basep, int *error_basep);
+
+Status XDamageQueryVersion (Display *dpy,
+ int *major_versionp,
+ int *minor_versionp);
+
+Damage
+XDamageCreate (Display *dpy, Drawable drawable, int level);
+
+void
+XDamageDestroy (Display *dpy, Damage damage);
+
+void
+XDamageSubtract (Display *dpy, Damage damage,
+ XserverRegion repair, XserverRegion parts);
+
+_XFUNCPROTOEND
+
+#endif /* _XDAMAGE_H_ */
diff --git a/nx-X11/lib/Xdamage/autogen.sh b/nx-X11/lib/Xdamage/autogen.sh
new file mode 100755
index 000000000..b1376df5a
--- /dev/null
+++ b/nx-X11/lib/Xdamage/autogen.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+autoreconf -v --install || exit 1
+./configure --enable-maintainer-mode "$@"
diff --git a/nx-X11/lib/Xdamage/configure.ac b/nx-X11/lib/Xdamage/configure.ac
new file mode 100644
index 000000000..c2ab2ce26
--- /dev/null
+++ b/nx-X11/lib/Xdamage/configure.ac
@@ -0,0 +1,93 @@
+dnl
+dnl $Id: configure.ac,v 1.1 2004/07/31 05:50:39 anholt Exp $
+dnl
+dnl Copyright © 2003 Keith Packard, Noah Levitt
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this software and its
+dnl documentation for any purpose is hereby granted without fee, provided that
+dnl the above copyright notice appear in all copies and that both that
+dnl copyright notice and this permission notice appear in supporting
+dnl documentation, and that the name of Keith Packard not be used in
+dnl advertising or publicity pertaining to distribution of the software without
+dnl specific, written prior permission. Keith Packard makes no
+dnl representations about the suitability of this software for any purpose. It
+dnl is provided "as is" without express or implied warranty.
+dnl
+dnl KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+dnl EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+dnl PERFORMANCE OF THIS SOFTWARE.
+dnl
+dnl Process this file with autoconf to create configure.
+
+AC_PREREQ([2.57])
+
+dnl
+dnl Version should match the current XFixes version. XFixesQueryVersion
+dnl returns the version from xfixeswire.h, NOT the version we set here. But we
+dnl try to keep these the same. Note that the library has an extra
+dnl digit in the version number to track changes which don't affect the
+dnl protocol, so Xfixes version l.n.m corresponds to protocol version l.n
+dnl
+AC_INIT(libXdamage, 1.0.1, [keithp@keithp.com], libXdamage)
+AM_INIT_AUTOMAKE([dist-bzip2])
+AM_MAINTAINER_MODE
+
+AM_CONFIG_HEADER(config.h)
+AC_CONFIG_AUX_DIR(.)
+
+# Check for progs
+AC_PROG_CC
+AC_PROG_LIBTOOL
+
+# Check for X
+PKG_CHECK_MODULES(X, x11,
+ [x_found_with_pkgconfig=yes],
+ [x_found_with_pkgconfig=no])
+
+if test "$x_found_with_pkgconfig" = "no"
+then
+ AC_PATH_XTRA
+ X_LIBS="$X_LIBS -lX11"
+
+ if test "x$no_x" = "xyes"
+ then
+ AC_MSG_ERROR([X is required, but it was either disabled or not found.])
+ fi
+
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $X_CFLAGS"
+ LIBS="$LIBS $X_LIBS"
+
+ AC_MSG_CHECKING([for XTHREADS in Xlib])
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
+ [[return XInitThreads() == 0 ? 0 : 1;]])],
+ [xthreads=no],
+ [xthreads=yes],
+ [xthreads=yes])
+
+ AC_MSG_RESULT($xthreads)
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ if test "x$xthreads" = "xyes"
+ then
+ X_CFLAGS="$X_CFLAGS -DXTHREADS"
+ fi
+fi
+
+# Check damageext configuration, strip extra digits from package version to
+# find the required protocol version
+
+DAMAGEEXT_VERSION=[`echo $VERSION | sed 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`]
+PKG_CHECK_MODULES(XDAMAGE, [damageext >= $DAMAGEEXT_VERSION] xfixes)
+
+AC_OUTPUT([Makefile
+ xdamage.pc])
+
diff --git a/nx-X11/lib/Xdamage/xdamage.pc.in b/nx-X11/lib/Xdamage/xdamage.pc.in
new file mode 100644
index 000000000..dbf77ac57
--- /dev/null
+++ b/nx-X11/lib/Xdamage/xdamage.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Xdamage
+Description: X Damage Library
+Version: @VERSION@
+Cflags: -I${includedir} @XDAMAGE_CFLAGS@ @X_CFLAGS@
+Libs: -L${libdir} -lXdamage @XDAMAGE_LIBS@ @X_LIBS@
diff --git a/nx-X11/lib/Xdamage/xdamageint.h b/nx-X11/lib/Xdamage/xdamageint.h
new file mode 100644
index 000000000..145d6610f
--- /dev/null
+++ b/nx-X11/lib/Xdamage/xdamageint.h
@@ -0,0 +1,66 @@
+/*
+ * $Id: xdamageint.h,v 1.2 2005/07/03 07:00:56 daniels Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _XDAMAGEINT_H_
+#define _XDAMAGEINT_H_
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/damageproto.h>
+#include "Xdamage.h"
+
+typedef struct _XDamageExtDisplayInfo {
+ struct _XDamageExtDisplayInfo *next; /* keep a linked list */
+ Display *display; /* which display this is */
+ XExtCodes *codes; /* the extension protocol codes */
+ int major_version; /* -1 means we don't know */
+ int minor_version; /* -1 means we don't know */
+} XDamageExtDisplayInfo;
+
+/* replaces XExtensionInfo */
+typedef struct _XDamageExtInfo {
+ XDamageExtDisplayInfo *head; /* start of the list */
+ XDamageExtDisplayInfo *cur; /* most recently used */
+ int ndisplays; /* number of displays */
+} XDamageExtInfo;
+
+extern XDamageExtInfo XDamageExtensionInfo;
+extern const char XDamageExtensionName[];
+
+XDamageExtDisplayInfo *
+XDamageFindDisplay (Display *dpy);
+
+#define XDamageHasExtension(i) ((i) && ((i)->codes))
+
+#define XDamageCheckExtension(dpy,i,val) \
+ if (!XDamageHasExtension(i)) { return val; }
+
+#define XDamageSimpleCheckExtension(dpy,i) \
+ if (!XDamageHasExtension(i)) { return; }
+
+#endif /* _XDAMAGEINT_H_ */
diff --git a/nx-X11/lib/Xdmcp/A8Eq.c b/nx-X11/lib/Xdmcp/A8Eq.c
new file mode 100644
index 000000000..b98658017
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/A8Eq.c
@@ -0,0 +1,50 @@
+/*
+ * $Xorg: A8Eq.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpARRAY8Equal (array1, array2)
+ ARRAY8Ptr array1, array2;
+{
+ int i;
+
+ if (array1->length != array2->length)
+ return FALSE;
+ for (i = 0; i < (int)array1->length; i++)
+ if (array1->data[i] != array2->data[i])
+ return FALSE;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/AA16.c b/nx-X11/lib/Xdmcp/AA16.c
new file mode 100644
index 000000000..5de5cafee
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/AA16.c
@@ -0,0 +1,51 @@
+/*
+ * $Xorg: AA16.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/AA16.c,v 1.3 2001/01/17 19:42:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpAllocARRAY16 (ARRAY16Ptr array, int length)
+{
+ CARD16Ptr newData;
+
+ newData = (CARD16Ptr) Xalloc (length * sizeof (CARD16));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/AA32.c b/nx-X11/lib/Xdmcp/AA32.c
new file mode 100644
index 000000000..fbeded1f9
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/AA32.c
@@ -0,0 +1,51 @@
+/*
+ * $Xorg: AA32.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/AA32.c,v 1.3 2001/01/17 19:42:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpAllocARRAY32 (ARRAY32Ptr array, int length)
+{
+ CARD32Ptr newData;
+
+ newData = (CARD32Ptr) Xalloc (length * sizeof (CARD32));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/AA8.c b/nx-X11/lib/Xdmcp/AA8.c
new file mode 100644
index 000000000..391e78874
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/AA8.c
@@ -0,0 +1,51 @@
+/*
+ * $Xorg: AA8.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/AA8.c,v 1.3 2001/01/17 19:42:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpAllocARRAY8 (ARRAY8Ptr array, int length)
+{
+ CARD8Ptr newData;
+
+ newData = (CARD8Ptr) Xalloc (length * sizeof (CARD8));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/Alloc.c b/nx-X11/lib/Xdmcp/Alloc.c
new file mode 100644
index 000000000..40cbacf0b
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/Alloc.c
@@ -0,0 +1,66 @@
+/*
+ * $Xorg: Alloc.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/Alloc.c,v 3.4 2001/07/25 15:04:50 dawes Exp $ */
+
+/* stubs for use when Xalloc, Xrealloc and Xfree are not defined */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+#include <stdlib.h>
+
+void *
+Xalloc (unsigned long amount)
+{
+ if (amount == 0)
+ amount = 1;
+ return malloc (amount);
+}
+
+void *
+Xrealloc (void *old, unsigned long amount)
+{
+ if (amount == 0)
+ amount = 1;
+ if (!old)
+ return malloc (amount);
+ return realloc ((char *) old, amount);
+}
+
+void
+Xfree (void *old)
+{
+ if (old)
+ free ((char *) old);
+}
diff --git a/nx-X11/lib/Xdmcp/AofA8.c b/nx-X11/lib/Xdmcp/AofA8.c
new file mode 100644
index 000000000..fe773300d
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/AofA8.c
@@ -0,0 +1,51 @@
+/*
+ * $Xorg: AofA8.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/AofA8.c,v 1.3 2001/01/17 19:42:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpAllocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length)
+{
+ ARRAY8Ptr newData;
+
+ newData = (ARRAY8Ptr) Xalloc (length * sizeof (ARRAY8));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/CA8.c b/nx-X11/lib/Xdmcp/CA8.c
new file mode 100644
index 000000000..efdd5a17b
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/CA8.c
@@ -0,0 +1,49 @@
+/*
+ * $Xorg: CA8.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+#include <X11/Xfuncs.h>
+
+int
+XdmcpCopyARRAY8 (src, dst)
+ ARRAY8Ptr src, dst;
+{
+ dst->length = src->length;
+ dst->data = (CARD8 *) Xalloc (dst->length * sizeof (CARD8));
+ if (!dst->data)
+ return FALSE;
+ memmove (dst->data, src->data, src->length * sizeof (CARD8));
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/CmpKey.c b/nx-X11/lib/Xdmcp/CmpKey.c
new file mode 100644
index 000000000..112bc2006
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/CmpKey.c
@@ -0,0 +1,49 @@
+/*
+ * $Xorg: CmpKey.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/CmpKey.c,v 1.3 2001/01/17 19:42:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpCompareKeys (XdmAuthKeyPtr a, XdmAuthKeyPtr b)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ if (a->data[i] != b->data[i])
+ return FALSE;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/DA16.c b/nx-X11/lib/Xdmcp/DA16.c
new file mode 100644
index 000000000..021accee5
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/DA16.c
@@ -0,0 +1,46 @@
+/*
+ * $Xorg: DA16.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/DA16.c,v 1.5 2001/01/17 19:42:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+void
+XdmcpDisposeARRAY16 (ARRAY16Ptr array)
+{
+ if (array->data != NULL) Xfree (array->data);
+ array->length = 0;
+ array->data = NULL;
+}
diff --git a/nx-X11/lib/Xdmcp/DA32.c b/nx-X11/lib/Xdmcp/DA32.c
new file mode 100644
index 000000000..9d9620b81
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/DA32.c
@@ -0,0 +1,45 @@
+/*
+ * $Xorg: DA32.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+void
+XdmcpDisposeARRAY32 (array)
+ ARRAY32Ptr array;
+{
+ if (array->data != NULL) Xfree (array->data);
+ array->length = 0;
+ array->data = NULL;
+}
diff --git a/nx-X11/lib/Xdmcp/DA8.c b/nx-X11/lib/Xdmcp/DA8.c
new file mode 100644
index 000000000..9c206904d
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/DA8.c
@@ -0,0 +1,45 @@
+/*
+ * $Xorg: DA8.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+void
+XdmcpDisposeARRAY8 (array)
+ ARRAY8Ptr array;
+{
+ if (array->data != NULL) Xfree (array->data);
+ array->length = 0;
+ array->data = NULL;
+}
diff --git a/nx-X11/lib/Xdmcp/DAofA8.c b/nx-X11/lib/Xdmcp/DAofA8.c
new file mode 100644
index 000000000..73a2e9c75
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/DAofA8.c
@@ -0,0 +1,51 @@
+/* $Xdotorg: $
+ * $Xorg: DAofA8.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+void
+XdmcpDisposeARRAYofARRAY8 (array)
+ ARRAYofARRAY8Ptr array;
+{
+ int i;
+
+ if (array->data != NULL) {
+ for (i = 0; i < (int)array->length; i++)
+ XdmcpDisposeARRAY8 (&array->data[i]);
+ Xfree (array->data);
+ }
+ array->length = 0;
+ array->data = NULL;
+}
diff --git a/nx-X11/lib/Xdmcp/DecKey.c b/nx-X11/lib/Xdmcp/DecKey.c
new file mode 100644
index 000000000..fe08cc33f
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/DecKey.c
@@ -0,0 +1,49 @@
+/*
+ * $Xorg: DecKey.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/DecKey.c,v 1.3 2001/01/17 19:42:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+void
+XdmcpDecrementKey (XdmAuthKeyPtr key)
+{
+ int i;
+
+ i = 7;
+ while (key->data[i]-- == 0)
+ if (--i < 0)
+ break;
+}
diff --git a/nx-X11/lib/Xdmcp/Fill.c b/nx-X11/lib/Xdmcp/Fill.c
new file mode 100644
index 000000000..08f6b350a
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/Fill.c
@@ -0,0 +1,102 @@
+/*
+ * $Xorg: Fill.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/Fill.c,v 3.8 2001/07/23 13:15:42 dawes Exp $ */
+
+#ifdef WIN32
+#define _WILLWINSOCK_
+#endif
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+#ifdef STREAMSCONN
+#include <tiuser.h>
+#else
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#else
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif /* !Lynx */
+#endif
+#endif
+
+int
+XdmcpFill (fd, buffer, from, fromlen)
+ int fd;
+ XdmcpBufferPtr buffer;
+ XdmcpNetaddr from; /* return */
+ int *fromlen; /* return */
+{
+ BYTE *newBuf;
+#ifdef STREAMSCONN
+ struct t_unitdata dataunit;
+ int gotallflag, result;
+#endif
+
+ if (buffer->size < XDM_MAX_MSGLEN)
+ {
+ newBuf = (BYTE *) Xalloc (XDM_MAX_MSGLEN);
+ if (newBuf)
+ {
+ Xfree (buffer->data);
+ buffer->data = newBuf;
+ buffer->size = XDM_MAX_MSGLEN;
+ }
+ }
+ buffer->pointer = 0;
+#ifdef STREAMSCONN
+ dataunit.addr.buf = from;
+ dataunit.addr.maxlen = *fromlen;
+ dataunit.opt.maxlen = 0; /* don't care to know about options */
+ dataunit.udata.buf = (char *)buffer->data;
+ dataunit.udata.maxlen = buffer->size;
+ result = t_rcvudata (fd, &dataunit, &gotallflag);
+ if (result < 0) {
+ return FALSE;
+ }
+ buffer->count = dataunit.udata.len;
+ *fromlen = dataunit.addr.len;
+#else
+ buffer->count = recvfrom (fd, (char*)buffer->data, buffer->size, 0,
+ (struct sockaddr *)from, (void *)fromlen);
+#endif
+ if (buffer->count < 6) {
+ buffer->count = 0;
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/Flush.c b/nx-X11/lib/Xdmcp/Flush.c
new file mode 100644
index 000000000..d04cdb378
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/Flush.c
@@ -0,0 +1,83 @@
+/*
+ * $Xorg: Flush.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/Flush.c,v 3.7 2001/07/23 13:15:42 dawes Exp $ */
+
+#ifdef WIN32
+#define _WILLWINSOCK_
+#endif
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+#ifdef STREAMSCONN
+#include <tiuser.h>
+#else
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#else
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif /* !Lynx */
+#endif
+#endif
+
+int
+XdmcpFlush (fd, buffer, to, tolen)
+ int fd;
+ XdmcpBufferPtr buffer;
+ XdmcpNetaddr to;
+ int tolen;
+{
+ int result;
+#ifdef STREAMSCONN
+ struct t_unitdata dataunit;
+
+ dataunit.addr.buf = to;
+ dataunit.addr.len = tolen;
+ dataunit.opt.len = 0; /* default options */
+ dataunit.udata.buf = (char *)buffer->data;
+ dataunit.udata.len = buffer->pointer;
+ result = t_sndudata(fd, &dataunit);
+ if (result < 0)
+ return FALSE;
+#else
+ result = sendto (fd, (char *)buffer->data, buffer->pointer, 0,
+ (struct sockaddr *)to, tolen);
+ if (result != buffer->pointer)
+ return FALSE;
+#endif
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/GenKey.c b/nx-X11/lib/Xdmcp/GenKey.c
new file mode 100644
index 000000000..0d702560e
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/GenKey.c
@@ -0,0 +1,74 @@
+/*
+ * $Xorg: GenKey.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/GenKey.c,v 3.7 2001/07/25 15:04:50 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+static void
+getbits (long data, unsigned char *dst)
+{
+ dst[0] = (data ) & 0xff;
+ dst[1] = (data >> 8) & 0xff;
+ dst[2] = (data >> 16) & 0xff;
+ dst[3] = (data >> 24) & 0xff;
+}
+
+#define Time_t time_t
+
+#include <stdlib.h>
+
+#if defined(SYSV) || defined(SVR4)
+#define srandom srand48
+#define random lrand48
+#endif
+#ifdef WIN32
+#include <process.h>
+#define srandom srand
+#define random rand
+#define getpid(x) _getpid(x)
+#endif
+
+void
+XdmcpGenerateKey (XdmAuthKeyPtr key)
+{
+ long lowbits, highbits;
+
+ srandom ((int)getpid() ^ time((Time_t *)0));
+ lowbits = random ();
+ highbits = random ();
+ getbits (lowbits, key->data);
+ getbits (highbits, key->data + 4);
+}
diff --git a/nx-X11/lib/Xdmcp/Imakefile b/nx-X11/lib/Xdmcp/Imakefile
new file mode 100644
index 000000000..08b91cd45
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/Imakefile
@@ -0,0 +1,121 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:45:48 cpqbld Exp $
+XCOMM $XdotOrg: xc/lib/Xdmcp/Imakefile,v 1.3 2005/09/22 23:54:18 alanc Exp $
+
+
+
+XCOMM $XFree86: xc/lib/Xdmcp/Imakefile,v 3.4 1999/04/17 09:08:12 dawes Exp $
+
+#define DoNormalLib NormalLibXdmcp
+#define DoSharedLib SharedLibXdmcp
+#define DoExtraLib SharedLibXdmcp
+#define DoDebugLib DebugLibXdmcp
+#define DoProfileLib ProfileLibXdmcp
+#define LibName Xdmcp
+#define SoRev SOXDMCPREV
+#define IncSubdir X11
+
+#ifdef SharedXdmcpReqs
+REQUIREDLIBS = SharedXdmcpReqs
+#endif
+
+#if HasXdmAuth
+AUTHDEFS = -DHASXDMAUTH
+AUTHSRCS = Wrap.c Unwrap.c Wraphelp.c
+AUTHOBJS = Wrap.o Unwrap.o Wraphelp.o
+#endif
+
+DEFINES = $(AUTHDEFS)
+
+HEADERS = Xdmcp.h
+
+SRCS = \
+ A8Eq.c \
+ AA8.c \
+ AA16.c \
+ AA32.c \
+ AofA8.c \
+ CA8.c \
+ DA8.c \
+ DA16.c \
+ DA32.c \
+ DAofA8.c \
+ Fill.c \
+ Flush.c \
+ RA8.c \
+ RA16.c \
+ RA32.c \
+ RAofA8.c \
+ RC8.c \
+ RC16.c \
+ RC32.c \
+ RHead.c \
+ RR.c \
+ RaA8.c \
+ RaA16.c \
+ RaA32.c \
+ RaAoA8.c \
+ WA8.c \
+ WA16.c \
+ WA32.c \
+ WAofA8.c \
+ WC8.c \
+ WC16.c \
+ WC32.c \
+ Whead.c \
+ Alloc.c \
+ CmpKey.c \
+ DecKey.c \
+ GenKey.c \
+ IncKey.c \
+ $(AUTHSRCS)
+
+OBJS = \
+ A8Eq.o \
+ AA8.o \
+ AA16.o \
+ AA32.o \
+ AofA8.o \
+ CA8.o \
+ DA8.o \
+ DA16.o \
+ DA32.o \
+ DAofA8.o \
+ Fill.o \
+ Flush.o \
+ RA8.o \
+ RA16.o \
+ RA32.o \
+ RAofA8.o \
+ RC8.o \
+ RC16.o \
+ RC32.o \
+ RHead.o \
+ RR.o \
+ RaA8.o \
+ RaA16.o \
+ RaA32.o \
+ RaAoA8.o \
+ WA8.o \
+ WA16.o \
+ WA32.o \
+ WAofA8.o \
+ WC8.o \
+ WC16.o \
+ WC32.o \
+ Whead.o \
+ Alloc.o \
+ CmpKey.o \
+ DecKey.o \
+ GenKey.o \
+ IncKey.o \
+ $(AUTHOBJS)
+
+#include <Library.tmpl>
+
+#ifdef WraphelpSourceRule
+WraphelpSourceRule()
+#endif
+SpecialCLibObjectRule(Fill,$(ICONFIGFILES),$(CONNECTION_FLAGS))
+SpecialCLibObjectRule(Flush,$(ICONFIGFILES),$(CONNECTION_FLAGS))
+
+DependTarget()
diff --git a/nx-X11/lib/Xdmcp/IncKey.c b/nx-X11/lib/Xdmcp/IncKey.c
new file mode 100644
index 000000000..292413a49
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/IncKey.c
@@ -0,0 +1,49 @@
+/*
+ * $Xorg: IncKey.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/IncKey.c,v 1.3 2001/01/17 19:42:43 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+void
+XdmcpIncrementKey (XdmAuthKeyPtr key)
+{
+ int i;
+
+ i = 7;
+ while (++key->data[i] == 0)
+ if (--i < 0)
+ break;
+}
diff --git a/nx-X11/lib/Xdmcp/RA16.c b/nx-X11/lib/Xdmcp/RA16.c
new file mode 100644
index 000000000..cdaaa226c
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/RA16.c
@@ -0,0 +1,72 @@
+/*
+ * $Xorg: RA16.c,v 1.5 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadARRAY16 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAY16Ptr array;
+{
+ int i;
+
+ if (!XdmcpReadCARD8 (buffer, &array->length)) {
+
+ /* Must set array->data to NULL to guarantee safe call of
+ * XdmcpDisposeARRAY*(array) (which calls Xfree(array->data));
+ * see defect 7329 */
+ array->data = 0;
+ return FALSE;
+ }
+ if (!array->length)
+ {
+ array->data = NULL;
+ return TRUE;
+ }
+ array->data = (CARD16 *) Xalloc (array->length * sizeof (CARD16));
+ if (!array->data)
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ {
+ if (!XdmcpReadCARD16 (buffer, &array->data[i]))
+ {
+ Xfree (array->data);
+ array->data = NULL;
+ array->length = 0;
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/RA32.c b/nx-X11/lib/Xdmcp/RA32.c
new file mode 100644
index 000000000..09f72da48
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/RA32.c
@@ -0,0 +1,72 @@
+/*
+ * $Xorg: RA32.c,v 1.5 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadARRAY32 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAY32Ptr array;
+{
+ int i;
+
+ if (!XdmcpReadCARD8 (buffer, &array->length)) {
+
+ /* Must set array->data to NULL to guarantee safe call of
+ * XdmcpDisposeARRAY*(array) (which calls Xfree(array->data));
+ * see defect 7329 */
+ array->data = 0;
+ return FALSE;
+ }
+ if (!array->length)
+ {
+ array->data = NULL;
+ return TRUE;
+ }
+ array->data = (CARD32 *) Xalloc (array->length * sizeof (CARD32));
+ if (!array->data)
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ {
+ if (!XdmcpReadCARD32 (buffer, &array->data[i]))
+ {
+ Xfree (array->data);
+ array->data = NULL;
+ array->length = 0;
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/RA8.c b/nx-X11/lib/Xdmcp/RA8.c
new file mode 100644
index 000000000..eee3c6b3b
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/RA8.c
@@ -0,0 +1,72 @@
+/*
+ * $Xorg: RA8.c,v 1.5 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadARRAY8 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAY8Ptr array;
+{
+ int i;
+
+ if (!XdmcpReadCARD16 (buffer, &array->length)) {
+
+ /* Must set array->data to NULL to guarantee safe call of
+ * XdmcpDisposeARRAY*(array) (which calls Xfree(array->data));
+ * see defect 7329 */
+ array->data = 0;
+ return FALSE;
+ }
+ if (!array->length)
+ {
+ array->data = NULL;
+ return TRUE;
+ }
+ array->data = (CARD8 *) Xalloc (array->length * sizeof (CARD8));
+ if (!array->data)
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ {
+ if (!XdmcpReadCARD8 (buffer, &array->data[i]))
+ {
+ Xfree (array->data);
+ array->data = NULL;
+ array->length = 0;
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/RAofA8.c b/nx-X11/lib/Xdmcp/RAofA8.c
new file mode 100644
index 000000000..568236c61
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/RAofA8.c
@@ -0,0 +1,75 @@
+/*
+ * $Xorg: RAofA8.c,v 1.6 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadARRAYofARRAY8 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAYofARRAY8Ptr array;
+{
+ int i;
+
+ if (!XdmcpReadCARD8 (buffer, &array->length)) {
+
+ /* Must set array->data to NULL to guarantee safe call of
+ * XdmcpDisposeARRAY*(array) (which calls Xfree(array->data));
+ * see defect 7329 */
+ array->data = 0;
+ return FALSE;
+ }
+ if (!array->length)
+ {
+ array->data = NULL;
+ return TRUE;
+ }
+ array->data = (ARRAY8 *) Xalloc (array->length * sizeof (ARRAY8));
+ if (!array->data)
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ {
+ if (!XdmcpReadARRAY8 (buffer, &array->data[i]))
+ {
+
+ /* All arrays allocated thus far in the loop must be freed
+ * if there is an error in the read.
+ * See Defect 7328 */
+ array->length = i;
+ XdmcpDisposeARRAYofARRAY8(array);
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/RC16.c b/nx-X11/lib/Xdmcp/RC16.c
new file mode 100644
index 000000000..1af69a663
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/RC16.c
@@ -0,0 +1,52 @@
+/*
+ * $Xorg: RC16.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadCARD16 (buffer, valuep)
+ XdmcpBufferPtr buffer;
+ CARD16Ptr valuep;
+{
+ CARD8 high, low;
+
+ if (XdmcpReadCARD8 (buffer, &high) &&
+ XdmcpReadCARD8 (buffer, &low))
+ {
+ *valuep = (((CARD16) high) << 8) | ((CARD16) low);
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/nx-X11/lib/Xdmcp/RC32.c b/nx-X11/lib/Xdmcp/RC32.c
new file mode 100644
index 000000000..caf19e643
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/RC32.c
@@ -0,0 +1,56 @@
+/*
+ * $Xorg: RC32.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadCARD32 (buffer, valuep)
+ XdmcpBufferPtr buffer;
+ CARD32Ptr valuep;
+{
+ CARD8 byte0, byte1, byte2, byte3;
+ if (XdmcpReadCARD8 (buffer, &byte0) &&
+ XdmcpReadCARD8 (buffer, &byte1) &&
+ XdmcpReadCARD8 (buffer, &byte2) &&
+ XdmcpReadCARD8 (buffer, &byte3))
+ {
+ *valuep = (((CARD32) byte0) << 24) |
+ (((CARD32) byte1) << 16) |
+ (((CARD32) byte2) << 8) |
+ (((CARD32) byte3));
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/nx-X11/lib/Xdmcp/RC8.c b/nx-X11/lib/Xdmcp/RC8.c
new file mode 100644
index 000000000..a9cd068a9
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/RC8.c
@@ -0,0 +1,47 @@
+/*
+ * $Xorg: RC8.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadCARD8 (buffer, valuep)
+ XdmcpBufferPtr buffer;
+ CARD8Ptr valuep;
+{
+ if (buffer->pointer >= buffer->count)
+ return FALSE;
+ *valuep = (CARD8) buffer->data[buffer->pointer++];
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/RHead.c b/nx-X11/lib/Xdmcp/RHead.c
new file mode 100644
index 000000000..6b0b837bd
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/RHead.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: RHead.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadHeader (buffer, header)
+ XdmcpBufferPtr buffer;
+ XdmcpHeaderPtr header;
+{
+ if (XdmcpReadCARD16 (buffer, &header->version) &&
+ XdmcpReadCARD16 (buffer, &header->opcode) &&
+ XdmcpReadCARD16 (buffer, &header->length))
+ return TRUE;
+ return FALSE;
+}
diff --git a/nx-X11/lib/Xdmcp/RR.c b/nx-X11/lib/Xdmcp/RR.c
new file mode 100644
index 000000000..2d7d2dba7
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/RR.c
@@ -0,0 +1,43 @@
+/*
+ * $Xorg: RR.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadRemaining (buffer)
+ XdmcpBufferPtr buffer;
+{
+ return buffer->count - buffer->pointer;
+}
diff --git a/nx-X11/lib/Xdmcp/RaA16.c b/nx-X11/lib/Xdmcp/RaA16.c
new file mode 100644
index 000000000..b02fa2f05
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/RaA16.c
@@ -0,0 +1,51 @@
+/*
+ * $Xorg: RaA16.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/RaA16.c,v 1.3 2001/01/17 19:42:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReallocARRAY16 (ARRAY16Ptr array, int length)
+{
+ CARD16Ptr newData;
+
+ newData = (CARD16Ptr) Xrealloc (array->data, length * sizeof (CARD16));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/RaA32.c b/nx-X11/lib/Xdmcp/RaA32.c
new file mode 100644
index 000000000..52167d1e4
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/RaA32.c
@@ -0,0 +1,51 @@
+/*
+ * $Xorg: RaA32.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/RaA32.c,v 1.3 2001/01/17 19:42:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReallocARRAY32 (ARRAY32Ptr array, int length)
+{
+ CARD32Ptr newData;
+
+ newData = (CARD32Ptr) Xrealloc (array->data, length * sizeof (CARD32));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/RaA8.c b/nx-X11/lib/Xdmcp/RaA8.c
new file mode 100644
index 000000000..3e7bc08e4
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/RaA8.c
@@ -0,0 +1,51 @@
+/*
+ * $Xorg: RaA8.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/RaA8.c,v 1.3 2001/01/17 19:42:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReallocARRAY8 (ARRAY8Ptr array, int length)
+{
+ CARD8Ptr newData;
+
+ newData = (CARD8Ptr) Xrealloc (array->data, length * sizeof (CARD8));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/RaAoA8.c b/nx-X11/lib/Xdmcp/RaAoA8.c
new file mode 100644
index 000000000..8b4806c5b
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/RaAoA8.c
@@ -0,0 +1,51 @@
+/*
+ * $Xorg: RaAoA8.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/RaAoA8.c,v 1.3 2001/01/17 19:42:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReallocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length)
+{
+ ARRAY8Ptr newData;
+
+ newData = (ARRAY8Ptr) Xrealloc (array->data, length * sizeof (ARRAY8));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/Unwrap.c b/nx-X11/lib/Xdmcp/Unwrap.c
new file mode 100644
index 000000000..0d60c2bed
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/Unwrap.c
@@ -0,0 +1,95 @@
+/*
+ * $Xorg: Unwrap.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/Unwrap.c,v 1.3 2001/01/17 19:42:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+#ifdef HASXDMAUTH
+
+/*
+ * The following function exists only to demonstrate the
+ * desired functional interface for this routine. You will
+ * need to add the appropriate algorithm if you wish to
+ * use XDM-AUTHENTICATION-1/XDM-AUTHORIZATION-1.
+ *
+ * The interface for this routine is quite simple. All three
+ * arguments are arrays of 8 unsigned characters, the first two
+ * are 64 bits of useful data, the last is 56 bits of useful
+ * data packed into 8 bytes, using the low 7 bits of each
+ * byte, filling the high bit with odd parity.
+ *
+ * Examine the XDMCP specification for the correct algorithm
+ */
+
+#include "Wrap.h"
+
+void
+XdmcpUnwrap (
+ unsigned char *input,
+ unsigned char *wrapper,
+ unsigned char *output,
+ int bytes)
+{
+ int i, j, k;
+ unsigned char tmp[8];
+ unsigned char blocks[2][8];
+ unsigned char expand_wrapper[8];
+ auth_wrapper_schedule schedule;
+
+ _XdmcpWrapperToOddParity (wrapper, expand_wrapper);
+ _XdmcpAuthSetup (expand_wrapper, schedule);
+
+ k = 0;
+ for (j = 0; j < bytes; j += 8)
+ {
+ if (bytes - j < 8)
+ return; /* bad input length */
+ for (i = 0; i < 8; i++)
+ blocks[k][i] = input[j + i];
+ _XdmcpAuthDoIt ((unsigned char *) (input + j), (unsigned char *) tmp, schedule, 0);
+ /* block chaining */
+ k = (k == 0) ? 1 : 0;
+ for (i = 0; i < 8; i++)
+ {
+ if (j == 0)
+ output[j + i] = tmp[i];
+ else
+ output[j + i] = tmp[i] ^ blocks[k][i];
+ }
+ }
+}
+
+#endif /* HASXDMAUTH */
diff --git a/nx-X11/lib/Xdmcp/WA16.c b/nx-X11/lib/Xdmcp/WA16.c
new file mode 100644
index 000000000..4551161e4
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/WA16.c
@@ -0,0 +1,51 @@
+/*
+ * $Xorg: WA16.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteARRAY16 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAY16Ptr array;
+{
+ int i;
+
+ if (!XdmcpWriteCARD8 (buffer, array->length))
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ if (!XdmcpWriteCARD16 (buffer, array->data[i]))
+ return FALSE;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/WA32.c b/nx-X11/lib/Xdmcp/WA32.c
new file mode 100644
index 000000000..8d61b1e37
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/WA32.c
@@ -0,0 +1,51 @@
+/*
+ * $Xorg: WA32.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteARRAY32 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAY32Ptr array;
+{
+ int i;
+
+ if (!XdmcpWriteCARD8 (buffer, array->length))
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ if (!XdmcpWriteCARD32 (buffer, array->data[i]))
+ return FALSE;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/WA8.c b/nx-X11/lib/Xdmcp/WA8.c
new file mode 100644
index 000000000..43443c9f6
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/WA8.c
@@ -0,0 +1,51 @@
+/*
+ * $Xorg: WA8.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteARRAY8 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAY8Ptr array;
+{
+ int i;
+
+ if (!XdmcpWriteCARD16 (buffer, array->length))
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ if (!XdmcpWriteCARD8 (buffer, array->data[i]))
+ return FALSE;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/WAofA8.c b/nx-X11/lib/Xdmcp/WAofA8.c
new file mode 100644
index 000000000..69f7bd051
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/WAofA8.c
@@ -0,0 +1,51 @@
+/*
+ * $Xorg: WAofA8.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteARRAYofARRAY8 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAYofARRAY8Ptr array;
+{
+ int i;
+
+ if (!XdmcpWriteCARD8 (buffer, array->length))
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ if (!XdmcpWriteARRAY8 (buffer, &array->data[i]))
+ return FALSE;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/WC16.c b/nx-X11/lib/Xdmcp/WC16.c
new file mode 100644
index 000000000..945171d8c
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/WC16.c
@@ -0,0 +1,50 @@
+/*
+ * $Xorg: WC16.c,v 1.4 2001/02/09 02:03:48 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/WC16.c,v 1.4 2001/01/17 19:42:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteCARD16 (
+ XdmcpBufferPtr buffer,
+ unsigned value)
+{
+ if (!XdmcpWriteCARD8 (buffer, value >> 8))
+ return FALSE;
+ if (!XdmcpWriteCARD8 (buffer, value & 0xff))
+ return FALSE;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/WC32.c b/nx-X11/lib/Xdmcp/WC32.c
new file mode 100644
index 000000000..2d5df8340
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/WC32.c
@@ -0,0 +1,53 @@
+/*
+ * $Xorg: WC32.c,v 1.4 2001/02/09 02:03:49 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xdmcp/WC32.c,v 1.4 2001/01/17 19:42:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteCARD32 (
+ XdmcpBufferPtr buffer,
+ unsigned value)
+{
+ if (!XdmcpWriteCARD8 (buffer, value >> 24))
+ return FALSE;
+ if (!XdmcpWriteCARD8 (buffer, (value >> 16) & 0xff))
+ return FALSE;
+ if (!XdmcpWriteCARD8 (buffer, (value >> 8) & 0xff))
+ return FALSE;
+ if (!XdmcpWriteCARD8 (buffer, value & 0xff))
+ return FALSE;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/WC8.c b/nx-X11/lib/Xdmcp/WC8.c
new file mode 100644
index 000000000..2cbd6f1bf
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/WC8.c
@@ -0,0 +1,49 @@
+/*
+ * $Xorg: WC8.c,v 1.4 2001/02/09 02:03:49 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/WC8.c,v 1.4 2001/01/17 19:42:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteCARD8 (
+ XdmcpBufferPtr buffer,
+ unsigned value)
+{
+ if (buffer->pointer >= buffer->size)
+ return FALSE;
+ buffer->data[buffer->pointer++] = (BYTE) value;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/Whead.c b/nx-X11/lib/Xdmcp/Whead.c
new file mode 100644
index 000000000..82c55c9d2
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/Whead.c
@@ -0,0 +1,64 @@
+/*
+ * $Xorg: Whead.c,v 1.4 2001/02/09 02:03:49 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/Whead.c,v 1.3 2001/01/17 19:42:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteHeader (
+ XdmcpBufferPtr buffer,
+ XdmcpHeaderPtr header)
+{
+ BYTE *newData;
+
+ if ((int)buffer->size < 6 + (int)header->length)
+ {
+ newData = (BYTE *) Xalloc (XDM_MAX_MSGLEN * sizeof (BYTE));
+ if (!newData)
+ return FALSE;
+ Xfree ((unsigned long *)(buffer->data));
+ buffer->data = newData;
+ buffer->size = XDM_MAX_MSGLEN;
+ }
+ buffer->pointer = 0;
+ if (!XdmcpWriteCARD16 (buffer, header->version))
+ return FALSE;
+ if (!XdmcpWriteCARD16 (buffer, header->opcode))
+ return FALSE;
+ if (!XdmcpWriteCARD16 (buffer, header->length))
+ return FALSE;
+ return TRUE;
+}
diff --git a/nx-X11/lib/Xdmcp/Wrap.c b/nx-X11/lib/Xdmcp/Wrap.c
new file mode 100644
index 000000000..d8a032abc
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/Wrap.c
@@ -0,0 +1,133 @@
+/*
+ * $Xorg: Wrap.c,v 1.4 2001/02/09 02:03:49 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.
+ * *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/lib/Xdmcp/Wrap.c,v 1.3 2001/01/17 19:42:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+#ifdef HASXDMAUTH
+
+/*
+ * The following function exists only to demonstrate the
+ * desired functional interface for this routine. You will
+ * need to add the appropriate algorithm if you wish to
+ * use XDM-AUTHENTICATION-1/XDM-AUTHORIZATION-1.
+ *
+ * Examine the XDMCP specification for the correct algorithm
+ */
+
+#include "Wrap.h"
+
+void
+XdmcpWrap (
+ unsigned char *input,
+ unsigned char *wrapper,
+ unsigned char *output,
+ int bytes)
+{
+ int i, j;
+ int len;
+ unsigned char tmp[8];
+ unsigned char expand_wrapper[8];
+ auth_wrapper_schedule schedule;
+
+ _XdmcpWrapperToOddParity (wrapper, expand_wrapper);
+ _XdmcpAuthSetup (expand_wrapper, schedule);
+ for (j = 0; j < bytes; j += 8)
+ {
+ len = 8;
+ if (bytes - j < len)
+ len = bytes - j;
+ /* block chaining */
+ for (i = 0; i < len; i++)
+ {
+ if (j == 0)
+ tmp[i] = input[i];
+ else
+ tmp[i] = input[j + i] ^ output[j - 8 + i];
+ }
+ for (; i < 8; i++)
+ {
+ if (j == 0)
+ tmp[i] = 0;
+ else
+ tmp[i] = 0 ^ output[j - 8 + i];
+ }
+ _XdmcpAuthDoIt (tmp, (output + j), schedule, 1);
+ }
+}
+
+/*
+ * Given a 56 bit wrapper in XDMCP format, create a 56
+ * bit wrapper in 7-bits + odd parity format
+ */
+
+static int
+OddParity (unsigned char c)
+{
+ c = c ^ (c >> 4);
+ c = c ^ (c >> 2);
+ c = c ^ (c >> 1);
+ return ~c & 0x1;
+}
+
+/*
+ * Spread the 56 bit wrapper among 8 bytes, using the upper 7 bits
+ * of each byte, and storing an odd parity bit in the low bit
+ */
+
+void
+_XdmcpWrapperToOddParity (
+ unsigned char *in,
+ unsigned char *out)
+{
+ int ashift, bshift;
+ int i;
+ unsigned char c;
+
+ ashift = 7;
+ bshift = 1;
+ for (i = 0; i < 7; i++)
+ {
+ c = ((in[i] << ashift) | (in[i+1] >> bshift)) & 0x7f;
+ out[i] = (c << 1) | OddParity (c);
+ ashift--;
+ bshift++;
+ }
+ c = in[i];
+ out[i] = (c << 1) | OddParity(c);
+}
+
+#endif
diff --git a/nx-X11/lib/Xdmcp/Wrap.h b/nx-X11/lib/Xdmcp/Wrap.h
new file mode 100644
index 000000000..511254933
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/Wrap.h
@@ -0,0 +1,19 @@
+/* $XdotOrg: xc/lib/Xdmcp/Wrap.h,v 1.6 2005/07/03 07:00:56 daniels Exp $ */
+/* $Xorg: Wrap.h,v 1.3 2000/08/17 19:45:50 cpqbld Exp $ */
+/*
+ * header file for compatibility with something useful
+ */
+
+/* $XFree86: xc/lib/Xdmcp/Wrap.h,v 1.3 2001/01/17 19:42:44 dawes Exp $ */
+
+typedef unsigned char auth_cblock[8]; /* block size */
+
+typedef struct auth_ks_struct { auth_cblock _; } auth_wrapper_schedule[16];
+
+extern void _XdmcpWrapperToOddParity (unsigned char *in, unsigned char *out);
+
+#ifdef HASXDMAUTH
+extern void _XdmcpAuthSetup (auth_cblock key, auth_wrapper_schedule schedule);
+extern void _XdmcpAuthDoIt (auth_cblock input, auth_cblock output,
+ auth_wrapper_schedule schedule, int edflag);
+#endif
diff --git a/nx-X11/lib/Xdmcp/Wraphelp.README.crypto b/nx-X11/lib/Xdmcp/Wraphelp.README.crypto
new file mode 100644
index 000000000..20c34c071
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/Wraphelp.README.crypto
@@ -0,0 +1,64 @@
+Export Requirements.
+
+You may not export or re-export this software or any copy or
+adaptation in violation of any applicable laws or regulations.
+
+Without limiting the generality of the foregoing, hardware, software,
+technology or services provided under this license agreement may not
+be exported, reexported, transferred or downloaded to or within (or to
+a national resident of) countries under U.S. economic embargo
+including the following countries:
+
+Cuba, Iran, Libya, North Korea, Sudan and Syria. This list is subject
+to change.
+
+Hardware, software, technology or services may not be exported,
+reexported, transferred or downloaded to persons or entities listed on
+the U.S. Department of Commerce Denied Persons List, Entity List of
+proliferation concern or on any U.S. Treasury Department Designated
+Nationals exclusion list, or to parties directly or indirectly
+involved in the development or production of nuclear, chemical,
+biological weapons or in missile technology programs as specified in
+the U.S. Export Administration Regulations (15 CFR 744).
+
+By accepting this license agreement you confirm that you are not
+located in (or a national resident of) any country under U.S. economic
+embargo, not identified on any U.S. Department of Commerce Denied
+Persons List, Entity List or Treasury Department Designated Nationals
+exclusion list, and not directly or indirectly involved in the
+development or production of nuclear, chemical, biological weapons or
+in missile technology programs as specified in the U.S. Export
+Administration Regulations.
+
+Software available on this web site contains cryptography and is
+therefore subject to US government export control under the
+U.S. Export Administration Regulations ("EAR"). EAR Part 740.13(e)
+allows the export and reexport of publicly available encryption source
+code that is not subject to payment of license fee or royalty
+payment. Object code resulting from the compiling of such source code
+may also be exported and reexported under this provision if publicly
+available and not subject to a fee or payment other than reasonable
+and customary fees for reproduction and distribution. This kind of
+encryption source code and the corresponding object code may be
+exported or reexported without prior U.S. government export license
+authorization provided that the U.S. government is notified about the
+Internet location of the software.
+
+The open source software available on this web site is publicly
+available without license fee or royalty payment, and all binary
+software is compiled from the source code. The U.S. government has
+been notified about this site and the location site for the source
+code. Therefore, the source code and compiled object code may be
+downloaded and exported under U.S. export license exception (without a
+U.S. export license) in accordance with the further restrictions
+outlined above regarding embargoed countries, restricted persons and
+restricted end uses.
+
+Local Country Import Requirements. The software you are about to
+download contains cryptography technology. Some countries regulate the
+import, use and/or export of certain products with cryptography. The
+X.org Foundation makes no claims as to the applicability of local
+country import, use and/or export regulations in relation to the
+download of this product. If you are located outside the U.S. and
+Canada you are advised to consult your local country regulations to
+insure compliance.
diff --git a/nx-X11/lib/Xdmcp/Wraphelp.c b/nx-X11/lib/Xdmcp/Wraphelp.c
new file mode 100644
index 000000000..8e50ee222
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/Wraphelp.c
@@ -0,0 +1,500 @@
+/*
+ * $Xorg: A8Eq.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <sys/types.h>
+#include <X11/Xmd.h>
+#include "Wrap.h"
+
+/* des routines for non-usa - eay 10/9/1991 eay@psych.psy.uq.oz.au
+ * These routines were written for speed not size so they are bigger than
+ * needed. I have removed some of the loop unrolling, this will reduce
+ * code size at the expense of some speed.
+ * 25/9/1991 eay - much faster _XdmcpAuthSetup (4 times faster).
+ * 19/9/1991 eay - cleaned up the IP and FP code.
+ * 10/9/1991 eay - first release.
+ * The des routines this file has been made from can be found in
+ * ftp.psy.uq.oz.au /pub/DES
+ * This particular version derived from OpenBSD Revsion 1.3.
+ */
+
+/*
+ *
+ * Export Requirements.
+ * You may not export or re-export this software or any copy or
+ * adaptation in violation of any applicable laws or regulations.
+ *
+ * Without limiting the generality of the foregoing, hardware, software,
+ * technology or services provided under this license agreement may not
+ * be exported, reexported, transferred or downloaded to or within (or to
+ * a national resident of) countries under U.S. economic embargo
+ * including the following countries:
+ *
+ * Cuba, Iran, Libya, North Korea, Sudan and Syria. This list is subject
+ * to change.
+ *
+ * Hardware, software, technology or services may not be exported,
+ * reexported, transferred or downloaded to persons or entities listed on
+ * the U.S. Department of Commerce Denied Persons List, Entity List of
+ * proliferation concern or on any U.S. Treasury Department Designated
+ * Nationals exclusion list, or to parties directly or indirectly
+ * involved in the development or production of nuclear, chemical,
+ * biological weapons or in missile technology programs as specified in
+ * the U.S. Export Administration Regulations (15 CFR 744).
+ *
+ * By accepting this license agreement you confirm that you are not
+ * located in (or a national resident of) any country under U.S. economic
+ * embargo, not identified on any U.S. Department of Commerce Denied
+ * Persons List, Entity List or Treasury Department Designated Nationals
+ * exclusion list, and not directly or indirectly involved in the
+ * development or production of nuclear, chemical, biological weapons or
+ * in missile technology programs as specified in the U.S. Export
+ * Administration Regulations.
+ *
+ *
+ * Local Country Import Requirements. The software you are about to
+ * download contains cryptography technology. Some countries regulate the
+ * import, use and/or export of certain products with cryptography. The
+ * X.org Foundation makes no claims as to the applicability of local
+ * country import, use and/or export regulations in relation to the
+ * download of this product. If you are located outside the U.S. and
+ * Canada you are advised to consult your local country regulations to
+ * insure compliance.
+ */
+
+static CARD32 skb[8][64] = {
+ /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
+ { 0x00000000,0x00000010,0x20000000,0x20000010,
+ 0x00010000,0x00010010,0x20010000,0x20010010,
+ 0x00000800,0x00000810,0x20000800,0x20000810,
+ 0x00010800,0x00010810,0x20010800,0x20010810,
+ 0x00000020,0x00000030,0x20000020,0x20000030,
+ 0x00010020,0x00010030,0x20010020,0x20010030,
+ 0x00000820,0x00000830,0x20000820,0x20000830,
+ 0x00010820,0x00010830,0x20010820,0x20010830,
+ 0x00080000,0x00080010,0x20080000,0x20080010,
+ 0x00090000,0x00090010,0x20090000,0x20090010,
+ 0x00080800,0x00080810,0x20080800,0x20080810,
+ 0x00090800,0x00090810,0x20090800,0x20090810,
+ 0x00080020,0x00080030,0x20080020,0x20080030,
+ 0x00090020,0x00090030,0x20090020,0x20090030,
+ 0x00080820,0x00080830,0x20080820,0x20080830,
+ 0x00090820,0x00090830,0x20090820,0x20090830 },
+ /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
+ { 0x00000000,0x02000000,0x00002000,0x02002000,
+ 0x00200000,0x02200000,0x00202000,0x02202000,
+ 0x00000004,0x02000004,0x00002004,0x02002004,
+ 0x00200004,0x02200004,0x00202004,0x02202004,
+ 0x00000400,0x02000400,0x00002400,0x02002400,
+ 0x00200400,0x02200400,0x00202400,0x02202400,
+ 0x00000404,0x02000404,0x00002404,0x02002404,
+ 0x00200404,0x02200404,0x00202404,0x02202404,
+ 0x10000000,0x12000000,0x10002000,0x12002000,
+ 0x10200000,0x12200000,0x10202000,0x12202000,
+ 0x10000004,0x12000004,0x10002004,0x12002004,
+ 0x10200004,0x12200004,0x10202004,0x12202004,
+ 0x10000400,0x12000400,0x10002400,0x12002400,
+ 0x10200400,0x12200400,0x10202400,0x12202400,
+ 0x10000404,0x12000404,0x10002404,0x12002404,
+ 0x10200404,0x12200404,0x10202404,0x12202404 },
+ /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
+ { 0x00000000,0x00000001,0x00040000,0x00040001,
+ 0x01000000,0x01000001,0x01040000,0x01040001,
+ 0x00000002,0x00000003,0x00040002,0x00040003,
+ 0x01000002,0x01000003,0x01040002,0x01040003,
+ 0x00000200,0x00000201,0x00040200,0x00040201,
+ 0x01000200,0x01000201,0x01040200,0x01040201,
+ 0x00000202,0x00000203,0x00040202,0x00040203,
+ 0x01000202,0x01000203,0x01040202,0x01040203,
+ 0x08000000,0x08000001,0x08040000,0x08040001,
+ 0x09000000,0x09000001,0x09040000,0x09040001,
+ 0x08000002,0x08000003,0x08040002,0x08040003,
+ 0x09000002,0x09000003,0x09040002,0x09040003,
+ 0x08000200,0x08000201,0x08040200,0x08040201,
+ 0x09000200,0x09000201,0x09040200,0x09040201,
+ 0x08000202,0x08000203,0x08040202,0x08040203,
+ 0x09000202,0x09000203,0x09040202,0x09040203 },
+ /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
+ { 0x00000000,0x00100000,0x00000100,0x00100100,
+ 0x00000008,0x00100008,0x00000108,0x00100108,
+ 0x00001000,0x00101000,0x00001100,0x00101100,
+ 0x00001008,0x00101008,0x00001108,0x00101108,
+ 0x04000000,0x04100000,0x04000100,0x04100100,
+ 0x04000008,0x04100008,0x04000108,0x04100108,
+ 0x04001000,0x04101000,0x04001100,0x04101100,
+ 0x04001008,0x04101008,0x04001108,0x04101108,
+ 0x00020000,0x00120000,0x00020100,0x00120100,
+ 0x00020008,0x00120008,0x00020108,0x00120108,
+ 0x00021000,0x00121000,0x00021100,0x00121100,
+ 0x00021008,0x00121008,0x00021108,0x00121108,
+ 0x04020000,0x04120000,0x04020100,0x04120100,
+ 0x04020008,0x04120008,0x04020108,0x04120108,
+ 0x04021000,0x04121000,0x04021100,0x04121100,
+ 0x04021008,0x04121008,0x04021108,0x04121108 },
+ /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
+ { 0x00000000,0x10000000,0x00010000,0x10010000,
+ 0x00000004,0x10000004,0x00010004,0x10010004,
+ 0x20000000,0x30000000,0x20010000,0x30010000,
+ 0x20000004,0x30000004,0x20010004,0x30010004,
+ 0x00100000,0x10100000,0x00110000,0x10110000,
+ 0x00100004,0x10100004,0x00110004,0x10110004,
+ 0x20100000,0x30100000,0x20110000,0x30110000,
+ 0x20100004,0x30100004,0x20110004,0x30110004,
+ 0x00001000,0x10001000,0x00011000,0x10011000,
+ 0x00001004,0x10001004,0x00011004,0x10011004,
+ 0x20001000,0x30001000,0x20011000,0x30011000,
+ 0x20001004,0x30001004,0x20011004,0x30011004,
+ 0x00101000,0x10101000,0x00111000,0x10111000,
+ 0x00101004,0x10101004,0x00111004,0x10111004,
+ 0x20101000,0x30101000,0x20111000,0x30111000,
+ 0x20101004,0x30101004,0x20111004,0x30111004 },
+ /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
+ { 0x00000000,0x08000000,0x00000008,0x08000008,
+ 0x00000400,0x08000400,0x00000408,0x08000408,
+ 0x00020000,0x08020000,0x00020008,0x08020008,
+ 0x00020400,0x08020400,0x00020408,0x08020408,
+ 0x00000001,0x08000001,0x00000009,0x08000009,
+ 0x00000401,0x08000401,0x00000409,0x08000409,
+ 0x00020001,0x08020001,0x00020009,0x08020009,
+ 0x00020401,0x08020401,0x00020409,0x08020409,
+ 0x02000000,0x0A000000,0x02000008,0x0A000008,
+ 0x02000400,0x0A000400,0x02000408,0x0A000408,
+ 0x02020000,0x0A020000,0x02020008,0x0A020008,
+ 0x02020400,0x0A020400,0x02020408,0x0A020408,
+ 0x02000001,0x0A000001,0x02000009,0x0A000009,
+ 0x02000401,0x0A000401,0x02000409,0x0A000409,
+ 0x02020001,0x0A020001,0x02020009,0x0A020009,
+ 0x02020401,0x0A020401,0x02020409,0x0A020409 },
+ /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
+ { 0x00000000,0x00000100,0x00080000,0x00080100,
+ 0x01000000,0x01000100,0x01080000,0x01080100,
+ 0x00000010,0x00000110,0x00080010,0x00080110,
+ 0x01000010,0x01000110,0x01080010,0x01080110,
+ 0x00200000,0x00200100,0x00280000,0x00280100,
+ 0x01200000,0x01200100,0x01280000,0x01280100,
+ 0x00200010,0x00200110,0x00280010,0x00280110,
+ 0x01200010,0x01200110,0x01280010,0x01280110,
+ 0x00000200,0x00000300,0x00080200,0x00080300,
+ 0x01000200,0x01000300,0x01080200,0x01080300,
+ 0x00000210,0x00000310,0x00080210,0x00080310,
+ 0x01000210,0x01000310,0x01080210,0x01080310,
+ 0x00200200,0x00200300,0x00280200,0x00280300,
+ 0x01200200,0x01200300,0x01280200,0x01280300,
+ 0x00200210,0x00200310,0x00280210,0x00280310,
+ 0x01200210,0x01200310,0x01280210,0x01280310 },
+ /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
+ { 0x00000000,0x04000000,0x00040000,0x04040000,
+ 0x00000002,0x04000002,0x00040002,0x04040002,
+ 0x00002000,0x04002000,0x00042000,0x04042000,
+ 0x00002002,0x04002002,0x00042002,0x04042002,
+ 0x00000020,0x04000020,0x00040020,0x04040020,
+ 0x00000022,0x04000022,0x00040022,0x04040022,
+ 0x00002020,0x04002020,0x00042020,0x04042020,
+ 0x00002022,0x04002022,0x00042022,0x04042022,
+ 0x00000800,0x04000800,0x00040800,0x04040800,
+ 0x00000802,0x04000802,0x00040802,0x04040802,
+ 0x00002800,0x04002800,0x00042800,0x04042800,
+ 0x00002802,0x04002802,0x00042802,0x04042802,
+ 0x00000820,0x04000820,0x00040820,0x04040820,
+ 0x00000822,0x04000822,0x00040822,0x04040822,
+ 0x00002820,0x04002820,0x00042820,0x04042820,
+ 0x00002822,0x04002822,0x00042822,0x04042822 }
+};
+
+
+static CARD32 SPtrans[8][64] = {
+ /* nibble 0 */
+ { 0x00410100, 0x00010000, 0x40400000, 0x40410100,
+ 0x00400000, 0x40010100, 0x40010000, 0x40400000,
+ 0x40010100, 0x00410100, 0x00410000, 0x40000100,
+ 0x40400100, 0x00400000, 0x00000000, 0x40010000,
+ 0x00010000, 0x40000000, 0x00400100, 0x00010100,
+ 0x40410100, 0x00410000, 0x40000100, 0x00400100,
+ 0x40000000, 0x00000100, 0x00010100, 0x40410000,
+ 0x00000100, 0x40400100, 0x40410000, 0x00000000,
+ 0x00000000, 0x40410100, 0x00400100, 0x40010000,
+ 0x00410100, 0x00010000, 0x40000100, 0x00400100,
+ 0x40410000, 0x00000100, 0x00010100, 0x40400000,
+ 0x40010100, 0x40000000, 0x40400000, 0x00410000,
+ 0x40410100, 0x00010100, 0x00410000, 0x40400100,
+ 0x00400000, 0x40000100, 0x40010000, 0x00000000,
+ 0x00010000, 0x00400000, 0x40400100, 0x00410100,
+ 0x40000000, 0x40410000, 0x00000100, 0x40010100 },
+
+ /* nibble 1 */
+ { 0x08021002, 0x00000000, 0x00021000, 0x08020000,
+ 0x08000002, 0x00001002, 0x08001000, 0x00021000,
+ 0x00001000, 0x08020002, 0x00000002, 0x08001000,
+ 0x00020002, 0x08021000, 0x08020000, 0x00000002,
+ 0x00020000, 0x08001002, 0x08020002, 0x00001000,
+ 0x00021002, 0x08000000, 0x00000000, 0x00020002,
+ 0x08001002, 0x00021002, 0x08021000, 0x08000002,
+ 0x08000000, 0x00020000, 0x00001002, 0x08021002,
+ 0x00020002, 0x08021000, 0x08001000, 0x00021002,
+ 0x08021002, 0x00020002, 0x08000002, 0x00000000,
+ 0x08000000, 0x00001002, 0x00020000, 0x08020002,
+ 0x00001000, 0x08000000, 0x00021002, 0x08001002,
+ 0x08021000, 0x00001000, 0x00000000, 0x08000002,
+ 0x00000002, 0x08021002, 0x00021000, 0x08020000,
+ 0x08020002, 0x00020000, 0x00001002, 0x08001000,
+ 0x08001002, 0x00000002, 0x08020000, 0x00021000 },
+
+ /* nibble 2 */
+ { 0x20800000, 0x00808020, 0x00000020, 0x20800020,
+ 0x20008000, 0x00800000, 0x20800020, 0x00008020,
+ 0x00800020, 0x00008000, 0x00808000, 0x20000000,
+ 0x20808020, 0x20000020, 0x20000000, 0x20808000,
+ 0x00000000, 0x20008000, 0x00808020, 0x00000020,
+ 0x20000020, 0x20808020, 0x00008000, 0x20800000,
+ 0x20808000, 0x00800020, 0x20008020, 0x00808000,
+ 0x00008020, 0x00000000, 0x00800000, 0x20008020,
+ 0x00808020, 0x00000020, 0x20000000, 0x00008000,
+ 0x20000020, 0x20008000, 0x00808000, 0x20800020,
+ 0x00000000, 0x00808020, 0x00008020, 0x20808000,
+ 0x20008000, 0x00800000, 0x20808020, 0x20000000,
+ 0x20008020, 0x20800000, 0x00800000, 0x20808020,
+ 0x00008000, 0x00800020, 0x20800020, 0x00008020,
+ 0x00800020, 0x00000000, 0x20808000, 0x20000020,
+ 0x20800000, 0x20008020, 0x00000020, 0x00808000 },
+
+ /* nibble 3 */
+ { 0x00080201, 0x02000200, 0x00000001, 0x02080201,
+ 0x00000000, 0x02080000, 0x02000201, 0x00080001,
+ 0x02080200, 0x02000001, 0x02000000, 0x00000201,
+ 0x02000001, 0x00080201, 0x00080000, 0x02000000,
+ 0x02080001, 0x00080200, 0x00000200, 0x00000001,
+ 0x00080200, 0x02000201, 0x02080000, 0x00000200,
+ 0x00000201, 0x00000000, 0x00080001, 0x02080200,
+ 0x02000200, 0x02080001, 0x02080201, 0x00080000,
+ 0x02080001, 0x00000201, 0x00080000, 0x02000001,
+ 0x00080200, 0x02000200, 0x00000001, 0x02080000,
+ 0x02000201, 0x00000000, 0x00000200, 0x00080001,
+ 0x00000000, 0x02080001, 0x02080200, 0x00000200,
+ 0x02000000, 0x02080201, 0x00080201, 0x00080000,
+ 0x02080201, 0x00000001, 0x02000200, 0x00080201,
+ 0x00080001, 0x00080200, 0x02080000, 0x02000201,
+ 0x00000201, 0x02000000, 0x02000001, 0x02080200 },
+
+ /* nibble 4 */
+ { 0x01000000, 0x00002000, 0x00000080, 0x01002084,
+ 0x01002004, 0x01000080, 0x00002084, 0x01002000,
+ 0x00002000, 0x00000004, 0x01000004, 0x00002080,
+ 0x01000084, 0x01002004, 0x01002080, 0x00000000,
+ 0x00002080, 0x01000000, 0x00002004, 0x00000084,
+ 0x01000080, 0x00002084, 0x00000000, 0x01000004,
+ 0x00000004, 0x01000084, 0x01002084, 0x00002004,
+ 0x01002000, 0x00000080, 0x00000084, 0x01002080,
+ 0x01002080, 0x01000084, 0x00002004, 0x01002000,
+ 0x00002000, 0x00000004, 0x01000004, 0x01000080,
+ 0x01000000, 0x00002080, 0x01002084, 0x00000000,
+ 0x00002084, 0x01000000, 0x00000080, 0x00002004,
+ 0x01000084, 0x00000080, 0x00000000, 0x01002084,
+ 0x01002004, 0x01002080, 0x00000084, 0x00002000,
+ 0x00002080, 0x01002004, 0x01000080, 0x00000084,
+ 0x00000004, 0x00002084, 0x01002000, 0x01000004 },
+
+ /* nibble 5 */
+ { 0x10000008, 0x00040008, 0x00000000, 0x10040400,
+ 0x00040008, 0x00000400, 0x10000408, 0x00040000,
+ 0x00000408, 0x10040408, 0x00040400, 0x10000000,
+ 0x10000400, 0x10000008, 0x10040000, 0x00040408,
+ 0x00040000, 0x10000408, 0x10040008, 0x00000000,
+ 0x00000400, 0x00000008, 0x10040400, 0x10040008,
+ 0x10040408, 0x10040000, 0x10000000, 0x00000408,
+ 0x00000008, 0x00040400, 0x00040408, 0x10000400,
+ 0x00000408, 0x10000000, 0x10000400, 0x00040408,
+ 0x10040400, 0x00040008, 0x00000000, 0x10000400,
+ 0x10000000, 0x00000400, 0x10040008, 0x00040000,
+ 0x00040008, 0x10040408, 0x00040400, 0x00000008,
+ 0x10040408, 0x00040400, 0x00040000, 0x10000408,
+ 0x10000008, 0x10040000, 0x00040408, 0x00000000,
+ 0x00000400, 0x10000008, 0x10000408, 0x10040400,
+ 0x10040000, 0x00000408, 0x00000008, 0x10040008 },
+
+ /* nibble 6 */
+ { 0x00000800, 0x00000040, 0x00200040, 0x80200000,
+ 0x80200840, 0x80000800, 0x00000840, 0x00000000,
+ 0x00200000, 0x80200040, 0x80000040, 0x00200800,
+ 0x80000000, 0x00200840, 0x00200800, 0x80000040,
+ 0x80200040, 0x00000800, 0x80000800, 0x80200840,
+ 0x00000000, 0x00200040, 0x80200000, 0x00000840,
+ 0x80200800, 0x80000840, 0x00200840, 0x80000000,
+ 0x80000840, 0x80200800, 0x00000040, 0x00200000,
+ 0x80000840, 0x00200800, 0x80200800, 0x80000040,
+ 0x00000800, 0x00000040, 0x00200000, 0x80200800,
+ 0x80200040, 0x80000840, 0x00000840, 0x00000000,
+ 0x00000040, 0x80200000, 0x80000000, 0x00200040,
+ 0x00000000, 0x80200040, 0x00200040, 0x00000840,
+ 0x80000040, 0x00000800, 0x80200840, 0x00200000,
+ 0x00200840, 0x80000000, 0x80000800, 0x80200840,
+ 0x80200000, 0x00200840, 0x00200800, 0x80000800 },
+
+ /* nibble 7 */
+ { 0x04100010, 0x04104000, 0x00004010, 0x00000000,
+ 0x04004000, 0x00100010, 0x04100000, 0x04104010,
+ 0x00000010, 0x04000000, 0x00104000, 0x00004010,
+ 0x00104010, 0x04004010, 0x04000010, 0x04100000,
+ 0x00004000, 0x00104010, 0x00100010, 0x04004000,
+ 0x04104010, 0x04000010, 0x00000000, 0x00104000,
+ 0x04000000, 0x00100000, 0x04004010, 0x04100010,
+ 0x00100000, 0x00004000, 0x04104000, 0x00000010,
+ 0x00100000, 0x00004000, 0x04000010, 0x04104010,
+ 0x00004010, 0x04000000, 0x00000000, 0x00104000,
+ 0x04100010, 0x04004010, 0x04004000, 0x00100010,
+ 0x04104000, 0x00000010, 0x00100010, 0x04004000,
+ 0x04104010, 0x00100000, 0x04100000, 0x04000010,
+ 0x00104000, 0x00004010, 0x04004010, 0x04100000,
+ 0x00000010, 0x04104000, 0x00104010, 0x00000000,
+ 0x04000000, 0x04100010, 0x00004000, 0x00104010}
+};
+
+#define ITERATIONS 16
+#define HALF_ITERATIONS 8
+
+#define c2l(c,l) (l =((CARD32)(*((c)++))) , \
+ l|=((CARD32)(*((c)++)))<< 8, \
+ l|=((CARD32)(*((c)++)))<<16, \
+ l|=((CARD32)(*((c)++)))<<24)
+
+#define l2c(l,c) (*((c)++)=(CARD8)(((l) )&0xff), \
+ *((c)++)=(CARD8)(((l)>> 8)&0xff), \
+ *((c)++)=(CARD8)(((l)>>16)&0xff), \
+ *((c)++)=(CARD8)(((l)>>24)&0xff))
+
+#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
+ (b)^=(t),\
+ (a)^=((t)<<(n)))
+
+#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
+ (a)=(a)^(t)^(t>>(16-(n))))\
+
+static char shifts2[16] = {0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
+
+void _XdmcpAuthSetup(auth_cblock key, auth_wrapper_schedule schedule)
+{
+ CARD32 c,d,t,s;
+ CARD8 *in;
+ CARD32 *k;
+ int i;
+
+ k=(CARD32 *)schedule;
+ in=(CARD8 *)key;
+
+ c2l(in,c);
+ c2l(in,d);
+
+ /* do PC1 in 60 simple operations */
+ PERM_OP(d,c,t,4,0x0f0f0f0f);
+ HPERM_OP(c,t,-2, 0xcccc0000);
+ HPERM_OP(c,t,-1, 0xaaaa0000);
+ HPERM_OP(c,t, 8, 0x00ff0000);
+ HPERM_OP(c,t,-1, 0xaaaa0000);
+ HPERM_OP(d,t,-8, 0xff000000);
+ HPERM_OP(d,t, 8, 0x00ff0000);
+ HPERM_OP(d,t, 2, 0x33330000);
+ d=((d&0x00aa00aa)<<7)|((d&0x55005500)>>7)|(d&0xaa55aa55);
+ d=(d>>8)|((c&0xf0000000)>>4);
+ c&=0x0fffffff;
+
+ for (i=0; i<ITERATIONS; i++) {
+ if (shifts2[i]) {
+ c=((c>>2)|(c<<26)); d=((d>>2)|(d<<26));
+ } else {
+ c=((c>>1)|(c<<27)); d=((d>>1)|(d<<27));
+ }
+ c&=0x0fffffff;
+ d&=0x0fffffff;
+ /* could be a few less shifts but I am to lazy at this
+ * point in time to investigate */
+ s= skb[0][ (c )&0x3f ]|
+ skb[1][((c>> 6)&0x03)|((c>> 7)&0x3c)]|
+ skb[2][((c>>13)&0x0f)|((c>>14)&0x30)]|
+ skb[3][((c>>20)&0x01)|((c>>21)&0x06) |
+ ((c>>22)&0x38)];
+ t= skb[4][ (d )&0x3f ]|
+ skb[5][((d>> 7)&0x03)|((d>> 8)&0x3c)]|
+ skb[6][ (d>>15)&0x3f ]|
+ skb[7][((d>>21)&0x0f)|((d>>22)&0x30)];
+
+ /* table contained 0213 4657 */
+ *(k++)=((t<<16)|(s&0x0000ffff));
+ s= ((s>>16)|(t&0xffff0000));
+
+ s=(s<<4)|(s>>28);
+ *(k++)=s;
+ }
+ return;
+}
+
+#define D_ENCRYPT(L,R,S) \
+ t=(R<<1)|(R>>31); \
+ u=(t^s[S ]); \
+ t=(t^s[S+1]); \
+ t=(t>>4)|(t<<28); \
+ L^= SPtrans[1][(t )&0x3f]| \
+ SPtrans[3][(t>> 8)&0x3f]| \
+ SPtrans[5][(t>>16)&0x3f]| \
+ SPtrans[7][(t>>24)&0x3f]| \
+ SPtrans[0][(u )&0x3f]| \
+ SPtrans[2][(u>> 8)&0x3f]| \
+ SPtrans[4][(u>>16)&0x3f]| \
+ SPtrans[6][(u>>24)&0x3f];
+
+
+void _XdmcpAuthDoIt(auth_cblock input, auth_cblock output,
+ auth_wrapper_schedule ks, int encrypt)
+{
+ CARD32 l,r,t,u;
+ CARD32 *s;
+ CARD8 *in,*out;
+ int i;
+
+ in=(CARD8 *)input;
+ out=(CARD8 *)output;
+ c2l(in,l);
+ c2l(in,r);
+
+ /* do IP */
+ PERM_OP(r,l,t, 4,0x0f0f0f0f);
+ PERM_OP(l,r,t,16,0x0000ffff);
+ PERM_OP(r,l,t, 2,0x33333333);
+ PERM_OP(l,r,t, 8,0x00ff00ff);
+ PERM_OP(r,l,t, 1,0x55555555);
+ /* r and l are reversed - remember that :-) */
+ t=l;
+ l=r;
+ r=t;
+
+ s=(CARD32 *)ks;
+
+ if (encrypt) {
+ for (i=0; i<(ITERATIONS*2); i+=4) {
+ D_ENCRYPT(l,r, i); /* 1 */
+ D_ENCRYPT(r,l, i+2); /* 2 */
+ }
+ } else {
+ for (i=(ITERATIONS*2)-2; i >= 0; i-=4) {
+ D_ENCRYPT(l,r, i); /* 1 */
+ D_ENCRYPT(r,l, i-2); /* 2 */
+ }
+ }
+
+ /* swap l and r
+ * we will not do the swap so just remember they are
+ * reversed for the rest of the subroutine
+ * luckily by FP fixes this problem :-) */
+
+ PERM_OP(r,l,t, 1,0x55555555);
+ PERM_OP(l,r,t, 8,0x00ff00ff);
+ PERM_OP(r,l,t, 2,0x33333333);
+ PERM_OP(l,r,t,16,0x0000ffff);
+ PERM_OP(r,l,t, 4,0x0f0f0f0f);
+
+ l2c(l,out);
+ l2c(r,out);
+ return;
+}
diff --git a/nx-X11/lib/Xdmcp/Xdmcp.h b/nx-X11/lib/Xdmcp/Xdmcp.h
new file mode 100644
index 000000000..8fcf63292
--- /dev/null
+++ b/nx-X11/lib/Xdmcp/Xdmcp.h
@@ -0,0 +1,190 @@
+/* $XdotOrg: xc/lib/Xdmcp/Xdmcp.h,v 1.3 2005/07/03 07:00:56 daniels Exp $ */
+/* $Xorg: Xdmcp.h,v 1.7 2001/04/13 14:43:00 steve Exp $ */
+/*
+ * Copyright 1989 Network Computing Devices, Inc., Mountain View, California.
+ *
+ * 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 N.C.D. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. N.C.D. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ */
+/* $XFree86: xc/lib/Xdmcp/Xdmcp.h,v 3.7 2003/07/09 15:27:29 tsi Exp $ */
+
+#ifndef _XDMCP_H_
+#define _XDMCP_H_
+
+#include <X11/Xmd.h>
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+#define XDM_PROTOCOL_VERSION 1
+#define XDM_UDP_PORT 177
+
+/* IANA has assigned FF0X:0:0:0:0:0:0:12B as the permanently assigned
+ * multicast addresses for XDMCP, where X in the prefix may be replaced
+ * by any valid scope identifier, such as 1 for Node-Local, 2 for Link-Local,
+ * 5 for Site-Local, and so on. We set the default here to the Link-Local
+ * version to most closely match the old IPv4 subnet broadcast behavior.
+ * Both xdm and X -query allow specifying a different address if a different
+ * scope is defined.
+ */
+#define XDM_DEFAULT_MCAST_ADDR6 "ff02:0:0:0:0:0:0:12b"
+
+#define XDM_MAX_MSGLEN 8192
+#define XDM_MIN_RTX 2
+#define XDM_MAX_RTX 32
+#define XDM_RTX_LIMIT 7
+#define XDM_KA_RTX_LIMIT 4
+#define XDM_DEF_DORMANCY (3 * 60) /* 3 minutes */
+#define XDM_MAX_DORMANCY (24 * 60 * 60) /* 24 hours */
+
+typedef enum {
+ BROADCAST_QUERY = 1, QUERY, INDIRECT_QUERY, FORWARD_QUERY,
+ WILLING, UNWILLING, REQUEST, ACCEPT, DECLINE, MANAGE, REFUSE,
+ FAILED, KEEPALIVE, ALIVE
+} xdmOpCode;
+
+typedef enum {
+ XDM_QUERY, XDM_BROADCAST, XDM_INDIRECT, XDM_COLLECT_QUERY,
+ XDM_COLLECT_BROADCAST_QUERY, XDM_COLLECT_INDIRECT_QUERY,
+ XDM_START_CONNECTION, XDM_AWAIT_REQUEST_RESPONSE,
+ XDM_AWAIT_MANAGE_RESPONSE, XDM_MANAGE, XDM_RUN_SESSION, XDM_OFF,
+ XDM_AWAIT_USER_INPUT, XDM_KEEPALIVE, XDM_AWAIT_ALIVE_RESPONSE,
+#if defined(IPv6) && defined(AF_INET6)
+ XDM_MULTICAST, XDM_COLLECT_MULTICAST_QUERY,
+#endif
+ XDM_KEEP_ME_LAST
+} xdmcp_states;
+
+#ifdef NOTDEF
+/* table of hosts */
+
+#define XDM_MAX_STR_LEN 21
+#define XDM_MAX_HOSTS 20
+struct xdm_host_table {
+ struct sockaddr_in sockaddr;
+ char name[XDM_MAX_STR_LEN];
+ char status[XDM_MAX_STR_LEN];
+};
+#endif /* NOTDEF */
+
+typedef CARD8 *CARD8Ptr;
+typedef CARD16 *CARD16Ptr;
+typedef CARD32 *CARD32Ptr;
+
+typedef struct _ARRAY8 {
+ CARD16 length;
+ CARD8Ptr data;
+} ARRAY8, *ARRAY8Ptr;
+
+typedef struct _ARRAY16 {
+ CARD8 length;
+ CARD16Ptr data;
+} ARRAY16, *ARRAY16Ptr;
+
+typedef struct _ARRAY32 {
+ CARD8 length;
+ CARD32Ptr data;
+} ARRAY32, *ARRAY32Ptr;
+
+typedef struct _ARRAYofARRAY8 {
+ CARD8 length;
+ ARRAY8Ptr data;
+} ARRAYofARRAY8, *ARRAYofARRAY8Ptr;
+
+typedef struct _XdmcpHeader {
+ CARD16 version, opcode, length;
+} XdmcpHeader, *XdmcpHeaderPtr;
+
+typedef struct _XdmcpBuffer {
+ BYTE *data;
+ int size; /* size of buffer pointed by to data */
+ int pointer; /* current index into data */
+ int count; /* bytes read from network into data */
+} XdmcpBuffer, *XdmcpBufferPtr;
+
+typedef struct _XdmAuthKey {
+ BYTE data[8];
+} XdmAuthKeyRec, *XdmAuthKeyPtr;
+
+
+/* implementation-independent network address structure.
+ Equiv to sockaddr* for sockets and netbuf* for STREAMS. */
+
+typedef char *XdmcpNetaddr;
+
+extern int XdmcpWriteARRAY16(XdmcpBufferPtr buffer, ARRAY16Ptr array);
+extern int XdmcpWriteARRAY32(XdmcpBufferPtr buffer, ARRAY32Ptr array);
+extern int XdmcpWriteARRAY8(XdmcpBufferPtr buffer, ARRAY8Ptr array);
+extern int XdmcpWriteARRAYofARRAY8(XdmcpBufferPtr buffer, ARRAYofARRAY8Ptr array);
+extern int XdmcpWriteCARD16(XdmcpBufferPtr buffer, unsigned value);
+extern int XdmcpWriteCARD32(XdmcpBufferPtr buffer, unsigned value);
+extern int XdmcpWriteCARD8(XdmcpBufferPtr buffer, unsigned value);
+extern int XdmcpWriteHeader(XdmcpBufferPtr buffer, XdmcpHeaderPtr header);
+
+extern int XdmcpFlush(int fd, XdmcpBufferPtr buffer, XdmcpNetaddr to, int tolen);
+
+extern int XdmcpReadARRAY16(XdmcpBufferPtr buffer, ARRAY16Ptr array);
+extern int XdmcpReadARRAY32(XdmcpBufferPtr buffer, ARRAY32Ptr array);
+extern int XdmcpReadARRAY8(XdmcpBufferPtr buffer, ARRAY8Ptr array);
+extern int XdmcpReadARRAYofARRAY8(XdmcpBufferPtr buffer, ARRAYofARRAY8Ptr array);
+extern int XdmcpReadCARD16(XdmcpBufferPtr buffer, CARD16Ptr valuep);
+extern int XdmcpReadCARD32(XdmcpBufferPtr buffer, CARD32Ptr valuep);
+extern int XdmcpReadCARD8(XdmcpBufferPtr buffer, CARD8Ptr valuep);
+extern int XdmcpReadHeader(XdmcpBufferPtr buffer, XdmcpHeaderPtr header);
+
+extern int XdmcpFill(int fd, XdmcpBufferPtr buffer, XdmcpNetaddr from, int *fromlen);
+
+extern int XdmcpReadRemaining(XdmcpBufferPtr buffer);
+
+extern void XdmcpDisposeARRAY8(ARRAY8Ptr array);
+extern void XdmcpDisposeARRAY16(ARRAY16Ptr array);
+extern void XdmcpDisposeARRAY32(ARRAY32Ptr array);
+extern void XdmcpDisposeARRAYofARRAY8(ARRAYofARRAY8Ptr array);
+
+extern int XdmcpCopyARRAY8(ARRAY8Ptr src, ARRAY8Ptr dst);
+
+extern int XdmcpARRAY8Equal(ARRAY8Ptr array1, ARRAY8Ptr array2);
+
+extern void XdmcpGenerateKey (XdmAuthKeyPtr key);
+extern void XdmcpIncrementKey (XdmAuthKeyPtr key);
+extern void XdmcpDecrementKey (XdmAuthKeyPtr key);
+#ifdef HASXDMAUTH
+extern void XdmcpWrap(unsigned char *input, unsigned char *wrapper, unsigned char *output, int bytes);
+extern void XdmcpUnwrap(unsigned char *input, unsigned char *wrapper, unsigned char *output, int bytes);
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+#if !defined(Xalloc) && !defined(xalloc) && !defined(Xrealloc)
+extern void *Xalloc (unsigned long amount);
+extern void *Xrealloc (void *old, unsigned long amount);
+extern void Xfree(void *old);
+#endif
+
+extern int XdmcpCompareKeys (XdmAuthKeyPtr a, XdmAuthKeyPtr b);
+
+extern int XdmcpAllocARRAY16 (ARRAY16Ptr array, int length);
+extern int XdmcpAllocARRAY32 (ARRAY32Ptr array, int length);
+extern int XdmcpAllocARRAY8 (ARRAY8Ptr array, int length);
+extern int XdmcpAllocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length);
+
+extern int XdmcpReallocARRAY16 (ARRAY16Ptr array, int length);
+extern int XdmcpReallocARRAY32 (ARRAY32Ptr array, int length);
+extern int XdmcpReallocARRAY8 (ARRAY8Ptr array, int length);
+extern int XdmcpReallocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length);
+
+_XFUNCPROTOEND
+
+#endif /* _XDMCP_H_ */
diff --git a/nx-X11/lib/Xevie/AUTHORS b/nx-X11/lib/Xevie/AUTHORS
new file mode 100644
index 000000000..b60343fbd
--- /dev/null
+++ b/nx-X11/lib/Xevie/AUTHORS
@@ -0,0 +1 @@
+Derek Wang, SUN
diff --git a/nx-X11/lib/Xevie/Imakefile b/nx-X11/lib/Xevie/Imakefile
new file mode 100644
index 000000000..24e1f6ef2
--- /dev/null
+++ b/nx-X11/lib/Xevie/Imakefile
@@ -0,0 +1,76 @@
+XCOMM $XdotOrg: xc/lib/Xevie/Imakefile,v 1.4 2005/10/24 23:30:21 alanc Exp $
+
+#ifndef NormalLibXevie
+#define NormalLibXevie YES
+SOXEVIEREV=1.0.0
+#endif
+
+#ifndef SharedLibXevie
+#define SharedLibXevie YES
+#endif
+
+#define DoNormalLib NormalLibXevie
+#define DoSharedLib SharedLibXevie
+#define DoDebugLib DebugLibXevie
+#define DoProfileLib ProfileLibXevie
+
+#define LibName Xevie
+#define SoRev SOXEVIEREV
+#define IncSubdir X11
+#define IncSubSubdir extensions
+
+#ifdef SharedXevieReqs
+REQUIREDLIBS = SharedXevieReqs
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+XEVIE_VERSION=1.0.0
+
+X_LIBS=-L$(SHLIBDIR) $(XONLYLIB)
+X_CFLAGS=-I$(INCROOT) $(THREADS_DEFINES)
+
+RPATH_CFLAG = HardCodeLibdirFlag
+
+ DEFINES = $(ALLOC_DEFINES)
+ INCLUDES = -I. -I$(XLIBSRC) -I$(EXTINCSRC)
+ SRCS = Xevie.c
+ OBJS = Xevie.o
+ LINTLIBS = $(LINTXLIB)
+
+HEADERS= xevieplaceholder.h
+
+SUBSTVARS=prefix="$(PROJECTROOT)" \
+ exec_prefix="$(BINDIR)" \
+ libdir="$(USRLIBDIR)" \
+ hardcode_libdir_flag_spec="$(RPATH_CFLAG)" \
+ includedir="$(INCROOT)" \
+ X_LIBS="$(X_LIBS)" \
+ X_CFLAGS="$(X_CFLAGS)" \
+ VERSION="$(XEVIE_VERSION)"
+
+#include <Library.tmpl>
+
+MANSUFFIX = $(LIBMANSUFFIX)
+
+#define PreprocessManPages
+InstallManPage(Xevie,$(LIBMANDIR))
+
+DependTarget()
+
+all:: xevie.pc
+
+xevie.pc: xevie.pc.in
+ RemoveFile($@)
+ sh ../Xcursor/config-subst $(SUBSTVARS) < xevie.pc.in > $@
+
+InstallNonExecFile(xevie.pc,$(USRLIBDIR)/pkgconfig)
+
+clean::
+ RemoveFile(xevie.pc)
+
+#if ExpandManNames
+InstallManPageAliases(Xevie,$(LIBMANDIR),XevieQueryVersion XevieStart XevieSelectInput XevieSendEvent XevieEnd)
+#endif
diff --git a/nx-X11/lib/Xevie/Xevie.c b/nx-X11/lib/Xevie/Xevie.c
new file mode 100644
index 000000000..9698881b5
--- /dev/null
+++ b/nx-X11/lib/Xevie/Xevie.c
@@ -0,0 +1,211 @@
+/* $XdotOrg: xc/lib/Xevie/Xevie.c,v 1.3 2005/07/03 07:00:56 daniels Exp $ */
+/************************************************************
+
+Copyright 2003 Sun Microsystems, Inc.
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+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
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+************************************************************/
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xevie.h>
+#include <X11/extensions/Xeviestr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+static XExtensionInfo _xevie_info_data;
+static XExtensionInfo *xevie_info = &_xevie_info_data;
+static char *xevie_extension_name = XEVIENAME;
+static int major_opcode = 0;
+static long xevie_mask = 0;
+
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display();
+static /* const */ XExtensionHooks xevie_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xevie_info,
+ xevie_extension_name,
+ &xevie_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xevie_info)
+
+/*****************************************************************************
+ * *
+ * public Xevie Extension routines *
+ * *
+ *****************************************************************************/
+
+Status
+XevieQueryVersion(dpy, major_version_return, minor_version_return)
+ Display* dpy;
+ int* major_version_return;
+ int* minor_version_return;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXevieQueryVersionReply rep;
+ xXevieQueryVersionReq *req;
+
+ XextCheckExtension(dpy, info, xevie_extension_name, False);
+
+ major_opcode = info->codes->major_opcode;
+ LockDisplay(dpy);
+ GetReq(XevieQueryVersion, req);
+ req->reqType = major_opcode;
+ req->xevieReqType = X_XevieQueryVersion;
+ req->client_major_version = XEVIE_MAJOR_VERSION;
+ req->client_minor_version = XEVIE_MINOR_VERSION;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *major_version_return = rep.server_major_version;
+ *minor_version_return = rep.server_minor_version;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/* Win32 reserves 20 colormap entries for its desktop */
+#ifndef TYP_RESERVED_ENTRIES
+#define TYP_RESERVED_ENTRIES 20
+#endif
+
+Status
+#if NeedFunctionPrototypes
+XevieStart(
+ Display* dpy)
+#else
+XevieStart(dpy)
+ Display* dpy;
+#endif
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXevieStartReply rep;
+ xXevieStartReq *req;
+
+ XextCheckExtension(dpy, info, xevie_extension_name, False);
+
+ major_opcode = info->codes->major_opcode;
+ LockDisplay(dpy);
+ GetReq(XevieStart, req);
+ req->reqType = major_opcode;
+ req->xevieReqType = X_XevieStart;
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(rep.pad1);
+}
+
+Status
+XevieEnd(dpy)
+ Display* dpy;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXevieEndReply rep;
+ xXevieEndReq *req;
+
+ XextCheckExtension (dpy, info, xevie_extension_name, False);
+
+ LockDisplay(dpy);
+ GetReq(XevieEnd, req);
+ req->reqType = info->codes->major_opcode;
+ req->xevieReqType = X_XevieEnd;
+
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XevieSendEvent(dpy, event, dataType)
+ Display* dpy;
+ XEvent* event;
+ char dataType;
+{
+ xXevieSendReply rep;
+ xXevieSendReq *req;
+
+ LockDisplay(dpy);
+ GetReq(XevieSend, req);
+ req->reqType = major_opcode;
+ req->xevieReqType = X_XevieSend;
+ req->dataType = dataType;
+ _XEventToWire(dpy, event, &req->event);
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XevieSelectInput(dpy, event_mask)
+ Display* dpy;
+ long event_mask;
+{
+ xXevieSelectInputReply rep;
+ xXevieSelectInputReq *req;
+
+ LockDisplay(dpy);
+ GetReq(XevieSelectInput, req);
+ req->reqType = major_opcode;
+ req->xevieReqType = X_XevieSelectInput;
+ req->event_mask = event_mask;
+ xevie_mask = event_mask;
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
diff --git a/nx-X11/lib/Xevie/Xevie.man b/nx-X11/lib/Xevie/Xevie.man
new file mode 100644
index 000000000..79aeb18c5
--- /dev/null
+++ b/nx-X11/lib/Xevie/Xevie.man
@@ -0,0 +1,88 @@
+.\"
+.\" $XdotOrg: xc/lib/Xevie/Xevie.man,v 1.2 2005/04/04 02:41:49 alanc Exp $
+.\"
+.\"
+.de TQ
+.br
+.ns
+.TP \\$1
+..
+.TH XEVIE __libmansuffix__ __vendorversion__
+
+.SH NAME
+Xevie \- X Event Interception Extension (XEvIE)
+.SH SYNTAX
+\&#include <X11/extensions/Xevie.h>
+.nf
+.sp
+Status XevieQueryVersion \^(\^Display *\fIdpy\fP,
+ int *\fImajor_versionp\fP,
+ int *\fIminor_versionp\fP\^);
+.sp
+Status XevieStart \^(\^Display *\fIdpy\fp\^);
+.sp
+Status XevieSelectInput \^(\^Display *\fIdpy\fP,
+ long \fIevent_mask\fP\^);
+.sp
+Status XevieSendEvent \^(\^
+ \^(\^Display *\fIdpy\fP,
+ XEvent *\fIevent\fP,
+ char *fIdataType\fP\^);
+.sp
+Status XevieEnd \^(\^Display *\fIdpy\fp\^);
+.sp
+
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIevent_mask\fP 1i
+Specifies the mask of events to redirect.
+.IP \fIdatatype\fP 1i
+
+XEVIE_MODIFIED or XEVIE_UNMODIFIED - whether the Xevie client
+has changed or synthesised this event.
+
+.SH DATATYPES
+
+
+.SH DESCRIPTION
+.B X Event Interception Extension (XEvIE)
+is designed for users who need to intercept all the Keyboard and Mouse events.
+Programs can determine which events should be forwarded to other clients and
+modify the events if necessary.
+.PP
+
+.SH FUNCTIONS
+
+.B XevieQueryVersion
+The XevieQueryVersion function returns the major and minor protocol version
+numbers supported by the server.
+XevieQueryVersion returns True if success, otherwise, it returns False.
+
+.B XevieStart
+The XevieStart function requests that the X server enable the XEvIE extension.
+Once XEvIE is successfully enabled, all the XevieSelectInput specified events
+will be sent to the client which has enabled XEvIE.
+If XKB or AccessX is enabled, the events that are sent to the XEvIE clients
+are XKB/AccessX processed (filtered) ones.
+
+.B XevieSendEvent
+Events are sent back to the X server through XevieSendEvent.
+
+.B XevieEnd
+The XevieEnd function requests that the X server disables the XEvIE extension.
+Once XEvIE is disabled successfully, the X server stops sending events to the
+XEvIE client.
+
+.B XevieSelectInput
+The XevieSelectInput function requests that the X server reports the keyboard
+and pointer events associated with the specified event mask.
+By default, X will report KeyPress, KeyRelease, ButtonPress, ButtonRelease
+and MotionNotify events.
+
+.SH RESTRICTIONS
+.B Xevie
+will remain upward compatible after the current 1.0 release.
+.SH AUTHORS
+Derek Wang and Stuart Kreitman, Sun Microsystems, Inc.
+
diff --git a/nx-X11/lib/Xevie/xevie.pc.in b/nx-X11/lib/Xevie/xevie.pc.in
new file mode 100644
index 000000000..88e8b361f
--- /dev/null
+++ b/nx-X11/lib/Xevie/xevie.pc.in
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+xlibs=@X_LIBS@
+xcflags=@X_CFLAGS@
+
+Name: Xevie
+Description: X Event Interceptor Library
+Version: @VERSION@
+Cflags: -I${includedir} ${xcflags}
+Libs: -L${libdir} -lXevie ${xlibs}
diff --git a/nx-X11/lib/Xevie/xevieplaceholder.h b/nx-X11/lib/Xevie/xevieplaceholder.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/lib/Xevie/xevieplaceholder.h
diff --git a/nx-X11/lib/Xext/DPMS.c b/nx-X11/lib/Xext/DPMS.c
new file mode 100644
index 000000000..35b21b4ad
--- /dev/null
+++ b/nx-X11/lib/Xext/DPMS.c
@@ -0,0 +1,293 @@
+/* $Xorg: DPMS.c,v 1.3 2000/08/17 19:45:50 cpqbld Exp $ */
+/*****************************************************************
+
+Copyright (c) 1996 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+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
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xext/DPMS.c,v 3.5 2002/10/16 00:37:27 dawes Exp $ */
+
+/*
+ * HISTORY
+ */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/extensions/dpms.h>
+#include <X11/extensions/dpmsstr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <stdio.h>
+
+static XExtensionInfo _dpms_info_data;
+static XExtensionInfo *dpms_info = &_dpms_info_data;
+static char *dpms_extension_name = DPMSExtensionName;
+
+#define DPMSCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, dpms_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static /* const */ XExtensionHooks dpms_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, dpms_info,
+ dpms_extension_name,
+ &dpms_extension_hooks, DPMSNumberEvents,
+ NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, dpms_info)
+
+/*****************************************************************************
+ * *
+ * public routines *
+ * *
+ *****************************************************************************/
+
+Bool
+DPMSQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+Status
+DPMSGetVersion(Display *dpy, int *major_versionp, int *minor_versionp)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xDPMSGetVersionReply rep;
+ register xDPMSGetVersionReq *req;
+
+ DPMSCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (DPMSGetVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSGetVersion;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ *major_versionp = rep.majorVersion;
+ *minor_versionp = rep.minorVersion;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
+Bool
+DPMSCapable(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSCapableReq *req;
+ xDPMSCapableReply rep;
+
+ DPMSCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(DPMSCapable, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSCapable;
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.capable;
+}
+
+Status
+DPMSSetTimeouts(Display *dpy, CARD16 standby, CARD16 suspend, CARD16 off)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSSetTimeoutsReq *req;
+
+ if ((off != 0)&&(off < suspend))
+ {
+ return BadValue;
+ }
+ if ((suspend != 0)&&(suspend < standby))
+ {
+ return BadValue;
+ }
+
+ DPMSCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(DPMSSetTimeouts, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSSetTimeouts;
+ req->standby = standby;
+ req->suspend = suspend;
+ req->off = off;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+Bool
+DPMSGetTimeouts(Display *dpy, CARD16 *standby, CARD16 *suspend, CARD16 *off)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSGetTimeoutsReq *req;
+ xDPMSGetTimeoutsReply rep;
+
+ DPMSCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(DPMSGetTimeouts, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSGetTimeouts;
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *standby = rep.standby;
+ *suspend = rep.suspend;
+ *off = rep.off;
+ return 1;
+}
+
+Status
+DPMSEnable(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSEnableReq *req;
+
+ DPMSCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(DPMSEnable, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSEnable;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+Status
+DPMSDisable(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSDisableReq *req;
+
+ DPMSCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(DPMSDisable, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSDisable;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+Status
+DPMSForceLevel(Display *dpy, CARD16 level)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSForceLevelReq *req;
+
+ DPMSCheckExtension (dpy, info, 0);
+
+ if ((level != DPMSModeOn) &&
+ (level != DPMSModeStandby) &&
+ (level != DPMSModeSuspend) &&
+ (level != DPMSModeOff))
+ return BadValue;
+
+ LockDisplay(dpy);
+ GetReq(DPMSForceLevel, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSForceLevel;
+ req->level = level;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+Status
+DPMSInfo(Display *dpy, CARD16 *power_level, BOOL *state)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSInfoReq *req;
+ xDPMSInfoReply rep;
+
+ DPMSCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(DPMSInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSInfo;
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *power_level = rep.power_level;
+ *state = rep.state;
+ return 1;
+}
+
+
+
diff --git a/nx-X11/lib/Xext/Imakefile b/nx-X11/lib/Xext/Imakefile
new file mode 100644
index 000000000..b323dc7c2
--- /dev/null
+++ b/nx-X11/lib/Xext/Imakefile
@@ -0,0 +1,46 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:45:50 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/Xext/Imakefile,v 1.12 2002/10/16 00:37:27 dawes Exp $
+
+#define DoNormalLib NormalLibXext
+#define DoSharedLib SharedLibXext
+#define DoExtraLib SharedLibXext
+#define DoDebugLib DebugLibXext
+#define DoProfileLib ProfileLibXext
+#define LibName Xext
+#define SoRev SOXEXTREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXextReqs
+REQUIREDLIBS = SharedXextReqs
+#endif
+
+#if HasShm
+ SHMSRCS = XShm.c
+ SHMOBJS = XShm.o
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = Malloc0ReturnsNullDefines
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ INCLUDES = -I$(XLIBSRC)
+ SRCS = globals.c extutil.c XMultibuf.c XShape.c $(SHMSRCS) \
+ MITMisc.c XTestExt1.c XSync.c Xdbe.c XLbx.c \
+ XSecurity.c XAppgroup.c Xcup.c DPMS.c XEVI.c
+ OBJS = globals.o extutil.o XMultibuf.o XShape.o $(SHMOBJS) \
+ MITMisc.o XTestExt1.o XSync.o Xdbe.o XLbx.o \
+ XSecurity.o XAppgroup.o Xcup.o DPMS.o XEVI.o
+ LINTLIBS = $(LINTXLIB)
+
+#include <Library.tmpl>
+
+LinkFile(ImUtil.h,$(XLIBSRC)/ImUtil.h)
+
+DependTarget()
diff --git a/nx-X11/lib/Xext/MITMisc.c b/nx-X11/lib/Xext/MITMisc.c
new file mode 100644
index 000000000..c0fa87209
--- /dev/null
+++ b/nx-X11/lib/Xext/MITMisc.c
@@ -0,0 +1,133 @@
+/*
+ * $Xorg: MITMisc.c,v 1.4 2001/02/09 02:03:49 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.
+ *
+ */
+/* $XFree86: xc/lib/Xext/MITMisc.c,v 1.3 2002/10/16 00:37:27 dawes Exp $ */
+
+/* RANDOM CRUFT! THIS HAS NO OFFICIAL X CONSORTIUM BLESSING */
+
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/extensions/MITMisc.h>
+#include <X11/extensions/mitmiscstr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+static XExtensionInfo _mit_info_data;
+static XExtensionInfo *mit_info = &_mit_info_data;
+static /* const */ char *mit_extension_name = MITMISCNAME;
+
+#define MITCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, mit_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static /* const */ XExtensionHooks mit_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, mit_info, mit_extension_name,
+ &mit_extension_hooks, MITMiscNumberEvents,
+ NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, mit_info)
+
+
+/*****************************************************************************
+ * *
+ * public routines *
+ * *
+ *****************************************************************************/
+
+Bool XMITMiscQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+Status XMITMiscSetBugMode(Display *dpy, Bool onOff)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMITSetBugModeReq *req;
+
+ MITCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(MITSetBugMode, req);
+ req->reqType = info->codes->major_opcode;
+ req->mitReqType = X_MITSetBugMode;
+ req->onOff = onOff;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+Bool XMITMiscGetBugMode(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMITGetBugModeReq *req;
+ xMITGetBugModeReply rep;
+
+ MITCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(MITGetBugMode, req);
+ req->reqType = info->codes->major_opcode;
+ req->mitReqType = X_MITGetBugMode;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.onOff;
+}
diff --git a/nx-X11/lib/Xext/XAppgroup.c b/nx-X11/lib/Xext/XAppgroup.c
new file mode 100644
index 000000000..2ca3e4d21
--- /dev/null
+++ b/nx-X11/lib/Xext/XAppgroup.c
@@ -0,0 +1,391 @@
+/* $XFree86: xc/lib/Xext/XAppgroup.c,v 1.11 2002/10/16 02:19:22 dawes Exp $ */
+/*
+
+Copyright 1996, 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.
+
+*/
+/* $Xorg: XAppgroup.c,v 1.5 2001/02/09 02:03:49 xorgcvs Exp $ */
+
+#ifdef WIN32
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xwindows.h>
+#endif
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xagstr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+#include <stdarg.h>
+
+struct xagstuff {
+ int attrib_mask;
+ Bool app_group_leader;
+ Bool single_screen;
+ Window default_root;
+ VisualID root_visual;
+ Colormap default_colormap;
+ unsigned long black_pixel;
+ unsigned long white_pixel;
+};
+
+static XExtensionInfo _xag_info_data;
+static XExtensionInfo *xag_info = &_xag_info_data;
+static char *xag_extension_name = XAGNAME;
+
+#define XagCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xag_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static /* const */ XExtensionHooks xag_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xag_info,
+ xag_extension_name,
+ &xag_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xag_info)
+
+
+/*****************************************************************************
+ * *
+ * public Xag Extension routines *
+ * *
+ *****************************************************************************/
+
+Bool
+XagQueryVersion(
+ Display *dpy,
+ int *major_version_return,
+ int *minor_version_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagQueryVersionReply rep;
+ xXagQueryVersionReq *req;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XagQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagQueryVersion;
+ req->client_major_version = XAG_MAJOR_VERSION;
+ req->client_minor_version = XAG_MINOR_VERSION;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *major_version_return = rep.server_major_version;
+ *minor_version_return = rep.server_minor_version;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+static void
+StuffToWire (Display *dpy, struct xagstuff *stuff, xXagCreateReq *req)
+{
+ unsigned long values[8];
+ unsigned long* value = values;
+ unsigned int nvalues;
+
+ /* the order these are in is important */
+ if (stuff->attrib_mask & XagSingleScreenMask)
+ *value++ = stuff->single_screen;
+
+ if (stuff->attrib_mask & XagDefaultRootMask)
+ *value++ = stuff->default_root;
+
+ if (stuff->attrib_mask & XagRootVisualMask)
+ *value++ = stuff->root_visual;
+
+ if (stuff->attrib_mask & XagDefaultColormapMask)
+ *value++ = stuff->default_colormap;
+
+ if (stuff->attrib_mask & XagBlackPixelMask)
+ *value++ = stuff->black_pixel;
+
+ if (stuff->attrib_mask & XagWhitePixelMask)
+ *value++ = stuff->white_pixel;
+
+ if (stuff->attrib_mask & XagAppGroupLeaderMask)
+ *value++ = stuff->app_group_leader;
+
+ req->length += (nvalues = value - values);
+
+ nvalues <<= 2;
+ Data32 (dpy, (long*) values, (long) nvalues);
+}
+
+Bool
+XagCreateEmbeddedApplicationGroup(
+ Display* dpy,
+ VisualID root_visual,
+ Colormap default_colormap,
+ unsigned long black_pixel,
+ unsigned long white_pixel,
+ XAppGroup* app_group_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagCreateReq *req;
+ struct xagstuff stuff;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ stuff.app_group_leader = True;
+ stuff.single_screen = True;
+ stuff.default_root = RootWindow (dpy, DefaultScreen(dpy));
+ stuff.root_visual = root_visual;
+ stuff.default_colormap = default_colormap;
+ stuff.attrib_mask =
+ XagAppGroupLeaderMask | XagSingleScreenMask | XagDefaultRootMask |
+ XagRootVisualMask | XagDefaultColormapMask;
+ if (default_colormap != None) {
+ stuff.black_pixel = black_pixel;
+ stuff.white_pixel = white_pixel;
+ stuff.attrib_mask |= XagBlackPixelMask | XagWhitePixelMask;
+ }
+ /* might do some validation here */
+ GetReq(XagCreate, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagCreate;
+ *app_group_return = req->app_group = XAllocID(dpy);
+ req->attrib_mask = stuff.attrib_mask;
+ StuffToWire (dpy, &stuff, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XagCreateNonembeddedApplicationGroup(
+ Display* dpy,
+ XAppGroup* app_group_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagCreateReq *req;
+ struct xagstuff stuff;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ stuff.app_group_leader = False;
+ stuff.single_screen = False;
+ stuff.attrib_mask = XagAppGroupLeaderMask | XagSingleScreenMask;
+ /* might do some validation here */
+ GetReq(XagCreate, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagCreate;
+ *app_group_return = req->app_group = XAllocID(dpy);
+ req->attrib_mask = stuff.attrib_mask;
+ StuffToWire (dpy, &stuff, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XagDestroyApplicationGroup(Display* dpy, XAppGroup app_group)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagDestroyReq *req;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XagDestroy, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagDestroy;
+ req->app_group = app_group;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XagGetApplicationGroupAttributes(Display* dpy, XAppGroup app_group, ...)
+{
+ va_list var;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagGetAttrReq *req;
+ xXagGetAttrReply rep;
+ int attr;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XagGetAttr, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagGetAttr;
+ req->app_group = app_group;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ va_start (var, app_group);
+ for (attr = va_arg(var, int); attr != 0; attr = va_arg(var, int)) {
+ void* ptr;
+
+ switch (attr) {
+ case XagNappGroupLeader:
+ ptr = va_arg(var, void*);
+ *(Bool*)ptr = rep.app_group_leader;
+ break;
+ case XagNsingleScreen:
+ ptr = va_arg(var, void*);
+ *(Bool*)ptr = rep.single_screen;
+ break;
+ case XagNdefaultRoot:
+ ptr = va_arg(var, void*);
+ *(Window*)ptr = rep.default_root;
+ break;
+ case XagNrootVisual:
+ ptr = va_arg(var, void*);
+ *(VisualID*)ptr = rep.root_visual;
+ break;
+ case XagNdefaultColormap:
+ ptr = va_arg(var, void*);
+ *(Colormap*)ptr = rep.default_colormap;
+ break;
+ case XagNblackPixel:
+ ptr = va_arg(var, void*);
+ *(unsigned long*)ptr = rep.black_pixel;
+ break;
+ case XagNwhitePixel:
+ ptr = va_arg(var, void*);
+ *(unsigned long*)ptr = rep.white_pixel;
+ break;
+ }
+ }
+ va_end (var);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XagQueryApplicationGroup(
+ Display* dpy,
+ XID resource,
+ XAppGroup* app_group_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagQueryReq *req;
+ xXagQueryReply rep;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XagQuery, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagQuery;
+ req->resource = resource;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *app_group_return = rep.app_group;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+
+}
+
+Bool
+XagCreateAssociation(Display* dpy, Window* window_return, void* system_window)
+{
+#ifdef WIN32
+ long tmp = *(HWND*) system_window;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagCreateAssocReq *req;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XagCreateAssoc, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagCreateAssoc;
+ *window_return = req->window = XAllocID(dpy);
+ req->window_type = XagWindowTypeWin32;
+ req->system_window_len = sizeof(HWND);
+ Data32 (dpy, (long*) tmp, 1L);
+ req->length++;
+ UnlockDisplay(dpy);
+ SyncHandle();
+#else
+ /* other platforms go here */
+
+ /* this whole thing could be arranged better, but since X need
+ * only short-circuit the protocol and WIN32 is the only other
+ * platform the XC supports, it will suffice for now.
+ */
+ *window_return = *(Window*)system_window;
+#endif
+ return True;
+}
+
+Bool
+XagDestroyAssociation(Display* dpy, Window window)
+{
+#ifdef WIN32
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagDestroyAssocReq *req;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XagDestroyAssoc, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagDestroyAssoc;
+ req->window = window;
+ UnlockDisplay(dpy);
+ SyncHandle();
+#endif
+ return True;
+}
+
diff --git a/nx-X11/lib/Xext/XEVI.c b/nx-X11/lib/Xext/XEVI.c
new file mode 100644
index 000000000..a64b9c1ba
--- /dev/null
+++ b/nx-X11/lib/Xext/XEVI.c
@@ -0,0 +1,213 @@
+/* $Xorg: XEVI.c,v 1.3 2000/08/17 19:45:51 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1997 by Silicon Graphics Computer Systems, Inc.
+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 Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS 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.
+********************************************************/
+/* $XFree86$ */
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/extensions/XEVI.h>
+#include <X11/extensions/XEVIstr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/Xutil.h>
+static XExtensionInfo *xevi_info;/* needs to move to globals.c */
+static /* const */ char *xevi_extension_name = EVINAME;
+#define XeviCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xevi_extension_name, val)
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+static /* const */ XExtensionHooks xevi_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ NULL, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xevi_info,
+ xevi_extension_name,
+ &xevi_extension_hooks, 0, NULL)
+Bool XeviQueryExtension (Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ if (XextHasExtension(info)) {
+ return True;
+ } else {
+ return False;
+ }
+}
+Bool XeviQueryVersion(Display *dpy, int *majorVersion, int *minorVersion)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xEVIQueryVersionReply rep;
+ register xEVIQueryVersionReq *req;
+ XeviCheckExtension (dpy, info, False);
+ LockDisplay(dpy);
+ GetReq(EVIQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xeviReqType = X_EVIQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+static Bool notInList(VisualID32 *visual, int sz_visual, VisualID newVisualid)
+{
+ while (sz_visual-- > 0) {
+ if (*visual == newVisualid)
+ return False;
+ visual++;
+ }
+ return True;
+}
+Status XeviGetVisualInfo(
+ register Display *dpy,
+ VisualID *visual,
+ int n_visual,
+ ExtendedVisualInfo **evi_return,
+ int *n_info_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xEVIGetVisualInfoReq *req;
+ xEVIGetVisualInfoReply rep;
+ int sz_info, sz_xInfo, sz_conflict, sz_xConflict;
+ VisualID32 *temp_conflict, *temp_visual, *xConflictPtr;
+ VisualID *conflict;
+ xExtendedVisualInfo *temp_xInfo;
+ XVisualInfo *vinfo;
+ register ExtendedVisualInfo *infoPtr;
+ register xExtendedVisualInfo *xInfoPtr;
+ register int n_data, visualIndex, vinfoIndex;
+ Bool isValid;
+ XeviCheckExtension (dpy, info, 0);
+ *n_info_return = 0;
+ *evi_return = NULL;
+ vinfo = XGetVisualInfo(dpy, 0, NULL, &sz_info);
+ if (!vinfo) {
+ return BadValue;
+ }
+ if (!n_visual || !visual) { /* copy the all visual */
+ temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * sz_info);
+ n_visual = 0;
+ for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++)
+ if (notInList(temp_visual, n_visual, vinfo[vinfoIndex].visualid))
+ temp_visual[n_visual++] = vinfo[vinfoIndex].visualid;
+ }
+ else { /* check if the visual is valid */
+ for (visualIndex = 0; visualIndex < n_visual; visualIndex++) {
+ isValid = False;
+ for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++) {
+ if (visual[visualIndex] == vinfo[vinfoIndex].visualid) {
+ isValid = True;
+ break;
+ }
+ }
+ if (!isValid) {
+ XFree(vinfo);
+ return BadValue;
+ }
+ }
+ temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * n_visual);
+ for (visualIndex = 0; visualIndex < n_visual; visualIndex++)
+ temp_visual[visualIndex] = visual[visualIndex];
+ }
+ XFree(vinfo);
+ LockDisplay(dpy);
+ GetReq(EVIGetVisualInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->xeviReqType = X_EVIGetVisualInfo;
+ req->n_visual = n_visual;
+ SetReqLen(req, n_visual, 1);
+ Data(dpy, (char *)temp_visual, n_visual * sz_VisualID32);
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ Xfree(temp_visual);
+ return BadAccess;
+ }
+ Xfree(temp_visual);
+ sz_info = rep.n_info * sizeof(ExtendedVisualInfo);
+ sz_xInfo = rep.n_info * sz_xExtendedVisualInfo;
+ sz_conflict = rep.n_conflicts * sizeof(VisualID);
+ sz_xConflict = rep.n_conflicts * sz_VisualID32;
+ infoPtr = *evi_return = (ExtendedVisualInfo *)Xmalloc(sz_info + sz_conflict);
+ xInfoPtr = temp_xInfo = (xExtendedVisualInfo *)Xmalloc(sz_xInfo);
+ xConflictPtr = temp_conflict = (VisualID32 *)Xmalloc(sz_xConflict);
+ if (!*evi_return || !temp_xInfo || !temp_conflict) {
+ _XEatData(dpy, (sz_xInfo + sz_xConflict + 3) & ~3);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (evi_return)
+ Xfree(evi_return);
+ if (temp_xInfo)
+ Xfree(temp_xInfo);
+ if (temp_conflict)
+ Xfree(temp_conflict);
+ return BadAlloc;
+ }
+ _XRead(dpy, (char *)temp_xInfo, sz_xInfo);
+ _XRead(dpy, (char *)temp_conflict, sz_xConflict);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ n_data = rep.n_info;
+ conflict = (VisualID *)(infoPtr + n_data);
+ while (n_data-- > 0) {
+ infoPtr->core_visual_id = xInfoPtr->core_visual_id;
+ infoPtr->screen = xInfoPtr->screen;
+ infoPtr->level = xInfoPtr->level;
+ infoPtr->transparency_type = xInfoPtr->transparency_type;
+ infoPtr->transparency_value = xInfoPtr->transparency_value;
+ infoPtr->min_hw_colormaps = xInfoPtr->min_hw_colormaps;
+ infoPtr->max_hw_colormaps = xInfoPtr->max_hw_colormaps;
+ infoPtr->num_colormap_conflicts = xInfoPtr->num_colormap_conflicts;
+ infoPtr->colormap_conflicts = conflict;
+ conflict += infoPtr->num_colormap_conflicts;
+ infoPtr++;
+ xInfoPtr++;
+ }
+ n_data = rep.n_conflicts;
+ conflict = (VisualID *)(infoPtr);
+ while (n_data-- > 0)
+ *conflict++ = *xConflictPtr++;
+ Xfree(temp_xInfo);
+ Xfree(temp_conflict);
+ *n_info_return = rep.n_info;
+ return Success;
+}
diff --git a/nx-X11/lib/Xext/XLbx.c b/nx-X11/lib/Xext/XLbx.c
new file mode 100644
index 000000000..8c0cfad0b
--- /dev/null
+++ b/nx-X11/lib/Xext/XLbx.c
@@ -0,0 +1,129 @@
+/*
+ * $Xorg: XLbx.c,v 1.3 2000/08/17 19:45:51 cpqbld Exp $
+ *
+ * Copyright 1992 Network Computing Devices
+ *
+ * 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 of NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * 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.
+ *
+ * Author: Keith Packard, Network Computing Devices
+ */
+/* $XFree86: xc/lib/Xext/XLbx.c,v 1.4 2002/10/16 00:37:27 dawes Exp $ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XLbx.h>
+#include <X11/extensions/lbxstr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+static XExtensionInfo _lbx_info_data;
+static XExtensionInfo *lbx_info = &_lbx_info_data;
+static /* const */ char *lbx_extension_name = LBXNAME;
+
+#define LbxCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, lbx_extension_name, val)
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static char *error_string(Display *dpy, int code, XExtCodes *codes,
+ char *buf, int n);
+static /* const */ XExtensionHooks lbx_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ error_string, /* error_string */
+};
+
+static /* const */ char *lbx_error_list[] = {
+ "BadLbxClient", /* BadLbxClient */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, lbx_info, lbx_extension_name,
+ &lbx_extension_hooks, LbxNumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, lbx_info)
+
+static XEXT_GENERATE_ERROR_STRING (error_string, lbx_extension_name,
+ LbxNumberErrors, lbx_error_list)
+
+
+Bool XLbxQueryExtension (
+ Display *dpy,
+ int *requestp, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *requestp = info->codes->major_opcode;
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+int XLbxGetEventBase(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ return info->codes->first_event;
+ } else {
+ return -1;
+ }
+}
+
+
+Bool XLbxQueryVersion(Display *dpy, int *majorVersion, int *minorVersion)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xLbxQueryVersionReply rep;
+ register xLbxQueryVersionReq *req;
+
+ LbxCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(LbxQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->lbxReqType = X_LbxQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/* all other requests will run after Xlib has lost the wire ... */
diff --git a/nx-X11/lib/Xext/XMultibuf.c b/nx-X11/lib/Xext/XMultibuf.c
new file mode 100644
index 000000000..3e0049e92
--- /dev/null
+++ b/nx-X11/lib/Xext/XMultibuf.c
@@ -0,0 +1,714 @@
+/*
+ * $Xorg: XMultibuf.c,v 1.6 2001/02/09 02:03:49 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.
+ *
+ * Authors: Jim Fulton, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xext/XMultibuf.c,v 1.5 2001/12/14 19:55:00 dawes Exp $ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <stdio.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/multibufst.h>
+
+static XExtensionInfo _multibuf_info_data;
+static XExtensionInfo *multibuf_info = &_multibuf_info_data;
+static /* const */ char *multibuf_extension_name = MULTIBUFFER_PROTOCOL_NAME;
+
+#define MbufCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, multibuf_extension_name, val)
+#define MbufSimpleCheckExtension(dpy,i) \
+ XextSimpleCheckExtension (dpy, i, multibuf_extension_name)
+
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+/*
+ * find_display - locate the display info block
+ */
+static int close_display(Display *dpy, XExtCodes *codes);
+static char *error_string(Display *dpy, int code, XExtCodes *codes, char *buf, int n);
+static Bool wire_to_event(Display *dpy, XEvent *libevent, xEvent *netevent);
+static Status event_to_wire(Display *dpy, XEvent *libevent, xEvent *netevent);
+static /* const */ XExtensionHooks multibuf_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ error_string, /* error_string */
+};
+
+static /* const */ char *multibuf_error_list[] = {
+ "BadBuffer", /* MultibufferBadBuffer */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, multibuf_info,
+ multibuf_extension_name,
+ &multibuf_extension_hooks,
+ MultibufferNumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, multibuf_info)
+
+static XEXT_GENERATE_ERROR_STRING (error_string, multibuf_extension_name,
+ MultibufferNumberErrors,
+ multibuf_error_list)
+
+/*
+ * wire_to_event - convert a wire event in network format to a C
+ * event structure
+ */
+static Bool wire_to_event (Display *dpy, XEvent *libevent, xEvent *netevent)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ MbufCheckExtension (dpy, info, False);
+
+ switch ((netevent->u.u.type & 0x7f) - info->codes->first_event) {
+ case MultibufferClobberNotify:
+ {
+ XmbufClobberNotifyEvent *ev;
+ xMbufClobberNotifyEvent *event;
+
+ ev = (XmbufClobberNotifyEvent *) libevent;
+ event = (xMbufClobberNotifyEvent *) netevent;
+ ev->type = event->type & 0x7f;
+ ev->serial = _XSetLastRequestRead(dpy,(xGenericReply *) netevent);
+ ev->send_event = ((event->type & 0x80) != 0);
+ ev->display = dpy;
+ ev->buffer = event->buffer;
+ ev->state = event->state;
+ return True;
+ }
+ case MultibufferUpdateNotify:
+ {
+ XmbufUpdateNotifyEvent *ev;
+ xMbufUpdateNotifyEvent *event;
+
+ ev = (XmbufUpdateNotifyEvent *) libevent;
+ event = (xMbufUpdateNotifyEvent *) netevent;
+ ev->type = event->type & 0x7f;
+ ev->serial = _XSetLastRequestRead(dpy,(xGenericReply *) netevent);
+ ev->send_event = ((event->type & 0x80) != 0);
+ ev->display = dpy;
+ ev->buffer = event->buffer;
+ return True;
+ }
+ }
+ return False;
+}
+
+
+/*
+ * event_to_wire - convert a C event structure to a wire event in
+ * network format
+ */
+static Status event_to_wire (Display *dpy, XEvent *libevent, xEvent *netevent)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ MbufCheckExtension (dpy, info, 0);
+
+ switch ((libevent->type & 0x7f) - info->codes->first_event) {
+ case MultibufferClobberNotify:
+ {
+ XmbufClobberNotifyEvent *ev;
+ xMbufClobberNotifyEvent *event;
+
+ ev = (XmbufClobberNotifyEvent *) libevent;
+ event = (xMbufClobberNotifyEvent *) netevent;
+ event->type = ev->type;
+ event->sequenceNumber = (ev->serial & 0xffff);
+ event->buffer = ev->buffer;
+ event->state = ev->state;
+ return 1;
+ }
+ case MultibufferUpdateNotify:
+ {
+ XmbufUpdateNotifyEvent *ev;
+ xMbufUpdateNotifyEvent *event;
+
+ ev = (XmbufUpdateNotifyEvent *) libevent;
+ event = (xMbufUpdateNotifyEvent *) netevent;
+ event->type = ev->type;
+ event->sequenceNumber = (ev->serial & 0xffff);
+ event->buffer = ev->buffer;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+/*
+ * read_buffer_info - read Buffer Info descriptors from the net; if unable
+ * to allocate memory, read junk to make sure that stream is clear.
+ */
+#define TALLOC(type,count) ((type *) Xmalloc ((unsigned) count * sizeof(type)))
+
+static XmbufBufferInfo *read_buffer_info (Display *dpy, int nbufs)
+{
+ xMbufBufferInfo *netbuf = TALLOC (xMbufBufferInfo, nbufs);
+ XmbufBufferInfo *bufinfo = NULL;
+ long netbytes = nbufs * SIZEOF(xMbufBufferInfo);
+
+ if (netbuf) {
+ _XRead (dpy, (char *) netbuf, netbytes);
+
+ bufinfo = TALLOC (XmbufBufferInfo, nbufs);
+ if (bufinfo) {
+ register XmbufBufferInfo *c;
+ register xMbufBufferInfo *net;
+ register int i;
+
+ for (i = 0, c = bufinfo, net = netbuf; i < nbufs;
+ i++, c++, net++) {
+ c->visualid = net->visualID;
+ c->max_buffers = net->maxBuffers;
+ c->depth = net->depth;
+ }
+ }
+ Xfree ((char *) netbuf);
+ } else { /* eat the data */
+ while (netbytes > 0) {
+ char dummy[256]; /* stack size vs loops tradeoff */
+ long nbytes = sizeof dummy;
+
+ if (nbytes > netbytes) nbytes = netbytes;
+ _XRead (dpy, dummy, nbytes);
+ netbytes -= nbytes;
+ }
+ }
+
+ return bufinfo;
+}
+
+#undef TALLOC
+
+
+/*****************************************************************************
+ * *
+ * Multibuffering/stereo public interfaces *
+ * *
+ *****************************************************************************/
+
+
+/*
+ * XmbufQueryExtension -
+ * Returns True if the multibuffering/stereo extension is available
+ * on the given display. If the extension exists, the value of the
+ * first event code (which should be added to the event type constants
+ * MultibufferClobberNotify and MultibufferUpdateNotify to get the
+ * actual values) is stored into event_base and the value of the first
+ * error code (which should be added to the error type constant
+ * MultibufferBadBuffer to get the actual value) is stored into
+ * error_base.
+ */
+Bool XmbufQueryExtension (
+ Display *dpy,
+ int *event_base_return, int *error_base_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension (info)) {
+ *event_base_return = info->codes->first_event;
+ *error_base_return = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+/*
+ * XmbufGetVersion -
+ * Gets the major and minor version numbers of the extension. The return
+ * value is zero if an error occurs or non-zero if no error happens.
+ */
+Status XmbufGetVersion (
+ Display *dpy,
+ int *major_version_return, int *minor_version_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xMbufGetBufferVersionReply rep;
+ register xMbufGetBufferVersionReq *req;
+
+ MbufCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufGetBufferVersion, req, info);
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ *major_version_return = rep.majorVersion;
+ *minor_version_return = rep.minorVersion;
+ UnlockDisplay (dpy);
+
+ SyncHandle ();
+ return 1;
+}
+
+
+/*
+ * XmbufCreateBuffers -
+ * Requests that "count" buffers be created with the given update_action
+ * and update_hint and be associated with the indicated window. The
+ * number of buffers created is returned (zero if an error occurred)
+ * and buffers_return is filled in with that many Multibuffer identifiers.
+ */
+int XmbufCreateBuffers (
+ Display *dpy,
+ Window w,
+ int count,
+ int update_action, int update_hint,
+ Multibuffer *buffers)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xMbufCreateImageBuffersReply rep;
+ register xMbufCreateImageBuffersReq *req;
+ int result;
+
+ MbufCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+
+ XAllocIDs(dpy, buffers, count);
+ MbufGetReq (MbufCreateImageBuffers, req, info);
+ req->window = w;
+ req->updateAction = update_action;
+ req->updateHint = update_hint;
+ req->length += count;
+ count <<= 2;
+ PackData32 (dpy, buffers, count);
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ result = rep.numberBuffer;
+ UnlockDisplay (dpy);
+
+ SyncHandle ();
+ return result;
+}
+
+
+/*
+ * XmbufDestroyBuffers -
+ * Destroys the buffers associated with the given window.
+ */
+void XmbufDestroyBuffers (Display *dpy, Window window)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufDestroyImageBuffersReq *req;
+
+ MbufSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufDestroyImageBuffers, req, info);
+ req->window = window;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+
+/*
+ * XmbufDisplayBuffers -
+ * Displays the indicated buffers their appropriate windows within
+ * max_delay milliseconds after min_delay milliseconds have passed.
+ * No two buffers may be associated with the same window or else a Matc
+ * error is generated.
+ */
+void XmbufDisplayBuffers (
+ Display *dpy,
+ int count,
+ Multibuffer *buffers,
+ int min_delay, int max_delay)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufDisplayImageBuffersReq *req;
+
+ MbufSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufDisplayImageBuffers, req, info);
+ req->minDelay = min_delay;
+ req->maxDelay = max_delay;
+ req->length += count;
+ count <<= 2;
+ PackData32 (dpy, buffers, count);
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+
+/*
+ * XmbufGetWindowAttributes -
+ * Gets the multibuffering attributes that apply to all buffers associated
+ * with the given window. Returns non-zero on success and zero if an
+ * error occurs.
+ */
+Status XmbufGetWindowAttributes (
+ Display *dpy,
+ Window w,
+ XmbufWindowAttributes *attr)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufGetMBufferAttributesReq *req;
+ xMbufGetMBufferAttributesReply rep;
+
+ MbufCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufGetMBufferAttributes, req, info);
+ req->window = w;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ attr->buffers = (Multibuffer *) NULL;
+ if ((attr->nbuffers = rep.length)) {
+ int nbytes = rep.length * sizeof(Multibuffer);
+ attr->buffers = (Multibuffer *) Xmalloc((unsigned) nbytes);
+ nbytes = rep.length << 2;
+ if (! attr->buffers) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+ _XRead32 (dpy, (long *) attr->buffers, nbytes);
+ }
+ attr->displayed_index = rep.displayedBuffer;
+ attr->update_action = rep.updateAction;
+ attr->update_hint = rep.updateHint;
+ attr->window_mode = rep.windowMode;
+
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+/*
+ * XmbufChangeWindowAttributes -
+ * Sets the multibuffering attributes that apply to all buffers associated
+ * with the given window. This is currently limited to the update_hint.
+ */
+void XmbufChangeWindowAttributes (
+ Display *dpy,
+ Window w,
+ unsigned long valuemask,
+ XmbufSetWindowAttributes *attr)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufSetMBufferAttributesReq *req;
+
+ MbufSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufSetMBufferAttributes, req, info);
+ req->window = w;
+ if ((req->valueMask = valuemask)) { /* stolen from lib/X/XWindow.c */
+ unsigned long values[1]; /* one per element in if stmts below */
+ unsigned long *v = values;
+ unsigned int nvalues;
+
+ if (valuemask & MultibufferWindowUpdateHint)
+ *v++ = attr->update_hint;
+ req->length += (nvalues = v - values);
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, (long)nvalues);
+ }
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+
+/*
+ * XmbufGetBufferAttributes -
+ * Gets the attributes for the indicated buffer. Returns non-zero on
+ * success and zero if an error occurs.
+ */
+Status XmbufGetBufferAttributes (
+ Display *dpy,
+ Multibuffer b,
+ XmbufBufferAttributes *attr)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufGetBufferAttributesReq *req;
+ xMbufGetBufferAttributesReply rep;
+
+ MbufCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufGetBufferAttributes, req, info);
+ req->buffer = b;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ attr->window = rep.window;
+ attr->event_mask = rep.eventMask;
+ attr->buffer_index = rep.bufferIndex;
+ attr->side = rep.side;
+
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+/*
+ * XmbufChangeBufferAttributes -
+ * Sets the attributes for the indicated buffer. This is currently
+ * limited to the event_mask.
+ */
+void XmbufChangeBufferAttributes (
+ Display *dpy,
+ Multibuffer b,
+ unsigned long valuemask,
+ XmbufSetBufferAttributes *attr)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufSetBufferAttributesReq *req;
+
+ MbufSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufSetBufferAttributes, req, info);
+ req->buffer = b;
+ if ((req->valueMask = valuemask)) { /* stolen from lib/X/XWindow.c */
+ unsigned long values[1]; /* one per element in if stmts below */
+ unsigned long *v = values;
+ unsigned int nvalues;
+
+ if (valuemask & MultibufferBufferEventMask)
+ *v++ = attr->event_mask;
+ req->length += (nvalues = v - values);
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, (long)nvalues);
+ }
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+
+
+/*
+ * XmbufGetScreenInfo -
+ * Gets the parameters controlling how mono and stereo windows may be
+ * created on the indicated screen. The numbers of sets of visual and
+ * depths are returned in nmono_return and nstereo_return. If
+ * nmono_return is greater than zero, then mono_info_return is set to
+ * the address of an array of XmbufBufferInfo structures describing the
+ * various visuals and depths that may be used. Otherwise,
+ * mono_info_return is set to NULL. Similarly, stereo_info_return is
+ * set according to nstereo_return. The storage returned in
+ * mono_info_return and stereo_info_return may be released by XFree.
+ * If no errors are encounted, non-zero will be returned.
+ */
+Status XmbufGetScreenInfo (
+ Display *dpy,
+ Drawable d,
+ int *nmono_return,
+ XmbufBufferInfo **mono_info_return,
+ int *nstereo_return,
+ XmbufBufferInfo **stereo_info_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufGetBufferInfoReq *req;
+ xMbufGetBufferInfoReply rep;
+ int nmono, nstereo;
+ XmbufBufferInfo *minfo, *sinfo;
+
+ MbufCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufGetBufferInfo, req, info);
+ req->drawable = d;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ nmono = rep.normalInfo;
+ nstereo = rep.stereoInfo;
+ minfo = ((nmono > 0) ? read_buffer_info (dpy, nmono) : NULL);
+ sinfo = ((nstereo > 0) ? read_buffer_info (dpy, nstereo) : NULL);
+
+ /* check for bad reads indicating we need to return an error */
+ if ((nmono > 0 && !minfo) || (nstereo > 0 && !sinfo)) {
+ if (minfo) Xfree ((char *) minfo);
+ if (sinfo) Xfree ((char *) sinfo);
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return 0;
+ }
+
+ *nmono_return = nmono;
+ *mono_info_return = minfo;
+ *nstereo_return = nstereo;
+ *stereo_info_return = sinfo;
+
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+/*
+ * XmbufCreateStereoWindow -
+ * Creates a stereo window in the same way that XCreateWindow creates
+ * a mono window (in fact, use the same code, except for the request)
+ * and returns the left and right buffers that may be
+ */
+Window XmbufCreateStereoWindow (
+ Display *dpy,
+ Window parent,
+ int x, int y,
+ unsigned int width, unsigned int height, unsigned int border_width,
+ int depth,
+ unsigned int class,
+ Visual *visual,
+ unsigned long valuemask,
+ XSetWindowAttributes *attr,
+ Multibuffer *leftp, Multibuffer *rightp)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ Window wid;
+ register xMbufCreateStereoWindowReq *req;
+
+ MbufCheckExtension (dpy, info, None);
+
+ LockDisplay(dpy);
+ MbufGetReq(MbufCreateStereoWindow, req, info);
+ wid = req->wid = XAllocID(dpy);
+ req->parent = parent;
+ req->left = *leftp = XAllocID (dpy);
+ req->right = *rightp = XAllocID (dpy);
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->borderWidth = border_width;
+ req->depth = depth;
+ req->class = class;
+ if (visual == CopyFromParent)
+ req->visual = CopyFromParent;
+ else
+ req->visual = visual->visualid;
+ valuemask &= (CWBackPixmap|CWBackPixel|CWBorderPixmap|
+ CWBorderPixel|CWBitGravity|CWWinGravity|
+ CWBackingStore|CWBackingPlanes|CWBackingPixel|
+ CWOverrideRedirect|CWSaveUnder|CWEventMask|
+ CWDontPropagate|CWColormap|CWCursor);
+ if ((req->mask = valuemask)) {
+ unsigned long values[32];
+ register unsigned long *value = values;
+ unsigned int nvalues;
+
+ if (valuemask & CWBackPixmap)
+ *value++ = attr->background_pixmap;
+ if (valuemask & CWBackPixel)
+ *value++ = attr->background_pixel;
+ if (valuemask & CWBorderPixmap)
+ *value++ = attr->border_pixmap;
+ if (valuemask & CWBorderPixel)
+ *value++ = attr->border_pixel;
+ if (valuemask & CWBitGravity)
+ *value++ = attr->bit_gravity;
+ if (valuemask & CWWinGravity)
+ *value++ = attr->win_gravity;
+ if (valuemask & CWBackingStore)
+ *value++ = attr->backing_store;
+ if (valuemask & CWBackingPlanes)
+ *value++ = attr->backing_planes;
+ if (valuemask & CWBackingPixel)
+ *value++ = attr->backing_pixel;
+ if (valuemask & CWOverrideRedirect)
+ *value++ = attr->override_redirect;
+ if (valuemask & CWSaveUnder)
+ *value++ = attr->save_under;
+ if (valuemask & CWEventMask)
+ *value++ = attr->event_mask;
+ if (valuemask & CWDontPropagate)
+ *value++ = attr->do_not_propagate_mask;
+ if (valuemask & CWColormap)
+ *value++ = attr->colormap;
+ if (valuemask & CWCursor)
+ *value++ = attr->cursor;
+ req->length += (nvalues = value - values);
+
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, (long)nvalues);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return wid;
+}
+
+void XmbufClearBufferArea (
+ Display *dpy,
+ Multibuffer buffer,
+ int x, int y,
+ unsigned int width, unsigned int height,
+ Bool exposures)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufClearImageBufferAreaReq *req;
+
+ MbufSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufClearImageBufferArea, req, info);
+ req->buffer = buffer;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->exposures = exposures;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
diff --git a/nx-X11/lib/Xext/XSecurity.c b/nx-X11/lib/Xext/XSecurity.c
new file mode 100644
index 000000000..161ade3b7
--- /dev/null
+++ b/nx-X11/lib/Xext/XSecurity.c
@@ -0,0 +1,310 @@
+/* $Xorg: XSecurity.c,v 1.6 2001/02/09 02:03:49 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xext/XSecurity.c,v 1.5 2002/10/16 00:37:27 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <stdio.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/securstr.h>
+
+static XExtensionInfo _Security_info_data;
+static XExtensionInfo *Security_info = &_Security_info_data;
+static char *Security_extension_name = SECURITY_EXTENSION_NAME;
+
+#define SecurityCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, Security_extension_name, val)
+#define SecuritySimpleCheckExtension(dpy,i) \
+ XextSimpleCheckExtension (dpy, i, Security_extension_name)
+
+#define SecurityGetReq(name,req,info) GetReq (name, req); \
+ req->reqType = info->codes->major_opcode; \
+ req->securityReqType = X_##name;
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+/*
+ * find_display - locate the display info block
+ */
+static int close_display(Display *dpy, XExtCodes *codes);
+static Bool wire_to_event(Display *dpy, XEvent *event, xEvent *wire);
+static Status event_to_wire(Display *dpy, XEvent *event, xEvent *wire);
+static char *error_string(Display *dpy, int code, XExtCodes *codes,
+ char *buf, int n);
+
+static XExtensionHooks Security_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ error_string /* error_string */
+};
+
+static char *security_error_list[] = {
+ "BadAuthorization"
+ "BadAuthorizationProtocol"
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, Security_info,
+ Security_extension_name,
+ &Security_extension_hooks,
+ XSecurityNumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, Security_info)
+
+static
+XEXT_GENERATE_ERROR_STRING(error_string, Security_extension_name,
+ XSecurityNumberErrors, security_error_list)
+
+static Bool
+wire_to_event(Display *dpy, XEvent *event, xEvent *wire)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+
+ SecurityCheckExtension (dpy, info, False);
+
+ switch ((wire->u.u.type & 0x7F) - info->codes->first_event)
+ {
+ case XSecurityAuthorizationRevoked:
+ {
+ xSecurityAuthorizationRevokedEvent *rwire =
+ (xSecurityAuthorizationRevokedEvent *)wire;
+ XSecurityAuthorizationRevokedEvent *revent =
+ (XSecurityAuthorizationRevokedEvent *)event;
+
+ revent->type = rwire->type & 0x7F;
+ revent->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *) wire);
+ revent->send_event = (rwire->type & 0x80) != 0;
+ revent->display = dpy;
+ revent->auth_id = rwire->authId;
+ return True;
+ }
+ }
+ return False;
+}
+
+static Status
+event_to_wire(Display *dpy, XEvent *event, xEvent *wire)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+
+ SecurityCheckExtension(dpy, info, False);
+
+ switch ((event->type & 0x7F) - info->codes->first_event)
+ {
+ case XSecurityAuthorizationRevoked:
+ {
+ xSecurityAuthorizationRevokedEvent *rwire =
+ (xSecurityAuthorizationRevokedEvent *)wire;
+ XSecurityAuthorizationRevokedEvent *revent =
+ (XSecurityAuthorizationRevokedEvent *)event;
+ rwire->type = revent->type | (revent->send_event ? 0x80 : 0);
+ rwire->sequenceNumber = revent->serial & 0xFFFF;
+ return True;
+ }
+ }
+ return False;
+}
+
+/*****************************************************************************
+ * *
+ * Security public interfaces *
+ * *
+ *****************************************************************************/
+
+Status XSecurityQueryExtension (
+ Display *dpy,
+ int *major_version_return,
+ int *minor_version_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xSecurityQueryVersionReply rep;
+ register xSecurityQueryVersionReq *req;
+
+ if (!XextHasExtension (info))
+ return (Status)0; /* failure */
+
+ LockDisplay (dpy);
+ SecurityGetReq (SecurityQueryVersion, req, info);
+ req->majorVersion = SECURITY_MAJOR_VERSION;
+ req->minorVersion = SECURITY_MINOR_VERSION;
+
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return (Status)0; /* failure */
+ }
+ *major_version_return = rep.majorVersion;
+ *minor_version_return = rep.minorVersion;
+ UnlockDisplay (dpy);
+
+ SyncHandle ();
+
+ if (*major_version_return != SECURITY_MAJOR_VERSION)
+ return (Status)0; /* failure */
+ else
+ return (Status)1; /* success */
+}
+
+Xauth *
+XSecurityAllocXauth(void)
+{
+ return Xcalloc(1, sizeof(Xauth));
+}
+
+void
+XSecurityFreeXauth(Xauth *auth)
+{
+ XFree(auth);
+}
+
+static int
+Ones(Mask mask)
+{
+ register Mask y;
+
+ y = (mask >> 1) &033333333333;
+ y = mask - y - ((y >>1) & 033333333333);
+ return (((y + (y >> 3)) & 030707070707) % 077);
+}
+
+Xauth *
+XSecurityGenerateAuthorization(
+ Display *dpy,
+ Xauth *auth_in,
+ unsigned long valuemask,
+ XSecurityAuthorizationAttributes *attributes,
+ XSecurityAuthorization *auth_id_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xSecurityGenerateAuthorizationReq *req;
+ xSecurityGenerateAuthorizationReply rep;
+ Xauth *auth_return;
+ unsigned long values[3];
+ unsigned long *value = values;
+ unsigned int nvalues;
+
+ *auth_id_return = 0; /* in case we fail */
+
+ /* make sure extension is available */
+
+ SecurityCheckExtension (dpy, info, (Xauth *)NULL);
+
+ LockDisplay(dpy);
+ SecurityGetReq(SecurityGenerateAuthorization, req, info);
+
+ req->nbytesAuthProto = auth_in->name_length;
+ req->nbytesAuthData = auth_in->data_length;
+
+ /* adjust length to account for auth name and data */
+ req->length += (auth_in->name_length + (unsigned)3) >> 2;
+ req->length += (auth_in->data_length + (unsigned)3) >> 2;
+
+ /* adjust length to account for list of values */
+ req->valueMask = valuemask & XSecurityAllAuthorizationAttributes;
+ nvalues = Ones(req->valueMask);
+ req->length += nvalues;
+
+ /* send auth name and data */
+ Data(dpy, auth_in->name, auth_in->name_length);
+ Data(dpy, auth_in->data, auth_in->data_length);
+
+ /* send values */
+ if (valuemask & XSecurityTimeout) *value++ = attributes->timeout;
+ if (valuemask & XSecurityTrustLevel) *value++ = attributes->trust_level;
+ if (valuemask & XSecurityGroup) *value++ = attributes->group;
+ if (valuemask & XSecurityEventMask) *value++ = attributes->event_mask;
+
+ nvalues <<= 2;
+ Data32(dpy, (long *)values, (long)nvalues);
+
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return (Xauth *)NULL;
+ }
+
+ *auth_id_return = rep.authId;
+
+ /* Allocate space for the Xauth struct and the auth name and data all
+ * in one hunk. This lets XSecurityFreeXauth not have to care
+ * about whether the auth was allocated here or in
+ * XSecurityAllocXauth; in both cases, you just free one pointer.
+ */
+
+ if ((auth_return = (Xauth *)Xcalloc(1,
+ (sizeof(Xauth) + auth_in->name_length + rep.dataLength))))
+ {
+ auth_return->data_length = rep.dataLength;
+ auth_return->data = (char *)&auth_return[1];
+ _XReadPad(dpy, auth_return->data, (long)rep.dataLength);
+
+ auth_return->name_length = auth_in->name_length;
+ auth_return->name = auth_return->data + auth_return->data_length;
+ memcpy(auth_return->name, auth_in->name, auth_return->name_length);
+ }
+ else
+ {
+ _XEatData(dpy, (unsigned long) (rep.dataLength + 3) & ~3);
+ }
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return auth_return;
+
+} /* XSecurityGenerateAuthorization */
+
+Status
+XSecurityRevokeAuthorization(
+ Display *dpy,
+ XSecurityAuthorization auth_id)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xSecurityRevokeAuthorizationReq *req;
+
+ SecurityCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ SecurityGetReq(SecurityRevokeAuthorization, req, info);
+ req->authId = auth_id;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+} /* XSecurityRevokeAuthorization */
diff --git a/nx-X11/lib/Xext/XShape.c b/nx-X11/lib/Xext/XShape.c
new file mode 100644
index 000000000..29a7f83f9
--- /dev/null
+++ b/nx-X11/lib/Xext/XShape.c
@@ -0,0 +1,490 @@
+/*
+ * $Xorg: XShape.c,v 1.4 2001/02/09 02:03:49 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.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xext/XShape.c,v 1.3 2002/10/16 00:37:27 dawes Exp $ */
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/Xregion.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/shapestr.h>
+
+static XExtensionInfo _shape_info_data;
+static XExtensionInfo *shape_info = &_shape_info_data;
+static /* const */ char *shape_extension_name = SHAPENAME;
+
+#define ShapeCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, shape_extension_name, val)
+#define ShapeSimpleCheckExtension(dpy,i) \
+ XextSimpleCheckExtension (dpy, i, shape_extension_name)
+
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static Bool wire_to_event (Display *dpy, XEvent *re, xEvent *event);
+static Status event_to_wire (Display *dpy, XEvent *re, xEvent *event);
+static /* const */ XExtensionHooks shape_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, shape_info,
+ shape_extension_name,
+ &shape_extension_hooks,
+ ShapeNumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, shape_info)
+
+
+static Bool
+wire_to_event (Display *dpy, XEvent *re, xEvent *event)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XShapeEvent *se;
+ xShapeNotifyEvent *sevent;
+
+ ShapeCheckExtension (dpy, info, False);
+
+ switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
+ case ShapeNotify:
+ se = (XShapeEvent *) re;
+ sevent = (xShapeNotifyEvent *) event;
+ se->type = sevent->type & 0x7f;
+ se->serial = _XSetLastRequestRead(dpy,(xGenericReply *) event);
+ se->send_event = (sevent->type & 0x80) != 0;
+ se->display = dpy;
+ se->window = sevent->window;
+ se->kind = sevent->kind;
+ se->x = cvtINT16toInt (sevent->x);
+ se->y = cvtINT16toInt (sevent->y);
+ se->width = sevent->width;
+ se->height = sevent->height;
+ se->time = sevent->time;
+ se->shaped = True;
+ if (sevent->shaped == xFalse)
+ se->shaped = False;
+ return True;
+ }
+ return False;
+}
+
+static Status
+event_to_wire (Display *dpy, XEvent *re, xEvent *event)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XShapeEvent *se;
+ xShapeNotifyEvent *sevent;
+
+ ShapeCheckExtension (dpy, info, 0);
+
+ switch ((re->type & 0x7f) - info->codes->first_event) {
+ case ShapeNotify:
+ se = (XShapeEvent *) re;
+ sevent = (xShapeNotifyEvent *) event;
+ sevent->type = se->type | (se->send_event ? 0x80 : 0);
+ sevent->sequenceNumber = se->serial & 0xffff;
+ sevent->window = se->window;
+ sevent->kind = se->kind;
+ sevent->x = se->x;
+ sevent->y = se->y;
+ sevent->width = se->width;
+ sevent->height = se->height;
+ sevent->time = se->time;
+ return 1;
+ }
+ return 0;
+}
+
+
+/****************************************************************************
+ * *
+ * Shape public interfaces *
+ * *
+ ****************************************************************************/
+
+Bool XShapeQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+Status XShapeQueryVersion(
+ Display *dpy,
+ int *major_versionp,
+ int *minor_versionp)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xShapeQueryVersionReply rep;
+ register xShapeQueryVersionReq *req;
+
+ ShapeCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (ShapeQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeQueryVersion;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ *major_versionp = rep.majorVersion;
+ *minor_versionp = rep.minorVersion;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
+void XShapeCombineRegion(
+ register Display *dpy,
+ Window dest,
+ int destKind, int xOff, int yOff,
+ register REGION *r,
+ int op)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeRectanglesReq *req;
+ register long nbytes;
+ register int i;
+ register XRectangle *xr, *pr;
+ register BOX *pb;
+
+ ShapeSimpleCheckExtension (dpy, info);
+
+ LockDisplay(dpy);
+ GetReq(ShapeRectangles, req);
+ xr = (XRectangle *)
+ _XAllocScratch(dpy, (unsigned long)(r->numRects * sizeof (XRectangle)));
+ for (pr = xr, pb = r->rects, i = r->numRects; --i >= 0; pr++, pb++) {
+ pr->x = pb->x1;
+ pr->y = pb->y1;
+ pr->width = pb->x2 - pb->x1;
+ pr->height = pb->y2 - pb->y1;
+ }
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeRectangles;
+ req->op = op;
+ req->ordering = YXBanded;
+ req->destKind = destKind;
+ req->dest = dest;
+ req->xOff = xOff;
+ req->yOff = yOff;
+
+ /* SIZEOF(xRectangle) will be a multiple of 4 */
+ req->length += r->numRects * (SIZEOF(xRectangle) / 4);
+
+ nbytes = r->numRects * sizeof(xRectangle);
+
+ Data16 (dpy, (short *) xr, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+
+void XShapeCombineRectangles (
+ register Display *dpy,
+ XID dest,
+ int destKind, int xOff, int yOff,
+ XRectangle *rects,
+ int n_rects,
+ int op, int ordering)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeRectanglesReq *req;
+ register long nbytes;
+
+ ShapeSimpleCheckExtension (dpy, info);
+
+ LockDisplay(dpy);
+ GetReq(ShapeRectangles, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeRectangles;
+ req->op = op;
+ req->ordering = ordering;
+ req->destKind = destKind;
+ req->dest = dest;
+ req->xOff = xOff;
+ req->yOff = yOff;
+
+ /* SIZEOF(xRectangle) will be a multiple of 4 */
+ req->length += n_rects * (SIZEOF(xRectangle) / 4);
+
+ nbytes = n_rects * sizeof(xRectangle);
+
+ Data16 (dpy, (short *) rects, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+
+void XShapeCombineMask (
+ register Display *dpy,
+ XID dest,
+ int destKind,
+ int xOff, int yOff,
+ Pixmap src,
+ int op)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeMaskReq *req;
+
+ ShapeSimpleCheckExtension (dpy, info);
+
+ LockDisplay(dpy);
+ GetReq(ShapeMask, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeMask;
+ req->op = op;
+ req->destKind = destKind;
+ req->dest = dest;
+ req->xOff = xOff;
+ req->yOff = yOff;
+ req->src = src;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void XShapeCombineShape (
+ register Display *dpy,
+ XID dest,
+ int destKind,
+ int xOff, int yOff,
+ XID src,
+ int srcKind,
+ int op)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeCombineReq *req;
+
+ ShapeSimpleCheckExtension (dpy, info);
+
+ LockDisplay(dpy);
+ GetReq(ShapeCombine, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeCombine;
+ req->op = op;
+ req->destKind = destKind;
+ req->srcKind = srcKind;
+ req->dest = dest;
+ req->xOff = xOff;
+ req->yOff = yOff;
+ req->src = src;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void XShapeOffsetShape (
+ register Display *dpy,
+ XID dest,
+ int destKind,
+ int xOff, int yOff)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeOffsetReq *req;
+
+ ShapeSimpleCheckExtension (dpy, info);
+
+ LockDisplay(dpy);
+ GetReq(ShapeOffset, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeOffset;
+ req->destKind = destKind;
+ req->dest = dest;
+ req->xOff = xOff;
+ req->yOff = yOff;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+Status XShapeQueryExtents (
+ register Display *dpy,
+ Window window,
+ int *bShaped, int *xbs, int *ybs, unsigned int *wbs, unsigned int *hbs, /* RETURN */
+ int *cShaped, int *xcs, int *ycs, unsigned int *wcs, unsigned int *hcs /* RETURN */)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xShapeQueryExtentsReply rep;
+ register xShapeQueryExtentsReq *req;
+
+ ShapeCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (ShapeQueryExtents, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeQueryExtents;
+ req->window = window;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ *bShaped = rep.boundingShaped;
+ *cShaped = rep.clipShaped;
+ *xbs = cvtINT16toInt (rep.xBoundingShape);
+ *ybs = cvtINT16toInt (rep.yBoundingShape);
+ *wbs = rep.widthBoundingShape;
+ *hbs = rep.heightBoundingShape;
+ *xcs = cvtINT16toInt (rep.xClipShape);
+ *ycs = cvtINT16toInt (rep.yClipShape);
+ *wcs = rep.widthClipShape;
+ *hcs = rep.heightClipShape;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
+
+void XShapeSelectInput (
+ register Display *dpy,
+ Window window,
+ unsigned long mask)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeSelectInputReq *req;
+
+ ShapeSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ GetReq (ShapeSelectInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeSelectInput;
+ req->window = window;
+ if (mask & ShapeNotifyMask)
+ req->enable = xTrue;
+ else
+ req->enable = xFalse;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+unsigned long XShapeInputSelected (register Display *dpy, Window window)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeInputSelectedReq *req;
+ xShapeInputSelectedReply rep;
+
+ ShapeCheckExtension (dpy, info, False);
+
+ LockDisplay (dpy);
+ GetReq (ShapeInputSelected, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeInputSelected;
+ req->window = window;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return False;
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return rep.enabled ? ShapeNotifyMask : 0L;
+}
+
+
+XRectangle *XShapeGetRectangles (
+ register Display *dpy,
+ Window window,
+ int kind,
+ int *count, /* RETURN */
+ int *ordering /* RETURN */)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeGetRectanglesReq *req;
+ xShapeGetRectanglesReply rep;
+ XRectangle *rects;
+ xRectangle *xrects;
+ int i;
+
+ ShapeCheckExtension (dpy, info, (XRectangle *)NULL);
+
+ LockDisplay (dpy);
+ GetReq (ShapeGetRectangles, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeGetRectangles;
+ req->window = window;
+ req->kind = kind;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return (XRectangle *)NULL;
+ }
+ *count = rep.nrects;
+ *ordering = rep.ordering;
+ rects = 0;
+ if (*count) {
+ xrects = (xRectangle *) Xmalloc (*count * sizeof (xRectangle));
+ rects = (XRectangle *) Xmalloc (*count * sizeof (XRectangle));
+ if (!xrects || !rects) {
+ if (xrects)
+ Xfree (xrects);
+ if (rects)
+ Xfree (rects);
+ _XEatData (dpy, *count * sizeof (xRectangle));
+ rects = 0;
+ *count = 0;
+ } else {
+ _XRead (dpy, (char *) xrects, *count * sizeof (xRectangle));
+ for (i = 0; i < *count; i++) {
+ rects[i].x = (short) cvtINT16toInt (xrects[i].x);
+ rects[i].y = (short) cvtINT16toInt (xrects[i].y);
+ rects[i].width = xrects[i].width;
+ rects[i].height = xrects[i].height;
+ }
+ Xfree (xrects);
+ }
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return rects;
+}
diff --git a/nx-X11/lib/Xext/XShm.c b/nx-X11/lib/Xext/XShm.c
new file mode 100644
index 000000000..f4e29a42b
--- /dev/null
+++ b/nx-X11/lib/Xext/XShm.c
@@ -0,0 +1,437 @@
+/* $XdotOrg: xc/lib/Xext/XShm.c,v 1.5 2005/07/30 21:07:25 alanc Exp $ */
+/*
+ * $Xorg: XShm.c,v 1.4 2001/02/09 02:03:49 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.
+ *
+ * Author: Bob Scheifler and Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xext/XShm.c,v 1.6 2002/10/16 02:19:22 dawes Exp $ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlibint.h>
+#include <X11/ImUtil.h>
+#include <X11/extensions/XShm.h>
+#include <X11/extensions/shmstr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+static XExtensionInfo _shm_info_data;
+static XExtensionInfo *shm_info = &_shm_info_data;
+static /* const */ char *shm_extension_name = SHMNAME;
+
+#define ShmCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, shm_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static char *error_string(Display *dpy, int code, XExtCodes *codes,
+ char *buf, int n);
+static Bool wire_to_event (Display *dpy, XEvent *re, xEvent *event);
+static Status event_to_wire (Display *dpy, XEvent *re, xEvent *event);
+static /* const */ XExtensionHooks shm_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ error_string, /* error_string */
+};
+
+static /* const */ char *shm_error_list[] = {
+ "BadShmSeg", /* BadShmSeg */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, shm_info, shm_extension_name,
+ &shm_extension_hooks, ShmNumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, shm_info)
+
+static XEXT_GENERATE_ERROR_STRING (error_string, shm_extension_name,
+ ShmNumberErrors, shm_error_list)
+
+
+static Bool
+wire_to_event (Display *dpy, XEvent *re, xEvent *event)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XShmCompletionEvent *se;
+ xShmCompletionEvent *sevent;
+
+ ShmCheckExtension (dpy, info, False);
+
+ switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
+ case ShmCompletion:
+ se = (XShmCompletionEvent *) re;
+ sevent = (xShmCompletionEvent *) event;
+ se->type = sevent->type & 0x7f;
+ se->serial = _XSetLastRequestRead(dpy,(xGenericReply *) event);
+ se->send_event = (sevent->type & 0x80) != 0;
+ se->display = dpy;
+ se->drawable = sevent->drawable;
+ se->major_code = sevent->majorEvent;
+ se->minor_code = sevent->minorEvent;
+ se->shmseg = sevent->shmseg;
+ se->offset = sevent->offset;
+ return True;
+ }
+ return False;
+}
+
+static Status
+event_to_wire (Display *dpy, XEvent *re, xEvent *event)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XShmCompletionEvent *se;
+ xShmCompletionEvent *sevent;
+
+ ShmCheckExtension (dpy, info, 0);
+
+ switch ((re->type & 0x7f) - info->codes->first_event) {
+ case ShmCompletion:
+ se = (XShmCompletionEvent *) re;
+ sevent = (xShmCompletionEvent *) event;
+ sevent->type = se->type | (se->send_event ? 0x80 : 0);
+ sevent->sequenceNumber = se->serial & 0xffff;
+ sevent->drawable = se->drawable;
+ sevent->majorEvent = se->major_code;
+ sevent->minorEvent = se->minor_code;
+ sevent->shmseg = se->shmseg;
+ sevent->offset = se->offset;
+ return True;
+ }
+ return False;
+}
+
+/*****************************************************************************
+ * *
+ * public Shared Memory Extension routines *
+ * *
+ *****************************************************************************/
+
+Bool XShmQueryExtension (Display *dpy /* int *event_basep, *error_basep */)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+/* *event_basep = info->codes->first_event;
+ *error_basep = info->codes->error_event; */
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+int XShmGetEventBase(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ return info->codes->first_event;
+ } else {
+ return -1;
+ }
+}
+
+
+Bool XShmQueryVersion(
+ Display *dpy,
+ int *majorVersion,
+ int *minorVersion,
+ Bool *sharedPixmaps)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xShmQueryVersionReply rep;
+ register xShmQueryVersionReq *req;
+
+ ShmCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(ShmQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ *sharedPixmaps = rep.sharedPixmaps ? True : False;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+
+int XShmPixmapFormat(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xShmQueryVersionReply rep;
+ register xShmQueryVersionReq *req;
+
+ ShmCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(ShmQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (rep.sharedPixmaps &&
+ (rep.majorVersion > 1 || rep.minorVersion > 0))
+ return rep.pixmapFormat;
+ return 0;
+}
+
+
+Status XShmAttach(Display *dpy, XShmSegmentInfo *shminfo)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShmAttachReq *req;
+
+ ShmCheckExtension (dpy, info, 0);
+
+ shminfo->shmseg = XAllocID(dpy);
+ LockDisplay(dpy);
+ GetReq(ShmAttach, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmAttach;
+ req->shmseg = shminfo->shmseg;
+ req->shmid = shminfo->shmid;
+ req->readOnly = shminfo->readOnly ? xTrue : xFalse;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+Status XShmDetach(Display *dpy, XShmSegmentInfo *shminfo)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShmDetachReq *req;
+
+ ShmCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(ShmDetach, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmDetach;
+ req->shmseg = shminfo->shmseg;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+static int _XShmDestroyImage (XImage *ximage)
+{
+ Xfree((char *)ximage);
+ return 1;
+}
+
+#define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad) - 1)) / (pad)) * (pad))
+
+XImage *XShmCreateImage (
+ register Display *dpy,
+ register Visual *visual,
+ unsigned int depth,
+ int format,
+ char *data,
+ XShmSegmentInfo *shminfo,
+ unsigned int width,
+ unsigned int height)
+{
+ register XImage *image;
+
+ image = (XImage *)Xcalloc(1, (unsigned)sizeof(XImage));
+ if (!image)
+ return image;
+ image->data = data;
+ image->obdata = (char *)shminfo;
+ image->width = width;
+ image->height = height;
+ image->depth = depth;
+ image->format = format;
+ image->byte_order = dpy->byte_order;
+ image->bitmap_unit = dpy->bitmap_unit;
+ image->bitmap_bit_order = dpy->bitmap_bit_order;
+ image->bitmap_pad = _XGetScanlinePad(dpy, depth);
+ image->xoffset = 0;
+ if (visual) {
+ 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)
+ image->bits_per_pixel = _XGetBitsPerPixel(dpy, (int)depth);
+ else
+ image->bits_per_pixel = 1;
+ image->bytes_per_line = ROUNDUP((image->bits_per_pixel * width),
+ image->bitmap_pad) >> 3;
+ _XInitImageFuncPtrs(image);
+ image->f.destroy_image = _XShmDestroyImage;
+ return image;
+}
+
+Status XShmPutImage (
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ register XImage *image,
+ int src_x, int src_y, int dst_x, int dst_y,
+ unsigned int src_width, unsigned int src_height,
+ Bool send_event)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XShmSegmentInfo *shminfo = (XShmSegmentInfo *)image->obdata;
+ register xShmPutImageReq *req;
+
+ ShmCheckExtension (dpy, info, 0);
+ if (!shminfo) return 0;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq(ShmPutImage, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmPutImage;
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->srcX = src_x;
+ req->srcY = src_y;
+ req->srcWidth = src_width;
+ req->srcHeight = src_height;
+ req->dstX = dst_x;
+ req->dstY = dst_y;
+ req->totalWidth = image->width;
+ req->totalHeight = image->height;
+ req->depth = image->depth;
+ req->format = image->format;
+ req->sendEvent = send_event;
+ req->shmseg = shminfo->shmseg;
+ req->offset = image->data - shminfo->shmaddr;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+Status XShmGetImage(
+ register Display *dpy,
+ Drawable d,
+ XImage *image,
+ int x, int y,
+ unsigned long plane_mask)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XShmSegmentInfo *shminfo = (XShmSegmentInfo *)image->obdata;
+ register xShmGetImageReq *req;
+ xShmGetImageReply rep;
+ register Visual *visual;
+
+ ShmCheckExtension (dpy, info, 0);
+ if (!shminfo) return 0;
+
+ LockDisplay(dpy);
+ GetReq(ShmGetImage, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmGetImage;
+ req->drawable = d;
+ req->x = x;
+ req->y = y;
+ req->width = image->width;
+ req->height = image->height;
+ req->planeMask = plane_mask;
+ req->format = image->format;
+ req->shmseg = shminfo->shmseg;
+ req->offset = image->data - shminfo->shmaddr;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ visual = _XVIDtoVisual(dpy, rep.visual);
+ if (visual) {
+ 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;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+Pixmap XShmCreatePixmap (
+ register Display *dpy,
+ Drawable d,
+ char *data,
+ XShmSegmentInfo *shminfo,
+ unsigned int width, unsigned int height, unsigned int depth)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ Pixmap pid;
+ register xShmCreatePixmapReq *req;
+
+ ShmCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(ShmCreatePixmap, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmCreatePixmap;
+ req->drawable = d;
+ req->width = width;
+ req->height = height;
+ req->depth = depth;
+ req->shmseg = shminfo->shmseg;
+ req->offset = data - shminfo->shmaddr;
+ pid = req->pid = XAllocID(dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return pid;
+}
diff --git a/nx-X11/lib/Xext/XSync.c b/nx-X11/lib/Xext/XSync.c
new file mode 100644
index 000000000..61f8600ce
--- /dev/null
+++ b/nx-X11/lib/Xext/XSync.c
@@ -0,0 +1,817 @@
+/* $Xorg: XSync.c,v 1.5 2001/02/09 02:03:49 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 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.
+
+*/
+
+/***********************************************************
+Copyright 1991,1993 by Digital Equipment Corporation, Maynard, Massachusetts,
+and Olivetti Research Limited, Cambridge, England.
+
+ 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 names of Digital or Olivetti
+not be used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL THEY 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xext/XSync.c,v 1.7tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/syncstr.h>
+
+static XExtensionInfo _sync_info_data;
+static XExtensionInfo *sync_info = &_sync_info_data;
+static char *sync_extension_name = SYNC_NAME;
+
+#define SyncCheckExtension(dpy,i,val) \
+ XextCheckExtension(dpy, i, sync_extension_name, val)
+#define SyncSimpleCheckExtension(dpy,i) \
+ XextSimpleCheckExtension(dpy, i, sync_extension_name)
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static Bool wire_to_event(Display *dpy, XEvent *event, xEvent *wire);
+static Status event_to_wire(Display *dpy, XEvent *event, xEvent *wire);
+static char *error_string(Display *dpy, int code, XExtCodes *codes,
+ char *buf, int n);
+
+static XExtensionHooks sync_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ error_string, /* error_string */
+};
+
+static char *sync_error_list[] = {
+ "BadCounter",
+ "BadAlarm",
+};
+
+static
+XEXT_GENERATE_FIND_DISPLAY(find_display, sync_info,
+ sync_extension_name,
+ &sync_extension_hooks,
+ XSyncNumberEvents, (XPointer) NULL)
+
+static
+XEXT_GENERATE_CLOSE_DISPLAY(close_display, sync_info)
+
+static
+XEXT_GENERATE_ERROR_STRING(error_string, sync_extension_name,
+ XSyncNumberErrors, sync_error_list)
+
+
+static Bool
+wire_to_event(Display *dpy, XEvent *event, xEvent *wire)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ XSyncCounterNotifyEvent *aevent;
+ xSyncCounterNotifyEvent *awire;
+ XSyncAlarmNotifyEvent *anl;
+ xSyncAlarmNotifyEvent *ane;
+
+ SyncCheckExtension(dpy, info, False);
+
+ switch ((wire->u.u.type & 0x7F) - info->codes->first_event)
+ {
+ case XSyncCounterNotify:
+ awire = (xSyncCounterNotifyEvent *) wire;
+ aevent = (XSyncCounterNotifyEvent *) event;
+ aevent->type = awire->type & 0x7F;
+ aevent->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *) wire);
+ aevent->send_event = (awire->type & 0x80) != 0;
+ aevent->display = dpy;
+ aevent->counter = awire->counter;
+ XSyncIntsToValue(&aevent->wait_value, awire->wait_value_lo,
+ awire->wait_value_hi);
+ XSyncIntsToValue(&aevent->counter_value,
+ awire->counter_value_lo,
+ awire->counter_value_hi);
+ aevent->time = awire->time;
+ aevent->count = awire->count;
+ aevent->destroyed = awire->destroyed;
+ return True;
+
+ case XSyncAlarmNotify:
+ ane = (xSyncAlarmNotifyEvent *) wire; /* ENCODING EVENT PTR */
+ anl = (XSyncAlarmNotifyEvent *) event; /* LIBRARY EVENT PTR */
+ anl->type = ane->type & 0x7F;
+ anl->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *) wire);
+ anl->send_event = (ane->type & 0x80) != 0;
+ anl->display = dpy;
+ anl->alarm = ane->alarm;
+ XSyncIntsToValue(&anl->counter_value,
+ ane->counter_value_lo,
+ ane->counter_value_hi);
+ XSyncIntsToValue(&anl->alarm_value,
+ ane->alarm_value_lo,
+ ane->alarm_value_hi);
+ anl->state = (XSyncAlarmState)ane->state;
+ anl->time = ane->time;
+ return True;
+ }
+
+ return False;
+}
+
+static Status
+event_to_wire(Display *dpy, XEvent *event, xEvent *wire)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ XSyncCounterNotifyEvent *aevent;
+ xSyncCounterNotifyEvent *awire;
+ XSyncAlarmNotifyEvent *anl;
+ xSyncAlarmNotifyEvent *ane;
+
+ SyncCheckExtension(dpy, info, False);
+
+ switch ((event->type & 0x7F) - info->codes->first_event)
+ {
+ case XSyncCounterNotify:
+ awire = (xSyncCounterNotifyEvent *) wire;
+ aevent = (XSyncCounterNotifyEvent *) event;
+ awire->type = aevent->type | (aevent->send_event ? 0x80 : 0);
+ awire->sequenceNumber = aevent->serial & 0xFFFF;
+ awire->counter = aevent->counter;
+ awire->wait_value_lo = XSyncValueLow32(aevent->wait_value);
+ awire->wait_value_hi = XSyncValueHigh32(aevent->wait_value);
+ awire->counter_value_lo = XSyncValueLow32(aevent->counter_value);
+ awire->counter_value_hi = XSyncValueHigh32(aevent->counter_value);
+ awire->time = aevent->time;
+ awire->count = aevent->count;
+ awire->destroyed = aevent->destroyed;
+ return True;
+
+ case XSyncAlarmNotify:
+ ane = (xSyncAlarmNotifyEvent *) wire; /* ENCODING EVENT PTR */
+ anl = (XSyncAlarmNotifyEvent *) event; /* LIBRARY EVENT PTR */
+ ane->type = anl->type | (anl->send_event ? 0x80 : 0);
+ ane->sequenceNumber = anl->serial & 0xFFFF;
+ ane->alarm = anl->alarm;
+ ane->counter_value_lo = XSyncValueLow32(anl->counter_value);
+ ane->counter_value_hi = XSyncValueHigh32(anl->counter_value);
+ ane->alarm_value_lo = XSyncValueLow32(anl->alarm_value);
+ ane->alarm_value_hi = XSyncValueHigh32(anl->alarm_value);
+ ane->state = anl->state;
+ ane->time = anl->time;
+ return True;
+ }
+ return False;
+}
+
+Status
+XSyncQueryExtension(
+ Display *dpy,
+ int *event_base_return, int *error_base_return)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+
+ if (XextHasExtension(info))
+ {
+ *event_base_return = info->codes->first_event;
+ *error_base_return = info->codes->first_error;
+ return True;
+ }
+ else
+ return False;
+}
+
+Status
+XSyncInitialize(
+ Display *dpy,
+ int *major_version_return, int *minor_version_return)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncInitializeReply rep;
+ xSyncInitializeReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncInitialize, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncInitialize;
+ req->majorVersion = SYNC_MAJOR_VERSION;
+ req->minorVersion = SYNC_MINOR_VERSION;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xTrue))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *major_version_return = rep.majorVersion;
+ *minor_version_return = rep.minorVersion;
+ return ((rep.majorVersion == SYNC_MAJOR_VERSION)
+#if SYNC_MINOR_VERSION > 0 /* avoid compiler warning */
+ && (rep.minorVersion >= SYNC_MINOR_VERSION)
+#endif
+ );
+}
+
+XSyncSystemCounter *
+XSyncListSystemCounters(Display *dpy, int *n_counters_return)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncListSystemCountersReply rep;
+ xSyncListSystemCountersReq *req;
+ XSyncSystemCounter *list = NULL;
+
+ SyncCheckExtension(dpy, info, NULL);
+
+ LockDisplay(dpy);
+ GetReq(SyncListSystemCounters, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncListSystemCounters;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
+ goto bail;
+
+ *n_counters_return = rep.nCounters;
+ if (rep.nCounters > 0)
+ {
+ xSyncSystemCounter *pWireSysCounter, *pNextWireSysCounter;
+ XSyncCounter counter;
+ int replylen;
+ int i;
+
+ list = (XSyncSystemCounter *)Xmalloc(
+ rep.nCounters * sizeof(XSyncSystemCounter));
+ replylen = rep.length << 2;
+ pWireSysCounter = (xSyncSystemCounter *) Xmalloc ((unsigned) replylen + 1);
+ /* +1 to leave room for last null-terminator */
+
+ if ((!list) || (!pWireSysCounter))
+ {
+ if (list) Xfree((char *) list);
+ if (pWireSysCounter) Xfree((char *) pWireSysCounter);
+ _XEatData(dpy, (unsigned long) replylen);
+ list = NULL;
+ goto bail;
+ }
+
+ _XReadPad(dpy, (char *)pWireSysCounter, replylen);
+
+ counter = pWireSysCounter->counter;
+ for (i = 0; i < rep.nCounters; i++)
+ {
+ list[i].counter = counter;
+ XSyncIntsToValue(&list[i].resolution,
+ pWireSysCounter->resolution_lo,
+ pWireSysCounter->resolution_hi);
+
+ /* we may be about to clobber the counter field of the
+ * next syscounter because we have to add a null terminator
+ * to the counter name string. So we save the next counter
+ * here.
+ */
+ pNextWireSysCounter = (xSyncSystemCounter *)
+ (((char *)pWireSysCounter) + ((SIZEOF(xSyncSystemCounter) +
+ pWireSysCounter->name_length + 3) & ~3));
+ counter = pNextWireSysCounter->counter;
+
+ list[i].name = ((char *)pWireSysCounter) +
+ SIZEOF(xSyncSystemCounter);
+ /* null-terminate the string */
+ *(list[i].name + pWireSysCounter->name_length) = '\0';
+ pWireSysCounter = pNextWireSysCounter;
+ }
+ }
+
+bail:
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return list;
+}
+
+void
+XSyncFreeSystemCounterList(XSyncSystemCounter *list)
+{
+ if (list)
+ {
+ Xfree( ((char *)list[0].name) - SIZEOF(xSyncSystemCounter));
+ Xfree(list);
+ }
+}
+
+
+XSyncCounter
+XSyncCreateCounter(Display *dpy, XSyncValue initial_value)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncCreateCounterReq *req;
+
+ SyncCheckExtension(dpy, info, None);
+
+ LockDisplay(dpy);
+ GetReq(SyncCreateCounter, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncCreateCounter;
+
+ req->cid = XAllocID(dpy);
+ req->initial_value_lo = XSyncValueLow32(initial_value);
+ req->initial_value_hi = XSyncValueHigh32(initial_value);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return req->cid;
+}
+
+Status
+XSyncSetCounter(Display *dpy, XSyncCounter counter, XSyncValue value)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncSetCounterReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncSetCounter, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncSetCounter;
+ req->cid = counter;
+ req->value_lo = XSyncValueLow32(value);
+ req->value_hi = XSyncValueHigh32(value);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XSyncChangeCounter(Display *dpy, XSyncCounter counter, XSyncValue value)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncChangeCounterReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncChangeCounter, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncChangeCounter;
+ req->cid = counter;
+ req->value_lo = XSyncValueLow32(value);
+ req->value_hi = XSyncValueHigh32(value);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XSyncDestroyCounter(Display *dpy, XSyncCounter counter)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncDestroyCounterReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncDestroyCounter, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncDestroyCounter;
+ req->counter = counter;
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return True;
+}
+
+Status
+XSyncQueryCounter(Display *dpy, XSyncCounter counter, XSyncValue *value_return)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncQueryCounterReply rep;
+ xSyncQueryCounterReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncQueryCounter, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncQueryCounter;
+ req->counter = counter;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xTrue))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ XSyncIntsToValue(value_return, rep.value_lo, rep.value_hi);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return True;
+}
+
+
+Status
+XSyncAwait(Display *dpy, XSyncWaitCondition *wait_list, int n_conditions)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ XSyncWaitCondition *wait_item = wait_list;
+ xSyncAwaitReq *req;
+ unsigned int len;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncAwait, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncAwait;
+ len = (n_conditions * SIZEOF(xSyncWaitCondition)) >> 2;
+ SetReqLen(req, len, len /* XXX */ );
+
+ while (n_conditions--)
+ {
+ xSyncWaitCondition wc;
+ wc.counter = wait_item->trigger.counter;
+ wc.value_type = wait_item->trigger.value_type;
+ wc.wait_value_lo = XSyncValueLow32(wait_item->trigger.wait_value);
+ wc.wait_value_hi = XSyncValueHigh32(wait_item->trigger.wait_value);
+ wc.test_type = wait_item->trigger.test_type;
+ wc.event_threshold_lo = XSyncValueLow32(wait_item->event_threshold);
+ wc.event_threshold_hi = XSyncValueHigh32(wait_item->event_threshold);
+ Data(dpy, (char *)&wc, SIZEOF(xSyncWaitCondition));
+ wait_item++; /* get next trigger */
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+static void
+_XProcessAlarmAttributes(Display *dpy, xSyncChangeAlarmReq *req,
+ unsigned long valuemask,
+ XSyncAlarmAttributes *attributes)
+{
+
+ unsigned long values[32];
+ unsigned long *value = values;
+ unsigned int nvalues;
+
+ if (valuemask & XSyncCACounter)
+ *value++ = attributes->trigger.counter;
+
+ if (valuemask & XSyncCAValueType)
+ *value++ = attributes->trigger.value_type;
+
+ if (valuemask & XSyncCAValue)
+ {
+ *value++ = XSyncValueHigh32(attributes->trigger.wait_value);
+ *value++ = XSyncValueLow32(attributes->trigger.wait_value);
+ }
+
+ if (valuemask & XSyncCATestType)
+ *value++ = attributes->trigger.test_type;
+
+ if (valuemask & XSyncCADelta)
+ {
+ *value++ = XSyncValueHigh32(attributes->delta);
+ *value++ = XSyncValueLow32(attributes->delta);
+ }
+
+ if (valuemask & XSyncCAEvents)
+ *value++ = attributes->events;
+
+ /* N.B. the 'state' field cannot be set or changed */
+ req->length += (nvalues = value - values);
+ nvalues <<= 2; /* watch out for macros... */
+
+ Data32(dpy, (long *) values, (long) nvalues);
+}
+
+XSyncAlarm
+XSyncCreateAlarm(
+ Display *dpy,
+ unsigned long values_mask,
+ XSyncAlarmAttributes *values)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncCreateAlarmReq *req;
+ XSyncAlarm aid;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncCreateAlarm, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncCreateAlarm;
+ req->id = aid = XAllocID(dpy);
+ values_mask &= XSyncCACounter | XSyncCAValueType | XSyncCAValue
+ | XSyncCATestType | XSyncCADelta | XSyncCAEvents;
+ if ((req->valueMask = values_mask))
+ _XProcessAlarmAttributes(dpy, (xSyncChangeAlarmReq *) req,
+ values_mask, values);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return aid;
+}
+
+Status
+XSyncDestroyAlarm(Display *dpy, XSyncAlarm alarm)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncDestroyAlarmReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncDestroyAlarm, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncDestroyAlarm;
+ req->alarm = alarm;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XSyncQueryAlarm(
+ Display *dpy,
+ XSyncAlarm alarm,
+ XSyncAlarmAttributes *values_return)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncQueryAlarmReq *req;
+ xSyncQueryAlarmReply rep;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncQueryAlarm, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncQueryAlarm;
+ req->alarm = alarm;
+
+ if (!(_XReply(dpy, (xReply *) & rep,
+ ((SIZEOF(xSyncQueryAlarmReply) - SIZEOF(xGenericReply)) >> 2), xFalse)))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ values_return->trigger.counter = rep.counter;
+ values_return->trigger.value_type = (XSyncValueType)rep.value_type;
+ XSyncIntsToValue(&values_return->trigger.wait_value,
+ rep.wait_value_lo, rep.wait_value_hi);
+ values_return->trigger.test_type = (XSyncTestType)rep.test_type;
+ XSyncIntsToValue(&values_return->delta, rep.delta_lo,
+ rep.delta_hi);
+ values_return->events = rep.events;
+ values_return->state = (XSyncAlarmState)rep.state;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XSyncChangeAlarm(
+ Display *dpy,
+ XSyncAlarm alarm,
+ unsigned long values_mask,
+ XSyncAlarmAttributes *values)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncChangeAlarmReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncChangeAlarm, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncChangeAlarm;
+ req->alarm = alarm;
+ values_mask &= XSyncCACounter | XSyncCAValueType | XSyncCAValue
+ | XSyncCATestType | XSyncCADelta | XSyncCAEvents;
+ if ((req->valueMask = values_mask))
+ _XProcessAlarmAttributes(dpy, req, values_mask, values);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XSyncSetPriority(
+ Display *dpy,
+ XID client_resource_id,
+ int priority)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncSetPriorityReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncSetPriority, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncSetPriority;
+ req->id = client_resource_id;
+ req->priority = priority;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XSyncGetPriority(Display *dpy, XID client_resource_id, int *return_priority)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncGetPriorityReply rep;
+ xSyncGetPriorityReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncGetPriority, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncGetPriority;
+ req->id = client_resource_id;
+
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ if (return_priority)
+ *return_priority = rep.priority;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/*
+ * Functions corresponding to the macros for manipulating 64-bit values
+ */
+
+/* get rid of macros so we can define corresponding functions */
+#undef XSyncIntToValue
+#undef XSyncIntsToValue
+#undef XSyncValueGreaterThan
+#undef XSyncValueLessThan
+#undef XSyncValueGreaterOrEqual
+#undef XSyncValueLessOrEqual
+#undef XSyncValueEqual
+#undef XSyncValueIsNegative
+#undef XSyncValueIsZero
+#undef XSyncValueIsPositive
+#undef XSyncValueLow32
+#undef XSyncValueHigh32
+#undef XSyncValueAdd
+#undef XSyncValueSubtract
+#undef XSyncMaxValue
+#undef XSyncMinValue
+
+void
+XSyncIntToValue(XSyncValue *pv, int i)
+{
+ _XSyncIntToValue(pv,i);
+}
+
+void
+XSyncIntsToValue(XSyncValue *pv, unsigned int l, int h)
+{
+ _XSyncIntsToValue(pv, l, h);
+}
+
+Bool
+XSyncValueGreaterThan(XSyncValue a, XSyncValue b)
+{
+ return _XSyncValueGreaterThan(a, b);
+}
+
+Bool
+XSyncValueLessThan(XSyncValue a, XSyncValue b)
+{
+ return _XSyncValueLessThan(a, b);
+}
+
+Bool
+XSyncValueGreaterOrEqual(XSyncValue a, XSyncValue b)
+{
+ return _XSyncValueGreaterOrEqual(a, b);
+}
+
+Bool
+XSyncValueLessOrEqual(XSyncValue a, XSyncValue b)
+{
+ return _XSyncValueLessOrEqual(a, b);
+}
+
+Bool
+XSyncValueEqual(XSyncValue a, XSyncValue b)
+{
+ return _XSyncValueEqual(a, b);
+}
+
+Bool
+XSyncValueIsNegative(XSyncValue v)
+{
+ return _XSyncValueIsNegative(v);
+}
+
+Bool
+XSyncValueIsZero(XSyncValue a)
+{
+ return _XSyncValueIsZero(a);
+}
+
+Bool
+XSyncValueIsPositive(XSyncValue v)
+{
+ return _XSyncValueIsPositive(v);
+}
+
+unsigned int
+XSyncValueLow32(XSyncValue v)
+{
+ return _XSyncValueLow32(v);
+}
+
+int
+XSyncValueHigh32(XSyncValue v)
+{
+ return _XSyncValueHigh32(v);
+}
+
+void
+XSyncValueAdd(XSyncValue *presult, XSyncValue a, XSyncValue b, Bool *poverflow)
+{
+ _XSyncValueAdd(presult, a, b, poverflow);
+}
+
+void
+XSyncValueSubtract(
+ XSyncValue *presult,
+ XSyncValue a, XSyncValue b,
+ Bool *poverflow)
+{
+ _XSyncValueSubtract(presult, a, b, poverflow);
+}
+
+void
+XSyncMaxValue(XSyncValue *pv)
+{
+ _XSyncMaxValue(pv);
+}
+
+void
+XSyncMinValue(XSyncValue *pv)
+{
+ _XSyncMinValue(pv);
+}
diff --git a/nx-X11/lib/Xext/XTestExt1.c b/nx-X11/lib/Xext/XTestExt1.c
new file mode 100644
index 000000000..ee4a0bde0
--- /dev/null
+++ b/nx-X11/lib/Xext/XTestExt1.c
@@ -0,0 +1,1321 @@
+/* $Xorg: XTestExt1.c,v 1.4 2001/02/09 02:03:49 xorgcvs Exp $ */
+/*
+ * File: xtestext1lib.c
+ *
+ * This file contains the Xlib parts of the input synthesis extension
+ */
+
+/*
+
+
+Copyright 1986, 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 1986, 1987, 1988 by Hewlett-Packard Corporation
+
+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 Hewlett-Packard not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+Hewlett-Packard makes no representations about the
+suitability of this software for any purpose. It is provided
+"as is" without express or implied warranty.
+
+This software is not subject to any license of the American
+Telephone and Telegraph Company or of the Regents of the
+University of California.
+
+*/
+/* $XFree86: xc/lib/Xext/XTestExt1.c,v 1.3 2001/01/17 19:42:46 dawes Exp $ */
+
+/******************************************************************************
+ * include files
+ *****************************************************************************/
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/xtestext1.h>
+
+/******************************************************************************
+ * variables
+ *****************************************************************************/
+
+/*
+ * Holds the request type code for this extension. The request type code
+ * for this extension may vary depending on how many extensions are installed
+ * already, so the initial value given below will be added to the base request
+ * code that is aquired when this extension is installed.
+ */
+static int XTestReqCode = 0;
+/*
+ * Holds the two event type codes for this extension. The event type codes
+ * for this extension may vary depending on how many extensions are installed
+ * already, so the initial values given below will be added to the base event
+ * code that is aquired when this extension is installed.
+ *
+ * These two variables must be available to programs that use this extension.
+ */
+int XTestInputActionType = 0;
+int XTestFakeAckType = 1;
+/*
+ * holds the current x and y coordinates for XTestMovePointer
+ */
+static int current_x = 0;
+static int current_y = 0;
+/*
+ * Holds input actions being accumulated until the input action buffer is
+ * full or until XTestFlush is called.
+ */
+static CARD8 action_buf[XTestMAX_ACTION_LIST_SIZE];
+/*
+ * the index into the input action buffer
+ */
+static int action_index = 0;
+/*
+ * the number of input actions that the server can handle at one time
+ */
+static unsigned long action_array_size = 0;
+/*
+ * the current number of input actions
+ */
+static unsigned long action_count = 0;
+
+/******************************************************************************
+ * function declarations
+ *****************************************************************************/
+
+static int XTestWireToEvent(Display *dpy, XEvent *reTemp, xEvent *eventTemp);
+static int XTestCheckExtInit(register Display *dpy);
+static Bool XTestIdentifyMyEvent(Display *display, XEvent *event_ptr, char *args);
+static int XTestInitExtension(register Display *dpy);
+static int XTestKeyOrButton(Display *display, int device_id, long unsigned int delay, unsigned int code, unsigned int action);
+static int XTestCheckDelay(Display *display, long unsigned int *delay_addr);
+static int XTestPackInputAction(Display *display, CARD8 *action_addr, int action_size);
+static int XTestWriteInputActions(Display *display, char *action_list_addr, int action_list_size, int ack_flag);
+
+/******************************************************************************
+ *
+ * XTestFakeInput
+ *
+ * Send a a request containing one or more input actions to be sent
+ * to the server by this extension.
+ */
+int
+XTestFakeInput(
+/*
+ * the connection to the X server
+ */
+register Display *dpy,
+/*
+ * the address of a list of input actions to be sent to the server
+ */
+char *action_list_addr,
+/*
+ * the size (in bytes) of the list of input actions
+ */
+int action_list_size,
+/*
+ * specifies whether the server needs to send an event to indicate that its
+ * input action buffer is empty
+ */
+int ack_flag)
+{
+ /*
+ * pointer to xTestFakeInputReq structure
+ */
+ xTestFakeInputReq *req;
+ /*
+ * loop index
+ */
+ int i;
+
+ LockDisplay(dpy);
+ if ((XTestCheckExtInit(dpy) == -1) ||
+ (action_list_size > XTestMAX_ACTION_LIST_SIZE))
+ {
+ /*
+ * if the extension is not installed in the server or the
+ * action list will not fit in the request, then unlock
+ * the display and return -1.
+ */
+ UnlockDisplay(dpy);
+ return(-1);
+ }
+ else
+ {
+ /*
+ * Get the next available X request packet in the buffer.
+ * It sets the `length' field to the size (in 32-bit words)
+ * of the request. It also sets the `reqType' field in the
+ * request to X_TestFakeInput, which is not what is needed.
+ *
+ * GetReq is a macro defined in Xlibint.h.
+ */
+ GetReq(TestFakeInput, req);
+ /*
+ * fix up the request type code to what is needed
+ */
+ req->reqType = XTestReqCode;
+ /*
+ * set the minor request type code to X_TestFakeInput
+ */
+ req->XTestReqType = X_TestFakeInput;
+ /*
+ * set the ack code
+ */
+ req->ack = ack_flag;
+ /*
+ * Set the action_list area to all 0's. An input action header
+ * value of 0 is interpreted as a flag to the input action
+ * list handling code in the server part of this extension
+ * that there are no more input actions in this request.
+ */
+ for (i = 0; i < XTestMAX_ACTION_LIST_SIZE; i++)
+ {
+ req->action_list[i] = 0;
+ }
+ /*
+ * copy the input actions into the request
+ */
+ for (i = 0; i < action_list_size; i++)
+ {
+ req->action_list[i] = *(action_list_addr++);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(0);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestGetInput
+ *
+ * Request the server to begin putting user input actions into events
+ * to be sent to the client that called this function.
+ */
+int
+XTestGetInput(
+/*
+ * the connection to the X server
+ */
+register Display *dpy,
+/*
+ * tells the server what to do with the user input actions
+ */
+int action_handling)
+{
+ /*
+ * pointer to xTestGetInputReq structure
+ */
+ xTestGetInputReq *req;
+
+ LockDisplay(dpy);
+ if (XTestCheckExtInit(dpy) == -1)
+ {
+ /*
+ * if the extension is not installed in the server
+ * then unlock the display and return -1.
+ */
+ UnlockDisplay(dpy);
+ return(-1);
+ }
+ else
+ {
+ /*
+ * Get the next available X request packet in the buffer.
+ * It sets the `length' field to the size (in 32-bit words)
+ * of the request. It also sets the `reqType' field in the
+ * request to X_TestGetInput, which is not what is needed.
+ *
+ * GetReq is a macro defined in Xlibint.h.
+ */
+ GetReq(TestGetInput, req);
+ /*
+ * fix up the request type code to what is needed
+ */
+ req->reqType = XTestReqCode;
+ /*
+ * set the minor request type code to X_TestGetInput
+ */
+ req->XTestReqType = X_TestGetInput;
+ /*
+ * set the action handling mode
+ */
+ req->mode = action_handling;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(0);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestStopInput
+ *
+ * Tell the server to stop putting information about user input actions
+ * into events.
+ */
+int
+XTestStopInput(
+/*
+ * the connection to the X server
+ */
+register Display *dpy)
+{
+ /*
+ * pointer to xTestStopInputReq structure
+ */
+ xTestStopInputReq *req;
+
+ LockDisplay(dpy);
+ if (XTestCheckExtInit(dpy) == -1)
+ {
+ /*
+ * if the extension is not installed in the server
+ * then unlock the display and return -1.
+ */
+ UnlockDisplay(dpy);
+ return(-1);
+ }
+ else
+ {
+ /*
+ * Get the next available X request packet in the buffer.
+ * It sets the `length' field to the size (in 32-bit words)
+ * of the request. It also sets the `reqType' field in the
+ * request to X_TestStopInput, which is not what is needed.
+ *
+ * GetReq is a macro defined in Xlibint.h.
+ */
+ GetReq(TestStopInput, req);
+ /*
+ * fix up the request type code to what is needed
+ */
+ req->reqType = XTestReqCode;
+ /*
+ * set the minor request type code to X_TestStopInput
+ */
+ req->XTestReqType = X_TestStopInput;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(0);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestReset
+ *
+ * Tell the server to set everything having to do with this extension
+ * back to its initial state.
+ */
+int
+XTestReset(
+/*
+ * the connection to the X server
+ */
+register Display *dpy)
+{
+ /*
+ * pointer to xTestReset structure
+ */
+ xTestResetReq *req;
+
+ LockDisplay(dpy);
+ if (XTestCheckExtInit(dpy) == -1)
+ {
+ /*
+ * if the extension is not installed in the server
+ * then unlock the display and return -1.
+ */
+ UnlockDisplay(dpy);
+ return(-1);
+ }
+ else
+ {
+ /*
+ * Get the next available X request packet in the buffer.
+ * It sets the `length' field to the size (in 32-bit words)
+ * of the request. It also sets the `reqType' field in the
+ * request to X_TestReset, which is not what is needed.
+ *
+ * GetReq is a macro defined in Xlibint.h.
+ */
+ GetReq(TestReset, req);
+ /*
+ * fix up the request type code to what is needed
+ */
+ req->reqType = XTestReqCode;
+ /*
+ * set the minor request type code to X_TestReset
+ */
+ req->XTestReqType = X_TestReset;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(0);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestQueryInputSize
+ *
+ * Returns the number of input actions in the server's input action buffer.
+ */
+int
+XTestQueryInputSize(
+/*
+ * the connection to the X server
+ */
+register Display *dpy,
+/*
+ * the address of the place to put the number of input actions in the
+ * server's input action buffer
+ */
+unsigned long *size_return)
+{
+ /*
+ * pointer to xTestQueryInputSize structure
+ */
+ xTestQueryInputSizeReq *req;
+ /*
+ * pointer to xTestQueryInputSize structure
+ */
+ xTestQueryInputSizeReply rep;
+
+ LockDisplay(dpy);
+ if (XTestCheckExtInit(dpy) == -1)
+ {
+ /*
+ * if the extension is not installed in the server
+ * then unlock the display and return -1.
+ */
+ UnlockDisplay(dpy);
+ return(-1);
+ }
+ else
+ {
+ /*
+ * Get the next available X request packet in the buffer.
+ * It sets the `length' field to the size (in 32-bit words)
+ * of the request. It also sets the `reqType' field in the
+ * request to X_TestQueryInputSize, which is not what is needed.
+ *
+ * GetReq is a macro defined in Xlibint.h.
+ */
+ GetReq(TestQueryInputSize, req);
+ /*
+ * fix up the request type code to what is needed
+ */
+ req->reqType = XTestReqCode;
+ /*
+ * set the minor request type code to X_TestQueryInputSize
+ */
+ req->XTestReqType = X_TestQueryInputSize;
+ /*
+ * get a reply from the server
+ */
+ (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
+ /*
+ * put the size in the caller's variable
+ */
+ *size_return = (unsigned long) rep.size_return;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(0);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestCheckExtInit
+ *
+ * Check to see if the XTest extension is installed in the server.
+ */
+static int
+XTestCheckExtInit(
+/*
+ * the connection to the X server
+ */
+register Display *dpy)
+{
+ /*
+ * if the extension has not been initialized, then do so
+ */
+ if (!XTestReqCode)
+ {
+ return(XTestInitExtension(dpy));
+ }
+ return(0);
+}
+
+/******************************************************************************
+ *
+ * XTestInitExtension
+ *
+ * Attempt to initialize this extension in the server. Return 0 if it
+ * succeeds, -1 if it does not succeed.
+ */
+static int
+XTestInitExtension(
+/*
+ * the connection to the X server
+ */
+register Display *dpy)
+{
+ /*
+ * loop index
+ */
+ int i;
+ /*
+ * return value from XInitExtension
+ */
+ XExtCodes *ret;
+
+ /*
+ * attempt to initialize the extension
+ */
+ ret = XInitExtension(dpy, XTestEXTENSION_NAME);
+ /*
+ * if the initialize failed, return -1
+ */
+ if (ret == NULL)
+ {
+ return (-1);
+ }
+ /*
+ * the initialize succeeded, remember the major opcode
+ * for this extension
+ */
+ XTestReqCode = ret->major_opcode;
+ /*
+ * set up the event handler for any events from
+ * this extension
+ */
+ for (i = 0; i < XTestEVENT_COUNT; i++)
+ {
+ XESetWireToEvent(dpy,
+ ret->first_event+i,
+ XTestWireToEvent);
+ }
+ /*
+ * compute the event type codes for the events
+ * in this extension
+ */
+ XTestInputActionType += ret->first_event;
+ XTestFakeAckType += ret->first_event;
+ /*
+ * everything worked ok
+ */
+ return(0);
+}
+
+/******************************************************************************
+ *
+ * XTestWireToEvent
+ *
+ * Handle XTest extension events.
+ * Reformat a wire event into an XEvent structure of the right type.
+ */
+static Bool
+XTestWireToEvent(
+/*
+ * the connection to the X server
+ */
+Display *dpy,
+/*
+ * a pointer to where a host formatted event should be stored
+ * with the information copied to it
+ */
+XEvent *reTemp,
+/*
+ * a pointer to the wire event
+ */
+xEvent *eventTemp)
+{
+ XTestInputActionEvent *re = (XTestInputActionEvent *) reTemp;
+ xTestInputActionEvent *event = (xTestInputActionEvent *) eventTemp;
+
+ /*
+ * loop index
+ */
+ int i;
+ /*
+ * pointer to where the input actions go in the host format event
+ */
+ CARD8 *to;
+ /*
+ * pointer to the input actions in the wire event
+ */
+ CARD8 *from;
+
+ /*
+ * Copy the type of the wire event to the new event.
+ * This will work for either event type because the type,
+ * display, and window fields in the events have to be the same.
+ */
+ re->type = event->type;
+ /*
+ * set the display parameter in case it is needed (by who?)
+ */
+ re->display = dpy;
+ if (re->type == XTestInputActionType)
+ {
+ /*
+ * point at the first byte of input actions in the wire event
+ */
+ from = &(event->actions[0]);
+ /*
+ * point at where the input action bytes go in the new event
+ */
+ to = &(re->actions[0]);
+ /*
+ * copy the input action bytes from the wire event to
+ * the new event
+ */
+ for (i = 0; i < XTestACTIONS_SIZE; i++)
+ {
+ *(to++) = *(from++);
+ }
+ }
+ else if (re->type == XTestFakeAckType)
+ {
+ /*
+ * nothing else needs to be done
+ */
+ }
+ else
+ {
+ printf("XTestWireToEvent: UNKNOWN WIRE EVENT! type=%d\n",
+ (int) event->type);
+ printf("%s is giving up.\n", XTestEXTENSION_NAME);
+ exit (1);
+ }
+ return 1;
+}
+
+/******************************************************************************
+ *
+ * XTestPressKey
+ *
+ * Send input actions to the server to cause the server to think
+ * that the specified key on the keyboard was moved as specified.
+ */
+int
+XTestPressKey(
+Display *display,
+int device_id,
+unsigned long delay,
+unsigned int keycode,
+unsigned int key_action)
+{
+ /*
+ * bounds check the key code
+ */
+ if (keycode < 8 || keycode > 255)
+ {
+ return(-1);
+ }
+ /*
+ * use the commmon key/button handling routine
+ */
+ return(XTestKeyOrButton(display,
+ device_id,
+ delay,
+ keycode,
+ key_action));
+}
+
+/******************************************************************************
+ *
+ * XTestPressButton
+ *
+ * Send input actions to the server to cause the server to think
+ * that the specified button on the mouse was moved as specified.
+ */
+int
+XTestPressButton(
+Display *display,
+int device_id,
+unsigned long delay,
+unsigned int button_number,
+unsigned int button_action)
+{
+ /*
+ * bounds check the button number
+ */
+ if (button_number > 7)
+ {
+ return(-1);
+ }
+ /*
+ * use the commmon key/button handling routine
+ */
+ return(XTestKeyOrButton(display,
+ device_id,
+ delay,
+ button_number,
+ button_action));
+}
+
+/******************************************************************************
+ *
+ * XTestKeyOrButton
+ *
+ * Send input actions to the server to cause the server to think
+ * that the specified key/button was moved as specified.
+ */
+static int
+XTestKeyOrButton(
+Display *display,
+int device_id,
+unsigned long delay,
+unsigned int code,
+unsigned int action)
+{
+ /*
+ * holds a key input action to be filled out and sent to the server
+ */
+ XTestKeyInfo keyinfo;
+
+ /*
+ * bounds check the device id
+ */
+ if (device_id < 0 || device_id > XTestMAX_DEVICE_ID)
+ {
+ return(-1);
+ }
+ /*
+ * fill out the key input action(s) as appropriate
+ */
+ switch(action)
+ {
+ case XTestPRESS:
+ /*
+ * Check the delay. If it is larger than will fit in the
+ * key input action, send a delay input action.
+ */
+ if(XTestCheckDelay(display, &delay) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ /*
+ * create the header
+ */
+ keyinfo.header = XTestPackDeviceID(device_id) |
+ XTestKEY_ACTION |
+ XTestKEY_DOWN;
+ /*
+ * set the key/button code
+ */
+ keyinfo.keycode = code;
+ /*
+ * set the delay time
+ */
+ keyinfo.delay_time = delay;
+ /*
+ * pack the input action into a request to be sent to the
+ * server when the request is full or XTestFlush is called
+ */
+ return(XTestPackInputAction(display,
+ (CARD8 *) &keyinfo,
+ sizeof(XTestKeyInfo)));
+ case XTestRELEASE:
+ /*
+ * Check the delay. If it is larger than will fit in the
+ * key input action, send a delay input action.
+ */
+ if(XTestCheckDelay(display, &delay) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ /*
+ * create the header
+ */
+ keyinfo.header = XTestPackDeviceID(device_id) |
+ XTestKEY_ACTION |
+ XTestKEY_UP;
+ /*
+ * set the key/button code
+ */
+ keyinfo.keycode = code;
+ /*
+ * set the delay time
+ */
+ keyinfo.delay_time = delay;
+ /*
+ * pack the input action into a request to be sent to the
+ * server when the request is full or XTestFlush is called
+ */
+ return(XTestPackInputAction(display,
+ (CARD8 *) &keyinfo,
+ sizeof(XTestKeyInfo)));
+ case XTestSTROKE:
+ /*
+ * Check the delay. If it is larger than will fit in the
+ * key input action, send a delay input action.
+ */
+ if(XTestCheckDelay(display, &delay) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ /*
+ * create a key/button-down input action header
+ */
+ keyinfo.header = XTestPackDeviceID(device_id) |
+ XTestKEY_ACTION |
+ XTestKEY_DOWN;
+ /*
+ * set the key/button code
+ */
+ keyinfo.keycode = code;
+ /*
+ * set the delay time
+ */
+ keyinfo.delay_time = delay;
+ /*
+ * pack the input action into a request to be sent to the
+ * server when the request is full or XTestFlush is called
+ */
+ if (XTestPackInputAction(display,
+ (CARD8 *) &keyinfo,
+ sizeof(XTestKeyInfo)) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ /*
+ * set the delay to XTestSTROKE_DELAY_TIME
+ */
+ delay = XTestSTROKE_DELAY_TIME;
+ /*
+ * Check the delay. If it is larger than will fit in the
+ * key input action, send a delay input action.
+ */
+ if(XTestCheckDelay(display, &delay) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ /*
+ * create a key/button-up input action header
+ */
+ keyinfo.header = XTestPackDeviceID(device_id) |
+ XTestKEY_ACTION |
+ XTestKEY_UP;
+ /*
+ * set the key/button code
+ */
+ keyinfo.keycode = code;
+ /*
+ * set the delay time
+ */
+ keyinfo.delay_time = delay;
+ /*
+ * pack the input action into a request to be sent to the
+ * server when the request is full or XTestFlush is called
+ */
+ return(XTestPackInputAction(display,
+ (CARD8 *) &keyinfo,
+ sizeof(XTestKeyInfo)));
+ default:
+ /*
+ * invalid action value, return -1
+ */
+ return(-1);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestMovePointer
+ *
+ * Send input actions to the server to cause the server to think
+ * that the mouse was moved as specified.
+ */
+int
+XTestMovePointer(
+Display *display,
+int device_id,
+unsigned long delay[],
+int x[],
+int y[],
+unsigned int count)
+{
+ /*
+ * holds a motion input action to be filled out and sent to the server
+ */
+ XTestMotionInfo motioninfo;
+ /*
+ * holds a jump input action to be filled out and sent to the server
+ */
+ XTestJumpInfo jumpinfo;
+ /*
+ * loop index
+ */
+ unsigned int i;
+ /*
+ * holds the change in x and y directions from the current x and y
+ * coordinates
+ */
+ int dx;
+ int dy;
+
+ /*
+ * bounds check the device id
+ */
+ if (device_id < 0 || device_id > XTestMAX_DEVICE_ID)
+ {
+ return(-1);
+ }
+ /*
+ * if the count is 0, there is nothing to do. return 0
+ */
+ if (count == 0)
+ {
+ return(0);
+ }
+ /*
+ * loop through the pointer motions, creating the appropriate
+ * input actions for each motion
+ */
+ for (i = 0; i < count; i++)
+ {
+ /*
+ * Check the delay. If it is larger than will fit in the
+ * input action, send a delay input action.
+ */
+ if(XTestCheckDelay(display, &(delay[i])) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ /*
+ * compute the change from the current x and y coordinates
+ * to the new x and y coordinates
+ */
+ dx = x[i] - current_x;
+ dy = y[i] - current_y;
+ /*
+ * update the current x and y coordinates
+ */
+ current_x = x[i];
+ current_y = y[i];
+ /*
+ * If the pointer motion range is too large to fit into
+ * a motion input action, then use a jump input action.
+ * Otherwise, use a motion input action.
+ */
+ if ((dx > XTestMOTION_MAX) || (dx < XTestMOTION_MIN) ||
+ (dy > XTestMOTION_MAX) || (dy < XTestMOTION_MIN))
+ {
+ /*
+ * create a jump input action header
+ */
+ jumpinfo.header = XTestPackDeviceID(device_id) |
+ XTestJUMP_ACTION;
+ /*
+ * set the x and y coordinates to jump to
+ */
+ jumpinfo.jumpx = x[i];
+ jumpinfo.jumpy = y[i];
+ /*
+ * set the delay time
+ */
+ jumpinfo.delay_time = delay[i];
+ /*
+ * pack the jump input action into a request to be
+ * sent to the server when the request is full
+ * or XTestFlush is called
+ */
+ if (XTestPackInputAction(display,
+ (CARD8 *) &jumpinfo,
+ sizeof(XTestJumpInfo)) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ }
+ else
+ {
+ /*
+ * create a motion input action header
+ */
+ motioninfo.header = XTestPackDeviceID(device_id) |
+ XTestMOTION_ACTION;
+ /*
+ * compute the motion data byte
+ */
+ if (dx < 0)
+ {
+ motioninfo.header |= XTestX_NEGATIVE;
+ dx = abs(dx);
+ }
+ if (dy < 0)
+ {
+ motioninfo.header |= XTestY_NEGATIVE;
+ dy = abs(dy);
+ }
+ motioninfo.motion_data = XTestPackXMotionValue(dx);
+ motioninfo.motion_data |= XTestPackYMotionValue(dy);
+ /*
+ * set the delay time
+ */
+ motioninfo.delay_time = delay[i];
+ /*
+ * pack the motion input action into a request to be
+ * sent to the server when the request is full
+ * or XTestFlush is called
+ */
+ if (XTestPackInputAction(display,
+ (CARD8 *) &motioninfo,
+ sizeof(XTestMotionInfo)) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ }
+ }
+ /*
+ * if you get here, everything went ok
+ */
+ return(0);
+}
+
+/******************************************************************************
+ *
+ * XTestCheckDelay
+ *
+ * Check the delay value at the passed-in address. If it is larger than
+ * will fit in a normal input action, then send a delay input action.
+ */
+static int
+XTestCheckDelay(
+Display *display,
+unsigned long *delay_addr)
+{
+ /*
+ * holds a delay input action to be filled out and sent to the server
+ */
+ XTestDelayInfo delayinfo;
+
+ /*
+ * if the delay value will fit in the input action,
+ * then there is no need for a delay input action
+ */
+ if (*delay_addr <= XTestSHORT_DELAY_TIME)
+ {
+ return(0);
+ }
+ /*
+ * fill out a delay input action
+ */
+ delayinfo.header = XTestPackDeviceID(XTestDELAY_DEVICE_ID);
+ delayinfo.delay_time = *delay_addr;
+ /*
+ * all of the delay time will be accounted for in the
+ * delay input action, so set the original delay value to 0
+ */
+ *delay_addr = 0;
+ /*
+ * pack the delay input action into a request to be sent to the
+ * server when the request is full or XTestFlush is called
+ */
+ return(XTestPackInputAction(display,
+ (CARD8 *) &delayinfo,
+ sizeof(XTestDelayInfo)));
+}
+
+/******************************************************************************
+ *
+ * XTestPackInputAction
+ *
+ * If the input action buffer is full or the number of input actions
+ * has reached the maximum that the server can handle at one time,
+ * then send the input actions to the server using XTestFakeInput.
+ */
+static int
+XTestPackInputAction(
+Display *display,
+CARD8 *action_addr,
+int action_size)
+{
+ /*
+ * loop index
+ */
+ int i;
+ /*
+ * acknowledge flag
+ */
+ int ack_flag;
+
+ /*
+ * if we don't already know it, find out how many input actions
+ * the server can handle at one time
+ */
+ if (action_array_size == 0)
+ {
+ if(XTestQueryInputSize(display, &action_array_size) == -1)
+ {
+ /*
+ * if an error, return -1
+ */
+ return(-1);
+ }
+ }
+ /*
+ * if the specified input action will fit in the the input
+ * action buffer and won't exceed the server's capacity, then
+ * put the input action into the input buffer
+ */
+ if(((action_index + action_size) <= XTestMAX_ACTION_LIST_SIZE) &&
+ ((action_count + 1) < action_array_size))
+ {
+ /*
+ * copy the input action into the buffer
+ */
+ for (i = 0; i < action_size; i++)
+ {
+ action_buf[action_index++] = *(action_addr++);
+ }
+ /*
+ * increment the action count
+ */
+ action_count++;
+ /*
+ * everything went ok, return 0
+ */
+ return(0);
+ }
+ /*
+ * We have to write input actions to the server. If the server's
+ * input action capacity will be reached, then ask for an
+ * acknowledge event when the server has processed all of the
+ * input actions. Otherwise, an acknowledge event is not needed.
+ */
+ if (action_count >= action_array_size)
+ {
+ ack_flag = XTestFAKE_ACK_REQUEST;
+ }
+ else
+ {
+ ack_flag = XTestFAKE_ACK_NOT_NEEDED;
+ }
+ /*
+ * write the input actions to the server
+ */
+ if (XTestWriteInputActions(display,
+ (char *) &(action_buf[0]),
+ action_index,
+ ack_flag) == -1)
+ {
+ /*
+ * error, return -1
+ */
+ return(-1);
+ }
+ /*
+ * copy the input action into the buffer
+ */
+ for (i = 0; i < action_size; i++)
+ {
+ action_buf[action_index++] = *(action_addr++);
+ }
+ /*
+ * increment the action count
+ */
+ action_count++;
+ return(0);
+}
+
+/******************************************************************************
+ *
+ * XTestWriteInputActions
+ *
+ * Send input actions to the server.
+ */
+static int
+XTestWriteInputActions(
+Display *display,
+char *action_list_addr,
+int action_list_size,
+int ack_flag)
+{
+ /*
+ * Holds an event. Used while waiting for an acknowledge event
+ */
+ XEvent event;
+ /*
+ * points to XTestIdentifyMyEvent
+ */
+ Bool (*func_ptr)();
+
+ /*
+ * write the input actions to the server
+ */
+ if (XTestFakeInput(display,
+ action_list_addr,
+ action_list_size,
+ ack_flag) == -1)
+ {
+ /*
+ * if an error, return -1
+ */
+ return(-1);
+ }
+ /*
+ * flush X's buffers to make sure that the server really gets
+ * the input actions
+ */
+ XFlush(display);
+ /*
+ * mark the input action buffer as empty
+ */
+ action_index = 0;
+ /*
+ * if we asked for an acknowledge event, then wait for it
+ */
+ if (ack_flag == XTestFAKE_ACK_REQUEST)
+ {
+ /*
+ * point func_ptr at XTestIdentifyMyEvent
+ */
+ func_ptr = XTestIdentifyMyEvent;
+ /*
+ * Wait until the acknowledge event comes. When the
+ * acknowledge event comes, it is removed from the event
+ * queue without disturbing any other events that might
+ * be in the queue.
+ */
+ XIfEvent(display, &event, func_ptr, NULL);
+ /*
+ * set the input action count back to 0
+ */
+ action_count = 0;
+ }
+ /*
+ * if we got here, then everything is ok, return 0
+ */
+ return(0);
+}
+
+/******************************************************************************
+ *
+ * XTestIdentifyMyEvent
+ *
+ * This function is called by XIfEvent to look at an event and see if
+ * it is of XTestFakeAckType.
+ */
+static Bool
+XTestIdentifyMyEvent(
+Display *display,
+/*
+ * Holds the event that this routiine is supposed to look at.
+ */
+XEvent *event_ptr,
+/*
+ * this points to any user-specified arguments (ignored)
+ */
+char *args)
+{
+ /*
+ * if the event if of the correct type, return the Bool True,
+ * otherwise return the Bool False.
+ */
+ if (event_ptr->type == XTestFakeAckType)
+ {
+ return(True);
+ }
+ else
+ {
+ return(False);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestFlush
+ *
+ * Send any input actions in the input action buffer to the server.
+ */
+int
+XTestFlush(Display *display)
+{
+ /*
+ * acknowledge flag
+ */
+ int ack_flag;
+
+ /*
+ * if there are no input actions in the input action buffer,
+ * then return 0
+ */
+ if (action_index == 0)
+ {
+ return(0);
+ }
+ /*
+ * We have input actions to write to the server. We will
+ * wait until the server has finished processing the input actions.
+ */
+ ack_flag = XTestFAKE_ACK_REQUEST;
+ /*
+ * write the input actions to the server
+ */
+ return(XTestWriteInputActions(display,
+ (char *) &(action_buf[0]),
+ action_index,
+ ack_flag));
+}
diff --git a/nx-X11/lib/Xext/Xcup.c b/nx-X11/lib/Xext/Xcup.c
new file mode 100644
index 000000000..6315d32a4
--- /dev/null
+++ b/nx-X11/lib/Xext/Xcup.c
@@ -0,0 +1,265 @@
+/* $XFree86: xc/lib/Xext/Xcup.c,v 1.8 2002/10/16 02:19:22 dawes 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.
+
+*/
+/* $Xorg: Xcup.c,v 1.5 2001/02/09 02:03:49 xorgcvs Exp $ */
+
+#ifdef WIN32
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xwindows.h>
+#endif
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xcupstr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+static XExtensionInfo _xcup_info_data;
+static XExtensionInfo *xcup_info = &_xcup_info_data;
+static char *xcup_extension_name = XCUPNAME;
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static /* const */ XExtensionHooks xcup_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xcup_info,
+ xcup_extension_name,
+ &xcup_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xcup_info)
+
+
+/*****************************************************************************
+ * *
+ * public Xcup Extension routines *
+ * *
+ *****************************************************************************/
+
+Status
+XcupQueryVersion(
+ Display* dpy,
+ int* major_version_return,
+ int* minor_version_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXcupQueryVersionReply rep;
+ xXcupQueryVersionReq *req;
+
+ XextCheckExtension (dpy, info, xcup_extension_name, False);
+
+ LockDisplay(dpy);
+ GetReq(XcupQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xcupReqType = X_XcupQueryVersion;
+ req->client_major_version = XCUP_MAJOR_VERSION;
+ req->client_minor_version = XCUP_MINOR_VERSION;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *major_version_return = rep.server_major_version;
+ *minor_version_return = rep.server_minor_version;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/* Win32 reserves 20 colormap entries for its desktop */
+#ifndef TYP_RESERVED_ENTRIES
+#define TYP_RESERVED_ENTRIES 20
+#endif
+
+Status
+XcupGetReservedColormapEntries(
+ Display* dpy,
+ int screen,
+ XColor** colors_out,
+ int* ncolors)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXcupGetReservedColormapEntriesReply rep;
+ xXcupGetReservedColormapEntriesReq *req;
+ xColorItem rbuf[TYP_RESERVED_ENTRIES];
+
+ *ncolors = 0;
+
+ XextCheckExtension (dpy, info, xcup_extension_name, False);
+
+ LockDisplay(dpy);
+ GetReq(XcupGetReservedColormapEntries, req);
+ req->reqType = info->codes->major_opcode;
+ req->xcupReqType = X_XcupGetReservedColormapEntries;
+ req->screen = screen;
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ long nbytes;
+ xColorItem* rbufp;
+ int nentries = rep.length / 3;
+
+ nbytes = nentries * SIZEOF (xColorItem);
+ if (nentries > TYP_RESERVED_ENTRIES)
+ rbufp = (xColorItem*) Xmalloc (nbytes);
+ else
+ rbufp = rbuf;
+
+ if (rbufp == NULL) {
+ _XEatData (dpy, (unsigned long) nbytes);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return False;
+ }
+ _XRead (dpy, (char*) rbufp, nbytes);
+
+ *colors_out = (XColor*) Xmalloc (nentries * sizeof (XColor));
+ if (*colors_out) {
+ xColorItem* cs = (xColorItem *) rbufp;
+ XColor* cd = *colors_out;
+ int i;
+
+ *ncolors = nentries;
+ for (i = 0; i < *ncolors; i++, cd++) {
+ cd->pixel = cs->pixel;
+ cd->red = cs->red;
+ cd->green = cs->green;
+ cd->blue = cs->blue;
+ cs = (xColorItem*) (((char*) cs) + SIZEOF(xColorItem));
+ }
+ if (rbufp != rbuf) XFree ((char*) rbufp);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+ }
+ if (rbufp != rbuf) XFree ((char*) rbufp);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+}
+
+Status
+XcupStoreColors(
+ Display* dpy,
+ Colormap colormap,
+ XColor* colors_in_out,
+ int ncolors)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXcupStoreColorsReply rep;
+ xXcupStoreColorsReq *req;
+ xColorItem rbuf[256];
+ xColorItem citem;
+ int i;
+ XColor* xcp;
+
+ XextCheckExtension (dpy, info, xcup_extension_name, False);
+
+ LockDisplay(dpy);
+ GetReq(XcupStoreColors, req);
+ req->reqType = info->codes->major_opcode;
+ req->xcupReqType = X_XcupStoreColors;
+ req->cmap = colormap;
+ req->length += (ncolors * SIZEOF(xColorItem)) >> 2;
+
+ for (i = 0, xcp = colors_in_out; i < ncolors; i++, xcp++) {
+ citem.pixel = xcp->pixel;
+ citem.red = xcp->red;
+ citem.green = xcp->green;
+ citem.blue = xcp->blue;
+
+ /* note that xColorItem doesn't contain all 16-bit quantities, so
+ we can't use Data16 */
+ Data(dpy, (char *)&citem, (long) SIZEOF(xColorItem));
+ }
+
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ long nbytes;
+ xColorItem* rbufp;
+ xColorItem* cs;
+ int nentries = rep.length / 3;
+
+ nbytes = nentries * SIZEOF (xColorItem);
+
+ if (nentries != ncolors) {
+ _XEatData (dpy, (unsigned long) nbytes);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return False;
+ }
+
+ if (ncolors > 256)
+ rbufp = (xColorItem*) Xmalloc (nbytes);
+ else
+ rbufp = rbuf;
+
+ if (rbufp == NULL) {
+ _XEatData (dpy, (unsigned long) nbytes);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return False;
+
+ }
+
+ _XRead (dpy, (char*) rbufp, nbytes);
+
+ for (i = 0, xcp = colors_in_out, cs = rbufp; i < ncolors; i++, xcp++, cs++) {
+ xcp->pixel = cs->pixel;
+ xcp->red = cs->red;
+ xcp->green = cs->green;
+ xcp->blue = cs->blue;
+ xcp->flags = cs->flags;
+ }
+ if (rbufp != rbuf) XFree ((char*)rbufp);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+}
+
diff --git a/nx-X11/lib/Xext/Xdbe.c b/nx-X11/lib/Xext/Xdbe.c
new file mode 100644
index 000000000..954c8f01d
--- /dev/null
+++ b/nx-X11/lib/Xext/Xdbe.c
@@ -0,0 +1,474 @@
+/* $Xorg: Xdbe.c,v 1.4 2000/08/17 19:45:53 cpqbld Exp $ */
+/******************************************************************************
+ *
+ * Copyright (c) 1994, 1995 Hewlett-Packard Company
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * 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 HEWLETT-PACKARD COMPANY 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 Hewlett-Packard
+ * Company 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 Hewlett-Packard Company.
+ *
+ * Xlib DBE code
+ *
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xext/Xdbe.c,v 3.7 2002/10/16 02:19:22 dawes Exp $ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#define NEED_DBE_PROTOCOL
+#include <X11/extensions/Xdbe.h>
+
+static XExtensionInfo _dbe_info_data;
+static XExtensionInfo *dbe_info = &_dbe_info_data;
+static char *dbe_extension_name = DBE_PROTOCOL_NAME;
+
+#define DbeCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, dbe_extension_name, val)
+#define DbeSimpleCheckExtension(dpy,i) \
+ XextSimpleCheckExtension (dpy, i, dbe_extension_name)
+
+#if !defined(UNIXCPP)
+#define DbeGetReq(name,req,info) GetReq (name, req); \
+ req->reqType = info->codes->major_opcode; \
+ req->dbeReqType = X_##name;
+#else
+#define DbeGetReq(name,req,info) GetReq (name, req); \
+ req->reqType = info->codes->major_opcode; \
+ req->dbeReqType = X_/**/name;
+#endif
+
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+/*
+ * find_display - locate the display info block
+ */
+static int close_display(Display *dpy, XExtCodes *codes);
+static char *error_string(Display *dpy, int code, XExtCodes *codes,
+ char *buf, int n);
+static XExtensionHooks dbe_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ error_string, /* error_string */
+};
+
+static char *dbe_error_list[] = {
+ "BadBuffer", /* DbeBadBuffer */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, dbe_info,
+ dbe_extension_name,
+ &dbe_extension_hooks,
+ DbeNumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, dbe_info)
+
+static XEXT_GENERATE_ERROR_STRING (error_string, dbe_extension_name,
+ DbeNumberErrors,
+ dbe_error_list)
+
+
+/*****************************************************************************
+ * *
+ * Double-Buffering public interfaces *
+ * *
+ *****************************************************************************/
+
+/*
+ * XdbeQueryExtension -
+ * Sets major_version_return and minor_verion_return to the major and
+ * minor DBE protocol version supported by the server. If the DBE
+ * library is compatible with the version returned by the server, this
+ * function returns non-zero. If dpy does not support the DBE
+ * extension, or if there was an error during communication with the
+ * server, or if the server and library protocol versions are
+ * incompatible, this functions returns zero. No other Xdbe functions
+ * may be called before this function. If a client violates this rule,
+ * the effects of all subsequent Xdbe calls are undefined.
+ */
+Status XdbeQueryExtension (
+ Display *dpy,
+ int *major_version_return,
+ int *minor_version_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xDbeGetVersionReply rep;
+ register xDbeGetVersionReq *req;
+
+ if (!XextHasExtension (info))
+ return (Status)0; /* failure */
+
+ LockDisplay (dpy);
+ DbeGetReq (DbeGetVersion, req, info);
+ req->majorVersion = DBE_MAJOR_VERSION;
+ req->minorVersion = DBE_MINOR_VERSION;
+
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return (Status)0; /* failure */
+ }
+ *major_version_return = rep.majorVersion;
+ *minor_version_return = rep.minorVersion;
+ UnlockDisplay (dpy);
+
+ SyncHandle ();
+
+ if (*major_version_return != DBE_MAJOR_VERSION)
+ return (Status)0; /* failure */
+ else
+ return (Status)1; /* success */
+}
+
+
+/*
+ * XdbeAllocateBackBuffer -
+ * This function returns a drawable ID used to refer to the back buffer
+ * of the specified window. The swap_action is a hint to indicate the
+ * swap action that will likely be used in subsequent calls to
+ * XdbeSwapBuffers. The actual swap action used in calls to
+ * XdbeSwapBuffers does not have to be the same as the swap_action
+ * passed to this function, though clients are encouraged to provide
+ * accurate information whenever possible.
+ */
+
+XdbeBackBuffer XdbeAllocateBackBufferName(
+ Display *dpy,
+ Window window,
+ XdbeSwapAction swap_action)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDbeAllocateBackBufferNameReq *req;
+ XdbeBackBuffer buffer;
+
+ /* make sure extension is available; if not, return the
+ * third parameter (0).
+ */
+ DbeCheckExtension (dpy, info, (XdbeBackBuffer)0);
+
+ /* allocate the id */
+ buffer = XAllocID (dpy);
+
+ LockDisplay(dpy);
+ DbeGetReq(DbeAllocateBackBufferName, req, info);
+ req->window = window;
+ req->swapAction = (unsigned char)swap_action;
+ req->buffer = buffer;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return buffer;
+
+} /* XdbeAllocateBackBufferName() */
+
+/*
+ * XdbeDeallocateBackBufferName -
+ * This function frees a drawable ID, buffer, that was obtained via
+ * XdbeAllocateBackBufferName. The buffer must refer to the back buffer
+ * of the specified window, or a protocol error results.
+ */
+Status XdbeDeallocateBackBufferName (
+ Display *dpy,
+ XdbeBackBuffer buffer)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDbeDeallocateBackBufferNameReq *req;
+
+ DbeCheckExtension (dpy, info, (Status)0 /* failure */);
+
+ LockDisplay (dpy);
+ DbeGetReq (DbeDeallocateBackBufferName, req, info);
+ req->buffer = buffer;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+
+ return (Status)1; /* success */
+}
+
+
+/*
+ * XdbeSwapBuffers -
+ * This function swaps the front and back buffers for a list of windows.
+ * The argument num_windows specifies how many windows are to have their
+ * buffers swapped; it is the number of elements in the swap_info array.
+ * The argument swap_info specifies the information needed per window
+ * to do the swap.
+ */
+Status XdbeSwapBuffers (
+ Display *dpy,
+ XdbeSwapInfo *swap_info,
+ int num_windows)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDbeSwapBuffersReq *req;
+ int i;
+
+ DbeCheckExtension (dpy, info, (Status)0 /* failure */);
+
+ LockDisplay (dpy);
+ DbeGetReq (DbeSwapBuffers, req, info);
+ req->length += 2*num_windows;
+ req->n = num_windows;
+
+ /* We need to handle 64-bit machines, where we can not use PackData32
+ * directly because info would be lost in translating from 32- to 64-bit.
+ * Instead we send data via a loop that accounts for the translation.
+ */
+ for (i = 0; i < num_windows; i++)
+ {
+ char tmp[4];
+ Data32 (dpy, (long *)&swap_info[i].swap_window, 4);
+ tmp[0] = swap_info[i].swap_action;
+ Data (dpy, (char *)tmp, 4);
+ }
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+
+
+ return (Status)1; /* success */
+
+} /* XdbeSwapBuffers() */
+
+
+/*
+ * XdbeBeginIdiom -
+ * This function marks the beginning of an idiom sequence.
+ */
+Status XdbeBeginIdiom (Display *dpy)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ register xDbeBeginIdiomReq *req;
+
+ DbeCheckExtension (dpy, info, (Status)0 /* failure */);
+
+ LockDisplay (dpy);
+ DbeGetReq (DbeBeginIdiom, req, info);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+
+ return (Status)1; /* success */
+}
+
+
+/*
+ * XdbeEndIdiom -
+ * This function marks the end of an idiom sequence.
+ */
+Status XdbeEndIdiom (Display *dpy)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ register xDbeEndIdiomReq *req;
+
+ DbeCheckExtension (dpy, info, (Status)0 /* failure */);
+
+ LockDisplay (dpy);
+ DbeGetReq (DbeEndIdiom, req, info);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+
+ return (Status)1; /* success */
+}
+
+
+/*
+ * XdbeGetVisualInfo -
+ * This function returns information about which visuals support
+ * double buffering. The argument num_screens specifies how many
+ * elements there are in the screen_specifiers list. Each drawable
+ * in screen_specifiers designates a screen for which the supported
+ * visuals are being requested. If num_screens is zero, information
+ * for all screens is requested. In this case, upon return from this
+ * function, num_screens will be set to the number of screens that were
+ * found. If an error occurs, this function returns NULL, else it returns
+ * a pointer to a list of XdbeScreenVisualInfo structures of length
+ * num_screens. The nth element in the returned list corresponds to the
+ * nth drawable in the screen_specifiers list, unless num_screens was
+ * passed in with the value zero, in which case the nth element in the
+ * returned list corresponds to the nth screen of the server, starting
+ * with screen zero.
+ */
+XdbeScreenVisualInfo *XdbeGetVisualInfo (
+ Display *dpy,
+ Drawable *screen_specifiers,
+ int *num_screens) /* SEND and RETURN */
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ register xDbeGetVisualInfoReq *req;
+ xDbeGetVisualInfoReply rep;
+ XdbeScreenVisualInfo *scrVisInfo;
+ int i;
+
+ DbeCheckExtension (dpy, info, (XdbeScreenVisualInfo *)NULL);
+
+ LockDisplay (dpy);
+
+ DbeGetReq(DbeGetVisualInfo, req, info);
+ req->length = 2 + *num_screens;
+ req->n = *num_screens;
+ Data32 (dpy, screen_specifiers, (*num_screens * sizeof (CARD32)));
+
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return NULL;
+ }
+
+ /* return the number of screens actually found if we
+ * requested information about all screens (*num_screens == 0)
+ */
+ if (*num_screens == 0)
+ *num_screens = rep.m;
+
+ /* allocate list of visual information to be returned */
+ if (!(scrVisInfo =
+ (XdbeScreenVisualInfo *)Xmalloc(
+ (unsigned)(*num_screens * sizeof(XdbeScreenVisualInfo))))) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return NULL;
+ }
+
+ for (i = 0; i < *num_screens; i++)
+ {
+ int nbytes;
+ int j;
+ long c;
+
+ _XRead32 (dpy, &c, sizeof(CARD32));
+ scrVisInfo[i].count = c;
+
+ nbytes = scrVisInfo[i].count * sizeof(XdbeVisualInfo);
+
+ /* if we can not allocate the list of visual/depth info
+ * then free the lists that we already allocate as well
+ * as the visual info list itself
+ */
+ if (!(scrVisInfo[i].visinfo = (XdbeVisualInfo *)Xmalloc(
+ (unsigned)nbytes))) {
+ for (j = 0; j < i; j++) {
+ Xfree ((char *)scrVisInfo[j].visinfo);
+ }
+ Xfree ((char *)scrVisInfo);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return NULL;
+ }
+
+ /* Read the visual info item into the wire structure. Then copy each
+ * element into the library structure. The element sizes and/or
+ * padding may be different in the two structures.
+ */
+ for (j = 0; j < scrVisInfo[i].count; j++) {
+ xDbeVisInfo xvi;
+
+ _XRead (dpy, (char *)&xvi, sizeof(xDbeVisInfo));
+ scrVisInfo[i].visinfo[j].visual = xvi.visualID;
+ scrVisInfo[i].visinfo[j].depth = xvi.depth;
+ scrVisInfo[i].visinfo[j].perflevel = xvi.perfLevel;
+ }
+
+ }
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return scrVisInfo;
+
+} /* XdbeGetVisualInfo() */
+
+
+/*
+ * XdbeFreeVisualInfo -
+ * This function frees the list of XdbeScreenVisualInfo returned by the
+ * function XdbeGetVisualInfo.
+ */
+void XdbeFreeVisualInfo(XdbeScreenVisualInfo *visual_info)
+{
+ if (visual_info == NULL) {
+ return;
+ }
+
+ if (visual_info->visinfo) {
+ XFree(visual_info->visinfo);
+ }
+
+ XFree(visual_info);
+}
+
+
+/*
+ * XdbeGetBackBufferAttributes -
+ * This function returns the attributes associated with the specified
+ * buffer.
+ */
+XdbeBackBufferAttributes *XdbeGetBackBufferAttributes(
+ Display *dpy,
+ XdbeBackBuffer buffer)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ register xDbeGetBackBufferAttributesReq *req;
+ xDbeGetBackBufferAttributesReply rep;
+ XdbeBackBufferAttributes *attr;
+
+ DbeCheckExtension(dpy, info, (XdbeBackBufferAttributes *)NULL);
+
+ if (!(attr =
+ (XdbeBackBufferAttributes *)Xmalloc(sizeof(XdbeBackBufferAttributes)))) {
+ return NULL;
+ }
+
+ LockDisplay(dpy);
+ DbeGetReq(DbeGetBackBufferAttributes, req, info);
+ req->buffer = buffer;
+
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return NULL;
+ }
+ attr->window = rep.attributes;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+
+ return attr;
+}
+
diff --git a/nx-X11/lib/Xext/Xext-def.cpp b/nx-X11/lib/Xext/Xext-def.cpp
new file mode 100644
index 000000000..fcd9f49a2
--- /dev/null
+++ b/nx-X11/lib/Xext/Xext-def.cpp
@@ -0,0 +1,140 @@
+LIBRARY XEXT
+VERSION LIBRARY_VERSION
+EXPORTS
+ XMITMiscGetBugMode
+ XMITMiscQueryExtension
+ XMITMiscSetBugMode
+ XMissingExtension
+ XSetExtensionErrorHandler
+ XShapeCombineMask
+ XShapeCombineRectangles
+ XShapeCombineRegion
+ XShapeCombineShape
+ XShapeGetRectangles
+ XShapeInputSelected
+ XShapeOffsetShape
+ XShapeQueryExtension
+ XShapeQueryExtents
+ XShapeQueryVersion
+ XShapeSelectInput
+#if (defined(__CYGWIN__) && defined(HAS_SHM)) || defined(__UNIXOS2__)
+ XShmAttach
+ XShmCreateImage
+ XShmCreatePixmap
+ XShmDetach
+;XShmDestroyImage
+ XShmGetEventBase
+ XShmGetImage
+ XShmPixmapFormat
+ XShmPutImage
+ XShmQueryExtension
+ XShmQueryVersion
+#endif
+ XSyncAwait
+ XSyncChangeAlarm
+ XSyncChangeCounter
+ XSyncCreateAlarm
+ XSyncCreateCounter
+ XSyncDestroyAlarm
+ XSyncDestroyCounter
+ XSyncFreeSystemCounterList
+ XSyncGetPriority
+ XSyncInitialize
+ XSyncIntToValue
+ XSyncIntsToValue
+ XSyncListSystemCounters
+ XSyncMaxValue
+ XSyncMinValue
+ XSyncQueryAlarm
+ XSyncQueryCounter
+ XSyncQueryExtension
+ XSyncSetCounter
+ XSyncSetPriority
+ XSyncValueAdd
+ XSyncValueEqual
+ XSyncValueGreaterOrEqual
+ XSyncValueGreaterThan
+ XSyncValueHigh32
+ XSyncValueIsNegative
+ XSyncValueIsPositive
+ XSyncValueIsZero
+ XSyncValueLessOrEqual
+ XSyncValueLessThan
+ XSyncValueLow32
+ XSyncValueSubtract
+ XTestFakeInput
+ XTestFlush
+ XTestGetInput
+ XTestMovePointer
+ XTestPressButton
+ XTestPressKey
+ XTestQueryInputSize
+ XTestReset
+ XTestStopInput
+ XextAddDisplay
+ XextCreateExtension
+ XextDestroyExtension
+ XextFindDisplay
+ XextRemoveDisplay
+ XmbufChangeBufferAttributes
+ XmbufChangeWindowAttributes
+ XmbufClearBufferArea
+ XmbufCreateBuffers
+ XmbufCreateStereoWindow
+ XmbufDestroyBuffers
+ XmbufDisplayBuffers
+ XmbufGetBufferAttributes
+ XmbufGetScreenInfo
+ XmbufGetVersion
+ XmbufGetWindowAttributes
+ XmbufQueryExtension
+ XdbeQueryExtension
+ XdbeAllocateBackBufferName
+ XdbeDeallocateBackBufferName
+ XdbeSwapBuffers
+ XdbeBeginIdiom
+ XdbeEndIdiom
+ XdbeGetVisualInfo
+ XdbeFreeVisualInfo
+ XdbeGetBackBufferAttributes
+ XSecurityQueryExtension
+ XSecurityAllocXauth
+ XSecurityFreeXauth
+ XSecurityGenerateAuthorization
+ XSecurityRevokeAuthorization
+ XagQueryVersion
+ XagCreateAssociation
+ XagCreateEmbeddedApplicationGroup
+ XagCreateNonembeddedApplicationGroup
+ XagDestroyApplicationGroup
+ XagDestroyAssociation
+ XagGetApplicationGroupAttributes
+ XagQueryApplicationGroup
+ XLbxQueryExtension
+ XLbxGetEventBase
+ XLbxQueryVersion
+ XcupGetReservedColormapEntries
+ XcupQueryVersion
+ XcupStoreColors
+#if !defined(__CYGWIN__) && !defined(__UNIXOS2__)
+ XPanoramiXQueryVersion
+ XPanoramiXAllocInfo
+ XPanoramiXGetScreenCount
+ XPanoramiXGetScreenSize
+ XPanoramiXGetState
+ XPanoramiXQueryExtension
+#endif
+ DPMSQueryExtension
+ DPMSGetVersion
+ DPMSCapable
+ DPMSSetTimeouts
+ DPMSGetTimeouts
+ DPMSEnable
+ DPMSDisable
+ DPMSForceLevel
+ DPMSInfo
+ XeviQueryExtension
+ XeviQueryVersion
+ XeviGetVisualInfo
+/* $Xorg: Xext-def.cpp,v 1.3 2000/08/17 19:45:53 cpqbld Exp $ */
+/* $XFree86: xc/lib/Xext/Xext-def.cpp,v 1.8 2001/05/06 10:35:51 alanh Exp $ */
diff --git a/nx-X11/lib/Xext/extutil.c b/nx-X11/lib/Xext/extutil.c
new file mode 100644
index 000000000..d96b17f3f
--- /dev/null
+++ b/nx-X11/lib/Xext/extutil.c
@@ -0,0 +1,273 @@
+/*
+ * $Xorg: extutil.c,v 1.4 2001/02/09 02:03:49 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.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ *
+ *
+ * Xlib Extension-Writing Utilities
+ *
+ * This package contains utilities for writing the client API for various
+ * protocol extensions. THESE INTERFACES ARE NOT PART OF THE X STANDARD AND
+ * ARE SUBJECT TO CHANGE!
+ *
+ * Routines include:
+ *
+ * XextCreateExtension called once per extension
+ * XextDestroyExtension if no longer using extension
+ * XextAddDisplay add another display
+ * XextRemoveDisplay remove a display
+ * XextFindDisplay is a display open
+ *
+ * In addition, the following Xlib-style interfaces are provided:
+ *
+ * XSetExtensionErrorHandler establish an extension error handler
+ * XMissingExtension raise an error about missing ext
+ */
+/* $XFree86: xc/lib/Xext/extutil.c,v 1.5 2002/10/16 00:37:27 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+
+/*
+ * XextCreateExtension - return an extension descriptor containing context
+ * information for this extension. This object is passed to all Xext
+ * routines.
+ */
+XExtensionInfo *XextCreateExtension (void)
+{
+ register XExtensionInfo *info =
+ (XExtensionInfo *) Xmalloc (sizeof (XExtensionInfo));
+
+ if (info) {
+ info->head = NULL;
+ info->cur = NULL;
+ info->ndisplays = 0;
+ }
+ return info;
+}
+
+
+/*
+ * XextDestroyExtension - free memory the given extension descriptor
+ */
+void XextDestroyExtension (XExtensionInfo *info)
+{
+ info->head = NULL; /* to catch refs after this */
+ info->cur = NULL;
+ info->ndisplays = 0;
+ XFree ((char *) info);
+}
+
+
+
+/*
+ * XextAddDisplay - add a display to this extension
+ */
+XExtDisplayInfo *XextAddDisplay (
+ XExtensionInfo *extinfo,
+ Display *dpy,
+ char *ext_name,
+ XExtensionHooks *hooks,
+ int nevents,
+ XPointer data)
+{
+ XExtDisplayInfo *dpyinfo;
+
+ dpyinfo = (XExtDisplayInfo *) Xmalloc (sizeof (XExtDisplayInfo));
+ if (!dpyinfo) return NULL;
+ dpyinfo->display = dpy;
+ dpyinfo->data = data;
+ dpyinfo->codes = XInitExtension (dpy, ext_name);
+
+ /*
+ * if the server has the extension, then we can initialize the
+ * appropriate function vectors
+ */
+ if (dpyinfo->codes) {
+ int i, j;
+
+ for (i = 0, j = dpyinfo->codes->first_event; i < nevents; i++, j++) {
+ XESetWireToEvent (dpy, j, hooks->wire_to_event);
+ XESetEventToWire (dpy, j, hooks->event_to_wire);
+ }
+ if (hooks->create_gc)
+ XESetCreateGC (dpy, dpyinfo->codes->extension, hooks->create_gc);
+ if (hooks->copy_gc)
+ XESetCopyGC (dpy, dpyinfo->codes->extension, hooks->copy_gc);
+ if (hooks->flush_gc)
+ XESetFlushGC (dpy, dpyinfo->codes->extension, hooks->flush_gc);
+ if (hooks->free_gc)
+ XESetFreeGC (dpy, dpyinfo->codes->extension, hooks->free_gc);
+ if (hooks->create_font)
+ XESetCreateFont (dpy, dpyinfo->codes->extension, hooks->create_font);
+ if (hooks->free_font)
+ XESetFreeFont (dpy, dpyinfo->codes->extension, hooks->free_font);
+ if (hooks->close_display)
+ XESetCloseDisplay (dpy, dpyinfo->codes->extension,
+ hooks->close_display);
+ if (hooks->error)
+ XESetError (dpy, dpyinfo->codes->extension, hooks->error);
+ if (hooks->error_string)
+ XESetErrorString (dpy, dpyinfo->codes->extension,
+ hooks->error_string);
+ } else if (hooks->close_display) {
+ /* The server doesn't have this extension.
+ * Use a private Xlib-internal extension to hang the close_display
+ * hook on so that the "cache" (extinfo->cur) is properly cleaned.
+ * (XBUG 7955)
+ */
+ XExtCodes *codes = XAddExtension(dpy);
+ if (!codes) {
+ XFree(dpyinfo);
+ return NULL;
+ }
+ XESetCloseDisplay (dpy, codes->extension, hooks->close_display);
+ }
+
+ /*
+ * now, chain it onto the list
+ */
+ _XLockMutex(_Xglobal_lock);
+ dpyinfo->next = extinfo->head;
+ extinfo->head = dpyinfo;
+ extinfo->cur = dpyinfo;
+ extinfo->ndisplays++;
+ _XUnlockMutex(_Xglobal_lock);
+ return dpyinfo;
+}
+
+
+/*
+ * XextRemoveDisplay - remove the indicated display from the extension object
+ */
+int XextRemoveDisplay (XExtensionInfo *extinfo, Display *dpy)
+{
+ XExtDisplayInfo *dpyinfo, *prev;
+
+ /*
+ * locate this display and its back link so that it can be removed
+ */
+ _XLockMutex(_Xglobal_lock);
+ prev = NULL;
+ for (dpyinfo = extinfo->head; dpyinfo; dpyinfo = dpyinfo->next) {
+ if (dpyinfo->display == dpy) break;
+ prev = dpyinfo;
+ }
+ if (!dpyinfo) {
+ _XUnlockMutex(_Xglobal_lock);
+ return 0; /* hmm, actually an error */
+ }
+
+ /*
+ * remove the display from the list; handles going to zero
+ */
+ if (prev)
+ prev->next = dpyinfo->next;
+ else
+ extinfo->head = dpyinfo->next;
+
+ extinfo->ndisplays--;
+ if (dpyinfo == extinfo->cur) extinfo->cur = NULL; /* flush cache */
+ _XUnlockMutex(_Xglobal_lock);
+
+ Xfree ((char *) dpyinfo);
+ return 1;
+}
+
+
+/*
+ * XextFindDisplay - look for a display in this extension; keeps a cache
+ * of the most-recently used for efficiency.
+ */
+XExtDisplayInfo *XextFindDisplay (XExtensionInfo *extinfo, Display *dpy)
+{
+ register XExtDisplayInfo *dpyinfo;
+
+ /*
+ * see if this was the most recently accessed display
+ */
+ if ((dpyinfo = extinfo->cur)&& dpyinfo->display == dpy) return dpyinfo;
+
+
+ /*
+ * look for display in list
+ */
+ _XLockMutex(_Xglobal_lock);
+ for (dpyinfo = extinfo->head; dpyinfo; dpyinfo = dpyinfo->next) {
+ if (dpyinfo->display == dpy) {
+ extinfo->cur = dpyinfo; /* cache most recently used */
+ _XUnlockMutex(_Xglobal_lock);
+ return dpyinfo;
+ }
+ }
+ _XUnlockMutex(_Xglobal_lock);
+
+ return NULL;
+}
+
+
+
+static int _default_exterror (Display *dpy, char *ext_name, char *reason)
+{
+ fprintf (stderr, "Xlib: extension \"%s\" %s on display \"%s\".\n",
+ ext_name, reason, DisplayString(dpy));
+ return 0;
+}
+
+
+/*
+ * XSetExtensionErrorHandler - sets the handler that gets called when a
+ * requested extension is referenced. This should eventually move into Xlib.
+ */
+
+extern int (*_XExtensionErrorFunction)();
+
+int (*XSetExtensionErrorHandler(int (*handler)(Display*, char *, char * )))()
+{
+ int (*oldhandler)() = _XExtensionErrorFunction;
+
+ _XExtensionErrorFunction = (handler ? handler :
+ _default_exterror);
+ return oldhandler;
+}
+
+
+/*
+ * XMissingExtension - call the extension error handler
+ */
+int XMissingExtension (Display *dpy, _Xconst char *ext_name)
+{
+ int (*func)() = (_XExtensionErrorFunction ?
+ _XExtensionErrorFunction : _default_exterror);
+
+ if (!ext_name) ext_name = X_EXTENSION_UNKNOWN;
+ return (*func) (dpy, ext_name, X_EXTENSION_MISSING);
+}
diff --git a/nx-X11/lib/Xext/globals.c b/nx-X11/lib/Xext/globals.c
new file mode 100644
index 000000000..0cd5d2690
--- /dev/null
+++ b/nx-X11/lib/Xext/globals.c
@@ -0,0 +1,90 @@
+/* $Xorg: globals.c,v 1.4 2001/02/09 02:03:50 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.
+
+*/
+/* $XFree86: xc/lib/Xext/globals.c,v 3.4 2001/07/29 05:01:12 tsi Exp $ */
+
+/*
+ * This file should contain only those objects which must be predefined.
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/extensions/Xext.h>
+#include <stddef.h> /* for definition of NULL */
+
+/*
+ * If possible, it is useful to have the global data default to a null value.
+ * Some shared library implementations are *much* happier if there isn't any
+ * global initialized data.
+ */
+#ifdef NULL_NOT_ZERO /* then need to initialize */
+#define SetZero(t,var,z) t var = z
+#else
+#define SetZero(t,var,z) t var
+#endif
+
+#ifdef ATTSHAREDLIB /* then need extra variables */
+/*
+ * If we need to define extra variables for each global
+ */
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define ZEROINIT(t,var,val) SetZero(t,var,val); \
+ SetZero (long, _libX_##var##Flag, 0); \
+ SetZero (void *, _libX_##var##Ptr, NULL)
+#else /* else pcc concatenation */
+#define ZEROINIT(t,var,val) SetZero(t,var,val); \
+ SetZero (long, _libX_/**/var/**/Flag, 0); \
+ SetZero (void *, _libX_/**/var/**/Ptr, NULL)
+#endif /* concat ANSI C vs. pcc */
+
+#else /* else not ATTSHAREDLIB */
+/*
+ * no extra crud
+ */
+#define ZEROINIT(t,var,val) SetZero (t, var, val)
+
+#endif /* ATTSHAREDLIB */
+
+
+/*
+ * Error handlers; used to be in XlibInt.c
+ */
+typedef int (*funcptr)();
+ZEROINIT (funcptr, _XExtensionErrorFunction, NULL);
+
+/*
+ * NOTE: any additional external definition NEED
+ * to be inserted BELOW this point!!!
+ */
+
+/*
+ * NOTE: any additional external definition NEED
+ * to be inserted ABOVE this point!!!
+ */
+
diff --git a/nx-X11/lib/Xfixes/.cvsignore b/nx-X11/lib/Xfixes/.cvsignore
new file mode 100644
index 000000000..e69298c9d
--- /dev/null
+++ b/nx-X11/lib/Xfixes/.cvsignore
@@ -0,0 +1,25 @@
+.deps
+.libs
+*.lo
+*.la
+Makefile
+Makefile.in
+aclocal.m4
+autogen.sh
+autom4te.cache
+config.guess
+config.h
+config.h.in
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+libXfixes.la
+libtool
+ltmain.sh
+missing
+mkinstalldirs
+stamp-h1
+xfixes.pc
diff --git a/nx-X11/lib/Xfixes/AUTHORS b/nx-X11/lib/Xfixes/AUTHORS
new file mode 100644
index 000000000..ab0e01b06
--- /dev/null
+++ b/nx-X11/lib/Xfixes/AUTHORS
@@ -0,0 +1 @@
+Keith Packard, HP and XFree86.
diff --git a/nx-X11/lib/Xfixes/COPYING b/nx-X11/lib/Xfixes/COPYING
new file mode 100644
index 000000000..e85d981e7
--- /dev/null
+++ b/nx-X11/lib/Xfixes/COPYING
@@ -0,0 +1,22 @@
+$Id: COPYING,v 1.1 2004/07/31 05:50:39 anholt Exp $
+
+Copyright © 2001,2003 Keith Packard
+
+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 of Keith Packard not be used in
+advertising or publicity pertaining to distribution of the software without
+specific, written prior permission. Keith Packard makes no
+representations about the suitability of this software for any purpose. It
+is provided "as is" without express or implied warranty.
+
+KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL KEITH PACKARD 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.
+
diff --git a/nx-X11/lib/Xfixes/ChangeLog b/nx-X11/lib/Xfixes/ChangeLog
new file mode 100644
index 000000000..cf2da5a94
--- /dev/null
+++ b/nx-X11/lib/Xfixes/ChangeLog
@@ -0,0 +1,102 @@
+Tue May 17 13:00:21 2005 Søren Sandmann <sandmann@redhat.com>
+
+ * *.c: Conditionally include <config.h>
+
+2004-07-26 Keith Packard <keithp@keithp.com>
+
+ * Makefile.am:
+ * Region.c: (XFixesFetchRegion), (XFixesFetchRegionAndBounds),
+ (XFixesExpandRegion):
+ * Xfixes.c: (XFixesVersion):
+ * Xfixes.h:
+ * configure.ac:
+ Add XFixesExpandRegion and XFixesFetchRegionAndBounds
+
+2004-04-13 Daniel Stone <daniel@freedesktop.org>
+
+ * Bump version to 2.0.2 for xlibs 1.0.1; no other changes.
+
+2004-04-01 Keith Packard <keithp@keithp.com>
+
+ reviewed by: Bill Haneman
+
+ * Region.c: (XFixesFetchRegion):
+ Forgot to store the region operand in the protocol request.
+ Made this function completely broken.
+
+2004-03-08 Keith Packard <keithp@keithp.com>
+
+ * Cursor.c: (XFixesGetCursorImage), (XFixesSetCursorName),
+ (XFixesChangeCursorByName):
+ * Xfixes.h:
+ Use 'const' in API to make C++ happy
+
+2004-02-03 Jim Gettys <jg@freedesktop.org.org>
+
+ * AUTHORS: Get a author file with contents.
+
+2004-01-15 Daniel Stone <daniel@fooishbar.org>
+ * Tag release 2.0.1 for first freedesktop.org clientside lib release.
+
+2004-01-15 Harold L Hunt II <huntharo@msu.edu>
+ * Makefile.am: Pass -no-undefined to libtool via LDFLAGS.
+
+2003-11-21 Keith Packard <keithp@keithp.com>
+
+ * Region.c: (XFixesCopyRegion), (XFixesUnionRegion),
+ (XFixesIntersectRegion), (XFixesSubtractRegion),
+ (XFixesInvertRegion), (XFixesTranslateRegion):
+ * Xfixes.h:
+ Eliminate offset arguments in combining operators,
+ create separate XFixesCopyRegion and XFixesTranslateRegion functions.
+
+2003-11-02 Keith Packard <keithp@keithp.com>
+
+ * Cursor.c: (XFixesSelectCursorInput), (XFixesGetCursorImage),
+ (XFixesSetCursorName), (XFixesGetCursorName), (XFixesChangeCursor),
+ (XFixesChangeCursorByName):
+ * Makefile.am:
+ * Region.c: (XFixesCreateRegion), (XFixesCreateRegionFromBitmap),
+ (XFixesCreateRegionFromWindow), (XFixesCreateRegionFromGC),
+ (XFixesCreateRegionFromPicture), (XFixesDestroyRegion),
+ (XFixesSetRegion), (XFixesUnionRegion), (XFixesIntersectRegion),
+ (XFixesSubtractRegion), (XFixesInvertRegion),
+ (XFixesRegionExtents), (XFixesFetchRegion),
+ (XFixesSetGCClipRegion), (XFixesSetWindowShapeRegion),
+ (XFixesSetPictureClipRegion):
+ * SaveSet.c: (XFixesChangeSaveSet):
+ * Selection.c: (XFixesSelectSelectionInput):
+ * Xfixes.c: (XFixesExtAddDisplay), (XFixesExtRemoveDisplay),
+ (XFixesExtFindDisplay), (XFixesFindDisplay), (XFixesCloseDisplay),
+ (XFixesWireToEvent), (XFixesEventToWire), (XFixesQueryExtension),
+ (XFixesQueryVersion):
+ * Xfixes.h:
+ * Xfixesint.h:
+ * configure.ac:
+ * xfixes.pc.in:
+ Merge in xfixes_2_branch
+
+2003-10-19 Keith Packard <keithp@keithp.com>
+
+ * Cursor.c
+ * Region.c
+ * Makefile.am
+ * SaveSet.c
+ * Selection.c
+ * Xfixes.c
+ * Xfixes.h
+ * Xfixesint.h
+ * configure.ac
+ * xfixes.pc.in
+ Eliminate dependency on libXext by in-lining trivial code.
+ Switch to Xfixes 2.0, adding region and cursor name functions
+
+2003-09-16 Anders Carlsson <andersca@gnome.org>
+
+ * configure.ac:
+ * randr-uninstalled.pc.in:
+ Add uninstalled pc file.
+
+2003-04-21 Keith Packard <keithp@keithp.com>
+
+ + Added ChangeLog
diff --git a/nx-X11/lib/Xfixes/Cursor.c b/nx-X11/lib/Xfixes/Cursor.c
new file mode 100644
index 000000000..ada8a681a
--- /dev/null
+++ b/nx-X11/lib/Xfixes/Cursor.c
@@ -0,0 +1,220 @@
+/*
+ * $XFree86: xc/lib/Xfixes/Cursor.c,v 1.1 2002/11/30 06:21:44 keithp Exp $
+ *
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xfixesint.h"
+
+void
+XFixesSelectCursorInput (Display *dpy,
+ Window win,
+ unsigned long eventMask)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesSelectCursorInputReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ GetReq (XFixesSelectCursorInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesSelectCursorInput;
+ req->window = win;
+ req->eventMask = eventMask;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+XFixesCursorImage *
+XFixesGetCursorImage (Display *dpy)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesGetCursorImageAndNameReq *req;
+ xXFixesGetCursorImageAndNameReply rep;
+ int npixels;
+ int nbytes_name;
+ int nbytes, nread, rlength;
+ XFixesCursorImage *image;
+ char *name;
+
+ XFixesCheckExtension (dpy, info, 0);
+ LockDisplay (dpy);
+ GetReq (XFixesGetCursorImageAndName, req);
+ req->reqType = info->codes->major_opcode;
+ if (info->major_version >= 2)
+ req->xfixesReqType = X_XFixesGetCursorImageAndName;
+ else
+ req->xfixesReqType = X_XFixesGetCursorImage;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ if (info->major_version < 2)
+ {
+ rep.cursorName = None;
+ rep.nbytes = 0;
+ }
+ npixels = rep.width * rep.height;
+ nbytes_name = rep.nbytes;
+ /* reply data length */
+ nbytes = (long) rep.length << 2;
+ /* bytes of actual data in the reply */
+ nread = (npixels << 2) + nbytes_name;
+ /* size of data returned to application */
+ rlength = (sizeof (XFixesCursorImage) +
+ npixels * sizeof (unsigned long) +
+ nbytes_name + 1);
+
+ image = (XFixesCursorImage *) Xmalloc (rlength);
+ if (!image)
+ {
+ _XEatData (dpy, nbytes);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ image->x = rep.x;
+ image->y = rep.y;
+ image->width = rep.width;
+ image->height = rep.height;
+ image->xhot = rep.xhot;
+ image->yhot = rep.yhot;
+ image->cursor_serial = rep.cursorSerial;
+ image->pixels = (unsigned long *) (image + 1);
+ image->atom = rep.cursorName;
+ name = (char *) (image->pixels + npixels);
+ image->name = name;
+ _XRead32 (dpy, image->pixels, npixels << 2);
+ _XRead (dpy, name, nbytes_name);
+ name[nbytes_name] = '\0'; /* null-terminate */
+ /* skip any padding */
+ if(nbytes > nread)
+ {
+ _XEatData (dpy, (unsigned long) (nbytes - nread));
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return image;
+}
+
+void
+XFixesSetCursorName (Display *dpy, Cursor cursor, const char *name)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesSetCursorNameReq *req;
+ int nbytes = strlen (name);
+
+ XFixesSimpleCheckExtension (dpy, info);
+ if (info->major_version < 2)
+ return;
+ LockDisplay (dpy);
+ GetReq (XFixesSetCursorName, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesSetCursorName;
+ req->cursor = cursor;
+ req->nbytes = nbytes;
+ req->length += (nbytes + 3) >> 2;
+ Data (dpy, name, nbytes);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+const char *
+XFixesGetCursorName (Display *dpy, Cursor cursor, Atom *atom)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesGetCursorNameReq *req;
+ xXFixesGetCursorNameReply rep;
+ char *name;
+
+ XFixesCheckExtension (dpy, info, 0);
+ if (info->major_version < 2)
+ return 0;
+ LockDisplay (dpy);
+ GetReq (XFixesGetCursorName, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesGetCursorName;
+ req->cursor = cursor;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ *atom = rep.atom;
+ if ((name = (char *) Xmalloc(rep.nbytes+1))) {
+ _XReadPad(dpy, name, (long)rep.nbytes);
+ name[rep.nbytes] = '\0';
+ } else {
+ _XEatData(dpy, (unsigned long) (rep.nbytes + 3) & ~3);
+ name = (char *) NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(name);
+}
+
+void
+XFixesChangeCursor (Display *dpy, Cursor source, Cursor destination)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesChangeCursorReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ if (info->major_version < 2)
+ return;
+ LockDisplay (dpy);
+ GetReq (XFixesChangeCursor, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesChangeCursor;
+ req->source = source;
+ req->destination = destination;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XFixesChangeCursorByName (Display *dpy, Cursor source, const char *name)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesChangeCursorByNameReq *req;
+ int nbytes = strlen (name);
+
+ XFixesSimpleCheckExtension (dpy, info);
+ if (info->major_version < 2)
+ return;
+ LockDisplay (dpy);
+ GetReq (XFixesChangeCursorByName, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesChangeCursorByName;
+ req->source = source;
+ req->nbytes = nbytes;
+ req->length += (nbytes + 3) >> 2;
+ Data (dpy, name, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
diff --git a/nx-X11/lib/Xfixes/INSTALL b/nx-X11/lib/Xfixes/INSTALL
new file mode 100644
index 000000000..557b5e871
--- /dev/null
+++ b/nx-X11/lib/Xfixes/INSTALL
@@ -0,0 +1,8 @@
+Xfixes is built with the traditional configure script:
+
+ $ ./configure --prefix=/usr/X11R6
+
+This should generate valid Makefiles, then:
+
+ $ make
+ $ make install
diff --git a/nx-X11/lib/Xfixes/Imakefile b/nx-X11/lib/Xfixes/Imakefile
new file mode 100644
index 000000000..c053aa2b5
--- /dev/null
+++ b/nx-X11/lib/Xfixes/Imakefile
@@ -0,0 +1,75 @@
+XCOMM $XdotOrg: xc/lib/Xfixes/Imakefile,v 1.1 2004/07/31 05:50:39 anholt Exp $
+
+#ifndef NormalLibXfixes
+#define NormalLibXfixes YES
+SOXFIXESREV=3.0.0
+#endif
+
+#ifndef SharedLibXfixes
+#define SharedLibXfixes YES
+#endif
+
+#define DoNormalLib NormalLibXfixes
+#define DoSharedLib SharedLibXfixes
+#define DoDebugLib DebugLibXfixes
+#define DoProfileLib ProfileLibXfixes
+
+#define LibName Xfixes
+#define SoRev SOXFIXESREV
+#define IncSubdir X11
+#define IncSubSubdir extensions
+
+#include <Threads.tmpl>
+
+#ifdef SharedXfixesReqs
+REQUIREDLIBS = SharedXfixesReqs
+#endif
+
+XFIXES_VERSION=3.0.0
+
+X_LIBS=-L$(SHLIBDIR) $(XONLYLIB)
+X_CFLAGS=-I$(INCROOT) $(THREADS_DEFINES)
+
+RPATH_CFLAG = HardCodeLibdirFlag
+
+SRCS = Cursor.c \
+ Region.c \
+ SaveSet.c \
+ Selection.c \
+ Xfixes.c
+
+OBJS = Cursor.o \
+ Region.o \
+ SaveSet.o \
+ Selection.o \
+ Xfixes.o
+
+HEADERS = Xfixes.h
+
+SUBSTVARS=prefix="$(PROJECTROOT)" \
+ exec_prefix="$(BINDIR)" \
+ libdir="$(USRLIBDIR)" \
+ hardcode_libdir_flag_spec="$(RPATH_CFLAG)" \
+ includedir="$(INCROOT)" \
+ X_LIBS="$(X_LIBS)" \
+ X_CFLAGS="$(X_CFLAGS)" \
+ VERSION="$(XFIXES_VERSION)"
+
+#include <Library.tmpl>
+
+MANSUFFIX=$(LIBMANSUFFIX)
+InstallManPage(Xfixes,$(LIBMANDIR))
+
+DependTarget()
+
+all:: xfixes.pc
+
+xfixes.pc: xfixes.pc.in
+ RemoveFile($@)
+ sh ../Xcursor/config-subst $(SUBSTVARS) < xfixes.pc.in > $@
+
+InstallNonExecFile(xfixes.pc,$(USRLIBDIR)/pkgconfig)
+
+clean::
+ RemoveFile(xfixes.pc)
+
diff --git a/nx-X11/lib/Xfixes/Makefile.am b/nx-X11/lib/Xfixes/Makefile.am
new file mode 100644
index 000000000..08598f93e
--- /dev/null
+++ b/nx-X11/lib/Xfixes/Makefile.am
@@ -0,0 +1,56 @@
+#
+# $Id: Makefile.am,v 1.1 2004/07/31 05:50:39 anholt Exp $
+#
+# Copyright © 2003 Keith Packard, Noah Levitt
+#
+# 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 of Keith Packard not be used in
+# advertising or publicity pertaining to distribution of the software without
+# specific, written prior permission. Keith Packard makes no
+# representations about the suitability of this software for any purpose. It
+# is provided "as is" without express or implied warranty.
+#
+# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+# EVENT SHALL KEITH PACKARD 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.
+
+AM_CFLAGS = $(FIXESEXT_CFLAGS) $(X_CFLAGS)
+
+lib_LTLIBRARIES = libXfixes.la
+
+libXfixes_la_SOURCES = \
+ Cursor.c \
+ Region.c \
+ SaveSet.c \
+ Selection.c \
+ Xfixes.c \
+ Xfixesint.h
+
+libXfixes_la_LIBADD = @X_LIBS@
+
+#
+# Library version info. Check the libtool docs for
+# instructions on when and how to change this value
+#
+# bump when the ABI changes
+XFIXES_CURRENT=2
+# bump for non-ABI changes, reset to zero when CURRENT changes
+XFIXES_REVISION=0
+# bump when the ABI changes in backward-compatible fashion
+XFIXES_AGE=2
+libXfixes_la_LDFLAGS = -version-info ${XFIXES_CURRENT}:${XFIXES_REVISION}:${XFIXES_AGE} -no-undefined
+
+libXfixesincludedir = $(includedir)/X11/extensions
+libXfixesinclude_HEADERS = Xfixes.h
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = xfixes.pc
+
+EXTRA_DIST = xfixes.pc.in autogen.sh
diff --git a/nx-X11/lib/Xfixes/NEWS b/nx-X11/lib/Xfixes/NEWS
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/lib/Xfixes/NEWS
diff --git a/nx-X11/lib/Xfixes/README b/nx-X11/lib/Xfixes/README
new file mode 100644
index 000000000..67cf1d8be
--- /dev/null
+++ b/nx-X11/lib/Xfixes/README
@@ -0,0 +1,10 @@
+ Xfixes
+ XFIXES Extension
+ Version 2.0.1
+ 2002-10-4
+
+This package contains header files and documentation for the XFIXES
+extension. Library and server implementations are separate.
+
+Keith Packard
+keithp@keithp.com
diff --git a/nx-X11/lib/Xfixes/Region.c b/nx-X11/lib/Xfixes/Region.c
new file mode 100644
index 000000000..f4781fe9b
--- /dev/null
+++ b/nx-X11/lib/Xfixes/Region.c
@@ -0,0 +1,441 @@
+/*
+ * $Id: Region.c,v 1.3 2005/07/03 07:00:56 daniels Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xfixesint.h"
+
+XserverRegion
+XFixesCreateRegion (Display *dpy, XRectangle *rectangles, int nrectangles)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesCreateRegionReq *req;
+ long len;
+ XserverRegion region;
+
+ XFixesCheckExtension (dpy, info, 0);
+ LockDisplay (dpy);
+ GetReq (XFixesCreateRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesCreateRegion;
+ region = req->region = XAllocID (dpy);
+ len = ((long) nrectangles) << 1;
+ SetReqLen (req, len, len);
+ len <<= 2;
+ Data16 (dpy, (short *) rectangles, len);
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return region;
+}
+
+XserverRegion
+XFixesCreateRegionFromBitmap (Display *dpy, Pixmap bitmap)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesCreateRegionFromBitmapReq *req;
+ XserverRegion region;
+
+ XFixesCheckExtension (dpy, info, 0);
+ LockDisplay (dpy);
+ GetReq (XFixesCreateRegionFromBitmap, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesCreateRegionFromBitmap;
+ region = req->region = XAllocID (dpy);
+ req->bitmap = bitmap;
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return region;
+}
+
+XserverRegion
+XFixesCreateRegionFromWindow (Display *dpy, Window window, int kind)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesCreateRegionFromWindowReq *req;
+ XserverRegion region;
+
+ XFixesCheckExtension (dpy, info, 0);
+ LockDisplay (dpy);
+ GetReq (XFixesCreateRegionFromWindow, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesCreateRegionFromWindow;
+ region = req->region = XAllocID (dpy);
+ req->window = window;
+ req->kind = kind;
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return region;
+}
+
+XserverRegion
+XFixesCreateRegionFromGC (Display *dpy, GC gc)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesCreateRegionFromGCReq *req;
+ XserverRegion region;
+
+ XFixesCheckExtension (dpy, info, 0);
+ LockDisplay (dpy);
+ GetReq (XFixesCreateRegionFromGC, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesCreateRegionFromGC;
+ region = req->region = XAllocID (dpy);
+ req->gc = gc->gid;
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return region;
+}
+
+XserverRegion
+XFixesCreateRegionFromPicture (Display *dpy, XID picture)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesCreateRegionFromPictureReq *req;
+ XserverRegion region;
+
+ XFixesCheckExtension (dpy, info, 0);
+ LockDisplay (dpy);
+ GetReq (XFixesCreateRegionFromPicture, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesCreateRegionFromPicture;
+ region = req->region = XAllocID (dpy);
+ req->picture = picture;
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return region;
+}
+
+void
+XFixesDestroyRegion (Display *dpy, XserverRegion region)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesDestroyRegionReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (XFixesDestroyRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesDestroyRegion;
+ req->region = region;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+void
+XFixesSetRegion (Display *dpy, XserverRegion region,
+ XRectangle *rectangles, int nrectangles)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesSetRegionReq *req;
+ long len;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (XFixesSetRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesSetRegion;
+ req->region = region;
+ len = ((long) nrectangles) << 1;
+ SetReqLen (req, len, len);
+ len <<= 2;
+ Data16 (dpy, (short *) rectangles, len);
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+void
+XFixesCopyRegion (Display *dpy, XserverRegion dst, XserverRegion src)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesCopyRegionReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (XFixesCopyRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesCopyRegion;
+ req->source = src;
+ req->destination = dst;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+void
+XFixesUnionRegion (Display *dpy, XserverRegion dst,
+ XserverRegion src1, XserverRegion src2)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesUnionRegionReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (XFixesUnionRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesUnionRegion;
+ req->source1 = src1;
+ req->source2 = src2;
+ req->destination = dst;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+void
+XFixesIntersectRegion (Display *dpy, XserverRegion dst,
+ XserverRegion src1, XserverRegion src2)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesIntersectRegionReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (XFixesIntersectRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesIntersectRegion;
+ req->source1 = src1;
+ req->source2 = src2;
+ req->destination = dst;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+void
+XFixesSubtractRegion (Display *dpy, XserverRegion dst,
+ XserverRegion src1, XserverRegion src2)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesSubtractRegionReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (XFixesSubtractRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesSubtractRegion;
+ req->source1 = src1;
+ req->source2 = src2;
+ req->destination = dst;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+void
+XFixesInvertRegion (Display *dpy, XserverRegion dst,
+ XRectangle *rect, XserverRegion src)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesInvertRegionReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (XFixesInvertRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesInvertRegion;
+ req->source = src;
+ req->destination = dst;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+void
+XFixesTranslateRegion (Display *dpy, XserverRegion region, int dx, int dy)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesTranslateRegionReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (XFixesTranslateRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesTranslateRegion;
+ req->region = region;
+ req->dx = dx;
+ req->dy = dy;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+void
+XFixesRegionExtents (Display *dpy, XserverRegion dst, XserverRegion src)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesRegionExtentsReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (XFixesRegionExtents, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesRegionExtents;
+ req->source = src;
+ req->destination = dst;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+XRectangle *
+XFixesFetchRegion (Display *dpy, XserverRegion region, int *nrectanglesRet)
+{
+ XRectangle bounds;
+
+ return XFixesFetchRegionAndBounds (dpy, region, nrectanglesRet, &bounds);
+}
+
+XRectangle *
+XFixesFetchRegionAndBounds (Display *dpy,
+ XserverRegion region,
+ int *nrectanglesRet,
+ XRectangle *bounds)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesFetchRegionReq *req;
+ xXFixesFetchRegionReply rep;
+ XRectangle *rects;
+ int nrects;
+ long nbytes;
+ long nread;
+
+ XFixesCheckExtension (dpy, info, 0);
+ LockDisplay (dpy);
+ GetReq (XFixesFetchRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesFetchRegion;
+ req->region = region;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ bounds->x = rep.x;
+ bounds->y = rep.y;
+ bounds->width = rep.width;
+ bounds->height = rep.height;
+ nbytes = (long) rep.length << 2;
+ nrects = rep.length >> 1;
+ nread = nrects << 3;
+ rects = Xmalloc (nrects * sizeof (XRectangle));
+ if (!rects)
+ {
+ _XEatData (dpy, nbytes);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ _XRead16 (dpy, (short *) rects, nrects << 3);
+ /* skip any padding */
+ if(nbytes > nread)
+ {
+ _XEatData (dpy, (unsigned long) (nbytes - nread));
+ }
+ UnlockDisplay (dpy);
+ SyncHandle();
+ *nrectanglesRet = nrects;
+ return rects;
+}
+
+void
+XFixesSetGCClipRegion (Display *dpy, GC gc,
+ int clip_x_origin, int clip_y_origin,
+ XserverRegion region)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesSetGCClipRegionReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (XFixesSetGCClipRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesSetGCClipRegion;
+ req->gc = gc->gid;
+ req->region = region;
+ req->xOrigin = clip_x_origin;
+ req->yOrigin = clip_y_origin;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+void
+XFixesSetWindowShapeRegion (Display *dpy, Window win, int shape_kind,
+ int x_off, int y_off, XserverRegion region)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesSetWindowShapeRegionReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (XFixesSetWindowShapeRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesSetWindowShapeRegion;
+ req->dest = win;
+ req->destKind = shape_kind;
+ req->xOff = x_off;
+ req->yOff = y_off;
+ req->region = region;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+void
+XFixesSetPictureClipRegion (Display *dpy, XID picture,
+ int clip_x_origin, int clip_y_origin,
+ XserverRegion region)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesSetPictureClipRegionReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (XFixesSetPictureClipRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesSetPictureClipRegion;
+ req->picture = picture;
+ req->region = region;
+ req->xOrigin = clip_x_origin;
+ req->yOrigin = clip_y_origin;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+void
+XFixesExpandRegion (Display *dpy, XserverRegion dst, XserverRegion src,
+ unsigned left, unsigned right,
+ unsigned top, unsigned bottom)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesExpandRegionReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq (XFixesExpandRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesExpandRegion;
+ req->source = src;
+ req->destination = dst;
+ req->left = left;
+ req->right = right;
+ req->top = top;
+ req->bottom = bottom;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
diff --git a/nx-X11/lib/Xfixes/SaveSet.c b/nx-X11/lib/Xfixes/SaveSet.c
new file mode 100644
index 000000000..c5b73f9c9
--- /dev/null
+++ b/nx-X11/lib/Xfixes/SaveSet.c
@@ -0,0 +1,48 @@
+/*
+ * $XFree86: xc/lib/Xfixes/SaveSet.c,v 1.1 2002/11/30 18:41:33 keithp Exp $
+ *
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xfixesint.h"
+
+void
+XFixesChangeSaveSet (Display *dpy, Window win, int mode, int target, int map)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesChangeSaveSetReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ GetReq (XFixesChangeSaveSet, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesChangeSaveSet;
+ req->mode = mode;
+ req->target = target;
+ req->map = map;
+ req->window = win;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
diff --git a/nx-X11/lib/Xfixes/Selection.c b/nx-X11/lib/Xfixes/Selection.c
new file mode 100644
index 000000000..888dc84f0
--- /dev/null
+++ b/nx-X11/lib/Xfixes/Selection.c
@@ -0,0 +1,50 @@
+/*
+ * $XFree86: xc/lib/Xfixes/Selection.c,v 1.1 2002/11/30 06:21:45 keithp Exp $
+ *
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xfixesint.h"
+
+void
+XFixesSelectSelectionInput (Display *dpy,
+ Window win,
+ Atom selection,
+ unsigned long eventMask)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+ xXFixesSelectSelectionInputReq *req;
+
+ XFixesSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ GetReq (XFixesSelectSelectionInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesSelectSelectionInput;
+ req->window = win;
+ req->selection = selection;
+ req->eventMask = eventMask;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
diff --git a/nx-X11/lib/Xfixes/Xfixes-def.cpp b/nx-X11/lib/Xfixes/Xfixes-def.cpp
new file mode 100644
index 000000000..bbab58858
--- /dev/null
+++ b/nx-X11/lib/Xfixes/Xfixes-def.cpp
@@ -0,0 +1,10 @@
+LIBRARY Xfixes
+VERSION LIBRARY_VERSION
+EXPORTS
+ XFixesQueryExtension
+ XFixesQueryVersion
+ XFixesChangeSaveSet
+ XFixesSelectSelectionInput
+ XFixesSelectCursorInput
+ XFixesGetCursorImage
+/* $XFree86: xc/lib/Xfixes/Xfixes-def.cpp,v 1.1 2002/11/30 06:21:45 keithp Exp $ */
diff --git a/nx-X11/lib/Xfixes/Xfixes.c b/nx-X11/lib/Xfixes/Xfixes.c
new file mode 100644
index 000000000..e4dfd05de
--- /dev/null
+++ b/nx-X11/lib/Xfixes/Xfixes.c
@@ -0,0 +1,333 @@
+/*
+ * $XFree86: xc/lib/Xfixes/Xfixes.c,v 1.1 2002/11/30 06:21:45 keithp Exp $
+ *
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xfixesint.h"
+
+XFixesExtInfo XFixesExtensionInfo;
+char XFixesExtensionName[] = XFIXES_NAME;
+
+static int
+XFixesCloseDisplay (Display *dpy, XExtCodes *codes);
+
+static Bool
+XFixesWireToEvent(Display *dpy, XEvent *event, xEvent *wire);
+
+static Status
+XFixesEventToWire(Display *dpy, XEvent *event, xEvent *wire);
+
+/*
+ * XFixesExtAddDisplay - add a display to this extension. (Replaces
+ * XextAddDisplay)
+ */
+static XFixesExtDisplayInfo *
+XFixesExtAddDisplay (XFixesExtInfo *extinfo,
+ Display *dpy,
+ char *ext_name)
+{
+ XFixesExtDisplayInfo *info;
+ int ev;
+
+ info = (XFixesExtDisplayInfo *) Xmalloc (sizeof (XFixesExtDisplayInfo));
+ if (!info) return NULL;
+ info->display = dpy;
+
+ info->codes = XInitExtension (dpy, ext_name);
+
+ /*
+ * if the server has the extension, then we can initialize the
+ * appropriate function vectors
+ */
+ if (info->codes) {
+ xXFixesQueryVersionReply rep;
+ xXFixesQueryVersionReq *req;
+ XESetCloseDisplay (dpy, info->codes->extension,
+ XFixesCloseDisplay);
+ for (ev = info->codes->first_event;
+ ev < info->codes->first_event + XFixesNumberEvents;
+ ev++)
+ {
+ XESetWireToEvent (dpy, ev, XFixesWireToEvent);
+ XESetEventToWire (dpy, ev, XFixesEventToWire);
+ }
+ /*
+ * Get the version info
+ */
+ LockDisplay (dpy);
+ GetReq (XFixesQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xfixesReqType = X_XFixesQueryVersion;
+ req->majorVersion = XFIXES_MAJOR;
+ req->minorVersion = XFIXES_MINOR;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue))
+ {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ info->major_version = rep.majorVersion;
+ info->minor_version = rep.minorVersion;
+ UnlockDisplay (dpy);
+ } else {
+ /* The server doesn't have this extension.
+ * Use a private Xlib-internal extension to hang the close_display
+ * hook on so that the "cache" (extinfo->cur) is properly cleaned.
+ * (XBUG 7955)
+ */
+ XExtCodes *codes = XAddExtension(dpy);
+ if (!codes) {
+ XFree(info);
+ return NULL;
+ }
+ XESetCloseDisplay (dpy, codes->extension, XFixesCloseDisplay);
+ }
+
+ /*
+ * now, chain it onto the list
+ */
+ _XLockMutex(_Xglobal_lock);
+ info->next = extinfo->head;
+ extinfo->head = info;
+ extinfo->cur = info;
+ extinfo->ndisplays++;
+ _XUnlockMutex(_Xglobal_lock);
+ return info;
+}
+
+
+/*
+ * XFixesExtRemoveDisplay - remove the indicated display from the
+ * extension object. (Replaces XextRemoveDisplay.)
+ */
+static int
+XFixesExtRemoveDisplay (XFixesExtInfo *extinfo, Display *dpy)
+{
+ XFixesExtDisplayInfo *info, *prev;
+
+ /*
+ * locate this display and its back link so that it can be removed
+ */
+ _XLockMutex(_Xglobal_lock);
+ prev = NULL;
+ for (info = extinfo->head; info; info = info->next) {
+ if (info->display == dpy) break;
+ prev = info;
+ }
+ if (!info) {
+ _XUnlockMutex(_Xglobal_lock);
+ return 0; /* hmm, actually an error */
+ }
+
+ /*
+ * remove the display from the list; handles going to zero
+ */
+ if (prev)
+ prev->next = info->next;
+ else
+ extinfo->head = info->next;
+
+ extinfo->ndisplays--;
+ if (info == extinfo->cur) extinfo->cur = NULL; /* flush cache */
+ _XUnlockMutex(_Xglobal_lock);
+
+ Xfree ((char *) info);
+ return 1;
+}
+
+/*
+ * XFixesExtFindDisplay - look for a display in this extension; keeps a
+ * cache of the most-recently used for efficiency. (Replaces
+ * XextFindDisplay.)
+ */
+static XFixesExtDisplayInfo *
+XFixesExtFindDisplay (XFixesExtInfo *extinfo,
+ Display *dpy)
+{
+ XFixesExtDisplayInfo *info;
+
+ /*
+ * see if this was the most recently accessed display
+ */
+ if ((info = extinfo->cur) && info->display == dpy)
+ return info;
+
+ /*
+ * look for display in list
+ */
+ _XLockMutex(_Xglobal_lock);
+ for (info = extinfo->head; info; info = info->next) {
+ if (info->display == dpy) {
+ extinfo->cur = info; /* cache most recently used */
+ _XUnlockMutex(_Xglobal_lock);
+ return info;
+ }
+ }
+ _XUnlockMutex(_Xglobal_lock);
+
+ return NULL;
+}
+
+XFixesExtDisplayInfo *
+XFixesFindDisplay (Display *dpy)
+{
+ XFixesExtDisplayInfo *info;
+
+ info = XFixesExtFindDisplay (&XFixesExtensionInfo, dpy);
+ if (!info)
+ info = XFixesExtAddDisplay (&XFixesExtensionInfo, dpy,
+ XFixesExtensionName);
+ return info;
+}
+
+static int
+XFixesCloseDisplay (Display *dpy, XExtCodes *codes)
+{
+ return XFixesExtRemoveDisplay (&XFixesExtensionInfo, dpy);
+}
+
+static Bool
+XFixesWireToEvent(Display *dpy, XEvent *event, xEvent *wire)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay(dpy);
+
+ XFixesCheckExtension(dpy, info, False);
+
+ switch ((wire->u.u.type & 0x7F) - info->codes->first_event)
+ {
+ case XFixesSelectionNotify: {
+ XFixesSelectionNotifyEvent *aevent;
+ xXFixesSelectionNotifyEvent *awire;
+ awire = (xXFixesSelectionNotifyEvent *) wire;
+ aevent = (XFixesSelectionNotifyEvent *) event;
+ aevent->type = awire->type & 0x7F;
+ aevent->subtype = awire->subtype;
+ aevent->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *) wire);
+ aevent->send_event = (awire->type & 0x80) != 0;
+ aevent->display = dpy;
+ aevent->window = awire->window;
+ aevent->owner = awire->owner;
+ aevent->selection = awire->selection;
+ aevent->timestamp = awire->timestamp;
+ aevent->selection_timestamp = awire->selectionTimestamp;
+ return True;
+ }
+ case XFixesCursorNotify: {
+ XFixesCursorNotifyEvent *aevent;
+ xXFixesCursorNotifyEvent *awire;
+ awire = (xXFixesCursorNotifyEvent *) wire;
+ aevent = (XFixesCursorNotifyEvent *) event;
+ aevent->type = awire->type & 0x7F;
+ aevent->subtype = awire->subtype;
+ aevent->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *) wire);
+ aevent->send_event = (awire->type & 0x80) != 0;
+ aevent->display = dpy;
+ aevent->window = awire->window;
+ aevent->cursor_serial = awire->cursorSerial;
+ aevent->timestamp = awire->timestamp;
+ aevent->cursor_name = awire->name;
+ return True;
+ }
+ }
+ return False;
+}
+
+static Status
+XFixesEventToWire(Display *dpy, XEvent *event, xEvent *wire)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay(dpy);
+
+ XFixesCheckExtension(dpy, info, False);
+
+ switch ((event->type & 0x7F) - info->codes->first_event)
+ {
+ case XFixesSelectionNotify: {
+ XFixesSelectionNotifyEvent *aevent;
+ xXFixesSelectionNotifyEvent *awire;
+ awire = (xXFixesSelectionNotifyEvent *) wire;
+ aevent = (XFixesSelectionNotifyEvent *) event;
+ awire->type = aevent->type | (aevent->send_event ? 0x80 : 0);
+ awire->subtype = aevent->subtype;
+ awire->window = aevent->window;
+ awire->owner = aevent->owner;
+ awire->selection = aevent->selection;
+ awire->timestamp = aevent->timestamp;
+ awire->selectionTimestamp = aevent->selection_timestamp;
+ return True;
+ }
+ case XFixesCursorNotify: {
+ XFixesCursorNotifyEvent *aevent;
+ xXFixesCursorNotifyEvent *awire;
+ awire = (xXFixesCursorNotifyEvent *) wire;
+ aevent = (XFixesCursorNotifyEvent *) event;
+ awire->type = aevent->type | (aevent->send_event ? 0x80 : 0);
+ awire->subtype = aevent->subtype;
+ awire->window = aevent->window;
+ awire->timestamp = aevent->timestamp;
+ awire->cursorSerial = aevent->cursor_serial;
+ awire->name = aevent->cursor_name;
+ }
+ }
+ return False;
+}
+
+Bool
+XFixesQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+
+ if (XFixesHasExtension(info))
+ {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ }
+ else
+ return False;
+}
+
+Status
+XFixesQueryVersion (Display *dpy,
+ int *major_versionp,
+ int *minor_versionp)
+{
+ XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy);
+
+ XFixesCheckExtension (dpy, info, 0);
+
+ *major_versionp = info->major_version;
+ *minor_versionp = info->minor_version;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
+int
+XFixesVersion (void)
+{
+ return XFIXES_VERSION;
+}
diff --git a/nx-X11/lib/Xfixes/Xfixes.h b/nx-X11/lib/Xfixes/Xfixes.h
new file mode 100644
index 000000000..28ca28f1a
--- /dev/null
+++ b/nx-X11/lib/Xfixes/Xfixes.h
@@ -0,0 +1,220 @@
+/*
+ * $XFree86: xc/lib/Xfixes/Xfixes.h,v 1.1 2002/11/30 06:21:45 keithp Exp $
+ *
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _XFIXES_H_
+#define _XFIXES_H_
+
+#include <X11/extensions/xfixeswire.h>
+
+#include <X11/Xfuncproto.h>
+
+/*
+ * This revision number also appears in configure.ac, they have
+ * to be manually synchronized
+ */
+#define XFIXES_REVISION 1
+#define XFIXES_VERSION ((XFIXES_MAJOR * 10000) + (XFIXES_MINOR * 100) + (XFIXES_REVISION))
+
+typedef struct {
+ int type; /* event base */
+ unsigned long serial;
+ Bool send_event;
+ Display *display;
+ Window window;
+ int subtype;
+ Window owner;
+ Atom selection;
+ Time timestamp;
+ Time selection_timestamp;
+} XFixesSelectionNotifyEvent;
+
+typedef struct {
+ int type; /* event base */
+ unsigned long serial;
+ Bool send_event;
+ Display *display;
+ Window window;
+ int subtype;
+ unsigned long cursor_serial;
+ Time timestamp;
+ Atom cursor_name;
+} XFixesCursorNotifyEvent;
+
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+ unsigned short xhot, yhot;
+ unsigned long cursor_serial;
+ unsigned long *pixels;
+#if XFIXES_MAJOR >= 2
+ Atom atom; /* Version >= 2 only */
+ const char *name; /* Version >= 2 only */
+#endif
+} XFixesCursorImage;
+
+#if XFIXES_MAJOR >= 2
+/* Version 2 types */
+
+typedef XID XserverRegion;
+
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+ unsigned short xhot, yhot;
+ unsigned long cursor_serial;
+ unsigned long *pixels;
+ Atom atom;
+ const char *name;
+} XFixesCursorImageAndName;
+
+#endif
+
+_XFUNCPROTOBEGIN
+
+Bool XFixesQueryExtension (Display *dpy, int *event_basep, int *error_basep);
+Status XFixesQueryVersion (Display *dpy,
+ int *major_versionp,
+ int *minor_versionp);
+
+int XFixesVersion (void);
+
+void
+XFixesChangeSaveSet (Display *dpy,
+ Window win,
+ int mode,
+ int target,
+ int map);
+
+void
+XFixesSelectSelectionInput (Display *dpy,
+ Window win,
+ Atom selection,
+ unsigned long eventMask);
+
+void
+XFixesSelectCursorInput (Display *dpy,
+ Window win,
+ unsigned long eventMask);
+
+XFixesCursorImage *
+XFixesGetCursorImage (Display *dpy);
+
+#if XFIXES_MAJOR >= 2
+/* Version 2 functions */
+
+XserverRegion
+XFixesCreateRegion (Display *dpy, XRectangle *rectangles, int nrectangles);
+
+XserverRegion
+XFixesCreateRegionFromBitmap (Display *dpy, Pixmap bitmap);
+
+XserverRegion
+XFixesCreateRegionFromWindow (Display *dpy, Window window, int kind);
+
+XserverRegion
+XFixesCreateRegionFromGC (Display *dpy, GC gc);
+
+XserverRegion
+XFixesCreateRegionFromPicture (Display *dpy, XID picture);
+
+void
+XFixesDestroyRegion (Display *dpy, XserverRegion region);
+
+void
+XFixesSetRegion (Display *dpy, XserverRegion region,
+ XRectangle *rectangles, int nrectangles);
+
+void
+XFixesCopyRegion (Display *dpy, XserverRegion dst, XserverRegion src);
+
+void
+XFixesUnionRegion (Display *dpy, XserverRegion dst,
+ XserverRegion src1, XserverRegion src2);
+
+void
+XFixesIntersectRegion (Display *dpy, XserverRegion dst,
+ XserverRegion src1, XserverRegion src2);
+
+void
+XFixesSubtractRegion (Display *dpy, XserverRegion dst,
+ XserverRegion src1, XserverRegion src2);
+
+void
+XFixesInvertRegion (Display *dpy, XserverRegion dst,
+ XRectangle *rect, XserverRegion src);
+
+void
+XFixesTranslateRegion (Display *dpy, XserverRegion region, int dx, int dy);
+
+void
+XFixesRegionExtents (Display *dpy, XserverRegion dst, XserverRegion src);
+
+XRectangle *
+XFixesFetchRegion (Display *dpy, XserverRegion region, int *nrectanglesRet);
+
+XRectangle *
+XFixesFetchRegionAndBounds (Display *dpy, XserverRegion region,
+ int *nrectanglesRet,
+ XRectangle *bounds);
+
+void
+XFixesSetGCClipRegion (Display *dpy, GC gc,
+ int clip_x_origin, int clip_y_origin,
+ XserverRegion region);
+
+void
+XFixesSetWindowShapeRegion (Display *dpy, Window win, int shape_kind,
+ int x_off, int y_off, XserverRegion region);
+
+void
+XFixesSetPictureClipRegion (Display *dpy, XID picture,
+ int clip_x_origin, int clip_y_origin,
+ XserverRegion region);
+
+void
+XFixesSetCursorName (Display *dpy, Cursor cursor, const char *name);
+
+const char *
+XFixesGetCursorName (Display *dpy, Cursor cursor, Atom *atom);
+
+void
+XFixesChangeCursor (Display *dpy, Cursor source, Cursor destination);
+
+void
+XFixesChangeCursorByName (Display *dpy, Cursor source, const char *name);
+
+#endif /* XFIXES_MAJOR >= 2 */
+
+#if XFIXES_MAJOR >= 3
+
+void
+XFixesExpandRegion (Display *dpy, XserverRegion dst, XserverRegion src,
+ unsigned left, unsigned right,
+ unsigned top, unsigned bottom);
+
+#endif /* XFIXES_MAJOR >= 3 */
+
+_XFUNCPROTOEND
+
+#endif /* _XFIXES_H_ */
diff --git a/nx-X11/lib/Xfixes/Xfixes.man b/nx-X11/lib/Xfixes/Xfixes.man
new file mode 100644
index 000000000..f081cc54e
--- /dev/null
+++ b/nx-X11/lib/Xfixes/Xfixes.man
@@ -0,0 +1,76 @@
+.\"
+.\" $XFree86: xc/lib/Xfixes/Xfixes.man,v 1.1 2002/11/30 06:21:45 keithp Exp $
+.\"
+.\" Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+.\"
+.\" 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 of Keith Packard not be used in
+.\" advertising or publicity pertaining to distribution of the software without
+.\" specific, written prior permission. Keith Packard makes no
+.\" representations about the suitability of this software for any purpose. It
+.\" is provided "as is" without express or implied warranty.
+.\"
+.\" KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+.\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+.\" EVENT SHALL KEITH PACKARD 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.
+.\"
+.de TQ
+.br
+.ns
+.TP \\$1
+..
+.TH XFIXES 3 "Version 1.0" "XFree86"
+
+.SH NAME
+XFixes \- Augmented versions of core protocol requests
+.SH SYNTAX
+\&#include <X11/extensions/Xfixes.h>
+.nf
+.sp
+Bool XFixesQueryExtension \^(\^Display *\fIdpy\fP,
+ int *\fIevent_basep\fP, int *\fIerror_basep\fP\^);
+.sp
+Status XFixesQueryVersion \^(\^Display *\fIdpy\fP,
+ int *\fImajor_versionp\fP,
+ int *\fIminor_versionp\fP\^);
+.sp
+void XFixesChangeSaveSet \^(\^Display *dpy,
+ Window \fIwindow\fP,
+ int \fImode\fP,
+ int \fItarget\fP,
+ int \fImap\fP);
+.fi
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIwindow\fP 1i
+Specifies which window.
+.IP \fImode\fP 1i
+Specifies the save set operation (SetModeInsert/SetModeDelete).
+.IP \fItarget\fP 1i
+Specifies the target when executing the save set
+(SaveSetNearest/SaveSetRoot). In SaveSetNearest mode, the save set member
+window will be reparented to the nearest window not owned by the save set
+client. In SaveSetRoot mode, the save set member window will be reparented
+to the root window.
+.IP \fImap\fP 1i
+Specifies the map mode (SaveSetMap/SaveSetUnmap) which selects whether the
+save setmember window will be mapped or unmapped during save set processing.
+.SH DESCRIPTION
+.B Xfixes
+is a simple library designed to interface the X Fixes
+Extension. This extension provides application with work arounds for
+various limitations in the core protocol.
+.SH RESTRICTIONS
+.B Xfixes
+will remain upward compatible after the current 1.0 release.
+.SH AUTHORS
+Keith Packard, member of the XFree86 Project, Inc. and
+HP, Owen Taylor, member of the Gnome Foundation and Redhat, Inc.
diff --git a/nx-X11/lib/Xfixes/Xfixesint.h b/nx-X11/lib/Xfixes/Xfixesint.h
new file mode 100644
index 000000000..e227571be
--- /dev/null
+++ b/nx-X11/lib/Xfixes/Xfixesint.h
@@ -0,0 +1,68 @@
+/*
+ * $XFree86: xc/lib/Xfixes/Xfixesint.h,v 1.1 2002/11/30 06:21:45 keithp Exp $
+ *
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _XFIXESINT_H_
+#define _XFIXESINT_H_
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "Xfixes.h"
+#include <X11/extensions/xfixesproto.h>
+
+extern char XFixesExtensionName[];
+
+typedef struct _XFixesExtDisplayInfo {
+ struct _XFixesExtDisplayInfo *next; /* keep a linked list */
+ Display *display; /* which display this is */
+ XExtCodes *codes; /* the extension protocol codes */
+ int major_version; /* -1 means we don't know */
+ int minor_version; /* -1 means we don't know */
+} XFixesExtDisplayInfo;
+
+/* replaces XExtensionInfo */
+typedef struct _XFixesExtInfo {
+ XFixesExtDisplayInfo *head; /* start of the list */
+ XFixesExtDisplayInfo *cur; /* most recently used */
+ int ndisplays; /* number of displays */
+} XFixesExtInfo;
+
+extern XFixesExtInfo XFixesExtensionInfo;
+extern char XFixesExtensionName[];
+
+XFixesExtDisplayInfo *
+XFixesFindDisplay (Display *dpy);
+
+#define XFixesHasExtension(i) ((i) && ((i)->codes))
+
+#define XFixesCheckExtension(dpy,i,val) \
+ if (!XFixesHasExtension(i)) { return val; }
+
+#define XFixesSimpleCheckExtension(dpy,i) \
+ if (!XFixesHasExtension(i)) { return; }
+
+#endif /* _XFIXESINT_H_ */
diff --git a/nx-X11/lib/Xfixes/autogen.sh b/nx-X11/lib/Xfixes/autogen.sh
new file mode 100755
index 000000000..b1376df5a
--- /dev/null
+++ b/nx-X11/lib/Xfixes/autogen.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+autoreconf -v --install || exit 1
+./configure --enable-maintainer-mode "$@"
diff --git a/nx-X11/lib/Xfixes/configure.ac b/nx-X11/lib/Xfixes/configure.ac
new file mode 100644
index 000000000..37b123516
--- /dev/null
+++ b/nx-X11/lib/Xfixes/configure.ac
@@ -0,0 +1,99 @@
+dnl
+dnl $Id: configure.ac,v 1.1 2004/07/31 05:50:39 anholt Exp $
+dnl
+dnl Copyright © 2003 Keith Packard, Noah Levitt
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this software and its
+dnl documentation for any purpose is hereby granted without fee, provided that
+dnl the above copyright notice appear in all copies and that both that
+dnl copyright notice and this permission notice appear in supporting
+dnl documentation, and that the name of Keith Packard not be used in
+dnl advertising or publicity pertaining to distribution of the software without
+dnl specific, written prior permission. Keith Packard makes no
+dnl representations about the suitability of this software for any purpose. It
+dnl is provided "as is" without express or implied warranty.
+dnl
+dnl KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+dnl EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+dnl PERFORMANCE OF THIS SOFTWARE.
+dnl
+dnl Process this file with autoconf to create configure.
+
+AC_PREREQ([2.57])
+
+dnl
+dnl Version should match the current XFixes version. XFixesQueryVersion
+dnl returns the version from xfixeswire.h, NOT the version we set here. But we
+dnl try to keep these the same. Note that the library has an extra
+dnl digit in the version number to track changes which don't affect the
+dnl protocol, so Xfixes version l.n.m corresponds to protocol version l.n,
+dnl that 'revision' number appears in Xfixes.h and has to be manually
+dnl synchronized.
+dnl
+AC_INIT(libXfixes, 3.0.0, [keithp@keithp.com], libXfixes)
+AM_INIT_AUTOMAKE([dist-bzip2])
+AM_MAINTAINER_MODE
+
+AM_CONFIG_HEADER(config.h)
+AC_CONFIG_AUX_DIR(.)
+
+# Check for progs
+AC_PROG_CC
+AC_PROG_LIBTOOL
+
+# Check for X
+PKG_CHECK_MODULES(X, x11,
+ [x_found_with_pkgconfig=yes],
+ [x_found_with_pkgconfig=no])
+AC_SUBST(X_CFLAGS)
+AC_SUBST(X_LIBS)
+
+if test "$x_found_with_pkgconfig" = "no"
+then
+ AC_PATH_XTRA
+ X_LIBS="$X_LIBS -lX11"
+
+ if test "x$no_x" = "xyes"
+ then
+ AC_MSG_ERROR([X is required, but it was either disabled or not found.])
+ fi
+
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $X_CFLAGS"
+ LIBS="$LIBS $X_LIBS"
+
+ AC_MSG_CHECKING([for XTHREADS in Xlib])
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
+ [[return XInitThreads() == 0 ? 0 : 1;]])],
+ [xthreads=no],
+ [xthreads=yes],
+ [xthreads=yes])
+
+ AC_MSG_RESULT($xthreads)
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ if test "x$xthreads" = "xyes"
+ then
+ X_CFLAGS="$X_CFLAGS -DXTHREADS"
+ fi
+fi
+
+# Check fixesext configuration, strip extra digits from package version to
+# find the required protocol version
+
+FIXESEXT_VERSION=[`echo $VERSION | sed 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`]
+PKG_CHECK_MODULES(FIXESEXT, [fixesext >= $FIXESEXT_VERSION])
+AC_SUBST(FIXESEXT_CFLAGS)
+AC_SUBST(FIXESEXT_LIBS)
+
+AC_OUTPUT([Makefile
+ xfixes.pc])
+
diff --git a/nx-X11/lib/Xfixes/xfixes.pc.in b/nx-X11/lib/Xfixes/xfixes.pc.in
new file mode 100644
index 000000000..6180ea371
--- /dev/null
+++ b/nx-X11/lib/Xfixes/xfixes.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Xfixes
+Description: X Fixes Library
+Version: @VERSION@
+Cflags: -I${includedir} @X_CFLAGS@
+Libs: -L${libdir} -lXfixes @X_LIBS@
diff --git a/nx-X11/lib/Xfontcache/FontCache.c b/nx-X11/lib/Xfontcache/FontCache.c
new file mode 100644
index 000000000..7561f6605
--- /dev/null
+++ b/nx-X11/lib/Xfontcache/FontCache.c
@@ -0,0 +1,209 @@
+/*-
+ * Copyright (c) 1998-1999 Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
+ * All rights reserved.
+ * Copyright (c) 1998-1999 X-TrueType Server Project, All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Id: FontCache.c,v 1.8 1999/01/31 12:52:49 akiyama Exp $
+ */
+/* $XFree86: FontCache.c,v 1.3 2002/10/16 00:37:28 dawes Exp $ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/fontcachstr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+static XExtensionInfo _fontcache_info_data;
+static XExtensionInfo *fontcache_info = &_fontcache_info_data;
+static char *fontcache_extension_name = FONTCACHENAME;
+
+#define FontCacheCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, fontcache_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *, XExtCodes *);
+
+static /* const */ XExtensionHooks fontcache_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, fontcache_info,
+ fontcache_extension_name,
+ &fontcache_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, fontcache_info)
+
+
+/*****************************************************************************
+ * *
+ * public Font-Misc Extension routines *
+ * *
+ *****************************************************************************/
+
+Bool
+FontCacheQueryExtension(Display *dpy, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+Bool
+FontCacheQueryVersion(Display *dpy, int *majorVersion, int *minorVersion)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xFontCacheQueryVersionReply rep;
+ xFontCacheQueryVersionReq *req;
+
+ FontCacheCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(FontCacheQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->fontcacheReqType = X_FontCacheQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+FontCacheGetCacheSettings(Display *dpy, FontCacheSettings *cacheinfo)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xFontCacheGetCacheSettingsReply rep;
+ xFontCacheGetCacheSettingsReq *req;
+
+ FontCacheCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(FontCacheGetCacheSettings, req);
+ req->reqType = info->codes->major_opcode;
+ req->fontcacheReqType = X_FontCacheGetCacheSettings;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ /* XXX */
+ cacheinfo->himark = rep.himark;
+ cacheinfo->lowmark = rep.lowmark;
+ cacheinfo->balance = rep.balance;
+ /* XXX */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+FontCacheChangeCacheSettings(Display *dpy, FontCacheSettings *cacheinfo)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xFontCacheChangeCacheSettingsReq *req;
+
+ FontCacheCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(FontCacheChangeCacheSettings, req);
+ req->reqType = info->codes->major_opcode;
+ req->fontcacheReqType = X_FontCacheChangeCacheSettings;
+ /* XXX */
+ req->himark = cacheinfo->himark;
+ req->lowmark = cacheinfo->lowmark;
+ req->balance = cacheinfo->balance;
+ /* XXX */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+FontCacheGetCacheStatistics(Display *dpy, FontCacheStatistics *cachestats)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xFontCacheGetCacheStatisticsReply rep;
+ xFontCacheGetCacheStatisticsReq *req;
+
+ FontCacheCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(FontCacheGetCacheStatistics, req);
+ req->reqType = info->codes->major_opcode;
+ req->fontcacheReqType = X_FontCacheGetCacheStatistics;
+ if (!_XReply(dpy, (xReply *)&rep,
+ (SIZEOF(xFontCacheGetCacheStatisticsReply)-SIZEOF(xReply))>>2,
+ xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ /* XXX */
+ cachestats->purge_runs = rep.purge_runs;
+ cachestats->purge_stat = rep.purge_stat;
+ cachestats->balance = rep.balance;
+ cachestats->f.hits = rep.f_hits;
+ cachestats->f.misshits = rep.f_misshits;
+ cachestats->f.purged = rep.f_purged;
+ cachestats->f.usage = rep.f_usage;
+ cachestats->v.hits = rep.v_hits;
+ cachestats->v.misshits = rep.v_misshits;
+ cachestats->v.purged = rep.v_purged;
+ cachestats->v.usage = rep.v_usage;
+ /* XXX */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
diff --git a/nx-X11/lib/Xfontcache/Imakefile b/nx-X11/lib/Xfontcache/Imakefile
new file mode 100644
index 000000000..dd0e57831
--- /dev/null
+++ b/nx-X11/lib/Xfontcache/Imakefile
@@ -0,0 +1,42 @@
+XCOMM Id: Imakefile,v 1.3 1999/01/31 12:54:33 akiyama Exp $
+
+
+
+XCOMM $XFree86: xc/lib/Xfontcache/Imakefile,v 1.5 2003/10/13 21:49:21 herrb Exp $
+
+#define DoNormalLib NormalLibXfontcache
+#define DoSharedLib SharedLibXfontcache
+#define DoExtraLib SharedLibXfontcache
+#define DoDebugLib DebugLibXfontcache
+#define DoProfileLib ProfileLibXfontcache
+#define LibName Xfontcache
+#define SoRev SOXFONTCACHEREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXfontcacheReqs
+ REQUIREDLIBS = SharedXfontcacheReqs
+#endif
+
+ FONTCACHESRCS = FontCache.c
+ FONTCACHEOBJS = FontCache.o
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ SRCS = $(FONTCACHESRCS)
+ OBJS = $(FONTCACHEOBJS)
+ LINTLIBS = $(LINTXLIB)
+
+#include <Library.tmpl>
+
+MANSUFFIX=$(LIBMANSUFFIX)
+InstallManPage(LibName,$(LIBMANDIR))
+#if ExpandManNames
+InstallManPageAliases(LibName,$(LIBMANDIR),FontCacheQueryExtension FontCacheQueryVersion FontCacheGetCacheSettings FontCacheChangeCacheSettings FontCacheGetCacheStatistics)
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/Xfontcache/Xfontcache-def.cpp b/nx-X11/lib/Xfontcache/Xfontcache-def.cpp
new file mode 100644
index 000000000..26b141aed
--- /dev/null
+++ b/nx-X11/lib/Xfontcache/Xfontcache-def.cpp
@@ -0,0 +1,9 @@
+LIBRARY Xfontcache
+VERSION LIBRARY_VERSION
+EXPORTS
+ FontCacheChangeCacheSettings
+ FontCacheGetCacheSettings
+ FontCacheGetCacheStatistics
+ FontCacheQueryExtension
+ FontCacheQueryVersion
+/* $XFree86$ */
diff --git a/nx-X11/lib/Xfontcache/Xfontcache.man b/nx-X11/lib/Xfontcache/Xfontcache.man
new file mode 100644
index 000000000..473a4e306
--- /dev/null
+++ b/nx-X11/lib/Xfontcache/Xfontcache.man
@@ -0,0 +1,137 @@
+.\"
+.\" $XFree86: xc/lib/Xfontcache/Xfontcache.man,v 1.1 2003/10/13 21:19:28 herrb Exp $
+.\"
+.\" Copyright (C) 2003 The XFree86 Project, Inc. All Rights Reserved.
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" 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 NON-INFRINGEMENT.
+.\" IN NO EVENT SHALL THE XFREE86 PROJECT 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 XFree86 Project
+.\" 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 XFree86 Project.
+.\"
+.TH Xfontcache __libmansuffix__ __vendorversion__
+.SH NAME
+Xfontcache \- X-TrueType font cache extension client library
+.SH SYNOPSIS
+.B #include <X11/extension/FontCache.h>
+.PP
+.nf
+.ta .5i 2i
+typedef struct {
+ long himark;
+ long lowmark;
+ long balance;
+} FontCacheSettings, *FontCacheSettingsPtr;
+
+struct cacheinfo {
+ long hits;
+ long misshits;
+ long purged;
+ long usage;
+};
+
+typedef struct {
+ long purge_runs;
+ long purge_stat;
+ long balance;
+ struct cacheinfo f;
+ struct cacheinfo v;
+} FontCacheStatistics, *FontCacheStatisticsPtr;
+.fi
+.HP
+Bool FontCacheQueryExtension(Display *\fIdpy\fP,
+int *\fIevent_basep\fP, int *\fIerror_basep\fP\^);
+.HP
+Status FontCacheQueryVersion(Display *\fIdpy\fP, int *\fImajor_versionp\fP,
+int *\fIminor_versionp\fP\^);
+.HP
+Status FontCacheGetCacheSettings(Display *\fIdpy\fP,
+FontCacheSettings *\fIcache info\fP);
+.HP
+Status FontCacheChangeCacheSettings(Display *\fIdpy\fP,
+FontCacheSettings *\fIcache info\fP);
+.HP
+Status FontCacheGetCacheStatistics(Display *\fIdpy\fP,
+FontCacheStatistics *\fIcache statistics info\fP);
+.PP
+.SH DESCRIPTION
+.B FontCache
+is an extension that is used by X-TrueType to cache informations about
+fonts.
+.\" XXXX This should be filled in
+.PP
+.B FontCacheQueryExtension
+returns
+.B True
+if the
+.I FontCache
+extension is available on the given display.
+A client must call
+.B FontCacheQueryExtension
+before calling any other Xfontcache function in order
+to negotiate a compatible protocol version; otherwise the client will
+get undefined behavior (Xfontcache may or may not work).
+.PP
+.B FontCacheQueryVersion
+returns
+.B True
+if the request succeeded; the values of the major and minor protocol
+versions supported by the server are returned in
+.I major_versionp
+and
+.I minor_versionp .
+.PP
+.B FontCacheGetCacheSettings
+should be documented here.
+Returns
+.B True
+on success or
+.B False
+on failure.
+.PP
+.B FontCacheChangeCacheSettings
+should be documented here.
+Returns
+.B True
+on success or
+.B False
+on failure.
+.PP
+.B FontCacheGetCacheStatistics
+should be documented here.
+Returns
+.B True
+on success or
+.B False
+on failure.
+.SH "ERRORS"
+.B FontCacheChangeCacheSettings
+will return
+.I BadValue
+if passed an illegal parameters for lowmark, himark or balance fields.
+.SH "SEE ALSO"
+X(__miscmansuffix__)
+.SH AUTHOR
+Akio Morita, X-TrueType team, Nozomi Ytow.
+.SH STABILITY
+This API is considered as experimental. The Xfontcache library major
+revision may be incremented whenever incompatible changes are done to
+the API without notice. Use with care.
diff --git a/nx-X11/lib/Xft/AUTHORS b/nx-X11/lib/Xft/AUTHORS
new file mode 100644
index 000000000..2fe754d23
--- /dev/null
+++ b/nx-X11/lib/Xft/AUTHORS
@@ -0,0 +1,10 @@
+Keith Packard, of SuSE and HP
+
+Automake work by Noah Levitt
+Frank Giessler - OS/2
+Jungshik Shin - UTF-16 api's
+Ralf Habacker, Suhaib Siddiqi - Cygwin port
+Marc La France - Sun port
+David Dawes - bug fixes, maintenance.
+
+Our apologies if we've overlooked someone.
diff --git a/nx-X11/lib/Xft/COPYING b/nx-X11/lib/Xft/COPYING
new file mode 100644
index 000000000..31a72eed3
--- /dev/null
+++ b/nx-X11/lib/Xft/COPYING
@@ -0,0 +1,22 @@
+$Id: COPYING,v 1.3 2005/06/24 22:43:20 alanc Exp $
+
+Copyright © 2001,2003 Keith Packard
+
+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 of Keith Packard not be used in
+advertising or publicity pertaining to distribution of the software without
+specific, written prior permission. Keith Packard makes no
+representations about the suitability of this software for any purpose. It
+is provided "as is" without express or implied warranty.
+
+KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL KEITH PACKARD 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.
+
diff --git a/nx-X11/lib/Xft/ChangeLog b/nx-X11/lib/Xft/ChangeLog
new file mode 100644
index 000000000..8e6f68250
--- /dev/null
+++ b/nx-X11/lib/Xft/ChangeLog
@@ -0,0 +1,1216 @@
+2005-05-17 Egbert Eich <eich-at-freedesktop-dot-org>
+ * Xft.h:
+ gcc4 allows to check if sentinels are correct (a sentinel is the
+ terminating element in a varargs list). A sentinel needs to be
+ NULL, not 0 - which doesn't make a difference on 32bit but
+ matters on 64bit.
+ Furthermore it can be told that functions have a printf-like
+ format string and argument list so that they can verify that
+ both match.
+ To use these features certain attributes need to be set - which
+ are compiler specific. To do this we define macros which are
+ expanded depending on the compiler version.
+ For now we put those in include/Xfuncproto.h (the XFree86 DDX
+ layer contains a file compiler.h which however is not visible
+ outside the DDX) (Bugzilla #3268).
+
+2005-05-01 Josh Triplett <josh@freedesktop.org>
+
+ * Makefile.am:
+ * configure.ac:
+ * xft-config.1.in:
+ Add Branden Robinson's xft-config manpage.
+
+2005-04-20 Branden Robinson <branden@deadbeast.net>
+
+ * Xft.3.in:
+ - Independently document each of the XftTextExtents* functions,
+ with particular attention to the units the "len" parameter is
+ measuring for each function. (Thanks to Matthew Allum for the
+ suggestion.)
+ - Tweak wording to not risk programmer inference that exposed
+ functions used internally are not for application usage.
+ - Don't escape hyphens when we don't really mean it (unescaped
+ hyphens are perfectly appropriate for hyphenated terms like
+ "mother-in-law" or "UTF-8".
+
+2005-04-20 Branden Robinson <branden@deadbeast.net>
+
+ * Xft.3.in:
+ - Flesh out with more details of constants, data types, and
+ functions used in the library. This continues to be a
+ work-in-progress.
+ - Move Xft 1.x compatibility interfaces to a new subsection of the
+ "COMPATBILITY" section.
+ - Add "HEADER FILE" section.
+ - Add "SEE ALSO" section.
+
+2005-04-02 Branden Robinson <branden@deadbeast.net>
+ * Xft.3.in:
+ Improve roff markup in many respects:
+ - Don't define a macro we don't use (TQ).
+ - Eliminate gratuitous blank lines.
+ - End sentences with newlines so that roff knows when to use
+ intersentence spacing.
+ - Consistently use boldface when referring to the Xft library name
+ and data types.
+ - Mark up function prototypes more legibly.
+ - Remove extraneous whitespace characters at ends of lines.
+ Make editorial changes to improve comprehensibility:
+ - Delcare manpage name in .TH macro using mixed case.
+ - Rename "DATATYPES" section to "DATA TYPES".
+ - Make various wording changes and clarifications.
+ - Consistently refer to the RENDER extension as the "X Rendering
+ Extension".
+
+2005-04-02 Branden Robinson <branden@deadbeast.net>
+
+ * Makefile.am:
+ Remove $(man_MANS) from EXTRA_DIST; the Xft.3 manpage is generated
+ by the ./configure script, so there is no need to ship it as part
+ of the distribution tarball.
+ Whitespace police.
+
+2005-03-29 Keith Packard <keithp@keithp.com>
+
+ * README:
+ * Xft.h:
+ * configure.ac:
+ Update for version 2.1.7
+
+2005-03-01 Keith Packard <keithp@keithp.com>
+
+ * xftdpy.c: (_XftDisplayInfoGet), (XftDefaultSubstitute):
+ Avoid calling any Render functions when Render is missing (#137)
+
+ * xftglyphs.c: (XftFontLoadGlyphs):
+ Only clip to bounding box when FC_CHARCELL is specified.
+ Only fix glyph spacing when FC_MONO is specified.
+
+2005-02-28 Keith Packard <keithp@keithp.com>
+
+ * configure.ac:
+ * xftdpy.c: (_XftDefaultInit), (XftDefaultSubstitute):
+ * xftfreetype.c: (XftFontInfoFill), (XftFontOpenInfo):
+ * xftglyphs.c: (XftFontLoadGlyphs):
+ * xftint.h:
+ Add support for artificial emboldening of glyphs through
+ the FT_GlyphSlot_Embolden API when it is available.
+
+ * xftextent.c: (XftGlyphExtents):
+ Optimize one glyph extents case (it happens a *lot*).
+ (Ross Burton)
+
+2004-11-28 James Henstridge <james@jamesh.id.au>
+
+ * xftfreetype.c (_XftReleaseFile): add parentheses in the
+ expression in the second argument to XftMemFree so that it is
+ interpreted correctly.
+
+2004-09-05 Keith Packard <keithp@keithp.com>
+
+ * configure.ac:
+ Move AC_CONFIG_AUX_DIR above AM_INIT_AUTOMAKE to make
+ automake 1.9 happy
+
+Fri Aug 13 19:47:12 2004 Soeren Sandmann <sandmann@redhat.com>
+
+ * xftint.h: Make HAVE_FT_BITMAP_SIZE_Y_PPEM conditional on the
+ FreeType version instead of proping it. This way it will work
+ with the monolithic version too. #1062, Patch by Owen Taylor.
+
+2004-08-03 Keith Packard <keithp@keithp.com>
+
+ * xftfreetype.c: (_XftReleaseFile):
+ Called strlen with (f->file) without checking for NULL (which
+ happens when directly using FT_Face objects).
+
+2004-04-14 Keith Packard <keithp@keithp.com>
+
+ * AUTHORS:
+ * Makefile.am:
+ * Xft-def.cpp:
+ * Xft.3.in:
+ * Xft.h:
+ * XftCompat.h:
+ * configure.ac:
+ * xftcolor.c:
+ * xftcore.c:
+ * xftdbg.c:
+ * xftdpy.c:
+ * xftdraw.c:
+ * xftextent.c:
+ * xftfont.c:
+ * xftfreetype.c: (XftFontOpenInfo):
+ * xftglyphs.c:
+ * xftinit.c:
+ * xftint.h:
+ * xftlist.c:
+ * xftname.c:
+ * xftrender.c:
+ * xftstr.c:
+ * xftswap.c:
+ * xftxlfd.c:
+ Regularize #include usage so that all includes
+ happen in xftint.h. This allows conditional inclusion
+ of system headers like string.h/strings.h
+
+ Add GCC warnings on GCC systems.
+
+ Fix CVS Id strings
+
+2004-03-22 Keith Packard <keithp@keithp.com>
+
+ * Makefile.am:
+ * Xft.h:
+ * configure.ac:
+ Bump version number to 2.1.6
+ Bump .so version to 2.1.2
+
+2004-03-19 Keith Packard <keithp@keithp.com>
+
+ * xftfreetype.c: (_XftSetFace):
+ Rework bitmap instance selection code to make it look prettier.
+ Also, try both y_ppem/x_ppem *and* width/height to see
+ which values will actually manage to load a font -- FreeType 2.1.7
+ has broken bdf/pcf loaders.
+
+2004-03-11 Keith Packard <keithp@keithp.com>
+
+ * Xft.h:
+ * configure.ac:
+ * xftfreetype.c: (_XftSetFace):
+ Oops. Left #warnings from testing in the release.
+ Bump to version 2.1.5 and respin the release...
+
+2004-03-10 Keith Packard <keithp@keithp.com>
+
+ * Xft.h:
+ * configure.ac:
+ Sigh. "someone" released a 2.1.3 without fixing
+ the version numbers. Update to 2.1.4.
+
+2004-03-10 Keith Packard <keithp@keithp.com>
+
+ * Xft.h:
+ Update version number to 2.1.3
+ Change #include syntax for recent FreeType
+
+ * configure.ac:
+ Update version number to 2.1.3
+ Depend on fontconfig 2.2 instead of 2.2.91
+ Add check for y_ppem field in FTBitmapSize structure
+
+ * xftdraw.c: (XftDrawRect):
+ Use PictOpSrc for painting rectangles with XftDrawRect
+
+ * xftdpy.c: (_XftDefaultInit), (XftDefaultSubstitute):
+ Use FC_HINT_STYLE only when available
+
+ * xftfreetype.c: (_XftSetFace), (XftFontInfoFill):
+ Search for closest bitmap size when font provides only bitmaps
+ Use FC_HINT_STYLE only when available
+
+2004-03-04 Jan van Dijk <jan@etpmod.phys.tue.nl>
+
+ * configure.ac: Updated version check for fontconfig: usage of the
+ FC_HINT_* macros in Xft requires version >= 2.2.91
+
+2004-02-03 Jim Gettys <jg@freedesktop.org>
+
+ * AUTHORS: Get a cut at an author's list.
+
+2004-01-17 Daniel Stone <daniel@fooishbar.org>
+ * Xft.h, configure.ac: Bump version to 2.1.3, to release for the
+ first freedesktop.org platform release.
+
+2004-01-15 Harold L Hunt II <huntharo@msu.edu>
+ * Makefile.am: Pass -no-undefined to libtool via LDFLAGS.
+
+2003-12-02 Noah Levitt <nlevitt@columbia.edu>
+
+ * configure.ac: Sometimes autoconf doesn't set $VERSION, so use
+ $PACKAGE_VERSION. (#156)
+
+2003-11-18 Noah Levitt <nlevitt@columbia.edu>
+
+ * .cvsignore: ignore *.loT
+
+ * Xft.h: Fix build with freetype 2.1.7. (bug #149, Eric
+ Christopherson)
+
+2003-09-23 Owen Taylor <otaylor@redhat.com>
+
+ Support FC_HINT_STYLE (#Bug 118)
+
+ * xftfreetype.c: Hook up FC_HINT_STYLE to FT_LOAD_TARGET_LIGHT;
+ also use FT_LOAD_TARGET_MONO when appropriate.
+
+ * xftdpy.c: Hook up FC_HINT_STYLE to the Xft default system.
+
+2003-09-05 07:76 keithp
+
+ * xftfreetype.c: use FT_LOAD_TARGET_LCD/FT_LOAD_TARGET_LCD_V
+ so that the autohinter will snap stems to pixel boundaries
+
+2003-05-05 22:37 keithp
+
+ * Xft.h, configure.ac: Bump version to 2.1.2
+
+2003-05-05 21:50 branden
+
+ * ChangeLog: cvs2cl
+
+2003-05-05 21:44 keithp
+
+ * configure.ac: Make sure -lXext is included for broken Xrender
+ packages
+
+2003-05-05 21:33 branden
+
+ * ChangeLog: Generate ChangeLog with cvs2cl.
+
+2003-05-02 14:42 keithp
+
+ * xftfreetype.c, xftrender.c: Must switch to non-ARGB format when
+ mixing ARGB and non-ARGB fonts
+
+2003-04-30 17:49 branden
+
+ * xft-config.in, xft.pc.in: Add -lX11 to the list of libraries one
+ needs to link against when using Xft. (Someday, perhaps XFree86
+ will support pkg-config...)
+
+2003-04-30 17:48 branden
+
+ * configure.ac: Add -lXext and -lX11 to XRENDER_LIBS, since the
+ Xrender library links against those.
+
+2003-04-30 17:13 keithp
+
+ * xftdraw.c, xftfreetype.c, xftglyphs.c: Avoid uninitialized
+ fields. Dont call malloc for zero bytes
+
+2003-04-30 09:48 keithp
+
+ * xftglyphs.c: Walking off the end of the hash table
+
+2003-04-27 22:20 keithp
+
+ * xftfreetype.c: Mark reduction in memory usage as fonts are
+ destroyed
+
+2003-04-25 09:11 keithp
+
+ * Xft.3.in: Fix typo in Xft man page (from Miloslav Trmac
+ <mitr@volny.cz>)
+
+2003-04-24 09:14 keithp
+
+ * xftfreetype.c: Allow glyphs to range up to num_glyphs to fix PCF
+ problems
+
+2003-04-21 10:28 nlevitt
+
+ * .cvsignore: No more question marks.
+
+2003-04-21 10:18 keithp
+
+ * Makefile.am: Remove bogus extra EXTRA_DIST
+
+2003-04-21 10:12 keithp
+
+ * ChangeLog, INSTALL, Makefile.am, README, Xft.3.in, Xft.man,
+ configure.ac: Fix manual page version and install (manx_MANS is
+ busted)
+
+2003-04-21 09:59 keithp
+
+ * Makefile.am, Xft.h, configure.ac, xft.pc.in: Remove extra version
+ number (PACKAGE_VERSION) from confgiure.ac. One (VERSION) seems
+ like plenty. Bump version to 2.1.1
+
+2003-04-19 20:32 nlevitt
+
+ * Makefile.am: Remove XftFreetype.h.
+
+2003-04-19 19:16 keithp
+
+ * Xft.man: Fix manual page example to use NULL where appropriate
+
+2003-04-19 19:07 keithp
+
+ * XftFreetype.h: Remove XftFreetype.h
+
+2003-04-17 16:37 nlevitt
+
+ * .cvsignore: Quiet, please.
+
+2003-04-17 16:34 nlevitt
+
+ * configure.ac: Check for Xrender with pkg-config first.
+
+2003-04-17 12:52 nlevitt
+
+ * Makefile.am, autogen.sh: Use libtool 1.5 and -version-info for
+ library versioning.
+
+2003-04-17 08:37 nlevitt
+
+ * Xft.man: Remove XftConfig from the man page.
+
+2003-04-17 08:06 nlevitt
+
+ * Imakefile, config/config-subst: Removed imake files.
+
+2003-04-17 08:00 nlevitt
+
+ * configure.ac: Require fontconfig >= 1.0.1.
+
+2003-04-16 23:05 nlevitt
+
+ * configure.ac: Not sure what version of fontconfig we actually
+ require, but it at least compiles ok with 1.0.1. Requiring >=
+ 1.0.0.
+
+2003-04-16 22:00 nlevitt
+
+ * configure.ac: Everything is in the package root.
+
+2003-04-16 21:57 nlevitt
+
+ * Makefile.am: Everything is in the package root.
+
+2003-04-16 21:56 nlevitt
+
+ * config/config-subst: Re-adding config-subst, probably shouldn't
+ have deleted it.
+
+2003-04-16 21:51 nlevitt
+
+ * Imakefile: Re-adding Imakefile, probably shouldn't have deleted
+ it.
+
+2003-04-16 21:29 nlevitt
+
+ * Xft.h, Xft.man, XftCompat.h, XftFreetype.h, xftcolor.c,
+ xftcore.c, xftdbg.c, xftdpy.c, xftdraw.c, xftextent.c, xftfont.c,
+ xftfreetype.c, xftglyphs.c, xftinit.c, xftint.h, xftlist.c,
+ xftname.c, xftrender.c, xftstr.c, xftswap.c, xftxlfd.c: Change
+ copyright symbol to UTF-8 and replace $ with $.
+
+2003-04-16 21:16 nlevitt
+
+ * Makefile.am: Include autogen.sh in the distribution.
+
+2003-04-16 21:15 nlevitt
+
+ * configure.ac: Fail in ./configure if required libraries are not
+ found.
+
+2003-04-16 20:19 nlevitt
+
+ * COPYING, Makefile.am, autogen.sh, configure.ac: Initial checking
+ of automake stuff.
+
+2003-04-16 20:12 nlevitt
+
+ * Imakefile, Makefile.in, config.h.in, configure.in: Removed old
+ autoconf stuff.
+
+2003-04-16 20:09 nlevitt
+
+ * Makefile.in, config.h.in, config/config-subst,
+ config/config.guess, config/config.sub, config/install.sh: Removed
+ stuff in config/.
+
+2003-04-16 19:41 nlevitt
+
+ * xftpat.c: Removing xftpat.c, since it isn't used anymore.
+
+2003-04-05 05:33 herrb
+
+ * Xft.man: fix man page name to make man -k a bit more useful
+
+2003-04-03 14:25 dawes
+
+ * xftdraw.c: 51. Fix segfaults that can happen when using
+ composition of RENDER and
+ non-RENDER fonts (#A.1656, Wu Jian Feng).
+
+2003-03-26 12:43 tsi
+
+ * xftfreetype.c: 28. Various build and warning fixes (#A.1703,
+ Peter Breitenlohner).
+ 27. Avoid overlapping strcpy() in imake.c (Dan Nelson).
+
+2003-03-24 20:18 dawes
+
+ * Imakefile, Xft-def.cpp: 26. Updates for building on OS/2
+ (#5650, Frank Giessler).
+
+2003-02-25 14:18 dawes
+
+ * Imakefile: Missing part of libXft minor rev bump (#5652, Mike
+ Harris).
+
+2003-02-25 13:57 dawes
+
+ * Xft.h: 954. Bump the libXft minor revision for the UTF-16 APIs
+ that were added
+ after rev 2.0 (#A.1643, A.1644, Keith Packard).
+
+2003-02-15 14:30 dawes
+
+ * xftcore.c: 903. Fix some bugs with Xft drawing to non-Render
+ enabled servers:
+ - Drawing monochrome glyphs had an infinite loop.
+ - XftGlyphSpecCore failed to render some glyphs, leading to
+ application
+ crashes from uninitialized values.
+ (#A.1608, Keith Packard, reported by Nalin Dahyabhai).
+
+2003-02-12 19:17 dawes
+
+ * xftcore.c: 882. Add missing zero-sized check to one of Xft's
+ core rendering routines
+ (#A.1599, Keith Packard).
+
+2002-12-13 17:59 dawes
+
+ * Xft.h, xftextent.c, xftrender.c: 632. Finish off the UTF-16 APIs
+ in Xft, and fix the UTF-16 conversion
+ code in fontconfig (#A.1411, Keith Packard, Jungshik Shin).
+
+2002-11-14 13:01 tsi
+
+ * Imakefile: First pass at imake warnings. + some ATI driver
+ formatting changes.
+
+ Please ensure these changes are reflected in DRI's CVS.
+
+2002-10-19 11:52 herrb
+
+ * Imakefile: Build fix for systems without gcc
+
+2002-10-16 14:07 keithp
+
+ * xftcore.c: Destroy images when drawing glyphs with the core
+ protocol
+
+2002-10-11 10:53 keithp
+
+ * Xft.h, xftcolor.c, xftcore.c, xftdpy.c, xftdraw.c, xftextent.c,
+ xftfont.c, xftfreetype.c, xftglyphs.c, xftinit.c, xftint.h,
+ xftrender.c: Add a bunch more consts to Xft and fontconfig apis
+
+2002-10-04 08:06 keithp
+
+ * Xft.man: Update Xft manual
+
+2002-10-02 00:10 keithp
+
+ * xftdpy.c: Remove unnecessary link between FC RGBA values and
+ Render subpixel order constants
+
+2002-10-02 00:02 keithp
+
+ * XftCompat.h, xftcore.c, xftdpy.c, xftfreetype.c: Make handling of
+ RGBA constants more consistent and less error prone
+
+2002-09-25 19:56 keithp
+
+ * xftdpy.c: Add image transformation and sub-pixel ordering to
+ Render
+
+2002-09-25 19:55 keithp
+
+ * xftfreetype.c: Wrong datatype caused a warning
+
+2002-09-25 17:31 keithp
+
+ * xftfreetype.c, xftglyphs.c: Fix file/face locking to make it more
+ sensible
+
+2002-09-17 18:25 dawes
+
+ * Xft-def.cpp: 325. Export some more Xft symbols (Cygwin) that are
+ needed for qt 3.x
+ (#5285, Ralf Habacker).
+ 324. Don't sleep on Cygwin for ICE directory mode problems (#5284,
+ Ralf Habacker).
+ 323. Fix a bug in XtGetDisplays() with more than 1 open display
+ (#5282,
+ Kip Rugger).
+ CVS
+ :------------------------------------------------------------------
+ ----
+
+2002-08-31 15:18 keithp
+
+ * Xft.h: Rename public to pub for c++
+
+2002-08-31 11:08 keithp
+
+ * Xft.h, xftdraw.c, xftrender.c, xftxlfd.c: Add XftDrawStringUtf16.
+ Fix GlyphFontSpecRender where it loads glyphs one at a time. Stop
+ writing to XLFD string
+
+2002-08-22 01:09 keithp
+
+ * Xft.h, xftdpy.c, xftdraw.c, xftint.h: Add rectangle clipping,
+ avoid Xlib whining on servers without Render
+
+2002-08-12 15:16 keithp
+
+ * xftdpy.c, xftdraw.c, xftfreetype.c, xftglyphs.c, xftint.h,
+ xftrender.c: Create per-dpy info only when needed, fix fencepost in
+ indexing array of glyphs
+
+2002-08-02 11:48 keithp
+
+ * xftdpy.c, xftfreetype.c, xftglyphs.c: _XftCloseDisplay was
+ corrupting global list. Compute charset at open time for fonts
+ without them. Dont crash in XftCharIndex when fonts have no
+ unicode mapping
+
+2002-07-05 18:24 keithp
+
+ * xftdraw.c, xftextent.c: XftDrawGlyphFontSpec and
+ XftTextExtentsUtf8 were both horribly broken
+
+2002-06-19 13:18 keithp
+
+ * xftdpy.c: Add FC_AUTOHINT and FC_HINTING to X resources
+
+2002-06-19 13:18 keithp
+
+ * xftint.h: remove a couple of duplicate function declarations
+
+2002-06-19 13:08 keithp
+
+ * xftfont.c: Add a bit of error reporting on font open failure
+
+2002-06-07 10:55 keithp
+
+ * configure.in: Make autoconf use correct options to build solaris
+ shared libraries
+
+2002-06-02 13:52 keithp
+
+ * xftfreetype.c, xftglyphs.c, xftint.h: Add aspect ratio support to
+ Xft and fontconfig
+
+2002-06-02 13:33 keithp
+
+ * xftfreetype.c, xftglyphs.c: Transform global font metrics with
+ font matrix
+
+2002-05-31 16:21 keithp
+
+ * xftfreetype.c, xftint.h: Add support for user-provided freetype
+ faces to Xft
+
+2002-05-31 00:01 keithp
+
+ * Makefile.in: Fix autoconf make install in Xft to remove link
+ targets before linking
+
+2002-05-30 23:52 keithp
+
+ * Imakefile: Fix Xft2 to build right library version on old systems
+ with xmkmf. Fix fc-cache location for xmkmf out-of-tree build on
+ old systems
+
+2002-05-30 21:45 keithp
+
+ * Imakefile, Xft.h, xftcore.c, xftdpy.c, xftfreetype.c,
+ xftglyphs.c, xftint.h: Interpose the XftFontInfo structure between
+ patterns and fonts. Fix image leak in core drawing code. Attempt
+ to deal with xmkmf and pre-fontconfig config files. Save closed
+ fonts for a while.
+
+2002-05-28 09:15 keithp
+
+ * xftrender.c: Fix obvious bug in XftTextRenderUtf8
+
+2002-05-28 09:11 keithp
+
+ * xftdraw.c: Fix obvious bugs in XftDrawStringUtf8
+
+2002-05-28 08:59 keithp
+
+ * xft-config.in: xft-config was returning -lxft instead of -lXft
+
+2002-05-25 06:52 herrb
+
+ * Imakefile: $< in a non-implicit rule is a GNU-makeism. It's not
+ supported by BSD make.
+
+2002-05-25 05:03 alanh
+
+ * Xft-def.cpp: #5283, Fix Xft-def.cpp for Cygwin/XFree86
+
+2002-05-24 00:02 keithp
+
+ * xftname.c: Add XftNameUnparse
+
+2002-05-23 23:26 keithp
+
+ * Makefile.in: Clean up autoconf install to obey DESTDIR
+
+2002-05-23 22:54 keithp
+
+ * Xft.h, XftCompat.h, xftdraw.c, xftint.h: Add XftSetSubwindowMode
+ and another c++ compatiblity cast
+
+2002-05-23 16:18 keithp
+
+ * Makefile.in: Few autoconf build fixes
+
+2002-05-23 16:01 keithp
+
+ * Imakefile, Makefile.in, Xft.h, config.h.in, configure.in,
+ xft-config.in, xft.pc.in, xftinit.c, config/config-subst,
+ config/config.guess, config/config.sub, config/install.sh: Add
+ autoconf build support to Xft
+
+2002-05-22 10:15 keithp
+
+ * xftdpy.c, xftglyphs.c: Add debugging to check memory stats, dont
+ attempt to rasterize glyphs twice
+
+2002-05-22 10:14 keithp
+
+ * XftCompat.h: Allow Xft1 c++ programs to compile without
+ signed/unsigned type error
+
+2002-05-13 12:06 keithp
+
+ * Xft.h, xftdraw.c: Expose useful XftDrawSrcPicture function
+
+2002-04-10 09:20 tsi
+
+ * xftfreetype.c: Warnings
+
+2002-03-04 13:15 tsi
+
+ * xftdpy.c: Warning fixes
+
+2002-02-20 21:30 keithp
+
+ * Xft.h: Fix Xft.h for use by C++ progs
+
+2002-02-19 16:54 keithp
+
+ * Imakefile: Switch Xft from referencing libxml2 to expat
+
+2002-02-18 23:56 keithp
+
+ * xftdraw.c, xftfreetype.c: check for region equality in
+ XftDrawSetClip
+
+2002-02-18 23:51 keithp
+
+ * Xft.h, XftCompat.h, xftcore.c, xftrender.c: Fix
+ CharSpec/GlyphSpec rendering
+
+2002-02-14 23:46 keithp
+
+ * XftConfig.cpp: Remove prototype Xft configuration file; its not
+ used anymore
+
+2002-02-14 23:37 keithp
+
+ * XftCompat.h, xftswap.c: Add a few missing files from the Xft 2
+ update
+
+2002-02-14 23:36 keithp
+
+ * Imakefile, Xft.h, XftConfig.cpp, XftFreetype.h, xftcache.c,
+ xftcfg.c, xftcore.c, xftdbg.c, xftdir.c, xftdpy.c, xftdraw.c,
+ xftextent.c, xftfont.c, xftfreetype.c, xftfs.c, xftglyphs.c,
+ xftgram.y, xftinit.c, xftint.h, xftlex.l, xftlist.c, xftmatch.c,
+ xftmatrix.c, xftname.c, xftpat.c, xftrender.c, xftstr.c, xftxlfd.c:
+ Update to Xft version 2
+
+2002-01-16 13:50 tsi
+
+ * xftcfg.c, xftint.h: Resync with 4.1.99.6
+
+2002-01-12 12:46 keithp
+
+ * xftcfg.c, xftint.h: Xft crashed doing multiple edits to same
+ field. Also made edit debug use XFT_DEBUG.
+
+2001-12-18 09:08 tsi
+
+ * xftdpy.c, xftfreetype.c, xftint.h: Another resync with HEAD
+ branch.
+
+2001-12-13 09:26 keithp
+
+ * xftdpy.c, xftfreetype.c, xftint.h: Make freetype cache
+ per-display
+
+2001-11-21 15:41 keithp
+
+ * XftConfig.cpp: Fix aliasing for Luxi font name change
+
+2001-11-21 13:31 dawes
+
+ * XftConfig.cpp: 499. Add new Luxi fonts from Bigelow & Holmes
+ (#5010, Charles Bigelow and
+ Kris Holmes, integrated by Juliusz Chroboczek).
+
+2001-11-17 00:22 keithp
+
+ * xftglyphs.c: Force outline load as Xft doesnt deal with bitmaps
+ yet
+
+2001-10-27 20:32 tsi
+
+ * xftfreetype.c: 407. Fix for threaded libraries (Marc La France).
+ 406. Finish removal of SuperProbe (Marc La France).
+ 405. A rather large number of warning fixes throughout (Marc La
+ France).
+ 404. Fix bug in HTML install script (Marc La France).
+ 403. Missing ident lines for some XFree86-modified files (Marc La
+ France).
+ 402. Add default half-width doublescanned modes (Marc La France).
+ 401. Mark all driver-registered resources with ResBus (Maarc La
+ France).
+ 400. Fix DPMS-related build problem (Marc La France).
+ 399. Log a message just before calling each ChipProbe() during
+ '-probe'
+ processing (Marc La France).
+ 398. Temporarily disable ISA probing on SPARCs and PowerPCs (Marc
+ La France).
+ 397. Add PCI IDs for Sun hardware (Marc La France).
+ 396. Fix memory leak in resource relocation (Marc La France).
+ 395. Do not relocate resources that only conflict with disabled
+ non-video PCI
+ devices or disabled PCI ROMs (Marc La France).
+ 394. Re-organise SBUS code (Marc La France).
+ 393. Add as-yet-unused definitions for PCI resource types other
+ than I/O and
+ memory (Marc La France).
+ 392. Add doc for Solaris, but don't format it yet (Marc La
+ France).
+ 391. Normalise driver names (Marc La France).
+ 390. For SPARCs, disable DGA support in ATI driver (Marc La
+ France).
+ 389. Clean up some debugging messages (Marc La France).
+ 388. Fix newport driver for when a /proc fs isn't mounted (Marc La
+ France).
+ 387. Fix DAC handling bugs in s3 driver (Marc La France).
+ 386. Fix resource registration bug for PCI Tseng's (Marc La
+ France).
+ 385. Add aperture driver for Solaris (not yet used) (Marc La
+ France).
+ 384. Rework scanpci to fix problems that prevented it from
+ completely
+ displaying non-PCI bridges and Simba bridges (Marc La
+ France).
+ 383. Fix build problems in some input drivers (Marc La France).
+ 382. Fix int10 compile problem for SPARCs and PowerPCs (Marc La
+ France).
+ 381. Ensure master aborts on secondary buses complete normally
+ during PCI
+ scans (Marc La France).
+ 380. Some memory mapping and Solaris cleanups (Marc La France).
+
+2001-09-29 10:47 herrb
+
+ * Imakefile: whitespace fix
+
+2001-09-21 12:54 keithp
+
+ * xftfreetype.c, xftmatch.c: Make XFT_ANTIALIAS much less important
+ in the match
+
+2001-07-13 11:16 keithp
+
+ * xftint.h, xftrender.c: Change unsigned int to XftChar32
+ everywhere else, fix RenderExtents{16,32,Utf8} to match
+ RenderExtents8
+
+2001-06-11 15:53 keithp
+
+ * xftcache.c: lib/Xft: handle truetype fontfiles with more than one
+ font -- .xftcache was getting busted
+
+2001-05-18 09:03 tsi
+
+ * xftint.h, xftlex.l: 543. Back out sunleo conversion to fb. This
+ driver is too heavily dependent
+ on cfb32 for a simple fb conversion (Marc La France).
+ 542. Miscellaneous build/warning fixes (Marc La France).
+ 541. More prep work for SunOS (Marc La France).
+ 540. Fix libXft build on SunOS (Marc La France).
+ 539. Another makedepend bug fix (Marc La France).
+ 538. Fix use of xftcache utility during !UseInstalled builds (Marc
+ La France).
+
+2001-05-16 12:20 keithp
+
+ * xftdraw.c: Use PictOpOver for XftDrawRect
+
+2001-05-16 10:20 keithp
+
+ * xftcolor.c: Allow apps to allocate non-opaque colors in
+ XftColorAllocValue, even though they wont work without Render
+
+2001-05-16 03:32 keithp
+
+ * xftdir.c, xftfreetype.c, xftglyphs.c, xftgram.y, xftlex.l: Clean
+ up memory leaks in Xft, remove mono spacing attribute from TT fonts
+
+2001-04-28 20:21 keithp
+
+ * Xft.h, xftdpy.c: Add Xft.dpi resource to override server provided
+ resolution value
+
+2001-04-27 07:55 tsi
+
+ * Imakefile, XftConfig.cpp: Build fix
+
+2001-04-21 09:58 keithp
+
+ * xftrender.c: Fix extents computation for FreeType fonts
+
+2001-04-19 09:07 dawes
+
+ * Imakefile: 402. Install the XftConfig file under $(CONFDIR),
+ with a link from the
+ usual place (based on #4569, Branden Robinson).
+ 401. Update the Debian section on linux.cf (#4568, Branden
+ Robinson).
+
+2001-04-05 12:29 dawes
+
+ * Xft-def.cpp: 341. Add a driver for VMware virtual SVGA devices.
+ This is for use
+ by X servers running under a VMware guest OS (#4529, VMware,
+ Inc).
+ 340. Remove Cygwin-specific #ifdef in Xserver/os/Waitfor.c, which
+ fixes
+ a crash (#4528, Suhaib Siddiqi).
+ 339. Cygwin build fixes (#4527, Suhaib Siddiqi).
+ - fix some doc typos
+
+2001-04-01 07:00 tsi
+
+ * xftdraw.c, xftextent.c, xftfreetype.c, xftglyphs.c, xftstr.c:
+ 317. glxinfo needs libGLU (Marc La France).
+ 316. Rage128 fix to Cards database (Marc La France).
+ 315. Minor fix to PCI resource overlap handling (Marc La France).
+ 314. Loader code simplification and IA-64 cache flushes (Marc La
+ France).
+ 313. Workaround in the ATI driver for troublesome interaction
+ between loader
+ and compiler optimisation (Marc La France).
+ 312. Warning fixes for `gcc -fno-builtin`, which appears to be the
+ default on
+ some systems (Marc La France).
+
+ + more of #301, tags, warnings and build fixes.
+
+2001-03-31 15:07 keithp
+
+ * XftFreetype.h: Reorder struct elements in exposed datatype to
+ provide backward compatibility
+
+2001-03-30 17:57 keithp
+
+ * xftcfg.c, xftdbg.c, xftglyphs.c, xftgram.y, xftint.h, xftlex.l: +
+ Add matrix support to XftConfig files + Change SwitchYYPrefix to
+ edit __REALLY_YY__ back to yy + Add change log entry for glyph
+ transformations in Xft
+
+2001-03-30 10:50 keithp
+
+ * Imakefile, Xft.h, XftFreetype.h, xftdbg.c, xftdraw.c,
+ xftfreetype.c, xftglyphs.c, xftint.h, xftmatrix.c, xftname.c,
+ xftpat.c: Add matrix transformations to Freetype fonts
+
+2001-03-29 18:15 keithp
+
+ * XftFreetype.h, xftint.h: Add Xmuu library to remove requirement
+ for Xt/Xaw from most X utilities Add i810 and Xv support to kdrive
+
+2001-03-18 06:50 dawes
+
+ * Imakefile: rework the Freetype2 switches
+
+2001-03-12 08:03 keithp
+
+ * Imakefile: Add freetype2 to 4.0.2 branch
+
+2001-03-10 03:43 keithp
+
+ * xftstr.c: Guard against broken fonts with missing fields
+
+2001-03-06 10:00 keithp
+
+ * xftmatch.c: xft: make font spacing less important than font
+ family
+
+2001-02-13 11:19 dawes
+
+ * Xft-def.cpp: 135. Updates for Cygwin support (#4433, Suhaib M.
+ Siddiqi).
+ 134. Fix a bug in the fonts.sgml doc (#4432, Juliusz Chroboczek).
+ 133. Fix the xdpyinfo so that it will build when the XKB extension
+ isn't
+ defined (#4422, Jim Gettys).
+ 132. Fix the xdm greeter so that it will build when the XKB
+ extension isn't
+ defined (#4421, Jim Gettys).
+ 131. Only build setxkbmap when building the XKB lib support (based
+ on #4420,
+ Jim Gettys).
+ 130. Improve the mga driver messages when the HAL module isn't
+ available
+ (#4451, David Woodhouse).
+ 129. Add G450 support to the mga driver (#4416, Luugi Marsan
+ (Matrox),
+ 4449, David Woodhouse).
+ 128. Mga driver updates, including HAL cleanups, add a Crtc2Ram
+ option,
+ and merge with Matrox beta4 source (#4415, Antii Tapaninen,
+ #4423,
+ Simon Hosie).
+ 127. Fix a rounding problem in the wacom driver that was causing
+ some
+ position instability (#4417, Hannes Eriksson).
+
+2001-02-08 16:35 keithp
+
+ * Imakefile: Fix Freetype2 compilation, document changed Freetype
+ status
+
+2001-01-26 12:51 keithp
+
+ * Xft.h, xftdpy.c, xftfreetype.c, xftglyphs.c, xftint.h,
+ xftmatch.c, xftname.c: Add a bit more debug to Xft along with
+ vertical sub-pixel decimation
+
+2001-01-01 18:46 keithp
+
+ * Imakefile, Xft.h, XftFreetype.h, xftcache.c, xftcfg.c, xftdir.c,
+ xftfreetype.c, xftgram.y, xftint.h, xftlex.l, xftname.c: Add
+ FreeType font file info caching
+
+2000-12-21 21:05 tsi
+
+ * XftFreetype.h, xftfreetype.c, xftint.h, xftname.c, xftxlfd.c:
+ Build fixes
+
+2000-12-21 18:25 keithp
+
+ * XftFreetype.h, xftfreetype.c, xftglyphs.c, xftint.h: Move
+ XftFreeTypeSetFace to XftFreetype.h
+
+2000-12-20 02:24 keithp
+
+ * xftstr.c: Xft: fix utf8->ucs4 conversion
+
+2000-12-19 16:28 keithp
+
+ * Xft.h, XftFreetype.h, xftcore.c, xftdraw.c, xftextent.c,
+ xftint.h, xftrender.c, xftstr.c: Add UTF-8 support to Xft
+
+2000-12-19 16:20 keithp
+
+ * Xft.h, XftFreetype.h, xftdpy.c, xftdraw.c, xftfont.c,
+ xftfreetype.c, xftglyphs.c, xftint.h, xftname.c, xftxlfd.c: Xft:
+ Add font/face sharing. Improve debug. Add minspace for Dirk and
+ Linus.
+
+2000-12-17 01:11 keithp
+
+ * xftcfg.c: Xft: correct order of config file tests
+
+2000-12-17 00:30 keithp
+
+ * xftdpy.c: Xft: unintialized variable
+
+2000-12-15 14:48 dawes
+
+ * xftlex.l: 1204. Fix an Xlib memory overrun when the
+ Xutf8TextPropertyToTextList function is used in a unibyte
+ locale (#4394, Bruno Haible). 1203. Fix the yen/backslash keys for
+ Solaris 8/x86 with Japanese 106 keyboards (based on #4393,
+ Takaaki Nomura). 1202. Fix type mismatches in the r128 DRI driver
+ on Alpha platforms (#4392, Gareth Hughes). 1201. Fix build
+ on Japanized version of Solaris 8 for x86 (#4390, Takaaki
+ Nomura). 1200. Remove some old XtOffset magic for the arm that
+ affects building with gcc (#4388, Keith Packard).
+
+2000-12-15 09:12 keithp
+
+ * Imakefile, XftFreetype.h, xftcfg.c, xftdraw.c, xftextent.c,
+ xftfont.c, xftfreetype.c, xftglyphs.c, xftinit.c, xftint.h: Xft:
+ Change build w/o FREETYPE2 to not include any FreeType2 related
+ functions, fix XftFreetype.h to be usable by apps
+
+2000-12-14 15:03 keithp
+
+ * XftConfig.cpp, xftcfg.c, xftdpy.c, xftfont.c, xftfreetype.c,
+ xftint.h, xftmatch.c, xftname.c, xftpat.c, xftstr.c, xftxlfd.c:
+ Xft: Fix string compares and default config
+
+2000-12-11 16:45 keithp
+
+ * xftdraw.c, xftfont.c, xftint.h, xftmatch.c, xftxlfd.c: Fix pixel
+ values for core font rendering in Xft, add environment-selectable
+ debugging
+
+2000-12-11 13:48 keithp
+
+ * xftglyphs.c: Xft: TT fonts may not contain all glyphs in encoding
+
+2000-12-07 23:51 keithp
+
+ * Xft.h, XftFreetype.h, xftcore.c, xftdraw.c, xftextent.c,
+ xftfont.c, xftglyphs.c, xftint.h, xftpat.c, xftrender.c: Xft: be
+ liberal in what you accept... Also, metrics for missing glyphs are
+ all zeros now. Also added typedefs for 8,16,32 bit char datatypes
+
+2000-12-07 15:57 keithp
+
+ * xftint.h, xftlist.c, xftpat.c: Dont pass address of va_list
+ around anymore (ppc portability)
+
+2000-12-06 10:03 keithp
+
+ * Xft.h, xftdraw.c, xftint.h: Xft: add bitmap drawable support
+
+2000-12-05 10:26 keithp
+
+ * xftdpy.c: Xft: add X resource to disable anti-aliasing
+
+2000-12-04 23:42 keithp
+
+ * xftdraw.c: Xft,Xrender: make clip rectangles actually work
+
+2000-12-04 19:13 keithp
+
+ * Xft.h, XftFreetype.h, xftdraw.c, xftint.h, xftrender.c:
+ Xft,Xrender,Render: c++ support, clip rectangles, warnings
+
+2000-12-03 11:05 keithp
+
+ * xftcfg.c: Xft: (oops) left some debug output enabled
+
+2000-12-03 11:03 keithp
+
+ * Xft.h, xftcfg.c, xftfreetype.c, xftglyphs.c: Xft: allow apps to
+ specify char spacing for FreeType fonts Fix append/prepend editing
+ steps to make them relative to the match
+
+2000-12-02 16:45 keithp
+
+ * xftname.c: Xft: allow style names like "bold" to be used without
+ prefix in font names
+
+2000-12-02 02:02 keithp
+
+ * Xft.h, XftFreetype.h, xftcore.c, xftfont.c, xftfreetype.c,
+ xftglyphs.c, xftint.h, xftname.c, xftxlfd.c: Xft: fix name parsing,
+ add unencoded glyph access for FreeType fonts
+
+2000-12-01 13:32 keithp
+
+ * Xft.h, XftFreetype.h, xftcore.c, xftdraw.c, xftextent.c,
+ xftint.h, xftrender.c: Xrender/Xft: handle long strings, use
+ unsigned int for 32-bit glyphs
+
+2000-11-30 19:27 keithp
+
+ * Imakefile, Xft.h, xftcolor.c, xftdraw.c, xftfont.c, xftint.h,
+ xftxlfd.c: Xft: add new XftColor datatype, update xterm and x11perf
+
+2000-11-30 16:41 keithp
+
+ * xftname.c: Xft: workaround for wedging when given invalid font
+ name (like XLFD)
+
+2000-11-30 15:30 dawes
+
+ * xftgram.y, xftint.h, xftlex.l: Fix libXft build problems on
+ systems that don't have flex (like Solaris). 1031. Add PAM
+ authentication to the X server (based on Red Hat's
+ XFree86-4.0-Xwrapper patch). 1030. Add Slovenian and Romanian
+ entries to XKB's keymap/xfree86 file (Red Hat's
+ XFree86-4.0-si_xkb patch and XFree86-4.0-ro_xkb.patch). 1029. Fix
+ for PAM support in xdm SessionExit() (Red Hat's
+ XFree86-4.0-pamsession patch). 1028. XlibInt.c patch to avoid
+ buffer overflow (Red Hat's XFree86-3.3.6-fixemacs patch).
+ 1027. Updates to xfs from Red Hat and Debian, including: -
+ command line options to make xfs drop it's root privs (-droppriv
+ and -user) - command line options to make xfs start as
+ a daemon, and a build option to make this the default.
+ - don't let a port option in the config file override the -port
+ command line option - cleanup/fix syslogging
+ (based on #4253, Debian, and Red Hat's XFree86-4.0-xfsredhat
+ patch). 1026. Support for startx to set up the Xauth when starting
+ an X server (based on Red Hat's XFree86-4.0-startx_xauth
+ patch).
+
+2000-11-30 10:58 keithp
+
+ * Imakefile: Use sed to whack lex/yacc names in Xft
+
+2000-11-30 02:42 keithp
+
+ * Xft.h, xftdraw.c: Xft: Add XftDrawChange
+
+2000-11-29 22:59 keithp
+
+ * Imakefile, Xft.h, Xft.man, XftFreetype.h, xftcfg.c, xftint.h,
+ xftlist.c, xftpat.c: Xft: add font listing functions, update man
+ page and clean up headers
+
+2000-11-29 09:40 dawes
+
+ * xftrender.c: missing ident lines
+
+2000-11-29 00:39 keithp
+
+ * Imakefile, Xft.h, XftConfig.cpp, XftFreetype.h, drawstr.c,
+ extents.c, glyphs.c, lex.c, load.c, match.c, metrics.c, parse.c,
+ xftcfg.c, xftcore.c, xftdbg.c, xftdir.c, xftdpy.c, xftdraw.c,
+ xftextent.c, xftfont.c, xftfreetype.c, xftfs.c, xftglyphs.c,
+ xftgram.y, xftinit.c, xftint.h, xftlex.l, xftmatch.c, xftname.c,
+ xftpat.c, xftrender.c, xftstr.c, xftxlfd.c: Rewrite Xft library,
+ update xterm to match
+
+2000-10-13 06:41 keithp
+
+ * Imakefile, Xft.h, drawstr.c, glyphs.c, load.c, xftint.h: Update
+ for current Freetype2 CVS
+
+2000-10-10 07:05 tsi
+
+ * XftConfig.cpp: Static build fix and ident lines.
+
+2000-10-06 22:54 keithp
+
+ * load.c: Xft: Fix up horizontal advance computation
+
+2000-10-05 17:01 keithp
+
+ * Imakefile, XftConfig.cpp: Fix XftConfig file generation
+
+2000-10-05 15:57 keithp
+
+ * Xft.h, drawstr.c, parse.c: Add debugging to Xft config parsing
+
+2000-10-05 11:05 keithp
+
+ * Imakefile, Xft.h, Xft.man, XftConfig.cpp, drawstr.c, extents.c,
+ glyphs.c, lex.c, load.c, match.c, metrics.c, parse.c, xftint.h: Add
+ new Xft library to convert FreeType 2 fonts into Render glyphsets
+
diff --git a/nx-X11/lib/Xft/INSTALL b/nx-X11/lib/Xft/INSTALL
new file mode 100644
index 000000000..85a675941
--- /dev/null
+++ b/nx-X11/lib/Xft/INSTALL
@@ -0,0 +1,8 @@
+Xft is built with the traditional configure script:
+
+ $ ./configure --prefix=/usr/X11R6
+
+This should generate valid Makefiles, then:
+
+ $ make
+ $ make install
diff --git a/nx-X11/lib/Xft/Imakefile b/nx-X11/lib/Xft/Imakefile
new file mode 100644
index 000000000..4b827be5c
--- /dev/null
+++ b/nx-X11/lib/Xft/Imakefile
@@ -0,0 +1,145 @@
+XCOMM $XFree86: xc/lib/Xft/Imakefile,v 1.28 2003/11/17 15:18:04 tsi Exp $
+XCOMM $XdotOrg: xc/lib/Xft/Imakefile,v 1.5 2005/10/19 02:46:56 kem Exp $
+
+#define DoNormalLib NormalLibXft
+#define DoSharedLib SharedLibXft
+#define DoExtraLib SharedLibXft
+#define DoDebugLib DebugLibXft
+#define DoProfileLib ProfileLibXft
+
+#define HasSharedData YES
+#define LibName Xft
+#define SoRev SOXFTREV
+#define IncSubdir X11
+#define IncSubSubdir Xft
+
+#include <Threads.tmpl>
+
+#ifndef XftLibDir
+#define XftLibDir $(LIBDIR)
+#endif
+
+#ifndef XftType1Dir
+#define XftType1Dir $(LIBDIR)/fonts/Type1
+#endif
+
+#ifdef UseInstalled
+/* when using xmkmf, make sure the needed definitions for the fontconfig
+ * library are available
+ */
+
+#ifndef SharedFontconfigRev
+#define SharedFontconfigRev 1.0.4
+SharedLibReferences(FONTCONFIG,fontconfig,$(FONTCONFIGLIBSRC),SOFONTCONFIGREV,SharedFontconfigRev)
+#endif
+
+/* make sure we're building the right major version */
+SOXFTREV=2.1
+
+#endif
+
+XFTLIBDIR=XftLibDir
+
+TYPE1DIR=XftType1Dir
+#if HasGcc2 || HasGcc3
+WARNINGS=-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs
+#endif
+INCLUDES=$(FONTCONFIGINCLUDES) $(FREETYPE2INCLUDES) -I$(XBUILDINCDIR) $(WARNINGS)
+DEFINES=$(FREETYPE2DEFINES) $(RENDERDEFINES) -DXFREE86_FT2
+
+XFT_REVISION=8
+XFT_VERSION=2.1.$(XFT_REVISION)
+
+FREETYPE_LIBS=$(FREETYPE2LIB)
+FREETYPE_CFLAGS=$(FREETYPE2INCLUDES)
+XRENDER_LIBS=$(XRENDERLIB)
+XRENDER_CFLAGS=$(XRENDERINCLUDES)
+FONTCONFIG_CFLAGS=$(FONTCONFIGINCLUDES)
+FONTCONFIG_LIBS=$(FONTCONFIGLIB)
+
+#if !defined(UseInstalled)
+
+/* these must always be computed using the installed location,
+ * when building inside the tree that means extra work
+ */
+#if BuildFontconfigLibrary
+FONTCONFIG_LIBS=-L$(USRLIBDIR) -lfontconfig
+FONTCONFIG_CFLAGS=-I$(INCROOT)
+#endif
+
+#if BuildFreetype2Library
+FREETYPE_LIBS=-L$(USRLIBDIR) -lfreetype
+FREETYPE_CFLAGS=-I$(INCROOT)/freetype2
+#endif
+
+#if BuildRenderLibrary
+XRENDER_LIBS=-L$(USRLIBDIR) -lXrender
+XRENDER_CFLAGS=-I$(INCROOT)
+#endif
+
+#endif
+
+RPATH_CFLAG = HardCodeLibdirFlag
+
+SUBSTVARS=prefix="$(PROJECTROOT)" \
+ exec_prefix="$(BINDIR)" \
+ libdir="$(USRLIBDIR)" \
+ hardcode_libdir_flag_spec="$(RPATH_CFLAG)" \
+ includedir="$(INCROOT)" \
+ VERSION="$(XFT_VERSION)" \
+ FREETYPE_LIBS="$(FREETYPE_LIBS)" \
+ FREETYPE_CFLAGS="$(FREETYPE_CFLAGS)" \
+ XRENDER_LIBS="$(XRENDER_LIBS)" \
+ XRENDER_CFLAGS="$(XRENDER_CFLAGS)" \
+ FONTCONFIG_CFLAGS="$(FONTCONFIG_CFLAGS)" \
+ FONTCONFIG_LIBS="$(FONTCONFIG_LIBS)"
+
+REQUIREDLIBS=$(LDPRELIBS) $(XRENDERLIB) $(XLIB) $(FONTCONFIGLIB) $(EXPATLIB) $(FREETYPE2LIB)
+
+HEADERS = Xft.h XftCompat.h
+
+ SRCS = xftcolor.c xftdbg.c xftdpy.c \
+ xftdraw.c xftextent.c xftfont.c \
+ xftinit.c xftlist.c \
+ xftname.c xftstr.c xftswap.c xftxlfd.c \
+ xftfreetype.c xftglyphs.c xftrender.c xftcore.c
+
+ OBJS = xftcolor.o xftdbg.o xftdpy.o \
+ xftdraw.o xftextent.o xftfont.o \
+ xftinit.o xftlist.o \
+ xftname.o xftstr.o xftswap.o xftxlfd.o \
+ xftfreetype.o xftglyphs.o xftrender.o xftcore.o
+
+#include <Library.tmpl>
+
+#if DoSharedLib && SharedDataSeparation
+SpecialCObjectRule(sharedlib,NullParameter,$(SHLIBDEF))
+#endif
+
+#define ConfigSubst(file, old_suffix, new_suffix) @@\
+ @@\
+all:: Concat(file,new_suffix) @@\
+ @@\
+Concat(file,new_suffix): Concat(file,old_suffix) @@\
+ RemoveFile($@) @@\
+ sh config/config-subst $(SUBSTVARS) < Concat(file,old_suffix) > $@ @@\
+ @@\
+clean:: @@\
+ RemoveFile(Concat(file,new_suffix))
+
+XCOMM Create xft-config.script from xft-config.in
+ConfigSubst(xft-config,.in,.script)
+InstallScript(xft-config,$(BINDIR))
+
+XCOMM Create xft.pc from xft.pc.in
+ConfigSubst(xft.pc,.in,/*none*/)
+InstallNonExecFile(xft.pc,$(USRLIBDIR)/pkgconfig)
+
+XCOMM Create man pages from .*.in files
+ConfigSubst(xft-config,.1.in,.man)
+ConfigSubst(Xft,.3.in,.man)
+
+InstallGenManPage(xft-config,$(MANDIR),$(MANSUFFIX))
+InstallGenManPage(Xft,$(LIBMANDIR),$(LIBMANSUFFIX))
+
+DependTarget()
diff --git a/nx-X11/lib/Xft/Makefile.am b/nx-X11/lib/Xft/Makefile.am
new file mode 100644
index 000000000..38ca35360
--- /dev/null
+++ b/nx-X11/lib/Xft/Makefile.am
@@ -0,0 +1,64 @@
+#
+# $Id: Makefile.am,v 1.3 2005/06/24 22:43:20 alanc Exp $
+#
+# Copyright © 2003 Keith Packard, Noah Levitt
+#
+# 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 of Keith Packard not be used in
+# advertising or publicity pertaining to distribution of the software without
+# specific, written prior permission. Keith Packard makes no
+# representations about the suitability of this software for any purpose. It
+# is provided "as is" without express or implied warranty.
+#
+# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+# EVENT SHALL KEITH PACKARD 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.
+
+bin_SCRIPTS = xft-config
+
+man_MANS = Xft.3 xft-config.1
+
+AM_CFLAGS = $(FONTCONFIG_CFLAGS) $(FREETYPE_CFLAGS) $(XRENDER_CFLAGS) \
+ $(WARN_CFLAGS)
+
+lib_LTLIBRARIES = libXft.la
+
+libXft_la_SOURCES = Xft.h \
+ XftCompat.h \
+ xftint.h \
+ xftcolor.c \
+ xftcore.c \
+ xftdbg.c \
+ xftdpy.c \
+ xftdraw.c \
+ xftextent.c \
+ xftfont.c \
+ xftfreetype.c \
+ xftglyphs.c \
+ xftinit.c \
+ xftlist.c \
+ xftname.c \
+ xftrender.c \
+ xftstr.c \
+ xftswap.c \
+ xftxlfd.c
+
+libXft_la_LIBADD = @FONTCONFIG_LIBS@ @FREETYPE_LIBS@ @XRENDER_LIBS@
+
+# -version-number requires libtool >= 1.5
+libXft_la_LDFLAGS = -version-number 2:1:2 -no-undefined
+
+libXftincludedir = $(includedir)/X11/Xft
+libXftinclude_HEADERS = Xft.h XftCompat.h
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = xft.pc
+
+EXTRA_DIST = xft-config.in xft-config.1.in xft.pc.in Xft.3.in autogen.sh
diff --git a/nx-X11/lib/Xft/Makefile.in b/nx-X11/lib/Xft/Makefile.in
new file mode 100644
index 000000000..0827f7769
--- /dev/null
+++ b/nx-X11/lib/Xft/Makefile.in
@@ -0,0 +1,780 @@
+# Makefile.in generated by automake 1.7.9 from Makefile.am.
+# @configure_input@
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+#
+# $Id: Makefile.in,v 1.2 2004/04/23 18:43:41 eich Exp $
+#
+# Copyright © 2003 Keith Packard, Noah Levitt
+#
+# 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 of Keith Packard not be used in
+# advertising or publicity pertaining to distribution of the software without
+# specific, written prior permission. Keith Packard makes no
+# representations about the suitability of this software for any purpose. It
+# is provided "as is" without express or implied warranty.
+#
+# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+# EVENT SHALL KEITH PACKARD 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.
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = .
+
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_triplet = @host@
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
+MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XRENDER_CFLAGS = @XRENDER_CFLAGS@
+XRENDER_LIBS = @XRENDER_LIBS@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+
+bin_SCRIPTS = xft-config
+
+man_MANS = Xft.3
+
+AM_CFLAGS = $(FONTCONFIG_CFLAGS) $(FREETYPE_CFLAGS) $(XRENDER_CFLAGS)
+
+lib_LTLIBRARIES = libXft.la
+
+libXft_la_SOURCES = Xft.h \
+ XftCompat.h \
+ xftint.h \
+ xftcolor.c \
+ xftcore.c \
+ xftdbg.c \
+ xftdpy.c \
+ xftdraw.c \
+ xftextent.c \
+ xftfont.c \
+ xftfreetype.c \
+ xftglyphs.c \
+ xftinit.c \
+ xftlist.c \
+ xftname.c \
+ xftrender.c \
+ xftstr.c \
+ xftswap.c \
+ xftxlfd.c
+
+
+libXft_la_LIBADD = @FONTCONFIG_LIBS@ @FREETYPE_LIBS@ @XRENDER_LIBS@
+
+# -version-number requires libtool >= 1.5
+libXft_la_LDFLAGS = -version-number 2:1:1 -no-undefined
+
+libXftincludedir = $(includedir)/X11/Xft
+libXftinclude_HEADERS = Xft.h XftCompat.h
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = xft.pc
+
+EXTRA_DIST = xft-config.in xft.pc.in Xft.3.in $(man_MANS) autogen.sh
+subdir = .
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES = xft.pc xft-config Xft.3
+LTLIBRARIES = $(lib_LTLIBRARIES)
+
+libXft_la_DEPENDENCIES =
+am_libXft_la_OBJECTS = xftcolor.lo xftcore.lo xftdbg.lo xftdpy.lo \
+ xftdraw.lo xftextent.lo xftfont.lo xftfreetype.lo xftglyphs.lo \
+ xftinit.lo xftlist.lo xftname.lo xftrender.lo xftstr.lo \
+ xftswap.lo xftxlfd.lo
+libXft_la_OBJECTS = $(am_libXft_la_OBJECTS)
+SCRIPTS = $(bin_SCRIPTS)
+
+
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/xftcolor.Plo ./$(DEPDIR)/xftcore.Plo \
+@AMDEP_TRUE@ ./$(DEPDIR)/xftdbg.Plo ./$(DEPDIR)/xftdpy.Plo \
+@AMDEP_TRUE@ ./$(DEPDIR)/xftdraw.Plo ./$(DEPDIR)/xftextent.Plo \
+@AMDEP_TRUE@ ./$(DEPDIR)/xftfont.Plo ./$(DEPDIR)/xftfreetype.Plo \
+@AMDEP_TRUE@ ./$(DEPDIR)/xftglyphs.Plo ./$(DEPDIR)/xftinit.Plo \
+@AMDEP_TRUE@ ./$(DEPDIR)/xftlist.Plo ./$(DEPDIR)/xftname.Plo \
+@AMDEP_TRUE@ ./$(DEPDIR)/xftrender.Plo ./$(DEPDIR)/xftstr.Plo \
+@AMDEP_TRUE@ ./$(DEPDIR)/xftswap.Plo ./$(DEPDIR)/xftxlfd.Plo
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(libXft_la_SOURCES)
+
+NROFF = nroff
+MANS = $(man_MANS)
+DATA = $(pkgconfig_DATA)
+
+HEADERS = $(libXftinclude_HEADERS)
+
+DIST_COMMON = README $(libXftinclude_HEADERS) $(srcdir)/Makefile.in \
+ $(srcdir)/configure AUTHORS COPYING ChangeLog INSTALL \
+ Makefile.am NEWS Xft.3.in aclocal.m4 config.guess config.h.in \
+ config.sub configure configure.ac depcomp install-sh ltmain.sh \
+ missing mkinstalldirs xft-config.in xft.pc.in
+SOURCES = $(libXft_la_SOURCES)
+
+all: config.h
+ $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu Makefile
+Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)
+
+$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ $(SHELL) ./config.status --recheck
+$(srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(srcdir)/configure.ac $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
+ cd $(srcdir) && $(AUTOCONF)
+
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.ac
+ cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+
+config.h: stamp-h1
+ @if test ! -f $@; then \
+ rm -f stamp-h1; \
+ $(MAKE) stamp-h1; \
+ else :; fi
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+ @rm -f stamp-h1
+ cd $(top_builddir) && $(SHELL) ./config.status config.h
+
+$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(top_srcdir)/configure.ac $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOHEADER)
+ touch $(srcdir)/config.h.in
+
+distclean-hdr:
+ -rm -f config.h stamp-h1
+xft.pc: $(top_builddir)/config.status xft.pc.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+xft-config: $(top_builddir)/config.status xft-config.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+Xft.3: $(top_builddir)/config.status Xft.3.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+libLTLIBRARIES_INSTALL = $(INSTALL)
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f"; \
+ $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f; \
+ else :; fi; \
+ done
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ p="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \
+ $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" = "$$p" && dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libXft.la: $(libXft_la_OBJECTS) $(libXft_la_DEPENDENCIES)
+ $(LINK) -rpath $(libdir) $(libXft_la_LDFLAGS) $(libXft_la_OBJECTS) $(libXft_la_LIBADD) $(LIBS)
+binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
+install-binSCRIPTS: $(bin_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+ @list='$(bin_SCRIPTS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f $$d$$p; then \
+ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+ echo " $(binSCRIPT_INSTALL) $$d$$p $(DESTDIR)$(bindir)/$$f"; \
+ $(binSCRIPT_INSTALL) $$d$$p $(DESTDIR)$(bindir)/$$f; \
+ else :; fi; \
+ done
+
+uninstall-binSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_SCRIPTS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+ echo " rm -f $(DESTDIR)$(bindir)/$$f"; \
+ rm -f $(DESTDIR)$(bindir)/$$f; \
+ done
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT) core *.core
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftcolor.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftcore.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftdbg.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftdpy.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftdraw.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftextent.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftfont.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftfreetype.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftglyphs.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftinit.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftlist.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftname.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftrender.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftstr.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftswap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xftxlfd.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@ fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@ fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+
+.c.lo:
+@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; \
+@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@ fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+
+man3dir = $(mandir)/man3
+install-man3: $(man3_MANS) $(man_MANS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(man3dir)
+ @list='$(man3_MANS) $(dist_man3_MANS) $(nodist_man3_MANS)'; \
+ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+ for i in $$l2; do \
+ case "$$i" in \
+ *.3*) list="$$list $$i" ;; \
+ esac; \
+ done; \
+ for i in $$list; do \
+ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
+ else file=$$i; fi; \
+ ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+ case "$$ext" in \
+ 3*) ;; \
+ *) ext='3' ;; \
+ esac; \
+ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+ inst=`echo $$inst | sed -e 's/^.*\///'`; \
+ inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+ echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man3dir)/$$inst"; \
+ $(INSTALL_DATA) $$file $(DESTDIR)$(man3dir)/$$inst; \
+ done
+uninstall-man3:
+ @$(NORMAL_UNINSTALL)
+ @list='$(man3_MANS) $(dist_man3_MANS) $(nodist_man3_MANS)'; \
+ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+ for i in $$l2; do \
+ case "$$i" in \
+ *.3*) list="$$list $$i" ;; \
+ esac; \
+ done; \
+ for i in $$list; do \
+ ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+ case "$$ext" in \
+ 3*) ;; \
+ *) ext='3' ;; \
+ esac; \
+ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+ inst=`echo $$inst | sed -e 's/^.*\///'`; \
+ inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+ echo " rm -f $(DESTDIR)$(man3dir)/$$inst"; \
+ rm -f $(DESTDIR)$(man3dir)/$$inst; \
+ done
+pkgconfigDATA_INSTALL = $(INSTALL_DATA)
+install-pkgconfigDATA: $(pkgconfig_DATA)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(pkgconfigdir)
+ @list='$(pkgconfig_DATA)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " $(pkgconfigDATA_INSTALL) $$d$$p $(DESTDIR)$(pkgconfigdir)/$$f"; \
+ $(pkgconfigDATA_INSTALL) $$d$$p $(DESTDIR)$(pkgconfigdir)/$$f; \
+ done
+
+uninstall-pkgconfigDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgconfig_DATA)'; for p in $$list; do \
+ f="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " rm -f $(DESTDIR)$(pkgconfigdir)/$$f"; \
+ rm -f $(DESTDIR)$(pkgconfigdir)/$$f; \
+ done
+libXftincludeHEADERS_INSTALL = $(INSTALL_HEADER)
+install-libXftincludeHEADERS: $(libXftinclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(libXftincludedir)
+ @list='$(libXftinclude_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " $(libXftincludeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(libXftincludedir)/$$f"; \
+ $(libXftincludeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(libXftincludedir)/$$f; \
+ done
+
+uninstall-libXftincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(libXftinclude_HEADERS)'; for p in $$list; do \
+ f="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " rm -f $(DESTDIR)$(libXftincludedir)/$$f"; \
+ rm -f $(DESTDIR)$(libXftincludedir)/$$f; \
+ done
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+
+TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$tags$$unique" \
+ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique
+
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+top_distdir = .
+distdir = $(PACKAGE)-$(VERSION)
+
+am__remove_distdir = \
+ { test ! -d $(distdir) \
+ || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
+ && rm -fr $(distdir); }; }
+
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+
+distdir: $(DISTFILES)
+ $(am__remove_distdir)
+ mkdir $(distdir)
+ $(mkinstalldirs) $(distdir)/.
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkinstalldirs) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+ -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
+ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+ ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
+ || chmod -R a+r $(distdir)
+dist-gzip: distdir
+ $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+ $(am__remove_distdir)
+
+dist-bzip2: distdir
+ $(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
+ $(am__remove_distdir)
+
+dist dist-all: distdir
+ $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+ $(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
+ $(am__remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration. Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+ $(am__remove_distdir)
+ GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
+ chmod -R a-w $(distdir); chmod a+w $(distdir)
+ mkdir $(distdir)/_build
+ mkdir $(distdir)/_inst
+ chmod a-w $(distdir)
+ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+ && cd $(distdir)/_build \
+ && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+ $(DISTCHECK_CONFIGURE_FLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) dvi \
+ && $(MAKE) $(AM_MAKEFLAGS) check \
+ && $(MAKE) $(AM_MAKEFLAGS) install \
+ && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+ && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+ distuninstallcheck \
+ && chmod -R a-w "$$dc_install_base" \
+ && ({ \
+ (cd ../.. && $(mkinstalldirs) "$$dc_destdir") \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+ } || { rm -rf "$$dc_destdir"; exit 1; }) \
+ && rm -rf "$$dc_destdir" \
+ && $(MAKE) $(AM_MAKEFLAGS) dist-gzip \
+ && rm -f $(distdir).tar.gz \
+ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
+ $(am__remove_distdir)
+ @echo "$(distdir).tar.gz is ready for distribution" | \
+ sed 'h;s/./=/g;p;x;p;x'
+distuninstallcheck:
+ @cd $(distuninstallcheck_dir) \
+ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+ || { echo "ERROR: files left after uninstall:" ; \
+ if test -n "$(DESTDIR)"; then \
+ echo " (check DESTDIR support)"; \
+ fi ; \
+ $(distuninstallcheck_listfiles) ; \
+ exit 1; } >&2
+distcleancheck: distclean
+ @if test '$(srcdir)' = . ; then \
+ echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+ exit 1 ; \
+ fi
+ @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+ || { echo "ERROR: files left in build directory after distclean:" ; \
+ $(distcleancheck_listfiles) ; \
+ exit 1; } >&2
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(SCRIPTS) $(MANS) $(DATA) $(HEADERS) \
+ config.h
+
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) $(DESTDIR)$(man3dir) $(DESTDIR)$(pkgconfigdir) $(DESTDIR)$(libXftincludedir)
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic distclean-hdr \
+ distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-libXftincludeHEADERS install-man \
+ install-pkgconfigDATA
+
+install-exec-am: install-binSCRIPTS install-libLTLIBRARIES
+
+install-info: install-info-am
+
+install-man: install-man3
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+ -rm -rf $(top_srcdir)/autom4te.cache
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binSCRIPTS uninstall-info-am \
+ uninstall-libLTLIBRARIES uninstall-libXftincludeHEADERS \
+ uninstall-man uninstall-pkgconfigDATA
+
+uninstall-man: uninstall-man3
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libLTLIBRARIES clean-libtool ctags dist dist-all \
+ dist-bzip2 dist-gzip distcheck distclean distclean-compile \
+ distclean-generic distclean-hdr distclean-libtool \
+ distclean-tags distcleancheck distdir distuninstallcheck dvi \
+ dvi-am info info-am install install-am install-binSCRIPTS \
+ install-data install-data-am install-exec install-exec-am \
+ install-info install-info-am install-libLTLIBRARIES \
+ install-libXftincludeHEADERS install-man install-man3 \
+ install-pkgconfigDATA install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binSCRIPTS \
+ uninstall-info-am uninstall-libLTLIBRARIES \
+ uninstall-libXftincludeHEADERS uninstall-man uninstall-man3 \
+ uninstall-pkgconfigDATA
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/nx-X11/lib/Xft/NEWS b/nx-X11/lib/Xft/NEWS
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/lib/Xft/NEWS
diff --git a/nx-X11/lib/Xft/README b/nx-X11/lib/Xft/README
new file mode 100644
index 000000000..4a18a4c17
--- /dev/null
+++ b/nx-X11/lib/Xft/README
@@ -0,0 +1,65 @@
+ Xft
+ X FreeType library
+ Version 2.1.7
+ 2005-3-29
+
+Xft version 2.1 is the first stand alone release of Xft, a library that
+connects X applications with the FreeType font rasterization library. Xft
+uses fontconfig to locate fonts so it has no configuration files.
+
+Version 2.1.7
+
+Change FC_CHARCELL and FC_MONO interpretation. FC_MONO no longer clips
+glyphs to charcell, you must specify FC_CHARCELL for that.
+
+Add support for FT_GlyphSlot_Embolden where it exists (which it usually
+doesn't).
+
+Avoid crashing when using FT_Face objects.
+
+Version 2.1.6
+
+Deal with broken FreeType 2.1.7 BDF/PCF loaders by trying both y_ppem/x_ppem
+and width/height values.
+
+Version 2.1.5
+
+Left some #warnings from testing in the 2.1.4 release. Spin again.
+
+Version 2.1.4
+
+Work with older versions of Fontconfig by using various pattern elements
+only when defined.
+
+Version 2.1.3
+
+Change Freetype includes to new syntax.
+
+Search for nearest bitmap for bitmap-only fonts.
+
+Support fontconfig 2.2 release which doesn't include FC_HINT_STYLE.
+
+To release a version of this library:
+
+ 1. Update the version numbers
+ configure.ac
+ Xft.h
+ 2. Fix the README
+ Change version number
+ Set the date
+ 3. Commit those changes
+ 4. rebuild the configuration files with autogen.sh
+ sh autogen.sh --sysconfdir=/etc --prefix=/usr --mandir=/usr/share/man
+ 5. make distcheck
+ 6. tag the tree
+ cvs tag Xft-2_1_xx
+ 7. Copy Xft-2.1.xx.tar.gz and Xft-2.1.xx.tar.bz2 to
+ freedesktop.org:/srv/xlibs.freedesktop.org/www/release
+ 8. Compute md5sums for release files:
+ md5sum Xft-2.1.xx.tar.gz Xft-2.1.xx.tar.bz2
+ 9. Post a note to xorg@freedesktop.org. Include the md5sums.
+ gpg sign the message.
+
+
+Keith Packard
+keithp@keithp.com
diff --git a/nx-X11/lib/Xft/Xft-def.cpp b/nx-X11/lib/Xft/Xft-def.cpp
new file mode 100644
index 000000000..0a3e9c09d
--- /dev/null
+++ b/nx-X11/lib/Xft/Xft-def.cpp
@@ -0,0 +1,183 @@
+LIBRARY Xft
+VERSION LIBRARY_VERSION
+EXPORTS
+
+#ifndef __UNIXOS2__
+XftConfigAddDir
+XftConfigAddEdit
+XftConfigGetCache
+XftConfigSetCache
+XftConfigSubstitute
+_XftConfigCompareValue
+#endif
+XftColorAllocName
+XftColorAllocValue
+XftColorFree
+#ifndef __UNIXOS2__
+XftCoreConvert16
+XftCoreConvert32
+XftCoreConvertUtf8
+XftCoreExtents16
+XftCoreExtents32
+XftCoreExtents8
+XftCoreExtentsUtf8
+XftCoreGlyphExists
+XftEditPrint
+XftExprPrint
+XftFontSetPrint
+XftOpPrint
+XftPatternPrint
+XftSubstPrint
+XftTestPrint
+XftValueListPrint
+XftValuePrint
+#endif
+XftDefaultGetBool
+XftDefaultGetDouble
+XftDefaultGetInteger
+XftDefaultHasRender
+XftDefaultParseBool
+XftDefaultSet
+XftDefaultSubstitute
+#ifndef __UNIXOS2__
+XftDisplayGetFontSet
+#endif
+XftDrawChange
+#ifndef __UNIXOS2__
+XftDrawCorePrepare
+#endif
+XftDrawCreate
+XftDrawCreateBitmap
+XftDrawDestroy
+XftDrawRect
+#ifndef __UNIXOS2__
+XftDrawRenderPrepare
+#endif
+XftDrawSetClip
+XftDrawString16
+XftDrawString32
+XftDrawString8
+XftDrawStringUtf8
+XftTextExtents16
+XftTextExtents32
+XftTextExtents8
+XftTextExtentsUtf8
+XftFontClose
+XftFontMatch
+XftFontOpen
+XftFontOpenName
+XftFontOpenPattern
+XftFontOpenXlfd
+#ifndef __UNIXOS2__
+XftGlyphExists
+_XftFontDebug
+XftFontSetAdd
+XftFontSetCreate
+XftFontSetDestroy
+XftConfigSaveField
+XftConfigerror
+XftConfigparse
+XftConfigwrap
+XftEditCreate
+XftEditDestroy
+XftExprCreateBool
+XftExprCreateDouble
+XftExprCreateField
+XftExprCreateInteger
+XftExprCreateNil
+XftExprCreateOp
+XftExprCreateString
+XftExprDestroy
+XftTestCreate
+#endif
+XftInit
+#ifndef __UNIXOS2__
+XftConfigLexFile
+XftConfigPushInput
+XftConfig_create_buffer
+XftConfig_delete_buffer
+XftConfig_flush_buffer
+XftConfig_init_buffer
+XftConfig_load_buffer_state
+XftConfig_scan_buffer
+XftConfig_scan_bytes
+XftConfig_scan_string
+XftConfig_switch_to_buffer
+XftConfiglex
+XftConfigrestart
+XftListAppend
+XftListFontSets
+#endif
+XftListFonts
+XftListFontsPatternObjects
+#ifndef __UNIXOS2__
+XftListMatch
+XftListValueCompare
+XftListValueListCompare
+XftObjectSetAdd
+XftObjectSetBuild
+XftObjectSetCreate
+XftObjectSetDestroy
+XftObjectSetVaBuild
+XftFontSetMatch
+XftNameConstant
+#endif
+XftNameParse
+XftNameUnparse
+#ifndef __UNIXOS2__
+XftPatternAdd
+XftPatternAddBool
+XftPatternAddDouble
+XftPatternAddInteger
+XftPatternAddString
+XftPatternBuild
+XftPatternCreate
+XftPatternDel
+XftPatternDestroy
+XftPatternDuplicate
+XftPatternFind
+XftPatternGet
+XftPatternGetBool
+XftPatternGetDouble
+XftPatternGetInteger
+XftPatternGetString
+XftPatternVaBuild
+XftValueDestroy
+XftValueListDestroy
+XftUtf8Len
+XftUtf8ToUcs4
+_XftDownStr
+_XftGetInt
+#endif
+_XftMatchSymbolic
+#ifndef __UNIXOS2__
+_XftSaveString
+_XftSplitField
+_XftSplitStr
+_XftSplitValue
+_XftStrCmpIgnoreCase
+XftCoreAddFonts
+XftCoreClose
+XftCoreOpen
+#endif
+XftXlfdParse
+XftInitFtLibrary
+#ifndef __UNIXOS2__
+XftConfigDirs
+XftDirScan
+XftDirSave
+#endif
+XftDrawPicture
+XftDrawSrcPicture
+#ifndef __UNIXOS2__
+XftGlyphLoad
+XftGlyphCheck
+XftFreeTypeGlyphExists
+XftFreeTypeOpen
+XftFreeTypeClose
+XftRenderString16
+#else
+XftCharExists
+#endif /* __UNIXOS2__ */
+
+/* $Id: Xft-def.cpp,v 1.3 2005/06/24 22:43:20 alanc Exp $ */
diff --git a/nx-X11/lib/Xft/Xft.3.in b/nx-X11/lib/Xft/Xft.3.in
new file mode 100644
index 000000000..040dc1ffe
--- /dev/null
+++ b/nx-X11/lib/Xft/Xft.3.in
@@ -0,0 +1,847 @@
+.\"
+.\" $Id: Xft.3.in,v 1.3 2005/06/24 22:43:20 alanc Exp $
+.\"
+.\" Copyright © 2000 Keith Packard
+.\"
+.\" 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 of Keith Packard not be used in
+.\" advertising or publicity pertaining to distribution of the software without
+.\" specific, written prior permission. Keith Packard makes no
+.\" representations about the suitability of this software for any purpose. It
+.\" is provided "as is" without express or implied warranty.
+.\"
+.\" KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+.\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+.\" EVENT SHALL KEITH PACKARD 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.
+.\"
+.TH Xft 3 "Version @VERSION@" "Xft"
+.SH NAME
+ Xft \- X FreeType interface library
+.SH DESCRIPTION
+.B Xft
+is a simple library designed to interface the FreeType rasterizer with the X
+Rendering Extension.
+This manual page barely scratches the surface of this library.
+.SH "HEADER FILE"
+.B #include <X11/Xft/Xft.h>
+.SH CONSTANTS
+.TP
+.B XFT_MAJOR
+is the major version number of
+.BR Xft .
+.TP
+.B XFT_MINOR
+is the minor version number of
+.BR Xft .
+.TP
+.B XFT_REVISION
+is the revision number of
+.BR Xft .
+.TP
+.B XFT_VERSION
+is
+.B XFT_MAJOR
+times 10000 (ten thousand), plus
+.B XFT_MINOR
+times 100, plus
+.BR XFT_REVISION .
+.TP
+.B XftVersion
+is an alias for
+.BR XFT_VERSION .
+.PP
+The following example illustrates how
+.BR Xft 's
+version constants might be used:
+.nf
+ #if (XFT_VERSION >= 20107)
+ (void) puts("Version 2.1.7 or later of the Xft library is in"
+ " use.");
+ #else
+ (void) printf("Insufficient version of Xft (%d.%d.%d) installed;
+ " need at least version 2.1.7.\(rsn", XFT_MAJOR,
+ XFT_MINOR,
+ XFT_REVISION);
+ #endif
+.fi
+.\" I don't understand what these are for. -- BR, 2005-04-02
+.\" XFT_CORE used in xftname.c
+.\" XFT_RENDER used in xftdpy.c, xftfreetype.c, xftname.c
+.\" XFT_XLFD used in xftname.c, xftxlfd.c
+.\" XFT_MAX_GLYPH_MEMORY used in xftdpy.c, xftfreetype.c
+.\" XFT_MAX_UNREF_FONTS used in xftdpy.c
+.\" XFT_NMISSING used in xftcore.c, xftextent.c, xftglyphs.c,
+.\" xftrender.c
+.SH "DATA TYPES"
+.TP
+.B XftFont
+.nf
+typedef struct _XftFont {
+ int ascent;
+ int descent;
+ int height;
+ int max_advance_width;
+ FcCharSet *charset;
+ FcPattern *pattern;
+} XftFont;
+.fi
+An
+.B XftFont
+is the primary data structure of interest to programmers using
+.BR Xft ;
+it contains general font metrics and pointers to the Fontconfig
+character set and pattern associated with the font.
+The
+.B FcCharSet
+and
+.B FcPattern
+data types are defined by the Fontconfig library.
+.TP
+.B ""
+.BR XftFont s
+are populated with any of
+.BR XftFontOpen (),
+.BR XftFontOpenName (),
+.BR XftFontOpenXlfd (),
+.BR XftFontOpenInfo (),
+or
+.BR XftFontOpenPattern ().
+.BR XftFontCopy ()
+is used to duplicate
+.BR XftFont s,
+and
+.BR XftFontClose ()
+is used to mark an
+.B XftFont
+as unused.
+.BR XftFont s
+are internally allocated, reference-counted, and freed by
+.BR Xft ;
+the programmer does not ordinarily need to allocate or free storage
+for them.
+.TP
+.B ""
+.BR XftDrawGlyphs (),
+the
+.BR XftDrawString *()
+family,
+.BR XftDrawCharSpec (),
+and
+.BR XftDrawGlyphSpec ()
+use
+.BR XftFont s
+to render text to an
+.B XftDraw
+object, which may correspond to either a core X drawable or an X
+Rendering Extension drawable.
+.TP
+.B ""
+.BR XftGlyphExtents ()
+and the
+.BR XftTextExtents *()
+family are used to determine the extents (maximum dimensions) of an
+.BR XftFont .
+.TP
+.B ""
+An
+.BR XftFont 's
+glyph or character coverage can be determined with
+.BR XftFontCheckGlyph ()
+or
+.BR XftCharExists ().
+.BR XftCharIndex ()
+returns the
+.BR XftFont -specific
+character index corresponding to a given Unicode codepoint.
+.TP
+.B ""
+.BR XftGlyphRender (),
+.BR XftGlyphSpecRender (),
+.BR XftCharSpecRender (),
+and the
+.BR XftTextRender *()
+family use
+.BR XftFont s
+to draw into X Rendering Extension
+.B Picture
+structures.
+.B Note:
+.BR XftDrawGlyphs (),
+the
+.BR XftDrawString *()
+family,
+.BR XftDrawCharSpec (),
+and
+.BR XftDrawGlyphSpec ()
+provide a means of rendering fonts that is independent of the
+availability of the X Rendering Extension on the X server.
+.\" I'm not sure what these are for; they're used internally, but why
+.\" would any external users want them? -- BR, 2005-04-02
+.\" .BR XftLockFace()
+.\" .BR XftUnlockFace()
+.TP
+.B XftFontInfo
+is an opaque object that stores information about a font.
+.B XftFontInfo
+structures are created with
+.BR XftFontInfoCreate (),
+freed with
+.BR XftFontInfoDestroy (),
+and compared with
+.BR XftFontInfoEqual ().
+.B XftFontInfo
+objects are internally allocated and freed by
+.BR Xft ;
+the programmer does not ordinarily need to allocate or free storage
+for them.
+.TP
+.B ""
+Each
+.B XftFontInfo
+structure in use is associated with a unique identifier, which can be
+retrieved with
+.BR XftFontInfoHash ().
+An
+.B XftFont
+can be opened based on
+.B XftFontInfo
+data with
+.BR XftFontOpenInfo ().
+.TP
+.B XftColor
+.nf
+typedef struct _XftColor {
+ unsigned long pixel;
+ XRenderColor color;
+} XftColor;
+.fi
+An
+.B XftColor
+object permits text and other items to be rendered in a particular
+color (or the closest approximation offered by the X visual in use).
+The
+.B XRenderColor
+data type is defined by the X Render Extension library.
+.TP
+.B ""
+.BR XftColorAllocName ()
+and
+.BR XftColorAllocValue ()
+request a color allocation from the X server (if necessary) and
+initialize the members of
+.BR XftColor .
+.BR XftColorFree ()
+instructs the X server to free the color currently allocated for an
+.BR XftColor .
+.TP
+.B ""
+One an
+.B XftColor
+has been initialized,
+.BR XftDrawSrcPicture (),
+.BR XftDrawGlyphs (),
+the
+.BR XftDrawString *()
+family,
+.BR XftDrawCharSpec (),
+.BR XftDrawCharFontSpec (),
+.BR XftDrawGlyphSpec (),
+.BR XftDrawGlyphFontSpec (),
+and
+.BR XftDrawRect ()
+may be used to draw various objects using it.
+.TP
+.B XftDraw
+is an opaque object which holds information used to render to an X drawable
+using either the core protocol or the X Rendering extension.
+.TP
+.B ""
+.B XftDraw
+objects are created with any of
+.BR XftDrawCreate ()
+(which associates an
+.B XftDraw
+with an existing X drawable),
+.BR XftDrawCreateBitmap (),
+or
+.BR XftDrawCreateAlpha (),
+and destroyed with
+.BR XftDrawDestroy ().
+The X drawable associated with an
+.B XftDraw
+can be changed with
+.BR XftDrawChange ().
+.BR XftDraw s
+are internally allocated and freed by
+.BR Xft ;
+the programmer does not ordinarily need to allocate or free storage
+for them.
+.TP
+.B ""
+The X
+.BR Display ,
+.BR Drawable ,
+.BR Colormap ,
+and
+.BR Visual
+of an
+.B XftDraw
+can be queried with
+.BR XftDrawDisplay (),
+.BR XftDrawDrawable (),
+.BR XftDrawColormap (),
+and
+.BR XftDrawVisual (),
+respectively.
+The X Rendering Extension
+.B Picture
+associated with an
+.B XftDraw
+is returned by
+.BR XftDrawPicture ().
+.\" XftDrawSrcPicture
+.\" XftDrawGlyphs
+.\" XftDrawString*
+.\" XftDrawCharSpec
+.\" XftDrawCharFontSpec
+.\" XftDrawGlyphSpec
+.\" XftDrawGlyphFontSpec
+.\" XftDrawRect
+.\" XftDrawSetClip
+.\" XftDrawSetClipRectangles
+.\" XftDrawSetSubwindowMode
+.TP
+.B XftCharSpec
+.nf
+typedef struct _XftCharSpec {
+ FcChar32 ucs4;
+ short x;
+ short y;
+} XftCharSpec;
+.fi
+.TP
+.B ""
+The
+.B FcChar32
+data type is defined by the Fontconfig library.
+.\" XftDrawCharSpec
+.\" XftCharSpecRender
+.TP
+.B XftCharFontSpec
+.nf
+typedef struct _XftCharFontSpec {
+ XftFont *font;
+ FcChar32 ucs4;
+ short x;
+ short y;
+} XftCharFontSpec;
+.fi
+.TP
+.B ""
+The
+.B FcChar32
+data type is defined by the Fontconfig library.
+.\" XftDrawCharFontSpec
+.\" XftCharFontSpecRender
+.TP
+.B XftGlyphSpec
+.nf
+typedef struct _XftGlyphSpec {
+ FT_UInt glyph;
+ short x;
+ short y;
+} XftGlyphSpec;
+.fi
+.TP
+.B ""
+The
+.B FT_UInt
+data type is defined by the FreeType library.
+.\" XftDrawGlyphSpec
+.\" XftGlyphSpecRender
+.TP
+.B XftGlyphFontSpec
+.nf
+typedef struct _XftGlyphFontSpec {
+ XftFont *font;
+ FT_UInt glyph;
+ short x;
+ short y;
+} XftGlyphFontSpec;
+.fi
+.TP
+.B ""
+The
+.B FT_UInt
+data type is defined by the FreeType library.
+.\" XftDrawGlyphFontSpec
+.\" XftGlyphFontSpecRender
+.SH FUNCTIONS
+.SS "Opening and Matching Fonts"
+.nf
+\fBXftFont *\fR
+\fBXftFontOpen (Display *\fIdpy\fB,\fR
+\fB int \fIscreen\fB,\fR
+\fB ...);\fR\fR
+.fi
+.B XftFontOpen
+takes a list of pattern element triples of the form
+.IR field , " type" , " value"
+(terminated with a NULL), matches that pattern against the available fonts,
+and opens the matching font, sizing it correctly for screen number
+.I screen
+on display
+.IR dpy .
+The
+.B Display
+data type is defined by the X11 library.
+Returns NULL if no match is found.
+.PP
+Example:
+.nf
+ font = XftFontOpen (dpy, screen,
+ XFT_FAMILY, XftTypeString, "charter",
+ XFT_SIZE, XftTypeDouble, 12.0,
+ NULL);
+.fi
+This opens the \(lqcharter\(rq font at 12 points.
+The point size is automatically converted to the correct pixel size based
+on the resolution of the monitor.
+.PP
+.nf
+\fBXftFont *\fR
+\fBXftFontOpenName (Display *\fIdpy\fB,\fR
+\fB int \fIscreen\fB,\fR
+\fB unsigned char *\fIname\fB);\fR
+.fi
+.B XftFontOpenName
+behaves as
+.B XftFontOpen
+does, except that it takes a Fontconfig pattern string (which is passed to
+the Fontconfig library's
+.BR FcNameParse ()
+function).
+.PP
+.nf
+\fBXftFont *\fR
+\fBXftFontOpenXlfd (Display *\fIdpy\fB,\fR
+\fB int \fIscreen\fB,\fR
+\fB unsigned char *\fIxlfd\fB)\fR
+.fi
+.B XftFontOpenXlfd
+behaves as
+.B XftFontOpen
+does, except that it takes a string containing an X Logical Font
+Description (XLFD).
+.PP
+.nf
+\fBFcPattern *\fR
+\fBXftFontMatch (Display *\fIdpy\fB,\fR
+\fB int \fIscreen\fB,\fR
+\fB FcPattern *\fIpattern\fB,\fR
+\fB FcResult *\fIresult\fB);\fR
+.fi
+Also used internally by the
+.BR XftFontOpen *
+functions,
+.B XftFontMatch
+can also be used directly to determine the Fontconfig font pattern
+resulting from an Xft font open request.
+The
+.B FcPattern
+and
+.B FcResult
+data types are defined by the Fontconfig library.
+.SS "Determining the Pixel Extents of a Text String"
+.nf
+\fBvoid\fR
+\fBXftTextExtents8 (Display *\fIdpy\fB,\fR
+\fB XftFont *\fIfont\fB,\fR
+\fB FcChar8 *\fIstring\fB,\fR
+\fB int \fIlen\fB,\fR
+\fB XGlyphInfo *\fIextents\fB);\fR
+.fi
+.B XftTextExtents8
+computes the pixel extents on display
+.I dpy
+of no more than
+.I len
+glyphs of a
+.I string
+consisting of eight-bit characters when drawn with
+.IR font ,
+storing them in
+.IR extents .
+The
+.B FcChar8
+data type is defined by the Fontconfig library, and the
+.B XGlyphInfo
+data type is defined by the X Rendering Extension library.
+.PP
+.nf
+\fBvoid\fR
+\fBXftTextExtents16 (Display *\fIdpy\fB,\fR
+\fB XftFont *\fIfont\fB,\fR
+\fB FcChar16 *\fIstring\fB,\fR
+\fB int \fIlen\fB,\fR
+\fB XGlyphInfo *\fIextents\fB);\fR
+.fi
+.B XftTextExtents16
+computes the pixel extents on display
+.I dpy
+of no more than
+.I len
+glyphs of a
+.I string
+consisting of sixteen-bit characters when drawn with
+.IR font ,
+storing them in
+.IR extents .
+The
+.B FcChar16
+data type is defined by the Fontconfig library, and the
+.B XGlyphInfo
+data type is defined by the X Rendering Extension library.
+.PP
+.nf
+\fBvoid\fR
+\fBXftTextExtents32 (Display *\fIdpy\fB,\fR
+\fB XftFont *\fIfont\fB,\fR
+\fB FcChar32 *\fIstring\fB,\fR
+\fB int \fIlen\fB,\fR
+\fB XGlyphInfo *\fIextents\fB);\fR
+.fi
+.B XftTextExtents32
+computes the pixel extents on display
+.I dpy
+of no more than
+.I len
+glyphs of a
+.I string
+consisting of thirty-two-bit characters when drawn with
+.IR font ,
+storing them in
+.IR extents .
+The
+.B FcChar32
+data type is defined by the Fontconfig library, and the
+.B XGlyphInfo
+data type is defined by the X Rendering Extension library.
+.PP
+.nf
+\fBvoid\fR
+\fBXftTextExtentsUtf8 (Display *\fIdpy\fB,\fR
+\fB XftFont *\fIfont\fB,\fR
+\fB FcChar8 *\fIstring\fB,\fR
+\fB int \fIlen\fB,\fR
+\fB XGlyphInfo *\fIextents\fB);\fR
+.fi
+.B XftTextExtentsUtf8
+computes the pixel extents on display
+.I dpy
+of no more than
+.I len
+bytes of a UTF-8 encoded
+.I string
+when drawn with
+.IR font ,
+storing them in
+.IR extents .
+The
+.B XGlyphInfo
+data type is defined by the X Rendering Extension library.
+.PP
+.nf
+\fBvoid\fR
+\fBXftTextExtentsUtf16 (Display *\fIdpy\fB,\fR
+\fB XftFont *\fIfont\fB,\fR
+\fB FcChar8 *\fIstring\fB,\fR
+\fB FcEndian \fIendian\fB,\fR
+\fB int \fIlen\fB,\fR
+\fB XGlyphInfo *\fIextents\fB);\fR
+.fi
+.B XftTextExtentsUtf16
+computes the pixel extents on display
+.I dpy
+of no more than
+.I len
+bytes of a UTF-16LE- or UTF-16BE-encoded
+.I string
+when drawn with
+.IR font ,
+storing them in
+.IR extents .
+The endianness of
+.I string
+must be specified in
+.IR endian .
+The
+.B FcEndian
+data type is defined by the Fontconfig library, and the
+.B XGlyphInfo
+data type is defined by the X Rendering Extension library.
+.PP
+.nf
+\fBvoid\fR
+\fBXftGlyphExtents (Display *\fIdpy\fB,\fR
+\fB XftFont *\fIfont\fB,\fR
+\fB FT_UInt *\fIglyphs\fB,\fR
+\fB int \fInglyphs\fB,\fR
+\fB XGlyphInfo *\fIextents\fB);\fR
+.fi
+Also used internally by the
+.BR XftTextExtents *
+functions,
+.B XftGlyphExtents
+computes the pixel extents on display
+.I dpy
+of no more than
+.I nglyphs
+in the array
+.I glyphs
+drawn with
+.IR font ,
+storing them in
+.IR extents .
+The
+.B FT_UInt
+data type is defined by the FreeType library, and the
+.B XGlyphInfo
+data type is defined by the X Rendering Extension library.
+.SS "Drawing Strings (and Other Things)"
+.nf
+\fBXftDraw *\fR
+\fBXftDrawCreate (Display *\fIdpy\fB,\fR
+\fB Drawable \fIdrawable\fB,\fR
+\fB Visual *\fIvisual\fB,\fR
+\fB Colormap \fIcolormap\fB);\fR
+.fi
+.B XftDrawCreate
+creates a structure that can be used to render text and rectangles using
+the specified
+.IR drawable ,
+.IR visual ,
+and
+.I colormap
+on
+.IR display .
+The
+.BR Drawable ,
+.BR Visual ,
+and
+.B Colormap
+data types are defined by the X11 library.
+.PP
+.nf
+\fBXftDraw *\fR
+\fBXftDrawCreateBitmap (Display *\fIdpy\fB,\fR
+\fB Pixmap \fIbitmap\fB);\fR
+.fi
+.B XftDrawCreateBitmap
+behaves as
+.BR XftDrawCreate ,
+except it uses an X pixmap of color depth 1 instead of an X drawable.
+The
+.B Pixmap
+data type is defined by the X11 library.
+.PP
+.nf
+\fBXftDraw *\fR
+\fBXftDrawCreateAlpha (Display *\fIdpy\fB,\fR
+\fB Pixmap \fIpixmap\fB,\fR
+\fB int \fIdepth\fB);\fR
+.fi
+.B XftDrawCreateAlpha
+behaves as
+.BR XftDrawCreate ,
+except it uses an X pixmap of color depth
+.I depth
+instead of an X drawable.
+The
+.B Pixmap
+data type is defined by the X11 library.
+.PP
+.nf
+\fBvoid\fR
+\fBXftDrawChange (XftDraw *\fIdraw\fB,\fR
+\fB Drawable \fIdrawable\fB);\fR
+.fi
+.B XftDrawChange
+changes the X drawable association of the existing Xft draw object
+.I draw
+from its current value to
+.IR drawable .
+.PP
+.nf
+\fBDisplay *\fR
+\fBXftDrawDisplay (XftDraw *\fIdraw\fB);\fR
+.fi
+.B XftDrawDisplay
+returns a pointer to the display associated with the Xft draw object
+.IR draw .
+.PP
+.nf
+\fBDrawable\fR
+\fBXftDrawDrawable (XftDraw *\fIdraw\fB);\fR
+.fi
+.B XftDrawDrawable
+returns the X drawable associated with the Xft draw object
+.IR draw .
+.PP
+.nf
+\fBColormap\fR
+\fBXftDrawColormap (XftDraw *\fIdraw\fB);\fR
+.fi
+.B XftDrawColormap
+returns the colormap associatied with the Xft draw object
+.IR draw .
+.PP
+.nf
+\fBVisual *\fR
+\fBXftDrawVisual (XftDraw *\fIdraw\fB);\fR
+.fi
+.B XftDrawVisual
+returns a pointer to the visual associated with the Xft draw object
+.IR draw .
+.PP
+.nf
+\fBPicture\fR
+\fBXftDrawPicture (XftDraw *\fIdraw\fB);\fR
+.fi
+.B XftDrawPicture
+returns the picture associated with the Xft draw object
+.IR draw .
+If the the X server does not support the X Rendering Extension, 0 is
+returned.
+.PP
+.nf
+\fBPicture\fR
+\fBXftDrawSrcPicture (XftDraw *\fIdraw\fB,\fR
+\fB XftColor *\fIcolor\fB);\fR
+.fi
+.\" Unfortunately, I'm not quite sure what this does. I think it is the gizmo
+.\" that is used to create an Xrender Picture object so that glyphs can be
+.\" drawn in the XftDraw object
+.\" .I draw
+.\" using the specified
+.\" .IR color .
+.\" -- BR, 2005-04-02
+This function is never called if the X server doesn't support the X
+Rendering Extension; instead,
+.B XftGlyphCore
+is used.
+.PP
+.nf
+\fBvoid\fR
+\fBXftDrawDestroy (XftDraw *\fIdraw\fB);\fR
+.fi
+.B XftDrawDestroy
+destroys
+.I draw
+(created by one of the
+.B XftCreate
+functions) and frees the memory that was allocated for it.
+.PP
+.nf
+\fBvoid\fR
+\fBXftDrawString8 (XftDraw *\fId\fB,\fR
+\fB XRenderColor *\fIcolor\fB,\fR
+\fB XftFont *\fIfont\fB,\fR
+\fB int \fIx\fB,\fR
+\fB int \fIy\fB,\fR
+\fB unsigned char *\fIstring\fB,\fR
+\fB int \fIlen\fB);\fR
+.fi
+.B XftDrawString8
+draws no more than
+.I len
+glyphs of
+.I string
+to Xft drawable
+.I d
+using
+.I font
+in
+.I color
+at position
+.IR x , " y" .
+The
+.B XRenderColor
+data type is defined by the X Rendering Extension library.
+.PP
+.nf
+\fBvoid\fR
+\fBXftDrawRect (XftDraw *\fId\fB,\fR
+\fB XRenderColor *\fIcolor\fB,\fR
+\fB int \fIx\fB,\fR
+\fB int \fIy\fB,\fR
+\fB unsigned int \fIwidth\fB,\fR
+\fB unsigned int \fIheight\fB);\fR
+.fi
+.B XftDrawRect
+draws a solid rectangle of the specified
+.IR color ,
+.IR width ,
+and
+.I height
+at position
+.IR x , " y"
+to Xft drawable
+.IR d .
+.SH COMPATIBILITY
+As of version 2,
+.B Xft
+has become relatively stable and is expected to retain source and binary
+compatibility in future releases.
+.PP
+.B Xft
+does provide a compatibility interface to its previous major version,
+Xft
+.RI 1. x ,
+described below.
+.SS "Xft 1.x Compatibility Header File"
+.B #include <X11/Xft/XftCompat.h>
+.\" .SS "Xft 1.x Compatibility Constants"
+.SS "Xft 1.x Compatibility Data Types"
+.TP
+.B XftPattern
+holds a set of names with associated value lists; each name refers to a
+property of a font.
+.BR XftPattern s
+are used as inputs to the matching code as well as holding information
+about specific fonts.
+.TP
+.B XftFontSet
+contains a list of
+.BR XftPattern s.
+Internally,
+.B Xft
+uses this data structure to hold sets of fonts.
+Externally,
+.B Xft
+returns the results of listing fonts in this format.
+.TP
+.B XftObjectSet
+holds a set of names and is used to specify which fields from fonts are
+placed in the the list of returned patterns when listing fonts.
+.\" .SS "Xft 1.x Compatibility Functions"
+.SH AUTHOR
+Keith Packard
+.SH "SEE ALSO"
+.I Fontconfig Developers Reference
+.br
+.I FreeType API Reference
+.br
+.I Xlib \- C Language Interface
+.\" Set Vim modeline; textwidth is 70 to account for the extra margin
+.\" padding that man (on Debian GNU/Linux) does for output to
+.\" terminals (7 spaces on the left, 2 on the right), so that we don't
+.\" go past 80 columns total, particularly in .nf/.fi regions.
+.\" vim:set ai et sts=4 sw=4 tw=70:
diff --git a/nx-X11/lib/Xft/Xft.h b/nx-X11/lib/Xft/Xft.h
new file mode 100644
index 000000000..f3ea5a298
--- /dev/null
+++ b/nx-X11/lib/Xft/Xft.h
@@ -0,0 +1,642 @@
+/*
+ * $Id: Xft.h,v 1.6 2005/10/19 02:46:56 kem Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _XFT_H_
+#define _XFT_H_
+
+/*
+ * Current Xft version number. This same number
+ * must appear in the Xft configure.ac file. Yes,
+ * it'a a pain to synchronize version numbers like this.
+ */
+
+#define XFT_MAJOR 2
+#define XFT_MINOR 1
+#define XFT_REVISION 8
+#define XFT_VERSION ((XFT_MAJOR * 10000) + (XFT_MINOR * 100) + (XFT_REVISION))
+#define XftVersion XFT_VERSION
+
+#include <stdarg.h>
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include <fontconfig/fontconfig.h>
+#include <X11/extensions/Xrender.h>
+
+#include <X11/Xfuncproto.h>
+/* #include <X11/Xosdefs.h>*/
+#ifndef _X_SENTINEL
+# define _X_SENTINEL(x)
+#endif
+
+#ifndef _XFT_NO_COMPAT_
+#include <X11/Xft/XftCompat.h>
+#endif
+
+#define XFT_CORE "core"
+#define XFT_RENDER "render"
+#define XFT_XLFD "xlfd"
+#define XFT_MAX_GLYPH_MEMORY "maxglyphmemory"
+#define XFT_MAX_UNREF_FONTS "maxunreffonts"
+
+extern FT_Library _XftFTlibrary;
+
+typedef struct _XftFontInfo XftFontInfo;
+
+typedef struct _XftFont {
+ int ascent;
+ int descent;
+ int height;
+ int max_advance_width;
+ FcCharSet *charset;
+ FcPattern *pattern;
+} XftFont;
+
+typedef struct _XftDraw XftDraw;
+
+typedef struct _XftColor {
+ unsigned long pixel;
+ XRenderColor color;
+} XftColor;
+
+typedef struct _XftCharSpec {
+ FcChar32 ucs4;
+ short x;
+ short y;
+} XftCharSpec;
+
+typedef struct _XftCharFontSpec {
+ XftFont *font;
+ FcChar32 ucs4;
+ short x;
+ short y;
+} XftCharFontSpec;
+
+typedef struct _XftGlyphSpec {
+ FT_UInt glyph;
+ short x;
+ short y;
+} XftGlyphSpec;
+
+typedef struct _XftGlyphFontSpec {
+ XftFont *font;
+ FT_UInt glyph;
+ short x;
+ short y;
+} XftGlyphFontSpec;
+
+_XFUNCPROTOBEGIN
+
+
+/* xftcolor.c */
+Bool
+XftColorAllocName (Display *dpy,
+ _Xconst Visual *visual,
+ Colormap cmap,
+ _Xconst char *name,
+ XftColor *result);
+
+Bool
+XftColorAllocValue (Display *dpy,
+ Visual *visual,
+ Colormap cmap,
+ _Xconst XRenderColor *color,
+ XftColor *result);
+
+void
+XftColorFree (Display *dpy,
+ Visual *visual,
+ Colormap cmap,
+ XftColor *color);
+
+
+/* xftcore.c */
+
+/* xftdir.c */
+FcBool
+XftDirScan (FcFontSet *set, _Xconst char *dir, FcBool force);
+
+FcBool
+XftDirSave (FcFontSet *set, _Xconst char *dir);
+
+/* xftdpy.c */
+Bool
+XftDefaultHasRender (Display *dpy);
+
+Bool
+XftDefaultSet (Display *dpy, FcPattern *defaults);
+
+void
+XftDefaultSubstitute (Display *dpy, int screen, FcPattern *pattern);
+
+/* xftdraw.c */
+
+XftDraw *
+XftDrawCreate (Display *dpy,
+ Drawable drawable,
+ Visual *visual,
+ Colormap colormap);
+
+XftDraw *
+XftDrawCreateBitmap (Display *dpy,
+ Pixmap bitmap);
+
+XftDraw *
+XftDrawCreateAlpha (Display *dpy,
+ Pixmap pixmap,
+ int depth);
+
+void
+XftDrawChange (XftDraw *draw,
+ Drawable drawable);
+
+Display *
+XftDrawDisplay (XftDraw *draw);
+
+Drawable
+XftDrawDrawable (XftDraw *draw);
+
+Colormap
+XftDrawColormap (XftDraw *draw);
+
+Visual *
+XftDrawVisual (XftDraw *draw);
+
+void
+XftDrawDestroy (XftDraw *draw);
+
+Picture
+XftDrawPicture (XftDraw *draw);
+
+Picture
+XftDrawSrcPicture (XftDraw *draw, _Xconst XftColor *color);
+
+void
+XftDrawGlyphs (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ int x,
+ int y,
+ _Xconst FT_UInt *glyphs,
+ int nglyphs);
+
+void
+XftDrawString8 (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len);
+
+void
+XftDrawString16 (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ int x,
+ int y,
+ _Xconst FcChar16 *string,
+ int len);
+
+void
+XftDrawString32 (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ int x,
+ int y,
+ _Xconst FcChar32 *string,
+ int len);
+
+void
+XftDrawStringUtf8 (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len);
+
+void
+XftDrawStringUtf16 (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ FcEndian endian,
+ int len);
+
+void
+XftDrawCharSpec (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ _Xconst XftCharSpec *chars,
+ int len);
+
+void
+XftDrawCharFontSpec (XftDraw *draw,
+ _Xconst XftColor *color,
+ _Xconst XftCharFontSpec *chars,
+ int len);
+
+void
+XftDrawGlyphSpec (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ _Xconst XftGlyphSpec *glyphs,
+ int len);
+
+void
+XftDrawGlyphFontSpec (XftDraw *draw,
+ _Xconst XftColor *color,
+ _Xconst XftGlyphFontSpec *glyphs,
+ int len);
+
+void
+XftDrawRect (XftDraw *draw,
+ _Xconst XftColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height);
+
+
+Bool
+XftDrawSetClip (XftDraw *draw,
+ Region r);
+
+
+Bool
+XftDrawSetClipRectangles (XftDraw *draw,
+ int xOrigin,
+ int yOrigin,
+ _Xconst XRectangle *rects,
+ int n);
+
+void
+XftDrawSetSubwindowMode (XftDraw *draw,
+ int mode);
+
+/* xftextent.c */
+
+void
+XftGlyphExtents (Display *dpy,
+ XftFont *pub,
+ _Xconst FT_UInt *glyphs,
+ int nglyphs,
+ XGlyphInfo *extents);
+
+void
+XftTextExtents8 (Display *dpy,
+ XftFont *pub,
+ _Xconst FcChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftTextExtents16 (Display *dpy,
+ XftFont *pub,
+ _Xconst FcChar16 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftTextExtents32 (Display *dpy,
+ XftFont *pub,
+ _Xconst FcChar32 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftTextExtentsUtf8 (Display *dpy,
+ XftFont *pub,
+ _Xconst FcChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftTextExtentsUtf16 (Display *dpy,
+ XftFont *pub,
+ _Xconst FcChar8 *string,
+ FcEndian endian,
+ int len,
+ XGlyphInfo *extents);
+
+/* xftfont.c */
+FcPattern *
+XftFontMatch (Display *dpy,
+ int screen,
+ _Xconst FcPattern *pattern,
+ FcResult *result);
+
+XftFont *
+XftFontOpen (Display *dpy, int screen, ...) _X_SENTINEL(0);
+
+XftFont *
+XftFontOpenName (Display *dpy, int screen, _Xconst char *name);
+
+XftFont *
+XftFontOpenXlfd (Display *dpy, int screen, _Xconst char *xlfd);
+
+/* xftfreetype.c */
+
+FT_Face
+XftLockFace (XftFont *pub);
+
+void
+XftUnlockFace (XftFont *pub);
+
+XftFontInfo *
+XftFontInfoCreate (Display *dpy, _Xconst FcPattern *pattern);
+
+void
+XftFontInfoDestroy (Display *dpy, XftFontInfo *fi);
+
+FcChar32
+XftFontInfoHash (_Xconst XftFontInfo *fi);
+
+FcBool
+XftFontInfoEqual (_Xconst XftFontInfo *a, _Xconst XftFontInfo *b);
+
+XftFont *
+XftFontOpenInfo (Display *dpy,
+ FcPattern *pattern,
+ XftFontInfo *fi);
+
+XftFont *
+XftFontOpenPattern (Display *dpy, FcPattern *pattern);
+
+XftFont *
+XftFontCopy (Display *dpy, XftFont *pub);
+
+void
+XftFontClose (Display *dpy, XftFont *pub);
+
+FcBool
+XftInitFtLibrary(void);
+
+/* xftglyphs.c */
+void
+XftFontLoadGlyphs (Display *dpy,
+ XftFont *pub,
+ FcBool need_bitmaps,
+ _Xconst FT_UInt *glyphs,
+ int nglyph);
+
+void
+XftFontUnloadGlyphs (Display *dpy,
+ XftFont *pub,
+ _Xconst FT_UInt *glyphs,
+ int nglyph);
+
+#define XFT_NMISSING 256
+
+FcBool
+XftFontCheckGlyph (Display *dpy,
+ XftFont *pub,
+ FcBool need_bitmaps,
+ FT_UInt glyph,
+ FT_UInt *missing,
+ int *nmissing);
+
+FcBool
+XftCharExists (Display *dpy,
+ XftFont *pub,
+ FcChar32 ucs4);
+
+FT_UInt
+XftCharIndex (Display *dpy,
+ XftFont *pub,
+ FcChar32 ucs4);
+
+/* xftgram.y */
+
+/* xftinit.c */
+FcBool
+XftInit (_Xconst char *config);
+
+int
+XftGetVersion (void);
+
+/* xftlex.l */
+
+/* xftlist.c */
+
+FcFontSet *
+XftListFonts (Display *dpy,
+ int screen,
+ ...) _X_SENTINEL(0);
+
+/* xftmatch.c */
+
+/* xftmatrix.c */
+
+/* xftname.c */
+FcPattern
+*XftNameParse (_Xconst char *name);
+
+/* xftpat.c */
+
+/* xftrender.c */
+void
+XftGlyphRender (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FT_UInt *glyphs,
+ int nglyphs);
+
+void
+XftGlyphSpecRender (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ _Xconst XftGlyphSpec *glyphs,
+ int nglyphs);
+
+void
+XftCharSpecRender (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ _Xconst XftCharSpec *chars,
+ int len);
+
+void
+XftGlyphFontSpecRender (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ int srcx,
+ int srcy,
+ _Xconst XftGlyphFontSpec *glyphs,
+ int nglyphs);
+
+void
+XftCharFontSpecRender (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ int srcx,
+ int srcy,
+ _Xconst XftCharFontSpec *chars,
+ int len);
+
+void
+XftTextRender8 (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len);
+
+void
+XftTextRender16 (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar16 *string,
+ int len);
+
+void
+XftTextRender16BE (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len);
+
+void
+XftTextRender16LE (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len);
+
+void
+XftTextRender32 (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar32 *string,
+ int len);
+
+void
+XftTextRender32BE (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len);
+
+void
+XftTextRender32LE (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len);
+
+void
+XftTextRenderUtf8 (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len);
+
+void
+XftTextRenderUtf16 (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ FcEndian endian,
+ int len);
+
+/* xftstr.c */
+
+/* xftxlfd.c */
+FcPattern *
+XftXlfdParse (_Xconst char *xlfd_orig, Bool ignore_scalable, Bool complete);
+
+_XFUNCPROTOEND
+
+#endif /* _XFT_H_ */
diff --git a/nx-X11/lib/Xft/XftCompat.h b/nx-X11/lib/Xft/XftCompat.h
new file mode 100644
index 000000000..27442d42a
--- /dev/null
+++ b/nx-X11/lib/Xft/XftCompat.h
@@ -0,0 +1,165 @@
+/*
+ * $Id: XftCompat.h,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2001 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _XFTCOMPAT_H_
+#define _XFTCOMPAT_H_
+#include <X11/Xfuncproto.h>
+
+/*
+ * Compatibility definitions -- map Fc names to Xft names
+ */
+
+typedef FcChar8 XftChar8;
+typedef FcChar16 XftChar16;
+typedef FcChar32 XftChar32;
+
+#define XFT_FAMILY FC_FAMILY
+#define XFT_STYLE FC_STYLE
+#define XFT_SLANT FC_SLANT
+#define XFT_WEIGHT FC_WEIGHT
+#define XFT_SIZE FC_SIZE
+#define XFT_PIXEL_SIZE FC_PIXEL_SIZE
+#define XFT_SPACING FC_SPACING
+#define XFT_FOUNDRY FC_FOUNDRY
+#define XFT_ANTIALIAS FC_ANTIALIAS
+#define XFT_FILE FC_FILE
+#define XFT_INDEX FC_INDEX
+#define XFT_RASTERIZER FC_RASTERIZER
+#define XFT_OUTLINE FC_OUTLINE
+#define XFT_SCALABLE FC_SCALABLE
+#define XFT_RGBA FC_RGBA
+
+/* defaults from resources */
+#define XFT_SCALE FC_SCALE
+#define XFT_MINSPACE FC_MINSPACE
+#define XFT_DPI FC_DPI
+
+/* specific to FreeType rasterizer */
+#define XFT_CHAR_WIDTH FC_CHAR_WIDTH
+#define XFT_CHAR_HEIGHT FC_CHAR_HEIGHT
+#define XFT_MATRIX FC_MATRIX
+
+#define XFT_WEIGHT_LIGHT FC_WEIGHT_LIGHT
+#define XFT_WEIGHT_MEDIUM FC_WEIGHT_MEDIUM
+#define XFT_WEIGHT_DEMIBOLD FC_WEIGHT_DEMIBOLD
+#define XFT_WEIGHT_BOLD FC_WEIGHT_BOLD
+#define XFT_WEIGHT_BLACK FC_WEIGHT_BLACK
+
+#define XFT_SLANT_ROMAN FC_SLANT_ROMAN
+#define XFT_SLANT_ITALIC FC_SLANT_ITALIC
+#define XFT_SLANT_OBLIQUE FC_SLANT_OBLIQUE
+
+#define XFT_PROPORTIONAL FC_PROPORTIONAL
+#define XFT_MONO FC_MONO
+#define XFT_CHARCELL FC_CHARCELL
+
+#define XFT_RGBA_UNKNOWN FC_RGBA_UNKNOWN
+#define XFT_RGBA_RGB FC_RGBA_RGB
+#define XFT_RGBA_BGR FC_RGBA_BGR
+#define XFT_RGBA_VRGB FC_RGBA_VRGB
+#define XFT_RGBA_VBGR FC_RGBA_VBGR
+#define XFT_RGBA_NONE FC_RGBA_NONE
+
+/*
+ * Old constants
+ */
+#define XFT_ENCODING "encoding"
+
+typedef FcType XftType;
+
+typedef FcMatrix XftMatrix;
+
+#define XftMatrixInit(m) FcMatrixInit(m)
+
+typedef FcResult XftResult;
+
+#define XftResultMatch FcResultMatch
+#define XftResultNoMatch FcResultNoMatch
+#define XftResultTypeMismatch FcResultTypeMismatch
+#define XftResultNoId FcResultNoId
+
+typedef FcValue XftValue;
+typedef FcPattern XftPattern;
+typedef FcFontSet XftFontSet;
+typedef FcObjectSet XftObjectSet;
+
+#define XftGlyphExists XftCharExists
+
+#define XftObjectSetCreate FcObjectSetCreate
+#define XftObjectSetAdd FcObjectSetAdd
+#define XftObjectSetDestroy FcObjectSetDestroy
+#define XftObjectSetVaBuild FcObjectSetVaBuild
+#define XftObjectSetBuild FcObjectSetBuild
+
+#define XftFontSetMatch FcFontSetMatch
+#define XftFontSetDestroy FcFontSetDestroy
+
+#define XftMatrixEqual FcMatrixEqual
+#define XftMatrixMultiply FcMatrixMultiply
+#define XftMatrixRotate FcMatrixRotate
+#define XftMatrixScale FcMatrixScale
+#define XftMatrixShear FcMatrixShear
+
+#define XftPatternCreate FcPatternCreate
+#define XftPatternDuplicate FcPatternDuplicate
+#define XftValueDestroy FcValueDestroy
+#define XftValueListDestroy FcValueListDestroy
+#define XftPatternDestroy FcPatternDestroy
+#define XftPatternFind FcPatternFind
+#define XftPatternAdd FcPatternAdd
+#define XftPatternGet FcPatternGet
+#define XftPatternDel FcPatternDel
+#define XftPatternAddInteger FcPatternAddInteger
+#define XftPatternAddDouble FcPatternAddDouble
+#define XftPatternAddString(p,e,s) FcPatternAddString(p,e,(FcChar8 *)(s))
+#define XftPatternAddMatrix FcPatternAddMatrix
+#define XftPatternAddBool FcPatternAddBool
+#define XftPatternGetInteger FcPatternGetInteger
+#define XftPatternGetDouble FcPatternGetDouble
+#define XftPatternGetString(p,e,i,n) FcPatternGetString(p,e,i,(FcChar8 **) (n))
+#define XftPatternGetMatrix FcPatternGetMatrix
+#define XftPatternGetBool FcPatternGetBool
+#define XftPatternVaBuild FcPatternVaBuild
+#define XftPatternBuild FcPatternBuild
+
+#define XftUtf8ToUcs4 FcUtf8ToUcs4
+#define XftUtf8Len FcUtf8Len
+
+#define XftTypeVoid FcTypeVoid
+#define XftTypeInteger FcTypeInteger
+#define XftTypeDouble FcTypeDouble
+#define XftTypeString FcTypeString
+#define XftTypeBool FcTypeBool
+#define XftTypeMatrix FcTypeMatrix
+
+#define XftConfigSubstitute(p) FcConfigSubstitute (0, p, FcMatchPattern)
+
+_XFUNCPROTOBEGIN
+
+FcBool
+XftNameUnparse (XftPattern *pat, char *dest, int len);
+
+_XFUNCPROTOEND
+
+#endif /* _XFTCOMPAT_H_ */
diff --git a/nx-X11/lib/Xft/aclocal.m4 b/nx-X11/lib/Xft/aclocal.m4
new file mode 100644
index 000000000..901ff4099
--- /dev/null
+++ b/nx-X11/lib/Xft/aclocal.m4
@@ -0,0 +1,6858 @@
+# generated automatically by aclocal 1.7.9 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+# Do all the work for Automake. -*- Autoconf -*-
+
+# This macro actually does too much some checks are only needed if
+# your package does certain things. But this isn't really a big deal.
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+# Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 10
+
+AC_PREREQ([2.54])
+
+# Autoconf 2.50 wants to disallow AM_ names. We explicitly allow
+# the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out. PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition. After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+ AC_REQUIRE([AC_PROG_INSTALL])dnl
+# test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" &&
+ test -f $srcdir/config.status; then
+ AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+ if (cygpath --version) >/dev/null 2>/dev/null; then
+ CYGPATH_W='cygpath -w'
+ else
+ CYGPATH_W=echo
+ fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
+AM_MISSING_PROG(AUTOCONF, autoconf)
+AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
+AM_MISSING_PROG(AUTOHEADER, autoheader)
+AM_MISSING_PROG(MAKEINFO, makeinfo)
+AM_MISSING_PROG(AMTAR, tar)
+AM_PROG_INSTALL_SH
+AM_PROG_INSTALL_STRIP
+# We need awk for the "check" target. The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+ [_AM_DEPENDENCIES(CC)],
+ [define([AC_PROG_CC],
+ defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [_AM_DEPENDENCIES(CXX)],
+ [define([AC_PROG_CXX],
+ defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+])
+])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated. The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+ case $_am_header in
+ $1 | $1:* )
+ break ;;
+ * )
+ _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+ esac
+done
+echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
+
+# Copyright 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.7"])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION so it can be traced.
+# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+ [AM_AUTOMAKE_VERSION([1.7.9])])
+
+# Helper functions for option handling. -*- Autoconf -*-
+
+# Copyright 2001, 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 2
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# ------------------------------
+# Set option NAME. Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+#
+# Check to make sure that the build environment is sane.
+#
+
+# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 3
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+ if test "$[*]" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftest.file`
+ fi
+ rm -f conftest.file
+ if test "$[*]" != "X $srcdir/configure conftest.file" \
+ && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
+alias in your environment])
+ fi
+
+ test "$[2]" = conftest.file
+ )
+then
+ # Ok.
+ :
+else
+ AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT(yes)])
+
+# -*- Autoconf -*-
+
+
+# Copyright 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 3
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it supports --run.
+# If it does, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+ am_missing_run="$MISSING --run "
+else
+ am_missing_run=
+ AC_MSG_WARN([`missing' script is too old or missing])
+fi
+])
+
+# AM_AUX_DIR_EXPAND
+
+# Copyright 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
+# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory. The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run. This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+# fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+# fails if $ac_aux_dir is absolute,
+# fails when called from a subdirectory in a VPATH build with
+# a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir. In an in-source build this is usually
+# harmless because $srcdir is `.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
+# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+# MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH. The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+# Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])
+
+AC_DEFUN([AM_AUX_DIR_EXPAND], [
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+
+# Copyright 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+install_sh=${install_sh-"$am_aux_dir/install-sh"}
+AC_SUBST(install_sh)])
+
+# AM_PROG_INSTALL_STRIP
+
+# Copyright 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# One issue with vendor `install' (even GNU) is that you can't
+# specify the program used to strip binaries. This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in `make install-strip', and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'. However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+if test "$cross_compiling" != no; then
+ AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# -*- Autoconf -*-
+# Copyright (C) 2003 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 1
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot. For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+ am__leading_dot=.
+else
+ am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# serial 5 -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+
+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery. Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
+ [$1], CXX, [depcc="$CXX" am_compiler_list=],
+ [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+ [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
+ [depcc="$$1" am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+ [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named `D' -- because `-MD' means `put the output
+ # in D'.
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_$1_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+ fi
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ : > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ case $depmode in
+ nosideeffect)
+ # after this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ none) break ;;
+ esac
+ # We check with `-c' and `-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle `-M -o', and we need to detect this.
+ if depmode=$depmode \
+ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored.
+ if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
+ am_cv_$1_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE(dependency-tracking,
+[ --disable-dependency-tracking Speeds up one-time builds
+ --enable-dependency-tracking Do not reject slow dependency extractors])
+if test "x$enable_dependency_tracking" != xno; then
+ am_depcomp="$ac_aux_dir/depcomp"
+ AMDEPBACKSLASH='\'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])
+])
+
+# Generate code to set up dependency tracking. -*- Autoconf -*-
+
+# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+#serial 2
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[for mf in $CONFIG_FILES; do
+ # Strip MF so we end up with the name of the file.
+ mf=`echo "$mf" | sed -e 's/:.*$//'`
+ # Check whether this is an Automake generated Makefile or not.
+ # We used to match only the files named `Makefile.in', but
+ # some people rename them; so instead we look at the file content.
+ # Grep'ing the first line is not enough: some people post-process
+ # each Makefile.in and add a new line on top of each file to say so.
+ # So let's grep whole file.
+ if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
+ dirpart=`AS_DIRNAME("$mf")`
+ else
+ continue
+ fi
+ grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue
+ # Extract the definition of DEP_FILES from the Makefile without
+ # running `make'.
+ DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
+ test -z "$DEPDIR" && continue
+ # When using ansi2knr, U may be empty or an underscore; expand it
+ U=`sed -n -e '/^U = / s///p' < "$mf"`
+ test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
+ # We invoke sed twice because it is the simplest approach to
+ # changing $(DEPDIR) to its actual value in the expansion.
+ for file in `sed -n -e '
+ /^DEP_FILES = .*\\\\$/ {
+ s/^DEP_FILES = //
+ :loop
+ s/\\\\$//
+ p
+ n
+ /\\\\$/ b loop
+ p
+ }
+ /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
+ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+ # Make sure the directory exists.
+ test -f "$dirpart/$file" && continue
+ fdir=`AS_DIRNAME(["$file"])`
+ AS_MKDIR_P([$dirpart/$fdir])
+ # echo "creating $dirpart/$file"
+ echo '# dummy' > "$dirpart/$file"
+ done
+done
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled. FIXME. This creates each `.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+ [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+ [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Check to see how 'make' treats includes. -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 2
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+ @echo done
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# We grep out `Entering directory' and `Leaving directory'
+# messages which can occur if `w' ends up in MAKEFLAGS.
+# In particular we don't look at `^make:' because GNU make might
+# be invoked under some other name (usually "gmake"), in which
+# case it prints its new name instead of `make'.
+if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
+ am__include=include
+ am__quote=
+ _am_result=GNU
+fi
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+ echo '.include "confinc"' > confmf
+ if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
+ am__include=.include
+ am__quote="\""
+ _am_result=BSD
+ fi
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# AM_CONDITIONAL -*- Autoconf -*-
+
+# Copyright 1997, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 5
+
+AC_PREREQ(2.52)
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
+ [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])
+AC_SUBST([$1_FALSE])
+if $2; then
+ $1_TRUE=
+ $1_FALSE='#'
+else
+ $1_TRUE='#'
+ $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+ AC_MSG_ERROR([conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.])
+fi])])
+
+# Add --enable-maintainer-mode option to configure.
+# From Jim Meyering
+
+# Copyright 1996, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 2
+
+AC_DEFUN([AM_MAINTAINER_MODE],
+[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
+ dnl maintainer-mode is disabled by default
+ AC_ARG_ENABLE(maintainer-mode,
+[ --enable-maintainer-mode enable make rules and dependencies not useful
+ (and sometimes confusing) to the casual installer],
+ USE_MAINTAINER_MODE=$enableval,
+ USE_MAINTAINER_MODE=no)
+ AC_MSG_RESULT([$USE_MAINTAINER_MODE])
+ AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes])
+ MAINT=$MAINTAINER_MODE_TRUE
+ AC_SUBST(MAINT)dnl
+]
+)
+
+AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
+
+# Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*-
+
+# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+AC_PREREQ([2.52])
+
+# serial 6
+
+# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS.
+AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
+
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+
+# serial 47 AC_PROG_LIBTOOL
+# Debian $Rev: 192 $
+
+
+# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
+# -----------------------------------------------------------
+# If this macro is not defined by Autoconf, define it here.
+m4_ifdef([AC_PROVIDE_IFELSE],
+ [],
+ [m4_define([AC_PROVIDE_IFELSE],
+ [m4_ifdef([AC_PROVIDE_$1],
+ [$2], [$3])])])
+
+
+# AC_PROG_LIBTOOL
+# ---------------
+AC_DEFUN([AC_PROG_LIBTOOL],
+[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
+dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
+dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
+ AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [AC_LIBTOOL_CXX],
+ [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
+ ])])
+dnl And a similar setup for Fortran 77 support
+ AC_PROVIDE_IFELSE([AC_PROG_F77],
+ [AC_LIBTOOL_F77],
+ [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
+])])
+
+dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
+dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
+dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
+ AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+ [AC_LIBTOOL_GCJ],
+ [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+ [AC_LIBTOOL_GCJ],
+ [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
+ [AC_LIBTOOL_GCJ],
+ [ifdef([AC_PROG_GCJ],
+ [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+ ifdef([A][M_PROG_GCJ],
+ [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+ ifdef([LT_AC_PROG_GCJ],
+ [define([LT_AC_PROG_GCJ],
+ defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
+])])# AC_PROG_LIBTOOL
+
+
+# _AC_PROG_LIBTOOL
+# ----------------
+AC_DEFUN([_AC_PROG_LIBTOOL],
+[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+# Prevent multiple expansion
+define([AC_PROG_LIBTOOL], [])
+])# _AC_PROG_LIBTOOL
+
+
+# AC_LIBTOOL_SETUP
+# ----------------
+AC_DEFUN([AC_LIBTOOL_SETUP],
+[AC_PREREQ(2.50)dnl
+AC_REQUIRE([AC_ENABLE_SHARED])dnl
+AC_REQUIRE([AC_ENABLE_STATIC])dnl
+AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_LD])dnl
+AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
+AC_REQUIRE([AC_PROG_NM])dnl
+
+AC_REQUIRE([AC_PROG_LN_S])dnl
+AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
+# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
+AC_REQUIRE([AC_OBJEXT])dnl
+AC_REQUIRE([AC_EXEEXT])dnl
+dnl
+
+AC_LIBTOOL_SYS_MAX_CMD_LEN
+AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+AC_LIBTOOL_OBJDIR
+
+AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+_LT_AC_PROG_ECHO_BACKSLASH
+
+case $host_os in
+aix3*)
+ # AIX sometimes has problems with the GCC collect2 program. For some
+ # reason, if we set the COLLECT_NAMES environment variable, the problems
+ # vanish in a puff of smoke.
+ if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+ fi
+ ;;
+esac
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e s/^X//'
+[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
+
+# Same as above, but do not quote variable references.
+[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g']
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Constants:
+rm="rm -f"
+
+# Global variables:
+default_ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except M$VC,
+# which needs '.lib').
+libext=a
+ltmain="$ac_aux_dir/ltmain.sh"
+ofile="$default_ofile"
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+AC_CHECK_TOOL(AR, ar, false)
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+AC_CHECK_TOOL(STRIP, strip, :)
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+test -z "$AS" && AS=as
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+test -z "$LD" && LD=ld
+test -z "$LN_S" && LN_S="ln -s"
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+test -z "$NM" && NM=nm
+test -z "$SED" && SED=sed
+test -z "$OBJDUMP" && OBJDUMP=objdump
+test -z "$RANLIB" && RANLIB=:
+test -z "$STRIP" && STRIP=:
+test -z "$ac_objext" && ac_objext=o
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+ case $host_os in
+ openbsd*)
+ old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds"
+ ;;
+ *)
+ old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+ ;;
+ esac
+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+# Only perform the check for file, if the check method requires it
+case $deplibs_check_method in
+file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+ AC_PATH_MAGIC
+ fi
+ ;;
+esac
+
+AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
+AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+enable_win32_dll=yes, enable_win32_dll=no)
+
+AC_ARG_ENABLE([libtool-lock],
+ [AC_HELP_STRING([--disable-libtool-lock],
+ [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+AC_ARG_WITH([pic],
+ [AC_HELP_STRING([--with-pic],
+ [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+ [pic_mode="$withval"],
+ [pic_mode=default])
+test -z "$pic_mode" && pic_mode=default
+
+# Use C for the default configuration in the libtool script
+tagname=
+AC_LIBTOOL_LANG_C_CONFIG
+_LT_AC_TAGCONFIG
+])# AC_LIBTOOL_SETUP
+
+
+# _LT_AC_SYS_COMPILER
+# -------------------
+AC_DEFUN([_LT_AC_SYS_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_AC_SYS_COMPILER
+
+
+# _LT_AC_SYS_LIBPATH_AIX
+# ----------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
+[AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`; fi],[])
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+])# _LT_AC_SYS_LIBPATH_AIX
+
+
+# _LT_AC_SHELL_INIT(ARG)
+# ----------------------
+AC_DEFUN([_LT_AC_SHELL_INIT],
+[ifdef([AC_DIVERSION_NOTICE],
+ [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+ [AC_DIVERT_PUSH(NOTICE)])
+$1
+AC_DIVERT_POP
+])# _LT_AC_SHELL_INIT
+
+
+# _LT_AC_PROG_ECHO_BACKSLASH
+# --------------------------
+# Add some code to the start of the generated configure script which
+# will find an echo command which doesn't interpret backslashes.
+AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH],
+[_LT_AC_SHELL_INIT([
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$ECHO in
+X*--fallback-echo)
+ # Remove one level of quotation (which was required for Make).
+ ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+ ;;
+esac
+
+echo=${ECHO-echo}
+if test "X[$]1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+elif test "X[$]1" = X--fallback-echo; then
+ # Avoid inline document here, it may be left over
+ :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
+ # Yippee, $echo works!
+ :
+else
+ # Restart under the correct shell.
+ exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+fi
+
+if test "X[$]1" = X--fallback-echo; then
+ # used as fallback echo
+ shift
+ cat <<EOF
+[$]*
+EOF
+ exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
+
+if test -z "$ECHO"; then
+if test "X${echo_test_string+set}" != Xset; then
+# find a string as large as possible, as long as the shell can cope with it
+ for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
+ # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+ if (echo_test_string="`eval $cmd`") 2>/dev/null &&
+ echo_test_string="`eval $cmd`" &&
+ (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
+ then
+ break
+ fi
+ done
+fi
+
+if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ :
+else
+ # The Solaris, AIX, and Digital Unix default echo programs unquote
+ # backslashes. This makes it impossible to quote backslashes using
+ # echo "$something" | sed 's/\\/\\\\/g'
+ #
+ # So, first we look for a working echo in the user's PATH.
+
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for dir in $PATH /usr/ucb; do
+ IFS="$lt_save_ifs"
+ if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+ test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ echo="$dir/echo"
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+
+ if test "X$echo" = Xecho; then
+ # We didn't find a better echo, so look for alternatives.
+ if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ # This shell has a builtin print -r that does the trick.
+ echo='print -r'
+ elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+ test "X$CONFIG_SHELL" != X/bin/ksh; then
+ # If we have ksh, try running configure again with it.
+ ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+ export ORIGINAL_CONFIG_SHELL
+ CONFIG_SHELL=/bin/ksh
+ export CONFIG_SHELL
+ exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
+ else
+ # Try using printf.
+ echo='printf %s\n'
+ if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ # Cool, printf works
+ :
+ elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+ test "X$echo_testing_string" = 'X\t' &&
+ echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+ export CONFIG_SHELL
+ SHELL="$CONFIG_SHELL"
+ export SHELL
+ echo="$CONFIG_SHELL [$]0 --fallback-echo"
+ elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+ test "X$echo_testing_string" = 'X\t' &&
+ echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ echo="$CONFIG_SHELL [$]0 --fallback-echo"
+ else
+ # maybe with a smaller string...
+ prev=:
+
+ for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
+ if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
+ then
+ break
+ fi
+ prev="$cmd"
+ done
+
+ if test "$prev" != 'sed 50q "[$]0"'; then
+ echo_test_string=`eval $prev`
+ export echo_test_string
+ exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
+ else
+ # Oops. We lost completely, so just stick with echo.
+ echo=echo
+ fi
+ fi
+ fi
+ fi
+fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+ECHO=$echo
+if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+ ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+fi
+
+AC_SUBST(ECHO)
+])])# _LT_AC_PROG_ECHO_BACKSLASH
+
+
+# _LT_AC_LOCK
+# -----------
+AC_DEFUN([_LT_AC_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+ [AC_HELP_STRING([--disable-libtool-lock],
+ [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *ELF-32*)
+ HPUX_IA64_MODE="32"
+ ;;
+ *ELF-64*)
+ HPUX_IA64_MODE="64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+*-*-irix6*)
+ # Find out which ABI we are using.
+ echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -melf32bsmip"
+ ;;
+ *N32*)
+ LD="${LD-ld} -melf32bmipn32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -melf64bmip"
+ ;;
+ esac
+ else
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
+ fi
+ rm -rf conftest*
+ ;;
+
+x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case "`/usr/bin/file conftest.o`" in
+ *32-bit*)
+ case $host in
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_i386"
+ ;;
+ ppc64-*linux*|powerpc64-*linux*)
+ LD="${LD-ld} -m elf32ppclinux"
+ ;;
+ s390x-*linux*)
+ LD="${LD-ld} -m elf_s390"
+ ;;
+ sparc64-*linux*)
+ LD="${LD-ld} -m elf32_sparc"
+ ;;
+ esac
+ ;;
+ *64-bit*)
+ case $host in
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ ppc*-*linux*|powerpc*-*linux*)
+ LD="${LD-ld} -m elf64ppc"
+ ;;
+ s390*-*linux*)
+ LD="${LD-ld} -m elf64_s390"
+ ;;
+ sparc*-*linux*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+*-*-sco3.2v5*)
+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -belf"
+ AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+ [AC_LANG_PUSH(C)
+ AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+ AC_LANG_POP])
+ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+ CFLAGS="$SAVE_CFLAGS"
+ fi
+ ;;
+AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+ AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+ AC_CHECK_TOOL(AS, as, false)
+ AC_CHECK_TOOL(OBJDUMP, objdump, false)
+ ;;
+ ])
+esac
+
+need_locks="$enable_libtool_lock"
+
+])# _LT_AC_LOCK
+
+
+# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
+[AC_REQUIRE([LT_AC_PROG_SED])
+AC_CACHE_CHECK([$1], [$2],
+ [$2=no
+ ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$3"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test ! -s conftest.err; then
+ $2=yes
+ fi
+ fi
+ $rm conftest*
+])
+
+if test x"[$]$2" = xyes; then
+ ifelse([$5], , :, [$5])
+else
+ ifelse([$6], , :, [$6])
+fi
+])# AC_LIBTOOL_COMPILER_OPTION
+
+
+# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+# [ACTION-SUCCESS], [ACTION-FAILURE])
+# ------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
+[AC_CACHE_CHECK([$1], [$2],
+ [$2=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $3"
+ printf "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&AS_MESSAGE_LOG_FD
+ else
+ $2=yes
+ fi
+ fi
+ $rm conftest*
+ LDFLAGS="$save_LDFLAGS"
+])
+
+if test x"[$]$2" = xyes; then
+ ifelse([$4], , :, [$4])
+else
+ ifelse([$5], , :, [$5])
+fi
+])# AC_LIBTOOL_LINKER_OPTION
+
+
+# AC_LIBTOOL_SYS_MAX_CMD_LEN
+# --------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN],
+[# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+ i=0
+ testring="ABCD"
+
+ case $build_os in
+ msdosdjgpp*)
+ # On DJGPP, this test can blow up pretty badly due to problems in libc
+ # (any single argument exceeding 2000 bytes causes a buffer overrun
+ # during glob expansion). Even if it were fixed, the result of this
+ # check would be larger than it should be.
+ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+
+ gnu*)
+ # Under GNU Hurd, this test is not required because there is
+ # no limit to the length of command line arguments.
+ # Libtool will interpret -1 as no limit whatsoever
+ lt_cv_sys_max_cmd_len=-1;
+ ;;
+
+ cygwin* | mingw*)
+ # On Win9x/ME, this test blows up -- it succeeds, but takes
+ # about 5 minutes as the teststring grows exponentially.
+ # Worse, since 9x/ME are not pre-emptively multitasking,
+ # you end up with a "frozen" computer, even though with patience
+ # the test eventually succeeds (with a max line length of 256k).
+ # Instead, let's just punt: use the minimum linelength reported by
+ # all of the supported platforms: 8192 (on NT/2K/XP).
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ amigaos*)
+ # On AmigaOS with pdksh, this test takes hours, literally.
+ # So we just punt and use a minimum line length of 8192.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ *)
+ # If test is not a shell built-in, we'll probably end up computing a
+ # maximum length that is only half of the actual maximum length, but
+ # we can't tell.
+ while (test "X"`$CONFIG_SHELL [$]0 --fallback-echo "X$testring" 2>/dev/null` \
+ = "XX$testring") >/dev/null 2>&1 &&
+ new_result=`expr "X$testring" : ".*" 2>&1` &&
+ lt_cv_sys_max_cmd_len=$new_result &&
+ test $i != 17 # 1/2 MB should be enough
+ do
+ i=`expr $i + 1`
+ testring=$testring$testring
+ done
+ testring=
+ # Add a significant safety factor because C++ compilers can tack on massive
+ # amounts of additional arguments before passing them to the linker.
+ # It appears as though 1/2 is a usable value.
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+ ;;
+ esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+ AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+ AC_MSG_RESULT(none)
+fi
+])# AC_LIBTOOL_SYS_MAX_CMD_LEN
+
+
+# _LT_AC_CHECK_DLFCN
+# --------------------
+AC_DEFUN([_LT_AC_CHECK_DLFCN],
+[AC_CHECK_HEADERS(dlfcn.h)dnl
+])# _LT_AC_CHECK_DLFCN
+
+
+# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ------------------------------------------------------------------
+AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
+[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+ [$4]
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<EOF
+[#line __oline__ "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ /* dlclose (self); */
+ }
+
+ exit (status);
+}]
+EOF
+ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) $1 ;;
+ x$lt_dlneed_uscore) $2 ;;
+ x$lt_unknown|x*) $3 ;;
+ esac
+ else :
+ # compilation failed
+ $3
+ fi
+fi
+rm -fr conftest*
+])# _LT_AC_TRY_DLOPEN_SELF
+
+
+# AC_LIBTOOL_DLOPEN_SELF
+# -------------------
+AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
+[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+if test "x$enable_dlopen" != xyes; then
+ enable_dlopen=unknown
+ enable_dlopen_self=unknown
+ enable_dlopen_self_static=unknown
+else
+ lt_cv_dlopen=no
+ lt_cv_dlopen_libs=
+
+ case $host_os in
+ beos*)
+ lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ;;
+
+ mingw* | pw32*)
+ lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen_libs=
+ ;;
+
+ cygwin*)
+ lt_cv_dlopen="dlopen"
+ lt_cv_dlopen_libs=
+ ;;
+
+ darwin*)
+ # if libdl is installed we need to link against it
+ AC_CHECK_LIB([dl], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+ lt_cv_dlopen="dyld"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ])
+ ;;
+
+ *)
+ AC_CHECK_FUNC([shl_load],
+ [lt_cv_dlopen="shl_load"],
+ [AC_CHECK_LIB([dld], [shl_load],
+ [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
+ [AC_CHECK_FUNC([dlopen],
+ [lt_cv_dlopen="dlopen"],
+ [AC_CHECK_LIB([dl], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+ [AC_CHECK_LIB([svld], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+ [AC_CHECK_LIB([dld], [dld_link],
+ [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
+ ])
+ ])
+ ])
+ ])
+ ])
+ ;;
+ esac
+
+ if test "x$lt_cv_dlopen" != xno; then
+ enable_dlopen=yes
+ else
+ enable_dlopen=no
+ fi
+
+ case $lt_cv_dlopen in
+ dlopen)
+ save_CPPFLAGS="$CPPFLAGS"
+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+ save_LDFLAGS="$LDFLAGS"
+ eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+ save_LIBS="$LIBS"
+ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+ AC_CACHE_CHECK([whether a program can dlopen itself],
+ lt_cv_dlopen_self, [dnl
+ _LT_AC_TRY_DLOPEN_SELF(
+ lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+ lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+ ])
+
+ if test "x$lt_cv_dlopen_self" = xyes; then
+ LDFLAGS="$LDFLAGS $link_static_flag"
+ AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+ lt_cv_dlopen_self_static, [dnl
+ _LT_AC_TRY_DLOPEN_SELF(
+ lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+ lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
+ ])
+ fi
+
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
+ ;;
+ esac
+
+ case $lt_cv_dlopen_self in
+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+ *) enable_dlopen_self=unknown ;;
+ esac
+
+ case $lt_cv_dlopen_self_static in
+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+ *) enable_dlopen_self_static=unknown ;;
+ esac
+fi
+])# AC_LIBTOOL_DLOPEN_SELF
+
+
+# AC_LIBTOOL_PROG_CC_C_O([TAGNAME])
+# ---------------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler
+AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
+[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+ [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+ [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+ $rm -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&AS_MESSAGE_LOG_FD
+ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test ! -s out/conftest.err; then
+ _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+ fi
+ fi
+ chmod u+w .
+ $rm conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+ $rm out/* && rmdir out
+ cd ..
+ rmdir conftest
+ $rm conftest*
+])
+])# AC_LIBTOOL_PROG_CC_C_O
+
+
+# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME])
+# -----------------------------------------
+# Check to see if we can do hard links to lock some files if needed
+AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS],
+[AC_REQUIRE([_LT_AC_LOCK])dnl
+
+hard_links="nottested"
+if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ AC_MSG_CHECKING([if we can lock with hard links])
+ hard_links=yes
+ $rm conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ AC_MSG_RESULT([$hard_links])
+ if test "$hard_links" = no; then
+ AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS
+
+
+# AC_LIBTOOL_OBJDIR
+# -----------------
+AC_DEFUN([AC_LIBTOOL_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+ lt_cv_objdir=.libs
+else
+ # MS-DOS does not allow filenames that begin with a dot.
+ lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+])# AC_LIBTOOL_OBJDIR
+
+
+# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME])
+# ----------------------------------------------
+# Check hardcoding attributes.
+AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_AC_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
+ test -n "$_LT_AC_TAGVAR(runpath_var $1)" || \
+ test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)"="Xyes" ; then
+
+ # We can hardcode non-existant directories.
+ if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+ test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then
+ # Linking always hardcodes the temporary library directory.
+ _LT_AC_TAGVAR(hardcode_action, $1)=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ _LT_AC_TAGVAR(hardcode_action, $1)=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ _LT_AC_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH
+
+
+# AC_LIBTOOL_SYS_LIB_STRIP
+# ------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP],
+[striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+ AC_MSG_RESULT([yes])
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+ case $host_os in
+ darwin*)
+ if test -n "$STRIP" ; then
+ striplib="$STRIP -x"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+fi
+ ;;
+ *)
+ AC_MSG_RESULT([no])
+ ;;
+ esac
+fi
+])# AC_LIBTOOL_SYS_LIB_STRIP
+
+
+# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
+[AC_MSG_CHECKING([dynamic linker characteristics])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+if test "$GCC" = yes; then
+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+ # if the path contains ";" then we assume it to be the separator
+ # otherwise default to the standard path separator (i.e. ":") - it is
+ # assumed that no part of a normal pathname contains ";" but that should
+ # okay in the real world where ";" in dirpaths is itself problematic.
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+else
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix4* | aix5*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[[01]] | aix4.[[01]].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi4*)
+ version_type=linux
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32*)
+ version_type=windows
+ shrext=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$host_os in
+ yes,cygwin* | yes,mingw* | yes,pw32*)
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $rm \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+ ;;
+ mingw*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then
+ # It is most probably a Windows format PATH printed by
+ # mingw gcc, but we are running on Cygwin. Gcc prints its search
+ # path with ; separators, and with drive letters. We can handle the
+ # drive letters (cygwin fileutils understands them), so leave them,
+ # especially as we might pass files found there to a mingw objdump,
+ # which wouldn't understand a cygwinified path. Ahh.
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ ;;
+
+ *)
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext='$(test .$module = .yes && echo .so || echo .dylib)'
+ # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+ if test "$GCC" = yes; then
+ sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+ else
+ sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+ fi
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd1*)
+ dynamic_linker=no
+ ;;
+
+kfreebsd*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='GNU ld.so'
+ ;;
+
+freebsd*)
+ objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.[01]* | freebsdelf3.[01]*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ *) # from 3.2 on
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case "$host_cpu" in
+ ia64*)
+ shrext='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555.
+ postinstall_cmds='chmod 555 $lib'
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be Linux ELF.
+linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ ld_extra=`$SED -e 's/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g' /etc/ld.so.conf`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $ld_extra"
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+knetbsd*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='GNU ld.so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+nto-qnx*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+openbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=yes
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[[89]] | openbsd2.[[89]].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+sco3.2v5*)
+ version_type=osf
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+solaris*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ export_dynamic_flag_spec='${wl}-Blargedynsym'
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+uts4*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+
+
+# _LT_AC_TAGCONFIG
+# ----------------
+AC_DEFUN([_LT_AC_TAGCONFIG],
+[AC_ARG_WITH([tags],
+ [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@],
+ [include additional configurations @<:@automatic@:>@])],
+ [tagnames="$withval"])
+
+if test -f "$ltmain" && test -n "$tagnames"; then
+ if test ! -f "${ofile}"; then
+ AC_MSG_WARN([output file `$ofile' does not exist])
+ fi
+
+ if test -z "$LTCC"; then
+ eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+ if test -z "$LTCC"; then
+ AC_MSG_WARN([output file `$ofile' does not look like a libtool script])
+ else
+ AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
+ fi
+ fi
+
+ # Extract list of available tagged configurations in $ofile.
+ # Note that this assumes the entire list is on one line.
+ available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
+
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for tagname in $tagnames; do
+ IFS="$lt_save_ifs"
+ # Check whether tagname contains only valid characters
+ case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in
+ "") ;;
+ *) AC_MSG_ERROR([invalid tag name: $tagname])
+ ;;
+ esac
+
+ if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
+ then
+ AC_MSG_ERROR([tag name \"$tagname\" already exists])
+ fi
+
+ # Update the list of available tags.
+ if test -n "$tagname"; then
+ echo appending configuration tag \"$tagname\" to $ofile
+
+ case $tagname in
+ CXX)
+ if test -n "$CXX" && test "X$CXX" != "Xno"; then
+ AC_LIBTOOL_LANG_CXX_CONFIG
+ else
+ tagname=""
+ fi
+ ;;
+
+ F77)
+ if test -n "$F77" && test "X$F77" != "Xno"; then
+ AC_LIBTOOL_LANG_F77_CONFIG
+ else
+ tagname=""
+ fi
+ ;;
+
+ GCJ)
+ if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+ AC_LIBTOOL_LANG_GCJ_CONFIG
+ else
+ tagname=""
+ fi
+ ;;
+
+ RC)
+ AC_LIBTOOL_LANG_RC_CONFIG
+ ;;
+
+ *)
+ AC_MSG_ERROR([Unsupported tag name: $tagname])
+ ;;
+ esac
+
+ # Append the new tag name to the list of available tags.
+ if test -n "$tagname" ; then
+ available_tags="$available_tags $tagname"
+ fi
+ fi
+ done
+ IFS="$lt_save_ifs"
+
+ # Now substitute the updated list of available tags.
+ if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
+ mv "${ofile}T" "$ofile"
+ chmod +x "$ofile"
+ else
+ rm -f "${ofile}T"
+ AC_MSG_ERROR([unable to update list of available tagged configurations.])
+ fi
+fi
+])# _LT_AC_TAGCONFIG
+
+
+# AC_LIBTOOL_DLOPEN
+# -----------------
+# enable checks for dlopen support
+AC_DEFUN([AC_LIBTOOL_DLOPEN],
+ [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])
+])# AC_LIBTOOL_DLOPEN
+
+
+# AC_LIBTOOL_WIN32_DLL
+# --------------------
+# declare package support for building win32 dll's
+AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
+])# AC_LIBTOOL_WIN32_DLL
+
+
+# AC_ENABLE_SHARED([DEFAULT])
+# ---------------------------
+# implement the --enable-shared flag
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+AC_DEFUN([AC_ENABLE_SHARED],
+[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE([shared],
+ [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+ [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])],
+ [p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_shared=yes ;;
+ no) enable_shared=no ;;
+ *)
+ enable_shared=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_shared=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac],
+ [enable_shared=]AC_ENABLE_SHARED_DEFAULT)
+])# AC_ENABLE_SHARED
+
+
+# AC_DISABLE_SHARED
+# -----------------
+#- set the default shared flag to --disable-shared
+AC_DEFUN([AC_DISABLE_SHARED],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_SHARED(no)
+])# AC_DISABLE_SHARED
+
+
+# AC_ENABLE_STATIC([DEFAULT])
+# ---------------------------
+# implement the --enable-static flag
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+AC_DEFUN([AC_ENABLE_STATIC],
+[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE([static],
+ [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+ [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])],
+ [p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_static=yes ;;
+ no) enable_static=no ;;
+ *)
+ enable_static=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_static=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac],
+ [enable_static=]AC_ENABLE_STATIC_DEFAULT)
+])# AC_ENABLE_STATIC
+
+
+# AC_DISABLE_STATIC
+# -----------------
+# set the default static flag to --disable-static
+AC_DEFUN([AC_DISABLE_STATIC],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_STATIC(no)
+])# AC_DISABLE_STATIC
+
+
+# AC_ENABLE_FAST_INSTALL([DEFAULT])
+# ---------------------------------
+# implement the --enable-fast-install flag
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+AC_DEFUN([AC_ENABLE_FAST_INSTALL],
+[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE([fast-install],
+ [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+ [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+ [p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_fast_install=yes ;;
+ no) enable_fast_install=no ;;
+ *)
+ enable_fast_install=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_fast_install=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac],
+ [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT)
+])# AC_ENABLE_FAST_INSTALL
+
+
+# AC_DISABLE_FAST_INSTALL
+# -----------------------
+# set the default to --disable-fast-install
+AC_DEFUN([AC_DISABLE_FAST_INSTALL],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_FAST_INSTALL(no)
+])# AC_DISABLE_FAST_INSTALL
+
+
+# AC_LIBTOOL_PICMODE([MODE])
+# --------------------------
+# implement the --with-pic flag
+# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
+AC_DEFUN([AC_LIBTOOL_PICMODE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+pic_mode=ifelse($#,1,$1,default)
+])# AC_LIBTOOL_PICMODE
+
+
+# AC_PROG_EGREP
+# -------------
+# This is predefined starting with Autoconf 2.54, so this conditional
+# definition can be removed once we require Autoconf 2.54 or later.
+m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP],
+[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
+ [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+ then ac_cv_prog_egrep='grep -E'
+ else ac_cv_prog_egrep='egrep'
+ fi])
+ EGREP=$ac_cv_prog_egrep
+ AC_SUBST([EGREP])
+])])
+
+
+# AC_PATH_TOOL_PREFIX
+# -------------------
+# find a file program which can recognise shared library
+AC_DEFUN([AC_PATH_TOOL_PREFIX],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+[[\\/*] | ?:[\\/]*])
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word. This closes a longstanding sh security hole.
+ ac_dummy="ifelse([$2], , $PATH, [$2])"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$1; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ AC_MSG_RESULT($MAGIC_CMD)
+else
+ AC_MSG_RESULT(no)
+fi
+])# AC_PATH_TOOL_PREFIX
+
+
+# AC_PATH_MAGIC
+# -------------
+# find a file program which can recognise a shared library
+AC_DEFUN([AC_PATH_MAGIC],
+[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+ if test -n "$ac_tool_prefix"; then
+ AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+ else
+ MAGIC_CMD=:
+ fi
+fi
+])# AC_PATH_MAGIC
+
+
+# AC_PROG_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([AC_PROG_LD],
+[AC_ARG_WITH([gnu-ld],
+ [AC_HELP_STRING([--with-gnu-ld],
+ [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+ [test "$withval" = no || with_gnu_ld=yes],
+ [with_gnu_ld=no])
+AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ AC_MSG_CHECKING([for ld used by $CC])
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [[\\/]]* | ?:[[\\/]]*)
+ re_direlt='/[[^/]][[^/]]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
+ while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ AC_MSG_CHECKING([for GNU ld])
+else
+ AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some GNU ld's only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ AC_MSG_RESULT($LD)
+else
+ AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_PROG_LD_GNU
+])# AC_PROG_LD
+
+
+# AC_PROG_LD_GNU
+# --------------
+AC_DEFUN([AC_PROG_LD_GNU],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# AC_PROG_LD_GNU
+
+
+# AC_PROG_LD_RELOAD_FLAG
+# ----------------------
+# find reload flag for linker
+# -- PORTME Some linkers may need a different reload flag.
+AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
+[AC_CACHE_CHECK([for $LD option to reload object files],
+ lt_cv_ld_reload_flag,
+ [lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+])# AC_PROG_LD_RELOAD_FLAG
+
+
+# AC_DEPLIBS_CHECK_METHOD
+# -----------------------
+# how to check for library dependencies
+# -- PORTME fill in with the dynamic library characteristics
+AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
+[AC_CACHE_CHECK([how to recognise dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix4* | aix5*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+beos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+bsdi4*)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+ lt_cv_file_magic_cmd='/usr/bin/file -L'
+ lt_cv_file_magic_test_file=/shlib/libc.so
+ ;;
+
+cygwin*)
+ # win32_libid is a shell function defined in ltmain.sh
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='win32_libid'
+ ;;
+
+mingw* | pw32*)
+ # Base MSYS/MinGW do not provide the 'file' command needed by
+ # win32_libid shell function, so use a weaker test based on 'objdump'.
+ lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ ;;
+
+darwin* | rhapsody*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+freebsd* | kfreebsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ case $host_cpu in
+ i*86 )
+ # Not sure whether the presence of OpenBSD here was a mistake.
+ # Let's accept both of them until this is cleared up.
+ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[[3-9]]86 (compact )?demand paged shared library'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+ ;;
+ esac
+ else
+ lt_cv_deplibs_check_method=pass_all
+ fi
+ ;;
+
+gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+hpux10.20* | hpux11*)
+ lt_cv_file_magic_cmd=/usr/bin/file
+ case "$host_cpu" in
+ ia64*)
+ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+ hppa*64*)
+ [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
+ *)
+ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+ esac
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $LD in
+ *-32|*"-32 ") libmagic=32-bit;;
+ *-n32|*"-n32 ") libmagic=N32;;
+ *-64|*"-64 ") libmagic=64-bit;;
+ *) libmagic=never-match;;
+ esac
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+# This must be Linux ELF.
+linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+ fi
+ ;;
+
+newos6*)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=/usr/lib/libnls.so
+ ;;
+
+nto-qnx*)
+ lt_cv_deplibs_check_method=unknown
+ ;;
+
+openbsd*)
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB shared object'
+ else
+ lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library'
+ fi
+ ;;
+
+osf3* | osf4* | osf5*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sco3.2v5*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+solaris*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ case $host_vendor in
+ motorola)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+ ;;
+ ncr)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ sequent)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+ ;;
+ sni)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+ lt_cv_file_magic_test_file=/lib/libc.so
+ ;;
+ siemens)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ esac
+ ;;
+
+sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7* | sysv4*uw2*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+esac
+])
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+])# AC_DEPLIBS_CHECK_METHOD
+
+
+# AC_PROG_NM
+# ----------
+# find the pathname to a BSD-compatible name lister
+AC_DEFUN([AC_PROG_NM],
+[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM,
+[if test -n "$NM"; then
+ # Let the user override the test.
+ lt_cv_path_NM="$NM"
+else
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ tmp_nm="$ac_dir/${ac_tool_prefix}nm"
+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ # Tru64's nm complains that /dev/null is an invalid object file
+ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+ */dev/null* | *'Invalid file or object type'*)
+ lt_cv_path_NM="$tmp_nm -B"
+ break
+ ;;
+ *)
+ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+ */dev/null*)
+ lt_cv_path_NM="$tmp_nm -p"
+ break
+ ;;
+ *)
+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ ;;
+ esac
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+ test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+fi])
+NM="$lt_cv_path_NM"
+])# AC_PROG_NM
+
+
+# AC_CHECK_LIBM
+# -------------
+# check for math library
+AC_DEFUN([AC_CHECK_LIBM],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
+ # These system don't have libm, or don't need it
+ ;;
+*-ncr-sysv4.3*)
+ AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+ AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+ ;;
+*)
+ AC_CHECK_LIB(m, cos, LIBM="-lm")
+ ;;
+esac
+])# AC_CHECK_LIBM
+
+
+# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
+# -----------------------------------
+# sets LIBLTDL to the link flags for the libltdl convenience library and
+# LTDLINCL to the include flags for the libltdl header and adds
+# --enable-ltdl-convenience to the configure arguments. Note that LIBLTDL
+# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If
+# DIRECTORY is not provided, it is assumed to be `libltdl'. LIBLTDL will
+# be prefixed with '${top_builddir}/' and LTDLINCL will be prefixed with
+# '${top_srcdir}/' (note the single quotes!). If your package is not
+# flat and you're not using automake, define top_builddir and
+# top_srcdir appropriately in the Makefiles.
+AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+ case $enable_ltdl_convenience in
+ no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+ "") enable_ltdl_convenience=yes
+ ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
+ esac
+ LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
+ LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+ # For backwards non-gettext consistent compatibility...
+ INCLTDL="$LTDLINCL"
+])# AC_LIBLTDL_CONVENIENCE
+
+
+# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
+# -----------------------------------
+# sets LIBLTDL to the link flags for the libltdl installable library and
+# LTDLINCL to the include flags for the libltdl header and adds
+# --enable-ltdl-install to the configure arguments. Note that LIBLTDL
+# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If
+# DIRECTORY is not provided and an installed libltdl is not found, it is
+# assumed to be `libltdl'. LIBLTDL will be prefixed with '${top_builddir}/'
+# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single
+# quotes!). If your package is not flat and you're not using automake,
+# define top_builddir and top_srcdir appropriately in the Makefiles.
+# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+ AC_CHECK_LIB(ltdl, lt_dlinit,
+ [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
+ [if test x"$enable_ltdl_install" = xno; then
+ AC_MSG_WARN([libltdl not installed, but installation disabled])
+ else
+ enable_ltdl_install=yes
+ fi
+ ])
+ if test x"$enable_ltdl_install" = x"yes"; then
+ ac_configure_args="$ac_configure_args --enable-ltdl-install"
+ LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
+ LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+ else
+ ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+ LIBLTDL="-lltdl"
+ LTDLINCL=
+ fi
+ # For backwards non-gettext consistent compatibility...
+ INCLTDL="$LTDLINCL"
+])# AC_LIBLTDL_INSTALLABLE
+
+
+# AC_LIBTOOL_CXX
+# --------------
+# enable support for C++ libraries
+AC_DEFUN([AC_LIBTOOL_CXX],
+[AC_REQUIRE([_LT_AC_LANG_CXX])
+])# AC_LIBTOOL_CXX
+
+
+# _LT_AC_LANG_CXX
+# ---------------
+AC_DEFUN([_LT_AC_LANG_CXX],
+[AC_REQUIRE([AC_PROG_CXX])
+AC_REQUIRE([AC_PROG_CXXCPP])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
+])# _LT_AC_LANG_CXX
+
+
+# AC_LIBTOOL_F77
+# --------------
+# enable support for Fortran 77 libraries
+AC_DEFUN([AC_LIBTOOL_F77],
+[AC_REQUIRE([_LT_AC_LANG_F77])
+])# AC_LIBTOOL_F77
+
+
+# _LT_AC_LANG_F77
+# ---------------
+AC_DEFUN([_LT_AC_LANG_F77],
+[AC_REQUIRE([AC_PROG_F77])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
+])# _LT_AC_LANG_F77
+
+
+# AC_LIBTOOL_GCJ
+# --------------
+# enable support for GCJ libraries
+AC_DEFUN([AC_LIBTOOL_GCJ],
+[AC_REQUIRE([_LT_AC_LANG_GCJ])
+])# AC_LIBTOOL_GCJ
+
+
+# _LT_AC_LANG_GCJ
+# ---------------
+AC_DEFUN([_LT_AC_LANG_GCJ],
+[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
+ [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
+ [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
+ [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
+ [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
+ [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
+])# _LT_AC_LANG_GCJ
+
+
+# AC_LIBTOOL_RC
+# --------------
+# enable support for Windows resource files
+AC_DEFUN([AC_LIBTOOL_RC],
+[AC_REQUIRE([LT_AC_PROG_RC])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
+])# AC_LIBTOOL_RC
+
+
+# AC_LIBTOOL_LANG_C_CONFIG
+# ------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined. Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG])
+AC_DEFUN([_LT_AC_LANG_C_CONFIG],
+[lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}\n'
+
+_LT_AC_SYS_COMPILER
+
+#
+# Check for any special shared library compilation flags.
+#
+_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)=
+if test "$GCC" = no; then
+ case $host_os in
+ sco3.2v5*)
+ _LT_AC_TAGVAR(lt_prog_cc_shlib, $1)='-belf'
+ ;;
+ esac
+fi
+if test -n "$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)"; then
+ AC_MSG_WARN([`$CC' requires `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to build shared libraries])
+ if echo "$old_CC $old_CFLAGS " | grep "[[ ]]$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)[[ ]]" >/dev/null; then :
+ else
+ AC_MSG_WARN([add `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to the CC or CFLAGS env variable and reconfigure])
+ _LT_AC_TAGVAR(lt_cv_prog_cc_can_build_shared, $1)=no
+ fi
+fi
+
+
+#
+# Check to make sure the static flag actually works.
+#
+AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $_LT_AC_TAGVAR(lt_prog_compiler_static, $1) works],
+ _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
+ $_LT_AC_TAGVAR(lt_prog_compiler_static, $1),
+ [],
+ [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
+
+
+AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_DLOPEN_SELF($1)
+
+# Report which librarie types wil actually be built
+AC_MSG_CHECKING([if libtool supports shared libraries])
+AC_MSG_RESULT([$can_build_shared])
+
+AC_MSG_CHECKING([whether to build shared libraries])
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case "$host_os" in
+aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+
+aix4*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ darwin* | rhapsody*)
+ if test "$GCC" = yes; then
+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+ case "$host_os" in
+ rhapsody* | darwin1.[[012]])
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress'
+ ;;
+ *) # Darwin 1.3 on
+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+ else
+ case ${MACOSX_DEPLOYMENT_TARGET} in
+ 10.[[012]])
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+ ;;
+ 10.*)
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ output_verbose_link_cmd='echo'
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring'
+ _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=no
+ _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience'
+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+ else
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+esac
+AC_MSG_RESULT([$enable_shared])
+
+AC_MSG_CHECKING([whether to build static libraries])
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+AC_MSG_RESULT([$enable_static])
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_C_CONFIG
+
+
+# AC_LIBTOOL_LANG_CXX_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined. Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)])
+AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
+[AC_LANG_PUSH(C++)
+AC_REQUIRE([AC_PROG_CXX])
+AC_REQUIRE([AC_PROG_CXXCPP])
+
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+_LT_AC_TAGVAR(always_export_symbols, $1)=no
+_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_direct, $1)=no
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+_LT_AC_TAGVAR(module_cmds, $1)=
+_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_AC_TAGVAR(no_undefined_flag, $1)=
+_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Dependencies to place before and after the object being linked:
+_LT_AC_TAGVAR(predep_objects, $1)=
+_LT_AC_TAGVAR(postdep_objects, $1)=
+_LT_AC_TAGVAR(predeps, $1)=
+_LT_AC_TAGVAR(postdeps, $1)=
+_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
+
+# Source file extension for C++ test sources.
+ac_ext=cc
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_LD=$LD
+lt_save_GCC=$GCC
+GCC=$GXX
+lt_save_with_gnu_ld=$with_gnu_ld
+lt_save_path_LD=$lt_cv_path_LD
+if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+else
+ unset lt_cv_prog_gnu_ld
+fi
+if test -n "${lt_cv_path_LDCXX+set}"; then
+ lt_cv_path_LD=$lt_cv_path_LDCXX
+else
+ unset lt_cv_path_LD
+fi
+test -z "${LDCXX+set}" || LD=$LDCXX
+CC=${CXX-"c++"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
+
+# We don't want -fno-exception wen compiling C++ code, so set the
+# no_builtin_flag separately
+if test "$GXX" = yes; then
+ _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+else
+ _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+fi
+
+if test "$GXX" = yes; then
+ # Set up default GNU C++ configuration
+
+ AC_PROG_LD
+
+ # Check if GNU C++ uses GNU ld as the underlying linker, since the
+ # archiving commands below assume that GNU ld is being used.
+ if test "$with_gnu_ld" = yes; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+ # investigate it a little bit more. (MM)
+ wlarc='${wl}'
+
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
+ grep 'no-whole-archive' > /dev/null; then
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ else
+ with_gnu_ld=no
+ wlarc=
+
+ # A generic and very simple default shared library creation
+ # command for GNU C++ for the case where it uses the native
+ # linker, instead of GNU ld. If possible, this setting should
+ # overridden to take advantage of the native linker features on
+ # the platform it is being used on.
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ fi
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+else
+ GXX=no
+ with_gnu_ld=no
+ wlarc=
+fi
+
+# PORTME: fill in a description of your system's C++ link characteristics
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+_LT_AC_TAGVAR(ld_shlibs, $1)=yes
+case $host_os in
+ aix3*)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aix4* | aix5*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+ for ld_flag in $LDFLAGS; do
+ case $ld_flag in
+ *-brtl*)
+ aix_use_runtimelinking=yes
+ break
+ ;;
+ esac
+ done
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ _LT_AC_TAGVAR(archive_cmds, $1)=''
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+ if test "$GXX" = yes; then
+ case $host_os in aix4.[012]|aix4.[012].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" && \
+ strings "$collect2name" | grep resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ else
+ # We have old collect2
+ _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+ fi
+ esac
+ shared_flag='-shared'
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # Determine the default libpath from the value encoded in an empty executable.
+ _LT_AC_SYS_LIBPATH_AIX
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an empty executable.
+ _LT_AC_SYS_LIBPATH_AIX
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+ # -bexpall does not export symbols beginning with underscore (_)
+ _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+ # This is similar to how AIX traditionally builds it's shared libraries.
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+ chorus*)
+ case $cc_basename in
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+ # as there is no search path for DLLs.
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_AC_TAGVAR(always_export_symbols, $1)=no
+ _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+ else
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ darwin* | rhapsody*)
+ if test "$GXX" = yes; then
+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+ case "$host_os" in
+ rhapsody* | darwin1.[[012]])
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress'
+ ;;
+ *) # Darwin 1.3 on
+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+ else
+ case ${MACOSX_DEPLOYMENT_TARGET} in
+ 10.[[012]])
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+ ;;
+ 10.*)
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ lt_int_apple_cc_single_mod=no
+ output_verbose_link_cmd='echo'
+ if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+ lt_int_apple_cc_single_mod=yes
+ fi
+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ else
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ fi
+ _LT_AC_TAGVAR(module_cmds, $1)='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+
+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ else
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=no
+ _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience'
+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+ else
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ dgux*)
+ case $cc_basename in
+ ec++)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ ghcx)
+ # Green Hills C++ Compiler
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+ freebsd[12]*)
+ # C++ shared libraries reported to be fairly broken before switch to ELF
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ freebsd-elf*)
+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+ ;;
+ freebsd* | kfreebsd*-gnu)
+ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+ # conventions
+ _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+ gnu*)
+ ;;
+ hpux9*)
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+
+ case $cc_basename in
+ CC)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aCC)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | egrep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+ hpux10*|hpux11*)
+ if test $with_gnu_ld = no; then
+ case "$host_cpu" in
+ hppa*64*)
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+ ia64*)
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ ;;
+ *)
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ ;;
+ esac
+ fi
+ case "$host_cpu" in
+ hppa*64*)
+ _LT_AC_TAGVAR(hardcode_direct, $1)=no
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+ ia64*)
+ _LT_AC_TAGVAR(hardcode_direct, $1)=no
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+ ;;
+ *)
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+ ;;
+ esac
+
+ case $cc_basename in
+ CC)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aCC)
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+ ;;
+ *)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test $with_gnu_ld = no; then
+ case "$host_cpu" in
+ ia64*|hppa*64*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+ ;;
+ *)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ fi
+ else
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+ irix5* | irix6*)
+ case $cc_basename in
+ CC)
+ # SGI C++
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
+
+ # Archives containing C++ object files must be created using
+ # "CC -ar", where "CC" is the IRIX C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test "$with_gnu_ld" = no; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
+ else
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
+ fi
+ fi
+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+ esac
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+ linux*)
+ case $cc_basename in
+ KCC)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir'
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+ # Archives containing C++ object files must be created using
+ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+ _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+ icpc)
+ # Intel C++
+ with_gnu_ld=yes
+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+ cxx)
+ # Compaq C++
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+ runpath_var=LD_RUN_PATH
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+ ;;
+ esac
+ ;;
+ lynxos*)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ m88k*)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ mvs*)
+ case $cc_basename in
+ cxx)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+ wlarc=
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ fi
+ # Workaround some broken pre-1.5 toolchains
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+ ;;
+ osf3*)
+ case $cc_basename in
+ KCC)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Archives containing C++ object files must be created using
+ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+ _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+
+ ;;
+ RCC)
+ # Rational C++ 2.4.1
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ cxx)
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
+
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+ ;;
+ *)
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
+
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+ else
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+ osf4* | osf5*)
+ case $cc_basename in
+ KCC)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Archives containing C++ object files must be created using
+ # the KAI C++ compiler.
+ _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
+ ;;
+ RCC)
+ # Rational C++ 2.4.1
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ cxx)
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+ echo "-hidden">> $lib.exp~
+ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry $objdir/so_locations -o $lib~
+ $rm $lib.exp'
+
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+ ;;
+ *)
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
+
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+ else
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+ psos*)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ sco*)
+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+ case $cc_basename in
+ CC)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+ sunos4*)
+ case $cc_basename in
+ CC)
+ # Sun C++ 4.x
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ lcc)
+ # Lucid
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+ solaris*)
+ case $cc_basename in
+ CC)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *)
+ # The C++ compiler is used as linker so we must use $wl
+ # flag to pass the commands to the underlying system
+ # linker.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ ;;
+ esac
+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[[LR]]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ gcx)
+ # Green Hills C++ Compiler
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+ # The C++ compiler must be used to create the archive.
+ _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+ ;;
+ *)
+ # GNU C++ compiler with Solaris linker
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+ if $CC --version | grep -v '^2\.7' > /dev/null; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+ else
+ # g++ 2.7 appears to require `-G' NOT `-shared' on this
+ # platform.
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+ fi
+
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+ fi
+ ;;
+ esac
+ ;;
+ sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*)
+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+ ;;
+ tandem*)
+ case $cc_basename in
+ NCC)
+ # NonStop-UX NCC 3.20
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+ vxworks*)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+esac
+AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_AC_TAGVAR(GCC, $1)="$GXX"
+_LT_AC_TAGVAR(LD, $1)="$LD"
+
+AC_LIBTOOL_POSTDEP_PREDEP($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_DLOPEN_SELF($1)
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC=$lt_save_CC
+LDCXX=$LD
+LD=$lt_save_LD
+GCC=$lt_save_GCC
+with_gnu_ldcxx=$with_gnu_ld
+with_gnu_ld=$lt_save_with_gnu_ld
+lt_cv_path_LDCXX=$lt_cv_path_LD
+lt_cv_path_LD=$lt_save_path_LD
+lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+])# AC_LIBTOOL_LANG_CXX_CONFIG
+
+# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
+# ------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library. It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
+int a;
+void foo (void) { a = 0; }
+EOF
+],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
+class Foo
+{
+public:
+ Foo (void) { a = 0; }
+private:
+ int a;
+};
+EOF
+],[$1],[F77],[cat > conftest.$ac_ext <<EOF
+ subroutine foo
+ implicit none
+ integer*4 a
+ a=0
+ return
+ end
+EOF
+],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
+public class foo {
+ private int a;
+ public void bar (void) {
+ a = 0;
+ }
+};
+EOF
+])
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+ # Parse the compiler output and extract the necessary
+ # objects, libraries and library flags.
+
+ # Sentinel used to keep track of whether or not we are before
+ # the conftest object file.
+ pre_test_object_deps_done=no
+
+ # The `*' in the case matches for architectures that use `case' in
+ # $output_verbose_cmd can trigger glob expansion during the loop
+ # eval without this substitution.
+ output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e \"$no_glob_subst\"`"
+
+ for p in `eval $output_verbose_link_cmd`; do
+ case $p in
+
+ -L* | -R* | -l*)
+ # Some compilers place space between "-{L,R}" and the path.
+ # Remove the space.
+ if test $p = "-L" \
+ || test $p = "-R"; then
+ prev=$p
+ continue
+ else
+ prev=
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ case $p in
+ -L* | -R*)
+ # Internal compiler library paths should come after those
+ # provided the user. The postdeps already come after the
+ # user supplied libs so there is no need to process them.
+ if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+ _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+ else
+ _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+ fi
+ ;;
+ # The "-l" case would never come before the object being
+ # linked, so don't bother handling this case.
+ esac
+ else
+ if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then
+ _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}"
+ else
+ _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}"
+ fi
+ fi
+ ;;
+
+ *.$objext)
+ # This assumes that the test object file only shows up
+ # once in the compiler output.
+ if test "$p" = "conftest.$objext"; then
+ pre_test_object_deps_done=yes
+ continue
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then
+ _LT_AC_TAGVAR(predep_objects, $1)="$p"
+ else
+ _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p"
+ fi
+ else
+ if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then
+ _LT_AC_TAGVAR(postdep_objects, $1)="$p"
+ else
+ _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p"
+ fi
+ fi
+ ;;
+
+ *) ;; # Ignore the rest.
+
+ esac
+ done
+
+ # Clean up.
+ rm -f a.out a.exe
+else
+ echo "libtool.m4: error: problem compiling $1 test program"
+fi
+
+$rm -f confest.$objext
+
+case " $_LT_AC_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+])# AC_LIBTOOL_POSTDEP_PREDEP
+
+# AC_LIBTOOL_LANG_F77_CONFIG
+# ------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined. Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
+AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
+[AC_REQUIRE([AC_PROG_F77])
+AC_LANG_PUSH(Fortran 77)
+
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+_LT_AC_TAGVAR(always_export_symbols, $1)=no
+_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_direct, $1)=no
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+_LT_AC_TAGVAR(module_cmds, $1)=
+_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_AC_TAGVAR(no_undefined_flag, $1)=
+_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code=" subroutine t\n return\n end\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code=" program t\n end\n"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${F77-"f77"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
+
+AC_MSG_CHECKING([if libtool supports shared libraries])
+AC_MSG_RESULT([$can_build_shared])
+
+AC_MSG_CHECKING([whether to build shared libraries])
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case "$host_os" in
+aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+aix4*)
+ test "$enable_shared" = yes && enable_static=no
+ ;;
+esac
+AC_MSG_RESULT([$enable_shared])
+
+AC_MSG_CHECKING([whether to build static libraries])
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+AC_MSG_RESULT([$enable_static])
+
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_AC_TAGVAR(GCC, $1)="$G77"
+_LT_AC_TAGVAR(LD, $1)="$LD"
+
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_F77_CONFIG
+
+
+# AC_LIBTOOL_LANG_GCJ_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined. Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
+AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
+[AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${GCJ-"gcj"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+
+AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_DLOPEN_SELF($1)
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_GCJ_CONFIG
+
+
+# AC_LIBTOOL_LANG_RC_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the Windows resource compiler are
+# suitably defined. Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
+AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
+[AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${RC-"windres"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_RC_CONFIG
+
+
+# AC_LIBTOOL_CONFIG([TAGNAME])
+# ----------------------------
+# If TAGNAME is not passed, then create an initial libtool script
+# with a default configuration from the untagged config vars. Otherwise
+# add code to config.status for appending the configuration named by
+# TAGNAME from the matching tagged config vars.
+AC_DEFUN([AC_LIBTOOL_CONFIG],
+[# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+ # See if we are running on zsh, and set the options which allow our commands through
+ # without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+ # Now quote all the things that may contain metacharacters while being
+ # careful not to overquote the AC_SUBSTed values. We take copies of the
+ # variables and quote the copies for generation of the libtool script.
+ for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+ SED SHELL STRIP \
+ libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+ old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+ deplibs_check_method reload_flag reload_cmds need_locks \
+ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+ lt_cv_sys_global_symbol_to_c_name_address \
+ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+ old_postinstall_cmds old_postuninstall_cmds \
+ _LT_AC_TAGVAR(compiler, $1) \
+ _LT_AC_TAGVAR(CC, $1) \
+ _LT_AC_TAGVAR(LD, $1) \
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
+ _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
+ _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
+ _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
+ _LT_AC_TAGVAR(old_archive_cmds, $1) \
+ _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
+ _LT_AC_TAGVAR(predep_objects, $1) \
+ _LT_AC_TAGVAR(postdep_objects, $1) \
+ _LT_AC_TAGVAR(predeps, $1) \
+ _LT_AC_TAGVAR(postdeps, $1) \
+ _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
+ _LT_AC_TAGVAR(archive_cmds, $1) \
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
+ _LT_AC_TAGVAR(postinstall_cmds, $1) \
+ _LT_AC_TAGVAR(postuninstall_cmds, $1) \
+ _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
+ _LT_AC_TAGVAR(allow_undefined_flag, $1) \
+ _LT_AC_TAGVAR(no_undefined_flag, $1) \
+ _LT_AC_TAGVAR(export_symbols_cmds, $1) \
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
+ _LT_AC_TAGVAR(hardcode_automatic, $1) \
+ _LT_AC_TAGVAR(module_cmds, $1) \
+ _LT_AC_TAGVAR(module_expsym_cmds, $1) \
+ _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
+ _LT_AC_TAGVAR(exclude_expsyms, $1) \
+ _LT_AC_TAGVAR(include_expsyms, $1); do
+
+ case $var in
+ _LT_AC_TAGVAR(old_archive_cmds, $1) | \
+ _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
+ _LT_AC_TAGVAR(archive_cmds, $1) | \
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
+ _LT_AC_TAGVAR(module_cmds, $1) | \
+ _LT_AC_TAGVAR(module_expsym_cmds, $1) | \
+ _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
+ _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
+ extract_expsyms_cmds | reload_cmds | finish_cmds | \
+ postinstall_cmds | postuninstall_cmds | \
+ old_postinstall_cmds | old_postuninstall_cmds | \
+ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+ # Double-quote double-evaled strings.
+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+ ;;
+ *)
+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+ ;;
+ esac
+ done
+
+ case $lt_echo in
+ *'\[$]0 --fallback-echo"')
+ lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
+ ;;
+ esac
+
+ifelse([$1], [],
+ [cfgfile="${ofile}T"
+ trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+ $rm -f "$cfgfile"
+ AC_MSG_NOTICE([creating $ofile])],
+ [cfgfile="$ofile"])
+
+ cat <<__EOF__ >> "$cfgfile"
+ifelse([$1], [],
+[#! $SHELL
+
+# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+#
+# This file is part of GNU Libtool:
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="$SED -e s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
+
+# The names of the tagged configurations supported by this script.
+available_tags=
+
+# ### BEGIN LIBTOOL CONFIG],
+[# ### BEGIN LIBTOOL TAG CONFIG: $tagname])
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
+
+# Is the compiler the GNU C compiler?
+with_gcc=$_LT_AC_TAGVAR(GCC, $1)
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_[]_LT_AC_TAGVAR(LD, $1)
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext='$shrext'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
+
+# Must we lock files when doing compilation ?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1)
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1)
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1)
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names. First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1)
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1)
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1)
+archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1)
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1)
+module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1)
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1)
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1)
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1)
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1)
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1)
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1)
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1)
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1)
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1)
+
+# Symbols that must always be exported.
+include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1)
+
+ifelse([$1],[],
+[# ### END LIBTOOL CONFIG],
+[# ### END LIBTOOL TAG CONFIG: $tagname])
+
+__EOF__
+
+ifelse([$1],[], [
+ case $host_os in
+ aix3*)
+ cat <<\EOF >> "$cfgfile"
+
+# AIX sometimes has problems with the GCC collect2 program. For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+fi
+EOF
+ ;;
+ esac
+
+ # We use sed instead of cat because bash on DJGPP gets confused if
+ # if finds mixed CR/LF and LF-only lines. Since sed operates in
+ # text mode, it properly converts lines to CR/LF. This bash problem
+ # is reportedly fixed, but why not run on old versions too?
+ sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
+
+ mv -f "$cfgfile" "$ofile" || \
+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+ chmod +x "$ofile"
+])
+else
+ # If there is no Makefile yet, we rely on a make rule to execute
+ # `config.status --recheck' to rerun these tests and create the
+ # libtool script then.
+ ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+ if test -f "$ltmain_in"; then
+ test -f Makefile && make "$ltmain"
+ fi
+fi
+])# AC_LIBTOOL_CONFIG
+
+
+# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------------------
+AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI],
+[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+
+_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+ _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+ AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+ lt_cv_prog_compiler_rtti_exceptions,
+ [-fno-rtti -fno-exceptions], [],
+ [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI
+
+
+# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+# ---------------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
+[AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([AC_PROG_NM])
+AC_REQUIRE([AC_OBJEXT])
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
+
+# Transform the above into a raw symbol and a C symbol.
+symxfrm='\1 \2\3 \3'
+
+# Transform an extracted symbol line into a proper C declaration
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+ symcode='[[BCDT]]'
+ ;;
+cygwin* | mingw* | pw32*)
+ symcode='[[ABCDGISTW]]'
+ ;;
+hpux*) # Its linker distinguishes data from code symbols
+ if test "$host_cpu" = ia64; then
+ symcode='[[ABCDEGRST]]'
+ fi
+ lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+ lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
+ ;;
+irix* | nonstopux*)
+ symcode='[[BCDEGRST]]'
+ ;;
+osf*)
+ symcode='[[BCDEGQRST]]'
+ ;;
+solaris* | sysv5*)
+ symcode='[[BDRT]]'
+ ;;
+sysv4)
+ symcode='[[DFNSTU]]'
+ ;;
+esac
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+ opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+ ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+ symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+ # Write the raw and C identifiers.
+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"
+
+ # Check to see that the pipe works correctly.
+ pipe_works=no
+
+ rm -f conftest*
+ cat > conftest.$ac_ext <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+EOF
+
+ if AC_TRY_EVAL(ac_compile); then
+ # Now try to grab the symbols.
+ nlist=conftest.nm
+ if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+ # Try sorting and uniquifying the output.
+ if sort "$nlist" | uniq > "$nlist"T; then
+ mv -f "$nlist"T "$nlist"
+ else
+ rm -f "$nlist"T
+ fi
+
+ # Make sure that we snagged all the symbols we need.
+ if grep ' nm_test_var$' "$nlist" >/dev/null; then
+ if grep ' nm_test_func$' "$nlist" >/dev/null; then
+ cat <<EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+ # Now generate the symbol file.
+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
+
+ cat <<EOF >> conftest.$ac_ext
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ lt_ptr_t address;
+}
+lt_preloaded_symbols[[]] =
+{
+EOF
+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
+ cat <<\EOF >> conftest.$ac_ext
+ {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+ # Now try linking the two files.
+ mv conftest.$ac_objext conftstm.$ac_objext
+ lt_save_LIBS="$LIBS"
+ lt_save_CFLAGS="$CFLAGS"
+ LIBS="conftstm.$ac_objext"
+ CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+ pipe_works=yes
+ fi
+ LIBS="$lt_save_LIBS"
+ CFLAGS="$lt_save_CFLAGS"
+ else
+ echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+ cat conftest.$ac_ext >&5
+ fi
+ rm -f conftest* conftst*
+
+ # Do not use the global_symbol_pipe unless it works.
+ if test "$pipe_works" = yes; then
+ break
+ else
+ lt_cv_sys_global_symbol_pipe=
+ fi
+done
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+ lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+ AC_MSG_RESULT(failed)
+else
+ AC_MSG_RESULT(ok)
+fi
+]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+
+
+# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME])
+# ---------------------------------------
+AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],
+[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
+
+AC_MSG_CHECKING([for $compiler option to produce PIC])
+ ifelse([$1],[CXX],[
+ # C++ specific cases for pic, static, wl, etc.
+ if test "$GXX" = yes; then
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+ amigaos*)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+ mingw* | os2* | pw32*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+ ;;
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+ ;;
+ *djgpp*)
+ # DJGPP does not support shared libraries at all
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+ fi
+ ;;
+ hpux*)
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ ;;
+ *)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ ;;
+ *)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ else
+ case $host_os in
+ aix4* | aix5*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+ chorus*)
+ case $cc_basename in
+ cxch68)
+ # Green Hills C++ Compiler
+ # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+ ;;
+ esac
+ ;;
+ dgux*)
+ case $cc_basename in
+ ec++)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ ;;
+ ghcx)
+ # Green Hills C++ Compiler
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ freebsd* | kfreebsd*-gnu)
+ # FreeBSD uses GNU C++
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ case $cc_basename in
+ CC)
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+ if test "$host_cpu" != ia64; then
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ fi
+ ;;
+ aCC)
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ ;;
+ esac
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ irix5* | irix6* | nonstopux*)
+ case $cc_basename in
+ CC)
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ # CC pic flag -KPIC is the default.
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ linux*)
+ case $cc_basename in
+ KCC)
+ # KAI C++ Compiler
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ icpc)
+ # Intel C++
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ cxx)
+ # Compaq C++
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ lynxos*)
+ ;;
+ m88k*)
+ ;;
+ mvs*)
+ case $cc_basename in
+ cxx)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ netbsd* | knetbsd*-gnu)
+ ;;
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC)
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+ ;;
+ RCC)
+ # Rational C++ 2.4.1
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ cxx)
+ # Digital/Compaq C++
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ psos*)
+ ;;
+ sco*)
+ case $cc_basename in
+ CC)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ solaris*)
+ case $cc_basename in
+ CC)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
+ gcx)
+ # Green Hills C++ Compiler
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sunos4*)
+ case $cc_basename in
+ CC)
+ # Sun C++ 4.x
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ lcc)
+ # Lucid
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ tandem*)
+ case $cc_basename in
+ NCC)
+ # NonStop-UX NCC 3.20
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ unixware*)
+ ;;
+ vxworks*)
+ ;;
+ *)
+ _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+ fi
+],
+[
+ if test "$GCC" = yes; then
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+ ;;
+
+ beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+
+ mingw* | pw32* | os2*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+ ;;
+
+ msdosdjgpp*)
+ # Just because we use GCC doesn't mean we suddenly get shared libraries
+ # on systems that don't support them.
+ _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ enable_shared=no
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+ fi
+ ;;
+
+ hpux*)
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ ;;
+
+ *)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+
+ mingw* | pw32* | os2*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # PIC (with -KPIC) is the default.
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ newsos6)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ linux*)
+ case $CC in
+ icc* | ecc*)
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ ccc*)
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # All Alpha code is PIC.
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ esac
+ ;;
+
+ osf3* | osf4* | osf5*)
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # All OSF/1 code is PIC.
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ sco3.2v5*)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kpic'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-dn'
+ ;;
+
+ solaris*)
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ sunos4*)
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ uts4*)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ *)
+ _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+ fi
+])
+AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
+ AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
+ _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
+ [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
+ [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
+ "" | " "*) ;;
+ *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+ esac],
+ [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+case "$host_os" in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+ *)
+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
+ ;;
+esac
+])
+
+
+# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME])
+# ------------------------------------
+# See if the linker supports building shared libraries.
+AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
+[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+ifelse([$1],[CXX],[
+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ case $host_os in
+ aix4* | aix5*)
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+ else
+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+ fi
+ ;;
+ pw32*)
+ _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+ ;;
+ cygwin* | mingw*)
+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ *)
+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ esac
+],[
+ runpath_var=
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+ _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+ _LT_AC_TAGVAR(archive_cmds, $1)=
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+ _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)=
+ _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+ _LT_AC_TAGVAR(thread_safe_flag_spec, $1)=
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+ _LT_AC_TAGVAR(hardcode_direct, $1)=no
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+ _LT_AC_TAGVAR(hardcode_automatic, $1)=no
+ _LT_AC_TAGVAR(module_cmds, $1)=
+ _LT_AC_TAGVAR(module_expsym_cmds, $1)=
+ _LT_AC_TAGVAR(always_export_symbols, $1)=no
+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ _LT_AC_TAGVAR(include_expsyms, $1)=
+ # exclude_expsyms can be an extended regexp of symbols to exclude
+ # it will be wrapped by ` (' and `)$', so one must not match beginning or
+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+ # as well as any symbol that contains `d'.
+ _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+ # platforms (ab)use it in PIC code, but their linkers get confused if
+ # the symbol is explicitly referenced. Since portable code cannot
+ # rely on this symbol name, it's probably fine to never include it in
+ # preloaded symbol tables.
+ extract_expsyms_cmds=
+
+ case $host_os in
+ cygwin* | mingw* | pw32*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+ esac
+
+ _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+ if test "$with_gnu_ld" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # See if GNU ld supports shared libraries.
+ case $host_os in
+ aix3* | aix4* | aix5*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+ fi
+ ;;
+
+ amigaos*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+
+ # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+ # that the semantics of dynamic libraries on AmigaOS, at least up
+ # to version 4, is to share data among multiple programs linked
+ # with the same dynamic library. Since this doesn't match the
+ # behavior of shared libraries on other platforms, we can't use
+ # them.
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+ # as there is no search path for DLLs.
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_AC_TAGVAR(always_export_symbols, $1)=no
+ _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+
+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ fi
+ ;;
+
+ solaris* | sysv5*)
+ if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+ elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ sunos4*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ linux*)
+ if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+ tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_AC_TAGVAR(archive_cmds, $1)="$tmp_archive_cmds"
+ supports_anon_versioning=no
+ case `$LD -v 2>/dev/null` in
+ *\ [01].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+ *\ 2.11.*) ;; # other 2.11 versions
+ *) supports_anon_versioning=yes ;;
+ esac
+ if test $supports_anon_versioning = yes; then
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ else
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)="$tmp_archive_cmds"
+ fi
+ else
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ *)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+
+ if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = yes; then
+ runpath_var=LD_RUN_PATH
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+ if test "$GCC" = yes && test -z "$link_static_flag"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+ fi
+ ;;
+
+ aix4* | aix5*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+ else
+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+ fi
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ _LT_AC_TAGVAR(archive_cmds, $1)=''
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+ if test "$GCC" = yes; then
+ case $host_os in aix4.[012]|aix4.[012].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" && \
+ strings "$collect2name" | grep resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ else
+ # We have old collect2
+ _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+ fi
+ esac
+ shared_flag='-shared'
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # Determine the default libpath from the value encoded in an empty executable.
+ _LT_AC_SYS_LIBPATH_AIX
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an empty executable.
+ _LT_AC_SYS_LIBPATH_AIX
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+ # -bexpall does not export symbols beginning with underscore (_)
+ _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+ # This is similar to how AIX traditionally builds it's shared libraries.
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ amigaos*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+ # see comment about different semantics on the GNU ld section
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ bsdi4*)
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
+ # FIXME: Should let the user specify the lib program.
+ _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
+ fix_srcfile_path='`cygpath -w "$srcfile"`'
+ _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ ;;
+
+ darwin* | rhapsody*)
+ if test "$GXX" = yes ; then
+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+ case "$host_os" in
+ rhapsody* | darwin1.[[012]])
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress'
+ ;;
+ *) # Darwin 1.3 on
+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+ else
+ case ${MACOSX_DEPLOYMENT_TARGET} in
+ 10.[[012]])
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+ ;;
+ 10.*)
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ lt_int_apple_cc_single_mod=no
+ output_verbose_link_cmd='echo'
+ if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+ lt_int_apple_cc_single_mod=yes
+ fi
+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ else
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ fi
+ _LT_AC_TAGVAR(module_cmds, $1)='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ else
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=no
+ _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience'
+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+ else
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ dgux*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ freebsd1*)
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | kfreebsd*-gnu)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ fi
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ ;;
+
+ hpux10* | hpux11*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ else
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+ ;;
+ *)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+ ;;
+ esac
+ fi
+ if test "$with_gnu_ld" = no; then
+ case "$host_cpu" in
+ hppa*64*)
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_AC_TAGVAR(hardcode_direct, $1)=no
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+ ia64*)
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=no
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ *)
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+ fi
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ newsos6)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ openbsd*)
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ else
+ case $host_os in
+ openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ ;;
+ *)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ ;;
+
+ os2*)
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+ _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+ fi
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ else
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
+
+ # Both c and cxx compiler support -rpath directly
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ fi
+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+
+ sco3.2v5*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ ;;
+
+ solaris*)
+ _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
+ if test "$GCC" = yes; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+ else
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+ fi
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
+ esac
+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ sunos4*)
+ if test "x$host_vendor" = xsequent; then
+ # Use $CC to link under sequent, because it throws in some extra .o
+ # files that make .init and .fini sections work.
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=no
+ ;;
+ motorola)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ sysv4.3*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+ fi
+ ;;
+
+ sysv4.2uw2*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ hardcode_runpath_var=yes
+ runpath_var=LD_RUN_PATH
+ ;;
+
+ sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*)
+ _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z ${wl}text'
+ if test "$GCC" = yes; then
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ runpath_var='LD_RUN_PATH'
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ sysv5*)
+ _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
+ # $CC -shared without GNU ld will not create a library from C++
+ # object files and a static libstdc++, better avoid it by now
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var='LD_RUN_PATH'
+ ;;
+
+ uts4*)
+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *)
+ _LT_AC_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ fi
+])
+AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+ # Assume -lc should be added
+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $_LT_AC_TAGVAR(archive_cmds, $1) in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ AC_MSG_CHECKING([whether -lc should be explicitly linked in])
+ $rm conftest*
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1)
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+ if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
+ then
+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+ else
+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+ fi
+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $rm conftest*
+ AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)])
+ ;;
+ esac
+ fi
+ ;;
+esac
+])# AC_LIBTOOL_PROG_LD_SHLIBS
+
+
+# _LT_AC_FILE_LTDLL_C
+# -------------------
+# Be careful that the start marker always follows a newline.
+AC_DEFUN([_LT_AC_FILE_LTDLL_C], [
+# /* ltdll.c starts here */
+# #define WIN32_LEAN_AND_MEAN
+# #include <windows.h>
+# #undef WIN32_LEAN_AND_MEAN
+# #include <stdio.h>
+#
+# #ifndef __CYGWIN__
+# # ifdef __CYGWIN32__
+# # define __CYGWIN__ __CYGWIN32__
+# # endif
+# #endif
+#
+# #ifdef __cplusplus
+# extern "C" {
+# #endif
+# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
+# #ifdef __cplusplus
+# }
+# #endif
+#
+# #ifdef __CYGWIN__
+# #include <cygwin/cygwin_dll.h>
+# DECLARE_CYGWIN_DLL( DllMain );
+# #endif
+# HINSTANCE __hDllInstance_base;
+#
+# BOOL APIENTRY
+# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
+# {
+# __hDllInstance_base = hInst;
+# return TRUE;
+# }
+# /* ltdll.c ends here */
+])# _LT_AC_FILE_LTDLL_C
+
+
+# _LT_AC_TAGVAR(VARNAME, [TAGNAME])
+# ---------------------------------
+AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
+
+
+# old names
+AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL])
+AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+AC_DEFUN([AM_PROG_LD], [AC_PROG_LD])
+AC_DEFUN([AM_PROG_NM], [AC_PROG_NM])
+
+# This is just to silence aclocal about the macro not being used
+ifelse([AC_DISABLE_FAST_INSTALL])
+
+AC_DEFUN([LT_AC_PROG_GCJ],
+[AC_CHECK_TOOL(GCJ, gcj, no)
+ test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+ AC_SUBST(GCJFLAGS)
+])
+
+AC_DEFUN([LT_AC_PROG_RC],
+[AC_CHECK_TOOL(RC, windres, no)
+])
+
+# NOTE: This macro has been submitted for inclusion into #
+# GNU Autoconf as AC_PROG_SED. When it is available in #
+# a released version of Autoconf we should remove this #
+# macro and use it instead. #
+# LT_AC_PROG_SED
+# --------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible. Prefer GNU sed if found.
+AC_DEFUN([LT_AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for lt_ac_prog in sed gsed; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+ lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+ fi
+ done
+ done
+done
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+ test ! -f $lt_ac_sed && break
+ cat /dev/null > conftest.in
+ lt_ac_count=0
+ echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+ # Check for GNU sed and select it if it is found.
+ if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+ lt_cv_path_SED=$lt_ac_sed
+ break
+ fi
+ while true; do
+ cat conftest.in conftest.in >conftest.tmp
+ mv conftest.tmp conftest.in
+ cp conftest.in conftest.nl
+ echo >>conftest.nl
+ $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+ cmp -s conftest.out conftest.nl || break
+ # 10000 chars as input seems more than enough
+ test $lt_ac_count -gt 10 && break
+ lt_ac_count=`expr $lt_ac_count + 1`
+ if test $lt_ac_count -gt $lt_ac_max; then
+ lt_ac_max=$lt_ac_count
+ lt_cv_path_SED=$lt_ac_sed
+ fi
+ done
+done
+SED=$lt_cv_path_SED
+])
+AC_MSG_RESULT([$SED])
+])
+
+
+dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
+dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
+dnl also defines GSTUFF_PKG_ERRORS on error
+AC_DEFUN(PKG_CHECK_MODULES, [
+ succeeded=no
+
+ if test -z "$PKG_CONFIG"; then
+ AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
+ fi
+
+ if test "$PKG_CONFIG" = "no" ; then
+ echo "*** The pkg-config script could not be found. Make sure it is"
+ echo "*** in your path, or set the PKG_CONFIG environment variable"
+ echo "*** to the full path to pkg-config."
+ echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
+ else
+ PKG_CONFIG_MIN_VERSION=0.9.0
+ if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
+ AC_MSG_CHECKING(for $2)
+
+ if $PKG_CONFIG --exists "$2" ; then
+ AC_MSG_RESULT(yes)
+ succeeded=yes
+
+ AC_MSG_CHECKING($1_CFLAGS)
+ $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
+ AC_MSG_RESULT($$1_CFLAGS)
+
+ AC_MSG_CHECKING($1_LIBS)
+ $1_LIBS=`$PKG_CONFIG --libs "$2"`
+ AC_MSG_RESULT($$1_LIBS)
+ else
+ $1_CFLAGS=""
+ $1_LIBS=""
+ ## If we have a custom action on failure, don't print errors, but
+ ## do set a variable so people can do so.
+ $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
+ ifelse([$4], ,echo $$1_PKG_ERRORS,)
+ fi
+
+ AC_SUBST($1_CFLAGS)
+ AC_SUBST($1_LIBS)
+ else
+ echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
+ echo "*** See http://www.freedesktop.org/software/pkgconfig"
+ fi
+ fi
+
+ if test $succeeded = yes; then
+ ifelse([$3], , :, [$3])
+ else
+ ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
+ fi
+])
+
+
+
diff --git a/nx-X11/lib/Xft/autogen.sh b/nx-X11/lib/Xft/autogen.sh
new file mode 100755
index 000000000..904cd6746
--- /dev/null
+++ b/nx-X11/lib/Xft/autogen.sh
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+autoreconf -v --install || exit 1
+cd $ORIGDIR || exit $?
+
+$srcdir/configure --enable-maintainer-mode "$@"
diff --git a/nx-X11/lib/Xft/config.guess b/nx-X11/lib/Xft/config.guess
new file mode 100755
index 000000000..cc726cd15
--- /dev/null
+++ b/nx-X11/lib/Xft/config.guess
@@ -0,0 +1,1388 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+timestamp='2003-02-22'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit 0 ;;
+ amiga:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hp300:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mac68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ macppc:OpenBSD:*:*)
+ echo powerpc-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme88k:OpenBSD:*:*)
+ echo m88k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvmeppc:OpenBSD:*:*)
+ echo powerpc-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ pmax:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sgi:OpenBSD:*:*)
+ echo mipseb-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sun3:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ wgrisc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:OpenBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ alpha:OSF1:*:*)
+ if test $UNAME_RELEASE = "V4.0"; then
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ fi
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit 0 ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit 0 ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit 0 ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit 0;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit 0 ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit 0 ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit 0 ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit 0;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit 0;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit 0 ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit 0 ;;
+ DRS?6000:UNIX_SV:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7 && exit 0 ;;
+ esac ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ i86pc:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit 0 ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit 0 ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit 0 ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit 0 ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit 0 ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit 0 ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit 0 ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c \
+ && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+ && exit 0
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit 0 ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit 0 ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit 0 ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit 0 ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit 0 ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit 0 ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit 0 ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit 0 ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit 0 ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit 0 ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit 0 ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit 0 ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit 0 ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
+ echo rs6000-ibm-aix3.2.5
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit 0 ;;
+ *:AIX:*:[45])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit 0 ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit 0 ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit 0 ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit 0 ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit 0 ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit 0 ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit 0 ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit 0 ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ # avoid double evaluation of $set_cc_for_build
+ test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit 0 ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit 0 ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
+ echo unknown-hitachi-hiuxwe2
+ exit 0 ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit 0 ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit 0 ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit 0 ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit 0 ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit 0 ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit 0 ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit 0 ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ *:UNICOS/mp:*:*)
+ echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit 0 ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:FreeBSD:*:*)
+ # Determine whether the default compiler uses glibc.
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #if __GLIBC__ >= 2
+ LIBC=gnu
+ #else
+ LIBC=
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
+ exit 0 ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit 0 ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit 0 ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit 0 ;;
+ x86:Interix*:3*)
+ echo i586-pc-interix3
+ exit 0 ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit 0 ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+ exit 0 ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit 0 ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit 0 ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ *:GNU:*:*)
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit 0 ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit 0 ;;
+ arm*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ mips:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mipsel
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+ test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+ ;;
+ mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips64
+ #undef mips64el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mips64el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips64
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+ test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+ ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit 0 ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit 0 ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit 0 ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+ exit 0 ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit 0 ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit 0 ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit 0 ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ # Set LC_ALL=C to ensure ld outputs messages in English.
+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+ | sed -ne '/supported targets:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported targets: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_targets" in
+ elf32-i386)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ a.out-i386-linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit 0 ;;
+ coff-i386)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit 0 ;;
+ "")
+ # Either a pre-BFD a.out linker (linux-gnuoldld) or
+ # one that does not give us useful --help.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+ exit 0 ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #ifdef __ELF__
+ # ifdef __GLIBC__
+ # if __GLIBC__ >= 2
+ LIBC=gnu
+ # else
+ LIBC=gnulibc1
+ # endif
+ # else
+ LIBC=gnulibc1
+ # endif
+ #else
+ #ifdef __INTEL_COMPILER
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+ #endif
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+ test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
+ test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit 0 ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit 0 ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit 0 ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit 0 ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit 0 ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit 0 ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit 0 ;;
+ i*86:*:5:[78]*)
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit 0 ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit 0 ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit 0 ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit 0 ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit 0 ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit 0 ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit 0 ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit 0 ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit 0 ;;
+ M68*:*:R3V[567]*:*)
+ test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+ 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4 && exit 0 ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit 0 ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit 0 ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit 0 ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit 0 ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit 0 ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit 0 ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit 0 ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit 0 ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit 0 ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit 0 ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit 0 ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit 0 ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Darwin:*:*)
+ case `uname -p` in
+ *86) UNAME_PROCESSOR=i686 ;;
+ powerpc) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit 0 ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit 0 ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit 0 ;;
+ NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit 0 ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit 0 ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit 0 ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit 0 ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit 0 ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit 0 ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit 0 ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit 0 ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit 0 ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit 0 ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ c34*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ c38*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ c4*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/nx-X11/lib/Xft/config.h.in b/nx-X11/lib/Xft/config.h.in
new file mode 100644
index 000000000..3c5f48365
--- /dev/null
+++ b/nx-X11/lib/Xft/config.h.in
@@ -0,0 +1,76 @@
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* FT_Bitmap_Size structure includes y_ppem field */
+#undef HAVE_FT_BITMAP_SIZE_Y_PPEM
+
+/* Define to 1 if you have the `FT_Get_BDF_Property' function. */
+#undef HAVE_FT_GET_BDF_PROPERTY
+
+/* Define to 1 if you have the `FT_Get_Next_Char' function. */
+#undef HAVE_FT_GET_NEXT_CHAR
+
+/* Define to 1 if you have the `FT_Get_PS_Font_Info' function. */
+#undef HAVE_FT_GET_PS_FONT_INFO
+
+/* Define to 1 if you have the `FT_Has_PS_Glyph_Names' function. */
+#undef HAVE_FT_HAS_PS_GLYPH_NAMES
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the <X11/extensions/Xrender.h> header file. */
+#undef HAVE_X11_EXTENSIONS_XRENDER_H
+
+/* Define to 1 if you have the `XRenderFindStandardFormat' function. */
+#undef HAVE_XRENDERFINDSTANDARDFORMAT
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Version number of package */
+#undef VERSION
diff --git a/nx-X11/lib/Xft/config.sub b/nx-X11/lib/Xft/config.sub
new file mode 100755
index 000000000..9772e87d2
--- /dev/null
+++ b/nx-X11/lib/Xft/config.sub
@@ -0,0 +1,1489 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+timestamp='2003-02-22'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit 0;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+ | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k \
+ | m32r | m68000 | m68k | m88k | mcore \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | msp430 \
+ | ns16k | ns32k \
+ | openrisc | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
+ | strongarm \
+ | tahoe | thumb | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xscale | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* \
+ | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | clipper-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* \
+ | m32r-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | mcore-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | msp430-* \
+ | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
+ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
+ | xtensa-* \
+ | ymp-* \
+ | z8k-*)
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ mmix*)
+ basic_machine=mmix-knuth
+ os=-mmixware
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nv1)
+ basic_machine=nv1-cray
+ os=-unicosmp
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ or32 | or32-*)
+ basic_machine=or32-unknown
+ os=-coff
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2)
+ basic_machine=i686-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic4x | c4x*)
+ basic_machine=tic4x-unknown
+ os=-coff
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tic55x | c55x*)
+ basic_machine=tic55x-unknown
+ os=-coff
+ ;;
+ tic6x | c6x*)
+ basic_machine=tic6x-unknown
+ os=-coff
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparc | sparcv9 | sparcv9b)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
+ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -kaos*)
+ os=-kaos
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/nx-X11/lib/Xft/config/config-subst b/nx-X11/lib/Xft/config/config-subst
new file mode 100644
index 000000000..5907e0328
--- /dev/null
+++ b/nx-X11/lib/Xft/config/config-subst
@@ -0,0 +1,10 @@
+#!/bin/sh
+script=config-subst.$$
+trap "rm $script" 0
+rm -f $script
+for i in ${1+"$@"}; do
+ var="`echo "$i" | sed 's/=.*$//'`"
+ val="`echo "$i" | sed 's/^[^=]*=//'`"
+ echo "s;@$var@;$val;" >> $script
+done
+sed -f $script
diff --git a/nx-X11/lib/Xft/configure b/nx-X11/lib/Xft/configure
new file mode 100755
index 000000000..80cc735c5
--- /dev/null
+++ b/nx-X11/lib/Xft/configure
@@ -0,0 +1,21551 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.59 for libXft 2.1.5.
+#
+# Report bugs to <keithp@keithp.com>.
+#
+# Copyright (C) 2003 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+
+
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$ECHO in
+X*--fallback-echo)
+ # Remove one level of quotation (which was required for Make).
+ ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','`
+ ;;
+esac
+
+echo=${ECHO-echo}
+if test "X$1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+elif test "X$1" = X--fallback-echo; then
+ # Avoid inline document here, it may be left over
+ :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
+ # Yippee, $echo works!
+ :
+else
+ # Restart under the correct shell.
+ exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+ # used as fallback echo
+ shift
+ cat <<EOF
+$*
+EOF
+ exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
+
+if test -z "$ECHO"; then
+if test "X${echo_test_string+set}" != Xset; then
+# find a string as large as possible, as long as the shell can cope with it
+ for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
+ # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+ if (echo_test_string="`eval $cmd`") 2>/dev/null &&
+ echo_test_string="`eval $cmd`" &&
+ (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
+ then
+ break
+ fi
+ done
+fi
+
+if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ :
+else
+ # The Solaris, AIX, and Digital Unix default echo programs unquote
+ # backslashes. This makes it impossible to quote backslashes using
+ # echo "$something" | sed 's/\\/\\\\/g'
+ #
+ # So, first we look for a working echo in the user's PATH.
+
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for dir in $PATH /usr/ucb; do
+ IFS="$lt_save_ifs"
+ if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+ test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ echo="$dir/echo"
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+
+ if test "X$echo" = Xecho; then
+ # We didn't find a better echo, so look for alternatives.
+ if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ # This shell has a builtin print -r that does the trick.
+ echo='print -r'
+ elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+ test "X$CONFIG_SHELL" != X/bin/ksh; then
+ # If we have ksh, try running configure again with it.
+ ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+ export ORIGINAL_CONFIG_SHELL
+ CONFIG_SHELL=/bin/ksh
+ export CONFIG_SHELL
+ exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
+ else
+ # Try using printf.
+ echo='printf %s\n'
+ if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ # Cool, printf works
+ :
+ elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+ test "X$echo_testing_string" = 'X\t' &&
+ echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+ export CONFIG_SHELL
+ SHELL="$CONFIG_SHELL"
+ export SHELL
+ echo="$CONFIG_SHELL $0 --fallback-echo"
+ elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+ test "X$echo_testing_string" = 'X\t' &&
+ echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ echo="$CONFIG_SHELL $0 --fallback-echo"
+ else
+ # maybe with a smaller string...
+ prev=:
+
+ for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
+ if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
+ then
+ break
+ fi
+ prev="$cmd"
+ done
+
+ if test "$prev" != 'sed 50q "$0"'; then
+ echo_test_string=`eval $prev`
+ export echo_test_string
+ exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
+ else
+ # Oops. We lost completely, so just stick with echo.
+ echo=echo
+ fi
+ fi
+ fi
+ fi
+fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+ECHO=$echo
+if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
+ ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
+fi
+
+
+
+
+tagnames=${tagnames+${tagnames},}CXX
+
+tagnames=${tagnames+${tagnames},}F77
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+exec 6>&1
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Maximum number of lines to put in a shell here document.
+# This variable seems obsolete. It should probably be removed, and
+# only ac_max_sed_lines should be used.
+: ${ac_max_here_lines=38}
+
+# Identity of this package.
+PACKAGE_NAME='libXft'
+PACKAGE_TARNAME='libXft'
+PACKAGE_VERSION='2.1.5'
+PACKAGE_STRING='libXft 2.1.5'
+PACKAGE_BUGREPORT='keithp@keithp.com'
+
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+# include <stdint.h>
+# endif
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE am__leading_dot MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL PKG_CONFIG XRENDER_CFLAGS XRENDER_LIBS ft_config FONTCONFIG_CFLAGS FONTCONFIG_LIBS FREETYPE_CFLAGS FREETYPE_LIBS LIBOBJS LTLIBOBJS'
+ac_subst_files=''
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+ac_prev=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_option in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ eval "enable_$ac_feature=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_$ac_feature='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_$ac_package='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package | sed 's/-/_/g'`
+ eval "with_$ac_package=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; }
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+ { (exit 1); exit 1; }; }
+ ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+ eval "$ac_envvar='$ac_optarg'"
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ { echo "$as_me: error: missing argument to $ac_option" >&2
+ { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# Be sure to have absolute paths.
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+ localstatedir libdir includedir oldincludedir infodir mandir
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+ If a cross compiler is detected then cross compile mode will be used." >&2
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_confdir=`(dirname "$0") 2>/dev/null ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$0" : 'X\(//\)[^/]' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$0" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
+ { (exit 1); exit 1; }; }
+ else
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+ { (exit 1); exit 1; }; }
+ fi
+fi
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
+ { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
+ { (exit 1); exit 1; }; }
+srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
+ac_env_build_alias_set=${build_alias+set}
+ac_env_build_alias_value=$build_alias
+ac_cv_env_build_alias_set=${build_alias+set}
+ac_cv_env_build_alias_value=$build_alias
+ac_env_host_alias_set=${host_alias+set}
+ac_env_host_alias_value=$host_alias
+ac_cv_env_host_alias_set=${host_alias+set}
+ac_cv_env_host_alias_value=$host_alias
+ac_env_target_alias_set=${target_alias+set}
+ac_env_target_alias_value=$target_alias
+ac_cv_env_target_alias_set=${target_alias+set}
+ac_cv_env_target_alias_value=$target_alias
+ac_env_CC_set=${CC+set}
+ac_env_CC_value=$CC
+ac_cv_env_CC_set=${CC+set}
+ac_cv_env_CC_value=$CC
+ac_env_CFLAGS_set=${CFLAGS+set}
+ac_env_CFLAGS_value=$CFLAGS
+ac_cv_env_CFLAGS_set=${CFLAGS+set}
+ac_cv_env_CFLAGS_value=$CFLAGS
+ac_env_LDFLAGS_set=${LDFLAGS+set}
+ac_env_LDFLAGS_value=$LDFLAGS
+ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
+ac_cv_env_LDFLAGS_value=$LDFLAGS
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
+ac_env_CXX_set=${CXX+set}
+ac_env_CXX_value=$CXX
+ac_cv_env_CXX_set=${CXX+set}
+ac_cv_env_CXX_value=$CXX
+ac_env_CXXFLAGS_set=${CXXFLAGS+set}
+ac_env_CXXFLAGS_value=$CXXFLAGS
+ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set}
+ac_cv_env_CXXFLAGS_value=$CXXFLAGS
+ac_env_CXXCPP_set=${CXXCPP+set}
+ac_env_CXXCPP_value=$CXXCPP
+ac_cv_env_CXXCPP_set=${CXXCPP+set}
+ac_cv_env_CXXCPP_value=$CXXCPP
+ac_env_F77_set=${F77+set}
+ac_env_F77_value=$F77
+ac_cv_env_F77_set=${F77+set}
+ac_cv_env_F77_value=$F77
+ac_env_FFLAGS_set=${FFLAGS+set}
+ac_env_FFLAGS_value=$FFLAGS
+ac_cv_env_FFLAGS_set=${FFLAGS+set}
+ac_cv_env_FFLAGS_value=$FFLAGS
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures libXft 2.1.5 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+_ACEOF
+
+ cat <<_ACEOF
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --infodir=DIR info documentation [PREFIX/info]
+ --mandir=DIR man documentation [PREFIX/man]
+_ACEOF
+
+ cat <<\_ACEOF
+
+Program names:
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM run sed PROGRAM on installed program names
+
+X features:
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+ case $ac_init_help in
+ short | recursive ) echo "Configuration of libXft 2.1.5:";;
+ esac
+ cat <<\_ACEOF
+
+Optional Features:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --enable-maintainer-mode enable make rules and dependencies not useful
+ (and sometimes confusing) to the casual installer
+ --disable-dependency-tracking Speeds up one-time builds
+ --enable-dependency-tracking Do not reject slow dependency extractors
+ --enable-shared[=PKGS]
+ build shared libraries [default=yes]
+ --enable-static[=PKGS]
+ build static libraries [default=yes]
+ --enable-fast-install[=PKGS]
+ optimize for fast installation [default=yes]
+ --disable-libtool-lock avoid locking (might break parallel builds)
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-gnu-ld assume the C compiler uses GNU ld [default=no]
+ --with-pic try to use only PIC/non-PIC objects [default=use
+ both]
+ --with-tags[=TAGS]
+ include additional configurations [automatic]
+ --with-x use the X Window System
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
+ headers in a nonstandard directory <include dir>
+ CPP C preprocessor
+ CXX C++ compiler command
+ CXXFLAGS C++ compiler flags
+ CXXCPP C++ preprocessor
+ F77 Fortran 77 compiler command
+ FFLAGS Fortran 77 compiler flags
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <keithp@keithp.com>.
+_ACEOF
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ ac_popdir=`pwd`
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d $ac_dir || continue
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+ cd $ac_dir
+ # Check for guested configure; otherwise get Cygnus style configure.
+ if test -f $ac_srcdir/configure.gnu; then
+ echo
+ $SHELL $ac_srcdir/configure.gnu --help=recursive
+ elif test -f $ac_srcdir/configure; then
+ echo
+ $SHELL $ac_srcdir/configure --help=recursive
+ elif test -f $ac_srcdir/configure.ac ||
+ test -f $ac_srcdir/configure.in; then
+ echo
+ $ac_configure --help
+ else
+ echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi
+ cd "$ac_popdir"
+ done
+fi
+
+test -n "$ac_init_help" && exit 0
+if $ac_init_version; then
+ cat <<\_ACEOF
+libXft configure 2.1.5
+generated by GNU Autoconf 2.59
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit 0
+fi
+exec 5>config.log
+cat >&5 <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by libXft $as_me 2.1.5, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ echo "PATH: $as_dir"
+done
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_sep=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+ 2)
+ ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+ # Get rid of the leading space.
+ ac_sep=" "
+ ;;
+ esac
+ done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Be sure not to use single quotes in there, as some shells,
+# such as our DU 5.0 friend, will then `close' the trap.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+{
+ (set) 2>&1 |
+ case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ sed -n \
+ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+ ;;
+ *)
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+}
+ echo
+
+ cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ cat <<\_ASBOX
+## ------------- ##
+## Output files. ##
+## ------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+ echo
+ sed "/^$/d" confdefs.h | sort
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ echo "$as_me: caught signal $ac_signal"
+ echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core &&
+ rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+ ' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo >confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special
+ # files actually), so we avoid doing that.
+ if test -f "$cache_file"; then
+ { echo "$as_me:$LINENO: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . $cache_file;;
+ *) . ./$cache_file;;
+ esac
+ fi
+else
+ { echo "$as_me:$LINENO: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in `(set) 2>&1 |
+ sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val="\$ac_cv_env_${ac_var}_value"
+ eval ac_new_val="\$ac_env_${ac_var}_value"
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+echo "$as_me: former value: $ac_old_val" >&2;}
+ { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
+echo "$as_me: current value: $ac_new_val" >&2;}
+ ac_cache_corrupted=:
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+am__api_version="1.7"
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f $ac_dir/shtool; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"
+ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+ ./ | .// | /cC/* | \
+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+ /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
+ fi
+ fi
+ done
+ done
+ ;;
+esac
+done
+
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL=$ac_install_sh
+ fi
+fi
+echo "$as_me:$LINENO: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+echo "$as_me:$LINENO: checking whether build environment is sane" >&5
+echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+ if test "$*" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftest.file`
+ fi
+ rm -f conftest.file
+ if test "$*" != "X $srcdir/configure conftest.file" \
+ && test "$*" != "X conftest.file $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken
+alias in your environment" >&5
+echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken
+alias in your environment" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+ test "$2" = conftest.file
+ )
+then
+ # Ok.
+ :
+else
+ { { echo "$as_me:$LINENO: error: newly created file is older than distributed files!
+Check your system clock" >&5
+echo "$as_me: error: newly created file is older than distributed files!
+Check your system clock" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+test "$program_prefix" != NONE &&
+ program_transform_name="s,^,$program_prefix,;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s,\$,$program_suffix,;$program_transform_name"
+# Double any \ or $. echo might interpret backslashes.
+# By default was `s,x,x', remove it if useless.
+cat <<\_ACEOF >conftest.sed
+s/[\\$]/&&/g;s/;s,x,x,$//
+_ACEOF
+program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
+rm conftest.sed
+
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+ am_missing_run="$MISSING --run "
+else
+ am_missing_run=
+ { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5
+echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+fi
+
+for ac_prog in gawk mawk nawk awk
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_AWK+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$AWK"; then
+ ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AWK="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+ echo "$as_me:$LINENO: result: $AWK" >&5
+echo "${ECHO_T}$AWK" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$AWK" && break
+done
+
+echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'`
+if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.make <<\_ACEOF
+all:
+ @echo 'ac_maketemp="$(MAKE)"'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+else
+ eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftest.make
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ SET_MAKE=
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+ am__leading_dot=.
+else
+ am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+ # test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" &&
+ test -f $srcdir/config.status; then
+ { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
+echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+ if (cygpath --version) >/dev/null 2>/dev/null; then
+ CYGPATH_W='cygpath -w'
+ else
+ CYGPATH_W=echo
+ fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE='libXft'
+ VERSION='2.1.5'
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+install_sh=${install_sh-"$am_aux_dir/install-sh"}
+
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'. However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_STRIP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$STRIP"; then
+ ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+ echo "$as_me:$LINENO: result: $STRIP" >&5
+echo "${ECHO_T}$STRIP" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+ ac_ct_STRIP=$STRIP
+ # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_STRIP"; then
+ ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_STRIP="strip"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+ echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+echo "${ECHO_T}$ac_ct_STRIP" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ STRIP=$ac_ct_STRIP
+else
+ STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
+
+# We need awk for the "check" target. The system "awk" is bad on
+# some platforms.
+
+
+
+echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5
+echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6
+ # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
+if test "${enable_maintainer_mode+set}" = set; then
+ enableval="$enable_maintainer_mode"
+ USE_MAINTAINER_MODE=$enableval
+else
+ USE_MAINTAINER_MODE=no
+fi;
+ echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5
+echo "${ECHO_T}$USE_MAINTAINER_MODE" >&6
+
+
+if test $USE_MAINTAINER_MODE = yes; then
+ MAINTAINER_MODE_TRUE=
+ MAINTAINER_MODE_FALSE='#'
+else
+ MAINTAINER_MODE_TRUE='#'
+ MAINTAINER_MODE_FALSE=
+fi
+
+ MAINT=$MAINTAINER_MODE_TRUE
+
+
+
+ ac_config_headers="$ac_config_headers config.h"
+
+ac_aux_dir=
+for ac_dir in . $srcdir/.; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f $ac_dir/shtool; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in . $srcdir/." >&5
+echo "$as_me: error: cannot find install-sh or install.sh in . $srcdir/." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"
+ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
+
+
+# checks for progs
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$ac_ct_CC" && break
+done
+
+ CC=$ac_ct_CC
+fi
+
+fi
+
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+ "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+ (eval $ac_compiler --version </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+ (eval $ac_compiler -v </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+ (eval $ac_compiler -V </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
+ (eval $ac_link_default) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Find the output, starting from the most likely. This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+
+# Be careful to initialize this variable, since it used to be cached.
+# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
+ac_cv_exeext=
+# b.out is created by i960 compilers.
+for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
+ ;;
+ conftest.$ac_ext )
+ # This is the source file.
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ # FIXME: I believe we export ac_cv_exeext for Libtool,
+ # but it would be cool to find out if it's true. Does anybody
+ # maintain Libtool? --akim.
+ export ac_cv_exeext
+ break;;
+ * )
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6
+
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+ if { ac_try='./$ac_file'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ fi
+fi
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6
+
+echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ export ac_cv_exeext
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
+if test "${ac_cv_objext+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_compiler_gnu=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_compiler_gnu=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_g=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std1 is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std1. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX -qlanglvl=ansi
+# Ultrix and OSF/1 -std1
+# HP-UX 10.20 and later -Ae
+# HP-UX older versions -Aa -D_HPUX_SOURCE
+# SVR4 -Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+ x|xno)
+ echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+ *)
+ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+ CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
+# Some people use a C++ compiler to compile C. Since we use `exit',
+# in C++ we need to declare it. In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+ choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ for ac_declaration in \
+ '' \
+ 'extern "C" void std::exit (int) throw (); using std::exit;' \
+ 'extern "C" void std::exit (int); using std::exit;' \
+ 'extern "C" void exit (int) throw ();' \
+ 'extern "C" void exit (int);' \
+ 'void exit (int);'
+do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+#include <stdlib.h>
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+continue
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+ echo '#ifdef __cplusplus' >>confdefs.h
+ echo $ac_declaration >>confdefs.h
+ echo '#endif' >>confdefs.h
+fi
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+DEPDIR="${am__leading_dot}deps"
+
+ ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+ @echo done
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5
+echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# We grep out `Entering directory' and `Leaving directory'
+# messages which can occur if `w' ends up in MAKEFLAGS.
+# In particular we don't look at `^make:' because GNU make might
+# be invoked under some other name (usually "gmake"), in which
+# case it prints its new name instead of `make'.
+if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
+ am__include=include
+ am__quote=
+ _am_result=GNU
+fi
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+ echo '.include "confinc"' > confmf
+ if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
+ am__include=.include
+ am__quote="\""
+ _am_result=BSD
+ fi
+fi
+
+
+echo "$as_me:$LINENO: result: $_am_result" >&5
+echo "${ECHO_T}$_am_result" >&6
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then
+ enableval="$enable_dependency_tracking"
+
+fi;
+if test "x$enable_dependency_tracking" != xno; then
+ am_depcomp="$ac_aux_dir/depcomp"
+ AMDEPBACKSLASH='\'
+fi
+
+
+if test "x$enable_dependency_tracking" != xno; then
+ AMDEP_TRUE=
+ AMDEP_FALSE='#'
+else
+ AMDEP_TRUE='#'
+ AMDEP_FALSE=
+fi
+
+
+
+
+depcc="$CC" am_compiler_list=
+
+echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named `D' -- because `-MD' means `put the output
+ # in D'.
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_CC_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+ fi
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ : > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ case $depmode in
+ nosideeffect)
+ # after this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ none) break ;;
+ esac
+ # We check with `-c' and `-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle `-M -o', and we need to detect this.
+ if depmode=$depmode \
+ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored.
+ if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
+ am_cv_CC_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
+echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+
+
+if
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+ am__fastdepCC_TRUE=
+ am__fastdepCC_FALSE='#'
+else
+ am__fastdepCC_TRUE='#'
+ am__fastdepCC_FALSE=
+fi
+
+
+# Check whether --enable-shared or --disable-shared was given.
+if test "${enable_shared+set}" = set; then
+ enableval="$enable_shared"
+ p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_shared=yes ;;
+ no) enable_shared=no ;;
+ *)
+ enable_shared=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_shared=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ enable_shared=yes
+fi;
+
+# Check whether --enable-static or --disable-static was given.
+if test "${enable_static+set}" = set; then
+ enableval="$enable_static"
+ p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_static=yes ;;
+ no) enable_static=no ;;
+ *)
+ enable_static=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_static=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ enable_static=yes
+fi;
+
+# Check whether --enable-fast-install or --disable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then
+ enableval="$enable_fast_install"
+ p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_fast_install=yes ;;
+ no) enable_fast_install=no ;;
+ *)
+ enable_fast_install=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_fast_install=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ enable_fast_install=yes
+fi;
+
+# Make sure we can run config.sub.
+$ac_config_sub sun4 >/dev/null 2>&1 ||
+ { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
+echo "$as_me: error: cannot run $ac_config_sub" >&2;}
+ { (exit 1); exit 1; }; }
+
+echo "$as_me:$LINENO: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6
+if test "${ac_cv_build+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_build_alias=$build_alias
+test -z "$ac_cv_build_alias" &&
+ ac_cv_build_alias=`$ac_config_guess`
+test -z "$ac_cv_build_alias" &&
+ { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+ { (exit 1); exit 1; }; }
+ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
+ { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6
+build=$ac_cv_build
+build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+echo "$as_me:$LINENO: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6
+if test "${ac_cv_host+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_host_alias=$host_alias
+test -z "$ac_cv_host_alias" &&
+ ac_cv_host_alias=$ac_cv_build_alias
+ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
+ { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6
+host=$ac_cv_host
+host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5
+echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6
+if test "${lt_cv_path_SED+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for lt_ac_prog in sed gsed; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+ lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+ fi
+ done
+ done
+done
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+ test ! -f $lt_ac_sed && break
+ cat /dev/null > conftest.in
+ lt_ac_count=0
+ echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+ # Check for GNU sed and select it if it is found.
+ if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+ lt_cv_path_SED=$lt_ac_sed
+ break
+ fi
+ while true; do
+ cat conftest.in conftest.in >conftest.tmp
+ mv conftest.tmp conftest.in
+ cp conftest.in conftest.nl
+ echo >>conftest.nl
+ $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+ cmp -s conftest.out conftest.nl || break
+ # 10000 chars as input seems more than enough
+ test $lt_ac_count -gt 10 && break
+ lt_ac_count=`expr $lt_ac_count + 1`
+ if test $lt_ac_count -gt $lt_ac_max; then
+ lt_ac_max=$lt_ac_count
+ lt_cv_path_SED=$lt_ac_sed
+ fi
+ done
+done
+SED=$lt_cv_path_SED
+
+fi
+
+echo "$as_me:$LINENO: result: $SED" >&5
+echo "${ECHO_T}$SED" >&6
+
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+ then ac_cv_prog_egrep='grep -E'
+ else ac_cv_prog_egrep='egrep'
+ fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+
+# Check whether --with-gnu-ld or --without-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then
+ withval="$with_gnu_ld"
+ test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi;
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ echo "$as_me:$LINENO: checking for ld used by $CC" >&5
+echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [\\/]* | ?:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
+ while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ echo "$as_me:$LINENO: checking for GNU ld" >&5
+echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
+else
+ echo "$as_me:$LINENO: checking for non-GNU ld" >&5
+echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
+fi
+if test "${lt_cv_path_LD+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some GNU ld's only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ echo "$as_me:$LINENO: result: $LD" >&5
+echo "${ECHO_T}$LD" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
+echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
+ { (exit 1); exit 1; }; }
+echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
+echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
+if test "${lt_cv_prog_gnu_ld+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
+echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
+echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6
+if test "${lt_cv_ld_reload_flag+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_ld_reload_flag='-r'
+fi
+echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
+echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+
+echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5
+echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6
+if test "${lt_cv_path_NM+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$NM"; then
+ # Let the user override the test.
+ lt_cv_path_NM="$NM"
+else
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ tmp_nm="$ac_dir/${ac_tool_prefix}nm"
+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ # Tru64's nm complains that /dev/null is an invalid object file
+ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+ */dev/null* | *'Invalid file or object type'*)
+ lt_cv_path_NM="$tmp_nm -B"
+ break
+ ;;
+ *)
+ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+ */dev/null*)
+ lt_cv_path_NM="$tmp_nm -p"
+ break
+ ;;
+ *)
+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ ;;
+ esac
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+ test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+fi
+fi
+echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5
+echo "${ECHO_T}$lt_cv_path_NM" >&6
+NM="$lt_cv_path_NM"
+
+echo "$as_me:$LINENO: checking whether ln -s works" >&5
+echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+ echo "$as_me:$LINENO: result: no, using $LN_S" >&5
+echo "${ECHO_T}no, using $LN_S" >&6
+fi
+
+echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5
+echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6
+if test "${lt_cv_deplibs_check_method+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix4* | aix5*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+beos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+bsdi4*)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+ lt_cv_file_magic_cmd='/usr/bin/file -L'
+ lt_cv_file_magic_test_file=/shlib/libc.so
+ ;;
+
+cygwin*)
+ # win32_libid is a shell function defined in ltmain.sh
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='win32_libid'
+ ;;
+
+mingw* | pw32*)
+ # Base MSYS/MinGW do not provide the 'file' command needed by
+ # win32_libid shell function, so use a weaker test based on 'objdump'.
+ lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ ;;
+
+darwin* | rhapsody*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+freebsd* | kfreebsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ case $host_cpu in
+ i*86 )
+ # Not sure whether the presence of OpenBSD here was a mistake.
+ # Let's accept both of them until this is cleared up.
+ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+ ;;
+ esac
+ else
+ lt_cv_deplibs_check_method=pass_all
+ fi
+ ;;
+
+gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+hpux10.20* | hpux11*)
+ lt_cv_file_magic_cmd=/usr/bin/file
+ case "$host_cpu" in
+ ia64*)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+ hppa*64*)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'
+ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
+ *)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
+ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+ esac
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $LD in
+ *-32|*"-32 ") libmagic=32-bit;;
+ *-n32|*"-n32 ") libmagic=N32;;
+ *-64|*"-64 ") libmagic=64-bit;;
+ *) libmagic=never-match;;
+ esac
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+# This must be Linux ELF.
+linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+ fi
+ ;;
+
+newos6*)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=/usr/lib/libnls.so
+ ;;
+
+nto-qnx*)
+ lt_cv_deplibs_check_method=unknown
+ ;;
+
+openbsd*)
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object'
+ else
+ lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library'
+ fi
+ ;;
+
+osf3* | osf4* | osf5*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sco3.2v5*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+solaris*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ case $host_vendor in
+ motorola)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+ ;;
+ ncr)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ sequent)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+ ;;
+ sni)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+ lt_cv_file_magic_test_file=/lib/libc.so
+ ;;
+ siemens)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ esac
+ ;;
+
+sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7* | sysv4*uw2*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+esac
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5
+echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then
+ enableval="$enable_libtool_lock"
+
+fi;
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *ELF-32*)
+ HPUX_IA64_MODE="32"
+ ;;
+ *ELF-64*)
+ HPUX_IA64_MODE="64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+*-*-irix6*)
+ # Find out which ABI we are using.
+ echo '#line 3664 "configure"' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -melf32bsmip"
+ ;;
+ *N32*)
+ LD="${LD-ld} -melf32bmipn32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -melf64bmip"
+ ;;
+ esac
+ else
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
+ fi
+ rm -rf conftest*
+ ;;
+
+x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ case "`/usr/bin/file conftest.o`" in
+ *32-bit*)
+ case $host in
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_i386"
+ ;;
+ ppc64-*linux*|powerpc64-*linux*)
+ LD="${LD-ld} -m elf32ppclinux"
+ ;;
+ s390x-*linux*)
+ LD="${LD-ld} -m elf_s390"
+ ;;
+ sparc64-*linux*)
+ LD="${LD-ld} -m elf32_sparc"
+ ;;
+ esac
+ ;;
+ *64-bit*)
+ case $host in
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ ppc*-*linux*|powerpc*-*linux*)
+ LD="${LD-ld} -m elf64ppc"
+ ;;
+ s390*-*linux*)
+ LD="${LD-ld} -m elf64_s390"
+ ;;
+ sparc*-*linux*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+*-*-sco3.2v5*)
+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -belf"
+ echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5
+echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6
+if test "${lt_cv_cc_needs_belf+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ lt_cv_cc_needs_belf=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+lt_cv_cc_needs_belf=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5
+echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6
+ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+ CFLAGS="$SAVE_CFLAGS"
+ fi
+ ;;
+
+esac
+
+need_locks="$enable_libtool_lock"
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if test "${ac_cv_prog_CPP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ :
+else
+ { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_header_stdc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ exit(2);
+ exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+for ac_header in dlfcn.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## -------------------------------- ##
+## Report this to keithp@keithp.com ##
+## -------------------------------- ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+ac_ext=cc
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CXX+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CXX"; then
+ ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+ echo "$as_me:$LINENO: result: $CXX" >&5
+echo "${ECHO_T}$CXX" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$CXX" && break
+ done
+fi
+if test -z "$CXX"; then
+ ac_ct_CXX=$CXX
+ for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CXX"; then
+ ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CXX="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
+echo "${ECHO_T}$ac_ct_CXX" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$ac_ct_CXX" && break
+done
+test -n "$ac_ct_CXX" || ac_ct_CXX="g++"
+
+ CXX=$ac_ct_CXX
+fi
+
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+ "checking for C++ compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+ (eval $ac_compiler --version </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+ (eval $ac_compiler -v </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+ (eval $ac_compiler -V </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+
+echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
+if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_compiler_gnu=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_compiler_gnu=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
+GXX=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="-g"
+echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
+echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cxx_g+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cxx_g=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_prog_cxx_g=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
+if test "$ac_test_CXXFLAGS" = set; then
+ CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+ if test "$GXX" = yes; then
+ CXXFLAGS="-g -O2"
+ else
+ CXXFLAGS="-g"
+ fi
+else
+ if test "$GXX" = yes; then
+ CXXFLAGS="-O2"
+ else
+ CXXFLAGS=
+ fi
+fi
+for ac_declaration in \
+ '' \
+ 'extern "C" void std::exit (int) throw (); using std::exit;' \
+ 'extern "C" void std::exit (int); using std::exit;' \
+ 'extern "C" void exit (int) throw ();' \
+ 'extern "C" void exit (int);' \
+ 'void exit (int);'
+do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+#include <stdlib.h>
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+continue
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+ echo '#ifdef __cplusplus' >>confdefs.h
+ echo $ac_declaration >>confdefs.h
+ echo '#endif' >>confdefs.h
+fi
+
+ac_ext=cc
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+depcc="$CXX" am_compiler_list=
+
+echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
+if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named `D' -- because `-MD' means `put the output
+ # in D'.
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_CXX_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+ fi
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ : > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ case $depmode in
+ nosideeffect)
+ # after this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ none) break ;;
+ esac
+ # We check with `-c' and `-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle `-M -o', and we need to detect this.
+ if depmode=$depmode \
+ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored.
+ if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
+ am_cv_CXX_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
+echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+
+
+if
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+ am__fastdepCXX_TRUE=
+ am__fastdepCXX_FALSE='#'
+else
+ am__fastdepCXX_TRUE='#'
+ am__fastdepCXX_FALSE=
+fi
+
+
+ac_ext=cc
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5
+echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6
+if test -z "$CXXCPP"; then
+ if test "${ac_cv_prog_CXXCPP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Double quotes because CXXCPP needs to be expanded
+ for CXXCPP in "$CXX -E" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_cxx_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_cxx_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CXXCPP=$CXXCPP
+
+fi
+ CXXCPP=$ac_cv_prog_CXXCPP
+else
+ ac_cv_prog_CXXCPP=$CXXCPP
+fi
+echo "$as_me:$LINENO: result: $CXXCPP" >&5
+echo "${ECHO_T}$CXXCPP" >&6
+ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_cxx_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_cxx_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ :
+else
+ { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=cc
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_F77+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$F77"; then
+ ac_cv_prog_F77="$F77" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_F77="$ac_tool_prefix$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+F77=$ac_cv_prog_F77
+if test -n "$F77"; then
+ echo "$as_me:$LINENO: result: $F77" >&5
+echo "${ECHO_T}$F77" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$F77" && break
+ done
+fi
+if test -z "$F77"; then
+ ac_ct_F77=$F77
+ for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_F77+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_F77"; then
+ ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_F77="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_F77=$ac_cv_prog_ac_ct_F77
+if test -n "$ac_ct_F77"; then
+ echo "$as_me:$LINENO: result: $ac_ct_F77" >&5
+echo "${ECHO_T}$ac_ct_F77" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$ac_ct_F77" && break
+done
+
+ F77=$ac_ct_F77
+fi
+
+
+# Provide some information about the compiler.
+echo "$as_me:5221:" \
+ "checking for Fortran 77 compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+ (eval $ac_compiler --version </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+ (eval $ac_compiler -v </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+ (eval $ac_compiler -V </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+rm -f a.out
+
+# If we don't use `.F' as extension, the preprocessor is not run on the
+# input file. (Note that this only needs to work for GNU compilers.)
+ac_save_ext=$ac_ext
+ac_ext=F
+echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6
+if test "${ac_cv_f77_compiler_gnu+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+ program main
+#ifndef __GNUC__
+ choke me
+#endif
+
+ end
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_compiler_gnu=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_compiler_gnu=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_f77_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6
+ac_ext=$ac_save_ext
+ac_test_FFLAGS=${FFLAGS+set}
+ac_save_FFLAGS=$FFLAGS
+FFLAGS=
+echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5
+echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_f77_g+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ FFLAGS=-g
+cat >conftest.$ac_ext <<_ACEOF
+ program main
+
+ end
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_f77_g=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_prog_f77_g=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5
+echo "${ECHO_T}$ac_cv_prog_f77_g" >&6
+if test "$ac_test_FFLAGS" = set; then
+ FFLAGS=$ac_save_FFLAGS
+elif test $ac_cv_prog_f77_g = yes; then
+ if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+ FFLAGS="-g -O2"
+ else
+ FFLAGS="-g"
+ fi
+else
+ if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+ FFLAGS="-O2"
+ else
+ FFLAGS=
+ fi
+fi
+
+G77=`test $ac_compiler_gnu = yes && echo yes`
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
+
+# find the maximum length of command line arguments
+echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
+echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6
+if test "${lt_cv_sys_max_cmd_len+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ i=0
+ testring="ABCD"
+
+ case $build_os in
+ msdosdjgpp*)
+ # On DJGPP, this test can blow up pretty badly due to problems in libc
+ # (any single argument exceeding 2000 bytes causes a buffer overrun
+ # during glob expansion). Even if it were fixed, the result of this
+ # check would be larger than it should be.
+ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+
+ gnu*)
+ # Under GNU Hurd, this test is not required because there is
+ # no limit to the length of command line arguments.
+ # Libtool will interpret -1 as no limit whatsoever
+ lt_cv_sys_max_cmd_len=-1;
+ ;;
+
+ cygwin* | mingw*)
+ # On Win9x/ME, this test blows up -- it succeeds, but takes
+ # about 5 minutes as the teststring grows exponentially.
+ # Worse, since 9x/ME are not pre-emptively multitasking,
+ # you end up with a "frozen" computer, even though with patience
+ # the test eventually succeeds (with a max line length of 256k).
+ # Instead, let's just punt: use the minimum linelength reported by
+ # all of the supported platforms: 8192 (on NT/2K/XP).
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ amigaos*)
+ # On AmigaOS with pdksh, this test takes hours, literally.
+ # So we just punt and use a minimum line length of 8192.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ *)
+ # If test is not a shell built-in, we'll probably end up computing a
+ # maximum length that is only half of the actual maximum length, but
+ # we can't tell.
+ while (test "X"`$CONFIG_SHELL $0 --fallback-echo "X$testring" 2>/dev/null` \
+ = "XX$testring") >/dev/null 2>&1 &&
+ new_result=`expr "X$testring" : ".*" 2>&1` &&
+ lt_cv_sys_max_cmd_len=$new_result &&
+ test $i != 17 # 1/2 MB should be enough
+ do
+ i=`expr $i + 1`
+ testring=$testring$testring
+ done
+ testring=
+ # Add a significant safety factor because C++ compilers can tack on massive
+ # amounts of additional arguments before passing them to the linker.
+ # It appears as though 1/2 is a usable value.
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+ ;;
+ esac
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+ echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5
+echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6
+else
+ echo "$as_me:$LINENO: result: none" >&5
+echo "${ECHO_T}none" >&6
+fi
+
+
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5
+echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6
+if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Transform the above into a raw symbol and a C symbol.
+symxfrm='\1 \2\3 \3'
+
+# Transform an extracted symbol line into a proper C declaration
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+ symcode='[BCDT]'
+ ;;
+cygwin* | mingw* | pw32*)
+ symcode='[ABCDGISTW]'
+ ;;
+hpux*) # Its linker distinguishes data from code symbols
+ if test "$host_cpu" = ia64; then
+ symcode='[ABCDEGRST]'
+ fi
+ lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+ lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
+ ;;
+irix* | nonstopux*)
+ symcode='[BCDEGRST]'
+ ;;
+osf*)
+ symcode='[BCDEGQRST]'
+ ;;
+solaris* | sysv5*)
+ symcode='[BDRT]'
+ ;;
+sysv4)
+ symcode='[DFNSTU]'
+ ;;
+esac
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+ opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+ ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+ symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+ # Write the raw and C identifiers.
+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"
+
+ # Check to see that the pipe works correctly.
+ pipe_works=no
+
+ rm -f conftest*
+ cat > conftest.$ac_ext <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+EOF
+
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Now try to grab the symbols.
+ nlist=conftest.nm
+ if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5
+ (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s "$nlist"; then
+ # Try sorting and uniquifying the output.
+ if sort "$nlist" | uniq > "$nlist"T; then
+ mv -f "$nlist"T "$nlist"
+ else
+ rm -f "$nlist"T
+ fi
+
+ # Make sure that we snagged all the symbols we need.
+ if grep ' nm_test_var$' "$nlist" >/dev/null; then
+ if grep ' nm_test_func$' "$nlist" >/dev/null; then
+ cat <<EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+ # Now generate the symbol file.
+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
+
+ cat <<EOF >> conftest.$ac_ext
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ lt_ptr_t address;
+}
+lt_preloaded_symbols[] =
+{
+EOF
+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
+ cat <<\EOF >> conftest.$ac_ext
+ {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+ # Now try linking the two files.
+ mv conftest.$ac_objext conftstm.$ac_objext
+ lt_save_LIBS="$LIBS"
+ lt_save_CFLAGS="$CFLAGS"
+ LIBS="conftstm.$ac_objext"
+ CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s conftest${ac_exeext}; then
+ pipe_works=yes
+ fi
+ LIBS="$lt_save_LIBS"
+ CFLAGS="$lt_save_CFLAGS"
+ else
+ echo "cannot find nm_test_func in $nlist" >&5
+ fi
+ else
+ echo "cannot find nm_test_var in $nlist" >&5
+ fi
+ else
+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+ fi
+ else
+ echo "$progname: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ fi
+ rm -f conftest* conftst*
+
+ # Do not use the global_symbol_pipe unless it works.
+ if test "$pipe_works" = yes; then
+ break
+ else
+ lt_cv_sys_global_symbol_pipe=
+ fi
+done
+
+fi
+
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+ lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+ echo "$as_me:$LINENO: result: failed" >&5
+echo "${ECHO_T}failed" >&6
+else
+ echo "$as_me:$LINENO: result: ok" >&5
+echo "${ECHO_T}ok" >&6
+fi
+
+echo "$as_me:$LINENO: checking for objdir" >&5
+echo $ECHO_N "checking for objdir... $ECHO_C" >&6
+if test "${lt_cv_objdir+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+ lt_cv_objdir=.libs
+else
+ # MS-DOS does not allow filenames that begin with a dot.
+ lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+fi
+echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5
+echo "${ECHO_T}$lt_cv_objdir" >&6
+objdir=$lt_cv_objdir
+
+
+
+
+
+case $host_os in
+aix3*)
+ # AIX sometimes has problems with the GCC collect2 program. For some
+ # reason, if we set the COLLECT_NAMES environment variable, the problems
+ # vanish in a puff of smoke.
+ if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+ fi
+ ;;
+esac
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e s/^X//'
+sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Constants:
+rm="rm -f"
+
+# Global variables:
+default_ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except M$VC,
+# which needs '.lib').
+libext=a
+ltmain="$ac_aux_dir/ltmain.sh"
+ofile="$default_ofile"
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_AR+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AR="${ac_tool_prefix}ar"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+ echo "$as_me:$LINENO: result: $AR" >&5
+echo "${ECHO_T}$AR" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+ ac_ct_AR=$AR
+ # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_AR"; then
+ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_AR="ar"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="false"
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+ echo "$as_me:$LINENO: result: $ac_ct_AR" >&5
+echo "${ECHO_T}$ac_ct_AR" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ AR=$ac_ct_AR
+else
+ AR="$ac_cv_prog_AR"
+fi
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_RANLIB+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+ echo "$as_me:$LINENO: result: $RANLIB" >&5
+echo "${ECHO_T}$RANLIB" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+ ac_ct_RANLIB=$RANLIB
+ # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_RANLIB"; then
+ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_RANLIB="ranlib"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+ echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
+echo "${ECHO_T}$ac_ct_RANLIB" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ RANLIB=$ac_ct_RANLIB
+else
+ RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_STRIP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$STRIP"; then
+ ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+ echo "$as_me:$LINENO: result: $STRIP" >&5
+echo "${ECHO_T}$STRIP" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+ ac_ct_STRIP=$STRIP
+ # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_STRIP"; then
+ ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_STRIP="strip"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+ echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+echo "${ECHO_T}$ac_ct_STRIP" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ STRIP=$ac_ct_STRIP
+else
+ STRIP="$ac_cv_prog_STRIP"
+fi
+
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+test -z "$AS" && AS=as
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+test -z "$LD" && LD=ld
+test -z "$LN_S" && LN_S="ln -s"
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+test -z "$NM" && NM=nm
+test -z "$SED" && SED=sed
+test -z "$OBJDUMP" && OBJDUMP=objdump
+test -z "$RANLIB" && RANLIB=:
+test -z "$STRIP" && STRIP=:
+test -z "$ac_objext" && ac_objext=o
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+ case $host_os in
+ openbsd*)
+ old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds"
+ ;;
+ *)
+ old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+ ;;
+ esac
+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+# Only perform the check for file, if the check method requires it
+case $deplibs_check_method in
+file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+ echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
+echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $MAGIC_CMD in
+[\\/*] | ?:[\\/]*)
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/${ac_tool_prefix}file; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
+echo "${ECHO_T}$MAGIC_CMD" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+ if test -n "$ac_tool_prefix"; then
+ echo "$as_me:$LINENO: checking for file" >&5
+echo $ECHO_N "checking for file... $ECHO_C" >&6
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $MAGIC_CMD in
+[\\/*] | ?:[\\/]*)
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/file; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/file"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
+echo "${ECHO_T}$MAGIC_CMD" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ else
+ MAGIC_CMD=:
+ fi
+fi
+
+ fi
+ ;;
+esac
+
+enable_dlopen=no
+enable_win32_dll=no
+
+# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then
+ enableval="$enable_libtool_lock"
+
+fi;
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+
+# Check whether --with-pic or --without-pic was given.
+if test "${with_pic+set}" = set; then
+ withval="$with_pic"
+ pic_mode="$withval"
+else
+ pic_mode=default
+fi;
+test -z "$pic_mode" && pic_mode=default
+
+# Use C for the default configuration in the libtool script
+tagname=
+lt_save_CC="$CC"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}\n'
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+#
+# Check for any special shared library compilation flags.
+#
+lt_prog_cc_shlib=
+if test "$GCC" = no; then
+ case $host_os in
+ sco3.2v5*)
+ lt_prog_cc_shlib='-belf'
+ ;;
+ esac
+fi
+if test -n "$lt_prog_cc_shlib"; then
+ { echo "$as_me:$LINENO: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&5
+echo "$as_me: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&2;}
+ if echo "$old_CC $old_CFLAGS " | grep "[ ]$lt_prog_cc_shlib[ ]" >/dev/null; then :
+ else
+ { echo "$as_me:$LINENO: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5
+echo "$as_me: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&2;}
+ lt_cv_prog_cc_can_build_shared=no
+ fi
+fi
+
+
+#
+# Check to make sure the static flag actually works.
+#
+echo "$as_me:$LINENO: checking if $compiler static flag $lt_prog_compiler_static works" >&5
+echo $ECHO_N "checking if $compiler static flag $lt_prog_compiler_static works... $ECHO_C" >&6
+if test "${lt_prog_compiler_static_works+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_prog_compiler_static_works=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $lt_prog_compiler_static"
+ printf "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ else
+ lt_prog_compiler_static_works=yes
+ fi
+ fi
+ $rm conftest*
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5
+echo "${ECHO_T}$lt_prog_compiler_static_works" >&6
+
+if test x"$lt_prog_compiler_static_works" = xyes; then
+ :
+else
+ lt_prog_compiler_static=
+fi
+
+
+
+
+lt_prog_compiler_no_builtin_flag=
+
+if test "$GCC" = yes; then
+ lt_prog_compiler_no_builtin_flag=' -fno-builtin'
+
+
+echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_prog_compiler_rtti_exceptions=no
+ ac_outfile=conftest.$ac_objext
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="-fno-rtti -fno-exceptions"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:6253: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:6257: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test ! -s conftest.err; then
+ lt_cv_prog_compiler_rtti_exceptions=yes
+ fi
+ fi
+ $rm conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+ lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+ :
+fi
+
+fi
+
+lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
+
+ if test "$GCC" = yes; then
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_static='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+ ;;
+
+ beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+
+ mingw* | pw32* | os2*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic='-DDLL_EXPORT'
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ lt_prog_compiler_pic='-fno-common'
+ ;;
+
+ msdosdjgpp*)
+ # Just because we use GCC doesn't mean we suddenly get shared libraries
+ # on systems that don't support them.
+ lt_prog_compiler_can_build_shared=no
+ enable_shared=no
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic=-Kconform_pic
+ fi
+ ;;
+
+ hpux*)
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ esac
+ ;;
+
+ *)
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ lt_prog_compiler_wl='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static='-Bstatic'
+ else
+ lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+
+ mingw* | pw32* | os2*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic='-DDLL_EXPORT'
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ lt_prog_compiler_wl='-Wl,'
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ lt_prog_compiler_static='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ lt_prog_compiler_wl='-Wl,'
+ # PIC (with -KPIC) is the default.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ newsos6)
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ linux*)
+ case $CC in
+ icc* | ecc*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-static'
+ ;;
+ ccc*)
+ lt_prog_compiler_wl='-Wl,'
+ # All Alpha code is PIC.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+ esac
+ ;;
+
+ osf3* | osf4* | osf5*)
+ lt_prog_compiler_wl='-Wl,'
+ # All OSF/1 code is PIC.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ sco3.2v5*)
+ lt_prog_compiler_pic='-Kpic'
+ lt_prog_compiler_static='-dn'
+ ;;
+
+ solaris*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ sunos4*)
+ lt_prog_compiler_wl='-Qoption ld '
+ lt_prog_compiler_pic='-PIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ lt_prog_compiler_pic='-Kconform_pic'
+ lt_prog_compiler_static='-Bstatic'
+ fi
+ ;;
+
+ uts4*)
+ lt_prog_compiler_pic='-pic'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ *)
+ lt_prog_compiler_can_build_shared=no
+ ;;
+ esac
+ fi
+
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic" >&6
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+
+echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6
+if test "${lt_prog_compiler_pic_works+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_prog_compiler_pic_works=no
+ ac_outfile=conftest.$ac_objext
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:6486: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:6490: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test ! -s conftest.err; then
+ lt_prog_compiler_pic_works=yes
+ fi
+ fi
+ $rm conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6
+
+if test x"$lt_prog_compiler_pic_works" = xyes; then
+ case $lt_prog_compiler_pic in
+ "" | " "*) ;;
+ *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+ esac
+else
+ lt_prog_compiler_pic=
+ lt_prog_compiler_can_build_shared=no
+fi
+
+fi
+case "$host_os" in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ lt_prog_compiler_pic=
+ ;;
+ *)
+ lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+ ;;
+esac
+
+echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_c_o+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_prog_compiler_c_o=no
+ $rm -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:6546: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:6550: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test ! -s out/conftest.err; then
+ lt_cv_prog_compiler_c_o=yes
+ fi
+ fi
+ chmod u+w .
+ $rm conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+ $rm out/* && rmdir out
+ cd ..
+ rmdir conftest
+ $rm conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
+ hard_links=yes
+ $rm conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ echo "$as_me:$LINENO: result: $hard_links" >&5
+echo "${ECHO_T}$hard_links" >&6
+ if test "$hard_links" = no; then
+ { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+
+echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
+
+ runpath_var=
+ allow_undefined_flag=
+ enable_shared_with_static_runtimes=no
+ archive_cmds=
+ archive_expsym_cmds=
+ old_archive_From_new_cmds=
+ old_archive_from_expsyms_cmds=
+ export_dynamic_flag_spec=
+ whole_archive_flag_spec=
+ thread_safe_flag_spec=
+ hardcode_libdir_flag_spec=
+ hardcode_libdir_flag_spec_ld=
+ hardcode_libdir_separator=
+ hardcode_direct=no
+ hardcode_minus_L=no
+ hardcode_shlibpath_var=unsupported
+ link_all_deplibs=unknown
+ hardcode_automatic=no
+ module_cmds=
+ module_expsym_cmds=
+ always_export_symbols=no
+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ include_expsyms=
+ # exclude_expsyms can be an extended regexp of symbols to exclude
+ # it will be wrapped by ` (' and `)$', so one must not match beginning or
+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+ # as well as any symbol that contains `d'.
+ exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+ # platforms (ab)use it in PIC code, but their linkers get confused if
+ # the symbol is explicitly referenced. Since portable code cannot
+ # rely on this symbol name, it's probably fine to never include it in
+ # preloaded symbol tables.
+ extract_expsyms_cmds=
+
+ case $host_os in
+ cygwin* | mingw* | pw32*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+ esac
+
+ ld_shlibs=yes
+ if test "$with_gnu_ld" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # See if GNU ld supports shared libraries.
+ case $host_os in
+ aix3* | aix4* | aix5*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ ld_shlibs=no
+ cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+ fi
+ ;;
+
+ amigaos*)
+ archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+
+ # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+ # that the semantics of dynamic libraries on AmigaOS, at least up
+ # to version 4, is to share data among multiple programs linked
+ # with the same dynamic library. Since this doesn't match the
+ # behavior of shared libraries on other platforms, we can't use
+ # them.
+ ld_shlibs=no
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ allow_undefined_flag=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+ # as there is no search path for DLLs.
+ hardcode_libdir_flag_spec='-L$libdir'
+ allow_undefined_flag=unsupported
+ always_export_symbols=no
+ enable_shared_with_static_runtimes=yes
+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+
+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ fi
+ ;;
+
+ solaris* | sysv5*)
+ if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+ ld_shlibs=no
+ cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+ elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ sunos4*)
+ archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ linux*)
+ if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+ tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_cmds="$tmp_archive_cmds"
+ supports_anon_versioning=no
+ case `$LD -v 2>/dev/null` in
+ *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+ *\ 2.11.*) ;; # other 2.11 versions
+ *) supports_anon_versioning=yes ;;
+ esac
+ if test $supports_anon_versioning = yes; then
+ archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ else
+ archive_expsym_cmds="$tmp_archive_cmds"
+ fi
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ *)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+
+ if test "$ld_shlibs" = yes; then
+ runpath_var=LD_RUN_PATH
+ hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
+ export_dynamic_flag_spec='${wl}--export-dynamic'
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ whole_archive_flag_spec=
+ fi
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ allow_undefined_flag=unsupported
+ always_export_symbols=yes
+ archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ hardcode_minus_L=yes
+ if test "$GCC" = yes && test -z "$link_static_flag"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ hardcode_direct=unsupported
+ fi
+ ;;
+
+ aix4* | aix5*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+ export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+ else
+ export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+ fi
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ archive_cmds=''
+ hardcode_direct=yes
+ hardcode_libdir_separator=':'
+ link_all_deplibs=yes
+
+ if test "$GCC" = yes; then
+ case $host_os in aix4.012|aix4.012.*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" && \
+ strings "$collect2name" | grep resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ hardcode_direct=yes
+ else
+ # We have old collect2
+ hardcode_direct=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ hardcode_minus_L=yes
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_libdir_separator=
+ fi
+ esac
+ shared_flag='-shared'
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ always_export_symbols=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ allow_undefined_flag='-berok'
+ # Determine the default libpath from the value encoded in an empty executable.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`; fi
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+ allow_undefined_flag="-z nodefs"
+ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an empty executable.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`; fi
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ no_undefined_flag=' ${wl}-bernotok'
+ allow_undefined_flag=' ${wl}-berok'
+ # -bexpall does not export symbols beginning with underscore (_)
+ always_export_symbols=yes
+ # Exported symbols can be pulled into shared objects from archives
+ whole_archive_flag_spec=' '
+ archive_cmds_need_lc=yes
+ # This is similar to how AIX traditionally builds it's shared libraries.
+ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ amigaos*)
+ archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ # see comment about different semantics on the GNU ld section
+ ld_shlibs=no
+ ;;
+
+ bsdi4*)
+ export_dynamic_flag_spec=-rdynamic
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec=' '
+ allow_undefined_flag=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ old_archive_From_new_cmds='true'
+ # FIXME: Should let the user specify the lib program.
+ old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs'
+ fix_srcfile_path='`cygpath -w "$srcfile"`'
+ enable_shared_with_static_runtimes=yes
+ ;;
+
+ darwin* | rhapsody*)
+ if test "$GXX" = yes ; then
+ archive_cmds_need_lc=no
+ case "$host_os" in
+ rhapsody* | darwin1.[012])
+ allow_undefined_flag='-undefined suppress'
+ ;;
+ *) # Darwin 1.3 on
+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+ allow_undefined_flag='-flat_namespace -undefined suppress'
+ else
+ case ${MACOSX_DEPLOYMENT_TARGET} in
+ 10.[012])
+ allow_undefined_flag='-flat_namespace -undefined suppress'
+ ;;
+ 10.*)
+ allow_undefined_flag='-undefined dynamic_lookup'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ lt_int_apple_cc_single_mod=no
+ output_verbose_link_cmd='echo'
+ if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+ lt_int_apple_cc_single_mod=yes
+ fi
+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+ archive_cmds='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ else
+ archive_cmds='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ fi
+ module_cmds='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+ archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ else
+ archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ hardcode_direct=no
+ hardcode_automatic=yes
+ hardcode_shlibpath_var=unsupported
+ whole_archive_flag_spec='-all_load $convenience'
+ link_all_deplibs=yes
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ dgux*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_shlibpath_var=no
+ ;;
+
+ freebsd1*)
+ ld_shlibs=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | kfreebsd*-gnu)
+ archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ fi
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ export_dynamic_flag_spec='${wl}-E'
+ ;;
+
+ hpux10* | hpux11*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ else
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ archive_cmds='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+ ;;
+ *)
+ archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+ ;;
+ esac
+ fi
+ if test "$with_gnu_ld" = no; then
+ case "$host_cpu" in
+ hppa*64*)
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_flag_spec_ld='+b $libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=no
+ hardcode_shlibpath_var=no
+ ;;
+ ia64*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_direct=no
+ hardcode_shlibpath_var=no
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ ;;
+ *)
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+ export_dynamic_flag_spec='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec_ld='-rpath $libdir'
+ fi
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ link_all_deplibs=yes
+ ;;
+
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ newsos6)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_shlibpath_var=no
+ ;;
+
+ openbsd*)
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec='${wl}-E'
+ else
+ case $host_os in
+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-R$libdir'
+ ;;
+ *)
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ ;;
+
+ os2*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ allow_undefined_flag=unsupported
+ archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+ old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ allow_undefined_flag=' -expect_unresolved \*'
+ archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+ fi
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ else
+ allow_undefined_flag=' -expect_unresolved \*'
+ archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
+
+ # Both c and cxx compiler support -rpath directly
+ hardcode_libdir_flag_spec='-rpath $libdir'
+ fi
+ hardcode_libdir_separator=:
+ ;;
+
+ sco3.2v5*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var=no
+ export_dynamic_flag_spec='${wl}-Bexport'
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ ;;
+
+ solaris*)
+ no_undefined_flag=' -z text'
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+ else
+ archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+ fi
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_shlibpath_var=no
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+ whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
+ esac
+ link_all_deplibs=yes
+ ;;
+
+ sunos4*)
+ if test "x$host_vendor" = xsequent; then
+ # Use $CC to link under sequent, because it throws in some extra .o
+ # files that make .init and .fini sections work.
+ archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ reload_cmds='$CC -r -o $output$reload_objs'
+ hardcode_direct=no
+ ;;
+ motorola)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ hardcode_shlibpath_var=no
+ ;;
+
+ sysv4.3*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var=no
+ export_dynamic_flag_spec='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ ld_shlibs=yes
+ fi
+ ;;
+
+ sysv4.2uw2*)
+ archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes
+ hardcode_minus_L=no
+ hardcode_shlibpath_var=no
+ hardcode_runpath_var=yes
+ runpath_var=LD_RUN_PATH
+ ;;
+
+ sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*)
+ no_undefined_flag='${wl}-z ${wl}text'
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ runpath_var='LD_RUN_PATH'
+ hardcode_shlibpath_var=no
+ ;;
+
+ sysv5*)
+ no_undefined_flag=' -z text'
+ # $CC -shared without GNU ld will not create a library from C++
+ # object files and a static libstdc++, better avoid it by now
+ archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+ hardcode_libdir_flag_spec=
+ hardcode_shlibpath_var=no
+ runpath_var='LD_RUN_PATH'
+ ;;
+
+ uts4*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_shlibpath_var=no
+ ;;
+
+ *)
+ ld_shlibs=no
+ ;;
+ esac
+ fi
+
+echo "$as_me:$LINENO: result: $ld_shlibs" >&5
+echo "${ECHO_T}$ld_shlibs" >&6
+test "$ld_shlibs" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+ # Assume -lc should be added
+ archive_cmds_need_lc=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $archive_cmds in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
+ $rm conftest*
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$lt_prog_compiler_wl
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$allow_undefined_flag
+ allow_undefined_flag=
+ if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
+ (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+ then
+ archive_cmds_need_lc=no
+ else
+ archive_cmds_need_lc=yes
+ fi
+ allow_undefined_flag=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $rm conftest*
+ echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5
+echo "${ECHO_T}$archive_cmds_need_lc" >&6
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+if test "$GCC" = yes; then
+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+ # if the path contains ";" then we assume it to be the separator
+ # otherwise default to the standard path separator (i.e. ":") - it is
+ # assumed that no part of a normal pathname contains ";" but that should
+ # okay in the real world where ";" in dirpaths is itself problematic.
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+else
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix4* | aix5*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[01] | aix4.[01].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi4*)
+ version_type=linux
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32*)
+ version_type=windows
+ shrext=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$host_os in
+ yes,cygwin* | yes,mingw* | yes,pw32*)
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $rm \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+ ;;
+ mingw*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+ # It is most probably a Windows format PATH printed by
+ # mingw gcc, but we are running on Cygwin. Gcc prints its search
+ # path with ; separators, and with drive letters. We can handle the
+ # drive letters (cygwin fileutils understands them), so leave them,
+ # especially as we might pass files found there to a mingw objdump,
+ # which wouldn't understand a cygwinified path. Ahh.
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ ;;
+
+ *)
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext='$(test .$module = .yes && echo .so || echo .dylib)'
+ # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+ if test "$GCC" = yes; then
+ sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+ else
+ sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+ fi
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd1*)
+ dynamic_linker=no
+ ;;
+
+kfreebsd*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='GNU ld.so'
+ ;;
+
+freebsd*)
+ objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.01* | freebsdelf3.01*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ *) # from 3.2 on
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case "$host_cpu" in
+ ia64*)
+ shrext='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555.
+ postinstall_cmds='chmod 555 $lib'
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be Linux ELF.
+linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $ld_extra"
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+knetbsd*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='GNU ld.so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+nto-qnx*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+openbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=yes
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[89] | openbsd2.[89].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+sco3.2v5*)
+ version_type=osf
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+solaris*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ export_dynamic_flag_spec='${wl}-Blargedynsym'
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+uts4*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+echo "$as_me:$LINENO: result: $dynamic_linker" >&5
+echo "${ECHO_T}$dynamic_linker" >&6
+test "$dynamic_linker" = no && can_build_shared=no
+
+echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" || \
+ test -n "$runpath_var " || \
+ test "X$hardcode_automatic"="Xyes" ; then
+
+ # We can hardcode non-existant directories.
+ if test "$hardcode_direct" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no &&
+ test "$hardcode_minus_L" != no; then
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action=unsupported
+fi
+echo "$as_me:$LINENO: result: $hardcode_action" >&5
+echo "${ECHO_T}$hardcode_action" >&6
+
+if test "$hardcode_action" = relink; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+
+striplib=
+old_striplib=
+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+ case $host_os in
+ darwin*)
+ if test -n "$STRIP" ; then
+ striplib="$STRIP -x"
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+ ;;
+ *)
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ ;;
+ esac
+fi
+
+if test "x$enable_dlopen" != xyes; then
+ enable_dlopen=unknown
+ enable_dlopen_self=unknown
+ enable_dlopen_self_static=unknown
+else
+ lt_cv_dlopen=no
+ lt_cv_dlopen_libs=
+
+ case $host_os in
+ beos*)
+ lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ;;
+
+ mingw* | pw32*)
+ lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen_libs=
+ ;;
+
+ cygwin*)
+ lt_cv_dlopen="dlopen"
+ lt_cv_dlopen_libs=
+ ;;
+
+ darwin*)
+ # if libdl is installed we need to link against it
+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dl_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+ lt_cv_dlopen="dyld"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+
+fi
+
+ ;;
+
+ *)
+ echo "$as_me:$LINENO: checking for shl_load" >&5
+echo $ECHO_N "checking for shl_load... $ECHO_C" >&6
+if test "${ac_cv_func_shl_load+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define shl_load innocuous_shl_load
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char shl_load (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef shl_load
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char shl_load ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_shl_load) || defined (__stub___shl_load)
+choke me
+#else
+char (*f) () = shl_load;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != shl_load;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_shl_load=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_shl_load=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
+echo "${ECHO_T}$ac_cv_func_shl_load" >&6
+if test $ac_cv_func_shl_load = yes; then
+ lt_cv_dlopen="shl_load"
+else
+ echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
+echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char shl_load ();
+int
+main ()
+{
+shl_load ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dld_shl_load=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dld_shl_load=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6
+if test $ac_cv_lib_dld_shl_load = yes; then
+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
+else
+ echo "$as_me:$LINENO: checking for dlopen" >&5
+echo $ECHO_N "checking for dlopen... $ECHO_C" >&6
+if test "${ac_cv_func_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define dlopen innocuous_dlopen
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char dlopen (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef dlopen
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_dlopen) || defined (__stub___dlopen)
+choke me
+#else
+char (*f) () = dlopen;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != dlopen;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
+echo "${ECHO_T}$ac_cv_func_dlopen" >&6
+if test $ac_cv_func_dlopen = yes; then
+ lt_cv_dlopen="dlopen"
+else
+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dl_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+ echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
+echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_svld_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_svld_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6
+if test $ac_cv_lib_svld_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+ echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
+echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dld_link ();
+int
+main ()
+{
+dld_link ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dld_dld_link=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dld_dld_link=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6
+if test $ac_cv_lib_dld_dld_link = yes; then
+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+ ;;
+ esac
+
+ if test "x$lt_cv_dlopen" != xno; then
+ enable_dlopen=yes
+ else
+ enable_dlopen=no
+ fi
+
+ case $lt_cv_dlopen in
+ dlopen)
+ save_CPPFLAGS="$CPPFLAGS"
+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+ save_LDFLAGS="$LDFLAGS"
+ eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+ save_LIBS="$LIBS"
+ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+ echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
+echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<EOF
+#line 8721 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ /* dlclose (self); */
+ }
+
+ exit (status);
+}
+EOF
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_unknown|x*) lt_cv_dlopen_self=no ;;
+ esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self=no
+ fi
+fi
+rm -fr conftest*
+
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self" >&6
+
+ if test "x$lt_cv_dlopen_self" = xyes; then
+ LDFLAGS="$LDFLAGS $link_static_flag"
+ echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
+echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self_static+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self_static=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<EOF
+#line 8819 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ /* dlclose (self); */
+ }
+
+ exit (status);
+}
+EOF
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;;
+ esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self_static=no
+ fi
+fi
+rm -fr conftest*
+
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6
+ fi
+
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
+ ;;
+ esac
+
+ case $lt_cv_dlopen_self in
+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+ *) enable_dlopen_self=unknown ;;
+ esac
+
+ case $lt_cv_dlopen_self_static in
+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+ *) enable_dlopen_self_static=unknown ;;
+ esac
+fi
+
+
+# Report which librarie types wil actually be built
+echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
+echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $can_build_shared" >&5
+echo "${ECHO_T}$can_build_shared" >&6
+
+echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
+echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case "$host_os" in
+aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+
+aix4*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ darwin* | rhapsody*)
+ if test "$GCC" = yes; then
+ archive_cmds_need_lc=no
+ case "$host_os" in
+ rhapsody* | darwin1.[012])
+ allow_undefined_flag='-undefined suppress'
+ ;;
+ *) # Darwin 1.3 on
+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+ allow_undefined_flag='-flat_namespace -undefined suppress'
+ else
+ case ${MACOSX_DEPLOYMENT_TARGET} in
+ 10.[012])
+ allow_undefined_flag='-flat_namespace -undefined suppress'
+ ;;
+ 10.*)
+ allow_undefined_flag='-undefined dynamic_lookup'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ output_verbose_link_cmd='echo'
+ archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring'
+ module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+ archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ hardcode_direct=no
+ hardcode_automatic=yes
+ hardcode_shlibpath_var=unsupported
+ whole_archive_flag_spec='-all_load $convenience'
+ link_all_deplibs=yes
+ else
+ ld_shlibs=no
+ fi
+ ;;
+esac
+echo "$as_me:$LINENO: result: $enable_shared" >&5
+echo "${ECHO_T}$enable_shared" >&6
+
+echo "$as_me:$LINENO: checking whether to build static libraries" >&5
+echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+echo "$as_me:$LINENO: result: $enable_static" >&5
+echo "${ECHO_T}$enable_static" >&6
+
+# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+ # See if we are running on zsh, and set the options which allow our commands through
+ # without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+ # Now quote all the things that may contain metacharacters while being
+ # careful not to overquote the AC_SUBSTed values. We take copies of the
+ # variables and quote the copies for generation of the libtool script.
+ for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+ SED SHELL STRIP \
+ libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+ old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+ deplibs_check_method reload_flag reload_cmds need_locks \
+ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+ lt_cv_sys_global_symbol_to_c_name_address \
+ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+ old_postinstall_cmds old_postuninstall_cmds \
+ compiler \
+ CC \
+ LD \
+ lt_prog_compiler_wl \
+ lt_prog_compiler_pic \
+ lt_prog_compiler_static \
+ lt_prog_compiler_no_builtin_flag \
+ export_dynamic_flag_spec \
+ thread_safe_flag_spec \
+ whole_archive_flag_spec \
+ enable_shared_with_static_runtimes \
+ old_archive_cmds \
+ old_archive_from_new_cmds \
+ predep_objects \
+ postdep_objects \
+ predeps \
+ postdeps \
+ compiler_lib_search_path \
+ archive_cmds \
+ archive_expsym_cmds \
+ postinstall_cmds \
+ postuninstall_cmds \
+ old_archive_from_expsyms_cmds \
+ allow_undefined_flag \
+ no_undefined_flag \
+ export_symbols_cmds \
+ hardcode_libdir_flag_spec \
+ hardcode_libdir_flag_spec_ld \
+ hardcode_libdir_separator \
+ hardcode_automatic \
+ module_cmds \
+ module_expsym_cmds \
+ lt_cv_prog_compiler_c_o \
+ exclude_expsyms \
+ include_expsyms; do
+
+ case $var in
+ old_archive_cmds | \
+ old_archive_from_new_cmds | \
+ archive_cmds | \
+ archive_expsym_cmds | \
+ module_cmds | \
+ module_expsym_cmds | \
+ old_archive_from_expsyms_cmds | \
+ export_symbols_cmds | \
+ extract_expsyms_cmds | reload_cmds | finish_cmds | \
+ postinstall_cmds | postuninstall_cmds | \
+ old_postinstall_cmds | old_postuninstall_cmds | \
+ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+ # Double-quote double-evaled strings.
+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+ ;;
+ *)
+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+ ;;
+ esac
+ done
+
+ case $lt_echo in
+ *'\$0 --fallback-echo"')
+ lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+ ;;
+ esac
+
+cfgfile="${ofile}T"
+ trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+ $rm -f "$cfgfile"
+ { echo "$as_me:$LINENO: creating $ofile" >&5
+echo "$as_me: creating $ofile" >&6;}
+
+ cat <<__EOF__ >> "$cfgfile"
+#! $SHELL
+
+# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+#
+# This file is part of GNU Libtool:
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="$SED -e s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
+
+# The names of the tagged configurations supported by this script.
+available_tags=
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_compiler
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext='$shrext'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
+
+# Must we lock files when doing compilation ?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names. First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# ### END LIBTOOL CONFIG
+
+__EOF__
+
+
+ case $host_os in
+ aix3*)
+ cat <<\EOF >> "$cfgfile"
+
+# AIX sometimes has problems with the GCC collect2 program. For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+fi
+EOF
+ ;;
+ esac
+
+ # We use sed instead of cat because bash on DJGPP gets confused if
+ # if finds mixed CR/LF and LF-only lines. Since sed operates in
+ # text mode, it properly converts lines to CR/LF. This bash problem
+ # is reportedly fixed, but why not run on old versions too?
+ sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
+
+ mv -f "$cfgfile" "$ofile" || \
+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+ chmod +x "$ofile"
+
+else
+ # If there is no Makefile yet, we rely on a make rule to execute
+ # `config.status --recheck' to rerun these tests and create the
+ # libtool script then.
+ ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+ if test -f "$ltmain_in"; then
+ test -f Makefile && make "$ltmain"
+ fi
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+
+# Check whether --with-tags or --without-tags was given.
+if test "${with_tags+set}" = set; then
+ withval="$with_tags"
+ tagnames="$withval"
+fi;
+
+if test -f "$ltmain" && test -n "$tagnames"; then
+ if test ! -f "${ofile}"; then
+ { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5
+echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;}
+ fi
+
+ if test -z "$LTCC"; then
+ eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+ if test -z "$LTCC"; then
+ { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5
+echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;}
+ else
+ { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5
+echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;}
+ fi
+ fi
+
+ # Extract list of available tagged configurations in $ofile.
+ # Note that this assumes the entire list is on one line.
+ available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
+
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for tagname in $tagnames; do
+ IFS="$lt_save_ifs"
+ # Check whether tagname contains only valid characters
+ case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in
+ "") ;;
+ *) { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5
+echo "$as_me: error: invalid tag name: $tagname" >&2;}
+ { (exit 1); exit 1; }; }
+ ;;
+ esac
+
+ if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
+ then
+ { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5
+echo "$as_me: error: tag name \"$tagname\" already exists" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+ # Update the list of available tags.
+ if test -n "$tagname"; then
+ echo appending configuration tag \"$tagname\" to $ofile
+
+ case $tagname in
+ CXX)
+ if test -n "$CXX" && test "X$CXX" != "Xno"; then
+ ac_ext=cc
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+
+
+archive_cmds_need_lc_CXX=no
+allow_undefined_flag_CXX=
+always_export_symbols_CXX=no
+archive_expsym_cmds_CXX=
+export_dynamic_flag_spec_CXX=
+hardcode_direct_CXX=no
+hardcode_libdir_flag_spec_CXX=
+hardcode_libdir_flag_spec_ld_CXX=
+hardcode_libdir_separator_CXX=
+hardcode_minus_L_CXX=no
+hardcode_automatic_CXX=no
+module_cmds_CXX=
+module_expsym_cmds_CXX=
+link_all_deplibs_CXX=unknown
+old_archive_cmds_CXX=$old_archive_cmds
+no_undefined_flag_CXX=
+whole_archive_flag_spec_CXX=
+enable_shared_with_static_runtimes_CXX=no
+
+# Dependencies to place before and after the object being linked:
+predep_objects_CXX=
+postdep_objects_CXX=
+predeps_CXX=
+postdeps_CXX=
+compiler_lib_search_path_CXX=
+
+# Source file extension for C++ test sources.
+ac_ext=cc
+
+# Object file extension for compiled C++ test sources.
+objext=o
+objext_CXX=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(int, char *) { return(0); }\n'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_LD=$LD
+lt_save_GCC=$GCC
+GCC=$GXX
+lt_save_with_gnu_ld=$with_gnu_ld
+lt_save_path_LD=$lt_cv_path_LD
+if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+else
+ unset lt_cv_prog_gnu_ld
+fi
+if test -n "${lt_cv_path_LDCXX+set}"; then
+ lt_cv_path_LD=$lt_cv_path_LDCXX
+else
+ unset lt_cv_path_LD
+fi
+test -z "${LDCXX+set}" || LD=$LDCXX
+CC=${CXX-"c++"}
+compiler=$CC
+compiler_CXX=$CC
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
+
+# We don't want -fno-exception wen compiling C++ code, so set the
+# no_builtin_flag separately
+if test "$GXX" = yes; then
+ lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
+else
+ lt_prog_compiler_no_builtin_flag_CXX=
+fi
+
+if test "$GXX" = yes; then
+ # Set up default GNU C++ configuration
+
+
+# Check whether --with-gnu-ld or --without-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then
+ withval="$with_gnu_ld"
+ test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi;
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ echo "$as_me:$LINENO: checking for ld used by $CC" >&5
+echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [\\/]* | ?:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
+ while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ echo "$as_me:$LINENO: checking for GNU ld" >&5
+echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
+else
+ echo "$as_me:$LINENO: checking for non-GNU ld" >&5
+echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
+fi
+if test "${lt_cv_path_LD+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some GNU ld's only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ echo "$as_me:$LINENO: result: $LD" >&5
+echo "${ECHO_T}$LD" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
+echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
+ { (exit 1); exit 1; }; }
+echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
+echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
+if test "${lt_cv_prog_gnu_ld+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
+echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+ # Check if GNU C++ uses GNU ld as the underlying linker, since the
+ # archiving commands below assume that GNU ld is being used.
+ if test "$with_gnu_ld" = yes; then
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+ hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+ # investigate it a little bit more. (MM)
+ wlarc='${wl}'
+
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
+ grep 'no-whole-archive' > /dev/null; then
+ whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ whole_archive_flag_spec_CXX=
+ fi
+ else
+ with_gnu_ld=no
+ wlarc=
+
+ # A generic and very simple default shared library creation
+ # command for GNU C++ for the case where it uses the native
+ # linker, instead of GNU ld. If possible, this setting should
+ # overridden to take advantage of the native linker features on
+ # the platform it is being used on.
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ fi
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+else
+ GXX=no
+ with_gnu_ld=no
+ wlarc=
+fi
+
+# PORTME: fill in a description of your system's C++ link characteristics
+echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
+ld_shlibs_CXX=yes
+case $host_os in
+ aix3*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ aix4* | aix5*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+ for ld_flag in $LDFLAGS; do
+ case $ld_flag in
+ *-brtl*)
+ aix_use_runtimelinking=yes
+ break
+ ;;
+ esac
+ done
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ archive_cmds_CXX=''
+ hardcode_direct_CXX=yes
+ hardcode_libdir_separator_CXX=':'
+ link_all_deplibs_CXX=yes
+
+ if test "$GXX" = yes; then
+ case $host_os in aix4.012|aix4.012.*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" && \
+ strings "$collect2name" | grep resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ hardcode_direct_CXX=yes
+ else
+ # We have old collect2
+ hardcode_direct_CXX=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ hardcode_minus_L_CXX=yes
+ hardcode_libdir_flag_spec_CXX='-L$libdir'
+ hardcode_libdir_separator_CXX=
+ fi
+ esac
+ shared_flag='-shared'
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ always_export_symbols_CXX=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ allow_undefined_flag_CXX='-berok'
+ # Determine the default libpath from the value encoded in an empty executable.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`; fi
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+ archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
+ allow_undefined_flag_CXX="-z nodefs"
+ archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an empty executable.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`; fi
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ no_undefined_flag_CXX=' ${wl}-bernotok'
+ allow_undefined_flag_CXX=' ${wl}-berok'
+ # -bexpall does not export symbols beginning with underscore (_)
+ always_export_symbols_CXX=yes
+ # Exported symbols can be pulled into shared objects from archives
+ whole_archive_flag_spec_CXX=' '
+ archive_cmds_need_lc_CXX=yes
+ # This is similar to how AIX traditionally builds it's shared libraries.
+ archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+ chorus*)
+ case $cc_basename in
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
+ # as there is no search path for DLLs.
+ hardcode_libdir_flag_spec_CXX='-L$libdir'
+ allow_undefined_flag_CXX=unsupported
+ always_export_symbols_CXX=no
+ enable_shared_with_static_runtimes_CXX=yes
+
+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+ else
+ ld_shlibs_CXX=no
+ fi
+ ;;
+
+ darwin* | rhapsody*)
+ if test "$GXX" = yes; then
+ archive_cmds_need_lc_CXX=no
+ case "$host_os" in
+ rhapsody* | darwin1.[012])
+ allow_undefined_flag_CXX='-undefined suppress'
+ ;;
+ *) # Darwin 1.3 on
+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+ allow_undefined_flag_CXX='-flat_namespace -undefined suppress'
+ else
+ case ${MACOSX_DEPLOYMENT_TARGET} in
+ 10.[012])
+ allow_undefined_flag_CXX='-flat_namespace -undefined suppress'
+ ;;
+ 10.*)
+ allow_undefined_flag_CXX='-undefined dynamic_lookup'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ lt_int_apple_cc_single_mod=no
+ output_verbose_link_cmd='echo'
+ if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+ lt_int_apple_cc_single_mod=yes
+ fi
+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+ archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ else
+ archive_cmds_CXX='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ fi
+ module_cmds_CXX='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+
+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+ archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ else
+ archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ hardcode_direct_CXX=no
+ hardcode_automatic_CXX=yes
+ hardcode_shlibpath_var_CXX=unsupported
+ whole_archive_flag_spec_CXX='-all_load $convenience'
+ link_all_deplibs_CXX=yes
+ else
+ ld_shlibs_CXX=no
+ fi
+ ;;
+
+ dgux*)
+ case $cc_basename in
+ ec++)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ ghcx)
+ # Green Hills C++ Compiler
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+ freebsd12*)
+ # C++ shared libraries reported to be fairly broken before switch to ELF
+ ld_shlibs_CXX=no
+ ;;
+ freebsd-elf*)
+ archive_cmds_need_lc_CXX=no
+ ;;
+ freebsd* | kfreebsd*-gnu)
+ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+ # conventions
+ ld_shlibs_CXX=yes
+ ;;
+ gnu*)
+ ;;
+ hpux9*)
+ hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ hardcode_direct_CXX=yes
+ hardcode_minus_L_CXX=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+
+ case $cc_basename in
+ CC)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ aCC)
+ archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | egrep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+ hpux10*|hpux11*)
+ if test $with_gnu_ld = no; then
+ case "$host_cpu" in
+ hppa*64*)
+ hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+ hardcode_libdir_flag_spec_ld_CXX='+b $libdir'
+ hardcode_libdir_separator_CXX=:
+ ;;
+ ia64*)
+ hardcode_libdir_flag_spec_CXX='-L$libdir'
+ ;;
+ *)
+ hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ ;;
+ esac
+ fi
+ case "$host_cpu" in
+ hppa*64*)
+ hardcode_direct_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ ;;
+ ia64*)
+ hardcode_direct_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ hardcode_minus_L_CXX=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+ ;;
+ *)
+ hardcode_direct_CXX=yes
+ hardcode_minus_L_CXX=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+ ;;
+ esac
+
+ case $cc_basename in
+ CC)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ aCC)
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test $with_gnu_ld = no; then
+ case "$host_cpu" in
+ ia64*|hppa*64*)
+ archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ fi
+ else
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+ irix5* | irix6*)
+ case $cc_basename in
+ CC)
+ # SGI C++
+ archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
+
+ # Archives containing C++ object files must be created using
+ # "CC -ar", where "CC" is the IRIX C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test "$with_gnu_ld" = no; then
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
+ else
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
+ fi
+ fi
+ link_all_deplibs_CXX=yes
+ ;;
+ esac
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+ ;;
+ linux*)
+ case $cc_basename in
+ KCC)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+ archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+
+ hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+ # Archives containing C++ object files must be created using
+ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+ old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+ icpc)
+ # Intel C++
+ with_gnu_ld=yes
+ archive_cmds_need_lc_CXX=no
+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+ whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+ cxx)
+ # Compaq C++
+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+ runpath_var=LD_RUN_PATH
+ hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+ ;;
+ esac
+ ;;
+ lynxos*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ m88k*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ mvs*)
+ case $cc_basename in
+ cxx)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+ wlarc=
+ hardcode_libdir_flag_spec_CXX='-R$libdir'
+ hardcode_direct_CXX=yes
+ hardcode_shlibpath_var_CXX=no
+ fi
+ # Workaround some broken pre-1.5 toolchains
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+ ;;
+ osf3*)
+ case $cc_basename in
+ KCC)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Archives containing C++ object files must be created using
+ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+ old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
+
+ ;;
+ RCC)
+ # Rational C++ 2.4.1
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ cxx)
+ allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+ ;;
+ *)
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+ else
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+ osf4* | osf5*)
+ case $cc_basename in
+ KCC)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Archives containing C++ object files must be created using
+ # the KAI C++ compiler.
+ old_archive_cmds_CXX='$CC -o $oldlib $oldobjs'
+ ;;
+ RCC)
+ # Rational C++ 2.4.1
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ cxx)
+ allow_undefined_flag_CXX=' -expect_unresolved \*'
+ archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
+ archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+ echo "-hidden">> $lib.exp~
+ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry $objdir/so_locations -o $lib~
+ $rm $lib.exp'
+
+ hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+ ;;
+ *)
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+ else
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+ psos*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ sco*)
+ archive_cmds_need_lc_CXX=no
+ case $cc_basename in
+ CC)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+ sunos4*)
+ case $cc_basename in
+ CC)
+ # Sun C++ 4.x
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ lcc)
+ # Lucid
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+ solaris*)
+ case $cc_basename in
+ CC)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ no_undefined_flag_CXX=' -zdefs'
+ archive_cmds_CXX='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+ hardcode_libdir_flag_spec_CXX='-R$libdir'
+ hardcode_shlibpath_var_CXX=no
+ case $host_os in
+ solaris2.0-5 | solaris2.0-5.*) ;;
+ *)
+ # The C++ compiler is used as linker so we must use $wl
+ # flag to pass the commands to the underlying system
+ # linker.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ ;;
+ esac
+ link_all_deplibs_CXX=yes
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[LR]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ gcx)
+ # Green Hills C++ Compiler
+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+ # The C++ compiler must be used to create the archive.
+ old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+ ;;
+ *)
+ # GNU C++ compiler with Solaris linker
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
+ if $CC --version | grep -v '^2\.7' > /dev/null; then
+ archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+ else
+ # g++ 2.7 appears to require `-G' NOT `-shared' on this
+ # platform.
+ archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+ fi
+
+ hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+ fi
+ ;;
+ esac
+ ;;
+ sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*)
+ archive_cmds_need_lc_CXX=no
+ ;;
+ tandem*)
+ case $cc_basename in
+ NCC)
+ # NonStop-UX NCC 3.20
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+ vxworks*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+esac
+echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
+echo "${ECHO_T}$ld_shlibs_CXX" >&6
+test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+GCC_CXX="$GXX"
+LD_CXX="$LD"
+
+
+cat > conftest.$ac_ext <<EOF
+class Foo
+{
+public:
+ Foo (void) { a = 0; }
+private:
+ int a;
+};
+EOF
+
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Parse the compiler output and extract the necessary
+ # objects, libraries and library flags.
+
+ # Sentinel used to keep track of whether or not we are before
+ # the conftest object file.
+ pre_test_object_deps_done=no
+
+ # The `*' in the case matches for architectures that use `case' in
+ # $output_verbose_cmd can trigger glob expansion during the loop
+ # eval without this substitution.
+ output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e \"$no_glob_subst\"`"
+
+ for p in `eval $output_verbose_link_cmd`; do
+ case $p in
+
+ -L* | -R* | -l*)
+ # Some compilers place space between "-{L,R}" and the path.
+ # Remove the space.
+ if test $p = "-L" \
+ || test $p = "-R"; then
+ prev=$p
+ continue
+ else
+ prev=
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ case $p in
+ -L* | -R*)
+ # Internal compiler library paths should come after those
+ # provided the user. The postdeps already come after the
+ # user supplied libs so there is no need to process them.
+ if test -z "$compiler_lib_search_path_CXX"; then
+ compiler_lib_search_path_CXX="${prev}${p}"
+ else
+ compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
+ fi
+ ;;
+ # The "-l" case would never come before the object being
+ # linked, so don't bother handling this case.
+ esac
+ else
+ if test -z "$postdeps_CXX"; then
+ postdeps_CXX="${prev}${p}"
+ else
+ postdeps_CXX="${postdeps_CXX} ${prev}${p}"
+ fi
+ fi
+ ;;
+
+ *.$objext)
+ # This assumes that the test object file only shows up
+ # once in the compiler output.
+ if test "$p" = "conftest.$objext"; then
+ pre_test_object_deps_done=yes
+ continue
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ if test -z "$predep_objects_CXX"; then
+ predep_objects_CXX="$p"
+ else
+ predep_objects_CXX="$predep_objects_CXX $p"
+ fi
+ else
+ if test -z "$postdep_objects_CXX"; then
+ postdep_objects_CXX="$p"
+ else
+ postdep_objects_CXX="$postdep_objects_CXX $p"
+ fi
+ fi
+ ;;
+
+ *) ;; # Ignore the rest.
+
+ esac
+ done
+
+ # Clean up.
+ rm -f a.out a.exe
+else
+ echo "libtool.m4: error: problem compiling CXX test program"
+fi
+
+$rm -f confest.$objext
+
+case " $postdeps_CXX " in
+*" -lc "*) archive_cmds_need_lc_CXX=no ;;
+esac
+
+lt_prog_compiler_wl_CXX=
+lt_prog_compiler_pic_CXX=
+lt_prog_compiler_static_CXX=
+
+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
+
+ # C++ specific cases for pic, static, wl, etc.
+ if test "$GXX" = yes; then
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_CXX='-Bstatic'
+ fi
+ ;;
+ amigaos*)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+ mingw* | os2* | pw32*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+ ;;
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ lt_prog_compiler_pic_CXX='-fno-common'
+ ;;
+ *djgpp*)
+ # DJGPP does not support shared libraries at all
+ lt_prog_compiler_pic_CXX=
+ ;;
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic_CXX=-Kconform_pic
+ fi
+ ;;
+ hpux*)
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ esac
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ esac
+ else
+ case $host_os in
+ aix4* | aix5*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_CXX='-Bstatic'
+ else
+ lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+ chorus*)
+ case $cc_basename in
+ cxch68)
+ # Green Hills C++ Compiler
+ # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+ ;;
+ esac
+ ;;
+ dgux*)
+ case $cc_basename in
+ ec++)
+ lt_prog_compiler_pic_CXX='-KPIC'
+ ;;
+ ghcx)
+ # Green Hills C++ Compiler
+ lt_prog_compiler_pic_CXX='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ freebsd* | kfreebsd*-gnu)
+ # FreeBSD uses GNU C++
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ case $cc_basename in
+ CC)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+ if test "$host_cpu" != ia64; then
+ lt_prog_compiler_pic_CXX='+Z'
+ fi
+ ;;
+ aCC)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX='+Z'
+ ;;
+ esac
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ irix5* | irix6* | nonstopux*)
+ case $cc_basename in
+ CC)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='-non_shared'
+ # CC pic flag -KPIC is the default.
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ linux*)
+ case $cc_basename in
+ KCC)
+ # KAI C++ Compiler
+ lt_prog_compiler_wl_CXX='--backend -Wl,'
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ icpc)
+ # Intel C++
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-static'
+ ;;
+ cxx)
+ # Compaq C++
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ lt_prog_compiler_pic_CXX=
+ lt_prog_compiler_static_CXX='-non_shared'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ lynxos*)
+ ;;
+ m88k*)
+ ;;
+ mvs*)
+ case $cc_basename in
+ cxx)
+ lt_prog_compiler_pic_CXX='-W c,exportall'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ netbsd* | knetbsd*-gnu)
+ ;;
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC)
+ lt_prog_compiler_wl_CXX='--backend -Wl,'
+ ;;
+ RCC)
+ # Rational C++ 2.4.1
+ lt_prog_compiler_pic_CXX='-pic'
+ ;;
+ cxx)
+ # Digital/Compaq C++
+ lt_prog_compiler_wl_CXX='-Wl,'
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ lt_prog_compiler_pic_CXX=
+ lt_prog_compiler_static_CXX='-non_shared'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ psos*)
+ ;;
+ sco*)
+ case $cc_basename in
+ CC)
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ solaris*)
+ case $cc_basename in
+ CC)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ lt_prog_compiler_wl_CXX='-Qoption ld '
+ ;;
+ gcx)
+ # Green Hills C++ Compiler
+ lt_prog_compiler_pic_CXX='-PIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sunos4*)
+ case $cc_basename in
+ CC)
+ # Sun C++ 4.x
+ lt_prog_compiler_pic_CXX='-pic'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ ;;
+ lcc)
+ # Lucid
+ lt_prog_compiler_pic_CXX='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ tandem*)
+ case $cc_basename in
+ NCC)
+ # NonStop-UX NCC 3.20
+ lt_prog_compiler_pic_CXX='-KPIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ unixware*)
+ ;;
+ vxworks*)
+ ;;
+ *)
+ lt_prog_compiler_can_build_shared_CXX=no
+ ;;
+ esac
+ fi
+
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_CXX"; then
+
+echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6
+if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_prog_compiler_pic_works_CXX=no
+ ac_outfile=conftest.$ac_objext
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:10996: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:11000: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test ! -s conftest.err; then
+ lt_prog_compiler_pic_works_CXX=yes
+ fi
+ fi
+ $rm conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6
+
+if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then
+ case $lt_prog_compiler_pic_CXX in
+ "" | " "*) ;;
+ *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
+ esac
+else
+ lt_prog_compiler_pic_CXX=
+ lt_prog_compiler_can_build_shared_CXX=no
+fi
+
+fi
+case "$host_os" in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ lt_prog_compiler_pic_CXX=
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
+ ;;
+esac
+
+echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_prog_compiler_c_o_CXX=no
+ $rm -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:11056: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:11060: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test ! -s out/conftest.err; then
+ lt_cv_prog_compiler_c_o_CXX=yes
+ fi
+ fi
+ chmod u+w .
+ $rm conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+ $rm out/* && rmdir out
+ cd ..
+ rmdir conftest
+ $rm conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
+ hard_links=yes
+ $rm conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ echo "$as_me:$LINENO: result: $hard_links" >&5
+echo "${ECHO_T}$hard_links" >&6
+ if test "$hard_links" = no; then
+ { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+
+echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
+
+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ case $host_os in
+ aix4* | aix5*)
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+ export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+ else
+ export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+ fi
+ ;;
+ pw32*)
+ export_symbols_cmds_CXX="$ltdll_cmds"
+ ;;
+ cygwin* | mingw*)
+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ *)
+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ esac
+
+echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
+echo "${ECHO_T}$ld_shlibs_CXX" >&6
+test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_CXX" in
+x|xyes)
+ # Assume -lc should be added
+ archive_cmds_need_lc_CXX=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $archive_cmds_CXX in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
+ $rm conftest*
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$lt_prog_compiler_wl_CXX
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
+ allow_undefined_flag_CXX=
+ if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
+ (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+ then
+ archive_cmds_need_lc_CXX=no
+ else
+ archive_cmds_need_lc_CXX=yes
+ fi
+ allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $rm conftest*
+ echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5
+echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+if test "$GCC" = yes; then
+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+ # if the path contains ";" then we assume it to be the separator
+ # otherwise default to the standard path separator (i.e. ":") - it is
+ # assumed that no part of a normal pathname contains ";" but that should
+ # okay in the real world where ";" in dirpaths is itself problematic.
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+else
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix4* | aix5*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[01] | aix4.[01].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi4*)
+ version_type=linux
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32*)
+ version_type=windows
+ shrext=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$host_os in
+ yes,cygwin* | yes,mingw* | yes,pw32*)
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $rm \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+ ;;
+ mingw*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+ # It is most probably a Windows format PATH printed by
+ # mingw gcc, but we are running on Cygwin. Gcc prints its search
+ # path with ; separators, and with drive letters. We can handle the
+ # drive letters (cygwin fileutils understands them), so leave them,
+ # especially as we might pass files found there to a mingw objdump,
+ # which wouldn't understand a cygwinified path. Ahh.
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ ;;
+
+ *)
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext='$(test .$module = .yes && echo .so || echo .dylib)'
+ # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+ if test "$GCC" = yes; then
+ sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+ else
+ sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+ fi
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd1*)
+ dynamic_linker=no
+ ;;
+
+kfreebsd*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='GNU ld.so'
+ ;;
+
+freebsd*)
+ objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.01* | freebsdelf3.01*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ *) # from 3.2 on
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case "$host_cpu" in
+ ia64*)
+ shrext='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555.
+ postinstall_cmds='chmod 555 $lib'
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be Linux ELF.
+linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $ld_extra"
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+knetbsd*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='GNU ld.so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+nto-qnx*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+openbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=yes
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[89] | openbsd2.[89].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+sco3.2v5*)
+ version_type=osf
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+solaris*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ export_dynamic_flag_spec='${wl}-Blargedynsym'
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+uts4*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+echo "$as_me:$LINENO: result: $dynamic_linker" >&5
+echo "${ECHO_T}$dynamic_linker" >&6
+test "$dynamic_linker" = no && can_build_shared=no
+
+echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
+hardcode_action_CXX=
+if test -n "$hardcode_libdir_flag_spec_CXX" || \
+ test -n "$runpath_var CXX" || \
+ test "X$hardcode_automatic_CXX"="Xyes" ; then
+
+ # We can hardcode non-existant directories.
+ if test "$hardcode_direct_CXX" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
+ test "$hardcode_minus_L_CXX" != no; then
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action_CXX=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action_CXX=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action_CXX=unsupported
+fi
+echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5
+echo "${ECHO_T}$hardcode_action_CXX" >&6
+
+if test "$hardcode_action_CXX" = relink; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+
+striplib=
+old_striplib=
+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+ case $host_os in
+ darwin*)
+ if test -n "$STRIP" ; then
+ striplib="$STRIP -x"
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+ ;;
+ *)
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ ;;
+ esac
+fi
+
+if test "x$enable_dlopen" != xyes; then
+ enable_dlopen=unknown
+ enable_dlopen_self=unknown
+ enable_dlopen_self_static=unknown
+else
+ lt_cv_dlopen=no
+ lt_cv_dlopen_libs=
+
+ case $host_os in
+ beos*)
+ lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ;;
+
+ mingw* | pw32*)
+ lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen_libs=
+ ;;
+
+ cygwin*)
+ lt_cv_dlopen="dlopen"
+ lt_cv_dlopen_libs=
+ ;;
+
+ darwin*)
+ # if libdl is installed we need to link against it
+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dl_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+ lt_cv_dlopen="dyld"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+
+fi
+
+ ;;
+
+ *)
+ echo "$as_me:$LINENO: checking for shl_load" >&5
+echo $ECHO_N "checking for shl_load... $ECHO_C" >&6
+if test "${ac_cv_func_shl_load+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define shl_load innocuous_shl_load
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char shl_load (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef shl_load
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char shl_load ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_shl_load) || defined (__stub___shl_load)
+choke me
+#else
+char (*f) () = shl_load;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != shl_load;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_shl_load=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_shl_load=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
+echo "${ECHO_T}$ac_cv_func_shl_load" >&6
+if test $ac_cv_func_shl_load = yes; then
+ lt_cv_dlopen="shl_load"
+else
+ echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
+echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char shl_load ();
+int
+main ()
+{
+shl_load ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dld_shl_load=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dld_shl_load=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6
+if test $ac_cv_lib_dld_shl_load = yes; then
+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
+else
+ echo "$as_me:$LINENO: checking for dlopen" >&5
+echo $ECHO_N "checking for dlopen... $ECHO_C" >&6
+if test "${ac_cv_func_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define dlopen innocuous_dlopen
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char dlopen (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef dlopen
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_dlopen) || defined (__stub___dlopen)
+choke me
+#else
+char (*f) () = dlopen;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != dlopen;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
+echo "${ECHO_T}$ac_cv_func_dlopen" >&6
+if test $ac_cv_func_dlopen = yes; then
+ lt_cv_dlopen="dlopen"
+else
+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dl_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+ echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
+echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_svld_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_svld_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6
+if test $ac_cv_lib_svld_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+ echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
+echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dld_link ();
+int
+main ()
+{
+dld_link ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dld_dld_link=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dld_dld_link=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6
+if test $ac_cv_lib_dld_dld_link = yes; then
+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+ ;;
+ esac
+
+ if test "x$lt_cv_dlopen" != xno; then
+ enable_dlopen=yes
+ else
+ enable_dlopen=no
+ fi
+
+ case $lt_cv_dlopen in
+ dlopen)
+ save_CPPFLAGS="$CPPFLAGS"
+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+ save_LDFLAGS="$LDFLAGS"
+ eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+ save_LIBS="$LIBS"
+ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+ echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
+echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<EOF
+#line 12410 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ /* dlclose (self); */
+ }
+
+ exit (status);
+}
+EOF
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_unknown|x*) lt_cv_dlopen_self=no ;;
+ esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self=no
+ fi
+fi
+rm -fr conftest*
+
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self" >&6
+
+ if test "x$lt_cv_dlopen_self" = xyes; then
+ LDFLAGS="$LDFLAGS $link_static_flag"
+ echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
+echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self_static+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self_static=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<EOF
+#line 12508 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ /* dlclose (self); */
+ }
+
+ exit (status);
+}
+EOF
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;;
+ esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self_static=no
+ fi
+fi
+rm -fr conftest*
+
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6
+ fi
+
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
+ ;;
+ esac
+
+ case $lt_cv_dlopen_self in
+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+ *) enable_dlopen_self=unknown ;;
+ esac
+
+ case $lt_cv_dlopen_self_static in
+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+ *) enable_dlopen_self_static=unknown ;;
+ esac
+fi
+
+
+# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+ # See if we are running on zsh, and set the options which allow our commands through
+ # without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+ # Now quote all the things that may contain metacharacters while being
+ # careful not to overquote the AC_SUBSTed values. We take copies of the
+ # variables and quote the copies for generation of the libtool script.
+ for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+ SED SHELL STRIP \
+ libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+ old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+ deplibs_check_method reload_flag reload_cmds need_locks \
+ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+ lt_cv_sys_global_symbol_to_c_name_address \
+ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+ old_postinstall_cmds old_postuninstall_cmds \
+ compiler_CXX \
+ CC_CXX \
+ LD_CXX \
+ lt_prog_compiler_wl_CXX \
+ lt_prog_compiler_pic_CXX \
+ lt_prog_compiler_static_CXX \
+ lt_prog_compiler_no_builtin_flag_CXX \
+ export_dynamic_flag_spec_CXX \
+ thread_safe_flag_spec_CXX \
+ whole_archive_flag_spec_CXX \
+ enable_shared_with_static_runtimes_CXX \
+ old_archive_cmds_CXX \
+ old_archive_from_new_cmds_CXX \
+ predep_objects_CXX \
+ postdep_objects_CXX \
+ predeps_CXX \
+ postdeps_CXX \
+ compiler_lib_search_path_CXX \
+ archive_cmds_CXX \
+ archive_expsym_cmds_CXX \
+ postinstall_cmds_CXX \
+ postuninstall_cmds_CXX \
+ old_archive_from_expsyms_cmds_CXX \
+ allow_undefined_flag_CXX \
+ no_undefined_flag_CXX \
+ export_symbols_cmds_CXX \
+ hardcode_libdir_flag_spec_CXX \
+ hardcode_libdir_flag_spec_ld_CXX \
+ hardcode_libdir_separator_CXX \
+ hardcode_automatic_CXX \
+ module_cmds_CXX \
+ module_expsym_cmds_CXX \
+ lt_cv_prog_compiler_c_o_CXX \
+ exclude_expsyms_CXX \
+ include_expsyms_CXX; do
+
+ case $var in
+ old_archive_cmds_CXX | \
+ old_archive_from_new_cmds_CXX | \
+ archive_cmds_CXX | \
+ archive_expsym_cmds_CXX | \
+ module_cmds_CXX | \
+ module_expsym_cmds_CXX | \
+ old_archive_from_expsyms_cmds_CXX | \
+ export_symbols_cmds_CXX | \
+ extract_expsyms_cmds | reload_cmds | finish_cmds | \
+ postinstall_cmds | postuninstall_cmds | \
+ old_postinstall_cmds | old_postuninstall_cmds | \
+ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+ # Double-quote double-evaled strings.
+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+ ;;
+ *)
+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+ ;;
+ esac
+ done
+
+ case $lt_echo in
+ *'\$0 --fallback-echo"')
+ lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+ ;;
+ esac
+
+cfgfile="$ofile"
+
+ cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_CXX
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_compiler_CXX
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_CXX
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD_CXX
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_CXX
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext='$shrext'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_CXX
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
+
+# Must we lock files when doing compilation ?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_CXX
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names. First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds_CXX
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_CXX
+archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_CXX
+module_expsym_cmds=$lt_module_expsym_cmds_CXX
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_CXX
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_CXX
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_CXX
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_CXX
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_CXX
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_CXX
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_CXX
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_CXX
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_CXX
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_CXX
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_CXX
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path_CXX"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_CXX
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_CXX
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_CXX
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_CXX
+
+# ### END LIBTOOL TAG CONFIG: $tagname
+
+__EOF__
+
+
+else
+ # If there is no Makefile yet, we rely on a make rule to execute
+ # `config.status --recheck' to rerun these tests and create the
+ # libtool script then.
+ ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+ if test -f "$ltmain_in"; then
+ test -f Makefile && make "$ltmain"
+ fi
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC=$lt_save_CC
+LDCXX=$LD
+LD=$lt_save_LD
+GCC=$lt_save_GCC
+with_gnu_ldcxx=$with_gnu_ld
+with_gnu_ld=$lt_save_with_gnu_ld
+lt_cv_path_LDCXX=$lt_cv_path_LD
+lt_cv_path_LD=$lt_save_path_LD
+lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+
+ else
+ tagname=""
+ fi
+ ;;
+
+ F77)
+ if test -n "$F77" && test "X$F77" != "Xno"; then
+
+ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
+
+
+archive_cmds_need_lc_F77=no
+allow_undefined_flag_F77=
+always_export_symbols_F77=no
+archive_expsym_cmds_F77=
+export_dynamic_flag_spec_F77=
+hardcode_direct_F77=no
+hardcode_libdir_flag_spec_F77=
+hardcode_libdir_flag_spec_ld_F77=
+hardcode_libdir_separator_F77=
+hardcode_minus_L_F77=no
+hardcode_automatic_F77=no
+module_cmds_F77=
+module_expsym_cmds_F77=
+link_all_deplibs_F77=unknown
+old_archive_cmds_F77=$old_archive_cmds
+no_undefined_flag_F77=
+whole_archive_flag_spec_F77=
+enable_shared_with_static_runtimes_F77=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+objext_F77=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code=" subroutine t\n return\n end\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code=" program t\n end\n"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${F77-"f77"}
+compiler=$CC
+compiler_F77=$CC
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
+
+echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
+echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $can_build_shared" >&5
+echo "${ECHO_T}$can_build_shared" >&6
+
+echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
+echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case "$host_os" in
+aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+aix4*)
+ test "$enable_shared" = yes && enable_static=no
+ ;;
+esac
+echo "$as_me:$LINENO: result: $enable_shared" >&5
+echo "${ECHO_T}$enable_shared" >&6
+
+echo "$as_me:$LINENO: checking whether to build static libraries" >&5
+echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+echo "$as_me:$LINENO: result: $enable_static" >&5
+echo "${ECHO_T}$enable_static" >&6
+
+test "$ld_shlibs_F77" = no && can_build_shared=no
+
+GCC_F77="$G77"
+LD_F77="$LD"
+
+lt_prog_compiler_wl_F77=
+lt_prog_compiler_pic_F77=
+lt_prog_compiler_static_F77=
+
+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
+
+ if test "$GCC" = yes; then
+ lt_prog_compiler_wl_F77='-Wl,'
+ lt_prog_compiler_static_F77='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_F77='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4'
+ ;;
+
+ beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+
+ mingw* | pw32* | os2*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic_F77='-DDLL_EXPORT'
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ lt_prog_compiler_pic_F77='-fno-common'
+ ;;
+
+ msdosdjgpp*)
+ # Just because we use GCC doesn't mean we suddenly get shared libraries
+ # on systems that don't support them.
+ lt_prog_compiler_can_build_shared_F77=no
+ enable_shared=no
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic_F77=-Kconform_pic
+ fi
+ ;;
+
+ hpux*)
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic_F77='-fPIC'
+ ;;
+ esac
+ ;;
+
+ *)
+ lt_prog_compiler_pic_F77='-fPIC'
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ lt_prog_compiler_wl_F77='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_F77='-Bstatic'
+ else
+ lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+
+ mingw* | pw32* | os2*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic_F77='-DDLL_EXPORT'
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ lt_prog_compiler_wl_F77='-Wl,'
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic_F77='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ lt_prog_compiler_static_F77='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ lt_prog_compiler_wl_F77='-Wl,'
+ # PIC (with -KPIC) is the default.
+ lt_prog_compiler_static_F77='-non_shared'
+ ;;
+
+ newsos6)
+ lt_prog_compiler_pic_F77='-KPIC'
+ lt_prog_compiler_static_F77='-Bstatic'
+ ;;
+
+ linux*)
+ case $CC in
+ icc* | ecc*)
+ lt_prog_compiler_wl_F77='-Wl,'
+ lt_prog_compiler_pic_F77='-KPIC'
+ lt_prog_compiler_static_F77='-static'
+ ;;
+ ccc*)
+ lt_prog_compiler_wl_F77='-Wl,'
+ # All Alpha code is PIC.
+ lt_prog_compiler_static_F77='-non_shared'
+ ;;
+ esac
+ ;;
+
+ osf3* | osf4* | osf5*)
+ lt_prog_compiler_wl_F77='-Wl,'
+ # All OSF/1 code is PIC.
+ lt_prog_compiler_static_F77='-non_shared'
+ ;;
+
+ sco3.2v5*)
+ lt_prog_compiler_pic_F77='-Kpic'
+ lt_prog_compiler_static_F77='-dn'
+ ;;
+
+ solaris*)
+ lt_prog_compiler_wl_F77='-Wl,'
+ lt_prog_compiler_pic_F77='-KPIC'
+ lt_prog_compiler_static_F77='-Bstatic'
+ ;;
+
+ sunos4*)
+ lt_prog_compiler_wl_F77='-Qoption ld '
+ lt_prog_compiler_pic_F77='-PIC'
+ lt_prog_compiler_static_F77='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ lt_prog_compiler_wl_F77='-Wl,'
+ lt_prog_compiler_pic_F77='-KPIC'
+ lt_prog_compiler_static_F77='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ lt_prog_compiler_pic_F77='-Kconform_pic'
+ lt_prog_compiler_static_F77='-Bstatic'
+ fi
+ ;;
+
+ uts4*)
+ lt_prog_compiler_pic_F77='-pic'
+ lt_prog_compiler_static_F77='-Bstatic'
+ ;;
+
+ *)
+ lt_prog_compiler_can_build_shared_F77=no
+ ;;
+ esac
+ fi
+
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_F77"; then
+
+echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6
+if test "${lt_prog_compiler_pic_works_F77+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_prog_compiler_pic_works_F77=no
+ ac_outfile=conftest.$ac_objext
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$lt_prog_compiler_pic_F77"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:13335: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:13339: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test ! -s conftest.err; then
+ lt_prog_compiler_pic_works_F77=yes
+ fi
+ fi
+ $rm conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6
+
+if test x"$lt_prog_compiler_pic_works_F77" = xyes; then
+ case $lt_prog_compiler_pic_F77 in
+ "" | " "*) ;;
+ *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;;
+ esac
+else
+ lt_prog_compiler_pic_F77=
+ lt_prog_compiler_can_build_shared_F77=no
+fi
+
+fi
+case "$host_os" in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ lt_prog_compiler_pic_F77=
+ ;;
+ *)
+ lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77"
+ ;;
+esac
+
+echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_prog_compiler_c_o_F77=no
+ $rm -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:13395: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:13399: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test ! -s out/conftest.err; then
+ lt_cv_prog_compiler_c_o_F77=yes
+ fi
+ fi
+ chmod u+w .
+ $rm conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+ $rm out/* && rmdir out
+ cd ..
+ rmdir conftest
+ $rm conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
+ hard_links=yes
+ $rm conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ echo "$as_me:$LINENO: result: $hard_links" >&5
+echo "${ECHO_T}$hard_links" >&6
+ if test "$hard_links" = no; then
+ { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+
+echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
+
+ runpath_var=
+ allow_undefined_flag_F77=
+ enable_shared_with_static_runtimes_F77=no
+ archive_cmds_F77=
+ archive_expsym_cmds_F77=
+ old_archive_From_new_cmds_F77=
+ old_archive_from_expsyms_cmds_F77=
+ export_dynamic_flag_spec_F77=
+ whole_archive_flag_spec_F77=
+ thread_safe_flag_spec_F77=
+ hardcode_libdir_flag_spec_F77=
+ hardcode_libdir_flag_spec_ld_F77=
+ hardcode_libdir_separator_F77=
+ hardcode_direct_F77=no
+ hardcode_minus_L_F77=no
+ hardcode_shlibpath_var_F77=unsupported
+ link_all_deplibs_F77=unknown
+ hardcode_automatic_F77=no
+ module_cmds_F77=
+ module_expsym_cmds_F77=
+ always_export_symbols_F77=no
+ export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ include_expsyms_F77=
+ # exclude_expsyms can be an extended regexp of symbols to exclude
+ # it will be wrapped by ` (' and `)$', so one must not match beginning or
+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+ # as well as any symbol that contains `d'.
+ exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_"
+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+ # platforms (ab)use it in PIC code, but their linkers get confused if
+ # the symbol is explicitly referenced. Since portable code cannot
+ # rely on this symbol name, it's probably fine to never include it in
+ # preloaded symbol tables.
+ extract_expsyms_cmds=
+
+ case $host_os in
+ cygwin* | mingw* | pw32*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+ esac
+
+ ld_shlibs_F77=yes
+ if test "$with_gnu_ld" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # See if GNU ld supports shared libraries.
+ case $host_os in
+ aix3* | aix4* | aix5*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ ld_shlibs_F77=no
+ cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+ fi
+ ;;
+
+ amigaos*)
+ archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec_F77='-L$libdir'
+ hardcode_minus_L_F77=yes
+
+ # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+ # that the semantics of dynamic libraries on AmigaOS, at least up
+ # to version 4, is to share data among multiple programs linked
+ # with the same dynamic library. Since this doesn't match the
+ # behavior of shared libraries on other platforms, we can't use
+ # them.
+ ld_shlibs_F77=no
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ allow_undefined_flag_F77=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ ld_shlibs_F77=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless,
+ # as there is no search path for DLLs.
+ hardcode_libdir_flag_spec_F77='-L$libdir'
+ allow_undefined_flag_F77=unsupported
+ always_export_symbols_F77=no
+ enable_shared_with_static_runtimes_F77=yes
+ export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+
+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+ archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ fi
+ ;;
+
+ solaris* | sysv5*)
+ if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+ ld_shlibs_F77=no
+ cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+ elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs_F77=no
+ fi
+ ;;
+
+ sunos4*)
+ archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ hardcode_direct_F77=yes
+ hardcode_shlibpath_var_F77=no
+ ;;
+
+ linux*)
+ if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+ tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_cmds_F77="$tmp_archive_cmds"
+ supports_anon_versioning=no
+ case `$LD -v 2>/dev/null` in
+ *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+ *\ 2.11.*) ;; # other 2.11 versions
+ *) supports_anon_versioning=yes ;;
+ esac
+ if test $supports_anon_versioning = yes; then
+ archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ else
+ archive_expsym_cmds_F77="$tmp_archive_cmds"
+ fi
+ else
+ ld_shlibs_F77=no
+ fi
+ ;;
+
+ *)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs_F77=no
+ fi
+ ;;
+ esac
+
+ if test "$ld_shlibs_F77" = yes; then
+ runpath_var=LD_RUN_PATH
+ hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir'
+ export_dynamic_flag_spec_F77='${wl}--export-dynamic'
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ whole_archive_flag_spec_F77=
+ fi
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ allow_undefined_flag_F77=unsupported
+ always_export_symbols_F77=yes
+ archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ hardcode_minus_L_F77=yes
+ if test "$GCC" = yes && test -z "$link_static_flag"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ hardcode_direct_F77=unsupported
+ fi
+ ;;
+
+ aix4* | aix5*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+ export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+ else
+ export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+ fi
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ archive_cmds_F77=''
+ hardcode_direct_F77=yes
+ hardcode_libdir_separator_F77=':'
+ link_all_deplibs_F77=yes
+
+ if test "$GCC" = yes; then
+ case $host_os in aix4.012|aix4.012.*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" && \
+ strings "$collect2name" | grep resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ hardcode_direct_F77=yes
+ else
+ # We have old collect2
+ hardcode_direct_F77=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ hardcode_minus_L_F77=yes
+ hardcode_libdir_flag_spec_F77='-L$libdir'
+ hardcode_libdir_separator_F77=
+ fi
+ esac
+ shared_flag='-shared'
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ always_export_symbols_F77=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ allow_undefined_flag_F77='-berok'
+ # Determine the default libpath from the value encoded in an empty executable.
+ cat >conftest.$ac_ext <<_ACEOF
+ program main
+
+ end
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`; fi
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
+ archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib'
+ allow_undefined_flag_F77="-z nodefs"
+ archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an empty executable.
+ cat >conftest.$ac_ext <<_ACEOF
+ program main
+
+ end
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`; fi
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ no_undefined_flag_F77=' ${wl}-bernotok'
+ allow_undefined_flag_F77=' ${wl}-berok'
+ # -bexpall does not export symbols beginning with underscore (_)
+ always_export_symbols_F77=yes
+ # Exported symbols can be pulled into shared objects from archives
+ whole_archive_flag_spec_F77=' '
+ archive_cmds_need_lc_F77=yes
+ # This is similar to how AIX traditionally builds it's shared libraries.
+ archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ amigaos*)
+ archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec_F77='-L$libdir'
+ hardcode_minus_L_F77=yes
+ # see comment about different semantics on the GNU ld section
+ ld_shlibs_F77=no
+ ;;
+
+ bsdi4*)
+ export_dynamic_flag_spec_F77=-rdynamic
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec_F77=' '
+ allow_undefined_flag_F77=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ old_archive_From_new_cmds_F77='true'
+ # FIXME: Should let the user specify the lib program.
+ old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs'
+ fix_srcfile_path='`cygpath -w "$srcfile"`'
+ enable_shared_with_static_runtimes_F77=yes
+ ;;
+
+ darwin* | rhapsody*)
+ if test "$GXX" = yes ; then
+ archive_cmds_need_lc_F77=no
+ case "$host_os" in
+ rhapsody* | darwin1.[012])
+ allow_undefined_flag_F77='-undefined suppress'
+ ;;
+ *) # Darwin 1.3 on
+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+ allow_undefined_flag_F77='-flat_namespace -undefined suppress'
+ else
+ case ${MACOSX_DEPLOYMENT_TARGET} in
+ 10.[012])
+ allow_undefined_flag_F77='-flat_namespace -undefined suppress'
+ ;;
+ 10.*)
+ allow_undefined_flag_F77='-undefined dynamic_lookup'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ lt_int_apple_cc_single_mod=no
+ output_verbose_link_cmd='echo'
+ if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+ lt_int_apple_cc_single_mod=yes
+ fi
+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+ archive_cmds_F77='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ else
+ archive_cmds_F77='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ fi
+ module_cmds_F77='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+ archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ else
+ archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ hardcode_direct_F77=no
+ hardcode_automatic_F77=yes
+ hardcode_shlibpath_var_F77=unsupported
+ whole_archive_flag_spec_F77='-all_load $convenience'
+ link_all_deplibs_F77=yes
+ else
+ ld_shlibs_F77=no
+ fi
+ ;;
+
+ dgux*)
+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec_F77='-L$libdir'
+ hardcode_shlibpath_var_F77=no
+ ;;
+
+ freebsd1*)
+ ld_shlibs_F77=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ hardcode_libdir_flag_spec_F77='-R$libdir'
+ hardcode_direct_F77=yes
+ hardcode_shlibpath_var_F77=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2*)
+ archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_F77=yes
+ hardcode_minus_L_F77=yes
+ hardcode_shlibpath_var_F77=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | kfreebsd*-gnu)
+ archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec_F77='-R$libdir'
+ hardcode_direct_F77=yes
+ hardcode_shlibpath_var_F77=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ fi
+ hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_F77=:
+ hardcode_direct_F77=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L_F77=yes
+ export_dynamic_flag_spec_F77='${wl}-E'
+ ;;
+
+ hpux10* | hpux11*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ else
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ archive_cmds_F77='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+ ;;
+ *)
+ archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+ ;;
+ esac
+ fi
+ if test "$with_gnu_ld" = no; then
+ case "$host_cpu" in
+ hppa*64*)
+ hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+ hardcode_libdir_flag_spec_ld_F77='+b $libdir'
+ hardcode_libdir_separator_F77=:
+ hardcode_direct_F77=no
+ hardcode_shlibpath_var_F77=no
+ ;;
+ ia64*)
+ hardcode_libdir_flag_spec_F77='-L$libdir'
+ hardcode_direct_F77=no
+ hardcode_shlibpath_var_F77=no
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L_F77=yes
+ ;;
+ *)
+ hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_F77=:
+ hardcode_direct_F77=yes
+ export_dynamic_flag_spec_F77='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L_F77=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec_ld_F77='-rpath $libdir'
+ fi
+ hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_F77=:
+ link_all_deplibs_F77=yes
+ ;;
+
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ hardcode_libdir_flag_spec_F77='-R$libdir'
+ hardcode_direct_F77=yes
+ hardcode_shlibpath_var_F77=no
+ ;;
+
+ newsos6)
+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_F77=yes
+ hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_F77=:
+ hardcode_shlibpath_var_F77=no
+ ;;
+
+ openbsd*)
+ hardcode_direct_F77=yes
+ hardcode_shlibpath_var_F77=no
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_F77='${wl}-E'
+ else
+ case $host_os in
+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+ archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec_F77='-R$libdir'
+ ;;
+ *)
+ archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ ;;
+
+ os2*)
+ hardcode_libdir_flag_spec_F77='-L$libdir'
+ hardcode_minus_L_F77=yes
+ allow_undefined_flag_F77=unsupported
+ archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+ old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ allow_undefined_flag_F77=' -expect_unresolved \*'
+ archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+ fi
+ hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_F77=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+ else
+ allow_undefined_flag_F77=' -expect_unresolved \*'
+ archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
+
+ # Both c and cxx compiler support -rpath directly
+ hardcode_libdir_flag_spec_F77='-rpath $libdir'
+ fi
+ hardcode_libdir_separator_F77=:
+ ;;
+
+ sco3.2v5*)
+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var_F77=no
+ export_dynamic_flag_spec_F77='${wl}-Bexport'
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ ;;
+
+ solaris*)
+ no_undefined_flag_F77=' -z text'
+ if test "$GCC" = yes; then
+ archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+ else
+ archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+ fi
+ hardcode_libdir_flag_spec_F77='-R$libdir'
+ hardcode_shlibpath_var_F77=no
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+ whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;;
+ esac
+ link_all_deplibs_F77=yes
+ ;;
+
+ sunos4*)
+ if test "x$host_vendor" = xsequent; then
+ # Use $CC to link under sequent, because it throws in some extra .o
+ # files that make .init and .fini sections work.
+ archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ hardcode_libdir_flag_spec_F77='-L$libdir'
+ hardcode_direct_F77=yes
+ hardcode_minus_L_F77=yes
+ hardcode_shlibpath_var_F77=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_F77=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ reload_cmds_F77='$CC -r -o $output$reload_objs'
+ hardcode_direct_F77=no
+ ;;
+ motorola)
+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ hardcode_shlibpath_var_F77=no
+ ;;
+
+ sysv4.3*)
+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var_F77=no
+ export_dynamic_flag_spec_F77='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var_F77=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ ld_shlibs_F77=yes
+ fi
+ ;;
+
+ sysv4.2uw2*)
+ archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_F77=yes
+ hardcode_minus_L_F77=no
+ hardcode_shlibpath_var_F77=no
+ hardcode_runpath_var=yes
+ runpath_var=LD_RUN_PATH
+ ;;
+
+ sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*)
+ no_undefined_flag_F77='${wl}-z ${wl}text'
+ if test "$GCC" = yes; then
+ archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds_F77='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ runpath_var='LD_RUN_PATH'
+ hardcode_shlibpath_var_F77=no
+ ;;
+
+ sysv5*)
+ no_undefined_flag_F77=' -z text'
+ # $CC -shared without GNU ld will not create a library from C++
+ # object files and a static libstdc++, better avoid it by now
+ archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+ hardcode_libdir_flag_spec_F77=
+ hardcode_shlibpath_var_F77=no
+ runpath_var='LD_RUN_PATH'
+ ;;
+
+ uts4*)
+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec_F77='-L$libdir'
+ hardcode_shlibpath_var_F77=no
+ ;;
+
+ *)
+ ld_shlibs_F77=no
+ ;;
+ esac
+ fi
+
+echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5
+echo "${ECHO_T}$ld_shlibs_F77" >&6
+test "$ld_shlibs_F77" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_F77" in
+x|xyes)
+ # Assume -lc should be added
+ archive_cmds_need_lc_F77=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $archive_cmds_F77 in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
+ $rm conftest*
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$lt_prog_compiler_wl_F77
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$allow_undefined_flag_F77
+ allow_undefined_flag_F77=
+ if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
+ (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+ then
+ archive_cmds_need_lc_F77=no
+ else
+ archive_cmds_need_lc_F77=yes
+ fi
+ allow_undefined_flag_F77=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $rm conftest*
+ echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5
+echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+if test "$GCC" = yes; then
+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+ # if the path contains ";" then we assume it to be the separator
+ # otherwise default to the standard path separator (i.e. ":") - it is
+ # assumed that no part of a normal pathname contains ";" but that should
+ # okay in the real world where ";" in dirpaths is itself problematic.
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+else
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix4* | aix5*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[01] | aix4.[01].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi4*)
+ version_type=linux
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32*)
+ version_type=windows
+ shrext=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$host_os in
+ yes,cygwin* | yes,mingw* | yes,pw32*)
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $rm \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+ ;;
+ mingw*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+ # It is most probably a Windows format PATH printed by
+ # mingw gcc, but we are running on Cygwin. Gcc prints its search
+ # path with ; separators, and with drive letters. We can handle the
+ # drive letters (cygwin fileutils understands them), so leave them,
+ # especially as we might pass files found there to a mingw objdump,
+ # which wouldn't understand a cygwinified path. Ahh.
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ ;;
+
+ *)
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext='$(test .$module = .yes && echo .so || echo .dylib)'
+ # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+ if test "$GCC" = yes; then
+ sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+ else
+ sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+ fi
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd1*)
+ dynamic_linker=no
+ ;;
+
+kfreebsd*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='GNU ld.so'
+ ;;
+
+freebsd*)
+ objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.01* | freebsdelf3.01*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ *) # from 3.2 on
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case "$host_cpu" in
+ ia64*)
+ shrext='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555.
+ postinstall_cmds='chmod 555 $lib'
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be Linux ELF.
+linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $ld_extra"
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+knetbsd*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='GNU ld.so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+nto-qnx*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+openbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=yes
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[89] | openbsd2.[89].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+sco3.2v5*)
+ version_type=osf
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+solaris*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ export_dynamic_flag_spec='${wl}-Blargedynsym'
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+uts4*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+echo "$as_me:$LINENO: result: $dynamic_linker" >&5
+echo "${ECHO_T}$dynamic_linker" >&6
+test "$dynamic_linker" = no && can_build_shared=no
+
+echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
+hardcode_action_F77=
+if test -n "$hardcode_libdir_flag_spec_F77" || \
+ test -n "$runpath_var F77" || \
+ test "X$hardcode_automatic_F77"="Xyes" ; then
+
+ # We can hardcode non-existant directories.
+ if test "$hardcode_direct_F77" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no &&
+ test "$hardcode_minus_L_F77" != no; then
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action_F77=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action_F77=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action_F77=unsupported
+fi
+echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5
+echo "${ECHO_T}$hardcode_action_F77" >&6
+
+if test "$hardcode_action_F77" = relink; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+
+striplib=
+old_striplib=
+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+ case $host_os in
+ darwin*)
+ if test -n "$STRIP" ; then
+ striplib="$STRIP -x"
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+ ;;
+ *)
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ ;;
+ esac
+fi
+
+
+
+# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+ # See if we are running on zsh, and set the options which allow our commands through
+ # without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+ # Now quote all the things that may contain metacharacters while being
+ # careful not to overquote the AC_SUBSTed values. We take copies of the
+ # variables and quote the copies for generation of the libtool script.
+ for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+ SED SHELL STRIP \
+ libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+ old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+ deplibs_check_method reload_flag reload_cmds need_locks \
+ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+ lt_cv_sys_global_symbol_to_c_name_address \
+ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+ old_postinstall_cmds old_postuninstall_cmds \
+ compiler_F77 \
+ CC_F77 \
+ LD_F77 \
+ lt_prog_compiler_wl_F77 \
+ lt_prog_compiler_pic_F77 \
+ lt_prog_compiler_static_F77 \
+ lt_prog_compiler_no_builtin_flag_F77 \
+ export_dynamic_flag_spec_F77 \
+ thread_safe_flag_spec_F77 \
+ whole_archive_flag_spec_F77 \
+ enable_shared_with_static_runtimes_F77 \
+ old_archive_cmds_F77 \
+ old_archive_from_new_cmds_F77 \
+ predep_objects_F77 \
+ postdep_objects_F77 \
+ predeps_F77 \
+ postdeps_F77 \
+ compiler_lib_search_path_F77 \
+ archive_cmds_F77 \
+ archive_expsym_cmds_F77 \
+ postinstall_cmds_F77 \
+ postuninstall_cmds_F77 \
+ old_archive_from_expsyms_cmds_F77 \
+ allow_undefined_flag_F77 \
+ no_undefined_flag_F77 \
+ export_symbols_cmds_F77 \
+ hardcode_libdir_flag_spec_F77 \
+ hardcode_libdir_flag_spec_ld_F77 \
+ hardcode_libdir_separator_F77 \
+ hardcode_automatic_F77 \
+ module_cmds_F77 \
+ module_expsym_cmds_F77 \
+ lt_cv_prog_compiler_c_o_F77 \
+ exclude_expsyms_F77 \
+ include_expsyms_F77; do
+
+ case $var in
+ old_archive_cmds_F77 | \
+ old_archive_from_new_cmds_F77 | \
+ archive_cmds_F77 | \
+ archive_expsym_cmds_F77 | \
+ module_cmds_F77 | \
+ module_expsym_cmds_F77 | \
+ old_archive_from_expsyms_cmds_F77 | \
+ export_symbols_cmds_F77 | \
+ extract_expsyms_cmds | reload_cmds | finish_cmds | \
+ postinstall_cmds | postuninstall_cmds | \
+ old_postinstall_cmds | old_postuninstall_cmds | \
+ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+ # Double-quote double-evaled strings.
+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+ ;;
+ *)
+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+ ;;
+ esac
+ done
+
+ case $lt_echo in
+ *'\$0 --fallback-echo"')
+ lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+ ;;
+ esac
+
+cfgfile="$ofile"
+
+ cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_F77
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_compiler_F77
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_F77
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD_F77
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_F77
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext='$shrext'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_F77
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77
+
+# Must we lock files when doing compilation ?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_F77
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names. First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds_F77
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_F77
+archive_expsym_cmds=$lt_archive_expsym_cmds_F77
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_F77
+module_expsym_cmds=$lt_module_expsym_cmds_F77
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_F77
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_F77
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_F77
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_F77
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_F77
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_F77
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_F77
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_F77
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_F77
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_F77
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_F77
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_F77
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_F77
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path_F77"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_F77
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_F77
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_F77
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_F77
+
+# ### END LIBTOOL TAG CONFIG: $tagname
+
+__EOF__
+
+
+else
+ # If there is no Makefile yet, we rely on a make rule to execute
+ # `config.status --recheck' to rerun these tests and create the
+ # libtool script then.
+ ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+ if test -f "$ltmain_in"; then
+ test -f Makefile && make "$ltmain"
+ fi
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+ else
+ tagname=""
+ fi
+ ;;
+
+ GCJ)
+ if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+
+
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+objext_GCJ=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String argv) {}; }\n'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${GCJ-"gcj"}
+compiler=$CC
+compiler_GCJ=$CC
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+archive_cmds_need_lc_GCJ=no
+
+
+lt_prog_compiler_no_builtin_flag_GCJ=
+
+if test "$GCC" = yes; then
+ lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin'
+
+
+echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_prog_compiler_rtti_exceptions=no
+ ac_outfile=conftest.$ac_objext
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="-fno-rtti -fno-exceptions"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:15427: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:15431: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test ! -s conftest.err; then
+ lt_cv_prog_compiler_rtti_exceptions=yes
+ fi
+ fi
+ $rm conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+ lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions"
+else
+ :
+fi
+
+fi
+
+lt_prog_compiler_wl_GCJ=
+lt_prog_compiler_pic_GCJ=
+lt_prog_compiler_static_GCJ=
+
+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
+
+ if test "$GCC" = yes; then
+ lt_prog_compiler_wl_GCJ='-Wl,'
+ lt_prog_compiler_static_GCJ='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_GCJ='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4'
+ ;;
+
+ beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+
+ mingw* | pw32* | os2*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ lt_prog_compiler_pic_GCJ='-fno-common'
+ ;;
+
+ msdosdjgpp*)
+ # Just because we use GCC doesn't mean we suddenly get shared libraries
+ # on systems that don't support them.
+ lt_prog_compiler_can_build_shared_GCJ=no
+ enable_shared=no
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic_GCJ=-Kconform_pic
+ fi
+ ;;
+
+ hpux*)
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic_GCJ='-fPIC'
+ ;;
+ esac
+ ;;
+
+ *)
+ lt_prog_compiler_pic_GCJ='-fPIC'
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ lt_prog_compiler_wl_GCJ='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_GCJ='-Bstatic'
+ else
+ lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+
+ mingw* | pw32* | os2*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ lt_prog_compiler_wl_GCJ='-Wl,'
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic_GCJ='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ lt_prog_compiler_wl_GCJ='-Wl,'
+ # PIC (with -KPIC) is the default.
+ lt_prog_compiler_static_GCJ='-non_shared'
+ ;;
+
+ newsos6)
+ lt_prog_compiler_pic_GCJ='-KPIC'
+ lt_prog_compiler_static_GCJ='-Bstatic'
+ ;;
+
+ linux*)
+ case $CC in
+ icc* | ecc*)
+ lt_prog_compiler_wl_GCJ='-Wl,'
+ lt_prog_compiler_pic_GCJ='-KPIC'
+ lt_prog_compiler_static_GCJ='-static'
+ ;;
+ ccc*)
+ lt_prog_compiler_wl_GCJ='-Wl,'
+ # All Alpha code is PIC.
+ lt_prog_compiler_static_GCJ='-non_shared'
+ ;;
+ esac
+ ;;
+
+ osf3* | osf4* | osf5*)
+ lt_prog_compiler_wl_GCJ='-Wl,'
+ # All OSF/1 code is PIC.
+ lt_prog_compiler_static_GCJ='-non_shared'
+ ;;
+
+ sco3.2v5*)
+ lt_prog_compiler_pic_GCJ='-Kpic'
+ lt_prog_compiler_static_GCJ='-dn'
+ ;;
+
+ solaris*)
+ lt_prog_compiler_wl_GCJ='-Wl,'
+ lt_prog_compiler_pic_GCJ='-KPIC'
+ lt_prog_compiler_static_GCJ='-Bstatic'
+ ;;
+
+ sunos4*)
+ lt_prog_compiler_wl_GCJ='-Qoption ld '
+ lt_prog_compiler_pic_GCJ='-PIC'
+ lt_prog_compiler_static_GCJ='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ lt_prog_compiler_wl_GCJ='-Wl,'
+ lt_prog_compiler_pic_GCJ='-KPIC'
+ lt_prog_compiler_static_GCJ='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ lt_prog_compiler_pic_GCJ='-Kconform_pic'
+ lt_prog_compiler_static_GCJ='-Bstatic'
+ fi
+ ;;
+
+ uts4*)
+ lt_prog_compiler_pic_GCJ='-pic'
+ lt_prog_compiler_static_GCJ='-Bstatic'
+ ;;
+
+ *)
+ lt_prog_compiler_can_build_shared_GCJ=no
+ ;;
+ esac
+ fi
+
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_GCJ"; then
+
+echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6
+if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_prog_compiler_pic_works_GCJ=no
+ ac_outfile=conftest.$ac_objext
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$lt_prog_compiler_pic_GCJ"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:15660: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:15664: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test ! -s conftest.err; then
+ lt_prog_compiler_pic_works_GCJ=yes
+ fi
+ fi
+ $rm conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6
+
+if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then
+ case $lt_prog_compiler_pic_GCJ in
+ "" | " "*) ;;
+ *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;;
+ esac
+else
+ lt_prog_compiler_pic_GCJ=
+ lt_prog_compiler_can_build_shared_GCJ=no
+fi
+
+fi
+case "$host_os" in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ lt_prog_compiler_pic_GCJ=
+ ;;
+ *)
+ lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ"
+ ;;
+esac
+
+echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_prog_compiler_c_o_GCJ=no
+ $rm -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:15720: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:15724: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test ! -s out/conftest.err; then
+ lt_cv_prog_compiler_c_o_GCJ=yes
+ fi
+ fi
+ chmod u+w .
+ $rm conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+ $rm out/* && rmdir out
+ cd ..
+ rmdir conftest
+ $rm conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
+ hard_links=yes
+ $rm conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ echo "$as_me:$LINENO: result: $hard_links" >&5
+echo "${ECHO_T}$hard_links" >&6
+ if test "$hard_links" = no; then
+ { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+
+echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
+
+ runpath_var=
+ allow_undefined_flag_GCJ=
+ enable_shared_with_static_runtimes_GCJ=no
+ archive_cmds_GCJ=
+ archive_expsym_cmds_GCJ=
+ old_archive_From_new_cmds_GCJ=
+ old_archive_from_expsyms_cmds_GCJ=
+ export_dynamic_flag_spec_GCJ=
+ whole_archive_flag_spec_GCJ=
+ thread_safe_flag_spec_GCJ=
+ hardcode_libdir_flag_spec_GCJ=
+ hardcode_libdir_flag_spec_ld_GCJ=
+ hardcode_libdir_separator_GCJ=
+ hardcode_direct_GCJ=no
+ hardcode_minus_L_GCJ=no
+ hardcode_shlibpath_var_GCJ=unsupported
+ link_all_deplibs_GCJ=unknown
+ hardcode_automatic_GCJ=no
+ module_cmds_GCJ=
+ module_expsym_cmds_GCJ=
+ always_export_symbols_GCJ=no
+ export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ include_expsyms_GCJ=
+ # exclude_expsyms can be an extended regexp of symbols to exclude
+ # it will be wrapped by ` (' and `)$', so one must not match beginning or
+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+ # as well as any symbol that contains `d'.
+ exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_"
+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+ # platforms (ab)use it in PIC code, but their linkers get confused if
+ # the symbol is explicitly referenced. Since portable code cannot
+ # rely on this symbol name, it's probably fine to never include it in
+ # preloaded symbol tables.
+ extract_expsyms_cmds=
+
+ case $host_os in
+ cygwin* | mingw* | pw32*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+ esac
+
+ ld_shlibs_GCJ=yes
+ if test "$with_gnu_ld" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # See if GNU ld supports shared libraries.
+ case $host_os in
+ aix3* | aix4* | aix5*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ ld_shlibs_GCJ=no
+ cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+ fi
+ ;;
+
+ amigaos*)
+ archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec_GCJ='-L$libdir'
+ hardcode_minus_L_GCJ=yes
+
+ # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+ # that the semantics of dynamic libraries on AmigaOS, at least up
+ # to version 4, is to share data among multiple programs linked
+ # with the same dynamic library. Since this doesn't match the
+ # behavior of shared libraries on other platforms, we can't use
+ # them.
+ ld_shlibs_GCJ=no
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ allow_undefined_flag_GCJ=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ ld_shlibs_GCJ=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless,
+ # as there is no search path for DLLs.
+ hardcode_libdir_flag_spec_GCJ='-L$libdir'
+ allow_undefined_flag_GCJ=unsupported
+ always_export_symbols_GCJ=no
+ enable_shared_with_static_runtimes_GCJ=yes
+ export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+
+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+ archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ fi
+ ;;
+
+ solaris* | sysv5*)
+ if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+ ld_shlibs_GCJ=no
+ cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+ elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs_GCJ=no
+ fi
+ ;;
+
+ sunos4*)
+ archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ hardcode_direct_GCJ=yes
+ hardcode_shlibpath_var_GCJ=no
+ ;;
+
+ linux*)
+ if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+ tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_cmds_GCJ="$tmp_archive_cmds"
+ supports_anon_versioning=no
+ case `$LD -v 2>/dev/null` in
+ *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+ *\ 2.11.*) ;; # other 2.11 versions
+ *) supports_anon_versioning=yes ;;
+ esac
+ if test $supports_anon_versioning = yes; then
+ archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ else
+ archive_expsym_cmds_GCJ="$tmp_archive_cmds"
+ fi
+ else
+ ld_shlibs_GCJ=no
+ fi
+ ;;
+
+ *)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs_GCJ=no
+ fi
+ ;;
+ esac
+
+ if test "$ld_shlibs_GCJ" = yes; then
+ runpath_var=LD_RUN_PATH
+ hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
+ export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ whole_archive_flag_spec_GCJ=
+ fi
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ allow_undefined_flag_GCJ=unsupported
+ always_export_symbols_GCJ=yes
+ archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ hardcode_minus_L_GCJ=yes
+ if test "$GCC" = yes && test -z "$link_static_flag"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ hardcode_direct_GCJ=unsupported
+ fi
+ ;;
+
+ aix4* | aix5*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+ export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+ else
+ export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+ fi
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ archive_cmds_GCJ=''
+ hardcode_direct_GCJ=yes
+ hardcode_libdir_separator_GCJ=':'
+ link_all_deplibs_GCJ=yes
+
+ if test "$GCC" = yes; then
+ case $host_os in aix4.012|aix4.012.*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" && \
+ strings "$collect2name" | grep resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ hardcode_direct_GCJ=yes
+ else
+ # We have old collect2
+ hardcode_direct_GCJ=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ hardcode_minus_L_GCJ=yes
+ hardcode_libdir_flag_spec_GCJ='-L$libdir'
+ hardcode_libdir_separator_GCJ=
+ fi
+ esac
+ shared_flag='-shared'
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ always_export_symbols_GCJ=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ allow_undefined_flag_GCJ='-berok'
+ # Determine the default libpath from the value encoded in an empty executable.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`; fi
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
+ archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib'
+ allow_undefined_flag_GCJ="-z nodefs"
+ archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an empty executable.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`; fi
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ no_undefined_flag_GCJ=' ${wl}-bernotok'
+ allow_undefined_flag_GCJ=' ${wl}-berok'
+ # -bexpall does not export symbols beginning with underscore (_)
+ always_export_symbols_GCJ=yes
+ # Exported symbols can be pulled into shared objects from archives
+ whole_archive_flag_spec_GCJ=' '
+ archive_cmds_need_lc_GCJ=yes
+ # This is similar to how AIX traditionally builds it's shared libraries.
+ archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ amigaos*)
+ archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec_GCJ='-L$libdir'
+ hardcode_minus_L_GCJ=yes
+ # see comment about different semantics on the GNU ld section
+ ld_shlibs_GCJ=no
+ ;;
+
+ bsdi4*)
+ export_dynamic_flag_spec_GCJ=-rdynamic
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec_GCJ=' '
+ allow_undefined_flag_GCJ=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ old_archive_From_new_cmds_GCJ='true'
+ # FIXME: Should let the user specify the lib program.
+ old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs'
+ fix_srcfile_path='`cygpath -w "$srcfile"`'
+ enable_shared_with_static_runtimes_GCJ=yes
+ ;;
+
+ darwin* | rhapsody*)
+ if test "$GXX" = yes ; then
+ archive_cmds_need_lc_GCJ=no
+ case "$host_os" in
+ rhapsody* | darwin1.[012])
+ allow_undefined_flag_GCJ='-undefined suppress'
+ ;;
+ *) # Darwin 1.3 on
+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+ allow_undefined_flag_GCJ='-flat_namespace -undefined suppress'
+ else
+ case ${MACOSX_DEPLOYMENT_TARGET} in
+ 10.[012])
+ allow_undefined_flag_GCJ='-flat_namespace -undefined suppress'
+ ;;
+ 10.*)
+ allow_undefined_flag_GCJ='-undefined dynamic_lookup'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ lt_int_apple_cc_single_mod=no
+ output_verbose_link_cmd='echo'
+ if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+ lt_int_apple_cc_single_mod=yes
+ fi
+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+ archive_cmds_GCJ='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ else
+ archive_cmds_GCJ='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ fi
+ module_cmds_GCJ='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+ archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ else
+ archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ hardcode_direct_GCJ=no
+ hardcode_automatic_GCJ=yes
+ hardcode_shlibpath_var_GCJ=unsupported
+ whole_archive_flag_spec_GCJ='-all_load $convenience'
+ link_all_deplibs_GCJ=yes
+ else
+ ld_shlibs_GCJ=no
+ fi
+ ;;
+
+ dgux*)
+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec_GCJ='-L$libdir'
+ hardcode_shlibpath_var_GCJ=no
+ ;;
+
+ freebsd1*)
+ ld_shlibs_GCJ=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ hardcode_libdir_flag_spec_GCJ='-R$libdir'
+ hardcode_direct_GCJ=yes
+ hardcode_shlibpath_var_GCJ=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2*)
+ archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_GCJ=yes
+ hardcode_minus_L_GCJ=yes
+ hardcode_shlibpath_var_GCJ=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | kfreebsd*-gnu)
+ archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec_GCJ='-R$libdir'
+ hardcode_direct_GCJ=yes
+ hardcode_shlibpath_var_GCJ=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ fi
+ hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_GCJ=:
+ hardcode_direct_GCJ=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L_GCJ=yes
+ export_dynamic_flag_spec_GCJ='${wl}-E'
+ ;;
+
+ hpux10* | hpux11*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ else
+ case "$host_cpu" in
+ hppa*64*|ia64*)
+ archive_cmds_GCJ='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+ ;;
+ *)
+ archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+ ;;
+ esac
+ fi
+ if test "$with_gnu_ld" = no; then
+ case "$host_cpu" in
+ hppa*64*)
+ hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+ hardcode_libdir_flag_spec_ld_GCJ='+b $libdir'
+ hardcode_libdir_separator_GCJ=:
+ hardcode_direct_GCJ=no
+ hardcode_shlibpath_var_GCJ=no
+ ;;
+ ia64*)
+ hardcode_libdir_flag_spec_GCJ='-L$libdir'
+ hardcode_direct_GCJ=no
+ hardcode_shlibpath_var_GCJ=no
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L_GCJ=yes
+ ;;
+ *)
+ hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_GCJ=:
+ hardcode_direct_GCJ=yes
+ export_dynamic_flag_spec_GCJ='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L_GCJ=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir'
+ fi
+ hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_GCJ=:
+ link_all_deplibs_GCJ=yes
+ ;;
+
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ hardcode_libdir_flag_spec_GCJ='-R$libdir'
+ hardcode_direct_GCJ=yes
+ hardcode_shlibpath_var_GCJ=no
+ ;;
+
+ newsos6)
+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_GCJ=yes
+ hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_GCJ=:
+ hardcode_shlibpath_var_GCJ=no
+ ;;
+
+ openbsd*)
+ hardcode_direct_GCJ=yes
+ hardcode_shlibpath_var_GCJ=no
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_GCJ='${wl}-E'
+ else
+ case $host_os in
+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+ archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec_GCJ='-R$libdir'
+ ;;
+ *)
+ archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ ;;
+
+ os2*)
+ hardcode_libdir_flag_spec_GCJ='-L$libdir'
+ hardcode_minus_L_GCJ=yes
+ allow_undefined_flag_GCJ=unsupported
+ archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+ old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ allow_undefined_flag_GCJ=' -expect_unresolved \*'
+ archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+ fi
+ hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_GCJ=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+ else
+ allow_undefined_flag_GCJ=' -expect_unresolved \*'
+ archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
+
+ # Both c and cxx compiler support -rpath directly
+ hardcode_libdir_flag_spec_GCJ='-rpath $libdir'
+ fi
+ hardcode_libdir_separator_GCJ=:
+ ;;
+
+ sco3.2v5*)
+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var_GCJ=no
+ export_dynamic_flag_spec_GCJ='${wl}-Bexport'
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ ;;
+
+ solaris*)
+ no_undefined_flag_GCJ=' -z text'
+ if test "$GCC" = yes; then
+ archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+ else
+ archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+ fi
+ hardcode_libdir_flag_spec_GCJ='-R$libdir'
+ hardcode_shlibpath_var_GCJ=no
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+ whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;;
+ esac
+ link_all_deplibs_GCJ=yes
+ ;;
+
+ sunos4*)
+ if test "x$host_vendor" = xsequent; then
+ # Use $CC to link under sequent, because it throws in some extra .o
+ # files that make .init and .fini sections work.
+ archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ hardcode_libdir_flag_spec_GCJ='-L$libdir'
+ hardcode_direct_GCJ=yes
+ hardcode_minus_L_GCJ=yes
+ hardcode_shlibpath_var_GCJ=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_GCJ=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ reload_cmds_GCJ='$CC -r -o $output$reload_objs'
+ hardcode_direct_GCJ=no
+ ;;
+ motorola)
+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ hardcode_shlibpath_var_GCJ=no
+ ;;
+
+ sysv4.3*)
+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var_GCJ=no
+ export_dynamic_flag_spec_GCJ='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var_GCJ=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ ld_shlibs_GCJ=yes
+ fi
+ ;;
+
+ sysv4.2uw2*)
+ archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_GCJ=yes
+ hardcode_minus_L_GCJ=no
+ hardcode_shlibpath_var_GCJ=no
+ hardcode_runpath_var=yes
+ runpath_var=LD_RUN_PATH
+ ;;
+
+ sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*)
+ no_undefined_flag_GCJ='${wl}-z ${wl}text'
+ if test "$GCC" = yes; then
+ archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds_GCJ='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ runpath_var='LD_RUN_PATH'
+ hardcode_shlibpath_var_GCJ=no
+ ;;
+
+ sysv5*)
+ no_undefined_flag_GCJ=' -z text'
+ # $CC -shared without GNU ld will not create a library from C++
+ # object files and a static libstdc++, better avoid it by now
+ archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+ hardcode_libdir_flag_spec_GCJ=
+ hardcode_shlibpath_var_GCJ=no
+ runpath_var='LD_RUN_PATH'
+ ;;
+
+ uts4*)
+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec_GCJ='-L$libdir'
+ hardcode_shlibpath_var_GCJ=no
+ ;;
+
+ *)
+ ld_shlibs_GCJ=no
+ ;;
+ esac
+ fi
+
+echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5
+echo "${ECHO_T}$ld_shlibs_GCJ" >&6
+test "$ld_shlibs_GCJ" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_GCJ" in
+x|xyes)
+ # Assume -lc should be added
+ archive_cmds_need_lc_GCJ=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $archive_cmds_GCJ in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
+ $rm conftest*
+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$lt_prog_compiler_wl_GCJ
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ
+ allow_undefined_flag_GCJ=
+ if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
+ (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+ then
+ archive_cmds_need_lc_GCJ=no
+ else
+ archive_cmds_need_lc_GCJ=yes
+ fi
+ allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $rm conftest*
+ echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5
+echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+if test "$GCC" = yes; then
+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+ # if the path contains ";" then we assume it to be the separator
+ # otherwise default to the standard path separator (i.e. ":") - it is
+ # assumed that no part of a normal pathname contains ";" but that should
+ # okay in the real world where ";" in dirpaths is itself problematic.
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+else
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix4* | aix5*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[01] | aix4.[01].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi4*)
+ version_type=linux
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32*)
+ version_type=windows
+ shrext=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$host_os in
+ yes,cygwin* | yes,mingw* | yes,pw32*)
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $rm \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+ ;;
+ mingw*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+ # It is most probably a Windows format PATH printed by
+ # mingw gcc, but we are running on Cygwin. Gcc prints its search
+ # path with ; separators, and with drive letters. We can handle the
+ # drive letters (cygwin fileutils understands them), so leave them,
+ # especially as we might pass files found there to a mingw objdump,
+ # which wouldn't understand a cygwinified path. Ahh.
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ ;;
+
+ *)
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext='$(test .$module = .yes && echo .so || echo .dylib)'
+ # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+ if test "$GCC" = yes; then
+ sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+ else
+ sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+ fi
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd1*)
+ dynamic_linker=no
+ ;;
+
+kfreebsd*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='GNU ld.so'
+ ;;
+
+freebsd*)
+ objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.01* | freebsdelf3.01*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ *) # from 3.2 on
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case "$host_cpu" in
+ ia64*)
+ shrext='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555.
+ postinstall_cmds='chmod 555 $lib'
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be Linux ELF.
+linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $ld_extra"
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+knetbsd*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='GNU ld.so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+nto-qnx*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+openbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=yes
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[89] | openbsd2.[89].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+sco3.2v5*)
+ version_type=osf
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+solaris*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ export_dynamic_flag_spec='${wl}-Blargedynsym'
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+uts4*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+echo "$as_me:$LINENO: result: $dynamic_linker" >&5
+echo "${ECHO_T}$dynamic_linker" >&6
+test "$dynamic_linker" = no && can_build_shared=no
+
+echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
+hardcode_action_GCJ=
+if test -n "$hardcode_libdir_flag_spec_GCJ" || \
+ test -n "$runpath_var GCJ" || \
+ test "X$hardcode_automatic_GCJ"="Xyes" ; then
+
+ # We can hardcode non-existant directories.
+ if test "$hardcode_direct_GCJ" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no &&
+ test "$hardcode_minus_L_GCJ" != no; then
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action_GCJ=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action_GCJ=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action_GCJ=unsupported
+fi
+echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5
+echo "${ECHO_T}$hardcode_action_GCJ" >&6
+
+if test "$hardcode_action_GCJ" = relink; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+
+striplib=
+old_striplib=
+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+ case $host_os in
+ darwin*)
+ if test -n "$STRIP" ; then
+ striplib="$STRIP -x"
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+ ;;
+ *)
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ ;;
+ esac
+fi
+
+if test "x$enable_dlopen" != xyes; then
+ enable_dlopen=unknown
+ enable_dlopen_self=unknown
+ enable_dlopen_self_static=unknown
+else
+ lt_cv_dlopen=no
+ lt_cv_dlopen_libs=
+
+ case $host_os in
+ beos*)
+ lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ;;
+
+ mingw* | pw32*)
+ lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen_libs=
+ ;;
+
+ cygwin*)
+ lt_cv_dlopen="dlopen"
+ lt_cv_dlopen_libs=
+ ;;
+
+ darwin*)
+ # if libdl is installed we need to link against it
+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dl_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+ lt_cv_dlopen="dyld"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+
+fi
+
+ ;;
+
+ *)
+ echo "$as_me:$LINENO: checking for shl_load" >&5
+echo $ECHO_N "checking for shl_load... $ECHO_C" >&6
+if test "${ac_cv_func_shl_load+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define shl_load innocuous_shl_load
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char shl_load (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef shl_load
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char shl_load ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_shl_load) || defined (__stub___shl_load)
+choke me
+#else
+char (*f) () = shl_load;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != shl_load;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_shl_load=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_shl_load=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
+echo "${ECHO_T}$ac_cv_func_shl_load" >&6
+if test $ac_cv_func_shl_load = yes; then
+ lt_cv_dlopen="shl_load"
+else
+ echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
+echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char shl_load ();
+int
+main ()
+{
+shl_load ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dld_shl_load=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dld_shl_load=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6
+if test $ac_cv_lib_dld_shl_load = yes; then
+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
+else
+ echo "$as_me:$LINENO: checking for dlopen" >&5
+echo $ECHO_N "checking for dlopen... $ECHO_C" >&6
+if test "${ac_cv_func_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define dlopen innocuous_dlopen
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char dlopen (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef dlopen
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_dlopen) || defined (__stub___dlopen)
+choke me
+#else
+char (*f) () = dlopen;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != dlopen;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
+echo "${ECHO_T}$ac_cv_func_dlopen" >&6
+if test $ac_cv_func_dlopen = yes; then
+ lt_cv_dlopen="dlopen"
+else
+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dl_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+ echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
+echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_svld_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_svld_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6
+if test $ac_cv_lib_svld_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+ echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
+echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dld_link ();
+int
+main ()
+{
+dld_link ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dld_dld_link=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dld_dld_link=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6
+if test $ac_cv_lib_dld_dld_link = yes; then
+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+ ;;
+ esac
+
+ if test "x$lt_cv_dlopen" != xno; then
+ enable_dlopen=yes
+ else
+ enable_dlopen=no
+ fi
+
+ case $lt_cv_dlopen in
+ dlopen)
+ save_CPPFLAGS="$CPPFLAGS"
+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+ save_LDFLAGS="$LDFLAGS"
+ eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+ save_LIBS="$LIBS"
+ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+ echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
+echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<EOF
+#line 17895 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ /* dlclose (self); */
+ }
+
+ exit (status);
+}
+EOF
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_unknown|x*) lt_cv_dlopen_self=no ;;
+ esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self=no
+ fi
+fi
+rm -fr conftest*
+
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self" >&6
+
+ if test "x$lt_cv_dlopen_self" = xyes; then
+ LDFLAGS="$LDFLAGS $link_static_flag"
+ echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
+echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self_static+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self_static=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<EOF
+#line 17993 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ /* dlclose (self); */
+ }
+
+ exit (status);
+}
+EOF
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;;
+ esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self_static=no
+ fi
+fi
+rm -fr conftest*
+
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6
+ fi
+
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
+ ;;
+ esac
+
+ case $lt_cv_dlopen_self in
+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+ *) enable_dlopen_self=unknown ;;
+ esac
+
+ case $lt_cv_dlopen_self_static in
+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+ *) enable_dlopen_self_static=unknown ;;
+ esac
+fi
+
+
+# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+ # See if we are running on zsh, and set the options which allow our commands through
+ # without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+ # Now quote all the things that may contain metacharacters while being
+ # careful not to overquote the AC_SUBSTed values. We take copies of the
+ # variables and quote the copies for generation of the libtool script.
+ for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+ SED SHELL STRIP \
+ libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+ old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+ deplibs_check_method reload_flag reload_cmds need_locks \
+ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+ lt_cv_sys_global_symbol_to_c_name_address \
+ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+ old_postinstall_cmds old_postuninstall_cmds \
+ compiler_GCJ \
+ CC_GCJ \
+ LD_GCJ \
+ lt_prog_compiler_wl_GCJ \
+ lt_prog_compiler_pic_GCJ \
+ lt_prog_compiler_static_GCJ \
+ lt_prog_compiler_no_builtin_flag_GCJ \
+ export_dynamic_flag_spec_GCJ \
+ thread_safe_flag_spec_GCJ \
+ whole_archive_flag_spec_GCJ \
+ enable_shared_with_static_runtimes_GCJ \
+ old_archive_cmds_GCJ \
+ old_archive_from_new_cmds_GCJ \
+ predep_objects_GCJ \
+ postdep_objects_GCJ \
+ predeps_GCJ \
+ postdeps_GCJ \
+ compiler_lib_search_path_GCJ \
+ archive_cmds_GCJ \
+ archive_expsym_cmds_GCJ \
+ postinstall_cmds_GCJ \
+ postuninstall_cmds_GCJ \
+ old_archive_from_expsyms_cmds_GCJ \
+ allow_undefined_flag_GCJ \
+ no_undefined_flag_GCJ \
+ export_symbols_cmds_GCJ \
+ hardcode_libdir_flag_spec_GCJ \
+ hardcode_libdir_flag_spec_ld_GCJ \
+ hardcode_libdir_separator_GCJ \
+ hardcode_automatic_GCJ \
+ module_cmds_GCJ \
+ module_expsym_cmds_GCJ \
+ lt_cv_prog_compiler_c_o_GCJ \
+ exclude_expsyms_GCJ \
+ include_expsyms_GCJ; do
+
+ case $var in
+ old_archive_cmds_GCJ | \
+ old_archive_from_new_cmds_GCJ | \
+ archive_cmds_GCJ | \
+ archive_expsym_cmds_GCJ | \
+ module_cmds_GCJ | \
+ module_expsym_cmds_GCJ | \
+ old_archive_from_expsyms_cmds_GCJ | \
+ export_symbols_cmds_GCJ | \
+ extract_expsyms_cmds | reload_cmds | finish_cmds | \
+ postinstall_cmds | postuninstall_cmds | \
+ old_postinstall_cmds | old_postuninstall_cmds | \
+ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+ # Double-quote double-evaled strings.
+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+ ;;
+ *)
+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+ ;;
+ esac
+ done
+
+ case $lt_echo in
+ *'\$0 --fallback-echo"')
+ lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+ ;;
+ esac
+
+cfgfile="$ofile"
+
+ cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_GCJ
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_compiler_GCJ
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_GCJ
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD_GCJ
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_GCJ
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext='$shrext'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_GCJ
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ
+
+# Must we lock files when doing compilation ?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_GCJ
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names. First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds_GCJ
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_GCJ
+archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_GCJ
+module_expsym_cmds=$lt_module_expsym_cmds_GCJ
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_GCJ
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_GCJ
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_GCJ
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_GCJ
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_GCJ
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_GCJ
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_GCJ
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_GCJ
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_GCJ
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_GCJ
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_GCJ
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path_GCJ"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_GCJ
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_GCJ
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_GCJ
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_GCJ
+
+# ### END LIBTOOL TAG CONFIG: $tagname
+
+__EOF__
+
+
+else
+ # If there is no Makefile yet, we rely on a make rule to execute
+ # `config.status --recheck' to rerun these tests and create the
+ # libtool script then.
+ ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+ if test -f "$ltmain_in"; then
+ test -f Makefile && make "$ltmain"
+ fi
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+ else
+ tagname=""
+ fi
+ ;;
+
+ RC)
+
+
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+objext_RC=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${RC-"windres"}
+compiler=$CC
+compiler_RC=$CC
+lt_cv_prog_compiler_c_o_RC=yes
+
+# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+ # See if we are running on zsh, and set the options which allow our commands through
+ # without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+ # Now quote all the things that may contain metacharacters while being
+ # careful not to overquote the AC_SUBSTed values. We take copies of the
+ # variables and quote the copies for generation of the libtool script.
+ for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+ SED SHELL STRIP \
+ libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+ old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+ deplibs_check_method reload_flag reload_cmds need_locks \
+ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+ lt_cv_sys_global_symbol_to_c_name_address \
+ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+ old_postinstall_cmds old_postuninstall_cmds \
+ compiler_RC \
+ CC_RC \
+ LD_RC \
+ lt_prog_compiler_wl_RC \
+ lt_prog_compiler_pic_RC \
+ lt_prog_compiler_static_RC \
+ lt_prog_compiler_no_builtin_flag_RC \
+ export_dynamic_flag_spec_RC \
+ thread_safe_flag_spec_RC \
+ whole_archive_flag_spec_RC \
+ enable_shared_with_static_runtimes_RC \
+ old_archive_cmds_RC \
+ old_archive_from_new_cmds_RC \
+ predep_objects_RC \
+ postdep_objects_RC \
+ predeps_RC \
+ postdeps_RC \
+ compiler_lib_search_path_RC \
+ archive_cmds_RC \
+ archive_expsym_cmds_RC \
+ postinstall_cmds_RC \
+ postuninstall_cmds_RC \
+ old_archive_from_expsyms_cmds_RC \
+ allow_undefined_flag_RC \
+ no_undefined_flag_RC \
+ export_symbols_cmds_RC \
+ hardcode_libdir_flag_spec_RC \
+ hardcode_libdir_flag_spec_ld_RC \
+ hardcode_libdir_separator_RC \
+ hardcode_automatic_RC \
+ module_cmds_RC \
+ module_expsym_cmds_RC \
+ lt_cv_prog_compiler_c_o_RC \
+ exclude_expsyms_RC \
+ include_expsyms_RC; do
+
+ case $var in
+ old_archive_cmds_RC | \
+ old_archive_from_new_cmds_RC | \
+ archive_cmds_RC | \
+ archive_expsym_cmds_RC | \
+ module_cmds_RC | \
+ module_expsym_cmds_RC | \
+ old_archive_from_expsyms_cmds_RC | \
+ export_symbols_cmds_RC | \
+ extract_expsyms_cmds | reload_cmds | finish_cmds | \
+ postinstall_cmds | postuninstall_cmds | \
+ old_postinstall_cmds | old_postuninstall_cmds | \
+ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+ # Double-quote double-evaled strings.
+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+ ;;
+ *)
+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+ ;;
+ esac
+ done
+
+ case $lt_echo in
+ *'\$0 --fallback-echo"')
+ lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+ ;;
+ esac
+
+cfgfile="$ofile"
+
+ cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_RC
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_compiler_RC
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_RC
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD_RC
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_RC
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext='$shrext'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_RC
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC
+
+# Must we lock files when doing compilation ?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_RC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names. First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds_RC
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_RC
+archive_expsym_cmds=$lt_archive_expsym_cmds_RC
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_RC
+module_expsym_cmds=$lt_module_expsym_cmds_RC
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_RC
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_RC
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_RC
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_RC
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_RC
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_RC
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_RC
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_RC
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_RC
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_RC
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_RC
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_RC
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_RC
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path_RC"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_RC
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_RC
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_RC
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_RC
+
+# ### END LIBTOOL TAG CONFIG: $tagname
+
+__EOF__
+
+
+else
+ # If there is no Makefile yet, we rely on a make rule to execute
+ # `config.status --recheck' to rerun these tests and create the
+ # libtool script then.
+ ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+ if test -f "$ltmain_in"; then
+ test -f Makefile && make "$ltmain"
+ fi
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+ ;;
+
+ *)
+ { { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5
+echo "$as_me: error: Unsupported tag name: $tagname" >&2;}
+ { (exit 1); exit 1; }; }
+ ;;
+ esac
+
+ # Append the new tag name to the list of available tags.
+ if test -n "$tagname" ; then
+ available_tags="$available_tags $tagname"
+ fi
+ fi
+ done
+ IFS="$lt_save_ifs"
+
+ # Now substitute the updated list of available tags.
+ if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
+ mv "${ofile}T" "$ofile"
+ chmod +x "$ofile"
+ else
+ rm -f "${ofile}T"
+ { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5
+echo "$as_me: error: unable to update list of available tagged configurations." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+fi
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+# Prevent multiple expansion
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#
+# Check for Xrender
+#
+
+ succeeded=no
+
+ if test -z "$PKG_CONFIG"; then
+ # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $PKG_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
+ ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+
+if test -n "$PKG_CONFIG"; then
+ echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ fi
+
+ if test "$PKG_CONFIG" = "no" ; then
+ echo "*** The pkg-config script could not be found. Make sure it is"
+ echo "*** in your path, or set the PKG_CONFIG environment variable"
+ echo "*** to the full path to pkg-config."
+ echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
+ else
+ PKG_CONFIG_MIN_VERSION=0.9.0
+ if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
+ echo "$as_me:$LINENO: checking for xrender >= 0.8.2" >&5
+echo $ECHO_N "checking for xrender >= 0.8.2... $ECHO_C" >&6
+
+ if $PKG_CONFIG --exists "xrender >= 0.8.2" ; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ succeeded=yes
+
+ echo "$as_me:$LINENO: checking XRENDER_CFLAGS" >&5
+echo $ECHO_N "checking XRENDER_CFLAGS... $ECHO_C" >&6
+ XRENDER_CFLAGS=`$PKG_CONFIG --cflags "xrender >= 0.8.2"`
+ echo "$as_me:$LINENO: result: $XRENDER_CFLAGS" >&5
+echo "${ECHO_T}$XRENDER_CFLAGS" >&6
+
+ echo "$as_me:$LINENO: checking XRENDER_LIBS" >&5
+echo $ECHO_N "checking XRENDER_LIBS... $ECHO_C" >&6
+ XRENDER_LIBS=`$PKG_CONFIG --libs "xrender >= 0.8.2"`
+ echo "$as_me:$LINENO: result: $XRENDER_LIBS" >&5
+echo "${ECHO_T}$XRENDER_LIBS" >&6
+ else
+ XRENDER_CFLAGS=""
+ XRENDER_LIBS=""
+ ## If we have a custom action on failure, don't print errors, but
+ ## do set a variable so people can do so.
+ XRENDER_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "xrender >= 0.8.2"`
+
+ fi
+
+
+
+ else
+ echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
+ echo "*** See http://www.freedesktop.org/software/pkgconfig"
+ fi
+ fi
+
+ if test $succeeded = yes; then
+ xrender_found_with_pkgconfig=yes
+ else
+ xrender_found_with_pkgconfig=no
+ fi
+
+case "$xrender_found_with_pkgconfig" in
+no)
+
+ succeeded=no
+
+ if test -z "$PKG_CONFIG"; then
+ # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $PKG_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
+ ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+
+if test -n "$PKG_CONFIG"; then
+ echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ fi
+
+ if test "$PKG_CONFIG" = "no" ; then
+ echo "*** The pkg-config script could not be found. Make sure it is"
+ echo "*** in your path, or set the PKG_CONFIG environment variable"
+ echo "*** to the full path to pkg-config."
+ echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
+ else
+ PKG_CONFIG_MIN_VERSION=0.9.0
+ if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
+ echo "$as_me:$LINENO: checking for xrender >= 0" >&5
+echo $ECHO_N "checking for xrender >= 0... $ECHO_C" >&6
+
+ if $PKG_CONFIG --exists "xrender >= 0" ; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ succeeded=yes
+
+ echo "$as_me:$LINENO: checking XRENDER_CFLAGS" >&5
+echo $ECHO_N "checking XRENDER_CFLAGS... $ECHO_C" >&6
+ XRENDER_CFLAGS=`$PKG_CONFIG --cflags "xrender >= 0"`
+ echo "$as_me:$LINENO: result: $XRENDER_CFLAGS" >&5
+echo "${ECHO_T}$XRENDER_CFLAGS" >&6
+
+ echo "$as_me:$LINENO: checking XRENDER_LIBS" >&5
+echo $ECHO_N "checking XRENDER_LIBS... $ECHO_C" >&6
+ XRENDER_LIBS=`$PKG_CONFIG --libs "xrender >= 0"`
+ echo "$as_me:$LINENO: result: $XRENDER_LIBS" >&5
+echo "${ECHO_T}$XRENDER_LIBS" >&6
+ else
+ XRENDER_CFLAGS=""
+ XRENDER_LIBS=""
+ ## If we have a custom action on failure, don't print errors, but
+ ## do set a variable so people can do so.
+ XRENDER_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "xrender >= 0"`
+
+ fi
+
+
+
+ else
+ echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
+ echo "*** See http://www.freedesktop.org/software/pkgconfig"
+ fi
+ fi
+
+ if test $succeeded = yes; then
+ old_xrender_found_with_pkgconfig=yes
+ else
+ old_xrender_found_with_pkgconfig=no
+ fi
+
+ case "$old_xrender_found_with_pkgconfig" in
+ yes)
+ XRENDER_LIBS="$XRENDER_LIBS -lXext -lX11"
+ ;;
+ *)
+ # checks for X
+ echo "$as_me:$LINENO: checking for X" >&5
+echo $ECHO_N "checking for X... $ECHO_C" >&6
+
+
+# Check whether --with-x or --without-x was given.
+if test "${with_x+set}" = set; then
+ withval="$with_x"
+
+fi;
+# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
+if test "x$with_x" = xno; then
+ # The user explicitly disabled X.
+ have_x=disabled
+else
+ if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
+ # Both variables are already set.
+ have_x=yes
+ else
+ if test "${ac_cv_have_x+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # One or both of the vars are not set, and there is no cached value.
+ac_x_includes=no ac_x_libraries=no
+rm -fr conftest.dir
+if mkdir conftest.dir; then
+ cd conftest.dir
+ # Make sure to not put "make" in the Imakefile rules, since we grep it out.
+ cat >Imakefile <<'_ACEOF'
+acfindx:
+ @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
+_ACEOF
+ if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
+ # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+ eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
+ # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
+ for ac_extension in a so sl; do
+ if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
+ test -f $ac_im_libdir/libX11.$ac_extension; then
+ ac_im_usrlibdir=$ac_im_libdir; break
+ fi
+ done
+ # Screen out bogus values from the imake configuration. They are
+ # bogus both because they are the default anyway, and because
+ # using them would break gcc on systems where it needs fixed includes.
+ case $ac_im_incroot in
+ /usr/include) ;;
+ *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
+ esac
+ case $ac_im_usrlibdir in
+ /usr/lib | /lib) ;;
+ *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
+ esac
+ fi
+ cd ..
+ rm -fr conftest.dir
+fi
+
+# Standard set of common directories for X headers.
+# Check X11 before X11Rn because it is often a symlink to the current release.
+ac_x_header_dirs='
+/usr/X11/include
+/usr/X11R6/include
+/usr/X11R5/include
+/usr/X11R4/include
+
+/usr/include/X11
+/usr/include/X11R6
+/usr/include/X11R5
+/usr/include/X11R4
+
+/usr/local/X11/include
+/usr/local/X11R6/include
+/usr/local/X11R5/include
+/usr/local/X11R4/include
+
+/usr/local/include/X11
+/usr/local/include/X11R6
+/usr/local/include/X11R5
+/usr/local/include/X11R4
+
+/usr/X386/include
+/usr/x386/include
+/usr/XFree86/include/X11
+
+/usr/include
+/usr/local/include
+/usr/unsupported/include
+/usr/athena/include
+/usr/local/x11r5/include
+/usr/lpp/Xamples/include
+
+/usr/openwin/include
+/usr/openwin/share/include'
+
+if test "$ac_x_includes" = no; then
+ # Guess where to find include files, by looking for Intrinsic.h.
+ # First, try using that file with no special directory specified.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <X11/Intrinsic.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # We can compile using X headers with no special include directory.
+ac_x_includes=
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ for ac_dir in $ac_x_header_dirs; do
+ if test -r "$ac_dir/X11/Intrinsic.h"; then
+ ac_x_includes=$ac_dir
+ break
+ fi
+done
+fi
+rm -f conftest.err conftest.$ac_ext
+fi # $ac_x_includes = no
+
+if test "$ac_x_libraries" = no; then
+ # Check for the libraries.
+ # See if we find them without any special options.
+ # Don't add to $LIBS permanently.
+ ac_save_LIBS=$LIBS
+ LIBS="-lXt $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <X11/Intrinsic.h>
+int
+main ()
+{
+XtMalloc (0)
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ LIBS=$ac_save_LIBS
+# We can link X programs with no special library path.
+ac_x_libraries=
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+LIBS=$ac_save_LIBS
+for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
+do
+ # Don't even attempt the hair of trying to link an X program!
+ for ac_extension in a so sl; do
+ if test -r $ac_dir/libXt.$ac_extension; then
+ ac_x_libraries=$ac_dir
+ break 2
+ fi
+ done
+done
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi # $ac_x_libraries = no
+
+if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then
+ # Didn't find X anywhere. Cache the known absence of X.
+ ac_cv_have_x="have_x=no"
+else
+ # Record where we found X for the cache.
+ ac_cv_have_x="have_x=yes \
+ ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
+fi
+fi
+
+ fi
+ eval "$ac_cv_have_x"
+fi # $with_x != no
+
+if test "$have_x" != yes; then
+ echo "$as_me:$LINENO: result: $have_x" >&5
+echo "${ECHO_T}$have_x" >&6
+ no_x=yes
+else
+ # If each of the values was on the command line, it overrides each guess.
+ test "x$x_includes" = xNONE && x_includes=$ac_x_includes
+ test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
+ # Update the cache value to reflect the command line values.
+ ac_cv_have_x="have_x=yes \
+ ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
+ echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5
+echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6
+fi
+
+
+ XRENDER_CFLAGS="-I$x_includes"
+ XRENDER_LIBS="-L$x_libraries -lXrender -lXext -lX11"
+
+ saved_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $XRENDER_CFLAGS"
+
+for ac_header in X11/extensions/Xrender.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## -------------------------------- ##
+## Report this to keithp@keithp.com ##
+## -------------------------------- ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ { { echo "$as_me:$LINENO: error: Xrender.h not found." >&5
+echo "$as_me: error: Xrender.h not found." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+done
+
+ CPPFLAGS="$saved_CPPFLAGS"
+
+ saved_LIBS="$LIBS"
+ LIBS="$LIBS $XRENDER_LIBS"
+
+for ac_func in XRenderFindStandardFormat
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ { { echo "$as_me:$LINENO: error: libXrender not found or too old." >&5
+echo "$as_me: error: libXrender not found or too old." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+done
+
+ LIBS="$saved_LIBS"
+ ;;
+ esac
+ ;;
+esac
+
+# Check freetype configuration
+# Extract the first word of "freetype-config", so it can be a program name with args.
+set dummy freetype-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ft_config+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ft_config"; then
+ ac_cv_prog_ft_config="$ft_config" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ft_config="freetype-config"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ft_config=$ac_cv_prog_ft_config
+if test -n "$ft_config"; then
+ echo "$as_me:$LINENO: result: $ft_config" >&5
+echo "${ECHO_T}$ft_config" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+if test "x$ft_config" = "x" ; then
+ { { echo "$as_me:$LINENO: error: freetype-config not found. freetype is required. Please make sure you have the freetype development packages installed." >&5
+echo "$as_me: error: freetype-config not found. freetype is required. Please make sure you have the freetype development packages installed." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+FREETYPE_CFLAGS="`$ft_config --cflags`"
+FREETYPE_LIBS="`$ft_config --libs`"
+
+# Check fontconfig configuration
+
+ succeeded=no
+
+ if test -z "$PKG_CONFIG"; then
+ # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $PKG_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
+ ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+
+if test -n "$PKG_CONFIG"; then
+ echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ fi
+
+ if test "$PKG_CONFIG" = "no" ; then
+ echo "*** The pkg-config script could not be found. Make sure it is"
+ echo "*** in your path, or set the PKG_CONFIG environment variable"
+ echo "*** to the full path to pkg-config."
+ echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
+ else
+ PKG_CONFIG_MIN_VERSION=0.9.0
+ if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
+ echo "$as_me:$LINENO: checking for fontconfig >= 2.2" >&5
+echo $ECHO_N "checking for fontconfig >= 2.2... $ECHO_C" >&6
+
+ if $PKG_CONFIG --exists "fontconfig >= 2.2" ; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ succeeded=yes
+
+ echo "$as_me:$LINENO: checking FONTCONFIG_CFLAGS" >&5
+echo $ECHO_N "checking FONTCONFIG_CFLAGS... $ECHO_C" >&6
+ FONTCONFIG_CFLAGS=`$PKG_CONFIG --cflags "fontconfig >= 2.2"`
+ echo "$as_me:$LINENO: result: $FONTCONFIG_CFLAGS" >&5
+echo "${ECHO_T}$FONTCONFIG_CFLAGS" >&6
+
+ echo "$as_me:$LINENO: checking FONTCONFIG_LIBS" >&5
+echo $ECHO_N "checking FONTCONFIG_LIBS... $ECHO_C" >&6
+ FONTCONFIG_LIBS=`$PKG_CONFIG --libs "fontconfig >= 2.2"`
+ echo "$as_me:$LINENO: result: $FONTCONFIG_LIBS" >&5
+echo "${ECHO_T}$FONTCONFIG_LIBS" >&6
+ else
+ FONTCONFIG_CFLAGS=""
+ FONTCONFIG_LIBS=""
+ ## If we have a custom action on failure, don't print errors, but
+ ## do set a variable so people can do so.
+ FONTCONFIG_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "fontconfig >= 2.2"`
+ echo $FONTCONFIG_PKG_ERRORS
+ fi
+
+
+
+ else
+ echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
+ echo "*** See http://www.freedesktop.org/software/pkgconfig"
+ fi
+ fi
+
+ if test $succeeded = yes; then
+ :
+ else
+ { { echo "$as_me:$LINENO: error: Library requirements (fontconfig >= 2.2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&5
+echo "$as_me: error: Library requirements (fontconfig >= 2.2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+
+
+
+
+
+
+
+
+fontconfig_save_libs="$LIBS"
+fontconfig_save_cflags="$CFLAGS"
+LIBS="$LIBS $FREETYPE_LIBS"
+CFLAGS="$CFLAGS $FREETYPE_CFLAGS"
+
+
+
+
+for ac_func in FT_Get_Next_Char FT_Get_BDF_Property FT_Get_PS_Font_Info FT_Has_PS_Glyph_Names
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+echo "$as_me:$LINENO: checking for FT_Bitmap_Size.y_ppem" >&5
+echo $ECHO_N "checking for FT_Bitmap_Size.y_ppem... $ECHO_C" >&6
+if test "${ac_cv_member_FT_Bitmap_Size_y_ppem+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+int
+main ()
+{
+static FT_Bitmap_Size ac_aggr;
+if (ac_aggr.y_ppem)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_member_FT_Bitmap_Size_y_ppem=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+int
+main ()
+{
+static FT_Bitmap_Size ac_aggr;
+if (sizeof ac_aggr.y_ppem)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_member_FT_Bitmap_Size_y_ppem=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_member_FT_Bitmap_Size_y_ppem=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_member_FT_Bitmap_Size_y_ppem" >&5
+echo "${ECHO_T}$ac_cv_member_FT_Bitmap_Size_y_ppem" >&6
+if test $ac_cv_member_FT_Bitmap_Size_y_ppem = yes; then
+ HAVE_FT_BITMAP_SIZE_Y_PPEM=1
+else
+ HAVE_FT_BITMAP_SIZE_Y_PPEM=0
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_FT_BITMAP_SIZE_Y_PPEM $HAVE_FT_BITMAP_SIZE_Y_PPEM
+_ACEOF
+
+
+LIBS="$fontconfig_save_libs"
+CFLAGS="$fontconfig_save_cflags"
+
+if test "$VERSION" = "" ; then
+ VERSION=$PACKAGE_VERSION;
+fi
+
+ ac_config_files="$ac_config_files Makefile xft.pc xft-config Xft.3"
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+{
+ (set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+} |
+ sed '
+ t clear
+ : clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ : end' >>confcache
+if diff $cache_file confcache >/dev/null 2>&1; then :; else
+ if test -w $cache_file; then
+ test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+ cat confcache >$cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=/{
+s/:*\$(srcdir):*/:/;
+s/:*\${srcdir}:*/:/;
+s/:*@srcdir@:*/:/;
+s/^\([^=]*=[ ]*\):*/\1/;
+s/:*$//;
+s/^[^=]*=[ ]*$//;
+}'
+fi
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_i=`echo "$ac_i" |
+ sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
+ # 2. Add them.
+ ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
+ ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"MAINTAINER_MODE\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"MAINTAINER_MODE\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
+echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
+echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+exec 6>&1
+
+# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling. Logging --version etc. is OK.
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+} >&5
+cat >&5 <<_CSEOF
+
+This file was extended by libXft $as_me 2.1.5, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+_CSEOF
+echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
+echo >&5
+_ACEOF
+
+# Files that config.status was made for.
+if test -n "$ac_config_files"; then
+ echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_headers"; then
+ echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_links"; then
+ echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_commands"; then
+ echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -q, --quiet do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+ --header=FILE[:TEMPLATE]
+ instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to <bug-autoconf@gnu.org>."
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+libXft config.status 2.1.5
+configured by $0, generated by GNU Autoconf 2.59,
+ with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+srcdir=$srcdir
+INSTALL="$INSTALL"
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If no file are specified by the user, then we need to provide default
+# value. By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=*)
+ ac_option=`expr "x$1" : 'x\([^=]*\)='`
+ ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ -*)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ *) # This is not an option, so the user has probably given explicit
+ # arguments.
+ ac_option=$1
+ ac_need_defaults=false;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --vers* | -V )
+ echo "$ac_cs_version"; exit 0 ;;
+ --he | --h)
+ # Conflict between --help and --header
+ { { echo "$as_me:$LINENO: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; };;
+ --help | --hel | -h )
+ echo "$ac_cs_usage"; exit 0 ;;
+ --debug | --d* | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+ ac_need_defaults=false;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; } ;;
+
+ *) ac_config_targets="$ac_config_targets $1" ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+ echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+ exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+#
+# INIT-COMMANDS section.
+#
+
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+_ACEOF
+
+
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_config_target in $ac_config_targets
+do
+ case "$ac_config_target" in
+ # Handling of arguments.
+ "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "xft.pc" ) CONFIG_FILES="$CONFIG_FILES xft.pc" ;;
+ "xft-config" ) CONFIG_FILES="$CONFIG_FILES xft-config" ;;
+ "Xft.3" ) CONFIG_FILES="$CONFIG_FILES Xft.3" ;;
+ "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+ "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+ *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+ test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason to put it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+ trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+ trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
+ test -n "$tmp" && test -d "$tmp"
+} ||
+{
+ tmp=./confstat$$-$RANDOM
+ (umask 077 && mkdir $tmp)
+} ||
+{
+ echo "$me: cannot create a temporary directory in ." >&2
+ { (exit 1); exit 1; }
+}
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+
+#
+# CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "\$CONFIG_FILES"; then
+ # Protect against being on the right side of a sed subst in config.status.
+ sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
+ s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+s,@SHELL@,$SHELL,;t t
+s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s,@exec_prefix@,$exec_prefix,;t t
+s,@prefix@,$prefix,;t t
+s,@program_transform_name@,$program_transform_name,;t t
+s,@bindir@,$bindir,;t t
+s,@sbindir@,$sbindir,;t t
+s,@libexecdir@,$libexecdir,;t t
+s,@datadir@,$datadir,;t t
+s,@sysconfdir@,$sysconfdir,;t t
+s,@sharedstatedir@,$sharedstatedir,;t t
+s,@localstatedir@,$localstatedir,;t t
+s,@libdir@,$libdir,;t t
+s,@includedir@,$includedir,;t t
+s,@oldincludedir@,$oldincludedir,;t t
+s,@infodir@,$infodir,;t t
+s,@mandir@,$mandir,;t t
+s,@build_alias@,$build_alias,;t t
+s,@host_alias@,$host_alias,;t t
+s,@target_alias@,$target_alias,;t t
+s,@DEFS@,$DEFS,;t t
+s,@ECHO_C@,$ECHO_C,;t t
+s,@ECHO_N@,$ECHO_N,;t t
+s,@ECHO_T@,$ECHO_T,;t t
+s,@LIBS@,$LIBS,;t t
+s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
+s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
+s,@INSTALL_DATA@,$INSTALL_DATA,;t t
+s,@CYGPATH_W@,$CYGPATH_W,;t t
+s,@PACKAGE@,$PACKAGE,;t t
+s,@VERSION@,$VERSION,;t t
+s,@ACLOCAL@,$ACLOCAL,;t t
+s,@AUTOCONF@,$AUTOCONF,;t t
+s,@AUTOMAKE@,$AUTOMAKE,;t t
+s,@AUTOHEADER@,$AUTOHEADER,;t t
+s,@MAKEINFO@,$MAKEINFO,;t t
+s,@AMTAR@,$AMTAR,;t t
+s,@install_sh@,$install_sh,;t t
+s,@STRIP@,$STRIP,;t t
+s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t
+s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t
+s,@AWK@,$AWK,;t t
+s,@SET_MAKE@,$SET_MAKE,;t t
+s,@am__leading_dot@,$am__leading_dot,;t t
+s,@MAINTAINER_MODE_TRUE@,$MAINTAINER_MODE_TRUE,;t t
+s,@MAINTAINER_MODE_FALSE@,$MAINTAINER_MODE_FALSE,;t t
+s,@MAINT@,$MAINT,;t t
+s,@CC@,$CC,;t t
+s,@CFLAGS@,$CFLAGS,;t t
+s,@LDFLAGS@,$LDFLAGS,;t t
+s,@CPPFLAGS@,$CPPFLAGS,;t t
+s,@ac_ct_CC@,$ac_ct_CC,;t t
+s,@EXEEXT@,$EXEEXT,;t t
+s,@OBJEXT@,$OBJEXT,;t t
+s,@DEPDIR@,$DEPDIR,;t t
+s,@am__include@,$am__include,;t t
+s,@am__quote@,$am__quote,;t t
+s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t
+s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t
+s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t
+s,@CCDEPMODE@,$CCDEPMODE,;t t
+s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t
+s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t
+s,@build@,$build,;t t
+s,@build_cpu@,$build_cpu,;t t
+s,@build_vendor@,$build_vendor,;t t
+s,@build_os@,$build_os,;t t
+s,@host@,$host,;t t
+s,@host_cpu@,$host_cpu,;t t
+s,@host_vendor@,$host_vendor,;t t
+s,@host_os@,$host_os,;t t
+s,@EGREP@,$EGREP,;t t
+s,@LN_S@,$LN_S,;t t
+s,@ECHO@,$ECHO,;t t
+s,@AR@,$AR,;t t
+s,@ac_ct_AR@,$ac_ct_AR,;t t
+s,@RANLIB@,$RANLIB,;t t
+s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
+s,@CPP@,$CPP,;t t
+s,@CXX@,$CXX,;t t
+s,@CXXFLAGS@,$CXXFLAGS,;t t
+s,@ac_ct_CXX@,$ac_ct_CXX,;t t
+s,@CXXDEPMODE@,$CXXDEPMODE,;t t
+s,@am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t
+s,@am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t
+s,@CXXCPP@,$CXXCPP,;t t
+s,@F77@,$F77,;t t
+s,@FFLAGS@,$FFLAGS,;t t
+s,@ac_ct_F77@,$ac_ct_F77,;t t
+s,@LIBTOOL@,$LIBTOOL,;t t
+s,@PKG_CONFIG@,$PKG_CONFIG,;t t
+s,@XRENDER_CFLAGS@,$XRENDER_CFLAGS,;t t
+s,@XRENDER_LIBS@,$XRENDER_LIBS,;t t
+s,@ft_config@,$ft_config,;t t
+s,@FONTCONFIG_CFLAGS@,$FONTCONFIG_CFLAGS,;t t
+s,@FONTCONFIG_LIBS@,$FONTCONFIG_LIBS,;t t
+s,@FREETYPE_CFLAGS@,$FREETYPE_CFLAGS,;t t
+s,@FREETYPE_LIBS@,$FREETYPE_LIBS,;t t
+s,@LIBOBJS@,$LIBOBJS,;t t
+s,@LTLIBOBJS@,$LTLIBOBJS,;t t
+CEOF
+
+_ACEOF
+
+ cat >>$CONFIG_STATUS <<\_ACEOF
+ # Split the substitutions into bite-sized pieces for seds with
+ # small command number limits, like on Digital OSF/1 and HP-UX.
+ ac_max_sed_lines=48
+ ac_sed_frag=1 # Number of current file.
+ ac_beg=1 # First line for current file.
+ ac_end=$ac_max_sed_lines # Line after last line for current file.
+ ac_more_lines=:
+ ac_sed_cmds=
+ while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ else
+ sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ fi
+ if test ! -s $tmp/subs.frag; then
+ ac_more_lines=false
+ else
+ # The purpose of the label and of the branching condition is to
+ # speed up the sed processing (if there are no `@' at all, there
+ # is no need to browse any of the substitutions).
+ # These are the two extra sed commands mentioned above.
+ (echo ':t
+ /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+ fi
+ ac_sed_frag=`expr $ac_sed_frag + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_lines`
+ fi
+ done
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+ fi
+fi # test -n "$CONFIG_FILES"
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case $ac_file in
+ - | *:- | *:-:* ) # input from stdin
+ cat >$tmp/stdin
+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+ # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
+ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+
+ case $INSTALL in
+ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+ *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
+ esac
+
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ if test x"$ac_file" = x-; then
+ configure_input=
+ else
+ configure_input="$ac_file. "
+ fi
+ configure_input=$configure_input"Generated from `echo $ac_file_in |
+ sed 's,.*/,,'` by configure."
+
+ # First look for the input files in the build tree, otherwise in the
+ # src tree.
+ ac_file_inputs=`IFS=:
+ for f in $ac_file_in; do
+ case $f in
+ -) echo $tmp/stdin ;;
+ [\\/$]*)
+ # Absolute (can't be DOS-style, as IFS=:)
+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ echo "$f";;
+ *) # Relative
+ if test -f "$f"; then
+ # Build tree
+ echo "$f"
+ elif test -f "$srcdir/$f"; then
+ # Source tree
+ echo "$srcdir/$f"
+ else
+ # /dev/null tree
+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+
+ if test x"$ac_file" != x-; then
+ { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+ rm -f "$ac_file"
+ fi
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+ sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s,@configure_input@,$configure_input,;t t
+s,@srcdir@,$ac_srcdir,;t t
+s,@abs_srcdir@,$ac_abs_srcdir,;t t
+s,@top_srcdir@,$ac_top_srcdir,;t t
+s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
+s,@builddir@,$ac_builddir,;t t
+s,@abs_builddir@,$ac_abs_builddir,;t t
+s,@top_builddir@,$ac_top_builddir,;t t
+s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
+s,@INSTALL@,$ac_INSTALL,;t t
+" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
+ rm -f $tmp/stdin
+ if test x"$ac_file" != x-; then
+ mv $tmp/out $ac_file
+ else
+ cat $tmp/out
+ rm -f $tmp/out
+ fi
+
+done
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+#
+# CONFIG_HEADER section.
+#
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='[ ].*$,\1#\2'
+ac_dC=' '
+ac_dD=',;t'
+# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='$,\1#\2define\3'
+ac_uC=' '
+ac_uD=',;t'
+
+for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case $ac_file in
+ - | *:- | *:-:* ) # input from stdin
+ cat >$tmp/stdin
+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+ test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+
+ # First look for the input files in the build tree, otherwise in the
+ # src tree.
+ ac_file_inputs=`IFS=:
+ for f in $ac_file_in; do
+ case $f in
+ -) echo $tmp/stdin ;;
+ [\\/$]*)
+ # Absolute (can't be DOS-style, as IFS=:)
+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ # Do quote $f, to prevent DOS paths from being IFS'd.
+ echo "$f";;
+ *) # Relative
+ if test -f "$f"; then
+ # Build tree
+ echo "$f"
+ elif test -f "$srcdir/$f"; then
+ # Source tree
+ echo "$srcdir/$f"
+ else
+ # /dev/null tree
+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+ # Remove the trailing spaces.
+ sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
+
+_ACEOF
+
+# Transform confdefs.h into two sed scripts, `conftest.defines' and
+# `conftest.undefs', that substitutes the proper values into
+# config.h.in to produce config.h. The first handles `#define'
+# templates, and the second `#undef' templates.
+# And first: Protect against being on the right side of a sed subst in
+# config.status. Protect against being in an unquoted here document
+# in config.status.
+rm -f conftest.defines conftest.undefs
+# Using a here document instead of a string reduces the quoting nightmare.
+# Putting comments in sed scripts is not portable.
+#
+# `end' is used to avoid that the second main sed command (meant for
+# 0-ary CPP macros) applies to n-ary macro definitions.
+# See the Autoconf documentation for `clear'.
+cat >confdef2sed.sed <<\_ACEOF
+s/[\\&,]/\\&/g
+s,[\\$`],\\&,g
+t clear
+: clear
+s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
+t end
+s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
+: end
+_ACEOF
+# If some macros were called several times there might be several times
+# the same #defines, which is useless. Nevertheless, we may not want to
+# sort them, since we want the *last* AC-DEFINE to be honored.
+uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
+sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
+rm -f confdef2sed.sed
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >>conftest.undefs <<\_ACEOF
+s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
+_ACEOF
+
+# Break up conftest.defines because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
+echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
+echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
+echo ' :' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.defines >/dev/null
+do
+ # Write a limited-size here document to $tmp/defines.sed.
+ echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
+ # Speed up: don't consider the non `#define' lines.
+ echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
+ # Work around the forget-to-reset-the-flag bug.
+ echo 't clr' >>$CONFIG_STATUS
+ echo ': clr' >>$CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
+ echo 'CEOF
+ sed -f $tmp/defines.sed $tmp/in >$tmp/out
+ rm -f $tmp/in
+ mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
+ rm -f conftest.defines
+ mv conftest.tail conftest.defines
+done
+rm -f conftest.defines
+echo ' fi # grep' >>$CONFIG_STATUS
+echo >>$CONFIG_STATUS
+
+# Break up conftest.undefs because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo ' # Handle all the #undef templates' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.undefs >/dev/null
+do
+ # Write a limited-size here document to $tmp/undefs.sed.
+ echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
+ # Speed up: don't consider the non `#undef'
+ echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
+ # Work around the forget-to-reset-the-flag bug.
+ echo 't clr' >>$CONFIG_STATUS
+ echo ': clr' >>$CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
+ echo 'CEOF
+ sed -f $tmp/undefs.sed $tmp/in >$tmp/out
+ rm -f $tmp/in
+ mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
+ rm -f conftest.undefs
+ mv conftest.tail conftest.undefs
+done
+rm -f conftest.undefs
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ if test x"$ac_file" = x-; then
+ echo "/* Generated by configure. */" >$tmp/config.h
+ else
+ echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
+ fi
+ cat $tmp/in >>$tmp/config.h
+ rm -f $tmp/in
+ if test x"$ac_file" != x-; then
+ if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
+ { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ rm -f $ac_file
+ mv $tmp/config.h $ac_file
+ fi
+ else
+ cat $tmp/config.h
+ rm -f $tmp/config.h
+ fi
+# Compute $ac_file's index in $config_headers.
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+ case $_am_header in
+ $ac_file | $ac_file:* )
+ break ;;
+ * )
+ _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+ esac
+done
+echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null ||
+$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X$ac_file : 'X\(//\)[^/]' \| \
+ X$ac_file : 'X\(//\)$' \| \
+ X$ac_file : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X$ac_file |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`/stamp-h$_am_stamp_count
+done
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+#
+# CONFIG_COMMANDS section.
+#
+for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
+ ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
+ ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_dir=`(dirname "$ac_dest") 2>/dev/null ||
+$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_dest" : 'X\(//\)[^/]' \| \
+ X"$ac_dest" : 'X\(//\)$' \| \
+ X"$ac_dest" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_dest" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+
+ { echo "$as_me:$LINENO: executing $ac_dest commands" >&5
+echo "$as_me: executing $ac_dest commands" >&6;}
+ case $ac_dest in
+ depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
+ # Strip MF so we end up with the name of the file.
+ mf=`echo "$mf" | sed -e 's/:.*$//'`
+ # Check whether this is an Automake generated Makefile or not.
+ # We used to match only the files named `Makefile.in', but
+ # some people rename them; so instead we look at the file content.
+ # Grep'ing the first line is not enough: some people post-process
+ # each Makefile.in and add a new line on top of each file to say so.
+ # So let's grep whole file.
+ if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
+ dirpart=`(dirname "$mf") 2>/dev/null ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$mf" : 'X\(//\)[^/]' \| \
+ X"$mf" : 'X\(//\)$' \| \
+ X"$mf" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$mf" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ else
+ continue
+ fi
+ grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue
+ # Extract the definition of DEP_FILES from the Makefile without
+ # running `make'.
+ DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
+ test -z "$DEPDIR" && continue
+ # When using ansi2knr, U may be empty or an underscore; expand it
+ U=`sed -n -e '/^U = / s///p' < "$mf"`
+ test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
+ # We invoke sed twice because it is the simplest approach to
+ # changing $(DEPDIR) to its actual value in the expansion.
+ for file in `sed -n -e '
+ /^DEP_FILES = .*\\\\$/ {
+ s/^DEP_FILES = //
+ :loop
+ s/\\\\$//
+ p
+ n
+ /\\\\$/ b loop
+ p
+ }
+ /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
+ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+ # Make sure the directory exists.
+ test -f "$dirpart/$file" && continue
+ fdir=`(dirname "$file") 2>/dev/null ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$file" : 'X\(//\)[^/]' \| \
+ X"$file" : 'X\(//\)$' \| \
+ X"$file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p $dirpart/$fdir
+ else
+ as_dir=$dirpart/$fdir
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5
+echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ # echo "creating $dirpart/$file"
+ echo '# dummy' > "$dirpart/$file"
+ done
+done
+ ;;
+ esac
+done
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || { (exit 1); exit 1; }
+fi
+
+
diff --git a/nx-X11/lib/Xft/configure.ac b/nx-X11/lib/Xft/configure.ac
new file mode 100644
index 000000000..3ce090ac5
--- /dev/null
+++ b/nx-X11/lib/Xft/configure.ac
@@ -0,0 +1,133 @@
+dnl
+dnl $Id: configure.ac,v 1.3 2005/06/24 22:43:20 alanc Exp $
+dnl
+dnl Copyright © 2003 Keith Packard, Noah Levitt
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this software and its
+dnl documentation for any purpose is hereby granted without fee, provided that
+dnl the above copyright notice appear in all copies and that both that
+dnl copyright notice and this permission notice appear in supporting
+dnl documentation, and that the name of Keith Packard not be used in
+dnl advertising or publicity pertaining to distribution of the software without
+dnl specific, written prior permission. Keith Packard makes no
+dnl representations about the suitability of this software for any purpose. It
+dnl is provided "as is" without express or implied warranty.
+dnl
+dnl KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+dnl EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+dnl PERFORMANCE OF THIS SOFTWARE.
+dnl
+dnl Process this file with autoconf to create configure.
+
+AC_PREREQ([2.57])
+
+dnl
+dnl This is the package version number, not the shared library
+dnl version. This same version number must appear in Xft.h
+dnl Yes, it is a pain to synchronize version numbers. Unfortunately, it's
+dnl not possible to extract the version number here from Xft.h
+dnl Please bump the minor library number at each release as well.
+dnl
+AC_INIT(libXft, 2.1.7, [keithp@keithp.com], libXft)
+AC_CONFIG_AUX_DIR(.)
+
+AM_INIT_AUTOMAKE([dist-bzip2])
+AM_MAINTAINER_MODE
+
+AM_CONFIG_HEADER(config.h)
+
+# checks for progs
+AC_PROG_CC
+AC_PROG_LIBTOOL
+
+#
+# Check for Xrender
+#
+PKG_CHECK_MODULES(XRENDER, xrender >= 0.8.2, [xrender_found_with_pkgconfig=yes],
+ [xrender_found_with_pkgconfig=no])
+case "$xrender_found_with_pkgconfig" in
+no)
+ PKG_CHECK_MODULES(XRENDER, xrender >= 0, [old_xrender_found_with_pkgconfig=yes],
+ [old_xrender_found_with_pkgconfig=no])
+ case "$old_xrender_found_with_pkgconfig" in
+ yes)
+ XRENDER_LIBS="$XRENDER_LIBS -lXext -lX11"
+ ;;
+ *)
+ # checks for X
+ AC_PATH_X
+
+ XRENDER_CFLAGS="-I$x_includes"
+ XRENDER_LIBS="-L$x_libraries -lXrender -lXext -lX11"
+
+ saved_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $XRENDER_CFLAGS"
+ AC_CHECK_HEADERS([X11/extensions/Xrender.h], [], [AC_MSG_ERROR([Xrender.h not found.])])
+ CPPFLAGS="$saved_CPPFLAGS"
+
+ saved_LIBS="$LIBS"
+ LIBS="$LIBS $XRENDER_LIBS"
+ AC_CHECK_FUNCS([XRenderFindStandardFormat], [], [AC_MSG_ERROR([libXrender not found or too old.])])
+ LIBS="$saved_LIBS"
+ ;;
+ esac
+ ;;
+esac
+
+# Check freetype configuration
+AC_CHECK_PROG(ft_config, freetype-config, freetype-config)
+if test "x$ft_config" = "x" ; then
+ AC_MSG_ERROR([freetype-config not found. freetype is required. Please make sure you have the freetype development packages installed.])
+fi
+FREETYPE_CFLAGS="`$ft_config --cflags`"
+FREETYPE_LIBS="`$ft_config --libs`"
+
+# Check fontconfig configuration
+PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.2)
+
+AC_SUBST(XRENDER_CFLAGS)
+AC_SUBST(XRENDER_LIBS)
+AC_SUBST(FREETYPE_CFLAGS)
+AC_SUBST(FREETYPE_LIBS)
+AC_SUBST(FONTCONFIG_CFLAGS)
+AC_SUBST(FONTCONFIG_LIBS)
+
+fontconfig_save_libs="$LIBS"
+fontconfig_save_cflags="$CFLAGS"
+LIBS="$LIBS $FREETYPE_LIBS"
+CFLAGS="$CFLAGS $FREETYPE_CFLAGS"
+AC_CHECK_FUNCS(FT_Get_Next_Char FT_Get_BDF_Property FT_Get_PS_Font_Info FT_Has_PS_Glyph_Names FT_GlyphSlot_Embolden)
+AC_CHECK_MEMBER(FT_Bitmap_Size.y_ppem,
+ HAVE_FT_BITMAP_SIZE_Y_PPEM=1,
+ HAVE_FT_BITMAP_SIZE_Y_PPEM=0,
+[#include <ft2build.h>
+#include FT_FREETYPE_H])
+AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,$HAVE_FT_BITMAP_SIZE_Y_PPEM,
+ [FT_Bitmap_Size structure includes y_ppem field])
+
+LIBS="$fontconfig_save_libs"
+CFLAGS="$fontconfig_save_cflags"
+
+if test "$VERSION" = "" ; then
+ VERSION=$PACKAGE_VERSION;
+fi
+
+WARN_CFLAGS=""
+
+if test "x$GCC" = "xyes"; then
+ WARN_CFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes \
+ -Wmissing-prototypes -Wmissing-declarations \
+ -Wnested-externs -fno-strict-aliasing"
+fi
+AC_SUBST(WARN_CFLAGS)
+
+AC_OUTPUT([Makefile
+ xft.pc
+ xft-config
+ xft-config.1
+ Xft.3])
+
diff --git a/nx-X11/lib/Xft/depcomp b/nx-X11/lib/Xft/depcomp
new file mode 100755
index 000000000..edb5d38ef
--- /dev/null
+++ b/nx-X11/lib/Xft/depcomp
@@ -0,0 +1,479 @@
+#! /bin/sh
+
+# depcomp - compile a program generating dependencies as side-effects
+# Copyright 1999, 2000, 2003 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+ echo "depcomp: Variables source, object and depmode must be set" 1>&2
+ exit 1
+fi
+# `libtool' can also be set to `yes' or `no'.
+
+if test -z "$depfile"; then
+ base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
+ dir=`echo "$object" | sed 's,/.*$,/,'`
+ if test "$dir" = "$object"; then
+ dir=
+ fi
+ # FIXME: should be _deps on DOS.
+ depfile="$dir.deps/$base"
+fi
+
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags. We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write. Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+ # HP compiler uses -M and no extra arg.
+ gccflag=-M
+ depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+ # This is just like dashmstdout with a different argument.
+ dashmflag=-xM
+ depmode=dashmstdout
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want. Yay! Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff. Hmm.
+ "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ mv "$tmpdepfile" "$depfile"
+ ;;
+
+gcc)
+## There are various ways to get dependency output from gcc. Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+## up in a subdir. Having to rename by hand is ugly.
+## (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+## -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+## than renaming).
+ if test -z "$gccflag"; then
+ gccflag=-MD,
+ fi
+ "$@" -Wp,"$gccflag$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+ sed -e 's/^[^:]*: / /' \
+ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header). We avoid this by adding
+## dummy dependencies for each header file. Too bad gcc doesn't do
+## this for us directly.
+ tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'. On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp)
+ # This case exists only to let depend.m4 do its work. It works by
+ # looking at the text of this script. This case will never be run,
+ # since it is checked for above.
+ exit 1
+ ;;
+
+sgi)
+ if test "$libtool" = yes; then
+ "$@" "-Wp,-MDupdate,$tmpdepfile"
+ else
+ "$@" -MDupdate "$tmpdepfile"
+ fi
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+
+ if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
+ echo "$object : \\" > "$depfile"
+
+ # Clip off the initial element (the dependent). Don't try to be
+ # clever and replace this with sed code, as IRIX sed won't handle
+ # lines with more than a fixed number of characters (4096 in
+ # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
+ # the IRIX cc adds comments like `#:fec' to the end of the
+ # dependency line.
+ tr ' ' '
+' < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+ tr '
+' ' ' >> $depfile
+ echo >> $depfile
+
+ # The second pass generates a dummy entry for each header file.
+ tr ' ' '
+' < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+ >> $depfile
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+aix)
+ # The C for AIX Compiler uses -M and outputs the dependencies
+ # in a .u file. In older versions, this file always lives in the
+ # current directory. Also, the AIX compiler puts `$object:' at the
+ # start of each line; $object doesn't have directory information.
+ # Version 6 uses the directory in both cases.
+ stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
+ tmpdepfile="$stripped.u"
+ if test "$libtool" = yes; then
+ "$@" -Wc,-M
+ else
+ "$@" -M
+ fi
+ stat=$?
+
+ if test -f "$tmpdepfile"; then :
+ else
+ stripped=`echo "$stripped" | sed 's,^.*/,,'`
+ tmpdepfile="$stripped.u"
+ fi
+
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+
+ if test -f "$tmpdepfile"; then
+ outname="$stripped.o"
+ # Each line is of the form `foo.o: dependent.h'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
+ sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+icc)
+ # Intel's C compiler understands `-MD -MF file'. However on
+ # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+ # ICC 7.0 will fill foo.d with something like
+ # foo.o: sub/foo.c
+ # foo.o: sub/foo.h
+ # which is wrong. We want:
+ # sub/foo.o: sub/foo.c
+ # sub/foo.o: sub/foo.h
+ # sub/foo.c:
+ # sub/foo.h:
+ # ICC 7.1 will output
+ # foo.o: sub/foo.c sub/foo.h
+ # and will wrap long lines using \ :
+ # foo.o: sub/foo.c ... \
+ # sub/foo.h ... \
+ # ...
+
+ "$@" -MD -MF "$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ # Each line is of the form `foo.o: dependent.h',
+ # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+ # Some versions of the HPUX 10.20 sed can't process this invocation
+ # correctly. Breaking it into two sed invocations is a workaround.
+ sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+ sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+tru64)
+ # The Tru64 compiler uses -MD to generate dependencies as a side
+ # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+ # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+ # dependencies in `foo.d' instead, so we check for that too.
+ # Subdirectories are respected.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+ if test "$libtool" = yes; then
+ tmpdepfile1="$dir.libs/$base.lo.d"
+ tmpdepfile2="$dir.libs/$base.d"
+ "$@" -Wc,-MD
+ else
+ tmpdepfile1="$dir$base.o.d"
+ tmpdepfile2="$dir$base.d"
+ "$@" -MD
+ fi
+
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2"
+ exit $stat
+ fi
+
+ if test -f "$tmpdepfile1"; then
+ tmpdepfile="$tmpdepfile1"
+ else
+ tmpdepfile="$tmpdepfile2"
+ fi
+ if test -f "$tmpdepfile"; then
+ sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+ # That's a tab and a space in the [].
+ sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ else
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+#nosideeffect)
+ # This comment above is used by automake to tell side-effect
+ # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout, regardless of -o.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove `-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
+ esac
+ done
+
+ test -z "$dashmflag" && dashmflag=-M
+ # Require at least two characters before searching for `:'
+ # in the target name. This is to cope with DOS-style filenames:
+ # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+ "$@" $dashmflag |
+ sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
+ rm -f "$depfile"
+ cat < "$tmpdepfile" > "$depfile"
+ tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+dashXmstdout)
+ # This case only exists to satisfy depend.m4. It is never actually
+ # run, as this mode is specially recognized in the preamble.
+ exit 1
+ ;;
+
+makedepend)
+ "$@" || exit $?
+ # Remove any Libtool call
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+ # X makedepend
+ shift
+ cleared=no
+ for arg in "$@"; do
+ case $cleared in
+ no)
+ set ""; shift
+ cleared=yes ;;
+ esac
+ case "$arg" in
+ -D*|-I*)
+ set fnord "$@" "$arg"; shift ;;
+ # Strip any option that makedepend may not understand. Remove
+ # the object too, otherwise makedepend will parse it as a source file.
+ -*|$object)
+ ;;
+ *)
+ set fnord "$@" "$arg"; shift ;;
+ esac
+ done
+ obj_suffix="`echo $object | sed 's/^.*\././'`"
+ touch "$tmpdepfile"
+ ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+ rm -f "$depfile"
+ cat < "$tmpdepfile" > "$depfile"
+ sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile" "$tmpdepfile".bak
+ ;;
+
+cpp)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove `-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
+ esac
+ done
+
+ "$@" -E |
+ sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+ sed '$ s: \\$::' > "$tmpdepfile"
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ cat < "$tmpdepfile" >> "$depfile"
+ sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+msvisualcpp)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout, regardless of -o,
+ # because we must use -o when running libtool.
+ "$@" || exit $?
+ IFS=" "
+ for arg
+ do
+ case "$arg" in
+ "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+ set fnord "$@"
+ shift
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift
+ shift
+ ;;
+ esac
+ done
+ "$@" -E |
+ sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
+ echo " " >> "$depfile"
+ . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+none)
+ exec "$@"
+ ;;
+
+*)
+ echo "Unknown depmode $depmode" 1>&2
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/nx-X11/lib/Xft/install-sh b/nx-X11/lib/Xft/install-sh
new file mode 100755
index 000000000..6ce63b9f7
--- /dev/null
+++ b/nx-X11/lib/Xft/install-sh
@@ -0,0 +1,294 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+#
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# 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
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch. It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd=$cpprog
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd=$stripprog
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "$0: no input file specified" >&2
+ exit 1
+else
+ :
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d "$dst" ]; then
+ instcmd=:
+ chmodcmd=""
+ else
+ instcmd=$mkdirprog
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f "$src" ] || [ -d "$src" ]
+ then
+ :
+ else
+ echo "$0: $src does not exist" >&2
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "$0: no destination specified" >&2
+ exit 1
+ else
+ :
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d "$dst" ]
+ then
+ dst=$dst/`basename "$src"`
+ else
+ :
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+ '
+IFS="${IFS-$defaultIFS}"
+
+oIFS=$IFS
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS=$oIFS
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp=$pathcomp$1
+ shift
+
+ if [ ! -d "$pathcomp" ] ;
+ then
+ $mkdirprog "$pathcomp"
+ else
+ :
+ fi
+
+ pathcomp=$pathcomp/
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd "$dst" &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename "$dst"`
+ else
+ dstfile=`basename "$dst" $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename "$dst"`
+ else
+ :
+ fi
+
+# Make a couple of temp file names in the proper directory.
+
+ dsttmp=$dstdir/_inst.$$_
+ rmtmp=$dstdir/_rm.$$_
+
+# Trap to clean up temp files at exit.
+
+ trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
+ trap '(exit $?); exit' 1 2 13 15
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd "$src" "$dsttmp" &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
+
+# Now remove or move aside any old file at destination location. We try this
+# two ways since rm can't unlink itself on some systems and the destination
+# file might be busy for other reasons. In this case, the final cleanup
+# might fail but the new file should still install successfully.
+
+{
+ if [ -f "$dstdir/$dstfile" ]
+ then
+ $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
+ $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
+ {
+ echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
+ (exit 1); exit
+ }
+ else
+ :
+ fi
+} &&
+
+# Now rename the file to the real destination.
+
+ $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+
+fi &&
+
+# The final little trick to "correctly" pass the exit status to the exit trap.
+
+{
+ (exit 0); exit
+}
diff --git a/nx-X11/lib/Xft/ltmain.sh b/nx-X11/lib/Xft/ltmain.sh
new file mode 100644
index 000000000..fe83ff4fb
--- /dev/null
+++ b/nx-X11/lib/Xft/ltmain.sh
@@ -0,0 +1,6290 @@
+# ltmain.sh - Provide generalized library-building support services.
+# NOTE: Changing this file will not affect anything until you rerun configure.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003
+# Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Check that we have a working $echo.
+if test "X$1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+elif test "X$1" = X--fallback-echo; then
+ # Avoid inline document here, it may be left over
+ :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+ # Yippee, $echo works!
+ :
+else
+ # Restart under the correct shell, and then maybe $echo will work.
+ exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+ # used as fallback echo
+ shift
+ cat <<EOF
+$*
+EOF
+ exit 0
+fi
+
+# The name of this program.
+progname=`$echo "$0" | ${SED} 's%^.*/%%'`
+modename="$progname"
+
+# Constants.
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION=1.5
+TIMESTAMP=" (1.1220 2003/04/05 19:32:58)"
+
+default_mode=
+help="Try \`$progname --help' for more information."
+magic="%%%MAGIC variable%%%"
+mkdir="mkdir"
+mv="mv -f"
+rm="rm -f"
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed="${SED}"' -e 1s/^X//'
+sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
+# test EBCDIC or ASCII
+case `echo A|od -x` in
+ *[Cc]1*) # EBCDIC based system
+ SP2NL="tr '\100' '\n'"
+ NL2SP="tr '\r\n' '\100\100'"
+ ;;
+ *) # Assume ASCII based system
+ SP2NL="tr '\040' '\012'"
+ NL2SP="tr '\015\012' '\040\040'"
+ ;;
+esac
+
+# NLS nuisances.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+# We save the old values to restore during execute mode.
+if test "${LC_ALL+set}" = set; then
+ save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
+fi
+if test "${LANG+set}" = set; then
+ save_LANG="$LANG"; LANG=C; export LANG
+fi
+
+# Make sure IFS has a sensible default
+: ${IFS=" "}
+
+if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+ $echo "$modename: not configured to build any kind of library" 1>&2
+ $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
+ exit 1
+fi
+
+# Global variables.
+mode=$default_mode
+nonopt=
+prev=
+prevopt=
+run=
+show="$echo"
+show_help=
+execute_dlfiles=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+
+#####################################
+# Shell function definitions:
+# This seems to be the best place for them
+
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+win32_libid () {
+ win32_libid_type="unknown"
+ win32_fileres=`file -L $1 2>/dev/null`
+ case $win32_fileres in
+ *ar\ archive\ import\ library*) # definitely import
+ win32_libid_type="x86 archive import"
+ ;;
+ *ar\ archive*) # could be an import, or static
+ if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
+ grep -E 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
+ win32_nmres=`eval $NM -f posix -A $1 | \
+ sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
+ if test "X$win32_nmres" = "Ximport" ; then
+ win32_libid_type="x86 archive import"
+ else
+ win32_libid_type="x86 archive static"
+ fi
+ fi
+ ;;
+ *DLL*)
+ win32_libid_type="x86 DLL"
+ ;;
+ *executable*) # but shell scripts are "executable" too...
+ case $win32_fileres in
+ *MS\ Windows\ PE\ Intel*)
+ win32_libid_type="x86 DLL"
+ ;;
+ esac
+ ;;
+ esac
+ $echo $win32_libid_type
+}
+
+# End of Shell function definitions
+#####################################
+
+# Parse our command line options once, thoroughly.
+while test "$#" -gt 0
+do
+ arg="$1"
+ shift
+
+ case $arg in
+ -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
+ esac
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$prev"; then
+ case $prev in
+ execute_dlfiles)
+ execute_dlfiles="$execute_dlfiles $arg"
+ ;;
+ tag)
+ tagname="$arg"
+
+ # Check whether tagname contains only valid characters
+ case $tagname in
+ *[!-_A-Za-z0-9,/]*)
+ $echo "$progname: invalid tag name: $tagname" 1>&2
+ exit 1
+ ;;
+ esac
+
+ case $tagname in
+ CC)
+ # Don't test for the "default" C tag, as we know, it's there, but
+ # not specially marked.
+ ;;
+ *)
+ if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$0" > /dev/null; then
+ taglist="$taglist $tagname"
+ # Evaluate the configuration.
+ eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $0`"
+ else
+ $echo "$progname: ignoring unknown tag $tagname" 1>&2
+ fi
+ ;;
+ esac
+ ;;
+ *)
+ eval "$prev=\$arg"
+ ;;
+ esac
+
+ prev=
+ prevopt=
+ continue
+ fi
+
+ # Have we seen a non-optional argument yet?
+ case $arg in
+ --help)
+ show_help=yes
+ ;;
+
+ --version)
+ $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
+ $echo
+ $echo "Copyright (C) 2003 Free Software Foundation, Inc."
+ $echo "This is free software; see the source for copying conditions. There is NO"
+ $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+ exit 0
+ ;;
+
+ --config)
+ ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0
+ # Now print the configurations for the tags.
+ for tagname in $taglist; do
+ ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$0"
+ done
+ exit 0
+ ;;
+
+ --debug)
+ $echo "$progname: enabling shell trace mode"
+ set -x
+ ;;
+
+ --dry-run | -n)
+ run=:
+ ;;
+
+ --features)
+ $echo "host: $host"
+ if test "$build_libtool_libs" = yes; then
+ $echo "enable shared libraries"
+ else
+ $echo "disable shared libraries"
+ fi
+ if test "$build_old_libs" = yes; then
+ $echo "enable static libraries"
+ else
+ $echo "disable static libraries"
+ fi
+ exit 0
+ ;;
+
+ --finish) mode="finish" ;;
+
+ --mode) prevopt="--mode" prev=mode ;;
+ --mode=*) mode="$optarg" ;;
+
+ --preserve-dup-deps) duplicate_deps="yes" ;;
+
+ --quiet | --silent)
+ show=:
+ ;;
+
+ --tag) prevopt="--tag" prev=tag ;;
+ --tag=*)
+ set tag "$optarg" ${1+"$@"}
+ shift
+ prev=tag
+ ;;
+
+ -dlopen)
+ prevopt="-dlopen"
+ prev=execute_dlfiles
+ ;;
+
+ -*)
+ $echo "$modename: unrecognized option \`$arg'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+
+ *)
+ nonopt="$arg"
+ break
+ ;;
+ esac
+done
+
+if test -n "$prevopt"; then
+ $echo "$modename: option \`$prevopt' requires an argument" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+fi
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end. This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+if test -z "$show_help"; then
+
+ # Infer the operation mode.
+ if test -z "$mode"; then
+ $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
+ $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2
+ case $nonopt in
+ *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
+ mode=link
+ for arg
+ do
+ case $arg in
+ -c)
+ mode=compile
+ break
+ ;;
+ esac
+ done
+ ;;
+ *db | *dbx | *strace | *truss)
+ mode=execute
+ ;;
+ *install*|cp|mv)
+ mode=install
+ ;;
+ *rm)
+ mode=uninstall
+ ;;
+ *)
+ # If we have no mode, but dlfiles were specified, then do execute mode.
+ test -n "$execute_dlfiles" && mode=execute
+
+ # Just use the default operation mode.
+ if test -z "$mode"; then
+ if test -n "$nonopt"; then
+ $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
+ else
+ $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
+ fi
+ fi
+ ;;
+ esac
+ fi
+
+ # Only execute mode is allowed to have -dlopen flags.
+ if test -n "$execute_dlfiles" && test "$mode" != execute; then
+ $echo "$modename: unrecognized option \`-dlopen'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Change the help message to a mode-specific one.
+ generic_help="$help"
+ help="Try \`$modename --help --mode=$mode' for more information."
+
+ # These modes are in order of execution frequency so that they run quickly.
+ case $mode in
+ # libtool compile mode
+ compile)
+ modename="$modename: compile"
+ # Get the compilation command and the source file.
+ base_compile=
+ srcfile="$nonopt" # always keep a non-empty value in "srcfile"
+ suppress_output=
+ arg_mode=normal
+ libobj=
+
+ for arg
+ do
+ case "$arg_mode" in
+ arg )
+ # do not "continue". Instead, add this to base_compile
+ lastarg="$arg"
+ arg_mode=normal
+ ;;
+
+ target )
+ libobj="$arg"
+ arg_mode=normal
+ continue
+ ;;
+
+ normal )
+ # Accept any command-line options.
+ case $arg in
+ -o)
+ if test -n "$libobj" ; then
+ $echo "$modename: you cannot specify \`-o' more than once" 1>&2
+ exit 1
+ fi
+ arg_mode=target
+ continue
+ ;;
+
+ -static)
+ build_old_libs=yes
+ continue
+ ;;
+
+ -prefer-pic)
+ pic_mode=yes
+ continue
+ ;;
+
+ -prefer-non-pic)
+ pic_mode=no
+ continue
+ ;;
+
+ -Xcompiler)
+ arg_mode=arg # the next one goes into the "base_compile" arg list
+ continue # The current "srcfile" will either be retained or
+ ;; # replaced later. I would guess that would be a bug.
+
+ -Wc,*)
+ args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
+ lastarg=
+ save_ifs="$IFS"; IFS=','
+ for arg in $args; do
+ IFS="$save_ifs"
+
+ # Double-quote args containing other shell metacharacters.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ arg="\"$arg\""
+ ;;
+ esac
+ lastarg="$lastarg $arg"
+ done
+ IFS="$save_ifs"
+ lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
+
+ # Add the arguments to base_compile.
+ base_compile="$base_compile $lastarg"
+ continue
+ ;;
+
+ * )
+ # Accept the current argument as the source file.
+ # The previous "srcfile" becomes the current argument.
+ #
+ lastarg="$srcfile"
+ srcfile="$arg"
+ ;;
+ esac # case $arg
+ ;;
+ esac # case $arg_mode
+
+ # Aesthetically quote the previous argument.
+ lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
+
+ case $lastarg in
+ # Double-quote args containing other shell metacharacters.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ lastarg="\"$lastarg\""
+ ;;
+ esac
+
+ base_compile="$base_compile $lastarg"
+ done # for arg
+
+ case $arg_mode in
+ arg)
+ $echo "$modename: you must specify an argument for -Xcompile"
+ exit 1
+ ;;
+ target)
+ $echo "$modename: you must specify a target with \`-o'" 1>&2
+ exit 1
+ ;;
+ *)
+ # Get the name of the library object.
+ [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
+ ;;
+ esac
+
+ # Recognize several different file suffixes.
+ # If the user specifies -o file.o, it is replaced with file.lo
+ xform='[cCFSifmso]'
+ case $libobj in
+ *.ada) xform=ada ;;
+ *.adb) xform=adb ;;
+ *.ads) xform=ads ;;
+ *.asm) xform=asm ;;
+ *.c++) xform=c++ ;;
+ *.cc) xform=cc ;;
+ *.ii) xform=ii ;;
+ *.class) xform=class ;;
+ *.cpp) xform=cpp ;;
+ *.cxx) xform=cxx ;;
+ *.f90) xform=f90 ;;
+ *.for) xform=for ;;
+ *.java) xform=java ;;
+ esac
+
+ libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
+
+ case $libobj in
+ *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
+ *)
+ $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
+ exit 1
+ ;;
+ esac
+
+ # Infer tagged configuration to use if any are available and
+ # if one wasn't chosen via the "--tag" command line option.
+ # Only attempt this if the compiler in the base compile
+ # command doesn't match the default compiler.
+ if test -n "$available_tags" && test -z "$tagname"; then
+ case $base_compile in
+ # Blanks in the command may have been stripped by the calling shell,
+ # but not from the CC environment variable when configure was run.
+ " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "*) ;;
+ # Blanks at the start of $base_compile will cause this to fail
+ # if we don't check for them as well.
+ *)
+ for z in $available_tags; do
+ if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then
+ # Evaluate the configuration.
+ eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`"
+ case "$base_compile " in
+ "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*)
+ # The compiler in the base compile command matches
+ # the one in the tagged configuration.
+ # Assume this is the tagged configuration we want.
+ tagname=$z
+ break
+ ;;
+ esac
+ fi
+ done
+ # If $tagname still isn't set, then no tagged configuration
+ # was found and let the user know that the "--tag" command
+ # line option must be used.
+ if test -z "$tagname"; then
+ $echo "$modename: unable to infer tagged configuration"
+ $echo "$modename: specify a tag with \`--tag'" 1>&2
+ exit 1
+# else
+# $echo "$modename: using $tagname tagged configuration"
+ fi
+ ;;
+ esac
+ fi
+
+ objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+ xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$xdir" = "X$obj"; then
+ xdir=
+ else
+ xdir=$xdir/
+ fi
+ lobj=${xdir}$objdir/$objname
+
+ if test -z "$base_compile"; then
+ $echo "$modename: you must specify a compilation command" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Delete any leftover library objects.
+ if test "$build_old_libs" = yes; then
+ removelist="$obj $lobj $libobj ${libobj}T"
+ else
+ removelist="$lobj $libobj ${libobj}T"
+ fi
+
+ $run $rm $removelist
+ trap "$run $rm $removelist; exit 1" 1 2 15
+
+ # On Cygwin there's no "real" PIC flag so we must build both object types
+ case $host_os in
+ cygwin* | mingw* | pw32* | os2*)
+ pic_mode=default
+ ;;
+ esac
+ if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+ # non-PIC code in shared libraries is not supported
+ pic_mode=default
+ fi
+
+ # Calculate the filename of the output object if compiler does
+ # not support -o with -c
+ if test "$compiler_c_o" = no; then
+ output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
+ lockfile="$output_obj.lock"
+ removelist="$removelist $output_obj $lockfile"
+ trap "$run $rm $removelist; exit 1" 1 2 15
+ else
+ output_obj=
+ need_locks=no
+ lockfile=
+ fi
+
+ # Lock this critical section if it is needed
+ # We use this script file to make the link, it avoids creating a new file
+ if test "$need_locks" = yes; then
+ until $run ln "$0" "$lockfile" 2>/dev/null; do
+ $show "Waiting for $lockfile to be removed"
+ sleep 2
+ done
+ elif test "$need_locks" = warn; then
+ if test -f "$lockfile"; then
+ $echo "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $run $rm $removelist
+ exit 1
+ fi
+ $echo $srcfile > "$lockfile"
+ fi
+
+ if test -n "$fix_srcfile_path"; then
+ eval srcfile=\"$fix_srcfile_path\"
+ fi
+
+ $run $rm "$libobj" "${libobj}T"
+
+ # Create a libtool object file (analogous to a ".la" file),
+ # but don't create it if we're doing a dry run.
+ test -z "$run" && cat > ${libobj}T <<EOF
+# $libobj - a libtool object file
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+EOF
+
+ # Only build a PIC object if we are building libtool libraries.
+ if test "$build_libtool_libs" = yes; then
+ # Without this assignment, base_compile gets emptied.
+ fbsd_hideous_sh_bug=$base_compile
+
+ if test "$pic_mode" != no; then
+ command="$base_compile $srcfile $pic_flag"
+ else
+ # Don't build PIC code
+ command="$base_compile $srcfile"
+ fi
+
+ if test ! -d "${xdir}$objdir"; then
+ $show "$mkdir ${xdir}$objdir"
+ $run $mkdir ${xdir}$objdir
+ status=$?
+ if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
+ exit $status
+ fi
+ fi
+
+ if test -z "$output_obj"; then
+ # Place PIC objects in $objdir
+ command="$command -o $lobj"
+ fi
+
+ $run $rm "$lobj" "$output_obj"
+
+ $show "$command"
+ if $run eval "$command"; then :
+ else
+ test -n "$output_obj" && $run $rm $removelist
+ exit 1
+ fi
+
+ if test "$need_locks" = warn &&
+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+ $echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $run $rm $removelist
+ exit 1
+ fi
+
+ # Just move the object if needed, then go on to compile the next one
+ if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+ $show "$mv $output_obj $lobj"
+ if $run $mv $output_obj $lobj; then :
+ else
+ error=$?
+ $run $rm $removelist
+ exit $error
+ fi
+ fi
+
+ # Append the name of the PIC object to the libtool object file.
+ test -z "$run" && cat >> ${libobj}T <<EOF
+pic_object='$objdir/$objname'
+
+EOF
+
+ # Allow error messages only from the first compilation.
+ suppress_output=' >/dev/null 2>&1'
+ else
+ # No PIC object so indicate it doesn't exist in the libtool
+ # object file.
+ test -z "$run" && cat >> ${libobj}T <<EOF
+pic_object=none
+
+EOF
+ fi
+
+ # Only build a position-dependent object if we build old libraries.
+ if test "$build_old_libs" = yes; then
+ if test "$pic_mode" != yes; then
+ # Don't build PIC code
+ command="$base_compile $srcfile"
+ else
+ command="$base_compile $srcfile $pic_flag"
+ fi
+ if test "$compiler_c_o" = yes; then
+ command="$command -o $obj"
+ fi
+
+ # Suppress compiler output if we already did a PIC compilation.
+ command="$command$suppress_output"
+ $run $rm "$obj" "$output_obj"
+ $show "$command"
+ if $run eval "$command"; then :
+ else
+ $run $rm $removelist
+ exit 1
+ fi
+
+ if test "$need_locks" = warn &&
+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+ $echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $run $rm $removelist
+ exit 1
+ fi
+
+ # Just move the object if needed
+ if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+ $show "$mv $output_obj $obj"
+ if $run $mv $output_obj $obj; then :
+ else
+ error=$?
+ $run $rm $removelist
+ exit $error
+ fi
+ fi
+
+ # Append the name of the non-PIC object the libtool object file.
+ # Only append if the libtool object file exists.
+ test -z "$run" && cat >> ${libobj}T <<EOF
+# Name of the non-PIC object.
+non_pic_object='$objname'
+
+EOF
+ else
+ # Append the name of the non-PIC object the libtool object file.
+ # Only append if the libtool object file exists.
+ test -z "$run" && cat >> ${libobj}T <<EOF
+# Name of the non-PIC object.
+non_pic_object=none
+
+EOF
+ fi
+
+ $run $mv "${libobj}T" "${libobj}"
+
+ # Unlock the critical section if it was locked
+ if test "$need_locks" != no; then
+ $run $rm "$lockfile"
+ fi
+
+ exit 0
+ ;;
+
+ # libtool link mode
+ link | relink)
+ modename="$modename: link"
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ # It is impossible to link a dll without this setting, and
+ # we shouldn't force the makefile maintainer to figure out
+ # which system we are compiling for in order to pass an extra
+ # flag for every libtool invocation.
+ # allow_undefined=no
+
+ # FIXME: Unfortunately, there are problems with the above when trying
+ # to make a dll which has undefined symbols, in which case not
+ # even a static library is built. For now, we need to specify
+ # -no-undefined on the libtool link line when we can be certain
+ # that all symbols are satisfied, otherwise we get a static library.
+ allow_undefined=yes
+ ;;
+ *)
+ allow_undefined=yes
+ ;;
+ esac
+ libtool_args="$nonopt"
+ base_compile="$nonopt"
+ compile_command="$nonopt"
+ finalize_command="$nonopt"
+
+ compile_rpath=
+ finalize_rpath=
+ compile_shlibpath=
+ finalize_shlibpath=
+ convenience=
+ old_convenience=
+ deplibs=
+ old_deplibs=
+ compiler_flags=
+ linker_flags=
+ dllsearchpath=
+ lib_search_path=`pwd`
+ inst_prefix_dir=
+
+ avoid_version=no
+ dlfiles=
+ dlprefiles=
+ dlself=no
+ export_dynamic=no
+ export_symbols=
+ export_symbols_regex=
+ generated=
+ libobjs=
+ ltlibs=
+ module=no
+ no_install=no
+ objs=
+ non_pic_objects=
+ prefer_static_libs=no
+ preload=no
+ prev=
+ prevarg=
+ release=
+ rpath=
+ xrpath=
+ perm_rpath=
+ temp_rpath=
+ thread_safe=no
+ vinfo=
+ vinfo_number=no
+
+ # We need to know -static, to get the right output filenames.
+ for arg
+ do
+ case $arg in
+ -all-static | -static)
+ if test "X$arg" = "X-all-static"; then
+ if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+ $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
+ fi
+ if test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ else
+ if test -z "$pic_flag" && test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ fi
+ build_libtool_libs=no
+ build_old_libs=yes
+ prefer_static_libs=yes
+ break
+ ;;
+ esac
+ done
+
+ # See if our shared archives depend on static archives.
+ test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+ # Go through the arguments, transforming them on the way.
+ while test "$#" -gt 0; do
+ arg="$1"
+ base_compile="$base_compile $arg"
+ shift
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
+ ;;
+ *) qarg=$arg ;;
+ esac
+ libtool_args="$libtool_args $qarg"
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$prev"; then
+ case $prev in
+ output)
+ compile_command="$compile_command @OUTPUT@"
+ finalize_command="$finalize_command @OUTPUT@"
+ ;;
+ esac
+
+ case $prev in
+ dlfiles|dlprefiles)
+ if test "$preload" = no; then
+ # Add the symbol object into the linking commands.
+ compile_command="$compile_command @SYMFILE@"
+ finalize_command="$finalize_command @SYMFILE@"
+ preload=yes
+ fi
+ case $arg in
+ *.la | *.lo) ;; # We handle these cases below.
+ force)
+ if test "$dlself" = no; then
+ dlself=needless
+ export_dynamic=yes
+ fi
+ prev=
+ continue
+ ;;
+ self)
+ if test "$prev" = dlprefiles; then
+ dlself=yes
+ elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+ dlself=yes
+ else
+ dlself=needless
+ export_dynamic=yes
+ fi
+ prev=
+ continue
+ ;;
+ *)
+ if test "$prev" = dlfiles; then
+ dlfiles="$dlfiles $arg"
+ else
+ dlprefiles="$dlprefiles $arg"
+ fi
+ prev=
+ continue
+ ;;
+ esac
+ ;;
+ expsyms)
+ export_symbols="$arg"
+ if test ! -f "$arg"; then
+ $echo "$modename: symbol file \`$arg' does not exist"
+ exit 1
+ fi
+ prev=
+ continue
+ ;;
+ expsyms_regex)
+ export_symbols_regex="$arg"
+ prev=
+ continue
+ ;;
+ inst_prefix)
+ inst_prefix_dir="$arg"
+ prev=
+ continue
+ ;;
+ release)
+ release="-$arg"
+ prev=
+ continue
+ ;;
+ objectlist)
+ if test -f "$arg"; then
+ save_arg=$arg
+ moreargs=
+ for fil in `cat $save_arg`
+ do
+# moreargs="$moreargs $fil"
+ arg=$fil
+ # A libtool-controlled object.
+
+ # Check to see that this really is a libtool object.
+ if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ pic_object=
+ non_pic_object=
+
+ # Read the .lo file
+ # If there is no directory component, then add one.
+ case $arg in
+ */* | *\\*) . $arg ;;
+ *) . ./$arg ;;
+ esac
+
+ if test -z "$pic_object" || \
+ test -z "$non_pic_object" ||
+ test "$pic_object" = none && \
+ test "$non_pic_object" = none; then
+ $echo "$modename: cannot find name of object for \`$arg'" 1>&2
+ exit 1
+ fi
+
+ # Extract subdirectory from the argument.
+ xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$xdir" = "X$arg"; then
+ xdir=
+ else
+ xdir="$xdir/"
+ fi
+
+ if test "$pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ pic_object="$xdir$pic_object"
+
+ if test "$prev" = dlfiles; then
+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+ dlfiles="$dlfiles $pic_object"
+ prev=
+ continue
+ else
+ # If libtool objects are unsupported, then we need to preload.
+ prev=dlprefiles
+ fi
+ fi
+
+ # CHECK ME: I think I busted this. -Ossama
+ if test "$prev" = dlprefiles; then
+ # Preload the old-style object.
+ dlprefiles="$dlprefiles $pic_object"
+ prev=
+ fi
+
+ # A PIC object.
+ libobjs="$libobjs $pic_object"
+ arg="$pic_object"
+ fi
+
+ # Non-PIC object.
+ if test "$non_pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ non_pic_object="$xdir$non_pic_object"
+
+ # A standard non-PIC object
+ non_pic_objects="$non_pic_objects $non_pic_object"
+ if test -z "$pic_object" || test "$pic_object" = none ; then
+ arg="$non_pic_object"
+ fi
+ fi
+ else
+ # Only an error if not doing a dry-run.
+ if test -z "$run"; then
+ $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
+ exit 1
+ else
+ # Dry-run case.
+
+ # Extract subdirectory from the argument.
+ xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$xdir" = "X$arg"; then
+ xdir=
+ else
+ xdir="$xdir/"
+ fi
+
+ pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
+ non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
+ libobjs="$libobjs $pic_object"
+ non_pic_objects="$non_pic_objects $non_pic_object"
+ fi
+ fi
+ done
+ else
+ $echo "$modename: link input file \`$save_arg' does not exist"
+ exit 1
+ fi
+ arg=$save_arg
+ prev=
+ continue
+ ;;
+ rpath | xrpath)
+ # We need an absolute path.
+ case $arg in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ $echo "$modename: only absolute run-paths are allowed" 1>&2
+ exit 1
+ ;;
+ esac
+ if test "$prev" = rpath; then
+ case "$rpath " in
+ *" $arg "*) ;;
+ *) rpath="$rpath $arg" ;;
+ esac
+ else
+ case "$xrpath " in
+ *" $arg "*) ;;
+ *) xrpath="$xrpath $arg" ;;
+ esac
+ fi
+ prev=
+ continue
+ ;;
+ xcompiler)
+ compiler_flags="$compiler_flags $qarg"
+ prev=
+ compile_command="$compile_command $qarg"
+ finalize_command="$finalize_command $qarg"
+ continue
+ ;;
+ xlinker)
+ linker_flags="$linker_flags $qarg"
+ compiler_flags="$compiler_flags $wl$qarg"
+ prev=
+ compile_command="$compile_command $wl$qarg"
+ finalize_command="$finalize_command $wl$qarg"
+ continue
+ ;;
+ xcclinker)
+ linker_flags="$linker_flags $qarg"
+ compiler_flags="$compiler_flags $qarg"
+ prev=
+ compile_command="$compile_command $qarg"
+ finalize_command="$finalize_command $qarg"
+ continue
+ ;;
+ *)
+ eval "$prev=\"\$arg\""
+ prev=
+ continue
+ ;;
+ esac
+ fi # test -n "$prev"
+
+ prevarg="$arg"
+
+ case $arg in
+ -all-static)
+ if test -n "$link_static_flag"; then
+ compile_command="$compile_command $link_static_flag"
+ finalize_command="$finalize_command $link_static_flag"
+ fi
+ continue
+ ;;
+
+ -allow-undefined)
+ # FIXME: remove this flag sometime in the future.
+ $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
+ continue
+ ;;
+
+ -avoid-version)
+ avoid_version=yes
+ continue
+ ;;
+
+ -dlopen)
+ prev=dlfiles
+ continue
+ ;;
+
+ -dlpreopen)
+ prev=dlprefiles
+ continue
+ ;;
+
+ -export-dynamic)
+ export_dynamic=yes
+ continue
+ ;;
+
+ -export-symbols | -export-symbols-regex)
+ if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+ $echo "$modename: more than one -exported-symbols argument is not allowed"
+ exit 1
+ fi
+ if test "X$arg" = "X-export-symbols"; then
+ prev=expsyms
+ else
+ prev=expsyms_regex
+ fi
+ continue
+ ;;
+
+ -inst-prefix-dir)
+ prev=inst_prefix
+ continue
+ ;;
+
+ # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+ # so, if we see these flags be careful not to treat them like -L
+ -L[A-Z][A-Z]*:*)
+ case $with_gcc/$host in
+ no/*-*-irix* | /*-*-irix*)
+ compile_command="$compile_command $arg"
+ finalize_command="$finalize_command $arg"
+ ;;
+ esac
+ continue
+ ;;
+
+ -L*)
+ dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ absdir=`cd "$dir" && pwd`
+ if test -z "$absdir"; then
+ $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
+ exit 1
+ fi
+ dir="$absdir"
+ ;;
+ esac
+ case "$deplibs " in
+ *" -L$dir "*) ;;
+ *)
+ deplibs="$deplibs -L$dir"
+ lib_search_path="$lib_search_path $dir"
+ ;;
+ esac
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ case :$dllsearchpath: in
+ *":$dir:"*) ;;
+ *) dllsearchpath="$dllsearchpath:$dir";;
+ esac
+ ;;
+ esac
+ continue
+ ;;
+
+ -l*)
+ if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+ case $host in
+ *-*-cygwin* | *-*-pw32* | *-*-beos*)
+ # These systems don't actually have a C or math library (as such)
+ continue
+ ;;
+ *-*-mingw* | *-*-os2*)
+ # These systems don't actually have a C library (as such)
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-openbsd* | *-*-freebsd*)
+ # Do not include libc due to us having libc/libc_r.
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # Rhapsody C and math libraries are in the System framework
+ deplibs="$deplibs -framework System"
+ continue
+ esac
+ elif test "X$arg" = "X-lc_r"; then
+ case $host in
+ *-*-openbsd* | *-*-freebsd*)
+ # Do not include libc_r directly, use -pthread flag.
+ continue
+ ;;
+ esac
+ fi
+ deplibs="$deplibs $arg"
+ continue
+ ;;
+
+ -module)
+ module=yes
+ continue
+ ;;
+
+ # gcc -m* arguments should be passed to the linker via $compiler_flags
+ # in order to pass architecture information to the linker
+ # (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo
+ # but this is not reliable with gcc because gcc may use -mfoo to
+ # select a different linker, different libraries, etc, while
+ # -Wl,-mfoo simply passes -mfoo to the linker.
+ -m*)
+ # Unknown arguments in both finalize_command and compile_command need
+ # to be aesthetically quoted because they are evaled later.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ arg="\"$arg\""
+ ;;
+ esac
+ compile_command="$compile_command $arg"
+ finalize_command="$finalize_command $arg"
+ if test "$with_gcc" = "yes" ; then
+ compiler_flags="$compiler_flags $arg"
+ fi
+ continue
+ ;;
+
+ -shrext)
+ prev=shrext
+ continue
+ ;;
+
+ -no-fast-install)
+ fast_install=no
+ continue
+ ;;
+
+ -no-install)
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ # The PATH hackery in wrapper scripts is required on Windows
+ # in order for the loader to find any dlls it needs.
+ $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
+ $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
+ fast_install=no
+ ;;
+ *) no_install=yes ;;
+ esac
+ continue
+ ;;
+
+ -no-undefined)
+ allow_undefined=no
+ continue
+ ;;
+
+ -objectlist)
+ prev=objectlist
+ continue
+ ;;
+
+ -o) prev=output ;;
+
+ -release)
+ prev=release
+ continue
+ ;;
+
+ -rpath)
+ prev=rpath
+ continue
+ ;;
+
+ -R)
+ prev=xrpath
+ continue
+ ;;
+
+ -R*)
+ dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ $echo "$modename: only absolute run-paths are allowed" 1>&2
+ exit 1
+ ;;
+ esac
+ case "$xrpath " in
+ *" $dir "*) ;;
+ *) xrpath="$xrpath $dir" ;;
+ esac
+ continue
+ ;;
+
+ -static)
+ # The effects of -static are defined in a previous loop.
+ # We used to do the same as -all-static on platforms that
+ # didn't have a PIC flag, but the assumption that the effects
+ # would be equivalent was wrong. It would break on at least
+ # Digital Unix and AIX.
+ continue
+ ;;
+
+ -thread-safe)
+ thread_safe=yes
+ continue
+ ;;
+
+ -version-info)
+ prev=vinfo
+ continue
+ ;;
+ -version-number)
+ prev=vinfo
+ vinfo_number=yes
+ continue
+ ;;
+
+ -Wc,*)
+ args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
+ arg=
+ save_ifs="$IFS"; IFS=','
+ for flag in $args; do
+ IFS="$save_ifs"
+ case $flag in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ flag="\"$flag\""
+ ;;
+ esac
+ arg="$arg $wl$flag"
+ compiler_flags="$compiler_flags $flag"
+ done
+ IFS="$save_ifs"
+ arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
+ ;;
+
+ -Wl,*)
+ args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
+ arg=
+ save_ifs="$IFS"; IFS=','
+ for flag in $args; do
+ IFS="$save_ifs"
+ case $flag in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ flag="\"$flag\""
+ ;;
+ esac
+ arg="$arg $wl$flag"
+ compiler_flags="$compiler_flags $wl$flag"
+ linker_flags="$linker_flags $flag"
+ done
+ IFS="$save_ifs"
+ arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
+ ;;
+
+ -Xcompiler)
+ prev=xcompiler
+ continue
+ ;;
+
+ -Xlinker)
+ prev=xlinker
+ continue
+ ;;
+
+ -XCClinker)
+ prev=xcclinker
+ continue
+ ;;
+
+ # Some other compiler flag.
+ -* | +*)
+ # Unknown arguments in both finalize_command and compile_command need
+ # to be aesthetically quoted because they are evaled later.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ arg="\"$arg\""
+ ;;
+ esac
+ ;;
+
+ *.$objext)
+ # A standard object.
+ objs="$objs $arg"
+ ;;
+
+ *.lo)
+ # A libtool-controlled object.
+
+ # Check to see that this really is a libtool object.
+ if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ pic_object=
+ non_pic_object=
+
+ # Read the .lo file
+ # If there is no directory component, then add one.
+ case $arg in
+ */* | *\\*) . $arg ;;
+ *) . ./$arg ;;
+ esac
+
+ if test -z "$pic_object" || \
+ test -z "$non_pic_object" ||
+ test "$pic_object" = none && \
+ test "$non_pic_object" = none; then
+ $echo "$modename: cannot find name of object for \`$arg'" 1>&2
+ exit 1
+ fi
+
+ # Extract subdirectory from the argument.
+ xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$xdir" = "X$arg"; then
+ xdir=
+ else
+ xdir="$xdir/"
+ fi
+
+ if test "$pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ pic_object="$xdir$pic_object"
+
+ if test "$prev" = dlfiles; then
+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+ dlfiles="$dlfiles $pic_object"
+ prev=
+ continue
+ else
+ # If libtool objects are unsupported, then we need to preload.
+ prev=dlprefiles
+ fi
+ fi
+
+ # CHECK ME: I think I busted this. -Ossama
+ if test "$prev" = dlprefiles; then
+ # Preload the old-style object.
+ dlprefiles="$dlprefiles $pic_object"
+ prev=
+ fi
+
+ # A PIC object.
+ libobjs="$libobjs $pic_object"
+ arg="$pic_object"
+ fi
+
+ # Non-PIC object.
+ if test "$non_pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ non_pic_object="$xdir$non_pic_object"
+
+ # A standard non-PIC object
+ non_pic_objects="$non_pic_objects $non_pic_object"
+ if test -z "$pic_object" || test "$pic_object" = none ; then
+ arg="$non_pic_object"
+ fi
+ fi
+ else
+ # Only an error if not doing a dry-run.
+ if test -z "$run"; then
+ $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
+ exit 1
+ else
+ # Dry-run case.
+
+ # Extract subdirectory from the argument.
+ xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$xdir" = "X$arg"; then
+ xdir=
+ else
+ xdir="$xdir/"
+ fi
+
+ pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
+ non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
+ libobjs="$libobjs $pic_object"
+ non_pic_objects="$non_pic_objects $non_pic_object"
+ fi
+ fi
+ ;;
+
+ *.$libext)
+ # An archive.
+ deplibs="$deplibs $arg"
+ old_deplibs="$old_deplibs $arg"
+ continue
+ ;;
+
+ *.la)
+ # A libtool-controlled library.
+
+ if test "$prev" = dlfiles; then
+ # This library was specified with -dlopen.
+ dlfiles="$dlfiles $arg"
+ prev=
+ elif test "$prev" = dlprefiles; then
+ # The library was specified with -dlpreopen.
+ dlprefiles="$dlprefiles $arg"
+ prev=
+ else
+ deplibs="$deplibs $arg"
+ fi
+ continue
+ ;;
+
+ # Some other compiler argument.
+ *)
+ # Unknown arguments in both finalize_command and compile_command need
+ # to be aesthetically quoted because they are evaled later.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ arg="\"$arg\""
+ ;;
+ esac
+ ;;
+ esac # arg
+
+ # Now actually substitute the argument into the commands.
+ if test -n "$arg"; then
+ compile_command="$compile_command $arg"
+ finalize_command="$finalize_command $arg"
+ fi
+ done # argument parsing loop
+
+ if test -n "$prev"; then
+ $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Infer tagged configuration to use if any are available and
+ # if one wasn't chosen via the "--tag" command line option.
+ # Only attempt this if the compiler in the base link
+ # command doesn't match the default compiler.
+ if test -n "$available_tags" && test -z "$tagname"; then
+ case $base_compile in
+ # Blanks in the command may have been stripped by the calling shell,
+ # but not from the CC environment variable when configure was run.
+ "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*) ;;
+ # Blanks at the start of $base_compile will cause this to fail
+ # if we don't check for them as well.
+ *)
+ for z in $available_tags; do
+ if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then
+ # Evaluate the configuration.
+ eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`"
+ case $base_compile in
+ "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*)
+ # The compiler in $compile_command matches
+ # the one in the tagged configuration.
+ # Assume this is the tagged configuration we want.
+ tagname=$z
+ break
+ ;;
+ esac
+ fi
+ done
+ # If $tagname still isn't set, then no tagged configuration
+ # was found and let the user know that the "--tag" command
+ # line option must be used.
+ if test -z "$tagname"; then
+ $echo "$modename: unable to infer tagged configuration"
+ $echo "$modename: specify a tag with \`--tag'" 1>&2
+ exit 1
+# else
+# $echo "$modename: using $tagname tagged configuration"
+ fi
+ ;;
+ esac
+ fi
+
+ if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+ eval arg=\"$export_dynamic_flag_spec\"
+ compile_command="$compile_command $arg"
+ finalize_command="$finalize_command $arg"
+ fi
+
+ oldlibs=
+ # calculate the name of the file, without its directory
+ outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
+ libobjs_save="$libobjs"
+
+ if test -n "$shlibpath_var"; then
+ # get the directories listed in $shlibpath_var
+ eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+ else
+ shlib_search_path=
+ fi
+ eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+ eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+ output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$output_objdir" = "X$output"; then
+ output_objdir="$objdir"
+ else
+ output_objdir="$output_objdir/$objdir"
+ fi
+ # Create the object directory.
+ if test ! -d "$output_objdir"; then
+ $show "$mkdir $output_objdir"
+ $run $mkdir $output_objdir
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$output_objdir"; then
+ exit $status
+ fi
+ fi
+
+ # Determine the type of output
+ case $output in
+ "")
+ $echo "$modename: you must specify an output file" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+ *.$libext) linkmode=oldlib ;;
+ *.lo | *.$objext) linkmode=obj ;;
+ *.la) linkmode=lib ;;
+ *) linkmode=prog ;; # Anything else should be a program.
+ esac
+
+ case $host in
+ *cygwin* | *mingw* | *pw32*)
+ # don't eliminate duplcations in $postdeps and $predeps
+ duplicate_compiler_generated_deps=yes
+ ;;
+ *)
+ duplicate_compiler_generated_deps=$duplicate_deps
+ ;;
+ esac
+ specialdeplibs=
+
+ libs=
+ # Find all interdependent deplibs by searching for libraries
+ # that are linked more than once (e.g. -la -lb -la)
+ for deplib in $deplibs; do
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ libs="$libs $deplib"
+ done
+
+ if test "$linkmode" = lib; then
+ libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+ # Compute libraries that are listed more than once in $predeps
+ # $postdeps and mark them as special (i.e., whose duplicates are
+ # not to be eliminated).
+ pre_post_deps=
+ if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
+ for pre_post_dep in $predeps $postdeps; do
+ case "$pre_post_deps " in
+ *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+ esac
+ pre_post_deps="$pre_post_deps $pre_post_dep"
+ done
+ fi
+ pre_post_deps=
+ fi
+
+ deplibs=
+ newdependency_libs=
+ newlib_search_path=
+ need_relink=no # whether we're linking any uninstalled libtool libraries
+ notinst_deplibs= # not-installed libtool libraries
+ notinst_path= # paths that contain not-installed libtool libraries
+ case $linkmode in
+ lib)
+ passes="conv link"
+ for file in $dlfiles $dlprefiles; do
+ case $file in
+ *.la) ;;
+ *)
+ $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
+ exit 1
+ ;;
+ esac
+ done
+ ;;
+ prog)
+ compile_deplibs=
+ finalize_deplibs=
+ alldeplibs=no
+ newdlfiles=
+ newdlprefiles=
+ passes="conv scan dlopen dlpreopen link"
+ ;;
+ *) passes="conv"
+ ;;
+ esac
+ for pass in $passes; do
+ if test "$linkmode,$pass" = "lib,link" ||
+ test "$linkmode,$pass" = "prog,scan"; then
+ libs="$deplibs"
+ deplibs=
+ fi
+ if test "$linkmode" = prog; then
+ case $pass in
+ dlopen) libs="$dlfiles" ;;
+ dlpreopen) libs="$dlprefiles" ;;
+ link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+ esac
+ fi
+ if test "$pass" = dlopen; then
+ # Collect dlpreopened libraries
+ save_deplibs="$deplibs"
+ deplibs=
+ fi
+ for deplib in $libs; do
+ lib=
+ found=no
+ case $deplib in
+ -l*)
+ if test "$linkmode" != lib && test "$linkmode" != prog; then
+ $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
+ continue
+ fi
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
+ for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ # Search the libtool library
+ lib="$searchdir/lib${name}.la"
+ if test -f "$lib"; then
+ found=yes
+ break
+ fi
+ done
+ if test "$found" != yes; then
+ # deplib doesn't seem to be a libtool library
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+ fi
+ continue
+ else # deplib is a libtool library
+ # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+ # We need to do some special things here, and not later.
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $deplib "*)
+ if (${SED} -e '2q' $lib |
+ grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ library_names=
+ old_library=
+ case $lib in
+ */* | *\\*) . $lib ;;
+ *) . ./$lib ;;
+ esac
+ for l in $old_library $library_names; do
+ ll="$l"
+ done
+ if test "X$ll" = "X$old_library" ; then # only static version available
+ found=no
+ ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$ladir" = "X$lib" && ladir="."
+ lib=$ladir/$old_library
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+ fi
+ continue
+ fi
+ fi
+ ;;
+ *) ;;
+ esac
+ fi
+ fi
+ ;; # -l
+ -L*)
+ case $linkmode in
+ lib)
+ deplibs="$deplib $deplibs"
+ test "$pass" = conv && continue
+ newdependency_libs="$deplib $newdependency_libs"
+ newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+ ;;
+ prog)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ if test "$pass" = scan; then
+ deplibs="$deplib $deplibs"
+ newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+ else
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ fi
+ ;;
+ *)
+ $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
+ ;;
+ esac # linkmode
+ continue
+ ;; # -L
+ -R*)
+ if test "$pass" = link; then
+ dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
+ # Make sure the xrpath contains only unique directories.
+ case "$xrpath " in
+ *" $dir "*) ;;
+ *) xrpath="$xrpath $dir" ;;
+ esac
+ fi
+ deplibs="$deplib $deplibs"
+ continue
+ ;;
+ *.la) lib="$deplib" ;;
+ *.$libext)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ case $linkmode in
+ lib)
+ if test "$deplibs_check_method" != pass_all; then
+ $echo
+ $echo "*** Warning: Trying to link with static lib archive $deplib."
+ $echo "*** I have the capability to make that library automatically link in when"
+ $echo "*** you link to this library. But I can only do this if you have a"
+ $echo "*** shared version of the library, which you do not appear to have"
+ $echo "*** because the file extensions .$libext of this argument makes me believe"
+ $echo "*** that it is just a static archive that I should not used here."
+ else
+ $echo
+ $echo "*** Warning: Linking the shared library $output against the"
+ $echo "*** static library $deplib is not portable!"
+ deplibs="$deplib $deplibs"
+ fi
+ continue
+ ;;
+ prog)
+ if test "$pass" != link; then
+ deplibs="$deplib $deplibs"
+ else
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ fi
+ continue
+ ;;
+ esac # linkmode
+ ;; # *.$libext
+ *.lo | *.$objext)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ elif test "$linkmode" = prog; then
+ if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+ # If there is no dlopen support or we're linking statically,
+ # we need to preload.
+ newdlprefiles="$newdlprefiles $deplib"
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ newdlfiles="$newdlfiles $deplib"
+ fi
+ fi
+ continue
+ ;;
+ %DEPLIBS%)
+ alldeplibs=yes
+ continue
+ ;;
+ esac # case $deplib
+ if test "$found" = yes || test -f "$lib"; then :
+ else
+ $echo "$modename: cannot find the library \`$lib'" 1>&2
+ exit 1
+ fi
+
+ # Check to see that this really is a libtool archive.
+ if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+ else
+ $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+ exit 1
+ fi
+
+ ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$ladir" = "X$lib" && ladir="."
+
+ dlname=
+ dlopen=
+ dlpreopen=
+ libdir=
+ library_names=
+ old_library=
+ # If the library was installed with an old release of libtool,
+ # it will not redefine variables installed, or shouldnotlink
+ installed=yes
+ shouldnotlink=no
+
+ # Read the .la file
+ case $lib in
+ */* | *\\*) . $lib ;;
+ *) . ./$lib ;;
+ esac
+
+ if test "$linkmode,$pass" = "lib,link" ||
+ test "$linkmode,$pass" = "prog,scan" ||
+ { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+ test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
+ test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
+ fi
+
+ if test "$pass" = conv; then
+ # Only check for convenience libraries
+ deplibs="$lib $deplibs"
+ if test -z "$libdir"; then
+ if test -z "$old_library"; then
+ $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
+ exit 1
+ fi
+ # It is a libtool convenience library, so add in its objects.
+ convenience="$convenience $ladir/$objdir/$old_library"
+ old_convenience="$old_convenience $ladir/$objdir/$old_library"
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ deplibs="$deplib $deplibs"
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ tmp_libs="$tmp_libs $deplib"
+ done
+ elif test "$linkmode" != prog && test "$linkmode" != lib; then
+ $echo "$modename: \`$lib' is not a convenience library" 1>&2
+ exit 1
+ fi
+ continue
+ fi # $pass = conv
+
+
+ # Get the name of the library we link against.
+ linklib=
+ for l in $old_library $library_names; do
+ linklib="$l"
+ done
+ if test -z "$linklib"; then
+ $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
+ exit 1
+ fi
+
+ # This library was specified with -dlopen.
+ if test "$pass" = dlopen; then
+ if test -z "$libdir"; then
+ $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
+ exit 1
+ fi
+ if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+ # If there is no dlname, no dlopen support or we're linking
+ # statically, we need to preload. We also need to preload any
+ # dependent libraries so libltdl's deplib preloader doesn't
+ # bomb out in the load deplibs phase.
+ dlprefiles="$dlprefiles $lib $dependency_libs"
+ else
+ newdlfiles="$newdlfiles $lib"
+ fi
+ continue
+ fi # $pass = dlopen
+
+ # We need an absolute path.
+ case $ladir in
+ [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+ *)
+ abs_ladir=`cd "$ladir" && pwd`
+ if test -z "$abs_ladir"; then
+ $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
+ $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
+ abs_ladir="$ladir"
+ fi
+ ;;
+ esac
+ laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+
+ # Find the relevant object directory and library name.
+ if test "X$installed" = Xyes; then
+ if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+ $echo "$modename: warning: library \`$lib' was moved." 1>&2
+ dir="$ladir"
+ absdir="$abs_ladir"
+ libdir="$abs_ladir"
+ else
+ dir="$libdir"
+ absdir="$libdir"
+ fi
+ else
+ dir="$ladir/$objdir"
+ absdir="$abs_ladir/$objdir"
+ # Remove this search path later
+ notinst_path="$notinst_path $abs_ladir"
+ fi # $installed = yes
+ name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+
+ # This library was specified with -dlpreopen.
+ if test "$pass" = dlpreopen; then
+ if test -z "$libdir"; then
+ $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
+ exit 1
+ fi
+ # Prefer using a static library (so that no silly _DYNAMIC symbols
+ # are required to link).
+ if test -n "$old_library"; then
+ newdlprefiles="$newdlprefiles $dir/$old_library"
+ # Otherwise, use the dlname, so that lt_dlopen finds it.
+ elif test -n "$dlname"; then
+ newdlprefiles="$newdlprefiles $dir/$dlname"
+ else
+ newdlprefiles="$newdlprefiles $dir/$linklib"
+ fi
+ fi # $pass = dlpreopen
+
+ if test -z "$libdir"; then
+ # Link the convenience library
+ if test "$linkmode" = lib; then
+ deplibs="$dir/$old_library $deplibs"
+ elif test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$dir/$old_library $compile_deplibs"
+ finalize_deplibs="$dir/$old_library $finalize_deplibs"
+ else
+ deplibs="$lib $deplibs" # used for prog,scan pass
+ fi
+ continue
+ fi
+
+
+ if test "$linkmode" = prog && test "$pass" != link; then
+ newlib_search_path="$newlib_search_path $ladir"
+ deplibs="$lib $deplibs"
+
+ linkalldeplibs=no
+ if test "$link_all_deplibs" != no || test -z "$library_names" ||
+ test "$build_libtool_libs" = no; then
+ linkalldeplibs=yes
+ fi
+
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ case $deplib in
+ -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
+ esac
+ # Need to link against all dependency_libs?
+ if test "$linkalldeplibs" = yes; then
+ deplibs="$deplib $deplibs"
+ else
+ # Need to hardcode shared library paths
+ # or/and link against static libraries
+ newdependency_libs="$deplib $newdependency_libs"
+ fi
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ tmp_libs="$tmp_libs $deplib"
+ done # for deplib
+ continue
+ fi # $linkmode = prog...
+
+ if test "$linkmode,$pass" = "prog,link"; then
+ if test -n "$library_names" &&
+ { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+ # We need to hardcode the library path
+ if test -n "$shlibpath_var"; then
+ # Make sure the rpath contains only unique directories.
+ case "$temp_rpath " in
+ *" $dir "*) ;;
+ *" $absdir "*) ;;
+ *) temp_rpath="$temp_rpath $dir" ;;
+ esac
+ fi
+
+ # Hardcode the library path.
+ # Skip directories that are in the system default run-time
+ # search path.
+ case " $sys_lib_dlsearch_path " in
+ *" $absdir "*) ;;
+ *)
+ case "$compile_rpath " in
+ *" $absdir "*) ;;
+ *) compile_rpath="$compile_rpath $absdir"
+ esac
+ ;;
+ esac
+ case " $sys_lib_dlsearch_path " in
+ *" $libdir "*) ;;
+ *)
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir"
+ esac
+ ;;
+ esac
+ fi # $linkmode,$pass = prog,link...
+
+ if test "$alldeplibs" = yes &&
+ { test "$deplibs_check_method" = pass_all ||
+ { test "$build_libtool_libs" = yes &&
+ test -n "$library_names"; }; }; then
+ # We only need to search for static libraries
+ continue
+ fi
+ fi
+
+ link_static=no # Whether the deplib will be linked statically
+ if test -n "$library_names" &&
+ { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+ if test "$installed" = no; then
+ notinst_deplibs="$notinst_deplibs $lib"
+ need_relink=yes
+ fi
+ # This is a shared library
+
+ # Warn about portability, can't link against -module's on some systems (darwin)
+ if test "$shouldnotlink" = yes && test "$pass" = link ; then
+ $echo
+ if test "$linkmode" = prog; then
+ $echo "*** Warning: Linking the executable $output against the loadable module"
+ else
+ $echo "*** Warning: Linking the shared library $output against the loadable module"
+ fi
+ $echo "*** $linklib is not portable!"
+ fi
+ if test "$linkmode" = lib &&
+ test "$hardcode_into_libs" = yes; then
+ # Hardcode the library path.
+ # Skip directories that are in the system default run-time
+ # search path.
+ case " $sys_lib_dlsearch_path " in
+ *" $absdir "*) ;;
+ *)
+ case "$compile_rpath " in
+ *" $absdir "*) ;;
+ *) compile_rpath="$compile_rpath $absdir"
+ esac
+ ;;
+ esac
+ case " $sys_lib_dlsearch_path " in
+ *" $libdir "*) ;;
+ *)
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir"
+ esac
+ ;;
+ esac
+ fi
+
+ if test -n "$old_archive_from_expsyms_cmds"; then
+ # figure out the soname
+ set dummy $library_names
+ realname="$2"
+ shift; shift
+ libname=`eval \\$echo \"$libname_spec\"`
+ # use dlname if we got it. it's perfectly good, no?
+ if test -n "$dlname"; then
+ soname="$dlname"
+ elif test -n "$soname_spec"; then
+ # bleh windows
+ case $host in
+ *cygwin* | mingw*)
+ major=`expr $current - $age`
+ versuffix="-$major"
+ ;;
+ esac
+ eval soname=\"$soname_spec\"
+ else
+ soname="$realname"
+ fi
+
+ # Make a new name for the extract_expsyms_cmds to use
+ soroot="$soname"
+ soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
+ newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
+
+ # If the library has no export list, then create one now
+ if test -f "$output_objdir/$soname-def"; then :
+ else
+ $show "extracting exported symbol list from \`$soname'"
+ save_ifs="$IFS"; IFS='~'
+ eval cmds=\"$extract_expsyms_cmds\"
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ fi
+
+ # Create $newlib
+ if test -f "$output_objdir/$newlib"; then :; else
+ $show "generating import library for \`$soname'"
+ save_ifs="$IFS"; IFS='~'
+ eval cmds=\"$old_archive_from_expsyms_cmds\"
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ fi
+ # make sure the library variables are pointing to the new library
+ dir=$output_objdir
+ linklib=$newlib
+ fi # test -n "$old_archive_from_expsyms_cmds"
+
+ if test "$linkmode" = prog || test "$mode" != relink; then
+ add_shlibpath=
+ add_dir=
+ add=
+ lib_linked=yes
+ case $hardcode_action in
+ immediate | unsupported)
+ if test "$hardcode_direct" = no; then
+ add="$dir/$linklib"
+ case $host in
+ *-*-sco3.2v5* ) add_dir="-L$dir" ;;
+ *-*-darwin* )
+ # if the lib is a module then we can not link against it, someone
+ # is ignoring the new warnings I added
+ if /usr/bin/file -L $add 2> /dev/null | grep "bundle" >/dev/null ; then
+ $echo "** Warning, lib $linklib is a module, not a shared library"
+ if test -z "$old_library" ; then
+ $echo
+ $echo "** And there doesn't seem to be a static archive available"
+ $echo "** The link will probably fail, sorry"
+ else
+ add="$dir/$old_library"
+ fi
+ fi
+ esac
+ elif test "$hardcode_minus_L" = no; then
+ case $host in
+ *-*-sunos*) add_shlibpath="$dir" ;;
+ esac
+ add_dir="-L$dir"
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = no; then
+ add_shlibpath="$dir"
+ add="-l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+ relink)
+ if test "$hardcode_direct" = yes; then
+ add="$dir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ add_dir="-L$dir"
+ # Try looking first in the location we're being installed to.
+ if test -n "$inst_prefix_dir"; then
+ case "$libdir" in
+ [\\/]*)
+ add_dir="-L$inst_prefix_dir$libdir $add_dir"
+ ;;
+ esac
+ fi
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ add_shlibpath="$dir"
+ add="-l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+ *) lib_linked=no ;;
+ esac
+
+ if test "$lib_linked" != yes; then
+ $echo "$modename: configuration error: unsupported hardcode properties"
+ exit 1
+ fi
+
+ if test -n "$add_shlibpath"; then
+ case :$compile_shlibpath: in
+ *":$add_shlibpath:"*) ;;
+ *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
+ esac
+ fi
+ if test "$linkmode" = prog; then
+ test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+ test -n "$add" && compile_deplibs="$add $compile_deplibs"
+ else
+ test -n "$add_dir" && deplibs="$add_dir $deplibs"
+ test -n "$add" && deplibs="$add $deplibs"
+ if test "$hardcode_direct" != yes && \
+ test "$hardcode_minus_L" != yes && \
+ test "$hardcode_shlibpath_var" = yes; then
+ case :$finalize_shlibpath: in
+ *":$libdir:"*) ;;
+ *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+ esac
+ fi
+ fi
+ fi
+
+ if test "$linkmode" = prog || test "$mode" = relink; then
+ add_shlibpath=
+ add_dir=
+ add=
+ # Finalize command for both is simple: just hardcode it.
+ if test "$hardcode_direct" = yes; then
+ add="$libdir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ add_dir="-L$libdir"
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ case :$finalize_shlibpath: in
+ *":$libdir:"*) ;;
+ *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+ esac
+ add="-l$name"
+ elif test "$hardcode_automatic" = yes; then
+ if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then
+ add="$inst_prefix_dir$libdir/$linklib"
+ else
+ add="$libdir/$linklib"
+ fi
+ else
+ # We cannot seem to hardcode it, guess we'll fake it.
+ add_dir="-L$libdir"
+ # Try looking first in the location we're being installed to.
+ if test -n "$inst_prefix_dir"; then
+ case "$libdir" in
+ [\\/]*)
+ add_dir="-L$inst_prefix_dir$libdir $add_dir"
+ ;;
+ esac
+ fi
+ add="-l$name"
+ fi
+
+ if test "$linkmode" = prog; then
+ test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+ test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+ else
+ test -n "$add_dir" && deplibs="$add_dir $deplibs"
+ test -n "$add" && deplibs="$add $deplibs"
+ fi
+ fi
+ elif test "$linkmode" = prog; then
+ # Here we assume that one of hardcode_direct or hardcode_minus_L
+ # is not unsupported. This is valid on all known static and
+ # shared platforms.
+ if test "$hardcode_direct" != unsupported; then
+ test -n "$old_library" && linklib="$old_library"
+ compile_deplibs="$dir/$linklib $compile_deplibs"
+ finalize_deplibs="$dir/$linklib $finalize_deplibs"
+ else
+ compile_deplibs="-l$name -L$dir $compile_deplibs"
+ finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+ fi
+ elif test "$build_libtool_libs" = yes; then
+ # Not a shared library
+ if test "$deplibs_check_method" != pass_all; then
+ # We're trying link a shared library against a static one
+ # but the system doesn't support it.
+
+ # Just print a warning and add the library to dependency_libs so
+ # that the program can be linked against the static library.
+ $echo
+ $echo "*** Warning: This system can not link to static lib archive $lib."
+ $echo "*** I have the capability to make that library automatically link in when"
+ $echo "*** you link to this library. But I can only do this if you have a"
+ $echo "*** shared version of the library, which you do not appear to have."
+ if test "$module" = yes; then
+ $echo "*** But as you try to build a module library, libtool will still create "
+ $echo "*** a static module, that should work as long as the dlopening application"
+ $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
+ if test -z "$global_symbol_pipe"; then
+ $echo
+ $echo "*** However, this would only work if libtool was able to extract symbol"
+ $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ $echo "*** not find such a program. So, this module is probably useless."
+ $echo "*** \`nm' from GNU binutils and a full rebuild may help."
+ fi
+ if test "$build_old_libs" = no; then
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ fi
+ else
+ convenience="$convenience $dir/$old_library"
+ old_convenience="$old_convenience $dir/$old_library"
+ deplibs="$dir/$old_library $deplibs"
+ link_static=yes
+ fi
+ fi # link shared/static library?
+
+ if test "$linkmode" = lib; then
+ if test -n "$dependency_libs" &&
+ { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes ||
+ test "$link_static" = yes; }; then
+ # Extract -R from dependency_libs
+ temp_deplibs=
+ for libdir in $dependency_libs; do
+ case $libdir in
+ -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
+ case " $xrpath " in
+ *" $temp_xrpath "*) ;;
+ *) xrpath="$xrpath $temp_xrpath";;
+ esac;;
+ *) temp_deplibs="$temp_deplibs $libdir";;
+ esac
+ done
+ dependency_libs="$temp_deplibs"
+ fi
+
+ newlib_search_path="$newlib_search_path $absdir"
+ # Link against this library
+ test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+ # ... and its dependency_libs
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ newdependency_libs="$deplib $newdependency_libs"
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ tmp_libs="$tmp_libs $deplib"
+ done
+
+ if test "$link_all_deplibs" != no; then
+ # Add the search paths of all dependency libraries
+ for deplib in $dependency_libs; do
+ case $deplib in
+ -L*) path="$deplib" ;;
+ *.la)
+ dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$dir" = "X$deplib" && dir="."
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+ *)
+ absdir=`cd "$dir" && pwd`
+ if test -z "$absdir"; then
+ $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
+ absdir="$dir"
+ fi
+ ;;
+ esac
+ if grep "^installed=no" $deplib > /dev/null; then
+ path="$absdir/$objdir"
+ else
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+ if test -z "$libdir"; then
+ $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
+ exit 1
+ fi
+ if test "$absdir" != "$libdir"; then
+ $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
+ fi
+ path="$absdir"
+ fi
+ depdepl=
+ case $host in
+ *-*-darwin*)
+ # we do not want to link against static libs, but need to link against shared
+ eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+ if test -n "$deplibrary_names" ; then
+ for tmp in $deplibrary_names ; do
+ depdepl=$tmp
+ done
+ if test -f "$path/$depdepl" ; then
+ depdepl="$path/$depdepl"
+ fi
+ newlib_search_path="$newlib_search_path $path"
+ path=""
+ fi
+ ;;
+ *)
+ path="-L$path"
+ ;;
+ esac
+
+ ;;
+ -l*)
+ case $host in
+ *-*-darwin*)
+ # Again, we only want to link against shared libraries
+ eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
+ for tmp in $newlib_search_path ; do
+ if test -f "$tmp/lib$tmp_libs.dylib" ; then
+ eval depdepl="$tmp/lib$tmp_libs.dylib"
+ break
+ fi
+ done
+ path=""
+ ;;
+ *) continue ;;
+ esac
+ ;;
+ *) continue ;;
+ esac
+ case " $deplibs " in
+ *" $depdepl "*) ;;
+ *) deplibs="$deplibs $depdepl" ;;
+ esac
+ case " $deplibs " in
+ *" $path "*) ;;
+ *) deplibs="$deplibs $path" ;;
+ esac
+ done
+ fi # link_all_deplibs != no
+ fi # linkmode = lib
+ done # for deplib in $libs
+ dependency_libs="$newdependency_libs"
+ if test "$pass" = dlpreopen; then
+ # Link the dlpreopened libraries before other libraries
+ for deplib in $save_deplibs; do
+ deplibs="$deplib $deplibs"
+ done
+ fi
+ if test "$pass" != dlopen; then
+ if test "$pass" != conv; then
+ # Make sure lib_search_path contains only unique directories.
+ lib_search_path=
+ for dir in $newlib_search_path; do
+ case "$lib_search_path " in
+ *" $dir "*) ;;
+ *) lib_search_path="$lib_search_path $dir" ;;
+ esac
+ done
+ newlib_search_path=
+ fi
+
+ if test "$linkmode,$pass" != "prog,link"; then
+ vars="deplibs"
+ else
+ vars="compile_deplibs finalize_deplibs"
+ fi
+ for var in $vars dependency_libs; do
+ # Add libraries to $var in reverse order
+ eval tmp_libs=\"\$$var\"
+ new_libs=
+ for deplib in $tmp_libs; do
+ # FIXME: Pedantically, this is the right thing to do, so
+ # that some nasty dependency loop isn't accidentally
+ # broken:
+ #new_libs="$deplib $new_libs"
+ # Pragmatically, this seems to cause very few problems in
+ # practice:
+ case $deplib in
+ -L*) new_libs="$deplib $new_libs" ;;
+ -R*) ;;
+ *)
+ # And here is the reason: when a library appears more
+ # than once as an explicit dependence of a library, or
+ # is implicitly linked in more than once by the
+ # compiler, it is considered special, and multiple
+ # occurrences thereof are not removed. Compare this
+ # with having the same library being listed as a
+ # dependency of multiple other libraries: in this case,
+ # we know (pedantically, we assume) the library does not
+ # need to be listed more than once, so we keep only the
+ # last copy. This is not always right, but it is rare
+ # enough that we require users that really mean to play
+ # such unportable linking tricks to link the library
+ # using -Wl,-lname, so that libtool does not consider it
+ # for duplicate removal.
+ case " $specialdeplibs " in
+ *" $deplib "*) new_libs="$deplib $new_libs" ;;
+ *)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) new_libs="$deplib $new_libs" ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ done
+ tmp_libs=
+ for deplib in $new_libs; do
+ case $deplib in
+ -L*)
+ case " $tmp_libs " in
+ *" $deplib "*) ;;
+ *) tmp_libs="$tmp_libs $deplib" ;;
+ esac
+ ;;
+ *) tmp_libs="$tmp_libs $deplib" ;;
+ esac
+ done
+ eval $var=\"$tmp_libs\"
+ done # for var
+ fi
+ # Last step: remove runtime libs from dependency_libs (they stay in deplibs)
+ tmp_libs=
+ for i in $dependency_libs ; do
+ case " $predeps $postdeps $compiler_lib_search_path " in
+ *" $i "*)
+ i=""
+ ;;
+ esac
+ if test -n "$i" ; then
+ tmp_libs="$tmp_libs $i"
+ fi
+ done
+ dependency_libs=$tmp_libs
+ done # for pass
+ if test "$linkmode" = prog; then
+ dlfiles="$newdlfiles"
+ dlprefiles="$newdlprefiles"
+ fi
+
+ case $linkmode in
+ oldlib)
+ if test -n "$deplibs"; then
+ $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
+ fi
+
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$rpath"; then
+ $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$xrpath"; then
+ $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$vinfo"; then
+ $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$release"; then
+ $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+ $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
+ fi
+
+ # Now set the variables for building old libraries.
+ build_libtool_libs=no
+ oldlibs="$output"
+ objs="$objs$old_deplibs"
+ ;;
+
+ lib)
+ # Make sure we only generate libraries of the form `libNAME.la'.
+ case $outputname in
+ lib*)
+ name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+ eval shared_ext=\"$shrext\"
+ eval libname=\"$libname_spec\"
+ ;;
+ *)
+ if test "$module" = no; then
+ $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+ if test "$need_lib_prefix" != no; then
+ # Add the "lib" prefix for modules if required
+ name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+ eval shared_ext=\"$shrext\"
+ eval libname=\"$libname_spec\"
+ else
+ libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+ fi
+ ;;
+ esac
+
+ if test -n "$objs"; then
+ if test "$deplibs_check_method" != pass_all; then
+ $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
+ exit 1
+ else
+ $echo
+ $echo "*** Warning: Linking the shared library $output against the non-libtool"
+ $echo "*** objects $objs is not portable!"
+ libobjs="$libobjs $objs"
+ fi
+ fi
+
+ if test "$dlself" != no; then
+ $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
+ fi
+
+ set dummy $rpath
+ if test "$#" -gt 2; then
+ $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
+ fi
+ install_libdir="$2"
+
+ oldlibs=
+ if test -z "$rpath"; then
+ if test "$build_libtool_libs" = yes; then
+ # Building a libtool convenience library.
+ # Some compilers have problems with a `.al' extension so
+ # convenience libraries should have the same extension an
+ # archive normally would.
+ oldlibs="$output_objdir/$libname.$libext $oldlibs"
+ build_libtool_libs=convenience
+ build_old_libs=yes
+ fi
+
+ if test -n "$vinfo"; then
+ $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
+ fi
+
+ if test -n "$release"; then
+ $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
+ fi
+ else
+
+ # Parse the version information argument.
+ save_ifs="$IFS"; IFS=':'
+ set dummy $vinfo 0 0 0
+ IFS="$save_ifs"
+
+ if test -n "$8"; then
+ $echo "$modename: too many parameters to \`-version-info'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # convert absolute version numbers to libtool ages
+ # this retains compatibility with .la files and attempts
+ # to make the code below a bit more comprehensible
+
+ case $vinfo_number in
+ yes)
+ number_major="$2"
+ number_minor="$3"
+ number_revision="$4"
+ #
+ # There are really only two kinds -- those that
+ # use the current revision as the major version
+ # and those that subtract age and use age as
+ # a minor version. But, then there is irix
+ # which has an extra 1 added just for fun
+ #
+ case $version_type in
+ darwin|linux|osf|windows)
+ current=`expr $number_major + $number_minor`
+ age="$number_minor"
+ revision="$number_revision"
+ ;;
+ freebsd-aout|freebsd-elf|sunos)
+ current="$number_major"
+ revision="$number_minor"
+ age="0"
+ ;;
+ irix|nonstopux)
+ current=`expr $number_major + $number_minor - 1`
+ age="$number_minor"
+ revision="$number_minor"
+ ;;
+ esac
+ ;;
+ no)
+ current="$2"
+ revision="$3"
+ age="$4"
+ ;;
+ esac
+
+ # Check that each of the things are valid numbers.
+ case $current in
+ 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+ *)
+ $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
+ $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+ exit 1
+ ;;
+ esac
+
+ case $revision in
+ 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+ *)
+ $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
+ $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+ exit 1
+ ;;
+ esac
+
+ case $age in
+ 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+ *)
+ $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
+ $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+ exit 1
+ ;;
+ esac
+
+ if test "$age" -gt "$current"; then
+ $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
+ $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+ exit 1
+ fi
+
+ # Calculate the version variables.
+ major=
+ versuffix=
+ verstring=
+ case $version_type in
+ none) ;;
+
+ darwin)
+ # Like Linux, but with the current version available in
+ # verstring for coding it into the library header
+ major=.`expr $current - $age`
+ versuffix="$major.$age.$revision"
+ # Darwin ld doesn't like 0 for these options...
+ minor_current=`expr $current + 1`
+ verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+ ;;
+
+ freebsd-aout)
+ major=".$current"
+ versuffix=".$current.$revision";
+ ;;
+
+ freebsd-elf)
+ major=".$current"
+ versuffix=".$current";
+ ;;
+
+ irix | nonstopux)
+ major=`expr $current - $age + 1`
+
+ case $version_type in
+ nonstopux) verstring_prefix=nonstopux ;;
+ *) verstring_prefix=sgi ;;
+ esac
+ verstring="$verstring_prefix$major.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$revision
+ while test "$loop" -ne 0; do
+ iface=`expr $revision - $loop`
+ loop=`expr $loop - 1`
+ verstring="$verstring_prefix$major.$iface:$verstring"
+ done
+
+ # Before this point, $major must not contain `.'.
+ major=.$major
+ versuffix="$major.$revision"
+ ;;
+
+ linux)
+ major=.`expr $current - $age`
+ versuffix="$major.$age.$revision"
+ ;;
+
+ osf)
+ major=.`expr $current - $age`
+ versuffix=".$current.$age.$revision"
+ verstring="$current.$age.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$age
+ while test "$loop" -ne 0; do
+ iface=`expr $current - $loop`
+ loop=`expr $loop - 1`
+ verstring="$verstring:${iface}.0"
+ done
+
+ # Make executables depend on our current version.
+ verstring="$verstring:${current}.0"
+ ;;
+
+ sunos)
+ major=".$current"
+ versuffix=".$current.$revision"
+ ;;
+
+ windows)
+ # Use '-' rather than '.', since we only want one
+ # extension on DOS 8.3 filesystems.
+ major=`expr $current - $age`
+ versuffix="-$major"
+ ;;
+
+ *)
+ $echo "$modename: unknown library version type \`$version_type'" 1>&2
+ $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
+ exit 1
+ ;;
+ esac
+
+ # Clear the version info if we defaulted, and they specified a release.
+ if test -z "$vinfo" && test -n "$release"; then
+ major=
+ case $version_type in
+ darwin)
+ # we can't check for "0.0" in archive_cmds due to quoting
+ # problems, so we reset it completely
+ verstring=
+ ;;
+ *)
+ verstring="0.0"
+ ;;
+ esac
+ if test "$need_version" = no; then
+ versuffix=
+ else
+ versuffix=".0.0"
+ fi
+ fi
+
+ # Remove version info from name if versioning should be avoided
+ if test "$avoid_version" = yes && test "$need_version" = no; then
+ major=
+ versuffix=
+ verstring=""
+ fi
+
+ # Check to see if the archive will have undefined symbols.
+ if test "$allow_undefined" = yes; then
+ if test "$allow_undefined_flag" = unsupported; then
+ $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
+ build_libtool_libs=no
+ build_old_libs=yes
+ fi
+ else
+ # Don't allow undefined symbols.
+ allow_undefined_flag="$no_undefined_flag"
+ fi
+ fi
+
+ if test "$mode" != relink; then
+ # Remove our outputs, but don't remove object files since they
+ # may have been created when compiling PIC objects.
+ removelist=
+ tempremovelist=`$echo "$output_objdir/*"`
+ for p in $tempremovelist; do
+ case $p in
+ *.$objext)
+ ;;
+ $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+ removelist="$removelist $p"
+ ;;
+ *) ;;
+ esac
+ done
+ if test -n "$removelist"; then
+ $show "${rm}r $removelist"
+ $run ${rm}r $removelist
+ fi
+ fi
+
+ # Now set the variables for building old libraries.
+ if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+ oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+ # Transform .lo files to .o files.
+ oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+ fi
+
+ # Eliminate all temporary directories.
+ for path in $notinst_path; do
+ lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'`
+ deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'`
+ dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
+ done
+
+ if test -n "$xrpath"; then
+ # If the user specified any rpath flags, then add them.
+ temp_xrpath=
+ for libdir in $xrpath; do
+ temp_xrpath="$temp_xrpath -R$libdir"
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir" ;;
+ esac
+ done
+ if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+ dependency_libs="$temp_xrpath $dependency_libs"
+ fi
+ fi
+
+ # Make sure dlfiles contains only unique files that won't be dlpreopened
+ old_dlfiles="$dlfiles"
+ dlfiles=
+ for lib in $old_dlfiles; do
+ case " $dlprefiles $dlfiles " in
+ *" $lib "*) ;;
+ *) dlfiles="$dlfiles $lib" ;;
+ esac
+ done
+
+ # Make sure dlprefiles contains only unique files
+ old_dlprefiles="$dlprefiles"
+ dlprefiles=
+ for lib in $old_dlprefiles; do
+ case "$dlprefiles " in
+ *" $lib "*) ;;
+ *) dlprefiles="$dlprefiles $lib" ;;
+ esac
+ done
+
+ if test "$build_libtool_libs" = yes; then
+ if test -n "$rpath"; then
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
+ # these systems don't actually have a c library (as such)!
+ ;;
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # Rhapsody C library is in the System framework
+ deplibs="$deplibs -framework System"
+ ;;
+ *-*-netbsd*)
+ # Don't link with libc until the a.out ld.so is fixed.
+ ;;
+ *-*-openbsd* | *-*-freebsd*)
+ # Do not include libc due to us having libc/libc_r.
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *)
+ # Add libc to deplibs on all other systems if necessary.
+ if test "$build_libtool_need_lc" = "yes"; then
+ deplibs="$deplibs -lc"
+ fi
+ ;;
+ esac
+ fi
+
+ # Transform deplibs into only deplibs that can be linked in shared.
+ name_save=$name
+ libname_save=$libname
+ release_save=$release
+ versuffix_save=$versuffix
+ major_save=$major
+ # I'm not sure if I'm treating the release correctly. I think
+ # release should show up in the -l (ie -lgmp5) so we don't want to
+ # add it in twice. Is that correct?
+ release=""
+ versuffix=""
+ major=""
+ newdeplibs=
+ droppeddeps=no
+ case $deplibs_check_method in
+ pass_all)
+ # Don't check for shared/static. Everything works.
+ # This might be a little naive. We might want to check
+ # whether the library exists or not. But this is on
+ # osf3 & osf4 and I'm not really sure... Just
+ # implementing what was already the behavior.
+ newdeplibs=$deplibs
+ ;;
+ test_compile)
+ # This code stresses the "libraries are programs" paradigm to its
+ # limits. Maybe even breaks it. We compile a program, linking it
+ # against the deplibs as a proxy for the library. Then we can check
+ # whether they linked in statically or dynamically with ldd.
+ $rm conftest.c
+ cat > conftest.c <<EOF
+ int main() { return 0; }
+EOF
+ $rm conftest
+ $LTCC -o conftest conftest.c $deplibs
+ if test "$?" -eq 0 ; then
+ ldd_output=`ldd conftest`
+ for i in $deplibs; do
+ name="`expr $i : '-l\(.*\)'`"
+ # If $name is empty we are operating on a -L argument.
+ if test "$name" != "" && test "$name" -ne "0"; then
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $i "*)
+ newdeplibs="$newdeplibs $i"
+ i=""
+ ;;
+ esac
+ fi
+ if test -n "$i" ; then
+ libname=`eval \\$echo \"$libname_spec\"`
+ deplib_matches=`eval \\$echo \"$library_names_spec\"`
+ set dummy $deplib_matches
+ deplib_match=$2
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ newdeplibs="$newdeplibs $i"
+ else
+ droppeddeps=yes
+ $echo
+ $echo "*** Warning: dynamic linker does not accept needed library $i."
+ $echo "*** I have the capability to make that library automatically link in when"
+ $echo "*** you link to this library. But I can only do this if you have a"
+ $echo "*** shared version of the library, which I believe you do not have"
+ $echo "*** because a test_compile did reveal that the linker did not use it for"
+ $echo "*** its dynamic dependency list that programs get resolved with at runtime."
+ fi
+ fi
+ else
+ newdeplibs="$newdeplibs $i"
+ fi
+ done
+ else
+ # Error occurred in the first compile. Let's try to salvage
+ # the situation: Compile a separate program for each library.
+ for i in $deplibs; do
+ name="`expr $i : '-l\(.*\)'`"
+ # If $name is empty we are operating on a -L argument.
+ if test "$name" != "" && test "$name" != "0"; then
+ $rm conftest
+ $LTCC -o conftest conftest.c $i
+ # Did it work?
+ if test "$?" -eq 0 ; then
+ ldd_output=`ldd conftest`
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $i "*)
+ newdeplibs="$newdeplibs $i"
+ i=""
+ ;;
+ esac
+ fi
+ if test -n "$i" ; then
+ libname=`eval \\$echo \"$libname_spec\"`
+ deplib_matches=`eval \\$echo \"$library_names_spec\"`
+ set dummy $deplib_matches
+ deplib_match=$2
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ newdeplibs="$newdeplibs $i"
+ else
+ droppeddeps=yes
+ $echo
+ $echo "*** Warning: dynamic linker does not accept needed library $i."
+ $echo "*** I have the capability to make that library automatically link in when"
+ $echo "*** you link to this library. But I can only do this if you have a"
+ $echo "*** shared version of the library, which you do not appear to have"
+ $echo "*** because a test_compile did reveal that the linker did not use this one"
+ $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
+ fi
+ fi
+ else
+ droppeddeps=yes
+ $echo
+ $echo "*** Warning! Library $i is needed by this library but I was not able to"
+ $echo "*** make it link in! You will probably need to install it or some"
+ $echo "*** library that it depends on before this library will be fully"
+ $echo "*** functional. Installing it before continuing would be even better."
+ fi
+ else
+ newdeplibs="$newdeplibs $i"
+ fi
+ done
+ fi
+ ;;
+ file_magic*)
+ set dummy $deplibs_check_method
+ file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+ for a_deplib in $deplibs; do
+ name="`expr $a_deplib : '-l\(.*\)'`"
+ # If $name is empty we are operating on a -L argument.
+ if test "$name" != "" && test "$name" != "0"; then
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $a_deplib "*)
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ ;;
+ esac
+ fi
+ if test -n "$a_deplib" ; then
+ libname=`eval \\$echo \"$libname_spec\"`
+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+ for potent_lib in $potential_libs; do
+ # Follow soft links.
+ if ls -lLd "$potent_lib" 2>/dev/null \
+ | grep " -> " >/dev/null; then
+ continue
+ fi
+ # The statement above tries to avoid entering an
+ # endless loop below, in case of cyclic links.
+ # We might still enter an endless loop, since a link
+ # loop can be closed while we follow links,
+ # but so what?
+ potlib="$potent_lib"
+ while test -h "$potlib" 2>/dev/null; do
+ potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+ case $potliblink in
+ [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+ *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+ esac
+ done
+ if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
+ | ${SED} 10q \
+ | $EGREP "$file_magic_regex" > /dev/null; then
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ break 2
+ fi
+ done
+ done
+ fi
+ if test -n "$a_deplib" ; then
+ droppeddeps=yes
+ $echo
+ $echo "*** Warning: linker path does not have real file for library $a_deplib."
+ $echo "*** I have the capability to make that library automatically link in when"
+ $echo "*** you link to this library. But I can only do this if you have a"
+ $echo "*** shared version of the library, which you do not appear to have"
+ $echo "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ $echo "*** with $libname but no candidates were found. (...for file magic test)"
+ else
+ $echo "*** with $libname and none of the candidates passed a file format test"
+ $echo "*** using a file magic. Last file checked: $potlib"
+ fi
+ fi
+ else
+ # Add a -L argument.
+ newdeplibs="$newdeplibs $a_deplib"
+ fi
+ done # Gone through all deplibs.
+ ;;
+ match_pattern*)
+ set dummy $deplibs_check_method
+ match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+ for a_deplib in $deplibs; do
+ name="`expr $a_deplib : '-l\(.*\)'`"
+ # If $name is empty we are operating on a -L argument.
+ if test -n "$name" && test "$name" != "0"; then
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $a_deplib "*)
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ ;;
+ esac
+ fi
+ if test -n "$a_deplib" ; then
+ libname=`eval \\$echo \"$libname_spec\"`
+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+ for potent_lib in $potential_libs; do
+ potlib="$potent_lib" # see symlink-check above in file_magic test
+ if eval $echo \"$potent_lib\" 2>/dev/null \
+ | ${SED} 10q \
+ | $EGREP "$match_pattern_regex" > /dev/null; then
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ break 2
+ fi
+ done
+ done
+ fi
+ if test -n "$a_deplib" ; then
+ droppeddeps=yes
+ $echo
+ $echo "*** Warning: linker path does not have real file for library $a_deplib."
+ $echo "*** I have the capability to make that library automatically link in when"
+ $echo "*** you link to this library. But I can only do this if you have a"
+ $echo "*** shared version of the library, which you do not appear to have"
+ $echo "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
+ else
+ $echo "*** with $libname and none of the candidates passed a file format test"
+ $echo "*** using a regex pattern. Last file checked: $potlib"
+ fi
+ fi
+ else
+ # Add a -L argument.
+ newdeplibs="$newdeplibs $a_deplib"
+ fi
+ done # Gone through all deplibs.
+ ;;
+ none | unknown | *)
+ newdeplibs=""
+ tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
+ -e 's/ -[LR][^ ]*//g'`
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ for i in $predeps $postdeps ; do
+ # can't use Xsed below, because $i might contain '/'
+ tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
+ done
+ fi
+ if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \
+ | grep . >/dev/null; then
+ $echo
+ if test "X$deplibs_check_method" = "Xnone"; then
+ $echo "*** Warning: inter-library dependencies are not supported in this platform."
+ else
+ $echo "*** Warning: inter-library dependencies are not known to be supported."
+ fi
+ $echo "*** All declared inter-library dependencies are being dropped."
+ droppeddeps=yes
+ fi
+ ;;
+ esac
+ versuffix=$versuffix_save
+ major=$major_save
+ release=$release_save
+ libname=$libname_save
+ name=$name_save
+
+ case $host in
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # On Rhapsody replace the C library is the System framework
+ newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
+ ;;
+ esac
+
+ if test "$droppeddeps" = yes; then
+ if test "$module" = yes; then
+ $echo
+ $echo "*** Warning: libtool could not satisfy all declared inter-library"
+ $echo "*** dependencies of module $libname. Therefore, libtool will create"
+ $echo "*** a static module, that should work as long as the dlopening"
+ $echo "*** application is linked with the -dlopen flag."
+ if test -z "$global_symbol_pipe"; then
+ $echo
+ $echo "*** However, this would only work if libtool was able to extract symbol"
+ $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ $echo "*** not find such a program. So, this module is probably useless."
+ $echo "*** \`nm' from GNU binutils and a full rebuild may help."
+ fi
+ if test "$build_old_libs" = no; then
+ oldlibs="$output_objdir/$libname.$libext"
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ else
+ $echo "*** The inter-library dependencies that have been dropped here will be"
+ $echo "*** automatically added whenever a program is linked with this library"
+ $echo "*** or is declared to -dlopen it."
+
+ if test "$allow_undefined" = no; then
+ $echo
+ $echo "*** Since this library must not contain undefined symbols,"
+ $echo "*** because either the platform does not support them or"
+ $echo "*** it was explicitly requested with -no-undefined,"
+ $echo "*** libtool will only create a static version of it."
+ if test "$build_old_libs" = no; then
+ oldlibs="$output_objdir/$libname.$libext"
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ fi
+ fi
+ fi
+ # Done checking deplibs!
+ deplibs=$newdeplibs
+ fi
+
+ # All the library-specific variables (install_libdir is set above).
+ library_names=
+ old_library=
+ dlname=
+
+ # Test again, we may have decided not to build it any more
+ if test "$build_libtool_libs" = yes; then
+ if test "$hardcode_into_libs" = yes; then
+ # Hardcode the library paths
+ hardcode_libdirs=
+ dep_rpath=
+ rpath="$finalize_rpath"
+ test "$mode" != relink && rpath="$compile_rpath$rpath"
+ for libdir in $rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ dep_rpath="$dep_rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$perm_rpath " in
+ *" $libdir "*) ;;
+ *) perm_rpath="$perm_rpath $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ if test -n "$hardcode_libdir_flag_spec_ld"; then
+ eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
+ else
+ eval dep_rpath=\"$hardcode_libdir_flag_spec\"
+ fi
+ fi
+ if test -n "$runpath_var" && test -n "$perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+ fi
+ test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+ fi
+
+ shlibpath="$finalize_shlibpath"
+ test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+ if test -n "$shlibpath"; then
+ eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+ fi
+
+ # Get the real and link names of the library.
+ eval shared_ext=\"$shrext\"
+ eval library_names=\"$library_names_spec\"
+ set dummy $library_names
+ realname="$2"
+ shift; shift
+
+ if test -n "$soname_spec"; then
+ eval soname=\"$soname_spec\"
+ else
+ soname="$realname"
+ fi
+ if test -z "$dlname"; then
+ dlname=$soname
+ fi
+
+ lib="$output_objdir/$realname"
+ for link
+ do
+ linknames="$linknames $link"
+ done
+
+ # Use standard objects if they are pic
+ test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+ $show "generating symbol list for \`$libname.la'"
+ export_symbols="$output_objdir/$libname.exp"
+ $run $rm $export_symbols
+ eval cmds=\"$export_symbols_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ if len=`expr "X$cmd" : ".*"` &&
+ test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ skipped_export=false
+ else
+ # The command line is too long to execute in one step.
+ $show "using reloadable object file for export list..."
+ skipped_export=:
+ fi
+ done
+ IFS="$save_ifs"
+ if test -n "$export_symbols_regex"; then
+ $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
+ $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+ $show "$mv \"${export_symbols}T\" \"$export_symbols\""
+ $run eval '$mv "${export_symbols}T" "$export_symbols"'
+ fi
+ fi
+ fi
+
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
+ fi
+
+ tmp_deplibs=
+ for test_deplib in $deplibs; do
+ case " $convenience " in
+ *" $test_deplib "*) ;;
+ *)
+ tmp_deplibs="$tmp_deplibs $test_deplib"
+ ;;
+ esac
+ done
+ deplibs="$tmp_deplibs"
+
+ if test -n "$convenience"; then
+ if test -n "$whole_archive_flag_spec"; then
+ save_libobjs=$libobjs
+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+ else
+ gentop="$output_objdir/${outputname}x"
+ $show "${rm}r $gentop"
+ $run ${rm}r "$gentop"
+ $show "$mkdir $gentop"
+ $run $mkdir "$gentop"
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$gentop"; then
+ exit $status
+ fi
+ generated="$generated $gentop"
+
+ for xlib in $convenience; do
+ # Extract the objects.
+ case $xlib in
+ [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+ *) xabs=`pwd`"/$xlib" ;;
+ esac
+ xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+ xdir="$gentop/$xlib"
+
+ $show "${rm}r $xdir"
+ $run ${rm}r "$xdir"
+ $show "$mkdir $xdir"
+ $run $mkdir "$xdir"
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$xdir"; then
+ exit $status
+ fi
+ # We will extract separately just the conflicting names and we will no
+ # longer touch any unique names. It is faster to leave these extract
+ # automatically by $AR in one run.
+ $show "(cd $xdir && $AR x $xabs)"
+ $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+ if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
+ $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
+ $AR t "$xabs" | sort | uniq -cd | while read -r count name
+ do
+ i=1
+ while test "$i" -le "$count"
+ do
+ # Put our $i before any first dot (extension)
+ # Never overwrite any file
+ name_to="$name"
+ while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
+ do
+ name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
+ done
+ $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
+ $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
+ i=`expr $i + 1`
+ done
+ done
+ fi
+
+ libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+ done
+ fi
+ fi
+
+ if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+ eval flag=\"$thread_safe_flag_spec\"
+ linker_flags="$linker_flags $flag"
+ fi
+
+ # Make a backup of the uninstalled library when relinking
+ if test "$mode" = relink; then
+ $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
+ fi
+
+ # Do each of the archive commands.
+ if test "$module" = yes && test -n "$module_cmds" ; then
+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+ eval cmds=\"$module_expsym_cmds\"
+ else
+ eval cmds=\"$module_cmds\"
+ fi
+ else
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ eval cmds=\"$archive_expsym_cmds\"
+ else
+ eval cmds=\"$archive_cmds\"
+ fi
+ fi
+
+ if test "X$skipped_export" != "X:" && len=`expr "X$cmds" : ".*"` &&
+ test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ :
+ else
+ # The command line is too long to link in one step, link piecewise.
+ $echo "creating reloadable object files..."
+
+ # Save the value of $output and $libobjs because we want to
+ # use them later. If we have whole_archive_flag_spec, we
+ # want to use save_libobjs as it was before
+ # whole_archive_flag_spec was expanded, because we can't
+ # assume the linker understands whole_archive_flag_spec.
+ # This may have to be revisited, in case too many
+ # convenience libraries get linked in and end up exceeding
+ # the spec.
+ if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+ save_libobjs=$libobjs
+ fi
+ save_output=$output
+
+ # Clear the reloadable object creation command queue and
+ # initialize k to one.
+ test_cmds=
+ concat_cmds=
+ objlist=
+ delfiles=
+ last_robj=
+ k=1
+ output=$output_objdir/$save_output-${k}.$objext
+ # Loop over the list of objects to be linked.
+ for obj in $save_libobjs
+ do
+ eval test_cmds=\"$reload_cmds $objlist $last_robj\"
+ if test "X$objlist" = X ||
+ { len=`expr "X$test_cmds" : ".*"` &&
+ test "$len" -le "$max_cmd_len"; }; then
+ objlist="$objlist $obj"
+ else
+ # The command $test_cmds is almost too long, add a
+ # command to the queue.
+ if test "$k" -eq 1 ; then
+ # The first file doesn't have a previous command to add.
+ eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
+ else
+ # All subsequent reloadable object files will link in
+ # the last one created.
+ eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
+ fi
+ last_robj=$output_objdir/$save_output-${k}.$objext
+ k=`expr $k + 1`
+ output=$output_objdir/$save_output-${k}.$objext
+ objlist=$obj
+ len=1
+ fi
+ done
+ # Handle the remaining objects by creating one last
+ # reloadable object file. All subsequent reloadable object
+ # files will link in the last one created.
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
+
+ if ${skipped_export-false}; then
+ $show "generating symbol list for \`$libname.la'"
+ export_symbols="$output_objdir/$libname.exp"
+ $run $rm $export_symbols
+ libobjs=$output
+ # Append the command to create the export file.
+ eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
+ fi
+
+ # Set up a command to remove the reloadale object files
+ # after they are used.
+ i=0
+ while test "$i" -lt "$k"
+ do
+ i=`expr $i + 1`
+ delfiles="$delfiles $output_objdir/$save_output-${i}.$objext"
+ done
+
+ $echo "creating a temporary reloadable object file: $output"
+
+ # Loop through the commands generated above and execute them.
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $concat_cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+
+ libobjs=$output
+ # Restore the value of output.
+ output=$save_output
+
+ if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+ fi
+ # Expand the library linking commands again to reset the
+ # value of $libobjs for piecewise linking.
+
+ # Do each of the archive commands.
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ eval cmds=\"$archive_expsym_cmds\"
+ else
+ eval cmds=\"$archive_cmds\"
+ fi
+
+ # Append the command to remove the reloadable object files
+ # to the just-reset $cmds.
+ eval cmds=\"\$cmds~$rm $delfiles\"
+ fi
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+
+ # Restore the uninstalled library and exit
+ if test "$mode" = relink; then
+ $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
+ exit 0
+ fi
+
+ # Create links to the real library.
+ for linkname in $linknames; do
+ if test "$realname" != "$linkname"; then
+ $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
+ $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
+ fi
+ done
+
+ # If -module or -export-dynamic was specified, set the dlname.
+ if test "$module" = yes || test "$export_dynamic" = yes; then
+ # On all known operating systems, these are identical.
+ dlname="$soname"
+ fi
+ fi
+ ;;
+
+ obj)
+ if test -n "$deplibs"; then
+ $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
+ fi
+
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
+ fi
+
+ if test -n "$rpath"; then
+ $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
+ fi
+
+ if test -n "$xrpath"; then
+ $echo "$modename: warning: \`-R' is ignored for objects" 1>&2
+ fi
+
+ if test -n "$vinfo"; then
+ $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
+ fi
+
+ if test -n "$release"; then
+ $echo "$modename: warning: \`-release' is ignored for objects" 1>&2
+ fi
+
+ case $output in
+ *.lo)
+ if test -n "$objs$old_deplibs"; then
+ $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
+ exit 1
+ fi
+ libobj="$output"
+ obj=`$echo "X$output" | $Xsed -e "$lo2o"`
+ ;;
+ *)
+ libobj=
+ obj="$output"
+ ;;
+ esac
+
+ # Delete the old objects.
+ $run $rm $obj $libobj
+
+ # Objects from convenience libraries. This assumes
+ # single-version convenience libraries. Whenever we create
+ # different ones for PIC/non-PIC, this we'll have to duplicate
+ # the extraction.
+ reload_conv_objs=
+ gentop=
+ # reload_cmds runs $LD directly, so let us get rid of
+ # -Wl from whole_archive_flag_spec
+ wl=
+
+ if test -n "$convenience"; then
+ if test -n "$whole_archive_flag_spec"; then
+ eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
+ else
+ gentop="$output_objdir/${obj}x"
+ $show "${rm}r $gentop"
+ $run ${rm}r "$gentop"
+ $show "$mkdir $gentop"
+ $run $mkdir "$gentop"
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$gentop"; then
+ exit $status
+ fi
+ generated="$generated $gentop"
+
+ for xlib in $convenience; do
+ # Extract the objects.
+ case $xlib in
+ [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+ *) xabs=`pwd`"/$xlib" ;;
+ esac
+ xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+ xdir="$gentop/$xlib"
+
+ $show "${rm}r $xdir"
+ $run ${rm}r "$xdir"
+ $show "$mkdir $xdir"
+ $run $mkdir "$xdir"
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$xdir"; then
+ exit $status
+ fi
+ # We will extract separately just the conflicting names and we will no
+ # longer touch any unique names. It is faster to leave these extract
+ # automatically by $AR in one run.
+ $show "(cd $xdir && $AR x $xabs)"
+ $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+ if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
+ $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
+ $AR t "$xabs" | sort | uniq -cd | while read -r count name
+ do
+ i=1
+ while test "$i" -le "$count"
+ do
+ # Put our $i before any first dot (extension)
+ # Never overwrite any file
+ name_to="$name"
+ while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
+ do
+ name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
+ done
+ $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
+ $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
+ i=`expr $i + 1`
+ done
+ done
+ fi
+
+ reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+ done
+ fi
+ fi
+
+ # Create the old-style object.
+ reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+ output="$obj"
+ eval cmds=\"$reload_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+
+ # Exit if we aren't doing a library object file.
+ if test -z "$libobj"; then
+ if test -n "$gentop"; then
+ $show "${rm}r $gentop"
+ $run ${rm}r $gentop
+ fi
+
+ exit 0
+ fi
+
+ if test "$build_libtool_libs" != yes; then
+ if test -n "$gentop"; then
+ $show "${rm}r $gentop"
+ $run ${rm}r $gentop
+ fi
+
+ # Create an invalid libtool object if no PIC, so that we don't
+ # accidentally link it into a program.
+ # $show "echo timestamp > $libobj"
+ # $run eval "echo timestamp > $libobj" || exit $?
+ exit 0
+ fi
+
+ if test -n "$pic_flag" || test "$pic_mode" != default; then
+ # Only do commands if we really have different PIC objects.
+ reload_objs="$libobjs $reload_conv_objs"
+ output="$libobj"
+ eval cmds=\"$reload_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ fi
+
+ if test -n "$gentop"; then
+ $show "${rm}r $gentop"
+ $run ${rm}r $gentop
+ fi
+
+ exit 0
+ ;;
+
+ prog)
+ case $host in
+ *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
+ esac
+ if test -n "$vinfo"; then
+ $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
+ fi
+
+ if test -n "$release"; then
+ $echo "$modename: warning: \`-release' is ignored for programs" 1>&2
+ fi
+
+ if test "$preload" = yes; then
+ if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
+ test "$dlopen_self_static" = unknown; then
+ $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
+ fi
+ fi
+
+ case $host in
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # On Rhapsody replace the C library is the System framework
+ compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+ finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+ ;;
+ esac
+
+ case $host in
+ *darwin*)
+ # Don't allow lazy linking, it breaks C++ global constructors
+ if test "$tagname" = CXX ; then
+ compile_command="$compile_command ${wl}-bind_at_load"
+ finalize_command="$finalize_command ${wl}-bind_at_load"
+ fi
+ ;;
+ esac
+
+ compile_command="$compile_command $compile_deplibs"
+ finalize_command="$finalize_command $finalize_deplibs"
+
+ if test -n "$rpath$xrpath"; then
+ # If the user specified any rpath flags, then add them.
+ for libdir in $rpath $xrpath; do
+ # This is the magic to use -rpath.
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir" ;;
+ esac
+ done
+ fi
+
+ # Now hardcode the library paths
+ rpath=
+ hardcode_libdirs=
+ for libdir in $compile_rpath $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ rpath="$rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$perm_rpath " in
+ *" $libdir "*) ;;
+ *) perm_rpath="$perm_rpath $libdir" ;;
+ esac
+ fi
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ case :$dllsearchpath: in
+ *":$libdir:"*) ;;
+ *) dllsearchpath="$dllsearchpath:$libdir";;
+ esac
+ ;;
+ esac
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ compile_rpath="$rpath"
+
+ rpath=
+ hardcode_libdirs=
+ for libdir in $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ rpath="$rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$finalize_perm_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ finalize_rpath="$rpath"
+
+ if test -n "$libobjs" && test "$build_old_libs" = yes; then
+ # Transform all the library objects into standard objects.
+ compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ fi
+
+ dlsyms=
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ if test -n "$NM" && test -n "$global_symbol_pipe"; then
+ dlsyms="${outputname}S.c"
+ else
+ $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
+ fi
+ fi
+
+ if test -n "$dlsyms"; then
+ case $dlsyms in
+ "") ;;
+ *.c)
+ # Discover the nlist of each of the dlfiles.
+ nlist="$output_objdir/${outputname}.nm"
+
+ $show "$rm $nlist ${nlist}S ${nlist}T"
+ $run $rm "$nlist" "${nlist}S" "${nlist}T"
+
+ # Parse the name list into a source file.
+ $show "creating $output_objdir/$dlsyms"
+
+ test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
+/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
+/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* Prevent the only kind of declaration conflicts we can make. */
+#define lt_preloaded_symbols some_other_symbol
+
+/* External symbol declarations for the compiler. */\
+"
+
+ if test "$dlself" = yes; then
+ $show "generating symbol list for \`$output'"
+
+ test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
+
+ # Add our own program objects to the symbol list.
+ progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ for arg in $progfiles; do
+ $show "extracting global C symbols from \`$arg'"
+ $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+ done
+
+ if test -n "$exclude_expsyms"; then
+ $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+ $run eval '$mv "$nlist"T "$nlist"'
+ fi
+
+ if test -n "$export_symbols_regex"; then
+ $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+ $run eval '$mv "$nlist"T "$nlist"'
+ fi
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ export_symbols="$output_objdir/$output.exp"
+ $run $rm $export_symbols
+ $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+ else
+ $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
+ $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
+ $run eval 'mv "$nlist"T "$nlist"'
+ fi
+ fi
+
+ for arg in $dlprefiles; do
+ $show "extracting global C symbols from \`$arg'"
+ name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
+ $run eval '$echo ": $name " >> "$nlist"'
+ $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+ done
+
+ if test -z "$run"; then
+ # Make sure we have at least an empty file.
+ test -f "$nlist" || : > "$nlist"
+
+ if test -n "$exclude_expsyms"; then
+ $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+ $mv "$nlist"T "$nlist"
+ fi
+
+ # Try sorting and uniquifying the output.
+ if grep -v "^: " < "$nlist" |
+ if sort -k 3 </dev/null >/dev/null 2>&1; then
+ sort -k 3
+ else
+ sort +2
+ fi |
+ uniq > "$nlist"S; then
+ :
+ else
+ grep -v "^: " < "$nlist" > "$nlist"S
+ fi
+
+ if test -f "$nlist"S; then
+ eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
+ else
+ $echo '/* NONE */' >> "$output_objdir/$dlsyms"
+ fi
+
+ $echo >> "$output_objdir/$dlsyms" "\
+
+#undef lt_preloaded_symbols
+
+#if defined (__STDC__) && __STDC__
+# define lt_ptr void *
+#else
+# define lt_ptr char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ lt_ptr address;
+}
+lt_preloaded_symbols[] =
+{\
+"
+
+ eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
+
+ $echo >> "$output_objdir/$dlsyms" "\
+ {0, (lt_ptr) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+ fi
+
+ pic_flag_for_symtable=
+ case $host in
+ # compiling the symbol table file with pic_flag works around
+ # a FreeBSD bug that causes programs to crash when -lm is
+ # linked before any other PIC object. But we must not use
+ # pic_flag when linking with -static. The problem exists in
+ # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+ *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+ case "$compile_command " in
+ *" -static "*) ;;
+ *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
+ esac;;
+ *-*-hpux*)
+ case "$compile_command " in
+ *" -static "*) ;;
+ *) pic_flag_for_symtable=" $pic_flag";;
+ esac
+ esac
+
+ # Now compile the dynamic symbol file.
+ $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+ $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
+
+ # Clean up the generated files.
+ $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
+ $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
+
+ # Transform the symbol file into the correct name.
+ compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+ finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+ ;;
+ *)
+ $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
+ exit 1
+ ;;
+ esac
+ else
+ # We keep going just in case the user didn't refer to
+ # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
+ # really was required.
+
+ # Nullify the symbol file.
+ compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+ finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+ fi
+
+ if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+ # Replace the output file specification.
+ compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+ link_command="$compile_command$compile_rpath"
+
+ # We have no uninstalled library dependencies, so finalize right now.
+ $show "$link_command"
+ $run eval "$link_command"
+ status=$?
+
+ # Delete the generated files.
+ if test -n "$dlsyms"; then
+ $show "$rm $output_objdir/${outputname}S.${objext}"
+ $run $rm "$output_objdir/${outputname}S.${objext}"
+ fi
+
+ exit $status
+ fi
+
+ if test -n "$shlibpath_var"; then
+ # We should set the shlibpath_var
+ rpath=
+ for dir in $temp_rpath; do
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*)
+ # Absolute path.
+ rpath="$rpath$dir:"
+ ;;
+ *)
+ # Relative path: add a thisdir entry.
+ rpath="$rpath\$thisdir/$dir:"
+ ;;
+ esac
+ done
+ temp_rpath="$rpath"
+ fi
+
+ if test -n "$compile_shlibpath$finalize_shlibpath"; then
+ compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+ fi
+ if test -n "$finalize_shlibpath"; then
+ finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+ fi
+
+ compile_var=
+ finalize_var=
+ if test -n "$runpath_var"; then
+ if test -n "$perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ if test -n "$finalize_perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $finalize_perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ fi
+
+ if test "$no_install" = yes; then
+ # We don't need to create a wrapper script.
+ link_command="$compile_var$compile_command$compile_rpath"
+ # Replace the output file specification.
+ link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+ # Delete the old output file.
+ $run $rm $output
+ # Link the executable and exit
+ $show "$link_command"
+ $run eval "$link_command" || exit $?
+ exit 0
+ fi
+
+ if test "$hardcode_action" = relink; then
+ # Fast installation is not supported
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+ $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
+ $echo "$modename: \`$output' will be relinked during installation" 1>&2
+ else
+ if test "$fast_install" != no; then
+ link_command="$finalize_var$compile_command$finalize_rpath"
+ if test "$fast_install" = yes; then
+ relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+ else
+ # fast_install is set to needless
+ relink_command=
+ fi
+ else
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+ fi
+ fi
+
+ # Replace the output file specification.
+ link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+ # Delete the old output files.
+ $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+ $show "$link_command"
+ $run eval "$link_command" || exit $?
+
+ # Now create the wrapper script.
+ $show "creating $output"
+
+ # Quote the relink command for shipping.
+ if test -n "$relink_command"; then
+ # Preserve any variables that may affect compiler behavior
+ for var in $variables_saved_for_relink; do
+ if eval test -z \"\${$var+set}\"; then
+ relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
+ elif eval var_value=\$$var; test -z "$var_value"; then
+ relink_command="$var=; export $var; $relink_command"
+ else
+ var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
+ relink_command="$var=\"$var_value\"; export $var; $relink_command"
+ fi
+ done
+ relink_command="(cd `pwd`; $relink_command)"
+ relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+ fi
+
+ # Quote $echo for shipping.
+ if test "X$echo" = "X$SHELL $0 --fallback-echo"; then
+ case $0 in
+ [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";;
+ *) qecho="$SHELL `pwd`/$0 --fallback-echo";;
+ esac
+ qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
+ else
+ qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
+ fi
+
+ # Only actually do things if our run command is non-null.
+ if test -z "$run"; then
+ # win32 will think the script is a binary if it has
+ # a .exe suffix, so we strip it off here.
+ case $output in
+ *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
+ esac
+ # test for cygwin because mv fails w/o .exe extensions
+ case $host in
+ *cygwin*)
+ exeext=.exe
+ outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
+ *) exeext= ;;
+ esac
+ case $host in
+ *cygwin* | *mingw* )
+ cwrappersource=`$echo ${objdir}/lt-${output}.c`
+ cwrapper=`$echo ${output}.exe`
+ $rm $cwrappersource $cwrapper
+ trap "$rm $cwrappersource $cwrapper; exit 1" 1 2 15
+
+ cat > $cwrappersource <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+ Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+
+ The $output program cannot be directly executed until all the libtool
+ libraries that it depends on are installed.
+
+ This wrapper executable should never be moved out of the build directory.
+ If it is, it will not operate correctly.
+
+ Currently, it simply execs the wrapper *script* "/bin/sh $output",
+ but could eventually absorb all of the scripts functionality and
+ exec $objdir/$outputname directly.
+*/
+EOF
+ cat >> $cwrappersource<<"EOF"
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef DIR_SEPARATOR
+#define DIR_SEPARATOR '/'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+ defined (__OS2__)
+#define HAVE_DOS_BASED_FILE_SYSTEM
+#ifndef DIR_SEPARATOR_2
+#define DIR_SEPARATOR_2 '\\'
+#endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+ if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+const char *program_name = NULL;
+
+void * xmalloc (size_t num);
+char * xstrdup (const char *string);
+char * basename (const char *name);
+char * fnqualify(const char *path);
+char * strendzap(char *str, const char *pat);
+void lt_fatal (const char *message, ...);
+
+int
+main (int argc, char *argv[])
+{
+ char **newargz;
+ int i;
+
+ program_name = (char *) xstrdup ((char *) basename (argv[0]));
+ newargz = XMALLOC(char *, argc+2);
+EOF
+
+ cat >> $cwrappersource <<EOF
+ newargz[0] = "$SHELL";
+EOF
+
+ cat >> $cwrappersource <<"EOF"
+ newargz[1] = fnqualify(argv[0]);
+ /* we know the script has the same name, without the .exe */
+ /* so make sure newargz[1] doesn't end in .exe */
+ strendzap(newargz[1],".exe");
+ for (i = 1; i < argc; i++)
+ newargz[i+1] = xstrdup(argv[i]);
+ newargz[argc+1] = NULL;
+EOF
+
+ cat >> $cwrappersource <<EOF
+ execv("$SHELL",newargz);
+EOF
+
+ cat >> $cwrappersource <<"EOF"
+}
+
+void *
+xmalloc (size_t num)
+{
+ void * p = (void *) malloc (num);
+ if (!p)
+ lt_fatal ("Memory exhausted");
+
+ return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+ return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
+;
+}
+
+char *
+basename (const char *name)
+{
+ const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ /* Skip over the disk name in MSDOS pathnames. */
+ if (isalpha (name[0]) && name[1] == ':')
+ name += 2;
+#endif
+
+ for (base = name; *name; name++)
+ if (IS_DIR_SEPARATOR (*name))
+ base = name + 1;
+ return (char *) base;
+}
+
+char *
+fnqualify(const char *path)
+{
+ size_t size;
+ char *p;
+ char tmp[LT_PATHMAX + 1];
+
+ assert(path != NULL);
+
+ /* Is it qualified already? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ if (isalpha (path[0]) && path[1] == ':')
+ return xstrdup (path);
+#endif
+ if (IS_DIR_SEPARATOR (path[0]))
+ return xstrdup (path);
+
+ /* prepend the current directory */
+ /* doesn't handle '~' */
+ if (getcwd (tmp, LT_PATHMAX) == NULL)
+ lt_fatal ("getcwd failed");
+ size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
+ p = XMALLOC(char, size);
+ sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
+ return p;
+}
+
+char *
+strendzap(char *str, const char *pat)
+{
+ size_t len, patlen;
+
+ assert(str != NULL);
+ assert(pat != NULL);
+
+ len = strlen(str);
+ patlen = strlen(pat);
+
+ if (patlen <= len)
+ {
+ str += len - patlen;
+ if (strcmp(str, pat) == 0)
+ *str = '\0';
+ }
+ return str;
+}
+
+static void
+lt_error_core (int exit_status, const char * mode,
+ const char * message, va_list ap)
+{
+ fprintf (stderr, "%s: %s: ", program_name, mode);
+ vfprintf (stderr, message, ap);
+ fprintf (stderr, ".\n");
+
+ if (exit_status >= 0)
+ exit (exit_status);
+}
+
+void
+lt_fatal (const char *message, ...)
+{
+ va_list ap;
+ va_start (ap, message);
+ lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
+ va_end (ap);
+}
+EOF
+ # we should really use a build-platform specific compiler
+ # here, but OTOH, the wrappers (shell script and this C one)
+ # are only useful if you want to execute the "real" binary.
+ # Since the "real" binary is built for $host, then this
+ # wrapper might as well be built for $host, too.
+ $run $LTCC -s -o $cwrapper $cwrappersource
+ ;;
+ esac
+ $rm $output
+ trap "$rm $output; exit 1" 1 2 15
+
+ $echo > $output "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='${SED} -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+ # install mode needs the following variable:
+ notinst_deplibs='$notinst_deplibs'
+else
+ # When we are sourced in execute mode, \$file and \$echo are already set.
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ echo=\"$qecho\"
+ file=\"\$0\"
+ # Make sure echo works.
+ if test \"X\$1\" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+ elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
+ # Yippee, \$echo works!
+ :
+ else
+ # Restart under the correct shell, and then maybe \$echo will work.
+ exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+ fi
+ fi\
+"
+ $echo >> $output "\
+
+ # Find the directory that this script lives in.
+ thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+ test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+ # Follow symbolic links until we get to the real thisdir.
+ file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
+ while test -n \"\$file\"; do
+ destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+ # If there was a directory component, then change thisdir.
+ if test \"x\$destdir\" != \"x\$file\"; then
+ case \"\$destdir\" in
+ [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+ *) thisdir=\"\$thisdir/\$destdir\" ;;
+ esac
+ fi
+
+ file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+ file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
+ done
+
+ # Try to get the absolute directory name.
+ absdir=\`cd \"\$thisdir\" && pwd\`
+ test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+ if test "$fast_install" = yes; then
+ $echo >> $output "\
+ program=lt-'$outputname'$exeext
+ progdir=\"\$thisdir/$objdir\"
+
+ if test ! -f \"\$progdir/\$program\" || \\
+ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+ test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+ file=\"\$\$-\$program\"
+
+ if test ! -d \"\$progdir\"; then
+ $mkdir \"\$progdir\"
+ else
+ $rm \"\$progdir/\$file\"
+ fi"
+
+ $echo >> $output "\
+
+ # relink executable if necessary
+ if test -n \"\$relink_command\"; then
+ if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+ else
+ $echo \"\$relink_command_output\" >&2
+ $rm \"\$progdir/\$file\"
+ exit 1
+ fi
+ fi
+
+ $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+ { $rm \"\$progdir/\$program\";
+ $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+ $rm \"\$progdir/\$file\"
+ fi"
+ else
+ $echo >> $output "\
+ program='$outputname'
+ progdir=\"\$thisdir/$objdir\"
+"
+ fi
+
+ $echo >> $output "\
+
+ if test -f \"\$progdir/\$program\"; then"
+
+ # Export our shlibpath_var if we have one.
+ if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+ $echo >> $output "\
+ # Add our own library path to $shlibpath_var
+ $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+ # Some systems cannot cope with colon-terminated $shlibpath_var
+ # The second colon is a workaround for a bug in BeOS R4 sed
+ $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+ export $shlibpath_var
+"
+ fi
+
+ # fixup the dll searchpath if we need to.
+ if test -n "$dllsearchpath"; then
+ $echo >> $output "\
+ # Add the dll search path components to the executable PATH
+ PATH=$dllsearchpath:\$PATH
+"
+ fi
+
+ $echo >> $output "\
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ # Run the actual program with our arguments.
+"
+ case $host in
+ # Backslashes separate directories on plain windows
+ *-*-mingw | *-*-os2*)
+ $echo >> $output "\
+ exec \$progdir\\\\\$program \${1+\"\$@\"}
+"
+ ;;
+
+ *)
+ $echo >> $output "\
+ exec \$progdir/\$program \${1+\"\$@\"}
+"
+ ;;
+ esac
+ $echo >> $output "\
+ \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
+ exit 1
+ fi
+ else
+ # The program doesn't exist.
+ \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
+ \$echo \"This script is just a wrapper for \$program.\" 1>&2
+ $echo \"See the $PACKAGE documentation for more information.\" 1>&2
+ exit 1
+ fi
+fi\
+"
+ chmod +x $output
+ fi
+ exit 0
+ ;;
+ esac
+
+ # See if we need to build an old-fashioned archive.
+ for oldlib in $oldlibs; do
+
+ if test "$build_libtool_libs" = convenience; then
+ oldobjs="$libobjs_save"
+ addlibs="$convenience"
+ build_libtool_libs=no
+ else
+ if test "$build_libtool_libs" = module; then
+ oldobjs="$libobjs_save"
+ build_libtool_libs=no
+ else
+ oldobjs="$old_deplibs $non_pic_objects"
+ fi
+ addlibs="$old_convenience"
+ fi
+
+ if test -n "$addlibs"; then
+ gentop="$output_objdir/${outputname}x"
+ $show "${rm}r $gentop"
+ $run ${rm}r "$gentop"
+ $show "$mkdir $gentop"
+ $run $mkdir "$gentop"
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$gentop"; then
+ exit $status
+ fi
+ generated="$generated $gentop"
+
+ # Add in members from convenience archives.
+ for xlib in $addlibs; do
+ # Extract the objects.
+ case $xlib in
+ [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+ *) xabs=`pwd`"/$xlib" ;;
+ esac
+ xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+ xdir="$gentop/$xlib"
+
+ $show "${rm}r $xdir"
+ $run ${rm}r "$xdir"
+ $show "$mkdir $xdir"
+ $run $mkdir "$xdir"
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$xdir"; then
+ exit $status
+ fi
+ # We will extract separately just the conflicting names and we will no
+ # longer touch any unique names. It is faster to leave these extract
+ # automatically by $AR in one run.
+ $show "(cd $xdir && $AR x $xabs)"
+ $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+ if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
+ $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
+ $AR t "$xabs" | sort | uniq -cd | while read -r count name
+ do
+ i=1
+ while test "$i" -le "$count"
+ do
+ # Put our $i before any first dot (extension)
+ # Never overwrite any file
+ name_to="$name"
+ while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
+ do
+ name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
+ done
+ $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
+ $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
+ i=`expr $i + 1`
+ done
+ done
+ fi
+
+ oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
+ done
+ fi
+
+ # Do each command in the archive commands.
+ if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+ eval cmds=\"$old_archive_from_new_cmds\"
+ else
+ eval cmds=\"$old_archive_cmds\"
+
+ if len=`expr "X$cmds" : ".*"` &&
+ test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ :
+ else
+ # the command line is too long to link in one step, link in parts
+ $echo "using piecewise archive linking..."
+ save_RANLIB=$RANLIB
+ RANLIB=:
+ objlist=
+ concat_cmds=
+ save_oldobjs=$oldobjs
+ # GNU ar 2.10+ was changed to match POSIX; thus no paths are
+ # encoded into archives. This makes 'ar r' malfunction in
+ # this piecewise linking case whenever conflicting object
+ # names appear in distinct ar calls; check, warn and compensate.
+ if (for obj in $save_oldobjs
+ do
+ $echo "X$obj" | $Xsed -e 's%^.*/%%'
+ done | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2
+ $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2
+ AR_FLAGS=cq
+ fi
+ # Is there a better way of finding the last object in the list?
+ for obj in $save_oldobjs
+ do
+ last_oldobj=$obj
+ done
+ for obj in $save_oldobjs
+ do
+ oldobjs="$objlist $obj"
+ objlist="$objlist $obj"
+ eval test_cmds=\"$old_archive_cmds\"
+ if len=`expr "X$test_cmds" : ".*"` &&
+ test "$len" -le "$max_cmd_len"; then
+ :
+ else
+ # the above command should be used before it gets too long
+ oldobjs=$objlist
+ if test "$obj" = "$last_oldobj" ; then
+ RANLIB=$save_RANLIB
+ fi
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+ objlist=
+ fi
+ done
+ RANLIB=$save_RANLIB
+ oldobjs=$objlist
+ if test "X$oldobjs" = "X" ; then
+ eval cmds=\"\$concat_cmds\"
+ else
+ eval cmds=\"\$concat_cmds~$old_archive_cmds\"
+ fi
+ fi
+ fi
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ done
+
+ if test -n "$generated"; then
+ $show "${rm}r$generated"
+ $run ${rm}r$generated
+ fi
+
+ # Now create the libtool archive.
+ case $output in
+ *.la)
+ old_library=
+ test "$build_old_libs" = yes && old_library="$libname.$libext"
+ $show "creating $output"
+
+ # Preserve any variables that may affect compiler behavior
+ for var in $variables_saved_for_relink; do
+ if eval test -z \"\${$var+set}\"; then
+ relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
+ elif eval var_value=\$$var; test -z "$var_value"; then
+ relink_command="$var=; export $var; $relink_command"
+ else
+ var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
+ relink_command="$var=\"$var_value\"; export $var; $relink_command"
+ fi
+ done
+ # Quote the link command for shipping.
+ relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args @inst_prefix_dir@)"
+ relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+
+ # Only create the output if not a dry run.
+ if test -z "$run"; then
+ for installed in no yes; do
+ if test "$installed" = yes; then
+ if test -z "$install_libdir"; then
+ break
+ fi
+ output="$output_objdir/$outputname"i
+ # Replace all uninstalled libtool libraries with the installed ones
+ newdependency_libs=
+ for deplib in $dependency_libs; do
+ case $deplib in
+ *.la)
+ name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+ if test -z "$libdir"; then
+ $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
+ exit 1
+ fi
+ newdependency_libs="$newdependency_libs $libdir/$name"
+ ;;
+ *) newdependency_libs="$newdependency_libs $deplib" ;;
+ esac
+ done
+ dependency_libs="$newdependency_libs"
+ newdlfiles=
+ for lib in $dlfiles; do
+ name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ if test -z "$libdir"; then
+ $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+ exit 1
+ fi
+ newdlfiles="$newdlfiles $libdir/$name"
+ done
+ dlfiles="$newdlfiles"
+ newdlprefiles=
+ for lib in $dlprefiles; do
+ name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ if test -z "$libdir"; then
+ $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+ exit 1
+ fi
+ newdlprefiles="$newdlprefiles $libdir/$name"
+ done
+ dlprefiles="$newdlprefiles"
+ fi
+ $rm $output
+ # place dlname in correct position for cygwin
+ tdlname=$dlname
+ case $host,$output,$installed,$module,$dlname in
+ *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
+ esac
+ $echo > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+ if test "$installed" = no && test "$need_relink" = yes; then
+ $echo >> $output "\
+relink_command=\"$relink_command\""
+ fi
+ done
+ fi
+
+ # Do a symbolic link so that the libtool archive can be found in
+ # LD_LIBRARY_PATH before the program is installed.
+ $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
+ $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
+ ;;
+ esac
+ exit 0
+ ;;
+
+ # libtool install mode
+ install)
+ modename="$modename: install"
+
+ # There may be an optional sh(1) argument at the beginning of
+ # install_prog (especially on Windows NT).
+ if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+ # Allow the use of GNU shtool's install command.
+ $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then
+ # Aesthetically quote it.
+ arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
+ arg="\"$arg\""
+ ;;
+ esac
+ install_prog="$arg "
+ arg="$1"
+ shift
+ else
+ install_prog=
+ arg="$nonopt"
+ fi
+
+ # The real first argument should be the name of the installation program.
+ # Aesthetically quote it.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
+ arg="\"$arg\""
+ ;;
+ esac
+ install_prog="$install_prog$arg"
+
+ # We need to accept at least all the BSD install flags.
+ dest=
+ files=
+ opts=
+ prev=
+ install_type=
+ isdir=no
+ stripme=
+ for arg
+ do
+ if test -n "$dest"; then
+ files="$files $dest"
+ dest="$arg"
+ continue
+ fi
+
+ case $arg in
+ -d) isdir=yes ;;
+ -f) prev="-f" ;;
+ -g) prev="-g" ;;
+ -m) prev="-m" ;;
+ -o) prev="-o" ;;
+ -s)
+ stripme=" -s"
+ continue
+ ;;
+ -*) ;;
+
+ *)
+ # If the previous option needed an argument, then skip it.
+ if test -n "$prev"; then
+ prev=
+ else
+ dest="$arg"
+ continue
+ fi
+ ;;
+ esac
+
+ # Aesthetically quote the argument.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
+ arg="\"$arg\""
+ ;;
+ esac
+ install_prog="$install_prog $arg"
+ done
+
+ if test -z "$install_prog"; then
+ $echo "$modename: you must specify an install program" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ if test -n "$prev"; then
+ $echo "$modename: the \`$prev' option requires an argument" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ if test -z "$files"; then
+ if test -z "$dest"; then
+ $echo "$modename: no file or destination specified" 1>&2
+ else
+ $echo "$modename: you must specify a destination" 1>&2
+ fi
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Strip any trailing slash from the destination.
+ dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
+
+ # Check to see that the destination is a directory.
+ test -d "$dest" && isdir=yes
+ if test "$isdir" = yes; then
+ destdir="$dest"
+ destname=
+ else
+ destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$destdir" = "X$dest" && destdir=.
+ destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
+
+ # Not a directory, so check to see that there is only one file specified.
+ set dummy $files
+ if test "$#" -gt 2; then
+ $echo "$modename: \`$dest' is not a directory" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+ fi
+ case $destdir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ for file in $files; do
+ case $file in
+ *.lo) ;;
+ *)
+ $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ # This variable tells wrapper scripts just to set variables rather
+ # than running their programs.
+ libtool_install_magic="$magic"
+
+ staticlibs=
+ future_libdirs=
+ current_libdirs=
+ for file in $files; do
+
+ # Do each installation.
+ case $file in
+ *.$libext)
+ # Do the static libraries later.
+ staticlibs="$staticlibs $file"
+ ;;
+
+ *.la)
+ # Check to see that this really is a libtool archive.
+ if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+ else
+ $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ library_names=
+ old_library=
+ relink_command=
+ # If there is no directory component, then add one.
+ case $file in
+ */* | *\\*) . $file ;;
+ *) . ./$file ;;
+ esac
+
+ # Add the libdir to current_libdirs if it is the destination.
+ if test "X$destdir" = "X$libdir"; then
+ case "$current_libdirs " in
+ *" $libdir "*) ;;
+ *) current_libdirs="$current_libdirs $libdir" ;;
+ esac
+ else
+ # Note the libdir as a future libdir.
+ case "$future_libdirs " in
+ *" $libdir "*) ;;
+ *) future_libdirs="$future_libdirs $libdir" ;;
+ esac
+ fi
+
+ dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
+ test "X$dir" = "X$file/" && dir=
+ dir="$dir$objdir"
+
+ if test -n "$relink_command"; then
+ # Determine the prefix the user has applied to our future dir.
+ inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
+
+ # Don't allow the user to place us outside of our expected
+ # location b/c this prevents finding dependent libraries that
+ # are installed to the same prefix.
+ # At present, this check doesn't affect windows .dll's that
+ # are installed into $libdir/../bin (currently, that works fine)
+ # but it's something to keep an eye on.
+ if test "$inst_prefix_dir" = "$destdir"; then
+ $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
+ exit 1
+ fi
+
+ if test -n "$inst_prefix_dir"; then
+ # Stick the inst_prefix_dir data into the link command.
+ relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+ else
+ relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
+ fi
+
+ $echo "$modename: warning: relinking \`$file'" 1>&2
+ $show "$relink_command"
+ if $run eval "$relink_command"; then :
+ else
+ $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
+ exit 1
+ fi
+ fi
+
+ # See the names of the shared library.
+ set dummy $library_names
+ if test -n "$2"; then
+ realname="$2"
+ shift
+ shift
+
+ srcname="$realname"
+ test -n "$relink_command" && srcname="$realname"T
+
+ # Install the shared library and build the symlinks.
+ $show "$install_prog $dir/$srcname $destdir/$realname"
+ $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
+ if test -n "$stripme" && test -n "$striplib"; then
+ $show "$striplib $destdir/$realname"
+ $run eval "$striplib $destdir/$realname" || exit $?
+ fi
+
+ if test "$#" -gt 0; then
+ # Delete the old symlinks, and create new ones.
+ for linkname
+ do
+ if test "$linkname" != "$realname"; then
+ $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+ $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+ fi
+ done
+ fi
+
+ # Do each command in the postinstall commands.
+ lib="$destdir/$realname"
+ eval cmds=\"$postinstall_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ fi
+
+ # Install the pseudo-library for information purposes.
+ name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+ instname="$dir/$name"i
+ $show "$install_prog $instname $destdir/$name"
+ $run eval "$install_prog $instname $destdir/$name" || exit $?
+
+ # Maybe install the static library, too.
+ test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+ ;;
+
+ *.lo)
+ # Install (i.e. copy) a libtool object.
+
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+ destfile="$destdir/$destfile"
+ fi
+
+ # Deduce the name of the destination old-style object file.
+ case $destfile in
+ *.lo)
+ staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
+ ;;
+ *.$objext)
+ staticdest="$destfile"
+ destfile=
+ ;;
+ *)
+ $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+ esac
+
+ # Install the libtool object if requested.
+ if test -n "$destfile"; then
+ $show "$install_prog $file $destfile"
+ $run eval "$install_prog $file $destfile" || exit $?
+ fi
+
+ # Install the old object if enabled.
+ if test "$build_old_libs" = yes; then
+ # Deduce the name of the old-style object file.
+ staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
+
+ $show "$install_prog $staticobj $staticdest"
+ $run eval "$install_prog \$staticobj \$staticdest" || exit $?
+ fi
+ exit 0
+ ;;
+
+ *)
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+ destfile="$destdir/$destfile"
+ fi
+
+ # If the file is missing, and there is a .exe on the end, strip it
+ # because it is most likely a libtool script we actually want to
+ # install
+ stripped_ext=""
+ case $file in
+ *.exe)
+ if test ! -f "$file"; then
+ file=`$echo $file|${SED} 's,.exe$,,'`
+ stripped_ext=".exe"
+ fi
+ ;;
+ esac
+
+ # Do a test to see if this is really a libtool program.
+ case $host in
+ *cygwin*|*mingw*)
+ wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
+ ;;
+ *)
+ wrapper=$file
+ ;;
+ esac
+ if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
+ notinst_deplibs=
+ relink_command=
+
+ # To insure that "foo" is sourced, and not "foo.exe",
+ # finese the cygwin/MSYS system by explicitly sourcing "foo."
+ # which disallows the automatic-append-.exe behavior.
+ case $build in
+ *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
+ *) wrapperdot=${wrapper} ;;
+ esac
+ # If there is no directory component, then add one.
+ case $file in
+ */* | *\\*) . ${wrapperdot} ;;
+ *) . ./${wrapperdot} ;;
+ esac
+
+ # Check the variables that should have been set.
+ if test -z "$notinst_deplibs"; then
+ $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
+ exit 1
+ fi
+
+ finalize=yes
+ for lib in $notinst_deplibs; do
+ # Check to see that each library is installed.
+ libdir=
+ if test -f "$lib"; then
+ # If there is no directory component, then add one.
+ case $lib in
+ */* | *\\*) . $lib ;;
+ *) . ./$lib ;;
+ esac
+ fi
+ libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
+ if test -n "$libdir" && test ! -f "$libfile"; then
+ $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
+ finalize=no
+ fi
+ done
+
+ relink_command=
+ # To insure that "foo" is sourced, and not "foo.exe",
+ # finese the cygwin/MSYS system by explicitly sourcing "foo."
+ # which disallows the automatic-append-.exe behavior.
+ case $build in
+ *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
+ *) wrapperdot=${wrapper} ;;
+ esac
+ # If there is no directory component, then add one.
+ case $file in
+ */* | *\\*) . ${wrapperdot} ;;
+ *) . ./${wrapperdot} ;;
+ esac
+
+ outputname=
+ if test "$fast_install" = no && test -n "$relink_command"; then
+ if test "$finalize" = yes && test -z "$run"; then
+ tmpdir="/tmp"
+ test -n "$TMPDIR" && tmpdir="$TMPDIR"
+ tmpdir="$tmpdir/libtool-$$"
+ if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then :
+ else
+ $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
+ continue
+ fi
+ file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
+ outputname="$tmpdir/$file"
+ # Replace the output file specification.
+ relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+ $show "$relink_command"
+ if $run eval "$relink_command"; then :
+ else
+ $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
+ ${rm}r "$tmpdir"
+ continue
+ fi
+ file="$outputname"
+ else
+ $echo "$modename: warning: cannot relink \`$file'" 1>&2
+ fi
+ else
+ # Install the binary that we compiled earlier.
+ file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+ fi
+ fi
+
+ # remove .exe since cygwin /usr/bin/install will append another
+ # one anyways
+ case $install_prog,$host in
+ */usr/bin/install*,*cygwin*)
+ case $file:$destfile in
+ *.exe:*.exe)
+ # this is ok
+ ;;
+ *.exe:*)
+ destfile=$destfile.exe
+ ;;
+ *:*.exe)
+ destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
+ ;;
+ esac
+ ;;
+ esac
+ $show "$install_prog$stripme $file $destfile"
+ $run eval "$install_prog\$stripme \$file \$destfile" || exit $?
+ test -n "$outputname" && ${rm}r "$tmpdir"
+ ;;
+ esac
+ done
+
+ for file in $staticlibs; do
+ name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+
+ # Set up the ranlib parameters.
+ oldlib="$destdir/$name"
+
+ $show "$install_prog $file $oldlib"
+ $run eval "$install_prog \$file \$oldlib" || exit $?
+
+ if test -n "$stripme" && test -n "$striplib"; then
+ $show "$old_striplib $oldlib"
+ $run eval "$old_striplib $oldlib" || exit $?
+ fi
+
+ # Do each command in the postinstall commands.
+ eval cmds=\"$old_postinstall_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ done
+
+ if test -n "$future_libdirs"; then
+ $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
+ fi
+
+ if test -n "$current_libdirs"; then
+ # Maybe just do a dry run.
+ test -n "$run" && current_libdirs=" -n$current_libdirs"
+ exec_cmd='$SHELL $0 --finish$current_libdirs'
+ else
+ exit 0
+ fi
+ ;;
+
+ # libtool finish mode
+ finish)
+ modename="$modename: finish"
+ libdirs="$nonopt"
+ admincmds=
+
+ if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+ for dir
+ do
+ libdirs="$libdirs $dir"
+ done
+
+ for libdir in $libdirs; do
+ if test -n "$finish_cmds"; then
+ # Do each command in the finish commands.
+ eval cmds=\"$finish_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || admincmds="$admincmds
+ $cmd"
+ done
+ IFS="$save_ifs"
+ fi
+ if test -n "$finish_eval"; then
+ # Do the single finish_eval.
+ eval cmds=\"$finish_eval\"
+ $run eval "$cmds" || admincmds="$admincmds
+ $cmds"
+ fi
+ done
+ fi
+
+ # Exit here if they wanted silent mode.
+ test "$show" = : && exit 0
+
+ $echo "----------------------------------------------------------------------"
+ $echo "Libraries have been installed in:"
+ for libdir in $libdirs; do
+ $echo " $libdir"
+ done
+ $echo
+ $echo "If you ever happen to want to link against installed libraries"
+ $echo "in a given directory, LIBDIR, you must either use libtool, and"
+ $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+ $echo "flag during linking and do at least one of the following:"
+ if test -n "$shlibpath_var"; then
+ $echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
+ $echo " during execution"
+ fi
+ if test -n "$runpath_var"; then
+ $echo " - add LIBDIR to the \`$runpath_var' environment variable"
+ $echo " during linking"
+ fi
+ if test -n "$hardcode_libdir_flag_spec"; then
+ libdir=LIBDIR
+ eval flag=\"$hardcode_libdir_flag_spec\"
+
+ $echo " - use the \`$flag' linker flag"
+ fi
+ if test -n "$admincmds"; then
+ $echo " - have your system administrator run these commands:$admincmds"
+ fi
+ if test -f /etc/ld.so.conf; then
+ $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+ fi
+ $echo
+ $echo "See any operating system documentation about shared libraries for"
+ $echo "more information, such as the ld(1) and ld.so(8) manual pages."
+ $echo "----------------------------------------------------------------------"
+ exit 0
+ ;;
+
+ # libtool execute mode
+ execute)
+ modename="$modename: execute"
+
+ # The first argument is the command name.
+ cmd="$nonopt"
+ if test -z "$cmd"; then
+ $echo "$modename: you must specify a COMMAND" 1>&2
+ $echo "$help"
+ exit 1
+ fi
+
+ # Handle -dlopen flags immediately.
+ for file in $execute_dlfiles; do
+ if test ! -f "$file"; then
+ $echo "$modename: \`$file' is not a file" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ dir=
+ case $file in
+ *.la)
+ # Check to see that this really is a libtool archive.
+ if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+ else
+ $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Read the libtool library.
+ dlname=
+ library_names=
+
+ # If there is no directory component, then add one.
+ case $file in
+ */* | *\\*) . $file ;;
+ *) . ./$file ;;
+ esac
+
+ # Skip this library if it cannot be dlopened.
+ if test -z "$dlname"; then
+ # Warn if it was a shared library.
+ test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
+ continue
+ fi
+
+ dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$dir" = "X$file" && dir=.
+
+ if test -f "$dir/$objdir/$dlname"; then
+ dir="$dir/$objdir"
+ else
+ $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
+ exit 1
+ fi
+ ;;
+
+ *.lo)
+ # Just add the directory containing the .lo file.
+ dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$dir" = "X$file" && dir=.
+ ;;
+
+ *)
+ $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
+ continue
+ ;;
+ esac
+
+ # Get the absolute pathname.
+ absdir=`cd "$dir" && pwd`
+ test -n "$absdir" && dir="$absdir"
+
+ # Now add the directory to shlibpath_var.
+ if eval "test -z \"\$$shlibpath_var\""; then
+ eval "$shlibpath_var=\"\$dir\""
+ else
+ eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+ fi
+ done
+
+ # This variable tells wrapper scripts just to set shlibpath_var
+ # rather than running their programs.
+ libtool_execute_magic="$magic"
+
+ # Check if any of the arguments is a wrapper script.
+ args=
+ for file
+ do
+ case $file in
+ -*) ;;
+ *)
+ # Do a test to see if this is really a libtool program.
+ if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ # If there is no directory component, then add one.
+ case $file in
+ */* | *\\*) . $file ;;
+ *) . ./$file ;;
+ esac
+
+ # Transform arg to wrapped name.
+ file="$progdir/$program"
+ fi
+ ;;
+ esac
+ # Quote arguments (to preserve shell metacharacters).
+ file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
+ args="$args \"$file\""
+ done
+
+ if test -z "$run"; then
+ if test -n "$shlibpath_var"; then
+ # Export the shlibpath_var.
+ eval "export $shlibpath_var"
+ fi
+
+ # Restore saved environment variables
+ if test "${save_LC_ALL+set}" = set; then
+ LC_ALL="$save_LC_ALL"; export LC_ALL
+ fi
+ if test "${save_LANG+set}" = set; then
+ LANG="$save_LANG"; export LANG
+ fi
+
+ # Now prepare to actually exec the command.
+ exec_cmd="\$cmd$args"
+ else
+ # Display what would be done.
+ if test -n "$shlibpath_var"; then
+ eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
+ $echo "export $shlibpath_var"
+ fi
+ $echo "$cmd$args"
+ exit 0
+ fi
+ ;;
+
+ # libtool clean and uninstall mode
+ clean | uninstall)
+ modename="$modename: $mode"
+ rm="$nonopt"
+ files=
+ rmforce=
+ exit_status=0
+
+ # This variable tells wrapper scripts just to set variables rather
+ # than running their programs.
+ libtool_install_magic="$magic"
+
+ for arg
+ do
+ case $arg in
+ -f) rm="$rm $arg"; rmforce=yes ;;
+ -*) rm="$rm $arg" ;;
+ *) files="$files $arg" ;;
+ esac
+ done
+
+ if test -z "$rm"; then
+ $echo "$modename: you must specify an RM program" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ rmdirs=
+
+ origobjdir="$objdir"
+ for file in $files; do
+ dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$dir" = "X$file"; then
+ dir=.
+ objdir="$origobjdir"
+ else
+ objdir="$dir/$origobjdir"
+ fi
+ name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+ test "$mode" = uninstall && objdir="$dir"
+
+ # Remember objdir for removal later, being careful to avoid duplicates
+ if test "$mode" = clean; then
+ case " $rmdirs " in
+ *" $objdir "*) ;;
+ *) rmdirs="$rmdirs $objdir" ;;
+ esac
+ fi
+
+ # Don't error if the file doesn't exist and rm -f was used.
+ if (test -L "$file") >/dev/null 2>&1 \
+ || (test -h "$file") >/dev/null 2>&1 \
+ || test -f "$file"; then
+ :
+ elif test -d "$file"; then
+ exit_status=1
+ continue
+ elif test "$rmforce" = yes; then
+ continue
+ fi
+
+ rmfiles="$file"
+
+ case $name in
+ *.la)
+ # Possibly a libtool archive, so verify it.
+ if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ . $dir/$name
+
+ # Delete the libtool libraries and symlinks.
+ for n in $library_names; do
+ rmfiles="$rmfiles $objdir/$n"
+ done
+ test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+ test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+
+ if test "$mode" = uninstall; then
+ if test -n "$library_names"; then
+ # Do each command in the postuninstall commands.
+ eval cmds=\"$postuninstall_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd"
+ if test "$?" -ne 0 && test "$rmforce" != yes; then
+ exit_status=1
+ fi
+ done
+ IFS="$save_ifs"
+ fi
+
+ if test -n "$old_library"; then
+ # Do each command in the old_postuninstall commands.
+ eval cmds=\"$old_postuninstall_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd"
+ if test "$?" -ne 0 && test "$rmforce" != yes; then
+ exit_status=1
+ fi
+ done
+ IFS="$save_ifs"
+ fi
+ # FIXME: should reinstall the best remaining shared library.
+ fi
+ fi
+ ;;
+
+ *.lo)
+ # Possibly a libtool object, so verify it.
+ if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+
+ # Read the .lo file
+ . $dir/$name
+
+ # Add PIC object to the list of files to remove.
+ if test -n "$pic_object" \
+ && test "$pic_object" != none; then
+ rmfiles="$rmfiles $dir/$pic_object"
+ fi
+
+ # Add non-PIC object to the list of files to remove.
+ if test -n "$non_pic_object" \
+ && test "$non_pic_object" != none; then
+ rmfiles="$rmfiles $dir/$non_pic_object"
+ fi
+ fi
+ ;;
+
+ *)
+ if test "$mode" = clean ; then
+ noexename=$name
+ case $file in
+ *.exe)
+ file=`$echo $file|${SED} 's,.exe$,,'`
+ noexename=`$echo $name|${SED} 's,.exe$,,'`
+ # $file with .exe has already been added to rmfiles,
+ # add $file without .exe
+ rmfiles="$rmfiles $file"
+ ;;
+ esac
+ # Do a test to see if this is a libtool program.
+ if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ relink_command=
+ . $dir/$noexename
+
+ # note $name still contains .exe if it was in $file originally
+ # as does the version of $file that was added into $rmfiles
+ rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
+ if test "$fast_install" = yes && test -n "$relink_command"; then
+ rmfiles="$rmfiles $objdir/lt-$name"
+ fi
+ if test "X$noexename" != "X$name" ; then
+ rmfiles="$rmfiles $objdir/lt-${noexename}.c"
+ fi
+ fi
+ fi
+ ;;
+ esac
+ $show "$rm $rmfiles"
+ $run $rm $rmfiles || exit_status=1
+ done
+ objdir="$origobjdir"
+
+ # Try to remove the ${objdir}s in the directories where we deleted files
+ for dir in $rmdirs; do
+ if test -d "$dir"; then
+ $show "rmdir $dir"
+ $run rmdir $dir >/dev/null 2>&1
+ fi
+ done
+
+ exit $exit_status
+ ;;
+
+ "")
+ $echo "$modename: you must specify a MODE" 1>&2
+ $echo "$generic_help" 1>&2
+ exit 1
+ ;;
+ esac
+
+ if test -z "$exec_cmd"; then
+ $echo "$modename: invalid operation mode \`$mode'" 1>&2
+ $echo "$generic_help" 1>&2
+ exit 1
+ fi
+fi # test -z "$show_help"
+
+if test -n "$exec_cmd"; then
+ eval exec $exec_cmd
+ exit 1
+fi
+
+# We need to display help for each of the modes.
+case $mode in
+"") $echo \
+"Usage: $modename [OPTION]... [MODE-ARG]...
+
+Provide generalized library-building support services.
+
+ --config show all configuration variables
+ --debug enable verbose shell tracing
+-n, --dry-run display commands without modifying any files
+ --features display basic configuration information and exit
+ --finish same as \`--mode=finish'
+ --help display this help message and exit
+ --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS]
+ --quiet same as \`--silent'
+ --silent don't print informational messages
+ --tag=TAG use configuration variables from tag TAG
+ --version print version information
+
+MODE must be one of the following:
+
+ clean remove files from the build directory
+ compile compile a source file into a libtool object
+ execute automatically set library path, then run a program
+ finish complete the installation of libtool libraries
+ install install libraries or executables
+ link create a library or an executable
+ uninstall remove libraries from an installed directory
+
+MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for
+a more detailed description of MODE.
+
+Report bugs to <bug-libtool@gnu.org>."
+ exit 0
+ ;;
+
+clean)
+ $echo \
+"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+ ;;
+
+compile)
+ $echo \
+"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+ -o OUTPUT-FILE set the output file name to OUTPUT-FILE
+ -prefer-pic try to building PIC objects only
+ -prefer-non-pic try to building non-PIC objects only
+ -static always build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+ ;;
+
+execute)
+ $echo \
+"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+ -dlopen FILE add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+ ;;
+
+finish)
+ $echo \
+"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges. Use
+the \`--dry-run' option if you just want to see what would be executed."
+ ;;
+
+install)
+ $echo \
+"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command. The first component should be
+either the \`install' or \`cp' program.
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+ ;;
+
+link)
+ $echo \
+"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+ -all-static do not do any dynamic linking at all
+ -avoid-version do not add a version suffix if possible
+ -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
+ -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
+ -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+ -export-symbols SYMFILE
+ try to export only the symbols listed in SYMFILE
+ -export-symbols-regex REGEX
+ try to export only the symbols matching REGEX
+ -LLIBDIR search LIBDIR for required installed libraries
+ -lNAME OUTPUT-FILE requires the installed library libNAME
+ -module build a library that can dlopened
+ -no-fast-install disable the fast-install mode
+ -no-install link a not-installable executable
+ -no-undefined declare that a library does not refer to external symbols
+ -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
+ -objectlist FILE Use a list of object files found in FILE to specify objects
+ -release RELEASE specify package release information
+ -rpath LIBDIR the created library will eventually be installed in LIBDIR
+ -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
+ -static do not do any dynamic linking of libtool libraries
+ -version-info CURRENT[:REVISION[:AGE]]
+ specify library version info [each variable defaults to 0]
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename. Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+ ;;
+
+uninstall)
+ $echo \
+"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+ ;;
+
+*)
+ $echo "$modename: invalid operation mode \`$mode'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+esac
+
+$echo
+$echo "Try \`$modename --help' for more information about other modes."
+
+exit 0
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries. Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them. This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration. But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+build_libtool_libs=no
+build_old_libs=yes
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
diff --git a/nx-X11/lib/Xft/missing b/nx-X11/lib/Xft/missing
new file mode 100755
index 000000000..fc54c64ec
--- /dev/null
+++ b/nx-X11/lib/Xft/missing
@@ -0,0 +1,336 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+fi
+
+run=:
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+ configure_ac=configure.ac
+else
+ configure_ac=configure.in
+fi
+
+case "$1" in
+--run)
+ # Try to run requested program, and just exit if it succeeds.
+ run=
+ shift
+ "$@" && exit 0
+ ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case "$1" in
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+ --run try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+ aclocal touch file \`aclocal.m4'
+ autoconf touch file \`configure'
+ autoheader touch file \`config.h.in'
+ automake touch all \`Makefile.in' files
+ bison create \`y.tab.[ch]', if possible, from existing .[ch]
+ flex create \`lex.yy.c', if possible, from existing .c
+ help2man touch the output file
+ lex create \`lex.yy.c', if possible, from existing .c
+ makeinfo touch the output file
+ tar try tar, gnutar, gtar, then tar without non-portable flags
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing 0.4 - GNU automake"
+ ;;
+
+ -*)
+ echo 1>&2 "$0: Unknown \`$1' option"
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+ ;;
+
+ aclocal*)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acinclude.m4' or \`${configure_ac}'. You might want
+ to install the \`Automake' and \`Perl' packages. Grab them from
+ any GNU archive site."
+ touch aclocal.m4
+ ;;
+
+ autoconf)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`${configure_ac}'. You might want to install the
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
+ archive site."
+ touch configure
+ ;;
+
+ autoheader)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acconfig.h' or \`${configure_ac}'. You might want
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
+ from any GNU archive site."
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+ test -z "$files" && files="config.h"
+ touch_files=
+ for f in $files; do
+ case "$f" in
+ *:*) touch_files="$touch_files "`echo "$f" |
+ sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+ *) touch_files="$touch_files $f.in";;
+ esac
+ done
+ touch $touch_files
+ ;;
+
+ automake*)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+ You might want to install the \`Automake' and \`Perl' packages.
+ Grab them from any GNU archive site."
+ find . -type f -name Makefile.am -print |
+ sed 's/\.am$/.in/' |
+ while read f; do touch "$f"; done
+ ;;
+
+ autom4te)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+ system. You might have modified some files without having the
+ proper tools for further handling them.
+ You can get \`$1' as part of \`Autoconf' from any GNU
+ archive site."
+
+ file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
+ test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo "#! /bin/sh"
+ echo "# Created by GNU Automake missing as a replacement of"
+ echo "# $ $@"
+ echo "exit 0"
+ chmod +x $file
+ exit 1
+ fi
+ ;;
+
+ bison|yacc)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.y' file. You may need the \`Bison' package
+ in order for those modifications to take effect. You can get
+ \`Bison' from any GNU archive site."
+ rm -f y.tab.c y.tab.h
+ if [ $# -ne 1 ]; then
+ eval LASTARG="\${$#}"
+ case "$LASTARG" in
+ *.y)
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" y.tab.c
+ fi
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" y.tab.h
+ fi
+ ;;
+ esac
+ fi
+ if [ ! -f y.tab.h ]; then
+ echo >y.tab.h
+ fi
+ if [ ! -f y.tab.c ]; then
+ echo 'main() { return 0; }' >y.tab.c
+ fi
+ ;;
+
+ lex|flex)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.l' file. You may need the \`Flex' package
+ in order for those modifications to take effect. You can get
+ \`Flex' from any GNU archive site."
+ rm -f lex.yy.c
+ if [ $# -ne 1 ]; then
+ eval LASTARG="\${$#}"
+ case "$LASTARG" in
+ *.l)
+ SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" lex.yy.c
+ fi
+ ;;
+ esac
+ fi
+ if [ ! -f lex.yy.c ]; then
+ echo 'main() { return 0; }' >lex.yy.c
+ fi
+ ;;
+
+ help2man)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a dependency of a manual page. You may need the
+ \`Help2man' package in order for those modifications to take
+ effect. You can get \`Help2man' from any GNU archive site."
+
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ if test -z "$file"; then
+ file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
+ fi
+ if [ -f "$file" ]; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo ".ab help2man is required to generate this page"
+ exit 1
+ fi
+ ;;
+
+ makeinfo)
+ if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
+ # We have makeinfo, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.texi' or \`.texinfo' file, or any other file
+ indirectly affecting the aspect of the manual. The spurious
+ call might also be the consequence of using a buggy \`make' (AIX,
+ DU, IRIX). You might want to install the \`Texinfo' package or
+ the \`GNU make' package. Grab either from any GNU archive site."
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ if test -z "$file"; then
+ file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+ fi
+ touch $file
+ ;;
+
+ tar)
+ shift
+ if test -n "$run"; then
+ echo 1>&2 "ERROR: \`tar' requires --run"
+ exit 1
+ fi
+
+ # We have already tried tar in the generic part.
+ # Look for gnutar/gtar before invocation to avoid ugly error
+ # messages.
+ if (gnutar --version > /dev/null 2>&1); then
+ gnutar "$@" && exit 0
+ fi
+ if (gtar --version > /dev/null 2>&1); then
+ gtar "$@" && exit 0
+ fi
+ firstarg="$1"
+ if shift; then
+ case "$firstarg" in
+ *o*)
+ firstarg=`echo "$firstarg" | sed s/o//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ case "$firstarg" in
+ *h*)
+ firstarg=`echo "$firstarg" | sed s/h//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ fi
+
+ echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+ You may want to install GNU tar or Free paxutils, or check the
+ command line arguments."
+ exit 1
+ ;;
+
+ *)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+ system. You might have modified some files without having the
+ proper tools for further handling them. Check the \`README' file,
+ it often tells you about the needed prerequisites for installing
+ this package. You may also peek at any GNU archive site, in case
+ some other package would contain this missing \`$1' program."
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/nx-X11/lib/Xft/mkinstalldirs b/nx-X11/lib/Xft/mkinstalldirs
new file mode 100755
index 000000000..d2d5f21b6
--- /dev/null
+++ b/nx-X11/lib/Xft/mkinstalldirs
@@ -0,0 +1,111 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+errstatus=0
+dirmode=""
+
+usage="\
+Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
+
+# process command line arguments
+while test $# -gt 0 ; do
+ case $1 in
+ -h | --help | --h*) # -h for help
+ echo "$usage" 1>&2
+ exit 0
+ ;;
+ -m) # -m PERM arg
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ dirmode=$1
+ shift
+ ;;
+ --) # stop option processing
+ shift
+ break
+ ;;
+ -*) # unknown option
+ echo "$usage" 1>&2
+ exit 1
+ ;;
+ *) # first non-opt arg
+ break
+ ;;
+ esac
+done
+
+for file
+do
+ if test -d "$file"; then
+ shift
+ else
+ break
+ fi
+done
+
+case $# in
+ 0) exit 0 ;;
+esac
+
+case $dirmode in
+ '')
+ if mkdir -p -- . 2>/dev/null; then
+ echo "mkdir -p -- $*"
+ exec mkdir -p -- "$@"
+ fi
+ ;;
+ *)
+ if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
+ echo "mkdir -m $dirmode -p -- $*"
+ exec mkdir -m "$dirmode" -p -- "$@"
+ fi
+ ;;
+esac
+
+for file
+do
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+ shift
+
+ pathcomp=
+ for d
+ do
+ pathcomp="$pathcomp$d"
+ case $pathcomp in
+ -*) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp"
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ else
+ if test ! -z "$dirmode"; then
+ echo "chmod $dirmode $pathcomp"
+ lasterr=""
+ chmod "$dirmode" "$pathcomp" || lasterr=$?
+
+ if test ! -z "$lasterr"; then
+ errstatus=$lasterr
+ fi
+ fi
+ fi
+ fi
+
+ pathcomp="$pathcomp/"
+ done
+done
+
+exit $errstatus
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# End:
+# mkinstalldirs ends here
diff --git a/nx-X11/lib/Xft/xft-config.1.in b/nx-X11/lib/Xft/xft-config.1.in
new file mode 100644
index 000000000..904c2439a
--- /dev/null
+++ b/nx-X11/lib/Xft/xft-config.1.in
@@ -0,0 +1,120 @@
+.\" Copyright 2005 Branden Robinson
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining a copy
+.\" of this document (the "Document"), to deal in the Document without
+.\" restriction, including without limitation the rights to use, copy, modify,
+.\" merge, publish, distribute, sublicense, and/or sell copies of the Document,
+.\" and to permit persons to whom the Document is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included in
+.\" all copies or substantial portions of the Document.
+.\"
+.\" THE DOCUMENT 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 AUTHOR(S) OR COPYRIGHT HOLDER(S) 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 DOCUMENT OR THE USE OR OTHER
+.\" DEALINGS IN THE DOCUMENT.
+.TH xft-config 1 "Version @VERSION@" "Xft"
+.SH NAME
+xft\-config \- report Xft version, compiler, linker, and/or installation \
+directory information
+.SH SYNOPSIS
+.B xft\-config
+{
+.BR \-\-exec\-prefix [ =\fIlocal_prefix\fR ]
+|
+.BR \-\-prefix [ =\fIlocal_prefix\fR ]
+|
+.B \-\-cflags
+|
+.B \-\-libs
+} ...
+.PP
+.B xft\-config \-\-version
+.SH DESCRIPTION
+.B xft\-config
+reports information of interest to users and developers about the installed
+version of the X FreeType library,
+.BR Xft (3).
+Depending on how it is invoked,
+.B xft\-config
+reports the installed version of Xft, the compiler and linker flags
+that are required to successfully compile and link C (or C-compatible) code
+that uses the library, and/or the directories used by the GNU Autotools to
+install its files.
+Note that if the system's installed version of Xft came from an OS vendor
+or other third party, the actual location of its files may differ from
+those reported by
+.BR xft\-config .
+The system adminstrator can also relocate Xft's files.
+.PP
+If invoked without any arguments,
+.B xft\-config
+will print a usage message on standard error and exit.
+.SH OPTIONS
+.TP
+.B \-\-cflags
+Report the compiler flags that are required to compile code that uses Xft
+symbols.
+.TP
+.BR \-\-exec\-prefix [ =\fIlocal_prefix\fR ]
+If specified without the parameter
+.IR local_prefix ,
+report the file specification prefix that Xft uses for installation of
+executable files.
+If
+.I local_prefix
+is specified, it is used instead of the file specification prefix used for
+installation of executable files by Xft and the value of the option
+argument specified with
+.BR \-\-prefix ,
+if any, when compile and linker flags are reported (with
+.B \-\-cflags
+and
+.BR \-\-libs ,
+respectively).
+.TP
+.B \-\-libs
+Report the linker flags that are required to link code that uses Xft
+symbols.
+.TP
+.BR \-\-prefix [ =\fIlocal_prefix\fR ]
+If specified without the parameter
+.IR local_prefix ,
+report the file specification prefix that Xft uses for installation of
+files.
+If
+.I local_prefix
+is specified, it is used instead of the file specification prefix used for
+installation of files by Xft when compile and linker flags are reported
+(with
+.B \-\-cflags
+and
+.BR \-\-libs ,
+respectively); also see
+.BR \-\-exec\-prefix .
+.TP
+.B \-\-version
+Report the version of the Xft library installed on the system and exit.
+.SH OPERANDS
+.B xft\-config
+does not recognize any non-option arguments.
+At least one option must be specified.
+.SH "EXIT STATUS"
+.TP
+0
+Information was successfully reported.
+.TP
+1
+.B xft\-config
+was invoked with invalid arguments, or no arguments at all.
+.SH AUTHOR
+.B xft\-config
+was written by Keith Packard.
+This manual page was written by Branden Robinson.
+.SH "SEE ALSO"
+.BR Xft (3)
+.\" vim:set et tw=80
diff --git a/nx-X11/lib/Xft/xft-config.in b/nx-X11/lib/Xft/xft-config.in
new file mode 100644
index 000000000..549b73ae0
--- /dev/null
+++ b/nx-X11/lib/Xft/xft-config.in
@@ -0,0 +1,100 @@
+#! /bin/sh
+
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
+libdir="@libdir@"
+includedir="@includedir@"
+version="@VERSION@"
+freetypelibs="@FREETYPE_LIBS@"
+freetypecflags="@FREETYPE_CFLAGS@"
+fontconfiglibs="@FONTCONFIG_LIBS@"
+fontconfigcflags="@FONTCONFIG_CFLAGS@"
+xrenderlibs="@XRENDER_LIBS@"
+xrendercflags="@XRENDER_CFLAGS@"
+
+usage()
+{
+ cat <<EOF
+Usage: xft-config [OPTIONS] [LIBRARIES]
+Options:
+ [--prefix[=DIR]]
+ [--exec-prefix[=DIR]]
+ [--version]
+ [--libs]
+ [--cflags]
+EOF
+ exit $1
+}
+
+if test $# -eq 0 ; then
+ usage 1 1>&2
+fi
+
+while test $# -gt 0 ; do
+ case "$1" in
+ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
+ esac
+
+ case $1 in
+ --prefix=*)
+ prefix=$optarg
+ local_prefix=yes
+ ;;
+ --prefix)
+ echo_prefix=yes
+ ;;
+ --exec-prefix=*)
+ exec_prefix=$optarg
+ exec_prefix_set=yes
+ local_prefix=yes
+ ;;
+ --exec-prefix)
+ echo_exec_prefix=yes
+ ;;
+ --version)
+ echo $version
+ exit 0
+ ;;
+ --cflags)
+ echo_cflags=yes
+ ;;
+ --libs)
+ echo_libs=yes
+ ;;
+ *)
+ usage 1 1>&2
+ ;;
+ esac
+ shift
+done
+
+if test "$local_prefix" = "yes" ; then
+ if test "$exec_prefix_set" != "yes" ; then
+ exec_prefix=$prefix
+ fi
+fi
+
+if test "$echo_prefix" = "yes" ; then
+ echo $prefix
+fi
+
+if test "$echo_exec_prefix" = "yes" ; then
+ echo $exec_prefix
+fi
+
+if test "$echo_cflags" = "yes" ; then
+ cflags="-I${includedir} ${freetypecflags} ${fontconfigcflags} ${xrendercflags}"
+ echo $cflags
+fi
+
+if test "$echo_libs" = "yes" ; then
+ libs="-lXft -lX11 ${freetypelibs} ${fontconfiglibs} ${xrenderlibs}"
+ if test "${libdir}" != "/usr/lib" ; then
+ echo -L${libdir} $libs
+ else
+ echo $libs
+ fi
+fi
+
+# EOF
diff --git a/nx-X11/lib/Xft/xft.pc.in b/nx-X11/lib/Xft/xft.pc.in
new file mode 100644
index 000000000..45db8813b
--- /dev/null
+++ b/nx-X11/lib/Xft/xft.pc.in
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Xft
+Description: X FreeType library
+Version: @VERSION@
+Requires: xrender, fontconfig, freetype2
+Requires.private: xrender, fontconfig, freetype2
+Cflags: -I${includedir}
+Libs: -L${libdir} -lXft
diff --git a/nx-X11/lib/Xft/xftcolor.c b/nx-X11/lib/Xft/xftcolor.c
new file mode 100644
index 000000000..1a28d63fa
--- /dev/null
+++ b/nx-X11/lib/Xft/xftcolor.c
@@ -0,0 +1,125 @@
+/*
+ * $Id: xftcolor.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+Bool
+XftColorAllocName (Display *dpy,
+ _Xconst Visual *visual,
+ Colormap cmap,
+ _Xconst char *name,
+ XftColor *result)
+{
+ XColor screen, exact;
+
+ if (!XAllocNamedColor (dpy, cmap, name, &screen, &exact))
+ {
+ /* XXX stick standard colormap stuff here */
+ return False;
+ }
+
+ result->pixel = screen.pixel;
+ result->color.red = exact.red;
+ result->color.green = exact.green;
+ result->color.blue = exact.blue;
+ result->color.alpha = 0xffff;
+ return True;
+}
+
+static short
+maskbase (unsigned long m)
+{
+ short i;
+
+ if (!m)
+ return 0;
+ i = 0;
+ while (!(m&1))
+ {
+ m>>=1;
+ i++;
+ }
+ return i;
+}
+
+static short
+masklen (unsigned long m)
+{
+ unsigned long y;
+
+ y = (m >> 1) &033333333333;
+ y = m - y - ((y >>1) & 033333333333);
+ return (short) (((y + (y >> 3)) & 030707070707) % 077);
+}
+
+Bool
+XftColorAllocValue (Display *dpy,
+ Visual *visual,
+ Colormap cmap,
+ _Xconst XRenderColor *color,
+ XftColor *result)
+{
+ if (visual->class == TrueColor)
+ {
+ int red_shift, red_len;
+ int green_shift, green_len;
+ int blue_shift, blue_len;
+
+ red_shift = maskbase (visual->red_mask);
+ red_len = masklen (visual->red_mask);
+ green_shift = maskbase (visual->green_mask);
+ green_len = masklen (visual->green_mask);
+ blue_shift = maskbase (visual->blue_mask);
+ blue_len = masklen (visual->blue_mask);
+ result->pixel = (((color->red >> (16 - red_len)) << red_shift) |
+ ((color->green >> (16 - green_len)) << green_shift) |
+ ((color->blue >> (16 - blue_len)) << blue_shift));
+ }
+ else
+ {
+ XColor xcolor;
+
+ xcolor.red = color->red;
+ xcolor.green = color->green;
+ xcolor.blue = color->blue;
+ if (!XAllocColor (dpy, cmap, &xcolor))
+ return False;
+ result->pixel = xcolor.pixel;
+ }
+ result->color.red = color->red;
+ result->color.green = color->green;
+ result->color.blue = color->blue;
+ result->color.alpha = color->alpha;
+ return True;
+}
+
+void
+XftColorFree (Display *dpy,
+ Visual *visual,
+ Colormap cmap,
+ XftColor *color)
+{
+ if (visual->class != TrueColor)
+ XFreeColors (dpy, cmap, &color->pixel, 1, 0);
+}
diff --git a/nx-X11/lib/Xft/xftcore.c b/nx-X11/lib/Xft/xftcore.c
new file mode 100644
index 000000000..1052a1d09
--- /dev/null
+++ b/nx-X11/lib/Xft/xftcore.c
@@ -0,0 +1,1375 @@
+/*
+ * $Id: xftcore.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+void
+XftRectCore (XftDraw *draw,
+ _Xconst XftColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height)
+{
+ if (color->color.alpha >= 0x8000)
+ {
+ XSetForeground (draw->dpy, draw->core.gc, color->pixel);
+ XFillRectangle (draw->dpy, draw->drawable, draw->core.gc,
+ x, y, width, height);
+ }
+}
+
+/*
+ * Use the core protocol to draw the glyphs
+ */
+
+static void
+_XftSharpGlyphMono (XftDraw *draw,
+ XftGlyph *glyph,
+ int x,
+ int y)
+{
+ unsigned char *srcLine = glyph->bitmap, *src;
+ unsigned char bits, bitsMask;
+ int width = glyph->metrics.width;
+ int stride = ((width + 31) & ~31) >> 3;
+ int height = glyph->metrics.height;
+ int w;
+ int xspan, lenspan;
+
+ x -= glyph->metrics.x;
+ y -= glyph->metrics.y;
+ while (height--)
+ {
+ src = srcLine;
+ srcLine += stride;
+ w = width;
+
+ bitsMask = 0x80; /* FreeType is always MSB first */
+ bits = *src++;
+
+ xspan = x;
+ while (w)
+ {
+ if (bits & bitsMask)
+ {
+ lenspan = 0;
+ do
+ {
+ lenspan++;
+ if (lenspan == w)
+ break;
+ bitsMask = bitsMask >> 1;
+ if (!bitsMask)
+ {
+ bits = *src++;
+ bitsMask = 0x80;
+ }
+ } while (bits & bitsMask);
+ XFillRectangle (draw->dpy, draw->drawable,
+ draw->core.gc, xspan, y, lenspan, 1);
+ xspan += lenspan;
+ w -= lenspan;
+ }
+ else
+ {
+ do
+ {
+ w--;
+ xspan++;
+ if (!w)
+ break;
+ bitsMask = bitsMask >> 1;
+ if (!bitsMask)
+ {
+ bits = *src++;
+ bitsMask = 0x80;
+ }
+ } while (!(bits & bitsMask));
+ }
+ }
+ y++;
+ }
+}
+
+/*
+ * Draw solid color text from an anti-aliased bitmap. This is a
+ * fallback for cases where a particular drawable has no AA code
+ */
+static void
+_XftSharpGlyphGray (XftDraw *draw,
+ XftGlyph *glyph,
+ int x,
+ int y)
+{
+ unsigned char *srcLine = glyph->bitmap, *src, bits;
+ int width = glyph->metrics.width;
+ int stride = ((width + 3) & ~3);
+ int height = glyph->metrics.height;
+ int w;
+ int xspan, lenspan;
+
+ x -= glyph->metrics.x;
+ y -= glyph->metrics.y;
+ while (height--)
+ {
+ src = srcLine;
+ srcLine += stride;
+ w = width;
+
+ bits = *src++;
+ xspan = x;
+ while (w)
+ {
+ if (bits >= 0x80)
+ {
+ lenspan = 0;
+ do
+ {
+ lenspan++;
+ if (lenspan == w)
+ break;
+ bits = *src++;
+ } while (bits >= 0x80);
+ XFillRectangle (draw->dpy, draw->drawable,
+ draw->core.gc, xspan, y, lenspan, 1);
+ xspan += lenspan;
+ w -= lenspan;
+ }
+ else
+ {
+ do
+ {
+ w--;
+ xspan++;
+ if (!w)
+ break;
+ bits = *src++;
+ } while (bits < 0x80);
+ }
+ }
+ y++;
+ }
+}
+
+static void
+_XftSharpGlyphRgba (XftDraw *draw,
+ XftGlyph *glyph,
+ int x,
+ int y)
+{
+ CARD32 *srcLine = glyph->bitmap, *src, bits;
+ int width = glyph->metrics.width;
+ int stride = ((width + 3) & ~3);
+ int height = glyph->metrics.height;
+ int w;
+ int xspan, lenspan;
+
+ x -= glyph->metrics.x;
+ y -= glyph->metrics.y;
+ while (height--)
+ {
+ src = srcLine;
+ srcLine += stride;
+ w = width;
+
+ bits = *src++;
+ xspan = x;
+ while (w)
+ {
+ if (bits >= 0x80000000)
+ {
+ lenspan = 0;
+ do
+ {
+ lenspan++;
+ if (lenspan == w)
+ break;
+ bits = *src++;
+ } while (bits >= 0x80000000);
+ XFillRectangle (draw->dpy, draw->drawable,
+ draw->core.gc, xspan, y, lenspan, 1);
+ xspan += lenspan;
+ w -= lenspan;
+ }
+ else
+ {
+ do
+ {
+ w--;
+ xspan++;
+ if (!w)
+ break;
+ bits = *src++;
+ } while (bits < 0x80000000);
+ }
+ }
+ y++;
+ }
+}
+
+typedef void (*XftSharpGlyph) (XftDraw *draw,
+ XftGlyph *glyph,
+ int x,
+ int y);
+
+static XftSharpGlyph
+_XftSharpGlyphFind (XftDraw *draw, XftFont *public)
+{
+ XftFontInt *font = (XftFontInt *) public;
+
+ if (!font->info.antialias)
+ return _XftSharpGlyphMono;
+ else switch (font->info.rgba) {
+ case FC_RGBA_RGB:
+ case FC_RGBA_BGR:
+ case FC_RGBA_VRGB:
+ case FC_RGBA_VBGR:
+ return _XftSharpGlyphRgba;
+ default:
+ return _XftSharpGlyphGray;
+ }
+}
+
+/*
+ * Draw glyphs to a target that supports anti-aliasing
+ */
+
+/*
+ * Primitives for converting between RGB values and TrueColor pixels
+ */
+
+static void
+_XftExamineBitfield (unsigned long mask, int *shift, int *len)
+{
+ int s, l;
+
+ s = 0;
+ while ((mask & 1) == 0)
+ {
+ mask >>= 1;
+ s++;
+ }
+ l = 0;
+ while ((mask & 1) == 1)
+ {
+ mask >>= 1;
+ l++;
+ }
+ *shift = s;
+ *len = l;
+}
+
+static CARD32
+_XftGetField (unsigned long l_pixel, int shift, int len)
+{
+ CARD32 pixel = (CARD32) l_pixel;
+
+ pixel = pixel & (((1 << (len)) - 1) << shift);
+ pixel = pixel << (32 - (shift + len)) >> 24;
+ while (len < 8)
+ {
+ pixel |= (pixel >> len);
+ len <<= 1;
+ }
+ return pixel;
+}
+
+static unsigned long
+_XftPutField (CARD32 pixel, int shift, int len)
+{
+ unsigned long l_pixel = (unsigned long) pixel;
+
+ shift = shift - (8 - len);
+ if (len <= 8)
+ l_pixel &= (((1 << len) - 1) << (8 - len));
+ if (shift < 0)
+ l_pixel >>= -shift;
+ else
+ l_pixel <<= shift;
+ return l_pixel;
+}
+
+/*
+ * This is used when doing XftCharFontSpec/XftGlyphFontSpec where
+ * some of the fonts are bitmaps and some are anti-aliased to handle
+ * the bitmap portions
+ */
+static void
+_XftSmoothGlyphMono (XImage *image,
+ _Xconst XftGlyph *xftg,
+ int x,
+ int y,
+ _Xconst XftColor *color)
+{
+ unsigned char *srcLine = xftg->bitmap, *src;
+ unsigned char bits, bitsMask;
+ int width = xftg->metrics.width;
+ int stride = ((width + 31) & ~31) >> 3;
+ int height = xftg->metrics.height;
+ int w;
+ int xspan;
+ int r_shift, r_len;
+ int g_shift, g_len;
+ int b_shift, b_len;
+ unsigned long pixel;
+
+ _XftExamineBitfield (image->red_mask, &r_shift, &r_len);
+ _XftExamineBitfield (image->green_mask, &g_shift, &g_len);
+ _XftExamineBitfield (image->blue_mask, &b_shift, &b_len);
+ pixel = (_XftPutField (color->color.red >> 8, r_shift, r_len) |
+ _XftPutField (color->color.green >> 8, g_shift, g_len) |
+ _XftPutField (color->color.blue >> 8, b_shift, b_len));
+ x -= xftg->metrics.x;
+ y -= xftg->metrics.y;
+ while (height--)
+ {
+ src = srcLine;
+ srcLine += stride;
+ w = width;
+
+ bitsMask = 0x80; /* FreeType is always MSB first */
+ bits = *src++;
+
+ xspan = x;
+ while (w--)
+ {
+ if (bits & bitsMask)
+ XPutPixel (image, xspan, y, pixel);
+ bitsMask = bitsMask >> 1;
+ if (!bitsMask)
+ {
+ bits = *src++;
+ bitsMask = 0x80;
+ }
+ xspan++;
+ }
+ y++;
+ }
+}
+
+/*
+ * As simple anti-aliasing is likely to be common, there are three
+ * optimized versions for the usual true color pixel formats (888, 565, 555).
+ * Other formats are handled by the general case
+ */
+
+#define cvt8888to0565(s) ((((s) >> 3) & 0x001f) | \
+ (((s) >> 5) & 0x07e0) | \
+ (((s) >> 8) & 0xf800))
+
+#define cvt0565to8888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
+ ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
+ ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
+
+#define cvt8888to0555(s) ((((s) >> 3) & 0x001f) | \
+ (((s) >> 6) & 0x03e0) | \
+ (((s) >> 7) & 0x7c00))
+
+#define cvt0555to8888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
+ ((((s) << 6) & 0xf800) | (((s) >> 0) & 0x300)) | \
+ ((((s) << 9) & 0xf80000) | (((s) << 4) & 0x70000)))
+
+
+#define XftIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
+#define XftIntDiv(a,b) (((CARD16) (a) * 255) / (b))
+
+#define XftGet8(v,i) ((CARD16) (CARD8) ((v) >> i))
+
+/*
+ * There are two ways of handling alpha -- either as a single unified value or
+ * a separate value for each component, hence each macro must have two
+ * versions. The unified alpha version has a 'U' at the end of the name,
+ * the component version has a 'C'. Similarly, functions which deal with
+ * this difference will have two versions using the same convention.
+ */
+
+#define XftOverU(x,y,i,a,t) ((t) = XftIntMult(XftGet8(y,i),(a),(t)) + XftGet8(x,i),\
+ (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
+
+#define XftOverC(x,y,i,a,t) ((t) = XftIntMult(XftGet8(y,i),XftGet8(a,i),(t)) + XftGet8(x,i),\
+ (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
+
+#define XftInU(x,i,a,t) ((CARD32) XftIntMult(XftGet8(x,i),(a),(t)) << (i))
+
+#define XftInC(x,i,a,t) ((CARD32) XftIntMult(XftGet8(x,i),XftGet8(a,i),(t)) << (i))
+
+#define XftGen(x,y,i,ax,ay,t,u,v) ((t) = (XftIntMult(XftGet8(y,i),ay,(u)) + \
+ XftIntMult(XftGet8(x,i),ax,(v))),\
+ (CARD32) ((CARD8) ((t) | \
+ (0 - ((t) >> 8)))) << (i))
+
+#define XftAdd(x,y,i,t) ((t) = XftGet8(x,i) + XftGet8(y,i), \
+ (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
+
+
+static CARD32
+fbOver24 (CARD32 x, CARD32 y)
+{
+ CARD16 a = ~x >> 24;
+ CARD16 t;
+ CARD32 m,n,o;
+
+ m = XftOverU(x,y,0,a,t);
+ n = XftOverU(x,y,8,a,t);
+ o = XftOverU(x,y,16,a,t);
+ return m|n|o;
+}
+
+static CARD32
+fbIn (CARD32 x, CARD8 y)
+{
+ CARD16 a = y;
+ CARD16 t;
+ CARD32 m,n,o,p;
+
+ m = XftInU(x,0,a,t);
+ n = XftInU(x,8,a,t);
+ o = XftInU(x,16,a,t);
+ p = XftInU(x,24,a,t);
+ return m|n|o|p;
+}
+
+static void
+_XftSmoothGlyphGray8888 (XImage *image,
+ _Xconst XftGlyph *xftg,
+ int x,
+ int y,
+ _Xconst XftColor *color)
+{
+ CARD32 src, srca;
+ CARD32 r, g, b;
+ CARD32 *dstLine, *dst, d;
+ CARD8 *maskLine, *mask, m;
+ int dstStride, maskStride;
+ int width, height;
+ int w;
+
+ srca = color->color.alpha >> 8;
+
+ /* This handles only RGB and BGR */
+ g = (color->color.green & 0xff00);
+ if (image->red_mask == 0xff0000)
+ {
+ r = (color->color.red & 0xff00) << 8;
+ b = color->color.blue >> 8;
+ }
+ else
+ {
+ r = color->color.red >> 8;
+ b = (color->color.blue & 0xff00) << 8;
+ }
+ src = (srca << 24) | r | g | b;
+
+ width = xftg->metrics.width;
+ height = xftg->metrics.height;
+
+ x -= xftg->metrics.x;
+ y -= xftg->metrics.y;
+
+ dstLine = (CARD32 *) (image->data + image->bytes_per_line * y + (x << 2));
+ dstStride = image->bytes_per_line >> 2;
+ maskLine = (unsigned char *) xftg->bitmap;
+ maskStride = (width + 3) & ~3;
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+
+ while (w--)
+ {
+ m = *mask++;
+ if (m == 0xff)
+ {
+ if (srca == 0xff)
+ *dst = src;
+ else
+ *dst = fbOver24 (src, *dst);
+ }
+ else if (m)
+ {
+ d = fbIn (src, m);
+ *dst = fbOver24 (d, *dst);
+ }
+ dst++;
+ }
+ }
+}
+
+static void
+_XftSmoothGlyphGray565 (XImage *image,
+ _Xconst XftGlyph *xftg,
+ int x,
+ int y,
+ _Xconst XftColor *color)
+{
+ CARD32 src, srca;
+ CARD32 r, g, b;
+ CARD32 d;
+ CARD16 *dstLine, *dst;
+ CARD8 *maskLine, *mask, m;
+ int dstStride, maskStride;
+ int width, height;
+ int w;
+
+ srca = color->color.alpha >> 8;
+
+ /* This handles only RGB and BGR */
+ g = (color->color.green & 0xff00);
+ if (image->red_mask == 0xf800)
+ {
+ r = (color->color.red & 0xff00) << 8;
+ b = color->color.blue >> 8;
+ }
+ else
+ {
+ r = color->color.red >> 8;
+ b = (color->color.blue & 0xff00) << 8;
+ }
+ src = (srca << 24) | r | g | b;
+
+ width = xftg->metrics.width;
+ height = xftg->metrics.height;
+
+ x -= xftg->metrics.x;
+ y -= xftg->metrics.y;
+
+ dstLine = (CARD16 *) (image->data + image->bytes_per_line * y + (x << 1));
+ dstStride = image->bytes_per_line >> 1;
+ maskLine = (unsigned char *) xftg->bitmap;
+ maskStride = (width + 3) & ~3;
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+
+ while (w--)
+ {
+ m = *mask++;
+ if (m == 0xff)
+ {
+ if (srca == 0xff)
+ d = src;
+ else
+ {
+ d = *dst;
+ d = fbOver24 (src, cvt0565to8888(d));
+ }
+ *dst = cvt8888to0565(d);
+ }
+ else if (m)
+ {
+ d = *dst;
+ d = fbOver24 (fbIn(src,m), cvt0565to8888(d));
+ *dst = cvt8888to0565(d);
+ }
+ dst++;
+ }
+ }
+}
+
+static void
+_XftSmoothGlyphGray555 (XImage *image,
+ _Xconst XftGlyph *xftg,
+ int x,
+ int y,
+ _Xconst XftColor *color)
+{
+ CARD32 src, srca;
+ CARD32 r, g, b;
+ CARD32 d;
+ CARD16 *dstLine, *dst;
+ CARD8 *maskLine, *mask, m;
+ int dstStride, maskStride;
+ int width, height;
+ int w;
+
+ srca = color->color.alpha >> 8;
+
+ /* This handles only RGB and BGR */
+ g = (color->color.green & 0xff00);
+ if (image->red_mask == 0xf800)
+ {
+ r = (color->color.red & 0xff00) << 8;
+ b = color->color.blue >> 8;
+ }
+ else
+ {
+ r = color->color.red >> 8;
+ b = (color->color.blue & 0xff00) << 8;
+ }
+ src = (srca << 24) | r | g | b;
+
+ width = xftg->metrics.width;
+ height = xftg->metrics.height;
+
+ x -= xftg->metrics.x;
+ y -= xftg->metrics.y;
+
+ dstLine = (CARD16 *) (image->data + image->bytes_per_line * y + (x << 1));
+ dstStride = image->bytes_per_line >> 1;
+ maskLine = (unsigned char *) xftg->bitmap;
+ maskStride = (width + 3) & ~3;
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+
+ while (w--)
+ {
+ m = *mask++;
+ if (m == 0xff)
+ {
+ if (srca == 0xff)
+ d = src;
+ else
+ {
+ d = *dst;
+ d = fbOver24 (src, cvt0555to8888(d));
+ }
+ *dst = cvt8888to0555(d);
+ }
+ else if (m)
+ {
+ d = *dst;
+ d = fbOver24 (fbIn(src,m), cvt0555to8888(d));
+ *dst = cvt8888to0555(d);
+ }
+ dst++;
+ }
+ }
+}
+
+static void
+_XftSmoothGlyphGray (XImage *image,
+ _Xconst XftGlyph *xftg,
+ int x,
+ int y,
+ _Xconst XftColor *color)
+{
+ CARD32 src, srca;
+ int r_shift, r_len;
+ int g_shift, g_len;
+ int b_shift, b_len;
+ CARD8 *maskLine, *mask, m;
+ int maskStride;
+ CARD32 d;
+ unsigned long pixel;
+ int width, height;
+ int w, tx;
+
+ srca = color->color.alpha >> 8;
+ src = (srca << 24 |
+ (color->color.red & 0xff00) << 8 |
+ (color->color.green & 0xff00) |
+ (color->color.blue) >> 8);
+ x -= xftg->metrics.x;
+ y -= xftg->metrics.y;
+ width = xftg->metrics.width;
+ height = xftg->metrics.height;
+
+ maskLine = (unsigned char *) xftg->bitmap;
+ maskStride = (width + 3) & ~3;
+
+ _XftExamineBitfield (image->red_mask, &r_shift, &r_len);
+ _XftExamineBitfield (image->green_mask, &g_shift, &g_len);
+ _XftExamineBitfield (image->blue_mask, &b_shift, &b_len);
+ while (height--)
+ {
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+ tx = x;
+
+ while (w--)
+ {
+ m = *mask++;
+ if (m == 0xff)
+ {
+ if (srca == 0xff)
+ d = src;
+ else
+ {
+ pixel = XGetPixel (image, tx, y);
+ d = (_XftGetField (pixel, r_shift, r_len) << 16 |
+ _XftGetField (pixel, g_shift, g_len) << 8 |
+ _XftGetField (pixel, b_shift, b_len));
+ d = fbOver24 (src, d);
+ }
+ pixel = (_XftPutField ((d >> 16) & 0xff, r_shift, r_len) |
+ _XftPutField ((d >> 8) & 0xff, g_shift, g_len) |
+ _XftPutField ((d ) & 0xff, b_shift, b_len));
+ XPutPixel (image, tx, y, pixel);
+ }
+ else if (m)
+ {
+ pixel = XGetPixel (image, tx, y);
+ d = (_XftGetField (pixel, r_shift, r_len) << 16 |
+ _XftGetField (pixel, g_shift, g_len) << 8 |
+ _XftGetField (pixel, b_shift, b_len));
+ d = fbOver24 (fbIn(src,m), d);
+ pixel = (_XftPutField ((d >> 16) & 0xff, r_shift, r_len) |
+ _XftPutField ((d >> 8) & 0xff, g_shift, g_len) |
+ _XftPutField ((d ) & 0xff, b_shift, b_len));
+ XPutPixel (image, tx, y, pixel);
+ }
+ tx++;
+ }
+ y++;
+ }
+}
+
+static void
+_XftSmoothGlyphRgba (XImage *image,
+ _Xconst XftGlyph *xftg,
+ int x,
+ int y,
+ _Xconst XftColor *color)
+{
+ CARD32 src, srca;
+ int r_shift, r_len;
+ int g_shift, g_len;
+ int b_shift, b_len;
+ CARD32 *mask, ma;
+ CARD32 d;
+ unsigned long pixel;
+ int width, height;
+ int w, tx;
+
+ srca = color->color.alpha >> 8;
+ src = (srca << 24 |
+ (color->color.red & 0xff00) << 8 |
+ (color->color.green & 0xff00) |
+ (color->color.blue) >> 8);
+ x -= xftg->metrics.x;
+ y -= xftg->metrics.y;
+ width = xftg->metrics.width;
+ height = xftg->metrics.height;
+
+ mask = (CARD32 *) xftg->bitmap;
+
+ _XftExamineBitfield (image->red_mask, &r_shift, &r_len);
+ _XftExamineBitfield (image->green_mask, &g_shift, &g_len);
+ _XftExamineBitfield (image->blue_mask, &b_shift, &b_len);
+ while (height--)
+ {
+ w = width;
+ tx = x;
+
+ while (w--)
+ {
+ ma = *mask++;
+ if (ma == 0xffffffff)
+ {
+ if (srca == 0xff)
+ d = src;
+ else
+ {
+ pixel = XGetPixel (image, tx, y);
+ d = (_XftGetField (pixel, r_shift, r_len) << 16 |
+ _XftGetField (pixel, g_shift, g_len) << 8 |
+ _XftGetField (pixel, b_shift, b_len));
+ d = fbOver24 (src, d);
+ }
+ pixel = (_XftPutField ((d >> 16) & 0xff, r_shift, r_len) |
+ _XftPutField ((d >> 8) & 0xff, g_shift, g_len) |
+ _XftPutField ((d ) & 0xff, b_shift, b_len));
+ XPutPixel (image, tx, y, pixel);
+ }
+ else if (ma)
+ {
+ CARD32 m,n,o;
+ pixel = XGetPixel (image, tx, y);
+ d = (_XftGetField (pixel, r_shift, r_len) << 16 |
+ _XftGetField (pixel, g_shift, g_len) << 8 |
+ _XftGetField (pixel, b_shift, b_len));
+#define XftInOverC(src,srca,msk,dst,i,result) { \
+ CARD16 __a = XftGet8(msk,i); \
+ CARD32 __t, __ta; \
+ CARD32 __i; \
+ __t = XftIntMult (XftGet8(src,i), __a,__i); \
+ __ta = (CARD8) ~XftIntMult (srca, __a,__i); \
+ __t = __t + XftIntMult(XftGet8(dst,i),__ta,__i); \
+ __t = (CARD32) (CARD8) (__t | (-(__t >> 8))); \
+ result = __t << (i); \
+}
+ XftInOverC(src,srca,ma,d,0,m);
+ XftInOverC(src,srca,ma,d,8,n);
+ XftInOverC(src,srca,ma,d,16,o);
+ d = m | n | o;
+ pixel = (_XftPutField ((d >> 16) & 0xff, r_shift, r_len) |
+ _XftPutField ((d >> 8) & 0xff, g_shift, g_len) |
+ _XftPutField ((d ) & 0xff, b_shift, b_len));
+ XPutPixel (image, tx, y, pixel);
+ }
+ tx++;
+ }
+ y++;
+ }
+}
+
+static FcBool
+_XftSmoothGlyphPossible (XftDraw *draw)
+{
+ if (!draw->visual)
+ return FcFalse;
+ if (draw->visual->class != TrueColor)
+ return FcFalse;
+ return FcTrue;
+}
+
+typedef void (*XftSmoothGlyph) (XImage *image,
+ _Xconst XftGlyph *xftg,
+ int x,
+ int y,
+ _Xconst XftColor *color);
+
+static XftSmoothGlyph
+_XftSmoothGlyphFind (XftDraw *draw, XftFont *public)
+{
+ XftFontInt *font = (XftFontInt *) public;
+
+ if (!font->info.antialias)
+ return _XftSmoothGlyphMono;
+ else switch (font->info.rgba) {
+ case FC_RGBA_RGB:
+ case FC_RGBA_BGR:
+ case FC_RGBA_VRGB:
+ case FC_RGBA_VBGR:
+ return _XftSmoothGlyphRgba;
+ default:
+ switch (XftDrawBitsPerPixel (draw)) {
+ case 32:
+ if ((draw->visual->red_mask == 0xff0000 &&
+ draw->visual->green_mask == 0x00ff00 &&
+ draw->visual->blue_mask == 0x0000ff) ||
+ (draw->visual->red_mask == 0x0000ff &&
+ draw->visual->green_mask == 0x00ff00 &&
+ draw->visual->blue_mask == 0xff0000))
+ {
+ return _XftSmoothGlyphGray8888;
+ }
+ break;
+ case 16:
+ if ((draw->visual->red_mask == 0xf800 &&
+ draw->visual->green_mask == 0x07e0 &&
+ draw->visual->blue_mask == 0x001f) ||
+ (draw->visual->red_mask == 0x001f &&
+ draw->visual->green_mask == 0x07e0 &&
+ draw->visual->blue_mask == 0xf800))
+ {
+ return _XftSmoothGlyphGray565;
+ }
+ if ((draw->visual->red_mask == 0x7c00 &&
+ draw->visual->green_mask == 0x03e0 &&
+ draw->visual->blue_mask == 0x001f) ||
+ (draw->visual->red_mask == 0x001f &&
+ draw->visual->green_mask == 0x03e0 &&
+ draw->visual->blue_mask == 0x7c00))
+ {
+ return _XftSmoothGlyphGray555;
+ }
+ break;
+ default:
+ break;
+ }
+ return _XftSmoothGlyphGray;
+ }
+}
+
+static XftGlyph *
+_XftGlyphDefault (Display *dpy, XftFont *public)
+{
+ XftFontInt *font = (XftFontInt *) public;
+ FT_UInt missing[XFT_NMISSING];
+ int nmissing;
+ FcBool glyphs_loaded = FcFalse;
+
+ if (XftFontCheckGlyph (dpy, public, FcTrue, 0, missing, &nmissing))
+ glyphs_loaded = FcTrue;
+ if (nmissing)
+ XftFontLoadGlyphs (dpy, public, FcTrue, missing, nmissing);
+ return font->glyphs[0];
+}
+
+static int XftGetImageErrorHandler (Display *dpy, XErrorEvent *error_event)
+{
+ return 0;
+}
+
+void
+XftGlyphCore (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *public,
+ int x,
+ int y,
+ _Xconst FT_UInt *glyphs,
+ int nglyphs)
+{
+ Display *dpy = draw->dpy;
+ XftFontInt *font = (XftFontInt *) public;
+ XftGlyph *xftg;
+ FT_UInt glyph;
+ _Xconst FT_UInt *g;
+ FT_UInt missing[XFT_NMISSING];
+ FcBool glyphs_loaded;
+ int nmissing;
+ int n;
+ XErrorHandler prev_error;
+
+ /*
+ * Load missing glyphs
+ */
+ g = glyphs;
+ n = nglyphs;
+ nmissing = 0;
+ glyphs_loaded = FcFalse;
+ while (n--)
+ if (XftFontCheckGlyph (dpy, public, FcTrue, *g++, missing, &nmissing))
+ glyphs_loaded = FcTrue;
+ if (nmissing)
+ XftFontLoadGlyphs (dpy, public, FcTrue, missing, nmissing);
+
+ g = glyphs;
+ n = nglyphs;
+ if ((font->info.antialias || color->color.alpha != 0xffff) &&
+ _XftSmoothGlyphPossible (draw))
+ {
+ XGlyphInfo gi;
+ XImage *image;
+ unsigned int depth;
+ int ox, oy;
+ XftSmoothGlyph smooth = _XftSmoothGlyphFind (draw, public);
+
+ XftGlyphExtents (dpy, public, glyphs, nglyphs, &gi);
+ if (!gi.width || !gi.height)
+ goto bail1;
+ ox = x - gi.x;
+ oy = y - gi.y;
+ /*
+ * Try to get bits directly from the drawable; if that fails,
+ * use a temporary pixmap. When it does fail, assume it
+ * will probably fail for a while and keep using temporary
+ * pixmaps for a while to avoid double round trips.
+ */
+ if (draw->core.use_pixmap == 0)
+ {
+ prev_error = XSetErrorHandler (XftGetImageErrorHandler);
+ image = XGetImage (dpy, draw->drawable,
+ ox, oy,
+ gi.width, gi.height, AllPlanes,
+ ZPixmap);
+ XSetErrorHandler (prev_error);
+ if (!image)
+ draw->core.use_pixmap = XFT_ASSUME_PIXMAP;
+ }
+ else
+ {
+ draw->core.use_pixmap--;
+ image = 0;
+ }
+ if (!image && (depth = XftDrawDepth (draw)))
+ {
+ Pixmap pix;
+ GC gc;
+ XGCValues gcv;
+
+ pix = XCreatePixmap (dpy, draw->drawable,
+ gi.width, gi.height, depth);
+ gcv.graphics_exposures = False;
+ gc = XCreateGC (dpy, pix, GCGraphicsExposures, &gcv);
+ XCopyArea (dpy, draw->drawable, pix, gc, ox, oy,
+ gi.width, gi.height, 0, 0);
+ XFreeGC (dpy, gc);
+ image = XGetImage (dpy, pix, 0, 0, gi.width, gi.height, AllPlanes,
+ ZPixmap);
+ XFreePixmap (dpy, pix);
+ }
+ if (!image)
+ goto bail1;
+ image->red_mask = draw->visual->red_mask;
+ image->green_mask = draw->visual->green_mask;
+ image->blue_mask = draw->visual->blue_mask;
+ if (image->byte_order != XftNativeByteOrder ())
+ XftSwapImage (image);
+ while (n--)
+ {
+ glyph = *g++;
+ if (glyph >= font->num_glyphs || !(xftg = font->glyphs[glyph]))
+ xftg = _XftGlyphDefault (dpy, public);
+ if (xftg)
+ {
+ (*smooth) (image, xftg, x - ox, y - oy, color);
+ x += xftg->metrics.xOff;
+ y += xftg->metrics.yOff;
+ }
+ }
+ if (image->byte_order != XftNativeByteOrder ())
+ XftSwapImage (image);
+ XPutImage (dpy, draw->drawable, draw->core.gc, image, 0, 0, ox, oy,
+ gi.width, gi.height);
+ XDestroyImage (image);
+ }
+ else
+ {
+ XftSharpGlyph sharp = _XftSharpGlyphFind (draw, public);
+ while (n--)
+ {
+ glyph = *g++;
+ if (glyph >= font->num_glyphs || !(xftg = font->glyphs[glyph]))
+ xftg = _XftGlyphDefault (dpy, public);
+ if (xftg)
+ {
+ (*sharp) (draw, xftg, x, y);
+ x += xftg->metrics.xOff;
+ y += xftg->metrics.yOff;
+ }
+ }
+ }
+bail1:
+ if (glyphs_loaded)
+ _XftFontManageMemory (dpy, public);
+}
+
+#define NUM_LOCAL 1024
+
+void
+XftGlyphSpecCore (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *public,
+ _Xconst XftGlyphSpec *glyphs,
+ int nglyphs)
+{
+ Display *dpy = draw->dpy;
+ XftFontInt *font = (XftFontInt *) public;
+ XftGlyph *xftg;
+ FT_UInt missing[XFT_NMISSING];
+ FcBool glyphs_loaded;
+ int nmissing;
+ int i;
+ XErrorHandler prev_error;
+ int x1, y1, x2, y2;
+
+ /*
+ * Load missing glyphs
+ */
+ glyphs_loaded = FcFalse;
+ x1 = y1 = x2 = y2 = 0;
+ for (i = 0; i < nglyphs; i++)
+ {
+ XGlyphInfo gi;
+ int g_x1, g_x2, g_y1, g_y2;
+
+ nmissing = 0;
+ if (XftFontCheckGlyph (dpy, public, FcTrue, glyphs[i].glyph, missing, &nmissing))
+ glyphs_loaded = FcTrue;
+ if (nmissing)
+ XftFontLoadGlyphs (dpy, public, FcTrue, missing, nmissing);
+
+ XftGlyphExtents (dpy, public, &glyphs[i].glyph, 1, &gi);
+ g_x1 = glyphs[i].x - gi.x;
+ g_y1 = glyphs[i].y - gi.y;
+ g_x2 = g_x1 + gi.width;
+ g_y2 = g_y1 + gi.height;
+ if (i)
+ {
+ if (g_x1 < x1)
+ x1 = g_x1;
+ if (g_y1 < y1)
+ y1 = g_y1;
+ if (g_x2 > x2)
+ x2 = g_x2;
+ if (g_y2 > y2)
+ y2 = g_y2;
+ }
+ else
+ {
+ x1 = g_x1;
+ y1 = g_y1;
+ x2 = g_x2;
+ y2 = g_y2;
+ }
+ }
+
+ if (x1 == x2 || y1 == y2)
+ goto bail1;
+
+ if ((font->info.antialias || color->color.alpha != 0xffff) &&
+ _XftSmoothGlyphPossible (draw))
+ {
+ XImage *image;
+ unsigned int depth;
+ int width = x2 - x1, height = y2 - y1;
+ XftSmoothGlyph smooth = _XftSmoothGlyphFind (draw, public);
+
+ /*
+ * Try to get bits directly from the drawable; if that fails,
+ * use a temporary pixmap. When it does fail, assume it
+ * will probably fail for a while and keep using temporary
+ * pixmaps for a while to avoid double round trips.
+ */
+ if (draw->core.use_pixmap == 0)
+ {
+ prev_error = XSetErrorHandler (XftGetImageErrorHandler);
+ image = XGetImage (dpy, draw->drawable,
+ x1, y1,
+ width, height, AllPlanes,
+ ZPixmap);
+ XSetErrorHandler (prev_error);
+ if (!image)
+ draw->core.use_pixmap = XFT_ASSUME_PIXMAP;
+ }
+ else
+ {
+ draw->core.use_pixmap--;
+ image = 0;
+ }
+ if (!image && (depth = XftDrawDepth (draw)))
+ {
+ Pixmap pix;
+ GC gc;
+ XGCValues gcv;
+
+ pix = XCreatePixmap (dpy, draw->drawable,
+ width, height, depth);
+ gcv.graphics_exposures = False;
+ gc = XCreateGC (dpy, pix, GCGraphicsExposures, &gcv);
+ XCopyArea (dpy, draw->drawable, pix, gc, x1, y1,
+ width, height, 0, 0);
+ XFreeGC (dpy, gc);
+ image = XGetImage (dpy, pix, 0, 0, width, height, AllPlanes,
+ ZPixmap);
+ XFreePixmap (dpy, pix);
+ }
+ if (!image)
+ goto bail1;
+ image->red_mask = draw->visual->red_mask;
+ image->green_mask = draw->visual->green_mask;
+ image->blue_mask = draw->visual->blue_mask;
+ if (image->byte_order != XftNativeByteOrder ())
+ XftSwapImage (image);
+ for (i = 0; i < nglyphs; i++)
+ {
+ FT_UInt glyph = glyphs[i].glyph;
+ if (glyph >= font->num_glyphs || !(xftg = font->glyphs[glyph]))
+ xftg = _XftGlyphDefault (dpy, public);
+ if (xftg)
+ {
+ (*smooth) (image, xftg, glyphs[i].x - x1,
+ glyphs[i].y - y1, color);
+ }
+ }
+ if (image->byte_order != XftNativeByteOrder ())
+ XftSwapImage (image);
+ XPutImage (dpy, draw->drawable, draw->core.gc, image, 0, 0, x1, y1,
+ width, height);
+ XDestroyImage (image);
+ }
+ else
+ {
+ XftSharpGlyph sharp = _XftSharpGlyphFind (draw, public);
+ for (i = 0; i < nglyphs; i++)
+ {
+ FT_UInt glyph = glyphs[i].glyph;
+ if (glyph >= font->num_glyphs || !(xftg = font->glyphs[glyph]))
+ xftg = _XftGlyphDefault (dpy, public);
+ if (xftg)
+ (*sharp) (draw, xftg, glyphs[i].x, glyphs[i].y);
+ }
+ }
+bail1:
+ if (glyphs_loaded)
+ _XftFontManageMemory (dpy, public);
+}
+
+void
+XftGlyphFontSpecCore (XftDraw *draw,
+ _Xconst XftColor *color,
+ _Xconst XftGlyphFontSpec *glyphs,
+ int nglyphs)
+{
+ Display *dpy = draw->dpy;
+ XftGlyph *xftg;
+ FT_UInt missing[XFT_NMISSING];
+ FcBool glyphs_loaded;
+ int nmissing;
+ int i;
+ XErrorHandler prev_error;
+ int x1, y1, x2, y2;
+
+ /*
+ * Load missing glyphs
+ */
+ glyphs_loaded = FcFalse;
+ x1 = y1 = x2 = y2 = 0;
+ for (i = 0; i < nglyphs; i++)
+ {
+ XftFont *public = glyphs[i].font;
+ XGlyphInfo gi;
+ int g_x1, g_x2, g_y1, g_y2;
+
+ nmissing = 0;
+ if (XftFontCheckGlyph (dpy, public, FcTrue, glyphs[i].glyph, missing, &nmissing))
+ glyphs_loaded = FcTrue;
+ if (nmissing)
+ XftFontLoadGlyphs (dpy, public, FcTrue, missing, nmissing);
+
+ XftGlyphExtents (dpy, public, &glyphs[i].glyph, 1, &gi);
+ g_x1 = glyphs[i].x - gi.x;
+ g_y1 = glyphs[i].y - gi.y;
+ g_x2 = g_x1 + gi.width;
+ g_y2 = g_y1 + gi.height;
+ if (i)
+ {
+ if (g_x1 < x1)
+ x1 = g_x1;
+ if (g_y1 < y1)
+ y1 = g_y1;
+ if (g_x2 > x2)
+ x2 = g_x2;
+ if (g_y2 > y2)
+ y2 = g_y2;
+ }
+ else
+ {
+ x1 = g_x1;
+ y1 = g_y1;
+ x2 = g_x2;
+ y2 = g_y2;
+ }
+ }
+
+ if (x1 == x2 || y1 == y2)
+ goto bail1;
+
+ for (i = 0; i < nglyphs; i++)
+ if (((XftFontInt *) glyphs[i].font)->info.antialias)
+ break;
+
+ if ((i != nglyphs || color->color.alpha != 0xffff) &&
+ _XftSmoothGlyphPossible (draw))
+ {
+ XImage *image;
+ unsigned int depth;
+ int width = x2 - x1, height = y2 - y1;
+
+ /*
+ * Try to get bits directly from the drawable; if that fails,
+ * use a temporary pixmap. When it does fail, assume it
+ * will probably fail for a while and keep using temporary
+ * pixmaps for a while to avoid double round trips.
+ */
+ if (draw->core.use_pixmap == 0)
+ {
+ prev_error = XSetErrorHandler (XftGetImageErrorHandler);
+ image = XGetImage (dpy, draw->drawable,
+ x1, y1,
+ width, height, AllPlanes,
+ ZPixmap);
+ XSetErrorHandler (prev_error);
+ if (!image)
+ draw->core.use_pixmap = XFT_ASSUME_PIXMAP;
+ }
+ else
+ {
+ draw->core.use_pixmap--;
+ image = 0;
+ }
+ if (!image && (depth = XftDrawDepth (draw)))
+ {
+ Pixmap pix;
+ GC gc;
+ XGCValues gcv;
+
+ pix = XCreatePixmap (dpy, draw->drawable,
+ width, height, depth);
+ gcv.graphics_exposures = False;
+ gc = XCreateGC (dpy, pix, GCGraphicsExposures, &gcv);
+ XCopyArea (dpy, draw->drawable, pix, gc, x1, y1,
+ width, height, 0, 0);
+ XFreeGC (dpy, gc);
+ image = XGetImage (dpy, pix, 0, 0, width, height, AllPlanes,
+ ZPixmap);
+ XFreePixmap (dpy, pix);
+ }
+ if (!image)
+ goto bail1;
+ image->red_mask = draw->visual->red_mask;
+ image->green_mask = draw->visual->green_mask;
+ image->blue_mask = draw->visual->blue_mask;
+ if (image->byte_order != XftNativeByteOrder ())
+ XftSwapImage (image);
+ for (i = 0; i < nglyphs; i++)
+ {
+ XftFont *public = glyphs[i].font;
+ XftFontInt *font = (XftFontInt *) public;
+ XftSmoothGlyph smooth = _XftSmoothGlyphFind (draw, public);
+ FT_UInt glyph = glyphs[i].glyph;
+
+ if (glyph >= font->num_glyphs || !(xftg = font->glyphs[glyph]))
+ xftg = _XftGlyphDefault (dpy, public);
+ if (xftg)
+ {
+ (*smooth) (image, xftg, glyphs[i].x - x1,
+ glyphs[i].y - y1, color);
+ }
+ }
+ if (image->byte_order != XftNativeByteOrder ())
+ XftSwapImage (image);
+ XPutImage (dpy, draw->drawable, draw->core.gc, image, 0, 0, x1, y1,
+ width, height);
+ XDestroyImage (image);
+ }
+ else
+ {
+ for (i = 0; i < nglyphs; i++)
+ {
+ XftFont *public = glyphs[i].font;
+ XftFontInt *font = (XftFontInt *) public;
+ XftSharpGlyph sharp = _XftSharpGlyphFind (draw, public);
+ FT_UInt glyph = glyphs[i].glyph;
+
+ if (glyph >= font->num_glyphs || !(xftg = font->glyphs[glyph]))
+ xftg = _XftGlyphDefault (dpy, public);
+ if (xftg)
+ (*sharp) (draw, xftg, glyphs[i].x, glyphs[i].y);
+ }
+ }
+bail1:
+ if (glyphs_loaded)
+ for (i = 0; i < nglyphs; i++)
+ _XftFontManageMemory (dpy, glyphs[i].font);
+}
diff --git a/nx-X11/lib/Xft/xftdbg.c b/nx-X11/lib/Xft/xftdbg.c
new file mode 100644
index 000000000..1d5604698
--- /dev/null
+++ b/nx-X11/lib/Xft/xftdbg.c
@@ -0,0 +1,48 @@
+/*
+ * $Id: xftdbg.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+int
+XftDebug (void)
+{
+ static int initialized;
+ static int debug;
+
+ if (!initialized)
+ {
+ char *e;
+
+ initialized = 1;
+ e = getenv ("XFT_DEBUG");
+ if (e)
+ {
+ printf ("XFT_DEBUG=%s\n", e);
+ debug = atoi (e);
+ if (debug <= 0)
+ debug = 1;
+ }
+ }
+ return debug;
+}
diff --git a/nx-X11/lib/Xft/xftdpy.c b/nx-X11/lib/Xft/xftdpy.c
new file mode 100644
index 000000000..9eb32ba9e
--- /dev/null
+++ b/nx-X11/lib/Xft/xftdpy.c
@@ -0,0 +1,554 @@
+/*
+ * $Id: xftdpy.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+XftDisplayInfo *_XftDisplayInfo;
+
+static int
+_XftCloseDisplay (Display *dpy, XExtCodes *codes)
+{
+ XftDisplayInfo *info, **prev;
+
+ info = _XftDisplayInfoGet (dpy, FcFalse);
+ if (!info)
+ return 0;
+
+ /*
+ * Get rid of any dangling unreferenced fonts
+ */
+ info->max_unref_fonts = 0;
+ XftFontManageMemory (dpy);
+
+ /*
+ * Clean up the default values
+ */
+ if (info->defaults)
+ FcPatternDestroy (info->defaults);
+
+ /*
+ * Unhook from the global list
+ */
+ for (prev = &_XftDisplayInfo; (info = *prev); prev = &(*prev)->next)
+ if (info->display == dpy)
+ break;
+ *prev = info->next;
+
+ free (info);
+ return 0;
+}
+
+
+XftDisplayInfo *
+_XftDisplayInfoGet (Display *dpy, FcBool createIfNecessary)
+{
+ XftDisplayInfo *info, **prev;
+ XRenderPictFormat pf;
+ int i;
+ int event_base, error_base;
+
+ for (prev = &_XftDisplayInfo; (info = *prev); prev = &(*prev)->next)
+ {
+ if (info->display == dpy)
+ {
+ /*
+ * MRU the list
+ */
+ if (prev != &_XftDisplayInfo)
+ {
+ *prev = info->next;
+ info->next = _XftDisplayInfo;
+ _XftDisplayInfo = info;
+ }
+ return info;
+ }
+ }
+ if (!createIfNecessary)
+ return 0;
+
+ info = (XftDisplayInfo *) malloc (sizeof (XftDisplayInfo));
+ if (!info)
+ goto bail0;
+ info->codes = XAddExtension (dpy);
+ if (!info->codes)
+ goto bail1;
+ (void) XESetCloseDisplay (dpy, info->codes->extension, _XftCloseDisplay);
+
+ info->display = dpy;
+ info->defaults = 0;
+ info->solidFormat = 0;
+ info->hasRender = (XRenderQueryExtension (dpy, &event_base, &error_base) &&
+ (XRenderFindVisualFormat (dpy, DefaultVisual (dpy, DefaultScreen (dpy))) != 0));
+ info->use_free_glyphs = FcTrue;
+ if (info->hasRender)
+ {
+ int major, minor;
+ XRenderQueryVersion (dpy, &major, &minor);
+ if (major < 0 || (major == 0 && minor <= 2))
+ info->use_free_glyphs = FcFalse;
+
+ pf.type = PictTypeDirect;
+ pf.depth = 32;
+ pf.direct.redMask = 0xff;
+ pf.direct.greenMask = 0xff;
+ pf.direct.blueMask = 0xff;
+ pf.direct.alphaMask = 0xff;
+ info->solidFormat = XRenderFindFormat (dpy,
+ (PictFormatType|
+ PictFormatDepth|
+ PictFormatRedMask|
+ PictFormatGreenMask|
+ PictFormatBlueMask|
+ PictFormatAlphaMask),
+ &pf,
+ 0);
+ }
+ if (XftDebug () & XFT_DBG_RENDER)
+ {
+ Visual *visual = DefaultVisual (dpy, DefaultScreen (dpy));
+ XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
+
+ printf ("XftDisplayInfoGet Default visual 0x%x ",
+ (int) visual->visualid);
+ if (format)
+ {
+ if (format->type == PictTypeDirect)
+ {
+ printf ("format %d,%d,%d,%d\n",
+ format->direct.alpha,
+ format->direct.red,
+ format->direct.green,
+ format->direct.blue);
+ }
+ else
+ {
+ printf ("format indexed\n");
+ }
+ }
+ else
+ printf ("No Render format for default visual\n");
+
+ printf ("XftDisplayInfoGet initialized, hasRender set to \"%s\"\n",
+ info->hasRender ? "True" : "False");
+ }
+ for (i = 0; i < XFT_NUM_SOLID_COLOR; i++)
+ {
+ info->colors[i].screen = -1;
+ info->colors[i].pict = 0;
+ }
+ info->fonts = 0;
+
+ info->next = _XftDisplayInfo;
+ _XftDisplayInfo = info;
+
+ info->glyph_memory = 0;
+ info->max_glyph_memory = XftDefaultGetInteger (dpy,
+ XFT_MAX_GLYPH_MEMORY, 0,
+ XFT_DPY_MAX_GLYPH_MEMORY);
+ if (XftDebug () & XFT_DBG_CACHE)
+ printf ("global max cache memory %ld\n", info->max_glyph_memory);
+
+
+ info->num_unref_fonts = 0;
+ info->max_unref_fonts = XftDefaultGetInteger (dpy,
+ XFT_MAX_UNREF_FONTS, 0,
+ XFT_DPY_MAX_UNREF_FONTS);
+ if (XftDebug() & XFT_DBG_CACHE)
+ printf ("global max unref fonts %d\n", info->max_unref_fonts);
+
+ memset (info->fontHash, '\0', sizeof (XftFont *) * XFT_NUM_FONT_HASH);
+ return info;
+
+bail1:
+ free (info);
+bail0:
+ if (XftDebug () & XFT_DBG_RENDER)
+ {
+ printf ("XftDisplayInfoGet failed to initialize, Xft unhappy\n");
+ }
+ return 0;
+}
+
+/*
+ * Reduce memory usage in X server
+ */
+
+static void
+_XftDisplayValidateMemory (XftDisplayInfo *info)
+{
+ XftFont *public;
+ XftFontInt *font;
+ unsigned long glyph_memory;
+
+ glyph_memory = 0;
+ for (public = info->fonts; public; public = font->next)
+ {
+ font = (XftFontInt *) public;
+ glyph_memory += font->glyph_memory;
+ }
+ if (glyph_memory != info->glyph_memory)
+ printf ("Display glyph cache incorrect has %ld bytes, should have %ld\n",
+ info->glyph_memory, glyph_memory);
+}
+
+void
+_XftDisplayManageMemory (Display *dpy)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy, False);
+ unsigned long glyph_memory;
+ XftFont *public;
+ XftFontInt *font;
+
+ if (!info || !info->max_glyph_memory)
+ return;
+ if (XftDebug () & XFT_DBG_CACHE)
+ {
+ if (info->glyph_memory > info->max_glyph_memory)
+ printf ("Reduce global memory from %ld to %ld\n",
+ info->glyph_memory, info->max_glyph_memory);
+ _XftDisplayValidateMemory (info);
+ }
+ while (info->glyph_memory > info->max_glyph_memory)
+ {
+ glyph_memory = rand () % info->glyph_memory;
+ public = info->fonts;
+ while (public)
+ {
+ font = (XftFontInt *) public;
+
+ if (font->glyph_memory > glyph_memory)
+ {
+ _XftFontUncacheGlyph (dpy, public);
+ break;
+ }
+ public = font->next;
+ glyph_memory -= font->glyph_memory;
+ }
+ }
+ if (XftDebug () & XFT_DBG_CACHE)
+ _XftDisplayValidateMemory (info);
+}
+
+Bool
+XftDefaultHasRender (Display *dpy)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy, True);
+
+ if (!info)
+ return False;
+ return info->hasRender;
+}
+
+Bool
+XftDefaultSet (Display *dpy, FcPattern *defaults)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy, True);
+
+ if (!info)
+ return False;
+ if (info->defaults)
+ FcPatternDestroy (info->defaults);
+ info->defaults = defaults;
+ if (!info->max_glyph_memory)
+ info->max_glyph_memory = XFT_DPY_MAX_GLYPH_MEMORY;
+ info->max_glyph_memory = XftDefaultGetInteger (dpy,
+ XFT_MAX_GLYPH_MEMORY, 0,
+ info->max_glyph_memory);
+ if (!info->max_unref_fonts)
+ info->max_unref_fonts = XFT_DPY_MAX_UNREF_FONTS;
+ info->max_unref_fonts = XftDefaultGetInteger (dpy,
+ XFT_MAX_UNREF_FONTS, 0,
+ info->max_unref_fonts);
+ return True;
+}
+
+int
+XftDefaultParseBool (char *v)
+{
+ char c0, c1;
+
+ c0 = *v;
+ if (isupper ((int)c0))
+ c0 = tolower (c0);
+ if (c0 == 't' || c0 == 'y' || c0 == '1')
+ return 1;
+ if (c0 == 'f' || c0 == 'n' || c0 == '0')
+ return 0;
+ if (c0 == 'o')
+ {
+ c1 = v[1];
+ if (isupper ((int)c1))
+ c1 = tolower (c1);
+ if (c1 == 'n')
+ return 1;
+ if (c1 == 'f')
+ return 0;
+ }
+ return -1;
+}
+
+static Bool
+_XftDefaultInitBool (Display *dpy, FcPattern *pat, char *option)
+{
+ char *v;
+ int i;
+
+ v = XGetDefault (dpy, "Xft", option);
+ if (v && (i = XftDefaultParseBool (v)) >= 0)
+ return FcPatternAddBool (pat, option, i != 0);
+ return True;
+}
+
+static Bool
+_XftDefaultInitDouble (Display *dpy, FcPattern *pat, char *option)
+{
+ char *v, *e;
+ double d;
+
+ v = XGetDefault (dpy, "Xft", option);
+ if (v)
+ {
+ d = strtod (v, &e);
+ if (e != v)
+ return FcPatternAddDouble (pat, option, d);
+ }
+ return True;
+}
+
+static Bool
+_XftDefaultInitInteger (Display *dpy, FcPattern *pat, char *option)
+{
+ char *v, *e;
+ int i;
+
+ v = XGetDefault (dpy, "Xft", option);
+ if (v)
+ {
+ if (FcNameConstant ((FcChar8 *) v, &i))
+ return FcPatternAddInteger (pat, option, i);
+ i = strtol (v, &e, 0);
+ if (e != v)
+ return FcPatternAddInteger (pat, option, i);
+ }
+ return True;
+}
+
+static FcPattern *
+_XftDefaultInit (Display *dpy)
+{
+ FcPattern *pat;
+
+ pat = FcPatternCreate ();
+ if (!pat)
+ goto bail0;
+
+ if (!_XftDefaultInitDouble (dpy, pat, FC_SCALE))
+ goto bail1;
+ if (!_XftDefaultInitDouble (dpy, pat, FC_DPI))
+ goto bail1;
+ if (!_XftDefaultInitBool (dpy, pat, XFT_RENDER))
+ goto bail1;
+ if (!_XftDefaultInitInteger (dpy, pat, FC_RGBA))
+ goto bail1;
+ if (!_XftDefaultInitBool (dpy, pat, FC_ANTIALIAS))
+ goto bail1;
+#ifdef FC_EMBOLDEN
+ if (!_XftDefaultInitBool (dpy, pat, FC_EMBOLDEN))
+ goto bail1;
+#endif
+ if (!_XftDefaultInitBool (dpy, pat, FC_AUTOHINT))
+ goto bail1;
+#ifdef FC_HINT_STYLE
+ if (!_XftDefaultInitInteger (dpy, pat, FC_HINT_STYLE))
+ goto bail1;
+#endif
+ if (!_XftDefaultInitBool (dpy, pat, FC_HINTING))
+ goto bail1;
+ if (!_XftDefaultInitBool (dpy, pat, FC_MINSPACE))
+ goto bail1;
+ if (!_XftDefaultInitInteger (dpy, pat, XFT_MAX_GLYPH_MEMORY))
+ goto bail1;
+
+ return pat;
+
+bail1:
+ FcPatternDestroy (pat);
+bail0:
+ return 0;
+}
+
+static FcResult
+_XftDefaultGet (Display *dpy, const char *object, int screen, FcValue *v)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy, True);
+ FcResult r;
+
+ if (!info)
+ return FcResultNoMatch;
+
+ if (!info->defaults)
+ {
+ info->defaults = _XftDefaultInit (dpy);
+ if (!info->defaults)
+ return FcResultNoMatch;
+ }
+ r = FcPatternGet (info->defaults, object, screen, v);
+ if (r == FcResultNoId && screen > 0)
+ r = FcPatternGet (info->defaults, object, 0, v);
+ return r;
+}
+
+Bool
+XftDefaultGetBool (Display *dpy, const char *object, int screen, Bool def)
+{
+ FcResult r;
+ FcValue v;
+
+ r = _XftDefaultGet (dpy, object, screen, &v);
+ if (r != FcResultMatch || v.type != FcTypeBool)
+ return def;
+ return v.u.b;
+}
+
+int
+XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def)
+{
+ FcResult r;
+ FcValue v;
+
+ r = _XftDefaultGet (dpy, object, screen, &v);
+ if (r != FcResultMatch || v.type != FcTypeInteger)
+ return def;
+ return v.u.i;
+}
+
+double
+XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def)
+{
+ FcResult r;
+ FcValue v;
+
+ r = _XftDefaultGet (dpy, object, screen, &v);
+ if (r != FcResultMatch || v.type != FcTypeDouble)
+ return def;
+ return v.u.d;
+}
+
+void
+XftDefaultSubstitute (Display *dpy, int screen, FcPattern *pattern)
+{
+ FcValue v;
+ double dpi;
+
+ if (FcPatternGet (pattern, XFT_RENDER, 0, &v) == FcResultNoMatch)
+ {
+ FcPatternAddBool (pattern, XFT_RENDER,
+ XftDefaultGetBool (dpy, XFT_RENDER, screen,
+ XftDefaultHasRender (dpy)));
+ }
+ if (FcPatternGet (pattern, FC_ANTIALIAS, 0, &v) == FcResultNoMatch)
+ {
+ FcPatternAddBool (pattern, FC_ANTIALIAS,
+ XftDefaultGetBool (dpy, FC_ANTIALIAS, screen,
+ True));
+ }
+#ifdef FC_EMBOLDEN
+ if (FcPatternGet (pattern, FC_EMBOLDEN, 0, &v) == FcResultNoMatch)
+ {
+ FcPatternAddBool (pattern, FC_EMBOLDEN,
+ XftDefaultGetBool (dpy, FC_EMBOLDEN, screen,
+ False));
+ }
+#endif
+ if (FcPatternGet (pattern, FC_HINTING, 0, &v) == FcResultNoMatch)
+ {
+ FcPatternAddBool (pattern, FC_HINTING,
+ XftDefaultGetBool (dpy, FC_HINTING, screen,
+ True));
+ }
+#ifdef FC_HINT_STYLE
+ if (FcPatternGet (pattern, FC_HINT_STYLE, 0, &v) == FcResultNoMatch)
+ {
+ FcPatternAddInteger (pattern, FC_HINT_STYLE,
+ XftDefaultGetInteger (dpy, FC_HINT_STYLE, screen,
+ FC_HINT_FULL));
+ }
+#endif
+ if (FcPatternGet (pattern, FC_AUTOHINT, 0, &v) == FcResultNoMatch)
+ {
+ FcPatternAddBool (pattern, FC_AUTOHINT,
+ XftDefaultGetBool (dpy, FC_AUTOHINT, screen,
+ False));
+ }
+ if (FcPatternGet (pattern, FC_RGBA, 0, &v) == FcResultNoMatch)
+ {
+ int subpixel = FC_RGBA_UNKNOWN;
+#if RENDER_MAJOR > 0 || RENDER_MINOR >= 6
+ if (XftDefaultHasRender (dpy))
+ {
+ int render_order = XRenderQuerySubpixelOrder (dpy, screen);
+ switch (render_order) {
+ default:
+ case SubPixelUnknown: subpixel = FC_RGBA_UNKNOWN; break;
+ case SubPixelHorizontalRGB: subpixel = FC_RGBA_RGB; break;
+ case SubPixelHorizontalBGR: subpixel = FC_RGBA_BGR; break;
+ case SubPixelVerticalRGB: subpixel = FC_RGBA_VRGB; break;
+ case SubPixelVerticalBGR: subpixel = FC_RGBA_VBGR; break;
+ case SubPixelNone: subpixel = FC_RGBA_NONE; break;
+ }
+ }
+#endif
+ FcPatternAddInteger (pattern, FC_RGBA,
+ XftDefaultGetInteger (dpy, FC_RGBA, screen,
+ subpixel));
+ }
+ if (FcPatternGet (pattern, FC_MINSPACE, 0, &v) == FcResultNoMatch)
+ {
+ FcPatternAddBool (pattern, FC_MINSPACE,
+ XftDefaultGetBool (dpy, FC_MINSPACE, screen,
+ False));
+ }
+ if (FcPatternGet (pattern, FC_DPI, 0, &v) == FcResultNoMatch)
+ {
+ dpi = (((double) DisplayHeight (dpy, screen) * 25.4) /
+ (double) DisplayHeightMM (dpy, screen));
+ FcPatternAddDouble (pattern, FC_DPI,
+ XftDefaultGetDouble (dpy, FC_DPI, screen,
+ dpi));
+ }
+ if (FcPatternGet (pattern, FC_SCALE, 0, &v) == FcResultNoMatch)
+ {
+ FcPatternAddDouble (pattern, FC_SCALE,
+ XftDefaultGetDouble (dpy, FC_SCALE, screen, 1.0));
+ }
+ if (FcPatternGet (pattern, XFT_MAX_GLYPH_MEMORY, 0, &v) == FcResultNoMatch)
+ {
+ FcPatternAddInteger (pattern, XFT_MAX_GLYPH_MEMORY,
+ XftDefaultGetInteger (dpy, XFT_MAX_GLYPH_MEMORY,
+ screen,
+ XFT_FONT_MAX_GLYPH_MEMORY));
+ }
+ FcDefaultSubstitute (pattern);
+}
+
diff --git a/nx-X11/lib/Xft/xftdraw.c b/nx-X11/lib/Xft/xftdraw.c
new file mode 100644
index 000000000..f9c1cbd6f
--- /dev/null
+++ b/nx-X11/lib/Xft/xftdraw.c
@@ -0,0 +1,993 @@
+/*
+ * $Id: xftdraw.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+/*
+ * Ok, this is a pain. To share source pictures across multiple destinations,
+ * the screen for each drawable must be discovered.
+ */
+
+static int
+_XftDrawScreen (Display *dpy, Drawable drawable, Visual *visual)
+{
+ int s;
+ Window root;
+ int x, y;
+ unsigned int width, height, borderWidth, depth;
+ /* Special case the most common environment */
+ if (ScreenCount (dpy) == 1)
+ return 0;
+ /*
+ * If we've got a visual, look for the screen that points at it.
+ * This requires no round trip.
+ */
+ if (visual)
+ {
+ for (s = 0; s < ScreenCount (dpy); s++)
+ {
+ XVisualInfo template, *ret;
+ int nret;
+
+ template.visualid = visual->visualid;
+ template.screen = s;
+ ret = XGetVisualInfo (dpy, VisualIDMask|VisualScreenMask,
+ &template, &nret);
+ if (ret)
+ {
+ XFree (ret);
+ return s;
+ }
+ }
+ }
+ /*
+ * Otherwise, as the server for the drawable geometry and find
+ * the screen from the root window.
+ * This takes a round trip.
+ */
+ if (XGetGeometry (dpy, drawable, &root, &x, &y, &width, &height,
+ &borderWidth, &depth))
+ {
+ for (s = 0; s < ScreenCount (dpy); s++)
+ {
+ if (RootWindow (dpy, s) == root)
+ return s;
+ }
+ }
+ /*
+ * Make a guess -- it's probably wrong, but then the app probably
+ * handed us a bogus drawable in this case
+ */
+ return 0;
+}
+
+unsigned int
+XftDrawDepth (XftDraw *draw)
+{
+ if (!draw->depth)
+ {
+ Window root;
+ int x, y;
+ unsigned int width, height, borderWidth, depth;
+ if (XGetGeometry (draw->dpy, draw->drawable,
+ &root, &x, &y, &width, &height,
+ &borderWidth, &depth))
+ draw->depth = depth;
+ }
+ return draw->depth;
+}
+
+unsigned int
+XftDrawBitsPerPixel (XftDraw *draw)
+{
+ if (!draw->bits_per_pixel)
+ {
+ XPixmapFormatValues *formats;
+ int nformats;
+ unsigned int depth;
+
+ if ((depth = XftDrawDepth (draw)) &&
+ (formats = XListPixmapFormats (draw->dpy, &nformats)))
+ {
+ int i;
+
+ for (i = 0; i < nformats; i++)
+ {
+ if (formats[i].depth == depth)
+ {
+ draw->bits_per_pixel = formats[i].bits_per_pixel;
+ break;
+ }
+ }
+ XFree (formats);
+ }
+ }
+ return draw->bits_per_pixel;
+}
+
+XftDraw *
+XftDrawCreate (Display *dpy,
+ Drawable drawable,
+ Visual *visual,
+ Colormap colormap)
+{
+ XftDraw *draw;
+
+ draw = (XftDraw *) malloc (sizeof (XftDraw));
+ if (!draw)
+ return 0;
+
+ draw->dpy = dpy;
+ draw->drawable = drawable;
+ draw->screen = _XftDrawScreen (dpy, drawable, visual);
+ draw->depth = 0; /* don't find out unless we need to know */
+ draw->bits_per_pixel = 0; /* don't find out unless we need to know */
+ draw->visual = visual;
+ draw->colormap = colormap;
+ draw->render.pict = 0;
+ draw->core.gc = 0;
+ draw->core.use_pixmap = 0;
+ draw->clip_type = XftClipTypeNone;
+ draw->subwindow_mode = ClipByChildren;
+ XftMemAlloc (XFT_MEM_DRAW, sizeof (XftDraw));
+ return draw;
+}
+
+XftDraw *
+XftDrawCreateBitmap (Display *dpy,
+ Pixmap bitmap)
+{
+ XftDraw *draw;
+
+ draw = (XftDraw *) malloc (sizeof (XftDraw));
+ if (!draw)
+ return 0;
+ draw->dpy = dpy;
+ draw->drawable = (Drawable) bitmap;
+ draw->screen = _XftDrawScreen (dpy, bitmap, 0);
+ draw->depth = 1;
+ draw->bits_per_pixel = 1;
+ draw->visual = 0;
+ draw->colormap = 0;
+ draw->render.pict = 0;
+ draw->core.gc = 0;
+ draw->core.use_pixmap = 0;
+ draw->clip_type = XftClipTypeNone;
+ draw->subwindow_mode = ClipByChildren;
+ XftMemAlloc (XFT_MEM_DRAW, sizeof (XftDraw));
+ return draw;
+}
+
+XftDraw *
+XftDrawCreateAlpha (Display *dpy,
+ Pixmap pixmap,
+ int depth)
+{
+ XftDraw *draw;
+
+ draw = (XftDraw *) malloc (sizeof (XftDraw));
+ if (!draw)
+ return 0;
+ draw->dpy = dpy;
+ draw->drawable = (Drawable) pixmap;
+ draw->screen = _XftDrawScreen (dpy, pixmap, 0);
+ draw->depth = depth;
+ draw->bits_per_pixel = 0; /* don't find out until we need it */
+ draw->visual = 0;
+ draw->colormap = 0;
+ draw->render.pict = 0;
+ draw->core.gc = 0;
+ draw->core.use_pixmap = 0;
+ draw->clip_type = XftClipTypeNone;
+ draw->subwindow_mode = ClipByChildren;
+ XftMemAlloc (XFT_MEM_DRAW, sizeof (XftDraw));
+ return draw;
+}
+
+static XRenderPictFormat *
+_XftDrawFormat (XftDraw *draw)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (draw->dpy, True);
+
+ if (!info->hasRender)
+ return 0;
+
+ if (draw->visual == 0)
+ {
+ XRenderPictFormat pf;
+
+ pf.type = PictTypeDirect;
+ pf.depth = XftDrawDepth (draw);
+ pf.direct.alpha = 0;
+ pf.direct.alphaMask = (1 << pf.depth) - 1;
+ return XRenderFindFormat (draw->dpy,
+ (PictFormatType|
+ PictFormatDepth|
+ PictFormatAlpha|
+ PictFormatAlphaMask),
+ &pf,
+ 0);
+ }
+ else
+ return XRenderFindVisualFormat (draw->dpy, draw->visual);
+}
+
+void
+XftDrawChange (XftDraw *draw,
+ Drawable drawable)
+{
+ draw->drawable = drawable;
+ if (draw->render.pict)
+ {
+ XRenderFreePicture (draw->dpy, draw->render.pict);
+ draw->render.pict = 0;
+ }
+ if (draw->core.gc)
+ {
+ XFreeGC (draw->dpy, draw->core.gc);
+ draw->core.gc = 0;
+ }
+}
+
+Display *
+XftDrawDisplay (XftDraw *draw)
+{
+ return draw->dpy;
+}
+
+Drawable
+XftDrawDrawable (XftDraw *draw)
+{
+ return draw->drawable;
+}
+
+Colormap
+XftDrawColormap (XftDraw *draw)
+{
+ return draw->colormap;
+}
+
+Visual *
+XftDrawVisual (XftDraw *draw)
+{
+ return draw->visual;
+}
+
+void
+XftDrawDestroy (XftDraw *draw)
+{
+ if (draw->render.pict)
+ XRenderFreePicture (draw->dpy, draw->render.pict);
+ if (draw->core.gc)
+ XFreeGC (draw->dpy, draw->core.gc);
+ switch (draw->clip_type) {
+ case XftClipTypeRegion:
+ XDestroyRegion (draw->clip.region);
+ break;
+ case XftClipTypeRectangles:
+ free (draw->clip.rect);
+ break;
+ case XftClipTypeNone:
+ break;
+ }
+ XftMemFree (XFT_MEM_DRAW, sizeof (XftDraw));
+ free (draw);
+}
+
+Picture
+XftDrawSrcPicture (XftDraw *draw, _Xconst XftColor *color)
+{
+ Display *dpy = draw->dpy;
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy, True);
+ int i;
+ XftColor bitmapColor;
+
+ if (!info)
+ return 0;
+
+ /*
+ * Monochrome targets require special handling; the PictOp controls
+ * the color, and the color must be opaque
+ */
+ if (!draw->visual && draw->depth == 1)
+ {
+ bitmapColor.color.alpha = 0xffff;
+ bitmapColor.color.red = 0xffff;
+ bitmapColor.color.green = 0xffff;
+ bitmapColor.color.blue = 0xffff;
+ color = &bitmapColor;
+ }
+
+ /*
+ * See if there's one already available
+ */
+ for (i = 0; i < XFT_NUM_SOLID_COLOR; i++)
+ {
+ if (info->colors[i].pict &&
+ info->colors[i].screen == draw->screen &&
+ !memcmp ((void *) &color->color,
+ (void *) &info->colors[i].color,
+ sizeof (XRenderColor)))
+ return info->colors[i].pict;
+ }
+ /*
+ * Pick one to replace at random
+ */
+ i = (unsigned int) rand () % XFT_NUM_SOLID_COLOR;
+ /*
+ * Recreate if it was for the wrong screen
+ */
+ if (info->colors[i].screen != draw->screen && info->colors[i].pict)
+ {
+ XRenderFreePicture (dpy, info->colors[i].pict);
+ info->colors[i].pict = 0;
+ }
+ /*
+ * Create picture if necessary
+ */
+ if (!info->colors[i].pict)
+ {
+ Pixmap pix;
+ XRenderPictureAttributes pa;
+
+ pix = XCreatePixmap (dpy, RootWindow (dpy, draw->screen), 1, 1,
+ info->solidFormat->depth);
+ pa.repeat = True;
+ info->colors[i].pict = XRenderCreatePicture (draw->dpy,
+ pix,
+ info->solidFormat,
+ CPRepeat, &pa);
+ XFreePixmap (dpy, pix);
+ }
+ /*
+ * Set to the new color
+ */
+ info->colors[i].color = color->color;
+ info->colors[i].screen = draw->screen;
+ XRenderFillRectangle (dpy, PictOpSrc,
+ info->colors[i].pict,
+ &color->color, 0, 0, 1, 1);
+ return info->colors[i].pict;
+}
+
+static int
+_XftDrawOp (_Xconst XftDraw *draw, _Xconst XftColor *color)
+{
+ if (draw->visual || draw->depth != 1)
+ return PictOpOver;
+ if (color->color.alpha >= 0x8000)
+ return PictOpOver;
+ return PictOpOutReverse;
+}
+
+static FcBool
+_XftDrawRenderPrepare (XftDraw *draw)
+{
+ if (!draw->render.pict)
+ {
+ XRenderPictFormat *format;
+ XRenderPictureAttributes pa;
+ unsigned long mask = 0;
+
+ format = _XftDrawFormat (draw);
+ if (!format)
+ return FcFalse;
+
+ if (draw->subwindow_mode == IncludeInferiors)
+ {
+ pa.subwindow_mode = IncludeInferiors;
+ mask |= CPSubwindowMode;
+ }
+ draw->render.pict = XRenderCreatePicture (draw->dpy, draw->drawable,
+ format, mask, &pa);
+ if (!draw->render.pict)
+ return FcFalse;
+ switch (draw->clip_type) {
+ case XftClipTypeRegion:
+ XRenderSetPictureClipRegion (draw->dpy, draw->render.pict,
+ draw->clip.region);
+ break;
+ case XftClipTypeRectangles:
+ XRenderSetPictureClipRectangles (draw->dpy, draw->render.pict,
+ draw->clip.rect->xOrigin,
+ draw->clip.rect->yOrigin,
+ XftClipRects(draw->clip.rect),
+ draw->clip.rect->n);
+ break;
+ case XftClipTypeNone:
+ break;
+ }
+ }
+ return FcTrue;
+}
+
+static FcBool
+_XftDrawCorePrepare (XftDraw *draw, _Xconst XftColor *color)
+{
+ if (!draw->core.gc)
+ {
+ XGCValues gcv;
+ unsigned long mask = 0;
+ if (draw->subwindow_mode == IncludeInferiors)
+ {
+ gcv.subwindow_mode = IncludeInferiors;
+ mask |= GCSubwindowMode;
+ }
+ draw->core.gc = XCreateGC (draw->dpy, draw->drawable, mask, &gcv);
+ if (!draw->core.gc)
+ return FcFalse;
+ switch (draw->clip_type) {
+ case XftClipTypeRegion:
+ XSetRegion (draw->dpy, draw->core.gc, draw->clip.region);
+ break;
+ case XftClipTypeRectangles:
+ XSetClipRectangles (draw->dpy, draw->core.gc,
+ draw->clip.rect->xOrigin,
+ draw->clip.rect->yOrigin,
+ XftClipRects (draw->clip.rect),
+ draw->clip.rect->n,
+ Unsorted);
+ break;
+ case XftClipTypeNone:
+ break;
+ }
+ }
+ XSetForeground (draw->dpy, draw->core.gc, color->pixel);
+ return FcTrue;
+}
+
+Picture
+XftDrawPicture (XftDraw *draw)
+{
+ if (!_XftDrawRenderPrepare (draw))
+ return 0;
+ return draw->render.pict;
+}
+
+#define NUM_LOCAL 1024
+
+void
+XftDrawGlyphs (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ int x,
+ int y,
+ _Xconst FT_UInt *glyphs,
+ int nglyphs)
+{
+ XftFontInt *font = (XftFontInt *) pub;
+
+ if (font->format)
+ {
+ Picture src;
+
+ if (_XftDrawRenderPrepare (draw) &&
+ (src = XftDrawSrcPicture (draw, color)))
+ XftGlyphRender (draw->dpy, _XftDrawOp (draw, color),
+ src, pub, draw->render.pict,
+ 0, 0, x, y, glyphs, nglyphs);
+ }
+ else
+ {
+ if (_XftDrawCorePrepare (draw, color))
+ XftGlyphCore (draw, color, pub, x, y, glyphs, nglyphs);
+ }
+}
+
+void
+XftDrawString8 (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len)
+{
+ FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (XftDebug () & XFT_DBG_DRAW)
+ printf ("DrawString \"%*.*s\"\n", len, len, string);
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (FT_UInt));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ glyphs[i] = XftCharIndex (draw->dpy, pub, string[i]);
+ XftDrawGlyphs (draw, color, pub, x, y, glyphs, len);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftDrawString16 (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ int x,
+ int y,
+ _Xconst FcChar16 *string,
+ int len)
+{
+ FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (FT_UInt));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ glyphs[i] = XftCharIndex (draw->dpy, pub, string[i]);
+
+ XftDrawGlyphs (draw, color, pub, x, y, glyphs, len);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftDrawString32 (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ int x,
+ int y,
+ _Xconst FcChar32 *string,
+ int len)
+{
+ FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (FT_UInt));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ glyphs[i] = XftCharIndex (draw->dpy, pub, string[i]);
+
+ XftDrawGlyphs (draw, color, pub, x, y, glyphs, len);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftDrawStringUtf8 (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len)
+{
+ FT_UInt *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
+ FcChar32 ucs4;
+ int i;
+ int l;
+ int size;
+
+ i = 0;
+ glyphs = glyphs_local;
+ size = NUM_LOCAL;
+ while (len && (l = FcUtf8ToUcs4 (string, &ucs4, len)) > 0)
+ {
+ if (i == size)
+ {
+ glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
+ if (!glyphs_new)
+ {
+ if (glyphs != glyphs_local)
+ free (glyphs);
+ return;
+ }
+ memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
+ size *= 2;
+ if (glyphs != glyphs_local)
+ free (glyphs);
+ glyphs = glyphs_new;
+ }
+ glyphs[i++] = XftCharIndex (draw->dpy, pub, ucs4);
+ string += l;
+ len -= l;
+ }
+ XftDrawGlyphs (draw, color, pub, x, y, glyphs, i);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftDrawStringUtf16 (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ FcEndian endian,
+ int len)
+{
+ FT_UInt *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
+ FcChar32 ucs4;
+ int i;
+ int l;
+ int size;
+
+ i = 0;
+ glyphs = glyphs_local;
+ size = NUM_LOCAL;
+ while (len && (l = FcUtf16ToUcs4 (string, endian, &ucs4, len)) > 0)
+ {
+ if (i == size)
+ {
+ glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
+ if (!glyphs_new)
+ {
+ if (glyphs != glyphs_local)
+ free (glyphs);
+ return;
+ }
+ memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
+ size *= 2;
+ if (glyphs != glyphs_local)
+ free (glyphs);
+ glyphs = glyphs_new;
+ }
+ glyphs[i++] = XftCharIndex (draw->dpy, pub, ucs4);
+ string += l;
+ len -= l;
+ }
+ XftDrawGlyphs (draw, color, pub, x, y, glyphs, i);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftDrawGlyphSpec (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ _Xconst XftGlyphSpec *glyphs,
+ int len)
+{
+ XftFontInt *font = (XftFontInt *) pub;
+
+ if (font->format)
+ {
+ Picture src;
+
+ if (_XftDrawRenderPrepare (draw) &&
+ (src = XftDrawSrcPicture (draw, color)))
+ {
+ XftGlyphSpecRender (draw->dpy, _XftDrawOp (draw, color),
+ src, pub, draw->render.pict,
+ 0, 0, glyphs, len);
+ }
+ }
+ else
+ {
+ if (_XftDrawCorePrepare (draw, color))
+ XftGlyphSpecCore (draw, color, pub, glyphs, len);
+ }
+}
+
+void
+XftDrawGlyphFontSpec (XftDraw *draw,
+ _Xconst XftColor *color,
+ _Xconst XftGlyphFontSpec *glyphs,
+ int len)
+{
+ int i;
+ int start;
+
+ i = 0;
+ while (i < len)
+ {
+ start = i;
+ if (((XftFontInt *) glyphs[i].font)->format)
+ {
+ Picture src;
+ while (i < len && ((XftFontInt *) glyphs[i].font)->format)
+ i++;
+ if (_XftDrawRenderPrepare (draw) &&
+ (src = XftDrawSrcPicture (draw, color)))
+ {
+ XftGlyphFontSpecRender (draw->dpy, _XftDrawOp (draw, color),
+ src, draw->render.pict,
+ 0, 0, glyphs + start , i - start);
+ }
+ }
+ else
+ {
+ while (i < len && !((XftFontInt *) glyphs[i].font)->format)
+ i++;
+ if (_XftDrawCorePrepare (draw, color))
+ XftGlyphFontSpecCore (draw, color, glyphs + start, i - start);
+ }
+ }
+}
+
+void
+XftDrawCharSpec (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *pub,
+ _Xconst XftCharSpec *chars,
+ int len)
+{
+ XftGlyphSpec *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (XftGlyphSpec));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ {
+ glyphs[i].glyph = XftCharIndex(draw->dpy, pub, chars[i].ucs4);
+ glyphs[i].x = chars[i].x;
+ glyphs[i].y = chars[i].y;
+ }
+
+ XftDrawGlyphSpec (draw, color, pub, glyphs, len);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftDrawCharFontSpec (XftDraw *draw,
+ _Xconst XftColor *color,
+ _Xconst XftCharFontSpec *chars,
+ int len)
+{
+ XftGlyphFontSpec *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (XftGlyphFontSpec));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ {
+ glyphs[i].font = chars[i].font;
+ glyphs[i].glyph = XftCharIndex(draw->dpy, glyphs[i].font, chars[i].ucs4);
+ glyphs[i].x = chars[i].x;
+ glyphs[i].y = chars[i].y;
+ }
+
+ XftDrawGlyphFontSpec (draw, color, glyphs, len);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftDrawRect (XftDraw *draw,
+ _Xconst XftColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height)
+{
+ if (_XftDrawRenderPrepare (draw))
+ {
+ XRenderFillRectangle (draw->dpy, PictOpSrc, draw->render.pict,
+ &color->color, x, y, width, height);
+ }
+ else if (_XftDrawCorePrepare (draw, color))
+ {
+ XftRectCore (draw, color, x, y, width, height);
+ }
+}
+
+Bool
+XftDrawSetClip (XftDraw *draw,
+ Region r)
+{
+ Region n = 0;
+
+ /*
+ * Check for quick exits
+ */
+ if (!r && draw->clip_type == XftClipTypeNone)
+ return True;
+
+ if (r &&
+ draw->clip_type == XftClipTypeRegion &&
+ XEqualRegion (r, draw->clip.region))
+ {
+ return True;
+ }
+
+ /*
+ * Duplicate the region so future changes can be short circuited
+ */
+ if (r)
+ {
+ n = XCreateRegion ();
+ if (n)
+ {
+ if (!XUnionRegion (n, r, n))
+ {
+ XDestroyRegion (n);
+ return False;
+ }
+ }
+ }
+
+ /*
+ * Destroy existing clip
+ */
+ switch (draw->clip_type) {
+ case XftClipTypeRegion:
+ XDestroyRegion (draw->clip.region);
+ break;
+ case XftClipTypeRectangles:
+ free (draw->clip.rect);
+ break;
+ case XftClipTypeNone:
+ break;
+ }
+
+ /*
+ * Set the clip
+ */
+ if (n)
+ {
+ draw->clip_type = XftClipTypeRegion;
+ draw->clip.region = n;
+ }
+ else
+ {
+ draw->clip_type = XftClipTypeNone;
+ }
+ /*
+ * Apply new clip to existing objects
+ */
+ if (draw->render.pict)
+ {
+ if (n)
+ XRenderSetPictureClipRegion (draw->dpy, draw->render.pict, n);
+ else
+ {
+ XRenderPictureAttributes pa;
+ pa.clip_mask = None;
+ XRenderChangePicture (draw->dpy, draw->render.pict,
+ CPClipMask, &pa);
+ }
+ }
+ if (draw->core.gc)
+ {
+ if (n)
+ XSetRegion (draw->dpy, draw->core.gc, draw->clip.region);
+ else
+ XSetClipMask (draw->dpy, draw->core.gc, None);
+ }
+ return True;
+}
+
+Bool
+XftDrawSetClipRectangles (XftDraw *draw,
+ int xOrigin,
+ int yOrigin,
+ _Xconst XRectangle *rects,
+ int n)
+{
+ XftClipRect *new = 0;
+
+ /*
+ * Check for quick exit
+ */
+ if (draw->clip_type == XftClipTypeRectangles &&
+ draw->clip.rect->n == n &&
+ (n == 0 || (draw->clip.rect->xOrigin == xOrigin &&
+ draw->clip.rect->yOrigin == yOrigin)) &&
+ !memcmp (XftClipRects (draw->clip.rect), rects, n * sizeof (XRectangle)))
+ {
+ return True;
+ }
+
+ /*
+ * Duplicate the region so future changes can be short circuited
+ */
+ new = malloc (sizeof (XftClipRect) + n * sizeof (XRectangle));
+ if (!new)
+ return False;
+
+ new->n = n;
+ new->xOrigin = xOrigin;
+ new->yOrigin = yOrigin;
+ memcpy (XftClipRects (new), rects, n * sizeof (XRectangle));
+
+ /*
+ * Destroy existing clip
+ */
+ switch (draw->clip_type) {
+ case XftClipTypeRegion:
+ XDestroyRegion (draw->clip.region);
+ break;
+ case XftClipTypeRectangles:
+ free (draw->clip.rect);
+ break;
+ case XftClipTypeNone:
+ break;
+ }
+
+ /*
+ * Set the clip
+ */
+ draw->clip_type = XftClipTypeRectangles;
+ draw->clip.rect = new;
+ /*
+ * Apply new clip to existing objects
+ */
+ if (draw->render.pict)
+ {
+ XRenderSetPictureClipRectangles (draw->dpy, draw->render.pict,
+ new->xOrigin,
+ new->yOrigin,
+ XftClipRects(new),
+ new->n);
+ }
+ if (draw->core.gc)
+ {
+ XSetClipRectangles (draw->dpy, draw->core.gc,
+ new->xOrigin,
+ new->yOrigin,
+ XftClipRects (new),
+ new->n,
+ Unsorted);
+ }
+ return True;
+}
+
+void
+XftDrawSetSubwindowMode (XftDraw *draw, int mode)
+{
+ if (mode == draw->subwindow_mode)
+ return;
+ draw->subwindow_mode = mode;
+ if (draw->render.pict)
+ {
+ XRenderPictureAttributes pa;
+
+ pa.subwindow_mode = mode;
+ XRenderChangePicture (draw->dpy, draw->render.pict,
+ CPSubwindowMode, &pa);
+ }
+ if (draw->core.gc)
+ XSetSubwindowMode (draw->dpy, draw->core.gc, mode);
+}
diff --git a/nx-X11/lib/Xft/xftextent.c b/nx-X11/lib/Xft/xftextent.c
new file mode 100644
index 000000000..bc746bebe
--- /dev/null
+++ b/nx-X11/lib/Xft/xftextent.c
@@ -0,0 +1,287 @@
+/*
+ * $Id: xftextent.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+void
+XftGlyphExtents (Display *dpy,
+ XftFont *pub,
+ _Xconst FT_UInt *glyphs,
+ int nglyphs,
+ XGlyphInfo *extents)
+{
+ XftFontInt *font = (XftFontInt *) pub;
+ FT_UInt missing[XFT_NMISSING];
+ int nmissing;
+ int n;
+ _Xconst FT_UInt *g;
+ FT_UInt glyph;
+ XftGlyph *xftg;
+ FcBool glyphs_loaded;
+ int x, y;
+ int left, right, top, bottom;
+ int overall_left, overall_right;
+ int overall_top, overall_bottom;
+
+ g = glyphs;
+ n = nglyphs;
+ nmissing = 0;
+ glyphs_loaded = FcFalse;
+ while (n--)
+ if (XftFontCheckGlyph (dpy, pub, FcFalse, *g++, missing, &nmissing))
+ glyphs_loaded = FcTrue;
+ if (nmissing)
+ XftFontLoadGlyphs (dpy, pub, FcFalse, missing, nmissing);
+ g = glyphs;
+ n = nglyphs;
+ xftg = 0;
+ while (n)
+ {
+ glyph = *g++;
+ n--;
+ if (glyph < font->num_glyphs &&
+ (xftg = font->glyphs[glyph]))
+ break;
+ }
+ if (n == 0)
+ {
+ if (xftg)
+ *extents = xftg->metrics;
+ else
+ memset (extents, '\0', sizeof (*extents));
+ }
+ else
+ {
+ x = 0;
+ y = 0;
+ overall_left = x - xftg->metrics.x;
+ overall_top = y - xftg->metrics.y;
+ overall_right = overall_left + (int) xftg->metrics.width;
+ overall_bottom = overall_top + (int) xftg->metrics.height;
+ x += xftg->metrics.xOff;
+ y += xftg->metrics.yOff;
+ while (n--)
+ {
+ glyph = *g++;
+ if (glyph < font->num_glyphs && (xftg = font->glyphs[glyph]))
+ {
+ left = x - xftg->metrics.x;
+ top = y - xftg->metrics.y;
+ right = left + (int) xftg->metrics.width;
+ bottom = top + (int) xftg->metrics.height;
+ if (left < overall_left)
+ overall_left = left;
+ if (top < overall_top)
+ overall_top = top;
+ if (right > overall_right)
+ overall_right = right;
+ if (bottom > overall_bottom)
+ overall_bottom = bottom;
+ x += xftg->metrics.xOff;
+ y += xftg->metrics.yOff;
+ }
+ }
+ extents->x = -overall_left;
+ extents->y = -overall_top;
+ extents->width = overall_right - overall_left;
+ extents->height = overall_bottom - overall_top;
+ extents->xOff = x;
+ extents->yOff = y;
+ }
+ if (glyphs_loaded)
+ _XftFontManageMemory (dpy, pub);
+}
+
+#define NUM_LOCAL 1024
+
+void
+XftTextExtents8 (Display *dpy,
+ XftFont *pub,
+ _Xconst FcChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (FT_UInt));
+ if (!glyphs)
+ {
+ memset (extents, '\0', sizeof (XGlyphInfo));
+ return;
+ }
+ }
+ for (i = 0; i < len; i++)
+ glyphs[i] = XftCharIndex (dpy, pub, string[i]);
+ XftGlyphExtents (dpy, pub, glyphs, len, extents);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftTextExtents16 (Display *dpy,
+ XftFont *pub,
+ _Xconst FcChar16 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (FT_UInt));
+ if (!glyphs)
+ {
+ memset (extents, '\0', sizeof (XGlyphInfo));
+ return;
+ }
+ }
+ for (i = 0; i < len; i++)
+ glyphs[i] = XftCharIndex (dpy, pub, string[i]);
+ XftGlyphExtents (dpy, pub, glyphs, len, extents);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftTextExtents32 (Display *dpy,
+ XftFont *pub,
+ _Xconst FcChar32 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (FT_UInt));
+ if (!glyphs)
+ {
+ memset (extents, '\0', sizeof (XGlyphInfo));
+ return;
+ }
+ }
+ for (i = 0; i < len; i++)
+ glyphs[i] = XftCharIndex (dpy, pub, string[i]);
+ XftGlyphExtents (dpy, pub, glyphs, len, extents);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftTextExtentsUtf8 (Display *dpy,
+ XftFont *pub,
+ _Xconst FcChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ FT_UInt *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
+ FcChar32 ucs4;
+ int i;
+ int l;
+ int size;
+
+ i = 0;
+ glyphs = glyphs_local;
+ size = NUM_LOCAL;
+ while (len && (l = FcUtf8ToUcs4 (string, &ucs4, len)) > 0)
+ {
+ if (i == size)
+ {
+ glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
+ if (!glyphs_new)
+ {
+ if (glyphs != glyphs_local)
+ free (glyphs);
+ memset (extents, '\0', sizeof (XGlyphInfo));
+ return;
+ }
+ memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
+ size *= 2;
+ if (glyphs != glyphs_local)
+ free (glyphs);
+ glyphs = glyphs_new;
+ }
+ glyphs[i++] = XftCharIndex (dpy, pub, ucs4);
+ string += l;
+ len -= l;
+ }
+ XftGlyphExtents (dpy, pub, glyphs, i, extents);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftTextExtentsUtf16 (Display *dpy,
+ XftFont *pub,
+ _Xconst FcChar8 *string,
+ FcEndian endian,
+ int len,
+ XGlyphInfo *extents)
+{
+ FT_UInt *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
+ FcChar32 ucs4;
+ int i;
+ int l;
+ int size;
+
+ i = 0;
+ glyphs = glyphs_local;
+ size = NUM_LOCAL;
+ while (len && (l = FcUtf16ToUcs4 (string, endian, &ucs4, len)) > 0)
+ {
+ if (i == size)
+ {
+ glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
+ if (!glyphs_new)
+ {
+ if (glyphs != glyphs_local)
+ free (glyphs);
+ memset (extents, '\0', sizeof (XGlyphInfo));
+ return;
+ }
+ memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
+ size *= 2;
+ if (glyphs != glyphs_local)
+ free (glyphs);
+ glyphs = glyphs_new;
+ }
+ glyphs[i++] = XftCharIndex (dpy, pub, ucs4);
+ string += l;
+ len -= l;
+ }
+ XftGlyphExtents (dpy, pub, glyphs, i, extents);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
diff --git a/nx-X11/lib/Xft/xftfont.c b/nx-X11/lib/Xft/xftfont.c
new file mode 100644
index 000000000..b68fa7d26
--- /dev/null
+++ b/nx-X11/lib/Xft/xftfont.c
@@ -0,0 +1,208 @@
+/*
+ * $Id: xftfont.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+FcPattern *
+XftFontMatch (Display *dpy,
+ int screen,
+ _Xconst FcPattern *pattern,
+ FcResult *result)
+{
+ FcPattern *new;
+ FcPattern *match;
+
+ if (!XftInit (0))
+ return 0;
+
+ new = FcPatternDuplicate (pattern);
+ if (!new)
+ return 0;
+
+ if (XftDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch pattern ");
+ FcPatternPrint (new);
+ }
+ FcConfigSubstitute (0, new, FcMatchPattern);
+ if (XftDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch after FcConfig substitutions ");
+ FcPatternPrint (new);
+ }
+ XftDefaultSubstitute (dpy, screen, new);
+ if (XftDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch after X resource substitutions ");
+ FcPatternPrint (new);
+ }
+
+ match = FcFontMatch (0, new, result);
+ if (XftDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch result ");
+ FcPatternPrint (match);
+ }
+ FcPatternDestroy (new);
+ return match;
+}
+
+XftFont *
+XftFontOpen (Display *dpy, int screen, ...)
+{
+ va_list va;
+ FcPattern *pat;
+ FcPattern *match;
+ FcResult result;
+ XftFont *font;
+
+ va_start (va, screen);
+ pat = FcPatternVaBuild (0, va);
+ va_end (va);
+ if (!pat)
+ {
+ if (XftDebug () & XFT_DBG_OPEN)
+ printf ("XftFontOpen: Invalid pattern argument\n");
+ return 0;
+ }
+ match = XftFontMatch (dpy, screen, pat, &result);
+ if (XftDebug () & XFT_DBG_OPEN)
+ {
+ printf ("Pattern ");
+ FcPatternPrint (pat);
+ if (match)
+ {
+ printf ("Match ");
+ FcPatternPrint (match);
+ }
+ else
+ printf ("No Match\n");
+ }
+ FcPatternDestroy (pat);
+ if (!match)
+ return 0;
+
+ font = XftFontOpenPattern (dpy, match);
+ if (!font)
+ {
+ if (XftDebug () & XFT_DBG_OPEN)
+ printf ("No Font\n");
+ FcPatternDestroy (match);
+ }
+
+ return font;
+}
+
+XftFont *
+XftFontOpenName (Display *dpy, int screen, const char *name)
+{
+ FcPattern *pat;
+ FcPattern *match;
+ FcResult result;
+ XftFont *font;
+
+ pat = FcNameParse ((FcChar8 *) name);
+ if (XftDebug () & XFT_DBG_OPEN)
+ {
+ printf ("XftFontOpenName \"%s\": ", name);
+ if (pat)
+ FcPatternPrint (pat);
+ else
+ printf ("Invalid name\n");
+ }
+
+ if (!pat)
+ return 0;
+ match = XftFontMatch (dpy, screen, pat, &result);
+ if (XftDebug () & XFT_DBG_OPEN)
+ {
+ if (match)
+ {
+ printf ("Match ");
+ FcPatternPrint (match);
+ }
+ else
+ printf ("No Match\n");
+ }
+ FcPatternDestroy (pat);
+ if (!match)
+ return 0;
+
+ font = XftFontOpenPattern (dpy, match);
+ if (!font)
+ {
+ if (XftDebug () & XFT_DBG_OPEN)
+ printf ("No Font\n");
+ FcPatternDestroy (match);
+ }
+
+ return font;
+}
+
+XftFont *
+XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd)
+{
+ FcPattern *pat;
+ FcPattern *match;
+ FcResult result;
+ XftFont *font;
+
+ pat = XftXlfdParse (xlfd, FcFalse, FcFalse);
+ if (XftDebug () & XFT_DBG_OPEN)
+ {
+ printf ("XftFontOpenXlfd \"%s\": ", xlfd);
+ if (pat)
+ printf ("Invalid xlfd\n");
+ else
+ FcPatternPrint (pat);
+ }
+
+ if (!pat)
+ return 0;
+ match = XftFontMatch (dpy, screen, pat, &result);
+ if (XftDebug () & XFT_DBG_OPEN)
+ {
+ if (match)
+ {
+ printf ("Match ");
+ FcPatternPrint (match);
+ }
+ else
+ printf ("No Match\n");
+ }
+ FcPatternDestroy (pat);
+ if (!match)
+ return 0;
+
+ font = XftFontOpenPattern (dpy, match);
+ if (!font)
+ {
+ if (XftDebug () & XFT_DBG_OPEN)
+ printf ("No Font\n");
+ FcPatternDestroy (match);
+ }
+
+ return font;
+}
+
diff --git a/nx-X11/lib/Xft/xftfreetype.c b/nx-X11/lib/Xft/xftfreetype.c
new file mode 100644
index 000000000..abc7c8556
--- /dev/null
+++ b/nx-X11/lib/Xft/xftfreetype.c
@@ -0,0 +1,1156 @@
+/*
+ * $Id: xftfreetype.c,v 1.5 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+FT_Library _XftFTlibrary;
+
+#define FT_Matrix_Equal(a,b) ((a)->xx == (b)->xx && \
+ (a)->yy == (b)->yy && \
+ (a)->xy == (b)->xy && \
+ (a)->yx == (b)->yx)
+/*
+ * List of all open files (each face in a file is managed separately)
+ */
+
+static XftFtFile *_XftFtFiles;
+int XftMaxFreeTypeFiles = 5;
+
+static XftFtFile *
+_XftGetFile (const FcChar8 *file, int id)
+{
+ XftFtFile *f;
+
+ if (!XftInitFtLibrary ())
+ return 0;
+
+ for (f = _XftFtFiles; f; f = f->next)
+ {
+ if (!strcmp (f->file, (char *) file) && f->id == id)
+ {
+ ++f->ref;
+ if (XftDebug () & XFT_DBG_REF)
+ printf ("FontFile %s/%d matches existing (%d)\n",
+ file, id, f->ref);
+ return f;
+ }
+ }
+ f = malloc (sizeof (XftFtFile) + strlen ((char *) file) + 1);
+ if (!f)
+ return 0;
+
+ XftMemAlloc (XFT_MEM_FILE, sizeof (XftFtFile) + strlen ((char *) file) + 1);
+ if (XftDebug () & XFT_DBG_REF)
+ printf ("FontFile %s/%d matches new\n",
+ file, id);
+ f->next = _XftFtFiles;
+ _XftFtFiles = f;
+
+ f->ref = 1;
+
+ f->file = (char *) (f+1);
+ strcpy (f->file, (char *) file);
+ f->id = id;
+
+ f->lock = 0;
+ f->face = 0;
+ f->xsize = 0;
+ f->ysize = 0;
+ f->matrix.xx = f->matrix.xy = f->matrix.yx = f->matrix.yy = 0;
+ return f;
+}
+
+static XftFtFile *
+_XftGetFaceFile (FT_Face face)
+{
+ XftFtFile *f;
+
+ f = malloc (sizeof (XftFtFile));
+ if (!f)
+ return 0;
+ XftMemAlloc (XFT_MEM_FILE, sizeof(XftFtFile));
+ f->next = 0;
+
+ f->ref = 1;
+
+ f->file = 0;
+ f->id = 0;
+ f->lock = 0;
+ f->face = face;
+ f->xsize = 0;
+ f->ysize = 0;
+ f->matrix.xx = f->matrix.xy = f->matrix.yx = f->matrix.yy = 0;
+ return f;
+}
+
+static int
+_XftNumFiles (void)
+{
+ XftFtFile *f;
+ int count = 0;
+ for (f = _XftFtFiles; f; f = f->next)
+ if (f->face && !f->lock)
+ ++count;
+ return count;
+}
+
+static XftFtFile *
+_XftNthFile (int n)
+{
+ XftFtFile *f;
+ int count = 0;
+ for (f = _XftFtFiles; f; f = f->next)
+ if (f->face && !f->lock)
+ if (count++ == n)
+ break;
+ return f;
+}
+
+static void
+_XftUncacheFiles (void)
+{
+ int n;
+ XftFtFile *f;
+ while ((n = _XftNumFiles ()) > XftMaxFreeTypeFiles)
+ {
+ f = _XftNthFile (rand () % n);
+ if (f)
+ {
+ if (XftDebug() & XFT_DBG_REF)
+ printf ("Discard file %s/%d from cache\n",
+ f->file, f->id);
+ FT_Done_Face (f->face);
+ f->face = 0;
+ }
+ }
+}
+
+static FT_Face
+_XftLockFile (XftFtFile *f)
+{
+ ++f->lock;
+ if (!f->face)
+ {
+ if (XftDebug() & XFT_DBG_REF)
+ printf ("Loading file %s/%d\n", f->file, f->id);
+ if (FT_New_Face (_XftFTlibrary, f->file, f->id, &f->face))
+ --f->lock;
+
+ f->xsize = 0;
+ f->ysize = 0;
+ f->matrix.xx = f->matrix.xy = f->matrix.yx = f->matrix.yy = 0;
+ _XftUncacheFiles ();
+ }
+ return f->face;
+}
+
+static void
+_XftLockError (char *reason)
+{
+ fprintf (stderr, "Xft: locking error %s\n", reason);
+}
+
+static void
+_XftUnlockFile (XftFtFile *f)
+{
+ if (--f->lock < 0)
+ _XftLockError ("too many file unlocks");
+}
+
+#if HAVE_FT_BITMAP_SIZE_Y_PPEM
+#define X_SIZE(face,i) ((face)->available_sizes[i].x_ppem)
+#define Y_SIZE(face,i) ((face)->available_sizes[i].y_ppem)
+#else
+#define X_SIZE(face,i) ((face)->available_sizes[i].width << 6)
+#define Y_SIZE(face,i) ((face)->available_sizes[i].height << 6)
+#endif
+
+FcBool
+_XftSetFace (XftFtFile *f, FT_F26Dot6 xsize, FT_F26Dot6 ysize, FT_Matrix *matrix)
+{
+ FT_Face face = f->face;
+
+ if (f->xsize != xsize || f->ysize != ysize)
+ {
+ if (XftDebug() & XFT_DBG_GLYPH)
+ printf ("Set face size to %dx%d (%dx%d)\n",
+ (int) (xsize >> 6), (int) (ysize >> 6), (int) xsize, (int) ysize);
+ /*
+ * Bitmap only faces must match exactly, so find the closest
+ * one (height dominant search)
+ */
+ if (!(face->face_flags & FT_FACE_FLAG_SCALABLE))
+ {
+ int i, best = 0;
+
+#define xft_abs(a) ((a) < 0 ? -(a) : (a))
+#define dist(a,b) (xft_abs((a)-(b)))
+
+ for (i = 1; i < face->num_fixed_sizes; i++)
+ {
+ if (dist (ysize, Y_SIZE(face,i)) <
+ dist (ysize, Y_SIZE(face, best)) ||
+ (dist (ysize, Y_SIZE(face, i)) ==
+ dist (ysize, Y_SIZE(face, best)) &&
+ dist (xsize, X_SIZE(face, i)) <
+ dist (xsize, X_SIZE(face, best))))
+ {
+ best = i;
+ }
+ }
+ /*
+ * Freetype 2.1.7 and earlier used width/height
+ * for matching sizes in the BDF and PCF loaders.
+ * This has been fixed for 2.1.8. Because BDF and PCF
+ * files have but a single strike per file, we can
+ * simply try both sizes.
+ */
+ if (
+#if HAVE_FT_BITMAP_SIZE_Y_PPEM
+ FT_Set_Char_Size (face, face->available_sizes[best].x_ppem,
+ face->available_sizes[best].y_ppem, 0, 0) != 0
+ &&
+#endif
+ FT_Set_Char_Size (face, face->available_sizes[best].width << 6,
+ face->available_sizes[best].height << 6,
+ 0, 0) != 0)
+ {
+ return False;
+ }
+ }
+ else
+ {
+ if (FT_Set_Char_Size (face, xsize, ysize, 0, 0))
+ {
+ return False;
+ }
+ }
+ f->xsize = xsize;
+ f->ysize = ysize;
+ }
+ if (!FT_Matrix_Equal (&f->matrix, matrix))
+ {
+ if (XftDebug() & XFT_DBG_GLYPH)
+ printf ("Set face matrix to (%g,%g,%g,%g)\n",
+ (double) matrix->xx / 0x10000,
+ (double) matrix->xy / 0x10000,
+ (double) matrix->yx / 0x10000,
+ (double) matrix->yy / 0x10000);
+ FT_Set_Transform (face, matrix, 0);
+ f->matrix = *matrix;
+ }
+ return True;
+}
+
+static void
+_XftReleaseFile (XftFtFile *f)
+{
+ XftFtFile **prev;
+
+ if (--f->ref != 0)
+ return;
+ if (f->lock)
+ _XftLockError ("Attempt to close locked file");
+ if (f->file)
+ {
+ for (prev = &_XftFtFiles; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == f)
+ {
+ *prev = f->next;
+ break;
+ }
+ }
+ if (f->face)
+ FT_Done_Face (f->face);
+ }
+ XftMemFree (XFT_MEM_FILE,
+ sizeof (XftFtFile) + (f->file ? strlen (f->file) + 1 : 0));
+ free (f);
+}
+
+/*
+ * Find a prime larger than the minimum reasonable hash size
+ */
+
+static FcChar32
+_XftSqrt (FcChar32 a)
+{
+ FcChar32 l, h, m;
+
+ l = 2;
+ h = a/2;
+ while ((h-l) > 1)
+ {
+ m = (h+l) >> 1;
+ if (m * m < a)
+ l = m;
+ else
+ h = m;
+ }
+ return h;
+}
+
+static FcBool
+_XftIsPrime (FcChar32 i)
+{
+ FcChar32 l, t;
+
+ if (i < 2)
+ return FcFalse;
+ if ((i & 1) == 0)
+ {
+ if (i == 2)
+ return FcTrue;
+ return FcFalse;
+ }
+ l = _XftSqrt (i) + 1;
+ for (t = 3; t <= l; t += 2)
+ if (i % t == 0)
+ return FcFalse;
+ return FcTrue;
+}
+
+static FcChar32
+_XftHashSize (FcChar32 num_unicode)
+{
+ /* at least 31.25 % extra space */
+ FcChar32 hash = num_unicode + (num_unicode >> 2) + (num_unicode >> 4);
+
+ if ((hash & 1) == 0)
+ hash++;
+ while (!_XftIsPrime (hash))
+ hash += 2;
+ return hash;
+}
+
+FT_Face
+XftLockFace (XftFont *public)
+{
+ XftFontInt *font = (XftFontInt *) public;
+ XftFontInfo *fi = &font->info;
+ FT_Face face;
+
+ face = _XftLockFile (fi->file);
+ /*
+ * Make sure the face is usable at the requested size
+ */
+ if (face && !_XftSetFace (fi->file, fi->xsize, fi->ysize, &fi->matrix))
+ {
+ _XftUnlockFile (fi->file);
+ face = 0;
+ }
+ return face;
+}
+
+void
+XftUnlockFace (XftFont *public)
+{
+ XftFontInt *font = (XftFontInt *) public;
+ _XftUnlockFile (font->info.file);
+}
+
+static FcBool
+XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy, True);
+ FcChar8 *filename;
+ int id;
+ double dsize;
+ double aspect;
+ FcMatrix *font_matrix;
+ FcBool hinting, vertical_layout, autohint, global_advance;
+#ifdef FC_HINT_STYLE
+ int hint_style;
+#endif
+ FcChar32 hash, *hashp;
+ FT_Face face;
+ int nhash;
+
+ if (!info)
+ return FcFalse;
+
+ /*
+ * Find the associated file
+ */
+ switch (FcPatternGetString (pattern, FC_FILE, 0, &filename)) {
+ case FcResultNoMatch:
+ filename = 0;
+ break;
+ case FcResultMatch:
+ break;
+ default:
+ goto bail0;
+ }
+
+ switch (FcPatternGetInteger (pattern, FC_INDEX, 0, &id)) {
+ case FcResultNoMatch:
+ id = 0;
+ break;
+ case FcResultMatch:
+ break;
+ default:
+ goto bail0;
+ }
+
+ if (filename)
+ fi->file = _XftGetFile (filename, id);
+ else if (FcPatternGetFTFace (pattern, FC_FT_FACE, 0, &face) == FcResultMatch
+ && face)
+ fi->file = _XftGetFaceFile (face);
+ else
+ fi->file = 0;
+ if (!fi->file)
+ goto bail0;
+
+ /*
+ * Compute pixel size
+ */
+ if (FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &dsize) != FcResultMatch)
+ goto bail1;
+
+ if (FcPatternGetDouble (pattern, FC_ASPECT, 0, &aspect) != FcResultMatch)
+ aspect = 1.0;
+
+ fi->ysize = (FT_F26Dot6) (dsize * 64.0);
+ fi->xsize = (FT_F26Dot6) (dsize * aspect * 64.0);
+
+ if (XftDebug() & XFT_DBG_OPEN)
+ printf ("XftFontInfoFill: %s: %d (%g pixels)\n",
+ (filename ? filename : (FcChar8 *) "<none>"), id, dsize);
+ /*
+ * Get antialias value
+ */
+ switch (FcPatternGetBool (pattern, FC_ANTIALIAS, 0, &fi->antialias)) {
+ case FcResultNoMatch:
+ fi->antialias = True;
+ break;
+ case FcResultMatch:
+ break;
+ default:
+ goto bail1;
+ }
+
+ /*
+ * Get rgba value
+ */
+ switch (FcPatternGetInteger (pattern, FC_RGBA, 0, &fi->rgba)) {
+ case FcResultNoMatch:
+ fi->rgba = FC_RGBA_UNKNOWN;
+ break;
+ case FcResultMatch:
+ break;
+ default:
+ goto bail1;
+ }
+
+ /*
+ * Get matrix and transform values
+ */
+ switch (FcPatternGetMatrix (pattern, FC_MATRIX, 0, &font_matrix)) {
+ case FcResultNoMatch:
+ fi->matrix.xx = fi->matrix.yy = 0x10000;
+ fi->matrix.xy = fi->matrix.yx = 0;
+ break;
+ case FcResultMatch:
+ fi->matrix.xx = 0x10000L * font_matrix->xx;
+ fi->matrix.yy = 0x10000L * font_matrix->yy;
+ fi->matrix.xy = 0x10000L * font_matrix->xy;
+ fi->matrix.yx = 0x10000L * font_matrix->yx;
+ break;
+ default:
+ goto bail1;
+ }
+
+ fi->transform = (fi->matrix.xx != 0x10000 || fi->matrix.xy != 0 ||
+ fi->matrix.yx != 0 || fi->matrix.yy != 0x10000);
+
+ /*
+ * Get render value, set to false if no Render extension present
+ */
+ if (info->hasRender)
+ {
+ switch (FcPatternGetBool (pattern, XFT_RENDER, 0, &fi->render)) {
+ case FcResultNoMatch:
+ fi->render = info->hasRender;
+ break;
+ case FcResultMatch:
+ break;
+ default:
+ goto bail1;
+ }
+ }
+ else
+ fi->render = FcFalse;
+
+ /*
+ * Compute glyph load flags
+ */
+ fi->load_flags = FT_LOAD_DEFAULT;
+
+ /* disable bitmaps when anti-aliasing or transforming glyphs */
+ if (fi->antialias || fi->transform)
+ fi->load_flags |= FT_LOAD_NO_BITMAP;
+
+ /* disable hinting if requested */
+ switch (FcPatternGetBool (pattern, FC_HINTING, 0, &hinting)) {
+ case FcResultNoMatch:
+ hinting = FcTrue;
+ break;
+ case FcResultMatch:
+ break;
+ default:
+ goto bail1;
+ }
+
+#ifdef FC_EMBOLDEN
+ switch (FcPatternGetBool (pattern, FC_EMBOLDEN, 0, &fi->embolden)) {
+ case FcResultNoMatch:
+ fi->embolden = FcFalse;
+ break;
+ case FcResultMatch:
+ break;
+ default:
+ goto bail1;
+ }
+#else
+ fi->embolden = FcFalse;
+#endif
+
+#ifdef FC_HINT_STYLE
+ switch (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style)) {
+ case FcResultNoMatch:
+ hint_style = FC_HINT_FULL;
+ break;
+ case FcResultMatch:
+ break;
+ default:
+ goto bail1;
+ }
+#endif
+
+ if (!hinting
+#ifdef FC_HINT_STYLE
+ || hint_style == FC_HINT_NONE
+#endif
+ )
+ {
+ fi->load_flags |= FT_LOAD_NO_HINTING;
+ }
+
+ /* Figure out the load target, which modifies the hinting
+ * behavior of FreeType based on the intended use of the glyphs.
+ */
+ if (fi->antialias)
+ {
+#ifdef FC_HINT_STYLE
+#ifdef FT_LOAD_TARGET_LIGHT
+ if (FC_HINT_NONE < hint_style && hint_style < FC_HINT_FULL)
+ {
+ fi->load_flags |= FT_LOAD_TARGET_LIGHT;
+ }
+ else
+#endif
+#endif
+ {
+ /* autohinter will snap stems to integer widths, when
+ * the LCD targets are used.
+ */
+ switch (fi->rgba) {
+ case FC_RGBA_RGB:
+ case FC_RGBA_BGR:
+#ifdef FT_LOAD_TARGET_LCD
+ fi->load_flags |= FT_LOAD_TARGET_LCD;
+#endif
+ break;
+ case FC_RGBA_VRGB:
+ case FC_RGBA_VBGR:
+#ifdef FT_LOAD_TARGET_LCD_V
+ fi->load_flags |= FT_LOAD_TARGET_LCD_V;
+#endif
+ break;
+ }
+ }
+ }
+#ifdef FT_LOAD_TARGET_MONO
+ else
+ fi->load_flags |= FT_LOAD_TARGET_MONO;
+#endif
+
+ /* set vertical layout if requested */
+ switch (FcPatternGetBool (pattern, FC_VERTICAL_LAYOUT, 0, &vertical_layout)) {
+ case FcResultNoMatch:
+ vertical_layout = FcFalse;
+ break;
+ case FcResultMatch:
+ break;
+ default:
+ goto bail1;
+ }
+
+ if (vertical_layout)
+ fi->load_flags |= FT_LOAD_VERTICAL_LAYOUT;
+
+ /* force autohinting if requested */
+ switch (FcPatternGetBool (pattern, FC_AUTOHINT, 0, &autohint)) {
+ case FcResultNoMatch:
+ autohint = FcFalse;
+ break;
+ case FcResultMatch:
+ break;
+ default:
+ goto bail1;
+ }
+
+ if (autohint)
+ fi->load_flags |= FT_LOAD_FORCE_AUTOHINT;
+
+ /* disable global advance width (for broken DynaLab TT CJK fonts) */
+ switch (FcPatternGetBool (pattern, FC_GLOBAL_ADVANCE, 0, &global_advance)) {
+ case FcResultNoMatch:
+ global_advance = FcTrue;
+ break;
+ case FcResultMatch:
+ break;
+ default:
+ goto bail1;
+ }
+
+ if (!global_advance)
+ fi->load_flags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
+
+ /*
+ * Get requested spacing value
+ */
+ switch (FcPatternGetInteger (pattern, FC_SPACING, 0, &fi->spacing)) {
+ case FcResultNoMatch:
+ fi->spacing = FC_PROPORTIONAL;
+ break;
+ case FcResultMatch:
+ break;
+ default:
+ goto bail1;
+ }
+
+ /*
+ * Check for minspace
+ */
+
+ switch (FcPatternGetBool (pattern, FC_MINSPACE, 0, &fi->minspace)) {
+ case FcResultNoMatch:
+ fi->minspace = FcFalse;
+ break;
+ case FcResultMatch:
+ break;
+ default:
+ goto bail1;
+ }
+ /*
+ * Check for fixed pixel spacing
+ */
+ switch (FcPatternGetInteger (pattern, FC_CHAR_WIDTH, 0, &fi->char_width)) {
+ case FcResultNoMatch:
+ fi->char_width = 0;
+ break;
+ case FcResultMatch:
+ if (fi->char_width)
+ fi->spacing = FC_MONO;
+ break;
+ default:
+ goto bail1;
+ }
+
+ /*
+ * Step over hash value in the structure
+ */
+ hash = 0;
+ hashp = (FcChar32 *) fi + 1;
+ nhash = (sizeof (XftFontInfo) / sizeof (FcChar32)) - 1;
+
+ while (nhash--)
+ hash += *hashp++;
+ fi->hash = hash;
+
+ /*
+ * All done
+ */
+ return FcTrue;
+
+bail1:
+ _XftReleaseFile (fi->file);
+ fi->file = 0;
+bail0:
+ return FcFalse;
+}
+
+static void
+XftFontInfoEmpty (Display *dpy, XftFontInfo *fi)
+{
+ if (fi->file)
+ _XftReleaseFile (fi->file);
+}
+
+XftFontInfo *
+XftFontInfoCreate (Display *dpy, _Xconst FcPattern *pattern)
+{
+ XftFontInfo *fi = malloc (sizeof (XftFontInfo));
+
+ if (!fi)
+ return 0;
+
+ if (!XftFontInfoFill (dpy, pattern, fi))
+ {
+ free (fi);
+ fi = 0;
+ }
+ XftMemAlloc (XFT_MEM_FONT, sizeof (XftFontInfo));
+ return fi;
+}
+
+void
+XftFontInfoDestroy (Display *dpy, XftFontInfo *fi)
+{
+ XftFontInfoEmpty (dpy, fi);
+ XftMemFree (XFT_MEM_FONT, sizeof (XftFontInfo));
+ free (fi);
+}
+
+FcChar32
+XftFontInfoHash (_Xconst XftFontInfo *fi)
+{
+ return fi->hash;
+}
+
+FcBool
+XftFontInfoEqual (_Xconst XftFontInfo *a, _Xconst XftFontInfo *b)
+{
+ return memcmp ((void *) a, (void *) b, sizeof (XftFontInfo)) == 0;
+}
+
+XftFont *
+XftFontOpenInfo (Display *dpy,
+ FcPattern *pattern,
+ XftFontInfo *fi)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy, True);
+ FT_Face face;
+ XftFont **bucket;
+ XftFontInt *font;
+ XRenderPictFormat *format;
+ FcCharSet *charset;
+ FcChar32 num_unicode;
+ FcChar32 hash_value;
+ FcChar32 rehash_value;
+ FcBool antialias;
+ int max_glyph_memory;
+ int alloc_size;
+ int ascent, descent, height;
+ int i;
+ int num_glyphs;
+
+ if (!info)
+ return 0;
+ /*
+ * Find a matching previously opened font
+ */
+ bucket = &info->fontHash[fi->hash % XFT_NUM_FONT_HASH];
+ for (font = (XftFontInt *) *bucket; font; font = (XftFontInt *) font->hash_next)
+ if (XftFontInfoEqual (&font->info, fi))
+ {
+ if (!font->ref++)
+ --info->num_unref_fonts;
+ FcPatternDestroy (pattern);
+ return &font->public;
+ }
+
+ /*
+ * No existing font, create another.
+ */
+
+ if (XftDebug () & XFT_DBG_CACHE)
+ printf ("New font %s/%d size %dx%d\n",
+ fi->file->file, fi->file->id,
+ (int) fi->xsize >> 6, (int) fi->ysize >> 6);
+
+ if (FcPatternGetInteger (pattern, XFT_MAX_GLYPH_MEMORY, 0,
+ &max_glyph_memory) != FcResultMatch)
+ max_glyph_memory = XFT_FONT_MAX_GLYPH_MEMORY;
+
+ face = _XftLockFile (fi->file);
+ if (!face)
+ goto bail0;
+
+ if (!_XftSetFace (fi->file, fi->xsize, fi->ysize, &fi->matrix))
+ goto bail1;
+
+ /*
+ * Get the set of Unicode codepoints covered by the font.
+ * If the incoming pattern doesn't provide this data, go
+ * off and compute it. Yes, this is expensive, but it's
+ * required to map Unicode to glyph indices.
+ */
+ if (FcPatternGetCharSet (pattern, FC_CHARSET, 0, &charset) == FcResultMatch)
+ charset = FcCharSetCopy (charset);
+ else
+ charset = FcFreeTypeCharSet (face, FcConfigGetBlanks (0));
+
+ antialias = fi->antialias;
+ if (!(face->face_flags & FT_FACE_FLAG_SCALABLE))
+ antialias = FcFalse;
+
+ /*
+ * Find the appropriate picture format
+ */
+ if (fi->render)
+ {
+ if (antialias)
+ {
+ switch (fi->rgba) {
+ case FC_RGBA_RGB:
+ case FC_RGBA_BGR:
+ case FC_RGBA_VRGB:
+ case FC_RGBA_VBGR:
+ format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
+ break;
+ default:
+ format = XRenderFindStandardFormat (dpy, PictStandardA8);
+ break;
+ }
+ }
+ else
+ {
+ format = XRenderFindStandardFormat (dpy, PictStandardA1);
+ }
+
+ if (!format)
+ goto bail2;
+ }
+ else
+ format = 0;
+
+ if (charset)
+ {
+ num_unicode = FcCharSetCount (charset);
+ hash_value = _XftHashSize (num_unicode);
+ rehash_value = hash_value - 2;
+ }
+ else
+ {
+ num_unicode = 0;
+ hash_value = 0;
+ rehash_value = 0;
+ }
+
+ /*
+ * Sometimes the glyphs are numbered 1..n, other times 0..n-1,
+ * accept either numbering scheme by making room in the table
+ */
+ num_glyphs = face->num_glyphs + 1;
+ alloc_size = (sizeof (XftFontInt) +
+ num_glyphs * sizeof (XftGlyph *) +
+ hash_value * sizeof (XftUcsHash));
+ font = malloc (alloc_size);
+
+ if (!font)
+ goto bail2;
+
+ XftMemAlloc (XFT_MEM_FONT, alloc_size);
+
+ /*
+ * Public fields
+ */
+ if (fi->transform)
+ {
+ FT_Vector vector;
+
+ vector.x = 0;
+ vector.y = face->size->metrics.descender;
+ FT_Vector_Transform (&vector, &fi->matrix);
+ descent = -(vector.y >> 6);
+
+ vector.x = 0;
+ vector.y = face->size->metrics.ascender;
+ FT_Vector_Transform (&vector, &fi->matrix);
+ ascent = vector.y >> 6;
+
+ if (fi->minspace)
+ height = ascent + descent;
+ else
+ {
+ vector.x = 0;
+ vector.y = face->size->metrics.height;
+ FT_Vector_Transform (&vector, &fi->matrix);
+ height = vector.y >> 6;
+ }
+ }
+ else
+ {
+ descent = -(face->size->metrics.descender >> 6);
+ ascent = face->size->metrics.ascender >> 6;
+ if (fi->minspace)
+ height = ascent + descent;
+ else
+ height = face->size->metrics.height >> 6;
+ }
+ font->public.ascent = ascent;
+ font->public.descent = descent;
+ font->public.height = height;
+
+ if (fi->char_width)
+ font->public.max_advance_width = fi->char_width;
+ else
+ {
+ if (fi->transform)
+ {
+ FT_Vector vector;
+ vector.x = face->size->metrics.max_advance;
+ vector.y = 0;
+ FT_Vector_Transform (&vector, &fi->matrix);
+ font->public.max_advance_width = vector.x >> 6;
+ }
+ else
+ font->public.max_advance_width = face->size->metrics.max_advance >> 6;
+ }
+ font->public.charset = charset;
+ font->public.pattern = pattern;
+
+ /*
+ * Management fields
+ */
+ font->ref = 1;
+
+ font->next = info->fonts;
+ info->fonts = &font->public;
+
+ font->hash_next = *bucket;
+ *bucket = &font->public;
+
+ /*
+ * Copy the info over
+ */
+ font->info = *fi;
+ /*
+ * reset the antialias field. It can't
+ * be set correctly until the font is opened,
+ * which doesn't happen in XftFontInfoFill
+ */
+ font->info.antialias = antialias;
+ /*
+ * bump XftFile reference count
+ */
+ font->info.file->ref++;
+
+ /*
+ * Per glyph information
+ */
+ font->glyphs = (XftGlyph **) (font + 1);
+ memset (font->glyphs, '\0', num_glyphs * sizeof (XftGlyph *));
+ font->num_glyphs = num_glyphs;
+ /*
+ * Unicode hash table information
+ */
+ font->hash_table = (XftUcsHash *) (font->glyphs + font->num_glyphs);
+ for (i = 0; i < hash_value; i++)
+ {
+ font->hash_table[i].ucs4 = ((FcChar32) ~0);
+ font->hash_table[i].glyph = 0;
+ }
+ font->hash_value = hash_value;
+ font->rehash_value = rehash_value;
+ /*
+ * X specific fields
+ */
+ font->glyphset = 0;
+ font->format = format;
+
+ /*
+ * Glyph memory management fields
+ */
+ font->glyph_memory = 0;
+ font->max_glyph_memory = max_glyph_memory;
+ font->use_free_glyphs = info->use_free_glyphs;
+
+ _XftUnlockFile (fi->file);
+
+ return &font->public;
+
+bail2:
+ FcCharSetDestroy (charset);
+bail1:
+ _XftUnlockFile (fi->file);
+bail0:
+ return 0;
+}
+
+XftFont *
+XftFontOpenPattern (Display *dpy, FcPattern *pattern)
+{
+ XftFontInfo info;
+ XftFont *font;
+
+ if (!XftFontInfoFill (dpy, pattern, &info))
+ return 0;
+
+ font = XftFontOpenInfo (dpy, pattern, &info);
+ XftFontInfoEmpty (dpy, &info);
+ return font;
+}
+
+XftFont *
+XftFontCopy (Display *dpy, XftFont *public)
+{
+ XftFontInt *font = (XftFontInt *) public;
+
+ font->ref++;
+ return public;
+}
+
+static void
+XftFontDestroy (Display *dpy, XftFont *public)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy, False);
+ XftFontInt *font = (XftFontInt *) public;
+ int i;
+
+ /* note reduction in memory use */
+ if (info)
+ info->glyph_memory -= font->glyph_memory;
+ /* Clean up the info */
+ XftFontInfoEmpty (dpy, &font->info);
+ /* Free the glyphset */
+ if (font->glyphset)
+ XRenderFreeGlyphSet (dpy, font->glyphset);
+ /* Free the glyphs */
+ for (i = 0; i < font->num_glyphs; i++)
+ {
+ XftGlyph *xftg = font->glyphs[i];
+ if (xftg)
+ {
+ if (xftg->bitmap)
+ free (xftg->bitmap);
+ free (xftg);
+ }
+ }
+
+ /* Free the pattern and the charset */
+ FcPatternDestroy (font->public.pattern);
+ FcCharSetDestroy (font->public.charset);
+
+ /* Finally, free the font structure */
+ XftMemFree (XFT_MEM_FONT, sizeof (XftFontInt) +
+ font->num_glyphs * sizeof (XftGlyph *) +
+ font->hash_value * sizeof (XftUcsHash));
+ free (font);
+}
+
+static XftFont *
+XftFontFindNthUnref (XftDisplayInfo *info, int n)
+{
+ XftFont *public;
+ XftFontInt *font;
+
+ for (public = info->fonts; public; public = font->next)
+ {
+ font = (XftFontInt*) public;
+ if (!font->ref && !n--)
+ break;
+ }
+ return public;
+}
+
+void
+XftFontManageMemory (Display *dpy)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy, False);
+ XftFont **prev;
+ XftFont *public;
+ XftFontInt *font;
+
+ if (!info)
+ return;
+ while (info->num_unref_fonts > info->max_unref_fonts)
+ {
+ public = XftFontFindNthUnref (info, rand() % info->num_unref_fonts);
+ font = (XftFontInt *) public;
+
+ if (XftDebug () & XFT_DBG_CACHE)
+ printf ("freeing unreferenced font %s/%d size %dx%d\n",
+ font->info.file->file, font->info.file->id,
+ (int) font->info.xsize >> 6, (int) font->info.ysize >> 6);
+
+ /* Unhook from display list */
+ for (prev = &info->fonts; *prev; prev = &(*(XftFontInt **) prev)->next)
+ {
+ if (*prev == public)
+ {
+ *prev = font->next;
+ break;
+ }
+ }
+ /* Unhook from hash list */
+ for (prev = &info->fontHash[font->info.hash % XFT_NUM_FONT_HASH];
+ *prev;
+ prev = &(*(XftFontInt **) prev)->hash_next)
+ {
+ if (*prev == public)
+ {
+ *prev = font->hash_next;
+ break;
+ }
+ }
+ /* Destroy the font */
+ XftFontDestroy (dpy, public);
+ --info->num_unref_fonts;
+ }
+}
+
+void
+XftFontClose (Display *dpy, XftFont *public)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy, False);
+ XftFontInt *font = (XftFontInt *) public;
+
+ if (--font->ref != 0)
+ return;
+
+ if (info)
+ {
+ ++info->num_unref_fonts;
+ XftFontManageMemory (dpy);
+ }
+ else
+ {
+ XftFontDestroy (dpy, public);
+ }
+}
+
+FcBool
+XftInitFtLibrary (void)
+{
+ if (_XftFTlibrary)
+ return FcTrue;
+ if (FT_Init_FreeType (&_XftFTlibrary))
+ return FcFalse;
+ return FcTrue;
+}
diff --git a/nx-X11/lib/Xft/xftglyphs.c b/nx-X11/lib/Xft/xftglyphs.c
new file mode 100644
index 000000000..c1ee42142
--- /dev/null
+++ b/nx-X11/lib/Xft/xftglyphs.c
@@ -0,0 +1,825 @@
+/*
+ * $Id: xftglyphs.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+#include <freetype/ftoutln.h>
+
+static const int filters[3][3] = {
+ /* red */
+#if 0
+{ 65538*4/7,65538*2/7,65538*1/7 },
+ /* green */
+{ 65536*1/4, 65536*2/4, 65537*1/4 },
+ /* blue */
+{ 65538*1/7,65538*2/7,65538*4/7 },
+#endif
+{ 65538*9/13,65538*3/13,65538*1/13 },
+ /* green */
+{ 65538*1/6, 65538*4/6, 65538*1/6 },
+ /* blue */
+{ 65538*1/13,65538*3/13,65538*9/13 },
+};
+
+/*
+ * Validate the memory info for a font
+ */
+
+static void
+_XftFontValidateMemory (Display *dpy, XftFont *public)
+{
+ XftFontInt *font = (XftFontInt *) public;
+ unsigned long glyph_memory;
+ FT_UInt glyphindex;
+ XftGlyph *xftg;
+
+ glyph_memory = 0;
+ for (glyphindex = 0; glyphindex < font->num_glyphs; glyphindex++)
+ {
+ xftg = font->glyphs[glyphindex];
+ if (xftg)
+ {
+ glyph_memory += xftg->glyph_memory;
+ }
+ }
+ if (glyph_memory != font->glyph_memory)
+ printf ("Font glyph cache incorrect has %ld bytes, should have %ld\n",
+ font->glyph_memory, glyph_memory);
+}
+
+void
+XftFontLoadGlyphs (Display *dpy,
+ XftFont *pub,
+ FcBool need_bitmaps,
+ _Xconst FT_UInt *glyphs,
+ int nglyph)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy, True);
+ XftFontInt *font = (XftFontInt *) pub;
+ FT_Error error;
+ FT_UInt glyphindex;
+ FT_GlyphSlot glyphslot;
+ XftGlyph *xftg;
+ Glyph glyph;
+ unsigned char bufLocal[4096];
+ unsigned char *bufBitmap = bufLocal;
+ int bufSize = sizeof (bufLocal);
+ int size, pitch;
+ unsigned char bufLocalRgba[4096];
+ unsigned char *bufBitmapRgba = bufLocalRgba;
+ int bufSizeRgba = sizeof (bufLocalRgba);
+ int sizergba, pitchrgba, widthrgba;
+ int width;
+ int height;
+ int left, right, top, bottom;
+ int hmul = 1;
+ int vmul = 1;
+ FT_Bitmap ftbit;
+ FT_Matrix matrix;
+ FT_Vector vector;
+ Bool subpixel = False;
+ FT_Face face;
+
+ if (!info)
+ return;
+
+ face = XftLockFace (&font->public);
+
+ if (!face)
+ return;
+
+ matrix.xx = matrix.yy = 0x10000L;
+ matrix.xy = matrix.yx = 0;
+
+ if (font->info.antialias)
+ {
+ switch (font->info.rgba) {
+ case FC_RGBA_RGB:
+ case FC_RGBA_BGR:
+ matrix.xx *= 3;
+ subpixel = True;
+ hmul = 3;
+ break;
+ case FC_RGBA_VRGB:
+ case FC_RGBA_VBGR:
+ matrix.yy *= 3;
+ vmul = 3;
+ subpixel = True;
+ break;
+ }
+ }
+
+ while (nglyph--)
+ {
+ glyphindex = *glyphs++;
+ xftg = font->glyphs[glyphindex];
+ if (!xftg)
+ continue;
+
+ if (XftDebug() & XFT_DBG_CACHE)
+ _XftFontValidateMemory (dpy, pub);
+ /*
+ * Check to see if this glyph has just been loaded,
+ * this happens when drawing the same glyph twice
+ * in a single string
+ */
+ if (xftg->glyph_memory)
+ continue;
+
+ error = FT_Load_Glyph (face, glyphindex, font->info.load_flags);
+ if (error)
+ {
+ /*
+ * If anti-aliasing or transforming glyphs and
+ * no outline version exists, fallback to the
+ * bitmap and let things look bad instead of
+ * missing the glyph
+ */
+ if (font->info.load_flags & FT_LOAD_NO_BITMAP)
+ error = FT_Load_Glyph (face, glyphindex,
+ font->info.load_flags & ~FT_LOAD_NO_BITMAP);
+ if (error)
+ continue;
+ }
+
+#define FLOOR(x) ((x) & -64)
+#define CEIL(x) (((x)+63) & -64)
+#define TRUNC(x) ((x) >> 6)
+#define ROUND(x) (((x)+32) & -64)
+
+ glyphslot = face->glyph;
+
+#if HAVE_FT_GLYPHSLOT_EMBOLDEN
+ /*
+ * Embolden if required
+ */
+ if (font->info.embolden) FT_GlyphSlot_Embolden(glyphslot);
+#endif
+
+ /*
+ * Compute glyph metrics from FreeType information
+ */
+ if(font->info.transform && glyphslot->format != ft_glyph_format_bitmap)
+ {
+ /*
+ * calculate the true width by transforming all four corners.
+ */
+ int xc, yc;
+ left = right = top = bottom = 0;
+ for(xc = 0; xc <= 1; xc ++) {
+ for(yc = 0; yc <= 1; yc++) {
+ vector.x = glyphslot->metrics.horiBearingX + xc * glyphslot->metrics.width;
+ vector.y = glyphslot->metrics.horiBearingY - yc * glyphslot->metrics.height;
+ FT_Vector_Transform(&vector, &font->info.matrix);
+ if (XftDebug() & XFT_DBG_GLYPH)
+ printf("Trans %d %d: %d %d\n", (int) xc, (int) yc,
+ (int) vector.x, (int) vector.y);
+ if(xc == 0 && yc == 0) {
+ left = right = vector.x;
+ top = bottom = vector.y;
+ } else {
+ if(left > vector.x) left = vector.x;
+ if(right < vector.x) right = vector.x;
+ if(bottom > vector.y) bottom = vector.y;
+ if(top < vector.y) top = vector.y;
+ }
+
+ }
+ }
+ left = FLOOR(left);
+ right = CEIL(right);
+ bottom = FLOOR(bottom);
+ top = CEIL(top);
+
+ } else {
+ left = FLOOR( glyphslot->metrics.horiBearingX );
+ right = CEIL( glyphslot->metrics.horiBearingX + glyphslot->metrics.width );
+
+ top = CEIL( glyphslot->metrics.horiBearingY );
+ bottom = FLOOR( glyphslot->metrics.horiBearingY - glyphslot->metrics.height );
+ }
+
+ width = TRUNC(right - left);
+ height = TRUNC( top - bottom );
+
+ /*
+ * Clip charcell glyphs to the bounding box
+ * XXX transformed?
+ */
+ if (font->info.spacing >= FC_CHARCELL && !font->info.transform)
+ {
+ if (font->info.load_flags & FT_LOAD_VERTICAL_LAYOUT)
+ {
+ if (TRUNC(bottom) > font->public.max_advance_width)
+ {
+ int adjust;
+
+ adjust = bottom - (font->public.max_advance_width << 6);
+ if (adjust > top)
+ adjust = top;
+ top -= adjust;
+ bottom -= adjust;
+ height = font->public.max_advance_width;
+ }
+ }
+ else
+ {
+ if (TRUNC(right) > font->public.max_advance_width)
+ {
+ int adjust;
+
+ adjust = right - (font->public.max_advance_width << 6);
+ if (adjust > left)
+ adjust = left;
+ left -= adjust;
+ right -= adjust;
+ width = font->public.max_advance_width;
+ }
+ }
+ }
+
+ if (font->info.antialias)
+ pitch = (width * hmul + 3) & ~3;
+ else
+ pitch = ((width + 31) & ~31) >> 3;
+
+ size = pitch * height * vmul;
+
+ xftg->metrics.width = width;
+ xftg->metrics.height = height;
+ xftg->metrics.x = -TRUNC(left);
+ xftg->metrics.y = TRUNC(top);
+
+ if (font->info.spacing >= FC_MONO)
+ {
+ if (font->info.transform)
+ {
+ if (font->info.load_flags & FT_LOAD_VERTICAL_LAYOUT)
+ {
+ vector.x = 0;
+ vector.y = -face->size->metrics.max_advance;
+ }
+ else
+ {
+ vector.x = face->size->metrics.max_advance;
+ vector.y = 0;
+ }
+ FT_Vector_Transform (&vector, &font->info.matrix);
+ xftg->metrics.xOff = vector.x >> 6;
+ xftg->metrics.yOff = -(vector.y >> 6);
+ }
+ else
+ {
+ if (font->info.load_flags & FT_LOAD_VERTICAL_LAYOUT)
+ {
+ xftg->metrics.xOff = 0;
+ xftg->metrics.yOff = -font->public.max_advance_width;
+ }
+ else
+ {
+ xftg->metrics.xOff = font->public.max_advance_width;
+ xftg->metrics.yOff = 0;
+ }
+ }
+ }
+ else
+ {
+ xftg->metrics.xOff = TRUNC(ROUND(glyphslot->advance.x));
+ xftg->metrics.yOff = -TRUNC(ROUND(glyphslot->advance.y));
+ }
+
+ /*
+ * If the glyph is relatively large (> 1% of server memory),
+ * don't send it until necessary
+ */
+ if (!need_bitmaps && size > info->max_glyph_memory / 100)
+ continue;
+
+ /*
+ * Make sure there's enough buffer space for the glyph
+ */
+ if (size > bufSize)
+ {
+ if (bufBitmap != bufLocal)
+ free (bufBitmap);
+ bufBitmap = (unsigned char *) malloc (size);
+ if (!bufBitmap)
+ continue;
+ bufSize = size;
+ }
+ memset (bufBitmap, 0, size);
+
+ /*
+ * Rasterize into the local buffer
+ */
+ switch (glyphslot->format) {
+ case ft_glyph_format_outline:
+ ftbit.width = width * hmul;
+ ftbit.rows = height * vmul;
+ ftbit.pitch = pitch;
+ if (font->info.antialias)
+ ftbit.pixel_mode = ft_pixel_mode_grays;
+ else
+ ftbit.pixel_mode = ft_pixel_mode_mono;
+
+ ftbit.buffer = bufBitmap;
+
+ if (subpixel)
+ FT_Outline_Transform (&glyphslot->outline, &matrix);
+
+ FT_Outline_Translate ( &glyphslot->outline, -left*hmul, -bottom*vmul );
+
+ FT_Outline_Get_Bitmap( _XftFTlibrary, &glyphslot->outline, &ftbit );
+ break;
+ case ft_glyph_format_bitmap:
+ if (font->info.antialias)
+ {
+ unsigned char *srcLine, *dstLine;
+ int height;
+ int x;
+ int h, v;
+
+ srcLine = glyphslot->bitmap.buffer;
+ dstLine = bufBitmap;
+ height = glyphslot->bitmap.rows;
+ while (height--)
+ {
+ for (x = 0; x < glyphslot->bitmap.width; x++)
+ {
+ /* always MSB bitmaps */
+ unsigned char a = ((srcLine[x >> 3] & (0x80 >> (x & 7))) ?
+ 0xff : 0x00);
+ if (subpixel)
+ {
+ for (v = 0; v < vmul; v++)
+ for (h = 0; h < hmul; h++)
+ dstLine[v * pitch + x*hmul + h] = a;
+ }
+ else
+ dstLine[x] = a;
+ }
+ dstLine += pitch * vmul;
+ srcLine += glyphslot->bitmap.pitch;
+ }
+ }
+ else
+ {
+ unsigned char *srcLine, *dstLine;
+ int h, bytes;
+
+ srcLine = glyphslot->bitmap.buffer;
+ dstLine = bufBitmap;
+ h = glyphslot->bitmap.rows;
+ bytes = (glyphslot->bitmap.width + 7) >> 3;
+ while (h--)
+ {
+ memcpy (dstLine, srcLine, bytes);
+ dstLine += pitch;
+ srcLine += glyphslot->bitmap.pitch;
+ }
+ }
+ break;
+ default:
+ if (XftDebug() & XFT_DBG_GLYPH)
+ printf ("glyph %d is not in a usable format\n",
+ (int) glyphindex);
+ continue;
+ }
+
+ if (XftDebug() & XFT_DBG_GLYPH)
+ {
+ printf ("glyph %d:\n", (int) glyphindex);
+ printf (" xywh (%d %d %d %d), trans (%d %d %d %d) wh (%d %d)\n",
+ (int) glyphslot->metrics.horiBearingX,
+ (int) glyphslot->metrics.horiBearingY,
+ (int) glyphslot->metrics.width,
+ (int) glyphslot->metrics.height,
+ left, right, top, bottom,
+ width, height);
+ if (XftDebug() & XFT_DBG_GLYPHV)
+ {
+ int x, y;
+ unsigned char *line;
+
+ line = bufBitmap;
+ for (y = 0; y < height * vmul; y++)
+ {
+ if (font->info.antialias)
+ {
+ static char den[] = { " .:;=+*#" };
+ for (x = 0; x < pitch; x++)
+ printf ("%c", den[line[x] >> 5]);
+ }
+ else
+ {
+ for (x = 0; x < pitch * 8; x++)
+ {
+ printf ("%c", line[x>>3] & (1 << (x & 7)) ? '#' : ' ');
+ }
+ }
+ printf ("|\n");
+ line += pitch;
+ }
+ printf ("\n");
+ }
+ }
+
+ /*
+ * Use the glyph index as the wire encoding; it
+ * might be more efficient for some locales to map
+ * these by first usage to smaller values, but that
+ * would require persistently storing the map when
+ * glyphs were freed.
+ */
+ glyph = (Glyph) glyphindex;
+
+ if (subpixel)
+ {
+ int x, y;
+ unsigned char *in_line, *out_line, *in;
+ unsigned int *out;
+ unsigned int red, green, blue;
+ int rf, gf, bf;
+ int s;
+ int o, os;
+
+ /*
+ * Filter the glyph to soften the color fringes
+ */
+ widthrgba = width;
+ pitchrgba = (widthrgba * 4 + 3) & ~3;
+ sizergba = pitchrgba * height;
+
+ os = 1;
+ switch (font->info.rgba) {
+ case FC_RGBA_VRGB:
+ os = pitch;
+ case FC_RGBA_RGB:
+ default:
+ rf = 0;
+ gf = 1;
+ bf = 2;
+ break;
+ case FC_RGBA_VBGR:
+ os = pitch;
+ case FC_RGBA_BGR:
+ bf = 0;
+ gf = 1;
+ rf = 2;
+ break;
+ }
+ if (sizergba > bufSizeRgba)
+ {
+ if (bufBitmapRgba != bufLocalRgba)
+ free (bufBitmapRgba);
+ bufBitmapRgba = (unsigned char *) malloc (sizergba);
+ if (!bufBitmapRgba)
+ continue;
+ bufSizeRgba = sizergba;
+ }
+ memset (bufBitmapRgba, 0, sizergba);
+ in_line = bufBitmap;
+ out_line = bufBitmapRgba;
+ for (y = 0; y < height; y++)
+ {
+ in = in_line;
+ out = (unsigned int *) out_line;
+ in_line += pitch * vmul;
+ out_line += pitchrgba;
+ for (x = 0; x < width * hmul; x += hmul)
+ {
+ red = green = blue = 0;
+ o = 0;
+ for (s = 0; s < 3; s++)
+ {
+ red += filters[rf][s]*in[x+o];
+ green += filters[gf][s]*in[x+o];
+ blue += filters[bf][s]*in[x+o];
+ o += os;
+ }
+ red = red / 65536;
+ green = green / 65536;
+ blue = blue / 65536;
+ *out++ = (green << 24) | (red << 16) | (green << 8) | blue;
+ }
+ }
+
+ xftg->glyph_memory = sizergba + sizeof (XftGlyph);
+ if (font->format)
+ {
+ if (!font->glyphset)
+ font->glyphset = XRenderCreateGlyphSet (dpy, font->format);
+ if (ImageByteOrder (dpy) != XftNativeByteOrder ())
+ XftSwapCARD32 ((CARD32 *) bufBitmapRgba, sizergba >> 2);
+ XRenderAddGlyphs (dpy, font->glyphset, &glyph,
+ &xftg->metrics, 1,
+ (char *) bufBitmapRgba, sizergba);
+ }
+ else
+ {
+ if (sizergba)
+ {
+ xftg->bitmap = malloc (sizergba);
+ if (xftg->bitmap)
+ memcpy (xftg->bitmap, bufBitmapRgba, sizergba);
+ }
+ else
+ xftg->bitmap = 0;
+ }
+ }
+ else
+ {
+ xftg->glyph_memory = size + sizeof (XftGlyph);
+ if (font->format)
+ {
+ /*
+ * swap bit order around; FreeType is always MSBFirst
+ */
+ if (!font->info.antialias)
+ {
+ if (BitmapBitOrder (dpy) != MSBFirst)
+ {
+ unsigned char *line;
+ unsigned char c;
+ int i;
+
+ line = (unsigned char *) bufBitmap;
+ i = size;
+ while (i--)
+ {
+ c = *line;
+ c = ((c << 1) & 0xaa) | ((c >> 1) & 0x55);
+ c = ((c << 2) & 0xcc) | ((c >> 2) & 0x33);
+ c = ((c << 4) & 0xf0) | ((c >> 4) & 0x0f);
+ *line++ = c;
+ }
+ }
+ }
+ if (!font->glyphset)
+ font->glyphset = XRenderCreateGlyphSet (dpy, font->format);
+ XRenderAddGlyphs (dpy, font->glyphset, &glyph,
+ &xftg->metrics, 1,
+ (char *) bufBitmap, size);
+ }
+ else
+ {
+ if (size)
+ {
+ xftg->bitmap = malloc (size);
+ if (xftg->bitmap)
+ memcpy (xftg->bitmap, bufBitmap, size);
+ }
+ else
+ xftg->bitmap = 0;
+ }
+ }
+ font->glyph_memory += xftg->glyph_memory;
+ info->glyph_memory += xftg->glyph_memory;
+ if (XftDebug() & XFT_DBG_CACHE)
+ _XftFontValidateMemory (dpy, pub);
+ if (XftDebug() & XFT_DBG_CACHEV)
+ printf ("Caching glyph 0x%x size %ld\n", glyphindex,
+ xftg->glyph_memory);
+ }
+ if (bufBitmap != bufLocal)
+ free (bufBitmap);
+ if (bufBitmapRgba != bufLocalRgba)
+ free (bufBitmapRgba);
+ XftUnlockFace (&font->public);
+}
+
+void
+XftFontUnloadGlyphs (Display *dpy,
+ XftFont *pub,
+ _Xconst FT_UInt *glyphs,
+ int nglyph)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy, False);
+ XftFontInt *font = (XftFontInt *) pub;
+ XftGlyph *xftg;
+ FT_UInt glyphindex;
+ Glyph glyphBuf[1024];
+ int nused;
+
+ nused = 0;
+ while (nglyph--)
+ {
+ glyphindex = *glyphs++;
+ xftg = font->glyphs[glyphindex];
+ if (!xftg)
+ continue;
+ if (xftg->glyph_memory)
+ {
+ if (font->format)
+ {
+ if (font->glyphset)
+ {
+ glyphBuf[nused++] = (Glyph) glyphindex;
+ if (nused == sizeof (glyphBuf) / sizeof (glyphBuf[0]))
+ {
+ XRenderFreeGlyphs (dpy, font->glyphset, glyphBuf, nused);
+ nused = 0;
+ }
+ }
+ }
+ else
+ {
+ if (xftg->bitmap)
+ free (xftg->bitmap);
+ }
+ font->glyph_memory -= xftg->glyph_memory;
+ if (info)
+ info->glyph_memory -= xftg->glyph_memory;
+ }
+ free (xftg);
+ XftMemFree (XFT_MEM_GLYPH, sizeof (XftGlyph));
+ font->glyphs[glyphindex] = 0;
+ }
+ if (font->glyphset && nused)
+ XRenderFreeGlyphs (dpy, font->glyphset, glyphBuf, nused);
+}
+
+FcBool
+XftFontCheckGlyph (Display *dpy,
+ XftFont *pub,
+ FcBool need_bitmaps,
+ FT_UInt glyph,
+ FT_UInt *missing,
+ int *nmissing)
+{
+ XftFontInt *font = (XftFontInt *) pub;
+ XftGlyph *xftg;
+ int n;
+
+ if (glyph >= font->num_glyphs)
+ return FcFalse;
+ xftg = font->glyphs[glyph];
+ if (!xftg || (need_bitmaps && !xftg->glyph_memory))
+ {
+ if (!xftg)
+ {
+ xftg = (XftGlyph *) malloc (sizeof (XftGlyph));
+ if (!xftg)
+ return FcFalse;
+ XftMemAlloc (XFT_MEM_GLYPH, sizeof (XftGlyph));
+ xftg->bitmap = 0;
+ xftg->glyph_memory = 0;
+ font->glyphs[glyph] = xftg;
+ }
+ n = *nmissing;
+ missing[n++] = glyph;
+ if (n == XFT_NMISSING)
+ {
+ XftFontLoadGlyphs (dpy, pub, need_bitmaps, missing, n);
+ n = 0;
+ }
+ *nmissing = n;
+ return FcTrue;
+ }
+ else
+ return FcFalse;
+}
+
+FcBool
+XftCharExists (Display *dpy,
+ XftFont *pub,
+ FcChar32 ucs4)
+{
+ if (pub->charset)
+ return FcCharSetHasChar (pub->charset, ucs4);
+ return FcFalse;
+}
+
+#define Missing ((FT_UInt) ~0)
+
+FT_UInt
+XftCharIndex (Display *dpy,
+ XftFont *pub,
+ FcChar32 ucs4)
+{
+ XftFontInt *font = (XftFontInt *) pub;
+ FcChar32 ent, offset;
+ FT_Face face;
+
+ if (!font->hash_value)
+ return 0;
+
+ ent = ucs4 % font->hash_value;
+ offset = 0;
+ while (font->hash_table[ent].ucs4 != ucs4)
+ {
+ if (font->hash_table[ent].ucs4 == (FcChar32) ~0)
+ {
+ if (!XftCharExists (dpy, pub, ucs4))
+ return 0;
+ face = XftLockFace (pub);
+ if (!face)
+ return 0;
+ font->hash_table[ent].ucs4 = ucs4;
+ font->hash_table[ent].glyph = FcFreeTypeCharIndex (face, ucs4);
+ XftUnlockFace (pub);
+ break;
+ }
+ if (!offset)
+ {
+ offset = ucs4 % font->rehash_value;
+ if (!offset)
+ offset = 1;
+ }
+ ent = ent + offset;
+ if (ent >= font->hash_value)
+ ent -= font->hash_value;
+ }
+ return font->hash_table[ent].glyph;
+}
+
+/*
+ * Pick a random glyph from the font and remove it from the cache
+ */
+void
+_XftFontUncacheGlyph (Display *dpy, XftFont *pub)
+{
+ XftFontInt *font = (XftFontInt *) pub;
+ unsigned long glyph_memory;
+ FT_UInt glyphindex;
+ XftGlyph *xftg;
+
+ if (!font->glyph_memory)
+ return;
+ if (font->use_free_glyphs)
+ {
+ glyph_memory = rand() % font->glyph_memory;
+ }
+ else
+ {
+ if (font->glyphset)
+ {
+ XRenderFreeGlyphSet (dpy, font->glyphset);
+ font->glyphset = 0;
+ }
+ glyph_memory = 0;
+ }
+
+ if (XftDebug() & XFT_DBG_CACHE)
+ _XftFontValidateMemory (dpy, pub);
+ for (glyphindex = 0; glyphindex < font->num_glyphs; glyphindex++)
+ {
+ xftg = font->glyphs[glyphindex];
+ if (xftg)
+ {
+ if (xftg->glyph_memory > glyph_memory)
+ {
+ if (XftDebug() & XFT_DBG_CACHEV)
+ printf ("Uncaching glyph 0x%x size %ld\n",
+ glyphindex, xftg->glyph_memory);
+ XftFontUnloadGlyphs (dpy, pub, &glyphindex, 1);
+ if (!font->use_free_glyphs)
+ continue;
+ break;
+ }
+ glyph_memory -= xftg->glyph_memory;
+ }
+ }
+ if (XftDebug() & XFT_DBG_CACHE)
+ _XftFontValidateMemory (dpy, pub);
+}
+
+void
+_XftFontManageMemory (Display *dpy, XftFont *pub)
+{
+ XftFontInt *font = (XftFontInt *) pub;
+
+ if (font->max_glyph_memory)
+ {
+ if (XftDebug() & XFT_DBG_CACHE)
+ {
+ if (font->glyph_memory > font->max_glyph_memory)
+ printf ("Reduce memory for font 0x%lx from %ld to %ld\n",
+ font->glyphset ? font->glyphset : (unsigned long) font,
+ font->glyph_memory, font->max_glyph_memory);
+ }
+ while (font->glyph_memory > font->max_glyph_memory)
+ _XftFontUncacheGlyph (dpy, pub);
+ }
+ _XftDisplayManageMemory (dpy);
+}
diff --git a/nx-X11/lib/Xft/xftinit.c b/nx-X11/lib/Xft/xftinit.c
new file mode 100644
index 000000000..83724ce5a
--- /dev/null
+++ b/nx-X11/lib/Xft/xftinit.c
@@ -0,0 +1,115 @@
+/*
+ * $Id: xftinit.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+Bool _XftConfigInitialized;
+
+Bool
+XftInit (_Xconst char *config)
+{
+ if (_XftConfigInitialized)
+ return True;
+ _XftConfigInitialized = True;
+ if (!FcInit ())
+ return False;
+ _XftNameInit ();
+ return True;
+}
+
+int
+XftGetVersion (void)
+{
+ return XftVersion;
+}
+
+static struct {
+ char *name;
+ int alloc_count;
+ int alloc_mem;
+ int free_count;
+ int free_mem;
+} XftInUse[XFT_MEM_NUM] = {
+ { "XftDraw", 0, 0 },
+ { "XftFont", 0 ,0 },
+ { "XftFtFile", 0, 0 },
+ { "XftGlyph", 0, 0 },
+};
+
+static int XftAllocCount, XftAllocMem;
+static int XftFreeCount, XftFreeMem;
+
+static int XftMemNotice = 1*1024*1024;
+
+static int XftAllocNotify, XftFreeNotify;
+
+void
+XftMemReport (void)
+{
+ int i;
+ printf ("Xft Memory Usage:\n");
+ printf ("\t Which Alloc Free\n");
+ printf ("\t count bytes count bytes\n");
+ for (i = 0; i < XFT_MEM_NUM; i++)
+ printf ("\t%8.8s%8d%8d%8d%8d\n",
+ XftInUse[i].name,
+ XftInUse[i].alloc_count, XftInUse[i].alloc_mem,
+ XftInUse[i].free_count, XftInUse[i].free_mem);
+ printf ("\t%8.8s%8d%8d%8d%8d\n",
+ "Total",
+ XftAllocCount, XftAllocMem,
+ XftFreeCount, XftFreeMem);
+ XftAllocNotify = 0;
+ XftFreeNotify = 0;
+}
+
+void
+XftMemAlloc (int kind, int size)
+{
+ if (XftDebug() & XFT_DBG_MEMORY)
+ {
+ XftInUse[kind].alloc_count++;
+ XftInUse[kind].alloc_mem += size;
+ XftAllocCount++;
+ XftAllocMem += size;
+ XftAllocNotify += size;
+ if (XftAllocNotify > XftMemNotice)
+ XftMemReport ();
+ }
+}
+
+void
+XftMemFree (int kind, int size)
+{
+ if (XftDebug() & XFT_DBG_MEMORY)
+ {
+ XftInUse[kind].free_count++;
+ XftInUse[kind].free_mem += size;
+ XftFreeCount++;
+ XftFreeMem += size;
+ XftFreeNotify += size;
+ if (XftFreeNotify > XftMemNotice)
+ XftMemReport ();
+ }
+}
diff --git a/nx-X11/lib/Xft/xftint.h b/nx-X11/lib/Xft/xftint.h
new file mode 100644
index 000000000..824313ec5
--- /dev/null
+++ b/nx-X11/lib/Xft/xftint.h
@@ -0,0 +1,459 @@
+/*
+ * $Id: xftint.h,v 1.6 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+/*
+ * These definitions are solely for use by the implementation of Xft
+ * and constitute no kind of standard. If you need any of these functions,
+ * please drop me a note. Either the library needs new functionality,
+ * or there's a way to do what you need using the existing published
+ * interfaces. keithp@freedesktop.org
+ */
+
+#ifndef _XFTINT_H_
+#define _XFTINT_H_
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else /* X monolithic tree */
+#define HAVE_STDLIB_H 1 /* assumed since all ANSI C platforms require it */
+#include <X11/Xosdefs.h> /* get string.h or strings.h as appropriate */
+#endif
+
+#include <stdio.h>
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#if HAVE_STRING_H
+#include <string.h>
+#else
+#if HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+#include <ctype.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xmd.h>
+#include <X11/Xlibint.h>
+#define _XFT_NO_COMPAT_
+#include "Xft.h"
+#include <fontconfig/fcprivate.h>
+#include <fontconfig/fcfreetype.h>
+
+#ifndef HAVE_CONFIG_H
+# if (FREETYPE_MAJOR > 2 || \
+ (FREETYPE_MAJOR == 2 && (FREETYPE_MINOR > 1 || \
+ (FREETYPE_MINOR == 1 && FREETYPE_PATCH >= 5))))
+# define HAVE_FT_BITMAP_SIZE_Y_PPEM 1
+# else
+# define HAVE_FT_BITMAP_SIZE_Y_PPEM 0
+# endif
+#endif
+
+typedef struct _XftMatcher {
+ char *object;
+ double (*compare) (char *object, FcValue value1, FcValue value2);
+} XftMatcher;
+
+typedef struct _XftSymbolic {
+ const char *name;
+ int value;
+} XftSymbolic;
+
+/*
+ * Glyphs are stored in this structure
+ */
+typedef struct _XftGlyph {
+ XGlyphInfo metrics;
+ void *bitmap;
+ unsigned long glyph_memory;
+} XftGlyph;
+
+/*
+ * A hash table translates Unicode values into glyph indicies
+ */
+typedef struct _XftUcsHash {
+ FcChar32 ucs4;
+ FT_UInt glyph;
+} XftUcsHash;
+
+/*
+ * Many fonts can share the same underlying face data; this
+ * structure references that. Note that many faces may in fact
+ * live in the same font file; that is irrelevant to this structure
+ * which is concerned only with the individual faces themselves
+ */
+
+typedef struct _XftFtFile {
+ struct _XftFtFile *next;
+ int ref; /* number of font infos using this file */
+
+ char *file; /* file name */
+ int id; /* font index within that file */
+
+ FT_F26Dot6 xsize; /* current xsize setting */
+ FT_F26Dot6 ysize; /* current ysize setting */
+ FT_Matrix matrix; /* current matrix setting */
+
+ int lock; /* lock count; can't unload unless 0 */
+ FT_Face face; /* pointer to face; only valid when lock */
+} XftFtFile;
+
+/*
+ * This structure holds the data extracted from a pattern
+ * needed to create a unique font object.
+ */
+
+struct _XftFontInfo {
+ /*
+ * Hash value (not include in hash value computation)
+ */
+ FcChar32 hash;
+ XftFtFile *file; /* face source */
+ /*
+ * Rendering options
+ */
+ FT_F26Dot6 xsize, ysize; /* pixel size */
+ FcBool antialias; /* doing antialiasing */
+ FcBool embolden; /* force emboldening */
+ int rgba; /* subpixel order */
+ FT_Matrix matrix; /* glyph transformation matrix */
+ FcBool transform; /* non-identify matrix? */
+ FT_Int load_flags; /* glyph load flags */
+ FcBool render; /* whether to use the Render extension */
+ /*
+ * Internal fields
+ */
+ int spacing;
+ FcBool minspace;
+ int char_width;
+};
+
+/*
+ * Internal version of the font with private data
+ */
+
+typedef struct _XftFontInt {
+ XftFont public; /* public fields */
+ XftFont *next; /* all fonts on display */
+ XftFont *hash_next; /* fonts in this hash chain */
+ XftFontInfo info; /* Data from pattern */
+ int ref; /* reference count */
+ /*
+ * Per-glyph information, indexed by glyph ID
+ * This array follows the font in memory
+ */
+ XftGlyph **glyphs;
+ int num_glyphs; /* size of glyphs/bitmaps arrays */
+ /*
+ * Hash table to get from Unicode value to glyph ID
+ * This array follows the glyphs in memory
+ */
+ XftUcsHash *hash_table;
+ int hash_value;
+ int rehash_value;
+ /*
+ * X specific fields
+ */
+ GlyphSet glyphset; /* Render glyphset */
+ XRenderPictFormat *format; /* Render format for glyphs */
+ /*
+ * Glyph memory management fields
+ */
+ unsigned long glyph_memory;
+ unsigned long max_glyph_memory;
+ FcBool use_free_glyphs; /* Use XRenderFreeGlyphs */
+} XftFontInt;
+
+typedef enum _XftClipType {
+ XftClipTypeNone, XftClipTypeRegion, XftClipTypeRectangles
+} XftClipType;
+
+typedef struct _XftClipRect {
+ int xOrigin;
+ int yOrigin;
+ int n;
+} XftClipRect;
+
+#define XftClipRects(cr) ((XRectangle *) ((cr) + 1))
+
+typedef union _XftClip {
+ XftClipRect *rect;
+ Region region;
+} XftClip;
+
+struct _XftDraw {
+ Display *dpy;
+ int screen;
+ unsigned int bits_per_pixel;
+ unsigned int depth;
+ Drawable drawable;
+ Visual *visual; /* NULL for bitmaps */
+ Colormap colormap;
+ XftClipType clip_type;
+ XftClip clip;
+ int subwindow_mode;
+ struct {
+ Picture pict;
+ } render;
+ struct {
+ GC gc;
+ int use_pixmap;
+ } core;
+};
+
+/*
+ * Instead of taking two round trips for each blending request,
+ * assume that if a particular drawable fails GetImage that it will
+ * fail for a "while"; use temporary pixmaps to avoid the errors
+ */
+
+#define XFT_ASSUME_PIXMAP 20
+
+typedef struct _XftSolidColor {
+ XRenderColor color;
+ int screen;
+ Picture pict;
+} XftSolidColor;
+
+#define XFT_NUM_SOLID_COLOR 16
+
+#define XFT_NUM_FONT_HASH 127
+
+typedef struct _XftDisplayInfo {
+ struct _XftDisplayInfo *next;
+ Display *display;
+ XExtCodes *codes;
+ FcPattern *defaults;
+ FcBool hasRender;
+ XftFont *fonts;
+ XRenderPictFormat *solidFormat;
+ unsigned long glyph_memory;
+ unsigned long max_glyph_memory;
+ FcBool use_free_glyphs;
+ int num_unref_fonts;
+ int max_unref_fonts;
+ XftSolidColor colors[XFT_NUM_SOLID_COLOR];
+ XftFont *fontHash[XFT_NUM_FONT_HASH];
+} XftDisplayInfo;
+
+/*
+ * By default, use no more than 4 meg of server memory total, and no
+ * more than 1 meg for any one font
+ */
+#define XFT_DPY_MAX_GLYPH_MEMORY (4 * 1024 * 1024)
+#define XFT_FONT_MAX_GLYPH_MEMORY (1024 * 1024)
+
+/*
+ * By default, keep the last 16 unreferenced fonts around to
+ * speed reopening them. Note that the glyph caching code
+ * will keep the global memory usage reasonably limited
+ */
+#define XFT_DPY_MAX_UNREF_FONTS 16
+
+extern XftDisplayInfo *_XftDisplayInfo;
+
+#define XFT_DBG_OPEN 1
+#define XFT_DBG_OPENV 2
+#define XFT_DBG_RENDER 4
+#define XFT_DBG_DRAW 8
+#define XFT_DBG_REF 16
+#define XFT_DBG_GLYPH 32
+#define XFT_DBG_GLYPHV 64
+#define XFT_DBG_CACHE 128
+#define XFT_DBG_CACHEV 256
+#define XFT_DBG_MEMORY 512
+
+#define XFT_MEM_DRAW 0
+#define XFT_MEM_FONT 1
+#define XFT_MEM_FILE 2
+#define XFT_MEM_GLYPH 3
+#define XFT_MEM_NUM 4
+
+/* xftcompat.c */
+void XftFontSetDestroy (FcFontSet *s);
+FcBool XftMatrixEqual (_Xconst FcMatrix *mat1, _Xconst FcMatrix *mat2);
+void XftMatrixMultiply (FcMatrix *result, FcMatrix *a, FcMatrix *b);
+void XftMatrixRotate (FcMatrix *m, double c, double s);
+void XftMatrixScale (FcMatrix *m, double sx, double sy);
+void XftMatrixShear (FcMatrix *m, double sh, double sv);
+FcPattern *XftPatternCreate (void);
+void XftValueDestroy (FcValue v);
+void XftPatternDestroy (FcPattern *p);
+FcBool XftPatternAdd (FcPattern *p, _Xconst char *object, FcValue value, FcBool append);
+FcBool XftPatternDel (FcPattern *p, _Xconst char *object);
+FcBool XftPatternAddInteger (FcPattern *p, _Xconst char *object, int i);
+FcBool XftPatternAddDouble (FcPattern *p, _Xconst char *object, double i);
+FcBool XftPatternAddMatrix (FcPattern *p, _Xconst char *object, FcMatrix *i);
+FcBool XftPatternAddString (FcPattern *p, _Xconst char *object, char *i);
+FcBool XftPatternAddBool (FcPattern *p, _Xconst char *object, FcBool i);
+FcResult XftPatternGet (FcPattern *p, _Xconst char *object, int id, FcValue *v);
+FcResult XftPatternGetInteger (FcPattern *p, _Xconst char *object, int id, int *i);
+FcResult XftPatternGetDouble (FcPattern *p, _Xconst char *object, int id, double *i);
+FcResult XftPatternGetString (FcPattern *p, _Xconst char *object, int id, char **i);
+FcResult XftPatternGetMatrix (FcPattern *p, _Xconst char *object, int id, FcMatrix **i);
+FcResult XftPatternGetBool (FcPattern *p, _Xconst char *object, int id, FcBool *i);
+FcPattern *XftPatternDuplicate (FcPattern *orig);
+FcPattern *XftPatternVaBuild (FcPattern *orig, va_list va);
+FcPattern *XftPatternBuild (FcPattern *orig, ...);
+FcBool XftNameUnparse (FcPattern *pat, char *dest, int len);
+FcBool XftGlyphExists (Display *dpy, XftFont *font, FcChar32 ucs4);
+FcObjectSet *XftObjectSetCreate (void);
+Bool XftObjectSetAdd (FcObjectSet *os, _Xconst char *object);
+void XftObjectSetDestroy (FcObjectSet *os);
+FcObjectSet *XftObjectSetVaBuild (_Xconst char *first, va_list va);
+FcObjectSet *XftObjectSetBuild (_Xconst char *first, ...);
+FcFontSet *XftListFontSets (FcFontSet **sets, int nsets, FcPattern *p, FcObjectSet *os);
+
+/* xftcore.c */
+void
+XftRectCore (XftDraw *draw,
+ _Xconst XftColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height);
+
+void
+XftGlyphCore (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *public,
+ int x,
+ int y,
+ _Xconst FT_UInt *glyphs,
+ int nglyphs);
+
+void
+XftGlyphSpecCore (XftDraw *draw,
+ _Xconst XftColor *color,
+ XftFont *public,
+ _Xconst XftGlyphSpec *glyphs,
+ int nglyphs);
+
+void
+XftGlyphFontSpecCore (XftDraw *draw,
+ _Xconst XftColor *color,
+ _Xconst XftGlyphFontSpec *glyphs,
+ int nglyphs);
+
+/* xftdbg.c */
+int
+XftDebug (void);
+
+/* xftdpy.c */
+XftDisplayInfo *
+_XftDisplayInfoGet (Display *dpy, FcBool createIfNecessary);
+
+void
+_XftDisplayManageMemory (Display *dpy);
+
+int
+XftDefaultParseBool (char *v);
+
+FcBool
+XftDefaultGetBool (Display *dpy, const char *object, int screen, FcBool def);
+
+int
+XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def);
+
+double
+XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def);
+
+FcFontSet *
+XftDisplayGetFontSet (Display *dpy);
+
+/* xftdraw.c */
+unsigned int
+XftDrawDepth (XftDraw *draw);
+
+unsigned int
+XftDrawBitsPerPixel (XftDraw *draw);
+
+FcBool
+XftDrawRenderPrepare (XftDraw *draw);
+
+/* xftextent.c */
+
+/* xftfont.c */
+
+/* xftfreetype.c */
+FcBool
+_XftSetFace (XftFtFile *f, FT_F26Dot6 xsize, FT_F26Dot6 ysize, FT_Matrix *matrix);
+
+void
+XftFontManageMemory (Display *dpy);
+
+/* xftglyph.c */
+void
+_XftFontUncacheGlyph (Display *dpy, XftFont *public);
+
+void
+_XftFontManageMemory (Display *dpy, XftFont *public);
+
+/* xftinit.c */
+void
+XftMemReport (void);
+
+void
+XftMemAlloc (int kind, int size);
+
+void
+XftMemFree (int kind, int size);
+
+/* xftlist.c */
+FcFontSet *
+XftListFontsPatternObjects (Display *dpy,
+ int screen,
+ FcPattern *pattern,
+ FcObjectSet *os);
+
+/* xftname.c */
+void
+_XftNameInit (void);
+
+/* xftrender.c */
+
+/* xftstr.c */
+int
+_XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def);
+
+/* xftswap.c */
+int
+XftNativeByteOrder (void);
+
+void
+XftSwapCARD32 (CARD32 *data, int n);
+
+void
+XftSwapCARD24 (CARD8 *data, int width, int height);
+
+void
+XftSwapCARD16 (CARD16 *data, int n);
+
+void
+XftSwapImage (XImage *image);
+
+/* xftxlfd.c */
+#endif /* _XFT_INT_H_ */
diff --git a/nx-X11/lib/Xft/xftlist.c b/nx-X11/lib/Xft/xftlist.c
new file mode 100644
index 000000000..e2102b438
--- /dev/null
+++ b/nx-X11/lib/Xft/xftlist.c
@@ -0,0 +1,60 @@
+/*
+ * $Id: xftlist.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+FcFontSet *
+XftListFontsPatternObjects (Display *dpy,
+ int screen,
+ FcPattern *pattern,
+ FcObjectSet *os)
+{
+ return FcFontList (0, pattern, os);
+}
+
+FcFontSet *
+XftListFonts (Display *dpy,
+ int screen,
+ ...)
+{
+ va_list va;
+ FcFontSet *fs;
+ FcObjectSet *os;
+ FcPattern *pattern;
+ const char *first;
+
+ va_start (va, screen);
+
+ FcPatternVapBuild (pattern, 0, va);
+
+ first = va_arg (va, const char *);
+ FcObjectSetVapBuild (os, first, va);
+
+ va_end (va);
+
+ fs = XftListFontsPatternObjects (dpy, screen, pattern, os);
+ FcPatternDestroy (pattern);
+ FcObjectSetDestroy (os);
+ return fs;
+}
diff --git a/nx-X11/lib/Xft/xftname.c b/nx-X11/lib/Xft/xftname.c
new file mode 100644
index 000000000..16b7fc678
--- /dev/null
+++ b/nx-X11/lib/Xft/xftname.c
@@ -0,0 +1,83 @@
+/*
+ * $Id: xftname.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+static const FcObjectType _XftObjectTypes[] = {
+ { XFT_CORE, FcTypeBool, },
+ { XFT_XLFD, FcTypeString, },
+ { XFT_RENDER, FcTypeBool, },
+};
+
+#define NUM_OBJECT_TYPES (sizeof _XftObjectTypes / sizeof _XftObjectTypes[0])
+
+FcBool _XftNameInitialized;
+
+void
+_XftNameInit (void)
+{
+ if (_XftNameInitialized)
+ return;
+ _XftNameInitialized = FcTrue;
+ FcNameRegisterObjectTypes (_XftObjectTypes, NUM_OBJECT_TYPES);
+}
+
+FcPattern
+*XftNameParse (const char *name)
+{
+ _XftNameInit ();
+ return FcNameParse ((FcChar8 *) name);
+}
+
+FcBool
+XftNameUnparse (FcPattern *pat, char *dest, int len)
+{
+ FcChar8 *name;
+
+ _XftNameInit ();
+ name = FcNameUnparse (pat);
+ if (!name)
+ return FcFalse;
+ if (strlen ((char *) name) + 1 > len)
+ {
+ FcPattern *new = FcPatternDuplicate (pat);
+ free (name);
+ FcPatternDel (new, FC_LANG);
+ FcPatternDel (new, FC_CHARSET);
+ name = FcNameUnparse (new);
+ FcPatternDestroy (new);
+ if (!name)
+ return FcFalse;
+ if (strlen ((char *) name) + 1 > len)
+ {
+ strncpy (dest, ((char *) name), (size_t) len - 1);
+ dest[len - 1] = '\0';
+ free (name);
+ return FcFalse;
+ }
+ }
+ strcpy (dest, ((char *) name));
+ free (name);
+ return FcTrue;
+}
diff --git a/nx-X11/lib/Xft/xftrender.c b/nx-X11/lib/Xft/xftrender.c
new file mode 100644
index 000000000..5569bc70a
--- /dev/null
+++ b/nx-X11/lib/Xft/xftrender.c
@@ -0,0 +1,1009 @@
+/*
+ * $Id: xftrender.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+#define NUM_LOCAL 1024
+#define NUM_ELT_LOCAL 128
+
+/*
+ * Use the Render extension to draw the glyphs
+ */
+
+void
+XftGlyphRender (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FT_UInt *glyphs,
+ int nglyphs)
+{
+ XftFontInt *font = (XftFontInt *) pub;
+ int i;
+ FT_UInt missing[XFT_NMISSING];
+ int nmissing;
+ FT_UInt g, max;
+ int size, width;
+ Glyph wire;
+ char *char8;
+ unsigned short *char16;
+ unsigned int *char32;
+ unsigned int char_local[NUM_LOCAL];
+ unsigned int *chars;
+ FcBool glyphs_loaded;
+
+ if (!font->format)
+ return;
+
+ /*
+ * Load missing glyphs
+ */
+ nmissing = 0;
+ max = 0;
+ glyphs_loaded = FcFalse;
+ for (i = 0; i < nglyphs; i++)
+ {
+ g = glyphs[i];
+ if (g > max)
+ max = g;
+ if (XftFontCheckGlyph (dpy, pub, FcTrue, g, missing, &nmissing))
+ glyphs_loaded = FcTrue;
+ }
+ if (nmissing)
+ XftFontLoadGlyphs (dpy, pub, FcTrue, missing, nmissing);
+
+ if (!font->glyphset)
+ goto bail1;
+ if (max < 0x100)
+ {
+ width = 1;
+ size = sizeof (char);
+ }
+ else if (max < 0x10000)
+ {
+ width = 2;
+ size = sizeof (unsigned short);
+ }
+ else
+ {
+ width = 4;
+ size = sizeof (unsigned int);
+ }
+ chars = char_local;
+ if (nglyphs * size > sizeof (char_local))
+ {
+ chars = malloc (nglyphs * size);
+ if (!chars)
+ goto bail1;
+ }
+ char8 = (char *) chars;
+ char16 = (unsigned short *) chars;
+ char32 = (unsigned int *) chars;
+ for (i = 0; i < nglyphs; i++)
+ {
+ wire = (Glyph) glyphs[i];
+ if (wire >= font->num_glyphs || !font->glyphs[wire])
+ wire = 0;
+ switch (width) {
+ case 1: char8[i] = (char) wire; break;
+ case 2: char16[i] = (unsigned short) wire; break;
+ case 4: char32[i] = (unsigned long) wire; break;
+ }
+ }
+ switch (width) {
+ case 1:
+ default:
+ XRenderCompositeString8 (dpy, op,
+ src, dst, font->format, font->glyphset,
+ srcx, srcy, x, y, char8, nglyphs);
+ break;
+ case 2:
+ XRenderCompositeString16(dpy, op,
+ src, dst, font->format, font->glyphset,
+ srcx, srcy, x, y, char16, nglyphs);
+ break;
+ case 4:
+ XRenderCompositeString32(dpy, op,
+ src, dst, font->format, font->glyphset,
+ srcx, srcy, x, y, char32, nglyphs);
+ break;
+ }
+ if (chars != char_local)
+ free (chars);
+bail1:
+ if (glyphs_loaded)
+ _XftFontManageMemory (dpy, pub);
+}
+
+void
+XftGlyphSpecRender (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ _Xconst XftGlyphSpec *glyphs,
+ int nglyphs)
+{
+ XftFontInt *font = (XftFontInt *) pub;
+ int i, j;
+ FT_UInt missing[XFT_NMISSING];
+ int nmissing;
+ int n;
+ FT_UInt g;
+ XftGlyph *glyph;
+ FT_UInt max;
+ int size, width;
+ char *char8;
+ unsigned short *char16;
+ unsigned int *char32;
+ unsigned int char_local[NUM_LOCAL];
+ unsigned int *chars;
+ XGlyphElt8 *elts;
+ XGlyphElt8 elts_local[NUM_ELT_LOCAL];
+ FcBool glyphs_loaded;
+ int nelt;
+ int x, y;
+
+ if (!font->format)
+ return;
+ if (!nglyphs)
+ return;
+
+ /*
+ * Load missing glyphs
+ */
+ max = 0;
+ nmissing = 0;
+ glyphs_loaded = FcFalse;
+ g = glyphs[0].glyph;
+ for (i = 0; i < nglyphs; i++)
+ {
+ g = glyphs[i].glyph;
+ if (g > max)
+ max = g;
+ if (XftFontCheckGlyph (dpy, pub, FcTrue, g, missing, &nmissing))
+ glyphs_loaded = FcTrue;
+ }
+ if (nmissing)
+ XftFontLoadGlyphs (dpy, pub, FcTrue, missing, nmissing);
+
+ if (!font->glyphset)
+ goto bail1;
+
+ /*
+ * See what encoding size is needed
+ */
+ if (max < 0x100)
+ {
+ size = sizeof (char);
+ width = 1;
+ }
+ else if (max < 0x10000)
+ {
+ size = sizeof (unsigned short);
+ width = 2;
+ }
+ else
+ {
+ size = sizeof (unsigned int);
+ width = 4;
+ }
+ chars = char_local;
+ if (nglyphs * size > NUM_LOCAL)
+ {
+ chars = malloc (nglyphs * size);
+ if (!chars)
+ goto bail1;
+ }
+ char8 = (char *) chars;
+ char16 = (unsigned short *) chars;
+ char32 = (unsigned int *) chars;
+
+ /*
+ * Compute the number of glyph elts needed
+ */
+ nelt = 1;
+ for (i = 0; i < nglyphs; i++)
+ {
+ g = glyphs[i].glyph;
+ /* Substitute default for non-existant glyphs */
+ if (g >= font->num_glyphs || !font->glyphs[g])
+ g = 0;
+ if (font->glyphs[g])
+ break;
+ }
+ if (i == nglyphs)
+ goto bail2;
+ glyph = font->glyphs[g];
+ x = glyphs[i].x + glyph->metrics.xOff;
+ y = glyphs[i].y + glyph->metrics.yOff;
+ while (++i < nglyphs)
+ {
+ g = glyphs[i].glyph;
+ /* Substitute default for non-existant glyphs */
+ if (g >= font->num_glyphs || !font->glyphs[g])
+ g = 0;
+ /*
+ * check to see if the glyph is placed where it would
+ * fall using the normal spacing
+ */
+ if ((glyph = font->glyphs[g]))
+ {
+ if (x != glyphs[i].x || y != glyphs[i].y)
+ {
+ x = glyphs[i].x;
+ y = glyphs[i].y;
+ ++nelt;
+ }
+ x += glyph->metrics.xOff;
+ y += glyph->metrics.yOff;
+ }
+ }
+
+ elts = elts_local;
+ if (nelt > NUM_ELT_LOCAL)
+ {
+ elts = malloc (nelt * sizeof (XGlyphElt8));
+ if (!elts)
+ goto bail2;
+ }
+
+ /*
+ * Generate the list of glyph elts
+ */
+ nelt = 0;
+ x = y = 0;
+ n = 0;
+ j = 0;
+ for (i = 0; i < nglyphs; i++)
+ {
+ g = glyphs[i].glyph;
+ /* Substitute default for non-existant glyphs */
+ if (g >= font->num_glyphs || !font->glyphs[g])
+ g = 0;
+ if ((glyph = font->glyphs[g]))
+ {
+ if (!i || x != glyphs[i].x || y != glyphs[i].y)
+ {
+ if (n)
+ {
+ elts[nelt].nchars = n;
+ nelt++;
+ }
+ elts[nelt].glyphset = font->glyphset;
+ elts[nelt].chars = char8 + size * j;
+ elts[nelt].xOff = glyphs[i].x - x;
+ elts[nelt].yOff = glyphs[i].y - y;
+ x = glyphs[i].x;
+ y = glyphs[i].y;
+ n = 0;
+ }
+ switch (width) {
+ case 1: char8[j] = (char) g; break;
+ case 2: char16[j] = (unsigned short) g; break;
+ case 4: char32[j] = (unsigned int) g; break;
+ }
+ x += glyph->metrics.xOff;
+ y += glyph->metrics.yOff;
+ j++;
+ n++;
+ }
+ }
+ if (n)
+ {
+ elts[nelt].nchars = n;
+ nelt++;
+ }
+ switch (width) {
+ case 1:
+ XRenderCompositeText8 (dpy, op, src, dst, font->format,
+ srcx, srcy, glyphs[0].x, glyphs[0].y,
+ elts, nelt);
+ break;
+ case 2:
+ XRenderCompositeText16 (dpy, op, src, dst, font->format,
+ srcx, srcy, glyphs[0].x, glyphs[0].y,
+ (XGlyphElt16 *) elts, nelt);
+ break;
+ case 4:
+ XRenderCompositeText32 (dpy, op, src, dst, font->format,
+ srcx, srcy, glyphs[0].x, glyphs[0].y,
+ (XGlyphElt32 *) elts, nelt);
+ break;
+ }
+
+ if (elts != elts_local)
+ free (elts);
+bail2:
+ if (chars != char_local)
+ free (chars);
+bail1:
+ if (glyphs_loaded)
+ _XftFontManageMemory (dpy, pub);
+}
+
+void
+XftCharSpecRender (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ _Xconst XftCharSpec *chars,
+ int len)
+{
+ XftGlyphSpec *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (XftGlyphSpec));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ {
+ glyphs[i].glyph = XftCharIndex(dpy, pub, chars[i].ucs4);
+ glyphs[i].x = chars[i].x;
+ glyphs[i].y = chars[i].y;
+ }
+
+ XftGlyphSpecRender (dpy, op, src, pub, dst, srcx, srcy, glyphs, len);
+
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+/*
+ * Choose which format to draw text in when drawing with fonts
+ * of different formats. The trick is that ARGB formats aren't
+ * compatible with A formats as PictOpAdd does the wrong thing, so
+ * fall back to an A format when presented with an ARGB and A format
+ */
+
+#define XftIsARGBFormat(a) ((a)->depth == 32)
+
+static XRenderPictFormat *
+XftPreferFormat (Display *dpy, XRenderPictFormat *a, XRenderPictFormat *b)
+{
+ XRenderPictFormat *prefer = 0;
+
+ if (a == b)
+ prefer = a;
+ else if (XftIsARGBFormat(a) != XftIsARGBFormat(b))
+ prefer = XRenderFindStandardFormat (dpy, PictStandardA8);
+ else if (a->depth > b->depth)
+ prefer = a;
+ else
+ prefer = b;
+ return prefer;
+}
+
+void
+XftGlyphFontSpecRender (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ int srcx,
+ int srcy,
+ _Xconst XftGlyphFontSpec *glyphs,
+ int nglyphs)
+{
+ int i, j;
+ XftFont *prevPublic;
+ XftFontInt *firstFont;
+ XRenderPictFormat *format;
+ FT_UInt missing[XFT_NMISSING];
+ int nmissing;
+ int n;
+ FT_UInt g;
+ XftGlyph *glyph;
+ FT_UInt max;
+ int size, width;
+ char *char8;
+ unsigned short *char16;
+ unsigned int *char32;
+ unsigned int char_local[NUM_LOCAL];
+ unsigned int *chars;
+ XGlyphElt8 *elts;
+ XGlyphElt8 elts_local[NUM_ELT_LOCAL];
+ FcBool glyphs_loaded;
+ int nelt;
+ int x, y;
+
+ if (!nglyphs)
+ return;
+
+ /*
+ * Load missing glyphs. Have to load them
+ * one at a time in case the font changes
+ */
+ max = 0;
+ glyphs_loaded = FcFalse;
+ g = glyphs[0].glyph;
+ for (i = 0; i < nglyphs; i++)
+ {
+ XftFont *pub = glyphs[i].font;
+ XftFontInt *font = (XftFontInt *) pub;
+ g = glyphs[i].glyph;
+ if (g > max)
+ max = g;
+ nmissing = 0;
+ if (XftFontCheckGlyph (dpy, pub, FcTrue, g, missing, &nmissing))
+ glyphs_loaded = FcTrue;
+ if (nmissing)
+ XftFontLoadGlyphs (dpy, pub, FcTrue, missing, nmissing);
+ if (!font->format)
+ goto bail1;
+ if (!font->glyphset)
+ goto bail1;
+ }
+
+ /*
+ * See what encoding size is needed
+ */
+ if (max < 0x100)
+ {
+ size = sizeof (char);
+ width = 1;
+ }
+ else if (max < 0x10000)
+ {
+ size = sizeof (unsigned short);
+ width = 2;
+ }
+ else
+ {
+ size = sizeof (unsigned int);
+ width = 4;
+ }
+ chars = char_local;
+ if (nglyphs * size > NUM_LOCAL)
+ {
+ chars = malloc (nglyphs * size);
+ if (!chars)
+ goto bail1;
+ }
+ char8 = (char *) chars;
+ char16 = (unsigned short *) chars;
+ char32 = (unsigned int *) chars;
+
+ /*
+ * Compute the number of glyph elts needed
+ */
+ nelt = 1;
+ firstFont = 0;
+ for (i = 0; i < nglyphs; i++)
+ {
+ XftFont *pub = glyphs[i].font;
+ XftFontInt *font = (XftFontInt *) pub;
+ g = glyphs[i].glyph;
+ /* Substitute default for non-existant glyphs */
+ if (g >= font->num_glyphs || !font->glyphs[g])
+ g = 0;
+ if (font->glyphs[g])
+ {
+ firstFont = font;
+ break;
+ }
+ }
+ if (i == nglyphs)
+ goto bail2;
+ glyph = firstFont->glyphs[g];
+ format = firstFont->format;
+ x = glyphs[i].x + glyph->metrics.xOff;
+ y = glyphs[i].y + glyph->metrics.yOff;
+ prevPublic = 0;
+ while (++i < nglyphs)
+ {
+ XftFont *pub = glyphs[i].font;
+ XftFontInt *font = (XftFontInt *) pub;
+ g = glyphs[i].glyph;
+ /* Substitute default for non-existant glyphs */
+ if (g >= font->num_glyphs || !font->glyphs[g])
+ g = 0;
+ /*
+ * check to see if the glyph is placed where it would
+ * fall using the normal spacing
+ */
+ if ((glyph = font->glyphs[g]))
+ {
+ if (pub != prevPublic || x != glyphs[i].x || y != glyphs[i].y)
+ {
+ prevPublic = pub;
+ if (font->format != format)
+ format = XftPreferFormat (dpy, font->format, format);
+ x = glyphs[i].x;
+ y = glyphs[i].y;
+ ++nelt;
+ }
+ x += glyph->metrics.xOff;
+ y += glyph->metrics.yOff;
+ }
+ }
+
+ elts = elts_local;
+ if (nelt > NUM_ELT_LOCAL)
+ {
+ elts = malloc (nelt * sizeof (XGlyphElt8));
+ if (!elts)
+ goto bail2;
+ }
+
+ /*
+ * Generate the list of glyph elts
+ */
+ nelt = 0;
+ x = y = 0;
+ n = 0;
+ j = 0;
+ prevPublic = 0;
+ for (i = 0; i < nglyphs; i++)
+ {
+ XftFont *pub = glyphs[i].font;
+ XftFontInt *font = (XftFontInt *) pub;
+
+ g = glyphs[i].glyph;
+ /* Substitute default for non-existant glyphs */
+ if (g >= font->num_glyphs || !font->glyphs[g])
+ g = 0;
+ if ((glyph = font->glyphs[g]))
+ {
+ if (!i || pub != prevPublic || x != glyphs[i].x || y != glyphs[i].y)
+ {
+ if (n)
+ {
+ elts[nelt].nchars = n;
+ nelt++;
+ }
+ elts[nelt].glyphset = font->glyphset;
+ elts[nelt].chars = char8 + size * j;
+ elts[nelt].xOff = glyphs[i].x - x;
+ elts[nelt].yOff = glyphs[i].y - y;
+ prevPublic = pub;
+ x = glyphs[i].x;
+ y = glyphs[i].y;
+ n = 0;
+ }
+ switch (width) {
+ case 1: char8[j] = (char) g; break;
+ case 2: char16[j] = (unsigned short) g; break;
+ case 4: char32[j] = (unsigned int) g; break;
+ }
+ x += glyph->metrics.xOff;
+ y += glyph->metrics.yOff;
+ j++;
+ n++;
+ }
+ }
+ if (n)
+ {
+ elts[nelt].nchars = n;
+ nelt++;
+ }
+ switch (width) {
+ case 1:
+ XRenderCompositeText8 (dpy, op, src, dst, format,
+ srcx, srcy, glyphs[0].x, glyphs[0].y,
+ elts, nelt);
+ break;
+ case 2:
+ XRenderCompositeText16 (dpy, op, src, dst, format,
+ srcx, srcy, glyphs[0].x, glyphs[0].y,
+ (XGlyphElt16 *) elts, nelt);
+ break;
+ case 4:
+ XRenderCompositeText32 (dpy, op, src, dst, format,
+ srcx, srcy, glyphs[0].x, glyphs[0].y,
+ (XGlyphElt32 *) elts, nelt);
+ break;
+ }
+
+ if (elts != elts_local)
+ free (elts);
+bail2:
+ if (chars != char_local)
+ free (chars);
+bail1:
+ if (glyphs_loaded)
+ for (i = 0; i < nglyphs; i++)
+ _XftFontManageMemory (dpy, glyphs[i].font);
+}
+
+void
+XftCharFontSpecRender (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ int srcx,
+ int srcy,
+ _Xconst XftCharFontSpec *chars,
+ int len)
+{
+ XftGlyphFontSpec *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (XftGlyphFontSpec));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ {
+ glyphs[i].font = chars[i].font;
+ glyphs[i].glyph = XftCharIndex(dpy, glyphs[i].font, chars[i].ucs4);
+ glyphs[i].x = chars[i].x;
+ glyphs[i].y = chars[i].y;
+ }
+
+ XftGlyphFontSpecRender (dpy, op, src, dst, srcx, srcy, glyphs, len);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftTextRender8 (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len)
+{
+ FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (FT_UInt));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ glyphs[i] = XftCharIndex (dpy, pub, string[i]);
+ XftGlyphRender (dpy, op, src, pub, dst,
+ srcx, srcy, x, y, glyphs, len);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftTextRender16 (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar16 *string,
+ int len)
+{
+ FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (FT_UInt));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ glyphs[i] = XftCharIndex (dpy, pub, string[i]);
+ XftGlyphRender (dpy, op, src, pub, dst,
+ srcx, srcy, x, y, glyphs, len);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftTextRender16BE (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len)
+{
+ FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (FT_UInt));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ glyphs[i] = XftCharIndex (dpy, pub,
+ (string[i*2]<<8) | string[i*2+1]);
+ XftGlyphRender (dpy, op, src, pub, dst,
+ srcx, srcy, x, y, glyphs, len);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftTextRender16LE (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len)
+{
+ FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (FT_UInt));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ glyphs[i] = XftCharIndex (dpy, pub,
+ string[i*2] | (string[i*2+1]<<8));
+ XftGlyphRender (dpy, op, src, pub, dst,
+ srcx, srcy, x, y, glyphs, len);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftTextRender32 (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar32 *string,
+ int len)
+{
+ FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (FT_UInt));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ glyphs[i] = XftCharIndex (dpy, pub, string[i]);
+ XftGlyphRender (dpy, op, src, pub, dst,
+ srcx, srcy, x, y, glyphs, len);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftTextRender32BE (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len)
+{
+ FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (FT_UInt));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ glyphs[i] = XftCharIndex (dpy, pub,
+ (string[i*4] << 24) |
+ (string[i*4+1] << 16) |
+ (string[i*4+2] << 8) |
+ (string[i*4+3]));
+ XftGlyphRender (dpy, op, src, pub, dst,
+ srcx, srcy, x, y, glyphs, len);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftTextRender32LE (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len)
+{
+ FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
+ int i;
+
+ if (len <= NUM_LOCAL)
+ glyphs = glyphs_local;
+ else
+ {
+ glyphs = malloc (len * sizeof (FT_UInt));
+ if (!glyphs)
+ return;
+ }
+ for (i = 0; i < len; i++)
+ glyphs[i] = XftCharIndex (dpy, pub,
+ (string[i*4]) |
+ (string[i*4+1] << 8) |
+ (string[i*4+2] << 16) |
+ (string[i*4+3] << 24));
+ XftGlyphRender (dpy, op, src, pub, dst,
+ srcx, srcy, x, y, glyphs, len);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftTextRenderUtf8 (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ int len)
+{
+ FT_UInt *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
+ FcChar32 ucs4;
+ int i;
+ int l;
+ int size;
+
+ i = 0;
+ glyphs = glyphs_local;
+ size = NUM_LOCAL;
+ while (len && (l = FcUtf8ToUcs4 (string, &ucs4, len)) > 0)
+ {
+ if (i == size)
+ {
+ glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
+ if (!glyphs_new)
+ {
+ if (glyphs != glyphs_local)
+ free (glyphs);
+ return;
+ }
+ memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
+ size *= 2;
+ if (glyphs != glyphs_local)
+ free (glyphs);
+ glyphs = glyphs_new;
+ }
+ glyphs[i++] = XftCharIndex (dpy, pub, ucs4);
+ string += l;
+ len -= l;
+ }
+ XftGlyphRender (dpy, op, src, pub, dst,
+ srcx, srcy, x, y, glyphs, i);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
+
+void
+XftTextRenderUtf16 (Display *dpy,
+ int op,
+ Picture src,
+ XftFont *pub,
+ Picture dst,
+ int srcx,
+ int srcy,
+ int x,
+ int y,
+ _Xconst FcChar8 *string,
+ FcEndian endian,
+ int len)
+{
+ FT_UInt *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
+ FcChar32 ucs4;
+ int i;
+ int l;
+ int size;
+
+ i = 0;
+ glyphs = glyphs_local;
+ size = NUM_LOCAL;
+ while (len && (l = FcUtf16ToUcs4 (string, endian, &ucs4, len)) > 0)
+ {
+ if (i == size)
+ {
+ glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
+ if (!glyphs_new)
+ {
+ if (glyphs != glyphs_local)
+ free (glyphs);
+ return;
+ }
+ memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
+ size *= 2;
+ if (glyphs != glyphs_local)
+ free (glyphs);
+ glyphs = glyphs_new;
+ }
+ glyphs[i++] = XftCharIndex (dpy, pub, ucs4);
+ string += l;
+ len -= l;
+ }
+ XftGlyphRender (dpy, PictOpOver, src, pub, dst,
+ srcx, srcy, x, y, glyphs, i);
+ if (glyphs != glyphs_local)
+ free (glyphs);
+}
diff --git a/nx-X11/lib/Xft/xftstr.c b/nx-X11/lib/Xft/xftstr.c
new file mode 100644
index 000000000..2aec82df7
--- /dev/null
+++ b/nx-X11/lib/Xft/xftstr.c
@@ -0,0 +1,37 @@
+/*
+ * $Id: xftstr.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+int
+_XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def)
+{
+ while (n--)
+ {
+ if (!FcStrCmpIgnoreCase ((FcChar8 *) s->name, (FcChar8 *) name))
+ return s->value;
+ s++;
+ }
+ return def;
+}
diff --git a/nx-X11/lib/Xft/xftswap.c b/nx-X11/lib/Xft/xftswap.c
new file mode 100644
index 000000000..9e3ac6495
--- /dev/null
+++ b/nx-X11/lib/Xft/xftswap.c
@@ -0,0 +1,121 @@
+/*
+ * $Id: xftswap.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+int
+XftNativeByteOrder (void)
+{
+ int whichbyte = 1;
+
+ if (*((char *) &whichbyte))
+ return LSBFirst;
+ return MSBFirst;
+}
+
+/* byte swap a 32-bit value */
+#define swapl(x, n) { \
+ n = ((char *) (x))[0];\
+ ((char *) (x))[0] = ((char *) (x))[3];\
+ ((char *) (x))[3] = n;\
+ n = ((char *) (x))[1];\
+ ((char *) (x))[1] = ((char *) (x))[2];\
+ ((char *) (x))[2] = n; }
+
+/* byte swap a short */
+#define swaps(x, n) { \
+ n = ((char *) (x))[0];\
+ ((char *) (x))[0] = ((char *) (x))[1];\
+ ((char *) (x))[1] = n; }
+
+/* byte swap a three-byte unit */
+#define swapt(x, n) { \
+ n = ((char *) (x))[0];\
+ ((char *) (x))[0] = ((char *) (x))[2];\
+ ((char *) (x))[2] = n; }
+
+void
+XftSwapCARD32 (CARD32 *data, int u)
+{
+ char n;
+ while (u--)
+ {
+ swapl (data, n);
+ data++;
+ }
+}
+
+void
+XftSwapCARD24 (CARD8 *data, int width, int height)
+{
+ int units, u;
+ char n;
+ CARD8 *d;
+
+ units = width / 3;
+ while (height--)
+ {
+ d = data;
+ data += width;
+ u = units;
+ while (u--)
+ {
+ swapt (d, n);
+ d += 3;
+ }
+ }
+}
+
+void
+XftSwapCARD16 (CARD16 *data, int u)
+{
+ char n;
+ while (u--)
+ {
+ swaps (data, n);
+ data++;
+ }
+}
+
+void
+XftSwapImage (XImage *image)
+{
+ switch (image->bits_per_pixel) {
+ case 32:
+ XftSwapCARD32 ((CARD32 *) image->data,
+ image->height * image->bytes_per_line >> 2);
+ break;
+ case 24:
+ XftSwapCARD24 ((CARD8 *) image->data,
+ image->bytes_per_line,
+ image->height);
+ break;
+ case 16:
+ XftSwapCARD16 ((CARD16 *) image->data,
+ image->height * image->bytes_per_line >> 1);
+ break;
+ default:
+ break;
+ }
+}
diff --git a/nx-X11/lib/Xft/xftxlfd.c b/nx-X11/lib/Xft/xftxlfd.c
new file mode 100644
index 000000000..05899dbba
--- /dev/null
+++ b/nx-X11/lib/Xft/xftxlfd.c
@@ -0,0 +1,177 @@
+/*
+ * $Id: xftxlfd.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+static XftSymbolic XftXlfdWeights[] = {
+ { "light", FC_WEIGHT_LIGHT },
+ { "medium", FC_WEIGHT_MEDIUM },
+ { "regular", FC_WEIGHT_MEDIUM },
+ { "demibold", FC_WEIGHT_DEMIBOLD },
+ { "bold", FC_WEIGHT_BOLD },
+ { "black", FC_WEIGHT_BLACK },
+};
+
+#define NUM_XLFD_WEIGHTS (sizeof XftXlfdWeights/sizeof XftXlfdWeights[0])
+
+static XftSymbolic XftXlfdSlants[] = {
+ { "r", FC_SLANT_ROMAN },
+ { "i", FC_SLANT_ITALIC },
+ { "o", FC_SLANT_OBLIQUE },
+};
+
+#define NUM_XLFD_SLANTS (sizeof XftXlfdSlants/sizeof XftXlfdSlants[0])
+
+/*
+ * Cut out one XLFD field, placing it in 'save' and return
+ * the start of 'save'
+ */
+static char *
+XftSplitStr (const char *field, char *save)
+{
+ char *s = save;
+ char c;
+
+ while (*field)
+ {
+ if (*field == '-')
+ break;
+ c = *field++;
+ *save++ = c;
+ }
+ *save = 0;
+ return s;
+}
+
+/*
+ * convert one XLFD numeric field. Return -1 if the field is '*'
+ */
+
+static const char *
+XftGetInt(const char *ptr, int *val)
+{
+ if (*ptr == '*') {
+ *val = -1;
+ ptr++;
+ } else
+ for (*val = 0; *ptr >= '0' && *ptr <= '9';)
+ *val = *val * 10 + *ptr++ - '0';
+ if (*ptr == '-')
+ return ptr;
+ return (char *) 0;
+}
+
+FcPattern *
+XftXlfdParse (const char *xlfd_orig, FcBool ignore_scalable, FcBool complete)
+{
+ FcPattern *pat;
+ const char *xlfd = xlfd_orig;
+ const char *foundry;
+ const char *family;
+ const char *weight_name;
+ const char *slant;
+ const char *registry;
+ const char *encoding;
+ char *save;
+ int pixel;
+ int point;
+ int resx;
+ int resy;
+ int slant_value, weight_value;
+ double dpixel;
+
+ if (*xlfd != '-')
+ return 0;
+ if (!(xlfd = strchr (foundry = ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (family = ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (weight_name = ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (slant = ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (/* setwidth_name = */ ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (/* add_style_name = */ ++xlfd, '-'))) return 0;
+ if (!(xlfd = XftGetInt (++xlfd, &pixel))) return 0;
+ if (!(xlfd = XftGetInt (++xlfd, &point))) return 0;
+ if (!(xlfd = XftGetInt (++xlfd, &resx))) return 0;
+ if (!(xlfd = XftGetInt (++xlfd, &resy))) return 0;
+ if (!(xlfd = strchr (/* spacing = */ ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (/* average_width = */ ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (registry = ++xlfd, '-'))) return 0;
+ /* make sure no fields follow this one */
+ if ((xlfd = strchr (encoding = ++xlfd, '-'))) return 0;
+
+ if (!pixel)
+ return 0;
+
+ pat = FcPatternCreate ();
+ if (!pat)
+ return 0;
+
+ save = (char *) malloc (strlen (foundry) + 1);
+
+ if (!save)
+ return 0;
+
+ if (!FcPatternAddString (pat, XFT_XLFD, (FcChar8 *) xlfd_orig)) goto bail;
+
+ XftSplitStr (foundry, save);
+ if (save[0] && strcmp (save, "*") != 0)
+ if (!FcPatternAddString (pat, FC_FOUNDRY, (FcChar8 *) save)) goto bail;
+
+ XftSplitStr (family, save);
+ if (save[0] && strcmp (save, "*") != 0)
+ if (!FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) save)) goto bail;
+
+ weight_value = _XftMatchSymbolic (XftXlfdWeights, NUM_XLFD_WEIGHTS,
+ XftSplitStr (weight_name, save),
+ FC_WEIGHT_MEDIUM);
+ if (!FcPatternAddInteger (pat, FC_WEIGHT, weight_value))
+ goto bail;
+
+ slant_value = _XftMatchSymbolic (XftXlfdSlants, NUM_XLFD_SLANTS,
+ XftSplitStr (slant, save),
+ FC_SLANT_ROMAN);
+ if (!FcPatternAddInteger (pat, FC_SLANT, slant_value))
+ goto bail;
+
+ dpixel = (double) pixel;
+
+ if (point > 0)
+ {
+ if (!FcPatternAddDouble (pat, FC_SIZE, ((double) point) / 10.0)) goto bail;
+ if (pixel <= 0 && resy > 0)
+ {
+ dpixel = (double) point * (double) resy / 720.0;
+ }
+ }
+
+ if (dpixel > 0)
+ if (!FcPatternAddDouble (pat, FC_PIXEL_SIZE, dpixel)) goto bail;
+
+ free (save);
+ return pat;
+
+bail:
+ free (save);
+ FcPatternDestroy (pat);
+ return 0;
+}
diff --git a/nx-X11/lib/Xft1/Imakefile b/nx-X11/lib/Xft1/Imakefile
new file mode 100644
index 000000000..dbb48cf45
--- /dev/null
+++ b/nx-X11/lib/Xft1/Imakefile
@@ -0,0 +1,150 @@
+XCOMM $XFree86: xc/lib/Xft1/Imakefile,v 1.13tsi Exp $
+
+XCOMM Allow for builds against old installed bits
+#ifdef UseInstalled
+
+#ifndef SharedLibXft1
+#define SharedLibXft1 YES
+#endif
+
+#ifndef NormalLibXft1
+#define NormalLibXft1 (!SharedLibXft1 | ForceNormalLib)
+#endif
+
+#ifndef DebugLibXft1
+#define DebugLibXft1 NO
+#endif
+
+#ifndef ProfileLibXft1
+#define ProfileLibXft1 NO
+#endif
+
+#ifndef FontconfigClientDepLibs
+#define FontconfigClientDepLibs $(DEPFONTCONFIGLIB)
+#endif
+#ifndef FontconfigClientLibs
+#define FontconfigClientLibs $(FONTCONFIGLIB)
+#endif
+
+#if SharedLibFontconfig
+#define SharedFontconfigRev 1.0
+
+SharedLibReferences(FONTCONFIG,fontconfig,$(FONTCONFIGSRC),SOXLIBREV,SharedFontconfigRev)
+#else
+
+ProjectUnsharedLibReferences(FONTCONFIG,fontconfig,$(FONTCONFIGSRC),BuildLibDir)
+#endif
+
+#if SharedLibXft1
+#define SharedXft1Rev 1.2
+SharedLibReferences(XFT1,Xft,$(XFT1SRC),SOXFT1REV,SharedXft1Rev)
+#else
+ProjectUnsharedLibReferences(XFT1,Xft,$(XFT1SRC),BuildLibDir)
+#endif
+
+#undef LinkBuildLibrary
+#define LinkBuildLibrary(lib) MakeDir($(BUILDLIBDIR)) @@\
+ RemoveFile($(BUILDLIBDIR)/lib) @@\
+ cd $(BUILDLIBDIR) && $(LN) $(BUILDLIBTOP)/$(CURRENT_DIR)/lib .
+#undef _LinkBuildLibrary
+#define _LinkBuildLibrary(lib) LinkBuildLibrary(lib)
+
+#undef LinkBuildLibraryMaybe
+#define LinkBuildLibraryMaybe(lib,doit) MakeDir($(BUILDLIBDIR)) @@\
+ @if doit; then (set -x; \ @@\
+ RemoveFile($(BUILDLIBDIR)/lib); \ @@\
+ cd $(BUILDLIBDIR) && $(LN) $(BUILDLIBTOP)/$(CURRENT_DIR)/lib .); fi
+
+#ifdef LdPreLibs
+# undef LdPreLibs
+#endif
+#define LdPreLibs -L$(BUILDLIBDIR) LdPreLib XLdPreLibs
+
+LDPRELIBS=LdPreLibs
+#endif
+
+
+#define DoNormalLib NO
+#define DoSharedLib SharedLibXft1
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#define HasSharedData YES
+#define LibName Xft
+#define SoRev SOXFT1REV
+#define LibHeaders NO
+#define NoSoSymlink
+
+#include <Threads.tmpl>
+
+YFLAGS = -d
+
+#ifndef XftLibDir
+#define XftLibDir $(LIBDIR)
+#endif
+
+XFTLIBDIR=XftLibDir
+
+INCLUDES=$(FONTCONFIGINCLUDES) $(FREETYPE2INCLUDES) -I$(XBUILDINCDIR)
+DEFINES=$(FREETYPE2DEFINES) $(RENDERDEFINES) -DXFREE86_FT2
+
+#if UseFreetype2
+FREETYPE2REQLIB = $(FREETYPE2LIB)
+#endif
+
+REQUIREDLIBS=$(LDPRELIBS) $(XRENDERLIB) $(XLIB) $(FONTCONFIGLIB) $(EXPATLIB) $(FREETYPE2REQLIB)
+
+#if UseFreetype2
+FT_OLD = xftcache.c
+FT_HEADERS = XftFreetype.h
+ FT_SRCS = xftfreetype.c xftglyphs.c xftrender.c xftdir.c
+ FT_OBJS = xftfreetype.o xftglyphs.o xftrender.o xftdir.o
+#endif
+
+HEADERS = Xft.h $(FT_HEADERS)
+
+OLD = xftgram.c xftlex.c
+
+ SRCS = xftcfg.c xftcolor.c xftcore.c xftdbg.c xftdpy.c \
+ xftdraw.c xftextent.c xftfont.c xftfs.c\
+ xftinit.c xftlist.c xftmatch.c xftmatrix.c \
+ xftname.c xftpat.c xftstr.c xftxlfd.c $(FT_SRCS)
+
+ OBJS = xftcfg.o xftcolor.o xftcore.o xftdbg.o xftdpy.o \
+ xftdraw.o xftextent.o xftfont.o xftfs.o \
+ xftinit.o xftlist.o xftmatch.o xftmatrix.o \
+ xftname.o xftpat.o xftstr.o xftxlfd.o $(FT_OBJS)
+
+#include <Library.tmpl>
+
+#if DoSharedLib && SharedDataSeparation
+SpecialCObjectRule(sharedlib,NullParameter,$(SHLIBDEF))
+#endif
+
+/*
+ * InstallNamedTargetRelated - like InstallNamedTarget, but only
+ * installs if a related file already exists. Useful for
+ * annotating older systems with information on the relationship
+ * with the new system.
+ */
+
+#ifndef InstallNamedTargetRelated
+#define InstallNamedTargetRelated(step,srcname,flags,dest,dstname,dstrel)@@\
+step:: srcname @@\
+ MakeDir($(DESTDIR)dest) @@\
+ @if [ -f $(DESTDIR)dest/dstrel ]; then \ @@\
+ set -x; \ @@\
+ $(INSTALL) $(INSTALLFLAGS) flags srcname $(DESTDIR)dest/dstname; fi
+#endif
+
+#ifndef InstallNonExecFileRelated
+#define InstallNonExecFileRelated(file,dest,rel) @@\
+InstallNamedTargetRelated(install,file,$(INSTDATFLAGS),dest,file,rel)
+#endif /* InstallNonExecFileBackup */
+
+InstallNonExecFileRelated(XftConfig-OBSOLETE,$(XFTLIBDIR),XftConfig)
+InstallNonExecFileRelated(XftConfig-OBSOLETE,$(CONFDIR),XftConfig)
+
+MANSUFFIX = $(LIBMANSUFFIX)
+InstallManPage(Xft,$(LIBMANDIR))
+DependTarget()
diff --git a/nx-X11/lib/Xft1/Xft-def.cpp b/nx-X11/lib/Xft1/Xft-def.cpp
new file mode 100644
index 000000000..410b8202b
--- /dev/null
+++ b/nx-X11/lib/Xft1/Xft-def.cpp
@@ -0,0 +1,171 @@
+LIBRARY Xft
+VERSION LIBRARY_VERSION
+EXPORTS
+
+#ifndef __UNIXOS2__
+XftConfigAddDir
+XftConfigAddEdit
+XftConfigGetCache
+XftConfigSetCache
+XftConfigSubstitute
+_XftConfigCompareValue
+#endif
+XftColorAllocName
+XftColorAllocValue
+XftColorFree
+#ifndef __UNIXOS2__
+XftCoreConvert16
+XftCoreConvert32
+XftCoreConvertUtf8
+XftCoreExtents16
+XftCoreExtents32
+XftCoreExtents8
+XftCoreExtentsUtf8
+XftCoreGlyphExists
+XftEditPrint
+XftExprPrint
+XftFontSetPrint
+XftOpPrint
+XftPatternPrint
+XftSubstPrint
+XftTestPrint
+XftValueListPrint
+XftValuePrint
+#endif
+XftDefaultGetBool
+XftDefaultGetDouble
+XftDefaultGetInteger
+XftDefaultHasRender
+XftDefaultParseBool
+XftDefaultSet
+XftDefaultSubstitute
+#ifndef __UNIXOS2__
+XftDisplayGetFontSet
+#endif
+XftDrawChange
+#ifndef __UNIXOS2__
+XftDrawCorePrepare
+#endif
+XftDrawCreate
+XftDrawCreateBitmap
+XftDrawDestroy
+XftDrawRect
+#ifndef __UNIXOS2__
+XftDrawRenderPrepare
+#endif
+XftDrawSetClip
+XftDrawString16
+XftDrawString32
+XftDrawString8
+XftDrawStringUtf8
+XftTextExtents16
+XftTextExtents32
+XftTextExtents8
+XftTextExtentsUtf8
+XftFontClose
+XftFontMatch
+XftFontOpen
+XftFontOpenName
+XftFontOpenPattern
+XftFontOpenXlfd
+#ifndef __UNIXOS2__
+XftGlyphExists
+_XftFontDebug
+XftFontSetAdd
+XftFontSetCreate
+XftFontSetDestroy
+XftConfigSaveField
+XftConfigerror
+XftConfigparse
+XftConfigwrap
+XftEditCreate
+XftEditDestroy
+XftExprCreateBool
+XftExprCreateDouble
+XftExprCreateField
+XftExprCreateInteger
+XftExprCreateNil
+XftExprCreateOp
+XftExprCreateString
+XftExprDestroy
+XftTestCreate
+#endif
+XftInit
+#ifndef __UNIXOS2__
+XftConfigLexFile
+XftConfigPushInput
+XftConfig_create_buffer
+XftConfig_delete_buffer
+XftConfig_flush_buffer
+XftConfig_init_buffer
+XftConfig_load_buffer_state
+XftConfig_scan_buffer
+XftConfig_scan_bytes
+XftConfig_scan_string
+XftConfig_switch_to_buffer
+XftConfiglex
+XftConfigrestart
+XftListAppend
+XftListFontSets
+#endif
+XftListFonts
+XftListFontsPatternObjects
+#ifndef __UNIXOS2__
+XftListMatch
+XftListValueCompare
+XftListValueListCompare
+XftObjectSetAdd
+XftObjectSetBuild
+XftObjectSetCreate
+XftObjectSetDestroy
+XftObjectSetVaBuild
+XftFontSetMatch
+XftNameConstant
+#endif
+XftNameParse
+XftNameUnparse
+#ifndef __UNIXOS2__
+XftPatternAdd
+XftPatternAddBool
+XftPatternAddDouble
+XftPatternAddInteger
+XftPatternAddString
+XftPatternBuild
+XftPatternCreate
+XftPatternDel
+XftPatternDestroy
+XftPatternDuplicate
+XftPatternFind
+XftPatternGet
+XftPatternGetBool
+XftPatternGetDouble
+XftPatternGetInteger
+XftPatternGetString
+XftPatternVaBuild
+XftValueDestroy
+XftValueListDestroy
+XftUtf8Len
+XftUtf8ToUcs4
+_XftDownStr
+_XftGetInt
+#endif
+_XftMatchSymbolic
+#ifndef __UNIXOS2__
+_XftSaveString
+_XftSplitField
+_XftSplitStr
+_XftSplitValue
+_XftStrCmpIgnoreCase
+XftCoreAddFonts
+XftCoreClose
+XftCoreOpen
+#endif
+XftXlfdParse
+XftInitFtLibrary
+#ifndef __UNIXOS2__
+XftConfigDirs
+XftDirScan
+XftDirSave
+#endif
+
+/* $XFree86: xc/lib/Xft/Xft-def.cpp,v 1.4 2002/09/18 01:25:00 dawes Exp $ */
diff --git a/nx-X11/lib/Xft1/Xft.h b/nx-X11/lib/Xft1/Xft.h
new file mode 100644
index 000000000..71ef9b80c
--- /dev/null
+++ b/nx-X11/lib/Xft1/Xft.h
@@ -0,0 +1,486 @@
+/*
+ * $XFree86: xc/lib/Xft/Xft.h,v 1.19 2001/04/29 03:21:17 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _XFT_H_
+#define _XFT_H_
+
+#include <X11/extensions/Xrender.h>
+#include <fontconfig/fontconfig.h>
+#include <stdarg.h>
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+
+typedef unsigned char XftChar8;
+typedef unsigned short XftChar16;
+typedef unsigned int XftChar32;
+
+#define XFT_FAMILY "family" /* String */
+#define XFT_STYLE "style" /* String */
+#define XFT_SLANT "slant" /* Int */
+#define XFT_WEIGHT "weight" /* Int */
+#define XFT_SIZE "size" /* Double */
+#define XFT_PIXEL_SIZE "pixelsize" /* Double */
+#define XFT_ENCODING "encoding" /* String */
+#define XFT_SPACING "spacing" /* Int */
+#define XFT_FOUNDRY "foundry" /* String */
+#define XFT_CORE "core" /* Bool */
+#define XFT_ANTIALIAS "antialias" /* Bool */
+#define XFT_XLFD "xlfd" /* String */
+#define XFT_FILE "file" /* String */
+#define XFT_INDEX "index" /* Int */
+#define XFT_RASTERIZER "rasterizer"/* String */
+#define XFT_OUTLINE "outline" /* Bool */
+#define XFT_SCALABLE "scalable" /* Bool */
+#define XFT_RGBA "rgba" /* Int */
+
+/* defaults from resources */
+#define XFT_SCALE "scale" /* double */
+#define XFT_RENDER "render" /* Bool */
+#define XFT_MINSPACE "minspace" /* Bool use minimum line spacing */
+#define XFT_DPI "dpi" /* double */
+
+/* specific to FreeType rasterizer */
+#define XFT_CHAR_WIDTH "charwidth" /* Int */
+#define XFT_CHAR_HEIGHT "charheight"/* Int */
+#define XFT_MATRIX "matrix" /* XftMatrix */
+
+#define XFT_WEIGHT_LIGHT 0
+#define XFT_WEIGHT_MEDIUM 100
+#define XFT_WEIGHT_DEMIBOLD 180
+#define XFT_WEIGHT_BOLD 200
+#define XFT_WEIGHT_BLACK 210
+
+#define XFT_SLANT_ROMAN 0
+#define XFT_SLANT_ITALIC 100
+#define XFT_SLANT_OBLIQUE 110
+
+#define XFT_PROPORTIONAL 0
+#define XFT_MONO 100
+#define XFT_CHARCELL 110
+
+#define XFT_RGBA_NONE 0
+#define XFT_RGBA_RGB 1
+#define XFT_RGBA_BGR 2
+#define XFT_RGBA_VRGB 3
+#define XFT_RGBA_VBGR 4
+
+typedef FcType XftType;
+
+typedef FcMatrix XftMatrix;
+
+#define XftMatrixInit(m) FcMatrixInit(m)
+
+typedef FcResult XftResult;
+
+#define XftResultMatch FcResultMatch
+#define XftResultNoMatch FcResultNoMatch
+#define XftResultTypeMismatch FcResultTypeMismatch
+#define XftResultNoId FcResultNoId
+
+#define XftTypeVoid FcTypeVoid
+#define XftTypeInteger FcTypeInteger
+#define XftTypeDouble FcTypeDouble
+#define XftTypeString FcTypeString
+#define XftTypeBool FcTypeBool
+#define XftTypeMatrix FcTypeMatrix
+
+typedef FcValue XftValue;
+
+
+typedef FcPattern XftPattern;
+
+typedef FcFontSet XftFontSet;
+
+typedef struct _XftFontStruct XftFontStruct;
+
+typedef struct _XftFont {
+ int ascent;
+ int descent;
+ int height;
+ int max_advance_width;
+ Bool core;
+ XftPattern *pattern;
+ union {
+ struct {
+ XFontStruct *font;
+ } core;
+ struct {
+ XftFontStruct *font;
+ } ft;
+ } u;
+} XftFont;
+
+typedef struct _XftDraw XftDraw;
+
+typedef struct _XftColor {
+ unsigned long pixel;
+ XRenderColor color;
+} XftColor;
+
+typedef FcObjectSet XftObjectSet;
+
+_XFUNCPROTOBEGIN
+
+/* xftcfg.c */
+Bool
+XftConfigSubstitute (XftPattern *p);
+
+/* xftcolor.c */
+Bool
+XftColorAllocName (Display *dpy,
+ Visual *visual,
+ Colormap cmap,
+ char *name,
+ XftColor *result);
+
+Bool
+XftColorAllocValue (Display *dpy,
+ Visual *visual,
+ Colormap cmap,
+ XRenderColor *color,
+ XftColor *result);
+
+void
+XftColorFree (Display *dpy,
+ Visual *visual,
+ Colormap cmap,
+ XftColor *color);
+
+
+/* xftcore.c */
+/* xftdbg.c */
+void
+XftValuePrint (XftValue v);
+
+void
+XftPatternPrint (XftPattern *p);
+
+void
+XftFontSetPrint (XftFontSet *s);
+
+/* xftdir.c */
+/* xftdpy.c */
+Bool
+XftDefaultHasRender (Display *dpy);
+
+Bool
+XftDefaultSet (Display *dpy, XftPattern *defaults);
+
+void
+XftDefaultSubstitute (Display *dpy, int screen, XftPattern *pattern);
+
+/* xftdraw.c */
+
+XftDraw *
+XftDrawCreate (Display *dpy,
+ Drawable drawable,
+ Visual *visual,
+ Colormap colormap);
+
+XftDraw *
+XftDrawCreateBitmap (Display *dpy,
+ Pixmap bitmap);
+
+void
+XftDrawChange (XftDraw *draw,
+ Drawable drawable);
+
+void
+XftDrawDestroy (XftDraw *draw);
+
+void
+XftDrawString8 (XftDraw *d,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar8 *string,
+ int len);
+
+void
+XftDrawString16 (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar16 *string,
+ int len);
+
+void
+XftDrawString32 (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar32 *string,
+ int len);
+
+void
+XftDrawStringUtf8 (XftDraw *d,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar8 *string,
+ int len);
+
+void
+XftDrawRect (XftDraw *d,
+ XftColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height);
+
+
+Bool
+XftDrawSetClip (XftDraw *d,
+ Region r);
+
+/* xftextent.c */
+
+void
+XftTextExtents8 (Display *dpy,
+ XftFont *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftTextExtents16 (Display *dpy,
+ XftFont *font,
+ XftChar16 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftTextExtents32 (Display *dpy,
+ XftFont *font,
+ XftChar32 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftTextExtentsUtf8 (Display *dpy,
+ XftFont *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+/* xftfont.c */
+XftPattern *
+XftFontMatch (Display *dpy, int screen, XftPattern *pattern, XftResult *result);
+
+XftFont *
+XftFontOpenPattern (Display *dpy, XftPattern *pattern);
+
+XftFont *
+XftFontOpen (Display *dpy, int screen, ...);
+
+XftFont *
+XftFontOpenName (Display *dpy, int screen, const char *name);
+
+XftFont *
+XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd);
+
+void
+XftFontClose (Display *dpy, XftFont *font);
+
+Bool
+XftGlyphExists (Display *dpy, XftFont *font, XftChar32 glyph);
+
+/* xftfreetype.c */
+/* xftfs.c */
+
+XftFontSet *
+XftFontSetCreate (void);
+
+void
+XftFontSetDestroy (XftFontSet *s);
+
+Bool
+XftFontSetAdd (XftFontSet *s, XftPattern *font);
+
+/* xftglyphs.c */
+/* see XftFreetype.h */
+
+/* xftgram.y */
+
+/* xftinit.c */
+Bool
+XftInit (char *config);
+
+/* xftlex.l */
+
+/* xftlist.c */
+XftObjectSet *
+XftObjectSetCreate (void);
+
+Bool
+XftObjectSetAdd (XftObjectSet *os, const char *object);
+
+void
+XftObjectSetDestroy (XftObjectSet *os);
+
+XftObjectSet *
+XftObjectSetVaBuild (const char *first, va_list va);
+
+XftObjectSet *
+XftObjectSetBuild (const char *first, ...);
+
+XftFontSet *
+XftListFontSets (XftFontSet **sets,
+ int nsets,
+ XftPattern *p,
+ XftObjectSet *os);
+
+XftFontSet *
+XftListFontsPatternObjects (Display *dpy,
+ int screen,
+ XftPattern *pattern,
+ XftObjectSet *os);
+
+XftFontSet *
+XftListFonts (Display *dpy,
+ int screen,
+ ...);
+
+/* xftmatch.c */
+XftPattern *
+XftFontSetMatch (XftFontSet **sets,
+ int nsets,
+ XftPattern *p,
+ XftResult *result);
+
+/* xftmatrix.c */
+int
+XftMatrixEqual (const XftMatrix *mat1, const XftMatrix *mat2);
+
+void
+XftMatrixMultiply (XftMatrix *result, XftMatrix *a, XftMatrix *b);
+
+void
+XftMatrixRotate (XftMatrix *m, double c, double s);
+
+void
+XftMatrixScale (XftMatrix *m, double sx, double sy);
+
+void
+XftMatrixShear (XftMatrix *m, double sh, double sv);
+
+/* xftname.c */
+XftPattern *
+XftNameParse (const char *name);
+
+Bool
+XftNameUnparse (XftPattern *pat, char *dest, int len);
+
+/* xftpat.c */
+XftPattern *
+XftPatternCreate (void);
+
+XftPattern *
+XftPatternDuplicate (XftPattern *p);
+
+void
+XftValueDestroy (XftValue v);
+
+void
+XftPatternDestroy (XftPattern *p);
+
+Bool
+XftPatternAdd (XftPattern *p, const char *object, XftValue value, Bool append);
+
+XftResult
+XftPatternGet (XftPattern *p, const char *object, int id, XftValue *v);
+
+Bool
+XftPatternDel (XftPattern *p, const char *object);
+
+Bool
+XftPatternAddInteger (XftPattern *p, const char *object, int i);
+
+Bool
+XftPatternAddDouble (XftPattern *p, const char *object, double d);
+
+Bool
+XftPatternAddString (XftPattern *p, const char *object, const char *s);
+
+Bool
+XftPatternAddMatrix (XftPattern *p, const char *object, const XftMatrix *s);
+
+Bool
+XftPatternAddBool (XftPattern *p, const char *object, Bool b);
+
+XftResult
+XftPatternGetInteger (XftPattern *p, const char *object, int n, int *i);
+
+XftResult
+XftPatternGetDouble (XftPattern *p, const char *object, int n, double *d);
+
+XftResult
+XftPatternGetString (XftPattern *p, const char *object, int n, char **s);
+
+XftResult
+XftPatternGetMatrix (XftPattern *p, const char *object, int n, XftMatrix **s);
+
+XftResult
+XftPatternGetBool (XftPattern *p, const char *object, int n, Bool *b);
+
+XftPattern *
+XftPatternVaBuild (XftPattern *orig, va_list va);
+
+XftPattern *
+XftPatternBuild (XftPattern *orig, ...);
+
+/* xftrender.c */
+/* see XftFreetype.h */
+
+/* xftstr.c */
+
+int
+XftUtf8ToUcs4 (XftChar8 *src_orig,
+ XftChar32 *dst,
+ int len);
+
+Bool
+XftUtf8Len (XftChar8 *string,
+ int len,
+ int *nchar,
+ int *wchar);
+
+/* xftxlfd.c */
+XftPattern *
+XftXlfdParse (const char *xlfd_orig, Bool ignore_scalable, Bool complete);
+
+XFontStruct *
+XftCoreOpen (Display *dpy, XftPattern *pattern);
+
+void
+XftCoreClose (Display *dpy, XFontStruct *font);
+
+_XFUNCPROTOEND
+
+#endif /* _XFT_H_ */
diff --git a/nx-X11/lib/Xft1/Xft.man b/nx-X11/lib/Xft1/Xft.man
new file mode 100644
index 000000000..7d62818a2
--- /dev/null
+++ b/nx-X11/lib/Xft1/Xft.man
@@ -0,0 +1,180 @@
+.\"
+.\" $XFree86: xc/lib/Xft/Xft.man,v 1.2 2000/11/30 06:59:45 keithp Exp $
+.\"
+.\" Copyright © 2000 Keith Packard.
+.\" 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 of Keith Packard not be used in
+.\" advertising or publicity pertaining to distribution of the software without
+.\" specific, written prior permission. Keith Packard makes no
+.\" representations about the suitability of this software for any purpose. It
+.\" is provided "as is" without express or implied warranty.
+.\"
+.\" KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+.\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+.\" EVENT SHALL KEITH PACKARD 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.
+.\"
+.de TQ
+.br
+.ns
+.TP \\$1
+..
+.TH XFT __libmansuffix__ __vendorversion__
+
+.SH NAME
+ XFT \- X FreeType interface library
+
+.SH DESCRIPTION
+.B Xft
+is a simple library designed to interface the FreeType rasterizer with the X
+Rendering Extension. This manual page barely scratches the surface of this
+library.
+
+.SH DATATYPES
+
+.B XftPattern
+holds a set of names with associated value lists; each name refers to a
+property of a font. XftPatterns are used as inputs to the matching code as
+well as holding information about specific fonts.
+
+.B XftFont
+contains general font metrics and a pointer to either the core XFontStruct
+data or a structure holding FreeType and X Render Extension data.
+
+.B XftFontStruct
+contains information about FreeType fonts used with the X Render Extension.
+
+.B XftFontSet
+contains a list of XftPatterns. Internally Xft uses this data structure to
+hold sets of fonts. Externally, Xft returns the results of listing fonts in
+this format.
+
+.B XftObjectSet
+holds a set of names and is used to specify which fields from fonts are
+placed in the the list of returned patterns when listing fonts.
+
+.B XftDraw
+is an opaque object which holds information used to render to an X drawable
+using either core protocol or the X Rendering extension.
+
+.SH FUNCTIONS
+.nf
+XftFont *
+XftFontOpen (Display *dpy, int screen, ...);
+.fi
+.B XftFontOpen
+takes a list of pattern elements of the form (field, type, value) terminated
+with a 0, matches that pattern against the available fonts and opens the
+matching font.
+.PP
+Example:
+.br
+ font = XftFontOpen (dpy, scr,
+ XFT_FAMILY, XftTypeString, "charter",
+ XFT_SIZE, XftTypeDouble, 12.0);
+.PP
+This opens the charter font at 12 points. The point size is automatically
+converted to the correct pixel size based on the resolution of the monitor.
+.PP
+.nf
+void
+XftTextExtents8 (Display *dpy,
+ XftFont *font,
+ unsigned char *string,
+ int len,
+ XGlyphInfo *extents);
+.fi
+.B XftTextExtents8
+computes the pixel extents of "string" when drawn with "font".
+.PP
+.nf
+XftDraw *
+XftDrawCreate (Display *dpy,
+ Drawable drawable,
+ Visual *visual,
+ Colormap colormap);
+.fi
+.B XtDrawCreate
+creates a structure that can be used to render text and rectangles
+to the screen.
+.PP
+.nf
+void
+XftDrawString8 (XftDraw *d,
+ XRenderColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ unsigned char *string,
+ int len);
+.fi
+.B XftDrawString8
+draws "string" using "font" in "color" at "x, y".
+.PP
+.nf
+void
+XftDrawRect (XftDraw *d,
+ XRenderColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height);
+.fi
+.B XftDrawRect
+fills a solid rectangle in the specified color.
+.SH XftConfig
+The
+.B XftConfig
+file contains configuration information for the Xft library consisting of
+directories to look at for font information as well as instructions on
+editing program specified font patterns before attempting to match the
+available fonts.
+.PP
+.nf
+config : "dir" STRING
+ | "include" STRING
+ | "includeif" STRING
+ | "match" tests "edit" edits
+ ;
+test : qual FIELD-NAME COMPARE CONSTANT
+ ;
+qual : "any"
+ | "all"
+ ;
+edit : FIELD-NAME ASSIGN expr SEMI
+ ;
+.fi
+.PP
+STRINGs are double-quote delimited. FIELD-NAMEs are identifiers,
+ASSIGN is one of "=", "+=" or "=+". expr can contain the usual
+arithmetic operators and can include FIELD-NAMEs.
+.PP
+"dir" adds a directory to the list of places Xft will look for fonts.
+There is no particular order implied by the list; Xft treats all fonts about
+the same.
+.PP
+"include" and "includeif" cause Xft to load more configuration parameters
+from the indicated file. "includeif" doesn't elicit a complaint if the file
+doesn't exist. If the file name begins with a '~' character, it refers to a
+path relative to the home directory of the user.
+.PP
+If the tests in a "match" statement all match a user-specified pattern, the
+pattern will be edited with the specified instructions.
+.PP
+Where ASSIGN is "=", the matching value in the pattern will be replaced by
+the given expression. "+="/"=+" will prepend/append a new value to the list
+of values for the indicated field.
+
+.SH RESTRICTIONS
+.B Xft
+will probably change radically in the future; weak attempts will be made to
+retain some level of source-file compatibility.
+
+.SH AUTHOR
+Keith Packard
diff --git a/nx-X11/lib/Xft1/XftConfig-OBSOLETE b/nx-X11/lib/Xft1/XftConfig-OBSOLETE
new file mode 100644
index 000000000..ec90d1bfe
--- /dev/null
+++ b/nx-X11/lib/Xft1/XftConfig-OBSOLETE
@@ -0,0 +1,2 @@
+The XftConfig file is no longer used by Xft. Please see
+/etc/fonts/fonts.conf to configure client-side fonts.
diff --git a/nx-X11/lib/Xft1/XftFreetype.h b/nx-X11/lib/Xft1/XftFreetype.h
new file mode 100644
index 000000000..07fed47e4
--- /dev/null
+++ b/nx-X11/lib/Xft1/XftFreetype.h
@@ -0,0 +1,167 @@
+/*
+ * $XFree86: xc/lib/Xft1/XftFreetype.h,v 1.3 2002/03/02 22:09:04 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _XFTFREETYPE_H_
+#define _XFTFREETYPE_H_
+
+#include "Xft.h"
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+
+extern FT_Library _XftFTlibrary;
+
+struct _XftFontStruct {
+ FT_Face face; /* handle to face object */
+ GlyphSet glyphset;
+ int min_char;
+ int max_char;
+ FT_F26Dot6 size;
+ int ascent;
+ int descent;
+ int height;
+ int max_advance_width;
+ int spacing;
+ int rgba;
+ Bool antialias;
+ int charmap; /* -1 for unencoded */
+ XRenderPictFormat *format;
+ XGlyphInfo **realized;
+ int nrealized;
+ Bool transform;
+ FT_Matrix matrix;
+};
+
+#define XftUntestedGlyph ((XGlyphInfo *) 1)
+
+_XFUNCPROTOBEGIN
+
+/* xftdir.c */
+Bool
+XftDirScan (XftFontSet *set, const char *dir, Bool force);
+
+Bool
+XftDirSave (XftFontSet *set, const char *dir);
+
+/* xftfreetype.c */
+XftPattern *
+XftFreeTypeQuery (const char *file, int id, int *count);
+
+Bool
+XftFreeTypeSetFace (FT_Face face, FT_F26Dot6 size, int charmap, FT_Matrix *matrix);
+
+XftFontStruct *
+XftFreeTypeOpen (Display *dpy, XftPattern *pattern);
+
+void
+XftFreeTypeClose (Display *dpy, XftFontStruct *font);
+
+XftFontStruct *
+XftFreeTypeGet (XftFont *font);
+
+Bool
+XftInitFtLibrary(void);
+
+/* xftglyphs.c */
+void
+XftGlyphLoad (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 *glyphs,
+ int nglyph);
+
+void
+XftGlyphCheck (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 glyph,
+ XftChar32 *missing,
+ int *nmissing);
+
+Bool
+XftFreeTypeGlyphExists (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 glyph);
+
+/* xftrender.c */
+
+void
+XftRenderString8 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar8 *string, int len);
+
+void
+XftRenderString16 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar16 *string, int len);
+
+void
+XftRenderString32 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar32 *string, int len);
+
+void
+XftRenderStringUtf8 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar8 *string, int len);
+
+void
+XftRenderExtents8 (Display *dpy,
+ XftFontStruct *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftRenderExtents16 (Display *dpy,
+ XftFontStruct *font,
+ XftChar16 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftRenderExtents32 (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftRenderExtentsUtf8 (Display *dpy,
+ XftFontStruct *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+_XFUNCPROTOEND
+
+#endif /* _XFTFREETYPE_H_ */
diff --git a/nx-X11/lib/Xft1/xftcache.c b/nx-X11/lib/Xft1/xftcache.c
new file mode 100644
index 000000000..13e20a92b
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftcache.c
@@ -0,0 +1,608 @@
+/*
+ * $XFree86: xc/lib/Xft/xftcache.c,v 1.2 2001/06/11 22:53:30 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "xftint.h"
+
+typedef struct _XftFileCacheEnt {
+ struct _XftFileCacheEnt *next;
+ unsigned int hash;
+ char *file;
+ int id;
+ time_t time;
+ char *name;
+ Bool referenced;
+} XftFileCacheEnt;
+
+#define HASH_SIZE 509
+
+typedef struct _XftFileCache {
+ XftFileCacheEnt *ents[HASH_SIZE];
+ Bool updated;
+ int entries;
+ int referenced;
+} XftFileCache;
+
+static XftFileCache _XftFileCache;
+
+static unsigned int
+_XftFileCacheHash (char *string)
+{
+ unsigned int h = 0;
+ char c;
+
+ while ((c = *string++))
+ h = (h << 1) ^ c;
+ return h;
+}
+
+char *
+XftFileCacheFind (char *file, int id, int *count)
+{
+ XftFileCache *cache;
+ unsigned int hash;
+ char *match;
+ XftFileCacheEnt *c, *name;
+ int maxid;
+ struct stat statb;
+
+ cache = &_XftFileCache;
+ match = file;
+
+ hash = _XftFileCacheHash (match);
+ name = 0;
+ maxid = -1;
+ for (c = cache->ents[hash % HASH_SIZE]; c; c = c->next)
+ {
+ if (c->hash == hash && !strcmp (match, c->file))
+ {
+ if (c->id > maxid)
+ maxid = c->id;
+ if (c->id == id)
+ {
+ if (stat (file, &statb) < 0)
+ {
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ printf (" file missing\n");
+ return 0;
+ }
+ if (statb.st_mtime != c->time)
+ {
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ printf (" timestamp mismatch (was %d is %d)\n",
+ (int) c->time, (int) statb.st_mtime);
+ return 0;
+ }
+ if (!c->referenced)
+ {
+ cache->referenced++;
+ c->referenced = True;
+ }
+ name = c;
+ }
+ }
+ }
+ if (!name)
+ return 0;
+ *count = maxid + 1;
+ return name->name;
+}
+
+/*
+ * Cache file syntax is quite simple:
+ *
+ * "file_name" id time "font_name" \n
+ */
+
+static Bool
+_XftFileCacheReadString (FILE *f, char *dest, int len)
+{
+ int c;
+ Bool escape;
+
+ while ((c = getc (f)) != EOF)
+ if (c == '"')
+ break;
+ if (c == EOF)
+ return False;
+ if (len == 0)
+ return False;
+
+ escape = False;
+ while ((c = getc (f)) != EOF)
+ {
+ if (!escape)
+ {
+ switch (c) {
+ case '"':
+ *dest++ = '\0';
+ return True;
+ case '\\':
+ escape = True;
+ continue;
+ }
+ }
+ if (--len <= 1)
+ return False;
+ *dest++ = c;
+ escape = False;
+ }
+ return False;
+}
+
+static Bool
+_XftFileCacheReadUlong (FILE *f, unsigned long *dest)
+{
+ unsigned long t;
+ int c;
+
+ while ((c = getc (f)) != EOF)
+ {
+ if (!isspace (c))
+ break;
+ }
+ if (c == EOF)
+ return False;
+ t = 0;
+ for (;;)
+ {
+ if (c == EOF || isspace (c))
+ break;
+ if (!isdigit (c))
+ return False;
+ t = t * 10 + (c - '0');
+ c = getc (f);
+ }
+ *dest = t;
+ return True;
+}
+
+static Bool
+_XftFileCacheReadInt (FILE *f, int *dest)
+{
+ unsigned long t;
+ Bool ret;
+
+ ret = _XftFileCacheReadUlong (f, &t);
+ if (ret)
+ *dest = (int) t;
+ return ret;
+}
+
+static Bool
+_XftFileCacheReadTime (FILE *f, time_t *dest)
+{
+ unsigned long t;
+ Bool ret;
+
+ ret = _XftFileCacheReadUlong (f, &t);
+ if (ret)
+ *dest = (time_t) t;
+ return ret;
+}
+
+static Bool
+_XftFileCacheAdd (XftFileCache *cache,
+ char *file,
+ int id,
+ time_t time,
+ char *name,
+ Bool replace)
+{
+ XftFileCacheEnt *c;
+ XftFileCacheEnt **prev, *old;
+ unsigned int hash;
+
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ {
+ printf ("%s face %s/%d as %s\n", replace ? "Replace" : "Add",
+ file, id, name);
+ }
+ hash = _XftFileCacheHash (file);
+ for (prev = &cache->ents[hash % HASH_SIZE];
+ (old = *prev);
+ prev = &(*prev)->next)
+ {
+ if (old->hash == hash && old->id == id && !strcmp (old->file, file))
+ break;
+ }
+ if (*prev)
+ {
+ if (!replace)
+ return False;
+
+ old = *prev;
+ if (old->referenced)
+ cache->referenced--;
+ *prev = old->next;
+ free (old);
+ cache->entries--;
+ }
+
+ c = malloc (sizeof (XftFileCacheEnt) +
+ strlen (file) + 1 +
+ strlen (name) + 1);
+ if (!c)
+ return False;
+ c->next = *prev;
+ *prev = c;
+ c->hash = hash;
+ c->file = (char *) (c + 1);
+ c->id = id;
+ c->name = c->file + strlen (file) + 1;
+ strcpy (c->file, file);
+ c->time = time;
+ c->referenced = replace;
+ strcpy (c->name, name);
+ cache->entries++;
+ return True;
+}
+
+void
+XftFileCacheDispose (void)
+{
+ XftFileCache *cache;
+ XftFileCacheEnt *c, *next;
+ int h;
+
+ cache = &_XftFileCache;
+
+ for (h = 0; h < HASH_SIZE; h++)
+ {
+ for (c = cache->ents[h]; c; c = next)
+ {
+ next = c->next;
+ free (c);
+ }
+ cache->ents[h] = 0;
+ }
+ cache->entries = 0;
+ cache->referenced = 0;
+ cache->updated = False;
+}
+
+void
+XftFileCacheLoad (char *cache_file)
+{
+ XftFileCache *cache;
+ FILE *f;
+ char file[8192];
+ int id;
+ time_t time;
+ char name[8192];
+
+ f = fopen (cache_file, "r");
+ if (!f)
+ return;
+
+ cache = &_XftFileCache;
+
+ cache->updated = False;
+ while (_XftFileCacheReadString (f, file, sizeof (file)) &&
+ _XftFileCacheReadInt (f, &id) &&
+ _XftFileCacheReadTime (f, &time) &&
+ _XftFileCacheReadString (f, name, sizeof (name)))
+ {
+ (void) _XftFileCacheAdd (cache, file, id, time, name, False);
+ }
+ fclose (f);
+}
+
+Bool
+XftFileCacheUpdate (char *file, int id, char *name)
+{
+ XftFileCache *cache;
+ char *match;
+ struct stat statb;
+ Bool ret;
+
+ cache = &_XftFileCache;
+ match = file;
+
+ if (stat (file, &statb) < 0)
+ return False;
+ ret = _XftFileCacheAdd (cache, match, id,
+ statb.st_mtime, name, True);
+ if (ret)
+ cache->updated = True;
+ return ret;
+}
+
+static Bool
+_XftFileCacheWriteString (FILE *f, char *string)
+{
+ char c;
+
+ if (putc ('"', f) == EOF)
+ return False;
+ while ((c = *string++))
+ {
+ switch (c) {
+ case '"':
+ case '\\':
+ if (putc ('\\', f) == EOF)
+ return False;
+ /* fall through */
+ default:
+ if (putc (c, f) == EOF)
+ return False;
+ }
+ }
+ if (putc ('"', f) == EOF)
+ return False;
+ return True;
+}
+
+static Bool
+_XftFileCacheWriteUlong (FILE *f, unsigned long t)
+{
+ int pow;
+ unsigned long temp, digit;
+
+ temp = t;
+ pow = 1;
+ while (temp >= 10)
+ {
+ temp /= 10;
+ pow *= 10;
+ }
+ temp = t;
+ while (pow)
+ {
+ digit = temp / pow;
+ if (putc ((char) digit + '0', f) == EOF)
+ return False;
+ temp = temp - pow * digit;
+ pow = pow / 10;
+ }
+ return True;
+}
+
+static Bool
+_XftFileCacheWriteInt (FILE *f, int i)
+{
+ return _XftFileCacheWriteUlong (f, (unsigned long) i);
+}
+
+static Bool
+_XftFileCacheWriteTime (FILE *f, time_t t)
+{
+ return _XftFileCacheWriteUlong (f, (unsigned long) t);
+}
+
+Bool
+XftFileCacheSave (char *cache_file)
+{
+ XftFileCache *cache;
+ char *lck;
+ char *tmp;
+ FILE *f;
+ int h;
+ XftFileCacheEnt *c;
+
+ cache = &_XftFileCache;
+
+ if (!cache->updated && cache->referenced == cache->entries)
+ return True;
+
+ lck = malloc (strlen (cache_file)*2 + 4);
+ if (!lck)
+ goto bail0;
+ tmp = lck + strlen (cache_file) + 2;
+ strcpy (lck, cache_file);
+ strcat (lck, "L");
+ strcpy (tmp, cache_file);
+ strcat (tmp, "T");
+ if (link (lck, cache_file) < 0 && errno != ENOENT)
+ goto bail1;
+ if (access (tmp, F_OK) == 0)
+ goto bail2;
+ f = fopen (tmp, "w");
+ if (!f)
+ goto bail2;
+
+ for (h = 0; h < HASH_SIZE; h++)
+ {
+ for (c = cache->ents[h]; c; c = c->next)
+ {
+ if (!c->referenced)
+ continue;
+ if (!_XftFileCacheWriteString (f, c->file))
+ goto bail4;
+ if (putc (' ', f) == EOF)
+ goto bail4;
+ if (!_XftFileCacheWriteInt (f, c->id))
+ goto bail4;
+ if (putc (' ', f) == EOF)
+ goto bail4;
+ if (!_XftFileCacheWriteTime (f, c->time))
+ goto bail4;
+ if (putc (' ', f) == EOF)
+ goto bail4;
+ if (!_XftFileCacheWriteString (f, c->name))
+ goto bail4;
+ if (putc ('\n', f) == EOF)
+ goto bail4;
+ }
+ }
+
+ if (fclose (f) == EOF)
+ goto bail3;
+
+ if (rename (tmp, cache_file) < 0)
+ goto bail3;
+
+ unlink (lck);
+ cache->updated = False;
+ return True;
+
+bail4:
+ fclose (f);
+bail3:
+ unlink (tmp);
+bail2:
+ unlink (lck);
+bail1:
+ free (lck);
+bail0:
+ return False;
+}
+
+Bool
+XftFileCacheReadDir (XftFontSet *set, const char *cache_file)
+{
+ XftPattern *font;
+ FILE *f;
+ char *path;
+ char *base;
+ char file[8192];
+ int id;
+ char name[8192];
+ Bool ret = False;
+
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ {
+ printf ("XftFileCacheReadDir cache_file \"%s\"\n", cache_file);
+ }
+
+ f = fopen (cache_file, "r");
+ if (!f)
+ {
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ {
+ printf (" no cache file\n");
+ }
+ goto bail0;
+ }
+
+ base = strrchr (cache_file, '/');
+ if (!base)
+ goto bail1;
+ base++;
+ path = malloc (base - cache_file + 8192 + 1);
+ if (!path)
+ goto bail1;
+ memcpy (path, cache_file, base - cache_file);
+ base = path + (base - cache_file);
+
+ while (_XftFileCacheReadString (f, file, sizeof (file)) &&
+ _XftFileCacheReadInt (f, &id) &&
+ _XftFileCacheReadString (f, name, sizeof (name)))
+ {
+ font = XftNameParse (name);
+ if (font)
+ {
+ strcpy (base, file);
+ if (_XftFontDebug () & XFT_DBG_CACHEV)
+ {
+ printf (" dir cache file \"%s\"\n", file);
+ }
+ XftPatternAddString (font, XFT_FILE, path);
+ if (!XftFontSetAdd (set, font))
+ goto bail2;
+ }
+ }
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ {
+ printf (" cache loaded\n");
+ }
+
+ ret = True;
+bail2:
+ free (path);
+bail1:
+ fclose (f);
+bail0:
+ return ret;
+}
+
+Bool
+XftFileCacheWriteDir (XftFontSet *set, const char *cache_file)
+{
+ XftPattern *font;
+ FILE *f;
+ char name[8192];
+ char *file, *base;
+ int n;
+ int id;
+
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ printf ("XftFileCacheWriteDir cache_file \"%s\"\n", cache_file);
+
+ f = fopen (cache_file, "w");
+ if (!f)
+ {
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ printf (" can't create \"%s\"\n", cache_file);
+ goto bail0;
+ }
+ for (n = 0; n < set->nfont; n++)
+ {
+ font = set->fonts[n];
+ if (XftPatternGetString (font, XFT_FILE, 0, &file) != XftResultMatch)
+ goto bail1;
+ base = strrchr (file, '/');
+ if (base)
+ base = base + 1;
+ else
+ base = file;
+ if (XftPatternGetInteger (font, XFT_INDEX, 0, &id) != XftResultMatch)
+ goto bail1;
+ if (!XftNameUnparse (font, name, sizeof (name)))
+ goto bail1;
+ if (_XftFontDebug () & XFT_DBG_CACHEV)
+ printf (" write file \"%s\"\n", base);
+ if (!_XftFileCacheWriteString (f, base))
+ goto bail1;
+ if (putc (' ', f) == EOF)
+ goto bail1;
+ if (!_XftFileCacheWriteInt (f, id))
+ goto bail1;
+ if (putc (' ', f) == EOF)
+ goto bail1;
+ if (!_XftFileCacheWriteString (f, name))
+ goto bail1;
+ if (putc ('\n', f) == EOF)
+ goto bail1;
+ }
+ if (fclose (f) == EOF)
+ goto bail0;
+
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ printf (" cache written\n");
+ return True;
+
+bail1:
+ fclose (f);
+bail0:
+ unlink (cache_file);
+ return False;
+}
diff --git a/nx-X11/lib/Xft1/xftcfg.c b/nx-X11/lib/Xft1/xftcfg.c
new file mode 100644
index 000000000..b6e9d3a7c
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftcfg.c
@@ -0,0 +1,36 @@
+/*
+ * $XFree86: xc/lib/Xft/xftcfg.c,v 1.8 2001/01/02 02:46:51 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "xftint.h"
+
+Bool
+XftConfigSubstitute (XftPattern *p)
+{
+ FcConfigSubstitute (0, p, FcMatchPattern);
+ FcConfigSubstitute (0, p, FcMatchFont);
+ return True;
+}
diff --git a/nx-X11/lib/Xft1/xftcolor.c b/nx-X11/lib/Xft1/xftcolor.c
new file mode 100644
index 000000000..9c81f50ca
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftcolor.c
@@ -0,0 +1,125 @@
+/*
+ * $XFree86: xc/lib/Xft/xftcolor.c,v 1.2 2001/05/16 17:20:06 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+Bool
+XftColorAllocName (Display *dpy,
+ Visual *visual,
+ Colormap cmap,
+ char *name,
+ XftColor *result)
+{
+ XColor screen, exact;
+
+ if (!XAllocNamedColor (dpy, cmap, name, &screen, &exact))
+ {
+ /* XXX stick standard colormap stuff here */
+ return False;
+ }
+
+ result->pixel = screen.pixel;
+ result->color.red = exact.red;
+ result->color.green = exact.green;
+ result->color.blue = exact.blue;
+ result->color.alpha = 0xffff;
+ return True;
+}
+
+static short
+maskbase (unsigned long m)
+{
+ short i;
+
+ if (!m)
+ return 0;
+ i = 0;
+ while (!(m&1))
+ {
+ m>>=1;
+ i++;
+ }
+ return i;
+}
+
+static short
+masklen (unsigned long m)
+{
+ unsigned long y;
+
+ y = (m >> 1) &033333333333;
+ y = m - y - ((y >>1) & 033333333333);
+ return (short) (((y + (y >> 3)) & 030707070707) % 077);
+}
+
+Bool
+XftColorAllocValue (Display *dpy,
+ Visual *visual,
+ Colormap cmap,
+ XRenderColor *color,
+ XftColor *result)
+{
+ if (visual->class == TrueColor)
+ {
+ int red_shift, red_len;
+ int green_shift, green_len;
+ int blue_shift, blue_len;
+
+ red_shift = maskbase (visual->red_mask);
+ red_len = masklen (visual->red_mask);
+ green_shift = maskbase (visual->green_mask);
+ green_len = masklen (visual->green_mask);
+ blue_shift = maskbase (visual->blue_mask);
+ blue_len = masklen (visual->blue_mask);
+ result->pixel = (((color->red >> (16 - red_len)) << red_shift) |
+ ((color->green >> (16 - green_len)) << green_shift) |
+ ((color->blue >> (16 - blue_len)) << blue_shift));
+ }
+ else
+ {
+ XColor xcolor;
+
+ xcolor.red = color->red;
+ xcolor.green = color->green;
+ xcolor.blue = color->blue;
+ if (!XAllocColor (dpy, cmap, &xcolor))
+ return False;
+ result->pixel = xcolor.pixel;
+ }
+ result->color.red = color->red;
+ result->color.green = color->green;
+ result->color.blue = color->blue;
+ result->color.alpha = color->alpha;
+ return True;
+}
+
+void
+XftColorFree (Display *dpy,
+ Visual *visual,
+ Colormap cmap,
+ XftColor *color)
+{
+ if (visual->class != TrueColor)
+ XFreeColors (dpy, cmap, &color->pixel, 1, 0);
+}
diff --git a/nx-X11/lib/Xft1/xftcore.c b/nx-X11/lib/Xft1/xftcore.c
new file mode 100644
index 000000000..331cbd7e3
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftcore.c
@@ -0,0 +1,247 @@
+/*
+ * $XFree86: xc/lib/Xft/xftcore.c,v 1.5 2000/12/20 00:28:44 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdlib.h>
+#include "xftint.h"
+
+XChar2b *
+XftCoreConvert16 (XftChar16 *string,
+ int len,
+ XChar2b xcloc[XFT_CORE_N16LOCAL])
+{
+ XChar2b *xc;
+ int i;
+
+ if (len < XFT_CORE_N16LOCAL)
+ xc = xcloc;
+ else
+ xc = (XChar2b *) malloc (len * sizeof (XChar2b));
+ for (i = 0; i < len; i++)
+ {
+ xc[i].byte1 = string[i] & 0xff;
+ xc[i].byte2 = (string[i] >> 8) & 0xff;
+ }
+ return xc;
+}
+
+XChar2b *
+XftCoreConvert32 (XftChar32 *string,
+ int len,
+ XChar2b xcloc[XFT_CORE_N16LOCAL])
+{
+ XChar2b *xc;
+ int i;
+
+ if (len < XFT_CORE_N16LOCAL)
+ xc = xcloc;
+ else
+ xc = (XChar2b *) malloc (len * sizeof (XChar2b));
+ for (i = 0; i < len; i++)
+ {
+ xc[i].byte1 = string[i] & 0xff;
+ xc[i].byte2 = (string[i] >> 8) & 0xff;
+ }
+ return xc;
+}
+
+XChar2b *
+XftCoreConvertUtf8 (XftChar8 *string,
+ int len,
+ XChar2b xcloc[XFT_CORE_N16LOCAL],
+ int *nchar)
+{
+ XChar2b *xc;
+ XftChar32 c;
+ int i;
+ int n, width;
+ int clen;
+
+ if (!XftUtf8Len (string, len, &n, &width))
+ return 0;
+
+ if (n < XFT_CORE_N16LOCAL)
+ xc = xcloc;
+ else
+ xc = (XChar2b *) malloc (n * sizeof (XChar2b));
+ for (i = 0; i < n; i++)
+ {
+ clen = XftUtf8ToUcs4 (string, &c, len);
+ xc[i].byte1 = c & 0xff;
+ xc[i].byte2 = (c >> 8) & 0xff;
+ string += clen;
+ len -= clen;
+ }
+ *nchar = n;
+ return xc;
+}
+
+void
+XftCoreExtents8 (Display *dpy,
+ XFontStruct *fs,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ int direction;
+ int ascent, descent;
+ XCharStruct overall;
+
+ XTextExtents (fs, (char *) string, len, &direction,
+ &ascent, &descent, &overall);
+ if (overall.lbearing < overall.rbearing)
+ {
+ extents->x = overall.lbearing;
+ extents->width = overall.rbearing - overall.lbearing;
+ }
+ else
+ {
+ extents->x = overall.rbearing;
+ extents->width = overall.lbearing - overall.rbearing;
+ }
+ extents->y = -overall.ascent;
+ extents->height = overall.ascent + overall.descent;
+ extents->xOff = overall.width;
+ extents->yOff = 0;
+}
+
+void
+XftCoreExtents16 (Display *dpy,
+ XFontStruct *fs,
+ XftChar16 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ int direction;
+ int ascent, descent;
+ XCharStruct overall;
+ XChar2b *xc, xcloc[XFT_CORE_N16LOCAL];
+
+ xc = XftCoreConvert16 (string, len, xcloc);
+ XTextExtents16 (fs, xc, len, &direction,
+ &ascent, &descent, &overall);
+ if (xc != xcloc)
+ free (xc);
+ if (overall.lbearing < overall.rbearing)
+ {
+ extents->x = overall.lbearing;
+ extents->width = overall.rbearing - overall.lbearing;
+ }
+ else
+ {
+ extents->x = overall.rbearing;
+ extents->width = overall.lbearing - overall.rbearing;
+ }
+ extents->y = -overall.ascent;
+ extents->height = overall.ascent + overall.descent;
+ extents->xOff = overall.width;
+ extents->yOff = 0;
+}
+
+void
+XftCoreExtents32 (Display *dpy,
+ XFontStruct *fs,
+ XftChar32 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ int direction;
+ int ascent, descent;
+ XCharStruct overall;
+ XChar2b *xc, xcloc[XFT_CORE_N16LOCAL];
+
+ xc = XftCoreConvert32 (string, len, xcloc);
+ XTextExtents16 (fs, xc, len, &direction,
+ &ascent, &descent, &overall);
+ if (xc != xcloc)
+ free (xc);
+ if (overall.lbearing < overall.rbearing)
+ {
+ extents->x = overall.lbearing;
+ extents->width = overall.rbearing - overall.lbearing;
+ }
+ else
+ {
+ extents->x = overall.rbearing;
+ extents->width = overall.lbearing - overall.rbearing;
+ }
+ extents->y = -overall.ascent;
+ extents->height = overall.ascent + overall.descent;
+ extents->xOff = overall.width;
+ extents->yOff = 0;
+}
+
+void
+XftCoreExtentsUtf8 (Display *dpy,
+ XFontStruct *fs,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ int direction;
+ int ascent, descent;
+ XCharStruct overall;
+ XChar2b *xc, xcloc[XFT_CORE_N16LOCAL];
+ int n;
+
+ xc = XftCoreConvertUtf8 (string, len, xcloc, &n);
+ XTextExtents16 (fs, xc, n, &direction,
+ &ascent, &descent, &overall);
+ if (xc != xcloc)
+ free (xc);
+ if (overall.lbearing < overall.rbearing)
+ {
+ extents->x = overall.lbearing;
+ extents->width = overall.rbearing - overall.lbearing;
+ }
+ else
+ {
+ extents->x = overall.rbearing;
+ extents->width = overall.lbearing - overall.rbearing;
+ }
+ extents->y = -overall.ascent;
+ extents->height = overall.ascent + overall.descent;
+ extents->xOff = overall.width;
+ extents->yOff = 0;
+}
+
+Bool
+XftCoreGlyphExists (Display *dpy,
+ XFontStruct *fs,
+ XftChar32 glyph)
+{
+ int direction;
+ int ascent, descent;
+ XCharStruct overall;
+ XChar2b xc;
+
+ XftCoreConvert32 (&glyph, 1, &xc);
+ XTextExtents16 (fs, &xc, 1, &direction,
+ &ascent, &descent, &overall);
+ return (overall.lbearing != 0 ||
+ overall.rbearing != 0 ||
+ overall.width != 0 ||
+ overall.ascent != 0 ||
+ overall.descent != 0);
+}
+
diff --git a/nx-X11/lib/Xft1/xftdbg.c b/nx-X11/lib/Xft1/xftdbg.c
new file mode 100644
index 000000000..098fef74b
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftdbg.c
@@ -0,0 +1,43 @@
+/*
+ * $XFree86: xc/lib/Xft/xftdbg.c,v 1.3 2001/03/31 01:57:20 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+void
+XftFontSetPrint (XftFontSet *s)
+{
+ FcFontSetPrint (s);
+}
+
+void
+XftPatternPrint (XftPattern *p)
+{
+ FcPatternPrint (p);
+}
+
+void
+XftValuePrint (XftValue v)
+{
+ FcValuePrint (v);
+}
diff --git a/nx-X11/lib/Xft1/xftdir.c b/nx-X11/lib/Xft1/xftdir.c
new file mode 100644
index 000000000..88d89c902
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftdir.c
@@ -0,0 +1,42 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftdir.c,v 1.2 2002/03/01 01:00:53 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <sys/types.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <string.h>
+#include "xftint.h"
+
+Bool
+XftDirScan (XftFontSet *set, const char *dir, Bool force)
+{
+ return FcFalse;
+}
+
+Bool
+XftDirSave (XftFontSet *set, const char *dir)
+{
+ return FcFalse;
+}
+
diff --git a/nx-X11/lib/Xft1/xftdpy.c b/nx-X11/lib/Xft1/xftdpy.c
new file mode 100644
index 000000000..d28c5c88a
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftdpy.c
@@ -0,0 +1,436 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftdpy.c,v 1.2tsi Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <X11/Xlibint.h>
+#include "xftint.h"
+
+XftDisplayInfo *_XftDisplayInfo;
+
+static int
+_XftCloseDisplay (Display *dpy, XExtCodes *codes)
+{
+ XftDisplayInfo *info, **prev;
+
+ for (prev = &_XftDisplayInfo; (info = *prev); prev = &(*prev)->next)
+ if (info->codes == codes)
+ break;
+ if (!info)
+ return 0;
+ *prev = info->next;
+ if (info->defaults)
+ XftPatternDestroy (info->defaults);
+ if (info->coreFonts)
+ XftFontSetDestroy (info->coreFonts);
+ free (info);
+ return 0;
+}
+
+XftDisplayInfo *
+_XftDisplayInfoGet (Display *dpy)
+{
+ XftDisplayInfo *info, **prev;
+
+ for (prev = &_XftDisplayInfo; (info = *prev); prev = &(*prev)->next)
+ {
+ if (info->display == dpy)
+ {
+ /*
+ * MRU the list
+ */
+ if (prev != &_XftDisplayInfo)
+ {
+ *prev = info->next;
+ info->next = _XftDisplayInfo;
+ _XftDisplayInfo = info;
+ }
+ return info;
+ }
+ }
+ info = (XftDisplayInfo *) malloc (sizeof (XftDisplayInfo));
+ if (!info)
+ goto bail0;
+ info->codes = XAddExtension (dpy);
+ if (!info->codes)
+ goto bail1;
+ (void) XESetCloseDisplay (dpy, info->codes->extension, _XftCloseDisplay);
+
+ info->display = dpy;
+ info->defaults = 0;
+ info->coreFonts = 0;
+ info->hasRender = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, DefaultScreen (dpy))) != 0;
+ info->glyphSets = 0;
+ if (_XftFontDebug () & XFT_DBG_RENDER)
+ {
+ Visual *visual = DefaultVisual (dpy, DefaultScreen (dpy));
+ XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
+
+ printf ("XftDisplayInfoGet Default visual 0x%x ",
+ (int) visual->visualid);
+ if (format)
+ {
+ if (format->type == PictTypeDirect)
+ {
+ printf ("format %d,%d,%d,%d\n",
+ format->direct.alpha,
+ format->direct.red,
+ format->direct.green,
+ format->direct.blue);
+ }
+ else
+ {
+ printf ("format indexed\n");
+ }
+ }
+ else
+ printf ("No Render format for default visual\n");
+
+ printf ("XftDisplayInfoGet initialized, hasRender set to \"%s\"\n",
+ info->hasRender ? "True" : "False");
+ }
+
+ info->next = _XftDisplayInfo;
+ _XftDisplayInfo = info;
+ return info;
+
+bail1:
+ free (info);
+bail0:
+ if (_XftFontDebug () & XFT_DBG_RENDER)
+ {
+ printf ("XftDisplayInfoGet failed to initialize, Xft unhappy\n");
+ }
+ return 0;
+}
+
+Bool
+XftDefaultHasRender (Display *dpy)
+{
+#ifdef FREETYPE2
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
+
+ if (!info)
+ return False;
+ return info->hasRender;
+#else
+ return False;
+#endif
+}
+
+Bool
+XftDefaultSet (Display *dpy, XftPattern *defaults)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
+
+ if (!info)
+ return False;
+ if (info->defaults)
+ XftPatternDestroy (info->defaults);
+ info->defaults = defaults;
+ return True;
+}
+
+int
+XftDefaultParseBool (char *v)
+{
+ char c0, c1;
+
+ c0 = *v;
+ if (isupper (c0))
+ c0 = tolower (c0);
+ if (c0 == 't' || c0 == 'y' || c0 == '1')
+ return 1;
+ if (c0 == 'f' || c0 == 'n' || c0 == '0')
+ return 0;
+ if (c0 == 'o')
+ {
+ c1 = v[1];
+ if (isupper (c1))
+ c1 = tolower (c1);
+ if (c1 == 'n')
+ return 1;
+ if (c1 == 'f')
+ return 0;
+ }
+ return -1;
+}
+
+static Bool
+_XftDefaultInitBool (Display *dpy, XftPattern *pat, char *option)
+{
+ char *v;
+ int i;
+
+ v = XGetDefault (dpy, "Xft", option);
+ if (v && (i = XftDefaultParseBool (v)) >= 0)
+ return XftPatternAddBool (pat, option, i != 0);
+ return True;
+}
+
+static Bool
+_XftDefaultInitDouble (Display *dpy, XftPattern *pat, char *option)
+{
+ char *v, *e;
+ double d;
+
+ v = XGetDefault (dpy, "Xft", option);
+ if (v)
+ {
+ d = strtod (v, &e);
+ if (e != v)
+ return XftPatternAddDouble (pat, option, d);
+ }
+ return True;
+}
+
+static Bool
+_XftDefaultInitInteger (Display *dpy, XftPattern *pat, char *option)
+{
+ char *v, *e;
+ int i;
+
+ v = XGetDefault (dpy, "Xft", option);
+ if (v)
+ {
+ if (XftNameConstant (v, &i))
+ return XftPatternAddInteger (pat, option, i);
+ i = strtol (v, &e, 0);
+ if (e != v)
+ return XftPatternAddInteger (pat, option, i);
+ }
+ return True;
+}
+
+static XftPattern *
+_XftDefaultInit (Display *dpy)
+{
+ XftPattern *pat;
+
+ pat = XftPatternCreate ();
+ if (!pat)
+ goto bail0;
+
+ if (!_XftDefaultInitBool (dpy, pat, XFT_CORE))
+ goto bail1;
+ if (!_XftDefaultInitDouble (dpy, pat, XFT_SCALE))
+ goto bail1;
+ if (!_XftDefaultInitDouble (dpy, pat, XFT_DPI))
+ goto bail1;
+ if (!_XftDefaultInitBool (dpy, pat, XFT_RENDER))
+ goto bail1;
+ if (!_XftDefaultInitInteger (dpy, pat, XFT_RGBA))
+ goto bail1;
+ if (!_XftDefaultInitBool (dpy, pat, XFT_ANTIALIAS))
+ goto bail1;
+ if (!_XftDefaultInitBool (dpy, pat, XFT_MINSPACE))
+ goto bail1;
+
+ return pat;
+
+bail1:
+ XftPatternDestroy (pat);
+bail0:
+ return 0;
+}
+
+static XftResult
+_XftDefaultGet (Display *dpy, const char *object, int screen, XftValue *v)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
+ XftResult r;
+
+ if (!info)
+ return XftResultNoMatch;
+
+ if (!info->defaults)
+ {
+ info->defaults = _XftDefaultInit (dpy);
+ if (!info->defaults)
+ return XftResultNoMatch;
+ }
+ r = XftPatternGet (info->defaults, object, screen, v);
+ if (r == XftResultNoId && screen > 0)
+ r = XftPatternGet (info->defaults, object, 0, v);
+ return r;
+}
+
+Bool
+XftDefaultGetBool (Display *dpy, const char *object, int screen, Bool def)
+{
+ XftResult r;
+ XftValue v;
+
+ r = _XftDefaultGet (dpy, object, screen, &v);
+ if (r != XftResultMatch || v.type != XftTypeBool)
+ return def;
+ return v.u.b;
+}
+
+int
+XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def)
+{
+ XftResult r;
+ XftValue v;
+
+ r = _XftDefaultGet (dpy, object, screen, &v);
+ if (r != XftResultMatch || v.type != XftTypeInteger)
+ return def;
+ return v.u.i;
+}
+
+double
+XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def)
+{
+ XftResult r;
+ XftValue v;
+
+ r = _XftDefaultGet (dpy, object, screen, &v);
+ if (r != XftResultMatch || v.type != XftTypeDouble)
+ return def;
+ return v.u.d;
+}
+
+XftFontSet *
+XftDisplayGetFontSet (Display *dpy)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
+
+ if (!info)
+ return 0;
+ if (!info->coreFonts)
+ {
+ info->coreFonts = XftFontSetCreate ();
+ if (info->coreFonts)
+ {
+ if (!XftCoreAddFonts (info->coreFonts, dpy,
+ XftDefaultGetBool (dpy, XFT_SCALABLE,
+ DefaultScreen (dpy),
+ False)))
+ {
+ XftFontSetDestroy (info->coreFonts);
+ info->coreFonts = 0;
+ }
+ }
+ }
+ return info->coreFonts;
+}
+
+void
+XftDefaultSubstitute (Display *dpy, int screen, XftPattern *pattern)
+{
+ XftValue v;
+ double size;
+ double scale;
+
+ if (XftPatternGet (pattern, XFT_STYLE, 0, &v) == XftResultNoMatch)
+ {
+ if (XftPatternGet (pattern, XFT_WEIGHT, 0, &v) == XftResultNoMatch )
+ {
+ XftPatternAddInteger (pattern, XFT_WEIGHT, XFT_WEIGHT_MEDIUM);
+ }
+ if (XftPatternGet (pattern, XFT_SLANT, 0, &v) == XftResultNoMatch)
+ {
+ XftPatternAddInteger (pattern, XFT_SLANT, XFT_SLANT_ROMAN);
+ }
+ }
+ if (XftPatternGet (pattern, XFT_ENCODING, 0, &v) == XftResultNoMatch)
+ XftPatternAddString (pattern, XFT_ENCODING, "iso8859-1");
+ if (XftPatternGet (pattern, XFT_RENDER, 0, &v) == XftResultNoMatch)
+ {
+ XftPatternAddBool (pattern, XFT_RENDER,
+ XftDefaultGetBool (dpy, XFT_RENDER, screen,
+ XftDefaultHasRender (dpy)));
+ }
+ if (XftPatternGet (pattern, XFT_CORE, 0, &v) == XftResultNoMatch)
+ {
+ XftPatternAddBool (pattern, XFT_CORE,
+ XftDefaultGetBool (dpy, XFT_CORE, screen,
+ !XftDefaultHasRender (dpy)));
+ }
+ if (XftPatternGet (pattern, XFT_ANTIALIAS, 0, &v) == XftResultNoMatch)
+ {
+ XftPatternAddBool (pattern, XFT_ANTIALIAS,
+ XftDefaultGetBool (dpy, XFT_ANTIALIAS, screen,
+ True));
+ }
+ if (XftPatternGet (pattern, XFT_RGBA, 0, &v) == XftResultNoMatch)
+ {
+ int subpixel = XFT_RGBA_NONE;
+#if RENDER_MAJOR > 0 || RENDER_MINOR >= 6
+ int render_order = XRenderQuerySubpixelOrder (dpy, screen);
+ switch (render_order) {
+ default:
+ case SubPixelUnknown: subpixel = XFT_RGBA_NONE; break;
+ case SubPixelHorizontalRGB: subpixel = XFT_RGBA_RGB; break;
+ case SubPixelHorizontalBGR: subpixel = XFT_RGBA_BGR; break;
+ case SubPixelVerticalRGB: subpixel = XFT_RGBA_VRGB; break;
+ case SubPixelVerticalBGR: subpixel = XFT_RGBA_VBGR; break;
+ case SubPixelNone: subpixel = XFT_RGBA_NONE; break;
+ }
+#endif
+ XftPatternAddInteger (pattern, XFT_RGBA,
+ XftDefaultGetInteger (dpy, XFT_RGBA, screen,
+ subpixel));
+ }
+ if (XftPatternGet (pattern, XFT_MINSPACE, 0, &v) == XftResultNoMatch)
+ {
+ XftPatternAddBool (pattern, XFT_MINSPACE,
+ XftDefaultGetBool (dpy, XFT_MINSPACE, screen,
+ False));
+ }
+ if (XftPatternGet (pattern, XFT_PIXEL_SIZE, 0, &v) == XftResultNoMatch)
+ {
+ double pixels, mm, dpi;
+
+ if (XftPatternGet (pattern, XFT_SIZE, 0, &v) != XftResultMatch)
+ {
+ size = 12.0;
+ XftPatternAddDouble (pattern, XFT_SIZE, size);
+ }
+ else
+ {
+ switch (v.type) {
+ case XftTypeInteger:
+ size = (double) v.u.i;
+ break;
+ case XftTypeDouble:
+ size = v.u.d;
+ break;
+ default:
+ size = 12.0;
+ break;
+ }
+ }
+ scale = XftDefaultGetDouble (dpy, XFT_SCALE, screen, 1.0);
+ size *= scale;
+ pixels = DisplayHeight (dpy, screen);
+ mm = DisplayHeightMM (dpy, screen);
+ dpi = (pixels * 25.4) / mm;
+ dpi = XftDefaultGetDouble (dpy, XFT_DPI, screen, dpi);
+ size = size * dpi / 72.0;
+ XftPatternAddDouble (pattern, XFT_PIXEL_SIZE, size);
+ }
+}
diff --git a/nx-X11/lib/Xft1/xftdraw.c b/nx-X11/lib/Xft1/xftdraw.c
new file mode 100644
index 000000000..f9c3b8b79
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftdraw.c
@@ -0,0 +1,482 @@
+/*
+ * $XFree86: xc/lib/Xft/xftdraw.c,v 1.15 2001/05/16 19:20:43 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "xftint.h"
+#include <X11/Xutil.h>
+
+XftDraw *
+XftDrawCreate (Display *dpy,
+ Drawable drawable,
+ Visual *visual,
+ Colormap colormap)
+{
+ XftDraw *draw;
+
+ draw = (XftDraw *) malloc (sizeof (XftDraw));
+ if (!draw)
+ return 0;
+ draw->dpy = dpy;
+ draw->drawable = drawable;
+ draw->visual = visual;
+ draw->colormap = colormap;
+ draw->core_set = False;
+ draw->render_set = False;
+ draw->render_able = False;
+ draw->clip = 0;
+ return draw;
+}
+
+XftDraw *
+XftDrawCreateBitmap (Display *dpy,
+ Pixmap bitmap)
+{
+ XftDraw *draw;
+
+ draw = (XftDraw *) malloc (sizeof (XftDraw));
+ if (!draw)
+ return 0;
+ draw->dpy = dpy;
+ draw->drawable = (Drawable) bitmap;
+ draw->visual = 0;
+ draw->colormap = 0;
+ draw->core_set = False;
+ draw->render_set = False;
+ draw->render_able = False;
+ draw->clip = 0;
+ return draw;
+}
+
+static XRenderPictFormat *
+_XftDrawFormat (XftDraw *draw)
+{
+ if (draw->visual == 0)
+ {
+ XRenderPictFormat pf;
+
+ pf.type = PictTypeDirect;
+ pf.depth = 1;
+ pf.direct.alpha = 0;
+ pf.direct.alphaMask = 1;
+ return XRenderFindFormat (draw->dpy,
+ (PictFormatType|
+ PictFormatDepth|
+ PictFormatAlpha|
+ PictFormatAlphaMask),
+ &pf,
+ 0);
+ }
+ else
+ return XRenderFindVisualFormat (draw->dpy, draw->visual);
+}
+
+static XRenderPictFormat *
+_XftDrawFgFormat (XftDraw *draw)
+{
+ XRenderPictFormat pf;
+
+ if (draw->visual == 0)
+ {
+ pf.type = PictTypeDirect;
+ pf.depth = 1;
+ pf.direct.alpha = 0;
+ pf.direct.alphaMask = 1;
+ return XRenderFindFormat (draw->dpy,
+ (PictFormatType|
+ PictFormatDepth|
+ PictFormatAlpha|
+ PictFormatAlphaMask),
+ &pf,
+ 0);
+ }
+ else
+ {
+ pf.type = PictTypeDirect;
+ pf.depth = 32;
+ pf.direct.redMask = 0xff;
+ pf.direct.greenMask = 0xff;
+ pf.direct.blueMask = 0xff;
+ pf.direct.alphaMask = 0xff;
+ return XRenderFindFormat (draw->dpy,
+ (PictFormatType|
+ PictFormatDepth|
+ PictFormatRedMask|
+ PictFormatGreenMask|
+ PictFormatBlueMask|
+ PictFormatAlphaMask),
+ &pf,
+ 0);
+ }
+}
+
+void
+XftDrawChange (XftDraw *draw,
+ Drawable drawable)
+{
+ draw->drawable = drawable;
+ if (draw->render_able)
+ {
+ XRenderPictFormat *format;
+
+ XRenderFreePicture (draw->dpy, draw->render.pict);
+ format = XRenderFindVisualFormat (draw->dpy, draw->visual);
+ draw->render.pict = XRenderCreatePicture (draw->dpy, draw->drawable,
+ format, 0, 0);
+ }
+}
+
+void
+XftDrawDestroy (XftDraw *draw)
+{
+ int n;
+
+ if (draw->render_able)
+ {
+ XRenderFreePicture (draw->dpy, draw->render.pict);
+ for (n = 0; n < XFT_DRAW_N_SRC; n++)
+ XRenderFreePicture (draw->dpy, draw->render.src[n].pict);
+ }
+ if (draw->core_set)
+ XFreeGC (draw->dpy, draw->core.draw_gc);
+ if (draw->clip)
+ XDestroyRegion (draw->clip);
+ free (draw);
+}
+
+Bool
+XftDrawRenderPrepare (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int src)
+{
+ if (!draw->render_set)
+ {
+ XRenderPictFormat *format;
+ XRenderPictFormat *pix_format;
+ XRenderPictureAttributes pa;
+ int n;
+ Pixmap pix;
+
+ draw->render_set = True;
+ draw->render_able = False;
+ format = _XftDrawFormat (draw);
+ pix_format = _XftDrawFgFormat (draw);
+ if (format && pix_format)
+ {
+ draw->render_able = True;
+
+ draw->render.pict = XRenderCreatePicture (draw->dpy, draw->drawable,
+ format, 0, 0);
+ for (n = 0; n < XFT_DRAW_N_SRC; n++)
+ {
+ pix = XCreatePixmap (draw->dpy, draw->drawable,
+ 1, 1, pix_format->depth);
+ pa.repeat = True;
+ draw->render.src[n].pict = XRenderCreatePicture (draw->dpy,
+ pix,
+ pix_format,
+ CPRepeat, &pa);
+ XFreePixmap (draw->dpy, pix);
+
+ draw->render.src[n].color = color->color;
+ XRenderFillRectangle (draw->dpy, PictOpSrc,
+ draw->render.src[n].pict,
+ &color->color, 0, 0, 1, 1);
+ }
+ if (draw->clip)
+ XRenderSetPictureClipRegion (draw->dpy, draw->render.pict,
+ draw->clip);
+ }
+ }
+ if (!draw->render_able)
+ return False;
+ if (memcmp (&color->color, &draw->render.src[src].color,
+ sizeof (XRenderColor)))
+ {
+ if (_XftFontDebug () & XFT_DBG_DRAW)
+ {
+ printf ("Switching to color %04x,%04x,%04x,%04x\n",
+ color->color.alpha,
+ color->color.red,
+ color->color.green,
+ color->color.blue);
+ }
+ XRenderFillRectangle (draw->dpy, PictOpSrc,
+ draw->render.src[src].pict,
+ &color->color, 0, 0, 1, 1);
+ draw->render.src[src].color = color->color;
+ }
+ return True;
+}
+
+Bool
+XftDrawCorePrepare (XftDraw *draw,
+ XftColor *color,
+ XftFont *font)
+{
+
+ if (!draw->core_set)
+ {
+ XGCValues gcv;
+ unsigned long mask;
+ draw->core_set = True;
+
+ draw->core.fg = color->pixel;
+ gcv.foreground = draw->core.fg;
+ mask = GCForeground;
+ if (font)
+ {
+ draw->core.font = font->u.core.font->fid;
+ gcv.font = draw->core.font;
+ mask |= GCFont;
+ }
+ draw->core.draw_gc = XCreateGC (draw->dpy, draw->drawable,
+ mask, &gcv);
+ if (draw->clip)
+ XSetRegion (draw->dpy, draw->core.draw_gc, draw->clip);
+ }
+ if (draw->core.fg != color->pixel)
+ {
+ draw->core.fg = color->pixel;
+ XSetForeground (draw->dpy, draw->core.draw_gc, draw->core.fg);
+ }
+ if (font && draw->core.font != font->u.core.font->fid)
+ {
+ draw->core.font = font->u.core.font->fid;
+ XSetFont (draw->dpy, draw->core.draw_gc, draw->core.font);
+ }
+ return True;
+}
+
+void
+XftDrawString8 (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar8 *string,
+ int len)
+{
+ if (_XftFontDebug () & XFT_DBG_DRAW)
+ {
+ printf ("DrawString \"%*.*s\"\n", len, len, string);
+ }
+ if (font->core)
+ {
+ XftDrawCorePrepare (draw, color, font);
+ XDrawString (draw->dpy, draw->drawable, draw->core.draw_gc, x, y,
+ (char *) string, len);
+ }
+#ifdef FREETYPE2
+ else if (XftDrawRenderPrepare (draw, color, font, XFT_DRAW_SRC_TEXT))
+ {
+ XftRenderString8 (draw->dpy,
+ draw->render.src[XFT_DRAW_SRC_TEXT].pict,
+ font->u.ft.font,
+ draw->render.pict, 0, 0, x, y, string, len);
+ }
+#endif
+}
+
+#define N16LOCAL 256
+
+void
+XftDrawString16 (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar16 *string,
+ int len)
+{
+ if (font->core)
+ {
+ XChar2b *xc;
+ XChar2b xcloc[XFT_CORE_N16LOCAL];
+
+ XftDrawCorePrepare (draw, color, font);
+ xc = XftCoreConvert16 (string, len, xcloc);
+ XDrawString16 (draw->dpy, draw->drawable, draw->core.draw_gc, x, y,
+ xc, len);
+ if (xc != xcloc)
+ free (xc);
+ }
+#ifdef FREETYPE2
+ else if (XftDrawRenderPrepare (draw, color, font, XFT_DRAW_SRC_TEXT))
+ {
+ XftRenderString16 (draw->dpy,
+ draw->render.src[XFT_DRAW_SRC_TEXT].pict,
+ font->u.ft.font,
+ draw->render.pict, 0, 0, x, y, string, len);
+ }
+#endif
+}
+
+void
+XftDrawString32 (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar32 *string,
+ int len)
+{
+ if (font->core)
+ {
+ XChar2b *xc;
+ XChar2b xcloc[XFT_CORE_N16LOCAL];
+
+ XftDrawCorePrepare (draw, color, font);
+ xc = XftCoreConvert32 (string, len, xcloc);
+ XDrawString16 (draw->dpy, draw->drawable, draw->core.draw_gc, x, y,
+ xc, len);
+ if (xc != xcloc)
+ free (xc);
+ }
+#ifdef FREETYPE2
+ else if (XftDrawRenderPrepare (draw, color, font, XFT_DRAW_SRC_TEXT))
+ {
+ XftRenderString32 (draw->dpy,
+ draw->render.src[XFT_DRAW_SRC_TEXT].pict,
+ font->u.ft.font,
+ draw->render.pict, 0, 0, x, y, string, len);
+ }
+#endif
+}
+
+void
+XftDrawStringUtf8 (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar8 *string,
+ int len)
+{
+ if (font->core)
+ {
+ XChar2b *xc;
+ XChar2b xcloc[XFT_CORE_N16LOCAL];
+ int n;
+
+ XftDrawCorePrepare (draw, color, font);
+ xc = XftCoreConvertUtf8 (string, len, xcloc, &n);
+ if (xc)
+ {
+ XDrawString16 (draw->dpy, draw->drawable, draw->core.draw_gc, x, y,
+ xc, n);
+ }
+ if (xc != xcloc)
+ free (xc);
+ }
+#ifdef FREETYPE2
+ else if (XftDrawRenderPrepare (draw, color, font, XFT_DRAW_SRC_TEXT))
+ {
+ XftRenderStringUtf8 (draw->dpy,
+ draw->render.src[XFT_DRAW_SRC_TEXT].pict,
+ font->u.ft.font,
+ draw->render.pict, 0, 0, x, y, string, len);
+ }
+#endif
+}
+
+
+void
+XftDrawRect (XftDraw *draw,
+ XftColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height)
+{
+ if (XftDrawRenderPrepare (draw, color, 0, XFT_DRAW_SRC_RECT))
+ {
+ XRenderFillRectangle (draw->dpy, PictOpOver, draw->render.pict,
+ &color->color, x, y, width, height);
+ }
+ else
+ {
+ XftDrawCorePrepare (draw, color, 0);
+ XFillRectangle (draw->dpy, draw->drawable, draw->core.draw_gc,
+ x, y, width, height);
+ }
+}
+
+Bool
+XftDrawSetClip (XftDraw *draw,
+ Region r)
+{
+ Region n = 0;
+
+ if (!r && !draw->clip)
+ return True;
+
+ if (r)
+ {
+ n = XCreateRegion ();
+ if (n)
+ {
+ if (!XUnionRegion (n, r, n))
+ {
+ XDestroyRegion (n);
+ return False;
+ }
+ }
+ }
+ if (draw->clip)
+ {
+ XDestroyRegion (draw->clip);
+ }
+ draw->clip = n;
+ if (draw->render_able)
+ {
+ XRenderPictureAttributes pa;
+ if (n)
+ {
+ XRenderSetPictureClipRegion (draw->dpy, draw->render.pict, n);
+ }
+ else
+ {
+ pa.clip_mask = None;
+ XRenderChangePicture (draw->dpy, draw->render.pict,
+ CPClipMask, &pa);
+ }
+ }
+ if (draw->core_set)
+ {
+ XGCValues gv;
+
+ if (n)
+ XSetRegion (draw->dpy, draw->core.draw_gc, n);
+ else
+ {
+ gv.clip_mask = None;
+ XChangeGC (draw->dpy, draw->core.draw_gc,
+ GCClipMask, &gv);
+ }
+ }
+ return True;
+}
diff --git a/nx-X11/lib/Xft1/xftextent.c b/nx-X11/lib/Xft1/xftextent.c
new file mode 100644
index 000000000..8a6cf620a
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftextent.c
@@ -0,0 +1,190 @@
+/*
+ * $XFree86: xc/lib/Xft/xftextent.c,v 1.6 2001/04/01 14:00:01 tsi Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdlib.h>
+#include <string.h>
+#include "xftint.h"
+
+void
+XftTextExtents8 (Display *dpy,
+ XftFont *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ if (font->core)
+ {
+ XftCoreExtents8 (dpy, font->u.core.font, string, len, extents);
+ }
+#ifdef FREETYPE2
+ else
+ {
+ XftRenderExtents8 (dpy, font->u.ft.font, string, len, extents);
+ }
+#endif
+}
+
+void
+XftTextExtents16 (Display *dpy,
+ XftFont *font,
+ XftChar16 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ if (font->core)
+ {
+ XftCoreExtents16 (dpy, font->u.core.font, string, len, extents);
+ }
+#ifdef FREETYPE2
+ else
+ {
+ XftRenderExtents16 (dpy, font->u.ft.font, string, len, extents);
+ }
+#endif
+}
+
+void
+XftTextExtents32 (Display *dpy,
+ XftFont *font,
+ XftChar32 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ if (font->core)
+ {
+ XftCoreExtents32 (dpy, font->u.core.font, string, len, extents);
+ }
+#ifdef FREETYPE2
+ else
+ {
+ XftRenderExtents32 (dpy, font->u.ft.font, string, len, extents);
+ }
+#endif
+}
+
+void
+XftTextExtentsUtf8 (Display *dpy,
+ XftFont *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ XftChar8 *src;
+ XftChar32 c;
+ XftChar32 lbuf[4096];
+ XftChar32 *dst;
+ XftChar8 *dst8;
+ XftChar16 *dst16;
+ XftChar32 *dst32;
+ int rlen, clen;
+ int width = 1;
+ int n;
+
+ /* compute needed width */
+ src = string;
+ rlen = len;
+ n = 0;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (src, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ {
+ memset (extents, 0, sizeof (XGlyphInfo));
+ return;
+ }
+ if (c >= 0x10000)
+ width = 4;
+ else if (c >= 0x100)
+ {
+ if (width == 1)
+ width = 2;
+ }
+ src += clen;
+ rlen -= clen;
+ n++;
+ }
+ dst = lbuf;
+ if (n * width > sizeof (lbuf))
+ {
+ dst = (XftChar32 *) malloc (n * width);
+ if (!dst)
+ {
+ memset (extents, 0, sizeof (XGlyphInfo));
+ return;
+ }
+ }
+
+ switch (width) {
+ case 4:
+ src = string;
+ rlen = len;
+ dst32 = dst;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (src, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ return;
+ *dst32++ = c;
+ src += clen;
+ rlen -= clen;
+ }
+ dst32 = dst;
+ XftTextExtents32 (dpy, font, dst32, n, extents);
+ break;
+ case 2:
+ src = string;
+ rlen = len;
+ dst16 = (XftChar16 *) dst;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (src, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ return;
+ *dst16++ = c;
+ src += clen;
+ rlen -= clen;
+ }
+ dst16 = (XftChar16 *) dst;
+ XftTextExtents16 (dpy, font, dst16, n, extents);
+ break;
+ case 1:
+ src = string;
+ rlen = len;
+ dst8 = (XftChar8 *) dst;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (src, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ return;
+ *dst8++ = c;
+ src += clen;
+ rlen -= clen;
+ }
+ dst8 = (XftChar8 *) dst;
+ XftTextExtents8 (dpy, font, dst8, n, extents);
+ break;
+ }
+ if (dst != lbuf)
+ free (dst);
+}
diff --git a/nx-X11/lib/Xft1/xftfont.c b/nx-X11/lib/Xft1/xftfont.c
new file mode 100644
index 000000000..ab393af81
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftfont.c
@@ -0,0 +1,327 @@
+/*
+ * $XFree86: xc/lib/Xft/xftfont.c,v 1.8 2000/12/20 00:20:48 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdio.h>
+#include <stdlib.h>
+#include "xftint.h"
+
+XftPattern *
+XftFontMatch (Display *dpy, int screen, XftPattern *pattern, XftResult *result)
+{
+ XftPattern *new;
+ XftPattern *match;
+ XftFontSet *sets[2];
+ int nsets;
+#ifdef FREETYPE2
+ Bool render, core;
+#endif
+
+ if (!XftInit (0))
+ return 0;
+
+ new = XftPatternDuplicate (pattern);
+ if (!new)
+ return 0;
+
+ if (_XftFontDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch pattern ");
+ XftPatternPrint (new);
+ }
+ XftConfigSubstitute (new);
+ if (_XftFontDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch after XftConfig substitutions ");
+ XftPatternPrint (new);
+ }
+ XftDefaultSubstitute (dpy, screen, new);
+ if (_XftFontDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch after X resource substitutions ");
+ XftPatternPrint (new);
+ }
+ nsets = 0;
+
+#ifdef FREETYPE2
+ render = False;
+ core = True;
+ (void) XftPatternGetBool (new, XFT_RENDER, 0, &render);
+ (void) XftPatternGetBool (new, XFT_CORE, 0, &core);
+ if (_XftFontDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch: use core fonts \"%s\", use render fonts \"%s\"\n",
+ core ? "True" : "False", render ? "True" : "False");
+ }
+
+ if (render)
+ {
+ if (XftInitFtLibrary())
+ {
+ sets[nsets] = _XftFontSet;
+ if (sets[nsets])
+ nsets++;
+ }
+ }
+ if (core)
+#endif
+ {
+ sets[nsets] = XftDisplayGetFontSet (dpy);
+ if (sets[nsets])
+ nsets++;
+ }
+
+ match = XftFontSetMatch (sets, nsets, new, result);
+ XftPatternDestroy (new);
+ return match;
+}
+
+XftFont *
+XftFontOpenPattern (Display *dpy, XftPattern *pattern)
+{
+ Bool core = True;
+ XFontStruct *xfs = 0;
+ XftFont *font;
+#ifdef FREETYPE2
+ XftFontStruct *fs = 0;
+
+ if (XftPatternGetBool (pattern, XFT_CORE, 0, &core) != XftResultMatch)
+ return 0;
+ if (core)
+#endif
+ {
+ xfs = XftCoreOpen (dpy, pattern);
+ if (!xfs) return 0;
+ }
+#ifdef FREETYPE2
+ else
+ {
+ fs = XftFreeTypeOpen (dpy, pattern);
+ if (!fs) return 0;
+ }
+#endif
+ font = (XftFont *) malloc (sizeof (XftFont));
+ font->core = core;
+ font->pattern = pattern;
+#ifdef FREETYPE2
+ if (core)
+#endif
+ {
+ font->u.core.font = xfs;
+ font->ascent = xfs->ascent;
+ font->descent = xfs->descent;
+ font->height = xfs->ascent + xfs->descent;
+ font->max_advance_width = xfs->max_bounds.width;
+ }
+#ifdef FREETYPE2
+ else
+ {
+ font->u.ft.font = fs;
+ font->ascent = fs->ascent;
+ font->descent = fs->descent;
+ font->height = fs->height;
+ font->max_advance_width = fs->max_advance_width;
+ }
+#endif
+ return font;
+}
+
+int
+_XftFontDebug (void)
+{
+ static int initialized;
+ static int debug;
+
+ if (!initialized)
+ {
+ char *e;
+
+ initialized = 1;
+ e = getenv ("XFT_DEBUG");
+ if (e)
+ {
+ printf ("XFT_DEBUG=%s\n", e);
+ debug = atoi (e);
+ if (debug <= 0)
+ debug = 1;
+ }
+ }
+ return debug;
+}
+
+XftFont *
+XftFontOpen (Display *dpy, int screen, ...)
+{
+ va_list va;
+ XftPattern *pat;
+ XftPattern *match;
+ XftResult result;
+ XftFont *font;
+
+ va_start (va, screen);
+ pat = XftPatternVaBuild (0, va);
+ va_end (va);
+ if (!pat)
+ {
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ printf ("XftFontOpen: Invalid pattern argument\n");
+ return 0;
+ }
+ match = XftFontMatch (dpy, screen, pat, &result);
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ {
+ printf ("Pattern ");
+ XftPatternPrint (pat);
+ if (match)
+ {
+ printf ("Match ");
+ XftPatternPrint (match);
+ }
+ else
+ printf ("No Match\n");
+ }
+ XftPatternDestroy (pat);
+ if (!match)
+ return 0;
+
+ font = XftFontOpenPattern (dpy, match);
+ if (!font)
+ {
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ printf ("No Font\n");
+ XftPatternDestroy (match);
+ }
+
+ return font;
+}
+
+XftFont *
+XftFontOpenName (Display *dpy, int screen, const char *name)
+{
+ XftPattern *pat;
+ XftPattern *match;
+ XftResult result;
+ XftFont *font;
+
+ pat = XftNameParse (name);
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ {
+ printf ("XftFontOpenName \"%s\": ", name);
+ if (pat)
+ XftPatternPrint (pat);
+ else
+ printf ("Invalid name\n");
+ }
+
+ if (!pat)
+ return 0;
+ match = XftFontMatch (dpy, screen, pat, &result);
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ {
+ if (match)
+ {
+ printf ("Match ");
+ XftPatternPrint (match);
+ }
+ else
+ printf ("No Match\n");
+ }
+ XftPatternDestroy (pat);
+ if (!match)
+ return 0;
+
+ font = XftFontOpenPattern (dpy, match);
+ if (!font)
+ XftPatternDestroy (match);
+
+ return font;
+}
+
+XftFont *
+XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd)
+{
+ XftPattern *pat;
+ XftPattern *match;
+ XftResult result;
+ XftFont *font;
+
+ pat = XftXlfdParse (xlfd, False, False);
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ {
+ printf ("XftFontOpenXlfd \"%s\": ", xlfd);
+ if (pat)
+ printf ("Invalid xlfd\n");
+ else
+ XftPatternPrint (pat);
+ }
+
+ if (!pat)
+ return 0;
+ match = XftFontMatch (dpy, screen, pat, &result);
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ {
+ if (match)
+ {
+ printf ("Match ");
+ XftPatternPrint (match);
+ }
+ else
+ printf ("No Match\n");
+ }
+ XftPatternDestroy (pat);
+ if (!match)
+ return 0;
+
+ font = XftFontOpenPattern (dpy, match);
+ if (!font)
+ XftPatternDestroy (match);
+
+ return font;
+}
+
+void
+XftFontClose (Display *dpy, XftFont *font)
+{
+ if (font->core)
+ XftCoreClose (dpy, font->u.core.font);
+#ifdef FREETYPE2
+ else
+ XftFreeTypeClose (dpy, font->u.ft.font);
+#endif
+ if (font->pattern)
+ XftPatternDestroy (font->pattern);
+ free (font);
+}
+
+Bool
+XftGlyphExists (Display *dpy, XftFont *font, XftChar32 glyph)
+{
+ if (font->core)
+ return XftCoreGlyphExists (dpy, font->u.core.font, glyph);
+ else
+#ifdef FREETYPE2
+ return XftFreeTypeGlyphExists (dpy, font->u.ft.font, glyph);
+#else
+ return False;
+#endif
+}
diff --git a/nx-X11/lib/Xft1/xftfreetype.c b/nx-X11/lib/Xft1/xftfreetype.c
new file mode 100644
index 000000000..1021c95bf
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftfreetype.c
@@ -0,0 +1,678 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftfreetype.c,v 1.5 2002/08/12 22:17:49 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "xftint.h"
+
+FT_Library _XftFTlibrary;
+
+typedef struct _XftFtEncoding {
+ const char *name;
+ FT_Encoding encoding;
+} XftFtEncoding;
+
+static XftFtEncoding xftFtEncoding[] = {
+ { "iso10646-1", ft_encoding_unicode, },
+ { "iso8859-1", ft_encoding_unicode, },
+ { "apple-roman", ft_encoding_apple_roman },
+ { "adobe-fontspecific", ft_encoding_symbol, },
+ { "glyphs-fontspecific",ft_encoding_none, },
+};
+
+#define NUM_FT_ENCODINGS (sizeof xftFtEncoding / sizeof xftFtEncoding[0])
+
+#define FT_Matrix_Equal(a,b) ((a)->xx == (b)->xx && \
+ (a)->yy == (b)->yy && \
+ (a)->xy == (b)->xy && \
+ (a)->yx == (b)->yx)
+
+XftPattern *
+XftFreeTypeQuery (const char *file, int id, int *count)
+{
+ FT_Face face;
+ XftPattern *pat;
+ int slant;
+ int weight;
+ int i, j;
+
+ if (FT_New_Face (_XftFTlibrary, file, id, &face))
+ return 0;
+
+ *count = face->num_faces;
+
+ pat = XftPatternCreate ();
+ if (!pat)
+ goto bail0;
+
+
+ if (!XftPatternAddBool (pat, XFT_CORE, False))
+ goto bail1;
+
+ if (!XftPatternAddBool (pat, XFT_OUTLINE,
+ (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
+ goto bail1;
+
+ if (!XftPatternAddBool (pat, XFT_SCALABLE,
+ (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
+ goto bail1;
+
+
+ slant = XFT_SLANT_ROMAN;
+ if (face->style_flags & FT_STYLE_FLAG_ITALIC)
+ slant = XFT_SLANT_ITALIC;
+
+ if (!XftPatternAddInteger (pat, XFT_SLANT, slant))
+ goto bail1;
+
+ weight = XFT_WEIGHT_MEDIUM;
+ if (face->style_flags & FT_STYLE_FLAG_BOLD)
+ weight = XFT_WEIGHT_BOLD;
+
+ if (!XftPatternAddInteger (pat, XFT_WEIGHT, weight))
+ goto bail1;
+
+ if (!XftPatternAddString (pat, XFT_FAMILY, face->family_name))
+ goto bail1;
+
+ if (!XftPatternAddString (pat, XFT_STYLE, face->style_name))
+ goto bail1;
+
+ if (!XftPatternAddString (pat, XFT_FILE, file))
+ goto bail1;
+
+ if (!XftPatternAddInteger (pat, XFT_INDEX, id))
+ goto bail1;
+
+#if 0
+ if ((face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) != 0)
+ if (!XftPatternAddInteger (pat, XFT_SPACING, XFT_MONO))
+ goto bail1;
+#endif
+
+ if (!(face->face_flags & FT_FACE_FLAG_SCALABLE))
+ {
+ for (i = 0; i < face->num_fixed_sizes; i++)
+ if (!XftPatternAddDouble (pat, XFT_PIXEL_SIZE,
+ (double) face->available_sizes[i].height))
+ goto bail1;
+ }
+
+ for (i = 0; i < face->num_charmaps; i++)
+ {
+#if 0
+ printf ("face %s encoding %d %c%c%c%c\n",
+ face->family_name, i,
+ face->charmaps[i]->encoding >> 24,
+ face->charmaps[i]->encoding >> 16,
+ face->charmaps[i]->encoding >> 8,
+ face->charmaps[i]->encoding >> 0);
+#endif
+ for (j = 0; j < NUM_FT_ENCODINGS; j++)
+ {
+ if (face->charmaps[i]->encoding == xftFtEncoding[j].encoding)
+ {
+ if (!XftPatternAddString (pat, XFT_ENCODING,
+ xftFtEncoding[j].name))
+ goto bail1;
+ }
+ }
+ }
+
+ if (!XftPatternAddString (pat, XFT_ENCODING,
+ "glyphs-fontspecific"))
+ goto bail1;
+
+
+ FT_Done_Face (face);
+ return pat;
+
+bail1:
+ XftPatternDestroy (pat);
+bail0:
+ FT_Done_Face (face);
+ return 0;
+}
+
+/*
+ * List of all open files (each face in a file is managed separately)
+ */
+typedef struct _XftFtFile {
+ struct _XftFtFile *next;
+ int ref;
+
+ char *file;
+ int id;
+
+ FT_Face face;
+ FT_F26Dot6 size;
+ FT_Matrix matrix;
+ int charmap;
+} XftFtFile;
+
+static XftFtFile *_XftFtFiles;
+
+static XftFtFile *
+_XftFreeTypeOpenFile (char *file, int id)
+{
+ XftFtFile *f;
+ FT_Face face;
+
+ for (f = _XftFtFiles; f; f = f->next)
+ {
+ if (!strcmp (f->file, file) && f->id == id)
+ {
+ ++f->ref;
+ if (_XftFontDebug () & XFT_DBG_REF)
+ printf ("FontFile %s/%d matches existing (%d)\n",
+ file, id, f->ref);
+ return f;
+ }
+ }
+ if (FT_New_Face (_XftFTlibrary, file, id, &face))
+ return 0;
+
+ f = malloc (sizeof (XftFtFile) + strlen (file) + 1);
+ if (!f)
+ return 0;
+
+ if (_XftFontDebug () & XFT_DBG_REF)
+ printf ("FontFile %s/%d matches new\n",
+ file, id);
+ f->next = _XftFtFiles;
+ _XftFtFiles = f;
+ f->ref = 1;
+
+ f->file = (char *) (f+1);
+ strcpy (f->file, file);
+ f->id = id;
+
+ f->face = face;
+ f->size = 0;
+ f->charmap = -1;
+ f->matrix.xx = 0x10000;
+ f->matrix.xy = 0x0;
+ f->matrix.yy = 0x10000;
+ f->matrix.yx = 0x0;
+ return f;
+}
+
+Bool
+XftFreeTypeSetFace (FT_Face face, FT_F26Dot6 size, int charmap, FT_Matrix *matrix)
+{
+ XftFtFile *f, **prev;
+
+ for (prev = &_XftFtFiles; (f = *prev); prev = &f->next)
+ {
+ if (f->face == face)
+ {
+ /* LRU */
+ if (prev != &_XftFtFiles)
+ {
+ *prev = f->next;
+ f->next = _XftFtFiles;
+ _XftFtFiles = f;
+ }
+ if (f->size != size)
+ {
+ if (_XftFontDebug() & XFT_DBG_GLYPH)
+ printf ("Set face size to %d (%d)\n",
+ (int) (size >> 6), (int) size);
+ if (FT_Set_Char_Size (face, size, size, 0, 0))
+ return False;
+ f->size = size;
+ }
+ if (f->charmap != charmap && charmap != -1)
+ {
+ if (_XftFontDebug() & XFT_DBG_GLYPH)
+ printf ("Set face charmap to %d\n", charmap);
+ if (FT_Set_Charmap (face, face->charmaps[charmap]))
+ return False;
+ f->charmap = charmap;
+ }
+ if (!FT_Matrix_Equal (&f->matrix, matrix))
+ {
+ if (_XftFontDebug() & XFT_DBG_GLYPH)
+ printf ("Set face matrix to (%g,%g,%g,%g)\n",
+ (double) matrix->xx / 0x10000,
+ (double) matrix->xy / 0x10000,
+ (double) matrix->yx / 0x10000,
+ (double) matrix->yy / 0x10000);
+ FT_Set_Transform (face, matrix, 0);
+ f->matrix = *matrix;
+ }
+ break;
+ }
+ }
+ return True;
+}
+
+static void
+_XftFreeTypeCloseFile (XftFtFile *f)
+{
+ XftFtFile **prev;
+
+ if (--f->ref != 0)
+ return;
+ for (prev = &_XftFtFiles; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == f)
+ {
+ *prev = f->next;
+ break;
+ }
+ }
+ FT_Done_Face (f->face);
+ free (f);
+}
+
+/*
+ * Cache of all glyphsets
+ */
+typedef struct _XftFtGlyphSet {
+ struct _XftFtGlyphSet *next;
+ int ref;
+
+ XftFtFile *file;
+ Bool minspace;
+ int char_width;
+
+ XftFontStruct font;
+} XftFtGlyphSet;
+
+XftFontStruct *
+XftFreeTypeOpen (Display *dpy, XftPattern *pattern)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
+ XftFtFile *file;
+ FT_Face face;
+ XftFtGlyphSet *gs;
+ char *filename;
+ int id;
+ double dsize;
+ FT_F26Dot6 size;
+ int rgba;
+ int spacing;
+ int char_width;
+ Bool antialias;
+ Bool minspace;
+ char *encoding_name;
+ XftFontStruct *font;
+ int j;
+ FT_Encoding encoding;
+ int charmap;
+ FT_Matrix matrix;
+ XftMatrix *font_matrix;
+
+#if 0
+ int extra;
+#endif
+ int height, ascent, descent;
+ XRenderPictFormat pf, *format;
+
+ /*
+ * Open the file
+ */
+ if (XftPatternGetString (pattern, XFT_FILE, 0, &filename) != XftResultMatch)
+ goto bail0;
+
+ if (XftPatternGetInteger (pattern, XFT_INDEX, 0, &id) != XftResultMatch)
+ goto bail0;
+
+ file = _XftFreeTypeOpenFile (filename, id);
+ if (!file)
+ goto bail0;
+
+ face = file->face;
+
+ /*
+ * Extract the glyphset information from the pattern
+ */
+ if (XftPatternGetString (pattern, XFT_ENCODING, 0, &encoding_name) != XftResultMatch)
+ goto bail0;
+
+ if (XftPatternGetDouble (pattern, XFT_PIXEL_SIZE, 0, &dsize) != XftResultMatch)
+ goto bail0;
+
+ switch (XftPatternGetInteger (pattern, XFT_RGBA, 0, &rgba)) {
+ case XftResultNoMatch:
+ rgba = XFT_RGBA_NONE;
+ break;
+ case XftResultMatch:
+ break;
+ default:
+ goto bail0;
+ }
+
+ switch (XftPatternGetBool (pattern, XFT_ANTIALIAS, 0, &antialias)) {
+ case XftResultNoMatch:
+ antialias = True;
+ break;
+ case XftResultMatch:
+ break;
+ default:
+ goto bail0;
+ }
+
+ switch (XftPatternGetBool (pattern, XFT_MINSPACE, 0, &minspace)) {
+ case XftResultNoMatch:
+ minspace = False;
+ break;
+ case XftResultMatch:
+ break;
+ default:
+ goto bail0;
+ }
+
+ switch (XftPatternGetInteger (pattern, XFT_SPACING, 0, &spacing)) {
+ case XftResultNoMatch:
+ spacing = XFT_PROPORTIONAL;
+ break;
+ case XftResultMatch:
+ break;
+ default:
+ goto bail1;
+ }
+
+ if (XftPatternGetInteger (pattern, XFT_CHAR_WIDTH,
+ 0, &char_width) != XftResultMatch)
+ {
+ char_width = 0;
+ }
+ else if (char_width)
+ spacing = XFT_MONO;
+
+ matrix.xx = matrix.yy = 0x10000;
+ matrix.xy = matrix.yx = 0;
+
+ switch (XftPatternGetMatrix (pattern, XFT_MATRIX, 0, &font_matrix)) {
+ case XftResultNoMatch:
+ break;
+ case XftResultMatch:
+ matrix.xx = 0x10000L * font_matrix->xx;
+ matrix.yy = 0x10000L * font_matrix->yy;
+ matrix.xy = 0x10000L * font_matrix->xy;
+ matrix.yx = 0x10000L * font_matrix->yx;
+ break;
+ default:
+ goto bail1;
+ }
+
+
+
+ if (XftPatternGetInteger (pattern, XFT_CHAR_WIDTH,
+ 0, &char_width) != XftResultMatch)
+ {
+ char_width = 0;
+ }
+ else if (char_width)
+ spacing = XFT_MONO;
+
+ encoding = face->charmaps[0]->encoding;
+
+ for (j = 0; j < NUM_FT_ENCODINGS; j++)
+ if (!strcmp (encoding_name, xftFtEncoding[j].name))
+ {
+ encoding = xftFtEncoding[j].encoding;
+ break;
+ }
+
+ size = (FT_F26Dot6) (dsize * 64.0);
+
+ if (encoding == ft_encoding_none)
+ charmap = -1;
+ else
+ {
+ for (charmap = 0; charmap < face->num_charmaps; charmap++)
+ if (face->charmaps[charmap]->encoding == encoding)
+ break;
+
+ if (charmap == face->num_charmaps)
+ goto bail1;
+ }
+
+
+ /*
+ * Match an existing glyphset
+ */
+ for (gs = info->glyphSets; gs; gs = gs->next)
+ {
+ if (gs->file == file &&
+ gs->minspace == minspace &&
+ gs->char_width == char_width &&
+ gs->font.size == size &&
+ gs->font.spacing == spacing &&
+ gs->font.charmap == charmap &&
+ gs->font.rgba == rgba &&
+ gs->font.antialias == antialias &&
+ FT_Matrix_Equal (&gs->font.matrix, &matrix))
+ {
+ ++gs->ref;
+ if (_XftFontDebug () & XFT_DBG_REF)
+ {
+ printf ("Face size %g matches existing (%d)\n",
+ dsize, gs->ref);
+ }
+ return &gs->font;
+ }
+ }
+
+ if (_XftFontDebug () & XFT_DBG_REF)
+ {
+ printf ("Face size %g matches new\n",
+ dsize);
+ }
+ /*
+ * No existing glyphset, create another
+ */
+ gs = malloc (sizeof (XftFtGlyphSet));
+ if (!gs)
+ goto bail1;
+
+ gs->ref = 1;
+
+ gs->file = file;
+ gs->minspace = minspace;
+ gs->char_width = char_width;
+
+ font = &gs->font;
+
+ if (antialias)
+ {
+ switch (rgba) {
+ case FC_RGBA_RGB:
+ case FC_RGBA_BGR:
+ case FC_RGBA_VRGB:
+ case FC_RGBA_VBGR:
+ pf.depth = 32;
+ pf.type = PictTypeDirect;
+ pf.direct.alpha = 24;
+ pf.direct.alphaMask = 0xff;
+ pf.direct.red = 16;
+ pf.direct.redMask = 0xff;
+ pf.direct.green = 8;
+ pf.direct.greenMask = 0xff;
+ pf.direct.blue = 0;
+ pf.direct.blueMask = 0xff;
+ format = XRenderFindFormat(dpy,
+ PictFormatType|
+ PictFormatDepth|
+ PictFormatAlpha|
+ PictFormatAlphaMask|
+ PictFormatRed|
+ PictFormatRedMask|
+ PictFormatGreen|
+ PictFormatGreenMask|
+ PictFormatBlue|
+ PictFormatBlueMask,
+ &pf, 0);
+ break;
+ default:
+ pf.depth = 8;
+ pf.type = PictTypeDirect;
+ pf.direct.alpha = 0;
+ pf.direct.alphaMask = 0xff;
+ format = XRenderFindFormat(dpy,
+ PictFormatType|
+ PictFormatDepth|
+ PictFormatAlpha|
+ PictFormatAlphaMask,
+ &pf, 0);
+ break;
+ }
+ }
+ else
+ {
+ pf.depth = 1;
+ pf.type = PictTypeDirect;
+ pf.direct.alpha = 0;
+ pf.direct.alphaMask = 0x1;
+ format = XRenderFindFormat(dpy,
+ PictFormatType|
+ PictFormatDepth|
+ PictFormatAlpha|
+ PictFormatAlphaMask,
+ &pf, 0);
+ }
+
+ if (!format)
+ goto bail2;
+
+ if (!XftFreeTypeSetFace (face, size, charmap, &matrix))
+ goto bail2;
+
+ descent = -(face->size->metrics.descender >> 6);
+ ascent = face->size->metrics.ascender >> 6;
+ if (minspace)
+ {
+ height = ascent + descent;
+ }
+ else
+ {
+ height = face->size->metrics.height >> 6;
+#if 0
+ extra = (height - (ascent + descent));
+ if (extra > 0)
+ {
+ ascent = ascent + extra / 2;
+ descent = height - ascent;
+ }
+ else if (extra < 0)
+ height = ascent + descent;
+#endif
+ }
+ font->ascent = ascent;
+ font->descent = descent;
+ font->height = height;
+
+ if (char_width)
+ font->max_advance_width = char_width;
+ else
+ font->max_advance_width = face->size->metrics.max_advance >> 6;
+
+ gs->next = info->glyphSets;
+ info->glyphSets = gs;
+
+ font->glyphset = XRenderCreateGlyphSet (dpy, format);
+
+ font->size = size;
+ font->spacing = spacing;
+ font->format = format;
+ font->realized =0;
+ font->nrealized = 0;
+ font->rgba = rgba;
+ font->antialias = antialias;
+ font->charmap = charmap;
+ font->transform = (matrix.xx != 0x10000 || matrix.xy != 0 ||
+ matrix.yx != 0 || matrix.yy != 0x10000);
+ font->matrix = matrix;
+ font->face = face;
+
+ return font;
+
+bail2:
+ free (gs);
+bail1:
+ _XftFreeTypeCloseFile (file);
+bail0:
+ return 0;
+}
+
+void
+XftFreeTypeClose (Display *dpy, XftFontStruct *font)
+{
+ XftFtGlyphSet *gs, **prev;
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
+ int i;
+ XGlyphInfo *gi;
+
+ for (prev = &info->glyphSets; (gs = *prev); prev = &gs->next)
+ {
+ if (&gs->font == font)
+ {
+ if (--gs->ref == 0)
+ {
+ XRenderFreeGlyphSet (dpy, font->glyphset);
+ for (i = 0; i < font->nrealized; i++)
+ {
+ gi = font->realized[i];
+ if (gi && gi != XftUntestedGlyph)
+ free (gi);
+ }
+ if (font->realized)
+ free (font->realized);
+
+ _XftFreeTypeCloseFile (gs->file);
+
+ *prev = gs->next;
+ free (gs);
+ }
+ break;
+ }
+ }
+}
+
+XftFontStruct *
+XftFreeTypeGet (XftFont *font)
+{
+ if (font->core)
+ return 0;
+ return font->u.ft.font;
+}
+
+/* #define XFT_DEBUG_FONTSET */
+
+Bool
+XftInitFtLibrary (void)
+{
+ if (_XftFTlibrary)
+ return True;
+ if (FT_Init_FreeType (&_XftFTlibrary))
+ return False;
+ _XftFontSet = FcConfigGetFonts (0, FcSetSystem);
+ if (!_XftFontSet)
+ return False;
+ return True;
+}
diff --git a/nx-X11/lib/Xft1/xftfs.c b/nx-X11/lib/Xft1/xftfs.c
new file mode 100644
index 000000000..a246b2056
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftfs.c
@@ -0,0 +1,44 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdlib.h>
+#include "xftint.h"
+
+XftFontSet *
+XftFontSetCreate (void)
+{
+ return FcFontSetCreate ();
+}
+
+void
+XftFontSetDestroy (XftFontSet *s)
+{
+ FcFontSetDestroy (s);
+}
+
+Bool
+XftFontSetAdd (XftFontSet *s, XftPattern *font)
+{
+ return FcFontSetAdd (s, font);
+}
diff --git a/nx-X11/lib/Xft1/xftglyphs.c b/nx-X11/lib/Xft1/xftglyphs.c
new file mode 100644
index 000000000..1e23d0a0b
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftglyphs.c
@@ -0,0 +1,491 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftglyphs.c,v 1.3 2003/05/27 22:26:41 tsi Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "xftint.h"
+#include <ft2build.h>
+#include FT_OUTLINE_H
+
+static const int filters[3][3] = {
+ /* red */
+#if 0
+{ 65538*4/7,65538*2/7,65538*1/7 },
+ /* green */
+{ 65536*1/4, 65536*2/4, 65537*1/4 },
+ /* blue */
+{ 65538*1/7,65538*2/7,65538*4/7 },
+#endif
+{ 65538*9/13,65538*3/13,65538*1/13 },
+ /* green */
+{ 65538*1/6, 65538*4/6, 65538*1/6 },
+ /* blue */
+{ 65538*1/13,65538*3/13,65538*9/13 },
+};
+
+void
+XftGlyphLoad (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 *glyphs,
+ int nglyph)
+{
+ FT_Error error;
+ FT_ULong charcode;
+ FT_UInt glyphindex;
+ FT_GlyphSlot glyph;
+ XGlyphInfo *gi;
+ Glyph g;
+ unsigned char bufLocal[4096];
+ unsigned char *bufBitmap = bufLocal;
+ int bufSize = sizeof (bufLocal);
+ int size, pitch;
+ unsigned char bufLocalRgba[4096];
+ unsigned char *bufBitmapRgba = bufLocalRgba;
+ int bufSizeRgba = sizeof (bufLocalRgba);
+ int sizergba, pitchrgba, widthrgba;
+ int width;
+ int height;
+ int left, right, top, bottom;
+ int hmul = 1;
+ int vmul = 1;
+ FT_Bitmap ftbit;
+ FT_Matrix matrix;
+ FT_Vector vector;
+ Bool subpixel = False;
+
+ if (!XftFreeTypeSetFace (font->face, font->size, font->charmap, &font->matrix))
+ return ;
+
+ matrix.xx = matrix.yy = 0x10000L;
+ matrix.xy = matrix.yx = 0;
+
+ if (font->antialias)
+ {
+ switch (font->rgba) {
+ case XFT_RGBA_RGB:
+ case XFT_RGBA_BGR:
+ matrix.xx *= 3;
+ subpixel = True;
+ hmul = 3;
+ break;
+ case XFT_RGBA_VRGB:
+ case XFT_RGBA_VBGR:
+ matrix.yy *= 3;
+ vmul = 3;
+ subpixel = True;
+ break;
+ }
+ }
+
+ while (nglyph--)
+ {
+ charcode = (FT_ULong) *glyphs++;
+ gi = font->realized[charcode];
+ if (!gi)
+ continue;
+
+ if (font->charmap != -1)
+ {
+ glyphindex = FT_Get_Char_Index (font->face, charcode);
+#if 0
+ if (!glyphindex)
+ {
+ if (_XftFontDebug() & XFT_DBG_GLYPH)
+ printf ("glyph (%c) %d missing\n",
+ (int) charcode, (int) charcode);
+ continue;
+ }
+#endif
+ }
+ else
+ glyphindex = (FT_UInt) charcode;
+ error = FT_Load_Glyph (font->face, glyphindex, FT_LOAD_NO_BITMAP);
+ if (error)
+ continue;
+
+#define FLOOR(x) ((x) & -64)
+#define CEIL(x) (((x)+63) & -64)
+#define TRUNC(x) ((x) >> 6)
+#define ROUND(x) (((x)+32) & -64)
+
+ glyph = font->face->glyph;
+
+ if(font->transform)
+ {
+ /*
+ * calculate the true width by transforming all four corners.
+ */
+ int xc, yc;
+ left = right = top = bottom = 0;
+ for(xc = 0; xc <= 1; xc ++) {
+ for(yc = 0; yc <= 1; yc++) {
+ vector.x = glyph->metrics.horiBearingX + xc * glyph->metrics.width;
+ vector.y = glyph->metrics.horiBearingY - yc * glyph->metrics.height;
+ FT_Vector_Transform(&vector, &font->matrix);
+ if (_XftFontDebug() & XFT_DBG_GLYPH)
+ printf("Trans %d %d: %d %d\n", (int) xc, (int) yc,
+ (int) vector.x, (int) vector.y);
+ if(xc == 0 && yc == 0) {
+ left = right = vector.x;
+ top = bottom = vector.y;
+ } else {
+ if(left > vector.x) left = vector.x;
+ if(right < vector.x) right = vector.x;
+ if(bottom > vector.y) bottom = vector.y;
+ if(top < vector.y) top = vector.y;
+ }
+
+ }
+ }
+ left = FLOOR(left);
+ right = CEIL(right);
+ bottom = FLOOR(bottom);
+ top = CEIL(top);
+
+ } else {
+ left = FLOOR( glyph->metrics.horiBearingX );
+ right = CEIL( glyph->metrics.horiBearingX + glyph->metrics.width );
+
+ top = CEIL( glyph->metrics.horiBearingY );
+ bottom = FLOOR( glyph->metrics.horiBearingY - glyph->metrics.height );
+ }
+
+ width = TRUNC(right - left);
+ height = TRUNC( top - bottom );
+
+
+ /*
+ * Try to keep monospace fonts ink-inside
+ * XXX transformed?
+ */
+ if (font->spacing != XFT_PROPORTIONAL && !font->transform)
+ {
+ if (TRUNC(right) > font->max_advance_width)
+ {
+ int adjust;
+
+ adjust = right - (font->max_advance_width << 6);
+ if (adjust > left)
+ adjust = left;
+ left -= adjust;
+ right -= adjust;
+ width = font->max_advance_width;
+ }
+ }
+
+ if ( glyph->format == ft_glyph_format_outline )
+ {
+ if (font->antialias)
+ pitch = (width * hmul + 3) & ~3;
+ else
+ pitch = ((width + 31) & ~31) >> 3;
+
+ size = pitch * height * vmul;
+
+ if (size > bufSize)
+ {
+ if (bufBitmap != bufLocal)
+ free (bufBitmap);
+ bufBitmap = (unsigned char *) malloc (size);
+ if (!bufBitmap)
+ continue;
+ bufSize = size;
+ }
+ memset (bufBitmap, 0, size);
+
+ ftbit.width = width * hmul;
+ ftbit.rows = height * vmul;
+ ftbit.pitch = pitch;
+ if (font->antialias)
+ ftbit.pixel_mode = ft_pixel_mode_grays;
+ else
+ ftbit.pixel_mode = ft_pixel_mode_mono;
+
+ ftbit.buffer = bufBitmap;
+
+ if (subpixel)
+ FT_Outline_Transform (&glyph->outline, &matrix);
+
+ FT_Outline_Translate ( &glyph->outline, -left*hmul, -bottom*vmul );
+
+ FT_Outline_Get_Bitmap( _XftFTlibrary, &glyph->outline, &ftbit );
+
+ /*
+ * swap bit order around
+ */
+ if (!font->antialias)
+ {
+ if (BitmapBitOrder (dpy) != MSBFirst)
+ {
+ unsigned char *line;
+ unsigned char c;
+ int i;
+
+ line = (unsigned char *) bufBitmap;
+ i = size;
+ while (i--)
+ {
+ c = *line;
+ c = ((c << 1) & 0xaa) | ((c >> 1) & 0x55);
+ c = ((c << 2) & 0xcc) | ((c >> 2) & 0x33);
+ c = ((c << 4) & 0xf0) | ((c >> 4) & 0x0f);
+ *line++ = c;
+ }
+ }
+ }
+ if (_XftFontDebug() & XFT_DBG_GLYPH)
+ {
+ printf ("char 0x%x (%c):\n", (int) charcode, (char) charcode);
+ printf (" xywh (%d %d %d %d), trans (%d %d %d %d) wh (%d %d)\n",
+ (int) glyph->metrics.horiBearingX,
+ (int) glyph->metrics.horiBearingY,
+ (int) glyph->metrics.width,
+ (int) glyph->metrics.height,
+ left, right, top, bottom,
+ width, height);
+ if (_XftFontDebug() & XFT_DBG_GLYPHV)
+ {
+ int x, y;
+ unsigned char *line;
+
+ line = bufBitmap;
+ for (y = 0; y < height * vmul; y++)
+ {
+ if (font->antialias)
+ {
+ static char den[] = { " .:;=+*#" };
+ for (x = 0; x < pitch; x++)
+ printf ("%c", den[line[x] >> 5]);
+ }
+ else
+ {
+ for (x = 0; x < pitch * 8; x++)
+ {
+ printf ("%c", line[x>>3] & (1 << (x & 7)) ? '#' : ' ');
+ }
+ }
+ printf ("|\n");
+ line += pitch;
+ }
+ printf ("\n");
+ }
+ }
+ }
+ else
+ {
+ if (_XftFontDebug() & XFT_DBG_GLYPH)
+ printf ("glyph (%c) %d no outline\n",
+ (int) charcode, (int) charcode);
+ continue;
+ }
+
+ gi->width = width;
+ gi->height = height;
+ gi->x = -TRUNC(left);
+ gi->y = TRUNC(top);
+ if (font->spacing != XFT_PROPORTIONAL)
+ {
+ if (font->transform)
+ {
+ vector.x = font->max_advance_width;
+ vector.y = 0;
+ FT_Vector_Transform (&vector, &font->matrix);
+ gi->xOff = vector.x;
+ gi->yOff = -vector.y;
+ }
+ else
+ {
+ gi->xOff = font->max_advance_width;
+ gi->yOff = 0;
+ }
+ }
+ else
+ {
+ gi->xOff = TRUNC(ROUND(glyph->advance.x));
+ gi->yOff = -TRUNC(ROUND(glyph->advance.y));
+ }
+ g = charcode;
+
+ if (subpixel)
+ {
+ int x, y;
+ unsigned char *in_line, *out_line, *in;
+ unsigned int *out;
+ unsigned int red, green, blue;
+ int rf, gf, bf;
+ int s;
+ int o, os;
+
+ widthrgba = width;
+ pitchrgba = (widthrgba * 4 + 3) & ~3;
+ sizergba = pitchrgba * height;
+
+ os = 1;
+ switch (font->rgba) {
+ case XFT_RGBA_VRGB:
+ os = pitch;
+ case XFT_RGBA_RGB:
+ default:
+ rf = 0;
+ gf = 1;
+ bf = 2;
+ break;
+ case XFT_RGBA_VBGR:
+ os = pitch;
+ case XFT_RGBA_BGR:
+ bf = 0;
+ gf = 1;
+ rf = 2;
+ break;
+ }
+ if (sizergba > bufSizeRgba)
+ {
+ if (bufBitmapRgba != bufLocalRgba)
+ free (bufBitmapRgba);
+ bufBitmapRgba = (unsigned char *) malloc (sizergba);
+ if (!bufBitmapRgba)
+ continue;
+ bufSizeRgba = sizergba;
+ }
+ memset (bufBitmapRgba, 0, sizergba);
+ in_line = bufBitmap;
+ out_line = bufBitmapRgba;
+ for (y = 0; y < height; y++)
+ {
+ in = in_line;
+ out = (unsigned int *) out_line;
+ in_line += pitch * vmul;
+ out_line += pitchrgba;
+ for (x = 0; x < width * hmul; x += hmul)
+ {
+ red = green = blue = 0;
+ o = 0;
+ for (s = 0; s < 3; s++)
+ {
+ red += filters[rf][s]*in[x+o];
+ green += filters[gf][s]*in[x+o];
+ blue += filters[bf][s]*in[x+o];
+ o += os;
+ }
+ red = red / 65536;
+ green = green / 65536;
+ blue = blue / 65536;
+ *out++ = (green << 24) | (red << 16) | (green << 8) | blue;
+ }
+ }
+
+ XRenderAddGlyphs (dpy, font->glyphset, &g, gi, 1,
+ (char *) bufBitmapRgba, sizergba);
+ }
+ else
+ {
+ XRenderAddGlyphs (dpy, font->glyphset, &g, gi, 1,
+ (char *) bufBitmap, size);
+ }
+ }
+ if (bufBitmap != bufLocal)
+ free (bufBitmap);
+ if (bufBitmapRgba != bufLocalRgba)
+ free (bufBitmapRgba);
+}
+
+#define STEP 256
+
+/*
+ * Return whether the given glyph generates any image on the screen,
+ * this means it exists or a default glyph exists
+ */
+static Bool
+XftGlyphDrawable (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 glyph)
+{
+ if (font->charmap != -1)
+ {
+ FT_Set_Charmap (font->face, font->face->charmaps[font->charmap]);
+ glyph = (XftChar32) FT_Get_Char_Index (font->face, (FT_ULong) glyph);
+ }
+ return glyph <= font->face->num_glyphs;
+}
+
+void
+XftGlyphCheck (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 glyph,
+ XftChar32 *missing,
+ int *nmissing)
+{
+ XGlyphInfo **realized;
+ int nrealized;
+ int n;
+
+ if (glyph >= font->nrealized)
+ {
+ nrealized = glyph + STEP;
+
+ if (font->realized)
+ realized = (XGlyphInfo **) realloc ((void *) font->realized,
+ nrealized * sizeof (XGlyphInfo *));
+ else
+ realized = (XGlyphInfo **) malloc (nrealized * sizeof (XGlyphInfo *));
+ if (!realized)
+ return;
+ for (n = font->nrealized; n < nrealized; n++)
+ realized[n] = XftUntestedGlyph;
+
+ font->realized = realized;
+ font->nrealized = nrealized;
+ }
+ if (font->realized[glyph] == XftUntestedGlyph)
+ {
+ if (XftGlyphDrawable (dpy, font, glyph))
+ {
+ font->realized[glyph] = (XGlyphInfo *) malloc (sizeof (XGlyphInfo));
+ n = *nmissing;
+ missing[n++] = glyph;
+ if (n == XFT_NMISSING)
+ {
+ XftGlyphLoad (dpy, font, missing, n);
+ n = 0;
+ }
+ *nmissing = n;
+ }
+ else
+ font->realized[glyph] = 0;
+ }
+}
+
+Bool
+XftFreeTypeGlyphExists (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 glyph)
+{
+ if (font->charmap != -1)
+ {
+ FT_Set_Charmap (font->face, font->face->charmaps[font->charmap]);
+ glyph = (XftChar32) FT_Get_Char_Index (font->face, (FT_ULong) glyph);
+ }
+ return glyph && glyph <= font->face->num_glyphs;
+}
diff --git a/nx-X11/lib/Xft1/xftgram.y b/nx-X11/lib/Xft1/xftgram.y
new file mode 100644
index 000000000..04e231e7c
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftgram.y
@@ -0,0 +1,452 @@
+/*
+ * $XFree86: xc/lib/Xft/xftgram.y,v 1.5 2001/05/16 10:32:54 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdlib.h>
+#include <stdio.h>
+#include "xftint.h"
+
+static XftMatrix matrix;
+
+%}
+
+%union {
+ int ival;
+ double dval;
+ char *sval;
+ XftExpr *eval;
+ XftPattern *pval;
+ XftValue vval;
+ XftEdit *Eval;
+ XftOp oval;
+ XftQual qval;
+ XftTest *tval;
+}
+
+%token <ival> INTEGER
+%token <dval> DOUBLE
+%token <sval> STRING NAME
+%token <ival> ANY ALL
+%token <ival> DIR CACHE INCLUDE INCLUDEIF MATCH EDIT
+%token <ival> TOK_TRUE TOK_FALSE TOK_NIL
+%token <ival> EQUAL SEMI OS CS
+
+%type <eval> expr
+%type <vval> value
+%type <sval> field
+%type <Eval> edit
+%type <Eval> edits
+%type <oval> eqop
+%type <qval> qual
+%type <oval> compare
+%type <tval> tests test
+%type <dval> number
+
+%right <ival> QUEST COLON
+%left <ival> OROR
+%left <ival> ANDAND
+%left <ival> EQEQ NOTEQ
+%left <ival> LESS LESSEQ MORE MOREEQ
+%left <ival> PLUS MINUS
+%left <ival> TIMES DIVIDE
+%right <ival> NOT
+
+%%
+configs : configs config
+ |
+ ;
+config : DIR STRING
+ { XftConfigAddDir ($2); }
+ | CACHE STRING
+ { XftConfigSetCache ($2); }
+ | INCLUDE STRING
+ { XftConfigPushInput ($2, True); }
+ | INCLUDEIF STRING
+ { XftConfigPushInput ($2, False); }
+ | MATCH tests EDIT edits
+ { XftConfigAddEdit ($2, $4); }
+ ;
+tests : test tests
+ { $1->next = $2; $$ = $1; }
+ |
+ { $$ = 0; }
+ ;
+test : qual field compare value
+ { $$ = XftTestCreate ($1, $2, $3, $4); }
+ ;
+qual : ANY
+ { $$ = XftQualAny; }
+ | ALL
+ { $$ = XftQualAll; }
+ |
+ { $$ = XftQualAny; }
+ ;
+field : NAME
+ {
+ $$ = XftConfigSaveField ($1);
+ }
+ ;
+compare : EQUAL
+ { $$ = XftOpEqual; }
+ | EQEQ
+ { $$ = XftOpEqual; }
+ | NOTEQ
+ { $$ = XftOpNotEqual; }
+ | LESS
+ { $$ = XftOpLess; }
+ | LESSEQ
+ { $$ = XftOpLessEqual; }
+ | MORE
+ { $$ = XftOpMore; }
+ | MOREEQ
+ { $$ = XftOpMoreEqual; }
+ ;
+value : INTEGER
+ {
+ $$.type = XftTypeInteger;
+ $$.u.i = $1;
+ }
+ | DOUBLE
+ {
+ $$.type = XftTypeDouble;
+ $$.u.d = $1;
+ }
+ | STRING
+ {
+ $$.type = XftTypeString;
+ $$.u.s = $1;
+ }
+ | TOK_TRUE
+ {
+ $$.type = XftTypeBool;
+ $$.u.b = True;
+ }
+ | TOK_FALSE
+ {
+ $$.type = XftTypeBool;
+ $$.u.b = False;
+ }
+ | TOK_NIL
+ {
+ $$.type = XftTypeVoid;
+ }
+ | matrix
+ {
+ $$.type = XftTypeMatrix;
+ $$.u.m = &matrix;
+ }
+ ;
+matrix : OS number number number number CS
+ {
+ matrix.xx = $2;
+ matrix.xy = $3;
+ matrix.yx = $4;
+ matrix.__REALLY_YY__ = $5;
+ }
+number : INTEGER
+ { $$ = (double) $1; }
+ | DOUBLE
+ ;
+edits : edit edits
+ { $1->next = $2; $$ = $1; }
+ |
+ { $$ = 0; }
+ ;
+edit : field eqop expr SEMI
+ { $$ = XftEditCreate ($1, $2, $3); }
+ ;
+eqop : EQUAL
+ { $$ = XftOpAssign; }
+ | PLUS EQUAL
+ { $$ = XftOpPrepend; }
+ | EQUAL PLUS
+ { $$ = XftOpAppend; }
+ ;
+expr : INTEGER
+ { $$ = XftExprCreateInteger ($1); }
+ | DOUBLE
+ { $$ = XftExprCreateDouble ($1); }
+ | STRING
+ { $$ = XftExprCreateString ($1); }
+ | TOK_TRUE
+ { $$ = XftExprCreateBool (True); }
+ | TOK_FALSE
+ { $$ = XftExprCreateBool (False); }
+ | TOK_NIL
+ { $$ = XftExprCreateNil (); }
+ | matrix
+ { $$ = XftExprCreateMatrix (&matrix); }
+ | NAME
+ { $$ = XftExprCreateField ($1); }
+ | expr OROR expr
+ { $$ = XftExprCreateOp ($1, XftOpOr, $3); }
+ | expr ANDAND expr
+ { $$ = XftExprCreateOp ($1, XftOpAnd, $3); }
+ | expr EQEQ expr
+ { $$ = XftExprCreateOp ($1, XftOpEqual, $3); }
+ | expr NOTEQ expr
+ { $$ = XftExprCreateOp ($1, XftOpNotEqual, $3); }
+ | expr LESS expr
+ { $$ = XftExprCreateOp ($1, XftOpLess, $3); }
+ | expr LESSEQ expr
+ { $$ = XftExprCreateOp ($1, XftOpLessEqual, $3); }
+ | expr MORE expr
+ { $$ = XftExprCreateOp ($1, XftOpMore, $3); }
+ | expr MOREEQ expr
+ { $$ = XftExprCreateOp ($1, XftOpMoreEqual, $3); }
+ | expr PLUS expr
+ { $$ = XftExprCreateOp ($1, XftOpPlus, $3); }
+ | expr MINUS expr
+ { $$ = XftExprCreateOp ($1, XftOpMinus, $3); }
+ | expr TIMES expr
+ { $$ = XftExprCreateOp ($1, XftOpTimes, $3); }
+ | expr DIVIDE expr
+ { $$ = XftExprCreateOp ($1, XftOpDivide, $3); }
+ | NOT expr
+ { $$ = XftExprCreateOp ($2, XftOpNot, (XftExpr *) 0); }
+ | expr QUEST expr COLON expr
+ { $$ = XftExprCreateOp ($1, XftOpQuest, XftExprCreateOp ($3, XftOpQuest, $5)); }
+ ;
+%%
+
+int
+XftConfigwrap (void)
+{
+ return 1;
+}
+
+void
+XftConfigerror (char *fmt, ...)
+{
+ va_list args;
+
+ fprintf (stderr, "\"%s\": line %d, ", XftConfigFile, XftConfigLineno);
+ va_start (args, fmt);
+ vfprintf (stderr, fmt, args);
+ va_end (args);
+ fprintf (stderr, "\n");
+}
+
+XftTest *
+XftTestCreate (XftQual qual, const char *field, XftOp compare, XftValue value)
+{
+ XftTest *test = (XftTest *) malloc (sizeof (XftTest));;
+
+ if (test)
+ {
+ test->next = 0;
+ test->qual = qual;
+ test->field = field; /* already saved in grammar */
+ test->op = compare;
+ if (value.type == XftTypeString)
+ value.u.s = _XftSaveString (value.u.s);
+ else if (value.type == XftTypeMatrix)
+ value.u.m = _XftSaveMatrix (value.u.m);
+ test->value = value;
+ }
+ return test;
+}
+
+XftExpr *
+XftExprCreateInteger (int i)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpInteger;
+ e->u.ival = i;
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateDouble (double d)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpDouble;
+ e->u.dval = d;
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateString (const char *s)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpString;
+ e->u.sval = _XftSaveString (s);
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateMatrix (const XftMatrix *m)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpMatrix;
+ e->u.mval = _XftSaveMatrix (m);
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateBool (Bool b)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpBool;
+ e->u.bval = b;
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateNil (void)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpNil;
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateField (const char *field)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpField;
+ e->u.field = _XftSaveString (field);
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateOp (XftExpr *left, XftOp op, XftExpr *right)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = op;
+ e->u.tree.left = left;
+ e->u.tree.right = right;
+ }
+ return e;
+}
+
+void
+XftExprDestroy (XftExpr *e)
+{
+ switch (e->op) {
+ case XftOpInteger:
+ break;
+ case XftOpDouble:
+ break;
+ case XftOpString:
+ free (e->u.sval);
+ break;
+ case XftOpMatrix:
+ free (e->u.mval);
+ break;
+ case XftOpBool:
+ break;
+ case XftOpField:
+ free (e->u.field);
+ break;
+ case XftOpAssign:
+ case XftOpPrepend:
+ case XftOpAppend:
+ break;
+ case XftOpOr:
+ case XftOpAnd:
+ case XftOpEqual:
+ case XftOpNotEqual:
+ case XftOpLess:
+ case XftOpLessEqual:
+ case XftOpMore:
+ case XftOpMoreEqual:
+ case XftOpPlus:
+ case XftOpMinus:
+ case XftOpTimes:
+ case XftOpDivide:
+ case XftOpQuest:
+ XftExprDestroy (e->u.tree.right);
+ /* fall through */
+ case XftOpNot:
+ XftExprDestroy (e->u.tree.left);
+ break;
+ case XftOpNil:
+ break;
+ }
+ free (e);
+}
+
+XftEdit *
+XftEditCreate (const char *field, XftOp op, XftExpr *expr)
+{
+ XftEdit *e = (XftEdit *) malloc (sizeof (XftEdit));
+
+ if (e)
+ {
+ e->next = 0;
+ e->field = field; /* already saved in grammar */
+ e->op = op;
+ e->expr = expr;
+ }
+ return e;
+}
+
+void
+XftEditDestroy (XftEdit *e)
+{
+ if (e->next)
+ XftEditDestroy (e->next);
+ free ((void *) e->field);
+ if (e->expr)
+ XftExprDestroy (e->expr);
+}
+
+char *
+XftConfigSaveField (const char *field)
+{
+ return _XftSaveString (field);
+}
diff --git a/nx-X11/lib/Xft1/xftinit.c b/nx-X11/lib/Xft1/xftinit.c
new file mode 100644
index 000000000..79e589160
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftinit.c
@@ -0,0 +1,42 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftinit.c,v 1.3 2002/03/01 20:33:33 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdlib.h>
+#include "xftint.h"
+
+XftFontSet *_XftFontSet;
+Bool _XftConfigInitialized;
+static char *nodirs[] = { 0 };
+char **XftConfigDirs = nodirs;
+
+Bool
+XftInit (char *config)
+{
+ if (_XftConfigInitialized)
+ return True;
+ if (!FcInit ())
+ return False;
+ _XftConfigInitialized = True;
+ return True;
+}
diff --git a/nx-X11/lib/Xft1/xftint.h b/nx-X11/lib/Xft1/xftint.h
new file mode 100644
index 000000000..c73fb1723
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftint.h
@@ -0,0 +1,508 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftint.h,v 1.2 2002/03/01 01:00:53 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _XFTINT_H_
+#define _XFTINT_H_
+
+#include <X11/Xlib.h>
+#include <fontconfig/fontconfig.h>
+#ifdef FREETYPE2
+#include "XftFreetype.h"
+#else
+#include "Xft.h"
+#endif
+
+typedef struct _XftMatcher {
+ char *object;
+ double (*compare) (char *object, XftValue value1, XftValue value2);
+} XftMatcher;
+
+typedef struct _XftSymbolic {
+ const char *name;
+ int value;
+} XftSymbolic;
+
+#define XFT_DRAW_N_SRC 2
+
+#define XFT_DRAW_SRC_TEXT 0
+#define XFT_DRAW_SRC_RECT 1
+
+struct _XftDraw {
+ Display *dpy;
+ Drawable drawable;
+ Visual *visual; /* NULL for bitmaps */
+ Colormap colormap;
+ Region clip;
+ Bool core_set;
+ Bool render_set;
+ Bool render_able;
+ struct {
+ Picture pict;
+ struct {
+ Picture pict;
+ XRenderColor color;
+ } src[XFT_DRAW_N_SRC];
+ } render;
+ struct {
+ GC draw_gc;
+ unsigned long fg;
+ Font font;
+ } core;
+};
+
+typedef struct _XftDisplayInfo {
+ struct _XftDisplayInfo *next;
+ Display *display;
+ XExtCodes *codes;
+ XftPattern *defaults;
+ XftFontSet *coreFonts;
+ Bool hasRender;
+ struct _XftFtGlyphSet *glyphSets;
+} XftDisplayInfo;
+
+extern XftFontSet *_XftGlobalFontSet;
+extern XftDisplayInfo *_XftDisplayInfo;
+extern char **XftConfigDirs;
+extern XftFontSet *_XftFontSet;
+
+typedef struct _FcPatternElt FcPatternElt;
+
+/*
+ * Yes, these are stolen from fcint.h
+ */
+FcPatternElt *
+FcPatternFindElt (const FcPattern *p, const char *object);
+
+FcPatternElt *
+FcPatternInsertElt (FcPattern *p, const char *object);
+
+typedef FcPatternElt XftPatternElt;
+
+#define XFT_NMISSING 256
+
+#ifndef XFT_DEFAULT_PATH
+#define XFT_DEFAULT_PATH "/usr/X11R6/lib/X11/XftConfig"
+#endif
+
+#define XFT_DBG_OPEN 1
+#define XFT_DBG_OPENV 2
+#define XFT_DBG_RENDER 4
+#define XFT_DBG_DRAW 8
+#define XFT_DBG_REF 16
+#define XFT_DBG_GLYPH 32
+#define XFT_DBG_GLYPHV 64
+#define XFT_DBG_CACHE 128
+#define XFT_DBG_CACHEV 256
+#define XFT_DBG_MATCH 512
+#define XFT_DBG_MATCHV 1024
+#define XFT_DBG_EDIT 2048
+
+typedef enum _XftOp {
+ XftOpInteger, XftOpDouble, XftOpString, XftOpMatrix, XftOpBool, XftOpNil,
+ XftOpField,
+ XftOpAssign, XftOpPrepend, XftOpAppend,
+ XftOpQuest,
+ XftOpOr, XftOpAnd, XftOpEqual, XftOpNotEqual,
+ XftOpLess, XftOpLessEqual, XftOpMore, XftOpMoreEqual,
+ XftOpPlus, XftOpMinus, XftOpTimes, XftOpDivide,
+ XftOpNot
+} XftOp;
+
+typedef struct _XftExpr {
+ XftOp op;
+ union {
+ int ival;
+ double dval;
+ char *sval;
+ XftMatrix *mval;
+ Bool bval;
+ char *field;
+ struct {
+ struct _XftExpr *left, *right;
+ } tree;
+ } u;
+} XftExpr;
+
+typedef enum _XftQual {
+ XftQualAny, XftQualAll
+} XftQual;
+
+typedef struct _XftTest {
+ struct _XftTest *next;
+ XftQual qual;
+ const char *field;
+ XftOp op;
+ XftValue value;
+} XftTest;
+
+typedef struct _XftEdit {
+ struct _XftEdit *next;
+ const char *field;
+ XftOp op;
+ XftExpr *expr;
+} XftEdit;
+
+typedef struct _XftSubst {
+ struct _XftSubst *next;
+ XftTest *test;
+ XftEdit *edit;
+} XftSubst;
+
+/*
+ * I tried this with functions that took va_list* arguments
+ * but portability concerns made me change these functions
+ * into macros (sigh).
+ */
+
+#define _XftPatternVapBuild(result, orig, va) \
+{ \
+ XftPattern *__p__ = (orig); \
+ const char *__o__; \
+ XftValue __v__; \
+ \
+ if (!__p__) \
+ { \
+ __p__ = XftPatternCreate (); \
+ if (!__p__) \
+ goto _XftPatternVapBuild_bail0; \
+ } \
+ for (;;) \
+ { \
+ __o__ = va_arg (va, const char *); \
+ if (!__o__) \
+ break; \
+ __v__.type = va_arg (va, XftType); \
+ switch (__v__.type) { \
+ case XftTypeVoid: \
+ goto _XftPatternVapBuild_bail1; \
+ case XftTypeInteger: \
+ __v__.u.i = va_arg (va, int); \
+ break; \
+ case XftTypeDouble: \
+ __v__.u.d = va_arg (va, double); \
+ break; \
+ case XftTypeString: \
+ __v__.u.s = va_arg (va, char *); \
+ break; \
+ case XftTypeBool: \
+ __v__.u.b = va_arg (va, Bool); \
+ break; \
+ case XftTypeMatrix: \
+ __v__.u.m = va_arg (va, XftMatrix *); \
+ break; \
+ } \
+ if (!XftPatternAdd (__p__, __o__, __v__, True)) \
+ goto _XftPatternVapBuild_bail1; \
+ } \
+ result = __p__; \
+ goto _XftPatternVapBuild_return; \
+ \
+_XftPatternVapBuild_bail1: \
+ if (!orig) \
+ XftPatternDestroy (__p__); \
+_XftPatternVapBuild_bail0: \
+ result = 0; \
+ \
+_XftPatternVapBuild_return: \
+ ; \
+}
+
+
+/* xftcache.c */
+
+char *
+XftFileCacheFind (char *file, int id, int *count);
+
+void
+XftFileCacheDispose (void);
+
+void
+XftFileCacheLoad (char *cache);
+
+Bool
+XftFileCacheUpdate (char *file, int id, char *name);
+
+Bool
+XftFileCacheSave (char *cache);
+
+Bool
+XftFileCacheReadDir (XftFontSet *set, const char *cache_file);
+
+Bool
+XftFileCacheWriteDir (XftFontSet *set, const char *cache_file);
+
+/* xftcfg.c */
+Bool
+XftConfigAddDir (char *d);
+
+Bool
+XftConfigSetCache (char *c);
+
+char *
+XftConfigGetCache (void);
+
+Bool
+XftConfigAddEdit (XftTest *test, XftEdit *edit);
+
+Bool
+_XftConfigCompareValue (XftValue m,
+ XftOp op,
+ XftValue v);
+
+/* xftcore.c */
+
+#define XFT_CORE_N16LOCAL 256
+
+XChar2b *
+XftCoreConvert16 (XftChar16 *string,
+ int len,
+ XChar2b xcloc[XFT_CORE_N16LOCAL]);
+
+XChar2b *
+XftCoreConvert32 (XftChar32 *string,
+ int len,
+ XChar2b xcloc[XFT_CORE_N16LOCAL]);
+
+XChar2b *
+XftCoreConvertUtf8 (XftChar8 *string,
+ int len,
+ XChar2b xcloc[XFT_CORE_N16LOCAL],
+ int *nchar);
+
+void
+XftCoreExtents8 (Display *dpy,
+ XFontStruct *fs,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftCoreExtents16 (Display *dpy,
+ XFontStruct *fs,
+ XftChar16 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftCoreExtents32 (Display *dpy,
+ XFontStruct *fs,
+ XftChar32 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftCoreExtentsUtf8 (Display *dpy,
+ XFontStruct *fs,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+Bool
+XftCoreGlyphExists (Display *dpy,
+ XFontStruct *fs,
+ XftChar32 glyph);
+
+/* xftdbg.c */
+void
+XftOpPrint (XftOp op);
+
+void
+XftTestPrint (XftTest *test);
+
+void
+XftExprPrint (XftExpr *expr);
+
+void
+XftEditPrint (XftEdit *edit);
+
+void
+XftSubstPrint (XftSubst *subst);
+
+/* xftdpy.c */
+XftDisplayInfo *
+_XftDisplayInfoGet (Display *dpy);
+
+int
+XftDefaultParseBool (char *v);
+
+Bool
+XftDefaultGetBool (Display *dpy, const char *object, int screen, Bool def);
+
+int
+XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def);
+
+double
+XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def);
+
+XftFontSet *
+XftDisplayGetFontSet (Display *dpy);
+
+/* xftdraw.c */
+Bool
+XftDrawRenderPrepare (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int src);
+
+Bool
+XftDrawCorePrepare (XftDraw *draw,
+ XftColor *color,
+ XftFont *font);
+
+/* xftextent.c */
+/* xftfont.c */
+int
+_XftFontDebug (void);
+
+/* xftfs.c */
+/* xftgram.y */
+int
+XftConfigparse (void);
+
+int
+XftConfigwrap (void);
+
+void
+XftConfigerror (char *fmt, ...);
+
+char *
+XftConfigSaveField (const char *field);
+
+XftTest *
+XftTestCreate (XftQual qual, const char *field, XftOp compare, XftValue value);
+
+XftExpr *
+XftExprCreateInteger (int i);
+
+XftExpr *
+XftExprCreateDouble (double d);
+
+XftExpr *
+XftExprCreateString (const char *s);
+
+XftExpr *
+XftExprCreateMatrix (const XftMatrix *m);
+
+XftExpr *
+XftExprCreateBool (Bool b);
+
+XftExpr *
+XftExprCreateNil (void);
+
+XftExpr *
+XftExprCreateField (const char *field);
+
+XftExpr *
+XftExprCreateOp (XftExpr *left, XftOp op, XftExpr *right);
+
+void
+XftExprDestroy (XftExpr *e);
+
+XftEdit *
+XftEditCreate (const char *field, XftOp op, XftExpr *expr);
+
+void
+XftEditDestroy (XftEdit *e);
+
+/* xftinit.c */
+
+/* xftlex.l */
+extern int XftConfigLineno;
+extern char *XftConfigFile;
+
+int
+XftConfiglex (void);
+
+Bool
+XftConfigLexFile(char *s);
+
+Bool
+XftConfigPushInput (char *s, Bool complain);
+
+/* xftlist.c */
+Bool
+XftListValueCompare (XftValue v1,
+ XftValue v2);
+
+Bool
+XftListMatch (XftPattern *p,
+ XftPattern *font,
+ XftQual qual);
+
+Bool
+XftListAppend (XftFontSet *s,
+ XftPattern *font,
+ XftObjectSet *os);
+
+
+/* xftmatch.c */
+
+/* xftname.c */
+Bool
+XftNameConstant (char *string, int *result);
+
+/* xftpat.c */
+
+extern FcPatternElt *
+FcPatternFind (FcPattern *p, const char *object, FcBool insert);
+
+XftPatternElt *
+XftPatternFind (XftPattern *p, const char *object, FcBool insert);
+
+/* xftrender.c */
+
+/* xftmatrix.c */
+XftMatrix *
+_XftSaveMatrix (const XftMatrix *mat);
+
+/* xftstr.c */
+char *
+_XftSaveString (const char *s);
+
+const char *
+_XftGetInt(const char *ptr, int *val);
+
+char *
+_XftSplitStr (const char *field, char *save);
+
+char *
+_XftDownStr (const char *field, char *save);
+
+const char *
+_XftSplitField (const char *field, char *save);
+
+const char *
+_XftSplitValue (const char *field, char *save);
+
+int
+_XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def);
+
+int
+_XftStrCmpIgnoreCase (const char *s1, const char *s2);
+
+/* xftxlfd.c */
+Bool
+XftCoreAddFonts (XftFontSet *set, Display *dpy, Bool ignore_scalable);
+
+#endif /* _XFT_INT_H_ */
diff --git a/nx-X11/lib/Xft1/xftlex.l b/nx-X11/lib/Xft1/xftlex.l
new file mode 100644
index 000000000..3eff3f429
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftlex.l
@@ -0,0 +1,275 @@
+%{
+/*
+ * $XFree86: xc/lib/Xft/xftlex.l,v 1.7 2001/05/18 16:03:06 tsi Exp $
+ *
+ * Copyright (c) 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <string.h>
+#include "xftint.h"
+
+#include "xftgram.h"
+
+int XftConfigLineno;
+
+static void _XftConfigSkipComment (void);
+
+static void _XftConfigSkipLine (void);
+
+static int _XftConfigPopInput (void);
+
+
+#define XFT_CONFIG_IN_DEEP 20
+FILE *XftConfigInStack[XFT_CONFIG_IN_DEEP];
+FILE **XftConfigInpt = XftConfigInStack + XFT_CONFIG_IN_DEEP;
+FILE *XftConfigInput;
+int XftConfigLinenos[XFT_CONFIG_IN_DEEP];
+int *XftConfigLinenopt = XftConfigLinenos + XFT_CONFIG_IN_DEEP;
+char *XftConfigFile = "";
+char *XftConfigFileNames[XFT_CONFIG_IN_DEEP];
+char **XftConfigFileNamePt = XftConfigFileNames + XFT_CONFIG_IN_DEEP;
+int XftConfigFiledeep = 0;
+
+#undef YY_INPUT
+
+#define YY_INPUT(buf,result,max_size) \
+{ \
+ int c; \
+ result = 0; \
+ while (result < max_size) { \
+ c = getc (XftConfigInput); \
+ if (c < 0) { \
+ c = _XftConfigPopInput (); \
+ if (c < 0) \
+ break; \
+ } \
+ buf[result++] = c; \
+ if (c == '\n') \
+ { \
+ XftConfigLineno++; \
+ break; \
+ } \
+ } \
+}
+
+#ifndef FLEX_SCANNER
+#undef input
+#undef unput
+static int input (void)
+{
+ char buf[1];
+ static int r = EOF;
+
+ if (r == 0)
+ return 0;
+ YY_INPUT(buf, r, 1);
+ if (r == 0)
+ return EOF;
+ return buf[0];
+}
+
+static void unput (char c)
+{
+ if (!c || c == EOF)
+ return;
+ if (c == '\n')
+ XftConfigLineno--;
+ ungetc (c, XftConfigInput);
+}
+#endif
+
+%}
+%%
+"/\052" _XftConfigSkipComment();
+^# _XftConfigSkipLine();
+dir return DIR;
+cache return CACHE;
+include return INCLUDE;
+includeif return INCLUDEIF;
+match return MATCH;
+edit return EDIT;
+true return TOK_TRUE;
+false return TOK_FALSE;
+nil return TOK_NIL;
+any return ANY;
+all return ALL;
+"=" return EQUAL;
+":" return COLON;
+";" return SEMI;
+"+" return PLUS;
+"-" return MINUS;
+"*" return TIMES;
+"/" return DIVIDE;
+"!" return NOT;
+"&&" return ANDAND;
+"||" return OROR;
+"<" return LESS;
+"<=" return LESSEQ;
+"==" return EQEQ;
+">=" return MOREEQ;
+">" return MORE;
+"!=" return NOTEQ;
+"?" return QUEST;
+"[" return OS;
+"]" return CS;
+\"([^\n\"]|\\\")*\" {
+ yytext[yyleng - 1] = '\0';
+ yylval.sval = yytext+1;
+ return STRING;
+ }
+[0-9]+ {
+ yylval.ival = strtol (yytext, 0, 10);
+ return INTEGER;
+ }
+(([0-9]+((\.[0-9]*(\{[0-9]+\})?)?))|(\.[0-9]+)|(\.[0-9]*\{[0-9]+\}))(([Ee][-+]?[0-9]+)?) {
+ yylval.dval = strtod (yytext, 0);
+ return DOUBLE;
+ }
+[a-zA-Z][0-9a-zA-Z_]* {
+ if (XftNameConstant (yytext, &yylval.ival))
+ return INTEGER;
+ yylval.sval = yytext;
+ return NAME;
+ }
+. ;
+"\n" ;
+%%
+static void
+_XftConfigSkipComment (void)
+{
+ int c;
+
+ c = input();
+ for (;;) {
+ while (c != EOF && c != '*')
+ c = input();
+ if (c == EOF)
+ return;
+ c = input();
+ if (c == EOF || c == '/')
+ return;
+ }
+}
+
+static void
+_XftConfigSkipLine (void)
+{
+ int c;
+
+ do {
+ c = input();
+ } while (c != EOF && c != '\n');
+ if (c == '\n') unput('\n');
+}
+
+Bool
+XftConfigLexFile(char *s)
+{
+ FILE *f;
+
+ f = fopen (s, "r");
+ if (f == 0)
+ {
+ fprintf (stderr, "cannot open file \"%s\"\n", s);
+ return False;
+ }
+ ++XftConfigFiledeep;
+ XftConfigInput = f;
+ XftConfigFile = s;
+ return True;
+}
+
+Bool
+XftConfigPushInput (char *s, Bool complain)
+{
+ FILE *f;
+ char *t;
+ char *h;
+
+ if (XftConfigInpt == XftConfigInStack)
+ {
+ (void) fprintf (stderr, "files nested too deeply\n");
+ return False;
+ }
+ t = s;
+ if (*s == '~')
+ {
+ h = getenv ("HOME");
+ if (h)
+ {
+ t = (char *) malloc (strlen (h) + strlen (s));
+ if (t)
+ {
+ strcpy (t, h);
+ strcat (t, s+1);
+ }
+ else
+ t = s;
+ }
+ }
+ f = fopen (t, "r");
+ if (t != s)
+ free (t);
+ if (f == 0)
+ {
+ if (complain)
+ (void) fprintf (stderr, "cannot open file %s\n", s);
+ return False;
+ }
+ ++XftConfigFiledeep;
+ *--XftConfigInpt = XftConfigInput;
+ *--XftConfigLinenopt = XftConfigLineno;
+ *--XftConfigFileNamePt = XftConfigFile;
+ XftConfigInput = f;
+ XftConfigLineno = 1;
+ XftConfigFile = _XftSaveString (s);
+ return True;
+}
+
+static int
+_XftConfigPopInput (void)
+{
+ int c;
+
+ for (;;)
+ {
+ c = getc (XftConfigInput);
+ if (c >= 0)
+ return c;
+ fclose (XftConfigInput);
+ XftConfigInput = 0;
+ if (XftConfigInpt == XftConfigInStack + XFT_CONFIG_IN_DEEP)
+ return EOF;
+ XftConfigInput = *XftConfigInpt++;
+ XftConfigLineno = *XftConfigLinenopt++;
+ free (XftConfigFile);
+ XftConfigFile = *XftConfigFileNamePt++;
+ --XftConfigFiledeep;
+ }
+}
+
+void
+XftConfigLexDone (void)
+{
+#ifdef FLEX_SCANNER
+ XftConfig_delete_buffer (XftConfig_current_buffer);
+#endif
+}
diff --git a/nx-X11/lib/Xft1/xftlist.c b/nx-X11/lib/Xft1/xftlist.c
new file mode 100644
index 000000000..dca5c42d1
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftlist.c
@@ -0,0 +1,166 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftlist.c,v 1.3 2002/06/21 06:15:14 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdlib.h>
+#include "xftint.h"
+#include <fontconfig/fcprivate.h>
+
+XftObjectSet *
+XftObjectSetCreate (void)
+{
+ return FcObjectSetCreate ();
+}
+
+Bool
+XftObjectSetAdd (XftObjectSet *os, const char *object)
+{
+ return FcObjectSetAdd (os, object);
+}
+
+void
+XftObjectSetDestroy (XftObjectSet *os)
+{
+ FcObjectSetDestroy (os);
+}
+
+
+XftObjectSet *
+XftObjectSetVaBuild (const char *first, va_list va)
+{
+ XftObjectSet *ret;
+
+ FcObjectSetVapBuild (ret, first, va);
+ return ret;
+}
+
+XftObjectSet *
+XftObjectSetBuild (const char *first, ...)
+{
+ va_list va;
+ XftObjectSet *os;
+
+ va_start (va, first);
+ FcObjectSetVapBuild (os, first, va);
+ va_end (va);
+ return os;
+}
+
+XftFontSet *
+XftListFontSets (XftFontSet **sets,
+ int nsets,
+ XftPattern *p,
+ XftObjectSet *os)
+{
+ return FcFontSetList (0, sets, nsets, p, os);
+}
+
+XftFontSet *
+XftListFontsPatternObjects (Display *dpy,
+ int screen,
+ XftPattern *pattern,
+ XftObjectSet *os)
+{
+ XftFontSet *sets[2];
+ int nsets = 0;
+#ifdef FREETYPE2
+ Bool core, render;
+ XftResult result;
+#endif
+ XftPattern *pattern_trim;
+ XftFontSet *ret;
+
+ if (!XftInit (0))
+ return 0;
+
+ pattern_trim = XftPatternDuplicate (pattern);
+ if (!pattern_trim)
+ return 0;
+
+ XftPatternDel (pattern_trim, XFT_CORE);
+ XftPatternDel (pattern_trim, XFT_RENDER);
+#ifdef FREETYPE2
+ render = core = False;
+ result = XftPatternGetBool (pattern, XFT_CORE, 0, &core);
+ if (result != XftResultMatch)
+ core = XftDefaultGetBool (dpy, XFT_CORE, screen,
+ !XftDefaultHasRender (dpy));
+
+ result = XftPatternGetBool (pattern, XFT_RENDER, 0, &render);
+ if (result != XftResultMatch)
+ render = XftDefaultGetBool (dpy, XFT_RENDER, screen,
+ XftDefaultHasRender (dpy));
+ if (render)
+ {
+ /*
+ * fontconfig fonts never include encoding values.
+ * deleting it is something of a kludge as it eliminates the
+ * ability to list core fonts and render fonts of a specific
+ * encoding. Fortunately, Xft1 apps generally don't want core
+ * fonts in any case.
+ */
+ XftPatternDel (pattern_trim, XFT_ENCODING);
+ if (XftInitFtLibrary())
+ {
+ sets[nsets] = _XftFontSet;
+ if (sets[nsets])
+ nsets++;
+ }
+ }
+ if (core)
+#endif
+ {
+ sets[nsets] = XftDisplayGetFontSet (dpy);
+ if (sets[nsets])
+ nsets++;
+ }
+ ret = XftListFontSets (sets, nsets, pattern_trim, os);
+ XftPatternDestroy (pattern_trim);
+ return ret;
+}
+
+XftFontSet *
+XftListFonts (Display *dpy,
+ int screen,
+ ...)
+{
+ va_list va;
+ XftFontSet *fs;
+ XftObjectSet *os;
+ XftPattern *pattern;
+ const char *first;
+
+ va_start (va, screen);
+
+ FcPatternVapBuild (pattern, 0, va);
+
+ first = va_arg (va, const char *);
+ FcObjectSetVapBuild (os, first, va);
+
+ va_end (va);
+
+ fs = XftListFontsPatternObjects (dpy, screen, pattern, os);
+ XftPatternDestroy (pattern);
+ XftObjectSetDestroy (os);
+ return fs;
+}
diff --git a/nx-X11/lib/Xft1/xftmatch.c b/nx-X11/lib/Xft1/xftmatch.c
new file mode 100644
index 000000000..f764abb9a
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftmatch.c
@@ -0,0 +1,37 @@
+/*
+ * $XFree86: xc/lib/Xft/xftmatch.c,v 1.6 2001/09/21 19:54:53 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <string.h>
+#include <ctype.h>
+#include "xftint.h"
+#include <stdio.h>
+
+XftPattern *
+XftFontSetMatch (XftFontSet **sets,
+ int nsets,
+ XftPattern *p,
+ XftResult *result)
+{
+ return FcFontSetMatch (0, sets, nsets, p, result);
+}
diff --git a/nx-X11/lib/Xft1/xftmatrix.c b/nx-X11/lib/Xft1/xftmatrix.c
new file mode 100644
index 000000000..7feeccc94
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftmatrix.c
@@ -0,0 +1,104 @@
+/*
+ * $XFree86: xc/lib/Xft/xftmatrix.c,v 1.1 2001/03/30 18:50:18 keithp Exp $
+ *
+ * Copyright © 2000 Tuomas J. Lukka
+ *
+ * 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 of Tuomas Lukka not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Tuomas Lukka makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * TUOMAS LUKKA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL TUOMAS LUKKA 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 <math.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "xftint.h"
+
+XftMatrix *
+_XftSaveMatrix (const XftMatrix *mat)
+{
+ XftMatrix *r;
+ if(!mat)
+ return 0;
+ r = (XftMatrix *) malloc (sizeof (*r) );
+ if (!r)
+ return 0;
+ *r = *mat;
+ return r;
+}
+
+int
+XftMatrixEqual (const XftMatrix *mat1, const XftMatrix *mat2)
+{
+ if(mat1 == mat2) return True;
+ if(mat1 == 0 || mat2 == 0) return False;
+ return mat1->xx == mat2->xx &&
+ mat1->xy == mat2->xy &&
+ mat1->yx == mat2->yx &&
+ mat1->yy == mat2->yy;
+}
+
+void
+XftMatrixMultiply (XftMatrix *result, XftMatrix *a, XftMatrix *b)
+{
+ XftMatrix r;
+
+ r.xx = a->xx * b->xx + a->xy * b->yx;
+ r.xy = a->xx * b->xy + a->xy * b->yy;
+ r.yx = a->yx * b->xx + a->yy * b->yx;
+ r.yy = a->yx * b->xy + a->yy * b->yy;
+ *result = r;
+}
+
+void
+XftMatrixRotate (XftMatrix *m, double c, double s)
+{
+ XftMatrix r;
+
+ /*
+ * X Coordinate system is upside down, swap to make
+ * rotations counterclockwise
+ */
+ r.xx = c;
+ r.xy = -s;
+ r.yx = s;
+ r.yy = c;
+ XftMatrixMultiply (m, &r, m);
+}
+
+void
+XftMatrixScale (XftMatrix *m, double sx, double sy)
+{
+ XftMatrix r;
+
+ r.xx = sx;
+ r.xy = 0;
+ r.yx = 0;
+ r.yy = sy;
+ XftMatrixMultiply (m, &r, m);
+}
+
+void
+XftMatrixShear (XftMatrix *m, double sh, double sv)
+{
+ XftMatrix r;
+
+ r.xx = 1;
+ r.xy = sh;
+ r.yx = sv;
+ r.yy = 1;
+ XftMatrixMultiply (m, &r, m);
+}
diff --git a/nx-X11/lib/Xft1/xftname.c b/nx-X11/lib/Xft1/xftname.c
new file mode 100644
index 000000000..a28e32cd9
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftname.c
@@ -0,0 +1,59 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftname.c,v 1.3tsi Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+XftPattern *
+XftNameParse (const char *name)
+{
+ return FcNameParse ((const FcChar8 *) name);
+}
+
+
+Bool
+XftNameUnparse (XftPattern *pat, char *dest, int len)
+{
+ FcChar8 *name = FcNameUnparse (pat);
+ if (!name)
+ return FcFalse;
+ if (strlen ((char *) name) > len - 1)
+ {
+ free (name);
+ return FcFalse;
+ }
+ strcpy (dest, (char *) name);
+ free (name);
+ return FcTrue;
+}
+
+Bool
+XftNameConstant (char *string, int *result)
+{
+ return FcNameConstant ((FcChar8 *) string, result);
+}
+
diff --git a/nx-X11/lib/Xft1/xftpat.c b/nx-X11/lib/Xft1/xftpat.c
new file mode 100644
index 000000000..611144c2d
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftpat.c
@@ -0,0 +1,243 @@
+/*
+ * $XFree86: xc/lib/Xft/xftpat.c,v 1.6 2001/03/30 18:50:18 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdlib.h>
+#include <string.h>
+#include "xftint.h"
+#include <fontconfig/fcprivate.h>
+
+XftPattern *
+XftPatternCreate (void)
+{
+ return FcPatternCreate ();
+}
+
+void
+XftValueDestroy (XftValue v)
+{
+ FcValueDestroy (v);
+}
+
+void
+XftPatternDestroy (XftPattern *p)
+{
+ FcPatternDestroy (p);
+}
+
+
+Bool
+XftPatternAdd (XftPattern *p, const char *object, XftValue value, Bool append)
+{
+ return FcPatternAdd (p, object, value, append);
+}
+
+Bool
+XftPatternDel (XftPattern *p, const char *object)
+{
+ return FcPatternDel (p, object);
+}
+
+Bool
+XftPatternAddInteger (XftPattern *p, const char *object, int i)
+{
+ XftValue v;
+
+ v.type = XftTypeInteger;
+ v.u.i = i;
+ return XftPatternAdd (p, object, v, True);
+}
+
+Bool
+XftPatternAddDouble (XftPattern *p, const char *object, double d)
+{
+ XftValue v;
+
+ v.type = XftTypeDouble;
+ v.u.d = d;
+ return XftPatternAdd (p, object, v, True);
+}
+
+
+Bool
+XftPatternAddString (XftPattern *p, const char *object, const char *s)
+{
+ XftValue v;
+
+ v.type = XftTypeString;
+ v.u.s = (FcChar8 *) s;
+ return XftPatternAdd (p, object, v, True);
+}
+
+Bool
+XftPatternAddMatrix (XftPattern *p, const char *object, const XftMatrix *s)
+{
+ XftValue v;
+
+ v.type = XftTypeMatrix;
+ v.u.m = (XftMatrix *) s;
+ return XftPatternAdd (p, object, v, True);
+}
+
+
+Bool
+XftPatternAddBool (XftPattern *p, const char *object, Bool b)
+{
+ XftValue v;
+
+ v.type = XftTypeBool;
+ v.u.b = b;
+ return XftPatternAdd (p, object, v, True);
+}
+
+XftResult
+XftPatternGet (XftPattern *p, const char *object, int id, XftValue *v)
+{
+ return FcPatternGet (p, object, id, v);
+}
+
+XftResult
+XftPatternGetInteger (XftPattern *p, const char *object, int id, int *i)
+{
+ XftValue v;
+ XftResult r;
+
+ r = XftPatternGet (p, object, id, &v);
+ if (r != XftResultMatch)
+ return r;
+ switch (v.type) {
+ case XftTypeDouble:
+ *i = (int) v.u.d;
+ break;
+ case XftTypeInteger:
+ *i = v.u.i;
+ break;
+ default:
+ return XftResultTypeMismatch;
+ }
+ return XftResultMatch;
+}
+
+XftResult
+XftPatternGetDouble (XftPattern *p, const char *object, int id, double *d)
+{
+ XftValue v;
+ XftResult r;
+
+ r = XftPatternGet (p, object, id, &v);
+ if (r != XftResultMatch)
+ return r;
+ switch (v.type) {
+ case XftTypeDouble:
+ *d = v.u.d;
+ break;
+ case XftTypeInteger:
+ *d = (double) v.u.i;
+ break;
+ default:
+ return XftResultTypeMismatch;
+ }
+ return XftResultMatch;
+}
+
+XftResult
+XftPatternGetString (XftPattern *p, const char *object, int id, char **s)
+{
+ XftValue v;
+ XftResult r;
+
+ r = XftPatternGet (p, object, id, &v);
+ if (r != XftResultMatch)
+ return r;
+ if (v.type != XftTypeString)
+ return XftResultTypeMismatch;
+ *s = (char *) v.u.s;
+ return XftResultMatch;
+}
+
+XftResult
+XftPatternGetMatrix (XftPattern *p, const char *object, int id, XftMatrix **m)
+{
+ XftValue v;
+ XftResult r;
+
+ r = XftPatternGet (p, object, id, &v);
+ if (r != XftResultMatch)
+ return r;
+ if (v.type != XftTypeMatrix)
+ return XftResultTypeMismatch;
+ *m = (XftMatrix *) v.u.m;
+ return XftResultMatch;
+}
+
+
+XftResult
+XftPatternGetBool (XftPattern *p, const char *object, int id, Bool *b)
+{
+ XftValue v;
+ XftResult r;
+
+ r = XftPatternGet (p, object, id, &v);
+ if (r != XftResultMatch)
+ return r;
+ if (v.type != XftTypeBool)
+ return XftResultTypeMismatch;
+ *b = v.u.b;
+ return XftResultMatch;
+}
+
+XftPatternElt *
+XftPatternFind (XftPattern *p, const char *object, FcBool insert)
+{
+ if (insert)
+ return FcPatternInsertElt (p, object);
+ else
+ return FcPatternFindElt (p, object);
+}
+
+
+XftPattern *
+XftPatternDuplicate (XftPattern *orig)
+{
+ return FcPatternDuplicate (orig);
+}
+
+XftPattern *
+XftPatternVaBuild (XftPattern *orig, va_list va)
+{
+ XftPattern *ret;
+
+ FcPatternVapBuild (ret, orig, va);
+ return ret;
+}
+
+XftPattern *
+XftPatternBuild (XftPattern *orig, ...)
+{
+ va_list va;
+
+ va_start (va, orig);
+ FcPatternVapBuild (orig, orig, va);
+ va_end (va);
+ return orig;
+}
diff --git a/nx-X11/lib/Xft1/xftrender.c b/nx-X11/lib/Xft1/xftrender.c
new file mode 100644
index 000000000..419ae9f8a
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftrender.c
@@ -0,0 +1,527 @@
+/*
+ * $XFree86: xc/lib/Xft/xftrender.c,v 1.8 2001/07/13 18:16:10 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdlib.h>
+#include "xftint.h"
+
+void
+XftRenderString8 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar8 *string, int len)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar8 *s;
+ int l;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l--)
+ XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+ XRenderCompositeString8 (dpy, PictOpOver, src, dst,
+ font->format, font->glyphset,
+ srcx, srcy, x, y, (char *) string, len);
+}
+
+void
+XftRenderString16 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar16 *string, int len)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar16 *s;
+ int l;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l--)
+ XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+ XRenderCompositeString16 (dpy, PictOpOver, src, dst,
+ font->format, font->glyphset,
+ srcx, srcy, x, y, string, len);
+}
+
+void
+XftRenderString32 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar32 *string, int len)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar32 *s;
+ int l;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l--)
+ XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+ XRenderCompositeString32 (dpy, PictOpOver, src, dst,
+ font->format, font->glyphset,
+ srcx, srcy, x, y, string, len);
+}
+
+void
+XftRenderStringUtf8 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar8 *string, int len)
+{
+ XftChar8 *s;
+ XftChar32 c;
+ XftChar32 lbuf[4096];
+ XftChar32 *d;
+ XftChar8 *dst8;
+ XftChar16 *dst16;
+ XftChar32 *dst32;
+ int rlen, clen;
+ int width = 1;
+ int n;
+
+ /* compute needed width */
+ if (!XftUtf8Len (string, len, &n, &width))
+ return;
+
+ d = lbuf;
+ if (n * width > sizeof (lbuf))
+ {
+ d = (XftChar32 *) malloc (n * width);
+ if (!d)
+ return;
+ }
+
+ switch (width) {
+ case 4:
+ s = string;
+ rlen = len;
+ dst32 = d;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (s, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ return;
+ *dst32++ = c;
+ s += clen;
+ rlen -= clen;
+ }
+ dst32 = d;
+ XftRenderString32 (dpy, src, font, dst, srcx, srcy, x, y,
+ dst32, n);
+ break;
+ case 2:
+ s = string;
+ rlen = len;
+ dst16 = (XftChar16 *) d;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (s, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ return;
+ *dst16++ = c;
+ s += clen;
+ rlen -= clen;
+ }
+ dst16 = (XftChar16 *) d;
+ XftRenderString16 (dpy, src, font, dst, srcx, srcy, x, y,
+ dst16, n);
+ break;
+ case 1:
+ s = string;
+ rlen = len;
+ dst8 = (XftChar8 *) d;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (s, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ return;
+ *dst8++ = c;
+ s += clen;
+ rlen -= clen;
+ }
+ dst8 = (XftChar8 *) d;
+ XftRenderString8 (dpy, src, font, dst, srcx, srcy, x, y,
+ dst8, n);
+ break;
+ }
+ if (d != lbuf)
+ free (d);
+}
+
+void
+XftRenderExtents8 (Display *dpy,
+ XftFontStruct *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar8 *s, c;
+ int l;
+ XGlyphInfo *gi;
+ int x, y;
+ int left, right, top, bottom;
+ int overall_left, overall_right;
+ int overall_top, overall_bottom;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l--)
+ XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+
+ gi = 0;
+ while (len)
+ {
+ c = *string++;
+ len--;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (gi)
+ break;
+ }
+ if (len == 0 && !gi)
+ {
+ extents->width = 0;
+ extents->height = 0;
+ extents->x = 0;
+ extents->y = 0;
+ extents->yOff = 0;
+ extents->xOff = 0;
+ return;
+ }
+ x = 0;
+ y = 0;
+ overall_left = x - gi->x;
+ overall_top = y - gi->y;
+ overall_right = overall_left + (int) gi->width;
+ overall_bottom = overall_top + (int) gi->height;
+ x += gi->xOff;
+ y += gi->yOff;
+ while (len--)
+ {
+ c = *string++;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (!gi)
+ continue;
+ left = x - gi->x;
+ top = y - gi->y;
+ right = left + (int) gi->width;
+ bottom = top + (int) gi->height;
+ if (left < overall_left)
+ overall_left = left;
+ if (top < overall_top)
+ overall_top = top;
+ if (right > overall_right)
+ overall_right = right;
+ if (bottom > overall_bottom)
+ overall_bottom = bottom;
+ x += gi->xOff;
+ y += gi->yOff;
+ }
+ extents->x = -overall_left;
+ extents->y = -overall_top;
+ extents->width = overall_right - overall_left;
+ extents->height = overall_bottom - overall_top;
+ extents->xOff = x;
+ extents->yOff = y;
+}
+
+void
+XftRenderExtents16 (Display *dpy,
+ XftFontStruct *font,
+ XftChar16 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar16 *s, c;
+ int l;
+ XGlyphInfo *gi;
+ int x, y;
+ int left, right, top, bottom;
+ int overall_left, overall_right;
+ int overall_top, overall_bottom;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l--)
+ XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+
+ gi = 0;
+ while (len)
+ {
+ c = *string++;
+ len--;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (gi)
+ break;
+ }
+ if (len == 0 && !gi)
+ {
+ extents->width = 0;
+ extents->height = 0;
+ extents->x = 0;
+ extents->y = 0;
+ extents->yOff = 0;
+ extents->xOff = 0;
+ return;
+ }
+ x = 0;
+ y = 0;
+ overall_left = x - gi->x;
+ overall_top = y - gi->y;
+ overall_right = overall_left + (int) gi->width;
+ overall_bottom = overall_top + (int) gi->height;
+ x += gi->xOff;
+ y += gi->yOff;
+ while (len--)
+ {
+ c = *string++;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (!gi)
+ continue;
+ left = x - gi->x;
+ top = y - gi->y;
+ right = left + (int) gi->width;
+ bottom = top + (int) gi->height;
+ if (left < overall_left)
+ overall_left = left;
+ if (top < overall_top)
+ overall_top = top;
+ if (right > overall_right)
+ overall_right = right;
+ if (bottom > overall_bottom)
+ overall_bottom = bottom;
+ x += gi->xOff;
+ y += gi->yOff;
+ }
+ extents->x = -overall_left;
+ extents->y = -overall_top;
+ extents->width = overall_right - overall_left;
+ extents->height = overall_bottom - overall_top;
+ extents->xOff = x;
+ extents->yOff = y;
+}
+
+void
+XftRenderExtents32 (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar32 *s, c;
+ int l;
+ XGlyphInfo *gi;
+ int x, y;
+ int left, right, top, bottom;
+ int overall_left, overall_right;
+ int overall_top, overall_bottom;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l--)
+ XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+
+ gi = 0;
+ while (len)
+ {
+ c = *string++;
+ len--;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (gi)
+ break;
+ }
+ if (len == 0 && !gi)
+ {
+ extents->width = 0;
+ extents->height = 0;
+ extents->x = 0;
+ extents->y = 0;
+ extents->yOff = 0;
+ extents->xOff = 0;
+ return;
+ }
+ x = 0;
+ y = 0;
+ overall_left = x - gi->x;
+ overall_top = y - gi->y;
+ overall_right = overall_left + (int) gi->width;
+ overall_bottom = overall_top + (int) gi->height;
+ x += gi->xOff;
+ y += gi->yOff;
+ while (len--)
+ {
+ c = *string++;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (!gi)
+ continue;
+ left = x - gi->x;
+ top = y - gi->y;
+ right = left + (int) gi->width;
+ bottom = top + (int) gi->height;
+ if (left < overall_left)
+ overall_left = left;
+ if (top < overall_top)
+ overall_top = top;
+ if (right > overall_right)
+ overall_right = right;
+ if (bottom > overall_bottom)
+ overall_bottom = bottom;
+ x += gi->xOff;
+ y += gi->yOff;
+ }
+ extents->x = -overall_left;
+ extents->y = -overall_top;
+ extents->width = overall_right - overall_left;
+ extents->height = overall_bottom - overall_top;
+ extents->xOff = x;
+ extents->yOff = y;
+}
+
+void
+XftRenderExtentsUtf8 (Display *dpy,
+ XftFontStruct *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar8 *s;
+ XftChar32 c;
+ int l, clen;
+ XGlyphInfo *gi;
+ int x, y;
+ int left, right, top, bottom;
+ int overall_left, overall_right;
+ int overall_top, overall_bottom;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l)
+ {
+ clen = XftUtf8ToUcs4 (s, &c, l);
+ if (clen < 0)
+ break;
+ XftGlyphCheck (dpy, font, (XftChar32) c, missing, &nmissing);
+ s += clen;
+ l -= clen;
+ }
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+
+ gi = 0;
+ while (len)
+ {
+ clen = XftUtf8ToUcs4 (string, &c, len);
+ if (clen < 0)
+ {
+ len = 0;
+ break;
+ }
+ len -= clen;
+ string += clen;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (gi)
+ break;
+ }
+ if (len == 0 && !gi)
+ {
+ extents->width = 0;
+ extents->height = 0;
+ extents->x = 0;
+ extents->y = 0;
+ extents->yOff = 0;
+ extents->xOff = 0;
+ return;
+ }
+ x = 0;
+ y = 0;
+ overall_left = x - gi->x;
+ overall_top = y - gi->y;
+ overall_right = overall_left + (int) gi->width;
+ overall_bottom = overall_top + (int) gi->height;
+ x += gi->xOff;
+ y += gi->yOff;
+ while (len)
+ {
+ clen = XftUtf8ToUcs4 (string, &c, len);
+ if (clen < 0)
+ break;
+ len -= clen;
+ string += clen;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (!gi)
+ continue;
+ left = x - gi->x;
+ top = y - gi->y;
+ right = left + (int) gi->width;
+ bottom = top + (int) gi->height;
+ if (left < overall_left)
+ overall_left = left;
+ if (top < overall_top)
+ overall_top = top;
+ if (right > overall_right)
+ overall_right = right;
+ if (bottom > overall_bottom)
+ overall_bottom = bottom;
+ x += gi->xOff;
+ y += gi->yOff;
+ }
+ extents->x = -overall_left;
+ extents->y = -overall_top;
+ extents->width = overall_right - overall_left;
+ extents->height = overall_bottom - overall_top;
+ extents->xOff = x;
+ extents->yOff = y;
+}
diff --git a/nx-X11/lib/Xft1/xftstr.c b/nx-X11/lib/Xft1/xftstr.c
new file mode 100644
index 000000000..af6013764
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftstr.c
@@ -0,0 +1,259 @@
+/*
+ * $XFree86: xc/lib/Xft/xftstr.c,v 1.6 2001/04/01 14:00:01 tsi Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include "xftint.h"
+
+char *
+_XftSaveString (const char *s)
+{
+ char *r;
+
+ if (!s)
+ return 0;
+ r = (char *) malloc (strlen (s) + 1);
+ if (!r)
+ return 0;
+ strcpy (r, s);
+ return r;
+}
+
+const char *
+_XftGetInt(const char *ptr, int *val)
+{
+ if (*ptr == '*') {
+ *val = -1;
+ ptr++;
+ } else
+ for (*val = 0; *ptr >= '0' && *ptr <= '9';)
+ *val = *val * 10 + *ptr++ - '0';
+ if (*ptr == '-')
+ return ptr;
+ return (char *) 0;
+}
+
+char *
+_XftSplitStr (const char *field, char *save)
+{
+ char *s = save;
+ char c;
+
+ while (*field)
+ {
+ if (*field == '-')
+ break;
+ c = *field++;
+ *save++ = c;
+ }
+ *save = 0;
+ return s;
+}
+
+char *
+_XftDownStr (const char *field, char *save)
+{
+ char *s = save;
+ char c;
+
+ while (*field)
+ {
+ c = *field++;
+ *save++ = c;
+ }
+ *save = 0;
+ return s;
+}
+
+const char *
+_XftSplitField (const char *field, char *save)
+{
+ char c;
+
+ while (*field)
+ {
+ if (*field == '-' || *field == '=')
+ break;
+ c = *field++;
+ *save++ = c;
+ }
+ *save = 0;
+ return field;
+}
+
+const char *
+_XftSplitValue (const char *field, char *save)
+{
+ char c;
+
+ while (*field)
+ {
+ if (*field == '-' || *field == ',')
+ break;
+ c = *field++;
+ *save++ = c;
+ }
+ *save = 0;
+ if (*field)
+ field++;
+ return field;
+}
+
+int
+_XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def)
+{
+ while (n--)
+ {
+ if (!_XftStrCmpIgnoreCase (s->name, name))
+ return s->value;
+ s++;
+ }
+ return def;
+}
+
+int
+_XftStrCmpIgnoreCase (const char *s1, const char *s2)
+{
+ char c1, c2;
+
+ for (;;)
+ {
+ c1 = *s1++;
+ c2 = *s2++;
+ if (!c1 || !c2)
+ break;
+ if (isupper (c1))
+ c1 = tolower (c1);
+ if (isupper (c2))
+ c2 = tolower (c2);
+ if (c1 != c2)
+ break;
+ }
+ return (int) c2 - (int) c1;
+}
+
+int
+XftUtf8ToUcs4 (XftChar8 *src_orig,
+ XftChar32 *dst,
+ int len)
+{
+ XftChar8 *src = src_orig;
+ XftChar8 s;
+ int extra;
+ XftChar32 result;
+
+ if (len == 0)
+ return 0;
+
+ s = *src++;
+ len--;
+
+ if (!(s & 0x80))
+ {
+ result = s;
+ extra = 0;
+ }
+ else if (!(s & 0x40))
+ {
+ return -1;
+ }
+ else if (!(s & 0x20))
+ {
+ result = s & 0x1f;
+ extra = 1;
+ }
+ else if (!(s & 0x10))
+ {
+ result = s & 0xf;
+ extra = 2;
+ }
+ else if (!(s & 0x08))
+ {
+ result = s & 0x07;
+ extra = 3;
+ }
+ else if (!(s & 0x04))
+ {
+ result = s & 0x03;
+ extra = 4;
+ }
+ else if ( ! (s & 0x02))
+ {
+ result = s & 0x01;
+ extra = 5;
+ }
+ else
+ {
+ return -1;
+ }
+ if (extra > len)
+ return -1;
+
+ while (extra--)
+ {
+ result <<= 6;
+ s = *src++;
+
+ if ((s & 0xc0) != 0x80)
+ return -1;
+
+ result |= s & 0x3f;
+ }
+ *dst = result;
+ return src - src_orig;
+}
+
+Bool
+XftUtf8Len (XftChar8 *string,
+ int len,
+ int *nchar,
+ int *wchar)
+{
+ int n;
+ int clen;
+ int width = 1;
+ XftChar32 c;
+
+ n = 0;
+ while (len)
+ {
+ clen = XftUtf8ToUcs4 (string, &c, len);
+ if (clen <= 0) /* malformed UTF8 string */
+ return False;
+ if (c >= 0x10000)
+ width = 4;
+ else if (c >= 0x100)
+ {
+ if (width == 1)
+ width = 2;
+ }
+ string += clen;
+ len -= clen;
+ n++;
+ }
+ *nchar = n;
+ *wchar = width;
+ return True;
+}
diff --git a/nx-X11/lib/Xft1/xftxlfd.c b/nx-X11/lib/Xft1/xftxlfd.c
new file mode 100644
index 000000000..8de596b47
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftxlfd.c
@@ -0,0 +1,334 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftxlfd.c,v 1.1.1.1tsi Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "xftint.h"
+
+static XftSymbolic XftXlfdWeights[] = {
+ { "light", XFT_WEIGHT_LIGHT },
+ { "medium", XFT_WEIGHT_MEDIUM },
+ { "regular", XFT_WEIGHT_MEDIUM },
+ { "demibold", XFT_WEIGHT_DEMIBOLD },
+ { "bold", XFT_WEIGHT_BOLD },
+ { "black", XFT_WEIGHT_BLACK },
+};
+
+#define NUM_XLFD_WEIGHTS (sizeof XftXlfdWeights/sizeof XftXlfdWeights[0])
+
+static XftSymbolic XftXlfdSlants[] = {
+ { "r", XFT_SLANT_ROMAN },
+ { "i", XFT_SLANT_ITALIC },
+ { "o", XFT_SLANT_OBLIQUE },
+};
+
+#define NUM_XLFD_SLANTS (sizeof XftXlfdSlants/sizeof XftXlfdSlants[0])
+
+XftPattern *
+XftXlfdParse (const char *xlfd_orig, Bool ignore_scalable, Bool complete)
+{
+ XftPattern *pat;
+ const char *xlfd = xlfd_orig;
+ const char *foundry;
+ const char *family;
+ const char *weight_name;
+ const char *slant;
+ const char *registry;
+ char *save;
+ char style[128];
+ int pixel;
+ int point;
+ int resx;
+ int resy;
+ int slant_value, weight_value;
+ double dpixel;
+
+ if (*xlfd != '-')
+ return 0;
+ if (!(xlfd = strchr (foundry = ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (family = ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (weight_name = ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (slant = ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (/* setwidth_name = */ ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (/* add_style_name = */ ++xlfd, '-'))) return 0;
+ if (!(xlfd = _XftGetInt (++xlfd, &pixel))) return 0;
+ if (!(xlfd = _XftGetInt (++xlfd, &point))) return 0;
+ if (!(xlfd = _XftGetInt (++xlfd, &resx))) return 0;
+ if (!(xlfd = _XftGetInt (++xlfd, &resy))) return 0;
+ if (!(xlfd = strchr (/* spacing = */ ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (/* average_width = */ ++xlfd, '-'))) return 0;
+ if (!(xlfd = strchr (registry = ++xlfd, '-'))) return 0;
+ /* make sure no fields follow this one */
+ if ((xlfd = strchr (/* encoding = */ ++xlfd, '-'))) return 0;
+
+ if (ignore_scalable && !pixel)
+ return 0;
+
+ pat = XftPatternCreate ();
+ if (!pat)
+ return 0;
+
+ save = (char *) malloc (strlen (foundry) + 1);
+
+ if (!save)
+ return 0;
+
+ if (!XftPatternAddString (pat, XFT_XLFD, xlfd_orig)) goto bail;
+
+ _XftSplitStr (foundry, save);
+ if (save[0] && strcmp (save, "*") != 0)
+ if (!XftPatternAddString (pat, XFT_FOUNDRY, save)) goto bail;
+
+ _XftSplitStr (family, save);
+ if (save[0] && strcmp (save, "*") != 0)
+ if (!XftPatternAddString (pat, XFT_FAMILY, save)) goto bail;
+
+ weight_value = _XftMatchSymbolic (XftXlfdWeights, NUM_XLFD_WEIGHTS,
+ _XftSplitStr (weight_name, save),
+ XFT_WEIGHT_MEDIUM);
+ if (!XftPatternAddInteger (pat, XFT_WEIGHT, weight_value))
+ goto bail;
+
+ slant_value = _XftMatchSymbolic (XftXlfdSlants, NUM_XLFD_SLANTS,
+ _XftSplitStr (slant, save),
+ XFT_SLANT_ROMAN);
+ if (!XftPatternAddInteger (pat, XFT_SLANT, slant_value))
+ goto bail;
+
+ dpixel = (double) pixel;
+
+ if (complete)
+ {
+ /*
+ * Build a style name
+ */
+ style[0] = '\0';
+ switch (weight_value) {
+ case XFT_WEIGHT_LIGHT: strcat (style, "light"); break;
+ case XFT_WEIGHT_DEMIBOLD: strcat (style, "demibold"); break;
+ case XFT_WEIGHT_BOLD: strcat (style, "bold"); break;
+ case XFT_WEIGHT_BLACK: strcat (style, "black"); break;
+ }
+ if (slant_value != XFT_SLANT_ROMAN) {
+ if (style[0])
+ strcat (style, " ");
+ switch (slant_value) {
+ case XFT_SLANT_ITALIC: strcat (style, "italic"); break;
+ case XFT_SLANT_OBLIQUE: strcat (style, "oblique"); break;
+ }
+ }
+ if (!style[0])
+ strcat (style, "Regular");
+
+ if (!XftPatternAddString (pat, XFT_STYLE, style))
+ goto bail;
+ if (!XftPatternAddBool (pat, XFT_SCALABLE, pixel == 0)) goto bail;
+ if (!XftPatternAddBool (pat, XFT_CORE, True)) goto bail;
+ if (!XftPatternAddBool (pat, XFT_ANTIALIAS, False)) goto bail;
+ }
+ else
+ {
+ if (point > 0)
+ {
+ if (!XftPatternAddDouble (pat, XFT_SIZE, ((double) point) / 10.0)) goto bail;
+ if (pixel <= 0 && resy > 0)
+ {
+ dpixel = (double) point * (double) resy / 720.0;
+ }
+ }
+ }
+
+ if (dpixel > 0)
+ if (!XftPatternAddDouble (pat, XFT_PIXEL_SIZE, dpixel)) goto bail;
+
+ _XftDownStr (registry, save);
+ if (registry[0] && !strchr (registry, '*'))
+ if (!XftPatternAddString (pat, XFT_ENCODING, save)) goto bail;
+
+ free (save);
+ return pat;
+
+bail:
+ free (save);
+ XftPatternDestroy (pat);
+ return 0;
+}
+
+Bool
+XftCoreAddFonts (XftFontSet *set, Display *dpy, Bool ignore_scalable)
+{
+ char **xlfds;
+ int num;
+ int i;
+ XftPattern *font;
+ Bool ret;
+
+ xlfds = XListFonts (dpy,
+ "-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
+ 10000, &num);
+ if (!xlfds)
+ return False;
+ ret = True;
+ for (i = 0; ret && i < num; i++)
+ {
+ font = XftXlfdParse (xlfds[i], ignore_scalable, True);
+ if (font)
+ {
+ if (!XftFontSetAdd (set, font))
+ {
+ XftPatternDestroy (font);
+ ret = False;
+ }
+ }
+ }
+ XFreeFontNames (xlfds);
+ return ret;
+}
+
+typedef struct _XftCoreFont {
+ struct _XftCoreFont *next;
+ int ref;
+
+ XFontStruct *font;
+ Display *display;
+ char *xlfd;
+} XftCoreFont;
+
+static XftCoreFont *_XftCoreFonts;
+
+XFontStruct*
+XftCoreOpen (Display *dpy, XftPattern *pattern)
+{
+ XftCoreFont *cf;
+ char *xlfd;
+ char *xlfd_pixel = 0;
+ char *i, *o;
+ int d;
+ Bool scalable;
+ double pixel_size;
+ int pixel_int;
+ XFontStruct *ret;
+
+#if 0
+ printf ("Core ");
+ XftPatternPrint (pattern);
+#endif
+ if (XftPatternGetString (pattern, XFT_XLFD, 0, &xlfd) != XftResultMatch)
+ return 0;
+ if (XftPatternGetBool (pattern, XFT_SCALABLE, 0, &scalable) != XftResultMatch)
+ return 0;
+ if (scalable)
+ {
+ if (XftPatternGetDouble (pattern, XFT_PIXEL_SIZE, 0, &pixel_size) != XftResultMatch)
+ return 0;
+ pixel_int = (int) (pixel_size + 0.5);
+ if (pixel_int)
+ {
+ xlfd_pixel = (char *) malloc (strlen (xlfd) + 32);
+ i = xlfd;
+ o = xlfd_pixel;
+ d = 0;
+ while (d != 7 && *i)
+ {
+ if ((*o++ = *i++) == '-')
+ d++;
+ }
+ if (*i)
+ {
+ sprintf (o, "%d", pixel_int);
+ o += strlen (o);
+ while (*i != '-')
+ ++i;
+ }
+ while ((*o++ = *i++));
+#if 0
+ printf ("original %s sized %s\n", xlfd, xlfd_pixel);
+#endif
+ xlfd = xlfd_pixel;
+ }
+ }
+ for (cf = _XftCoreFonts; cf; cf = cf->next)
+ {
+ if (cf->display == dpy &&
+ !_XftStrCmpIgnoreCase (cf->xlfd, xlfd))
+ {
+ cf->ref++;
+ if (_XftFontDebug () & XFT_DBG_REF)
+ {
+ printf ("Xlfd \"%s\" matches existing font (%d)\n",
+ xlfd, cf->ref);
+ }
+ break;
+ }
+ }
+ if (!cf)
+ {
+ ret = XLoadQueryFont (dpy, xlfd);
+ if (!ret)
+ return 0;
+
+ cf = (XftCoreFont *) malloc (sizeof (XftCoreFont) +
+ strlen (xlfd) + 1);
+ if (!cf)
+ {
+ XFreeFont (dpy, ret);
+ return 0;
+ }
+
+ if (_XftFontDebug () & XFT_DBG_REF)
+ printf ("Xlfd \"%s\" matches new font\n", xlfd);
+
+ cf->next = _XftCoreFonts;
+ _XftCoreFonts = cf;
+ cf->ref = 1;
+
+ cf->font = ret;
+ cf->xlfd = (char *) (cf + 1);
+ strcpy (cf->xlfd, xlfd);
+ }
+ if (xlfd_pixel)
+ free (xlfd_pixel);
+ return cf->font;
+}
+
+void
+XftCoreClose (Display *dpy, XFontStruct *font)
+{
+ XftCoreFont *cf, **prev;
+
+ for (prev = &_XftCoreFonts; (cf = *prev); prev = &cf->next)
+ {
+ if (cf->display == dpy && cf->font == font)
+ {
+ if (--cf->ref == 0)
+ {
+ XFreeFont (dpy, cf->font);
+ *prev = cf->next;
+ free (cf);
+ }
+ break;
+ }
+ }
+}
diff --git a/nx-X11/lib/Xi/Imakefile b/nx-X11/lib/Xi/Imakefile
new file mode 100644
index 000000000..365d78280
--- /dev/null
+++ b/nx-X11/lib/Xi/Imakefile
@@ -0,0 +1,107 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:45:53 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/Xi/Imakefile,v 1.4 2001/01/17 19:42:47 dawes Exp $
+
+#define DoNormalLib NormalLibXi
+#define DoSharedLib SharedLibXi
+#define DoExtraLib SharedLibXi
+#define DoDebugLib DebugLibXi
+#define DoProfileLib ProfileLibXi
+#define LibName Xi
+#define SoRev SOXINPUTREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXiReqs
+REQUIREDLIBS = SharedXiReqs
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+SRCS = XAllowDv.c \
+ XChgDCtl.c \
+ XChgFCtl.c \
+ XChgKbd.c \
+ XChgKMap.c \
+ XChgPnt.c \
+ XChgProp.c \
+ XCloseDev.c \
+ XDevBell.c \
+ XExtToWire.c \
+ XGetBMap.c \
+ XGetDCtl.c \
+ XGetFCtl.c \
+ XGetKMap.c \
+ XGetMMap.c \
+ XGetProp.c \
+ XGetVers.c \
+ XGMotion.c \
+ XGrabDev.c \
+ XGrDvBut.c \
+ XGrDvKey.c \
+ XGtFocus.c \
+ XGtSelect.c \
+ XListDev.c \
+ XOpenDev.c \
+ XQueryDv.c \
+ XSelect.c \
+ XSetBMap.c \
+ XSetDVal.c \
+ XSetMMap.c \
+ XSetMode.c \
+ XSndExEv.c \
+ XStFocus.c \
+ XUngrDev.c \
+ XUngrDvB.c \
+ XUngrDvK.c \
+ XExtInt.c
+OBJS = XAllowDv.o \
+ XChgDCtl.o \
+ XChgFCtl.o \
+ XChgKbd.o \
+ XChgKMap.o \
+ XChgPnt.o \
+ XChgProp.o \
+ XCloseDev.o \
+ XDevBell.o \
+ XExtToWire.o \
+ XGetBMap.o \
+ XGetDCtl.o \
+ XGetFCtl.o \
+ XGetKMap.o \
+ XGetMMap.o \
+ XGetProp.o \
+ XGetVers.o \
+ XGMotion.o \
+ XGrabDev.o \
+ XGrDvBut.o \
+ XGrDvKey.o \
+ XGtFocus.o \
+ XGtSelect.o \
+ XListDev.o \
+ XOpenDev.o \
+ XQueryDv.o \
+ XSelect.o \
+ XSetBMap.o \
+ XSetDVal.o \
+ XSetMMap.o \
+ XSetMode.o \
+ XSndExEv.o \
+ XStFocus.o \
+ XUngrDev.o \
+ XUngrDvB.o \
+ XUngrDvK.o \
+ XExtInt.o
+
+ LINTLIBS = $(LINTXLIB) $(LINTXEXT)
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/Xi/XAllowDv.c b/nx-X11/lib/Xi/XAllowDv.c
new file mode 100644
index 000000000..d74504608
--- /dev/null
+++ b/nx-X11/lib/Xi/XAllowDv.c
@@ -0,0 +1,88 @@
+/* $Xorg: XAllowDv.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XAllowDv.c,v 3.3 2001/12/14 19:55:03 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XAllowDeviceEvents - Thaw a frozen extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XAllowDeviceEvents (dpy, dev, event_mode, time)
+ register Display *dpy;
+ XDevice *dev;
+ int event_mode;
+ Time time;
+ {
+ xAllowDeviceEventsReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(AllowDeviceEvents,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_AllowDeviceEvents;
+ req->deviceid = dev->device_id;
+ req->mode = event_mode;
+ req->time = time;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/nx-X11/lib/Xi/XChgDCtl.c b/nx-X11/lib/Xi/XChgDCtl.c
new file mode 100644
index 000000000..b1fd7a18b
--- /dev/null
+++ b/nx-X11/lib/Xi/XChgDCtl.c
@@ -0,0 +1,130 @@
+/* $Xorg: XChgDCtl.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XChgDCtl.c,v 3.3 2001/12/14 19:55:03 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XChangeDeviceControl - Change the control attributes of an extension
+ * input device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XChangeDeviceControl (dpy, dev, control, d)
+ register Display *dpy;
+ XDevice *dev;
+ int control;
+ XDeviceControl *d;
+ {
+ int length;
+ xChangeDeviceControlReq *req;
+ xChangeDeviceControlReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Add_XChangeDeviceControl) == -1)
+ return (NoSuchExtension);
+
+ GetReq(ChangeDeviceControl,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ChangeDeviceControl;
+ req->deviceid = dev->device_id;
+ req->control = control;
+
+ switch (control)
+ {
+ case DEVICE_RESOLUTION:
+ {
+ XDeviceResolutionControl *R;
+ xDeviceResolutionCtl r;
+
+ R = (XDeviceResolutionControl *) d;
+ r.control = DEVICE_RESOLUTION;
+ r.length = sizeof (xDeviceResolutionCtl) +
+ R->num_valuators * sizeof(int);
+ r.first_valuator = R->first_valuator;
+ r.num_valuators = R->num_valuators;
+ req->length += ((unsigned)(r.length + 3) >> 2);
+ length = sizeof (xDeviceResolutionCtl);
+ Data (dpy, (char *) &r, length);
+ length = r.num_valuators * sizeof(int);
+ Data (dpy, (char *) R->resolutions, length);
+ if (! _XReply (dpy, (xReply *) &rep, 0, xTrue))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (NoSuchExtension);
+ }
+ else
+ return (rep.status);
+ }
+ default:
+ {
+ xDeviceCtl u;
+
+ u.control = d->control;
+ u.length = d->length - sizeof (int);
+ length = ((unsigned)(u.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &u, length);
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/nx-X11/lib/Xi/XChgFCtl.c b/nx-X11/lib/Xi/XChgFCtl.c
new file mode 100644
index 000000000..8f4c009c0
--- /dev/null
+++ b/nx-X11/lib/Xi/XChgFCtl.c
@@ -0,0 +1,207 @@
+/* $Xorg: XChgFCtl.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XChgFCtl.c,v 3.3 2001/12/14 19:55:03 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XChangeFeedbackControl - Change the control attributes of feedbacks on
+ * an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XChangeFeedbackControl (dpy, dev, mask, f)
+ register Display *dpy;
+ XDevice *dev;
+ unsigned long mask;
+ XFeedbackControl *f;
+ {
+ int length;
+ xChangeFeedbackControlReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(ChangeFeedbackControl,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ChangeFeedbackControl;
+ req->deviceid = dev->device_id;
+ req->mask = mask;
+ req->feedbackid = f->class;
+
+ if (f->class == KbdFeedbackClass)
+ {
+ XKbdFeedbackControl *K;
+ xKbdFeedbackCtl k;
+
+ K = (XKbdFeedbackControl *) f;
+ k.class = KbdFeedbackClass;
+ k.length = sizeof (xKbdFeedbackCtl);
+ k.id = K->id;
+ k.click = K->click;
+ k.percent = K->percent;
+ k.pitch = K->pitch;
+ k.duration = K->duration;
+ k.led_mask = K->led_mask;
+ k.led_values = K->led_value;
+ k.key = K->key;
+ k.auto_repeat_mode = K->auto_repeat_mode;
+ length = ((unsigned)(k.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &k, length);
+ }
+ else if (f->class == PtrFeedbackClass)
+ {
+ XPtrFeedbackControl *P;
+ xPtrFeedbackCtl p;
+
+ P = (XPtrFeedbackControl *) f;
+ p.class = PtrFeedbackClass;
+ p.length = sizeof (xPtrFeedbackCtl);
+ p.id = P->id;
+ p.num = P->accelNum;
+ p.denom = P->accelDenom;
+ p.thresh = P->threshold;
+ length = ((unsigned)(p.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &p, length);
+ }
+ else if (f->class == IntegerFeedbackClass)
+ {
+ XIntegerFeedbackControl *I;
+ xIntegerFeedbackCtl i;
+
+ I = (XIntegerFeedbackControl *) f;
+ i.class = IntegerFeedbackClass;
+ i.length = sizeof (xIntegerFeedbackCtl);
+ i.id = I->id;
+ i.int_to_display = I->int_to_display;
+ length = ((unsigned)(i.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &i, length);
+ }
+ else if (f->class == StringFeedbackClass)
+ {
+ XStringFeedbackControl *S;
+ xStringFeedbackCtl s;
+
+ S = (XStringFeedbackControl *) f;
+ s.class = StringFeedbackClass;
+ s.length = sizeof (xStringFeedbackCtl) +
+ (S->num_keysyms * sizeof (KeySym));
+ s.id = S->id;
+ s.num_keysyms = S->num_keysyms;
+ req->length += ((unsigned)(s.length + 3) >> 2);
+ length = sizeof (xStringFeedbackCtl);
+ Data (dpy, (char *) &s, length);
+ length = (s.num_keysyms * sizeof (KeySym));
+ Data (dpy, (char *) S->syms_to_display, length);
+ }
+ else if (f->class == BellFeedbackClass)
+ {
+ XBellFeedbackControl *B;
+ xBellFeedbackCtl b;
+
+ B = (XBellFeedbackControl *) f;
+ b.class = BellFeedbackClass;
+ b.length = sizeof (xBellFeedbackCtl);
+ b.id = B->id;
+ b.percent = B->percent;
+ b.pitch = B->pitch;
+ b.duration = B->duration;
+ length = ((unsigned)(b.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &b, length);
+ }
+ else if (f->class == LedFeedbackClass)
+ {
+ XLedFeedbackControl *L;
+ xLedFeedbackCtl l;
+
+ L = (XLedFeedbackControl *) f;
+ l.class = LedFeedbackClass;
+ l.length = sizeof (xLedFeedbackCtl);
+ l.id = L->id;
+ l.led_mask = L->led_mask;
+ l.led_values = L->led_values;
+ length = ((unsigned)(l.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &l, length);
+ }
+ else
+ {
+ xFeedbackCtl u;
+
+ u.class = f->class;
+ u.length = f->length - sizeof (int);
+ u.id = f->id;
+ length = ((unsigned)(u.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &u, length);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/nx-X11/lib/Xi/XChgKMap.c b/nx-X11/lib/Xi/XChgKMap.c
new file mode 100644
index 000000000..8ad77ca2c
--- /dev/null
+++ b/nx-X11/lib/Xi/XChgKMap.c
@@ -0,0 +1,94 @@
+/* $Xorg: XChgKMap.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XChgKMap.c,v 3.3 2001/12/14 19:55:04 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XChangeDeviceKeyMapping - change the keymap of an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XChangeDeviceKeyMapping (dpy, dev, first, syms_per_code, keysyms, count)
+ register Display *dpy;
+ XDevice *dev;
+ int first;
+ int syms_per_code;
+ KeySym *keysyms;
+ int count;
+ {
+ register long nbytes;
+ xChangeDeviceKeyMappingReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(ChangeDeviceKeyMapping,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ChangeDeviceKeyMapping;
+ req->deviceid = dev->device_id;
+ req->firstKeyCode = first;
+ req->keyCodes = count;
+ req->keySymsPerKeyCode = syms_per_code;
+ req->length += count * syms_per_code;
+ nbytes = syms_per_code * count * sizeof (CARD32);
+ Data (dpy, (char *)keysyms, nbytes);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/nx-X11/lib/Xi/XChgKbd.c b/nx-X11/lib/Xi/XChgKbd.c
new file mode 100644
index 000000000..b3e2c06c1
--- /dev/null
+++ b/nx-X11/lib/Xi/XChgKbd.c
@@ -0,0 +1,88 @@
+/* $Xorg: XChgKbd.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XChgKbd.c,v 3.3 2001/12/14 19:55:04 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XChangeKeyboardDevice - Change the device used as the X keyboard.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XChangeKeyboardDevice (dpy, dev)
+ register Display *dpy;
+ XDevice *dev;
+ {
+ xChangeKeyboardDeviceReq *req;
+ xChangeKeyboardDeviceReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(ChangeKeyboardDevice,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ChangeKeyboardDevice;
+ req->deviceid = dev->device_id;
+ rep.status = Success;
+
+ (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.status);
+ }
+
diff --git a/nx-X11/lib/Xi/XChgPnt.c b/nx-X11/lib/Xi/XChgPnt.c
new file mode 100644
index 000000000..c7248fd64
--- /dev/null
+++ b/nx-X11/lib/Xi/XChgPnt.c
@@ -0,0 +1,92 @@
+/* $Xorg: XChgPnt.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XChgPnt.c,v 3.3 2001/12/14 19:55:04 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XChangePointerDevice - Change the device used as the X Pointer.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XChangePointerDevice (dpy, dev, xaxis, yaxis)
+ register Display *dpy;
+ XDevice *dev;
+ int xaxis;
+ int yaxis;
+ {
+ xChangePointerDeviceReq *req;
+ xChangePointerDeviceReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(ChangePointerDevice,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ChangePointerDevice;
+ req->deviceid = dev->device_id;
+ req->xaxis = xaxis;
+ req->yaxis = yaxis;
+ rep.status = Success;
+
+ (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.status);
+ }
+
diff --git a/nx-X11/lib/Xi/XChgProp.c b/nx-X11/lib/Xi/XChgProp.c
new file mode 100644
index 000000000..3fa68cfde
--- /dev/null
+++ b/nx-X11/lib/Xi/XChgProp.c
@@ -0,0 +1,98 @@
+/* $Xorg: XChgProp.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XChgProp.c,v 3.3 2001/12/14 19:55:05 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XChangeDeviceDontPropagateList - Get the dont_propagate_list for a
+ * window.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XChangeDeviceDontPropagateList (dpy, window, count, events, mode)
+ register Display *dpy;
+ Window window;
+ int count;
+ XEventClass *events;
+ int mode;
+ {
+ xChangeDeviceDontPropagateListReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(ChangeDeviceDontPropagateList,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ChangeDeviceDontPropagateList;
+ req->window = window;
+ req->count = count;
+ req->mode = mode;
+ req->length += count;
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ count <<= 2;
+ Data32 (dpy, (long *) events, count);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/nx-X11/lib/Xi/XCloseDev.c b/nx-X11/lib/Xi/XCloseDev.c
new file mode 100644
index 000000000..170843b96
--- /dev/null
+++ b/nx-X11/lib/Xi/XCloseDev.c
@@ -0,0 +1,85 @@
+/* $Xorg: XCloseDev.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XCloseDev.c,v 3.3 2001/12/14 19:55:06 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XCloseDevice - Request the server to close an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XCloseDevice(dpy, dev)
+ register Display *dpy;
+ register XDevice *dev;
+ {
+ xCloseDeviceReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(CloseDevice,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_CloseDevice;
+ req->deviceid = dev->device_id;
+
+ XFree ((char *)dev);
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/nx-X11/lib/Xi/XDevBell.c b/nx-X11/lib/Xi/XDevBell.c
new file mode 100644
index 000000000..2b7669ff5
--- /dev/null
+++ b/nx-X11/lib/Xi/XDevBell.c
@@ -0,0 +1,89 @@
+/* $Xorg: XDevBell.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XDevBell.c,v 3.3 2001/12/14 19:55:08 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XDeviceBell - Ring a bell on an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XDeviceBell (dpy, dev, feedbackclass, feedbackid, percent)
+ register Display *dpy;
+ XDevice *dev;
+ XID feedbackclass, feedbackid;
+ int percent;
+ {
+ xDeviceBellReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Add_XDeviceBell) == -1)
+ return (NoSuchExtension);
+
+ GetReq(DeviceBell,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_DeviceBell;
+ req->deviceid = dev->device_id;
+ req->feedbackclass = feedbackclass;
+ req->feedbackid = feedbackid;
+ req->percent = percent;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/nx-X11/lib/Xi/XExtInt.c b/nx-X11/lib/Xi/XExtInt.c
new file mode 100644
index 000000000..9e569df44
--- /dev/null
+++ b/nx-X11/lib/Xi/XExtInt.c
@@ -0,0 +1,663 @@
+/* $Xorg: XExtInt.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XExtInt.c,v 3.6 2001/12/14 19:55:09 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Input Extension library internal functions.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <stdio.h>
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+#define ENQUEUE_EVENT True
+#define DONT_ENQUEUE False
+
+static XExtensionInfo *xinput_info;
+static /* const */ char *xinput_extension_name = INAME;
+static int XInputClose();
+static char *XInputError();
+static Bool XInputWireToEvent();
+Status _XiEventToWire();
+static /* const */ XEvent emptyevent;
+
+typedef struct _XInputData
+ {
+ XEvent data;
+ XExtensionVersion *vers;
+ } XInputData;
+
+#define XInputCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xinput_extension_name, val)
+
+static /* const */ XExtensionHooks xinput_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ XInputClose, /* close_display */
+ XInputWireToEvent, /* wire_to_event */
+ _XiEventToWire, /* event_to_wire */
+ NULL, /* error */
+ XInputError, /* error_string */
+};
+
+static char *XInputErrorList[] = {
+ "BadDevice, invalid or uninitialized input device", /* BadDevice */
+ "BadEvent, invalid event type", /* BadEvent */
+ "BadMode, invalid mode parameter", /* BadMode */
+ "DeviceBusy, device is busy", /* DeviceBusy */
+ "BadClass, invalid event class", /* BadClass */
+};
+
+XEXT_GENERATE_FIND_DISPLAY (XInput_find_display, xinput_info,
+ xinput_extension_name, &xinput_extension_hooks, IEVENTS, NULL)
+
+static XEXT_GENERATE_ERROR_STRING (XInputError, xinput_extension_name,
+ IERRORS, XInputErrorList)
+/*******************************************************************
+ *
+ * Input extension versions.
+ *
+ */
+
+static XExtensionVersion versions[] = {{XI_Absent,0,0},
+ {XI_Present, XI_Initial_Release_Major, XI_Initial_Release_Minor},
+ {XI_Present, XI_Add_XDeviceBell_Major, XI_Add_XDeviceBell_Minor},
+ {XI_Present, XI_Add_XSetDeviceValuators_Major,
+ XI_Add_XSetDeviceValuators_Minor},
+ {XI_Present, XI_Add_XChangeDeviceControl_Major,
+ XI_Add_XChangeDeviceControl_Minor}};
+
+/***********************************************************************
+ *
+ * Return errors reported by this extension.
+ *
+ */
+
+void _xibaddevice (dpy, error)
+ Display *dpy;
+ int *error;
+ {
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+ *error = info->codes->first_error + XI_BadDevice;
+ }
+
+void _xibadclass (dpy, error)
+ Display *dpy;
+ int *error;
+ {
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+ *error = info->codes->first_error + XI_BadClass;
+ }
+
+void _xibadevent (dpy, error)
+ Display *dpy;
+ int *error;
+ {
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+ *error = info->codes->first_error + XI_BadEvent;
+ }
+
+void _xibadmode (dpy, error)
+ Display *dpy;
+ int *error;
+ {
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+ *error = info->codes->first_error + XI_BadMode;
+ }
+
+void _xidevicebusy (dpy, error)
+ Display *dpy;
+ int *error;
+ {
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+ *error = info->codes->first_error + XI_DeviceBusy;
+ }
+
+/***********************************************************************
+ *
+ * Check to see if the input extension is installed in the server.
+ * Also check to see if the version is >= the requested version.
+ *
+ */
+
+int
+_XiCheckExtInit(dpy, version_index)
+ register Display *dpy;
+ register int version_index;
+ {
+ XExtensionVersion *ext;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ XInputCheckExtension (dpy, info, -1);
+
+ if (info->data == NULL)
+ {
+ info->data = (XPointer) Xmalloc (sizeof (XInputData));
+ if (!info->data)
+ {
+ UnlockDisplay(dpy);
+ return (-1);
+ }
+ ((XInputData *) info->data)->vers =
+ _XiGetExtensionVersion (dpy, "XInputExtension");
+ }
+
+ if (versions[version_index].major_version > Dont_Check)
+ {
+ ext = ((XInputData *) info->data)->vers;
+ if ((ext->major_version < versions[version_index].major_version) ||
+ ((ext->major_version == versions[version_index].major_version) &&
+ (ext->minor_version < versions[version_index].minor_version)))
+ {
+ UnlockDisplay(dpy);
+ return (-1);
+ }
+ }
+ return (0);
+ }
+
+/***********************************************************************
+ *
+ * Close display routine.
+ *
+ */
+
+static int
+XInputClose (dpy, codes)
+ Display *dpy;
+ XExtCodes *codes;
+ {
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ if(info->data != NULL) {
+ XFree((char *)((XInputData *) info->data)->vers);
+ XFree((char *)info->data);
+ }
+ return XextRemoveDisplay (xinput_info, dpy);
+ }
+
+
+static int
+Ones(mask)
+ Mask mask;
+{
+ register Mask y;
+
+ y = (mask >> 1) &033333333333;
+ y = mask - y - ((y >>1) & 033333333333);
+ return (((y + (y >> 3)) & 030707070707) % 077);
+}
+
+/***********************************************************************
+ *
+ * Handle Input extension events.
+ * Reformat a wire event into an XEvent structure of the right type.
+ *
+ */
+
+static Bool
+XInputWireToEvent (dpy, re, event)
+ Display *dpy;
+ XEvent *re;
+ xEvent *event;
+ {
+ unsigned int type, reltype;
+ unsigned int i,j;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+ XEvent *save = (XEvent *) info->data;
+
+ type = event->u.u.type & 0x7f;
+ reltype = (type - info->codes->first_event);
+
+
+
+ if (reltype != XI_DeviceValuator &&
+ reltype != XI_DeviceKeystateNotify &&
+ reltype != XI_DeviceButtonstateNotify)
+ {
+ *save = emptyevent;
+ save->type = type;
+ ((XAnyEvent *)save)->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ ((XAnyEvent *)save)->send_event = ((event->u.u.type & 0x80) != 0);
+ ((XAnyEvent *)save)->display = dpy;
+ }
+
+ switch (reltype)
+ {
+ case XI_DeviceMotionNotify:
+ {
+ register XDeviceMotionEvent *ev = (XDeviceMotionEvent*) save;
+ deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
+
+ ev->root = ev2->root;
+ ev->window = ev2->event;
+ ev->subwindow = ev2->child;
+ ev->time = ev2->time;
+ ev->x_root = ev2->root_x;
+ ev->y_root = ev2->root_y;
+ ev->x = ev2->event_x;
+ ev->y = ev2->event_y;
+ ev->state = ev2->state;
+ ev->same_screen = ev2->same_screen;
+ ev->is_hint = ev2->detail;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ return (DONT_ENQUEUE);
+ }
+ break;
+ case XI_DeviceKeyPress:
+ case XI_DeviceKeyRelease:
+ {
+ register XDeviceKeyEvent *ev = (XDeviceKeyEvent*) save;
+ deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
+
+ ev->root = ev2->root;
+ ev->window = ev2->event;
+ ev->subwindow = ev2->child;
+ ev->time = ev2->time;
+ ev->x_root = ev2->root_x;
+ ev->y_root = ev2->root_y;
+ ev->x = ev2->event_x;
+ ev->y = ev2->event_y;
+ ev->state = ev2->state;
+ ev->same_screen = ev2->same_screen;
+ ev->keycode = ev2->detail;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ if (ev2->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else
+ {
+ *re = *save;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceButtonPress:
+ case XI_DeviceButtonRelease:
+ {
+ register XDeviceButtonEvent *ev = (XDeviceButtonEvent*) save;
+ deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
+
+ ev->root = ev2->root;
+ ev->window = ev2->event;
+ ev->subwindow = ev2->child;
+ ev->time = ev2->time;
+ ev->x_root = ev2->root_x;
+ ev->y_root = ev2->root_y;
+ ev->x = ev2->event_x;
+ ev->y = ev2->event_y;
+ ev->state = ev2->state;
+ ev->same_screen = ev2->same_screen;
+ ev->button = ev2->detail;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ if (ev2->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else
+ {
+ *re = *save;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_ProximityIn:
+ case XI_ProximityOut:
+ {
+ register XProximityNotifyEvent *ev =
+ (XProximityNotifyEvent *) save;
+ deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
+
+ ev->root = ev2->root;
+ ev->window = ev2->event;
+ ev->subwindow = ev2->child;
+ ev->time = ev2->time;
+ ev->x_root = ev2->root_x;
+ ev->y_root = ev2->root_y;
+ ev->x = ev2->event_x;
+ ev->y = ev2->event_y;
+ ev->state = ev2->state;
+ ev->same_screen = ev2->same_screen;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ if (ev2->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else
+ {
+ *re = *save;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceValuator:
+ {
+ deviceValuator *xev = (deviceValuator *) event;
+ int save_type = save->type - info->codes->first_event;
+
+ if (save_type == XI_DeviceKeyPress ||
+ save_type == XI_DeviceKeyRelease)
+ {
+ XDeviceKeyEvent *kev = (XDeviceKeyEvent*) save;
+ kev->device_state = xev->device_state;
+ kev->axes_count = xev->num_valuators;
+ kev->first_axis = xev->first_valuator;
+ i = xev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: kev->axis_data[5] = xev->valuator5;
+ case 5: kev->axis_data[4] = xev->valuator4;
+ case 4: kev->axis_data[3] = xev->valuator3;
+ case 3: kev->axis_data[2] = xev->valuator2;
+ case 2: kev->axis_data[1] = xev->valuator1;
+ case 1: kev->axis_data[0] = xev->valuator0;
+ }
+ }
+ else if (save_type == XI_DeviceButtonPress ||
+ save_type == XI_DeviceButtonRelease)
+ {
+ XDeviceButtonEvent *bev = (XDeviceButtonEvent*) save;
+ bev->device_state = xev->device_state;
+ bev->axes_count = xev->num_valuators;
+ bev->first_axis = xev->first_valuator;
+ i = xev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: bev->axis_data[5] = xev->valuator5;
+ case 5: bev->axis_data[4] = xev->valuator4;
+ case 4: bev->axis_data[3] = xev->valuator3;
+ case 3: bev->axis_data[2] = xev->valuator2;
+ case 2: bev->axis_data[1] = xev->valuator1;
+ case 1: bev->axis_data[0] = xev->valuator0;
+ }
+ }
+ else if (save_type == XI_DeviceMotionNotify)
+ {
+ XDeviceMotionEvent *mev = (XDeviceMotionEvent*) save;
+ mev->device_state = xev->device_state;
+ mev->axes_count = xev->num_valuators;
+ mev->first_axis = xev->first_valuator;
+ i = xev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: mev->axis_data[5] = xev->valuator5;
+ case 5: mev->axis_data[4] = xev->valuator4;
+ case 4: mev->axis_data[3] = xev->valuator3;
+ case 3: mev->axis_data[2] = xev->valuator2;
+ case 2: mev->axis_data[1] = xev->valuator1;
+ case 1: mev->axis_data[0] = xev->valuator0;
+ }
+ }
+ else if (save_type == XI_ProximityIn ||
+ save_type == XI_ProximityOut)
+ {
+ XProximityNotifyEvent *pev =
+ (XProximityNotifyEvent*) save;
+ pev->device_state = xev->device_state;
+ pev->axes_count = xev->num_valuators;
+ pev->first_axis = xev->first_valuator;
+ i = xev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: pev->axis_data[5] = xev->valuator5;
+ case 5: pev->axis_data[4] = xev->valuator4;
+ case 4: pev->axis_data[3] = xev->valuator3;
+ case 3: pev->axis_data[2] = xev->valuator2;
+ case 2: pev->axis_data[1] = xev->valuator1;
+ case 1: pev->axis_data[0] = xev->valuator0;
+ }
+ }
+ else if (save_type == XI_DeviceStateNotify)
+ {
+ XDeviceStateNotifyEvent *sev =
+ (XDeviceStateNotifyEvent*) save;
+ XInputClass *any = (XInputClass *) &sev->data[0];
+ XValuatorStatus *v;
+
+ for (i=0; i<sev->num_classes; i++)
+ if (any->class != ValuatorClass)
+ any = (XInputClass *) ((char *) any + any->length);
+ v = (XValuatorStatus *) any;
+ i = v->num_valuators;
+ j = xev->num_valuators;
+ if (j > 3) j = 3;
+ switch (j)
+ {
+ case 3: v->valuators[i + 2] = xev->valuator2;
+ case 2: v->valuators[i + 1] = xev->valuator1;
+ case 1: v->valuators[i + 0] = xev->valuator0;
+ }
+ v->num_valuators += j;
+
+ }
+ *re = *save;
+ return (ENQUEUE_EVENT);
+ }
+ break;
+ case XI_DeviceFocusIn:
+ case XI_DeviceFocusOut:
+ {
+ register XDeviceFocusChangeEvent *ev =
+ (XDeviceFocusChangeEvent *) re;
+ deviceFocus *fev = (deviceFocus *) event;
+
+ *ev = *((XDeviceFocusChangeEvent *) save);
+ ev->window = fev->window;
+ ev->time = fev->time;
+ ev->mode = fev->mode;
+ ev->detail = fev->detail;
+ ev->deviceid = fev->deviceid & DEVICE_BITS;
+ return (ENQUEUE_EVENT);
+ }
+ break;
+ case XI_DeviceStateNotify:
+ {
+ XDeviceStateNotifyEvent *stev =
+ (XDeviceStateNotifyEvent *) save;
+ deviceStateNotify *sev = (deviceStateNotify *) event;
+ char *data;
+
+ stev->window = None;
+ stev->deviceid = sev->deviceid & DEVICE_BITS;
+ stev->time = sev->time;
+ stev->num_classes = Ones ((Mask)sev->classes_reported & InputClassBits);
+ data = (char *) &stev->data[0];
+ if (sev->classes_reported & (1 << KeyClass))
+ {
+ register XKeyStatus *kstev = (XKeyStatus *) data;
+ kstev->class = KeyClass;
+ kstev->length = sizeof (XKeyStatus);
+ kstev->num_keys = sev->num_keys;
+ memcpy ((char *) &kstev->keys[0], (char *) &sev->keys[0], 4);
+ data += sizeof (XKeyStatus);
+ }
+ if (sev->classes_reported & (1 << ButtonClass))
+ {
+ register XButtonStatus *bev = (XButtonStatus *) data;
+ bev->class = ButtonClass;
+ bev->length = sizeof (XButtonStatus);
+ bev->num_buttons = sev->num_buttons;
+ memcpy ((char *) bev->buttons, (char *) sev->buttons, 4);
+ data += sizeof (XButtonStatus);
+ }
+ if (sev->classes_reported & (1 << ValuatorClass))
+ {
+ register XValuatorStatus *vev = (XValuatorStatus *) data;
+ vev->class = ValuatorClass;
+ vev->length = sizeof (XValuatorStatus);
+ vev->num_valuators = sev->num_valuators;
+ vev->mode = sev->classes_reported >> ModeBitsShift;
+ j = sev->num_valuators;
+ if (j > 3) j = 3;
+ switch (j)
+ {
+ case 3: vev->valuators[2] = sev->valuator2;
+ case 2: vev->valuators[1] = sev->valuator1;
+ case 1: vev->valuators[0] = sev->valuator0;
+ }
+ data += sizeof (XValuatorStatus);
+ }
+ if (sev->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else
+ {
+ *re = *save;
+ stev = (XDeviceStateNotifyEvent *) re;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceKeystateNotify:
+ {
+ int i;
+ XInputClass *anyclass;
+ register XKeyStatus *kv;
+ deviceKeyStateNotify *ksev = (deviceKeyStateNotify *) event;
+ XDeviceStateNotifyEvent *kstev =
+ (XDeviceStateNotifyEvent *) save;
+
+ anyclass = (XInputClass *) &kstev->data[0];
+ for (i=0; i<kstev->num_classes; i++)
+ if (anyclass->class == KeyClass)
+ break;
+ else
+ anyclass = (XInputClass *) ((char *) anyclass +
+ anyclass->length);
+
+ kv = (XKeyStatus *) anyclass;
+ kv->num_keys = 256;
+ memcpy ((char *) &kv->keys[4], (char *) ksev->keys, 28);
+ if (ksev->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else
+ {
+ *re = *save;
+ kstev = (XDeviceStateNotifyEvent *) re;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceButtonstateNotify:
+ {
+ int i;
+ XInputClass *anyclass;
+ register XButtonStatus *bv;
+ deviceButtonStateNotify *bsev = (deviceButtonStateNotify *) event;
+ XDeviceStateNotifyEvent *bstev =
+ (XDeviceStateNotifyEvent *) save;
+
+
+ anyclass = (XInputClass *) &bstev->data[0];
+ for (i=0; i<bstev->num_classes; i++)
+ if (anyclass->class == ButtonClass)
+ break;
+ else
+ anyclass = (XInputClass *) ((char *) anyclass +
+ anyclass->length);
+
+ bv = (XButtonStatus *) anyclass;
+ bv->num_buttons = 256;
+ memcpy ((char *) &bv->buttons[4], (char *) bsev->buttons, 28);
+ if (bsev->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else
+ {
+ *re = *save;
+ bstev = (XDeviceStateNotifyEvent *) re;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceMappingNotify:
+ {
+ register XDeviceMappingEvent *ev = (XDeviceMappingEvent *) re;
+ deviceMappingNotify *ev2 = (deviceMappingNotify *) event;
+
+ *ev = *((XDeviceMappingEvent *) save);
+ ev->window = 0;
+ ev->first_keycode = ev2->firstKeyCode;
+ ev->request = ev2->request;
+ ev->count = ev2->count;
+ ev->time = ev2->time;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ return (ENQUEUE_EVENT);
+ }
+ break;
+ case XI_ChangeDeviceNotify:
+ {
+ register XChangeDeviceNotifyEvent *ev =
+ (XChangeDeviceNotifyEvent *) re;
+ changeDeviceNotify *ev2 = (changeDeviceNotify *) event;
+
+ *ev = *((XChangeDeviceNotifyEvent *) save);
+ ev->window = 0;
+ ev->request = ev2->request;
+ ev->time = ev2->time;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ return (ENQUEUE_EVENT);
+ }
+ break;
+ default:
+ printf ("XInputWireToEvent: UNKNOWN WIRE EVENT! type=%d\n",type);
+ break;
+ }
+
+ return (DONT_ENQUEUE);
+ }
diff --git a/nx-X11/lib/Xi/XExtToWire.c b/nx-X11/lib/Xi/XExtToWire.c
new file mode 100644
index 000000000..30f01408b
--- /dev/null
+++ b/nx-X11/lib/Xi/XExtToWire.c
@@ -0,0 +1,452 @@
+/* $Xorg: XExtToWire.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XExtToWire.c,v 3.5 2002/10/16 00:37:28 dawes Exp $ */
+
+/****************************************************************
+ *
+ * XExtToWire.c - reformat an XEvent into a wire event.
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+Status
+_XiEventToWire(dpy, re, event, count)
+ register Display *dpy; /* pointer to display structure */
+ register XEvent *re; /* pointer to client event */
+ register xEvent **event; /* wire protocol event */
+ register int *count;
+ {
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+ int i;
+
+ switch ((re->type & 0x7f) - info->codes->first_event)
+ {
+ case XI_DeviceKeyPress:
+ case XI_DeviceKeyRelease:
+ {
+ register XDeviceKeyEvent *ev = (XDeviceKeyEvent*) re;
+ register deviceKeyButtonPointer *kev;
+ register deviceValuator *vev;
+
+ *count = 2;
+ kev = (deviceKeyButtonPointer *) Xmalloc (*count * sizeof (xEvent));
+ if (!kev)
+ return(_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) kev;
+
+ kev->type = ev->type;
+ kev->root = ev->root;
+ kev->event = ev->window;
+ kev->child = ev->subwindow;
+ kev->time = ev->time;
+ kev->event_x = ev->x ;
+ kev->event_y = ev->y ;
+ kev->root_x = ev->x_root;
+ kev->root_y = ev->y_root;
+ kev->state = ev->state;
+ kev->same_screen = ev->same_screen;
+ kev->detail = ev->keycode;
+ kev->deviceid = ev->deviceid | MORE_EVENTS;
+
+ vev = (deviceValuator *) ++kev;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->device_state = ev->device_state;
+ vev->first_valuator = ev->first_axis;
+ vev->num_valuators = ev->axes_count;
+ i = vev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: vev->valuator5 = ev->axis_data[5];
+ case 5: vev->valuator4 = ev->axis_data[4];
+ case 4: vev->valuator3 = ev->axis_data[3];
+ case 3: vev->valuator2 = ev->axis_data[2];
+ case 2: vev->valuator1 = ev->axis_data[1];
+ case 1: vev->valuator0 = ev->axis_data[0];
+ }
+ break;
+ }
+ case XI_ProximityIn:
+ case XI_ProximityOut:
+ {
+ register XProximityNotifyEvent *ev =
+ (XProximityNotifyEvent *) re;
+ register deviceKeyButtonPointer *pev;
+ register deviceValuator *vev;
+
+ *count = 2;
+ pev = (deviceKeyButtonPointer *) Xmalloc (*count * sizeof (xEvent));
+ if (!pev)
+ return(_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) pev;
+
+ pev->type = ev->type;
+ pev->root = ev->root;
+ pev->event = ev->window;
+ pev->child = ev->subwindow;
+ pev->time = ev->time;
+ pev->event_x = ev->x ;
+ pev->event_y = ev->y ;
+ pev->root_x = ev->x_root;
+ pev->root_y = ev->y_root;
+ pev->state = ev->state;
+ pev->same_screen = ev->same_screen;
+ pev->deviceid = ev->deviceid | MORE_EVENTS;
+
+ vev = (deviceValuator *) ++pev;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->device_state = ev->device_state;
+ vev->first_valuator = ev->first_axis;
+ vev->num_valuators = ev->axes_count;
+
+ i = vev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: vev->valuator5 = ev->axis_data[5];
+ case 5: vev->valuator4 = ev->axis_data[4];
+ case 4: vev->valuator3 = ev->axis_data[3];
+ case 3: vev->valuator2 = ev->axis_data[2];
+ case 2: vev->valuator1 = ev->axis_data[1];
+ case 1: vev->valuator0 = ev->axis_data[0];
+ }
+ break;
+ }
+ case XI_DeviceButtonPress:
+ case XI_DeviceButtonRelease:
+ {
+ register XDeviceButtonEvent *ev =
+ (XDeviceButtonEvent *) re;
+ register deviceKeyButtonPointer *bev;
+ register deviceValuator *vev;
+
+ *count = 2;
+ bev = (deviceKeyButtonPointer *) Xmalloc (*count * sizeof (xEvent));
+ if (!bev)
+ return(_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) bev;
+
+ bev->type = ev->type;
+ bev->root = ev->root;
+ bev->event = ev->window;
+ bev->child = ev->subwindow;
+ bev->time = ev->time;
+ bev->event_x = ev->x ;
+ bev->event_y = ev->y ;
+ bev->root_x = ev->x_root;
+ bev->root_y = ev->y_root;
+ bev->state = ev->state;
+ bev->same_screen = ev->same_screen;
+ bev->detail = ev->button;
+ bev->deviceid = ev->deviceid | MORE_EVENTS;
+
+ vev = (deviceValuator *) ++bev;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->device_state = ev->device_state;
+ vev->first_valuator = ev->first_axis;
+ vev->num_valuators = ev->axes_count;
+
+ i = vev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: vev->valuator5 = ev->axis_data[5];
+ case 5: vev->valuator4 = ev->axis_data[4];
+ case 4: vev->valuator3 = ev->axis_data[3];
+ case 3: vev->valuator2 = ev->axis_data[2];
+ case 2: vev->valuator1 = ev->axis_data[1];
+ case 1: vev->valuator0 = ev->axis_data[0];
+ }
+ break;
+ }
+ case XI_DeviceMotionNotify:
+ {
+ register XDeviceMotionEvent *ev =
+ (XDeviceMotionEvent *)re;
+ register deviceKeyButtonPointer *mev;
+ register deviceValuator *vev;
+
+ *count = 2;
+ mev = (deviceKeyButtonPointer *) Xmalloc (*count * sizeof (xEvent));
+ if (!mev)
+ return(_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) mev;
+
+ mev->type = ev->type;
+ mev->root = ev->root;
+ mev->event = ev->window;
+ mev->child = ev->subwindow;
+ mev->time = ev->time;
+ mev->event_x = ev->x ;
+ mev->event_y = ev->y ;
+ mev->root_x = ev->x_root;
+ mev->root_y = ev->y_root;
+ mev->state = ev->state;
+ mev->same_screen = ev->same_screen;
+ mev->detail = ev->is_hint;
+ mev->deviceid = ev->deviceid | MORE_EVENTS;
+
+ vev = (deviceValuator *) ++mev;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->device_state = ev->device_state;
+ vev->first_valuator = ev->first_axis;
+ vev->num_valuators = ev->axes_count;
+
+ i = vev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: vev->valuator5 = ev->axis_data[5];
+ case 5: vev->valuator4 = ev->axis_data[4];
+ case 4: vev->valuator3 = ev->axis_data[3];
+ case 3: vev->valuator2 = ev->axis_data[2];
+ case 2: vev->valuator1 = ev->axis_data[1];
+ case 1: vev->valuator0 = ev->axis_data[0];
+ }
+ break;
+ }
+ case XI_DeviceFocusIn:
+ case XI_DeviceFocusOut:
+ {
+ register XDeviceFocusChangeEvent *ev =
+ (XDeviceFocusChangeEvent *) re;
+ register deviceFocus *fev;
+
+ *count = 1;
+ fev = (deviceFocus *) Xmalloc (*count * sizeof (xEvent));
+ if (!fev)
+ return(_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) fev;
+
+ fev->type = ev->type;
+ fev->window = ev->window;
+ fev->mode = ev->mode;
+ fev->detail = ev->detail;
+ fev->time = ev->time;
+ fev->deviceid = ev->deviceid;
+ break;
+ }
+ case XI_DeviceMappingNotify:
+ {
+ register XDeviceMappingEvent *ev = (XDeviceMappingEvent *) re;
+ register deviceMappingNotify *mev;
+
+ *count = 1;
+ mev = (deviceMappingNotify *) Xmalloc (*count * sizeof (xEvent));
+ if (!mev)
+ return(_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) mev;
+
+ mev->type = ev->type;
+ mev->firstKeyCode = ev->first_keycode;
+ mev->request = ev->request;
+ mev->count = ev->count;
+ mev->time = ev->time;
+ mev->deviceid = ev->deviceid;
+ break;
+ }
+ case XI_DeviceStateNotify:
+ {
+ register XDeviceStateNotifyEvent *ev =
+ (XDeviceStateNotifyEvent *) re;
+ register deviceStateNotify *sev;
+ register xEvent *tev;
+ XInputClass *any = (XInputClass *) &ev->data[0];
+ unsigned char *sav_id;
+ *count = 1;
+
+ for (i=0; i<ev->num_classes; i++)
+ {
+ if (any->class == KeyClass)
+ {
+ XKeyStatus *k = (XKeyStatus *) any;
+ if (k->num_keys > 32)
+ (*count)++;
+ }
+ else if (any->class == ButtonClass)
+ {
+ XButtonStatus *b = (XButtonStatus *) any;
+ if (b->num_buttons > 32)
+ (*count)++;
+ }
+ else if (any->class == ValuatorClass)
+ {
+ XValuatorStatus *v = (XValuatorStatus *) any;
+ if (v->num_valuators > 3)
+ (*count)++;
+ }
+ any = (XInputClass *) ((char *) any + any->length);
+ }
+
+ sev = (deviceStateNotify *) Xmalloc (*count * sizeof (xEvent));
+ if (!sev)
+ return(_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) sev;
+ tev = (xEvent *) (sev+1);
+
+ sev->type = ev->type;
+ sev->deviceid = ev->deviceid;
+ sav_id = &(sev->deviceid);
+ sev->time = ev->time;
+ sev->classes_reported = 0;
+
+ any = (XInputClass *) &ev->data[0];
+ for (i=0; i<ev->num_classes; i++)
+ {
+ if (any->class == KeyClass)
+ {
+ XKeyStatus *k = (XKeyStatus *) any;
+ register deviceKeyStateNotify *kev;
+
+ sev->classes_reported |= (1 << KeyClass);
+ sev->num_keys = k->num_keys;
+ memcpy ((char *) (sev->keys), (char *) (k->keys), 4);
+ if (k->num_keys > 32)
+ {
+ kev = (deviceKeyStateNotify *) tev++;
+ kev->type = info->codes->first_event +
+ XI_DeviceKeystateNotify;
+ kev->deviceid = ev->deviceid;
+ *sav_id |= MORE_EVENTS;
+ sav_id = &(kev->deviceid);
+ memcpy ((char *) (kev->keys), (char *) (&k->keys[4]),
+ 28);
+ }
+ }
+ else if (any->class == ButtonClass)
+ {
+ XButtonStatus *b = (XButtonStatus *) any;
+ register deviceButtonStateNotify *bev;
+
+ sev->classes_reported |= (1 << ButtonClass);
+ sev->num_buttons = b->num_buttons;
+ memcpy ((char *) (sev->buttons), (char *) (b->buttons), 4);
+ if (b->num_buttons > 32)
+ {
+ bev = (deviceButtonStateNotify *) tev++;
+ bev->type = info->codes->first_event +
+ XI_DeviceButtonstateNotify;
+ bev->deviceid = ev->deviceid;
+ *sav_id |= MORE_EVENTS;
+ sav_id = &(bev->deviceid);
+ memcpy ((char *)(bev->buttons), (char *)(&b->buttons[4]),
+ 28);
+ }
+ }
+ else if (any->class == ValuatorClass)
+ {
+ XValuatorStatus *val = (XValuatorStatus *) any;
+ register deviceValuator *vev;
+
+ sev->classes_reported |= (1 << ValuatorClass);
+ sev->num_valuators = val->num_valuators < 3 ?
+ val->num_valuators : 3;
+ switch (sev->num_valuators)
+ {
+ case 3: sev->valuator2 = val->valuators[2];
+ case 2: sev->valuator1 = val->valuators[1];
+ case 1: sev->valuator0 = val->valuators[0];
+ }
+ if (val->num_valuators > 3)
+ {
+ vev = (deviceValuator *) tev++;
+ vev->type = info->codes->first_event +
+ XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->first_valuator = 3;
+ vev->num_valuators = val->num_valuators - 3;
+ *sav_id |= MORE_EVENTS;
+ sav_id = &(vev->deviceid);
+ i = val->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: vev->valuator2 = val->valuators[5];
+ case 5: vev->valuator1 = val->valuators[4];
+ case 4: vev->valuator0 = val->valuators[3];
+ }
+ }
+ }
+ any = (XInputClass *) ((char *) any + any->length);
+ }
+ break;
+ }
+ case XI_ChangeDeviceNotify:
+ {
+ register XChangeDeviceNotifyEvent *ev =
+ (XChangeDeviceNotifyEvent *) re;
+ register changeDeviceNotify *cev;
+
+ *count = 1;
+ cev = (changeDeviceNotify *) Xmalloc (*count * sizeof (xEvent));
+ if (!cev)
+ return(_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) cev;
+
+ cev->type = ev->type;
+ cev->request = ev->request;
+ cev->time = ev->time;
+ cev->deviceid = ev->deviceid;
+ break;
+ }
+ default:
+ return(_XUnknownNativeEvent(dpy, re, *event));
+ }
+ return(1);
+ }
diff --git a/nx-X11/lib/Xi/XFreeLst.c b/nx-X11/lib/Xi/XFreeLst.c
new file mode 100644
index 000000000..3966f3f0a
--- /dev/null
+++ b/nx-X11/lib/Xi/XFreeLst.c
@@ -0,0 +1,73 @@
+/* $Xorg: XFreeLst.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86$ */
+
+/***********************************************************************
+ *
+ * XFreeDeviceList - free the input device list.
+ *
+ */
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+
+/***********************************************************************
+ *
+ * Free the list of input devices.
+ *
+ */
+
+XFreeDeviceList (list)
+ XDeviceList *list;
+ {
+ if (list != NULL)
+ {
+ XFree ((list->name) - sizeof(XDeviceList));
+ XFree ((XDeviceList *) list);
+ }
+ }
diff --git a/nx-X11/lib/Xi/XGMotion.c b/nx-X11/lib/Xi/XGMotion.c
new file mode 100644
index 000000000..4ce41bf99
--- /dev/null
+++ b/nx-X11/lib/Xi/XGMotion.c
@@ -0,0 +1,142 @@
+/* $Xorg: XGMotion.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XGMotion.c,v 3.3 2001/12/14 19:55:12 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XGetDeviceMotionEvents - Get the motion history of an input device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+XDeviceTimeCoord
+*XGetDeviceMotionEvents (dpy, dev, start, stop, nEvents, mode, axis_count)
+ register Display *dpy;
+ XDevice *dev;
+ Time start;
+ Time stop;
+ int *nEvents;
+ int *mode;
+ int *axis_count;
+ {
+ xGetDeviceMotionEventsReq *req;
+ xGetDeviceMotionEventsReply rep;
+ XDeviceTimeCoord *tc;
+ int *data, *bufp, *readp, *savp;
+ long size, size2;
+ int i, j;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XDeviceTimeCoord *) NoSuchExtension);
+
+ GetReq(GetDeviceMotionEvents,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceMotionEvents;
+ req->start = start;
+ req->stop = stop;
+ req->deviceid = dev->device_id;
+
+ if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *nEvents = 0;
+ return (NULL);
+ }
+
+ *mode = rep.mode;
+ *axis_count = rep.axes;
+ *nEvents = rep.nEvents;
+ if (!rep.nEvents)
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (NULL);
+ }
+ size = rep.length << 2;
+ size2 = rep.nEvents *
+ (sizeof (XDeviceTimeCoord) + (rep.axes * sizeof (int)));
+ savp = readp = (int *) Xmalloc (size);
+ bufp = (int *) Xmalloc (size2);
+ if (!bufp || !savp)
+ {
+ *nEvents = 0;
+ _XEatData (dpy, (unsigned long) size);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (NULL);
+ }
+ _XRead (dpy, (char *) readp, size);
+
+ tc = (XDeviceTimeCoord *) bufp;
+ data = (int *) (tc + rep.nEvents);
+ for (i=0; i<*nEvents; i++,tc++)
+ {
+ tc->time = *readp++;
+ tc->data = data;
+ for (j=0; j<*axis_count; j++)
+ *data++ = *readp++;
+ }
+ XFree ((char *)savp);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((XDeviceTimeCoord *) bufp);
+ }
+
+void XFreeDeviceMotionEvents (events)
+ XDeviceTimeCoord *events;
+ {
+ XFree ((char *)events);
+ }
diff --git a/nx-X11/lib/Xi/XGetBMap.c b/nx-X11/lib/Xi/XGetBMap.c
new file mode 100644
index 000000000..1c1658fda
--- /dev/null
+++ b/nx-X11/lib/Xi/XGetBMap.c
@@ -0,0 +1,108 @@
+/* $Xorg: XGetBMap.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XGetBMap.c,v 3.3 2001/12/14 19:55:13 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XGetDeviceButtonMapping - Get the button mapping of an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+#ifdef MIN /* some systems define this in <sys/param.h> */
+#undef MIN
+#endif
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+
+int
+XGetDeviceButtonMapping (dpy, device, map, nmap)
+ register Display *dpy;
+ XDevice *device;
+ unsigned char map[];
+ unsigned int nmap;
+ {
+ int status = 0;
+ unsigned char mapping[256]; /* known fixed size */
+ long nbytes;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ register xGetDeviceButtonMappingReq *req;
+ xGetDeviceButtonMappingReply rep;
+
+ LockDisplay(dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+ GetReq(GetDeviceButtonMapping, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceButtonMapping;
+ req->deviceid = device->device_id;
+
+ status = _XReply (dpy, (xReply *)&rep, 0, xFalse);
+ if (status == 1)
+ {
+ nbytes = (long)rep.length << 2;
+ _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, nmap));
+ status = rep.nElts;
+ }
+ else
+ status = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (status);
+ }
diff --git a/nx-X11/lib/Xi/XGetDCtl.c b/nx-X11/lib/Xi/XGetDCtl.c
new file mode 100644
index 000000000..66b352594
--- /dev/null
+++ b/nx-X11/lib/Xi/XGetDCtl.c
@@ -0,0 +1,173 @@
+/* $Xorg: XGetDCtl.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XGetDCtl.c,v 3.3 2001/12/14 19:55:13 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XGetDeviceControl - get the Device control state of an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+XDeviceControl
+*XGetDeviceControl (dpy, dev, control)
+ register Display *dpy;
+ XDevice *dev;
+ int control;
+ {
+ int size = 0;
+ int nbytes, i;
+ XDeviceControl *Device = NULL;
+ XDeviceControl *Sav = NULL;
+ xDeviceState *d = NULL;
+ xDeviceState *sav = NULL;
+ xGetDeviceControlReq *req;
+ xGetDeviceControlReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Add_XChangeDeviceControl) == -1)
+ return ((XDeviceControl *) NoSuchExtension);
+
+ GetReq(GetDeviceControl,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceControl;
+ req->deviceid = dev->device_id;
+ req->control = control;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceControl *) NULL;
+ }
+ if (rep.length > 0)
+ {
+ nbytes = (long)rep.length << 2;
+ d = (xDeviceState *) Xmalloc((unsigned) nbytes);
+ if (!d)
+ {
+ _XEatData (dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceControl *) NULL;
+ }
+ sav = d;
+ _XRead (dpy, (char *) d, nbytes);
+
+ switch (d->control)
+ {
+ case DEVICE_RESOLUTION:
+ {
+ xDeviceResolutionState *r;
+
+ r = (xDeviceResolutionState *) d;
+ size += sizeof (XDeviceResolutionState) +
+ (3 * sizeof(int) * r->num_valuators);
+ break;
+ }
+ default:
+ size += d->length;
+ break;
+ }
+
+ Device = (XDeviceControl *) Xmalloc((unsigned) size);
+ if (!Device)
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceControl *) NULL;
+ }
+ Sav = Device;
+
+ d = sav;
+ switch (control)
+ {
+ case DEVICE_RESOLUTION:
+ {
+ int *iptr, *iptr2;
+ xDeviceResolutionState *r;
+ XDeviceResolutionState *R;
+ r = (xDeviceResolutionState *) d;
+ R = (XDeviceResolutionState *) Device;
+
+ R->control = DEVICE_RESOLUTION;
+ R->length = sizeof (XDeviceResolutionState);
+ R->num_valuators = r->num_valuators;
+ iptr = (int *) (R+1);
+ iptr2 = (int *) (r+1);
+ R->resolutions = iptr;
+ R->min_resolutions = iptr + R->num_valuators;
+ R->max_resolutions = iptr + (2 * R->num_valuators);
+ for (i=0; i < (3 * R->num_valuators); i++)
+ *iptr++ = *iptr2++;
+ break;
+ }
+ default:
+ break;
+ }
+ XFree (sav);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Sav);
+ }
+
+void XFreeDeviceControl (control)
+ XDeviceControl *control;
+ {
+ XFree (control);
+ }
diff --git a/nx-X11/lib/Xi/XGetFCtl.c b/nx-X11/lib/Xi/XGetFCtl.c
new file mode 100644
index 000000000..e34c7ced5
--- /dev/null
+++ b/nx-X11/lib/Xi/XGetFCtl.c
@@ -0,0 +1,273 @@
+/* $Xorg: XGetFCtl.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XGetFCtl.c,v 3.3 2001/12/14 19:55:14 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XGetFeedbackControl - get the feedback attributes of an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+XFeedbackState
+*XGetFeedbackControl (dpy, dev, num_feedbacks)
+ register Display *dpy;
+ XDevice *dev;
+ int *num_feedbacks;
+ {
+ int size = 0;
+ int nbytes, i;
+ XFeedbackState *Feedback = NULL;
+ XFeedbackState *Sav = NULL;
+ xFeedbackState *f = NULL;
+ xFeedbackState *sav = NULL;
+ xGetFeedbackControlReq *req;
+ xGetFeedbackControlReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XFeedbackState *) NoSuchExtension);
+
+ GetReq(GetFeedbackControl,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetFeedbackControl;
+ req->deviceid = dev->device_id;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XFeedbackState *) NULL;
+ }
+ if (rep.length > 0)
+ {
+ *num_feedbacks = rep.num_feedbacks;
+ nbytes = (long)rep.length << 2;
+ f = (xFeedbackState *) Xmalloc((unsigned) nbytes);
+ if (!f)
+ {
+ _XEatData (dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XFeedbackState *) NULL;
+ }
+ sav = f;
+ _XRead (dpy, (char *) f, nbytes);
+
+ for (i=0; i<*num_feedbacks; i++)
+ {
+ switch (f->class)
+ {
+ case KbdFeedbackClass:
+ size += sizeof (XKbdFeedbackState);
+ break;
+ case PtrFeedbackClass:
+ size += sizeof (XPtrFeedbackState);
+ break;
+ case IntegerFeedbackClass:
+ size += sizeof (XIntegerFeedbackState);
+ break;
+ case StringFeedbackClass:
+ {
+ xStringFeedbackState *strf = (xStringFeedbackState *) f;
+
+ size += sizeof (XStringFeedbackState) +
+ (strf->num_syms_supported * sizeof (KeySym));
+ }
+ break;
+ case LedFeedbackClass:
+ size += sizeof (XLedFeedbackState);
+ break;
+ case BellFeedbackClass:
+ size += sizeof (XBellFeedbackState);
+ break;
+ default:
+ size += f->length;
+ break;
+ }
+ f = (xFeedbackState *) ((char *) f + f->length);
+ }
+
+ Feedback = (XFeedbackState *) Xmalloc((unsigned) size);
+ if (!Feedback)
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XFeedbackState *) NULL;
+ }
+ Sav = Feedback;
+
+ f = sav;
+ for (i=0; i<*num_feedbacks; i++)
+ {
+ switch (f->class)
+ {
+ case KbdFeedbackClass:
+ {
+ xKbdFeedbackState *k;
+ XKbdFeedbackState *K;
+ k = (xKbdFeedbackState *) f;
+ K = (XKbdFeedbackState *) Feedback;
+
+ K->class = k->class;
+ K->length = sizeof (XKbdFeedbackState);
+ K->id = k->id;
+ K->click = k->click;
+ K->percent = k->percent;
+ K->pitch = k->pitch;
+ K->duration = k->duration;
+ K->led_mask = k->led_mask;
+ K->global_auto_repeat = k->global_auto_repeat;
+ memcpy ((char *) &K->auto_repeats[0],
+ (char *) &k->auto_repeats[0], 32);
+ break;
+ }
+ case PtrFeedbackClass:
+ {
+ xPtrFeedbackState *p;
+ XPtrFeedbackState *P;
+ p = (xPtrFeedbackState *) f;
+ P = (XPtrFeedbackState *) Feedback;
+
+ P->class = p->class;
+ P->length = sizeof (XPtrFeedbackState);
+ P->id = p->id;
+ P->accelNum = p->accelNum;
+ P->accelDenom = p->accelDenom;
+ P->threshold = p->threshold;
+ break;
+ }
+ case IntegerFeedbackClass:
+ {
+ xIntegerFeedbackState *i;
+ XIntegerFeedbackState *I;
+ i = (xIntegerFeedbackState *) f;
+ I = (XIntegerFeedbackState *) Feedback;
+
+ I->class = i->class;
+ I->length = sizeof (XIntegerFeedbackState);
+ I->id = i->id;
+ I->resolution = i->resolution;
+ I->minVal = i->min_value;
+ I->maxVal = i->max_value;
+ break;
+ }
+ case StringFeedbackClass:
+ {
+ xStringFeedbackState *s;
+ XStringFeedbackState *S;
+ s = (xStringFeedbackState *) f;
+ S = (XStringFeedbackState *) Feedback;
+
+ S->class = s->class;
+ S->length = sizeof (XStringFeedbackState) +
+ (s->num_syms_supported * sizeof (KeySym));
+ S->id = s->id;
+ S->max_symbols = s->max_symbols;
+ S->num_syms_supported = s->num_syms_supported;
+ S->syms_supported = (KeySym *) (S+1);
+ memcpy ((char *) S->syms_supported, (char *) (s+1),
+ (S->num_syms_supported * sizeof (KeySym)));
+ break;
+ }
+ case LedFeedbackClass:
+ {
+ xLedFeedbackState *l;
+ XLedFeedbackState *L;
+ l = (xLedFeedbackState *) f;
+ L = (XLedFeedbackState *) Feedback;
+
+ L->class = l->class;
+ L->length = sizeof (XLedFeedbackState);
+ L->id = l->id;
+ L->led_values = l->led_values;
+ L->led_mask = l->led_mask;
+ break;
+ }
+ case BellFeedbackClass:
+ {
+ xBellFeedbackState *b;
+ XBellFeedbackState *B;
+ b = (xBellFeedbackState *) f;
+ B = (XBellFeedbackState *) Feedback;
+
+ B->class = b->class;
+ B->length = sizeof (XBellFeedbackState);
+ B->id = b->id;
+ B->percent = b->percent;
+ B->pitch = b->pitch;
+ B->duration = b->duration;
+ break;
+ }
+ default:
+ break;
+ }
+ f = (xFeedbackState *) ((char *) f + f->length);
+ Feedback = (XFeedbackState *) ((char *) Feedback+Feedback->length);
+ }
+ XFree ((char *)sav);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Sav);
+ }
+
+void XFreeFeedbackList (list)
+ XFeedbackState *list;
+ {
+ XFree ((char *)list);
+ }
diff --git a/nx-X11/lib/Xi/XGetKMap.c b/nx-X11/lib/Xi/XGetKMap.c
new file mode 100644
index 000000000..c794006a3
--- /dev/null
+++ b/nx-X11/lib/Xi/XGetKMap.c
@@ -0,0 +1,111 @@
+/* $Xorg: XGetKMap.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XGetKMap.c,v 3.4 2002/10/16 00:37:28 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XGetDeviceKeyMapping - get the keymap of an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+KeySym *
+XGetDeviceKeyMapping (
+ register Display *dpy,
+ XDevice *dev,
+#if NeedWidePrototypes
+ unsigned int first,
+#else
+ KeyCode first,
+#endif
+ int keycount,
+ int *syms_per_code)
+ {
+ long nbytes;
+ register KeySym *mapping = NULL;
+ xGetDeviceKeyMappingReq *req;
+ xGetDeviceKeyMappingReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((KeySym *) NoSuchExtension);
+
+ GetReq(GetDeviceKeyMapping,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceKeyMapping;
+ req->deviceid = dev->device_id;
+ req->firstKeyCode = first;
+ req->count = keycount;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (KeySym *) NULL;
+ }
+ if (rep.length > 0) {
+ *syms_per_code = rep.keySymsPerKeyCode;
+ nbytes = (long)rep.length << 2;
+ mapping = (KeySym *) Xmalloc((unsigned) nbytes);
+ if (mapping)
+ _XRead (dpy, (char *)mapping, nbytes);
+ else
+ _XEatData (dpy, (unsigned long) nbytes);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (mapping);
+ }
diff --git a/nx-X11/lib/Xi/XGetMMap.c b/nx-X11/lib/Xi/XGetMMap.c
new file mode 100644
index 000000000..04e89d839
--- /dev/null
+++ b/nx-X11/lib/Xi/XGetMMap.c
@@ -0,0 +1,104 @@
+/* $Xorg: XGetMMap.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XGetMMap.c,v 3.3 2001/12/14 19:55:16 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XGetDeviceModifierMapping - get the modifier map of an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+XModifierKeymap
+*XGetDeviceModifierMapping (dpy, dev)
+ register Display *dpy;
+ XDevice *dev;
+ {
+ unsigned long nbytes;
+ XModifierKeymap *res;
+ xGetDeviceModifierMappingReq *req;
+ xGetDeviceModifierMappingReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XModifierKeymap *) NoSuchExtension);
+
+ GetReq(GetDeviceModifierMapping,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceModifierMapping;
+ req->deviceid = dev->device_id;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XModifierKeymap *) NULL;
+ }
+ nbytes = (unsigned long)rep.length << 2;
+ res = (XModifierKeymap *) Xmalloc(sizeof (XModifierKeymap));
+ if (res)
+ {
+ res->modifiermap = (KeyCode *) Xmalloc (nbytes);
+ if (res->modifiermap)
+ _XReadPad(dpy, (char *) res->modifiermap, nbytes);
+ else
+ _XEatData (dpy, (unsigned long) nbytes);
+ res->max_keypermod = rep.numKeyPerModifier;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (res);
+ }
diff --git a/nx-X11/lib/Xi/XGetProp.c b/nx-X11/lib/Xi/XGetProp.c
new file mode 100644
index 000000000..ed5a2d185
--- /dev/null
+++ b/nx-X11/lib/Xi/XGetProp.c
@@ -0,0 +1,120 @@
+/* $Xorg: XGetProp.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XGetProp.c,v 3.3 2001/12/14 19:55:17 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XGetDeviceDontPropagateList - Get the dont_propagate_list for a
+ * window.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+XEventClass
+*XGetDeviceDontPropagateList (dpy, window, count)
+ register Display *dpy;
+ Window window;
+ int *count;
+ {
+ XEventClass *list = NULL;
+ int rlen;
+ xGetDeviceDontPropagateListReq *req;
+ xGetDeviceDontPropagateListReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XEventClass *) NoSuchExtension);
+
+ GetReq(GetDeviceDontPropagateList,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceDontPropagateList;
+ req->window = window;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XEventClass *) NULL;
+ }
+ *count = rep.count;
+
+ if (*count)
+ {
+ rlen = rep.length << 2;
+ list = (XEventClass *) Xmalloc (rep.length * sizeof(XEventClass));
+ if (list)
+ {
+ int i;
+ CARD32 ec;
+
+ /* read and assign each XEventClass separately because
+ * the library representation may not be the same size
+ * as the wire representation (64 bit machines)
+ */
+ for (i = 0; i < rep.length; i++)
+ {
+ _XRead (dpy, (char *)(&ec), sizeof(CARD32));
+ list[i] = (XEventClass)ec;
+ }
+ }
+ else
+ _XEatData (dpy, (unsigned long) rlen);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (list);
+ }
+
diff --git a/nx-X11/lib/Xi/XGetVers.c b/nx-X11/lib/Xi/XGetVers.c
new file mode 100644
index 000000000..318083735
--- /dev/null
+++ b/nx-X11/lib/Xi/XGetVers.c
@@ -0,0 +1,115 @@
+/* $Xorg: XGetVers.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XGetVers.c,v 3.6 2003/07/08 15:39:47 tsi Exp $ */
+
+/***********************************************************************
+ *
+ * XGetExtensionVersion - Get the version of the input extension.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+XExtensionVersion *
+XGetExtensionVersion (
+ register Display *dpy,
+ _Xconst char *name)
+ {
+ XExtensionVersion *ext;
+
+ LockDisplay (dpy);
+ ext = _XiGetExtensionVersion (dpy, name);
+ if (ext != (XExtensionVersion *) NoSuchExtension) {
+ UnlockDisplay (dpy);
+ SyncHandle();
+ }
+ return (ext);
+ }
+
+XExtensionVersion *
+_XiGetExtensionVersion (
+ register Display *dpy,
+ _Xconst char *name)
+ {
+ xGetExtensionVersionReq *req;
+ xGetExtensionVersionReply rep;
+ XExtensionVersion *ext;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ if (_XiCheckExtInit(dpy, Dont_Check) == -1)
+ return ((XExtensionVersion *) NoSuchExtension);
+
+ GetReq(GetExtensionVersion,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetExtensionVersion;
+ req->nbytes = name ? strlen(name) : 0;
+ req->length += (unsigned)(req->nbytes+3)>>2;
+ _XSend(dpy, name, (long)req->nbytes);
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xTrue))
+ {
+ return (XExtensionVersion *) NULL;
+ }
+ ext = (XExtensionVersion *) Xmalloc (sizeof (XExtensionVersion));
+ if (ext)
+ {
+ ext->present = rep.present;
+ if (ext->present)
+ {
+ ext->major_version = rep.major_version;
+ ext->minor_version = rep.minor_version;
+ }
+ }
+ return (ext);
+ }
+
diff --git a/nx-X11/lib/Xi/XGrDvBut.c b/nx-X11/lib/Xi/XGrDvBut.c
new file mode 100644
index 000000000..48381f8e5
--- /dev/null
+++ b/nx-X11/lib/Xi/XGrDvBut.c
@@ -0,0 +1,114 @@
+/* $Xorg: XGrDvBut.c,v 1.4 2001/02/09 02:03:50 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XGrDvBut.c,v 3.4 2001/12/14 19:55:17 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XGrabDeviceBut - Grab a button on an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XGrabDeviceButton (dpy, dev, button, modifiers, modifier_device,
+ grab_window, owner_events, event_count, event_list, this_device_mode,
+ other_devices_mode)
+ register Display *dpy;
+ XDevice *dev;
+ unsigned int button; /* CARD8 */
+ unsigned int modifiers; /* CARD16 */
+ XDevice *modifier_device;
+ Window grab_window;
+ Bool owner_events;
+ unsigned int event_count;
+ XEventClass *event_list;
+ int this_device_mode;
+ int other_devices_mode;
+ {
+ register xGrabDeviceButtonReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(GrabDeviceButton, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GrabDeviceButton;
+ req->grabbed_device = dev->device_id;
+ req->button = button;
+ req->modifiers = modifiers;
+ if (modifier_device)
+ req->modifier_device = modifier_device->device_id;
+ else
+ req->modifier_device = UseXKeyboard;
+ req->grabWindow = grab_window;
+ req->ownerEvents = owner_events;
+ req->event_count = event_count;
+ req->this_device_mode = this_device_mode;
+ req->other_devices_mode = other_devices_mode;
+ req->length += event_count;
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ event_count <<= 2;
+ Data32 (dpy, (long *) event_list, event_count);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/nx-X11/lib/Xi/XGrDvKey.c b/nx-X11/lib/Xi/XGrDvKey.c
new file mode 100644
index 000000000..94e9ba444
--- /dev/null
+++ b/nx-X11/lib/Xi/XGrDvKey.c
@@ -0,0 +1,117 @@
+/* $Xorg: XGrDvKey.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XGrDvKey.c,v 3.3 2001/12/14 19:55:17 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XGrabDeviceKey - Grab a key on an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XGrabDeviceKey (dpy, dev, key, modifiers, modifier_device,
+ grab_window, owner_events, event_count, event_list, this_device_mode,
+ other_devices_mode)
+ register Display *dpy;
+ XDevice *dev;
+ unsigned int key; /* CARD8 */
+ unsigned int modifiers; /* CARD16 */
+ XDevice *modifier_device;
+ Window grab_window;
+ Bool owner_events;
+ unsigned int event_count;
+ XEventClass *event_list;
+ int this_device_mode;
+ int other_devices_mode;
+ {
+ register xGrabDeviceKeyReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(GrabDeviceKey, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GrabDeviceKey;
+ req->grabbed_device = dev->device_id;
+ req->key = key;
+ req->modifiers = modifiers;
+ if (modifier_device)
+ req->modifier_device = modifier_device->device_id;
+ else
+ req->modifier_device = UseXKeyboard;
+ req->grabWindow = grab_window;
+ req->ownerEvents = owner_events;
+ req->event_count = event_count;
+ req->this_device_mode = this_device_mode;
+ req->other_devices_mode = other_devices_mode;
+ req->length += event_count;
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ if (event_count)
+ {
+ event_count <<= 2;
+ Data32 (dpy, (long *) event_list, event_count);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/nx-X11/lib/Xi/XGrabDev.c b/nx-X11/lib/Xi/XGrabDev.c
new file mode 100644
index 000000000..f49a6bd34
--- /dev/null
+++ b/nx-X11/lib/Xi/XGrabDev.c
@@ -0,0 +1,109 @@
+/* $Xorg: XGrabDev.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XGrabDev.c,v 3.3 2001/12/14 19:55:17 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XGrabDevice - grab an extension input device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XGrabDevice (dpy, dev, grab_window, ownerEvents, event_count, event_list,
+ this_device_mode, other_devices_mode, time)
+ register Display *dpy;
+ XDevice *dev;
+ Window grab_window;
+ Bool ownerEvents;
+ int event_count;
+ XEventClass *event_list;
+ int this_device_mode;
+ int other_devices_mode;
+ Time time;
+ {
+ xGrabDeviceReply rep;
+ register xGrabDeviceReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(GrabDevice,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GrabDevice;
+
+ req->deviceid = dev->device_id;
+ req->grabWindow = grab_window;
+ req->ownerEvents = ownerEvents;
+ req->event_count = event_count;
+ req->this_device_mode = this_device_mode;
+ req->other_devices_mode = other_devices_mode;
+ req->time = time;
+ req->length += event_count;
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ event_count <<= 2;
+ Data32 (dpy, (long *) event_list, event_count);
+
+ if (_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0)
+ rep.status = GrabSuccess;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.status);
+ }
diff --git a/nx-X11/lib/Xi/XGtFocus.c b/nx-X11/lib/Xi/XGtFocus.c
new file mode 100644
index 000000000..29e8de7b4
--- /dev/null
+++ b/nx-X11/lib/Xi/XGtFocus.c
@@ -0,0 +1,92 @@
+/* $Xorg: XGtFocus.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XGtFocus.c,v 3.3 2001/12/14 19:55:18 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XGetDeviceFocus - Get the focus of an input device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XGetDeviceFocus (dpy, dev, focus, revert_to, time)
+ register Display *dpy;
+ XDevice *dev;
+ Window *focus;
+ int *revert_to;
+ Time *time;
+ {
+ xGetDeviceFocusReq *req;
+ xGetDeviceFocusReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(GetDeviceFocus,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceFocus;
+ req->deviceid = dev->device_id;
+
+ (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
+ *focus = rep.focus;
+ *revert_to = rep.revertTo;
+ *time = rep.time;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/nx-X11/lib/Xi/XGtSelect.c b/nx-X11/lib/Xi/XGtSelect.c
new file mode 100644
index 000000000..966365367
--- /dev/null
+++ b/nx-X11/lib/Xi/XGtSelect.c
@@ -0,0 +1,146 @@
+/* $Xorg: XGtSelect.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XGtSelect.c,v 3.3 2001/12/14 19:55:19 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XGetSelectedExtensionEvents - return a list of currently selected events.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XGetSelectedExtensionEvents (dpy, w, this_client_count, this_client_list,
+ all_clients_count, all_clients_list)
+ register Display *dpy;
+ Window w;
+ int *this_client_count;
+ XEventClass **this_client_list;
+ int *all_clients_count;
+ XEventClass **all_clients_list;
+ {
+ int tlen, alen;
+ register xGetSelectedExtensionEventsReq *req;
+ xGetSelectedExtensionEventsReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+ GetReq(GetSelectedExtensionEvents,req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetSelectedExtensionEvents;
+ req->window = w;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return Success;
+ }
+
+ *this_client_count = rep.this_client_count;
+ *all_clients_count = rep.all_clients_count;
+
+ if (rep.length)
+ {
+ int i;
+ CARD32 ec;
+ tlen = (*this_client_count) * sizeof(CARD32);
+ alen = (rep.length << 2) - tlen;
+
+ if (tlen)
+ {
+ *this_client_list = (XEventClass *) Xmalloc (
+ *this_client_count * sizeof(XEventClass));
+ if (!*this_client_list)
+ {
+ _XEatData (dpy, (unsigned long) tlen+alen);
+ return (Success);
+ }
+ for (i = 0; i < *this_client_count; i++)
+ {
+ _XRead (dpy, (char *)(&ec), sizeof(CARD32));
+ (*this_client_list)[i] = (XEventClass)ec;
+ }
+ }
+ else
+ *this_client_list = (XEventClass *) NULL;
+ if (alen)
+ {
+ *all_clients_list = (XEventClass *) Xmalloc (
+ *all_clients_count * sizeof(XEventClass));
+ if (!*all_clients_list)
+ {
+ Xfree((char *)*this_client_list);
+ *this_client_list = NULL;
+ _XEatData (dpy, (unsigned long) alen);
+ return (Success);
+ }
+ for (i = 0; i < *all_clients_count; i++)
+ {
+ _XRead (dpy, (char *)(&ec), sizeof(CARD32));
+ (*all_clients_list)[i] = (XEventClass)ec;
+ }
+ }
+ else
+ *all_clients_list = (XEventClass *) NULL;
+
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/nx-X11/lib/Xi/XIint.h b/nx-X11/lib/Xi/XIint.h
new file mode 100644
index 000000000..fdca57d6a
--- /dev/null
+++ b/nx-X11/lib/Xi/XIint.h
@@ -0,0 +1,25 @@
+/* $XFree86: xc/lib/Xi/XIint.h,v 3.2 2003/07/07 15:34:22 eich Exp $ */
+
+/*
+ * XIint.h - Header definition and support file for the internal
+ * support routines used by the Xi library.
+ */
+
+#ifndef _XIINT_H_
+#define _XIINT_H_
+
+extern XExtDisplayInfo * XInput_find_display(
+ Display*
+);
+
+extern int _XiCheckExtInit(
+ Display*,
+ int
+);
+
+extern XExtensionVersion * _XiGetExtensionVersion(
+ Display*,
+ _Xconst char*
+);
+
+#endif
diff --git a/nx-X11/lib/Xi/XListDev.c b/nx-X11/lib/Xi/XListDev.c
new file mode 100644
index 000000000..279beded0
--- /dev/null
+++ b/nx-X11/lib/Xi/XListDev.c
@@ -0,0 +1,259 @@
+/* $Xorg: XListDev.c,v 1.5 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XListDev.c,v 3.4 2001/12/14 19:55:19 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XListInputDevices - Request the server to return a list of
+ * available input devices.
+ *
+ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+XDeviceInfo
+*XListInputDevices(dpy, ndevices)
+ register Display *dpy;
+ int *ndevices;
+ {
+ int size;
+ xListInputDevicesReq *req;
+ xListInputDevicesReply rep;
+ xDeviceInfo *list, *slist = NULL;
+ XDeviceInfo *sclist = NULL;
+ XDeviceInfo *clist = NULL;
+ xAnyClassPtr any, sav_any;
+ XAnyClassPtr Any;
+ char *nptr, *Nptr;
+ register int i,j,k;
+ register long rlen;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XDeviceInfo *) NULL);
+
+ GetReq(ListInputDevices,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ListInputDevices;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceInfo *) NULL;
+ }
+
+ if ((*ndevices = rep.ndevices)) /* at least 1 input device */
+ {
+ size = *ndevices * sizeof (XDeviceInfo);
+ rlen = rep.length << 2; /* multiply length by 4 */
+ list = (xDeviceInfo *) Xmalloc (rlen);
+ slist = list;
+ if (!slist)
+ {
+ _XEatData (dpy, (unsigned long) rlen);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceInfo *) NULL;
+ }
+ _XRead (dpy, (char *)list, rlen);
+
+ any = (xAnyClassPtr) ((char *) list +
+ (*ndevices * sizeof(xDeviceInfo)));
+ sav_any = any;
+ for (i=0; i<*ndevices; i++, list++)
+ {
+ for (j=0; j<(int)list->num_classes; j++)
+ {
+ switch (any->class)
+ {
+ case KeyClass:
+ size += sizeof (XKeyInfo);
+ break;
+ case ButtonClass:
+ size += sizeof (XButtonInfo);
+ break;
+ case ValuatorClass:
+ {
+ xValuatorInfoPtr v;
+ v = (xValuatorInfoPtr) any;
+ size += sizeof (XValuatorInfo) +
+ (v->num_axes * sizeof (XAxisInfo));
+ break;
+ }
+ default:
+ break;
+ }
+ any = (xAnyClassPtr) ((char *) any + any->length);
+ }
+ }
+
+ for (i=0, nptr = (char *) any; i<*ndevices; i++)
+ {
+ size += *nptr +1;
+ nptr += (*nptr + 1);
+ }
+
+ clist = (XDeviceInfoPtr) Xmalloc (size);
+ if (!clist)
+ {
+ XFree ((char *)slist);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceInfo *) NULL;
+ }
+ sclist = clist;
+ Any = (XAnyClassPtr) ((char *) clist +
+ (*ndevices * sizeof (XDeviceInfo)));
+ list = slist;
+ any = sav_any;
+ for (i=0; i<*ndevices; i++, list++, clist++)
+ {
+ clist->type = list->type;
+ clist->id = list->id;
+ clist->use = list->use;
+ clist->num_classes = list->num_classes;
+ clist->inputclassinfo = Any;
+ for (j=0; j<(int)list->num_classes; j++)
+ {
+ switch (any->class)
+ {
+ case KeyClass:
+ {
+ XKeyInfoPtr K = (XKeyInfoPtr) Any;
+ xKeyInfoPtr k = (xKeyInfoPtr) any;
+ K->class = KeyClass;
+ K->length = sizeof (XKeyInfo);
+ K->min_keycode = k->min_keycode;
+ K->max_keycode = k->max_keycode;
+ K->num_keys = k->num_keys;
+ break;
+ }
+ case ButtonClass:
+ {
+ XButtonInfoPtr B = (XButtonInfoPtr) Any;
+ xButtonInfoPtr b = (xButtonInfoPtr) any;
+ B->class = ButtonClass;
+ B->length = sizeof (XButtonInfo);
+ B->num_buttons = b->num_buttons;
+ break;
+ }
+ case ValuatorClass:
+ {
+ XValuatorInfoPtr V = (XValuatorInfoPtr) Any;
+ xValuatorInfoPtr v = (xValuatorInfoPtr) any;
+ XAxisInfoPtr A;
+ xAxisInfoPtr a;
+
+ V->class = ValuatorClass;
+ V->length = sizeof (XValuatorInfo) +
+ (v->num_axes * sizeof (XAxisInfo));
+ V->num_axes = v->num_axes;
+ V->motion_buffer = v->motion_buffer_size;
+ V->mode = v->mode;
+ A = (XAxisInfoPtr) ((char *) V + sizeof(XValuatorInfo));
+ V->axes = A;
+ a = (xAxisInfoPtr) ((char *) any +
+ sizeof (xValuatorInfo));
+ for (k=0; k<(int)v->num_axes; k++,a++,A++)
+ {
+ A->min_value = a->min_value;
+ A->max_value = a->max_value;
+ A->resolution = a->resolution;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ any = (xAnyClassPtr) ((char *) any + any->length);
+ Any = (XAnyClassPtr) ((char *) Any + Any->length);
+ }
+ }
+
+ clist = sclist;
+ nptr = (char *) any;
+ Nptr = (char *) Any;
+ for (i=0; i<*ndevices; i++,clist++)
+ {
+ clist->name = (char *) Nptr;
+ memcpy (Nptr, nptr+1, *nptr);
+ Nptr += (*nptr);
+ *Nptr++ = '\0';
+ nptr += (*nptr + 1);
+ }
+ }
+
+ XFree ((char *)slist);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (sclist);
+ }
+
+/***********************************************************************
+ *
+ * Free the list of input devices.
+ *
+ */
+
+void XFreeDeviceList (list)
+ XDeviceInfo *list;
+ {
+ if (list != NULL)
+ {
+ XFree ((char *) list);
+ }
+ }
diff --git a/nx-X11/lib/Xi/XOpenDev.c b/nx-X11/lib/Xi/XOpenDev.c
new file mode 100644
index 000000000..7930a9a80
--- /dev/null
+++ b/nx-X11/lib/Xi/XOpenDev.c
@@ -0,0 +1,113 @@
+/* $Xorg: XOpenDev.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XOpenDev.c,v 3.3 2001/12/14 19:55:20 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XOpenDevice - Request the server to open and extension input device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+XDevice
+*XOpenDevice(dpy, id)
+ register Display *dpy;
+ register XID id;
+ {
+ register long rlen; /* raw length */
+ xOpenDeviceReq *req;
+ xOpenDeviceReply rep;
+ XDevice *dev;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XDevice *) NoSuchExtension);
+
+ GetReq(OpenDevice,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_OpenDevice;
+ req->deviceid = id;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDevice *) NULL;
+ }
+
+ rlen = rep.length << 2;
+ dev = (XDevice *) Xmalloc (sizeof(XDevice) + rep.num_classes *
+ sizeof (XInputClassInfo));
+ if (dev)
+ {
+ int dlen; /* data length */
+
+ dev->device_id = req->deviceid;
+ dev->num_classes = rep.num_classes;
+ dev->classes = (XInputClassInfo *) ((char *) dev + sizeof (XDevice));
+ dlen = rep.num_classes * sizeof(xInputClassInfo);
+ _XRead (dpy, (char *)dev->classes, dlen);
+ /* could be padding that we still need to eat (yummy!) */
+ if(rlen - dlen > 0)
+ _XEatData (dpy, (unsigned long) rlen - dlen);
+ }
+ else
+ _XEatData (dpy, (unsigned long) rlen);
+
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return (dev);
+ }
+
diff --git a/nx-X11/lib/Xi/XQueryDv.c b/nx-X11/lib/Xi/XQueryDv.c
new file mode 100644
index 000000000..1450c15fb
--- /dev/null
+++ b/nx-X11/lib/Xi/XQueryDv.c
@@ -0,0 +1,198 @@
+/* $Xorg: XQueryDv.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XQueryDv.c,v 3.3 2001/12/14 19:55:20 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XQueryDeviceState - Query the state of an extension input device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+XDeviceState
+*XQueryDeviceState (dpy, dev)
+ register Display *dpy;
+ XDevice *dev;
+ {
+ int i,j;
+ int rlen;
+ int size = 0;
+ xQueryDeviceStateReq *req;
+ xQueryDeviceStateReply rep;
+ XDeviceState *state = NULL;
+ XInputClass *any, *Any;
+ char *data;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XDeviceState *) NoSuchExtension);
+
+ GetReq(QueryDeviceState,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_QueryDeviceState;
+ req->deviceid = dev->device_id;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceState *) NULL;
+ }
+
+ rlen = rep.length << 2;
+ if (rlen > 0)
+ {
+ data = Xmalloc (rlen);
+ if (!data)
+ {
+ _XEatData (dpy, (unsigned long) rlen);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((XDeviceState *) NULL);
+ }
+ _XRead (dpy, data, rlen);
+
+ for (i=0, any=(XInputClass *) data; i<(int)rep.num_classes; i++)
+ {
+ switch (any->class)
+ {
+ case KeyClass:
+ size += sizeof (XKeyState);
+ break;
+ case ButtonClass:
+ size += sizeof (XButtonState);
+ break;
+ case ValuatorClass:
+ {
+ xValuatorState *v = (xValuatorState *) any;
+ size += (sizeof (XValuatorState) +
+ (v->num_valuators * sizeof(int)));
+ }
+ break;
+ }
+ any = (XInputClass *) ((char *) any + any->length);
+ }
+ state = (XDeviceState *) Xmalloc (size + sizeof(XDeviceState));
+ if (!state)
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((XDeviceState *) NULL);
+ }
+ state->device_id = dev->device_id;
+ state->num_classes = rep.num_classes;
+ state->data = (XInputClass *) (state + 1);
+
+ Any = state->data;
+ for (i=0, any=(XInputClass *) data; i<(int)rep.num_classes; i++)
+ {
+ switch (any->class)
+ {
+ case KeyClass:
+ {
+ xKeyState *k = (xKeyState *) any;
+ XKeyState *K = (XKeyState *) Any;
+ K->class = k->class;
+ K->length = sizeof (XKeyState);
+ K->num_keys = k->num_keys;
+ memcpy ((char *) &K->keys[0], (char *) &k->keys[0], 32);
+ Any = (XInputClass *) (K+1);
+ }
+ break;
+ case ButtonClass:
+ {
+ xButtonState *b = (xButtonState *) any;
+ XButtonState *B = (XButtonState *) Any;
+ B->class = b->class;
+ B->length = sizeof (XButtonState);
+ B->num_buttons = b->num_buttons;
+ memcpy ((char *) &B->buttons[0], (char *) &b->buttons[0],
+ 32);
+ Any = (XInputClass *) (B+1);
+ }
+ break;
+ case ValuatorClass:
+ {
+ xValuatorState *v = (xValuatorState *) any;
+ XValuatorState *V = (XValuatorState *) Any;
+ CARD32 *valuators = (CARD32 *) (v+1);
+ V->class = v->class;
+ V->length = sizeof (XValuatorState);
+ V->num_valuators = v->num_valuators;
+ V->mode = v->mode;
+ Any = (XInputClass *) (V+1);
+ V->valuators = (int *) Any;
+ for (j=0; j<(int)V->num_valuators; j++)
+ *(V->valuators + j) = *valuators++;
+ Any = (XInputClass *)((char *) Any +
+ V->num_valuators * sizeof (int));
+ }
+ break;
+ }
+ any = (XInputClass *) ((char *) any + any->length);
+ }
+ Xfree(data);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (state);
+ }
+
+void XFreeDeviceState (list)
+ XDeviceState *list;
+ {
+ XFree ((char *)list);
+ }
diff --git a/nx-X11/lib/Xi/XSelect.c b/nx-X11/lib/Xi/XSelect.c
new file mode 100644
index 000000000..c0a8dc832
--- /dev/null
+++ b/nx-X11/lib/Xi/XSelect.c
@@ -0,0 +1,94 @@
+/* $Xorg: XSelect.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XSelect.c,v 3.3 2001/12/14 19:55:21 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XSelectExtensionEvent - Select input from an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XSelectExtensionEvent (dpy, w, event_list, count)
+ register Display *dpy;
+ Window w;
+ XEventClass *event_list;
+ int count;
+ {
+ register xSelectExtensionEventReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy,XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+ GetReq(SelectExtensionEvent,req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SelectExtensionEvent;
+ req->window = w;
+ req->count = count;
+ req->length += count;
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ count <<= 2;
+ Data32 (dpy, (long *) event_list, count);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/nx-X11/lib/Xi/XSetBMap.c b/nx-X11/lib/Xi/XSetBMap.c
new file mode 100644
index 000000000..716d8c5fc
--- /dev/null
+++ b/nx-X11/lib/Xi/XSetBMap.c
@@ -0,0 +1,93 @@
+/* $Xorg: XSetBMap.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XSetBMap.c,v 3.3 2001/12/14 19:55:21 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XSetDeviceButtonMapping - Set the button mapping of an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+#define NEED_REPLIES
+
+/* returns either DeviceMappingSuccess or DeviceMappingBusy */
+
+int
+XSetDeviceButtonMapping (dpy, device, map, nmap)
+ register Display *dpy;
+ XDevice *device;
+ unsigned char map[];
+ int nmap;
+ {
+ register xSetDeviceButtonMappingReq *req;
+ xSetDeviceButtonMappingReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay(dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+ GetReq (SetDeviceButtonMapping, req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SetDeviceButtonMapping;
+ req->map_length = nmap;
+ req->length += (nmap + 3)>>2;
+ req->deviceid = device->device_id;
+
+ Data (dpy, (char *)map, (long) nmap); /* note that map is char[] */
+ if (_XReply (dpy, (xReply *)&rep, 0, xFalse) == 0) /* suppress error */
+ rep.status = MappingSuccess;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((int) rep.status);
+ }
diff --git a/nx-X11/lib/Xi/XSetDVal.c b/nx-X11/lib/Xi/XSetDVal.c
new file mode 100644
index 000000000..3cee1a939
--- /dev/null
+++ b/nx-X11/lib/Xi/XSetDVal.c
@@ -0,0 +1,100 @@
+/* $Xorg: XSetDVal.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XSetDVal.c,v 3.3 2001/12/14 19:55:22 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XSetDeviceValuators - Set the value of valuators on an extension input
+ * device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XSetDeviceValuators (dpy, dev, valuators, first_valuator, num_valuators)
+ register Display *dpy;
+ XDevice *dev;
+ int *valuators;
+ int first_valuator;
+ int num_valuators;
+ {
+ xSetDeviceValuatorsReq *req;
+ xSetDeviceValuatorsReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Add_XSetDeviceValuators) == -1)
+ return (NoSuchExtension);
+
+ GetReq(SetDeviceValuators,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SetDeviceValuators;
+ req->deviceid = dev->device_id;
+ req->first_valuator = first_valuator;
+ req->num_valuators = num_valuators;
+ req->length += num_valuators;
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ num_valuators <<= 2;
+ Data (dpy, (char *) valuators, num_valuators);
+
+ (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.status);
+ }
+
diff --git a/nx-X11/lib/Xi/XSetMMap.c b/nx-X11/lib/Xi/XSetMMap.c
new file mode 100644
index 000000000..d31197cff
--- /dev/null
+++ b/nx-X11/lib/Xi/XSetMMap.c
@@ -0,0 +1,91 @@
+/* $Xorg: XSetMMap.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XSetMMap.c,v 3.3 2001/12/14 19:55:22 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XSetDeviceModifierMapping - set the modifier map of an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XSetDeviceModifierMapping (dpy, dev, modmap)
+ register Display *dpy;
+ XDevice *dev;
+ XModifierKeymap *modmap;
+ {
+ int mapSize = modmap->max_keypermod << 3; /* 8 modifiers */
+ xSetDeviceModifierMappingReq *req;
+ xSetDeviceModifierMappingReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReqExtra(SetDeviceModifierMapping, mapSize, req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SetDeviceModifierMapping;
+ req->deviceid = dev->device_id;
+ req->numKeyPerModifier = modmap->max_keypermod;
+ memcpy((char *)&req[1], modmap->modifiermap, mapSize);
+
+ (void) _XReply(dpy, (xReply *) &rep,
+ (sizeof(xSetDeviceModifierMappingReply) - sizeof(xReply)) >> 2, xTrue);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.success);
+ }
diff --git a/nx-X11/lib/Xi/XSetMode.c b/nx-X11/lib/Xi/XSetMode.c
new file mode 100644
index 000000000..5f62fb197
--- /dev/null
+++ b/nx-X11/lib/Xi/XSetMode.c
@@ -0,0 +1,88 @@
+/* $Xorg: XSetMode.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XSetMode.c,v 3.3 2001/12/14 19:55:23 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XSetDeviceMode - Set the mode of an extension input device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XSetDeviceMode (dpy, dev, mode)
+ register Display *dpy;
+ XDevice *dev;
+ int mode;
+ {
+ xSetDeviceModeReq *req;
+ xSetDeviceModeReply rep;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(SetDeviceMode,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SetDeviceMode;
+ req->deviceid = dev->device_id;
+ req->mode = mode;
+
+ (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.status);
+ }
+
diff --git a/nx-X11/lib/Xi/XSndExEv.c b/nx-X11/lib/Xi/XSndExEv.c
new file mode 100644
index 000000000..28b654ba5
--- /dev/null
+++ b/nx-X11/lib/Xi/XSndExEv.c
@@ -0,0 +1,123 @@
+/* $Xorg: XSndExEv.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XSndExEv.c,v 3.3 2001/12/14 19:55:23 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XSendExtensionEvent - send an extension event to a client.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+extern Status _XiEventToWire();
+
+Status
+XSendExtensionEvent (dpy, dev, dest, prop, count, list, event)
+ register Display *dpy;
+ XDevice *dev;
+ Window dest;
+ Bool prop;
+ int count;
+ XEventClass *list;
+ XEvent *event;
+ {
+ int num_events;
+ int ev_size;
+ xSendExtensionEventReq *req;
+ xEvent *ev;
+ register Status (**fp)();
+ Status status;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ /* call through display to find proper conversion routine */
+
+ fp = &dpy->wire_vec[event->type & 0177];
+ if (*fp == NULL)
+ *fp = _XiEventToWire;
+ status = (**fp)(dpy, event, &ev, &num_events);
+
+ if (status)
+ {
+ GetReq(SendExtensionEvent,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SendExtensionEvent;
+ req->deviceid = dev->device_id;
+ req->destination = dest;
+ req->propagate = prop;
+ req->count = count;
+ req->num_events = num_events;
+ ev_size = num_events * sizeof (xEvent);
+ req->length += (count + (ev_size >> 2));
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "count" is changed in a separate assignment
+ statement. Any extra events must be sent before the event
+ list, in order to ensure quad alignment. */
+
+ Data (dpy, (char *) ev, ev_size);
+
+ count <<= 2;
+ Data32 (dpy, (long *) list, count);
+ XFree ((char *)ev);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (status);
+ }
+
diff --git a/nx-X11/lib/Xi/XStFocus.c b/nx-X11/lib/Xi/XStFocus.c
new file mode 100644
index 000000000..fc61896b6
--- /dev/null
+++ b/nx-X11/lib/Xi/XStFocus.c
@@ -0,0 +1,87 @@
+/* $Xorg: XStFocus.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XStFocus.c,v 3.3 2001/12/14 19:55:23 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XSetDeviceFocus - Set the focus of an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XSetDeviceFocus(dpy, dev, focus, revert_to, time)
+ register Display *dpy;
+ XDevice *dev;
+ Window focus;
+ int revert_to;
+ Time time;
+ {
+ xSetDeviceFocusReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+
+ GetReq(SetDeviceFocus,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SetDeviceFocus;
+ req->device = dev->device_id;
+ req->focus = focus;
+ req->revertTo = revert_to;
+ req->time = time;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/nx-X11/lib/Xi/XUngrDev.c b/nx-X11/lib/Xi/XUngrDev.c
new file mode 100644
index 000000000..e3aec3606
--- /dev/null
+++ b/nx-X11/lib/Xi/XUngrDev.c
@@ -0,0 +1,86 @@
+/* $Xorg: XUngrDev.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XUngrDev.c,v 3.3 2001/12/14 19:55:23 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XUngrabDevice - Ungrab an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XUngrabDevice (dpy, dev, time)
+ register Display *dpy;
+ XDevice *dev;
+ Time time;
+ {
+ register xUngrabDeviceReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(UngrabDevice,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_UngrabDevice;
+
+ req->deviceid = dev->device_id;
+ req->time = time;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/nx-X11/lib/Xi/XUngrDvB.c b/nx-X11/lib/Xi/XUngrDvB.c
new file mode 100644
index 000000000..7e96665dd
--- /dev/null
+++ b/nx-X11/lib/Xi/XUngrDvB.c
@@ -0,0 +1,93 @@
+/* $Xorg: XUngrDvB.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XUngrDvB.c,v 3.3 2001/12/14 19:55:25 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XUngrabDeviceButton - Ungrab a button on an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XUngrabDeviceButton(dpy, dev, button, modifiers, modifier_dev, grab_window)
+ register Display *dpy;
+ XDevice *dev;
+ unsigned int button; /* CARD8 */
+ unsigned int modifiers; /* CARD16 */
+ XDevice *modifier_dev;
+ Window grab_window;
+ {
+ register xUngrabDeviceButtonReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay(dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+ GetReq(UngrabDeviceButton, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_UngrabDeviceButton;
+ req->grabbed_device = dev->device_id;
+ req->button = button;
+ req->modifiers = modifiers;
+ if (modifier_dev)
+ req->modifier_device = modifier_dev->device_id;
+ else
+ req->modifier_device = UseXKeyboard;
+ req->grabWindow = grab_window;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/nx-X11/lib/Xi/XUngrDvK.c b/nx-X11/lib/Xi/XUngrDvK.c
new file mode 100644
index 000000000..26a5841de
--- /dev/null
+++ b/nx-X11/lib/Xi/XUngrDvK.c
@@ -0,0 +1,93 @@
+/* $Xorg: XUngrDvK.c,v 1.4 2001/02/09 02:03:51 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ 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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+/* $XFree86: xc/lib/Xi/XUngrDvK.c,v 3.3 2001/12/14 19:55:26 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * XUngrabDeviceKey - Ungrab a key on an extension device.
+ *
+ */
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/extutil.h>
+#include "XIint.h"
+
+int
+XUngrabDeviceKey (dpy, dev, key, modifiers, modifier_dev, grab_window)
+ register Display *dpy;
+ XDevice *dev;
+ unsigned int key; /* CARD8 */
+ unsigned int modifiers; /* CARD16 */
+ XDevice *modifier_dev;
+ Window grab_window;
+ {
+ register xUngrabDeviceKeyReq *req;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ LockDisplay(dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+ GetReq(UngrabDeviceKey, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_UngrabDeviceKey;
+ req->grabbed_device = dev->device_id;
+ req->key = key;
+ req->modifiers = modifiers;
+ if (modifier_dev)
+ req->modifier_device = modifier_dev->device_id;
+ else
+ req->modifier_device = UseXKeyboard;
+ req->grabWindow = grab_window;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/nx-X11/lib/Xi/Xi-def.cpp b/nx-X11/lib/Xi/Xi-def.cpp
new file mode 100644
index 000000000..62760066d
--- /dev/null
+++ b/nx-X11/lib/Xi/Xi-def.cpp
@@ -0,0 +1,49 @@
+LIBRARY XI
+VERSION LIBRARY_VERSION
+EXPORTS
+ XAllowDeviceEvents
+ XChangeDeviceControl
+ XChangeDeviceDontPropagateList
+ XChangeDeviceKeyMapping
+ XChangeFeedbackControl
+ XChangeKeyboardDevice
+ XChangePointerDevice
+ XCloseDevice
+ XDeviceBell
+ XFreeDeviceControl
+ XFreeDeviceList
+ XFreeDeviceMotionEvents
+ XFreeDeviceState
+ XFreeFeedbackList
+ XGetDeviceButtonMapping
+ XGetDeviceControl
+ XGetDeviceDontPropagateList
+ XGetDeviceFocus
+ XGetDeviceKeyMapping
+ XGetDeviceModifierMapping
+ XGetDeviceMotionEvents
+ XGetExtensionVersion
+ XGetFeedbackControl
+ XGetSelectedExtensionEvents
+ XGrabDevice
+ XGrabDeviceButton
+ XGrabDeviceKey
+ XListInputDevices
+ XOpenDevice
+ XQueryDeviceState
+ XSelectExtensionEvent
+ XSendExtensionEvent
+ XSetDeviceButtonMapping
+ XSetDeviceFocus
+ XSetDeviceMode
+ XSetDeviceModifierMapping
+ XSetDeviceValuators
+ XUngrabDevice
+ XUngrabDeviceButton
+ XUngrabDeviceKey
+ _xibadclass
+ _xibaddevice
+ _xibadevent
+ _xibadmode
+ _xidevicebusy
+/* $Xorg: Xi-def.cpp,v 1.3 2000/08/17 19:45:58 cpqbld Exp $ */
diff --git a/nx-X11/lib/Xinerama/Imakefile b/nx-X11/lib/Xinerama/Imakefile
new file mode 100644
index 000000000..99271306b
--- /dev/null
+++ b/nx-X11/lib/Xinerama/Imakefile
@@ -0,0 +1,30 @@
+XCOMM $XFree86: xc/lib/Xinerama/Imakefile,v 1.4 2002/10/16 00:37:31 dawes Exp $
+
+#define DoNormalLib NormalLibXinerama
+#define DoSharedLib SharedLibXinerama
+#define DoDebugLib DebugLibXinerama
+#define DoProfileLib ProfileLibXinerama
+#define LibName Xinerama
+#define SoRev SOXINERAMAREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXineramaReqs
+REQUIREDLIBS = SharedXineramaReqs
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ SRCS = Xinerama.c
+ OBJS = Xinerama.o
+ LINTLIBS = $(LINTXLIB)
+
+#define IncludeSharedObjectInNormalLib
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/Xinerama/Xinerama-def.cpp b/nx-X11/lib/Xinerama/Xinerama-def.cpp
new file mode 100644
index 000000000..01449d15b
--- /dev/null
+++ b/nx-X11/lib/Xinerama/Xinerama-def.cpp
@@ -0,0 +1,14 @@
+LIBRARY Xinerama
+VERSION LIBRARY_VERSION
+EXPORTS
+ XPanoramiXAllocInfo
+ XPanoramiXGetScreenCount
+ XPanoramiXGetScreenSize
+ XPanoramiXGetState
+ XPanoramiXQueryExtension
+ XPanoramiXQueryVersion
+ XineramaIsActive
+ XineramaQueryExtension
+ XineramaQueryScreens
+ XineramaQueryVersion
+/* $XFree86$ */
diff --git a/nx-X11/lib/Xinerama/Xinerama.c b/nx-X11/lib/Xinerama/Xinerama.c
new file mode 100644
index 000000000..43084b213
--- /dev/null
+++ b/nx-X11/lib/Xinerama/Xinerama.c
@@ -0,0 +1,319 @@
+/* $Xorg: XPanoramiX.c,v 1.4 2000/08/17 19:45:51 cpqbld Exp $ */
+/*****************************************************************
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+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
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+******************************************************************/
+/* $XFree86: xc/lib/Xinerama/Xinerama.c,v 1.2 2001/07/23 17:20:28 dawes Exp $ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/panoramiXext.h>
+#include <X11/extensions/panoramiXproto.h>
+#include <X11/extensions/Xinerama.h>
+
+
+static XExtensionInfo _panoramiX_ext_info_data;
+static XExtensionInfo *panoramiX_ext_info = &_panoramiX_ext_info_data;
+static /* const */ char *panoramiX_extension_name = PANORAMIX_PROTOCOL_NAME;
+
+#define PanoramiXCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, panoramiX_extension_name, val)
+#define PanoramiXSimpleCheckExtension(dpy,i) \
+ XextSimpleCheckExtension (dpy, i, panoramiX_extension_name)
+
+static int close_display();
+static /* const */ XExtensionHooks panoramiX_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, panoramiX_ext_info,
+ panoramiX_extension_name,
+ &panoramiX_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, panoramiX_ext_info)
+
+
+
+/****************************************************************************
+ * *
+ * PanoramiX public interfaces *
+ * *
+ ****************************************************************************/
+
+Bool XPanoramiXQueryExtension (
+ Display *dpy,
+ int *event_basep,
+ int *error_basep
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+Status XPanoramiXQueryVersion(
+ Display *dpy,
+ int *major_versionp,
+ int *minor_versionp
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xPanoramiXQueryVersionReply rep;
+ register xPanoramiXQueryVersionReq *req;
+
+ PanoramiXCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (PanoramiXQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->panoramiXReqType = X_PanoramiXQueryVersion;
+ req->clientMajor = PANORAMIX_MAJOR_VERSION;
+ req->clientMinor = PANORAMIX_MINOR_VERSION;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ *major_versionp = rep.majorVersion;
+ *minor_versionp = rep.minorVersion;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
+XPanoramiXInfo *XPanoramiXAllocInfo(void)
+{
+ return (XPanoramiXInfo *) Xmalloc (sizeof (XPanoramiXInfo));
+}
+
+Status XPanoramiXGetState (
+ Display *dpy,
+ Drawable drawable,
+ XPanoramiXInfo *panoramiX_info
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xPanoramiXGetStateReply rep;
+ register xPanoramiXGetStateReq *req;
+
+ PanoramiXCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (PanoramiXGetState, req);
+ req->reqType = info->codes->major_opcode;
+ req->panoramiXReqType = X_PanoramiXGetState;
+ req->window = drawable;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ panoramiX_info->window = rep.window;
+ panoramiX_info->State = rep.state;
+ return 1;
+}
+
+Status XPanoramiXGetScreenCount (
+ Display *dpy,
+ Drawable drawable,
+ XPanoramiXInfo *panoramiX_info
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xPanoramiXGetScreenCountReply rep;
+ register xPanoramiXGetScreenCountReq *req;
+
+ PanoramiXCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (PanoramiXGetScreenCount, req);
+ req->reqType = info->codes->major_opcode;
+ req->panoramiXReqType = X_PanoramiXGetScreenCount;
+ req->window = drawable;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ panoramiX_info->window = rep.window;
+ panoramiX_info->ScreenCount = rep.ScreenCount;
+ return 1;
+}
+
+Status XPanoramiXGetScreenSize (
+ Display *dpy,
+ Drawable drawable,
+ int screen_num,
+ XPanoramiXInfo *panoramiX_info
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xPanoramiXGetScreenSizeReply rep;
+ register xPanoramiXGetScreenSizeReq *req;
+
+ PanoramiXCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (PanoramiXGetScreenSize, req);
+ req->reqType = info->codes->major_opcode;
+ req->panoramiXReqType = X_PanoramiXGetScreenSize;
+ req->window = drawable;
+ req->screen = screen_num; /* need to define */
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ panoramiX_info->window = rep.window;
+ panoramiX_info->screen = rep.screen;
+ panoramiX_info->width = rep.width;
+ panoramiX_info->height = rep.height;
+ return 1;
+}
+
+/*******************************************************************\
+ Alternate interface to make up for shortcomings in the original,
+ namely, the omission of the screen origin. The new interface is
+ in the "Xinerama" namespace instead of "PanoramiX".
+\*******************************************************************/
+
+Bool XineramaQueryExtension (
+ Display *dpy,
+ int *event_base,
+ int *error_base
+)
+{
+ return XPanoramiXQueryExtension(dpy, event_base, error_base);
+}
+
+Status XineramaQueryVersion(
+ Display *dpy,
+ int *major,
+ int *minor
+)
+{
+ return XPanoramiXQueryVersion(dpy, major, minor);
+}
+
+Bool XineramaIsActive(Display *dpy)
+{
+ xXineramaIsActiveReply rep;
+ xXineramaIsActiveReq *req;
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if(!XextHasExtension(info))
+ return False; /* server doesn't even have the extension */
+
+ LockDisplay (dpy);
+ GetReq (XineramaIsActive, req);
+ req->reqType = info->codes->major_opcode;
+ req->panoramiXReqType = X_XineramaIsActive;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return False;
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return rep.state;
+}
+
+#include <stdio.h>
+
+XineramaScreenInfo *
+XineramaQueryScreens(
+ Display *dpy,
+ int *number
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXineramaQueryScreensReply rep;
+ xXineramaQueryScreensReq *req;
+ XineramaScreenInfo *scrnInfo = NULL;
+
+ PanoramiXCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (XineramaQueryScreens, req);
+ req->reqType = info->codes->major_opcode;
+ req->panoramiXReqType = X_XineramaQueryScreens;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return NULL;
+ }
+
+ if(rep.number) {
+ if((scrnInfo = Xmalloc(sizeof(XineramaScreenInfo) * rep.number))) {
+ xXineramaScreenInfo scratch;
+ int i;
+
+ for(i = 0; i < rep.number; i++) {
+ _XRead(dpy, (char*)(&scratch), sz_XineramaScreenInfo);
+ scrnInfo[i].screen_number = i;
+ scrnInfo[i].x_org = scratch.x_org;
+ scrnInfo[i].y_org = scratch.y_org;
+ scrnInfo[i].width = scratch.width;
+ scrnInfo[i].height = scratch.height;
+ }
+
+ *number = rep.number;
+ } else
+ _XEatData(dpy, rep.length << 2);
+ }
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return scrnInfo;
+}
+
+
+
diff --git a/nx-X11/lib/Xmu/AllCmap.c b/nx-X11/lib/Xmu/AllCmap.c
new file mode 100644
index 000000000..09ae52aa4
--- /dev/null
+++ b/nx-X11/lib/Xmu/AllCmap.c
@@ -0,0 +1,158 @@
+/* $Xorg: AllCmap.c,v 1.4 2001/02/09 02:03:51 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/AllCmap.c,v 1.7 2001/01/17 19:42:53 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+static XVisualInfo *getDeepestVisual(int, XVisualInfo*, int);
+
+/*
+ * To create all of the appropriate standard colormaps for every visual of
+ * every screen on a given display, use XmuAllStandardColormaps.
+ *
+ * Define and retain as permanent resources all standard colormaps which are
+ * meaningful for the visuals of each screen of the display. Return 0 on
+ * failure, non-zero on success. If the property of any standard colormap
+ * is already defined, redefine it.
+ *
+ * This interface is intended to be used by window managers or a client
+ * upon start-up of a session.
+ *
+ * The standard colormaps of a screen are defined by properties associated
+ * with the screen's root window. Each screen has exactly one root window.
+ * The property names of standard colormaps are predefined, and each property
+ * name may describe at most one colormap.
+ *
+ * The standard colormaps are
+ * RGB_BEST_MAP
+ * RGB_RED_MAP
+ * RGB_GREEN_MAP
+ * RGB_BLUE_MAP
+ * RGB_DEFAULT_MAP
+ * RGB_GRAY_MAP
+ *
+ * Therefore a screen may have at most 6 standard colormap properties defined.
+ *
+ * A standard colormap is associated with a particular visual of the screen.
+ * A screen may have multiple visuals defined, including visuals of the same
+ * class at different depths. Note that a visual id might be repeated for
+ * more than one depth, so the visual id and the depth of a visual identify
+ * the visual. The characteristics of the visual will determine which
+ * standard colormaps are meaningful under that visual, and will determine
+ * how the standard colormap is defined. Because a standard colormap is
+ * associated with a specific visual, there must be a method of determining
+ * which visuals take precedence in defining standard colormaps.
+ *
+ * The method used here is: for the visual of greatest depth, define all
+ * standard colormaps meaningful to that visual class, according to this
+ * order of (descending) precedence:
+ * 1. DirectColor
+ * 2. PseudoColor
+ * 3. TrueColor and GrayScale
+ * 4. StaticColor and StaticGray
+ *
+ * Allows partial success by screenful. For example, if a map on screen 1
+ * fails, the maps on screen 0, created earlier, will remain. However,
+ * none on screen 1 will remain. If a map on 0 fails, none will remain.
+ *
+ * See the comments under XmuVisualStandardColormaps() for notes on which
+ * standard colormaps are meaningful under these classes of visuals.
+ */
+
+Status
+XmuAllStandardColormaps(Display *dpy)
+{
+ int nvisuals, scr;
+ Status status;
+ long vinfo_mask;
+ XVisualInfo template, *vinfo, *v1, *v2;
+
+ status = 0;
+ /* for each screen, determine all visuals of this server */
+ for (scr=0; scr < ScreenCount(dpy); scr++)
+ {
+ template.screen = scr;
+ vinfo_mask = VisualScreenMask;
+ vinfo = XGetVisualInfo(dpy, vinfo_mask, &template, &nvisuals);
+ if (vinfo == NULL) /* unexpected: a screen with no visuals */
+ continue;
+
+ v1 = getDeepestVisual(DirectColor, vinfo, nvisuals);
+ v2 = getDeepestVisual(PseudoColor, vinfo, nvisuals);
+
+ if (v2 &&
+ (!v1 || (v2->colormap_size >=
+ ((v1->red_mask | v1->green_mask | v1->blue_mask) + 1))))
+ status = XmuVisualStandardColormaps(dpy, scr, v2->visualid,
+ (unsigned) v2->depth, 1, 1);
+ else if (v1)
+ status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
+ (unsigned) v1->depth, 1, 1);
+
+ else {
+ if (((v1 = getDeepestVisual(TrueColor, vinfo, nvisuals)) != NULL)
+ || ((v1 = getDeepestVisual(StaticColor, vinfo, nvisuals)) !=
+ NULL))
+ status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
+ (unsigned) v1->depth, 1, 1);
+ if (status &&
+ (((v1 = getDeepestVisual(GrayScale, vinfo, nvisuals)) != NULL)
+ || ((v1 = getDeepestVisual(StaticGray, vinfo, nvisuals)) !=
+ NULL)))
+ status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
+ (unsigned) v1->depth, 1, 1);
+ }
+ XFree ((char *) vinfo);
+ if (!status) break;
+ }
+ return status;
+}
+
+static XVisualInfo *
+getDeepestVisual(int visual_class, XVisualInfo *vinfo, int nvisuals)
+{
+ register int i;
+ register int maxdepth = 0;
+ XVisualInfo *v = NULL;
+
+ for (i=0; i < nvisuals; i++, vinfo++)
+ if (vinfo->class == visual_class && vinfo->depth > maxdepth)
+ {
+ maxdepth = vinfo->depth;
+ v = vinfo;
+ }
+ return(v);
+}
+
diff --git a/nx-X11/lib/Xmu/Atoms.c b/nx-X11/lib/Xmu/Atoms.c
new file mode 100644
index 000000000..dcdf497a5
--- /dev/null
+++ b/nx-X11/lib/Xmu/Atoms.c
@@ -0,0 +1,154 @@
+/* $Xorg: Atoms.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/Atoms.c,v 3.7 2001/07/25 15:04:50 dawes Exp $ */
+
+/*
+ * This file contains routines to cache atoms, avoiding multiple
+ * server round-trips. Not so useful now that Xlib caches them.
+ *
+ * Public entry points:
+ *
+ * XmuMakeAtom creates & initializes an opaque AtomRec
+ * XmuInternAtom fetches an Atom from cache or Display
+ * XmuInternStrings fetches multiple Atoms as strings
+ * XmuGetAtomName returns name of an Atom
+ * XmuNameOfAtom returns name from an AtomPtr
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include "Atoms.h"
+
+typedef struct _DisplayRec {
+ struct _DisplayRec* next;
+ Display *dpy;
+ Atom atom;
+} DisplayRec;
+
+struct _AtomRec {
+ char *name;
+ DisplayRec* head;
+};
+
+#ifdef SUNSHLIB
+#define STATIC
+#else
+#define STATIC static
+#endif
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define DeclareAtom(atom,text) \
+STATIC struct _AtomRec __##atom = { text, NULL }; \
+AtomPtr _##atom = &__##atom;
+#else
+#define DeclareAtom(atom,text) \
+STATIC struct _AtomRec __/**/atom = { text, NULL }; \
+AtomPtr _/**/atom = &__/**/atom;
+#endif
+
+DeclareAtom(XA_ATOM_PAIR, "ATOM_PAIR" )
+DeclareAtom(XA_CHARACTER_POSITION, "CHARACTER_POSITION" )
+DeclareAtom(XA_CLASS, "CLASS" )
+DeclareAtom(XA_CLIENT_WINDOW, "CLIENT_WINDOW" )
+DeclareAtom(XA_CLIPBOARD, "CLIPBOARD" )
+DeclareAtom(XA_COMPOUND_TEXT, "COMPOUND_TEXT" )
+DeclareAtom(XA_DECNET_ADDRESS, "DECNET_ADDRESS" )
+DeclareAtom(XA_DELETE, "DELETE" )
+DeclareAtom(XA_FILENAME, "FILENAME" )
+DeclareAtom(XA_HOSTNAME, "HOSTNAME" )
+DeclareAtom(XA_IP_ADDRESS, "IP_ADDRESS" )
+DeclareAtom(XA_LENGTH, "LENGTH" )
+DeclareAtom(XA_LIST_LENGTH, "LIST_LENGTH" )
+DeclareAtom(XA_NAME, "NAME" )
+DeclareAtom(XA_NET_ADDRESS, "NET_ADDRESS" )
+DeclareAtom(XA_NULL, "NULL" )
+DeclareAtom(XA_OWNER_OS, "OWNER_OS" )
+DeclareAtom(XA_SPAN, "SPAN" )
+DeclareAtom(XA_TARGETS, "TARGETS" )
+DeclareAtom(XA_TEXT, "TEXT" )
+DeclareAtom(XA_TIMESTAMP, "TIMESTAMP" )
+DeclareAtom(XA_USER, "USER" )
+DeclareAtom(XA_UTF8_STRING, "UTF8_STRING" )
+
+/******************************************************************
+
+ Public procedures
+
+ ******************************************************************/
+
+
+AtomPtr
+XmuMakeAtom(_Xconst char *name)
+{
+ AtomPtr ptr = XtNew(struct _AtomRec);
+ ptr->name = (char *) name;
+ ptr->head = NULL;
+ return ptr;
+}
+
+char *
+XmuNameOfAtom(AtomPtr atom_ptr)
+{
+ return atom_ptr->name;
+}
+
+
+Atom
+XmuInternAtom(Display *d, AtomPtr atom_ptr)
+{
+ DisplayRec* display_rec;
+ for (display_rec = atom_ptr->head; display_rec != NULL;
+ display_rec = display_rec->next) {
+ if (display_rec->dpy == d)
+ return display_rec->atom;
+ }
+ display_rec = XtNew(DisplayRec);
+ display_rec->next = atom_ptr->head;
+ atom_ptr->head = display_rec;
+ display_rec->dpy = d;
+ display_rec->atom = XInternAtom(d, atom_ptr->name, False);
+ return display_rec->atom;
+}
+
+
+char *
+XmuGetAtomName(Display *d, Atom atom)
+{
+ if (atom == 0) return (NULL);
+ return XGetAtomName(d, atom);
+}
+
+/* convert (names, count) to a list of atoms. Caller allocates list */
+void
+XmuInternStrings(Display *d, register String *names,
+ register Cardinal count, register Atom *atoms)
+{
+ (void) XInternAtoms(d, (char**)names, (int)count, FALSE, atoms);
+}
diff --git a/nx-X11/lib/Xmu/Atoms.h b/nx-X11/lib/Xmu/Atoms.h
new file mode 100644
index 000000000..f7b4c8f7e
--- /dev/null
+++ b/nx-X11/lib/Xmu/Atoms.h
@@ -0,0 +1,126 @@
+/* $Xorg: Atoms.h,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/Atoms.h,v 1.6 2001/01/17 19:42:53 dawes Exp $ */
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_ATOMS_H_
+#define _XMU_ATOMS_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+typedef struct _AtomRec *AtomPtr;
+
+extern AtomPtr
+ _XA_ATOM_PAIR,
+ _XA_CHARACTER_POSITION,
+ _XA_CLASS,
+ _XA_CLIENT_WINDOW,
+ _XA_CLIPBOARD,
+ _XA_COMPOUND_TEXT,
+ _XA_DECNET_ADDRESS,
+ _XA_DELETE,
+ _XA_FILENAME,
+ _XA_HOSTNAME,
+ _XA_IP_ADDRESS,
+ _XA_LENGTH,
+ _XA_LIST_LENGTH,
+ _XA_NAME,
+ _XA_NET_ADDRESS,
+ _XA_NULL,
+ _XA_OWNER_OS,
+ _XA_SPAN,
+ _XA_TARGETS,
+ _XA_TEXT,
+ _XA_TIMESTAMP,
+ _XA_USER,
+ _XA_UTF8_STRING;
+
+#define XA_ATOM_PAIR(d) XmuInternAtom(d, _XA_ATOM_PAIR)
+#define XA_CHARACTER_POSITION(d) XmuInternAtom(d, _XA_CHARACTER_POSITION)
+#define XA_CLASS(d) XmuInternAtom(d, _XA_CLASS)
+#define XA_CLIENT_WINDOW(d) XmuInternAtom(d, _XA_CLIENT_WINDOW)
+#define XA_CLIPBOARD(d) XmuInternAtom(d, _XA_CLIPBOARD)
+#define XA_COMPOUND_TEXT(d) XmuInternAtom(d, _XA_COMPOUND_TEXT)
+#define XA_DECNET_ADDRESS(d) XmuInternAtom(d, _XA_DECNET_ADDRESS)
+#define XA_DELETE(d) XmuInternAtom(d, _XA_DELETE)
+#define XA_FILENAME(d) XmuInternAtom(d, _XA_FILENAME)
+#define XA_HOSTNAME(d) XmuInternAtom(d, _XA_HOSTNAME)
+#define XA_IP_ADDRESS(d) XmuInternAtom(d, _XA_IP_ADDRESS)
+#define XA_LENGTH(d) XmuInternAtom(d, _XA_LENGTH)
+#define XA_LIST_LENGTH(d) XmuInternAtom(d, _XA_LIST_LENGTH)
+#define XA_NAME(d) XmuInternAtom(d, _XA_NAME)
+#define XA_NET_ADDRESS(d) XmuInternAtom(d, _XA_NET_ADDRESS)
+#define XA_NULL(d) XmuInternAtom(d, _XA_NULL)
+#define XA_OWNER_OS(d) XmuInternAtom(d, _XA_OWNER_OS)
+#define XA_SPAN(d) XmuInternAtom(d, _XA_SPAN)
+#define XA_TARGETS(d) XmuInternAtom(d, _XA_TARGETS)
+#define XA_TEXT(d) XmuInternAtom(d, _XA_TEXT)
+#define XA_TIMESTAMP(d) XmuInternAtom(d, _XA_TIMESTAMP)
+#define XA_USER(d) XmuInternAtom(d, _XA_USER)
+#define XA_UTF8_STRING(d) XmuInternAtom(d, _XA_UTF8_STRING)
+
+_XFUNCPROTOBEGIN
+
+char *XmuGetAtomName
+(
+ Display *dpy,
+ Atom atom
+ );
+
+Atom XmuInternAtom
+(
+ Display *dpy,
+ AtomPtr atom_ptr
+ );
+
+void XmuInternStrings
+(
+ Display *dpy,
+ String *names,
+ Cardinal count,
+ Atom *atoms_return
+);
+
+AtomPtr XmuMakeAtom
+(
+ _Xconst char *name
+ );
+
+char *XmuNameOfAtom
+(
+ AtomPtr atom_ptr
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_ATOMS_H_ */
diff --git a/nx-X11/lib/Xmu/CharSet.h b/nx-X11/lib/Xmu/CharSet.h
new file mode 100644
index 000000000..32cebfeda
--- /dev/null
+++ b/nx-X11/lib/Xmu/CharSet.h
@@ -0,0 +1,77 @@
+/* $Xorg: CharSet.h,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+
+/* $XFree86: xc/lib/Xmu/CharSet.h,v 1.7 2001/01/17 19:42:53 dawes Exp $ */
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_CHARSET_H_
+#define _XMU_CHARSET_H_
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+void XmuCopyISOLatin1Lowered
+(
+ char *dst_return,
+ _Xconst char *src
+ );
+
+void XmuCopyISOLatin1Uppered
+(
+ char *dst_return,
+ _Xconst char *src
+ );
+
+int XmuCompareISOLatin1
+(
+ _Xconst char *first,
+ _Xconst char *second
+ );
+
+void XmuNCopyISOLatin1Lowered
+(
+ char *dst_return,
+ _Xconst char *src,
+ int size
+ );
+
+void XmuNCopyISOLatin1Uppered
+(
+ char *dst_return,
+ _Xconst char *src,
+ int size
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_CHARSET_H_ */
diff --git a/nx-X11/lib/Xmu/ClientWin.c b/nx-X11/lib/Xmu/ClientWin.c
new file mode 100644
index 000000000..7fc273f1f
--- /dev/null
+++ b/nx-X11/lib/Xmu/ClientWin.c
@@ -0,0 +1,100 @@
+/* $Xorg: ClientWin.c,v 1.4 2001/02/09 02:03:51 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/ClientWin.c,v 1.7 2001/12/14 19:55:34 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+
+#include <X11/Xmu/WinUtil.h>
+
+/*
+ * Prototypes
+ */
+static Window TryChildren(Display*, Window, Atom);
+
+/* Find a window with WM_STATE, else return win itself, as per ICCCM */
+
+Window
+XmuClientWindow(Display *dpy, Window win)
+{
+ Atom WM_STATE;
+ Atom type = None;
+ int format;
+ unsigned long nitems, after;
+ unsigned char *data = NULL;
+ Window inf;
+
+ WM_STATE = XInternAtom(dpy, "WM_STATE", True);
+ if (!WM_STATE)
+ return win;
+ XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType,
+ &type, &format, &nitems, &after, &data);
+ if (data)
+ XFree(data);
+ if (type)
+ return win;
+ inf = TryChildren(dpy, win, WM_STATE);
+ if (!inf)
+ inf = win;
+ return inf;
+}
+
+static Window
+TryChildren(Display *dpy, Window win, Atom WM_STATE)
+{
+ Window root, parent;
+ Window *children;
+ unsigned int nchildren;
+ unsigned int i;
+ Atom type = None;
+ int format;
+ unsigned long nitems, after;
+ unsigned char *data;
+ Window inf = 0;
+
+ if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren))
+ return 0;
+ for (i = 0; !inf && (i < nchildren); i++) {
+ data = NULL;
+ XGetWindowProperty(dpy, children[i], WM_STATE, 0, 0, False,
+ AnyPropertyType, &type, &format, &nitems,
+ &after, &data);
+ if (data)
+ XFree(data);
+ if (type)
+ inf = children[i];
+ }
+ for (i = 0; !inf && (i < nchildren); i++)
+ inf = TryChildren(dpy, children[i], WM_STATE);
+ if (children)
+ XFree(children);
+ return inf;
+}
diff --git a/nx-X11/lib/Xmu/Clip.c b/nx-X11/lib/Xmu/Clip.c
new file mode 100644
index 000000000..8d2c8455e
--- /dev/null
+++ b/nx-X11/lib/Xmu/Clip.c
@@ -0,0 +1,1617 @@
+/*
+ * Copyright (c) 1998 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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 XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+/* $XFree86: xc/lib/Xmu/Clip.c,v 1.1 1998/08/16 10:25:03 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdlib.h>
+
+#include <X11/IntrinsicP.h>
+#include <X11/Xmu/Xmu.h>
+
+#define XmuMax(a, b) ((a) > (b) ? (a) : (b))
+#define XmuMin(a, b) ((a) < (b) ? (a) : (b))
+
+/*
+ * Function:
+ * XmuNewArea
+ *
+ * Parameters:
+ * x1 - Coordinates of the rectangle
+ * y1 - ""
+ * x2 - ""
+ * y2 - ""
+ *
+ * Description:
+ * Creates a new rectangular clipping area
+ */
+XmuArea *
+XmuNewArea(int x1, int y1, int x2, int y2)
+{
+ XmuArea *area;
+
+ area = (XmuArea *)XtMalloc(sizeof(XmuArea));
+ if (x2 > x1 && y2 > y1)
+ {
+ area->scanline = XmuNewScanline(y1, x1, x2);
+ area->scanline->next = XmuNewScanline(y2, 0, 0);
+ }
+ else
+ area->scanline = (XmuScanline *)NULL;
+
+ return (area);
+}
+
+/*
+ * Function:
+ * XmuAreaDup
+ *
+ * Parameters:
+ * area - Area to copy
+ *
+ * Description:
+ * Returns a copy of its argument
+ */
+XmuArea *
+XmuAreaDup(XmuArea *area)
+{
+ XmuArea *dst;
+
+ if (!area)
+ return ((XmuArea *)NULL);
+
+ dst = XmuCreateArea();
+ XmuAreaCopy(dst, area);
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuAreaCopy
+ *
+ * Parameters:
+ * dst - destination area
+ * src - source area
+ *
+ * Description:
+ * Minimizes memory alocation, trying to use already alocated memory
+ * in dst, freeing what is not required anymore.
+ */
+XmuArea *
+XmuAreaCopy(XmuArea *dst, XmuArea *src)
+{
+ XmuScanline *z, *p, *Z;
+
+ if (!dst || !src || dst == src)
+ return (dst);
+
+ z = p = dst->scanline;
+ Z = src->scanline;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ if (!Z)
+ {
+ if (z == dst->scanline)
+ {
+ XmuDestroyScanlineList(dst->scanline);
+ dst->scanline = (XmuScanline *)NULL;
+ }
+ else
+ {
+ XmuDestroyScanlineList(p->next);
+ p->next = (XmuScanline *)NULL;
+ }
+ return (dst);
+ }
+ if (z)
+ {
+ XmuScanlineCopy(z, Z);
+ z->y = Z->y;
+ }
+ else
+ {
+ z = XmuNewScanline(Z->y, 0, 0);
+ XmuScanlineCopy(z, Z);
+ if (p == dst->scanline && !dst->scanline)
+ p = dst->scanline = z;
+ else
+ p->next = z;
+ }
+ p = z;
+ z = z->next;
+ Z = Z->next;
+ }
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuAreaNot
+ *
+ * Parameters:
+ * area - area to operate
+ * x1 - retangle to clip the result against
+ * y1 - ""
+ * x2 - ""
+ * y2 - ""
+ *
+ * Description:
+ * (Input)
+ * (x1, y1) (x2, y1)
+ * +-------------+
+ * +------------+ +----+
+ * | +--------------+
+ * +----------------+
+ * (x1, y2) (x2, y2)
+ *
+ * (Output)
+ * (x1, y1) (x2, y1)
+ * +--------------+ +--------------------------+
+ * | +------------+ +----+ |
+ * | | +--------------+ |
+ * +-+ +------------------------------------+
+ * (x1, y2) (x2, y2)
+ */
+XmuArea *
+XmuAreaNot(XmuArea *area, int x1, int y1, int x2, int y2)
+{
+ XmuScanline *z;
+ XmuArea *and;
+
+ if (!area)
+ return (area);
+
+ if (x1 > x2)
+ {
+ x1 ^= x2; x2 ^= x1; x1 ^= x2;
+ }
+ if (y1 > y2)
+ {
+ y1 ^= y2; y2 ^= y1; y1 ^= y2;
+ }
+ if (!area->scanline)
+ {
+ if ((area->scanline = XmuNewScanline(y1, x1, x2)) != NULL)
+ area->scanline->next = XmuNewScanline(y2, 0, 0);
+ return (area);
+ }
+ and = XmuNewArea(x1, y1, x2, y2);
+ XmuAreaAnd(area, and);
+ XmuDestroyArea(and);
+ z = area->scanline;
+ if (z->y != y1)
+ {
+ XmuScanline *q = XmuNewScanline(y1, x1, x2);
+ q->next = z;
+ area->scanline = q;
+ }
+ else
+ {
+ area->scanline = area->scanline->next;
+ XmuDestroyScanline(z);
+ XmuOptimizeArea(area);
+ if((z = area->scanline) == (XmuScanline *)NULL)
+ return (area);
+ }
+
+ /* CONSTCOND */
+ while (1)
+ {
+ XmuScanlineNot(z, x1, x2);
+ if (!z->next)
+ {
+ z->next = XmuNewScanline(y2, 0, 0);
+ break;
+ }
+ if (z->next->y == y2)
+ {
+ XmuDestroyScanlineList(z->next);
+ z->next = XmuNewScanline(y2, 0, 0);
+ break;
+ }
+ z = z->next;
+ }
+
+ return (area);
+}
+
+/*
+ * Function:
+ * XmuAreaOrXor
+ *
+ * Parameters:
+ * dst - destination area
+ * src - source area
+ * or - or operation if true, else xor operation
+ *
+ * Description:
+ * Executes Or (Union) or Xor (Reverse intesection) of the areas
+ */
+XmuArea *
+XmuAreaOrXor(XmuArea *dst, XmuArea *src, Bool or)
+{
+ XmuScanline *z, *p, *Z, *P, *ins, *top;
+
+ if (!dst || !src)
+ return (dst);
+
+ if (dst == src)
+ {
+ if (or)
+ return (dst);
+ XmuDestroyScanlineList(dst->scanline);
+ dst->scanline = (XmuScanline *)NULL;
+ return (dst);
+ }
+ if (!XmuValidArea(src))
+ return (dst);
+ if (!XmuValidArea(dst))
+ {
+ XmuAreaCopy(dst, src);
+ return (dst);
+ }
+
+ p = z = dst->scanline;
+ P = Z = src->scanline;
+ ins = XmuNewScanline(dst->scanline->y, 0, 0);
+ top = XmuNewScanline(dst->scanline->y, 0, 0);
+ XmuScanlineCopy(ins, dst->scanline);
+ XmuScanlineCopy(top, dst->scanline);
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ if (!Z)
+ break;
+ else if (Z->y < z->y)
+ {
+ XmuScanline *q = XmuNewScanline(Z->y, 0, 0);
+ XmuScanlineCopy(q, Z);
+
+ if (z == dst->scanline)
+ {
+ dst->scanline = p = q;
+ q->next = z;
+ }
+ else
+ {
+ p->next = q;
+ q->next = z;
+ if (Z->y >= p->y)
+ {
+ if (ins->y >= top->y
+ && (p->y != P->y || !XmuScanlineEqu(p, P)
+ || (ins->y <= P->y && !XmuScanlineEqu(ins, P))))
+ {
+ if (or)
+ XmuScanlineOr(q, ins);
+ else
+ XmuScanlineXor(q, ins);
+ }
+ else if (Z->y >= top->y
+ && (top->y == p->y || top->y > ins->y
+ || !XmuValidScanline(Z)
+ || (p->y == P->y && XmuValidScanline(p)
+ && XmuValidScanline(P))
+ || XmuScanlineEqu(ins, top)))
+ {
+ if (or)
+ XmuScanlineOr(q, top);
+ else
+ XmuScanlineXor(q, top);
+ }
+ if (ins->y != p->y && p->y != P->y)
+ {
+ XmuScanlineCopy(ins, p);
+ ins->y = p->y;
+ }
+ }
+ if (!XmuValidScanline(p) || Z->y <= p->y)
+ {
+ XmuScanlineCopy(top, p);
+ top->y = p->y;
+ }
+ p = q;
+ }
+ P = Z;
+ Z = Z->next;
+ continue;
+ }
+ else if (Z->y == z->y)
+ {
+ if (top->y != z->y)
+ {
+ XmuScanlineCopy(top, z);
+ top->y = z->y;
+ }
+ if (or)
+ XmuScanlineOr(z, Z);
+ else
+ XmuScanlineXor(z, Z);
+ P = Z;
+ Z = Z->next;
+ }
+ else if (P != Z) /* && Z->y > z->y */
+ {
+ if (top->y == ins->y && top->y != z->y)
+ {
+ XmuScanlineCopy(top, z);
+ top->y = z->y;
+ }
+ if (ins->y != z->y)
+ {
+ XmuScanlineCopy(ins, z);
+ ins->y = z->y;
+ }
+ if (or)
+ XmuScanlineOr(z, P);
+ else
+ XmuScanlineXor(z, P);
+ }
+ else if (ins->y != z->y)
+ {
+ XmuScanlineCopy(ins, z);
+ ins->y = z->y;
+ }
+ p = z;
+ z = z->next;
+ if (!z)
+ {
+ while (Z)
+ {
+ p->next = XmuNewScanline(Z->y, 0, 0);
+ XmuScanlineCopy(p->next, Z);
+ p = p->next;
+ Z = Z->next;
+ }
+ break;
+ }
+ else if (ins->y > top->y && !XmuValidScanline(z)
+ && XmuValidScanline(ins))
+ {
+ XmuScanlineCopy(top, ins);
+ top->y = ins->y;
+ }
+ }
+ XmuOptimizeArea(dst);
+ XmuDestroyScanline(ins);
+ XmuDestroyScanline(top);
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuAreaAnd(dst, src)
+ *
+ * Parameters:
+ * dst - destination area
+ * src - source area
+ *
+ * Description:
+ * Executes And (intersection) of the areas
+ */
+XmuArea *
+XmuAreaAnd(XmuArea *dst, XmuArea *src)
+{
+ XmuScanline *z, *p, *Z, *P, *top;
+
+ if (!dst || !src || dst == src)
+ return (dst);
+ if (!XmuValidArea(dst) || !XmuValidArea(src))
+ {
+ XmuDestroyScanlineList(dst->scanline);
+ dst->scanline = (XmuScanline *)NULL;
+ return (dst);
+ }
+ z = p = dst->scanline;
+ Z = P = src->scanline;
+ top = XmuNewScanline(dst->scanline->y, 0, 0);
+ XmuScanlineCopy(top, dst->scanline);
+
+ while (z)
+ {
+ while (Z->next && Z->next->y < z->y)
+ {
+ P = Z;
+ Z = Z->next;
+ if (Z->y >= p->y)
+ {
+ XmuScanline *q = XmuNewScanline(Z->y, 0, 0);
+ XmuScanlineCopy(q, Z);
+
+ XmuScanlineAnd(q, top);
+ if (p->y != P->y)
+ {
+ XmuScanlineAnd(p, P);
+ p->y = XmuMax(p->y, P->y);
+ }
+ p->next = q;
+ q->next = z;
+ p = q;
+ }
+ }
+ if (!z->next)
+ {
+ z->y = XmuMax(z->y, Z->y);
+ break;
+ }
+ while (Z->y >= z->next->y)
+ {
+ if (z == dst->scanline)
+ {
+ p = dst->scanline = dst->scanline->next;
+ XmuDestroyScanline(z);
+ z = dst->scanline;
+ }
+ else
+ {
+ p->next = z->next;
+ XmuDestroyScanline(z);
+ z = p;
+ }
+ if (!z || !z->next)
+ {
+ XmuOptimizeArea(dst);
+ XmuDestroyScanline(top);
+
+ return (dst);
+ }
+ }
+ if (Z->y > p->y)
+ z->y = XmuMax(z->y, Z->y);
+ if (top->y != z->y)
+ {
+ XmuScanlineCopy(top, z);
+ top->y = z->y;
+ }
+ XmuScanlineAnd(z, Z);
+ p = z;
+ z = z->next;
+ }
+ XmuOptimizeArea(dst);
+ XmuDestroyScanline(top);
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuValidArea(area)
+ *
+ * Parameters:
+ * area - area to verify
+ *
+ * Description:
+ * Verifies if the area is valid and/or useful
+ */
+Bool
+XmuValidArea(XmuArea *area)
+{
+ XmuScanline *at;
+
+ if (!area || !area->scanline)
+ return (False);
+
+ at = area->scanline;
+ while (at)
+ {
+ if (XmuValidScanline(at))
+ return (True);
+ at = at->next;
+ }
+
+ return (False);
+}
+
+/*
+ * Function:
+ * XmuValidScanline
+ *
+ * Parameters:
+ * scanline - scanline to verify
+ *
+ * Description:
+ * Verifies if a scanline is useful
+ */
+Bool
+XmuValidScanline(XmuScanline *scanline)
+{
+ XmuSegment *z;
+
+ if (!scanline)
+ return (False);
+
+ z = scanline->segment;
+ while (z)
+ {
+ if (XmuValidSegment(z))
+ return (True);
+ z = z->next;
+ }
+
+ return (False);
+}
+
+/*
+ * Function:
+ * XmuScanlineEqu
+ *
+ * Parameters:
+ * s1 - scanline 1
+ * s2 - scanline 2
+ *
+ * Description:
+ * Checks if s1 and s2 are equal
+ */
+Bool
+XmuScanlineEqu(XmuScanline *s1, XmuScanline *s2)
+{
+ XmuSegment *z, *Z;
+
+ if ((!s1 && !s2) || s1 == s2)
+ return (True);
+ if (!s1 || !s2)
+ return (False);
+
+ z = s1->segment;
+ Z = s2->segment;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ if (!z && !Z)
+ return (True);
+ if (!z || !Z)
+ return (False);
+ if (!XmuSegmentEqu(z, Z))
+ return (False);
+ z = z->next;
+ Z = Z->next;
+ }
+ /*NOTREACHED*/
+}
+
+/*
+ * Function:
+ * XmuNewSegment
+ *
+ * Parameters:
+ * x1 - coordinates of the segment
+ * x2 - ""
+ *
+ * Description:
+ * Creates a new segments with the coordinates x1 and x2
+ *
+ * Returns:
+ * New Segment of NULL
+ */
+XmuSegment *
+XmuNewSegment(int x1, int x2)
+{
+ XmuSegment *segment;
+
+ if ((segment = (XmuSegment *)XtMalloc(sizeof(XmuSegment))) == NULL)
+ return (segment);
+
+ segment->x1 = x1;
+ segment->x2 = x2;
+ segment->next = (XmuSegment *)NULL;
+
+ return (segment);
+}
+
+/*
+ * Function:
+ * XmuDestroySegmentList
+ *
+ * Parameters:
+ * segment - Segment to destroy
+ *
+ * Description:
+ * Frees the memory used by the list headed by segment
+ */
+void
+XmuDestroySegmentList(XmuSegment *segment)
+{
+ XmuSegment *z;
+
+ if (!segment)
+ return;
+
+ while (segment)
+ {
+ z = segment;
+ segment = segment->next;
+ XmuDestroySegment(z);
+ }
+}
+
+/*
+ * Function:
+ * XmuScanlineCopy
+ *
+ * Parameters:
+ * dst - destination scanline
+ * src - source scanline
+ *
+ * Description:
+ * Makes dst contain the same data as src
+ */
+XmuScanline *
+XmuScanlineCopy(XmuScanline *dst, XmuScanline *src)
+{
+ XmuSegment *z, *p, *Z;
+
+ if (!dst || !src || dst == src)
+ return (dst);
+
+ z = p = dst->segment;
+ Z = src->segment;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ if (!Z)
+ {
+ if (z == dst->segment)
+ dst->segment = (XmuSegment *)NULL;
+ else
+ p->next = (XmuSegment *)NULL;
+ XmuDestroySegmentList(z);
+ return (dst);
+ }
+ if (z)
+ {
+ z->x1 = Z->x1;
+ z->x2 = Z->x2;
+ }
+ else
+ {
+ z = XmuNewSegment(Z->x1, Z->x2);
+ if (p == dst->segment && !dst->segment)
+ p = dst->segment = z;
+ else
+ p->next = z;
+ }
+ p = z;
+ z = z->next;
+ Z = Z->next;
+ }
+ /*NOTREACHED*/
+}
+
+/*
+ * Function:
+ * XmuAppendSegment
+ *
+ * Parameters:
+ * segment - destination segment
+ * append - segment to add
+ *
+ * Description:
+ * Adds a copy of the append list at the end of the segment list
+ */
+Bool
+XmuAppendSegment(XmuSegment *segment, XmuSegment *append)
+{
+ if (!segment || !append)
+ return (False);
+
+ if (segment->next)
+ /* Should not happen! */
+ XmuDestroySegmentList(segment->next);
+
+ while (append)
+ {
+ if (XmuValidSegment(append))
+ {
+ if ((segment->next = XmuNewSegment(append->x1, append->x2)) == NULL)
+ return (False);
+ segment = segment->next;
+ }
+ append = append->next;
+ }
+
+ return (True);
+}
+
+/*
+ * Function:
+ * XmuOptimizeScanline
+ *
+ * Parameters:
+ * scanline - scanline to optimize
+ *
+ * Description:
+ * Some functions, when transforming Segments of Scanlines, left these
+ * with unnecessary data (that may cause error in these same functions).
+ * This function corrects these incorrect segments.
+ */
+XmuScanline *
+XmuOptimizeScanline(XmuScanline *scanline)
+{
+ XmuSegment *z, *p;
+
+ while (scanline->segment && !XmuValidSegment(scanline->segment))
+ {
+ XmuSegment *s = scanline->segment;
+
+ scanline->segment = scanline->segment->next;
+ XmuDestroySegment(s);
+ }
+ for (z = p = scanline->segment; z; p = z, z = z->next)
+ {
+ if (!XmuValidSegment(z))
+ {
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ }
+ }
+ return (scanline);
+}
+
+/*
+ * Name:
+ * XmuScanlineNot(scanline, minx, maxx)
+ *
+ * Parameters:
+ * scanline - scanlines operate
+ * minx - minimum x coordinate
+ * maxx - maximum x coordinate
+ *
+ * Description:
+ * (minx) (maxx)
+ * + +
+ * (input) +---------+ +--------+ +--------+
+ * (output) +-----+ +-----+ +--------+ +------------+
+ */
+XmuScanline *
+XmuScanlineNot(XmuScanline *scanline, int minx, int maxx)
+{
+ XmuSegment *z;
+ static XmuSegment x = { 0, 0, 0 };
+ static XmuScanline and = { 0, &x, 0 };
+
+ if (!scanline)
+ return (scanline);
+
+ XmuOptimizeScanline(scanline);
+ if (minx > maxx)
+ {
+ minx ^= maxx; maxx ^= minx; minx ^= maxx;
+ }
+ and.segment->x1 = minx;
+ and.segment->x2 = maxx;
+ XmuScanlineAnd(scanline, &and);
+ if (!scanline->segment)
+ {
+ scanline->segment = XmuNewSegment(minx, maxx);
+ return (scanline);
+ }
+ z = scanline->segment;
+ if (z->x1 != minx)
+ {
+ XmuSegment *q = XmuNewSegment(minx, z->x1);
+
+ q->next = z;
+ scanline->segment = q;
+ }
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ z->x1 = z->x2;
+ if (!z->next)
+ {
+ z->x2 = maxx;
+ break;
+ }
+ z->x2 = z->next->x1;
+ if (z->next->x2 == maxx)
+ {
+ XmuDestroySegment(z->next);
+ z->next = (XmuSegment *)NULL;
+ break;
+ }
+ z = z->next;
+ }
+
+ return (scanline);
+}
+
+
+#ifndef notdef
+/*
+ * Function:
+ * XmuScanlineOrSegment
+ *
+ * Parameters:
+ * dst - destionation scanline
+ * src - source segment
+ *
+ * Description:
+ * (input) +-----------+ +--------+ +---------+
+ * (src) +-------------------+
+ * (output) +-------------------------+ +---------+
+ */
+XmuScanline *
+XmuScanlineOrSegment(XmuScanline *dst, XmuSegment *src)
+{
+ XmuSegment *z, *p, ins;
+
+ if (!src || !dst || !XmuValidSegment(src))
+ return (dst);
+
+ if (!dst->segment)
+ {
+ dst->segment = XmuNewSegment(src->x1, src->x2);
+ return (dst);
+ }
+
+ z = p = dst->segment;
+ ins.x1 = src->x1;
+ ins.x2 = src->x2;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ if (!z)
+ {
+ XmuSegment *q = XmuNewSegment(ins.x1, ins.x2);
+
+ if (p == dst->segment && z == p)
+ dst->segment = q;
+ else
+ p->next = q;
+ break;
+ }
+ else if (ins.x2 < z->x1)
+ {
+ XmuSegment *q = XmuNewSegment(ins.x1, ins.x2);
+
+ if (p == dst->segment && z == p)
+ {
+ q->next = dst->segment;
+ dst->segment = q;
+ }
+ else
+ {
+ p->next = q;
+ q->next = z;
+ }
+ break;
+ }
+ else if (ins.x2 <= z->x2)
+ {
+ z->x1 = XmuMin(z->x1, ins.x1);
+ break;
+ }
+ else if (ins.x1 <= z->x2)
+ {
+ ins.x1 = XmuMin(z->x1, ins.x1);
+ if (!z->next)
+ {
+ z->x1 = ins.x1;
+ z->x2 = ins.x2;
+ break;
+ }
+ else
+ {
+ if (z == dst->segment)
+ {
+ p = dst->segment = dst->segment->next;
+ XmuDestroySegment(z);
+ z = dst->segment;
+ continue;
+ }
+ else
+ {
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ }
+ }
+ }
+ p = z;
+ z = z->next;
+ }
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuScanlineAndSegment
+ *
+ * Parameters:
+ * dst - destination scanline
+ * src - source segment
+ *
+ * Description:
+ * (input) +------------+ +------+ +----------+
+ * (src) +---------------------+
+ * (output) +-------+ +------+
+ */
+XmuScanline *
+XmuScanlineAndSegment(XmuScanline *dst, XmuSegment *src)
+{
+ XmuSegment *z, *p;
+
+ if (!dst || !src)
+ return (dst);
+
+ if (!XmuValidSegment(src))
+ {
+ XmuDestroySegmentList(dst->segment);
+ dst->segment = (XmuSegment *)NULL;
+ return (dst);
+ }
+ if (!dst->segment)
+ return (dst);
+
+ z = p = dst->segment;
+ while (z)
+ {
+ if (src->x2 <= z->x1 || src->x1 >= z->x2)
+ {
+ if (z == dst->segment)
+ {
+ p = dst->segment = dst->segment->next;
+ XmuDestroySegment(z);
+ z = dst->segment;
+ continue;
+ }
+ else
+ {
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ }
+ }
+ else
+ {
+ z->x1 = XmuMax(z->x1, src->x1);
+ z->x2 = XmuMin(z->x2, src->x2);
+ }
+ p = z;
+ z = z->next;
+ }
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuScanlineXorSegment
+ *
+ * Parameters:
+ * dst - destionation scanline
+ * src - source segment
+ *
+ * Descriptipn:
+ * (input) +------------+ +----------+ +-----------+
+ * (src) +------------------------+
+ * (output) +---+ +--+ +-+ +-----------+
+ */
+XmuScanline *
+XmuScanlineXorSegment(XmuScanline *dst, XmuSegment *src)
+{
+ XmuSegment *p, *z, ins;
+ int tmp1, tmp2;
+
+ if (!dst || !src || !XmuValidSegment(src))
+ return (dst);
+ if (!dst->segment)
+ {
+ dst->segment = XmuNewSegment(src->x1, src->x2);
+ return (dst);
+ }
+
+ p = z = dst->segment;
+ ins.x1 = src->x1;
+ ins.x2 = src->x2;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ if (!XmuValidSegment((&ins)))
+ break;
+ if (!z || ins.x2 < z->x1)
+ {
+ XmuSegment *q = XmuNewSegment(ins.x1, ins.x2);
+
+ q->next = z;
+ if (z == dst->segment)
+ dst->segment = q;
+ else
+ p->next = q;
+ break;
+ }
+ else if (ins.x2 == z->x1)
+ {
+ z->x1 = ins.x1;
+ break;
+ }
+ else if (ins.x1 < z->x2)
+ {
+ if (ins.x1 < z->x1)
+ {
+ tmp1 = ins.x2;
+ tmp2 = z->x2;
+ ins.x2 = XmuMax(ins.x2, z->x2);
+ z->x2 = z->x1;
+ z->x1 = ins.x1;
+ ins.x1 = XmuMin(tmp1, tmp2);
+ }
+ else if (ins.x1 > z->x1)
+ {
+ tmp1 = ins.x1;
+ ins.x1 = XmuMin(ins.x2, z->x2);
+ ins.x2 = XmuMax(z->x2, ins.x2);
+ z->x2 = tmp1;
+ }
+ else /* ins.x1 == z->x1 */
+ {
+ if (ins.x2 < z->x2)
+ {
+ z->x1 = ins.x2;
+ break;
+ }
+ else
+ {
+ ins.x1 = z->x2;
+ if (z == dst->segment)
+ p = dst->segment = dst->segment->next;
+ else
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ continue;
+ }
+ }
+ }
+ else if (ins.x1 == z->x2)
+ {
+ ins.x1 = z->x1;
+ if (z == dst->segment)
+ p = dst->segment = dst->segment->next;
+ else
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ continue;
+ }
+ p = z;
+ z = z->next;
+ }
+
+ return (dst);
+}
+#endif /* notdef */
+
+/*
+ * Function:
+ * ScanlineOr
+ *
+ * Parameters:
+ * dst - destionation scanline
+ * src - source scanline
+ *
+ * Description:
+ * (input) +--------------+ +-----+ +----------+
+ * (src) +---------------------+ +-----------+
+ * (output) +-------------------------+ +----------------+
+ */
+XmuScanline *
+XmuScanlineOr(XmuScanline *dst, XmuScanline *src)
+{
+ XmuSegment *z, *p, *Z, ins;
+
+ if (!src || !src->segment || !dst || dst == src)
+ return (dst);
+ if (!dst->segment)
+ {
+ XmuScanlineCopy(dst, src);
+ return (dst);
+ }
+
+ z = p = dst->segment;
+ Z = src->segment;
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ while (!XmuValidSegment((&ins)))
+ {
+ if ((Z = Z->next) == (XmuSegment *)NULL)
+ return (dst);
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ }
+ if (!z)
+ {
+ XmuSegment *q = XmuNewSegment(ins.x1, ins.x2);
+
+ if (p == dst->segment && z == p)
+ dst->segment = p = q;
+ else
+ {
+ p->next = q;
+ p = q;
+ }
+ Z = Z->next;
+ XmuAppendSegment(p, Z);
+ break;
+ }
+ else if (ins.x2 < z->x1)
+ {
+ XmuSegment *r = XmuNewSegment(ins.x1, ins.x2);
+
+ if (p == dst->segment && z == p)
+ {
+ r->next = dst->segment;
+ dst->segment = p = r;
+ }
+ else
+ {
+ p->next = r;
+ r->next = z;
+ p = r;
+ }
+ Z = Z->next;
+ if (!Z)
+ break;
+ else
+ {
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ continue;
+ }
+ }
+ else if (ins.x2 <= z->x2)
+ {
+ z->x1 = XmuMin(z->x1, ins.x1);
+ Z = Z->next;
+ if (!Z)
+ break;
+ else
+ {
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ continue;
+ }
+ }
+ else if (ins.x1 <= z->x2)
+ {
+ ins.x1 = XmuMin(z->x1, ins.x1);
+ if (!z->next)
+ {
+ z->x1 = ins.x1;
+ z->x2 = ins.x2;
+ p = z;
+ Z = Z->next;
+ XmuAppendSegment(p, Z);
+ break;
+ }
+ else
+ {
+ if (z == dst->segment)
+ {
+ p = dst->segment = dst->segment->next;
+ XmuDestroySegment(z);
+ z = p;
+ continue;
+ }
+ else
+ {
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ }
+ }
+ }
+ p = z;
+ z = z->next;
+ }
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuScanlineAnd
+ *
+ * Parameters:
+ * dst - destination scanline
+ * src - source scanline
+ *
+ * Description:
+ * (input) +--------------+ +-----+ +----------+
+ * (src) +---------------------+ +-----------+
+ * (output) +----------+ +-----+ +-----+
+ */
+XmuScanline *
+XmuScanlineAnd(XmuScanline *dst, XmuScanline *src)
+{
+ XmuSegment *z, *p, *Z;
+
+ if (!dst || !src || dst == src || !dst->segment) {
+ return (dst);
+ }
+ if (!src->segment)
+ {
+ XmuDestroySegmentList(dst->segment);
+ dst->segment = (XmuSegment *)NULL;
+ return (dst);
+ }
+ z = p = dst->segment;
+ Z = src->segment;
+
+ while (z)
+ {
+ while (!XmuValidSegment(Z) || Z->x2 <= z->x1)
+ {
+ Z = Z->next;
+ if (!Z)
+ {
+ if (z == dst->segment)
+ dst->segment = (XmuSegment *)NULL;
+ else
+ p->next = (XmuSegment *)0;
+ XmuDestroySegmentList(z);
+ return (dst);
+ }
+ }
+ if (Z->x1 >= z->x2)
+ {
+ if (z == dst->segment)
+ {
+ p = dst->segment = dst->segment->next;
+ XmuDestroySegment(z);
+ z = dst->segment;
+ }
+ else
+ {
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p->next;
+ }
+ if (!z)
+ return (dst);
+ else
+ continue;
+ }
+ z->x1 = XmuMax(z->x1, Z->x1);
+ if (z->x2 > Z->x2)
+ {
+ if (Z->next)
+ {
+ XmuSegment *q = XmuNewSegment(Z->x2, z->x2);
+
+ q->next = z->next;
+ z->next = q;
+ }
+ z->x2 = Z->x2;
+ }
+ p = z;
+ z = z->next;
+ }
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * ScanlineXor
+ *
+ * Parameters:
+ * dst - destination scanline
+ * src - source scanline
+ *
+ * Description:
+ * (input) +--------------+ +-----+ +----------+
+ * (src) +---------------------+ +-----------+
+ * (output) +---+ +--+ +-+ +----+ +-----+
+ */
+XmuScanline *
+XmuScanlineXor(XmuScanline *dst, XmuScanline *src)
+{
+ XmuSegment *z, *p, *Z, ins;
+ int tmp1, tmp2;
+
+ if (!src || !dst || !src->segment)
+ return (dst);
+ if (src == dst)
+ {
+ XmuDestroySegmentList(dst->segment);
+ dst->segment = (XmuSegment *)NULL;
+ return (dst);
+ }
+ if (!dst->segment)
+ {
+ XmuScanlineCopy(dst, src);
+ return (dst);
+ }
+
+ z = p = dst->segment;
+ Z = src->segment;
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ while (!XmuValidSegment((&ins)))
+ {
+ if ((Z = Z->next) == (XmuSegment *)NULL)
+ return (dst);
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ }
+ if (!z)
+ {
+ XmuSegment *q = XmuNewSegment(ins.x1, ins.x2);
+
+ if (!dst->segment)
+ dst->segment = q;
+ else
+ p->next = q;
+ p = q;
+ Z = Z->next;
+ XmuAppendSegment(p, Z);
+ break;
+ }
+ else if (ins.x2 < z->x1)
+ {
+ XmuSegment *q = XmuNewSegment(ins.x1, ins.x2);
+
+ q->next = z;
+ if (z == dst->segment)
+ dst->segment = q;
+ else
+ p->next = q;
+ if ((Z = Z->next) == (XmuSegment *)NULL)
+ return (dst);
+
+ p = q;
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ continue;
+ }
+ else if (ins.x2 == z->x1)
+ {
+ z->x1 = ins.x1;
+ if ((Z = Z->next) == (XmuSegment *)NULL)
+ break;
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ continue;
+ }
+ else if (ins.x1 < z->x2)
+ {
+ if (ins.x1 == z->x1)
+ {
+ if (ins.x2 < z->x2)
+ {
+ z->x1 = ins.x2;
+ if ((Z = Z->next) == (XmuSegment *)NULL)
+ break;
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ continue;
+ }
+ else
+ {
+ ins.x1 = z->x2;
+ if (z == dst->segment)
+ p = dst->segment = dst->segment->next;
+ else
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ continue;
+ }
+ }
+ else
+ {
+ if (Z->x2 < z->x2)
+ {
+ XmuSegment *q = XmuNewSegment(XmuMin(ins.x1, z->x1),
+ XmuMax(z->x1, ins.x1));
+
+ q->next = z;
+ if (z == dst->segment)
+ dst->segment = q;
+ else
+ p->next = q;
+ ins.x1 = z->x2;
+ z->x1 = ins.x2;
+ p = q;
+ continue;
+ }
+ else
+ {
+ tmp1 = ins.x2;
+ tmp2 = z->x2;
+ ins.x2 = XmuMax(ins.x2, z->x2);
+ z->x2 = XmuMax(z->x1, ins.x1);
+ z->x1 = XmuMin(ins.x1, z->x1);
+ ins.x1 = XmuMin(tmp1, tmp2);
+ }
+ }
+ }
+ else if (ins.x1 == z->x2)
+ {
+ ins.x1 = z->x1;
+ if (z == dst->segment)
+ p = dst->segment = dst->segment->next;
+ else
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ continue;
+ }
+ p = z;
+ z = z->next;
+ }
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuNewScanline
+ *
+ * Parameters:
+ * y - y coordinate
+ * x1 - left coordinate
+ * x2 - right coordinate
+ *
+ * Description:
+ * Creates a new Scanline
+ */
+XmuScanline *
+XmuNewScanline(int y, int x1, int x2)
+{
+ XmuScanline *scanline;
+
+ scanline = (XmuScanline *)XtMalloc(sizeof(XmuScanline));
+ scanline->y = y;
+ if (x1 < x2)
+ scanline->segment = XmuNewSegment(x1, x2);
+ else
+ scanline->segment = (XmuSegment *)NULL;
+
+ scanline->next = (XmuScanline *)NULL;
+
+ return (scanline);
+}
+
+/*
+ * Function:
+ * XmuDestroyScanlineList
+ *
+ * Parameters:
+ * scanline - scanline list to destroy
+ *
+ * Description:
+ * Destroy a scanline list
+ *
+ * Observation:
+ * Use as follow:
+ * XmuDestroyScanlineList(area->scanline);
+ * area->scanline = (XmuScanline *)NULL;
+ */
+void
+XmuDestroyScanlineList(XmuScanline *scanline)
+{
+ XmuScanline *z;
+
+ if (!scanline)
+ return;
+
+ while (scanline)
+ {
+ z = scanline;
+ scanline = scanline->next;
+ XmuDestroyScanline(z);
+ }
+}
+
+/*
+ * Function:
+ * XmuOptimizeArea
+ *
+ * Parameters:
+ * area - area to optimize
+ *
+ * Description:
+ * Optimizes an area. This function is called when finishing a
+ * operation between areas, since they can end with redundant data,
+ * and the algorithms for area combination waits a area with
+ * correct data (but can left unnecessary data in the area, to avoid
+ * to much paranoia tests).
+ */
+XmuArea *XmuOptimizeArea(XmuArea *area)
+{
+ XmuScanline *pr, *at;
+
+ if (!area || !area->scanline)
+ return (area);
+
+ if (!area->scanline->next)
+ {
+ XmuDestroyScanlineList(area->scanline);
+ area->scanline = (XmuScanline *)0;
+ return (area);
+ }
+
+ pr = area->scanline;
+ at = area->scanline->next;
+ while (area->scanline && (!XmuValidScanline(area->scanline)
+ || (area->scanline->next && area->scanline->y
+ >= area->scanline->next->y)))
+ {
+ area->scanline = area->scanline->next;
+ XmuDestroyScanline(pr);
+ pr = area->scanline;
+ if (pr)
+ at = pr->next;
+ }
+
+ for (; at; pr = at, at = at->next)
+ {
+ if (XmuScanlineEqu(at, pr)
+ || (!XmuValidScanline(at) && !XmuValidScanline(pr))
+ || (at->next && at->y >= at->next->y))
+ {
+ pr->next = at->next;
+ XmuDestroyScanline(at);
+ at = pr;
+ }
+ }
+ if (pr && XmuValidScanline(pr))
+ {
+ XmuDestroySegmentList(pr->segment);
+ pr->segment = (XmuSegment *)NULL;
+ }
+ if (area->scanline && !area->scanline->next)
+ {
+ XmuDestroyScanlineList(area->scanline);
+ area->scanline = (XmuScanline *)NULL;
+ }
+
+ return (area);
+}
diff --git a/nx-X11/lib/Xmu/CloseHook.c b/nx-X11/lib/Xmu/CloseHook.c
new file mode 100644
index 000000000..5e66d0cad
--- /dev/null
+++ b/nx-X11/lib/Xmu/CloseHook.c
@@ -0,0 +1,297 @@
+/* $Xorg: CloseHook.c,v 1.4 2001/02/09 02:03:51 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/CloseHook.c,v 3.5 2001/07/25 15:04:50 dawes Exp $ */
+
+/*
+ * CloseDisplayHook package - provide callback on XCloseDisplay
+ *
+ * *
+ * Author: Jim Fulton, MIT X Consortium
+ *
+ *
+ * Public Entry Points
+ *
+ * CloseHook XmuAddCloseDisplayHook (dpy, func, arg)
+ * Display *dpy;
+ * XmuCloseHookProc func;
+ * XPointer arg;
+ *
+ * Bool XmuRemoveCloseDisplayHook (dpy, hook, func, arg)
+ * Display *dpy;
+ * CloseHook hook;
+ * XmuCloseHookProc func;
+ * XPointer arg;
+ *
+ * Bool XmuLookupCloseDisplayHook (dpy, hook, func, arg)
+ * Display *dpy;
+ * CloseHook hook;
+ * XmuCloseHookProc func;
+ * XPointer arg;
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h> /* for NULL */
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/Xmu/CloseHook.h>
+#include <stdlib.h>
+
+/*
+ * Private data
+ *
+ * This is a list of display entries, each of which contains a list of callback
+ * records.
+ */
+
+typedef struct _CallbackRec {
+ struct _CallbackRec *next; /* next link in chain */
+ XmuCloseHookProc func; /* function to call */
+ XPointer arg; /* argument to pass with function */
+} CallbackRec;
+
+
+typedef struct _DisplayEntry {
+ struct _DisplayEntry *next; /* next link in chain */
+ Display *dpy; /* the display this represents */
+ int extension; /* from XAddExtension */
+ struct _CallbackRec *start, *end; /* linked list of callbacks */
+ struct _CallbackRec *calling; /* currently being called back */
+} DisplayEntry;
+
+/*
+ * Prototypes
+ */
+static DisplayEntry *_FindDisplayEntry(Display*, DisplayEntry**);
+static Bool _MakeExtension(Display*, int*);
+
+static DisplayEntry *elist = NULL;
+
+
+/*
+ *****************************************************************************
+ * Public Entry Points *
+ *****************************************************************************
+ */
+
+/*
+ * Add - add a callback for the given display. When the display is closed,
+ * the given function will be called as:
+ *
+ * (*func) (dpy, arg)
+ *
+ * This function is declared to return an int even though the value is ignored
+ * because some compilers have problems with functions returning void.
+ *
+ * This routine returns NULL if it was unable to add the callback, otherwise
+ * it returns an untyped pointer that can be used with Remove or Lookup, but
+ * not dereferenced.
+ */
+CloseHook
+XmuAddCloseDisplayHook(Display *dpy, XmuCloseHookProc func, XPointer arg)
+{
+ DisplayEntry *de;
+ CallbackRec *cb;
+
+ /* allocate ahead of time so that we can fail atomically */
+ cb = (CallbackRec *) malloc (sizeof (CallbackRec));
+ if (!cb) return ((XPointer) NULL);
+
+ de = _FindDisplayEntry (dpy, NULL);
+ if (!de) {
+ if ((de = (DisplayEntry *) malloc (sizeof (DisplayEntry))) == NULL ||
+ !_MakeExtension (dpy, &de->extension)) {
+ free ((char *) cb);
+ if (de) free ((char *) de);
+ return ((CloseHook) NULL);
+ }
+ de->dpy = dpy;
+ de->start = de->end = NULL;
+ de->calling = NULL;
+ de->next = elist;
+ elist = de;
+ }
+
+ /* add to end of list of callback recordss */
+ cb->func = func;
+ cb->arg = arg;
+ cb->next = NULL;
+ if (de->end) {
+ de->end->next = cb;
+ } else {
+ de->start = cb;
+ }
+ de->end = cb;
+
+ return ((CloseHook) cb);
+}
+
+
+/*
+ * Remove - get rid of a callback. If handle is non-null, use that to compare
+ * entries. Otherwise, remove first instance of the function/argument pair.
+ */
+Bool
+XmuRemoveCloseDisplayHook(Display *dpy, CloseHook handle,
+ XmuCloseHookProc func, XPointer arg)
+{
+ DisplayEntry *de = _FindDisplayEntry (dpy, NULL);
+ register CallbackRec *h, *prev;
+
+ if (!de) return False;
+
+ /* look for handle or function/argument pair */
+ for (h = de->start, prev = NULL; h; h = h->next) {
+ if (handle) {
+ if (h == (CallbackRec *) handle) break;
+ } else {
+ if (h->func == func && h->arg == arg) break;
+ }
+ prev = h;
+ }
+ if (!h) return False;
+
+
+ /* remove from list, watch head and tail */
+ if (de->start == h) {
+ de->start = h->next;
+ } else {
+ prev->next = h->next;
+ }
+ if (de->end == h) de->end = prev;
+ if (de->calling != h) free ((char *) h);
+ return True;
+}
+
+
+/*
+ * Lookup - see whether or not a handle has been installed. If handle is
+ * non-NULL, look for an entry that matches it; otherwise look for an entry
+ * with the same function/argument pair.
+ */
+Bool
+XmuLookupCloseDisplayHook(Display *dpy, CloseHook handle,
+ XmuCloseHookProc func, XPointer arg)
+{
+ DisplayEntry *de = _FindDisplayEntry (dpy, NULL);
+ register CallbackRec *h;
+
+ if (!de) return False;
+
+ for (h = de->start; h; h = h->next) {
+ if (handle) {
+ if (h == (CallbackRec *) handle) break;
+ } else {
+ if (h->func == func && h->arg == arg) break;
+ }
+ }
+ return (h ? True : False);
+}
+
+
+/*
+ *****************************************************************************
+ * internal routines *
+ *****************************************************************************
+ */
+
+
+/*
+ * Find the specified display on the linked list of displays. Also return
+ * the preceeding link so that the display can be unlinked without having
+ * back pointers.
+ */
+static DisplayEntry *
+_FindDisplayEntry(register Display *dpy, DisplayEntry **prevp)
+{
+ register DisplayEntry *d, *prev;
+
+ for (d = elist, prev = NULL; d; d = d->next) {
+ if (d->dpy == dpy) {
+ if (prevp) *prevp = prev;
+ return d;
+ }
+ prev = d;
+ }
+ return NULL;
+}
+
+
+
+/*
+ * _DoCallbacks - process all of the callbacks for this display and free
+ * the associated callback data (callback records and display entries).
+ */
+/* ARGSUSED */
+static int
+_DoCallbacks(Display *dpy, XExtCodes *codes)
+{
+ register CallbackRec *h;
+ DisplayEntry *prev;
+ DisplayEntry *de = _FindDisplayEntry (dpy, &prev);
+
+ if (!de) return 0;
+
+ /* walk the list doing the callbacks and freeing callback record */
+ for (h = de->start; h;) {
+ register CallbackRec *nexth = h->next;
+ de->calling = h; /* let remove know we'll free it */
+ (*(h->func)) (dpy, h->arg);
+ de->calling = NULL;
+ free ((char *) h);
+ h = nexth;
+ }
+
+ /* unlink this display from chain */
+ if (elist == de) {
+ elist = de->next;
+ } else {
+ prev->next = de->next;
+ }
+ free ((char *) de);
+ return 1;
+}
+
+
+/*
+ * _MakeExtension - create an extension for this display; done once per display
+ */
+static Bool
+_MakeExtension(Display *dpy, int *extensionp)
+{
+ XExtCodes *codes;
+
+ codes = XAddExtension (dpy);
+ if (!codes) return False;
+
+ (void) XESetCloseDisplay (dpy, codes->extension, _DoCallbacks);
+
+ *extensionp = codes->extension;
+ return True;
+}
diff --git a/nx-X11/lib/Xmu/CloseHook.h b/nx-X11/lib/Xmu/CloseHook.h
new file mode 100644
index 000000000..1940a793b
--- /dev/null
+++ b/nx-X11/lib/Xmu/CloseHook.h
@@ -0,0 +1,73 @@
+/* $Xorg: CloseHook.h,v 1.5 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/CloseHook.h,v 1.6 2001/01/17 19:42:53 dawes Exp $ */
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_CLOSEHOOK_H_
+#define _XMU_CLOSEHOOK_H_
+
+#include <X11/Xlib.h>
+#include <X11/Xfuncproto.h>
+#include <X11/Xlibint.h>
+
+typedef XPointer CloseHook;
+
+typedef int (*XmuCloseHookProc)(Display *dpy, XPointer data);
+
+_XFUNCPROTOBEGIN
+
+CloseHook XmuAddCloseDisplayHook
+(
+ Display *dpy,
+ XmuCloseHookProc proc,
+ XPointer arg
+ );
+
+Bool XmuLookupCloseDisplayHook
+(
+ Display *dpy,
+ CloseHook handle,
+ XmuCloseHookProc proc,
+ XPointer arg
+ );
+
+Bool XmuRemoveCloseDisplayHook
+(
+ Display *dpy,
+ CloseHook handle,
+ XmuCloseHookProc proc,
+ XPointer arg
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_CLOSEHOOK_H_ */
diff --git a/nx-X11/lib/Xmu/CmapAlloc.c b/nx-X11/lib/Xmu/CmapAlloc.c
new file mode 100644
index 000000000..1f27f1eef
--- /dev/null
+++ b/nx-X11/lib/Xmu/CmapAlloc.c
@@ -0,0 +1,346 @@
+/* $Xorg: CmapAlloc.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xmu/CmapAlloc.c,v 1.6 2001/01/17 19:42:53 dawes Exp $ */
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+#include <stdio.h>
+
+#define lowbit(x) ((x) & (~(x) + 1))
+
+/*
+ * Prototypes
+ */
+static void best_allocation(XVisualInfo*, unsigned long*, unsigned long*,
+ unsigned long*);
+static int default_allocation(XVisualInfo*, unsigned long*,
+ unsigned long*, unsigned long*);
+static void gray_allocation(int, unsigned long*, unsigned long*,
+ unsigned long*);
+static int icbrt(int);
+static int icbrt_with_bits(int, int);
+static int icbrt_with_guess(int, int);
+
+/* To determine the best allocation of reds, greens, and blues in a
+ * standard colormap, use XmuGetColormapAllocation.
+ * vinfo specifies visual information for a chosen visual
+ * property specifies one of the standard colormap property names
+ * red_max returns maximum red value
+ * green_max returns maximum green value
+ * blue_max returns maximum blue value
+ *
+ * XmuGetColormapAllocation returns 0 on failure, non-zero on success.
+ * It is assumed that the visual is appropriate for the colormap property.
+ */
+
+Status
+XmuGetColormapAllocation(XVisualInfo *vinfo, Atom property,
+ unsigned long *red_max,
+ unsigned long *green_max,
+ unsigned long *blue_max)
+{
+ Status status = 1;
+
+ if (vinfo->colormap_size <= 2)
+ return 0;
+
+ switch (property)
+ {
+ case XA_RGB_DEFAULT_MAP:
+ status = default_allocation(vinfo, red_max, green_max, blue_max);
+ break;
+ case XA_RGB_BEST_MAP:
+ best_allocation(vinfo, red_max, green_max, blue_max);
+ break;
+ case XA_RGB_GRAY_MAP:
+ gray_allocation(vinfo->colormap_size, red_max, green_max, blue_max);
+ break;
+ case XA_RGB_RED_MAP:
+ *red_max = vinfo->colormap_size - 1;
+ *green_max = *blue_max = 0;
+ break;
+ case XA_RGB_GREEN_MAP:
+ *green_max = vinfo->colormap_size - 1;
+ *red_max = *blue_max = 0;
+ break;
+ case XA_RGB_BLUE_MAP:
+ *blue_max = vinfo->colormap_size - 1;
+ *red_max = *green_max = 0;
+ break;
+ default:
+ status = 0;
+ }
+ return status;
+}
+
+/****************************************************************************/
+/* Determine the appropriate color allocations of a gray scale.
+ *
+ * Keith Packard, MIT X Consortium
+ */
+
+static void
+gray_allocation(int n, unsigned long *red_max, unsigned long *green_max,
+ unsigned long *blue_max)
+{
+ *red_max = (n * 30) / 100;
+ *green_max = (n * 59) / 100;
+ *blue_max = (n * 11) / 100;
+ *green_max += ((n - 1) - (*red_max + *green_max + *blue_max));
+}
+
+/****************************************************************************/
+/* Determine an appropriate color allocation for the RGB_DEFAULT_MAP.
+ * If a map has less than a minimum number of definable entries, we do not
+ * produce an allocation for an RGB_DEFAULT_MAP.
+ *
+ * For 16 planes, the default colormap will have 27 each RGB; for 12 planes,
+ * 12 each. For 8 planes, let n = the number of colormap entries, which may
+ * be 256 or 254. Then, maximum red value = floor(cube_root(n - 125)) - 1.
+ * Maximum green and maximum blue values are identical to maximum red.
+ * This leaves at least 125 cells which clients can allocate.
+ *
+ * Return 0 if an allocation has been determined, non-zero otherwise.
+ */
+
+static int
+default_allocation(XVisualInfo *vinfo, unsigned long *red,
+ unsigned long *green, unsigned long *blue)
+{
+ int ngrays; /* number of gray cells */
+
+ switch (vinfo->class) {
+ case PseudoColor:
+
+ if (vinfo->colormap_size > 65000)
+ /* intended for displays with 16 planes */
+ *red = *green = *blue = (unsigned long) 27;
+ else if (vinfo->colormap_size > 4000)
+ /* intended for displays with 12 planes */
+ *red = *green = *blue = (unsigned long) 12;
+ else if (vinfo->colormap_size < 250)
+ return 0;
+ else
+ /* intended for displays with 8 planes */
+ *red = *green = *blue = (unsigned long)
+ (icbrt(vinfo->colormap_size - 125) - 1);
+ break;
+
+ case DirectColor:
+
+ if (vinfo->colormap_size < 10)
+ return 0;
+ *red = *green = *blue = vinfo->colormap_size / 2 - 1;
+ break;
+
+ case TrueColor:
+
+ *red = vinfo->red_mask / lowbit(vinfo->red_mask);
+ *green = vinfo->green_mask / lowbit(vinfo->green_mask);
+ *blue = vinfo->blue_mask / lowbit(vinfo->blue_mask);
+ break;
+
+ case GrayScale:
+
+ if (vinfo->colormap_size > 65000)
+ ngrays = 4096;
+ else if (vinfo->colormap_size > 4000)
+ ngrays = 512;
+ else if (vinfo->colormap_size < 250)
+ return 0;
+ else
+ ngrays = 12;
+ gray_allocation(ngrays, red, green, blue);
+ break;
+
+ default:
+ return 0;
+ }
+ return 1;
+}
+
+/****************************************************************************/
+/* Determine an appropriate color allocation for the RGB_BEST_MAP.
+ *
+ * For a DirectColor or TrueColor visual, the allocation is determined
+ * by the red_mask, green_mask, and blue_mask members of the visual info.
+ *
+ * Otherwise, if the colormap size is an integral power of 2, determine
+ * the allocation according to the number of bits given to each color,
+ * with green getting more than red, and red more than blue, if there
+ * are to be inequities in the distribution. If the colormap size is
+ * not an integral power of 2, let n = the number of colormap entries.
+ * Then maximum red value = floor(cube_root(n)) - 1;
+ * maximum blue value = floor(cube_root(n)) - 1;
+ * maximum green value = n / ((# red values) * (# blue values)) - 1;
+ * Which, on a GPX, allows for 252 entries in the best map, out of 254
+ * defineable colormap entries.
+ */
+
+static void
+best_allocation(XVisualInfo *vinfo, unsigned long *red, unsigned long *green,
+ unsigned long *blue)
+{
+
+ if (vinfo->class == DirectColor || vinfo->class == TrueColor)
+ {
+ *red = vinfo->red_mask;
+ while ((*red & 01) == 0)
+ *red >>= 1;
+ *green = vinfo->green_mask;
+ while ((*green & 01) == 0)
+ *green >>=1;
+ *blue = vinfo->blue_mask;
+ while ((*blue & 01) == 0)
+ *blue >>= 1;
+ }
+ else
+ {
+ register int bits, n;
+
+ /* Determine n such that n is the least integral power of 2 which is
+ * greater than or equal to the number of entries in the colormap.
+ */
+ n = 1;
+ bits = 0;
+ while (vinfo->colormap_size > n)
+ {
+ n = n << 1;
+ bits++;
+ }
+
+ /* If the number of entries in the colormap is a power of 2, determine
+ * the allocation by "dealing" the bits, first to green, then red, then
+ * blue. If not, find the maximum integral red, green, and blue values
+ * which, when multiplied together, do not exceed the number of
+
+ * colormap entries.
+ */
+ if (n == vinfo->colormap_size)
+ {
+ register int r, g, b;
+ b = bits / 3;
+ g = b + ((bits % 3) ? 1 : 0);
+ r = b + (((bits % 3) == 2) ? 1 : 0);
+ *red = 1 << r;
+ *green = 1 << g;
+ *blue = 1 << b;
+ }
+ else
+ {
+ *red = icbrt_with_bits(vinfo->colormap_size, bits);
+ *blue = *red;
+ *green = (vinfo->colormap_size / ((*red) * (*blue)));
+ }
+ (*red)--;
+ (*green)--;
+ (*blue)--;
+ }
+ return;
+}
+
+/*
+ * integer cube roots by Newton's method
+ *
+ * Stephen Gildea, MIT X Consortium, July 1991
+ */
+
+static int
+icbrt(int a)
+{
+ register int bits = 0;
+ register unsigned n = a;
+
+ while (n)
+ {
+ bits++;
+ n >>= 1;
+ }
+ return icbrt_with_bits(a, bits);
+}
+
+
+static int
+icbrt_with_bits(int a, int bits)
+ /* bits - log 2 of a */
+{
+ return icbrt_with_guess(a, a>>2*bits/3);
+}
+
+#ifdef _X_ROOT_STATS
+int icbrt_loopcount;
+#endif
+
+/* Newton's Method: x_n+1 = x_n - ( f(x_n) / f'(x_n) ) */
+
+/* for cube roots, x^3 - a = 0, x_new = x - 1/3 (x - a/x^2) */
+
+/*
+ * Quick and dirty cube roots. Nothing fancy here, just Newton's method.
+ * Only works for positive integers (since that's all we need).
+ * We actually return floor(cbrt(a)) because that's what we need here, too.
+ */
+
+static int
+icbrt_with_guess(int a, int guess)
+{
+ register int delta;
+
+#ifdef _X_ROOT_STATS
+ icbrt_loopcount = 0;
+#endif
+ if (a <= 0)
+ return 0;
+ if (guess < 1)
+ guess = 1;
+
+ do {
+#ifdef _X_ROOT_STATS
+ icbrt_loopcount++;
+#endif
+ delta = (guess - a/(guess*guess))/3;
+#ifdef DEBUG
+ printf("pass %d: guess=%d, delta=%d\n", icbrt_loopcount, guess, delta);
+#endif
+ guess -= delta;
+ } while (delta != 0);
+
+ if (guess*guess*guess > a)
+ guess--;
+
+ return guess;
+}
diff --git a/nx-X11/lib/Xmu/Converters.h b/nx-X11/lib/Xmu/Converters.h
new file mode 100644
index 000000000..11055d950
--- /dev/null
+++ b/nx-X11/lib/Xmu/Converters.h
@@ -0,0 +1,281 @@
+/* $Xorg: Converters.h,v 1.5 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+
+/* $XFree86: xc/lib/Xmu/Converters.h,v 1.5 2001/01/17 19:42:53 dawes Exp $ */
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_STRCONVERT_H_
+#define _XMU_STRCONVERT_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+void XmuCvtFunctionToCallback
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+#define XtNbackingStore "backingStore"
+#define XtCBackingStore "BackingStore"
+#define XtRBackingStore "BackingStore"
+#define XtEnotUseful "notUseful"
+#define XtEwhenMapped "whenMapped"
+#define XtEalways "always"
+#define XtEdefault "default"
+void XmuCvtStringToBackingStore
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+Boolean XmuCvtBackingStoreToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+void XmuCvtStringToCursor
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+#define XtRColorCursor "ColorCursor"
+#define XtNpointerColor "pointerColor"
+#define XtNpointerColorBackground "pointerColorBackground"
+Boolean XmuCvtStringToColorCursor
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+typedef int XtGravity;
+
+#ifndef XtRGravity
+#define XtRGravity "Gravity"
+#endif
+#define XtEForget "forget"
+#define XtENorthWest "northwest"
+#define XtENorth "north"
+#define XtENorthEast "northeast"
+#define XtEWest "west"
+#define XtECenter "center"
+#define XtEEast "east"
+#define XtESouthWest "southwest"
+#define XtESouth "south"
+#define XtESouthEast "southeast"
+#define XtEStatic "static"
+#define XtEUnmap "unmap"
+void XmuCvtStringToGravity
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+Boolean XmuCvtGravityToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+typedef enum {
+ XtJustifyLeft, /* justify text to left side of button */
+ XtJustifyCenter, /* justify text in center of button */
+ XtJustifyRight /* justify text to right side of button */
+} XtJustify;
+#ifndef XtRJustify
+#define XtRJustify "Justify"
+#endif
+#define XtEleft "left"
+#define XtEcenter "center"
+#define XtEright "right"
+#define XtEtop "top"
+#define XtEbottom "bottom"
+void XmuCvtStringToJustify
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+Boolean XmuCvtJustifyToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+#define XtRLong "Long"
+void XmuCvtStringToLong
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+Boolean XmuCvtLongToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+typedef enum {
+ XtorientHorizontal,
+ XtorientVertical
+} XtOrientation;
+void XmuCvtStringToOrientation
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+Boolean XmuCvtOrientationToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+void XmuCvtStringToBitmap
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+#define XtRShapeStyle "ShapeStyle"
+#define XtERectangle "Rectangle"
+#define XtEOval "Oval"
+#define XtEEllipse "Ellipse"
+#define XtERoundedRectangle "RoundedRectangle"
+
+#define XmuShapeRectangle 1
+#define XmuShapeOval 2
+#define XmuShapeEllipse 3
+#define XmuShapeRoundedRectangle 4
+
+Boolean XmuCvtStringToShapeStyle
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+Boolean XmuCvtShapeStyleToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+Boolean XmuReshapeWidget
+(
+ Widget w,
+ int shape_style,
+ int corner_width,
+ int corner_height
+ );
+
+void XmuCvtStringToWidget
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+Boolean XmuNewCvtStringToWidget
+(
+ Display *display,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValue *fromVal,
+ XrmValue *toVal,
+ XtPointer *converter_data
+ );
+
+Boolean XmuCvtWidgetToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValue *fromVal,
+ XrmValue *toVal,
+ XtPointer *converter_data
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_STRCONVERT_H_ */
diff --git a/nx-X11/lib/Xmu/CrCmap.c b/nx-X11/lib/Xmu/CrCmap.c
new file mode 100644
index 000000000..011c71465
--- /dev/null
+++ b/nx-X11/lib/Xmu/CrCmap.c
@@ -0,0 +1,537 @@
+/* $Xorg: CrCmap.c,v 1.4 2001/02/09 02:03:51 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/CrCmap.c,v 3.6 2001/01/17 19:42:53 dawes Exp $ */
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+/*
+ * CreateCmap.c - given a standard colormap description, make the map.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+/*
+ * Prototypes
+ */
+/* allocate entire map Read Only */
+static int ROmap(Display*, Colormap, unsigned long[], int, int);
+
+/* allocate a cell, prefer Read Only */
+static Status ROorRWcell(Display*, Colormap, unsigned long[], int,
+ XColor*, unsigned long);
+
+/* allocate a cell Read Write */
+static Status RWcell(Display*, Colormap, XColor*, XColor*, unsigned long*);
+
+/* for quicksort */
+static int compare(_Xconst void*, _Xconst void*);
+
+/* find contiguous sequence of cells */
+static Status contiguous(unsigned long[], int, int, unsigned long, int*, int*);
+
+/* frees resources before quitting */
+static void free_cells(Display*, Colormap, unsigned long[], int, int);
+
+/* create a map in a RO visual type */
+static Status readonly_map(Display*, XVisualInfo*, XStandardColormap*);
+
+/* create a map in a RW visual type */
+static Status readwrite_map(Display*, XVisualInfo*, XStandardColormap*);
+
+#define lowbit(x) ((x) & (~(x) + 1))
+#define TRUEMATCH(mult,max,mask) \
+ (colormap->max * colormap->mult <= vinfo->mask && \
+ lowbit(vinfo->mask) == colormap->mult)
+
+/*
+ * To create any one colormap which is described by an XStandardColormap
+ * structure, use XmuCreateColormap().
+ *
+ * Return 0 on failure, non-zero on success.
+ * Resources created by this function are not made permanent.
+ * No argument error checking is provided. Use at your own risk.
+ *
+ * All colormaps are created with read only allocations, with the exception
+ * of read only allocations of colors in the default map or otherwise
+ * which fail to return the expected pixel value, and these are individually
+ * defined as read/write allocations. This is done so that all the cells
+ * defined in the default map are contiguous, for use in image processing.
+ * This typically happens with White and Black in the default map.
+ *
+ * Colormaps of static visuals are considered to be successfully created if
+ * the map of the static visual matches the definition given in the
+ * standard colormap structure.
+ */
+
+Status
+XmuCreateColormap(Display *dpy, XStandardColormap *colormap)
+ /* dpy - specifies the connection under which the map is created
+ * colormap - specifies the map to be created, and returns, particularly
+ * if the map is created as a subset of the default colormap
+ * of the screen, the base_pixel of the map.
+ */
+{
+ XVisualInfo vinfo_template; /* template visual information */
+ XVisualInfo *vinfo; /* matching visual information */
+ XVisualInfo *vpointer; /* for freeing the entire list */
+ long vinfo_mask; /* specifies the visual mask value */
+ int n; /* number of matching visuals */
+ int status;
+
+ vinfo_template.visualid = colormap->visualid;
+ vinfo_mask = VisualIDMask;
+ if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
+ return 0;
+
+ /* A visual id may be valid on multiple screens. Also, there may
+ * be multiple visuals with identical visual ids at different depths.
+ * If the colormap is the Default Colormap, use the Default Visual.
+ * Otherwise, arbitrarily, use the deepest visual.
+ */
+ vpointer = vinfo;
+ if (n > 1)
+ {
+ register int i;
+ register int screen_number;
+ Bool def_cmap;
+
+ def_cmap = False;
+ for (screen_number = ScreenCount(dpy); --screen_number >= 0; )
+ if (colormap->colormap == DefaultColormap(dpy, screen_number)) {
+ def_cmap = True;
+ break;
+ }
+
+ if (def_cmap) {
+ for (i=0; i < n; i++, vinfo++) {
+ if (vinfo->visual == DefaultVisual(dpy, screen_number))
+ break;
+ }
+ } else {
+ int maxdepth = 0;
+ XVisualInfo *v = NULL;
+
+ for (i=0; i < n; i++, vinfo++)
+ if (vinfo->depth > maxdepth) {
+ maxdepth = vinfo->depth;
+ v = vinfo;
+ }
+ vinfo = v;
+ }
+ }
+
+ if (vinfo->class == PseudoColor || vinfo->class == DirectColor ||
+ vinfo->class == GrayScale)
+ status = readwrite_map(dpy, vinfo, colormap);
+ else if (vinfo->class == TrueColor)
+ status = TRUEMATCH(red_mult, red_max, red_mask) &&
+ TRUEMATCH(green_mult, green_max, green_mask) &&
+ TRUEMATCH(blue_mult, blue_max, blue_mask);
+ else
+ status = readonly_map(dpy, vinfo, colormap);
+
+ XFree((char *) vpointer);
+ return status;
+}
+
+/****************************************************************************/
+static Status
+readwrite_map(Display *dpy, XVisualInfo *vinfo, XStandardColormap *colormap)
+{
+ register unsigned long i, n; /* index counters */
+ unsigned long ncolors; /* number of colors to be defined */
+ int npixels; /* number of pixels allocated R/W */
+ int first_index; /* first index of pixels to use */
+ int remainder; /* first index of remainder */
+ XColor color; /* the definition of a color */
+ unsigned long *pixels; /* array of colormap pixels */
+ unsigned long delta;
+
+
+ /* Determine ncolors, the number of colors to be defined.
+ * Insure that 1 < ncolors <= the colormap size.
+ */
+ if (vinfo->class == DirectColor) {
+ ncolors = colormap->red_max;
+ if (colormap->green_max > ncolors)
+ ncolors = colormap->green_max;
+ if (colormap->blue_max > ncolors)
+ ncolors = colormap->blue_max;
+ ncolors++;
+ delta = lowbit(vinfo->red_mask) +
+ lowbit(vinfo->green_mask) +
+ lowbit(vinfo->blue_mask);
+ } else {
+ ncolors = colormap->red_max * colormap->red_mult +
+ colormap->green_max * colormap->green_mult +
+ colormap->blue_max * colormap->blue_mult + 1;
+ delta = 1;
+ }
+ if (ncolors <= 1 || (int) ncolors > vinfo->colormap_size) return 0;
+
+ /* Allocate Read/Write as much of the colormap as we can possibly get.
+ * Then insure that the pixels we were allocated are given in
+ * monotonically increasing order, using a quicksort. Next, insure
+ * that our allocation includes a subset of contiguous pixels at least
+ * as long as the number of colors to be defined. Now we know that
+ * these conditions are met:
+ * 1) There are no free cells in the colormap.
+ * 2) We have a contiguous sequence of pixels, monotonically
+ * increasing, of length >= the number of colors requested.
+ *
+ * One cell at a time, we will free, compute the next color value,
+ * then allocate read only. This takes a long time.
+ * This is done to insure that cells are allocated read only in the
+ * contiguous order which we prefer. If the server has a choice of
+ * cells to grant to an allocation request, the server may give us any
+ * cell, so that is why we do these slow gymnastics.
+ */
+
+ if ((pixels = (unsigned long *) calloc((unsigned) vinfo->colormap_size,
+ sizeof(unsigned long))) == NULL)
+ return 0;
+
+ if ((npixels = ROmap(dpy, colormap->colormap, pixels,
+ vinfo->colormap_size, ncolors)) == 0) {
+ free((char *) pixels);
+ return 0;
+ }
+
+ qsort((char *) pixels, npixels, sizeof(unsigned long), compare);
+
+ if (!contiguous(pixels, npixels, ncolors, delta, &first_index, &remainder))
+ {
+ /* can't find enough contiguous cells, give up */
+ XFreeColors(dpy, colormap->colormap, pixels, npixels,
+ (unsigned long) 0);
+ free((char *) pixels);
+ return 0;
+ }
+ colormap->base_pixel = pixels[first_index];
+
+ /* construct a gray map */
+ if (colormap->red_mult == 1 && colormap->green_mult == 1 &&
+ colormap->blue_mult == 1)
+ for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n;
+ color.blue = color.green = color.red =
+ (unsigned short) ((i * 65535) / (colormap->red_max +
+ colormap->green_max +
+ colormap->blue_max));
+
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+
+ /* construct a red ramp map */
+ else if (colormap->green_max == 0 && colormap->blue_max == 0)
+ for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n;
+ color.red = (unsigned short) ((i * 65535) / colormap->red_max);
+ color.green = color.blue = 0;
+
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+
+ /* construct a green ramp map */
+ else if (colormap->red_max == 0 && colormap->blue_max == 0)
+ for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n;
+ color.green = (unsigned short) ((i * 65535) / colormap->green_max);
+ color.red = color.blue = 0;
+
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+
+ /* construct a blue ramp map */
+ else if (colormap->red_max == 0 && colormap->green_max == 0)
+ for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n;
+ color.blue = (unsigned short) ((i * 65535) / colormap->blue_max);
+ color.red = color.green = 0;
+
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+
+ /* construct a standard red green blue cube map */
+ else
+ {
+#define calc(max,mult) (((n / colormap->mult) % \
+ (colormap->max + 1)) * 65535) / colormap->max
+
+ for (n=0, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n + colormap->base_pixel;
+ color.red = calc(red_max, red_mult);
+ color.green = calc(green_max, green_mult);
+ color.blue = calc(blue_max, blue_mult);
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+#undef calc
+ }
+ /* We have a read-only map defined. Now free unused cells,
+ * first those occuring before the contiguous sequence begins,
+ * then any following the contiguous sequence.
+ */
+
+ if (first_index)
+ XFreeColors(dpy, colormap->colormap, pixels, first_index,
+ (unsigned long) 0);
+ if (remainder)
+ XFreeColors(dpy, colormap->colormap,
+ &(pixels[first_index + ncolors]), remainder,
+ (unsigned long) 0);
+
+ free((char *) pixels);
+ return 1;
+}
+
+
+/****************************************************************************/
+static int
+ROmap(Display *dpy, Colormap cmap, unsigned long pixels[], int m, int n)
+ /*
+ * dpy - the X server connection
+ * cmap - specifies colormap ID
+ * pixels - returns pixel allocations
+ * m - specifies colormap size
+ * n - specifies number of colors
+ */
+{
+ register int p;
+
+ /* first try to allocate the entire colormap */
+ if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL,
+ (unsigned) 0, pixels, (unsigned) m))
+ return m;
+
+ /* Allocate all available cells in the colormap, using a binary
+ * algorithm to discover how many cells we can allocate in the colormap.
+ */
+ m--;
+ while (n <= m) {
+ p = n + ((m - n + 1) / 2);
+ if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL,
+ (unsigned) 0, pixels, (unsigned) p)) {
+ if (p == m)
+ return p;
+ else {
+ XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
+ n = p;
+ }
+ }
+ else
+ m = p - 1;
+ }
+ return 0;
+}
+
+
+/****************************************************************************/
+static Status
+contiguous(unsigned long pixels[], int npixels, int ncolors,
+ unsigned long delta, int *first, int *rem)
+ /* pixels - specifies allocated pixels
+ * npixels - specifies count of alloc'd pixels
+ * ncolors - specifies needed sequence length
+ * delta - between pixels
+ * first - returns first index of sequence
+ * rem - returns first index after sequence, or 0, if none follow
+ */
+{
+ register int i = 1; /* walking index into the pixel array */
+ register int count = 1; /* length of sequence discovered so far */
+
+ *first = 0;
+ if (npixels == ncolors) {
+ *rem = 0;
+ return 1;
+ }
+ *rem = npixels - 1;
+ while (count < ncolors && ncolors - count <= *rem)
+ {
+ if (pixels[i-1] + delta == pixels[i])
+ count++;
+ else {
+ count = 1;
+ *first = i;
+ }
+ i++;
+ (*rem)--;
+ }
+ if (count != ncolors)
+ return 0;
+ return 1;
+}
+
+
+/****************************************************************************/
+static Status
+ROorRWcell(Display *dpy, Colormap cmap, unsigned long pixels[],
+ int npixels, XColor *color, unsigned long p)
+{
+ unsigned long pixel;
+ XColor request;
+
+ /* Free the read/write allocation of one cell in the colormap.
+ * Request a read only allocation of one cell in the colormap.
+ * If the read only allocation cannot be granted, give up, because
+ * there must be no free cells in the colormap.
+ * If the read only allocation is granted, but gives us a cell which
+ * is not the one that we just freed, it is probably the case that
+ * we are trying allocate White or Black or some other color which
+ * already has a read-only allocation in the map. So we try to
+ * allocate the previously freed cell with a read/write allocation,
+ * because we want contiguous cells for image processing algorithms.
+ */
+
+ pixel = color->pixel;
+ request.red = color->red;
+ request.green = color->green;
+ request.blue = color->blue;
+
+ XFreeColors(dpy, cmap, &pixel, 1, (unsigned long) 0);
+ if (! XAllocColor(dpy, cmap, color)
+ || (color->pixel != pixel &&
+ (!RWcell(dpy, cmap, color, &request, &pixel))))
+ {
+ free_cells(dpy, cmap, pixels, npixels, (int)p);
+ return 0;
+ }
+ return 1;
+}
+
+
+/****************************************************************************/
+static void
+free_cells(Display *dpy, Colormap cmap, unsigned long pixels[],
+ int npixels, int p)
+ /*
+ * pixels - to be freed
+ * npixels - original number allocated
+ */
+{
+ /* One of the npixels allocated has already been freed.
+ * p is the index of the freed pixel.
+ * First free the pixels preceeding p, and there are p of them;
+ * then free the pixels following p, there are npixels - p - 1 of them.
+ */
+ XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
+ XFreeColors(dpy, cmap, &(pixels[p+1]), npixels - p - 1, (unsigned long) 0);
+ free((char *) pixels);
+}
+
+
+/****************************************************************************/
+static Status
+RWcell(Display *dpy, Colormap cmap, XColor *color, XColor *request,
+ unsigned long *pixel)
+{
+ unsigned long n = *pixel;
+
+ XFreeColors(dpy, cmap, &(color->pixel), 1, (unsigned long)0);
+ if (! XAllocColorCells(dpy, cmap, (Bool) 0, (unsigned long *) NULL,
+ (unsigned) 0, pixel, (unsigned) 1))
+ return 0;
+ if (*pixel != n)
+ {
+ XFreeColors(dpy, cmap, pixel, 1, (unsigned long) 0);
+ return 0;
+ }
+ color->pixel = *pixel;
+ color->flags = DoRed | DoGreen | DoBlue;
+ color->red = request->red;
+ color->green = request->green;
+ color->blue = request->blue;
+ XStoreColors(dpy, cmap, color, 1);
+ return 1;
+}
+
+
+/****************************************************************************/
+static int
+compare(_Xconst void *e1, _Xconst void *e2)
+{
+ return ((int)(*(long *)e1 - *(long *)e2));
+}
+
+
+/****************************************************************************/
+static Status
+readonly_map(Display *dpy, XVisualInfo *vinfo, XStandardColormap *colormap)
+{
+ int i, last_pixel;
+ XColor color;
+
+ last_pixel = (colormap->red_max + 1) * (colormap->green_max + 1) *
+ (colormap->blue_max + 1) + colormap->base_pixel - 1;
+
+ for(i=colormap->base_pixel; i <= last_pixel; i++) {
+
+ color.pixel = (unsigned long) i;
+ color.red = (unsigned short)
+ (((i/colormap->red_mult) * 65535) / colormap->red_max);
+
+ if (vinfo->class == StaticColor) {
+ color.green = (unsigned short)
+ ((((i/colormap->green_mult) % (colormap->green_max + 1)) *
+ 65535) / colormap->green_max);
+ color.blue = (unsigned short)
+ (((i%colormap->green_mult) * 65535) / colormap->blue_max);
+ }
+ else /* vinfo->class == GrayScale, old style allocation XXX */
+ color.green = color.blue = color.red;
+
+ XAllocColor(dpy, colormap->colormap, &color);
+ if (color.pixel != (unsigned long) i)
+ return 0;
+ }
+ return 1;
+}
diff --git a/nx-X11/lib/Xmu/CrPixFBit.c b/nx-X11/lib/Xmu/CrPixFBit.c
new file mode 100644
index 000000000..c7ff6caf2
--- /dev/null
+++ b/nx-X11/lib/Xmu/CrPixFBit.c
@@ -0,0 +1,85 @@
+/* $Xorg: CrPixFBit.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/CrPixFBit.c,v 1.6 2001/01/17 19:42:53 dawes Exp $ */
+
+/*
+ * This file contains miscellaneous utility routines and is not part of the
+ * Xlib standard.
+ */
+
+/*
+ * Public entry points:
+ *
+ * XmuCreatePixmapFromBitmap make a pixmap from a bitmap
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/Xmu/Drawing.h>
+
+Pixmap
+XmuCreatePixmapFromBitmap(Display *dpy, Drawable d, Pixmap bitmap,
+ unsigned int width, unsigned int height,
+ unsigned int depth,
+ unsigned long fore, unsigned long back)
+ /*
+ * dpy - connection to X server
+ * d - drawable indicating screen
+ * bitmap - single plane pixmap
+ * width, height - dimensions of bitmap and pixmap
+ * depth - depth of pixmap to create
+ * fore, back - colors to use
+ */
+{
+ Pixmap pixmap;
+
+ pixmap = XCreatePixmap (dpy, d, width, height, depth);
+ if (pixmap != None) {
+ GC gc;
+ XGCValues xgcv;
+
+ xgcv.foreground = fore;
+ xgcv.background = back;
+ xgcv.graphics_exposures = False;
+
+ gc = XCreateGC (dpy, d,
+ (GCForeground | GCBackground | GCGraphicsExposures),
+ &xgcv);
+ if (gc) {
+ XCopyPlane (dpy, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1);
+ XFreeGC (dpy, gc);
+ } else {
+ XFreePixmap (dpy, pixmap);
+ pixmap = None;
+ }
+ }
+ return pixmap;
+}
diff --git a/nx-X11/lib/Xmu/CurUtil.h b/nx-X11/lib/Xmu/CurUtil.h
new file mode 100644
index 000000000..27ab18848
--- /dev/null
+++ b/nx-X11/lib/Xmu/CurUtil.h
@@ -0,0 +1,49 @@
+/* $Xorg: CurUtil.h,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/CurUtil.h,v 1.5 2001/01/17 19:42:54 dawes Exp $ */
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_CURUTIL_H_
+#define _XMU_CURUTIL_H_
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+int XmuCursorNameToIndex
+(
+ _Xconst char *name
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_CURUTIL_H_ */
diff --git a/nx-X11/lib/Xmu/CursorName.c b/nx-X11/lib/Xmu/CursorName.c
new file mode 100644
index 000000000..17f390246
--- /dev/null
+++ b/nx-X11/lib/Xmu/CursorName.c
@@ -0,0 +1,141 @@
+/* $Xorg: CursorName.c,v 1.4 2001/02/09 02:03:51 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/CursorName.c,v 3.7tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/CurUtil.h>
+#include <X11/cursorfont.h>
+#include <string.h>
+
+int
+XmuCursorNameToIndex(_Xconst char *name)
+{
+ static _Xconst struct _CursorName {
+ _Xconst char *name;
+ unsigned int shape;
+ } cursor_names[] = {
+ {"x_cursor", XC_X_cursor},
+ {"arrow", XC_arrow},
+ {"based_arrow_down", XC_based_arrow_down},
+ {"based_arrow_up", XC_based_arrow_up},
+ {"boat", XC_boat},
+ {"bogosity", XC_bogosity},
+ {"bottom_left_corner", XC_bottom_left_corner},
+ {"bottom_right_corner", XC_bottom_right_corner},
+ {"bottom_side", XC_bottom_side},
+ {"bottom_tee", XC_bottom_tee},
+ {"box_spiral", XC_box_spiral},
+ {"center_ptr", XC_center_ptr},
+ {"circle", XC_circle},
+ {"clock", XC_clock},
+ {"coffee_mug", XC_coffee_mug},
+ {"cross", XC_cross},
+ {"cross_reverse", XC_cross_reverse},
+ {"crosshair", XC_crosshair},
+ {"diamond_cross", XC_diamond_cross},
+ {"dot", XC_dot},
+ {"dotbox", XC_dotbox},
+ {"double_arrow", XC_double_arrow},
+ {"draft_large", XC_draft_large},
+ {"draft_small", XC_draft_small},
+ {"draped_box", XC_draped_box},
+ {"exchange", XC_exchange},
+ {"fleur", XC_fleur},
+ {"gobbler", XC_gobbler},
+ {"gumby", XC_gumby},
+ {"hand1", XC_hand1},
+ {"hand2", XC_hand2},
+ {"heart", XC_heart},
+ {"icon", XC_icon},
+ {"iron_cross", XC_iron_cross},
+ {"left_ptr", XC_left_ptr},
+ {"left_side", XC_left_side},
+ {"left_tee", XC_left_tee},
+ {"leftbutton", XC_leftbutton},
+ {"ll_angle", XC_ll_angle},
+ {"lr_angle", XC_lr_angle},
+ {"man", XC_man},
+ {"middlebutton", XC_middlebutton},
+ {"mouse", XC_mouse},
+ {"pencil", XC_pencil},
+ {"pirate", XC_pirate},
+ {"plus", XC_plus},
+ {"question_arrow", XC_question_arrow},
+ {"right_ptr", XC_right_ptr},
+ {"right_side", XC_right_side},
+ {"right_tee", XC_right_tee},
+ {"rightbutton", XC_rightbutton},
+ {"rtl_logo", XC_rtl_logo},
+ {"sailboat", XC_sailboat},
+ {"sb_down_arrow", XC_sb_down_arrow},
+ {"sb_h_double_arrow", XC_sb_h_double_arrow},
+ {"sb_left_arrow", XC_sb_left_arrow},
+ {"sb_right_arrow", XC_sb_right_arrow},
+ {"sb_up_arrow", XC_sb_up_arrow},
+ {"sb_v_double_arrow", XC_sb_v_double_arrow},
+ {"shuttle", XC_shuttle},
+ {"sizing", XC_sizing},
+ {"spider", XC_spider},
+ {"spraycan", XC_spraycan},
+ {"star", XC_star},
+ {"target", XC_target},
+ {"tcross", XC_tcross},
+ {"top_left_arrow", XC_top_left_arrow},
+ {"top_left_corner", XC_top_left_corner},
+ {"top_right_corner", XC_top_right_corner},
+ {"top_side", XC_top_side},
+ {"top_tee", XC_top_tee},
+ {"trek", XC_trek},
+ {"ul_angle", XC_ul_angle},
+ {"umbrella", XC_umbrella},
+ {"ur_angle", XC_ur_angle},
+ {"watch", XC_watch},
+ {"xterm", XC_xterm},
+ };
+#define NUM_CURSOR_NAMES (sizeof (cursor_names) / sizeof (cursor_names[0]))
+ register _Xconst struct _CursorName *table;
+ register int i;
+ char tmp[40];
+
+ if (strlen (name) >= sizeof tmp) return -1;
+ XmuCopyISOLatin1Lowered (tmp, name);
+
+ for (i=0, table=cursor_names; i < NUM_CURSOR_NAMES; i++, table++ ) {
+ if (strcmp(tmp, table->name) == 0) return table->shape;
+ }
+
+ return -1;
+}
+
+
+
+
+
diff --git a/nx-X11/lib/Xmu/CvtCache.c b/nx-X11/lib/Xmu/CvtCache.c
new file mode 100644
index 000000000..8dd4602ea
--- /dev/null
+++ b/nx-X11/lib/Xmu/CvtCache.c
@@ -0,0 +1,136 @@
+/* $Xorg: CvtCache.c,v 1.5 2001/02/09 02:03:52 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/CvtCache.c,v 3.6 2001/08/23 00:03:21 dawes Exp $ */
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xos.h>
+#include <X11/Xmu/CvtCache.h>
+#include <stdlib.h>
+
+/*
+ * Prototypes
+ */
+static int _CloseDisplay(XmuDisplayQueue*, XmuDisplayQueueEntry*);
+static int _FreeCCDQ(XmuDisplayQueue*);
+static void _InitializeCvtCache(XmuCvtCache*);
+
+/*
+ * Initialization
+ */
+static XmuDisplayQueue *dq = NULL;
+
+
+/*
+ * internal utility callbacks
+ */
+
+static int
+_FreeCCDQ(XmuDisplayQueue *q)
+{
+ XmuDQDestroy (dq, False);
+ dq = NULL;
+ return (0);
+}
+
+
+static int
+_CloseDisplay(XmuDisplayQueue *q, XmuDisplayQueueEntry *e)
+{
+ XmuCvtCache *c;
+
+ if (e && (c = (XmuCvtCache *)(e->data))) {
+ _XmuStringToBitmapFreeCache (c);
+ /* insert calls to free any cached memory */
+
+ }
+ return 0;
+}
+
+static void
+_InitializeCvtCache(register XmuCvtCache *c)
+{
+ _XmuStringToBitmapInitCache (c);
+ /* insert calls to init any cached memory */
+}
+
+
+/*
+ * XmuCCLookupDisplay - return the cache entry for the indicated display;
+ * initialize the cache if necessary
+ */
+XmuCvtCache *
+_XmuCCLookupDisplay(Display *dpy)
+{
+ XmuDisplayQueueEntry *e;
+
+ /*
+ * If no displays have been added before this, create the display queue.
+ */
+ if (!dq) {
+ dq = XmuDQCreate (_CloseDisplay, _FreeCCDQ, NULL);
+ if (!dq) return NULL;
+ }
+
+ /*
+ * See if the display is already there
+ */
+ e = XmuDQLookupDisplay (dq, dpy); /* see if it's there */
+ if (!e) { /* else create it */
+ XmuCvtCache *c = (XmuCvtCache *) malloc (sizeof (XmuCvtCache));
+ if (!c) return NULL;
+
+ /*
+ * Add the display to the queue
+ */
+ e = XmuDQAddDisplay (dq, dpy, (XPointer) c);
+ if (!e) {
+ free ((char *) c);
+ return NULL;
+ }
+
+ /*
+ * initialize fields in cache
+ */
+ _InitializeCvtCache (c);
+ }
+
+ /*
+ * got it
+ */
+ return (XmuCvtCache *)(e->data);
+}
+
+
diff --git a/nx-X11/lib/Xmu/CvtCache.h b/nx-X11/lib/Xmu/CvtCache.h
new file mode 100644
index 000000000..d9b967ab7
--- /dev/null
+++ b/nx-X11/lib/Xmu/CvtCache.h
@@ -0,0 +1,62 @@
+/* $Xorg: CvtCache.h,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/CvtCache.h,v 1.6 2001/01/17 19:42:54 dawes Exp $ */
+
+/*
+ * Public Interfaces
+ *
+ * XmuCvtCache *XmuCvtCacheLookupDisplay (dpy)
+ * Display *dpy;
+ */
+
+#ifndef _XMU_CVTCACHE_H_
+#define _XMU_CVTCACHE_H_
+
+#include <X11/Xmu/DisplayQue.h>
+#include <X11/Xfuncproto.h>
+
+typedef struct _XmuCvtCache {
+ struct {
+ char **bitmapFilePath;
+ } string_to_bitmap;
+ /* add other per-display data that needs to be cached */
+} XmuCvtCache;
+
+_XFUNCPROTOBEGIN
+
+XmuCvtCache *_XmuCCLookupDisplay
+(
+ Display *dpy
+ );
+
+extern void _XmuStringToBitmapInitCache(XmuCvtCache *c);
+extern void _XmuStringToBitmapFreeCache(XmuCvtCache *c);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_CVTCACHE_H_ */
diff --git a/nx-X11/lib/Xmu/CvtStdSel.c b/nx-X11/lib/Xmu/CvtStdSel.c
new file mode 100644
index 000000000..e52197f13
--- /dev/null
+++ b/nx-X11/lib/Xmu/CvtStdSel.c
@@ -0,0 +1,347 @@
+/* $Xorg: CvtStdSel.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
+/* $XdotOrg: xc/lib/Xmu/CvtStdSel.c,v 1.6 2005/07/03 07:00:57 daniels Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/CvtStdSel.c,v 3.19 2001/11/21 16:22:59 tsi Exp $ */
+
+/*
+ * This file contains routines to handle common selection targets.
+ *
+ * Public entry points:
+ *
+ * XmuConvertStandardSelection() return a known selection
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef SYSVNET
+#include <interlan/il_types.h>
+#define __TYPES__ /* prevent #include <sys/types.h> in Xlib.h */
+#include <interlan/netdb.h>
+#include <interlan/socket.h>
+#endif /* SYSVNET */
+
+#include <X11/IntrinsicP.h>
+#include <X11/Xatom.h>
+#include <X11/ShellP.h>
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+#include <stdio.h>
+
+#ifndef SYSVNET
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#define XOS_USE_MTSAFE_NETDBAPI
+#else
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <sys/types.h>
+#include <socket.h>
+#endif
+#define XOS_USE_XT_LOCKING
+#endif
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+#endif
+
+#include <X11/Xos.h>
+#include <stdlib.h>
+#include "Atoms.h"
+#include "StdSel.h"
+#include "SysUtil.h"
+#include <X11/Xfuncs.h>
+
+#ifndef OS_NAME
+#ifndef X_OS_FILE
+#ifdef SYSV /* keep separate until makedepend fixed */
+#define USE_UNAME
+#endif
+#ifdef SVR4
+#define USE_UNAME
+#endif
+#ifdef ultrix
+#define USE_UNAME
+#endif
+#ifdef CSRG_BASED
+#define USE_UNAME
+#endif
+#endif /*X_OS_FILE*/
+#ifdef USE_UNAME
+#include <sys/utsname.h>
+#endif
+#endif
+
+/*
+ * Prototypes
+ */
+static char *get_os_name(void);
+static Bool isApplicationShell(Widget);
+
+/*
+ * Implementation
+ */
+static char *
+get_os_name(void)
+{
+#ifdef OS_NAME
+ return XtNewString(OS_NAME);
+#else
+ FILE *f = NULL;
+
+#ifdef USE_UNAME
+ struct utsname utss;
+
+ if (uname (&utss) >= 0) {
+ char *os_name;
+ int len = strlen(utss.sysname) + 1;
+#ifndef hpux /* because of hostname length crock */
+ len += 2 + strlen(utss.release);
+#endif
+ os_name = XtMalloc (len);
+ strcpy (os_name, utss.sysname);
+#ifndef hpux
+ strcat (os_name, " ");
+ strcat (os_name, utss.release);
+#endif
+ return os_name;
+ }
+#endif
+
+#ifdef X_OS_FILE
+ f = fopen(X_OS_FILE, "r");
+ if (!f)
+#endif
+#ifdef MOTD_FILE
+ f = fopen(MOTD_FILE, "r");
+#endif
+ if (f) {
+ char motd[512];
+ motd[0] = '\0';
+ (void) fgets(motd, 511, f);
+ fclose(f);
+ motd[511] = '\0';
+ if (motd[0] != '\0') {
+ int len = strlen(motd);
+ if (motd[len - 1] == '\n')
+ motd[len - 1] = '\0';
+ return XtNewString(motd);
+ }
+ }
+
+#ifdef sun
+ return XtNewString("SunOS");
+#else
+# if !defined(SYSV) && (defined(CSRG_BASED) || defined(unix))
+ return XtNewString("BSD");
+# else
+ return NULL;
+# endif
+#endif
+
+#endif /*OS_NAME*/
+}
+
+/* This is a trick/kludge. To make shared libraries happier (linking
+ * against Xmu but not linking against Xt, and apparently even work
+ * as we desire on SVR4, we need to avoid an explicit data reference
+ * to applicationShellWidgetClass. XtIsTopLevelShell is known
+ * (implementation dependent assumption!) to use a bit flag. So we
+ * go that far. Then, we test whether it is an applicationShellWidget
+ * class by looking for an explicit class name. Seems pretty safe.
+ */
+static Bool
+isApplicationShell(Widget w)
+{
+ register WidgetClass c;
+
+ if (!XtIsTopLevelShell(w))
+ return False;
+ for (c = XtClass(w); c; c = c->core_class.superclass) {
+ if (!strcmp(c->core_class.class_name, "ApplicationShell"))
+ return True;
+ }
+ return False;
+}
+
+Boolean
+XmuConvertStandardSelection(Widget w, Time time, Atom *selection, Atom *target,
+ Atom *type, XPointer *value,
+ unsigned long *length, int *format)
+{
+ Display *d = XtDisplay(w);
+ if (*target == XA_TIMESTAMP(d)) {
+ *value = XtMalloc(4);
+ if (sizeof(long) == 4)
+ *(long*)*value = time;
+ else {
+ long temp = time;
+ (void) memmove((char*)*value, ((char*)&temp)+sizeof(long)-4, 4);
+ }
+ *type = XA_INTEGER;
+ *length = 1;
+ *format = 32;
+ return True;
+ }
+ if (*target == XA_HOSTNAME(d)) {
+ char hostname[1024];
+ hostname[0] = '\0';
+ *length = XmuGetHostname (hostname, sizeof hostname);
+ *value = XtNewString(hostname);
+ *type = XA_STRING;
+ *format = 8;
+ return True;
+ }
+#if defined(TCPCONN)
+ if (*target == XA_IP_ADDRESS(d)) {
+ char hostname[1024];
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ struct hostent *hostp;
+
+ hostname[0] = '\0';
+ (void) XmuGetHostname (hostname, sizeof hostname);
+
+ if ((hostp = _XGethostbyname (hostname,hparams)) == NULL)
+ return False;
+
+ if (hostp->h_addrtype != AF_INET) return False;
+ *length = hostp->h_length;
+ *value = XtMalloc(*length);
+ (void) memmove (*value, hostp->h_addr, *length);
+ *type = XA_NET_ADDRESS(d);
+ *format = 8;
+ return True;
+ }
+#endif
+#ifdef DNETCONN
+ if (*target == XA_DECNET_ADDRESS(d)) {
+ return False; /* XXX niy */
+ }
+#endif
+ if (*target == XA_USER(d)) {
+ char *name = (char*)getenv("USER");
+ if (name == NULL) return False;
+ *value = XtNewString(name);
+ *type = XA_STRING;
+ *length = strlen(name);
+ *format = 8;
+ return True;
+ }
+ if (*target == XA_CLASS(d)) {
+ Widget parent = XtParent(w);
+ char *class;
+ int len;
+ while (parent != NULL && !isApplicationShell(w)) {
+ w = parent;
+ parent = XtParent(w);
+ }
+ if (isApplicationShell(w))
+ class = ((ApplicationShellWidget) w)->application.class;
+ else
+ class = XtClass(w)->core_class.class_name;
+ *length = (len=strlen(w->core.name)) + strlen(class) + 2;
+ *value = XtMalloc(*length);
+ strcpy( (char*)*value, w->core.name );
+ strcpy( (char*)*value+len+1, class );
+ *type = XA_STRING;
+ *format = 8;
+ return True;
+ }
+ if (*target == XA_NAME(d)) {
+ Widget parent = XtParent(w);
+
+ while (parent != NULL && !XtIsWMShell(w)) {
+ w = parent;
+ parent = XtParent(w);
+ }
+ if (!XtIsWMShell(w)) return False;
+ *value = XtNewString( ((WMShellWidget) w)->wm.title );
+ *length = strlen(*value);
+ *type = XA_STRING;
+ *format = 8;
+ return True;
+ }
+ if (*target == XA_CLIENT_WINDOW(d)) {
+ Widget parent = XtParent(w);
+ while (parent != NULL) {
+ w = parent;
+ parent = XtParent(w);
+ }
+ *value = XtMalloc(sizeof(Window));
+ *(Window*)*value = w->core.window;
+ *type = XA_WINDOW;
+ *length = 1;
+ *format = 32;
+ return True;
+ }
+ if (*target == XA_OWNER_OS(d)) {
+ *value = get_os_name();
+ if (*value == NULL) return False;
+ *type = XA_STRING;
+ *length = strlen(*value);
+ *format = 8;
+ return True;
+ }
+ if (*target == XA_TARGETS(d)) {
+#if defined(unix) && defined(DNETCONN)
+# define NUM_TARGETS 9
+#else
+# if defined(unix) || defined(DNETCONN)
+# define NUM_TARGETS 8
+# else
+# define NUM_TARGETS 7
+# endif
+#endif
+ Atom* std_targets = (Atom*)XtMalloc(NUM_TARGETS*sizeof(Atom));
+ int i = 0;
+ std_targets[i++] = XA_TIMESTAMP(d);
+ std_targets[i++] = XA_HOSTNAME(d);
+ std_targets[i++] = XA_IP_ADDRESS(d);
+ std_targets[i++] = XA_USER(d);
+ std_targets[i++] = XA_CLASS(d);
+ std_targets[i++] = XA_NAME(d);
+ std_targets[i++] = XA_CLIENT_WINDOW(d);
+#ifdef unix
+ std_targets[i++] = XA_OWNER_OS(d);
+#endif
+#ifdef DNETCONN
+ std_targets[i++] = XA_DECNET_ADDRESS(d);
+#endif
+ *value = (XPointer)std_targets;
+ *type = XA_ATOM;
+ *length = NUM_TARGETS;
+ *format = 32;
+ return True;
+ }
+ /* else */
+ return False;
+}
diff --git a/nx-X11/lib/Xmu/DefErrMsg.c b/nx-X11/lib/Xmu/DefErrMsg.c
new file mode 100644
index 000000000..d1aa9ad9a
--- /dev/null
+++ b/nx-X11/lib/Xmu/DefErrMsg.c
@@ -0,0 +1,173 @@
+/* $Xorg: DefErrMsg.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/DefErrMsg.c,v 1.7 2001/01/17 19:42:54 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#define NEED_EVENTS
+#include <X11/Xlibint.h>
+#include <X11/Xproto.h>
+#include <X11/Xmu/Error.h>
+#include <X11/Xmu/SysUtil.h>
+
+/*
+ * XmuPrintDefaultErrorMessage - print a nice error that looks like the usual
+ * message. Returns 1 if the caller should consider exitting else 0.
+ */
+int
+XmuPrintDefaultErrorMessage(Display *dpy, XErrorEvent *event, FILE *fp)
+{
+ char buffer[BUFSIZ];
+ char mesg[BUFSIZ];
+ char number[32];
+ char *mtype = "XlibMessage";
+ register _XExtension *ext = (_XExtension *)NULL;
+ _XExtension *bext = (_XExtension *)NULL;
+ XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
+ XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
+ (void) fprintf(fp, "%s: %s\n ", mesg, buffer);
+ XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->request_code);
+ if (event->request_code < 128) {
+ XmuSnprintf(number, sizeof(number), "%d", event->request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
+ } else {
+ /* XXX this is non-portable */
+ for (ext = dpy->ext_procs;
+ ext && (ext->codes.major_opcode != event->request_code);
+ ext = ext->next)
+ ;
+ if (ext)
+ XmuSnprintf(buffer, sizeof(buffer), "%s", ext->name);
+ else
+ buffer[0] = '\0';
+ }
+ (void) fprintf(fp, " (%s)", buffer);
+ fputs("\n ", fp);
+ if (event->request_code >= 128) {
+ XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->minor_code);
+ if (ext) {
+ XmuSnprintf(mesg, sizeof(mesg),
+ "%s.%d", ext->name, event->minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
+ (void) fprintf(fp, " (%s)", buffer);
+ }
+ fputs("\n ", fp);
+ }
+ if (event->error_code >= 128) {
+ /* kludge, try to find the extension that caused it */
+ buffer[0] = '\0';
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_string)
+ (*ext->error_string)(dpy, event->error_code, &ext->codes,
+ buffer, BUFSIZ);
+ if (buffer[0]) {
+ bext = ext;
+ break;
+ }
+ if (ext->codes.first_error &&
+ ext->codes.first_error < event->error_code &&
+ (!bext || ext->codes.first_error > bext->codes.first_error))
+ bext = ext;
+ }
+ if (bext)
+ XmuSnprintf(buffer, sizeof(buffer), "%s.%d", bext->name,
+ event->error_code - bext->codes.first_error);
+ else
+ strcpy(buffer, "Value");
+ XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
+ if (mesg[0]) {
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ /* let extensions try to print the values */
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_values)
+ (*ext->error_values)(dpy, event, fp);
+ }
+ } else if ((event->error_code == BadWindow) ||
+ (event->error_code == BadPixmap) ||
+ (event->error_code == BadCursor) ||
+ (event->error_code == BadFont) ||
+ (event->error_code == BadDrawable) ||
+ (event->error_code == BadColor) ||
+ (event->error_code == BadGC) ||
+ (event->error_code == BadIDChoice) ||
+ (event->error_code == BadValue) ||
+ (event->error_code == BadAtom)) {
+ if (event->error_code == BadValue)
+ XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
+ mesg, BUFSIZ);
+ else if (event->error_code == BadAtom)
+ XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
+ mesg, BUFSIZ);
+ else
+ XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n ", fp);
+ }
+ XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->serial);
+ fputs("\n ", fp);
+ XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, NextRequest(dpy)-1);
+ fputs("\n", fp);
+ if (event->error_code == BadImplementation) return 0;
+ return 1;
+}
+
+
+/*
+ * XmuSimpleErrorHandler - ignore errors for XQueryTree, XGetWindowAttributes,
+ * and XGetGeometry; print a message for everything else. In all case, do
+ * not exit.
+ */
+int
+XmuSimpleErrorHandler(Display *dpy, XErrorEvent *errorp)
+{
+ switch (errorp->request_code) {
+ case X_QueryTree:
+ case X_GetWindowAttributes:
+ if (errorp->error_code == BadWindow) return 0;
+ break;
+ case X_GetGeometry:
+ if (errorp->error_code == BadDrawable) return 0;
+ break;
+ }
+ /* got a "real" X error */
+ return XmuPrintDefaultErrorMessage (dpy, errorp, stderr);
+}
diff --git a/nx-X11/lib/Xmu/DelCmap.c b/nx-X11/lib/Xmu/DelCmap.c
new file mode 100644
index 000000000..1f2c6abe8
--- /dev/null
+++ b/nx-X11/lib/Xmu/DelCmap.c
@@ -0,0 +1,73 @@
+/* $Xorg: DelCmap.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/DelCmap.c,v 1.6 2001/01/17 19:42:54 dawes Exp $ */
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+/* To remove any standard colormap property, use XmuDeleteStandardColormap().
+ * XmuDeleteStandardColormap() will remove the specified property from the
+ * specified screen, releasing any resources used by the colormap(s) of the
+ * property if possible.
+ */
+
+void
+XmuDeleteStandardColormap(Display *dpy, int screen, Atom property)
+ /* dpy; - specifies the X server to connect to
+ * screen - specifies the screen of the display
+ * property - specifies the standard colormap property
+ */
+{
+ XStandardColormap *stdcmaps, *s;
+ int count = 0;
+
+ if (XGetRGBColormaps(dpy, RootWindow(dpy, screen), &stdcmaps, &count,
+ property))
+ {
+ for (s=stdcmaps; count > 0; count--, s++) {
+ if ((s->killid == ReleaseByFreeingColormap) &&
+ (s->colormap != None) &&
+ (s->colormap != DefaultColormap(dpy, screen)))
+ XFreeColormap(dpy, s->colormap);
+ else if (s->killid != None)
+ XKillClient(dpy, s->killid);
+ }
+ XDeleteProperty(dpy, RootWindow(dpy, screen), property);
+ XFree((char *) stdcmaps);
+ XSync(dpy, False);
+ }
+}
+
diff --git a/nx-X11/lib/Xmu/DisplayQue.c b/nx-X11/lib/Xmu/DisplayQue.c
new file mode 100644
index 000000000..ae9f92e1d
--- /dev/null
+++ b/nx-X11/lib/Xmu/DisplayQue.c
@@ -0,0 +1,194 @@
+/* $Xorg: DisplayQue.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/DisplayQue.c,v 3.4 2001/07/25 15:04:50 dawes Exp $ */
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <stdlib.h>
+#include <X11/Xmu/DisplayQue.h>
+
+/*
+ * Prototypes
+ */
+static int _DQCloseDisplay(Display*, XPointer);
+
+#define CallCloseCallback(q,e) (void) (*((q)->closefunc)) ((q), (e))
+#define CallFreeCallback(q) (void) (*((q)->freefunc)) ((q))
+
+/*
+ * XmuDQCreate - create a display queue
+ */
+XmuDisplayQueue *
+XmuDQCreate(XmuCloseDisplayQueueProc closefunc,
+ XmuFreeDisplayQueueProc freefunc,
+ XPointer data)
+{
+ XmuDisplayQueue *q = (XmuDisplayQueue *) malloc (sizeof (XmuDisplayQueue));
+ if (q) {
+ q->nentries = 0;
+ q->head = q->tail = NULL;
+ q->closefunc = closefunc;
+ q->freefunc = freefunc;
+ q->data = data;
+ }
+ return q;
+}
+
+
+/*
+ * XmuDQDestroy - free all storage associated with this display queue,
+ * optionally invoking the close callbacks.
+ */
+
+Bool
+XmuDQDestroy(XmuDisplayQueue *q, Bool docallbacks)
+{
+ XmuDisplayQueueEntry *e = q->head;
+
+ while (e) {
+ XmuDisplayQueueEntry *nexte = e->next;
+ if (docallbacks && q->closefunc) CallCloseCallback (q, e);
+ free ((char *) e);
+ e = nexte;
+ }
+ free ((char *) q);
+ return True;
+}
+
+
+/*
+ * XmuDQLookupDisplay - finds the indicated display on the given queue
+ */
+XmuDisplayQueueEntry *
+XmuDQLookupDisplay(XmuDisplayQueue *q, Display *dpy)
+{
+ XmuDisplayQueueEntry *e;
+
+ for (e = q->head; e; e = e->next) {
+ if (e->display == dpy) return e;
+ }
+ return NULL;
+}
+
+
+/*
+ * XmuDQAddDisplay - add the specified display to the queue; set data as a
+ * convenience. Does not ensure that dpy hasn't already been added.
+ */
+XmuDisplayQueueEntry *
+XmuDQAddDisplay(XmuDisplayQueue *q, Display *dpy, XPointer data)
+{
+ XmuDisplayQueueEntry *e;
+
+ if (!(e = (XmuDisplayQueueEntry *) malloc (sizeof (XmuDisplayQueueEntry)))) {
+ return NULL;
+ }
+ if (!(e->closehook = XmuAddCloseDisplayHook (dpy, _DQCloseDisplay,
+ (XPointer) q))) {
+ free ((char *) e);
+ return NULL;
+ }
+
+ e->display = dpy;
+ e->next = NULL;
+ e->data = data;
+
+ if (q->tail) {
+ q->tail->next = e;
+ e->prev = q->tail;
+ } else {
+ q->head = e;
+ e->prev = NULL;
+ }
+ q->tail = e;
+ q->nentries++;
+ return e;
+}
+
+
+/*
+ * XmuDQRemoveDisplay - remove the specified display from the queue
+ */
+Bool
+XmuDQRemoveDisplay(XmuDisplayQueue *q, Display *dpy)
+{
+ XmuDisplayQueueEntry *e;
+
+ for (e = q->head; e; e = e->next) {
+ if (e->display == dpy) {
+ if (q->head == e)
+ q->head = e->next; /* if at head, then bump head */
+ else
+ e->prev->next = e->next; /* else splice out */
+ if (q->tail == e)
+ q->tail = e->prev; /* if at tail, then bump tail */
+ else
+ e->next->prev = e->prev; /* else splice out */
+ (void) XmuRemoveCloseDisplayHook (dpy, e->closehook,
+ _DQCloseDisplay, (XPointer) q);
+ free ((char *) e);
+ q->nentries--;
+ return True;
+ }
+ }
+ return False;
+}
+
+
+/*****************************************************************************
+ * private functions *
+ *****************************************************************************/
+
+/*
+ * _DQCloseDisplay - upcalled from CloseHook to notify this queue; remove the
+ * display when finished
+ */
+static int
+_DQCloseDisplay(Display *dpy, XPointer arg)
+{
+ XmuDisplayQueue *q = (XmuDisplayQueue *) arg;
+ XmuDisplayQueueEntry *e;
+
+ for (e = q->head; e; e = e->next) {
+ if (e->display == dpy) {
+ if (q->closefunc) CallCloseCallback (q, e);
+ (void) XmuDQRemoveDisplay (q, dpy);
+ if (q->nentries == 0 && q->freefunc) CallFreeCallback (q);
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/nx-X11/lib/Xmu/DisplayQue.h b/nx-X11/lib/Xmu/DisplayQue.h
new file mode 100644
index 000000000..9f9013c1e
--- /dev/null
+++ b/nx-X11/lib/Xmu/DisplayQue.h
@@ -0,0 +1,155 @@
+/* $Xorg: DisplayQue.h,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/DisplayQue.h,v 1.5 2001/01/17 19:42:54 dawes Exp $ */
+
+#ifndef _XMU_DISPLAYQUE_H_
+#define _XMU_DISPLAYQUE_H_
+
+#include <X11/Xmu/CloseHook.h>
+#include <X11/Xfuncproto.h>
+
+/*
+ * Public Entry Points
+ *
+ *
+ * XmuDisplayQueue *XmuDQCreate (closefunc, freefunc, data)
+ * XmuCloseDisplayQueueProc closefunc;
+ * XmuFreeDisplayQueueProc freefunc;
+ * XPointer data;
+ *
+ * Creates and returns a queue into which displays may be placed. When
+ * the display is closed, the closefunc (if non-NULL) is upcalled with
+ * as follows:
+ *
+ * (*closefunc) (queue, entry)
+ *
+ * The freeproc, if non-NULL, is called whenever the last display is
+ * closed, notifying the creator that display queue may be released
+ * using XmuDQDestroy.
+ *
+ *
+ * Bool XmuDQDestroy (q, docallbacks)
+ * XmuDisplayQueue *q;
+ * Bool docallbacks;
+ *
+ * Releases all memory for the indicated display queue. If docallbacks
+ * is true, then the closefunc (if non-NULL) is called for each
+ * display.
+ *
+ *
+ * XmuDisplayQueueEntry *XmuDQLookupDisplay (q, dpy)
+ * XmuDisplayQueue *q;
+ * Display *dpy;
+ *
+ * Returns the queue entry for the specified display or NULL if the
+ * display is not in the queue.
+ *
+ *
+ * XmuDisplayQueueEntry *XmuDQAddDisplay (q, dpy, data)
+ * XmuDisplayQueue *q;
+ * Display *dpy;
+ * XPointer data;
+ *
+ * Adds the indicated display to the end of the queue or NULL if it
+ * is unable to allocate memory. The data field may be used by the
+ * caller to attach arbitrary data to this display in this queue. The
+ * caller should use XmuDQLookupDisplay to make sure that the display
+ * hasn't already been added.
+ *
+ *
+ * Bool XmuDQRemoveDisplay (q, dpy)
+ * XmuDisplayQueue *q;
+ * Display *dpy;
+ *
+ * Removes the specified display from the given queue. If the
+ * indicated display is not found on this queue, False is returned,
+ * otherwise True is returned.
+ */
+
+typedef struct _XmuDisplayQueue XmuDisplayQueue;
+typedef struct _XmuDisplayQueueEntry XmuDisplayQueueEntry;
+
+typedef int (*XmuCloseDisplayQueueProc)(XmuDisplayQueue *queue,
+ XmuDisplayQueueEntry *entry);
+
+typedef int (*XmuFreeDisplayQueueProc)(XmuDisplayQueue *queue);
+
+struct _XmuDisplayQueueEntry {
+ struct _XmuDisplayQueueEntry *prev, *next;
+ Display *display;
+ CloseHook closehook;
+ XPointer data;
+};
+
+struct _XmuDisplayQueue {
+ int nentries;
+ XmuDisplayQueueEntry *head, *tail;
+ XmuCloseDisplayQueueProc closefunc;
+ XmuFreeDisplayQueueProc freefunc;
+ XPointer data;
+};
+
+_XFUNCPROTOBEGIN
+
+XmuDisplayQueue *XmuDQCreate
+(
+ XmuCloseDisplayQueueProc closefunc,
+ XmuFreeDisplayQueueProc freefunc,
+ XPointer data
+ );
+
+Bool XmuDQDestroy
+(
+ XmuDisplayQueue *q,
+ Bool docallbacks
+ );
+
+XmuDisplayQueueEntry *XmuDQLookupDisplay
+(
+ XmuDisplayQueue *q,
+ Display *dpy
+ );
+
+XmuDisplayQueueEntry *XmuDQAddDisplay
+(
+ XmuDisplayQueue *q,
+ Display *dpy,
+ XPointer data
+ );
+
+Bool XmuDQRemoveDisplay
+(
+ XmuDisplayQueue *q,
+ Display *dpy
+ );
+
+_XFUNCPROTOEND
+
+#define XmuDQNDisplays(q) ((q)->nentries)
+
+#endif /* _XMU_DISPLAYQUE_H_ */
diff --git a/nx-X11/lib/Xmu/Distinct.c b/nx-X11/lib/Xmu/Distinct.c
new file mode 100644
index 000000000..f00b00b5a
--- /dev/null
+++ b/nx-X11/lib/Xmu/Distinct.c
@@ -0,0 +1,92 @@
+/* $Xorg: Distinct.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/Distinct.c,v 3.5 2001/07/25 15:04:50 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <stdlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+/*
+ * Distinguishable colors routine. Determines if two colors are
+ * distinguishable or not. Somewhat arbitrary meaning.
+ */
+
+#define MIN_DISTINGUISH 10000.0
+
+Bool
+XmuDistinguishableColors(XColor *colors, int count)
+{
+ double deltaRed, deltaGreen, deltaBlue;
+ double dist;
+ int i, j;
+
+ for (i = 0; i < count - 1; i++)
+ for (j = i + 1; j < count; j++)
+ {
+ deltaRed = (double)colors[i].red - (double)colors[j].red;
+ deltaGreen = (double)colors[i].green - (double)colors[j].green;
+ deltaBlue = (double)colors[i].blue - (double)colors[j].blue;
+ dist = deltaRed * deltaRed +
+ deltaGreen * deltaGreen +
+ deltaBlue * deltaBlue;
+ if (dist <= MIN_DISTINGUISH * MIN_DISTINGUISH)
+ return False;
+ }
+ return True;
+}
+
+Bool
+XmuDistinguishablePixels(Display *dpy, Colormap cmap,
+ unsigned long *pixels, int count)
+{
+ XColor *defs;
+ int i, j;
+ Bool ret;
+
+ for (i = 0; i < count - 1; i++)
+ for (j = i + 1; j < count; j++)
+ if (pixels[i] == pixels[j])
+ return False;
+ defs = (XColor *) malloc (count * sizeof (XColor));
+ if (!defs)
+ return False;
+ for (i = 0; i < count; i++)
+ defs[i].pixel = pixels[i];
+ XQueryColors (dpy, cmap, defs, count);
+ ret = XmuDistinguishableColors (defs, count);
+ free ((char *) defs);
+ return ret;
+}
diff --git a/nx-X11/lib/Xmu/DrRndRect.c b/nx-X11/lib/Xmu/DrRndRect.c
new file mode 100644
index 000000000..7fe5489d0
--- /dev/null
+++ b/nx-X11/lib/Xmu/DrRndRect.c
@@ -0,0 +1,182 @@
+/* $Xorg: DrRndRect.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/DrRndRect.c,v 1.6 2001/01/17 19:42:54 dawes Exp $ */
+
+/*
+ * XmuDrawRoundedRectangle, XmuFillRoundedRectangle
+ *
+ * Draw/Fill a rounded rectangle, where x, y, w, h are the dimensions of
+ * the overall rectangle, and ew and eh are the sizes of a bounding box
+ * that the corners are drawn inside of.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xmu/Drawing.h>
+
+void
+XmuDrawRoundedRectangle(Display *dpy, Drawable draw, GC gc,
+ int x, int y, int w, int h, int ew, int eh)
+{
+ XArc arcs[8];
+ int ew2, eh2;
+
+ if ((ew2 = (ew << 1)) > w)
+ ew2 = ew = 0;
+ if ((eh2 = (eh << 1)) > h)
+ eh2 = eh = 0;
+
+ arcs[0].x = x;
+ arcs[0].y = y;
+ arcs[0].width = ew2;
+ arcs[0].height = eh2;
+ arcs[0].angle1 = 180 * 64;
+ arcs[0].angle2 = -90 * 64;
+
+ arcs[1].x = x + ew;
+ arcs[1].y = y;
+ arcs[1].width = w - ew2;
+ arcs[1].height = 0;
+ arcs[1].angle1 = 180 * 64;
+ arcs[1].angle2 = -180 * 64;
+
+ arcs[2].x = x + w - ew2;
+ arcs[2].y = y;
+ arcs[2].width = ew2;
+ arcs[2].height = eh2;
+ arcs[2].angle1 = 90 * 64;
+ arcs[2].angle2 = -90 * 64;
+
+ arcs[3].x = x + w;
+ arcs[3].y = y + eh;
+ arcs[3].width = 0;
+ arcs[3].height = h - eh2;
+ arcs[3].angle1 = 90 * 64;
+ arcs[3].angle2 = -180 * 64;
+
+ arcs[4].x = x + w - ew2;
+ arcs[4].y = y + h - eh2;
+ arcs[4].width = ew2;
+ arcs[4].height = eh2;
+ arcs[4].angle1 = 0;
+ arcs[4].angle2 = -90 * 64;
+
+ arcs[5].x = x + ew;
+ arcs[5].y = y + h;
+ arcs[5].width = w - ew2;
+ arcs[5].height = 0;
+ arcs[5].angle1 = 0;
+ arcs[5].angle2 = -180 * 64;
+
+ arcs[6].x = x;
+ arcs[6].y = y + h - eh2;
+ arcs[6].width = ew2;
+ arcs[6].height = eh2;
+ arcs[6].angle1 = 270 * 64;
+ arcs[6].angle2 = -90 * 64;
+
+ arcs[7].x = x;
+ arcs[7].y = y + eh;
+ arcs[7].width = 0;
+ arcs[7].height = h - eh2;
+ arcs[7].angle1 = 270 * 64;
+ arcs[7].angle2 = -180 * 64;
+
+ XDrawArcs(dpy, draw, gc, arcs, 8);
+}
+
+void
+XmuFillRoundedRectangle(Display *dpy, Drawable draw, GC gc,
+ int x, int y, int w, int h, int ew, int eh)
+{
+ XArc arcs[4];
+ XRectangle rects[3];
+ XGCValues vals;
+ int ew2, eh2;
+
+ XGetGCValues(dpy, gc, GCArcMode, &vals);
+ if (vals.arc_mode != ArcPieSlice)
+ XSetArcMode(dpy, gc, ArcPieSlice);
+
+ if ((ew2 = (ew << 1)) > w)
+ ew2 = ew = 0;
+ if ((eh2 = (eh << 1)) > h)
+ eh2 = eh = 0;
+
+ arcs[0].x = x;
+ arcs[0].y = y;
+ arcs[0].width = ew2;
+ arcs[0].height = eh2;
+ arcs[0].angle1 = 180 * 64;
+ arcs[0].angle2 = -90 * 64;
+
+ arcs[1].x = x + w - ew2 - 1;
+ arcs[1].y = y;
+ arcs[1].width = ew2;
+ arcs[1].height = eh2;
+ arcs[1].angle1 = 90 * 64;
+ arcs[1].angle2 = -90 * 64;
+
+ arcs[2].x = x + w - ew2 - 1;
+ arcs[2].y = y + h - eh2 - 1;
+ arcs[2].width = ew2;
+ arcs[2].height = eh2;
+ arcs[2].angle1 = 0;
+ arcs[2].angle2 = -90 * 64;
+
+ arcs[3].x = x;
+ arcs[3].y = y + h - eh2 - 1;
+ arcs[3].width = ew2;
+ arcs[3].height = eh2;
+ arcs[3].angle1 = 270 * 64;
+ arcs[3].angle2 = -90 * 64;
+
+ XFillArcs(dpy, draw, gc, arcs, 4);
+
+ rects[0].x = x + ew;
+ rects[0].y = y;
+ rects[0].width = w - ew2;
+ rects[0].height = h;
+
+ rects[1].x = x;
+ rects[1].y = y + eh;
+ rects[1].width = ew;
+ rects[1].height = h - eh2;
+
+ rects[2].x = x + w - ew;
+ rects[2].y = y + eh;
+ rects[2].width = ew;
+ rects[2].height = h - eh2;
+
+ XFillRectangles(dpy, draw, gc, rects, 3);
+
+ if (vals.arc_mode != ArcPieSlice)
+ XSetArcMode(dpy, gc, vals.arc_mode);
+}
diff --git a/nx-X11/lib/Xmu/DrawLogo.c b/nx-X11/lib/Xmu/DrawLogo.c
new file mode 100644
index 000000000..74e64d866
--- /dev/null
+++ b/nx-X11/lib/Xmu/DrawLogo.c
@@ -0,0 +1,155 @@
+/* $Xorg: DrawLogo.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/DrawLogo.c,v 1.7 2001/01/17 19:42:54 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xmu/Drawing.h>
+
+/*
+ * Draw the "official" X Window System Logo, designed by Danny Chong
+ *
+ * Written by Ollie Jones, Apollo Computer
+ *
+ * Does some fancy stuff to make the logo look acceptable even
+ * if it is tiny. Also makes the various linear elements of
+ * the logo line up as well as possible considering rasterization.
+ */
+void
+XmuDrawLogo(Display *dpy, Drawable drawable, GC gcFore, GC gcBack,
+ int x, int y, unsigned int width, unsigned int height)
+{
+ unsigned int size;
+ int thin, gap, d31;
+ XPoint poly[4];
+
+ XFillRectangle(dpy, drawable, gcBack, x, y, width, height);
+
+ /* for now, do a centered even-sized square, at least for now */
+ size = width;
+ if (height < width)
+ size = height;
+ size &= ~1;
+ x += (width - size) >> 1;
+ y += (height - size) >> 1;
+
+/*
+ * Draw what will be the thin strokes.
+ *
+ * -----
+ * / /
+ * / /
+ * / /
+ * / /
+ * /____/
+ * d
+ *
+ * Point d is 9/44 (~1/5) of the way across.
+ */
+
+ thin = (size / 11);
+ if (thin < 1) thin = 1;
+ gap = (thin+3) / 4;
+ d31 = thin + thin + gap;
+ poly[0].x = x + size; poly[0].y = y;
+ poly[1].x = x + size-d31; poly[1].y = y;
+ poly[2].x = x + 0; poly[2].y = y + size;
+ poly[3].x = x + d31; poly[3].y = y + size;
+ XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
+
+/*
+ * Erase area not needed for lower thin stroke.
+ *
+ * ------
+ * / /
+ * / __ /
+ * / / /
+ * / / /
+ * /__/__/
+ */
+
+ poly[0].x = x + d31/2; poly[0].y = y + size;
+ poly[1].x = x + size / 2; poly[1].y = y + size/2;
+ poly[2].x = x + (size/2)+(d31-(d31/2)); poly[2].y = y + size/2;
+ poly[3].x = x + d31; poly[3].y = y + size;
+ XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
+
+/*
+ * Erase area not needed for upper thin stroke.
+ *
+ * ------
+ * / / /
+ * /--/ /
+ * / /
+ * / /
+ * /_____/
+ */
+
+ poly[0].x = x + size - d31/2; poly[0].y = y;
+ poly[1].x = x + size / 2; poly[1].y = y + size/2;
+ poly[2].x = x + (size/2)-(d31-(d31/2)); poly[2].y = y + size/2;
+ poly[3].x = x + size - d31; poly[3].y = y;
+ XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
+
+/*
+ * Draw thick stroke.
+ * Point b is 1/4 of the way across.
+ *
+ * b
+ * -----
+ * \ \
+ * \ \
+ * \ \
+ * \ \
+ * \____\
+ */
+
+ poly[0].x = x; poly[0].y = y;
+ poly[1].x = x + size/4; poly[1].y = y;
+ poly[2].x = x + size; poly[2].y = y + size;
+ poly[3].x = x + size - size/4; poly[3].y = y + size;
+ XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
+
+/*
+ * Erase to create gap.
+ *
+ * /
+ * /
+ * /
+ * /
+ * /
+ */
+
+ poly[0].x = x + size- thin; poly[0].y = y;
+ poly[1].x = x + size-( thin+gap); poly[1].y = y;
+ poly[2].x = x + thin; poly[2].y = y + size;
+ poly[3].x = x + thin + gap; poly[3].y = y + size;
+ XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
+}
diff --git a/nx-X11/lib/Xmu/Drawing.h b/nx-X11/lib/Xmu/Drawing.h
new file mode 100644
index 000000000..9ffed3bab
--- /dev/null
+++ b/nx-X11/lib/Xmu/Drawing.h
@@ -0,0 +1,161 @@
+/* $Xorg: Drawing.h,v 1.5 2001/02/09 02:03:52 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/Drawing.h,v 1.6 2001/12/14 19:55:42 dawes Exp $ */
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_DRAWING_H_
+#define _XMU_DRAWING_H_
+
+#include <X11/Xlib.h>
+#include <X11/Xfuncproto.h>
+
+#include <stdio.h>
+#if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
+typedef unsigned long Pixel;
+#endif
+
+_XFUNCPROTOBEGIN
+
+void XmuDrawRoundedRectangle
+(
+ Display *dpy,
+ Drawable draw,
+ GC gc,
+ int x,
+ int y,
+ int w,
+ int h,
+ int ew,
+ int eh
+ );
+
+void XmuFillRoundedRectangle
+(
+ Display *dpy,
+ Drawable draw,
+ GC gc,
+ int x,
+ int y,
+ int w,
+ int h,
+ int ew,
+ int eh
+ );
+
+void XmuDrawLogo
+(
+ Display *dpy,
+ Drawable drawable,
+ GC gcFore,
+ GC gcBack,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height
+ );
+
+Pixmap XmuCreatePixmapFromBitmap
+(
+ Display *dpy,
+ Drawable d,
+ Pixmap bitmap,
+ unsigned int width,
+ unsigned int height,
+ unsigned int depth,
+ unsigned long fore,
+ unsigned long back
+);
+
+Pixmap XmuCreateStippledPixmap
+(
+ Screen *screen,
+ Pixel fore,
+ Pixel back,
+ unsigned int depth
+ );
+
+void XmuReleaseStippledPixmap
+(
+ Screen *screen,
+ Pixmap pixmap
+ );
+
+Pixmap XmuLocateBitmapFile
+(
+ Screen *screen,
+ _Xconst char *name,
+ char *srcname_return,
+ int srcnamelen,
+ int *width_return,
+ int *height_return,
+ int *xhot_return,
+ int *yhot_return
+ );
+
+Pixmap XmuLocatePixmapFile
+(
+ Screen *screen,
+ _Xconst char *name,
+ unsigned long fore,
+ unsigned long back,
+ unsigned int depth,
+ char *srcname_return,
+ int srcnamelen,
+ int *width_return,
+ int *height_return,
+ int *xhot_return,
+ int *yhot_return
+ );
+
+int XmuReadBitmapData
+(
+ FILE *fstream,
+ unsigned int *width_return,
+ unsigned int *height_return,
+ unsigned char **datap_return,
+ int *xhot_return,
+ int *yhot_return
+);
+
+int XmuReadBitmapDataFromFile
+(
+ _Xconst char *filename,
+ unsigned int *width_return,
+ unsigned int *height_return,
+ unsigned char **datap_return,
+ int *xhot_return,
+ int *yhot_return
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_DRAWING_H_ */
diff --git a/nx-X11/lib/Xmu/Editres.h b/nx-X11/lib/Xmu/Editres.h
new file mode 100644
index 000000000..2a3f3e250
--- /dev/null
+++ b/nx-X11/lib/Xmu/Editres.h
@@ -0,0 +1,42 @@
+/* $Xorg: Editres.h,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xmu/Editres.h,v 1.5 2001/01/17 19:42:55 dawes Exp $ */
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+void _XEditResCheckMessages
+(
+ Widget w,
+ XtPointer data,
+ XEvent *event,
+ Boolean *cont
+);
+
+_XFUNCPROTOEND
diff --git a/nx-X11/lib/Xmu/EditresCom.c b/nx-X11/lib/Xmu/EditresCom.c
new file mode 100644
index 000000000..66da52c9b
--- /dev/null
+++ b/nx-X11/lib/Xmu/EditresCom.c
@@ -0,0 +1,2214 @@
+/* $Xorg: EditresCom.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/EditresCom.c,v 1.21 2003/10/24 15:44:05 tsi Exp $ */
+
+/*
+ * Author: Chris D. Peterson, Dave Sternlicht, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h> /* To get into the composite and core widget
+ structures. */
+#include <X11/ObjectP.h> /* For XtIs<Classname> macros. */
+#include <X11/StringDefs.h> /* for XtRString. */
+#include <X11/ShellP.h> /* for Application Shell Widget class. */
+
+#include <X11/Xatom.h>
+#include <X11/Xos.h> /* for strcpy declaration */
+#include <X11/Xfuncs.h>
+#include <X11/Xmu/EditresP.h>
+#include <X11/Xmd.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/SysUtil.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define _XEditResPutBool _XEditResPut8
+#define _XEditResPutResourceType _XEditResPut8
+
+/*
+ * Types
+ */
+typedef enum {
+ BlockNone,
+ BlockSetValues,
+ BlockAll
+} EditresBlock;
+
+typedef struct _SetValuesEvent {
+ EditresCommand type; /* first field must be type */
+ WidgetInfo *widgets;
+ unsigned short num_entries; /* number of set values requests */
+ char *name;
+ char *res_type;
+ XtPointer value;
+ unsigned short value_len;
+} SetValuesEvent;
+
+typedef struct _SVErrorInfo {
+ SetValuesEvent *event;
+ ProtocolStream *stream;
+ unsigned short *count;
+ WidgetInfo *entry;
+} SVErrorInfo;
+
+typedef struct _GetValuesEvent {
+ EditresCommand type; /* first field must be type */
+ WidgetInfo *widgets;
+ unsigned short num_entries; /* number of get values requests */
+ char *name;
+} GetValuesEvent;
+
+typedef struct _FindChildEvent {
+ EditresCommand type; /* first field must be type */
+ WidgetInfo *widgets;
+ short x, y;
+} FindChildEvent;
+
+typedef struct _GenericGetEvent {
+ EditresCommand type; /* first field must be type */
+ WidgetInfo *widgets;
+ unsigned short num_entries; /* number of set values requests */
+} GenericGetEvent, GetResEvent, GetGeomEvent;
+
+/*
+ * Common to all events
+ */
+typedef struct _AnyEvent {
+ EditresCommand type; /* first field must be type */
+ WidgetInfo *widgets;
+} AnyEvent;
+
+/*
+ * The event union
+ */
+typedef union _EditresEvent {
+ AnyEvent any_event;
+ SetValuesEvent set_values_event;
+ GetResEvent get_resources_event;
+ GetGeomEvent get_geometry_event;
+ FindChildEvent find_child_event;
+} EditresEvent;
+
+typedef struct _Globals {
+ EditresBlock block;
+ SVErrorInfo error_info;
+ ProtocolStream stream;
+ ProtocolStream *command_stream; /* command stream */
+#if defined(LONG64) || defined(WORD64)
+ unsigned long base_address;
+#endif
+} Globals;
+
+#define CURRENT_PROTOCOL_VERSION 5L
+
+#define streq(a,b) (strcmp((a), (b)) == 0)
+
+/*
+ * Prototypes
+ */
+static Widget _FindChild(Widget, int, int);
+static void _XEditresGetStringValues(Widget, Arg*, int);
+static XtPointer BuildReturnPacket(ResIdent, EditResError, ProtocolStream*);
+static void CommandDone(Widget, Atom*, Atom*);
+static Boolean ConvertReturnCommand(Widget, Atom*, Atom*, Atom*, XtPointer*,
+ unsigned long*, int*);
+static Boolean CvtStringToBlock(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static EditresEvent *BuildEvent(Widget, Atom, XtPointer, ResIdent,
+ unsigned long);
+static char *DoFindChild(Widget, EditresEvent*, ProtocolStream*);
+static char *DoGetGeometry(Widget, EditresEvent*, ProtocolStream*);
+static char *DoGetResources(Widget, EditresEvent*, ProtocolStream*);
+static char *DoSetValues(Widget, EditresEvent*, ProtocolStream*);
+static void DumpChildren(Widget, ProtocolStream*, unsigned short*);
+static char *DumpValues(Widget, EditresEvent*, ProtocolStream*);
+static char *DumpWidgets(Widget, EditresEvent*, ProtocolStream*);
+static void ExecuteCommand(Widget, Atom, ResIdent, EditresEvent*);
+static void ExecuteGetGeometry(Widget, ProtocolStream*);
+static void ExecuteGetResources(Widget w, ProtocolStream *stream);
+static void ExecuteSetValues(Widget, SetValuesEvent*, WidgetInfo*,
+ ProtocolStream*, unsigned short*);
+static void FreeEvent(EditresEvent*);
+static void GetCommand(Widget w, XtPointer, Atom*, Atom*, XtPointer,
+ unsigned long*, int*);
+static void HandleToolkitErrors(String, String, String, String,
+ String*, Cardinal*);
+static void InsertWidget(ProtocolStream*, Widget);
+static Bool IsChild(Widget, Widget, Widget);
+static Bool isApplicationShell(Widget);
+static void LoadResources(Widget);
+static Bool PositionInChild(Widget, int, int);
+static int qcmp_widget_list(register _Xconst void*, register _Xconst void*);
+static void SendCommand(Widget, Atom, ResIdent, EditResError,
+ ProtocolStream*);
+static void SendFailure(Widget, Atom, ResIdent, char*);
+static char *VerifyWidget(Widget, WidgetInfo*);
+
+/*
+ * External
+ */
+void _XEditResCheckMessages(Widget, XtPointer, XEvent*, Boolean*);
+
+/*
+ * Initialization
+ */
+static Atom res_editor_command, res_editor_protocol, client_value;
+static Globals globals;
+
+/************************************************************
+ * Resource Editor Communication Code
+ ************************************************************/
+/*
+ * Function:
+ * _XEditResCheckMessages
+ *
+ * Parameters:
+ * data - unused
+ * event - The X Event that triggered this handler
+ * cont - unused
+ *
+ * Description:
+ * This callback routine is set on all shell widgets, and checks to
+ * see if a client message event has come from the resource editor.
+ */
+/*ARGSUSED*/
+void
+_XEditResCheckMessages(Widget w, XtPointer data, XEvent *event, Boolean *cont)
+{
+ Time time;
+ ResIdent ident;
+ static Boolean first_time = False;
+ static Atom res_editor, res_comm;
+ Display *dpy;
+
+ if (event->type == ClientMessage)
+ {
+ XClientMessageEvent * c_event = (XClientMessageEvent *)event;
+ dpy = XtDisplay(w);
+
+ if (!first_time)
+ {
+ Atom atoms[4];
+ static char *names[] = {
+ EDITRES_NAME, EDITRES_COMMAND_ATOM,
+ EDITRES_PROTOCOL_ATOM, EDITRES_CLIENT_VALUE
+ };
+
+ first_time = True;
+ XInternAtoms(dpy, names, 4, False, atoms);
+ res_editor = atoms[0];
+ res_editor_command = atoms[1];
+ res_editor_protocol = atoms[2];
+ /* Used in later procedures */
+ client_value = atoms[3];
+ LoadResources(w);
+ }
+
+ if ((c_event->message_type != res_editor)
+ || (c_event->format != EDITRES_SEND_EVENT_FORMAT))
+ return;
+
+ time = c_event->data.l[0];
+ res_comm = c_event->data.l[1];
+ ident = (ResIdent) c_event->data.l[2];
+ if (c_event->data.l[3] != CURRENT_PROTOCOL_VERSION)
+ {
+ _XEditResResetStream(&globals.stream);
+ _XEditResPut8(&globals.stream, (unsigned int) CURRENT_PROTOCOL_VERSION);
+ SendCommand(w, res_comm, ident, ProtocolMismatch, &globals.stream);
+ return;
+ }
+
+ XtGetSelectionValue(w, res_comm, res_editor_command,
+ GetCommand, (XtPointer)(long)ident, time);
+ }
+}
+
+/*
+ * Function:
+ * BuildEvent
+ *
+ * Parameters:
+ * w - widget to own selection, in case of error
+ * sel - selection to send error message beck in
+ * data - the data for the request
+ * ident - the id number we are looking for
+ * length - length of request
+ *
+ * Description:
+ * Takes the info out the protocol stream an constructs
+ * the proper event structure.
+ *
+ * Returns:
+ * the event, or NULL
+ */
+#if defined(ERROR_MESSAGE)
+#undef ERROR_MESSAGE
+#endif
+#define ERROR_MESSAGE "Client: Improperly formatted protocol request"
+static EditresEvent *
+BuildEvent(Widget w, Atom sel, XtPointer data, ResIdent ident,
+ unsigned long length)
+{
+ EditresEvent *event;
+ ProtocolStream alloc_stream, *stream;
+ unsigned char temp;
+ register unsigned int i;
+
+ stream = &alloc_stream;
+ stream->current = stream->top = (unsigned char *)data;
+ stream->size = HEADER_SIZE; /* size of header */
+
+ /*
+ * Retrieve the Header
+ */
+ if (length < HEADER_SIZE)
+ {
+ SendFailure(w, sel, ident, ERROR_MESSAGE);
+ return (NULL);
+ }
+
+ (void)_XEditResGet8(stream, &temp);
+ if (temp != ident) /* Id's don't match, ignore request */
+ return (NULL);
+
+ event = (EditresEvent *)XtCalloc(sizeof(EditresEvent), 1);
+
+ (void)_XEditResGet8(stream, &temp);
+ event->any_event.type = (EditresCommand)temp;
+ (void)_XEditResGet32(stream, &stream->size);
+ stream->top = stream->current; /* reset stream to top of value */
+
+ /*
+ * Now retrieve the data segment
+ */
+ switch(event->any_event.type)
+ {
+ case SendWidgetTree:
+ break; /* no additional info */
+ case SetValues:
+ {
+ SetValuesEvent *sv_event = (SetValuesEvent *)event;
+
+ if (!(_XEditResGetString8(stream, &sv_event->name)
+ && _XEditResGetString8(stream, &sv_event->res_type)))
+ goto done;
+
+ /*
+ * Since we need the value length, we have to pull the
+ * value out by hand
+ */
+ if (!_XEditResGet16(stream, &sv_event->value_len))
+ goto done;
+
+ sv_event->value = XtMalloc(sizeof(char) * (sv_event->value_len + 1));
+
+ for (i = 0; i < sv_event->value_len; i++)
+ if (!_XEditResGet8(stream, (unsigned char *)sv_event->value + i))
+ goto done;
+
+ ((char*)sv_event->value)[i] = '\0';
+
+ if (!_XEditResGet16(stream, &sv_event->num_entries))
+ goto done;
+
+ sv_event->widgets = (WidgetInfo *)
+ XtCalloc(sizeof(WidgetInfo), sv_event->num_entries);
+
+ for (i = 0; i < sv_event->num_entries; i++)
+ if (!_XEditResGetWidgetInfo(stream, sv_event->widgets + i))
+ goto done;
+ }
+ break;
+ case FindChild:
+ {
+ FindChildEvent *find_event = (FindChildEvent *)event;
+
+ find_event->widgets = (WidgetInfo *)XtCalloc(sizeof(WidgetInfo), 1);
+
+ if (!(_XEditResGetWidgetInfo(stream, find_event->widgets)
+ && _XEditResGetSigned16(stream, &find_event->x)
+ && _XEditResGetSigned16(stream, &find_event->y)))
+ goto done;
+ }
+ break;
+ case GetGeometry:
+ case GetResources:
+ {
+ GenericGetEvent *get_event = (GenericGetEvent *)event;
+
+ if (!_XEditResGet16(stream, &get_event->num_entries))
+ goto done;
+
+ get_event->widgets = (WidgetInfo *)
+ XtCalloc(sizeof(WidgetInfo), get_event->num_entries);
+
+ for (i = 0; i < get_event->num_entries; i++)
+ if (!_XEditResGetWidgetInfo(stream, get_event->widgets + i))
+ goto done;
+ }
+ break;
+ case GetValues:
+ {
+ GetValuesEvent *gv_event = (GetValuesEvent *)event;
+
+ _XEditResGetString8(stream, &gv_event->name);
+ _XEditResGet16(stream, &gv_event->num_entries);
+ gv_event->widgets = (WidgetInfo *)
+ XtCalloc(sizeof(WidgetInfo), gv_event->num_entries);
+ _XEditResGetWidgetInfo(stream, gv_event->widgets);
+ }
+ break;
+ default:
+ {
+ char buf[BUFSIZ];
+
+ XmuSnprintf(buf, sizeof(buf),
+ "Unknown Protocol request %d.", event->any_event.type);
+ SendFailure(w, sel, ident, buf);
+ FreeEvent(event);
+ return (NULL);
+ }
+ }
+
+ return (event);
+
+ done:
+ SendFailure(w, sel, ident, ERROR_MESSAGE);
+ FreeEvent(event);
+ return (NULL);
+}
+
+/*
+ * Function:
+ * FreeEvent
+ *
+ * Parameters:
+ * event - event to free
+ *
+ * Description:
+ * Frees the event structure and any other pieces in it that need freeing.
+ */
+static void
+FreeEvent(EditresEvent *event)
+{
+ if (event->any_event.widgets != NULL)
+ {
+ XtFree((char *)event->any_event.widgets->ids);
+ XtFree((char *)event->any_event.widgets);
+ }
+
+ if (event->any_event.type == SetValues)
+ {
+ XtFree(event->set_values_event.name);
+ XtFree(event->set_values_event.res_type);
+ }
+
+ XtFree((char *)event);
+}
+
+/*
+ * Function:
+ * GetCommand
+ *
+ * Parameters:
+ * (See Xt XtConvertSelectionProc)
+ * data - contains the ident number for the command
+ *
+ * Description:
+ * Gets the Command out of the selection asserted by the resource manager.
+ */
+/*ARGSUSED*/
+static void
+GetCommand(Widget w, XtPointer data, Atom *selection, Atom *type,
+ XtPointer value, unsigned long *length, int *format)
+{
+ ResIdent ident = (ResIdent)(long)data;
+ EditresEvent *event;
+
+ if (*type != res_editor_protocol || *format != EDITRES_FORMAT)
+ return;
+
+ if ((event = BuildEvent(w, *selection, value, ident, *length)) != NULL)
+ {
+ ExecuteCommand(w, *selection, ident, event);
+ FreeEvent(event);
+ }
+}
+
+/*
+ * Function:
+ * ExecuteCommand
+ *
+ * Parameters:
+ * w - widget
+ * command - the command to execute
+ * value - the associated with the command
+ *
+ * Description:
+ * Executes a command string received from the resource editor.
+ */
+/*ARGSUSED*/
+static void
+ExecuteCommand(Widget w, Atom sel, ResIdent ident, EditresEvent *event)
+{
+ char *(*func)(Widget, EditresEvent*, ProtocolStream*);
+ char *str;
+
+ if (globals.block == BlockAll)
+ {
+ SendFailure(w, sel, ident,
+ "This client has blocked all Editres commands.");
+ return;
+ }
+ else if (globals.block == BlockSetValues
+ && event->any_event.type == SetValues)
+ {
+ SendFailure(w, sel, ident,
+ "This client has blocked all SetValues requests.");
+ return;
+ }
+
+ switch(event->any_event.type)
+ {
+ case SendWidgetTree:
+#if defined(LONG64) || defined(WORD64)
+ globals.base_address = (unsigned long)w & 0xFFFFFFFF00000000;
+#endif
+ func = DumpWidgets;
+ break;
+ case SetValues:
+ func = DoSetValues;
+ break;
+ case FindChild:
+ func = DoFindChild;
+ break;
+ case GetGeometry:
+ func = DoGetGeometry;
+ break;
+ case GetResources:
+ func = DoGetResources;
+ break;
+ case GetValues:
+ func = DumpValues;
+ break;
+ default:
+ {
+ char buf[BUFSIZ];
+
+ XmuSnprintf(buf, sizeof(buf),
+ "Unknown Protocol request %d.",event->any_event.type);
+ SendFailure(w, sel, ident, buf);
+ return;
+ }
+ }
+
+ _XEditResResetStream(&globals.stream);
+ if ((str = (*func)(w, event, &globals.stream)) == NULL)
+ SendCommand(w, sel, ident, PartialSuccess, &globals.stream);
+ else
+ SendFailure(w, sel, ident, str);
+}
+
+/*
+ * Function:
+ * ConvertReturnCommand
+ *
+ * Parameters:
+ * w - the widget that owns the selection
+ * selection - selection to convert
+ * target - target type for this selection
+ * type_ret - type of the selection
+ * value_ret - selection value
+ * length_ret - lenght of this selection
+ * format_ret - the format the selection is in
+ *
+ * Description:
+ * Converts a selection
+ *
+ * Returns:
+ * True if conversion was sucessful
+ */
+/*ARGSUSED*/
+static Boolean
+ConvertReturnCommand(Widget w, Atom *selection, Atom *target, Atom *type_ret,
+ XtPointer *value_ret, unsigned long *length_ret,
+ int *format_ret)
+{
+ /*
+ * I assume the intrinsics give me the correct selection back
+ */
+ if ((*target != client_value))
+ return (False);
+
+ *type_ret = res_editor_protocol;
+ *value_ret = (XtPointer)globals.command_stream->real_top;
+ *length_ret = globals.command_stream->size + HEADER_SIZE;
+ *format_ret = EDITRES_FORMAT;
+
+ return (True);
+}
+
+/*
+ * Function:
+ * CommandDone
+ *
+ * Parameters:
+ * widget - unused
+ * selection - unused
+ * target - unused
+ *
+ * Description:
+ * done with the selection
+ */
+/*ARGSUSED*/
+static void
+CommandDone(Widget widget, Atom *selection, Atom *target)
+{
+ /* Keep the toolkit from automaticaly freeing the selection value */
+}
+
+/*
+ * Function:
+ * SendFailure
+ *
+ * Paramters:
+ * w - widget to own the selection
+ * sel - selection to assert
+ * ident - identifier
+ * str - error message
+ *
+ * Description:
+ * Sends a failure message
+ */
+static void
+SendFailure(Widget w, Atom sel, ResIdent ident, char *str)
+{
+ _XEditResResetStream(&globals.stream);
+ _XEditResPutString8(&globals.stream, str);
+ SendCommand(w, sel, ident, Failure, &globals.stream);
+}
+
+/*
+ * Function:
+ * BuildReturnPacket
+ *
+ * Parameters:
+ * ident - identifier
+ * command - command code
+ * stream - protocol stream
+ * Description:
+ * Builds a return packet, given the data to send
+ *
+ * Returns:
+ * packet to send
+ */
+static XtPointer
+BuildReturnPacket(ResIdent ident, EditResError error, ProtocolStream *stream)
+{
+ long old_alloc, old_size;
+ unsigned char *old_current;
+
+ /*
+ * We have cleverly keep enough space at the top of the header
+ * for the return protocol stream, so all we have to do is
+ * fill in the space
+ */
+ /*
+ * Fool the insert routines into putting the header in the right
+ * place while being damn sure not to realloc (that would be very bad.)
+ */
+ old_current = stream->current;
+ old_alloc = stream->alloc;
+ old_size = stream->size;
+
+ stream->current = stream->real_top;
+ stream->alloc = stream->size + (2 * HEADER_SIZE);
+
+ _XEditResPut8(stream, ident);
+ _XEditResPut8(stream, (unsigned char)error);
+ _XEditResPut32(stream, old_size);
+
+ stream->alloc = old_alloc;
+ stream->current = old_current;
+ stream->size = old_size;
+
+ return ((XtPointer)stream->real_top);
+}
+
+/*
+ * Function:
+ * SendCommand
+ * Parameters:
+ * w - widget to own the selection
+ * sel - selection to assert
+ * ident - identifier
+ * command - command code
+ * stream - protocol stream
+ *
+ * Description:
+ * Builds a return command line
+ */
+static void
+SendCommand(Widget w, Atom sel, ResIdent ident, EditResError error,
+ ProtocolStream *stream)
+{
+ BuildReturnPacket(ident, error, stream);
+ globals.command_stream = stream;
+
+ /*
+ * I REALLY want to own the selection. Since this was not triggered
+ * by a user action, and I am the only one using this atom it is safe to
+ * use CurrentTime
+ */
+ XtOwnSelection(w, sel, CurrentTime, ConvertReturnCommand, NULL, CommandDone);
+}
+
+/************************************************************
+ * Generic Utility Functions
+ ************************************************************/
+static int
+qcmp_widget_list(register _Xconst void *left, register _Xconst void *right)
+{
+ return (char *)*(Widget **)left - (char *)*(Widget **)right;
+}
+
+/*
+ * Function:
+ * FindChildren
+ *
+ * Parameters:
+ * parent - parent widget
+ * children - list of children
+ * normal - return normal children
+ * popup - return popup children
+ * extra - return extra children
+ *
+ * Description:
+ * Retuns all children (popup, normal and otherwise) of this widget
+ *
+ * Returns:
+ * number of children
+ */
+static int
+FindChildren(Widget parent, Widget **children, Bool normal, Bool popup,
+ Bool extra)
+{
+ CompositeWidget cw = (CompositeWidget)parent;
+ Cardinal i, num_children, current = 0;
+ Widget *extra_widgets = NULL;
+ Cardinal num_extra = 0;
+
+ num_children = 0;
+
+ if (XtIsWidget(parent) && popup)
+ num_children += parent->core.num_popups;
+
+ if (XtIsComposite(parent) && normal)
+ num_children += cw->composite.num_children;
+
+ if (XtIsWidget(parent) && extra)
+ {
+ XtResourceList norm_list, cons_list;
+ Cardinal num_norm, num_cons;
+ Arg args[1];
+ Widget widget;
+
+ XtGetResourceList(XtClass(parent), &norm_list, &num_norm);
+
+ if (XtParent(parent) != NULL)
+ XtGetConstraintResourceList(XtClass(XtParent(parent)),
+ &cons_list, &num_cons);
+ else
+ num_cons = 0;
+
+ extra_widgets = (Widget *)XtMalloc(sizeof(Widget));
+ for (i = 0; i < num_norm; i++)
+ if (strcmp(norm_list[i].resource_type, XtRWidget) == 0)
+ {
+ widget = NULL;
+ XtSetArg(args[0], norm_list[i].resource_name, &widget);
+ XtGetValues(parent, args, 1);
+ if (widget && XtParent(widget) == parent)
+ {
+ ++num_extra;
+ extra_widgets = (Widget *)
+ XtRealloc((char *)extra_widgets, num_extra * sizeof(Widget));
+ extra_widgets[num_extra - 1] = widget;
+ }
+ }
+ for (i = 0; i < num_cons; i++)
+ if (strcmp(cons_list[i].resource_type, XtRWidget) == 0)
+ {
+ widget = NULL;
+ XtSetArg(args[0], cons_list[i].resource_name, &widget);
+ XtGetValues(parent, args, 1);
+ if (widget && XtParent(widget) == parent)
+ {
+ ++num_extra;
+ extra_widgets = (Widget *)
+ XtRealloc((char *)extra_widgets, num_extra * sizeof(Widget));
+ extra_widgets[num_extra - 1] = widget;
+ }
+ }
+ if (num_norm)
+ XtFree((char *)norm_list);
+ if (num_cons)
+ XtFree((char *)cons_list);
+ }
+
+ if ((num_children + num_extra) == 0)
+ {
+ *children = NULL;
+ return (0);
+ }
+
+ *children = (Widget *)XtMalloc(sizeof(Widget) * (num_children + num_extra));
+
+ if (XtIsComposite(parent) && normal)
+ for (i = 0; i < cw->composite.num_children; i++, current++)
+ (*children)[current] = cw->composite.children[i];
+
+ if (XtIsWidget(parent) && popup)
+ for (i = 0; i < parent->core.num_popups; i++, current++)
+ (*children)[current] = parent->core.popup_list[i];
+
+ if (num_extra)
+ /* Check for dups */
+ {
+ Cardinal j, old_num_extra = num_extra;
+
+ qsort(extra_widgets, num_extra, sizeof(Widget), qcmp_widget_list);
+ for (i = 0; i < num_extra - 1; i++)
+ while (i < num_extra - 1 && extra_widgets[i] == extra_widgets[i + 1])
+ {
+ memmove(&extra_widgets[i], &extra_widgets[i + 1],
+ (num_extra - i) * sizeof(Widget));
+ --num_extra;
+ }
+
+ for (i = 0; i < num_children; i++)
+ for (j = 0; j < num_extra; j++)
+ if ((*children)[i] == extra_widgets[j])
+ {
+ if ((j + 1) < num_extra)
+ memmove(&extra_widgets[j], &extra_widgets[j + 1],
+ (num_extra - j) * sizeof(Widget));
+ --num_extra;
+ }
+
+ if (old_num_extra != num_extra)
+ *children = (Widget *)XtRealloc((char *)*children, sizeof(Widget)
+ * (num_children + num_extra));
+
+ if (num_extra)
+ memcpy(&(*children)[num_children], extra_widgets,
+ sizeof(Widget) * num_extra);
+ }
+ if (extra_widgets)
+ XtFree((char *)extra_widgets);
+ if (num_children + num_extra == 0)
+ {
+ XtFree((char *)*children);
+ *children = NULL;
+ }
+
+ return (num_children + num_extra);
+}
+
+/*
+ * Function:
+ * IsChild
+ *
+ * parameters:
+ * top - top of the tree
+ * parent - parent widget
+ * child - child widget
+ *
+ * Description:
+ * Check to see of child is a child of parent
+ */
+static Bool
+IsChild(Widget top, Widget parent, Widget child)
+{
+ int i, num_children;
+ Widget *children;
+
+ if (parent == NULL)
+ return (top == child);
+
+ num_children = FindChildren(parent, &children, True, True, True);
+
+ for (i = 0; i < num_children; i++)
+ if (children[i] == child)
+ {
+ XtFree((char *)children);
+ return (True);
+ }
+
+ XtFree((char *)children);
+ return (False);
+}
+
+/*
+ * Function:
+ * VerifyWidget
+ *
+ * Parameters:
+ * w - any widget in the tree
+ * info - info about the widget to verify
+ *
+ * Description:
+ * Makes sure all the widgets still exist
+ */
+static char *
+VerifyWidget(Widget w, WidgetInfo *info)
+{
+ Widget top;
+ register int count;
+ register Widget parent;
+ register unsigned long *child;
+
+ for (top = w; XtParent(top) != NULL; top = XtParent(top))
+ ;
+
+ parent = NULL;
+ child = info->ids;
+ count = 0;
+
+ while (True)
+ {
+ if (!IsChild(top, parent, (Widget) *child))
+ return ("This widget no longer exists in the client.");
+
+ if (++count == info->num_widgets)
+ break;
+
+ parent = (Widget)*child++;
+ }
+
+ info->real_widget = (Widget)*child;
+
+ return (NULL);
+}
+
+/************************************************************
+ * Code to Perform SetValues operations
+ ************************************************************/
+/*
+ * Function:
+ * DoSetValues
+ *
+ * Parameters:
+ * w - a widget in the tree
+ * event - event that caused this action
+ * stream - protocol stream to add
+ *
+ * Description:
+ * Performs the setvalues requested
+ *
+ * Returns:
+ * NULL
+ */
+static char *
+DoSetValues(Widget w, EditresEvent *event, ProtocolStream *stream)
+{
+ char *str;
+ register unsigned i;
+ unsigned short count = 0;
+ SetValuesEvent *sv_event = (SetValuesEvent *)event;
+
+ _XEditResPut16(stream, count); /* insert 0, will be overwritten later */
+
+ for (i = 0; i < sv_event->num_entries; i++)
+ {
+ if ((str = VerifyWidget(w, &sv_event->widgets[i])) != NULL)
+ {
+ _XEditResPutWidgetInfo(stream, &sv_event->widgets[i]);
+ _XEditResPutString8(stream, str);
+ count++;
+ }
+ else
+ ExecuteSetValues(sv_event->widgets[i].real_widget,
+ sv_event, sv_event->widgets + i, stream, &count);
+ }
+
+ /*
+ * Overwrite the first 2 bytes with the real count.
+ */
+ *(stream->top) = count >> XER_NBBY;
+ *(stream->top + 1) = count;
+
+ return (NULL);
+}
+
+/*
+ * Function:
+ * HandleToolkitErrors
+ *
+ * Parameters:
+ * name - name of the error
+ * type - type of the error
+ * class - class of the error
+ * msg - the default message
+ * params - the extra parameters for this message
+ * num_params - ""
+ *
+ * Description: Handles X Toolkit Errors.
+ */
+/* ARGSUSED */
+static void
+HandleToolkitErrors(String name, String type, String class, String msg,
+ String *params, Cardinal *num_params)
+{
+ SVErrorInfo *info = &globals.error_info;
+ char buf[BUFSIZ];
+
+ if (streq(name, "unknownType"))
+ XmuSnprintf(buf, sizeof(buf),
+ "The `%s' resource is not used by this widget.",
+ info->event->name);
+ else if (streq(name, "noColormap"))
+ XmuSnprintf(buf, sizeof(buf), msg, params[0]);
+ else if (streq(name, "conversionFailed") || streq(name, "conversionError"))
+ {
+ if (streq((String)info->event->value, XtRString))
+ XmuSnprintf(buf, sizeof(buf),
+ "Could not convert the string '%s' for the `%s' "
+ "resource.", (String)info->event->value,
+ info->event->name);
+ else
+ XmuSnprintf(buf, sizeof(buf),
+ "Could not convert the `%s' resource.",
+ info->event->name);
+ }
+ else
+ XmuSnprintf(buf, sizeof(buf),
+ "Name: %s, Type: %s, Class: %s, Msg: %s",
+ name, type, class, msg);
+
+ /*
+ * Insert this info into the protocol stream, and update the count
+ */
+ (*(info->count))++;
+ _XEditResPutWidgetInfo(info->stream, info->entry);
+ _XEditResPutString8(info->stream, buf);
+}
+
+/*
+ * Function:
+ * ExecuteSetValues
+ *
+ * Parameters:
+ * w - widget to perform the set_values on
+ * sv_event - set values event
+ * sv_info - set_value info
+ *.
+ * Description:
+ * Performs a setvalues for a given command
+ */
+static void
+ExecuteSetValues(Widget w, SetValuesEvent *sv_event, WidgetInfo *entry,
+ ProtocolStream *stream, unsigned short *count)
+{
+ XtErrorMsgHandler old;
+ SVErrorInfo *info = &globals.error_info;
+
+ info->event = sv_event; /* No data can be passed to */
+ info->stream = stream; /* an error handler, so we */
+ info->count = count; /* have to use a global */
+ info->entry = entry;
+
+ old = XtAppSetWarningMsgHandler(XtWidgetToApplicationContext(w),
+ HandleToolkitErrors);
+
+ XtVaSetValues(w, XtVaTypedArg,
+ sv_event->name, sv_event->res_type,
+ sv_event->value, sv_event->value_len,
+ NULL);
+
+ (void)XtAppSetWarningMsgHandler(XtWidgetToApplicationContext(w), old);
+}
+
+/************************************************************
+ * Code for Creating and dumping widget tree.
+ ************************************************************/
+/* Function:
+ * DumpWidgets
+ *
+ * Parameters:
+ * w - a widget in the tree
+ * event - event that caused this action
+ * stream - protocol stream to add
+ *
+ * Description:
+ * Given a widget it builds a protocol packet containing the entire
+ * widget heirarchy.
+ *
+ * Returns:
+ * NULL
+ */
+#define TOOLKIT_TYPE ("Xt")
+/*ARGSUSED*/
+static char *
+DumpWidgets(Widget w, EditresEvent *event, ProtocolStream *stream)
+{
+ unsigned short count = 0;
+
+ /* Find Tree's root */
+ for (; XtParent(w) != NULL; w = XtParent(w))
+ ;
+
+ /*
+ * hold space for count, overwritten later
+ */
+ _XEditResPut16(stream, (unsigned int)0);
+
+ DumpChildren(w, stream, &count);
+
+ /*
+ * write out toolkit type
+ */
+ _XEditResPutString8(stream, TOOLKIT_TYPE);
+
+ /*
+ * Overwrite the first 2 bytes with the real count
+ */
+ *(stream->top) = count >> XER_NBBY;
+ *(stream->top + 1) = count;
+
+ return (NULL);
+}
+
+/*
+ * Function:
+ * DumpChildren
+ *
+ * Parameters:
+ * w - widget to dump
+ * stream - stream to dump to
+ * count - number of dumps we have performed
+ *
+ * Description:
+ * Adds a child's name to the list.
+ */
+/* This is a trick/kludge. To make shared libraries happier (linking
+ * against Xmu but not linking against Xt, and apparently even work
+ * as we desire on SVR4, we need to avoid an explicit data reference
+ * to applicationShellWidgetClass. XtIsTopLevelShell is known
+ * (implementation dependent assumption!) to use a bit flag. So we
+ * go that far. Then, we test whether it is an applicationShellWidget
+ * class by looking for an explicit class name. Seems pretty safe.
+ */
+static Bool
+isApplicationShell(Widget w)
+{
+ register WidgetClass c;
+
+ if (!XtIsTopLevelShell(w))
+ return (False);
+ for (c = XtClass(w); c; c = c->core_class.superclass)
+ if (strcmp(c->core_class.class_name, "ApplicationShell") == 0)
+ return (True);
+
+ return (False);
+}
+
+static void
+DumpChildren(Widget w, ProtocolStream *stream, unsigned short *count)
+{
+ int i, num_children;
+ Widget *children;
+ unsigned long window;
+ char *c_class;
+
+ (*count)++;
+
+ InsertWidget(stream, w); /* Insert the widget into the stream */
+
+ _XEditResPutString8(stream, XtName(w)); /* Insert name */
+
+ if (isApplicationShell(w))
+ c_class = ((ApplicationShellWidget)w)->application.class;
+ else
+ c_class = XtClass(w)->core_class.class_name;
+
+ _XEditResPutString8(stream, c_class); /* Insert class */
+
+ if (XtIsWidget(w))
+ if (XtIsRealized(w))
+ window = XtWindow(w);
+ else
+ window = EDITRES_IS_UNREALIZED;
+ else
+ window = EDITRES_IS_OBJECT;
+
+ _XEditResPut32(stream, window); /* Insert window id */
+
+ /*
+ * Find children and recurse
+ */
+ num_children = FindChildren(w, &children, True, True, True);
+ for (i = 0; i < num_children; i++)
+ DumpChildren(children[i], stream, count);
+
+ XtFree((char *)children);
+}
+
+/************************************************************
+ * Code for getting the geometry of widgets
+ ************************************************************/
+/*
+ * Function:
+ * DoGetGeometry
+ *
+ * Parameters:
+ * w - widget in the tree
+ * event - event that caused this action
+ * stream - protocol stream to add
+ *
+ * Description:
+ * Retrieves the Geometry of each specified widget.
+ *
+ * Returns:
+ * NULL
+ */
+static char *
+DoGetGeometry(Widget w, EditresEvent *event, ProtocolStream *stream)
+{
+ unsigned i;
+ char *str;
+ GetGeomEvent *geom_event = (GetGeomEvent *)event;
+
+ _XEditResPut16(stream, geom_event->num_entries);
+
+ for (i = 0; i < geom_event->num_entries; i++)
+ {
+ /*
+ * Send out the widget id
+ */
+ _XEditResPutWidgetInfo(stream, &geom_event->widgets[i]);
+
+ if ((str = VerifyWidget(w, &geom_event->widgets[i])) != NULL)
+ {
+ _XEditResPutBool(stream, True); /* an error occured */
+ _XEditResPutString8(stream, str); /* set message */
+ }
+ else
+ ExecuteGetGeometry(geom_event->widgets[i].real_widget, stream);
+ }
+
+ return (NULL);
+}
+
+/*
+ * Function:
+ * ExecuteGetGeometry
+ *
+ * Parameters:
+ * w - widget to get geometry
+ * stream - stream to append to
+ *
+ * Description:
+ * Gets the geometry for each widget specified.
+ *
+ * Returns:
+ * True if no error occured.
+ */
+static void
+ExecuteGetGeometry(Widget w, ProtocolStream *stream)
+{
+ int i;
+ Boolean mapped_when_man;
+ Dimension width, height, border_width;
+ Arg args[8];
+ Cardinal num_args = 0;
+ Position x, y;
+
+ if (!XtIsRectObj(w) || (XtIsWidget(w) && !XtIsRealized(w)))
+ {
+ _XEditResPutBool(stream, False); /* no error */
+ _XEditResPutBool(stream, False); /* not visable */
+ for (i = 0; i < 5; i++) /* fill in extra space with 0's */
+ _XEditResPut16(stream, 0);
+ return;
+ }
+
+ XtSetArg(args[num_args], XtNwidth, &width); num_args++;
+ XtSetArg(args[num_args], XtNheight, &height); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, &border_width); num_args++;
+ XtSetArg(args[num_args], XtNmappedWhenManaged, &mapped_when_man);
+ num_args++;
+ XtGetValues(w, args, num_args);
+
+ if (!(XtIsManaged(w) && mapped_when_man) && XtIsWidget(w))
+ {
+ XWindowAttributes attrs;
+
+ /*
+ * The toolkit does not maintain mapping state, we have
+ * to go to the server
+ */
+ if (XGetWindowAttributes(XtDisplay(w), XtWindow(w), &attrs) != 0)
+ {
+ if (attrs.map_state != IsViewable)
+ {
+ _XEditResPutBool(stream, False); /* no error */
+ _XEditResPutBool(stream, False); /* not visable */
+ for (i = 0; i < 5; i++) /* fill in extra space with 0's */
+ _XEditResPut16(stream, 0);
+ return;
+ }
+ }
+ else
+ {
+ _XEditResPut8(stream, True); /* Error occured. */
+ _XEditResPutString8(stream, "XGetWindowAttributes failed.");
+ return;
+ }
+ }
+
+ XtTranslateCoords(w, -((int) border_width), -((int) border_width), &x, &y);
+
+ _XEditResPutBool(stream, False); /* no error */
+ _XEditResPutBool(stream, True); /* Visable */
+ _XEditResPut16(stream, x);
+ _XEditResPut16(stream, y);
+ _XEditResPut16(stream, width);
+ _XEditResPut16(stream, height);
+ _XEditResPut16(stream, border_width);
+}
+
+/************************************************************
+ * Code for executing FindChild
+ ************************************************************/
+/*
+ * Function:
+ * PositionInChild
+ *
+ * Parameters:
+ * child - child widget to check
+ * x - location of point to check in the parent's coord space
+ * y - ""
+ *
+ * Description:
+ * Returns true if this location is in the child.
+ */
+static Bool
+PositionInChild(Widget child, int x, int y)
+{
+ Arg args[6];
+ Cardinal num;
+ Dimension width, height, border_width;
+ Position child_x, child_y;
+ Boolean mapped_when_managed;
+
+ if (!XtIsRectObj(child)) /* we must at least be a rect obj */
+ return (False);
+
+ num = 0;
+ XtSetArg(args[num], XtNmappedWhenManaged, &mapped_when_managed); num++;
+ XtSetArg(args[num], XtNwidth, &width); num++;
+ XtSetArg(args[num], XtNheight, &height); num++;
+ XtSetArg(args[num], XtNx, &child_x); num++;
+ XtSetArg(args[num], XtNy, &child_y); num++;
+ XtSetArg(args[num], XtNborderWidth, &border_width); num++;
+ XtGetValues(child, args, num);
+
+ /*
+ * The only way we will know of the widget is mapped is to see if
+ * mapped when managed is True and this is a managed child. Otherwise
+ * we will have to ask the server if this window is mapped
+ */
+ if (XtIsWidget(child) && !(mapped_when_managed && XtIsManaged(child)))
+ {
+ XWindowAttributes attrs;
+
+ if (XGetWindowAttributes(XtDisplay(child), XtWindow(child), &attrs)
+ && attrs.map_state != IsViewable)
+ return (False);
+ }
+
+ return ((x >= child_x)
+ && (x <= (child_x + (Position)width + 2 * (Position)border_width))
+ && (y >= child_y)
+ && (y <= (child_y + (Position)height + 2 * (Position)border_width)));
+}
+
+/*
+ * Function:
+ * _FindChild
+ *
+ * Parameters:
+ * parent - widget that is known to contain the point specified
+ * x - point in coordinates relative to the widget specified
+ * y - ""
+ *
+ * Description:
+ * Finds the child that actually contains the point shown.
+ */
+static Widget
+_FindChild(Widget parent, int x, int y)
+{
+ Widget *children;
+ int i = FindChildren(parent, &children, True, False, True);
+
+ while (i > 0)
+ {
+ i--;
+
+ if (PositionInChild(children[i], x, y))
+ {
+ Widget child = children[i];
+
+ XtFree((char *)children);
+ return (_FindChild(child, x - child->core.x, y - child->core.y));
+ }
+ }
+
+ XtFree((char *)children);
+
+ return (parent);
+}
+
+/*
+ * Function:
+ * DoFindChild
+ *
+ * Parameters:
+ * w - widget in the tree
+ * event - event that caused this action
+ * stream - protocol stream to add
+ * Description:
+ * Finds the child that contains the location specified.
+ *
+ * Returns:
+ * An allocated error message if something went horribly wrong and
+ * no set values were performed, else NULL.
+ */
+static char *
+DoFindChild(Widget w, EditresEvent *event, ProtocolStream *stream)
+{
+ char *str;
+ Widget parent, child;
+ Position parent_x, parent_y;
+ FindChildEvent *find_event = (FindChildEvent *)event;
+
+ if ((str = VerifyWidget(w, find_event->widgets)) != NULL)
+ return (str);
+
+ parent = find_event->widgets->real_widget;
+
+ XtTranslateCoords(parent, (Position) 0, (Position) 0,
+ &parent_x, &parent_y);
+
+ child = _FindChild(parent, find_event->x - (int) parent_x,
+ find_event->y - (int) parent_y);
+
+ InsertWidget(stream, child);
+
+ return (NULL);
+}
+
+/************************************************************
+ * Procedures for performing GetResources
+ ************************************************************/
+/*
+ * Function:
+ * DoGetResources
+ *
+ * Parameters:
+ * w - widget in the tree
+ * event - event that caused this action
+ * stream - protocol stream to add
+ *
+ * Description:
+ * Gets the Resources associated with the widgets passed.
+ *
+ * Returns:
+ * NULL
+ */
+static char *
+DoGetResources(Widget w, EditresEvent *event, ProtocolStream *stream)
+{
+ unsigned int i;
+ char *str;
+ GetResEvent *res_event = (GetResEvent *)event;
+
+ _XEditResPut16(stream, res_event->num_entries); /* number of replys */
+
+ for (i = 0; i < res_event->num_entries; i++)
+ {
+ /*
+ * Send out the widget id
+ */
+ _XEditResPutWidgetInfo(stream, &res_event->widgets[i]);
+ if ((str = VerifyWidget(w, &res_event->widgets[i])) != NULL)
+ {
+ _XEditResPutBool(stream, True); /* an error occured */
+ _XEditResPutString8(stream, str); /* set message */
+ }
+ else
+ {
+ _XEditResPutBool(stream, False); /* no error occured */
+ ExecuteGetResources(res_event->widgets[i].real_widget, stream);
+ }
+ }
+
+ return (NULL);
+}
+
+/* Function:
+ * ExecuteGetResources
+ *
+ * Parameters:
+ * w - widget to get resources on
+ * stream - protocol stream
+ *
+ * Description:
+ * Gets the resources for any individual widget
+ */
+static void
+ExecuteGetResources(Widget w, ProtocolStream *stream)
+{
+ XtResourceList norm_list, cons_list;
+ Cardinal num_norm, num_cons;
+ register Cardinal i;
+
+ /*
+ * Get Normal Resources
+ */
+ XtGetResourceList(XtClass(w), &norm_list, &num_norm);
+
+ if (XtParent(w) != NULL)
+ XtGetConstraintResourceList(XtClass(XtParent(w)), &cons_list,&num_cons);
+ else
+ num_cons = 0;
+
+ _XEditResPut16(stream, num_norm + num_cons); /* how many resources */
+
+ /*
+ * Insert all the normal resources
+ */
+ for (i = 0; i < num_norm; i++)
+ {
+ _XEditResPutResourceType(stream, NormalResource);
+ _XEditResPutString8(stream, norm_list[i].resource_name);
+ _XEditResPutString8(stream, norm_list[i].resource_class);
+ _XEditResPutString8(stream, norm_list[i].resource_type);
+ }
+ XtFree((char *)norm_list);
+
+ /*
+ * Insert all the constraint resources
+ */
+ if (num_cons > 0)
+ {
+ for (i = 0; i < num_cons; i++)
+ {
+ _XEditResPutResourceType(stream, ConstraintResource);
+ _XEditResPutString8(stream, cons_list[i].resource_name);
+ _XEditResPutString8(stream, cons_list[i].resource_class);
+ _XEditResPutString8(stream, cons_list[i].resource_type);
+ }
+ XtFree((char *)cons_list);
+ }
+}
+
+/*
+ * Function:
+ * DumpValues
+ *
+ * Parameters:
+ * event - event that caused this action
+ * stream - protocol stream to add
+ *
+ * Description:
+ * Returns resource values to the resource editor.
+ *
+ * Returns:
+ * NULL
+ */
+/*ARGSUSED*/
+static char *
+DumpValues(Widget w, EditresEvent* event, ProtocolStream* stream)
+{
+ char *str;
+ Arg warg[1];
+ String res_value = NULL;
+ GetValuesEvent *gv_event = (GetValuesEvent *)event;
+
+ /* put the count in the stream */
+ _XEditResPut16(stream, (unsigned int)1);
+
+ /*
+ * Get the resource of the widget asked for by the
+ * resource editor and insert it into the stream
+ */
+ XtSetArg(warg[0], gv_event->name, &res_value);
+
+ if ((str = VerifyWidget(w, &gv_event->widgets[0])) != NULL)
+ _XEditResPutString8(stream, str);
+ else
+ {
+ _XEditresGetStringValues(gv_event->widgets[0].real_widget, warg, 1);
+ if (!res_value)
+ res_value = "NoValue";
+ _XEditResPutString8(stream, res_value);
+ }
+
+ return (NULL);
+}
+
+/************************************************************
+ * Code for inserting values into the protocol stream
+ ************************************************************/
+/*
+ * Function:
+ * InsertWidget
+ *
+ * Parameters:
+ * stream - protocol stream
+ * w - widget to insert
+ *
+ * Description:
+ * Inserts the full parent hierarchy of this widget into the protocol
+ * stream as a widget list.
+ */
+static void
+InsertWidget(ProtocolStream *stream, Widget w)
+{
+ Widget temp;
+ unsigned long *widget_list;
+ register int i, num_widgets;
+
+ for (temp = w, i = 0; temp != 0; temp = XtParent(temp), i++)
+ ;
+
+ num_widgets = i;
+ widget_list = (unsigned long *)XtMalloc(sizeof(unsigned long) * num_widgets);
+
+ /*
+ * Put the widgets into the list
+ * make sure that they are inserted in the list from parent -> child
+ */
+ for (i--, temp = w; temp != NULL; temp = XtParent(temp), i--)
+ widget_list[i] = (unsigned long)temp;
+
+ _XEditResPut16(stream, num_widgets); /* insert number of widgets */
+ for (i = 0; i < num_widgets; i++) /* insert Widgets themselves */
+ _XEditResPut32(stream, widget_list[i]);
+
+ XtFree((char *)widget_list);
+}
+
+/************************************************************
+ * All of the following routines are public
+ ************************************************************/
+/*
+ * Function:
+ * _XEditResPutString8
+ *
+ * Parameters:
+ * stream - stream to insert string into
+ * str - string to insert
+ *
+ * Description:
+ * Inserts a string into the protocol stream.
+ */
+void
+_XEditResPutString8(ProtocolStream *stream, char *str)
+{
+ int i, len = strlen(str);
+
+ _XEditResPut16(stream, len);
+ for (i = 0; i < len; i++, str++)
+ _XEditResPut8(stream, *str);
+}
+
+/*
+ * Function:
+ * _XEditResPut8
+ *
+ * Parameters:
+ * stream - stream to insert string into
+ * value - value to insert
+ *
+ * Description:
+ * Inserts an 8 bit integer into the protocol stream.
+ */
+void
+_XEditResPut8(ProtocolStream *stream, unsigned int value)
+{
+ unsigned char temp;
+
+ if (stream->size >= stream->alloc)
+ {
+ stream->alloc += 100;
+ stream->real_top = (unsigned char *)
+ XtRealloc((char *)stream->real_top, stream->alloc + HEADER_SIZE);
+ stream->top = stream->real_top + HEADER_SIZE;
+ stream->current = stream->top + stream->size;
+ }
+
+ temp = (unsigned char) (value & BYTE_MASK);
+ *((stream->current)++) = temp;
+ (stream->size)++;
+}
+
+/*
+ * Function:
+ * _XEditResPut16
+ *
+ * Arguments:
+ * stream - stream to insert string into
+ * value - value to insert
+ *
+ * Description:
+ * Inserts a 16 bit integer into the protocol stream.
+ */
+void
+_XEditResPut16(ProtocolStream *stream, unsigned int value)
+{
+ _XEditResPut8(stream, (value >> XER_NBBY) & BYTE_MASK);
+ _XEditResPut8(stream, value & BYTE_MASK);
+}
+
+/*
+ * Function:
+ * _XEditResPut32
+ *
+ * Arguments:
+ * stream - stream to insert string into
+ * value - value to insert
+ *
+ * Description:
+ * Inserts a 32 bit integer into the protocol stream.
+ */
+void
+_XEditResPut32(ProtocolStream *stream, unsigned long value)
+{
+ int i;
+
+ for (i = 3; i >= 0; i--)
+ _XEditResPut8(stream, (value >> (XER_NBBY * i)) & BYTE_MASK);
+}
+
+/*
+ * Function:
+ * _XEditResPutWidgetInfo
+ *
+ * Parameters:
+ * stream - stream to insert widget info into
+ * info - info to insert
+ *
+ * Description:
+ * Inserts the widget info into the protocol stream.
+ */
+void
+_XEditResPutWidgetInfo(ProtocolStream *stream, WidgetInfo *info)
+{
+ unsigned int i;
+
+ _XEditResPut16(stream, info->num_widgets);
+ for (i = 0; i < info->num_widgets; i++)
+ _XEditResPut32(stream, info->ids[i]);
+}
+
+/************************************************************
+ * Code for retrieving values from the protocol stream
+ ************************************************************/
+/*
+ * Function:
+ * _XEditResResetStream
+ *
+ * Parameters:
+ * stream - stream to reset
+ *
+ * Description:
+ * Resets the protocol stream.
+ */
+void
+_XEditResResetStream(ProtocolStream *stream)
+{
+ stream->current = stream->top;
+ stream->size = 0;
+ if (stream->real_top == NULL)
+ {
+ stream->real_top = (unsigned char *)
+ XtRealloc((char *)stream->real_top, stream->alloc + HEADER_SIZE);
+ stream->top = stream->real_top + HEADER_SIZE;
+ stream->current = stream->top + stream->size;
+ }
+}
+
+/*
+ * NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
+ *
+ * The only modified field if the "current" field
+ *
+ * The only fields that must be set correctly are the "current", "top"
+ * and "size" fields.
+ */
+/*
+ * Function:
+ * _XEditResGetg8
+ *
+ * Parameters:
+ * stream - protocol stream
+ * value - a pointer to value to return
+ *
+ * Description:
+ * Retrieves an unsigned 8 bit value from the protocol stream.
+ *
+ * Returns:
+ * True if sucessful
+ */
+Bool
+_XEditResGet8(ProtocolStream *stream, unsigned char *value)
+{
+ if (stream->size < (unsigned long)(stream->current - stream->top))
+ return (False);
+
+ *value = *((stream->current)++);
+ return (True);
+}
+
+/*
+ * Function:
+ * _XEditResGet16
+ *
+ * Parameters:
+ * stream - protocol stream
+ * value - pointer to return value
+ *
+ * Description:
+ * Retrieves an unsigned 16 bit value from the protocol stream.
+ *
+ * Returns:
+ * True if sucessful
+ */
+Bool
+_XEditResGet16(ProtocolStream *stream, unsigned short *value)
+{
+ unsigned char temp1, temp2;
+
+ if (!(_XEditResGet8(stream, &temp1) && _XEditResGet8(stream, &temp2)))
+ return (False);
+
+ *value = ((unsigned short)temp1 << XER_NBBY) + (unsigned short)temp2;
+ return (True);
+}
+
+/*
+ * Function:
+ * _XEditResGetSigned16
+ *
+ * Parameters:
+ * stream - protocol stream
+ * value - pointer to return value
+ *
+ * Description:
+ * Retrieves an signed 16 bit value from the protocol stream.
+ *
+ * Returns:
+ * True if sucessful
+ */
+Bool
+_XEditResGetSigned16(ProtocolStream *stream, short *value)
+{
+ unsigned char temp1, temp2;
+
+ if (!(_XEditResGet8(stream, &temp1) && _XEditResGet8(stream, &temp2)))
+ return (False);
+
+ if (temp1 & (1 << (XER_NBBY - 1))) /* If the sign bit is active */
+ {
+ *value = -1; /* store all 1's */
+ *value &= (temp1 << XER_NBBY); /* Now and in the MSB */
+ *value &= temp2; /* and LSB */
+ }
+ else
+ *value = ((unsigned short)temp1 << XER_NBBY) + (unsigned short)temp2;
+
+ return (True);
+}
+
+/*
+ * Function:
+ * _XEditResGet32
+ *
+ * Parameters:
+ * stream - protocol stream
+ * value - pointer to return value
+ *
+ * Description:
+ * Retrieves an unsigned 32 bit value from the protocol stream.
+ *
+ * Returns:
+ * True if sucessful
+ */
+Bool
+_XEditResGet32(ProtocolStream *stream, unsigned long *value)
+{
+ unsigned short temp1, temp2;
+
+ if (!(_XEditResGet16(stream, &temp1) && _XEditResGet16(stream, &temp2)))
+ return (False);
+
+ *value = ((unsigned short)temp1 << (XER_NBBY * 2)) + (unsigned short)temp2;
+ return (True);
+}
+
+/* Function:
+ * _XEditResGetString8
+ *
+ * Parameters:
+ * stream - protocol stream
+ * str - string to retrieve
+ *
+ * Description:
+ * Retrieves an 8 bit string value from the protocol stream.
+ *
+ * Returns:
+ * True if retrieval was successful
+ */
+Bool
+_XEditResGetString8(ProtocolStream *stream, char **str)
+{
+ unsigned short len;
+ register unsigned i;
+
+ if (!_XEditResGet16(stream, &len))
+ return (False);
+
+ *str = XtMalloc(sizeof(char) * (len + 1));
+
+ for (i = 0; i < len; i++)
+ {
+ if (!_XEditResGet8(stream, (unsigned char *)*str + i))
+ {
+ XtFree(*str);
+ *str = NULL;
+ return (False);
+ }
+ }
+ (*str)[i] = '\0';
+
+ return (True);
+}
+
+/*
+ * Function:
+ * _XEditResGetWidgetInfo
+ *
+ * Parameters:
+ * stream - protocol stream
+ * info - widget info struct to store into
+ *
+ * Description:
+ * Retrieves the list of widgets that follow and stores them in the
+ * widget info structure provided.
+ *
+ * Returns:
+ * True if retrieval was successful
+ */
+Bool
+_XEditResGetWidgetInfo(ProtocolStream *stream, WidgetInfo *info)
+{
+ unsigned int i;
+
+ if (!_XEditResGet16(stream, &info->num_widgets))
+ return (False);
+
+ info->ids = (unsigned long *)XtMalloc(sizeof(long) * info->num_widgets);
+
+ for (i = 0; i < info->num_widgets; i++)
+ {
+ if (!_XEditResGet32(stream, info->ids + i))
+ {
+ XtFree((char *)info->ids);
+ info->ids = NULL;
+ return (False);
+ }
+#if defined(LONG64) || defined(WORD64)
+ info->ids[i] |= globals.base_address;
+#endif
+ }
+ return (True);
+}
+
+/************************************************************
+ * Code for Loading the EditresBlock resource
+ ************************************************************/
+/*
+ * Function:
+ * CvStringToBlock
+ *
+ * Parameters:
+ * dpy - display
+ * args - unused
+ * num_args - unused
+ * from_val - value to convert
+ * to_val - where to store
+ * converter_data - unused
+ *
+ * Description:
+ * Converts a string to an editres block value.
+ *
+ * Returns:
+ * True if conversion was sucessful
+ */
+/*ARGSUSED*/
+static Boolean
+CvtStringToBlock(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *from_val, XrmValue *to_val,
+ XtPointer *converter_data)
+{
+ char ptr[16];
+ static EditresBlock block;
+
+ XmuNCopyISOLatin1Lowered(ptr, from_val->addr, sizeof(ptr));
+
+ if (streq(ptr, "none"))
+ block = BlockNone;
+ else if (streq(ptr, "setvalues"))
+ block = BlockSetValues;
+ else if (streq(ptr, "all"))
+ block = BlockAll;
+ else
+ {
+ Cardinal num_params = 1;
+ String params[1];
+
+ params[0] = from_val->addr;
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "CvtStringToBlock", "unknownValue", "EditresError",
+ "Could not convert string \"%s\" to EditresBlock.",
+ params, &num_params);
+ return FALSE;
+ }
+
+ if (to_val->addr != NULL)
+ {
+ if (to_val->size < sizeof(EditresBlock))
+ {
+ to_val->size = sizeof(EditresBlock);
+ return FALSE;
+ }
+ *(EditresBlock *)(to_val->addr) = block;
+ }
+ else
+ to_val->addr = (XtPointer)block;
+
+ to_val->size = sizeof(EditresBlock);
+ return TRUE;
+}
+
+#define XtREditresBlock "EditresBlock"
+/*
+ * Function:
+ * LoadResources
+ *
+ * Parameters:
+ * w - any widget in the tree
+ *
+ * Description:
+ * Loads a global resource the determines of this application should
+ * allow Editres requests.
+ */
+static void
+LoadResources(Widget w)
+{
+ static XtResource resources[] = {
+ {"editresBlock", "EditresBlock", XtREditresBlock, sizeof(EditresBlock),
+ XtOffsetOf(Globals, block), XtRImmediate, (XtPointer)BlockNone}
+ };
+
+ for (; XtParent(w) != NULL; w = XtParent(w))
+ ;
+
+ XtAppSetTypeConverter(XtWidgetToApplicationContext(w),
+ XtRString, XtREditresBlock, CvtStringToBlock,
+ NULL, 0, XtCacheAll, NULL);
+
+ XtGetApplicationResources(w, (XtPointer)&globals, resources,
+ XtNumber(resources), NULL, 0);
+}
+
+/*
+ * Function:
+ * _XEditresGetStringValues
+ *
+ * Parameters:
+ * w - widget
+ * warg - where to store result
+ * numargs - unused
+ */
+/*ARGSUSED*/
+static void
+_XEditresGetStringValues(Widget w, Arg *warg, int numargs)
+{
+ static char buffer[32];
+ XtResourceList res_list;
+ Cardinal num_res;
+ XtResource *res = NULL;
+ long value;
+ Cardinal i;
+ char *string = "";
+ Arg args[1];
+ XrmValue to, from;
+
+ /*
+ * Look for the resource
+ */
+ XtGetResourceList(XtClass(w), &res_list, &num_res);
+ for (i = 0; i < num_res; i++)
+ if (strcmp(res_list[i].resource_name, warg->name) == 0)
+ {
+ res = &res_list[i];
+ break;
+ }
+
+ if (res == NULL && XtParent(w) != NULL)
+ {
+ XtFree((char *)res_list);
+ XtGetConstraintResourceList(XtClass(XtParent(w)), &res_list, &num_res);
+ for (i = 0; i < num_res; i++)
+ if (strcmp(res_list[i].resource_name, warg->name) == 0)
+ {
+ res = &res_list[i];
+ break;
+ }
+ }
+
+ if (res == NULL)
+ {
+ /* Couldn't find resource */
+
+ XtFree((char *)res_list);
+ *(XtPointer *)warg->value = NULL;
+ return;
+ }
+
+ /* try to get the value in the proper size */
+ switch (res->resource_size)
+ {
+#ifdef LONG_64
+ long v8;
+#endif
+ int v4;
+ short v2;
+ char v1;
+
+ case 1:
+ XtSetArg(args[0], res->resource_name, &v1);
+ XtGetValues(w, args, 1);
+ value = (int)v1;
+ break;
+ case 2:
+ XtSetArg(args[0], res->resource_name, &v2);
+ XtGetValues(w, args, 1);
+ value = (int)v2;
+ break;
+ case 4:
+ XtSetArg(args[0], res->resource_name, &v4);
+ XtGetValues(w, args, 1);
+ value = (int)v4;
+ break;
+#ifdef LONG_64
+ case 8:
+ XtSetArg(args[0], res->resource_name, &v8);
+ XtGetValues(w, args, 1);
+ value = (long)v8;
+ break;
+#endif
+ default:
+ fprintf(stderr, "_XEditresGetStringValues: bad size %d\n",
+ res->resource_size);
+ string = "bad size";
+ *(char **)(warg->value) = string;
+ XtFree((char *)res_list);
+ return;
+ }
+
+ /*
+ * If the resource is already String, no conversion needed
+ */
+ if (strcmp(XtRString, res->resource_type) == 0)
+ {
+ if (value == 0)
+ string = "(null)";
+ else
+ string = (char *)value;
+ }
+ else
+ {
+ from.size = res->resource_size;
+ from.addr = (XPointer)&value;
+ to.addr = NULL;
+ to.size = 0;
+
+ if (XtConvertAndStore(w,res->resource_type, &from, XtRString, &to))
+ string = to.addr;
+ else
+ {
+ string = buffer;
+ /*
+ * Conversion failed, fall back to representing it as integer
+ */
+ switch (res->resource_size)
+ {
+ case sizeof(char):
+ XmuSnprintf(buffer, sizeof(buffer), "%d", (int)(value & 0xff));
+ break;
+ case sizeof(short):
+ XmuSnprintf(buffer, sizeof(buffer), "%d", (int)(value & 0xffff));
+ break;
+ case sizeof(int):
+ XmuSnprintf(buffer, sizeof(buffer), "0x%08x", (int)value);
+ break;
+#ifdef LONG_64
+ case sizeof(long):
+ XmuSnprintf(buffer, sizeof(buffer), "0x%016lx", value);
+ break;
+#endif
+ }
+ }
+ }
+
+ if (string == NULL)
+ string = "";
+
+ *(char **)(warg->value) = string;
+ XtFree((char *)res_list);
+}
diff --git a/nx-X11/lib/Xmu/EditresP.h b/nx-X11/lib/Xmu/EditresP.h
new file mode 100644
index 000000000..886205bf2
--- /dev/null
+++ b/nx-X11/lib/Xmu/EditresP.h
@@ -0,0 +1,409 @@
+/* $Xorg: EditresP.h,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/EditresP.h,v 1.5 2001/01/17 19:42:55 dawes Exp $ */
+
+/*
+ * Author: Chris D. Peterson, MIT X Consortium
+ */
+
+/************************************************************
+
+ The Editres Protocol
+
+
+ The Client message sent to the application is:
+
+ ATOM = "ResEditor" --- RES_EDITOR_NAME
+
+ FORMAT = 32 --- RES_EDIT_SEND_EVENT_FORMAT
+
+ l[0] = timestamp
+ l[1] = command atom name
+ l[2] = ident of command
+ l[3] = protocol version number to use
+
+
+
+ The binary protocol has the following format:
+
+ Card8: 8-bit unsingned integer
+ Card16: 16-bit unsingned integer
+ Card32: 32-bit unsingned integer
+ Int16: 16-bit signed integer
+ Window: 32-bit value
+ Widget: 32-bit value
+ String8: ListOfCard8
+
+ [a][b][c] represent an exclusive list of choices.
+
+ All widgets are passed as a list of widgets, containing the
+ full instance heirarch of this widget. The hierarchy is ordered
+ from parent to child. Thus the first element of each list is
+ the root of the widget tree (this makes verifying that the widget
+ still exists, MUCH faster).
+
+ ListOfFoo comprises a list of things in the following format:
+
+ number: Card16
+ <number> things: ????
+
+ This is a synchronous protocol, every request MUST be followed by a
+ reply.
+
+ Request:
+
+ Serial Number: Card8
+ Op Code: Card8 - { SendWidgetTree = 0,
+ SetValues = 1,
+ GetResources = 2,
+ GetGeometry = 3,
+ FindChild = 4,
+ GetValues = 5 }
+ Length: Card32
+ Data:
+
+ Reply:
+
+ Serial Number: Card8
+ Type: Card8 - { Formatted = 0,
+ Unformatted = 1,
+ ProtocolMismatch = 2
+ }
+ Length: Card32
+
+
+ Byte Order:
+
+ All Fields are MSB -> LSB
+
+ Data:
+
+ Formatted:
+
+ The data contains the reply information for the request as
+ specified below if the reply type is "Formatted". The return
+ values for the other reply types are shown below.
+
+ Unformatted:
+
+ Message: String8
+
+ ProtocolMismatch:
+
+ RequestedVersion: Card8
+
+------------------------------------------------------------
+
+ SendWidgetTree:
+
+ --->
+
+ Number of Entries: Card16
+ Entry:
+ widget: ListOfWidgets
+ name: String8
+ class: String8
+ window: Card32
+ toolkit: String8
+
+ Send Widget Tree returns the toolkit type, and a fuly specified list
+ of widgets for each widget in the tree. This is enough information
+ to completely reconstruct the entire widget heirarchy.
+
+ The window return value contains the Xid of the window currently
+ used by this widget. If the widget is unrealized then 0 is returned,
+ and if widget is a non-windowed object a value of 2 is returned.
+
+ SetValues:
+
+ name: String8
+ type: String8
+ value: String8
+ Number of Entries: Card16
+ Entry:
+ widget: ListOfWidgets
+
+ --->
+
+ Number of Entries: Card16
+ Entry:
+ widget: ListOfWidgets
+ message: String8
+
+ SetValues will allow the same resource to be set on a number of
+ widgets. This function will return an error message if the SetValues
+ request caused an Xt error.
+
+ GetValues:
+
+ names: ListOfString8
+ widget: Widget
+
+ --->
+ novalues: ListOfCard16
+ values: ListOfString8
+
+ GetValues will allow a number of resource values to be read
+ on a particular widget. The request specifies the names of
+ the resources wanted and the widget id these resources are
+ from. The reply returns a list of indices from the requests
+ name list of resources for which a value can not be returned.
+ It also returns a list of returned values, in the order of the
+ requests names list, skipping those indices present in novalues.
+
+ GetResources:
+
+ Number of Entries: Card16
+ Entry
+ widget: ListOfWidgets:
+
+ ---->
+
+ Number of Entries: Card16
+ Entry
+ Widget: ListOfWidgets:
+ Error: Bool
+
+ [ Message: String 8 ]
+ [ Number of Resources: Card16
+ Resource:
+ Kind: {normal, constraint}
+ Name: String8
+ Class: String8
+ Type: String8 ]
+
+ GetResource retrieves the kind, name, class and type for every
+ widget passed to it. If an error occured with the resource fetch
+ Error will be set to True for the given widget and a message
+ is returned rather than the resource info.
+
+ GetGeometry:
+
+ Number of Entries: Card16
+ Entry
+ Widget: ListOfWidgets:
+
+ ---->
+
+ Number of Entries: Card16
+ Entry
+ Widget: ListOfWidgets:
+ Error: Bool
+
+ [ message: String 8 ]
+ [ mapped: Boolean
+ X: Int16
+ Y: Int16
+ Width: Card16
+ Height: Card16
+ BorderWidth: Card16 ]
+
+ GetGeometry retreives the mapping state, x, y, width, height
+ and border width for each widget specified. If an error occured
+ with the geometry fetch "Error" will be set to True for the given
+ widget and a message is returned rather than the geometry info.
+ X an Y corrospond to the root coordinates of the upper left corner
+ of the widget (outside the window border).
+
+ FindChild:
+
+ Widget: ListOfWidgets
+ X: Int16
+ Y: Int16
+
+ --->
+
+ Widget: ListOfWidgets
+
+ Find Child returns a descendent of the widget specified that
+ is at the root coordinates specified.
+
+ NOTE:
+
+ The returned widget is undefined if the point is contained in
+ two or more mapped widgets, or in two overlapping Rect objs.
+
+ GetValues:
+
+ names: ListOfString8
+ widget: Widget
+
+ --->
+
+ values: ListOfString8
+
+ GetValues will allow a number of resource values to be read
+ on a particular widget. Currently only InterViews 3.0.1 Styles
+ and their attributes are supported. In addition, the current
+ user interface only supports the return of 1 resource. The ability
+ to specify and return multiple resources is defined for future editres
+ interfaces where some or all of a widgets resource values are returned
+ and displayed at once.
+
+
+************************************************************/
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+#define XER_NBBY 8 /* number of bits in a byte */
+#define BYTE_MASK 255
+
+#define HEADER_SIZE 6
+
+#define EDITRES_IS_OBJECT 2
+#define EDITRES_IS_UNREALIZED 0
+
+/*
+ * Format for atoms
+ */
+#define EDITRES_FORMAT 8
+#define EDITRES_SEND_EVENT_FORMAT 32
+
+/*
+ * Atoms
+ */
+#define EDITRES_NAME "Editres"
+#define EDITRES_COMMAND_ATOM "EditresCommand"
+#define EDITRES_COMM_ATOM "EditresComm"
+#define EDITRES_CLIENT_VALUE "EditresClientVal"
+#define EDITRES_PROTOCOL_ATOM "EditresProtocol"
+
+typedef enum {
+ SendWidgetTree = 0,
+ SetValues = 1,
+ GetResources = 2,
+ GetGeometry = 3,
+ FindChild = 4,
+ GetValues = 5
+} EditresCommand;
+
+typedef enum {
+ NormalResource = 0,
+ ConstraintResource = 1
+} ResourceType;
+
+/*
+ * The type of a resource identifier
+ */
+typedef unsigned char ResIdent;
+
+typedef enum {
+ PartialSuccess = 0,
+ Failure = 1,
+ ProtocolMismatch = 2
+} EditResError;
+
+typedef struct _WidgetInfo {
+ unsigned short num_widgets;
+ unsigned long *ids;
+ Widget real_widget;
+} WidgetInfo;
+
+typedef struct _ProtocolStream {
+ unsigned long size, alloc;
+ unsigned char *real_top, *top, *current;
+} ProtocolStream;
+
+/************************************************************
+ * Function definitions for reading and writing protocol requests
+ ************************************************************/
+_XFUNCPROTOBEGIN
+
+void _XEditResPutString8
+(
+ ProtocolStream *stream,
+ char *str
+ );
+
+void _XEditResPut8
+(
+ ProtocolStream *stream,
+ unsigned int value
+ );
+
+void _XEditResPut16
+(
+ ProtocolStream *stream,
+ unsigned int value
+ );
+
+void _XEditResPut32
+(
+ ProtocolStream *stream,
+ unsigned long value
+ );
+
+void _XEditResPutWidgetInfo
+(
+ ProtocolStream *stream,
+ WidgetInfo *info
+ );
+
+void _XEditResResetStream
+(
+ ProtocolStream *stream
+ );
+
+Bool _XEditResGet8
+(
+ ProtocolStream *stream,
+ unsigned char *value
+ );
+
+Bool _XEditResGet16
+(
+ ProtocolStream *stream,
+ unsigned short *value
+ );
+
+Bool _XEditResGetSigned16
+(
+ ProtocolStream *stream,
+ short *value
+ );
+
+Bool _XEditResGet32
+(
+ ProtocolStream *stream,
+ unsigned long *value
+ );
+
+Bool _XEditResGetString8
+(
+ ProtocolStream *stream,
+ char **str
+ );
+
+Bool _XEditResGetWidgetInfo
+(
+ ProtocolStream *stream,
+ WidgetInfo *info
+ );
+
+_XFUNCPROTOEND
diff --git a/nx-X11/lib/Xmu/Error.h b/nx-X11/lib/Xmu/Error.h
new file mode 100644
index 000000000..f992930ec
--- /dev/null
+++ b/nx-X11/lib/Xmu/Error.h
@@ -0,0 +1,59 @@
+/* $Xorg: Error.h,v 1.5 2001/02/09 02:03:52 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/Error.h,v 1.5 2001/01/17 19:42:55 dawes Exp $ */
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_ERROR_H_
+#define _XMU_ERROR_H_
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+int XmuPrintDefaultErrorMessage
+(
+ Display *dpy,
+ XErrorEvent *event,
+ FILE *fp
+ );
+
+int XmuSimpleErrorHandler
+(
+ Display *dpy,
+ XErrorEvent *errorp
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_ERROR_H_ */
diff --git a/nx-X11/lib/Xmu/ExtAgent.c b/nx-X11/lib/Xmu/ExtAgent.c
new file mode 100644
index 000000000..27955678f
--- /dev/null
+++ b/nx-X11/lib/Xmu/ExtAgent.c
@@ -0,0 +1,46 @@
+/* $Xorg: ExtAgent.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/ExtAgent.c,v 1.6 2001/01/17 19:42:55 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/ExtAgent.h>
+
+/* ARGSUSED */
+void
+XmuRegisterExternalAgent(Widget w, XtPointer data,
+ XEvent *event, Boolean *cont)
+{
+/*
+* This is a stub. Writers of protocol libraries
+* that want to add protocol to Xaw, such as RAP, will reimplement this
+* procedure in their own libraries.
+*/
+}
diff --git a/nx-X11/lib/Xmu/ExtAgent.h b/nx-X11/lib/Xmu/ExtAgent.h
new file mode 100644
index 000000000..b0caf3699
--- /dev/null
+++ b/nx-X11/lib/Xmu/ExtAgent.h
@@ -0,0 +1,44 @@
+/* $Xorg: ExtAgent.h,v 1.5 2001/02/09 02:03:52 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/ExtAgent.h,v 1.5 2001/01/17 19:42:55 dawes Exp $ */
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+extern void XmuRegisterExternalAgent
+(
+ Widget w,
+ XtPointer data,
+ XEvent *event,
+ Boolean *cont
+ );
+
+_XFUNCPROTOEND
+
diff --git a/nx-X11/lib/Xmu/FToCback.c b/nx-X11/lib/Xmu/FToCback.c
new file mode 100644
index 000000000..6da4826f7
--- /dev/null
+++ b/nx-X11/lib/Xmu/FToCback.c
@@ -0,0 +1,48 @@
+/* $Xorg: FToCback.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/FToCback.c,v 1.6 2001/01/17 19:42:55 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Converters.h>
+
+/* ARGSUSED */
+void
+XmuCvtFunctionToCallback(XrmValue *args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static XtCallbackRec callback[2]; /* K&R: initialized to NULL */
+ static XtCallbackList callback_list = callback;
+
+ callback[0].callback = *(XtCallbackProc *)fromVal->addr;
+
+ toVal->size = sizeof(XtCallbackList);
+ toVal->addr = (XPointer)&callback_list;
+}
diff --git a/nx-X11/lib/Xmu/GetHost.c b/nx-X11/lib/Xmu/GetHost.c
new file mode 100644
index 000000000..91673b86c
--- /dev/null
+++ b/nx-X11/lib/Xmu/GetHost.c
@@ -0,0 +1,86 @@
+/* $Xorg: GetHost.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/GetHost.c,v 3.7 2001/07/25 15:04:50 dawes Exp $ */
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ *
+ * _XGetHostname - similar to gethostname but allows special processing.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xosdefs.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+
+#ifdef USG
+#define NEED_UTSNAME
+#endif
+
+#ifdef NEED_UTSNAME
+#include <sys/utsname.h>
+#endif
+
+#include <X11/Xmu/SysUtil.h>
+
+int
+XmuGetHostname(char *buf, int maxlen)
+{
+ int len;
+#ifdef WIN32
+ static WSADATA wsadata;
+
+ if (!wsadata.wVersion && WSAStartup(MAKEWORD(1,1), &wsadata))
+ return -1;
+#endif
+
+#ifdef NEED_UTSNAME
+ /*
+ * same host name crock as in server and xinit.
+ */
+ struct utsname name;
+
+ uname (&name);
+ len = strlen (name.nodename);
+ if (len >= maxlen) len = maxlen - 1;
+ strncpy (buf, name.nodename, len);
+ buf[len] = '\0';
+#else
+ buf[0] = '\0';
+ (void) gethostname (buf, maxlen);
+ buf [maxlen - 1] = '\0';
+ len = strlen(buf);
+#endif /* hpux */
+ return len;
+}
diff --git a/nx-X11/lib/Xmu/GrayPixmap.c b/nx-X11/lib/Xmu/GrayPixmap.c
new file mode 100644
index 000000000..478269f8a
--- /dev/null
+++ b/nx-X11/lib/Xmu/GrayPixmap.c
@@ -0,0 +1,139 @@
+/* $Xorg: GrayPixmap.c,v 1.4 2001/02/09 02:03:52 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xmu/GrayPixmap.c,v 1.5 2001/01/17 19:42:55 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Drawing.h>
+
+typedef struct _PixmapCache {
+ Screen *screen;
+ Pixmap pixmap;
+ Pixel foreground, background;
+ unsigned int depth;
+ int ref_count;
+ struct _PixmapCache *next;
+ } CacheEntry;
+
+static CacheEntry *pixmapCache = NULL;
+
+
+
+Pixmap
+XmuCreateStippledPixmap(Screen *screen, Pixel fore, Pixel back,
+ unsigned int depth)
+/*
+ * Creates a stippled pixmap of specified depth
+ * caches these so that multiple requests share the pixmap
+ */
+{
+ register Display *display = DisplayOfScreen(screen);
+ CacheEntry *cachePtr;
+ Pixmap stippled_pixmap;
+ static unsigned char pixmap_bits[] = {
+ 0x02, 0x01,
+ };
+
+/*
+ * Creates a stippled pixmap of depth DefaultDepth(screen)
+ * caches these so that multiple requests share the pixmap
+ */
+
+#define pixmap_width 2
+#define pixmap_height 2
+
+ /* see if we already have a pixmap suitable for this screen */
+ for (cachePtr = pixmapCache; cachePtr; cachePtr = cachePtr->next) {
+ if (cachePtr->screen == screen && cachePtr->foreground == fore &&
+ cachePtr->background == back && cachePtr->depth == depth)
+ return( cachePtr->ref_count++, cachePtr->pixmap );
+ }
+
+ stippled_pixmap = XCreatePixmapFromBitmapData (display,
+ RootWindowOfScreen(screen), (char *)pixmap_bits,
+ pixmap_width, pixmap_height, fore, back, depth);
+
+ /* and insert it at the head of the cache */
+ cachePtr = XtNew(CacheEntry);
+ cachePtr->screen = screen;
+ cachePtr->foreground = fore;
+ cachePtr->background = back;
+ cachePtr->depth = depth;
+ cachePtr->pixmap = stippled_pixmap;
+ cachePtr->ref_count = 1;
+ cachePtr->next = pixmapCache;
+ pixmapCache = cachePtr;
+
+ return( stippled_pixmap );
+}
+
+void
+XmuReleaseStippledPixmap(Screen *screen, Pixmap pixmap)
+{
+ register Display *display = DisplayOfScreen(screen);
+ CacheEntry *cachePtr, **prevP;
+ for (prevP = &pixmapCache, cachePtr = pixmapCache; cachePtr;) {
+ if (cachePtr->screen == screen && cachePtr->pixmap == pixmap) {
+ if (--cachePtr->ref_count == 0) {
+ XFreePixmap( display, pixmap );
+ *prevP = cachePtr->next;
+ XtFree( (char*)cachePtr );
+ break;
+ }
+ }
+ prevP = &cachePtr->next;
+ cachePtr = *prevP;
+ }
+}
diff --git a/nx-X11/lib/Xmu/Imakefile b/nx-X11/lib/Xmu/Imakefile
new file mode 100644
index 000000000..5d3ac5bb5
--- /dev/null
+++ b/nx-X11/lib/Xmu/Imakefile
@@ -0,0 +1,176 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:02 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/Xmu/Imakefile,v 1.7 1999/04/28 15:04:50 dawes Exp $
+
+#define DoNormalLib NormalLibXmu
+#define DoSharedLib SharedLibXmu
+#define DoExtraLib SharedLibXmu
+#define DoDebugLib DebugLibXmu
+#define DoProfileLib ProfileLibXmu
+#define HasSharedData YES
+#define LibName Xmu
+#define SoRev SOXMUREV
+#define IncSubdir X11
+#define IncSubSubdir Xmu
+
+#include <Threads.tmpl>
+
+#ifdef SharedXmuReqs
+REQUIREDLIBS = SharedXmuReqs
+#endif
+
+/* Since people link in Xmu without Xt, we avoid references to string data. */
+#if HasSharedLibraries
+ SHAREDCODEDEF = SharedCodeDef -DXTSTRINGDEFINES
+#endif
+ LINTLIBS = $(LINTXLIB)
+
+#if HasSnprintf
+ MISC_DEFINES = -DHAS_SNPRINTF
+#else
+ MISC_INCLUDES = -I$(LIBSRC)/misc
+#endif
+
+ DEFINES = $(MISC_DEFINES)
+ INCLUDES = $(MISC_INCLUDES)
+
+#ifdef OsNameDefines
+OS_NAME_DEFINES = OsNameDefines
+#endif
+ CSSDEFS = $(OS_NAME_DEFINES) $(CONNECTION_FLAGS)
+ BITDEFS = -DBITMAPDIR=\"$(INCDIR)/X11/bitmaps\"
+
+HEADERS = \
+ Xmu.h \
+ Atoms.h \
+ CharSet.h \
+ CloseHook.h \
+ Converters.h \
+ CurUtil.h \
+ CvtCache.h \
+ DisplayQue.h \
+ Drawing.h \
+ Editres.h \
+ EditresP.h \
+ Error.h \
+ ExtAgent.h \
+ Initer.h \
+ Lookup.h \
+ Misc.h \
+ StdSel.h \
+ StdCmap.h \
+ SysUtil.h \
+ WidgetNode.h \
+ WinUtil.h \
+ Xct.h
+
+
+SRCS = \
+ AllCmap.c \
+ Atoms.c \
+ ClientWin.c \
+ Clip.c \
+ CloseHook.c \
+ CmapAlloc.c \
+ CrCmap.c \
+ CrPixFBit.c \
+ CursorName.c \
+ CvtCache.c \
+ CvtStdSel.c \
+ DefErrMsg.c \
+ DelCmap.c \
+ DisplayQue.c \
+ Distinct.c \
+ DrawLogo.c \
+ DrRndRect.c \
+ EditresCom.c \
+ ExtAgent.c \
+ FToCback.c \
+ GetHost.c \
+ GrayPixmap.c \
+ Initer.c \
+ LocBitmap.c \
+ Lookup.c \
+ LookupCmap.c \
+ Lower.c \
+ RdBitF.c \
+ ScrOfWin.c \
+ ShapeWidg.c \
+ StdCmap.c \
+ StrToBS.c \
+ StrToBmap.c \
+ StrToCurs.c \
+ StrToGrav.c \
+ StrToJust.c \
+ StrToLong.c \
+ StrToOrnt.c \
+ StrToShap.c \
+ StrToWidg.c \
+ UpdMapHint.c \
+ VisCmap.c \
+ WidgetNode.c \
+ Xct.c \
+ sharedlib.c
+
+#if SharedDataSeparation
+UNSHAREDOBJS = sharedlib.o
+#endif
+
+OBJS = \
+ AllCmap.o \
+ Atoms.o \
+ ClientWin.o \
+ Clip.o \
+ CloseHook.o \
+ CmapAlloc.o \
+ CrCmap.o \
+ CrPixFBit.o \
+ CursorName.o \
+ CvtCache.o \
+ CvtStdSel.o \
+ DefErrMsg.o \
+ DelCmap.o \
+ DisplayQue.o \
+ Distinct.o \
+ DrawLogo.o \
+ DrRndRect.o \
+ EditresCom.o \
+ ExtAgent.o \
+ FToCback.o \
+ GetHost.o \
+ GrayPixmap.o \
+ Initer.o \
+ LocBitmap.o \
+ Lookup.o \
+ LookupCmap.o \
+ Lower.o \
+ RdBitF.o \
+ ScrOfWin.o \
+ ShapeWidg.o \
+ StdCmap.o \
+ StrToBS.o \
+ StrToBmap.o \
+ StrToCurs.o \
+ StrToGrav.o \
+ StrToJust.o \
+ StrToLong.o \
+ StrToOrnt.o \
+ StrToShap.o \
+ StrToWidg.o \
+ UpdMapHint.o \
+ VisCmap.o \
+ WidgetNode.o \
+ Xct.o
+
+#include <Library.tmpl>
+
+SpecialCLibObjectRule(CvtStdSel,$(ICONFIGFILES),$(CSSDEFS))
+SpecialCLibObjectRule(LocBitmap,$(ICONFIGFILES),$(BITDEFS))
+#if DoSharedLib && SharedDataSeparation
+SpecialCObjectRule(sharedlib,$(_NOOP_),$(SHLIBDEF))
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/Xmu/Initer.c b/nx-X11/lib/Xmu/Initer.c
new file mode 100644
index 000000000..f18492f69
--- /dev/null
+++ b/nx-X11/lib/Xmu/Initer.c
@@ -0,0 +1,117 @@
+/* $Xorg: Initer.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
+
+/*
+
+Copyright 1988, 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/Initer.c,v 1.6 2001/01/17 19:42:56 dawes Exp $ */
+
+/* Created By: Chris D. Peterson
+ * MIT X Consortium
+ * Date: May 8, 1989
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Initer.h>
+
+struct InitializerList {
+ XmuInitializerProc function; /* function to call */
+ XPointer data; /* Data to pass the function. */
+ XtAppContext * app_con_list; /* a null terminated list of app_contexts. */
+};
+
+/*
+ * Prototypes
+ */
+static Bool AddToAppconList(XtAppContext**, XtAppContext);
+
+static struct InitializerList * init_list = NULL;
+static Cardinal init_list_length = 0;
+
+void
+XmuAddInitializer(XmuInitializerProc func, XPointer data)
+{
+ init_list_length++;
+ init_list = (struct InitializerList *) XtRealloc( (char *) init_list,
+ (sizeof(struct InitializerList) *
+ init_list_length) );
+
+ init_list[init_list_length - 1].function = func;
+ init_list[init_list_length - 1].data = data;
+ init_list[init_list_length - 1].app_con_list = NULL;
+}
+
+void
+XmuCallInitializers(XtAppContext app_con)
+{
+ unsigned i;
+
+ for (i = 0 ; i < init_list_length ; i++) {
+ if (AddToAppconList(&(init_list[i].app_con_list), app_con))
+ (init_list[i].function) (app_con, init_list[i].data);
+ }
+}
+
+/*
+ * Function:
+ * AddToAppconList
+ *
+ * Parameters:
+ * app_list - NULL terminated list of application contexts
+ * app_con - application context to test
+ *
+ * Description:
+ * Adds an action to the application context list and
+ * returns True, if this app_con is already on the list then
+ * it is NOT added and False is returned.
+ *
+ * Returns:
+ * True if not found, False if found
+ */
+static Bool
+AddToAppconList(XtAppContext **app_list, XtAppContext app_con)
+{
+ int i;
+ XtAppContext *local_list;
+
+ i = 0;
+ local_list = *app_list;
+ if (*app_list != NULL) {
+ for ( ; *local_list != NULL ; i++, local_list++) {
+ if (*local_list == app_con)
+ return (False);
+ }
+ }
+
+ *app_list = (XtAppContext *) XtRealloc((char *)(*app_list),
+ sizeof(XtAppContext *) * (i + 2) );
+ (*app_list)[i++] = app_con;
+ (*app_list)[i] = NULL;
+
+ return (True);
+}
+
diff --git a/nx-X11/lib/Xmu/Initer.h b/nx-X11/lib/Xmu/Initer.h
new file mode 100644
index 000000000..5e870af8c
--- /dev/null
+++ b/nx-X11/lib/Xmu/Initer.h
@@ -0,0 +1,58 @@
+/* $Xorg: Initer.h,v 1.5 2001/02/09 02:03:52 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/Initer.h,v 1.5 2001/01/17 19:42:56 dawes Exp $ */
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_INITER_H_
+#define _XMU_INITER_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+typedef void (*XmuInitializerProc)(XtAppContext app_context, XPointer data);
+
+_XFUNCPROTOBEGIN
+
+void XmuCallInitializers
+(
+ XtAppContext app_context
+ );
+
+void XmuAddInitializer
+(
+ XmuInitializerProc func,
+ XPointer data
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_INITER_H_ */
diff --git a/nx-X11/lib/Xmu/LocBitmap.c b/nx-X11/lib/Xmu/LocBitmap.c
new file mode 100644
index 000000000..112f3cff4
--- /dev/null
+++ b/nx-X11/lib/Xmu/LocBitmap.c
@@ -0,0 +1,272 @@
+/* $Xorg: LocBitmap.c,v 1.7 2001/02/09 02:03:52 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/LocBitmap.c,v 3.9 2001/12/14 19:55:47 dawes Exp $ */
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <stdlib.h>
+#include <string.h>
+#include <X11/Xresource.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/CvtCache.h>
+#include <X11/Xmu/Drawing.h>
+#include <X11/Xmu/SysUtil.h>
+
+#ifndef X_NOT_POSIX
+#ifdef _POSIX_SOURCE
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif
+#endif /* X_NOT_POSIX */
+#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 /* PATH_MAX */
+
+/*
+ * Prototypes
+ */
+static char **split_path_string(char*);
+
+/*
+ * XmuLocateBitmapFile - read a bitmap file using the normal defaults
+ */
+
+Pixmap
+XmuLocateBitmapFile(Screen *screen, _Xconst char *name, char *srcname,
+ int srcnamelen, int *widthp, int *heightp,
+ int *xhotp, int *yhotp)
+{
+ return XmuLocatePixmapFile (screen, name,
+ (unsigned long) 1, (unsigned long) 0,
+ (unsigned int) 1, srcname, srcnamelen,
+ widthp, heightp, xhotp, yhotp);
+}
+
+
+/*
+ * version that reads pixmap data as well as bitmap data
+ */
+Pixmap
+XmuLocatePixmapFile(Screen *screen, _Xconst char *name,
+ unsigned long fore, unsigned long back,
+ unsigned int depth,
+ char *srcname, int srcnamelen,
+ int *widthp, int *heightp, int *xhotp, int *yhotp)
+{
+
+#ifndef BITMAPDIR
+#define BITMAPDIR "/usr/include/X11/bitmaps"
+#endif
+
+ Display *dpy = DisplayOfScreen (screen);
+ Window root = RootWindowOfScreen (screen);
+ Bool try_plain_name = True;
+ XmuCvtCache *cache = _XmuCCLookupDisplay (dpy);
+ char **file_paths = (char **) NULL;
+ char filename[PATH_MAX];
+#if 0
+ char* bitmapdir = BITMAPDIR;
+#endif
+ unsigned int width, height;
+ int xhot, yhot;
+ int i;
+
+ /*
+ * look in cache for bitmap path
+ */
+ if (cache) {
+ if (!cache->string_to_bitmap.bitmapFilePath) {
+ XrmName xrm_name[2];
+ XrmClass xrm_class[2];
+ XrmRepresentation rep_type;
+ XrmValue value;
+
+ xrm_name[0] = XrmPermStringToQuark ("bitmapFilePath");
+ xrm_name[1] = NULLQUARK;
+ xrm_class[0] = XrmPermStringToQuark ("BitmapFilePath");
+ xrm_class[1] = NULLQUARK;
+ if (!XrmGetDatabase(dpy)) {
+ /* what a hack; need to initialize it */
+ (void) XGetDefault (dpy, "", "");
+ }
+ if (XrmQGetResource (XrmGetDatabase(dpy), xrm_name, xrm_class,
+ &rep_type, &value) &&
+ rep_type == XrmPermStringToQuark("String")) {
+ cache->string_to_bitmap.bitmapFilePath =
+ split_path_string (value.addr);
+ }
+ }
+ file_paths = cache->string_to_bitmap.bitmapFilePath;
+ }
+
+ /*
+ * Search order:
+ * 1. name if it begins with / or ./
+ * 2. "each prefix in file_paths"/name
+ * 3. BITMAPDIR/name
+ * 4. name if didn't begin with / or .
+ */
+
+ for (i = 1; i <= 4; i++) {
+ char *fn = filename;
+ Pixmap pixmap;
+ unsigned char *data;
+
+ switch (i) {
+ case 1:
+#ifndef __UNIXOS2__
+ if (!(name[0] == '/' || ((name[0] == '.') && name[1] == '/')))
+#else
+ if (!(name[0] == '/' || (name[0] == '.' && name[1] == '/') ||
+ (isalpha(name[0]) && name[1] == ':')))
+#endif
+ continue;
+ fn = (char *) name;
+ try_plain_name = False;
+ break;
+ case 2:
+ if (file_paths && *file_paths) {
+ XmuSnprintf(filename, sizeof(filename),
+ "%s/%s", *file_paths, name);
+ file_paths++;
+ i--;
+ break;
+ }
+ continue;
+ case 3:
+ XmuSnprintf(filename, sizeof(filename), "%s/%s", BITMAPDIR, name);
+ break;
+ case 4:
+ if (!try_plain_name) continue;
+ fn = (char *) name;
+ break;
+ }
+
+ data = NULL;
+ pixmap = None;
+#ifdef __UNIXOS2__
+ fn = (char*)__XOS2RedirRoot(fn);
+#endif
+ if (XmuReadBitmapDataFromFile (fn, &width, &height, &data,
+ &xhot, &yhot) == BitmapSuccess) {
+ pixmap = XCreatePixmapFromBitmapData (dpy, root, (char *) data,
+ width, height,
+ fore, back, depth);
+ XFree ((char *)data);
+ }
+
+ if (pixmap) {
+ if (widthp) *widthp = (int)width;
+ if (heightp) *heightp = (int)height;
+ if (xhotp) *xhotp = xhot;
+ if (yhotp) *yhotp = yhot;
+ if (srcname && srcnamelen > 0) {
+ strncpy (srcname, fn, srcnamelen - 1);
+ srcname[srcnamelen - 1] = '\0';
+ }
+ return pixmap;
+ }
+ }
+
+ return None;
+}
+
+
+/*
+ * split_path_string - split a colon-separated list into its constituent
+ * parts; to release, free list[0] and list.
+ */
+static char **
+split_path_string(register char *src)
+{
+ int nelems = 1;
+ register char *dst;
+ char **elemlist, **elem;
+
+ /* count the number of elements */
+ for (dst = src; *dst; dst++) if (*dst == ':') nelems++;
+
+ /* get memory for everything */
+ dst = (char *) malloc (dst - src + 1);
+ if (!dst) return NULL;
+ elemlist = (char **) calloc ((nelems + 1), sizeof (char *));
+ if (!elemlist) {
+ free (dst);
+ return NULL;
+ }
+
+ /* copy to new list and walk up nulling colons and setting list pointers */
+ strcpy (dst, src);
+ for (elem = elemlist, src = dst; *src; src++) {
+ if (*src == ':') {
+ *elem++ = dst;
+ *src = '\0';
+ dst = src + 1;
+ }
+ }
+ *elem = dst;
+
+ return elemlist;
+}
+
+
+void
+_XmuStringToBitmapInitCache(register XmuCvtCache *c)
+{
+ c->string_to_bitmap.bitmapFilePath = NULL;
+}
+
+void
+_XmuStringToBitmapFreeCache(register XmuCvtCache *c)
+{
+ if (c->string_to_bitmap.bitmapFilePath) {
+ if (c->string_to_bitmap.bitmapFilePath[0])
+ free (c->string_to_bitmap.bitmapFilePath[0]);
+ free ((char *) (c->string_to_bitmap.bitmapFilePath));
+ }
+}
diff --git a/nx-X11/lib/Xmu/Lookup.c b/nx-X11/lib/Xmu/Lookup.c
new file mode 100644
index 000000000..27676c1da
--- /dev/null
+++ b/nx-X11/lib/Xmu/Lookup.c
@@ -0,0 +1,279 @@
+/* $Xorg: Lookup.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+Copyright 1988, 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/Lookup.c,v 3.7 2001/01/17 19:42:56 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xmu/Lookup.h>
+
+#define XK_LATIN1
+#define XK_PUBLISHING
+#include <X11/keysymdef.h>
+
+/* bit (1<<i) means character is in codeset i */
+static unsigned short _Xconst latin1[128] =
+ {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x10ee, 0x0000, 0x1000, 0x1084, 0x102e, 0x1000, 0x1080, 0x108e, /* 10 */
+ 0x108e, 0x1080, 0x0000, 0x1080, 0x1080, 0x10ee, 0x1000, 0x1008,
+ 0x108e, 0x1080, 0x1084, 0x1084, 0x108e, 0x1004, 0x1000, 0x1084, /* 11 */
+ 0x100e, 0x1000, 0x0000, 0x1080, 0x1000, 0x1084, 0x1000, 0x0000,
+ 0x0004, 0x000e, 0x000e, 0x0008, 0x000e, 0x0008, 0x0008, 0x0006, /* 12 */
+ 0x0004, 0x000e, 0x0004, 0x000e, 0x0004, 0x000e, 0x000e, 0x0004,
+ 0x0000, 0x0004, 0x0004, 0x0006, 0x000e, 0x0008, 0x000e, 0x000e, /* 13 */
+ 0x0008, 0x0004, 0x000e, 0x000c, 0x000e, 0x0002, 0x0000, 0x000e,
+ 0x0004, 0x000e, 0x000e, 0x0008, 0x000e, 0x0008, 0x0008, 0x0006, /* 14 */
+ 0x0004, 0x000e, 0x0004, 0x000e, 0x0004, 0x000e, 0x000e, 0x0004,
+ 0x0000, 0x0004, 0x0004, 0x0006, 0x000e, 0x0008, 0x000e, 0x000e, /* 15 */
+ 0x0008, 0x0004, 0x000e, 0x000c, 0x000e, 0x0002, 0x0000, 0x0000};
+
+/* bit (1<<i) means character is in codeset i */
+static unsigned short _Xconst latin2[128] =
+ {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0008, 0x0004, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 10 */
+ 0x0000, 0x0008, 0x0004, 0x0000, 0x0000, 0x0000, 0x0008, 0x0004,
+ 0x0000, 0x0008, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0008, /* 11 */
+ 0x0000, 0x0008, 0x0004, 0x0000, 0x0000, 0x0000, 0x0008, 0x0004,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 12 */
+ 0x0008, 0x0000, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 13 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 14 */
+ 0x0008, 0x0000, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 15 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x000c};
+
+/* maps Cyrillic keysyms to 8859-5 */
+static unsigned char _Xconst cyrillic[128] =
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf2, 0xf3, 0xf1, 0xf4, 0xf5, 0xf6, 0xf7, /* 10 */
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0xfe, 0xff,
+ 0xf0, 0xa2, 0xa3, 0xa1, 0xa4, 0xa5, 0xa6, 0xa7, /* 11 */
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0x00, 0xae, 0xaf,
+ 0xee, 0xd0, 0xd1, 0xe6, 0xd4, 0xd5, 0xe4, 0xd3, /* 12 */
+ 0xe5, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde,
+ 0xdf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0xd6, 0xd2, /* 13 */
+ 0xec, 0xeb, 0xd7, 0xe8, 0xed, 0xe9, 0xe7, 0xea,
+ 0xce, 0xb0, 0xb1, 0xc6, 0xb4, 0xb5, 0xc4, 0xb3, /* 14 */
+ 0xc5, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe,
+ 0xbf, 0xcf, 0xc0, 0xc1, 0xc2, 0xc3, 0xb6, 0xb2, /* 15 */
+ 0xcc, 0xcb, 0xb7, 0xc8, 0xcd, 0xc9, 0xc7, 0xca};
+
+/* maps Greek keysyms to 8859-7 */
+static unsigned char _Xconst greek[128] =
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xb6, 0xb8, 0xb9, 0xba, 0xda, 0x00, 0xbc, /* 10 */
+ 0xbe, 0xdb, 0x00, 0xbf, 0x00, 0x00, 0xb5, 0xaf,
+ 0x00, 0xdc, 0xdd, 0xde, 0xdf, 0xfa, 0xc0, 0xfc, /* 11 */
+ 0xfd, 0xfb, 0xe0, 0xfe, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 12 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd3, 0x00, 0xd4, 0xd5, 0xd6, 0xd7, /* 13 */
+ 0xd8, 0xd9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 14 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf3, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7, /* 15 */
+ 0xf8, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+#define sLatin1 (unsigned long)0
+#define sLatin2 (unsigned long)1
+#define sLatin3 (unsigned long)2
+#define sLatin4 (unsigned long)3
+#define sKana (unsigned long)4
+#define sX0201 (unsigned long)0x01000004
+#define sArabic (unsigned long)5
+#define sCyrillic (unsigned long)6
+#define sGreek (unsigned long)7
+#define sAPL (unsigned long)11
+#define sHebrew (unsigned long)12
+
+int
+XmuLookupString(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status,
+ unsigned long keysymSet)
+{
+ int count;
+ KeySym symbol;
+ unsigned long kset;
+
+ kset = keysymSet & 0xffffff;
+ count = XLookupString(event, (char *)buffer, nbytes, &symbol, status);
+ if (keysym) *keysym = symbol;
+ if ((nbytes == 0) || (symbol == NoSymbol)) {
+ /* nothing */
+ } else if ((count == 0) && ((symbol >> 8) == kset)) {
+ count = 1;
+ switch (keysymSet) {
+ case sKana:
+ buffer[0] = (symbol & 0xff);
+ if (buffer[0] == 0x7e)
+ count = 0;
+ break;
+ case sCyrillic:
+ buffer[0] = cyrillic[symbol & 0x7f];
+ break;
+ case sGreek:
+ buffer[0] = greek[symbol & 0x7f];
+ if (!buffer[0])
+ count = 0;
+ break;
+ default:
+ buffer[0] = (symbol & 0xff);
+ break;
+ }
+ } else if ((keysymSet != 0) && (count == 1) &&
+ (((unsigned char *)buffer)[0] == symbol) &&
+ (symbol & 0x80) &&
+ !(latin1[symbol & 0x7f] & (1 << kset))) {
+ if ((keysymSet == sHebrew) && (symbol == XK_multiply))
+ buffer[0] = 0xaa;
+ else if ((keysymSet == sHebrew) && (symbol == XK_division))
+ buffer[0] = 0xba;
+ else if ((keysymSet == sCyrillic) && (symbol == XK_section))
+ buffer[0] = 0xfd;
+ else if ((keysymSet == sX0201) && (symbol == XK_yen))
+ buffer[0] = 0x5c;
+ else
+ count = 0;
+ } else if (count != 0) {
+ if ((keysymSet == sX0201) &&
+ ((symbol == XK_backslash) || (symbol == XK_asciitilde)))
+ count = 0;
+ } else if (((symbol >> 8) == sLatin2) &&
+ (symbol & 0x80) && (latin2[symbol & 0x7f] & (1 << kset))) {
+ buffer[0] = (symbol & 0xff);
+ count = 1;
+ } else if ((keysymSet == sGreek) &&
+ ((symbol == XK_leftsinglequotemark) ||
+ (symbol == XK_rightsinglequotemark))) {
+ buffer[0] = symbol - (XK_leftsinglequotemark - 0xa1);
+ count = 1;
+ }
+ return count;
+}
+
+/* produces ISO 8859-1 encoding plus ASCII control */
+int
+XmuLookupLatin1(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XLookupString(event, (char *)buffer, nbytes, keysym, status);
+}
+
+/* produces ISO 8859-2 encoding plus ASCII control */
+int
+XmuLookupLatin2(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin2);
+}
+
+/* produces ISO 8859-3 encoding plus ASCII control */
+int
+XmuLookupLatin3(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin3);
+}
+
+/* produces ISO 8859-4 encoding plus ASCII control */
+int
+XmuLookupLatin4(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin4);
+}
+
+/* produces ISO 8859-1 GL plus Katakana plus ASCII control */
+int
+XmuLookupKana(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sKana);
+}
+
+/* produces JIS X0201-1976 (8-bit) */
+int
+XmuLookupJISX0201(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sX0201);
+}
+
+/* produces ISO 8859-6 encoding plus ASCII control */
+int
+XmuLookupArabic(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sArabic);
+}
+
+/* produces ISO/IEC 8859-5 encoding plus ASCII control */
+int
+XmuLookupCyrillic(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sCyrillic);
+}
+
+/* produces ISO 8859-7 encoding plus ASCII control */
+int
+XmuLookupGreek(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sGreek);
+}
+
+/* XXX this character set needs work */
+
+int
+XmuLookupAPL(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sAPL);
+}
+
+/* produces ISO 8859-8 encoding plus ASCII control */
+int
+XmuLookupHebrew(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sHebrew);
+}
diff --git a/nx-X11/lib/Xmu/Lookup.h b/nx-X11/lib/Xmu/Lookup.h
new file mode 100644
index 000000000..3699a2719
--- /dev/null
+++ b/nx-X11/lib/Xmu/Lookup.h
@@ -0,0 +1,128 @@
+/*
+ * $XFree86$
+ */
+
+/************************************************************
+
+Copyright 1999 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+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 ABOVE LISTED COPYRIGHT HOLDER(S) 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(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#ifndef included_xmu_lookup_h
+#define included_xmu_lookup_h 1
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+extern int XmuLookupString(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status,
+ unsigned long keysymSet);
+
+extern int XmuLookupLatin1(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupLatin2(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupLatin3(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupLatin4(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupKana(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupJISX0201(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupArabic(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupCyrillic(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupGreek(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupAPL(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupHebrew(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+#endif /* included_xmu_lookup_h */
diff --git a/nx-X11/lib/Xmu/LookupCmap.c b/nx-X11/lib/Xmu/LookupCmap.c
new file mode 100644
index 000000000..e7d7008e5
--- /dev/null
+++ b/nx-X11/lib/Xmu/LookupCmap.c
@@ -0,0 +1,325 @@
+/* $Xorg: LookupCmap.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/LookupCmap.c,v 1.7 2001/07/25 15:04:50 dawes Exp $ */
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+#include <stdlib.h>
+
+/*
+ * Prototypes
+ */
+static Status lookup(Display*, int, VisualID, Atom, XStandardColormap*, Bool);
+
+/*
+ * To create a standard colormap if one does not currently exist, or
+ * replace the currently existing standard colormap, use
+ * XmuLookupStandardColormap().
+ *
+ * Given a screen, a visual, and a property, XmuLookupStandardColormap()
+ * will determine the best allocation for the property under the specified
+ * visual, and determine the whether to create a new colormap or to use
+ * the default colormap of the screen. It will call XmuStandardColormap()
+ * to create the standard colormap.
+ *
+ * If replace is true, any previous definition of the property will be
+ * replaced. If retain is true, the property and the colormap will be
+ * made permanent for the duration of the server session. However,
+ * pre-existing property definitions which are not replaced cannot be made
+ * permanent by a call to XmuLookupStandardColormap(); a request to retain
+ * resources pertains to newly created resources.
+ *
+ * Returns 0 on failure, non-zero on success. A request to create a
+ * standard colormap upon a visual which cannot support such a map is
+ * considered a failure. An example of this would be requesting any
+ * standard colormap property on a monochrome visual, or, requesting an
+ * RGB_BEST_MAP on a display whose colormap size is 16.
+ */
+
+Status
+XmuLookupStandardColormap(Display *dpy, int screen, VisualID visualid,
+ unsigned int depth, Atom property,
+ Bool replace, Bool retain)
+ /*
+ * dpy - specifies X server connection
+ * screen - specifies screen of display
+ * visualid - specifies the visual type
+ * depth - specifies the visual type
+ * property - a standard colormap property
+ * replace - specifies whether to replace
+ * retain - specifies whether to retain
+ */
+{
+ Display *odpy; /* original display connection */
+ XStandardColormap *colormap;
+ XVisualInfo vinfo_template, *vinfo; /* visual */
+ long vinfo_mask;
+ unsigned long r_max, g_max, b_max; /* allocation */
+ int count;
+ Colormap cmap; /* colormap ID */
+ Status status = 0;
+
+
+ /* Match the requested visual */
+
+ vinfo_template.visualid = visualid;
+ vinfo_template.screen = screen;
+ vinfo_template.depth = depth;
+ vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask;
+ if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &count)) ==
+ NULL)
+ return 0;
+
+ /* Monochrome visuals have no standard maps */
+
+ if (vinfo->colormap_size <= 2) {
+ XFree((char *) vinfo);
+ return 0;
+ }
+
+ /* If the requested property already exists on this screen, and,
+ * if the replace flag has not been set to true, return success.
+ * lookup() will remove a pre-existing map if replace is true.
+ */
+
+ if (lookup(dpy, screen, visualid, property, (XStandardColormap *) NULL,
+ replace) && !replace) {
+ XFree((char *) vinfo);
+ return 1;
+ }
+
+ /* Determine the best allocation for this property under the requested
+ * visualid and depth, and determine whether or not to use the default
+ * colormap of the screen.
+ */
+
+ if (!XmuGetColormapAllocation(vinfo, property, &r_max, &g_max, &b_max)) {
+ XFree((char *) vinfo);
+ return 0;
+ }
+
+ cmap = (property == XA_RGB_DEFAULT_MAP &&
+ visualid == XVisualIDFromVisual(DefaultVisual(dpy, screen)))
+ ? DefaultColormap(dpy, screen) : None;
+
+ /* If retaining resources, open a new connection to the same server */
+
+ if (retain) {
+ odpy = dpy;
+ if ((dpy = XOpenDisplay(XDisplayString(odpy))) == NULL) {
+ XFree((char *) vinfo);
+ return 0;
+ }
+ }
+
+ /* Create the standard colormap */
+
+ colormap = XmuStandardColormap(dpy, screen, visualid, depth, property,
+ cmap, r_max, g_max, b_max);
+
+ /* Set the standard colormap property */
+
+ if (colormap) {
+ XGrabServer(dpy);
+
+ if (lookup(dpy, screen, visualid, property, colormap, replace) &&
+ !replace) {
+ /* Someone has defined the property since we last looked.
+ * Since we will not replace it, release our own resources.
+ * If this is the default map, our allocations will be freed
+ * when this connection closes.
+ */
+ if (colormap->killid == ReleaseByFreeingColormap)
+ XFreeColormap(dpy, colormap->colormap);
+ }
+ else if (retain) {
+ XSetCloseDownMode(dpy, RetainPermanent);
+ }
+ XUngrabServer(dpy);
+ XFree((char *) colormap);
+ status = 1;
+ }
+
+ if (retain)
+ XCloseDisplay(dpy);
+ XFree((char *) vinfo);
+ return status;
+}
+
+/***************************************************************************/
+
+/* Lookup a standard colormap property. If the property is RGB_DEFAULT_MAP,
+ * the visualid is used to determine whether the indicated standard colormap
+ * exists. If the map exists and replace is true, delete the resources used
+ * by the map and remove the property. Return true if the map exists,
+ * or did exist and was deleted; return false if the map was not found.
+ *
+ * Note that this is not the way that a Status return is normally used.
+ *
+ * If new is not NULL, new points to an XStandardColormap structure which
+ * describes a standard colormap of the specified property. It will be made
+ * a standard colormap of the screen if none already exists, or if replace
+ * is true.
+ */
+
+static Status
+lookup(Display *dpy, int screen, VisualID visualid, Atom property,
+ XStandardColormap *cnew, Bool replace)
+ /*
+ * dpy - specifies display connection
+ * screen - specifies screen number
+ * visualid - specifies visualid for std map
+ * property - specifies colormap property name
+ * cnew - specifies a standard colormap
+ * replace - specifies whether to replace
+ */
+{
+ register int i;
+ int count;
+ XStandardColormap *stdcmaps, *s;
+ Window win = RootWindow(dpy, screen);
+
+ /* The property does not already exist */
+
+ if (! XGetRGBColormaps(dpy, win, &stdcmaps, &count, property)) {
+ if (cnew)
+ XSetRGBColormaps(dpy, win, cnew, 1, property);
+ return 0;
+ }
+
+ /* The property exists and is not describing the RGB_DEFAULT_MAP */
+
+ if (property != XA_RGB_DEFAULT_MAP) {
+ if (replace) {
+ XmuDeleteStandardColormap(dpy, screen, property);
+ if (cnew)
+ XSetRGBColormaps(dpy, win, cnew, 1, property);
+ }
+ XFree((char *)stdcmaps);
+ return 1;
+ }
+
+ /* The property exists and is RGB_DEFAULT_MAP */
+
+ for (i=0, s=stdcmaps; (i < count) && (s->visualid != visualid); i++, s++)
+ ;
+
+ /* No RGB_DEFAULT_MAP property matches the given visualid */
+
+ if (i == count) {
+ if (cnew) {
+ XStandardColormap *m, *maps;
+
+ s = (XStandardColormap *) malloc((unsigned) ((count+1) * sizeof
+ (XStandardColormap)));
+
+ for (i = 0, m = s, maps = stdcmaps; i < count; i++, m++, maps++) {
+ m->colormap = maps->colormap;
+ m->red_max = maps->red_max;
+ m->red_mult = maps->red_mult;
+ m->green_max = maps->green_max;
+ m->green_mult = maps->green_mult;
+ m->blue_max = maps->blue_max;
+ m->blue_mult = maps->blue_mult;
+ m->base_pixel = maps->base_pixel;
+ m->visualid = maps->visualid;
+ m->killid = maps->killid;
+ }
+ m->colormap = cnew->colormap;
+ m->red_max = cnew->red_max;
+ m->red_mult = cnew->red_mult;
+ m->green_max = cnew->green_max;
+ m->green_mult = cnew->green_mult;
+ m->blue_max = cnew->blue_max;
+ m->blue_mult = cnew->blue_mult;
+ m->base_pixel = cnew->base_pixel;
+ m->visualid = cnew->visualid;
+ m->killid = cnew->killid;
+
+ XSetRGBColormaps(dpy, win, s, ++count, property);
+ free((char *) s);
+ }
+ XFree((char *) stdcmaps);
+ return 0;
+ }
+
+ /* Found an RGB_DEFAULT_MAP property with a matching visualid */
+
+ if (replace) {
+ /* Free old resources first - we may need them, particularly in
+ * the default colormap of the screen. However, because of this,
+ * it is possible that we will destroy the old resource and fail
+ * to create a new one if XmuStandardColormap() fails.
+ */
+
+ if (count == 1) {
+ XmuDeleteStandardColormap(dpy, screen, property);
+ if (cnew)
+ XSetRGBColormaps(dpy, win, cnew, 1, property);
+ }
+ else {
+ XStandardColormap *map;
+
+ /* s still points to the matching standard colormap */
+
+ if (s->killid == ReleaseByFreeingColormap) {
+ if ((s->colormap != None) &&
+ (s->colormap != DefaultColormap(dpy, screen)))
+ XFreeColormap(dpy, s->colormap);
+ }
+ else if (s->killid != None)
+ XKillClient(dpy, s->killid);
+
+ map = (cnew) ? cnew : stdcmaps + --count;
+
+ s->colormap = map->colormap;
+ s->red_max = map->red_max;
+ s->red_mult = map->red_mult;
+ s->green_max = map->green_max;
+ s->green_mult = map->green_mult;
+ s->blue_max = map->blue_max;
+ s->blue_mult = map->blue_mult;
+ s->visualid = map->visualid;
+ s->killid = map->killid;
+
+ XSetRGBColormaps(dpy, win, stdcmaps, count, property);
+ }
+ }
+ XFree((char *) stdcmaps);
+ return 1;
+}
diff --git a/nx-X11/lib/Xmu/Lower.c b/nx-X11/lib/Xmu/Lower.c
new file mode 100644
index 000000000..06ad31a29
--- /dev/null
+++ b/nx-X11/lib/Xmu/Lower.c
@@ -0,0 +1,164 @@
+/* $Xorg: Lower.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+
+/* $XFree86: xc/lib/Xmu/Lower.c,v 1.11 2001/07/25 15:04:50 dawes Exp $ */
+
+#define XK_LATIN1
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/keysymdef.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/SysUtil.h>
+
+#include <stdio.h>
+
+#ifndef HAS_SNPRINTF
+#undef SCOPE
+#define SCOPE static
+#include "snprintf.c"
+#endif
+
+#include <stdarg.h>
+
+/*
+ * ISO Latin-1 case conversion routine
+ */
+#define XmuTolower(c) \
+((c) >= XK_a && (c) <= XK_z ? \
+ (c) : (c) >= XK_A && (c) <= XK_Z ? \
+ (c) + (XK_a - XK_A) : (c) >= XK_Agrave && (c) <= XK_Odiaeresis ? \
+ (c) + (XK_agrave - XK_Agrave) : (c) >= XK_Ooblique && (c) <= XK_Thorn ? \
+ (c) + (XK_oslash - XK_Ooblique) : \
+ (c))
+
+#define XmuToupper(c) \
+((c) >= XK_A && (c) <= XK_Z ? \
+ (c) : (c) >= XK_a && (c) <= XK_z ? \
+ (c) - (XK_a - XK_A) : (c) >= XK_agrave && (c) <= XK_odiaeresis ? \
+ (c) - (XK_agrave - XK_Agrave) : (c) >= XK_oslash && (c) <= XK_thorn ? \
+ (c) - (XK_oslash - XK_Ooblique) : \
+ (c))
+
+/*
+ * Implementation
+ */
+void
+XmuCopyISOLatin1Lowered(char *dst, _Xconst char *src)
+{
+ register unsigned char *dest, *source;
+
+ for (dest = (unsigned char *)dst, source = (unsigned char *)src;
+ *source;
+ source++, dest++)
+ *dest = XmuTolower(*source);
+ *dest = '\0';
+}
+
+void
+XmuCopyISOLatin1Uppered(char *dst, _Xconst char *src)
+{
+ register unsigned char *dest, *source;
+
+ for (dest = (unsigned char *)dst, source = (unsigned char *)src;
+ *source;
+ source++, dest++)
+ *dest = XmuToupper(*source);
+ *dest = '\0';
+}
+
+int
+XmuCompareISOLatin1(_Xconst char *first, _Xconst char *second)
+{
+ register unsigned char *ap, *bp;
+
+ for (ap = (unsigned char *)first, bp = (unsigned char *)second;
+ *ap && *bp && XmuTolower(*ap) == XmuTolower(*bp);
+ ap++, bp++)
+ ;
+
+ return ((int)XmuTolower(*ap) - (int)XmuTolower(*bp));
+}
+
+void
+XmuNCopyISOLatin1Lowered(char *dst, _Xconst char *src, register int size)
+{
+ register unsigned char *dest, *source;
+
+ if (size > 0)
+ {
+ for (dest = (unsigned char *)dst, source = (unsigned char *)src;
+ *source && size > 1;
+ source++, dest++, size--)
+ *dest = XmuTolower(*source);
+ *dest = '\0';
+ }
+}
+
+void
+XmuNCopyISOLatin1Uppered(char *dst, _Xconst char *src, register int size)
+{
+ register unsigned char *dest, *source;
+
+ if (size > 0)
+ {
+ for (dest = (unsigned char *)dst, source = (unsigned char *)src;
+ *source && size > 1;
+ source++, dest++, size--)
+ *dest = XmuToupper(*source);
+ *dest = '\0';
+ }
+}
+
+int
+XmuSnprintf(char *str, int size, _Xconst char *fmt, ...)
+{
+ va_list ap;
+ int retval;
+
+ if (size <= 0)
+ return (size);
+
+ va_start(ap, fmt);
+
+#if 0
+ retval = vsprintf(str, fmt, ap);
+ if (retval >= size)
+ {
+ fprintf(stderr, "WARNING: buffer overflow detected!\n");
+ fflush(stderr);
+ abort();
+ }
+#else
+ retval = vsnprintf(str, size, fmt, ap);
+#endif
+
+ va_end(ap);
+
+ return (retval);
+}
diff --git a/nx-X11/lib/Xmu/Misc.h b/nx-X11/lib/Xmu/Misc.h
new file mode 100644
index 000000000..b47fbba4b
--- /dev/null
+++ b/nx-X11/lib/Xmu/Misc.h
@@ -0,0 +1,65 @@
+/* $Xorg: Misc.h,v 1.4 2001/02/09 02:03:53 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.
+
+******************************************************************/
+
+/* Various useful constant and macro definitions */
+
+#ifndef _Xmu_Misc_h
+#define _Xmu_Misc_h
+
+#define MAXDIMENSION ((1 << 31)-1)
+
+#define Max(x, y) (((x) > (y)) ? (x) : (y))
+#define Min(x, y) (((x) < (y)) ? (x) : (y))
+#define AssignMax(x, y) {if ((y) > (x)) x = (y);}
+#define AssignMin(x, y) {if ((y) < (x)) x = (y);}
+
+#endif /*_Xmu_Misc_h*/
diff --git a/nx-X11/lib/Xmu/README b/nx-X11/lib/Xmu/README
new file mode 100644
index 000000000..d618e2a71
--- /dev/null
+++ b/nx-X11/lib/Xmu/README
@@ -0,0 +1,8 @@
+This library contains miscellaneous utilities and is not part of the Xlib
+standard. It contains routines which only use public interfaces so that it
+may be layered on top of any proprietary implementation of Xlib or Xt.
+
+It is intended to support clients in the MIT distribution; vendors
+may choose not to distribute this library if they wish. Therefore,
+applications developers who depend on this library should be prepared to
+treat it as part of their software base when porting.
diff --git a/nx-X11/lib/Xmu/RdBitF.c b/nx-X11/lib/Xmu/RdBitF.c
new file mode 100644
index 000000000..eb5fe598d
--- /dev/null
+++ b/nx-X11/lib/Xmu/RdBitF.c
@@ -0,0 +1,401 @@
+/* $Xorg: RdBitF.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/RdBitF.c,v 3.12 2001/12/14 19:55:48 dawes Exp $ */
+
+/*
+ * This file contains miscellaneous utility routines and is not part of the
+ * Xlib standard.
+ *
+ * Public entry points:
+ *
+ * XmuReadBitmapData read data from FILE descriptor
+ * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files
+ * and return data
+ *
+ * Note that this file and ../X/XRdBitF.c look very similar.... Keep them
+ * that way (but don't use common source code so that people can have one
+ * without the other).
+ */
+
+
+/*
+ * Based on an optimized version provided by Jim Becker, Auguest 5, 1988.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xlibint.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <X11/Xmu/Drawing.h>
+
+#define MAX_SIZE 255
+
+/*
+ * Prototypes
+ */
+static void initHexTable(void);
+static int NextInt(FILE*);
+
+/* shared data for the image read/parse logic */
+static short hexTable[256]; /* conversion value */
+static Bool initialized = False; /* easier to fill in at run time */
+
+
+/*
+ * Table index for the hex values. Initialized once, first time.
+ * Used for translation value or delimiter significance lookup.
+ */
+static void
+initHexTable(void)
+{
+ /*
+ * We build the table at run time for several reasons:
+ *
+ * 1. portable to non-ASCII machines.
+ * 2. still reentrant since we set the init flag after setting table.
+ * 3. easier to extend.
+ * 4. less prone to bugs.
+ */
+ hexTable['0'] = 0; hexTable['1'] = 1;
+ hexTable['2'] = 2; hexTable['3'] = 3;
+ hexTable['4'] = 4; hexTable['5'] = 5;
+ hexTable['6'] = 6; hexTable['7'] = 7;
+ hexTable['8'] = 8; hexTable['9'] = 9;
+ hexTable['A'] = 10; hexTable['B'] = 11;
+ hexTable['C'] = 12; hexTable['D'] = 13;
+ hexTable['E'] = 14; hexTable['F'] = 15;
+ hexTable['a'] = 10; hexTable['b'] = 11;
+ hexTable['c'] = 12; hexTable['d'] = 13;
+ hexTable['e'] = 14; hexTable['f'] = 15;
+
+ /* delimiters of significance are flagged w/ negative value */
+ hexTable[' '] = -1; hexTable[','] = -1;
+ hexTable['}'] = -1; hexTable['\n'] = -1;
+ hexTable['\t'] = -1;
+
+ initialized = True;
+}
+
+/*
+ * read next hex value in the input stream, return -1 if EOF
+ */
+static int
+NextInt(FILE *fstream)
+{
+ int ch;
+ int value = 0;
+ int gotone = 0;
+ int done = 0;
+
+ /* loop, accumulate hex value until find delimiter */
+ /* skip any initial delimiters found in read stream */
+
+ while (!done) {
+ ch = getc(fstream);
+ if (ch == EOF) {
+ value = -1;
+ done++;
+ } else {
+ /* trim high bits, check type and accumulate */
+ ch &= 0xff;
+ if (isascii(ch) && isxdigit(ch)) {
+ value = (value << 4) + hexTable[ch];
+ gotone++;
+ } else if ((hexTable[ch]) < 0 && gotone)
+ done++;
+ }
+ }
+ return value;
+}
+
+
+/*
+ * The data returned by the following routine is always in left-most byte
+ * first and left-most bit first. If it doesn't return BitmapSuccess then
+ * its arguments won't have been touched. This routine should look as much
+ * like the Xlib routine XReadBitmapfile as possible.
+ */
+int
+XmuReadBitmapData(FILE *fstream, unsigned int *width, unsigned int *height,
+ unsigned char **datap, int *x_hot, int *y_hot)
+{
+ unsigned char *data = NULL; /* working variable */
+ char line[MAX_SIZE]; /* input line from file */
+ int size; /* number of bytes of data */
+ char name_and_type[MAX_SIZE]; /* an input line */
+ char *type; /* for parsing */
+ int value; /* from an input line */
+ int version10p; /* boolean, old format */
+ int padding; /* to handle alignment */
+ int bytes_per_line; /* per scanline of data */
+ unsigned int ww = 0; /* width */
+ unsigned int hh = 0; /* height */
+ int hx = -1; /* x hotspot */
+ int hy = -1; /* y hotspot */
+
+#undef Xmalloc /* see MALLOC_0_RETURNS_NULL in Xlibint.h */
+#define Xmalloc(size) malloc(size)
+
+ /* first time initialization */
+ if (initialized == False) initHexTable();
+
+ /* error cleanup and return macro */
+#define RETURN(code) { if (data) free (data); return code; }
+
+ while (fgets(line, MAX_SIZE, fstream)) {
+ if (strlen(line) == MAX_SIZE-1) {
+ RETURN (BitmapFileInvalid);
+ }
+ if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) {
+ if (!(type = strrchr(name_and_type, '_')))
+ type = name_and_type;
+ else
+ type++;
+
+ if (!strcmp("width", type))
+ ww = (unsigned int) value;
+ if (!strcmp("height", type))
+ hh = (unsigned int) value;
+ if (!strcmp("hot", type)) {
+ if (type-- == name_and_type || type-- == name_and_type)
+ continue;
+ if (!strcmp("x_hot", type))
+ hx = value;
+ if (!strcmp("y_hot", type))
+ hy = value;
+ }
+ continue;
+ }
+
+ if (sscanf(line, "static short %s = {", name_and_type) == 1)
+ version10p = 1;
+ else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1)
+ version10p = 0;
+ else if (sscanf(line, "static char %s = {", name_and_type) == 1)
+ version10p = 0;
+ else
+ continue;
+
+ if (!(type = strrchr(name_and_type, '_')))
+ type = name_and_type;
+ else
+ type++;
+
+ if (strcmp("bits[]", type))
+ continue;
+
+ if (!ww || !hh)
+ RETURN (BitmapFileInvalid);
+
+ if ((ww % 16) && ((ww % 16) < 9) && version10p)
+ padding = 1;
+ else
+ padding = 0;
+
+ bytes_per_line = (ww+7)/8 + padding;
+
+ size = bytes_per_line * hh;
+ data = (unsigned char *) Xmalloc ((unsigned int) size);
+ if (!data)
+ RETURN (BitmapNoMemory);
+
+ if (version10p) {
+ unsigned char *ptr;
+ int bytes;
+
+ for (bytes=0, ptr=data; bytes<size; (bytes += 2)) {
+ if ((value = NextInt(fstream)) < 0)
+ RETURN (BitmapFileInvalid);
+ *(ptr++) = value;
+ if (!padding || ((bytes+2) % bytes_per_line))
+ *(ptr++) = value >> 8;
+ }
+ } else {
+ unsigned char *ptr;
+ int bytes;
+
+ for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) {
+ if ((value = NextInt(fstream)) < 0)
+ RETURN (BitmapFileInvalid);
+ *ptr=value;
+ }
+ }
+ break;
+ } /* end while */
+
+ if (data == NULL) {
+ RETURN (BitmapFileInvalid);
+ }
+
+ *datap = data;
+ data = NULL;
+ *width = ww;
+ *height = hh;
+ if (x_hot) *x_hot = hx;
+ if (y_hot) *y_hot = hy;
+
+ RETURN (BitmapSuccess);
+}
+
+#if defined(WIN32)
+static int
+access_file(char *path, char *pathbuf, int len_pathbuf, char **pathret)
+{
+ if (access (path, F_OK) == 0) {
+ if (strlen (path) < len_pathbuf)
+ *pathret = pathbuf;
+ else
+ *pathret = malloc (strlen (path) + 1);
+ if (*pathret) {
+ strcpy (*pathret, path);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int
+AccessFile(char *path, char *pathbuf, int len_pathbuf, char **pathret)
+{
+#ifndef MAX_PATH
+#define MAX_PATH 512
+#endif
+
+ unsigned long drives;
+ int i, len;
+ char* drive;
+ char buf[MAX_PATH];
+ char* bufp;
+
+ /* just try the "raw" name first and see if it works */
+ if (access_file (path, pathbuf, len_pathbuf, pathret))
+ return 1;
+
+ /* try the places set in the environment */
+ drive = getenv ("_XBASEDRIVE");
+#ifdef __UNIXOS2__
+ if (!drive)
+ drive = getenv ("X11ROOT");
+#endif
+ if (!drive)
+ drive = "C:";
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = malloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) free (bufp);
+ return 1;
+ }
+
+#ifndef __UNIXOS2__
+ /* one last place to look */
+ drive = getenv ("HOMEDRIVE");
+ if (drive) {
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = malloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) free (bufp);
+ return 1;
+ }
+ }
+
+ /* does OS/2 (with or with gcc-emx) have getdrives? */
+ /* tried everywhere else, go fishing */
+#define C_DRIVE ('C' - 'A')
+#define Z_DRIVE ('Z' - 'A')
+ drives = _getdrives ();
+ for (i = C_DRIVE; i <= Z_DRIVE; i++) { /* don't check on A: or B: */
+ if ((1 << i) & drives) {
+ len = 2 + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = malloc (len + 1);
+ *bufp = 'A' + i;
+ *(bufp + 1) = ':';
+ *(bufp + 2) = '\0';
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) free (bufp);
+ return 1;
+ }
+ }
+ }
+#endif
+ return 0;
+}
+
+FILE *
+fopen_file(char *path, char *mode)
+{
+ char buf[MAX_PATH];
+ char* bufp;
+ void* ret = NULL;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ ret = fopen (bufp, mode);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) free (bufp);
+
+ return ret;
+}
+
+#else
+#define fopen_file fopen
+#endif
+
+
+int
+XmuReadBitmapDataFromFile(_Xconst char *filename, unsigned int *width,
+ unsigned int *height, unsigned char **datap,
+ int *x_hot, int *y_hot)
+{
+ FILE *fstream;
+ int status;
+
+#ifdef __UNIXOS2__
+ filename = __XOS2RedirRoot(filename);
+#endif
+ if ((fstream = fopen_file (filename, "r")) == NULL) {
+ return BitmapOpenFailed;
+ }
+ status = XmuReadBitmapData(fstream, width, height, datap, x_hot, y_hot);
+ fclose (fstream);
+ return status;
+}
diff --git a/nx-X11/lib/Xmu/ScrOfWin.c b/nx-X11/lib/Xmu/ScrOfWin.c
new file mode 100644
index 000000000..dbba3c65b
--- /dev/null
+++ b/nx-X11/lib/Xmu/ScrOfWin.c
@@ -0,0 +1,60 @@
+/* $Xorg: ScrOfWin.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/ScrOfWin.c,v 1.6 2001/01/17 19:42:56 dawes Exp $ */
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xmu/WinUtil.h>
+
+Screen *
+XmuScreenOfWindow(Display *dpy, Window w)
+{
+ register int i;
+ Window root;
+ int x, y; /* dummy variables */
+ unsigned int width, height, bw, depth; /* dummy variables */
+
+ if (!XGetGeometry (dpy, w, &root, &x, &y, &width, &height,
+ &bw, &depth)) {
+ return NULL;
+ }
+ for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */
+ if (root == RootWindow (dpy, i)) {
+ return ScreenOfDisplay (dpy, i);
+ }
+ }
+ return NULL;
+}
+
diff --git a/nx-X11/lib/Xmu/ShapeWidg.c b/nx-X11/lib/Xmu/ShapeWidg.c
new file mode 100644
index 000000000..732018c92
--- /dev/null
+++ b/nx-X11/lib/Xmu/ShapeWidg.c
@@ -0,0 +1,251 @@
+/* $Xorg: ShapeWidg.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/ShapeWidg.c,v 1.7 2001/01/17 19:42:56 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/extensions/shape.h>
+#include "Converters.h"
+#include "Drawing.h"
+#include "Misc.h"
+
+/*
+ * Prototypes
+ */
+static void ShapeEllipseOrRoundedRectangle(Widget, Bool, int, int);
+static void ShapeError(Widget);
+static void ShapeOval(Widget);
+static void ShapeRectangle(Widget);
+
+/*
+ * Implementation
+ */
+Boolean
+XmuReshapeWidget(Widget w, int shape_style,
+ int corner_width, int corner_height)
+{
+ switch (shape_style)
+ {
+ case XmuShapeRectangle:
+ ShapeRectangle(w);
+ break;
+ case XmuShapeOval:
+ ShapeOval(w);
+ break;
+ case XmuShapeEllipse:
+ case XmuShapeRoundedRectangle:
+ ShapeEllipseOrRoundedRectangle(w, shape_style == XmuShapeEllipse,
+ corner_width, corner_height);
+ break;
+ default:
+ ShapeError(w);
+ return (False);
+ }
+ return (True);
+}
+
+static void
+ShapeError(Widget w)
+{
+ String params[1];
+ Cardinal num_params = 1;
+
+ params[0] = XtName(w);
+ XtAppWarningMsg(XtWidgetToApplicationContext(w),
+ "shapeUnknown", "xmuReshapeWidget", "XmuLibrary",
+ "Unsupported shape style for Command widget \"%s\"",
+ params, &num_params);
+}
+
+static void
+ShapeRectangle(Widget w)
+{
+ XShapeCombineMask(XtDisplay(w), XtWindow(w),
+ ShapeBounding, 0, 0, None, ShapeSet);
+ XShapeCombineMask(XtDisplay(w), XtWindow(w),
+ ShapeClip, 0, 0, None, ShapeSet);
+}
+
+/*
+ * Function:
+ * ShapeOval
+ *
+ * Parameters:
+ * w - widget to be reshaped
+ *
+ * Description:
+ * Reshapes a widget to a oval format.
+ *
+ * Notes:
+ * X11R6.3 behaviour changed. Now if the height is larger than the
+ * width, this function inverts the sense of the oval, instead of
+ * fallbacking to ellipse.
+ */
+static void
+ShapeOval(Widget w)
+{
+ Display *dpy = XtDisplay(w);
+ int width = w->core.width;
+ int height = w->core.height;
+ Pixmap p;
+ XGCValues values;
+ GC gc;
+ int rad;
+
+ if (width < 3 || height < 3)
+ return;
+ width += w->core.border_width << 1;
+ height += w->core.border_width << 1;
+
+ p = XCreatePixmap(dpy, XtWindow(w), width, height, 1);
+ values.foreground = 0;
+ values.background = 1;
+ values.cap_style = CapRound;
+ values.line_width = Min(width, height);
+ gc = XCreateGC(dpy, p,
+ GCForeground | GCBackground | GCLineWidth | GCCapStyle,
+ &values);
+ XFillRectangle(dpy, p, gc, 0, 0, width, height);
+ XSetForeground(dpy, gc, 1);
+
+ if (width < height)
+ {
+ rad = width >> 1;
+ XDrawLine(dpy, p, gc, rad, rad, rad, height - rad - 1);
+ }
+ else
+ {
+ rad = height >> 1;
+ XDrawLine(dpy, p, gc, rad, rad, width - rad - 1, rad);
+ }
+ XShapeCombineMask(dpy, XtWindow(w), ShapeBounding,
+ -(int)w->core.border_width, -(int)w->core.border_width,
+ p, ShapeSet);
+ if (w->core.border_width)
+ {
+ XSetForeground(dpy, gc, 0);
+ XFillRectangle(dpy, p, gc, 0, 0, width, height);
+ values.line_width = Min(w->core.width, w->core.height);
+ values.foreground = 1;
+ XChangeGC(dpy, gc, GCLineWidth | GCForeground, &values);
+ if (w->core.width < w->core.height)
+ {
+ rad = w->core.width >> 1;
+ XDrawLine(dpy, p, gc, rad, rad, rad, w->core.height - rad - 1);
+ }
+ else
+ {
+ rad = w->core.height >> 1;
+ XDrawLine(dpy, p, gc, rad, rad, w->core.width - rad - 1, rad);
+ }
+ XShapeCombineMask(dpy, XtWindow(w), ShapeClip, 0, 0, p, ShapeSet);
+ }
+ else
+ XShapeCombineMask(XtDisplay(w), XtWindow(w),
+ ShapeClip, 0, 0, None, ShapeSet);
+
+ XFreePixmap(dpy, p);
+ XFreeGC(dpy, gc);
+}
+
+/*
+ * Function:
+ * ShapeEllipseOrRoundedRectangle
+ *
+ * Parameters:
+ * w - widget to be reshaped
+ * ellipse - True if shape to ellise, rounded rectangle otherwise
+ * ew - horizontal radius of rounded rectangle
+ * eh - vertical radius of rouded rectangle
+ *
+ * Description:
+ * Based on the ellipse parameter, gives the widget a elliptical
+ * shape, or rounded rectangle shape.
+ *
+ * Notes:
+ * The GC is created with a line width of 2, what seens to draw the
+ * widget border correctly, if the width - height is not proportional.
+ */
+static void
+ShapeEllipseOrRoundedRectangle(Widget w, Bool ellipse, int ew, int eh)
+{
+ Display *dpy = XtDisplay(w);
+ unsigned width = w->core.width;
+ unsigned height = w->core.height;
+ Pixmap p;
+ XGCValues values;
+ GC gc;
+ unsigned long mask;
+
+ if (width < 3 || width < 3)
+ return;
+ width += w->core.border_width << 1;
+ height += w->core.border_width << 1;
+
+ mask = GCForeground | GCLineWidth;
+ p = XCreatePixmap(dpy, XtWindow(w), width, height, 1);
+
+ values.foreground = 0;
+ values.line_width = 2;
+
+ gc = XCreateGC(dpy, p, mask, &values);
+ XFillRectangle(dpy, p, gc, 0, 0, width, height);
+ XSetForeground(dpy, gc, 1);
+ if (!ellipse)
+ XmuFillRoundedRectangle(dpy, p, gc, 1, 1, width - 2, height - 2, ew, eh);
+ else
+ {
+ XDrawArc(dpy, p, gc, 1, 1, width - 2, height - 2, 0, 360 * 64);
+ XFillArc(dpy, p, gc, 2, 2, width - 4, height - 4, 0, 360 * 64);
+ }
+ XShapeCombineMask(dpy, XtWindow(w), ShapeBounding,
+ -(int)w->core.border_width, -(int)w->core.border_width,
+ p, ShapeSet);
+ if (w->core.border_width)
+ {
+ XSetForeground(dpy, gc, 0);
+ XFillRectangle(dpy, p, gc, 0, 0, width, height);
+ XSetForeground(dpy, gc, 1);
+ if (!ellipse)
+ XmuFillRoundedRectangle(dpy, p, gc, 1, 1,
+ w->core.width - 2, w->core.height - 2,
+ ew, eh);
+ else
+ XFillArc(dpy, p, gc, 0, 0, w->core.width, w->core.height,
+ 0, 360 * 64);
+ XShapeCombineMask(dpy, XtWindow(w), ShapeClip, 0, 0, p, ShapeSet);
+ }
+ else
+ XShapeCombineMask(XtDisplay(w), XtWindow(w),
+ ShapeClip, 0, 0, None, ShapeSet);
+
+ XFreePixmap(dpy, p);
+ XFreeGC(dpy, gc);
+}
diff --git a/nx-X11/lib/Xmu/StdCmap.c b/nx-X11/lib/Xmu/StdCmap.c
new file mode 100644
index 000000000..ffce489ce
--- /dev/null
+++ b/nx-X11/lib/Xmu/StdCmap.c
@@ -0,0 +1,236 @@
+/* $Xorg: StdCmap.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/StdCmap.c,v 1.5 2001/01/17 19:42:56 dawes Exp $ */
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+#define lowbit(x) ((x) & (~(x) + 1))
+
+/*
+ * Prototypes
+ */
+/* argument restrictions */
+static Status valid_args(XVisualInfo*, unsigned long, unsigned long,
+ unsigned long, Atom);
+
+/*
+ * To create any one standard colormap, use XmuStandardColormap().
+ *
+ * Create a standard colormap for the given screen, visualid, and visual
+ * depth, with the given red, green, and blue maximum values, with the
+ * given standard property name. Return a pointer to an XStandardColormap
+ * structure which describes the newly created colormap, upon success.
+ * Upon failure, return NULL.
+ *
+ * XmuStandardColormap() calls XmuCreateColormap() to create the map.
+ *
+ * Resources created by this function are not made permanent; that is the
+ * caller's responsibility.
+ */
+
+XStandardColormap *
+XmuStandardColormap(Display *dpy, int screen, VisualID visualid,
+ unsigned int depth, Atom property, Colormap cmap,
+ unsigned long red_max, unsigned long green_max,
+ unsigned long blue_max)
+ /*
+ * dpy - specifies X server connection
+ * screen - specifies display screen
+ * visualid - identifies the visual type
+ * depth - identifies the visual type
+ * property - a standard colormap property
+ * cmap - specifies colormap ID or None
+ * red_max, green_max, blue_max - allocations
+ */
+{
+ XStandardColormap *stdcmap;
+ Status status;
+ XVisualInfo vinfo_template, *vinfo;
+ long vinfo_mask;
+ int n;
+
+ /* Match the required visual information to an actual visual */
+ vinfo_template.visualid = visualid;
+ vinfo_template.screen = screen;
+ vinfo_template.depth = depth;
+ vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask;
+ if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
+ return 0;
+
+ /* Check the validity of the combination of visual characteristics,
+ * allocation, and colormap property. Create an XStandardColormap
+ * structure.
+ */
+
+ if (! valid_args(vinfo, red_max, green_max, blue_max, property)
+ || ((stdcmap = XAllocStandardColormap()) == NULL)) {
+ XFree((char *) vinfo);
+ return 0;
+ }
+
+ /* Fill in the XStandardColormap structure */
+
+ if (cmap == DefaultColormap(dpy, screen)) {
+ /* Allocating out of the default map, cannot use XFreeColormap() */
+ Window win = XCreateWindow(dpy, RootWindow(dpy, screen), 1, 1, 1, 1,
+ 0, 0, InputOnly, vinfo->visual,
+ (unsigned long) 0,
+ (XSetWindowAttributes *)NULL);
+ stdcmap->killid = (XID) XCreatePixmap(dpy, win, 1, 1, depth);
+ XDestroyWindow(dpy, win);
+ stdcmap->colormap = cmap;
+ } else {
+ stdcmap->killid = ReleaseByFreeingColormap;
+ stdcmap->colormap = XCreateColormap(dpy, RootWindow(dpy, screen),
+ vinfo->visual, AllocNone);
+ }
+ stdcmap->red_max = red_max;
+ stdcmap->green_max = green_max;
+ stdcmap->blue_max = blue_max;
+ if (property == XA_RGB_GRAY_MAP)
+ stdcmap->red_mult = stdcmap->green_mult = stdcmap->blue_mult = 1;
+ else if (vinfo->class == TrueColor || vinfo->class == DirectColor) {
+ stdcmap->red_mult = lowbit(vinfo->red_mask);
+ stdcmap->green_mult = lowbit(vinfo->green_mask);
+ stdcmap->blue_mult = lowbit(vinfo->blue_mask);
+ } else {
+ stdcmap->red_mult = (red_max > 0)
+ ? (green_max + 1) * (blue_max + 1) : 0;
+ stdcmap->green_mult = (green_max > 0) ? blue_max + 1 : 0;
+ stdcmap->blue_mult = (blue_max > 0) ? 1 : 0;
+ }
+ stdcmap->base_pixel = 0; /* base pixel may change */
+ stdcmap->visualid = vinfo->visualid;
+
+ /* Make the colormap */
+
+ status = XmuCreateColormap(dpy, stdcmap);
+
+ /* Clean up */
+
+ XFree((char *) vinfo);
+ if (!status) {
+
+ /* Free the colormap or the pixmap, if we created one */
+ if (stdcmap->killid == ReleaseByFreeingColormap)
+ XFreeColormap(dpy, stdcmap->colormap);
+ else if (stdcmap->killid != None)
+ XFreePixmap(dpy, stdcmap->killid);
+
+ XFree((char *) stdcmap);
+ return (XStandardColormap *) NULL;
+ }
+ return stdcmap;
+}
+
+/****************************************************************************/
+static Status
+valid_args(XVisualInfo *vinfo, unsigned long red_max, unsigned long green_max,
+ unsigned long blue_max, Atom property)
+ /*
+ * vinfo - specifies visual
+ * red_max, green_max, blue_max - specifies alloc
+ * property - specifies property name
+ */
+{
+ unsigned long ncolors; /* number of colors requested */
+
+ /* Determine that the number of colors requested is <= map size */
+
+ if ((vinfo->class == DirectColor) || (vinfo->class == TrueColor)) {
+ unsigned long mask;
+
+ mask = vinfo->red_mask;
+ while (!(mask & 1))
+ mask >>= 1;
+ if (red_max > mask)
+ return 0;
+ mask = vinfo->green_mask;
+ while (!(mask & 1))
+ mask >>= 1;
+ if (green_max > mask)
+ return 0;
+ mask = vinfo->blue_mask;
+ while (!(mask & 1))
+ mask >>= 1;
+ if (blue_max > mask)
+ return 0;
+ } else if (property == XA_RGB_GRAY_MAP) {
+ ncolors = red_max + green_max + blue_max + 1;
+ if (ncolors > vinfo->colormap_size)
+ return 0;
+ } else {
+ ncolors = (red_max + 1) * (green_max + 1) * (blue_max + 1);
+ if (ncolors > vinfo->colormap_size)
+ return 0;
+ }
+
+ /* Determine that the allocation and visual make sense for the property */
+
+ switch (property)
+ {
+ case XA_RGB_DEFAULT_MAP:
+ if (red_max == 0 || green_max == 0 || blue_max == 0)
+ return 0;
+ break;
+ case XA_RGB_RED_MAP:
+ if (red_max == 0)
+ return 0;
+ break;
+ case XA_RGB_GREEN_MAP:
+ if (green_max == 0)
+ return 0;
+ break;
+ case XA_RGB_BLUE_MAP:
+ if (blue_max == 0)
+ return 0;
+ break;
+ case XA_RGB_BEST_MAP:
+ if (red_max == 0 || green_max == 0 || blue_max == 0)
+ return 0;
+ break;
+ case XA_RGB_GRAY_MAP:
+ if (red_max == 0 || blue_max == 0 || green_max == 0)
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
diff --git a/nx-X11/lib/Xmu/StdCmap.h b/nx-X11/lib/Xmu/StdCmap.h
new file mode 100644
index 000000000..b268d073c
--- /dev/null
+++ b/nx-X11/lib/Xmu/StdCmap.h
@@ -0,0 +1,119 @@
+/* $Xorg: StdCmap.h,v 1.5 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/StdCmap.h,v 1.8 2001/01/23 17:38:14 keithp Exp $ */
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_STDCMAP_H_
+#define _XMU_STDCMAP_H_
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+Status XmuAllStandardColormaps
+(
+ Display *dpy
+ );
+
+Status XmuCreateColormap
+(
+ Display *dpy,
+ XStandardColormap *colormap
+ );
+
+void XmuDeleteStandardColormap
+(
+ Display *dpy,
+ int screen,
+ Atom property
+ );
+
+Status XmuGetColormapAllocation
+(
+ XVisualInfo *vinfo,
+ Atom property,
+ unsigned long *red_max_return,
+ unsigned long *green_max_return,
+ unsigned long *blue_max_return
+ );
+
+Status XmuLookupStandardColormap
+(
+ Display *dpy,
+ int screen,
+ VisualID visualid,
+ unsigned int depth,
+ Atom property,
+ Bool replace,
+ Bool retain
+ );
+
+XStandardColormap *XmuStandardColormap
+(
+ Display *dpy,
+ int screen,
+ VisualID visualid,
+ unsigned int depth,
+ Atom property,
+ Colormap cmap,
+ unsigned long red_max,
+ unsigned long green_max,
+ unsigned long blue_max
+ );
+
+Status XmuVisualStandardColormaps
+(
+ Display *dpy,
+ int screen,
+ VisualID visualid,
+ unsigned int depth,
+ Bool replace,
+ Bool retain
+ );
+
+Bool XmuDistinguishableColors
+(
+ XColor *colors,
+ int count
+ );
+
+Bool XmuDistinguishablePixels
+(
+ Display *dpy,
+ Colormap cmap,
+ unsigned long *pixels,
+ int count
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_STDCMAP_H_ */
diff --git a/nx-X11/lib/Xmu/StdSel.h b/nx-X11/lib/Xmu/StdSel.h
new file mode 100644
index 000000000..f7c9452de
--- /dev/null
+++ b/nx-X11/lib/Xmu/StdSel.h
@@ -0,0 +1,57 @@
+/* $Xorg: StdSel.h,v 1.5 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/StdSel.h,v 1.7 2001/01/17 19:42:56 dawes Exp $ */
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_SELECTION_H_
+#define _XMU_SELECTION_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+Boolean XmuConvertStandardSelection
+(
+ Widget w,
+ Time timev,
+ Atom *selection,
+ Atom *target,
+ Atom *type_return,
+ XPointer *value_return,
+ unsigned long *length_return,
+ int *format_return
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_SELECTION_H_ */
diff --git a/nx-X11/lib/Xmu/StrToBS.c b/nx-X11/lib/Xmu/StrToBS.c
new file mode 100644
index 000000000..79fbedda6
--- /dev/null
+++ b/nx-X11/lib/Xmu/StrToBS.c
@@ -0,0 +1,149 @@
+/* $Xorg: StrToBS.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+
+/* $XFree86: xc/lib/Xmu/StrToBS.c,v 1.6 2001/01/17 19:42:56 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include "Converters.h"
+#include "CharSet.h"
+
+/*
+ * Prototypes
+ */
+static void InitializeQuarks(void);
+
+/*
+ * Initialization
+ */
+static XrmQuark QnotUseful, QwhenMapped, Qalways, Qdefault;
+static Boolean haveQuarks;
+
+/*
+ * Implementation
+ */
+static void
+InitializeQuarks(void)
+{
+ if (!haveQuarks)
+ {
+ char name[11];
+
+ XmuNCopyISOLatin1Lowered(name, XtEnotUseful, sizeof(name));
+ QnotUseful = XrmStringToQuark(name);
+ XmuNCopyISOLatin1Lowered(name, XtEwhenMapped, sizeof(name));
+ QwhenMapped = XrmStringToQuark(name);
+ XmuNCopyISOLatin1Lowered(name, XtEalways, sizeof(name));
+ Qalways = XrmStringToQuark(name);
+ XmuNCopyISOLatin1Lowered(name, XtEdefault, sizeof(name));
+ Qdefault = XrmStringToQuark(name);
+ haveQuarks = True;
+ }
+}
+
+/*ARGSUSED*/
+void
+XmuCvtStringToBackingStore(XrmValue *args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ XrmQuark q;
+ char name[11];
+ static int backingStoreType;
+
+ if (*num_args != 0)
+ XtWarning("String to BackingStore conversion needs no extra arguments");
+
+ InitializeQuarks();
+ XmuNCopyISOLatin1Lowered(name, (char *)fromVal->addr, sizeof(name));
+
+ q = XrmStringToQuark (name);
+ if (q == QnotUseful)
+ backingStoreType = NotUseful;
+ else if (q == QwhenMapped)
+ backingStoreType = WhenMapped;
+ else if (q == Qalways)
+ backingStoreType = Always;
+ else if (q == Qdefault)
+ backingStoreType = Always + WhenMapped + NotUseful;
+ else
+ {
+ XtStringConversionWarning((char *)fromVal->addr, XtRBackingStore);
+ return;
+ }
+ toVal->size = sizeof(int);
+ toVal->addr = (XPointer)&backingStoreType;
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtBackingStoreToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal,
+ XtPointer *data)
+{
+ static String buffer;
+ Cardinal size;
+
+ switch (*(int *)fromVal->addr)
+ {
+ case NotUseful:
+ buffer = XtEnotUseful;
+ break;
+ case WhenMapped:
+ buffer = XtEwhenMapped;
+ break;
+ case Always:
+ buffer = XtEalways;
+ break;
+ case (Always + WhenMapped + NotUseful):
+ buffer = XtEdefault;
+ break;
+ default:
+ XtWarning("Cannot convert BackingStore to String");
+ toVal->addr = NULL;
+ toVal->size = 0;
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size < size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
diff --git a/nx-X11/lib/Xmu/StrToBmap.c b/nx-X11/lib/Xmu/StrToBmap.c
new file mode 100644
index 000000000..f46a99a1a
--- /dev/null
+++ b/nx-X11/lib/Xmu/StrToBmap.c
@@ -0,0 +1,150 @@
+/* $Xorg: StrToBmap.c,v 1.4 2001/02/09 02:03:53 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xmu/StrToBmap.c,v 1.5 2001/01/17 19:42:57 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Drawing.h>
+
+
+/*
+ * XmuConvertStringToBitmap:
+ *
+ * creates a depth-1 Pixmap suitable for window manager icons.
+ * "string" represents a bitmap(1) filename which may be absolute,
+ * or relative to the global resource bitmapFilePath, class
+ * BitmapFilePath. If the resource is not defined, the default
+ * value is the build symbol BITMAPDIR.
+ *
+ * shares lots of code with XmuConvertStringToCursor.
+ *
+ * To use, include the following in your ClassInitialize procedure:
+
+static XtConvertArgRec screenConvertArg[] = {
+ {XtBaseOffset, (XtPointer) XtOffset(Widget, core.screen), sizeof(Screen *)}
+};
+
+ XtAddConverter("String", "Bitmap", XmuCvtStringToBitmap,
+ screenConvertArg, XtNumber(screenConvertArg));
+ *
+ */
+
+#define done(address, type) \
+ { (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; }
+
+
+/*ARGSUSED*/
+void
+XmuCvtStringToBitmap(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static Pixmap pixmap; /* static for cvt magic */
+ char *name = (char *)fromVal->addr;
+ Screen *screen;
+ Display *dpy;
+ XrmDatabase db;
+ String fn;
+ unsigned int width, height;
+ int xhot, yhot;
+ unsigned char *data;
+
+ if (*num_args != 1)
+ XtErrorMsg("wrongParameters","cvtStringToBitmap","XtToolkitError",
+ "String to pixmap conversion needs screen argument",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if (strcmp(name, "None") == 0) {
+ pixmap = None;
+ done(&pixmap, Pixmap);
+ return;
+ }
+
+ if (strcmp(name, "ParentRelative") == 0) {
+ pixmap = ParentRelative;
+ done(&pixmap, Pixmap);
+ return;
+ }
+
+ screen = *((Screen **) args[0].addr);
+ pixmap = XmuLocateBitmapFile (screen, name,
+ NULL, 0, NULL, NULL, NULL, NULL);
+ if (pixmap == None) {
+ dpy = DisplayOfScreen(screen);
+ db = XrmGetDatabase(dpy);
+ XrmSetDatabase(dpy, XtScreenDatabase(screen));
+ fn = XtResolvePathname(dpy, "bitmaps", name, "", NULL, NULL, 0, NULL);
+ if (!fn)
+ fn = XtResolvePathname(dpy, "", name, ".xbm", NULL, NULL, 0, NULL);
+ XrmSetDatabase(dpy, db);
+ if (fn &&
+ XmuReadBitmapDataFromFile (fn, &width, &height, &data,
+ &xhot, &yhot) == BitmapSuccess) {
+ pixmap = XCreatePixmapFromBitmapData (dpy,
+ RootWindowOfScreen(screen),
+ (char *) data, width, height,
+ 1, 0, 1);
+ XFree ((char *)data);
+ }
+ }
+
+ if (pixmap != None) {
+ done (&pixmap, Pixmap);
+ } else {
+ XtStringConversionWarning (name, "Pixmap");
+ return;
+ }
+}
+
diff --git a/nx-X11/lib/Xmu/StrToCurs.c b/nx-X11/lib/Xmu/StrToCurs.c
new file mode 100644
index 000000000..7f13c0d4e
--- /dev/null
+++ b/nx-X11/lib/Xmu/StrToCurs.c
@@ -0,0 +1,351 @@
+/* $Xorg: StrToCurs.c,v 1.4 2001/02/09 02:03:53 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.
+
+******************************************************************/
+
+/* $XFree86: xc/lib/Xmu/StrToCurs.c,v 1.11 2002/09/19 13:21:58 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Drawing.h>
+#include <X11/Xmu/CurUtil.h>
+#include <X11/Xmu/CharSet.h>
+
+#ifndef X_NOT_POSIX
+#include <stdlib.h>
+#ifdef _POSIX_SOURCE
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif
+#endif /* X_NOT_POSIX */
+#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 /* PATH_MAX */
+
+/* Kludge source to avoid encountering broken shared library linkers
+ which insist on resolving references unused by the application,
+ and broken object file formats that don't correctly distinguish
+ references to procedures from references to data.
+ */
+#if defined(SUNSHLIB) || defined(SVR4)
+#define XMU_KLUDGE
+#endif
+
+/*
+ * XmuConvertStringToCursor:
+ *
+ * allows String to specify a standard cursor name (from cursorfont.h), a
+ * font name and glyph index of the form "FONT fontname index [[font] index]",
+ * or a bitmap file name (absolute, or relative to the global resource
+ * bitmapFilePath, class BitmapFilePath). If the resource is not
+ * defined, the default value is the build symbol BITMAPDIR.
+ *
+ * shares lots of code with XmuCvtStringToPixmap, but unfortunately
+ * can't use it as the hotspot info is lost.
+ *
+ * To use, include the following in your ClassInitialize procedure:
+
+static XtConvertArgRec screenConvertArg[] = {
+ {XtBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
+ sizeof(Screen *)}
+};
+
+ XtAddConverter(XtRString, XtRCursor, XmuCvtStringToCursor,
+ screenConvertArg, XtNumber(screenConvertArg));
+ *
+ */
+
+#define done(address, type) \
+ { (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; }
+
+#define FONTSPECIFIER "FONT "
+
+/*ARGSUSED*/
+void
+XmuCvtStringToCursor(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static Cursor cursor; /* static for cvt magic */
+ char *name = (char *)fromVal->addr;
+ Screen *screen;
+ register int i;
+ char maskname[PATH_MAX];
+ Pixmap source, mask = 0;
+ /* XXX - make fg/bg resources */
+ static XColor bgColor = {0, 0xffff, 0xffff, 0xffff};
+ static XColor fgColor = {0, 0, 0, 0};
+ int xhot, yhot;
+ int len;
+
+
+ if (*num_args != 1)
+ XtErrorMsg("wrongParameters","cvtStringToCursor","XtToolkitError",
+ "String to cursor conversion needs screen argument",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if (XmuCompareISOLatin1(name, "None") == 0)
+ {
+ cursor = None;
+ done(&cursor, Cursor);
+ return;
+ }
+
+ screen = *((Screen **) args[0].addr);
+
+ if (0 == strncmp(FONTSPECIFIER, name, strlen(FONTSPECIFIER))) {
+ char source_name[PATH_MAX], mask_name[PATH_MAX];
+ int source_char, mask_char, fields;
+ Font source_font, mask_font;
+ XrmValue fromString, toFont;
+ XrmValue cvtArg;
+ Boolean success;
+ Display *dpy = DisplayOfScreen(screen);
+ char *strspec = NULL;
+#ifdef XMU_KLUDGE
+ Cardinal num;
+#endif
+
+ strspec = XtMalloc(strlen("FONT %s %d %s %d") + 21);
+ sprintf(strspec, "FONT %%%lds %%d %%%lds %%d",
+ (unsigned long)sizeof(source_name) - 1,
+ (unsigned long)sizeof(mask_name) - 1);
+ fields = sscanf(name, strspec,
+ source_name, &source_char,
+ mask_name, &mask_char);
+ XtFree(strspec);
+ if (fields < 2) {
+ XtStringConversionWarning(name, XtRCursor);
+ return;
+ }
+
+ fromString.addr = source_name;
+ fromString.size = strlen(source_name) + 1;
+ toFont.addr = (XPointer) &source_font;
+ toFont.size = sizeof(Font);
+ cvtArg.addr = (XPointer) &dpy;
+ cvtArg.size = sizeof(Display *);
+ /* XXX using display of screen argument as message display */
+#ifdef XMU_KLUDGE
+ /* XXX Sacrifice caching */
+ num = 1;
+ success = XtCvtStringToFont(dpy, &cvtArg, &num, &fromString, &toFont,
+ NULL);
+#else
+ success = XtCallConverter(dpy, XtCvtStringToFont, &cvtArg,
+ (Cardinal)1, &fromString, &toFont, NULL);
+#endif
+ if (!success) {
+ XtStringConversionWarning(name, XtRCursor);
+ return;
+ }
+
+ switch (fields) {
+ case 2: /* defaulted mask font & char */
+ mask_font = source_font;
+ mask_char = source_char;
+ break;
+
+ case 3: /* defaulted mask font */
+ mask_font = source_font;
+ mask_char = atoi(mask_name);
+ break;
+
+ case 4: /* specified mask font & char */
+ fromString.addr = mask_name;
+ fromString.size = strlen(mask_name) + 1;
+ toFont.addr = (XPointer) &mask_font;
+ toFont.size = sizeof(Font);
+ /* XXX using display of screen argument as message display */
+#ifdef XMU_KLUDGE
+ /* XXX Sacrifice caching */
+ num = 1;
+ success = XtCvtStringToFont(dpy, &cvtArg, &num, &fromString,
+ &toFont, NULL);
+#else
+ success = XtCallConverter(dpy, XtCvtStringToFont, &cvtArg,
+ (Cardinal)1, &fromString, &toFont, NULL);
+#endif
+ if (!success) {
+ XtStringConversionWarning(name, XtRCursor);
+ return;
+ }
+ }
+
+ cursor = XCreateGlyphCursor( DisplayOfScreen(screen), source_font,
+ mask_font, source_char, mask_char,
+ &fgColor, &bgColor );
+ done(&cursor, Cursor);
+ return;
+ }
+
+ i = XmuCursorNameToIndex (name);
+ if (i != -1) {
+ cursor = XCreateFontCursor (DisplayOfScreen(screen), i);
+ done(&cursor, Cursor);
+ return;
+ }
+
+ if ((source = XmuLocateBitmapFile (screen, name,
+ maskname, (sizeof maskname) - 4,
+ NULL, NULL, &xhot, &yhot)) == None) {
+ XtStringConversionWarning (name, XtRCursor);
+ cursor = None;
+ done(&cursor, Cursor);
+ return;
+ }
+ len = strlen (maskname);
+ for (i = 0; i < 2; i++) {
+ strcpy (maskname + len, i == 0 ? "Mask" : "msk");
+ if ((mask = XmuLocateBitmapFile (screen, maskname, NULL, 0,
+ NULL, NULL, NULL, NULL)) != None)
+ break;
+ }
+
+ cursor = XCreatePixmapCursor( DisplayOfScreen(screen), source, mask,
+ &fgColor, &bgColor, xhot, yhot );
+ XFreePixmap( DisplayOfScreen(screen), source );
+ if (mask != None) XFreePixmap( DisplayOfScreen(screen), mask );
+
+ done(&cursor, Cursor);
+}
+
+#define new_done(type, value) \
+ { \
+ if (toVal->addr != NULL) { \
+ if (toVal->size < sizeof(type)) { \
+ toVal->size = sizeof(type); \
+ return False; \
+ } \
+ *(type*)(toVal->addr) = (value); \
+ } \
+ else { \
+ static type static_val; \
+ static_val = (value); \
+ toVal->addr = (XPointer)&static_val; \
+ } \
+ toVal->size = sizeof(type); \
+ return True; \
+ }
+
+/* Function Name: XmuCvtStringToColorCursor
+ * Description: Converts a string into a colored cursor.
+ * Arguments: dpy
+ * args - an argument list (see below).
+ * num_args - number of elements in the argument list.
+ * fromVal - value to convert from.
+ * toVal - value to convert to.
+ * data
+ * Returns: True or False
+ */
+
+/*ARGSUSED*/
+Boolean
+XmuCvtStringToColorCursor(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal,
+ XtPointer *converter_data)
+{
+ Cursor cursor;
+ Screen *screen;
+ Pixel fg, bg;
+ Colormap c_map;
+ XColor colors[2];
+ Cardinal number;
+ XrmValue ret_val;
+
+ if (*num_args != 4) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "wrongParameters","cvtStringToColorCursor","XmuError",
+ "String to color cursor conversion needs four arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ return False;
+ }
+
+ screen = *((Screen **) args[0].addr);
+ fg = *((Pixel *) args[1].addr);
+ bg = *((Pixel *) args[2].addr);
+ c_map = *((Colormap *) args[3].addr);
+
+ number = 1;
+ XmuCvtStringToCursor(args, &number, fromVal, &ret_val);
+
+ cursor = *((Cursor *) ret_val.addr);
+
+ if (cursor == None || (fg == BlackPixelOfScreen(screen)
+ && bg == WhitePixelOfScreen(screen)))
+ new_done(Cursor, cursor);
+
+ colors[0].pixel = fg;
+ colors[1].pixel = bg;
+
+ XQueryColors (dpy, c_map, colors, 2);
+ XRecolorCursor(dpy, cursor, colors, colors + 1);
+ new_done(Cursor, cursor);
+}
+
+
+
diff --git a/nx-X11/lib/Xmu/StrToGrav.c b/nx-X11/lib/Xmu/StrToGrav.c
new file mode 100644
index 000000000..a0c99687c
--- /dev/null
+++ b/nx-X11/lib/Xmu/StrToGrav.c
@@ -0,0 +1,151 @@
+/* $Xorg: StrToGrav.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/StrToGrav.c,v 1.6 2001/01/17 19:42:57 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/CharSet.h>
+
+#define done(address, type) \
+{ (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; }
+
+/*
+ * Initialization
+ */
+static struct _namepair {
+ XrmQuark quark;
+ char *name;
+ XtGravity gravity;
+} names[] = {
+ { NULLQUARK, XtEForget, ForgetGravity },
+ { NULLQUARK, XtENorthWest, NorthWestGravity },
+ { NULLQUARK, XtENorth, NorthGravity },
+ { NULLQUARK, XtENorthEast, NorthEastGravity },
+ { NULLQUARK, XtEWest, WestGravity },
+ { NULLQUARK, XtECenter, CenterGravity },
+ { NULLQUARK, XtEEast, EastGravity },
+ { NULLQUARK, XtESouthWest, SouthWestGravity },
+ { NULLQUARK, XtESouth, SouthGravity },
+ { NULLQUARK, XtESouthEast, SouthEastGravity },
+ { NULLQUARK, XtEStatic, StaticGravity },
+ { NULLQUARK, XtEUnmap, UnmapGravity },
+ { NULLQUARK, XtEleft, WestGravity },
+ { NULLQUARK, XtEtop, NorthGravity },
+ { NULLQUARK, XtEright, EastGravity },
+ { NULLQUARK, XtEbottom, SouthGravity },
+ { NULLQUARK, NULL, ForgetGravity }
+};
+
+/*
+ * This function is deprecated as of the addition of
+ * XtCvtStringToGravity in R6
+ */
+void
+XmuCvtStringToGravity(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static Boolean haveQuarks = False;
+ char name[10];
+ XrmQuark q;
+ struct _namepair *np;
+
+ if (*num_args != 0)
+ XtWarningMsg("wrongParameters","cvtStringToGravity","XtToolkitError",
+ "String to Gravity conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if (!haveQuarks)
+ {
+ for (np = names; np->name; np++)
+ np->quark = XrmPermStringToQuark(np->name);
+ haveQuarks = True;
+ }
+
+ XmuNCopyISOLatin1Lowered(name, (char *)fromVal->addr, sizeof(name));
+ q = XrmStringToQuark(name);
+
+ for (np = names; np->name; np++)
+ {
+ if (np->quark == q)
+ {
+ done(&np->gravity, XtGravity);
+ return;
+ }
+ }
+
+ XtStringConversionWarning((char *)fromVal->addr, XtRGravity);
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtGravityToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal, XtPointer *data)
+{
+ static char *buffer;
+ Cardinal size;
+ struct _namepair *np;
+ XtGravity gravity;
+
+ gravity = *(XtGravity *)fromVal->addr;
+ buffer = NULL;
+ for (np = names; np->name; np++)
+ if (np->gravity == gravity)
+ {
+ buffer = np->name;
+ break;
+ }
+
+ if (!buffer)
+ {
+ XtAppWarning(XtDisplayToApplicationContext(dpy),
+ "Cannot convert Gravity to String");
+ toVal->addr = NULL;
+ toVal->size = 0;
+
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size <= size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = size;
+
+ return (True);
+}
diff --git a/nx-X11/lib/Xmu/StrToJust.c b/nx-X11/lib/Xmu/StrToJust.c
new file mode 100644
index 000000000..f3b4b7828
--- /dev/null
+++ b/nx-X11/lib/Xmu/StrToJust.c
@@ -0,0 +1,140 @@
+/* $Xorg: StrToJust.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+
+/* $XFree86: xc/lib/Xmu/StrToJust.c,v 1.6 2001/01/17 19:42:57 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <string.h>
+#include <X11/Intrinsic.h>
+#include "Converters.h"
+#include "CharSet.h"
+
+/*
+ * Prototypes
+ */
+static void InitializeQuarks(void);
+
+/*
+ * Initialization
+ */
+static XrmQuark Qleft, Qcenter, Qright;
+static Boolean haveQuarks;
+
+/*
+ * Implementation
+ */
+static void
+InitializeQuarks(void)
+{
+ if (!haveQuarks)
+ {
+ Qleft = XrmPermStringToQuark(XtEleft);
+ Qcenter = XrmPermStringToQuark(XtEcenter);
+ Qright = XrmPermStringToQuark(XtEright);
+ haveQuarks = True;
+ }
+}
+
+/*ARGSUSED*/
+void
+XmuCvtStringToJustify(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static XtJustify e;
+ XrmQuark q;
+ char *s = (char *)fromVal->addr;
+ char name[7];
+
+ if (s == NULL)
+ return;
+
+ InitializeQuarks();
+ XmuNCopyISOLatin1Lowered(name, s, sizeof(name));
+
+ q = XrmStringToQuark(name);
+
+ toVal->size = sizeof(XtJustify);
+ toVal->addr = (XPointer)&e;
+
+ if (q == Qleft)
+ e = XtJustifyLeft;
+ else if (q == Qcenter)
+ e = XtJustifyCenter;
+ else if (q == Qright)
+ e = XtJustifyRight;
+ else
+ {
+ toVal->addr = NULL;
+ XtStringConversionWarning((char *)fromVal->addr, XtRJustify);
+ }
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtJustifyToString(Display *dpy, XrmValue* args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal, XtPointer *data)
+{
+ static String buffer;
+ Cardinal size;
+
+ switch (*(XtJustify *)fromVal->addr)
+ {
+ case XtJustifyLeft:
+ buffer = XtEleft;
+ break;
+ case XtJustifyCenter:
+ buffer = XtEcenter;
+ break;
+ case XtJustifyRight:
+ buffer = XtEright;
+ break;
+ default:
+ XtWarning("Cannot convert Justify to String");
+ toVal->addr = NULL;
+ toVal->size = 0;
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size < size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
diff --git a/nx-X11/lib/Xmu/StrToLong.c b/nx-X11/lib/Xmu/StrToLong.c
new file mode 100644
index 000000000..6a7539aa9
--- /dev/null
+++ b/nx-X11/lib/Xmu/StrToLong.c
@@ -0,0 +1,83 @@
+/* $Xorg: StrToLong.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/StrToLong.c,v 1.8 2001/08/23 00:03:21 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xmu/Converters.h>
+
+void
+XmuCvtStringToLong(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static long l;
+
+ if (*num_args != 0)
+ XtWarning("String to Long conversion needs no extra arguments");
+ if (sscanf((char *)fromVal->addr, "%ld", &l) == 1)
+ {
+ toVal->size = sizeof(long);
+ toVal->addr = (XPointer)&l;
+ }
+ else
+ XtStringConversionWarning((char *)fromVal->addr, XtRLong);
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtLongToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal, XtPointer *data)
+{
+ static char buffer[32];
+ size_t size;
+
+ if (*num_args != 0)
+ XtWarning("Long to String conversion needs no extra arguments");
+
+ XmuSnprintf(buffer, sizeof(buffer), "%ld", *(long *)fromVal->addr);
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size < size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
diff --git a/nx-X11/lib/Xmu/StrToOrnt.c b/nx-X11/lib/Xmu/StrToOrnt.c
new file mode 100644
index 000000000..209b13a19
--- /dev/null
+++ b/nx-X11/lib/Xmu/StrToOrnt.c
@@ -0,0 +1,130 @@
+/* $Xorg: StrToOrnt.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+
+/* $XFree86: xc/lib/Xmu/StrToOrnt.c,v 1.6 2001/01/17 19:42:57 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include "Converters.h"
+#include "CharSet.h"
+
+/*
+ * Prototypes
+ */
+static void InitializeQuarks(void);
+
+/*
+ * Initialization
+ */
+static XrmQuark Qhorizontal, Qvertical;
+static Boolean haveQuarks;
+
+/*
+ * Implementation
+ */
+static void
+InitializeQuarks(void)
+{
+ if (!haveQuarks)
+ {
+ Qhorizontal = XrmPermStringToQuark(XtEhorizontal);
+ Qvertical = XrmPermStringToQuark(XtEvertical);
+ haveQuarks = True;
+ }
+}
+
+/*ARGSUSED*/
+void
+XmuCvtStringToOrientation(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static XtOrientation orient;
+ XrmQuark q;
+ char name[11];
+
+ InitializeQuarks();
+ XmuNCopyISOLatin1Lowered(name, (char *)fromVal->addr, sizeof(name));
+ q = XrmStringToQuark(name);
+
+ toVal->size = sizeof(XtJustify);
+ toVal->addr = (XPointer)&orient;
+
+ if (q == Qhorizontal)
+ orient = XtorientHorizontal;
+ else if (q == Qvertical)
+ orient = XtorientVertical;
+ else
+ {
+ toVal->addr = NULL;
+ XtStringConversionWarning((char *)fromVal->addr, XtROrientation);
+ }
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtOrientationToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal,
+ XtPointer *data)
+{
+ static String buffer;
+ Cardinal size;
+
+ switch (*(XtOrientation *)fromVal->addr)
+ {
+ case XtorientVertical:
+ buffer = XtEvertical;
+ break;
+ case XtorientHorizontal:
+ buffer = XtEhorizontal;
+ break;
+ default:
+ XtWarning("Cannot convert Orientation to String");
+ toVal->addr = NULL;
+ toVal->size = 0;
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size < size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
diff --git a/nx-X11/lib/Xmu/StrToShap.c b/nx-X11/lib/Xmu/StrToShap.c
new file mode 100644
index 000000000..3f17c01e9
--- /dev/null
+++ b/nx-X11/lib/Xmu/StrToShap.c
@@ -0,0 +1,125 @@
+/* $Xorg: StrToShap.c,v 1.5 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/StrToShap.c,v 1.6 2001/01/17 19:42:57 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <string.h>
+#include <X11/Intrinsic.h>
+#include "Converters.h"
+#include "CharSet.h"
+
+/* ARGSUSED */
+#define done(type, value) \
+ { \
+ if (toVal->addr != NULL) { \
+ if (toVal->size < sizeof(type)) { \
+ toVal->size = sizeof(type); \
+ return False; \
+ } \
+ *(type*)(toVal->addr) = (value); \
+ } \
+ else { \
+ static type static_val; \
+ static_val = (value); \
+ toVal->addr = (XtPointer)&static_val; \
+ } \
+ toVal->size = sizeof(type); \
+ return True; \
+ }
+
+
+/*ARGSUSED*/
+Boolean
+XmuCvtStringToShapeStyle(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *from, XrmValue *toVal, XtPointer *data)
+{
+ String name = (String)from->addr;
+
+ if (XmuCompareISOLatin1(name, XtERectangle) == 0)
+ done(int, XmuShapeRectangle);
+ if (XmuCompareISOLatin1(name, XtEOval) == 0)
+ done(int, XmuShapeOval);
+ if (XmuCompareISOLatin1(name, XtEEllipse) == 0)
+ done(int, XmuShapeEllipse);
+ if (XmuCompareISOLatin1(name, XtERoundedRectangle) == 0)
+ done(int, XmuShapeRoundedRectangle);
+
+ XtDisplayStringConversionWarning(dpy, name, XtRShapeStyle);
+
+ return (False);
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtShapeStyleToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal, XtPointer *data)
+{
+ static char *buffer;
+ Cardinal size;
+
+ switch (*(int *)fromVal->addr)
+ {
+ case XmuShapeRectangle:
+ buffer = XtERectangle;
+ break;
+ case XmuShapeOval:
+ buffer = XtEOval;
+ break;
+ case XmuShapeEllipse:
+ buffer = XtEEllipse;
+ break;
+ case XmuShapeRoundedRectangle:
+ buffer = XtERoundedRectangle;
+ break;
+ default:
+ XtAppWarning(XtDisplayToApplicationContext(dpy),
+ "Cannot convert ShapeStyle to String");
+ toVal->addr = NULL;
+ toVal->size = 0;
+
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size <= size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = size;
+
+ return (True);
+}
diff --git a/nx-X11/lib/Xmu/StrToWidg.c b/nx-X11/lib/Xmu/StrToWidg.c
new file mode 100644
index 000000000..22411de3a
--- /dev/null
+++ b/nx-X11/lib/Xmu/StrToWidg.c
@@ -0,0 +1,225 @@
+/* $Xorg: StrToWidg.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/StrToWidg.c,v 1.6 2001/01/17 19:42:57 dawes Exp $ */
+
+/*
+ * XmuCvtStringToWidget
+ *
+ * static XtConvertArgRec parentCvtArgs[] = {
+ * {XtBaseOffset, (XtPointer)XtOffset(Widget, core.parent), sizeof(Widget)},
+ * };
+ *
+ * matches the string against the name of the immediate children (normal
+ * or popup) of the parent. If none match, compares string to classname
+ * & returns first match. Case is significant.
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/ObjectP.h>
+#include <X11/Xmu/Converters.h>
+
+#define done(address, type) \
+{ \
+ toVal->size = sizeof(type); \
+ toVal->addr = (XPointer)address; \
+ return; \
+}
+
+/*ARGSUSED*/
+void
+XmuCvtStringToWidget(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static Widget widget, *widgetP, parent;
+ XrmName name = XrmStringToName(fromVal->addr);
+ int i;
+
+ if (*num_args != 1)
+ XtErrorMsg("wrongParameters", "cvtStringToWidget", "xtToolkitError",
+ "StringToWidget conversion needs parent arg", NULL, 0);
+
+ parent = *(Widget*)args[0].addr;
+ /* try to match names of normal children */
+ if (XtIsComposite(parent))
+ {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++)
+ if ((*widgetP)->core.xrm_name == name)
+ {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+ }
+
+ /* try to match names of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++)
+ if ((*widgetP)->core.xrm_name == name)
+ {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+
+ /* try to match classes of normal children */
+ if (XtIsComposite(parent))
+ {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++)
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name)
+ {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+ }
+
+ /* try to match classes of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++)
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name)
+ {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+
+ XtStringConversionWarning(fromVal->addr, XtRWidget);
+ toVal->addr = NULL;
+ toVal->size = 0;
+}
+
+#undef done
+
+#define newDone(type, value) \
+ { \
+ if (toVal->addr != NULL) { \
+ if (toVal->size < sizeof(type)) { \
+ toVal->size = sizeof(type); \
+ return False; \
+ } \
+ *(type*)(toVal->addr) = (value); \
+ } \
+ else { \
+ static type static_val; \
+ static_val = (value); \
+ toVal->addr = (XtPointer)&static_val; \
+ } \
+ toVal->size = sizeof(type); \
+ return True; \
+ }
+
+
+/*ARGSUSED*/
+Boolean
+XmuNewCvtStringToWidget(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ Widget *widgetP, parent;
+ XrmName name = XrmStringToName(fromVal->addr);
+ int i;
+
+ if (*num_args != 1)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "wrongParameters","cvtStringToWidget","xtToolkitError",
+ "String To Widget conversion needs parent argument",
+ (String *)NULL, (Cardinal *)NULL);
+
+ parent = *(Widget*)args[0].addr;
+ /* try to match names of normal children */
+ if (XtIsComposite(parent))
+ {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++)
+ if ((*widgetP)->core.xrm_name == name)
+ newDone(Widget, *widgetP);
+ }
+
+ /* try to match names of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++)
+ if ((*widgetP)->core.xrm_name == name)
+ newDone(Widget, *widgetP);
+
+ /* try to match classes of normal children */
+ if (XtIsComposite(parent))
+ {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++)
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name)
+ newDone(Widget, *widgetP);
+ }
+
+ /* try to match classes of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++)
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name)
+ newDone(Widget, *widgetP);
+
+ XtDisplayStringConversionWarning(dpy, (String)fromVal->addr, XtRWidget);
+ return (False);
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtWidgetToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal,
+ XtPointer *data)
+{
+ static String buffer;
+ Cardinal size;
+ Widget widget;
+
+ widget = *(Widget *)fromVal->addr;
+
+ if (widget)
+ buffer = XrmQuarkToString(widget->core.xrm_name);
+ else
+ buffer = "(null)";
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size < size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
diff --git a/nx-X11/lib/Xmu/SysUtil.h b/nx-X11/lib/Xmu/SysUtil.h
new file mode 100644
index 000000000..9f5b033ac
--- /dev/null
+++ b/nx-X11/lib/Xmu/SysUtil.h
@@ -0,0 +1,60 @@
+/* $Xorg: SysUtil.h,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/SysUtil.h,v 1.9 2001/12/14 19:55:55 dawes Exp $ */
+
+#ifndef _SYSUTIL_H_
+#define _SYSUTIL_H_
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+int XmuGetHostname
+(
+ char *buf_return,
+ int maxlen
+);
+
+#ifndef _XMU_H_
+int XmuSnprintf
+(
+ char *str,
+ int size,
+ _Xconst char *fmt,
+ ...
+ )
+#if defined(__GNUC__) && \
+ ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ > 4)))
+__attribute((format(printf,3,4)))
+#endif
+;
+#endif
+
+_XFUNCPROTOEND
+
+#endif /* _SYSUTIL_H_ */
diff --git a/nx-X11/lib/Xmu/UpdMapHint.c b/nx-X11/lib/Xmu/UpdMapHint.c
new file mode 100644
index 000000000..aeba3037f
--- /dev/null
+++ b/nx-X11/lib/Xmu/UpdMapHint.c
@@ -0,0 +1,62 @@
+/* $Xorg: UpdMapHint.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/UpdMapHint.c,v 1.6 2001/01/17 19:42:57 dawes Exp $ */
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/WinUtil.h>
+
+Bool
+XmuUpdateMapHints(Display *dpy, Window w, XSizeHints *hints)
+{
+ static XSizeHints *shp = NULL;
+
+ if (!hints) { /* get them first */
+ long supp;
+
+ if (!shp) {
+ shp = XAllocSizeHints();
+ if (!shp) return False;
+ }
+ if (!XGetWMNormalHints (dpy, w, shp, &supp)) return False;
+ hints = shp;
+ }
+ hints->flags &= ~(PPosition|PSize);
+ hints->flags |= (USPosition|USSize);
+ XSetWMNormalHints (dpy, w, hints);
+ return True;
+}
+
diff --git a/nx-X11/lib/Xmu/VisCmap.c b/nx-X11/lib/Xmu/VisCmap.c
new file mode 100644
index 000000000..54022cc9a
--- /dev/null
+++ b/nx-X11/lib/Xmu/VisCmap.c
@@ -0,0 +1,183 @@
+/* $Xorg: VisCmap.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/VisCmap.c,v 1.6 2001/01/17 19:42:57 dawes Exp $ */
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <math.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+/*
+ * To create all of the appropriate standard colormaps for a given visual on
+ * a given screen, use XmuVisualStandardColormaps.
+ *
+ * Define all appropriate standard colormap properties for the given visual.
+ * If replace is true, any previous definition will be removed.
+ * If retain is true, new properties will be retained for the duration of
+ * the server session. Return 0 on failure, non-zero on success.
+ * On failure, no new properties will be defined, and, old ones may have
+ * been removed if replace was True.
+ *
+ * Not all standard colormaps are meaningful to all visual classes. This
+ * routine will check and define the following properties for the following
+ * classes, provided that the size of the colormap is not too small.
+ *
+ * DirectColor and PseudoColor
+ * RGB_DEFAULT_MAP
+ * RGB_BEST_MAP
+ * RGB_RED_MAP
+ * RGB_GREEN_MAP
+ * RGB_BLUE_MAP
+ * RGB_GRAY_MAP
+ *
+ * TrueColor and StaticColor
+ * RGB_BEST_MAP
+ *
+ * GrayScale and StaticGray
+ * RGB_GRAY_MAP
+ */
+
+Status
+XmuVisualStandardColormaps(Display *dpy, int screen, VisualID visualid,
+ unsigned int depth, Bool replace, Bool retain)
+ /*
+ * dpy - specifies server connection
+ * screen - specifies screen number
+ * visualid - specifies the visual
+ * depth - specifies the visual
+ * replace specifies - whether to replace
+ * retain - specifies whether to retain
+ */
+{
+ Status status;
+ int n;
+ long vinfo_mask;
+ XVisualInfo vinfo_template, *vinfo;
+
+ status = 0;
+ vinfo_template.screen = screen;
+ vinfo_template.visualid = visualid;
+ vinfo_template.depth = depth;
+ vinfo_mask = VisualScreenMask | VisualIDMask | VisualDepthMask;
+ if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
+ return 0;
+
+ if (vinfo->colormap_size <= 2) {
+ /* Monochrome visuals have no standard maps; considered successful */
+ XFree((char *) vinfo);
+ return 1;
+ }
+
+ switch (vinfo->class)
+ {
+ case PseudoColor:
+ case DirectColor:
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_DEFAULT_MAP, replace,retain);
+ if (!status) break;
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_GRAY_MAP, replace, retain);
+ if (!status) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ break;
+ }
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_RED_MAP, replace, retain);
+ if (!status) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
+ break;
+ }
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_GREEN_MAP, replace, retain);
+ if (!status) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
+ break;
+ }
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_BLUE_MAP, replace, retain);
+ if (!status) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP);
+ break;
+ }
+ /* fall through */
+
+ case StaticColor:
+ case TrueColor:
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_BEST_MAP, replace, retain);
+ if (!status && (vinfo->class == PseudoColor ||
+ vinfo->class == DirectColor)) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_BLUE_MAP);
+ }
+ break;
+ /* the end for PseudoColor, DirectColor, StaticColor, and TrueColor */
+
+ case GrayScale:
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_DEFAULT_MAP, replace,
+ retain);
+ if (! status) break;
+ /*FALLTHROUGH*/
+
+ case StaticGray:
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_GRAY_MAP, replace, retain);
+ if (! status && vinfo->class == GrayScale) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ break;
+ }
+ }
+
+ XFree((char *) vinfo);
+ return status;
+}
diff --git a/nx-X11/lib/Xmu/WhitePoint.h b/nx-X11/lib/Xmu/WhitePoint.h
new file mode 100644
index 000000000..a05bddd4a
--- /dev/null
+++ b/nx-X11/lib/Xmu/WhitePoint.h
@@ -0,0 +1,65 @@
+/* $Xorg: WhitePoint.h,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 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.
+
+*/
+
+
+/*
+ *
+ * DESCRIPTION
+ * This file contains a series of standard white point values.
+ */
+#define CIE_A_u 0.2560
+#define CIE_A_v 0.5243
+#define CIE_A_Y 1.0000
+
+#define CIE_B_u 0.2137
+#define CIE_B_v 0.4852
+#define CIE_B_Y 1.0000
+
+#define CIE_C_u 0.2009
+#define CIE_C_v 0.4609
+#define CIE_C_Y 1.0000
+
+#define CIE_D55_u 0.2044
+#define CIE_D55_v 0.4808
+#define CIE_D55_Y 1.0000
+
+#define CIE_D65_u 0.1978
+#define CIE_D65_v 0.4684
+#define CIE_D65_Y 1.0000
+
+#define CIE_D75_u 0.1935
+#define CIE_D75_v 0.4586
+#define CIE_D75_Y 1.0000
+
+#define ASTM_D50_u 0.2092
+#define ASTM_D50_v 0.4881
+#define ASTM_D50_Y 1.0000
+
+#define WP_9300K_u 0.1884
+#define WP_9300K_v 0.4463
+#define WP_9300K_Y 1.0000
diff --git a/nx-X11/lib/Xmu/WidgetNode.c b/nx-X11/lib/Xmu/WidgetNode.c
new file mode 100644
index 000000000..e157ccc10
--- /dev/null
+++ b/nx-X11/lib/Xmu/WidgetNode.c
@@ -0,0 +1,310 @@
+/* $Xorg: WidgetNode.c,v 1.5 2001/02/09 02:03:53 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.
+
+*/
+
+/* $XFree86: xc/lib/Xmu/WidgetNode.c,v 1.12 2002/09/19 13:21:58 tsi Exp $ */
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xos.h>
+#include <X11/IntrinsicP.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/WidgetNode.h>
+
+/*
+ * Prototypes
+ */
+static char *binsearch(char*, char*, int, int,
+ int (*__compar)(_Xconst void*, _Xconst void*));
+static int compare_resource_entries(_Xconst void *a, _Xconst void *b);
+static XmuWidgetNode *find_resource(XmuWidgetNode*, char*, Bool);
+static void mark_resource_owner(XmuWidgetNode*);
+/*
+ * Implementation
+ */
+static char *
+binsearch(char *key, char *base, int nelems, int elemsize,
+ int compar(_Xconst void*, _Xconst void*))
+ /*
+ * key - template of object to find
+ * base - beginning of array
+ * nelems - number of elements in array
+ * elemsize - sizeof an element
+ * compar - qsort-style compare function
+ */
+{
+ int lower = 0, upper = nelems - 1;
+
+ while (lower <= upper) {
+ int middle = (lower + upper) / 2;
+ char *p = base + middle * elemsize;
+ int res = (*compar) (p, key);
+
+ if (res < 0) {
+ lower = middle + 1;
+ } else if (res == 0) {
+ return p;
+ } else {
+ upper = middle - 1;
+ }
+ }
+
+ return NULL;
+}
+
+
+static int
+compare_resource_entries(register _Xconst void *a,
+ register _Xconst void *b)
+{
+ return strcmp (((XtResourceList)a)->resource_name,
+ ((XtResourceList)b)->resource_name);
+}
+
+
+static XmuWidgetNode *
+find_resource(XmuWidgetNode *node, char *name, Bool cons)
+{
+ register XmuWidgetNode *sup;
+ XtResource res;
+
+#define reslist ((char *) (cons ? sup->constraints : sup->resources))
+#define nreslist (int) (cons ? sup->nconstraints : sup->nresources)
+
+ res.resource_name = name;
+ for (sup = node->superclass;
+ sup && (XtResourceList) binsearch ((char *) &res,
+ reslist, nreslist,
+ sizeof(XtResource),
+ compare_resource_entries);
+ node = sup, sup = sup->superclass) ;
+
+#undef reslist
+#undef nreslist
+
+ return node;
+}
+
+
+static void
+mark_resource_owner(register XmuWidgetNode *node)
+{
+ register Cardinal i;
+ XtResourceList childres;
+
+ childres = node->resources;
+ for (i = 0; i < node->nresources; i++, childres++) {
+ node->resourcewn[i] = find_resource (node, childres->resource_name,
+ False);
+ }
+
+ childres = node->constraints;
+ for (i = 0; i < node->nconstraints; i++, childres++) {
+ node->constraintwn[i] = find_resource (node, childres->resource_name,
+ True);
+ }
+}
+
+
+/*
+ * Public Interfaces
+ */
+
+void
+XmuWnInitializeNodes(XmuWidgetNode *nodearray, int nnodes)
+{
+ int i;
+ XmuWidgetNode *wn;
+
+ /*
+ * Assume that the node array is in alphabetic order, so we need to
+ * search backwards to make sure that the children are listed forward.
+ */
+ for (i = nnodes - 1, wn = nodearray + (nnodes - 1); i >= 0; i--, wn--) {
+ WidgetClass superclass = XmuWnSuperclass(wn);
+ int j;
+ XmuWidgetNode *swn;
+ int lablen = strlen (wn->label);
+ int namelen = strlen (XmuWnClassname(wn));
+
+ wn->lowered_label = XtMalloc (lablen + namelen + 2);
+#if 0
+ /* XtMalloc exits if failed */
+ if (!wn->lowered_label) {
+ fprintf (stderr,
+ "%s: unable to allocate %d bytes for widget name\n",
+ "XmuWnInitializeNodes", lablen + namelen + 2);
+ exit (1);
+ }
+#endif
+ wn->lowered_classname = wn->lowered_label + (lablen + 1);
+ XmuCopyISOLatin1Lowered (wn->lowered_label, wn->label);
+ XmuCopyISOLatin1Lowered (wn->lowered_classname, XmuWnClassname(wn));
+ wn->superclass = NULL;
+ wn->have_resources = False;
+ wn->resources = NULL;
+ wn->resourcewn = NULL;
+ wn->nresources = 0;
+ wn->constraints = NULL;
+ wn->constraintwn = NULL;
+ wn->nconstraints = 0;
+ wn->data = (XtPointer) NULL;
+
+ /*
+ * walk up the superclass chain
+ */
+ while (superclass) {
+ for (j = 0, swn = nodearray; j < nnodes; j++, swn++) {
+ if (superclass == XmuWnClass(swn)) {
+ wn->superclass = swn;
+ goto done; /* stupid C language */
+ }
+ }
+ /*
+ * Hmm, we have a hidden superclass (such as in core in R4); just
+ * ignore it and keep on walking
+ */
+ superclass = superclass->core_class.superclass;
+ }
+ done:
+ if (wn->superclass) {
+ wn->siblings = wn->superclass->children;
+ wn->superclass->children = wn;
+ }
+ }
+
+ return;
+}
+
+
+void
+XmuWnFetchResources(XmuWidgetNode *node, Widget toplevel,
+ XmuWidgetNode *topnode)
+{
+ Widget dummy;
+ XmuWidgetNode *wn;
+
+ if (node->have_resources) return;
+
+ dummy = XtCreateWidget (node->label, XmuWnClass(node), toplevel,
+ NULL, 0);
+ if (dummy) XtDestroyWidget (dummy);
+
+
+ /*
+ * walk up tree geting resources; since we've instantiated the widget,
+ * we know that all of our superclasses have been initialized
+ */
+ for (wn = node; wn && !wn->have_resources; wn = wn->superclass) {
+ XtGetResourceList (XmuWnClass(wn), &wn->resources, &wn->nresources);
+ if (wn->resources) {
+ qsort ((char *) wn->resources, wn->nresources,
+ sizeof(XtResource), compare_resource_entries);
+ }
+ wn->resourcewn = (XmuWidgetNode **) XtCalloc (wn->nresources,
+ sizeof (XmuWidgetNode *));
+ if (!wn->resourcewn) {
+ fprintf (stderr,
+ "%s: unable to calloc %d %ld byte widget node ptrs\n",
+ "XmuWnFetchResources", wn->nresources,
+ (unsigned long)sizeof (XmuWidgetNode *));
+ exit (1);
+ }
+
+ XtGetConstraintResourceList (XmuWnClass(wn), &wn->constraints,
+ &wn->nconstraints);
+ if (wn->constraints) {
+ qsort ((char *) wn->constraints, wn->nconstraints,
+ sizeof(XtResource), compare_resource_entries);
+ }
+ wn->constraintwn = (XmuWidgetNode **)
+ XtCalloc (wn->nconstraints, sizeof (XmuWidgetNode *));
+ if (!wn->constraintwn) {
+ fprintf (stderr,
+ "%s: unable to calloc %d %ld byte widget node ptrs\n",
+ "XmuWnFetchResources", wn->nconstraints,
+ (unsigned long)sizeof (XmuWidgetNode *));
+ exit (1);
+ }
+
+ wn->have_resources = True;
+ if (wn == topnode) break;
+ }
+
+
+ /*
+ * Walk up tree removing all resources that appear in superclass; we can
+ * mash the resource list in place since it was copied out of widget.
+ */
+ for (wn = node; wn; wn = wn->superclass) {
+ mark_resource_owner (wn);
+ if (wn == topnode) break;
+ }
+
+ return;
+}
+
+
+int
+XmuWnCountOwnedResources(XmuWidgetNode *node, XmuWidgetNode *ownernode,
+ Bool cons)
+{
+ register int i;
+ XmuWidgetNode **wn = (cons ? node->constraintwn : node->resourcewn);
+ int nmatches = 0;
+
+ for (i = (cons ? node->nconstraints : node->nresources); i > 0; i--, wn++)
+ if (*wn == ownernode) nmatches++;
+ return nmatches;
+}
+
+
+XmuWidgetNode *
+XmuWnNameToNode(XmuWidgetNode *nodelist, int nnodes, _Xconst char *name)
+{
+ int i;
+ XmuWidgetNode *wn;
+ char tmp[1024];
+
+ XmuNCopyISOLatin1Lowered(tmp, name, sizeof(tmp));
+ for (i = 0, wn = nodelist; i < nnodes; i++, wn++) {
+ if (strcmp (tmp, wn->lowered_label) == 0 ||
+ strcmp (tmp, wn->lowered_classname) == 0) {
+ return wn;
+ }
+ }
+ return NULL;
+}
diff --git a/nx-X11/lib/Xmu/WidgetNode.h b/nx-X11/lib/Xmu/WidgetNode.h
new file mode 100644
index 000000000..75050d253
--- /dev/null
+++ b/nx-X11/lib/Xmu/WidgetNode.h
@@ -0,0 +1,98 @@
+/* $Xorg: WidgetNode.h,v 1.5 2001/02/09 02:03:53 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/WidgetNode.h,v 1.5 2001/01/17 19:42:57 dawes Exp $ */
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifndef _XmuWidgetNode_h
+#define _XmuWidgetNode_h
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+/*
+ * This is usually initialized by setting the first two fields and letting
+ * rest be implicitly nulled (by genlist.sh, for example)
+ */
+typedef struct _XmuWidgetNode {
+ char *label; /* mixed case name */
+ WidgetClass *widget_class_ptr; /* addr of widget class */
+ struct _XmuWidgetNode *superclass; /* superclass of widget_class */
+ struct _XmuWidgetNode *children, *siblings; /* subclass links */
+ char *lowered_label; /* lowercase version of label */
+ char *lowered_classname; /* lowercase version of class_name */
+ Bool have_resources; /* resources have been fetched */
+ XtResourceList resources; /* extracted resource database */
+ struct _XmuWidgetNode **resourcewn; /* where resources come from */
+ Cardinal nresources; /* number of resources */
+ XtResourceList constraints; /* extracted constraint resources */
+ struct _XmuWidgetNode **constraintwn; /* where constraints come from */
+ Cardinal nconstraints; /* number of constraint resources */
+ XtPointer data; /* extra data */
+} XmuWidgetNode;
+
+#define XmuWnClass(wn) ((wn)->widget_class_ptr[0])
+#define XmuWnClassname(wn) (XmuWnClass(wn)->core_class.class_name)
+#define XmuWnSuperclass(wn) ((XmuWnClass(wn))->core_class.superclass)
+
+ /* external interfaces */
+_XFUNCPROTOBEGIN
+
+void XmuWnInitializeNodes
+(
+ XmuWidgetNode *nodearray,
+ int nnodes
+ );
+
+void XmuWnFetchResources
+(
+ XmuWidgetNode *node,
+ Widget toplevel,
+ XmuWidgetNode *topnode
+ );
+
+int XmuWnCountOwnedResources
+(
+ XmuWidgetNode *node,
+ XmuWidgetNode *ownernode,
+ Bool constraints
+ );
+
+XmuWidgetNode *XmuWnNameToNode
+(
+ XmuWidgetNode *nodelist,
+ int nnodes,
+ _Xconst char *name
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XmuWidgetNode_h */
+
diff --git a/nx-X11/lib/Xmu/WinUtil.h b/nx-X11/lib/Xmu/WinUtil.h
new file mode 100644
index 000000000..0445bcfa8
--- /dev/null
+++ b/nx-X11/lib/Xmu/WinUtil.h
@@ -0,0 +1,64 @@
+/* $Xorg: WinUtil.h,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/WinUtil.h,v 1.6 2001/01/17 19:42:57 dawes Exp $ */
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_WINDOWUTIL_H_
+#define _XMU_WINDOWUTIL_H_
+
+#include <X11/Xutil.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+Window XmuClientWindow
+(
+ Display *dpy,
+ Window win
+ );
+
+Bool XmuUpdateMapHints
+(
+ Display *dpy,
+ Window win,
+ XSizeHints *hints
+ );
+
+Screen *XmuScreenOfWindow
+(
+ Display *dpy,
+ Window w
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_WINDOWUTIL_H_ */
diff --git a/nx-X11/lib/Xmu/Xct.c b/nx-X11/lib/Xmu/Xct.c
new file mode 100644
index 000000000..b186d27d7
--- /dev/null
+++ b/nx-X11/lib/Xmu/Xct.c
@@ -0,0 +1,687 @@
+/* $Xorg: Xct.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/Xct.c,v 1.8 2001/07/25 15:04:50 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xfuncs.h>
+#include "Xct.h"
+#include <stdio.h>
+
+#define UsedGraphic 0x0001
+#define UsedDirection 0x0002
+
+typedef struct _XctPriv {
+ XctString ptr;
+ XctString ptrend;
+ unsigned flags;
+ XctHDirection *dirstack;
+ unsigned dirsize;
+ char **encodings;
+ unsigned enc_count;
+ XctString itembuf;
+ unsigned buf_count;
+} *XctPriv;
+
+#define IsMore(priv) ((priv)->ptr != (priv)->ptrend)
+#define AmountLeft(priv) ((priv)->ptrend - (priv)->ptr)
+
+#include <stdlib.h>
+
+#define HT 0x09
+#define NL 0x0a
+#define ESC 0x1b
+#define CSI 0x9b
+
+#define IsLegalC0(data, c) (((c) == HT) || ((c) == NL) || \
+ (((data)->version > XctVersion) && \
+ ((data)->flags & XctAcceptC0Extensions)))
+
+#define IsLegalC1(priv, c) (((data)->version > XctVersion) && \
+ ((data)->flags & XctAcceptC1Extensions))
+
+#define IsI2(c) (((c) >= 0x20) && ((c) <= 0x2f))
+#define IsI3(c) (((c) >= 0x30) && ((c) <= 0x3f))
+#define IsESCF(c) (((c) >= 0x30) && ((c) <= 0x7e))
+#define IsCSIF(c) (((c) >= 0x40) && ((c) <= 0x7e))
+#define IsC0(c) ((c) <= 0x1f)
+#define IsGL(c) (((c) >= 0x20) && ((c) <= 0x7f))
+#define IsC1(c) (((c) >= 0x80) && ((c) <= 0x9f))
+#define IsGR(c) ((c) >= 0xa0)
+
+#define HasC 1
+#define HasGL 2
+#define HasGR 4
+#define ToGL 8
+
+/*
+ * Prototypes
+ */
+static void ComputeGLGR(XctData);
+static int Handle94GR(XctData, int);
+static int Handle96GR(XctData, int);
+static int HandleExtended(XctData data, int);
+static int HandleGL(XctData, int);
+static int HandleMultiGL(XctData, int);
+static int HandleMultiGR(XctData data, int);
+static void ShiftGRToGL(XctData, int);
+
+/*
+ * Implementation
+ */
+static void
+ComputeGLGR(register XctData data)
+{
+ /* XXX this will need more work if more sets are registered */
+ if ((data->GL_set_size == 94) && (data->GL_char_size == 1) &&
+ (data->GL[0] == '\102') &&
+ (data->GR_set_size == 96) && (data->GR_char_size == 1))
+ data->GLGR_encoding = data->GR_encoding;
+ else if ((data->GL_set_size == 94) && (data->GL_char_size == 1) &&
+ (data->GL[0] == '\112') &&
+ (data->GR_set_size == 94) && (data->GR_char_size == 1))
+ data->GLGR_encoding = data->GR_encoding;
+ else
+ data->GLGR_encoding = (char *)NULL;
+}
+
+static int
+HandleGL(register XctData data, int c)
+{
+ switch (c) {
+ case 0x42:
+ data->GL = "\102";
+ data->GL_encoding = "ISO8859-1";
+ break;
+ case 0x4a:
+ data->GL = "\112";
+ data->GL_encoding = "JISX0201.1976-0";
+ break;
+ default:
+ return 0;
+ }
+ data->GL_set_size = 94;
+ data->GL_char_size = 1;
+ ComputeGLGR(data);
+ return 1;
+}
+
+static int
+HandleMultiGL(register XctData data, int c)
+{
+ switch (c) {
+ case 0x41:
+ data->GL = "\101";
+ data->GL_encoding = "GB2312.1980-0";
+ break;
+ case 0x42:
+ data->GL = "\102";
+ data->GL_encoding = "JISX0208.1983-0";
+ break;
+ case 0x43:
+ data->GL = "\103";
+ data->GL_encoding = "KSC5601.1987-0";
+ break;
+ default:
+ return 0;
+ }
+ data->GL_set_size = 94;
+ data->GL_char_size = 2;
+#ifdef notdef
+ if (c < 0x60)
+ data->GL_char_size = 2;
+ else if (c < 0x70)
+ data->GL_char_size = 3;
+ else
+ data->GL_char_size = 4;
+#endif
+ data->GLGR_encoding = (char *)NULL;
+ return 1;
+}
+
+static int
+Handle94GR(register XctData data, int c)
+{
+ switch (c) {
+ case 0x49:
+ data->GR = "\111";
+ data->GR_encoding = "JISX0201.1976-0";
+ break;
+ default:
+ return 0;
+ }
+ data->priv->flags &= ~ToGL;
+ data->GR_set_size = 94;
+ data->GR_char_size = 1;
+ data->GLGR_encoding = (char *)NULL;
+ return 1;
+}
+
+static int
+Handle96GR(register XctData data, int c)
+{
+ switch (c) {
+ case 0x41:
+ data->GR = "\101";
+ data->GR_encoding = "ISO8859-1";
+ break;
+ case 0x42:
+ data->GR = "\102";
+ data->GR_encoding = "ISO8859-2";
+ break;
+ case 0x43:
+ data->GR = "\103";
+ data->GR_encoding = "ISO8859-3";
+ break;
+ case 0x44:
+ data->GR = "\104";
+ data->GR_encoding = "ISO8859-4";
+ break;
+ case 0x46:
+ data->GR = "\106";
+ data->GR_encoding = "ISO8859-7";
+ break;
+ case 0x47:
+ data->GR = "\107";
+ data->GR_encoding = "ISO8859-6";
+ break;
+ case 0x48:
+ data->GR = "\110";
+ data->GR_encoding = "ISO8859-8";
+ break;
+ case 0x4c:
+ data->GR = "\114";
+ data->GR_encoding = "ISO8859-5";
+ break;
+ case 0x4d:
+ data->GR = "\115";
+ data->GR_encoding = "ISO8859-9";
+ break;
+ default:
+ return 0;
+ }
+ data->priv->flags &= ~ToGL;
+ data->GR_set_size = 96;
+ data->GR_char_size = 1;
+ ComputeGLGR(data);
+ return 1;
+}
+
+static int
+HandleMultiGR(register XctData data, int c)
+{
+ switch (c) {
+ case 0x41:
+ data->GR = "\101";
+ if (data->flags & XctShiftMultiGRToGL)
+ data->GR_encoding = "GB2312.1980-0";
+ else
+ data->GR_encoding = "GB2312.1980-1";
+ break;
+ case 0x42:
+ data->GR = "\102";
+ if (data->flags & XctShiftMultiGRToGL)
+ data->GR_encoding = "JISX0208.1983-0";
+ else
+ data->GR_encoding = "JISX0208.1983-1";
+ break;
+ case 0x43:
+ data->GR = "\103";
+ if (data->flags & XctShiftMultiGRToGL)
+ data->GR_encoding = "KSC5601.1987-0";
+ else
+ data->GR_encoding = "KSC5601.1987-1";
+ break;
+ default:
+ return 0;
+ }
+ if (data->flags & XctShiftMultiGRToGL)
+ data->priv->flags |= ToGL;
+ else
+ data->priv->flags &= ~ToGL;
+ data->GR_set_size = 94;
+ data->GR_char_size = 2;
+#ifdef notdef
+ if (c < 0x60)
+ data->GR_char_size = 2;
+ else if (c < 0x70)
+ data->GR_char_size = 3;
+ else
+ data->GR_char_size = 4;
+#endif
+ data->GLGR_encoding = (char *)NULL;
+ return 1;
+}
+
+static int
+HandleExtended(register XctData data, int c)
+{
+ register XctPriv priv = data->priv;
+ XctString enc = data->item + 6;
+ register XctString ptr = enc;
+ unsigned i, len;
+
+ while (*ptr != 0x02) {
+ if (!*ptr || (++ptr == priv->ptr))
+ return 0;
+ }
+ data->item = ptr + 1;
+ data->item_length = priv->ptr - data->item;
+ len = ptr - enc;
+ for (i = 0;
+ (i < priv->enc_count) &&
+ strncmp(priv->encodings[i], (char *)enc, len);
+ i++)
+ ;
+ if (i == priv->enc_count) {
+ XctString cp;
+
+ for (cp = enc; cp != ptr; cp++) {
+ if ((!IsGL(*cp) && !IsGR(*cp)) || (*cp == 0x2a) || (*cp == 0x3f))
+ return 0;
+ }
+ ptr = (XctString)malloc((unsigned)len + 1);
+ (void) memmove((char *)ptr, (char *)enc, len);
+ ptr[len] = 0x00;
+ priv->enc_count++;
+ if (priv->encodings)
+ priv->encodings = (char **)realloc(
+ (char *)priv->encodings,
+ priv->enc_count * sizeof(char *));
+ else
+ priv->encodings = (char **)malloc(sizeof(char *));
+ priv->encodings[i] = (char *)ptr;
+ }
+ data->encoding = priv->encodings[i];
+ data->char_size = c - 0x30;
+ return 1;
+}
+
+static void
+ShiftGRToGL(register XctData data, int hasCdata)
+{
+ register XctPriv priv = data->priv;
+ register int i;
+
+ if (data->item_length > priv->buf_count) {
+ priv->buf_count = data->item_length;
+ if (priv->itembuf)
+ priv->itembuf = (XctString)realloc((char *)priv->itembuf,
+ priv->buf_count);
+ else
+ priv->itembuf = (XctString)malloc(priv->buf_count);
+ }
+ (void) memmove((char *)priv->itembuf, (char *)data->item,
+ data->item_length);
+ data->item = priv->itembuf;
+ if (hasCdata) {
+ for (i = data->item_length; --i >= 0; ) {
+ if (IsGR(data->item[i]))
+ data->item[i] &= 0x7f;
+ }
+ } else {
+ for (i = data->item_length; --i >= 0; )
+ data->item[i] &= 0x7f;
+ }
+}
+
+/* Create an XctData structure for parsing a Compound Text string. */
+XctData
+XctCreate(_Xconst unsigned char *string, int length, XctFlags flags)
+{
+ register XctData data;
+ register XctPriv priv;
+
+ data = (XctData)malloc(sizeof(struct _XctRec) + sizeof(struct _XctPriv));
+ if (!data)
+ return data;
+ data->priv = priv = (XctPriv)(data + 1);
+ data->total_string = (XctString)string;
+ data->total_length = length;
+ data->flags = flags;
+ priv->dirstack = (XctHDirection *)NULL;
+ priv->dirsize = 0;
+ priv->encodings = (char **)NULL;
+ priv->enc_count = 0;
+ priv->itembuf = (XctString)NULL;
+ priv->buf_count = 0;
+ XctReset(data);
+ return data;
+}
+
+/* Reset the XctData structure to re-parse the string from the beginning. */
+void
+XctReset(register XctData data)
+{
+ register XctPriv priv = data->priv;
+
+ priv->ptr = data->total_string;
+ priv->ptrend = data->total_string + data->total_length;
+ data->item = (XctString)NULL;
+ data->item_length = 0;
+ data->encoding = (char *)NULL;
+ data->char_size = 1;
+ data->horizontal = XctUnspecified;
+ data->horz_depth = 0;
+ priv->flags = 0;
+ data->GL_set_size = data->GR_set_size = 0; /* XXX */
+ (void)HandleGL(data, (unsigned char)0x42);
+ (void)Handle96GR(data, (unsigned char)0x41);
+ data->version = 1;
+ data->can_ignore_exts = 0;
+ /* parse version, if present */
+ if ((data->total_length >= 4) &&
+ (priv->ptr[0] == ESC) && (priv->ptr[1] == 0x23) &&
+ IsI2(priv->ptr[2]) &&
+ ((priv->ptr[3] == 0x30) || (priv->ptr[3] == 0x31))) {
+ data->version = priv->ptr[2] - 0x1f;
+ if (priv->ptr[3] == 0x30)
+ data->can_ignore_exts = 1;
+ priv->ptr += 4;
+ }
+}
+
+/* Parse the next "item" from the Compound Text string. The return value
+ * indicates what kind of item is returned. The item itself, and the current
+ * contextual state, are reported as components of the XctData structure.
+ */
+XctResult
+XctNextItem(register XctData data)
+{
+ register XctPriv priv = data->priv;
+ unsigned char c;
+ int len, bits;
+
+#define NEXT data->item_length++; priv->ptr++
+
+ while (IsMore(priv)) {
+ data->item = priv->ptr;
+ data->item_length = 0;
+ c = *priv->ptr;
+ if (c == ESC) {
+ NEXT;
+ while (IsMore(priv) && IsI2(*priv->ptr)) {
+ NEXT;
+ }
+ if (!IsMore(priv))
+ return XctError;
+ c = *priv->ptr;
+ NEXT;
+ if (!IsESCF(c))
+ return XctError;
+ switch (data->item[1]) {
+ case 0x24:
+ if (data->item_length > 3) {
+ if (data->item[2] == 0x28) {
+ if (HandleMultiGL(data, c))
+ continue;
+ } else if (data->item[2] == 0x29) {
+ if (HandleMultiGR(data, c))
+ continue;
+ }
+ }
+ break;
+ case 0x25:
+ if ((data->item_length == 4) && (data->item[2] == 0x2f) &&
+ (c <= 0x3f)) {
+ if ((AmountLeft(priv) < 2) ||
+ (priv->ptr[0] < 0x80) || (priv->ptr[1] < 0x80))
+ return XctError;
+ len = *priv->ptr - 0x80;
+ NEXT;
+ len = (len << 7) + (*priv->ptr - 0x80);
+ NEXT;
+ if (AmountLeft(priv) < len)
+ return XctError;
+ data->item_length += len;
+ priv->ptr += len;
+ if (c <= 0x34) {
+ if (!HandleExtended(data, c) ||
+ ((data->horz_depth == 0) &&
+ (priv->flags & UsedDirection)))
+ return XctError;
+ priv->flags |= UsedGraphic;
+ return XctExtendedSegment;
+ }
+ }
+ break;
+ case 0x28:
+ if (HandleGL(data, c))
+ continue;
+ break;
+ case 0x29:
+ if (Handle94GR(data, c))
+ continue;
+ break;
+ case 0x2d:
+ if (Handle96GR(data, c))
+ continue;
+ break;
+ }
+ } else if (c == CSI) {
+ NEXT;
+ while (IsMore(priv) && IsI3(*priv->ptr)) {
+ NEXT;
+ }
+ while (IsMore(priv) && IsI2(*priv->ptr)) {
+ NEXT;
+ }
+ if (!IsMore(priv))
+ return XctError;
+ c = *priv->ptr;
+ NEXT;
+ if (!IsCSIF(c))
+ return XctError;
+ if (c == 0x5d) {
+ if ((data->item_length == 3) &&
+ ((data->item[1] == 0x31) || (data->item[1] == 0x32))) {
+ data->horz_depth++;
+ if (priv->dirsize < data->horz_depth) {
+ priv->dirsize += 10;
+ if (priv->dirstack)
+ priv->dirstack = (XctHDirection *)
+ realloc((char *)priv->dirstack,
+ priv->dirsize *
+ sizeof(XctHDirection));
+ else
+ priv->dirstack = (XctHDirection *)
+ malloc(priv->dirsize *
+ sizeof(XctHDirection));
+ }
+ priv->dirstack[data->horz_depth - 1] = data->horizontal;
+ if (data->item[1] == 0x31)
+ data->horizontal = XctLeftToRight;
+ else
+ data->horizontal = XctRightToLeft;
+ if ((priv->flags & UsedGraphic) &&
+ !(priv->flags & UsedDirection))
+ return XctError;
+ priv->flags |= UsedDirection;
+ if (data->flags & XctHideDirection)
+ continue;
+ return XctHorizontal;
+ } else if (data->item_length == 2) {
+ if (!data->horz_depth)
+ return XctError;
+ data->horz_depth--;
+ data->horizontal = priv->dirstack[data->horz_depth];
+ if (data->flags & XctHideDirection)
+ continue;
+ return XctHorizontal;
+ }
+ }
+ } else if (data->flags & XctSingleSetSegments) {
+ NEXT;
+ if IsC0(c) {
+ data->encoding = (char *)NULL;
+ data->char_size = 1;
+ if (IsLegalC0(data, c))
+ return XctC0Segment;
+ } else if (IsGL(c)) {
+ data->encoding = data->GL_encoding;
+ data->char_size = data->GL_char_size;
+ while (IsMore(priv) && IsGL(*priv->ptr)) {
+ NEXT;
+ }
+ if (((data->char_size > 1) &&
+ (data->item_length % data->char_size)) ||
+ ((data->horz_depth == 0) &&
+ (priv->flags & UsedDirection)))
+ return XctError;
+ priv->flags |= UsedGraphic;
+ return XctGLSegment;
+ } else if (IsC1(c)) {
+ data->encoding = (char *)NULL;
+ data->char_size = 1;
+ if (IsLegalC1(data, c))
+ return XctC1Segment;
+ } else {
+ data->encoding = data->GR_encoding;
+ data->char_size = data->GR_char_size;
+ while (IsMore(priv) && IsGR(*priv->ptr)) {
+ NEXT;
+ }
+ if (((data->char_size > 1) &&
+ (data->item_length % data->char_size)) ||
+ ((data->horz_depth == 0) &&
+ (priv->flags & UsedDirection)))
+ return XctError;
+ priv->flags |= UsedGraphic;
+ if (!(priv->flags & ToGL))
+ return XctGRSegment;
+ ShiftGRToGL(data, 0);
+ return XctGLSegment;
+ }
+ } else {
+ bits = 0;
+ while (1) {
+ if (IsC0(c) || IsC1(c)) {
+ if ((c == ESC) || (c == CSI))
+ break;
+ if (IsC0(c) ? !IsLegalC0(data, c) : !IsLegalC1(data, c))
+ break;
+ bits |= HasC;
+ NEXT;
+ } else {
+ len = data->item_length;
+ if (IsGL(c)) {
+ if ((data->flags & XctShiftMultiGRToGL) &&
+ (bits & HasGR))
+ break;
+ NEXT;
+ bits |= HasGL;
+ while (IsMore(priv) && IsGL(*priv->ptr)) {
+ NEXT;
+ }
+ if ((data->GL_char_size > 1) &&
+ ((data->item_length - len) % data->GL_char_size))
+ return XctError;
+ } else {
+ if ((data->flags & XctShiftMultiGRToGL) &&
+ (bits & HasGL))
+ break;
+ NEXT;
+ bits |= HasGR;
+ while (IsMore(priv) && IsGR(*priv->ptr)) {
+ NEXT;
+ }
+ if ((data->GR_char_size > 1) &&
+ ((data->item_length - len) % data->GR_char_size))
+ return XctError;
+ }
+ }
+ if (!IsMore(priv))
+ break;
+ c = *priv->ptr;
+ }
+ if (data->item_length) {
+ if (bits & (HasGL|HasGR)) {
+ priv->flags |= UsedGraphic;
+ if ((data->horz_depth == 0) &&
+ (priv->flags & UsedDirection))
+ return XctError;
+ if ((data->flags & XctShiftMultiGRToGL) && (bits & HasGR))
+ ShiftGRToGL(data, bits & HasC);
+ }
+ if ((bits == (HasGL|HasGR)) ||
+ (data->GLGR_encoding && !(bits & HasC))) {
+ data->encoding = data->GLGR_encoding;
+ if (data->GL_char_size == data->GR_char_size)
+ data->char_size = data->GL_char_size;
+ else
+ data->char_size = 0;
+ } else if (bits == HasGL) {
+ data->encoding = data->GL_encoding;
+ data->char_size = data->GL_char_size;
+ } else if (bits == HasGR) {
+ data->encoding = data->GR_encoding;
+ data->char_size = data->GR_char_size;
+ } else {
+ data->encoding = (char *)NULL;
+ data->char_size = 1;
+ if ((bits & HasGL) &&
+ (data->GL_char_size != data->char_size))
+ data->char_size = 0;
+ if ((bits & HasGR) &&
+ (data->GR_char_size != data->char_size))
+ data->char_size = 0;
+ }
+ return XctSegment;
+ }
+ NEXT;
+ }
+ if (data->version <= XctVersion)
+ return XctError;
+ if (data->flags & XctProvideExtensions)
+ return XctExtension;
+ if (!data->can_ignore_exts)
+ return XctError;
+ }
+ return XctEndOfText;
+}
+
+/* Free all data associated with an XctDataStructure. */
+void
+XctFree(register XctData data)
+{
+ unsigned i;
+ register XctPriv priv = data->priv;
+
+ if (priv->dirstack)
+ free((char *)priv->dirstack);
+ if (data->flags & XctFreeString)
+ free((char *)data->total_string);
+ for (i = 0; i < priv->enc_count; i++)
+ free(priv->encodings[i]);
+ if (priv->encodings)
+ free((char *)priv->encodings);
+ if (priv->itembuf)
+ free((char *)priv->itembuf);
+ free((char *)data);
+}
diff --git a/nx-X11/lib/Xmu/Xct.h b/nx-X11/lib/Xmu/Xct.h
new file mode 100644
index 000000000..b06644ae0
--- /dev/null
+++ b/nx-X11/lib/Xmu/Xct.h
@@ -0,0 +1,168 @@
+/* $Xorg: Xct.h,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+/* $XFree86: xc/lib/Xmu/Xct.h,v 1.6 2001/01/17 19:42:58 dawes Exp $ */
+
+#ifndef _Xct_h
+#define _Xct_h
+
+#include <X11/Xfuncproto.h>
+
+#define XctVersion 1
+
+typedef unsigned char *XctString;
+
+typedef enum {
+ XctUnspecified,
+ XctLeftToRight,
+ XctRightToLeft
+} XctHDirection;
+
+typedef unsigned long XctFlags;
+
+/* These are bits in XctFlags. */
+
+#define XctSingleSetSegments 0x0001
+ /* This means that returned segments should contain characters from only
+ * one set (C0, C1, GL, GR). When this is requested, XctSegment is never
+ * returned, instead XctC0Segment, XctC1Segment, XctGlSegment, and
+ * XctGRSegment are returned. C0 and C1 segments are always returned as
+ * singleton characters.
+ */
+
+#define XctProvideExtensions 0x0002
+ /* This means that if the Compound Text string is from a higher version
+ * than this code is implemented to, then syntactically correct but unknown
+ * control sequences should be returned as XctExtension items. If this
+ * flag is not set, and the Compound Text string version indicates that
+ * extensions cannot be ignored, then each unknown control sequence will be
+ * reported as an XctError.
+ */
+
+#define XctAcceptC0Extensions 0x0004
+ /* This means that if the Compound Text string is from a higher version
+ * than this code is implemented to, then unknown C0 characters should be
+ * treated as if they were legal, and returned as C0 characters (regardless
+ * of how XctProvideExtensions is set). If this flag is not set, then all
+ * unknown C0 characters are treated according to XctProvideExtensions.
+ */
+
+#define XctAcceptC1Extensions 0x0008
+ /* This means that if the Compound Text string is from a higher version
+ * than this code is implemented to, then unknown C0 characters should be
+ * treated as if they were legal, and returned as C0 characters (regardless
+ * of how XctProvideExtensions is set). If this flag is not set, then all
+ * unknown C0 characters are treated according to XctProvideExtensions.
+ */
+
+#define XctHideDirection 0x0010
+ /* This means that horizontal direction changes should be reported as
+ * XctHorizontal items. If this flag is not set, then direction changes are
+ * not returned as items, but the current direction is still maintained and
+ * reported for other items.
+ */
+
+#define XctFreeString 0x0020
+ /* This means that XctFree should free the Compound Text string (that was
+ * passed to XctCreate. If this flag is not set, the string is not freed.
+ */
+
+#define XctShiftMultiGRToGL 0x0040
+ /* Translate GR segments on-the-fly into GL segments for the GR sets:
+ * GB2312.1980-1, JISX0208.1983-1, and KSC5601.1987-1.
+ */
+
+/* This is the return type for XctNextItem. */
+typedef enum {
+ XctSegment, /* used when XctSingleSetSegments is not requested */
+ XctC0Segment, /* used when XctSingleSetSegments is requested */
+ XctGLSegment, /* used when XctSingleSetSegments is requested */
+ XctC1Segment, /* used when XctSingleSetSegments is requested */
+ XctGRSegment, /* used when XctSingleSetSegments is requested */
+ XctExtendedSegment, /* an extended segment */
+ XctExtension, /* used when XctProvideExtensions is requested */
+ XctHorizontal, /* horizontal direction or depth change */
+ XctEndOfText, /* end of text string */
+ XctError /* syntactic or semantic error */
+} XctResult;
+
+typedef struct _XctRec {
+ XctString total_string; /* as given to XctCreate */
+ int total_length; /* as given to XctCreate */
+ XctFlags flags; /* as given to XctCreate */
+ int version; /* indicates the version of the CT spec
+ * the string was produced from */
+ int can_ignore_exts;/* non-zero if ignoring extensions is
+ * acceptable, else zero */
+ XctString item; /* item returned from XctNextItem */
+ unsigned item_length; /* length of item in bytes */
+ int char_size; /* number of bytes per character in
+ * item, with zero meaning variable */
+ char *encoding; /* Encoding name for item */
+ XctHDirection horizontal; /* direction of item */
+ unsigned horz_depth; /* current direction nesting depth */
+ char *GL; /* "{I} F" string for current GL */
+ char *GL_encoding; /* Encoding name for current GL */
+ int GL_set_size; /* 94 or 96 */
+ int GL_char_size; /* number of bytes per GL character */
+ char *GR; /* "{I} F" string for current GR */
+ char *GR_encoding; /* Encoding name for current GR */
+ int GR_set_size; /* 94 or 96 */
+ int GR_char_size; /* number of bytes per GR character */
+ char *GLGR_encoding; /* Encoding name for current GL+GR,
+ * if known */
+ struct _XctPriv *priv; /* private to parser, don't peek */
+} *XctData;
+
+/* these are the external routines */
+_XFUNCPROTOBEGIN
+
+XctData XctCreate
+(
+ _Xconst unsigned char *string,
+ int length,
+ XctFlags flags
+);
+
+XctResult XctNextItem
+(
+ XctData data
+);
+
+void XctFree
+(
+ XctData data
+ );
+
+void XctReset
+(
+ XctData data
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _Xct_h */
diff --git a/nx-X11/lib/Xmu/Xmu-def.cpp b/nx-X11/lib/Xmu/Xmu-def.cpp
new file mode 100644
index 000000000..6a5ea4f9c
--- /dev/null
+++ b/nx-X11/lib/Xmu/Xmu-def.cpp
@@ -0,0 +1,145 @@
+LIBRARY libXmu
+VERSION LIBRARY_VERSION
+EXPORTS
+XmuAllStandardColormaps
+XmuGetAtomName
+XmuInternAtom
+XmuInternStrings
+XmuMakeAtom
+XmuNameOfAtom
+XmuClientWindow
+XmuAddCloseDisplayHook
+XmuLookupCloseDisplayHook
+XmuRemoveCloseDisplayHook
+XmuGetColormapAllocation
+XmuCreateColormap
+XmuCreatePixmapFromBitmap
+XmuCursorNameToIndex
+_XmuCCLookupDisplay
+XmuConvertStandardSelection
+XmuPrintDefaultErrorMessage
+XmuSimpleErrorHandler
+XmuDeleteStandardColormap
+XmuDQAddDisplay
+XmuDQCreate
+XmuDQDestroy
+XmuDQLookupDisplay
+XmuDQRemoveDisplay
+XmuDistinguishableColors
+XmuDistinguishablePixels
+XmuDrawLogo
+XmuDrawRoundedRectangle
+XmuFillRoundedRectangle
+_XEditResCheckMessages
+_XEditResGet16
+_XEditResGet32
+_XEditResGet8
+_XEditResGetSigned16
+_XEditResGetString8
+_XEditResGetWidgetInfo
+_XEditResPut16
+_XEditResPut32
+_XEditResPut8
+_XEditResPutString8
+_XEditResPutWidgetInfo
+_XEditResResetStream
+XmuRegisterExternalAgent
+XmuCvtFunctionToCallback
+XmuGetHostname
+XmuCreateStippledPixmap
+XmuReleaseStippledPixmap
+XmuAddInitializer
+XmuCallInitializers
+XmuLocateBitmapFile
+XmuLocatePixmapFile
+_XmuStringToBitmapFreeCache
+_XmuStringToBitmapInitCache
+XmuLookupAPL
+XmuLookupArabic
+XmuLookupCyrillic
+XmuLookupGreek
+XmuLookupHebrew
+XmuLookupJISX0201
+XmuLookupKana
+XmuLookupLatin1
+XmuLookupLatin2
+XmuLookupLatin3
+XmuLookupLatin4
+XmuLookupString
+XmuLookupStandardColormap
+XmuCompareISOLatin1
+XmuCopyISOLatin1Lowered
+XmuCopyISOLatin1Uppered
+XmuReadBitmapData
+XmuReadBitmapDataFromFile
+XmuScreenOfWindow
+XmuReshapeWidget
+XmuStandardColormap
+XmuCvtStringToBackingStore
+XmuCvtStringToBitmap
+XmuCvtStringToColorCursor
+XmuCvtStringToCursor
+XmuCvtStringToGravity
+XmuCvtStringToJustify
+XmuCvtStringToLong
+XmuCvtStringToOrientation
+XmuCvtStringToShapeStyle
+XmuCvtStringToWidget
+XmuNewCvtStringToWidget
+XmuUpdateMapHints
+XmuVisualStandardColormaps
+XmuWnCountOwnedResources
+XmuWnFetchResources
+XmuWnInitializeNodes
+XmuWnNameToNode
+XctCreate
+XctFree
+XctNextItem
+XctReset
+XmuCvtGravityToString
+XmuCvtBackingStoreToString
+_XA_ATOM_PAIR
+_XA_CHARACTER_POSITION
+_XA_CLASS
+_XA_CLIENT_WINDOW
+_XA_CLIPBOARD
+_XA_COMPOUND_TEXT
+_XA_DECNET_ADDRESS
+_XA_DELETE
+_XA_FILENAME
+_XA_HOSTNAME
+_XA_IP_ADDRESS
+_XA_LENGTH
+_XA_LIST_LENGTH
+_XA_NAME
+_XA_NET_ADDRESS
+_XA_NULL
+_XA_OWNER_OS
+_XA_SPAN
+_XA_TARGETS
+_XA_TEXT
+_XA_TIMESTAMP
+_XA_USER
+_XA_UTF8_STRING
+XmuNewArea
+XmuDestroyScanlineList
+XmuCvtWidgetToString
+XmuOptimizeScanline
+XmuAreaOrXor
+XmuScanlineXor
+XmuDestroySegmentList
+XmuCvtJustifyToString
+XmuSnprintf
+XmuNewScanline
+XmuNCopyISOLatin1Lowered
+XmuNCopyISOLatin1Uppered
+XmuCvtShapeStyleToString
+XmuCvtOrientationToString
+XmuScanlineOrSegment
+#ifdef __UNIXOS2__
+XmuScanlineNot
+XmuScanlineAnd
+XmuScanlineOr
+#endif
+
+/* $XFree86: xc/lib/Xmu/Xmu-def.cpp,v 1.1 2000/08/09 23:40:13 dawes Exp $ */
diff --git a/nx-X11/lib/Xmu/Xmu.h b/nx-X11/lib/Xmu/Xmu.h
new file mode 100644
index 000000000..c503a41b8
--- /dev/null
+++ b/nx-X11/lib/Xmu/Xmu.h
@@ -0,0 +1,128 @@
+/* $Xorg: Xmu.h,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/Xmu.h,v 1.9 2001/12/14 19:55:59 dawes Exp $ */
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_H_
+#define _XMU_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Atoms.h> /* _XA_... */
+#include <X11/Xmu/CharSet.h> /* CopyISOLatin1Lowered */
+#include <X11/Xmu/Converters.h> /* CvtStringTo... */
+#include <X11/Xmu/Drawing.h> /* DrawRoundedRect, DrawLogo */
+#include <X11/Xmu/Error.h> /* PrintDefaultError */
+#include <X11/Xmu/StdSel.h> /* ConvertStandardSelection */
+
+/*
+ * clip lists
+ */
+typedef struct _XmuSegment {
+ int x1, x2;
+ struct _XmuSegment *next;
+} XmuSegment;
+
+typedef struct _XmuScanline {
+ int y;
+ XmuSegment *segment;
+ struct _XmuScanline *next;
+} XmuScanline;
+
+typedef struct _XmuArea {
+ XmuScanline *scanline;
+} XmuArea;
+
+#define XmuCreateArea() XmuNewArea(0, 0, 0, 0)
+#define XmuAreaOr(dst, src) XmuAreaOrXor((dst), (src), True)
+#define XmuAreaXor(dst, src) XmuAreaOrXor((dst), (src), False)
+
+#define XmuDestroyArea(a) \
+ do { \
+ XmuDestroyScanlineList((a)->scanline); \
+ XtFree((char *)(a)); \
+ } while (0)
+
+#define FreeArea(a) \
+ do { \
+ XmuDestroyScanlineList((a)->scanline); \
+ a->scanline = (Scanline *)0; \
+ } while (0)
+
+#define XmuValidSegment(s) ((s)->x1 < (s)->x2)
+#define XmuSegmentEqu(s1, s2) ((s1)->x1 == (s2)->x1 && (s1)->x2 == (s2)->x2)
+#define XmuDestroySegment(s) XtFree((char *)(s))
+
+#define XmuDestroyScanline(s) \
+ do { \
+ XmuDestroySegmentList((s)->segment); \
+ XtFree((char*)(s)); \
+ } while (0)
+
+XmuArea *XmuNewArea(int, int, int, int);
+XmuArea *XmuAreaDup(XmuArea*);
+XmuArea *XmuAreaCopy(XmuArea*, XmuArea*);
+XmuArea *XmuAreaNot(XmuArea*, int, int, int, int);
+XmuArea *XmuAreaOrXor(XmuArea*, XmuArea*, Bool);
+XmuArea *XmuAreaAnd(XmuArea*, XmuArea*);
+Bool XmuValidArea(XmuArea*);
+Bool XmuValidScanline(XmuScanline*);
+Bool XmuScanlineEqu(XmuScanline*, XmuScanline*);
+XmuSegment *XmuNewSegment(int, int);
+void XmuDestroySegmentList(XmuSegment*);
+XmuScanline *XmuScanlineCopy(XmuScanline*, XmuScanline*);
+Bool XmuAppendSegment(XmuSegment*, XmuSegment*);
+XmuScanline *XmuOptimizeScanline(XmuScanline*);
+XmuScanline *XmuScanlineNot(XmuScanline *scanline, int, int);
+XmuScanline *XmuScanlineOr(XmuScanline*, XmuScanline*);
+XmuScanline *XmuScanlineAnd(XmuScanline*, XmuScanline*);
+XmuScanline *XmuScanlineXor(XmuScanline*, XmuScanline*);
+XmuScanline *XmuNewScanline(int, int, int);
+void XmuDestroyScanlineList(XmuScanline*);
+XmuArea *XmuOptimizeArea(XmuArea *area);
+
+#ifndef notdef
+XmuScanline *XmuScanlineOrSegment(XmuScanline*, XmuSegment*);
+XmuScanline *XmuScanlineAndSegment(XmuScanline*, XmuSegment*);
+XmuScanline *XmuScanlineXorSegment(XmuScanline*, XmuSegment*);
+#endif /* notdef */
+
+#ifndef _SYSUTIL_H_
+int XmuSnprintf(char *str, int size, _Xconst char *fmt, ...)
+#if defined(__GNUC__) && \
+ ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ > 4)))
+__attribute((format(printf,3,4)))
+#endif
+;
+#endif
+
+#endif /* _XMU_H_ */
+
diff --git a/nx-X11/lib/Xmu/sharedlib.c b/nx-X11/lib/Xmu/sharedlib.c
new file mode 100644
index 000000000..0ef5e3ce9
--- /dev/null
+++ b/nx-X11/lib/Xmu/sharedlib.c
@@ -0,0 +1,76 @@
+/* $Xorg: sharedlib.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xmu/sharedlib.c,v 3.4 2001/07/25 15:04:51 dawes Exp $ */
+
+#if defined(SUNSHLIB) && !defined(SHAREDCODE)
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Atoms.h"
+
+struct _AtomRec {
+ char *name;
+ struct _DisplayRec* head;
+};
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define DeclareAtom(atom) \
+extern struct _AtomRec __##atom; \
+AtomPtr _##atom = &__##atom;
+#else
+#define DeclareAtom(atom) \
+extern struct _AtomRec __/**/atom; \
+AtomPtr _/**/atom = &__/**/atom;
+#endif
+
+DeclareAtom(XA_ATOM_PAIR)
+DeclareAtom(XA_CHARACTER_POSITION)
+DeclareAtom(XA_CLASS)
+DeclareAtom(XA_CLIENT_WINDOW)
+DeclareAtom(XA_CLIPBOARD)
+DeclareAtom(XA_COMPOUND_TEXT)
+DeclareAtom(XA_DECNET_ADDRESS)
+DeclareAtom(XA_DELETE)
+DeclareAtom(XA_FILENAME)
+DeclareAtom(XA_HOSTNAME)
+DeclareAtom(XA_IP_ADDRESS)
+DeclareAtom(XA_LENGTH)
+DeclareAtom(XA_LIST_LENGTH)
+DeclareAtom(XA_NAME)
+DeclareAtom(XA_NET_ADDRESS)
+DeclareAtom(XA_NULL)
+DeclareAtom(XA_OWNER_OS)
+DeclareAtom(XA_SPAN)
+DeclareAtom(XA_TARGETS)
+DeclareAtom(XA_TEXT)
+DeclareAtom(XA_TIMESTAMP)
+DeclareAtom(XA_USER)
+DeclareAtom(XA_UTF8_STRING)
+
+#endif /* SUNSHLIB */
diff --git a/nx-X11/lib/Xmuu/Imakefile b/nx-X11/lib/Xmuu/Imakefile
new file mode 100644
index 000000000..7cd087921
--- /dev/null
+++ b/nx-X11/lib/Xmuu/Imakefile
@@ -0,0 +1,67 @@
+XCOMM $XFree86: xc/lib/Xmuu/Imakefile,v 1.2tsi Exp $
+XCOMM Mini Xmu library: pull out just those things that are used by apps
+XCOMM that do not use Xt and Xaw in the core applications
+XCOMM
+XCOMM Feel free to include additional code into this library, please
+XCOMM be careful not to use anything which requires libraries other
+XCOMM other than Xlib and the system C library
+
+#define DoNormalLib NormalLibXmuu
+#define DoSharedLib SharedLibXmuu
+#define DoExtraLib SharedLibXmuu
+#define DoDebugLib DebugLibXmuu
+#define DoProfileLib ProfileLibXmuu
+#define LibName Xmuu
+#define SoRev SOXMUUREV
+#define LibHeaders NO
+
+#ifdef SharedXmuuReqs
+REQUIREDLIBS = SharedXmuuReqs
+#endif
+ LINTLIBS = $(LINTXLIB)
+
+#if HasSnprintf
+ MISC_DEFINES = -DHAS_SNPRINTF
+#else
+ MISC_INCLUDES = -I$(LIBSRC)/misc
+#endif
+
+ DEFINES = $(MISC_DEFINES)
+ INCLUDES = $(MISC_INCLUDES)
+
+#ifdef OsNameDefines
+OS_NAME_DEFINES = OsNameDefines
+#endif
+ CSSDEFS = $(OS_NAME_DEFINES) $(CONNECTION_FLAGS)
+
+
+SRCS = ClientWin.c\
+ CursorName.c\
+ DefErrMsg.c\
+ GetHost.c\
+ Lower.c
+
+OBJS = ClientWin.o\
+ CursorName.o\
+ DefErrMsg.o\
+ GetHost.o\
+ Lower.o
+
+### Commented out following line...
+### INCLUDES = -I$(XMUSRC)
+### ... it breaks Lower.c (which needs -I../../lib/misc to find snprintf.c)
+###
+
+#include <Library.tmpl>
+
+#if DoSharedLib
+SpecialCObjectRule(sharedlib,NullParameter,$(SHLIBDEF))
+#endif
+
+LinkSourceFile(ClientWin.c,$(XMUSRC))
+LinkSourceFile(CursorName.c,$(XMUSRC))
+LinkSourceFile(DefErrMsg.c,$(XMUSRC))
+LinkSourceFile(GetHost.c,$(XMUSRC))
+LinkSourceFile(Lower.c,$(XMUSRC))
+
+DependTarget()
diff --git a/nx-X11/lib/Xmuu/Xmuu-def.cpp b/nx-X11/lib/Xmuu/Xmuu-def.cpp
new file mode 100644
index 000000000..243d5fcb2
--- /dev/null
+++ b/nx-X11/lib/Xmuu/Xmuu-def.cpp
@@ -0,0 +1,22 @@
+LIBRARY libXmuu
+VERSION LIBRARY_VERSION
+EXPORTS
+
+ XmuClientWindow
+ XmuCursorNameToIndex
+ XmuPrintDefaultErrorMessage
+ XmuSimpleErrorHandler
+ XmuGetHostname
+ XmuCompareISOLatin1
+ XmuCopyISOLatin1Lowered
+ XmuCopyISOLatin1Uppered
+ XmuNCopyISOLatin1Lowered
+ XmuNCopyISOLatin1Uppered
+ XmuSnprintf
+#ifndef __UNIXOS2__
+ _cygwin_dll_entry@12
+ _cygwin_noncygwin_dll_entry@12
+ dll_main@12
+#endif
+
+/* $XFree86: xc/lib/Xmuu/Xmuu-def.cpp,v 1.1 2001/04/18 17:14:00 dawes Exp $ */
diff --git a/nx-X11/lib/Xp/Imakefile b/nx-X11/lib/Xp/Imakefile
new file mode 100644
index 000000000..2b64417a2
--- /dev/null
+++ b/nx-X11/lib/Xp/Imakefile
@@ -0,0 +1,107 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:05 cpqbld Exp $
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** Description: Imakefile for the DtPrint extension library.
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+XCOMM $XFree86: xc/lib/Xp/Imakefile,v 1.3 2001/01/17 19:43:01 dawes Exp $
+
+
+#define DoNormalLib NormalLibXp
+#define DoSharedLib SharedLibXp
+#define DoExtraLib SharedLibXp
+#define DoDebugLib DebugLibXp
+#define DoProfileLib ProfileLibXp
+#define LibName Xp
+#define SoRev SOXPREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXpReqs
+REQUIREDLIBS = SharedXpReqs
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+DEFINES = $(ALLOC_DEFINES)
+
+/*
+ * NOTE: libDtPrint.a has a dependency on extutil.o found in
+ * libXext.a
+ */
+SRCS = \
+ XpAttr.c \
+ XpContext.c \
+ XpDoc.c \
+ XpExtUtil.c \
+ XpExtVer.c \
+ XpGetData.c \
+ XpInput.c \
+ XpJob.c \
+ XpLocale.c \
+ XpPage.c \
+ XpNotifyPdm.c \
+ XpPrinter.c \
+ XpPutData.c \
+ XpScreens.c \
+ XpPageDim.c \
+ XpImageRes.c
+
+OBJS = \
+ XpAttr.o \
+ XpContext.o \
+ XpDoc.o \
+ XpExtUtil.o \
+ XpExtVer.o \
+ XpGetData.o \
+ XpInput.o \
+ XpJob.o \
+ XpLocale.o \
+ XpPage.o \
+ XpNotifyPdm.o \
+ XpPrinter.o \
+ XpPutData.o \
+ XpScreens.o \
+ XpPageDim.o \
+ XpImageRes.o
+
+LINTLIBS = $(LINTXLIB) $(LINTXEXT)
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/Xp/Xp-def.cpp b/nx-X11/lib/Xp/Xp-def.cpp
new file mode 100644
index 000000000..253c649ca
--- /dev/null
+++ b/nx-X11/lib/Xp/Xp-def.cpp
@@ -0,0 +1,42 @@
+LIBRARY Xp
+VERSION LIBRARY_VERSION
+EXPORTS
+ XpCancelDoc
+ XpCancelJob
+ XpCancelPage
+ XpCreateContext
+ XpDestroyContext
+ XpEndDoc
+ XpEndJob
+ XpEndPage
+ XpFreePrinterList
+ XpGetAttributes
+ XpGetAuthParams
+ XpGetContext
+ XpGetDocumentData
+ XpGetLocaleHinter
+ XpGetLocaleNetString
+ XpGetOneAttribute
+ XpGetPageDimensions
+ XpGetPdmStartParams
+ XpGetPrinterList
+ XpGetScreenOfContext
+ XpInputSelected
+ XpNotifyPdm
+ XpPutDocumentData
+ XpQueryExtension
+ XpQueryScreens
+ XpQueryVersion
+ XpRehashPrinterList
+ XpSelectInput
+ XpSendAuth
+ XpSendOneTicket
+ XpSetAttributes
+ XpSetContext
+ XpSetImageResolution
+ XpSetLocaleHinter
+ XpStartDoc
+ XpStartJob
+ XpStartPage
+/* $Xorg: Xp-def.cpp,v 1.3 2000/08/17 19:46:05 cpqbld Exp $ */
+/* $XFree86: xc/lib/Xp/Xp-def.cpp,v 1.2 2000/08/09 23:40:13 dawes Exp $ */
diff --git a/nx-X11/lib/Xp/XpAttr.c b/nx-X11/lib/Xp/XpAttr.c
new file mode 100644
index 000000000..9e1fbfd64
--- /dev/null
+++ b/nx-X11/lib/Xp/XpAttr.c
@@ -0,0 +1,208 @@
+/* $Xorg: XpAttr.c,v 1.4 2000/08/17 19:46:05 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpAttr.c,v 1.6 2001/01/17 19:43:01 dawes Exp $ */
+
+#define NEED_REPLIES
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+
+#define _XpPadOut(len) (((len) + 3) & ~3)
+
+
+#include <stdio.h>
+#include <sys/stat.h>
+
+char *
+XpGetAttributes (
+ Display *dpy,
+ XPContext print_context,
+ XPAttributes type
+)
+{
+ char *buf;
+
+ xPrintGetAttributesReq *req;
+ xPrintGetAttributesReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return( (char *) NULL ); /* No such extension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintGetAttributes,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintGetAttributes;
+ req->printContext = print_context;
+ req->type = type;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return( (char *) NULL ); /* No such extension */
+ }
+
+ /*
+ * Read pool and return to caller.
+ */
+ buf = Xmalloc( (unsigned) rep.stringLen + 1 );
+
+ if (!buf) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return( (char *) NULL ); /* malloc error */
+ }
+
+ _XReadPad (dpy, (char *) buf, (long) rep.stringLen );
+
+ buf[rep.stringLen] = 0;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return( buf );
+}
+
+
+char *
+XpGetOneAttribute (
+ Display *dpy,
+ XPContext print_context,
+ XPAttributes type,
+ char *attribute_name
+)
+{
+ char *buf;
+
+ xPrintGetOneAttributeReq *req;
+ xPrintGetOneAttributeReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return( (char *) NULL ); /* No such extension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintGetOneAttribute,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintGetOneAttribute;
+ req->type = type;
+ req->printContext = print_context;
+ req->nameLen = strlen( attribute_name );
+
+ /*
+ * Attach variable data and adjust request length.
+ */
+ req->length += _XpPadOut(req->nameLen) >> 2 ;
+ Data( dpy, (char *) attribute_name, req->nameLen ); /* n bytes + pad */
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return( (char *) NULL ); /* No such extension */
+ }
+
+ /*
+ * Read variable answer.
+ */
+ buf = Xmalloc( (unsigned) rep.valueLen + 1 );
+
+ if (!buf) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return( (char *) NULL ); /* malloc error */
+ }
+
+ buf[rep.valueLen] = 0;
+
+ _XReadPad (dpy, (char *) buf, (long) rep.valueLen );
+ buf[rep.valueLen] = 0;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return( buf );
+}
+
+
+void
+XpSetAttributes (
+ Display *dpy,
+ XPContext print_context,
+ XPAttributes type,
+ char *pool,
+ XPAttrReplacement replacement_rule
+)
+{
+ xPrintSetAttributesReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return; /* No such extension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintSetAttributes,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintSetAttributes;
+
+ req->printContext = print_context;
+ req->type = type;
+ req->rule = replacement_rule;
+
+ /*
+ * Attach variable data and adjust request length.
+ */
+ req->stringLen = (CARD32) strlen( (char *) pool );
+ req->length += _XpPadOut(req->stringLen) >> 2 ;
+
+ Data( dpy, (char *) pool, req->stringLen ); /* n bytes + pad */
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return;
+}
+
diff --git a/nx-X11/lib/Xp/XpContext.c b/nx-X11/lib/Xp/XpContext.c
new file mode 100644
index 000000000..fc3da9c2b
--- /dev/null
+++ b/nx-X11/lib/Xp/XpContext.c
@@ -0,0 +1,250 @@
+/* $Xorg: XpContext.c,v 1.4 2000/08/17 19:46:05 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpContext.c,v 1.6 2001/10/28 03:32:39 tsi Exp $ */
+
+#define NEED_REPLIES
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+
+#define _XpPadOut(len) (((len) + 3) & ~3)
+
+XPContext
+XpCreateContext (
+ Display *dpy,
+ char *printer_name
+)
+{
+ xPrintCreateContextReq *req;
+ char *locale;
+ int locale_len;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return ( (XPContext) None ); /* No such extension */
+
+ /*
+ * Fetch locale information. Note: XpGetLocaleNetString has
+ * a thread-safe mutex on _Xglobal_lock.
+ */
+ locale = XpGetLocaleNetString();
+
+ LockDisplay (dpy);
+
+ GetReq(PrintCreateContext,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintCreateContext;
+
+ req->contextID = XAllocID(dpy);
+ req->printerNameLen = strlen(printer_name);
+
+ if ( locale == (char *) NULL )
+ req->localeLen = 0;
+ else if ( *locale == (char) NULL )
+ req->localeLen = 0;
+ else {
+ locale_len = strlen( locale );
+ req->length += _XpPadOut(locale_len) >> 2;
+ req->localeLen = (unsigned long) locale_len;
+ }
+
+ /*
+ * Attach variable data
+ */
+ req->length += _XpPadOut(req->printerNameLen) >> 2;
+ Data( dpy, (char *) printer_name, (long) req->printerNameLen );
+
+ if (req->localeLen)
+ Data( dpy, (char *) locale, (long) req->localeLen );
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ XFree(locale);
+
+ return ( (XPContext) req->contextID );
+}
+
+
+void
+XpSetContext (
+ Display *dpy,
+ XPContext print_context
+)
+{
+ xPrintSetContextReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return; /* No such extension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintSetContext,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintSetContext;
+
+ req->printContext = print_context;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return;
+}
+
+
+XPContext
+XpGetContext (
+ Display *dpy
+)
+{
+ xPrintGetContextReq *req;
+ xPrintGetContextReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return ( (XPContext) None ); /* No such extension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintGetContext,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintGetContext;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ( (XPContext) None ); /* No such extension */
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return ( (XPContext) rep.printContext );
+}
+
+
+void
+XpDestroyContext (
+ Display *dpy,
+ XPContext print_context
+)
+{
+ xPrintDestroyContextReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return; /* No such extension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintDestroyContext,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintDestroyContext;
+ req->printContext = print_context;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return;
+}
+
+
+
+Screen *
+XpGetScreenOfContext (
+ Display *dpy,
+ XPContext print_context
+)
+{
+ xPrintGetContextScreenReq *req;
+ xPrintGetContextScreenReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ int i;
+ Screen *checkScr = NULL;
+ int ok;
+
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return ( (Screen *) NULL ); /* No such extension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintGetContextScreen,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintGetContextScreen;
+
+ req->printContext = print_context;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ( (Screen *) NULL ); /* No such extension */
+ }
+
+ /*
+ * Pull rootWindow ID and convert to the corresponding
+ * Screen rec.
+ */
+ ok = False;
+
+ for ( i = 0; i < XScreenCount(dpy); i++ ) {
+ checkScr = XScreenOfDisplay(dpy, i);
+ if ( XRootWindowOfScreen( checkScr ) == (Window) rep.rootWindow ) {
+ ok = True;
+ break;
+ }
+ }
+
+ if (!ok)
+ checkScr = (Screen *) NULL;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return ( (Screen *) checkScr );
+}
+
diff --git a/nx-X11/lib/Xp/XpDoc.c b/nx-X11/lib/Xp/XpDoc.c
new file mode 100644
index 000000000..3fb4ad5d5
--- /dev/null
+++ b/nx-X11/lib/Xp/XpDoc.c
@@ -0,0 +1,159 @@
+/* $Xorg: XpDoc.c,v 1.3 2000/08/17 19:46:06 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpDoc.c,v 1.3 2001/01/17 19:43:01 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+
+typedef struct {
+ int event_base_return;
+ XPContext context;
+} _XpDiscardDocRec;
+
+static Bool _XpDiscardDoc(Display *dpy, XEvent *event, XPointer arg)
+{
+ _XpDiscardDocRec *disrec = (_XpDiscardDocRec *) arg;
+
+ if (event->type != disrec->event_base_return + XPPrintNotify)
+ return False;
+
+ if (disrec->context != ((XPPrintEvent *) event)->context)
+ return False;
+
+ if ((((XPPrintEvent *) event)->detail == XPEndDocNotify) ||
+ (((XPPrintEvent *) event)->detail == XPEndPageNotify)) {
+ return False;
+ }
+
+ return True;
+}
+
+
+void
+XpStartDoc (
+ Display *dpy,
+ XPDocumentType type
+)
+{
+ xPrintStartDocReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
+ return; /* NoSuchExtension NULL */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintStartDoc,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintStartDoc;
+ req->type = (unsigned char ) type;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+void
+XpEndDoc (
+ Display *dpy
+)
+{
+ xPrintEndDocReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+
+ if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
+ return; /* NoSuchExtension NULL */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintEndDoc,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintEndDoc;
+ req->cancel = False;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+
+void
+XpCancelDoc (
+ Display *dpy,
+ Bool discard
+)
+{
+ xPrintEndDocReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ _XpDiscardDocRec disrec;
+ XEvent event;
+
+
+ if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
+ return; /* NoSuchExtension NULL */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintEndDoc,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintEndDoc;
+ req->cancel = True;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+
+ if (discard) {
+ /*
+ * get context and effectively do a sync of events.
+ */
+ disrec.event_base_return = info->codes->first_event;
+ disrec.context = XpGetContext(dpy);
+
+ /*
+ * discard doc, and also page XPPrintNotify events.
+ */
+ while (XCheckIfEvent(dpy, &event, _XpDiscardDoc, (XPointer) &disrec))
+ {
+ /*EMPTY*/
+ }
+ }
+}
+
diff --git a/nx-X11/lib/Xp/XpExtUtil.c b/nx-X11/lib/Xp/XpExtUtil.c
new file mode 100644
index 000000000..dac80286f
--- /dev/null
+++ b/nx-X11/lib/Xp/XpExtUtil.c
@@ -0,0 +1,355 @@
+/* $Xorg: XpExtUtil.c,v 1.3 2000/08/17 19:46:06 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpExtUtil.c,v 1.7 2002/10/16 00:37:31 dawes Exp $ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+#include <X11/Xos.h>
+
+#define ENQUEUE_EVENT True
+#define DONT_ENQUEUE False
+
+static XExtensionInfo xp_info_data;
+static XExtensionInfo *xp_info = &xp_info_data;
+static /* const */ char *xp_extension_name = XP_PRINTNAME;
+
+static int XpClose();
+static char *XpError();
+static Bool XpWireToEvent();
+static Status XpEventToWire();
+
+#define XpCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xp_extension_name, val)
+
+static /* const */ XExtensionHooks xpprint_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ XpClose, /* close_display */
+ XpWireToEvent, /* wire_to_event */
+ XpEventToWire, /* event_to_wire */
+ NULL, /* error */
+ XpError, /* error_string */
+};
+
+typedef struct {
+ int present;
+ short major_version;
+ short minor_version;
+} XPrintLocalExtensionVersion;
+
+typedef struct _xpPrintData {
+ XEvent data;
+ XPrintLocalExtensionVersion *vers;
+} xpPrintData;
+
+static char *XpErrorList[ /* XP_ERRORS */ ] = {
+ "XPBadContext",
+ "XPBadSequence",
+ "XPBadResourceID"
+};
+
+XEXT_GENERATE_FIND_DISPLAY (xp_find_display, xp_info,
+ xp_extension_name, &xpprint_extension_hooks, XP_EVENTS, NULL)
+
+static XEXT_GENERATE_ERROR_STRING (XpError, xp_extension_name,
+ XP_ERRORS, XpErrorList)
+
+/*******************************************************************
+ *
+ * XP Print extension versions.
+ */
+
+static XPrintLocalExtensionVersion xpprintversions[] = {{XP_ABSENT,0,0},
+ {XP_PRESENT, XP_PROTO_MAJOR, XP_PROTO_MINOR}};
+
+
+/***********************************************************************
+ *
+ * Check to see if the Xp Print extension is installed in the server.
+ * Also check to see if the version is >= the requested version.
+ *
+ * xpprintversions[] shows all revisions of this library, past to present.
+ * xpprintversions[version_index] shows which version *this* library is.
+ */
+
+int XpCheckExtInitUnlocked(dpy, version_index)
+ register Display *dpy;
+ register int version_index;
+{
+ XExtDisplayInfo *info = xp_find_display (dpy);
+
+ XpCheckExtension (dpy, info, -1);
+
+
+ /*
+ * Check for broken condition - a partial info world.
+ */
+ if (info->data) {
+ if (!(((xpPrintData *) info->data)->vers)) {
+ return (-1);
+ }
+ }
+
+ if (info->data == NULL) {
+ /*
+ * Hang a Xp private data struct. Use it for version
+ * information.
+ */
+ info->data = (XPointer) Xmalloc (sizeof (xpPrintData));
+ if (!info->data) {
+ return (-1);
+ }
+
+ ((xpPrintData *) info->data)->vers =
+ (XPrintLocalExtensionVersion *) Xmalloc(sizeof(XPrintLocalExtensionVersion));
+ if (!(((xpPrintData *) info->data)->vers)) {
+ return (-1);
+ }
+
+ /*
+ * Set present to false so that XpQueryVersion will fill
+ * it in vs using its own cache which now contains garbage.
+ */
+ ((xpPrintData *) info->data)->vers->present = False;
+
+ ((xpPrintData *) info->data)->vers->present = XpQueryVersion(dpy,
+ &(((xpPrintData *) info->data)->vers->major_version),
+ &(((xpPrintData *) info->data)->vers->minor_version) );
+ }
+ if (xpprintversions[version_index].major_version > XP_DONT_CHECK) {
+ if ( ( ((xpPrintData *) info->data)->vers->major_version
+ < xpprintversions[version_index].major_version) ||
+ ( (((xpPrintData *) info->data)->vers->major_version
+ == xpprintversions[version_index].major_version) &&
+ (((xpPrintData *) info->data)->vers->minor_version
+ < xpprintversions[version_index].minor_version))) {
+ return (-1);
+ }
+ }
+
+ return (0);
+}
+
+int XpCheckExtInit(dpy, version_index)
+ register Display *dpy;
+ register int version_index;
+{
+ int retval;
+
+ _XLockMutex(_Xglobal_lock);
+
+ retval = XpCheckExtInitUnlocked(dpy, version_index);
+
+ _XUnlockMutex(_Xglobal_lock);
+
+ return retval;
+}
+
+/***********************************************************************
+ *
+ * Close display routine.
+ *
+ */
+
+static int
+XpClose (dpy, codes)
+ Display *dpy;
+ XExtCodes *codes;
+ {
+ XExtDisplayInfo *info = xp_find_display (dpy);
+
+ _XLockMutex(_Xglobal_lock);
+ if ( ((xpPrintData *) info->data)) {
+ if (((xpPrintData *) info->data)->vers) {
+ XFree((char *)((xpPrintData *) info->data)->vers);
+ }
+ XFree((char *)info->data);
+ info->data = (char *) NULL; /* NULL since tests are run on */
+ }
+ _XUnlockMutex(_Xglobal_lock);
+
+ return XextRemoveDisplay (xp_info, dpy);
+ }
+
+
+/******************************************************************************
+ *
+ * Handle extension events.
+ */
+
+/********************************************************************
+ *
+ * Reformat a wire event into an XEvent structure of the right type.
+ */
+static Bool
+XpWireToEvent (dpy, re, event)
+ Display *dpy;
+ XEvent *re;
+ xEvent *event;
+{
+ XExtDisplayInfo *info = xp_find_display (dpy);
+
+
+ /*
+ * type, serial, send_event, display are common to all events.
+ */
+ re->type = event->u.u.type & 0x7f;
+ ((XAnyEvent *)re)->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ ((XAnyEvent *)re)->send_event = ((event->u.u.type & 0x80) != 0);
+ ((XAnyEvent *)re)->display = dpy;
+
+
+ switch (re->type - info->codes->first_event)
+ {
+
+ case XPPrintNotify:
+ {
+ register XPPrintEvent *ev = (XPPrintEvent *) re;
+ xPrintPrintEvent *ev2 = (xPrintPrintEvent *) event;
+
+ /* type, serial, send_event, *display */
+
+ ev->context = (XPContext) ev2->printContext;
+ ev->cancel = (Bool) ev2->cancel;
+ ev->detail = (int) ev2->detail;
+
+ return (ENQUEUE_EVENT);
+ break;
+ }
+
+ case XPAttributeNotify:
+ {
+ register XPAttributeEvent *ev = (XPAttributeEvent *) re;
+ xPrintAttributeEvent *ev2 = (xPrintAttributeEvent *) event;
+
+ /* type, serial, send_event, *display */
+
+ ev->context = (XPContext) ev2->printContext;
+ ev->detail = (int) ev2->detail;
+
+ return (ENQUEUE_EVENT);
+ break;
+ }
+
+ default:
+ printf ("XpWireToEvent: UNKNOWN WIRE EVENT! type=%d\n",re->type);
+ break;
+ }
+
+ return (DONT_ENQUEUE);
+}
+
+/********************************************************************
+ *
+ * Reformat an XEvent into a wire event.
+ */
+static Status
+XpEventToWire(dpy, re, event, count)
+ register Display *dpy; /* pointer to display structure */
+ register XEvent *re; /* pointer to client event */
+ register xEvent **event; /* wire protocol event */
+ register int *count;
+{
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ switch ((re->type & 0x7f) - info->codes->first_event)
+ {
+#ifdef PRINT_SomeEventExample2
+ case PRINT_SomeEventExample:
+ {
+ register XDeviceKeyEvent *ev = (XDeviceKeyEvent*) re;
+ register deviceKeyButtonPointer *kev;
+ register deviceValuator *vev;
+ int i;
+
+ *count = 2;
+ kev = (deviceKeyButtonPointer *) Xmalloc (*count * sizeof (xEvent));
+ if (!kev)
+ return(_XUnknownNativeEvent(dpy, re, event));
+ *event = (xEvent *) kev;
+
+ kev->type = ev->type;
+ kev->root = ev->root;
+ kev->event = ev->window;
+ kev->child = ev->subwindow;
+ kev->time = ev->time;
+ kev->event_x = ev->x ;
+ kev->event_y = ev->y ;
+ kev->root_x = ev->x_root;
+ kev->root_y = ev->y_root;
+ kev->state = ev->state;
+ kev->same_screen = ev->same_screen;
+ kev->detail = ev->keycode;
+ kev->deviceid = ev->deviceid | MORE_EVENTS;
+
+ vev = (deviceValuator *) ++kev;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->device_state = ev->device_state;
+ vev->first_valuator = ev->first_axis;
+ vev->num_valuators = ev->axes_count;
+ i = vev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: vev->valuator5 = ev->axis_data[5];
+ case 5: vev->valuator4 = ev->axis_data[4];
+ case 4: vev->valuator3 = ev->axis_data[3];
+ case 3: vev->valuator2 = ev->axis_data[2];
+ case 2: vev->valuator1 = ev->axis_data[1];
+ case 1: vev->valuator0 = ev->axis_data[0];
+ }
+ break;
+ }
+#endif /* PRINT_SomeEventExample2 */
+
+ default:
+ return(_XUnknownNativeEvent(dpy, re, *event));
+ }
+}
diff --git a/nx-X11/lib/Xp/XpExtUtil.h b/nx-X11/lib/Xp/XpExtUtil.h
new file mode 100644
index 000000000..81b5ce3c4
--- /dev/null
+++ b/nx-X11/lib/Xp/XpExtUtil.h
@@ -0,0 +1,41 @@
+/* $XFree86: xc/lib/Xp/XpExtUtil.h,v 1.3 2002/10/16 00:37:31 dawes Exp $ */
+/*
+ * Copyright (C) 2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+
+#ifndef _XPEXTUTIL_H
+#define _XPEXTUTIL_H 1
+
+#include <X11/Xfuncproto.h>
+#include <X11/extensions/extutil.h>
+
+extern XEXT_FIND_DISPLAY_PROTO(xp_find_display);
+
+extern int XpCheckExtInit(
+ Display * /* dpy */,
+ int /* version_index */
+);
+
+#endif /* _XPEXTUTIL_H */
diff --git a/nx-X11/lib/Xp/XpExtVer.c b/nx-X11/lib/Xp/XpExtVer.c
new file mode 100644
index 000000000..32227e89f
--- /dev/null
+++ b/nx-X11/lib/Xp/XpExtVer.c
@@ -0,0 +1,125 @@
+/* $Xorg: XpExtVer.c,v 1.4 2000/08/17 19:46:07 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpExtVer.c,v 1.5 2002/10/16 00:37:31 dawes Exp $ */
+
+#define NEED_REPLIES
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+
+
+Bool
+XpQueryExtension (
+ Display *dpy,
+ int *event_base_return, /* return value */
+ int *error_base_return /* return value */
+)
+{
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ if (XextHasExtension (info)) {
+ *event_base_return = info->codes->first_event;
+ *error_base_return = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+/* Prototype for |XpCheckExtInitUnlocked()|
+ * See XpExtUtil.c - same as |XpCheckExtInit()| but does not obtain the Xlib global lock */
+extern int XpCheckExtInitUnlocked(
+ register Display *dpy,
+ register int version_index
+);
+
+Status
+XpQueryVersion (
+ Display *dpy,
+ short *major_version,
+ short *minor_version
+)
+{
+ xPrintQueryVersionReq *req;
+ xPrintQueryVersionReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ /*
+ * Note: many extensions treat major and minor as "ints", but
+ * protocol wise and internal wise, they're shorts.
+ */
+ *major_version = 0;
+ *minor_version = 0;
+
+#ifdef Would_Need_xpPrintData_Struct_Def
+ /*
+ * We may already have the answer cached from a previous query.
+ */
+ if (( info->data ) && ( ((xpPrintData *) info->data)->vers->present )) {
+ *major_version = ((xpPrintData *) info->data)->vers->major_version ;
+ *minor_version = ((xpPrintData *) info->data)->vers->minor_version ;
+ return (/* non-zero indicates extension present */ True);
+ }
+#endif /* Would_Need_xpPrintData_Struct_Def */
+
+ if (XpCheckExtInitUnlocked(dpy, XP_DONT_CHECK) == -1)
+ return (/* No such extension */ False);
+
+ LockDisplay (dpy);
+
+ GetReq(PrintQueryVersion,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintQueryVersion;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(/* No such extension */ False);
+ }
+
+ *major_version = rep.majorVersion;
+ *minor_version = rep.minorVersion;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (/* non-zero indicates extension present */ True);
+}
+
diff --git a/nx-X11/lib/Xp/XpGetData.c b/nx-X11/lib/Xp/XpGetData.c
new file mode 100644
index 000000000..b49502155
--- /dev/null
+++ b/nx-X11/lib/Xp/XpGetData.c
@@ -0,0 +1,215 @@
+/* $Xorg: XpGetData.c,v 1.4 2000/08/17 19:46:07 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpGetData.c,v 1.4 2001/01/17 19:43:02 dawes Exp $ */
+
+#define NEED_REPLIES
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+
+#define MAX_XP_BUFFER_SIZE 32768
+
+/*
+ * At the tail of every async struct of ours is attached the
+ * following "dev private" information needed by our async handler.
+ */
+typedef struct {
+ XPContext context;
+ XPSaveProc save_proc;
+ XPFinishProc finish_proc;
+ XPointer client_data;
+ _XAsyncHandler *async;
+ unsigned long seq; /* sequence # that will trigger handler */
+} _XpState;
+
+
+/*
+ * The following is the handler for async replies from
+ * XpGetDocumentData().
+ */
+static Bool
+_XpGetDocDataHandler(dpy, rep, buf, len, adata)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer adata;
+{
+ register _XpState *state;
+ xPrintGetDocumentDataReply replbuf;
+ xPrintGetDocumentDataReply *repl;
+ int dataLen;
+ char *data;
+
+ state = (_XpState *)adata;
+
+ /*
+ * Bypass this handler if the reply is NOT the one we're looking for.
+ */
+ if (dpy->last_request_read != state->seq) {
+ return False;
+ }
+
+ /*
+ * When an error occurs, call the finish_proc and then de-queue
+ * this event handler. Once an error occurs, all bets are off.
+ * The error XPGetDocError is *not* the most descriptive, so the
+ * caller will be encouraged to dig around for the corresponding
+ * generated error.
+ *
+ * Note - Do not confuse the "generated" errors here with
+ * XPGetDocSecondConsumer which is returned in a protocol reply.
+ */
+ if (rep->generic.type == X_Error) {
+ (*state->finish_proc)( (Display *) dpy,
+ (XPContext) state->context,
+ XPGetDocError,
+ (XPointer) state->client_data );
+ DeqAsyncHandler(dpy, state->async);
+ Xfree(state->async);
+ return False;
+ }
+
+ repl = (xPrintGetDocumentDataReply *)
+ _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len, 0, False);
+
+ if (repl->dataLen) {
+ /*
+ * Call save_proc in cases where there was document data
+ */
+
+ dataLen = repl->length << 2; /*with pad len*/
+
+ data = (char *) _XAllocTemp( dpy, dataLen );
+
+ _XGetAsyncData( dpy, (char *) data, buf, len,
+ SIZEOF(xPrintGetDocumentDataReply), dataLen, 0);
+
+ (*state->save_proc)( (Display *) dpy,
+ (XPContext) state->context,
+ (unsigned char *) data,
+ (unsigned int) repl->dataLen, /* actual len */
+ (XPointer) state->client_data );
+
+ _XFreeTemp( dpy, (char *) data, dataLen );
+ }
+
+ if (repl->finishedFlag) {
+ /*
+ * Call finish_proc
+ */
+ (*state->finish_proc)( (Display *) dpy,
+ (XPContext) state->context,
+ (XPGetDocStatus) repl->statusCode,
+ (XPointer) state->client_data );
+ /*
+ * De-queue this async handler - we're done.
+ */
+ DeqAsyncHandler( dpy, state->async );
+ Xfree(state->async);
+ }
+
+ return True; /* the reply WAS consumed by this handler */
+}
+
+/******************************************************************************
+ *
+ * XpGetDocumentData()
+ *
+ * ...registers callbacks to be triggered when async protocol replies
+ * come back in response to the origial request.
+ *
+ * Returned Status indicate whether the callbacks will be used
+ * (finish_proc and possibly save_proc), or whether they will
+ * never be used.
+ *
+ */
+Status
+XpGetDocumentData (
+ Display *dpy,
+ XPContext context,
+ XPSaveProc save_proc,
+ XPFinishProc finish_proc,
+ XPointer client_data
+)
+{
+ xPrintGetDocumentDataReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+ _XAsyncHandler *async;
+ _XpState *async_state;
+
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return(0); /* No such extension */
+
+ async = (_XAsyncHandler *)Xmalloc(sizeof(_XAsyncHandler) +
+ sizeof(_XpState));
+ if (!async)
+ return(0); /* malloc error */
+ async_state = (_XpState *)(async + 1);
+
+ LockDisplay (dpy);
+
+ GetReq(PrintGetDocumentData,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintGetDocumentData;
+ req->printContext = context;
+ req->maxBufferSize = MAX_XP_BUFFER_SIZE; /* use as a hint to X server */
+
+ async_state->context = context;
+ async_state->save_proc = save_proc;
+ async_state->finish_proc = finish_proc;
+ async_state->client_data = client_data;
+ async_state->seq = dpy->request;
+ async_state->async = async;
+
+ async->next = dpy->async_handlers;
+ async->handler = _XpGetDocDataHandler;
+ async->data = (XPointer)async_state;
+
+ dpy->async_handlers = async;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return(1); /* success at registering a handler */
+}
+
diff --git a/nx-X11/lib/Xp/XpImageRes.c b/nx-X11/lib/Xp/XpImageRes.c
new file mode 100644
index 000000000..5b7a5c476
--- /dev/null
+++ b/nx-X11/lib/Xp/XpImageRes.c
@@ -0,0 +1,118 @@
+/* $Xorg: XpImageRes.c,v 1.4 2000/08/17 19:46:07 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpImageRes.c,v 1.4 2001/01/17 19:43:02 dawes Exp $ */
+
+
+#define NEED_REPLIES
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+
+
+Bool
+XpSetImageResolution (
+ Display *dpy,
+ XPContext print_context,
+ int image_res,
+ int *prev_res
+)
+{
+ xPrintSetImageResolutionReq *req;
+ xPrintSetImageResolutionReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ if (image_res < 0 || image_res > 65535)
+ return (False);
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return (False);
+
+ LockDisplay (dpy);
+
+ GetReq(PrintSetImageResolution,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintSetImageResolution;
+ req->printContext = print_context;
+ req->imageRes = image_res;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(False);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (rep.status && prev_res)
+ *prev_res = rep.prevRes;
+ return ( rep.status );
+}
+
+int
+XpGetImageResolution (
+ Display *dpy,
+ XPContext print_context
+)
+{
+ xPrintGetImageResolutionReq *req;
+ xPrintGetImageResolutionReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return (-1);
+
+ LockDisplay (dpy);
+
+ GetReq(PrintGetImageResolution,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintGetImageResolution;
+ req->printContext = print_context;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(-1);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ( rep.imageRes );
+}
diff --git a/nx-X11/lib/Xp/XpInput.c b/nx-X11/lib/Xp/XpInput.c
new file mode 100644
index 000000000..099189517
--- /dev/null
+++ b/nx-X11/lib/Xp/XpInput.c
@@ -0,0 +1,107 @@
+/* $Xorg: XpInput.c,v 1.4 2000/08/17 19:46:07 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpInput.c,v 1.4 2001/01/17 19:43:02 dawes Exp $ */
+
+#define NEED_REPLIES
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+
+
+void
+XpSelectInput (
+ Display *dpy,
+ XPContext print_context,
+ unsigned long event_mask
+)
+{
+ xPrintSelectInputReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
+ return; /* NoSuchExtension NULL */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintSelectInput,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintSelectInput;
+ req->printContext = print_context;
+ req->eventMask = event_mask;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+unsigned long
+XpInputSelected (
+ Display *dpy,
+ XPContext print_context,
+ unsigned long *all_events_mask
+)
+{
+ xPrintInputSelectedReq *req;
+ xPrintInputSelectedReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return (/* No such extension */ 0L );
+
+ LockDisplay (dpy);
+
+ GetReq(PrintInputSelected,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintInputSelected;
+ req->printContext = print_context;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(/* No such extension */ 0L);
+ }
+
+ *all_events_mask = rep.allEventsMask;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ( rep.eventMask );
+}
+
diff --git a/nx-X11/lib/Xp/XpJob.c b/nx-X11/lib/Xp/XpJob.c
new file mode 100644
index 000000000..1ad7e306a
--- /dev/null
+++ b/nx-X11/lib/Xp/XpJob.c
@@ -0,0 +1,206 @@
+/* $Xorg: XpJob.c,v 1.4 2000/08/17 19:46:07 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpJob.c,v 1.5 2002/04/10 16:20:07 tsi Exp $ */
+
+#if defined(sun) && defined(i386) && defined(SVR4) && !defined(__EXTENSIONS__)
+#define __EXTENSIONS__
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include <X11/Xos.h>
+#include "XpExtUtil.h"
+#include <limits.h>
+#ifndef WIN32
+#define X_INCLUDE_PWD_H
+#define XOS_USE_XLIB_LOCKING
+#include <X11/Xos_r.h>
+#endif
+#include <limits.h>
+
+
+typedef struct {
+ int event_base_return;
+ XPContext context;
+} _XpDiscardJobRec;
+
+static Bool _XpDiscardJob(Display *dpy, XEvent *event, XPointer arg)
+{
+ _XpDiscardJobRec *disrec = (_XpDiscardJobRec *) arg;
+
+ if (event->type != disrec->event_base_return + XPPrintNotify)
+ return False;
+
+ if (disrec->context != ((XPPrintEvent *) event)->context)
+ return False;
+
+ if ((((XPPrintEvent *) event)->detail == XPEndJobNotify) ||
+ (((XPPrintEvent *) event)->detail == XPEndDocNotify) ||
+ (((XPPrintEvent *) event)->detail == XPEndPageNotify)) {
+ return False;
+ }
+
+ return True;
+}
+
+
+void
+XpStartJob (
+ Display *dpy,
+ XPSaveData save_data
+)
+{
+ xPrintStartJobReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ XPContext context;
+
+
+ /****************************************************************
+ *
+ * PRIOR TO XPSTARTJOB, set the job attribute "job-owner"
+ * which will be used by the X-Server when it spools the
+ * output. When XpStartJob completes, the job attribute
+ * pool is frozen, disallowing "job-owner" to be modified.
+ */
+ {
+ char *joa; /* job owner attribute */
+ char *PwName;
+#ifndef WIN32
+#ifdef X_NEEDS_PWPARAMS
+ _Xgetpwparams pwparams;
+#endif
+ struct passwd *pw;
+ pw = _XGetpwuid(getuid(),pwparams);
+
+ if (pw && (PwName = pw->pw_name)) {
+#else
+ if ((PwName = getenv("USERNAME"))) {
+#endif
+ joa = (char *) Xmalloc( strlen( PwName ) + 20 );
+ sprintf( joa, "*job-owner: %s", PwName );
+ context = XpGetContext( dpy );
+ XpSetAttributes( dpy, context, XPJobAttr, joa, XPAttrMerge );
+
+ Xfree( joa );
+ }
+ }
+
+ if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
+ return; /* NoSuchExtension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintStartJob,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintStartJob;
+ req->saveData = (CARD8) save_data;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+
+void
+XpEndJob (
+ Display *dpy
+)
+{
+ xPrintEndJobReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
+ return; /* NoSuchExtension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintEndJob,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintEndJob;
+ req->cancel = False;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+
+void
+XpCancelJob (
+ Display *dpy,
+ Bool discard
+)
+{
+ xPrintEndJobReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ _XpDiscardJobRec disrec;
+ XEvent event;
+
+
+ if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
+ return; /* NoSuchExtension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintEndJob,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintEndJob;
+ req->cancel = True;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+
+ if (discard) {
+ /*
+ * get context and effectively do a sync of events.
+ */
+ disrec.event_base_return = info->codes->first_event;
+ disrec.context = XpGetContext(dpy);
+
+ /*
+ * discard job, and also doc and page XPPrintNotify events.
+ */
+ while (XCheckIfEvent(dpy, &event, _XpDiscardJob, (XPointer) &disrec))
+ {
+ /*EMPTY*/
+ }
+ }
+}
+
diff --git a/nx-X11/lib/Xp/XpLocale.c b/nx-X11/lib/Xp/XpLocale.c
new file mode 100644
index 000000000..ef7c5fb01
--- /dev/null
+++ b/nx-X11/lib/Xp/XpLocale.c
@@ -0,0 +1,269 @@
+/* $Xorg: XpLocale.c,v 1.3 2000/08/17 19:46:07 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpLocale.c,v 1.4 2001/01/17 19:43:02 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+
+#include <X11/Xlocale.h>
+
+
+/*
+ * Global hangers for locale hint machinery.
+ */
+XPHinterProc _xp_hinter_proc = NULL;
+char *_xp_hinter_desc = NULL;
+int _xp_hinter_init = 1; /* need to init */
+
+
+extern char *_xpstrdup();
+
+
+/******************************************************************************
+ *
+ * THE DEFAULT LOCALE HINTER
+ *
+ * Make changes here only.
+ */
+static char *_XpLocaleHinter()
+{
+#ifdef hpux
+ char lbuf[ LC_BUFSIZ ];
+
+ if ( setlocale_r( LC_CTYPE, (char *) NULL, lbuf, LC_BUFSIZ ) ) {
+#else
+ char *lbuf;
+
+ if ((lbuf = setlocale(LC_CTYPE, (char *) NULL)) == NULL) {
+#endif
+ return( _xpstrdup( "" ) );
+ }
+ else {
+ return( _xpstrdup( lbuf ) );
+ }
+}
+
+#define _XPLOCALEHINTERDESC NULL
+
+
+/******************************************************************************
+ *
+ * XpSetLocaleHinter
+ */
+void
+XpSetLocaleHinter (
+ XPHinterProc hinter_proc,
+ char *hinter_desc
+)
+{
+
+ _XLockMutex(_Xglobal_lock);
+
+ /*
+ * Free up existing hinter description.
+ */
+ if (_xp_hinter_desc)
+ XFree( _xp_hinter_desc );
+
+ /*
+ * Either install the default hinter, or install the
+ * one provided by the caller.
+ */
+ if (!hinter_proc) {
+ _xp_hinter_proc = _XpLocaleHinter;
+ _xp_hinter_desc = _xpstrdup( _XPLOCALEHINTERDESC );
+ _xp_hinter_init = 0;
+ }
+ else {
+ _xp_hinter_proc = hinter_proc;
+ _xp_hinter_desc = _xpstrdup( hinter_desc );
+ _xp_hinter_init = 0;
+ }
+
+ _XUnlockMutex(_Xglobal_lock);
+}
+
+
+/******************************************************************************
+ *
+ * XpGetLocaleHinter
+ */
+char *
+XpGetLocaleHinter (
+ XPHinterProc *hinter_proc
+)
+{
+ char *tmpstr;
+
+ _XLockMutex(_Xglobal_lock);
+
+ if (_xp_hinter_init) {
+ _xp_hinter_proc = _XpLocaleHinter;
+ _xp_hinter_desc = _xpstrdup( _XPLOCALEHINTERDESC );
+ _xp_hinter_init = 0;
+ }
+
+ *hinter_proc = _xp_hinter_proc;
+ tmpstr = _xpstrdup( _xp_hinter_desc );
+
+ _XUnlockMutex(_Xglobal_lock);
+
+ return( tmpstr );
+}
+
+
+/******************************************************************************
+ *
+ * XpGetLocaleNetString
+ *
+ * this is the routine that uses the locale hint machinery
+ * to construct the actual "locale_hint" that is passed in
+ * the various protocols and ICCCM-selection requests.
+ *
+ * A "Locale Net String" is made up of two components, a "locale hint"
+ * that is the locale, and a "locale description" that is a description
+ * of how the locale was derived.
+ *
+ * If a locale hint and description are available, then the net string
+ * will be the description, and if the description contains the
+ * keyword "%locale%", that keyword will be replaced with the locale
+ * hint. For example:
+ *
+ * locale_desc = XOPEN;%locale%;01_00;XFN-001001
+ * locale_hint = de_DE
+ *
+ * result is = XOPEN;de_DE;01_00;XFN-001001
+ *
+ * If only a locale description is available, then it becomes the
+ * entire net string.
+ *
+ * If only a locale hint is available, then it becomes the
+ * entire net string.
+ *
+ * If neither a hint or description exists, a NULL is returned.
+ */
+char *XpGetLocaleNetString()
+{
+ XPHinterProc locale_hinter;
+
+ char *locale_desc;
+ char *locale_hint;
+ char *tptr1;
+ char *locale_net_string;
+
+
+ /*
+ * Fetch the current locale hinter machinery.
+ */
+ locale_desc = XpGetLocaleHinter( &locale_hinter );
+
+ /*
+ * Run it.
+ */
+ locale_hint = (locale_hinter)();
+
+ /*
+ * Use locale_desc and locale_hint to build a full
+ * locale net string.
+ */
+ if (locale_desc && locale_hint) {
+ /*
+ * Combine the two portions to form locale_net_string.
+ *
+ * For example:
+ */
+
+ tptr1 = strstr( locale_desc, "%locale%" );
+
+ if (tptr1) {
+ /*
+ * Insert locale_hint into locale_desc.
+ *
+ * Note: strlen("%locale%") = 8
+ */
+ locale_net_string = Xmalloc( strlen(locale_desc) - 8 +
+ strlen(locale_hint) + 1 );
+
+ /*
+ * Copy first portion of locale_desc.
+ */
+ *tptr1 = '\0';
+ strcpy( locale_net_string, locale_desc );
+
+ /*
+ * Copy middle portion consisting of locale_hint.
+ */
+ strcat( locale_net_string, locale_hint );
+
+ /*
+ * Copy first portion of locale_desc.
+ */
+ tptr1 = tptr1 + 8; /* skip by %Locale% keyword */
+
+ strcat( locale_net_string, tptr1 );
+
+ /*
+ * Free up and return.
+ */
+ XFree( locale_hint );
+ XFree( locale_desc );
+ return( locale_net_string );
+ }
+ else {
+ /*
+ * Since a locale_desc was given WITHOUT a place to insert
+ * the locale_hint, the locale_desc wins out.
+ */
+ XFree( locale_hint );
+ return( locale_desc );
+ }
+ }
+ else if (locale_desc) {
+ return( locale_desc );
+ }
+ else if (locale_hint) {
+ return( locale_hint );
+ }
+ else {
+ return( (char *) NULL );
+ }
+}
+
diff --git a/nx-X11/lib/Xp/XpNotifyPdm.c b/nx-X11/lib/Xp/XpNotifyPdm.c
new file mode 100644
index 000000000..feb62f0eb
--- /dev/null
+++ b/nx-X11/lib/Xp/XpNotifyPdm.c
@@ -0,0 +1,900 @@
+/* $Xorg: XpNotifyPdm.c,v 1.4 2000/08/17 19:46:07 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** Description: XpNotifyPdm is used to engage a Page Dialog Manager
+ ** (PDM). Though the PDM is not a formal part of the
+ ** Print Extension, the concept and likely usage of
+ ** PDM's is strong enough that this routine is being
+ ** provided as a sample standard mechanism for engaging
+ ** PDM's from the Print Extension.
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpNotifyPdm.c,v 1.7tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Print.h>
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Xauth.h>
+#include <stdlib.h>
+#include <X11/Xos.h>
+
+/*
+ * Alternate selection environment variables.
+ */
+#define ALT_PDM_SELECTION_ENV_VAR "XPDMSELECTION"
+#define ALT_PMD_DISPLAY_ENV_VAR "XPDMDISPLAY"
+
+/*
+ * X-Authority file for authorization tickets.
+ */
+#define PDM_XAUTHORITY_ENV_VAR "XPDMXAUTHORITY"
+
+/*
+ * str_dup using Xmalloc
+ */
+char *_xpstrdup(char * str)
+{
+ int len;
+ char *newstr;
+
+ if (!str)
+ return( (char *) NULL );
+
+ len = strlen(str) + 1;
+ newstr = (char *) Xmalloc( len );
+ memcpy( newstr, str, len );
+ return( newstr );
+}
+
+/******************************************************************************
+ *
+ * _XpGetSelectionServer
+ *
+ * Routine that considers print_display, video_display, and alt
+ * environment variables, and figures out the selection_display
+ * and selection_atom.
+ *
+ * selection_display can be one of print_display, video_display,
+ * or a brand new display connection that the caller will later
+ * have to close.
+ */
+static Display *
+_XpGetSelectionServer (
+ Display *print_display,
+ Display *video_display,
+ Atom *sel_atom /* return value */
+)
+{
+ char *tstr1, *tstr2, *tstr3, *tstrptr;
+ char *sel_displaystr;
+ Display *sel_display;
+ char *selectionstr;
+
+
+ /*
+ * Possibly tickle a selection on an alternate display.
+ */
+ if ( (sel_displaystr = getenv( ALT_PMD_DISPLAY_ENV_VAR )) != NULL ) {
+ if ( !strcmp(sel_displaystr, "print") ) {
+ /*
+ * Explicitly use the Print display.
+ */
+ sel_display = print_display;
+ }
+ else if ( !strcmp(sel_displaystr, "video") ) {
+ /*
+ * Explicitly use the Video display.
+ */
+ sel_display = video_display;
+ }
+ else {
+ /*
+ * Do more work to determine the selection server connection.
+ * The following is not clever enough to handle host aliases.
+ */
+ tstr1 = _xpstrdup( sel_displaystr );
+ tstr2 = _xpstrdup( XDisplayString(print_display) );
+ tstr3 = _xpstrdup( XDisplayString(video_display) );
+
+ /*
+ * remove ".scr" portion from "host:disp.scr" strings.
+ * Use strrchr to find : separating host from display
+ * to allow IPv6 numeric addresses with embedded colons.
+ */
+ if (( tstrptr = strrchr( tstr1, ':' ) ))
+ if (( tstrptr = strchr( tstrptr, '.' ) ))
+ *tstrptr = '\0';
+
+ if (( tstrptr = strrchr( tstr2, ':' ) ))
+ if (( tstrptr = strchr( tstrptr, '.' ) ))
+ *tstrptr = '\0';
+
+ if (( tstrptr = strrchr( tstr3, ':' ) ))
+ if (( tstrptr = strchr( tstrptr, '.' ) ))
+ *tstrptr = '\0';
+
+ if ( !strcmp( tstr1, tstr2 ) ) {
+ /*
+ * Explicitly use the Print display.
+ */
+ sel_display = print_display;
+ }
+ else if ( !strcmp( tstr1, tstr3 ) ) {
+ /*
+ * Explicitly use the Print display.
+ */
+ sel_display = video_display;
+ }
+ else {
+ /*
+ * Create a new display connection to a server
+ * never previously contacted. The caller will
+ * have to realize this is a new display handle
+ * (ie, its not equal to print_display or
+ * video_display) when done.
+ */
+ sel_display = XOpenDisplay(sel_displaystr);
+ }
+
+ XFree( tstr3 );
+ XFree( tstr2 );
+ XFree( tstr1 );
+ }
+ }
+ else {
+ /*
+ * If no alt selection server, use the print server.
+ */
+ sel_display = print_display;
+ }
+
+ if (sel_display) {
+ /*
+ * Tickle (possibly alternate) PDM_MANAGER selection
+ */
+ if ( (selectionstr = getenv( ALT_PDM_SELECTION_ENV_VAR )) == NULL )
+ selectionstr = "PDM_MANAGER";
+
+ *sel_atom = XInternAtom( sel_display, selectionstr, False );
+ }
+
+ return( sel_display );
+}
+
+
+
+/******************************************************************************
+ *
+ * XpGetPdmStartParams
+ */
+Status
+XpGetPdmStartParams (
+ Display *print_display,
+ Window print_window,
+ XPContext print_context,
+ Display *video_display,
+ Window video_window,
+ Display **selection_display, /* return value */
+ Atom *selection, /* return value */
+ Atom *type, /* return value */
+ int *format, /* return value */
+ unsigned char **data, /* return value */
+ int *nelements /* return value */
+)
+{
+ XTextProperty text_prop;
+ int status;
+ char str1[128], str2[128], str3[128];
+ char *list[6];
+
+
+ *selection_display = _XpGetSelectionServer( print_display, video_display,
+ selection );
+
+ if (*selection_display == NULL) {
+ /*
+ * Error - cannot determine or establish a selection_display.
+ */
+ return( (Status) NULL );
+ }
+
+ /*
+ * Create a property that can be included in the PDM_MANAGER
+ * selection to communicate information.
+ *
+ * video_display host:display[.anyScreen]
+ * video_window
+ * print_display host:display[.anyScreen]
+ * print_window
+ * print_context use to derive host:display.properScreen and other
+ * locale_hint
+ */
+ list[0] = XDisplayString( video_display );
+ sprintf( str1, "0x%lx", (long)video_window );
+ list[1] = str1;
+
+ list[2] = XDisplayString( print_display );
+ sprintf( str2, "0x%lx", (long)print_window );
+ list[3] = str2;
+
+ sprintf( str3, "0x%lx", (long)print_context );
+ list[4] = str3;
+
+ list[5] = XpGetLocaleNetString();
+
+ status = XSupportsLocale();
+ if ( ! status ) {
+ /*
+ * Error.
+ */
+ if ( (*selection_display != print_display) &&
+ (*selection_display != video_display) ) {
+ XCloseDisplay( *selection_display );
+ *selection_display = (Display *) NULL;
+ }
+ return( (Status) NULL );
+ }
+
+ status = XmbTextListToTextProperty( *selection_display, list, 6,
+ XStdICCTextStyle, &text_prop );
+
+ if ( status < 0 ) {
+ /*
+ * Error.
+ */
+ if ( (*selection_display != print_display) &&
+ (*selection_display != video_display) ) {
+ XCloseDisplay( *selection_display );
+ *selection_display = (Display *) NULL;
+ }
+ return( (Status) NULL );
+ }
+
+ *type = text_prop.encoding;
+ *format = text_prop.format;
+ *data = text_prop.value;
+ *nelements = text_prop.nitems;
+
+ XFree(list[5]);
+
+ return( (Status) 1 );
+}
+
+/******************************************************************************
+ *
+ * XpSendOneTicket
+ *
+ * The ticket transfer protocol is as follows:
+ * unsigned short ticket_state;
+ * - 0 means NULL ticket, terminating ticket
+ * - 1 means non-NULL ticket, terminating ticket
+ * - 2 means non-NULL ticket, and more tickets to send
+ * unsigned short address_length;
+ * unsigned short number_length;
+ * unsigned short name_length;
+ * unsigned short data_length;
+ * unsigned short family;
+ *
+ * char *address;
+ * char *number;
+ * char *name;
+ * char *data;
+ *
+ */
+
+Status XpSendOneTicket(
+ Display *display,
+ Window window,
+ Xauth *ticket,
+ Bool more )
+{
+ XClientMessageEvent ev;
+ int bigstrlen, left, gofor;
+ char *bigstr, *tptr;
+ Status status;
+
+ /*
+ * Fixed portion of event.
+ */
+ ev.type = ClientMessage;
+ ev.display = display;
+ ev.window = window;
+ ev.message_type = XInternAtom( display, "PDM_MAIL", False );
+
+ /*
+ * Special build the first ClientMessage to carry the
+ * ticket transfer header.
+ */
+ ev.format = 16;
+
+ if (!ticket) {
+ ev.data.s[0] = 0;
+ }
+ else {
+ if (more)
+ ev.data.s[0] = 2;
+ else
+ ev.data.s[0] = 1;
+ ev.data.s[1] = (short) ticket->address_length;
+ ev.data.s[2] = (short) ticket->number_length;
+ ev.data.s[3] = (short) ticket->name_length;
+ ev.data.s[4] = (short) ticket->data_length;
+ ev.data.s[5] = (short) ticket->family;
+ }
+
+ status = XSendEvent( display, window, False, 0L, (XEvent *) &ev );
+ if (!status)
+ return( (Status) 0 );
+
+ if (!ticket)
+ return( (Status) 1 );;
+
+ /*
+ * Break down the remaining ticket data and build the
+ * second thru N ClientMessages.
+ */
+ ev.format = 8;
+ bigstrlen = (int) ticket->address_length +
+ (int) ticket->number_length +
+ (int) ticket->name_length +
+ (int) ticket->data_length;
+
+ bigstr = Xmalloc( bigstrlen );
+
+ tptr = bigstr;
+ memcpy( tptr, ticket->address, ticket->address_length );
+ tptr += ticket->address_length;
+ memcpy( tptr, ticket->number, ticket->number_length );
+ tptr += ticket->number_length;
+ memcpy( tptr, ticket->name, ticket->name_length );
+ tptr += ticket->name_length;
+ memcpy( tptr, ticket->data, ticket->data_length );
+
+ left = bigstrlen;
+ tptr = bigstr;
+
+ while ( left ) {
+ if (left > 20)
+ gofor = 20;
+ else
+ gofor = left;
+
+ memcpy( ev.data.b, tptr, gofor );
+
+ tptr += gofor;
+ left -= gofor;
+
+ status = XSendEvent( display, window, False, 0L, (XEvent *) &ev );
+ if (!status) {
+ Xfree( bigstr );
+ return( (Status) 0 );
+ }
+ }
+
+ Xfree( bigstr );
+
+ return( (Status) 1 );
+}
+
+Status XpSendAuth( Display *display, Window window )
+{
+
+ FILE *auth_file;
+ char *auth_name;
+ Xauth *entry;
+
+ if ( !(auth_name = getenv( PDM_XAUTHORITY_ENV_VAR )) ) {
+ return( (Status) 0 );
+ /* auth_name = XauFileName (); */
+ }
+
+ if (access (auth_name, R_OK) != 0) /* checks REAL id */
+ return( (Status) 0 );
+
+ auth_file = fopen (auth_name, "r");
+ if (!auth_file)
+ return( (Status) 0 );
+
+ for (;;) {
+ entry = XauReadAuth (auth_file);
+ if (!entry)
+ break;
+
+ /*
+ * NOTE: in and around this area, an optimization can
+ * be made. Rather than sending all the tickets in
+ * .Xauthority, just pull out the *one* that is needed
+ * by the PDM.
+ */
+ XpSendOneTicket( display, window, entry, True );
+
+ XauDisposeAuth (entry);
+ }
+
+ XpSendOneTicket( display, window, (Xauth *) NULL, False );
+
+ (void) fclose (auth_file);
+
+ return( (Status) 1 );
+}
+
+/******************************************************************************
+ *
+ *
+ */
+Status
+XpGetAuthParams (
+ Display *print_display,
+ Display *video_display,
+ Display **sel_display, /* return value */
+ Atom *sel_atom, /* return value */
+ Atom *sel_target_atom /* return value */
+)
+{
+ *sel_display = _XpGetSelectionServer( print_display, video_display,
+ sel_atom );
+
+ if (*sel_display == NULL) {
+ /*
+ * Error - cannot determine or establish a selection_display.
+ */
+ return (Status)0;
+ }
+
+ /*
+ * Create property and transfer data to.
+ */
+ *sel_target_atom = XInternAtom( *sel_display, "PDM_MBOX", False );
+ return (Status)1;
+}
+
+
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** UNSUPPORTED ROUTINES used for testing and debugging.
+ **
+ **/
+
+
+/******************************************************************************
+ *
+ * Predicate routines to dig out events from the users event queue.
+ */
+
+/*
+ * client_data structures to use with XIfEvent()
+ */
+typedef struct {
+ Window requestor;
+ Atom selection;
+ Atom target;
+} Dosnrec;
+
+typedef struct {
+ Window window;
+ Atom atom;
+} Dopnrec, Docmrec;
+
+
+/*
+ * Dig out a selection notify from the users event
+ * queue.
+ */
+static Bool digOutSelectionNotify(
+ Display *display,
+ XEvent *event,
+ char *arg
+)
+
+{
+ Dosnrec *t;
+
+ if (event->type == SelectionNotify) {
+ t = (Dosnrec *) arg;
+
+ /*
+ * Selection complete because of good reply.
+ */
+ if ( ( t->requestor == event->xselection.requestor ) &&
+ ( t->selection == event->xselection.selection ) &&
+ ( t->target == event->xselection.target ) ) {
+ return( True );
+ }
+
+ /*
+ * Selection complete because of problem, and X-Server
+ * had to generate the event.
+ */
+ if ( ( t->requestor == event->xselection.requestor ) &&
+ ( t->selection == event->xselection.selection ) &&
+ ( None == event->xselection.property ) ) {
+ return( True );
+ }
+ }
+ return( False );
+}
+
+/*
+ * Dig out a property notify event for the XpNotifyPdm
+ * selection mechanism from the users event queue.
+ */
+static Bool digOutPropertyNotify(
+ Display *display,
+ XEvent *event,
+ char *arg
+)
+{
+ Dopnrec *t;
+
+ if (event->type == PropertyNotify) {
+ t = (Dopnrec *) arg;
+ if ( ( t->window == event->xproperty.window ) &&
+ ( t->atom == event->xproperty.atom ) ) {
+ return( True );
+ }
+ }
+ return( False );
+}
+
+#ifdef UNUSED
+/*
+ * Dig out a ClientMessage of type PDM_REPLY.
+ */
+static Bool digOutClientMessage(
+ Display *display,
+ XEvent *event,
+ char *arg
+)
+{
+ Docmrec *t;
+
+ if (event->type == ClientMessage) {
+ t = (Docmrec *) arg;
+ if ( ( t->window == event->xclient.window ) &&
+ ( t->atom == event->xclient.message_type ) ) {
+ return( True );
+ }
+ }
+ return( False );
+}
+#endif
+
+
+/******************************************************************************
+ *
+ * XpCookieToPdm
+ */
+static char *
+XpCookieToPdm (
+ Display *print_display,
+ Display *video_display,
+ Window sel_window
+)
+{
+ Display *sel_display;
+ Atom prop_atom, sel_atom, pdm_mbox_atom, ttype;
+ Dosnrec dosnrec;
+ Dopnrec dopnrec;
+ XEvent tevent;
+ int tformat;
+ unsigned long nitems, bytes_after;
+ unsigned char *return_data;
+ char *sel_str;
+ char cdata[2048];
+ Window tmpw;
+
+
+ if ( !getenv(PDM_XAUTHORITY_ENV_VAR) ) {
+ /*
+ * short cut for lack of cookie file.
+ */
+ return( (char *) NULL );
+ }
+
+ if (! XpGetAuthParams( print_display, video_display,
+ &sel_display, &sel_atom, &pdm_mbox_atom ) ) {
+ sprintf(cdata,
+ "XpCookieToPdm: XpGetAuthParams failed");
+ return( _xpstrdup( cdata ) );
+ }
+
+ prop_atom = XInternAtom( sel_display, "PDM_MBOX_PROP", False );
+
+ XConvertSelection( sel_display, sel_atom, pdm_mbox_atom,
+ prop_atom, sel_window, CurrentTime );
+
+ /*
+ * Hang out waiting for a SelectionNotify. Dig out from
+ * event queue when it arrives.
+ */
+ dosnrec.requestor = sel_window;
+ dosnrec.selection = sel_atom;
+ dosnrec.target = pdm_mbox_atom;
+
+ XIfEvent( sel_display, &tevent, digOutSelectionNotify, (char *) &dosnrec );
+
+ /*
+ * See if selection was successful.
+ */
+ if ( tevent.xselection.property == None ) {
+ /*
+ * The selection failed.
+ */
+ sel_str = XGetAtomName( sel_display, sel_atom );
+ sprintf(cdata,
+ "XpCookieToPdm: Unable to make selection on %s", sel_str);
+ XFree(sel_str);
+
+ XDeleteProperty( sel_display, sel_window, prop_atom );
+ if ((sel_display != print_display) && (sel_display != video_display))
+ XCloseDisplay( sel_display );
+ return( _xpstrdup( cdata ) );
+ }
+
+ /*
+ * Read property content for status.
+ */
+ XGetWindowProperty( sel_display, sel_window,
+ prop_atom, 0, 100000, True, AnyPropertyType,
+ &ttype, &tformat, &nitems, &bytes_after,
+ &return_data );
+
+ /*
+ * So that the client won't see how XpCookieToPdm is implemented,
+ * run through the event queue, dig out, and destroy all
+ * PropertyNotify events related to this call.
+ */
+ dopnrec.window = sel_window;
+ dopnrec.atom = prop_atom;
+ while ( XCheckIfEvent( sel_display, &tevent, digOutPropertyNotify,
+ (char *) &dopnrec ) );
+
+ if ((sel_display != print_display) && (sel_display != video_display))
+ XCloseDisplay( sel_display );
+
+ if ((ttype != XA_WINDOW) && (tformat != 32) && (nitems != 1)) {
+ /*
+ * Unable to read SelectionNotify property.
+ */
+ sprintf(cdata,
+ "XpCookieToPdm: Unable to read SelectionNotify property" );
+ return( _xpstrdup( cdata ) );
+ }
+
+ tmpw = *((Window *) return_data);
+ Xfree( return_data );
+
+ /*
+ * Now send cookie information.
+ */
+ XpSendAuth( sel_display, tmpw );
+
+ return( (char *) NULL );
+}
+
+
+/******************************************************************************
+ *
+ * XpNotifyPdm
+ */
+char *
+XpNotifyPdm (
+ Display *print_display,
+ Window print_window,
+ XPContext print_context,
+ Display *video_display,
+ Window video_window,
+ Bool auth_flag
+)
+{
+ enum { XA_PDM_CLIENT_PROP, XA_PDM_START, XA_PDM_START_OK,
+ XA_PDM_START_VXAUTH, XA_PDM_START_PXAUTH, XA_PDM_START_ERROR,
+ NUM_ATOMS };
+ static char *atom_names[] = {
+ "PDM_CLIENT_PROP", "PDM_START", "PDM_START_OK",
+ "PDM_START_VXAUTH", "PDM_START_PXAUTH", "PDM_START_ERROR" };
+
+ char cdata[2048];
+ char *tptr;
+ Dosnrec dosnrec;
+ Dopnrec dopnrec;
+ XEvent tevent;
+
+ Display *sel_display;
+ int sel_screen;
+ Atom sel_atom;
+ char *sel_str;
+
+ Window sel_window;
+ Atom prop_type;
+ int prop_format;
+ unsigned char *prop_data;
+ int prop_nelements;
+
+ Atom ttype;
+ int tformat;
+ unsigned long nitems, bytes_after;
+ unsigned char *return_data;
+
+ int tmpi;
+ Atom atoms[NUM_ATOMS];
+
+
+
+ if ( ! XpGetPdmStartParams( print_display, print_window, print_context,
+ video_display, video_window,
+ &sel_display,
+ &sel_atom,
+ &prop_type,
+ &prop_format,
+ &prop_data,
+ &prop_nelements ) ) {
+
+ sprintf(cdata, "XpNotifyPdm: XpGetPdmStartParams failed" );
+ return( _xpstrdup( cdata ) );
+ }
+
+
+ sel_screen = DefaultScreen( sel_display );
+ sel_window = XCreateSimpleWindow( sel_display,
+ DefaultRootWindow( sel_display ),
+ 0, 0, 1, 1, 1,
+ BlackPixel(sel_display, sel_screen),
+ WhitePixel(sel_display, sel_screen) );
+
+ /*
+ * Possibly send over authorization cookies first.
+ */
+ if (auth_flag) {
+ tptr = XpCookieToPdm ( print_display, video_display, sel_window );
+ if (tptr)
+ return( tptr );
+ }
+
+ /*
+ * Create property and transfer data to.
+ */
+ XInternAtoms( sel_display, atom_names, NUM_ATOMS, False, atoms );
+
+ XChangeProperty( sel_display,
+ sel_window, atoms[XA_PDM_CLIENT_PROP],
+ prop_type,
+ prop_format,
+ PropModeReplace,
+ prop_data,
+ prop_nelements );
+
+ XFree( prop_data );
+
+ /*
+ * Tickle PDM_MANAGER selection with PDM_START target
+ */
+ XConvertSelection( sel_display, sel_atom, atoms[XA_PDM_START],
+ atoms[XA_PDM_CLIENT_PROP], sel_window, CurrentTime );
+
+ /*
+ * Hang out waiting for a SelectionNotify. Dig out from
+ * event queue when it arrives.
+ */
+ dosnrec.requestor = sel_window;
+ dosnrec.selection = sel_atom;
+ dosnrec.target = atoms[XA_PDM_START];
+
+ XIfEvent( sel_display, &tevent, digOutSelectionNotify, (char *) &dosnrec );
+
+ /*
+ * See if selection was successful.
+ */
+ if ( tevent.xselection.property == None ) {
+ /*
+ * The selection failed.
+ */
+ sel_str = XGetAtomName( sel_display, sel_atom );
+ sprintf(cdata,
+ "XpNotifyPdm: Unable to make selection on %s", sel_str);
+ XFree(sel_str);
+
+ XDeleteProperty( sel_display, sel_window, atoms[XA_PDM_CLIENT_PROP] );
+ XDestroyWindow( sel_display, sel_window );
+ if ((sel_display != print_display) && (sel_display != video_display))
+ XCloseDisplay( sel_display );
+ return( _xpstrdup( cdata ) );
+ }
+
+ /*
+ * Read property content for status.
+ */
+ XGetWindowProperty( sel_display, sel_window,
+ atoms[XA_PDM_CLIENT_PROP],
+ 0, 100000, True, AnyPropertyType,
+ &ttype, &tformat, &nitems, &bytes_after,
+ &return_data );
+
+ /*
+ * So that the client won't see how XpNotifyPdm is implemented,
+ * run through the event queue, dig out, and destroy all
+ * PropertyNotify events related to this call.
+ */
+ dopnrec.window = sel_window;
+ dopnrec.atom = atoms[XA_PDM_CLIENT_PROP];
+ while ( XCheckIfEvent( sel_display, &tevent, digOutPropertyNotify,
+ (char *) &dopnrec ) );
+
+ XDestroyWindow( sel_display, sel_window );
+ if ((sel_display != print_display) && (sel_display != video_display))
+ XCloseDisplay( sel_display );
+
+ if ((ttype != XA_ATOM) && (tformat != 32) && (nitems != 1)) {
+ /*
+ * Unable to read SelectionNotify property.
+ */
+ sprintf(cdata,
+ "XpNotifyPdm: Unable to read SelectionNotify property" );
+ return( _xpstrdup( cdata ) );
+ }
+
+ tmpi = *((Atom *) return_data);
+ Xfree( return_data );
+
+ if ( tmpi == atoms[XA_PDM_START_OK] ) {
+ return( (char *) NULL );
+ }
+ else if ( tmpi == atoms[XA_PDM_START_VXAUTH] ) {
+ sprintf(cdata,
+ "XpNotifyPdm: PDM not authorized to connect to video display." );
+ return( _xpstrdup( cdata ) );
+ }
+ else if ( tmpi == atoms[XA_PDM_START_PXAUTH] ) {
+ sprintf(cdata,
+ "XpNotifyPdm: PDM not authorized to connect to print display." );
+ return( _xpstrdup( cdata ) );
+ }
+ else if ( tmpi == atoms[XA_PDM_START_ERROR] ) {
+ sprintf(cdata,
+ "XpNotifyPdm: PDM encountered an error. See PDM log file." );
+ return( _xpstrdup( cdata ) );
+ }
+ else {
+ sprintf(cdata,
+ "XpNotifyPdm: unknown PDM error." );
+ return( _xpstrdup( cdata ) );
+ }
+}
+
diff --git a/nx-X11/lib/Xp/XpPage.c b/nx-X11/lib/Xp/XpPage.c
new file mode 100644
index 000000000..886bc578a
--- /dev/null
+++ b/nx-X11/lib/Xp/XpPage.c
@@ -0,0 +1,160 @@
+/* $Xorg: XpPage.c,v 1.4 2001/03/06 13:59:02 pookie Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpPage.c,v 1.4 2001/12/19 21:28:44 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+
+
+typedef struct {
+ int event_base_return;
+ XPContext context;
+} _XpDiscardPageRec;
+
+static Bool _XpDiscardPage(Display *dpy, XEvent *event, XPointer arg)
+{
+ _XpDiscardPageRec *disrec = (_XpDiscardPageRec *) arg;
+
+ if (event->type != disrec->event_base_return + XPPrintNotify)
+ return False;
+
+ if (disrec->context != ((XPPrintEvent *) event)->context)
+ return False;
+
+ if (((XPPrintEvent *) event)->detail == XPEndPageNotify) {
+ return False;
+ }
+
+ return True;
+}
+
+
+void
+XpStartPage (
+ Display *dpy,
+ Window window
+)
+{
+ xPrintStartPageReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ XMapWindow(dpy, window);
+ if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
+ return; /* NoSuchExtension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintStartPage,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintStartPage;
+ req->window = window;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+
+void
+XpEndPage (
+ Display *dpy
+)
+{
+ xPrintEndPageReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
+ return; /* NoSuchExtension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintEndPage,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintEndPage;
+ req->cancel = False;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+
+void
+XpCancelPage (
+ Display *dpy,
+ Bool discard
+)
+{
+ xPrintEndPageReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ _XpDiscardPageRec disrec;
+ XEvent event;
+
+
+ if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
+ return; /* NoSuchExtension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintEndPage,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintEndPage;
+ req->cancel = True;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+
+ if (discard) {
+ /*
+ * get context and effectively do a sync of events.
+ */
+ disrec.event_base_return = info->codes->first_event;
+ disrec.context = XpGetContext(dpy);
+
+ /*
+ * discard page XPPrintNotify events.
+ */
+ while (XCheckIfEvent(dpy, &event, _XpDiscardPage, (XPointer) &disrec))
+ {
+ /*EMPTY*/
+ }
+ }
+}
+
diff --git a/nx-X11/lib/Xp/XpPageDim.c b/nx-X11/lib/Xp/XpPageDim.c
new file mode 100644
index 000000000..61ef28a41
--- /dev/null
+++ b/nx-X11/lib/Xp/XpPageDim.c
@@ -0,0 +1,89 @@
+/* $Xorg: XpPageDim.c,v 1.4 2000/08/17 19:46:07 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpPageDim.c,v 1.4 2001/01/17 19:43:02 dawes Exp $ */
+
+#define NEED_REPLIES
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+
+
+Status
+XpGetPageDimensions (
+ Display *dpy,
+ XPContext print_context,
+ unsigned short *width,
+ unsigned short *height,
+ XRectangle *reproducible_area
+)
+{
+ xPrintGetPageDimensionsReq *req;
+ xPrintGetPageDimensionsReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return (/* No such extension */ 0L );
+
+ LockDisplay (dpy);
+
+ GetReq(PrintGetPageDimensions,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintGetPageDimensions;
+ req->printContext = print_context;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(/* No such extension */ 0L);
+ }
+
+ *width = rep.width;
+ *height = rep.height;
+ reproducible_area-> x = rep.rx;
+ reproducible_area-> y = rep.ry;
+ reproducible_area-> width = rep.rwidth;
+ reproducible_area-> height = rep.rheight;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ( 1L );
+}
+
diff --git a/nx-X11/lib/Xp/XpPrinter.c b/nx-X11/lib/Xp/XpPrinter.c
new file mode 100644
index 000000000..7ed33b706
--- /dev/null
+++ b/nx-X11/lib/Xp/XpPrinter.c
@@ -0,0 +1,248 @@
+/* $Xorg: XpPrinter.c,v 1.4 2000/08/17 19:46:07 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpPrinter.c,v 1.8 2001/04/01 14:00:02 tsi Exp $ */
+
+#define NEED_REPLIES
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+
+#define _XpPadOut(len) (((len) + 3) & ~3)
+
+XPPrinterList
+XpGetPrinterList (
+ Display *dpy,
+ char *printer_name,
+ int *list_count /* return value */
+)
+{
+ xPrintGetPrinterListReq *req;
+ xPrintGetPrinterListReply rep;
+
+ int printer_name_len, locale_len;
+ char *locale;
+
+ /* For decoding the variable portion of Reply */
+ long dataLenVR;
+ CARD8 *dataVR; /* aka STRING8 */
+
+ XPPrinterList ptr_list;
+
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+ /* For converting root winID to corresponding ScreenPtr */
+ int i;
+
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return ( (XPPrinterList) NULL ); /* No such extension */
+
+ /*
+ * Fetch locale information. Note: XpGetLocaleNetString has
+ * a thread-safe mutex on _Xglobal_lock.
+ */
+ locale = XpGetLocaleNetString();
+
+ LockDisplay (dpy);
+
+ GetReq(PrintGetPrinterList,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintGetPrinterList;
+
+ /*
+ * Compute lengths of variable portions.
+ */
+ if ( printer_name == (char *) NULL )
+ req->printerNameLen = 0;
+ else if ( *printer_name == (char) NULL )
+ req->printerNameLen = 0;
+ else {
+ printer_name_len = strlen( printer_name );
+ req->length += _XpPadOut(printer_name_len) >> 2;
+ req->printerNameLen = (unsigned long) printer_name_len;
+ }
+
+ if ( locale == (char *) NULL )
+ req->localeLen = 0;
+ else if ( *locale == (char) NULL )
+ req->localeLen = 0;
+ else {
+ locale_len = strlen( locale );
+ req->length += _XpPadOut(locale_len) >> 2;
+ req->localeLen = (unsigned long) locale_len;
+ }
+
+ /*
+ * Attach variable data.
+ */
+ if (req->printerNameLen)
+ Data( dpy, (char *) printer_name, (long) req->printerNameLen );
+
+ if (req->localeLen)
+ Data( dpy, (char *) locale, (long) req->localeLen );
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ( (XPPrinterList) NULL ); /* error */
+ }
+
+ XFree(locale);
+
+ *list_count = rep.listCount;
+
+ if (*list_count) {
+ ptr_list = (XPPrinterList)
+ Xmalloc( (unsigned) (sizeof(XPPrinterRec) * (*list_count + 1)));
+
+ if (!ptr_list) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ( (XPPrinterList) NULL ); /* malloc error */
+ }
+
+ /*
+ * NULL last entry so XpFreePrinterList can work without a list_count
+ */
+ ptr_list[*list_count].name = (char *) NULL;
+ ptr_list[*list_count].desc = (char *) NULL;
+
+ for ( i = 0; i < *list_count; i++ ) {
+ /*
+ * Pull printer length and then name.
+ */
+ _XRead32 (dpy, &dataLenVR, (long) sizeof(CARD32) );
+
+ if (dataLenVR) {
+ dataVR = (CARD8 *) Xmalloc( (unsigned) dataLenVR + 1 );
+
+ if (!dataVR) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ( (XPPrinterList) NULL ); /* malloc error */
+ }
+
+ _XReadPad (dpy, (char *) dataVR, (long) dataLenVR);
+ dataVR[dataLenVR] = 0;
+ ptr_list[i].name = (char *) dataVR;
+ }
+ else {
+ ptr_list[i].name = (char *) NULL;
+ }
+
+ /*
+ * Pull localized description length and then description.
+ */
+ _XRead32 (dpy, &dataLenVR, (long) sizeof(CARD32) );
+
+ if (dataLenVR) {
+ dataVR = (CARD8 *) Xmalloc( (unsigned) dataLenVR + 1 );
+
+ if (!dataVR) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ( (XPPrinterList) NULL ); /* malloc error */
+ }
+
+ _XReadPad (dpy, (char *) dataVR, (long) dataLenVR);
+ dataVR[dataLenVR] = 0;
+ ptr_list[i].desc = (char *) dataVR;
+ }
+ else {
+ ptr_list[i].desc = (char *) NULL;
+ }
+ }
+ }
+ else {
+ ptr_list = (XPPrinterList) NULL;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return ( ptr_list );
+}
+
+
+void
+XpFreePrinterList (
+ XPPrinterList printer_list
+)
+{
+ int i;
+
+
+ if ( printer_list == NULL )
+ return;
+
+ i = 0;
+ while (printer_list[i].name != NULL) {
+ Xfree( (char *) printer_list[i].name );
+ Xfree( (char *) printer_list[i].desc );
+ i++;
+ }
+
+ Xfree( (char *) printer_list );
+}
+
+
+void
+XpRehashPrinterList (
+ Display *dpy
+)
+{
+ xPrintRehashPrinterListReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+
+ if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
+ return; /* NoSuchExtension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintRehashPrinterList,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintRehashPrinterList;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
diff --git a/nx-X11/lib/Xp/XpPutData.c b/nx-X11/lib/Xp/XpPutData.c
new file mode 100644
index 000000000..76ff635d3
--- /dev/null
+++ b/nx-X11/lib/Xp/XpPutData.c
@@ -0,0 +1,100 @@
+/* $Xorg: XpPutData.c,v 1.3 2000/08/17 19:46:07 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpPutData.c,v 1.3 2001/01/17 19:43:02 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+
+#define _XpPadOut(len) (((len) + 3) & ~3)
+
+void
+XpPutDocumentData (
+ Display *dpy,
+ Drawable drawable,
+ unsigned char *data,
+ int data_len,
+ char *doc_fmt,
+ char *options
+)
+{
+ xPrintPutDocumentDataReq *req;
+ long maxcando, varlen;
+ int doc_fmt_len, options_len;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+
+ if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
+ return; /* NoSuchExtension */
+
+ doc_fmt_len = strlen( doc_fmt );
+ options_len = strlen( options );
+
+ maxcando = XExtendedMaxRequestSize(dpy);
+ if (!maxcando)
+ maxcando = XMaxRequestSize(dpy);
+ varlen = (_XpPadOut(data_len) +
+ _XpPadOut(doc_fmt_len) + _XpPadOut(options_len)) >> 2;
+ if (maxcando < ((sz_xPrintPutDocumentDataReq >> 2) + varlen))
+ return;
+
+ LockDisplay (dpy);
+
+ GetReq(PrintPutDocumentData,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintPutDocumentData;
+ req->drawable = drawable;
+ req->len_data = data_len;
+ req->len_fmt = doc_fmt_len;
+ req->len_options = options_len;
+ SetReqLen(req, varlen, varlen);
+
+ /*
+ * Send strings, each with padding provided by Data()
+ */
+ Data( dpy, (char *) data, data_len );
+ Data( dpy, doc_fmt, doc_fmt_len );
+ Data( dpy, options, options_len );
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return; /* Success */
+}
+
diff --git a/nx-X11/lib/Xp/XpScreens.c b/nx-X11/lib/Xp/XpScreens.c
new file mode 100644
index 000000000..dd30ed329
--- /dev/null
+++ b/nx-X11/lib/Xp/XpScreens.c
@@ -0,0 +1,128 @@
+/* $Xorg: XpScreens.c,v 1.5 2000/08/17 19:46:08 cpqbld Exp $ */
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 1996 Hewlett-Packard Company
+ ** (c) Copyright 1996 International Business Machines Corp.
+ ** (c) Copyright 1996 Sun Microsystems, Inc.
+ ** (c) Copyright 1996 Novell, Inc.
+ ** (c) Copyright 1996 Digital Equipment Corp.
+ ** (c) Copyright 1996 Fujitsu Limited
+ ** (c) Copyright 1996 Hitachi, Ltd.
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpScreens.c,v 1.5 2001/04/01 14:00:02 tsi Exp $ */
+
+#define NEED_REPLIES
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/extensions/Printstr.h>
+#include <X11/Xlibint.h>
+#include "XpExtUtil.h"
+
+
+Screen **
+XpQueryScreens (
+ Display *dpy,
+ int *list_count /* return value */
+)
+{
+ xPrintQueryScreensReq *req;
+ xPrintQueryScreensReply rep;
+
+ /* For decoding the variable portion of Reply */
+ long rootWindow;
+
+ /* For converting root winID to corresponding ScreenPtr */
+ Screen **scr_list;
+ Screen *checkScr;
+ int i,j;
+
+ XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);
+
+
+ if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
+ return ( (Screen **) NULL ); /* No such extension */
+
+ LockDisplay (dpy);
+
+ GetReq(PrintQueryScreens,req);
+ req->reqType = info->codes->major_opcode;
+ req->printReqType = X_PrintQueryScreens;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ( (Screen **) NULL ); /* error */
+ }
+
+ *list_count = rep.listCount;
+
+ if (*list_count) {
+ scr_list = (Screen **)
+ Xmalloc( (unsigned) (sizeof(Screen *) * *list_count) );
+
+ if (!scr_list) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ( (Screen **) NULL ); /* malloc error */
+ }
+ i = 0;
+ while(i < *list_count){
+ /*
+ * Pull printer length and then name.
+ */
+ _XRead32 (dpy, &rootWindow, (long) sizeof(CARD32) );
+ scr_list[i] = NULL;
+ for ( j = 0; j < XScreenCount(dpy); j++ ) {
+ checkScr = XScreenOfDisplay(dpy, j);
+ if ( XRootWindowOfScreen(checkScr) == (Window) rootWindow ) {
+ scr_list[i] = checkScr;
+ break;
+ }
+ }
+ if(scr_list[i] == NULL)
+ (*list_count)--;
+ else
+ i++;
+ }
+ if(!(*list_count)) {
+ Xfree(scr_list);
+ scr_list = (Screen **) NULL;
+ }
+ }
+ else {
+ scr_list = (Screen **) NULL;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return ( scr_list );
+}
+
diff --git a/nx-X11/lib/Xpm/Imakefile b/nx-X11/lib/Xpm/Imakefile
new file mode 100644
index 000000000..dd98b2fb8
--- /dev/null
+++ b/nx-X11/lib/Xpm/Imakefile
@@ -0,0 +1,126 @@
+XCOMM $XFree86: xc/lib/Xpm/Imakefile,v 1.1 1999/01/11 14:40:02 dawes Exp $
+
+/* This is a simplified version of the standard Xpm Imakefile */
+
+#ifdef SunArchitecture
+#define DoNormalLib YES
+#else
+#define DoNormalLib NormalLibXpm
+#endif
+#define DoSharedLib SharedLibXpm
+#define DoExtraLib SharedLibXpm
+#define DoDebugLib DebugLibXpm
+#define DoProfileLib ProfileLibXpm
+#define HasSharedData NO
+#define LibName Xpm
+#define SoRev SOXPMREV
+#define IncSubdir X11
+
+#ifdef SharedXpmReqs
+REQUIREDLIBS = SharedXpmReqs
+#endif
+
+/*
+ * if your system doesn't provide strcasecmp add -DNEED_STRCASECMP
+ * if your system doesn't provide strdup add -DNEED_STRDUP
+ * if your system doesn't provide pipe add -DNO_ZPIPE
+ * if on your system sprintf doesn't return the number of bytes transmitted
+ * add -DVOID_SPRINTF
+ * if you want xpm to try name.xpm.Z and name.xpm.gz when asked to read
+ * name.xpm , add -DSTAT_ZFILE
+ */
+
+#if defined(LinuxArchitecture)
+ZFILEDEF = -DSTAT_ZFILE
+#endif
+#if defined(UltrixArchitecture) || \
+ (defined(MipsArchitecture) && !defined(SGIArchitecture))
+STRDUPDEF = -DNEED_STRDUP
+#endif
+
+#if !HasStrcasecmp
+STRCASECMPDEF = -DNEED_STRCASECMP
+#endif
+
+#if defined(SunArchitecture) && !defined(SVR4Architecture)
+SPRINTFDEF = -DVOID_SPRINTF
+#endif
+
+#if HasStrlcat
+STRLCATDEF = -DHAS_STRLCAT
+#endif
+
+#if HasSnprintf
+SNPRINTFDEF = -DHAS_SNPRINTF
+#else
+SNPRINTFDEF = -Dsnprintf=_XpmSnprintf
+SNPRINTFSRCS = snprintf.c
+SNPRINTFOBJS = snprintf.o
+#endif
+
+#if defined(Win32Architecture)
+ZPIPEDEF = -DNO_ZPIPE
+#endif
+
+DEFINES = $(STRDUPDEF) $(STRCASECMPDEF) $(SPRINTFDEF) $(STRLCATDEF) \
+ $(SNPRINTFDEF) $(ZPIPEDEF) $(ZFILEDEF)
+
+HEADERS = xpm.h
+
+ SRCS = data.c create.c misc.c rgb.c scan.c parse.c hashtab.c \
+ CrBufFrI.c CrDatFrP.c CrPFrBuf.c RdFToI.c WrFFrI.c \
+ CrBufFrP.c CrIFrBuf.c CrPFrDat.c RdFToP.c WrFFrP.c \
+ CrDatFrI.c CrIFrDat.c RdFToDat.c WrFFrDat.c \
+ Attrib.c CrIFrP.c CrPFrI.c Image.c Info.c RdFToBuf.c WrFFrBuf.c \
+ $(SNPRINTFSRCS)
+
+ OBJS = data.o create.o misc.o rgb.o scan.o parse.o hashtab.o \
+ CrBufFrI.o CrDatFrP.o CrPFrBuf.o RdFToI.o WrFFrI.o \
+ CrBufFrP.o CrIFrBuf.o CrPFrDat.o RdFToP.o WrFFrP.o \
+ CrDatFrI.o CrIFrDat.o RdFToDat.o WrFFrDat.o \
+ Attrib.o CrIFrP.o CrPFrI.o Image.o Info.o RdFToBuf.o WrFFrBuf.o \
+ $(SNPRINTFOBJS)
+
+ XPMDIR = $(TOP)/extras/Xpm
+ XPMLIBDIR = $(TOP)/extras/Xpm/lib
+
+ INCLUDES = -I$(XPMLIBDIR)
+ LINTLIBS = $(LINTXTOLL) $(LINTXLIB)
+
+#include <Library.tmpl>
+
+LinkSourceFile(data.c,$(XPMLIBDIR))
+LinkSourceFile(create.c,$(XPMLIBDIR))
+LinkSourceFile(misc.c,$(XPMLIBDIR))
+LinkSourceFile(rgb.c,$(XPMLIBDIR))
+LinkSourceFile(scan.c,$(XPMLIBDIR))
+LinkSourceFile(parse.c,$(XPMLIBDIR))
+LinkSourceFile(hashtab.c,$(XPMLIBDIR))
+LinkSourceFile(CrBufFrI.c,$(XPMLIBDIR))
+LinkSourceFile(CrDatFrP.c,$(XPMLIBDIR))
+LinkSourceFile(CrPFrBuf.c,$(XPMLIBDIR))
+LinkSourceFile(RdFToI.c,$(XPMLIBDIR))
+LinkSourceFile(WrFFrI.c,$(XPMLIBDIR))
+LinkSourceFile(CrBufFrP.c,$(XPMLIBDIR))
+LinkSourceFile(CrIFrBuf.c,$(XPMLIBDIR))
+LinkSourceFile(CrPFrDat.c,$(XPMLIBDIR))
+LinkSourceFile(RdFToP.c,$(XPMLIBDIR))
+LinkSourceFile(WrFFrP.c,$(XPMLIBDIR))
+LinkSourceFile(CrDatFrI.c,$(XPMLIBDIR))
+LinkSourceFile(CrIFrDat.c,$(XPMLIBDIR))
+LinkSourceFile(RdFToDat.c,$(XPMLIBDIR))
+LinkSourceFile(WrFFrDat.c,$(XPMLIBDIR))
+LinkSourceFile(Attrib.c,$(XPMLIBDIR))
+LinkSourceFile(CrIFrP.c,$(XPMLIBDIR))
+LinkSourceFile(CrPFrI.c,$(XPMLIBDIR))
+LinkSourceFile(Image.c,$(XPMLIBDIR))
+LinkSourceFile(Info.c,$(XPMLIBDIR))
+LinkSourceFile(RdFToBuf.c,$(XPMLIBDIR))
+LinkSourceFile(WrFFrBuf.c,$(XPMLIBDIR))
+LinkSourceFile(xpm.h,$(XPMLIBDIR))
+
+#if !HasSnprintf
+LinkSourceFile(snprintf.c,$(LIBSRC)/misc)
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/Xpm/Imakefile.NX.original b/nx-X11/lib/Xpm/Imakefile.NX.original
new file mode 100644
index 000000000..dd98b2fb8
--- /dev/null
+++ b/nx-X11/lib/Xpm/Imakefile.NX.original
@@ -0,0 +1,126 @@
+XCOMM $XFree86: xc/lib/Xpm/Imakefile,v 1.1 1999/01/11 14:40:02 dawes Exp $
+
+/* This is a simplified version of the standard Xpm Imakefile */
+
+#ifdef SunArchitecture
+#define DoNormalLib YES
+#else
+#define DoNormalLib NormalLibXpm
+#endif
+#define DoSharedLib SharedLibXpm
+#define DoExtraLib SharedLibXpm
+#define DoDebugLib DebugLibXpm
+#define DoProfileLib ProfileLibXpm
+#define HasSharedData NO
+#define LibName Xpm
+#define SoRev SOXPMREV
+#define IncSubdir X11
+
+#ifdef SharedXpmReqs
+REQUIREDLIBS = SharedXpmReqs
+#endif
+
+/*
+ * if your system doesn't provide strcasecmp add -DNEED_STRCASECMP
+ * if your system doesn't provide strdup add -DNEED_STRDUP
+ * if your system doesn't provide pipe add -DNO_ZPIPE
+ * if on your system sprintf doesn't return the number of bytes transmitted
+ * add -DVOID_SPRINTF
+ * if you want xpm to try name.xpm.Z and name.xpm.gz when asked to read
+ * name.xpm , add -DSTAT_ZFILE
+ */
+
+#if defined(LinuxArchitecture)
+ZFILEDEF = -DSTAT_ZFILE
+#endif
+#if defined(UltrixArchitecture) || \
+ (defined(MipsArchitecture) && !defined(SGIArchitecture))
+STRDUPDEF = -DNEED_STRDUP
+#endif
+
+#if !HasStrcasecmp
+STRCASECMPDEF = -DNEED_STRCASECMP
+#endif
+
+#if defined(SunArchitecture) && !defined(SVR4Architecture)
+SPRINTFDEF = -DVOID_SPRINTF
+#endif
+
+#if HasStrlcat
+STRLCATDEF = -DHAS_STRLCAT
+#endif
+
+#if HasSnprintf
+SNPRINTFDEF = -DHAS_SNPRINTF
+#else
+SNPRINTFDEF = -Dsnprintf=_XpmSnprintf
+SNPRINTFSRCS = snprintf.c
+SNPRINTFOBJS = snprintf.o
+#endif
+
+#if defined(Win32Architecture)
+ZPIPEDEF = -DNO_ZPIPE
+#endif
+
+DEFINES = $(STRDUPDEF) $(STRCASECMPDEF) $(SPRINTFDEF) $(STRLCATDEF) \
+ $(SNPRINTFDEF) $(ZPIPEDEF) $(ZFILEDEF)
+
+HEADERS = xpm.h
+
+ SRCS = data.c create.c misc.c rgb.c scan.c parse.c hashtab.c \
+ CrBufFrI.c CrDatFrP.c CrPFrBuf.c RdFToI.c WrFFrI.c \
+ CrBufFrP.c CrIFrBuf.c CrPFrDat.c RdFToP.c WrFFrP.c \
+ CrDatFrI.c CrIFrDat.c RdFToDat.c WrFFrDat.c \
+ Attrib.c CrIFrP.c CrPFrI.c Image.c Info.c RdFToBuf.c WrFFrBuf.c \
+ $(SNPRINTFSRCS)
+
+ OBJS = data.o create.o misc.o rgb.o scan.o parse.o hashtab.o \
+ CrBufFrI.o CrDatFrP.o CrPFrBuf.o RdFToI.o WrFFrI.o \
+ CrBufFrP.o CrIFrBuf.o CrPFrDat.o RdFToP.o WrFFrP.o \
+ CrDatFrI.o CrIFrDat.o RdFToDat.o WrFFrDat.o \
+ Attrib.o CrIFrP.o CrPFrI.o Image.o Info.o RdFToBuf.o WrFFrBuf.o \
+ $(SNPRINTFOBJS)
+
+ XPMDIR = $(TOP)/extras/Xpm
+ XPMLIBDIR = $(TOP)/extras/Xpm/lib
+
+ INCLUDES = -I$(XPMLIBDIR)
+ LINTLIBS = $(LINTXTOLL) $(LINTXLIB)
+
+#include <Library.tmpl>
+
+LinkSourceFile(data.c,$(XPMLIBDIR))
+LinkSourceFile(create.c,$(XPMLIBDIR))
+LinkSourceFile(misc.c,$(XPMLIBDIR))
+LinkSourceFile(rgb.c,$(XPMLIBDIR))
+LinkSourceFile(scan.c,$(XPMLIBDIR))
+LinkSourceFile(parse.c,$(XPMLIBDIR))
+LinkSourceFile(hashtab.c,$(XPMLIBDIR))
+LinkSourceFile(CrBufFrI.c,$(XPMLIBDIR))
+LinkSourceFile(CrDatFrP.c,$(XPMLIBDIR))
+LinkSourceFile(CrPFrBuf.c,$(XPMLIBDIR))
+LinkSourceFile(RdFToI.c,$(XPMLIBDIR))
+LinkSourceFile(WrFFrI.c,$(XPMLIBDIR))
+LinkSourceFile(CrBufFrP.c,$(XPMLIBDIR))
+LinkSourceFile(CrIFrBuf.c,$(XPMLIBDIR))
+LinkSourceFile(CrPFrDat.c,$(XPMLIBDIR))
+LinkSourceFile(RdFToP.c,$(XPMLIBDIR))
+LinkSourceFile(WrFFrP.c,$(XPMLIBDIR))
+LinkSourceFile(CrDatFrI.c,$(XPMLIBDIR))
+LinkSourceFile(CrIFrDat.c,$(XPMLIBDIR))
+LinkSourceFile(RdFToDat.c,$(XPMLIBDIR))
+LinkSourceFile(WrFFrDat.c,$(XPMLIBDIR))
+LinkSourceFile(Attrib.c,$(XPMLIBDIR))
+LinkSourceFile(CrIFrP.c,$(XPMLIBDIR))
+LinkSourceFile(CrPFrI.c,$(XPMLIBDIR))
+LinkSourceFile(Image.c,$(XPMLIBDIR))
+LinkSourceFile(Info.c,$(XPMLIBDIR))
+LinkSourceFile(RdFToBuf.c,$(XPMLIBDIR))
+LinkSourceFile(WrFFrBuf.c,$(XPMLIBDIR))
+LinkSourceFile(xpm.h,$(XPMLIBDIR))
+
+#if !HasSnprintf
+LinkSourceFile(snprintf.c,$(LIBSRC)/misc)
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/Xpm/Imakefile.X.original b/nx-X11/lib/Xpm/Imakefile.X.original
new file mode 100644
index 000000000..9899fe209
--- /dev/null
+++ b/nx-X11/lib/Xpm/Imakefile.X.original
@@ -0,0 +1,122 @@
+XCOMM $XFree86: xc/lib/Xpm/Imakefile,v 1.1 1999/01/11 14:40:02 dawes Exp $
+
+/* This is a simplified version of the standard Xpm Imakefile */
+
+#define DoNormalLib NormalLibXpm
+#define DoSharedLib SharedLibXpm
+#define DoExtraLib SharedLibXpm
+#define DoDebugLib DebugLibXpm
+#define DoProfileLib ProfileLibXpm
+#define HasSharedData NO
+#define LibName Xpm
+#define SoRev SOXPMREV
+#define IncSubdir X11
+
+#ifdef SharedXpmReqs
+REQUIREDLIBS = SharedXpmReqs
+#endif
+
+/*
+ * if your system doesn't provide strcasecmp add -DNEED_STRCASECMP
+ * if your system doesn't provide strdup add -DNEED_STRDUP
+ * if your system doesn't provide pipe add -DNO_ZPIPE
+ * if on your system sprintf doesn't return the number of bytes transmitted
+ * add -DVOID_SPRINTF
+ * if you want xpm to try name.xpm.Z and name.xpm.gz when asked to read
+ * name.xpm , add -DSTAT_ZFILE
+ */
+
+#if defined(LinuxArchitecture)
+ZFILEDEF = -DSTAT_ZFILE
+#endif
+#if defined(UltrixArchitecture) || \
+ (defined(MipsArchitecture) && !defined(SGIArchitecture))
+STRDUPDEF = -DNEED_STRDUP
+#endif
+
+#if !HasStrcasecmp
+STRCASECMPDEF = -DNEED_STRCASECMP
+#endif
+
+#if defined(SunArchitecture) && !defined(SVR4Architecture)
+SPRINTFDEF = -DVOID_SPRINTF
+#endif
+
+#if HasStrlcat
+STRLCATDEF = -DHAS_STRLCAT
+#endif
+
+#if HasSnprintf
+SNPRINTFDEF = -DHAS_SNPRINTF
+#else
+SNPRINTFDEF = -Dsnprintf=_XpmSnprintf
+SNPRINTFSRCS = snprintf.c
+SNPRINTFOBJS = snprintf.o
+#endif
+
+#if defined(Win32Architecture)
+ZPIPEDEF = -DNO_ZPIPE
+#endif
+
+DEFINES = $(STRDUPDEF) $(STRCASECMPDEF) $(SPRINTFDEF) $(STRLCATDEF) \
+ $(SNPRINTFDEF) $(ZPIPEDEF) $(ZFILEDEF)
+
+HEADERS = xpm.h
+
+ SRCS = data.c create.c misc.c rgb.c scan.c parse.c hashtab.c \
+ CrBufFrI.c CrDatFrP.c CrPFrBuf.c RdFToI.c WrFFrI.c \
+ CrBufFrP.c CrIFrBuf.c CrPFrDat.c RdFToP.c WrFFrP.c \
+ CrDatFrI.c CrIFrDat.c RdFToDat.c WrFFrDat.c \
+ Attrib.c CrIFrP.c CrPFrI.c Image.c Info.c RdFToBuf.c WrFFrBuf.c \
+ $(SNPRINTFSRCS)
+
+ OBJS = data.o create.o misc.o rgb.o scan.o parse.o hashtab.o \
+ CrBufFrI.o CrDatFrP.o CrPFrBuf.o RdFToI.o WrFFrI.o \
+ CrBufFrP.o CrIFrBuf.o CrPFrDat.o RdFToP.o WrFFrP.o \
+ CrDatFrI.o CrIFrDat.o RdFToDat.o WrFFrDat.o \
+ Attrib.o CrIFrP.o CrPFrI.o Image.o Info.o RdFToBuf.o WrFFrBuf.o \
+ $(SNPRINTFOBJS)
+
+ XPMDIR = $(TOP)/extras/Xpm
+ XPMLIBDIR = $(TOP)/extras/Xpm/lib
+
+ INCLUDES = -I$(XPMLIBDIR)
+ LINTLIBS = $(LINTXTOLL) $(LINTXLIB)
+
+#include <Library.tmpl>
+
+LinkSourceFile(data.c,$(XPMLIBDIR))
+LinkSourceFile(create.c,$(XPMLIBDIR))
+LinkSourceFile(misc.c,$(XPMLIBDIR))
+LinkSourceFile(rgb.c,$(XPMLIBDIR))
+LinkSourceFile(scan.c,$(XPMLIBDIR))
+LinkSourceFile(parse.c,$(XPMLIBDIR))
+LinkSourceFile(hashtab.c,$(XPMLIBDIR))
+LinkSourceFile(CrBufFrI.c,$(XPMLIBDIR))
+LinkSourceFile(CrDatFrP.c,$(XPMLIBDIR))
+LinkSourceFile(CrPFrBuf.c,$(XPMLIBDIR))
+LinkSourceFile(RdFToI.c,$(XPMLIBDIR))
+LinkSourceFile(WrFFrI.c,$(XPMLIBDIR))
+LinkSourceFile(CrBufFrP.c,$(XPMLIBDIR))
+LinkSourceFile(CrIFrBuf.c,$(XPMLIBDIR))
+LinkSourceFile(CrPFrDat.c,$(XPMLIBDIR))
+LinkSourceFile(RdFToP.c,$(XPMLIBDIR))
+LinkSourceFile(WrFFrP.c,$(XPMLIBDIR))
+LinkSourceFile(CrDatFrI.c,$(XPMLIBDIR))
+LinkSourceFile(CrIFrDat.c,$(XPMLIBDIR))
+LinkSourceFile(RdFToDat.c,$(XPMLIBDIR))
+LinkSourceFile(WrFFrDat.c,$(XPMLIBDIR))
+LinkSourceFile(Attrib.c,$(XPMLIBDIR))
+LinkSourceFile(CrIFrP.c,$(XPMLIBDIR))
+LinkSourceFile(CrPFrI.c,$(XPMLIBDIR))
+LinkSourceFile(Image.c,$(XPMLIBDIR))
+LinkSourceFile(Info.c,$(XPMLIBDIR))
+LinkSourceFile(RdFToBuf.c,$(XPMLIBDIR))
+LinkSourceFile(WrFFrBuf.c,$(XPMLIBDIR))
+LinkSourceFile(xpm.h,$(XPMLIBDIR))
+
+#if !HasSnprintf
+LinkSourceFile(snprintf.c,$(LIBSRC)/misc)
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/Xpm/Xpm-def.cpp b/nx-X11/lib/Xpm/Xpm-def.cpp
new file mode 100644
index 000000000..84cf843ed
--- /dev/null
+++ b/nx-X11/lib/Xpm/Xpm-def.cpp
@@ -0,0 +1,39 @@
+LIBRARY Xpm
+VERSION LIBRARY_VERSION
+EXPORTS
+ XpmAttributesSize
+ XpmCreateBufferFromImage
+ XpmCreateBufferFromPixmap
+ XpmCreateBufferFromXpmImage
+ XpmCreateDataFromImage
+ XpmCreateDataFromPixmap
+ XpmCreateDataFromXpmImage
+ XpmCreateImageFromBuffer
+ XpmCreateImageFromData
+ XpmCreateImageFromXpmImage
+ XpmCreatePixmapFromBuffer
+ XpmCreatePixmapFromData
+ XpmCreatePixmapFromXpmImage
+ XpmCreateXpmImageFromBuffer
+ XpmCreateXpmImageFromData
+ XpmCreateXpmImageFromImage
+ XpmCreateXpmImageFromPixmap
+ XpmFree
+ XpmFreeAttributes
+ XpmFreeExtensions
+ XpmFreeXpmImage
+ XpmFreeXpmInfo
+ XpmGetErrorString
+ XpmLibraryVersion
+ XpmReadFileToBuffer
+ XpmReadFileToData
+ XpmReadFileToImage
+ XpmReadFileToPixmap
+ XpmReadFileToXpmImage
+ XpmWriteFileFromBuffer
+ XpmWriteFileFromData
+ XpmWriteFileFromImage
+ XpmWriteFileFromPixmap
+ XpmWriteFileFromXpmImage
+
+/* $XFree86$ */
diff --git a/nx-X11/lib/XprintAppUtil/Imakefile b/nx-X11/lib/XprintAppUtil/Imakefile
new file mode 100644
index 000000000..4826ce8d7
--- /dev/null
+++ b/nx-X11/lib/XprintAppUtil/Imakefile
@@ -0,0 +1,21 @@
+#define DoNormalLib YES
+# XprintAppUtil is not a stable interface yet, therefore avoid shipping it
+# as shared lib for now
+#define DoSharedLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#define HasSharedData NO
+#define LibName XprintAppUtil
+#define SoRev SOZLIBREV
+#define IncSubdir X11
+#define IncSubSubdir XprintAppUtil
+
+
+HEADERS = xpapputil.h
+
+SRCS = xpapputil.c
+OBJS = xpapputil.o
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/XprintAppUtil/xpapputil.c b/nx-X11/lib/XprintAppUtil/xpapputil.c
new file mode 100644
index 000000000..aaf918c4e
--- /dev/null
+++ b/nx-X11/lib/XprintAppUtil/xpapputil.c
@@ -0,0 +1,550 @@
+
+/*
+ * $Xorg:xpapputil.c,v 1.1 2002/06/10 02:54:18 gisburn Exp $
+ *
+ * xpapputil - Application level utility library for Xprint
+ *
+ *
+Copyright 2002-2004 Roland Mainz <roland.mainz@nrubsig.org>
+
+All Rights Reserved.
+
+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: Roland Mainz <roland.mainz@nrubsig.org>
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <X11/XprintAppUtil/xpapputil.h>
+
+XpauContext *XpauGetContext( const char *printername )
+{
+ Display *pdpy;
+ XPContext pcontext;
+ XpauContext *context;
+
+ if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 )
+ return NULL;
+
+ if( (context = (XpauContext *)malloc(sizeof(XpauContext))) )
+ {
+ memset(context, 0, sizeof(XpauContext));
+
+ context->pdpy = pdpy;
+ context->pcontext = pcontext;
+
+ if( XpQueryExtension(pdpy, &context->xp_event_base, &context->xp_error_base) == False )
+ {
+ fprintf(stderr, "XpauGetContext: XpQueryExtension() failed.\n");
+ XpauReleaseContext(context);
+ return NULL;
+ }
+
+ /* It may be better to fetch all this info on demand... */
+ context->medium_list = XpuGetMediumSourceSizeList(pdpy, pcontext, &context->medium_num_list_entries);
+ context->resolution_list = XpuGetResolutionList(pdpy, pcontext, &context->resolution_num_list_entries);
+ context->orientation_list = XpuGetOrientationList(pdpy, pcontext, &context->orientation_num_list_entries);
+ context->plex_list = XpuGetPlexList(pdpy, pcontext, &context->plex_num_list_entries);
+ context->supported_job_attributes = XpuGetSupportedJobAttributes(pdpy, pcontext);
+ context->supported_doc_attributes = XpuGetSupportedDocAttributes(pdpy, pcontext);
+ context->supported_page_attributes = XpuGetSupportedPageAttributes(pdpy, pcontext);
+
+ return context;
+ }
+
+ XpuClosePrinterDisplay(pdpy, pcontext);
+
+ return NULL;
+}
+
+void XpauReleaseContext( XpauContext *context )
+{
+ if( context )
+ {
+ if( context->medium_list )
+ XpuFreeMediumSourceSizeList(context->medium_list);
+
+ if( context->resolution_list )
+ XpuFreeResolutionList(context->resolution_list);
+
+ if( context->orientation_list )
+ XpuFreeOrientationList(context->orientation_list);
+
+ if( context->plex_list )
+ XpuFreePlexList(context->plex_list);
+
+ XpuClosePrinterDisplay(context->pdpy, context->pcontext);
+
+ free(context);
+ }
+}
+
+static
+XpAuErrorValue XpauParseArg( const char *arg_name, const char *arg_value, XpauContext *context,
+ XpauFlags *jobvaluemask, XpauJobValues *jobvalues,
+ XpauFlags *docvaluemask, XpauDocValues *docvalues,
+ char **jobfilename )
+{
+ XPAU_DEBUG(printf("XpauParseArg: name='%s', value='%s'\n", arg_name, arg_value));
+
+ if( !strcasecmp(arg_name, "file") ||
+ !strcasecmp(arg_name, "tofile") )
+ {
+ if( *jobfilename )
+ free((char *)*jobfilename);
+
+ *jobfilename = strdup(arg_value);
+ if( !*jobfilename )
+ return XpAuError_error_no_memory;
+
+ return XpAuError_success;
+ }
+ else if( !strcasecmp(arg_name, "medium") ||
+ !strcasecmp(arg_name, "papersize"))
+ {
+ if( !(context->medium_list && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM)) )
+ return XpAuError_unsupported_medium;
+
+ /* XXX: What about the tray name ? */
+ docvalues->medium = XpuFindMediumSourceSizeByName(context->medium_list,
+ context->medium_num_list_entries,
+ NULL, arg_value);
+
+ if( !docvalues->medium )
+ return XpAuError_unsupported_medium;
+
+ *docvaluemask |= XpauVMedium;
+ return XpAuError_success;
+ }
+ else if( !strcasecmp(arg_name, "resolution") )
+ {
+ if( !(context->resolution_list && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION)) )
+ return XpAuError_unsupported_resolution;
+
+ docvalues->resolution = XpuFindResolutionByName(context->resolution_list,
+ context->resolution_num_list_entries,
+ arg_value);
+
+ if( !docvalues->resolution )
+ return XpAuError_unsupported_resolution;
+
+ *docvaluemask |= XpauVResolution;
+ return XpAuError_success;
+ }
+ else if( !strcasecmp(arg_name, "orientation") )
+ {
+ if( !(context->orientation_list && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION)) )
+ return XpAuError_unsupported_orientation;
+
+ docvalues->orientation = XpuFindOrientationByName(context->orientation_list,
+ context->orientation_num_list_entries,
+ arg_value);
+
+ if( !docvalues->orientation )
+ return XpAuError_unsupported_orientation;
+
+ *docvaluemask |= XpauVOrientation;
+ return XpAuError_success;
+ }
+ else if( !strcasecmp(arg_name, "plex") )
+ {
+ if( !(context->plex_list && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_PLEX)) )
+ return XpAuError_unsupported_plex;
+
+ docvalues->plex = XpuFindPlexByName(context->plex_list,
+ context->plex_num_list_entries,
+ arg_value);
+
+ if( !docvalues->plex )
+ return XpAuError_unsupported_plex;
+
+ *docvaluemask |= XpauVPlex;
+ return XpAuError_success;
+ }
+ else if( !strcasecmp(arg_name, "copies") )
+ {
+ if( !(context->supported_job_attributes & XPUATTRIBUTESUPPORTED_COPY_COUNT) )
+ return XpAuError_unsupported_copy_count;
+
+ jobvalues->copies = atoi(arg_value);
+ if( jobvalues->copies <= 1 )
+ return XpAuError_unsupported_copy_count;
+
+ *jobvaluemask |= XpauVCopies;
+ return XpAuError_success;
+ }
+ else if( !strcasecmp(arg_name, "title") )
+ {
+ if( !(context->supported_job_attributes & XPUATTRIBUTESUPPORTED_JOB_NAME) )
+ return XpAuError_unsupported_job_name;
+
+ if( jobvalues->title )
+ free((char *)jobvalues->title);
+
+ jobvalues->title = strdup(arg_value);
+ if( !jobvalues->title )
+ return XpAuError_error_no_memory;
+
+ *jobvaluemask |= XpauVTitle;
+ return XpAuError_success;
+ }
+
+ return XpAuError_unknown_argument;
+}
+
+XpAuErrorValue XpauParseArgs( XpauContext *context,
+ XpauFlags *jobvaluemask, XpauJobValues *jobvalues,
+ XpauFlags *docvaluemask, XpauDocValues *docvalues,
+ char **jobfilename,
+ const char *argument_string )
+{
+ char *args_string,
+ *arg_name,
+ *arg_value,
+ *start,
+ *s;
+ int result;
+
+ if( !argument_string )
+ return XpAuError_success;
+
+ args_string = strdup(argument_string); /* Create copy of read-only string that we can write into it... */
+ if( !args_string )
+ return XpAuError_error_no_memory;
+
+ s = args_string;
+
+ while( s != NULL )
+ {
+ /* Fetch argument name */
+ start = s;
+ while( *s != '\0' && *s != '=' )
+ s++;
+ if( *s == '\0' )
+ {
+ free(args_string);
+ return XpAuError_unexpected_eos;
+ }
+ *s++ = '\0';
+ arg_name = start;
+
+ /* Fetch argument value */
+ start = s;
+ while( *s != '\0' && *s != ',' )
+ s++;
+ if( *s == '\0' )
+ s = NULL;
+ else
+ *s++ = '\0';
+ arg_value = start;
+
+ result = XpauParseArg(arg_name, arg_value, context, jobvaluemask, jobvalues, docvaluemask, docvalues, jobfilename);
+ if( result != XpAuError_success )
+ {
+ free(args_string);
+ return result;
+ }
+ }
+
+ free(args_string);
+ return XpAuError_success;
+}
+
+XpAuErrorValue
+XpauSetJobValues( XpauContext *context, XpauFlags valuemask, XpauJobValues *jobvalues )
+{
+ /* "Dry-run" tests */
+
+ /* We can't change job attributes while we are at the "job level"
+ * (e.g. after |XpStartJob()| and before |XpEndJob()| */
+ XPAU_RETURN_IF_FAIL(context->inJob == False, XpAuError_inside_job);
+
+ if( valuemask & XpauVTitle )
+ XPAU_RETURN_IF_FAIL(jobvalues->title && (context->supported_job_attributes & XPUATTRIBUTESUPPORTED_JOB_NAME), XpAuError_unsupported_job_name);
+
+ if( valuemask & XpauVCopies )
+ XPAU_RETURN_IF_FAIL((jobvalues->copies > 0) && (context->supported_job_attributes & XPUATTRIBUTESUPPORTED_COPY_COUNT), XpAuError_unsupported_copy_count);
+
+ /* Set values */
+
+ if( valuemask & XpauVTitle )
+ XpuSetJobTitle(context->pdpy, context->pcontext, jobvalues->title);
+
+#ifdef NOTNOW
+ if( valuemask & XpauVResolution )
+ XpuJobDocumentCopies(context->pdpy, context->pcontext, jobvalues->copies);
+#endif /* NOTNOW */
+
+ return XpAuError_success;
+}
+
+XpAuErrorValue
+XpauSetDocValues( XpauContext *context, XpauFlags valuemask, XpauDocValues *docvalues )
+{
+ /* "Dry-run" tests */
+
+ /* We can't change document attributes while we are at the "document level"
+ * (e.g. after |XpStartDoc()| and before |XpEndDoc()| */
+ XPAU_RETURN_IF_FAIL(context->inDocument == False, XpAuError_inside_document);
+
+ if( valuemask & XpauVMedium )
+ XPAU_RETURN_IF_FAIL(docvalues->medium && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM), XpAuError_unsupported_medium);
+
+ if( valuemask & XpauVOrientation )
+ XPAU_RETURN_IF_FAIL(docvalues->orientation && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION), XpAuError_unsupported_orientation);
+
+ if( valuemask & XpauVPlex )
+ XPAU_RETURN_IF_FAIL(docvalues->plex && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_PLEX), XpAuError_unsupported_plex);
+
+ if( valuemask & XpauVResolution )
+ XPAU_RETURN_IF_FAIL(docvalues->resolution && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION), XpAuError_unsupported_resolution);
+
+ if( valuemask & XpauVCopies )
+ XPAU_RETURN_IF_FAIL((docvalues->copies > 0) && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_COPY_COUNT), XpAuError_unsupported_copy_count);
+
+ /* Set values */
+
+ if( valuemask & XpauVMedium )
+ XpuSetDocMediumSourceSize(context->pdpy, context->pcontext, docvalues->medium);
+
+ if( valuemask & XpauVOrientation )
+ XpuSetDocOrientation(context->pdpy, context->pcontext, docvalues->orientation);
+
+ if( valuemask & XpauVPlex )
+ XpuSetDocPlex(context->pdpy, context->pcontext, docvalues->plex);
+
+ if( valuemask & XpauVResolution )
+ XpuSetDocResolution(context->pdpy, context->pcontext, docvalues->resolution);
+
+ if( valuemask & XpauVCopies )
+ XpuSetDocumentCopies(context->pdpy, context->pcontext, docvalues->copies);
+
+ return XpAuError_success;
+}
+
+XpAuErrorValue
+XpauSetPageValues( XpauContext *context, XpauFlags valuemask, XpauPageValues *pagevalues )
+{
+ /* "Dry-run" tests */
+
+ /* We can't change page attributes while we are at the "page level"
+ * (e.g. after |XpStartPage()| and before |XpEndPage()| */
+ XPAU_RETURN_IF_FAIL(context->inPage == False, XpAuError_inside_page);
+
+ if( valuemask & XpauVMedium )
+ XPAU_RETURN_IF_FAIL(pagevalues->medium && (context->supported_page_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM), XpAuError_unsupported_medium);
+
+ if( valuemask & XpauVOrientation )
+ XPAU_RETURN_IF_FAIL(pagevalues->orientation && (context->supported_page_attributes & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION), XpAuError_unsupported_orientation);
+
+ if( valuemask & XpauVPlex )
+ XPAU_RETURN_IF_FAIL(pagevalues->plex && (context->supported_page_attributes & XPUATTRIBUTESUPPORTED_PLEX), XpAuError_unsupported_plex);
+
+ if( valuemask & XpauVResolution )
+ XPAU_RETURN_IF_FAIL(pagevalues->resolution && (context->supported_page_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION), XpAuError_unsupported_resolution);
+
+ /* Set values */
+
+ if( valuemask & XpauVMedium )
+ XpuSetPageMediumSourceSize(context->pdpy, context->pcontext, pagevalues->medium);
+
+ if( valuemask & XpauVOrientation )
+ XpuSetPageOrientation(context->pdpy, context->pcontext, pagevalues->orientation);
+
+ if( valuemask & XpauVPlex )
+ XpuSetPagePlex(context->pdpy, context->pcontext, pagevalues->plex);
+
+ if( valuemask & XpauVResolution )
+ XpuSetPageResolution(context->pdpy, context->pcontext, pagevalues->resolution);
+
+ return XpAuError_success;
+}
+
+XpAuErrorValue XpauStartJob( XpauContext *context, const char *printerfile )
+{
+ void *handle;
+ XpAuErrorValue result = XpAuError_unspecified_error;
+
+ XPAU_RETURN_IF_FAIL(context->inJob == False, XpAuError_inside_job);
+
+ /* Set print context
+ * Note that this modifies the available fonts, including build-in printer prints.
+ * All XListFonts()/XLoadFont() stuff should be done _after_ setting the print
+ * context to obtain the proper fonts.
+ */
+ XpSetContext(context->pdpy, context->pcontext);
+
+ if( printerfile )
+ {
+ context->print_to_filehandle = XpuStartJobToFile(context->pdpy, context->pcontext, printerfile);
+ if( context->print_to_filehandle )
+ {
+ result = XpAuError_success;
+ }
+ else
+ {
+ result = XpAuError_errno;
+ }
+ }
+ else
+ {
+ XpuStartJobToSpooler(context->pdpy);
+ result = XpAuError_success;
+ }
+
+ /* Get default printer resolution */
+ if( XpuGetResolution(context->pdpy, context->pcontext, &context->document_dpi_x, &context->document_dpi_y) != 1 )
+ {
+ result = XpAuError_no_dpi_set;
+ }
+
+ if( result == XpAuError_success )
+ {
+ context->inJob = True;
+ context->pscreen = XpGetScreenOfContext(context->pdpy, context->pcontext);
+ context->pscreennumber = XScreenNumberOfScreen(context->pscreen);
+ }
+
+ return result;
+}
+
+XpAuErrorValue XpauEndJob( XpauContext *context )
+{
+ XPAU_RETURN_IF_FAIL(context->inJob, XpAuError_not_inside_job);
+
+ /* End the print job - the final results are sent by the X print
+ * server to the spooler sub system.
+ */
+ XpEndJob(context->pdpy);
+
+ /* Be sure to process the X traffic (remember that we registered a
+ * "consumer" hook via Xlib internal magic when we print to a
+ * file)
+ * FixMe: |XpuWaitForPrintFileChild()| should call XFlush() instead!
+ */
+ XFlush(context->pdpy);
+
+ context->inJob = False;
+ context->pscreen = NULL;
+ context->pscreennumber = -1;
+ context->document_dpi_x = 0L;
+ context->document_dpi_y = 0L;
+
+ if( context->print_to_filehandle )
+ {
+ if( XpuWaitForPrintFileChild(context->print_to_filehandle) != XPGetDocFinished )
+ {
+ return XpAuError_errno;
+ }
+ }
+
+ return XpAuError_success;
+}
+
+XpAuErrorValue XpauStartDocument( XpauContext *context, XPDocumentType type )
+{
+ XPAU_RETURN_IF_FAIL(context->inJob == True, XpAuError_not_inside_job);
+ XPAU_RETURN_IF_FAIL(context->inDocument == False, XpAuError_inside_document);
+ XPAU_RETURN_IF_FAIL(context->inPage == False, XpAuError_inside_page);
+
+ XpStartDoc(context->pdpy, type);
+ context->inDocument = True;
+
+ return XpAuError_success;
+}
+
+XpAuErrorValue XpauEndDocument( XpauContext *context )
+{
+ XPAU_RETURN_IF_FAIL(context->inDocument, XpAuError_not_inside_document);
+
+ XpEndDoc(context->pdpy);
+ context->inDocument = False;
+
+ return XpAuError_success;
+}
+
+XpAuErrorValue XpauStartPage( XpauContext *context, Window pwin )
+{
+ XPAU_RETURN_IF_FAIL(context->inPage == False, XpAuError_inside_page);
+ XPAU_RETURN_IF_FAIL(context->inJob == True, XpAuError_not_inside_job);
+
+ XpStartPage(context->pdpy, pwin);
+
+ /* |XpStartPage()| will generate a "synthetic" |XpStartDoc()|
+ * if it was not called yet */
+ if( context->inDocument == False )
+ {
+ context->inDocument = True;
+ }
+
+ context->inPage = True;
+
+ return XpAuError_success;
+}
+
+XpAuErrorValue XpauEndPage( XpauContext *context )
+{
+ XPAU_RETURN_IF_FAIL(context->inPage, XpAuError_not_inside_page);
+
+ XpEndPage(context->pdpy);
+ context->inPage = False;
+
+ return XpAuError_success;
+}
+
+void XpauWaitForPrintNotify(XpauContext *context, int type)
+{
+ XpuWaitForPrintNotify(context->pdpy, context->xp_event_base, type);
+}
+
+
+const char *XpAuErrorValueToString(XpAuErrorValue value)
+{
+ char *msg;
+
+ switch(value)
+ {
+ case XpAuError_success: msg = "success" ; break;
+ case XpAuError_errno: msg = strerror(errno) ; break;
+ case XpAuError_error_no_memory: msg = "out of memory" ; break;
+ case XpAuError_unexpected_eos: msg = "unexpected end of string" ; break;
+ case XpAuError_unknown_argument: msg = "unknown argument" ; break;
+ case XpAuError_unsupported_medium: msg = "unsupported print medium" ; break;
+ case XpAuError_unsupported_resolution: msg = "unsupported print resolution" ; break;
+ case XpAuError_unsupported_orientation: msg = "unsupported orientation" ; break;
+ case XpAuError_unsupported_plex: msg = "unsupported plex" ; break;
+ case XpAuError_unsupported_copy_count: msg = "unsupported copy count" ; break;
+ case XpAuError_unsupported_job_name: msg = "unsupported job name" ; break;
+ case XpAuError_no_dpi_set: msg = "no DPI set (or no default DPI provided by server)" ; break;
+ case XpAuError_not_inside_job: msg = "state error: not inside job" ; break;
+ case XpAuError_not_inside_document: msg = "state error: not inside document" ; break;
+ case XpAuError_not_inside_page: msg = "stage error: not inside page" ; break;
+ case XpAuError_inside_job: msg = "state error: (already) inside job" ; break;
+ case XpAuError_inside_document: msg = "state error: (already) inside document" ; break;
+ case XpAuError_inside_page: msg = "stage error: (already) inside page" ; break;
+ case XpAuError_unspecified_error: msg = "unspecified error" ; break;
+ default:
+ msg = "unknown error" ;
+ break;
+ }
+
+ return msg;
+}
+
+
+
+
diff --git a/nx-X11/lib/XprintAppUtil/xpapputil.h b/nx-X11/lib/XprintAppUtil/xpapputil.h
new file mode 100644
index 000000000..d7159bb14
--- /dev/null
+++ b/nx-X11/lib/XprintAppUtil/xpapputil.h
@@ -0,0 +1,175 @@
+
+/*
+ * $Xorg:xpapputil.h,v 1.1 2002/06/10 02:54:18 gisburn Exp $
+ *
+ * xpapputil - Application level utility library for Xprint
+ *
+ *
+Copyright 2002-2004 Roland Mainz <roland.mainz@nrubsig.org>
+
+All Rights Reserved.
+
+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: Roland Mainz <roland.mainz@nrubsig.org>
+ */
+
+#ifndef XPAPPUTILS_H
+#define XPAPPUTILS_H 1
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/XprintUtil/xprintutil.h>
+
+#ifdef DEBUG
+#define XPAU_RETURN_IF_FAIL(expr, return_code) \
+ if( !(expr) ) { \
+ printf("XPAU_RETURN_IF_FAIL(file %s, line %d): " #expr ", returning " #return_code "\n", __FILE__, __LINE__); \
+ return (return_code); \
+ }
+
+#define XPAU_DEBUG(x) x
+
+#else
+
+#define XPAU_RETURN_IF_FAIL(expr, return_code) \
+ if( !(expr) ) { \
+ return (return_code); \
+ }
+
+#define XPAU_DEBUG(x)
+#endif /* DEBUG */
+
+/*
+ * Struct for XpauGetContext(), XpauReleaseContext()
+ *
+ */
+typedef struct
+{
+ Display *pdpy;
+ XPContext pcontext;
+ int xp_event_base,
+ xp_error_base;
+
+ Bool inJob;
+ Bool inDocument;
+ Bool inPage;
+
+ void *print_to_filehandle;
+ Screen *pscreen;
+ int pscreennumber;
+ long document_dpi_x,
+ document_dpi_y;
+
+ XpuSupportedFlags supported_job_attributes;
+ XpuSupportedFlags supported_doc_attributes;
+ XpuSupportedFlags supported_page_attributes;
+
+ XpuMediumSourceSizeList medium_list;
+ int medium_num_list_entries;
+ XpuResolutionList resolution_list;
+ int resolution_num_list_entries;
+ XpuOrientationList orientation_list;
+ int orientation_num_list_entries;
+ XpuPlexList plex_list;
+ int plex_num_list_entries;
+} XpauContext;
+
+
+#define XpauVFilename (1L<<0)
+#define XpauVMedium (1L<<1)
+#define XpauVResolution (1L<<2)
+#define XpauVOrientation (1L<<3)
+#define XpauVPlex (1L<<4)
+#define XpauVCopies (1L<<5)
+#define XpauVTitle (1L<<6)
+#define XpauVAll (XpauVFilename | \
+ XpauVMedium | \
+ XpauVResolution | \
+ XpauVOrientation | \
+ XpauVPlex | \
+ XpauVCopies | \
+ XpauVTitle)
+
+typedef unsigned long XpauFlags;
+
+typedef struct
+{
+ const char *title;
+ long copies;
+} XpauJobValues;
+
+typedef struct
+{
+ XpuMediumSourceSizeRec *medium;
+ XpuResolutionRec *resolution;
+ XpuOrientationRec *orientation;
+ XpuPlexRec *plex;
+ long copies;
+} XpauDocValues;
+
+typedef struct
+{
+ XpuMediumSourceSizeRec *medium;
+ XpuResolutionRec *resolution;
+ XpuOrientationRec *orientation;
+ XpuPlexRec *plex;
+} XpauPageValues;
+
+typedef enum {
+ XpAuError_success = 0,
+ XpAuError_unspecified_error,
+ XpAuError_errno, /* check |errno| for error */
+ XpAuError_error_no_memory,
+ XpAuError_unexpected_eos,
+ XpAuError_unknown_argument,
+ XpAuError_unsupported_medium,
+ XpAuError_unsupported_resolution,
+ XpAuError_unsupported_orientation,
+ XpAuError_unsupported_plex,
+ XpAuError_unsupported_copy_count,
+ XpAuError_unsupported_job_name,
+ XpAuError_no_dpi_set,
+ XpAuError_not_inside_job,
+ XpAuError_not_inside_document,
+ XpAuError_not_inside_page,
+ XpAuError_inside_job,
+ XpAuError_inside_document,
+ XpAuError_inside_page
+} XpAuErrorValue;
+
+/* Prototypes */
+XpauContext * XpauGetContext( const char *printername );
+void XpauReleaseContext( XpauContext *context );
+XpAuErrorValue XpauParseArgs( XpauContext *context,
+ XpauFlags *jobvaluemask, XpauJobValues *jobvalues,
+ XpauFlags *docvaluemask, XpauDocValues *docvalues,
+ char **jobfilename,
+ const char *argument_string );
+XpAuErrorValue XpauSetJobValues( XpauContext *context, XpauFlags valuemask, XpauJobValues *Xpaujobvalues );
+XpAuErrorValue XpauSetDocValues( XpauContext *context, XpauFlags valuemask, XpauDocValues *Xpaudocvalues );
+XpAuErrorValue XpauSetPageValues( XpauContext *context, XpauFlags valuemask, XpauPageValues *Xpaupagevalues );
+XpAuErrorValue XpauStartJob( XpauContext *context, const char *printerfile );
+XpAuErrorValue XpauEndJob( XpauContext *context );
+XpAuErrorValue XpauStartDocument( XpauContext *context, XPDocumentType type );
+XpAuErrorValue XpauEndDocument( XpauContext *context );
+XpAuErrorValue XpauStartPage( XpauContext *context, Window pwin );
+XpAuErrorValue XpauEndPage( XpauContext *context );
+void XpauWaitForPrintNotify(XpauContext *context, int type);
+const char *XpAuErrorValueToString(XpAuErrorValue value);
+#endif /* !XPAPPUTILS_H */
+
+
diff --git a/nx-X11/lib/XprintUtil/Imakefile b/nx-X11/lib/XprintUtil/Imakefile
new file mode 100644
index 000000000..dfbeae63a
--- /dev/null
+++ b/nx-X11/lib/XprintUtil/Imakefile
@@ -0,0 +1,21 @@
+#define DoNormalLib YES
+# XprintUtil is not a stable interface yet, therefore avoid shipping it
+# as shared lib for now
+#define DoSharedLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#define HasSharedData NO
+#define LibName XprintUtil
+#define SoRev SOZLIBREV
+#define IncSubdir X11
+#define IncSubSubdir XprintUtil
+
+
+HEADERS = xprintutil.h
+
+SRCS = xprintutil.c xprintutil_printtofile.c
+OBJS = xprintutil.o xprintutil_printtofile.o
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/XprintUtil/xprintutil.c b/nx-X11/lib/XprintUtil/xprintutil.c
new file mode 100644
index 000000000..58fe1386b
--- /dev/null
+++ b/nx-X11/lib/XprintUtil/xprintutil.c
@@ -0,0 +1,2111 @@
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 2001-2004 Roland Mainz <roland.mainz@nrubsig.org>
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+
+#include "xprintutil.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <limits.h>
+#include <errno.h>
+#include <locale.h>
+
+#ifdef XPU_USE_NSPR
+#include "plstr.h"
+#undef strtok_r
+#define strtok_r(s1, s2, x) PL_strtok_r((s1), (s2), (x))
+#endif /* XPU_USE_NSPR */
+
+/* List of tokens which can be used to separate entries in the
+ * $XPSERVERLIST env var */
+static const char XPServerListSeparators[] = " \t\v\n\r\f";
+
+/* conformace only; X11 API does (currrently) not make use of |const|.
+ * If Xlib API gets fixed these macros can be turned into empty
+ * placeholders... (|#define MAKE_STRING_WRITABLE(x)|) :-)
+ */
+#define MAKE_STRING_WRITABLE(str) (((str)?((str) = strdup(str)):0))
+#define FREE_WRITABLE_STRING(str) free((void *)(str))
+#define STRING_AS_WRITABLE(str) ((char *)(str))
+
+/* Local prototypes */
+static const char *XpuGetDefaultXpPrintername(void);
+static const char *XpuGetXpServerList( void );
+static const char *XpuEnumerateXpAttributeValue( const char *value, void **vcptr );
+static const char *XpuGetCurrentAttributeGroup( void **vcptr );
+static void XpuDisposeEnumerateXpAttributeValue( void **vc );
+static Bool XpuEnumerateMediumSourceSizes( Display *pdpy, XPContext pcontext,
+ const char **tray_name,
+ const char **medium_name, int *mbool,
+ float *ma1, float *ma2, float *ma3, float *ma4,
+ void **vcptr );
+static void XpuDisposeEnumerateMediumSourceSizes( void **vc );
+
+/*
+** XprintUtil functions start with Xpu
+**
+*/
+
+int XpuCheckExtension( Display *pdpy )
+{
+ char *display = XDisplayString(pdpy);
+ short major = 0,
+ minor = 0;
+
+ if( XpQueryVersion(pdpy, &major, &minor) != 0 )
+ {
+ XPU_DEBUG_ONLY(printf("XpuCheckExtension: XpQueryVersion '%s' %d %d\n", XPU_NULLXSTR(display), (int)major, (int)minor));
+ return(1);
+ }
+ else
+ {
+ XPU_DEBUG_ONLY(printf("XpuCheckExtension: XpQueryVersion '%s' returned 0(=Xprint not supported)\n", XPU_NULLXSTR(display)));
+ }
+
+ return(0);
+}
+
+/* Get the default printer name from the XPRINTER env var.
+ * If XPRINTER env var is not present looks for PDPRINTER, LPDEST, and
+ * PRINTER (in that order)
+ * See CDE's DtPrintSetupBox(3) manual page, too...
+ */
+static
+const char *XpuGetDefaultXpPrintername(void)
+{
+ const char *s;
+ /* BUG/TODO: XpPrinter resource needs to be sourced, too... */
+ s = getenv("XPRINTER");
+ if( !s )
+ {
+ s = getenv("PDPRINTER");
+ if( !s )
+ {
+ s = getenv("LPDEST");
+ if( !s )
+ {
+ s = getenv("PRINTER");
+ }
+ }
+ }
+ return s;
+}
+
+static
+const char *XpuGetXpServerList( void )
+{
+ const char *s;
+ /* BUG/TODO: XpServerList resource needs to be sourced first, then append
+ * contents of XPSERVERLIST, then remove duplicates...
+ */
+ s = getenv("XPSERVERLIST");
+ if( s == NULL )
+ s = "";
+
+ return(s);
+}
+
+
+Bool XpuXprintServersAvailable( void )
+{
+ const char *s;
+ int c = 0;
+ /* BUGs/ToDo:
+ * - XpServerList resource needs to be sourced, too...
+ * (see comment for |XpuGetXpServerList|, too)
+ * - There should be some validation whether the server entries
+ * are
+ * a) valid (easy :)
+ * and
+ * b) available (hard to implement when XOpenDisplay() should be avoided)
+ */
+ s = getenv("XPSERVERLIST");
+ /* Check if serverlist is non-empty */
+ if (s)
+ {
+ while( *s++ )
+ {
+ if( !isspace(*s) )
+ c++;
+ }
+ }
+ /* a valid server name must at least contain the ':'-seperator
+ * and a number (e.g. ":1") */
+ return( c >= 2 );
+}
+
+
+static
+int XpuGetPrinter2( char *printer, char *display, Display **pdpyptr, XPContext *pcontextptr )
+{
+ Display *pdpy;
+ XPContext pcontext;
+
+ XPU_DEBUG_ONLY(printf("XpuGetPrinter2: probing display '%s' for '%s'\n", XPU_NULLXSTR(display), XPU_NULLXSTR(printer)));
+
+ if( (pdpy = XOpenDisplay(display)) != NULL )
+ {
+ if( XpuCheckExtension(pdpy) )
+ {
+ XPPrinterList list;
+ int list_count;
+
+ /* get list of available printers... */
+ list = XpGetPrinterList(pdpy, printer, &list_count);
+ if( list != NULL ) XpFreePrinterList(list);
+
+ /* ...and check if printer exists... */
+ if( (list != NULL) && (list_count > 0) )
+ {
+ if( (pcontext = XpCreateContext(pdpy, printer)) != None )
+ {
+ *pdpyptr = pdpy;
+ *pcontextptr = pcontext;
+ return(1);
+ }
+
+ XPU_DEBUG_ONLY(printf("XpuGetPrinter2: could not create print context for '%s'\n", XPU_NULLXSTR(printer)));
+ }
+ }
+ else
+ {
+ XPU_DEBUG_ONLY(printf("display '%s' does not support the Xprint extension\n", XPU_NULLXSTR(display)));
+ }
+
+ XCloseDisplay(pdpy);
+ return(0);
+ }
+ else
+ {
+ XPU_DEBUG_ONLY(printf("could not open display '%s'\n", XPU_NULLXSTR(display)));
+ return(0);
+ }
+}
+
+
+/* acceps "printer" or "printer@display" */
+int XpuGetPrinter( const char *arg_printername, Display **pdpyptr, XPContext *pcontextptr )
+{
+ Display *pdpy;
+ XPContext pcontext;
+ char *printername;
+ char *s;
+ char *tok_lasts;
+
+ *pdpyptr = NULL;
+ *pcontextptr = None;
+
+ XPU_DEBUG_ONLY(printf("XpuGetPrinter: looking for '%s'\n", XPU_NULLXSTR(arg_printername)));
+
+ /* strtok_r will modify string - duplicate it first... */
+ printername = strdup(arg_printername);
+ if( printername == NULL )
+ return(0);
+
+ if( (s = strtok_r(printername, "@", &tok_lasts)) != NULL )
+ {
+ char *name = s;
+ char *display = strtok_r(NULL, "@", &tok_lasts);
+
+ /* if we have a display - open it and grab printer */
+ if( display != NULL )
+ {
+ if( XpuGetPrinter2(name, display, pdpyptr, pcontextptr) )
+ {
+ free(printername);
+ return(1);
+ }
+ }
+ /* if we did not get a display, travel througth all displays */
+ else
+ {
+ char *sl = strdup(XpuGetXpServerList());
+
+ if( sl != NULL )
+ {
+ for( display = strtok_r(sl, XPServerListSeparators, &tok_lasts) ;
+ display != NULL ;
+ display = strtok_r(NULL, XPServerListSeparators, &tok_lasts) )
+ {
+ if( XpuGetPrinter2(name, display, pdpyptr, pcontextptr) )
+ {
+ free(sl);
+ free(printername);
+ return(1);
+ }
+ }
+
+ free(sl);
+ }
+ }
+ }
+
+ free(printername);
+ XPU_DEBUG_ONLY(printf("XpuGetPrinter: failure\n"));
+
+ return(0);
+}
+
+
+void XpuClosePrinterDisplay(Display *pdpy, XPContext pcontext)
+{
+ if( pdpy )
+ {
+ if( pcontext != None )
+ XpDestroyContext(pdpy, pcontext);
+
+ XCloseDisplay(pdpy);
+ }
+}
+
+void XpuSetOneAttribute( Display *pdpy, XPContext pcontext,
+ XPAttributes type, const char *attribute_name, const char *value, XPAttrReplacement replacement_rule )
+{
+ /* Alloc buffer for sprintf() stuff below */
+ char *buffer = (char *)malloc(strlen(attribute_name)+strlen(value)+4);
+
+ if( buffer != NULL )
+ {
+ sprintf(buffer, "%s: %s", attribute_name, value);
+ XpSetAttributes(pdpy, pcontext, type, buffer, replacement_rule);
+ free(buffer);
+ }
+}
+
+void XpuSetOneLongAttribute( Display *pdpy, XPContext pcontext,
+ XPAttributes type, const char *attribute_name, long value, XPAttrReplacement replacement_rule )
+{
+ /* Alloc buffer for sprintf() stuff below */
+ char *buffer = (char *)malloc(strlen(attribute_name)+32+4);
+
+ if( buffer != NULL )
+ {
+ sprintf(buffer, "%s: %ld", attribute_name, value);
+ XpSetAttributes(pdpy, pcontext, type, buffer, replacement_rule);
+ free(buffer);
+ }
+}
+
+/* Check if attribute value is supported or not
+ * Use this function _only_ if XpuGetSupported{Job,Doc,Page}Attributes()
+ * does not help you...
+ */
+int XpuCheckSupported( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, const char *query )
+{
+ char *value;
+ void *tok_lasts;
+
+ MAKE_STRING_WRITABLE(attribute_name);
+ if( attribute_name == NULL )
+ return(0);
+
+ value = XpGetOneAttribute(pdpy, pcontext, type, STRING_AS_WRITABLE(attribute_name));
+
+ XPU_DEBUG_ONLY(printf("XpuCheckSupported: XpGetOneAttribute(%s) returned '%s'\n", XPU_NULLXSTR(attribute_name), XPU_NULLXSTR(value)));
+
+ FREE_WRITABLE_STRING(attribute_name);
+
+ if( value != NULL )
+ {
+ const char *s;
+
+ for( s = XpuEnumerateXpAttributeValue(value, &tok_lasts) ; s != NULL ; s = XpuEnumerateXpAttributeValue(NULL, &tok_lasts) )
+ {
+ XPU_DEBUG_ONLY(printf("XpuCheckSupported: probing '%s'=='%s'\n", XPU_NULLXSTR(s), XPU_NULLXSTR(query)));
+ if( !strcmp(s, query) )
+ {
+ XFree(value);
+ XpuDisposeEnumerateXpAttributeValue(&tok_lasts);
+ return(1);
+ }
+ }
+
+ XpuDisposeEnumerateXpAttributeValue(&tok_lasts);
+ XFree(value);
+ }
+
+ return(0);
+}
+
+
+int XpuSetJobTitle( Display *pdpy, XPContext pcontext, const char *title )
+{
+ if( XpuGetSupportedJobAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_JOB_NAME )
+ {
+ char *encoded_title;
+
+ encoded_title = XpuResourceEncode(title);
+ if (!encoded_title)
+ return(0);
+ XpuSetOneAttribute(pdpy, pcontext, XPJobAttr, "*job-name", encoded_title, XPAttrMerge);
+ XpuResourceFreeString(encoded_title);
+ return(1);
+ }
+ else
+ {
+ XPU_DEBUG_ONLY(printf("XpuSetJobTitle: XPUATTRIBUTESUPPORTED_JOB_NAME not supported ('%s')\n", XPU_NULLXSTR(title)));
+ return(0);
+ }
+}
+
+int XpuGetOneLongAttribute( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, long *result )
+{
+ char *s;
+
+ MAKE_STRING_WRITABLE(attribute_name);
+ if( attribute_name == NULL )
+ return(0);
+ s = XpGetOneAttribute(pdpy, pcontext, type, STRING_AS_WRITABLE(attribute_name));
+
+ if(s && *s)
+ {
+ long tmp;
+
+ XPU_DEBUG_ONLY(printf("XpuGetOneLongAttribute: '%s' got '%s'\n", XPU_NULLXSTR(attribute_name), XPU_NULLXSTR(s)));
+
+ tmp = strtol(s, (char **)NULL, 10);
+
+ if( !(((tmp == 0L) || (tmp == LONG_MIN) || (tmp == LONG_MAX)) &&
+ ((errno == ERANGE) || (errno == EINVAL))) )
+ {
+ *result = tmp;
+ XFree(s);
+ XPU_DEBUG_ONLY(printf("XpuGetOneLongAttribute: result %ld\n", *result));
+ FREE_WRITABLE_STRING(attribute_name);
+ return(1);
+ }
+ }
+
+ if( s != NULL )
+ XFree(s);
+
+ FREE_WRITABLE_STRING(attribute_name);
+
+ return(0);
+}
+
+
+#ifdef DEBUG
+/* debug only */
+void dumpXpAttributes( Display *pdpy, XPContext pcontext )
+{
+ char *s;
+ printf("------------------------------------------------\n");
+ printf("--> Job\n%s\n", s=XpuGetJobAttributes(pdpy, pcontext)); XFree(s);
+ printf("--> Doc\n%s\n", s=XpuGetDocAttributes(pdpy, pcontext)); XFree(s);
+ printf("--> Page\n%s\n", s=XpuGetPageAttributes(pdpy, pcontext)); XFree(s);
+ printf("--> Printer\n%s\n", s=XpuGetPrinterAttributes(pdpy, pcontext)); XFree(s);
+ printf("--> Server\n%s\n", s=XpuGetServerAttributes(pdpy, pcontext)); XFree(s);
+ printf("image resolution %d\n", (int)XpGetImageResolution(pdpy, pcontext));
+ printf("------------------------------------------------\n");
+}
+#endif /* DEBUG */
+
+
+typedef struct XpuIsNotifyEventContext_
+{
+ int event_base;
+ int detail;
+} XpuIsNotifyEventContext;
+
+static
+Bool IsXpNotifyEvent( Display *pdpy, XEvent *ev, XPointer arg )
+{
+ Bool match;
+ XpuIsNotifyEventContext *context = (XpuIsNotifyEventContext *)arg;
+ XPPrintEvent *pev = (XPPrintEvent *)ev;
+
+ match = pev->type == (context->event_base+XPPrintNotify) &&
+ pev->detail == context->detail;
+
+ XPU_DEBUG_ONLY(printf("XpuWaitForPrintNotify: %d=IsXpNotifyEvent(%d,%d)\n",
+ (int)match,
+ (int)pev->type,
+ (int)pev->detail));
+ return match;
+}
+
+void XpuWaitForPrintNotify( Display *pdpy, int xp_event_base, int detail )
+{
+ XEvent dummy;
+ XpuIsNotifyEventContext matchcontext;
+
+ matchcontext.event_base = xp_event_base;
+ matchcontext.detail = detail;
+ XIfEvent(pdpy, &dummy, IsXpNotifyEvent, (XPointer)&matchcontext);
+}
+
+static
+const char *skip_matching_brackets(const char *start)
+{
+ const char *s = start;
+ int level = 0;
+
+ if( !start )
+ return(NULL);
+
+ do
+ {
+ switch(*s++)
+ {
+ case '\0': return(NULL);
+ case '{': level++; break;
+ case '}': level--; break;
+ }
+ } while(level > 0);
+
+ return(s);
+}
+
+
+static
+const char *search_next_space(const char *start)
+{
+ const char *s = start;
+ int level = 0;
+
+ if( !start )
+ return(NULL);
+
+ for(;;)
+ {
+ if( isspace(*s) )
+ return(s);
+
+ if( *s=='\0' )
+ return(NULL);
+
+ s++;
+ }
+}
+
+/* PRIVATE context data for XpuEnumerateXpAttributeValue() */
+typedef struct _XpuAttributeValueEnumeration
+{
+ char *value;
+ size_t original_value_len; /* original length of value */
+ char *group;
+ char *start;
+ char *s;
+} XpuAttributeValueEnumeration;
+
+
+/* Hacked parser for Xp values and enumerations */
+static
+const char *XpuEnumerateXpAttributeValue( const char *value, void **vcptr )
+{
+ XpuAttributeValueEnumeration **cptr = (XpuAttributeValueEnumeration **)vcptr;
+ XpuAttributeValueEnumeration *context;
+ const char *tmp;
+
+ if( !cptr )
+ return(NULL);
+
+ if( value )
+ {
+ XpuAttributeValueEnumeration *e;
+ const char *s = value;
+ Bool isGroup = FALSE;
+
+ e = (XpuAttributeValueEnumeration *)malloc(sizeof(XpuAttributeValueEnumeration));
+ if( !e )
+ return NULL;
+
+ /* Skip leading '{'. */
+ while(*s=='{' && isGroup==FALSE)
+ {
+ s++;
+ isGroup = TRUE;
+ }
+ /* Skip leading blanks. */
+ while(isspace(*s))
+ s++;
+
+ e->group = NULL;
+
+ /* Read group name. */
+ if( isGroup )
+ {
+ tmp = s;
+ while(!isspace(*s))
+ s++;
+ if(strncmp(tmp, "''", s-tmp) != 0)
+ {
+ e->group = strdup(tmp);
+ e->group[s-tmp] = '\0';
+ }
+ }
+
+ e->original_value_len = strlen(s);
+ e->value = (char *)malloc(e->original_value_len+4); /* We may look up to three bytes beyond the string */
+ strcpy(e->value, s);
+ memset(e->value+e->original_value_len+1, 0, 3); /* quad termination */
+ e->start = e->s = e->value;
+
+ *cptr = e;
+ }
+
+ context = *cptr;
+
+ if( !context || !context->s )
+ return(NULL);
+
+ /* Skip leading blanks, '\'' or '}' */
+ while(isspace(*(context->s)) || *(context->s)=='\'' /*|| *(context->s)=='}'*/ )
+ context->s++;
+
+ if( *(context->s) == '\0' )
+ return(NULL);
+
+ context->start = context->s;
+ if( *(context->start) == '{' )
+ context->s = (char *)skip_matching_brackets(context->start);
+ else
+ context->s = (char *)search_next_space(context->start);
+
+ /* end of string reached ? */
+ if( context->s )
+ {
+ *(context->s) = '\0';
+ context->s++;
+ }
+
+ /* Check if we reached a new attribute group */
+ tmp = context->start;
+ while(isspace(*tmp))
+ tmp++;
+ if( *tmp=='}' )
+ {
+ void *prev_cptr = *vcptr;
+
+ tmp+=2; /* We have 3*'\0' at the end of the string - this is legal! */
+ if( *tmp!='\0' )
+ {
+ const char *ret;
+
+ /* Start the parser again */
+ *vcptr = NULL;
+ ret = XpuEnumerateXpAttributeValue(tmp, vcptr);
+
+ /* Free old context */
+ XpuDisposeEnumerateXpAttributeValue(&prev_cptr);
+
+ return(ret);
+ }
+ else
+ {
+ return(NULL);
+ }
+ }
+
+ return(context->start);
+}
+
+/* Get enumeration group for last string returned by |XpuEnumerateXpAttributeValue|... */
+static
+const char *XpuGetCurrentAttributeGroup( void **vcptr )
+{
+ XpuAttributeValueEnumeration **cptr = (XpuAttributeValueEnumeration **)vcptr;
+ if( !cptr )
+ return(NULL);
+ if( !*cptr )
+ return(NULL);
+
+ return((*cptr)->group);
+}
+
+
+static
+void XpuDisposeEnumerateXpAttributeValue( void **vc )
+{
+ if( vc )
+ {
+ XpuAttributeValueEnumeration *context = *((XpuAttributeValueEnumeration **)vc);
+ free(context->value);
+ if(context->group)
+ free(context->group);
+ free(context);
+ }
+}
+
+/* parse a paper size string
+ * (example: '{na-letter False {6.3500 209.5500 6.3500 273.0500}}') */
+static
+Bool XpuParseMediumSourceSize( const char *value,
+ const char **medium_name, int *mbool,
+ float *ma1, float *ma2, float *ma3, float *ma4 )
+{
+ const char *s;
+ char *d,
+ *name;
+ char *boolbuf;
+ size_t value_len;
+ int num_input_items;
+ const char *cur_locale;
+
+ if( value && value[0]!='{' && value[0]!='\0' )
+ return(False);
+
+ value_len = strlen(value);
+
+ /* alloc buffer for |medium_name| and |boolbuf| in one step
+ * (both must be large enougth to hold at least |strlen(value)+1| bytes) */
+ name = (char *)malloc(value_len*2 + 4);
+ boolbuf = name + value_len+2; /* |boolbuf| starts directly after |name| */
+
+ /* remove '{' && '}' */
+ s = value;
+ d = name;
+ do
+ {
+ *d = tolower(*s);
+
+ if( *s!='{' && *s!='}' )
+ d++;
+
+ s++;
+ }
+ while(*s);
+ *d = '\0';
+
+ /* separate medium name from string */
+ d = (char *)search_next_space(name);
+ if( !d )
+ {
+ free(name);
+ return(False);
+ }
+ *d = '\0';
+ *medium_name = name;
+
+ /* ... continue to parse the remaining string... */
+ d++;
+
+
+ /* Force C/POSIX radix for scanf()-parsing (see bug 131831 ("Printing
+ * does not work in de_AT@euro locale")), do the parsing and restore
+ * the original locale.
+ * XXX: This may affect all threads and not only the calling one...
+ */
+ {
+#define CUR_LOCALE_SIZE 256
+ char cur_locale[CUR_LOCALE_SIZE+1];
+ strncpy(cur_locale, setlocale(LC_NUMERIC, NULL), CUR_LOCALE_SIZE);
+ cur_locale[CUR_LOCALE_SIZE]='\0';
+ setlocale(LC_NUMERIC, "C");
+ num_input_items = sscanf(d, "%s %f %f %f %f", boolbuf, ma1, ma2, ma3, ma4);
+ setlocale(LC_NUMERIC, cur_locale);
+#undef CUR_LOCALE_SIZE
+ }
+
+ if( num_input_items != 5 )
+ {
+ free(name);
+ return(False);
+ }
+
+ if( !strcmp(boolbuf, "true") )
+ *mbool = True;
+ else if( !strcmp(boolbuf, "false") )
+ *mbool = False;
+ else
+ {
+ free(name);
+ return(False);
+ }
+ return(True);
+}
+
+
+/* parse a paper size string
+ * (example: '{na-letter False {6.3500 209.5500 6.3500 273.0500}}') */
+static
+Bool XpuEnumerateMediumSourceSizes( Display *pdpy, XPContext pcontext,
+ const char **tray_name,
+ const char **medium_name, int *mbool,
+ float *ma1, float *ma2, float *ma3, float *ma4,
+ void **vcptr )
+{
+ const char *medium_spec;
+ const char *value = NULL;
+
+ if( pdpy && pcontext )
+ {
+ value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "medium-source-sizes-supported");
+ if( !value )
+ return(False);
+ }
+
+ while(1)
+ {
+ medium_spec = XpuEnumerateXpAttributeValue(value, vcptr);
+
+ if( value )
+ {
+ XFree((void *)value);
+ value = NULL;
+ }
+
+ /* enumeration done? */
+ if( !medium_spec )
+ return(False);
+
+ if (XpuParseMediumSourceSize(medium_spec,
+ medium_name, mbool,
+ ma1, ma2, ma3, ma4))
+ {
+ *tray_name = XpuGetCurrentAttributeGroup(vcptr);
+ return(True);
+ }
+ else
+ {
+ /* Should never ever happen! */
+ fprintf(stderr, "XpuEnumerateMediumSourceSize: error parsing '%s'\n", medium_spec);
+ }
+ }
+ /* not reached */
+}
+
+static
+void XpuDisposeEnumerateMediumSourceSizes( void **vc )
+{
+ XpuDisposeEnumerateXpAttributeValue(vc);
+}
+
+
+/* future: Migrate this functionality into |XpGetPrinterList| - just do
+ * not pass a |Display *| to |XpGetPrinterList|
+ */
+XPPrinterList XpuGetPrinterList( const char *printer, int *res_list_count )
+{
+ XPPrinterRec *rec = NULL;
+ int rec_count = 1; /* Allocate one more |XPPrinterRec| structure
+ * as terminator */
+ char *sl;
+ const char *default_printer_name = XpuGetDefaultXpPrintername();
+ int default_printer_rec_index = -1;
+
+ if( !res_list_count )
+ return(NULL);
+
+ sl = strdup(XpuGetXpServerList());
+ MAKE_STRING_WRITABLE(printer);
+
+ if( sl != NULL )
+ {
+ char *display;
+ char *tok_lasts;
+
+ for( display = strtok_r(sl, XPServerListSeparators, &tok_lasts) ;
+ display != NULL ;
+ display = strtok_r(NULL, XPServerListSeparators, &tok_lasts) )
+ {
+ Display *pdpy;
+
+ if( (pdpy = XOpenDisplay(display)) != NULL )
+ {
+ XPPrinterList list;
+ int list_count;
+ size_t display_len = strlen(display);
+
+ /* get list of available printers... */
+ list = XpGetPrinterList(pdpy, STRING_AS_WRITABLE(printer), &list_count);
+
+ if( list && list_count )
+ {
+ int i;
+
+ for( i = 0 ; i < list_count ; i++ )
+ {
+ char *s;
+
+ /* Workaround for http://bugzilla.mozilla.org/show_bug.cgi?id=193499
+ * ("Xprint print/print preview crashes Mozilla") where the Solaris
+ * Xprt may create invalid entries (e.g. |XpGetPrinterList| will
+ * return |list[i].name==NULL| due to empty lines in the printer list.
+ */
+ if( !list[i].name )
+ continue;
+
+ rec_count++;
+ rec = (XPPrinterRec *)realloc(rec, sizeof(XPPrinterRec)*rec_count);
+ if( !rec ) /* failure */
+ break;
+
+ s = (char *)malloc(strlen(list[i].name)+display_len+4);
+ sprintf(s, "%s@%s", list[i].name, display);
+ rec[rec_count-2].name = s;
+ rec[rec_count-2].desc = (list[i].desc)?(strdup(list[i].desc)):(NULL);
+
+ /* Test for default printer (if the user set one).*/
+ if( default_printer_name )
+ {
+ /* Default_printer_name may either contain the FQPN(=full
+ * qualified printer name ("foo@myhost:5") or just the name
+ * ("foo")) */
+ if( (!strcmp(list[i].name, default_printer_name)) ||
+ (!strcmp(s, default_printer_name)) )
+ {
+ /* Remember index of default printer that we can swap it to
+ * the head of the array below... */
+ default_printer_rec_index = rec_count-2;
+ }
+ }
+ }
+
+ XpFreePrinterList(list);
+ }
+
+ XCloseDisplay(pdpy);
+ }
+ }
+
+ free(sl);
+ }
+
+ if( rec )
+ {
+ /* users: DO NOT COUNT ON THIS DETAIL
+ * (this is only to make current impl. of XpuFreePrinterList() easier)
+ * I may remove this implementation detail in a later revision of
+ * the library!
+ */
+ rec[rec_count-1].name = NULL;
+ rec[rec_count-1].desc = NULL;
+ rec_count--;
+ }
+ else
+ {
+ rec_count = 0;
+ }
+
+ /* The default printer is always the first one in the printer list... */
+ if( (default_printer_rec_index != -1) && rec )
+ {
+ XPPrinterRec tmp;
+ tmp = rec[0];
+ rec[0] = rec[default_printer_rec_index];
+ rec[default_printer_rec_index] = tmp;
+ }
+
+ *res_list_count = rec_count;
+ FREE_WRITABLE_STRING(printer);
+ return(rec);
+}
+
+
+void XpuFreePrinterList( XPPrinterList list )
+{
+ if( list )
+ {
+ XPPrinterRec *curr = list;
+
+ /* See the warning abouve about using this implementation detail for
+ * checking for the list's end... */
+ while( curr->name != NULL )
+ {
+ free(curr->name);
+ if(curr->desc)
+ free(curr->desc);
+ curr++;
+ }
+
+ free(list);
+ }
+}
+
+/* Set number of copies to print from this document */
+int XpuSetDocumentCopies( Display *pdpy, XPContext pcontext, long num_copies )
+{
+ if( XpuGetSupportedDocAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_COPY_COUNT)
+ {
+ XpuSetOneLongAttribute(pdpy, pcontext, XPDocAttr, "*copy-count", num_copies, XPAttrMerge);
+ return(1);
+ }
+ else
+ {
+ XPU_DEBUG_ONLY(printf("XpuSetContentOrientation: XPUATTRIBUTESUPPORTED_COPY_COUNT not supported\n"));
+
+ /* Failure... */
+ return(0);
+ }
+}
+
+XpuMediumSourceSizeList XpuGetMediumSourceSizeList( Display *pdpy, XPContext pcontext, int *numEntriesPtr )
+{
+ XpuMediumSourceSizeList list = NULL;
+ int rec_count = 1; /* allocate one more |XpuMediumSourceSizeRec| structure
+ * as terminator */
+ Bool status;
+ float ma1,
+ ma2,
+ ma3,
+ ma4;
+ char *value;
+ void *tok_lasts;
+ const char *tray_name,
+ *medium_name;
+ int mbool;
+ const char *default_tray,
+ *default_medium;
+ int default_medium_rec_index = -1;
+
+ default_tray = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "default-input-tray");
+ if(!default_tray)
+ {
+ fprintf(stderr, "XpuGetMediumSourceSizeList: Internal error, no 'default-input-tray' found.\n");
+ return(NULL);
+ }
+ default_medium = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "default-medium");
+ if(!default_medium)
+ {
+ fprintf(stderr, "XpuGetMediumSourceSizeList: Internal error, no 'default-medium' found.\n");
+ XFree((void *)default_tray);
+ return(NULL);
+ }
+
+ for( status = XpuEnumerateMediumSourceSizes(pdpy, pcontext, &tray_name, &medium_name, &mbool,
+ &ma1, &ma2, &ma3, &ma4, &tok_lasts) ;
+ status != False ;
+ status = XpuEnumerateMediumSourceSizes(NULL, None, &tray_name, &medium_name, &mbool,
+ &ma1, &ma2, &ma3, &ma4, &tok_lasts) )
+ {
+ rec_count++;
+ list = (XpuMediumSourceSizeRec *)realloc(list, sizeof(XpuMediumSourceSizeRec)*rec_count);
+ if( !list )
+ return(NULL);
+
+ list[rec_count-2].tray_name = (tray_name)?(strdup(tray_name)):(NULL);
+ list[rec_count-2].medium_name = strdup(medium_name);
+ list[rec_count-2].mbool = mbool;
+ list[rec_count-2].ma1 = ma1;
+ list[rec_count-2].ma2 = ma2;
+ list[rec_count-2].ma3 = ma3;
+ list[rec_count-2].ma4 = ma4;
+
+ /* Default medium ? */
+ if( (!strcmp(medium_name, default_medium)) &&
+ ((tray_name && (*default_tray))?(!strcmp(tray_name, default_tray)):(True)) )
+ {
+ default_medium_rec_index = rec_count-2;
+ }
+ }
+
+ XpuDisposeEnumerateMediumSourceSizes(&tok_lasts);
+
+ if( list )
+ {
+ /* users: DO NOT COUNT ON THIS DETAIL
+ * (this is only to make current impl. of XpuFreeMediumSourceSizeList() easier)
+ * I may remove this implementation detail in a later revision of
+ * the library! */
+ list[rec_count-1].tray_name = NULL;
+ list[rec_count-1].medium_name = NULL;
+ rec_count--;
+ }
+ else
+ {
+ rec_count = 0;
+ }
+
+ /* Make the default medium always the first item in the list... */
+ if( (default_medium_rec_index != -1) && list )
+ {
+ XpuMediumSourceSizeRec tmp;
+ tmp = list[0];
+ list[0] = list[default_medium_rec_index];
+ list[default_medium_rec_index] = tmp;
+ }
+
+ *numEntriesPtr = rec_count;
+ return(list);
+}
+
+void XpuFreeMediumSourceSizeList( XpuMediumSourceSizeList list )
+{
+ if( list )
+ {
+ XpuMediumSourceSizeRec *curr = list;
+
+ /* See the warning abouve about using this implementation detail for
+ * checking for the list's end... */
+ while( curr->medium_name != NULL )
+ {
+ if( curr->tray_name)
+ free((void *)curr->tray_name);
+ free((void *)curr->medium_name);
+ curr++;
+ }
+
+ free(list);
+ }
+}
+
+static
+int XpuSetMediumSourceSize( Display *pdpy, XPContext pcontext, XPAttributes type, XpuMediumSourceSizeRec *medium_spec )
+{
+ /* Set the "default-medium" and "*default-input-tray"
+ * (if |XpuEnumerateMediumSourceSizes| returned one) XPDocAttr's
+ * attribute and return */
+ if (medium_spec->tray_name)
+ {
+ XpuSetOneAttribute(pdpy, pcontext, type, "*default-input-tray", medium_spec->tray_name, XPAttrMerge);
+ }
+ XpuSetOneAttribute(pdpy, pcontext, type, "*default-medium", medium_spec->medium_name, XPAttrMerge);
+
+ return( 1 );
+}
+
+/* Set document medium size */
+int XpuSetDocMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec )
+{
+ XpuSupportedFlags doc_supported_flags;
+
+ doc_supported_flags = XpuGetSupportedDocAttributes(pdpy, pcontext);
+
+ if( (doc_supported_flags & XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM) == 0 )
+ return( 0 );
+
+ if (medium_spec->tray_name)
+ {
+ if( (doc_supported_flags & XPUATTRIBUTESUPPORTED_DEFAULT_INPUT_TRAY) == 0 )
+ return( 0 );
+ }
+
+ return XpuSetMediumSourceSize(pdpy, pcontext, XPDocAttr, medium_spec);
+}
+
+/* Set page medium size */
+int XpuSetPageMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec )
+{
+ XpuSupportedFlags page_supported_flags;
+
+ page_supported_flags = XpuGetSupportedPageAttributes(pdpy, pcontext);
+
+ if( (page_supported_flags & XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM) == 0 )
+ return( 0 );
+
+ if (medium_spec->tray_name)
+ {
+ if( (page_supported_flags & XPUATTRIBUTESUPPORTED_DEFAULT_INPUT_TRAY) == 0 )
+ return( 0 );
+ }
+
+ return XpuSetMediumSourceSize(pdpy, pcontext, XPPageAttr, medium_spec);
+}
+
+#ifndef ABS
+#define ABS(x) ((x)<0?-(x):(x))
+#endif /* ABS */
+#define MORE_OR_LESS_EQUAL(a, b, tolerance) (ABS((a) - (b)) <= (tolerance))
+
+XpuMediumSourceSizeRec *
+XpuFindMediumSourceSizeBySize( XpuMediumSourceSizeList mlist, int mlist_count,
+ float page_width_mm, float page_height_mm, float tolerance )
+{
+ int i;
+ for( i = 0 ; i < mlist_count ; i++ )
+ {
+ XpuMediumSourceSizeRec *curr = &mlist[i];
+ float total_width = curr->ma1 + curr->ma2,
+ total_height = curr->ma3 + curr->ma4;
+
+ /* Match width/height*/
+ if( ((page_width_mm !=-1.f)?(MORE_OR_LESS_EQUAL(total_width, page_width_mm, tolerance)):(True)) &&
+ ((page_height_mm!=-1.f)?(MORE_OR_LESS_EQUAL(total_height, page_height_mm, tolerance)):(True)) )
+ {
+ return(curr);
+ }
+ }
+
+ return(NULL);
+}
+
+XpuMediumSourceSizeRec *
+XpuFindMediumSourceSizeByBounds( XpuMediumSourceSizeList mlist, int mlist_count,
+ float m1, float m2, float m3, float m4, float tolerance )
+{
+ int i;
+ for( i = 0 ; i < mlist_count ; i++ )
+ {
+ XpuMediumSourceSizeRec *curr = &mlist[i];
+
+ /* Match bounds */
+ if( ((m1!=-1.f)?(MORE_OR_LESS_EQUAL(curr->ma1, m1, tolerance)):(True)) &&
+ ((m2!=-1.f)?(MORE_OR_LESS_EQUAL(curr->ma2, m2, tolerance)):(True)) &&
+ ((m3!=-1.f)?(MORE_OR_LESS_EQUAL(curr->ma3, m3, tolerance)):(True)) &&
+ ((m4!=-1.f)?(MORE_OR_LESS_EQUAL(curr->ma4, m4, tolerance)):(True)) )
+ {
+ return(curr);
+ }
+ }
+
+ return(NULL);
+}
+
+XpuMediumSourceSizeRec *
+XpuFindMediumSourceSizeByName( XpuMediumSourceSizeList mlist, int mlist_count,
+ const char *tray_name, const char *medium_name )
+{
+ int i;
+ for( i = 0 ; i < mlist_count ; i++ )
+ {
+ XpuMediumSourceSizeRec *curr = &mlist[i];
+
+ /* Match by tray name and/or medium name */
+ if( ((tray_name && curr->tray_name)?(!strcasecmp(curr->tray_name, tray_name)):(tray_name==NULL)) &&
+ ((medium_name)?(!strcasecmp(curr->medium_name, medium_name)):(True)) )
+ {
+ return(curr);
+ }
+ }
+
+ return(NULL);
+}
+
+XpuResolutionList XpuGetResolutionList( Display *pdpy, XPContext pcontext, int *numEntriesPtr )
+{
+ XpuResolutionList list = NULL;
+ int rec_count = 1; /* Allocate one more |XpuResolutionRec| structure
+ * as terminator */
+ char *value;
+ char *tok_lasts;
+ const char *s;
+ long default_resolution = -1;
+ int default_resolution_rec_index = -1;
+ char namebuf[64];
+
+ /* Get default document resolution */
+ if( XpuGetOneLongAttribute(pdpy, pcontext, XPDocAttr, "default-printer-resolution", &default_resolution) != 1 )
+ {
+ default_resolution = -1;
+ }
+
+ value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "printer-resolutions-supported");
+ if (!value)
+ {
+ fprintf(stderr, "XpuGetResolutionList: Internal error, no 'printer-resolutions-supported' XPPrinterAttr found.\n");
+ return(NULL);
+ }
+
+ for( s = strtok_r(value, " ", &tok_lasts) ;
+ s != NULL ;
+ s = strtok_r(NULL, " ", &tok_lasts) )
+ {
+ long tmp;
+
+ tmp = strtol(s, (char **)NULL, 10);
+
+ if( ((tmp == 0L) || (tmp == LONG_MIN) || (tmp == LONG_MAX)) &&
+ ((errno == ERANGE) || (errno == EINVAL)) )
+ {
+ fprintf(stderr, "XpuGetResolutionList: Internal parser errror for '%s'.\n", s);
+ continue;
+ }
+
+ rec_count++;
+ list = (XpuResolutionRec *)realloc(list, sizeof(XpuResolutionRec)*rec_count);
+ if( !list )
+ return(NULL);
+
+ sprintf(namebuf, "%lddpi", tmp);
+ list[rec_count-2].name = strdup(namebuf);
+ list[rec_count-2].x_dpi = tmp;
+ list[rec_count-2].y_dpi = tmp;
+
+ if( default_resolution != -1 )
+ {
+ /* Is this the default resolution ? */
+ if( (list[rec_count-2].x_dpi == default_resolution) &&
+ (list[rec_count-2].y_dpi == default_resolution) )
+ {
+ default_resolution_rec_index = rec_count-2;
+ }
+ }
+ }
+
+ XFree(value);
+
+ if( list )
+ {
+ /* users: DO NOT COUNT ON THIS DETAIL
+ * (this is only to make current impl. of XpuGetResolutionList() easier)
+ * We may remove this implementation detail in a later revision of
+ * the library! */
+ list[rec_count-1].name = NULL;
+ list[rec_count-1].x_dpi = -1;
+ list[rec_count-1].y_dpi = -1;
+ rec_count--;
+ }
+ else
+ {
+ rec_count = 0;
+ }
+
+ /* Make the default resolution always the first item in the list... */
+ if( (default_resolution_rec_index != -1) && list )
+ {
+ XpuResolutionRec tmp;
+ tmp = list[0];
+ list[0] = list[default_resolution_rec_index];
+ list[default_resolution_rec_index] = tmp;
+ }
+
+ *numEntriesPtr = rec_count;
+ return(list);
+}
+
+void XpuFreeResolutionList( XpuResolutionList list )
+{
+ if( list )
+ {
+ XpuResolutionRec *curr = list;
+
+ /* See the warning abouve about using this implementation detail for
+ * checking for the list's end... */
+ while( curr->name != NULL )
+ {
+ free((void *)curr->name);
+ curr++;
+ }
+
+ free(list);
+ }
+}
+
+/* Find resolution in resolution list.
+ */
+XpuResolutionRec *XpuFindResolutionByName( XpuResolutionList list, int list_count, const char *name)
+{
+ int i;
+
+ for( i = 0 ; i < list_count ; i++ )
+ {
+ XpuResolutionRec *curr = &list[i];
+ if (!strcasecmp(curr->name, name))
+ return curr;
+
+ /* Search by plain DPI value (no "dpi" suffix )*/
+ if (curr->x_dpi == curr->x_dpi)
+ {
+ char buf[32];
+ sprintf(buf, "%ld", curr->x_dpi);
+ if (!strcasecmp(buf, name))
+ return curr;
+ }
+ }
+
+ return NULL;
+}
+
+/* Get default page (if defined) or document resolution
+ * this function may fail in the following conditions:
+ * - No default resolution set yet
+ * - X DPI != Y DPI (not yet implemented in Xprt)
+ */
+Bool XpuGetResolution( Display *pdpy, XPContext pcontext, long *x_dpi_ptr, long *y_dpi_ptr )
+{
+ long dpi;
+
+ /* Try to get the current page's resolution (pages may differ in resolution if the DDX supports this) */
+ if( XpuGetOneLongAttribute(pdpy, pcontext, XPPageAttr, "default-printer-resolution", &dpi) == 1 )
+ {
+ *x_dpi_ptr = dpi;
+ *y_dpi_ptr = dpi;
+ return True;
+ }
+
+ /* Get document resolution */
+ if( XpuGetOneLongAttribute(pdpy, pcontext, XPDocAttr, "default-printer-resolution", &dpi) == 1 )
+ {
+ *x_dpi_ptr = dpi;
+ *y_dpi_ptr = dpi;
+ return True;
+ }
+
+ return False;
+}
+
+static
+int XpuSetResolution( Display *pdpy, XPContext pcontext, XPAttributes type, XpuResolutionRec *rec )
+{
+ if( rec->x_dpi != rec->y_dpi )
+ {
+ fprintf(stderr, "XpuSetResolution: internal error: x_dpi != y_dpi not supported yet.\n");
+ return 0;
+ }
+
+ XpuSetOneLongAttribute(pdpy, pcontext, type, "*default-printer-resolution", rec->x_dpi, XPAttrMerge);
+ return( 1 );
+}
+
+/* Set document resolution
+ * Retun error if printer does not support setting a resolution
+ */
+int XpuSetDocResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec *rec )
+{
+ if( (XpuGetSupportedDocAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION) == 0 )
+ return( 0 );
+
+ return XpuSetResolution(pdpy, pcontext, XPDocAttr, rec);
+}
+
+/* Set page medium size
+ * Retun error if printer does not support setting a resolution or if per-page
+ * resolution changes are not allowed.
+ */
+int XpuSetPageResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec *rec )
+{
+ if( (XpuGetSupportedPageAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION) == 0 )
+ return( 0 );
+
+ return XpuSetResolution(pdpy, pcontext, XPPageAttr, rec);
+}
+
+XpuOrientationList XpuGetOrientationList( Display *pdpy, XPContext pcontext, int *numEntriesPtr )
+{
+ XpuOrientationList list = NULL;
+ int rec_count = 1; /* Allocate one more |XpuOrientationRec|
+ * structure as terminator */
+ char *value;
+ char *tok_lasts;
+ const char *s;
+ const char *default_orientation = NULL;
+ int default_orientation_rec_index = -1;
+
+ /* Get default document orientation */
+ default_orientation = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "content-orientation");
+ if( !default_orientation )
+ {
+ fprintf(stderr, "XpuGetOrientationList: Internal error, no 'content-orientation' XPDocAttr found.\n");
+ return(NULL);
+ }
+
+ value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "content-orientations-supported");
+ if (!value)
+ {
+ fprintf(stderr, "XpuGetOrientationList: Internal error, no 'content-orientations-supported' XPPrinterAttr found.\n");
+ return(NULL);
+ }
+
+ for( s = strtok_r(value, " ", &tok_lasts) ;
+ s != NULL ;
+ s = strtok_r(NULL, " ", &tok_lasts) )
+ {
+ rec_count++;
+ list = (XpuOrientationRec *)realloc(list, sizeof(XpuOrientationRec)*rec_count);
+ if( !list )
+ return(NULL);
+
+ list[rec_count-2].orientation = strdup(s);
+
+ /* Default resolution ? */
+ if( !strcmp(list[rec_count-2].orientation, default_orientation) )
+ {
+ default_orientation_rec_index = rec_count-2;
+ }
+ }
+
+ XFree(value);
+ XFree((void *)default_orientation);
+
+ if( list )
+ {
+ /* users: DO NOT COUNT ON THIS DETAIL
+ * (this is only to make current impl. of XpuFreeOrientationList() easier)
+ * I may remove this implementation detail in a later revision of
+ * the library! */
+ list[rec_count-1].orientation = NULL;
+ rec_count--;
+ }
+ else
+ {
+ rec_count = 0;
+ }
+
+ /* Make the default orientation always the first item in the list... */
+ if( (default_orientation_rec_index != -1) && list )
+ {
+ XpuOrientationRec tmp;
+ tmp = list[0];
+ list[0] = list[default_orientation_rec_index];
+ list[default_orientation_rec_index] = tmp;
+ }
+
+ *numEntriesPtr = rec_count;
+ return(list);
+}
+
+void XpuFreeOrientationList( XpuOrientationList list )
+{
+ if( list )
+ {
+ XpuOrientationRec *curr = list;
+
+ /* See the warning abouve about using this implementation detail for
+ * checking for the list's end... */
+ while( curr->orientation != NULL )
+ {
+ free((void *)curr->orientation);
+ curr++;
+ }
+ free(list);
+ }
+}
+
+XpuOrientationRec *
+XpuFindOrientationByName( XpuOrientationList list, int list_count, const char *orientation )
+{
+ int i;
+
+ for( i = 0 ; i < list_count ; i++ )
+ {
+ XpuOrientationRec *curr = &list[i];
+ if (!strcasecmp(curr->orientation, orientation))
+ return curr;
+ }
+
+ return(NULL);
+}
+
+static
+int XpuSetOrientation( Display *pdpy, XPContext pcontext, XPAttributes type, XpuOrientationRec *rec )
+{
+ XpuSetOneAttribute(pdpy, pcontext, type, "*content-orientation", rec->orientation, XPAttrMerge);
+ return(1);
+}
+
+/* Set document orientation
+ * Retun error if printer does not support setting an orientation
+ */
+int XpuSetDocOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec )
+{
+ if( (XpuGetSupportedDocAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION) == 0 )
+ return( 0 );
+
+ return XpuSetOrientation(pdpy, pcontext, XPDocAttr, rec);
+}
+
+/* Set page orientation
+ * Retun error if printer does not support setting an orientation or if
+ * per-page orientations changes are not allowed
+ */
+int XpuSetPageOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec )
+{
+ if( (XpuGetSupportedPageAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION) == 0 )
+ return( 0 );
+
+ return XpuSetOrientation(pdpy, pcontext, XPPageAttr, rec);
+}
+
+XpuPlexList XpuGetPlexList( Display *pdpy, XPContext pcontext, int *numEntriesPtr )
+{
+ XpuPlexList list = NULL;
+ int rec_count = 1; /* Allocate one more |XpuPlexList| structure
+ * as terminator */
+ char *value;
+ char *tok_lasts;
+ const char *s;
+ const char *default_plex = NULL;
+ int default_plex_rec_index = -1;
+
+ /* Get default document plex */
+ default_plex = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "plex");
+ if( !default_plex )
+ {
+ fprintf(stderr, "XpuGetPlexList: Internal error, no 'plex' XPDocAttr found.\n");
+ return(NULL);
+ }
+
+ value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "plexes-supported");
+ if (!value)
+ {
+ fprintf(stderr, "XpuGetPlexList: Internal error, no 'plexes-supported' XPPrinterAttr found.\n");
+ return(NULL);
+ }
+
+ for( s = strtok_r(value, " ", &tok_lasts) ;
+ s != NULL ;
+ s = strtok_r(NULL, " ", &tok_lasts) )
+ {
+ rec_count++;
+ list = (XpuPlexRec *)realloc(list, sizeof(XpuPlexRec)*rec_count);
+ if( !list )
+ return(NULL);
+
+ list[rec_count-2].plex = strdup(s);
+
+ /* Default plex ? */
+ if( !strcmp(list[rec_count-2].plex, default_plex) )
+ {
+ default_plex_rec_index = rec_count-2;
+ }
+ }
+
+ XFree(value);
+ XFree((void *)default_plex);
+
+ if( list )
+ {
+ /* users: DO NOT COUNT ON THIS DETAIL
+ * (this is only to make current impl. of XpuFreePlexList() easier)
+ * I may remove this implementation detail in a later revision of
+ * the library! */
+ list[rec_count-1].plex = NULL;
+ rec_count--;
+ }
+ else
+ {
+ rec_count = 0;
+ }
+
+ /* Make the default plex always the first item in the list... */
+ if( (default_plex_rec_index != -1) && list )
+ {
+ XpuPlexRec tmp;
+ tmp = list[0];
+ list[0] = list[default_plex_rec_index];
+ list[default_plex_rec_index] = tmp;
+ }
+
+ *numEntriesPtr = rec_count;
+ return(list);
+}
+
+void XpuFreePlexList( XpuPlexList list )
+{
+ if( list )
+ {
+ XpuPlexRec *curr = list;
+
+ /* See the warning abouve about using this implementation detail for
+ * checking for the list's end... */
+ while( curr->plex != NULL )
+ {
+ free((void *)curr->plex);
+ curr++;
+ }
+ free(list);
+ }
+}
+
+XpuPlexRec *
+XpuFindPlexByName( XpuPlexList list, int list_count, const char *plex )
+{
+ int i;
+
+ for( i = 0 ; i < list_count ; i++ )
+ {
+ XpuPlexRec *curr = &list[i];
+ if (!strcasecmp(curr->plex, plex))
+ return curr;
+ }
+
+ return(NULL);
+}
+
+static
+int XpuSetContentPlex( Display *pdpy, XPContext pcontext, XPAttributes type, XpuPlexRec *rec )
+{
+ XpuSetOneAttribute(pdpy, pcontext, type, "*plex", rec->plex, XPAttrMerge);
+ return(1);
+}
+
+/* Set document plex
+ * Retun error if printer does not support setting an plex
+ */
+int XpuSetDocPlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec )
+{
+ if( (XpuGetSupportedDocAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_PLEX) == 0 )
+ return( 0 );
+
+ return XpuSetContentPlex(pdpy, pcontext, XPDocAttr, rec);
+}
+
+/* Set page plex
+ * Retun error if printer does not support setting an plex or if
+ * per-page plex changes are not allowed
+ */
+int XpuSetPagePlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec )
+{
+ if( (XpuGetSupportedPageAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_PLEX) == 0 )
+ return( 0 );
+
+ return XpuSetContentPlex(pdpy, pcontext, XPPageAttr, rec);
+}
+
+
+XpuColorspaceList XpuGetColorspaceList( Display *pdpy, XPContext pcontext, int *numEntriesPtr )
+{
+ XpuColorspaceList list = NULL;
+ int rec_count = 1; /* Allocate one more |XpuColorspaceRec| structure
+ * as terminator */
+ char namebuf[256]; /* Temporary name buffer for colorspace names */
+ int i; /* Loop counter */
+ int nvi; /* Number of visuals */
+ Screen *pscreen; /* Print screen */
+ XVisualInfo viproto; /* fill in for getting info */
+ XVisualInfo *vip; /* retured info */
+
+ pscreen = XpGetScreenOfContext(pdpy, pcontext);
+
+ nvi = 0;
+ viproto.screen = XScreenNumberOfScreen(pscreen);
+ vip = XGetVisualInfo(pdpy, VisualScreenMask, &viproto, &nvi);
+ if (!vip)
+ {
+ fprintf(stderr, "XpuGetColorspaceList: Internal error: vip == NULL\n");
+ return NULL;
+ }
+
+ for( i = 0 ; i < nvi ; i++ )
+ {
+ XVisualInfo *vcurr = vip+i;
+ char cbuff[64];
+ const char *class = NULL;
+
+#ifdef USE_MOZILLA_TYPES
+ /* Workaround for the current limitation of the gfx/src/xlibrgb code
+ * which cannot handle depths > 24bit yet */
+ if( vcurr->depth > 24 )
+ continue;
+#endif /* USE_MOZILLA_TYPES */
+
+ rec_count++;
+ list = (XpuColorspaceRec *)realloc(list, sizeof(XpuColorspaceRec)*rec_count);
+ if( !list )
+ return NULL;
+
+ /* ToDO: This needs to be updated for the COLORSPACE X11 extension
+ * once it is ready and approved by the XOrg arch board. */
+ switch (vcurr->class) {
+ case StaticGray: class = "StaticGray"; break;
+ case GrayScale: class = "GrayScale"; break;
+ case StaticColor: class = "StaticColor"; break;
+ case PseudoColor: class = "PseudoColor"; break;
+ case TrueColor: class = "TrueColor"; break;
+ case DirectColor: class = "DirectColor"; break;
+ default: /* Needed for forward compatibility to the COLORSPACE extension */
+ sprintf (cbuff, "unknown_class_%x", vcurr->class);
+ class = cbuff;
+ break;
+ }
+
+ if (vcurr->bits_per_rgb == 8)
+ {
+ sprintf(namebuf, "%s/%dbit", class, vcurr->depth);
+ }
+ else
+ {
+ sprintf(namebuf, "%s/%dbit/%dbpg", class, vcurr->depth, vcurr->bits_per_rgb);
+ }
+ list[rec_count-2].name = strdup(namebuf);
+ list[rec_count-2].visualinfo = *vcurr;
+ }
+
+ XFree((char *)vip);
+
+ if( list )
+ {
+ /* users: DO NOT COUNT ON THIS DETAIL
+ * (this is only to make current impl. of XpuGetResolutionList() easier)
+ * We may remove this implementation detail in a later revision of
+ * the library! */
+ list[rec_count-1].name = NULL;
+ rec_count--;
+ }
+ else
+ {
+ rec_count = 0;
+ }
+
+ *numEntriesPtr = rec_count;
+ return(list);
+}
+
+void XpuFreeColorspaceList( XpuColorspaceList list )
+{
+ if( list )
+ {
+ XpuColorspaceRec *curr = list;
+
+ /* See the warning abouve about using this implementation detail for
+ * checking for the list's end... */
+ while( curr->name != NULL )
+ {
+ free((void *)curr->name);
+ curr++;
+ }
+
+ free(list);
+ }
+}
+
+XpuColorspaceRec *
+XpuFindColorspaceByName( XpuColorspaceList list, int list_count, const char *name )
+{
+ int i;
+
+ for( i = 0 ; i < list_count ; i++ )
+ {
+ XpuColorspaceRec *curr = &list[i];
+ if (!strcmp(curr->name, name))
+ return curr;
+ }
+
+ return(NULL);
+}
+
+Bool XpuGetEnableFontDownload( Display *pdpy, XPContext pcontext )
+{
+ Bool enableFontDownload;
+ char *value;
+
+ value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "xp-listfonts-modes-supported");
+ if( !value )
+ {
+ fprintf(stderr, "XpuGetEnableFontDownload: xp-listfonts-modes-supported printer attribute not found.\n");
+ return False;
+ }
+
+ enableFontDownload = (strstr(value, "xp-list-glyph-fonts") != NULL);
+ XFree(value);
+ return enableFontDownload;
+}
+
+int XpuSetEnableFontDownload( Display *pdpy, XPContext pcontext, Bool enableFontDownload )
+{
+ char *value,
+ *newvalue;
+
+ value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "xp-listfonts-modes-supported");
+ if( !value )
+ {
+ fprintf(stderr, "XpuSetEnableFontDownload: xp-listfonts-modes-supported printer attribute not found.\n");
+ return 0; /* failure */
+ }
+
+ /* Set "xp-list-glyph-fonts" */
+ if( enableFontDownload )
+ {
+ /* Return success if "xp-list-glyph-fonts" is already set */
+ if( strstr(value, "xp-list-glyph-fonts") != NULL )
+ {
+ XFree(value);
+ return 1; /* success */
+ }
+
+ newvalue = malloc(strlen(value) + 33);
+ if( !newvalue )
+ {
+ XFree(value);
+ return 0; /* failure */
+ }
+
+ sprintf(newvalue, "%s xp-list-glyph-fonts", value);
+ XpuSetOneAttribute(pdpy, pcontext, XPDocAttr, "*xp-listfonts-modes", newvalue, XPAttrMerge);
+
+ free(newvalue);
+ XFree(value);
+ return 1; /* success */
+ }
+ else
+ {
+ char *s, /* copy string "source" */
+ *d; /* copy string "destination" */
+
+ /* Return success if "xp-list-glyph-fonts" not set */
+ d = strstr(value, "xp-list-glyph-fonts");
+ if( d == NULL )
+ {
+ XFree(value);
+ return 1; /* success */
+ }
+
+ /* strip "xp-list-glyph-fonts" from |value| */
+ s = d+19/*strlen("xp-list-glyph-fonts")*/;
+ while( (*d++ = *s++) != '\0' )
+ ;
+
+ XpuSetOneAttribute(pdpy, pcontext, XPDocAttr, "*xp-listfonts-modes", value, XPAttrMerge);
+
+ XFree(value);
+ return 1; /* success */
+ }
+}
+
+/* Return flags to indicate which attributes are supported and which not... */
+static
+XpuSupportedFlags XpuGetSupportedAttributes( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name )
+{
+ char *value;
+ void *tok_lasts;
+ XpuSupportedFlags flags = 0;
+
+ MAKE_STRING_WRITABLE(attribute_name);
+ if( attribute_name == NULL )
+ return(0);
+
+ value = XpGetOneAttribute(pdpy, pcontext, type, STRING_AS_WRITABLE(attribute_name));
+
+ FREE_WRITABLE_STRING(attribute_name);
+
+ if( value != NULL )
+ {
+ const char *s;
+
+ for( s = XpuEnumerateXpAttributeValue(value, &tok_lasts) ; s != NULL ; s = XpuEnumerateXpAttributeValue(NULL, &tok_lasts) )
+ {
+ if( !strcmp(s, "job-name") ) flags |= XPUATTRIBUTESUPPORTED_JOB_NAME;
+ else if( !strcmp(s, "job-owner") ) flags |= XPUATTRIBUTESUPPORTED_JOB_OWNER;
+ else if( !strcmp(s, "notification-profile") ) flags |= XPUATTRIBUTESUPPORTED_NOTIFICATION_PROFILE;
+ else if( !strcmp(s, "copy-count") ) flags |= XPUATTRIBUTESUPPORTED_COPY_COUNT;
+ else if( !strcmp(s, "document-format") ) flags |= XPUATTRIBUTESUPPORTED_DOCUMENT_FORMAT;
+ else if( !strcmp(s, "content-orientation") ) flags |= XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION;
+ else if( !strcmp(s, "default-printer-resolution") ) flags |= XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION;
+ else if( !strcmp(s, "default-input-tray") ) flags |= XPUATTRIBUTESUPPORTED_DEFAULT_INPUT_TRAY;
+ else if( !strcmp(s, "default-medium") ) flags |= XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM;
+ else if( !strcmp(s, "plex") ) flags |= XPUATTRIBUTESUPPORTED_PLEX;
+ else if( !strcmp(s, "xp-listfonts-modes") ) flags |= XPUATTRIBUTESUPPORTED_LISTFONTS_MODES;
+ }
+
+ XpuDisposeEnumerateXpAttributeValue(&tok_lasts);
+ XFree(value);
+ }
+
+ return(flags);
+}
+
+XpuSupportedFlags XpuGetSupportedJobAttributes(Display *pdpy, XPContext pcontext)
+{
+ return XpuGetSupportedAttributes(pdpy, pcontext, XPPrinterAttr, "job-attributes-supported");
+}
+
+XpuSupportedFlags XpuGetSupportedDocAttributes(Display *pdpy, XPContext pcontext)
+{
+ return XpuGetSupportedAttributes(pdpy, pcontext, XPPrinterAttr, "document-attributes-supported");
+}
+
+XpuSupportedFlags XpuGetSupportedPageAttributes(Display *pdpy, XPContext pcontext)
+{
+ return XpuGetSupportedAttributes(pdpy, pcontext, XPPrinterAttr, "xp-page-attributes-supported");
+}
+
+/* Encode string for usage in a Xrm resource database as
+ * defined in X(7): [...] To allow a Value to begin
+ * with whitespace, the two-character sequence ``\space''
+ * (backslash followed by space) is recognized and replaced by
+ * a space character, and the two-character sequence ``\tab''
+ * (backslash followed by horizontal tab) is recognized and
+ * replaced by a horizontal tab character. To allow a Value to
+ * contain embedded newline characters, the two-character
+ * sequence ``\n'' is recognized and replaced by a newline
+ * character. To allow a Value to be broken across multiple
+ * lines in a text file, the two-character sequence ``\new-
+ * line'' (backslash followed by newline) is recognized and
+ * removed from the value. To allow a Value to contain arbi-
+ * trary character codes, the four-character sequence ``\nnn'',
+ * where each n is a digit character in the range of
+ * ``0''-``7'', is recognized and replaced with a single byte
+ * that contains the octal value specified by the sequence.
+ * Finally, the two-character sequence ``\\'' is recognized and
+ * replaced with a single backslash.
+ */
+char *XpuResourceEncode( const char *s )
+{
+ size_t slen;
+ char *res;
+ char *d;
+ int i,
+ c;
+
+ slen = strlen(s);
+ res = malloc(slen*4+1);
+ if (!res)
+ return NULL;
+
+ d = res;
+ i = slen;
+ while (i--) {
+ c = *s++;
+ if (c == '\n') {
+ if (i) {
+ *d++ = '\\';
+ *d++ = 'n';
+ *d++ = '\\';
+ *d++ = '\n';
+ }
+ else {
+ *d++ = '\\';
+ *d++ = 'n';
+ }
+ } else if (c == '\\') {
+ *d++ = '\\';
+ *d++ = '\\';
+ }
+ else if ((c < ' ' && c != '\t') ||
+ ((unsigned char)c >= 0x7F && (unsigned char)c < 0xA0)) {
+ sprintf(d, "\\%03o", (unsigned char)c);
+ d += 4;
+ }
+ else {
+ *d++ = c;
+ }
+ }
+
+ *d = '\0';
+
+ return res;
+}
+
+#ifdef XXXJULIEN_NOTNOW
+char *XpuResourceDecode( const char *str )
+{
+}
+#endif /* XXXJULIEN_NOTNOW */
+
+void XpuResourceFreeString( char *s )
+{
+ free(s);
+}
+
+const char *XpuXmbToCompoundText(Display *dpy, const char *xmbtext)
+{
+ XTextProperty xtp;
+ int xcr;
+ char *xtl[2];
+ char *ct;
+
+ if (strlen(xmbtext) == 0)
+ return strdup(xmbtext);
+
+ memset(&xtp, 0, sizeof(xtp));
+ xtl[0] = (char *)xmbtext;
+ xtl[1] = NULL;
+
+ xcr = XmbTextListToTextProperty(dpy, xtl, 1, XCompoundTextStyle, &xtp);
+
+ if (xcr == XNoMemory || xcr == XLocaleNotSupported)
+ {
+ fprintf(stderr, "XpuXmbToCompoundText: XmbTextListToTextProperty failure.\n");
+ return strdup(xmbtext);
+ }
+
+ /* Did conversion succeed (some unconvertible characters
+ * are not a problem) ? */
+ if ( !((xcr == Success) || (xcr > 0)) ||
+ (xtp.value == NULL))
+ {
+ fprintf(stderr, "XpuXmbToCompoundText: XmbTextListToTextProperty failure 2.\n");
+ return strdup(xmbtext);
+ }
+
+ ct = malloc(xtp.nitems+1);
+ if (!ct)
+ {
+ XFree(xtp.value);
+ return NULL;
+ }
+ memcpy(ct, xtp.value, xtp.nitems);
+ ct[xtp.nitems] = '\0';
+
+ XFree(xtp.value);
+
+ return ct;
+}
+
+void XpuFreeCompundTextString( const char *s )
+{
+ free((void *)s);
+}
+
+const char *XpuCompoundTextToXmb(Display *dpy, const char *ct)
+{
+ XTextProperty xtp;
+ int xcr;
+ char **xtl = NULL;
+ int xtl_count = 0;
+ char *xmb;
+ int xmb_len = 0;
+ int i;
+
+ if (strlen(ct) == 0)
+ return strdup(ct);
+
+ xtp.value = (unsigned char *)ct;
+ xtp.nitems = strlen(ct);
+ xtp.encoding = XInternAtom(dpy, "COMPOUND_TEXT", False);
+ xtp.format = 8;
+
+ xcr = XmbTextPropertyToTextList(dpy, &xtp, &xtl, &xtl_count);
+
+ if (xcr == XNoMemory || xcr == XLocaleNotSupported)
+ {
+ fprintf(stderr, "XpuCompoundTextToXmb: XmbTextPropertyToTextList failure 1.\n");
+ return strdup(ct);
+ }
+
+ /* Did conversion succeed (some unconvertible characters
+ * are not a problem) ? */
+ if ( !((xcr == Success) || (xcr > 0)) ||
+ (xtl == NULL))
+ {
+ fprintf(stderr, "XpuCompoundTextToXmb: XmbTextPropertyToTextList failure 2.\n");
+ return strdup(ct);
+ }
+
+ for (i = 0; i < xtl_count; i++)
+ {
+ xmb_len += strlen(xtl[i]);
+ }
+ xmb = malloc (xmb_len + 1);
+ if (!xmb)
+ {
+ XFreeStringList(xtl);
+ return NULL;
+ }
+ xmb[0] = '\0'; /* Catch zero-length case */
+ for (i = 0; i < xtl_count; i++)
+ {
+ strcat(xmb, xtl[i]);
+ }
+
+ XFreeStringList(xtl);
+
+ return xmb;
+}
+
+void XpuFreeXmbString( const char *s )
+{
+ free((void *)s);
+}
+
+/* EOF. */
diff --git a/nx-X11/lib/XprintUtil/xprintutil.h b/nx-X11/lib/XprintUtil/xprintutil.h
new file mode 100644
index 000000000..e4cc7c640
--- /dev/null
+++ b/nx-X11/lib/XprintUtil/xprintutil.h
@@ -0,0 +1,250 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+#ifndef XPRINTUTIL_H
+#define XPRINTUTIL_H 1
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 2001-2004 Roland Mainz <roland.mainz@nrubsig.org>
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+
+/* Force ANSI C prototypes from X11 headers */
+#ifndef FUNCPROTO
+#define FUNCPROTO 15
+#endif /* !FUNCPROTO */
+
+#include <X11/Xlibint.h>
+#include <X11/extensions/Print.h>
+#include <X11/Intrinsic.h>
+
+/* I don't know how to make this "better" yet... ;-( */
+#ifdef USE_MOZILLA_TYPES
+#include <prtypes.h>
+#include <prmem.h>
+#include <prthread.h>
+#define XPU_USE_NSPR 1
+/*
+ * Disabled for now - Threaded codepath does not work properly always.
+ * See bug 134570 ("Print-to-file not working with threaded XprintUtil")
+ * #define XPU_USE_THREADS 1
+ */
+#endif /* USE_MOZILLA_TYPES */
+
+#ifdef DEBUG
+/* trace function calls */
+#define XPU_TRACE(EX) (puts(#EX),EX)
+/* trace function calls in child */
+#define XPU_TRACE_CHILD(EX) (puts("child: " #EX),EX)
+/* execute function EX only in debug mode */
+#define XPU_DEBUG_ONLY(EX) (EX)
+#else
+#define XPU_TRACE(EX) (EX)
+#define XPU_TRACE_CHILD(EX) (EX)
+#define XPU_DEBUG_ONLY(EX)
+#endif /* DEBUG */
+
+/* debug/logging: replace NULLptrs with "<NULL>" string */
+#define XPU_NULLXSTR(s) (((s)!=NULL)?(s):("<NULL>"))
+
+/*
+ * Struct for XpuGetMediumSourceSizeList(), XpuFreeMediumSourceSizeList(),
+ * XpuSetDocMediumSourceSize(), XpuSetPageMediumSourceSize(),
+ * XpuFindMediumSourceSizeBy*()
+ */
+typedef struct {
+ const char *tray_name;
+ const char *medium_name;
+ int mbool;
+ float ma1;
+ float ma2;
+ float ma3;
+ float ma4;
+} XpuMediumSourceSizeRec, *XpuMediumSourceSizeList;
+
+/*
+ * Struct for XpuGetResolutionList(), XpuFreeResolutionList(),
+ * XpuGetResolution(), XpuSetPageResolution(), XpuSetDocResolution(),
+ * XpuFindResolutionByName()
+ */
+typedef struct {
+ const char *name;
+ long x_dpi;
+ long y_dpi;
+} XpuResolutionRec, *XpuResolutionList;
+
+/*
+ * Struct for XpuGetOrientationList(), XpuFreeOrientationList(),
+ * XpuFindOrientationBy*(), XpuSetPageResolution(),
+ * XpuSetDocOrientation()
+ */
+typedef struct {
+ const char *orientation;
+} XpuOrientationRec, *XpuOrientationList;
+
+/*
+ * Struct for XpuGetPlexList(), XpuFreePlexList(), XpuFindPlexBy*(),
+ * XpuSetDocPlex(), XpuSetPagePlex()
+ */
+typedef struct {
+ const char *plex;
+} XpuPlexRec, *XpuPlexList;
+
+/*
+ * Struct for XpuGetColorspaceList(), XpuFreeColorspaceList()
+ */
+typedef struct
+{
+ const char *name;
+ XVisualInfo visualinfo;
+} XpuColorspaceRec, *XpuColorspaceList;
+
+/* XPUATTRIBUTESUPPORTED_*:
+ * Flags which indicate whether it is allowed to set/change a specific attribute
+ */
+typedef long XpuSupportedFlags;
+/* Job attributes */
+#define XPUATTRIBUTESUPPORTED_JOB_NAME (1L<<0)
+#define XPUATTRIBUTESUPPORTED_JOB_OWNER (1L<<1)
+#define XPUATTRIBUTESUPPORTED_NOTIFICATION_PROFILE (1L<<2)
+/* Document/Page attributes */
+#define XPUATTRIBUTESUPPORTED_COPY_COUNT (1L<<3)
+#define XPUATTRIBUTESUPPORTED_DOCUMENT_FORMAT (1L<<4)
+#define XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION (1L<<5)
+#define XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION (1L<<6)
+#define XPUATTRIBUTESUPPORTED_DEFAULT_INPUT_TRAY (1L<<7)
+#define XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM (1L<<8)
+#define XPUATTRIBUTESUPPORTED_PLEX (1L<<9)
+#define XPUATTRIBUTESUPPORTED_LISTFONTS_MODES (1L<<10)
+
+/* prototypes */
+_XFUNCPROTOBEGIN
+
+int XpuCheckExtension( Display *pdpy );
+
+/* Create/destroy connection to printer */
+Bool XpuXprintServersAvailable( void );
+int XpuGetPrinter( const char *printername, Display **pdpyptr, XPContext *pcontextptr );
+void XpuClosePrinterDisplay(Display *pdpy, XPContext pcontext);
+
+/* Misc. functions */
+void XpuSetOneAttribute( Display *pdpy, XPContext pcontext,
+ XPAttributes type, const char *attribute_name, const char *value, XPAttrReplacement replacement_rule );
+void XpuSetOneLongAttribute( Display *pdpy, XPContext pcontext,
+ XPAttributes type, const char *attribute_name, long value, XPAttrReplacement replacement_rule );
+int XpuCheckSupported( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, const char *query );
+int XpuSetJobTitle( Display *pdpy, XPContext pcontext, const char *title );
+int XpuGetOneLongAttribute( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, long *result );
+#ifdef DEBUG
+void dumpXpAttributes( Display *pdpy, XPContext pcontext );
+#endif /* DEBUG */
+void XpuWaitForPrintNotify( Display *pdpy, int xp_event_base, int detail );
+
+/* Get list of printers */
+XPPrinterList XpuGetPrinterList( const char *printer, int *res_list_count );
+void XpuFreePrinterList( XPPrinterList list );
+
+/* Set number of document copies */
+int XpuSetDocumentCopies( Display *pdpy, XPContext pcontext, long num_copies );
+
+/* Get/Set/Query supported mediums (paper sizes) */
+XpuMediumSourceSizeList XpuGetMediumSourceSizeList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
+void XpuFreeMediumSourceSizeList( XpuMediumSourceSizeList list );
+int XpuSetDocMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec );
+int XpuSetPageMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec );
+XpuMediumSourceSizeRec *
+XpuFindMediumSourceSizeBySize( XpuMediumSourceSizeList mlist, int mlist_count,
+ float page_width_mm, float page_height_mm, float tolerance );
+XpuMediumSourceSizeRec *
+XpuFindMediumSourceSizeByBounds( XpuMediumSourceSizeList mlist, int mlist_count,
+ float m1, float m2, float m3, float m4, float tolerance );
+XpuMediumSourceSizeRec *
+XpuFindMediumSourceSizeByName( XpuMediumSourceSizeList mlist, int mlist_count,
+ const char *tray_name, const char *medium_name );
+
+/* Get/Set resolution */
+XpuResolutionList XpuGetResolutionList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
+void XpuFreeResolutionList( XpuResolutionList list );
+Bool XpuGetResolution( Display *pdpy, XPContext pcontext, long *x_dpi, long *y_dpi );
+Bool XpuSetPageResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec * );
+Bool XpuSetDocResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec * );
+XpuResolutionRec *XpuFindResolutionByName( XpuResolutionList list, int list_count, const char *resolution_name);
+
+/* Get/Set orientation */
+XpuOrientationList XpuGetOrientationList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
+void XpuFreeOrientationList( XpuOrientationList list );
+XpuOrientationRec *
+XpuFindOrientationByName( XpuOrientationList list, int list_count, const char *orientation );
+int XpuSetDocOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec );
+int XpuSetPageOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec );
+
+/* Get/set plex modes */
+XpuPlexList XpuGetPlexList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
+void XpuFreePlexList( XpuPlexList list );
+XpuPlexRec *XpuFindPlexByName( XpuPlexList list, int list_count, const char *plex );
+int XpuSetDocPlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec );
+int XpuSetPagePlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec );
+
+/* Set/get usage of fonts */
+Bool XpuGetEnableFontDownload( Display *pdpy, XPContext pcontext );
+int XpuSetEnableFontDownload( Display *pdpy, XPContext pcontext, Bool enableFontDownload );
+
+/* Get per-printer colorspace information */
+XpuColorspaceList XpuGetColorspaceList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
+void XpuFreeColorspaceList( XpuColorspaceList list );
+XpuColorspaceRec *XpuFindColorspaceByName( XpuColorspaceList list, int list_count, const char *colorspace );
+
+/* Start job to printer (spooler) or file */
+void XpuStartJobToSpooler(Display *pdpy);
+void *XpuStartJobToFile( Display *pdpy, XPContext pcontext, const char *filename );
+XPGetDocStatus XpuWaitForPrintFileChild( void *handle );
+
+/* Get flags which indicate whether it is allowed to set/change a specific attribute */
+XpuSupportedFlags XpuGetSupportedJobAttributes(Display *pdpy, XPContext pcontext);
+XpuSupportedFlags XpuGetSupportedDocAttributes(Display *pdpy, XPContext pcontext);
+XpuSupportedFlags XpuGetSupportedPageAttributes(Display *pdpy, XPContext pcontext);
+
+/* Encode/decode resource strings */
+char *XpuResourceEncode( const char *str );
+char *XpuResourceDecode( const char *str );
+void XpuResourceFreeString( char *s );
+
+/* COMPOUND_TEXT <----> local encoding string converters */
+const char *XpuXmbToCompoundText(Display *dpy, const char *xmbtext);
+void XpuFreeCompundTextString( const char *s );
+const char *XpuCompoundTextToXmb(Display *dpy, const char *ct);
+void XpuFreeXmbString( const char *s );
+
+
+_XFUNCPROTOEND
+
+#define XpuGetJobAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPJobAttr )
+#define XpuGetDocAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPDocAttr )
+#define XpuGetPageAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPPageAttr )
+#define XpuGetPrinterAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPPrinterAttr )
+#define XpuGetServerAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPServerAttr )
+
+#endif /* !XPRINTUTIL_H */
+/* EOF. */
diff --git a/nx-X11/lib/XprintUtil/xprintutil_printtofile.c b/nx-X11/lib/XprintUtil/xprintutil_printtofile.c
new file mode 100644
index 000000000..331e7ad5b
--- /dev/null
+++ b/nx-X11/lib/XprintUtil/xprintutil_printtofile.c
@@ -0,0 +1,498 @@
+/******************************************************************************
+ ******************************************************************************
+ **
+ ** (c) Copyright 2001-2004 Roland Mainz <roland.mainz@nrubsig.org>
+ **
+ ** Permission is hereby granted, free of charge, to any person obtaining a copy
+ ** of this software and associated documentation files (the "Software"), to deal
+ ** in the Software without restriction, including without limitation the rights
+ ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ** copies of the Software, and to permit persons to whom the Software is
+ ** furnished to do so, subject to the following conditions:
+ **
+ ** 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
+ ** COPYRIGHT HOLDERS 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 names of the copyright holders shall
+ ** not be used in advertising or otherwise to promote the sale, use or other
+ ** dealings in this Software without prior written authorization from said
+ ** copyright holders.
+ **
+ ******************************************************************************
+ *****************************************************************************/
+
+#include "xprintutil.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <limits.h>
+#include <errno.h>
+#ifdef XPU_USE_THREADS
+#include <time.h>
+#ifdef XPU_USE_NSPR
+#include <prthread.h>
+#else
+#include <pthread.h>
+#endif /* XPU_USE_NSPR */
+#endif /* XPU_USE_THREADS */
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+/* local prototypes */
+#ifdef DEBUG
+static void PrintXPGetDocStatus( XPGetDocStatus status );
+#endif
+static Bool XNextEventTimeout( Display *display, XEvent *event_return, struct timeval *timeout );
+static void *XpuPrintToFile( Display *pdpy, XPContext pcontext, const char *filename );
+static void MyPrintToFileProc( Display *pdpy, XPContext pcontext, unsigned char *data, unsigned int data_len, XPointer client_data );
+static void MyFinishProc( Display *pdpy, XPContext pcontext, XPGetDocStatus status, XPointer client_data );
+#ifdef XPU_USE_NSPR
+static void PrintToFile_Consumer( void *handle );
+#else
+static void *PrintToFile_Consumer( void *handle );
+#endif
+
+void XpuStartJobToSpooler(Display *pdpy)
+{
+ XpStartJob(pdpy, XPSpool);
+}
+
+void *XpuStartJobToFile( Display *pdpy, XPContext pcontext, const char *filename )
+{
+ void *handle;
+
+ XpStartJob(pdpy, XPGetData);
+ handle = XpuPrintToFile(pdpy, pcontext, filename);
+
+ if (!handle)
+ {
+ /* Cancel the print job and discard all events... */
+ XpCancelJob(pdpy, True);
+ }
+
+ return(handle);
+}
+
+#ifdef DEBUG
+/* DEBUG: Print XPGetDocStatus */
+static
+void PrintXPGetDocStatus( XPGetDocStatus status )
+{
+ switch(status)
+ {
+ case XPGetDocFinished: puts("PrintXPGetDocStatus: XPGetDocFinished"); break;
+ case XPGetDocSecondConsumer: puts("PrintXPGetDocStatus: XPGetDocSecondConsumer"); break;
+ case XPGetDocError: puts("PrintXPGetDocStatus: XPGetDocError"); break;
+ default: puts("PrintXPGetDocStatus: <unknown value"); break;
+ }
+}
+#endif /* DEBUG */
+
+
+/* XNextEvent() with timeout */
+static
+Bool XNextEventTimeout( Display *display, XEvent *event_return, struct timeval *timeout )
+{
+ int res;
+ fd_set readfds;
+ int display_fd = XConnectionNumber(display);
+
+ /* small shortcut... */
+ if( timeout == NULL )
+ {
+ XNextEvent(display, event_return);
+ return(True);
+ }
+
+ FD_ZERO(&readfds);
+ FD_SET(display_fd, &readfds);
+
+ /* Note/bug: In the case of internal X events (like used to trigger callbacks
+ * registered by XpGetDocumentData()&co.) select() will return with "new info"
+ * - but XNextEvent() below processes these _internal_ events silently - and
+ * will block if there are no other non-internal events.
+ * The workaround here is to check with XEventsQueued() if there are non-internal
+ * events queued - if not select() will be called again - unfortunately we use
+ * the old timeout here instead of the "remaining" time... (this only would hurt
+ * if the timeout would be really long - but for current use with values below
+ * 1/2 secs it does not hurt... =:-)
+ */
+ while( XEventsQueued(display, QueuedAfterFlush) == 0 )
+ {
+ res = select(display_fd+1, &readfds, NULL, NULL, timeout);
+
+ switch(res)
+ {
+ case -1: /* select() error - should not happen */
+ perror("XNextEventTimeout: select() failure");
+ return(False);
+ case 0: /* timeout */
+ return(False);
+ }
+ }
+
+ XNextEvent(display, event_return);
+ return(True);
+}
+
+
+#ifdef XPU_USE_THREADS
+/**
+ ** XpuPrintToFile() - threaded version
+ ** Create consumer thread which creates it's own display connection to print server
+ ** (a 2nd display connection/thread is required to avoid deadlocks within Xlib),
+ ** registers (Xlib-internal) consumer callback (via XpGetDocumentData(3Xp)) and
+ ** processes/eats all incoming events via MyPrintToFileProc(). A final call to
+ ** MyPrintToFileProc() cleans-up all stuff and sets the "done" flag.
+ ** Note that these callbacks are called directly by Xlib while waiting for events in
+ ** XNextEvent() because XpGetDocumentData() registeres them as "internal" callbacks,
+ ** e.g. XNextEvent() does _not_ return before/after processing these events !!
+ **
+ ** Usage:
+ ** XpStartJob(pdpy, XPGetData);
+ ** handle = XpuPrintToFile(pdpy, pcontext, "myfile");
+ ** // render something
+ ** XpEndJob(); // or XpCancelJob()
+ ** status = XpuWaitForPrintFileChild(handle);
+ **
+ */
+
+typedef struct
+{
+#ifdef XPU_USE_NSPR
+ PRThread *prthread;
+#else
+ pthread_t tid;
+#endif
+ char *displayname;
+ Display *pdpy;
+ Display *parent_pdpy;
+ XPContext pcontext;
+ const char *file_name;
+ FILE *file;
+ XPGetDocStatus status;
+ Bool done;
+} MyPrintFileData;
+
+
+static
+void *XpuPrintToFile( Display *pdpy, XPContext pcontext, const char *filename )
+{
+ MyPrintFileData *mpfd; /* warning: shared between threads !! */
+
+ if( (mpfd = malloc(sizeof(MyPrintFileData))) == NULL )
+ return(NULL);
+
+ mpfd->parent_pdpy = pdpy;
+ mpfd->displayname = XDisplayString(pdpy);
+ mpfd->pdpy = NULL;
+ mpfd->pcontext = pcontext;
+ mpfd->file_name = filename;
+ mpfd->file = NULL;
+ mpfd->status = XPGetDocError;
+
+ /* make sure we can open the file for writing */
+ if( (mpfd->file = fopen(mpfd->file_name, "w")) == NULL )
+ {
+ /* fopen() error */
+ free(mpfd);
+ return(NULL);
+ }
+
+ /* its important to flush before we start the consumer thread,
+ * to make sure that the XpStartJob gets through first in the parent
+ */
+ XFlush(pdpy);
+#ifdef XPU_USE_NSPR
+ if( (mpfd->prthread = PR_CreateThread(PR_SYSTEM_THREAD, PrintToFile_Consumer, mpfd, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0)) == NULL )
+#else
+ if( pthread_create(&(mpfd->tid), NULL, PrintToFile_Consumer, mpfd) != 0 )
+#endif
+ {
+ /* pthread_create() error */
+ fclose(mpfd->file);
+ free(mpfd);
+ return(NULL);
+ }
+
+ /* we're still in the parent */
+ XPU_DEBUG_ONLY(printf("### parent started consumer thread.\n" ));
+ return(mpfd);
+}
+
+
+XPGetDocStatus XpuWaitForPrintFileChild( void *handle )
+{
+ MyPrintFileData *mpfd = (MyPrintFileData *)handle;
+ void *res;
+ XPGetDocStatus status;
+
+ /* Flush data a last time to make sure we send all data to Xprt and that
+ * the Xlib internal hooks have called a last time */
+ XFlush(mpfd->parent_pdpy);
+
+#ifdef XPU_USE_NSPR
+ if( PR_JoinThread(mpfd->prthread) != PR_SUCCESS )
+ perror("XpuWaitForPrintFileChild: PR_JoinThread() failure"); /* fixme(later): use NSPR error handling calls... */
+#else
+ if( XPU_TRACE(pthread_join(mpfd->tid, &res)) != 0 )
+ perror("XpuWaitForPrintFileChild: pthread_join() failure");
+#endif
+
+ status = mpfd->status;
+ free(handle);
+
+ XPU_DEBUG_ONLY(PrintXPGetDocStatus(status));
+ return(status);
+}
+
+#else /* XPU_USE_THREADS */
+/**
+ ** XpuPrintToFile() - fork() version
+ ** Create consumer thread which creates it's own display connection to print server
+ ** (a 2nd display connection/process is required to avoid deadlocks within Xlib),
+ ** registers (Xlib-internal) consumer callback (via XpGetDocumentData(3Xp)) and
+ ** processes/eats all incoming events via MyPrintToFileProc(). A final call to
+ ** MyPrintToFileProc() cleans-up all stuff and sets the "done" flag.
+ ** Note that these callbacks are called directly by Xlib while waiting for events in
+ ** XNextEvent() because XpGetDocumentData() registeres them as "internal" callbacks,
+ ** e.g. XNextEvent() does _not_ return before/after processing these events !!
+ **
+ ** Usage:
+ ** XpStartJob(pdpy, XPGetData);
+ ** handle = XpuPrintToFile(pdpy, pcontext, "myfile");
+ ** // render something
+ ** XpEndJob(); // or XpCancelJob()
+ ** status = XpuWaitForPrintFileChild(handle);
+ **
+ */
+typedef struct
+{
+ pid_t pid;
+ int pipe[2]; /* child-->parent communication pipe */
+ const char *displayname;
+ Display *pdpy;
+ Display *parent_pdpy;
+ XPContext pcontext;
+ const char *file_name;
+ FILE *file;
+ XPGetDocStatus status;
+ Bool done;
+} MyPrintFileData;
+
+
+static
+void *XpuPrintToFile( Display *pdpy, XPContext pcontext, const char *filename )
+{
+ MyPrintFileData *mpfd;
+
+ if( (mpfd = (MyPrintFileData *)malloc(sizeof(MyPrintFileData))) == NULL )
+ return(NULL);
+
+ /* create pipe */
+ if( pipe(mpfd->pipe) == -1 )
+ {
+ /* this should never happen, but... */
+ perror("XpuPrintToFile: cannot create pipe");
+ free(mpfd);
+ return(NULL);
+ }
+
+ mpfd->parent_pdpy = pdpy;
+ mpfd->displayname = XDisplayString(pdpy);
+ mpfd->pcontext = pcontext;
+ mpfd->file_name = filename;
+ mpfd->file = NULL;
+ mpfd->status = XPGetDocError;
+
+ /* make sure we can open the file for writing */
+ if( (mpfd->file = fopen(mpfd->file_name, "w")) == NULL )
+ {
+ /* fopen() error */
+ close(mpfd->pipe[1]);
+ close(mpfd->pipe[0]);
+ free(mpfd);
+ return(NULL);
+ }
+
+ /* its important to flush before we fork, to make sure that the
+ * XpStartJob gets through first in the parent
+ */
+ XFlush(pdpy);
+
+ mpfd->pid = fork();
+
+ if( mpfd->pid == 0 )
+ {
+ /* we're now in the fork()'ed child */
+ PrintToFile_Consumer(mpfd);
+ }
+ else if( mpfd->pid < 0 )
+ {
+ /* fork() error */
+ close(mpfd->pipe[1]);
+ close(mpfd->pipe[0]);
+ fclose(mpfd->file);
+ free(mpfd);
+ return(NULL);
+ }
+
+ /* we're still in the parent */
+ XPU_DEBUG_ONLY(printf("### parent fork()'ed consumer child.\n"));
+
+ /* child will write into file - we don't need it anymore here... :-) */
+ fclose(mpfd->file);
+ close(mpfd->pipe[1]);
+ return(mpfd);
+}
+
+
+XPGetDocStatus XpuWaitForPrintFileChild( void *handle )
+{
+ MyPrintFileData *mpfd = (MyPrintFileData *)handle;
+ int res;
+ XPGetDocStatus status = XPGetDocError; /* used when read() from pipe fails */
+
+ /* Flush data a last time to make sure we send all data to Xprt and that
+ * the Xlib internal hooks have called a last time */
+ XFlush(mpfd->parent_pdpy);
+
+ if( XPU_TRACE(waitpid(mpfd->pid, &res, 0)) == -1 )
+ perror("XpuWaitForPrintFileChild: waitpid failure");
+
+ /* read the status from the child */
+ if( read(mpfd->pipe[0], &status, sizeof(XPGetDocStatus)) != sizeof(XPGetDocStatus) )
+ {
+ perror("XpuWaitForPrintFileChild: can't read XPGetDocStatus");
+ }
+ close(mpfd->pipe[0]);
+
+ free(handle);
+
+ XPU_DEBUG_ONLY(PrintXPGetDocStatus(status));
+ return(status);
+}
+#endif /* XPU_USE_THREADS */
+
+
+static
+void MyPrintToFileProc( Display *pdpy,
+ XPContext pcontext,
+ unsigned char *data,
+ unsigned int data_len,
+ XPointer client_data )
+{
+ MyPrintFileData *mpfd = (MyPrintFileData *)client_data;
+
+ /* write to the file */
+ XPU_TRACE_CHILD((void)fwrite(data, data_len, 1, mpfd->file)); /* what about error handling ? */
+}
+
+
+static
+void MyFinishProc( Display *pdpy,
+ XPContext pcontext,
+ XPGetDocStatus status,
+ XPointer client_data )
+{
+ MyPrintFileData *mpfd = (MyPrintFileData *)client_data;
+
+ /* remove the file if unsuccessful */
+ if( status != XPGetDocFinished )
+ {
+ XPU_DEBUG_ONLY(printf("MyFinishProc: error %d\n", (int)status));
+ XPU_TRACE_CHILD(remove(mpfd->file_name));
+ }
+
+ XPU_TRACE_CHILD((void)fclose(mpfd->file)); /* what about error handling ? */
+
+ mpfd->status = status;
+ mpfd->done = True;
+}
+
+
+static
+#ifdef XPU_USE_NSPR
+void PrintToFile_Consumer( void *handle )
+#else
+void *PrintToFile_Consumer( void *handle )
+#endif
+{
+ MyPrintFileData *mpfd = (MyPrintFileData *)handle;
+ XEvent dummy;
+ struct timeval timeout;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 100000; /* 1/10 s */
+
+ XPU_DEBUG_ONLY(printf("### child running, getting data from '%s'.\n", mpfd->displayname));
+
+ /* we cannot reuse fork()'ed display handles - our child needs his own one */
+ if( (mpfd->pdpy = XPU_TRACE_CHILD(XOpenDisplay(mpfd->displayname))) == NULL )
+ {
+ perror("child cannot open display");
+#ifdef XPU_USE_NSPR
+ return;
+#else
+ return(NULL);
+#endif
+ }
+
+ mpfd->done = False;
+
+ /* register "consumer" callbacks */
+ if( XPU_TRACE_CHILD(XpGetDocumentData(mpfd->pdpy, mpfd->pcontext,
+ MyPrintToFileProc, MyFinishProc,
+ (XPointer)mpfd)) == 0 )
+ {
+ XPU_DEBUG_ONLY(printf("XpGetDocumentData cannot register callbacks\n"));
+#ifdef XPU_USE_NSPR
+ return;
+#else
+ return(NULL);
+#endif
+ }
+
+ /* loop forever - libXp has registered hidden event callbacks for the consumer
+ * callbacks - the finishCB will call set the "done" boolean after all...
+ */
+ while( mpfd->done != True )
+ {
+ XNextEventTimeout(mpfd->pdpy, &dummy, &timeout);
+ }
+
+ XCloseDisplay(mpfd->pdpy);
+
+#ifdef XPU_USE_THREADS
+#ifdef XPU_USE_NSPR
+ return;
+#else
+ return(NULL);
+#endif
+#else
+ /* write the status to the parent */
+ if( XPU_TRACE_CHILD(write(mpfd->pipe[1], &mpfd->status, sizeof(XPGetDocStatus))) != sizeof(XPGetDocStatus) )
+ {
+ perror("PrintToFile_Consumer: can't write XPGetDocStatus");
+ }
+
+ /* we don't do any free's or close's, as we are just
+ * going to exit, in fact, get out without calling any C++
+ * destructors, etc., as we don't want anything funny to happen
+ * to the parent
+ */
+ XPU_TRACE_CHILD(_exit(EXIT_SUCCESS));
+#endif /* XPU_USE_THREADS */
+}
+
+/* EOF. */
diff --git a/nx-X11/lib/Xrandr/Imakefile b/nx-X11/lib/Xrandr/Imakefile
new file mode 100644
index 000000000..15167a9f6
--- /dev/null
+++ b/nx-X11/lib/Xrandr/Imakefile
@@ -0,0 +1,42 @@
+XCOMM $XFree86: xc/lib/Xrandr/Imakefile,v 1.1 2001/05/23 03:29:44 keithp Exp $
+XCOMM $XdotOrg: xc/lib/Xrandr/Imakefile,v 1.5 2005/10/24 23:30:21 alanc Exp $
+
+#define DoNormalLib NormalLibXrandr
+#define DoSharedLib SharedLibXrandr
+#define DoDebugLib DebugLibXrandr
+#define DoProfileLib ProfileLibXrandr
+#define LibName Xrandr
+#define SoRev SOXRANDRREV
+#define IncSubdir X11
+#define IncSubSubdir extensions
+
+#include <Threads.tmpl>
+
+#ifdef SharedXrandrReqs
+REQUIREDLIBS = SharedXrandrReqs
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ INCLUDES = -I. -I$(XLIBSRC) -I$(EXTINCSRC)
+ SRCS = Xrandr.c
+ OBJS = Xrandr.o
+ LINTLIBS = $(LINTXLIB)
+
+HEADERS = Xrandr.h
+
+#include <Library.tmpl>
+
+MANSUFFIX = $(LIBMANSUFFIX)
+
+#define PreprocessManPages
+InstallManPage(Xrandr,$(LIBMANDIR))
+
+#if ExpandManNames
+InstallManPageAliases(Xrandr,$(LIBMANDIR),XRRQueryExtension XRRQueryVersion XRRGetScreenInfo XRRFreeScreenConfigInfo XRRSetScreenConfig XRRSetScreenConfigAndRate XRRConfigRotations XRRConfigTimes XRRConfigSizes XRRConfigRates XRRConfigCurrentConfiguration XRRConfigCurrentRate XRRRootToScreen XRRScreenConfig XRRConfig XRRSelectInput)
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/Xrandr/Xrandr-def.cpp b/nx-X11/lib/Xrandr/Xrandr-def.cpp
new file mode 100644
index 000000000..8b0d8a754
--- /dev/null
+++ b/nx-X11/lib/Xrandr/Xrandr-def.cpp
@@ -0,0 +1,36 @@
+LIBRARY Xrandr
+VERSION LIBRARY_VERSION
+EXPORTS
+#ifndef __UNIXOS2__
+XRRCurrentConfig
+#endif
+ XRRFindDisplay
+#ifndef __UNIXOS2__
+XRRFreeScreenInfo
+#endif
+ XRRGetScreenInfo
+ XRRQueryExtension
+ XRRQueryVersion
+ XRRRootToScreen
+ XRRRotations
+#ifndef __UNIXOS2__
+XRRScreenChangeSelectInput
+#endif
+ XRRSetScreenConfig
+ XRRSizes
+ XRRTimes
+#ifndef __UNIXOS2__
+XRRVisualIDToVisual
+XRRVisualToDepth
+#else
+XRRConfigCurrentConfiguration
+XRRConfigSizes
+XRRConfigRotations
+XRRSelectInput
+XRRFreeScreenConfigInfo
+XRRUpdateConfiguration
+XRRConfigCurrentRate
+XRRConfigRates
+XRRSetScreenConfigAndRate
+#endif /* __UNIXOS2__
+/* $XFree86: xc/lib/Xrandr/Xrandr-def.cpp,v 1.1 2001/08/19 15:22:58 alanh Exp $ */
diff --git a/nx-X11/lib/Xrandr/Xrandr.c b/nx-X11/lib/Xrandr/Xrandr.c
new file mode 100644
index 000000000..32537b403
--- /dev/null
+++ b/nx-X11/lib/Xrandr/Xrandr.c
@@ -0,0 +1,744 @@
+/*
+ * $XFree86: xc/lib/Xrandr/Xrandr.c,v 1.13tsi Exp $
+ *
+ * Copyright © 2000 Compaq Computer Corporation, Inc.
+ * Copyright © 2002 Hewlett Packard Company, Inc.
+ *
+ * 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 of Compaq or HP not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. HP makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL COMPAQ
+ * 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.
+ *
+ * Author: Jim Gettys, HP Labs, HP.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+/* we need to be able to manipulate the Display structure on events */
+#include <X11/Xlibint.h>
+#include <X11/extensions/render.h>
+#include <X11/extensions/Xrender.h>
+#include "Xrandrint.h"
+
+XExtensionInfo XRRExtensionInfo;
+char XRRExtensionName[] = RANDR_NAME;
+
+static Bool XRRWireToEvent(Display *dpy, XEvent *event, xEvent *wire);
+static Status XRREventToWire(Display *dpy, XEvent *event, xEvent *wire);
+
+static XRRScreenConfiguration *_XRRGetScreenInfo (Display *dpy, Window window);
+
+static int
+XRRCloseDisplay (Display *dpy, XExtCodes *codes);
+
+static /* const */ XExtensionHooks rr_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ XRRCloseDisplay, /* close_display */
+ XRRWireToEvent, /* wire_to_event */
+ XRREventToWire, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static Bool XRRWireToEvent(Display *dpy, XEvent *event, xEvent *wire)
+{
+ XExtDisplayInfo *info = XRRFindDisplay(dpy);
+ XRRScreenChangeNotifyEvent *aevent;
+ xRRScreenChangeNotifyEvent *awire;
+
+ RRCheckExtension(dpy, info, False);
+
+ switch ((wire->u.u.type & 0x7F) - info->codes->first_event)
+ {
+ case RRScreenChangeNotify:
+ awire = (xRRScreenChangeNotifyEvent *) wire;
+ aevent = (XRRScreenChangeNotifyEvent *) event;
+ aevent->type = awire->type & 0x7F;
+ aevent->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *) wire);
+ aevent->send_event = (awire->type & 0x80) != 0;
+ aevent->display = dpy;
+ aevent->window = awire->window;
+ aevent->root = awire->root;
+ aevent->timestamp = awire->timestamp;
+ aevent->config_timestamp = awire->configTimestamp;
+ aevent->size_index = awire->sizeID;
+ aevent->subpixel_order = awire->subpixelOrder;
+ aevent->rotation = awire->rotation;
+ aevent->width = awire->widthInPixels;
+ aevent->height = awire->heightInPixels;
+ aevent->mwidth = awire->widthInMillimeters;
+ aevent->mheight = awire->heightInMillimeters;
+ return True;
+ }
+
+ return False;
+}
+
+static Status XRREventToWire(Display *dpy, XEvent *event, xEvent *wire)
+{
+ XExtDisplayInfo *info = XRRFindDisplay(dpy);
+ XRRScreenChangeNotifyEvent *aevent;
+ xRRScreenChangeNotifyEvent *awire;
+
+ RRCheckExtension(dpy, info, False);
+
+ switch ((event->type & 0x7F) - info->codes->first_event)
+ {
+ case RRScreenChangeNotify:
+ awire = (xRRScreenChangeNotifyEvent *) wire;
+ aevent = (XRRScreenChangeNotifyEvent *) event;
+ awire->type = aevent->type | (aevent->send_event ? 0x80 : 0);
+ awire->rotation = (CARD8) aevent->rotation;
+ awire->sequenceNumber = aevent->serial & 0xFFFF;
+ awire->timestamp = aevent->timestamp;
+ awire->configTimestamp = aevent->config_timestamp;
+ awire->root = aevent->root;
+ awire->window = aevent->window;
+ awire->sizeID = aevent->size_index;
+ awire->subpixelOrder = aevent->subpixel_order;
+ awire->widthInPixels = aevent->width;
+ awire->heightInPixels = aevent->height;
+ awire->widthInMillimeters = aevent->mwidth;
+ awire->heightInMillimeters = aevent->mheight;
+ return True;
+ }
+ return False;
+}
+
+XExtDisplayInfo *
+XRRFindDisplay (Display *dpy)
+{
+ XExtDisplayInfo *dpyinfo;
+ XRandRInfo *xrri;
+ int i, numscreens;
+
+ dpyinfo = XextFindDisplay (&XRRExtensionInfo, dpy);
+ if (!dpyinfo) {
+ dpyinfo = XextAddDisplay (&XRRExtensionInfo, dpy,
+ XRRExtensionName,
+ &rr_extension_hooks,
+ RRNumberEvents, 0);
+ numscreens = ScreenCount(dpy);
+ xrri = Xmalloc (sizeof(XRandRInfo) +
+ sizeof(char *) * numscreens);
+ xrri->config = (XRRScreenConfiguration **)(xrri + 1);
+ for(i = 0; i < numscreens; i++)
+ xrri->config[i] = NULL;
+ xrri->major_version = -1;
+ dpyinfo->data = (char *) xrri;
+ }
+ return dpyinfo;
+}
+
+static int
+XRRCloseDisplay (Display *dpy, XExtCodes *codes)
+{
+ int i;
+ XRRScreenConfiguration **configs;
+ XExtDisplayInfo *info = XRRFindDisplay (dpy);
+ XRandRInfo *xrri;
+
+ LockDisplay(dpy);
+ /*
+ * free cached data
+ */
+ if (XextHasExtension(info)) {
+ xrri = (XRandRInfo *) info->data;
+ if (xrri) {
+ configs = xrri->config;
+
+ for (i = 0; i < ScreenCount(dpy); i++) {
+ if (configs[i] != NULL) XFree (configs[i]);
+ }
+ XFree (xrri);
+ }
+ }
+ UnlockDisplay(dpy);
+ return XextRemoveDisplay (&XRRExtensionInfo, dpy);
+}
+
+
+Rotation XRRConfigRotations(XRRScreenConfiguration *config, Rotation *current_rotation)
+{
+ *current_rotation = config->current_rotation;
+ return config->rotations;
+}
+
+XRRScreenSize *XRRConfigSizes(XRRScreenConfiguration *config, int *nsizes)
+{
+ *nsizes = config->nsizes;
+ return config->sizes;
+}
+
+short *XRRConfigRates (XRRScreenConfiguration *config, int sizeID, int *nrates)
+{
+ short *r = config->rates;
+ int nents = config->nrates;
+
+ /* Skip over the intervening rate lists */
+ while (sizeID > 0 && nents > 0)
+ {
+ int i = (*r + 1);
+ r += i;
+ nents -= i;
+ sizeID--;
+ }
+ if (!nents)
+ {
+ *nrates = 0;
+ return 0;
+ }
+ *nrates = (int) *r;
+ return r + 1;
+}
+
+Time XRRConfigTimes (XRRScreenConfiguration *config, Time *config_timestamp)
+{
+ *config_timestamp = config->config_timestamp;
+ return config->timestamp;
+}
+
+
+SizeID XRRConfigCurrentConfiguration (XRRScreenConfiguration *config,
+ Rotation *rotation)
+{
+ *rotation = (Rotation) config->current_rotation;
+ return (SizeID) config->current_size;
+}
+
+short XRRConfigCurrentRate (XRRScreenConfiguration *config)
+{
+ return config->current_rate;
+}
+
+/*
+ * Go get the screen configuration data and salt it away for future use;
+ * returns NULL if extension not supported
+ */
+static XRRScreenConfiguration *_XRRValidateCache (Display *dpy, int screen)
+{
+ XExtDisplayInfo *info = XRRFindDisplay (dpy);
+ XRRScreenConfiguration **configs;
+ XRandRInfo *xrri;
+
+ if (XextHasExtension(info)) {
+ xrri = (XRandRInfo *) info->data;
+ configs = xrri->config;
+
+ if (configs[screen] == NULL)
+ configs[screen] = _XRRGetScreenInfo (dpy, RootWindow(dpy, screen));
+ return configs[screen];
+ } else {
+ return NULL;
+ }
+}
+
+/* given a screen, return the information from the (possibly) cached data */
+Rotation XRRRotations(Display *dpy, int screen, Rotation *current_rotation)
+{
+ XRRScreenConfiguration *config;
+ Rotation cr;
+ LockDisplay(dpy);
+ if ((config = _XRRValidateCache(dpy, screen))) {
+ *current_rotation = config->current_rotation;
+ cr = config->rotations;
+ UnlockDisplay(dpy);
+ return cr;
+ }
+ else {
+ UnlockDisplay(dpy);
+ *current_rotation = RR_Rotate_0;
+ return 0; /* no rotations supported */
+ }
+}
+
+/* given a screen, return the information from the (possibly) cached data */
+XRRScreenSize *XRRSizes(Display *dpy, int screen, int *nsizes)
+{
+ XRRScreenConfiguration *config;
+ XRRScreenSize *sizes;
+
+ LockDisplay(dpy);
+ if ((config = _XRRValidateCache(dpy, screen))) {
+ *nsizes = config->nsizes;
+ sizes = config->sizes;
+ UnlockDisplay(dpy);
+ return sizes;
+ }
+ else {
+ UnlockDisplay(dpy);
+ *nsizes = 0;
+ return NULL;
+ }
+}
+
+short *XRRRates (Display *dpy, int screen, int sizeID, int *nrates)
+{
+ XRRScreenConfiguration *config;
+ short *rates;
+
+ LockDisplay(dpy);
+ if ((config = _XRRValidateCache(dpy, screen))) {
+ rates = XRRConfigRates (config, sizeID, nrates);
+ UnlockDisplay(dpy);
+ return rates;
+ }
+ else {
+ UnlockDisplay(dpy);
+ *nrates = 0;
+ return NULL;
+ }
+}
+
+/* given a screen, return the information from the (possibly) cached data */
+Time XRRTimes (Display *dpy, int screen, Time *config_timestamp)
+{
+ XRRScreenConfiguration *config;
+ Time ts;
+
+ LockDisplay(dpy);
+ if ((config = _XRRValidateCache(dpy, screen))) {
+ *config_timestamp = config->config_timestamp;
+ ts = config->timestamp;
+ UnlockDisplay(dpy);
+ return ts;
+ } else {
+ UnlockDisplay(dpy);
+ return CurrentTime;
+ }
+}
+
+int XRRRootToScreen(Display *dpy, Window root)
+{
+ int snum;
+ for (snum = 0; snum < ScreenCount(dpy); snum++) {
+ if (RootWindow(dpy, snum) == root) return snum;
+ }
+ return -1;
+}
+
+
+Bool XRRQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = XRRFindDisplay (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+static Bool
+_XRRHasRates (int major, int minor)
+{
+ return major > 1 || (major == 1 && minor >= 1);
+}
+
+Status XRRQueryVersion (Display *dpy,
+ int *major_versionp,
+ int *minor_versionp)
+{
+ XExtDisplayInfo *info = XRRFindDisplay (dpy);
+ xRRQueryVersionReply rep;
+ xRRQueryVersionReq *req;
+ XRandRInfo *xrri;
+
+ RRCheckExtension (dpy, info, 0);
+
+ xrri = (XRandRInfo *) info->data;
+
+ /*
+ * only get the version information from the server if we don't have it already
+ */
+ if (xrri->major_version == -1) {
+ LockDisplay (dpy);
+ GetReq (RRQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->randrReqType = X_RRQueryVersion;
+ req->majorVersion = RANDR_MAJOR;
+ req->minorVersion = RANDR_MINOR;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ xrri->major_version = rep.majorVersion;
+ xrri->minor_version = rep.minorVersion;
+ xrri->has_rates = _XRRHasRates (xrri->major_version, xrri->minor_version);
+ }
+ *major_versionp = xrri->major_version;
+ *minor_versionp = xrri->minor_version;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
+typedef struct _randrVersionState {
+ unsigned long version_seq;
+ Bool error;
+ int major_version;
+ int minor_version;
+} _XRRVersionState;
+
+static Bool
+_XRRVersionHandler (Display *dpy,
+ xReply *rep,
+ char *buf,
+ int len,
+ XPointer data)
+{
+ xRRQueryVersionReply replbuf;
+ xRRQueryVersionReply *repl;
+ _XRRVersionState *state = (_XRRVersionState *) data;
+
+ if (dpy->last_request_read != state->version_seq)
+ return False;
+ if (rep->generic.type == X_Error)
+ {
+ state->error = True;
+ return False;
+ }
+ repl = (xRRQueryVersionReply *)
+ _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
+ (SIZEOF(xRRQueryVersionReply) - SIZEOF(xReply)) >> 2,
+ True);
+ state->major_version = repl->majorVersion;
+ state->minor_version = repl->minorVersion;
+ return True;
+}
+/* need a version that does not hold the display lock */
+static XRRScreenConfiguration *_XRRGetScreenInfo (Display *dpy, Window window)
+{
+ XExtDisplayInfo *info = XRRFindDisplay(dpy);
+ xRRGetScreenInfoReply rep;
+ xRRGetScreenInfoReq *req;
+ _XAsyncHandler async;
+ _XRRVersionState async_state;
+ int nbytes, nbytesRead, rbytes;
+ int i;
+ xScreenSizes size;
+ struct _XRRScreenConfiguration *scp;
+ XRRScreenSize *ssp;
+ short *rates;
+ xRRQueryVersionReq *vreq;
+ XRandRInfo *xrri;
+ Bool getting_version = False;
+
+ RRCheckExtension (dpy, info, 0);
+
+ xrri = (XRandRInfo *) info->data;
+
+ if (xrri->major_version == -1)
+ {
+ /* hide a version query in the request */
+ GetReq (RRQueryVersion, vreq);
+ vreq->reqType = info->codes->major_opcode;
+ vreq->randrReqType = X_RRQueryVersion;
+ vreq->majorVersion = RANDR_MAJOR;
+ vreq->minorVersion = RANDR_MINOR;
+
+ async_state.version_seq = dpy->request;
+ async_state.error = False;
+ async.next = dpy->async_handlers;
+ async.handler = _XRRVersionHandler;
+ async.data = (XPointer) &async_state;
+ dpy->async_handlers = &async;
+
+ getting_version = True;
+ }
+
+ GetReq (RRGetScreenInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->randrReqType = X_RRGetScreenInfo;
+ req->window = window;
+
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ if (getting_version)
+ DeqAsyncHandler (dpy, &async);
+ SyncHandle ();
+ return NULL;
+ }
+ if (getting_version)
+ {
+ DeqAsyncHandler (dpy, &async);
+ if (async_state.error)
+ {
+ SyncHandle();
+ }
+ xrri->major_version = async_state.major_version;
+ xrri->minor_version = async_state.minor_version;
+ xrri->has_rates = _XRRHasRates (xrri->minor_version, xrri->major_version);
+ }
+
+ /*
+ * Make the reply compatible with v1.1
+ */
+ if (!xrri->has_rates)
+ {
+ rep.rate = 0;
+ rep.nrateEnts = 0;
+ }
+
+ nbytes = (long) rep.length << 2;
+
+ nbytesRead = (long) (rep.nSizes * SIZEOF (xScreenSizes) +
+ ((rep.nrateEnts + 1)& ~1) * 2 /* SIZEOF (CARD16) */);
+
+ /*
+ * first we must compute how much space to allocate for
+ * randr library's use; we'll allocate the structures in a single
+ * allocation, on cleanlyness grounds.
+ */
+
+ rbytes = sizeof (XRRScreenConfiguration) +
+ (rep.nSizes * sizeof (XRRScreenSize) +
+ rep.nrateEnts * sizeof (int));
+
+ scp = (struct _XRRScreenConfiguration *) Xmalloc(rbytes);
+ if (scp == NULL) {
+ _XEatData (dpy, (unsigned long) nbytes);
+ SyncHandle ();
+ return NULL;
+ }
+
+
+ ssp = (XRRScreenSize *)(scp + 1);
+ rates = (short *) (ssp + rep.nSizes);
+
+ /* set up the screen configuration structure */
+ scp->screen =
+ ScreenOfDisplay (dpy, XRRRootToScreen(dpy, rep.root));
+
+ scp->sizes = ssp;
+ scp->rates = rates;
+ scp->rotations = rep.setOfRotations;
+ scp->current_size = rep.sizeID;
+ scp->current_rate = rep.rate;
+ scp->current_rotation = rep.rotation;
+ scp->timestamp = rep.timestamp;
+ scp->config_timestamp = rep.configTimestamp;
+ scp->nsizes = rep.nSizes;
+ scp->nrates = rep.nrateEnts;
+
+ /*
+ * Time to unpack the data from the server.
+ */
+
+ /*
+ * First the size information
+ */
+ for (i = 0; i < rep.nSizes; i++) {
+ _XReadPad (dpy, (char *) &size, SIZEOF (xScreenSizes));
+
+ ssp[i].width = size.widthInPixels;
+ ssp[i].height = size.heightInPixels;
+ ssp[i].mwidth = size.widthInMillimeters;
+ ssp[i].mheight = size.heightInMillimeters;
+ }
+ /*
+ * And the rates
+ */
+ _XRead16Pad (dpy, rates, 2 /* SIZEOF (CARD16) */ * rep.nrateEnts);
+
+ /*
+ * Skip any extra data
+ */
+ if (nbytes > nbytesRead)
+ _XEatData (dpy, (unsigned long) (nbytes - nbytesRead));
+
+ return (XRRScreenConfiguration *)(scp);
+}
+
+XRRScreenConfiguration *XRRGetScreenInfo (Display *dpy, Window window)
+{
+ XRRScreenConfiguration *config;
+ XRRFindDisplay(dpy);
+ LockDisplay (dpy);
+ config = _XRRGetScreenInfo(dpy, window);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return config;
+}
+
+
+void XRRFreeScreenConfigInfo (XRRScreenConfiguration *config)
+{
+ Xfree (config);
+}
+
+
+/*
+ * in protocol version 0.1, routine added to allow selecting for new events.
+ */
+
+void XRRSelectInput (Display *dpy, Window window, int mask)
+{
+ XExtDisplayInfo *info = XRRFindDisplay (dpy);
+ xRRSelectInputReq *req;
+
+ RRSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ GetReq (RRSelectInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->randrReqType = X_RRSelectInput;
+ req->window = window;
+ req->enable = 0;
+ if (mask) req->enable = mask;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return;
+}
+
+Status XRRSetScreenConfigAndRate (Display *dpy,
+ XRRScreenConfiguration *config,
+ Drawable draw,
+ int size_index,
+ Rotation rotation,
+ short rate,
+ Time timestamp)
+{
+ XExtDisplayInfo *info = XRRFindDisplay (dpy);
+ xRRSetScreenConfigReply rep;
+ XRandRInfo *xrri;
+ int major, minor;
+
+ RRCheckExtension (dpy, info, 0);
+
+ /* Make sure has_rates is set */
+ if (!XRRQueryVersion (dpy, &major, &minor))
+ return 0;
+
+ LockDisplay (dpy);
+ xrri = (XRandRInfo *) info->data;
+ if (xrri->has_rates)
+ {
+ xRRSetScreenConfigReq *req;
+ GetReq (RRSetScreenConfig, req);
+ req->reqType = info->codes->major_opcode;
+ req->randrReqType = X_RRSetScreenConfig;
+ req->drawable = draw;
+ req->sizeID = size_index;
+ req->rotation = rotation;
+ req->timestamp = timestamp;
+ req->configTimestamp = config->config_timestamp;
+ req->rate = rate;
+ }
+ else
+ {
+ xRR1_0SetScreenConfigReq *req;
+ GetReq (RR1_0SetScreenConfig, req);
+ req->reqType = info->codes->major_opcode;
+ req->randrReqType = X_RRSetScreenConfig;
+ req->drawable = draw;
+ req->sizeID = size_index;
+ req->rotation = rotation;
+ req->timestamp = timestamp;
+ req->configTimestamp = config->config_timestamp;
+ }
+
+ (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
+
+ if (rep.status == RRSetConfigSuccess) {
+ /* if we succeed, set our view of reality to what we set it to */
+ config->config_timestamp = rep.newConfigTimestamp;
+ config->timestamp = rep.newTimestamp;
+ config->screen = ScreenOfDisplay (dpy, XRRRootToScreen(dpy, rep.root));
+ config->current_size = size_index;
+ config->current_rotation = rotation;
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return(rep.status);
+}
+
+Status XRRSetScreenConfig (Display *dpy,
+ XRRScreenConfiguration *config,
+ Drawable draw,
+ int size_index,
+ Rotation rotation, Time timestamp)
+{
+ return XRRSetScreenConfigAndRate (dpy, config, draw, size_index,
+ rotation, 0, timestamp);
+}
+
+int XRRUpdateConfiguration(XEvent *event)
+{
+ XRRScreenChangeNotifyEvent *scevent;
+ XConfigureEvent *rcevent;
+ Display *dpy = event->xany.display;
+ XExtDisplayInfo *info;
+ XRandRInfo *xrri;
+ int snum;
+
+ /* first, see if it is a vanilla configure notify event */
+ if (event->type == ConfigureNotify) {
+ rcevent = (XConfigureEvent *) event;
+ snum = XRRRootToScreen(dpy, rcevent->window);
+ dpy->screens[snum].width = rcevent->width;
+ dpy->screens[snum].height = rcevent->height;
+ return 1;
+ }
+
+ info = XRRFindDisplay(dpy);
+ RRCheckExtension (dpy, info, 0);
+
+ switch (event->type - info->codes->first_event) {
+ case RRScreenChangeNotify:
+ scevent = (XRRScreenChangeNotifyEvent *) event;
+ snum = XRRRootToScreen(dpy,
+ ((XRRScreenChangeNotifyEvent *) event)->root);
+ if (scevent->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
+ dpy->screens[snum].width = scevent->height;
+ dpy->screens[snum].height = scevent->width;
+ dpy->screens[snum].mwidth = scevent->mheight;
+ dpy->screens[snum].mheight = scevent->mwidth;
+ } else {
+ dpy->screens[snum].width = scevent->width;
+ dpy->screens[snum].height = scevent->height;
+ dpy->screens[snum].mwidth = scevent->mwidth;
+ dpy->screens[snum].mheight = scevent->mheight;
+ }
+ XRenderSetSubpixelOrder (dpy, snum, scevent->subpixel_order);
+ break;
+ default:
+ return 0;
+ }
+ xrri = (XRandRInfo *) info->data;
+ /*
+ * so the next time someone wants some data, it will be fetched;
+ * it might be better to force the round trip immediately, but
+ * I dislike pounding the server simultaneously when not necessary
+ */
+ if (xrri->config[snum] != NULL) {
+ XFree (xrri->config[snum]);
+ xrri->config[snum] = NULL;
+ }
+ return 1;
+}
diff --git a/nx-X11/lib/Xrandr/Xrandr.h b/nx-X11/lib/Xrandr/Xrandr.h
new file mode 100644
index 000000000..6a4d7fe98
--- /dev/null
+++ b/nx-X11/lib/Xrandr/Xrandr.h
@@ -0,0 +1,151 @@
+/*
+ * $XFree86: xc/lib/Xrandr/Xrandr.h,v 1.9 2002/09/29 23:39:44 keithp Exp $
+ *
+ * Copyright © 2000 Compaq Computer Corporation, Inc.
+ * Copyright © 2002 Hewlett-Packard Company, Inc.
+ *
+ * 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 of Compaq not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. HP makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL COMPAQ
+ * 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.
+ *
+ * Author: Jim Gettys, HP Labs, HP.
+ */
+
+#ifndef _XRANDR_H_
+#define _XRANDR_H_
+
+#include <X11/extensions/randr.h>
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+
+typedef struct {
+ int width, height;
+ int mwidth, mheight;
+} XRRScreenSize;
+
+/*
+ * Events.
+ */
+
+typedef struct {
+ int type; /* event base */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* window which selected for this event */
+ Window root; /* Root window for changed screen */
+ Time timestamp; /* when the screen change occurred */
+ Time config_timestamp; /* when the last configuration change */
+ SizeID size_index;
+ SubpixelOrder subpixel_order;
+ Rotation rotation;
+ int width;
+ int height;
+ int mwidth;
+ int mheight;
+} XRRScreenChangeNotifyEvent;
+
+
+/* internal representation is private to the library */
+typedef struct _XRRScreenConfiguration XRRScreenConfiguration;
+
+Bool XRRQueryExtension (Display *dpy, int *event_basep, int *error_basep);
+Status XRRQueryVersion (Display *dpy,
+ int *major_versionp,
+ int *minor_versionp);
+
+XRRScreenConfiguration *XRRGetScreenInfo (Display *dpy,
+ Drawable draw);
+
+void XRRFreeScreenConfigInfo (XRRScreenConfiguration *config);
+
+/*
+ * Note that screen configuration changes are only permitted if the client can
+ * prove it has up to date configuration information. We are trying to
+ * insist that it become possible for screens to change dynamically, so
+ * we want to ensure the client knows what it is talking about when requesting
+ * changes.
+ */
+Status XRRSetScreenConfig (Display *dpy,
+ XRRScreenConfiguration *config,
+ Drawable draw,
+ int size_index,
+ Rotation rotation,
+ Time timestamp);
+
+/* added in v1.1, sorry for the lame name */
+Status XRRSetScreenConfigAndRate (Display *dpy,
+ XRRScreenConfiguration *config,
+ Drawable draw,
+ int size_index,
+ Rotation rotation,
+ short rate,
+ Time timestamp);
+
+
+Rotation XRRConfigRotations(XRRScreenConfiguration *config, Rotation *current_rotation);
+
+Time XRRConfigTimes (XRRScreenConfiguration *config, Time *config_timestamp);
+
+XRRScreenSize *XRRConfigSizes(XRRScreenConfiguration *config, int *nsizes);
+
+short *XRRConfigRates (XRRScreenConfiguration *config, int sizeID, int *nrates);
+
+SizeID XRRConfigCurrentConfiguration (XRRScreenConfiguration *config,
+ Rotation *rotation);
+
+short XRRConfigCurrentRate (XRRScreenConfiguration *config);
+
+int XRRRootToScreen(Display *dpy, Window root);
+
+/*
+ * returns the screen configuration for the specified screen; does a lazy
+ * evalution to delay getting the information, and caches the result.
+ * These routines should be used in preference to XRRGetScreenInfo
+ * to avoid unneeded round trips to the X server. These are new
+ * in protocol version 0.1.
+ */
+
+
+XRRScreenConfiguration *XRRScreenConfig(Display *dpy, int screen);
+XRRScreenConfiguration *XRRConfig(Screen *screen);
+void XRRSelectInput(Display *dpy, Window window, int mask);
+
+/*
+ * the following are always safe to call, even if RandR is not implemented
+ * on a screen
+ */
+
+
+Rotation XRRRotations(Display *dpy, int screen, Rotation *current_rotation);
+XRRScreenSize *XRRSizes(Display *dpy, int screen, int *nsizes);
+short *XRRRates (Display *dpy, int screen, int sizeID, int *nrates);
+Time XRRTimes (Display *dpy, int screen, Time *config_timestamp);
+
+
+/*
+ * intended to take RRScreenChangeNotify, or
+ * ConfigureNotify (on the root window)
+ * returns 1 if it is an event type it understands, 0 if not
+ */
+int XRRUpdateConfiguration(XEvent *event);
+
+_XFUNCPROTOEND
+
+#endif /* _XRANDR_H_ */
diff --git a/nx-X11/lib/Xrandr/Xrandr.man b/nx-X11/lib/Xrandr/Xrandr.man
new file mode 100644
index 000000000..f61d93044
--- /dev/null
+++ b/nx-X11/lib/Xrandr/Xrandr.man
@@ -0,0 +1,351 @@
+.\"
+.\" $XFree86: xc/lib/Xrandr/Xrandr.man,v 1.7 2003/08/04 10:32:21 eich Exp $
+.\" $XdotOrg: xc/lib/Xrandr/Xrandr.man,v 1.4 2005/10/13 02:56:42 alanc Exp $
+.\"
+.\" Copyright 2002 Hewlett-Packard Company.\"
+.\" 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 of Hewlett-Packard Company not be used in
+.\" advertising or publicity pertaining to distribution of the software without
+.\" specific, written prior permission. Hewlett Packard Company makes no
+.\" representations about the suitability of this software for any purpose. It
+.\" is provided "as is" without express or implied warranty.
+.\"
+.\" Hewlett-Packard DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+.\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+.\" EVENT SHALL KEITH PACKARD 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.
+.\"
+.de TQ
+.br
+.ns
+.TP \\$1
+..
+.TH XRANDR __libmansuffix__ __vendorversion__
+
+.SH NAME
+ Xrandr \- X Resize, Rotate and Reflection extension.
+.SH SYNTAX
+\&#include <X11/extensions/Xrandr.h>
+.nf
+.sp
+Bool XRRQueryExtension \^(\^Display *\fIdpy\fP,
+ int *\fIevent_basep\fP, int *\fIerror_basep\fP\^);
+.sp
+Status XRRQueryVersion \^(\^Display *\fIdpy\fP,
+ int *\fImajor_versionp\fP,
+ int *\fIminor_versionp\fP\^);
+.sp
+XRRScreenConfiguration *XRRGetScreenInfo \^(\^Display *dpy,
+ Drawable \fIdraw\fP\^);
+.sp
+void XRRFreeScreenConfigInfo \^(\^
+ \fIXRRScreenConfiguration *config\fP\^);
+.sp
+Status XRRSetScreenConfig \^(\^Display *\fIdpy\fP,
+ XRRScreenConfiguration *\fIconfig\fP,
+ Drawable \fIdraw\fP,
+ int \fIsize_index\fP,
+ Rotation \fIrotation\fP,
+ Time \fItimestamp\fP\^);
+.sp
+Status XRRSetScreenConfigAndRate \^(\^Display *\fIdpy\fP,
+ XRRScreenConfiguration *\fIconfig\fP,
+ Drawable \fIdraw\fP,
+ int \fIsize_index\fP,
+ Rotation \fIrotation\fP,
+ short \fIrate\fP,
+ Time \fItimestamp\fP\^);
+.sp
+Rotation XRRConfigRotations\^(\^
+ XRRScreenConfiguration *\fIconfig\fP,
+ Rotation *\fIcurrent_rotation\fP\^);
+.sp
+Time XRRConfigTimes \^(\^
+ XRRScreenConfiguration *\fIconfig\fP,
+ Time *\fIconfig_timestamp\fP\^);
+.sp
+XRRScreenSize *XRRConfigSizes\^(\^
+ XRRScreenConfiguration *\fIconfig\fP,
+ int *\fInsizes\fP\^);
+.sp
+short *XRRConfigRates \^(\^
+ XRRScreenConfiguration *\fIconfig\fP,
+ int \fIsize_index\fP,
+ int *\fInrates\fP\^);
+.sp
+SizeID XRRConfigCurrentConfiguration \^(\^
+ XRRScreenConfiguration *\fIconfig\fP,
+ Rotation *\fIrotation\fP\^);
+.sp
+short XRRConfigCurrentRate \^(\^
+ XRRScreenConfiguration *\fIconfig\fP\^);
+.sp
+int XRRRootToScreen\^(\^
+ Display *\fIdpy\fP,
+ Window \fIroot\fP\^);
+.sp
+XRRScreenConfiguration *XRRScreenConfig\^(\^
+ Display *\fIdpy\fP, int \fIscreen\fP\^);
+.sp
+XRRScreenConfiguration *XRRConfig\^(\^Screen *\fIscreen\fP\^);
+.sp
+void XRRSelectInput\^(\^Display *\fIdpy\fP, Window \fIwindow\fP, int \fImask\fP\^);
+.sp
+/\(**
+ * intended to take RRScreenChangeNotify, or
+ * ConfigureNotify \^(\^\fIon the root window\fP\^)
+ * returns 1 if it is an event type it understands, 0 if not
+ */
+int XRRUpdateConfiguration\^(\^XEvent *\fIevent\fP^);
+.sp
+/\(**
+ * the following are always safe to call, even if RandR is
+ * not implemented on a screen
+ */
+.br
+Rotation XRRRotations\^(\^
+ Display *\fIdpy\fP, int \fIscreen\fP,
+ Rotation *\fIcurrent_rotation\fP\^);
+.sp
+XRRScreenSize *XRRSizes\^(\^Display *\fIdpy\fP,
+ int \fIscreen\fP, int *\fInsizes\fP\^);
+.sp
+short *XRRRates \^(\^Display *\fIdpy\fP, int \fIscreen\fP,
+ int \fIsize_index\fP, int *\fInrates\fP\^);
+.sp
+Time XRRTimes \^(\^Display *\fIdpy\fP, int \fIscreen\fP, Time *\fIconfig_timestamp\fP\^);
+.fi
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIscreen\fP 1i
+Specifies which screen.
+.IP \fIdraw\fP 1i
+Specifies the screen.
+.IP \fIrotation\fP 1i
+Specifies the rotations or reflections possible of the screen.
+.IP \fIcurrent_rotation\fP 1i
+Specifies the current rotations and reflection of the screen.
+.IP \fItimestamp\fP 1i
+Specifies the server timestamp.
+.IP \fIconfig_timestamp\fP 1i
+Specifies the timestamp when the screen was last (re)configured.
+.IP \fIconfig\fP 1i
+Specifies the screen configuration being used.
+.IP \fIsizes\fP 1i
+Specifies the array of sizes supported.
+.IP \fIrate\fP 1i
+Specifies the refresh rate in Hz.
+
+.SH DATATYPES
+
+.PP
+.B Rotations/Reflections
+.PP
+Can be any of:
+.nf
+\&#define RR_Rotate_0 1
+\&#define RR_Rotate_90 2
+\&#define RR_Rotate_180 4
+\&#define RR_Rotate_270 8
+
+/\(** new in 1.0 protocol, to allow reflection of screen */
+/\(** reflection is applied after rotation */
+
+\&#define RR_Reflect_X 16
+\&#define RR_Reflect_Y 32
+
+
+typedef struct {
+ int width, height;
+ int mwidth, mheight;
+} XRRScreenSize;
+
+typedef struct {
+ int type; /\(** event base */
+ unsigned long serial; /\(** # of last request processed by server */
+ Bool send_event; /\(** true if this came from a SendEvent request */
+ Display *display; /\(** Display the event was read from */
+ Window window; /\(** window which selected for this event */
+ Window root; /\(** Root window for changed screen */
+ Time timestamp; /\(** when the screen change occurred */
+ Time config_timestamp; /\(** when the last configuration change */
+ SizeID size_index;
+ SubpixelOrder subpixel_order;
+ Rotation rotation;
+ int width;
+ int height;
+ int mwidth;
+ int mheight;
+} XRRScreenChangeNotifyEvent;
+.sp
+.fi
+.B XRRScreenSize
+structure contains a possible root size in pixels and in millimeters.
+.B XRRScreenChangeNotifyEvent
+Is sent to a client that has requested notification whenever the screen
+configuration is changed.
+
+.B XRRScreenConfiguration
+This is an opaque data type containing the configuration information
+for a screen.
+
+.B Timestamps
+.PP
+Time stamps are included and must be used to ensure the client is playing
+with a full deck: the screen may change properties
+on the fly and this ensures its knowledge of the configuration is up to date.
+This is to help issues when screens may become hot-pluggable in the future.
+
+.SH DESCRIPTION
+.B Xrandr
+is a simple library designed to interface the X Resize and Rotate
+Extension. This allows clients to change the size and rotation of the
+root window of a screen, along with the ability to reflect the screen
+about either axis (if supported by the implementation). Rotation and
+reflection may be implemented by software and may result in slower
+performance if rotation and reflection are implemented in this fashion
+(as are all implementations as of October 2002).
+.PP
+The Xrandr library does some minimal caching to avoid roundtrips to
+provide clients frequently used information. See "The X Resize and
+Rotate Extension" for a detailed description; also note that depth
+switching, as described in the document is not implemented, and may
+(or may not) ever be implemented, as display memory is growing rapidly,
+and toolkits are already beginning to support migration, mitigating the
+need for depth switching. If it is implemented in the future, we
+expect to do so via an upward compatible extension to the
+current library/protocol; functionality described here should continue
+to work.
+.PP
+Rotation and reflection and how they interact can be confusing. In
+Randr, the coordinate system is rotated in a counter-clockwise
+direction relative to the normal orientation. Reflection is along the
+window system coordinate system, not the physical screen X and Y axis,
+so that rotation and reflection do not interact. The other way to
+consider reflection is to is specified in the "normal" orientation,
+before rotation, if you find the other way confusing.
+.PP
+The
+.B XRRScreenChangeNotify
+event is sent to clients that ask to be informed whenever the root window
+configuration changes. Configuration changes may include resolution,
+physical size, subpixel order (see XRender(3)), and rotation. Note
+that changes to any or all of these could occur due to external events
+(user control in the X server, a different monitor/flat panel display
+being hot-plugged) and is not only the result of a protocol/library
+request to the X server.
+.PP
+Additionally, to eliminate a potential race condition,
+this event may be generated
+immediately upon selecting for notification if the screen has changed
+since the client of Xrandr connected to the X server, to enable
+reliable screen resolution changing when a user may log in and
+change the configuration while one or many clients are starting up.
+.PP
+.B Xlib notification
+.PP
+Clients must call back into Xlib using
+.B XRRUpdateConfiguration
+when screen configuration change notify events are generated
+(or root window configuration changes occur, to update Xlib's
+view of the resolution, size, rotation, reflection or subpixel order.
+Generally, toolkits will perform this operation on behalf of applications;
+we did not want to change display structure data behind the back of toolkits,
+as in multithreaded clients, various race conditions might occur.
+Toolkits should provide clients some mechanism for notification of
+screen change, of course.
+
+.SH FUNCTIONS
+There are two classes of interfaces: those which can be safely called
+even if RandR is not implemented on a screen (to make common idioms not
+dependent on the server having support), and those which will return
+errors if the extension is not present.
+.PP
+.B XRRRotations
+returns both the possible set of rotations/reflections supported
+(as a bitmask) as the value of the function, along with the current
+rotation/reflection of the screen.
+.PP
+.B XRRSizes
+returns the size and a pointer to the current sizes supported by
+the specified screen. The first size specified is the default size
+of the server. If RandR is not supported, it returns 0 for
+the number of sizes.
+.PP
+.B XRRRates
+returns a pointer to a the rates supported by the specified size.
+If RandR is not supported, it returns 0 for the number of rates.
+.PP
+.B XRRTimes
+returns the time last reported by the server along with the
+timestamp the last configuration changed.
+If the configuration has changed since the client last updated
+its view of the server time, requests to change the configuration
+will fail until the client has an up to date timestamp.
+.PP
+.B XRRRootToScreen
+returns the screen number given a root window (for example, from
+an \fBXRRScreenChangeNotifyEvent\fI.
+.PP
+The rest of the functions will fail if applied to screens not
+implementing the RandR extension.
+.B XRRSetScreenConfig
+sets the screen size and rotation and reflection to the desired
+values on the screen specified by \fIdraw\fP, or returns a
+.B BadValue
+error.
+\fIsize_index\fP specifies which size configuration is to be used,
+\fIrotation\fP specifies which rotation or reflection is to
+be used (or a
+.B BadValue
+error is returned).
+The \fItimestamp\fP is used by the server to make sure the client
+has up to date configuration information. Status is returned
+to indicate success or failure; a client must refresh its configuration
+information if it fails and try the call again (by calling
+\fBXRRGetScreenInfo\fP).
+.PP
+.B XRRSetScreenConfigAndRate
+like
+.B XRRSetScreenConfig
+but also set the refresh rate. If specified rate is not supported a
+.B BadValue
+error is returned.
+.PP
+.B XRRConfigRotations,
+.B XRRConfigSizes,
+.B XRRConfigCurrentConfiguration,
+.B XRRConfigTimes,
+.B XRRConfigRates,
+and
+.B XRRConfigCurrentRate
+are used to get specific configuration information out of a screen
+configuration.
+.PP
+.B XRRGetScreenInfo
+Returns a screen configuration for later use; the information is
+private to the library.
+Call
+.B XRRFreeScreenConfigInfo
+to free this information when you are finished with it.
+It forces a round trip to the server.
+
+Other functions include:
+.B XRRQueryExtension
+which returns the event and error base codes,
+.B XRRQueryVersion
+, which returns the current version of the extension (this information
+is cached by the library).
+.SH RESTRICTIONS
+.B Xrandr
+will remain upward compatible after the current 1.0 release.
+.SH AUTHOR
+Jim Gettys, and Keith Packard, HP.
+
diff --git a/nx-X11/lib/Xrandr/Xrandrint.h b/nx-X11/lib/Xrandr/Xrandrint.h
new file mode 100644
index 000000000..78a8fcf11
--- /dev/null
+++ b/nx-X11/lib/Xrandr/Xrandrint.h
@@ -0,0 +1,87 @@
+/*
+ * $XFree86: xc/lib/Xrandr/Xrandrint.h,v 1.2 2001/06/07 15:33:43 keithp Exp $
+ *
+ *
+ * Copyright © 2000, Compaq Computer Corporation,
+ * Copyright © 2002, Hewlett Packard, Inc.
+ *
+ * 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 of Compaq or HP not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. HP makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP
+ * 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.
+ *
+ * Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc.
+ */
+
+#ifndef _XRANDRINT_H_
+#define _XRANDRINT_H_
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include "Xrandr.h"
+#include <X11/extensions/randr.h>
+#include <X11/extensions/randrproto.h>
+
+extern XExtensionInfo XrandrExtensionInfo;
+extern char XrandrExtensionName[];
+
+#define RRCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, XRRExtensionName, val)
+#define RRSimpleCheckExtension(dpy,i) \
+ XextSimpleCheckExtension (dpy, i, XRRExtensionName)
+
+XExtDisplayInfo *XRRFindDisplay (Display *dpy);
+
+
+/* deliberately opaque internal data structure; can be extended,
+ but not reordered */
+struct _XRRScreenConfiguration {
+ Screen *screen; /* the root window in GetScreenInfo */
+ XRRScreenSize *sizes;
+ Rotation rotations;
+ Rotation current_rotation;
+ int nsizes;
+ int current_size;
+ short current_rate;
+ Time timestamp;
+ Time config_timestamp;
+ int subpixel_order; /* introduced in randr v0.1 */
+ short *rates; /* introduced in randr v1.1 */
+ int nrates;
+};
+
+/*
+ * if a configure notify on the root is recieved, or
+ * an XRRScreenChangeNotify is recieved,
+ * XRRUpdateConfiguration should be called to update the X library's
+ * view of the screen configuration; it will also invalidate the cache
+ * provided by XRRScreenConfig and XRRConfig, and force a round trip
+ * when next used. Returns invalid status if not an event type
+ * the library routine understand.
+ */
+
+/* we cache one screen configuration/screen */
+
+typedef struct _XRandRInfo {
+ XRRScreenConfiguration **config;
+ int major_version, minor_version; /* major_version = -1 means we don't know */
+ Bool has_rates; /* Server supports refresh rates */
+} XRandRInfo;
+
+#endif /* _XRANDRINT_H_ */
diff --git a/nx-X11/lib/Xrandr/test.c b/nx-X11/lib/Xrandr/test.c
new file mode 100644
index 000000000..01e67eba0
--- /dev/null
+++ b/nx-X11/lib/Xrandr/test.c
@@ -0,0 +1,21 @@
+/* $XFree86$ */
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include "Xrandr.h"
+
+main (int argc, char **argv)
+
+{
+ char *display_name = ":0";
+ Display *display;
+ int major, minor, status;
+
+ if ((display = XOpenDisplay (display_name)) == NULL) {
+ fprintf(stderr, "Can't open display!\n");
+ }
+ status = XRRQueryVersion (display, &major, &minor);
+ fprintf(stderr, "status = %d, major = %d, minor = %d\n,
+ status, major, minor");
+
+}
diff --git a/nx-X11/lib/Xrender/AUTHORS b/nx-X11/lib/Xrender/AUTHORS
new file mode 100644
index 000000000..5f6c46a80
--- /dev/null
+++ b/nx-X11/lib/Xrender/AUTHORS
@@ -0,0 +1,3 @@
+Keith Packard, of SuSE, XFree86 and Hewlett-Packard
+
+Noah Levitt, autotooling.
diff --git a/nx-X11/lib/Xrender/AddTrap.c b/nx-X11/lib/Xrender/AddTrap.c
new file mode 100644
index 000000000..3422a63c7
--- /dev/null
+++ b/nx-X11/lib/Xrender/AddTrap.c
@@ -0,0 +1,70 @@
+/*
+ * $Id: AddTrap.c,v 1.4 2005/07/03 07:00:57 daniels Exp $
+ *
+ * Copyright © 2004 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+#define NLOCAL 256
+
+void
+XRenderAddTraps (Display *dpy,
+ Picture picture,
+ int xOff,
+ int yOff,
+ _Xconst XTrap *traps,
+ int ntrap)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderAddTrapsReq *req;
+ int n;
+ long len;
+ unsigned long max_req = dpy->bigreq_size ? dpy->bigreq_size : dpy->max_request_size;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ while (ntrap)
+ {
+ GetReq(RenderAddTraps, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderAddTraps;
+ req->picture = picture;
+ req->xOff = xOff;
+ req->yOff = yOff;
+ n = ntrap;
+ len = ((long) n) * (SIZEOF (xTrap) >> 2);
+ if (len > (max_req - req->length)) {
+ n = (max_req - req->length) / (SIZEOF (xTrap) >> 2);
+ len = ((long)n) * (SIZEOF (xTrap) >> 2);
+ }
+ SetReqLen (req, len, len);
+ len <<= 2;
+ DataInt32 (dpy, (int *) traps, len);
+ ntrap -= n;
+ traps += n;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
diff --git a/nx-X11/lib/Xrender/COPYING b/nx-X11/lib/Xrender/COPYING
new file mode 100644
index 000000000..a232c2bea
--- /dev/null
+++ b/nx-X11/lib/Xrender/COPYING
@@ -0,0 +1,22 @@
+$Id: COPYING,v 1.2 2004/04/23 18:43:50 eich Exp $
+
+Copyright © 2001,2003 Keith Packard
+
+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 of Keith Packard not be used in
+advertising or publicity pertaining to distribution of the software without
+specific, written prior permission. Keith Packard makes no
+representations about the suitability of this software for any purpose. It
+is provided "as is" without express or implied warranty.
+
+KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL KEITH PACKARD 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.
+
diff --git a/nx-X11/lib/Xrender/ChangeLog b/nx-X11/lib/Xrender/ChangeLog
new file mode 100644
index 000000000..1fae6e0d2
--- /dev/null
+++ b/nx-X11/lib/Xrender/ChangeLog
@@ -0,0 +1,456 @@
+Thu May 19 15:22:19 2005 Søren Sandmann <sandmann@redhat.com>
+
+ * *.c: Conditionallyu include config.h
+
+2004-02-03 Jim Gettys <jg@freedesktop.org>
+
+ * AUTHORS: Get a author's list going.
+
+2004-01-15 Daniel Stone <daniel@fooishbar.org>
+ * Tag release 0.8.4 for first freedesktop.org clientside lib release.
+
+2004-01-15 Harold L Hunt II <huntharo@msu.edu>
+ * Makefile.am: Pass -no-undefined to libtool via LDFLAGS.
+
+2003-12-12 Keith Packard <keithp@keithp.com>
+
+ * configure.ac:
+ * xrender.pc.in:
+ Use Requires: in xrender.pc when x11.pc exists
+
+2003-06-08 10:56 keithp
+
+ * Filter.c, Makefile.am, Xrender.c, Xrenderint.h, configure.ac:
+ Bail on bogus Xsun servers, compile with -DXTHREADS if necessary,
+ get rid of unecessary cast to XRenderInfo *
+
+2003-05-06 09:05 branden
+
+ * ChangeLog: Huh. Did Keith tag xrender-0_8_2 *before* running
+ cvs2cl? Running it again.
+
+2003-05-05 20:56 keithp
+
+ * ChangeLog: Update ChangeLog with spiffy cvs2cl script (thanks
+ Branden)
+
+2003-05-05 20:49 keithp
+
+ * configure.ac: Update version to 0.8.2, add some version-related
+ comments
+
+2003-05-05 20:18 branden
+
+ * debian/: changelog, compat, control, copyright,
+ libxrender-dev.install, libxrender-dev.postrm,
+ libxrender-dev.preinst, libxrender1-dbg.install,
+ libxrender1-dbg.postrm, libxrender1-dbg.preinst,
+ libxrender1.install, libxrender1.postrm, libxrender1.preinst,
+ rules: Check in Debian packaging infrastructure per Keith's
+ request. This is the stuff that corresponds to Debian's xrender
+ 0.8.1-1 package.
+
+2003-05-05 19:06 keithp
+
+ * Xrenderint.h, configure.ac: Remove bogus Xext.h include. Fix
+ Render version comparison
+
+2003-05-03 13:00 keithp
+
+ * Makefile.am, configure.ac: Bump to version 0.8.1, library version
+ 1.2.2 after extutil was removed
+
+2003-04-26 08:52 nlevitt
+
+ * Xrenderint.h: Get rid of reference to XMissingExtension. It's in
+ libXext, which we don't link, and we don't want to print an error
+ message anyway.
+
+2003-04-23 20:29 nlevitt
+
+ * ChangeLog, Composite.c, Cursor.c, FillRect.c, FillRects.c,
+ Filter.c, Glyph.c, Makefile.am, Picture.c, Trap.c, Tri.c,
+ Xrender.c, Xrenderint.h, configure.ac, extutil.h, xrender.pc.in:
+ Get rid of libXext dependency.
+
+2003-04-22 09:59 nlevitt
+
+ * .cvsignore: Testing syncmail.
+
+2003-04-21 23:41 nlevitt
+
+ * xrender.pc.in: Xrender.h #includes render.h, so it needs the
+ Render CFLAGS.
+
+2003-04-21 23:12 nlevitt
+
+ * xrender.pc.in: s/@PACKAGE_VERSION@/@VERSION@/ (Jeff Waugh, bug
+ #71)
+
+2003-04-21 21:46 nlevitt
+
+ * Makefile.am, Xrenderint.h, configure.ac: Use local extutil.h if
+ not installed on the system.
+
+2003-04-21 10:36 keithp
+
+ * COPYING, ChangeLog, INSTALL, configure.ac: Fix render header
+ version check to use VERSION, eliminate duplicate version numbers
+ from configure.ac
+
+2003-04-21 10:22 keithp
+
+ * Color.c, Composite.c, Cursor.c, FillRects.c, Filter.c, Glyph.c,
+ Picture.c, Poly.c, Trap.c, Tri.c, Xrender-def.cpp, Xrender.h,
+ Xrenderint.h, extutil.h: Switch CVS id tags so regular CVS can cope
+
+2003-04-21 09:47 keithp
+
+ * Makefile.am: Xrender .so is 1.2. switch order of dependent
+ libraries
+
+2003-04-20 23:49 nlevitt
+
+ * FillRect.c: Testing syncmail again.
+
+2003-04-20 23:44 nlevitt
+
+ * Xrender.c: Testing syncmail.
+
+2003-04-19 16:02 nlevitt
+
+ * xrender.pc.in: Add X libs to pkg-config --libs.
+
+2003-04-19 11:32 nlevitt
+
+ * Makefile.am: Link with -lX11 -lXext.
+
+2003-04-19 11:21 nlevitt
+
+ * Makefile.am, Xrenderint.h, configure.ac: Use installed
+ <X11/extenstions/extutil.h>. (Thanks, jdub). Make sure X is found
+ at ./configure time. Bump .so version to 1.1.1.
+
+2003-04-17 17:43 nlevitt
+
+ * configure.ac: Xrender version is the same as Render.
+
+2003-04-17 16:41 nlevitt
+
+ * .cvsignore: Quiet, please.
+
+2003-04-17 15:53 nlevitt
+
+ * xrender.pc.in: Fix typo
+
+2003-04-17 15:49 nlevitt
+
+ * Imakefile, Makefile.am, Xrenderint.h, autogen.sh, configure.ac,
+ extutil.h, region.h, xrender.pc.in: Initial automake support.
+
+2003-03-24 20:18 dawes
+
+ * Xrender-def.cpp: 26. Updates for building on OS/2 (#5650, Frank
+ Giessler).
+
+2002-11-24 13:46 tsi
+
+ * Cursor.c: Warning fix
+
+2002-11-22 18:34 keithp
+
+ * Cursor.c, Xrender.h: Add animate cursor support, client side
+
+2002-11-21 18:10 keithp
+
+ * Xrender.c: Skip unexpected data in QueryFormats. Deal with
+ broken X servers a bit better
+
+2002-11-14 13:01 tsi
+
+ * Imakefile: First pass at imake warnings. + some ATI driver
+ formatting changes.
+
+ Please ensure these changes are reflected in DRI's CVS.
+
+2002-11-06 14:47 keithp
+
+ * Xrender.c, Xrender.h: XRenderQueryPictIndexValues support (from
+ Olivier Chapuis). Bump Render version to 0.7
+
+2002-11-05 15:22 keithp
+
+ * Glyph.c, Trap.c, Tri.c, Xrenderint.h: Render uses int for 32
+ bits, Xlib uses long. This matters on alpha
+
+2002-10-17 18:13 keithp
+
+ * Glyph.c: Miscomputing request length for String16 and String32
+
+2002-10-01 07:31 alanh
+
+ * Xrender-def.cpp: 358. Enable version controlled .dll's on
+ Cygwin/XFree86 (Alexander Gottwald).
+ 357. Some build fixes for Cygwin/XFree86 (Alan Hourihane).
+
+2002-09-29 16:39 keithp
+
+ * Xrender.c, Xrender.h: Update RandR to 1.0 (library version 2.0)
+
+2002-09-27 09:40 keithp
+
+ * Trap.c: Obey max request length even with BIG-REQUESTS
+
+2002-09-25 19:56 keithp
+
+ * Filter.c, Imakefile, Picture.c, Xrender.c, Xrender.h,
+ Xrenderint.h: Add image transformation and sub-pixel ordering to
+ Render
+
+2002-08-31 11:15 keithp
+
+ * Glyph.c: Remember not to write code at 1am.
+ CompositeText{8,16,32} werent switching glyphsets at the right
+ time.
+
+2002-08-30 23:52 keithp
+
+ * Glyph.c: CompositeGlyphs functions were re-using overwritten data
+ and trashing the output buffer
+
+2002-08-22 22:48 keithp
+
+ * Cursor.c, Imakefile, Xrender.h: Add CreateCursor request to
+ Render
+
+2002-07-24 08:26 tsi
+
+ * Imakefile: Make libXrender buildable in non-XFree86 environments.
+
+2002-06-07 11:04 keithp
+
+ * Imakefile: Get Xrender to build out of the XFree86 environment
+
+2002-06-04 16:22 keithp
+
+ * Poly.c: Free edges structure after drawing Render polygons
+
+2002-05-30 23:38 keithp
+
+ * Imakefile: Fix up support for building Xft1, Xrender and
+ fontconfig out of the tree
+
+2002-05-21 13:39 keithp
+
+ * Poly.c: Xrender library didnt render some concave polygons right
+
+2002-05-17 16:54 keithp
+
+ * Xrender.c: standard 1-bit render format had incorrect depth in
+ spec
+
+2002-05-17 15:34 keithp
+
+ * Color.c, Imakefile, Xrender.h: Add Render color parse routine for
+ rgba colorspace
+
+2002-05-16 23:54 keithp
+
+ * Poly.c: Another tesselation fix for Rendered polygons
+
+2002-05-16 08:28 tsi
+
+ * Poly.c: Warning fix
+
+2002-05-14 23:43 keithp
+
+ * Tri.c: Fix up triangle request encodings
+
+2002-05-14 23:42 keithp
+
+ * Xrender.c, Xrender.h: Add XRenderFindStandardFormat
+
+2002-05-14 23:39 keithp
+
+ * Poly.c: Redo tesselation to match foley and vanDam
+
+2002-05-13 00:21 keithp
+
+ * Poly.c: Make tesselation function do something reasonable
+
+2002-05-12 22:21 keithp
+
+ * Imakefile, Xrender.h, Poly.c, Trap.c, Tri.c: Update render
+ extension to include trapezoids
+
+2002-02-11 23:17 keithp
+
+ * Glyph.c: XRenderFreeGlyphs wasnt sending the glyphset
+
+2002-01-02 11:57 tsi
+
+ * Glyph.c, Xrender.h: Resync with today's trunk.
+
+2001-12-26 17:16 keithp
+
+ * Glyph.c, Xrender.h: Add Render equivalents of XPolyText*
+
+2001-12-18 09:08 tsi
+
+ * FillRect.c, FillRects.c, Glyph.c, Picture.c, Xrender.c,
+ Xrender.h: Another resync with HEAD branch.
+
+2001-12-16 10:27 keithp
+
+ * FillRect.c, FillRects.c, Glyph.c, Picture.c, Xrender.c,
+ Xrender.h: lib/Xrender: add a bunch of _Xconst to make c++ happier
+
+2001-10-10 20:26 keithp
+
+ * Xrender.c: Check malloc return for Xrender query reply temp data
+
+2001-09-05 13:13 mvojkovi
+
+ * Xrender.c:
+ Missing SyncHandle() in XRenderQueryFormats.
+
+2001-07-31 17:44 tsi
+
+ * Xrender.h: 168. Fix 16bpp colour maps on Mach64's (Marc La
+ France).
+ 167. Fix Mach64 DPMS bug (Marc La France).
+ 166. Fix bug that prevented hardware cursors on Mach64 CT's (Marc
+ La France).
+ 165. Document what a ChipAdjustFrame() function should to to
+ prevent moving
+ of hardware cursors during mode switches (Marc La France).
+ 164. -Wimplicit warning cleanup [`make World` >required<] (Marc La
+ France).
+ 163. Ensure installed headers can find the headers they, in turn,
+ #include
+ (Marc La France).
+ 162. Make imake pass its -W* flags to cpp (Marc La France).
+ 161. More accomodations for newer GCC's (Mike A. Harris).
+
+2001-07-06 13:46 keithp
+
+ * Xrender.c: Fix a couple of locking bugs in Xrender library
+
+2001-05-16 03:33 keithp
+
+ * Xrender.c: Clean up memory leaks in Xrender library
+
+2001-02-13 11:19 dawes
+
+ * Xrender-def.cpp: 135. Updates for Cygwin support (#4433, Suhaib
+ M. Siddiqi).
+ 134. Fix a bug in the fonts.sgml doc (#4432, Juliusz Chroboczek).
+ 133. Fix the xdpyinfo so that it will build when the XKB extension
+ isn't
+ defined (#4422, Jim Gettys).
+ 132. Fix the xdm greeter so that it will build when the XKB
+ extension isn't
+ defined (#4421, Jim Gettys).
+ 131. Only build setxkbmap when building the XKB lib support (based
+ on #4420,
+ Jim Gettys).
+ 130. Improve the mga driver messages when the HAL module isn't
+ available
+ (#4451, David Woodhouse).
+ 129. Add G450 support to the mga driver (#4416, Luugi Marsan
+ (Matrox),
+ 4449, David Woodhouse).
+ 128. Mga driver updates, including HAL cleanups, add a Crtc2Ram
+ option,
+ and merge with Matrox beta4 source (#4415, Antii Tapaninen,
+ #4423,
+ Simon Hosie).
+ 127. Fix a rounding problem in the wacom driver that was causing
+ some
+ position instability (#4417, Hannes Eriksson).
+
+2000-12-07 15:55 keithp
+
+ * Picture.c: Xrender: missing mask field in ChangePictureAttributes
+ request encoding
+
+2000-12-04 23:42 keithp
+
+ * Picture.c: Xft,Xrender: make clip rectangles actually work
+
+2000-12-04 19:13 keithp
+
+ * Picture.c, Xrender.h: Xft,Xrender,Render: c++ support, clip
+ rectangles, warnings
+
+2000-12-04 13:01 dawes
+
+ * Xrender-def.cpp: missing ident lines
+
+2000-12-04 10:49 dawes
+
+ * Xrender-def.cpp: 1085. Updates for Hurd support (#A.209, Marcus
+ Brinkmann). 1084. Bump the minor revisions of libXmu (UTF8_STRING)
+ and libX11 (Xutf8LookupString). 1083. Fixes for all known
+ bugs in the CompoundText parser and generator, (#4333, Bruno
+ Haible). 1082. Fix documentation for XSetOMValues() (#4332, Bruno
+ Haible). 1081. Fix namespace polution in <X11/Xlib.h> introduced
+ with patch #4293 (#4331, Bruno Haible). 1080. Fix a bug in
+ the newly introduced Xutf8LookupString() function that loses
+ input not representable in the locale encoding (#4330, Bruno
+ Haible). 1079. Avoid four new gcc warnings about const in lcUTF8.c
+ introduced by patch #4293 (#4329, Bruno Haible). 1078. Fix
+ some additional cases of confusing local typedef for wchar_t
+ (#4328, Bruno Haible). 1077. Fix some round-trip conversion errors
+ in COMPOUND_TEXT -> UTF8_STRING -> COMPOUND_TEXT due to wrong
+ tables introduced by patches #4214, 4215 (#4327, Pablo
+ Saratxaga). 1076. Cygwin update for building Xrender DLL (#4326,
+ Suhaib M. Siddiqi). 1075. Fix an undefined SUBDIRS in
+ xc/lib/GL/mesa/src/drv/Imakefile when compiling on something
+ other than x86, alpha or sparc (#4325, Brian Paul). 1074.
+ Don't have the neomagic driver disable stretching when a mode that
+ fills the panel is selected (#4324, Andrew C. Aitchison).
+ 1073. Fix a bug in Xlib's _XimLocalMbLookupString() that causes a
+ crash when a zero keycode keypress event is received (#4322,
+ HIBINO Kei).
+
+2000-12-03 15:41 keithp
+
+ * Xrender.h: Xrender: prototype using "template" collides with
+ reserved c++ word
+
+2000-12-02 01:38 keithp
+
+ * Glyph.c: Xrender: 16/32 bit glyph functions using wrong minor
+ request code
+
+2000-12-01 13:31 keithp
+
+ * Glyph.c, Picture.c, Xrender.c, Xrender.h: Xrender/Xft: handle
+ long strings, use unsigned int for 32-bit glyphs
+
+2000-11-29 00:25 keithp
+
+ * Glyph.c, Xrender.h: add 16/32 bit glyph rendering to Xrender
+ library
+
+2000-11-19 23:13 keithp
+
+ * FillRect.c, FillRects.c, Imakefile, Picture.c, Xrender.h: Add
+ component alpha to Render extension
+
+2000-08-27 19:43 tsi
+
+ * Composite.c, Glyph.c, Picture.c, Xrender.c, Xrender.h,
+ Xrenderint.h: Ident lines
+
+2000-08-26 09:37 keithp
+
+ * Imakefile: Get render library to actually build and install
+ correctly
+
+2000-08-25 17:38 keithp
+
+ * Composite.c, Glyph.c, Imakefile, Picture.c, Xrender.c, Xrender.h,
+ Xrenderint.h: Add Xrender library
+
diff --git a/nx-X11/lib/Xrender/Color.c b/nx-X11/lib/Xrender/Color.c
new file mode 100644
index 000000000..4f934f038
--- /dev/null
+++ b/nx-X11/lib/Xrender/Color.c
@@ -0,0 +1,92 @@
+/*
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+Status
+XRenderParseColor(Display *dpy, char *spec, XRenderColor *def)
+{
+
+ if (!strncmp (spec, "rgba:", 5))
+ {
+ unsigned short elements[4];
+ unsigned short *pShort;
+ int i, n;
+ char c;
+
+ spec += 5;
+ /*
+ * Attempt to parse the value portion.
+ */
+ pShort = elements;
+ for (i = 0; i < 4; i++, pShort++, spec++) {
+ n = 0;
+ *pShort = 0;
+ while (*spec != '/' && *spec != '\0') {
+ if (++n > 4) {
+ return 0;
+ }
+ c = *spec++;
+ *pShort <<= 4;
+ if (c >= '0' && c <= '9')
+ *pShort |= c - '0';
+ /* assume string in lowercase
+ else if (c >= 'A' && c <= 'F')
+ *pShort |= c - ('A' - 10);
+ */
+ else if (c >= 'a' && c <= 'f')
+ *pShort |= c - ('a' - 10);
+ else return 0;
+ }
+ if (n == 0)
+ return 0;
+ if (n < 4) {
+ *pShort = ((unsigned long)*pShort * 0xFFFF) / ((1 << n*4) - 1);
+ }
+ }
+ def->red = elements[0];
+ def->green = elements[1];
+ def->blue = elements[2];
+ def->alpha = elements[3];
+ }
+ else
+ {
+ XColor coreColor;
+ Colormap colormap;
+
+ colormap = DefaultColormap (dpy, DefaultScreen (dpy));
+ if (!XParseColor (dpy, colormap, spec, &coreColor))
+ return 0;
+ def->red = coreColor.red;
+ def->green = coreColor.green;
+ def->blue = coreColor.blue;
+ def->alpha = 0xffff;
+ }
+ def->red = (def->red * def->alpha) / 65535;
+ def->green = (def->green * def->alpha) / 65535;
+ def->blue = (def->blue * def->alpha) / 65535;
+ return 1;
+}
diff --git a/nx-X11/lib/Xrender/Composite.c b/nx-X11/lib/Xrender/Composite.c
new file mode 100644
index 000000000..07151ded9
--- /dev/null
+++ b/nx-X11/lib/Xrender/Composite.c
@@ -0,0 +1,67 @@
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+void
+XRenderComposite (Display *dpy,
+ int op,
+ Picture src,
+ Picture mask,
+ Picture dst,
+ int src_x,
+ int src_y,
+ int mask_x,
+ int mask_y,
+ int dst_x,
+ int dst_y,
+ unsigned int width,
+ unsigned int height)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeReq *req;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ GetReq(RenderComposite, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderComposite;
+ req->op = (CARD8) op;
+ req->src = src;
+ req->mask = mask;
+ req->dst = dst;
+ req->xSrc = src_x;
+ req->ySrc = src_y;
+ req->xMask = mask_x;
+ req->yMask = mask_y;
+ req->xDst = dst_x;
+ req->yDst = dst_y;
+ req->width = width;
+ req->height = height;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
diff --git a/nx-X11/lib/Xrender/Cursor.c b/nx-X11/lib/Xrender/Cursor.c
new file mode 100644
index 000000000..2679a9eaa
--- /dev/null
+++ b/nx-X11/lib/Xrender/Cursor.c
@@ -0,0 +1,79 @@
+/*
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+Cursor
+XRenderCreateCursor (Display *dpy,
+ Picture source,
+ unsigned int x,
+ unsigned int y)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ Cursor cid;
+ xRenderCreateCursorReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreateCursor, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreateCursor;
+ req->cid = cid = XAllocID (dpy);
+ req->src = source;
+ req->x = x;
+ req->y = y;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return cid;
+}
+
+Cursor
+XRenderCreateAnimCursor (Display *dpy,
+ int ncursor,
+ XAnimCursor *cursors)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ Cursor cid;
+ xRenderCreateAnimCursorReq *req;
+ long len;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreateAnimCursor, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreateAnimCursor;
+ req->cid = cid = XAllocID (dpy);
+
+ len = (long) ncursor * SIZEOF (xAnimCursorElt) >> 2;
+ SetReqLen (req, len, len);
+ len <<= 2;
+ Data32 (dpy, (long *) cursors, len);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return cid;
+}
diff --git a/nx-X11/lib/Xrender/FillRect.c b/nx-X11/lib/Xrender/FillRect.c
new file mode 100644
index 000000000..319c35d57
--- /dev/null
+++ b/nx-X11/lib/Xrender/FillRect.c
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define size (SIZEOF(xRenderFillRectanglesReq) + FRCTSPERBATCH * SIZEOF(xRectangle))
+
+void
+XRenderFillRectangle (Display *dpy,
+ int op,
+ Picture dst,
+ _Xconst XRenderColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRectangle *rect;
+ xRenderFillRectanglesReq *req;
+#ifdef MUSTCOPY
+ xRectangle rectdata;
+ long len = SIZEOF(xRectangle);
+
+ rect = &rectdata;
+#endif /* MUSTCOPY */
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ req = (xRenderFillRectanglesReq *) dpy->last_req;
+ /* if same as previous request, with same drawable, batch requests */
+ if (req->reqType == info->codes->major_opcode &&
+ req->renderReqType == X_RenderFillRectangles &&
+ req->op == op &&
+ req->dst == dst &&
+ req->color.red == color->red &&
+ req->color.green == color->green &&
+ req->color.blue == color->blue &&
+ req->color.alpha == color->alpha &&
+ 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(RenderFillRectangles, SIZEOF(xRectangle), req);
+
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderFillRectangles;
+ req->op = op;
+ req->dst = dst;
+ req->color.red = color->red;
+ req->color.green = color->green;
+ req->color.blue = color->blue;
+ req->color.alpha = color->alpha;
+
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xRectangle);
+#else
+ rect = (xRectangle *) NEXTPTR(req,xRenderFillRectanglesReq);
+#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();
+}
+
diff --git a/nx-X11/lib/Xrender/FillRects.c b/nx-X11/lib/Xrender/FillRects.c
new file mode 100644
index 000000000..517eeb0dc
--- /dev/null
+++ b/nx-X11/lib/Xrender/FillRects.c
@@ -0,0 +1,79 @@
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define size (SIZEOF(xRenderFillRectanglesReq) + FRCTSPERBATCH * SIZEOF(xRectangle))
+
+void
+XRenderFillRectangles (Display *dpy,
+ int op,
+ Picture dst,
+ _Xconst XRenderColor *color,
+ _Xconst XRectangle *rectangles,
+ int n_rects)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderFillRectanglesReq *req;
+ long len;
+ int n;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ while (n_rects)
+ {
+ GetReq(RenderFillRectangles, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderFillRectangles;
+ req->op = op;
+ req->dst = dst;
+ req->color.red = color->red;
+ req->color.green = color->green;
+ req->color.blue = color->blue;
+ req->color.alpha = color->alpha;
+
+ 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();
+}
+
diff --git a/nx-X11/lib/Xrender/Filter.c b/nx-X11/lib/Xrender/Filter.c
new file mode 100644
index 000000000..335f6b2e6
--- /dev/null
+++ b/nx-X11/lib/Xrender/Filter.c
@@ -0,0 +1,152 @@
+/*
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+XFilters *
+XRenderQueryFilters (Display *dpy, Drawable drawable)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderInfo *xri;
+ xRenderQueryFiltersReq *req;
+ xRenderQueryFiltersReply rep;
+ XFilters *filters;
+ char *name;
+ char len;
+ int i;
+ long nbytes, nbytesAlias, nbytesName;
+
+ if (!RenderHasExtension (info))
+ return 0;
+
+ if (!XRenderQueryFormats (dpy))
+ return 0;
+
+ xri = info->info;
+ if (xri->minor_version < 6)
+ return 0;
+
+ LockDisplay (dpy);
+ GetReq (RenderQueryFilters, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderQueryFilters;
+ req->drawable = drawable;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ /*
+ * Compute total number of bytes for filter names
+ */
+ nbytes = (long)rep.length << 2;
+ nbytesAlias = rep.numAliases * 2;
+ if (rep.numAliases & 1)
+ nbytesAlias += 2;
+ nbytesName = nbytes - nbytesAlias;
+
+ /*
+ * Allocate one giant block for the whole data structure
+ */
+ filters = Xmalloc (sizeof (XFilters) +
+ rep.numFilters * sizeof (char *) +
+ rep.numAliases * sizeof (short) +
+ nbytesName);
+
+ if (!filters)
+ {
+ _XEatData (dpy, (unsigned long) rep.length << 2);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+
+ /*
+ * Layout:
+ * XFilters
+ * numFilters char * pointers to filter names
+ * numAliases short alias values
+ * nbytesName char strings
+ */
+
+ filters->nfilter = rep.numFilters;
+ filters->nalias = rep.numAliases;
+ filters->filter = (char **) (filters + 1);
+ filters->alias = (short *) (filters->filter + rep.numFilters);
+ name = (char *) (filters->alias + rep.numAliases);
+
+ /*
+ * Read the filter aliases
+ */
+ _XRead16Pad (dpy, filters->alias, 2 * rep.numAliases);
+
+ /*
+ * Read the filter names
+ */
+ for (i = 0; i < rep.numFilters; i++)
+ {
+ int l;
+ _XRead (dpy, &len, 1);
+ l = len & 0xff;
+ filters->filter[i] = name;
+ _XRead (dpy, name, l);
+ name[l] = '\0';
+ name += l + 1;
+ }
+ i = name - (char *) (filters->alias + rep.numAliases);
+
+ if (i & 3)
+ _XEatData (dpy, 4 - (i & 3));
+
+ UnlockDisplay (dpy);
+ return filters;
+}
+
+void
+XRenderSetPictureFilter (Display *dpy,
+ Picture picture,
+ char *filter,
+ XFixed *params,
+ int nparams)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderSetPictureFilterReq *req;
+ int nbytes = strlen (filter);
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ GetReq(RenderSetPictureFilter, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderSetPictureFilter;
+ req->picture = picture;
+ req->nbytes = nbytes;
+ req->length += ((nbytes + 3) >> 2) + nparams;
+ Data (dpy, filter, nbytes);
+ Data32 (dpy, params, nparams << 2);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
diff --git a/nx-X11/lib/Xrender/Glyph.c b/nx-X11/lib/Xrender/Glyph.c
new file mode 100644
index 000000000..e25805f5c
--- /dev/null
+++ b/nx-X11/lib/Xrender/Glyph.c
@@ -0,0 +1,1169 @@
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+/*
+ * NX_RENDER_CLEANUP enables cleaning of padding bytes
+ */
+
+#define NX_RENDER_CLEANUP
+
+#define PANIC
+#define WARNING
+#undef TEST
+#undef DEBUG
+#undef DUMP
+
+#ifdef NX_RENDER_CLEANUP
+
+#include <stdio.h>
+
+#define ROUNDUP(nbits, pad) ((((nbits) + ((pad)-1)) / (pad)) * ((pad)>>3))
+
+#endif /* NX_RENDER_CLEANUP */
+
+GlyphSet
+XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ GlyphSet gsid;
+ xRenderCreateGlyphSetReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreateGlyphSet, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreateGlyphSet;
+ req->gsid = gsid = XAllocID(dpy);
+ req->format = format->id;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return gsid;
+}
+
+GlyphSet
+XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ GlyphSet gsid;
+ xRenderReferenceGlyphSetReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderReferenceGlyphSet, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderReferenceGlyphSet;
+ req->gsid = gsid = XAllocID(dpy);
+ req->existing = existing;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return gsid;
+}
+
+void
+XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderFreeGlyphSetReq *req;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ GetReq(RenderFreeGlyphSet, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderFreeGlyphSet;
+ req->glyphset = glyphset;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+#ifdef NX_RENDER_CLEANUP
+
+void
+XRenderCleanGlyphs(xGlyphInfo *gi,
+ int nglyphs,
+ CARD8 *images,
+ int depth,
+ Display *dpy)
+{
+
+ int widthInBits;
+ int bytesPerLine;
+ int bytesToClean;
+ int bitsToClean;
+ int widthInBytes;
+ int height = gi -> height;
+ register int i;
+ int j;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Found a Glyph with Depth %d, width %d, pad %d.\n",
+ depth, gi -> width, dpy -> bitmap_pad);
+ #endif
+
+ while (nglyphs > 0)
+ {
+ if (depth == 24)
+ {
+ widthInBits = gi -> width * 32;
+
+ bytesPerLine = ROUNDUP(widthInBits, dpy -> bitmap_pad);
+
+ bytesToClean = bytesPerLine * height;
+
+ #ifdef DUBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Found glyph with depth 24, bytes to clean is %d"
+ "width in bits is %d bytes per line [%d] height [%d].\n", bytesToClean,
+ widthInBits, bytesPerLine, height);
+ #endif
+
+ if (dpy -> byte_order == LSBFirst)
+ {
+ for (i = 3; i < bytesToClean; i += 4)
+ {
+ images[i] = 0x00;
+ }
+ }
+ else
+ {
+ for (i = 0; i < bytesToClean; i += 4)
+ {
+ images[i] = 0x00;
+ }
+ }
+
+ #ifdef DUMP
+ fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean);
+ for (i = 0; i < bytesPerLine; i++)
+ {
+ fprintf(stderr, "[%d]", images[i]);
+ }
+ fprintf(stderr,"\n");
+ #endif
+
+ images += bytesToClean;
+
+ gi++;
+
+ nglyphs--;
+ }
+ else if (depth == 1)
+ {
+ widthInBits = gi -> width;
+
+ bytesPerLine = ROUNDUP(widthInBits, dpy -> bitmap_pad);
+
+ bitsToClean = (bytesPerLine << 3) - (gi -> width);
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Found glyph with depth 1, width [%d], height [%d], bitsToClean [%d],"
+ " bytesPerLine [%d].\n", gi -> width, height, bitsToClean, bytesPerLine);
+ #endif
+
+ bytesToClean = bitsToClean >> 3;
+
+ bitsToClean &= 7;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: bitsToClean &=7 is %d, bytesToCLean is %d."
+ " byte_order is %d, bitmap_bit_order is %d.\n", bitsToClean, bytesToClean,
+ dpy -> byte_order, dpy -> bitmap_bit_order);
+ #endif
+
+ for (i = 1; i <= height; i++)
+ {
+ if (dpy -> byte_order == dpy -> bitmap_bit_order)
+ {
+ for (j = 1; j <= bytesToClean; j++)
+ {
+ images[i * bytesPerLine - j] = 0x00;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: byte_order = bitmap_bit_orde, cleaning %d, i=%d, j=%d.\n"
+ , (i * bytesPerLine - j), i, j);
+ #endif
+
+ }
+ }
+ else
+ {
+ for (j = bytesToClean; j >= 1; j--)
+ {
+ images[i * bytesPerLine - j] = 0x00;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: byte_order %d, bitmap_bit_order %d, cleaning %d, i=%d, j=%d.\n"
+ , dpy -> byte_order, dpy -> bitmap_bit_order, (i * bytesPerLine - j), i, j);
+ #endif
+
+ }
+ }
+
+ if (dpy -> bitmap_bit_order == MSBFirst)
+ {
+ images[i * bytesPerLine - j] &= 0xff << bitsToClean;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: byte_order MSBFirst, cleaning %d, i=%d, j=%d.\n"
+ , (i * bytesPerLine - j), i, j);
+ #endif
+ }
+ else
+ {
+ images[i * bytesPerLine - j] &= 0xff >> bitsToClean;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: byte_order LSBFirst, cleaning %d, i=%d, j=%d.\n"
+ , (i * bytesPerLine - j), i, j);
+ #endif
+ }
+ }
+
+ #ifdef DUMP
+ fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean);
+ for (i = 0; i < bytesPerLine; i++)
+ {
+ fprintf(stderr, "[%d]", images[i]);
+ }
+ fprintf(stderr,"\n");
+ #endif
+
+ images += bytesPerLine * height;
+
+ gi++;
+
+ nglyphs--;
+ }
+ else if ((depth == 8) || (depth == 16) )
+ {
+ widthInBits = gi -> width * depth;
+
+ bytesPerLine = ROUNDUP(widthInBits, dpy -> bitmap_pad);
+
+ widthInBytes = (widthInBits >> 3);
+
+ bytesToClean = bytesPerLine - widthInBytes;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: nglyphs is %d, width of glyph in bits is %d, in bytes is %d.\n",
+ nglyphs, widthInBits, widthInBytes);
+
+ fprintf(stderr, "nxagentCleanGlyphs: bytesPerLine is %d bytes, there are %d scanlines.\n", bytesPerLine, height);
+
+ fprintf(stderr, "nxagentCleanGlyphs: Bytes to clean for each scanline are %d.\n", bytesToClean);
+ #endif
+
+ if (bytesToClean > 0)
+ {
+ while (height > 0)
+ {
+ i = bytesToClean;
+
+ while (i > 0)
+ {
+ *(images + (bytesPerLine - i)) = 0;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: cleaned a byte.\n");
+ #endif
+
+ i--;
+ }
+
+ #ifdef DUMP
+ fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean);
+ for (i = 0; i < bytesPerLine; i++)
+ {
+ fprintf(stderr, "[%d]", images[i]);
+ }
+ fprintf(stderr,"\n");
+ #endif
+
+ images += bytesPerLine;
+
+ height--;
+ }
+ }
+
+ gi++;
+
+ nglyphs--;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Breaking Out.\n");
+ #endif
+ }
+ else if (depth == 32)
+ {
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Found glyph with depth 32.\n");
+ #endif
+
+ gi++;
+
+ nglyphs--;
+ }
+ else
+ {
+ #ifdef WARNING
+ fprintf(stderr, "nxagentCleanGlyphs: Unrecognized glyph, depth is not 8/16/24/32, it appears to be %d.\n",
+ depth);
+ #endif
+
+ gi++;
+
+ nglyphs--;
+ }
+ }
+}
+
+#endif /* #ifdef NX_RENDER_CLEANUP */
+
+void
+XRenderAddGlyphs (Display *dpy,
+ GlyphSet glyphset,
+ _Xconst Glyph *gids,
+ _Xconst XGlyphInfo *glyphs,
+ int nglyphs,
+ _Xconst char *images,
+ int nbyte_images)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderAddGlyphsReq *req;
+ long len;
+
+ if (nbyte_images & 3)
+ nbyte_images += 4 - (nbyte_images & 3);
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ GetReq(RenderAddGlyphs, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderAddGlyphs;
+ req->glyphset = glyphset;
+ req->nglyphs = nglyphs;
+ len = (nglyphs * (SIZEOF (xGlyphInfo) + 4) + nbyte_images) >> 2;
+ SetReqLen(req, len, len);
+ Data32 (dpy, (long *) gids, nglyphs * 4);
+ Data16 (dpy, (short *) glyphs, nglyphs * SIZEOF (xGlyphInfo));
+ Data (dpy, images, nbyte_images);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderFreeGlyphs (Display *dpy,
+ GlyphSet glyphset,
+ _Xconst Glyph *gids,
+ int nglyphs)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderFreeGlyphsReq *req;
+ long len;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ GetReq(RenderFreeGlyphs, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderFreeGlyphs;
+ req->glyphset = glyphset;
+ len = nglyphs;
+ SetReqLen(req, len, len);
+ len <<= 2;
+ Data32 (dpy, (long *) gids, len);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeString8 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst char *string,
+ int nchar)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs8Req *req;
+ long len;
+ xGlyphElt *elt;
+ int nbytes;
+
+ if (!nchar)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs8, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs8;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+ /*
+ * xGlyphElt must be aligned on a 32-bit boundary; this is
+ * easily done by filling no more than 252 glyphs in each
+ * bucket
+ */
+
+#define MAX_8 252
+
+ len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar;
+
+ req->length += (len + 3)>>2; /* convert to number of 32-bit words */
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first.
+ */
+
+ if (dpy->bufptr + len > dpy->bufmax)
+ _XFlush (dpy);
+
+ while(nchar > MAX_8)
+ {
+ nbytes = MAX_8 + SIZEOF(xGlyphElt);
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = MAX_8;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+ memcpy ((char *) (elt + 1), string, MAX_8);
+ nchar = nchar - MAX_8;
+ string += MAX_8;
+ }
+
+ if (nchar)
+ {
+ nbytes = (nchar + SIZEOF(xGlyphElt) + 3) & ~3;
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = nchar;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ memcpy ((char *) (elt + 1), string, nchar);
+ }
+#undef MAX_8
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+void
+XRenderCompositeString16 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst unsigned short *string,
+ int nchar)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs8Req *req;
+ long len;
+ xGlyphElt *elt;
+ int nbytes;
+
+ if (!nchar)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs16, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs16;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+#define MAX_16 254
+
+ len = SIZEOF(xGlyphElt) * ((nchar + MAX_16-1) / MAX_16) + nchar * 2;
+
+ req->length += (len + 3)>>2; /* convert to number of 32-bit words */
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first.
+ */
+
+ if (dpy->bufptr + len > dpy->bufmax)
+ _XFlush (dpy);
+
+ while(nchar > MAX_16)
+ {
+ nbytes = MAX_16 * 2 + SIZEOF(xGlyphElt);
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = MAX_16;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+ memcpy ((char *) (elt + 1), (char *) string, MAX_16 * 2);
+ nchar = nchar - MAX_16;
+ string += MAX_16;
+ }
+
+ if (nchar)
+ {
+ nbytes = (nchar * 2 + SIZEOF(xGlyphElt) + 3) & ~3;
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = nchar;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ memcpy ((char *) (elt + 1), (char *) string, nchar * 2);
+ }
+#undef MAX_16
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeString32 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst unsigned int *string,
+ int nchar)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs8Req *req;
+ long len;
+ xGlyphElt *elt;
+ int nbytes;
+
+ if (!nchar)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs32, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs32;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+#define MAX_32 254
+
+ len = SIZEOF(xGlyphElt) * ((nchar + MAX_32-1) / MAX_32) + nchar * 4;
+
+ req->length += (len + 3)>>2; /* convert to number of 32-bit words */
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first.
+ */
+
+ if (dpy->bufptr + len > dpy->bufmax)
+ _XFlush (dpy);
+
+ while(nchar > MAX_32)
+ {
+ nbytes = MAX_32 * 4 + SIZEOF(xGlyphElt);
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = MAX_32;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+ memcpy ((char *) (elt + 1), (char *) string, MAX_32 * 4);
+ nchar = nchar - MAX_32;
+ string += MAX_32;
+ }
+
+ if (nchar)
+ {
+ nbytes = nchar * 4 + SIZEOF(xGlyphElt);
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = nchar;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ memcpy ((char *) (elt + 1), (char *) string, nchar * 4);
+ }
+#undef MAX_32
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeText8 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt8 *elts,
+ int nelt)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs8Req *req;
+ GlyphSet glyphset;
+ long len;
+ long elen;
+ xGlyphElt *elt;
+ int i;
+ _Xconst char *chars;
+ int nchars;
+
+ #ifdef NX_RENDER_CLEANUP
+
+ char tmpChar[4];
+ int bytes_to_clean;
+ int bytes_to_write;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ if (!nelt)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs8, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs8;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = elts[0].glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+ /*
+ * Compute the space necessary
+ */
+ len = 0;
+
+#define MAX_8 252
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Check for glyphset change
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ len += (SIZEOF (xGlyphElt) + 4) >> 2;
+ }
+ nchars = elts[i].nchars;
+ /*
+ * xGlyphElt must be aligned on a 32-bit boundary; this is
+ * easily done by filling no more than 252 glyphs in each
+ * bucket
+ */
+ elen = SIZEOF(xGlyphElt) * ((nchars + MAX_8-1) / MAX_8) + nchars;
+ len += (elen + 3) >> 2;
+ }
+
+ req->length += len;
+
+ /*
+ * Send the glyphs
+ */
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Switch glyphsets
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
+
+ #ifdef NX_RENDER_CLEANUP
+
+ elt->pad1 = 0;
+ elt->pad2 = 0;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ elt->len = 0xff;
+ elt->deltax = 0;
+ elt->deltay = 0;
+ Data32(dpy, &glyphset, 4);
+ }
+ nchars = elts[i].nchars;
+ xDst = elts[i].xOff;
+ yDst = elts[i].yOff;
+ chars = elts[i].chars;
+ while (nchars)
+ {
+ int this_chars = nchars > MAX_8 ? MAX_8 : nchars;
+
+ BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
+
+ #ifdef NX_RENDER_CLEANUP
+
+ elt->pad1 = 0;
+ elt->pad2 = 0;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ elt->len = this_chars;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+
+ #ifdef NX_RENDER_CLEANUP
+
+ bytes_to_write = this_chars & ~3;
+
+ bytes_to_clean = ((this_chars + 3) & ~3) - this_chars;
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText8: bytes_to_write %d, bytes_to_clean are %d,"
+ " this_chars %d.\n", bytes_to_write, bytes_to_clean, this_chars);
+ #endif
+
+ if (bytes_to_clean > 0)
+ {
+ if (bytes_to_write > 0)
+ {
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText8: found %d clean bytes, bytes_to_clean are %d,"
+ " this_chars %d.\n", bytes_to_write, bytes_to_clean, this_chars);
+ #endif
+
+ Data (dpy, chars, bytes_to_write);
+ chars += bytes_to_write;
+ }
+
+ bytes_to_write = this_chars % 4;
+ memcpy (tmpChar, chars, bytes_to_write);
+ chars += bytes_to_write;
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText8: last 32 bit, bytes_to_write are %d,"
+ " bytes_to_clean are %d, this_chars are %d.\n", bytes_to_write, bytes_to_clean, this_chars);
+ #endif
+
+ #ifdef DUMP
+ fprintf(stderr, "XRenderCompositeText8: bytes_to_clean %d, ", bytes_to_clean);
+ #endif
+
+ while (bytes_to_clean > 0)
+ {
+ tmpChar[4 - bytes_to_clean] = 0;
+ bytes_to_clean--;
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText8: Cleaned %d byte.\n", 4 - bytes_to_clean);
+ #endif
+ }
+
+ Data (dpy, tmpChar, 4);
+ nchars -= this_chars;
+
+ #ifdef DUMP
+ fprintf(stderr, "Data: ");
+ for (i = 0; i < 4; i++)
+ {
+ fprintf(stderr, "[%d]", tmpChar[i]);
+ }
+ fprintf(stderr,"\n");
+ #endif
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText8: nchars now is %d.\n", nchars);
+ #endif
+
+ continue;
+ }
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ Data (dpy, chars, this_chars);
+ nchars -= this_chars;
+ chars += this_chars;
+ }
+ }
+#undef MAX_8
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeText16 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt16 *elts,
+ int nelt)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs16Req *req;
+ GlyphSet glyphset;
+ long len;
+ long elen;
+ xGlyphElt *elt;
+ int i;
+ _Xconst unsigned short *chars;
+ int nchars;
+
+ #ifdef NX_RENDER_CLEANUP
+
+ int bytes_to_write;
+ int bytes_to_clean;
+ char tmpChar[4];
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ if (!nelt)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs16, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs16;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = elts[0].glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+ /*
+ * Compute the space necessary
+ */
+ len = 0;
+
+#define MAX_16 254
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Check for glyphset change
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ len += (SIZEOF (xGlyphElt) + 4) >> 2;
+ }
+ nchars = elts[i].nchars;
+ /*
+ * xGlyphElt must be aligned on a 32-bit boundary; this is
+ * easily done by filling no more than 254 glyphs in each
+ * bucket
+ */
+ elen = SIZEOF(xGlyphElt) * ((nchars + MAX_16-1) / MAX_16) + nchars * 2;
+ len += (elen + 3) >> 2;
+ }
+
+ req->length += len;
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Switch glyphsets
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
+
+ #ifdef NX_RENDER_CLEANUP
+
+ elt->pad1 = 0;
+ elt->pad2 = 0;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ elt->len = 0xff;
+ elt->deltax = 0;
+ elt->deltay = 0;
+ Data32(dpy, &glyphset, 4);
+ }
+ nchars = elts[i].nchars;
+ xDst = elts[i].xOff;
+ yDst = elts[i].yOff;
+ chars = elts[i].chars;
+ while (nchars)
+ {
+ int this_chars = nchars > MAX_16 ? MAX_16 : nchars;
+ int this_bytes = this_chars * 2;
+
+ BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
+
+ #ifdef NX_RENDER_CLEANUP
+
+ elt->pad1 = 0;
+ elt->pad2 = 0;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ elt->len = this_chars;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+
+ #ifdef NX_RENDER_CLEANUP
+
+ bytes_to_write = this_bytes & ~3;
+ bytes_to_clean = ((this_bytes + 3) & ~3) - this_bytes;
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText16: this_chars %d, this_bytes %d.\n"
+ "bytes_to_write %d, bytes_to_clean are %d.\n", this_chars, this_bytes,
+ bytes_to_write, bytes_to_clean);
+ #endif
+
+ if (bytes_to_clean > 0)
+ {
+ if (bytes_to_write > 0)
+ {
+ Data16 (dpy, chars, bytes_to_write);
+
+ /*
+ * Cast chars to avoid errors with pointer arithmetic.
+ */
+
+ chars = (unsigned short *) ((char *) chars + bytes_to_write);
+ }
+
+ bytes_to_write = this_bytes % 4;
+ memcpy (tmpChar, (char *) chars, bytes_to_write);
+ chars = (unsigned short *) ((char *) chars + bytes_to_write);
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText16: last 32 bit, bytes_to_write are %d,"
+ " bytes_to_clean are %d.\n", bytes_to_write, bytes_to_clean);
+ #endif
+
+ while (bytes_to_clean > 0)
+ {
+ tmpChar[4 - bytes_to_clean] = 0;
+ bytes_to_clean--;
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText16: Cleaned %d byte.\n", 4 - bytes_to_clean);
+ #endif
+ }
+
+ Data16 (dpy, tmpChar, 4);
+ nchars -= this_chars;
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText16: nchars now is %d.\n", nchars);
+ #endif
+
+ continue;
+ }
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ Data16 (dpy, chars, this_bytes);
+ nchars -= this_chars;
+ chars += this_chars;
+ }
+ }
+#undef MAX_16
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeText32 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt32 *elts,
+ int nelt)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs32Req *req;
+ GlyphSet glyphset;
+ long len;
+ long elen;
+ xGlyphElt *elt;
+ int i;
+ _Xconst unsigned int *chars;
+ int nchars;
+
+ if (!nelt)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+
+ GetReq(RenderCompositeGlyphs32, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs32;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = elts[0].glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+ /*
+ * Compute the space necessary
+ */
+ len = 0;
+
+#define MAX_32 254
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Check for glyphset change
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ len += (SIZEOF (xGlyphElt) + 4) >> 2;
+ }
+ nchars = elts[i].nchars;
+ elen = SIZEOF(xGlyphElt) * ((nchars + MAX_32) / MAX_32) + nchars *4;
+ len += (elen + 3) >> 2;
+ }
+
+ req->length += len;
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Switch glyphsets
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
+
+ #ifdef NX_RENDER_CLEANUP
+
+ elt->pad1 = 0;
+ elt->pad2 = 0;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ elt->len = 0xff;
+ elt->deltax = 0;
+ elt->deltay = 0;
+ Data32(dpy, &glyphset, 4);
+ }
+ nchars = elts[i].nchars;
+ xDst = elts[i].xOff;
+ yDst = elts[i].yOff;
+ chars = elts[i].chars;
+ while (nchars)
+ {
+ int this_chars = nchars > MAX_32 ? MAX_32 : nchars;
+ int this_bytes = this_chars * 4;
+ BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
+
+ #ifdef NX_RENDER_CLEANUP
+
+ elt->pad1 = 0;
+ elt->pad2 = 0;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ elt->len = this_chars;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+
+ #ifdef TEST
+ fprintf(stderr, "XRenderCompositeText32: this_chars %d, this_bytes %d.\n",
+ this_chars, this_bytes);
+ #endif
+
+ DataInt32 (dpy, chars, this_bytes);
+ nchars -= this_chars;
+ chars += this_chars;
+ }
+ }
+#undef MAX_32
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
diff --git a/nx-X11/lib/Xrender/Glyph.c.NX.original b/nx-X11/lib/Xrender/Glyph.c.NX.original
new file mode 100644
index 000000000..e25805f5c
--- /dev/null
+++ b/nx-X11/lib/Xrender/Glyph.c.NX.original
@@ -0,0 +1,1169 @@
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+/*
+ * NX_RENDER_CLEANUP enables cleaning of padding bytes
+ */
+
+#define NX_RENDER_CLEANUP
+
+#define PANIC
+#define WARNING
+#undef TEST
+#undef DEBUG
+#undef DUMP
+
+#ifdef NX_RENDER_CLEANUP
+
+#include <stdio.h>
+
+#define ROUNDUP(nbits, pad) ((((nbits) + ((pad)-1)) / (pad)) * ((pad)>>3))
+
+#endif /* NX_RENDER_CLEANUP */
+
+GlyphSet
+XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ GlyphSet gsid;
+ xRenderCreateGlyphSetReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreateGlyphSet, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreateGlyphSet;
+ req->gsid = gsid = XAllocID(dpy);
+ req->format = format->id;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return gsid;
+}
+
+GlyphSet
+XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ GlyphSet gsid;
+ xRenderReferenceGlyphSetReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderReferenceGlyphSet, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderReferenceGlyphSet;
+ req->gsid = gsid = XAllocID(dpy);
+ req->existing = existing;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return gsid;
+}
+
+void
+XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderFreeGlyphSetReq *req;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ GetReq(RenderFreeGlyphSet, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderFreeGlyphSet;
+ req->glyphset = glyphset;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+#ifdef NX_RENDER_CLEANUP
+
+void
+XRenderCleanGlyphs(xGlyphInfo *gi,
+ int nglyphs,
+ CARD8 *images,
+ int depth,
+ Display *dpy)
+{
+
+ int widthInBits;
+ int bytesPerLine;
+ int bytesToClean;
+ int bitsToClean;
+ int widthInBytes;
+ int height = gi -> height;
+ register int i;
+ int j;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Found a Glyph with Depth %d, width %d, pad %d.\n",
+ depth, gi -> width, dpy -> bitmap_pad);
+ #endif
+
+ while (nglyphs > 0)
+ {
+ if (depth == 24)
+ {
+ widthInBits = gi -> width * 32;
+
+ bytesPerLine = ROUNDUP(widthInBits, dpy -> bitmap_pad);
+
+ bytesToClean = bytesPerLine * height;
+
+ #ifdef DUBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Found glyph with depth 24, bytes to clean is %d"
+ "width in bits is %d bytes per line [%d] height [%d].\n", bytesToClean,
+ widthInBits, bytesPerLine, height);
+ #endif
+
+ if (dpy -> byte_order == LSBFirst)
+ {
+ for (i = 3; i < bytesToClean; i += 4)
+ {
+ images[i] = 0x00;
+ }
+ }
+ else
+ {
+ for (i = 0; i < bytesToClean; i += 4)
+ {
+ images[i] = 0x00;
+ }
+ }
+
+ #ifdef DUMP
+ fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean);
+ for (i = 0; i < bytesPerLine; i++)
+ {
+ fprintf(stderr, "[%d]", images[i]);
+ }
+ fprintf(stderr,"\n");
+ #endif
+
+ images += bytesToClean;
+
+ gi++;
+
+ nglyphs--;
+ }
+ else if (depth == 1)
+ {
+ widthInBits = gi -> width;
+
+ bytesPerLine = ROUNDUP(widthInBits, dpy -> bitmap_pad);
+
+ bitsToClean = (bytesPerLine << 3) - (gi -> width);
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Found glyph with depth 1, width [%d], height [%d], bitsToClean [%d],"
+ " bytesPerLine [%d].\n", gi -> width, height, bitsToClean, bytesPerLine);
+ #endif
+
+ bytesToClean = bitsToClean >> 3;
+
+ bitsToClean &= 7;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: bitsToClean &=7 is %d, bytesToCLean is %d."
+ " byte_order is %d, bitmap_bit_order is %d.\n", bitsToClean, bytesToClean,
+ dpy -> byte_order, dpy -> bitmap_bit_order);
+ #endif
+
+ for (i = 1; i <= height; i++)
+ {
+ if (dpy -> byte_order == dpy -> bitmap_bit_order)
+ {
+ for (j = 1; j <= bytesToClean; j++)
+ {
+ images[i * bytesPerLine - j] = 0x00;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: byte_order = bitmap_bit_orde, cleaning %d, i=%d, j=%d.\n"
+ , (i * bytesPerLine - j), i, j);
+ #endif
+
+ }
+ }
+ else
+ {
+ for (j = bytesToClean; j >= 1; j--)
+ {
+ images[i * bytesPerLine - j] = 0x00;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: byte_order %d, bitmap_bit_order %d, cleaning %d, i=%d, j=%d.\n"
+ , dpy -> byte_order, dpy -> bitmap_bit_order, (i * bytesPerLine - j), i, j);
+ #endif
+
+ }
+ }
+
+ if (dpy -> bitmap_bit_order == MSBFirst)
+ {
+ images[i * bytesPerLine - j] &= 0xff << bitsToClean;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: byte_order MSBFirst, cleaning %d, i=%d, j=%d.\n"
+ , (i * bytesPerLine - j), i, j);
+ #endif
+ }
+ else
+ {
+ images[i * bytesPerLine - j] &= 0xff >> bitsToClean;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: byte_order LSBFirst, cleaning %d, i=%d, j=%d.\n"
+ , (i * bytesPerLine - j), i, j);
+ #endif
+ }
+ }
+
+ #ifdef DUMP
+ fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean);
+ for (i = 0; i < bytesPerLine; i++)
+ {
+ fprintf(stderr, "[%d]", images[i]);
+ }
+ fprintf(stderr,"\n");
+ #endif
+
+ images += bytesPerLine * height;
+
+ gi++;
+
+ nglyphs--;
+ }
+ else if ((depth == 8) || (depth == 16) )
+ {
+ widthInBits = gi -> width * depth;
+
+ bytesPerLine = ROUNDUP(widthInBits, dpy -> bitmap_pad);
+
+ widthInBytes = (widthInBits >> 3);
+
+ bytesToClean = bytesPerLine - widthInBytes;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: nglyphs is %d, width of glyph in bits is %d, in bytes is %d.\n",
+ nglyphs, widthInBits, widthInBytes);
+
+ fprintf(stderr, "nxagentCleanGlyphs: bytesPerLine is %d bytes, there are %d scanlines.\n", bytesPerLine, height);
+
+ fprintf(stderr, "nxagentCleanGlyphs: Bytes to clean for each scanline are %d.\n", bytesToClean);
+ #endif
+
+ if (bytesToClean > 0)
+ {
+ while (height > 0)
+ {
+ i = bytesToClean;
+
+ while (i > 0)
+ {
+ *(images + (bytesPerLine - i)) = 0;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: cleaned a byte.\n");
+ #endif
+
+ i--;
+ }
+
+ #ifdef DUMP
+ fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean);
+ for (i = 0; i < bytesPerLine; i++)
+ {
+ fprintf(stderr, "[%d]", images[i]);
+ }
+ fprintf(stderr,"\n");
+ #endif
+
+ images += bytesPerLine;
+
+ height--;
+ }
+ }
+
+ gi++;
+
+ nglyphs--;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Breaking Out.\n");
+ #endif
+ }
+ else if (depth == 32)
+ {
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Found glyph with depth 32.\n");
+ #endif
+
+ gi++;
+
+ nglyphs--;
+ }
+ else
+ {
+ #ifdef WARNING
+ fprintf(stderr, "nxagentCleanGlyphs: Unrecognized glyph, depth is not 8/16/24/32, it appears to be %d.\n",
+ depth);
+ #endif
+
+ gi++;
+
+ nglyphs--;
+ }
+ }
+}
+
+#endif /* #ifdef NX_RENDER_CLEANUP */
+
+void
+XRenderAddGlyphs (Display *dpy,
+ GlyphSet glyphset,
+ _Xconst Glyph *gids,
+ _Xconst XGlyphInfo *glyphs,
+ int nglyphs,
+ _Xconst char *images,
+ int nbyte_images)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderAddGlyphsReq *req;
+ long len;
+
+ if (nbyte_images & 3)
+ nbyte_images += 4 - (nbyte_images & 3);
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ GetReq(RenderAddGlyphs, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderAddGlyphs;
+ req->glyphset = glyphset;
+ req->nglyphs = nglyphs;
+ len = (nglyphs * (SIZEOF (xGlyphInfo) + 4) + nbyte_images) >> 2;
+ SetReqLen(req, len, len);
+ Data32 (dpy, (long *) gids, nglyphs * 4);
+ Data16 (dpy, (short *) glyphs, nglyphs * SIZEOF (xGlyphInfo));
+ Data (dpy, images, nbyte_images);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderFreeGlyphs (Display *dpy,
+ GlyphSet glyphset,
+ _Xconst Glyph *gids,
+ int nglyphs)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderFreeGlyphsReq *req;
+ long len;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ GetReq(RenderFreeGlyphs, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderFreeGlyphs;
+ req->glyphset = glyphset;
+ len = nglyphs;
+ SetReqLen(req, len, len);
+ len <<= 2;
+ Data32 (dpy, (long *) gids, len);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeString8 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst char *string,
+ int nchar)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs8Req *req;
+ long len;
+ xGlyphElt *elt;
+ int nbytes;
+
+ if (!nchar)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs8, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs8;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+ /*
+ * xGlyphElt must be aligned on a 32-bit boundary; this is
+ * easily done by filling no more than 252 glyphs in each
+ * bucket
+ */
+
+#define MAX_8 252
+
+ len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar;
+
+ req->length += (len + 3)>>2; /* convert to number of 32-bit words */
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first.
+ */
+
+ if (dpy->bufptr + len > dpy->bufmax)
+ _XFlush (dpy);
+
+ while(nchar > MAX_8)
+ {
+ nbytes = MAX_8 + SIZEOF(xGlyphElt);
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = MAX_8;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+ memcpy ((char *) (elt + 1), string, MAX_8);
+ nchar = nchar - MAX_8;
+ string += MAX_8;
+ }
+
+ if (nchar)
+ {
+ nbytes = (nchar + SIZEOF(xGlyphElt) + 3) & ~3;
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = nchar;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ memcpy ((char *) (elt + 1), string, nchar);
+ }
+#undef MAX_8
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+void
+XRenderCompositeString16 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst unsigned short *string,
+ int nchar)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs8Req *req;
+ long len;
+ xGlyphElt *elt;
+ int nbytes;
+
+ if (!nchar)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs16, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs16;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+#define MAX_16 254
+
+ len = SIZEOF(xGlyphElt) * ((nchar + MAX_16-1) / MAX_16) + nchar * 2;
+
+ req->length += (len + 3)>>2; /* convert to number of 32-bit words */
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first.
+ */
+
+ if (dpy->bufptr + len > dpy->bufmax)
+ _XFlush (dpy);
+
+ while(nchar > MAX_16)
+ {
+ nbytes = MAX_16 * 2 + SIZEOF(xGlyphElt);
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = MAX_16;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+ memcpy ((char *) (elt + 1), (char *) string, MAX_16 * 2);
+ nchar = nchar - MAX_16;
+ string += MAX_16;
+ }
+
+ if (nchar)
+ {
+ nbytes = (nchar * 2 + SIZEOF(xGlyphElt) + 3) & ~3;
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = nchar;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ memcpy ((char *) (elt + 1), (char *) string, nchar * 2);
+ }
+#undef MAX_16
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeString32 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst unsigned int *string,
+ int nchar)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs8Req *req;
+ long len;
+ xGlyphElt *elt;
+ int nbytes;
+
+ if (!nchar)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs32, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs32;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+#define MAX_32 254
+
+ len = SIZEOF(xGlyphElt) * ((nchar + MAX_32-1) / MAX_32) + nchar * 4;
+
+ req->length += (len + 3)>>2; /* convert to number of 32-bit words */
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first.
+ */
+
+ if (dpy->bufptr + len > dpy->bufmax)
+ _XFlush (dpy);
+
+ while(nchar > MAX_32)
+ {
+ nbytes = MAX_32 * 4 + SIZEOF(xGlyphElt);
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = MAX_32;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+ memcpy ((char *) (elt + 1), (char *) string, MAX_32 * 4);
+ nchar = nchar - MAX_32;
+ string += MAX_32;
+ }
+
+ if (nchar)
+ {
+ nbytes = nchar * 4 + SIZEOF(xGlyphElt);
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = nchar;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ memcpy ((char *) (elt + 1), (char *) string, nchar * 4);
+ }
+#undef MAX_32
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeText8 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt8 *elts,
+ int nelt)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs8Req *req;
+ GlyphSet glyphset;
+ long len;
+ long elen;
+ xGlyphElt *elt;
+ int i;
+ _Xconst char *chars;
+ int nchars;
+
+ #ifdef NX_RENDER_CLEANUP
+
+ char tmpChar[4];
+ int bytes_to_clean;
+ int bytes_to_write;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ if (!nelt)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs8, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs8;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = elts[0].glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+ /*
+ * Compute the space necessary
+ */
+ len = 0;
+
+#define MAX_8 252
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Check for glyphset change
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ len += (SIZEOF (xGlyphElt) + 4) >> 2;
+ }
+ nchars = elts[i].nchars;
+ /*
+ * xGlyphElt must be aligned on a 32-bit boundary; this is
+ * easily done by filling no more than 252 glyphs in each
+ * bucket
+ */
+ elen = SIZEOF(xGlyphElt) * ((nchars + MAX_8-1) / MAX_8) + nchars;
+ len += (elen + 3) >> 2;
+ }
+
+ req->length += len;
+
+ /*
+ * Send the glyphs
+ */
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Switch glyphsets
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
+
+ #ifdef NX_RENDER_CLEANUP
+
+ elt->pad1 = 0;
+ elt->pad2 = 0;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ elt->len = 0xff;
+ elt->deltax = 0;
+ elt->deltay = 0;
+ Data32(dpy, &glyphset, 4);
+ }
+ nchars = elts[i].nchars;
+ xDst = elts[i].xOff;
+ yDst = elts[i].yOff;
+ chars = elts[i].chars;
+ while (nchars)
+ {
+ int this_chars = nchars > MAX_8 ? MAX_8 : nchars;
+
+ BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
+
+ #ifdef NX_RENDER_CLEANUP
+
+ elt->pad1 = 0;
+ elt->pad2 = 0;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ elt->len = this_chars;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+
+ #ifdef NX_RENDER_CLEANUP
+
+ bytes_to_write = this_chars & ~3;
+
+ bytes_to_clean = ((this_chars + 3) & ~3) - this_chars;
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText8: bytes_to_write %d, bytes_to_clean are %d,"
+ " this_chars %d.\n", bytes_to_write, bytes_to_clean, this_chars);
+ #endif
+
+ if (bytes_to_clean > 0)
+ {
+ if (bytes_to_write > 0)
+ {
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText8: found %d clean bytes, bytes_to_clean are %d,"
+ " this_chars %d.\n", bytes_to_write, bytes_to_clean, this_chars);
+ #endif
+
+ Data (dpy, chars, bytes_to_write);
+ chars += bytes_to_write;
+ }
+
+ bytes_to_write = this_chars % 4;
+ memcpy (tmpChar, chars, bytes_to_write);
+ chars += bytes_to_write;
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText8: last 32 bit, bytes_to_write are %d,"
+ " bytes_to_clean are %d, this_chars are %d.\n", bytes_to_write, bytes_to_clean, this_chars);
+ #endif
+
+ #ifdef DUMP
+ fprintf(stderr, "XRenderCompositeText8: bytes_to_clean %d, ", bytes_to_clean);
+ #endif
+
+ while (bytes_to_clean > 0)
+ {
+ tmpChar[4 - bytes_to_clean] = 0;
+ bytes_to_clean--;
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText8: Cleaned %d byte.\n", 4 - bytes_to_clean);
+ #endif
+ }
+
+ Data (dpy, tmpChar, 4);
+ nchars -= this_chars;
+
+ #ifdef DUMP
+ fprintf(stderr, "Data: ");
+ for (i = 0; i < 4; i++)
+ {
+ fprintf(stderr, "[%d]", tmpChar[i]);
+ }
+ fprintf(stderr,"\n");
+ #endif
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText8: nchars now is %d.\n", nchars);
+ #endif
+
+ continue;
+ }
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ Data (dpy, chars, this_chars);
+ nchars -= this_chars;
+ chars += this_chars;
+ }
+ }
+#undef MAX_8
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeText16 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt16 *elts,
+ int nelt)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs16Req *req;
+ GlyphSet glyphset;
+ long len;
+ long elen;
+ xGlyphElt *elt;
+ int i;
+ _Xconst unsigned short *chars;
+ int nchars;
+
+ #ifdef NX_RENDER_CLEANUP
+
+ int bytes_to_write;
+ int bytes_to_clean;
+ char tmpChar[4];
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ if (!nelt)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs16, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs16;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = elts[0].glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+ /*
+ * Compute the space necessary
+ */
+ len = 0;
+
+#define MAX_16 254
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Check for glyphset change
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ len += (SIZEOF (xGlyphElt) + 4) >> 2;
+ }
+ nchars = elts[i].nchars;
+ /*
+ * xGlyphElt must be aligned on a 32-bit boundary; this is
+ * easily done by filling no more than 254 glyphs in each
+ * bucket
+ */
+ elen = SIZEOF(xGlyphElt) * ((nchars + MAX_16-1) / MAX_16) + nchars * 2;
+ len += (elen + 3) >> 2;
+ }
+
+ req->length += len;
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Switch glyphsets
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
+
+ #ifdef NX_RENDER_CLEANUP
+
+ elt->pad1 = 0;
+ elt->pad2 = 0;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ elt->len = 0xff;
+ elt->deltax = 0;
+ elt->deltay = 0;
+ Data32(dpy, &glyphset, 4);
+ }
+ nchars = elts[i].nchars;
+ xDst = elts[i].xOff;
+ yDst = elts[i].yOff;
+ chars = elts[i].chars;
+ while (nchars)
+ {
+ int this_chars = nchars > MAX_16 ? MAX_16 : nchars;
+ int this_bytes = this_chars * 2;
+
+ BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
+
+ #ifdef NX_RENDER_CLEANUP
+
+ elt->pad1 = 0;
+ elt->pad2 = 0;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ elt->len = this_chars;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+
+ #ifdef NX_RENDER_CLEANUP
+
+ bytes_to_write = this_bytes & ~3;
+ bytes_to_clean = ((this_bytes + 3) & ~3) - this_bytes;
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText16: this_chars %d, this_bytes %d.\n"
+ "bytes_to_write %d, bytes_to_clean are %d.\n", this_chars, this_bytes,
+ bytes_to_write, bytes_to_clean);
+ #endif
+
+ if (bytes_to_clean > 0)
+ {
+ if (bytes_to_write > 0)
+ {
+ Data16 (dpy, chars, bytes_to_write);
+
+ /*
+ * Cast chars to avoid errors with pointer arithmetic.
+ */
+
+ chars = (unsigned short *) ((char *) chars + bytes_to_write);
+ }
+
+ bytes_to_write = this_bytes % 4;
+ memcpy (tmpChar, (char *) chars, bytes_to_write);
+ chars = (unsigned short *) ((char *) chars + bytes_to_write);
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText16: last 32 bit, bytes_to_write are %d,"
+ " bytes_to_clean are %d.\n", bytes_to_write, bytes_to_clean);
+ #endif
+
+ while (bytes_to_clean > 0)
+ {
+ tmpChar[4 - bytes_to_clean] = 0;
+ bytes_to_clean--;
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText16: Cleaned %d byte.\n", 4 - bytes_to_clean);
+ #endif
+ }
+
+ Data16 (dpy, tmpChar, 4);
+ nchars -= this_chars;
+
+ #ifdef DEBUG
+ fprintf(stderr, "XRenderCompositeText16: nchars now is %d.\n", nchars);
+ #endif
+
+ continue;
+ }
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ Data16 (dpy, chars, this_bytes);
+ nchars -= this_chars;
+ chars += this_chars;
+ }
+ }
+#undef MAX_16
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeText32 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt32 *elts,
+ int nelt)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs32Req *req;
+ GlyphSet glyphset;
+ long len;
+ long elen;
+ xGlyphElt *elt;
+ int i;
+ _Xconst unsigned int *chars;
+ int nchars;
+
+ if (!nelt)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+
+ GetReq(RenderCompositeGlyphs32, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs32;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = elts[0].glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+ /*
+ * Compute the space necessary
+ */
+ len = 0;
+
+#define MAX_32 254
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Check for glyphset change
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ len += (SIZEOF (xGlyphElt) + 4) >> 2;
+ }
+ nchars = elts[i].nchars;
+ elen = SIZEOF(xGlyphElt) * ((nchars + MAX_32) / MAX_32) + nchars *4;
+ len += (elen + 3) >> 2;
+ }
+
+ req->length += len;
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Switch glyphsets
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
+
+ #ifdef NX_RENDER_CLEANUP
+
+ elt->pad1 = 0;
+ elt->pad2 = 0;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ elt->len = 0xff;
+ elt->deltax = 0;
+ elt->deltay = 0;
+ Data32(dpy, &glyphset, 4);
+ }
+ nchars = elts[i].nchars;
+ xDst = elts[i].xOff;
+ yDst = elts[i].yOff;
+ chars = elts[i].chars;
+ while (nchars)
+ {
+ int this_chars = nchars > MAX_32 ? MAX_32 : nchars;
+ int this_bytes = this_chars * 4;
+ BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
+
+ #ifdef NX_RENDER_CLEANUP
+
+ elt->pad1 = 0;
+ elt->pad2 = 0;
+
+ #endif /* NX_RENDER_CLEANUP */
+
+ elt->len = this_chars;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+
+ #ifdef TEST
+ fprintf(stderr, "XRenderCompositeText32: this_chars %d, this_bytes %d.\n",
+ this_chars, this_bytes);
+ #endif
+
+ DataInt32 (dpy, chars, this_bytes);
+ nchars -= this_chars;
+ chars += this_chars;
+ }
+ }
+#undef MAX_32
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
diff --git a/nx-X11/lib/Xrender/Glyph.c.X.original b/nx-X11/lib/Xrender/Glyph.c.X.original
new file mode 100644
index 000000000..894bb77f2
--- /dev/null
+++ b/nx-X11/lib/Xrender/Glyph.c.X.original
@@ -0,0 +1,712 @@
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+GlyphSet
+XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ GlyphSet gsid;
+ xRenderCreateGlyphSetReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreateGlyphSet, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreateGlyphSet;
+ req->gsid = gsid = XAllocID(dpy);
+ req->format = format->id;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return gsid;
+}
+
+GlyphSet
+XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ GlyphSet gsid;
+ xRenderReferenceGlyphSetReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderReferenceGlyphSet, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderReferenceGlyphSet;
+ req->gsid = gsid = XAllocID(dpy);
+ req->existing = existing;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return gsid;
+}
+
+void
+XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderFreeGlyphSetReq *req;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ GetReq(RenderFreeGlyphSet, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderFreeGlyphSet;
+ req->glyphset = glyphset;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderAddGlyphs (Display *dpy,
+ GlyphSet glyphset,
+ _Xconst Glyph *gids,
+ _Xconst XGlyphInfo *glyphs,
+ int nglyphs,
+ _Xconst char *images,
+ int nbyte_images)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderAddGlyphsReq *req;
+ long len;
+
+ if (nbyte_images & 3)
+ nbyte_images += 4 - (nbyte_images & 3);
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ GetReq(RenderAddGlyphs, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderAddGlyphs;
+ req->glyphset = glyphset;
+ req->nglyphs = nglyphs;
+ len = (nglyphs * (SIZEOF (xGlyphInfo) + 4) + nbyte_images) >> 2;
+ SetReqLen(req, len, len);
+ Data32 (dpy, (long *) gids, nglyphs * 4);
+ Data16 (dpy, (short *) glyphs, nglyphs * SIZEOF (xGlyphInfo));
+ Data (dpy, images, nbyte_images);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderFreeGlyphs (Display *dpy,
+ GlyphSet glyphset,
+ _Xconst Glyph *gids,
+ int nglyphs)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderFreeGlyphsReq *req;
+ long len;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ GetReq(RenderFreeGlyphs, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderFreeGlyphs;
+ req->glyphset = glyphset;
+ len = nglyphs;
+ SetReqLen(req, len, len);
+ len <<= 2;
+ Data32 (dpy, (long *) gids, len);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeString8 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst char *string,
+ int nchar)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs8Req *req;
+ long len;
+ xGlyphElt *elt;
+ int nbytes;
+
+ if (!nchar)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs8, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs8;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+ /*
+ * xGlyphElt must be aligned on a 32-bit boundary; this is
+ * easily done by filling no more than 252 glyphs in each
+ * bucket
+ */
+
+#define MAX_8 252
+
+ len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar;
+
+ req->length += (len + 3)>>2; /* convert to number of 32-bit words */
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first.
+ */
+
+ if (dpy->bufptr + len > dpy->bufmax)
+ _XFlush (dpy);
+
+ while(nchar > MAX_8)
+ {
+ nbytes = MAX_8 + SIZEOF(xGlyphElt);
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = MAX_8;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+ memcpy ((char *) (elt + 1), string, MAX_8);
+ nchar = nchar - MAX_8;
+ string += MAX_8;
+ }
+
+ if (nchar)
+ {
+ nbytes = (nchar + SIZEOF(xGlyphElt) + 3) & ~3;
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = nchar;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ memcpy ((char *) (elt + 1), string, nchar);
+ }
+#undef MAX_8
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+void
+XRenderCompositeString16 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst unsigned short *string,
+ int nchar)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs8Req *req;
+ long len;
+ xGlyphElt *elt;
+ int nbytes;
+
+ if (!nchar)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs16, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs16;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+#define MAX_16 254
+
+ len = SIZEOF(xGlyphElt) * ((nchar + MAX_16-1) / MAX_16) + nchar * 2;
+
+ req->length += (len + 3)>>2; /* convert to number of 32-bit words */
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first.
+ */
+
+ if (dpy->bufptr + len > dpy->bufmax)
+ _XFlush (dpy);
+
+ while(nchar > MAX_16)
+ {
+ nbytes = MAX_16 * 2 + SIZEOF(xGlyphElt);
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = MAX_16;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+ memcpy ((char *) (elt + 1), (char *) string, MAX_16 * 2);
+ nchar = nchar - MAX_16;
+ string += MAX_16;
+ }
+
+ if (nchar)
+ {
+ nbytes = (nchar * 2 + SIZEOF(xGlyphElt) + 3) & ~3;
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = nchar;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ memcpy ((char *) (elt + 1), (char *) string, nchar * 2);
+ }
+#undef MAX_16
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeString32 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst unsigned int *string,
+ int nchar)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs8Req *req;
+ long len;
+ xGlyphElt *elt;
+ int nbytes;
+
+ if (!nchar)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs32, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs32;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+#define MAX_32 254
+
+ len = SIZEOF(xGlyphElt) * ((nchar + MAX_32-1) / MAX_32) + nchar * 4;
+
+ req->length += (len + 3)>>2; /* convert to number of 32-bit words */
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first.
+ */
+
+ if (dpy->bufptr + len > dpy->bufmax)
+ _XFlush (dpy);
+
+ while(nchar > MAX_32)
+ {
+ nbytes = MAX_32 * 4 + SIZEOF(xGlyphElt);
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = MAX_32;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+ memcpy ((char *) (elt + 1), (char *) string, MAX_32 * 4);
+ nchar = nchar - MAX_32;
+ string += MAX_32;
+ }
+
+ if (nchar)
+ {
+ nbytes = nchar * 4 + SIZEOF(xGlyphElt);
+ BufAlloc (xGlyphElt *, elt, nbytes);
+ elt->len = nchar;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ memcpy ((char *) (elt + 1), (char *) string, nchar * 4);
+ }
+#undef MAX_32
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeText8 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt8 *elts,
+ int nelt)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs8Req *req;
+ GlyphSet glyphset;
+ long len;
+ long elen;
+ xGlyphElt *elt;
+ int i;
+ _Xconst char *chars;
+ int nchars;
+
+ if (!nelt)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs8, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs8;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = elts[0].glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+ /*
+ * Compute the space necessary
+ */
+ len = 0;
+
+#define MAX_8 252
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Check for glyphset change
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ len += (SIZEOF (xGlyphElt) + 4) >> 2;
+ }
+ nchars = elts[i].nchars;
+ /*
+ * xGlyphElt must be aligned on a 32-bit boundary; this is
+ * easily done by filling no more than 252 glyphs in each
+ * bucket
+ */
+ elen = SIZEOF(xGlyphElt) * ((nchars + MAX_8-1) / MAX_8) + nchars;
+ len += (elen + 3) >> 2;
+ }
+
+ req->length += len;
+
+ /*
+ * Send the glyphs
+ */
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Switch glyphsets
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
+ elt->len = 0xff;
+ elt->deltax = 0;
+ elt->deltay = 0;
+ Data32(dpy, &glyphset, 4);
+ }
+ nchars = elts[i].nchars;
+ xDst = elts[i].xOff;
+ yDst = elts[i].yOff;
+ chars = elts[i].chars;
+ while (nchars)
+ {
+ int this_chars = nchars > MAX_8 ? MAX_8 : nchars;
+
+ BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
+ elt->len = this_chars;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+ Data (dpy, chars, this_chars);
+ nchars -= this_chars;
+ chars += this_chars;
+ }
+ }
+#undef MAX_8
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeText16 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt16 *elts,
+ int nelt)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs16Req *req;
+ GlyphSet glyphset;
+ long len;
+ long elen;
+ xGlyphElt *elt;
+ int i;
+ _Xconst unsigned short *chars;
+ int nchars;
+
+ if (!nelt)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+ GetReq(RenderCompositeGlyphs16, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs16;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = elts[0].glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+ /*
+ * Compute the space necessary
+ */
+ len = 0;
+
+#define MAX_16 254
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Check for glyphset change
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ len += (SIZEOF (xGlyphElt) + 4) >> 2;
+ }
+ nchars = elts[i].nchars;
+ /*
+ * xGlyphElt must be aligned on a 32-bit boundary; this is
+ * easily done by filling no more than 254 glyphs in each
+ * bucket
+ */
+ elen = SIZEOF(xGlyphElt) * ((nchars + MAX_16-1) / MAX_16) + nchars * 2;
+ len += (elen + 3) >> 2;
+ }
+
+ req->length += len;
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Switch glyphsets
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
+ elt->len = 0xff;
+ elt->deltax = 0;
+ elt->deltay = 0;
+ Data32(dpy, &glyphset, 4);
+ }
+ nchars = elts[i].nchars;
+ xDst = elts[i].xOff;
+ yDst = elts[i].yOff;
+ chars = elts[i].chars;
+ while (nchars)
+ {
+ int this_chars = nchars > MAX_16 ? MAX_16 : nchars;
+ int this_bytes = this_chars * 2;
+
+ BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
+ elt->len = this_chars;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+ Data16 (dpy, chars, this_bytes);
+ nchars -= this_chars;
+ chars += this_chars;
+ }
+ }
+#undef MAX_16
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeText32 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt32 *elts,
+ int nelt)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderCompositeGlyphs32Req *req;
+ GlyphSet glyphset;
+ long len;
+ long elen;
+ xGlyphElt *elt;
+ int i;
+ _Xconst unsigned int *chars;
+ int nchars;
+
+ if (!nelt)
+ return;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+
+
+ GetReq(RenderCompositeGlyphs32, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCompositeGlyphs32;
+ req->op = op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : None;
+ req->glyphset = elts[0].glyphset;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+
+ /*
+ * Compute the space necessary
+ */
+ len = 0;
+
+#define MAX_32 254
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Check for glyphset change
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ len += (SIZEOF (xGlyphElt) + 4) >> 2;
+ }
+ nchars = elts[i].nchars;
+ elen = SIZEOF(xGlyphElt) * ((nchars + MAX_32) / MAX_32) + nchars *4;
+ len += (elen + 3) >> 2;
+ }
+
+ req->length += len;
+
+ glyphset = elts[0].glyphset;
+ for (i = 0; i < nelt; i++)
+ {
+ /*
+ * Switch glyphsets
+ */
+ if (elts[i].glyphset != glyphset)
+ {
+ glyphset = elts[i].glyphset;
+ BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
+ elt->len = 0xff;
+ elt->deltax = 0;
+ elt->deltay = 0;
+ Data32(dpy, &glyphset, 4);
+ }
+ nchars = elts[i].nchars;
+ xDst = elts[i].xOff;
+ yDst = elts[i].yOff;
+ chars = elts[i].chars;
+ while (nchars)
+ {
+ int this_chars = nchars > MAX_32 ? MAX_32 : nchars;
+ int this_bytes = this_chars * 4;
+ BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
+ elt->len = this_chars;
+ elt->deltax = xDst;
+ elt->deltay = yDst;
+ xDst = 0;
+ yDst = 0;
+ DataInt32 (dpy, chars, this_bytes);
+ nchars -= this_chars;
+ chars += this_chars;
+ }
+ }
+#undef MAX_32
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
diff --git a/nx-X11/lib/Xrender/INSTALL b/nx-X11/lib/Xrender/INSTALL
new file mode 100644
index 000000000..835f6080a
--- /dev/null
+++ b/nx-X11/lib/Xrender/INSTALL
@@ -0,0 +1,8 @@
+Xrender is built with the traditional configure script:
+
+ $ ./configure --prefix=/usr/X11R6
+
+This should generate valid Makefiles, then:
+
+ $ make
+ $ make install
diff --git a/nx-X11/lib/Xrender/Imakefile b/nx-X11/lib/Xrender/Imakefile
new file mode 100644
index 000000000..c690dc0f0
--- /dev/null
+++ b/nx-X11/lib/Xrender/Imakefile
@@ -0,0 +1,167 @@
+XCOMM $XFree86: xc/lib/Xrender/Imakefile,v 1.10tsi Exp $
+
+#ifdef UseInstalled
+
+XCOMM Allow for builds against old installed bits. Note that this requires
+XCOMM that additional files be copied (or linked) into this directory. See
+XCOMM NONSTANDARD_HEADERS below.
+
+#ifndef SharedLibXrender
+#define SharedLibXrender YES
+#endif
+
+#ifndef NormalLibXrender
+#define NormalLibXrender (!SharedLibXrender | ForceNormalLib)
+#endif
+
+#ifndef DebugLibXrender
+#define DebugLibXrender NO
+#endif
+
+#ifndef ProfileLibXrender
+#define ProfileLibXrender NO
+#endif
+
+#undef SharedXrenderRev
+#define SharedXrenderRev 1.1
+SOXRENDERREV = SharedXrenderRev
+
+#if SharedLibXrender
+#define SharedXft1Rev 1.2
+SharedLibReferences(XFT1,Xft,$(XFT1SRC),SOXFT1REV,SharedXft1Rev)
+#else
+ProjectUnsharedLibReferences(XFT1,Xft,$(XFT1SRC),BuildLibDir)
+#endif
+
+#undef LinkBuildLibrary
+#define LinkBuildLibrary(lib) MakeDir($(BUILDLIBDIR)) @@\
+ RemoveFile($(BUILDLIBDIR)/lib) @@\
+ cd $(BUILDLIBDIR) && $(LN) $(BUILDLIBTOP)/$(CURRENT_DIR)/lib .
+#undef _LinkBuildLibrary
+#define _LinkBuildLibrary(lib) LinkBuildLibrary(lib)
+
+#undef LinkBuildLibraryMaybe
+#define LinkBuildLibraryMaybe(lib,doit) MakeDir($(BUILDLIBDIR)) @@\
+ @if doit; then (set -x; \ @@\
+ RemoveFile($(BUILDLIBDIR)/lib); \ @@\
+ cd $(BUILDLIBDIR) && $(LN) $(BUILDLIBTOP)/$(CURRENT_DIR)/lib .); fi
+
+#undef LdPreLibs
+#define LdPreLibs -L$(BUILDLIBDIR) LdPreLib XLdPreLibs
+
+LDPRELIBS = LdPreLibs
+
+NONSTANDARD_HEADERS = extutil.h region.h render.h renderproto.h
+
+all:: $(NONSTANDARD_HEADERS)
+includes depend:: $(NONSTANDARD_HEADERS)
+
+$(NONSTANDARD_HEADERS):
+ @echo Header file $@ is missing.
+
+#ifdef XBuildIncDir
+RENDERCLEANDIR = $(BUILDINCROOT)
+#else
+RENDERCLEANDIR = $(BUILDINCDIR)
+#endif
+
+clean::
+ $(RM) -r $(RENDERCLEANDIR)
+
+#endif
+
+#define DoNormalLib NormalLibXrender
+#define DoSharedLib SharedLibXrender
+#define DoDebugLib DebugLibXrender
+#define DoProfileLib ProfileLibXrender
+#define LibName Xrender
+#define SoRev SOXRENDERREV
+
+#ifdef XBuildIncDir
+#define IncSubdir X11
+#define IncSubSubdir extensions
+RENDERINCDIR = $(BUILDINCDIR)
+#else
+#define IncSubdir extensions
+RENDERINCDIR = $(BUILDINCROOT)
+#endif
+
+#include <Threads.tmpl>
+
+#ifdef SharedXrenderReqs
+REQUIREDLIBS = SharedXrenderReqs
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+#ifdef UseInstalled
+ INCLUDES = -I$(RENDERINCDIR) -I$(INCROOT)/X11 -I$(INCROOT)/X11/extensions
+#else
+ INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC)
+#endif
+
+ SRCS = Xrender.c \
+ AddTrap.c \
+ Color.c \
+ Composite.c \
+ Cursor.c \
+ Glyph.c \
+ Picture.c \
+ FillRect.c \
+ FillRects.c \
+ Filter.c \
+ Poly.c \
+ Trap.c \
+ Tri.c
+
+ OBJS = Xrender.o \
+ AddTrap.o \
+ Color.o \
+ Composite.o \
+ Cursor.o \
+ Glyph.o \
+ Picture.o \
+ FillRect.o \
+ FillRects.o \
+ Filter.o \
+ Poly.o \
+ Trap.o \
+ Tri.o
+
+ LINTLIBS = $(LINTXLIB)
+
+HEADERS = Xrender.h $(NONSTANDARD_HEADERS)
+
+SUBSTVARS=prefix="$(PROJECTROOT)" \
+ exec_prefix="$(BINDIR)" \
+ libdir="$(USRLIBDIR)" \
+ includedir="$(INCROOT)" \
+ VERSION="0.8.4" \
+ X_REQUIRES="" \
+ RENDER_CFLAGS="" \
+ X_NON_PKG_CFLAGS="" \
+ X_NON_PKG_LIBS="-lX11 -lXext"
+
+#include <Library.tmpl>
+
+DependTarget()
+
+#ifndef clean
+/* Generate a distclean target */
+distclean:: clean
+ RemoveFile(Makefile)
+#endif
+
+all:: xrender.pc
+
+xrender.pc: xrender.pc.in
+ RemoveFile($@)
+ sh ../Xcursor/config-subst $(SUBSTVARS) < xrender.pc.in > $@
+
+InstallNonExecFile(xrender.pc,$(USRLIBDIR)/pkgconfig)
+
+clean::
+ RemoveFile(xrender.pc)
diff --git a/nx-X11/lib/Xrender/NEWS b/nx-X11/lib/Xrender/NEWS
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/lib/Xrender/NEWS
diff --git a/nx-X11/lib/Xrender/Picture.c b/nx-X11/lib/Xrender/Picture.c
new file mode 100644
index 000000000..0b18f5c57
--- /dev/null
+++ b/nx-X11/lib/Xrender/Picture.c
@@ -0,0 +1,366 @@
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+#include <X11/Xregion.h>
+
+static void
+_XRenderProcessPictureAttributes (Display *dpy,
+ xRenderChangePictureReq *req,
+ unsigned long valuemask,
+ _Xconst XRenderPictureAttributes *attributes)
+{
+ unsigned long values[32];
+ register unsigned long *value = values;
+ unsigned int nvalues;
+
+ if (valuemask & CPRepeat)
+ *value++ = attributes->repeat;
+ if (valuemask & CPAlphaMap)
+ *value++ = attributes->alpha_map;
+ if (valuemask & CPAlphaXOrigin)
+ *value++ = attributes->alpha_x_origin;
+ if (valuemask & CPAlphaYOrigin)
+ *value++ = attributes->alpha_y_origin;
+ if (valuemask & CPClipXOrigin)
+ *value++ = attributes->clip_x_origin;
+ if (valuemask & CPClipYOrigin)
+ *value++ = attributes->clip_y_origin;
+ if (valuemask & CPClipMask)
+ *value++ = attributes->clip_mask;
+ if (valuemask & CPGraphicsExposure)
+ *value++ = attributes->graphics_exposures;
+ if (valuemask & CPSubwindowMode)
+ *value++ = attributes->subwindow_mode;
+ if (valuemask & CPPolyEdge)
+ *value++ = attributes->poly_edge;
+ if (valuemask & CPPolyMode)
+ *value++ = attributes->poly_mode;
+ if (valuemask & CPDither)
+ *value++ = attributes->dither;
+ if (valuemask & CPComponentAlpha)
+ *value++ = attributes->component_alpha;
+
+ req->length += (nvalues = value - values);
+
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, (long)nvalues);
+}
+
+Picture
+XRenderCreatePicture (Display *dpy,
+ Drawable drawable,
+ _Xconst XRenderPictFormat *format,
+ unsigned long valuemask,
+ _Xconst XRenderPictureAttributes *attributes)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ Picture pid;
+ xRenderCreatePictureReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreatePicture, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreatePicture;
+ req->pid = pid = XAllocID(dpy);
+ req->drawable = drawable;
+ req->format = format->id;
+ if ((req->mask = valuemask))
+ _XRenderProcessPictureAttributes (dpy,
+ (xRenderChangePictureReq *) req,
+ valuemask,
+ attributes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return pid;
+}
+
+void
+XRenderChangePicture (Display *dpy,
+ Picture picture,
+ unsigned long valuemask,
+ _Xconst XRenderPictureAttributes *attributes)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderChangePictureReq *req;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ GetReq(RenderChangePicture, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderChangePicture;
+ req->picture = picture;
+ req->mask = valuemask;
+ _XRenderProcessPictureAttributes (dpy,
+ req,
+ valuemask,
+ attributes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+static void
+_XRenderSetPictureClipRectangles (Display *dpy,
+ XRenderExtDisplayInfo *info,
+ Picture picture,
+ int xOrigin,
+ int yOrigin,
+ _Xconst XRectangle *rects,
+ int n)
+{
+ xRenderSetPictureClipRectanglesReq *req;
+ long len;
+
+ GetReq (RenderSetPictureClipRectangles, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderSetPictureClipRectangles;
+ req->picture = picture;
+ req->xOrigin = xOrigin;
+ req->yOrigin = yOrigin;
+ len = ((long) n) << 1;
+ SetReqLen (req, len, 1);
+ len <<= 2;
+ Data16 (dpy, (short *) rects, len);
+}
+
+void
+XRenderSetPictureClipRectangles (Display *dpy,
+ Picture picture,
+ int xOrigin,
+ int yOrigin,
+ _Xconst XRectangle *rects,
+ int n)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ _XRenderSetPictureClipRectangles (dpy, info, picture,
+ xOrigin, yOrigin, rects, n);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+void
+XRenderSetPictureClipRegion (Display *dpy,
+ Picture picture,
+ Region r)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ int i;
+ XRectangle *xr, *pr;
+ BOX *pb;
+ unsigned long total;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ total = r->numRects * sizeof (XRectangle);
+ if ((xr = (XRectangle *) _XAllocTemp(dpy, total))) {
+ for (pr = xr, pb = r->rects, i = r->numRects; --i >= 0; pr++, pb++) {
+ pr->x = pb->x1;
+ pr->y = pb->y1;
+ pr->width = pb->x2 - pb->x1;
+ pr->height = pb->y2 - pb->y1;
+ }
+ }
+ if (xr || !r->numRects)
+ _XRenderSetPictureClipRectangles (dpy, info, picture, 0, 0,
+ xr, r->numRects);
+ if (xr)
+ _XFreeTemp(dpy, (char *)xr, total);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderSetPictureTransform (Display *dpy,
+ Picture picture,
+ XTransform *transform)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderSetPictureTransformReq *req;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay (dpy);
+ GetReq(RenderSetPictureTransform, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderSetPictureTransform;
+ req->picture = picture;
+ req->transform.matrix11 = transform->matrix[0][0];
+ req->transform.matrix12 = transform->matrix[0][1];
+ req->transform.matrix13 = transform->matrix[0][2];
+ req->transform.matrix21 = transform->matrix[1][0];
+ req->transform.matrix22 = transform->matrix[1][1];
+ req->transform.matrix23 = transform->matrix[1][2];
+ req->transform.matrix31 = transform->matrix[2][0];
+ req->transform.matrix32 = transform->matrix[2][1];
+ req->transform.matrix33 = transform->matrix[2][2];
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+}
+
+void
+XRenderFreePicture (Display *dpy,
+ Picture picture)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderFreePictureReq *req;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ GetReq(RenderFreePicture, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderFreePicture;
+ req->picture = picture;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+
+Picture XRenderCreateSolidFill(Display *dpy,
+ const XRenderColor *color)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ Picture pid;
+ xRenderCreateSolidFillReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreateSolidFill, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreateSolidFill;
+
+ req->pid = pid = XAllocID(dpy);
+ req->color.red = color->red;
+ req->color.green = color->green;
+ req->color.blue = color->blue;
+ req->color.alpha = color->alpha;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return pid;
+}
+
+
+Picture XRenderCreateLinearGradient(Display *dpy,
+ const XLinearGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nStops)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ Picture pid;
+ xRenderCreateLinearGradientReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreateLinearGradient, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreateLinearGradient;
+
+ req->pid = pid = XAllocID(dpy);
+ req->p1.x = gradient->p1.x;
+ req->p1.y = gradient->p1.y;
+ req->p2.x = gradient->p2.x;
+ req->p2.y = gradient->p2.y;
+
+ req->nStops = nStops;
+ DataInt32(dpy, stops, nStops * 4);
+ Data16(dpy, colors, nStops * 8);
+ req->length += nStops*3;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return pid;
+}
+
+Picture XRenderCreateRadialGradient(Display *dpy,
+ const XRadialGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nStops)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ Picture pid;
+ xRenderCreateRadialGradientReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreateRadialGradient, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreateRadialGradient;
+
+ req->pid = pid = XAllocID(dpy);
+ req->inner.x = gradient->inner.x;
+ req->inner.y = gradient->inner.y;
+ req->outer.x = gradient->outer.x;
+ req->outer.y = gradient->outer.y;
+ req->inner_radius = gradient->inner.radius;
+ req->outer_radius = gradient->outer.radius;
+
+ req->nStops = nStops;
+ DataInt32(dpy, stops, nStops * 4);
+ Data16(dpy, colors, nStops * 8);
+ req->length += nStops*3;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return pid;
+}
+
+Picture XRenderCreateConicalGradient(Display *dpy,
+ const XConicalGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nStops)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ Picture pid;
+ xRenderCreateConicalGradientReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreateConicalGradient, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreateConicalGradient;
+
+ req->pid = pid = XAllocID(dpy);
+ req->center.x = gradient->center.x;
+ req->center.y = gradient->center.y;
+ req->angle = gradient->angle;
+
+ req->nStops = nStops;
+ DataInt32(dpy, stops, nStops * 4);
+ Data16(dpy, colors, nStops * 8);
+ req->length += nStops*3;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return pid;
+}
diff --git a/nx-X11/lib/Xrender/Poly.c b/nx-X11/lib/Xrender/Poly.c
new file mode 100644
index 000000000..ee461d7c5
--- /dev/null
+++ b/nx-X11/lib/Xrender/Poly.c
@@ -0,0 +1,302 @@
+/*
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+typedef struct _Edge Edge;
+
+struct _Edge {
+ XLineFixed edge;
+ XFixed current_x;
+ Bool clockWise;
+ Edge *next, *prev;
+};
+
+static int
+CompareEdge (const void *o1, const void *o2)
+{
+ const Edge *e1 = o1, *e2 = o2;
+
+ return e1->edge.p1.y - e2->edge.p1.y;
+}
+
+static XFixed
+XRenderComputeX (XLineFixed *line, XFixed y)
+{
+ XFixed dx = line->p2.x - line->p1.x;
+ double ex = (double) (y - line->p1.y) * (double) dx;
+ XFixed dy = line->p2.y - line->p1.y;
+
+ return (XFixed) line->p1.x + (XFixed) (ex / dy);
+}
+
+static double
+XRenderComputeInverseSlope (XLineFixed *l)
+{
+ return (XFixedToDouble (l->p2.x - l->p1.x) /
+ XFixedToDouble (l->p2.y - l->p1.y));
+}
+
+static double
+XRenderComputeXIntercept (XLineFixed *l, double inverse_slope)
+{
+ return XFixedToDouble (l->p1.x) - inverse_slope * XFixedToDouble (l->p1.y);
+}
+
+static XFixed
+XRenderComputeIntersect (XLineFixed *l1, XLineFixed *l2)
+{
+ /*
+ * x = m1y + b1
+ * x = m2y + b2
+ * m1y + b1 = m2y + b2
+ * y * (m1 - m2) = b2 - b1
+ * y = (b2 - b1) / (m1 - m2)
+ */
+ double m1 = XRenderComputeInverseSlope (l1);
+ double b1 = XRenderComputeXIntercept (l1, m1);
+ double m2 = XRenderComputeInverseSlope (l2);
+ double b2 = XRenderComputeXIntercept (l2, m2);
+
+ return XDoubleToFixed ((b2 - b1) / (m1 - m2));
+}
+
+static int
+XRenderComputeTrapezoids (Edge *edges,
+ int nedges,
+ int winding,
+ XTrapezoid *traps)
+{
+ int ntraps = 0;
+ int inactive;
+ Edge *active;
+ Edge *e, *en, *next;
+ XFixed y, next_y, intersect;
+
+ qsort (edges, nedges, sizeof (Edge), CompareEdge);
+
+ y = edges[0].edge.p1.y;
+ active = 0;
+ inactive = 0;
+ while (active || inactive < nedges)
+ {
+ /* insert new active edges into list */
+ while (inactive < nedges)
+ {
+ e = &edges[inactive];
+ if (e->edge.p1.y > y)
+ break;
+ /* move this edge into the active list */
+ inactive++;
+ e->next = active;
+ e->prev = 0;
+ if (active)
+ active->prev = e;
+ active = e;
+ }
+ /* compute x coordinates along this group */
+ for (e = active; e; e = e->next)
+ e->current_x = XRenderComputeX (&e->edge, y);
+
+ /* sort active list */
+ for (e = active; e; e = next)
+ {
+ next = e->next;
+ /*
+ * Find one later in the list that belongs before the
+ * current one
+ */
+ for (en = next; en; en = en->next)
+ {
+ if (en->current_x < e->current_x ||
+ (en->current_x == e->current_x &&
+ en->edge.p2.x < e->edge.p2.x))
+ {
+ /*
+ * insert en before e
+ *
+ * extract en
+ */
+ en->prev->next = en->next;
+ if (en->next)
+ en->next->prev = en->prev;
+ /*
+ * insert en
+ */
+ if (e->prev)
+ e->prev->next = en;
+ else
+ active = en;
+ en->prev = e->prev;
+ e->prev = en;
+ en->next = e;
+ /*
+ * start over at en
+ */
+ next = en;
+ break;
+ }
+ }
+ }
+#if 0
+ printf ("y: %6.3g:", y / 65536.0);
+ for (e = active; e; e = e->next)
+ {
+ printf (" %6.3g", e->current_x / 65536.0);
+ }
+ printf ("\n");
+#endif
+ /* find next inflection point */
+ next_y = active->edge.p2.y;
+ for (e = active; e; e = en)
+ {
+ if (e->edge.p2.y < next_y)
+ next_y = e->edge.p2.y;
+ en = e->next;
+ /* check intersect */
+ if (en && e->edge.p2.x > en->edge.p2.x)
+ {
+ intersect = XRenderComputeIntersect (&e->edge, &e->next->edge);
+ /* make sure this point is below the actual intersection */
+ intersect = intersect + 1;
+ if (intersect < next_y)
+ next_y = intersect;
+ }
+ }
+ /* check next inactive point */
+ if (inactive < nedges && edges[inactive].edge.p1.y < next_y)
+ next_y = edges[inactive].edge.p1.y;
+
+ /* walk the list generating trapezoids */
+ for (e = active; e && (en = e->next); e = en->next)
+ {
+ traps->top = y;
+ traps->bottom = next_y;
+ traps->left = e->edge;
+ traps->right = en->edge;
+ traps++;
+ ntraps++;
+ }
+
+ y = next_y;
+
+ /* delete inactive edges from list */
+ for (e = active; e; e = next)
+ {
+ next = e->next;
+ if (e->edge.p2.y <= y)
+ {
+ if (e->prev)
+ e->prev->next = e->next;
+ else
+ active = e->next;
+ if (e->next)
+ e->next->prev = e->prev;
+ }
+ }
+ }
+ return ntraps;
+}
+
+void
+XRenderCompositeDoublePoly (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XPointDouble *fpoints,
+ int npoints,
+ int winding)
+{
+ Edge *edges;
+ XTrapezoid *traps;
+ int i, nedges, ntraps;
+ XFixed x, y, prevx = 0, prevy = 0, firstx = 0, firsty = 0;
+ XFixed top = 0, bottom = 0; /* GCCism */
+
+ edges = (Edge *) Xmalloc (npoints * sizeof (Edge) +
+ (npoints * npoints * sizeof (XTrapezoid)));
+ if (!edges)
+ return;
+ traps = (XTrapezoid *) (edges + npoints);
+ nedges = 0;
+ for (i = 0; i <= npoints; i++)
+ {
+ if (i == npoints)
+ {
+ x = firstx;
+ y = firsty;
+ }
+ else
+ {
+ x = XDoubleToFixed (fpoints[i].x);
+ y = XDoubleToFixed (fpoints[i].y);
+ }
+ if (i)
+ {
+ if (y < top)
+ top = y;
+ else if (y > bottom)
+ bottom = y;
+ if (prevy < y)
+ {
+ edges[nedges].edge.p1.x = prevx;
+ edges[nedges].edge.p1.y = prevy;
+ edges[nedges].edge.p2.x = x;
+ edges[nedges].edge.p2.y = y;
+ edges[nedges].clockWise = True;
+ nedges++;
+ }
+ else if (prevy > y)
+ {
+ edges[nedges].edge.p1.x = x;
+ edges[nedges].edge.p1.y = y;
+ edges[nedges].edge.p2.x = prevx;
+ edges[nedges].edge.p2.y = prevy;
+ edges[nedges].clockWise = False;
+ nedges++;
+ }
+ /* drop horizontal edges */
+ }
+ else
+ {
+ top = y;
+ bottom = y;
+ firstx = x;
+ firsty = y;
+ }
+ prevx = x;
+ prevy = y;
+ }
+ ntraps = XRenderComputeTrapezoids (edges, nedges, winding, traps);
+ /* XXX adjust xSrc/xDst */
+ XRenderCompositeTrapezoids (dpy, op, src, dst, maskFormat, xSrc, ySrc, traps, ntraps);
+ Xfree (edges);
+}
diff --git a/nx-X11/lib/Xrender/README b/nx-X11/lib/Xrender/README
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/lib/Xrender/README
diff --git a/nx-X11/lib/Xrender/Trap.c b/nx-X11/lib/Xrender/Trap.c
new file mode 100644
index 000000000..919aaef53
--- /dev/null
+++ b/nx-X11/lib/Xrender/Trap.c
@@ -0,0 +1,74 @@
+/*
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+void
+XRenderCompositeTrapezoids (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XTrapezoid *traps,
+ int ntrap)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderTrapezoidsReq *req;
+ int n;
+ long len;
+ unsigned long max_req = dpy->bigreq_size ? dpy->bigreq_size : dpy->max_request_size;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ while (ntrap)
+ {
+ GetReq(RenderTrapezoids, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderTrapezoids;
+ req->op = (CARD8) op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : 0;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+ n = ntrap;
+ len = ((long) n) * (SIZEOF (xTrapezoid) >> 2);
+ if (len > (max_req - req->length)) {
+ n = (max_req - req->length) / (SIZEOF (xTrapezoid) >> 2);
+ len = ((long)n) * (SIZEOF (xTrapezoid) >> 2);
+ }
+ SetReqLen (req, len, len);
+ len <<= 2;
+ DataInt32 (dpy, (int *) traps, len);
+ ntrap -= n;
+ traps += n;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
diff --git a/nx-X11/lib/Xrender/Tri.c b/nx-X11/lib/Xrender/Tri.c
new file mode 100644
index 000000000..155f2ce14
--- /dev/null
+++ b/nx-X11/lib/Xrender/Tri.c
@@ -0,0 +1,169 @@
+/*
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+void
+XRenderCompositeTriangles (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XTriangle *triangles,
+ int ntriangle)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderTrianglesReq *req;
+ int n;
+ long len;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ while (ntriangle)
+ {
+ GetReq(RenderTriangles, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderTriangles;
+ req->op = (CARD8) op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : 0;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+ n = ntriangle;
+ len = ((long) n) * (SIZEOF (xTriangle) >> 2);
+ if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) {
+ n = (dpy->max_request_size - req->length) / (SIZEOF (xTriangle) >> 2);
+ len = ((long)n) * (SIZEOF (xTriangle) >> 2);
+ }
+ SetReqLen (req, len, len);
+ len <<= 2;
+ DataInt32 (dpy, (int *) triangles, len);
+ ntriangle -= n;
+ triangles += n;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeTriStrip (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XPointFixed *points,
+ int npoint)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderTriStripReq *req;
+ int n;
+ long len;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ while (npoint > 2)
+ {
+ GetReq(RenderTriStrip, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderTriStrip;
+ req->op = (CARD8) op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : 0;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+ n = npoint;
+ len = ((long) n) * (SIZEOF (xPointFixed) >> 2);
+ if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) {
+ n = (dpy->max_request_size - req->length) / (SIZEOF (xPointFixed) >> 2);
+ len = ((long)n) * (SIZEOF (xPointFixed) >> 2);
+ }
+ SetReqLen (req, len, len);
+ len <<= 2;
+ DataInt32 (dpy, (int *) points, len);
+ npoint -= (n - 2);
+ points += (n - 2);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void
+XRenderCompositeTriFan (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XPointFixed *points,
+ int npoint)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ _Xconst XPointFixed *first = points;
+ xPointFixed *p;
+ xRenderTriFanReq *req;
+ int n;
+ long len;
+
+ RenderSimpleCheckExtension (dpy, info);
+ LockDisplay(dpy);
+ points++;
+ npoint--;
+ while (npoint > 1)
+ {
+ GetReqExtra(RenderTriFan, SIZEOF (xPointFixed), req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderTriFan;
+ req->op = (CARD8) op;
+ req->src = src;
+ req->dst = dst;
+ req->maskFormat = maskFormat ? maskFormat->id : 0;
+ req->xSrc = xSrc;
+ req->ySrc = ySrc;
+ p = (xPointFixed *) (req + 1);
+ p->x = first->x;
+ p->y = first->y;
+ n = npoint;
+ len = ((long) n) * (SIZEOF (xPointFixed) >> 2);
+ if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) {
+ n = (dpy->max_request_size - req->length) / (SIZEOF (xPointFixed) >> 2);
+ len = ((long)n) * (SIZEOF (xPointFixed) >> 2);
+ }
+ SetReqLen (req, len, len);
+ len <<= 2;
+ DataInt32 (dpy, (int *) points, len);
+ npoint -= (n - 1);
+ points += (n - 1);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
diff --git a/nx-X11/lib/Xrender/Xrender-def.cpp b/nx-X11/lib/Xrender/Xrender-def.cpp
new file mode 100644
index 000000000..c197df1ad
--- /dev/null
+++ b/nx-X11/lib/Xrender/Xrender-def.cpp
@@ -0,0 +1,44 @@
+LIBRARY Xrender
+VERSION LIBRARY_VERSION
+EXPORTS
+XRenderParseColor
+XRenderComposite
+XRenderCreateCursor
+XRenderFillRectangle
+XRenderFillRectangles
+XRenderQueryFilters
+XRenderSetPictureFilter
+XRenderAddGlyphs
+XRenderCompositeString16
+XRenderCompositeString32
+XRenderCompositeString8
+XRenderCompositeText16
+XRenderCompositeText32
+XRenderCompositeText8
+XRenderCreateGlyphSet
+XRenderFreeGlyphSet
+XRenderFreeGlyphs
+XRenderReferenceGlyphSet
+XRenderChangePicture
+XRenderCreatePicture
+XRenderFreePicture
+XRenderSetPictureClipRectangles
+XRenderSetPictureClipRegion
+XRenderSetPictureTransform
+XRenderCompositeDoublePoly
+XRenderCompositeTrapezoids
+XRenderCompositeTriFan
+XRenderCompositeTriStrip
+XRenderCompositeTriangles
+XRenderFindDisplay
+XRenderFindFormat
+XRenderFindStandardFormat
+XRenderFindVisualFormat
+XRenderQueryExtension
+XRenderQueryFormats
+XRenderQuerySubpixelOrder
+XRenderQueryVersion
+XRenderSetSubpixelOrder
+#ifdef __UNIXOS2__
+XRenderCreateAnimCursor
+#endif
diff --git a/nx-X11/lib/Xrender/Xrender.c b/nx-X11/lib/Xrender/Xrender.c
new file mode 100644
index 000000000..8d8aeb979
--- /dev/null
+++ b/nx-X11/lib/Xrender/Xrender.c
@@ -0,0 +1,889 @@
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xrenderint.h"
+
+XRenderExtInfo XRenderExtensionInfo;
+char XRenderExtensionName[] = RENDER_NAME;
+
+static int XRenderCloseDisplay (Display *dpy, XExtCodes *codes);
+
+/*
+ * XRenderExtFindDisplay - look for a display in this extension; keeps a
+ * cache of the most-recently used for efficiency. (Replaces
+ * XextFindDisplay.)
+ */
+static XRenderExtDisplayInfo *
+XRenderExtFindDisplay (XRenderExtInfo *extinfo,
+ Display *dpy)
+{
+ XRenderExtDisplayInfo *dpyinfo;
+
+ /*
+ * see if this was the most recently accessed display
+ */
+ if ((dpyinfo = extinfo->cur) && dpyinfo->display == dpy)
+ return dpyinfo;
+
+ /*
+ * look for display in list
+ */
+ _XLockMutex(_Xglobal_lock);
+ for (dpyinfo = extinfo->head; dpyinfo; dpyinfo = dpyinfo->next) {
+ if (dpyinfo->display == dpy) {
+ extinfo->cur = dpyinfo; /* cache most recently used */
+ _XUnlockMutex(_Xglobal_lock);
+ return dpyinfo;
+ }
+ }
+ _XUnlockMutex(_Xglobal_lock);
+
+ return NULL;
+}
+
+/*
+ * If the server is missing support for any of the required depths on
+ * any screen, tell the application that Render is not present.
+ */
+
+#define DEPTH_MASK(d) (1 << ((d) - 1))
+
+/*
+ * Render requires support for depth 1, 4, 8, 24 and 32 pixmaps
+ */
+
+#define REQUIRED_DEPTHS (DEPTH_MASK(1) | \
+ DEPTH_MASK(4) | \
+ DEPTH_MASK(8) | \
+ DEPTH_MASK(24) | \
+ DEPTH_MASK(32))
+
+typedef struct _DepthCheckRec {
+ struct _DepthCheckRec *next;
+ Display *dpy;
+ CARD32 missing;
+ unsigned long serial;
+} DepthCheckRec, *DepthCheckPtr;
+
+static DepthCheckPtr depthChecks;
+
+static int
+XRenderDepthCheckErrorHandler (Display *dpy, XErrorEvent *evt)
+{
+ if (evt->request_code == X_CreatePixmap && evt->error_code == BadValue)
+ {
+ DepthCheckPtr d;
+ _XLockMutex(_Xglobal_lock);
+ for (d = depthChecks; d; d = d->next)
+ if (d->dpy == dpy)
+ {
+ if ((long) (evt->serial - d->serial) >= 0)
+ d->missing |= DEPTH_MASK(evt->resourceid);
+ break;
+ }
+ _XUnlockMutex (_Xglobal_lock);
+ }
+ return 0;
+}
+
+static Bool
+XRenderHasDepths (Display *dpy)
+{
+ int s;
+
+ for (s = 0; s < ScreenCount (dpy); s++)
+ {
+ CARD32 depths = 0;
+ CARD32 missing;
+ Screen *scr = ScreenOfDisplay (dpy, s);
+ int d;
+
+ for (d = 0; d < scr->ndepths; d++)
+ depths |= DEPTH_MASK(scr->depths[d].depth);
+ missing = ~depths & REQUIRED_DEPTHS;
+ if (missing)
+ {
+ DepthCheckRec dc, **dp;
+ XErrorHandler previousHandler;
+
+ /*
+ * Ok, this is ugly. It should be sufficient at this
+ * point to just return False, but Xinerama is broken at
+ * this point and only advertises depths which have an
+ * associated visual. Of course, the other depths still
+ * work, but the only way to find out is to try them.
+ */
+ dc.dpy = dpy;
+ dc.missing = 0;
+ dc.serial = XNextRequest (dpy);
+ _XLockMutex(_Xglobal_lock);
+ dc.next = depthChecks;
+ depthChecks = &dc;
+ _XUnlockMutex (_Xglobal_lock);
+ /*
+ * I suspect this is not really thread safe, but Xlib doesn't
+ * provide a lot of options here
+ */
+ previousHandler = XSetErrorHandler (XRenderDepthCheckErrorHandler);
+ /*
+ * Try each missing depth and see if pixmap creation succeeds
+ */
+ for (d = 1; d <= 32; d++)
+ /* don't check depth 1 == Xcursor recurses... */
+ if ((missing & DEPTH_MASK(d)) && d != 1)
+ {
+ Pixmap p;
+ p = XCreatePixmap (dpy, RootWindow (dpy, s), 1, 1, d);
+ XFreePixmap (dpy, p);
+ }
+ XSync (dpy, False);
+ XSetErrorHandler (previousHandler);
+ /*
+ * Unhook from the list of depth check records
+ */
+ _XLockMutex(_Xglobal_lock);
+ for (dp = &depthChecks; *dp; dp = &(*dp)->next)
+ {
+ if (*dp == &dc)
+ {
+ *dp = dc.next;
+ break;
+ }
+ }
+ _XUnlockMutex (_Xglobal_lock);
+ if (dc.missing)
+ return False;
+ }
+ }
+ return True;
+}
+
+/*
+ * XRenderExtAddDisplay - add a display to this extension. (Replaces
+ * XextAddDisplay)
+ */
+static XRenderExtDisplayInfo *
+XRenderExtAddDisplay (XRenderExtInfo *extinfo,
+ Display *dpy,
+ char *ext_name)
+{
+ XRenderExtDisplayInfo *dpyinfo;
+
+ dpyinfo = (XRenderExtDisplayInfo *) Xmalloc (sizeof (XRenderExtDisplayInfo));
+ if (!dpyinfo) return NULL;
+ dpyinfo->display = dpy;
+ dpyinfo->info = NULL;
+
+ if (XRenderHasDepths (dpy))
+ dpyinfo->codes = XInitExtension (dpy, ext_name);
+ else
+ dpyinfo->codes = NULL;
+
+ /*
+ * if the server has the extension, then we can initialize the
+ * appropriate function vectors
+ */
+ if (dpyinfo->codes) {
+ XESetCloseDisplay (dpy, dpyinfo->codes->extension,
+ XRenderCloseDisplay);
+ } else {
+ /* The server doesn't have this extension.
+ * Use a private Xlib-internal extension to hang the close_display
+ * hook on so that the "cache" (extinfo->cur) is properly cleaned.
+ * (XBUG 7955)
+ */
+ XExtCodes *codes = XAddExtension(dpy);
+ if (!codes) {
+ XFree(dpyinfo);
+ return NULL;
+ }
+ XESetCloseDisplay (dpy, codes->extension, XRenderCloseDisplay);
+ }
+
+ /*
+ * now, chain it onto the list
+ */
+ _XLockMutex(_Xglobal_lock);
+ dpyinfo->next = extinfo->head;
+ extinfo->head = dpyinfo;
+ extinfo->cur = dpyinfo;
+ extinfo->ndisplays++;
+ _XUnlockMutex(_Xglobal_lock);
+ return dpyinfo;
+}
+
+
+/*
+ * XRenderExtRemoveDisplay - remove the indicated display from the
+ * extension object. (Replaces XextRemoveDisplay.)
+ */
+static int
+XRenderExtRemoveDisplay (XRenderExtInfo *extinfo, Display *dpy)
+{
+ XRenderExtDisplayInfo *dpyinfo, *prev;
+
+ /*
+ * locate this display and its back link so that it can be removed
+ */
+ _XLockMutex(_Xglobal_lock);
+ prev = NULL;
+ for (dpyinfo = extinfo->head; dpyinfo; dpyinfo = dpyinfo->next) {
+ if (dpyinfo->display == dpy) break;
+ prev = dpyinfo;
+ }
+ if (!dpyinfo) {
+ _XUnlockMutex(_Xglobal_lock);
+ return 0; /* hmm, actually an error */
+ }
+
+ /*
+ * remove the display from the list; handles going to zero
+ */
+ if (prev)
+ prev->next = dpyinfo->next;
+ else
+ extinfo->head = dpyinfo->next;
+
+ extinfo->ndisplays--;
+ if (dpyinfo == extinfo->cur) extinfo->cur = NULL; /* flush cache */
+ _XUnlockMutex(_Xglobal_lock);
+
+ Xfree ((char *) dpyinfo);
+ return 1;
+}
+
+
+
+XRenderExtDisplayInfo *
+XRenderFindDisplay (Display *dpy)
+{
+ XRenderExtDisplayInfo *dpyinfo;
+
+ dpyinfo = XRenderExtFindDisplay (&XRenderExtensionInfo, dpy);
+ if (!dpyinfo)
+ dpyinfo = XRenderExtAddDisplay (&XRenderExtensionInfo, dpy,
+ XRenderExtensionName);
+ return dpyinfo;
+}
+
+static int
+XRenderCloseDisplay (Display *dpy, XExtCodes *codes)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ if (info->info) XFree (info->info);
+
+ return XRenderExtRemoveDisplay (&XRenderExtensionInfo, dpy);
+}
+
+/****************************************************************************
+ * *
+ * Render public interfaces *
+ * *
+ ****************************************************************************/
+
+Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+
+ if (RenderHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+Status XRenderQueryVersion (Display *dpy,
+ int *major_versionp,
+ int *minor_versionp)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderInfo *xri;
+
+ if (!RenderHasExtension (info))
+ return 0;
+
+ if (!XRenderQueryFormats (dpy))
+ return 0;
+
+ xri = info->info;
+ *major_versionp = xri->major_version;
+ *minor_versionp = xri->minor_version;
+ return 1;
+}
+
+static XRenderPictFormat *
+_XRenderFindFormat (XRenderInfo *xri, PictFormat format)
+{
+ int nf;
+
+ for (nf = 0; nf < xri->nformat; nf++)
+ if (xri->format[nf].id == format)
+ return &xri->format[nf];
+ return 0;
+}
+
+static Visual *
+_XRenderFindVisual (Display *dpy, VisualID vid)
+{
+ return _XVIDtoVisual (dpy, vid);
+}
+
+typedef struct _renderVersionState {
+ unsigned long version_seq;
+ Bool error;
+ int major_version;
+ int minor_version;
+
+} _XrenderVersionState;
+
+static Bool
+_XRenderVersionHandler (Display *dpy,
+ xReply *rep,
+ char *buf,
+ int len,
+ XPointer data)
+{
+ xRenderQueryVersionReply replbuf;
+ xRenderQueryVersionReply *repl;
+ _XrenderVersionState *state = (_XrenderVersionState *) data;
+
+ if (dpy->last_request_read != state->version_seq)
+ return False;
+ if (rep->generic.type == X_Error)
+ {
+ state->error = True;
+ return False;
+ }
+ repl = (xRenderQueryVersionReply *)
+ _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
+ (SIZEOF(xRenderQueryVersionReply) - SIZEOF(xReply)) >> 2,
+ True);
+ state->major_version = repl->majorVersion;
+ state->minor_version = repl->minorVersion;
+ return True;
+}
+
+Status
+XRenderQueryFormats (Display *dpy)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ _XAsyncHandler async;
+ _XrenderVersionState async_state;
+ xRenderQueryVersionReq *vreq;
+ xRenderQueryPictFormatsReply rep;
+ xRenderQueryPictFormatsReq *req;
+ XRenderInfo *xri;
+ XRenderPictFormat *format;
+ XRenderScreen *screen;
+ XRenderDepth *depth;
+ XRenderVisual *visual;
+ xPictFormInfo *xFormat;
+ xPictScreen *xScreen;
+ xPictDepth *xDepth;
+ xPictVisual *xVisual;
+ CARD32 *xSubpixel;
+ void *xData;
+ int nf, ns, nd, nv;
+ int rlength;
+ int nbytes;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay (dpy);
+ if (info->info)
+ {
+ UnlockDisplay (dpy);
+ return 1;
+ }
+ GetReq (RenderQueryVersion, vreq);
+ vreq->reqType = info->codes->major_opcode;
+ vreq->renderReqType = X_RenderQueryVersion;
+ vreq->majorVersion = RENDER_MAJOR;
+ vreq->minorVersion = RENDER_MINOR;
+
+ async_state.version_seq = dpy->request;
+ async_state.error = False;
+ async.next = dpy->async_handlers;
+ async.handler = _XRenderVersionHandler;
+ async.data = (XPointer) &async_state;
+ dpy->async_handlers = &async;
+
+ GetReq (RenderQueryPictFormats, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderQueryPictFormats;
+
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ DeqAsyncHandler (dpy, &async);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ DeqAsyncHandler (dpy, &async);
+ if (async_state.error)
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ /*
+ * Check for the lack of sub-pixel data
+ */
+ if (async_state.major_version == 0 && async_state.minor_version < 6)
+ rep.numSubpixel = 0;
+
+ xri = (XRenderInfo *) Xmalloc (sizeof (XRenderInfo) +
+ rep.numFormats * sizeof (XRenderPictFormat) +
+ rep.numScreens * sizeof (XRenderScreen) +
+ rep.numDepths * sizeof (XRenderDepth) +
+ rep.numVisuals * sizeof (XRenderVisual));
+ xri->major_version = async_state.major_version;
+ xri->minor_version = async_state.minor_version;
+ xri->format = (XRenderPictFormat *) (xri + 1);
+ xri->nformat = rep.numFormats;
+ xri->screen = (XRenderScreen *) (xri->format + rep.numFormats);
+ xri->nscreen = rep.numScreens;
+ xri->depth = (XRenderDepth *) (xri->screen + rep.numScreens);
+ xri->ndepth = rep.numDepths;
+ xri->visual = (XRenderVisual *) (xri->depth + rep.numDepths);
+ xri->nvisual = rep.numVisuals;
+ rlength = (rep.numFormats * sizeof (xPictFormInfo) +
+ rep.numScreens * sizeof (xPictScreen) +
+ rep.numDepths * sizeof (xPictDepth) +
+ rep.numVisuals * sizeof (xPictVisual) +
+ rep.numSubpixel * 4);
+ xData = (void *) Xmalloc (rlength);
+ nbytes = (int) rep.length << 2;
+
+ if (!xri || !xData || nbytes < rlength)
+ {
+ if (xri) Xfree (xri);
+ if (xData) Xfree (xData);
+ _XEatData (dpy, nbytes);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ _XRead (dpy, (char *) xData, rlength);
+ format = xri->format;
+ xFormat = (xPictFormInfo *) xData;
+ for (nf = 0; nf < rep.numFormats; nf++)
+ {
+ format->id = xFormat->id;
+ format->type = xFormat->type;
+ format->depth = xFormat->depth;
+ format->direct.red = xFormat->direct.red;
+ format->direct.redMask = xFormat->direct.redMask;
+ format->direct.green = xFormat->direct.green;
+ format->direct.greenMask = xFormat->direct.greenMask;
+ format->direct.blue = xFormat->direct.blue;
+ format->direct.blueMask = xFormat->direct.blueMask;
+ format->direct.alpha = xFormat->direct.alpha;
+ format->direct.alphaMask = xFormat->direct.alphaMask;
+ format->colormap = xFormat->colormap;
+ format++;
+ xFormat++;
+ }
+ xScreen = (xPictScreen *) xFormat;
+ screen = xri->screen;
+ depth = xri->depth;
+ visual = xri->visual;
+ for (ns = 0; ns < xri->nscreen; ns++)
+ {
+ screen->depths = depth;
+ screen->ndepths = xScreen->nDepth;
+ screen->fallback = _XRenderFindFormat (xri, xScreen->fallback);
+ screen->subpixel = SubPixelUnknown;
+ xDepth = (xPictDepth *) (xScreen + 1);
+ for (nd = 0; nd < screen->ndepths; nd++)
+ {
+ depth->depth = xDepth->depth;
+ depth->nvisuals = xDepth->nPictVisuals;
+ depth->visuals = visual;
+ xVisual = (xPictVisual *) (xDepth + 1);
+ for (nv = 0; nv < depth->nvisuals; nv++)
+ {
+ visual->visual = _XRenderFindVisual (dpy, xVisual->visual);
+ visual->format = _XRenderFindFormat (xri, xVisual->format);
+ visual++;
+ xVisual++;
+ }
+ depth++;
+ xDepth = (xPictDepth *) xVisual;
+ }
+ screen++;
+ xScreen = (xPictScreen *) xDepth;
+ }
+ xSubpixel = (CARD32 *) xScreen;
+ screen = xri->screen;
+ for (ns = 0; ns < rep.numSubpixel; ns++)
+ {
+ screen->subpixel = *xSubpixel;
+ xSubpixel++;
+ screen++;
+ }
+ info->info = xri;
+ /*
+ * Skip any extra data
+ */
+ if (nbytes > rlength)
+ _XEatData (dpy, (unsigned long) (nbytes - rlength));
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ Xfree (xData);
+ return 1;
+}
+
+int
+XRenderQuerySubpixelOrder (Display *dpy, int screen)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderInfo *xri;
+
+ if (!RenderHasExtension (info))
+ return SubPixelUnknown;
+
+ if (!XRenderQueryFormats (dpy))
+ return SubPixelUnknown;
+
+ xri = info->info;
+ return xri->screen[screen].subpixel;
+}
+
+Bool
+XRenderSetSubpixelOrder (Display *dpy, int screen, int subpixel)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderInfo *xri;
+
+ if (!RenderHasExtension (info))
+ return False;
+
+ if (!XRenderQueryFormats (dpy))
+ return False;
+
+ xri = info->info;
+ xri->screen[screen].subpixel = subpixel;
+ return True;
+}
+
+XRenderPictFormat *
+XRenderFindVisualFormat (Display *dpy, _Xconst Visual *visual)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ int nv;
+ XRenderInfo *xri;
+ XRenderVisual *xrv;
+
+ RenderCheckExtension (dpy, info, 0);
+ if (!XRenderQueryFormats (dpy))
+ return 0;
+ xri = info->info;
+ for (nv = 0, xrv = xri->visual; nv < xri->nvisual; nv++, xrv++)
+ if (xrv->visual == visual)
+ return xrv->format;
+ return 0;
+}
+
+XRenderPictFormat *
+XRenderFindFormat (Display *dpy,
+ unsigned long mask,
+ _Xconst XRenderPictFormat *template,
+ int count)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ int nf;
+ XRenderInfo *xri;
+
+ RenderCheckExtension (dpy, info, 0);
+ if (!XRenderQueryFormats (dpy))
+ return 0;
+ xri = info->info;
+ for (nf = 0; nf < xri->nformat; nf++)
+ {
+ if (mask & PictFormatID)
+ if (template->id != xri->format[nf].id)
+ continue;
+ if (mask & PictFormatType)
+ if (template->type != xri->format[nf].type)
+ continue;
+ if (mask & PictFormatDepth)
+ if (template->depth != xri->format[nf].depth)
+ continue;
+ if (mask & PictFormatRed)
+ if (template->direct.red != xri->format[nf].direct.red)
+ continue;
+ if (mask & PictFormatRedMask)
+ if (template->direct.redMask != xri->format[nf].direct.redMask)
+ continue;
+ if (mask & PictFormatGreen)
+ if (template->direct.green != xri->format[nf].direct.green)
+ continue;
+ if (mask & PictFormatGreenMask)
+ if (template->direct.greenMask != xri->format[nf].direct.greenMask)
+ continue;
+ if (mask & PictFormatBlue)
+ if (template->direct.blue != xri->format[nf].direct.blue)
+ continue;
+ if (mask & PictFormatBlueMask)
+ if (template->direct.blueMask != xri->format[nf].direct.blueMask)
+ continue;
+ if (mask & PictFormatAlpha)
+ if (template->direct.alpha != xri->format[nf].direct.alpha)
+ continue;
+ if (mask & PictFormatAlphaMask)
+ if (template->direct.alphaMask != xri->format[nf].direct.alphaMask)
+ continue;
+ if (mask & PictFormatColormap)
+ if (template->colormap != xri->format[nf].colormap)
+ continue;
+ if (count-- == 0)
+ return &xri->format[nf];
+ }
+ return 0;
+}
+
+XRenderPictFormat *
+XRenderFindStandardFormat (Display *dpy,
+ int format)
+{
+ static struct {
+ XRenderPictFormat templ;
+ unsigned long mask;
+ } standardFormats[PictStandardNUM] = {
+ /* PictStandardARGB32 */
+ {
+ {
+ 0, /* id */
+ PictTypeDirect, /* type */
+ 32, /* depth */
+ { /* direct */
+ 16, /* direct.red */
+ 0xff, /* direct.redMask */
+ 8, /* direct.green */
+ 0xff, /* direct.greenMask */
+ 0, /* direct.blue */
+ 0xff, /* direct.blueMask */
+ 24, /* direct.alpha */
+ 0xff, /* direct.alphaMask */
+ },
+ 0, /* colormap */
+ },
+ PictFormatType |
+ PictFormatDepth |
+ PictFormatRed |
+ PictFormatRedMask |
+ PictFormatGreen |
+ PictFormatGreenMask |
+ PictFormatBlue |
+ PictFormatBlueMask |
+ PictFormatAlpha |
+ PictFormatAlphaMask,
+ },
+ /* PictStandardRGB24 */
+ {
+ {
+ 0, /* id */
+ PictTypeDirect, /* type */
+ 24, /* depth */
+ { /* direct */
+ 16, /* direct.red */
+ 0xff, /* direct.redMask */
+ 8, /* direct.green */
+ 0xff, /* direct.greenMask */
+ 0, /* direct.blue */
+ 0xff, /* direct.blueMask */
+ 0, /* direct.alpha */
+ 0x00, /* direct.alphaMask */
+ },
+ 0, /* colormap */
+ },
+ PictFormatType |
+ PictFormatDepth |
+ PictFormatRed |
+ PictFormatRedMask |
+ PictFormatGreen |
+ PictFormatGreenMask |
+ PictFormatBlue |
+ PictFormatBlueMask |
+ PictFormatAlphaMask,
+ },
+ /* PictStandardA8 */
+ {
+ {
+ 0, /* id */
+ PictTypeDirect, /* type */
+ 8, /* depth */
+ { /* direct */
+ 0, /* direct.red */
+ 0x00, /* direct.redMask */
+ 0, /* direct.green */
+ 0x00, /* direct.greenMask */
+ 0, /* direct.blue */
+ 0x00, /* direct.blueMask */
+ 0, /* direct.alpha */
+ 0xff, /* direct.alphaMask */
+ },
+ 0, /* colormap */
+ },
+ PictFormatType |
+ PictFormatDepth |
+ PictFormatRedMask |
+ PictFormatGreenMask |
+ PictFormatBlueMask |
+ PictFormatAlpha |
+ PictFormatAlphaMask,
+ },
+ /* PictStandardA4 */
+ {
+ {
+ 0, /* id */
+ PictTypeDirect, /* type */
+ 4, /* depth */
+ { /* direct */
+ 0, /* direct.red */
+ 0x00, /* direct.redMask */
+ 0, /* direct.green */
+ 0x00, /* direct.greenMask */
+ 0, /* direct.blue */
+ 0x00, /* direct.blueMask */
+ 0, /* direct.alpha */
+ 0x0f, /* direct.alphaMask */
+ },
+ 0, /* colormap */
+ },
+ PictFormatType |
+ PictFormatDepth |
+ PictFormatRedMask |
+ PictFormatGreenMask |
+ PictFormatBlueMask |
+ PictFormatAlpha |
+ PictFormatAlphaMask,
+ },
+ /* PictStandardA1 */
+ {
+ {
+ 0, /* id */
+ PictTypeDirect, /* type */
+ 1, /* depth */
+ { /* direct */
+ 0, /* direct.red */
+ 0x00, /* direct.redMask */
+ 0, /* direct.green */
+ 0x00, /* direct.greenMask */
+ 0, /* direct.blue */
+ 0x00, /* direct.blueMask */
+ 0, /* direct.alpha */
+ 0x01, /* direct.alphaMask */
+ },
+ 0, /* colormap */
+ },
+ PictFormatType |
+ PictFormatDepth |
+ PictFormatRedMask |
+ PictFormatGreenMask |
+ PictFormatBlueMask |
+ PictFormatAlpha |
+ PictFormatAlphaMask,
+ },
+ };
+
+ if (0 <= format && format < PictStandardNUM)
+ return XRenderFindFormat (dpy,
+ standardFormats[format].mask,
+ &standardFormats[format].templ,
+ 0);
+ return 0;
+}
+
+XIndexValue *
+XRenderQueryPictIndexValues(Display *dpy,
+ _Xconst XRenderPictFormat *format,
+ int *num)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ xRenderQueryPictIndexValuesReq *req;
+ xRenderQueryPictIndexValuesReply rep;
+ XIndexValue *values;
+ int nbytes, nread, rlength, i;
+
+ RenderCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (RenderQueryPictIndexValues, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderQueryPictIndexValues;
+ req->format = format->id;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+
+ /* request data length */
+ nbytes = (long)rep.length << 2;
+ /* bytes of actual data in the request */
+ nread = rep.numIndexValues * SIZEOF (xIndexValue);
+ /* size of array returned to application */
+ rlength = rep.numIndexValues * sizeof (XIndexValue);
+
+ /* allocate returned data */
+ values = (XIndexValue *)Xmalloc (rlength);
+ if (!values)
+ {
+ _XEatData (dpy, nbytes);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+
+ /* read the values one at a time and convert */
+ *num = rep.numIndexValues;
+ for(i = 0; i < rep.numIndexValues; i++)
+ {
+ xIndexValue value;
+
+ _XRead (dpy, (char *) &value, SIZEOF (xIndexValue));
+ values[i].pixel = value.pixel;
+ values[i].red = value.red;
+ values[i].green = value.green;
+ values[i].blue = value.blue;
+ values[i].alpha = value.alpha;
+ }
+ /* skip any padding */
+ if(nbytes > nread)
+ {
+ _XEatData (dpy, (unsigned long) (nbytes - nread));
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return values;
+}
diff --git a/nx-X11/lib/Xrender/Xrender.h b/nx-X11/lib/Xrender/Xrender.h
new file mode 100644
index 000000000..4d125cd81
--- /dev/null
+++ b/nx-X11/lib/Xrender/Xrender.h
@@ -0,0 +1,544 @@
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _XRENDER_H_
+#define _XRENDER_H_
+
+#define NX_CLEANUP
+
+#include <X11/extensions/render.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+#include <X11/Xutil.h>
+
+#ifdef NX_CLEANUP
+#include "renderproto.h"
+#endif
+
+typedef struct {
+ short red;
+ short redMask;
+ short green;
+ short greenMask;
+ short blue;
+ short blueMask;
+ short alpha;
+ short alphaMask;
+} XRenderDirectFormat;
+
+typedef struct {
+ PictFormat id;
+ int type;
+ int depth;
+ XRenderDirectFormat direct;
+ Colormap colormap;
+} XRenderPictFormat;
+
+#define PictFormatID (1 << 0)
+#define PictFormatType (1 << 1)
+#define PictFormatDepth (1 << 2)
+#define PictFormatRed (1 << 3)
+#define PictFormatRedMask (1 << 4)
+#define PictFormatGreen (1 << 5)
+#define PictFormatGreenMask (1 << 6)
+#define PictFormatBlue (1 << 7)
+#define PictFormatBlueMask (1 << 8)
+#define PictFormatAlpha (1 << 9)
+#define PictFormatAlphaMask (1 << 10)
+#define PictFormatColormap (1 << 11)
+
+typedef struct _XRenderPictureAttributes {
+ int repeat;
+ Picture alpha_map;
+ int alpha_x_origin;
+ int alpha_y_origin;
+ int clip_x_origin;
+ int clip_y_origin;
+ Pixmap clip_mask;
+ Bool graphics_exposures;
+ int subwindow_mode;
+ int poly_edge;
+ int poly_mode;
+ Atom dither;
+ Bool component_alpha;
+} XRenderPictureAttributes;
+
+typedef struct {
+ unsigned short red;
+ unsigned short green;
+ unsigned short blue;
+ unsigned short alpha;
+} XRenderColor;
+
+typedef struct _XGlyphInfo {
+ unsigned short width;
+ unsigned short height;
+ short x;
+ short y;
+ short xOff;
+ short yOff;
+} XGlyphInfo;
+
+typedef struct _XGlyphElt8 {
+ GlyphSet glyphset;
+ _Xconst char *chars;
+ int nchars;
+ int xOff;
+ int yOff;
+} XGlyphElt8;
+
+typedef struct _XGlyphElt16 {
+ GlyphSet glyphset;
+ _Xconst unsigned short *chars;
+ int nchars;
+ int xOff;
+ int yOff;
+} XGlyphElt16;
+
+typedef struct _XGlyphElt32 {
+ GlyphSet glyphset;
+ _Xconst unsigned int *chars;
+ int nchars;
+ int xOff;
+ int yOff;
+} XGlyphElt32;
+
+typedef double XDouble;
+
+typedef struct _XPointDouble {
+ XDouble x, y;
+} XPointDouble;
+
+#define XDoubleToFixed(f) ((XFixed) ((f) * 65536))
+#define XFixedToDouble(f) (((XDouble) (f)) / 65536)
+
+typedef int XFixed;
+
+typedef struct _XPointFixed {
+ XFixed x, y;
+} XPointFixed;
+
+typedef struct _XLineFixed {
+ XPointFixed p1, p2;
+} XLineFixed;
+
+typedef struct _XTriangle {
+ XPointFixed p1, p2, p3;
+} XTriangle;
+
+typedef struct _XCircle {
+ XFixed x;
+ XFixed y;
+ XFixed radius;
+} XCircle;
+
+typedef struct _XTrapezoid {
+ XFixed top, bottom;
+ XLineFixed left, right;
+} XTrapezoid;
+
+typedef struct _XTransform {
+ XFixed matrix[3][3];
+} XTransform;
+
+typedef struct _XFilters {
+ int nfilter;
+ char **filter;
+ int nalias;
+ short *alias;
+} XFilters;
+
+typedef struct _XIndexValue {
+ unsigned long pixel;
+ unsigned short red, green, blue, alpha;
+} XIndexValue;
+
+typedef struct _XAnimCursor {
+ Cursor cursor;
+ unsigned long delay;
+} XAnimCursor;
+
+typedef struct _XSpanFix {
+ XFixed left, right, y;
+} XSpanFix;
+
+typedef struct _XTrap {
+ XSpanFix top, bottom;
+} XTrap;
+
+typedef struct _XLinearGradient {
+ XPointFixed p1;
+ XPointFixed p2;
+} XLinearGradient;
+
+typedef struct _XRadialGradient {
+ XCircle inner;
+ XCircle outer;
+} XRadialGradient;
+
+typedef struct _XConicalGradient {
+ XPointFixed center;
+ XFixed angle; /* in degrees */
+} XConicalGradient;
+
+_XFUNCPROTOBEGIN
+
+Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep);
+
+Status XRenderQueryVersion (Display *dpy,
+ int *major_versionp,
+ int *minor_versionp);
+
+Status XRenderQueryFormats (Display *dpy);
+
+int XRenderQuerySubpixelOrder (Display *dpy, int screen);
+
+Bool XRenderSetSubpixelOrder (Display *dpy, int screen, int subpixel);
+
+XRenderPictFormat *
+XRenderFindVisualFormat (Display *dpy, _Xconst Visual *visual);
+
+XRenderPictFormat *
+XRenderFindFormat (Display *dpy,
+ unsigned long mask,
+ _Xconst XRenderPictFormat *templ,
+ int count);
+
+#define PictStandardARGB32 0
+#define PictStandardRGB24 1
+#define PictStandardA8 2
+#define PictStandardA4 3
+#define PictStandardA1 4
+#define PictStandardNUM 5
+
+XRenderPictFormat *
+XRenderFindStandardFormat (Display *dpy,
+ int format);
+
+XIndexValue *
+XRenderQueryPictIndexValues(Display *dpy,
+ _Xconst XRenderPictFormat *format,
+ int *num);
+
+Picture
+XRenderCreatePicture (Display *dpy,
+ Drawable drawable,
+ _Xconst XRenderPictFormat *format,
+ unsigned long valuemask,
+ _Xconst XRenderPictureAttributes *attributes);
+
+void
+XRenderChangePicture (Display *dpy,
+ Picture picture,
+ unsigned long valuemask,
+ _Xconst XRenderPictureAttributes *attributes);
+
+void
+XRenderSetPictureClipRectangles (Display *dpy,
+ Picture picture,
+ int xOrigin,
+ int yOrigin,
+ _Xconst XRectangle *rects,
+ int n);
+
+void
+XRenderSetPictureClipRegion (Display *dpy,
+ Picture picture,
+ Region r);
+
+void
+XRenderSetPictureTransform (Display *dpy,
+ Picture picture,
+ XTransform *transform);
+
+void
+XRenderFreePicture (Display *dpy,
+ Picture picture);
+
+void
+XRenderComposite (Display *dpy,
+ int op,
+ Picture src,
+ Picture mask,
+ Picture dst,
+ int src_x,
+ int src_y,
+ int mask_x,
+ int mask_y,
+ int dst_x,
+ int dst_y,
+ unsigned int width,
+ unsigned int height);
+
+GlyphSet
+XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format);
+
+GlyphSet
+XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing);
+
+void
+XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset);
+
+#ifdef NX_CLEANUP
+
+void XRenderCleanGlyphs (xGlyphInfo *gi,
+ int nglyphs,
+ CARD8 *images,
+ int depth,
+ Display *dpy);
+
+#endif /* #ifdef NX_CLEANUP */
+
+void
+XRenderAddGlyphs (Display *dpy,
+ GlyphSet glyphset,
+ _Xconst Glyph *gids,
+ _Xconst XGlyphInfo *glyphs,
+ int nglyphs,
+ _Xconst char *images,
+ int nbyte_images);
+
+void
+XRenderFreeGlyphs (Display *dpy,
+ GlyphSet glyphset,
+ _Xconst Glyph *gids,
+ int nglyphs);
+
+void
+XRenderCompositeString8 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst char *string,
+ int nchar);
+
+void
+XRenderCompositeString16 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst unsigned short *string,
+ int nchar);
+
+void
+XRenderCompositeString32 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst unsigned int *string,
+ int nchar);
+
+void
+XRenderCompositeText8 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt8 *elts,
+ int nelt);
+
+void
+XRenderCompositeText16 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt16 *elts,
+ int nelt);
+
+void
+XRenderCompositeText32 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt32 *elts,
+ int nelt);
+
+void
+XRenderFillRectangle (Display *dpy,
+ int op,
+ Picture dst,
+ _Xconst XRenderColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height);
+
+void
+XRenderFillRectangles (Display *dpy,
+ int op,
+ Picture dst,
+ _Xconst XRenderColor *color,
+ _Xconst XRectangle *rectangles,
+ int n_rects);
+
+void
+XRenderCompositeTrapezoids (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XTrapezoid *traps,
+ int ntrap);
+
+void
+XRenderCompositeTriangles (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XTriangle *triangles,
+ int ntriangle);
+
+void
+XRenderCompositeTriStrip (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XPointFixed *points,
+ int npoint);
+
+void
+XRenderCompositeTriFan (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XPointFixed *points,
+ int npoint);
+
+void
+XRenderCompositeDoublePoly (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XPointDouble *fpoints,
+ int npoints,
+ int winding);
+Status
+XRenderParseColor(Display *dpy,
+ char *spec,
+ XRenderColor *def);
+
+Cursor
+XRenderCreateCursor (Display *dpy,
+ Picture source,
+ unsigned int x,
+ unsigned int y);
+
+XFilters *
+XRenderQueryFilters (Display *dpy, Drawable drawable);
+
+void
+XRenderSetPictureFilter (Display *dpy,
+ Picture picture,
+ char *filter,
+ XFixed *params,
+ int nparams);
+
+Cursor
+XRenderCreateAnimCursor (Display *dpy,
+ int ncursor,
+ XAnimCursor *cursors);
+
+
+void
+XRenderAddTraps (Display *dpy,
+ Picture picture,
+ int xOff,
+ int yOff,
+ _Xconst XTrap *traps,
+ int ntrap);
+
+Picture XRenderCreateSolidFill (Display *dpy,
+ const XRenderColor *color);
+
+Picture XRenderCreateLinearGradient (Display *dpy,
+ const XLinearGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nstops);
+
+Picture XRenderCreateRadialGradient (Display *dpy,
+ const XRadialGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nstops);
+
+Picture XRenderCreateConicalGradient (Display *dpy,
+ const XConicalGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nstops);
+
+_XFUNCPROTOEND
+
+#endif /* _XRENDER_H_ */
diff --git a/nx-X11/lib/Xrender/Xrender.h.NX.original b/nx-X11/lib/Xrender/Xrender.h.NX.original
new file mode 100644
index 000000000..4d125cd81
--- /dev/null
+++ b/nx-X11/lib/Xrender/Xrender.h.NX.original
@@ -0,0 +1,544 @@
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _XRENDER_H_
+#define _XRENDER_H_
+
+#define NX_CLEANUP
+
+#include <X11/extensions/render.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+#include <X11/Xutil.h>
+
+#ifdef NX_CLEANUP
+#include "renderproto.h"
+#endif
+
+typedef struct {
+ short red;
+ short redMask;
+ short green;
+ short greenMask;
+ short blue;
+ short blueMask;
+ short alpha;
+ short alphaMask;
+} XRenderDirectFormat;
+
+typedef struct {
+ PictFormat id;
+ int type;
+ int depth;
+ XRenderDirectFormat direct;
+ Colormap colormap;
+} XRenderPictFormat;
+
+#define PictFormatID (1 << 0)
+#define PictFormatType (1 << 1)
+#define PictFormatDepth (1 << 2)
+#define PictFormatRed (1 << 3)
+#define PictFormatRedMask (1 << 4)
+#define PictFormatGreen (1 << 5)
+#define PictFormatGreenMask (1 << 6)
+#define PictFormatBlue (1 << 7)
+#define PictFormatBlueMask (1 << 8)
+#define PictFormatAlpha (1 << 9)
+#define PictFormatAlphaMask (1 << 10)
+#define PictFormatColormap (1 << 11)
+
+typedef struct _XRenderPictureAttributes {
+ int repeat;
+ Picture alpha_map;
+ int alpha_x_origin;
+ int alpha_y_origin;
+ int clip_x_origin;
+ int clip_y_origin;
+ Pixmap clip_mask;
+ Bool graphics_exposures;
+ int subwindow_mode;
+ int poly_edge;
+ int poly_mode;
+ Atom dither;
+ Bool component_alpha;
+} XRenderPictureAttributes;
+
+typedef struct {
+ unsigned short red;
+ unsigned short green;
+ unsigned short blue;
+ unsigned short alpha;
+} XRenderColor;
+
+typedef struct _XGlyphInfo {
+ unsigned short width;
+ unsigned short height;
+ short x;
+ short y;
+ short xOff;
+ short yOff;
+} XGlyphInfo;
+
+typedef struct _XGlyphElt8 {
+ GlyphSet glyphset;
+ _Xconst char *chars;
+ int nchars;
+ int xOff;
+ int yOff;
+} XGlyphElt8;
+
+typedef struct _XGlyphElt16 {
+ GlyphSet glyphset;
+ _Xconst unsigned short *chars;
+ int nchars;
+ int xOff;
+ int yOff;
+} XGlyphElt16;
+
+typedef struct _XGlyphElt32 {
+ GlyphSet glyphset;
+ _Xconst unsigned int *chars;
+ int nchars;
+ int xOff;
+ int yOff;
+} XGlyphElt32;
+
+typedef double XDouble;
+
+typedef struct _XPointDouble {
+ XDouble x, y;
+} XPointDouble;
+
+#define XDoubleToFixed(f) ((XFixed) ((f) * 65536))
+#define XFixedToDouble(f) (((XDouble) (f)) / 65536)
+
+typedef int XFixed;
+
+typedef struct _XPointFixed {
+ XFixed x, y;
+} XPointFixed;
+
+typedef struct _XLineFixed {
+ XPointFixed p1, p2;
+} XLineFixed;
+
+typedef struct _XTriangle {
+ XPointFixed p1, p2, p3;
+} XTriangle;
+
+typedef struct _XCircle {
+ XFixed x;
+ XFixed y;
+ XFixed radius;
+} XCircle;
+
+typedef struct _XTrapezoid {
+ XFixed top, bottom;
+ XLineFixed left, right;
+} XTrapezoid;
+
+typedef struct _XTransform {
+ XFixed matrix[3][3];
+} XTransform;
+
+typedef struct _XFilters {
+ int nfilter;
+ char **filter;
+ int nalias;
+ short *alias;
+} XFilters;
+
+typedef struct _XIndexValue {
+ unsigned long pixel;
+ unsigned short red, green, blue, alpha;
+} XIndexValue;
+
+typedef struct _XAnimCursor {
+ Cursor cursor;
+ unsigned long delay;
+} XAnimCursor;
+
+typedef struct _XSpanFix {
+ XFixed left, right, y;
+} XSpanFix;
+
+typedef struct _XTrap {
+ XSpanFix top, bottom;
+} XTrap;
+
+typedef struct _XLinearGradient {
+ XPointFixed p1;
+ XPointFixed p2;
+} XLinearGradient;
+
+typedef struct _XRadialGradient {
+ XCircle inner;
+ XCircle outer;
+} XRadialGradient;
+
+typedef struct _XConicalGradient {
+ XPointFixed center;
+ XFixed angle; /* in degrees */
+} XConicalGradient;
+
+_XFUNCPROTOBEGIN
+
+Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep);
+
+Status XRenderQueryVersion (Display *dpy,
+ int *major_versionp,
+ int *minor_versionp);
+
+Status XRenderQueryFormats (Display *dpy);
+
+int XRenderQuerySubpixelOrder (Display *dpy, int screen);
+
+Bool XRenderSetSubpixelOrder (Display *dpy, int screen, int subpixel);
+
+XRenderPictFormat *
+XRenderFindVisualFormat (Display *dpy, _Xconst Visual *visual);
+
+XRenderPictFormat *
+XRenderFindFormat (Display *dpy,
+ unsigned long mask,
+ _Xconst XRenderPictFormat *templ,
+ int count);
+
+#define PictStandardARGB32 0
+#define PictStandardRGB24 1
+#define PictStandardA8 2
+#define PictStandardA4 3
+#define PictStandardA1 4
+#define PictStandardNUM 5
+
+XRenderPictFormat *
+XRenderFindStandardFormat (Display *dpy,
+ int format);
+
+XIndexValue *
+XRenderQueryPictIndexValues(Display *dpy,
+ _Xconst XRenderPictFormat *format,
+ int *num);
+
+Picture
+XRenderCreatePicture (Display *dpy,
+ Drawable drawable,
+ _Xconst XRenderPictFormat *format,
+ unsigned long valuemask,
+ _Xconst XRenderPictureAttributes *attributes);
+
+void
+XRenderChangePicture (Display *dpy,
+ Picture picture,
+ unsigned long valuemask,
+ _Xconst XRenderPictureAttributes *attributes);
+
+void
+XRenderSetPictureClipRectangles (Display *dpy,
+ Picture picture,
+ int xOrigin,
+ int yOrigin,
+ _Xconst XRectangle *rects,
+ int n);
+
+void
+XRenderSetPictureClipRegion (Display *dpy,
+ Picture picture,
+ Region r);
+
+void
+XRenderSetPictureTransform (Display *dpy,
+ Picture picture,
+ XTransform *transform);
+
+void
+XRenderFreePicture (Display *dpy,
+ Picture picture);
+
+void
+XRenderComposite (Display *dpy,
+ int op,
+ Picture src,
+ Picture mask,
+ Picture dst,
+ int src_x,
+ int src_y,
+ int mask_x,
+ int mask_y,
+ int dst_x,
+ int dst_y,
+ unsigned int width,
+ unsigned int height);
+
+GlyphSet
+XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format);
+
+GlyphSet
+XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing);
+
+void
+XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset);
+
+#ifdef NX_CLEANUP
+
+void XRenderCleanGlyphs (xGlyphInfo *gi,
+ int nglyphs,
+ CARD8 *images,
+ int depth,
+ Display *dpy);
+
+#endif /* #ifdef NX_CLEANUP */
+
+void
+XRenderAddGlyphs (Display *dpy,
+ GlyphSet glyphset,
+ _Xconst Glyph *gids,
+ _Xconst XGlyphInfo *glyphs,
+ int nglyphs,
+ _Xconst char *images,
+ int nbyte_images);
+
+void
+XRenderFreeGlyphs (Display *dpy,
+ GlyphSet glyphset,
+ _Xconst Glyph *gids,
+ int nglyphs);
+
+void
+XRenderCompositeString8 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst char *string,
+ int nchar);
+
+void
+XRenderCompositeString16 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst unsigned short *string,
+ int nchar);
+
+void
+XRenderCompositeString32 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst unsigned int *string,
+ int nchar);
+
+void
+XRenderCompositeText8 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt8 *elts,
+ int nelt);
+
+void
+XRenderCompositeText16 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt16 *elts,
+ int nelt);
+
+void
+XRenderCompositeText32 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt32 *elts,
+ int nelt);
+
+void
+XRenderFillRectangle (Display *dpy,
+ int op,
+ Picture dst,
+ _Xconst XRenderColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height);
+
+void
+XRenderFillRectangles (Display *dpy,
+ int op,
+ Picture dst,
+ _Xconst XRenderColor *color,
+ _Xconst XRectangle *rectangles,
+ int n_rects);
+
+void
+XRenderCompositeTrapezoids (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XTrapezoid *traps,
+ int ntrap);
+
+void
+XRenderCompositeTriangles (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XTriangle *triangles,
+ int ntriangle);
+
+void
+XRenderCompositeTriStrip (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XPointFixed *points,
+ int npoint);
+
+void
+XRenderCompositeTriFan (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XPointFixed *points,
+ int npoint);
+
+void
+XRenderCompositeDoublePoly (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XPointDouble *fpoints,
+ int npoints,
+ int winding);
+Status
+XRenderParseColor(Display *dpy,
+ char *spec,
+ XRenderColor *def);
+
+Cursor
+XRenderCreateCursor (Display *dpy,
+ Picture source,
+ unsigned int x,
+ unsigned int y);
+
+XFilters *
+XRenderQueryFilters (Display *dpy, Drawable drawable);
+
+void
+XRenderSetPictureFilter (Display *dpy,
+ Picture picture,
+ char *filter,
+ XFixed *params,
+ int nparams);
+
+Cursor
+XRenderCreateAnimCursor (Display *dpy,
+ int ncursor,
+ XAnimCursor *cursors);
+
+
+void
+XRenderAddTraps (Display *dpy,
+ Picture picture,
+ int xOff,
+ int yOff,
+ _Xconst XTrap *traps,
+ int ntrap);
+
+Picture XRenderCreateSolidFill (Display *dpy,
+ const XRenderColor *color);
+
+Picture XRenderCreateLinearGradient (Display *dpy,
+ const XLinearGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nstops);
+
+Picture XRenderCreateRadialGradient (Display *dpy,
+ const XRadialGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nstops);
+
+Picture XRenderCreateConicalGradient (Display *dpy,
+ const XConicalGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nstops);
+
+_XFUNCPROTOEND
+
+#endif /* _XRENDER_H_ */
diff --git a/nx-X11/lib/Xrender/Xrender.h.X.original b/nx-X11/lib/Xrender/Xrender.h.X.original
new file mode 100644
index 000000000..4e4723a64
--- /dev/null
+++ b/nx-X11/lib/Xrender/Xrender.h.X.original
@@ -0,0 +1,528 @@
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _XRENDER_H_
+#define _XRENDER_H_
+
+#include <X11/extensions/render.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+#include <X11/Xutil.h>
+
+typedef struct {
+ short red;
+ short redMask;
+ short green;
+ short greenMask;
+ short blue;
+ short blueMask;
+ short alpha;
+ short alphaMask;
+} XRenderDirectFormat;
+
+typedef struct {
+ PictFormat id;
+ int type;
+ int depth;
+ XRenderDirectFormat direct;
+ Colormap colormap;
+} XRenderPictFormat;
+
+#define PictFormatID (1 << 0)
+#define PictFormatType (1 << 1)
+#define PictFormatDepth (1 << 2)
+#define PictFormatRed (1 << 3)
+#define PictFormatRedMask (1 << 4)
+#define PictFormatGreen (1 << 5)
+#define PictFormatGreenMask (1 << 6)
+#define PictFormatBlue (1 << 7)
+#define PictFormatBlueMask (1 << 8)
+#define PictFormatAlpha (1 << 9)
+#define PictFormatAlphaMask (1 << 10)
+#define PictFormatColormap (1 << 11)
+
+typedef struct _XRenderPictureAttributes {
+ int repeat;
+ Picture alpha_map;
+ int alpha_x_origin;
+ int alpha_y_origin;
+ int clip_x_origin;
+ int clip_y_origin;
+ Pixmap clip_mask;
+ Bool graphics_exposures;
+ int subwindow_mode;
+ int poly_edge;
+ int poly_mode;
+ Atom dither;
+ Bool component_alpha;
+} XRenderPictureAttributes;
+
+typedef struct {
+ unsigned short red;
+ unsigned short green;
+ unsigned short blue;
+ unsigned short alpha;
+} XRenderColor;
+
+typedef struct _XGlyphInfo {
+ unsigned short width;
+ unsigned short height;
+ short x;
+ short y;
+ short xOff;
+ short yOff;
+} XGlyphInfo;
+
+typedef struct _XGlyphElt8 {
+ GlyphSet glyphset;
+ _Xconst char *chars;
+ int nchars;
+ int xOff;
+ int yOff;
+} XGlyphElt8;
+
+typedef struct _XGlyphElt16 {
+ GlyphSet glyphset;
+ _Xconst unsigned short *chars;
+ int nchars;
+ int xOff;
+ int yOff;
+} XGlyphElt16;
+
+typedef struct _XGlyphElt32 {
+ GlyphSet glyphset;
+ _Xconst unsigned int *chars;
+ int nchars;
+ int xOff;
+ int yOff;
+} XGlyphElt32;
+
+typedef double XDouble;
+
+typedef struct _XPointDouble {
+ XDouble x, y;
+} XPointDouble;
+
+#define XDoubleToFixed(f) ((XFixed) ((f) * 65536))
+#define XFixedToDouble(f) (((XDouble) (f)) / 65536)
+
+typedef int XFixed;
+
+typedef struct _XPointFixed {
+ XFixed x, y;
+} XPointFixed;
+
+typedef struct _XLineFixed {
+ XPointFixed p1, p2;
+} XLineFixed;
+
+typedef struct _XTriangle {
+ XPointFixed p1, p2, p3;
+} XTriangle;
+
+typedef struct _XCircle {
+ XFixed x;
+ XFixed y;
+ XFixed radius;
+} XCircle;
+
+typedef struct _XTrapezoid {
+ XFixed top, bottom;
+ XLineFixed left, right;
+} XTrapezoid;
+
+typedef struct _XTransform {
+ XFixed matrix[3][3];
+} XTransform;
+
+typedef struct _XFilters {
+ int nfilter;
+ char **filter;
+ int nalias;
+ short *alias;
+} XFilters;
+
+typedef struct _XIndexValue {
+ unsigned long pixel;
+ unsigned short red, green, blue, alpha;
+} XIndexValue;
+
+typedef struct _XAnimCursor {
+ Cursor cursor;
+ unsigned long delay;
+} XAnimCursor;
+
+typedef struct _XSpanFix {
+ XFixed left, right, y;
+} XSpanFix;
+
+typedef struct _XTrap {
+ XSpanFix top, bottom;
+} XTrap;
+
+typedef struct _XLinearGradient {
+ XPointFixed p1;
+ XPointFixed p2;
+} XLinearGradient;
+
+typedef struct _XRadialGradient {
+ XCircle inner;
+ XCircle outer;
+} XRadialGradient;
+
+typedef struct _XConicalGradient {
+ XPointFixed center;
+ XFixed angle; /* in degrees */
+} XConicalGradient;
+
+_XFUNCPROTOBEGIN
+
+Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep);
+
+Status XRenderQueryVersion (Display *dpy,
+ int *major_versionp,
+ int *minor_versionp);
+
+Status XRenderQueryFormats (Display *dpy);
+
+int XRenderQuerySubpixelOrder (Display *dpy, int screen);
+
+Bool XRenderSetSubpixelOrder (Display *dpy, int screen, int subpixel);
+
+XRenderPictFormat *
+XRenderFindVisualFormat (Display *dpy, _Xconst Visual *visual);
+
+XRenderPictFormat *
+XRenderFindFormat (Display *dpy,
+ unsigned long mask,
+ _Xconst XRenderPictFormat *templ,
+ int count);
+
+#define PictStandardARGB32 0
+#define PictStandardRGB24 1
+#define PictStandardA8 2
+#define PictStandardA4 3
+#define PictStandardA1 4
+#define PictStandardNUM 5
+
+XRenderPictFormat *
+XRenderFindStandardFormat (Display *dpy,
+ int format);
+
+XIndexValue *
+XRenderQueryPictIndexValues(Display *dpy,
+ _Xconst XRenderPictFormat *format,
+ int *num);
+
+Picture
+XRenderCreatePicture (Display *dpy,
+ Drawable drawable,
+ _Xconst XRenderPictFormat *format,
+ unsigned long valuemask,
+ _Xconst XRenderPictureAttributes *attributes);
+
+void
+XRenderChangePicture (Display *dpy,
+ Picture picture,
+ unsigned long valuemask,
+ _Xconst XRenderPictureAttributes *attributes);
+
+void
+XRenderSetPictureClipRectangles (Display *dpy,
+ Picture picture,
+ int xOrigin,
+ int yOrigin,
+ _Xconst XRectangle *rects,
+ int n);
+
+void
+XRenderSetPictureClipRegion (Display *dpy,
+ Picture picture,
+ Region r);
+
+void
+XRenderSetPictureTransform (Display *dpy,
+ Picture picture,
+ XTransform *transform);
+
+void
+XRenderFreePicture (Display *dpy,
+ Picture picture);
+
+void
+XRenderComposite (Display *dpy,
+ int op,
+ Picture src,
+ Picture mask,
+ Picture dst,
+ int src_x,
+ int src_y,
+ int mask_x,
+ int mask_y,
+ int dst_x,
+ int dst_y,
+ unsigned int width,
+ unsigned int height);
+
+GlyphSet
+XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format);
+
+GlyphSet
+XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing);
+
+void
+XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset);
+
+void
+XRenderAddGlyphs (Display *dpy,
+ GlyphSet glyphset,
+ _Xconst Glyph *gids,
+ _Xconst XGlyphInfo *glyphs,
+ int nglyphs,
+ _Xconst char *images,
+ int nbyte_images);
+
+void
+XRenderFreeGlyphs (Display *dpy,
+ GlyphSet glyphset,
+ _Xconst Glyph *gids,
+ int nglyphs);
+
+void
+XRenderCompositeString8 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst char *string,
+ int nchar);
+
+void
+XRenderCompositeString16 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst unsigned short *string,
+ int nchar);
+
+void
+XRenderCompositeString32 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ GlyphSet glyphset,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst unsigned int *string,
+ int nchar);
+
+void
+XRenderCompositeText8 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt8 *elts,
+ int nelt);
+
+void
+XRenderCompositeText16 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt16 *elts,
+ int nelt);
+
+void
+XRenderCompositeText32 (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XGlyphElt32 *elts,
+ int nelt);
+
+void
+XRenderFillRectangle (Display *dpy,
+ int op,
+ Picture dst,
+ _Xconst XRenderColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height);
+
+void
+XRenderFillRectangles (Display *dpy,
+ int op,
+ Picture dst,
+ _Xconst XRenderColor *color,
+ _Xconst XRectangle *rectangles,
+ int n_rects);
+
+void
+XRenderCompositeTrapezoids (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XTrapezoid *traps,
+ int ntrap);
+
+void
+XRenderCompositeTriangles (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XTriangle *triangles,
+ int ntriangle);
+
+void
+XRenderCompositeTriStrip (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XPointFixed *points,
+ int npoint);
+
+void
+XRenderCompositeTriFan (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ _Xconst XPointFixed *points,
+ int npoint);
+
+void
+XRenderCompositeDoublePoly (Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ int xDst,
+ int yDst,
+ _Xconst XPointDouble *fpoints,
+ int npoints,
+ int winding);
+Status
+XRenderParseColor(Display *dpy,
+ char *spec,
+ XRenderColor *def);
+
+Cursor
+XRenderCreateCursor (Display *dpy,
+ Picture source,
+ unsigned int x,
+ unsigned int y);
+
+XFilters *
+XRenderQueryFilters (Display *dpy, Drawable drawable);
+
+void
+XRenderSetPictureFilter (Display *dpy,
+ Picture picture,
+ char *filter,
+ XFixed *params,
+ int nparams);
+
+Cursor
+XRenderCreateAnimCursor (Display *dpy,
+ int ncursor,
+ XAnimCursor *cursors);
+
+
+void
+XRenderAddTraps (Display *dpy,
+ Picture picture,
+ int xOff,
+ int yOff,
+ _Xconst XTrap *traps,
+ int ntrap);
+
+Picture XRenderCreateSolidFill (Display *dpy,
+ const XRenderColor *color);
+
+Picture XRenderCreateLinearGradient (Display *dpy,
+ const XLinearGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nstops);
+
+Picture XRenderCreateRadialGradient (Display *dpy,
+ const XRadialGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nstops);
+
+Picture XRenderCreateConicalGradient (Display *dpy,
+ const XConicalGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nstops);
+
+_XFUNCPROTOEND
+
+#endif /* _XRENDER_H_ */
diff --git a/nx-X11/lib/Xrender/Xrenderint.h b/nx-X11/lib/Xrender/Xrenderint.h
new file mode 100644
index 000000000..49a294b14
--- /dev/null
+++ b/nx-X11/lib/Xrender/Xrenderint.h
@@ -0,0 +1,114 @@
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _XRENDERINT_H_
+#define _XRENDERINT_H_
+
+#include "config.h"
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/renderproto.h>
+#include "Xrender.h"
+
+typedef struct {
+ Visual *visual;
+ XRenderPictFormat *format;
+} XRenderVisual;
+
+typedef struct {
+ int depth;
+ int nvisuals;
+ XRenderVisual *visuals;
+} XRenderDepth;
+
+typedef struct {
+ XRenderDepth *depths;
+ int ndepths;
+ XRenderPictFormat *fallback;
+ int subpixel;
+} XRenderScreen;
+
+typedef struct _XRenderInfo {
+ int major_version;
+ int minor_version;
+ XRenderPictFormat *format;
+ int nformat;
+ XRenderScreen *screen;
+ int nscreen;
+ XRenderDepth *depth;
+ int ndepth;
+ XRenderVisual *visual;
+ int nvisual;
+ int *subpixel;
+ int nsubpixel;
+ char **filter;
+ int nfilter;
+ short *filter_alias;
+ int nfilter_alias;
+} XRenderInfo;
+
+/* replaces XRenderExtDisplayInfo */
+typedef struct _XRenderExtDisplayInfo {
+ struct _XRenderExtDisplayInfo *next; /* keep a linked list */
+ Display *display; /* which display this is */
+ XExtCodes *codes; /* the extension protocol codes */
+ XRenderInfo *info; /* extra data for the extension to use */
+} XRenderExtDisplayInfo;
+
+/* replaces XExtensionInfo */
+typedef struct _XRenderExtInfo {
+ XRenderExtDisplayInfo *head; /* start of the list */
+ XRenderExtDisplayInfo *cur; /* most recently used */
+ int ndisplays; /* number of displays */
+} XRenderExtInfo;
+
+extern XRenderExtInfo XRenderExtensionInfo;
+extern char XRenderExtensionName[];
+
+XRenderExtDisplayInfo *
+XRenderFindDisplay (Display *dpy);
+
+#define RenderHasExtension(i) ((i) && ((i)->codes))
+
+#define RenderCheckExtension(dpy,i,val) \
+ if (!RenderHasExtension(i)) { return val; }
+
+#define RenderSimpleCheckExtension(dpy,i) \
+ if (!RenderHasExtension(i)) { return; }
+
+/*
+ * Xlib uses long for 32-bit values. Xrender uses int. This
+ * matters on alpha. Note that this macro assumes that int is 32 bits
+ * except on WORD64 machines where it is 64 bits.
+ */
+
+#ifdef WORD64
+#define DataInt32(dpy,d,len) Data32(dpy,(long *) (d),len)
+#else
+#define DataInt32(dpy,d,len) Data(dpy,(char *) (d),len)
+#endif
+
+#endif /* _XRENDERINT_H_ */
diff --git a/nx-X11/lib/Xrender/autogen.sh b/nx-X11/lib/Xrender/autogen.sh
new file mode 100755
index 000000000..b1376df5a
--- /dev/null
+++ b/nx-X11/lib/Xrender/autogen.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+autoreconf -v --install || exit 1
+./configure --enable-maintainer-mode "$@"
diff --git a/nx-X11/lib/Xrender/config.h b/nx-X11/lib/Xrender/config.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/lib/Xrender/config.h
diff --git a/nx-X11/lib/Xrender/configure.ac b/nx-X11/lib/Xrender/configure.ac
new file mode 100644
index 000000000..a190657f3
--- /dev/null
+++ b/nx-X11/lib/Xrender/configure.ac
@@ -0,0 +1,113 @@
+dnl
+dnl $Id: configure.ac,v 1.3 2004/08/07 00:40:40 keithp Exp $
+dnl
+dnl Copyright © 2003 Keith Packard, Noah Levitt
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this software and its
+dnl documentation for any purpose is hereby granted without fee, provided that
+dnl the above copyright notice appear in all copies and that both that
+dnl copyright notice and this permission notice appear in supporting
+dnl documentation, and that the name of Keith Packard not be used in
+dnl advertising or publicity pertaining to distribution of the software without
+dnl specific, written prior permission. Keith Packard makes no
+dnl representations about the suitability of this software for any purpose. It
+dnl is provided "as is" without express or implied warranty.
+dnl
+dnl KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+dnl EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+dnl PERFORMANCE OF THIS SOFTWARE.
+dnl
+dnl Process this file with autoconf to create configure.
+
+AC_PREREQ([2.57])
+
+dnl
+dnl Version should match the current Render version. XRenderQueryVersion
+dnl returns the version from render.h, NOT the version we set here. But we
+dnl try to keep these the same. Note that the library has an extra
+dnl digit in the version number to track changes which don't affect the
+dnl protocol, so Xrender version l.n.m corresponds to protocol version l.n
+dnl
+AC_INIT(libXrender, 0.9.0, [keithp@keithp.com], libXrender)
+AM_INIT_AUTOMAKE([dist-bzip2])
+AM_MAINTAINER_MODE
+
+AM_CONFIG_HEADER(config.h)
+AC_CONFIG_AUX_DIR(.)
+
+# Check for progs
+AC_PROG_CC
+AC_PROG_LIBTOOL
+
+# Check for X
+PKG_CHECK_MODULES(X, x11,
+ [x_found_with_pkgconfig=yes],
+ [x_found_with_pkgconfig=no])
+
+if test "$x_found_with_pkgconfig" = "yes"
+then
+ X_REQUIRES="x11"
+ X_NON_PKG_CFLAGS=""
+ X_NON_PKG_LIBS=""
+else
+ AC_PATH_XTRA
+
+ if test "x$no_x" = "xyes"
+ then
+ AC_MSG_ERROR([X is required, but it was either disabled or not found.])
+ fi
+
+ # pkg-config adds the -l flag while AC_PATH_XTRA does not
+
+ X_LIBS="$X_LIBS -lX11"
+
+ #
+ # Check for XTHREADS support
+ #
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $X_CFLAGS"
+ LIBS="$LIBS $X_LIBS"
+
+ AC_MSG_CHECKING([for XTHREADS in Xlib])
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
+ [[return XInitThreads() == 0 ? 0 : 1;]])],
+ [xthreads=no],
+ [xthreads=yes],
+ [xthreads=yes])
+
+ AC_MSG_RESULT($xthreads)
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ if test "x$xthreads" = "xyes"
+ then
+ X_CFLAGS="$X_CFLAGS -DXTHREADS"
+ fi
+
+ X_REQUIRES=""
+ X_NON_PKG_CFLAGS="$X_CFLAGS"
+ X_NON_PKG_LIBS="$X_LIBS"
+fi
+AC_SUBST(X_REQUIRES)
+AC_SUBST(X_NON_PKG_CFLAGS)
+AC_SUBST(X_NON_PKG_LIBS)
+
+# Check render configuration, strip extra digits from package version to
+# find the required protocol version
+
+if test "$VERSION" = "" ; then
+ VERSION=$PACKAGE_VERSION;
+fi
+RENDER_VERSION=[`echo $VERSION | sed 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`]
+PKG_CHECK_MODULES(RENDER, render >= $RENDER_VERSION)
+
+AC_OUTPUT([Makefile
+ xrender.pc])
+
diff --git a/nx-X11/lib/Xrender/xrender.pc.in b/nx-X11/lib/Xrender/xrender.pc.in
new file mode 100644
index 000000000..5cc898b0a
--- /dev/null
+++ b/nx-X11/lib/Xrender/xrender.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Xrender
+Description: X Render Library
+Version: @VERSION@
+Requires: @X_REQUIRES@
+Cflags: -I${includedir} @RENDER_CFLAGS@ @X_NON_PKG_CFLAGS@
+Libs: -L${libdir} -lXrender @X_NON_PKG_LIBS@
diff --git a/nx-X11/lib/Xss/Imakefile b/nx-X11/lib/Xss/Imakefile
new file mode 100644
index 000000000..bd7f7a8fc
--- /dev/null
+++ b/nx-X11/lib/Xss/Imakefile
@@ -0,0 +1,47 @@
+XCOMM $XFree86: xc/lib/Xss/Imakefile,v 3.5 2003/10/26 18:59:49 herrb Exp $
+#define DoNormalLib NormalLibXss
+#define DoSharedLib SharedLibXss
+#define DoExtraLib SharedLibXss
+#define DoDebugLib DebugLibXss
+#define DoProfileLib ProfileLibXss
+#define LibName Xss
+#define SoRev SOXSSREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXssReqs
+REQUIREDLIBS = SharedXssReqs
+#endif
+
+SCRNSAVSRC = XScrnSaver.c
+SCRNSAVOBJ = XScrnSaver.o
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ SRCS = $(SCRNSAVSRC)
+ OBJS = $(SCRNSAVOBJ)
+ LINTLIBS = $(LINTXLIB)
+
+#define IncludeSharedObjectInNormalLib
+
+MANSUFFIX=$(LIBMANSUFFIX)
+InstallManPage(LibName,$(LIBMANDIR))
+#if ExpandManNames
+InstallManPageAliases(LibName,$(LIBMANDIR), XScreenSaverQueryExtension \ @@\
+ XScreenSaverQueryVersion \ @@\
+ XScreenSaverAllocInfo \ @@\
+ XScreenSaverQueryInfo \ @@\
+ XScreenSaverSelectInput \ @@\
+ XScreenSaverSetAttributes \ @@\
+ XScreenSaverUnsetAttributes \ @@\
+ XScreenSaverRegister \ @@\
+ XScreenSaverUnregister \ @@\
+ XScreenSaverGetRegistered)
+#endif
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/Xss/XScrnSaver.c b/nx-X11/lib/Xss/XScrnSaver.c
new file mode 100644
index 000000000..3727ae4f6
--- /dev/null
+++ b/nx-X11/lib/Xss/XScrnSaver.c
@@ -0,0 +1,442 @@
+/*
+ * $XConsortium: XScrnSaver.c,v 1.5 94/04/17 20:59:35 rws Exp $
+ *
+Copyright (c) 1992 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+X CONSORTIUM 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 X Consortium 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 X Consortium.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xss/XScrnSaver.c,v 3.1 2001/10/28 03:32:40 tsi Exp $ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/saverproto.h>
+#include <X11/extensions/scrnsaver.h>
+
+
+static XExtensionInfo _screen_saver_info_data;
+static XExtensionInfo *screen_saver_info = &_screen_saver_info_data;
+static /* const */ char *screen_saver_extension_name = ScreenSaverName;
+
+#define ScreenSaverCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, screen_saver_extension_name, val)
+#define ScreenSaverSimpleCheckExtension(dpy,i) \
+ XextSimpleCheckExtension (dpy, i, screen_saver_extension_name)
+
+static int close_display();
+static Bool wire_to_event();
+static Status event_to_wire();
+static /* const */ XExtensionHooks screen_saver_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, screen_saver_info,
+ screen_saver_extension_name,
+ &screen_saver_extension_hooks,
+ ScreenSaverNumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, screen_saver_info)
+
+
+static Bool wire_to_event (dpy, re, event)
+ Display *dpy;
+ XEvent *re;
+ xEvent *event;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XScreenSaverNotifyEvent *se;
+ xScreenSaverNotifyEvent *sevent;
+
+ ScreenSaverCheckExtension (dpy, info, False);
+
+ switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
+ case ScreenSaverNotify:
+ se = (XScreenSaverNotifyEvent *) re;
+ sevent = (xScreenSaverNotifyEvent *) event;
+ se->type = sevent->type & 0x7f;
+ se->serial = _XSetLastRequestRead(dpy,(xGenericReply *) event);
+ se->send_event = (sevent->type & 0x80) != 0;
+ se->display = dpy;
+ se->window = sevent->window;
+ se->window = sevent->root;
+ se->state = sevent->state;
+ se->kind = sevent->kind;
+ se->forced = True;
+ if (sevent->forced == xFalse)
+ se->forced = False;
+ se->time = sevent->timestamp;
+ return True;
+ }
+ return False;
+}
+
+static Status event_to_wire (dpy, re, event)
+ Display *dpy;
+ XEvent *re;
+ xEvent *event;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XScreenSaverNotifyEvent *se;
+ xScreenSaverNotifyEvent *sevent;
+
+ ScreenSaverCheckExtension (dpy, info, 0);
+
+ switch ((re->type & 0x7f) - info->codes->first_event) {
+ case ScreenSaverNotify:
+ se = (XScreenSaverNotifyEvent *) re;
+ sevent = (xScreenSaverNotifyEvent *) event;
+ sevent->type = se->type | (se->send_event ? 0x80 : 0);
+ sevent->sequenceNumber = se->serial & 0xffff;
+ sevent->root = se->root;
+ sevent->window = se->window;
+ sevent->state = se->state;
+ sevent->kind = se->kind;
+ sevent->forced = xFalse;
+ if (se->forced == True)
+ sevent->forced = xTrue;
+ sevent->timestamp = se->time;
+ return 1;
+ }
+ return 0;
+}
+
+/****************************************************************************
+ * *
+ * ScreenSaver public interfaces *
+ * *
+ ****************************************************************************/
+
+Bool XScreenSaverQueryExtension (dpy, event_basep, error_basep)
+ Display *dpy;
+ int *event_basep, *error_basep;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+Status XScreenSaverQueryVersion(dpy, major_versionp, minor_versionp)
+ Display *dpy;
+ int *major_versionp, *minor_versionp;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xScreenSaverQueryVersionReply rep;
+ register xScreenSaverQueryVersionReq *req;
+
+ ScreenSaverCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (ScreenSaverQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->saverReqType = X_ScreenSaverQueryVersion;
+ req->clientMajor = ScreenSaverMajorVersion;
+ req->clientMinor = ScreenSaverMinorVersion;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ *major_versionp = rep.majorVersion;
+ *minor_versionp = rep.minorVersion;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
+XScreenSaverInfo *XScreenSaverAllocInfo ()
+{
+ return (XScreenSaverInfo *) Xmalloc (sizeof (XScreenSaverInfo));
+}
+
+Status XScreenSaverQueryInfo (dpy, drawable, saver_info)
+ Display *dpy;
+ Drawable drawable;
+ XScreenSaverInfo *saver_info;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xScreenSaverQueryInfoReply rep;
+ register xScreenSaverQueryInfoReq *req;
+
+ ScreenSaverCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (ScreenSaverQueryInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->saverReqType = X_ScreenSaverQueryInfo;
+ req->drawable = drawable;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ saver_info->window = rep.window;
+ saver_info->state = rep.state;
+ saver_info->kind = rep.kind;
+ saver_info->til_or_since = rep.tilOrSince;
+ saver_info->idle = rep.idle;
+ saver_info->eventMask = rep.eventMask;
+ return 1;
+}
+
+void XScreenSaverSelectInput (dpy, drawable, mask)
+ register Display *dpy;
+ Drawable drawable;
+ unsigned long mask;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xScreenSaverSelectInputReq *req;
+
+ ScreenSaverSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ GetReq (ScreenSaverSelectInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->saverReqType = X_ScreenSaverSelectInput;
+ req->drawable = drawable;
+ req->eventMask = mask;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+static void
+XScreenSaverProcessWindowAttributes (dpy, req, valuemask, attributes)
+ register Display *dpy;
+ xChangeWindowAttributesReq *req;
+ register unsigned long valuemask;
+ register XSetWindowAttributes *attributes;
+ {
+ unsigned long values[32];
+ register unsigned long *value = values;
+ unsigned int nvalues;
+
+ if (valuemask & CWBackPixmap)
+ *value++ = attributes->background_pixmap;
+
+ if (valuemask & CWBackPixel)
+ *value++ = attributes->background_pixel;
+
+ if (valuemask & CWBorderPixmap)
+ *value++ = attributes->border_pixmap;
+
+ if (valuemask & CWBorderPixel)
+ *value++ = attributes->border_pixel;
+
+ if (valuemask & CWBitGravity)
+ *value++ = attributes->bit_gravity;
+
+ if (valuemask & CWWinGravity)
+ *value++ = attributes->win_gravity;
+
+ if (valuemask & CWBackingStore)
+ *value++ = attributes->backing_store;
+
+ if (valuemask & CWBackingPlanes)
+ *value++ = attributes->backing_planes;
+
+ if (valuemask & CWBackingPixel)
+ *value++ = attributes->backing_pixel;
+
+ if (valuemask & CWOverrideRedirect)
+ *value++ = attributes->override_redirect;
+
+ if (valuemask & CWSaveUnder)
+ *value++ = attributes->save_under;
+
+ if (valuemask & CWEventMask)
+ *value++ = attributes->event_mask;
+
+ if (valuemask & CWDontPropagate)
+ *value++ = attributes->do_not_propagate_mask;
+
+ if (valuemask & CWColormap)
+ *value++ = attributes->colormap;
+
+ if (valuemask & CWCursor)
+ *value++ = attributes->cursor;
+
+ req->length += (nvalues = value - values);
+
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, (long)nvalues);
+
+ }
+
+void XScreenSaverSetAttributes (dpy, drawable, x, y, width, height,
+ border_width, depth, class, visual,
+ valuemask, attributes)
+ Display* dpy;
+ Drawable drawable;
+ int x;
+ int y;
+ unsigned int width;
+ unsigned int height;
+ unsigned int border_width;
+ int depth;
+ unsigned int class;
+ Visual * visual;
+ unsigned long valuemask;
+ XSetWindowAttributes *attributes;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xScreenSaverSetAttributesReq *req;
+
+ ScreenSaverSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ GetReq (ScreenSaverSetAttributes, req);
+ req->reqType = info->codes->major_opcode;
+ req->saverReqType = X_ScreenSaverSetAttributes;
+ req->drawable = drawable;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->borderWidth = border_width;
+ req->c_class = class;
+ req->depth = depth;
+ if (visual == CopyFromParent)
+ req->visualID = CopyFromParent;
+ else
+ req->visualID = visual->visualid;
+ /* abuse an Xlib internal interface - is this legal for us? */
+ if ((req->mask = valuemask))
+ XScreenSaverProcessWindowAttributes (dpy,
+ (xChangeWindowAttributesReq *)req,
+ valuemask, attributes);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+
+void XScreenSaverUnsetAttributes (dpy, drawable)
+ register Display *dpy;
+ Drawable drawable;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xScreenSaverUnsetAttributesReq *req;
+
+ ScreenSaverSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ GetReq (ScreenSaverUnsetAttributes, req);
+ req->reqType = info->codes->major_opcode;
+ req->saverReqType = X_ScreenSaverUnsetAttributes;
+ req->drawable = drawable;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+
+Status XScreenSaverRegister (dpy, screen, xid, type)
+ Display *dpy;
+ int screen;
+ XID xid;
+ Atom type;
+{
+ Atom prop;
+ unsigned long ul;
+
+ prop = XInternAtom (dpy, ScreenSaverPropertyName, False);
+ if (!prop)
+ return 0;
+
+ ul = (unsigned long) xid;
+ XChangeProperty (dpy, RootWindow(dpy,screen), prop, type, 32,
+ PropModeReplace, (unsigned char *) &ul, 1);
+ return 1;
+}
+
+
+
+Status XScreenSaverUnregister (dpy, screen)
+ Display *dpy;
+ int screen;
+{
+ Atom prop;
+
+ prop = XInternAtom (dpy, ScreenSaverPropertyName, False);
+ if (!prop)
+ return 0;
+
+ XDeleteProperty (dpy, RootWindow(dpy,screen), prop);
+ return 1;
+}
+
+
+
+Status XScreenSaverGetRegistered (dpy, screen, xid, type)
+ Display *dpy;
+ int screen;
+ XID *xid;
+ Atom *type;
+{
+ Atom actual_type = None;
+ int actual_format;
+ unsigned long nitems, bytesafter;
+ unsigned long *ulp = (unsigned long *) 0;
+ Atom prop;
+ int retval = 0;
+
+ prop = XInternAtom (dpy, ScreenSaverPropertyName, False);
+ if (!prop)
+ return retval;
+
+ if (XGetWindowProperty (dpy, RootWindow(dpy,screen), prop, 0L, 1L, False,
+ AnyPropertyType, &actual_type, &actual_format,
+ &nitems, &bytesafter, (unsigned char **) &ulp)
+ != Success)
+ return retval;
+
+ if (ulp) {
+ if (actual_format == 32) {
+ *xid = (XID) ulp[0];
+ *type = actual_type;
+ retval = 1;
+ }
+ XFree ((char *) ulp);
+ }
+ return retval;
+}
diff --git a/nx-X11/lib/Xss/Xss-def.cpp b/nx-X11/lib/Xss/Xss-def.cpp
new file mode 100644
index 000000000..60d529cf1
--- /dev/null
+++ b/nx-X11/lib/Xss/Xss-def.cpp
@@ -0,0 +1,14 @@
+LIBRARY Xss
+EXPORTS
+ XScreenSaverQueryExtension
+ XScreenSaverQueryVersion
+ XScreenSaverAllocInfo
+ XScreenSaverQueryInfo
+ XScreenSaverSelectInput
+ XScreenSaverSetAttributes
+ XScreenSaverUnsetAttributes
+ XScreenSaverRegister
+ XScreenSaverUnregister
+ XScreenSaverGetRegistered
+
+/* $XFree86: xc/lib/Xss/Xss-def.cpp,v 1.1 2000/08/09 23:40:13 dawes Exp $ */
diff --git a/nx-X11/lib/Xss/Xss.man b/nx-X11/lib/Xss/Xss.man
new file mode 100644
index 000000000..fa1545241
--- /dev/null
+++ b/nx-X11/lib/Xss/Xss.man
@@ -0,0 +1,328 @@
+.\"
+.\" $XFree86: xc/lib/Xss/Xss.man,v 1.1 2003/10/26 19:00:24 herrb Exp $
+.\" $XdotOrg: xc/lib/Xss/Xss.man,v 1.2 2004/04/23 18:43:51 eich Exp $
+.\"
+.\" Copyright (C) 2003 The XFree86 Project, Inc. All Rights Reserved.
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" 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 NON-INFRINGEMENT.
+.\" IN NO EVENT SHALL THE XFREE86 PROJECT 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 XFree86 Project
+.\" 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 XFree86 Project.
+.\"
+.TH XScreenSaver __libmansuffix__ __vendorversion__
+.SH NAME
+XScreenSaver \- X11 Screen Saver extension client library
+.SH SYNOPSIS
+.B #include <X11/extension/scrnsaver.h>
+.PP
+.nf
+.ta .5i 2i
+typedef struct {
+ Window window; /\(** screen saver window */
+ int state; /\(** ScreenSaver{Off,On,Disabled} */
+ int kind; /\(** ScreenSaver{Blanked,Internal,External} */
+ unsigned long til_or_since; /\(** milliseconds */
+ unsigned long idle; /\(** milliseconds */
+ unsigned long event_mask; /\(** events */
+.br
+} XScreenSaverInfo;
+
+typedef struct {
+ int type; /\(** of event */
+ unsigned long serial; /\(** # of last request processed by server */
+ Bool send_event; /\(** true if this came frome a SendEvent request */
+ Display *display; /\(** Display the event was read from */
+ Window window; /\(** screen saver window */
+ Window root; /\(** root window of event screen */
+ int state; /\(** ScreenSaver{Off,On,Cycle} */
+ int kind; /\(** ScreenSaver{Blanked,Internal,External} */
+ Bool forced; /\(** extents of new region */
+ Time time; /\(** event timestamp */
+.br
+} XScreenSaverNotifyEvent;
+.fi
+.HP
+Bool XScreenSaverQueryExtension(Display *\fIdpy\fP,
+int *\fIevent_basep\fP, int *\fIerror_basep\fP\^);
+.HP
+Status XScreenSaverQueryVersion(Display *\fIdpy\fP, int *\fImajor_versionp\fP,
+int *\fIminor_versionp\fP\^);
+.HP
+XScreenSaverInfo *XScreenSaverAllocInfo(\^void\^);
+.HP
+Status XScreenSaverQueryInfo(\^Display *\fIdpy\fP, Drawable \fIdrawable\fP,
+XScreenSaverInfo *\fIsaver_info\fP\^);
+.HP
+void XScreenSaverSelectInput(Display *\fIdpy\fP, Drawable \fIdrawable\fP,
+unsigned long \fImask\fp\^);
+.HP
+void XScreenSaverSetAttributes(Display *\fIdpy\fP, Drawable \fIdrawable\fP,
+int \fIx\fP,
+int \fIy\fP,
+unsigned int \fIwidth\fP,
+unsigned int \fIheight\fP,
+unsigned int \fIborder_width\fP,
+int \fIdepth\fP,
+unsigned int \fIclass\fP,
+Visual *\fIvisual\fP,
+unsigned long \fIvaluemask\fP,
+XSetWindowAttributes *\fIattributes\fP\^);
+.HP
+void XScreenSaverUnsetAttributes(Display *\fIdpy\fP,
+Drawable \fIdrawable\fP\^);
+.HP
+void XScreenSaverSaverRegister(Display *\fIdpy\fP, int \fIscreen\fP,
+XID \fIxid\fP, Atom \fItype\fP\^);
+.HP
+Status XScreenSaverUnregister(Display *\fIdpy\fP, int \fIscreen\fP\^);
+.HP
+Status XScreenSaverGetRegistered(Display *\fIdpy\fP, int \fIscreen\fP,
+XID *\fIxid\fP, Atom *\fItype\fP\^);
+.PP
+.SH DESCRIPTION
+The X Window System provides support for changing the image on a
+display screen after a user-settable period of inactivity to avoid
+burning the cathode ray tube phosphors.
+However, no interfaces are provided for the user to control the image
+that is drawn.
+This extension allows an external ``screen saver'' client to detect
+when the alternate image is to be displayed and to provide the
+graphics.
+.PP
+Current X server implementations typically provide at least one form of
+``screen saver'' image.
+Historically, this has been a copy of the X logo drawn against the
+root background pattern.
+However, many users have asked for the mechanism to allow them to
+write screen saver programs that provide capabilities similar to those
+provided by other window systems.
+In particular, such users often wish to be able to display corporate
+logos, instructions on how to reactivate the screen, and automatic
+screen-locking utilities.
+This extension provides a means for writing such clients.
+.SS Assumptions
+This extension exports the notion of a special screen saver window that is
+mapped above all other windows on a display.
+This window has the \fIoverride-redirect\fP attribute set so that it
+is not subject to manipulation by the window manager.
+Furthermore, the X identifier for the window is never returned by
+\fBQueryTree\fP requests on the root window, so it is typically not
+visible to other clients.
+.PP
+.B XScreenSaverQueryExtension
+returns
+.B True
+if the
+.I XScreenSaver
+extension is available on the given display.
+A client must call
+.B XScreenSaverQueryExtension
+before calling any other XScreenSaver function in order
+to negotiate a compatible protocol version; otherwise the client will
+get undefined behavior (XScreenSaver may or may not work).
+.PP
+If the extension is supported, the event number for
+.I ScreenSaverNotify
+events is returned in the value pointed to by \fIevent_base\fP.
+Since no additional errors are defined by this extension, the results
+of \fIerror_base\fP are not defined.
+.PP
+.B XScreenSaverQueryVersion
+returns
+.B True
+if the request succeeded; the values of the major and minor protocol
+versions supported by the server are returned in
+.I major_versionp
+and
+.I minor_versionp .
+.PP
+.B XScreenSaverAllocInfo
+allocates and returns an \fBXScreenSaverInfo\fP structure
+for use in calls to \fBXScreenSaverQueryInfo\fP.
+All fields in the structure are initialized to zero.
+If insufficient memory is available, NULL is returned.
+The results of this routine can be released using \fIXFree\fP.
+.PP
+.B XScreenSaverQueryInfo
+returns information about the current state of the
+screen server in \fIsaver_info\fP and a non-zero value is
+returned.
+If the extension is not supported, \fIsaver_info\fP is not changed and 0
+is returned.
+.br
+The \fIstate\fP field specifies whether or not the screen saver is currently
+active and how the \fItil-or-since\fP value should be interpreted:
+.TP 4
+.I Off
+The screen is not currently being saved; \fItil-or-since\fP
+specifies the number of milliseconds until the screen saver is expected to
+activate.
+.TP 4
+.I On
+The screen is currently being saved; \fItil-or-since\fP specifies
+the number of milliseconds since the screen saver activated.
+.TP 4
+.I Disabled
+The screen saver is currently disabled; \fItil-or-since\fP is zero.
+.br
+The \fIkind\fP field specifies the mechanism that either is currently being
+used or would have been were the screen being saved:
+.TP 4
+.I Blanked
+The video signal to the display monitor was disabled.
+.TP 4
+.I Internal
+A server-dependent, built-in screen saver image was displayed; either no
+client had set the screen saver window attributes or a different client
+had the server grabbed when the screen saver activated.
+.TP 4
+.I External
+The screen saver window was mapped with attributes set by a
+client using the \fBScreenSaverSetAttributes\fP request.
+.PP
+The \fIidle\fP field specifies the number of milliseconds since the last
+input was received from the user on any of the input devices.
+.br
+The \fIevent-mask\fP field specifies which, if any, screen saver
+events this client has requested using \fBScreenSaverSelectInput\fP.
+.PP
+.B XScreenSaverSelectInput
+asks that events related to
+the screen saver be generated for this client.
+If
+no bits are set in \fIevent-mask\fP, then no events will be generated.
+Otherwise, any combination of the following bits may be set:
+.TP 8
+.B ScreenSaverNotify
+If this bit is set, \fBScreenSaverNotify\fP events are generated whenever
+the screen saver is activated or deactivated.
+.TP 8
+.B ScreenSaverCycle
+If this bit is set, \fBScreenSaverNotify\fP events are generated whenever
+the screen saver cycle interval passes.
+.PP
+.B XScreenSaverSetAttributes
+sets the attributes to be used
+the next time the external screen saver is activated.
+If another client currently has the attributes set,
+a BadAccess error is generated and the request is ignored.
+.br
+Otherwise, the specified window attributes are checked as if
+they were used in a core \fBCreateWindow\fP request whose
+parent is the root.
+The \fIoverride-redirect\fP field is ignored as it is implicitly set
+to True.
+If the window attributes result in an error according to the rules for
+\fBCreateWindow\fP, the request is ignored.
+.br
+Otherwise, the attributes are stored and will take effect on the next
+activation that occurs when the server is not grabbed by another client.
+Any resources specified for the
+\fIbackground-pixmap\fP or \fIcursor\fP attributes may be
+freed immediately.
+The server is free to copy the \fIbackground-pixmap\fP or \fIcursor\fP
+resources or to use them in place; therefore, the effect of changing
+the contents of those resources is undefined.
+If the specified \fIcolormap\fP no longer exists when the screen saver
+activates, the parent's colormap is used instead.
+If no errors are generated by this request, any previous screen saver
+window attributes set by this client are released.
+.br
+When the screen saver next activates and the server is not grabbed by
+another client, the screen saver window is
+created, if necessary, and set to the specified attributes and events
+are generated as usual.
+The colormap associated with the screen saver window is installed.
+Finally, the screen saver window is mapped.
+.br
+The window remains mapped and at the top of the stacking order
+until the screen saver is deactivated in response to activity on
+any of the user input devices, a \fBForceScreenSaver\fP request with
+a value of Reset, or any request that would cause the window to be
+unmapped.
+.br
+If the screen saver activates while the server is grabbed by another
+client, the internal saver mechanism is used.
+The \fBForceScreenSaver\fP request may be used with a value of Active
+to deactivate the internal saver and activate the external saver.
+.br
+If the screen saver client's connection to the server is broken
+while the screen saver is activated and the client's close down mode has not
+been RetainPermanent or RetainTemporary, the current screen saver
+is deactivated and the internal screen saver is immediately activated.
+.br
+When the screen saver deactivates, the screen saver window's colormap
+is uninstalled and the window is unmapped (except as described below).
+The screen saver XID is disassociated
+with the window and the server may, but is not required to,
+destroy the window along with any children.
+.br
+When the screen saver is being deactivated and then immediately
+reactivated (such as when switching screen savers), the server
+may leave the screen saver window mapped (typically to avoid
+generating exposures).
+.PP
+.B XScreenSaverUnsetAttributes
+instructs the server to discard
+any previous screen saver window attributes set by this client.
+.PP
+.B XScreenSaverRegister
+stores the given \fIXID\fP in the \fB_SCREEN_SAVER_ID\fP
+property (of the given \fItype\fP) on the
+root window of the specified \fIscreen\fP.
+It returns zero if an error is encountered and the property is not
+changed, otherwise it returns non-zero.
+.PP
+.B XScreenSaverUnregister
+removes any \fB_SCREEN_SAVER_ID\fP from the
+root window of the specified \fIscreen\fP.
+It returns zero if an error is encountered and the property is
+changed, otherwise it returns non-zero.
+.PP
+.B XScreenSaverGetRegistered
+returns the \fIXID\fP and \fItype\fP stored in
+the \fB_SCREEN_SAVER_ID\fP property on the
+root window of the specified \fIscreen\fP.
+It returns zero if an error is encountered or if the property does not
+exist or is not of the correct format; otherwise it returns non-zero.
+.SH "ERRORS"
+.B XScreenSaverSelectInput,
+.B XScreenSaverQueryInfo,
+.B XScreenSaverSetAttributes
+and
+.B XScreenSaverUnsetAttributes
+will generate a
+.I BadDrawable
+error if \fIdrawable\fP is not a valid drawable identifier.
+If any undefined bits are set in \fIevent-mask\fP,
+a BadValue error is generated by
+.B XScreenSaverSelectInput .
+.PP
+.SH "SEE ALSO"
+X(__miscmansuffix__)
+.SH AUTHORS
+Jim Fulton and Keith Packard.
+.SH STABILITY
+This API is considered as experimental.
+The Xss library major revision may be incremented whenever
+incompatible changes are done to the API without notice.
+Use with care.
diff --git a/nx-X11/lib/Xt/ActionHook.c b/nx-X11/lib/Xt/ActionHook.c
new file mode 100644
index 000000000..6c2fe2bd0
--- /dev/null
+++ b/nx-X11/lib/Xt/ActionHook.c
@@ -0,0 +1,135 @@
+/* $Xorg: ActionHook.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*LINTLIBRARY*/
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+/* $XFree86: xc/lib/Xt/ActionHook.c,v 1.2 2001/08/22 22:52:17 dawes Exp $ */
+
+/*
+ * Contains XtAppAddActionHook, XtRemoveActionHook
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+
+
+/*ARGSUSED*/
+static void FreeActionHookList(
+ Widget widget, /* unused (and invalid) */
+ XtPointer closure, /* ActionHook* */
+ XtPointer call_data) /* unused */
+{
+ ActionHook list = *(ActionHook*)closure;
+ while (list != NULL) {
+ ActionHook next = list->next;
+ XtFree( (XtPointer)list );
+ list = next;
+ }
+}
+
+
+XtActionHookId XtAppAddActionHook(
+ XtAppContext app,
+ XtActionHookProc proc,
+ XtPointer closure)
+{
+ ActionHook hook = XtNew(ActionHookRec);
+ LOCK_APP(app);
+ hook->next = app->action_hook_list;
+ hook->app = app;
+ hook->proc = proc;
+ hook->closure = closure;
+ if (app->action_hook_list == NULL) {
+ _XtAddCallback( &app->destroy_callbacks,
+ FreeActionHookList,
+ (XtPointer)&app->action_hook_list
+ );
+ }
+ app->action_hook_list = hook;
+ UNLOCK_APP(app);
+ return (XtActionHookId)hook;
+}
+
+
+void XtRemoveActionHook(
+ XtActionHookId id)
+{
+ ActionHook *p, hook = (ActionHook)id;
+ XtAppContext app = hook->app;
+ LOCK_APP(app);
+ for (p = &app->action_hook_list; p != NULL && *p != hook; p = &(*p)->next);
+ if (p) {
+ *p = hook->next;
+ XtFree( (XtPointer)hook );
+ if (app->action_hook_list == NULL)
+ _XtRemoveCallback(&app->destroy_callbacks, FreeActionHookList,
+ (XtPointer) &app->action_hook_list);
+ }
+#ifdef DEBUG
+ else {
+ XtAppWarningMsg(app, "badId", "xtRemoveActionHook", XtCXtToolkitError,
+ "XtRemoveActionHook called with bad or old hook id",
+ (String*)NULL, (Cardinal*)NULL);
+ }
+#endif /*DEBUG*/
+ UNLOCK_APP(app);
+}
diff --git a/nx-X11/lib/Xt/Alloc.c b/nx-X11/lib/Xt/Alloc.c
new file mode 100644
index 000000000..1312db2ac
--- /dev/null
+++ b/nx-X11/lib/Xt/Alloc.c
@@ -0,0 +1,494 @@
+/* $Xorg: Alloc.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+/* $XFree86: xc/lib/Xt/Alloc.c,v 1.9 2001/12/14 19:56:07 dawes Exp $ */
+
+/*
+ * X Toolkit Memory Allocation Routines
+ *
+ * Uses Xlib memory management, which is spec'd to be re-entrant.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "InitialI.h"
+#undef _XBCOPYFUNC
+
+#include <stdlib.h>
+
+#define Xmalloc(size) malloc((size))
+#define Xrealloc(ptr, size) realloc((ptr), (size))
+#define Xcalloc(nelem, elsize) calloc((nelem), (elsize))
+#define Xfree(ptr) free(ptr)
+
+#ifdef _XNEEDBCOPYFUNC
+void _XtBcopy(
+ char *src, char *dst,
+ int length)
+{
+ if (src < dst) {
+ dst += length;
+ src += length;
+ while (length--)
+ *--dst = *--src;
+ } else {
+ while (length--)
+ *dst++ = *src++;
+ }
+}
+#endif
+
+void _XtAllocError(
+ String type)
+{
+ Cardinal num_params = 1;
+ if (type == NULL) type = "local memory allocation";
+ XtErrorMsg("allocError", type, XtCXtToolkitError,
+ "Cannot perform %s", &type, &num_params);
+}
+
+void _XtHeapInit(
+ Heap* heap)
+{
+ heap->start = NULL;
+ heap->bytes_remaining = 0;
+}
+
+#ifndef XTTRACEMEMORY
+
+char *XtMalloc(
+ unsigned size)
+{
+ char *ptr;
+
+#if defined(MALLOC_0_RETURNS_NULL) && defined(XTMALLOC_BC)
+ /* preserve this (broken) behavior until everyone fixes their apps */
+ if (!size) size = 1;
+#endif
+ if ((ptr = Xmalloc(size)) == NULL)
+ _XtAllocError("malloc");
+
+ return(ptr);
+}
+
+char *XtRealloc(
+ char *ptr,
+ unsigned size)
+{
+ if (ptr == NULL) {
+#ifdef MALLOC_0_RETURNS_NULL
+ if (!size) size = 1;
+#endif
+ return(XtMalloc(size));
+ } else if ((ptr = Xrealloc(ptr, size)) == NULL
+#ifdef MALLOC_0_RETURNS_NULL
+ && size
+#endif
+ )
+ _XtAllocError("realloc");
+
+ return(ptr);
+}
+
+char *XtCalloc(
+ unsigned num, unsigned size)
+{
+ char *ptr;
+
+#if defined(MALLOC_0_RETURNS_NULL) && defined(XTMALLOC_BC)
+ /* preserve this (broken) behavior until everyone fixes their apps */
+ if (!size) num = size = 1;
+#endif
+ if ((ptr = Xcalloc(num, size)) == NULL)
+ _XtAllocError("calloc");
+
+ return(ptr);
+}
+
+void XtFree(
+ char *ptr)
+{
+ if (ptr != NULL) Xfree(ptr);
+}
+
+char* __XtMalloc(
+ unsigned size)
+{
+#ifdef MALLOC_0_RETURNS_NULL
+ if (!size) size = 1;
+#endif
+ return XtMalloc (size);
+}
+
+char* __XtCalloc(
+ unsigned num, unsigned size)
+{
+#ifdef MALLOC_0_RETURNS_NULL
+ if (!size) num = size = 1;
+#endif
+ return XtCalloc(num, size);
+}
+
+#ifndef HEAP_SEGMENT_SIZE
+#define HEAP_SEGMENT_SIZE 1492
+#endif
+
+char* _XtHeapAlloc(
+ Heap* heap,
+ Cardinal bytes)
+{
+ register char* heap_loc;
+ if (heap == NULL) return XtMalloc(bytes);
+ if (heap->bytes_remaining < (int)bytes) {
+ if ((bytes + sizeof(char*)) >= (HEAP_SEGMENT_SIZE>>1)) {
+ /* preserve current segment; insert this one in front */
+#ifdef _TRACE_HEAP
+ printf( "allocating large segment (%d bytes) on heap %#x\n",
+ bytes, heap );
+#endif
+ heap_loc = XtMalloc(bytes + sizeof(char*));
+ if (heap->start) {
+ *(char**)heap_loc = *(char**)heap->start;
+ *(char**)heap->start = heap_loc;
+ }
+ else {
+ *(char**)heap_loc = NULL;
+ heap->start = heap_loc;
+ }
+ return heap_loc + sizeof(char*);
+ }
+ /* else discard remainder of this segment */
+#ifdef _TRACE_HEAP
+ printf( "allocating new segment on heap %#x\n", heap );
+#endif
+ heap_loc = XtMalloc((unsigned)HEAP_SEGMENT_SIZE);
+ *(char**)heap_loc = heap->start;
+ heap->start = heap_loc;
+ heap->current = heap_loc + sizeof(char*);
+ heap->bytes_remaining = HEAP_SEGMENT_SIZE - sizeof(char*);
+ }
+ bytes = (bytes + (sizeof(long) - 1)) & (~(sizeof(long) - 1));
+ heap_loc = heap->current;
+ heap->current += bytes;
+ heap->bytes_remaining -= bytes; /* can be negative, if rounded */
+ return heap_loc;
+}
+
+void _XtHeapFree(
+ Heap* heap)
+{
+ char* segment = heap->start;
+ while (segment != NULL) {
+ char* next_segment = *(char**)segment;
+ XtFree(segment);
+ segment = next_segment;
+ }
+ heap->start = NULL;
+ heap->bytes_remaining = 0;
+}
+
+#else
+
+/*
+ * X Toolkit Memory Trace Allocation Routines
+ */
+
+#undef XtMalloc
+#undef XtRealloc
+#undef XtCalloc
+#undef XtFree
+
+typedef struct _Stats *StatsPtr;
+typedef struct _Stats {
+ StatsPtr prev, next;
+ char *file;
+ int line;
+ unsigned size;
+ unsigned long seq;
+ XtPointer heap;
+} Stats;
+
+static StatsPtr XtMemory = (StatsPtr)NULL;
+static unsigned long ActiveXtMemory = 0;
+static unsigned long XtSeqId = 0;
+static unsigned long XtSeqBreakpoint = ~0;
+
+#define StatsSize(n) ((((n) + (sizeof(long) - 1)) & ~(sizeof(long) - 1)) + sizeof(Stats))
+#define ToStats(ptr) ((StatsPtr)(ptr - sizeof(Stats)))
+#define ToMem(ptr) (((char *)ptr) + sizeof(Stats))
+
+#define CHAIN(ptr,len,hp) \
+ ptr->next = XtMemory; \
+ if (XtMemory) \
+ XtMemory->prev = ptr; \
+ XtMemory = ptr; \
+ ptr->prev = (StatsPtr)NULL; \
+ ptr->file = file; \
+ ptr->line = line; \
+ ptr->size = len; \
+ ptr->heap = hp; \
+ if (file) \
+ ActiveXtMemory += len; \
+ ptr->seq = XtSeqId; \
+ if (XtSeqId == XtSeqBreakpoint) \
+ _XtBreakpoint(ptr); \
+ XtSeqId++
+
+/*ARGUSED*/
+static void _XtBreakpoint(
+ StatsPtr mem)
+{
+ mem->seq = XtSeqId; /* avoid being optimized out of existence */
+}
+
+char *_XtMalloc(
+ unsigned size,
+ char *file,
+ int line)
+{
+ StatsPtr ptr;
+ unsigned newsize;
+ char* retval = NULL;
+
+ LOCK_PROCESS;
+ newsize = StatsSize(size);
+ if ((ptr = (StatsPtr)Xmalloc(newsize)) == NULL)
+ _XtAllocError("malloc");
+ CHAIN(ptr, size, NULL);
+ retval = (ToMem(ptr));
+ UNLOCK_PROCESS;
+ return retval;
+}
+
+char *XtMalloc(
+ unsigned size)
+{
+ return _XtMalloc(size, (char *)NULL, 0);
+}
+
+char *_XtRealloc(
+ char *ptr,
+ unsigned size,
+ char *file,
+ int line)
+{
+ char *newptr;
+
+ LOCK_PROCESS;
+ newptr = _XtMalloc(size, file, line);
+ if (ptr) {
+ unsigned copysize = ToStats(ptr)->size;
+ if (copysize > size) copysize = size;
+ memmove(newptr, ptr, copysize);
+ _XtFree(ptr);
+ }
+ UNLOCK_PROCESS;
+ return(newptr);
+}
+
+char *XtRealloc(
+ char *ptr,
+ unsigned size)
+{
+ return _XtRealloc(ptr, size, (char *)NULL, 0);
+}
+
+char *_XtCalloc(
+ unsigned num, unsigned size,
+ char *file,
+ int line)
+{
+ StatsPtr ptr;
+ unsigned total, newsize;
+ char* retval = NULL;
+
+ LOCK_PROCESS;
+ total = num * size;
+ newsize = StatsSize(total);
+ if ((ptr = (StatsPtr)Xcalloc(newsize, 1)) == NULL)
+ _XtAllocError("calloc");
+ CHAIN(ptr, total, NULL);
+ retval = (ToMem(ptr));
+ UNLOCK_PROCESS;
+ return retval;
+}
+
+char *XtCalloc(
+ unsigned num, unsigned size)
+{
+ return _XtCalloc(num, size, (char *)NULL, 0);
+}
+
+Boolean _XtIsValidPointer(
+ char *ptr)
+{
+ register StatsPtr mem;
+ register StatsPtr stp = ToStats(ptr);
+
+ LOCK_PROCESS;
+ for (mem = XtMemory; mem; mem = mem->next) {
+ if (mem == stp) {
+ UNLOCK_PROCESS;
+ return True;
+ }
+ }
+ UNLOCK_PROCESS;
+ return False;
+}
+
+Boolean _XtValidateMemory = False;
+
+void _XtFree(
+ char *ptr)
+{
+ register StatsPtr stp;
+
+ LOCK_PROCESS;
+ if (ptr) {
+ if (_XtValidateMemory && !_XtIsValidPointer(ptr))
+ abort();
+ stp = ToStats(ptr);
+ if (stp->file)
+ ActiveXtMemory -= stp->size;
+ if (stp->prev)
+ stp->prev->next = stp->next;
+ else
+ XtMemory = stp->next;
+ if (stp->next)
+ stp->next->prev = stp->prev;
+ Xfree((char *)stp);
+ }
+ UNLOCK_PROCESS;
+}
+
+void XtFree(char *ptr)
+{
+ _XtFree(ptr);
+}
+
+char *_XtHeapMalloc(
+ Heap *heap,
+ Cardinal size,
+ char *file,
+ int line)
+{
+ StatsPtr ptr;
+ unsigned newsize;
+ XtPointer hp = (XtPointer) heap;
+ char* retval = NULL;
+
+ LOCK_PROCESS;
+ newsize = StatsSize(size);
+ if ((ptr = (StatsPtr)Xmalloc(newsize)) == NULL)
+ _XtAllocError("malloc");
+ CHAIN(ptr, size, hp);
+ retval = (ToMem(ptr));
+ UNLOCK_PROCESS;
+ return retval;
+}
+
+void _XtHeapFree(register XtPointer heap)
+{
+ register StatsPtr mem, next;
+
+ LOCK_PROCESS;
+ for (mem = XtMemory; mem; mem = next) {
+ next = mem->next;
+ if (mem->heap == heap) {
+ if (mem->file)
+ ActiveXtMemory -= mem->size;
+ if (mem->prev)
+ mem->prev->next = next;
+ else
+ XtMemory = next;
+ if (next)
+ next->prev = mem->prev;
+ Xfree((char *)mem);
+ }
+ }
+ UNLOCK_PROCESS;
+}
+
+#include <stdio.h>
+
+void _XtPrintMemory(char * filename)
+{
+ register StatsPtr mem;
+ FILE *f;
+
+ if (filename == NULL)
+ f = stderr;
+ else
+ f = fopen(filename, "w");
+ LOCK_PROCESS;
+ fprintf(f, "total size: %d\n", ActiveXtMemory);
+ for (mem = XtMemory; mem; mem = mem->next) {
+ if (mem->file)
+ fprintf(f, "size: %6d seq: %5d %12s(%4d) %s\n",
+ mem->size, mem->seq,
+ mem->file, mem->line, mem->heap ? "heap" : "");
+ }
+ UNLOCK_PROCESS;
+ if (filename) fclose(f);
+}
+
+#endif /* XTTRACEMEMORY */
diff --git a/nx-X11/lib/Xt/ArgList.c b/nx-X11/lib/Xt/ArgList.c
new file mode 100644
index 000000000..622f31351
--- /dev/null
+++ b/nx-X11/lib/Xt/ArgList.c
@@ -0,0 +1,77 @@
+/* $Xorg: ArgList.c,v 1.4 2001/02/09 02:03:53 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.
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include <stdio.h>
+
+/*
+ * This routine merges two arglists. It does NOT check for duplicate entries.
+ */
+
+ArgList XtMergeArgLists(
+ ArgList args1,
+ Cardinal num_args1,
+ ArgList args2,
+ Cardinal num_args2)
+{
+ ArgList result, args;
+
+ result = (ArgList) __XtCalloc((unsigned) num_args1 + num_args2,
+ (unsigned) sizeof(Arg));
+
+ for (args = result; num_args1 != 0; num_args1--)
+ *args++ = *args1++;
+ for ( ; num_args2 != 0; num_args2--)
+ *args++ = *args2++;
+
+ return result;
+}
diff --git a/nx-X11/lib/Xt/Callback.c b/nx-X11/lib/Xt/Callback.c
new file mode 100644
index 000000000..03aae5274
--- /dev/null
+++ b/nx-X11/lib/Xt/Callback.c
@@ -0,0 +1,692 @@
+/* $Xorg: Callback.c,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+/* $XFree86: xc/lib/Xt/Callback.c,v 1.8 2001/12/14 19:56:08 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+
+static String XtNinvalidCallbackList = "invalidCallbackList";
+static String XtNxtAddCallback = "xtAddCallback";
+static String XtNxtRemoveCallback = "xtRemoveCallback";
+static String XtNxtRemoveAllCallback = "xtRemoveAllCallback";
+static String XtNxtCallCallback = "xtCallCallback";
+
+/* However it doesn't contain a final NULL record */
+#define ToList(p) ((XtCallbackList) ((p)+1))
+
+static InternalCallbackList* FetchInternalList(
+ Widget widget,
+ _Xconst char *name)
+{
+ XrmQuark quark;
+ int n;
+ CallbackTable offsets;
+ InternalCallbackList* retval = NULL;
+
+ quark = StringToQuark(name);
+ LOCK_PROCESS;
+ offsets = (CallbackTable)
+ widget->core.widget_class->core_class.callback_private;
+
+ for (n = (int)(long) *(offsets++); --n >= 0; offsets++)
+ if (quark == (*offsets)->xrm_name) {
+ retval = (InternalCallbackList *)
+ ((char *) widget - (*offsets)->xrm_offset - 1);
+ break;
+ }
+ UNLOCK_PROCESS;
+ return retval;
+}
+
+
+void _XtAddCallback(
+ InternalCallbackList* callbacks,
+ XtCallbackProc callback,
+ XtPointer closure)
+{
+ register InternalCallbackList icl;
+ register XtCallbackList cl;
+ register int count;
+
+ icl = *callbacks;
+ count = icl ? icl->count : 0;
+
+ if (icl && icl->call_state) {
+ icl->call_state |= _XtCBFreeAfterCalling;
+ icl = (InternalCallbackList)
+ __XtMalloc(sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * (count + 1));
+ (void) memmove((char *)ToList(icl), (char *)ToList(*callbacks),
+ sizeof(XtCallbackRec) * count);
+ } else {
+ icl = (InternalCallbackList)
+ XtRealloc((char *) icl, sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * (count + 1));
+ }
+ *callbacks = icl;
+ icl->count = count + 1;
+ icl->is_padded = 0;
+ icl->call_state = 0;
+ cl = ToList(icl) + count;
+ cl->callback = callback;
+ cl->closure = closure;
+} /* _XtAddCallback */
+
+void _XtAddCallbackOnce(
+ register InternalCallbackList*callbacks,
+ XtCallbackProc callback,
+ XtPointer closure)
+{
+ register XtCallbackList cl = ToList(*callbacks);
+ register int i;
+
+ for (i=(*callbacks)->count; --i >= 0; cl++)
+ if (cl->callback == callback && cl->closure == closure)
+ return;
+
+ _XtAddCallback(callbacks, callback, closure);
+} /* _XtAddCallbackOnce */
+
+void XtAddCallback(
+ Widget widget,
+ _Xconst char* name,
+ XtCallbackProc callback,
+ XtPointer closure
+ )
+{
+ InternalCallbackList *callbacks;
+ Widget hookobj;
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+
+ LOCK_APP(app);
+ callbacks = FetchInternalList(widget, name);
+ if (!callbacks) {
+ XtAppWarningMsg(app,
+ XtNinvalidCallbackList,XtNxtAddCallback,XtCXtToolkitError,
+ "Cannot find callback list in XtAddCallback",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_APP(app);
+ return;
+ }
+ _XtAddCallback(callbacks, callback, closure);
+ if (!_XtIsHookObject(widget)) {
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHaddCallback;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer) name;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ }
+ UNLOCK_APP(app);
+} /* XtAddCallback */
+
+/* ARGSUSED */
+static void AddCallbacks(
+ Widget widget,
+ InternalCallbackList *callbacks,
+ XtCallbackList newcallbacks)
+{
+ register InternalCallbackList icl;
+ register int i, j;
+ register XtCallbackList cl;
+
+ icl = *callbacks;
+ i = icl ? icl->count : 0;
+ for (j=0, cl = newcallbacks; cl->callback; cl++, j++);
+ if (icl && icl->call_state) {
+ icl->call_state |= _XtCBFreeAfterCalling;
+ icl = (InternalCallbackList) __XtMalloc(sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * (i+j));
+ (void) memmove((char *)ToList(*callbacks), (char *)ToList(icl),
+ sizeof(XtCallbackRec) * i);
+ } else {
+ icl = (InternalCallbackList) XtRealloc((char *) icl,
+ sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * (i+j));
+ }
+ *callbacks = icl;
+ icl->count = i+j;
+ icl->is_padded = 0;
+ icl->call_state = 0;
+ for (cl = ToList(icl) + i; --j >= 0; )
+ *cl++ = *newcallbacks++;
+} /* AddCallbacks */
+
+void XtAddCallbacks(
+ Widget widget,
+ _Xconst char* name,
+ XtCallbackList xtcallbacks
+ )
+{
+ InternalCallbackList* callbacks;
+ Widget hookobj;
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+
+ LOCK_APP(app);
+ callbacks = FetchInternalList(widget, name);
+ if (!callbacks) {
+ XtAppWarningMsg(app,
+ XtNinvalidCallbackList,XtNxtAddCallback,XtCXtToolkitError,
+ "Cannot find callback list in XtAddCallbacks",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_APP(app);
+ return;
+ }
+ AddCallbacks(widget, callbacks, xtcallbacks);
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHaddCallbacks;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer) name;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ UNLOCK_APP(app);
+} /* XtAddCallbacks */
+
+void _XtRemoveCallback (
+ InternalCallbackList *callbacks,
+ XtCallbackProc callback,
+ XtPointer closure)
+{
+ register InternalCallbackList icl;
+ register int i, j;
+ register XtCallbackList cl, ncl, ocl;
+
+ icl = *callbacks;
+ if (!icl) return;
+
+ cl = ToList(icl);
+ for (i=icl->count; --i >= 0; cl++) {
+ if (cl->callback == callback && cl->closure == closure) {
+ if (icl->call_state) {
+ icl->call_state |= _XtCBFreeAfterCalling;
+ if (icl->count == 1) {
+ *callbacks = NULL;
+ } else {
+ j = icl->count - i - 1;
+ ocl = ToList(icl);
+ icl = (InternalCallbackList)
+ __XtMalloc(sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * (i + j));
+ icl->count = i + j;
+ icl->is_padded = 0;
+ icl->call_state = 0;
+ ncl = ToList(icl);
+ while (--j >= 0)
+ *ncl++ = *ocl++;
+ while (--i >= 0)
+ *ncl++ = *++cl;
+ *callbacks = icl;
+ }
+ } else {
+ if (--icl->count) {
+ ncl = cl + 1;
+ while (--i >= 0)
+ *cl++ = *ncl++;
+ icl = (InternalCallbackList)
+ XtRealloc((char *) icl, sizeof(InternalCallbackRec)
+ + sizeof(XtCallbackRec) * icl->count);
+ icl->is_padded = 0;
+ *callbacks = icl;
+ } else {
+ XtFree((char *) icl);
+ *callbacks = NULL;
+ }
+ }
+ return;
+ }
+ }
+} /* _XtRemoveCallback */
+
+void XtRemoveCallback (
+ Widget widget,
+ _Xconst char* name,
+ XtCallbackProc callback,
+ XtPointer closure
+ )
+{
+ InternalCallbackList *callbacks;
+ Widget hookobj;
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+
+ LOCK_APP(app);
+ callbacks = FetchInternalList(widget, name);
+ if (!callbacks) {
+ XtAppWarningMsg(app,
+ XtNinvalidCallbackList,XtNxtRemoveCallback,XtCXtToolkitError,
+ "Cannot find callback list in XtRemoveCallback",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_APP(app);
+ return;
+ }
+ _XtRemoveCallback(callbacks, callback, closure);
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHremoveCallback;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer) name;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ UNLOCK_APP(app);
+} /* XtRemoveCallback */
+
+
+void XtRemoveCallbacks (
+ Widget widget,
+ _Xconst char* name,
+ XtCallbackList xtcallbacks)
+{
+ InternalCallbackList *callbacks;
+ Widget hookobj;
+ int i;
+ InternalCallbackList icl;
+ XtCallbackList cl, ccl, rcl;
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+
+ LOCK_APP(app);
+ callbacks = FetchInternalList(widget, name);
+ if (!callbacks) {
+ XtAppWarningMsg(app,
+ XtNinvalidCallbackList,XtNxtRemoveCallback,XtCXtToolkitError,
+ "Cannot find callback list in XtRemoveCallbacks",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_APP(app);
+ return;
+ }
+
+ icl = *callbacks;
+ if (!icl) {
+ UNLOCK_APP(app);
+ return;
+ }
+
+ i = icl->count;
+ cl = ToList(icl);
+ if (icl->call_state) {
+ icl->call_state |= _XtCBFreeAfterCalling;
+ icl = (InternalCallbackList)__XtMalloc(sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * i);
+ icl->count = i;
+ icl->call_state = 0;
+ }
+ ccl = ToList(icl);
+ while (--i >= 0) {
+ *ccl++ = *cl;
+ for (rcl=xtcallbacks; rcl->callback; rcl++) {
+ if (cl->callback == rcl->callback && cl->closure == rcl->closure) {
+ ccl--;
+ icl->count--;
+ break;
+ }
+ }
+ cl++;
+ }
+ if (icl->count) {
+ icl = (InternalCallbackList)
+ XtRealloc((char *)icl, (sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * icl->count));
+ icl->is_padded = 0;
+ *callbacks = icl;
+ } else {
+ XtFree((char *)icl);
+ *callbacks = NULL;
+ }
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHremoveCallbacks;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer) name;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ UNLOCK_APP(app);
+} /* XtRemoveCallbacks */
+
+
+void _XtRemoveAllCallbacks (
+ InternalCallbackList *callbacks)
+{
+ register InternalCallbackList icl = *callbacks;
+
+ if (icl) {
+ if (icl->call_state)
+ icl->call_state |= _XtCBFreeAfterCalling;
+ else
+ XtFree((char *) icl);
+ *callbacks = NULL;
+ }
+} /* _XtRemoveAllCallbacks */
+
+void XtRemoveAllCallbacks(
+ Widget widget,
+ _Xconst char* name)
+{
+ InternalCallbackList *callbacks;
+ Widget hookobj;
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+
+ LOCK_APP(app);
+ callbacks = FetchInternalList(widget, name);
+ if (!callbacks) {
+ XtAppWarningMsg(app,
+ XtNinvalidCallbackList,XtNxtRemoveAllCallback,XtCXtToolkitError,
+ "Cannot find callback list in XtRemoveAllCallbacks",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_APP(app);
+ return;
+ }
+ _XtRemoveAllCallbacks(callbacks);
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHremoveAllCallbacks;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer) name;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ UNLOCK_APP(app);
+} /* XtRemoveAllCallbacks */
+
+InternalCallbackList _XtCompileCallbackList(
+ XtCallbackList xtcallbacks)
+{
+ register int n;
+ register XtCallbackList xtcl, cl;
+ register InternalCallbackList callbacks;
+
+ for (n=0, xtcl=xtcallbacks; xtcl->callback; n++, xtcl++) {};
+ if (n == 0) return (InternalCallbackList) NULL;
+
+ callbacks = (InternalCallbackList) __XtMalloc(sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * n);
+ callbacks->count = n;
+ callbacks->is_padded = 0;
+ callbacks->call_state = 0;
+ cl = ToList(callbacks);
+ while (--n >= 0)
+ *cl++ = *xtcallbacks++;
+ return(callbacks);
+} /* _XtCompileCallbackList */
+
+
+XtCallbackList _XtGetCallbackList(
+ InternalCallbackList *callbacks)
+{
+ register int i;
+ register InternalCallbackList icl;
+ register XtCallbackList cl, ocl;
+
+ icl = *callbacks;
+ if (!icl) {
+ static XtCallbackRec emptyList[1] = { {NULL, NULL} };
+ return (XtCallbackList)emptyList;
+ }
+ if (icl->is_padded)
+ return ToList(icl);
+ i = icl->count;
+ if (icl->call_state) {
+ icl->call_state |= _XtCBFreeAfterCalling;
+ ocl = ToList(icl);
+ icl = (InternalCallbackList) __XtMalloc(sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * (i+1));
+ icl->count = i;
+ icl->call_state = 0;
+ cl = ToList(icl);
+ while (--i >= 0)
+ *cl++ = *ocl++;
+ } else {
+ icl = (InternalCallbackList) XtRealloc((char *)icl,
+ sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * (i+1));
+ cl = ToList(icl) + i;
+ }
+ icl->is_padded = 1;
+ cl->callback = (XtCallbackProc) NULL;
+ cl->closure = NULL;
+ *callbacks = icl;
+ return ToList(icl);
+}
+
+void XtCallCallbacks(
+ Widget widget,
+ _Xconst char* name,
+ XtPointer call_data
+ )
+{
+ InternalCallbackList *callbacks;
+ InternalCallbackList icl;
+ XtCallbackList cl;
+ int i;
+ char ostate;
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+
+ LOCK_APP(app);
+ callbacks = FetchInternalList(widget, name);
+ if (!callbacks) {
+ XtAppWarningMsg(app,
+ XtNinvalidCallbackList,XtNxtCallCallback,XtCXtToolkitError,
+ "Cannot find callback list in XtCallCallbacks",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_APP(app);
+ return;
+ }
+
+ icl = *callbacks;
+ if (!icl) {
+ UNLOCK_APP(app);
+ return;
+ }
+ cl = ToList(icl);
+ if (icl->count == 1) {
+ (*cl->callback) (widget, cl->closure, call_data);
+ UNLOCK_APP(app);
+ return;
+ }
+ ostate = icl->call_state;
+ icl->call_state = _XtCBCalling;
+ for (i = icl->count; --i >= 0; cl++)
+ (*cl->callback) (widget, cl->closure, call_data);
+ if (ostate)
+ icl->call_state |= ostate;
+ else if (icl->call_state & _XtCBFreeAfterCalling)
+ XtFree((char *)icl);
+ else
+ icl->call_state = ostate;
+ UNLOCK_APP(app);
+} /* XtCallCallbacks */
+
+
+XtCallbackStatus XtHasCallbacks(
+ Widget widget,
+ _Xconst char* callback_name
+ )
+{
+ InternalCallbackList *callbacks;
+ XtCallbackStatus retval = XtCallbackHasSome;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ callbacks = FetchInternalList(widget, callback_name);
+ if (!callbacks)
+ retval = XtCallbackNoList;
+ else if (!*callbacks)
+ retval = XtCallbackHasNone;
+ UNLOCK_APP(app);
+ return retval;
+} /* XtHasCallbacks */
+
+
+void XtCallCallbackList(
+ Widget widget,
+ XtCallbackList callbacks,
+ XtPointer call_data)
+{
+ register InternalCallbackList icl;
+ register XtCallbackList cl;
+ register int i;
+ char ostate;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ if (!callbacks) {
+ UNLOCK_APP(app);
+ return;
+ }
+ icl = (InternalCallbackList)callbacks;
+ cl = ToList(icl);
+ if (icl->count == 1) {
+ (*cl->callback) (widget, cl->closure, call_data);
+ UNLOCK_APP(app);
+ return;
+ }
+ ostate = icl->call_state;
+ icl->call_state = _XtCBCalling;
+ for (i = icl->count; --i >= 0; cl++)
+ (*cl->callback) (widget, cl->closure, call_data);
+ if (ostate)
+ icl->call_state |= ostate;
+ else if (icl->call_state & _XtCBFreeAfterCalling)
+ XtFree((char *)icl);
+ else
+ icl->call_state = 0;
+ UNLOCK_APP(app);
+} /* XtCallCallbackList */
+
+void _XtPeekCallback(
+ Widget widget,
+ XtCallbackList callbacks,
+ XtCallbackProc *callback,
+ XtPointer *closure)
+{
+ register InternalCallbackList icl = (InternalCallbackList) callbacks;
+ register XtCallbackList cl;
+
+ if (!callbacks) {
+ *callback = (XtCallbackProc) NULL;
+ return;
+ }
+ cl = ToList(icl);
+ *callback = cl->callback;
+ *closure = cl->closure;
+ return;
+}
+
+void _XtCallConditionalCallbackList(
+ Widget widget,
+ XtCallbackList callbacks,
+ XtPointer call_data,
+ _XtConditionProc cond_proc)
+{
+ register InternalCallbackList icl;
+ register XtCallbackList cl;
+ register int i;
+ char ostate;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ if (!callbacks) {
+ UNLOCK_APP(app);
+ return;
+ }
+ icl = (InternalCallbackList)callbacks;
+ cl = ToList(icl);
+ if (icl->count == 1) {
+ (*cl->callback) (widget, cl->closure, call_data);
+ (void) (*cond_proc)(call_data);
+ UNLOCK_APP(app);
+ return;
+ }
+ ostate = icl->call_state;
+ icl->call_state = _XtCBCalling;
+ for (i = icl->count; --i >= 0; cl++) {
+ (*cl->callback) (widget, cl->closure, call_data);
+ if (! (*cond_proc)(call_data))
+ break;
+ }
+ if (ostate)
+ icl->call_state |= ostate;
+ else if (icl->call_state & _XtCBFreeAfterCalling)
+ XtFree((char *)icl);
+ else
+ icl->call_state = 0;
+ UNLOCK_APP(app);
+}
diff --git a/nx-X11/lib/Xt/CallbackI.h b/nx-X11/lib/Xt/CallbackI.h
new file mode 100644
index 000000000..4ae08ab01
--- /dev/null
+++ b/nx-X11/lib/Xt/CallbackI.h
@@ -0,0 +1,117 @@
+/* $Xorg: CallbackI.h,v 1.4 2001/02/09 02:03:54 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.
+
+******************************************************************/
+/* $XFree86$ */
+
+/****************************************************************
+ *
+ * Callbacks
+ *
+ ****************************************************************/
+
+typedef XrmResource **CallbackTable;
+
+#define _XtCBCalling 1
+#define _XtCBFreeAfterCalling 2
+
+typedef struct internalCallbackRec {
+ unsigned short count;
+ char is_padded; /* contains NULL padding for external form */
+ char call_state; /* combination of _XtCB{FreeAfter}Calling */
+#ifdef LONG64
+ unsigned int align_pad; /* padding to align callback list */
+#endif
+ /* XtCallbackList */
+} InternalCallbackRec, *InternalCallbackList;
+
+typedef Boolean (*_XtConditionProc)(
+ XtPointer /* data */
+);
+
+extern void _XtAddCallback(
+ InternalCallbackList* /* callbacks */,
+ XtCallbackProc /* callback */,
+ XtPointer /* closure */
+);
+
+extern void _XtAddCallbackOnce(
+ InternalCallbackList* /* callbacks */,
+ XtCallbackProc /* callback */,
+ XtPointer /* closure */
+);
+
+extern InternalCallbackList _XtCompileCallbackList(
+ XtCallbackList /* xtcallbacks */
+);
+
+extern XtCallbackList _XtGetCallbackList(
+ InternalCallbackList* /* callbacks */
+);
+
+extern void _XtRemoveAllCallbacks(
+ InternalCallbackList* /* callbacks */
+);
+
+extern void _XtRemoveCallback(
+ InternalCallbackList* /* callbacks */,
+ XtCallbackProc /* callback */,
+ XtPointer /* closure */
+);
+
+extern void _XtPeekCallback(
+ Widget /* widget */,
+ XtCallbackList /* callbacks */,
+ XtCallbackProc * /* callback */,
+ XtPointer * /* closure */
+);
+
+extern void _XtCallConditionalCallbackList(
+ Widget /* widget */,
+ XtCallbackList /* callbacks */,
+ XtPointer /* call_data */,
+ _XtConditionProc /* cond_proc */
+);
diff --git a/nx-X11/lib/Xt/ClickTime.c b/nx-X11/lib/Xt/ClickTime.c
new file mode 100644
index 000000000..bfebd421f
--- /dev/null
+++ b/nx-X11/lib/Xt/ClickTime.c
@@ -0,0 +1,93 @@
+/* $Xorg: ClickTime.c,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+
+/*
+ * Contains XtSetMultiClickTime, XtGetMultiClickTime
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+
+void XtSetMultiClickTime(
+ Display *dpy,
+ int time)
+{
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ _XtGetPerDisplay(dpy)->multi_click_time = time;
+ UNLOCK_APP(app);
+}
+
+
+int XtGetMultiClickTime(
+ Display *dpy)
+{
+ int retval;
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ retval = _XtGetPerDisplay(dpy)->multi_click_time;
+ UNLOCK_APP(app);
+ return retval;
+}
diff --git a/nx-X11/lib/Xt/Composite.c b/nx-X11/lib/Xt/Composite.c
new file mode 100644
index 000000000..7a90975a3
--- /dev/null
+++ b/nx-X11/lib/Xt/Composite.c
@@ -0,0 +1,284 @@
+/* $Xorg: Composite.c,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital, or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+/* $XFree86: xc/lib/Xt/Composite.c,v 1.5 2001/08/22 22:52:17 dawes Exp $ */
+
+#define XT_COMPOSITE
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+
+static XtResource resources[] = {
+ {XtNchildren, XtCReadOnly, XtRWidgetList, sizeof(WidgetList),
+ XtOffsetOf(CompositeRec, composite.children), XtRImmediate, NULL},
+ {XtNnumChildren, XtCReadOnly, XtRCardinal, sizeof(Cardinal),
+ XtOffsetOf(CompositeRec, composite.num_children), XtRImmediate, 0},
+ {XtNinsertPosition, XtCInsertPosition, XtRFunction, sizeof(XtOrderProc),
+ XtOffsetOf(CompositeRec, composite.insert_position), XtRImmediate, NULL},
+};
+
+static void CompositeClassPartInitialize(WidgetClass);
+static void CompositeInitialize(Widget, Widget, ArgList, Cardinal *);
+static void CompositeInsertChild(Widget);
+static void CompositeDeleteChild(Widget);
+static void CompositeDestroy(Widget);
+
+externaldef(compositeclassrec) CompositeClassRec compositeClassRec = {
+ { /******* CorePart *******/
+ /* superclass */ &widgetClassRec,
+ /* class_name */ "Composite",
+ /* widget_size */ sizeof(CompositeRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize*/ CompositeClassPartInitialize,
+ /* class_inited */ FALSE,
+ /* initialize */ CompositeInitialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ CompositeDestroy,
+ /* resize */ NULL,
+ /* expose */ NULL,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL
+ },
+ { /**** CompositePart *****/
+ /* geometry_handler */ NULL,
+ /* change_managed */ NULL,
+ /* insert_child */ CompositeInsertChild,
+ /* delete_child */ CompositeDeleteChild,
+ /* extension */ NULL
+ }
+};
+
+externaldef(compositewidgetclass) WidgetClass compositeWidgetClass = (WidgetClass) &compositeClassRec;
+
+static void InheritAllowsChangeManagedSet(
+ WidgetClass widget_class)
+{
+ CompositeWidgetClass cc = (CompositeWidgetClass) widget_class;
+ CompositeClassExtension ext, super_ext, new_ext;
+
+ ext = (CompositeClassExtension)
+ XtGetClassExtension(widget_class,
+ XtOffsetOf(CompositeClassRec, composite_class.extension),
+ NULLQUARK, 1L, 0);
+
+ if (ext && ext->version == XtCompositeExtensionVersion)
+ return;
+
+ super_ext = (CompositeClassExtension)
+ XtGetClassExtension(cc->core_class.superclass,
+ XtOffsetOf(CompositeClassRec, composite_class.extension),
+ NULLQUARK, 1L, 0);
+
+ LOCK_PROCESS;
+ if (super_ext && super_ext->version == XtCompositeExtensionVersion &&
+ super_ext->record_size == sizeof(CompositeClassExtensionRec) &&
+ super_ext->allows_change_managed_set) {
+
+ new_ext = (CompositeClassExtension)
+ __XtCalloc(1, sizeof(CompositeClassExtensionRec));
+
+ /* Be careful to inherit only what is appropriate */
+ new_ext->next_extension = cc->composite_class.extension;
+ new_ext->record_type = NULLQUARK;
+ new_ext->version = XtCompositeExtensionVersion;
+ new_ext->record_size = sizeof(CompositeClassExtensionRec);
+ new_ext->accepts_objects = (ext ? ext->accepts_objects : False);
+ new_ext->allows_change_managed_set = True;
+ cc->composite_class.extension = (XtPointer) new_ext;
+ }
+ UNLOCK_PROCESS;
+}
+
+static void CompositeClassPartInitialize(
+ WidgetClass widgetClass)
+{
+ register CompositePartPtr wcPtr;
+ register CompositePartPtr superPtr = NULL;
+
+ wcPtr = (CompositePartPtr)
+ &(((CompositeWidgetClass)widgetClass)->composite_class);
+
+ if (widgetClass != compositeWidgetClass)
+ /* don't compute possible bogus pointer */
+ superPtr = (CompositePartPtr)&(((CompositeWidgetClass)widgetClass
+ ->core_class.superclass)->composite_class);
+
+ /* We don't need to check for null super since we'll get to composite
+ eventually, and it had better define them! */
+
+ LOCK_PROCESS;
+ if (wcPtr->geometry_manager == XtInheritGeometryManager) {
+ wcPtr->geometry_manager =
+ superPtr->geometry_manager;
+ }
+
+ if (wcPtr->change_managed == XtInheritChangeManaged) {
+ wcPtr->change_managed =
+ superPtr->change_managed;
+ InheritAllowsChangeManagedSet(widgetClass);
+ }
+
+ if (wcPtr->insert_child == XtInheritInsertChild) {
+ wcPtr->insert_child = superPtr->insert_child;
+ }
+
+ if (wcPtr->delete_child == XtInheritDeleteChild) {
+ wcPtr->delete_child = superPtr->delete_child;
+ }
+ UNLOCK_PROCESS;
+}
+
+static void CompositeDestroy(
+ Widget w)
+{
+ register CompositeWidget cw = (CompositeWidget) w;
+
+ XtFree((char *) cw->composite.children);
+}
+
+static void CompositeInsertChild(
+ Widget w)
+{
+ register Cardinal position;
+ register Cardinal i;
+ register CompositeWidget cw;
+ register WidgetList children;
+
+ cw = (CompositeWidget) w->core.parent;
+ children = cw->composite.children;
+
+ if (cw->composite.insert_position != NULL)
+ position = (*(cw->composite.insert_position))(w);
+ else
+ position = cw->composite.num_children;
+
+ if (cw->composite.num_children == cw->composite.num_slots) {
+ /* Allocate more space */
+ cw->composite.num_slots += (cw->composite.num_slots / 2) + 2;
+ cw->composite.children = children =
+ (WidgetList) XtRealloc((XtPointer) children,
+ (unsigned) (cw->composite.num_slots) * sizeof(Widget));
+ }
+ /* Ripple children up one space from "position" */
+ for (i = cw->composite.num_children; i > position; i--) {
+ children[i] = children[i-1];
+ }
+ children[position] = w;
+ cw->composite.num_children++;
+}
+
+static void CompositeDeleteChild(
+ Widget w)
+{
+ register Cardinal position;
+ register Cardinal i;
+ register CompositeWidget cw;
+
+ cw = (CompositeWidget) w->core.parent;
+
+ for (position = 0; position < cw->composite.num_children; position++) {
+ if (cw->composite.children[position] == w) {
+ break;
+ }
+ }
+ if (position == cw->composite.num_children) return;
+
+ /* Ripple children down one space from "position" */
+ cw->composite.num_children--;
+ for (i = position; i < cw->composite.num_children; i++) {
+ cw->composite.children[i] = cw->composite.children[i+1];
+ }
+}
+
+/* ARGSUSED */
+static void CompositeInitialize(
+ Widget requested_widget,
+ Widget new_widget,
+ ArgList args,
+ Cardinal *num_args)
+{
+ register CompositeWidget cw;
+
+ cw = (CompositeWidget) new_widget;
+ cw->composite.num_children = 0;
+ cw->composite.children = NULL;
+ cw->composite.num_slots = 0;
+}
diff --git a/nx-X11/lib/Xt/Composite.h b/nx-X11/lib/Xt/Composite.h
new file mode 100644
index 000000000..0a58332be
--- /dev/null
+++ b/nx-X11/lib/Xt/Composite.h
@@ -0,0 +1,105 @@
+/* $Xorg: Composite.h,v 1.4 2001/02/09 02:03:54 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.
+
+******************************************************************/
+/* $XFree86$ */
+
+#ifndef _XtComposite_h
+#define _XtComposite_h
+
+typedef struct _CompositeClassRec *CompositeWidgetClass;
+
+typedef Cardinal (*XtOrderProc)(
+ Widget /* child */
+);
+
+_XFUNCPROTOBEGIN
+
+extern void XtManageChildren(
+ WidgetList /* children */,
+ Cardinal /* num_children */
+);
+
+extern void XtManageChild(
+ Widget /* child */
+);
+
+extern void XtUnmanageChildren(
+ WidgetList /* children */,
+ Cardinal /* num_children */
+);
+
+extern void XtUnmanageChild(
+ Widget /* child */
+);
+
+typedef void (*XtDoChangeProc)(
+ Widget /* composite_parent */,
+ WidgetList /* unmanage_children */,
+ Cardinal * /* num_unmanage_children */,
+ WidgetList /* manage_children */,
+ Cardinal * /* num_manage_children */,
+ XtPointer /* client_data */
+);
+
+extern void XtChangeManagedSet(
+ WidgetList /* unmanage_children */,
+ Cardinal /* num_unmanage_children */,
+ XtDoChangeProc /* do_change_proc */,
+ XtPointer /* client_data */,
+ WidgetList /* manage_children */,
+ Cardinal /* num_manage_children */
+);
+
+_XFUNCPROTOEND
+
+#ifndef XT_COMPOSITE
+externalref WidgetClass compositeWidgetClass;
+#endif
+
+#endif /* _XtComposite_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/CompositeP.h b/nx-X11/lib/Xt/CompositeP.h
new file mode 100644
index 000000000..ed055b21f
--- /dev/null
+++ b/nx-X11/lib/Xt/CompositeP.h
@@ -0,0 +1,111 @@
+/* $Xorg: CompositeP.h,v 1.4 2001/02/09 02:03:54 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.
+
+******************************************************************/
+
+#ifndef _XtCompositeP_h
+#define _XtCompositeP_h
+
+#include <X11/Composite.h>
+
+/************************************************************************
+ *
+ * Additional instance fields for widgets of (sub)class 'Composite'
+ *
+ ************************************************************************/
+
+typedef struct _CompositePart {
+ WidgetList children; /* array of ALL widget children */
+ Cardinal num_children; /* total number of widget children */
+ Cardinal num_slots; /* number of slots in children array */
+ XtOrderProc insert_position; /* compute position of new child */
+} CompositePart,*CompositePtr;
+
+typedef struct _CompositeRec {
+ CorePart core;
+ CompositePart composite;
+} CompositeRec;
+
+/*********************************************************************
+ *
+ * Additional class fields for widgets of (sub)class 'Composite'
+ *
+ ********************************************************************/
+
+typedef struct _CompositeClassPart {
+ XtGeometryHandler geometry_manager; /* geometry manager for children */
+ XtWidgetProc change_managed; /* change managed state of child */
+ XtWidgetProc insert_child; /* physically add child to parent */
+ XtWidgetProc delete_child; /* physically remove child */
+ XtPointer extension; /* pointer to extension record */
+} CompositeClassPart,*CompositePartPtr;
+
+typedef struct {
+ XtPointer next_extension; /* 1st 4 mandated for all extension records */
+ XrmQuark record_type; /* NULLQUARK; on CompositeClassPart */
+ long version; /* must be XtCompositeExtensionVersion */
+ Cardinal record_size; /* sizeof(CompositeClassExtensionRec) */
+ Boolean accepts_objects;
+ Boolean allows_change_managed_set;
+} CompositeClassExtensionRec, *CompositeClassExtension;
+
+
+typedef struct _CompositeClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+} CompositeClassRec;
+
+externalref CompositeClassRec compositeClassRec;
+
+#define XtCompositeExtensionVersion 2L
+#define XtInheritGeometryManager ((XtGeometryHandler) _XtInherit)
+#define XtInheritChangeManaged ((XtWidgetProc) _XtInherit)
+#define XtInheritInsertChild ((XtWidgetProc) _XtInherit)
+#define XtInheritDeleteChild ((XtWidgetProc) _XtInherit)
+
+#endif /* _XtCompositeP_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/ConstrainP.h b/nx-X11/lib/Xt/ConstrainP.h
new file mode 100644
index 000000000..a90d19ac6
--- /dev/null
+++ b/nx-X11/lib/Xt/ConstrainP.h
@@ -0,0 +1,94 @@
+/* $Xorg: ConstrainP.h,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
+/* $oHeader: ConstrainP.h,v 1.2 88/08/18 15:54:15 asente 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.
+
+******************************************************************/
+
+#ifndef _XtConstraintP_h
+#define _XtConstraintP_h
+
+#include <X11/Constraint.h>
+
+typedef struct _ConstraintPart {
+ XtPointer mumble; /* No new fields, keep C compiler happy */
+} ConstraintPart;
+
+typedef struct _ConstraintRec {
+ CorePart core;
+ CompositePart composite;
+ ConstraintPart constraint;
+} ConstraintRec, *ConstraintWidget;
+
+typedef struct _ConstraintClassPart {
+ XtResourceList resources; /* constraint resource list */
+ Cardinal num_resources; /* number of constraints in list */
+ Cardinal constraint_size; /* size of constraint record */
+ XtInitProc initialize; /* constraint initialization */
+ XtWidgetProc destroy; /* constraint destroy proc */
+ XtSetValuesFunc set_values; /* constraint set_values proc */
+ XtPointer extension; /* pointer to extension record */
+} ConstraintClassPart;
+
+typedef struct {
+ XtPointer next_extension; /* 1st 4 mandated for all extension records */
+ XrmQuark record_type; /* NULLQUARK; on ConstraintClassPart */
+ long version; /* must be XtConstraintExtensionVersion */
+ Cardinal record_size; /* sizeof(ConstraintClassExtensionRec) */
+ XtArgsProc get_values_hook;
+} ConstraintClassExtensionRec, *ConstraintClassExtension;
+
+typedef struct _ConstraintClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ConstraintClassPart constraint_class;
+} ConstraintClassRec;
+
+externalref ConstraintClassRec constraintClassRec;
+
+#define XtConstraintExtensionVersion 1L
+
+#endif /* _XtConstraintP_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/Constraint.c b/nx-X11/lib/Xt/Constraint.c
new file mode 100644
index 000000000..dd9b52310
--- /dev/null
+++ b/nx-X11/lib/Xt/Constraint.c
@@ -0,0 +1,134 @@
+/* $Xorg: Constraint.c,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+/* $XFree86: xc/lib/Xt/Constraint.c,v 1.2 2001/08/22 22:52:17 dawes Exp $ */
+
+#define CONSTRAINT
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+
+static void ConstraintPartInitialize(WidgetClass wc);
+externaldef(constraintclassrec) ConstraintClassRec constraintClassRec = {
+ { /******* CorePart *******/
+ /* superclass */ (WidgetClass) &compositeClassRec,
+ /* class_name */ "Constraint",
+ /* widget_size */ sizeof(ConstraintRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize*/ ConstraintPartInitialize,
+ /* class_inited */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ NULL,
+ /* num_resources */ 0,
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ NULL,
+ /* expose */ NULL,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL
+ },{ /**** CompositePart *****/
+ /* geometry_handler */ NULL,
+ /* change_managed */ NULL,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },{ /**** ConstraintPart ****/
+ /* resources */ NULL,
+ /* num_resources */ 0,
+ /* constraint_size */ 0,
+ /* initialize */ NULL,
+ /* destroy */ NULL,
+ /* set_values */ NULL,
+ /* extension */ NULL
+ }
+};
+
+externaldef(constraintwidgetclass) WidgetClass constraintWidgetClass =
+ (WidgetClass) &constraintClassRec;
+
+
+static void ConstraintPartInitialize(WidgetClass wc)
+{
+ ConstraintWidgetClass cwc = (ConstraintWidgetClass)wc;
+ if (cwc->constraint_class.resources)
+ _XtCompileResourceList(cwc->constraint_class.resources,
+ cwc->constraint_class.num_resources);
+
+ _XtConstraintResDependencies((ConstraintWidgetClass)wc);
+}
diff --git a/nx-X11/lib/Xt/Constraint.h b/nx-X11/lib/Xt/Constraint.h
new file mode 100644
index 000000000..9bb962e0d
--- /dev/null
+++ b/nx-X11/lib/Xt/Constraint.h
@@ -0,0 +1,60 @@
+/* $Xorg: Constraint.h,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
+/* $oHeader: Constraint.h,v 1.2 88/08/18 15:54:18 asente 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.
+
+******************************************************************/
+
+#ifndef _XtConstraint_h
+#define _XtConstraint_h
+
+typedef struct _ConstraintClassRec *ConstraintWidgetClass;
+
+#ifndef CONSTRAINT
+externalref WidgetClass constraintWidgetClass;
+#endif
+
+#endif /* _XtConstraint_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/Convert.c b/nx-X11/lib/Xt/Convert.c
new file mode 100644
index 000000000..c3bb3c63a
--- /dev/null
+++ b/nx-X11/lib/Xt/Convert.c
@@ -0,0 +1,1087 @@
+/* $Xorg: Convert.c,v 1.5 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/Convert.c,v 3.7 2001/12/14 19:56:09 dawes 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+#include "Intrinsic.h"
+
+/* Conversion procedure hash table */
+
+#define CONVERTHASHSIZE ((unsigned)256)
+#define CONVERTHASHMASK 255
+#define ProcHash(from_type, to_type) (2 * (from_type) + to_type)
+
+typedef struct _ConverterRec *ConverterPtr;
+typedef struct _ConverterRec {
+ ConverterPtr next;
+ XrmRepresentation from, to;
+ XtTypeConverter converter;
+ XtDestructor destructor;
+ unsigned short num_args;
+ unsigned int do_ref_count:1;
+ unsigned int new_style:1;
+ unsigned int global:1;
+ char cache_type;
+} ConverterRec;
+
+#define ConvertArgs(p) ((XtConvertArgList)((p)+1))
+
+/* used for old-style type converter cache only */
+static Heap globalHeap = {NULL, NULL, 0};
+
+void _XtSetDefaultConverterTable(
+ ConverterTable *table)
+{
+ register ConverterTable globalConverterTable;
+
+ LOCK_PROCESS;
+ globalConverterTable = _XtGetProcessContext()->globalConverterTable;
+
+ *table = (ConverterTable)
+ __XtCalloc(CONVERTHASHSIZE, (unsigned)sizeof(ConverterPtr));
+ _XtAddDefaultConverters(*table);
+
+ if (globalConverterTable) {
+ ConverterPtr rec;
+ int i;
+ XtCacheType cache_type;
+ for (i = CONVERTHASHSIZE; --i >= 0; ) {
+ for (rec = *globalConverterTable++; rec; rec = rec->next) {
+ cache_type = rec->cache_type;
+ if (rec->do_ref_count)
+ cache_type |= XtCacheRefCount;
+ _XtTableAddConverter(*table, rec->from, rec->to, rec->converter,
+ ConvertArgs(rec), rec->num_args,
+ rec->new_style, cache_type,
+ rec->destructor, True);
+ }
+ }
+ }
+ UNLOCK_PROCESS;
+}
+
+void _XtFreeConverterTable(
+ ConverterTable table)
+{
+ register Cardinal i;
+ register ConverterPtr p;
+
+ for (i = 0; i < CONVERTHASHSIZE; i++) {
+ for (p = table[i]; p; ) {
+ register ConverterPtr next = p->next;
+ XtFree((char*)p);
+ p = next;
+ }
+ }
+ XtFree((char*)table);
+}
+
+/* Data cache hash table */
+
+typedef struct _CacheRec *CachePtr;
+
+typedef struct _CacheRec {
+ CachePtr next;
+ XtPointer tag;
+ int hash;
+ XtTypeConverter converter;
+ unsigned short num_args;
+ unsigned int conversion_succeeded:1;
+ unsigned int has_ext:1;
+ unsigned int is_refcounted:1;
+ unsigned int must_be_freed:1;
+ unsigned int from_is_value:1;
+ unsigned int to_is_value:1;
+ XrmValue from;
+ XrmValue to;
+} CacheRec;
+
+typedef struct _CacheRecExt {
+ CachePtr *prev;
+ XtDestructor destructor;
+ XtPointer closure;
+ long ref_count;
+} CacheRecExt;
+
+#define CEXT(p) ((CacheRecExt *)((p)+1))
+#define CARGS(p) ((p)->has_ext ? (XrmValue *)(CEXT(p)+1) : (XrmValue *)((p)+1))
+
+#define CACHEHASHSIZE 256
+#define CACHEHASHMASK 255
+typedef CachePtr CacheHashTable[CACHEHASHSIZE];
+
+static CacheHashTable cacheHashTable;
+
+void _XtTableAddConverter(
+ ConverterTable table,
+ XrmRepresentation from_type,
+ XrmRepresentation to_type,
+ XtTypeConverter converter,
+ XtConvertArgList convert_args,
+ Cardinal num_args,
+ _XtBoolean new_style,
+ XtCacheType cache_type,
+ XtDestructor destructor,
+ _XtBoolean global)
+{
+ register ConverterPtr *pp;
+ register ConverterPtr p;
+ XtConvertArgList args;
+
+ pp= &table[ProcHash(from_type, to_type) & CONVERTHASHMASK];
+ while ((p = *pp) && (p->from != from_type || p->to != to_type))
+ pp = &p->next;
+
+ if (p) {
+ *pp = p->next;
+ XtFree((char *)p);
+ }
+
+ p = (ConverterPtr) __XtMalloc(sizeof(ConverterRec) +
+ sizeof(XtConvertArgRec) * num_args);
+ p->next = *pp;
+ *pp = p;
+ p->from = from_type;
+ p->to = to_type;
+ p->converter = converter;
+ p->destructor = destructor;
+ p->num_args = num_args;
+ p->global = global;
+ args = ConvertArgs(p);
+ while (num_args--)
+ *args++ = *convert_args++;
+ p->new_style = new_style;
+ p->do_ref_count = False;
+ if (destructor || (cache_type & 0xff)) {
+ p->cache_type = cache_type & 0xff;
+ if (cache_type & XtCacheRefCount)
+ p->do_ref_count = True;
+ } else {
+ p->cache_type = XtCacheNone;
+ }
+}
+
+void XtSetTypeConverter(
+ register _Xconst char* from_type,
+ register _Xconst char* to_type,
+ XtTypeConverter converter,
+ XtConvertArgList convert_args,
+ Cardinal num_args,
+ XtCacheType cache_type,
+ XtDestructor destructor
+ )
+{
+ ProcessContext process;
+ XtAppContext app;
+ XrmRepresentation from;
+ XrmRepresentation to;
+
+ LOCK_PROCESS;
+ process = _XtGetProcessContext();
+ app = process->appContextList;
+ from = XrmStringToRepresentation(from_type);
+ to = XrmStringToRepresentation(to_type);
+
+ if (!process->globalConverterTable) {
+ process->globalConverterTable = (ConverterTable)
+ __XtCalloc(CONVERTHASHSIZE, (unsigned)sizeof(ConverterPtr));
+ }
+ _XtTableAddConverter(process->globalConverterTable, from, to,
+ converter, convert_args,
+ num_args, True, cache_type, destructor, True);
+ while (app) {
+ _XtTableAddConverter(app->converterTable, from, to,
+ converter, convert_args,
+ num_args, True, cache_type, destructor, True);
+ app = app->next;
+ }
+ UNLOCK_PROCESS;
+}
+
+void XtAppSetTypeConverter(
+ XtAppContext app,
+ register _Xconst char* from_type,
+ register _Xconst char* to_type,
+ XtTypeConverter converter,
+ XtConvertArgList convert_args,
+ Cardinal num_args,
+ XtCacheType cache_type,
+ XtDestructor destructor
+ )
+{
+ LOCK_PROCESS;
+ _XtTableAddConverter(app->converterTable,
+ XrmStringToRepresentation(from_type),
+ XrmStringToRepresentation(to_type),
+ converter, convert_args, num_args,
+ True, cache_type, destructor, False);
+ UNLOCK_PROCESS;
+}
+
+/* old interface */
+void XtAddConverter(
+ register _Xconst char* from_type,
+ register _Xconst char* to_type,
+ XtConverter converter,
+ XtConvertArgList convert_args,
+ Cardinal num_args
+ )
+{
+ ProcessContext process;
+ XtAppContext app;
+ XrmRepresentation from;
+ XrmRepresentation to;
+
+ LOCK_PROCESS;
+ process = _XtGetProcessContext();
+ app = process->appContextList;
+ from = XrmStringToRepresentation(from_type);
+ to = XrmStringToRepresentation(to_type);
+
+ if (!process->globalConverterTable) {
+ process->globalConverterTable = (ConverterTable)
+ __XtCalloc(CONVERTHASHSIZE, (unsigned)sizeof(ConverterPtr));
+ }
+ _XtTableAddConverter(process->globalConverterTable, from, to,
+ (XtTypeConverter)converter, convert_args, num_args,
+ False, XtCacheAll, (XtDestructor)NULL, True);
+ while (app) {
+ _XtTableAddConverter(app->converterTable, from, to,
+ (XtTypeConverter)converter, convert_args,
+ num_args, False, XtCacheAll, (XtDestructor)NULL,
+ True);
+ app = app->next;
+ }
+ UNLOCK_PROCESS;
+}
+
+/* old interface */
+void XtAppAddConverter(
+ XtAppContext app,
+ register _Xconst char* from_type,
+ register _Xconst char* to_type,
+ XtConverter converter,
+ XtConvertArgList convert_args,
+ Cardinal num_args
+ )
+{
+ LOCK_PROCESS;
+ _XtTableAddConverter(app->converterTable,
+ XrmStringToRepresentation(from_type),
+ XrmStringToRepresentation(to_type),
+ (XtTypeConverter)converter, convert_args, num_args,
+ False, XtCacheAll, (XtDestructor)NULL, False);
+ UNLOCK_PROCESS;
+}
+
+static CachePtr
+CacheEnter(
+ Heap* heap,
+ register XtTypeConverter converter,
+ register XrmValuePtr args,
+ Cardinal num_args,
+ XrmValuePtr from,
+ XrmValuePtr to,
+ Boolean succeeded,
+ register int hash,
+ Boolean do_ref,
+ Boolean do_free,
+ XtDestructor destructor,
+ XtPointer closure)
+{
+ register CachePtr *pHashEntry;
+ register CachePtr p;
+ register Cardinal i;
+
+ LOCK_PROCESS;
+ pHashEntry = &cacheHashTable[hash & CACHEHASHMASK];
+
+ if ((succeeded && destructor) || do_ref) {
+ p = (CachePtr) _XtHeapAlloc(heap, (sizeof(CacheRec) +
+ sizeof(CacheRecExt) +
+ num_args * sizeof(XrmValue)));
+ CEXT(p)->prev = pHashEntry;
+ CEXT(p)->destructor = succeeded ? destructor : NULL;
+ CEXT(p)->closure = closure;
+ CEXT(p)->ref_count = 1;
+ p->has_ext = True;
+ }
+ else {
+ p = (CachePtr)_XtHeapAlloc(heap, (sizeof(CacheRec) +
+ num_args * sizeof(XrmValue)));
+ p->has_ext = False;
+ }
+ if (!to->addr)
+ succeeded = False;
+ p->conversion_succeeded = succeeded;
+ p->is_refcounted = do_ref;
+ p->must_be_freed = do_free;
+ p->next = *pHashEntry;
+ if (p->next && p->next->has_ext)
+ CEXT(p->next)->prev = &p->next;
+
+ *pHashEntry = p;
+ p->tag = (XtPointer)heap;
+ p->hash = hash;
+ p->converter = converter;
+ p->from.size = from->size;
+ if (from->size <= sizeof(p->from.addr)) {
+ p->from_is_value = True;
+ XtMemmove(&p->from.addr, from->addr, from->size);
+ } else {
+ p->from_is_value = False;
+ p->from.addr = (XPointer)_XtHeapAlloc(heap, from->size);
+ (void) memmove((char *)p->from.addr, (char *)from->addr, from->size);
+ }
+ p->num_args = num_args;
+ if (num_args) {
+ XrmValue *pargs = CARGS(p);
+ for (i = 0; i < num_args; i++) {
+ pargs[i].size = args[i].size;
+ pargs[i].addr = (XPointer)_XtHeapAlloc(heap, args[i].size);
+ XtMemmove(pargs[i].addr, args[i].addr, args[i].size);
+ }
+ }
+ p->to.size = to->size;
+ if (!succeeded) {
+ p->to_is_value = False;
+ p->to.addr = NULL;
+ } else if (to->size <= sizeof(p->to.addr)) {
+ p->to_is_value = True;
+ XtMemmove(&p->to.addr, to->addr, to->size);
+ } else {
+ p->to_is_value = False;
+ p->to.addr = (XPointer)_XtHeapAlloc(heap, to->size);
+ (void) memmove((char *)p->to.addr, (char *)to->addr, to->size);
+ }
+ UNLOCK_PROCESS;
+ return p;
+}
+
+static void FreeCacheRec(
+ XtAppContext app,
+ CachePtr p,
+ CachePtr *prev)
+{
+ LOCK_PROCESS;
+ if (p->has_ext) {
+ if (CEXT(p)->destructor) {
+ Cardinal num_args = p->num_args;
+ XrmValue *args = NULL;
+ XrmValue toc;
+ if (num_args)
+ args = CARGS(p);
+ toc.size = p->to.size;
+ if (p->to_is_value)
+ toc.addr = (XPointer)&p->to.addr;
+ else
+ toc.addr = p->to.addr;
+ (*CEXT(p)->destructor) (app, &toc, CEXT(p)->closure, args,
+ &num_args);
+ }
+ *(CEXT(p)->prev) = p->next;
+ if (p->next && p->next->has_ext)
+ CEXT(p->next)->prev = CEXT(p)->prev;
+ } else {
+ *prev = p->next;
+ if (p->next && p->next->has_ext)
+ CEXT(p->next)->prev = prev;
+ }
+ if (p->must_be_freed) {
+ register int i;
+ if (!p->from_is_value)
+ XtFree(p->from.addr);
+ if ((i = p->num_args)) {
+ XrmValue *pargs = CARGS(p);
+ while (i--)
+ XtFree(pargs[i].addr);
+ }
+ if (!p->to_is_value)
+ XtFree(p->to.addr);
+ XtFree((char*)p);
+ }
+ /* else on private heap; will free entire heap later */
+ UNLOCK_PROCESS;
+}
+
+
+void _XtCacheFlushTag(
+ XtAppContext app,
+ XtPointer tag)
+{
+ int i;
+ register CachePtr *prev;
+ register CachePtr rec;
+
+ LOCK_PROCESS;
+ for (i = CACHEHASHSIZE; --i >= 0;) {
+ prev = &cacheHashTable[i];
+ while ((rec = *prev)) {
+ if (rec->tag == tag)
+ FreeCacheRec(app, rec, prev);
+ else
+ prev = &rec->next;
+ }
+ }
+ UNLOCK_PROCESS;
+}
+
+#ifdef DEBUG
+#include <stdio.h>
+
+void _XtConverterCacheStats(void)
+{
+ register Cardinal i;
+ register CachePtr p;
+ register Cardinal entries;
+
+ LOCK_PROCESS;
+ for (i = 0; i < CACHEHASHSIZE; i++) {
+ p = cacheHashTable[i];
+ if (p) {
+ for (entries = 0; p; p = p->next) {
+ entries++;
+ }
+ (void) fprintf(stdout, "Index: %4d Entries: %d\n", i, entries);
+ for (p = cacheHashTable[i]; p; p = p->next) {
+ (void) fprintf(stdout, " Size: %3d Refs: %3d '",
+ p->from.size,
+ p->has_ext ? CEXT(p)->ref_count : 0);
+ (void) fprintf(stdout, "'\n");
+ }
+ (void) fprintf(stdout, "\n");
+ }
+ }
+ UNLOCK_PROCESS;
+}
+#endif /*DEBUG*/
+
+static Boolean ResourceQuarkToOffset(
+ WidgetClass widget_class,
+ XrmName name,
+ Cardinal *offset)
+{
+ register WidgetClass wc;
+ register Cardinal i;
+ register XrmResourceList res, *resources;
+
+ for (wc = widget_class; wc; wc = wc->core_class.superclass) {
+ resources = (XrmResourceList*) wc->core_class.resources;
+ for (i = 0; i < wc->core_class.num_resources; i++, resources++) {
+ res = *resources;
+ if (res->xrm_name == name) {
+ *offset = -res->xrm_offset - 1;
+ return True;
+ }
+ } /* for i in resources */
+ } /* for wc in widget classes */
+ (*offset) = 0;
+ return False;
+}
+
+
+static void ComputeArgs(
+ Widget widget,
+ XtConvertArgList convert_args,
+ Cardinal num_args,
+ XrmValuePtr args)
+{
+ register Cardinal i;
+ Cardinal offset;
+ String params[1];
+ Cardinal num_params = 1;
+ Widget ancestor = NULL;
+
+ for (i = 0; i < num_args; i++) {
+ args[i].size = convert_args[i].size;
+ switch (convert_args[i].address_mode) {
+ case XtAddress:
+ args[i].addr = convert_args[i].address_id;
+ break;
+
+ case XtBaseOffset:
+ args[i].addr =
+ (XPointer)((char *)widget + (long)convert_args[i].address_id);
+ break;
+
+ case XtWidgetBaseOffset:
+ if (!ancestor) {
+ if (XtIsWidget(widget))
+ ancestor = widget;
+ else
+ ancestor = _XtWindowedAncestor(widget);
+ }
+
+ args[i].addr =
+ (XPointer)((char *)ancestor + (long)convert_args[i].address_id);
+ break;
+
+ case XtImmediate:
+ args[i].addr = (XPointer) &(convert_args[i].address_id);
+ break;
+
+ case XtProcedureArg:
+ (*(XtConvertArgProc)convert_args[i].address_id)
+ (widget, &convert_args[i].size, &args[i]);
+ break;
+
+ case XtResourceString:
+ /* Convert in place for next usage */
+ convert_args[i].address_mode = XtResourceQuark;
+ convert_args[i].address_id =
+ (XtPointer)(long)XrmStringToQuark((String)convert_args[i].address_id);
+ /* Fall through */
+
+ case XtResourceQuark:
+ if (! ResourceQuarkToOffset(widget->core.widget_class,
+ (XrmQuark)(long) convert_args[i].address_id, &offset)) {
+ params[0]=
+ XrmQuarkToString((XrmQuark)(long) convert_args[i].address_id);
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "invalidResourceName","computeArgs",XtCXtToolkitError,
+ "Cannot find resource name %s as argument to conversion",
+ params,&num_params);
+ offset = 0;
+ }
+ args[i].addr = (XPointer)((char *)widget + offset);
+ break;
+ default:
+ params[0] = XtName(widget);
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "invalidAddressMode", "computeArgs", XtCXtToolkitError,
+ "Conversion arguments for widget '%s' contain an unsupported address mode",
+ params,&num_params);
+ args[i].addr = NULL;
+ args[i].size = 0;
+ } /* switch */
+ } /* for */
+} /* ComputeArgs */
+
+void XtDirectConvert(
+ XtConverter converter,
+ XrmValuePtr args,
+ Cardinal num_args,
+ register XrmValuePtr from,
+ XrmValuePtr to)
+{
+ register CachePtr p;
+ register int hash;
+ register Cardinal i;
+
+ LOCK_PROCESS;
+ /* Try to find cache entry for conversion */
+ hash = ((long) converter >> 2) + from->size + *((char *) from->addr);
+ if (from->size > 1) hash += ((char *) from->addr)[1];
+
+ for (p = cacheHashTable[hash & CACHEHASHMASK]; p; p = p->next) {
+ if ((p->hash == hash)
+ && (p->converter == (XtTypeConverter)converter)
+ && (p->from.size == from->size)
+ && !(p->from_is_value ?
+ XtMemcmp(&p->from.addr, from->addr, from->size) :
+ memcmp((char *)p->from.addr, (char *)from->addr, from->size))
+ && (p->num_args == num_args)) {
+ if ((i = num_args)) {
+ XrmValue *pargs = CARGS(p);
+ /* Are all args the same data ? */
+ while (i) {
+ i--; /* do not move to while test, broken compilers */
+ if (pargs[i].size != args[i].size ||
+ XtMemcmp(pargs[i].addr, args[i].addr, args[i].size)) {
+ i++;
+ break;
+ }
+ }
+ }
+ if (!i) {
+ /* Perfect match */
+ to->size = p->to.size;
+ if (p->to_is_value)
+ to->addr = (XPointer)&p->to.addr;
+ else
+ to->addr = p->to.addr;
+ UNLOCK_PROCESS;
+ return;
+ }
+ }
+ }
+
+ /* Didn't find it, call converter procedure and entry result in cache */
+ (*to).size = 0;
+ (*to).addr = NULL;
+ (*converter)(args, &num_args, from, to);
+ /* This memory can never be freed since we don't know the Display
+ * or app context from which to compute the persistance */
+ {
+ CacheEnter(&globalHeap, (XtTypeConverter)converter, args, num_args,
+ from, to, (to->addr != NULL), hash, False, False,
+ (XtDestructor)NULL, NULL);
+ }
+ UNLOCK_PROCESS;
+}
+
+
+static ConverterPtr GetConverterEntry(
+ XtAppContext app,
+ XtTypeConverter converter)
+{
+ Cardinal entry;
+ register ConverterPtr cP;
+ ConverterTable converterTable;
+
+ LOCK_PROCESS;
+ converterTable = app->converterTable;
+ cP = NULL;
+ for (entry = 0; (entry < CONVERTHASHSIZE) && !cP; entry++) {
+ cP = converterTable[entry];
+ while (cP && (cP->converter != converter)) cP = cP->next;
+ }
+ UNLOCK_PROCESS;
+ return cP;
+}
+
+
+static Boolean
+CallConverter(
+ Display* dpy,
+ XtTypeConverter converter,
+ XrmValuePtr args,
+ Cardinal num_args,
+ register XrmValuePtr from,
+ XrmValuePtr to,
+ XtCacheRef *cache_ref_return,
+ register ConverterPtr cP)
+{
+ CachePtr p;
+ int hash;
+ Cardinal i;
+ Boolean retval;
+
+ if (!cP || ((cP->cache_type == XtCacheNone) && !cP->destructor)) {
+ XtPointer closure;
+ if (cache_ref_return) *cache_ref_return = NULL;
+ retval = (*(XtTypeConverter)converter)
+ (dpy, args, &num_args, from, to, &closure);
+ return retval;
+ }
+
+ LOCK_PROCESS;
+ /* Try to find cache entry for conversion */
+ hash = ((long)(converter) >> 2) + from->size + *((char *) from->addr);
+ if (from->size > 1) hash += ((char *) from->addr)[1];
+
+ if (cP->cache_type != XtCacheNone) {
+ for (p = cacheHashTable[hash & CACHEHASHMASK]; p; p = p->next){
+ if ((p->hash == hash)
+ && (p->converter == converter)
+ && (p->from.size == from->size)
+ && !(p->from_is_value ?
+ XtMemcmp(&p->from.addr, from->addr, from->size) :
+ memcmp((char *)p->from.addr, (char *)from->addr, from->size))
+ && (p->num_args == num_args)) {
+ if ((i = num_args)) {
+ XrmValue *pargs = CARGS(p);
+ /* Are all args the same data ? */
+ while (i) {
+ i--; /* do not move to while test, broken compilers */
+ if (pargs[i].size != args[i].size ||
+ XtMemcmp(pargs[i].addr, args[i].addr, args[i].size)){
+ i++;
+ break;
+ }
+ }
+ }
+ if (!i) {
+ /* Perfect match */
+ if (p->conversion_succeeded) {
+ if (to->addr) { /* new-style call */
+ if (to->size < p->to.size) {
+ to->size = p->to.size;
+ UNLOCK_PROCESS;
+ return False;
+ }
+ to->size = p->to.size;
+ if (p->to_is_value) {
+ XtMemmove(to->addr, &p->to.addr,
+ to->size);
+ } else {
+ (void) memmove((char *)to->addr,
+ (char *)p->to.addr, to->size);
+ }
+ } else { /* old-style call */
+ to->size = p->to.size;
+ if (p->to_is_value)
+ to->addr = (XPointer)&p->to.addr;
+ else
+ to->addr = p->to.addr;
+ }
+ }
+ if (p->is_refcounted) {
+ CEXT(p)->ref_count++;
+ if (cache_ref_return)
+ *cache_ref_return = (XtCacheRef)p;
+ else
+ p->is_refcounted = False;
+ }
+ else {
+ if (cache_ref_return)
+ *cache_ref_return = NULL;
+ }
+ retval = (p->conversion_succeeded);
+ UNLOCK_PROCESS;
+ return retval;
+ }
+ }
+ }
+ }
+
+ /* No cache entry, call converter procedure and enter result in cache */
+ {
+ Heap *heap;
+ XtPointer closure = NULL;
+ unsigned int supplied_size = to->size;
+ Boolean do_ref = cP->do_ref_count && cache_ref_return;
+ Boolean do_free = False;
+ Boolean retval =
+ (*(XtTypeConverter)converter)(dpy, args, &num_args, from, to, &closure);
+
+ if (retval == False && supplied_size < to->size) {
+ /* programmer error: caller must allocate sufficient storage */
+ if (cache_ref_return)
+ *cache_ref_return = NULL;
+ UNLOCK_PROCESS;
+ return False;
+ }
+
+ if ((cP->cache_type == XtCacheNone) || do_ref) {
+ heap = NULL;
+ do_free = True;
+ }
+ else if (cP->cache_type == XtCacheByDisplay)
+ heap = &_XtGetPerDisplay(dpy)->heap;
+ else if (cP->global)
+ heap = &globalHeap;
+ else
+ heap = &XtDisplayToApplicationContext(dpy)->heap;
+
+ p = CacheEnter(heap, converter, args, num_args, from, to, retval,
+ hash, do_ref, do_free, cP->destructor, closure);
+ if (do_ref)
+ *cache_ref_return = (XtCacheRef)p;
+ else if (cache_ref_return)
+ *cache_ref_return = NULL;
+ UNLOCK_PROCESS;
+ return retval;
+ }
+}
+
+Boolean
+XtCallConverter(
+ Display* dpy,
+ XtTypeConverter converter,
+ XrmValuePtr args,
+ Cardinal num_args,
+ register XrmValuePtr from,
+ XrmValuePtr to,
+ XtCacheRef *cache_ref_return)
+{
+ ConverterPtr cP;
+ Boolean retval;
+ XtAppContext app = XtDisplayToApplicationContext(dpy);
+
+ LOCK_APP(app);
+ if ((cP = GetConverterEntry(app, converter)) == NULL) {
+ XtAppSetTypeConverter(XtDisplayToApplicationContext(dpy),
+ "_XtUnk1", "_XtUnk2",
+ converter, NULL, 0,
+ XtCacheAll, NULL);
+ cP = GetConverterEntry(app, converter);
+ }
+ retval = CallConverter(dpy, converter, args, num_args, from, to,
+ cache_ref_return, cP);
+ UNLOCK_APP(app);
+ return retval;
+}
+
+Boolean _XtConvert(
+ Widget widget,
+ register XrmRepresentation from_type,
+ XrmValuePtr from,
+ register XrmRepresentation to_type,
+ register XrmValuePtr to,
+ XtCacheRef *cache_ref_return)
+{
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+ register ConverterPtr p;
+ Cardinal num_args;
+ XrmValue *args;
+
+ /* Look for type converter */
+ LOCK_PROCESS;
+ p = app->converterTable[ProcHash(from_type, to_type) & CONVERTHASHMASK];
+ for (; p; p = p->next) {
+ if (from_type == p->from && to_type == p->to) {
+ Boolean retval = False;
+ /* Compute actual arguments from widget and arg descriptor */
+ num_args = p->num_args;
+ if (num_args != 0) {
+ args = (XrmValue*)
+ ALLOCATE_LOCAL( num_args * sizeof (XrmValue) );
+ if (!args) _XtAllocError("alloca");
+ ComputeArgs(widget, ConvertArgs(p), num_args, args);
+ } else args = NULL;
+ if (p->new_style) {
+ retval =
+ CallConverter(XtDisplayOfObject(widget),
+ p->converter, args, num_args,
+ from, to, cache_ref_return, p);
+ }
+ else { /* is old-style (non-display) converter */
+ XrmValue tempTo;
+ XtDirectConvert((XtConverter)p->converter, args, num_args,
+ from, &tempTo);
+ if (cache_ref_return)
+ *cache_ref_return = NULL;
+ if (tempTo.addr) {
+ if (to->addr) { /* new-style caller */
+ if (to->size >= tempTo.size) {
+ if (to_type == _XtQString)
+ *(String*)(to->addr) = tempTo.addr;
+ else {
+ XtMemmove(to->addr, tempTo.addr,
+ tempTo.size);
+ }
+ retval = True;
+ }
+ to->size = tempTo.size;
+ } else { /* old-style caller */
+ *to = tempTo;
+ retval = True;
+ }
+ }
+ }
+ if (args) DEALLOCATE_LOCAL( (XtPointer)args );
+ UNLOCK_PROCESS;
+ return retval;
+ }
+ }
+
+ {
+ String params[2];
+ Cardinal num_params = 2;
+ params[0] = XrmRepresentationToString(from_type);
+ params[1] = XrmRepresentationToString(to_type);
+ XtAppWarningMsg(app, "typeConversionError", "noConverter", XtCXtToolkitError,
+ "No type converter registered for '%s' to '%s' conversion.",
+ params, &num_params);
+ }
+ UNLOCK_PROCESS;
+ return False;
+}
+
+void XtConvert(
+ Widget widget,
+ _Xconst char* from_type_str,
+ XrmValuePtr from,
+ _Xconst char* to_type_str,
+ XrmValuePtr to)
+{
+ XrmQuark from_type, to_type;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ from_type = XrmStringToRepresentation(from_type_str);
+ to_type = XrmStringToRepresentation(to_type_str);
+ if (from_type != to_type) {
+ /* It's not safe to ref count these resources, 'cause we
+ don't know what older clients may have assumed about
+ the resource lifetimes.
+ XtCacheRef ref;
+ */
+ to->addr = NULL;
+ to->size = 0;
+ _XtConvert(widget, from_type, from, to_type, to, /*&ref*/ NULL);
+ /*
+ if (ref) {
+ XtAddCallback( widget, XtNdestroyCallback,
+ XtCallbackReleaseCacheRef, (XtPointer)ref );
+ }
+ */
+ }
+ else
+ (*to) = *from;
+ UNLOCK_APP(app);
+}
+
+Boolean XtConvertAndStore(
+ Widget object,
+ _Xconst char* from_type_str,
+ XrmValuePtr from,
+ _Xconst char* to_type_str,
+ XrmValuePtr to)
+{
+ XrmQuark from_type, to_type;
+ WIDGET_TO_APPCON(object);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ from_type = XrmStringToRepresentation(from_type_str);
+ to_type = XrmStringToRepresentation(to_type_str);
+ if (from_type != to_type) {
+ static XtPointer local_valueP = NULL;
+ static Cardinal local_valueS = 128;
+ XtCacheRef ref;
+ Boolean local = False;
+ do {
+ if (!to->addr) {
+ if (!local_valueP)
+ local_valueP = _XtHeapAlloc(&globalHeap, local_valueS);
+ to->addr = local_valueP;
+ to->size = local_valueS;
+ local = True;
+ }
+ if (!_XtConvert(object, from_type, from, to_type, to, &ref)) {
+ if (local && (to->size > local_valueS)) {
+ to->addr =
+ local_valueP = _XtHeapAlloc(&globalHeap, to->size);
+ local_valueS = to->size;
+ continue;
+ } else {
+ if (local) {
+ to->addr = NULL;
+ to->size = 0;
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return False;
+ }
+ }
+ if (ref) {
+ XtAddCallback( object, XtNdestroyCallback,
+ XtCallbackReleaseCacheRef, (XtPointer)ref );
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return True;
+ } while (local /* && local_valueS < to->size */);
+ }
+ if (to->addr) {
+ if (to->size < from->size) {
+ to->size = from->size;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return False;
+ }
+ (void) memmove(to->addr, from->addr, from->size );
+ to->size = from->size;
+ } else /* from_type == to_type */
+ *to = *from;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return True;
+}
+
+void XtAppReleaseCacheRefs(
+ XtAppContext app,
+ XtCacheRef *refs)
+{
+ register CachePtr *r;
+ register CachePtr p;
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ for (r = (CachePtr*)refs; (p = *r); r++) {
+ if (p->is_refcounted && --(CEXT(p)->ref_count) == 0) {
+ FreeCacheRec(app, p, NULL);
+ }
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+
+/* ARGSUSED */
+void XtCallbackReleaseCacheRefList(
+ Widget widget, /* unused */
+ XtPointer closure,
+ XtPointer call_data) /* unused */
+{
+ XtAppReleaseCacheRefs( XtWidgetToApplicationContext(widget),
+ (XtCacheRef*)closure );
+ XtFree(closure);
+}
+
+
+/* ARGSUSED */
+void XtCallbackReleaseCacheRef(
+ Widget widget, /* unused */
+ XtPointer closure,
+ XtPointer call_data) /* unused */
+{
+ XtCacheRef cache_refs[2];
+ cache_refs[0] = (XtCacheRef)closure;
+ cache_refs[1] = NULL;
+ XtAppReleaseCacheRefs( XtWidgetToApplicationContext(widget), cache_refs );
+}
diff --git a/nx-X11/lib/Xt/ConvertI.h b/nx-X11/lib/Xt/ConvertI.h
new file mode 100644
index 000000000..02c0e5ca0
--- /dev/null
+++ b/nx-X11/lib/Xt/ConvertI.h
@@ -0,0 +1,96 @@
+/* $Xorg: ConvertI.h,v 1.4 2001/02/09 02:03:54 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/ConvertI.h,v 1.3 2001/12/14 19:56:09 dawes Exp $ */
+
+/* Representation types */
+
+extern XrmQuark _XtQString;
+
+/*
+ * Resource conversions
+ */
+
+typedef struct _ConverterRec **ConverterTable;
+
+extern void _XtAddDefaultConverters(
+ ConverterTable /* table */
+);
+
+extern void _XtSetDefaultConverterTable(
+ ConverterTable* /* table */
+);
+
+extern void _XtFreeConverterTable(
+ ConverterTable /* table */
+);
+
+extern void _XtTableAddConverter(
+ ConverterTable /* table */,
+ XrmRepresentation /* from_type */,
+ XrmRepresentation /* to_type */,
+ XtTypeConverter /* converter */,
+ XtConvertArgList /* convert_args */,
+ Cardinal /* num_args */,
+ _XtBoolean /* new_style */,
+ XtCacheType /* cache_type */,
+ XtDestructor /* destructor */,
+ _XtBoolean /* global */
+);
+
+extern Boolean _XtConvert(
+ Widget /* widget */,
+ XrmRepresentation /* from_type */,
+ XrmValuePtr /* from */,
+ XrmRepresentation /* to_type */,
+ XrmValuePtr /* to */,
+ XtCacheRef* /* cache_ref_return */
+);
+
+void _XtConvertInitialize(void);
+
diff --git a/nx-X11/lib/Xt/Converters.c b/nx-X11/lib/Xt/Converters.c
new file mode 100644
index 000000000..acb572e69
--- /dev/null
+++ b/nx-X11/lib/Xt/Converters.c
@@ -0,0 +1,1864 @@
+/* $Xorg: Converters.c,v 1.5 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/Converters.c,v 3.14tsi Exp $ */
+
+/*
+
+Copyright 1987, 1988, 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.
+
+*/
+
+/*LINTLIBRARY*/
+/* Conversion.c - implementations of resource type conversion procs */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+#include "Shell.h"
+#include <stdio.h>
+#include <X11/cursorfont.h>
+#include <X11/keysym.h>
+#include <X11/Xlocale.h>
+#include <errno.h> /* for StringToDirectoryString */
+
+#ifdef __UNIXOS2__
+#define IsNewline(str) ((str) == '\n' || (str) == '\r')
+#define IsWhitespace(str) ((str)== ' ' || (str) == '\t' || (str) == '\r')
+#else
+#define IsNewline(str) ((str) == '\n')
+#define IsWhitespace(str) ((str)== ' ' || (str) == '\t')
+#endif
+
+static const String XtNwrongParameters = "wrongParameters";
+static const String XtNconversionError = "conversionError";
+static const String XtNmissingCharsetList = "missingCharsetList";
+
+/* Representation types */
+
+#define XtQAtom XrmPermStringToQuark(XtRAtom)
+#define XtQCommandArgArray XrmPermStringToQuark(XtRCommandArgArray)
+#define XtQCursor XrmPermStringToQuark(XtRCursor)
+#define XtQDirectoryString XrmPermStringToQuark(XtRDirectoryString)
+#define XtQDisplay XrmPermStringToQuark(XtRDisplay)
+#define XtQFile XrmPermStringToQuark(XtRFile)
+#define XtQFloat XrmPermStringToQuark(XtRFloat)
+#define XtQInitialState XrmPermStringToQuark(XtRInitialState)
+#define XtQPixmap XrmPermStringToQuark(XtRPixmap)
+#define XtQRestartStyle XrmPermStringToQuark(XtRRestartStyle)
+#define XtQShort XrmPermStringToQuark(XtRShort)
+#define XtQUnsignedChar XrmPermStringToQuark(XtRUnsignedChar)
+#define XtQVisual XrmPermStringToQuark(XtRVisual)
+
+static XrmQuark XtQBool;
+static XrmQuark XtQBoolean;
+static XrmQuark XtQColor;
+static XrmQuark XtQDimension;
+static XrmQuark XtQFont;
+static XrmQuark XtQFontSet;
+static XrmQuark XtQFontStruct;
+static XrmQuark XtQGravity;
+static XrmQuark XtQInt;
+static XrmQuark XtQPixel;
+static XrmQuark XtQPosition;
+#ifdef __UNIXOS2__
+XrmQuark _XtQString = 0;
+#else
+XrmQuark _XtQString;
+#endif
+
+void _XtConvertInitialize(void)
+{
+ XtQBool = XrmPermStringToQuark(XtRBool);
+ XtQBoolean = XrmPermStringToQuark(XtRBoolean);
+ XtQColor = XrmPermStringToQuark(XtRColor);
+ XtQDimension = XrmPermStringToQuark(XtRDimension);
+ XtQFont = XrmPermStringToQuark(XtRFont);
+ XtQFontSet = XrmPermStringToQuark(XtRFontSet);
+ XtQFontStruct = XrmPermStringToQuark(XtRFontStruct);
+ XtQGravity = XrmPermStringToQuark(XtRGravity);
+ XtQInt = XrmPermStringToQuark(XtRInt);
+ XtQPixel = XrmPermStringToQuark(XtRPixel);
+ XtQPosition = XrmPermStringToQuark(XtRPosition);
+ _XtQString = XrmPermStringToQuark(XtRString);
+}
+
+#define donestr(type, value, tstr) \
+ { \
+ if (toVal->addr != NULL) { \
+ if (toVal->size < sizeof(type)) { \
+ toVal->size = sizeof(type); \
+ XtDisplayStringConversionWarning(dpy, \
+ (char*) fromVal->addr, tstr); \
+ return False; \
+ } \
+ *(type*)(toVal->addr) = (value); \
+ } \
+ else { \
+ static type static_val; \
+ static_val = (value); \
+ toVal->addr = (XPointer)&static_val; \
+ } \
+ toVal->size = sizeof(type); \
+ return True; \
+ }
+
+#define done(type, value) \
+ { \
+ if (toVal->addr != NULL) { \
+ if (toVal->size < sizeof(type)) { \
+ toVal->size = sizeof(type); \
+ return False; \
+ } \
+ *(type*)(toVal->addr) = (value); \
+ } \
+ else { \
+ static type static_val; \
+ static_val = (value); \
+ toVal->addr = (XPointer)&static_val; \
+ } \
+ toVal->size = sizeof(type); \
+ return True; \
+ }
+
+void XtDisplayStringConversionWarning(
+ Display* dpy,
+ _Xconst char* from,
+ _Xconst char* toType
+ )
+{
+#ifndef NO_MIT_HACKS
+ /* Allow suppression of conversion warnings. %%% Not specified. */
+
+ static enum {Check, Report, Ignore} report_it = Check;
+ XtAppContext app = XtDisplayToApplicationContext(dpy);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if (report_it == Check) {
+ XrmDatabase rdb = XtDatabase(dpy);
+ XrmName xrm_name[2];
+ XrmClass xrm_class[2];
+ XrmRepresentation rep_type;
+ XrmValue value;
+ xrm_name[0] = XrmPermStringToQuark( "stringConversionWarnings" );
+ xrm_name[1] = 0;
+ xrm_class[0] = XrmPermStringToQuark( "StringConversionWarnings" );
+ xrm_class[1] = 0;
+ if (XrmQGetResource( rdb, xrm_name, xrm_class,
+ &rep_type, &value ))
+ {
+ if (rep_type == XtQBoolean)
+ report_it = *(Boolean*)value.addr ? Report : Ignore;
+ else if (rep_type == _XtQString) {
+ XrmValue toVal;
+ Boolean report;
+ toVal.addr = (XPointer)&report;
+ toVal.size = sizeof(Boolean);
+ if (XtCallConverter(dpy, XtCvtStringToBoolean, (XrmValuePtr)NULL,
+ (Cardinal)0, &value, &toVal,
+ (XtCacheRef*)NULL))
+ report_it = report ? Report : Ignore;
+ }
+ else report_it = Report;
+ }
+ else report_it = Report;
+ }
+
+ if (report_it == Report) {
+#endif /* ifndef NO_MIT_HACKS */
+ String params[2];
+ Cardinal num_params = 2;
+ params[0] = (String)from;
+ params[1] = (String)toType;
+ XtAppWarningMsg(app,
+ XtNconversionError,"string",XtCXtToolkitError,
+ "Cannot convert string \"%s\" to type %s",
+ params,&num_params);
+#ifndef NO_MIT_HACKS
+ }
+#endif /* ifndef NO_MIT_HACKS */
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+void XtStringConversionWarning(
+ _Xconst char* from,
+ _Xconst char* toType
+ )
+{
+ String params[2];
+ Cardinal num_params = 2;
+ params[0] = (String)from;
+ params[1] = (String)toType;
+ XtWarningMsg(XtNconversionError,"string",XtCXtToolkitError,
+ "Cannot convert string \"%s\" to type %s",
+ params,&num_params);
+}
+
+static int CompareISOLatin1(char *, char *);
+
+
+static Boolean IsInteger(
+ String string,
+ int *value)
+{
+ Boolean foundDigit = False;
+ Boolean isNegative = False;
+ Boolean isPositive = False;
+ int val = 0;
+ char ch;
+ /* skip leading whitespace */
+#ifndef __UNIXOS2__
+ while ((ch = *string) == ' ' || ch == '\t') string++;
+#else
+ while ((ch = *string) == ' ' || ch == '\t' || ch == '\r') string++;
+#endif
+ while ((ch = *string++)) {
+ if (ch >= '0' && ch <= '9') {
+ val *= 10;
+ val += ch - '0';
+ foundDigit = True;
+ continue;
+ }
+ if (IsWhitespace(ch)) {
+ if (!foundDigit) return False;
+ /* make sure only trailing whitespace */
+ while ((ch = *string++)) {
+ if (!IsWhitespace(ch))
+ return False;
+ }
+ break;
+ }
+ if (ch == '-' && !foundDigit && !isNegative && !isPositive) {
+ isNegative = True;
+ continue;
+ }
+ if (ch == '+' && !foundDigit && !isNegative && !isPositive) {
+ isPositive = True;
+ continue;
+ }
+ return False;
+ }
+ if (ch == '\0') {
+ if (isNegative)
+ *value = -val;
+ else
+ *value = val;
+ return True;
+ }
+ return False;
+}
+
+
+/*ARGSUSED*/
+Boolean XtCvtIntToBoolean(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtIntToBoolean",XtCXtToolkitError,
+ "Integer to Boolean conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ done(Boolean, (*(int *)fromVal->addr != 0));
+}
+
+
+/*ARGSUSED*/
+Boolean XtCvtIntToShort(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtIntToShort",XtCXtToolkitError,
+ "Integer to Short conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ done(short, (*(int *)fromVal->addr));
+}
+
+
+/*ARGSUSED*/
+Boolean XtCvtStringToBoolean(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ String str = (String)fromVal->addr;
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToBoolean",XtCXtToolkitError,
+ "String to Boolean conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if ( (CompareISOLatin1(str, "true") == 0)
+ || (CompareISOLatin1(str, "yes") == 0)
+ || (CompareISOLatin1(str, "on") == 0)
+ || (CompareISOLatin1(str, "1") == 0)) donestr( Boolean, True, XtRBoolean );
+
+ if ( (CompareISOLatin1(str, "false") == 0)
+ || (CompareISOLatin1(str, "no") == 0)
+ || (CompareISOLatin1(str, "off") == 0)
+ || (CompareISOLatin1(str, "0") == 0)) donestr( Boolean, False, XtRBoolean );
+
+ XtDisplayStringConversionWarning(dpy, str, XtRBoolean);
+ return False;
+}
+
+
+/*ARGSUSED*/
+Boolean XtCvtIntToBool(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtIntToBool",XtCXtToolkitError,
+ "Integer to Bool conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ done(Bool, (*(int *)fromVal->addr != 0));
+}
+
+
+/*ARGSUSED*/
+Boolean XtCvtStringToBool(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ String str = (String)fromVal->addr;
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToBool",
+ XtCXtToolkitError,
+ "String to Bool conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if ( (CompareISOLatin1(str, "true") == 0)
+ || (CompareISOLatin1(str, "yes") == 0)
+ || (CompareISOLatin1(str, "on") == 0)
+ || (CompareISOLatin1(str, "1") == 0)) donestr( Bool, True, XtRBool );
+
+ if ( (CompareISOLatin1(str, "false") == 0)
+ || (CompareISOLatin1(str, "no") == 0)
+ || (CompareISOLatin1(str, "off") == 0)
+ || (CompareISOLatin1(str, "0") == 0)) donestr( Bool, False, XtRBool );
+
+ XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRBool);
+ return False;
+}
+
+XtConvertArgRec const colorConvertArgs[] = {
+ {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.screen),
+ sizeof(Screen *)},
+ {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.colormap),
+ sizeof(Colormap)}
+};
+
+
+/* ARGSUSED */
+Boolean XtCvtIntToColor(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ XColor c;
+ Screen *screen;
+ Colormap colormap;
+
+ if (*num_args != 2) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtIntOrPixelToXColor",XtCXtToolkitError,
+ "Pixel to color conversion needs screen and colormap arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ return False;
+ }
+ screen = *((Screen **) args[0].addr);
+ colormap = *((Colormap *) args[1].addr);
+ c.pixel = *(int *)fromVal->addr;
+
+ XQueryColor(DisplayOfScreen(screen), colormap, &c);
+ done(XColor, c);
+}
+
+
+Boolean XtCvtStringToPixel(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ String str = (String)fromVal->addr;
+ XColor screenColor;
+ XColor exactColor;
+ Screen *screen;
+ XtPerDisplay pd = _XtGetPerDisplay(dpy);
+ Colormap colormap;
+ Status status;
+ String params[1];
+ Cardinal num_params=1;
+
+ if (*num_args != 2) {
+ XtAppWarningMsg(pd->appContext, XtNwrongParameters, "cvtStringToPixel",
+ XtCXtToolkitError,
+ "String to pixel conversion needs screen and colormap arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ return False;
+ }
+
+ screen = *((Screen **) args[0].addr);
+ colormap = *((Colormap *) args[1].addr);
+
+ if (CompareISOLatin1(str, XtDefaultBackground) == 0) {
+ *closure_ret = False;
+ if (pd->rv) donestr(Pixel, BlackPixelOfScreen(screen), XtRPixel)
+ else donestr(Pixel, WhitePixelOfScreen(screen), XtRPixel);
+ }
+ if (CompareISOLatin1(str, XtDefaultForeground) == 0) {
+ *closure_ret = False;
+ if (pd->rv) donestr(Pixel, WhitePixelOfScreen(screen), XtRPixel)
+ else donestr(Pixel, BlackPixelOfScreen(screen), XtRPixel);
+ }
+
+ status = XAllocNamedColor(DisplayOfScreen(screen), colormap,
+ (char*)str, &screenColor, &exactColor);
+ if (status == 0) {
+ String msg, type;
+ params[0] = str;
+ /* Server returns a specific error code but Xlib discards it. Ugh */
+ if (XLookupColor(DisplayOfScreen(screen), colormap, (char*)str,
+ &exactColor, &screenColor)) {
+ type = "noColormap";
+ msg = "Cannot allocate colormap entry for \"%s\"";
+ }
+ else {
+ type = "badValue";
+ msg = "Color name \"%s\" is not defined";
+ }
+
+ XtAppWarningMsg(pd->appContext, type, "cvtStringToPixel",
+ XtCXtToolkitError, msg, params, &num_params);
+ *closure_ret = False;
+ return False;
+ } else {
+ *closure_ret = (char*)True;
+ donestr(Pixel, screenColor.pixel, XtRPixel);
+ }
+}
+
+/* ARGSUSED */
+static void FreePixel(
+ XtAppContext app,
+ XrmValuePtr toVal,
+ XtPointer closure,
+ XrmValuePtr args,
+ Cardinal *num_args)
+{
+ Screen *screen;
+ Colormap colormap;
+
+ if (*num_args != 2) {
+ XtAppWarningMsg(app, XtNwrongParameters,"freePixel",XtCXtToolkitError,
+ "Freeing a pixel requires screen and colormap arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ return;
+ }
+
+ screen = *((Screen **) args[0].addr);
+ colormap = *((Colormap *) args[1].addr);
+
+ if (closure) {
+ XFreeColors( DisplayOfScreen(screen), colormap,
+ (unsigned long*)toVal->addr, 1, (unsigned long)0
+ );
+ }
+}
+
+
+/* no longer used by Xt, but it's in the spec */
+XtConvertArgRec const screenConvertArg[] = {
+ {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.screen),
+ sizeof(Screen *)}
+};
+
+/*ARGSUSED*/
+static void FetchDisplayArg(
+ Widget widget,
+ Cardinal *size,
+ XrmValue* value)
+{
+ if (widget == NULL)
+ XtErrorMsg("missingWidget", "fetchDisplayArg", XtCXtToolkitError,
+ "FetchDisplayArg called without a widget to reference",
+ (String*)NULL, (Cardinal*)NULL);
+ /* can't return any useful Display and caller will de-ref NULL,
+ so aborting is the only useful option */
+
+ value->size = sizeof(Display*);
+ value->addr = (XPointer)&DisplayOfScreen(XtScreenOfObject(widget));
+}
+
+static XtConvertArgRec const displayConvertArg[] = {
+ {XtProcedureArg, (XtPointer)FetchDisplayArg, 0},
+};
+
+/*ARGSUSED*/
+Boolean XtCvtStringToCursor(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ static const struct _CursorName {
+ const char *name;
+ unsigned int shape;
+ } cursor_names[] = {
+ {"X_cursor", XC_X_cursor},
+ {"arrow", XC_arrow},
+ {"based_arrow_down", XC_based_arrow_down},
+ {"based_arrow_up", XC_based_arrow_up},
+ {"boat", XC_boat},
+ {"bogosity", XC_bogosity},
+ {"bottom_left_corner", XC_bottom_left_corner},
+ {"bottom_right_corner", XC_bottom_right_corner},
+ {"bottom_side", XC_bottom_side},
+ {"bottom_tee", XC_bottom_tee},
+ {"box_spiral", XC_box_spiral},
+ {"center_ptr", XC_center_ptr},
+ {"circle", XC_circle},
+ {"clock", XC_clock},
+ {"coffee_mug", XC_coffee_mug},
+ {"cross", XC_cross},
+ {"cross_reverse", XC_cross_reverse},
+ {"crosshair", XC_crosshair},
+ {"diamond_cross", XC_diamond_cross},
+ {"dot", XC_dot},
+ {"dotbox", XC_dotbox},
+ {"double_arrow", XC_double_arrow},
+ {"draft_large", XC_draft_large},
+ {"draft_small", XC_draft_small},
+ {"draped_box", XC_draped_box},
+ {"exchange", XC_exchange},
+ {"fleur", XC_fleur},
+ {"gobbler", XC_gobbler},
+ {"gumby", XC_gumby},
+ {"hand1", XC_hand1},
+ {"hand2", XC_hand2},
+ {"heart", XC_heart},
+ {"icon", XC_icon},
+ {"iron_cross", XC_iron_cross},
+ {"left_ptr", XC_left_ptr},
+ {"left_side", XC_left_side},
+ {"left_tee", XC_left_tee},
+ {"leftbutton", XC_leftbutton},
+ {"ll_angle", XC_ll_angle},
+ {"lr_angle", XC_lr_angle},
+ {"man", XC_man},
+ {"middlebutton", XC_middlebutton},
+ {"mouse", XC_mouse},
+ {"pencil", XC_pencil},
+ {"pirate", XC_pirate},
+ {"plus", XC_plus},
+ {"question_arrow", XC_question_arrow},
+ {"right_ptr", XC_right_ptr},
+ {"right_side", XC_right_side},
+ {"right_tee", XC_right_tee},
+ {"rightbutton", XC_rightbutton},
+ {"rtl_logo", XC_rtl_logo},
+ {"sailboat", XC_sailboat},
+ {"sb_down_arrow", XC_sb_down_arrow},
+ {"sb_h_double_arrow", XC_sb_h_double_arrow},
+ {"sb_left_arrow", XC_sb_left_arrow},
+ {"sb_right_arrow", XC_sb_right_arrow},
+ {"sb_up_arrow", XC_sb_up_arrow},
+ {"sb_v_double_arrow", XC_sb_v_double_arrow},
+ {"shuttle", XC_shuttle},
+ {"sizing", XC_sizing},
+ {"spider", XC_spider},
+ {"spraycan", XC_spraycan},
+ {"star", XC_star},
+ {"target", XC_target},
+ {"tcross", XC_tcross},
+ {"top_left_arrow", XC_top_left_arrow},
+ {"top_left_corner", XC_top_left_corner},
+ {"top_right_corner", XC_top_right_corner},
+ {"top_side", XC_top_side},
+ {"top_tee", XC_top_tee},
+ {"trek", XC_trek},
+ {"ul_angle", XC_ul_angle},
+ {"umbrella", XC_umbrella},
+ {"ur_angle", XC_ur_angle},
+ {"watch", XC_watch},
+ {"xterm", XC_xterm},
+ };
+ const struct _CursorName *nP;
+ char *name = (char *)fromVal->addr;
+ register Cardinal i;
+
+ if (*num_args != 1) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToCursor",XtCXtToolkitError,
+ "String to cursor conversion needs display argument",
+ (String *)NULL, (Cardinal *)NULL);
+ return False;
+ }
+
+ for (i=0, nP=cursor_names; i < XtNumber(cursor_names); i++, nP++ ) {
+ if (strcmp(name, nP->name) == 0) {
+ Display *display = *(Display**)args[0].addr;
+ Cursor cursor = XCreateFontCursor(display, nP->shape );
+ donestr(Cursor, cursor, XtRCursor);
+ }
+ }
+ XtDisplayStringConversionWarning(dpy, name, XtRCursor);
+ return False;
+}
+
+/* ARGSUSED */
+static void FreeCursor(
+ XtAppContext app,
+ XrmValuePtr toVal,
+ XtPointer closure, /* unused */
+ XrmValuePtr args,
+ Cardinal *num_args)
+{
+ Display* display;
+
+ if (*num_args != 1) {
+ XtAppWarningMsg(app,
+ XtNwrongParameters,"freeCursor",XtCXtToolkitError,
+ "Free Cursor requires display argument",
+ (String *)NULL, (Cardinal *)NULL);
+ return;
+ }
+
+ display = *(Display**)args[0].addr;
+ XFreeCursor( display, *(Cursor*)toVal->addr );
+}
+
+/*ARGSUSED*/
+Boolean XtCvtStringToDisplay(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ Display *d;
+
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToDisplay",XtCXtToolkitError,
+ "String to Display conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+
+ d = XOpenDisplay((char *)fromVal->addr);
+ if (d != NULL)
+ donestr(Display*, d, XtRDisplay);
+
+ XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRDisplay);
+ return False;
+}
+
+
+/*ARGSUSED*/
+Boolean XtCvtStringToFile(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ FILE *f;
+
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToFile",XtCXtToolkitError,
+ "String to File conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+
+ f = fopen((char *)fromVal->addr, "r");
+ if (f != NULL)
+ donestr(FILE*, f, XtRFile);
+
+ XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRFile);
+ return False;
+}
+
+/* ARGSUSED */
+static void FreeFile(
+ XtAppContext app,
+ XrmValuePtr toVal,
+ XtPointer closure, /* unused */
+ XrmValuePtr args, /* unused */
+ Cardinal *num_args)
+{
+ if (*num_args != 0)
+ XtAppWarningMsg(app,
+ XtNwrongParameters,"freeFile",XtCXtToolkitError,
+ "Free File requires no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+
+ fclose( *(FILE**)toVal->addr );
+}
+
+/*ARGSUSED*/
+Boolean XtCvtIntToFloat(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtIntToFloat",XtCXtToolkitError,
+ "Integer to Float conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ done(float, (*(int *)fromVal->addr));
+}
+
+/*ARGSUSED*/
+Boolean XtCvtStringToFloat(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ int ret;
+ float f, nan;
+
+#ifndef ISC /* On ISC this generates a core dump :-( at least with gs */
+ /* depending on the system this may or may not do anything useful */
+ (void) sscanf ("NaNS", "%g",
+ toVal->addr != NULL ? (float*) toVal->addr : &nan);
+#endif
+
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToFloat",XtCXtToolkitError,
+ "String to Float conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+
+ ret = sscanf (fromVal->addr, "%g", &f);
+ if (ret == 0) {
+ if (toVal->addr != NULL && toVal->size == sizeof nan)
+ *(float*)toVal->addr = nan;
+ XtDisplayStringConversionWarning (dpy, (char*) fromVal->addr, XtRFloat);
+ return False;
+ }
+ donestr(float, f, XtRFloat);
+}
+
+/*ARGSUSED*/
+Boolean XtCvtStringToFont(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ Font f;
+ Display* display;
+
+ if (*num_args != 1) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToFont",XtCXtToolkitError,
+ "String to font conversion needs display argument",
+ (String *) NULL, (Cardinal *)NULL);
+ return False;
+ }
+
+ display = *(Display**)args[0].addr;
+
+ if (CompareISOLatin1((String)fromVal->addr, XtDefaultFont) != 0) {
+ f = XLoadFont(display, (char *)fromVal->addr);
+ if (f != 0) {
+ Done: donestr( Font, f, XtRFont );
+ }
+ XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRFont);
+ }
+ /* try and get the default font */
+
+ {
+ XrmName xrm_name[2];
+ XrmClass xrm_class[2];
+ XrmRepresentation rep_type;
+ XrmValue value;
+
+ xrm_name[0] = XrmPermStringToQuark ("xtDefaultFont");
+ xrm_name[1] = 0;
+ xrm_class[0] = XrmPermStringToQuark ("XtDefaultFont");
+ xrm_class[1] = 0;
+ if (XrmQGetResource(XtDatabase(display), xrm_name, xrm_class,
+ &rep_type, &value)) {
+ if (rep_type == _XtQString) {
+ f = XLoadFont(display, (char *)value.addr);
+ if (f != 0)
+ goto Done;
+ else
+ XtDisplayStringConversionWarning(dpy, (char *)value.addr,
+ XtRFont);
+ } else if (rep_type == XtQFont) {
+ f = *(Font*)value.addr;
+ goto Done;
+ } else if (rep_type == XtQFontStruct) {
+ f = ((XFontStruct*)value.addr)->fid;
+ goto Done;
+ }
+ }
+ }
+ /* Should really do XListFonts, but most servers support this */
+ f = XLoadFont(display, "-*-*-*-R-*-*-*-120-*-*-*-*-ISO8859-*");
+ if (f != 0)
+ goto Done;
+
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "noFont","cvtStringToFont",XtCXtToolkitError,
+ "Unable to load any usable ISO8859 font",
+ (String *) NULL, (Cardinal *)NULL);
+
+ return False;
+}
+
+/* ARGSUSED */
+static void FreeFont(
+ XtAppContext app,
+ XrmValuePtr toVal,
+ XtPointer closure, /* unused */
+ XrmValuePtr args,
+ Cardinal *num_args)
+{
+ Display *display;
+ if (*num_args != 1) {
+ XtAppWarningMsg(app,
+ XtNwrongParameters,"freeFont",XtCXtToolkitError,
+ "Free Font needs display argument",
+ (String *) NULL, (Cardinal *)NULL);
+ return;
+ }
+
+ display = *(Display**)args[0].addr;
+ XUnloadFont( display, *(Font*)toVal->addr );
+}
+
+/*ARGSUSED*/
+Boolean XtCvtIntToFont(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtIntToFont",XtCXtToolkitError,
+ "Integer to Font conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+ done(Font, *(int*)fromVal->addr);
+}
+
+/*ARGSUSED*/
+Boolean XtCvtStringToFontSet(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ XFontSet f;
+ Display* display;
+ char** missing_charset_list;
+ int missing_charset_count;
+ char* def_string;
+
+ if (*num_args != 2) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToFontSet",XtCXtToolkitError,
+ "String to FontSet conversion needs display and locale arguments",
+ (String *) NULL, (Cardinal *)NULL);
+ return False;
+ }
+
+ display = *(Display**)args[0].addr;
+
+ if (CompareISOLatin1((String)fromVal->addr, XtDefaultFontSet) != 0) {
+ f = XCreateFontSet(display, (char *)fromVal->addr,
+ &missing_charset_list, &missing_charset_count, &def_string);
+ /* Free any returned missing charset list */
+ if (missing_charset_count) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNmissingCharsetList,"cvtStringToFontSet",XtCXtToolkitError,
+ "Missing charsets in String to FontSet conversion",
+ (String *) NULL, (Cardinal *)NULL);
+ XFreeStringList(missing_charset_list);
+ }
+ if (f != NULL) {
+ Done: donestr( XFontSet, f, XtRFontSet );
+ }
+ XtDisplayStringConversionWarning(dpy, (char *)fromVal->addr, XtRFontSet);
+ }
+ /* try and get the default fontset */
+
+ {
+ XrmName xrm_name[2];
+ XrmClass xrm_class[2];
+ XrmRepresentation rep_type;
+ XrmValue value;
+
+ xrm_name[0] = XrmPermStringToQuark ("xtDefaultFontSet");
+ xrm_name[1] = 0;
+ xrm_class[0] = XrmPermStringToQuark ("XtDefaultFontSet");
+ xrm_class[1] = 0;
+ if (XrmQGetResource(XtDatabase(display), xrm_name, xrm_class,
+ &rep_type, &value)) {
+ if (rep_type == _XtQString) {
+
+ f = XCreateFontSet(display, (char *)value.addr,
+ &missing_charset_list, &missing_charset_count,
+ &def_string);
+ /* Free any returned missing charset list */
+ if (missing_charset_count) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNmissingCharsetList,"cvtStringToFontSet",
+ XtCXtToolkitError,
+ "Missing charsets in String to FontSet conversion",
+ (String *) NULL, (Cardinal *)NULL);
+ XFreeStringList(missing_charset_list);
+ }
+ if (f != NULL)
+ goto Done;
+ else
+ XtDisplayStringConversionWarning(dpy, (char *)value.addr,
+ XtRFontSet);
+ } else if (rep_type == XtQFontSet) {
+ f = *(XFontSet*)value.addr;
+ goto Done;
+ }
+ }
+ }
+
+ /* Should really do XListFonts, but most servers support this */
+ f = XCreateFontSet(display, "-*-*-*-R-*-*-*-120-*-*-*-*,*",
+ &missing_charset_list, &missing_charset_count, &def_string);
+
+ /* Free any returned missing charset list */
+ if (missing_charset_count) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNmissingCharsetList,"cvtStringToFontSet",XtCXtToolkitError,
+ "Missing charsets in String to FontSet conversion",
+ (String *) NULL, (Cardinal *)NULL);
+ XFreeStringList(missing_charset_list);
+ }
+ if (f != NULL)
+ goto Done;
+
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "noFont","cvtStringToFontSet",XtCXtToolkitError,
+ "Unable to load any usable fontset",
+ (String *) NULL, (Cardinal *)NULL);
+
+ return False;
+}
+
+/*ARGSUSED*/
+static void FreeFontSet(
+ XtAppContext app,
+ XrmValuePtr toVal,
+ XtPointer closure, /* unused */
+ XrmValuePtr args,
+ Cardinal *num_args)
+{
+ Display *display;
+ if (*num_args != 2) {
+ XtAppWarningMsg(app,
+ XtNwrongParameters,"freeFontSet",XtCXtToolkitError,
+ "FreeFontSet needs display and locale arguments",
+ (String *) NULL, (Cardinal *)NULL);
+ return;
+ }
+
+ display = *(Display**)args[0].addr;
+ XFreeFontSet( display, *(XFontSet*)toVal->addr );
+}
+
+/*ARGSUSED*/
+static void FetchLocaleArg(
+ Widget widget, /* unused */
+ Cardinal *size, /* unused */
+ XrmValue *value)
+{
+ static XrmString locale;
+
+ locale = XrmQuarkToString(XrmStringToQuark
+ (setlocale(LC_CTYPE, (char*)NULL)));
+ value->size = sizeof(XrmString);
+ value->addr = (XPointer)&locale;
+}
+
+static XtConvertArgRec const localeDisplayConvertArgs[] = {
+ {XtProcedureArg, (XtPointer)FetchDisplayArg, 0},
+ {XtProcedureArg, (XtPointer)FetchLocaleArg, 0},
+};
+
+
+/*ARGSUSED*/
+Boolean
+XtCvtStringToFontStruct(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ XFontStruct *f;
+ Display* display;
+
+ if (*num_args != 1) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToFontStruct",XtCXtToolkitError,
+ "String to font conversion needs display argument",
+ (String *) NULL, (Cardinal *)NULL);
+ return False;
+ }
+
+ display = *(Display**)args[0].addr;
+
+ if (CompareISOLatin1((String)fromVal->addr, XtDefaultFont) != 0) {
+ f = XLoadQueryFont(display, (char *)fromVal->addr);
+ if (f != NULL) {
+ Done: donestr( XFontStruct*, f, XtRFontStruct);
+ }
+
+ XtDisplayStringConversionWarning(dpy, (char*)fromVal->addr,
+ XtRFontStruct);
+ }
+
+ /* try and get the default font */
+
+ {
+ XrmName xrm_name[2];
+ XrmClass xrm_class[2];
+ XrmRepresentation rep_type;
+ XrmValue value;
+
+ xrm_name[0] = XrmPermStringToQuark ("xtDefaultFont");
+ xrm_name[1] = 0;
+ xrm_class[0] = XrmPermStringToQuark ("XtDefaultFont");
+ xrm_class[1] = 0;
+ if (XrmQGetResource(XtDatabase(display), xrm_name, xrm_class,
+ &rep_type, &value)) {
+ if (rep_type == _XtQString) {
+ f = XLoadQueryFont(display, (char*)value.addr);
+ if (f != NULL)
+ goto Done;
+ else
+ XtDisplayStringConversionWarning(dpy, (char*)value.addr,
+ XtRFontStruct);
+ } else if (rep_type == XtQFont) {
+ f = XQueryFont(display, *(Font*)value.addr );
+ if (f != NULL) goto Done;
+ } else if (rep_type == XtQFontStruct) {
+ f = (XFontStruct*)value.addr;
+ goto Done;
+ }
+ }
+ }
+ /* Should really do XListFonts, but most servers support this */
+ f = XLoadQueryFont(display, "-*-*-*-R-*-*-*-120-*-*-*-*-ISO8859-*");
+ if (f != NULL)
+ goto Done;
+
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "noFont","cvtStringToFontStruct",XtCXtToolkitError,
+ "Unable to load any usable ISO8859 font",
+ (String *) NULL, (Cardinal *)NULL);
+
+ return False;
+}
+
+/* ARGSUSED */
+static void FreeFontStruct(
+ XtAppContext app,
+ XrmValuePtr toVal,
+ XtPointer closure, /* unused */
+ XrmValuePtr args,
+ Cardinal *num_args)
+{
+ Display *display;
+ if (*num_args != 1) {
+ XtAppWarningMsg(app,
+ XtNwrongParameters,"freeFontStruct",XtCXtToolkitError,
+ "Free FontStruct requires display argument",
+ (String *) NULL, (Cardinal *)NULL);
+ return;
+ }
+
+ display = *(Display**)args[0].addr;
+ XFreeFont( display, *(XFontStruct**)toVal->addr );
+}
+
+/*ARGSUSED*/
+Boolean XtCvtStringToInt(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ int i;
+
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToInt",XtCXtToolkitError,
+ "String to Integer conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+ if (IsInteger((String)fromVal->addr, &i))
+ donestr(int, i, XtRInt);
+
+ XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRInt);
+ return False;
+}
+
+/*ARGSUSED*/
+Boolean XtCvtStringToShort(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ int i;
+
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToShort",XtCXtToolkitError,
+ "String to Integer conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+ if (IsInteger((String)fromVal->addr, &i))
+ donestr(short, (short)i, XtRShort);
+
+ XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRShort);
+ return False;
+}
+
+/*ARGSUSED*/
+Boolean XtCvtStringToDimension(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ int i;
+
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToDimension",XtCXtToolkitError,
+ "String to Dimension conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+ if (IsInteger((String)fromVal->addr, &i)) {
+ if ( i < 0 )
+ XtDisplayStringConversionWarning(dpy, (char*)fromVal->addr,
+ XtRDimension);
+ donestr(Dimension, (Dimension)i, XtRDimension);
+ }
+ XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRDimension);
+ return False;
+}
+
+/*ARGSUSED*/
+Boolean XtCvtIntToUnsignedChar(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtIntToUnsignedChar",XtCXtToolkitError,
+ "Integer to UnsignedChar conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ done(unsigned char, (*(int *)fromVal->addr));
+}
+
+
+/*ARGSUSED*/
+Boolean XtCvtStringToUnsignedChar(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ int i;
+
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToUnsignedChar",XtCXtToolkitError,
+ "String to Integer conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+ if (IsInteger((String)fromVal->addr, &i)) {
+ if ( i < 0 || i > 255 )
+ XtDisplayStringConversionWarning(dpy, (char*)fromVal->addr,
+ XtRUnsignedChar);
+ donestr(unsigned char, i, XtRUnsignedChar);
+ }
+ XtDisplayStringConversionWarning(dpy, (char*)fromVal->addr,
+ XtRUnsignedChar);
+ return False;
+}
+
+
+/*ARGSUSED*/
+Boolean XtCvtColorToPixel(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtXColorToPixel",XtCXtToolkitError,
+ "Color to Pixel conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+ done(Pixel, ((XColor *)fromVal->addr)->pixel);
+}
+
+/*ARGSUSED*/
+Boolean XtCvtIntToPixel(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtIntToPixel",XtCXtToolkitError,
+ "Integer to Pixel conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+ done(Pixel, *(int*)fromVal->addr);
+}
+
+/*ARGSUSED*/
+Boolean XtCvtIntToPixmap(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtIntToPixmap",XtCXtToolkitError,
+ "Integer to Pixmap conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+ done(Pixmap, *(Pixmap*)fromVal->addr);
+}
+
+#ifdef MOTIFBC
+void LowerCase(register char *source, register *dest)
+{
+ register char ch;
+ int i;
+
+ for (i = 0; (ch = *source) != 0 && i < 999; source++, dest++, i++) {
+ if ('A' <= ch && ch <= 'Z')
+ *dest = ch - 'A' + 'a';
+ else
+ *dest = ch;
+ }
+ *dest = 0;
+}
+#endif
+
+static int CompareISOLatin1 (char *first, char *second)
+{
+ register unsigned char *ap, *bp;
+
+ for (ap = (unsigned char *) first, bp = (unsigned char *) second;
+ *ap && *bp; ap++, bp++) {
+ register unsigned char a, b;
+
+ if ((a = *ap) != (b = *bp)) {
+ /* try lowercasing and try again */
+
+ if ((a >= XK_A) && (a <= XK_Z))
+ a += (XK_a - XK_A);
+ else if ((a >= XK_Agrave) && (a <= XK_Odiaeresis))
+ a += (XK_agrave - XK_Agrave);
+ else if ((a >= XK_Ooblique) && (a <= XK_Thorn))
+ a += (XK_oslash - XK_Ooblique);
+
+ if ((b >= XK_A) && (b <= XK_Z))
+ b += (XK_a - XK_A);
+ else if ((b >= XK_Agrave) && (b <= XK_Odiaeresis))
+ b += (XK_agrave - XK_Agrave);
+ else if ((b >= XK_Ooblique) && (b <= XK_Thorn))
+ b += (XK_oslash - XK_Ooblique);
+
+ if (a != b) break;
+ }
+ }
+ return (((int) *bp) - ((int) *ap));
+}
+
+static void CopyISOLatin1Lowered(char *dst, char *src)
+{
+ unsigned char *dest, *source;
+
+ dest = (unsigned char *) dst; source = (unsigned char *) src;
+
+ for ( ; *source; source++, dest++) {
+ if (*source >= XK_A && *source <= XK_Z)
+ *dest = *source + (XK_a - XK_A);
+ else if (*source >= XK_Agrave && *source <= XK_Odiaeresis)
+ *dest = *source + (XK_agrave - XK_Agrave);
+ else if (*source >= XK_Ooblique && *source <= XK_Thorn)
+ *dest = *source + (XK_oslash - XK_Ooblique);
+ else
+ *dest = *source;
+ }
+ *dest = '\0';
+}
+
+/*ARGSUSED*/
+Boolean
+XtCvtStringToInitialState(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ String str = (String)fromVal->addr;
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToInitialState",XtCXtToolkitError,
+ "String to InitialState conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+
+ if (CompareISOLatin1(str, "NormalState") == 0) donestr(int, NormalState, XtRInitialState);
+ if (CompareISOLatin1(str, "IconicState") == 0) donestr(int, IconicState, XtRInitialState);
+ {
+ int val;
+ if (IsInteger(str, &val)) donestr( int, val, XtRInitialState );
+ }
+ XtDisplayStringConversionWarning(dpy, str, XtRInitialState);
+ return False;
+}
+
+static XtConvertArgRec const visualConvertArgs[] = {
+ {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.screen),
+ sizeof(Screen *)},
+ {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.depth),
+ sizeof(Cardinal)}
+};
+
+/*ARGSUSED*/
+Boolean XtCvtStringToVisual(
+ Display* dpy,
+ XrmValuePtr args, /* Screen, depth */
+ Cardinal *num_args, /* 2 */
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret) /* unused */
+{
+ String str = (String)fromVal->addr;
+ int vc;
+ XVisualInfo vinfo;
+ if (*num_args != 2) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToVisual",XtCXtToolkitError,
+ "String to Visual conversion needs screen and depth arguments",
+ (String *) NULL, (Cardinal *)NULL);
+ return False;
+ }
+
+ if (CompareISOLatin1(str, "StaticGray") == 0) vc = StaticGray;
+ else if (CompareISOLatin1(str, "StaticColor") == 0) vc = StaticColor;
+ else if (CompareISOLatin1(str, "TrueColor") == 0) vc = TrueColor;
+ else if (CompareISOLatin1(str, "GrayScale") == 0) vc = GrayScale;
+ else if (CompareISOLatin1(str, "PseudoColor") == 0) vc = PseudoColor;
+ else if (CompareISOLatin1(str, "DirectColor") == 0) vc = DirectColor;
+ else if (!IsInteger(str, &vc)) {
+ XtDisplayStringConversionWarning(dpy, str, "Visual class name");
+ return False;
+ }
+
+ if (XMatchVisualInfo( XDisplayOfScreen((Screen*)*(Screen**)args[0].addr),
+ XScreenNumberOfScreen((Screen*)*(Screen**)args[0].addr),
+ (int)*(int*)args[1].addr,
+ vc,
+ &vinfo) ) {
+ donestr( Visual*, vinfo.visual, XtRVisual );
+ }
+ else {
+ String params[2];
+ Cardinal num_params = 2;
+ params[0] = str;
+ params[1] =
+ DisplayString(XDisplayOfScreen((Screen*)*(Screen**)args[0].addr));
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNconversionError, "stringToVisual", XtCXtToolkitError,
+ "Cannot find Visual of class %s for display %s",
+ params, &num_params );
+ return False;
+ }
+}
+
+
+/*ARGSUSED*/
+Boolean XtCvtStringToAtom(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ Atom atom;
+ if (*num_args != 1) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToAtom",XtCXtToolkitError,
+ "String to Atom conversion needs Display argument",
+ (String *) NULL, (Cardinal *)NULL);
+ return False;
+ }
+
+ atom = XInternAtom( *(Display**)args->addr, (char*)fromVal->addr, False );
+ donestr(Atom, atom, XtRAtom);
+}
+
+/*ARGSUSED*/
+Boolean XtCvtStringToDirectoryString(
+ Display *dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ String str;
+ char directory[PATH_MAX+1];
+
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToDirectoryString",XtCXtToolkitError,
+ "String to DirectoryString conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+
+ str = (String)fromVal->addr;
+ if (CompareISOLatin1(str, "XtCurrentDirectory") == 0) {
+ /* uglier, but does not depend on compiler knowing return type */
+#if !defined(X_NOT_POSIX) || defined(SYSV) || defined(WIN32)
+ if (getcwd(directory, PATH_MAX + 1))
+ str = directory;
+#else
+ if (getwd(directory))
+ str = directory;
+#endif
+ if (!str) {
+ if (errno == EACCES)
+ errno = 0; /* reset errno */
+ XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr,
+ XtRDirectoryString);
+ return False;
+ }
+ }
+
+ /* Since memory from the resource database or from static buffers of
+ * system libraries may be freed or overwritten, allocate memory.
+ * The memory is freed when all cache references are released.
+ */
+ str = XtNewString(str);
+ donestr(String, str, XtRDirectoryString);
+}
+
+/*ARGSUSED*/
+static void FreeDirectoryString(
+ XtAppContext app,
+ XrmValuePtr toVal,
+ XtPointer closure, /* unused */
+ XrmValuePtr args,
+ Cardinal *num_args)
+{
+ if (*num_args != 0)
+ XtAppWarningMsg(app,
+ XtNwrongParameters,"freeDirectoryString",XtCXtToolkitError,
+ "Free Directory String requires no extra arguments",
+ (String *) NULL, (Cardinal *) NULL);
+
+ XtFree((char *) toVal->addr);
+}
+
+/*ARGSUSED*/
+Boolean XtCvtStringToRestartStyle(
+ Display *dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ String str = (String)fromVal->addr;
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToRestartStyle",XtCXtToolkitError,
+ "String to RestartStyle conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if (CompareISOLatin1(str, "RestartIfRunning") == 0)
+ donestr(unsigned char, SmRestartIfRunning, XtRRestartStyle);
+ if (CompareISOLatin1(str, "RestartAnyway") == 0)
+ donestr(unsigned char, SmRestartAnyway, XtRRestartStyle);
+ if (CompareISOLatin1(str, "RestartImmediately") == 0)
+ donestr(unsigned char, SmRestartImmediately, XtRRestartStyle);
+ if (CompareISOLatin1(str, "RestartNever") == 0)
+ donestr(unsigned char, SmRestartNever, XtRRestartStyle);
+ XtDisplayStringConversionWarning(dpy, str, XtRRestartStyle);
+ return False;
+}
+
+/*ARGSUSED*/
+Boolean XtCvtStringToCommandArgArray(
+ Display *dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ String *strarray, *ptr;
+ char *src;
+ char *dst, *dst_str;
+ char *start;
+ int tokens, len;
+
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ XtNwrongParameters,"cvtStringToCommandArgArray",XtCXtToolkitError,
+ "String to CommandArgArray conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+
+ src = fromVal->addr;
+ dst = dst_str = __XtMalloc((unsigned) strlen(src) + 1);
+ tokens = 0;
+
+ while (*src != '\0') {
+ /* skip whitespace */
+ while (IsWhitespace(*src) || IsNewline(*src))
+ src++;
+ /* test for end of string */
+ if (*src == '\0')
+ break;
+
+ /* start new token */
+ tokens++;
+ start = src;
+ while (*src != '\0' && !IsWhitespace(*src) && !IsNewline(*src)) {
+ if (*src == '\\' &&
+ (IsWhitespace(*(src+1)) || IsNewline(*(src+1)))) {
+ len = src - start;
+ if (len) {
+ /* copy preceeding part of token */
+ memcpy(dst, start, len);
+ dst += len;
+ }
+ /* skip backslash */
+ src++;
+ /* next part of token starts at whitespace */
+ start = src;
+ }
+ src++;
+ }
+ len = src - start;
+ if (len) {
+ /* copy last part of token */
+ memcpy(dst, start, len);
+ dst += len;
+ }
+ *dst = '\0';
+ if (*src != '\0')
+ dst++;
+ }
+
+ ptr = strarray = (String*) __XtMalloc((Cardinal)(tokens+1) * sizeof(String));
+ src = dst_str;
+ while (--tokens >= 0) {
+ *ptr = src;
+ ptr++;
+ if (tokens) {
+ len = strlen(src);
+ src = src + len + 1;
+ }
+ }
+ *ptr = NULL;
+
+ *closure_ret = (XtPointer) strarray;
+ donestr(char**, strarray, XtRCommandArgArray)
+}
+
+/*ARGSUSED*/
+static void ArgArrayDestructor(
+ XtAppContext app,
+ XrmValuePtr toVal,
+ XtPointer closure,
+ XrmValuePtr args,
+ Cardinal *num_args)
+{
+ String *strarray;
+
+ if (closure) {
+ strarray = (String*) closure;
+ XtFree(*strarray);
+ XtFree((char *) strarray);
+ }
+}
+
+/*ARGSUSED*/
+Boolean XtCvtStringToGravity (
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *closure_ret)
+{
+ static struct _namepair {
+ XrmQuark quark;
+ char *name;
+ int gravity;
+ } names[] = {
+ { NULLQUARK, "forget", ForgetGravity },
+ { NULLQUARK, "northwest", NorthWestGravity },
+ { NULLQUARK, "north", NorthGravity },
+ { NULLQUARK, "northeast", NorthEastGravity },
+ { NULLQUARK, "west", WestGravity },
+ { NULLQUARK, "center", CenterGravity },
+ { NULLQUARK, "east", EastGravity },
+ { NULLQUARK, "southwest", SouthWestGravity },
+ { NULLQUARK, "south", SouthGravity },
+ { NULLQUARK, "southeast", SouthEastGravity },
+ { NULLQUARK, "static", StaticGravity },
+ { NULLQUARK, "unmap", UnmapGravity },
+ { NULLQUARK, "0", ForgetGravity },
+ { NULLQUARK, "1", NorthWestGravity },
+ { NULLQUARK, "2", NorthGravity },
+ { NULLQUARK, "3", NorthEastGravity },
+ { NULLQUARK, "4", WestGravity },
+ { NULLQUARK, "5", CenterGravity },
+ { NULLQUARK, "6", EastGravity },
+ { NULLQUARK, "7", SouthWestGravity },
+ { NULLQUARK, "8", SouthGravity },
+ { NULLQUARK, "9", SouthEastGravity },
+ { NULLQUARK, "10", StaticGravity },
+ { NULLQUARK, NULL, ForgetGravity }
+ };
+ static Boolean haveQuarks = FALSE;
+ char lowerName[40];
+ XrmQuark q;
+ char *s;
+ struct _namepair *np;
+
+ if (*num_args != 0) {
+ XtAppWarningMsg(XtDisplayToApplicationContext (dpy),
+ "wrongParameters","cvtStringToGravity","XtToolkitError",
+ "String to Gravity conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+ return False;
+ }
+ if (!haveQuarks) {
+ for (np = names; np->name; np++) {
+ np->quark = XrmPermStringToQuark (np->name);
+ }
+ haveQuarks = TRUE;
+ }
+ s = (char *) fromVal->addr;
+ if (strlen(s) < sizeof lowerName) {
+ CopyISOLatin1Lowered (lowerName, s);
+ q = XrmStringToQuark (lowerName);
+ for (np = names; np->name; np++)
+ if (np->quark == q) donestr(int, np->gravity, XtRGravity);
+ }
+ XtDisplayStringConversionWarning(dpy, (char *)fromVal->addr, XtRGravity);
+ return False;
+}
+
+void _XtAddDefaultConverters(
+ ConverterTable table)
+{
+#define Add(from, to, proc, convert_args, num_args, cache) \
+ _XtTableAddConverter(table, from, to, proc, \
+ (XtConvertArgList) convert_args, (Cardinal)num_args, \
+ True, cache, (XtDestructor)NULL, True)
+
+#define Add2(from, to, proc, convert_args, num_args, cache, destructor) \
+ _XtTableAddConverter(table, from, to, proc, \
+ (XtConvertArgList) convert_args, (Cardinal)num_args, \
+ True, cache, destructor, True)
+
+ Add(XtQColor, XtQPixel, XtCvtColorToPixel, NULL, 0, XtCacheNone);
+
+ Add(XtQInt, XtQBool, XtCvtIntToBool, NULL, 0, XtCacheNone);
+ Add(XtQInt, XtQBoolean, XtCvtIntToBoolean, NULL, 0, XtCacheNone);
+ Add(XtQInt, XtQColor, XtCvtIntToColor,
+ colorConvertArgs, XtNumber(colorConvertArgs), XtCacheByDisplay);
+ Add(XtQInt, XtQDimension, XtCvtIntToShort, NULL, 0, XtCacheNone);
+ Add(XtQInt, XtQFloat, XtCvtIntToFloat, NULL, 0, XtCacheNone);
+ Add(XtQInt, XtQFont, XtCvtIntToFont, NULL, 0, XtCacheNone);
+ Add(XtQInt, XtQPixel, XtCvtIntToPixel, NULL, 0, XtCacheNone);
+ Add(XtQInt, XtQPixmap, XtCvtIntToPixmap, NULL, 0, XtCacheNone);
+ Add(XtQInt, XtQPosition, XtCvtIntToShort, NULL, 0, XtCacheNone);
+ Add(XtQInt, XtQShort, XtCvtIntToShort, NULL, 0, XtCacheNone);
+ Add(XtQInt, XtQUnsignedChar,XtCvtIntToUnsignedChar,NULL, 0, XtCacheNone);
+
+ Add(XtQPixel, XtQColor, XtCvtIntToColor,
+ colorConvertArgs, XtNumber(colorConvertArgs), XtCacheByDisplay);
+
+ Add(_XtQString, XtQAtom, XtCvtStringToAtom,
+ displayConvertArg, XtNumber(displayConvertArg), XtCacheNone);
+ Add(_XtQString, XtQBool, XtCvtStringToBool, NULL, 0, XtCacheNone);
+ Add(_XtQString, XtQBoolean, XtCvtStringToBoolean, NULL, 0, XtCacheNone);
+ Add2(_XtQString, XtQCommandArgArray, XtCvtStringToCommandArgArray,
+ NULL, 0, XtCacheNone | XtCacheRefCount, ArgArrayDestructor);
+ Add2(_XtQString, XtQCursor, XtCvtStringToCursor,
+ displayConvertArg, XtNumber(displayConvertArg),
+ XtCacheByDisplay, FreeCursor);
+ Add(_XtQString, XtQDimension, XtCvtStringToDimension,NULL, 0, XtCacheNone);
+ Add2(_XtQString, XtQDirectoryString, XtCvtStringToDirectoryString, NULL, 0,
+ XtCacheNone | XtCacheRefCount, FreeDirectoryString);
+ Add(_XtQString, XtQDisplay, XtCvtStringToDisplay, NULL, 0, XtCacheAll);
+ Add2(_XtQString, XtQFile, XtCvtStringToFile, NULL, 0,
+ XtCacheAll | XtCacheRefCount, FreeFile);
+ Add(_XtQString, XtQFloat, XtCvtStringToFloat, NULL, 0, XtCacheNone);
+
+ Add2(_XtQString, XtQFont, XtCvtStringToFont,
+ displayConvertArg, XtNumber(displayConvertArg),
+ XtCacheByDisplay, FreeFont);
+ Add2(_XtQString, XtQFontSet, XtCvtStringToFontSet,
+ localeDisplayConvertArgs, XtNumber(localeDisplayConvertArgs),
+ XtCacheByDisplay, FreeFontSet);
+ Add2(_XtQString, XtQFontStruct,XtCvtStringToFontStruct,
+ displayConvertArg, XtNumber(displayConvertArg),
+ XtCacheByDisplay, FreeFontStruct);
+
+ Add(_XtQString, XtQGravity, XtCvtStringToGravity, NULL, 0, XtCacheNone);
+ Add(_XtQString, XtQInitialState, XtCvtStringToInitialState, NULL, 0,
+ XtCacheNone);
+ Add(_XtQString, XtQInt, XtCvtStringToInt, NULL, 0, XtCacheAll);
+ Add2(_XtQString, XtQPixel, XtCvtStringToPixel,
+ colorConvertArgs, XtNumber(colorConvertArgs),
+ XtCacheByDisplay, FreePixel);
+ Add(_XtQString, XtQPosition, XtCvtStringToShort, NULL, 0, XtCacheAll);
+ Add(_XtQString, XtQRestartStyle, XtCvtStringToRestartStyle, NULL, 0,
+ XtCacheNone);
+ Add(_XtQString, XtQShort, XtCvtStringToShort, NULL, 0, XtCacheAll);
+ Add(_XtQString, XtQUnsignedChar, XtCvtStringToUnsignedChar,
+ NULL, 0, XtCacheAll);
+ Add2(_XtQString, XtQVisual, XtCvtStringToVisual,
+ visualConvertArgs, XtNumber(visualConvertArgs),
+ XtCacheByDisplay, NULL);
+
+ _XtAddTMConverters(table);
+}
diff --git a/nx-X11/lib/Xt/Core.c b/nx-X11/lib/Xt/Core.c
new file mode 100644
index 000000000..d30b4937c
--- /dev/null
+++ b/nx-X11/lib/Xt/Core.c
@@ -0,0 +1,400 @@
+/* $Xorg: Core.c,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+
+#define _XT_CORE_C
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicP.h"
+#include "EventI.h"
+#include "ConvertI.h"
+#include "TranslateI.h"
+#include "ResourceI.h"
+#include "RectObj.h"
+#include "RectObjP.h"
+#include "ThreadsI.h"
+#include "StringDefs.h"
+
+/******************************************************************
+ *
+ * CoreWidget Resources
+ *
+ ******************************************************************/
+
+externaldef(xtinherittranslations) int _XtInheritTranslations = 0;
+extern String XtCXtToolkitError; /* from IntrinsicI.h */
+static void XtCopyScreen(Widget, int, XrmValue *);
+
+static XtResource resources[] = {
+ {XtNscreen, XtCScreen, XtRScreen, sizeof(Screen*),
+ XtOffsetOf(CoreRec,core.screen), XtRCallProc, (XtPointer)XtCopyScreen},
+/*_XtCopyFromParent does not work for screen because the Display
+parameter is not passed through to the XtRCallProc routines */
+ {XtNdepth, XtCDepth, XtRInt,sizeof(int),
+ XtOffsetOf(CoreRec,core.depth),
+ XtRCallProc, (XtPointer)_XtCopyFromParent},
+ {XtNcolormap, XtCColormap, XtRColormap, sizeof(Colormap),
+ XtOffsetOf(CoreRec,core.colormap),
+ XtRCallProc,(XtPointer)_XtCopyFromParent},
+ {XtNbackground, XtCBackground, XtRPixel,sizeof(Pixel),
+ XtOffsetOf(CoreRec,core.background_pixel),
+ XtRString, (XtPointer)"XtDefaultBackground"},
+ {XtNbackgroundPixmap, XtCPixmap, XtRPixmap, sizeof(Pixmap),
+ XtOffsetOf(CoreRec,core.background_pixmap),
+ XtRImmediate, (XtPointer)XtUnspecifiedPixmap},
+ {XtNborderColor, XtCBorderColor, XtRPixel,sizeof(Pixel),
+ XtOffsetOf(CoreRec,core.border_pixel),
+ XtRString,(XtPointer)"XtDefaultForeground"},
+ {XtNborderPixmap, XtCPixmap, XtRPixmap, sizeof(Pixmap),
+ XtOffsetOf(CoreRec,core.border_pixmap),
+ XtRImmediate, (XtPointer)XtUnspecifiedPixmap},
+ {XtNmappedWhenManaged, XtCMappedWhenManaged, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(CoreRec,core.mapped_when_managed),
+ XtRImmediate, (XtPointer)True},
+ {XtNtranslations, XtCTranslations, XtRTranslationTable,
+ sizeof(XtTranslations), XtOffsetOf(CoreRec,core.tm.translations),
+ XtRTranslationTable, (XtPointer)NULL},
+ {XtNaccelerators, XtCAccelerators, XtRAcceleratorTable,
+ sizeof(XtTranslations), XtOffsetOf(CoreRec,core.accelerators),
+ XtRTranslationTable, (XtPointer)NULL}
+ };
+
+static void CoreInitialize(Widget, Widget, ArgList, Cardinal *);
+static void CoreClassPartInitialize(WidgetClass);
+static void CoreDestroy(Widget);
+static void CoreRealize(Widget, XtValueMask *, XSetWindowAttributes *);
+static Boolean CoreSetValues(Widget, Widget, Widget, ArgList, Cardinal *);
+static void CoreSetValuesAlmost(Widget, Widget, XtWidgetGeometry *, XtWidgetGeometry *);
+
+static RectObjClassRec unNamedObjClassRec = {
+ {
+ /* superclass */ (WidgetClass)&rectObjClassRec,
+ /* class_name */ "UnNamedObj",
+ /* widget_size */ 0,
+ /* class_initialize */ NULL,
+ /* class_part_initialize*/ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_hook */ NULL,
+ /* realize */ (XtProc)XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ NULL,
+ /* num_resources */ 0,
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ FALSE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ NULL,
+ /* expose */ NULL,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL
+ }
+};
+
+
+externaldef(widgetclassrec) WidgetClassRec widgetClassRec = {
+{
+ /* superclass */ (WidgetClass)&unNamedObjClassRec,
+ /* class_name */ "Core",
+ /* widget_size */ sizeof(WidgetRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize*/ CoreClassPartInitialize,
+ /* class_inited */ FALSE,
+ /* initialize */ CoreInitialize,
+ /* initialize_hook */ NULL,
+ /* realize */ CoreRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ CoreDestroy,
+ /* resize */ NULL,
+ /* expose */ NULL,
+ /* set_values */ CoreSetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ CoreSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL
+ }
+};
+externaldef (WidgetClass) WidgetClass widgetClass = &widgetClassRec;
+
+externaldef (WidgetClass) WidgetClass coreWidgetClass = &widgetClassRec;
+
+
+/*ARGSUSED*/
+static void XtCopyScreen(
+ Widget widget,
+ int offset,
+ XrmValue *value)
+{
+ value->addr = (XPointer)(&widget->core.screen);
+}
+
+/*
+ * Start of Core methods
+ */
+
+static void CoreClassPartInitialize(
+ register WidgetClass wc)
+{
+ /* We don't need to check for null super since we'll get to object
+ eventually, and it had better define them! */
+
+ register WidgetClass super = wc->core_class.superclass;
+
+ LOCK_PROCESS;
+ if (wc->core_class.realize == XtInheritRealize) {
+ wc->core_class.realize = super->core_class.realize;
+ }
+
+ if (wc->core_class.accept_focus == XtInheritAcceptFocus) {
+ wc->core_class.accept_focus = super->core_class.accept_focus;
+ }
+
+ if (wc->core_class.display_accelerator == XtInheritDisplayAccelerator) {
+ wc->core_class.display_accelerator =
+ super->core_class.display_accelerator;
+ }
+
+ if (wc->core_class.tm_table == (char *) XtInheritTranslations) {
+ wc->core_class.tm_table =
+ wc->core_class.superclass->core_class.tm_table;
+ } else if (wc->core_class.tm_table != NULL) {
+ wc->core_class.tm_table =
+ (String)XtParseTranslationTable(wc->core_class.tm_table);
+ }
+
+ if (wc->core_class.actions != NULL) {
+ Boolean inPlace;
+
+ if (wc->core_class.version == XtVersionDontCheck)
+ inPlace = True;
+ else
+ inPlace = (wc->core_class.version < XtVersion) ? False : True;
+
+ /* Compile the action table into a more efficient form */
+ wc->core_class.actions = (XtActionList) _XtInitializeActionData(
+ wc->core_class.actions, wc->core_class.num_actions, inPlace);
+ }
+ UNLOCK_PROCESS;
+}
+/* ARGSUSED */
+static void CoreInitialize(
+ Widget requested_widget,
+ register Widget new_widget,
+ ArgList args,
+ Cardinal *num_args)
+{
+ XtTranslations save1, save2;
+ new_widget->core.event_table = NULL;
+ new_widget->core.tm.proc_table = NULL;
+ new_widget->core.tm.lastEventTime = 0;
+ /* magic semi-resource fetched by GetResources */
+ save1 = (XtTranslations)new_widget->core.tm.current_state;
+ new_widget->core.tm.current_state = NULL;
+ save2 = new_widget->core.tm.translations;
+ LOCK_PROCESS;
+ new_widget->core.tm.translations =
+ (XtTranslations)new_widget->core.widget_class->core_class.tm_table;
+ UNLOCK_PROCESS;
+ if (save1)
+ _XtMergeTranslations(new_widget, save1, save1->operation);
+ if (save2)
+ _XtMergeTranslations(new_widget, save2, save2->operation);
+}
+
+static void CoreRealize(
+ Widget widget,
+ XtValueMask *value_mask,
+ XSetWindowAttributes *attributes)
+{
+ XtCreateWindow(widget, (unsigned int) InputOutput,
+ (Visual *) CopyFromParent, *value_mask, attributes);
+} /* CoreRealize */
+
+static void CoreDestroy (
+ Widget widget)
+{
+ _XtFreeEventTable(&widget->core.event_table);
+ _XtDestroyTMData(widget);
+ XtUnregisterDrawable(XtDisplay(widget), widget->core.window);
+
+ if (widget->core.popup_list != NULL)
+ XtFree((char *)widget->core.popup_list);
+
+} /* CoreDestroy */
+
+/* ARGSUSED */
+static Boolean CoreSetValues(
+ Widget old, Widget reference, Widget new,
+ ArgList args,
+ Cardinal *num_args)
+{
+ Boolean redisplay;
+ Mask window_mask;
+ XSetWindowAttributes attributes;
+ XtTranslations save;
+
+ redisplay = FALSE;
+ if (old->core.tm.translations != new->core.tm.translations) {
+ save = new->core.tm.translations;
+ new->core.tm.translations = old->core.tm.translations;
+ _XtMergeTranslations(new, save, XtTableReplace);
+ }
+
+ /* Check everything that depends upon window being realized */
+ if (XtIsRealized(old)) {
+ window_mask = 0;
+ /* Check window attributes */
+ if (old->core.background_pixel != new->core.background_pixel
+ && new->core.background_pixmap == XtUnspecifiedPixmap) {
+ attributes.background_pixel = new->core.background_pixel;
+ window_mask |= CWBackPixel;
+ redisplay = TRUE;
+ }
+ if (old->core.background_pixmap != new->core.background_pixmap) {
+ if (new->core.background_pixmap == XtUnspecifiedPixmap) {
+ window_mask |= CWBackPixel;
+ attributes.background_pixel = new->core.background_pixel;
+ }
+ else {
+ attributes.background_pixmap = new->core.background_pixmap;
+ window_mask &= ~CWBackPixel;
+ window_mask |= CWBackPixmap;
+ }
+ redisplay = TRUE;
+ }
+ if (old->core.border_pixel != new->core.border_pixel
+ && new->core.border_pixmap == XtUnspecifiedPixmap) {
+ attributes.border_pixel = new->core.border_pixel;
+ window_mask |= CWBorderPixel;
+ }
+ if (old->core.border_pixmap != new->core.border_pixmap) {
+ if (new->core.border_pixmap == XtUnspecifiedPixmap) {
+ window_mask |= CWBorderPixel;
+ attributes.border_pixel = new->core.border_pixel;
+ }
+ else {
+ attributes.border_pixmap = new->core.border_pixmap;
+ window_mask &= ~CWBorderPixel;
+ window_mask |= CWBorderPixmap;
+ }
+ }
+ if (old->core.depth != new->core.depth) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(old),
+ "invalidDepth","setValues",XtCXtToolkitError,
+ "Can't change widget depth", (String *)NULL, (Cardinal *)NULL);
+ new->core.depth = old->core.depth;
+ }
+ if (old->core.colormap != new->core.colormap) {
+ window_mask |= CWColormap;
+ attributes.colormap = new->core.colormap;
+ }
+ if (window_mask != 0) {
+ /* Actually change X window attributes */
+ XChangeWindowAttributes(
+ XtDisplay(new), XtWindow(new), window_mask, &attributes);
+ }
+
+ if (old->core.mapped_when_managed != new->core.mapped_when_managed) {
+ Boolean mapped_when_managed = new->core.mapped_when_managed;
+ new->core.mapped_when_managed = !mapped_when_managed;
+ XtSetMappedWhenManaged(new, mapped_when_managed);
+ }
+ } /* if realized */
+
+ return redisplay;
+} /* CoreSetValues */
+
+/*ARGSUSED*/
+static void CoreSetValuesAlmost(
+ Widget old,
+ Widget new,
+ XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+ *request = *reply;
+}
diff --git a/nx-X11/lib/Xt/Core.h b/nx-X11/lib/Xt/Core.h
new file mode 100644
index 000000000..ff6cb7535
--- /dev/null
+++ b/nx-X11/lib/Xt/Core.h
@@ -0,0 +1,66 @@
+/*
+* $Xorg: Core.h,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $
+* $oHeader: Core.h,v 1.2 88/08/18 15:54:32 asente 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.
+
+******************************************************************/
+
+#ifndef _XtCore_h
+#define _XtCore_h
+
+typedef struct _WidgetClassRec *CoreWidgetClass;
+typedef struct _WidgetRec *CoreWidget;
+externalref WidgetClass coreWidgetClass;
+
+#ifndef _XT_CORE_C
+externalref WidgetClass widgetClass;
+
+#endif
+
+#endif /* _XtCore_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/CoreP.h b/nx-X11/lib/Xt/CoreP.h
new file mode 100644
index 000000000..e07f085e6
--- /dev/null
+++ b/nx-X11/lib/Xt/CoreP.h
@@ -0,0 +1,171 @@
+/*
+* $Xorg: CoreP.h,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $
+* $oHeader: CoreP.h,v 1.2 88/08/18 15:54:37 asente 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.
+
+******************************************************************/
+
+#ifndef XtCoreP_h
+#define XtCoreP_h
+
+#include <X11/Core.h>
+
+externalref int _XtInheritTranslations;
+
+#define XtInheritTranslations ((String) &_XtInheritTranslations)
+#define XtInheritRealize ((XtRealizeProc) _XtInherit)
+#define XtInheritResize ((XtWidgetProc) _XtInherit)
+#define XtInheritExpose ((XtExposeProc) _XtInherit)
+#define XtInheritSetValuesAlmost ((XtAlmostProc) _XtInherit)
+#define XtInheritAcceptFocus ((XtAcceptFocusProc) _XtInherit)
+#define XtInheritQueryGeometry ((XtGeometryHandler) _XtInherit)
+#define XtInheritDisplayAccelerator ((XtStringProc) _XtInherit)
+
+/***************************************************************
+ * Widget Core Data Structures
+ *
+ *
+ **************************************************************/
+
+typedef struct _CorePart {
+ Widget self; /* pointer to widget itself */
+ WidgetClass widget_class; /* pointer to Widget's ClassRec */
+ Widget parent; /* parent widget */
+ XrmName xrm_name; /* widget resource name quarkified */
+ Boolean being_destroyed; /* marked for destroy */
+ XtCallbackList destroy_callbacks; /* who to call when widget destroyed */
+ XtPointer constraints; /* constraint record */
+ Position x, y; /* window position */
+ Dimension width, height; /* window dimensions */
+ Dimension border_width; /* window border width */
+ Boolean managed; /* is widget geometry managed? */
+ Boolean sensitive; /* is widget sensitive to user events*/
+ Boolean ancestor_sensitive; /* are all ancestors sensitive? */
+ XtEventTable event_table; /* private to event dispatcher */
+ XtTMRec tm; /* translation management */
+ XtTranslations accelerators; /* accelerator translations */
+ Pixel border_pixel; /* window border pixel */
+ Pixmap border_pixmap; /* window border pixmap or NULL */
+ WidgetList popup_list; /* list of popups */
+ Cardinal num_popups; /* how many popups */
+ String name; /* widget resource name */
+ Screen *screen; /* window's screen */
+ Colormap colormap; /* colormap */
+ Window window; /* window ID */
+ Cardinal depth; /* number of planes in window */
+ Pixel background_pixel; /* window background pixel */
+ Pixmap background_pixmap; /* window background pixmap or NULL */
+ Boolean visible; /* is window mapped and not occluded?*/
+ Boolean mapped_when_managed;/* map window if it's managed? */
+} CorePart;
+
+typedef struct _WidgetRec {
+ CorePart core;
+ } WidgetRec, CoreRec;
+
+
+
+/******************************************************************
+ *
+ * Core Class Structure. Widgets, regardless of their class, will have
+ * these fields. All widgets of a given class will have the same values
+ * for these fields. Widgets of a given class may also have additional
+ * common fields. These additional fields are included in incremental
+ * class structures, such as CommandClass.
+ *
+ * The fields that are specific to this subclass, as opposed to fields that
+ * are part of the superclass, are called "subclass fields" below. Many
+ * procedures are responsible only for the subclass fields, and not for
+ * any superclass fields.
+ *
+ ********************************************************************/
+
+typedef struct _CoreClassPart {
+ WidgetClass superclass; /* pointer to superclass ClassRec */
+ String class_name; /* widget resource class name */
+ Cardinal widget_size; /* size in bytes of widget record */
+ XtProc class_initialize; /* class initialization proc */
+ XtWidgetClassProc class_part_initialize; /* dynamic initialization */
+ XtEnum class_inited; /* has class been initialized? */
+ XtInitProc initialize; /* initialize subclass fields */
+ XtArgsProc initialize_hook; /* notify that initialize called */
+ XtRealizeProc realize; /* XCreateWindow for widget */
+ XtActionList actions; /* widget semantics name to proc map */
+ Cardinal num_actions; /* number of entries in actions */
+ XtResourceList resources; /* resources for subclass fields */
+ Cardinal num_resources; /* number of entries in resources */
+ XrmClass xrm_class; /* resource class quarkified */
+ Boolean compress_motion; /* compress MotionNotify for widget */
+ XtEnum compress_exposure; /* compress Expose events for widget*/
+ Boolean compress_enterleave;/* compress enter and leave events */
+ Boolean visible_interest; /* select for VisibilityNotify */
+ XtWidgetProc destroy; /* free data for subclass pointers */
+ XtWidgetProc resize; /* geom manager changed widget size */
+ XtExposeProc expose; /* rediplay window */
+ XtSetValuesFunc set_values; /* set subclass resource values */
+ XtArgsFunc set_values_hook; /* notify that set_values called */
+ XtAlmostProc set_values_almost; /* set_values got "Almost" geo reply */
+ XtArgsProc get_values_hook; /* notify that get_values called */
+ XtAcceptFocusProc accept_focus; /* assign input focus to widget */
+ XtVersionType version; /* version of intrinsics used */
+ XtPointer callback_private; /* list of callback offsets */
+ String tm_table; /* state machine */
+ XtGeometryHandler query_geometry; /* return preferred geometry */
+ XtStringProc display_accelerator;/* display your accelerator */
+ XtPointer extension; /* pointer to extension record */
+ } CoreClassPart;
+
+typedef struct _WidgetClassRec {
+ CoreClassPart core_class;
+} WidgetClassRec, CoreClassRec;
+
+externalref WidgetClassRec widgetClassRec;
+#define coreClassRec widgetClassRec
+
+#endif /* _XtCoreP_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/Create.c b/nx-X11/lib/Xt/Create.c
new file mode 100644
index 000000000..d3417a115
--- /dev/null
+++ b/nx-X11/lib/Xt/Create.c
@@ -0,0 +1,779 @@
+/* $Xorg: Create.c,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/Create.c,v 3.10 2002/12/17 04:50:58 dawes Exp $ */
+
+/*
+
+Copyright 1987, 1988, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "VarargsI.h"
+#include "ShellP.h"
+#include "CreateI.h"
+#ifndef X_NO_RESOURCE_CONFIGURATION_MANAGEMENT
+#include "ResConfigP.h"
+#endif
+#include <stdio.h>
+
+static String XtNxtCreateWidget = "xtCreateWidget";
+static String XtNxtCreatePopupShell = "xtCreatePopupShell";
+
+static void
+CallClassPartInit(WidgetClass ancestor, WidgetClass wc)
+{
+ if (ancestor->core_class.superclass != NULL) {
+ CallClassPartInit(ancestor->core_class.superclass, wc);
+ }
+ if (ancestor->core_class.class_part_initialize != NULL) {
+ (*(ancestor->core_class.class_part_initialize)) (wc);
+ }
+}
+
+void
+XtInitializeWidgetClass(wc)
+ WidgetClass wc;
+{
+ XtEnum inited;
+ LOCK_PROCESS;
+ if (wc->core_class.class_inited) {
+ UNLOCK_PROCESS;
+ return;
+ }
+ inited = 0x01;
+ {
+ WidgetClass pc;
+#define LeaveIfClass(c, d) if (pc == c) { inited = d; break; }
+ for (pc = wc; pc; pc = pc->core_class.superclass) {
+ LeaveIfClass(rectObjClass, 0x01 |
+ RectObjClassFlag);
+ LeaveIfClass(coreWidgetClass, 0x01 |
+ RectObjClassFlag |
+ WidgetClassFlag);
+ LeaveIfClass(compositeWidgetClass, 0x01 |
+ RectObjClassFlag |
+ WidgetClassFlag |
+ CompositeClassFlag);
+ LeaveIfClass(constraintWidgetClass, 0x01 |
+ RectObjClassFlag |
+ WidgetClassFlag |
+ CompositeClassFlag |
+ ConstraintClassFlag);
+ LeaveIfClass(shellWidgetClass, 0x01 |
+ RectObjClassFlag |
+ WidgetClassFlag |
+ CompositeClassFlag |
+ ShellClassFlag);
+ LeaveIfClass(wmShellWidgetClass, 0x01 |
+ RectObjClassFlag |
+ WidgetClassFlag |
+ CompositeClassFlag |
+ ShellClassFlag |
+ WMShellClassFlag);
+ LeaveIfClass(topLevelShellWidgetClass, 0x01 |
+ RectObjClassFlag |
+ WidgetClassFlag |
+ CompositeClassFlag |
+ ShellClassFlag |
+ WMShellClassFlag |
+ TopLevelClassFlag);
+ }
+#undef LeaveIfClass
+ }
+ if (wc->core_class.version != XtVersion &&
+ wc->core_class.version != XtVersionDontCheck) {
+ String param[3];
+ String mismatch = "Widget class %s version mismatch (recompilation needed):\n widget %d vs. intrinsics %d.";
+ String recompile = "Widget class %s must be re-compiled.";
+ Cardinal num_params;
+
+ param[0] = wc->core_class.class_name;
+ param[1] = (String) wc->core_class.version;
+ param[2] = (String) XtVersion;
+
+ if (wc->core_class.version == (11 * 1000 + 5) || /* MIT X11R5 */
+ wc->core_class.version == (11 * 1000 + 4)) { /* MIT X11R4 */
+ if ((inited & WMShellClassFlag) &&
+ (sizeof(Boolean) != sizeof(char) ||
+ sizeof(Atom) != sizeof(Widget) ||
+ sizeof(Atom) != sizeof(String))) {
+ num_params=3;
+ XtWarningMsg("versionMismatch","widget",XtCXtToolkitError,
+ mismatch, param, &num_params);
+ num_params=1;
+ XtErrorMsg("R4orR5versionMismatch","widget",XtCXtToolkitError,
+ recompile, param, &num_params);
+
+ }
+ }
+ else if (wc->core_class.version == (11 * 1000 + 3)) { /* MIT X11R3 */
+ if (inited & ShellClassFlag) {
+ num_params=1;
+ XtWarningMsg("r3versionMismatch","widget",XtCXtToolkitError,
+ "Shell Widget class %s binary compiled for R3",
+ param,&num_params);
+ XtErrorMsg("R3versionMismatch","widget",XtCXtToolkitError,
+ recompile, param, &num_params);
+ }
+ }
+ else {
+ num_params=3;
+ XtWarningMsg("versionMismatch","widget",XtCXtToolkitError,
+ mismatch, param, &num_params);
+ if (wc->core_class.version == (2 * 1000 + 2)) /* MIT X11R2 */ {
+ num_params=1;
+ XtErrorMsg("r2versionMismatch","widget",XtCXtToolkitError,
+ recompile, param, &num_params);
+ }
+ }
+ }
+
+ if ((wc->core_class.superclass != NULL)
+ && (!(wc->core_class.superclass->core_class.class_inited)))
+ XtInitializeWidgetClass(wc->core_class.superclass);
+
+ if (wc->core_class.class_initialize != NULL)
+ (*(wc->core_class.class_initialize))();
+ CallClassPartInit(wc, wc);
+ wc->core_class.class_inited = inited;
+ UNLOCK_PROCESS;
+}
+
+static void
+CallInitialize (
+ WidgetClass class,
+ Widget req_widget,
+ Widget new_widget,
+ ArgList args,
+ Cardinal num_args)
+{
+ WidgetClass superclass;
+ XtInitProc initialize;
+ XtArgsProc initialize_hook;
+
+ LOCK_PROCESS;
+ superclass = class->core_class.superclass;
+ UNLOCK_PROCESS;
+ if (superclass)
+ CallInitialize (superclass, req_widget, new_widget, args, num_args);
+ LOCK_PROCESS;
+ initialize = class->core_class.initialize;
+ UNLOCK_PROCESS;
+ if (initialize)
+ (*initialize) (req_widget, new_widget, args, &num_args);
+ LOCK_PROCESS;
+ initialize_hook = class->core_class.initialize_hook;
+ UNLOCK_PROCESS;
+ if (initialize_hook)
+ (*initialize_hook) (new_widget, args, &num_args);
+}
+
+static void
+CallConstraintInitialize (
+ ConstraintWidgetClass class,
+ Widget req_widget,
+ Widget new_widget,
+ ArgList args,
+ Cardinal num_args)
+{
+ WidgetClass superclass;
+ XtInitProc initialize;
+
+ LOCK_PROCESS;
+ superclass = class->core_class.superclass;
+ UNLOCK_PROCESS;
+ if (superclass != constraintWidgetClass)
+ CallConstraintInitialize((ConstraintWidgetClass) superclass,
+ req_widget, new_widget, args, num_args);
+ LOCK_PROCESS;
+ initialize = class->constraint_class.initialize;
+ UNLOCK_PROCESS;
+ if (initialize)
+ (*initialize) (req_widget, new_widget, args, &num_args);
+}
+
+static Widget
+xtWidgetAlloc(
+ WidgetClass widget_class,
+ ConstraintWidgetClass parent_constraint_class,
+ Widget parent,
+ String name,
+ ArgList args, /* must be NULL if typed_args is non-NULL */
+ Cardinal num_args,
+ XtTypedArgList typed_args, /* must be NULL if args is non-NULL */
+ Cardinal num_typed_args)
+{
+ Widget widget;
+ Cardinal wsize, csize = 0;
+ ObjectClassExtension ext;
+
+ LOCK_PROCESS;
+ if (! (widget_class->core_class.class_inited))
+ XtInitializeWidgetClass(widget_class);
+ ext = (ObjectClassExtension)
+ XtGetClassExtension(widget_class,
+ XtOffsetOf(ObjectClassRec, object_class.extension),
+ NULLQUARK, XtObjectExtensionVersion,
+ sizeof(ObjectClassExtensionRec));
+ if (parent_constraint_class)
+ csize = parent_constraint_class->constraint_class.constraint_size;
+ if (ext && ext->allocate) {
+ XtAllocateProc allocate;
+ Cardinal extra = 0;
+ Cardinal nargs = num_args;
+ Cardinal ntyped = num_typed_args;
+ allocate = ext->allocate;
+ UNLOCK_PROCESS;
+ (*allocate)(widget_class, &csize, &extra, args, &nargs,
+ typed_args, &ntyped, &widget, NULL);
+ } else {
+ wsize = widget_class->core_class.widget_size;
+ UNLOCK_PROCESS;
+ if (csize) {
+ if (sizeof(struct {char a; double b;}) !=
+ (sizeof(struct {char a; unsigned long b;}) -
+ sizeof(unsigned long) + sizeof(double))) {
+ if (csize && !(csize & (sizeof(double) - 1)))
+ wsize = (wsize + sizeof(double) - 1) & ~(sizeof(double)-1);
+ }
+ }
+ widget = (Widget) __XtMalloc((unsigned)(wsize + csize));
+ bzero(widget, wsize + csize);
+ widget->core.constraints =
+ (csize ? (XtPointer)((char *)widget + wsize) : NULL);
+ }
+ widget->core.self = widget;
+ widget->core.parent = parent;
+ widget->core.widget_class = widget_class;
+ widget->core.xrm_name = StringToName((name != NULL) ? name : "");
+ widget->core.being_destroyed =
+ (parent != NULL ? parent->core.being_destroyed : FALSE);
+ return widget;
+}
+
+static void
+CompileCallbacks(
+ Widget widget)
+{
+ CallbackTable offsets;
+ InternalCallbackList* cl;
+ int i;
+
+ LOCK_PROCESS;
+ offsets = (CallbackTable)
+ widget->core.widget_class->core_class.callback_private;
+
+ for (i = (int)(long) *(offsets++); --i >= 0; offsets++) {
+ cl = (InternalCallbackList *)
+ ((char *) widget - (*offsets)->xrm_offset - 1);
+ if (*cl)
+ *cl = _XtCompileCallbackList((XtCallbackList) *cl);
+ }
+ UNLOCK_PROCESS;
+}
+
+static Widget
+xtCreate(
+ char *name,
+ char *class,
+ WidgetClass widget_class,
+ Widget parent,
+ Screen* default_screen, /* undefined when creating a nonwidget */
+ ArgList args, /* must be NULL if typed_args is non-NULL */
+ Cardinal num_args,
+ XtTypedArgList typed_args, /* must be NULL if args is non-NULL */
+ Cardinal num_typed_args,
+ ConstraintWidgetClass parent_constraint_class,
+ /* NULL if not a subclass of Constraint or if child is popup shell */
+ XtWidgetProc post_proc)
+{
+ /* need to use strictest alignment rules possible in next two decls. */
+ double widget_cache[100];
+ double constraint_cache[20];
+ Widget req_widget;
+ XtPointer req_constraints = NULL;
+ Cardinal wsize, csize;
+ Widget widget;
+ XtCacheRef *cache_refs;
+ Cardinal i;
+ XtCreateHookDataRec call_data;
+
+ widget = xtWidgetAlloc(widget_class, parent_constraint_class, parent,
+ name, args, num_args, typed_args, num_typed_args);
+
+ if (XtIsRectObj(widget)) {
+ widget->core.managed = FALSE;
+ }
+ if (XtIsWidget(widget)) {
+ widget->core.name = XrmNameToString(widget->core.xrm_name);
+ widget->core.screen = default_screen;
+ widget->core.tm.translations = NULL;
+ widget->core.window = (Window) 0;
+ widget->core.visible = TRUE;
+ widget->core.popup_list = NULL;
+ widget->core.num_popups = 0;
+ };
+ LOCK_PROCESS;
+ if (XtIsApplicationShell(widget)) {
+ ApplicationShellWidget a = (ApplicationShellWidget) widget;
+ if (class != NULL)
+ a->application.xrm_class = StringToClass(class);
+ else
+ a->application.xrm_class = widget_class->core_class.xrm_class;
+ a->application.class = XrmQuarkToString(a->application.xrm_class);
+ }
+ UNLOCK_PROCESS;
+
+ /* fetch resources */
+ cache_refs = _XtGetResources(widget, args, num_args,
+ typed_args, &num_typed_args);
+
+ /* Convert typed arg list to arg list */
+ if (typed_args != NULL && num_typed_args > 0) {
+ args = (ArgList)ALLOCATE_LOCAL(sizeof(Arg) * num_typed_args);
+ if (args == NULL) _XtAllocError(NULL);
+ for (i = 0; i < num_typed_args; i++) {
+ args[i].name = typed_args[i].name;
+ args[i].value = typed_args[i].value;
+ }
+ num_args = num_typed_args;
+ }
+
+ CompileCallbacks(widget);
+
+ if (cache_refs != NULL) {
+ XtAddCallback(widget, XtNdestroyCallback,
+ XtCallbackReleaseCacheRefList, (XtPointer)cache_refs );
+ }
+
+ wsize = widget_class->core_class.widget_size;
+ csize = 0;
+ req_widget = (Widget) XtStackAlloc(wsize, widget_cache);
+ (void) memmove ((char *) req_widget, (char *) widget, (int) wsize);
+ CallInitialize (XtClass(widget), req_widget, widget, args, num_args);
+ if (parent_constraint_class != NULL) {
+ csize = parent_constraint_class->constraint_class.constraint_size;
+ if (csize) {
+ req_constraints = XtStackAlloc(csize, constraint_cache);
+ (void) memmove((char*)req_constraints, widget->core.constraints,
+ (int)csize);
+ req_widget->core.constraints = req_constraints;
+ } else req_widget->core.constraints = NULL;
+ CallConstraintInitialize(parent_constraint_class, req_widget, widget,
+ args, num_args);
+ if (csize) {
+ XtStackFree(req_constraints, constraint_cache);
+ }
+ }
+ XtStackFree((XtPointer)req_widget, widget_cache);
+ if (post_proc != (XtWidgetProc) NULL) {
+ Widget hookobj;
+ (*post_proc)(widget);
+ hookobj = XtHooksOfDisplay((default_screen != (Screen*) NULL) ?
+ default_screen->display :
+ XtDisplayOfObject(parent));
+ if (XtHasCallbacks(hookobj, XtNcreateHook) == XtCallbackHasSome) {
+
+ call_data.type = XtHcreate;
+ call_data.widget = widget;
+ call_data.args = args;
+ call_data.num_args = num_args;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.createhook_callbacks,
+ (XtPointer)&call_data);
+ }
+ }
+ if (typed_args != NULL) {
+ while (num_typed_args-- > 0) {
+
+ /* In GetResources we may have dynamically alloc'd store to hold */
+ /* a copy of a resource which was larger then sizeof(XtArgVal). */
+ /* We must free this store now in order to prevent a memory leak */
+ /* A typed arg that has a converted value in dynamic store has a */
+ /* negated size field. */
+
+ if (typed_args->type != NULL && typed_args->size < 0) {
+ XtFree((char*)typed_args->value);
+ typed_args->size = -(typed_args->size);
+ }
+ typed_args++;
+ }
+ DEALLOCATE_LOCAL((char*)args);
+ }
+ return (widget);
+}
+
+static void
+widgetPostProc(Widget w)
+{
+ XtWidgetProc insert_child;
+ Widget parent = XtParent(w);
+ String param = XtName(w);
+ Cardinal num_params = 1;
+
+ if (XtIsComposite(parent)) {
+ LOCK_PROCESS;
+ insert_child = ((CompositeWidgetClass) parent->core.widget_class)->
+ composite_class.insert_child;
+ UNLOCK_PROCESS;
+ } else {
+ return;
+ }
+ if (insert_child == NULL) {
+ XtAppErrorMsg(XtWidgetToApplicationContext(parent),
+ "nullProc","insertChild",XtCXtToolkitError,
+ "\"%s\" parent has NULL insert_child method",
+ &param, &num_params);
+ } else {
+ (*insert_child) (w);
+ }
+}
+
+Widget
+_XtCreateWidget(
+ String name,
+ WidgetClass widget_class,
+ Widget parent,
+ ArgList args,
+ Cardinal num_args,
+ XtTypedArgList typed_args,
+ Cardinal num_typed_args)
+{
+ register Widget widget;
+ ConstraintWidgetClass cwc;
+ Screen* default_screen;
+ XtEnum class_inited;
+ String params[3];
+ Cardinal num_params;
+
+ params[0] = name;
+ num_params = 1;
+
+ if (parent == NULL) {
+ XtErrorMsg("invalidParent", XtNxtCreateWidget, XtCXtToolkitError,
+ "XtCreateWidget \"%s\" requires non-NULL parent",
+ params, &num_params);
+ } else if (widget_class == NULL) {
+ XtAppErrorMsg(XtWidgetToApplicationContext(parent),
+ "invalidClass", XtNxtCreateWidget, XtCXtToolkitError,
+ "XtCreateWidget \"%s\" requires non-NULL widget class",
+ params, &num_params);
+ }
+ LOCK_PROCESS;
+ if (!widget_class->core_class.class_inited)
+ XtInitializeWidgetClass(widget_class);
+ class_inited = widget_class->core_class.class_inited;
+ UNLOCK_PROCESS;
+ if ((class_inited & WidgetClassFlag) == 0) {
+ /* not a widget */
+ default_screen = NULL;
+ if (XtIsComposite(parent)) {
+ CompositeClassExtension ext;
+ ext = (CompositeClassExtension)
+ XtGetClassExtension(XtClass(parent),
+ XtOffsetOf(CompositeClassRec, composite_class.extension),
+ NULLQUARK, 1L, (Cardinal) 0);
+ LOCK_PROCESS;
+ if (ext &&
+ (ext->version > XtCompositeExtensionVersion ||
+ ext->record_size > sizeof(CompositeClassExtensionRec))) {
+ params[1] = XtClass(parent)->core_class.class_name;
+ num_params = 2;
+ XtAppWarningMsg(XtWidgetToApplicationContext(parent),
+ "invalidExtension", XtNxtCreateWidget,
+ XtCXtToolkitError,
+ "widget \"%s\" class %s has invalid CompositeClassExtension record",
+ params, &num_params);
+ }
+ if (!ext || !ext->accepts_objects) {
+ params[1] = XtName(parent);
+ num_params = 2;
+ XtAppErrorMsg(XtWidgetToApplicationContext(parent),
+ "nonWidget", XtNxtCreateWidget,XtCXtToolkitError,
+"attempt to add non-widget child \"%s\" to parent \"%s\" which supports only widgets",
+ params, &num_params);
+ }
+ UNLOCK_PROCESS;
+ }
+ } else {
+ default_screen = parent->core.screen;
+ }
+
+ if (XtIsConstraint(parent)) {
+ cwc = (ConstraintWidgetClass) parent->core.widget_class;
+ } else {
+ cwc = NULL;
+ }
+ widget = xtCreate(name, (char *)NULL, widget_class, parent,
+ default_screen, args, num_args,
+ typed_args, num_typed_args, cwc, widgetPostProc);
+ return (widget);
+}
+
+Widget
+XtCreateWidget(
+ _Xconst char* name,
+ WidgetClass widget_class,
+ Widget parent,
+ ArgList args,
+ Cardinal num_args
+ )
+{
+ Widget retval;
+ WIDGET_TO_APPCON(parent);
+
+ LOCK_APP(app);
+ retval = _XtCreateWidget((String)name, widget_class, parent, args, num_args,
+ (XtTypedArgList)NULL, (Cardinal)0);
+ UNLOCK_APP(app);
+ return retval;
+}
+
+
+Widget
+XtCreateManagedWidget(
+ _Xconst char* name,
+ WidgetClass widget_class,
+ Widget parent,
+ ArgList args,
+ Cardinal num_args
+ )
+{
+ register Widget widget;
+ WIDGET_TO_APPCON(parent);
+
+ LOCK_APP(app);
+ XtCheckSubclass(parent, compositeWidgetClass, "in XtCreateManagedWidget");
+ widget = _XtCreateWidget((String)name, widget_class, parent, args,
+ num_args, (XtTypedArgList)NULL, (Cardinal) 0);
+ XtManageChild(widget);
+ UNLOCK_APP(app);
+ return widget;
+}
+
+static void
+popupPostProc(Widget w)
+{
+ Widget parent = XtParent(w);
+
+ parent->core.popup_list =
+ (WidgetList) XtRealloc((char*) parent->core.popup_list,
+ (unsigned) (parent->core.num_popups+1) * sizeof(Widget));
+ parent->core.popup_list[parent->core.num_popups++] = w;
+}
+
+Widget
+_XtCreatePopupShell(
+ String name,
+ WidgetClass widget_class,
+ Widget parent,
+ ArgList args,
+ Cardinal num_args,
+ XtTypedArgList typed_args,
+ Cardinal num_typed_args)
+{
+ register Widget widget;
+ Screen* default_screen;
+
+ if (parent == NULL) {
+ XtErrorMsg("invalidParent",XtNxtCreatePopupShell,XtCXtToolkitError,
+ "XtCreatePopupShell requires non-NULL parent",
+ (String *)NULL, (Cardinal *)NULL);
+ } else if (widget_class == NULL) {
+ XtAppErrorMsg(XtWidgetToApplicationContext(parent),
+ "invalidClass",XtNxtCreatePopupShell,XtCXtToolkitError,
+ "XtCreatePopupShell requires non-NULL widget class",
+ (String *)NULL, (Cardinal *)NULL);
+ }
+ XtCheckSubclass(parent, coreWidgetClass, "in XtCreatePopupShell");
+ default_screen = parent->core.screen;
+ widget = xtCreate(name, (char *)NULL, widget_class, parent,
+ default_screen, args, num_args, typed_args,
+ num_typed_args, (ConstraintWidgetClass)NULL,
+ popupPostProc);
+
+#ifndef X_NO_RESOURCE_CONFIGURATION_MANAGEMENT
+ XtAddEventHandler (widget, (EventMask) PropertyChangeMask, FALSE,
+ (XtEventHandler) _XtResourceConfigurationEH, NULL);
+#endif
+ return(widget);
+}
+
+Widget
+XtCreatePopupShell(
+ _Xconst char* name,
+ WidgetClass widget_class,
+ Widget parent,
+ ArgList args,
+ Cardinal num_args
+ )
+{
+ Widget retval;
+ WIDGET_TO_APPCON(parent);
+
+ LOCK_APP(app);
+ retval = _XtCreatePopupShell((String)name, widget_class, parent, args,
+ num_args, (XtTypedArgList)NULL, (Cardinal)0);
+ UNLOCK_APP(app);
+ return retval;
+}
+
+Widget
+_XtAppCreateShell(
+ String name,
+ String class,
+ WidgetClass widget_class,
+ Display* display,
+ ArgList args,
+ Cardinal num_args,
+ XtTypedArgList typed_args,
+ Cardinal num_typed_args)
+{
+ Widget shell;
+
+ if (widget_class == NULL) {
+ XtAppErrorMsg(XtDisplayToApplicationContext(display),
+ "invalidClass","xtAppCreateShell",XtCXtToolkitError,
+ "XtAppCreateShell requires non-NULL widget class",
+ (String *)NULL, (Cardinal *)NULL);
+ }
+ if (name == NULL)
+ name = XrmNameToString(_XtGetPerDisplay(display)->name);
+ shell = xtCreate(name, class, widget_class, (Widget)NULL,
+ (Screen*)DefaultScreenOfDisplay(display),
+ args, num_args, typed_args, num_typed_args,
+ (ConstraintWidgetClass) NULL, _XtAddShellToHookObj);
+
+#ifndef X_NO_RESOURCE_CONFIGURATION_MANAGEMENT
+ XtAddEventHandler (shell, (EventMask) PropertyChangeMask, FALSE,
+ (XtEventHandler) _XtResourceConfigurationEH, NULL);
+#endif
+
+ return shell;
+}
+
+Widget
+XtAppCreateShell(
+ _Xconst char* name,
+ _Xconst char* class,
+ WidgetClass widget_class,
+ Display *display,
+ ArgList args,
+ Cardinal num_args
+ )
+{
+ Widget retval;
+ DPY_TO_APPCON(display);
+
+ LOCK_APP(app);
+ retval = _XtAppCreateShell((String)name, (String)class, widget_class,
+ display, args, num_args, (XtTypedArgList)NULL, (Cardinal)0);
+ UNLOCK_APP(app);
+ return retval;
+}
+
+/* ARGSUSED */
+Widget
+XtCreateApplicationShell(
+ _Xconst char* name, /* unused in R3 and later */
+ WidgetClass widget_class,
+ ArgList args,
+ Cardinal num_args
+ )
+{
+ Widget retval;
+ Display* dpy;
+ XrmClass class;
+ XtAppContext app = _XtDefaultAppContext();
+
+ LOCK_APP(app);
+ dpy = app->list[0];
+ class = _XtGetPerDisplay(dpy)->class;
+
+ retval = _XtAppCreateShell((String)NULL, XrmQuarkToString((XrmQuark)class),
+ widget_class, dpy, args, num_args,
+ (XtTypedArgList)NULL, (Cardinal)0);
+ UNLOCK_APP(app);
+ return retval;
+}
+
+Widget
+_XtCreateHookObj(Screen* screen)
+{
+ Widget req_widget;
+ double widget_cache[100];
+ Cardinal wsize = 0;
+ Widget hookobj = xtWidgetAlloc(hookObjectClass,
+ (ConstraintWidgetClass)NULL,
+ (Widget)NULL, "hooks",
+ (ArgList)NULL, (Cardinal)0,
+ (XtTypedArgList)NULL, (Cardinal)0);
+
+ ((HookObject)hookobj)->hooks.screen = screen;
+ (void) _XtGetResources(hookobj, (ArgList)NULL, 0,
+ (XtTypedArgList)NULL, &wsize);
+ CompileCallbacks(hookobj);
+ wsize = hookObjectClass->core_class.widget_size;
+ req_widget = (Widget) XtStackAlloc(wsize, widget_cache);
+ (void) memmove ((char *) req_widget, (char *) hookobj, (int) wsize);
+ CallInitialize (hookObjectClass, req_widget, hookobj,
+ (ArgList)NULL, (Cardinal) 0);
+ XtStackFree((XtPointer)req_widget, widget_cache);
+ return hookobj;
+}
diff --git a/nx-X11/lib/Xt/CreateI.h b/nx-X11/lib/Xt/CreateI.h
new file mode 100644
index 000000000..87abb1d2d
--- /dev/null
+++ b/nx-X11/lib/Xt/CreateI.h
@@ -0,0 +1,37 @@
+/* $XFree86$ */
+
+#ifndef _XtcreateI_h
+#define _XtcreateI_h
+
+extern Widget _XtCreateWidget(String name, WidgetClass widget_class,
+ Widget parent, ArgList args, Cardinal num_args,
+ XtTypedArgList typed_args,
+ Cardinal num_typed_args);
+extern Widget _XtCreatePopupShell(String name, WidgetClass widget_class,
+ Widget parent, ArgList args,
+ Cardinal num_args, XtTypedArgList typed_args,
+ Cardinal num_typed_args);
+extern Widget _XtAppCreateShell(String name, String class,
+ WidgetClass widget_class, Display *display,
+ ArgList args, Cardinal num_args,
+ XtTypedArgList typed_args,
+ Cardinal num_typed_args);
+extern Widget _XtCreateHookObj(Screen *screen);
+
+
+#include <stdarg.h>
+
+/* VarCreate.c */
+extern Widget _XtVaOpenApplication(XtAppContext *app_context_return,
+ _Xconst char* application_class,
+ XrmOptionDescList options, Cardinal num_options,
+ int *argc_in_out, String *argv_in_out,
+ String *fallback_resources, WidgetClass widget_class,
+ va_list var_args);
+extern Widget _XtVaAppInitialize(XtAppContext *app_context_return,
+ _Xconst char* application_class,
+ XrmOptionDescList options, Cardinal num_options,
+ int *argc_in_out, String *argv_in_out,
+ String *fallback_resources, va_list var_args);
+
+#endif /* _XtcreateI_h */
diff --git a/nx-X11/lib/Xt/Destroy.c b/nx-X11/lib/Xt/Destroy.c
new file mode 100644
index 000000000..60f1b277f
--- /dev/null
+++ b/nx-X11/lib/Xt/Destroy.c
@@ -0,0 +1,374 @@
+/* $Xorg: Destroy.c,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/Destroy.c,v 1.2 2001/08/22 22:52:18 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+
+struct _DestroyRec {
+ int dispatch_level;
+ Widget widget;
+};
+
+static void Recursive(Widget widget, XtWidgetProc proc)
+{
+ register Cardinal i;
+ CompositePart *cwp;
+
+ /* Recurse down normal children */
+ if (XtIsComposite(widget)) {
+ cwp = &(((CompositeWidget) widget)->composite);
+ for (i = 0; i < cwp->num_children; i++) {
+ Recursive(cwp->children[i], proc);
+ }
+ }
+
+ /* Recurse down popup children */
+ if (XtIsWidget(widget)) {
+ for (i = 0; i < widget->core.num_popups; i++) {
+ Recursive(widget->core.popup_list[i], proc);
+ }
+ }
+
+ /* Finally, apply procedure to this widget */
+ (*proc) (widget);
+} /* Recursive */
+
+static void Phase1Destroy (Widget widget)
+{
+ Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
+
+ widget->core.being_destroyed = TRUE;
+ if (XtHasCallbacks(hookobj, XtNdestroyHook) == XtCallbackHasSome) {
+ XtDestroyHookDataRec call_data;
+
+ call_data.type = XtHdestroy;
+ call_data.widget = widget;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.destroyhook_callbacks,
+ (XtPointer) &call_data);
+ }
+} /* Phase1Destroy */
+
+static void Phase2Callbacks(Widget widget)
+{
+ if (widget->core.destroy_callbacks != NULL) {
+ XtCallCallbackList(widget,
+ widget->core.destroy_callbacks, (XtPointer) NULL);
+ }
+} /* Phase2Callbacks */
+
+static void Phase2Destroy(register Widget widget)
+{
+ register WidgetClass class;
+ register ConstraintWidgetClass cwClass;
+ ObjectClassExtension ext;
+
+ /* Call constraint destroy procedures */
+ if (XtParent(widget) != NULL && !XtIsShell(widget) && XtIsConstraint(XtParent(widget))) {
+ LOCK_PROCESS;
+ cwClass = (ConstraintWidgetClass)XtParent(widget)->core.widget_class;
+ UNLOCK_PROCESS;
+ for (;;) {
+ XtWidgetProc destroy;
+
+ LOCK_PROCESS;
+ destroy = cwClass->constraint_class.destroy;
+ UNLOCK_PROCESS;
+ if (destroy)
+ (*destroy) (widget);
+ if (cwClass == (ConstraintWidgetClass)constraintWidgetClass) break;
+ LOCK_PROCESS;
+ cwClass = (ConstraintWidgetClass) cwClass->core_class.superclass;
+ UNLOCK_PROCESS;
+ }
+ }
+
+ /* Call widget destroy procedures */
+ LOCK_PROCESS;
+ for (class = widget->core.widget_class;
+ class != NULL;
+ class = class->core_class.superclass) {
+ XtWidgetProc destroy;
+
+ destroy = class->core_class.destroy;
+ UNLOCK_PROCESS;
+ if (destroy)
+ (*destroy) (widget);
+ LOCK_PROCESS;
+ }
+
+ /* Call widget deallocate procedure */
+ ext = (ObjectClassExtension)
+ XtGetClassExtension(widget->core.widget_class,
+ XtOffsetOf(CoreClassPart, extension),
+ NULLQUARK, XtObjectExtensionVersion,
+ sizeof(ObjectClassExtensionRec));
+ if (ext && ext->deallocate) {
+ XtDeallocateProc deallocate;
+ deallocate = ext->deallocate;
+ UNLOCK_PROCESS;
+ (*deallocate)(widget, NULL);
+ } else {
+ UNLOCK_PROCESS;
+ XtFree((char *)widget);
+ }
+} /* Phase2Destroy */
+
+static Boolean IsDescendant(Widget widget, Widget root)
+{
+ while ((widget = XtParent(widget)) != root) {
+ if (widget == NULL) return False;
+ }
+ return True;
+}
+
+static void XtPhase2Destroy (Widget widget)
+{
+ Display *display = NULL;
+ Window window;
+ Widget parent;
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+ Widget outerInPhase2Destroy = app->in_phase2_destroy;
+ int starting_count = app->destroy_count;
+ Boolean isPopup = False;
+
+ /* invalidate focus trace cache for this display */
+ _XtGetPerDisplay(XtDisplayOfObject(widget))->pdi.traceDepth = 0;
+
+ parent = widget->core.parent;
+
+ if (parent && XtIsWidget(parent) && parent->core.num_popups) {
+ Cardinal i;
+ for (i = 0; i < parent->core.num_popups; i++) {
+ if (parent->core.popup_list[i] == widget) {
+ isPopup = True;
+ break;
+ }
+ }
+ }
+
+ if (!isPopup && parent && XtIsComposite(parent)) {
+ XtWidgetProc delete_child;
+
+ LOCK_PROCESS;
+ delete_child =
+ ((CompositeWidgetClass) parent->core.widget_class)->
+ composite_class.delete_child;
+ UNLOCK_PROCESS;
+ if (XtIsRectObj(widget)) {
+ XtUnmanageChild(widget);
+ }
+ if (delete_child == NULL) {
+ String param;
+ Cardinal num_params = 1;
+
+ LOCK_PROCESS;
+ param = parent->core.widget_class->core_class.class_name;
+ UNLOCK_PROCESS;
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "invalidProcedure","deleteChild",XtCXtToolkitError,
+ "null delete_child procedure for class %s in XtDestroy",
+ &param, &num_params);
+ } else {
+ (*delete_child) (widget);
+ }
+ }
+
+ /* widget is freed in Phase2Destroy, so retrieve window now.
+ * Shells destroy their own windows, to prevent window leaks in
+ * popups; this test is practical only when XtIsShell() is cheap.
+ */
+ if (XtIsShell(widget) || !XtIsWidget(widget)) {
+ window = 0;
+ }
+ else {
+ display = XtDisplay(widget);
+ window = widget->core.window;
+ }
+
+ Recursive(widget, Phase2Callbacks);
+ if (app->destroy_count > starting_count) {
+ int i = starting_count;
+ while (i < app->destroy_count) {
+
+ DestroyRec * dr = app->destroy_list + i;
+ if (IsDescendant(dr->widget, widget)) {
+ Widget descendant = dr->widget;
+ register int j;
+ app->destroy_count--;
+ for (j = app->destroy_count - i; --j >= 0; dr++)
+ *dr = *(dr + 1);
+ XtPhase2Destroy(descendant);
+ }
+ else i++;
+ }
+ }
+
+ app->in_phase2_destroy = widget;
+ Recursive(widget, Phase2Destroy);
+ app->in_phase2_destroy = outerInPhase2Destroy;
+
+ if (isPopup) {
+ Cardinal i;
+ for (i = 0; i < parent->core.num_popups; i++)
+ if (parent->core.popup_list[i] == widget) {
+ parent->core.num_popups--;
+ while (i < parent->core.num_popups) {
+ parent->core.popup_list[i] = parent->core.popup_list[i+1];
+ i++;
+ }
+ break;
+ }
+ }
+
+ /* %%% the following parent test hides a more serious problem,
+ but it avoids breaking those who depended on the old bug
+ until we have time to fix it properly. */
+
+ if (window && (parent == NULL || !parent->core.being_destroyed))
+ XDestroyWindow(display, window);
+} /* XtPhase2Destroy */
+
+
+void _XtDoPhase2Destroy(XtAppContext app, int dispatch_level)
+{
+ /* Phase 2 must occur in fifo order. List is not necessarily
+ * contiguous in dispatch_level.
+ */
+
+ int i = 0;
+ while (i < app->destroy_count) {
+
+ /* XtPhase2Destroy can result in calls to XtDestroyWidget,
+ * and these could cause app->destroy_list to be reallocated.
+ */
+
+ DestroyRec* dr = app->destroy_list + i;
+ if (dr->dispatch_level >= dispatch_level) {
+ Widget w = dr->widget;
+ register int j;
+ app->destroy_count--;
+ for (j = app->destroy_count - i; --j >=0; dr++)
+ *dr = *(dr + 1);
+ XtPhase2Destroy(w);
+ }
+ else i++;
+ }
+}
+
+
+void XtDestroyWidget (Widget widget)
+{
+ XtAppContext app;
+ DestroyRec *dr, *dr2;
+
+ app = XtWidgetToApplicationContext(widget);
+ LOCK_APP(app);
+ if (widget->core.being_destroyed) {
+ UNLOCK_APP(app);
+ return;
+ }
+ Recursive(widget, Phase1Destroy);
+
+ if (app->in_phase2_destroy &&
+ IsDescendant(widget, app->in_phase2_destroy))
+ {
+ XtPhase2Destroy(widget);
+ UNLOCK_APP(app);
+ return;
+ }
+
+ if (app->destroy_count == app->destroy_list_size) {
+ app->destroy_list_size += 10;
+ app->destroy_list = (DestroyRec*)
+ XtRealloc( (char*)app->destroy_list,
+ (unsigned)sizeof(DestroyRec)*app->destroy_list_size
+ );
+ }
+ dr = app->destroy_list + app->destroy_count++;
+ dr->dispatch_level = app->dispatch_level;
+ dr->widget = widget;
+
+ if (app->dispatch_level > 1) {
+ int i;
+ for (i = app->destroy_count - 1; i;) {
+ /* this handles only one case of nesting difficulties */
+ dr = app->destroy_list + (--i);
+ if (dr->dispatch_level < app->dispatch_level &&
+ IsDescendant(dr->widget, widget)) {
+ dr2 = app->destroy_list + (app->destroy_count-1);
+ dr2->dispatch_level = dr->dispatch_level;
+ break;
+ }
+ }
+ }
+
+ if (_XtSafeToDestroy(app)) {
+ app->dispatch_level = 1; /* avoid nested _XtDoPhase2Destroy */
+ _XtDoPhase2Destroy(app, 0);
+ app->dispatch_level = 0;
+ }
+ UNLOCK_APP(app);
+
+} /* XtDestroyWidget */
diff --git a/nx-X11/lib/Xt/Display.c b/nx-X11/lib/Xt/Display.c
new file mode 100644
index 000000000..2812aa81e
--- /dev/null
+++ b/nx-X11/lib/Xt/Display.c
@@ -0,0 +1,763 @@
+/* $Xorg: Display.c,v 1.6 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/Display.c,v 3.15 2002/09/18 01:25:01 dawes 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#ifndef X_NO_RESOURCE_CONFIGURATION_MANAGEMENT
+#include "ResConfigP.h"
+#endif
+
+#include <stdlib.h>
+
+#ifdef XTHREADS
+void (*_XtProcessLock)(void) = NULL;
+void (*_XtProcessUnlock)(void) = NULL;
+void (*_XtInitAppLock)(XtAppContext) = NULL;
+#endif
+
+static String XtNnoPerDisplay = "noPerDisplay";
+
+ProcessContext _XtGetProcessContext(void)
+{
+ static ProcessContextRec processContextRec = {
+ (XtAppContext)NULL,
+ (XtAppContext)NULL,
+ (ConverterTable)NULL,
+ {(XtLanguageProc)NULL, (XtPointer)NULL}
+ };
+
+ return &processContextRec;
+}
+
+
+XtAppContext _XtDefaultAppContext(void)
+{
+ ProcessContext process = _XtGetProcessContext();
+ XtAppContext app;
+
+ LOCK_PROCESS;
+ if (process->defaultAppContext == NULL) {
+ process->defaultAppContext = XtCreateApplicationContext();
+ }
+ app = process->defaultAppContext;
+ UNLOCK_PROCESS;
+ return app;
+}
+
+static void AddToAppContext(
+ Display *d,
+ XtAppContext app)
+{
+#define DISPLAYS_TO_ADD 4
+
+ if (app->count >= app->max) {
+ app->max += DISPLAYS_TO_ADD;
+ app->list = (Display **) XtRealloc((char *)app->list,
+ (unsigned) app->max * sizeof(Display *));
+ }
+
+ app->list[app->count++] = d;
+ app->rebuild_fdlist = TRUE;
+#ifndef USE_POLL
+ if (ConnectionNumber(d) + 1 > app->fds.nfds) {
+ app->fds.nfds = ConnectionNumber(d) + 1;
+ }
+#else
+ app->fds.nfds++;
+#endif
+#undef DISPLAYS_TO_ADD
+}
+
+static void XtDeleteFromAppContext(
+ Display *d,
+ register XtAppContext app)
+{
+ register int i;
+
+ for (i = 0; i < app->count; i++) if (app->list[i] == d) break;
+
+ if (i < app->count) {
+ if (i <= app->last && app->last > 0) app->last--;
+ for (i++; i < app->count; i++) app->list[i-1] = app->list[i];
+ app->count--;
+ }
+ app->rebuild_fdlist = TRUE;
+#ifndef USE_POLL
+ if ((ConnectionNumber(d) + 1) == app->fds.nfds)
+ app->fds.nfds--;
+ else /* Unnecessary, just to be fool-proof */
+ FD_CLR(ConnectionNumber(d), &app->fds.rmask);
+#else
+ app->fds.nfds--;
+#endif
+}
+
+static XtPerDisplay NewPerDisplay(
+ Display *dpy)
+{
+ PerDisplayTablePtr pd;
+
+ pd = XtNew(PerDisplayTable);
+ LOCK_PROCESS;
+ pd->dpy = dpy;
+ pd->next = _XtperDisplayList;
+ _XtperDisplayList = pd;
+ UNLOCK_PROCESS;
+ return &(pd->perDpy);
+}
+
+static XtPerDisplay InitPerDisplay(
+ Display *dpy,
+ XtAppContext app,
+ _Xconst char * name,
+ _Xconst char * classname)
+{
+ XtPerDisplay pd;
+
+ AddToAppContext(dpy, app);
+
+ pd = NewPerDisplay(dpy);
+ _XtHeapInit(&pd->heap);
+ pd->destroy_callbacks = NULL;
+ pd->region = XCreateRegion();
+ pd->case_cvt = NULL;
+ pd->defaultKeycodeTranslator = XtTranslateKey;
+ pd->keysyms_serial = 0;
+ pd->keysyms = NULL;
+ XDisplayKeycodes(dpy, &pd->min_keycode, &pd->max_keycode);
+ pd->modKeysyms = NULL;
+ pd->modsToKeysyms = NULL;
+ pd->appContext = app;
+ pd->name = XrmStringToName(name);
+ pd->class = XrmStringToClass(classname);
+ pd->being_destroyed = False;
+ pd->GClist = NULL;
+ pd->pixmap_tab = NULL;
+ pd->language = NULL;
+ pd->rv = False;
+ pd->last_event.xany.serial = 0;
+ pd->last_timestamp = 0;
+ _XtAllocTMContext(pd);
+ pd->mapping_callbacks = NULL;
+
+ pd->pdi.grabList = NULL;
+ pd->pdi.trace = NULL;
+ pd->pdi.traceDepth = 0;
+ pd->pdi.traceMax = 0;
+ pd->pdi.focusWidget = NULL;
+ pd->pdi.activatingKey = 0;
+ pd->pdi.keyboard.grabType = XtNoServerGrab;
+ pd->pdi.pointer.grabType = XtNoServerGrab;
+ _XtAllocWWTable(pd);
+ pd->per_screen_db = (XrmDatabase *)__XtCalloc(ScreenCount(dpy),
+ sizeof(XrmDatabase));
+ pd->cmd_db = (XrmDatabase)NULL;
+ pd->server_db = (XrmDatabase)NULL;
+ pd->dispatcher_list = NULL;
+ pd->ext_select_list = NULL;
+ pd->ext_select_count = 0;
+ pd->hook_object = NULL;
+#if 0
+ pd->hook_object = _XtCreate("hooks", "Hooks", hookObjectClass,
+ (Widget)NULL, (Screen*)DefaultScreenOfDisplay(dpy),
+ (ArgList)NULL, 0, (XtTypedArgList)NULL, 0,
+ (ConstraintWidgetClass)NULL);
+#endif
+
+#ifndef X_NO_RESOURCE_CONFIGURATION_MANAGEMENT
+ pd->rcm_init = XInternAtom (dpy, RCM_INIT, 0);
+ pd->rcm_data = XInternAtom (dpy, RCM_DATA, 0);
+#endif
+
+ return pd;
+}
+
+Display *XtOpenDisplay(
+ XtAppContext app,
+ _Xconst char* displayName,
+ _Xconst char* applName,
+ _Xconst char* className,
+ XrmOptionDescRec *urlist,
+ Cardinal num_urs,
+ int *argc,
+ String *argv)
+{
+ Display *d;
+ XrmDatabase db = 0;
+ XtPerDisplay pd;
+ String language = NULL;
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ /* parse the command line for name, display, and/or language */
+ db = _XtPreparseCommandLine(urlist, num_urs, *argc, argv,
+ (String *)&applName,
+ (String *)(displayName ? NULL : &displayName),
+ (app->process->globalLangProcRec.proc ?
+ &language : NULL));
+ UNLOCK_PROCESS;
+ d = XOpenDisplay(displayName);
+
+ if (! applName && !(applName = getenv("RESOURCE_NAME"))) {
+ if (*argc > 0 && argv[0] && *argv[0]) {
+#ifdef WIN32
+ char *ptr = strrchr(argv[0], '\\');
+#else
+ char *ptr = strrchr(argv[0], '/');
+#endif
+#ifdef __UNIXOS2__
+ char *dot_ptr,*ptr2;
+ ptr2 = strrchr(argv[0],'\\');
+ if (ptr2 > ptr) ptr = ptr2;
+ dot_ptr = strrchr(argv[0],'.');
+ if (dot_ptr && (dot_ptr > ptr)) *dot_ptr='\0';
+#endif /* This will remove the .exe suffix under OS/2 */
+
+ if (ptr) applName = ++ptr;
+ else applName = argv[0];
+ } else
+ applName = "main";
+ }
+
+ if (d) {
+ pd = InitPerDisplay(d, app, applName, className);
+ pd->language = language;
+ _XtDisplayInitialize(d, pd, applName, urlist, num_urs, argc, argv);
+ } else {
+ int len;
+ displayName = XDisplayName(displayName);
+ len = strlen (displayName);
+ app->display_name_tried = (String) __XtMalloc (len + 1);
+ strncpy ((char*) app->display_name_tried, displayName, len + 1);
+ app->display_name_tried[len] = '\0';
+ }
+ if (db) XrmDestroyDatabase(db);
+ UNLOCK_APP(app);
+ return d;
+}
+
+Display *
+_XtAppInit(
+ XtAppContext * app_context_return,
+ String application_class,
+ XrmOptionDescRec *options,
+ Cardinal num_options,
+ int *argc_in_out,
+ String **argv_in_out,
+ String * fallback_resources)
+{
+ String *saved_argv;
+ int i;
+ Display *dpy;
+
+/*
+ * Save away argv and argc so we can set the properties later
+ */
+
+ saved_argv = (String *)
+ __XtMalloc( (Cardinal)((*argc_in_out + 1) * sizeof(String)) );
+
+ for (i = 0 ; i < *argc_in_out ; i++) saved_argv[i] = (*argv_in_out)[i];
+ saved_argv[i] = NULL; /* NULL terminate that sucker. */
+
+
+ *app_context_return = XtCreateApplicationContext();
+
+ LOCK_APP((*app_context_return));
+ if (fallback_resources) /* save a procedure call */
+ XtAppSetFallbackResources(*app_context_return, fallback_resources);
+
+ dpy = XtOpenDisplay(*app_context_return, (String) NULL, NULL,
+ application_class,
+ options, num_options, argc_in_out, *argv_in_out);
+
+ if (!dpy) {
+ String param = (*app_context_return)->display_name_tried;
+ Cardinal param_count = 1;
+ XtErrorMsg("invalidDisplay","xtInitialize",XtCXtToolkitError,
+ "Can't open display: %s", &param, &param_count);
+ XtFree((char *) (*app_context_return)->display_name_tried);
+ }
+ *argv_in_out = saved_argv;
+ UNLOCK_APP((*app_context_return));
+ return dpy;
+}
+
+void
+XtDisplayInitialize(
+ XtAppContext app,
+ Display *dpy,
+ _Xconst char* name,
+ _Xconst char* classname,
+ XrmOptionDescRec *urlist,
+ Cardinal num_urs,
+ int *argc,
+ String *argv
+ )
+{
+ XtPerDisplay pd;
+ XrmDatabase db = 0;
+
+ LOCK_APP(app);
+ pd = InitPerDisplay(dpy, app, name, classname);
+ LOCK_PROCESS;
+ if (app->process->globalLangProcRec.proc)
+ /* pre-parse the command line for the language resource */
+ db = _XtPreparseCommandLine(urlist, num_urs, *argc, argv, NULL, NULL,
+ &pd->language);
+ UNLOCK_PROCESS;
+ _XtDisplayInitialize(dpy, pd, name, urlist, num_urs, argc, argv);
+ if (db) XrmDestroyDatabase(db);
+ UNLOCK_APP(app);
+}
+
+XtAppContext XtCreateApplicationContext(void)
+{
+ XtAppContext app = XtNew(XtAppStruct);
+#ifdef XTHREADS
+ app->lock_info = NULL;
+ app->lock = NULL;
+ app->unlock = NULL;
+ app->yield_lock = NULL;
+ app->restore_lock = NULL;
+ app->free_lock = NULL;
+#endif
+ INIT_APP_LOCK(app);
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ app->process = _XtGetProcessContext();
+ app->next = app->process->appContextList;
+ app->process->appContextList = app;
+ app->langProcRec.proc = app->process->globalLangProcRec.proc;
+ app->langProcRec.closure = app->process->globalLangProcRec.closure;
+ app->destroy_callbacks = NULL;
+ app->list = NULL;
+ app->count = app->max = app->last = 0;
+ app->timerQueue = NULL;
+ app->workQueue = NULL;
+ app->signalQueue = NULL;
+ app->input_list = NULL;
+ app->outstandingQueue = NULL;
+ app->errorDB = NULL;
+ _XtSetDefaultErrorHandlers(&app->errorMsgHandler,
+ &app->warningMsgHandler, &app->errorHandler,
+ &app->warningHandler);
+ app->action_table = NULL;
+ _XtSetDefaultSelectionTimeout(&app->selectionTimeout);
+ _XtSetDefaultConverterTable(&app->converterTable);
+ app->sync = app->being_destroyed = app->error_inited = FALSE;
+ app->in_phase2_destroy = NULL;
+#ifndef USE_POLL
+ FD_ZERO(&app->fds.rmask);
+ FD_ZERO(&app->fds.wmask);
+ FD_ZERO(&app->fds.emask);
+#endif
+ app->fds.nfds = 0;
+ app->input_count = app->input_max = 0;
+ _XtHeapInit(&app->heap);
+ app->fallback_resources = NULL;
+ _XtPopupInitialize(app);
+ app->action_hook_list = NULL;
+ app->block_hook_list = NULL;
+ app->destroy_list_size = app->destroy_count = app->dispatch_level = 0;
+ app->destroy_list = NULL;
+#ifndef NO_IDENTIFY_WINDOWS
+ app->identify_windows = False;
+#endif
+ app->free_bindings = NULL;
+ app->display_name_tried = NULL;
+ app->dpy_destroy_count = 0;
+ app->dpy_destroy_list = NULL;
+ app->exit_flag = FALSE;
+ app->rebuild_fdlist = TRUE;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return app;
+}
+
+void XtAppSetExitFlag (
+ XtAppContext app)
+{
+ LOCK_APP(app);
+ app->exit_flag = TRUE;
+ UNLOCK_APP(app);
+}
+
+Boolean XtAppGetExitFlag (
+ XtAppContext app)
+{
+ Boolean retval;
+ LOCK_APP(app);
+ retval = app->exit_flag;
+ UNLOCK_APP(app);
+ return retval;
+}
+
+static void DestroyAppContext(XtAppContext app)
+{
+ XtAppContext* prev_app;
+
+ prev_app = &app->process->appContextList;
+ while (app->count-- > 0) XtCloseDisplay(app->list[app->count]);
+ if (app->list != NULL) XtFree((char *)app->list);
+ _XtFreeConverterTable(app->converterTable);
+ _XtCacheFlushTag(app, (XtPointer)&app->heap);
+ _XtFreeActions(app->action_table);
+ if (app->destroy_callbacks != NULL) {
+ XtCallCallbackList((Widget) NULL,
+ (XtCallbackList)app->destroy_callbacks,
+ (XtPointer)app);
+ _XtRemoveAllCallbacks(&app->destroy_callbacks);
+ }
+ while (app->timerQueue) XtRemoveTimeOut((XtIntervalId)app->timerQueue);
+ while (app->workQueue) XtRemoveWorkProc((XtWorkProcId)app->workQueue);
+ while (app->signalQueue) XtRemoveSignal((XtSignalId)app->signalQueue);
+ if (app->input_list) _XtRemoveAllInputs(app);
+ XtFree((char*)app->destroy_list);
+ _XtHeapFree(&app->heap);
+ while (*prev_app != app) prev_app = &(*prev_app)->next;
+ *prev_app = app->next;
+ if (app->process->defaultAppContext == app)
+ app->process->defaultAppContext = NULL;
+ if (app->free_bindings) _XtDoFreeBindings (app);
+ FREE_APP_LOCK(app);
+ XtFree((char *)app);
+}
+
+static XtAppContext* appDestroyList = NULL;
+int _XtAppDestroyCount = 0;
+
+void XtDestroyApplicationContext(XtAppContext app)
+{
+ LOCK_APP(app);
+ if (app->being_destroyed) {
+ UNLOCK_APP(app);
+ return;
+ }
+
+ if (_XtSafeToDestroy(app)) {
+ LOCK_PROCESS;
+ DestroyAppContext(app);
+ UNLOCK_PROCESS;
+ } else {
+ app->being_destroyed = TRUE;
+ LOCK_PROCESS;
+ _XtAppDestroyCount++;
+ appDestroyList =
+ (XtAppContext *) XtRealloc((char *) appDestroyList,
+ (unsigned) (_XtAppDestroyCount * sizeof(XtAppContext)));
+ appDestroyList[_XtAppDestroyCount-1] = app;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ }
+}
+
+void _XtDestroyAppContexts(void)
+{
+ int i,ii;
+ XtAppContext apps[8];
+ XtAppContext* pApps;
+
+ pApps = XtStackAlloc (sizeof (XtAppContext) * _XtAppDestroyCount, apps);
+
+ for (i = ii = 0; i < _XtAppDestroyCount; i++) {
+ if (_XtSafeToDestroy(appDestroyList[i]))
+ DestroyAppContext(appDestroyList[i]);
+ else
+ pApps[ii++] = appDestroyList[i];
+ }
+ _XtAppDestroyCount = ii;
+ if (_XtAppDestroyCount == 0) {
+ XtFree((char *) appDestroyList);
+ appDestroyList = NULL;
+ } else {
+ for (i = 0; i < ii; i++)
+ appDestroyList[i] = pApps[i];
+ }
+ XtStackFree ((XtPointer) pApps, apps);
+}
+
+XrmDatabase XtDatabase(Display *dpy)
+{
+ XrmDatabase retval;
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ retval = XrmGetDatabase(dpy);
+ UNLOCK_APP(app);
+ return retval;
+}
+
+PerDisplayTablePtr _XtperDisplayList = NULL;
+
+XtPerDisplay _XtSortPerDisplayList(Display *dpy)
+{
+ register PerDisplayTablePtr pd, opd = NULL;
+
+ LOCK_PROCESS;
+ for (pd = _XtperDisplayList;
+ pd != NULL && pd->dpy != dpy;
+ pd = pd->next) {
+ opd = pd;
+ }
+
+ if (pd == NULL) {
+ XtErrorMsg(XtNnoPerDisplay, "getPerDisplay", XtCXtToolkitError,
+ "Couldn't find per display information",
+ (String *) NULL, (Cardinal *)NULL);
+ }
+
+ if (pd != _XtperDisplayList) { /* move it to the front */
+ /* opd points to the previous one... */
+
+ opd->next = pd->next;
+ pd->next = _XtperDisplayList;
+ _XtperDisplayList = pd;
+ }
+ UNLOCK_PROCESS;
+ return &(pd->perDpy);
+}
+
+XtAppContext XtDisplayToApplicationContext(Display *dpy)
+{
+ XtAppContext retval;
+
+ retval = _XtGetPerDisplay(dpy)->appContext;
+ return retval;
+}
+
+static void CloseDisplay(Display *dpy)
+{
+ register XtPerDisplay xtpd;
+ register PerDisplayTablePtr pd, opd = NULL;
+ XrmDatabase db;
+ int i;
+
+ XtDestroyWidget(XtHooksOfDisplay(dpy));
+
+ LOCK_PROCESS;
+ for (pd = _XtperDisplayList;
+ pd != NULL && pd->dpy != dpy;
+ pd = pd->next){
+ opd = pd;
+ }
+
+ if (pd == NULL) {
+ XtErrorMsg(XtNnoPerDisplay, "closeDisplay", XtCXtToolkitError,
+ "Couldn't find per display information",
+ (String *) NULL, (Cardinal *)NULL);
+ }
+
+ if (pd == _XtperDisplayList) _XtperDisplayList = pd->next;
+ else opd->next = pd->next;
+
+ xtpd = &(pd->perDpy);
+
+ if (xtpd != NULL) {
+ if (xtpd->destroy_callbacks != NULL) {
+ XtCallCallbackList((Widget) NULL,
+ (XtCallbackList)xtpd->destroy_callbacks,
+ (XtPointer)xtpd);
+ _XtRemoveAllCallbacks(&xtpd->destroy_callbacks);
+ }
+ if (xtpd->mapping_callbacks != NULL)
+ _XtRemoveAllCallbacks(&xtpd->mapping_callbacks);
+ XtDeleteFromAppContext(dpy, xtpd->appContext);
+ if (xtpd->keysyms)
+ XFree((char *) xtpd->keysyms);
+ XtFree((char *) xtpd->modKeysyms);
+ XtFree((char *) xtpd->modsToKeysyms);
+ xtpd->keysyms_per_keycode = 0;
+ xtpd->being_destroyed = FALSE;
+ xtpd->keysyms = NULL;
+ xtpd->modKeysyms = NULL;
+ xtpd->modsToKeysyms = NULL;
+ XDestroyRegion(xtpd->region);
+ _XtCacheFlushTag(xtpd->appContext, (XtPointer)&xtpd->heap);
+ _XtGClistFree(dpy, xtpd);
+ XtFree((char*)xtpd->pdi.trace);
+ _XtHeapFree(&xtpd->heap);
+ _XtFreeWWTable(xtpd);
+ xtpd->per_screen_db[DefaultScreen(dpy)] = (XrmDatabase)NULL;
+ for (i = ScreenCount(dpy); --i >= 0; ) {
+ db = xtpd->per_screen_db[i];
+ if (db)
+ XrmDestroyDatabase(db);
+ }
+ XtFree((char *)xtpd->per_screen_db);
+ if ((db = XrmGetDatabase(dpy)))
+ XrmDestroyDatabase(db);
+ if (xtpd->cmd_db)
+ XrmDestroyDatabase(xtpd->cmd_db);
+ if (xtpd->server_db)
+ XrmDestroyDatabase(xtpd->server_db);
+ XtFree(xtpd->language);
+ if (xtpd->dispatcher_list != NULL)
+ XtFree((char *) xtpd->dispatcher_list);
+ if (xtpd->ext_select_list != NULL)
+ XtFree((char *) xtpd->ext_select_list);
+ }
+ XtFree((char*)pd);
+ XrmSetDatabase(dpy, (XrmDatabase)NULL);
+ XCloseDisplay(dpy);
+ UNLOCK_PROCESS;
+}
+
+void XtCloseDisplay(Display *dpy)
+{
+ XtPerDisplay pd;
+ XtAppContext app = XtDisplayToApplicationContext(dpy);
+
+ LOCK_APP(app);
+ pd = _XtGetPerDisplay(dpy);
+ if (pd->being_destroyed) {
+ UNLOCK_APP(app);
+ return;
+ }
+
+ if (_XtSafeToDestroy(app)) CloseDisplay(dpy);
+ else {
+ pd->being_destroyed = TRUE;
+ app->dpy_destroy_count++;
+ app->dpy_destroy_list = (Display **)
+ XtRealloc((char *) app->dpy_destroy_list,
+ (unsigned) (app->dpy_destroy_count * sizeof(Display *)));
+ app->dpy_destroy_list[app->dpy_destroy_count-1] = dpy;
+ }
+ UNLOCK_APP(app);
+}
+
+void _XtCloseDisplays(XtAppContext app)
+{
+ int i;
+
+ LOCK_APP(app);
+ for (i = 0; i < app->dpy_destroy_count; i++) {
+ CloseDisplay(app->dpy_destroy_list[i]);
+ }
+ app->dpy_destroy_count = 0;
+ XtFree((char *) app->dpy_destroy_list);
+ app->dpy_destroy_list = NULL;
+ UNLOCK_APP(app);
+}
+
+XtAppContext XtWidgetToApplicationContext(Widget w)
+{
+ XtAppContext retval;
+
+ retval = _XtGetPerDisplay(XtDisplayOfObject(w))->appContext;
+ return retval;
+}
+
+
+void XtGetApplicationNameAndClass(
+ Display *dpy,
+ String *name_return,
+ String *class_return)
+{
+ XtPerDisplay pd;
+
+ pd = _XtGetPerDisplay(dpy);
+ *name_return = XrmQuarkToString(pd->name);
+ *class_return = XrmQuarkToString(pd->class);
+}
+
+XtPerDisplay _XtGetPerDisplay (Display* display)
+{
+ XtPerDisplay retval;
+
+ LOCK_PROCESS;
+ retval = ((_XtperDisplayList != NULL &&
+ _XtperDisplayList->dpy == display)
+ ? &_XtperDisplayList->perDpy
+ : _XtSortPerDisplayList(display));
+ UNLOCK_PROCESS;
+ return retval;
+}
+
+XtPerDisplayInputRec* _XtGetPerDisplayInput(Display* display)
+{
+ XtPerDisplayInputRec* retval;
+ LOCK_PROCESS;
+ retval = ((_XtperDisplayList != NULL &&
+ _XtperDisplayList->dpy == display)
+ ? &_XtperDisplayList->perDpy.pdi
+ : &_XtSortPerDisplayList(display)->pdi);
+ UNLOCK_PROCESS;
+ return retval;
+}
+
+void XtGetDisplays(
+ XtAppContext app_context,
+ Display*** dpy_return,
+ Cardinal* num_dpy_return)
+{
+ int ii;
+ LOCK_APP(app_context);
+ *num_dpy_return = app_context->count;
+ *dpy_return = (Display**)__XtMalloc(app_context->count * sizeof(Display*));
+ for (ii = 0; ii < app_context->count; ii++)
+ (*dpy_return)[ii] = app_context->list[ii];
+ UNLOCK_APP(app_context);
+}
diff --git a/nx-X11/lib/Xt/Error.c b/nx-X11/lib/Xt/Error.c
new file mode 100644
index 000000000..b1badc970
--- /dev/null
+++ b/nx-X11/lib/Xt/Error.c
@@ -0,0 +1,636 @@
+/* $Xorg: Error.c,v 1.5 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/Error.c,v 3.13tsi 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+/* The error handlers in the application context aren't used since we can't
+ come up with a uniform way of using them. If you can, define
+ GLOBALERRORS to be FALSE (or 0). */
+
+#ifndef GLOBALERRORS
+#define GLOBALERRORS 1
+#endif
+
+static void InitErrorHandling(XrmDatabase *);
+#if GLOBALERRORS
+static XrmDatabase errorDB = NULL;
+static Boolean error_inited = FALSE;
+void _XtDefaultErrorMsg(String, String, String, String, String*, Cardinal*);
+void _XtDefaultWarningMsg(String, String, String, String, String*, Cardinal*);
+void _XtDefaultError(String);
+void _XtDefaultWarning(String);
+static XtErrorMsgHandler errorMsgHandler = _XtDefaultErrorMsg;
+static XtErrorMsgHandler warningMsgHandler = _XtDefaultWarningMsg;
+static XtErrorHandler errorHandler = _XtDefaultError;
+static XtErrorHandler warningHandler = _XtDefaultWarning;
+#endif /* GLOBALERRORS */
+
+XrmDatabase *XtGetErrorDatabase(void)
+{
+ XrmDatabase* retval;
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ retval = &errorDB;
+ UNLOCK_PROCESS;
+#else
+ retval = XtAppGetErrorDatabase(_XtDefaultAppContext());
+#endif /* GLOBALERRORS */
+ return retval;
+}
+
+XrmDatabase *XtAppGetErrorDatabase(
+ XtAppContext app)
+{
+ XrmDatabase* retval;
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ retval = &errorDB;
+ UNLOCK_PROCESS;
+#else
+ LOCK_APP(app);
+ retval= &app->errorDB;
+ UNLOCK_APP(app);
+#endif /* GLOBALERRORS */
+ return retval;
+}
+
+void XtGetErrorDatabaseText(
+ register _Xconst char* name,
+ register _Xconst char* type,
+ register _Xconst char* class,
+ _Xconst char* defaultp,
+ String buffer,
+ int nbytes)
+{
+#if GLOBALERRORS
+ XtAppGetErrorDatabaseText(NULL,
+ name,type,class,defaultp, buffer, nbytes, NULL);
+#else
+ XtAppGetErrorDatabaseText(_XtDefaultAppContext(),
+ name,type,class,defaultp, buffer, nbytes, NULL);
+#endif /* GLOBALERRORS */
+}
+
+void XtAppGetErrorDatabaseText(
+ XtAppContext app,
+ register _Xconst char* name,
+ register _Xconst char* type,
+ register _Xconst char* class,
+ _Xconst char* defaultp,
+ String buffer,
+ int nbytes,
+ XrmDatabase db)
+{
+ String str_class;
+ String type_str;
+ XrmValue result;
+ char *str_name = NULL;
+ char *temp = NULL;
+
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ if (error_inited == FALSE) {
+ InitErrorHandling (&errorDB);
+ error_inited = TRUE;
+ }
+#else
+ LOCK_APP(app);
+ if (app->error_inited == FALSE) {
+ InitErrorHandling (&app->errorDB);
+ app->error_inited = TRUE;
+ }
+#endif /* GLOBALERRORS */
+ if (!(str_name = ALLOCATE_LOCAL(strlen(name) + strlen(type) + 2)))
+ _XtAllocError(NULL);
+ (void) sprintf(str_name, "%s.%s", name, type);
+ /* XrmGetResource requires the name and class to be fully qualified
+ * and to have the same number of components. */
+ str_class = (char *)class;
+ if (! strchr(class, '.')) {
+ if (!(temp = ALLOCATE_LOCAL(2 * strlen(class) + 2)))
+ _XtAllocError(NULL);
+ (void) sprintf(temp, "%s.%s", class, class);
+ str_class = temp;
+ }
+ if (db == NULL) {
+#if GLOBALERRORS
+ (void) XrmGetResource(errorDB, str_name, str_class, &type_str,
+ &result);
+#else
+ (void) XrmGetResource(app->errorDB, str_name, str_class, &type_str,
+ &result);
+#endif /* GLOBALERRORS */
+ } else (void) XrmGetResource(db, str_name, str_class, &type_str, &result);
+ if (result.addr) {
+ (void) strncpy (buffer, result.addr, nbytes);
+ if (result.size > (unsigned) nbytes) buffer[nbytes-1] = 0;
+ } else {
+ int len = strlen(defaultp);
+ if (len >= nbytes) len = nbytes-1;
+ (void) memmove(buffer, defaultp, len);
+ buffer[len] = '\0';
+ }
+ if (str_name)
+ DEALLOCATE_LOCAL(str_name);
+ if (temp)
+ DEALLOCATE_LOCAL(temp);
+#if GLOBALERRORS
+ UNLOCK_PROCESS;
+#else
+ UNLOCK_APP(app);
+#endif
+}
+
+static void InitErrorHandling (
+ XrmDatabase *db)
+{
+ XrmDatabase errordb;
+
+ errordb = XrmGetFileDatabase(ERRORDB);
+ XrmMergeDatabases(errordb, db);
+}
+
+static void DefaultMsg (
+ String name,
+ String type,
+ String class,
+ String defaultp,
+ String* params,
+ Cardinal* num_params,
+ Bool error,
+ void (*fn)(_Xconst _XtString))
+{
+#define BIGBUF 1024
+#ifdef notyet /* older versions don't, might want to wait until more do */
+#if defined(__linux__) || defined(CSRG_BASED) /* everyone else needs to get with the program */
+#define USE_SNPRINTF
+#endif
+#endif
+ char buffer[BIGBUF];
+ char* message;
+ XtGetErrorDatabaseText(name,type,class,defaultp, buffer, BIGBUF);
+/*need better solution here, perhaps use lower level printf primitives? */
+ if (params == NULL || num_params == NULL || *num_params == 0)
+ (*fn)(buffer);
+#ifndef WIN32 /* and OS/2 */
+ else if ((getuid () != geteuid ()) || getuid() == 0) {
+ if ((error && errorHandler == _XtDefaultError) ||
+ (!error && warningHandler == _XtDefaultWarning)) {
+ /*
+ * if it's just going to go to stderr anyway, then we'll
+ * fprintf to stderr ourselves and skip the insecure sprintf.
+ */
+ Cardinal i = *num_params;
+ String par[10];
+ if (i > 10) i = 10;
+ (void) memmove((char*)par, (char*)params, i * sizeof(String) );
+ bzero( &par[i], (10-i) * sizeof(String) );
+ (void) fprintf (stderr, "%s%s",
+ error ? XTERROR_PREFIX : XTWARNING_PREFIX,
+ error ? "Error: " : "Warning: ");
+ (void) fprintf (stderr, buffer,
+ par[0], par[1], par[2], par[3], par[4],
+ par[5], par[6], par[7], par[8], par[9]);
+ (void) fprintf (stderr, "%c", '\n');
+ if (i != *num_params)
+ (*fn) ( "Some arguments in previous message were lost" );
+ else if (error) exit (1);
+ } else {
+ /*
+ * can't tell what it might do, so we'll play it safe
+ */
+ XtWarning ("\
+This program is an suid-root program or is being run by the root user.\n\
+The full text of the error or warning message cannot be safely formatted\n\
+in this environment. You may get a more descriptive message by running the\n\
+program as a non-root user or by removing the suid bit on the executable.");
+ (*fn)(buffer); /* if *fn is an ErrorHandler it should exit */
+ }
+ }
+#endif
+ else {
+ /*
+ * If you have snprintf the worst thing that could happen is you'd
+ * lose some information. Without snprintf you're probably going to
+ * scramble your heap and perhaps SEGV -- sooner or later.
+ * If it hurts when you go like this then don't go like this! :-)
+ */
+ Cardinal i = *num_params;
+ String par[10];
+ if (i > 10) i = 10;
+ (void) memmove((char*)par, (char*)params, i * sizeof(String) );
+ bzero( &par[i], (10-i) * sizeof(String) );
+ if (i != *num_params)
+ XtWarning( "Some arguments in following message were lost" );
+ /*
+ * resist any temptation you might have to make `message' a
+ * local buffer on the stack. Doing so is a security hole
+ * in programs executing as root. Error and Warning
+ * messages shouldn't be called frequently enough for this
+ * to be a performance issue.
+ */
+ if ((message = __XtMalloc (BIGBUF))) {
+#ifndef USE_SNPRINTF
+ message[BIGBUF-1] = 0;
+ (void) sprintf (message, buffer,
+#else
+ (void) snprintf (message, BIGBUF, buffer,
+#endif
+ par[0], par[1], par[2], par[3], par[4],
+ par[5], par[6], par[7], par[8], par[9]);
+#ifndef USE_SNPRINTF
+ if (message[BIGBUF-1] != '\0')
+ XtWarning ("Possible heap corruption in Xt{Error,Warning}MsgHandler");
+#endif
+ (*fn)(message);
+ XtFree(message);
+ } else {
+ XtWarning ("Memory allocation failed, arguments in the following message were lost");
+ (*fn)(buffer);
+ }
+ }
+}
+
+void _XtDefaultErrorMsg (
+ String name,
+ String type,
+ String class,
+ String defaultp,
+ String* params,
+ Cardinal* num_params)
+{
+ DefaultMsg (name,type,class,defaultp,params,num_params,True,XtError);
+}
+
+void _XtDefaultWarningMsg (
+ String name,
+ String type,
+ String class,
+ String defaultp,
+ String* params,
+ Cardinal* num_params)
+{
+ DefaultMsg (name,type,class,defaultp,params,num_params,False,XtWarning);
+}
+
+void XtErrorMsg(
+ _Xconst char* name,
+ _Xconst char* type,
+ _Xconst char* class,
+ _Xconst char* defaultp,
+ String* params,
+ Cardinal* num_params)
+{
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ (*errorMsgHandler)((String)name,(String)type,(String)class,
+ (String)defaultp,params,num_params);
+ UNLOCK_PROCESS;
+#else
+ XtAppErrorMsg(_XtDefaultAppContext(),name,type,class,
+ defaultp,params,num_params);
+#endif /* GLOBALERRORS */
+}
+
+void XtAppErrorMsg(
+ XtAppContext app,
+ _Xconst char* name,
+ _Xconst char* type,
+ _Xconst char* class,
+ _Xconst char* defaultp,
+ String* params,
+ Cardinal* num_params)
+{
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ (*errorMsgHandler)((String)name,(String)type,(String)class,
+ (String)defaultp,params,num_params);
+ UNLOCK_PROCESS;
+#else
+ LOCK_APP(app);
+ (*app->errorMsgHandler)(name,type,class,defaultp,params,num_params);
+ UNLOCK_APP(app);
+#endif /* GLOBALERRORS */
+}
+
+void XtWarningMsg(
+ _Xconst char* name,
+ _Xconst char* type,
+ _Xconst char* class,
+ _Xconst char* defaultp,
+ String* params,
+ Cardinal* num_params)
+{
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ (*warningMsgHandler)((String)name,(String)type,(String)class,
+ (String)defaultp,params,num_params);
+ UNLOCK_PROCESS;
+#else
+ XtAppWarningMsg(_XtDefaultAppContext(),name,type,class,
+ defaultp,params,num_params);
+#endif /* GLOBALERRORS */
+}
+
+void XtAppWarningMsg(
+ XtAppContext app,
+ _Xconst char* name,
+ _Xconst char* type,
+ _Xconst char* class,
+ _Xconst char* defaultp,
+ String* params,
+ Cardinal* num_params)
+{
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ (*warningMsgHandler)((String)name,(String)type,(String)class,
+ (String)defaultp,params,num_params);
+ UNLOCK_PROCESS;
+#else
+ LOCK_APP(app);
+ (*app->warningMsgHandler)(name,type,class,defaultp,params,num_params);
+ UNLOCK_APP(app);
+#endif /* GLOBALERRORS */
+}
+
+void XtSetErrorMsgHandler(
+ XtErrorMsgHandler handler)
+{
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ if (handler != NULL) errorMsgHandler = handler;
+ else errorMsgHandler = _XtDefaultErrorMsg;
+ UNLOCK_PROCESS;
+#else
+ XtAppSetErrorMsgHandler(_XtDefaultAppContext(), handler);
+#endif /* GLOBALERRORS */
+}
+
+XtErrorMsgHandler XtAppSetErrorMsgHandler(
+ XtAppContext app,
+ XtErrorMsgHandler handler)
+{
+ XtErrorMsgHandler old;
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ old = errorMsgHandler;
+ if (handler != NULL) errorMsgHandler = handler;
+ else errorMsgHandler = _XtDefaultErrorMsg;
+ UNLOCK_PROCESS;
+#else
+ LOCK_APP(app);
+ old = app->errorMsgHandler;
+ if (handler != NULL) app->errorMsgHandler = handler;
+ else app->errorMsgHandler = _XtDefaultErrorMsg;
+ UNLOCK_APP(app);
+#endif /* GLOBALERRORS */
+ return old;
+}
+
+void XtSetWarningMsgHandler(
+ XtErrorMsgHandler handler)
+{
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ if (handler != NULL) warningMsgHandler = handler;
+ else warningMsgHandler = _XtDefaultWarningMsg;
+ UNLOCK_PROCESS;
+#else
+ XtAppSetWarningMsgHandler(_XtDefaultAppContext(),handler);
+#endif /* GLOBALERRORS */
+}
+
+XtErrorMsgHandler XtAppSetWarningMsgHandler(
+ XtAppContext app,
+ XtErrorMsgHandler handler)
+{
+ XtErrorMsgHandler old;
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ old = warningMsgHandler;
+ if (handler != NULL) warningMsgHandler = handler;
+ else warningMsgHandler = _XtDefaultWarningMsg;
+ UNLOCK_PROCESS;
+#else
+ LOCK_APP(app);
+ old = app->warningMsgHandler;
+ if (handler != NULL) app->warningMsgHandler = handler;
+ else app->warningMsgHandler = _XtDefaultWarningMsg;
+ UNLOCK_APP(app);
+#endif /* GLOBALERRORS */
+ return old;
+}
+
+void _XtDefaultError(String message)
+{
+ if (message && *message)
+ (void)fprintf(stderr, "%sError: %s\n", XTERROR_PREFIX, message);
+ exit(1);
+}
+
+void _XtDefaultWarning(String message)
+{
+ if (message && *message)
+ (void)fprintf(stderr, "%sWarning: %s\n", XTWARNING_PREFIX, message);
+ return;
+}
+
+void XtError(
+ _Xconst char* message)
+{
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ (*errorHandler)((String)message);
+ UNLOCK_PROCESS;
+#else
+ XtAppError(_XtDefaultAppContext(),message);
+#endif /* GLOBALERRORS */
+}
+
+void XtAppError(
+ XtAppContext app,
+ _Xconst char* message)
+{
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ (*errorHandler)((String)message);
+ UNLOCK_PROCESS;
+#else
+ LOCK_APP(app);
+ (*app->errorHandler)(message);
+ UNLOCK_APP(app);
+#endif /* GLOBALERRORS */
+}
+
+void XtWarning(
+ _Xconst char* message)
+{
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ (*warningHandler)((String)message);
+ UNLOCK_PROCESS;
+#else
+ XtAppWarning(_XtDefaultAppContext(),message);
+#endif /* GLOBALERRORS */
+}
+
+void XtAppWarning(
+ XtAppContext app,
+ _Xconst char* message)
+{
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ (*warningHandler)((String)message);
+ UNLOCK_PROCESS;
+#else
+ LOCK_APP(app);
+ (*app->warningHandler)(message);
+ UNLOCK_APP(app);
+#endif /* GLOBALERRORS */
+}
+
+void XtSetErrorHandler(XtErrorHandler handler)
+{
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ if (handler != NULL) errorHandler = handler;
+ else errorHandler = _XtDefaultError;
+ UNLOCK_PROCESS;
+#else
+ XtAppSetErrorHandler(_XtDefaultAppContext(),handler);
+#endif /* GLOBALERRORS */
+}
+
+XtErrorHandler XtAppSetErrorHandler(
+ XtAppContext app,
+ XtErrorHandler handler)
+{
+ XtErrorHandler old;
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ old = errorHandler;
+ if (handler != NULL) errorHandler = handler;
+ else errorHandler = _XtDefaultError;
+ UNLOCK_PROCESS;
+#else
+ LOCK_APP(app);
+ old = app->errorHandler;
+ if (handler != NULL) app->errorHandler = handler;
+ else app->errorHandler = _XtDefaultError;
+ UNLOCK_APP(app);
+#endif /* GLOBALERRORS */
+ return old;
+}
+
+void XtSetWarningHandler(XtErrorHandler handler)
+{
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ if (handler != NULL) warningHandler = handler;
+ else warningHandler = _XtDefaultWarning;
+ UNLOCK_PROCESS;
+#else
+ XtAppSetWarningHandler(_XtDefaultAppContext(),handler);
+#endif /* GLOBALERRORS */
+}
+
+XtErrorHandler XtAppSetWarningHandler(
+ XtAppContext app,
+ XtErrorHandler handler)
+{
+ XtErrorHandler old;
+#if GLOBALERRORS
+ LOCK_PROCESS;
+ old = warningHandler;
+ if (handler != NULL) warningHandler = handler;
+ else warningHandler = _XtDefaultWarning;
+ UNLOCK_PROCESS;
+#else
+ LOCK_APP(app);
+ old = app->warningHandler;
+ if (handler != NULL) app->warningHandler = handler;
+ else app->warningHandler = _XtDefaultWarning;
+ UNLOCK_APP(app);
+#endif /* GLOBALERRORS */
+ return old;
+}
+
+void _XtSetDefaultErrorHandlers(
+ XtErrorMsgHandler *errMsg,
+ XtErrorMsgHandler *warnMsg,
+ XtErrorHandler *err,
+ XtErrorHandler *warn)
+{
+#ifndef GLOBALERRORS
+ LOCK_PROCESS;
+ *errMsg = _XtDefaultErrorMsg;
+ *warnMsg = _XtDefaultWarningMsg;
+ *err = _XtDefaultError;
+ *warn = _XtDefaultWarning;
+ UNLOCK_PROCESS;
+#endif /* GLOBALERRORS */
+}
diff --git a/nx-X11/lib/Xt/Event.c b/nx-X11/lib/Xt/Event.c
new file mode 100644
index 000000000..1d564f970
--- /dev/null
+++ b/nx-X11/lib/Xt/Event.c
@@ -0,0 +1,1731 @@
+/* $Xorg: Event.c,v 1.5 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+/* $XFree86: xc/lib/Xt/Event.c,v 3.10 2001/12/14 19:56:11 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "Shell.h"
+#include "StringDefs.h"
+
+typedef struct _XtEventRecExt {
+ int type;
+ XtPointer select_data[1]; /* actual dimension is [mask] */
+} XtEventRecExt;
+
+#define EXT_TYPE(p) (((XtEventRecExt*) ((p)+1))->type)
+#define EXT_SELECT_DATA(p,n) (((XtEventRecExt*) ((p)+1))->select_data[n])
+
+#define NonMaskableMask ((EventMask)0x80000000L)
+
+/*
+ * These are definitions to make the code that handles exposure compresssion
+ * easier to read.
+ *
+ * COMP_EXPOSE - The compression exposure field of "widget"
+ * COMP_EXPOSE_TYPE - The type of compression (lower 4 bits of COMP_EXPOSE.
+ * GRAPHICS_EXPOSE - TRUE if the widget wants graphics expose events
+ * dispatched.
+ * NO_EXPOSE - TRUE if the widget wants No expose events dispatched.
+ */
+
+#define COMP_EXPOSE (widget->core.widget_class->core_class.compress_exposure)
+#define COMP_EXPOSE_TYPE (COMP_EXPOSE & 0x0f)
+#define GRAPHICS_EXPOSE ((XtExposeGraphicsExpose & COMP_EXPOSE) || \
+ (XtExposeGraphicsExposeMerged & COMP_EXPOSE))
+#define NO_EXPOSE (XtExposeNoExpose & COMP_EXPOSE)
+
+EventMask XtBuildEventMask(
+ Widget widget)
+{
+ XtEventTable ev;
+ EventMask mask = 0L;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ for (ev = widget->core.event_table; ev != NULL; ev = ev->next)
+ if (ev->select) {
+ if (!ev->has_type_specifier)
+ mask |= ev->mask;
+ else {
+ if (EXT_TYPE(ev) < LASTEvent) {
+ Cardinal i;
+ for (i = 0; i < ev->mask; i++)
+ if (EXT_SELECT_DATA(ev, i))
+ mask |= *(EventMask*)EXT_SELECT_DATA(ev, i);
+ }
+ }
+ }
+ LOCK_PROCESS;
+ if (widget->core.widget_class->core_class.expose != NULL)
+ mask |= ExposureMask;
+ if (widget->core.widget_class->core_class.visible_interest)
+ mask |= VisibilityChangeMask;
+ UNLOCK_PROCESS;
+ if (widget->core.tm.translations)
+ mask |= widget->core.tm.translations->eventMask;
+
+ mask = mask & ~NonMaskableMask;
+ UNLOCK_APP(app);
+ return mask;
+}
+
+static void CallExtensionSelector(
+ Widget widget,
+ ExtSelectRec* rec,
+ Boolean forceCall)
+{
+ XtEventRec* p;
+ XtPointer* data;
+ int* types;
+ Cardinal i, count = 0;
+
+ for (p = widget->core.event_table; p != NULL; p = p->next)
+ if (p->has_type_specifier &&
+ EXT_TYPE(p) >= rec->min && EXT_TYPE(p) <= rec->max)
+ count += p->mask;
+
+ if (count == 0 && !forceCall) return;
+
+ data = (XtPointer *) ALLOCATE_LOCAL(count * sizeof (XtPointer));
+ types = (int *) ALLOCATE_LOCAL(count * sizeof (int));
+ count = 0;
+
+ for (p = widget->core.event_table; p != NULL; p = p->next)
+ if (p->has_type_specifier &&
+ EXT_TYPE(p) >= rec->min && EXT_TYPE(p) <= rec->max)
+ for (i =0; i < p->mask; i++) {
+ types[count] = EXT_TYPE(p);
+ data[count++] = EXT_SELECT_DATA(p, i);
+ }
+
+ (*rec->proc)(widget, types, data, count, rec->client_data);
+ DEALLOCATE_LOCAL((char*) types);
+ DEALLOCATE_LOCAL((char*) data);
+}
+
+static void
+RemoveEventHandler(
+ Widget widget,
+ XtPointer select_data,
+ int type,
+ Boolean has_type_specifier,
+ Boolean other,
+ XtEventHandler proc,
+ XtPointer closure,
+ Boolean raw)
+{
+ XtEventRec *p, **pp;
+ EventMask eventMask, oldMask = XtBuildEventMask(widget);
+
+ if (raw) raw = 1;
+ pp = &widget->core.event_table;
+ while ((p = *pp) &&
+ (p->proc != proc || p->closure != closure || p->select == raw ||
+ has_type_specifier != p->has_type_specifier ||
+ (has_type_specifier && EXT_TYPE(p) != type)))
+ pp = &p->next;
+ if (!p) return;
+
+ /* un-register it */
+ if (!has_type_specifier) {
+ eventMask = *(EventMask*)select_data;
+ eventMask &= ~NonMaskableMask;
+ if (other)
+ eventMask |= NonMaskableMask;
+ p->mask &= ~eventMask;
+ } else {
+ Cardinal i;
+ /* p->mask specifies count of EXT_SELECT_DATA(p,i)
+ * search through the list of selection data, if not found
+ * dont remove this handler
+ */
+ for (i = 0; i < p->mask && select_data != EXT_SELECT_DATA(p,i);) i++;
+ if (i == p->mask) return;
+ if (p->mask == 1) p->mask = 0;
+ else {
+ p->mask--;
+ while (i < p->mask) {
+ EXT_SELECT_DATA(p,i) = EXT_SELECT_DATA(p, i+1);
+ i++;
+ }
+ }
+ }
+
+ if (!p->mask) { /* delete it entirely */
+ *pp = p->next;
+ XtFree((char *)p);
+ }
+
+ /* Reset select mask if realized and not raw. */
+ if ( !raw && XtIsRealized(widget) && !widget->core.being_destroyed) {
+ EventMask mask = XtBuildEventMask(widget);
+ Display* dpy = XtDisplay (widget);
+
+ if (oldMask != mask)
+ XSelectInput(dpy, XtWindow(widget), mask);
+
+ if (has_type_specifier) {
+ XtPerDisplay pd = _XtGetPerDisplay(dpy);
+ int i;
+ for (i = 0; i < pd->ext_select_count; i++) {
+ if (type >= pd->ext_select_list[i].min &&
+ type <= pd->ext_select_list[i].max) {
+ CallExtensionSelector(widget, pd->ext_select_list+i, TRUE);
+ break;
+ }
+ if (type < pd->ext_select_list[i].min) break;
+ }
+ }
+ }
+}
+
+/* Function Name: AddEventHandler
+ * Description: An Internal routine that does the actual work of
+ * adding the event handlers.
+ * Arguments: widget - widget to register an event handler for.
+ * eventMask - events to mask for.
+ * other - pass non maskable events to this proceedure.
+ * proc - proceedure to register.
+ * closure - data to pass to the event hander.
+ * position - where to add this event handler.
+ * force_new_position - If the element is already in the
+ * list, this will force it to the
+ * beginning or end depending on position.
+ * raw - If FALSE call XSelectInput for events in mask.
+ * Returns: none
+ */
+
+static void
+AddEventHandler(
+ Widget widget,
+ XtPointer select_data,
+ int type,
+ Boolean has_type_specifier,
+ Boolean other,
+ XtEventHandler proc,
+ XtPointer closure,
+ XtListPosition position,
+ Boolean force_new_position,
+ Boolean raw)
+{
+ register XtEventRec *p, **pp;
+ EventMask oldMask = 0, eventMask = 0;
+
+ if (!has_type_specifier) {
+ eventMask = *(EventMask*)select_data & ~NonMaskableMask;
+ if (other) eventMask |= NonMaskableMask;
+ if (!eventMask) return;
+ } else if (!type) return;
+
+ if (XtIsRealized(widget) && !raw) oldMask = XtBuildEventMask(widget);
+
+ if (raw) raw = 1;
+ pp = &widget->core.event_table;
+ while ((p = *pp) &&
+ (p->proc != proc || p->closure != closure || p->select == raw ||
+ has_type_specifier != p->has_type_specifier ||
+ (has_type_specifier && EXT_TYPE(p) != type)))
+ pp = &p->next;
+
+ if (!p) { /* New proc to add to list */
+ if (has_type_specifier) {
+ p = (XtEventRec*) __XtMalloc(sizeof(XtEventRec) +
+ sizeof(XtEventRecExt));
+ EXT_TYPE(p) = type;
+ EXT_SELECT_DATA(p,0) = select_data;
+ p->mask = 1;
+ p->has_type_specifier = True;
+ } else {
+ p = (XtEventRec*) __XtMalloc(sizeof(XtEventRec));
+ p->mask = eventMask;
+ p->has_type_specifier = False;
+ }
+ p->proc = proc;
+ p->closure = closure;
+ p->select = ! raw;
+
+ if (position == XtListHead) {
+ p->next = widget->core.event_table;
+ widget->core.event_table = p;
+ pp = &widget->core.event_table;
+ } else {
+ *pp = p;
+ p->next = NULL;
+ }
+ }
+ else {
+ if (force_new_position) {
+ *pp = p->next;
+
+ if (position == XtListHead) {
+ p->next = widget->core.event_table;
+ widget->core.event_table = p;
+ } else {
+ /*
+ * Find the last element in the list.
+ */
+ while (*pp)
+ pp = &(*pp)->next;
+ *pp = p;
+ p->next = NULL;
+ }
+ }
+
+ if (!has_type_specifier)
+ p->mask |= eventMask;
+ else {
+ Cardinal i;
+ /* p->mask specifies count of EXT_SELECT_DATA(p,i) */
+ for (i = 0; i < p->mask && select_data != EXT_SELECT_DATA(p,i); )
+ i++;
+ if (i == p->mask) {
+ p = (XtEventRec*) XtRealloc((char*)p,
+ sizeof(XtEventRec) +
+ sizeof(XtEventRecExt) +
+ p->mask * sizeof(XtPointer));
+ EXT_SELECT_DATA(p,i) = select_data;
+ p->mask++;
+ *pp = p;
+ }
+ }
+ }
+
+ if (XtIsRealized(widget) && !raw) {
+ EventMask mask = XtBuildEventMask(widget);
+ Display* dpy = XtDisplay (widget);
+
+ if (oldMask != mask)
+ XSelectInput(dpy, XtWindow(widget), mask);
+
+ if (has_type_specifier) {
+ XtPerDisplay pd = _XtGetPerDisplay (dpy);
+ int i;
+ for (i = 0; i < pd->ext_select_count; i++) {
+ if (type >= pd->ext_select_list[i].min &&
+ type <= pd->ext_select_list[i].max) {
+ CallExtensionSelector(widget, pd->ext_select_list+i, FALSE);
+ break;
+ }
+ if (type < pd->ext_select_list[i].min) break;
+ }
+ }
+ }
+}
+
+void XtRemoveEventHandler(
+ Widget widget,
+ EventMask eventMask,
+ _XtBoolean other,
+ XtEventHandler proc,
+ XtPointer closure)
+{
+ WIDGET_TO_APPCON(widget);
+ LOCK_APP(app);
+ RemoveEventHandler(widget, (XtPointer) &eventMask, 0, FALSE,
+ other, proc, closure, FALSE);
+ UNLOCK_APP(app);
+}
+
+void XtAddEventHandler(
+ Widget widget,
+ EventMask eventMask,
+ _XtBoolean other,
+ XtEventHandler proc,
+ XtPointer closure)
+{
+ WIDGET_TO_APPCON(widget);
+ LOCK_APP(app);
+ AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, other,
+ proc, closure, XtListTail, FALSE, FALSE);
+ UNLOCK_APP(app);
+}
+
+void XtInsertEventHandler(
+ Widget widget,
+ EventMask eventMask,
+ _XtBoolean other,
+ XtEventHandler proc,
+ XtPointer closure,
+ XtListPosition position)
+{
+ WIDGET_TO_APPCON(widget);
+ LOCK_APP(app);
+ AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, other,
+ proc, closure, position, TRUE, FALSE);
+ UNLOCK_APP(app);
+}
+
+void XtRemoveRawEventHandler(
+ Widget widget,
+ EventMask eventMask,
+ _XtBoolean other,
+ XtEventHandler proc,
+ XtPointer closure)
+{
+ WIDGET_TO_APPCON(widget);
+ LOCK_APP(app);
+ RemoveEventHandler(widget, (XtPointer) &eventMask, 0, FALSE,
+ other, proc, closure, TRUE);
+ UNLOCK_APP(app);
+}
+
+void XtInsertRawEventHandler(
+ Widget widget,
+ EventMask eventMask,
+ _XtBoolean other,
+ XtEventHandler proc,
+ XtPointer closure,
+ XtListPosition position)
+{
+ WIDGET_TO_APPCON(widget);
+ LOCK_APP(app);
+ AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, other,
+ proc, closure, position, TRUE, TRUE);
+ UNLOCK_APP(app);
+}
+
+void XtAddRawEventHandler(
+ Widget widget,
+ EventMask eventMask,
+ _XtBoolean other,
+ XtEventHandler proc,
+ XtPointer closure)
+{
+ WIDGET_TO_APPCON(widget);
+ LOCK_APP(app);
+ AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, other,
+ proc, closure, XtListTail, FALSE, TRUE);
+ UNLOCK_APP(app);
+}
+
+void XtRemoveEventTypeHandler(
+ Widget widget,
+ int type,
+ XtPointer select_data,
+ XtEventHandler proc,
+ XtPointer closure)
+{
+ WIDGET_TO_APPCON(widget);
+ LOCK_APP(app);
+ RemoveEventHandler(widget, select_data, type, TRUE,
+ FALSE, proc, closure, FALSE);
+ UNLOCK_APP(app);
+}
+
+void XtInsertEventTypeHandler(
+ Widget widget,
+ int type,
+ XtPointer select_data,
+ XtEventHandler proc,
+ XtPointer closure,
+ XtListPosition position)
+{
+ WIDGET_TO_APPCON(widget);
+ LOCK_APP(app);
+ AddEventHandler(widget, select_data, type, TRUE, FALSE,
+ proc, closure, position, TRUE, FALSE);
+ UNLOCK_APP(app);
+}
+
+typedef struct _WWPair {
+ struct _WWPair *next;
+ Window window;
+ Widget widget;
+} *WWPair;
+
+typedef struct _WWTable {
+ unsigned int mask; /* size of hash table - 1 */
+ unsigned int rehash; /* mask - 2 */
+ unsigned int occupied; /* number of occupied entries */
+ unsigned int fakes; /* number occupied by WWfake */
+ Widget *entries; /* the entries */
+ WWPair pairs; /* bogus entries */
+} *WWTable;
+
+static const WidgetRec WWfake; /* placeholder for deletions */
+
+#define WWHASH(tab,win) ((win) & tab->mask)
+#define WWREHASHVAL(tab,win) ((((win) % tab->rehash) + 2) | 1)
+#define WWREHASH(tab,idx,rehash) ((idx + rehash) & tab->mask)
+#define WWTABLE(display) (_XtGetPerDisplay(display)->WWtable)
+
+static void ExpandWWTable(WWTable);
+
+void XtRegisterDrawable(
+ Display* display,
+ Drawable drawable,
+ Widget widget)
+{
+ WWTable tab;
+ int idx, rehash;
+ Widget entry;
+ Window window = (Window) drawable;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ tab = WWTABLE(display);
+ if (window != XtWindow(widget)) {
+ WWPair pair;
+ pair = XtNew(struct _WWPair);
+ pair->next = tab->pairs;
+ pair->window = window;
+ pair->widget = widget;
+ tab->pairs = pair;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return;
+ }
+ if ((tab->occupied + (tab->occupied >> 2)) > tab->mask)
+ ExpandWWTable(tab);
+
+ idx = WWHASH(tab, window);
+ if ((entry = tab->entries[idx]) && entry != &WWfake) {
+ rehash = WWREHASHVAL(tab, window);
+ do {
+ idx = WWREHASH(tab, idx, rehash);
+ } while ((entry = tab->entries[idx]) && entry != &WWfake);
+ }
+ if (!entry)
+ tab->occupied++;
+ else if (entry == &WWfake)
+ tab->fakes--;
+ tab->entries[idx] = widget;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+void XtUnregisterDrawable(
+ Display* display,
+ Drawable drawable)
+{
+ WWTable tab;
+ int idx, rehash;
+ Widget entry;
+ Window window = (Window) drawable;
+ Widget widget = XtWindowToWidget (display, window);
+ DPY_TO_APPCON(display);
+
+ if (widget == NULL) return;
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ tab = WWTABLE(display);
+ if (window != XtWindow(widget)) {
+ WWPair *prev, pair;
+
+ prev = &tab->pairs;
+ while ((pair = *prev) && pair->window != window)
+ prev = &pair->next;
+ if (pair) {
+ *prev = pair->next;
+ XtFree((char *)pair);
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return;
+ }
+ idx = WWHASH(tab, window);
+ if ((entry = tab->entries[idx])) {
+ if (entry != widget) {
+ rehash = WWREHASHVAL(tab, window);
+ do {
+ idx = WWREHASH(tab, idx, rehash);
+ if (!(entry = tab->entries[idx])) {
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return;
+ }
+ } while (entry != widget);
+ }
+ tab->entries[idx] = (Widget)&WWfake;
+ tab->fakes++;
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+static void ExpandWWTable(
+ register WWTable tab)
+{
+ unsigned int oldmask;
+ register Widget *oldentries, *entries;
+ register Cardinal oldidx, newidx, rehash;
+ register Widget entry;
+
+ LOCK_PROCESS;
+ oldmask = tab->mask;
+ oldentries = tab->entries;
+ tab->occupied -= tab->fakes;
+ tab->fakes = 0;
+ if ((tab->occupied + (tab->occupied >> 2)) > tab->mask) {
+ tab->mask = (tab->mask << 1) + 1;
+ tab->rehash = tab->mask - 2;
+ }
+ entries = tab->entries = (Widget *) __XtCalloc(tab->mask+1, sizeof(Widget));
+ for (oldidx = 0; oldidx <= oldmask; oldidx++) {
+ if ((entry = oldentries[oldidx]) && entry != &WWfake) {
+ newidx = WWHASH(tab, XtWindow(entry));
+ if (entries[newidx]) {
+ rehash = WWREHASHVAL(tab, XtWindow(entry));
+ do {
+ newidx = WWREHASH(tab, newidx, rehash);
+ } while (entries[newidx]);
+ }
+ entries[newidx] = entry;
+ }
+ }
+ XtFree((char *)oldentries);
+ UNLOCK_PROCESS;
+}
+
+Widget XtWindowToWidget(
+ register Display *display,
+ register Window window)
+{
+ register WWTable tab;
+ register int idx, rehash;
+ register Widget entry;
+ WWPair pair;
+ DPY_TO_APPCON(display);
+
+ if (!window) return NULL;
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ tab = WWTABLE(display);
+ idx = WWHASH(tab, window);
+ if ((entry = tab->entries[idx]) && XtWindow(entry) != window) {
+ rehash = WWREHASHVAL(tab, window);
+ do {
+ idx = WWREHASH(tab, idx, rehash);
+ } while ((entry = tab->entries[idx]) && XtWindow(entry) != window);
+ }
+ if (entry) {
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return entry;
+ }
+ for (pair = tab->pairs; pair; pair = pair->next) {
+ if (pair->window == window) {
+ entry = pair->widget;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return entry;
+ }
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return NULL;
+}
+
+void _XtAllocWWTable(
+ XtPerDisplay pd)
+{
+ register WWTable tab;
+
+ tab = (WWTable) __XtMalloc(sizeof(struct _WWTable));
+ tab->mask = 0x7f;
+ tab->rehash = tab->mask - 2;
+ tab->entries = (Widget *) __XtCalloc(tab->mask+1, sizeof(Widget));
+ tab->occupied = 0;
+ tab->fakes = 0;
+ tab->pairs = NULL;
+ pd->WWtable = tab;
+}
+
+void _XtFreeWWTable(
+ register XtPerDisplay pd)
+{
+ register WWPair pair, next;
+
+ for (pair = pd->WWtable->pairs; pair; pair = next) {
+ next = pair->next;
+ XtFree((char *)pair);
+ }
+ XtFree((char *)pd->WWtable->entries);
+ XtFree((char *)pd->WWtable);
+}
+
+#define EHMAXSIZE 25 /* do not make whopping big */
+
+static Boolean CallEventHandlers(
+ Widget widget,
+ XEvent *event,
+ EventMask mask)
+{
+ register XtEventRec *p;
+ XtEventHandler *proc;
+ XtPointer *closure;
+ XtEventHandler procs[EHMAXSIZE];
+ XtPointer closures[EHMAXSIZE];
+ Boolean cont_to_disp = True;
+ int i, numprocs;
+
+ /* Have to copy the procs into an array, because one of them might
+ * call XtRemoveEventHandler, which would break our linked list. */
+
+ numprocs = 0;
+ for (p=widget->core.event_table; p; p = p->next) {
+ if ((!p->has_type_specifier && (mask & p->mask)) ||
+ (p->has_type_specifier && event->type == EXT_TYPE(p)))
+ numprocs++;
+ }
+ if (numprocs > EHMAXSIZE) {
+ proc = (XtEventHandler *)__XtMalloc(numprocs * (sizeof(XtEventHandler) +
+ sizeof(XtPointer)));
+ closure = (XtPointer *)(proc + numprocs);
+ } else {
+ proc = procs;
+ closure = closures;
+ }
+ numprocs = 0;
+ for (p=widget->core.event_table; p; p = p->next) {
+ if ((!p->has_type_specifier && (mask & p->mask)) ||
+ (p->has_type_specifier && event->type == EXT_TYPE(p))) {
+ proc[numprocs] = p->proc;
+ closure[numprocs] = p->closure;
+ numprocs++;
+ }
+ }
+/* FUNCTIONS CALLED THROUGH POINTER proc:
+ Selection.c:ReqCleanup,
+ "Shell.c":EventHandler,
+ PassivGrab.c:ActiveHandler,
+ PassivGrab.c:RealizeHandler,
+ Keyboard.c:QueryEventMask,
+ _XtHandleFocus,
+ Selection.c:HandleSelectionReplies,
+ Selection.c:HandleGetIncrement,
+ Selection.c:HandleIncremental,
+ Selection.c:HandlePropertyGone,
+ Selection.c:HandleSelectionEvents
+ */
+ for (i = 0; i < numprocs && cont_to_disp; i++)
+ (*(proc[i]))(widget, closure[i], event, &cont_to_disp);
+ if (numprocs > EHMAXSIZE)
+ XtFree((char *)proc);
+ return cont_to_disp;
+}
+
+static void CompressExposures(XEvent *, Widget);
+
+#define KnownButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
+ Button4MotionMask|Button5MotionMask)
+
+/* keep this SMALL to avoid blowing stack cache! */
+/* because some compilers allocate all local locals on procedure entry */
+#define EHSIZE 4
+
+Boolean XtDispatchEventToWidget(
+ Widget widget,
+ XEvent* event)
+{
+ register XtEventRec *p;
+ Boolean was_dispatched = False;
+ Boolean call_tm = False;
+ Boolean cont_to_disp;
+ EventMask mask;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+
+ mask = _XtConvertTypeToMask(event->type);
+ if (event->type == MotionNotify)
+ mask |= (event->xmotion.state & KnownButtons);
+
+ LOCK_PROCESS;
+ if ( (mask == ExposureMask) ||
+ ((event->type == NoExpose) && NO_EXPOSE) ||
+ ((event->type == GraphicsExpose) && GRAPHICS_EXPOSE) ) {
+
+ if (widget->core.widget_class->core_class.expose != NULL ) {
+
+ /* We need to mask off the bits that could contain the information
+ * about whether or not we desire Graphics and NoExpose events. */
+
+ if ( (COMP_EXPOSE_TYPE == XtExposeNoCompress) ||
+ (event->type == NoExpose) )
+
+ (*widget->core.widget_class->core_class.expose)
+ (widget, event, (Region)NULL);
+ else {
+ CompressExposures(event, widget);
+ }
+ was_dispatched = True;
+ }
+ }
+
+ if ((mask == VisibilityChangeMask) &&
+ XtClass(widget)->core_class.visible_interest) {
+ was_dispatched = True;
+ /* our visibility just changed... */
+ switch (((XVisibilityEvent *)event)->state) {
+ case VisibilityUnobscured:
+ widget->core.visible = TRUE;
+ break;
+
+ case VisibilityPartiallyObscured:
+ /* what do we want to say here? */
+ /* well... some of us is visible */
+ widget->core.visible = TRUE;
+ break;
+
+ case VisibilityFullyObscured:
+ widget->core.visible = FALSE;
+ /* do we want to mark our children obscured? */
+ break;
+ }
+ }
+ UNLOCK_PROCESS;
+
+ /* to maintain "copy" semantics we check TM now but call later */
+ if (widget->core.tm.translations &&
+ (mask & widget->core.tm.translations->eventMask))
+ call_tm = True;
+
+ cont_to_disp = True;
+ p=widget->core.event_table;
+ if (p) {
+ if (p->next) {
+ XtEventHandler proc[EHSIZE];
+ XtPointer closure[EHSIZE];
+ int numprocs = 0;
+
+ /* Have to copy the procs into an array, because one of them might
+ * call XtRemoveEventHandler, which would break our linked list. */
+
+ for (; p; p = p->next) {
+ if ((!p->has_type_specifier && (mask & p->mask)) ||
+ (p->has_type_specifier && event->type == EXT_TYPE(p))) {
+ if (numprocs >= EHSIZE)
+ break;
+ proc[numprocs] = p->proc;
+ closure[numprocs] = p->closure;
+ numprocs++;
+ }
+ }
+ if (numprocs) {
+ if (p) {
+ cont_to_disp = CallEventHandlers(widget, event, mask);
+ } else {
+ int i;
+ for (i = 0; i < numprocs && cont_to_disp; i++)
+ (*(proc[i]))(widget, closure[i], event, &cont_to_disp);
+/* FUNCTIONS CALLED THROUGH POINTER proc:
+ Selection.c:ReqCleanup,
+ "Shell.c":EventHandler,
+ PassivGrab.c:ActiveHandler,
+ PassivGrab.c:RealizeHandler,
+ Keyboard.c:QueryEventMask,
+ _XtHandleFocus,
+ Selection.c:HandleSelectionReplies,
+ Selection.c:HandleGetIncrement,
+ Selection.c:HandleIncremental,
+ Selection.c:HandlePropertyGone,
+ Selection.c:HandleSelectionEvents
+ */
+ }
+ was_dispatched = True;
+ }
+ } else if ((!p->has_type_specifier && (mask & p->mask)) ||
+ (p->has_type_specifier && event->type == EXT_TYPE(p))) {
+ (*p->proc)(widget, p->closure, event, &cont_to_disp);
+ was_dispatched = True;
+ }
+ }
+ if (call_tm && cont_to_disp)
+ _XtTranslateEvent(widget, event);
+ UNLOCK_APP(app);
+ return (was_dispatched|call_tm);
+}
+
+/*
+ * This structure is passed into the check exposure proc.
+ */
+
+typedef struct _CheckExposeInfo {
+ int type1, type2; /* Types of events to check for. */
+ Boolean maximal; /* Ignore non-exposure events? */
+ Boolean non_matching; /* Was there an event that did not
+ match either type? */
+ Window window; /* Window to match. */
+} CheckExposeInfo;
+
+#define GetCount(ev) (((XExposeEvent *)(ev))->count)
+
+static void SendExposureEvent(XEvent *, Widget, XtPerDisplay);
+static Bool CheckExposureEvent(Display *, XEvent *, char *);
+static void AddExposureToRectangularRegion(XEvent *, Region);
+
+/* Function Name: CompressExposures
+ * Description: Handles all exposure compression
+ * Arguments: event - the xevent that is to be dispatched
+ * widget - the widget that this event occured in.
+ * Returns: none.
+ *
+ * NOTE: Event must be of type Expose or GraphicsExpose.
+ */
+
+static void
+CompressExposures(
+XEvent * event,
+Widget widget)
+{
+ CheckExposeInfo info;
+ int count;
+ Display* dpy = XtDisplay (widget);
+ XtPerDisplay pd = _XtGetPerDisplay(dpy);
+ XtEnum comp_expose;
+ XtEnum comp_expose_type;
+ Boolean no_region;
+
+ LOCK_PROCESS;
+ comp_expose = COMP_EXPOSE;
+ UNLOCK_PROCESS;
+ comp_expose_type = comp_expose & 0x0f;
+ no_region = ((comp_expose & XtExposeNoRegion) ? True : False);
+
+ if (no_region)
+ AddExposureToRectangularRegion(event, pd->region);
+ else
+ XtAddExposureToRegion(event, pd->region);
+
+ if ( GetCount(event) != 0 )
+ return;
+
+ if ((comp_expose_type == XtExposeCompressSeries) ||
+ (XEventsQueued(dpy, QueuedAfterReading) == 0)) {
+ SendExposureEvent(event, widget, pd);
+ return;
+ }
+
+ if (comp_expose & XtExposeGraphicsExposeMerged) {
+ info.type1 = Expose;
+ info.type2 = GraphicsExpose;
+ }
+ else {
+ info.type1 = event->type;
+ info.type2 = 0;
+ }
+ info.maximal = (comp_expose_type == XtExposeCompressMaximal);
+ info.non_matching = FALSE;
+ info.window = XtWindow(widget);
+
+/*
+ * We have to be very careful here not to hose down the processor
+ * when blocking until count gets to zero.
+ *
+ * First, check to see if there are any events in the queue for this
+ * widget, and of the correct type.
+ *
+ * Once we cannot find any more events, check to see that count is zero.
+ * If it is not then block until we get another exposure event.
+ *
+ * If we find no more events, and count on the last one we saw was zero we
+ * we can be sure that all events have been processed.
+ *
+ * Unfortunately, we wind up having to look at the entire queue
+ * event if we're not doing Maximal compression, due to the
+ * semantics of XCheckIfEvent (we can't abort without re-ordering
+ * the event queue as a side-effect).
+ */
+
+ count = 0;
+ while (TRUE) {
+ XEvent event_return;
+
+ if (XCheckIfEvent(dpy, &event_return,
+ CheckExposureEvent, (char *) &info)) {
+
+ count = GetCount(&event_return);
+ if (no_region)
+ AddExposureToRectangularRegion(&event_return, pd->region);
+ else
+ XtAddExposureToRegion(&event_return, pd->region);
+ }
+ else if (count != 0) {
+ XIfEvent(dpy, &event_return,
+ CheckExposureEvent, (char *) &info);
+ count = GetCount(&event_return);
+ if (no_region)
+ AddExposureToRectangularRegion(&event_return, pd->region);
+ else
+ XtAddExposureToRegion(&event_return, pd->region);
+ }
+ else /* count == 0 && XCheckIfEvent Failed. */
+ break;
+ }
+
+ SendExposureEvent(event, widget, pd);
+}
+
+void XtAddExposureToRegion(
+ XEvent *event,
+ Region region)
+{
+ XRectangle rect;
+ XExposeEvent *ev = (XExposeEvent *) event;
+ /* These Expose and GraphicsExpose fields are at identical offsets */
+
+ if (event->type == Expose || event->type == GraphicsExpose) {
+ rect.x = ev->x;
+ rect.y = ev->y;
+ rect.width = ev->width;
+ rect.height = ev->height;
+ XUnionRectWithRegion(&rect, region, region);
+ }
+}
+
+#ifndef MAX
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+
+#ifndef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+static void AddExposureToRectangularRegion(
+ XEvent *event, /* when called internally, type is always appropriate */
+ Region region)
+{
+ XRectangle rect;
+ XExposeEvent *ev = (XExposeEvent *) event;
+ /* These Expose and GraphicsExpose fields are at identical offsets */
+
+ rect.x = ev->x;
+ rect.y = ev->y;
+ rect.width = ev->width;
+ rect.height = ev->height;
+
+ if (XEmptyRegion(region)) {
+ XUnionRectWithRegion(&rect, region, region);
+ } else {
+ XRectangle merged, bbox;
+
+ XClipBox(region, &bbox);
+ merged.x = MIN(rect.x, bbox.x);
+ merged.y = MIN(rect.y, bbox.y);
+ merged.width = MAX(rect.x + rect.width,
+ bbox.x + bbox.width) - merged.x;
+ merged.height = MAX(rect.y + rect.height,
+ bbox.y + bbox.height) - merged.y;
+ XUnionRectWithRegion(&merged, region, region);
+ }
+}
+
+static Region nullRegion;
+/* READ-ONLY VARIABLES: nullRegion */
+
+void _XtEventInitialize(void)
+{
+#ifndef __lock_lint
+ nullRegion = XCreateRegion();
+#endif
+}
+
+/* Function Name: SendExposureEvent
+ * Description: Sets the x, y, width, and height of the event
+ * to be the clip box of Expose Region.
+ * Arguments: event - the X Event to mangle; Expose or GraphicsExpose.
+ * widget - the widget that this event occured in.
+ * pd - the per display information for this widget.
+ * Returns: none.
+ */
+
+static void
+SendExposureEvent(
+XEvent * event,
+Widget widget,
+XtPerDisplay pd)
+{
+ XtExposeProc expose;
+ XRectangle rect;
+ XtEnum comp_expose;
+ XExposeEvent *ev = (XExposeEvent *) event;
+
+ XClipBox(pd->region, &rect);
+ ev->x = rect.x;
+ ev->y = rect.y;
+ ev->width = rect.width;
+ ev->height = rect.height;
+
+ LOCK_PROCESS;
+ comp_expose = COMP_EXPOSE;
+ expose = widget->core.widget_class->core_class.expose;
+ UNLOCK_PROCESS;
+ if (comp_expose & XtExposeNoRegion)
+ (*expose)(widget, event, NULL);
+ else
+ (*expose)(widget, event, pd->region);
+ (void) XIntersectRegion(nullRegion, pd->region, pd->region);
+}
+
+/* Function Name: CheckExposureEvent
+ * Description: Checks the event queue for an expose event
+ * Arguments: display - the display connection.
+ * event - the event to check.
+ * arg - a pointer to the exposure info structure.
+ * Returns: TRUE if we found an event of the correct type
+ * with the right window.
+ *
+ * NOTE: The only valid types (info.type1 and info.type2) are Expose
+ * and GraphicsExpose.
+ */
+
+/* ARGSUSED */
+static Bool
+CheckExposureEvent(
+Display * disp,
+XEvent * event,
+char * arg)
+{
+ CheckExposeInfo * info = ((CheckExposeInfo *) arg);
+
+ if ( (info->type1 == event->type) || (info->type2 == event->type)) {
+ if (!info->maximal && info->non_matching) return FALSE;
+ if (event->type == GraphicsExpose)
+ return(event->xgraphicsexpose.drawable == info->window);
+ return(event->xexpose.window == info->window);
+ }
+ info->non_matching = TRUE;
+ return(FALSE);
+}
+
+static EventMask const masks[] = {
+ 0, /* Error, should never see */
+ 0, /* Reply, should never see */
+ KeyPressMask, /* KeyPress */
+ KeyReleaseMask, /* KeyRelease */
+ ButtonPressMask, /* ButtonPress */
+ ButtonReleaseMask, /* ButtonRelease */
+ PointerMotionMask /* MotionNotify */
+ | ButtonMotionMask,
+ EnterWindowMask, /* EnterNotify */
+ LeaveWindowMask, /* LeaveNotify */
+ FocusChangeMask, /* FocusIn */
+ FocusChangeMask, /* FocusOut */
+ KeymapStateMask, /* KeymapNotify */
+ ExposureMask, /* Expose */
+ NonMaskableMask, /* GraphicsExpose, in GC */
+ NonMaskableMask, /* NoExpose, in GC */
+ VisibilityChangeMask, /* VisibilityNotify */
+ SubstructureNotifyMask, /* CreateNotify */
+ StructureNotifyMask /* DestroyNotify */
+ | SubstructureNotifyMask,
+ StructureNotifyMask /* UnmapNotify */
+ | SubstructureNotifyMask,
+ StructureNotifyMask /* MapNotify */
+ | SubstructureNotifyMask,
+ SubstructureRedirectMask, /* MapRequest */
+ StructureNotifyMask /* ReparentNotify */
+ | SubstructureNotifyMask,
+ StructureNotifyMask /* ConfigureNotify */
+ | SubstructureNotifyMask,
+ SubstructureRedirectMask, /* ConfigureRequest */
+ StructureNotifyMask /* GravityNotify */
+ | SubstructureNotifyMask,
+ ResizeRedirectMask, /* ResizeRequest */
+ StructureNotifyMask /* CirculateNotify */
+ | SubstructureNotifyMask,
+ SubstructureRedirectMask, /* CirculateRequest */
+ PropertyChangeMask, /* PropertyNotify */
+ NonMaskableMask, /* SelectionClear */
+ NonMaskableMask, /* SelectionRequest */
+ NonMaskableMask, /* SelectionNotify */
+ ColormapChangeMask, /* ColormapNotify */
+ NonMaskableMask, /* ClientMessage */
+ NonMaskableMask /* MappingNotify */
+};
+
+EventMask _XtConvertTypeToMask (
+ int eventType)
+{
+ if ((Cardinal) eventType < XtNumber(masks))
+ return masks[eventType];
+ else
+ return NoEventMask;
+}
+
+Boolean _XtOnGrabList(
+ register Widget widget,
+ XtGrabRec *grabList)
+{
+ register XtGrabRec* gl;
+ for (; widget != NULL; widget = (Widget)widget->core.parent) {
+ for (gl = grabList; gl != NULL; gl = gl->next) {
+ if (gl->widget == widget) return TRUE;
+ if (gl->exclusive) break;
+ }
+ }
+ return FALSE;
+}
+
+static Widget LookupSpringLoaded(
+ XtGrabList grabList)
+{
+ XtGrabList gl;
+
+ for (gl = grabList; gl != NULL; gl = gl->next) {
+ if (gl->spring_loaded) {
+ if (XtIsSensitive(gl->widget))
+ return gl->widget;
+ else
+ return NULL;
+ }
+ if (gl->exclusive) break;
+ }
+ return NULL;
+}
+
+static Boolean DispatchEvent(
+ XEvent* event,
+ Widget widget)
+{
+
+ if (event->type == EnterNotify &&
+ event->xcrossing.mode == NotifyNormal &&
+ widget->core.widget_class->core_class.compress_enterleave) {
+ if (XPending(event->xcrossing.display)) {
+ XEvent nextEvent;
+ XPeekEvent(event->xcrossing.display, &nextEvent);
+ if (nextEvent.type == LeaveNotify &&
+ event->xcrossing.window == nextEvent.xcrossing.window &&
+ nextEvent.xcrossing.mode == NotifyNormal &&
+ ((event->xcrossing.detail != NotifyInferior &&
+ nextEvent.xcrossing.detail != NotifyInferior) ||
+ (event->xcrossing.detail == NotifyInferior &&
+ nextEvent.xcrossing.detail == NotifyInferior))) {
+ /* skip the enter/leave pair */
+ XNextEvent(event->xcrossing.display, &nextEvent);
+ return False;
+ }
+ }
+ }
+
+ if (event->type == MotionNotify &&
+ widget->core.widget_class->core_class.compress_motion) {
+ while (XPending(event->xmotion.display)) {
+ XEvent nextEvent;
+ XPeekEvent(event->xmotion.display, &nextEvent);
+ if (nextEvent.type == MotionNotify &&
+ event->xmotion.window == nextEvent.xmotion.window &&
+ event->xmotion.subwindow == nextEvent.xmotion.subwindow) {
+ /* replace the current event with the next one */
+ XNextEvent(event->xmotion.display, event);
+ } else break;
+ }
+ }
+
+ return XtDispatchEventToWidget(widget, event);
+}
+
+typedef enum _GrabType {pass, ignore, remap} GrabType;
+
+#if !defined(AIXV3) || !defined(AIXSHLIB)
+static /* AIX shared libraries are broken */
+#endif
+Boolean _XtDefaultDispatcher(
+ XEvent *event)
+{
+ register Widget widget;
+ GrabType grabType;
+ XtPerDisplayInput pdi;
+ XtGrabList grabList;
+ Boolean was_dispatched = False;
+ DPY_TO_APPCON(event->xany.display);
+
+ /* the default dispatcher discards all extension events */
+ if (event->type >= LASTEvent)
+ return False;
+
+ LOCK_APP(app);
+
+ switch (event->type) {
+ case KeyPress:
+ case KeyRelease:
+ case ButtonPress:
+ case ButtonRelease: grabType = remap; break;
+ case MotionNotify:
+ case EnterNotify: grabType = ignore; break;
+ default: grabType = pass; break;
+ }
+
+ widget = XtWindowToWidget (event->xany.display, event->xany.window);
+ pdi = _XtGetPerDisplayInput(event->xany.display);
+ grabList = *_XtGetGrabList(pdi);
+
+ if (widget == NULL) {
+ if (grabType == remap
+ && (widget = LookupSpringLoaded(grabList)) != NULL) {
+ /* event occurred in a non-widget window, but we've promised also
+ to dispatch it to the nearest accessible spring_loaded widget */
+ was_dispatched = (XFilterEvent(event, XtWindow(widget))
+ || XtDispatchEventToWidget(widget, event));
+ }
+ else was_dispatched = XFilterEvent(event, None);
+ }
+ else if (grabType == pass) {
+ if (event->type == LeaveNotify ||
+ event->type == FocusIn ||
+ event->type == FocusOut) {
+ if (XtIsSensitive (widget))
+ was_dispatched = (XFilterEvent(event, XtWindow(widget)) ||
+ XtDispatchEventToWidget(widget, event));
+ } else was_dispatched = (XFilterEvent(event, XtWindow(widget)) ||
+ XtDispatchEventToWidget(widget, event));
+ }
+ else if (grabType == ignore) {
+ if ((grabList == NULL || _XtOnGrabList(widget, grabList))
+ && XtIsSensitive(widget)) {
+ was_dispatched = (XFilterEvent(event, XtWindow(widget))
+ || DispatchEvent(event, widget));
+ }
+ }
+ else if (grabType == remap) {
+ EventMask mask = _XtConvertTypeToMask(event->type);
+ Widget dspWidget;
+ Boolean was_filtered = False;
+
+ dspWidget = _XtFindRemapWidget(event, widget, mask, pdi);
+
+ if ((grabList == NULL ||_XtOnGrabList(dspWidget, grabList))
+ && XtIsSensitive(dspWidget)) {
+ if ((was_filtered = XFilterEvent(event, XtWindow(dspWidget)))) {
+ /* If this event activated a device grab, release it. */
+ _XtUngrabBadGrabs(event, widget, mask, pdi);
+ was_dispatched = True;
+ } else
+ was_dispatched = XtDispatchEventToWidget(dspWidget, event);
+ }
+ else _XtUngrabBadGrabs(event, widget, mask, pdi);
+
+ if (!was_filtered) {
+ /* Also dispatch to nearest accessible spring_loaded. */
+ /* Fetch this afterward to reflect modal list changes */
+ grabList = *_XtGetGrabList(pdi);
+ widget = LookupSpringLoaded(grabList);
+ if (widget != NULL && widget != dspWidget) {
+ was_dispatched = (XFilterEvent(event, XtWindow(widget))
+ || XtDispatchEventToWidget(widget, event)
+ || was_dispatched);
+ }
+ }
+ }
+ UNLOCK_APP(app);
+ return was_dispatched;
+}
+
+Boolean XtDispatchEvent (
+ XEvent *event)
+{
+ Boolean was_dispatched, safe;
+ int dispatch_level;
+ int starting_count;
+ XtPerDisplay pd;
+ Time time = 0;
+ XtEventDispatchProc dispatch = _XtDefaultDispatcher;
+ XtAppContext app = XtDisplayToApplicationContext(event->xany.display);
+
+ LOCK_APP(app);
+ dispatch_level = ++app->dispatch_level;
+ starting_count = app->destroy_count;
+
+ switch (event->type) {
+ case KeyPress:
+ case KeyRelease: time = event->xkey.time; break;
+ case ButtonPress:
+ case ButtonRelease: time = event->xbutton.time; break;
+ case MotionNotify: time = event->xmotion.time; break;
+ case EnterNotify:
+ case LeaveNotify: time = event->xcrossing.time; break;
+ case PropertyNotify: time = event->xproperty.time; break;
+ case SelectionClear: time = event->xselectionclear.time; break;
+
+ case MappingNotify: _XtRefreshMapping(event, True); break;
+ }
+ pd = _XtGetPerDisplay(event->xany.display);
+ if (time) pd->last_timestamp = time;
+ pd->last_event = *event;
+
+ if (pd->dispatcher_list) {
+ dispatch = pd->dispatcher_list[event->type];
+ if (dispatch == NULL) dispatch = _XtDefaultDispatcher;
+ }
+ was_dispatched = (*dispatch)(event);
+
+ /*
+ * To make recursive XtDispatchEvent work, we need to do phase 2 destroys
+ * only on those widgets destroyed by this particular dispatch.
+ *
+ */
+
+ if (app->destroy_count > starting_count)
+ _XtDoPhase2Destroy(app, dispatch_level);
+
+ app->dispatch_level = dispatch_level - 1;
+
+ if ((safe = _XtSafeToDestroy(app))) {
+ if (app->dpy_destroy_count != 0) _XtCloseDisplays(app);
+ if (app->free_bindings) _XtDoFreeBindings(app);
+ }
+ UNLOCK_APP(app);
+ LOCK_PROCESS;
+ if (_XtAppDestroyCount != 0 && safe) _XtDestroyAppContexts();
+ UNLOCK_PROCESS;
+ return was_dispatched;
+}
+
+/* ARGSUSED */
+static void GrabDestroyCallback(
+ Widget widget,
+ XtPointer closure,
+ XtPointer call_data)
+{
+ /* Remove widget from grab list if it destroyed */
+ XtRemoveGrab(widget);
+}
+
+static XtGrabRec *NewGrabRec(
+ Widget widget,
+ Boolean exclusive,
+ Boolean spring_loaded)
+{
+ register XtGrabList gl;
+
+ gl = XtNew(XtGrabRec);
+ gl->next = NULL;
+ gl->widget = widget;
+ gl->exclusive = exclusive;
+ gl->spring_loaded = spring_loaded;
+
+ return gl;
+}
+
+void XtAddGrab(
+ Widget widget,
+ _XtBoolean exclusive,
+ _XtBoolean spring_loaded)
+{
+ register XtGrabList gl;
+ XtGrabList *grabListPtr;
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ grabListPtr = _XtGetGrabList(_XtGetPerDisplayInput(XtDisplay(widget)));
+
+ if (spring_loaded && !exclusive) {
+ XtAppWarningMsg(app,
+ "grabError", "xtAddGrab", XtCXtToolkitError,
+ "XtAddGrab requires exclusive grab if spring_loaded is TRUE",
+ (String *) NULL, (Cardinal *) NULL);
+ exclusive = TRUE;
+ }
+
+ gl = NewGrabRec(widget, exclusive, spring_loaded);
+ gl->next = *grabListPtr;
+ *grabListPtr = gl;
+
+ XtAddCallback (widget, XtNdestroyCallback,
+ GrabDestroyCallback, (XtPointer) NULL);
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+void XtRemoveGrab(
+ Widget widget)
+{
+ register XtGrabList gl;
+ register Boolean done;
+ XtGrabList *grabListPtr;
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+
+ grabListPtr = _XtGetGrabList(_XtGetPerDisplayInput(XtDisplay(widget)));
+
+ for (gl = *grabListPtr; gl != NULL; gl = gl->next) {
+ if (gl->widget == widget) break;
+ }
+
+ if (gl == NULL) {
+ XtAppWarningMsg(app,
+ "grabError","xtRemoveGrab",XtCXtToolkitError,
+ "XtRemoveGrab asked to remove a widget not on the list",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return;
+ }
+
+ do {
+ gl = *grabListPtr;
+ done = (gl->widget == widget);
+ *grabListPtr = gl->next;
+ XtRemoveCallback(gl->widget, XtNdestroyCallback,
+ GrabDestroyCallback, (XtPointer)NULL);
+ XtFree((char *)gl);
+ } while (! done);
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return;
+}
+
+void XtMainLoop(void)
+{
+ XtAppMainLoop(_XtDefaultAppContext());
+}
+
+void XtAppMainLoop(
+ XtAppContext app)
+{
+ XEvent event;
+
+ LOCK_APP(app);
+ do {
+ XtAppNextEvent(app, &event);
+#ifdef XTHREADS
+ /* assert(app == XtDisplayToApplicationContext(event.xany.display)); */
+#endif
+ XtDispatchEvent(&event);
+ } while(app->exit_flag == FALSE);
+ UNLOCK_APP(app);
+}
+
+void _XtFreeEventTable(
+ XtEventTable *event_table)
+{
+ register XtEventTable event;
+
+ event = *event_table;
+ while (event != NULL) {
+ register XtEventTable next = event->next;
+ XtFree((char *) event);
+ event = next;
+ }
+}
+
+Time XtLastTimestampProcessed(
+ Display *dpy)
+{
+ Time time;
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ time = _XtGetPerDisplay(dpy)->last_timestamp;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return(time);
+}
+
+XEvent* XtLastEventProcessed(
+ Display* dpy)
+{
+ XEvent* le = NULL;
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ le = &_XtGetPerDisplay(dpy)->last_event;
+ if (!le->xany.serial)
+ le = NULL;
+ UNLOCK_APP(app);
+ return le;
+}
+
+void _XtSendFocusEvent(
+ Widget child,
+ int type)
+{
+ child = XtIsWidget(child) ? child : _XtWindowedAncestor(child);
+ if (XtIsSensitive(child) && !child->core.being_destroyed
+ && XtIsRealized(child)
+ && (XtBuildEventMask(child) & FocusChangeMask))
+ {
+ XFocusChangeEvent event;
+ Display* dpy = XtDisplay (child);
+
+ event.type = type;
+ event.serial = LastKnownRequestProcessed(dpy);
+ event.send_event = True;
+ event.display = dpy;
+ event.window = XtWindow(child);
+ event.mode = NotifyNormal;
+ event.detail = NotifyAncestor;
+ if (XFilterEvent((XEvent*)&event, XtWindow(child)))
+ return;
+ XtDispatchEventToWidget(child, (XEvent*)&event);
+ }
+}
+
+static XtEventDispatchProc* NewDispatcherList(void)
+{
+ XtEventDispatchProc* l =
+ (XtEventDispatchProc*) __XtCalloc((Cardinal) 128,
+ (Cardinal)sizeof(XtEventDispatchProc));
+ return l;
+}
+
+XtEventDispatchProc XtSetEventDispatcher(
+ Display *dpy,
+ int event_type,
+ XtEventDispatchProc proc)
+{
+ XtEventDispatchProc *list;
+ XtEventDispatchProc old_proc;
+ register XtPerDisplay pd;
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ pd = _XtGetPerDisplay(dpy);
+
+ list = pd->dispatcher_list;
+ if (!list) {
+ if (proc) list = pd->dispatcher_list = NewDispatcherList();
+ else return _XtDefaultDispatcher;
+ }
+ old_proc = list[event_type];
+ list[event_type] = proc;
+ if (old_proc == NULL) old_proc = _XtDefaultDispatcher;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return old_proc;
+}
+
+void XtRegisterExtensionSelector(
+ Display *dpy,
+ int min_event_type,
+ int max_event_type,
+ XtExtensionSelectProc proc,
+ XtPointer client_data)
+{
+ ExtSelectRec *e;
+ XtPerDisplay pd;
+ int i;
+ DPY_TO_APPCON(dpy);
+
+ if (dpy == NULL) XtErrorMsg("nullDisplay",
+ "xtRegisterExtensionSelector", XtCXtToolkitError,
+ "XtRegisterExtensionSelector requires a non-NULL display",
+ (String *) NULL, (Cardinal *) NULL);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ pd = _XtGetPerDisplay(dpy);
+
+ for (i = 0; i < pd->ext_select_count; i++) {
+ e = &pd->ext_select_list[i];
+ if (e->min == min_event_type && e->max == max_event_type) {
+ e->proc = proc;
+ e->client_data = client_data;
+ return;
+ }
+ if ((min_event_type >= e->min && min_event_type <= e->max) ||
+ (max_event_type >= e->min && max_event_type <= e->max)) {
+ XtErrorMsg("rangeError", "xtRegisterExtensionSelector",
+ XtCXtToolkitError,
+ "Attempt to register multiple selectors for one extension event type",
+ (String *) NULL, (Cardinal *) NULL);
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return;
+ }
+ }
+ pd->ext_select_count++;
+ pd->ext_select_list =
+ (ExtSelectRec *) XtRealloc((char *) pd->ext_select_list,
+ pd->ext_select_count * sizeof(ExtSelectRec));
+ for (i = pd->ext_select_count - 1; i > 0; i--) {
+ if (pd->ext_select_list[i-1].min > min_event_type) {
+ pd->ext_select_list[i] = pd->ext_select_list[i-1];
+ } else break;
+ }
+ pd->ext_select_list[i].min = min_event_type;
+ pd->ext_select_list[i].max = max_event_type;
+ pd->ext_select_list[i].proc = proc;
+ pd->ext_select_list[i].client_data = client_data;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+void _XtExtensionSelect(
+ Widget widget)
+{
+ int i;
+ XtPerDisplay pd;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+
+ pd = _XtGetPerDisplay(XtDisplay(widget));
+
+ for (i = 0; i < pd->ext_select_count; i++) {
+ CallExtensionSelector(widget, pd->ext_select_list+i, FALSE);
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
diff --git a/nx-X11/lib/Xt/EventI.h b/nx-X11/lib/Xt/EventI.h
new file mode 100644
index 000000000..00858e71e
--- /dev/null
+++ b/nx-X11/lib/Xt/EventI.h
@@ -0,0 +1,134 @@
+/* $Xorg: EventI.h,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
+/* $oHeader: EventI.h,v 1.3 88/08/24 09:21:11 asente 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/EventI.h,v 1.3 2001/12/14 19:56:12 dawes Exp $ */
+
+/*
+ * Event.h - exported types and functions for toolkit event handler
+ *
+ * Author: Charles Haynes
+ * Digital Equipment Corporation
+ * Western Software Laboratory
+ * Date: Sun Dec 6 1987
+ */
+
+#ifndef _Event_h_
+#define _Event_h_
+
+typedef struct _XtGrabRec *XtGrabList;
+
+#include "PassivGraI.h"
+
+extern void _XtEventInitialize(
+ void
+);
+
+typedef struct _XtEventRec {
+ XtEventTable next;
+ EventMask mask; /* also select_data count for RecExt */
+ XtEventHandler proc;
+ XtPointer closure;
+ unsigned int select:1;
+ unsigned int has_type_specifier:1;
+ unsigned int async:1; /* not used, here for Digital extension? */
+} XtEventRec;
+
+typedef struct _XtGrabRec {
+ XtGrabList next;
+ Widget widget;
+ unsigned int exclusive:1;
+ unsigned int spring_loaded:1;
+}XtGrabRec;
+
+typedef struct _BlockHookRec {
+ struct _BlockHookRec* next;
+ XtAppContext app;
+ XtBlockHookProc proc;
+ XtPointer closure;
+} BlockHookRec, *BlockHook;
+
+extern void _XtFreeEventTable(
+ XtEventTable* /* event_table */
+);
+
+extern Boolean _XtOnGrabList(
+ Widget /* widget */,
+ XtGrabRec* /* grabList */
+);
+
+extern void _XtRemoveAllInputs(
+ XtAppContext /* app */
+);
+
+extern void _XtRefreshMapping(
+ XEvent* /* event */,
+ _XtBoolean /* dispatch */
+);
+
+extern void _XtSendFocusEvent(
+ Widget /* child */,
+ int /* type */);
+
+extern EventMask _XtConvertTypeToMask(
+ int /* eventType */
+);
+
+/* EventUtil.c */
+extern Widget _XtFindRemapWidget(XEvent *event, Widget widget,
+ EventMask mask, XtPerDisplayInput pdi);
+extern void _XtUngrabBadGrabs(XEvent *event, Widget widget,
+ EventMask mask, XtPerDisplayInput pdi);
+extern void _XtFillAncestorList(Widget **listPtr, int *maxElemsPtr,
+ int *numElemsPtr, Widget start,
+ Widget breakWidget);
+
+/* NextEvent.c */
+extern Boolean XtAppPeekEvent_SkipTimer;
+
+#endif /* _Event_h_ */
diff --git a/nx-X11/lib/Xt/EventUtil.c b/nx-X11/lib/Xt/EventUtil.c
new file mode 100644
index 000000000..929d83dc1
--- /dev/null
+++ b/nx-X11/lib/Xt/EventUtil.c
@@ -0,0 +1,221 @@
+/* $Xorg: EventUtil.c,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/********************************************************
+
+Copyright 1988 by Hewlett-Packard Company
+Copyright 1987, 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, CA.
+
+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 names of
+Hewlett-Packard, Digital, or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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, 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.
+
+*/
+/* $XFree86: xc/lib/Xt/EventUtil.c,v 1.6 2001/12/14 19:56:13 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "PassivGraI.h"
+#include "StringDefs.h"
+#include "EventI.h"
+
+static XContext perWidgetInputContext = 0;
+
+void _XtFreePerWidgetInput(
+ Widget w,
+ XtPerWidgetInput pwi)
+{
+ LOCK_PROCESS;
+ XDeleteContext(XtDisplay(w),
+ (Window)w,
+ perWidgetInputContext);
+
+ XtFree((char *)pwi);
+ UNLOCK_PROCESS;
+}
+
+/*
+ * This routine gets the passive list associated with the widget
+ * from the context manager.
+ */
+XtPerWidgetInput _XtGetPerWidgetInput(
+ Widget widget,
+ _XtBoolean create)
+{
+ XtPerWidgetInput pwi = NULL;
+ Display *dpy = widget->core.screen->display;
+
+ LOCK_PROCESS;
+ if (! perWidgetInputContext)
+ perWidgetInputContext = XUniqueContext();
+
+ if (XFindContext(dpy,
+ (Window)widget,
+ perWidgetInputContext,
+ (XPointer *)&pwi) &&
+ create)
+ {
+ pwi = (XtPerWidgetInput)
+ __XtMalloc((unsigned) sizeof(XtPerWidgetInputRec));
+
+ pwi->focusKid = NULL;
+ pwi->queryEventDescendant = NULL;
+ pwi->focalPoint = XtUnrelated;
+ pwi->keyList =
+ pwi->ptrList = NULL;
+
+ pwi->haveFocus =
+ pwi->map_handler_added =
+ pwi->realize_handler_added =
+ pwi->active_handler_added = FALSE;
+
+ XtAddCallback(widget, XtNdestroyCallback,
+ _XtDestroyServerGrabs, (XtPointer)pwi);
+
+ (void) XSaveContext(dpy,
+ (Window)widget,
+ perWidgetInputContext,
+ (char *) pwi);
+ }
+ UNLOCK_PROCESS;
+ return pwi;
+}
+
+
+void _XtFillAncestorList(
+ Widget **listPtr,
+ int *maxElemsPtr,
+ int *numElemsPtr,
+ Widget start,
+ Widget breakWidget)
+{
+#define CACHESIZE 16
+ Cardinal i;
+ Widget w;
+ Widget *trace = *listPtr;
+
+ /* First time in, allocate the ancestor list */
+ if (trace == NULL)
+ {
+ trace = (Widget *) __XtMalloc(CACHESIZE * sizeof(Widget));
+ *maxElemsPtr = CACHESIZE;
+ }
+ /* First fill in the ancestor list */
+
+ trace[0] = start;
+
+ for (i = 1, w = XtParent(start);
+ w != NULL && !XtIsShell(trace[i-1]) && trace[i-1] != breakWidget;
+ w = XtParent(w), i++) {
+ if (i == (Cardinal) *maxElemsPtr) {
+ /* This should rarely happen, but if it does it'll probably
+ happen again, so grow the ancestor list */
+ *maxElemsPtr += CACHESIZE;
+ trace = (Widget *) XtRealloc((char*)trace,
+ sizeof(Widget) * (*maxElemsPtr));
+ }
+ trace[i] = w;
+ }
+ *listPtr = trace;
+ *numElemsPtr = i;
+#undef CACHESIZE
+}
+
+
+Widget _XtFindRemapWidget(
+ XEvent *event,
+ Widget widget,
+ EventMask mask,
+ XtPerDisplayInput pdi)
+{
+ Widget dspWidget = widget;
+
+ if (!pdi->traceDepth || !(widget == pdi->trace[0]))
+ {
+ _XtFillAncestorList(&pdi->trace, &pdi->traceMax,
+ &pdi->traceDepth, widget, NULL);
+ pdi->focusWidget = NULL; /* invalidate the focus
+ cache */
+ }
+ if (mask & (KeyPressMask | KeyReleaseMask))
+ dspWidget = _XtProcessKeyboardEvent((XKeyEvent*)event, widget, pdi);
+ else if (mask &(ButtonPressMask | ButtonReleaseMask))
+ dspWidget = _XtProcessPointerEvent((XButtonEvent*)event, widget,pdi);
+
+ return dspWidget;
+}
+
+void _XtUngrabBadGrabs(
+ XEvent *event,
+ Widget widget,
+ EventMask mask,
+ XtPerDisplayInput pdi)
+{
+ XKeyEvent * ke = (XKeyEvent *) event;
+
+ if (mask & (KeyPressMask | KeyReleaseMask))
+ {
+ if (IsServerGrab(pdi->keyboard.grabType) &&
+ !_XtOnGrabList(pdi->keyboard.grab.widget,
+ pdi->grabList))
+ XtUngrabKeyboard(widget, ke->time);
+
+ }
+ else
+ {
+ if (IsServerGrab(pdi->pointer.grabType) &&
+ !_XtOnGrabList(pdi->pointer.grab.widget,
+ pdi->grabList))
+ XtUngrabPointer(widget, ke->time);
+ }
+}
diff --git a/nx-X11/lib/Xt/Functions.c b/nx-X11/lib/Xt/Functions.c
new file mode 100644
index 000000000..074a60f4c
--- /dev/null
+++ b/nx-X11/lib/Xt/Functions.c
@@ -0,0 +1,216 @@
+/* $Xorg: Functions.c,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/*
+
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, CA.
+
+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 Sun not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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 1985, 1986, 1987, 1988, 1989, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include <X11/Shell.h>
+#include <X11/Vendor.h>
+
+/*
+ * This file defines functional equivalents to all macros defined
+ * in Intrinsic.h
+ *
+ */
+
+#undef XtIsRectObj
+Boolean XtIsRectObj(Widget object)
+{
+ return _XtCheckSubclassFlag(object, 0x02);
+}
+
+
+#undef XtIsWidget
+Boolean XtIsWidget(Widget object)
+{
+ return _XtCheckSubclassFlag(object, 0x04);
+}
+
+
+#undef XtIsComposite
+Boolean XtIsComposite(Widget object)
+{
+ return _XtCheckSubclassFlag(object, 0x08);
+}
+
+
+#undef XtIsConstraint
+Boolean XtIsConstraint(Widget object)
+{
+ return _XtCheckSubclassFlag(object, 0x10);
+}
+
+
+#undef XtIsShell
+Boolean XtIsShell(Widget object)
+{
+ return _XtCheckSubclassFlag(object, 0x20);
+}
+
+
+#undef XtIsOverrideShell
+Boolean XtIsOverrideShell(Widget object)
+{
+ return _XtIsSubclassOf(object, (WidgetClass)overrideShellWidgetClass,
+ (WidgetClass)shellWidgetClass, 0x20);
+}
+
+
+#undef XtIsWMShell
+Boolean XtIsWMShell(Widget object)
+{
+ return _XtCheckSubclassFlag(object, 0x40);
+}
+
+
+#undef XtIsVendorShell
+Boolean XtIsVendorShell(Widget object)
+{
+ Boolean retval;
+
+ LOCK_PROCESS;
+ retval = _XtIsSubclassOf(object,
+#ifdef notdef
+/*
+ * We don't refer to vendorShell directly, because some shared libraries
+ * bind local references tightly.
+ */
+ (WidgetClass)vendorShellWidgetClass,
+#endif
+ transientShellWidgetClass->core_class.superclass,
+ (WidgetClass)wmShellWidgetClass, 0x40);
+ UNLOCK_PROCESS;
+ return retval;
+}
+
+
+#undef XtIsTransientShell
+Boolean XtIsTransientShell(Widget object)
+{
+ return _XtIsSubclassOf(object, (WidgetClass)transientShellWidgetClass,
+ (WidgetClass)wmShellWidgetClass, 0x40);
+}
+
+
+#undef XtIsTopLevelShell
+Boolean XtIsTopLevelShell(Widget object)
+{
+ return _XtCheckSubclassFlag(object, 0x80);
+}
+
+
+#undef XtIsApplicationShell
+Boolean XtIsApplicationShell(Widget object)
+{
+ return _XtIsSubclassOf(object, (WidgetClass)applicationShellWidgetClass,
+ (WidgetClass)topLevelShellWidgetClass, 0x80);
+}
+
+#undef XtIsSessionShell
+Boolean XtIsSessionShell(Widget object)
+{
+ return _XtIsSubclassOf(object, (WidgetClass)sessionShellWidgetClass,
+ (WidgetClass)topLevelShellWidgetClass, 0x80);
+}
+
+#undef XtMapWidget
+void XtMapWidget(Widget w)
+{
+ Widget hookobj;
+ WIDGET_TO_APPCON(w);
+
+ LOCK_APP(app);
+ XMapWindow(XtDisplay(w), XtWindow(w));
+ hookobj = XtHooksOfDisplay(XtDisplay(w));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHmapWidget;
+ call_data.widget = w;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ UNLOCK_APP(app);
+}
+
+
+#undef XtUnmapWidget
+void XtUnmapWidget(Widget w)
+{
+ Widget hookobj;
+ WIDGET_TO_APPCON(w);
+
+ LOCK_APP(app);
+ XUnmapWindow(XtDisplay(w), XtWindow(w));
+ hookobj = XtHooksOfDisplay(XtDisplay(w));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHunmapWidget;
+ call_data.widget = w;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ UNLOCK_APP(app);
+}
+
+
+#undef XtNewString
+String XtNewString(String str)
+{
+ if (str == NULL)
+ return NULL;
+ else
+ return strcpy(__XtMalloc((unsigned)strlen(str) + 1), str);
+}
diff --git a/nx-X11/lib/Xt/GCManager.c b/nx-X11/lib/Xt/GCManager.c
new file mode 100644
index 000000000..c09cb229b
--- /dev/null
+++ b/nx-X11/lib/Xt/GCManager.c
@@ -0,0 +1,353 @@
+/* $Xorg: GCManager.c,v 1.5 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988, 1990 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+/* $XFree86: xc/lib/Xt/GCManager.c,v 1.5 2001/08/22 22:52:18 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+
+
+typedef struct _GCrec {
+ unsigned char screen; /* Screen for GC */
+ unsigned char depth; /* Depth for GC */
+ char dashes; /* Dashes value */
+ Pixmap clip_mask; /* Clip_mask value */
+ Cardinal ref_count; /* # of shareholders */
+ GC gc; /* The GC itself. */
+ XtGCMask dynamic_mask; /* Writable values */
+ XtGCMask unused_mask; /* Unused values */
+ struct _GCrec *next; /* Next GC for this widgetkind. */
+} GCrec, *GCptr;
+
+#define GCVAL(bit,mask,val,default) ((bit&mask) ? val : default)
+
+#define CHECK(bit,comp,default) \
+ if ((checkMask & bit) && \
+ (GCVAL(bit,valueMask,v->comp,default) != gcv.comp)) return False
+
+#define ALLGCVALS (GCFunction | GCPlaneMask | GCForeground | \
+ GCBackground | GCLineWidth | GCLineStyle | \
+ GCCapStyle | GCJoinStyle | GCFillStyle | \
+ GCFillRule | GCTile | GCStipple | \
+ GCTileStipXOrigin | GCTileStipYOrigin | \
+ GCFont | GCSubwindowMode | GCGraphicsExposures | \
+ GCClipXOrigin | GCClipYOrigin | GCDashOffset | \
+ GCArcMode)
+
+static Bool Matches(
+ Display *dpy,
+ GCptr ptr,
+ register XtGCMask valueMask,
+ register XGCValues *v,
+ XtGCMask readOnlyMask,
+ XtGCMask dynamicMask)
+{
+ XGCValues gcv;
+ register XtGCMask checkMask;
+
+ if (readOnlyMask & ptr->dynamic_mask)
+ return False;
+ if (((ptr->dynamic_mask|ptr->unused_mask) & dynamicMask) != dynamicMask)
+ return False;
+ if (!XGetGCValues(dpy, ptr->gc, ALLGCVALS, &gcv))
+ return False;
+ checkMask = readOnlyMask & ~ptr->unused_mask;
+ CHECK(GCForeground, foreground, 0);
+ CHECK(GCBackground, background, 1);
+ CHECK(GCFont, font, ~0UL);
+ CHECK(GCFillStyle, fill_style, FillSolid);
+ CHECK(GCLineWidth, line_width, 0);
+ CHECK(GCFunction, function, GXcopy);
+ CHECK(GCGraphicsExposures, graphics_exposures, True);
+ CHECK(GCTile, tile, ~0UL);
+ CHECK(GCSubwindowMode, subwindow_mode, ClipByChildren);
+ CHECK(GCPlaneMask, plane_mask, AllPlanes);
+ CHECK(GCLineStyle, line_style, LineSolid);
+ CHECK(GCCapStyle, cap_style, CapButt);
+ CHECK(GCJoinStyle, join_style, JoinMiter);
+ CHECK(GCFillRule, fill_rule, EvenOddRule);
+ CHECK(GCArcMode, arc_mode, ArcPieSlice);
+ CHECK(GCStipple, stipple, ~0UL);
+ CHECK(GCTileStipXOrigin, ts_x_origin, 0);
+ CHECK(GCTileStipYOrigin, ts_y_origin, 0);
+ CHECK(GCClipXOrigin, clip_x_origin, 0);
+ CHECK(GCClipYOrigin, clip_y_origin, 0);
+ CHECK(GCDashOffset, dash_offset, 0);
+ gcv.clip_mask = ptr->clip_mask;
+ CHECK(GCClipMask, clip_mask, None);
+ gcv.dashes = ptr->dashes;
+ CHECK(GCDashList, dashes, 4);
+ valueMask &= ptr->unused_mask | dynamicMask;
+ if (valueMask) {
+ XChangeGC(dpy, ptr->gc, valueMask, v);
+ if (valueMask & GCDashList)
+ ptr->dashes = v->dashes;
+ if (valueMask & GCClipMask)
+ ptr->clip_mask = v->clip_mask;
+ }
+ ptr->unused_mask &= ~(dynamicMask | readOnlyMask);
+ ptr->dynamic_mask |= dynamicMask;
+ return True;
+} /* Matches */
+
+/* Called by CloseDisplay to free the per-display GC list */
+void _XtGClistFree(
+ Display *dpy,
+ register XtPerDisplay pd)
+{
+ register GCptr GClist, next;
+ register int i;
+
+ GClist = pd->GClist;
+ while (GClist) {
+ next = GClist->next;
+ XtFree((char*)GClist);
+ GClist = next;
+ }
+ if (pd->pixmap_tab) {
+ for (i = ScreenCount(dpy); --i >= 0; ) {
+ if (pd->pixmap_tab[i])
+ XtFree((char *)pd->pixmap_tab[i]);
+ }
+ XtFree((char *)pd->pixmap_tab);
+ }
+}
+
+
+/*
+ * Return a GC with the given values and characteristics.
+ */
+
+GC XtAllocateGC(
+ register Widget widget,
+ Cardinal depth,
+ XtGCMask valueMask,
+ XGCValues *values,
+ XtGCMask dynamicMask,
+ XtGCMask unusedMask)
+{
+ register GCptr *prev;
+ register GCptr cur;
+ Screen *screen;
+ register Display *dpy;
+ register XtPerDisplay pd;
+ Drawable drawable;
+ Drawable *pixmaps;
+ XtGCMask readOnlyMask;
+ GC retval;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if (!XtIsWidget(widget))
+ widget = _XtWindowedAncestor(widget);
+ if (!depth)
+ depth = widget->core.depth;
+ screen = XtScreen(widget);
+ dpy = DisplayOfScreen(screen);
+ pd = _XtGetPerDisplay(dpy);
+ unusedMask &= ~valueMask;
+ readOnlyMask = ~(dynamicMask | unusedMask);
+
+ /* Search for existing GC that matches exactly */
+ for (prev = &pd->GClist; (cur = *prev); prev = &cur->next) {
+ if (cur->depth == depth &&
+ ScreenOfDisplay(dpy, cur->screen) == screen &&
+ Matches(dpy, cur, valueMask, values, readOnlyMask, dynamicMask)) {
+ cur->ref_count++;
+ /* Move this GC to front of list */
+ *prev = cur->next;
+ cur->next = pd->GClist;
+ pd->GClist = cur;
+ retval = cur->gc;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return retval;
+ }
+ }
+
+ /* No matches, have to create a new one */
+ cur = XtNew(GCrec);
+ cur->screen = XScreenNumberOfScreen(screen);
+ cur->depth = depth;
+ cur->ref_count = 1;
+ cur->dynamic_mask = dynamicMask;
+ cur->unused_mask = (unusedMask & ~dynamicMask);
+ cur->dashes = GCVAL(GCDashList, valueMask, values->dashes, 4);
+ cur->clip_mask = GCVAL(GCClipMask, valueMask, values->clip_mask, None);
+ drawable = 0;
+ if (depth == widget->core.depth)
+ drawable = XtWindow(widget);
+ if (!drawable && depth == (Cardinal) DefaultDepthOfScreen(screen))
+ drawable = RootWindowOfScreen(screen);
+ if (!drawable) {
+ if (!pd->pixmap_tab) {
+ int n;
+ pd->pixmap_tab = (Drawable **)__XtMalloc((unsigned)ScreenCount(dpy) *
+ sizeof(Drawable *));
+ for (n = 0; n < ScreenCount(dpy); n++)
+ pd->pixmap_tab[n] = NULL;
+ }
+ pixmaps = pd->pixmap_tab[cur->screen];
+ if (!pixmaps) {
+ int max, n, *depths;
+ depths = XListDepths(dpy, cur->screen, &n);
+ n--;
+ max = depths[n];
+ while (n--) {
+ if (depths[n] > max)
+ max = depths[n];
+ }
+ XFree((char *)depths);
+ pixmaps = (Drawable *)__XtCalloc((unsigned)max, sizeof(Drawable));
+ pd->pixmap_tab[cur->screen] = pixmaps;
+ }
+ drawable = pixmaps[cur->depth - 1];
+ if (!drawable) {
+ drawable = XCreatePixmap(dpy, RootWindowOfScreen(screen), 1, 1,
+ cur->depth);
+ pixmaps[cur->depth - 1] = drawable;
+ }
+ }
+ cur->gc = XCreateGC(dpy, drawable, valueMask, values);
+ cur->next = pd->GClist;
+ pd->GClist = cur;
+ retval = cur->gc;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return retval;
+} /* XtAllocateGC */
+
+/*
+ * Return a read-only GC with the given values.
+ */
+
+GC XtGetGC(
+ register Widget widget,
+ XtGCMask valueMask,
+ XGCValues *values)
+{
+ return XtAllocateGC(widget, 0, valueMask, values, 0, 0);
+} /* XtGetGC */
+
+void XtReleaseGC(
+ Widget widget,
+ register GC gc)
+{
+ register GCptr cur, *prev;
+ Display* dpy;
+ XtPerDisplay pd;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ dpy = XtDisplayOfObject(widget);
+ pd = _XtGetPerDisplay(dpy);
+
+ for (prev = &pd->GClist; (cur = *prev); prev = &cur->next) {
+ if (cur->gc == gc) {
+ if (--(cur->ref_count) == 0) {
+ *prev = cur->next;
+ XFreeGC(dpy, gc);
+ XtFree((char *) cur);
+ }
+ break;
+ }
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+} /* XtReleaseGC */
+
+/* The following interface is broken and supplied only for backwards
+ * compatibility. It will work properly in all cases only if there
+ * is exactly 1 Display created by the application.
+ */
+
+void XtDestroyGC(register GC gc)
+{
+ GCptr cur, *prev;
+ XtAppContext app;
+
+ LOCK_PROCESS;
+ app = _XtGetProcessContext()->appContextList;
+ /* This is awful; we have to search through all the lists
+ to find the GC. */
+ for (; app; app = app->next) {
+ int i;
+ for (i = app->count; i ;) {
+ Display *dpy = app->list[--i];
+ XtPerDisplay pd = _XtGetPerDisplay(dpy);
+ for (prev = &pd->GClist; (cur = *prev); prev = &cur->next) {
+ if (cur->gc == gc) {
+ if (--(cur->ref_count) == 0) {
+ *prev = cur->next;
+ XFreeGC(dpy, gc);
+ XtFree((char *) cur);
+ }
+ UNLOCK_PROCESS;
+ return;
+ }
+ }
+ }
+ }
+ UNLOCK_PROCESS;
+} /* XtDestroyGC */
diff --git a/nx-X11/lib/Xt/Geometry.c b/nx-X11/lib/Xt/Geometry.c
new file mode 100644
index 000000000..b183bfd76
--- /dev/null
+++ b/nx-X11/lib/Xt/Geometry.c
@@ -0,0 +1,817 @@
+/* $Xorg: Geometry.c,v 1.5 2001/02/09 02:03:54 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/Geometry.c,v 1.12 2001/12/14 19:56:15 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "ShellP.h"
+#include "ShellI.h"
+
+static void ClearRectObjAreas(
+ RectObj r,
+ XWindowChanges* old)
+{
+ Widget pw = _XtWindowedAncestor((Widget)r);
+ int bw2;
+
+ bw2 = old->border_width << 1;
+ XClearArea( XtDisplay(pw), XtWindow(pw),
+ old->x, old->y,
+ old->width + bw2, old->height + bw2,
+ TRUE );
+
+ bw2 = r->rectangle.border_width << 1;
+ XClearArea( XtDisplay(pw), XtWindow(pw),
+ (int)r->rectangle.x, (int)r->rectangle.y,
+ (unsigned int)(r->rectangle.width + bw2),
+ (unsigned int)(r->rectangle.height + bw2),
+ TRUE );
+}
+
+/*
+ * Internal function used by XtMakeGeometryRequest and XtSetValues.
+ * Returns more data than the public interface. Does not convert
+ * XtGeometryDone to XtGeometryYes.
+ *
+ * clear_rect_obj - *** RETURNED ***
+ * TRUE if the rect obj has been cleared, false otherwise.
+ */
+
+XtGeometryResult
+_XtMakeGeometryRequest (
+ Widget widget,
+ XtWidgetGeometry *request,
+ XtWidgetGeometry *reply,
+ Boolean * clear_rect_obj)
+{
+ XtWidgetGeometry junk;
+ XtGeometryHandler manager = (XtGeometryHandler) NULL;
+ XtGeometryResult returnCode;
+ Widget parent = widget->core.parent;
+ Boolean managed, parentRealized, rgm = False;
+ XtConfigureHookDataRec req;
+ Widget hookobj;
+
+ *clear_rect_obj = FALSE;
+
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "\"%s\" is making a %sgeometry request to its parent \"%s\".\n",
+ XtName(widget),
+ ((request->request_mode & XtCWQueryOnly))? "query only ":"",
+ (XtParent(widget))?XtName(XtParent(widget)):"Root"));
+ CALLGEOTAT(_XtGeoTab(1));
+
+ if (XtIsShell(widget)) {
+ ShellClassExtension ext;
+ LOCK_PROCESS;
+ for (ext = (ShellClassExtension)((ShellWidgetClass)XtClass(widget))
+ ->shell_class.extension;
+ ext != NULL && ext->record_type != NULLQUARK;
+ ext = (ShellClassExtension)ext->next_extension);
+
+ if (ext != NULL) {
+ if ( ext->version == XtShellExtensionVersion
+ && ext->record_size == sizeof(ShellClassExtensionRec)) {
+ manager = ext->root_geometry_manager;
+ rgm = True;
+ } else {
+ String params[1];
+ Cardinal num_params = 1;
+ params[0] = XtClass(widget)->core_class.class_name;
+ XtAppErrorMsg(XtWidgetToApplicationContext(widget),
+ "invalidExtension", "xtMakeGeometryRequest",
+ XtCXtToolkitError,
+ "widget class %s has invalid ShellClassExtension record",
+ params, &num_params);
+ }
+ } else {
+ XtAppErrorMsg(XtWidgetToApplicationContext(widget),
+ "internalError", "xtMakeGeometryRequest",
+ XtCXtToolkitError,
+ "internal error; ShellClassExtension is NULL",
+ NULL, NULL);
+ }
+ managed = True;
+ parentRealized = TRUE;
+ UNLOCK_PROCESS;
+ } else /* not shell */ {
+ if (parent == NULL)
+ XtAppErrorMsg(XtWidgetToApplicationContext(widget),
+ "invalidParent","xtMakeGeometryRequest",
+ XtCXtToolkitError,
+ "non-shell has no parent in XtMakeGeometryRequest",
+ (String *)NULL, (Cardinal *)NULL);
+
+ managed = XtIsManaged(widget);
+ parentRealized = XtIsRealized(parent);
+ if (XtIsComposite(parent))
+ {
+ LOCK_PROCESS;
+ manager = ((CompositeWidgetClass) (parent->core.widget_class))
+ ->composite_class.geometry_manager;
+ UNLOCK_PROCESS;
+ }
+ }
+
+#if 0
+ /*
+ * The Xt spec says that these conditions must generate
+ * error messages (not warnings), but many Xt applications
+ * and toolkits (including parts of Xaw, Motif and Netscape)
+ * depend on the previous Xt behaviour. Thus, these tests
+ * should probably remain disabled.
+ */
+ if (parentRealized && managed) {
+ if (parent && !XtIsComposite(parent))
+ {
+ /*
+ * This shouldn't ever happen, we only test for this to pass
+ * VSW5. Normally managing the widget will catch this, but VSW5
+ * does some really screwy stuff to get here.
+ */
+ XtAppErrorMsg(XtWidgetToApplicationContext(widget),
+ "invalidParent", "xtMakeGeometryRequest",
+ XtCXtToolkitError,
+ "XtMakeGeometryRequest - parent not composite",
+ (String *)NULL, (Cardinal *)NULL);
+ }
+ else if (manager == (XtGeometryHandler) NULL)
+ {
+ XtAppErrorMsg(XtWidgetToApplicationContext(widget),
+ "invalidGeometryManager","xtMakeGeometryRequest",
+ XtCXtToolkitError,
+ "XtMakeGeometryRequest - parent has no geometry manager",
+ (String *)NULL, (Cardinal *)NULL);
+ }
+ }
+#else
+ if (!manager)
+ managed = False;
+#endif
+
+ if (widget->core.being_destroyed) {
+ CALLGEOTAT(_XtGeoTab(-1));
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "It is being destroyed, just return XtGeometryNo.\n"));
+ return XtGeometryNo;
+ }
+
+ /* see if requesting anything to change */
+ req.changeMask = 0;
+ if (request->request_mode & CWStackMode
+ && request->stack_mode != XtSMDontChange) {
+ req.changeMask |= CWStackMode;
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "Asking for a change in StackMode!\n"));
+ if (request->request_mode & CWSibling) {
+ XtCheckSubclass(request->sibling, rectObjClass,
+ "XtMakeGeometryRequest");
+ req.changeMask |= CWSibling;
+ }
+ }
+ if (request->request_mode & CWX
+ && widget->core.x != request->x) {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "Asking for a change in x: from %d to %d.\n",
+ widget->core.x, request->x));
+ req.changeMask |= CWX;
+ }
+ if (request->request_mode & CWY
+ && widget->core.y != request->y) {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "Asking for a change in y: from %d to %d.\n",
+ widget->core.y, request->y));
+ req.changeMask |= CWY;
+ }
+ if (request->request_mode & CWWidth
+ && widget->core.width != request->width) {
+ CALLGEOTAT(_XtGeoTrace(widget,"Asking for a change in width: from %d to %d.\n",
+ widget->core.width, request->width));
+ req.changeMask |= CWWidth;
+ }
+ if (request->request_mode & CWHeight
+ && widget->core.height != request->height) {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "Asking for a change in height: from %d to %d.\n",
+ widget->core.height, request->height));
+ req.changeMask |= CWHeight;
+ }
+ if (request->request_mode & CWBorderWidth
+ && widget->core.border_width != request->border_width){
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "Asking for a change in border_width: from %d to %d.\n",
+ widget->core.border_width, request->border_width));
+ req.changeMask |= CWBorderWidth;
+ }
+ if (! req.changeMask) {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "Asking for nothing new,\n"));
+ CALLGEOTAT(_XtGeoTab(-1));
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "just return XtGeometryYes.\n"));
+ return XtGeometryYes;
+ }
+ req.changeMask |= (request->request_mode & XtCWQueryOnly);
+
+ if ( !(req.changeMask & XtCWQueryOnly) && XtIsRealized(widget) ) {
+ /* keep record of the current geometry so we know what's changed */
+ req.changes.x = widget->core.x ;
+ req.changes.y = widget->core.y ;
+ req.changes.width = widget->core.width ;
+ req.changes.height = widget->core.height ;
+ req.changes.border_width = widget->core.border_width ;
+ }
+
+ if (!managed || !parentRealized) {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "Not Managed or Parent not realized.\n"));
+ /* Don't get parent's manager involved--assume the answer is yes */
+ if (req.changeMask & XtCWQueryOnly) {
+ /* He was just asking, don't change anything, just tell him yes */
+ CALLGEOTAT(_XtGeoTrace(widget,"QueryOnly request\n"));
+ CALLGEOTAT(_XtGeoTab(-1));
+ CALLGEOTAT(_XtGeoTrace(widget,"just return XtGeometryYes.\n"));
+ return XtGeometryYes;
+ } else {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "Copy values from request to widget.\n"));
+ /* copy values from request to widget */
+ if (request->request_mode & CWX)
+ widget->core.x = request->x;
+ if (request->request_mode & CWY)
+ widget->core.y = request->y;
+ if (request->request_mode & CWWidth)
+ widget->core.width = request->width;
+ if (request->request_mode & CWHeight)
+ widget->core.height = request->height;
+ if (request->request_mode & CWBorderWidth)
+ widget->core.border_width = request->border_width;
+ if (!parentRealized) {
+ CALLGEOTAT(_XtGeoTab(-1));
+ CALLGEOTAT(_XtGeoTrace(widget,"and return XtGeometryYes.\n"));
+ return XtGeometryYes;
+ }
+ else returnCode = XtGeometryYes;
+ }
+ } else {
+ /* go ask the widget's geometry manager */
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "Go ask the parent geometry manager.\n"));
+ if (reply == (XtWidgetGeometry *) NULL) {
+ returnCode = (*manager)(widget, request, &junk);
+ } else {
+ returnCode = (*manager)(widget, request, reply);
+ }
+ }
+
+ /*
+ * If Unrealized, not a XtGeometryYes, or a query-only then we are done.
+ */
+
+ if ((returnCode != XtGeometryYes) ||
+ (req.changeMask & XtCWQueryOnly) || !XtIsRealized(widget)) {
+
+#ifdef XT_GEO_TATTLER
+ switch(returnCode){
+ case XtGeometryNo:
+ CALLGEOTAT(_XtGeoTab(-1));
+ CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryNo.\n",
+ (XtParent(widget))?XtName(XtParent(widget)):"Root"));
+ /* check for no change */
+ break ;
+ case XtGeometryDone:
+ CALLGEOTAT(_XtGeoTab(-1));
+ CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryDone.\n",
+ (XtParent(widget))?XtName(XtParent(widget)):"Root"));
+ /* check for no change in queryonly */
+ break ;
+ case XtGeometryAlmost:
+ CALLGEOTAT(_XtGeoTab(-1));
+ CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryAlmost.\n",
+ (XtParent(widget))?XtName(XtParent(widget)):"Root"));
+ CALLGEOTAT(_XtGeoTab(1));
+ CALLGEOTAT(_XtGeoTrace(widget,"Proposal: width %d height %d.\n",
+ (reply)?reply->width:junk.width,
+ (reply)?reply->height:junk.height));
+ CALLGEOTAT(_XtGeoTab(-1));
+
+ /* check for no change */
+ break ;
+ case XtGeometryYes:
+ if (req.changeMask & XtCWQueryOnly) {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "QueryOnly specified, no configuration.\n"));
+ }
+ if (!XtIsRealized(widget)) {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "\"%s\" not realized, no configuration.\n",
+ XtName(widget)));
+ }
+ CALLGEOTAT(_XtGeoTab(-1));
+ CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryYes.\n",
+ (XtParent(widget))?XtName(XtParent(widget)):"Root"));
+ break ;
+ }
+#endif
+ return returnCode;
+ }
+
+ CALLGEOTAT(_XtGeoTab(-1));
+ CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryYes.\n",
+ (XtParent(widget))?XtName(XtParent(widget)):"Root"));
+
+ if (XtIsWidget(widget)) { /* reconfigure the window (if needed) */
+
+ if (rgm) return returnCode;
+
+ if (req.changes.x != widget->core.x) {
+ req.changeMask |= CWX;
+ req.changes.x = widget->core.x;
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "x changing to %d\n",widget->core.x));
+ }
+ if (req.changes.y != widget->core.y) {
+ req.changeMask |= CWY;
+ req.changes.y = widget->core.y;
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "y changing to %d\n",widget->core.y));
+ }
+ if (req.changes.width != widget->core.width) {
+ req.changeMask |= CWWidth;
+ req.changes.width = widget->core.width;
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "width changing to %d\n",widget->core.width));
+ }
+ if (req.changes.height != widget->core.height) {
+ req.changeMask |= CWHeight;
+ req.changes.height = widget->core.height;
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "height changing to %d\n",widget->core.height));
+ }
+ if (req.changes.border_width != widget->core.border_width) {
+ req.changeMask |= CWBorderWidth;
+ req.changes.border_width = widget->core.border_width;
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "border_width changing to %d\n",
+ widget->core.border_width));
+ }
+ if (req.changeMask & CWStackMode) {
+ req.changes.stack_mode = request->stack_mode;
+ CALLGEOTAT(_XtGeoTrace(widget,"stack_mode changing\n"));
+ if (req.changeMask & CWSibling) {
+ if (XtIsWidget(request->sibling))
+ req.changes.sibling = XtWindow(request->sibling);
+ else
+ req.changeMask &= ~(CWStackMode | CWSibling);
+ }
+ }
+
+#ifdef XT_GEO_TATTLER
+ if (req.changeMask) {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "XConfigure \"%s\"'s window.\n",
+ XtName(widget)));
+ } else {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "No window configuration needed for \"%s\".\n",
+ XtName(widget)));
+ }
+#endif
+
+ XConfigureWindow(XtDisplay(widget), XtWindow(widget),
+ req.changeMask, &req.changes);
+ }
+ else { /* RectObj child of realized Widget */
+ *clear_rect_obj = TRUE;
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "ClearRectObj on \"%s\".\n",XtName(widget)));
+
+ ClearRectObjAreas((RectObj)widget, &req.changes);
+ }
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));;
+ if (XtHasCallbacks(hookobj, XtNconfigureHook) == XtCallbackHasSome) {
+ req.type = XtHconfigure;
+ req.widget = widget;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.confighook_callbacks,
+ (XtPointer)&req);
+ }
+
+ return returnCode;
+} /* _XtMakeGeometryRequest */
+
+
+/* Public routines */
+
+XtGeometryResult XtMakeGeometryRequest (
+ Widget widget,
+ XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+ Boolean junk;
+ XtGeometryResult r;
+ XtGeometryHookDataRec call_data;
+ Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ if (XtHasCallbacks(hookobj, XtNgeometryHook) == XtCallbackHasSome) {
+ call_data.type = XtHpreGeometry;
+ call_data.widget = widget;
+ call_data.request = request;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.geometryhook_callbacks,
+ (XtPointer)&call_data);
+ call_data.result = r =
+ _XtMakeGeometryRequest(widget, request, reply, &junk);
+ call_data.type = XtHpostGeometry;
+ call_data.reply = reply;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.geometryhook_callbacks,
+ (XtPointer)&call_data);
+ } else {
+ r = _XtMakeGeometryRequest(widget, request, reply, &junk);
+ }
+ UNLOCK_APP(app);
+
+ return ((r == XtGeometryDone) ? XtGeometryYes : r);
+}
+
+XtGeometryResult
+XtMakeResizeRequest(
+ Widget widget,
+ _XtDimension width,
+ _XtDimension height,
+ Dimension *replyWidth,
+ Dimension *replyHeight)
+{
+ XtWidgetGeometry request, reply;
+ XtGeometryResult r;
+ XtGeometryHookDataRec call_data;
+ Boolean junk;
+ Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ request.request_mode = CWWidth | CWHeight;
+ request.width = width;
+ request.height = height;
+
+ if (XtHasCallbacks(hookobj, XtNgeometryHook) == XtCallbackHasSome) {
+ call_data.type = XtHpreGeometry;
+ call_data.widget = widget;
+ call_data.request = &request;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.geometryhook_callbacks,
+ (XtPointer)&call_data);
+ call_data.result = r =
+ _XtMakeGeometryRequest(widget, &request, &reply, &junk);
+ call_data.type = XtHpostGeometry;
+ call_data.reply = &reply;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.geometryhook_callbacks,
+ (XtPointer)&call_data);
+ } else {
+ r = _XtMakeGeometryRequest(widget, &request, &reply, &junk);
+ }
+ if (replyWidth != NULL) {
+ if (r == XtGeometryAlmost && reply.request_mode & CWWidth)
+ *replyWidth = reply.width;
+ else
+ *replyWidth = width;
+ }
+ if (replyHeight != NULL) {
+ if (r == XtGeometryAlmost && reply.request_mode & CWHeight)
+ *replyHeight = reply.height;
+ else
+ *replyHeight = height;
+ }
+ UNLOCK_APP(app);
+ return ((r == XtGeometryDone) ? XtGeometryYes : r);
+} /* XtMakeResizeRequest */
+
+void XtResizeWindow(
+ Widget w)
+{
+ XtConfigureHookDataRec req;
+ Widget hookobj;
+ WIDGET_TO_APPCON(w);
+
+ LOCK_APP(app);
+ if (XtIsRealized(w)) {
+ req.changes.width = w->core.width;
+ req.changes.height = w->core.height;
+ req.changes.border_width = w->core.border_width;
+ req.changeMask = CWWidth | CWHeight | CWBorderWidth;
+ XConfigureWindow(XtDisplay(w), XtWindow(w),
+ (unsigned) req.changeMask, &req.changes);
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(w));;
+ if (XtHasCallbacks(hookobj, XtNconfigureHook) == XtCallbackHasSome) {
+ req.type = XtHconfigure;
+ req.widget = w;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.confighook_callbacks,
+ (XtPointer)&req);
+ }
+ }
+ UNLOCK_APP(app);
+} /* XtResizeWindow */
+
+void XtResizeWidget(
+ Widget w,
+ _XtDimension width,
+ _XtDimension height,
+ _XtDimension borderWidth)
+{
+ XtConfigureWidget(w, w->core.x, w->core.y, width, height, borderWidth);
+} /* XtResizeWidget */
+
+void XtConfigureWidget(
+ Widget w,
+ _XtPosition x,
+ _XtPosition y,
+ _XtDimension width,
+ _XtDimension height,
+ _XtDimension borderWidth)
+{
+ XtConfigureHookDataRec req;
+ Widget hookobj;
+ XWindowChanges old;
+ WIDGET_TO_APPCON(w);
+
+ CALLGEOTAT(_XtGeoTrace(w,
+ "\"%s\" is being configured by its parent \"%s\"\n",
+ XtName(w),
+ (XtParent(w))?XtName(XtParent(w)):"Root"));
+ CALLGEOTAT(_XtGeoTab(1));
+
+ LOCK_APP(app);
+ req.changeMask = 0;
+ if ((old.x = w->core.x) != x) {
+ CALLGEOTAT(_XtGeoTrace(w,"x move from %d to %d\n",w->core.x, x));
+ req.changes.x = w->core.x = x;
+ req.changeMask |= CWX;
+ }
+
+ if ((old.y = w->core.y) != y) {
+ CALLGEOTAT(_XtGeoTrace(w,"y move from %d to %d\n",w->core.y, y));
+ req.changes.y = w->core.y = y;
+ req.changeMask |= CWY;
+ }
+
+ if ((old.width = w->core.width) != width) {
+ CALLGEOTAT(_XtGeoTrace(w,
+ "width move from %d to %d\n",w->core.width, width));
+ req.changes.width = w->core.width = width;
+ req.changeMask |= CWWidth;
+ }
+
+ if ((old.height = w->core.height) != height) {
+ CALLGEOTAT(_XtGeoTrace(w,
+ "height move from %d to %d\n",w->core.height, height));
+ req.changes.height = w->core.height = height;
+ req.changeMask |= CWHeight;
+ }
+
+ if ((old.border_width = w->core.border_width) != borderWidth) {
+ CALLGEOTAT(_XtGeoTrace(w,"border_width move from %d to %d\n",
+ w->core.border_width,borderWidth ));
+ req.changes.border_width = w->core.border_width = borderWidth;
+ req.changeMask |= CWBorderWidth;
+ }
+
+ if (req.changeMask != 0) {
+ if (XtIsRealized(w)) {
+ if (XtIsWidget(w)) {
+ CALLGEOTAT(_XtGeoTrace(w,
+ "XConfigure \"%s\"'s window\n",XtName(w)));
+ XConfigureWindow(XtDisplay(w), XtWindow(w),
+ req.changeMask, &req.changes);
+ } else {
+ CALLGEOTAT(_XtGeoTrace(w,
+ "ClearRectObj called on \"%s\"\n",XtName(w)));
+ ClearRectObjAreas((RectObj)w, &old);
+ }
+ }
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(w));;
+ if (XtHasCallbacks(hookobj, XtNconfigureHook) == XtCallbackHasSome) {
+ req.type = XtHconfigure;
+ req.widget = w;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.confighook_callbacks,
+ (XtPointer)&req);
+ }
+ {
+ XtWidgetProc resize;
+
+ LOCK_PROCESS;
+ resize = XtClass(w)->core_class.resize;
+ UNLOCK_PROCESS;
+ if ((req.changeMask & (CWWidth | CWHeight)) &&
+ resize != (XtWidgetProc) NULL) {
+ CALLGEOTAT(_XtGeoTrace(w,"Resize proc is called.\n"));
+ (*resize)(w);
+ }
+ }
+ } else {
+ CALLGEOTAT(_XtGeoTrace(w,"No change in configuration\n"));
+ }
+
+ CALLGEOTAT(_XtGeoTab(-1));
+ UNLOCK_APP(app);
+} /* XtConfigureWidget */
+
+void XtMoveWidget(
+ Widget w,
+ _XtPosition x,
+ _XtPosition y)
+{
+ XtConfigureWidget(w, x, y, w->core.width, w->core.height,
+ w->core.border_width);
+} /* XtMoveWidget */
+
+void XtTranslateCoords(
+ register Widget w,
+ _XtPosition x,
+ _XtPosition y,
+ register Position *rootx, /* return */
+ register Position *rooty) /* return */
+{
+ Position garbagex, garbagey;
+ XtAppContext app = XtWidgetToApplicationContext(w);
+
+ LOCK_APP(app);
+ if (rootx == NULL) rootx = &garbagex;
+ if (rooty == NULL) rooty = &garbagey;
+
+ *rootx = x;
+ *rooty = y;
+
+ for (; w != NULL && ! XtIsShell(w); w = w->core.parent) {
+ *rootx += w->core.x + w->core.border_width;
+ *rooty += w->core.y + w->core.border_width;
+ }
+
+ if (w == NULL)
+ XtAppWarningMsg(app,
+ "invalidShell","xtTranslateCoords",XtCXtToolkitError,
+ "Widget has no shell ancestor",
+ (String *)NULL, (Cardinal *)NULL);
+ else {
+ Position x, y;
+ _XtShellGetCoordinates( w, &x, &y );
+ *rootx += x + w->core.border_width;
+ *rooty += y + w->core.border_width;
+ }
+ UNLOCK_APP(app);
+}
+
+XtGeometryResult XtQueryGeometry(
+ Widget widget,
+ register XtWidgetGeometry *intended, /* parent's changes; may be NULL */
+ XtWidgetGeometry *reply) /* child's preferred geometry; never NULL */
+{
+ XtWidgetGeometry null_intended;
+ XtGeometryHandler query;
+ XtGeometryResult result;
+ WIDGET_TO_APPCON(widget);
+
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "\"%s\" is asking its preferred geometry to \"%s\".\n",
+ (XtParent(widget))?XtName(XtParent(widget)):"Root",
+ XtName(widget)));
+ CALLGEOTAT(_XtGeoTab(1));
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ query = XtClass(widget)->core_class.query_geometry;
+ UNLOCK_PROCESS;
+ reply->request_mode = 0;
+ if (query != NULL) {
+ if (intended == NULL) {
+ null_intended.request_mode = 0;
+ intended = &null_intended;
+#ifdef XT_GEO_TATTLER
+ CALLGEOTAT(_XtGeoTrace(widget,"without any constraint.\n"));
+ } else {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ "with the following constraints:\n"));
+
+ if (intended->request_mode & CWX) {
+ CALLGEOTAT(_XtGeoTrace(widget," x = %d\n",intended->x));
+ }
+ if (intended->request_mode & CWY) {
+ CALLGEOTAT(_XtGeoTrace(widget," y = %d\n",intended->y));
+ }
+ if (intended->request_mode & CWWidth) {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ " width = %d\n",intended->width));
+ }
+ if (intended->request_mode & CWHeight) {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ " height = %d\n",intended->height));
+ }
+ if (intended->request_mode & CWBorderWidth) {
+ CALLGEOTAT(_XtGeoTrace(widget,
+ " border_width = %d\n",intended->border_width));
+ }
+#endif
+ }
+
+ result = (*query) (widget, intended, reply);
+ }
+ else {
+ CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" has no QueryGeometry proc, return the current state\n",XtName(widget)));
+
+ result = XtGeometryYes;
+ }
+
+#ifdef XT_GEO_TATTLER
+#define FillIn(mask, field) \
+ if (!(reply->request_mode & mask)) {\
+ reply->field = widget->core.field;\
+ _XtGeoTrace(widget," using core %s = %d.\n","field",\
+ widget->core.field);\
+ } else {\
+ _XtGeoTrace(widget," replied %s = %d\n","field",\
+ reply->field);\
+ }
+#else
+#define FillIn(mask, field) \
+ if (!(reply->request_mode & mask)) reply->field = widget->core.field;
+#endif
+
+ FillIn(CWX, x);
+ FillIn(CWY, y);
+ FillIn(CWWidth, width);
+ FillIn(CWHeight, height);
+ FillIn(CWBorderWidth, border_width);
+
+ CALLGEOTAT(_XtGeoTab(-1));
+#undef FillIn
+
+ if (!(reply->request_mode & CWStackMode))
+ reply->stack_mode = XtSMDontChange;
+ UNLOCK_APP(app);
+ return result;
+}
diff --git a/nx-X11/lib/Xt/GetActKey.c b/nx-X11/lib/Xt/GetActKey.c
new file mode 100644
index 000000000..20cae5efe
--- /dev/null
+++ b/nx-X11/lib/Xt/GetActKey.c
@@ -0,0 +1,102 @@
+/* $Xorg: GetActKey.c,v 1.4 2001/02/09 02:03:55 xorgcvs Exp $ */
+
+/*LINTLIBRARY*/
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+
+KeySym XtGetActionKeysym(
+ XEvent *event,
+ Modifiers *modifiers_return)
+{
+ TMKeyContext tm_context;
+ Modifiers modifiers;
+ KeySym keysym, retval;
+
+ LOCK_PROCESS;
+ tm_context= _XtGetPerDisplay(event->xany.display)->tm_context;
+ if (event->xany.type != KeyPress && event->xany.type != KeyRelease) {
+ UNLOCK_PROCESS;
+ return NoSymbol;
+ }
+ if (tm_context != NULL
+ && event == tm_context->event
+ && event->xany.serial == tm_context->serial ) {
+
+ if (modifiers_return != NULL)
+ *modifiers_return = tm_context->modifiers;
+ retval = tm_context->keysym;
+ UNLOCK_PROCESS;
+ return retval;
+ }
+
+ XtTranslateKeycode( event->xany.display, (KeyCode)event->xkey.keycode,
+ event->xkey.state, &modifiers, &keysym );
+
+ if (modifiers_return != NULL)
+ *modifiers_return = event->xkey.state & modifiers;
+
+ UNLOCK_PROCESS;
+ return keysym;
+}
diff --git a/nx-X11/lib/Xt/GetResList.c b/nx-X11/lib/Xt/GetResList.c
new file mode 100644
index 000000000..8f99398d7
--- /dev/null
+++ b/nx-X11/lib/Xt/GetResList.c
@@ -0,0 +1,193 @@
+/* $Xorg: GetResList.c,v 1.4 2001/02/09 02:03:55 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/GetResList.c,v 3.5 2001/08/22 22:52:18 dawes 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "Intrinsic.h"
+
+/*
+ * XtGetResourceList(), XtGetConstraintResourceList()
+ */
+
+#define TOXRMQUARK(p) ((XrmQuark)(long)(p)) /* avoid LP64 warnings */
+
+void XtGetResourceList(
+ WidgetClass widget_class,
+ XtResourceList *resources,
+ Cardinal *num_resources)
+{
+ int size;
+ register Cardinal i, dest = 0;
+ register XtResourceList *list, dlist;
+
+ LOCK_PROCESS;
+ size = widget_class->core_class.num_resources * sizeof(XtResource);
+ *resources = (XtResourceList) __XtMalloc((unsigned) size);
+
+ if (!widget_class->core_class.class_inited) {
+ /* Easy case */
+
+ (void) memmove((char *) *resources,
+ (char *)widget_class->core_class.resources, size);
+ *num_resources = widget_class->core_class.num_resources;
+ UNLOCK_PROCESS;
+ return;
+ }
+
+ /* Nope, it's the hard case */
+
+ list = (XtResourceList *) widget_class->core_class.resources;
+ dlist = *resources;
+ for (i = 0; i < widget_class->core_class.num_resources; i++) {
+ if (list[i] != NULL) {
+ dlist[dest].resource_name = (String)
+ XrmQuarkToString(TOXRMQUARK(list[i]->resource_name));
+ dlist[dest].resource_class = (String)
+ XrmQuarkToString(TOXRMQUARK(list[i]->resource_class));
+ dlist[dest].resource_type = (String)
+ XrmQuarkToString(TOXRMQUARK(list[i]->resource_type));
+ dlist[dest].resource_size = list[i]->resource_size;
+ /* trust that resource_offset isn't that big */
+ dlist[dest].resource_offset = (Cardinal)
+ -((int)(list[i]->resource_offset + 1));
+ dlist[dest].default_type = (String)
+ XrmQuarkToString(TOXRMQUARK(list[i]->default_type));
+ dlist[dest].default_addr = list[i]->default_addr;
+ dest++;
+ }
+ }
+ *num_resources = dest;
+ UNLOCK_PROCESS;
+}
+
+
+static Boolean ClassIsSubclassOf(WidgetClass class, WidgetClass superclass)
+{
+ for (; class != NULL; class = class->core_class.superclass) {
+ if (class == superclass) return True;
+ }
+ return False;
+}
+
+void XtGetConstraintResourceList(
+ WidgetClass widget_class,
+ XtResourceList *resources,
+ Cardinal *num_resources)
+{
+ int size;
+ register Cardinal i, dest = 0;
+ register XtResourceList *list, dlist;
+ ConstraintWidgetClass class = (ConstraintWidgetClass)widget_class;
+
+ LOCK_PROCESS;
+ if ( (class->core_class.class_inited &&
+ !(class->core_class.class_inited & ConstraintClassFlag))
+ || (!class->core_class.class_inited &&
+ !ClassIsSubclassOf(widget_class, constraintWidgetClass))
+ || class->constraint_class.num_resources == 0) {
+
+ *resources = NULL;
+ *num_resources = 0;
+ UNLOCK_PROCESS;
+ return;
+ }
+
+ size = class->constraint_class.num_resources * sizeof(XtResource);
+ *resources = (XtResourceList) __XtMalloc((unsigned) size);
+
+ if (!class->core_class.class_inited) {
+ /* Easy case */
+
+ (void) memmove((char *) *resources,
+ (char *)class->constraint_class.resources, size);
+ *num_resources = class->constraint_class.num_resources;
+ UNLOCK_PROCESS;
+ return;
+ }
+
+ /* Nope, it's the hard case */
+
+ list = (XtResourceList *) class->constraint_class.resources;
+ dlist = *resources;
+ for (i = 0; i < class->constraint_class.num_resources; i++) {
+ if (list[i] != NULL) {
+ dlist[dest].resource_name = (String)
+ XrmQuarkToString(TOXRMQUARK(list[i]->resource_name));
+ dlist[dest].resource_class = (String)
+ XrmQuarkToString(TOXRMQUARK(list[i]->resource_class));
+ dlist[dest].resource_type = (String)
+ XrmQuarkToString(TOXRMQUARK(list[i]->resource_type));
+ dlist[dest].resource_size = list[i]->resource_size;
+ /* trust that resource_offset isn't that big */
+ dlist[dest].resource_offset = (Cardinal)
+ -((int)(list[i]->resource_offset + 1));
+ dlist[dest].default_type = (String)
+ XrmQuarkToString(TOXRMQUARK(list[i]->default_type));
+ dlist[dest].default_addr = list[i]->default_addr;
+ dest++;
+ }
+ }
+ *num_resources = dest;
+ UNLOCK_PROCESS;
+}
diff --git a/nx-X11/lib/Xt/GetValues.c b/nx-X11/lib/Xt/GetValues.c
new file mode 100644
index 000000000..f6b8e1f3b
--- /dev/null
+++ b/nx-X11/lib/Xt/GetValues.c
@@ -0,0 +1,251 @@
+/* $Xorg: GetValues.c,v 1.4 2001/02/09 02:03:55 xorgcvs Exp $ */
+/*LINTLIBRARY*/
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+/* $XFree86: xc/lib/Xt/GetValues.c,v 1.2 2001/08/22 22:52:18 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+
+static int GetValues(
+ char* base, /* Base address to fetch values from */
+ XrmResourceList* res, /* The current resource values. */
+ register Cardinal num_resources, /* number of items in resources */
+ ArgList args, /* The resource values requested */
+ Cardinal num_args) /* number of items in arg list */
+{
+ register ArgList arg;
+ register Cardinal i;
+ register XrmName argName;
+ register XrmResourceList* xrmres;
+ int translation_arg_num = -1;
+ static XrmQuark QCallback = NULLQUARK;
+ static XrmQuark QTranslationTable = NULLQUARK;
+
+ LOCK_PROCESS;
+ if (QCallback == NULLQUARK) {
+ QCallback = XrmPermStringToQuark(XtRCallback);
+ QTranslationTable = XrmPermStringToQuark(XtRTranslationTable);
+ }
+ UNLOCK_PROCESS;
+
+ /* Resource lists should be in compiled form already */
+
+ for (arg = args ; num_args != 0; num_args--, arg++) {
+ argName = StringToName(arg->name);
+ for (xrmres = res, i = 0; i < num_resources; i++, xrmres++) {
+ if (argName == (*xrmres)->xrm_name) {
+ /* hack; do special cases here instead of a get_values_hook
+ * because get_values_hook looses info as to
+ * whether arg->value == NULL for ancient compatibility
+ * mode in _XtCopyToArg. It helps performance, too...
+ */
+ if ((*xrmres)->xrm_type == QCallback) {
+ XtCallbackList callback = _XtGetCallbackList(
+ (InternalCallbackList *)
+ (base - (*xrmres)->xrm_offset - 1));
+ _XtCopyToArg(
+ (char*)&callback, &arg->value,
+ (*xrmres)->xrm_size);
+ }
+ else if ((*xrmres)->xrm_type == QTranslationTable)
+ translation_arg_num = (int) (arg - args);
+ else {
+ _XtCopyToArg(
+ base - (*xrmres)->xrm_offset - 1,
+ &arg->value,
+ (*xrmres)->xrm_size);
+ }
+ break;
+ }
+ }
+ }
+ return translation_arg_num;
+} /* GetValues */
+
+static void CallGetValuesHook(
+ WidgetClass widget_class,
+ Widget w,
+ ArgList args,
+ Cardinal num_args)
+{
+ WidgetClass superclass;
+ XtArgsProc get_values_hook;
+
+ LOCK_PROCESS;
+ superclass = widget_class->core_class.superclass;
+ UNLOCK_PROCESS;
+ if (superclass != NULL)
+ CallGetValuesHook (superclass, w, args, num_args);
+
+ LOCK_PROCESS;
+ get_values_hook = widget_class->core_class.get_values_hook;
+ UNLOCK_PROCESS;
+ if (get_values_hook != NULL)
+ (*get_values_hook) (w, args, &num_args);
+}
+
+
+
+static void CallConstraintGetValuesHook(
+ WidgetClass widget_class,
+ Widget w,
+ ArgList args,
+ Cardinal num_args)
+{
+ ConstraintClassExtension ext;
+
+ LOCK_PROCESS;
+ if (widget_class->core_class.superclass
+ ->core_class.class_inited & ConstraintClassFlag) {
+ CallConstraintGetValuesHook
+ (widget_class->core_class.superclass, w, args, num_args);
+ }
+
+ for (ext = (ConstraintClassExtension)((ConstraintWidgetClass)widget_class)
+ ->constraint_class.extension;
+ ext != NULL && ext->record_type != NULLQUARK;
+ ext = (ConstraintClassExtension)ext->next_extension);
+
+ if (ext != NULL) {
+ if ( ext->version == XtConstraintExtensionVersion
+ && ext->record_size == sizeof(ConstraintClassExtensionRec)) {
+ if (ext->get_values_hook != NULL)
+ (*(ext->get_values_hook)) (w, args, &num_args);
+ } else {
+ String params[1];
+ Cardinal num_params = 1;
+ params[0] = widget_class->core_class.class_name;
+ XtAppWarningMsg(XtWidgetToApplicationContext(w),
+ "invalidExtension", "xtCreateWidget", XtCXtToolkitError,
+ "widget class %s has invalid ConstraintClassExtension record",
+ params, &num_params);
+ }
+ }
+ UNLOCK_PROCESS;
+}
+
+
+void XtGetValues(
+ register Widget w,
+ register ArgList args,
+ register Cardinal num_args)
+{
+ WidgetClass wc;
+ int targ;
+ XtAppContext app = XtWidgetToApplicationContext(w);
+
+ if (num_args == 0) return;
+ if ((args == NULL) && (num_args != 0)) {
+ XtAppErrorMsg(app,
+ "invalidArgCount","xtGetValues",XtCXtToolkitError,
+ "Argument count > 0 on NULL argument list in XtGetValues",
+ (String *)NULL, (Cardinal *)NULL);
+ }
+
+ LOCK_APP(app);
+ wc = XtClass(w);
+ LOCK_PROCESS;
+ /* Get widget values */
+ targ = GetValues((char*)w, (XrmResourceList *) wc->core_class.resources,
+ wc->core_class.num_resources, args, num_args);
+ UNLOCK_PROCESS;
+ if (targ != -1 && XtIsWidget(w)) {
+ XtTranslations translations = _XtGetTranslationValue(w);
+ _XtCopyToArg((char*)&translations, &args[targ].value,
+ sizeof(XtTranslations));
+ }
+
+ /* Get constraint values if necessary */
+ /* constraints may be NULL if constraint_size==0 */
+ if (XtParent(w) != NULL && !XtIsShell(w) && XtIsConstraint(XtParent(w)) &&
+ w->core.constraints) {
+ ConstraintWidgetClass cwc
+ = (ConstraintWidgetClass) XtClass(XtParent(w));
+ LOCK_PROCESS;
+ GetValues((char*)w->core.constraints,
+ (XrmResourceList *)(cwc->constraint_class.resources),
+ cwc->constraint_class.num_resources, args, num_args);
+ UNLOCK_PROCESS;
+ }
+ /* Notify any class procedures that we have performed get_values */
+ CallGetValuesHook(wc, w, args, num_args);
+
+ /* Notify constraint get_values if necessary */
+ if (XtParent(w) != NULL && !XtIsShell(w) && XtIsConstraint(XtParent(w)))
+ CallConstraintGetValuesHook(XtClass(XtParent(w)), w, args,num_args);
+ UNLOCK_APP(app);
+} /* XtGetValues */
+
+void XtGetSubvalues(
+ XtPointer base, /* Base address to fetch values from */
+ XtResourceList resources, /* The current resource values. */
+ Cardinal num_resources, /* number of items in resources */
+ ArgList args, /* The resource values requested */
+ Cardinal num_args) /* number of items in arg list */
+{
+ XrmResourceList* xrmres;
+ xrmres = _XtCreateIndirectionTable(resources, num_resources);
+ GetValues((char*)base, xrmres, num_resources, args, num_args);
+ XtFree((char *)xrmres);
+}
diff --git a/nx-X11/lib/Xt/HookObj.c b/nx-X11/lib/Xt/HookObj.c
new file mode 100644
index 000000000..f4ac749b2
--- /dev/null
+++ b/nx-X11/lib/Xt/HookObj.c
@@ -0,0 +1,137 @@
+/* $Xorg: HookObj.c,v 1.4 2001/02/09 02:03:55 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.
+
+*/
+/* $XFree86: xc/lib/Xt/HookObj.c,v 1.2 2001/08/22 22:52:18 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+/******************************************************************
+ *
+ * Hook Object Resources
+ *
+ ******************************************************************/
+
+static XtResource resources[] = {
+ { XtNcreateHook, XtCCallback, XtRCallback, sizeof(XtPointer),
+ XtOffsetOf(HookObjRec, hooks.createhook_callbacks),
+ XtRCallback, (XtPointer)NULL},
+ { XtNchangeHook, XtCCallback, XtRCallback, sizeof(XtPointer),
+ XtOffsetOf(HookObjRec, hooks.changehook_callbacks),
+ XtRCallback, (XtPointer)NULL},
+ { XtNconfigureHook, XtCCallback, XtRCallback, sizeof(XtPointer),
+ XtOffsetOf(HookObjRec, hooks.confighook_callbacks),
+ XtRCallback, (XtPointer)NULL},
+ { XtNgeometryHook, XtCCallback, XtRCallback, sizeof(XtPointer),
+ XtOffsetOf(HookObjRec, hooks.geometryhook_callbacks),
+ XtRCallback, (XtPointer)NULL},
+ { XtNdestroyHook, XtCCallback, XtRCallback, sizeof(XtPointer),
+ XtOffsetOf(HookObjRec, hooks.destroyhook_callbacks),
+ XtRCallback, (XtPointer)NULL},
+ { XtNshells, XtCReadOnly, XtRWidgetList, sizeof(WidgetList),
+ XtOffsetOf(HookObjRec, hooks.shells), XtRImmediate, (XtPointer) NULL },
+ { XtNnumShells, XtCReadOnly, XtRCardinal, sizeof(Cardinal),
+ XtOffsetOf(HookObjRec, hooks.num_shells), XtRImmediate, (XtPointer) 0 }
+};
+
+static void GetValuesHook(Widget widget, ArgList args, Cardinal *num_args);
+static void Initialize(Widget req, Widget new, ArgList args,
+ Cardinal *num_args);
+
+externaldef(hookobjclassrec) HookObjClassRec hookObjClassRec = {
+ { /* Object Class Part */
+ /* superclass */ (WidgetClass)&objectClassRec,
+ /* class_name */ "Hook",
+ /* widget_size */ sizeof(HookObjRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize*/ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ NULL,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ NULL,
+ /* expose */ NULL,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ NULL,
+ /* get_values_hook */ GetValuesHook,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL
+ },
+ { /* HookObj Class Part */
+ /* unused */ 0
+ }
+};
+
+externaldef(hookObjectClass) WidgetClass hookObjectClass =
+ (WidgetClass)&hookObjClassRec;
+
+static void FreeShellList(
+ Widget w,
+ XtPointer closure,
+ XtPointer call_data)
+{
+ HookObject h = (HookObject)w;
+ if (h->hooks.shells != NULL)
+ XtFree((char*)h->hooks.shells);
+}
+
+static void Initialize(
+ Widget req,
+ Widget new,
+ ArgList args,
+ Cardinal* num_args)
+{
+ HookObject w = (HookObject) new;
+ w->hooks.max_shells = 0;
+ XtAddCallback (new, XtNdestroyCallback, FreeShellList, (XtPointer) NULL);
+}
+
+static void GetValuesHook(
+ Widget widget,
+ ArgList args,
+ Cardinal* num_args)
+{
+ /* get the XtNshells and XtNnumShells pseudo-resources */
+}
diff --git a/nx-X11/lib/Xt/HookObjI.h b/nx-X11/lib/Xt/HookObjI.h
new file mode 100644
index 000000000..c9a22a256
--- /dev/null
+++ b/nx-X11/lib/Xt/HookObjI.h
@@ -0,0 +1,71 @@
+/* $Xorg: HookObjI.h,v 1.4 2001/02/09 02:03:55 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.
+
+*/
+
+#ifndef _XtHookObjI_h
+#define _XtHookObjI_h
+
+/* This object is implementation-dependent and private to the library. */
+
+typedef struct _HookObjRec *HookObject;
+typedef struct _HookObjClassRec *HookObjectClass;
+
+externalref WidgetClass hookObjectClass;
+
+typedef struct _HookObjPart {
+ /* resources */
+ XtCallbackList createhook_callbacks;
+ XtCallbackList changehook_callbacks;
+ XtCallbackList confighook_callbacks;
+ XtCallbackList geometryhook_callbacks;
+ XtCallbackList destroyhook_callbacks;
+ WidgetList shells;
+ Cardinal num_shells;
+ /* private data */
+ Cardinal max_shells;
+ Screen* screen;
+}HookObjPart;
+
+typedef struct _HookObjRec {
+ ObjectPart object;
+ HookObjPart hooks;
+} HookObjRec;
+
+typedef struct _HookObjClassPart {
+ int unused;
+} HookObjClassPart;
+
+typedef struct _HookObjClassRec {
+ ObjectClassPart object_class;
+ HookObjClassPart hook_class;
+} HookObjClassRec;
+
+externalref HookObjClassRec hookObjClassRec;
+
+#endif /* ifndef _Xt_HookObjI_h */
+
+
diff --git a/nx-X11/lib/Xt/Hooks.c b/nx-X11/lib/Xt/Hooks.c
new file mode 100644
index 000000000..05b67ce05
--- /dev/null
+++ b/nx-X11/lib/Xt/Hooks.c
@@ -0,0 +1,158 @@
+/* $Xorg: Hooks.c,v 1.4 2001/02/09 02:03:55 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.
+
+*/
+/* $XFree86: xc/lib/Xt/Hooks.c,v 1.3 2001/12/14 19:56:18 dawes Exp $ */
+
+/*LINTLIBRARY*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "CreateI.h"
+
+static void FreeBlockHookList(
+ Widget widget, /* unused (and invalid) */
+ XtPointer closure, /* ActionHook* */
+ XtPointer call_data) /* unused */
+{
+ BlockHook list = *(BlockHook*)closure;
+ while (list != NULL) {
+ BlockHook next = list->next;
+ XtFree( (XtPointer)list );
+ list = next;
+ }
+}
+
+
+XtBlockHookId XtAppAddBlockHook(
+ XtAppContext app,
+ XtBlockHookProc proc,
+ XtPointer closure)
+{
+ BlockHook hook = XtNew(BlockHookRec);
+ LOCK_APP(app);
+ hook->next = app->block_hook_list;
+ hook->app = app;
+ hook->proc = proc;
+ hook->closure = closure;
+ if (app->block_hook_list == NULL) {
+ _XtAddCallback( &app->destroy_callbacks,
+ FreeBlockHookList,
+ (XtPointer)&app->block_hook_list
+ );
+ }
+ app->block_hook_list = hook;
+ UNLOCK_APP(app);
+ return (XtBlockHookId)hook;
+}
+
+
+void XtRemoveBlockHook(
+ XtBlockHookId id)
+{
+ BlockHook *p, hook = (BlockHook)id;
+ XtAppContext app = hook->app;
+ LOCK_APP(app);
+ for (p = &app->block_hook_list; p != NULL && *p != hook; p = &(*p)->next);
+ if (p == NULL) {
+#ifdef DEBUG
+ XtAppWarningMsg(app, "badId", "xtRemoveBlockHook", XtCXtToolkitError,
+ "XtRemoveBlockHook called with bad or old hook id",
+ (String*)NULL, (Cardinal*)NULL);
+#endif /*DEBUG*/
+ UNLOCK_APP(app);
+ return;
+ }
+ *p = hook->next;
+ XtFree( (XtPointer)hook );
+ UNLOCK_APP(app);
+}
+
+static void DeleteShellFromHookObj(
+ Widget shell,
+ XtPointer closure,
+ XtPointer call_data)
+{
+ /* app_con is locked when this function is called */
+ Cardinal ii, jj;
+ HookObject ho = (HookObject) closure;
+
+ for (ii = 0; ii < ho->hooks.num_shells; ii++)
+ if (ho->hooks.shells[ii] == shell) {
+ /* collapse the list */
+ for (jj = ii; jj < ho->hooks.num_shells; jj++) {
+ if ((jj+1) < ho->hooks.num_shells)
+ ho->hooks.shells[jj] = ho->hooks.shells[jj+1];
+ }
+ break;
+ }
+ ho->hooks.num_shells--;
+}
+
+#define SHELL_INCR 4
+
+void _XtAddShellToHookObj(
+ Widget shell)
+{
+ /* app_con is locked when this function is called */
+ HookObject ho = (HookObject) XtHooksOfDisplay(XtDisplay(shell));
+
+ if (ho->hooks.num_shells == ho->hooks.max_shells) {
+ ho->hooks.max_shells += SHELL_INCR;
+ ho->hooks.shells =
+ (WidgetList)XtRealloc((char*)ho->hooks.shells,
+ ho->hooks.max_shells * sizeof (Widget));
+ }
+ ho->hooks.shells[ho->hooks.num_shells++] = shell;
+
+ XtAddCallback(shell, XtNdestroyCallback, DeleteShellFromHookObj,
+ (XtPointer)ho);
+}
+
+Boolean _XtIsHookObject(
+ Widget widget)
+{
+ return (widget->core.widget_class == hookObjectClass);
+}
+
+Widget XtHooksOfDisplay(
+ Display* dpy)
+{
+ Widget retval;
+ XtPerDisplay pd;
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ pd = _XtGetPerDisplay(dpy);
+ if (pd->hook_object == NULL)
+ pd->hook_object =
+ _XtCreateHookObj((Screen*)DefaultScreenOfDisplay(dpy));
+ retval = pd->hook_object;
+ UNLOCK_APP(app);
+ return retval;
+}
diff --git a/nx-X11/lib/Xt/Imakefile b/nx-X11/lib/Xt/Imakefile
new file mode 100644
index 000000000..6399e4618
--- /dev/null
+++ b/nx-X11/lib/Xt/Imakefile
@@ -0,0 +1,307 @@
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:12 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/Xt/Imakefile,v 3.18tsi Exp $
+
+#if NXLibraries
+
+/*
+ * This will make applications that use the Xt
+ * toolkit deal with the NX modified select().
+ */
+
+NX_DEFINES = -DNX_TRANS_SOCKET
+
+# -DNX_TRANS_TEST \
+# -DNX_TRANS_DEBUG
+
+#endif
+
+#define DoNormalLib NormalLibXt
+#define DoSharedLib SharedLibXt
+#define DoExtraLib SharedLibXt
+#define DoDebugLib DebugLibXt
+#define DoProfileLib ProfileLibXt
+#define HasSharedData YES
+#define LibName Xt
+#define SoRev SOXTREV
+#define IncSubdir X11
+
+#include <Threads.tmpl>
+
+#if ResourceConfigurationManagement
+RCMOBJS = ResConfig.o
+RCMSRCS = ResConfig.c
+#else
+RCM_DEFINES = -DX_NO_RESOURCE_CONFIGURATION_MANAGEMENT
+#endif
+
+#if XtPopdownConformance
+POPDOWN_DEFINES =
+#else
+POPDOWN_DEFINES = -DX_NO_XT_POPDOWN_CONFORMANCE
+#endif
+
+#ifndef MotifBC
+#define MotifBC NO
+#endif
+
+/* "YES" allows illegal XtGetValues requests with NULL ArgVal to
+ usually succeed, as R5 did. Some applications erroneously rely on
+ this behavior. Support for this will be removed in a future release. */
+#ifndef GetValuesBC
+#define GetValuesBC NO
+#endif
+
+#ifdef SharedXtReqs
+REQUIREDLIBS = SharedXtReqs
+#endif
+
+/* config options */
+
+XFILESEARCHPATHDEFAULT = XFileSearchPathDefault
+
+XTERRORPREFIX = XtErrorPrefix
+XTWARNINGPREFIX = XtWarningPrefix
+
+#if UnalignedReferencesAllowed
+ ALIGN_DEFINES = -DUNALIGNED
+#endif
+#if DoSharedLib && defined(SharedAllocateLocalDefines)
+#undef AllocateLocalDefines
+#define AllocateLocalDefines SharedAllocateLocalDefines
+#endif
+#if HasPoll
+ POLL_DEFINES = -DUSE_POLL
+#endif
+#if HasSnprintf
+ MISC_DEFINES = -DUSE_SNPRINTF -DLIBXT
+#endif
+
+#if NXLibraries
+ DEFINES = AllocateLocalDefines $(ALIGN_DEFINES) $(POLL_DEFINES) $(MISC_DEFINES) XtExtraDefines $(RCM_DEFINES) $(POPDOWN_DEFINES) $(NX_DEFINES)
+#else
+ DEFINES = AllocateLocalDefines $(ALIGN_DEFINES) $(POLL_DEFINES) $(MISC_DEFINES) XtExtraDefines $(RCM_DEFINES) $(POPDOWN_DEFINES)
+#endif
+
+ DB_DEFINES = -DERRORDB=\"$(LIBDIR)/XtErrorDB\" \
+ -DXTERROR_PREFIX=\"$(XTERRORPREFIX)\" \
+ -DXTWARNING_PREFIX=\"$(XTWARNINGPREFIX)\"
+
+ SRCH_DEFINES = -DXFILESEARCHPATHDEFAULT=\"$(XFILESEARCHPATHDEFAULT)\"
+#if Malloc0ReturnsNull
+ ALLOC_DEFINES = XtMalloc0ReturnsNullDefines
+#endif
+#if MotifBC
+ BC_DEFINES = -DMOTIFBC
+#endif
+#if GetValuesBC
+ GETVALUES_DEFINES = -DGETVALUES_BUG
+#endif
+#if NoRConst
+ RCONST_DEFINES = -DNORCONST
+#endif
+STRINGSABIOPTIONS = ToolkitStringsABIOptions
+
+ LINTLIBS = $(LINTXLIB)
+
+HEADERS = \
+ Composite.h \
+ CompositeP.h \
+ Constraint.h \
+ ConstrainP.h \
+ Core.h \
+ CoreP.h \
+ Intrinsic.h \
+ IntrinsicP.h \
+ Object.h \
+ ObjectP.h \
+ RectObj.h \
+ RectObjP.h \
+ Shell.h \
+ ShellP.h \
+ StringDefs.h \
+ Vendor.h \
+ VendorP.h \
+ \
+ CallbackI.h \
+ ConvertI.h \
+ CreateI.h \
+ EventI.h \
+ HookObjI.h \
+ InitialI.h \
+ IntrinsicI.h \
+ PassivGraI.h \
+ ResourceI.h \
+ SelectionI.h \
+ ShellI.h \
+ ThreadsI.h \
+ TranslateI.h \
+ VarargsI.h
+
+
+SRCS = \
+ $(MISCSRCS) \
+ ActionHook.c \
+ Alloc.c \
+ ArgList.c \
+ Callback.c \
+ ClickTime.c \
+ Composite.c \
+ Constraint.c \
+ Convert.c \
+ Converters.c \
+ Core.c \
+ Create.c \
+ Destroy.c \
+ Display.c \
+ Error.c \
+ Event.c \
+ EventUtil.c \
+ Functions.c \
+ GCManager.c \
+ Geometry.c \
+ GetActKey.c \
+ GetResList.c \
+ GetValues.c \
+ HookObj.c \
+ Hooks.c \
+ Initialize.c \
+ Intrinsic.c \
+ Keyboard.c \
+ Manage.c \
+ NextEvent.c \
+ Object.c \
+ PassivGrab.c \
+ Pointer.c \
+ Popup.c \
+ PopupCB.c \
+ RectObj.c \
+ Resources.c \
+ Selection.c \
+ SetSens.c \
+ SetValues.c \
+ SetWMCW.c \
+ Shell.c \
+ StringDefs.c \
+ Threads.c \
+ TMaction.c \
+ TMgrab.c \
+ TMkey.c \
+ TMparse.c \
+ TMprint.c \
+ TMstate.c \
+ VarCreate.c \
+ VarGet.c \
+ Varargs.c \
+ Vendor.c \
+ sharedlib.c \
+ $(RCMSRCS)
+
+OBJS = \
+ $(MISCOBJS) \
+ ActionHook.o \
+ Alloc.o \
+ ArgList.o \
+ Callback.o \
+ ClickTime.o \
+ Composite.o \
+ Constraint.o \
+ Convert.o \
+ Converters.o \
+ Core.o \
+ Create.o \
+ Destroy.o \
+ Display.o \
+ Error.o \
+ Event.o \
+ EventUtil.o \
+ Functions.o \
+ GCManager.o \
+ Geometry.o \
+ GetActKey.o \
+ GetResList.o \
+ GetValues.o \
+ HookObj.o \
+ Hooks.o \
+ Initialize.o \
+ Intrinsic.o \
+ Keyboard.o \
+ Manage.o \
+ NextEvent.o \
+ Object.o \
+ PassivGrab.o \
+ Pointer.o \
+ Popup.o \
+ PopupCB.o \
+ RectObj.o \
+ Resources.o \
+ Selection.o \
+ SetSens.o \
+ SetValues.o \
+ SetWMCW.o \
+ Shell.o \
+ StringDefs.o \
+ Threads.o \
+ TMaction.o \
+ TMgrab.o \
+ TMkey.o \
+ TMparse.o \
+ TMprint.o \
+ TMstate.o \
+ VarCreate.o \
+ VarGet.o \
+ Varargs.o \
+ Vendor.o \
+ $(RCMOBJS)
+
+#if SharedDataSeparation
+UNSHAREDOBJS = StringDefs.o sharedlib.o
+#else
+UNSHAREDOBJS = sharedlib.o
+#endif
+
+#include <Library.tmpl>
+
+SpecialCLibObjectRule(Intrinsic,$(ICONFIGFILES),$(SRCH_DEFINES))
+SpecialCLibObjectRule(Error,$(ICONFIGFILES),$(DB_DEFINES))
+SpecialCLibObjectRule(Alloc,$(_NOOP_),$(ALLOC_DEFINES))
+SpecialCLibObjectRule(Converters,$(ICONFIGFILES),$(BC_DEFINES))
+SpecialCLibObjectRule(Resources,$(ICONFIGFILES),$(GETVALUES_DEFINES))
+SpecialCLibObjectRule(TMaction,$(_NOOP_),$(RCONST_DEFINES))
+#if BuildXKBlib
+SpecialCLibObjectRule(TMkey,$(_NOOP_),-DXKB)
+#endif
+#if DoSharedLib
+SpecialCObjectRule(sharedlib,$(_NOOP_),$(SHLIBDEF))
+#endif
+#if defined(ItsyCompilerBug)
+SpecialCLibObjectRule(PassivGrab,$(_NOOP_),-O0)
+#endif
+
+STRINGS_FILES = StringDefs.c StringDefs.h Shell.h
+STRINGS_TMPLS = util/StrDefs.ct util/StrDefs.ht util/Shell.ht
+STRING_LIST = util/string.list
+
+ToolkitMakeStrings($(STRINGS_FILES),$(STRING_LIST),$(STRINGSABIOPTIONS),$(STRINGS_TMPLS),StringDefs.c)
+
+DependTarget()
diff --git a/nx-X11/lib/Xt/Imakefile.NX.original b/nx-X11/lib/Xt/Imakefile.NX.original
new file mode 100644
index 000000000..6399e4618
--- /dev/null
+++ b/nx-X11/lib/Xt/Imakefile.NX.original
@@ -0,0 +1,307 @@
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:12 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/Xt/Imakefile,v 3.18tsi Exp $
+
+#if NXLibraries
+
+/*
+ * This will make applications that use the Xt
+ * toolkit deal with the NX modified select().
+ */
+
+NX_DEFINES = -DNX_TRANS_SOCKET
+
+# -DNX_TRANS_TEST \
+# -DNX_TRANS_DEBUG
+
+#endif
+
+#define DoNormalLib NormalLibXt
+#define DoSharedLib SharedLibXt
+#define DoExtraLib SharedLibXt
+#define DoDebugLib DebugLibXt
+#define DoProfileLib ProfileLibXt
+#define HasSharedData YES
+#define LibName Xt
+#define SoRev SOXTREV
+#define IncSubdir X11
+
+#include <Threads.tmpl>
+
+#if ResourceConfigurationManagement
+RCMOBJS = ResConfig.o
+RCMSRCS = ResConfig.c
+#else
+RCM_DEFINES = -DX_NO_RESOURCE_CONFIGURATION_MANAGEMENT
+#endif
+
+#if XtPopdownConformance
+POPDOWN_DEFINES =
+#else
+POPDOWN_DEFINES = -DX_NO_XT_POPDOWN_CONFORMANCE
+#endif
+
+#ifndef MotifBC
+#define MotifBC NO
+#endif
+
+/* "YES" allows illegal XtGetValues requests with NULL ArgVal to
+ usually succeed, as R5 did. Some applications erroneously rely on
+ this behavior. Support for this will be removed in a future release. */
+#ifndef GetValuesBC
+#define GetValuesBC NO
+#endif
+
+#ifdef SharedXtReqs
+REQUIREDLIBS = SharedXtReqs
+#endif
+
+/* config options */
+
+XFILESEARCHPATHDEFAULT = XFileSearchPathDefault
+
+XTERRORPREFIX = XtErrorPrefix
+XTWARNINGPREFIX = XtWarningPrefix
+
+#if UnalignedReferencesAllowed
+ ALIGN_DEFINES = -DUNALIGNED
+#endif
+#if DoSharedLib && defined(SharedAllocateLocalDefines)
+#undef AllocateLocalDefines
+#define AllocateLocalDefines SharedAllocateLocalDefines
+#endif
+#if HasPoll
+ POLL_DEFINES = -DUSE_POLL
+#endif
+#if HasSnprintf
+ MISC_DEFINES = -DUSE_SNPRINTF -DLIBXT
+#endif
+
+#if NXLibraries
+ DEFINES = AllocateLocalDefines $(ALIGN_DEFINES) $(POLL_DEFINES) $(MISC_DEFINES) XtExtraDefines $(RCM_DEFINES) $(POPDOWN_DEFINES) $(NX_DEFINES)
+#else
+ DEFINES = AllocateLocalDefines $(ALIGN_DEFINES) $(POLL_DEFINES) $(MISC_DEFINES) XtExtraDefines $(RCM_DEFINES) $(POPDOWN_DEFINES)
+#endif
+
+ DB_DEFINES = -DERRORDB=\"$(LIBDIR)/XtErrorDB\" \
+ -DXTERROR_PREFIX=\"$(XTERRORPREFIX)\" \
+ -DXTWARNING_PREFIX=\"$(XTWARNINGPREFIX)\"
+
+ SRCH_DEFINES = -DXFILESEARCHPATHDEFAULT=\"$(XFILESEARCHPATHDEFAULT)\"
+#if Malloc0ReturnsNull
+ ALLOC_DEFINES = XtMalloc0ReturnsNullDefines
+#endif
+#if MotifBC
+ BC_DEFINES = -DMOTIFBC
+#endif
+#if GetValuesBC
+ GETVALUES_DEFINES = -DGETVALUES_BUG
+#endif
+#if NoRConst
+ RCONST_DEFINES = -DNORCONST
+#endif
+STRINGSABIOPTIONS = ToolkitStringsABIOptions
+
+ LINTLIBS = $(LINTXLIB)
+
+HEADERS = \
+ Composite.h \
+ CompositeP.h \
+ Constraint.h \
+ ConstrainP.h \
+ Core.h \
+ CoreP.h \
+ Intrinsic.h \
+ IntrinsicP.h \
+ Object.h \
+ ObjectP.h \
+ RectObj.h \
+ RectObjP.h \
+ Shell.h \
+ ShellP.h \
+ StringDefs.h \
+ Vendor.h \
+ VendorP.h \
+ \
+ CallbackI.h \
+ ConvertI.h \
+ CreateI.h \
+ EventI.h \
+ HookObjI.h \
+ InitialI.h \
+ IntrinsicI.h \
+ PassivGraI.h \
+ ResourceI.h \
+ SelectionI.h \
+ ShellI.h \
+ ThreadsI.h \
+ TranslateI.h \
+ VarargsI.h
+
+
+SRCS = \
+ $(MISCSRCS) \
+ ActionHook.c \
+ Alloc.c \
+ ArgList.c \
+ Callback.c \
+ ClickTime.c \
+ Composite.c \
+ Constraint.c \
+ Convert.c \
+ Converters.c \
+ Core.c \
+ Create.c \
+ Destroy.c \
+ Display.c \
+ Error.c \
+ Event.c \
+ EventUtil.c \
+ Functions.c \
+ GCManager.c \
+ Geometry.c \
+ GetActKey.c \
+ GetResList.c \
+ GetValues.c \
+ HookObj.c \
+ Hooks.c \
+ Initialize.c \
+ Intrinsic.c \
+ Keyboard.c \
+ Manage.c \
+ NextEvent.c \
+ Object.c \
+ PassivGrab.c \
+ Pointer.c \
+ Popup.c \
+ PopupCB.c \
+ RectObj.c \
+ Resources.c \
+ Selection.c \
+ SetSens.c \
+ SetValues.c \
+ SetWMCW.c \
+ Shell.c \
+ StringDefs.c \
+ Threads.c \
+ TMaction.c \
+ TMgrab.c \
+ TMkey.c \
+ TMparse.c \
+ TMprint.c \
+ TMstate.c \
+ VarCreate.c \
+ VarGet.c \
+ Varargs.c \
+ Vendor.c \
+ sharedlib.c \
+ $(RCMSRCS)
+
+OBJS = \
+ $(MISCOBJS) \
+ ActionHook.o \
+ Alloc.o \
+ ArgList.o \
+ Callback.o \
+ ClickTime.o \
+ Composite.o \
+ Constraint.o \
+ Convert.o \
+ Converters.o \
+ Core.o \
+ Create.o \
+ Destroy.o \
+ Display.o \
+ Error.o \
+ Event.o \
+ EventUtil.o \
+ Functions.o \
+ GCManager.o \
+ Geometry.o \
+ GetActKey.o \
+ GetResList.o \
+ GetValues.o \
+ HookObj.o \
+ Hooks.o \
+ Initialize.o \
+ Intrinsic.o \
+ Keyboard.o \
+ Manage.o \
+ NextEvent.o \
+ Object.o \
+ PassivGrab.o \
+ Pointer.o \
+ Popup.o \
+ PopupCB.o \
+ RectObj.o \
+ Resources.o \
+ Selection.o \
+ SetSens.o \
+ SetValues.o \
+ SetWMCW.o \
+ Shell.o \
+ StringDefs.o \
+ Threads.o \
+ TMaction.o \
+ TMgrab.o \
+ TMkey.o \
+ TMparse.o \
+ TMprint.o \
+ TMstate.o \
+ VarCreate.o \
+ VarGet.o \
+ Varargs.o \
+ Vendor.o \
+ $(RCMOBJS)
+
+#if SharedDataSeparation
+UNSHAREDOBJS = StringDefs.o sharedlib.o
+#else
+UNSHAREDOBJS = sharedlib.o
+#endif
+
+#include <Library.tmpl>
+
+SpecialCLibObjectRule(Intrinsic,$(ICONFIGFILES),$(SRCH_DEFINES))
+SpecialCLibObjectRule(Error,$(ICONFIGFILES),$(DB_DEFINES))
+SpecialCLibObjectRule(Alloc,$(_NOOP_),$(ALLOC_DEFINES))
+SpecialCLibObjectRule(Converters,$(ICONFIGFILES),$(BC_DEFINES))
+SpecialCLibObjectRule(Resources,$(ICONFIGFILES),$(GETVALUES_DEFINES))
+SpecialCLibObjectRule(TMaction,$(_NOOP_),$(RCONST_DEFINES))
+#if BuildXKBlib
+SpecialCLibObjectRule(TMkey,$(_NOOP_),-DXKB)
+#endif
+#if DoSharedLib
+SpecialCObjectRule(sharedlib,$(_NOOP_),$(SHLIBDEF))
+#endif
+#if defined(ItsyCompilerBug)
+SpecialCLibObjectRule(PassivGrab,$(_NOOP_),-O0)
+#endif
+
+STRINGS_FILES = StringDefs.c StringDefs.h Shell.h
+STRINGS_TMPLS = util/StrDefs.ct util/StrDefs.ht util/Shell.ht
+STRING_LIST = util/string.list
+
+ToolkitMakeStrings($(STRINGS_FILES),$(STRING_LIST),$(STRINGSABIOPTIONS),$(STRINGS_TMPLS),StringDefs.c)
+
+DependTarget()
diff --git a/nx-X11/lib/Xt/Imakefile.X.original b/nx-X11/lib/Xt/Imakefile.X.original
new file mode 100644
index 000000000..af6da4dbe
--- /dev/null
+++ b/nx-X11/lib/Xt/Imakefile.X.original
@@ -0,0 +1,271 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:12 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/Xt/Imakefile,v 3.18tsi Exp $
+
+#define DoNormalLib NormalLibXt
+#define DoSharedLib SharedLibXt
+#define DoExtraLib SharedLibXt
+#define DoDebugLib DebugLibXt
+#define DoProfileLib ProfileLibXt
+#define HasSharedData YES
+#define LibName Xt
+#define SoRev SOXTREV
+#define IncSubdir X11
+
+#include <Threads.tmpl>
+
+#if ResourceConfigurationManagement
+RCMOBJS = ResConfig.o
+RCMSRCS = ResConfig.c
+#else
+RCM_DEFINES = -DX_NO_RESOURCE_CONFIGURATION_MANAGEMENT
+#endif
+
+#if XtPopdownConformance
+POPDOWN_DEFINES =
+#else
+POPDOWN_DEFINES = -DX_NO_XT_POPDOWN_CONFORMANCE
+#endif
+
+#ifndef MotifBC
+#define MotifBC NO
+#endif
+
+/* "YES" allows illegal XtGetValues requests with NULL ArgVal to
+ usually succeed, as R5 did. Some applications erroneously rely on
+ this behavior. Support for this will be removed in a future release. */
+#ifndef GetValuesBC
+#define GetValuesBC NO
+#endif
+
+#ifdef SharedXtReqs
+REQUIREDLIBS = SharedXtReqs
+#endif
+
+/* config options */
+
+XFILESEARCHPATHDEFAULT = XFileSearchPathDefault
+
+XTERRORPREFIX = XtErrorPrefix
+XTWARNINGPREFIX = XtWarningPrefix
+
+#if UnalignedReferencesAllowed
+ ALIGN_DEFINES = -DUNALIGNED
+#endif
+#if DoSharedLib && defined(SharedAllocateLocalDefines)
+#undef AllocateLocalDefines
+#define AllocateLocalDefines SharedAllocateLocalDefines
+#endif
+#if HasPoll
+ POLL_DEFINES = -DUSE_POLL
+#endif
+#if HasSnprintf
+ MISC_DEFINES = -DUSE_SNPRINTF -DLIBXT
+#endif
+ DEFINES = AllocateLocalDefines $(ALIGN_DEFINES) $(POLL_DEFINES) $(MISC_DEFINES) XtExtraDefines $(RCM_DEFINES) $(POPDOWN_DEFINES)
+
+ DB_DEFINES = -DERRORDB=\"$(LIBDIR)/XtErrorDB\" \
+ -DXTERROR_PREFIX=\"$(XTERRORPREFIX)\" \
+ -DXTWARNING_PREFIX=\"$(XTWARNINGPREFIX)\"
+
+ SRCH_DEFINES = -DXFILESEARCHPATHDEFAULT=\"$(XFILESEARCHPATHDEFAULT)\"
+#if Malloc0ReturnsNull
+ ALLOC_DEFINES = XtMalloc0ReturnsNullDefines
+#endif
+#if MotifBC
+ BC_DEFINES = -DMOTIFBC
+#endif
+#if GetValuesBC
+ GETVALUES_DEFINES = -DGETVALUES_BUG
+#endif
+#if NoRConst
+ RCONST_DEFINES = -DNORCONST
+#endif
+STRINGSABIOPTIONS = ToolkitStringsABIOptions
+
+ LINTLIBS = $(LINTXLIB)
+
+HEADERS = \
+ Composite.h \
+ CompositeP.h \
+ Constraint.h \
+ ConstrainP.h \
+ Core.h \
+ CoreP.h \
+ Intrinsic.h \
+ IntrinsicP.h \
+ Object.h \
+ ObjectP.h \
+ RectObj.h \
+ RectObjP.h \
+ Shell.h \
+ ShellP.h \
+ StringDefs.h \
+ Vendor.h \
+ VendorP.h \
+ \
+ CallbackI.h \
+ ConvertI.h \
+ CreateI.h \
+ EventI.h \
+ HookObjI.h \
+ InitialI.h \
+ IntrinsicI.h \
+ PassivGraI.h \
+ ResourceI.h \
+ SelectionI.h \
+ ShellI.h \
+ ThreadsI.h \
+ TranslateI.h \
+ VarargsI.h
+
+
+SRCS = \
+ $(MISCSRCS) \
+ ActionHook.c \
+ Alloc.c \
+ ArgList.c \
+ Callback.c \
+ ClickTime.c \
+ Composite.c \
+ Constraint.c \
+ Convert.c \
+ Converters.c \
+ Core.c \
+ Create.c \
+ Destroy.c \
+ Display.c \
+ Error.c \
+ Event.c \
+ EventUtil.c \
+ Functions.c \
+ GCManager.c \
+ Geometry.c \
+ GetActKey.c \
+ GetResList.c \
+ GetValues.c \
+ HookObj.c \
+ Hooks.c \
+ Initialize.c \
+ Intrinsic.c \
+ Keyboard.c \
+ Manage.c \
+ NextEvent.c \
+ Object.c \
+ PassivGrab.c \
+ Pointer.c \
+ Popup.c \
+ PopupCB.c \
+ RectObj.c \
+ Resources.c \
+ Selection.c \
+ SetSens.c \
+ SetValues.c \
+ SetWMCW.c \
+ Shell.c \
+ StringDefs.c \
+ Threads.c \
+ TMaction.c \
+ TMgrab.c \
+ TMkey.c \
+ TMparse.c \
+ TMprint.c \
+ TMstate.c \
+ VarCreate.c \
+ VarGet.c \
+ Varargs.c \
+ Vendor.c \
+ sharedlib.c \
+ $(RCMSRCS)
+
+OBJS = \
+ $(MISCOBJS) \
+ ActionHook.o \
+ Alloc.o \
+ ArgList.o \
+ Callback.o \
+ ClickTime.o \
+ Composite.o \
+ Constraint.o \
+ Convert.o \
+ Converters.o \
+ Core.o \
+ Create.o \
+ Destroy.o \
+ Display.o \
+ Error.o \
+ Event.o \
+ EventUtil.o \
+ Functions.o \
+ GCManager.o \
+ Geometry.o \
+ GetActKey.o \
+ GetResList.o \
+ GetValues.o \
+ HookObj.o \
+ Hooks.o \
+ Initialize.o \
+ Intrinsic.o \
+ Keyboard.o \
+ Manage.o \
+ NextEvent.o \
+ Object.o \
+ PassivGrab.o \
+ Pointer.o \
+ Popup.o \
+ PopupCB.o \
+ RectObj.o \
+ Resources.o \
+ Selection.o \
+ SetSens.o \
+ SetValues.o \
+ SetWMCW.o \
+ Shell.o \
+ StringDefs.o \
+ Threads.o \
+ TMaction.o \
+ TMgrab.o \
+ TMkey.o \
+ TMparse.o \
+ TMprint.o \
+ TMstate.o \
+ VarCreate.o \
+ VarGet.o \
+ Varargs.o \
+ Vendor.o \
+ $(RCMOBJS)
+
+#if SharedDataSeparation
+UNSHAREDOBJS = StringDefs.o sharedlib.o
+#else
+UNSHAREDOBJS = sharedlib.o
+#endif
+
+#include <Library.tmpl>
+
+SpecialCLibObjectRule(Intrinsic,$(ICONFIGFILES),$(SRCH_DEFINES))
+SpecialCLibObjectRule(Error,$(ICONFIGFILES),$(DB_DEFINES))
+SpecialCLibObjectRule(Alloc,$(_NOOP_),$(ALLOC_DEFINES))
+SpecialCLibObjectRule(Converters,$(ICONFIGFILES),$(BC_DEFINES))
+SpecialCLibObjectRule(Resources,$(ICONFIGFILES),$(GETVALUES_DEFINES))
+SpecialCLibObjectRule(TMaction,$(_NOOP_),$(RCONST_DEFINES))
+#if BuildXKBlib
+SpecialCLibObjectRule(TMkey,$(_NOOP_),-DXKB)
+#endif
+#if DoSharedLib
+SpecialCObjectRule(sharedlib,$(_NOOP_),$(SHLIBDEF))
+#endif
+#if defined(ItsyCompilerBug)
+SpecialCLibObjectRule(PassivGrab,$(_NOOP_),-O0)
+#endif
+
+STRINGS_FILES = StringDefs.c StringDefs.h Shell.h
+STRINGS_TMPLS = util/StrDefs.ct util/StrDefs.ht util/Shell.ht
+STRING_LIST = util/string.list
+
+ToolkitMakeStrings($(STRINGS_FILES),$(STRING_LIST),$(STRINGSABIOPTIONS),$(STRINGS_TMPLS),StringDefs.c)
+
+DependTarget()
diff --git a/nx-X11/lib/Xt/InitialI.h b/nx-X11/lib/Xt/InitialI.h
new file mode 100644
index 000000000..c2fe47c1b
--- /dev/null
+++ b/nx-X11/lib/Xt/InitialI.h
@@ -0,0 +1,429 @@
+/* $Xorg: InitialI.h,v 1.4 2001/02/09 02:03:55 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/InitialI.h,v 3.10 2001/12/14 19:56:18 dawes Exp $ */
+
+#ifndef _XtinitialI_h
+#define _XtinitialI_h
+
+/****************************************************************
+ *
+ * Displays
+ *
+ ****************************************************************/
+
+#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
+
+#include <X11/Xos.h>
+#include <X11/Xpoll.h>
+
+typedef struct _TimerEventRec {
+ struct timeval te_timer_value;
+ struct _TimerEventRec *te_next;
+ XtTimerCallbackProc te_proc;
+ XtAppContext app;
+ XtPointer te_closure;
+} TimerEventRec;
+
+typedef struct _InputEvent {
+ XtInputCallbackProc ie_proc;
+ XtPointer ie_closure;
+ struct _InputEvent *ie_next;
+ struct _InputEvent *ie_oq;
+ XtAppContext app;
+ int ie_source;
+ XtInputMask ie_condition;
+} InputEvent;
+
+typedef struct _SignalEventRec {
+ XtSignalCallbackProc se_proc;
+ XtPointer se_closure;
+ struct _SignalEventRec *se_next;
+ XtAppContext app;
+ Boolean se_notice;
+} SignalEventRec;
+
+typedef struct _WorkProcRec {
+ XtWorkProc proc;
+ XtPointer closure;
+ struct _WorkProcRec *next;
+ XtAppContext app;
+} WorkProcRec;
+
+
+typedef struct
+{
+#ifndef USE_POLL
+ fd_set rmask;
+ fd_set wmask;
+ fd_set emask;
+#endif
+ int nfds;
+} FdStruct;
+
+typedef struct _LangProcRec {
+ XtLanguageProc proc;
+ XtPointer closure;
+} LangProcRec;
+
+typedef struct _ProcessContextRec {
+ XtAppContext defaultAppContext;
+ XtAppContext appContextList;
+ ConverterTable globalConverterTable;
+ LangProcRec globalLangProcRec;
+} ProcessContextRec, *ProcessContext;
+
+typedef struct {
+ char* start;
+ char* current;
+ int bytes_remaining;
+} Heap;
+
+typedef struct _DestroyRec DestroyRec;
+
+
+typedef struct _XtAppStruct {
+ XtAppContext next; /* link to next app in process context */
+ ProcessContext process; /* back pointer to our process context */
+ InternalCallbackList destroy_callbacks;
+ Display **list;
+ TimerEventRec *timerQueue;
+ WorkProcRec *workQueue;
+ InputEvent **input_list;
+ InputEvent *outstandingQueue;
+ SignalEventRec *signalQueue;
+ XrmDatabase errorDB;
+ XtErrorMsgHandler errorMsgHandler, warningMsgHandler;
+ XtErrorHandler errorHandler, warningHandler;
+ struct _ActionListRec *action_table;
+ ConverterTable converterTable;
+ unsigned long selectionTimeout;
+ FdStruct fds;
+ short count; /* num of assigned entries in list */
+ short max; /* allocate size of list */
+ short last;
+ short input_count;
+ short input_max; /* elts input_list init'd with */
+ Boolean sync, being_destroyed, error_inited;
+#ifndef NO_IDENTIFY_WINDOWS
+ Boolean identify_windows; /* debugging hack */
+#endif
+ Heap heap;
+ String * fallback_resources; /* Set by XtAppSetFallbackResources. */
+ struct _ActionHookRec* action_hook_list;
+ struct _BlockHookRec* block_hook_list;
+ int destroy_list_size; /* state data for 2-phase destroy */
+ int destroy_count;
+ int dispatch_level;
+ DestroyRec* destroy_list;
+ Widget in_phase2_destroy;
+ LangProcRec langProcRec;
+ struct _TMBindCacheRec * free_bindings;
+ String display_name_tried;
+ Display **dpy_destroy_list;
+ int dpy_destroy_count;
+ Boolean exit_flag;
+ Boolean rebuild_fdlist;
+#ifdef XTHREADS
+ LockPtr lock_info;
+ ThreadAppProc lock;
+ ThreadAppProc unlock;
+ ThreadAppYieldLockProc yield_lock;
+ ThreadAppRestoreLockProc restore_lock;
+ ThreadAppProc free_lock;
+#endif
+} XtAppStruct;
+
+extern void _XtHeapInit(Heap* heap);
+extern void _XtHeapFree(Heap* heap);
+
+#ifdef XTTRACEMEMORY
+
+
+extern char *_XtHeapMalloc(
+ Heap* /* heap */,
+ Cardinal /* size */,
+ char * /* file */,
+ int /* line */
+);
+
+#define _XtHeapAlloc(heap,bytes) _XtHeapMalloc(heap, bytes, __FILE__, __LINE__)
+
+#else /* XTTRACEMEMORY */
+
+extern char* _XtHeapAlloc(
+ Heap* /* heap */,
+ Cardinal /* size */
+);
+
+#endif /* XTTRACEMEMORY */
+
+extern void _XtSetDefaultErrorHandlers(
+ XtErrorMsgHandler* /* errMsg */,
+ XtErrorMsgHandler* /* warnMsg */,
+ XtErrorHandler* /* err */,
+ XtErrorHandler* /* warn */
+);
+
+extern void _XtSetDefaultSelectionTimeout(
+ unsigned long* /* timeout */
+);
+
+extern XtAppContext _XtDefaultAppContext(
+ void
+);
+
+extern ProcessContext _XtGetProcessContext(
+ void
+);
+
+Display *
+_XtAppInit(
+ XtAppContext* /* app_context_return */,
+ String /* application_class */,
+ XrmOptionDescRec* /* options */,
+ Cardinal /* num_options */,
+ int* /* argc_in_out */,
+ String** /* argv_in_out */,
+ String* /* fallback_resources */
+);
+
+extern void _XtDestroyAppContexts(
+ void
+);
+
+extern void _XtCloseDisplays(
+ XtAppContext /* app */
+);
+
+extern int _XtAppDestroyCount;
+
+extern int _XtWaitForSomething(
+ XtAppContext /* app */,
+ _XtBoolean /* ignoreEvents */,
+ _XtBoolean /* ignoreTimers */,
+ _XtBoolean /* ignoreInputs */,
+ _XtBoolean /* ignoreSignals */,
+ _XtBoolean /* block */,
+#ifdef XTHREADS
+ _XtBoolean /* drop_lock */,
+#endif
+ unsigned long* /* howlong */
+);
+
+typedef struct _CaseConverterRec *CaseConverterPtr;
+typedef struct _CaseConverterRec {
+ KeySym start; /* first KeySym valid in converter */
+ KeySym stop; /* last KeySym valid in converter */
+ XtCaseProc proc; /* case converter function */
+ CaseConverterPtr next; /* next converter record */
+} CaseConverterRec;
+
+typedef struct _ExtensionSelectorRec {
+ XtExtensionSelectProc proc;
+ int min, max;
+ XtPointer client_data;
+} ExtSelectRec;
+
+typedef struct _XtPerDisplayStruct {
+ InternalCallbackList destroy_callbacks;
+ Region region;
+ CaseConverterPtr case_cvt; /* user-registered case converters */
+ XtKeyProc defaultKeycodeTranslator;
+ XtAppContext appContext;
+ unsigned long keysyms_serial; /* for tracking MappingNotify events */
+ KeySym *keysyms; /* keycode to keysym table */
+ int keysyms_per_keycode; /* number of keysyms for each keycode*/
+ int min_keycode, max_keycode; /* range of keycodes */
+ KeySym *modKeysyms; /* keysym values for modToKeysysm */
+ ModToKeysymTable *modsToKeysyms; /* modifiers to Keysysms index table*/
+ unsigned char isModifier[32]; /* key-is-modifier-p bit table */
+ KeySym lock_meaning; /* Lock modifier meaning */
+ Modifiers mode_switch; /* keyboard group modifiers */
+ Modifiers num_lock; /* keyboard numlock modifiers */
+ Boolean being_destroyed;
+ Boolean rv; /* reverse_video resource */
+ XrmName name; /* resolved app name */
+ XrmClass class; /* application class */
+ Heap heap;
+ struct _GCrec *GClist; /* support for XtGetGC */
+ Drawable **pixmap_tab; /* ditto for XtGetGC */
+ String language; /* XPG language string */
+ XEvent last_event; /* last event dispatched */
+ Time last_timestamp; /* from last event dispatched */
+ int multi_click_time; /* for XtSetMultiClickTime */
+ struct _TMKeyContextRec* tm_context; /* for XtGetActionKeysym */
+ InternalCallbackList mapping_callbacks; /* special case for TM */
+ XtPerDisplayInputRec pdi; /* state for modal grabs & kbd focus */
+ struct _WWTable *WWtable; /* window to widget table */
+ XrmDatabase *per_screen_db; /* per screen resource databases */
+ XrmDatabase cmd_db; /* db from command line, if needed */
+ XrmDatabase server_db; /* resource property else .Xdefaults */
+ XtEventDispatchProc* dispatcher_list;
+ ExtSelectRec* ext_select_list;
+ int ext_select_count;
+ Widget hook_object;
+#ifndef X_NO_RESOURCE_CONFIGURATION_MANAGEMENT
+ Atom rcm_init; /* ResConfig - initialize */
+ Atom rcm_data; /* ResConfig - data atom */
+#endif
+} XtPerDisplayStruct, *XtPerDisplay;
+
+typedef struct _PerDisplayTable {
+ Display *dpy;
+ XtPerDisplayStruct perDpy;
+ struct _PerDisplayTable *next;
+} PerDisplayTable, *PerDisplayTablePtr;
+
+extern PerDisplayTablePtr _XtperDisplayList;
+
+extern XtPerDisplay _XtSortPerDisplayList(
+ Display* /* dpy */
+);
+
+extern XtPerDisplay _XtGetPerDisplay(
+ Display* /* dpy */
+);
+
+extern XtPerDisplayInputRec* _XtGetPerDisplayInput(
+ Display* /* dpy */
+);
+
+#if 0
+#ifdef DEBUG
+#define _XtGetPerDisplay(display) \
+ ((_XtperDisplayList != NULL && (_XtperDisplayList->dpy == (display))) \
+ ? &_XtperDisplayList->perDpy \
+ : _XtSortPerDisplayList(display))
+#define _XtGetPerDisplayInput(display) \
+ ((_XtperDisplayList != NULL && (_XtperDisplayList->dpy == (display))) \
+ ? &_XtperDisplayList->perDpy.pdi \
+ : &_XtSortPerDisplayList(display)->pdi)
+#else
+#define _XtGetPerDisplay(display) \
+ ((_XtperDisplayList->dpy == (display)) \
+ ? &_XtperDisplayList->perDpy \
+ : _XtSortPerDisplayList(display))
+#define _XtGetPerDisplayInput(display) \
+ ((_XtperDisplayList->dpy == (display)) \
+ ? &_XtperDisplayList->perDpy.pdi \
+ : &_XtSortPerDisplayList(display)->pdi)
+#endif /*DEBUG*/
+#endif
+
+extern void _XtDisplayInitialize(
+ Display* /* dpy */,
+ XtPerDisplay /* pd */,
+ _Xconst char* /* name */,
+ XrmOptionDescRec* /* urlist */,
+ Cardinal /* num_urs */,
+ int* /* argc */,
+ char** /* argv */
+);
+
+extern void _XtCacheFlushTag(
+ XtAppContext /* app */,
+ XtPointer /* tag */
+);
+
+extern void _XtFreeActions(
+ struct _ActionListRec* /* action_table */
+);
+
+extern void _XtDoPhase2Destroy(
+ XtAppContext /* app */,
+ int /* dispatch_level */
+);
+
+extern void _XtDoFreeBindings(
+ XtAppContext /* app */
+);
+
+extern void _XtExtensionSelect(
+ Widget /* widget */
+);
+
+#define _XtSafeToDestroy(app) ((app)->dispatch_level == 0)
+
+extern void _XtAllocWWTable(
+ XtPerDisplay pd
+);
+
+extern void _XtFreeWWTable(
+ XtPerDisplay pd
+);
+
+extern String _XtGetUserName(String dest, int len);
+extern XrmDatabase _XtPreparseCommandLine(XrmOptionDescRec *urlist,
+ Cardinal num_urs, int argc, String *argv,
+ String *applName, String *displayName,
+ String *language);
+
+#endif /* _XtinitialI_h */
diff --git a/nx-X11/lib/Xt/Initialize.c b/nx-X11/lib/Xt/Initialize.c
new file mode 100644
index 000000000..bbc84b954
--- /dev/null
+++ b/nx-X11/lib/Xt/Initialize.c
@@ -0,0 +1,1044 @@
+/* $Xorg: Initialize.c,v 1.8 2001/02/09 02:03:55 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/Initialize.c,v 3.21 2003/04/21 16:34:27 herrb Exp $ */
+
+/*
+
+Copyright 1987, 1988, 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.
+
+*/
+
+/* Make sure all wm properties can make it out of the resource manager */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+#include "CoreP.h"
+#include "ShellP.h"
+#include <stdio.h>
+#include <X11/Xlocale.h>
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+#ifndef WIN32
+#define X_INCLUDE_PWD_H
+#define XOS_USE_XT_LOCKING
+#include <X11/Xos_r.h>
+#endif
+
+#include <stdlib.h>
+
+#if (defined(SUNSHLIB) || defined(AIXSHLIB)) && defined(SHAREDCODE)
+/*
+ * If used as a shared library, generate code under a different name so that
+ * the stub routines in sharedlib.c get loaded into the application binary.
+ */
+#define XtToolkitInitialize _XtToolkitInitialize
+#define XtOpenApplication _XtOpenApplication
+#define XtAppInitialize _XtAppInitialize
+#define XtInitialize _XtInitialize
+#endif /* (SUNSHLIB || AIXSHLIB) && SHAREDCODE */
+
+/*
+ * hpux
+ * Hand-patched versions of HP-UX prior to version 7.0 can usefully add
+ * -DUSE_UNAME in the appropriate config file to get long hostnames.
+ */
+
+#ifdef USG
+#define USE_UNAME
+#endif
+
+#ifdef USE_UNAME
+#include <sys/utsname.h>
+#endif
+
+/* some unspecified magic number of expected search levels for Xrm */
+#define SEARCH_LIST_SIZE 1000
+
+/*
+ This is a set of default records describing the command line arguments that
+ Xlib will parse and set into the resource data base.
+
+ This list is applied before the users list to enforce these defaults. This is
+ policy, which the toolkit avoids but I hate differing programs at this level.
+*/
+
+static XrmOptionDescRec const opTable[] = {
+{"+rv", "*reverseVideo", XrmoptionNoArg, (XtPointer) "off"},
+{"+synchronous","*synchronous", XrmoptionNoArg, (XtPointer) "off"},
+{"-background", "*background", XrmoptionSepArg, (XtPointer) NULL},
+{"-bd", "*borderColor", XrmoptionSepArg, (XtPointer) NULL},
+{"-bg", "*background", XrmoptionSepArg, (XtPointer) NULL},
+{"-bordercolor","*borderColor", XrmoptionSepArg, (XtPointer) NULL},
+{"-borderwidth",".borderWidth", XrmoptionSepArg, (XtPointer) NULL},
+{"-bw", ".borderWidth", XrmoptionSepArg, (XtPointer) NULL},
+{"-display", ".display", XrmoptionSepArg, (XtPointer) NULL},
+{"-fg", "*foreground", XrmoptionSepArg, (XtPointer) NULL},
+{"-fn", "*font", XrmoptionSepArg, (XtPointer) NULL},
+{"-font", "*font", XrmoptionSepArg, (XtPointer) NULL},
+{"-foreground", "*foreground", XrmoptionSepArg, (XtPointer) NULL},
+{"-geometry", ".geometry", XrmoptionSepArg, (XtPointer) NULL},
+{"-iconic", ".iconic", XrmoptionNoArg, (XtPointer) "on"},
+{"-name", ".name", XrmoptionSepArg, (XtPointer) NULL},
+{"-reverse", "*reverseVideo", XrmoptionNoArg, (XtPointer) "on"},
+{"-rv", "*reverseVideo", XrmoptionNoArg, (XtPointer) "on"},
+{"-selectionTimeout",
+ ".selectionTimeout", XrmoptionSepArg, (XtPointer) NULL},
+{"-synchronous","*synchronous", XrmoptionNoArg, (XtPointer) "on"},
+{"-title", ".title", XrmoptionSepArg, (XtPointer) NULL},
+{"-xnllanguage",".xnlLanguage", XrmoptionSepArg, (XtPointer) NULL},
+{"-xrm", NULL, XrmoptionResArg, (XtPointer) NULL},
+{"-xtsessionID",".sessionID", XrmoptionSepArg, (XtPointer) NULL},
+};
+
+
+/*
+ * GetHostname - emulates gethostname() on non-bsd systems.
+ */
+
+static void GetHostname (
+ char *buf,
+ int maxlen)
+{
+#ifdef USE_UNAME
+ int len;
+ struct utsname name;
+
+ if (maxlen <= 0 || buf == NULL)
+ return;
+
+ uname (&name);
+ len = strlen (name.nodename);
+ if (len >= maxlen) len = maxlen;
+ (void) strncpy (buf, name.nodename, len-1);
+ buf[len-1] = '\0';
+#else
+ if (maxlen <= 0 || buf == NULL)
+ return;
+
+ buf[0] = '\0';
+ (void) gethostname (buf, maxlen);
+ buf [maxlen - 1] = '\0';
+#endif
+}
+
+
+#ifdef SUNSHLIB
+void _XtInherit(void)
+{
+ extern void __XtInherit();
+ __XtInherit();
+}
+#define _XtInherit __XtInherit
+#endif
+
+
+#if defined(__CYGWIN__)
+/*
+ * The Symbol _XtInherit is used in two different manners.
+ * First it could be used as a generic function and second
+ * as an absolute address reference, which will be used to
+ * check the initialisation process of several other libraries.
+ * Because of this the symbol must be accessable by all
+ * client dll's and applications. In unix environments
+ * this is no problem, because the used shared libraries
+ * format (elf) supports this immediatly. Under Windows
+ * this isn't true, because a functions address in a dll
+ * is different from the same function in another dll or
+ * applications, because the used Portable Executable
+ * File adds a code stub to each client to provide the
+ * exported symbol name. This stub uses an indirect
+ * pointer to get the original symbol address, which is
+ * then jumped to, like in this example:
+ *
+ * --- client --- --- dll ----
+ * ...
+ * call foo
+ *
+ * foo: jmp (*_imp_foo) ----> foo: ....
+ * nop
+ * nop
+ *
+ * _imp_foo: .long <index of foo in dll export table, is
+ * set to the real address by the runtime linker>
+ *
+ * Now it is clear why the clients symbol foo isn't the same
+ * as in the dll and we can think about how to deal which
+ * this two above mentioned requirements, to export this
+ * symbol to all clients and to allow calling this symbol
+ * as a function. The solution I've used exports the
+ * symbol _XtInherit as data symbol, because global data
+ * symbols are exported to all clients. But how to deal
+ * with the second requirement, that this symbol should
+ * be used as function. The Trick is to build a little
+ * code stub in the data section in the exact manner as
+ * above explained. This is done with the assembler code
+ * below.
+ *
+ * Ralf Habacker
+ *
+ * References:
+ * msdn http://msdn.microsoft.com/msdnmag/issues/02/02/PE/PE.asp
+ * cygwin-xfree: http://www.cygwin.com/ml/cygwin-xfree/2003-10/msg00000.html
+ */
+
+asm (".data\n\
+ .globl __XtInherit \n\
+ __XtInherit: jmp *_y \n\
+ _y: .long ___XtInherit \n\
+ .text \n");
+
+#define _XtInherit __XtInherit
+#endif
+
+
+void _XtInherit(void)
+{
+ XtErrorMsg("invalidProcedure","inheritanceProc",XtCXtToolkitError,
+ "Unresolved inheritance operation",
+ (String *)NULL, (Cardinal *)NULL);
+}
+
+
+void XtToolkitInitialize(void)
+{
+ static Boolean initialized = False;
+
+ LOCK_PROCESS;
+ if (initialized) {
+ UNLOCK_PROCESS;
+ return;
+ }
+ initialized = True;
+ UNLOCK_PROCESS;
+ /* Resource management initialization */
+ XrmInitialize();
+ _XtResourceListInitialize();
+
+ /* Other intrinsic intialization */
+ _XtConvertInitialize();
+ _XtEventInitialize();
+ _XtTranslateInitialize();
+
+ /* Some apps rely on old (broken) XtAppPeekEvent behavior */
+ if(getenv("XTAPPPEEKEVENT_SKIPTIMER"))
+ XtAppPeekEvent_SkipTimer = True;
+ else
+ XtAppPeekEvent_SkipTimer = False;
+}
+
+
+String _XtGetUserName(
+ String dest,
+ int len)
+{
+#ifdef WIN32
+ String ptr = NULL;
+
+ if ((ptr = getenv("USERNAME"))) {
+ (void) strncpy (dest, ptr, len-1);
+ dest[len-1] = '\0';
+ } else
+ *dest = '\0';
+#else
+#ifdef X_NEEDS_PWPARAMS
+ _Xgetpwparams pwparams;
+#endif
+ struct passwd *pw;
+ char* ptr;
+
+ if ((ptr = getenv("USER"))) {
+ (void) strncpy (dest, ptr, len-1);
+ dest[len-1] = '\0';
+ } else {
+ if ((pw = _XGetpwuid(getuid(),pwparams)) != NULL) {
+ (void) strncpy (dest, pw->pw_name, len-1);
+ dest[len-1] = '\0';
+ } else
+ *dest = '\0';
+ }
+#endif
+ return dest;
+}
+
+
+static String GetRootDirName(
+ String dest,
+ int len)
+{
+#ifdef WIN32
+ register char *ptr1;
+ register char *ptr2 = NULL;
+ 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
+#ifdef X_NEEDS_PWPARAMS
+ _Xgetpwparams pwparams;
+#endif
+ struct passwd *pw;
+ static char *ptr;
+
+ if (len <= 0 || dest == NULL)
+ return NULL;
+
+ if ((ptr = getenv("HOME"))) {
+ (void) strncpy (dest, ptr, len-1);
+ 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-1);
+ dest[len-1] = '\0';
+ } else
+ *dest = '\0';
+ }
+#endif
+ return dest;
+}
+
+static void CombineAppUserDefaults(
+ Display *dpy,
+ XrmDatabase *pdb)
+{
+ char* filename;
+ char* path;
+ Boolean deallocate = False;
+
+ if (!(path = getenv("XUSERFILESEARCHPATH"))) {
+ char *old_path;
+ char homedir[PATH_MAX];
+ GetRootDirName(homedir, PATH_MAX);
+ if (!(old_path = getenv("XAPPLRESDIR"))) {
+ char *path_default = "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N";
+ if (!(path =
+ ALLOCATE_LOCAL(6*strlen(homedir) + strlen(path_default))))
+ _XtAllocError(NULL);
+ sprintf( path, path_default,
+ homedir, homedir, homedir, homedir, homedir, homedir );
+ } else {
+ char *path_default = "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N:%s/%%N";
+ if (!(path =
+ ALLOCATE_LOCAL( 6*strlen(old_path) + 2*strlen(homedir)
+ + strlen(path_default))))
+ _XtAllocError(NULL);
+ sprintf(path, path_default, old_path, old_path, old_path, homedir,
+ old_path, old_path, old_path, homedir );
+ }
+ deallocate = True;
+ }
+
+ filename = XtResolvePathname(dpy, NULL, NULL, NULL, path, NULL, 0, NULL);
+ if (filename) {
+ (void)XrmCombineFileDatabase(filename, pdb, False);
+ XtFree(filename);
+ }
+
+ if (deallocate) DEALLOCATE_LOCAL(path);
+}
+
+static void CombineUserDefaults(
+ Display *dpy,
+ XrmDatabase *pdb)
+{
+ char *slashDotXdefaults = "/.Xdefaults";
+ char *dpy_defaults = XResourceManagerString(dpy);
+
+ if (dpy_defaults) {
+ XrmCombineDatabase(XrmGetStringDatabase(dpy_defaults), pdb, False);
+ } else {
+ char filename[PATH_MAX];
+ (void) GetRootDirName(filename,
+ PATH_MAX - strlen (slashDotXdefaults) - 1);
+ (void) strcat(filename, slashDotXdefaults);
+ (void)XrmCombineFileDatabase(filename, pdb, False);
+ }
+}
+
+/*ARGSUSED*/
+static Bool StoreDBEntry(
+ XrmDatabase *db,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ XrmRepresentation *type,
+ XrmValuePtr value,
+ XPointer data)
+{
+ XrmQPutResource((XrmDatabase *)data, bindings, quarks, *type, value);
+ return False;
+}
+
+static XrmDatabase CopyDB(XrmDatabase db)
+{
+ XrmDatabase copy = NULL;
+ XrmQuark empty = NULLQUARK;
+
+ XrmEnumerateDatabase(db, &empty, &empty, XrmEnumAllLevels,
+ StoreDBEntry, (XPointer)&copy);
+ return copy;
+}
+
+/*ARGSUSED*/
+static String _XtDefaultLanguageProc(
+ Display *dpy, /* unused */
+ String xnl,
+ XtPointer closure) /* unused */
+{
+ if (! setlocale(LC_ALL, xnl))
+ XtWarning("locale not supported by C library, locale unchanged");
+
+ if (! XSupportsLocale()) {
+ XtWarning("locale not supported by Xlib, locale set to C");
+ setlocale(LC_ALL, "C");
+ }
+ if (! XSetLocaleModifiers(""))
+ XtWarning("X locale modifiers not supported, using default");
+
+ return setlocale(LC_ALL, NULL); /* re-query in case overwritten */
+}
+
+XtLanguageProc XtSetLanguageProc(
+ XtAppContext app,
+ XtLanguageProc proc,
+ XtPointer closure)
+{
+ XtLanguageProc old;
+
+ if (!proc) {
+ proc = _XtDefaultLanguageProc;
+ closure = NULL;
+ }
+
+ if (app) {
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ /* set langProcRec only for this application context */
+ old = app->langProcRec.proc;
+ app->langProcRec.proc = proc;
+ app->langProcRec.closure = closure;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ } else {
+ /* set langProcRec for all application contexts */
+ ProcessContext process;
+
+ LOCK_PROCESS;
+ process = _XtGetProcessContext();
+ old = process->globalLangProcRec.proc;
+ process->globalLangProcRec.proc = proc;
+ process->globalLangProcRec.closure = closure;
+ app = process->appContextList;
+ while (app) {
+ app->langProcRec.proc = proc;
+ app->langProcRec.closure = closure;
+ app = app->next;
+ }
+ UNLOCK_PROCESS;
+ }
+ return (old ? old : _XtDefaultLanguageProc);
+}
+
+XrmDatabase XtScreenDatabase(
+ Screen *screen)
+{
+ int scrno;
+ Bool doing_def;
+ XrmDatabase db, olddb;
+ XtPerDisplay pd;
+ Status do_fallback;
+ char *scr_resources;
+ Display *dpy = DisplayOfScreen(screen);
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if (screen == DefaultScreenOfDisplay(dpy)) {
+ scrno = DefaultScreen(dpy);
+ doing_def = True;
+ } else {
+ scrno = XScreenNumberOfScreen(screen);
+ doing_def = False;
+ }
+ pd = _XtGetPerDisplay(dpy);
+ if ((db = pd->per_screen_db[scrno])) {
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return (doing_def ? XrmGetDatabase(dpy) : db);
+ }
+ scr_resources = XScreenResourceString(screen);
+
+ if (ScreenCount(dpy) == 1) {
+ db = pd->cmd_db;
+ pd->cmd_db = NULL;
+ } else {
+ db = CopyDB(pd->cmd_db);
+ }
+ { /* Environment defaults */
+ char filenamebuf[PATH_MAX];
+ char *filename;
+
+ if (!(filename = getenv("XENVIRONMENT"))) {
+ int len;
+ char *slashDotXdefaultsDash = "/.Xdefaults-";
+
+ (void) GetRootDirName(filename = filenamebuf,
+ PATH_MAX - strlen (slashDotXdefaultsDash) - 1);
+ (void) strcat(filename, slashDotXdefaultsDash);
+ len = strlen(filename);
+ GetHostname (filename+len, PATH_MAX-len);
+ }
+ (void)XrmCombineFileDatabase(filename, &db, False);
+ }
+ if (scr_resources)
+ { /* Screen defaults */
+ XrmCombineDatabase(XrmGetStringDatabase(scr_resources), &db, False);
+ XFree(scr_resources);
+ }
+ /* Server or host defaults */
+ if (!pd->server_db)
+ CombineUserDefaults(dpy, &db);
+ else {
+ (void) XrmCombineDatabase(pd->server_db, &db, False);
+ pd->server_db = NULL;
+ }
+
+ if (!db)
+ db = XrmGetStringDatabase("");
+ pd->per_screen_db[scrno] = db;
+ olddb = XrmGetDatabase(dpy);
+ /* set database now, for XtResolvePathname to use */
+ XrmSetDatabase(dpy, db);
+ CombineAppUserDefaults(dpy, &db);
+ do_fallback = 1;
+ { /* System app-defaults */
+ char *filename;
+
+ if ((filename = XtResolvePathname(dpy, "app-defaults",
+ NULL, NULL, NULL, NULL, 0, NULL))) {
+ do_fallback = !XrmCombineFileDatabase(filename, &db, False);
+ XtFree(filename);
+ }
+ }
+ /* now restore old database, if need be */
+ if (!doing_def)
+ XrmSetDatabase(dpy, olddb);
+ if (do_fallback && pd->appContext->fallback_resources)
+ { /* Fallback defaults */
+ XrmDatabase fdb = NULL;
+ String *res;
+
+ for (res = pd->appContext->fallback_resources; *res; res++)
+ XrmPutLineResource(&fdb, *res);
+ (void)XrmCombineDatabase(fdb, &db, False);
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return db;
+}
+
+/*
+ * Merge two option tables, allowing the second to over-ride the first,
+ * so that ambiguous abbreviations can be noticed. The merge attempts
+ * to make the resulting table lexicographically sorted, but succeeds
+ * only if the first source table is sorted. Though it _is_ recommended
+ * (for optimizations later in XrmParseCommand), it is not required
+ * that either source table be sorted.
+ *
+ * Caller is responsible for freeing the returned option table.
+ */
+
+static void _MergeOptionTables(
+ const XrmOptionDescRec *src1,
+ Cardinal num_src1,
+ const XrmOptionDescRec *src2,
+ Cardinal num_src2,
+ XrmOptionDescRec **dst,
+ Cardinal *num_dst)
+{
+ XrmOptionDescRec *table, *endP;
+ register XrmOptionDescRec *opt1, *whereP, *dstP;
+ register const XrmOptionDescRec *opt2;
+ int i1;
+ Cardinal i2;
+ int dst_len, order;
+ Boolean found;
+ enum {Check, NotSorted, IsSorted} sort_order = Check;
+
+ *dst = table = (XrmOptionDescRec*)
+ __XtMalloc( sizeof(XrmOptionDescRec) * (num_src1 + num_src2) );
+
+ (void) memmove(table, src1, sizeof(XrmOptionDescRec) * num_src1 );
+ if (num_src2 == 0) {
+ *num_dst = num_src1;
+ return;
+ }
+ endP = &table[dst_len = num_src1];
+ for (opt2 = src2, i2= 0; i2 < num_src2; opt2++, i2++) {
+ found = False;
+ whereP = endP-1; /* assume new option goes at the end */
+ for (opt1 = table, i1 = 0; i1 < dst_len; opt1++, i1++) {
+ /* have to walk the entire new table so new list is ordered
+ (if src1 was ordered) */
+ if (sort_order == Check && i1 > 0
+ && strcmp(opt1->option, (opt1-1)->option) < 0)
+ sort_order = NotSorted;
+ if ((order = strcmp(opt1->option, opt2->option)) == 0) {
+ /* same option names; just overwrite opt1 with opt2 */
+ *opt1 = *opt2;
+ found = True;
+ break;
+ }
+ /* else */
+ if (sort_order == IsSorted && order > 0) {
+ /* insert before opt1 to preserve order */
+ /* shift rest of table forward to make room for new entry */
+ for (dstP = endP++; dstP > opt1; dstP--)
+ *dstP = *(dstP-1);
+ *opt1 = *opt2;
+ dst_len++;
+ found = True;
+ break;
+ }
+ /* else */
+ if (order < 0)
+ /* opt2 sorts after opt1, so remember this position */
+ whereP = opt1;
+ }
+ if (sort_order == Check && i1 == dst_len)
+ sort_order = IsSorted;
+ if (!found) {
+ /* when we get here, whereP points to the last entry in the
+ destination that sorts before "opt2". Shift rest of table
+ forward and insert "opt2" after whereP. */
+ whereP++;
+ for (dstP = endP++; dstP > whereP; dstP--)
+ *dstP = *(dstP-1);
+ *whereP = *opt2;
+ dst_len++;
+ }
+ }
+ *num_dst = dst_len;
+}
+
+
+/* NOTE: name, class, and type must be permanent strings */
+static Boolean _GetResource(
+ Display *dpy,
+ XrmSearchList list,
+ String name,
+ String class,
+ String type,
+ XrmValue* value)
+{
+ XrmRepresentation db_type;
+ XrmValue db_value;
+ XrmName Qname = XrmPermStringToQuark(name);
+ XrmClass Qclass = XrmPermStringToQuark(class);
+ XrmRepresentation Qtype = XrmPermStringToQuark(type);
+
+ if (XrmQGetSearchResource(list, Qname, Qclass, &db_type, &db_value)) {
+ if (db_type == Qtype) {
+ if (Qtype == _XtQString)
+ *(String*)value->addr = db_value.addr;
+ else
+ (void) memmove(value->addr, db_value.addr, value->size );
+ return True;
+ } else {
+ WidgetRec widget; /* hack, hack */
+ bzero( &widget, sizeof(widget) );
+ widget.core.self = &widget;
+ widget.core.widget_class = coreWidgetClass;
+ widget.core.screen = (Screen*)DefaultScreenOfDisplay(dpy);
+ XtInitializeWidgetClass(coreWidgetClass);
+ if (_XtConvert(&widget,db_type,&db_value,Qtype,value,NULL)) {
+ return True;
+ }
+ }
+ }
+ return False;
+}
+
+XrmDatabase _XtPreparseCommandLine(
+ XrmOptionDescRec *urlist,
+ Cardinal num_urs,
+ int argc,
+ String *argv,
+ /* return */
+ String *applName,
+ String *displayName,
+ String *language)
+{
+ XrmDatabase db = 0;
+ XrmOptionDescRec *options;
+ Cardinal num_options;
+ XrmName name_list[3];
+ XrmName class_list[3];
+ XrmRepresentation type;
+ XrmValue val;
+ String *targv;
+ int targc = argc;
+
+ targv = (String *) __XtMalloc(sizeof(char *) * argc);
+ (void) memmove(targv, argv, sizeof(char *) * argc);
+ _MergeOptionTables(opTable, XtNumber(opTable), urlist, num_urs,
+ &options, &num_options);
+ name_list[0] = class_list[0] = XrmPermStringToQuark(".");
+ name_list[2] = class_list[2] = NULLQUARK;
+ XrmParseCommand(&db, options, num_options, ".", &targc, targv);
+ if (applName) {
+ name_list[1] = XrmPermStringToQuark("name");
+ if (XrmQGetResource(db, name_list, name_list, &type, &val) &&
+ type == _XtQString)
+ *applName = val.addr;
+ }
+ if (displayName) {
+ name_list[1] = XrmPermStringToQuark("display");
+ if (XrmQGetResource(db, name_list, name_list, &type, &val) &&
+ type == _XtQString)
+ *displayName = val.addr;
+ }
+ if (language) {
+ name_list[1] = XrmPermStringToQuark("xnlLanguage");
+ class_list[1] = XrmPermStringToQuark("XnlLanguage");
+ if (XrmQGetResource(db, name_list, class_list, &type, &val) &&
+ type == _XtQString)
+ *language = val.addr;
+ }
+
+ XtFree((char *)targv);
+ XtFree((char *)options);
+ return db;
+}
+
+
+static void GetLanguage(
+ Display *dpy,
+ XtPerDisplay pd)
+{
+ XrmRepresentation type;
+ XrmValue value;
+ XrmName name_list[3];
+ XrmName class_list[3];
+
+ LOCK_PROCESS;
+ if (! pd->language) {
+ name_list[0] = pd->name;
+ name_list[1] = XrmPermStringToQuark("xnlLanguage");
+ class_list[0] = pd->class;
+ class_list[1] = XrmPermStringToQuark("XnlLanguage");
+ name_list[2] = class_list[2] = NULLQUARK;
+ if (!pd->server_db)
+ CombineUserDefaults(dpy, &pd->server_db);
+ if (pd->server_db &&
+ XrmQGetResource(pd->server_db,name_list,class_list, &type, &value)
+ && type == _XtQString)
+ pd->language = (char *) value.addr;
+ }
+
+ if (pd->appContext->langProcRec.proc) {
+ if (! pd->language) pd->language = "";
+ pd->language = (*pd->appContext->langProcRec.proc)
+ (dpy, pd->language, pd->appContext->langProcRec.closure);
+ }
+ else if (! pd->language || pd->language[0] == '\0') /* R4 compatibility */
+ pd->language = getenv("LANG");
+
+ if (pd->language) pd->language = XtNewString(pd->language);
+ UNLOCK_PROCESS;
+}
+
+static void ProcessInternalConnection (
+ XtPointer client_data,
+ int* fd,
+ XtInputId* id)
+{
+ XProcessInternalConnection ((Display *) client_data, *fd);
+}
+
+static void ConnectionWatch (
+ Display* dpy,
+ XPointer client_data,
+ int fd,
+ Bool opening,
+ XPointer* watch_data)
+{
+ XtInputId* iptr;
+ XtAppContext app = XtDisplayToApplicationContext(dpy);
+
+ if (opening) {
+ iptr = (XtInputId *) __XtMalloc(sizeof(XtInputId));
+ *iptr = XtAppAddInput(app, fd, (XtPointer) XtInputReadMask,
+ ProcessInternalConnection, client_data);
+ *watch_data = (XPointer) iptr;
+ } else {
+ iptr = (XtInputId *) *watch_data;
+ XtRemoveInput(*iptr);
+ (void) XtFree(*watch_data);
+ }
+}
+
+void _XtDisplayInitialize(
+ Display *dpy,
+ XtPerDisplay pd,
+ _Xconst char* name,
+ XrmOptionDescRec *urlist,
+ Cardinal num_urs,
+ int *argc,
+ char **argv)
+{
+ Boolean tmp_bool;
+ XrmValue value;
+ XrmOptionDescRec *options;
+ Cardinal num_options;
+ XrmDatabase db;
+ XrmName name_list[2];
+ XrmClass class_list[2];
+ XrmHashTable* search_list;
+ int search_list_size = SEARCH_LIST_SIZE;
+
+ GetLanguage(dpy, pd);
+
+ /* Parse the command line and remove Xt arguments from argv */
+ _MergeOptionTables( opTable, XtNumber(opTable), urlist, num_urs,
+ &options, &num_options );
+ XrmParseCommand(&pd->cmd_db, options, num_options, name, argc, argv);
+
+ db = XtScreenDatabase(DefaultScreenOfDisplay(dpy));
+
+ if (!(search_list = (XrmHashTable*)
+ ALLOCATE_LOCAL( SEARCH_LIST_SIZE*sizeof(XrmHashTable))))
+ _XtAllocError(NULL);
+ name_list[0] = pd->name;
+ class_list[0] = pd->class;
+ name_list[1] = NULLQUARK;
+ class_list[1] = NULLQUARK;
+
+ while (!XrmQGetSearchList(db, name_list, class_list,
+ search_list, search_list_size)) {
+ XrmHashTable* old = search_list;
+ Cardinal size = (search_list_size*=2)*sizeof(XrmHashTable);
+ if (!(search_list = (XrmHashTable*)ALLOCATE_LOCAL(size)))
+ _XtAllocError(NULL);
+ (void) memmove((char*)search_list, (char*)old, (size>>1) );
+ DEALLOCATE_LOCAL(old);
+ }
+
+ value.size = sizeof(tmp_bool);
+ value.addr = (XtPointer)&tmp_bool;
+ if (_GetResource(dpy, search_list, "synchronous", "Synchronous",
+ XtRBoolean, &value)) {
+ int i;
+ Display **dpyP = pd->appContext->list;
+ pd->appContext->sync = tmp_bool;
+ for (i = pd->appContext->count; i; dpyP++, i--) {
+ (void) XSynchronize(*dpyP, (Bool)tmp_bool);
+ }
+ } else {
+ (void) XSynchronize(dpy, (Bool)pd->appContext->sync);
+ }
+
+ if (_GetResource(dpy, search_list, "reverseVideo", "ReverseVideo",
+ XtRBoolean, &value)
+ && tmp_bool) {
+ pd->rv = True;
+ }
+
+ value.size = sizeof(pd->multi_click_time);
+ value.addr = (XtPointer)&pd->multi_click_time;
+ if (!_GetResource(dpy, search_list,
+ "multiClickTime", "MultiClickTime",
+ XtRInt, &value)) {
+ pd->multi_click_time = 200;
+ }
+
+ value.size = sizeof(pd->appContext->selectionTimeout);
+ value.addr = (XtPointer)&pd->appContext->selectionTimeout;
+ (void)_GetResource(dpy, search_list,
+ "selectionTimeout", "SelectionTimeout",
+ XtRInt, &value);
+
+#ifndef NO_IDENTIFY_WINDOWS
+ value.size = sizeof(pd->appContext->identify_windows);
+ value.addr = (XtPointer)&pd->appContext->identify_windows;
+ (void)_GetResource(dpy, search_list,
+ "xtIdentifyWindows", "XtDebug",
+ XtRBoolean, &value);
+#endif
+
+ XAddConnectionWatch(dpy, ConnectionWatch, (XPointer) dpy);
+
+ XtFree( (XtPointer)options );
+ DEALLOCATE_LOCAL( search_list );
+}
+
+/* Function Name: XtAppSetFallbackResources
+ * Description: Sets the fallback resource list that will be loaded
+ * at display initialization time.
+ * Arguments: app_context - the app context.
+ * specification_list - the resource specification list.
+ * Returns: none.
+ */
+
+void
+XtAppSetFallbackResources(
+ XtAppContext app_context,
+ String *specification_list)
+{
+ LOCK_APP(app_context);
+ app_context->fallback_resources = specification_list;
+ UNLOCK_APP(app_context);
+}
+
+
+Widget XtOpenApplication(XtAppContext *app_context_return,
+ _Xconst char *application_class,
+ XrmOptionDescRec *options, Cardinal num_options,
+ int *argc_in_out, String *argv_in_out,
+ String *fallback_resources, WidgetClass widget_class,
+ ArgList args_in, Cardinal num_args_in)
+{
+ XtAppContext app_con;
+ Display * dpy;
+ register int saved_argc = *argc_in_out;
+ Widget root;
+ Arg args[3], *merged_args;
+ Cardinal num = 0;
+
+ XtToolkitInitialize(); /* cannot be moved into _XtAppInit */
+
+ dpy = _XtAppInit(&app_con, (String)application_class, options, num_options,
+ argc_in_out, &argv_in_out, fallback_resources);
+
+ LOCK_APP(app_con);
+ XtSetArg(args[num], XtNscreen, DefaultScreenOfDisplay(dpy)); num++;
+ XtSetArg(args[num], XtNargc, saved_argc); num++;
+ XtSetArg(args[num], XtNargv, argv_in_out); num++;
+
+ merged_args = XtMergeArgLists(args_in, num_args_in, args, num);
+ num += num_args_in;
+
+ root = XtAppCreateShell(NULL, application_class, widget_class, dpy,
+ merged_args, num);
+
+ if (app_context_return)
+ *app_context_return = app_con;
+
+ XtFree((XtPointer)merged_args);
+ XtFree((XtPointer)argv_in_out);
+ UNLOCK_APP(app_con);
+ return root;
+}
+
+
+Widget
+XtAppInitialize(
+ XtAppContext * app_context_return,
+ _Xconst char* application_class,
+ XrmOptionDescRec *options,
+ Cardinal num_options,
+ int *argc_in_out,
+ String *argv_in_out,
+ String *fallback_resources,
+ ArgList args_in,
+ Cardinal num_args_in)
+{
+ return XtOpenApplication(app_context_return, application_class,
+ options, num_options,
+ argc_in_out, argv_in_out, fallback_resources,
+ applicationShellWidgetClass,
+ args_in, num_args_in);
+}
+
+
+/*ARGSUSED*/
+Widget
+XtInitialize(
+ _Xconst char* name,
+ _Xconst char* classname,
+ XrmOptionDescRec *options,
+ Cardinal num_options,
+ int *argc,
+ String *argv)
+{
+ Widget root;
+ XtAppContext app_con;
+ register ProcessContext process = _XtGetProcessContext();
+
+ root = XtAppInitialize(&app_con, classname, options, num_options,
+ argc, argv, NULL, NULL, (Cardinal) 0);
+
+ LOCK_PROCESS;
+ process->defaultAppContext = app_con;
+ UNLOCK_PROCESS;
+ return root;
+}
diff --git a/nx-X11/lib/Xt/Intrinsic.c b/nx-X11/lib/Xt/Intrinsic.c
new file mode 100644
index 000000000..482df0ab3
--- /dev/null
+++ b/nx-X11/lib/Xt/Intrinsic.c
@@ -0,0 +1,1593 @@
+/* $Xorg: Intrinsic.c,v 1.4 2001/02/09 02:03:55 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/Intrinsic.c,v 3.22 2003/01/12 03:55:46 tsi Exp $ */
+
+/*
+
+Copyright 1987, 1988, 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.
+
+*/
+
+#define INTRINSIC_C
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "VarargsI.h" /* for geoTattler */
+#ifndef NO_IDENTIFY_WINDOWS
+#include <X11/Xatom.h>
+#endif
+#ifndef VMS
+#include <sys/stat.h>
+#endif /* VMS */
+
+#include <stdlib.h>
+
+String XtCXtToolkitError = "XtToolkitError";
+
+Boolean XtIsSubclass(
+ Widget widget,
+ WidgetClass widgetClass)
+{
+ register WidgetClass w;
+ Boolean retval = FALSE;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ for (w = widget->core.widget_class; w != NULL; w = w->core_class.superclass)
+ if (w == widgetClass) {
+ retval = TRUE;
+ break;
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return retval;
+} /* XtIsSubclass */
+
+
+Boolean _XtCheckSubclassFlag(
+ Widget object,
+ _XtXtEnum flag)
+{
+ Boolean retval;
+
+ LOCK_PROCESS;
+ if (object->core.widget_class->core_class.class_inited & flag)
+ retval = TRUE;
+ else
+ retval = FALSE;
+ UNLOCK_PROCESS;
+ return retval;
+} /*_XtVerifySubclass */
+
+
+Boolean _XtIsSubclassOf(
+ Widget object,
+ WidgetClass widgetClass,
+ WidgetClass superClass,
+ _XtXtEnum flag)
+{
+ LOCK_PROCESS;
+ if (!(object->core.widget_class->core_class.class_inited & flag)) {
+ UNLOCK_PROCESS;
+ return False;
+ } else {
+ register WidgetClass c = object->core.widget_class;
+ while (c != superClass) {
+ if (c == widgetClass) {
+ UNLOCK_PROCESS;
+ return True;
+ }
+ c = c->core_class.superclass;
+ }
+ UNLOCK_PROCESS;
+ return False;
+ }
+} /*_XtIsSubclassOf */
+
+
+XtPointer XtGetClassExtension(
+ WidgetClass object_class,
+ Cardinal byte_offset,
+ XrmQuark type,
+ long version,
+ Cardinal record_size)
+{
+ ObjectClassExtension ext;
+ LOCK_PROCESS;
+
+ ext = *(ObjectClassExtension *)((char *)object_class + byte_offset);
+ while (ext && (ext->record_type != type || ext->version < version
+ || ext->record_size < record_size)) {
+ ext = (ObjectClassExtension) ext->next_extension;
+ }
+
+ UNLOCK_PROCESS;
+ return (XtPointer) ext;
+}
+
+
+static void ComputeWindowAttributes(
+ Widget widget,
+ XtValueMask *value_mask,
+ XSetWindowAttributes *values)
+{
+ XtExposeProc expose;
+
+ *value_mask = CWEventMask | CWColormap;
+ (*values).event_mask = XtBuildEventMask(widget);
+ (*values).colormap = widget->core.colormap;
+ if (widget->core.background_pixmap != XtUnspecifiedPixmap) {
+ *value_mask |= CWBackPixmap;
+ (*values).background_pixmap = widget->core.background_pixmap;
+ } else {
+ *value_mask |= CWBackPixel;
+ (*values).background_pixel = widget->core.background_pixel;
+ }
+ if (widget->core.border_pixmap != XtUnspecifiedPixmap) {
+ *value_mask |= CWBorderPixmap;
+ (*values).border_pixmap = widget->core.border_pixmap;
+ } else {
+ *value_mask |= CWBorderPixel;
+ (*values).border_pixel = widget->core.border_pixel;
+ }
+ LOCK_PROCESS;
+ expose = widget->core.widget_class->core_class.expose;
+ UNLOCK_PROCESS;
+ if (expose == (XtExposeProc) NULL) {
+ /* Try to avoid redisplay upon resize by making bit_gravity the same
+ as the default win_gravity */
+ *value_mask |= CWBitGravity;
+ (*values).bit_gravity = NorthWestGravity;
+ }
+} /* ComputeWindowAttributes */
+
+static void CallChangeManaged(
+ register Widget widget)
+{
+ register Cardinal i;
+ XtWidgetProc change_managed;
+ register WidgetList children;
+ int managed_children = 0;
+
+ register CompositePtr cpPtr;
+ register CompositePartPtr clPtr;
+
+ if (XtIsComposite (widget)) {
+ cpPtr = (CompositePtr)&((CompositeWidget) widget)->composite;
+ clPtr = (CompositePartPtr)&((CompositeWidgetClass)
+ widget->core.widget_class)->composite_class;
+ } else return;
+
+ children = cpPtr->children;
+ LOCK_PROCESS;
+ change_managed = clPtr->change_managed;
+ UNLOCK_PROCESS;
+
+ /* CallChangeManaged for all children */
+ for (i = cpPtr->num_children; i != 0; --i) {
+ CallChangeManaged (children[i-1]);
+ if (XtIsManaged(children[i-1])) managed_children++;
+ }
+
+ if (change_managed != NULL && managed_children != 0) {
+ CALLGEOTAT(_XtGeoTrace(widget,"Call \"%s\"[%d,%d]'s changemanaged\n",
+ XtName(widget),
+ widget->core.width, widget->core.height));
+ (*change_managed) (widget);
+ }
+} /* CallChangeManaged */
+
+
+static void MapChildren(
+ CompositePart *cwp)
+{
+ Cardinal i;
+ WidgetList children;
+ register Widget child;
+
+ children = cwp->children;
+ for (i = 0; i < cwp->num_children; i++) {
+ child = children[i];
+ if (XtIsWidget (child)){
+ if (child->core.managed && child->core.mapped_when_managed) {
+ XtMapWidget (children[i]);
+ }
+ }
+ }
+} /* MapChildren */
+
+
+static Boolean ShouldMapAllChildren(
+ CompositePart *cwp)
+{
+ Cardinal i;
+ WidgetList children;
+ register Widget child;
+
+ children = cwp->children;
+ for (i = 0; i < cwp->num_children; i++) {
+ child = children[i];
+ if (XtIsWidget(child)) {
+ if (XtIsRealized(child) && (! (child->core.managed
+ && child->core.mapped_when_managed))){
+ return False;
+ }
+ }
+ }
+
+ return True;
+} /* ShouldMapAllChildren */
+
+
+static void RealizeWidget(
+ Widget widget)
+{
+ XtValueMask value_mask;
+ XSetWindowAttributes values;
+ XtRealizeProc realize;
+ Window window;
+ Display* display;
+ String class_name;
+ Widget hookobj;
+
+ if (!XtIsWidget(widget) || XtIsRealized(widget)) return;
+ display = XtDisplay(widget);
+ _XtInstallTranslations(widget);
+
+ ComputeWindowAttributes (widget, &value_mask, &values);
+ LOCK_PROCESS;
+ realize = widget->core.widget_class->core_class.realize;
+ class_name = widget->core.widget_class->core_class.class_name;
+ UNLOCK_PROCESS;
+ if (realize == NULL)
+ XtAppErrorMsg(XtWidgetToApplicationContext(widget),
+ "invalidProcedure","realizeProc",XtCXtToolkitError,
+ "No realize class procedure defined",
+ (String *)NULL, (Cardinal *)NULL);
+ else {
+ CALLGEOTAT(_XtGeoTrace(widget,"Call \"%s\"[%d,%d]'s realize proc\n",
+ XtName(widget),
+ widget->core.width, widget->core.height));
+ (*realize) (widget, &value_mask, &values);
+ }
+ window = XtWindow(widget);
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
+ if (XtHasCallbacks(hookobj,XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHrealizeWidget;
+ call_data.widget = widget;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+#ifndef NO_IDENTIFY_WINDOWS
+ if (_XtGetPerDisplay(display)->appContext->identify_windows) {
+ int len_nm, len_cl;
+ char *s;
+
+ len_nm = widget->core.name ? strlen(widget->core.name) : 0;
+ len_cl = strlen(class_name);
+ s = __XtMalloc((unsigned) (len_nm + len_cl + 2));
+ s[0] = '\0';
+ if (len_nm)
+ strcpy(s, widget->core.name);
+ strcpy(s + len_nm + 1, class_name);
+ XChangeProperty(display, window,
+ XInternAtom(display, "_MIT_OBJ_CLASS",
+ False),
+ XA_STRING, 8, PropModeReplace, (unsigned char *) s,
+ len_nm + len_cl + 2);
+ XtFree(s);
+ }
+#endif
+#ifdef notdef
+ _XtRegisterAsyncHandlers(widget);
+#endif
+ /* (re)register any grabs extant in the translations */
+ _XtRegisterGrabs(widget);
+ /* reregister any grabs added with XtGrab{Button,Key} */
+ _XtRegisterPassiveGrabs(widget);
+ XtRegisterDrawable (display, window, widget);
+ _XtExtensionSelect(widget);
+
+ if (XtIsComposite (widget)) {
+ Cardinal i;
+ CompositePart *cwp = &(((CompositeWidget)widget)->composite);
+ WidgetList children = cwp->children;
+ /* Realize all children */
+ for (i = cwp->num_children; i != 0; --i) {
+ RealizeWidget (children[i-1]);
+ }
+ /* Map children that are managed and mapped_when_managed */
+
+ if (cwp->num_children != 0) {
+ if (ShouldMapAllChildren(cwp)) {
+ XMapSubwindows (display, window);
+ } else {
+ MapChildren(cwp);
+ }
+ }
+ }
+
+ /* If this is the application's popup shell, map it */
+ if (widget->core.parent == NULL && widget->core.mapped_when_managed) {
+ XtMapWidget (widget);
+ }
+} /* RealizeWidget */
+
+void XtRealizeWidget (
+ Widget widget)
+{
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ if (XtIsRealized (widget)) {
+ UNLOCK_APP(app);
+ return;
+ }
+ CallChangeManaged(widget);
+ RealizeWidget(widget);
+ UNLOCK_APP(app);
+} /* XtRealizeWidget */
+
+
+static void UnrealizeWidget(
+ Widget widget)
+{
+ CompositeWidget cw;
+ Cardinal i;
+ WidgetList children;
+
+ if (!XtIsWidget(widget) || !XtIsRealized(widget)) return;
+
+ /* If this is the application's popup shell, unmap it? */
+ /* no, the window is being destroyed */
+
+ /* Recurse on children */
+ if (XtIsComposite (widget)) {
+ cw = (CompositeWidget) widget;
+ children = cw->composite.children;
+ /* Unrealize all children */
+ for (i = cw->composite.num_children; i != 0; --i) {
+ UnrealizeWidget (children[i-1]);
+ }
+ /* Unmap children that are managed and mapped_when_managed? */
+ /* No, it's ok to be managed and unrealized as long as your parent */
+ /* is unrealized. XtUnrealize widget makes sure the "top" widget */
+ /* is unmanaged, we can ignore all descendents */
+ }
+
+ if (XtHasCallbacks(widget, XtNunrealizeCallback) == XtCallbackHasSome)
+ XtCallCallbacks(widget, XtNunrealizeCallback, NULL);
+
+ /* Unregister window */
+ XtUnregisterDrawable(XtDisplay(widget), XtWindow(widget));
+
+ /* Remove Event Handlers */
+ /* remove grabs. Happens automatically when window is destroyed. */
+
+ /* Destroy X Window, done at outer level with one request */
+ widget->core.window = None;
+
+ /* Removing the event handler here saves having to keep track if
+ * the translation table is changed while the widget is unrealized.
+ */
+ _XtRemoveTranslations(widget);
+} /* UnrealizeWidget */
+
+
+void XtUnrealizeWidget (
+ Widget widget)
+{
+ Window window;
+ Widget hookobj;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ window = XtWindow(widget);
+ if (! XtIsRealized (widget)) {
+ UNLOCK_APP(app);
+ return;
+ }
+ if (widget->core.managed && widget->core.parent != NULL)
+ XtUnmanageChild(widget);
+ UnrealizeWidget(widget);
+ if (window != None)
+ XDestroyWindow(XtDisplay(widget), window);
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHunrealizeWidget;
+ call_data.widget = widget;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ UNLOCK_APP(app);
+} /* XtUnrealizeWidget */
+
+
+void XtCreateWindow(
+ Widget widget,
+ unsigned int window_class,
+ Visual *visual,
+ XtValueMask value_mask,
+ XSetWindowAttributes *attributes)
+{
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+
+ LOCK_APP(app);
+ if (widget->core.window == None) {
+ if (widget->core.width == 0 || widget->core.height == 0) {
+ Cardinal count = 1;
+ XtAppErrorMsg(app,
+ "invalidDimension", "xtCreateWindow", XtCXtToolkitError,
+ "Widget %s has zero width and/or height",
+ &widget->core.name, &count);
+ }
+ widget->core.window =
+ XCreateWindow (
+ XtDisplay (widget),
+ (widget->core.parent ?
+ widget->core.parent->core.window :
+ widget->core.screen->root),
+ (int)widget->core.x, (int)widget->core.y,
+ (unsigned)widget->core.width, (unsigned)widget->core.height,
+ (unsigned)widget->core.border_width, (int) widget->core.depth,
+ window_class, visual, value_mask, attributes);
+ }
+ UNLOCK_APP(app);
+} /* XtCreateWindow */
+
+
+/* ---------------- XtNameToWidget ----------------- */
+
+static Widget NameListToWidget(
+ Widget root,
+ XrmNameList names,
+ XrmBindingList bindings,
+ int in_depth, int *out_depth, int *found_depth);
+
+typedef Widget (*NameMatchProc)(XrmNameList,
+ XrmBindingList,
+ WidgetList, Cardinal, int, int *, int *);
+
+static Widget MatchExactChildren(
+ XrmNameList names,
+ XrmBindingList bindings,
+ register WidgetList children,
+ register Cardinal num,
+ int in_depth, int *out_depth, int *found_depth)
+{
+ register Cardinal i;
+ register XrmName name = *names;
+ Widget w, result = NULL;
+ int d, min = 10000;
+
+ for (i = 0; i < num; i++) {
+ if (name == children[i]->core.xrm_name) {
+ w = NameListToWidget(children[i], &names[1], &bindings[1],
+ in_depth+1, &d, found_depth);
+ if (w != NULL && d < min) {result = w; min = d;}
+ }
+ }
+ *out_depth = min;
+ return result;
+}
+
+static Widget MatchWildChildren(
+ XrmNameList names,
+ XrmBindingList bindings,
+ register WidgetList children,
+ register Cardinal num,
+ int in_depth, int *out_depth, int *found_depth)
+{
+ register Cardinal i;
+ Widget w, result = NULL;
+ int d, min = 10000;
+
+ for (i = 0; i < num; i++) {
+ w = NameListToWidget(children[i], names, bindings,
+ in_depth+1, &d, found_depth);
+ if (w != NULL && d < min) {result = w; min = d;}
+ }
+ *out_depth = min;
+ return result;
+}
+
+static Widget SearchChildren(
+ Widget root,
+ XrmNameList names,
+ XrmBindingList bindings,
+ NameMatchProc matchproc,
+ int in_depth, int *out_depth, int *found_depth)
+{
+ Widget w1 = 0, w2;
+ int d1, d2;
+
+ if (XtIsComposite(root)) {
+ w1 = (*matchproc)(names, bindings,
+ ((CompositeWidget) root)->composite.children,
+ ((CompositeWidget) root)->composite.num_children,
+ in_depth, &d1, found_depth);
+ } else d1 = 10000;
+ w2 = (*matchproc)(names, bindings, root->core.popup_list,
+ root->core.num_popups, in_depth, &d2, found_depth);
+ *out_depth = (d1 < d2 ? d1 : d2);
+ return (d1 < d2 ? w1 : w2);
+}
+
+static Widget NameListToWidget(
+ register Widget root,
+ XrmNameList names,
+ XrmBindingList bindings,
+ int in_depth, int *out_depth, int *found_depth)
+{
+ Widget w1, w2;
+ int d1, d2;
+
+ if (in_depth >= *found_depth) {
+ *out_depth = 10000;
+ return NULL;
+ }
+
+ if (names[0] == NULLQUARK) {
+ *out_depth = *found_depth = in_depth;
+ return root;
+ }
+
+ if (! XtIsWidget(root)) {
+ *out_depth = 10000;
+ return NULL;
+ }
+
+ if (*bindings == XrmBindTightly) {
+ return SearchChildren(root, names, bindings, MatchExactChildren,
+ in_depth, out_depth, found_depth);
+
+ } else { /* XrmBindLoosely */
+ w1 = SearchChildren(root, names, bindings, MatchExactChildren,
+ in_depth, &d1, found_depth);
+ w2 = SearchChildren(root, names, bindings, MatchWildChildren,
+ in_depth, &d2, found_depth);
+ *out_depth = (d1 < d2 ? d1 : d2);
+ return (d1 < d2 ? w1 : w2);
+ }
+} /* NameListToWidget */
+
+Widget XtNameToWidget(
+ Widget root,
+ _Xconst char* name)
+{
+ XrmName *names;
+ XrmBinding *bindings;
+ int len, depth, found = 10000;
+ Widget result;
+ WIDGET_TO_APPCON(root);
+
+ len = strlen(name);
+ if (len == 0) return NULL;
+
+ LOCK_APP(app);
+ names = (XrmName *) ALLOCATE_LOCAL((unsigned) (len+1) * sizeof(XrmName));
+ bindings = (XrmBinding *)
+ ALLOCATE_LOCAL((unsigned) (len+1) * sizeof(XrmBinding));
+ if (names == NULL || bindings == NULL) _XtAllocError(NULL);
+
+ XrmStringToBindingQuarkList(name, bindings, names);
+ if (names[0] == NULLQUARK) {
+ DEALLOCATE_LOCAL((char *) bindings);
+ DEALLOCATE_LOCAL((char *) names);
+ UNLOCK_APP(app);
+ return NULL;
+ }
+
+ result = NameListToWidget(root, names, bindings, 0, &depth, &found);
+
+ DEALLOCATE_LOCAL((char *) bindings);
+ DEALLOCATE_LOCAL((char *) names);
+ UNLOCK_APP(app);
+ return result;
+} /* XtNameToWidget */
+
+/* Define user versions of intrinsics macros */
+
+#undef XtDisplayOfObject
+Display *XtDisplayOfObject(
+ Widget object)
+{
+ /* Attempts to LockApp() here will generate endless recursive loops */
+ if (XtIsSubclass(object, hookObjectClass))
+ return DisplayOfScreen(((HookObject)object)->hooks.screen);
+ return XtDisplay(XtIsWidget(object) ? object : _XtWindowedAncestor(object));
+}
+
+#undef XtDisplay
+Display *XtDisplay(
+ Widget widget)
+{
+ /* Attempts to LockApp() here will generate endless recursive loops */
+ return DisplayOfScreen(widget->core.screen);
+}
+
+#undef XtScreenOfObject
+Screen *XtScreenOfObject(
+ Widget object)
+{
+ /* Attempts to LockApp() here will generate endless recursive loops */
+ if (XtIsSubclass(object, hookObjectClass))
+ return ((HookObject)object)->hooks.screen;
+ return XtScreen(XtIsWidget(object) ? object : _XtWindowedAncestor(object));
+}
+
+#undef XtScreen
+Screen *XtScreen(
+ Widget widget)
+{
+ /* Attempts to LockApp() here will generate endless recursive loops */
+ return widget->core.screen;
+}
+
+#undef XtWindowOfObject
+Window XtWindowOfObject(
+ Widget object)
+{
+ return XtWindow(XtIsWidget(object) ? object : _XtWindowedAncestor(object));
+}
+
+
+#undef XtWindow
+Window XtWindow(
+ Widget widget)
+{
+ return widget->core.window;
+}
+
+#undef XtSuperclass
+WidgetClass XtSuperclass(
+ Widget widget)
+{
+ WidgetClass retval;
+
+ LOCK_PROCESS;
+ retval = XtClass(widget)->core_class.superclass;
+ UNLOCK_PROCESS;
+ return retval;
+}
+
+#undef XtClass
+WidgetClass XtClass(
+ Widget widget)
+{
+ WidgetClass retval;
+
+ LOCK_PROCESS;
+ retval = widget->core.widget_class;
+ UNLOCK_PROCESS;
+ return retval;
+}
+
+#undef XtIsManaged
+Boolean XtIsManaged(
+ Widget object)
+{
+ Boolean retval;
+ WIDGET_TO_APPCON(object);
+
+ LOCK_APP(app);
+ if (XtIsRectObj(object))
+ retval = object->core.managed;
+ else
+ retval = False;
+ UNLOCK_APP(app);
+ return retval;
+}
+
+#undef XtIsRealized
+Boolean XtIsRealized (
+ Widget object)
+{
+ Boolean retval;
+ WIDGET_TO_APPCON(object);
+
+ LOCK_APP(app);
+ retval = XtWindowOfObject(object) != None;
+ UNLOCK_APP(app);
+ return retval;
+} /* XtIsRealized */
+
+#undef XtIsSensitive
+Boolean XtIsSensitive(
+ Widget object)
+{
+ Boolean retval;
+ WIDGET_TO_APPCON(object);
+
+ LOCK_APP(app);
+ if (XtIsRectObj(object))
+ retval = object->core.sensitive && object->core.ancestor_sensitive;
+ else
+ retval = False;
+ UNLOCK_APP(app);
+ return retval;
+}
+
+/*
+ * Internal routine; must be called only after XtIsWidget returns false
+ */
+Widget _XtWindowedAncestor(
+ register Widget object)
+{
+ Widget obj = object;
+ for (object = XtParent(object); object && !XtIsWidget(object);)
+ object = XtParent(object);
+
+ if (object == NULL) {
+ String params = XtName(obj);
+ Cardinal num_params = 1;
+ XtErrorMsg("noWidgetAncestor", "windowedAncestor", XtCXtToolkitError,
+ "Object \"%s\" does not have windowed ancestor",
+ &params, &num_params);
+ }
+
+ return object;
+}
+
+#undef XtParent
+Widget XtParent(
+ Widget widget)
+{
+ /* Attempts to LockApp() here will generate endless recursive loops */
+ return widget->core.parent;
+}
+
+#undef XtName
+String XtName(
+ Widget object)
+{
+ /* Attempts to LockApp() here will generate endless recursive loops */
+ return XrmQuarkToString(object->core.xrm_name);
+}
+
+
+Boolean XtIsObject(
+ Widget object)
+{
+ WidgetClass wc;
+ String class_name;
+
+ /* perform basic sanity checks */
+ if (object->core.self != object || object->core.xrm_name == NULLQUARK)
+ return False;
+
+ LOCK_PROCESS;
+ wc = object->core.widget_class;
+ if (wc->core_class.class_name == NULL ||
+ wc->core_class.xrm_class == NULLQUARK ||
+ (class_name = XrmClassToString(wc->core_class.xrm_class)) == NULL ||
+ strcmp(wc->core_class.class_name, class_name) != 0) {
+ UNLOCK_PROCESS;
+ return False;
+ }
+ UNLOCK_PROCESS;
+
+ if (XtIsWidget(object)) {
+ if (object->core.name == NULL ||
+ (class_name = XrmNameToString(object->core.xrm_name)) == NULL ||
+ strcmp(object->core.name, class_name) != 0)
+ return False;
+ }
+ return True;
+}
+
+#if defined(WIN32)
+static int access_file (
+ char* path,
+ char* pathbuf,
+ int len_pathbuf,
+ char** pathret)
+{
+ if (access (path, F_OK) == 0) {
+ if (strlen (path) < len_pathbuf)
+ *pathret = pathbuf;
+ else
+ *pathret = XtMalloc (strlen (path));
+ if (*pathret) {
+ strcpy (*pathret, path);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int AccessFile (
+ char* path,
+ char* pathbuf,
+ int len_pathbuf,
+ char** pathret)
+{
+ unsigned long drives;
+ int i, len;
+ char* drive;
+ char buf[MAX_PATH];
+ char* bufp;
+
+ /* just try the "raw" name first and see if it works */
+ if (access_file (path, pathbuf, len_pathbuf, pathret))
+ return 1;
+
+ /* try the places set in the environment */
+ drive = getenv ("_XBASEDRIVE");
+#ifdef __UNIXOS2__
+ if (!drive)
+ drive = getenv ("X11ROOT");
+#endif
+ if (!drive)
+ drive = "C:";
+ len = strlen (drive) + strlen (path);
+ bufp = XtStackAlloc (len + 1, buf);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ XtStackFree (bufp, buf);
+ return 1;
+ }
+
+#ifndef __UNIXOS2__
+ /* one last place to look */
+ drive = getenv ("HOMEDRIVE");
+ if (drive) {
+ len = strlen (drive) + strlen (path);
+ bufp = XtStackAlloc (len + 1, buf);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ XtStackFree (bufp, buf);
+ return 1;
+ }
+ }
+
+ /* does OS/2 (with or with gcc-emx) have getdrives()? */
+ /* tried everywhere else, go fishing */
+ drives = _getdrives ();
+#define C_DRIVE ('C' - 'A')
+#define Z_DRIVE ('Z' - 'A')
+ for (i = C_DRIVE; i <= Z_DRIVE; i++) { /* don't check on A: or B: */
+ if ((1 << i) & drives) {
+ len = 2 + strlen (path);
+ bufp = XtStackAlloc (len + 1, buf);
+ *bufp = 'A' + i;
+ *(bufp + 1) = ':';
+ *(bufp + 2) = '\0';
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ XtStackFree (bufp, buf);
+ return 1;
+ }
+ }
+ }
+#endif
+ return 0;
+}
+#endif
+
+static Boolean TestFile(
+ String path)
+{
+#ifndef VMS
+ int ret = 0;
+ struct stat status;
+#if defined(WIN32)
+ char buf[MAX_PATH];
+ char* bufp;
+ int len;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ path = bufp;
+
+ (void) SetErrorMode (olderror);
+#endif
+ ret = (access(path, R_OK) == 0 && /* exists and is readable */
+ stat(path, &status) == 0 && /* get the status */
+#ifndef X_NOT_POSIX
+ S_ISDIR(status.st_mode) == 0); /* not a directory */
+#else
+ (status.st_mode & S_IFMT) != S_IFDIR); /* not a directory */
+#endif /* X_NOT_POSIX else */
+#if defined(WIN32)
+ XtStackFree ((XtPointer)bufp, buf);
+#endif
+ return ret;
+#else /* VMS */
+ return TRUE; /* Who knows what to do here? */
+#endif /* VMS */
+}
+
+/* return of TRUE = resolved string fit, FALSE = didn't fit. Not
+ null-terminated and not collapsed if it didn't fit */
+
+static Boolean Resolve(
+ register _Xconst char *source, /* The source string */
+ register int len, /* The length in bytes of *source */
+ Substitution sub, /* Array of string values to substitute */
+ Cardinal num, /* Number of substitution entries */
+ char *buf, /* Where to put the resolved string; */
+ char collapse) /* Character to collapse */
+{
+ register int bytesLeft = PATH_MAX;
+ register char* bp = buf;
+#ifndef DONT_COLLAPSE
+ Boolean atBeginning = TRUE;
+ Boolean prevIsCollapse = FALSE;
+
+#define PUT(ch) \
+ { \
+ if (--bytesLeft == 0) return FALSE; \
+ if (prevIsCollapse) \
+ if ((*bp = ch) != collapse) { \
+ prevIsCollapse = FALSE; \
+ bp++; \
+ } \
+ else bytesLeft++; \
+ else if ((*bp++ = ch) == collapse && !atBeginning) \
+ prevIsCollapse = TRUE; \
+ }
+#else /* DONT_COLLAPSE */
+
+#define PUT(ch) \
+ { \
+ if (--bytesLeft == 0) return FALSE; \
+ *bp++ = ch; \
+ }
+#endif /* DONT_COLLAPSE */
+#define escape '%'
+
+ while (len--) {
+#ifndef DONT_COLLAPSE
+ if (*source == collapse) {
+ PUT(*source);
+ source++;
+ continue;
+ }
+ else
+#endif /* DONT_COLLAPSE */
+ if (*source != escape) {
+ PUT(*source);
+ }
+ else {
+ source++;
+ if (len-- == 0) {
+ PUT(escape);
+ break;
+ }
+
+ if (*source == ':' || *source == escape)
+ PUT(*source)
+ else {
+ /* Match the character against the match array */
+ register Cardinal j;
+
+ for (j = 0; j < num && sub[j].match != *source; j++) {}
+
+ /* Substitute the substitution string */
+
+ if (j >= num) PUT(*source)
+ else if (sub[j].substitution != NULL) {
+ char *sp = sub[j].substitution;
+ while (*sp) {
+ PUT(*sp);
+ sp++;
+ }
+ }
+ }
+ }
+ source++;
+#ifndef DONT_COLLAPSE
+ atBeginning = FALSE;
+#endif /* DONT_COLLAPSE */
+ }
+ PUT('\0');
+
+ return TRUE;
+#undef PUT
+#undef escape
+}
+
+
+String XtFindFile(
+ _Xconst char* path,
+ Substitution substitutions,
+ Cardinal num_substitutions,
+ XtFilePredicate predicate)
+{
+ char *buf, *buf1, *buf2, *colon;
+ int len;
+ Boolean firstTime = TRUE;
+
+ buf = buf1 = __XtMalloc((unsigned)PATH_MAX);
+ buf2 = __XtMalloc((unsigned)PATH_MAX);
+
+ if (predicate == NULL) predicate = TestFile;
+
+ while (1) {
+ colon = (String)path;
+ /* skip leading colons */
+ while (*colon) {
+ if (*colon != ':') break;
+ colon++;
+ path++;
+ }
+ /* now look for an un-escaped colon */
+ for ( ; *colon ; colon++) {
+ if (*colon == '%' && *(path+1)) {
+ colon++; /* bump it an extra time to skip %. */
+ continue;
+ }
+ if (*colon == ':')
+#ifdef __UNIXOS2__
+ if (colon > (path+1))
+#endif
+ break;
+ }
+ len = colon - path;
+ if (Resolve(path, len, substitutions, num_substitutions,
+ buf, '/')) {
+ if (firstTime || strcmp(buf1,buf2) != 0) {
+#ifdef __UNIXOS2__
+ {
+ char *bufx = (char*)__XOS2RedirRoot(buf);
+ strcpy(buf,bufx);
+ }
+#endif
+#ifdef XNL_DEBUG
+ printf("Testing file %s\n", buf);
+#endif /* XNL_DEBUG */
+ /* Check out the file */
+ if ((*predicate) (buf)) {
+ /* We've found it, return it */
+#ifdef XNL_DEBUG
+ printf("File found.\n");
+#endif /* XNL_DEBUG */
+ if (buf == buf1) XtFree(buf2);
+ else XtFree(buf1);
+ return buf;
+ }
+ if (buf == buf1)
+ buf = buf2;
+ else
+ buf = buf1;
+ firstTime = FALSE;
+ }
+ }
+
+ /* Nope...any more paths? */
+
+ if (*colon == '\0') break;
+ path = colon+1;
+ }
+
+ /* No file found */
+
+ XtFree(buf1);
+ XtFree(buf2);
+ return NULL;
+}
+
+
+/* The implementation of this routine is operating system dependent */
+/* Should match the code in Xlib _XlcMapOSLocaleName */
+
+static char *ExtractLocaleName(
+ String lang)
+{
+
+#if defined(hpux) || defined(CSRG_BASED) || defined(sun) || defined(SVR4) || defined(sgi) || defined(__osf__) || defined(AIXV3) || defined(ultrix) || defined(WIN32) || defined(__UNIXOS2__) || defined (linux)
+# ifdef hpux
+/*
+ * We need to discriminated between HPUX 9 and HPUX 10. The equivalent
+ * code in Xlib in SetLocale.c does include locale.h via X11/Xlocale.h.
+ */
+# include <locale.h>
+# ifndef _LastCategory
+ /* HPUX 9 and earlier */
+# define SKIPCOUNT 2
+# define STARTCHAR ':'
+# define ENDCHAR ';'
+# else
+ /* HPUX 10 */
+# define ENDCHAR ' '
+# endif
+# else
+# ifdef ultrix
+# define SKIPCOUNT 2
+# define STARTCHAR '\001'
+# define ENDCHAR '\001'
+# else
+# if defined(WIN32) || defined(__UNIXOS2__)
+# define SKIPCOUNT 1
+# define STARTCHAR '='
+# define ENDCHAR ';'
+# define WHITEFILL
+# else
+# if defined(__osf__) || (defined(AIXV3) && !defined(AIXV4))
+# define STARTCHAR ' '
+# define ENDCHAR ' '
+# else
+# if defined(linux)
+# define STARTSTR "LC_CTYPE="
+# define ENDCHAR ';'
+# else
+# if !defined(sun) || defined(SVR4)
+# define STARTCHAR '/'
+# define ENDCHAR '/'
+# endif
+# endif
+# endif
+# endif
+# endif
+# endif
+
+ char *start;
+ char *end;
+ int len;
+# ifdef SKIPCOUNT
+ int n;
+# endif
+ static char* buf = NULL;
+
+ start = lang;
+# ifdef SKIPCOUNT
+ for (n = SKIPCOUNT;
+ --n >= 0 && start && (start = strchr (start, STARTCHAR));
+ start++)
+ ;
+ if (!start)
+ start = lang;
+# endif
+# ifdef STARTCHAR
+ if (start && (start = strchr (start, STARTCHAR)))
+# elif defined (STARTSTR)
+ if (start && (start = strstr (start,STARTSTR)))
+# endif
+ {
+# ifdef STARTCHAR
+ start++;
+# elif defined (STARTSTR)
+ start += strlen(STARTSTR);
+# endif
+
+ if ((end = strchr (start, ENDCHAR))) {
+ len = end - start;
+ if (buf != NULL) XtFree (buf);
+ buf = XtMalloc (len + 1);
+ if (buf == NULL) return NULL;
+ strncpy(buf, start, len);
+ *(buf + len) = '\0';
+# ifdef WHITEFILL
+ for (start = buf; start = strchr(start, ' '); )
+ *start++ = '-';
+# endif
+ return buf;
+ } else /* if no ENDCHAR is found we are at the end of the line */
+ return start;
+ }
+# ifdef WHITEFILL
+ if (strchr(lang, ' ')) {
+ if (buf != NULL) XtFree (buf);
+ else buf = XtMalloc (strlen (lang) + 1);
+ if (buf == NULL) return NULL;
+ strcpy(buf, lang);
+ for (start = buf; start = strchr(start, ' '); )
+ *start++ = '-';
+ return buf;
+ }
+# endif
+# undef STARTCHAR
+# undef ENDCHAR
+# undef WHITEFILL
+#endif
+
+ return lang;
+}
+
+static void FillInLangSubs(
+ Substitution subs,
+ XtPerDisplay pd)
+{
+ int len;
+ char *string, *p1, *p2, *p3;
+ char **rest;
+ char *ch;
+
+ if (pd->language == NULL ||
+ (pd->language != NULL && pd->language[0] == '\0')) {
+ subs[0].substitution = subs[1].substitution =
+ subs[2].substitution = subs[3].substitution = NULL;
+ return;
+ }
+
+ string = ExtractLocaleName(pd->language);
+
+ if (string == NULL ||
+ (string != NULL && string[0] == '\0')) {
+ subs[0].substitution = subs[1].substitution =
+ subs[2].substitution = subs[3].substitution = NULL;
+ return;
+ }
+
+ len = strlen(string) + 1;
+ subs[0].substitution = string;
+ p1 = subs[1].substitution = __XtMalloc((Cardinal) 3*len);
+ p2 = subs[2].substitution = subs[1].substitution + len;
+ p3 = subs[3].substitution = subs[2].substitution + len;
+
+ /* Everything up to the first "_" goes into p1. From "_" to "." in
+ p2. The rest in p3. If no delimiters, all goes into p1. We
+ assume p1, p2, and p3 are large enough. */
+
+ *p1 = *p2 = *p3 = '\0';
+
+ ch = strchr(string, '_');
+ if (ch != NULL) {
+ len = ch - string;
+ (void) strncpy(p1, string, len);
+ p1[len] = '\0';
+ string = ch + 1;
+ rest = &p2;
+ } else rest = &p1;
+
+ /* Rest points to where we put the first part */
+
+ ch = strchr(string, '.');
+ if (ch != NULL) {
+ len = ch - string;
+ strncpy(*rest, string, len);
+ (*rest)[len] = '\0';
+ (void) strcpy(p3, ch+1);
+ } else (void) strcpy(*rest, string);
+}
+
+/*
+ * default path used if environment variable XFILESEARCHPATH
+ * is not defined. Also substitued for %D.
+ * The exact value should be documented in the implementation
+ * notes for any Xt implementation.
+ */
+static char *implementation_default_path(void)
+{
+#if defined(WIN32) || defined(__UNIXOS2__)
+ /* if you know how to pass % thru the compiler let me know */
+ static char xfilesearchpath[] = XFILESEARCHPATHDEFAULT;
+ static Bool fixed;
+ char *ch;
+
+ if (!fixed) {
+ for (ch = xfilesearchpath; ch = strchr(ch, ';'); ch++)
+ *ch = '%';
+ fixed = True;
+ }
+ return xfilesearchpath;
+#else
+ return XFILESEARCHPATHDEFAULT;
+#endif
+}
+
+
+static SubstitutionRec defaultSubs[] = {
+ {'N', NULL},
+ {'T', NULL},
+ {'S', NULL},
+ {'C', NULL},
+ {'L', NULL},
+ {'l', NULL},
+ {'t', NULL},
+ {'c', NULL}
+};
+
+
+String XtResolvePathname(
+ Display *dpy,
+ _Xconst char* type,
+ _Xconst char* filename,
+ _Xconst char* suffix,
+ _Xconst char* path,
+ Substitution substitutions,
+ Cardinal num_substitutions,
+ XtFilePredicate predicate)
+{
+ XtPerDisplay pd;
+ static char *defaultPath = NULL;
+ char *impl_default = implementation_default_path();
+ int idef_len = strlen(impl_default);
+ char *massagedPath;
+ int bytesAllocd, bytesLeft;
+ char *ch, *result;
+ Substitution merged_substitutions;
+ XrmRepresentation db_type;
+ XrmValue value;
+ XrmName name_list[3];
+ XrmClass class_list[3];
+ Boolean pathMallocd = False;
+
+ LOCK_PROCESS;
+ pd = _XtGetPerDisplay(dpy);
+ if (path == NULL) {
+#ifndef VMS
+ if (defaultPath == NULL) {
+ defaultPath = getenv("XFILESEARCHPATH");
+ if (defaultPath == NULL)
+ defaultPath = impl_default;
+ }
+ path = defaultPath;
+#else
+ path = ""; /* NULL would kill us later */
+#endif /* VMS */
+ }
+
+ if (filename == NULL) {
+ filename = XrmClassToString(pd->class);
+ }
+
+ bytesAllocd = bytesLeft = 1000;
+ massagedPath = ALLOCATE_LOCAL(bytesAllocd);
+ if (massagedPath == NULL) _XtAllocError(NULL);
+
+ if (path[0] == ':') {
+ strcpy(massagedPath, "%N%S");
+ ch = &massagedPath[4];
+ bytesLeft -= 4;
+ } else ch = massagedPath;
+
+ /* Insert %N%S between adjacent colons
+ * and default path for %D.
+ * Default path should not have any adjacent colons of its own.
+ */
+
+ while (*path != '\0') {
+ if (bytesLeft < idef_len) {
+ int bytesUsed = bytesAllocd - bytesLeft;
+ char *new;
+ bytesAllocd +=1000;
+ new = __XtMalloc((Cardinal) bytesAllocd);
+ strncpy( new, massagedPath, bytesUsed );
+ ch = new + bytesUsed;
+ if (pathMallocd)
+ XtFree(massagedPath);
+ else
+ DEALLOCATE_LOCAL(massagedPath);
+ pathMallocd = True;
+ massagedPath = new;
+ bytesLeft = bytesAllocd - bytesUsed;
+ }
+ if (*path == '%' && *(path+1) == ':') {
+ *ch++ = '%';
+ *ch++ = ':';
+ path += 2;
+ bytesLeft -= 2;
+ continue;
+ }
+ if (*path == ':' && *(path+1) == ':') {
+ strcpy(ch, ":%N%S:");
+ ch += 6;
+ bytesLeft -= 6;
+ while (*path == ':') path++;
+ continue;
+ }
+ if (*path == '%' && *(path+1) == 'D') {
+ strcpy(ch, impl_default);
+ ch += idef_len;
+ bytesLeft -= idef_len;
+ path += 2;
+ continue;
+ }
+ *ch++ = *path++;
+ bytesLeft--;
+ }
+ *ch = '\0';
+#ifdef XNL_DEBUG
+ printf("Massaged path: %s\n", massagedPath);
+#endif /* XNL_DEBUG */
+
+ if (num_substitutions == 0)
+ merged_substitutions = defaultSubs;
+ else {
+ int i = XtNumber(defaultSubs);
+ Substitution sub, def;
+ merged_substitutions = sub = (Substitution)
+ ALLOCATE_LOCAL((unsigned)(num_substitutions+i)*sizeof(SubstitutionRec));
+ if (sub == NULL) _XtAllocError(NULL);
+ for (def = defaultSubs; i--; sub++, def++) sub->match = def->match;
+ for (i = num_substitutions; i--; ) *sub++ = *substitutions++;
+ }
+ merged_substitutions[0].substitution = (String)filename;
+ merged_substitutions[1].substitution = (String)type;
+ merged_substitutions[2].substitution = (String)suffix;
+ name_list[0] = pd->name;
+ name_list[1] = XrmPermStringToQuark("customization");
+ name_list[2] = NULLQUARK;
+ class_list[0] = pd->class;
+ class_list[1] = XrmPermStringToQuark("Customization");
+ class_list[2] = NULLQUARK;
+ if (XrmQGetResource(XrmGetDatabase(dpy), name_list, class_list,
+ &db_type, &value) &&
+ db_type == _XtQString)
+ merged_substitutions[3].substitution = (char *)value.addr;
+ else
+ merged_substitutions[3].substitution = NULL;
+ FillInLangSubs(&merged_substitutions[4], pd);
+
+ result = XtFindFile(massagedPath, merged_substitutions,
+ num_substitutions + XtNumber(defaultSubs),
+ predicate);
+
+ if (merged_substitutions[5].substitution != NULL)
+ XtFree( (XtPointer)merged_substitutions[5].substitution );
+
+ if (merged_substitutions != defaultSubs)
+ DEALLOCATE_LOCAL(merged_substitutions);
+
+ if (pathMallocd)
+ XtFree(massagedPath);
+ else
+ DEALLOCATE_LOCAL(massagedPath);
+
+ UNLOCK_PROCESS;
+ return result;
+}
+
+
+Boolean XtCallAcceptFocus(
+ Widget widget,
+ Time *time)
+{
+ XtAcceptFocusProc ac;
+ Boolean retval;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ ac = XtClass(widget)->core_class.accept_focus;
+ UNLOCK_PROCESS;
+
+ if (ac != NULL)
+ retval = (*ac) (widget, time);
+ else
+ retval = FALSE;
+ UNLOCK_APP(app);
+ return retval;
+}
+
+#ifdef XT_GEO_TATTLER
+/**************************************************************************
+ GeoTattler: This is used to debug Geometry management in Xt.
+
+ It uses a pseudo resource XtNgeotattler.
+
+ E.G. if those lines are found in the resource database:
+
+ myapp*draw.XmScale.geoTattler: ON
+ *XmScrollBar.geoTattler:ON
+ *XmRowColumn.exit_button.geoTattler:ON
+
+ then:
+
+ all the XmScale children of the widget named draw,
+ all the XmScrollBars,
+ the widget named exit_button in any XmRowColumn
+
+ will return True to the function IsTattled(), and will generate
+ outlined trace to stdout.
+
+*************************************************************************/
+
+#define XtNgeoTattler "geoTattler"
+#define XtCGeoTattler "GeoTattler"
+
+typedef struct { Boolean geo_tattler ;} GeoDataRec ;
+
+static XtResource geo_resources[] = {
+ { XtNgeoTattler, XtCGeoTattler, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(GeoDataRec, geo_tattler),
+ XtRImmediate, (XtPointer) False }
+};
+
+/************************************************************************
+ This function uses XtGetSubresources to find out if a widget
+ needs to be geo-spied by the caller. */
+static Boolean IsTattled (Widget widget)
+{
+ GeoDataRec geo_data ;
+
+ XtGetSubresources(widget, (XtPointer)&geo_data,
+ (String)NULL, (String)NULL,
+ geo_resources, XtNumber(geo_resources),
+ NULL, 0);
+
+ return geo_data.geo_tattler;
+
+} /* IsTattled */
+
+static int n_tab = 0 ; /* not MT for now */
+
+void
+_XtGeoTab (int direction) /* +1 or -1 */
+{
+ n_tab += direction ;
+}
+
+
+void
+_XtGeoTrace (Widget widget, ...)
+{
+ va_list args;
+ char *fmt;
+ int i ;
+ if (IsTattled(widget)) {
+ va_start(args, widget);
+ fmt = va_arg(args, char *);
+ for (i=0; i<n_tab; i++) printf(" ");
+ (void) vprintf(fmt, args);
+ va_end(args);
+ }
+}
+
+#endif /* XT_GEO_TATTLER */
+
diff --git a/nx-X11/lib/Xt/Intrinsic.h b/nx-X11/lib/Xt/Intrinsic.h
new file mode 100644
index 000000000..0461b842f
--- /dev/null
+++ b/nx-X11/lib/Xt/Intrinsic.h
@@ -0,0 +1,2589 @@
+/* $Xorg: Intrinsic.h,v 1.4 2001/02/09 02:03:55 xorgcvs Exp $ */
+
+/***********************************************************
+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 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, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/Intrinsic.h,v 3.8 2001/12/14 19:56:22 dawes Exp $ */
+
+#ifndef _XtIntrinsic_h
+#define _XtIntrinsic_h
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xresource.h>
+#include <X11/Xfuncproto.h>
+#ifdef XT_BC
+#include <X11/Xos.h> /* for R4 compatibility */
+#else
+#include <X11/Xosdefs.h>
+#include <string.h> /* for XtNewString */
+#endif /* XT_BC else */
+
+#define XtSpecificationRelease 6
+
+typedef char *String;
+
+/* We do this in order to get "const" declarations to work right. We
+ * use _XtString instead of String so that C++ applications can
+ * #define String to something else if they choose, to avoid conflicts
+ * with other C++ libraries.
+ */
+#define _XtString char*
+
+/* _Xt names are private to Xt implementation, do not use in client code */
+#if NeedWidePrototypes
+#define _XtBoolean int
+#define _XtDimension unsigned int
+#define _XtKeyCode unsigned int
+#define _XtPosition int
+#define _XtXtEnum unsigned int
+#else
+#define _XtBoolean Boolean
+#define _XtDimension Dimension
+#define _XtKeyCode KeyCode
+#define _XtPosition Position
+#define _XtXtEnum XtEnum
+#endif /* NeedWidePrototypes */
+
+#include <stddef.h>
+
+#ifdef VMS
+#define externalref globalref
+#define externaldef(psect) globaldef {"psect"} noshare
+#else
+#define externalref extern
+#define externaldef(psect)
+#endif /* VMS */
+
+#ifndef FALSE
+#define FALSE 0
+#define TRUE 1
+#endif
+
+#define XtNumber(arr) ((Cardinal) (sizeof(arr) / sizeof(arr[0])))
+
+typedef struct _WidgetRec *Widget;
+typedef Widget *WidgetList;
+typedef struct _WidgetClassRec *WidgetClass;
+typedef struct _CompositeRec *CompositeWidget;
+typedef struct _XtActionsRec *XtActionList;
+typedef struct _XtEventRec *XtEventTable;
+
+typedef struct _XtAppStruct *XtAppContext;
+typedef unsigned long XtValueMask;
+typedef unsigned long XtIntervalId;
+typedef unsigned long XtInputId;
+typedef unsigned long XtWorkProcId;
+typedef unsigned long XtSignalId;
+typedef unsigned int XtGeometryMask;
+typedef unsigned long XtGCMask; /* Mask of values that are used by widget*/
+typedef unsigned long Pixel; /* Index into colormap */
+typedef int XtCacheType;
+#define XtCacheNone 0x001
+#define XtCacheAll 0x002
+#define XtCacheByDisplay 0x003
+#define XtCacheRefCount 0x100
+
+/****************************************************************
+ *
+ * System Dependent Definitions; see spec for specific range
+ * requirements. Do not assume every implementation uses the
+ * same base types!
+ *
+ *
+ * XtArgVal ought to be a union of XtPointer, char *, long, int *, and proc *
+ * but casting to union types is not really supported.
+ *
+ * So the typedef for XtArgVal should be chosen such that
+ *
+ * sizeof (XtArgVal) >= sizeof(XtPointer)
+ * sizeof(char *)
+ * sizeof(long)
+ * sizeof(int *)
+ * sizeof(proc *)
+ *
+ * ArgLists rely heavily on the above typedef.
+ *
+ ****************************************************************/
+#ifdef CRAY
+typedef long Boolean;
+typedef char* XtArgVal;
+typedef long XtEnum;
+#else
+typedef char Boolean;
+typedef long XtArgVal;
+typedef unsigned char XtEnum;
+#endif
+
+typedef unsigned int Cardinal;
+typedef unsigned short Dimension; /* Size in pixels */
+typedef short Position; /* Offset from 0 coordinate */
+
+typedef void* XtPointer;
+
+/* The type Opaque is NOT part of the Xt standard, do NOT use it. */
+/* (It remains here only for backward compatibility.) */
+typedef XtPointer Opaque;
+
+#include <X11/Core.h>
+#include <X11/Composite.h>
+#include <X11/Constraint.h>
+#include <X11/Object.h>
+#include <X11/RectObj.h>
+
+typedef struct _TranslationData *XtTranslations;
+typedef struct _TranslationData *XtAccelerators;
+typedef unsigned int Modifiers;
+
+typedef void (*XtActionProc)(
+ Widget /* widget */,
+ XEvent* /* event */,
+ String* /* params */,
+ Cardinal* /* num_params */
+);
+
+typedef XtActionProc* XtBoundActions;
+
+typedef struct _XtActionsRec{
+ String string;
+ XtActionProc proc;
+} XtActionsRec;
+
+typedef enum {
+/* address mode parameter representation */
+/* ------------ ------------------------ */
+ XtAddress, /* address */
+ XtBaseOffset, /* offset */
+ XtImmediate, /* constant */
+ XtResourceString, /* resource name string */
+ XtResourceQuark, /* resource name quark */
+ XtWidgetBaseOffset, /* offset from ancestor */
+ XtProcedureArg /* procedure to invoke */
+} XtAddressMode;
+
+typedef struct {
+ XtAddressMode address_mode;
+ XtPointer address_id;
+ Cardinal size;
+} XtConvertArgRec, *XtConvertArgList;
+
+typedef void (*XtConvertArgProc)(
+ Widget /* widget */,
+ Cardinal* /* size */,
+ XrmValue* /* value */
+);
+
+typedef struct {
+ XtGeometryMask request_mode;
+ Position x, y;
+ Dimension width, height, border_width;
+ Widget sibling;
+ int stack_mode; /* Above, Below, TopIf, BottomIf, Opposite, DontChange */
+} XtWidgetGeometry;
+
+/* Additions to Xlib geometry requests: ask what would happen, don't do it */
+#define XtCWQueryOnly (1 << 7)
+
+/* Additions to Xlib stack modes: don't change stack order */
+#define XtSMDontChange 5
+
+typedef void (*XtConverter)( /* obsolete */
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValue* /* from */,
+ XrmValue* /* to */
+);
+
+typedef Boolean (*XtTypeConverter)(
+ Display* /* dpy */,
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValue* /* from */,
+ XrmValue* /* to */,
+ XtPointer* /* converter_data */
+);
+
+typedef void (*XtDestructor)(
+ XtAppContext /* app */,
+ XrmValue* /* to */,
+ XtPointer /* converter_data */,
+ XrmValue* /* args */,
+ Cardinal* /* num_args */
+);
+
+typedef Opaque XtCacheRef;
+
+typedef Opaque XtActionHookId;
+
+typedef void (*XtActionHookProc)(
+ Widget /* w */,
+ XtPointer /* client_data */,
+ String /* action_name */,
+ XEvent* /* event */,
+ String* /* params */,
+ Cardinal* /* num_params */
+);
+
+typedef unsigned long XtBlockHookId;
+
+typedef void (*XtBlockHookProc)(
+ XtPointer /* client_data */
+);
+
+typedef void (*XtKeyProc)(
+ Display* /* dpy */,
+ _XtKeyCode /* keycode */,
+ Modifiers /* modifiers */,
+ Modifiers* /* modifiers_return */,
+ KeySym* /* keysym_return */
+);
+
+typedef void (*XtCaseProc)(
+ Display* /* display */,
+ KeySym /* keysym */,
+ KeySym* /* lower_return */,
+ KeySym* /* upper_return */
+);
+
+typedef void (*XtEventHandler)(
+ Widget /* widget */,
+ XtPointer /* closure */,
+ XEvent* /* event */,
+ Boolean* /* continue_to_dispatch */
+);
+typedef unsigned long EventMask;
+
+typedef enum {XtListHead, XtListTail } XtListPosition;
+
+typedef unsigned long XtInputMask;
+#define XtInputNoneMask 0L
+#define XtInputReadMask (1L<<0)
+#define XtInputWriteMask (1L<<1)
+#define XtInputExceptMask (1L<<2)
+
+typedef void (*XtTimerCallbackProc)(
+ XtPointer /* closure */,
+ XtIntervalId* /* id */
+);
+
+typedef void (*XtInputCallbackProc)(
+ XtPointer /* closure */,
+ int* /* source */,
+ XtInputId* /* id */
+);
+
+typedef void (*XtSignalCallbackProc)(
+ XtPointer /* closure */,
+ XtSignalId* /* id */
+);
+
+typedef struct {
+ String name;
+ XtArgVal value;
+} Arg, *ArgList;
+
+typedef XtPointer XtVarArgsList;
+
+typedef void (*XtCallbackProc)(
+ Widget /* widget */,
+ XtPointer /* closure */, /* data the application registered */
+ XtPointer /* call_data */ /* callback specific data */
+);
+
+typedef struct _XtCallbackRec {
+ XtCallbackProc callback;
+ XtPointer closure;
+} XtCallbackRec, *XtCallbackList;
+
+typedef enum {
+ XtCallbackNoList,
+ XtCallbackHasNone,
+ XtCallbackHasSome
+} XtCallbackStatus;
+
+typedef enum {
+ XtGeometryYes, /* Request accepted. */
+ XtGeometryNo, /* Request denied. */
+ XtGeometryAlmost, /* Request denied, but willing to take replyBox. */
+ XtGeometryDone /* Request accepted and done. */
+} XtGeometryResult;
+
+typedef enum {XtGrabNone, XtGrabNonexclusive, XtGrabExclusive} XtGrabKind;
+
+typedef struct {
+ Widget shell_widget;
+ Widget enable_widget;
+} XtPopdownIDRec, *XtPopdownID;
+
+typedef struct _XtResource {
+ String resource_name; /* Resource name */
+ String resource_class; /* Resource class */
+ String resource_type; /* Representation type desired */
+ Cardinal resource_size; /* Size in bytes of representation */
+ Cardinal resource_offset;/* Offset from base to put resource value */
+ String default_type; /* representation type of specified default */
+ XtPointer default_addr; /* Address of default resource */
+} XtResource, *XtResourceList;
+
+typedef void (*XtResourceDefaultProc)(
+ Widget /* widget */,
+ int /* offset */,
+ XrmValue* /* value */
+);
+
+typedef String (*XtLanguageProc)(
+ Display* /* dpy */,
+ String /* xnl */,
+ XtPointer /* client_data */
+);
+
+typedef void (*XtErrorMsgHandler)(
+ String /* name */,
+ String /* type */,
+ String /* class */,
+ String /* default */,
+ String* /* params */,
+ Cardinal* /* num_params */
+);
+
+typedef void (*XtErrorHandler)(
+ String /* msg */
+);
+
+typedef void (*XtCreatePopupChildProc)(
+ Widget /* shell */
+);
+
+typedef Boolean (*XtWorkProc)(
+ XtPointer /* closure */ /* data the application registered */
+);
+
+typedef struct {
+ char match;
+ String substitution;
+} SubstitutionRec, *Substitution;
+
+typedef Boolean (*XtFilePredicate)(
+ String /* filename */
+);
+
+typedef XtPointer XtRequestId;
+
+typedef Boolean (*XtConvertSelectionProc)(
+ Widget /* widget */,
+ Atom* /* selection */,
+ Atom* /* target */,
+ Atom* /* type_return */,
+ XtPointer* /* value_return */,
+ unsigned long* /* length_return */,
+ int* /* format_return */
+);
+
+typedef void (*XtLoseSelectionProc)(
+ Widget /* widget */,
+ Atom* /* selection */
+);
+
+typedef void (*XtSelectionDoneProc)(
+ Widget /* widget */,
+ Atom* /* selection */,
+ Atom* /* target */
+);
+
+typedef void (*XtSelectionCallbackProc)(
+ Widget /* widget */,
+ XtPointer /* closure */,
+ Atom* /* selection */,
+ Atom* /* type */,
+ XtPointer /* value */,
+ unsigned long* /* length */,
+ int* /* format */
+);
+
+typedef void (*XtLoseSelectionIncrProc)(
+ Widget /* widget */,
+ Atom* /* selection */,
+ XtPointer /* client_data */
+);
+
+typedef void (*XtSelectionDoneIncrProc)(
+ Widget /* widget */,
+ Atom* /* selection */,
+ Atom* /* target */,
+ XtRequestId* /* receiver_id */,
+ XtPointer /* client_data */
+);
+
+typedef Boolean (*XtConvertSelectionIncrProc)(
+ Widget /* widget */,
+ Atom* /* selection */,
+ Atom* /* target */,
+ Atom* /* type */,
+ XtPointer* /* value */,
+ unsigned long* /* length */,
+ int* /* format */,
+ unsigned long* /* max_length */,
+ XtPointer /* client_data */,
+ XtRequestId* /* receiver_id */
+);
+
+typedef void (*XtCancelConvertSelectionProc)(
+ Widget /* widget */,
+ Atom* /* selection */,
+ Atom* /* target */,
+ XtRequestId* /* receiver_id */,
+ XtPointer /* client_data */
+);
+
+typedef Boolean (*XtEventDispatchProc)(
+ XEvent* /* event */
+);
+
+typedef void (*XtExtensionSelectProc)(
+ Widget /* widget */,
+ int* /* event_types */,
+ XtPointer* /* select_data */,
+ int /* count */,
+ XtPointer /* client_data */
+);
+
+/***************************************************************
+ *
+ * Exported Interfaces
+ *
+ ****************************************************************/
+
+_XFUNCPROTOBEGIN
+
+extern Boolean XtConvertAndStore(
+ Widget /* widget */,
+ _Xconst _XtString /* from_type */,
+ XrmValue* /* from */,
+ _Xconst _XtString /* to_type */,
+ XrmValue* /* to_in_out */
+);
+
+extern Boolean XtCallConverter(
+ Display* /* dpy */,
+ XtTypeConverter /* converter */,
+ XrmValuePtr /* args */,
+ Cardinal /* num_args */,
+ XrmValuePtr /* from */,
+ XrmValue* /* to_in_out */,
+ XtCacheRef* /* cache_ref_return */
+);
+
+extern Boolean XtDispatchEvent(
+ XEvent* /* event */
+);
+
+extern Boolean XtCallAcceptFocus(
+ Widget /* widget */,
+ Time* /* time */
+);
+
+extern Boolean XtPeekEvent( /* obsolete */
+ XEvent* /* event_return */
+);
+
+extern Boolean XtAppPeekEvent(
+ XtAppContext /* app_context */,
+ XEvent* /* event_return */
+);
+
+extern Boolean XtIsSubclass(
+ Widget /* widget */,
+ WidgetClass /* widgetClass */
+);
+
+extern Boolean XtIsObject(
+ Widget /* object */
+);
+
+extern Boolean _XtCheckSubclassFlag( /* implementation-private */
+ Widget /* object */,
+ _XtXtEnum /* type_flag */
+);
+
+extern Boolean _XtIsSubclassOf( /* implementation-private */
+ Widget /* object */,
+ WidgetClass /* widget_class */,
+ WidgetClass /* flag_class */,
+ _XtXtEnum /* type_flag */
+);
+
+extern Boolean XtIsManaged(
+ Widget /* rectobj */
+);
+
+extern Boolean XtIsRealized(
+ Widget /* widget */
+);
+
+extern Boolean XtIsSensitive(
+ Widget /* widget */
+);
+
+extern Boolean XtOwnSelection(
+ Widget /* widget */,
+ Atom /* selection */,
+ Time /* time */,
+ XtConvertSelectionProc /* convert */,
+ XtLoseSelectionProc /* lose */,
+ XtSelectionDoneProc /* done */
+);
+
+extern Boolean XtOwnSelectionIncremental(
+ Widget /* widget */,
+ Atom /* selection */,
+ Time /* time */,
+ XtConvertSelectionIncrProc /* convert_callback */,
+ XtLoseSelectionIncrProc /* lose_callback */,
+ XtSelectionDoneIncrProc /* done_callback */,
+ XtCancelConvertSelectionProc /* cancel_callback */,
+ XtPointer /* client_data */
+);
+
+extern XtGeometryResult XtMakeResizeRequest(
+ Widget /* widget */,
+ _XtDimension /* width */,
+ _XtDimension /* height */,
+ Dimension* /* width_return */,
+ Dimension* /* height_return */
+);
+
+extern void XtTranslateCoords(
+ Widget /* widget */,
+ _XtPosition /* x */,
+ _XtPosition /* y */,
+ Position* /* rootx_return */,
+ Position* /* rooty_return */
+);
+
+extern KeySym* XtGetKeysymTable(
+ Display* /* dpy */,
+ KeyCode* /* min_keycode_return */,
+ int* /* keysyms_per_keycode_return */
+);
+
+extern void XtKeysymToKeycodeList(
+ Display* /* dpy */,
+ KeySym /* keysym */,
+ KeyCode** /* keycodes_return */,
+ Cardinal* /* keycount_return */
+);
+
+extern void XtStringConversionWarning( /* obsolete */
+ _Xconst _XtString /* from_value */,
+ _Xconst _XtString /* to_type */
+);
+
+extern void XtDisplayStringConversionWarning(
+ Display* /* dpy */,
+ _Xconst _XtString /* from_value */,
+ _Xconst _XtString /* to_type */
+);
+
+externalref XtConvertArgRec const colorConvertArgs[];
+externalref XtConvertArgRec const screenConvertArg[];
+
+extern void XtAppAddConverter( /* obsolete */
+ XtAppContext /* app_context */,
+ _Xconst _XtString /* from_type */,
+ _Xconst _XtString /* to_type */,
+ XtConverter /* converter */,
+ XtConvertArgList /* convert_args */,
+ Cardinal /* num_args */
+);
+
+extern void XtAddConverter( /* obsolete */
+ _Xconst _XtString /* from_type */,
+ _Xconst _XtString /* to_type */,
+ XtConverter /* converter */,
+ XtConvertArgList /* convert_args */,
+ Cardinal /* num_args */
+);
+
+extern void XtSetTypeConverter(
+ _Xconst _XtString /* from_type */,
+ _Xconst _XtString /* to_type */,
+ XtTypeConverter /* converter */,
+ XtConvertArgList /* convert_args */,
+ Cardinal /* num_args */,
+ XtCacheType /* cache_type */,
+ XtDestructor /* destructor */
+);
+
+extern void XtAppSetTypeConverter(
+ XtAppContext /* app_context */,
+ _Xconst _XtString /* from_type */,
+ _Xconst _XtString /* to_type */,
+ XtTypeConverter /* converter */,
+ XtConvertArgList /* convert_args */,
+ Cardinal /* num_args */,
+ XtCacheType /* cache_type */,
+ XtDestructor /* destructor */
+);
+
+extern void XtConvert( /* obsolete */
+ Widget /* widget */,
+ _Xconst _XtString /* from_type */,
+ XrmValue* /* from */,
+ _Xconst _XtString /* to_type */,
+ XrmValue* /* to_return */
+);
+
+extern void XtDirectConvert( /* obsolete */
+ XtConverter /* converter */,
+ XrmValuePtr /* args */,
+ Cardinal /* num_args */,
+ XrmValuePtr /* from */,
+ XrmValue* /* to_return */
+);
+
+/****************************************************************
+ *
+ * Translation Management
+ *
+ ****************************************************************/
+
+extern XtTranslations XtParseTranslationTable(
+ _Xconst _XtString /* table */
+);
+
+extern XtAccelerators XtParseAcceleratorTable(
+ _Xconst _XtString /* source */
+);
+
+extern void XtOverrideTranslations(
+ Widget /* widget */,
+ XtTranslations /* translations */
+);
+
+extern void XtAugmentTranslations(
+ Widget /* widget */,
+ XtTranslations /* translations */
+);
+
+extern void XtInstallAccelerators(
+ Widget /* destination */,
+ Widget /* source */
+);
+
+extern void XtInstallAllAccelerators(
+ Widget /* destination */,
+ Widget /* source */
+);
+
+extern void XtUninstallTranslations(
+ Widget /* widget */
+);
+
+extern void XtAppAddActions(
+ XtAppContext /* app_context */,
+ XtActionList /* actions */,
+ Cardinal /* num_actions */
+);
+
+extern void XtAddActions( /* obsolete */
+ XtActionList /* actions */,
+ Cardinal /* num_actions */
+);
+
+extern XtActionHookId XtAppAddActionHook(
+ XtAppContext /* app_context */,
+ XtActionHookProc /* proc */,
+ XtPointer /* client_data */
+);
+
+extern void XtRemoveActionHook(
+ XtActionHookId /* id */
+);
+
+extern void XtGetActionList(
+ WidgetClass /* widget_class */,
+ XtActionList* /* actions_return */,
+ Cardinal* /* num_actions_return */
+);
+
+extern void XtCallActionProc(
+ Widget /* widget */,
+ _Xconst _XtString /* action */,
+ XEvent* /* event */,
+ String* /* params */,
+ Cardinal /* num_params */
+);
+
+extern void XtRegisterGrabAction(
+ XtActionProc /* action_proc */,
+ _XtBoolean /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */
+);
+
+extern void XtSetMultiClickTime(
+ Display* /* dpy */,
+ int /* milliseconds */
+);
+
+extern int XtGetMultiClickTime(
+ Display* /* dpy */
+);
+
+extern KeySym XtGetActionKeysym(
+ XEvent* /* event */,
+ Modifiers* /* modifiers_return */
+);
+
+/***************************************************************
+ *
+ * Keycode and Keysym procedures for translation management
+ *
+ ****************************************************************/
+
+extern void XtTranslateKeycode(
+ Display* /* dpy */,
+ _XtKeyCode /* keycode */,
+ Modifiers /* modifiers */,
+ Modifiers* /* modifiers_return */,
+ KeySym* /* keysym_return */
+);
+
+extern void XtTranslateKey(
+ Display* /* dpy */,
+ _XtKeyCode /* keycode */,
+ Modifiers /* modifiers */,
+ Modifiers* /* modifiers_return */,
+ KeySym* /* keysym_return */
+);
+
+extern void XtSetKeyTranslator(
+ Display* /* dpy */,
+ XtKeyProc /* proc */
+);
+
+extern void XtRegisterCaseConverter(
+ Display* /* dpy */,
+ XtCaseProc /* proc */,
+ KeySym /* start */,
+ KeySym /* stop */
+);
+
+extern void XtConvertCase(
+ Display* /* dpy */,
+ KeySym /* keysym */,
+ KeySym* /* lower_return */,
+ KeySym* /* upper_return */
+);
+
+/****************************************************************
+ *
+ * Event Management
+ *
+ ****************************************************************/
+
+/* XtAllEvents is valid only for XtRemoveEventHandler and
+ * XtRemoveRawEventHandler; don't use it to select events!
+ */
+#define XtAllEvents ((EventMask) -1L)
+
+extern void XtAddEventHandler(
+ Widget /* widget */,
+ EventMask /* event_mask */,
+ _XtBoolean /* nonmaskable */,
+ XtEventHandler /* proc */,
+ XtPointer /* closure */
+);
+
+extern void XtRemoveEventHandler(
+ Widget /* widget */,
+ EventMask /* event_mask */,
+ _XtBoolean /* nonmaskable */,
+ XtEventHandler /* proc */,
+ XtPointer /* closure */
+);
+
+extern void XtAddRawEventHandler(
+ Widget /* widget */,
+ EventMask /* event_mask */,
+ _XtBoolean /* nonmaskable */,
+ XtEventHandler /* proc */,
+ XtPointer /* closure */
+);
+
+extern void XtRemoveRawEventHandler(
+ Widget /* widget */,
+ EventMask /* event_mask */,
+ _XtBoolean /* nonmaskable */,
+ XtEventHandler /* proc */,
+ XtPointer /* closure */
+);
+
+extern void XtInsertEventHandler(
+ Widget /* widget */,
+ EventMask /* event_mask */,
+ _XtBoolean /* nonmaskable */,
+ XtEventHandler /* proc */,
+ XtPointer /* closure */,
+ XtListPosition /* position */
+);
+
+extern void XtInsertRawEventHandler(
+ Widget /* widget */,
+ EventMask /* event_mask */,
+ _XtBoolean /* nonmaskable */,
+ XtEventHandler /* proc */,
+ XtPointer /* closure */,
+ XtListPosition /* position */
+);
+
+extern XtEventDispatchProc XtSetEventDispatcher(
+ Display* /* dpy */,
+ int /* event_type */,
+ XtEventDispatchProc /* proc */
+);
+
+extern Boolean XtDispatchEventToWidget(
+ Widget /* widget */,
+ XEvent* /* event */
+);
+
+extern void XtInsertEventTypeHandler(
+ Widget /* widget */,
+ int /* type */,
+ XtPointer /* select_data */,
+ XtEventHandler /* proc */,
+ XtPointer /* closure */,
+ XtListPosition /* position */
+);
+
+extern void XtRemoveEventTypeHandler(
+ Widget /* widget */,
+ int /* type */,
+ XtPointer /* select_data */,
+ XtEventHandler /* proc */,
+ XtPointer /* closure */
+);
+
+extern EventMask XtBuildEventMask(
+ Widget /* widget */
+);
+
+extern void XtRegisterExtensionSelector(
+ Display* /* dpy */,
+ int /* min_event_type */,
+ int /* max_event_type */,
+ XtExtensionSelectProc /* proc */,
+ XtPointer /* client_data */
+);
+
+extern void XtAddGrab(
+ Widget /* widget */,
+ _XtBoolean /* exclusive */,
+ _XtBoolean /* spring_loaded */
+);
+
+extern void XtRemoveGrab(
+ Widget /* widget */
+);
+
+extern void XtProcessEvent( /* obsolete */
+ XtInputMask /* mask */
+);
+
+extern void XtAppProcessEvent(
+ XtAppContext /* app_context */,
+ XtInputMask /* mask */
+);
+
+extern void XtMainLoop( /* obsolete */
+ void
+);
+
+extern void XtAppMainLoop(
+ XtAppContext /* app_context */
+);
+
+extern void XtAddExposureToRegion(
+ XEvent* /* event */,
+ Region /* region */
+);
+
+extern void XtSetKeyboardFocus(
+ Widget /* subtree */,
+ Widget /* descendent */
+);
+
+extern Widget XtGetKeyboardFocusWidget(
+ Widget /* widget */
+);
+
+extern XEvent* XtLastEventProcessed(
+ Display* /* dpy */
+);
+
+extern Time XtLastTimestampProcessed(
+ Display* /* dpy */
+);
+
+/****************************************************************
+ *
+ * Event Gathering Routines
+ *
+ ****************************************************************/
+
+extern XtIntervalId XtAddTimeOut( /* obsolete */
+ unsigned long /* interval */,
+ XtTimerCallbackProc /* proc */,
+ XtPointer /* closure */
+);
+
+extern XtIntervalId XtAppAddTimeOut(
+ XtAppContext /* app_context */,
+ unsigned long /* interval */,
+ XtTimerCallbackProc /* proc */,
+ XtPointer /* closure */
+);
+
+extern void XtRemoveTimeOut(
+ XtIntervalId /* timer */
+);
+
+extern XtInputId XtAddInput( /* obsolete */
+ int /* source */,
+ XtPointer /* condition */,
+ XtInputCallbackProc /* proc */,
+ XtPointer /* closure */
+);
+
+extern XtInputId XtAppAddInput(
+ XtAppContext /* app_context */,
+ int /* source */,
+ XtPointer /* condition */,
+ XtInputCallbackProc /* proc */,
+ XtPointer /* closure */
+);
+
+extern void XtRemoveInput(
+ XtInputId /* id */
+);
+
+extern XtSignalId XtAddSignal(
+ XtSignalCallbackProc /* proc */,
+ XtPointer /* closure */);
+
+extern XtSignalId XtAppAddSignal(
+ XtAppContext /* app_context */,
+ XtSignalCallbackProc /* proc */,
+ XtPointer /* closure */
+);
+
+extern void XtRemoveSignal(
+ XtSignalId /* id */
+);
+
+extern void XtNoticeSignal(
+ XtSignalId /* id */
+);
+
+extern void XtNextEvent( /* obsolete */
+ XEvent* /* event */
+);
+
+extern void XtAppNextEvent(
+ XtAppContext /* app_context */,
+ XEvent* /* event_return */
+);
+
+#define XtIMXEvent 1
+#define XtIMTimer 2
+#define XtIMAlternateInput 4
+#define XtIMSignal 8
+#define XtIMAll (XtIMXEvent | XtIMTimer | XtIMAlternateInput | XtIMSignal)
+
+extern Boolean XtPending( /* obsolete */
+ void
+);
+
+extern XtInputMask XtAppPending(
+ XtAppContext /* app_context */
+);
+
+extern XtBlockHookId XtAppAddBlockHook(
+ XtAppContext /* app_context */,
+ XtBlockHookProc /* proc */,
+ XtPointer /* client_data */
+);
+
+extern void XtRemoveBlockHook(
+ XtBlockHookId /* id */
+);
+
+/****************************************************************
+ *
+ * Random utility routines
+ *
+ ****************************************************************/
+
+#define XtIsRectObj(object) (_XtCheckSubclassFlag(object, (XtEnum)0x02))
+#define XtIsWidget(object) (_XtCheckSubclassFlag(object, (XtEnum)0x04))
+#define XtIsComposite(widget) (_XtCheckSubclassFlag(widget, (XtEnum)0x08))
+#define XtIsConstraint(widget) (_XtCheckSubclassFlag(widget, (XtEnum)0x10))
+#define XtIsShell(widget) (_XtCheckSubclassFlag(widget, (XtEnum)0x20))
+
+#undef XtIsOverrideShell
+extern Boolean XtIsOverrideShell(Widget /* object */);
+#define XtIsOverrideShell(widget) \
+ (_XtIsSubclassOf(widget, (WidgetClass)overrideShellWidgetClass, \
+ (WidgetClass)shellWidgetClass, (XtEnum)0x20))
+
+#define XtIsWMShell(widget) (_XtCheckSubclassFlag(widget, (XtEnum)0x40))
+
+#undef XtIsVendorShell
+extern Boolean XtIsVendorShell(Widget /* object */);
+#define XtIsVendorShell(widget) \
+ (_XtIsSubclassOf(widget, (WidgetClass)vendorShellWidgetClass, \
+ (WidgetClass)wmShellWidgetClass, (XtEnum)0x40))
+
+#undef XtIsTransientShell
+extern Boolean XtIsTransientShell(Widget /* object */);
+#define XtIsTransientShell(widget) \
+ (_XtIsSubclassOf(widget, (WidgetClass)transientShellWidgetClass, \
+ (WidgetClass)wmShellWidgetClass, (XtEnum)0x40))
+#define XtIsTopLevelShell(widget) (_XtCheckSubclassFlag(widget, (XtEnum)0x80))
+
+#undef XtIsApplicationShell
+extern Boolean XtIsApplicationShell(Widget /* object */);
+#define XtIsApplicationShell(widget) \
+ (_XtIsSubclassOf(widget, (WidgetClass)applicationShellWidgetClass, \
+ (WidgetClass)topLevelShellWidgetClass, (XtEnum)0x80))
+
+#undef XtIsSessionShell
+extern Boolean XtIsSessionShell(Widget /* object */);
+#define XtIsSessionShell(widget) \
+ (_XtIsSubclassOf(widget, (WidgetClass)sessionShellWidgetClass, \
+ (WidgetClass)topLevelShellWidgetClass, (XtEnum)0x80))
+
+extern void XtRealizeWidget(
+ Widget /* widget */
+);
+
+void XtUnrealizeWidget(
+ Widget /* widget */
+);
+
+extern void XtDestroyWidget(
+ Widget /* widget */
+);
+
+extern void XtSetSensitive(
+ Widget /* widget */,
+ _XtBoolean /* sensitive */
+);
+
+extern void XtSetMappedWhenManaged(
+ Widget /* widget */,
+ _XtBoolean /* mapped_when_managed */
+);
+
+extern Widget XtNameToWidget(
+ Widget /* reference */,
+ _Xconst _XtString /* names */
+);
+
+extern Widget XtWindowToWidget(
+ Display* /* display */,
+ Window /* window */
+);
+
+extern XtPointer XtGetClassExtension(
+ WidgetClass /* object_class */,
+ Cardinal /* byte_offset */,
+ XrmQuark /* type */,
+ long /* version */,
+ Cardinal /* record_size */
+);
+
+/***************************************************************
+ *
+ * Arg lists
+ *
+ ****************************************************************/
+
+
+#define XtSetArg(arg, n, d) \
+ ((void)( (arg).name = (n), (arg).value = (XtArgVal)(d) ))
+
+extern ArgList XtMergeArgLists(
+ ArgList /* args1 */,
+ Cardinal /* num_args1 */,
+ ArgList /* args2 */,
+ Cardinal /* num_args2 */
+);
+
+/***************************************************************
+ *
+ * Vararg lists
+ *
+ ****************************************************************/
+
+#define XtVaNestedList "XtVaNestedList"
+#define XtVaTypedArg "XtVaTypedArg"
+
+extern XtVarArgsList XtVaCreateArgsList(
+ XtPointer /*unused*/, ...
+) _X_SENTINEL(0);
+
+/*************************************************************
+ *
+ * Information routines
+ *
+ ************************************************************/
+
+#ifndef _XtIntrinsicP_h
+
+/* We're not included from the private file, so define these */
+
+extern Display *XtDisplay(
+ Widget /* widget */
+);
+
+extern Display *XtDisplayOfObject(
+ Widget /* object */
+);
+
+extern Screen *XtScreen(
+ Widget /* widget */
+);
+
+extern Screen *XtScreenOfObject(
+ Widget /* object */
+);
+
+extern Window XtWindow(
+ Widget /* widget */
+);
+
+extern Window XtWindowOfObject(
+ Widget /* object */
+);
+
+extern String XtName(
+ Widget /* object */
+);
+
+extern WidgetClass XtSuperclass(
+ Widget /* object */
+);
+
+extern WidgetClass XtClass(
+ Widget /* object */
+);
+
+extern Widget XtParent(
+ Widget /* widget */
+);
+
+#endif /*_XtIntrinsicP_h*/
+
+#undef XtMapWidget
+extern void XtMapWidget(Widget /* w */);
+#define XtMapWidget(widget) XMapWindow(XtDisplay(widget), XtWindow(widget))
+
+#undef XtUnmapWidget
+extern void XtUnmapWidget(Widget /* w */);
+#define XtUnmapWidget(widget) \
+ XUnmapWindow(XtDisplay(widget), XtWindow(widget))
+
+extern void XtAddCallback(
+ Widget /* widget */,
+ _Xconst _XtString /* callback_name */,
+ XtCallbackProc /* callback */,
+ XtPointer /* closure */
+);
+
+extern void XtRemoveCallback(
+ Widget /* widget */,
+ _Xconst _XtString /* callback_name */,
+ XtCallbackProc /* callback */,
+ XtPointer /* closure */
+);
+
+extern void XtAddCallbacks(
+ Widget /* widget */,
+ _Xconst _XtString /* callback_name */,
+ XtCallbackList /* callbacks */
+);
+
+extern void XtRemoveCallbacks(
+ Widget /* widget */,
+ _Xconst _XtString /* callback_name */,
+ XtCallbackList /* callbacks */
+);
+
+extern void XtRemoveAllCallbacks(
+ Widget /* widget */,
+ _Xconst _XtString /* callback_name */
+);
+
+
+extern void XtCallCallbacks(
+ Widget /* widget */,
+ _Xconst _XtString /* callback_name */,
+ XtPointer /* call_data */
+);
+
+extern void XtCallCallbackList(
+ Widget /* widget */,
+ XtCallbackList /* callbacks */,
+ XtPointer /* call_data */
+);
+
+extern XtCallbackStatus XtHasCallbacks(
+ Widget /* widget */,
+ _Xconst _XtString /* callback_name */
+);
+
+/****************************************************************
+ *
+ * Geometry Management
+ *
+ ****************************************************************/
+
+
+extern XtGeometryResult XtMakeGeometryRequest(
+ Widget /* widget */,
+ XtWidgetGeometry* /* request */,
+ XtWidgetGeometry* /* reply_return */
+);
+
+extern XtGeometryResult XtQueryGeometry(
+ Widget /* widget */,
+ XtWidgetGeometry* /* intended */,
+ XtWidgetGeometry* /* preferred_return */
+);
+
+extern Widget XtCreatePopupShell(
+ _Xconst _XtString /* name */,
+ WidgetClass /* widgetClass */,
+ Widget /* parent */,
+ ArgList /* args */,
+ Cardinal /* num_args */
+);
+
+extern Widget XtVaCreatePopupShell(
+ _Xconst _XtString /* name */,
+ WidgetClass /* widgetClass */,
+ Widget /* parent */,
+ ...
+) _X_SENTINEL(0);
+
+extern void XtPopup(
+ Widget /* popup_shell */,
+ XtGrabKind /* grab_kind */
+);
+
+extern void XtPopupSpringLoaded(
+ Widget /* popup_shell */
+);
+
+extern void XtCallbackNone(
+ Widget /* widget */,
+ XtPointer /* closure */,
+ XtPointer /* call_data */
+);
+
+extern void XtCallbackNonexclusive(
+ Widget /* widget */,
+ XtPointer /* closure */,
+ XtPointer /* call_data */
+);
+
+extern void XtCallbackExclusive(
+ Widget /* widget */,
+ XtPointer /* closure */,
+ XtPointer /* call_data */
+);
+
+extern void XtPopdown(
+ Widget /* popup_shell */
+);
+
+extern void XtCallbackPopdown(
+ Widget /* widget */,
+ XtPointer /* closure */,
+ XtPointer /* call_data */
+);
+
+extern void XtMenuPopupAction(
+ Widget /* widget */,
+ XEvent* /* event */,
+ String* /* params */,
+ Cardinal* /* num_params */
+);
+
+extern Widget XtCreateWidget(
+ _Xconst _XtString /* name */,
+ WidgetClass /* widget_class */,
+ Widget /* parent */,
+ ArgList /* args */,
+ Cardinal /* num_args */
+);
+
+extern Widget XtCreateManagedWidget(
+ _Xconst _XtString /* name */,
+ WidgetClass /* widget_class */,
+ Widget /* parent */,
+ ArgList /* args */,
+ Cardinal /* num_args */
+);
+
+extern Widget XtVaCreateWidget(
+ _Xconst _XtString /* name */,
+ WidgetClass /* widget */,
+ Widget /* parent */,
+ ...
+) _X_SENTINEL(0);
+
+extern Widget XtVaCreateManagedWidget(
+ _Xconst _XtString /* name */,
+ WidgetClass /* widget_class */,
+ Widget /* parent */,
+ ...
+) _X_SENTINEL(0);
+
+extern Widget XtCreateApplicationShell( /* obsolete */
+ _Xconst _XtString /* name */,
+ WidgetClass /* widget_class */,
+ ArgList /* args */,
+ Cardinal /* num_args */
+);
+
+extern Widget XtAppCreateShell(
+ _Xconst _XtString /* application_name */,
+ _Xconst _XtString /* application_class */,
+ WidgetClass /* widget_class */,
+ Display* /* display */,
+ ArgList /* args */,
+ Cardinal /* num_args */
+);
+
+extern Widget XtVaAppCreateShell(
+ _Xconst _XtString /* application_name */,
+ _Xconst _XtString /* application_class */,
+ WidgetClass /* widget_class */,
+ Display* /* display */,
+ ...
+) _X_SENTINEL(0);
+
+/****************************************************************
+ *
+ * Toolkit initialization
+ *
+ ****************************************************************/
+
+extern void XtToolkitInitialize(
+ void
+);
+
+extern XtLanguageProc XtSetLanguageProc(
+ XtAppContext /* app_context */,
+ XtLanguageProc /* proc */,
+ XtPointer /* client_data */
+);
+
+extern void XtDisplayInitialize(
+ XtAppContext /* app_context */,
+ Display* /* dpy */,
+ _Xconst _XtString /* application_name */,
+ _Xconst _XtString /* application_class */,
+ XrmOptionDescRec* /* options */,
+ Cardinal /* num_options */,
+ int* /* argc */,
+ char** /* argv */
+);
+
+extern Widget XtOpenApplication(
+ XtAppContext* /* app_context_return */,
+ _Xconst _XtString /* application_class */,
+ XrmOptionDescList /* options */,
+ Cardinal /* num_options */,
+ int* /* argc_in_out */,
+ String* /* argv_in_out */,
+ String* /* fallback_resources */,
+ WidgetClass /* widget_class */,
+ ArgList /* args */,
+ Cardinal /* num_args */
+);
+
+extern Widget XtVaOpenApplication(
+ XtAppContext* /* app_context_return */,
+ _Xconst _XtString /* application_class */,
+ XrmOptionDescList /* options */,
+ Cardinal /* num_options */,
+ int* /* argc_in_out */,
+ String* /* argv_in_out */,
+ String* /* fallback_resources */,
+ WidgetClass /* widget_class */,
+ ...
+) _X_SENTINEL(0);
+
+extern Widget XtAppInitialize( /* obsolete */
+ XtAppContext* /* app_context_return */,
+ _Xconst _XtString /* application_class */,
+ XrmOptionDescList /* options */,
+ Cardinal /* num_options */,
+ int* /* argc_in_out */,
+ String* /* argv_in_out */,
+ String* /* fallback_resources */,
+ ArgList /* args */,
+ Cardinal /* num_args */
+);
+
+extern Widget XtVaAppInitialize( /* obsolete */
+ XtAppContext* /* app_context_return */,
+ _Xconst _XtString /* application_class */,
+ XrmOptionDescList /* options */,
+ Cardinal /* num_options */,
+ int* /* argc_in_out */,
+ String* /* argv_in_out */,
+ String* /* fallback_resources */,
+ ...
+) _X_SENTINEL(0);
+
+extern Widget XtInitialize( /* obsolete */
+ _Xconst _XtString /* shell_name */,
+ _Xconst _XtString /* application_class */,
+ XrmOptionDescRec* /* options */,
+ Cardinal /* num_options */,
+ int* /* argc */,
+ char** /* argv */
+);
+
+extern Display *XtOpenDisplay(
+ XtAppContext /* app_context */,
+ _Xconst _XtString /* display_string */,
+ _Xconst _XtString /* application_name */,
+ _Xconst _XtString /* application_class */,
+ XrmOptionDescRec* /* options */,
+ Cardinal /* num_options */,
+ int* /* argc */,
+ char** /* argv */
+);
+
+extern XtAppContext XtCreateApplicationContext(
+ void
+);
+
+extern void XtAppSetFallbackResources(
+ XtAppContext /* app_context */,
+ String* /* specification_list */
+);
+
+extern void XtDestroyApplicationContext(
+ XtAppContext /* app_context */
+);
+
+extern void XtInitializeWidgetClass(
+ WidgetClass /* widget_class */
+);
+
+extern XtAppContext XtWidgetToApplicationContext(
+ Widget /* widget */
+);
+
+extern XtAppContext XtDisplayToApplicationContext(
+ Display* /* dpy */
+);
+
+extern XrmDatabase XtDatabase(
+ Display* /* dpy */
+);
+
+extern XrmDatabase XtScreenDatabase(
+ Screen* /* screen */
+);
+
+extern void XtCloseDisplay(
+ Display* /* dpy */
+);
+
+extern void XtGetApplicationResources(
+ Widget /* widget */,
+ XtPointer /* base */,
+ XtResourceList /* resources */,
+ Cardinal /* num_resources */,
+ ArgList /* args */,
+ Cardinal /* num_args */
+);
+
+extern void XtVaGetApplicationResources(
+ Widget /* widget */,
+ XtPointer /* base */,
+ XtResourceList /* resources */,
+ Cardinal /* num_resources */,
+ ...
+) _X_SENTINEL(0);
+
+extern void XtGetSubresources(
+ Widget /* widget */,
+ XtPointer /* base */,
+ _Xconst _XtString /* name */,
+ _Xconst _XtString /* class */,
+ XtResourceList /* resources */,
+ Cardinal /* num_resources */,
+ ArgList /* args */,
+ Cardinal /* num_args */
+);
+
+extern void XtVaGetSubresources(
+ Widget /* widget */,
+ XtPointer /* base */,
+ _Xconst _XtString /* name */,
+ _Xconst _XtString /* class */,
+ XtResourceList /* resources */,
+ Cardinal /* num_resources */,
+ ...
+) _X_SENTINEL(0);
+
+extern void XtSetValues(
+ Widget /* widget */,
+ ArgList /* args */,
+ Cardinal /* num_args */
+);
+
+extern void XtVaSetValues(
+ Widget /* widget */,
+ ...
+) _X_SENTINEL(0);
+
+extern void XtGetValues(
+ Widget /* widget */,
+ ArgList /* args */,
+ Cardinal /* num_args */
+);
+
+extern void XtVaGetValues(
+ Widget /* widget */,
+ ...
+) _X_SENTINEL(0);
+
+extern void XtSetSubvalues(
+ XtPointer /* base */,
+ XtResourceList /* resources */,
+ Cardinal /* num_resources */,
+ ArgList /* args */,
+ Cardinal /* num_args */
+);
+
+extern void XtVaSetSubvalues(
+ XtPointer /* base */,
+ XtResourceList /* resources */,
+ Cardinal /* num_resources */,
+ ...
+) _X_SENTINEL(0);
+
+extern void XtGetSubvalues(
+ XtPointer /* base */,
+ XtResourceList /* resources */,
+ Cardinal /* num_resources */,
+ ArgList /* args */,
+ Cardinal /* num_args */
+);
+
+extern void XtVaGetSubvalues(
+ XtPointer /* base */,
+ XtResourceList /* resources */,
+ Cardinal /* num_resources */,
+ ...
+) _X_SENTINEL(0);
+
+extern void XtGetResourceList(
+ WidgetClass /* widget_class */,
+ XtResourceList* /* resources_return */,
+ Cardinal* /* num_resources_return */
+);
+
+extern void XtGetConstraintResourceList(
+ WidgetClass /* widget_class */,
+ XtResourceList* /* resources_return */,
+ Cardinal* /* num_resources_return */
+);
+
+#define XtUnspecifiedPixmap ((Pixmap)2)
+#define XtUnspecifiedShellInt (-1)
+#define XtUnspecifiedWindow ((Window)2)
+#define XtUnspecifiedWindowGroup ((Window)3)
+#define XtCurrentDirectory "XtCurrentDirectory"
+#define XtDefaultForeground "XtDefaultForeground"
+#define XtDefaultBackground "XtDefaultBackground"
+#define XtDefaultFont "XtDefaultFont"
+#define XtDefaultFontSet "XtDefaultFontSet"
+
+#if defined(CRAY)
+#define XtOffset(p_type,field) _Offsetof(p_type,field)
+#else /* ! CRAY */
+#define XtOffset(p_type,field) \
+ ((Cardinal) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
+#endif /* !CRAY */
+
+#ifdef offsetof
+#define XtOffsetOf(s_type,field) offsetof(s_type,field)
+#else
+#define XtOffsetOf(s_type,field) XtOffset(s_type*,field)
+#endif
+
+/*************************************************************
+ *
+ * Session Management
+ *
+ ************************************************************/
+
+typedef struct _XtCheckpointTokenRec {
+ int save_type;
+ int interact_style;
+ Boolean shutdown;
+ Boolean fast;
+ Boolean cancel_shutdown;
+ int phase;
+ int interact_dialog_type; /* return */
+ Boolean request_cancel; /* return */
+ Boolean request_next_phase; /* return */
+ Boolean save_success; /* return */
+ int type; /* implementation private */
+ Widget widget; /* implementation private */
+} XtCheckpointTokenRec, *XtCheckpointToken;
+
+XtCheckpointToken XtSessionGetToken(
+ Widget /* widget */
+);
+
+void XtSessionReturnToken(
+ XtCheckpointToken /* token */
+);
+
+/*************************************************************
+ *
+ * Error Handling
+ *
+ ************************************************************/
+
+extern XtErrorMsgHandler XtAppSetErrorMsgHandler(
+ XtAppContext /* app_context */,
+ XtErrorMsgHandler /* handler */
+);
+
+extern void XtSetErrorMsgHandler( /* obsolete */
+ XtErrorMsgHandler /* handler */
+);
+
+extern XtErrorMsgHandler XtAppSetWarningMsgHandler(
+ XtAppContext /* app_context */,
+ XtErrorMsgHandler /* handler */
+);
+
+extern void XtSetWarningMsgHandler( /* obsolete */
+ XtErrorMsgHandler /* handler */
+);
+
+extern void XtAppErrorMsg(
+ XtAppContext /* app_context */,
+ _Xconst _XtString /* name */,
+ _Xconst _XtString /* type */,
+ _Xconst _XtString /* class */,
+ _Xconst _XtString /* default */,
+ String* /* params */,
+ Cardinal* /* num_params */
+);
+
+extern void XtErrorMsg( /* obsolete */
+ _Xconst _XtString /* name */,
+ _Xconst _XtString /* type */,
+ _Xconst _XtString /* class */,
+ _Xconst _XtString /* default */,
+ String* /* params */,
+ Cardinal* /* num_params */
+);
+
+extern void XtAppWarningMsg(
+ XtAppContext /* app_context */,
+ _Xconst _XtString /* name */,
+ _Xconst _XtString /* type */,
+ _Xconst _XtString /* class */,
+ _Xconst _XtString /* default */,
+ String* /* params */,
+ Cardinal* /* num_params */
+);
+
+extern void XtWarningMsg( /* obsolete */
+ _Xconst _XtString /* name */,
+ _Xconst _XtString /* type */,
+ _Xconst _XtString /* class */,
+ _Xconst _XtString /* default */,
+ String* /* params */,
+ Cardinal* /* num_params */
+);
+
+extern XtErrorHandler XtAppSetErrorHandler(
+ XtAppContext /* app_context */,
+ XtErrorHandler /* handler */
+);
+
+extern void XtSetErrorHandler( /* obsolete */
+ XtErrorHandler /* handler */
+);
+
+extern XtErrorHandler XtAppSetWarningHandler(
+ XtAppContext /* app_context */,
+ XtErrorHandler /* handler */
+);
+
+extern void XtSetWarningHandler( /* obsolete */
+ XtErrorHandler /* handler */
+);
+
+extern void XtAppError(
+ XtAppContext /* app_context */,
+ _Xconst _XtString /* message */
+);
+
+extern void XtError( /* obsolete */
+ _Xconst _XtString /* message */
+);
+
+extern void XtAppWarning(
+ XtAppContext /* app_context */,
+ _Xconst _XtString /* message */
+);
+
+extern void XtWarning( /* obsolete */
+ _Xconst _XtString /* message */
+);
+
+extern XrmDatabase *XtAppGetErrorDatabase(
+ XtAppContext /* app_context */
+);
+
+extern XrmDatabase *XtGetErrorDatabase( /* obsolete */
+ void
+);
+
+extern void XtAppGetErrorDatabaseText(
+ XtAppContext /* app_context */,
+ _Xconst _XtString /* name */,
+ _Xconst _XtString /* type */,
+ _Xconst _XtString /* class */,
+ _Xconst _XtString /* default */,
+ String /* buffer_return */,
+ int /* nbytes */,
+ XrmDatabase /* database */
+);
+
+extern void XtGetErrorDatabaseText( /* obsolete */
+ _Xconst _XtString /* name */,
+ _Xconst _XtString /* type */,
+ _Xconst _XtString /* class */,
+ _Xconst _XtString /* default */,
+ String /* buffer_return */,
+ int /* nbytes */
+);
+
+/****************************************************************
+ *
+ * Memory Management
+ *
+ ****************************************************************/
+
+extern char *XtMalloc(
+ Cardinal /* size */
+);
+
+extern char *XtCalloc(
+ Cardinal /* num */,
+ Cardinal /* size */
+);
+
+extern char *XtRealloc(
+ char* /* ptr */,
+ Cardinal /* num */
+);
+
+extern void XtFree(
+ char* /* ptr */
+);
+
+#ifdef XTTRACEMEMORY
+
+extern char *_XtMalloc( /* implementation-private */
+ Cardinal /* size */,
+ char * /* file */,
+ int /* line */
+);
+
+extern char *_XtRealloc( /* implementation-private */
+ char * /* ptr */,
+ Cardinal /* size */,
+ char * /* file */,
+ int /* line */
+);
+
+extern char *_XtCalloc( /* implementation-private */
+ Cardinal /* num */,
+ Cardinal /* size */,
+ char * /* file */,
+ int /* line */
+);
+
+extern void _XtFree( /* implementation-private */
+ char * /* ptr */
+);
+
+#define XtMalloc(size) _XtMalloc(size, __FILE__, __LINE__)
+#define XtRealloc(ptr,size) _XtRealloc(ptr, size, __FILE__, __LINE__)
+#define XtCalloc(num,size) _XtCalloc(num, size, __FILE__, __LINE__)
+#define XtFree(ptr) _XtFree(ptr)
+
+#endif /* ifdef XTTRACEMEMORY */
+
+#define XtNew(type) ((type *) XtMalloc((unsigned) sizeof(type)))
+
+#undef XtNewString
+extern String XtNewString(String /* str */);
+#define XtNewString(str) \
+ ((str) != NULL ? (strcpy(XtMalloc((unsigned)strlen(str) + 1), str)) : NULL)
+
+/*************************************************************
+ *
+ * Work procs
+ *
+ **************************************************************/
+
+extern XtWorkProcId XtAddWorkProc( /* obsolete */
+ XtWorkProc /* proc */,
+ XtPointer /* closure */
+);
+
+extern XtWorkProcId XtAppAddWorkProc(
+ XtAppContext /* app_context */,
+ XtWorkProc /* proc */,
+ XtPointer /* closure */
+);
+
+extern void XtRemoveWorkProc(
+ XtWorkProcId /* id */
+);
+
+
+/****************************************************************
+ *
+ * Graphic Context Management
+ *****************************************************************/
+
+extern GC XtGetGC(
+ Widget /* widget */,
+ XtGCMask /* valueMask */,
+ XGCValues* /* values */
+);
+
+extern GC XtAllocateGC(
+ Widget /* widget */,
+ Cardinal /* depth */,
+ XtGCMask /* valueMask */,
+ XGCValues* /* values */,
+ XtGCMask /* dynamicMask */,
+ XtGCMask /* unusedMask */
+);
+
+/* This implementation of XtDestroyGC differs from the formal specification
+ * for historic backwards compatibility reasons. As other implementations
+ * may conform to the spec, use of XtReleaseGC is strongly encouraged.
+ */
+extern void XtDestroyGC( /* obsolete */
+ GC /* gc */
+);
+
+extern void XtReleaseGC(
+ Widget /* object */,
+ GC /* gc */
+);
+
+
+
+extern void XtAppReleaseCacheRefs(
+ XtAppContext /* app_context */,
+ XtCacheRef* /* cache_ref */
+);
+
+extern void XtCallbackReleaseCacheRef(
+ Widget /* widget */,
+ XtPointer /* closure */, /* XtCacheRef */
+ XtPointer /* call_data */
+);
+
+extern void XtCallbackReleaseCacheRefList(
+ Widget /* widget */,
+ XtPointer /* closure */, /* XtCacheRef* */
+ XtPointer /* call_data */
+);
+
+extern void XtSetWMColormapWindows(
+ Widget /* widget */,
+ Widget* /* list */,
+ Cardinal /* count */
+);
+
+extern String XtFindFile(
+ _Xconst _XtString /* path */,
+ Substitution /* substitutions */,
+ Cardinal /* num_substitutions */,
+ XtFilePredicate /* predicate */
+);
+
+extern String XtResolvePathname(
+ Display* /* dpy */,
+ _Xconst _XtString /* type */,
+ _Xconst _XtString /* filename */,
+ _Xconst _XtString /* suffix */,
+ _Xconst _XtString /* path */,
+ Substitution /* substitutions */,
+ Cardinal /* num_substitutions */,
+ XtFilePredicate /* predicate */
+);
+
+/****************************************************************
+ *
+ * Selections
+ *
+ *****************************************************************/
+
+#define XT_CONVERT_FAIL (Atom)0x80000001
+
+extern void XtDisownSelection(
+ Widget /* widget */,
+ Atom /* selection */,
+ Time /* time */
+);
+
+extern void XtGetSelectionValue(
+ Widget /* widget */,
+ Atom /* selection */,
+ Atom /* target */,
+ XtSelectionCallbackProc /* callback */,
+ XtPointer /* closure */,
+ Time /* time */
+);
+
+extern void XtGetSelectionValues(
+ Widget /* widget */,
+ Atom /* selection */,
+ Atom* /* targets */,
+ int /* count */,
+ XtSelectionCallbackProc /* callback */,
+ XtPointer* /* closures */,
+ Time /* time */
+);
+
+extern void XtAppSetSelectionTimeout(
+ XtAppContext /* app_context */,
+ unsigned long /* timeout */
+);
+
+extern void XtSetSelectionTimeout( /* obsolete */
+ unsigned long /* timeout */
+);
+
+extern unsigned long XtAppGetSelectionTimeout(
+ XtAppContext /* app_context */
+);
+
+extern unsigned long XtGetSelectionTimeout( /* obsolete */
+ void
+);
+
+extern XSelectionRequestEvent *XtGetSelectionRequest(
+ Widget /* widget */,
+ Atom /* selection */,
+ XtRequestId /* request_id */
+);
+
+extern void XtGetSelectionValueIncremental(
+ Widget /* widget */,
+ Atom /* selection */,
+ Atom /* target */,
+ XtSelectionCallbackProc /* selection_callback */,
+ XtPointer /* client_data */,
+ Time /* time */
+);
+
+extern void XtGetSelectionValuesIncremental(
+ Widget /* widget */,
+ Atom /* selection */,
+ Atom* /* targets */,
+ int /* count */,
+ XtSelectionCallbackProc /* callback */,
+ XtPointer* /* client_data */,
+ Time /* time */
+);
+
+extern void XtSetSelectionParameters(
+ Widget /* requestor */,
+ Atom /* selection */,
+ Atom /* type */,
+ XtPointer /* value */,
+ unsigned long /* length */,
+ int /* format */
+);
+
+extern void XtGetSelectionParameters(
+ Widget /* owner */,
+ Atom /* selection */,
+ XtRequestId /* request_id */,
+ Atom* /* type_return */,
+ XtPointer* /* value_return */,
+ unsigned long* /* length_return */,
+ int* /* format_return */
+);
+
+extern void XtCreateSelectionRequest(
+ Widget /* requestor */,
+ Atom /* selection */
+);
+
+extern void XtSendSelectionRequest(
+ Widget /* requestor */,
+ Atom /* selection */,
+ Time /* time */
+);
+
+extern void XtCancelSelectionRequest(
+ Widget /* requestor */,
+ Atom /* selection */
+);
+
+extern Atom XtReservePropertyAtom(
+ Widget /* widget */
+);
+
+extern void XtReleasePropertyAtom(
+ Widget /* widget */,
+ Atom /* selection */
+);
+
+extern void XtGrabKey(
+ Widget /* widget */,
+ _XtKeyCode /* keycode */,
+ Modifiers /* modifiers */,
+ _XtBoolean /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */
+);
+
+extern void XtUngrabKey(
+ Widget /* widget */,
+ _XtKeyCode /* keycode */,
+ Modifiers /* modifiers */
+);
+
+extern int XtGrabKeyboard(
+ Widget /* widget */,
+ _XtBoolean /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Time /* time */
+);
+
+extern void XtUngrabKeyboard(
+ Widget /* widget */,
+ Time /* time */
+);
+
+extern void XtGrabButton(
+ Widget /* widget */,
+ int /* button */,
+ Modifiers /* modifiers */,
+ _XtBoolean /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */
+);
+
+extern void XtUngrabButton(
+ Widget /* widget */,
+ unsigned int /* button */,
+ Modifiers /* modifiers */
+);
+
+extern int XtGrabPointer(
+ Widget /* widget */,
+ _XtBoolean /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */,
+ Time /* time */
+);
+
+extern void XtUngrabPointer(
+ Widget /* widget */,
+ Time /* time */
+);
+
+extern void XtGetApplicationNameAndClass(
+ Display* /* dpy */,
+ String* /* name_return */,
+ String* /* class_return */
+);
+
+extern void XtRegisterDrawable(
+ Display* /* dpy */,
+ Drawable /* drawable */,
+ Widget /* widget */
+);
+
+extern void XtUnregisterDrawable(
+ Display* /* dpy */,
+ Drawable /* drawable */
+);
+
+extern Widget XtHooksOfDisplay(
+ Display* /* dpy */
+);
+
+typedef struct {
+ String type;
+ Widget widget;
+ ArgList args;
+ Cardinal num_args;
+} XtCreateHookDataRec, *XtCreateHookData;
+
+typedef struct {
+ String type;
+ Widget widget;
+ XtPointer event_data;
+ Cardinal num_event_data;
+} XtChangeHookDataRec, *XtChangeHookData;
+
+typedef struct {
+ Widget old, req;
+ ArgList args;
+ Cardinal num_args;
+} XtChangeHookSetValuesDataRec, *XtChangeHookSetValuesData;
+
+typedef struct {
+ String type;
+ Widget widget;
+ XtGeometryMask changeMask;
+ XWindowChanges changes;
+} XtConfigureHookDataRec, *XtConfigureHookData;
+
+typedef struct {
+ String type;
+ Widget widget;
+ XtWidgetGeometry* request;
+ XtWidgetGeometry* reply;
+ XtGeometryResult result;
+} XtGeometryHookDataRec, *XtGeometryHookData;
+
+typedef struct {
+ String type;
+ Widget widget;
+} XtDestroyHookDataRec, *XtDestroyHookData;
+
+extern void XtGetDisplays(
+ XtAppContext /* app_context */,
+ Display*** /* dpy_return */,
+ Cardinal* /* num_dpy_return */
+);
+
+extern Boolean XtToolkitThreadInitialize(
+ void
+);
+
+extern void XtAppSetExitFlag(
+ XtAppContext /* app_context */
+);
+
+extern Boolean XtAppGetExitFlag(
+ XtAppContext /* app_context */
+);
+
+extern void XtAppLock(
+ XtAppContext /* app_context */
+);
+
+extern void XtAppUnlock(
+ XtAppContext /* app_context */
+);
+
+/*
+ * Predefined Resource Converters
+ */
+
+
+/* String converters */
+
+extern Boolean XtCvtStringToAcceleratorTable(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToAtom(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* Display */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToBool(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToBoolean(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToCommandArgArray(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToCursor(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* Display */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToDimension(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToDirectoryString(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToDisplay(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToFile(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToFloat(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToFont(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* Display */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToFontSet(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* Display, locale */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToFontStruct(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* Display */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToGravity(
+ Display* /* dpy */,
+ XrmValuePtr /* args */,
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToInitialState(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToInt(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToPixel(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* Screen, Colormap */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+#define XtCvtStringToPosition XtCvtStringToShort
+
+extern Boolean XtCvtStringToRestartStyle(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToShort(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToTranslationTable(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToUnsignedChar(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtStringToVisual(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* Screen, depth */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+/* int converters */
+
+extern Boolean XtCvtIntToBool(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtIntToBoolean(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtIntToColor(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* Screen, Colormap */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+#define XtCvtIntToDimension XtCvtIntToShort
+
+extern Boolean XtCvtIntToFloat(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtIntToFont(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtIntToPixel(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtIntToPixmap(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+#define XtCvtIntToPosition XtCvtIntToShort
+
+extern Boolean XtCvtIntToShort(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+extern Boolean XtCvtIntToUnsignedChar(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+/* Color converter */
+
+extern Boolean XtCvtColorToPixel(
+ Display* /* dpy */,
+ XrmValuePtr /* args */, /* none */
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* closure_ret */
+);
+
+/* Pixel converter */
+
+#define XtCvtPixelToColor XtCvtIntToColor
+
+
+_XFUNCPROTOEND
+
+#endif /*_XtIntrinsic_h*/
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/IntrinsicI.h b/nx-X11/lib/Xt/IntrinsicI.h
new file mode 100644
index 000000000..d749867b8
--- /dev/null
+++ b/nx-X11/lib/Xt/IntrinsicI.h
@@ -0,0 +1,261 @@
+/* $Xorg: IntrinsicI.h,v 1.4 2001/02/09 02:03:55 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/IntrinsicI.h,v 3.8 2001/12/14 19:56:25 dawes Exp $ */
+
+#ifndef _XtintrinsicI_h
+#define _XtintrinsicI_h
+
+#include "Xtos.h"
+#include "IntrinsicP.h"
+#ifdef WIN32
+#define _WILLWINSOCK_
+#endif
+#include <X11/Xos.h>
+
+#include "Object.h"
+#include "RectObj.h"
+#include "ObjectP.h"
+#include "RectObjP.h"
+
+#include "ConvertI.h"
+#include "TranslateI.h"
+
+#define RectObjClassFlag 0x02
+#define WidgetClassFlag 0x04
+#define CompositeClassFlag 0x08
+#define ConstraintClassFlag 0x10
+#define ShellClassFlag 0x20
+#define WMShellClassFlag 0x40
+#define TopLevelClassFlag 0x80
+
+/*
+ * The following macros, though very handy, are not suitable for
+ * IntrinsicP.h as they violate the rule that arguments are to
+ * be evaluated exactly once.
+ */
+
+#define XtDisplayOfObject(object) \
+ (XtIsWidget(object) ? (object)->core.screen->display : \
+ _XtIsHookObject(object) ? ((HookObject)(object))->hooks.screen->display : \
+ _XtWindowedAncestor(object)->core.screen->display)
+
+#define XtScreenOfObject(object) \
+ (XtIsWidget(object) ? (object)->core.screen : \
+ _XtIsHookObject(object) ? ((HookObject)(object))->hooks.screen : \
+ _XtWindowedAncestor(object)->core.screen)
+
+#define XtWindowOfObject(object) \
+ ((XtIsWidget(object) ? (object) : _XtWindowedAncestor(object)) \
+ ->core.window)
+
+#define XtIsManaged(object) \
+ (XtIsRectObj(object) ? (object)->core.managed : False)
+
+#define XtIsSensitive(object) \
+ (XtIsRectObj(object) ? ((object)->core.sensitive && \
+ (object)->core.ancestor_sensitive) : False)
+
+
+/****************************************************************
+ *
+ * Byte utilities
+ *
+ ****************************************************************/
+
+#define _XBCOPYFUNC _XtBcopy
+#include <X11/Xfuncs.h>
+
+/* If the alignment characteristics of your machine are right, these may be
+ faster */
+
+#ifdef UNALIGNED
+
+#define XtMemmove(dst, src, size) \
+ if ((char *)(dst) != (char *)(src)) { \
+ if (size == sizeof(int)) \
+ *((int *) (dst)) = *((int *) (src)); \
+ else if (size == sizeof(char)) \
+ *((char *) (dst)) = *((char *) (src)); \
+ else if (size == sizeof(short)) \
+ *((short *) (dst)) = *((short *) (src)); \
+ else \
+ (void) memcpy((char *) (dst), (char *) (src), (int) (size)); \
+ }
+
+#define XtBZero(dst, size) \
+ if (size == sizeof(int)) \
+ *((int *) (dst)) = 0; \
+ else \
+ bzero((char *) (dst), (int) (size))
+
+#define XtMemcmp(b1, b2, size) \
+ (size == sizeof(int) ? \
+ *((int *) (b1)) != *((int *) (b2)) \
+ : memcmp((char *) (b1), (char *) (b2), (int) (size)) \
+ )
+
+#else
+
+#define XtMemmove(dst, src, size) \
+ if ((char *)(dst) != (char *)(src)) { \
+ (void) memcpy((char *) (dst), (char *) (src), (int) (size)); \
+ }
+
+#define XtBZero(dst, size) \
+ bzero((char *) (dst), (int) (size))
+
+#define XtMemcmp(b1, b2, size) \
+ memcmp((char *) (b1), (char *) (b2), (int) (size))
+
+#endif
+
+
+/****************************************************************
+ *
+ * Stack cache allocation/free
+ *
+ ****************************************************************/
+
+#define XtStackAlloc(size, stack_cache_array) \
+ ((size) <= sizeof(stack_cache_array) \
+ ? (XtPointer)(stack_cache_array) \
+ : XtMalloc((unsigned)(size)))
+
+#define XtStackFree(pointer, stack_cache_array) \
+ { if ((pointer) != ((XtPointer)(stack_cache_array))) XtFree(pointer); }
+
+/***************************************************************
+ *
+ * Filename defines
+ *
+ **************************************************************/
+
+/* used by XtResolvePathname */
+#ifndef XFILESEARCHPATHDEFAULT
+#define XFILESEARCHPATHDEFAULT "/usr/lib/X11/%L/%T/%N%S:/usr/lib/X11/%l/%T/%N%S:/usr/lib/X11/%T/%N%S"
+#endif
+
+/* the following two were both "X Toolkit " prior to R4 */
+#ifndef XTERROR_PREFIX
+#define XTERROR_PREFIX ""
+#endif
+
+#ifndef XTWARNING_PREFIX
+#define XTWARNING_PREFIX ""
+#endif
+
+#ifndef ERRORDB
+#define ERRORDB "/usr/lib/X11/XtErrorDB"
+#endif
+
+extern String XtCXtToolkitError;
+
+extern void _XtAllocError(
+ String /* alloc_type */
+);
+
+extern void _XtCompileResourceList(
+ XtResourceList /* resources */,
+ Cardinal /* num_resources */
+);
+
+extern XtGeometryResult _XtMakeGeometryRequest(
+ Widget /* widget */,
+ XtWidgetGeometry* /* request */,
+ XtWidgetGeometry* /* reply_return */,
+ Boolean* /* clear_rect_obj */
+);
+
+extern Boolean _XtIsHookObject(
+ Widget /* widget */
+);
+
+extern void _XtAddShellToHookObj(
+ Widget /* widget */
+);
+
+/* GCManager.c */
+extern void _XtGClistFree(Display *dpy, XtPerDisplay pd);
+
+/** GeoTattler stuff */
+
+#ifdef XT_GEO_TATTLER
+
+extern void _XtGeoTab (int);
+extern void _XtGeoTrace (
+ Widget widget,
+ ...
+) _X_ATTRIBUTE_PRINTF(2,3);
+
+#define CALLGEOTAT(f) f
+
+#else /* XT_GEO_TATTLER */
+
+#define CALLGEOTAT(f)
+
+#endif /* XT_GEO_TATTLER */
+
+#ifndef XTTRACEMEMORY
+
+extern char* __XtMalloc (
+ unsigned /* size */
+);
+extern char* __XtCalloc (
+ unsigned /* num */,
+ unsigned /* size */
+);
+
+#else
+
+#define __XtMalloc XtMalloc
+#define __XtCalloc XtCalloc
+#endif
+
+#endif /* _XtintrinsicI_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/IntrinsicP.h b/nx-X11/lib/Xt/IntrinsicP.h
new file mode 100644
index 000000000..517c55d2b
--- /dev/null
+++ b/nx-X11/lib/Xt/IntrinsicP.h
@@ -0,0 +1,327 @@
+/* $Xorg: IntrinsicP.h,v 1.4 2001/02/09 02:03:55 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86$ */
+
+#ifndef _XtintrinsicP_h
+#define _XtintrinsicP_h
+
+#include <X11/Intrinsic.h>
+
+/*
+ * Field sizes and offsets of XrmResource must match those of XtResource.
+ * Type long is used instead of XrmQuark here because XrmQuark and String
+ * are not the same size on all systems.
+ */
+typedef struct {
+ long xrm_name; /* Resource name quark */
+ long xrm_class; /* Resource class quark */
+ long xrm_type; /* Resource representation type quark */
+ Cardinal xrm_size; /* Size in bytes of representation */
+ int xrm_offset; /* -offset-1 */
+ long xrm_default_type; /* Default representation type quark */
+ XtPointer xrm_default_addr; /* Default resource address */
+} XrmResource, *XrmResourceList;
+
+typedef unsigned long XtVersionType;
+
+#define XT_VERSION 11
+#ifndef XT_REVISION
+#define XT_REVISION 6
+#endif
+#define XtVersion (XT_VERSION * 1000 + XT_REVISION)
+#define XtVersionDontCheck 0
+
+typedef void (*XtProc)(
+ void
+);
+
+typedef void (*XtWidgetClassProc)(
+ WidgetClass /* class */
+);
+
+typedef void (*XtWidgetProc)(
+ Widget /* widget */
+);
+
+typedef Boolean (*XtAcceptFocusProc)(
+ Widget /* widget */,
+ Time* /* time */
+);
+
+typedef void (*XtArgsProc)(
+ Widget /* widget */,
+ ArgList /* args */,
+ Cardinal* /* num_args */
+);
+
+typedef void (*XtInitProc)(
+ Widget /* request */,
+ Widget /* new */,
+ ArgList /* args */,
+ Cardinal* /* num_args */
+);
+
+typedef Boolean (*XtSetValuesFunc)(
+ Widget /* old */,
+ Widget /* request */,
+ Widget /* new */,
+ ArgList /* args */,
+ Cardinal* /* num_args */
+);
+
+typedef Boolean (*XtArgsFunc)(
+ Widget /* widget */,
+ ArgList /* args */,
+ Cardinal* /* num_args */
+);
+
+typedef void (*XtAlmostProc)(
+ Widget /* old */,
+ Widget /* new */,
+ XtWidgetGeometry* /* request */,
+ XtWidgetGeometry* /* reply */
+);
+
+typedef void (*XtExposeProc)(
+ Widget /* widget */,
+ XEvent* /* event */,
+ Region /* region */
+);
+
+/* compress_exposure options*/
+#define XtExposeNoCompress ((XtEnum)False)
+#define XtExposeCompressSeries ((XtEnum)True)
+#define XtExposeCompressMultiple 2
+#define XtExposeCompressMaximal 3
+
+/* modifiers */
+#define XtExposeGraphicsExpose 0x10
+#define XtExposeGraphicsExposeMerged 0x20
+#define XtExposeNoExpose 0x40
+#define XtExposeNoRegion 0x80
+
+typedef void (*XtRealizeProc)(
+ Widget /* widget */,
+ XtValueMask* /* mask */,
+ XSetWindowAttributes* /* attributes */
+);
+
+typedef XtGeometryResult (*XtGeometryHandler)(
+ Widget /* widget */,
+ XtWidgetGeometry* /* request */,
+ XtWidgetGeometry* /* reply */
+);
+
+typedef void (*XtStringProc)(
+ Widget /* widget */,
+ String /* str */
+);
+
+typedef struct {
+ String name; /* resource name */
+ String type; /* representation type name */
+ XtArgVal value; /* representation */
+ int size; /* size of representation */
+} XtTypedArg, *XtTypedArgList;
+
+typedef void (*XtAllocateProc)(
+ WidgetClass /* widget_class */,
+ Cardinal * /* constraint_size */,
+ Cardinal * /* more_bytes */,
+ ArgList /* args */,
+ Cardinal * /* num_args */,
+ XtTypedArgList /* typed_args */,
+ Cardinal * /* num_typed_args */,
+ Widget * /* widget_return */,
+ XtPointer * /* more_bytes_return */
+);
+
+typedef void (*XtDeallocateProc)(
+ Widget /* widget */,
+ XtPointer /* more_bytes */
+);
+
+struct _XtStateRec; /* Forward declare before use for C++ */
+
+typedef struct _XtTMRec {
+ XtTranslations translations; /* private to Translation Manager */
+ XtBoundActions proc_table; /* procedure bindings for actions */
+ struct _XtStateRec *current_state; /* Translation Manager state ptr */
+ unsigned long lastEventTime;
+} XtTMRec, *XtTM;
+
+#include <X11/CoreP.h>
+#include <X11/CompositeP.h>
+#include <X11/ConstrainP.h>
+#include <X11/ObjectP.h>
+#include <X11/RectObjP.h>
+
+#define XtDisplay(widget) DisplayOfScreen((widget)->core.screen)
+#define XtScreen(widget) ((widget)->core.screen)
+#define XtWindow(widget) ((widget)->core.window)
+
+#define XtClass(widget) ((widget)->core.widget_class)
+#define XtSuperclass(widget) (XtClass(widget)->core_class.superclass)
+#define XtIsRealized(object) (XtWindowOfObject(object) != None)
+#define XtParent(widget) ((widget)->core.parent)
+
+#undef XtIsRectObj
+extern Boolean XtIsRectObj(Widget);
+#define XtIsRectObj(obj) \
+ (((Object)(obj))->object.widget_class->core_class.class_inited & 0x02)
+
+#undef XtIsWidget
+extern Boolean XtIsWidget(Widget);
+#define XtIsWidget(obj) \
+ (((Object)(obj))->object.widget_class->core_class.class_inited & 0x04)
+
+#undef XtIsComposite
+extern Boolean XtIsComposite(Widget);
+#define XtIsComposite(obj) \
+ (((Object)(obj))->object.widget_class->core_class.class_inited & 0x08)
+
+#undef XtIsConstraint
+extern Boolean XtIsConstraint(Widget);
+#define XtIsConstraint(obj) \
+ (((Object)(obj))->object.widget_class->core_class.class_inited & 0x10)
+
+#undef XtIsShell
+extern Boolean XtIsShell(Widget);
+#define XtIsShell(obj) \
+ (((Object)(obj))->object.widget_class->core_class.class_inited & 0x20)
+
+#undef XtIsWMShell
+extern Boolean XtIsWMShell(Widget);
+#define XtIsWMShell(obj) \
+ (((Object)(obj))->object.widget_class->core_class.class_inited & 0x40)
+
+#undef XtIsTopLevelShell
+extern Boolean XtIsTopLevelShell(Widget);
+#define XtIsTopLevelShell(obj) \
+ (((Object)(obj))->object.widget_class->core_class.class_inited & 0x80)
+
+#ifdef DEBUG
+#define XtCheckSubclass(w, widget_class_ptr, message) \
+ if (!XtIsSubclass(((Widget)(w)), (widget_class_ptr))) { \
+ String params[3]; \
+ Cardinal num_params = 3; \
+ params[0] = ((Widget)(w))->core.widget_class->core_class.class_name;\
+ params[1] = (widget_class_ptr)->core_class.class_name; \
+ params[2] = (message); \
+ XtAppErrorMsg(XtWidgetToApplicationContext((Widget)(w)), \
+ "subclassMismatch", "xtCheckSubclass", "XtToolkitError", \
+ "Widget class %s found when subclass of %s expected: %s",\
+ params, &num_params); \
+ }
+#else
+#define XtCheckSubclass(w, widget_class, message) /* nothing */
+#endif
+
+_XFUNCPROTOBEGIN
+
+extern Widget _XtWindowedAncestor( /* internal; implementation-dependent */
+ Widget /* object */
+);
+
+extern void _XtInherit(
+ void
+);
+
+extern void _XtHandleFocus(
+ Widget /* widget */,
+ XtPointer /* client_data */,
+ XEvent * /* event */,
+ Boolean * /* cont */);
+
+extern void XtCreateWindow(
+ Widget /* widget */,
+ unsigned int /* window_class */,
+ Visual* /* visual */,
+ XtValueMask /* value_mask */,
+ XSetWindowAttributes* /* attributes */
+);
+
+extern void XtResizeWidget(
+ Widget /* widget */,
+ _XtDimension /* width */,
+ _XtDimension /* height */,
+ _XtDimension /* border_width */
+);
+
+extern void XtMoveWidget(
+ Widget /* widget */,
+ _XtPosition /* x */,
+ _XtPosition /* y */
+);
+
+extern void XtConfigureWidget(
+ Widget /* widget */,
+ _XtPosition /* x */,
+ _XtPosition /* y */,
+ _XtDimension /* width */,
+ _XtDimension /* height */,
+ _XtDimension /* border_width */
+);
+
+extern void XtResizeWindow(
+ Widget /* widget */
+);
+
+extern void XtProcessLock(
+ void
+);
+
+extern void XtProcessUnlock(
+ void
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XtIntrinsicP_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/Keyboard.c b/nx-X11/lib/Xt/Keyboard.c
new file mode 100644
index 000000000..82bcc2478
--- /dev/null
+++ b/nx-X11/lib/Xt/Keyboard.c
@@ -0,0 +1,851 @@
+/* $Xorg: Keyboard.c,v 1.5 2001/02/09 02:03:55 xorgcvs Exp $ */
+
+/********************************************************
+
+Copyright 1988 by Hewlett-Packard Company
+Copyright 1987, 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, CA.
+
+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 names of
+Hewlett-Packard, Digital, or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/Keyboard.c,v 3.3 2001/08/22 22:52:19 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+
+#include "PassivGraI.h"
+#include "EventI.h"
+
+#define _GetWindowedAncestor(w) (XtIsWidget(w) ? w : _XtWindowedAncestor(w))
+
+/* InActiveSubtree cache of the current focus source and its ancestors */
+static Widget *pathTrace = NULL;
+static int pathTraceDepth = 0;
+static int pathTraceMax = 0;
+
+/* FindKeyDestination cache of focus destination and ancestors up to source */
+static Widget *pseudoTrace = NULL;
+static int pseudoTraceDepth = 0;
+static int pseudoTraceMax = 0;
+
+void _XtClearAncestorCache(Widget widget)
+{
+ /* the caller must lock the process lock */
+ if (pathTraceDepth && pathTrace[0] == widget)
+ pathTraceDepth = 0;
+}
+
+static XtServerGrabPtr CheckServerGrabs(
+ XEvent *event,
+ Widget *trace,
+ Cardinal traceDepth)
+{
+ XtServerGrabPtr grab;
+ Cardinal i;
+
+ for (i = traceDepth; i > 0; i--)
+ {
+ if ((grab = _XtCheckServerGrabsOnWidget(event, trace[i-1], KEYBOARD)))
+ return (grab);
+ }
+ return (XtServerGrabPtr)0;
+}
+
+static Boolean IsParent(Widget a, Widget b)
+{
+ for (b = XtParent(b); b; b = XtParent(b)) {
+ if (b == a) return TRUE;
+ if (XtIsShell(b)) return FALSE;
+ }
+ return FALSE;
+}
+
+#define RelRtn(lca, type) {*relTypeRtn = type; return lca;}
+
+static Widget CommonAncestor(
+ register Widget a,
+ register Widget b,
+ XtGeneology * relTypeRtn)
+{
+ if (a == b)
+ {
+ RelRtn(a, XtMySelf)
+ }
+ else if (IsParent(a, b))
+ {
+ RelRtn(a, XtMyAncestor)
+ }
+ else if (IsParent(b, a))
+ {
+ RelRtn(b, XtMyDescendant)
+ }
+ else
+ for (b = XtParent(b);
+ b && !XtIsShell(b);
+ b = XtParent(b))
+ if (IsParent(b, a))
+ {
+ RelRtn(b, XtMyCousin)
+ }
+ RelRtn(NULL, XtUnrelated)
+}
+#undef RelRtn
+
+
+
+
+
+static Widget _FindFocusWidget(
+ Widget widget,
+ Widget *trace,
+ int traceDepth,
+ Boolean activeCheck,
+ Boolean *isTarget)
+{
+ int src;
+ Widget dst;
+ XtPerWidgetInput pwi = NULL;
+
+ /* For each ancestor, starting at the top, see if it's forwarded */
+
+
+ /* first check the trace list till done or we go to branch */
+ for (src = traceDepth-1, dst = widget; src > 0;)
+ {
+ if ((pwi = _XtGetPerWidgetInput(trace[src], FALSE)))
+ {
+ if (pwi->focusKid)
+ {
+ dst = pwi->focusKid;
+ for (src--; src > 0 && trace[src] != dst; src--) {}
+ }
+ else dst = trace[--src];
+ }
+ else dst = trace[--src];
+ }
+
+ if (isTarget) {
+ if (pwi && pwi->focusKid == widget)
+ *isTarget = TRUE;
+ else
+ *isTarget = FALSE;
+ }
+
+ if (!activeCheck)
+ while (XtIsWidget(dst)
+ && (pwi = _XtGetPerWidgetInput(dst, FALSE))
+ && pwi->focusKid)
+ dst = pwi->focusKid;
+
+ return dst;
+}
+
+
+static Widget FindFocusWidget(
+ Widget widget,
+ XtPerDisplayInput pdi)
+{
+ if (pdi->focusWidget)
+ return pdi->focusWidget;
+ else
+ return _FindFocusWidget(widget, pdi->trace, pdi->traceDepth, FALSE, NULL);
+}
+
+Widget XtGetKeyboardFocusWidget(Widget widget)
+{
+ XtPerDisplayInput pdi;
+ Widget retval;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ pdi = _XtGetPerDisplayInput(XtDisplay(widget));
+ retval = FindFocusWidget(widget, pdi);
+ UNLOCK_APP(app);
+ return retval;
+}
+
+static Boolean IsOutside(
+ XKeyEvent *e,
+ Widget w)
+{
+ Position left, right, top, bottom;
+
+ /*
+ * if the pointer is outside the shell or inside
+ * the window try to see if it would recieve the
+ * focus
+ */
+ XtTranslateCoords(w, 0, 0, &left, &top);
+ /* We need to take borders into consideration */
+ left = left - w->core.border_width;
+ top = top - w->core.border_width;
+ right = left + w->core.width + w->core.border_width;
+ bottom = top + w->core.height + w->core.border_width;
+
+ if (
+ (e->x_root < left) || (e->y_root < top) ||
+ (e->x_root > right) || (e->y_root > bottom))
+ return TRUE;
+ else
+ return FALSE;
+}
+
+static Widget FindKeyDestination(
+ Widget widget,
+ XKeyEvent *event,
+ XtServerGrabPtr prevGrab,
+ XtServerGrabType prevGrabType,
+ XtServerGrabPtr devGrab,
+ XtServerGrabType devGrabType,
+ XtPerDisplayInput pdi)
+{
+
+ Widget dspWidget;
+ Widget focusWidget;
+
+ LOCK_PROCESS;
+ dspWidget =
+ focusWidget =
+ pdi->focusWidget =
+ _GetWindowedAncestor(FindFocusWidget(widget, pdi));
+
+
+ /*
+ * If a grab is active from a previous activation then dispatch
+ * based on owner_events ala protocol but with focus being
+ * determined by XtSetKeyboardFocus.
+ */
+ if (IsAnyGrab(prevGrabType))
+ {
+ if (prevGrab->ownerEvents)
+ dspWidget = focusWidget;
+ else
+ dspWidget = prevGrab->widget;
+ }
+ else
+ {
+ /*
+ * If the focus widget is the event widget or a descendant
+ * then we can avoid the rest of this. Else ugh...
+ */
+ if (focusWidget != widget)
+ {
+ XtGeneology ewRelFw; /* relationship of event widget to
+ focusWidget */
+ Widget lca;
+
+ lca = CommonAncestor(widget, focusWidget, &ewRelFw);
+
+ /*
+ * if the event widget is an ancestor of focus due to the pointer
+ * and/or the grab being in an ancestor and it's a passive grab
+ * send to grab widget.
+ * we are also dispatching to widget if ownerEvents and the event
+ * is outside the client
+ */
+ if ((ewRelFw == XtMyAncestor) &&
+ (devGrabType == XtPassiveServerGrab))
+ {
+ if (IsOutside(event, widget) ||
+ event->type ==KeyPress
+ )
+ dspWidget = devGrab->widget;
+ }
+ else
+ {
+ /*
+ * if the grab widget is not an ancestor of the focus
+ * release the grab in order to avoid locking. There
+ * is a possible case in that ownerEvents true will fall
+ * through and if synch is set and the event widget
+ * could turn it off we'll lock. check for it ? why not
+ */
+ if ((ewRelFw != XtMyAncestor)
+ && (devGrabType == XtPassiveServerGrab)
+ && (!IsAnyGrab(prevGrabType))
+ )
+ {
+ XtUngrabKeyboard(devGrab->widget,
+ event->time);
+ devGrabType = XtNoServerGrab;
+ }
+ /*
+ * if there isn't a grab with then check
+ * for a logical grab that would have been activated
+ * if the server was using Xt focus instead of server
+ * focus
+ */
+ if (
+ (event->type != KeyPress) ||
+ (event->keycode == 0) /* Xlib XIM composed input */
+ )
+ dspWidget = focusWidget;
+ else
+ {
+ XtServerGrabPtr grab;
+
+ if (!pseudoTraceDepth ||
+ !(focusWidget == pseudoTrace[0]) ||
+ !(lca == pseudoTrace[pseudoTraceDepth]))
+ {
+ /*
+ * fill ancestor list from lca
+ * (non-inclusive)to focusWidget by
+ * passing in lca as breakWidget
+ */
+ _XtFillAncestorList(&pseudoTrace,
+ &pseudoTraceMax,
+ &pseudoTraceDepth,
+ focusWidget,
+ lca);
+ /* ignore lca */
+ pseudoTraceDepth--;
+ }
+ if ((grab = CheckServerGrabs((XEvent*)event,
+ pseudoTrace,
+ pseudoTraceDepth)))
+ {
+ XtDevice device = &pdi->keyboard;
+
+ device->grabType = XtPseudoPassiveServerGrab;
+ pdi->activatingKey = event->keycode;
+ device->grab = *grab;
+
+ if (grab
+ )
+ dspWidget = grab->widget;
+ else
+ dspWidget = focusWidget;
+ }
+ }
+ }
+ }
+ }
+ UNLOCK_PROCESS;
+ return dspWidget;
+}
+
+Widget _XtProcessKeyboardEvent(
+ XKeyEvent *event,
+ Widget widget,
+ XtPerDisplayInput pdi)
+{
+ XtDevice device = &pdi->keyboard;
+ XtServerGrabPtr newGrab, devGrab = &device->grab;
+ XtServerGrabRec prevGrabRec;
+ XtServerGrabType prevGrabType = device->grabType;
+ Widget dspWidget = NULL;
+ Boolean deactivateGrab = FALSE;
+
+ prevGrabRec = *devGrab;
+
+ switch (event->type)
+ {
+ case KeyPress:
+ {
+ if (event->keycode != 0 && /* Xlib XIM composed input */
+ !IsServerGrab(device->grabType) &&
+ (newGrab = CheckServerGrabs((XEvent*)event,
+ pdi->trace,
+ pdi->traceDepth)))
+ {
+ /*
+ * honor pseudo-grab from prior event by X
+ * unlocking keyboard. Not Xt Unlock !
+ */
+ if (IsPseudoGrab(prevGrabType))
+ XUngrabKeyboard(XtDisplay(newGrab->widget),
+ event->time);
+ else
+ {
+ /* Activate the grab */
+ device->grab = *newGrab;
+ pdi->activatingKey = event->keycode;
+ device->grabType = XtPassiveServerGrab;
+ }
+ }
+ }
+ break;
+
+ case KeyRelease:
+ {
+ if (IsEitherPassiveGrab(device->grabType) &&
+ (event->keycode == pdi->activatingKey))
+ deactivateGrab = TRUE;
+ }
+ break;
+ }
+ dspWidget = FindKeyDestination(widget, event,
+ &prevGrabRec, prevGrabType,
+ devGrab, device->grabType,
+ pdi);
+ if (deactivateGrab)
+ {
+ /* Deactivate the grab */
+ device->grabType = XtNoServerGrab;
+ pdi->activatingKey = 0;
+ }
+ return dspWidget;
+}
+
+static Widget GetShell(Widget widget)
+{
+ Widget shell;
+
+ for (shell = widget;
+ shell && !XtIsShell(shell);
+ shell = XtParent(shell)){}
+ return shell;
+}
+
+
+/*
+ * Check that widget really has Xt focus due to it having recieved an
+ * event
+ */
+typedef enum {NotActive = 0, IsActive, IsTarget} ActiveType;
+static ActiveType InActiveSubtree(Widget widget)
+{
+ Boolean isTarget;
+ ActiveType retval;
+
+ LOCK_PROCESS;
+ if (!pathTraceDepth || widget != pathTrace[0]) {
+ _XtFillAncestorList(&pathTrace,
+ &pathTraceMax,
+ &pathTraceDepth,
+ widget,
+ NULL);
+ }
+ if (widget == _FindFocusWidget(widget,
+ pathTrace,
+ pathTraceDepth,
+ TRUE,
+ &isTarget))
+ retval = (isTarget ? IsTarget : IsActive);
+ else
+ retval = NotActive;
+ UNLOCK_PROCESS;
+ return retval;
+}
+
+
+
+
+/* ARGSUSED */
+void _XtHandleFocus(
+ Widget widget,
+ XtPointer client_data, /* child who wants focus */
+ XEvent *event,
+ Boolean *cont) /* unused */
+{
+ XtPerDisplayInput pdi = _XtGetPerDisplayInput(XtDisplay(widget));
+ XtPerWidgetInput pwi = (XtPerWidgetInput)client_data;
+ XtGeneology oldFocalPoint = pwi->focalPoint;
+ XtGeneology newFocalPoint = pwi->focalPoint;
+
+ switch( event->type ) {
+
+ case KeyPress:
+ case KeyRelease:
+ /*
+ * We're getting the keyevents used to guarantee propagating
+ * child interest ala ForwardEvent in R3
+ */
+ return;
+
+ case EnterNotify:
+ case LeaveNotify:
+
+ /*
+ * If operating in a focus driven model, then enter and
+ * leave events do not affect the keyboard focus.
+ */
+ if ((event->xcrossing.detail != NotifyInferior)
+ && (event->xcrossing.focus))
+ {
+ switch (oldFocalPoint)
+ {
+ case XtMyAncestor:
+ if (event->type == LeaveNotify)
+ newFocalPoint = XtUnrelated;
+ break;
+ case XtUnrelated:
+ if (event->type == EnterNotify)
+ newFocalPoint = XtMyAncestor;
+ break;
+ case XtMySelf:
+ break;
+ case XtMyDescendant:
+ break;
+
+ }
+ }
+ break;
+ case FocusIn:
+ switch (event->xfocus.detail)
+ {
+ case NotifyNonlinear:
+ case NotifyAncestor:
+ case NotifyInferior:
+ newFocalPoint = XtMySelf;
+ break;
+ case NotifyNonlinearVirtual:
+ case NotifyVirtual:
+ newFocalPoint = XtMyDescendant;
+ break;
+ case NotifyPointer:
+ newFocalPoint = XtMyAncestor;
+ break;
+ }
+ break;
+ case FocusOut:
+ switch (event->xfocus.detail)
+ {
+ case NotifyPointer:
+ case NotifyNonlinear:
+ case NotifyAncestor:
+ case NotifyNonlinearVirtual:
+ case NotifyVirtual:
+ newFocalPoint = XtUnrelated;
+ break;
+ case NotifyInferior:
+ newFocalPoint = XtMyDescendant;
+ return;
+ break;
+ }
+ break;
+ }
+
+ if (newFocalPoint != oldFocalPoint)
+ {
+ Boolean add;
+ Widget descendant = pwi->focusKid;
+
+ pwi->focalPoint = newFocalPoint;
+
+ if ((oldFocalPoint == XtUnrelated) &&
+ InActiveSubtree(widget) != NotActive)
+ {
+ pdi->focusWidget = NULL; /* invalidate the cache */
+ pwi->haveFocus = TRUE;
+ add = TRUE;
+ }
+ else if (newFocalPoint == XtUnrelated)
+ {
+ pdi->focusWidget = NULL; /* invalidate the cache */
+ pwi->haveFocus = FALSE;
+ add = FALSE;
+ }
+ else
+ return;
+
+ if (descendant)
+ {
+ if (add)
+ {
+ _XtSendFocusEvent(descendant, FocusIn);
+ }
+ else
+ {
+ _XtSendFocusEvent(descendant, FocusOut);
+ }
+ }
+ }
+}
+
+
+static void AddFocusHandler(
+ Widget widget,
+ Widget descendant,
+ XtPerWidgetInput pwi,
+ XtPerWidgetInput psi,
+ XtPerDisplayInput pdi,
+ EventMask oldEventMask)
+{
+ EventMask eventMask, targetEventMask;
+ Widget target;
+
+ /*
+ * widget must now select for key events if the descendant is
+ * interested in them.
+ *
+ * shell borders are not occluded by the child, they're occluded
+ * by reparenting window managers. !!!
+ */
+ target = descendant ? _GetWindowedAncestor(descendant) : NULL;
+ targetEventMask = XtBuildEventMask(target);
+ eventMask = targetEventMask & (KeyPressMask | KeyReleaseMask);
+ eventMask |= FocusChangeMask | EnterWindowMask | LeaveWindowMask;
+
+ if (oldEventMask) {
+ oldEventMask &= KeyPressMask | KeyReleaseMask;
+ oldEventMask |= FocusChangeMask | EnterWindowMask | LeaveWindowMask;
+
+ if (oldEventMask != eventMask)
+ XtRemoveEventHandler(widget, (oldEventMask & ~eventMask),
+ False, _XtHandleFocus, (XtPointer)pwi);
+ }
+
+ if (oldEventMask != eventMask)
+ XtAddEventHandler(widget, eventMask, False,
+ _XtHandleFocus, (XtPointer)pwi);
+
+ /* What follows is too much grief to go through if the
+ * target doesn't actually care about focus change events,
+ * so just invalidate the focus cache & refill it when
+ * the next input event actually arrives.
+ */
+
+ if (!(targetEventMask & FocusChangeMask)) {
+ pdi->focusWidget = NULL;
+ return;
+ }
+
+ if (XtIsRealized(widget) && !pwi->haveFocus) {
+ if (psi->haveFocus) {
+ Window root, child;
+ int root_x, root_y, win_x, win_y;
+ int left, right, top, bottom;
+ unsigned int modMask;
+ ActiveType act;
+
+ /*
+ * If the shell has the focus but the source widget
+ * doesn't, it may only be because the source widget
+ * wasn't previously tracking focus or crossing events.
+ * If the target wants focus events, we have to
+ * now determine whether the source has the focus.
+ */
+
+ if ((act = InActiveSubtree(widget)) == IsTarget)
+ pwi->haveFocus = TRUE;
+ else if (act == IsActive) {
+ /*
+ * An ancestor contains the focus, so if source
+ * contains the pointer, then source has the focus.
+ */
+
+ if (XQueryPointer(XtDisplay(widget), XtWindow(widget),
+ &root, &child,
+ &root_x, &root_y, &win_x, &win_y, &modMask))
+ {
+ /* We need to take borders into consideration */
+ left = top = -((int) widget->core.border_width);
+ right = (int) (widget->core.width + (widget->core.border_width << 1));
+ bottom = (int) (widget->core.height + (widget->core.border_width << 1));
+
+ if (win_x >= left && win_x < right &&
+ win_y >= top && win_y < bottom)
+ pwi->haveFocus = TRUE;
+ }
+ }
+ }
+ }
+ if (pwi->haveFocus) {
+ pdi->focusWidget = NULL; /* invalidate the cache */
+ _XtSendFocusEvent(target, FocusIn);
+ }
+}
+
+
+/* ARGSUSED */
+static void QueryEventMask(
+ Widget widget, /* child who gets focus */
+ XtPointer client_data, /* ancestor giving it */
+ XEvent *event,
+ Boolean *cont) /* unused */
+{
+ /* widget was once the target of an XtSetKeyboardFocus but
+ * was unrealized at the time. Make sure ancestor still wants
+ * focus set here then install the handler now that we know the
+ * complete event mask.
+ */
+ Widget ancestor = (Widget)client_data;
+ XtPerWidgetInput pwi = _XtGetPerWidgetInput(ancestor, FALSE);
+ Widget target = pwi->queryEventDescendant;
+
+ /* use of 'target' is non-standard hackery; allows focus to non-widget */
+ if (pwi && (pwi->focusKid == target)) {
+ AddFocusHandler(ancestor, target, pwi,
+ _XtGetPerWidgetInput(GetShell(ancestor), TRUE),
+ _XtGetPerDisplayInput(XtDisplay(ancestor)),
+ (EventMask)0);
+ }
+ XtRemoveEventHandler(widget, XtAllEvents, True,
+ QueryEventMask, client_data);
+ pwi->map_handler_added = FALSE;
+}
+
+
+/* ARGSUSED */
+static void FocusDestroyCallback(
+ Widget widget,
+ XtPointer closure, /* Widget */
+ XtPointer call_data)
+{
+ XtSetKeyboardFocus((Widget)closure, None);
+}
+
+void XtSetKeyboardFocus(
+ Widget widget,
+ Widget descendant)
+{
+ XtPerDisplayInput pdi;
+ XtPerWidgetInput pwi;
+ Widget oldDesc, oldTarget, target, hookobj;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ pdi = _XtGetPerDisplayInput(XtDisplay(widget));
+ pwi = _XtGetPerWidgetInput(widget, TRUE);
+ oldDesc = pwi->focusKid;
+
+ if (descendant == widget) descendant = (Widget)None;
+
+ target = descendant ? _GetWindowedAncestor(descendant) : NULL;
+ oldTarget = oldDesc ? _GetWindowedAncestor(oldDesc) : NULL;
+
+ if (descendant != oldDesc) {
+
+ /* update the forward path */
+ pwi->focusKid = descendant;
+
+
+ /* all the rest handles focus ins and focus outs and misc gunk */
+
+ if (oldDesc) {
+ /* invalidate FindKeyDestination's ancestor list */
+ if (pseudoTraceDepth && oldTarget == pseudoTrace[0])
+ pseudoTraceDepth = 0;
+
+ XtRemoveCallback(oldDesc, XtNdestroyCallback,
+ FocusDestroyCallback, (XtPointer)widget);
+
+ if (!oldTarget->core.being_destroyed) {
+ if (pwi->map_handler_added) {
+ XtRemoveEventHandler(oldTarget, XtAllEvents, True,
+ QueryEventMask, (XtPointer)widget);
+ pwi->map_handler_added = FALSE;
+ }
+ if (pwi->haveFocus) {
+ _XtSendFocusEvent( oldTarget, FocusOut);
+ }
+ }
+ else if (pwi->map_handler_added) {
+ pwi->map_handler_added = FALSE;
+ }
+
+ if (pwi->haveFocus)
+ pdi->focusWidget = NULL; /* invalidate cache */
+
+ /*
+ * If there was a forward path then remove the handler if
+ * the path is being set to null and it isn't a shell.
+ * shells always have a handler for tracking focus for the
+ * hierarchy.
+ *
+ * Keep the pwi record on the assumption that the client
+ * will continue to dynamically assign focus for this widget.
+ */
+ if (!XtIsShell(widget) && !descendant) {
+ XtRemoveEventHandler(widget, XtAllEvents, True,
+ _XtHandleFocus, (XtPointer)pwi);
+ pwi->haveFocus = FALSE;
+ }
+ }
+
+ if (descendant) {
+ Widget shell = GetShell(widget);
+ XtPerWidgetInput psi = _XtGetPerWidgetInput(shell, TRUE);
+ XtAddCallback (descendant, XtNdestroyCallback,
+ FocusDestroyCallback, (XtPointer) widget);
+
+ AddFocusHandler(widget, descendant, pwi, psi, pdi,
+ oldTarget ? XtBuildEventMask(oldTarget) : 0);
+
+ if (widget != shell)
+ XtAddEventHandler(
+ shell,
+ FocusChangeMask | EnterWindowMask | LeaveWindowMask,
+ False,
+ _XtHandleFocus,
+ (XtPointer)psi
+ );
+
+ if (! XtIsRealized(target)) {
+ XtAddEventHandler(target, (EventMask)StructureNotifyMask,
+ False, QueryEventMask, (XtPointer)widget);
+ pwi->map_handler_added = TRUE;
+ pwi->queryEventDescendant = descendant;
+ }
+ }
+ }
+ hookobj = XtHooksOfDisplay(XtDisplay(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHsetKeyboardFocus;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer) descendant;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
diff --git a/nx-X11/lib/Xt/Manage.c b/nx-X11/lib/Xt/Manage.c
new file mode 100644
index 000000000..05957a2fa
--- /dev/null
+++ b/nx-X11/lib/Xt/Manage.c
@@ -0,0 +1,491 @@
+/* $Xorg: Manage.c,v 1.4 2001/02/09 02:03:55 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/Manage.c,v 3.10tsi Exp $ */
+
+/*
+
+Copyright 1987, 1988, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+
+static String XtNinvalidChild = "invalidChild";
+static String XtNxtUnmanageChildren = "xtUnmanageChildren";
+static String XtNxtManageChildren = "xtManageChildren";
+static String XtNxtChangeManagedSet = "xtChangeManagedSet";
+
+static void UnmanageChildren(
+ WidgetList children,
+ Cardinal num_children,
+ Widget parent,
+ Cardinal* num_unique_children,
+ Boolean call_change_managed,
+ String caller_func)
+{
+ Widget child;
+ Cardinal i;
+ XtWidgetProc change_managed = NULL;
+ Bool parent_realized = False;
+
+ *num_unique_children = 0;
+
+ if (XtIsComposite((Widget) parent)) {
+ LOCK_PROCESS;
+ change_managed = ((CompositeWidgetClass) parent->core.widget_class)
+ ->composite_class.change_managed;
+ UNLOCK_PROCESS;
+ parent_realized = XtIsRealized((Widget)parent);
+ } else {
+ XtAppErrorMsg(XtWidgetToApplicationContext((Widget)parent),
+ "invalidParent",caller_func, XtCXtToolkitError,
+ "Attempt to unmanage a child when parent is not Composite",
+ (String *) NULL, (Cardinal *) NULL);
+ }
+
+ for (i = 0; i < num_children; i++) {
+ child = children[i];
+ if (child == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(parent),
+ XtNinvalidChild,caller_func,XtCXtToolkitError,
+ "Null child passed to XtUnmanageChildren",
+ (String *)NULL, (Cardinal *)NULL);
+ return;
+ }
+ if (child->core.parent != parent) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(parent),
+ "ambiguousParent",caller_func,XtCXtToolkitError,
+ "Not all children have same parent in UnmanageChildren",
+ (String *)NULL, (Cardinal *)NULL);
+ } else
+ if (child->core.managed) {
+ (*num_unique_children)++;
+ CALLGEOTAT(_XtGeoTrace(child,"Child \"%s\" is marked unmanaged\n",
+ XtName(child)));
+ child->core.managed = FALSE;
+ if (XtIsWidget(child)
+ && XtIsRealized(child)
+ && child->core.mapped_when_managed)
+ XtUnmapWidget(child);
+ else
+ { /* RectObj child */
+ Widget pw = child->core.parent;
+ RectObj r = (RectObj) child;
+ while ((pw!=NULL) && (!XtIsWidget(pw))) pw = pw->core.parent;
+ if ((pw!=NULL) && XtIsRealized (pw))
+ XClearArea (XtDisplay (pw), XtWindow (pw),
+ r->rectangle.x, r->rectangle.y,
+ r->rectangle.width + (r->rectangle.border_width << 1),
+ r->rectangle.height + (r->rectangle.border_width << 1),
+ TRUE);
+ }
+
+ }
+ }
+ if (call_change_managed && *num_unique_children != 0 &&
+ change_managed != NULL && parent_realized) {
+ CALLGEOTAT(_XtGeoTrace((Widget)parent,
+ "Call parent: \"%s\"[%d,%d]'s changemanaged proc\n",
+ XtName((Widget)parent),
+ parent->core.width,parent->core.height));
+ (*change_managed) (parent);
+ }
+} /* UnmanageChildren */
+
+void XtUnmanageChildren (
+ WidgetList children,
+ Cardinal num_children)
+{
+ Widget parent, hookobj;
+ Cardinal ii;
+#ifdef XTHREADS
+ XtAppContext app;
+#endif
+
+ if (num_children == 0) return;
+ if (children[0] == NULL) {
+ XtWarningMsg(XtNinvalidChild,XtNxtUnmanageChildren,XtCXtToolkitError,
+ "Null child found in argument list to unmanage",
+ (String *)NULL, (Cardinal *)NULL);
+ return;
+ }
+#ifdef XTHREADS
+ app = XtWidgetToApplicationContext(children[0]);
+#endif
+ LOCK_APP(app);
+ parent = children[0]->core.parent;
+ if (parent->core.being_destroyed) {
+ UNLOCK_APP(app);
+ return;
+ }
+ UnmanageChildren(children, num_children, parent, &ii,
+ (Boolean)True, XtNxtUnmanageChildren);
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(children[0]));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHunmanageChildren;
+ call_data.widget = parent;
+ call_data.event_data = (XtPointer) children;
+ call_data.num_event_data = num_children;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ UNLOCK_APP(app);
+} /* XtUnmanageChildren */
+
+void XtUnmanageChild(
+ Widget child)
+{
+ XtUnmanageChildren(&child, (Cardinal)1);
+} /* XtUnmanageChild */
+
+
+static void ManageChildren(
+ WidgetList children,
+ Cardinal num_children,
+ Widget parent,
+ Boolean call_change_managed,
+ String caller_func)
+{
+#define MAXCHILDREN 100
+ Widget child;
+ Cardinal num_unique_children, i;
+ XtWidgetProc change_managed = NULL;
+ WidgetList unique_children;
+ Widget cache[MAXCHILDREN];
+ Bool parent_realized = False;
+
+ if (XtIsComposite((Widget) parent)) {
+ LOCK_PROCESS;
+ change_managed = ((CompositeWidgetClass) parent->core.widget_class)
+ ->composite_class.change_managed;
+ UNLOCK_PROCESS;
+ parent_realized = XtIsRealized((Widget)parent);
+ } else {
+ XtAppErrorMsg(XtWidgetToApplicationContext((Widget)parent),
+ "invalidParent",caller_func, XtCXtToolkitError,
+ "Attempt to manage a child when parent is not Composite",
+ (String *) NULL, (Cardinal *) NULL);
+ }
+
+ /* Construct new list of children that really need to be operated upon. */
+ if (num_children <= MAXCHILDREN) {
+ unique_children = cache;
+ } else {
+ unique_children = (WidgetList) __XtMalloc(num_children * sizeof(Widget));
+ }
+ num_unique_children = 0;
+ for (i = 0; i < num_children; i++) {
+ child = children[i];
+ if (child == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent),
+ XtNinvalidChild,caller_func,XtCXtToolkitError,
+ "null child passed to ManageChildren",
+ (String *)NULL, (Cardinal *)NULL);
+ if (unique_children != cache) XtFree((char *) unique_children);
+ return;
+ }
+#ifdef DEBUG
+ if (!XtIsRectObj(child)) {
+ String params[2];
+ Cardinal num_params = 2;
+ params[0] = XtName(child);
+ params[1] = child->core.widget_class->core_class.class_name;
+ XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent),
+ "notRectObj",caller_func,XtCXtToolkitError,
+ "child \"%s\", class %s is not a RectObj",
+ params, &num_params);
+ continue;
+ }
+#endif /*DEBUG*/
+ if (child->core.parent != parent) {
+ XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent),
+ "ambiguousParent",caller_func,XtCXtToolkitError,
+ "Not all children have same parent in XtManageChildren",
+ (String *)NULL, (Cardinal *)NULL);
+ } else if (! child->core.managed && !child->core.being_destroyed) {
+ unique_children[num_unique_children++] = child;
+ CALLGEOTAT(_XtGeoTrace(child,
+ "Child \"%s\"[%d,%d] is marked managed\n",
+ XtName(child),
+ child->core.width,child->core.height));
+ child->core.managed = TRUE;
+ }
+ }
+
+ if ((call_change_managed || num_unique_children != 0) && parent_realized) {
+ /* Compute geometry of new managed set of children. */
+ if (change_managed != NULL) {
+ CALLGEOTAT(_XtGeoTrace((Widget)parent,
+ "Call parent: \"%s\"[%d,%d]'s changemanaged\n",
+ XtName((Widget)parent),
+ parent->core.width,parent->core.height));
+ (*change_managed) ((Widget)parent);
+ }
+
+ /* Realize each child if necessary, then map if necessary */
+ for (i = 0; i < num_unique_children; i++) {
+ child = unique_children[i];
+ if (XtIsWidget(child)) {
+ if (! XtIsRealized(child)) XtRealizeWidget(child);
+ if (child->core.mapped_when_managed) XtMapWidget(child);
+ } else { /* RectObj child */
+ Widget pw = child->core.parent;
+ RectObj r = (RectObj) child;
+ while ((pw!=NULL) && (!XtIsWidget(pw)))
+ pw = pw->core.parent;
+ if (pw != NULL)
+ XClearArea (XtDisplay (pw), XtWindow (pw),
+ r->rectangle.x, r->rectangle.y,
+ r->rectangle.width + (r->rectangle.border_width << 1),
+ r->rectangle.height + (r->rectangle.border_width << 1),
+ TRUE);
+ }
+ }
+ }
+
+ if (unique_children != cache) XtFree((char *) unique_children);
+} /* ManageChildren */
+
+void XtManageChildren(
+ WidgetList children,
+ Cardinal num_children)
+{
+ Widget parent, hookobj;
+#ifdef XTHREADS
+ XtAppContext app;
+#endif
+
+ if (num_children == 0) return;
+ if (children[0] == NULL) {
+ XtWarningMsg(XtNinvalidChild, XtNxtManageChildren, XtCXtToolkitError,
+ "null child passed to XtManageChildren",
+ (String*)NULL, (Cardinal*)NULL);
+ return;
+ }
+#ifdef XTHREADS
+ app = XtWidgetToApplicationContext(children[0]);
+#endif
+ LOCK_APP(app);
+ parent = children[0]->core.parent;
+ if (parent->core.being_destroyed) {
+ UNLOCK_APP(app);
+ return;
+ }
+ ManageChildren(children, num_children, parent, (Boolean)False,
+ XtNxtManageChildren);
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(children[0]));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHmanageChildren;
+ call_data.widget = parent;
+ call_data.event_data = (XtPointer) children;
+ call_data.num_event_data = num_children;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ UNLOCK_APP(app);
+} /* XtManageChildren */
+
+void XtManageChild(
+ Widget child)
+{
+ XtManageChildren(&child, (Cardinal) 1);
+} /* XtManageChild */
+
+
+void XtSetMappedWhenManaged(
+ Widget widget,
+ _XtBoolean mapped_when_managed)
+{
+ Widget hookobj;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ if (widget->core.mapped_when_managed == mapped_when_managed) {
+ UNLOCK_APP(app);
+ return;
+ }
+ widget->core.mapped_when_managed = mapped_when_managed;
+
+ hookobj = XtHooksOfDisplay(XtDisplay(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHsetMappedWhenManaged;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer) (unsigned long) mapped_when_managed;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+
+ if (! XtIsManaged(widget)) {
+ UNLOCK_APP(app);
+ return;
+ }
+
+ if (mapped_when_managed) {
+ /* Didn't used to be mapped when managed. */
+ if (XtIsRealized(widget)) XtMapWidget(widget);
+ } else {
+ /* Used to be mapped when managed. */
+ if (XtIsRealized(widget)) XtUnmapWidget(widget);
+ }
+ UNLOCK_APP(app);
+} /* XtSetMappedWhenManaged */
+
+
+void XtChangeManagedSet(
+ WidgetList unmanage_children,
+ Cardinal num_unmanage,
+ XtDoChangeProc do_change_proc,
+ XtPointer client_data,
+ WidgetList manage_children,
+ Cardinal num_manage)
+{
+ WidgetList childp;
+ Widget parent;
+ int i;
+ Cardinal some_unmanaged;
+ Boolean call_out;
+ CompositeClassExtension ext;
+ XtAppContext app;
+ Widget hookobj;
+ XtChangeHookDataRec call_data;
+
+ if (num_unmanage == 0 && num_manage == 0)
+ return;
+
+ /* specification doesn't state that library will check for NULL in list */
+
+ childp = num_unmanage ? unmanage_children : manage_children;
+ app = XtWidgetToApplicationContext(*childp);
+ LOCK_APP(app);
+
+ parent = XtParent(*childp);
+ childp = unmanage_children;
+ for (i = num_unmanage; --i >= 0 && XtParent(*childp) == parent; childp++);
+ call_out = (i >= 0);
+ childp = manage_children;
+ for (i = num_manage; --i >= 0 && XtParent(*childp) == parent; childp++);
+ if (call_out || i >= 0) {
+ XtAppWarningMsg(app, "ambiguousParent", XtNxtChangeManagedSet,
+ XtCXtToolkitError, "Not all children have same parent",
+ (String *)NULL, (Cardinal *)NULL);
+ }
+ if (! XtIsComposite(parent)) {
+ UNLOCK_APP(app);
+ XtAppErrorMsg(app, "invalidParent", XtNxtChangeManagedSet,
+ XtCXtToolkitError,
+ "Attempt to manage a child when parent is not Composite",
+ (String *) NULL, (Cardinal *) NULL);
+ }
+ if (parent->core.being_destroyed) {
+ UNLOCK_APP(app);
+ return;
+ }
+
+ call_out = False;
+ if (do_change_proc) {
+ ext = (CompositeClassExtension)
+ XtGetClassExtension(parent->core.widget_class,
+ XtOffsetOf(CompositeClassRec,
+ composite_class.extension),
+ NULLQUARK, XtCompositeExtensionVersion,
+ sizeof(CompositeClassExtensionRec));
+ if (!ext || !ext->allows_change_managed_set)
+ call_out = True;
+ }
+
+ UnmanageChildren(unmanage_children, num_unmanage, parent,
+ &some_unmanaged, call_out, XtNxtChangeManagedSet);
+
+ hookobj = XtHooksOfDisplay(XtDisplay(parent));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ call_data.type = XtHunmanageSet;
+ call_data.widget = parent;
+ call_data.event_data = (XtPointer) unmanage_children;
+ call_data.num_event_data = num_unmanage;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer) &call_data);
+ }
+
+ if (do_change_proc)
+ (*do_change_proc)(parent, unmanage_children, &num_unmanage,
+ manage_children, &num_manage, client_data);
+
+ call_out = (some_unmanaged && !call_out);
+ ManageChildren(manage_children, num_manage, parent, call_out,
+ XtNxtChangeManagedSet);
+
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ call_data.type = XtHmanageSet;
+ call_data.event_data = (XtPointer) manage_children;
+ call_data.num_event_data = num_manage;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer) &call_data);
+ }
+ UNLOCK_APP(app);
+} /* XtChangeManagedSet */
diff --git a/nx-X11/lib/Xt/NextEvent.c b/nx-X11/lib/Xt/NextEvent.c
new file mode 100644
index 000000000..e6cd9cb06
--- /dev/null
+++ b/nx-X11/lib/Xt/NextEvent.c
@@ -0,0 +1,1642 @@
+/* $Xorg: NextEvent.c,v 1.8 2001/02/09 02:03:55 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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, 1994, 1998, 2001 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 (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/* $XFree86: xc/lib/Xt/NextEvent.c,v 3.26 2002/06/04 21:55:42 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include <stdio.h>
+#include <errno.h>
+
+#ifdef __UNIXOS2__
+#include <sys/time.h>
+#endif
+
+static TimerEventRec* freeTimerRecs;
+static WorkProcRec* freeWorkRecs;
+static SignalEventRec* freeSignalRecs;
+
+/* Some systems running NTP daemons are known to return strange usec
+ * values from gettimeofday.
+ */
+
+#ifndef NEEDS_NTPD_FIXUP
+# if defined(sun) || defined(MOTOROLA) || (defined(__osf__) && defined(__alpha))
+# define NEEDS_NTPD_FIXUP 1
+# else
+# define NEEDS_NTPD_FIXUP 0
+# endif
+#endif
+
+#if NEEDS_NTPD_FIXUP
+#define FIXUP_TIMEVAL(t) { \
+ while ((t).tv_usec >= 1000000) { \
+ (t).tv_usec -= 1000000; \
+ (t).tv_sec++; \
+ } \
+ while ((t).tv_usec < 0) { \
+ if ((t).tv_sec > 0) { \
+ (t).tv_usec += 1000000; \
+ (t).tv_sec--; \
+ } else { \
+ (t).tv_usec = 0; \
+ break; \
+ } \
+ }}
+#else
+#define FIXUP_TIMEVAL(t)
+#endif /*NEEDS_NTPD_FIXUP*/
+
+/*
+ * Private routines
+ */
+#define ADD_TIME(dest, src1, src2) { \
+ if(((dest).tv_usec = (src1).tv_usec + (src2).tv_usec) >= 1000000) {\
+ (dest).tv_usec -= 1000000;\
+ (dest).tv_sec = (src1).tv_sec + (src2).tv_sec + 1 ; \
+ } else { (dest).tv_sec = (src1).tv_sec + (src2).tv_sec ; \
+ if(((dest).tv_sec >= 1) && (((dest).tv_usec <0))) { \
+ (dest).tv_sec --;(dest).tv_usec += 1000000; } } }
+
+
+#define TIMEDELTA(dest, src1, src2) { \
+ if(((dest).tv_usec = (src1).tv_usec - (src2).tv_usec) < 0) {\
+ (dest).tv_usec += 1000000;\
+ (dest).tv_sec = (src1).tv_sec - (src2).tv_sec - 1;\
+ } else (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; }
+
+#define IS_AFTER(t1, t2) (((t2).tv_sec > (t1).tv_sec) \
+ || (((t2).tv_sec == (t1).tv_sec)&& ((t2).tv_usec > (t1).tv_usec)))
+
+#define IS_AT_OR_AFTER(t1, t2) (((t2).tv_sec > (t1).tv_sec) \
+ || (((t2).tv_sec == (t1).tv_sec)&& ((t2).tv_usec >= (t1).tv_usec)))
+
+#ifdef USE_POLL
+#ifndef XT_DEFAULT_FDLIST_SIZE
+#define XT_DEFAULT_FDLIST_SIZE 32
+#endif
+#endif
+
+static void AdjustHowLong (
+ unsigned long *howlong,
+ struct timeval *start_time)
+{
+ struct timeval new_time, time_spent, lstart_time;
+
+ lstart_time = *start_time;
+ X_GETTIMEOFDAY (&new_time);
+ FIXUP_TIMEVAL(new_time);
+ TIMEDELTA(time_spent, new_time, lstart_time);
+ if(*howlong <= (unsigned long)(time_spent.tv_sec*1000+time_spent.tv_usec/1000))
+ *howlong = (unsigned long)0; /* Timed out */
+ else
+ *howlong -= (time_spent.tv_sec*1000+time_spent.tv_usec/1000);
+}
+
+typedef struct {
+ struct timeval cur_time;
+ struct timeval start_time;
+ struct timeval wait_time;
+ struct timeval new_time;
+ struct timeval time_spent;
+ struct timeval max_wait_time;
+#ifndef USE_POLL
+ struct timeval *wait_time_ptr;
+#else
+ int poll_wait;
+#endif
+} wait_times_t, *wait_times_ptr_t;
+
+static struct timeval zero_time = { 0 , 0};
+#ifndef USE_POLL
+static fd_set zero_fd;
+#else
+#define X_BLOCK -1
+#define X_DONT_BLOCK 0
+#endif
+
+static void InitTimes (
+ Boolean block,
+ unsigned long* howlong,
+ wait_times_ptr_t wt)
+{
+ if (block) {
+ X_GETTIMEOFDAY (&wt->cur_time);
+ FIXUP_TIMEVAL(wt->cur_time);
+ wt->start_time = wt->cur_time;
+ if(howlong == NULL) { /* special case for ever */
+#ifndef USE_POLL
+ wt->wait_time_ptr = NULL;
+#else
+ wt->poll_wait = X_BLOCK;
+#endif
+ } else { /* block until at most */
+ wt->max_wait_time.tv_sec = *howlong/1000;
+ wt->max_wait_time.tv_usec = (*howlong %1000)*1000;
+#ifndef USE_POLL
+ wt->wait_time_ptr = &wt->max_wait_time;
+#else
+ wt->poll_wait = *howlong;
+#endif
+ }
+ } else { /* don't block */
+ wt->max_wait_time = zero_time;
+#ifndef USE_POLL
+ wt->wait_time_ptr = &wt->max_wait_time;
+#else
+ wt->poll_wait = X_DONT_BLOCK;
+#endif
+ }
+}
+
+typedef struct {
+#ifndef USE_POLL
+ fd_set rmask, wmask, emask;
+ int nfds;
+#else
+ struct pollfd* fdlist;
+ struct pollfd* stack;
+ int fdlistlen, num_dpys;
+#endif
+} wait_fds_t, *wait_fds_ptr_t;
+
+static void InitFds (
+ XtAppContext app,
+ Boolean ignoreEvents,
+ Boolean ignoreInputs,
+ wait_fds_ptr_t wf)
+{
+ int ii;
+ app->rebuild_fdlist = FALSE;
+#ifndef USE_POLL
+ wf->nfds = app->fds.nfds;
+ if( !ignoreInputs ) {
+ wf->rmask = app->fds.rmask;
+ wf->wmask = app->fds.wmask;
+ wf->emask = app->fds.emask;
+ } else
+ wf->rmask = wf->wmask = wf->emask = zero_fd;
+
+ if (!ignoreEvents)
+ for (ii = 0; ii < app->count; ii++) {
+ FD_SET (ConnectionNumber(app->list[ii]), &wf->rmask);
+ }
+#else
+#ifndef POLLRDNORM
+#define POLLRDNORM 0
+#endif
+
+#ifndef POLLRDBAND
+#define POLLRDBAND 0
+#endif
+
+#ifndef POLLWRNORM
+#define POLLWRNORM 0
+#endif
+
+#ifndef POLLWRBAND
+#define POLLWRBAND 0
+#endif
+
+#define XPOLL_READ (POLLIN|POLLRDNORM|POLLPRI|POLLRDBAND)
+#define XPOLL_WRITE (POLLOUT|POLLWRNORM|POLLWRBAND)
+#define XPOLL_EXCEPT 0
+
+ if (!ignoreEvents)
+ wf->fdlistlen = wf->num_dpys = app->count;
+ else
+ wf->fdlistlen = wf->num_dpys = 0;
+
+ if (!ignoreInputs && app->input_list != NULL) {
+ int ii;
+ for (ii = 0; ii < (int) app->input_max; ii++)
+ if (app->input_list[ii] != NULL)
+ wf->fdlistlen++;
+ }
+
+ if (!wf->fdlist || wf->fdlist == wf->stack) {
+ wf->fdlist = (struct pollfd*)
+ XtStackAlloc (sizeof (struct pollfd) * wf->fdlistlen, wf->stack);
+ } else {
+ wf->fdlist = (struct pollfd*)
+ XtRealloc ((char*) wf->fdlist,
+ sizeof (struct pollfd) * wf->fdlistlen);
+ }
+
+ if (wf->fdlistlen) {
+ struct pollfd* fdlp = wf->fdlist;
+ InputEvent* iep;
+
+ if (!ignoreEvents)
+ for (ii = 0 ; ii < wf->num_dpys; ii++, fdlp++) {
+ fdlp->fd = ConnectionNumber (app->list[ii]);
+ fdlp->events = POLLIN;
+ }
+ if (!ignoreInputs && app->input_list != NULL)
+ for (ii = 0; ii < app->input_max; ii++)
+ if (app->input_list[ii] != NULL) {
+ iep = app->input_list[ii];
+ fdlp->fd = ii;
+ fdlp->events = 0;
+ for ( ; iep; iep = iep->ie_next) {
+ if (iep->ie_condition & XtInputReadMask)
+ fdlp->events |= XPOLL_READ;
+ if (iep->ie_condition & XtInputWriteMask)
+ fdlp->events |= XPOLL_WRITE;
+ if (iep->ie_condition & XtInputExceptMask)
+ fdlp->events |= XPOLL_EXCEPT;
+ }
+ fdlp++;
+ }
+ }
+#endif
+}
+
+static void AdjustTimes (
+ XtAppContext app,
+ Boolean block,
+ unsigned long* howlong,
+ Boolean ignoreTimers,
+ wait_times_ptr_t wt)
+{
+ if (app->timerQueue != NULL && !ignoreTimers && block) {
+ if (IS_AFTER (wt->cur_time, app->timerQueue->te_timer_value)) {
+ TIMEDELTA (wt->wait_time, app->timerQueue->te_timer_value, wt->cur_time);
+ if (howlong == NULL || IS_AFTER (wt->wait_time, wt->max_wait_time))
+#ifndef USE_POLL
+ wt->wait_time_ptr = &wt->wait_time;
+ else
+ wt->wait_time_ptr = &wt->max_wait_time;
+ } else
+ wt->wait_time_ptr = &zero_time;
+ }
+#else
+ wt->poll_wait = wt->wait_time.tv_sec * 1000 + wt->wait_time.tv_usec / 1000;
+ else
+ wt->poll_wait = wt->max_wait_time.tv_sec * 1000 + wt->max_wait_time.tv_usec / 1000;
+ } else
+ wt->poll_wait = X_DONT_BLOCK;
+ }
+#endif
+}
+
+
+static int IoWait (
+ wait_times_ptr_t wt,
+ wait_fds_ptr_t wf)
+{
+#ifndef USE_POLL
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+
+ fprintf(stderr, "Xt::IoWait: Select called with [%d][%p][%p][%p][%p].\n",
+ wf->nfds, (void *) &wf->rmask, (void *) &wf->wmask, (void *) &wf->emask,
+ (void *) wt->wait_time_ptr);
+#endif
+
+ return Select (wf->nfds, &wf->rmask, &wf->wmask, &wf->emask,
+ wt->wait_time_ptr);
+#else
+ return poll (wf->fdlist, wf->fdlistlen, wt->poll_wait);
+#endif
+}
+
+
+static void FindInputs (
+ XtAppContext app,
+ wait_fds_ptr_t wf,
+ int nfds,
+ Boolean ignoreEvents,
+ Boolean ignoreInputs,
+ int* dpy_no,
+ int* found_input)
+{
+ XtInputMask condition;
+ InputEvent *ep;
+ int ii;
+#ifndef USE_POLL /* { check ready file descriptors block */
+#ifdef XTHREADS
+ fd_set rmask;
+#endif
+ int dd;
+ *dpy_no = -1;
+ *found_input = False;
+
+#ifdef XTHREADS
+ rmask = app->fds.rmask;
+ for (dd = app->count; dd-- > 0; )
+ FD_SET (ConnectionNumber (app->list[dd]), &rmask);
+#endif
+
+ for (ii = 0; ii < wf->nfds && nfds > 0; ii++) {
+ condition = 0;
+ if (FD_ISSET (ii, &wf->rmask)
+#ifdef XTHREADS
+ && FD_ISSET (ii, &rmask)
+#endif
+ ) {
+ nfds--;
+ if (!ignoreEvents) {
+ for (dd = 0; dd < app->count; dd++) {
+ if (ii == ConnectionNumber (app->list[dd])) {
+ if (*dpy_no == -1) {
+ if (XEventsQueued (app->list[dd], QueuedAfterReading ))
+ *dpy_no = dd;
+ /*
+ * An error event could have arrived
+ * without any real events, or events
+ * could have been swallowed by Xlib,
+ * or the connection may be broken.
+ * We can't tell the difference, so
+ * assume Xlib will eventually discover
+ * a broken connection.
+ */
+ }
+ goto ENDILOOP;
+ }
+ }
+ }
+ condition = XtInputReadMask;
+ }
+ if (FD_ISSET (ii, &wf->wmask)
+#ifdef XTHREADS
+ && FD_ISSET (ii, &app->fds.wmask)
+#endif
+ ) {
+ condition |= XtInputWriteMask;
+ nfds--;
+ }
+ if (FD_ISSET (ii, &wf->emask)
+#ifdef XTHREADS
+ && FD_ISSET (ii, &app->fds.emask)
+#endif
+ ) {
+ condition |= XtInputExceptMask;
+ nfds--;
+ }
+ if (condition) {
+ for (ep = app->input_list[ii]; ep; ep = ep->ie_next)
+ if (condition & ep->ie_condition) {
+ /* make sure this input isn't already marked outstanding */
+ InputEvent *oq;
+ for (oq = app->outstandingQueue; oq; oq = oq->ie_oq)
+ if (oq == ep)
+ break;
+ if (!oq)
+ {
+ ep->ie_oq = app->outstandingQueue;
+ app->outstandingQueue = ep;
+ }
+ }
+ *found_input = True;
+ }
+ENDILOOP: ;
+ } /* endfor */
+#else /* }{ */
+ struct pollfd* fdlp;
+
+ *dpy_no = -1;
+ *found_input = False;
+
+ if (!ignoreEvents) {
+ fdlp = wf->fdlist;
+ for (ii = 0; ii < wf->num_dpys; ii++, fdlp++) {
+ if (*dpy_no == -1 && fdlp->revents & (POLLIN|POLLHUP|POLLERR) &&
+#ifdef XTHREADS
+ !(fdlp->revents & POLLNVAL) &&
+#endif
+ XEventsQueued (app->list[ii], QueuedAfterReading)) {
+ *dpy_no = ii;
+ break;
+ }
+ }
+ }
+
+ if (!ignoreInputs) {
+ fdlp = &wf->fdlist[wf->num_dpys];
+ for (ii = wf->num_dpys; ii < wf->fdlistlen; ii++, fdlp++) {
+ condition = 0;
+ if (fdlp->revents) {
+ if (fdlp->revents & (XPOLL_READ|POLLHUP|POLLERR)
+#ifdef XTHREADS
+ && !(fdlp->revents & POLLNVAL)
+#endif
+ )
+ condition = XtInputReadMask;
+ if (fdlp->revents & XPOLL_WRITE)
+ condition |= XtInputWriteMask;
+ if (fdlp->revents & XPOLL_EXCEPT)
+ condition |= XtInputExceptMask;
+ }
+ if (condition) {
+ *found_input = True;
+ for (ep = app->input_list[fdlp->fd]; ep; ep = ep->ie_next)
+ if (condition & ep->ie_condition) {
+ InputEvent *oq;
+ /* make sure this input isn't already marked outstanding */
+ for (oq = app->outstandingQueue; oq; oq = oq->ie_oq)
+ if (oq == ep)
+ break;
+ if (!oq)
+ {
+ ep->ie_oq = app->outstandingQueue;
+ app->outstandingQueue = ep;
+ }
+ }
+ }
+ }
+ }
+#endif /* } */
+}
+
+/*
+ * Routine to block in the toolkit. This should be the only call to select.
+ *
+ * This routine returns when there is something to be done.
+ *
+ * Before calling this with ignoreInputs==False, app->outstandingQueue should
+ * be checked; this routine will not verify that an alternate input source
+ * has not already been enqueued.
+ *
+ *
+ * _XtWaitForSomething( appContext,
+ * ignoreEvent, ignoreTimers, ignoreInputs, ignoreSignals,
+ * block, drop_lock, howlong)
+ * XtAppContext app; (Displays to check wait on)
+ *
+ * Boolean ignoreEvents; (Don't return if XEvents are available
+ * Also implies forget XEvents exist)
+ *
+ * Boolean ignoreTimers; (Ditto for timers)
+ *
+ * Boolean ignoreInputs; (Ditto for input callbacks )
+ *
+ * Boolean ignoreSignals; (Ditto for signals)
+ *
+ * Boolean block; (Okay to block)
+ *
+ * Boolean drop_lock (drop lock before going into select/poll)
+ *
+ * TimeVal howlong; (howlong to wait for if blocking and not
+ * doing Timers... Null means forever.
+ * Maybe should mean shortest of both)
+ * Returns display for which input is available, if any
+ * and if ignoreEvents==False, else returns -1
+ *
+ * if ignoring everything && block=True && howlong=NULL, you'll have
+ * lots of time for coffee; better not try it! In fact, it probably
+ * makes little sense to do this regardless of the value of howlong
+ * (bottom line is, we don't bother checking here).
+ *
+ * If drop_lock is FALSE, the app->lock->mutex is not unlocked before
+ * entering select/poll. It is illegal for drop_lock to be FALSE if
+ * ignoreTimers, ignoreInputs, or ignoreSignals is FALSE.
+ */
+int _XtWaitForSomething(
+ XtAppContext app,
+ _XtBoolean ignoreEvents,
+ _XtBoolean ignoreTimers,
+ _XtBoolean ignoreInputs,
+ _XtBoolean ignoreSignals,
+ _XtBoolean block,
+#ifdef XTHREADS
+ _XtBoolean drop_lock,
+#endif
+ unsigned long *howlong)
+{
+ wait_times_t wt;
+ wait_fds_t wf;
+ int nfds, dpy_no, found_input, dd;
+#ifdef XTHREADS
+ Boolean push_thread = TRUE;
+ Boolean pushed_thread = FALSE;
+ int level = 0;
+#endif
+#ifdef USE_POLL
+ struct pollfd fdlist[XT_DEFAULT_FDLIST_SIZE];
+#endif
+
+#ifdef XTHREADS
+ /* assert ((ignoreTimers && ignoreInputs && ignoreSignals) || drop_lock); */
+ /* If not multi-threaded, never drop lock */
+ if (app->lock == (ThreadAppProc) NULL)
+ drop_lock = FALSE;
+#endif
+
+ InitTimes (block, howlong, &wt);
+
+#ifdef USE_POLL
+ wf.fdlist = NULL;
+ wf.stack = fdlist;
+#endif
+
+ app->rebuild_fdlist = TRUE;
+
+ while (1) {
+WaitLoop:
+ AdjustTimes (app, block, howlong, ignoreTimers, &wt);
+
+ if (block && app->block_hook_list) {
+ BlockHook hook;
+ for (hook = app->block_hook_list;
+ hook != NULL;
+ hook = hook->next)
+ (*hook->proc) (hook->closure);
+
+ if (!ignoreEvents)
+ /* see if the hook(s) generated any protocol */
+ for (dd = 0; dd < app->count; dd++)
+ if (XEventsQueued(app->list[dd], QueuedAlready)) {
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return dd;
+ }
+ }
+
+ if (app->rebuild_fdlist)
+ InitFds (app, ignoreEvents, ignoreInputs, &wf);
+
+#ifdef XTHREADS /* { */
+ if (drop_lock) {
+ YIELD_APP_LOCK(app, &push_thread, &pushed_thread, &level);
+ nfds = IoWait (&wt, &wf);
+ RESTORE_APP_LOCK(app, level, &pushed_thread);
+ } else
+#endif /* } */
+ nfds = IoWait (&wt, &wf);
+ if (nfds == -1) {
+ /*
+ * interrupt occured recalculate time value and wait again.
+ */
+ if (errno == EINTR || errno == EAGAIN) {
+ if (errno == EAGAIN) {
+ errno = 0; /* errno is not self reseting */
+ continue;
+ }
+ errno = 0; /* errno is not self reseting */
+
+ /* was it interrupted by a signal that we care about? */
+ if (!ignoreSignals && app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice) {
+ if (block && howlong != NULL)
+ AdjustHowLong (howlong, &wt.start_time);
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return -1;
+ }
+ se_ptr = se_ptr->se_next;
+ }
+ }
+
+ if (!ignoreEvents)
+ /* get Xlib to detect a bad connection */
+ for (dd = 0; dd < app->count; dd++)
+ if (XEventsQueued(app->list[dd], QueuedAfterReading)) {
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return dd;
+ }
+
+ if (block) {
+#ifndef USE_POLL
+ if (wt.wait_time_ptr == NULL)
+#else
+ if (wt.poll_wait == X_BLOCK)
+#endif
+ continue;
+ X_GETTIMEOFDAY (&wt.new_time);
+ FIXUP_TIMEVAL (wt.new_time);
+ TIMEDELTA (wt.time_spent, wt.new_time, wt.cur_time);
+ wt.cur_time = wt.new_time;
+#ifndef USE_POLL
+ if (IS_AFTER (wt.time_spent, *wt.wait_time_ptr)) {
+ TIMEDELTA (wt.wait_time, *wt.wait_time_ptr, wt.time_spent);
+ wt.wait_time_ptr = &wt.wait_time;
+ continue;
+ } else
+#else
+ if ((wt.time_spent.tv_sec * 1000 + wt.time_spent.tv_usec / 1000) < wt.poll_wait) {
+ wt.poll_wait -= (wt.time_spent.tv_sec * 1000 + wt.time_spent.tv_usec / 1000);
+ continue;
+ } else
+#endif
+ nfds = 0;
+ }
+ } else {
+ char Errno[12];
+ String param = Errno;
+ Cardinal param_count = 1;
+
+ sprintf( Errno, "%d", errno);
+ XtAppWarningMsg(app, "communicationError","select",
+ XtCXtToolkitError,"Select failed; error code %s",
+ &param, &param_count);
+ continue;
+ }
+ } /* timed out or input available */
+ break;
+ }
+
+ if (nfds == 0) {
+ /* Timed out */
+ if (howlong)
+ *howlong = (unsigned long)0;
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return -1;
+ }
+
+ if (block && howlong != NULL)
+ AdjustHowLong (howlong, &wt.start_time);
+
+ if (ignoreInputs && ignoreEvents) {
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return -1;
+ } else
+ FindInputs (app, &wf, nfds,
+ ignoreEvents, ignoreInputs,
+ &dpy_no, &found_input);
+
+ if (dpy_no >= 0 || found_input) {
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return dpy_no;
+ }
+ goto WaitLoop;
+}
+
+#define IeCallProc(ptr) \
+ (*ptr->ie_proc) (ptr->ie_closure, &ptr->ie_source, (XtInputId*)&ptr);
+
+#define TeCallProc(ptr) \
+ (*ptr->te_proc) (ptr->te_closure, (XtIntervalId*)&ptr);
+
+#define SeCallProc(ptr) \
+ (*ptr->se_proc) (ptr->se_closure, (XtSignalId*)&ptr);
+
+/*
+ * Public Routines
+ */
+
+XtIntervalId XtAddTimeOut(
+ unsigned long interval,
+ XtTimerCallbackProc proc,
+ XtPointer closure)
+{
+ return XtAppAddTimeOut(_XtDefaultAppContext(),
+ interval, proc, closure);
+}
+
+static void QueueTimerEvent(
+ XtAppContext app,
+ TimerEventRec *ptr)
+{
+ TimerEventRec *t,**tt;
+ tt = &app->timerQueue;
+ t = *tt;
+ while (t != NULL &&
+ IS_AFTER(t->te_timer_value, ptr->te_timer_value)) {
+ tt = &t->te_next;
+ t = *tt;
+ }
+ ptr->te_next = t;
+ *tt = ptr;
+}
+
+XtIntervalId XtAppAddTimeOut(
+ XtAppContext app,
+ unsigned long interval,
+ XtTimerCallbackProc proc,
+ XtPointer closure)
+{
+ TimerEventRec *tptr;
+ struct timeval current_time;
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if (freeTimerRecs) {
+ tptr = freeTimerRecs;
+ freeTimerRecs = tptr->te_next;
+ }
+ else tptr = XtNew(TimerEventRec);
+ UNLOCK_PROCESS;
+
+ tptr->te_next = NULL;
+ tptr->te_closure = closure;
+ tptr->te_proc = proc;
+ tptr->app = app;
+ tptr->te_timer_value.tv_sec = interval/1000;
+ tptr->te_timer_value.tv_usec = (interval%1000)*1000;
+ X_GETTIMEOFDAY (&current_time);
+ FIXUP_TIMEVAL(current_time);
+ ADD_TIME(tptr->te_timer_value,tptr->te_timer_value,current_time);
+ QueueTimerEvent(app, tptr);
+ UNLOCK_APP(app);
+ return( (XtIntervalId) tptr);
+}
+
+void XtRemoveTimeOut(
+ XtIntervalId id)
+{
+ TimerEventRec *t, *last, *tid = (TimerEventRec *) id;
+ XtAppContext app = tid->app;
+
+ /* find it */
+ LOCK_APP(app);
+ for(t = app->timerQueue, last = NULL;
+ t != NULL && t != tid;
+ t = t->te_next) last = t;
+
+ if (t == NULL) {
+ UNLOCK_APP(app);
+ return; /* couldn't find it */
+ }
+ if(last == NULL) { /* first one on the list */
+ app->timerQueue = t->te_next;
+ } else last->te_next = t->te_next;
+
+ LOCK_PROCESS;
+ t->te_next = freeTimerRecs;
+ freeTimerRecs = t;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+XtWorkProcId XtAddWorkProc(
+ XtWorkProc proc,
+ XtPointer closure)
+{
+ return XtAppAddWorkProc(_XtDefaultAppContext(), proc, closure);
+}
+
+XtWorkProcId XtAppAddWorkProc(
+ XtAppContext app,
+ XtWorkProc proc,
+ XtPointer closure)
+{
+ WorkProcRec *wptr;
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if (freeWorkRecs) {
+ wptr = freeWorkRecs;
+ freeWorkRecs = wptr->next;
+ } else wptr = XtNew(WorkProcRec);
+ UNLOCK_PROCESS;
+ wptr->next = app->workQueue;
+ wptr->closure = closure;
+ wptr->proc = proc;
+ wptr->app = app;
+ app->workQueue = wptr;
+ UNLOCK_APP(app);
+ return (XtWorkProcId) wptr;
+}
+
+void XtRemoveWorkProc(
+ XtWorkProcId id)
+{
+ WorkProcRec *wid= (WorkProcRec *) id, *w, *last;
+ XtAppContext app = wid->app;
+
+ LOCK_APP(app);
+ /* find it */
+ for(w = app->workQueue, last = NULL;
+ w != NULL && w != wid; w = w->next) last = w;
+
+ if (w == NULL) {
+ UNLOCK_APP(app);
+ return; /* couldn't find it */
+ }
+
+ if(last == NULL) app->workQueue = w->next;
+ else last->next = w->next;
+ LOCK_PROCESS;
+ w->next = freeWorkRecs;
+ freeWorkRecs = w;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+XtSignalId XtAddSignal(
+ XtSignalCallbackProc proc,
+ XtPointer closure)
+{
+ return XtAppAddSignal(_XtDefaultAppContext(), proc, closure);
+}
+
+XtSignalId XtAppAddSignal(
+ XtAppContext app,
+ XtSignalCallbackProc proc,
+ XtPointer closure)
+{
+ SignalEventRec *sptr;
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if (freeSignalRecs) {
+ sptr = freeSignalRecs;
+ freeSignalRecs = sptr->se_next;
+ } else
+ sptr = XtNew(SignalEventRec);
+ UNLOCK_PROCESS;
+ sptr->se_next = app->signalQueue;
+ sptr->se_closure = closure;
+ sptr->se_proc = proc;
+ sptr->app = app;
+ sptr->se_notice = FALSE;
+ app->signalQueue = sptr;
+ UNLOCK_APP(app);
+ return (XtSignalId) sptr;
+}
+
+void XtRemoveSignal(
+ XtSignalId id)
+{
+ SignalEventRec *sid = (SignalEventRec*) id, *s, *last = NULL;
+ XtAppContext app = sid->app;
+
+ LOCK_APP(app);
+ for (s = app->signalQueue; s != NULL && s != sid; s = s->se_next)
+ last = s;
+ if (s == NULL) {
+ UNLOCK_APP(app);
+ return;
+ }
+ if (last == NULL)
+ app->signalQueue = s->se_next;
+ else
+ last->se_next = s->se_next;
+ LOCK_PROCESS;
+ s->se_next = freeSignalRecs;
+ freeSignalRecs = s;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+void XtNoticeSignal(
+ XtSignalId id)
+{
+ /*
+ * It would be overkill to lock the app to set this flag.
+ * In the worst case, 2..n threads would be modifying this
+ * flag. The last one wins. Since signals occur asynchronously
+ * anyway, this can occur with or without threads.
+ *
+ * The other issue is that thread t1 sets the flag in a
+ * signalrec that has been deleted in thread t2. We rely
+ * on a detail of the implementation, i.e. free'd signalrecs
+ * aren't really free'd, they're just moved to a list of
+ * free recs, so deref'ing one won't hurt anything.
+ *
+ * Lastly, and perhaps most importantly, since POSIX threads
+ * says that the handling of asynchronous signals in a synchronous
+ * threads environment is undefined. Therefor it would be an
+ * error for both signals and threads to be in use in the same
+ * program.
+ */
+ SignalEventRec *sid = (SignalEventRec*) id;
+ sid->se_notice = TRUE;
+}
+
+XtInputId XtAddInput(
+ int source,
+ XtPointer Condition,
+ XtInputCallbackProc proc,
+ XtPointer closure)
+{
+ return XtAppAddInput(_XtDefaultAppContext(),
+ source, Condition, proc, closure);
+}
+
+XtInputId XtAppAddInput(
+ XtAppContext app,
+ int source,
+ XtPointer Condition,
+ XtInputCallbackProc proc,
+ XtPointer closure)
+{
+ InputEvent* sptr;
+ XtInputMask condition = (XtInputMask) Condition;
+
+ LOCK_APP(app);
+ if (!condition ||
+ condition & ~(XtInputReadMask|XtInputWriteMask|XtInputExceptMask))
+ XtAppErrorMsg(app,"invalidParameter","xtAddInput",XtCXtToolkitError,
+ "invalid condition passed to XtAppAddInput",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if (app->input_max <= source) {
+ Cardinal n = source + 1;
+ int ii;
+ app->input_list = (InputEvent**)XtRealloc((char*) app->input_list,
+ n * sizeof(InputEvent*));
+ for (ii = app->input_max; ii < (int) n; ii++)
+ app->input_list[ii] = (InputEvent*) NULL;
+ app->input_max = n;
+ }
+ sptr = XtNew(InputEvent);
+ sptr->ie_proc = proc;
+ sptr->ie_closure = closure;
+ sptr->app = app;
+ sptr->ie_oq = NULL;
+ sptr->ie_source = source;
+ sptr->ie_condition = condition;
+ sptr->ie_next = app->input_list[source];
+ app->input_list[source] = sptr;
+
+#ifndef USE_POLL
+ if (condition & XtInputReadMask) FD_SET(source, &app->fds.rmask);
+ if (condition & XtInputWriteMask) FD_SET(source, &app->fds.wmask);
+ if (condition & XtInputExceptMask) FD_SET(source, &app->fds.emask);
+
+ if (app->fds.nfds < (source+1)) app->fds.nfds = source+1;
+#else
+ if (sptr->ie_next == NULL)
+ app->fds.nfds++;
+#endif
+ app->input_count++;
+ app->rebuild_fdlist = TRUE;
+ UNLOCK_APP(app);
+ return((XtInputId)sptr);
+}
+
+void XtRemoveInput(
+ register XtInputId id)
+{
+ register InputEvent *sptr, *lptr;
+ XtAppContext app = ((InputEvent *)id)->app;
+ register int source = ((InputEvent *)id)->ie_source;
+ Boolean found = False;
+
+ LOCK_APP(app);
+ sptr = app->outstandingQueue;
+ lptr = NULL;
+ for (; sptr != NULL; sptr = sptr->ie_oq) {
+ if (sptr == (InputEvent *)id) {
+ if (lptr == NULL) app->outstandingQueue = sptr->ie_oq;
+ else lptr->ie_oq = sptr->ie_oq;
+ }
+ lptr = sptr;
+ }
+
+ if(app->input_list && (sptr = app->input_list[source]) != NULL) {
+ for( lptr = NULL ; sptr; sptr = sptr->ie_next ){
+ if(sptr == (InputEvent *) id) {
+#ifndef USE_POLL
+ XtInputMask condition = 0;
+#endif
+ if(lptr == NULL) {
+ app->input_list[source] = sptr->ie_next;
+ } else {
+ lptr->ie_next = sptr->ie_next;
+ }
+#ifndef USE_POLL
+ for (lptr = app->input_list[source];
+ lptr; lptr = lptr->ie_next)
+ condition |= lptr->ie_condition;
+ if ((sptr->ie_condition & XtInputReadMask) &&
+ !(condition & XtInputReadMask))
+ FD_CLR(source, &app->fds.rmask);
+ if ((sptr->ie_condition & XtInputWriteMask) &&
+ !(condition & XtInputWriteMask))
+ FD_CLR(source, &app->fds.wmask);
+ if ((sptr->ie_condition & XtInputExceptMask) &&
+ !(condition & XtInputExceptMask))
+ FD_CLR(source, &app->fds.emask);
+#endif
+ XtFree((char *) sptr);
+ found = True;
+ break;
+ }
+ lptr = sptr;
+ }
+ }
+
+ if (found) {
+ app->input_count--;
+#ifdef USE_POLL
+ if (app->input_list[source] == NULL)
+ app->fds.nfds--;
+#endif
+ app->rebuild_fdlist = TRUE;
+ } else
+ XtAppWarningMsg(app, "invalidProcedure","inputHandler",
+ XtCXtToolkitError,
+ "XtRemoveInput: Input handler not found",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_APP(app);
+}
+
+void _XtRemoveAllInputs(
+ XtAppContext app)
+{
+ int i;
+ for (i = 0; i < app->input_max; i++) {
+ InputEvent* ep = app->input_list[i];
+ while (ep) {
+ InputEvent *next = ep->ie_next;
+ XtFree( (char*)ep );
+ ep = next;
+ }
+ }
+ XtFree((char *) app->input_list);
+}
+
+/* Do alternate input and timer callbacks if there are any */
+
+static void DoOtherSources(
+ XtAppContext app)
+{
+ TimerEventRec *te_ptr;
+ InputEvent *ie_ptr;
+ struct timeval cur_time;
+
+#define DrainQueue() \
+ for (ie_ptr = app->outstandingQueue; ie_ptr != NULL;) { \
+ app->outstandingQueue = ie_ptr->ie_oq; \
+ ie_ptr ->ie_oq = NULL; \
+ IeCallProc(ie_ptr); \
+ ie_ptr = app->outstandingQueue; \
+ }
+/*enddef*/
+ DrainQueue();
+ if (app->input_count > 0) {
+ /* Call _XtWaitForSomething to get input queued up */
+ (void) _XtWaitForSomething (app,
+ TRUE, TRUE, FALSE, TRUE,
+ FALSE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *)NULL);
+ DrainQueue();
+ }
+ if (app->timerQueue != NULL) { /* check timeout queue */
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ while(IS_AT_OR_AFTER (app->timerQueue->te_timer_value, cur_time)) {
+ te_ptr = app->timerQueue;
+ app->timerQueue = te_ptr->te_next;
+ te_ptr->te_next = NULL;
+ if (te_ptr->te_proc != NULL)
+ TeCallProc(te_ptr);
+ LOCK_PROCESS;
+ te_ptr->te_next = freeTimerRecs;
+ freeTimerRecs = te_ptr;
+ UNLOCK_PROCESS;
+ if (app->timerQueue == NULL) break;
+ }
+ }
+ if (app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice) {
+ se_ptr->se_notice = FALSE;
+ if (se_ptr->se_proc != NULL)
+ SeCallProc(se_ptr);
+ }
+ se_ptr = se_ptr->se_next;
+ }
+ }
+#undef DrainQueue
+}
+
+/* If there are any work procs, call them. Return whether we did so */
+
+static Boolean CallWorkProc(
+ XtAppContext app)
+{
+ register WorkProcRec *w = app->workQueue;
+ Boolean delete;
+
+ if (w == NULL) return FALSE;
+
+ app->workQueue = w->next;
+
+ delete = (*(w->proc)) (w->closure);
+
+ if (delete) {
+ LOCK_PROCESS;
+ w->next = freeWorkRecs;
+ freeWorkRecs = w;
+ UNLOCK_PROCESS;
+ }
+ else {
+ w->next = app->workQueue;
+ app->workQueue = w;
+ }
+ return TRUE;
+}
+
+/*
+ * XtNextEvent()
+ * return next event;
+ */
+
+void XtNextEvent(
+ XEvent *event)
+{
+ XtAppNextEvent(_XtDefaultAppContext(), event);
+}
+
+void _XtRefreshMapping(
+ XEvent* event,
+ _XtBoolean dispatch)
+{
+ XtPerDisplay pd;
+
+ LOCK_PROCESS;
+ pd = _XtGetPerDisplay(event->xmapping.display);
+ if (event->xmapping.request != MappingPointer &&
+ pd && pd->keysyms && (event->xmapping.serial >= pd->keysyms_serial))
+ _XtBuildKeysymTables( event->xmapping.display, pd );
+ XRefreshKeyboardMapping(&event->xmapping);
+ if (dispatch && pd && pd->mapping_callbacks)
+ XtCallCallbackList((Widget) NULL,
+ (XtCallbackList)pd->mapping_callbacks,
+ (XtPointer)event );
+ UNLOCK_PROCESS;
+}
+
+void XtAppNextEvent(
+ XtAppContext app,
+ XEvent *event)
+{
+ int i, d;
+
+ LOCK_APP(app);
+ for (;;) {
+ if (app->count == 0)
+ DoOtherSources(app);
+ else {
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (d == 0) DoOtherSources(app);
+ if (XEventsQueued(app->list[d], QueuedAfterReading))
+ goto GotEvent;
+ }
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (XEventsQueued(app->list[d], QueuedAfterFlush))
+ goto GotEvent;
+ }
+ }
+
+ /* We're ready to wait...if there is a work proc, call it */
+ if (CallWorkProc(app)) continue;
+
+ d = _XtWaitForSomething (app,
+ FALSE, FALSE, FALSE, FALSE,
+ TRUE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *) NULL);
+
+ if (d != -1) {
+ GotEvent:
+ XNextEvent (app->list[d], event);
+#ifdef XTHREADS
+ /* assert(app->list[d] == event->xany.display); */
+#endif
+ app->last = d;
+ if (event->xany.type == MappingNotify)
+ _XtRefreshMapping(event, False);
+ UNLOCK_APP(app);
+ return;
+ }
+
+ } /* for */
+}
+
+void XtProcessEvent(
+ XtInputMask mask)
+{
+ XtAppProcessEvent(_XtDefaultAppContext(), mask);
+}
+
+void XtAppProcessEvent(
+ XtAppContext app,
+ XtInputMask mask)
+{
+ int i, d;
+ XEvent event;
+ struct timeval cur_time;
+
+ LOCK_APP(app);
+ if (mask == 0) {
+ UNLOCK_APP(app);
+ return;
+ }
+
+ for (;;) {
+
+ if (mask & XtIMSignal && app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice) {
+ se_ptr->se_notice = FALSE;
+ SeCallProc(se_ptr);
+ UNLOCK_APP(app);
+ return;
+ }
+ se_ptr = se_ptr->se_next;
+ }
+ }
+
+ if (mask & XtIMTimer && app->timerQueue != NULL) {
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ if (IS_AT_OR_AFTER(app->timerQueue->te_timer_value, cur_time)){
+ TimerEventRec *te_ptr = app->timerQueue;
+ app->timerQueue = app->timerQueue->te_next;
+ te_ptr->te_next = NULL;
+ if (te_ptr->te_proc != NULL)
+ TeCallProc(te_ptr);
+ LOCK_PROCESS;
+ te_ptr->te_next = freeTimerRecs;
+ freeTimerRecs = te_ptr;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return;
+ }
+ }
+
+ if (mask & XtIMAlternateInput) {
+ if (app->input_count > 0 && app->outstandingQueue == NULL) {
+ /* Call _XtWaitForSomething to get input queued up */
+ (void) _XtWaitForSomething (app,
+ TRUE, TRUE, FALSE, TRUE,
+ FALSE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *)NULL);
+ }
+ if (app->outstandingQueue != NULL) {
+ InputEvent *ie_ptr = app->outstandingQueue;
+ app->outstandingQueue = ie_ptr->ie_oq;
+ ie_ptr->ie_oq = NULL;
+ IeCallProc(ie_ptr);
+ UNLOCK_APP(app);
+ return;
+ }
+ }
+
+ if (mask & XtIMXEvent) {
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (XEventsQueued(app->list[d], QueuedAfterReading))
+ goto GotEvent;
+ }
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (XEventsQueued(app->list[d], QueuedAfterFlush))
+ goto GotEvent;
+ }
+ }
+
+ /* Nothing to do...wait for something */
+
+ if (CallWorkProc(app)) continue;
+
+ d = _XtWaitForSomething (app,
+ (mask & XtIMXEvent ? FALSE : TRUE),
+ (mask & XtIMTimer ? FALSE : TRUE),
+ (mask & XtIMAlternateInput ? FALSE : TRUE),
+ (mask & XtIMSignal ? FALSE : TRUE),
+ TRUE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *) NULL);
+
+ if (mask & XtIMXEvent && d != -1) {
+ GotEvent:
+ XNextEvent(app->list[d], &event);
+#ifdef XTHREADS
+ /* assert(app->list[d] == event.xany.display); */
+#endif
+ app->last = d;
+ if (event.xany.type == MappingNotify) {
+ _XtRefreshMapping(&event, False);
+ }
+ XtDispatchEvent(&event);
+ UNLOCK_APP(app);
+ return;
+ }
+
+ }
+}
+
+Boolean XtPending(void)
+{
+ return (XtAppPending(_XtDefaultAppContext()) != 0);
+}
+
+XtInputMask XtAppPending(
+ XtAppContext app)
+{
+ struct timeval cur_time;
+ int d;
+ XtInputMask ret = 0;
+
+/*
+ * Check for pending X events
+ */
+ LOCK_APP(app);
+ for (d = 0; d < app->count; d++) {
+ if (XEventsQueued(app->list[d], QueuedAfterReading)) {
+ ret = XtIMXEvent;
+ break;
+ }
+ }
+ if (ret == 0) {
+ for (d = 0; d < app->count; d++) {
+ if (XEventsQueued(app->list[d], QueuedAfterFlush)) {
+ ret = XtIMXEvent;
+ break;
+ }
+ }
+ }
+
+ if (app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice) {
+ ret |= XtIMSignal;
+ break;
+ }
+ se_ptr = se_ptr->se_next;
+ }
+ }
+
+/*
+ * Check for pending alternate input
+ */
+ if (app->timerQueue != NULL) { /* check timeout queue */
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ if ((IS_AT_OR_AFTER(app->timerQueue->te_timer_value, cur_time)) &&
+ (app->timerQueue->te_proc != 0)) {
+ ret |= XtIMTimer;
+ }
+ }
+
+ if (app->outstandingQueue != NULL) ret |= XtIMAlternateInput;
+ else {
+ /* This won't cause a wait, but will enqueue any input */
+
+ if(_XtWaitForSomething (app,
+ FALSE, TRUE, FALSE, TRUE,
+ FALSE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *) NULL) != -1)
+ ret |= XtIMXEvent;
+ if (app->outstandingQueue != NULL) ret |= XtIMAlternateInput;
+ }
+ UNLOCK_APP(app);
+ return ret;
+}
+
+/* Peek at alternate input and timer callbacks if there are any */
+
+static Boolean PeekOtherSources(
+ XtAppContext app)
+{
+ struct timeval cur_time;
+
+ if (app->outstandingQueue != NULL) return TRUE;
+
+ if (app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice)
+ return TRUE;
+ se_ptr = se_ptr->se_next;
+ }
+ }
+
+ if (app->input_count > 0) {
+ /* Call _XtWaitForSomething to get input queued up */
+ (void) _XtWaitForSomething (app,
+ TRUE, TRUE, FALSE, TRUE,
+ FALSE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *)NULL);
+ if (app->outstandingQueue != NULL) return TRUE;
+ }
+
+ if (app->timerQueue != NULL) { /* check timeout queue */
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ if (IS_AT_OR_AFTER (app->timerQueue->te_timer_value, cur_time))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+Boolean XtPeekEvent(
+ XEvent *event)
+{
+ return XtAppPeekEvent(_XtDefaultAppContext(), event);
+}
+
+Boolean XtAppPeekEvent_SkipTimer;
+
+Boolean XtAppPeekEvent(
+ XtAppContext app,
+ XEvent *event)
+{
+ int i, d;
+ Boolean foundCall = FALSE;
+
+ LOCK_APP(app);
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (d == 0) foundCall = PeekOtherSources(app);
+ if (XEventsQueued(app->list[d], QueuedAfterReading))
+ goto GotEvent;
+ }
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (XEventsQueued(app->list[d], QueuedAfterFlush))
+ goto GotEvent;
+ }
+
+ if (foundCall) {
+ event->xany.type = 0;
+ event->xany.display = NULL;
+ event->xany.window = 0;
+ UNLOCK_APP(app);
+ return FALSE;
+ }
+
+ while (1) {
+ d = _XtWaitForSomething (app,
+ FALSE, FALSE, FALSE, FALSE,
+ TRUE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *) NULL);
+
+ if (d != -1) { /* event */
+ GotEvent:
+ XPeekEvent(app->list[d], event);
+ app->last = (d == 0 ? app->count : d) - 1;
+ UNLOCK_APP(app);
+ return TRUE;
+ }
+ else { /* input or timer or signal */
+ /*
+ * Check to see why a -1 was returned, if a timer expired,
+ * call it and block some more
+ */
+ if ((app->timerQueue != NULL) && ! XtAppPeekEvent_SkipTimer) { /* timer */
+ struct timeval cur_time;
+ Bool did_timer = False;
+
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ while (IS_AT_OR_AFTER(app->timerQueue->te_timer_value, cur_time)) {
+ TimerEventRec *te_ptr = app->timerQueue;
+ app->timerQueue = app->timerQueue->te_next;
+ te_ptr->te_next = NULL;
+ if (te_ptr->te_proc != NULL) {
+ TeCallProc(te_ptr);
+ did_timer = True;
+ }
+ LOCK_PROCESS;
+ te_ptr->te_next = freeTimerRecs;
+ freeTimerRecs = te_ptr;
+ UNLOCK_PROCESS;
+ if (app->timerQueue == NULL) break;
+ }
+ if (did_timer)
+ {
+ for (d = 0; d < app->count; d++)
+ /* the timer's procedure may have caused an event */
+ if (XEventsQueued(app->list[d], QueuedAfterFlush)) {
+ goto GotEvent;
+ }
+ continue; /* keep blocking */
+ }
+ }
+ /*
+ * spec is vague here; we'll assume signals also return FALSE,
+ * of course to determine whether a signal is pending requires
+ * walking the signalQueue looking for se_notice flags which
+ * this code doesn't do.
+ */
+#if 0
+ if (app->signalQueue != NULL) { /* signal */
+ event->xany.type = 0;
+ event->xany.display = NULL;
+ event->xany.window = 0;
+ UNLOCK_APP(app);
+ return FALSE;
+ }
+ else
+#endif
+ { /* input */
+ event->xany.type = 0;
+ event->xany.display = NULL;
+ event->xany.window = 0;
+ UNLOCK_APP(app);
+ return FALSE;
+ }
+ }
+ } /* end while */
+}
diff --git a/nx-X11/lib/Xt/NextEvent.c.NX.original b/nx-X11/lib/Xt/NextEvent.c.NX.original
new file mode 100644
index 000000000..e6cd9cb06
--- /dev/null
+++ b/nx-X11/lib/Xt/NextEvent.c.NX.original
@@ -0,0 +1,1642 @@
+/* $Xorg: NextEvent.c,v 1.8 2001/02/09 02:03:55 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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, 1994, 1998, 2001 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 (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/* $XFree86: xc/lib/Xt/NextEvent.c,v 3.26 2002/06/04 21:55:42 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include <stdio.h>
+#include <errno.h>
+
+#ifdef __UNIXOS2__
+#include <sys/time.h>
+#endif
+
+static TimerEventRec* freeTimerRecs;
+static WorkProcRec* freeWorkRecs;
+static SignalEventRec* freeSignalRecs;
+
+/* Some systems running NTP daemons are known to return strange usec
+ * values from gettimeofday.
+ */
+
+#ifndef NEEDS_NTPD_FIXUP
+# if defined(sun) || defined(MOTOROLA) || (defined(__osf__) && defined(__alpha))
+# define NEEDS_NTPD_FIXUP 1
+# else
+# define NEEDS_NTPD_FIXUP 0
+# endif
+#endif
+
+#if NEEDS_NTPD_FIXUP
+#define FIXUP_TIMEVAL(t) { \
+ while ((t).tv_usec >= 1000000) { \
+ (t).tv_usec -= 1000000; \
+ (t).tv_sec++; \
+ } \
+ while ((t).tv_usec < 0) { \
+ if ((t).tv_sec > 0) { \
+ (t).tv_usec += 1000000; \
+ (t).tv_sec--; \
+ } else { \
+ (t).tv_usec = 0; \
+ break; \
+ } \
+ }}
+#else
+#define FIXUP_TIMEVAL(t)
+#endif /*NEEDS_NTPD_FIXUP*/
+
+/*
+ * Private routines
+ */
+#define ADD_TIME(dest, src1, src2) { \
+ if(((dest).tv_usec = (src1).tv_usec + (src2).tv_usec) >= 1000000) {\
+ (dest).tv_usec -= 1000000;\
+ (dest).tv_sec = (src1).tv_sec + (src2).tv_sec + 1 ; \
+ } else { (dest).tv_sec = (src1).tv_sec + (src2).tv_sec ; \
+ if(((dest).tv_sec >= 1) && (((dest).tv_usec <0))) { \
+ (dest).tv_sec --;(dest).tv_usec += 1000000; } } }
+
+
+#define TIMEDELTA(dest, src1, src2) { \
+ if(((dest).tv_usec = (src1).tv_usec - (src2).tv_usec) < 0) {\
+ (dest).tv_usec += 1000000;\
+ (dest).tv_sec = (src1).tv_sec - (src2).tv_sec - 1;\
+ } else (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; }
+
+#define IS_AFTER(t1, t2) (((t2).tv_sec > (t1).tv_sec) \
+ || (((t2).tv_sec == (t1).tv_sec)&& ((t2).tv_usec > (t1).tv_usec)))
+
+#define IS_AT_OR_AFTER(t1, t2) (((t2).tv_sec > (t1).tv_sec) \
+ || (((t2).tv_sec == (t1).tv_sec)&& ((t2).tv_usec >= (t1).tv_usec)))
+
+#ifdef USE_POLL
+#ifndef XT_DEFAULT_FDLIST_SIZE
+#define XT_DEFAULT_FDLIST_SIZE 32
+#endif
+#endif
+
+static void AdjustHowLong (
+ unsigned long *howlong,
+ struct timeval *start_time)
+{
+ struct timeval new_time, time_spent, lstart_time;
+
+ lstart_time = *start_time;
+ X_GETTIMEOFDAY (&new_time);
+ FIXUP_TIMEVAL(new_time);
+ TIMEDELTA(time_spent, new_time, lstart_time);
+ if(*howlong <= (unsigned long)(time_spent.tv_sec*1000+time_spent.tv_usec/1000))
+ *howlong = (unsigned long)0; /* Timed out */
+ else
+ *howlong -= (time_spent.tv_sec*1000+time_spent.tv_usec/1000);
+}
+
+typedef struct {
+ struct timeval cur_time;
+ struct timeval start_time;
+ struct timeval wait_time;
+ struct timeval new_time;
+ struct timeval time_spent;
+ struct timeval max_wait_time;
+#ifndef USE_POLL
+ struct timeval *wait_time_ptr;
+#else
+ int poll_wait;
+#endif
+} wait_times_t, *wait_times_ptr_t;
+
+static struct timeval zero_time = { 0 , 0};
+#ifndef USE_POLL
+static fd_set zero_fd;
+#else
+#define X_BLOCK -1
+#define X_DONT_BLOCK 0
+#endif
+
+static void InitTimes (
+ Boolean block,
+ unsigned long* howlong,
+ wait_times_ptr_t wt)
+{
+ if (block) {
+ X_GETTIMEOFDAY (&wt->cur_time);
+ FIXUP_TIMEVAL(wt->cur_time);
+ wt->start_time = wt->cur_time;
+ if(howlong == NULL) { /* special case for ever */
+#ifndef USE_POLL
+ wt->wait_time_ptr = NULL;
+#else
+ wt->poll_wait = X_BLOCK;
+#endif
+ } else { /* block until at most */
+ wt->max_wait_time.tv_sec = *howlong/1000;
+ wt->max_wait_time.tv_usec = (*howlong %1000)*1000;
+#ifndef USE_POLL
+ wt->wait_time_ptr = &wt->max_wait_time;
+#else
+ wt->poll_wait = *howlong;
+#endif
+ }
+ } else { /* don't block */
+ wt->max_wait_time = zero_time;
+#ifndef USE_POLL
+ wt->wait_time_ptr = &wt->max_wait_time;
+#else
+ wt->poll_wait = X_DONT_BLOCK;
+#endif
+ }
+}
+
+typedef struct {
+#ifndef USE_POLL
+ fd_set rmask, wmask, emask;
+ int nfds;
+#else
+ struct pollfd* fdlist;
+ struct pollfd* stack;
+ int fdlistlen, num_dpys;
+#endif
+} wait_fds_t, *wait_fds_ptr_t;
+
+static void InitFds (
+ XtAppContext app,
+ Boolean ignoreEvents,
+ Boolean ignoreInputs,
+ wait_fds_ptr_t wf)
+{
+ int ii;
+ app->rebuild_fdlist = FALSE;
+#ifndef USE_POLL
+ wf->nfds = app->fds.nfds;
+ if( !ignoreInputs ) {
+ wf->rmask = app->fds.rmask;
+ wf->wmask = app->fds.wmask;
+ wf->emask = app->fds.emask;
+ } else
+ wf->rmask = wf->wmask = wf->emask = zero_fd;
+
+ if (!ignoreEvents)
+ for (ii = 0; ii < app->count; ii++) {
+ FD_SET (ConnectionNumber(app->list[ii]), &wf->rmask);
+ }
+#else
+#ifndef POLLRDNORM
+#define POLLRDNORM 0
+#endif
+
+#ifndef POLLRDBAND
+#define POLLRDBAND 0
+#endif
+
+#ifndef POLLWRNORM
+#define POLLWRNORM 0
+#endif
+
+#ifndef POLLWRBAND
+#define POLLWRBAND 0
+#endif
+
+#define XPOLL_READ (POLLIN|POLLRDNORM|POLLPRI|POLLRDBAND)
+#define XPOLL_WRITE (POLLOUT|POLLWRNORM|POLLWRBAND)
+#define XPOLL_EXCEPT 0
+
+ if (!ignoreEvents)
+ wf->fdlistlen = wf->num_dpys = app->count;
+ else
+ wf->fdlistlen = wf->num_dpys = 0;
+
+ if (!ignoreInputs && app->input_list != NULL) {
+ int ii;
+ for (ii = 0; ii < (int) app->input_max; ii++)
+ if (app->input_list[ii] != NULL)
+ wf->fdlistlen++;
+ }
+
+ if (!wf->fdlist || wf->fdlist == wf->stack) {
+ wf->fdlist = (struct pollfd*)
+ XtStackAlloc (sizeof (struct pollfd) * wf->fdlistlen, wf->stack);
+ } else {
+ wf->fdlist = (struct pollfd*)
+ XtRealloc ((char*) wf->fdlist,
+ sizeof (struct pollfd) * wf->fdlistlen);
+ }
+
+ if (wf->fdlistlen) {
+ struct pollfd* fdlp = wf->fdlist;
+ InputEvent* iep;
+
+ if (!ignoreEvents)
+ for (ii = 0 ; ii < wf->num_dpys; ii++, fdlp++) {
+ fdlp->fd = ConnectionNumber (app->list[ii]);
+ fdlp->events = POLLIN;
+ }
+ if (!ignoreInputs && app->input_list != NULL)
+ for (ii = 0; ii < app->input_max; ii++)
+ if (app->input_list[ii] != NULL) {
+ iep = app->input_list[ii];
+ fdlp->fd = ii;
+ fdlp->events = 0;
+ for ( ; iep; iep = iep->ie_next) {
+ if (iep->ie_condition & XtInputReadMask)
+ fdlp->events |= XPOLL_READ;
+ if (iep->ie_condition & XtInputWriteMask)
+ fdlp->events |= XPOLL_WRITE;
+ if (iep->ie_condition & XtInputExceptMask)
+ fdlp->events |= XPOLL_EXCEPT;
+ }
+ fdlp++;
+ }
+ }
+#endif
+}
+
+static void AdjustTimes (
+ XtAppContext app,
+ Boolean block,
+ unsigned long* howlong,
+ Boolean ignoreTimers,
+ wait_times_ptr_t wt)
+{
+ if (app->timerQueue != NULL && !ignoreTimers && block) {
+ if (IS_AFTER (wt->cur_time, app->timerQueue->te_timer_value)) {
+ TIMEDELTA (wt->wait_time, app->timerQueue->te_timer_value, wt->cur_time);
+ if (howlong == NULL || IS_AFTER (wt->wait_time, wt->max_wait_time))
+#ifndef USE_POLL
+ wt->wait_time_ptr = &wt->wait_time;
+ else
+ wt->wait_time_ptr = &wt->max_wait_time;
+ } else
+ wt->wait_time_ptr = &zero_time;
+ }
+#else
+ wt->poll_wait = wt->wait_time.tv_sec * 1000 + wt->wait_time.tv_usec / 1000;
+ else
+ wt->poll_wait = wt->max_wait_time.tv_sec * 1000 + wt->max_wait_time.tv_usec / 1000;
+ } else
+ wt->poll_wait = X_DONT_BLOCK;
+ }
+#endif
+}
+
+
+static int IoWait (
+ wait_times_ptr_t wt,
+ wait_fds_ptr_t wf)
+{
+#ifndef USE_POLL
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+
+ fprintf(stderr, "Xt::IoWait: Select called with [%d][%p][%p][%p][%p].\n",
+ wf->nfds, (void *) &wf->rmask, (void *) &wf->wmask, (void *) &wf->emask,
+ (void *) wt->wait_time_ptr);
+#endif
+
+ return Select (wf->nfds, &wf->rmask, &wf->wmask, &wf->emask,
+ wt->wait_time_ptr);
+#else
+ return poll (wf->fdlist, wf->fdlistlen, wt->poll_wait);
+#endif
+}
+
+
+static void FindInputs (
+ XtAppContext app,
+ wait_fds_ptr_t wf,
+ int nfds,
+ Boolean ignoreEvents,
+ Boolean ignoreInputs,
+ int* dpy_no,
+ int* found_input)
+{
+ XtInputMask condition;
+ InputEvent *ep;
+ int ii;
+#ifndef USE_POLL /* { check ready file descriptors block */
+#ifdef XTHREADS
+ fd_set rmask;
+#endif
+ int dd;
+ *dpy_no = -1;
+ *found_input = False;
+
+#ifdef XTHREADS
+ rmask = app->fds.rmask;
+ for (dd = app->count; dd-- > 0; )
+ FD_SET (ConnectionNumber (app->list[dd]), &rmask);
+#endif
+
+ for (ii = 0; ii < wf->nfds && nfds > 0; ii++) {
+ condition = 0;
+ if (FD_ISSET (ii, &wf->rmask)
+#ifdef XTHREADS
+ && FD_ISSET (ii, &rmask)
+#endif
+ ) {
+ nfds--;
+ if (!ignoreEvents) {
+ for (dd = 0; dd < app->count; dd++) {
+ if (ii == ConnectionNumber (app->list[dd])) {
+ if (*dpy_no == -1) {
+ if (XEventsQueued (app->list[dd], QueuedAfterReading ))
+ *dpy_no = dd;
+ /*
+ * An error event could have arrived
+ * without any real events, or events
+ * could have been swallowed by Xlib,
+ * or the connection may be broken.
+ * We can't tell the difference, so
+ * assume Xlib will eventually discover
+ * a broken connection.
+ */
+ }
+ goto ENDILOOP;
+ }
+ }
+ }
+ condition = XtInputReadMask;
+ }
+ if (FD_ISSET (ii, &wf->wmask)
+#ifdef XTHREADS
+ && FD_ISSET (ii, &app->fds.wmask)
+#endif
+ ) {
+ condition |= XtInputWriteMask;
+ nfds--;
+ }
+ if (FD_ISSET (ii, &wf->emask)
+#ifdef XTHREADS
+ && FD_ISSET (ii, &app->fds.emask)
+#endif
+ ) {
+ condition |= XtInputExceptMask;
+ nfds--;
+ }
+ if (condition) {
+ for (ep = app->input_list[ii]; ep; ep = ep->ie_next)
+ if (condition & ep->ie_condition) {
+ /* make sure this input isn't already marked outstanding */
+ InputEvent *oq;
+ for (oq = app->outstandingQueue; oq; oq = oq->ie_oq)
+ if (oq == ep)
+ break;
+ if (!oq)
+ {
+ ep->ie_oq = app->outstandingQueue;
+ app->outstandingQueue = ep;
+ }
+ }
+ *found_input = True;
+ }
+ENDILOOP: ;
+ } /* endfor */
+#else /* }{ */
+ struct pollfd* fdlp;
+
+ *dpy_no = -1;
+ *found_input = False;
+
+ if (!ignoreEvents) {
+ fdlp = wf->fdlist;
+ for (ii = 0; ii < wf->num_dpys; ii++, fdlp++) {
+ if (*dpy_no == -1 && fdlp->revents & (POLLIN|POLLHUP|POLLERR) &&
+#ifdef XTHREADS
+ !(fdlp->revents & POLLNVAL) &&
+#endif
+ XEventsQueued (app->list[ii], QueuedAfterReading)) {
+ *dpy_no = ii;
+ break;
+ }
+ }
+ }
+
+ if (!ignoreInputs) {
+ fdlp = &wf->fdlist[wf->num_dpys];
+ for (ii = wf->num_dpys; ii < wf->fdlistlen; ii++, fdlp++) {
+ condition = 0;
+ if (fdlp->revents) {
+ if (fdlp->revents & (XPOLL_READ|POLLHUP|POLLERR)
+#ifdef XTHREADS
+ && !(fdlp->revents & POLLNVAL)
+#endif
+ )
+ condition = XtInputReadMask;
+ if (fdlp->revents & XPOLL_WRITE)
+ condition |= XtInputWriteMask;
+ if (fdlp->revents & XPOLL_EXCEPT)
+ condition |= XtInputExceptMask;
+ }
+ if (condition) {
+ *found_input = True;
+ for (ep = app->input_list[fdlp->fd]; ep; ep = ep->ie_next)
+ if (condition & ep->ie_condition) {
+ InputEvent *oq;
+ /* make sure this input isn't already marked outstanding */
+ for (oq = app->outstandingQueue; oq; oq = oq->ie_oq)
+ if (oq == ep)
+ break;
+ if (!oq)
+ {
+ ep->ie_oq = app->outstandingQueue;
+ app->outstandingQueue = ep;
+ }
+ }
+ }
+ }
+ }
+#endif /* } */
+}
+
+/*
+ * Routine to block in the toolkit. This should be the only call to select.
+ *
+ * This routine returns when there is something to be done.
+ *
+ * Before calling this with ignoreInputs==False, app->outstandingQueue should
+ * be checked; this routine will not verify that an alternate input source
+ * has not already been enqueued.
+ *
+ *
+ * _XtWaitForSomething( appContext,
+ * ignoreEvent, ignoreTimers, ignoreInputs, ignoreSignals,
+ * block, drop_lock, howlong)
+ * XtAppContext app; (Displays to check wait on)
+ *
+ * Boolean ignoreEvents; (Don't return if XEvents are available
+ * Also implies forget XEvents exist)
+ *
+ * Boolean ignoreTimers; (Ditto for timers)
+ *
+ * Boolean ignoreInputs; (Ditto for input callbacks )
+ *
+ * Boolean ignoreSignals; (Ditto for signals)
+ *
+ * Boolean block; (Okay to block)
+ *
+ * Boolean drop_lock (drop lock before going into select/poll)
+ *
+ * TimeVal howlong; (howlong to wait for if blocking and not
+ * doing Timers... Null means forever.
+ * Maybe should mean shortest of both)
+ * Returns display for which input is available, if any
+ * and if ignoreEvents==False, else returns -1
+ *
+ * if ignoring everything && block=True && howlong=NULL, you'll have
+ * lots of time for coffee; better not try it! In fact, it probably
+ * makes little sense to do this regardless of the value of howlong
+ * (bottom line is, we don't bother checking here).
+ *
+ * If drop_lock is FALSE, the app->lock->mutex is not unlocked before
+ * entering select/poll. It is illegal for drop_lock to be FALSE if
+ * ignoreTimers, ignoreInputs, or ignoreSignals is FALSE.
+ */
+int _XtWaitForSomething(
+ XtAppContext app,
+ _XtBoolean ignoreEvents,
+ _XtBoolean ignoreTimers,
+ _XtBoolean ignoreInputs,
+ _XtBoolean ignoreSignals,
+ _XtBoolean block,
+#ifdef XTHREADS
+ _XtBoolean drop_lock,
+#endif
+ unsigned long *howlong)
+{
+ wait_times_t wt;
+ wait_fds_t wf;
+ int nfds, dpy_no, found_input, dd;
+#ifdef XTHREADS
+ Boolean push_thread = TRUE;
+ Boolean pushed_thread = FALSE;
+ int level = 0;
+#endif
+#ifdef USE_POLL
+ struct pollfd fdlist[XT_DEFAULT_FDLIST_SIZE];
+#endif
+
+#ifdef XTHREADS
+ /* assert ((ignoreTimers && ignoreInputs && ignoreSignals) || drop_lock); */
+ /* If not multi-threaded, never drop lock */
+ if (app->lock == (ThreadAppProc) NULL)
+ drop_lock = FALSE;
+#endif
+
+ InitTimes (block, howlong, &wt);
+
+#ifdef USE_POLL
+ wf.fdlist = NULL;
+ wf.stack = fdlist;
+#endif
+
+ app->rebuild_fdlist = TRUE;
+
+ while (1) {
+WaitLoop:
+ AdjustTimes (app, block, howlong, ignoreTimers, &wt);
+
+ if (block && app->block_hook_list) {
+ BlockHook hook;
+ for (hook = app->block_hook_list;
+ hook != NULL;
+ hook = hook->next)
+ (*hook->proc) (hook->closure);
+
+ if (!ignoreEvents)
+ /* see if the hook(s) generated any protocol */
+ for (dd = 0; dd < app->count; dd++)
+ if (XEventsQueued(app->list[dd], QueuedAlready)) {
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return dd;
+ }
+ }
+
+ if (app->rebuild_fdlist)
+ InitFds (app, ignoreEvents, ignoreInputs, &wf);
+
+#ifdef XTHREADS /* { */
+ if (drop_lock) {
+ YIELD_APP_LOCK(app, &push_thread, &pushed_thread, &level);
+ nfds = IoWait (&wt, &wf);
+ RESTORE_APP_LOCK(app, level, &pushed_thread);
+ } else
+#endif /* } */
+ nfds = IoWait (&wt, &wf);
+ if (nfds == -1) {
+ /*
+ * interrupt occured recalculate time value and wait again.
+ */
+ if (errno == EINTR || errno == EAGAIN) {
+ if (errno == EAGAIN) {
+ errno = 0; /* errno is not self reseting */
+ continue;
+ }
+ errno = 0; /* errno is not self reseting */
+
+ /* was it interrupted by a signal that we care about? */
+ if (!ignoreSignals && app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice) {
+ if (block && howlong != NULL)
+ AdjustHowLong (howlong, &wt.start_time);
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return -1;
+ }
+ se_ptr = se_ptr->se_next;
+ }
+ }
+
+ if (!ignoreEvents)
+ /* get Xlib to detect a bad connection */
+ for (dd = 0; dd < app->count; dd++)
+ if (XEventsQueued(app->list[dd], QueuedAfterReading)) {
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return dd;
+ }
+
+ if (block) {
+#ifndef USE_POLL
+ if (wt.wait_time_ptr == NULL)
+#else
+ if (wt.poll_wait == X_BLOCK)
+#endif
+ continue;
+ X_GETTIMEOFDAY (&wt.new_time);
+ FIXUP_TIMEVAL (wt.new_time);
+ TIMEDELTA (wt.time_spent, wt.new_time, wt.cur_time);
+ wt.cur_time = wt.new_time;
+#ifndef USE_POLL
+ if (IS_AFTER (wt.time_spent, *wt.wait_time_ptr)) {
+ TIMEDELTA (wt.wait_time, *wt.wait_time_ptr, wt.time_spent);
+ wt.wait_time_ptr = &wt.wait_time;
+ continue;
+ } else
+#else
+ if ((wt.time_spent.tv_sec * 1000 + wt.time_spent.tv_usec / 1000) < wt.poll_wait) {
+ wt.poll_wait -= (wt.time_spent.tv_sec * 1000 + wt.time_spent.tv_usec / 1000);
+ continue;
+ } else
+#endif
+ nfds = 0;
+ }
+ } else {
+ char Errno[12];
+ String param = Errno;
+ Cardinal param_count = 1;
+
+ sprintf( Errno, "%d", errno);
+ XtAppWarningMsg(app, "communicationError","select",
+ XtCXtToolkitError,"Select failed; error code %s",
+ &param, &param_count);
+ continue;
+ }
+ } /* timed out or input available */
+ break;
+ }
+
+ if (nfds == 0) {
+ /* Timed out */
+ if (howlong)
+ *howlong = (unsigned long)0;
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return -1;
+ }
+
+ if (block && howlong != NULL)
+ AdjustHowLong (howlong, &wt.start_time);
+
+ if (ignoreInputs && ignoreEvents) {
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return -1;
+ } else
+ FindInputs (app, &wf, nfds,
+ ignoreEvents, ignoreInputs,
+ &dpy_no, &found_input);
+
+ if (dpy_no >= 0 || found_input) {
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return dpy_no;
+ }
+ goto WaitLoop;
+}
+
+#define IeCallProc(ptr) \
+ (*ptr->ie_proc) (ptr->ie_closure, &ptr->ie_source, (XtInputId*)&ptr);
+
+#define TeCallProc(ptr) \
+ (*ptr->te_proc) (ptr->te_closure, (XtIntervalId*)&ptr);
+
+#define SeCallProc(ptr) \
+ (*ptr->se_proc) (ptr->se_closure, (XtSignalId*)&ptr);
+
+/*
+ * Public Routines
+ */
+
+XtIntervalId XtAddTimeOut(
+ unsigned long interval,
+ XtTimerCallbackProc proc,
+ XtPointer closure)
+{
+ return XtAppAddTimeOut(_XtDefaultAppContext(),
+ interval, proc, closure);
+}
+
+static void QueueTimerEvent(
+ XtAppContext app,
+ TimerEventRec *ptr)
+{
+ TimerEventRec *t,**tt;
+ tt = &app->timerQueue;
+ t = *tt;
+ while (t != NULL &&
+ IS_AFTER(t->te_timer_value, ptr->te_timer_value)) {
+ tt = &t->te_next;
+ t = *tt;
+ }
+ ptr->te_next = t;
+ *tt = ptr;
+}
+
+XtIntervalId XtAppAddTimeOut(
+ XtAppContext app,
+ unsigned long interval,
+ XtTimerCallbackProc proc,
+ XtPointer closure)
+{
+ TimerEventRec *tptr;
+ struct timeval current_time;
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if (freeTimerRecs) {
+ tptr = freeTimerRecs;
+ freeTimerRecs = tptr->te_next;
+ }
+ else tptr = XtNew(TimerEventRec);
+ UNLOCK_PROCESS;
+
+ tptr->te_next = NULL;
+ tptr->te_closure = closure;
+ tptr->te_proc = proc;
+ tptr->app = app;
+ tptr->te_timer_value.tv_sec = interval/1000;
+ tptr->te_timer_value.tv_usec = (interval%1000)*1000;
+ X_GETTIMEOFDAY (&current_time);
+ FIXUP_TIMEVAL(current_time);
+ ADD_TIME(tptr->te_timer_value,tptr->te_timer_value,current_time);
+ QueueTimerEvent(app, tptr);
+ UNLOCK_APP(app);
+ return( (XtIntervalId) tptr);
+}
+
+void XtRemoveTimeOut(
+ XtIntervalId id)
+{
+ TimerEventRec *t, *last, *tid = (TimerEventRec *) id;
+ XtAppContext app = tid->app;
+
+ /* find it */
+ LOCK_APP(app);
+ for(t = app->timerQueue, last = NULL;
+ t != NULL && t != tid;
+ t = t->te_next) last = t;
+
+ if (t == NULL) {
+ UNLOCK_APP(app);
+ return; /* couldn't find it */
+ }
+ if(last == NULL) { /* first one on the list */
+ app->timerQueue = t->te_next;
+ } else last->te_next = t->te_next;
+
+ LOCK_PROCESS;
+ t->te_next = freeTimerRecs;
+ freeTimerRecs = t;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+XtWorkProcId XtAddWorkProc(
+ XtWorkProc proc,
+ XtPointer closure)
+{
+ return XtAppAddWorkProc(_XtDefaultAppContext(), proc, closure);
+}
+
+XtWorkProcId XtAppAddWorkProc(
+ XtAppContext app,
+ XtWorkProc proc,
+ XtPointer closure)
+{
+ WorkProcRec *wptr;
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if (freeWorkRecs) {
+ wptr = freeWorkRecs;
+ freeWorkRecs = wptr->next;
+ } else wptr = XtNew(WorkProcRec);
+ UNLOCK_PROCESS;
+ wptr->next = app->workQueue;
+ wptr->closure = closure;
+ wptr->proc = proc;
+ wptr->app = app;
+ app->workQueue = wptr;
+ UNLOCK_APP(app);
+ return (XtWorkProcId) wptr;
+}
+
+void XtRemoveWorkProc(
+ XtWorkProcId id)
+{
+ WorkProcRec *wid= (WorkProcRec *) id, *w, *last;
+ XtAppContext app = wid->app;
+
+ LOCK_APP(app);
+ /* find it */
+ for(w = app->workQueue, last = NULL;
+ w != NULL && w != wid; w = w->next) last = w;
+
+ if (w == NULL) {
+ UNLOCK_APP(app);
+ return; /* couldn't find it */
+ }
+
+ if(last == NULL) app->workQueue = w->next;
+ else last->next = w->next;
+ LOCK_PROCESS;
+ w->next = freeWorkRecs;
+ freeWorkRecs = w;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+XtSignalId XtAddSignal(
+ XtSignalCallbackProc proc,
+ XtPointer closure)
+{
+ return XtAppAddSignal(_XtDefaultAppContext(), proc, closure);
+}
+
+XtSignalId XtAppAddSignal(
+ XtAppContext app,
+ XtSignalCallbackProc proc,
+ XtPointer closure)
+{
+ SignalEventRec *sptr;
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if (freeSignalRecs) {
+ sptr = freeSignalRecs;
+ freeSignalRecs = sptr->se_next;
+ } else
+ sptr = XtNew(SignalEventRec);
+ UNLOCK_PROCESS;
+ sptr->se_next = app->signalQueue;
+ sptr->se_closure = closure;
+ sptr->se_proc = proc;
+ sptr->app = app;
+ sptr->se_notice = FALSE;
+ app->signalQueue = sptr;
+ UNLOCK_APP(app);
+ return (XtSignalId) sptr;
+}
+
+void XtRemoveSignal(
+ XtSignalId id)
+{
+ SignalEventRec *sid = (SignalEventRec*) id, *s, *last = NULL;
+ XtAppContext app = sid->app;
+
+ LOCK_APP(app);
+ for (s = app->signalQueue; s != NULL && s != sid; s = s->se_next)
+ last = s;
+ if (s == NULL) {
+ UNLOCK_APP(app);
+ return;
+ }
+ if (last == NULL)
+ app->signalQueue = s->se_next;
+ else
+ last->se_next = s->se_next;
+ LOCK_PROCESS;
+ s->se_next = freeSignalRecs;
+ freeSignalRecs = s;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+void XtNoticeSignal(
+ XtSignalId id)
+{
+ /*
+ * It would be overkill to lock the app to set this flag.
+ * In the worst case, 2..n threads would be modifying this
+ * flag. The last one wins. Since signals occur asynchronously
+ * anyway, this can occur with or without threads.
+ *
+ * The other issue is that thread t1 sets the flag in a
+ * signalrec that has been deleted in thread t2. We rely
+ * on a detail of the implementation, i.e. free'd signalrecs
+ * aren't really free'd, they're just moved to a list of
+ * free recs, so deref'ing one won't hurt anything.
+ *
+ * Lastly, and perhaps most importantly, since POSIX threads
+ * says that the handling of asynchronous signals in a synchronous
+ * threads environment is undefined. Therefor it would be an
+ * error for both signals and threads to be in use in the same
+ * program.
+ */
+ SignalEventRec *sid = (SignalEventRec*) id;
+ sid->se_notice = TRUE;
+}
+
+XtInputId XtAddInput(
+ int source,
+ XtPointer Condition,
+ XtInputCallbackProc proc,
+ XtPointer closure)
+{
+ return XtAppAddInput(_XtDefaultAppContext(),
+ source, Condition, proc, closure);
+}
+
+XtInputId XtAppAddInput(
+ XtAppContext app,
+ int source,
+ XtPointer Condition,
+ XtInputCallbackProc proc,
+ XtPointer closure)
+{
+ InputEvent* sptr;
+ XtInputMask condition = (XtInputMask) Condition;
+
+ LOCK_APP(app);
+ if (!condition ||
+ condition & ~(XtInputReadMask|XtInputWriteMask|XtInputExceptMask))
+ XtAppErrorMsg(app,"invalidParameter","xtAddInput",XtCXtToolkitError,
+ "invalid condition passed to XtAppAddInput",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if (app->input_max <= source) {
+ Cardinal n = source + 1;
+ int ii;
+ app->input_list = (InputEvent**)XtRealloc((char*) app->input_list,
+ n * sizeof(InputEvent*));
+ for (ii = app->input_max; ii < (int) n; ii++)
+ app->input_list[ii] = (InputEvent*) NULL;
+ app->input_max = n;
+ }
+ sptr = XtNew(InputEvent);
+ sptr->ie_proc = proc;
+ sptr->ie_closure = closure;
+ sptr->app = app;
+ sptr->ie_oq = NULL;
+ sptr->ie_source = source;
+ sptr->ie_condition = condition;
+ sptr->ie_next = app->input_list[source];
+ app->input_list[source] = sptr;
+
+#ifndef USE_POLL
+ if (condition & XtInputReadMask) FD_SET(source, &app->fds.rmask);
+ if (condition & XtInputWriteMask) FD_SET(source, &app->fds.wmask);
+ if (condition & XtInputExceptMask) FD_SET(source, &app->fds.emask);
+
+ if (app->fds.nfds < (source+1)) app->fds.nfds = source+1;
+#else
+ if (sptr->ie_next == NULL)
+ app->fds.nfds++;
+#endif
+ app->input_count++;
+ app->rebuild_fdlist = TRUE;
+ UNLOCK_APP(app);
+ return((XtInputId)sptr);
+}
+
+void XtRemoveInput(
+ register XtInputId id)
+{
+ register InputEvent *sptr, *lptr;
+ XtAppContext app = ((InputEvent *)id)->app;
+ register int source = ((InputEvent *)id)->ie_source;
+ Boolean found = False;
+
+ LOCK_APP(app);
+ sptr = app->outstandingQueue;
+ lptr = NULL;
+ for (; sptr != NULL; sptr = sptr->ie_oq) {
+ if (sptr == (InputEvent *)id) {
+ if (lptr == NULL) app->outstandingQueue = sptr->ie_oq;
+ else lptr->ie_oq = sptr->ie_oq;
+ }
+ lptr = sptr;
+ }
+
+ if(app->input_list && (sptr = app->input_list[source]) != NULL) {
+ for( lptr = NULL ; sptr; sptr = sptr->ie_next ){
+ if(sptr == (InputEvent *) id) {
+#ifndef USE_POLL
+ XtInputMask condition = 0;
+#endif
+ if(lptr == NULL) {
+ app->input_list[source] = sptr->ie_next;
+ } else {
+ lptr->ie_next = sptr->ie_next;
+ }
+#ifndef USE_POLL
+ for (lptr = app->input_list[source];
+ lptr; lptr = lptr->ie_next)
+ condition |= lptr->ie_condition;
+ if ((sptr->ie_condition & XtInputReadMask) &&
+ !(condition & XtInputReadMask))
+ FD_CLR(source, &app->fds.rmask);
+ if ((sptr->ie_condition & XtInputWriteMask) &&
+ !(condition & XtInputWriteMask))
+ FD_CLR(source, &app->fds.wmask);
+ if ((sptr->ie_condition & XtInputExceptMask) &&
+ !(condition & XtInputExceptMask))
+ FD_CLR(source, &app->fds.emask);
+#endif
+ XtFree((char *) sptr);
+ found = True;
+ break;
+ }
+ lptr = sptr;
+ }
+ }
+
+ if (found) {
+ app->input_count--;
+#ifdef USE_POLL
+ if (app->input_list[source] == NULL)
+ app->fds.nfds--;
+#endif
+ app->rebuild_fdlist = TRUE;
+ } else
+ XtAppWarningMsg(app, "invalidProcedure","inputHandler",
+ XtCXtToolkitError,
+ "XtRemoveInput: Input handler not found",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_APP(app);
+}
+
+void _XtRemoveAllInputs(
+ XtAppContext app)
+{
+ int i;
+ for (i = 0; i < app->input_max; i++) {
+ InputEvent* ep = app->input_list[i];
+ while (ep) {
+ InputEvent *next = ep->ie_next;
+ XtFree( (char*)ep );
+ ep = next;
+ }
+ }
+ XtFree((char *) app->input_list);
+}
+
+/* Do alternate input and timer callbacks if there are any */
+
+static void DoOtherSources(
+ XtAppContext app)
+{
+ TimerEventRec *te_ptr;
+ InputEvent *ie_ptr;
+ struct timeval cur_time;
+
+#define DrainQueue() \
+ for (ie_ptr = app->outstandingQueue; ie_ptr != NULL;) { \
+ app->outstandingQueue = ie_ptr->ie_oq; \
+ ie_ptr ->ie_oq = NULL; \
+ IeCallProc(ie_ptr); \
+ ie_ptr = app->outstandingQueue; \
+ }
+/*enddef*/
+ DrainQueue();
+ if (app->input_count > 0) {
+ /* Call _XtWaitForSomething to get input queued up */
+ (void) _XtWaitForSomething (app,
+ TRUE, TRUE, FALSE, TRUE,
+ FALSE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *)NULL);
+ DrainQueue();
+ }
+ if (app->timerQueue != NULL) { /* check timeout queue */
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ while(IS_AT_OR_AFTER (app->timerQueue->te_timer_value, cur_time)) {
+ te_ptr = app->timerQueue;
+ app->timerQueue = te_ptr->te_next;
+ te_ptr->te_next = NULL;
+ if (te_ptr->te_proc != NULL)
+ TeCallProc(te_ptr);
+ LOCK_PROCESS;
+ te_ptr->te_next = freeTimerRecs;
+ freeTimerRecs = te_ptr;
+ UNLOCK_PROCESS;
+ if (app->timerQueue == NULL) break;
+ }
+ }
+ if (app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice) {
+ se_ptr->se_notice = FALSE;
+ if (se_ptr->se_proc != NULL)
+ SeCallProc(se_ptr);
+ }
+ se_ptr = se_ptr->se_next;
+ }
+ }
+#undef DrainQueue
+}
+
+/* If there are any work procs, call them. Return whether we did so */
+
+static Boolean CallWorkProc(
+ XtAppContext app)
+{
+ register WorkProcRec *w = app->workQueue;
+ Boolean delete;
+
+ if (w == NULL) return FALSE;
+
+ app->workQueue = w->next;
+
+ delete = (*(w->proc)) (w->closure);
+
+ if (delete) {
+ LOCK_PROCESS;
+ w->next = freeWorkRecs;
+ freeWorkRecs = w;
+ UNLOCK_PROCESS;
+ }
+ else {
+ w->next = app->workQueue;
+ app->workQueue = w;
+ }
+ return TRUE;
+}
+
+/*
+ * XtNextEvent()
+ * return next event;
+ */
+
+void XtNextEvent(
+ XEvent *event)
+{
+ XtAppNextEvent(_XtDefaultAppContext(), event);
+}
+
+void _XtRefreshMapping(
+ XEvent* event,
+ _XtBoolean dispatch)
+{
+ XtPerDisplay pd;
+
+ LOCK_PROCESS;
+ pd = _XtGetPerDisplay(event->xmapping.display);
+ if (event->xmapping.request != MappingPointer &&
+ pd && pd->keysyms && (event->xmapping.serial >= pd->keysyms_serial))
+ _XtBuildKeysymTables( event->xmapping.display, pd );
+ XRefreshKeyboardMapping(&event->xmapping);
+ if (dispatch && pd && pd->mapping_callbacks)
+ XtCallCallbackList((Widget) NULL,
+ (XtCallbackList)pd->mapping_callbacks,
+ (XtPointer)event );
+ UNLOCK_PROCESS;
+}
+
+void XtAppNextEvent(
+ XtAppContext app,
+ XEvent *event)
+{
+ int i, d;
+
+ LOCK_APP(app);
+ for (;;) {
+ if (app->count == 0)
+ DoOtherSources(app);
+ else {
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (d == 0) DoOtherSources(app);
+ if (XEventsQueued(app->list[d], QueuedAfterReading))
+ goto GotEvent;
+ }
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (XEventsQueued(app->list[d], QueuedAfterFlush))
+ goto GotEvent;
+ }
+ }
+
+ /* We're ready to wait...if there is a work proc, call it */
+ if (CallWorkProc(app)) continue;
+
+ d = _XtWaitForSomething (app,
+ FALSE, FALSE, FALSE, FALSE,
+ TRUE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *) NULL);
+
+ if (d != -1) {
+ GotEvent:
+ XNextEvent (app->list[d], event);
+#ifdef XTHREADS
+ /* assert(app->list[d] == event->xany.display); */
+#endif
+ app->last = d;
+ if (event->xany.type == MappingNotify)
+ _XtRefreshMapping(event, False);
+ UNLOCK_APP(app);
+ return;
+ }
+
+ } /* for */
+}
+
+void XtProcessEvent(
+ XtInputMask mask)
+{
+ XtAppProcessEvent(_XtDefaultAppContext(), mask);
+}
+
+void XtAppProcessEvent(
+ XtAppContext app,
+ XtInputMask mask)
+{
+ int i, d;
+ XEvent event;
+ struct timeval cur_time;
+
+ LOCK_APP(app);
+ if (mask == 0) {
+ UNLOCK_APP(app);
+ return;
+ }
+
+ for (;;) {
+
+ if (mask & XtIMSignal && app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice) {
+ se_ptr->se_notice = FALSE;
+ SeCallProc(se_ptr);
+ UNLOCK_APP(app);
+ return;
+ }
+ se_ptr = se_ptr->se_next;
+ }
+ }
+
+ if (mask & XtIMTimer && app->timerQueue != NULL) {
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ if (IS_AT_OR_AFTER(app->timerQueue->te_timer_value, cur_time)){
+ TimerEventRec *te_ptr = app->timerQueue;
+ app->timerQueue = app->timerQueue->te_next;
+ te_ptr->te_next = NULL;
+ if (te_ptr->te_proc != NULL)
+ TeCallProc(te_ptr);
+ LOCK_PROCESS;
+ te_ptr->te_next = freeTimerRecs;
+ freeTimerRecs = te_ptr;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return;
+ }
+ }
+
+ if (mask & XtIMAlternateInput) {
+ if (app->input_count > 0 && app->outstandingQueue == NULL) {
+ /* Call _XtWaitForSomething to get input queued up */
+ (void) _XtWaitForSomething (app,
+ TRUE, TRUE, FALSE, TRUE,
+ FALSE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *)NULL);
+ }
+ if (app->outstandingQueue != NULL) {
+ InputEvent *ie_ptr = app->outstandingQueue;
+ app->outstandingQueue = ie_ptr->ie_oq;
+ ie_ptr->ie_oq = NULL;
+ IeCallProc(ie_ptr);
+ UNLOCK_APP(app);
+ return;
+ }
+ }
+
+ if (mask & XtIMXEvent) {
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (XEventsQueued(app->list[d], QueuedAfterReading))
+ goto GotEvent;
+ }
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (XEventsQueued(app->list[d], QueuedAfterFlush))
+ goto GotEvent;
+ }
+ }
+
+ /* Nothing to do...wait for something */
+
+ if (CallWorkProc(app)) continue;
+
+ d = _XtWaitForSomething (app,
+ (mask & XtIMXEvent ? FALSE : TRUE),
+ (mask & XtIMTimer ? FALSE : TRUE),
+ (mask & XtIMAlternateInput ? FALSE : TRUE),
+ (mask & XtIMSignal ? FALSE : TRUE),
+ TRUE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *) NULL);
+
+ if (mask & XtIMXEvent && d != -1) {
+ GotEvent:
+ XNextEvent(app->list[d], &event);
+#ifdef XTHREADS
+ /* assert(app->list[d] == event.xany.display); */
+#endif
+ app->last = d;
+ if (event.xany.type == MappingNotify) {
+ _XtRefreshMapping(&event, False);
+ }
+ XtDispatchEvent(&event);
+ UNLOCK_APP(app);
+ return;
+ }
+
+ }
+}
+
+Boolean XtPending(void)
+{
+ return (XtAppPending(_XtDefaultAppContext()) != 0);
+}
+
+XtInputMask XtAppPending(
+ XtAppContext app)
+{
+ struct timeval cur_time;
+ int d;
+ XtInputMask ret = 0;
+
+/*
+ * Check for pending X events
+ */
+ LOCK_APP(app);
+ for (d = 0; d < app->count; d++) {
+ if (XEventsQueued(app->list[d], QueuedAfterReading)) {
+ ret = XtIMXEvent;
+ break;
+ }
+ }
+ if (ret == 0) {
+ for (d = 0; d < app->count; d++) {
+ if (XEventsQueued(app->list[d], QueuedAfterFlush)) {
+ ret = XtIMXEvent;
+ break;
+ }
+ }
+ }
+
+ if (app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice) {
+ ret |= XtIMSignal;
+ break;
+ }
+ se_ptr = se_ptr->se_next;
+ }
+ }
+
+/*
+ * Check for pending alternate input
+ */
+ if (app->timerQueue != NULL) { /* check timeout queue */
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ if ((IS_AT_OR_AFTER(app->timerQueue->te_timer_value, cur_time)) &&
+ (app->timerQueue->te_proc != 0)) {
+ ret |= XtIMTimer;
+ }
+ }
+
+ if (app->outstandingQueue != NULL) ret |= XtIMAlternateInput;
+ else {
+ /* This won't cause a wait, but will enqueue any input */
+
+ if(_XtWaitForSomething (app,
+ FALSE, TRUE, FALSE, TRUE,
+ FALSE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *) NULL) != -1)
+ ret |= XtIMXEvent;
+ if (app->outstandingQueue != NULL) ret |= XtIMAlternateInput;
+ }
+ UNLOCK_APP(app);
+ return ret;
+}
+
+/* Peek at alternate input and timer callbacks if there are any */
+
+static Boolean PeekOtherSources(
+ XtAppContext app)
+{
+ struct timeval cur_time;
+
+ if (app->outstandingQueue != NULL) return TRUE;
+
+ if (app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice)
+ return TRUE;
+ se_ptr = se_ptr->se_next;
+ }
+ }
+
+ if (app->input_count > 0) {
+ /* Call _XtWaitForSomething to get input queued up */
+ (void) _XtWaitForSomething (app,
+ TRUE, TRUE, FALSE, TRUE,
+ FALSE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *)NULL);
+ if (app->outstandingQueue != NULL) return TRUE;
+ }
+
+ if (app->timerQueue != NULL) { /* check timeout queue */
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ if (IS_AT_OR_AFTER (app->timerQueue->te_timer_value, cur_time))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+Boolean XtPeekEvent(
+ XEvent *event)
+{
+ return XtAppPeekEvent(_XtDefaultAppContext(), event);
+}
+
+Boolean XtAppPeekEvent_SkipTimer;
+
+Boolean XtAppPeekEvent(
+ XtAppContext app,
+ XEvent *event)
+{
+ int i, d;
+ Boolean foundCall = FALSE;
+
+ LOCK_APP(app);
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (d == 0) foundCall = PeekOtherSources(app);
+ if (XEventsQueued(app->list[d], QueuedAfterReading))
+ goto GotEvent;
+ }
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (XEventsQueued(app->list[d], QueuedAfterFlush))
+ goto GotEvent;
+ }
+
+ if (foundCall) {
+ event->xany.type = 0;
+ event->xany.display = NULL;
+ event->xany.window = 0;
+ UNLOCK_APP(app);
+ return FALSE;
+ }
+
+ while (1) {
+ d = _XtWaitForSomething (app,
+ FALSE, FALSE, FALSE, FALSE,
+ TRUE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *) NULL);
+
+ if (d != -1) { /* event */
+ GotEvent:
+ XPeekEvent(app->list[d], event);
+ app->last = (d == 0 ? app->count : d) - 1;
+ UNLOCK_APP(app);
+ return TRUE;
+ }
+ else { /* input or timer or signal */
+ /*
+ * Check to see why a -1 was returned, if a timer expired,
+ * call it and block some more
+ */
+ if ((app->timerQueue != NULL) && ! XtAppPeekEvent_SkipTimer) { /* timer */
+ struct timeval cur_time;
+ Bool did_timer = False;
+
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ while (IS_AT_OR_AFTER(app->timerQueue->te_timer_value, cur_time)) {
+ TimerEventRec *te_ptr = app->timerQueue;
+ app->timerQueue = app->timerQueue->te_next;
+ te_ptr->te_next = NULL;
+ if (te_ptr->te_proc != NULL) {
+ TeCallProc(te_ptr);
+ did_timer = True;
+ }
+ LOCK_PROCESS;
+ te_ptr->te_next = freeTimerRecs;
+ freeTimerRecs = te_ptr;
+ UNLOCK_PROCESS;
+ if (app->timerQueue == NULL) break;
+ }
+ if (did_timer)
+ {
+ for (d = 0; d < app->count; d++)
+ /* the timer's procedure may have caused an event */
+ if (XEventsQueued(app->list[d], QueuedAfterFlush)) {
+ goto GotEvent;
+ }
+ continue; /* keep blocking */
+ }
+ }
+ /*
+ * spec is vague here; we'll assume signals also return FALSE,
+ * of course to determine whether a signal is pending requires
+ * walking the signalQueue looking for se_notice flags which
+ * this code doesn't do.
+ */
+#if 0
+ if (app->signalQueue != NULL) { /* signal */
+ event->xany.type = 0;
+ event->xany.display = NULL;
+ event->xany.window = 0;
+ UNLOCK_APP(app);
+ return FALSE;
+ }
+ else
+#endif
+ { /* input */
+ event->xany.type = 0;
+ event->xany.display = NULL;
+ event->xany.window = 0;
+ UNLOCK_APP(app);
+ return FALSE;
+ }
+ }
+ } /* end while */
+}
diff --git a/nx-X11/lib/Xt/NextEvent.c.X.original b/nx-X11/lib/Xt/NextEvent.c.X.original
new file mode 100644
index 000000000..64be87814
--- /dev/null
+++ b/nx-X11/lib/Xt/NextEvent.c.X.original
@@ -0,0 +1,1616 @@
+/* $Xorg: NextEvent.c,v 1.8 2001/02/09 02:03:55 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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, 1994, 1998, 2001 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/NextEvent.c,v 3.26 2002/06/04 21:55:42 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include <stdio.h>
+#include <errno.h>
+
+#ifdef __UNIXOS2__
+#include <sys/time.h>
+#endif
+
+static TimerEventRec* freeTimerRecs;
+static WorkProcRec* freeWorkRecs;
+static SignalEventRec* freeSignalRecs;
+
+/* Some systems running NTP daemons are known to return strange usec
+ * values from gettimeofday.
+ */
+
+#ifndef NEEDS_NTPD_FIXUP
+# if defined(sun) || defined(MOTOROLA) || (defined(__osf__) && defined(__alpha))
+# define NEEDS_NTPD_FIXUP 1
+# else
+# define NEEDS_NTPD_FIXUP 0
+# endif
+#endif
+
+#if NEEDS_NTPD_FIXUP
+#define FIXUP_TIMEVAL(t) { \
+ while ((t).tv_usec >= 1000000) { \
+ (t).tv_usec -= 1000000; \
+ (t).tv_sec++; \
+ } \
+ while ((t).tv_usec < 0) { \
+ if ((t).tv_sec > 0) { \
+ (t).tv_usec += 1000000; \
+ (t).tv_sec--; \
+ } else { \
+ (t).tv_usec = 0; \
+ break; \
+ } \
+ }}
+#else
+#define FIXUP_TIMEVAL(t)
+#endif /*NEEDS_NTPD_FIXUP*/
+
+/*
+ * Private routines
+ */
+#define ADD_TIME(dest, src1, src2) { \
+ if(((dest).tv_usec = (src1).tv_usec + (src2).tv_usec) >= 1000000) {\
+ (dest).tv_usec -= 1000000;\
+ (dest).tv_sec = (src1).tv_sec + (src2).tv_sec + 1 ; \
+ } else { (dest).tv_sec = (src1).tv_sec + (src2).tv_sec ; \
+ if(((dest).tv_sec >= 1) && (((dest).tv_usec <0))) { \
+ (dest).tv_sec --;(dest).tv_usec += 1000000; } } }
+
+
+#define TIMEDELTA(dest, src1, src2) { \
+ if(((dest).tv_usec = (src1).tv_usec - (src2).tv_usec) < 0) {\
+ (dest).tv_usec += 1000000;\
+ (dest).tv_sec = (src1).tv_sec - (src2).tv_sec - 1;\
+ } else (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; }
+
+#define IS_AFTER(t1, t2) (((t2).tv_sec > (t1).tv_sec) \
+ || (((t2).tv_sec == (t1).tv_sec)&& ((t2).tv_usec > (t1).tv_usec)))
+
+#define IS_AT_OR_AFTER(t1, t2) (((t2).tv_sec > (t1).tv_sec) \
+ || (((t2).tv_sec == (t1).tv_sec)&& ((t2).tv_usec >= (t1).tv_usec)))
+
+#ifdef USE_POLL
+#ifndef XT_DEFAULT_FDLIST_SIZE
+#define XT_DEFAULT_FDLIST_SIZE 32
+#endif
+#endif
+
+static void AdjustHowLong (
+ unsigned long *howlong,
+ struct timeval *start_time)
+{
+ struct timeval new_time, time_spent, lstart_time;
+
+ lstart_time = *start_time;
+ X_GETTIMEOFDAY (&new_time);
+ FIXUP_TIMEVAL(new_time);
+ TIMEDELTA(time_spent, new_time, lstart_time);
+ if(*howlong <= (unsigned long)(time_spent.tv_sec*1000+time_spent.tv_usec/1000))
+ *howlong = (unsigned long)0; /* Timed out */
+ else
+ *howlong -= (time_spent.tv_sec*1000+time_spent.tv_usec/1000);
+}
+
+typedef struct {
+ struct timeval cur_time;
+ struct timeval start_time;
+ struct timeval wait_time;
+ struct timeval new_time;
+ struct timeval time_spent;
+ struct timeval max_wait_time;
+#ifndef USE_POLL
+ struct timeval *wait_time_ptr;
+#else
+ int poll_wait;
+#endif
+} wait_times_t, *wait_times_ptr_t;
+
+static struct timeval zero_time = { 0 , 0};
+#ifndef USE_POLL
+static fd_set zero_fd;
+#else
+#define X_BLOCK -1
+#define X_DONT_BLOCK 0
+#endif
+
+static void InitTimes (
+ Boolean block,
+ unsigned long* howlong,
+ wait_times_ptr_t wt)
+{
+ if (block) {
+ X_GETTIMEOFDAY (&wt->cur_time);
+ FIXUP_TIMEVAL(wt->cur_time);
+ wt->start_time = wt->cur_time;
+ if(howlong == NULL) { /* special case for ever */
+#ifndef USE_POLL
+ wt->wait_time_ptr = NULL;
+#else
+ wt->poll_wait = X_BLOCK;
+#endif
+ } else { /* block until at most */
+ wt->max_wait_time.tv_sec = *howlong/1000;
+ wt->max_wait_time.tv_usec = (*howlong %1000)*1000;
+#ifndef USE_POLL
+ wt->wait_time_ptr = &wt->max_wait_time;
+#else
+ wt->poll_wait = *howlong;
+#endif
+ }
+ } else { /* don't block */
+ wt->max_wait_time = zero_time;
+#ifndef USE_POLL
+ wt->wait_time_ptr = &wt->max_wait_time;
+#else
+ wt->poll_wait = X_DONT_BLOCK;
+#endif
+ }
+}
+
+typedef struct {
+#ifndef USE_POLL
+ fd_set rmask, wmask, emask;
+ int nfds;
+#else
+ struct pollfd* fdlist;
+ struct pollfd* stack;
+ int fdlistlen, num_dpys;
+#endif
+} wait_fds_t, *wait_fds_ptr_t;
+
+static void InitFds (
+ XtAppContext app,
+ Boolean ignoreEvents,
+ Boolean ignoreInputs,
+ wait_fds_ptr_t wf)
+{
+ int ii;
+ app->rebuild_fdlist = FALSE;
+#ifndef USE_POLL
+ wf->nfds = app->fds.nfds;
+ if( !ignoreInputs ) {
+ wf->rmask = app->fds.rmask;
+ wf->wmask = app->fds.wmask;
+ wf->emask = app->fds.emask;
+ } else
+ wf->rmask = wf->wmask = wf->emask = zero_fd;
+
+ if (!ignoreEvents)
+ for (ii = 0; ii < app->count; ii++) {
+ FD_SET (ConnectionNumber(app->list[ii]), &wf->rmask);
+ }
+#else
+#ifndef POLLRDNORM
+#define POLLRDNORM 0
+#endif
+
+#ifndef POLLRDBAND
+#define POLLRDBAND 0
+#endif
+
+#ifndef POLLWRNORM
+#define POLLWRNORM 0
+#endif
+
+#ifndef POLLWRBAND
+#define POLLWRBAND 0
+#endif
+
+#define XPOLL_READ (POLLIN|POLLRDNORM|POLLPRI|POLLRDBAND)
+#define XPOLL_WRITE (POLLOUT|POLLWRNORM|POLLWRBAND)
+#define XPOLL_EXCEPT 0
+
+ if (!ignoreEvents)
+ wf->fdlistlen = wf->num_dpys = app->count;
+ else
+ wf->fdlistlen = wf->num_dpys = 0;
+
+ if (!ignoreInputs && app->input_list != NULL) {
+ int ii;
+ for (ii = 0; ii < (int) app->input_max; ii++)
+ if (app->input_list[ii] != NULL)
+ wf->fdlistlen++;
+ }
+
+ if (!wf->fdlist || wf->fdlist == wf->stack) {
+ wf->fdlist = (struct pollfd*)
+ XtStackAlloc (sizeof (struct pollfd) * wf->fdlistlen, wf->stack);
+ } else {
+ wf->fdlist = (struct pollfd*)
+ XtRealloc ((char*) wf->fdlist,
+ sizeof (struct pollfd) * wf->fdlistlen);
+ }
+
+ if (wf->fdlistlen) {
+ struct pollfd* fdlp = wf->fdlist;
+ InputEvent* iep;
+
+ if (!ignoreEvents)
+ for (ii = 0 ; ii < wf->num_dpys; ii++, fdlp++) {
+ fdlp->fd = ConnectionNumber (app->list[ii]);
+ fdlp->events = POLLIN;
+ }
+ if (!ignoreInputs && app->input_list != NULL)
+ for (ii = 0; ii < app->input_max; ii++)
+ if (app->input_list[ii] != NULL) {
+ iep = app->input_list[ii];
+ fdlp->fd = ii;
+ fdlp->events = 0;
+ for ( ; iep; iep = iep->ie_next) {
+ if (iep->ie_condition & XtInputReadMask)
+ fdlp->events |= XPOLL_READ;
+ if (iep->ie_condition & XtInputWriteMask)
+ fdlp->events |= XPOLL_WRITE;
+ if (iep->ie_condition & XtInputExceptMask)
+ fdlp->events |= XPOLL_EXCEPT;
+ }
+ fdlp++;
+ }
+ }
+#endif
+}
+
+static void AdjustTimes (
+ XtAppContext app,
+ Boolean block,
+ unsigned long* howlong,
+ Boolean ignoreTimers,
+ wait_times_ptr_t wt)
+{
+ if (app->timerQueue != NULL && !ignoreTimers && block) {
+ if (IS_AFTER (wt->cur_time, app->timerQueue->te_timer_value)) {
+ TIMEDELTA (wt->wait_time, app->timerQueue->te_timer_value, wt->cur_time);
+ if (howlong == NULL || IS_AFTER (wt->wait_time, wt->max_wait_time))
+#ifndef USE_POLL
+ wt->wait_time_ptr = &wt->wait_time;
+ else
+ wt->wait_time_ptr = &wt->max_wait_time;
+ } else
+ wt->wait_time_ptr = &zero_time;
+ }
+#else
+ wt->poll_wait = wt->wait_time.tv_sec * 1000 + wt->wait_time.tv_usec / 1000;
+ else
+ wt->poll_wait = wt->max_wait_time.tv_sec * 1000 + wt->max_wait_time.tv_usec / 1000;
+ } else
+ wt->poll_wait = X_DONT_BLOCK;
+ }
+#endif
+}
+
+
+static int IoWait (
+ wait_times_ptr_t wt,
+ wait_fds_ptr_t wf)
+{
+#ifndef USE_POLL
+ return Select (wf->nfds, &wf->rmask, &wf->wmask, &wf->emask,
+ wt->wait_time_ptr);
+#else
+ return poll (wf->fdlist, wf->fdlistlen, wt->poll_wait);
+#endif
+}
+
+
+static void FindInputs (
+ XtAppContext app,
+ wait_fds_ptr_t wf,
+ int nfds,
+ Boolean ignoreEvents,
+ Boolean ignoreInputs,
+ int* dpy_no,
+ int* found_input)
+{
+ XtInputMask condition;
+ InputEvent *ep;
+ int ii;
+#ifndef USE_POLL /* { check ready file descriptors block */
+#ifdef XTHREADS
+ fd_set rmask;
+#endif
+ int dd;
+ *dpy_no = -1;
+ *found_input = False;
+
+#ifdef XTHREADS
+ rmask = app->fds.rmask;
+ for (dd = app->count; dd-- > 0; )
+ FD_SET (ConnectionNumber (app->list[dd]), &rmask);
+#endif
+
+ for (ii = 0; ii < wf->nfds && nfds > 0; ii++) {
+ condition = 0;
+ if (FD_ISSET (ii, &wf->rmask)
+#ifdef XTHREADS
+ && FD_ISSET (ii, &rmask)
+#endif
+ ) {
+ nfds--;
+ if (!ignoreEvents) {
+ for (dd = 0; dd < app->count; dd++) {
+ if (ii == ConnectionNumber (app->list[dd])) {
+ if (*dpy_no == -1) {
+ if (XEventsQueued (app->list[dd], QueuedAfterReading ))
+ *dpy_no = dd;
+ /*
+ * An error event could have arrived
+ * without any real events, or events
+ * could have been swallowed by Xlib,
+ * or the connection may be broken.
+ * We can't tell the difference, so
+ * assume Xlib will eventually discover
+ * a broken connection.
+ */
+ }
+ goto ENDILOOP;
+ }
+ }
+ }
+ condition = XtInputReadMask;
+ }
+ if (FD_ISSET (ii, &wf->wmask)
+#ifdef XTHREADS
+ && FD_ISSET (ii, &app->fds.wmask)
+#endif
+ ) {
+ condition |= XtInputWriteMask;
+ nfds--;
+ }
+ if (FD_ISSET (ii, &wf->emask)
+#ifdef XTHREADS
+ && FD_ISSET (ii, &app->fds.emask)
+#endif
+ ) {
+ condition |= XtInputExceptMask;
+ nfds--;
+ }
+ if (condition) {
+ for (ep = app->input_list[ii]; ep; ep = ep->ie_next)
+ if (condition & ep->ie_condition) {
+ /* make sure this input isn't already marked outstanding */
+ InputEvent *oq;
+ for (oq = app->outstandingQueue; oq; oq = oq->ie_oq)
+ if (oq == ep)
+ break;
+ if (!oq)
+ {
+ ep->ie_oq = app->outstandingQueue;
+ app->outstandingQueue = ep;
+ }
+ }
+ *found_input = True;
+ }
+ENDILOOP: ;
+ } /* endfor */
+#else /* }{ */
+ struct pollfd* fdlp;
+
+ *dpy_no = -1;
+ *found_input = False;
+
+ if (!ignoreEvents) {
+ fdlp = wf->fdlist;
+ for (ii = 0; ii < wf->num_dpys; ii++, fdlp++) {
+ if (*dpy_no == -1 && fdlp->revents & (POLLIN|POLLHUP|POLLERR) &&
+#ifdef XTHREADS
+ !(fdlp->revents & POLLNVAL) &&
+#endif
+ XEventsQueued (app->list[ii], QueuedAfterReading)) {
+ *dpy_no = ii;
+ break;
+ }
+ }
+ }
+
+ if (!ignoreInputs) {
+ fdlp = &wf->fdlist[wf->num_dpys];
+ for (ii = wf->num_dpys; ii < wf->fdlistlen; ii++, fdlp++) {
+ condition = 0;
+ if (fdlp->revents) {
+ if (fdlp->revents & (XPOLL_READ|POLLHUP|POLLERR)
+#ifdef XTHREADS
+ && !(fdlp->revents & POLLNVAL)
+#endif
+ )
+ condition = XtInputReadMask;
+ if (fdlp->revents & XPOLL_WRITE)
+ condition |= XtInputWriteMask;
+ if (fdlp->revents & XPOLL_EXCEPT)
+ condition |= XtInputExceptMask;
+ }
+ if (condition) {
+ *found_input = True;
+ for (ep = app->input_list[fdlp->fd]; ep; ep = ep->ie_next)
+ if (condition & ep->ie_condition) {
+ InputEvent *oq;
+ /* make sure this input isn't already marked outstanding */
+ for (oq = app->outstandingQueue; oq; oq = oq->ie_oq)
+ if (oq == ep)
+ break;
+ if (!oq)
+ {
+ ep->ie_oq = app->outstandingQueue;
+ app->outstandingQueue = ep;
+ }
+ }
+ }
+ }
+ }
+#endif /* } */
+}
+
+/*
+ * Routine to block in the toolkit. This should be the only call to select.
+ *
+ * This routine returns when there is something to be done.
+ *
+ * Before calling this with ignoreInputs==False, app->outstandingQueue should
+ * be checked; this routine will not verify that an alternate input source
+ * has not already been enqueued.
+ *
+ *
+ * _XtWaitForSomething( appContext,
+ * ignoreEvent, ignoreTimers, ignoreInputs, ignoreSignals,
+ * block, drop_lock, howlong)
+ * XtAppContext app; (Displays to check wait on)
+ *
+ * Boolean ignoreEvents; (Don't return if XEvents are available
+ * Also implies forget XEvents exist)
+ *
+ * Boolean ignoreTimers; (Ditto for timers)
+ *
+ * Boolean ignoreInputs; (Ditto for input callbacks )
+ *
+ * Boolean ignoreSignals; (Ditto for signals)
+ *
+ * Boolean block; (Okay to block)
+ *
+ * Boolean drop_lock (drop lock before going into select/poll)
+ *
+ * TimeVal howlong; (howlong to wait for if blocking and not
+ * doing Timers... Null means forever.
+ * Maybe should mean shortest of both)
+ * Returns display for which input is available, if any
+ * and if ignoreEvents==False, else returns -1
+ *
+ * if ignoring everything && block=True && howlong=NULL, you'll have
+ * lots of time for coffee; better not try it! In fact, it probably
+ * makes little sense to do this regardless of the value of howlong
+ * (bottom line is, we don't bother checking here).
+ *
+ * If drop_lock is FALSE, the app->lock->mutex is not unlocked before
+ * entering select/poll. It is illegal for drop_lock to be FALSE if
+ * ignoreTimers, ignoreInputs, or ignoreSignals is FALSE.
+ */
+int _XtWaitForSomething(
+ XtAppContext app,
+ _XtBoolean ignoreEvents,
+ _XtBoolean ignoreTimers,
+ _XtBoolean ignoreInputs,
+ _XtBoolean ignoreSignals,
+ _XtBoolean block,
+#ifdef XTHREADS
+ _XtBoolean drop_lock,
+#endif
+ unsigned long *howlong)
+{
+ wait_times_t wt;
+ wait_fds_t wf;
+ int nfds, dpy_no, found_input, dd;
+#ifdef XTHREADS
+ Boolean push_thread = TRUE;
+ Boolean pushed_thread = FALSE;
+ int level = 0;
+#endif
+#ifdef USE_POLL
+ struct pollfd fdlist[XT_DEFAULT_FDLIST_SIZE];
+#endif
+
+#ifdef XTHREADS
+ /* assert ((ignoreTimers && ignoreInputs && ignoreSignals) || drop_lock); */
+ /* If not multi-threaded, never drop lock */
+ if (app->lock == (ThreadAppProc) NULL)
+ drop_lock = FALSE;
+#endif
+
+ InitTimes (block, howlong, &wt);
+
+#ifdef USE_POLL
+ wf.fdlist = NULL;
+ wf.stack = fdlist;
+#endif
+
+ app->rebuild_fdlist = TRUE;
+
+ while (1) {
+WaitLoop:
+ AdjustTimes (app, block, howlong, ignoreTimers, &wt);
+
+ if (block && app->block_hook_list) {
+ BlockHook hook;
+ for (hook = app->block_hook_list;
+ hook != NULL;
+ hook = hook->next)
+ (*hook->proc) (hook->closure);
+
+ if (!ignoreEvents)
+ /* see if the hook(s) generated any protocol */
+ for (dd = 0; dd < app->count; dd++)
+ if (XEventsQueued(app->list[dd], QueuedAlready)) {
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return dd;
+ }
+ }
+
+ if (app->rebuild_fdlist)
+ InitFds (app, ignoreEvents, ignoreInputs, &wf);
+
+#ifdef XTHREADS /* { */
+ if (drop_lock) {
+ YIELD_APP_LOCK(app, &push_thread, &pushed_thread, &level);
+ nfds = IoWait (&wt, &wf);
+ RESTORE_APP_LOCK(app, level, &pushed_thread);
+ } else
+#endif /* } */
+ nfds = IoWait (&wt, &wf);
+ if (nfds == -1) {
+ /*
+ * interrupt occured recalculate time value and wait again.
+ */
+ if (errno == EINTR || errno == EAGAIN) {
+ if (errno == EAGAIN) {
+ errno = 0; /* errno is not self reseting */
+ continue;
+ }
+ errno = 0; /* errno is not self reseting */
+
+ /* was it interrupted by a signal that we care about? */
+ if (!ignoreSignals && app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice) {
+ if (block && howlong != NULL)
+ AdjustHowLong (howlong, &wt.start_time);
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return -1;
+ }
+ se_ptr = se_ptr->se_next;
+ }
+ }
+
+ if (!ignoreEvents)
+ /* get Xlib to detect a bad connection */
+ for (dd = 0; dd < app->count; dd++)
+ if (XEventsQueued(app->list[dd], QueuedAfterReading)) {
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return dd;
+ }
+
+ if (block) {
+#ifndef USE_POLL
+ if (wt.wait_time_ptr == NULL)
+#else
+ if (wt.poll_wait == X_BLOCK)
+#endif
+ continue;
+ X_GETTIMEOFDAY (&wt.new_time);
+ FIXUP_TIMEVAL (wt.new_time);
+ TIMEDELTA (wt.time_spent, wt.new_time, wt.cur_time);
+ wt.cur_time = wt.new_time;
+#ifndef USE_POLL
+ if (IS_AFTER (wt.time_spent, *wt.wait_time_ptr)) {
+ TIMEDELTA (wt.wait_time, *wt.wait_time_ptr, wt.time_spent);
+ wt.wait_time_ptr = &wt.wait_time;
+ continue;
+ } else
+#else
+ if ((wt.time_spent.tv_sec * 1000 + wt.time_spent.tv_usec / 1000) < wt.poll_wait) {
+ wt.poll_wait -= (wt.time_spent.tv_sec * 1000 + wt.time_spent.tv_usec / 1000);
+ continue;
+ } else
+#endif
+ nfds = 0;
+ }
+ } else {
+ char Errno[12];
+ String param = Errno;
+ Cardinal param_count = 1;
+
+ sprintf( Errno, "%d", errno);
+ XtAppWarningMsg(app, "communicationError","select",
+ XtCXtToolkitError,"Select failed; error code %s",
+ &param, &param_count);
+ continue;
+ }
+ } /* timed out or input available */
+ break;
+ }
+
+ if (nfds == 0) {
+ /* Timed out */
+ if (howlong)
+ *howlong = (unsigned long)0;
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return -1;
+ }
+
+ if (block && howlong != NULL)
+ AdjustHowLong (howlong, &wt.start_time);
+
+ if (ignoreInputs && ignoreEvents) {
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return -1;
+ } else
+ FindInputs (app, &wf, nfds,
+ ignoreEvents, ignoreInputs,
+ &dpy_no, &found_input);
+
+ if (dpy_no >= 0 || found_input) {
+#ifdef USE_POLL
+ XtStackFree ((XtPointer) wf.fdlist, fdlist);
+#endif
+ return dpy_no;
+ }
+ goto WaitLoop;
+}
+
+#define IeCallProc(ptr) \
+ (*ptr->ie_proc) (ptr->ie_closure, &ptr->ie_source, (XtInputId*)&ptr);
+
+#define TeCallProc(ptr) \
+ (*ptr->te_proc) (ptr->te_closure, (XtIntervalId*)&ptr);
+
+#define SeCallProc(ptr) \
+ (*ptr->se_proc) (ptr->se_closure, (XtSignalId*)&ptr);
+
+/*
+ * Public Routines
+ */
+
+XtIntervalId XtAddTimeOut(
+ unsigned long interval,
+ XtTimerCallbackProc proc,
+ XtPointer closure)
+{
+ return XtAppAddTimeOut(_XtDefaultAppContext(),
+ interval, proc, closure);
+}
+
+static void QueueTimerEvent(
+ XtAppContext app,
+ TimerEventRec *ptr)
+{
+ TimerEventRec *t,**tt;
+ tt = &app->timerQueue;
+ t = *tt;
+ while (t != NULL &&
+ IS_AFTER(t->te_timer_value, ptr->te_timer_value)) {
+ tt = &t->te_next;
+ t = *tt;
+ }
+ ptr->te_next = t;
+ *tt = ptr;
+}
+
+XtIntervalId XtAppAddTimeOut(
+ XtAppContext app,
+ unsigned long interval,
+ XtTimerCallbackProc proc,
+ XtPointer closure)
+{
+ TimerEventRec *tptr;
+ struct timeval current_time;
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if (freeTimerRecs) {
+ tptr = freeTimerRecs;
+ freeTimerRecs = tptr->te_next;
+ }
+ else tptr = XtNew(TimerEventRec);
+ UNLOCK_PROCESS;
+
+ tptr->te_next = NULL;
+ tptr->te_closure = closure;
+ tptr->te_proc = proc;
+ tptr->app = app;
+ tptr->te_timer_value.tv_sec = interval/1000;
+ tptr->te_timer_value.tv_usec = (interval%1000)*1000;
+ X_GETTIMEOFDAY (&current_time);
+ FIXUP_TIMEVAL(current_time);
+ ADD_TIME(tptr->te_timer_value,tptr->te_timer_value,current_time);
+ QueueTimerEvent(app, tptr);
+ UNLOCK_APP(app);
+ return( (XtIntervalId) tptr);
+}
+
+void XtRemoveTimeOut(
+ XtIntervalId id)
+{
+ TimerEventRec *t, *last, *tid = (TimerEventRec *) id;
+ XtAppContext app = tid->app;
+
+ /* find it */
+ LOCK_APP(app);
+ for(t = app->timerQueue, last = NULL;
+ t != NULL && t != tid;
+ t = t->te_next) last = t;
+
+ if (t == NULL) {
+ UNLOCK_APP(app);
+ return; /* couldn't find it */
+ }
+ if(last == NULL) { /* first one on the list */
+ app->timerQueue = t->te_next;
+ } else last->te_next = t->te_next;
+
+ LOCK_PROCESS;
+ t->te_next = freeTimerRecs;
+ freeTimerRecs = t;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+XtWorkProcId XtAddWorkProc(
+ XtWorkProc proc,
+ XtPointer closure)
+{
+ return XtAppAddWorkProc(_XtDefaultAppContext(), proc, closure);
+}
+
+XtWorkProcId XtAppAddWorkProc(
+ XtAppContext app,
+ XtWorkProc proc,
+ XtPointer closure)
+{
+ WorkProcRec *wptr;
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if (freeWorkRecs) {
+ wptr = freeWorkRecs;
+ freeWorkRecs = wptr->next;
+ } else wptr = XtNew(WorkProcRec);
+ UNLOCK_PROCESS;
+ wptr->next = app->workQueue;
+ wptr->closure = closure;
+ wptr->proc = proc;
+ wptr->app = app;
+ app->workQueue = wptr;
+ UNLOCK_APP(app);
+ return (XtWorkProcId) wptr;
+}
+
+void XtRemoveWorkProc(
+ XtWorkProcId id)
+{
+ WorkProcRec *wid= (WorkProcRec *) id, *w, *last;
+ XtAppContext app = wid->app;
+
+ LOCK_APP(app);
+ /* find it */
+ for(w = app->workQueue, last = NULL;
+ w != NULL && w != wid; w = w->next) last = w;
+
+ if (w == NULL) {
+ UNLOCK_APP(app);
+ return; /* couldn't find it */
+ }
+
+ if(last == NULL) app->workQueue = w->next;
+ else last->next = w->next;
+ LOCK_PROCESS;
+ w->next = freeWorkRecs;
+ freeWorkRecs = w;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+XtSignalId XtAddSignal(
+ XtSignalCallbackProc proc,
+ XtPointer closure)
+{
+ return XtAppAddSignal(_XtDefaultAppContext(), proc, closure);
+}
+
+XtSignalId XtAppAddSignal(
+ XtAppContext app,
+ XtSignalCallbackProc proc,
+ XtPointer closure)
+{
+ SignalEventRec *sptr;
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if (freeSignalRecs) {
+ sptr = freeSignalRecs;
+ freeSignalRecs = sptr->se_next;
+ } else
+ sptr = XtNew(SignalEventRec);
+ UNLOCK_PROCESS;
+ sptr->se_next = app->signalQueue;
+ sptr->se_closure = closure;
+ sptr->se_proc = proc;
+ sptr->app = app;
+ sptr->se_notice = FALSE;
+ app->signalQueue = sptr;
+ UNLOCK_APP(app);
+ return (XtSignalId) sptr;
+}
+
+void XtRemoveSignal(
+ XtSignalId id)
+{
+ SignalEventRec *sid = (SignalEventRec*) id, *s, *last = NULL;
+ XtAppContext app = sid->app;
+
+ LOCK_APP(app);
+ for (s = app->signalQueue; s != NULL && s != sid; s = s->se_next)
+ last = s;
+ if (s == NULL) {
+ UNLOCK_APP(app);
+ return;
+ }
+ if (last == NULL)
+ app->signalQueue = s->se_next;
+ else
+ last->se_next = s->se_next;
+ LOCK_PROCESS;
+ s->se_next = freeSignalRecs;
+ freeSignalRecs = s;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+void XtNoticeSignal(
+ XtSignalId id)
+{
+ /*
+ * It would be overkill to lock the app to set this flag.
+ * In the worst case, 2..n threads would be modifying this
+ * flag. The last one wins. Since signals occur asynchronously
+ * anyway, this can occur with or without threads.
+ *
+ * The other issue is that thread t1 sets the flag in a
+ * signalrec that has been deleted in thread t2. We rely
+ * on a detail of the implementation, i.e. free'd signalrecs
+ * aren't really free'd, they're just moved to a list of
+ * free recs, so deref'ing one won't hurt anything.
+ *
+ * Lastly, and perhaps most importantly, since POSIX threads
+ * says that the handling of asynchronous signals in a synchronous
+ * threads environment is undefined. Therefor it would be an
+ * error for both signals and threads to be in use in the same
+ * program.
+ */
+ SignalEventRec *sid = (SignalEventRec*) id;
+ sid->se_notice = TRUE;
+}
+
+XtInputId XtAddInput(
+ int source,
+ XtPointer Condition,
+ XtInputCallbackProc proc,
+ XtPointer closure)
+{
+ return XtAppAddInput(_XtDefaultAppContext(),
+ source, Condition, proc, closure);
+}
+
+XtInputId XtAppAddInput(
+ XtAppContext app,
+ int source,
+ XtPointer Condition,
+ XtInputCallbackProc proc,
+ XtPointer closure)
+{
+ InputEvent* sptr;
+ XtInputMask condition = (XtInputMask) Condition;
+
+ LOCK_APP(app);
+ if (!condition ||
+ condition & ~(XtInputReadMask|XtInputWriteMask|XtInputExceptMask))
+ XtAppErrorMsg(app,"invalidParameter","xtAddInput",XtCXtToolkitError,
+ "invalid condition passed to XtAppAddInput",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if (app->input_max <= source) {
+ Cardinal n = source + 1;
+ int ii;
+ app->input_list = (InputEvent**)XtRealloc((char*) app->input_list,
+ n * sizeof(InputEvent*));
+ for (ii = app->input_max; ii < (int) n; ii++)
+ app->input_list[ii] = (InputEvent*) NULL;
+ app->input_max = n;
+ }
+ sptr = XtNew(InputEvent);
+ sptr->ie_proc = proc;
+ sptr->ie_closure = closure;
+ sptr->app = app;
+ sptr->ie_oq = NULL;
+ sptr->ie_source = source;
+ sptr->ie_condition = condition;
+ sptr->ie_next = app->input_list[source];
+ app->input_list[source] = sptr;
+
+#ifndef USE_POLL
+ if (condition & XtInputReadMask) FD_SET(source, &app->fds.rmask);
+ if (condition & XtInputWriteMask) FD_SET(source, &app->fds.wmask);
+ if (condition & XtInputExceptMask) FD_SET(source, &app->fds.emask);
+
+ if (app->fds.nfds < (source+1)) app->fds.nfds = source+1;
+#else
+ if (sptr->ie_next == NULL)
+ app->fds.nfds++;
+#endif
+ app->input_count++;
+ app->rebuild_fdlist = TRUE;
+ UNLOCK_APP(app);
+ return((XtInputId)sptr);
+}
+
+void XtRemoveInput(
+ register XtInputId id)
+{
+ register InputEvent *sptr, *lptr;
+ XtAppContext app = ((InputEvent *)id)->app;
+ register int source = ((InputEvent *)id)->ie_source;
+ Boolean found = False;
+
+ LOCK_APP(app);
+ sptr = app->outstandingQueue;
+ lptr = NULL;
+ for (; sptr != NULL; sptr = sptr->ie_oq) {
+ if (sptr == (InputEvent *)id) {
+ if (lptr == NULL) app->outstandingQueue = sptr->ie_oq;
+ else lptr->ie_oq = sptr->ie_oq;
+ }
+ lptr = sptr;
+ }
+
+ if(app->input_list && (sptr = app->input_list[source]) != NULL) {
+ for( lptr = NULL ; sptr; sptr = sptr->ie_next ){
+ if(sptr == (InputEvent *) id) {
+#ifndef USE_POLL
+ XtInputMask condition = 0;
+#endif
+ if(lptr == NULL) {
+ app->input_list[source] = sptr->ie_next;
+ } else {
+ lptr->ie_next = sptr->ie_next;
+ }
+#ifndef USE_POLL
+ for (lptr = app->input_list[source];
+ lptr; lptr = lptr->ie_next)
+ condition |= lptr->ie_condition;
+ if ((sptr->ie_condition & XtInputReadMask) &&
+ !(condition & XtInputReadMask))
+ FD_CLR(source, &app->fds.rmask);
+ if ((sptr->ie_condition & XtInputWriteMask) &&
+ !(condition & XtInputWriteMask))
+ FD_CLR(source, &app->fds.wmask);
+ if ((sptr->ie_condition & XtInputExceptMask) &&
+ !(condition & XtInputExceptMask))
+ FD_CLR(source, &app->fds.emask);
+#endif
+ XtFree((char *) sptr);
+ found = True;
+ break;
+ }
+ lptr = sptr;
+ }
+ }
+
+ if (found) {
+ app->input_count--;
+#ifdef USE_POLL
+ if (app->input_list[source] == NULL)
+ app->fds.nfds--;
+#endif
+ app->rebuild_fdlist = TRUE;
+ } else
+ XtAppWarningMsg(app, "invalidProcedure","inputHandler",
+ XtCXtToolkitError,
+ "XtRemoveInput: Input handler not found",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_APP(app);
+}
+
+void _XtRemoveAllInputs(
+ XtAppContext app)
+{
+ int i;
+ for (i = 0; i < app->input_max; i++) {
+ InputEvent* ep = app->input_list[i];
+ while (ep) {
+ InputEvent *next = ep->ie_next;
+ XtFree( (char*)ep );
+ ep = next;
+ }
+ }
+ XtFree((char *) app->input_list);
+}
+
+/* Do alternate input and timer callbacks if there are any */
+
+static void DoOtherSources(
+ XtAppContext app)
+{
+ TimerEventRec *te_ptr;
+ InputEvent *ie_ptr;
+ struct timeval cur_time;
+
+#define DrainQueue() \
+ for (ie_ptr = app->outstandingQueue; ie_ptr != NULL;) { \
+ app->outstandingQueue = ie_ptr->ie_oq; \
+ ie_ptr ->ie_oq = NULL; \
+ IeCallProc(ie_ptr); \
+ ie_ptr = app->outstandingQueue; \
+ }
+/*enddef*/
+ DrainQueue();
+ if (app->input_count > 0) {
+ /* Call _XtWaitForSomething to get input queued up */
+ (void) _XtWaitForSomething (app,
+ TRUE, TRUE, FALSE, TRUE,
+ FALSE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *)NULL);
+ DrainQueue();
+ }
+ if (app->timerQueue != NULL) { /* check timeout queue */
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ while(IS_AT_OR_AFTER (app->timerQueue->te_timer_value, cur_time)) {
+ te_ptr = app->timerQueue;
+ app->timerQueue = te_ptr->te_next;
+ te_ptr->te_next = NULL;
+ if (te_ptr->te_proc != NULL)
+ TeCallProc(te_ptr);
+ LOCK_PROCESS;
+ te_ptr->te_next = freeTimerRecs;
+ freeTimerRecs = te_ptr;
+ UNLOCK_PROCESS;
+ if (app->timerQueue == NULL) break;
+ }
+ }
+ if (app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice) {
+ se_ptr->se_notice = FALSE;
+ if (se_ptr->se_proc != NULL)
+ SeCallProc(se_ptr);
+ }
+ se_ptr = se_ptr->se_next;
+ }
+ }
+#undef DrainQueue
+}
+
+/* If there are any work procs, call them. Return whether we did so */
+
+static Boolean CallWorkProc(
+ XtAppContext app)
+{
+ register WorkProcRec *w = app->workQueue;
+ Boolean delete;
+
+ if (w == NULL) return FALSE;
+
+ app->workQueue = w->next;
+
+ delete = (*(w->proc)) (w->closure);
+
+ if (delete) {
+ LOCK_PROCESS;
+ w->next = freeWorkRecs;
+ freeWorkRecs = w;
+ UNLOCK_PROCESS;
+ }
+ else {
+ w->next = app->workQueue;
+ app->workQueue = w;
+ }
+ return TRUE;
+}
+
+/*
+ * XtNextEvent()
+ * return next event;
+ */
+
+void XtNextEvent(
+ XEvent *event)
+{
+ XtAppNextEvent(_XtDefaultAppContext(), event);
+}
+
+void _XtRefreshMapping(
+ XEvent* event,
+ _XtBoolean dispatch)
+{
+ XtPerDisplay pd;
+
+ LOCK_PROCESS;
+ pd = _XtGetPerDisplay(event->xmapping.display);
+ if (event->xmapping.request != MappingPointer &&
+ pd && pd->keysyms && (event->xmapping.serial >= pd->keysyms_serial))
+ _XtBuildKeysymTables( event->xmapping.display, pd );
+ XRefreshKeyboardMapping(&event->xmapping);
+ if (dispatch && pd && pd->mapping_callbacks)
+ XtCallCallbackList((Widget) NULL,
+ (XtCallbackList)pd->mapping_callbacks,
+ (XtPointer)event );
+ UNLOCK_PROCESS;
+}
+
+void XtAppNextEvent(
+ XtAppContext app,
+ XEvent *event)
+{
+ int i, d;
+
+ LOCK_APP(app);
+ for (;;) {
+ if (app->count == 0)
+ DoOtherSources(app);
+ else {
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (d == 0) DoOtherSources(app);
+ if (XEventsQueued(app->list[d], QueuedAfterReading))
+ goto GotEvent;
+ }
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (XEventsQueued(app->list[d], QueuedAfterFlush))
+ goto GotEvent;
+ }
+ }
+
+ /* We're ready to wait...if there is a work proc, call it */
+ if (CallWorkProc(app)) continue;
+
+ d = _XtWaitForSomething (app,
+ FALSE, FALSE, FALSE, FALSE,
+ TRUE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *) NULL);
+
+ if (d != -1) {
+ GotEvent:
+ XNextEvent (app->list[d], event);
+#ifdef XTHREADS
+ /* assert(app->list[d] == event->xany.display); */
+#endif
+ app->last = d;
+ if (event->xany.type == MappingNotify)
+ _XtRefreshMapping(event, False);
+ UNLOCK_APP(app);
+ return;
+ }
+
+ } /* for */
+}
+
+void XtProcessEvent(
+ XtInputMask mask)
+{
+ XtAppProcessEvent(_XtDefaultAppContext(), mask);
+}
+
+void XtAppProcessEvent(
+ XtAppContext app,
+ XtInputMask mask)
+{
+ int i, d;
+ XEvent event;
+ struct timeval cur_time;
+
+ LOCK_APP(app);
+ if (mask == 0) {
+ UNLOCK_APP(app);
+ return;
+ }
+
+ for (;;) {
+
+ if (mask & XtIMSignal && app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice) {
+ se_ptr->se_notice = FALSE;
+ SeCallProc(se_ptr);
+ UNLOCK_APP(app);
+ return;
+ }
+ se_ptr = se_ptr->se_next;
+ }
+ }
+
+ if (mask & XtIMTimer && app->timerQueue != NULL) {
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ if (IS_AT_OR_AFTER(app->timerQueue->te_timer_value, cur_time)){
+ TimerEventRec *te_ptr = app->timerQueue;
+ app->timerQueue = app->timerQueue->te_next;
+ te_ptr->te_next = NULL;
+ if (te_ptr->te_proc != NULL)
+ TeCallProc(te_ptr);
+ LOCK_PROCESS;
+ te_ptr->te_next = freeTimerRecs;
+ freeTimerRecs = te_ptr;
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return;
+ }
+ }
+
+ if (mask & XtIMAlternateInput) {
+ if (app->input_count > 0 && app->outstandingQueue == NULL) {
+ /* Call _XtWaitForSomething to get input queued up */
+ (void) _XtWaitForSomething (app,
+ TRUE, TRUE, FALSE, TRUE,
+ FALSE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *)NULL);
+ }
+ if (app->outstandingQueue != NULL) {
+ InputEvent *ie_ptr = app->outstandingQueue;
+ app->outstandingQueue = ie_ptr->ie_oq;
+ ie_ptr->ie_oq = NULL;
+ IeCallProc(ie_ptr);
+ UNLOCK_APP(app);
+ return;
+ }
+ }
+
+ if (mask & XtIMXEvent) {
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (XEventsQueued(app->list[d], QueuedAfterReading))
+ goto GotEvent;
+ }
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (XEventsQueued(app->list[d], QueuedAfterFlush))
+ goto GotEvent;
+ }
+ }
+
+ /* Nothing to do...wait for something */
+
+ if (CallWorkProc(app)) continue;
+
+ d = _XtWaitForSomething (app,
+ (mask & XtIMXEvent ? FALSE : TRUE),
+ (mask & XtIMTimer ? FALSE : TRUE),
+ (mask & XtIMAlternateInput ? FALSE : TRUE),
+ (mask & XtIMSignal ? FALSE : TRUE),
+ TRUE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *) NULL);
+
+ if (mask & XtIMXEvent && d != -1) {
+ GotEvent:
+ XNextEvent(app->list[d], &event);
+#ifdef XTHREADS
+ /* assert(app->list[d] == event.xany.display); */
+#endif
+ app->last = d;
+ if (event.xany.type == MappingNotify) {
+ _XtRefreshMapping(&event, False);
+ }
+ XtDispatchEvent(&event);
+ UNLOCK_APP(app);
+ return;
+ }
+
+ }
+}
+
+Boolean XtPending(void)
+{
+ return (XtAppPending(_XtDefaultAppContext()) != 0);
+}
+
+XtInputMask XtAppPending(
+ XtAppContext app)
+{
+ struct timeval cur_time;
+ int d;
+ XtInputMask ret = 0;
+
+/*
+ * Check for pending X events
+ */
+ LOCK_APP(app);
+ for (d = 0; d < app->count; d++) {
+ if (XEventsQueued(app->list[d], QueuedAfterReading)) {
+ ret = XtIMXEvent;
+ break;
+ }
+ }
+ if (ret == 0) {
+ for (d = 0; d < app->count; d++) {
+ if (XEventsQueued(app->list[d], QueuedAfterFlush)) {
+ ret = XtIMXEvent;
+ break;
+ }
+ }
+ }
+
+ if (app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice) {
+ ret |= XtIMSignal;
+ break;
+ }
+ se_ptr = se_ptr->se_next;
+ }
+ }
+
+/*
+ * Check for pending alternate input
+ */
+ if (app->timerQueue != NULL) { /* check timeout queue */
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ if ((IS_AT_OR_AFTER(app->timerQueue->te_timer_value, cur_time)) &&
+ (app->timerQueue->te_proc != 0)) {
+ ret |= XtIMTimer;
+ }
+ }
+
+ if (app->outstandingQueue != NULL) ret |= XtIMAlternateInput;
+ else {
+ /* This won't cause a wait, but will enqueue any input */
+
+ if(_XtWaitForSomething (app,
+ FALSE, TRUE, FALSE, TRUE,
+ FALSE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *) NULL) != -1)
+ ret |= XtIMXEvent;
+ if (app->outstandingQueue != NULL) ret |= XtIMAlternateInput;
+ }
+ UNLOCK_APP(app);
+ return ret;
+}
+
+/* Peek at alternate input and timer callbacks if there are any */
+
+static Boolean PeekOtherSources(
+ XtAppContext app)
+{
+ struct timeval cur_time;
+
+ if (app->outstandingQueue != NULL) return TRUE;
+
+ if (app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice)
+ return TRUE;
+ se_ptr = se_ptr->se_next;
+ }
+ }
+
+ if (app->input_count > 0) {
+ /* Call _XtWaitForSomething to get input queued up */
+ (void) _XtWaitForSomething (app,
+ TRUE, TRUE, FALSE, TRUE,
+ FALSE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *)NULL);
+ if (app->outstandingQueue != NULL) return TRUE;
+ }
+
+ if (app->timerQueue != NULL) { /* check timeout queue */
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ if (IS_AT_OR_AFTER (app->timerQueue->te_timer_value, cur_time))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+Boolean XtPeekEvent(
+ XEvent *event)
+{
+ return XtAppPeekEvent(_XtDefaultAppContext(), event);
+}
+
+Boolean XtAppPeekEvent_SkipTimer;
+
+Boolean XtAppPeekEvent(
+ XtAppContext app,
+ XEvent *event)
+{
+ int i, d;
+ Boolean foundCall = FALSE;
+
+ LOCK_APP(app);
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (d == 0) foundCall = PeekOtherSources(app);
+ if (XEventsQueued(app->list[d], QueuedAfterReading))
+ goto GotEvent;
+ }
+ for (i = 1; i <= app->count; i++) {
+ d = (i + app->last) % app->count;
+ if (XEventsQueued(app->list[d], QueuedAfterFlush))
+ goto GotEvent;
+ }
+
+ if (foundCall) {
+ event->xany.type = 0;
+ event->xany.display = NULL;
+ event->xany.window = 0;
+ UNLOCK_APP(app);
+ return FALSE;
+ }
+
+ while (1) {
+ d = _XtWaitForSomething (app,
+ FALSE, FALSE, FALSE, FALSE,
+ TRUE,
+#ifdef XTHREADS
+ TRUE,
+#endif
+ (unsigned long *) NULL);
+
+ if (d != -1) { /* event */
+ GotEvent:
+ XPeekEvent(app->list[d], event);
+ app->last = (d == 0 ? app->count : d) - 1;
+ UNLOCK_APP(app);
+ return TRUE;
+ }
+ else { /* input or timer or signal */
+ /*
+ * Check to see why a -1 was returned, if a timer expired,
+ * call it and block some more
+ */
+ if ((app->timerQueue != NULL) && ! XtAppPeekEvent_SkipTimer) { /* timer */
+ struct timeval cur_time;
+ Bool did_timer = False;
+
+ X_GETTIMEOFDAY (&cur_time);
+ FIXUP_TIMEVAL(cur_time);
+ while (IS_AT_OR_AFTER(app->timerQueue->te_timer_value, cur_time)) {
+ TimerEventRec *te_ptr = app->timerQueue;
+ app->timerQueue = app->timerQueue->te_next;
+ te_ptr->te_next = NULL;
+ if (te_ptr->te_proc != NULL) {
+ TeCallProc(te_ptr);
+ did_timer = True;
+ }
+ LOCK_PROCESS;
+ te_ptr->te_next = freeTimerRecs;
+ freeTimerRecs = te_ptr;
+ UNLOCK_PROCESS;
+ if (app->timerQueue == NULL) break;
+ }
+ if (did_timer)
+ {
+ for (d = 0; d < app->count; d++)
+ /* the timer's procedure may have caused an event */
+ if (XEventsQueued(app->list[d], QueuedAfterFlush)) {
+ goto GotEvent;
+ }
+ continue; /* keep blocking */
+ }
+ }
+ /*
+ * spec is vague here; we'll assume signals also return FALSE,
+ * of course to determine whether a signal is pending requires
+ * walking the signalQueue looking for se_notice flags which
+ * this code doesn't do.
+ */
+#if 0
+ if (app->signalQueue != NULL) { /* signal */
+ event->xany.type = 0;
+ event->xany.display = NULL;
+ event->xany.window = 0;
+ UNLOCK_APP(app);
+ return FALSE;
+ }
+ else
+#endif
+ { /* input */
+ event->xany.type = 0;
+ event->xany.display = NULL;
+ event->xany.window = 0;
+ UNLOCK_APP(app);
+ return FALSE;
+ }
+ }
+ } /* end while */
+}
diff --git a/nx-X11/lib/Xt/Object.c b/nx-X11/lib/Xt/Object.c
new file mode 100644
index 000000000..f762a2545
--- /dev/null
+++ b/nx-X11/lib/Xt/Object.c
@@ -0,0 +1,297 @@
+/* $Xorg: Object.c,v 1.4 2001/02/09 02:03:56 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/Object.c,v 1.5 2001/01/17 19:43:06 dawes Exp $ */
+
+#define OBJECT
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+
+static XtResource resources[] = {
+ {XtNdestroyCallback, XtCCallback, XtRCallback,sizeof(XtPointer),
+ XtOffsetOf(ObjectRec,object.destroy_callbacks),
+ XtRCallback, (XtPointer)NULL}
+ };
+
+static void ObjectClassPartInitialize(WidgetClass);
+static Boolean ObjectSetValues(Widget, Widget, Widget, ArgList, Cardinal *);
+static void ObjectDestroy(Widget);
+
+externaldef(objectclassrec) ObjectClassRec objectClassRec = {
+ {
+ /* superclass */ NULL,
+ /* class_name */ "Object",
+ /* widget_size */ sizeof(ObjectRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize*/ ObjectClassPartInitialize,
+ /* class_inited */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_hook */ NULL,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* pad */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* pad */ FALSE,
+ /* pad */ FALSE,
+ /* pad */ FALSE,
+ /* pad */ FALSE,
+ /* destroy */ ObjectDestroy,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* set_values */ ObjectSetValues,
+ /* set_values_hook */ NULL,
+ /* pad */ NULL,
+ /* get_values_hook */ NULL,
+ /* pad */ NULL,
+ /* version */ XtVersion,
+ /* callback_offsets */ NULL,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* extension */ NULL
+}
+};
+
+externaldef(objectClass) WidgetClass objectClass
+ = (WidgetClass)&objectClassRec;
+
+/*
+ * Start of object routines.
+ */
+
+
+static void ConstructCallbackOffsets(
+ WidgetClass widgetClass)
+{
+ static XrmQuark QCallback = NULLQUARK;
+ register int i;
+ register int tableSize;
+ register CallbackTable newTable;
+ register CallbackTable superTable;
+ register XrmResourceList resourceList;
+ ObjectClass objectClass = (ObjectClass)widgetClass;
+
+ /*
+ This function builds an array of pointers to the resource
+ structures which describe the callbacks for this widget class.
+ This array is special in that the 0th entry is the number of
+ callback pointers.
+ */
+
+ if (QCallback == NULLQUARK)
+ QCallback = XrmPermStringToQuark(XtRCallback);
+
+ if (objectClass->object_class.superclass != NULL) {
+ superTable = (CallbackTable)
+ ((ObjectClass) objectClass->object_class.superclass)->
+ object_class.callback_private;
+ tableSize = (int)(long) superTable[0];
+ } else {
+ superTable = (CallbackTable) NULL;
+ tableSize = 0;
+ }
+
+ /* Count the number of callbacks */
+ resourceList = (XrmResourceList) objectClass->object_class.resources;
+ for (i = objectClass->object_class.num_resources; --i >= 0; resourceList++)
+ if (resourceList->xrm_type == QCallback)
+ tableSize++;
+
+ /*
+ * Allocate and load the table. Make sure that the new callback
+ * offsets occur in the table ahead of the superclass callback
+ * offsets so that resource overrides work.
+ */
+ newTable = (CallbackTable)
+ __XtMalloc(sizeof(XrmResource *) * (tableSize + 1));
+
+ newTable[0] = (XrmResource *)(long) tableSize;
+
+ if (superTable)
+ tableSize -= (int)(long) superTable[0];
+ resourceList = (XrmResourceList) objectClass->object_class.resources;
+ for (i=1; tableSize > 0; resourceList++)
+ if (resourceList->xrm_type == QCallback) {
+ newTable[i++] = resourceList;
+ tableSize--;
+ }
+
+ if (superTable)
+ for (tableSize = (int)(long) *superTable++;
+ --tableSize >= 0; superTable++)
+ newTable[i++] = *superTable;
+
+ objectClass->object_class.callback_private = (XtPointer) newTable;
+}
+
+static void InheritObjectExtensionMethods(
+ WidgetClass widget_class)
+{
+ ObjectClass oc = (ObjectClass) widget_class;
+ ObjectClassExtension ext, super_ext = NULL;
+
+ ext = (ObjectClassExtension)
+ XtGetClassExtension(widget_class,
+ XtOffsetOf(ObjectClassRec, object_class.extension),
+ NULLQUARK, XtObjectExtensionVersion,
+ sizeof(ObjectClassExtensionRec));
+
+ if (oc->object_class.superclass)
+ super_ext = (ObjectClassExtension)
+ XtGetClassExtension(oc->object_class.superclass,
+ XtOffsetOf(ObjectClassRec, object_class.extension),
+ NULLQUARK, XtObjectExtensionVersion,
+ sizeof(ObjectClassExtensionRec));
+ LOCK_PROCESS;
+ if (ext) {
+ if (ext->allocate == XtInheritAllocate)
+ ext->allocate = (super_ext ? super_ext->allocate : NULL);
+ if (ext->deallocate == XtInheritDeallocate)
+ ext->deallocate = (super_ext ? super_ext->deallocate : NULL);
+ } else if (super_ext) {
+ /* Be careful to inherit only what is appropriate */
+ ext = (ObjectClassExtension)
+ __XtCalloc(1, sizeof(ObjectClassExtensionRec));
+ ext->next_extension = oc->object_class.extension;
+ ext->record_type = NULLQUARK;
+ ext->version = XtObjectExtensionVersion;
+ ext->record_size = sizeof(ObjectClassExtensionRec);
+ ext->allocate = super_ext->allocate;
+ ext->deallocate = super_ext->deallocate;
+ oc->object_class.extension = (XtPointer) ext;
+ }
+ UNLOCK_PROCESS;
+}
+
+static void ObjectClassPartInitialize(
+ register WidgetClass wc)
+{
+ ObjectClass oc = (ObjectClass)wc;
+
+ oc->object_class.xrm_class =
+ XrmPermStringToQuark(oc->object_class.class_name);
+
+ if (oc->object_class.resources)
+ _XtCompileResourceList(oc->object_class.resources,
+ oc->object_class.num_resources);
+
+ ConstructCallbackOffsets(wc);
+ _XtResourceDependencies(wc);
+ InheritObjectExtensionMethods(wc);
+}
+
+
+/*ARGSUSED*/
+static Boolean ObjectSetValues(
+ Widget old,
+ Widget request,
+ Widget widget,
+ ArgList args,
+ Cardinal * num_args)
+{
+ register CallbackTable offsets;
+ register int i;
+ register InternalCallbackList *ol, *nl;
+
+ LOCK_PROCESS;
+ /* Compile any callback lists into internal form */
+ offsets = (CallbackTable) XtClass(widget)->core_class.callback_private;
+
+ for (i= (int)(long) *(offsets++); --i >= 0; offsets++) {
+ ol = (InternalCallbackList *)
+ ((char *) old - (*offsets)->xrm_offset - 1);
+ nl = (InternalCallbackList *)
+ ((char *) widget - (*offsets)->xrm_offset - 1);
+ if (*ol != *nl) {
+ if (*ol != NULL)
+ XtFree((char *) *ol);
+ if (*nl != NULL)
+ *nl = _XtCompileCallbackList((XtCallbackList) *nl);
+ }
+ }
+ UNLOCK_PROCESS;
+ return False;
+}
+
+
+static void ObjectDestroy (
+ register Widget widget)
+{
+ register CallbackTable offsets;
+ register int i;
+ register InternalCallbackList cl;
+
+ /* Remove all callbacks associated with widget */
+ LOCK_PROCESS;
+ offsets = (CallbackTable)
+ widget->core.widget_class->core_class.callback_private;
+
+ for (i = (int)(long) *(offsets++); --i >= 0; offsets++) {
+ cl = *(InternalCallbackList *)
+ ((char *) widget - (*offsets)->xrm_offset - 1);
+ if (cl) XtFree((char *) cl);
+ }
+ UNLOCK_PROCESS;
+} /* ObjectDestroy */
diff --git a/nx-X11/lib/Xt/Object.h b/nx-X11/lib/Xt/Object.h
new file mode 100644
index 000000000..96723b16e
--- /dev/null
+++ b/nx-X11/lib/Xt/Object.h
@@ -0,0 +1,60 @@
+/* $Xorg: Object.h,v 1.4 2001/02/09 02:03:56 xorgcvs Exp $ */
+/* $oHeader: Object.h,v 1.2 88/08/18 15:55:32 asente 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.
+
+******************************************************************/
+
+#ifndef _XtObject_h
+#define _XtObject_h
+
+typedef struct _ObjectRec *Object;
+typedef struct _ObjectClassRec *ObjectClass;
+
+#ifndef OBJECT
+externalref WidgetClass objectClass;
+#endif
+#endif /* _XtObject_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/ObjectP.h b/nx-X11/lib/Xt/ObjectP.h
new file mode 100644
index 000000000..a24564ef2
--- /dev/null
+++ b/nx-X11/lib/Xt/ObjectP.h
@@ -0,0 +1,139 @@
+/* $Xorg: ObjectP.h,v 1.4 2001/02/09 02:03:56 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+
+#ifndef _Xt_ObjectP_h_
+#define _Xt_ObjectP_h_
+
+#include <X11/Object.h>
+
+/**********************************************************
+ * Object Instance Data Structures
+ *
+ **********************************************************/
+/* these fields match CorePart and can not be changed */
+
+typedef struct _ObjectPart {
+ Widget self; /* pointer to widget itself */
+ WidgetClass widget_class; /* pointer to Widget's ClassRec */
+ Widget parent; /* parent widget */
+ XrmName xrm_name; /* widget resource name quarkified */
+ Boolean being_destroyed; /* marked for destroy */
+ XtCallbackList destroy_callbacks; /* who to call when widget destroyed */
+ XtPointer constraints; /* constraint record */
+} ObjectPart;
+
+typedef struct _ObjectRec {
+ ObjectPart object;
+} ObjectRec;
+
+/********************************************************
+ * Object Class Data Structures
+ *
+ ********************************************************/
+/* these fields match CoreClassPart and can not be changed */
+/* ideally these structures would only contain the fields required;
+ but because the CoreClassPart cannot be changed at this late date
+ extraneous fields are necessary to make the field offsets match */
+
+typedef struct _ObjectClassPart {
+
+ WidgetClass superclass; /* pointer to superclass ClassRec */
+ String class_name; /* widget resource class name */
+ Cardinal widget_size; /* size in bytes of widget record */
+ XtProc class_initialize; /* class initialization proc */
+ XtWidgetClassProc class_part_initialize; /* dynamic initialization */
+ XtEnum class_inited; /* has class been initialized? */
+ XtInitProc initialize; /* initialize subclass fields */
+ XtArgsProc initialize_hook; /* notify that initialize called */
+ XtProc obj1; /* NULL */
+ XtPointer obj2; /* NULL */
+ Cardinal obj3; /* NULL */
+ XtResourceList resources; /* resources for subclass fields */
+ Cardinal num_resources; /* number of entries in resources */
+ XrmClass xrm_class; /* resource class quarkified */
+ Boolean obj4; /* NULL */
+ XtEnum obj5; /* NULL */
+ Boolean obj6; /* NULL */
+ Boolean obj7; /* NULL */
+ XtWidgetProc destroy; /* free data for subclass pointers */
+ XtProc obj8; /* NULL */
+ XtProc obj9; /* NULL */
+ XtSetValuesFunc set_values; /* set subclass resource values */
+ XtArgsFunc set_values_hook; /* notify that set_values called */
+ XtProc obj10; /* NULL */
+ XtArgsProc get_values_hook; /* notify that get_values called */
+ XtProc obj11; /* NULL */
+ XtVersionType version; /* version of intrinsics used */
+ XtPointer callback_private; /* list of callback offsets */
+ String obj12; /* NULL */
+ XtProc obj13; /* NULL */
+ XtProc obj14; /* NULL */
+ XtPointer extension; /* pointer to extension record */
+}ObjectClassPart;
+
+typedef struct {
+ XtPointer next_extension; /* 1st 4 required for all extension records */
+ XrmQuark record_type; /* NULLQUARK; when on ObjectClassPart */
+ long version; /* must be XtObjectExtensionVersion */
+ Cardinal record_size; /* sizeof(ObjectClassExtensionRec) */
+ XtAllocateProc allocate;
+ XtDeallocateProc deallocate;
+} ObjectClassExtensionRec, *ObjectClassExtension;
+
+typedef struct _ObjectClassRec {
+ ObjectClassPart object_class;
+} ObjectClassRec;
+
+externalref ObjectClassRec objectClassRec;
+
+#define XtObjectExtensionVersion 1L
+#define XtInheritAllocate ((XtAllocateProc) _XtInherit)
+#define XtInheritDeallocate ((XtDeallocateProc) _XtInherit)
+
+#endif /*_Xt_ObjectP_h_*/
diff --git a/nx-X11/lib/Xt/PassivGraI.h b/nx-X11/lib/Xt/PassivGraI.h
new file mode 100644
index 000000000..02e296484
--- /dev/null
+++ b/nx-X11/lib/Xt/PassivGraI.h
@@ -0,0 +1,186 @@
+/*
+* $Xorg: PassivGraI.h,v 1.4 2001/02/09 02:03:56 xorgcvs Exp $
+*/
+
+/********************************************************
+
+Copyright 1988 by Hewlett-Packard Company
+Copyright 1987, 1988, 1989 by Digital Equipment Corporation, Maynard
+
+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 names of
+Hewlett-Packard or 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, 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.
+
+*/
+/* $XFree86: xc/lib/Xt/PassivGraI.h,v 1.3 2001/12/14 19:56:27 dawes Exp $ */
+
+#ifndef _PDI_h_
+#define _PDI_h_
+
+
+#define KEYBOARD TRUE
+#define POINTER FALSE
+
+typedef enum {
+ XtNoServerGrab,
+ XtPassiveServerGrab,
+ XtActiveServerGrab,
+ XtPseudoPassiveServerGrab,
+ XtPseudoActiveServerGrab
+}XtServerGrabType;
+
+typedef struct _XtServerGrabRec {
+ struct _XtServerGrabRec *next;
+ Widget widget;
+ unsigned int ownerEvents:1;
+ unsigned int pointerMode:1;
+ unsigned int keyboardMode:1;
+ unsigned int hasExt:1;
+ unsigned int confineToIsWidgetWin:1;
+ KeyCode keybut;
+ unsigned short modifiers;
+ unsigned short eventMask;
+} XtServerGrabRec, *XtServerGrabPtr;
+
+typedef struct _XtGrabExtRec {
+ Mask *pKeyButMask;
+ Mask *pModifiersMask;
+ Window confineTo;
+ Cursor cursor;
+} XtServerGrabExtRec, *XtServerGrabExtPtr;
+
+#define GRABEXT(p) ((XtServerGrabExtPtr)((p)+1))
+
+typedef struct _XtDeviceRec{
+ XtServerGrabRec grab; /* need copy in order to protect
+ during grab */
+ XtServerGrabType grabType;
+}XtDeviceRec, *XtDevice;
+
+#define XtMyAncestor 0
+#define XtMyDescendant 1
+#define XtMyCousin 2
+#define XtMySelf 3
+#define XtUnrelated 4
+typedef char XtGeneology; /* do not use an enum makes PerWidgetInput larger */
+
+typedef struct {
+ Widget focusKid;
+ XtServerGrabPtr keyList, ptrList;
+ Widget queryEventDescendant;
+ unsigned int map_handler_added:1;
+ unsigned int realize_handler_added:1;
+ unsigned int active_handler_added:1;
+ unsigned int haveFocus:1;
+ XtGeneology focalPoint;
+}XtPerWidgetInputRec, *XtPerWidgetInput;
+
+typedef struct XtPerDisplayInputRec{
+ XtGrabList grabList;
+ XtDeviceRec keyboard, pointer;
+ KeyCode activatingKey;
+ Widget *trace;
+ int traceDepth, traceMax;
+ Widget focusWidget;
+}XtPerDisplayInputRec, *XtPerDisplayInput;
+
+#define IsServerGrab(g) ((g == XtPassiveServerGrab) ||\
+ (g == XtActiveServerGrab))
+
+#define IsAnyGrab(g) ((g == XtPassiveServerGrab) ||\
+ (g == XtActiveServerGrab) ||\
+ (g == XtPseudoPassiveServerGrab))
+
+#define IsEitherPassiveGrab(g) ((g == XtPassiveServerGrab) ||\
+ (g == XtPseudoPassiveServerGrab))
+
+#define IsPseudoGrab(g) ((g == XtPseudoPassiveServerGrab))
+
+extern void _XtDestroyServerGrabs(
+ Widget /* w */,
+ XtPointer /* pwi */, /*XtPerWidgetInput*/
+ XtPointer /* call_data */
+);
+
+extern XtPerWidgetInput _XtGetPerWidgetInput(
+ Widget /* widget */,
+ _XtBoolean /* create */
+);
+
+extern XtServerGrabPtr _XtCheckServerGrabsOnWidget(
+ XEvent* /* event */,
+ Widget /* widget */,
+ _XtBoolean /* isKeyboard */
+);
+
+/*
+extern XtGrabList* _XtGetGrabList( XtPerDisplayInput );
+*/
+
+#define _XtGetGrabList(pdi) (&(pdi)->grabList)
+
+extern void _XtFreePerWidgetInput(
+ Widget /* w */,
+ XtPerWidgetInput /* pwi */
+);
+
+extern Widget _XtProcessKeyboardEvent(
+ XKeyEvent* /* event */,
+ Widget /* widget */,
+ XtPerDisplayInput /* pdi */
+);
+
+extern Widget _XtProcessPointerEvent(
+ XButtonEvent* /* event */,
+ Widget /* widget */,
+ XtPerDisplayInput /* pdi */
+);
+
+extern void _XtRegisterPassiveGrabs(
+ Widget /* widget */
+);
+
+extern void _XtClearAncestorCache(
+ Widget /* widget */
+);
+
+#endif /* _PDI_h_ */
diff --git a/nx-X11/lib/Xt/PassivGrab.c b/nx-X11/lib/Xt/PassivGrab.c
new file mode 100644
index 000000000..377efdcd5
--- /dev/null
+++ b/nx-X11/lib/Xt/PassivGrab.c
@@ -0,0 +1,1053 @@
+/* $Xorg: PassivGrab.c,v 1.5 2001/02/09 02:03:56 xorgcvs Exp $ */
+
+/********************************************************
+
+Copyright 1988 by Hewlett-Packard Company
+Copyright 1987, 1988, 1989,1990 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, CA.
+
+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 names of
+Hewlett-Packard, Digital, or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+********************************************************/
+/* $XFree86$ */
+
+/*
+
+Copyright 1987, 1988, 1989, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+#include "PassivGraI.h"
+
+/* typedef unsigned long Mask; */
+#define BITMASK(i) (((Mask)1) << ((i) & 31))
+#define MASKIDX(i) ((i) >> 5)
+#define MASKWORD(buf, i) buf[MASKIDX(i)]
+#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
+#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
+#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
+#define MasksPerDetailMask 8
+
+#define pDisplay(grabPtr) (((grabPtr)->widget)->core.screen->display)
+#define pWindow(grabPtr) (((grabPtr)->widget)->core.window)
+
+
+/***************************************************************************/
+/*********************** Internal Support Routines *************************/
+/***************************************************************************/
+
+/*
+ * Turn off (clear) the bit in the specified detail mask which is associated
+ * with the detail.
+ */
+
+static void DeleteDetailFromMask(
+ Mask **ppDetailMask,
+ unsigned short detail)
+{
+ Mask *pDetailMask = *ppDetailMask;
+
+ if (!pDetailMask) {
+ int i;
+ pDetailMask = (Mask *)__XtMalloc(sizeof(Mask) * MasksPerDetailMask);
+ for (i = MasksPerDetailMask; --i >= 0; )
+ pDetailMask[i] = ~0;
+ *ppDetailMask = pDetailMask;
+ }
+ BITCLEAR((pDetailMask), detail);
+}
+
+
+/*
+ * Make an exact copy of the specified detail mask.
+ */
+
+static Mask *CopyDetailMask(
+ Mask *pOriginalDetailMask)
+{
+ Mask *pTempMask;
+ int i;
+
+ if (!pOriginalDetailMask)
+ return NULL;
+
+ pTempMask = (Mask *)__XtMalloc(sizeof(Mask) * MasksPerDetailMask);
+
+ for ( i = 0; i < MasksPerDetailMask; i++)
+ pTempMask[i]= pOriginalDetailMask[i];
+
+ return pTempMask;
+}
+
+
+/*
+ * Allocate a new grab entry, and fill in all of the fields using the
+ * specified parameters.
+ */
+
+static XtServerGrabPtr CreateGrab(
+ Widget widget,
+ Boolean ownerEvents,
+ Modifiers modifiers,
+ KeyCode keybut,
+ int pointer_mode,
+ int keyboard_mode,
+ Mask event_mask,
+ Window confine_to,
+ Cursor cursor,
+ Boolean need_ext)
+{
+ XtServerGrabPtr grab;
+
+ if (confine_to || cursor)
+ need_ext = True;
+ grab = (XtServerGrabPtr)__XtMalloc(sizeof(XtServerGrabRec) +
+ (need_ext ? sizeof(XtServerGrabExtRec)
+ : 0));
+ grab->next = NULL;
+ grab->widget = widget;
+ grab->ownerEvents = ownerEvents;
+ grab->pointerMode = pointer_mode;
+ grab->keyboardMode = keyboard_mode;
+ grab->eventMask = event_mask;
+ grab->hasExt = need_ext;
+ grab->confineToIsWidgetWin = (XtWindow (widget) == confine_to);
+ grab->modifiers = modifiers;
+ grab->keybut = keybut;
+ if (need_ext) {
+ XtServerGrabExtPtr ext = GRABEXT(grab);
+ ext->pModifiersMask = NULL;
+ ext->pKeyButMask = NULL;
+ ext->confineTo = confine_to;
+ ext->cursor = cursor;
+ }
+ return grab;
+}
+
+
+/*
+ * Free up the space occupied by a grab entry.
+ */
+
+static void FreeGrab(
+ XtServerGrabPtr pGrab)
+{
+ if (pGrab->hasExt) {
+ XtServerGrabExtPtr ext = GRABEXT(pGrab);
+ if (ext->pModifiersMask)
+ XtFree((char *)ext->pModifiersMask);
+ if (ext->pKeyButMask)
+ XtFree((char *)ext->pKeyButMask);
+ }
+ XtFree((char *)pGrab);
+}
+
+typedef struct _DetailRec {
+ unsigned short exact;
+ Mask *pMask;
+} DetailRec, *DetailPtr;
+
+/*
+ * If the first detail is set to 'exception' and the second detail
+ * is contained in the mask of the first, then TRUE is returned.
+ */
+
+static Bool IsInGrabMask(
+ register DetailPtr firstDetail,
+ register DetailPtr secondDetail,
+ unsigned short exception)
+{
+ if (firstDetail->exact == exception) {
+ if (!firstDetail->pMask)
+ return TRUE;
+
+ /* (at present) never called with two non-null pMasks */
+ if (secondDetail->exact == exception)
+ return FALSE;
+
+ if (GETBIT(firstDetail->pMask, secondDetail->exact))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/*
+ * If neither of the details is set to 'exception', and they match
+ * exactly, then TRUE is returned.
+ */
+
+static Bool IdenticalExactDetails(
+ unsigned short firstExact,
+ unsigned short secondExact,
+ unsigned short exception)
+{
+ if ((firstExact == exception) || (secondExact == exception))
+ return FALSE;
+
+ if (firstExact == secondExact)
+ return TRUE;
+
+ return FALSE;
+}
+
+
+/*
+ * If the first detail is set to 'exception', and its mask has the bit
+ * enabled which corresponds to the second detail, OR if neither of the
+ * details is set to 'exception' and the details match exactly, then
+ * TRUE is returned.
+ */
+
+static Bool DetailSupersedesSecond(
+ register DetailPtr firstDetail,
+ register DetailPtr secondDetail,
+ unsigned short exception)
+{
+ if (IsInGrabMask(firstDetail, secondDetail, exception))
+ return TRUE;
+
+ if (IdenticalExactDetails(firstDetail->exact, secondDetail->exact,
+ exception))
+ return TRUE;
+
+ return FALSE;
+}
+
+
+/*
+ * If the two grab events match exactly, or if the first grab entry
+ * 'encompasses' the second grab entry, then TRUE is returned.
+ */
+
+static Bool GrabSupersedesSecond(
+ register XtServerGrabPtr pFirstGrab,
+ register XtServerGrabPtr pSecondGrab)
+{
+ DetailRec first, second;
+
+ first.exact = pFirstGrab->modifiers;
+ if (pFirstGrab->hasExt)
+ first.pMask = GRABEXT(pFirstGrab)->pModifiersMask;
+ else
+ first.pMask = NULL;
+ second.exact = pSecondGrab->modifiers;
+ if (pSecondGrab->hasExt)
+ second.pMask = GRABEXT(pSecondGrab)->pModifiersMask;
+ else
+ second.pMask = NULL;
+ if (!DetailSupersedesSecond(&first, &second, (unsigned short)AnyModifier))
+ return FALSE;
+
+ first.exact = pFirstGrab->keybut;
+ if (pFirstGrab->hasExt)
+ first.pMask = GRABEXT(pFirstGrab)->pKeyButMask;
+ else
+ first.pMask = NULL;
+ second.exact = pSecondGrab->keybut;
+ if (pSecondGrab->hasExt)
+ second.pMask = GRABEXT(pSecondGrab)->pKeyButMask;
+ else
+ second.pMask = NULL;
+ if (DetailSupersedesSecond(&first, &second, (unsigned short)AnyKey))
+ return TRUE;
+
+ return FALSE;
+}
+
+
+/*
+ * Two grabs are considered to be matching if either of the following are true:
+ *
+ * 1) The two grab entries match exactly, or the first grab entry
+ * encompasses the second grab entry.
+ * 2) The second grab entry encompasses the first grab entry.
+ * 3) The keycodes match exactly, and one entry's modifiers encompasses
+ * the others.
+ * 4) The keycode for one entry encompasses the other, and the detail
+ * for the other entry encompasses the first.
+ */
+
+static Bool GrabMatchesSecond(
+ register XtServerGrabPtr pFirstGrab,
+ register XtServerGrabPtr pSecondGrab)
+{
+ DetailRec firstD, firstM, secondD, secondM;
+
+ if (pDisplay(pFirstGrab) != pDisplay(pSecondGrab))
+ return FALSE;
+
+ if (GrabSupersedesSecond(pFirstGrab, pSecondGrab))
+ return TRUE;
+
+ if (GrabSupersedesSecond(pSecondGrab, pFirstGrab))
+ return TRUE;
+
+ firstD.exact = pFirstGrab->keybut;
+ firstM.exact = pFirstGrab->modifiers;
+ if (pFirstGrab->hasExt) {
+ firstD.pMask = GRABEXT(pFirstGrab)->pKeyButMask;
+ firstM.pMask = GRABEXT(pFirstGrab)->pModifiersMask;
+ } else {
+ firstD.pMask = NULL;
+ firstM.pMask = NULL;
+ }
+ secondD.exact = pSecondGrab->keybut;
+ secondM.exact = pSecondGrab->modifiers;
+ if (pSecondGrab->hasExt) {
+ secondD.pMask = GRABEXT(pSecondGrab)->pKeyButMask;
+ secondM.pMask = GRABEXT(pSecondGrab)->pModifiersMask;
+ } else {
+ secondD.pMask = NULL;
+ secondM.pMask = NULL;
+ }
+
+ if (DetailSupersedesSecond(&secondD, &firstD, (unsigned short)AnyKey) &&
+ DetailSupersedesSecond(&firstM, &secondM, (unsigned short)AnyModifier))
+ return TRUE;
+
+ if (DetailSupersedesSecond(&firstD, &secondD, (unsigned short)AnyKey) &&
+ DetailSupersedesSecond(&secondM, &firstM, (unsigned short)AnyModifier))
+ return TRUE;
+
+ return FALSE;
+}
+
+
+/*
+ * Delete a grab combination from the passive grab list. Each entry will
+ * be checked to see if it is affected by the grab being deleted. This
+ * may result in multiple entries being modified/deleted.
+ */
+
+static void DeleteServerGrabFromList(
+ XtServerGrabPtr *passiveListPtr,
+ XtServerGrabPtr pMinuendGrab)
+{
+ register XtServerGrabPtr *next;
+ register XtServerGrabPtr grab;
+ register XtServerGrabExtPtr ext;
+
+ for (next = passiveListPtr; (grab = *next); )
+ {
+ if (GrabMatchesSecond(grab, pMinuendGrab) &&
+ (pDisplay(grab) == pDisplay(pMinuendGrab)))
+ {
+ if (GrabSupersedesSecond(pMinuendGrab, grab))
+ {
+ /*
+ * The entry being deleted encompasses the list entry,
+ * so delete the list entry.
+ */
+ *next = grab->next;
+ FreeGrab(grab);
+ continue;
+ }
+
+ if (!grab->hasExt) {
+ grab = (XtServerGrabPtr)
+ XtRealloc((char *)grab, (sizeof(XtServerGrabRec) +
+ sizeof(XtServerGrabExtRec)));
+ *next = grab;
+ grab->hasExt = True;
+ ext = GRABEXT(grab);
+ ext->pKeyButMask = NULL;
+ ext->pModifiersMask = NULL;
+ ext->confineTo = None;
+ ext->cursor = None;
+ } else
+ ext = GRABEXT(grab);
+ if ((grab->keybut == AnyKey) && (grab->modifiers != AnyModifier))
+ {
+ /*
+ * If the list entry has the key detail of AnyKey, and
+ * a modifier detail not set to AnyModifier, then we
+ * simply need to turn off the key detail bit in the
+ * list entry's key detail mask.
+ */
+ DeleteDetailFromMask(&ext->pKeyButMask, pMinuendGrab->keybut);
+ } else if ((grab->modifiers == AnyModifier) &&
+ (grab->keybut != AnyKey)) {
+ /*
+ * The list entry has a specific key detail, but its
+ * modifier detail is set to AnyModifier; so, we only
+ * need to turn off the specified modifier combination
+ * in the list entry's modifier mask.
+ */
+ DeleteDetailFromMask(&ext->pModifiersMask,
+ pMinuendGrab->modifiers);
+ } else if ((pMinuendGrab->keybut != AnyKey) &&
+ (pMinuendGrab->modifiers != AnyModifier)) {
+ /*
+ * The list entry has a key detail of AnyKey and a
+ * modifier detail of AnyModifier; the entry being
+ * deleted has a specific key and a specific modifier
+ * combination. Therefore, we need to mask off the
+ * keycode from the list entry, and also create a
+ * new entry for this keycode, which has a modifier
+ * mask set to AnyModifier & ~(deleted modifiers).
+ */
+ XtServerGrabPtr pNewGrab;
+
+ DeleteDetailFromMask(&ext->pKeyButMask, pMinuendGrab->keybut);
+ pNewGrab = CreateGrab(grab->widget,
+ (Boolean)grab->ownerEvents,
+ (Modifiers)AnyModifier,
+ pMinuendGrab->keybut,
+ (int)grab->pointerMode,
+ (int)grab->keyboardMode,
+ (Mask)0, (Window)0, (Cursor)0, True);
+ GRABEXT(pNewGrab)->pModifiersMask =
+ CopyDetailMask(ext->pModifiersMask);
+
+ DeleteDetailFromMask(&GRABEXT(pNewGrab)->pModifiersMask,
+ pMinuendGrab->modifiers);
+
+ pNewGrab->next = *passiveListPtr;
+ *passiveListPtr = pNewGrab;
+ } else if (pMinuendGrab->keybut == AnyKey) {
+ /*
+ * The list entry has keycode AnyKey and modifier
+ * AnyModifier; the entry being deleted has
+ * keycode AnyKey and specific modifiers. So we
+ * simply need to mask off the specified modifier
+ * combination.
+ */
+ DeleteDetailFromMask(&ext->pModifiersMask,
+ pMinuendGrab->modifiers);
+ } else {
+ /*
+ * The list entry has keycode AnyKey and modifier
+ * AnyModifier; the entry being deleted has a
+ * specific keycode and modifier AnyModifier. So
+ * we simply need to mask off the specified
+ * keycode.
+ */
+ DeleteDetailFromMask(&ext->pKeyButMask, pMinuendGrab->keybut);
+ }
+ }
+ next = &(*next)->next;
+ }
+}
+
+static void DestroyPassiveList(
+ XtServerGrabPtr *passiveListPtr)
+{
+ XtServerGrabPtr next, grab;
+
+ for (next = *passiveListPtr; next; ) {
+ grab = next;
+ next = grab->next;
+
+ /* not necessary to explicitly ungrab key or button;
+ * window is being destroyed so server will take care of it.
+ */
+
+ FreeGrab(grab);
+ }
+}
+
+
+/*
+ * This function is called at widget destroy time to clean up
+ */
+/*ARGSUSED*/
+void _XtDestroyServerGrabs(
+ Widget w,
+ XtPointer closure,
+ XtPointer call_data) /* unused */
+{
+ XtPerWidgetInput pwi = (XtPerWidgetInput)closure;
+ XtPerDisplayInput pdi;
+
+ LOCK_PROCESS;
+ pdi = _XtGetPerDisplayInput(XtDisplay(w));
+ _XtClearAncestorCache(w);
+ UNLOCK_PROCESS;
+
+ /* Remove the active grab, if necessary */
+ if ((pdi->keyboard.grabType != XtNoServerGrab) &&
+ (pdi->keyboard.grab.widget == w)) {
+ pdi->keyboard.grabType = XtNoServerGrab;
+ pdi->activatingKey = (KeyCode)0;
+ }
+ if ((pdi->pointer.grabType != XtNoServerGrab) &&
+ (pdi->pointer.grab.widget == w))
+ pdi->pointer.grabType = XtNoServerGrab;
+
+ DestroyPassiveList(&pwi->keyList);
+ DestroyPassiveList(&pwi->ptrList);
+
+ _XtFreePerWidgetInput(w, pwi);
+}
+
+/*
+ * If the incoming event is on the passive grab list, then activate
+ * the grab. The grab will remain in effect until the key is released.
+ */
+
+XtServerGrabPtr _XtCheckServerGrabsOnWidget (
+ XEvent *event,
+ Widget widget,
+ _XtBoolean isKeyboard)
+{
+ register XtServerGrabPtr grab;
+ XtServerGrabRec tempGrab;
+ XtServerGrabPtr *passiveListPtr;
+ XtPerWidgetInput pwi;
+
+ LOCK_PROCESS;
+ pwi = _XtGetPerWidgetInput(widget, FALSE);
+ UNLOCK_PROCESS;
+ if (!pwi)
+ return (XtServerGrabPtr)NULL;
+ if (isKeyboard)
+ passiveListPtr = &pwi->keyList;
+ else
+ passiveListPtr = &pwi->ptrList;
+
+ /*
+ * if either there is no entry in the context manager or the entry
+ * is empty, or the keyboard is grabed, then no work to be done
+ */
+ if (!*passiveListPtr)
+ return (XtServerGrabPtr)NULL;
+
+ /* Take only the lower thirteen bits as modifier state. The X Keyboard
+ * Extension may be representing keyboard group state in two upper bits.
+ */
+ tempGrab.widget = widget;
+ tempGrab.keybut = event->xkey.keycode; /* also xbutton.button */
+ tempGrab.modifiers = event->xkey.state & 0x1FFF; /*also xbutton.state*/
+ tempGrab.hasExt = False;
+
+ for (grab = *passiveListPtr; grab; grab = grab->next) {
+ if (GrabMatchesSecond(&tempGrab, grab))
+ return (grab);
+ }
+ return (XtServerGrabPtr)NULL;
+}
+
+/*
+ * This handler is needed to guarantee that we see releases on passive
+ * button grabs for widgets that haven't selected for button release.
+ */
+
+/*ARGSUSED*/
+static void ActiveHandler (
+ Widget widget,
+ XtPointer pdi,
+ XEvent *event,
+ Boolean *cont)
+{
+ /* nothing */
+}
+
+
+/*
+ * MakeGrab
+ */
+static void MakeGrab(
+ XtServerGrabPtr grab,
+ XtServerGrabPtr *passiveListPtr,
+ Boolean isKeyboard,
+ XtPerDisplayInput pdi,
+ XtPerWidgetInput pwi)
+{
+ if (!isKeyboard && !pwi->active_handler_added) {
+ XtAddEventHandler(grab->widget, ButtonReleaseMask, FALSE,
+ ActiveHandler, (XtPointer)pdi);
+ pwi->active_handler_added = TRUE;
+ }
+
+ if (isKeyboard) {
+ XGrabKey(pDisplay(grab),
+ grab->keybut, grab->modifiers,
+ pWindow(grab), grab->ownerEvents,
+ grab->pointerMode, grab->keyboardMode);
+ } else {
+ Window confineTo = None;
+ Cursor cursor = None;
+
+ if (grab->hasExt) {
+ if (grab->confineToIsWidgetWin)
+ confineTo = XtWindow (grab->widget);
+ else
+ confineTo = GRABEXT(grab)->confineTo;
+ cursor = GRABEXT(grab)->cursor;
+ }
+ XGrabButton(pDisplay(grab),
+ grab->keybut, grab->modifiers,
+ pWindow(grab), grab->ownerEvents, grab->eventMask,
+ grab->pointerMode, grab->keyboardMode,
+ confineTo, cursor);
+ }
+
+ /* Add the new grab entry to the passive key grab list */
+ grab->next = *passiveListPtr;
+ *passiveListPtr = grab;
+}
+
+static void MakeGrabs(
+ XtServerGrabPtr *passiveListPtr,
+ Boolean isKeyboard,
+ XtPerDisplayInput pdi)
+{
+ XtServerGrabPtr next = *passiveListPtr;
+ XtServerGrabPtr grab;
+ XtPerWidgetInput pwi;
+ /*
+ * make MakeGrab build a new list that has had the merge
+ * processing done on it. Start with an empty list
+ * (passiveListPtr).
+ */
+ LOCK_PROCESS;
+ *passiveListPtr = NULL;
+ while (next)
+ {
+ grab = next;
+ next = grab->next;
+ pwi = _XtGetPerWidgetInput(grab->widget, FALSE);
+ MakeGrab(grab, passiveListPtr, isKeyboard, pdi, pwi);
+ }
+ UNLOCK_PROCESS;
+}
+
+/*
+ * This function is the event handler attached to the associated widget
+ * when grabs need to be added, but the widget is not yet realized. When
+ * it is first mapped, this handler will be invoked, and it will add all
+ * needed grabs.
+ */
+
+/*ARGSUSED*/
+static void RealizeHandler (
+ Widget widget,
+ XtPointer closure,
+ XEvent *event, /* unused */
+ Boolean *cont) /* unused */
+{
+ XtPerWidgetInput pwi = (XtPerWidgetInput)closure;
+ XtPerDisplayInput pdi;
+
+ LOCK_PROCESS;
+ pdi = _XtGetPerDisplayInput(XtDisplay(widget));
+ UNLOCK_PROCESS;
+ MakeGrabs(&pwi->keyList, KEYBOARD, pdi);
+ MakeGrabs(&pwi->ptrList, POINTER, pdi);
+
+ XtRemoveEventHandler(widget, XtAllEvents, True,
+ RealizeHandler, (XtPointer)pwi);
+ pwi->realize_handler_added = FALSE;
+}
+
+/***************************************************************************/
+/**************************** Global Routines ******************************/
+/***************************************************************************/
+
+
+/*
+ * Routine used by an application to set up a passive grab for a key/modifier
+ * combination.
+ */
+
+static
+void GrabKeyOrButton (
+ Widget widget,
+ KeyCode keyOrButton,
+ Modifiers modifiers,
+ Boolean owner_events,
+ int pointer_mode,
+ int keyboard_mode,
+ Mask event_mask,
+ Window confine_to,
+ Cursor cursor,
+ Boolean isKeyboard)
+{
+ XtServerGrabPtr *passiveListPtr;
+ XtServerGrabPtr newGrab;
+ XtPerWidgetInput pwi;
+ XtPerDisplayInput pdi;
+
+
+ XtCheckSubclass(widget, coreWidgetClass, "in XtGrabKey or XtGrabButton");
+ LOCK_PROCESS;
+ pwi = _XtGetPerWidgetInput(widget, TRUE);
+ if (isKeyboard)
+ passiveListPtr = &pwi->keyList;
+ else
+ passiveListPtr = &pwi->ptrList;
+ pdi = _XtGetPerDisplayInput(XtDisplay(widget));
+ UNLOCK_PROCESS;
+ newGrab = CreateGrab(widget, owner_events, modifiers,
+ keyOrButton, pointer_mode, keyboard_mode,
+ event_mask, confine_to, cursor, False);
+ /*
+ * if the widget is realized then process the entry into the grab
+ * list. else if the list is empty (i.e. first time) then add the
+ * event handler. then add the raw entry to the list for processing
+ * in the handler at realize time.
+ */
+ if (XtIsRealized(widget))
+ MakeGrab(newGrab, passiveListPtr, isKeyboard, pdi, pwi);
+ else {
+ if (!pwi->realize_handler_added)
+ {
+ XtAddEventHandler(widget, StructureNotifyMask, FALSE,
+ RealizeHandler,
+ (XtPointer)pwi);
+ pwi->realize_handler_added = TRUE;
+ }
+
+ while (*passiveListPtr)
+ passiveListPtr = &(*passiveListPtr)->next;
+ *passiveListPtr = newGrab;
+ }
+}
+
+
+static
+void UngrabKeyOrButton (
+ Widget widget,
+ int keyOrButton,
+ Modifiers modifiers,
+ Boolean isKeyboard)
+{
+ XtServerGrabRec tempGrab;
+ XtPerWidgetInput pwi;
+
+ XtCheckSubclass(widget, coreWidgetClass,
+ "in XtUngrabKey or XtUngrabButton");
+
+ /* Build a temporary grab list entry */
+ tempGrab.widget = widget;
+ tempGrab.modifiers = modifiers;
+ tempGrab.keybut = keyOrButton;
+ tempGrab.hasExt = False;
+
+ LOCK_PROCESS;
+ pwi = _XtGetPerWidgetInput(widget, FALSE);
+ UNLOCK_PROCESS;
+ /*
+ * if there is no entry in the context manager then somethings wrong
+ */
+ if (!pwi)
+ {
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "invalidGrab", "ungrabKeyOrButton", XtCXtToolkitError,
+ "Attempt to remove nonexistent passive grab",
+ (String *)NULL, (Cardinal *)NULL);
+ return;
+ }
+
+ if (XtIsRealized(widget))
+ {
+ if (isKeyboard)
+ XUngrabKey(widget->core.screen->display,
+ keyOrButton, (unsigned int)modifiers,
+ widget->core.window);
+ else
+ XUngrabButton(widget->core.screen->display,
+ keyOrButton, (unsigned int)modifiers,
+ widget->core.window);
+ }
+
+
+ /* Delete all entries which are encompassed by the specified grab. */
+ DeleteServerGrabFromList(isKeyboard ? &pwi->keyList : &pwi->ptrList,
+ &tempGrab);
+}
+
+void XtGrabKey (
+ Widget widget,
+ _XtKeyCode keycode,
+ Modifiers modifiers,
+ _XtBoolean owner_events,
+ int pointer_mode,
+ int keyboard_mode)
+{
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ GrabKeyOrButton(widget, (KeyCode)keycode, modifiers, owner_events,
+ pointer_mode, keyboard_mode,
+ (Mask)0, (Window)None, (Cursor)None, KEYBOARD);
+ UNLOCK_APP(app);
+}
+
+void XtGrabButton(
+ Widget widget,
+ int button,
+ Modifiers modifiers,
+ _XtBoolean owner_events,
+ unsigned int event_mask,
+ int pointer_mode,
+ int keyboard_mode,
+ Window confine_to,
+ Cursor cursor)
+{
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ GrabKeyOrButton(widget, (KeyCode)button, modifiers, owner_events,
+ pointer_mode, keyboard_mode,
+ (Mask)event_mask, confine_to, cursor, POINTER);
+ UNLOCK_APP(app);
+}
+
+
+/*
+ * Routine used by an application to clear a passive grab for a key/modifier
+ * combination.
+ */
+
+void XtUngrabKey (
+ Widget widget,
+ _XtKeyCode keycode,
+ Modifiers modifiers)
+{
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ UngrabKeyOrButton(widget, (int)keycode, modifiers, KEYBOARD);
+ UNLOCK_APP(app);
+}
+
+void XtUngrabButton (
+ Widget widget,
+ unsigned int button,
+ Modifiers modifiers)
+{
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ UngrabKeyOrButton(widget, (KeyCode)button, modifiers, POINTER);
+ UNLOCK_APP(app);
+}
+
+/*
+ * Active grab of Device. clear any client side grabs so we dont lock
+ */
+static int GrabDevice (
+ Widget widget,
+ Boolean owner_events,
+ int pointer_mode,
+ int keyboard_mode,
+ Mask event_mask,
+ Window confine_to,
+ Cursor cursor,
+ Time time,
+ Boolean isKeyboard)
+{
+ XtPerDisplayInput pdi;
+ int returnVal;
+
+ XtCheckSubclass(widget, coreWidgetClass,
+ "in XtGrabKeyboard or XtGrabPointer");
+ if (!XtIsRealized(widget))
+ return GrabNotViewable;
+ LOCK_PROCESS;
+ pdi = _XtGetPerDisplayInput(XtDisplay(widget));
+ UNLOCK_PROCESS;
+ if (!isKeyboard)
+ returnVal = XGrabPointer(XtDisplay(widget), XtWindow(widget),
+ owner_events, event_mask,
+ pointer_mode, keyboard_mode,
+ confine_to, cursor, time);
+ else
+ returnVal = XGrabKeyboard(XtDisplay(widget), XtWindow(widget),
+ owner_events, pointer_mode,
+ keyboard_mode, time);
+
+ if (returnVal == GrabSuccess) {
+ XtDevice device;
+
+ device = isKeyboard ? &pdi->keyboard : &pdi->pointer;
+ /* fill in the server grab rec */
+ device->grab.widget = widget;
+ device->grab.modifiers = 0;
+ device->grab.keybut = 0;
+ device->grab.ownerEvents = owner_events;
+ device->grab.pointerMode = pointer_mode;
+ device->grab.keyboardMode = keyboard_mode;
+ device->grab.hasExt = False;
+ device->grabType = XtActiveServerGrab;
+ pdi->activatingKey = (KeyCode)0;
+ }
+ return returnVal;
+}
+
+static void UngrabDevice(
+ Widget widget,
+ Time time,
+ Boolean isKeyboard)
+{
+ XtPerDisplayInput pdi;
+ XtDevice device;
+
+ LOCK_PROCESS;
+ pdi = _XtGetPerDisplayInput(XtDisplay(widget));
+ UNLOCK_PROCESS;
+ device = isKeyboard ? &pdi->keyboard : &pdi->pointer;
+ XtCheckSubclass(widget, coreWidgetClass,
+ "in XtUngrabKeyboard or XtUngrabPointer");
+
+ if (device->grabType != XtNoServerGrab) {
+
+ if (device->grabType != XtPseudoPassiveServerGrab
+ && XtIsRealized(widget)) {
+ if (isKeyboard)
+ XUngrabKeyboard(XtDisplay(widget), time);
+ else
+ XUngrabPointer(XtDisplay(widget), time);
+ }
+ device->grabType = XtNoServerGrab;
+ pdi->activatingKey = (KeyCode)0;
+ }
+}
+
+
+/*
+ * Active grab of keyboard. clear any client side grabs so we dont lock
+ */
+int XtGrabKeyboard (
+ Widget widget,
+ _XtBoolean owner_events,
+ int pointer_mode,
+ int keyboard_mode,
+ Time time)
+{
+ int retval;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ retval = GrabDevice (widget, owner_events,
+ pointer_mode, keyboard_mode,
+ (Mask)0, (Window)None, (Cursor)None, time, KEYBOARD);
+ UNLOCK_APP(app);
+ return retval;
+}
+
+
+/*
+ * Ungrab the keyboard
+ */
+
+void XtUngrabKeyboard(
+ Widget widget,
+ Time time)
+{
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ UngrabDevice(widget, time, KEYBOARD);
+ UNLOCK_APP(app);
+}
+
+
+
+
+/*
+ * grab the pointer
+ */
+int XtGrabPointer (
+ Widget widget,
+ _XtBoolean owner_events,
+ unsigned int event_mask,
+ int pointer_mode,
+ int keyboard_mode,
+ Window confine_to,
+ Cursor cursor,
+ Time time)
+{
+ int retval;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ retval = GrabDevice (widget, owner_events,
+ pointer_mode, keyboard_mode,
+ (Mask)event_mask, confine_to,
+ cursor, time, POINTER);
+ UNLOCK_APP(app);
+ return retval;
+}
+
+
+/*
+ * Ungrab the pointer
+ */
+
+void XtUngrabPointer(
+ Widget widget,
+ Time time)
+{
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ UngrabDevice(widget, time, POINTER);
+ UNLOCK_APP(app);
+}
+
+
+void _XtRegisterPassiveGrabs (
+ Widget widget)
+{
+ XtPerWidgetInput pwi = _XtGetPerWidgetInput (widget, FALSE);
+
+ if (pwi != NULL && !pwi->realize_handler_added) {
+ XtAddEventHandler(widget, StructureNotifyMask, FALSE,
+ RealizeHandler,
+ (XtPointer)pwi);
+ pwi->realize_handler_added = TRUE;
+ }
+}
diff --git a/nx-X11/lib/Xt/Pointer.c b/nx-X11/lib/Xt/Pointer.c
new file mode 100644
index 000000000..bbcb13371
--- /dev/null
+++ b/nx-X11/lib/Xt/Pointer.c
@@ -0,0 +1,115 @@
+/* $Xorg: Pointer.c,v 1.4 2001/02/09 02:03:56 xorgcvs Exp $ */
+
+/********************************************************
+
+Copyright 1988 by Hewlett-Packard Company
+Copyright 1987, 1988, 1989 by Digital Equipment Corporation, Maynard
+
+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 names of
+Hewlett-Packard or 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, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "PassivGraI.h"
+
+
+#define AllButtonsMask (Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask)
+
+Widget _XtProcessPointerEvent(
+ XButtonEvent *event,
+ Widget widget,
+ XtPerDisplayInput pdi)
+{
+ XtDevice device = &pdi->pointer;
+ XtServerGrabPtr newGrab = NULL, devGrab = &device->grab;
+ Widget dspWidget = NULL;
+ Boolean deactivateGrab = FALSE;
+
+ switch (event->type)
+ {
+ case ButtonPress:
+ {
+ if (!IsServerGrab(device->grabType))
+ {
+ Cardinal i;
+
+ for (i = pdi->traceDepth;
+ i > 0 && !newGrab;
+ i--)
+ newGrab = _XtCheckServerGrabsOnWidget((XEvent*)event,
+ pdi->trace[i-1],
+ POINTER);
+ }
+ if (newGrab)
+ {
+ /* Activate the grab */
+ device->grab = *newGrab;
+ device->grabType = XtPassiveServerGrab;
+ }
+ }
+ break;
+
+ case ButtonRelease:
+ {
+ if ((device->grabType == XtPassiveServerGrab) &&
+ !(event->state & ~(Button1Mask << (event->button - 1)) &
+ AllButtonsMask))
+ deactivateGrab = TRUE;
+ }
+ break;
+ }
+
+ if (IsServerGrab(device->grabType) && !(devGrab)->ownerEvents)
+ dspWidget = (devGrab)->widget;
+ else
+ dspWidget = widget;
+
+ if (deactivateGrab)
+ device->grabType = XtNoServerGrab;
+
+ return dspWidget;
+}
diff --git a/nx-X11/lib/Xt/Popup.c b/nx-X11/lib/Xt/Popup.c
new file mode 100644
index 000000000..aac712da1
--- /dev/null
+++ b/nx-X11/lib/Xt/Popup.c
@@ -0,0 +1,198 @@
+/* $Xorg: Popup.c,v 1.4 2001/02/09 02:03:56 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "ShellP.h"
+
+void _XtPopup(
+ Widget widget,
+ XtGrabKind grab_kind,
+ _XtBoolean spring_loaded)
+{
+ register ShellWidget shell_widget = (ShellWidget) widget;
+
+ if (! XtIsShell(widget)) {
+ XtAppErrorMsg(XtWidgetToApplicationContext(widget),
+ "invalidClass","xtPopup",XtCXtToolkitError,
+ "XtPopup requires a subclass of shellWidgetClass",
+ (String *)NULL, (Cardinal *)NULL);
+ }
+
+ if (! shell_widget->shell.popped_up) {
+ XtGrabKind call_data = grab_kind;
+ XtCallCallbacks(widget, XtNpopupCallback, (XtPointer)&call_data);
+ shell_widget->shell.popped_up = TRUE;
+ shell_widget->shell.grab_kind = grab_kind;
+ shell_widget->shell.spring_loaded = spring_loaded;
+ if (shell_widget->shell.create_popup_child_proc != NULL) {
+ (*(shell_widget->shell.create_popup_child_proc))(widget);
+ }
+ if (grab_kind == XtGrabExclusive) {
+ XtAddGrab(widget, TRUE, spring_loaded);
+ } else if (grab_kind == XtGrabNonexclusive) {
+ XtAddGrab(widget, FALSE, spring_loaded);
+ }
+ XtRealizeWidget(widget);
+ XMapRaised(XtDisplay(widget), XtWindow(widget));
+ } else
+ XRaiseWindow(XtDisplay(widget), XtWindow(widget));
+
+} /* _XtPopup */
+
+void XtPopup (Widget widget, XtGrabKind grab_kind)
+{
+ Widget hookobj;
+
+ switch (grab_kind) {
+
+ case XtGrabNone:
+ case XtGrabExclusive:
+ case XtGrabNonexclusive:
+ break;
+
+ default:
+ XtAppWarningMsg(
+ XtWidgetToApplicationContext(widget),
+ "invalidGrabKind","xtPopup",XtCXtToolkitError,
+ "grab kind argument has invalid value; XtGrabNone assumed",
+ (String *)NULL, (Cardinal *)NULL);
+ grab_kind = XtGrabNone;
+ }
+
+ _XtPopup(widget, grab_kind, FALSE);
+
+ hookobj = XtHooksOfDisplay(XtDisplay(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHpopup;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer)grab_kind;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+} /* XtPopup */
+
+void XtPopupSpringLoaded (
+ Widget widget)
+{
+ Widget hookobj;
+
+ _XtPopup(widget, XtGrabExclusive, True);
+
+ hookobj = XtHooksOfDisplay(XtDisplay(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHpopupSpringLoaded;
+ call_data.widget = widget;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+}
+
+void XtPopdown(
+ Widget widget)
+{
+ /* Unmap a shell widget if it is mapped, and remove from grab list */
+ Widget hookobj;
+ ShellWidget shell_widget = (ShellWidget) widget;
+ XtGrabKind grab_kind;
+
+ if (! XtIsShell(widget)) {
+ XtAppErrorMsg(XtWidgetToApplicationContext(widget),
+ "invalidClass","xtPopdown",XtCXtToolkitError,
+ "XtPopdown requires a subclass of shellWidgetClass",
+ (String *)NULL, (Cardinal *)NULL);
+ }
+
+#ifndef X_NO_XT_POPDOWN_CONFORMANCE
+ if (!shell_widget->shell.popped_up)
+ return;
+#endif
+
+ grab_kind = shell_widget->shell.grab_kind;
+ XWithdrawWindow(XtDisplay(widget), XtWindow(widget),
+ XScreenNumberOfScreen(XtScreen(widget)));
+ if (grab_kind != XtGrabNone)
+ XtRemoveGrab(widget);
+ shell_widget->shell.popped_up = FALSE;
+ XtCallCallbacks(widget, XtNpopdownCallback, (XtPointer)&grab_kind);
+
+ hookobj = XtHooksOfDisplay(XtDisplay(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHpopdown;
+ call_data.widget = widget;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+} /* XtPopdown */
+
+/* ARGSUSED */
+void XtCallbackPopdown(
+ Widget widget,
+ XtPointer closure,
+ XtPointer call_data)
+{
+ register XtPopdownID id = (XtPopdownID) closure;
+
+ XtPopdown(id->shell_widget);
+ if (id->enable_widget != NULL) {
+ XtSetSensitive(id->enable_widget, TRUE);
+ }
+} /* XtCallbackPopdown */
diff --git a/nx-X11/lib/Xt/PopupCB.c b/nx-X11/lib/Xt/PopupCB.c
new file mode 100644
index 000000000..be5fd8502
--- /dev/null
+++ b/nx-X11/lib/Xt/PopupCB.c
@@ -0,0 +1,84 @@
+/* $Xorg: PopupCB.c,v 1.4 2001/02/09 02:03:56 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.
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+
+/* ARGSUSED */
+void XtCallbackNone(
+ Widget widget,
+ XtPointer closure,
+ XtPointer call_data)
+{
+ XtSetSensitive(widget, FALSE);
+ _XtPopup((Widget) closure, XtGrabNone, FALSE);
+} /* XtCallbackNone */
+
+/* ARGSUSED */
+void XtCallbackNonexclusive(
+ Widget widget,
+ XtPointer closure,
+ XtPointer call_data)
+{
+
+ XtSetSensitive(widget, FALSE);
+ _XtPopup((Widget) closure, XtGrabNonexclusive, FALSE);
+} /* XtCallbackNonexclusive */
+
+/* ARGSUSED */
+void XtCallbackExclusive(
+ Widget widget,
+ XtPointer closure,
+ XtPointer call_data)
+{
+ XtSetSensitive(widget, FALSE);
+ _XtPopup((Widget) closure, XtGrabExclusive, FALSE);
+} /* XtCallbackExclusive */
diff --git a/nx-X11/lib/Xt/RectObj.c b/nx-X11/lib/Xt/RectObj.c
new file mode 100644
index 000000000..07bbd1ff3
--- /dev/null
+++ b/nx-X11/lib/Xt/RectObj.c
@@ -0,0 +1,194 @@
+/* $Xorg: RectObj.c,v 1.4 2001/02/09 02:03:56 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/RectObj.c,v 1.2 2001/08/22 22:52:19 dawes Exp $ */
+
+#define RECTOBJ
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+#include "CreateI.h"
+
+/******************************************************************
+ *
+ * Rectangle Object Resources
+ *
+ ******************************************************************/
+
+static void XtCopyAncestorSensitive(Widget, int, XrmValue *);
+
+static XtResource resources[] = {
+
+ {XtNancestorSensitive, XtCSensitive, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(RectObjRec,rectangle.ancestor_sensitive),XtRCallProc,
+ (XtPointer)XtCopyAncestorSensitive},
+ {XtNx, XtCPosition, XtRPosition, sizeof(Position),
+ XtOffsetOf(RectObjRec,rectangle.x), XtRImmediate, (XtPointer)0},
+ {XtNy, XtCPosition, XtRPosition, sizeof(Position),
+ XtOffsetOf(RectObjRec,rectangle.y), XtRImmediate, (XtPointer)0},
+ {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
+ XtOffsetOf(RectObjRec,rectangle.width), XtRImmediate, (XtPointer)0},
+ {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
+ XtOffsetOf(RectObjRec,rectangle.height), XtRImmediate, (XtPointer)0},
+ {XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
+ XtOffsetOf(RectObjRec,rectangle.border_width), XtRImmediate,
+ (XtPointer)1},
+ {XtNsensitive, XtCSensitive, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(RectObjRec,rectangle.sensitive), XtRImmediate,
+ (XtPointer)True}
+ };
+
+static void RectClassPartInitialize(WidgetClass);
+static void RectSetValuesAlmost(Widget, Widget, XtWidgetGeometry *, XtWidgetGeometry *);
+
+externaldef(rectobjclassrec) RectObjClassRec rectObjClassRec = {
+ {
+ /* superclass */ (WidgetClass)&objectClassRec,
+ /* class_name */ "Rect",
+ /* widget_size */ sizeof(RectObjRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize*/ RectClassPartInitialize,
+ /* class_inited */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_hook */ NULL,
+ /* realize */ NULL,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ NULL,
+ /* expose */ NULL,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ RectSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL
+ }
+};
+
+externaldef(rectObjClass)
+WidgetClass rectObjClass = (WidgetClass)&rectObjClassRec;
+
+/*ARGSUSED*/
+static void XtCopyAncestorSensitive(
+ Widget widget,
+ int offset,
+ XrmValue *value)
+{
+ static Boolean sensitive;
+ Widget parent = widget->core.parent;
+
+ sensitive = (parent->core.ancestor_sensitive & parent->core.sensitive);
+ value->addr = (XPointer)(&sensitive);
+}
+
+
+/*
+ * Start of rectangle object methods
+ */
+
+
+static void RectClassPartInitialize(
+ register WidgetClass wc)
+{
+ register RectObjClass roc = (RectObjClass)wc;
+ register RectObjClass super = ((RectObjClass)roc->rect_class.superclass);
+
+ /* We don't need to check for null super since we'll get to object
+ eventually, and it had better define them! */
+
+
+ if (roc->rect_class.resize == XtInheritResize) {
+ roc->rect_class.resize = super->rect_class.resize;
+ }
+
+ if (roc->rect_class.expose == XtInheritExpose) {
+ roc->rect_class.expose = super->rect_class.expose;
+ }
+
+ if (roc->rect_class.set_values_almost == XtInheritSetValuesAlmost) {
+ roc->rect_class.set_values_almost = super->rect_class.set_values_almost;
+ }
+
+
+ if (roc->rect_class.query_geometry == XtInheritQueryGeometry) {
+ roc->rect_class.query_geometry = super->rect_class.query_geometry;
+ }
+}
+
+/*
+ * Why there isn't an Initialize Method:
+ *
+ * Initialization of the RectObj non-Resource field is done by the
+ * intrinsics in _XtCreateWidget in order that the field is initialized
+ * for use by converters during instance resource resolution.
+ */
+
+/*ARGSUSED*/
+static void RectSetValuesAlmost(
+ Widget old,
+ Widget new,
+ XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+ *request = *reply;
+}
diff --git a/nx-X11/lib/Xt/RectObj.h b/nx-X11/lib/Xt/RectObj.h
new file mode 100644
index 000000000..07615fab7
--- /dev/null
+++ b/nx-X11/lib/Xt/RectObj.h
@@ -0,0 +1,60 @@
+/* $Xorg: RectObj.h,v 1.4 2001/02/09 02:03:56 xorgcvs Exp $ */
+/* $oHeader: RectObj.h,v 1.2 88/08/18 17:39:17 asente 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.
+
+******************************************************************/
+
+#ifndef _XtRect_h
+#define _XtRect_h
+
+typedef struct _RectObjRec *RectObj;
+typedef struct _RectObjClassRec *RectObjClass;
+
+#ifndef RECTOBJ
+externalref WidgetClass rectObjClass;
+#endif
+#endif /* _XtRect_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/RectObjP.h b/nx-X11/lib/Xt/RectObjP.h
new file mode 100644
index 000000000..ca3b8ade7
--- /dev/null
+++ b/nx-X11/lib/Xt/RectObjP.h
@@ -0,0 +1,129 @@
+/* $Xorg: RectObjP.h,v 1.4 2001/02/09 02:03:56 xorgcvs Exp $ */
+/* $oHeader: RectObjP.h,v 1.2 88/08/18 15:55:52 asente 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.
+
+******************************************************************/
+
+#ifndef _Xt_RectObjP_h_
+#define _Xt_RectObjP_h_
+
+#include <X11/RectObj.h>
+#include <X11/ObjectP.h>
+
+/**********************************************************
+ * Rectangle Object Instance Data Structures
+ *
+ **********************************************************/
+/* these fields match CorePart and can not be changed */
+
+typedef struct _RectObjPart {
+ Position x, y; /* rectangle position */
+ Dimension width, height; /* rectangle dimensions */
+ Dimension border_width; /* rectangle border width */
+ Boolean managed; /* is widget geometry managed? */
+ Boolean sensitive; /* is widget sensitive to user events*/
+ Boolean ancestor_sensitive; /* are all ancestors sensitive? */
+}RectObjPart;
+
+typedef struct _RectObjRec {
+ ObjectPart object;
+ RectObjPart rectangle;
+} RectObjRec;
+
+
+
+/********************************************************
+ * Rectangle Object Class Data Structures
+ *
+ ********************************************************/
+/* these fields match CoreClassPart and can not be changed */
+/* ideally these structures would only contain the fields required;
+ but because the CoreClassPart cannot be changed at this late date
+ extraneous fields are necessary to make the field offsets match */
+
+typedef struct _RectObjClassPart {
+
+ WidgetClass superclass; /* pointer to superclass ClassRec */
+ String class_name; /* widget resource class name */
+ Cardinal widget_size; /* size in bytes of widget record */
+ XtProc class_initialize; /* class initialization proc */
+ XtWidgetClassProc class_part_initialize; /* dynamic initialization */
+ XtEnum class_inited; /* has class been initialized? */
+ XtInitProc initialize; /* initialize subclass fields */
+ XtArgsProc initialize_hook; /* notify that initialize called */
+ XtProc rect1; /* NULL */
+ XtPointer rect2; /* NULL */
+ Cardinal rect3; /* NULL */
+ XtResourceList resources; /* resources for subclass fields */
+ Cardinal num_resources; /* number of entries in resources */
+ XrmClass xrm_class; /* resource class quarkified */
+ Boolean rect4; /* NULL */
+ XtEnum rect5; /* NULL */
+ Boolean rect6; /* NULL */
+ Boolean rect7; /* NULL */
+ XtWidgetProc destroy; /* free data for subclass pointers */
+ XtWidgetProc resize; /* geom manager changed widget size */
+ XtExposeProc expose; /* rediplay rectangle */
+ XtSetValuesFunc set_values; /* set subclass resource values */
+ XtArgsFunc set_values_hook; /* notify that set_values called */
+ XtAlmostProc set_values_almost; /* set values almost for geometry */
+ XtArgsProc get_values_hook; /* notify that get_values called */
+ XtProc rect9; /* NULL */
+ XtVersionType version; /* version of intrinsics used */
+ XtPointer callback_private; /* list of callback offsets */
+ String rect10; /* NULL */
+ XtGeometryHandler query_geometry; /* return preferred geometry */
+ XtProc rect11; /* NULL */
+ XtPointer extension; /* pointer to extension record */
+} RectObjClassPart;
+
+typedef struct _RectObjClassRec {
+ RectObjClassPart rect_class;
+} RectObjClassRec;
+
+externalref RectObjClassRec rectObjClassRec;
+
+#endif /*_Xt_RectObjP_h_*/
diff --git a/nx-X11/lib/Xt/ResConfig.c b/nx-X11/lib/Xt/ResConfig.c
new file mode 100644
index 000000000..4c2e73602
--- /dev/null
+++ b/nx-X11/lib/Xt/ResConfig.c
@@ -0,0 +1,1022 @@
+/* $Xorg: ResConfig.c,v 1.5 2001/02/09 02:03:56 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.
+
+*/
+/*****************************************************************
+
+(C) COPYRIGHT International Business Machines Corp. 1992,1997
+ All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+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 IBM CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 IBM Corporation 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 IBM
+Corporation.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/ResConfig.c,v 3.7 2001/08/22 22:52:19 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Intrinsic.h"
+#include "IntrinsicI.h"
+#include "Core.h"
+#include "CoreP.h"
+#include "ShellP.h"
+#include "StringDefs.h"
+#include "ResConfigP.h"
+#include <X11/Xatom.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define MAX_BUFFER 512
+
+static void _search_child(Widget, char *, char *, char *, char *, char, char *);
+static void _set_and_search(Widget, char *, char *, char *, char *, char , char *);
+static int _locate_children(Widget, Widget **);
+
+#if defined(sun) && !defined(SVR4)
+# define Strtoul(a,b,c) (unsigned long)strtol(a,b,c)
+#else
+# define Strtoul(a,b,c) strtoul(a,b,c)
+#endif
+
+
+/*
+ * NAME: _set_resource_values
+ *
+ * FUNCTION:
+ * This function sets the value on the widget. It must first determine
+ * if the last part is a valid resource for that widget. (eg.
+ * labelString is a valid resource for label but not for bulletin board)
+ * It must also add the resource to the application's resource database
+ * and then query it out using specific resource strings that it builds
+ * from the widget information. This ensures that a customizing tool
+ * on-the-fly paradigm is followed: an application that is
+ * instantaneously updated should look the same as one that is restarted
+ * and uses the .Xdefaults file.
+ *
+ * PARAMETERS:
+ * w the widget to match
+ * resource the resource string to be matched
+ * value the value to be set
+ * last_part the last resource part (e.g. *background)
+ *
+ * RETURN VALUES: void
+ *
+ * ERRORS: none
+ */
+static void
+_set_resource_values (
+ Widget w,
+ char *resource,
+ char *value,
+ char *last_part)
+{
+ XrmDatabase db = NULL;
+ char *resource_name = NULL;
+ char *resource_class = NULL;
+ char *return_type;
+ XrmValue return_value;
+ char *resource_value;
+ Widget cur = w;
+ char *temp;
+ XtResourceList resources_return = NULL;
+ Cardinal num_resources_return = 0;
+ Cardinal res_index;
+ Boolean found_resource = False;
+ Display *dpy;
+ XrmDatabase tmp_db;
+
+ if (!XtIsWidget (w))
+ dpy = XtDisplay (w->core.parent);
+ else
+ dpy = XtDisplay (w);
+ tmp_db = XtDatabase(dpy);
+
+ /*
+ * get a list of all the valid resources for this widget
+ */
+ XtGetResourceList (w->core.widget_class,
+ &resources_return, &num_resources_return);
+
+ /*
+ * try to match the last_part of the resource string with
+ * a resource in this resource list
+ */
+ for (res_index=0; res_index<num_resources_return; res_index++) {
+ if ((strcmp (last_part,
+ resources_return[res_index].resource_name) == 0) ||
+ (strcmp (last_part,
+ resources_return[res_index].resource_class) == 0)) {
+ found_resource = True;
+ break;
+ }
+ }
+
+ /*
+ * if resource is not a valid resource for this widget
+ * or the resource name or class are NULL
+ * then exit this function
+ */
+ if (!found_resource
+ || !resources_return[res_index].resource_name
+ || !resources_return[res_index].resource_class) {
+ XtFree ((char *) resources_return);
+ return;
+ }
+
+ /*
+ * build the full resource name and class specifications so
+ * that you can query the resource database
+ * eg: .app.button1.foreground
+ * .App.XmPushButton.Foreground
+ */
+ while (cur != NULL) {
+ /*
+ * create resource name string
+ */
+ if (resource_name) {
+ temp = XtMalloc (sizeof(char) *
+ (2 + strlen(cur->core.name)
+ + strlen(resource_name)));
+ sprintf (temp, ".%s%s", cur->core.name, resource_name);
+ XtFree (resource_name);
+ } else if (!XtIsWidget (cur) || !cur->core.name) {
+ cur = XtParent(cur);
+ continue;
+ } else {
+ temp = XtMalloc (sizeof(char) *
+ (2 + strlen(cur->core.name)));
+ sprintf (temp, ".%s", cur->core.name);
+ }
+ resource_name = temp;
+
+ /*
+ * create resource class string
+ */
+ if ((XtIsTopLevelShell (cur)) && (XtParent (cur) == NULL)) {
+ ApplicationShellWidget top =
+ (ApplicationShellWidget) (cur);
+
+ if (resource_class) {
+ temp = XtMalloc (sizeof(char) *
+ (2 + strlen(top->application.class)
+ + strlen(resource_class)));
+ sprintf (temp, ".%s%s",
+ top->application.class, resource_class);
+ } else {
+ temp = XtMalloc (sizeof(char) *
+ (2 + strlen(top->application.class)));
+ sprintf (temp, ".%s",
+ top->application.class);
+ }
+ } else {
+ if (resource_class) {
+ temp = XtMalloc (sizeof(char) *
+ (2 + strlen(
+ cur->core.widget_class->core_class.class_name)
+ + strlen(resource_class)));
+ sprintf (temp, ".%s%s",
+ cur->core.widget_class->core_class.class_name,
+ resource_class);
+ } else {
+ temp = XtMalloc (sizeof(char) *
+ (2 + strlen(
+ cur->core.widget_class->core_class.class_name)));
+ sprintf (temp, ".%s",
+ cur->core.widget_class->core_class.class_name);
+ }
+ }
+ if (resource_class != NULL)
+ XtFree (resource_class);
+ resource_class = temp;
+
+ cur = XtParent(cur);
+ }
+
+ /*
+ * add the resource name to the end of the resource name string
+ */
+ temp = XtMalloc (2 + strlen(resource_name) +
+ strlen(resources_return[res_index].resource_name));
+ sprintf (temp, "%s.%s", resource_name,
+ resources_return[res_index].resource_name);
+ if (resource_name != NULL)
+ XtFree (resource_name);
+ resource_name = temp;
+
+ /*
+ * add the resource class to the end of the resource class string
+ */
+ temp = XtMalloc (2 + strlen(resource_class) +
+ strlen(resources_return[res_index].resource_class));
+ sprintf (temp, "%s.%s", resource_class,
+ resources_return[res_index].resource_class);
+ if (resource_class != NULL)
+ XtFree (resource_class);
+ resource_class = temp;
+
+#ifdef DEBUG
+ fprintf (stderr, "resource_name = %s\n", resource_name);
+ fprintf (stderr, "resource_class = %s\n", resource_class);
+#endif
+
+ /*
+ * put the resource and its value in a resource database and
+ * then query it back out again using the specific name and
+ * class resource strings that were built above. This is
+ * necessary to maintain a precedence similar to the .Xdefaults
+ * file
+ */
+ XrmPutStringResource (&db, resource, value);
+ XrmMergeDatabases (db, &tmp_db);
+ XrmGetResource (tmp_db, resource_name, resource_class,
+ &return_type, &return_value);
+ if (return_type)
+ resource_value = XtNewString (return_value.addr);
+ else
+ resource_value = XtNewString (value);
+
+#ifdef DEBUG
+ fprintf (stderr,
+ "Apply:\n\twidget = %s\n\tlast_part = %s\n\tvalue = %s\n",
+ (w->core.name == NULL) ? "NULL" : w->core.name,
+ resources_return[res_index].resource_name,
+ resource_value);
+#endif
+ /*
+ * use XtVaSetValues with XtVaTypedArg to convert the value of
+ * type String the the same type as the resource (last_part).
+ * Then set the value.
+ */
+ XtVaSetValues (w,
+ XtVaTypedArg, resources_return[res_index].resource_name,
+ XtRString, resource_value,
+ strlen (resource_value) + 1,
+ NULL);
+
+ XtFree ((char *) resources_return);
+ XtFree (resource_name);
+ XtFree (resource_class);
+ XtFree (resource_value);
+}
+
+/*
+ * NAME: _apply_values_to_children
+ *
+ * FUNCTION:
+ * Once the resource string matches the value must be applied to
+ * all children if applicable. (eg. App*Form.background must apply
+ * background to all children of the Form widget)
+ *
+ * PARAMETERS:
+ * w the widget to match
+ * remainder the part of the resource string left over
+ * resource the resource string to be matched
+ * value the value to be set
+ * last_token the last * or . before the final resoruce part
+ * last_part the last resource part (e.g. *background)
+ *
+ * RETURN VALUES: void
+ *
+ * ERRORS: none
+ */
+static void
+_apply_values_to_children (
+ Widget w,
+ char *remainder,
+ char *resource,
+ char *value,
+ char last_token,
+ char *last_part)
+{
+ int i;
+ int num_children;
+ Widget *children;
+
+ /*
+ * Recursively search through the children
+ */
+ num_children = _locate_children (w, &children);
+
+ for (i=0; i<num_children; i++) {
+
+#ifdef DEBUG
+ if (XtIsWidget (children[i]) && XtIsWidget (w))
+ fprintf (stderr, "searching child %s of parent %s\n",
+ children[i]->core.name, w->core.name);
+ else
+ fprintf (stderr,"searching child (NULL) of parent %s\n",
+ w->core.name);
+ if (!XtIsWidget (children[i]))
+ fprintf (stderr, "children[%d] is NOT a widget\n", i);
+ if (!XtIsWidget (w))
+ fprintf (stderr, "w is NOT a widget\n");
+#endif
+
+ _set_resource_values (children[i], resource, value, last_part);
+ _apply_values_to_children (children[i], remainder,
+ resource, value, last_token, last_part);
+ }
+
+ XtFree ((char *)children);
+}
+
+/*
+ * NAME: _search_child
+ *
+ * FUNCTION:
+ * descends through each child of the tree
+ *
+ * PARAMETERS:
+ * w the widget whose children are to be searched
+ * indx index into the resource string
+ * remainder the remaining part of the resource string
+ * resource the resource string to be matched
+ * value the value to be applied
+ * last_token the last * or . before the final resoruce part
+ * last_part the last resource part (e.g. *background)
+ *
+ * RETURN VALUES: none
+ *
+ * ERRORS: none
+ */
+static void
+_search_child (
+ Widget w,
+ char *indx,
+ char *remainder,
+ char *resource,
+ char *value,
+ char last_token,
+ char *last_part)
+{
+ int i;
+ int num_children;
+ Widget *children;
+
+ /*
+ * Recursively search through the children
+ */
+ num_children = _locate_children (w, &children);
+ for (i=0; i<num_children; i++) {
+ _set_and_search (children[i], indx, remainder, resource,
+ value, last_token, last_part);
+ }
+
+ XtFree ((char *)children);
+}
+
+/*
+ * NAME: _get_part
+ *
+ * FUNCTION:
+ * This routine will return the token and following part of the resource
+ * when given the current index it will update the index accordingly
+ *
+ * PARAMETERS:
+ * remainder the part of the resource string left over
+ * indx the index into the resource string
+ * part the parsed off part of the resource string
+ *
+ * RETURN VALUES:
+ * char the token (* or . or ?) preceding the resource part
+ * indx the index into the resource string
+ * part the parsed off part of the resource string
+ *
+ * ERRORS: none
+ */
+/* ARGSUSED */
+static char
+_get_part (
+ char *remainder,
+ char **indx,
+ char **part)
+{
+ char buffer[MAX_BUFFER];
+ char *buf_ptr;
+ char token = **indx;
+ int i = 0;
+
+ /*
+ * copy the remainder part into the buffer
+ */
+ buf_ptr = buffer;
+ (*indx)++; /* get rid of the token */
+ while (**indx && (**indx != '.') && (**indx != '*')) {
+ *buf_ptr++ = *(*indx)++;
+ if (++i >= MAX_BUFFER - 1)
+ break;
+ }
+ *buf_ptr = '\0';
+
+ *part = XtNewString (buffer); /* return a new string to part */
+
+ if (strcmp (*indx, "") == 0)
+ *indx = NULL;
+
+ return (token); /* return the token */
+}
+
+/*
+ * NAME: _match_resource_to_widget
+ *
+ * FUNCTION:
+ * This function matches the resource part to the widget name or class
+ *
+ * PARAMETERS:
+ * w the widget to match
+ * part the parsed off part of the resource string
+ *
+ * RETURN VALUES:
+ * Boolean true if a match occurs
+ *
+ * ERRORS: none
+ */
+static Boolean
+_match_resource_to_widget (
+ Widget w,
+ char *part)
+{
+ /*
+ * Match any widget at this level if the ? is used
+ */
+ if (strcmp (part, "?") == 0)
+ return (True);
+
+ /*
+ * if the object is really a widget then its name can be matched
+ * otherwise only use its class. Note that if you try to reference
+ * a widget name when the object is not a widget, you may get a
+ * core dump from an invalid pointer reference.
+ */
+ if (XtIsWidget (w)) {
+ if ((strcmp (w->core.name, part) == 0) ||
+ (strcmp (w->core.widget_class->core_class.class_name,
+ part) == 0))
+ return (True);
+ else
+ return (False);
+ } else {
+ if ((strcmp (w->core.widget_class->core_class.class_name,
+ part) == 0))
+ return (True);
+ else
+ return (False);
+ }
+}
+
+/*
+ * NAME: _set_and_search
+ *
+ * FUNCTION:
+ * The algorithm to search the widget tree and apply a resource string
+ *
+ * PARAMETERS:
+ * w the widget to match
+ * indx the index into the resource string
+ * remainder the part of the resource string left over
+ * resource the resource string to be matched
+ * value the value to be set
+ * last_token the last * or . before the final resoruce part
+ * last_part the last resource part (e.g. *background)
+ *
+ * RETURN VALUES: none
+ *
+ * ERRORS: none
+ *
+ * ALGORITHM:
+ * loop (look at all children)
+ * if (resource segment and current widget match)
+ * if '.'
+ * if at end of resource string
+ * set values ( .=over all children
+ * *=this widget only)
+ * else
+ * descend the widget tree
+ * and parse off resource segment
+ * exit the loop
+ * if '*'
+ * if at end of resource string
+ * set values ( .=over all children
+ * *=this widget only)
+ * descend and parse
+ * else
+ * if '.'
+ * continue looping
+ * if '*'
+ * descend but don't parse
+ * continue looping
+ * end loop
+ *
+ * NOTE: the _set_resource_values routine will not allow a value to be
+ * set on a resource against the rules of the resource database manager
+ */
+static void
+_set_and_search (
+ Widget w,
+ char *indx,
+ char *remainder,
+ char *resource,
+ char *value,
+ char last_token,
+ char *last_part)
+{
+ char *part;
+ char *local_index = indx;
+ char token;
+
+ /*
+ * parse off one part, return token and the new index
+ */
+ token = _get_part (remainder, &local_index, &part);
+
+ if (_match_resource_to_widget (w, part)) {
+ if (token == '.') {
+ if (local_index == NULL) {
+ if (last_token == '.') {
+ _set_resource_values (w, resource,
+ value, last_part);
+ } else if (last_token == '*') {
+ _set_resource_values (w, resource,
+ value, last_part);
+ _apply_values_to_children (w,
+ remainder, resource, value,
+ last_token, last_part);
+ }
+ } else
+ _search_child (w, local_index, remainder,
+ resource, value, last_token, last_part);
+ return;
+ }
+ if (token == '*') {
+ if (local_index == NULL) {
+ if (last_token == '.') {
+ _set_resource_values (w, resource,
+ value, last_part);
+ } else if (last_token == '*') {
+ _set_resource_values (w, resource,
+ value, last_part);
+ _apply_values_to_children ( w,
+ remainder, resource, value,
+ last_token, last_part);
+ }
+ } else
+ _search_child (w, local_index, remainder,
+ resource, value, last_token, last_part);
+ }
+ } else {/* if the widget name and class don't match the part */
+ /* if (token == '.') just continue looping */
+
+ if (token == '*') {
+ _search_child (w, indx, remainder, resource, value,
+ last_token, last_part);
+ }
+ }
+
+ XtFree (part);
+}
+
+/*
+ * NAME: _get_last_part
+ *
+ * FUNCTION:
+ * This routine will parse off the last segment of a resource string
+ * and its token and return them. the remainder of resource is also
+ * returned. strcoll is used to guarantee no problems with
+ * international strings.
+ *
+ * PARAMETERS:
+ * remainder the part of the resource string left over
+ * part the parsed off part of the resource string
+ *
+ * RETURN VALUES:
+ * char the token (* or . or ?) preceding the resource part
+ * remainder the part of the resource string left over
+ * part the parsed off part of the resource string
+ *
+ * ERRORS: none
+ */
+static char
+_get_last_part (
+ char *remainder,
+ char **part)
+{
+ char *loose, *tight;
+
+ loose = strrchr (remainder, '*');
+ tight = strrchr (remainder, '.');
+
+ if ((loose == NULL) && (tight == NULL)) {
+ *part = XtNewString (remainder);
+ return ('.');
+ }
+ if ((loose == NULL) || (tight && (strcoll (loose, tight) < 0))) {
+ *tight++ = '\0'; /* shorten the remainder string */
+ *part = XtNewString (tight);
+ return ('.');
+ }
+ if ((tight == NULL) || (loose && (strcoll (tight, loose) < 0))) {
+ *loose++ = '\0';
+ *part = XtNewString (loose);
+ return ('*');
+ }
+
+ return ('0'); /* error - return 0 */
+}
+
+/*
+ * NAME: _search_widget_tree
+ *
+ * FUNCTION:
+ * This function tries to match a resource string to the widgets
+ * it applies to. The functions it invokes to do this then set
+ * the value for that resource to each widget.
+ *
+ * The resource string has to be parsed into the following format:
+ * resource = App*Form*button1.background
+ * remainder = *Form*button1
+ * last_part = background last_token = .
+ * As the widget tree is recursively descended, these variables are
+ * passed. The remainder is parsed at each level in the widget
+ * tree as the _set_and_search function attempts to match
+ * the resource part (eg. part = Form token = *) to a widget. When
+ * the entire resource string has been matched, the _set_resource_values
+ * functions is called to apply the value to the widget or widgets.
+ *
+ * PARAMETERS:
+ * w a widget from whose toplevel shell ancestor
+ * the search will start
+ * resource the resource string to match
+ * value the value to apply
+ *
+ * RETURN VALUES: none
+ *
+ * ERRORS: none
+ */
+static void
+_search_widget_tree (
+ Widget w,
+ char *resource,
+ char *value)
+{
+ Widget parent = w;
+ char *last_part;
+ char *remainder = NULL;
+ char last_token;
+ char *indx, *copy;
+ char *loose, *tight;
+ int loose_len, tight_len;
+
+ /*
+ * Find the root of the tree given any widget
+ */
+ while (XtParent(parent) != NULL) {
+ parent = XtParent(parent);
+ }
+#ifdef DEBUG
+ if (XtIsWidget (w) && XtIsWidget (parent))
+ fprintf (stderr, "widget = %s parent = %s\n",
+ w->core.name, parent->core.name);
+ else
+ fprintf (stderr, "widget = NULL parent = NULL\n");
+#endif
+
+ /*
+ * parse off the Class name that was prepended to this string in
+ * a customizing tool
+ */
+ loose = strchr (resource, '*');
+ tight = strchr (resource, '.');
+ if ((loose == NULL) && (tight == NULL))
+ return;
+
+ loose_len = (loose) ? strlen (loose) : 0;
+ tight_len = (tight) ? strlen (tight) : 0;
+
+ if ((loose == NULL) || (tight_len > loose_len))
+ remainder = XtNewString (tight);
+ else if ((tight == NULL) || (loose_len > tight_len))
+ remainder = XtNewString (loose);
+
+ /*
+ * Parse last segment off of resource string, (eg. background, font,
+ * etc.)
+ */
+ last_token = _get_last_part (remainder, &last_part);
+ /*
+ * this case covers resources of only one level (eg. *background)
+ */
+ if (strcmp (remainder, "") == 0) {
+ _set_resource_values (w, resource, value, last_part);
+ if (last_token == '*')
+ _apply_values_to_children (parent, remainder, resource,
+ value, last_token, last_part);
+ /*
+ * all other resource strings are recursively applied to the widget tree.
+ * Prepend a '.' to the remainder string if there is no leading token.
+ */
+ } else {
+ if (remainder[0] != '*' && remainder[0] != '.') {
+ copy = XtMalloc (strlen(remainder) + 2);
+ sprintf (copy, ".%s", remainder);
+ XtFree (remainder);
+ remainder = copy;
+ }
+ indx = remainder;
+ _set_and_search (parent, indx, remainder, resource, value,
+ last_token, last_part);
+ }
+
+ XtFree (remainder);
+ XtFree (last_part);
+}
+
+/*
+ * NAME: _locate_children
+ *
+ * FUNCTION:
+ * returns a list of all of a widget's children
+ *
+ * PARAMETERS:
+ * w the parent to search for its children
+ * children the list of children that is created
+ * normal flag for normal children
+ * popup flag for popup children
+ *
+ * RETURN VALUES:
+ * int the number of children
+ * children the list of children found
+ *
+ * ERRORS: none
+ */
+static int
+_locate_children (
+ Widget parent,
+ Widget **children)
+{
+ CompositeWidget comp = (CompositeWidget) parent;
+ Cardinal i;
+ int num_children = 0;
+ int current = 0;
+
+ /*
+ * count the number of children
+ */
+ if (XtIsWidget (parent))
+ num_children += parent->core.num_popups;
+ if (XtIsComposite (parent))
+ num_children += comp->composite.num_children;
+ if (num_children == 0) {
+ *children = NULL;
+ return (0);
+ }
+
+ *children = (Widget *)
+ XtMalloc ((Cardinal) sizeof(Widget) * num_children);
+
+ if (XtIsComposite (parent)) {
+ for (i=0; i<comp->composite.num_children; i++) {
+ (*children)[current] = comp->composite.children[i];
+ current++;
+ }
+ }
+
+ if (XtIsWidget (parent)) {
+ for (i=0; i<parent->core.num_popups; i++) {
+ (*children)[current] = comp->core.popup_list[i];
+ current++;
+ }
+ }
+
+ return (num_children);
+}
+
+#ifdef DEBUG
+/*
+ * NAME: dump_widget_tree
+ *
+ * FUNCTION:
+ * recursively printout entire widget tree
+ *
+ * PARAMETERS:
+ * w the widget to match
+ * indent the amount to indent each line
+ *
+ * RETURN VALUES: void
+ *
+ * ERRORS: none
+ */
+static void
+dump_widget_tree (
+ Widget w,
+ int indent)
+{
+ int i,j;
+ int num_children;
+ Widget *children;
+
+ /*
+ * Recursively search through the children
+ */
+ num_children = _locate_children (w, &children);
+ indent += 2;
+ for (i=0; i<num_children; i++) {
+ if (children[i] != NULL) {
+ for (j=0; j<indent; j++)
+ fprintf (stderr, " ");
+ if (XtIsWidget (children[i])) {
+ fprintf (stderr, "(%s)\t",children[i]->core.name);
+ fprintf (stderr, "(%s)\n",
+ children[i]->core.widget_class->core_class.class_name);
+ } else {
+ fprintf (stderr, "(NULL)\t");
+ fprintf (stderr, "(%s)\n",
+ children[i]->core.widget_class->core_class.class_name);
+ }
+ }
+ dump_widget_tree (children[i], indent);
+ }
+
+ XtFree ((char *)children);
+}
+#endif
+
+/*
+ * NAME: _XtResourceConfiguationEH
+ *
+ * FUNCTION:
+ * This function is the event handler for the on-the-fly communication
+ * with a resource customization tool. This event handler must be
+ * registered for the toplevel shell of each app. This is best done
+ * in the _XtCreatePopupShell and _XtAppCreateShell functions in Xt's
+ * Create.c source file.
+ *
+ * The property used to communicate with a customizing tool is
+ * placed on the toplevel shell window of the application. The
+ * customizing tool places a property on this window which causes
+ * this event handler to be invoked via the PropertyNotify event.
+ * This event handler reads the property and then deletes it from
+ * the server. The contents of the property are a resource string
+ * and value. The event handler then calls functions to walk the
+ * applications widget tree, determining which widgets are affected
+ * by the resource string, and then applying the value with XtSetValues.
+ *
+ * PARAMETERS:
+ * w the widget that invoked this event handler
+ * client_data not used
+ * event the event structure
+ *
+ * RETURN VALUES: none
+ *
+ * ERRORS: none
+ */
+/* ARGSUSED */
+void
+_XtResourceConfigurationEH (
+ Widget w,
+ XtPointer client_data,
+ XEvent *event)
+{
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long leftover;
+ unsigned char *data = NULL;
+ unsigned long resource_len;
+ char *data_ptr;
+ char *resource;
+ char *value;
+#ifdef DEBUG
+ int indent = 0;
+#endif
+ XtPerDisplay pd;
+
+#ifdef DEBUG
+ fprintf (stderr, "in _XtResourceConfiguationEH atom = %d\n",event->xproperty.atom);
+ fprintf (stderr, " window = %x\n", XtWindow (w));
+ if (XtIsWidget (w))
+ fprintf (stderr, " widget = %x name = %s\n", w, w->core.name);
+#endif
+
+ pd = _XtGetPerDisplay (XtDisplay (w));
+
+ /*
+ * The window on which a customizing tool places the property
+ * is determined at this point. It should be the applications
+ * toplevel shell window.
+ *
+ * A customizing tool sends a "ping" to the application on
+ * the RCM_INIT property. The application answers the ping
+ * by deleting the property.
+ */
+ if (event->xproperty.atom == pd->rcm_init) {
+ XDeleteProperty (XtDisplay(w), XtWindow (w), pd->rcm_init);
+
+#ifdef DEBUG
+ if (XtIsWidget (w))
+ fprintf (stderr, "%s\n", w->core.name);
+ else
+ fprintf (stderr, "NULL name\n");
+ dump_widget_tree(w, indent);
+
+ fprintf (stderr, "answer ping\n");
+#endif
+ }
+
+ /*
+ * This event handler ignores any property notify events that
+ * are not RCM_INIT or RCM_DATA
+ */
+ if (event->xproperty.atom != pd->rcm_data)
+ return;
+
+ /*
+ * Retrieve the data from the property
+ */
+#ifdef DEBUG
+ fprintf (stderr, "receiving RCM_DATA property\n");
+#endif
+ if (XGetWindowProperty (XtDisplay(w),
+ XtWindow (w),
+ pd->rcm_data, 0L, 8192L,
+ TRUE, XA_STRING,
+ &actual_type, &actual_format, &nitems, &leftover,
+ &data ) == Success && actual_type == XA_STRING
+ && actual_format == 8) {
+ /*
+ * data format is:
+ *
+ * resource_length, resource, value
+ *
+ * convert the resource_length to a long, skip over it, put a
+ * zero byte at the end of the resource, and pick off the
+ * resource and value fields.
+ */
+ if (data) {
+ resource_len = Strtoul ((void *)data, &data_ptr, 10);
+ data_ptr++;
+
+ data_ptr[resource_len] = '\0';
+
+ resource = XtNewString (data_ptr);
+ value = XtNewString (&data_ptr[resource_len + 1]);
+#ifdef DEBUG
+ fprintf (stderr, "resource_len=%d\n",resource_len);
+ fprintf (stderr, "resource = %s\t value = %s\n",
+ resource, value);
+#endif
+ /*
+ * descend the application widget tree and
+ * apply the value to the appropriate widgets
+ */
+ _search_widget_tree (w, resource, value);
+
+ XtFree (resource);
+ XtFree (value);
+ }
+ }
+
+ if (data)
+ XFree ((char *)data);
+}
diff --git a/nx-X11/lib/Xt/ResConfigP.h b/nx-X11/lib/Xt/ResConfigP.h
new file mode 100644
index 000000000..a06cda715
--- /dev/null
+++ b/nx-X11/lib/Xt/ResConfigP.h
@@ -0,0 +1,78 @@
+/* $Xorg: ResConfigP.h,v 1.5 2001/02/09 02:03:56 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.
+
+*/
+/*****************************************************************
+
+(C) COPYRIGHT International Business Machines Corp. 1992,1997
+ All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+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 IBM CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 IBM Corporation 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 IBM
+Corporation.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/ResConfigP.h,v 3.7 2001/12/20 19:40:59 tsi Exp $ */
+
+#ifndef _RESCONFIGP_H
+#define _RESCONFIGP_H
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+/*
+ * Atom names for resource configuration management customization tool.
+ */
+#define RCM_DATA "Custom Data"
+#define RCM_INIT "Custom Init"
+
+extern void _XtResourceConfigurationEH(
+ Widget /* w */,
+ XtPointer /* client_data */,
+ XEvent * /* event */
+);
+
+_XFUNCPROTOEND
+
+#endif
diff --git a/nx-X11/lib/Xt/ResourceI.h b/nx-X11/lib/Xt/ResourceI.h
new file mode 100644
index 000000000..d6ed1df23
--- /dev/null
+++ b/nx-X11/lib/Xt/ResourceI.h
@@ -0,0 +1,100 @@
+/* $Xorg: ResourceI.h,v 1.4 2001/02/09 02:03:56 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/ResourceI.h,v 1.5 2001/12/14 19:56:28 dawes Exp $ */
+
+/****************************************************************
+ *
+ * Resources
+ *
+ ****************************************************************/
+
+#ifndef _XtresourceI_h
+#define _XtresourceI_h
+
+#define StringToQuark(string) XrmStringToQuark(string)
+#define StringToName(string) XrmStringToName(string)
+#define StringToClass(string) XrmStringToClass(string)
+
+extern void _XtDependencies(
+ XtResourceList * /* class_resp */,
+ Cardinal * /* class_num_resp */,
+ XrmResourceList * /* super_res */,
+ Cardinal /* super_num_res */,
+ Cardinal /* super_widget_size */);
+
+extern void _XtResourceDependencies(
+ WidgetClass /* wc */
+);
+
+extern void _XtConstraintResDependencies(
+ ConstraintWidgetClass /* wc */
+);
+
+extern XtCacheRef* _XtGetResources(
+ Widget /* w */,
+ ArgList /* args */,
+ Cardinal /* num_args */,
+ XtTypedArgList /* typed_args */,
+ Cardinal* /* num_typed_args */
+);
+
+extern void _XtCopyFromParent(
+ Widget /* widget */,
+ int /* offset */,
+ XrmValue* /* value */
+);
+
+extern void _XtCopyToArg(char *src, XtArgVal *dst, unsigned int size);
+extern void _XtCopyFromArg(XtArgVal src, char *dst, unsigned int size);
+extern XrmResourceList* _XtCreateIndirectionTable(XtResourceList resources,
+ Cardinal num_resources);
+extern void _XtResourceListInitialize(void);
+
+
+#endif /* _XtresourceI_h */
diff --git a/nx-X11/lib/Xt/Resources.c b/nx-X11/lib/Xt/Resources.c
new file mode 100644
index 000000000..7da7d90a2
--- /dev/null
+++ b/nx-X11/lib/Xt/Resources.c
@@ -0,0 +1,1259 @@
+/* $Xorg: Resources.c,v 1.4 2001/02/09 02:03:56 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* $XFree86: xc/lib/Xt/Resources.c,v 1.11tsi Exp $ */
+
+/*LINTLIBRARY*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "VarargsI.h"
+#include "Shell.h"
+#include "ShellP.h"
+#include "StringDefs.h"
+#include <stdio.h>
+
+static XrmClass QBoolean, QString, QCallProc, QImmediate;
+static XrmName QinitialResourcesPersistent, QInitialResourcesPersistent;
+static XrmClass QTranslations, QTranslationTable;
+static XrmName Qtranslations, QbaseTranslations;
+static XrmName Qscreen;
+static XrmClass QScreen;
+
+#ifdef CRAY
+void Cjump();
+char *Cjumpp = (char *) Cjump;
+void Cjump() {}
+#endif
+
+void _XtCopyFromParent(
+ Widget widget,
+ int offset,
+ XrmValue *value)
+{
+ if (widget->core.parent == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "invalidParent","xtCopyFromParent",XtCXtToolkitError,
+ "CopyFromParent must have non-NULL parent",
+ (String *)NULL, (Cardinal *)NULL);
+ value->addr = NULL;
+ return;
+ }
+ value->addr = (XPointer)(((char *)widget->core.parent) + offset);
+} /* _XtCopyFromParent */
+
+
+/* If the alignment characteristics of your machine are right, these may be
+ faster */
+
+#ifdef UNALIGNED
+
+void _XtCopyFromArg(
+ XtArgVal src,
+ char* dst,
+ register unsigned int size)
+{
+ if (size == sizeof(long)) *(long *)dst = (long)src;
+ else if (size == sizeof(short)) *(short *)dst = (short)src;
+ else if (size == sizeof(char)) *(char *)dst = (char)src;
+ else if (size == sizeof(XtPointer)) *(XtPointer *)dst = (XtPointer)src;
+ else if (size == sizeof(char*)) *(char **)dst = (char*)src;
+ else if (size == sizeof(XtArgVal)) *(XtArgVal *)dst = src;
+ else if (size > sizeof(XtArgVal))
+ (void) memmove((char *) dst, (char *) src, (int) size);
+ else
+ (void) memmove((char *) dst, (char *) &src, (int) size);
+} /* _XtCopyFromArg */
+
+void _XtCopyToArg(
+ char* src,
+ XtArgVal *dst,
+ register unsigned int size)
+{
+ if (! (*dst)) {
+#ifdef GETVALUES_BUG
+ /* old GetValues semantics (storing directly into arglists) are bad,
+ * but preserve for compatibility as long as arglist contains NULL.
+ */
+ if (size == sizeof(long)) *dst = (XtArgVal)*(long*)src;
+ else if (size == sizeof(short)) *dst = (XtArgVal)*(short*)src;
+ else if (size == sizeof(char)) *dst = (XtArgVal)*(char*)src;
+ else if (size == sizeof(XtPointer)) *dst = (XtArgVal)*(XtPointer*)src;
+ else if (size == sizeof(char*)) *dst = (XtArgVal)*(char**)src;
+ else if (size == sizeof(XtArgVal)) *dst = *(XtArgVal*)src;
+ else (void) memmove((char*)dst, (char*)src, (int)size);
+#else
+ XtErrorMsg("invalidGetValues", "xtGetValues", XtCXtToolkitError,
+ "NULL ArgVal in XtGetValues", (String*) NULL, (Cardinal*) NULL);
+#endif
+ }
+ else {
+ /* proper GetValues semantics: argval is pointer to destination */
+ if (size == sizeof(long)) *((long*)*dst) = *(long*)src;
+ else if (size == sizeof(short)) *((short*)*dst) = *(short*)src;
+ else if (size == sizeof(char)) *((char*)*dst) = *(char*)src;
+ else if (size == sizeof(XtPointer)) *((XtPointer*)*dst) = *(XtPointer*)src;
+ else if (size == sizeof(char*)) *((char**)*dst) = *(char**)src;
+ else if (size == sizeof(XtArgVal)) *((XtArgVal*)*dst)= *(XtArgVal*)src;
+ else (void) memmove((char*)*dst, (char*)src, (int)size);
+ }
+} /* _XtCopyToArg */
+
+static void CopyToArg(
+ char* src,
+ XtArgVal *dst,
+ register unsigned int size)
+{
+ if (! (*dst)) {
+ /* old GetValues semantics (storing directly into arglists) are bad,
+ * but preserve for compatibility as long as arglist contains NULL.
+ */
+ if (size == sizeof(long)) *dst = (XtArgVal)*(long*)src;
+ else if (size == sizeof(short)) *dst = (XtArgVal)*(short*)src;
+ else if (size == sizeof(char)) *dst = (XtArgVal)*(char*)src;
+ else if (size == sizeof(XtPointer)) *dst = (XtArgVal)*(XtPointer*)src;
+ else if (size == sizeof(char*)) *dst = (XtArgVal)*(char**)src;
+ else if (size == sizeof(XtArgVal)) *dst = *(XtArgVal*)src;
+ else (void) memmove((char*)dst, (char*)src, (int)size);
+ }
+ else {
+ /* proper GetValues semantics: argval is pointer to destination */
+ if (size == sizeof(long)) *((long*)*dst) = *(long*)src;
+ else if (size == sizeof(short)) *((short*)*dst) = *(short*)src;
+ else if (size == sizeof(char)) *((char*)*dst) = *(char*)src;
+ else if (size == sizeof(XtPointer)) *((XtPointer*)*dst) = *(XtPointer*)src;
+ else if (size == sizeof(char*)) *((char**)*dst) = *(char**)src;
+ else if (size == sizeof(XtArgVal)) *((XtArgVal*)*dst)= *(XtArgVal*)src;
+ else (void) memmove((char*)*dst, (char*)src, (int)size);
+ }
+} /* CopyToArg */
+
+#else
+void _XtCopyFromArg(
+ XtArgVal src,
+ char* dst,
+ register unsigned int size)
+{
+ if (size > sizeof(XtArgVal))
+ (void) memmove((char *) dst, (char *) src, (int) size);
+ else {
+ union {
+ long longval;
+#ifdef LONG64
+ int intval;
+#endif
+ short shortval;
+ char charval;
+ char* charptr;
+ XtPointer ptr;
+ } u;
+ char *p = (char*)&u;
+ if (size == sizeof(long)) u.longval = (long)src;
+#ifdef LONG64
+ else if (size == sizeof(int)) u.intval = (int)src;
+#endif
+ else if (size == sizeof(short)) u.shortval = (short)src;
+ else if (size == sizeof(char)) u.charval = (char)src;
+ else if (size == sizeof(XtPointer)) u.ptr = (XtPointer)src;
+ else if (size == sizeof(char*)) u.charptr = (char*)src;
+ else p = (char*)&src;
+
+ (void) memmove(dst, p, (int) size);
+ }
+} /* _XtCopyFromArg */
+
+void _XtCopyToArg(
+ char* src,
+ XtArgVal *dst,
+ register unsigned int size)
+{
+ if (!*dst) {
+#ifdef GETVALUES_BUG
+ /* old GetValues semantics (storing directly into arglists) are bad,
+ * but preserve for compatibility as long as arglist contains NULL.
+ */
+ union {
+ long longval;
+#ifdef LONG64
+ int intval;
+#endif
+ short shortval;
+ char charval;
+ char* charptr;
+ XtPointer ptr;
+ } u;
+ if (size <= sizeof(XtArgVal)) {
+ (void) memmove((char*)&u, (char*)src, (int)size );
+ if (size == sizeof(long)) *dst = (XtArgVal)u.longval;
+#ifdef LONG64
+ else if (size == sizeof(int)) *dst = (XtArgVal)u.intval;
+#endif
+ else if (size == sizeof(short)) *dst = (XtArgVal)u.shortval;
+ else if (size == sizeof(char)) *dst = (XtArgVal)u.charval;
+ else if (size == sizeof(char*)) *dst = (XtArgVal)u.charptr;
+ else if (size == sizeof(XtPointer)) *dst = (XtArgVal)u.ptr;
+ else (void) memmove((char*)dst, (char*)src, (int)size );
+ }
+ else
+ (void) memmove((char*)dst, (char*)src, (int)size );
+#else
+ XtErrorMsg("invalidGetValues", "xtGetValues", XtCXtToolkitError,
+ "NULL ArgVal in XtGetValues", (String*) NULL, (Cardinal*) NULL);
+#endif
+ }
+ else {
+ /* proper GetValues semantics: argval is pointer to destination */
+ (void) memmove((char*)*dst, (char*)src, (int)size );
+ }
+} /* _XtCopyToArg */
+
+static void CopyToArg(
+ char* src,
+ XtArgVal *dst,
+ register unsigned int size)
+{
+ if (!*dst) {
+ /* old GetValues semantics (storing directly into arglists) are bad,
+ * but preserve for compatibility as long as arglist contains NULL.
+ */
+ union {
+ long longval;
+#ifdef LONG64
+ int intval;
+#endif
+ short shortval;
+ char charval;
+ char* charptr;
+ XtPointer ptr;
+ } u;
+ if (size <= sizeof(XtArgVal)) {
+ (void) memmove((char*)&u, (char*)src, (int)size );
+ if (size == sizeof(long)) *dst = (XtArgVal)u.longval;
+#ifdef LONG64
+ else if (size == sizeof(int)) *dst = (XtArgVal)u.intval;
+#endif
+ else if (size == sizeof(short)) *dst = (XtArgVal)u.shortval;
+ else if (size == sizeof(char)) *dst = (XtArgVal)u.charval;
+ else if (size == sizeof(char*)) *dst = (XtArgVal)u.charptr;
+ else if (size == sizeof(XtPointer)) *dst = (XtArgVal)u.ptr;
+ else (void) memmove((char*)dst, (char*)src, (int)size );
+ }
+ else
+ (void) memmove((char*)dst, (char*)src, (int)size );
+ }
+ else {
+ /* proper GetValues semantics: argval is pointer to destination */
+ (void) memmove((char*)*dst, (char*)src, (int)size );
+ }
+} /* CopyToArg */
+
+#endif
+
+static Cardinal CountTreeDepth(
+ Widget w)
+{
+ Cardinal count;
+
+ for (count = 1; w != NULL; w = (Widget) w->core.parent)
+ count++;
+
+ return count;
+}
+
+static void GetNamesAndClasses(
+ register Widget w,
+ register XrmNameList names,
+ register XrmClassList classes)
+{
+ register Cardinal length, j;
+ register XrmQuark t;
+ WidgetClass class;
+
+ /* Return null-terminated quark arrays, with length the number of
+ quarks (not including NULL) */
+
+ LOCK_PROCESS;
+ for (length = 0; w != NULL; w = (Widget) w->core.parent) {
+ names[length] = w->core.xrm_name;
+ class = XtClass(w);
+ /* KLUDGE KLUDGE KLUDGE KLUDGE */
+ if (w->core.parent == NULL && XtIsApplicationShell(w)) {
+ classes[length] =
+ ((ApplicationShellWidget) w)->application.xrm_class;
+ } else classes[length] = class->core_class.xrm_class;
+ length++;
+ }
+ UNLOCK_PROCESS;
+ /* They're in backwards order, flop them around */
+ for (j = 0; j < length/2; j++) {
+ t = names[j];
+ names[j] = names[length-j-1];
+ names[length-j-1] = t;
+ t = classes[j];
+ classes[j] = classes[length-j-1];
+ classes[length-j-1] = t;
+ }
+ names[length] = NULLQUARK;
+ classes[length] = NULLQUARK;
+} /* GetNamesAndClasses */
+
+
+/* Spiffy fast compiled form of resource list. */
+/* XtResourceLists are compiled in-place into XrmResourceLists */
+/* All atoms are replaced by quarks, and offsets are -offset-1 to */
+/* indicate that this list has been compiled already */
+
+void _XtCompileResourceList(
+ register XtResourceList resources,
+ Cardinal num_resources)
+{
+ register Cardinal count;
+
+#define xrmres ((XrmResourceList) resources)
+#define PSToQ XrmPermStringToQuark
+
+ for (count = 0; count < num_resources; resources++, count++) {
+ xrmres->xrm_name = PSToQ(resources->resource_name);
+ xrmres->xrm_class = PSToQ(resources->resource_class);
+ xrmres->xrm_type = PSToQ(resources->resource_type);
+ xrmres->xrm_offset = (Cardinal)
+ (-(int)resources->resource_offset - 1);
+ xrmres->xrm_default_type = PSToQ(resources->default_type);
+ }
+#undef PSToQ
+#undef xrmres
+} /* _XtCompileResourceList */
+
+/* Like _XtCompileResourceList, but strings are not permanent */
+static void XrmCompileResourceListEphem(
+ register XtResourceList resources,
+ Cardinal num_resources)
+{
+ register Cardinal count;
+
+#define xrmres ((XrmResourceList) resources)
+
+ for (count = 0; count < num_resources; resources++, count++) {
+ xrmres->xrm_name = StringToName(resources->resource_name);
+ xrmres->xrm_class = StringToClass(resources->resource_class);
+ xrmres->xrm_type = StringToQuark(resources->resource_type);
+ xrmres->xrm_offset = (Cardinal)
+ (-(int)resources->resource_offset - 1);
+ xrmres->xrm_default_type = StringToQuark(resources->default_type);
+ }
+#undef xrmres
+} /* XrmCompileResourceListEphem */
+
+static void BadSize(
+ Cardinal size,
+ XrmQuark name)
+{
+ String params[2];
+ Cardinal num_params = 2;
+
+ params[0] = (String)(long) size;
+ params[1] = XrmQuarkToString(name);
+ XtWarningMsg("invalidSizeOverride", "xtDependencies", XtCXtToolkitError,
+ "Representation size %d must match superclass's to override %s",
+ params, &num_params);
+} /* BadType */
+
+/*
+ * Create a new resource list, with the class resources following the
+ * superclass's resources. If a resource in the class list overrides
+ * a superclass resource, then just replace the superclass entry in place.
+ *
+ * At the same time, add a level of indirection to the XtResourceList to
+ * create and XrmResourceList.
+ */
+void _XtDependencies(
+ XtResourceList *class_resp, /* VAR */
+ Cardinal *class_num_resp, /* VAR */
+ XrmResourceList *super_res,
+ Cardinal super_num_res,
+ Cardinal super_widget_size)
+{
+ register XrmResourceList *new_res;
+ Cardinal new_num_res;
+ XrmResourceList class_res = (XrmResourceList) *class_resp;
+ Cardinal class_num_res = *class_num_resp;
+ register Cardinal i, j;
+ Cardinal new_next;
+
+ if (class_num_res == 0) {
+ /* Just point to superclass resource list */
+ *class_resp = (XtResourceList) super_res;
+ *class_num_resp = super_num_res;
+ return;
+ }
+
+ /* Allocate and initialize new_res with superclass resource pointers */
+ new_num_res = super_num_res + class_num_res;
+ new_res = (XrmResourceList *) __XtMalloc(new_num_res*sizeof(XrmResourceList));
+ if (super_num_res > 0)
+ XtMemmove(new_res, super_res, super_num_res * sizeof(XrmResourceList));
+
+ /* Put pointers to class resource entries into new_res */
+ new_next = super_num_res;
+ for (i = 0; i < class_num_res; i++) {
+ if ((Cardinal)(-class_res[i].xrm_offset-1) < super_widget_size) {
+ /* Probably an override of superclass resources--look for overlap */
+ for (j = 0; j < super_num_res; j++) {
+ if (class_res[i].xrm_offset == new_res[j]->xrm_offset) {
+ /* Spec is silent on what fields subclass can override.
+ * The only two of real concern are type & size.
+ * Although allowing type to be over-ridden introduces
+ * the possibility of errors, it's at present the only
+ * reasonable way to allow a subclass to force a private
+ * converter to be invoked for a subset of fields.
+ */
+ /* We do insist that size be identical to superclass */
+ if (class_res[i].xrm_size != new_res[j]->xrm_size) {
+ BadSize(class_res[i].xrm_size,
+ (XrmQuark) class_res[i].xrm_name);
+ class_res[i].xrm_size = new_res[j]->xrm_size;
+ }
+ new_res[j] = &(class_res[i]);
+ new_num_res--;
+ goto NextResource;
+ }
+ } /* for j */
+ }
+ /* Not an overlap, add an entry to new_res */
+ new_res[new_next++] = &(class_res[i]);
+NextResource:;
+ } /* for i */
+
+ /* Okay, stuff new resources back into class record */
+ *class_resp = (XtResourceList) new_res;
+ *class_num_resp = new_num_res;
+} /* _XtDependencies */
+
+
+void _XtResourceDependencies(
+ WidgetClass wc)
+{
+ WidgetClass sc;
+
+ sc = wc->core_class.superclass;
+ if (sc == NULL) {
+ _XtDependencies(&(wc->core_class.resources),
+ &(wc->core_class.num_resources),
+ (XrmResourceList *) NULL, (unsigned)0, (unsigned)0);
+ } else {
+ _XtDependencies(&(wc->core_class.resources),
+ &(wc->core_class.num_resources),
+ (XrmResourceList *) sc->core_class.resources,
+ sc->core_class.num_resources,
+ sc->core_class.widget_size);
+ }
+} /* _XtResourceDependencies */
+
+void _XtConstraintResDependencies(
+ ConstraintWidgetClass wc)
+{
+ ConstraintWidgetClass sc;
+
+ if (wc == (ConstraintWidgetClass) constraintWidgetClass) {
+ _XtDependencies(&(wc->constraint_class.resources),
+ &(wc->constraint_class.num_resources),
+ (XrmResourceList *)NULL, (unsigned)0, (unsigned)0);
+ } else {
+ sc = (ConstraintWidgetClass) wc->core_class.superclass;
+ _XtDependencies(&(wc->constraint_class.resources),
+ &(wc->constraint_class.num_resources),
+ (XrmResourceList *) sc->constraint_class.resources,
+ sc->constraint_class.num_resources,
+ sc->constraint_class.constraint_size);
+ }
+} /* _XtConstraintResDependencies */
+
+
+
+
+XrmResourceList* _XtCreateIndirectionTable (
+ XtResourceList resources,
+ Cardinal num_resources)
+{
+ register Cardinal idx;
+ XrmResourceList* table;
+
+ table = (XrmResourceList*)__XtMalloc(num_resources * sizeof(XrmResourceList));
+ for (idx = 0; idx < num_resources; idx++)
+ table[idx] = (XrmResourceList)(&(resources[idx]));
+ return table;
+}
+
+static XtCacheRef *GetResources(
+ Widget widget, /* Widget resources are associated with */
+ char* base, /* Base address of memory to write to */
+ XrmNameList names, /* Full inheritance name of widget */
+ XrmClassList classes, /* Full inheritance class of widget */
+ XrmResourceList* table, /* The list of resources required. */
+ unsigned num_resources, /* number of items in resource list */
+ XrmQuarkList quark_args, /* Arg names quarkified */
+ ArgList args, /* ArgList to override resources */
+ unsigned num_args, /* number of items in arg list */
+ XtTypedArgList typed_args, /* Typed arg list to override resources */
+ Cardinal* pNumTypedArgs, /* number of items in typed arg list */
+ Boolean tm_hack) /* do baseTranslations */
+{
+/*
+ * assert: *pNumTypedArgs == 0 if num_args > 0
+ * assert: num_args == 0 if *pNumTypedArgs > 0
+ */
+#define SEARCHLISTLEN 100
+#define MAXRESOURCES 400
+
+ XrmValue value;
+ XrmQuark rawType;
+ XrmValue convValue;
+ XrmHashTable stackSearchList[SEARCHLISTLEN];
+ XrmHashTable *searchList = stackSearchList;
+ unsigned int searchListSize = SEARCHLISTLEN;
+ Boolean found[MAXRESOURCES];
+ int typed[MAXRESOURCES];
+ XtCacheRef cache_ref[MAXRESOURCES];
+ XtCacheRef *cache_ptr, *cache_base;
+ Boolean persistent_resources = True;
+ Boolean found_persistence = False;
+ int num_typed_args = *pNumTypedArgs;
+ XrmDatabase db;
+ Boolean do_tm_hack = False;
+
+ if ((args == NULL) && (num_args != 0)) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "invalidArgCount","getResources",XtCXtToolkitError,
+ "argument count > 0 on NULL argument list",
+ (String *)NULL, (Cardinal *)NULL);
+ num_args = 0;
+ }
+ if (num_resources == 0) {
+ return NULL;
+ } else if (num_resources >= MAXRESOURCES) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "invalidResourceCount","getResources",XtCXtToolkitError,
+ "too many resources",
+ (String *)NULL, (Cardinal *)NULL);
+ return NULL;
+ } else if (table == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "invalidResourceCount","getResources",XtCXtToolkitError,
+ "resource count > 0 on NULL resource list",
+ (String *)NULL, (Cardinal *)NULL);
+ return NULL;
+ }
+
+ /* Mark each resource as not found on arg list */
+ bzero((char *) found, (int) (num_resources * sizeof(Boolean)));
+ bzero((char *) typed, (int) (num_resources * sizeof(int)));
+
+ /* Copy the args into the resources, mark each as found */
+ {
+ register ArgList arg;
+ register XtTypedArgList typed_arg;
+ register XrmName argName;
+ register Cardinal j;
+ register int i;
+ register XrmResourceList rx;
+ register XrmResourceList *res;
+ for (arg = args, i = 0; (Cardinal)i < num_args; i++, arg++) {
+ argName = quark_args[i];
+ if (argName == QinitialResourcesPersistent) {
+ persistent_resources = (Boolean)arg->value;
+ found_persistence = True;
+ continue;
+ }
+ for (j = 0, res = table; j < num_resources; j++, res++) {
+ rx = *res;
+ if (argName == rx->xrm_name) {
+ _XtCopyFromArg(
+ arg->value,
+ base - rx->xrm_offset - 1,
+ rx->xrm_size);
+ found[j] = TRUE;
+ break;
+ }
+ }
+ }
+ for (typed_arg = typed_args, i = 0; i < num_typed_args;
+ i++, typed_arg++) {
+ register XrmRepresentation argType;
+ argName = quark_args[i];
+ argType = (typed_arg->type == NULL) ? NULLQUARK
+ : XrmStringToRepresentation(typed_arg->type);
+ if (argName == QinitialResourcesPersistent) {
+ persistent_resources = (Boolean)typed_arg->value;
+ found_persistence = True;
+ break;
+ }
+ for (j = 0, res = table; j < num_resources; j++, res++) {
+ rx = *res;
+ if (argName == rx->xrm_name) {
+ if (argType != NULLQUARK && argType != rx->xrm_type) {
+ typed[j] = i + 1;
+ } else {
+ _XtCopyFromArg(
+ typed_arg->value,
+ base - rx->xrm_offset - 1,
+ rx->xrm_size);
+ }
+ found[j] = TRUE;
+ break;
+ }
+ }
+ }
+ }
+
+ /* Ask resource manager for a list of database levels that we can
+ do a single-level search on each resource */
+
+ db = XtScreenDatabase(XtScreenOfObject(widget));
+ while (!XrmQGetSearchList(db, names, classes,
+ searchList, searchListSize)) {
+ if (searchList == stackSearchList)
+ searchList = NULL;
+ searchList = (XrmHashTable*)XtRealloc((char*)searchList,
+ sizeof(XrmHashTable) *
+ (searchListSize *= 2));
+ }
+
+ if (persistent_resources)
+ cache_base = NULL;
+ else
+ cache_base = cache_ref;
+ /* geez, this is an ugly mess */
+ if (XtIsShell(widget)) {
+ register XrmResourceList *res;
+ register Cardinal j;
+ Screen *oldscreen = widget->core.screen;
+
+ /* look up screen resource first, since real rdb depends on it */
+ for (res = table, j = 0; j < num_resources; j++, res++) {
+ if ((*res)->xrm_name != Qscreen)
+ continue;
+ if (typed[j]) {
+ register XtTypedArg* arg = typed_args + typed[j] - 1;
+ XrmQuark from_type;
+ XrmValue from_val, to_val;
+
+ from_type = StringToQuark(arg->type);
+ from_val.size = arg->size;
+ if ((from_type == QString) || ((unsigned) arg->size > sizeof(XtArgVal)))
+ from_val.addr = (XPointer)arg->value;
+ else
+ from_val.addr = (XPointer)&arg->value;
+ to_val.size = sizeof(Screen*);
+ to_val.addr = (XPointer)&widget->core.screen;
+ found[j] = _XtConvert(widget, from_type, &from_val,
+ QScreen, &to_val, cache_base);
+ if (cache_base && *cache_base)
+ cache_base++;
+ }
+ if (!found[j]) {
+ if (XrmQGetSearchResource(searchList, Qscreen, QScreen,
+ &rawType, &value)) {
+ if (rawType != QScreen) {
+ convValue.size = sizeof(Screen*);
+ convValue.addr = (XPointer)&widget->core.screen;
+ (void)_XtConvert(widget, rawType, &value,
+ QScreen, &convValue, cache_base);
+ if (cache_base && *cache_base)
+ cache_base++;
+ } else {
+ widget->core.screen = *((Screen **)value.addr);
+ }
+ }
+ }
+ break;
+ }
+ /* now get the database to use for the rest of the resources */
+ if (widget->core.screen != oldscreen) {
+ db = XtScreenDatabase(widget->core.screen);
+ while (!XrmQGetSearchList(db, names, classes,
+ searchList, searchListSize)) {
+ if (searchList == stackSearchList)
+ searchList = NULL;
+ searchList = (XrmHashTable*)XtRealloc((char*)searchList,
+ sizeof(XrmHashTable) *
+ (searchListSize *= 2));
+ }
+ }
+ }
+
+ /* go to the resource manager for those resources not found yet */
+ /* if it's not in the resource database use the default value */
+
+ {
+ register XrmResourceList rx;
+ register XrmResourceList *res;
+ register Cardinal j;
+ register XrmRepresentation xrm_type;
+ register XrmRepresentation xrm_default_type;
+ char char_val;
+ short short_val;
+ int int_val;
+ long long_val;
+ char* char_ptr;
+
+ if (!found_persistence) {
+ if (XrmQGetSearchResource(searchList, QinitialResourcesPersistent,
+ QInitialResourcesPersistent, &rawType, &value)) {
+ if (rawType != QBoolean) {
+ convValue.size = sizeof(Boolean);
+ convValue.addr = (XPointer)&persistent_resources;
+ (void)_XtConvert(widget, rawType, &value, QBoolean,
+ &convValue, NULL);
+ }
+ else
+ persistent_resources = *(Boolean*)value.addr;
+ }
+ }
+ if (persistent_resources)
+ cache_ptr = NULL;
+ else if (cache_base)
+ cache_ptr = cache_base;
+ else
+ cache_ptr = cache_ref;
+
+ for (res = table, j = 0; j < num_resources; j++, res++) {
+ rx = *res;
+ xrm_type = rx->xrm_type;
+ if (typed[j]) {
+ register XtTypedArg* arg = typed_args + typed[j] - 1;
+
+ /*
+ * This resource value has been specified as a typed arg and
+ * has to be converted. Typed arg conversions are done here
+ * to correctly interpose them with normal resource conversions.
+ */
+ XrmQuark from_type;
+ XrmValue from_val, to_val;
+ Boolean converted;
+
+ from_type = StringToQuark(arg->type);
+ from_val.size = arg->size;
+ if ((from_type == QString) || ((unsigned) arg->size > sizeof(XtArgVal)))
+ from_val.addr = (XPointer)arg->value;
+ else
+ from_val.addr = (XPointer)&arg->value;
+ to_val.size = rx->xrm_size;
+ to_val.addr = base - rx->xrm_offset - 1;
+ converted = _XtConvert(widget, from_type, &from_val,
+ xrm_type, &to_val, cache_ptr);
+ if (converted) {
+
+ /* Copy the converted value back into the typed argument.
+ * normally the data should be <= sizeof(XtArgVal) and
+ * is stored directly into the 'value' field .... BUT
+ * if the resource size is greater than sizeof(XtArgVal)
+ * then we dynamically alloc a block of store to hold the
+ * data and zap a copy in there !!! .... freeing it later
+ * the size field in the typed arg is negated to indicate
+ * that the store pointed to by the value field is
+ * dynamic .......
+ * "freeing" happens in the case of _XtCreate after the
+ * CallInitialize ..... other clients of GetResources
+ * using typed args should be aware of the need to free
+ * this store .....
+ */
+
+ if(rx->xrm_size > sizeof(XtArgVal)) {
+ arg->value = (XtArgVal) __XtMalloc(rx->xrm_size);
+ arg->size = -(arg->size);
+ } else { /* will fit - copy directly into value field */
+ arg->value = (XtArgVal) NULL;
+ }
+ CopyToArg((char *)(base - rx->xrm_offset - 1),
+ &arg->value, rx->xrm_size);
+
+ } else {
+ /* Conversion failed. Get default value. */
+ found[j] = False;
+ }
+
+ if (cache_ptr && *cache_ptr)
+ cache_ptr++;
+ }
+
+ if (!found[j]) {
+ Boolean already_copied = False;
+ Boolean have_value = False;
+
+ if (XrmQGetSearchResource(searchList,
+ rx->xrm_name, rx->xrm_class, &rawType, &value)) {
+ if (rawType != xrm_type) {
+ convValue.size = rx->xrm_size;
+ convValue.addr = (XPointer)(base - rx->xrm_offset - 1);
+ already_copied = have_value =
+ _XtConvert(widget, rawType, &value,
+ xrm_type, &convValue, cache_ptr);
+ if (cache_ptr && *cache_ptr)
+ cache_ptr++;
+ } else have_value = True;
+ if (have_value && rx->xrm_name == Qtranslations)
+ do_tm_hack = True;
+ }
+ LOCK_PROCESS;
+ if (!have_value
+ && ((rx->xrm_default_type == QImmediate)
+ || (rx->xrm_default_type == xrm_type)
+ || (rx->xrm_default_addr != NULL))) {
+ /* Convert default value to proper type */
+ xrm_default_type = rx->xrm_default_type;
+ if (xrm_default_type == QCallProc) {
+#ifdef CRAY
+ if ( (int) Cjumpp != (int) Cjump)
+ (*(XtResourceDefaultProc)
+ (((int)(rx->xrm_default_addr))<<2))(
+ widget,-(rx->xrm_offset+1), &value);
+ else
+#endif
+ (*(XtResourceDefaultProc)(rx->xrm_default_addr))(
+ widget,-(rx->xrm_offset+1), &value);
+
+ } else if (xrm_default_type == QImmediate) {
+ /* XtRImmediate == XtRString for type XtRString */
+ if (xrm_type == QString) {
+ value.addr = rx->xrm_default_addr;
+ } else if (rx->xrm_size == sizeof(int)) {
+ int_val = (int)(long)rx->xrm_default_addr;
+ value.addr = (XPointer) &int_val;
+ } else if (rx->xrm_size == sizeof(short)) {
+ short_val = (short)(long)rx->xrm_default_addr;
+ value.addr = (XPointer) &short_val;
+ } else if (rx->xrm_size == sizeof(char)) {
+ char_val = (char)(long)rx->xrm_default_addr;
+ value.addr = (XPointer) &char_val;
+ } else if (rx->xrm_size == sizeof(long)) {
+ long_val = (long)rx->xrm_default_addr;
+ value.addr = (XPointer) &long_val;
+ } else if (rx->xrm_size == sizeof(char*)) {
+ char_ptr = (char*)rx->xrm_default_addr;
+ value.addr = (XPointer) &char_ptr;
+ } else {
+ value.addr = (XPointer) &(rx->xrm_default_addr);
+ }
+ } else if (xrm_default_type == xrm_type) {
+ value.addr = rx->xrm_default_addr;
+ } else {
+ value.addr = rx->xrm_default_addr;
+ if (xrm_default_type == QString) {
+ value.size = strlen((char *)value.addr) + 1;
+ } else {
+ value.size = sizeof(XtPointer);
+ }
+ convValue.size = rx->xrm_size;
+ convValue.addr = (XPointer)(base - rx->xrm_offset - 1);
+ already_copied =
+ _XtConvert(widget, xrm_default_type, &value,
+ xrm_type, &convValue, cache_ptr);
+ if (!already_copied)
+ value.addr = NULL;
+ if (cache_ptr && *cache_ptr)
+ cache_ptr++;
+ }
+ }
+ if (!already_copied) {
+ if (xrm_type == QString) {
+ *((String*)(base - rx->xrm_offset - 1)) = value.addr;
+ } else {
+ if (value.addr != NULL) {
+ XtMemmove(base - rx->xrm_offset - 1,
+ value.addr, rx->xrm_size);
+ } else {
+ /* didn't get value, initialize to NULL... */
+ XtBZero(base - rx->xrm_offset - 1, rx->xrm_size);
+ }
+ }
+ }
+ UNLOCK_PROCESS;
+
+ if (typed[j]) {
+ /*
+ * This resource value was specified as a typed arg.
+ * However, the default value is being used here since
+ * type type conversion failed, so we compress the list.
+ */
+ register XtTypedArg* arg = typed_args + typed[j] - 1;
+ register int i;
+
+ for (i = num_typed_args - typed[j]; i; i--, arg++) {
+ *arg = *(arg+1);
+ }
+ num_typed_args--;
+ }
+ }
+ }
+ if (tm_hack)
+ widget->core.tm.current_state = NULL;
+ if (tm_hack &&
+ (!widget->core.tm.translations ||
+ (do_tm_hack &&
+ widget->core.tm.translations->operation != XtTableReplace)) &&
+ XrmQGetSearchResource(searchList, QbaseTranslations,
+ QTranslations, &rawType, &value)) {
+ if (rawType != QTranslationTable) {
+ convValue.size = sizeof(XtTranslations);
+ convValue.addr = (XPointer)&widget->core.tm.current_state;
+ (void)_XtConvert(widget, rawType, &value,
+ QTranslationTable, &convValue, cache_ptr);
+ if (cache_ptr && *cache_ptr)
+ cache_ptr++;
+ } else {
+ *((XtTranslations *)&widget->core.tm.current_state) =
+ *((XtTranslations *)value.addr);
+ }
+ }
+ }
+ if ((Cardinal)num_typed_args != *pNumTypedArgs) *pNumTypedArgs = num_typed_args;
+ if (searchList != stackSearchList) XtFree((char*)searchList);
+ if (!cache_ptr)
+ cache_ptr = cache_base;
+ if (cache_ptr && cache_ptr != cache_ref) {
+ int cache_ref_size = cache_ptr - cache_ref;
+ XtCacheRef *refs = (XtCacheRef*)
+ __XtMalloc((unsigned)sizeof(XtCacheRef)*(cache_ref_size + 1));
+ (void) memmove(refs, cache_ref, sizeof(XtCacheRef)*cache_ref_size );
+ refs[cache_ref_size] = NULL;
+ return refs;
+ }
+ return (XtCacheRef*)NULL;
+}
+
+
+
+static void CacheArgs(
+ ArgList args,
+ Cardinal num_args,
+ XtTypedArgList typed_args,
+ Cardinal num_typed_args,
+ XrmQuarkList quark_cache,
+ Cardinal num_quarks,
+ XrmQuarkList *pQuarks) /* RETURN */
+{
+ register XrmQuarkList quarks;
+ register Cardinal i;
+ register Cardinal count;
+
+ count = (args != NULL) ? num_args : num_typed_args;
+
+ if (num_quarks < count) {
+ quarks = (XrmQuarkList) __XtMalloc(count * sizeof(XrmQuark));
+ } else {
+ quarks = quark_cache;
+ }
+ *pQuarks = quarks;
+
+ if (args != NULL) {
+ for (i = count; i; i--)
+ *quarks++ = StringToQuark((args++)->name);
+ }
+ else {
+ for (i = count; i; i--)
+ *quarks++ = StringToQuark((typed_args++)->name);
+ }
+}
+
+#define FreeCache(cache, pointer) \
+ if (cache != pointer) XtFree((char *)pointer)
+
+
+XtCacheRef *_XtGetResources(
+ register Widget w,
+ ArgList args,
+ Cardinal num_args,
+ XtTypedArgList typed_args,
+ Cardinal* num_typed_args)
+{
+ XrmName *names, names_s[50];
+ XrmClass *classes, classes_s[50];
+ XrmQuark quark_cache[100];
+ XrmQuarkList quark_args;
+ WidgetClass wc;
+ ConstraintWidgetClass cwc;
+ XtCacheRef *cache_refs;
+ Cardinal count;
+
+ wc = XtClass(w);
+
+ count = CountTreeDepth(w);
+ names = (XrmName*) XtStackAlloc (count * sizeof(XrmName), names_s);
+ classes = (XrmClass*) XtStackAlloc (count * sizeof(XrmClass), classes_s);
+ if (names == NULL || classes == NULL) _XtAllocError(NULL);
+
+ /* Get names, classes for widget and ancestors */
+ GetNamesAndClasses(w, names, classes);
+
+ /* Compile arg list into quarks */
+ CacheArgs(args, num_args, typed_args, *num_typed_args, quark_cache,
+ XtNumber(quark_cache), &quark_args);
+
+ /* Get normal resources */
+ LOCK_PROCESS;
+ cache_refs = GetResources(w, (char*)w, names, classes,
+ (XrmResourceList *) wc->core_class.resources,
+ wc->core_class.num_resources, quark_args, args, num_args,
+ typed_args, num_typed_args, XtIsWidget(w));
+
+ if (w->core.constraints != NULL) {
+ cwc = (ConstraintWidgetClass) XtClass(w->core.parent);
+ (void) GetResources(w, (char*)w->core.constraints, names, classes,
+ (XrmResourceList *) cwc->constraint_class.resources,
+ cwc->constraint_class.num_resources,
+ quark_args, args, num_args, typed_args, num_typed_args, False);
+ }
+ FreeCache(quark_cache, quark_args);
+ UNLOCK_PROCESS;
+ XtStackFree((XtPointer)names, names_s);
+ XtStackFree((XtPointer)classes, classes_s);
+ return cache_refs;
+} /* _XtGetResources */
+
+
+void _XtGetSubresources (
+ Widget w, /* Widget "parent" of subobject */
+ XtPointer base, /* Base address to write to */
+ const char* name, /* name of subobject */
+ const char* class, /* class of subobject */
+ XtResourceList resources, /* resource list for subobject */
+ Cardinal num_resources,
+ ArgList args, /* arg list to override resources */
+ Cardinal num_args,
+ XtTypedArgList typed_args,
+ Cardinal num_typed_args)
+{
+ XrmName *names, names_s[50];
+ XrmClass *classes, classes_s[50];
+ XrmQuark quark_cache[100];
+ XrmQuarkList quark_args;
+ XrmResourceList* table;
+ Cardinal count, ntyped_args = num_typed_args;
+ WIDGET_TO_APPCON(w);
+
+ if (num_resources == 0) return;
+
+ LOCK_APP(app);
+ count = CountTreeDepth(w);
+ count++; /* make sure there's enough room for name and class */
+ names = (XrmName*) XtStackAlloc(count * sizeof(XrmName), names_s);
+ classes = (XrmClass*) XtStackAlloc(count * sizeof(XrmClass), classes_s);
+ if (names == NULL || classes == NULL) _XtAllocError(NULL);
+
+ /* Get full name, class of subobject */
+ GetNamesAndClasses(w, names, classes);
+ count -= 2;
+ names[count] = StringToName(name);
+ classes[count] = StringToClass(class);
+ count++;
+ names[count] = NULLQUARK;
+ classes[count] = NULLQUARK;
+
+ /* Compile arg list into quarks */
+ CacheArgs(args, num_args, typed_args, num_typed_args,
+ quark_cache, XtNumber(quark_cache), &quark_args);
+
+ /* Compile resource list if needed */
+ if (((int) resources->resource_offset) >= 0) {
+ XrmCompileResourceListEphem(resources, num_resources);
+ }
+ table = _XtCreateIndirectionTable(resources, num_resources);
+ (void) GetResources(w, (char*)base, names, classes, table, num_resources,
+ quark_args, args, num_args,
+ typed_args, &ntyped_args, False);
+ FreeCache(quark_cache, quark_args);
+ XtFree((char *)table);
+ XtStackFree((XtPointer)names, names_s);
+ XtStackFree((XtPointer)classes, classes_s);
+ UNLOCK_APP(app);
+}
+
+void XtGetSubresources (
+ Widget w, /* Widget "parent" of subobject */
+ XtPointer base, /* Base address to write to */
+ _Xconst char* name, /* name of subobject */
+ _Xconst char* class, /* class of subobject */
+ XtResourceList resources, /* resource list for subobject */
+ Cardinal num_resources,
+ ArgList args, /* arg list to override resources */
+ Cardinal num_args)
+{
+ _XtGetSubresources (w, base, name, class, resources, num_resources, args, num_args, NULL, 0);
+}
+
+
+void _XtGetApplicationResources (
+ Widget w, /* Application shell widget */
+ XtPointer base, /* Base address to write to */
+ XtResourceList resources, /* resource list for subobject */
+ Cardinal num_resources,
+ ArgList args, /* arg list to override resources */
+ Cardinal num_args,
+ XtTypedArgList typed_args,
+ Cardinal num_typed_args)
+{
+ XrmName *names, names_s[50];
+ XrmClass *classes, classes_s[50];
+ XrmQuark quark_cache[100];
+ XrmQuarkList quark_args;
+ XrmResourceList* table;
+ Cardinal count, ntyped_args = num_typed_args;
+#ifdef XTHREADS
+ XtAppContext app;
+#endif
+
+ if (num_resources == 0) return;
+
+#ifdef XTHREADS
+ if (w == NULL) app = _XtDefaultAppContext();
+ else app = XtWidgetToApplicationContext(w);
+#endif
+
+ LOCK_APP(app);
+ /* Get full name, class of application */
+ if (w == NULL) {
+ /* hack for R2 compatibility */
+ XtPerDisplay pd = _XtGetPerDisplay(_XtDefaultAppContext()->list[0]);
+ names = (XrmName*) XtStackAlloc (2 * sizeof(XrmName), names_s);
+ classes = (XrmClass*) XtStackAlloc (2 * sizeof(XrmClass), classes_s);
+ names[0] = pd->name;
+ names[1] = NULLQUARK;
+ classes[0] = pd->class;
+ classes[1] = NULLQUARK;
+ }
+ else {
+ count = CountTreeDepth(w);
+ names = (XrmName*) XtStackAlloc(count * sizeof(XrmName), names_s);
+ classes = (XrmClass*) XtStackAlloc(count * sizeof(XrmClass), classes_s);
+ if (names == NULL || classes == NULL) _XtAllocError(NULL);
+ GetNamesAndClasses(w, names, classes);
+ }
+
+ /* Compile arg list into quarks */
+ CacheArgs(args, num_args, typed_args, num_typed_args, quark_cache,
+ XtNumber(quark_cache), &quark_args);
+ /* Compile resource list if needed */
+ if (((int) resources->resource_offset) >= 0) {
+#ifdef CRAY2
+ if (base == 0) { /* this client is non-portable, but... */
+ int count;
+ XtResourceList res = resources;
+ for (count = 0; count < num_resources; res++, count++) {
+ res->resource_offset *= sizeof(long);
+ }
+ }
+#endif /* CRAY2 */
+ XrmCompileResourceListEphem(resources, num_resources);
+ }
+ table = _XtCreateIndirectionTable(resources,num_resources);
+
+ (void) GetResources(w, (char*)base, names, classes, table, num_resources,
+ quark_args, args, num_args,
+ typed_args, &ntyped_args, False);
+ FreeCache(quark_cache, quark_args);
+ XtFree((char *)table);
+ if (w != NULL) {
+ XtStackFree((XtPointer)names, names_s);
+ XtStackFree((XtPointer)classes, classes_s);
+ }
+ UNLOCK_APP(app);
+}
+
+void XtGetApplicationResources (
+ Widget w, /* Application shell widget */
+ XtPointer base, /* Base address to write to */
+ XtResourceList resources, /* resource list for subobject */
+ Cardinal num_resources,
+ ArgList args, /* arg list to override resources */
+ Cardinal num_args)
+{
+ _XtGetApplicationResources(w, base, resources, num_resources, args, num_args, NULL, 0);
+}
+
+static Boolean initialized = FALSE;
+
+void _XtResourceListInitialize(void)
+{
+ LOCK_PROCESS;
+ if (initialized) {
+ XtWarningMsg("initializationError","xtInitialize",XtCXtToolkitError,
+ "Initializing Resource Lists twice",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_PROCESS;
+ return;
+ }
+ initialized = TRUE;
+ UNLOCK_PROCESS;
+
+ QBoolean = XrmPermStringToQuark(XtCBoolean);
+ QString = XrmPermStringToQuark(XtCString);
+ QCallProc = XrmPermStringToQuark(XtRCallProc);
+ QImmediate = XrmPermStringToQuark(XtRImmediate);
+ QinitialResourcesPersistent = XrmPermStringToQuark(XtNinitialResourcesPersistent);
+ QInitialResourcesPersistent = XrmPermStringToQuark(XtCInitialResourcesPersistent);
+ Qtranslations = XrmPermStringToQuark(XtNtranslations);
+ QbaseTranslations = XrmPermStringToQuark("baseTranslations");
+ QTranslations = XrmPermStringToQuark(XtCTranslations);
+ QTranslationTable = XrmPermStringToQuark(XtRTranslationTable);
+ Qscreen = XrmPermStringToQuark(XtNscreen);
+ QScreen = XrmPermStringToQuark(XtCScreen);
+}
diff --git a/nx-X11/lib/Xt/Selection.c b/nx-X11/lib/Xt/Selection.c
new file mode 100644
index 000000000..46c75f882
--- /dev/null
+++ b/nx-X11/lib/Xt/Selection.c
@@ -0,0 +1,2295 @@
+/* $Xorg: Selection.c,v 1.4 2001/02/09 02:03:56 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/Selection.c,v 3.9 2001/12/14 19:56:29 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+#include "SelectionI.h"
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+void _XtSetDefaultSelectionTimeout(
+ unsigned long *timeout)
+{
+ *timeout = 5000; /* default to 5 seconds */
+}
+
+void XtSetSelectionTimeout(
+ unsigned long timeout)
+{
+ XtAppSetSelectionTimeout(_XtDefaultAppContext(), timeout);
+}
+
+void XtAppSetSelectionTimeout(
+ XtAppContext app,
+ unsigned long timeout)
+{
+ LOCK_APP(app);
+ app->selectionTimeout = timeout;
+ UNLOCK_APP(app);
+}
+
+unsigned long XtGetSelectionTimeout(void)
+{
+ return XtAppGetSelectionTimeout(_XtDefaultAppContext());
+}
+
+unsigned long XtAppGetSelectionTimeout(
+ XtAppContext app)
+{
+ unsigned long retval;
+
+ LOCK_APP(app);
+ retval = app->selectionTimeout;
+ UNLOCK_APP(app);
+ return retval;
+}
+
+
+/* General utilities */
+
+static void HandleSelectionReplies(Widget, XtPointer, XEvent *, Boolean *);
+static void ReqTimedOut(XtPointer, XtIntervalId *);
+static void HandlePropertyGone(Widget, XtPointer, XEvent *, Boolean *);
+static void HandleGetIncrement(Widget, XtPointer, XEvent *, Boolean *);
+static void HandleIncremental(Display *, Widget, Atom, CallBackInfo, unsigned long);
+
+static XContext selectPropertyContext = 0;
+static XContext paramPropertyContext = 0;
+static XContext multipleContext = 0;
+
+/* Multiple utilities */
+static void AddSelectionRequests(Widget, Atom, int, Atom *, XtSelectionCallbackProc *, int, XtPointer *, Boolean *, Atom *);
+static Boolean IsGatheringRequest(Widget, Atom);
+
+#define PREALLOCED 32
+
+/* Parameter utilities */
+static void AddParamInfo(Widget, Atom, Atom);
+static void RemoveParamInfo(Widget, Atom);
+static Atom GetParamInfo(Widget, Atom);
+
+static int StorageSize[3] = {1, sizeof(short), sizeof(long)};
+#define BYTELENGTH(length, format) ((length) * StorageSize[(format)>>4])
+#define NUMELEM(bytelength, format) ((bytelength) / StorageSize[(format)>>4])
+
+/* Xlib and Xt are permitted to have different memory allocators, and in the
+ * XtSelectionCallbackProc the client is instructed to free the selection
+ * value with XtFree, so the selection value received from XGetWindowProperty
+ * should be copied to memory allocated through Xt. But copying is
+ * undesirable since the selection value may be large, and, under normal
+ * library configuration copying is unnecessary.
+ */
+#ifdef XTTRACEMEMORY
+#define XT_COPY_SELECTION 1
+#endif
+
+/*ARGSUSED*/
+static void FreePropList(
+ Widget w, /* unused */
+ XtPointer closure,
+ XtPointer callData) /* unused */
+{
+ PropList sarray = (PropList)closure;
+ LOCK_PROCESS;
+ XDeleteContext(sarray->dpy, DefaultRootWindow(sarray->dpy),
+ selectPropertyContext);
+ UNLOCK_PROCESS;
+ XtFree((char*)sarray->list);
+ XtFree((char*)closure);
+}
+
+
+static PropList GetPropList(
+ Display *dpy)
+{
+ PropList sarray;
+ Atom atoms[4];
+ static char* names[] = {
+ "INCR",
+ "MULTIPLE",
+ "TIMESTAMP",
+ "_XT_SELECTION_0" };
+
+ LOCK_PROCESS;
+ if (selectPropertyContext == 0)
+ selectPropertyContext = XUniqueContext();
+ if (XFindContext(dpy, DefaultRootWindow(dpy), selectPropertyContext,
+ (XPointer *)&sarray)) {
+ XtPerDisplay pd = _XtGetPerDisplay(dpy);
+ sarray = (PropList) __XtMalloc((unsigned) sizeof(PropListRec));
+ sarray->dpy = dpy;
+ XInternAtoms(dpy, names, 4, FALSE, atoms);
+ sarray->incr_atom = atoms[0];
+ sarray->indirect_atom = atoms[1];
+ sarray->timestamp_atom = atoms[2];
+ sarray->propCount = 1;
+ sarray->list =
+ (SelectionProp)__XtMalloc((unsigned) sizeof(SelectionPropRec));
+ sarray->list[0].prop = atoms[3];
+ sarray->list[0].avail = TRUE;
+ (void) XSaveContext(dpy, DefaultRootWindow(dpy), selectPropertyContext,
+ (char *) sarray);
+ _XtAddCallback( &pd->destroy_callbacks,
+ FreePropList, (XtPointer)sarray );
+ }
+ UNLOCK_PROCESS;
+ return sarray;
+}
+
+
+static Atom GetSelectionProperty(
+ Display *dpy)
+{
+ SelectionProp p;
+ int propCount;
+ char propname[80];
+ PropList sarray = GetPropList(dpy);
+
+ for (p = sarray->list, propCount=sarray->propCount;
+ propCount;
+ p++, propCount--) {
+ if (p->avail) {
+ p->avail = FALSE;
+ return(p->prop);
+ }
+ }
+ propCount = sarray->propCount++;
+ sarray->list = (SelectionProp) XtRealloc((XtPointer)sarray->list,
+ (unsigned)(sarray->propCount*sizeof(SelectionPropRec)));
+ (void) sprintf(propname, "%s%d", "_XT_SELECTION_", propCount);
+ sarray->list[propCount].prop = XInternAtom(dpy, propname, FALSE);
+ sarray->list[propCount].avail = FALSE;
+ return(sarray->list[propCount].prop);
+}
+
+static void FreeSelectionProperty(
+ Display *dpy,
+ Atom prop)
+{
+ SelectionProp p;
+ PropList sarray;
+ if (prop == None) return;
+ LOCK_PROCESS;
+ if (XFindContext(dpy, DefaultRootWindow(dpy), selectPropertyContext,
+ (XPointer *)&sarray))
+ XtAppErrorMsg(XtDisplayToApplicationContext(dpy),
+ "noSelectionProperties", "freeSelectionProperty", XtCXtToolkitError,
+ "internal error: no selection property context for display",
+ (String *)NULL, (Cardinal *)NULL );
+ UNLOCK_PROCESS;
+ for (p = sarray->list; p; p++)
+ if (p->prop == prop) {
+ p->avail = TRUE;
+ return;
+ }
+}
+
+static void FreeInfo(
+ CallBackInfo info)
+{
+ XtFree((char*)info->incremental);
+ XtFree((char*)info->callbacks);
+ XtFree((char*)info->req_closure);
+ XtFree((char*)info->target);
+ XtFree((char*)info);
+}
+
+static CallBackInfo MakeInfo(
+ Select ctx,
+ XtSelectionCallbackProc *callbacks,
+ XtPointer *closures,
+ int count,
+ Widget widget,
+ Time time,
+ Boolean *incremental,
+ Atom *properties)
+{
+ CallBackInfo info = XtNew(CallBackInfoRec);
+
+ info->ctx = ctx;
+ info->callbacks = (XtSelectionCallbackProc *)
+ __XtMalloc((unsigned) (count * sizeof(XtSelectionCallbackProc)));
+ (void) memmove((char*)info->callbacks, (char*)callbacks,
+ count * sizeof(XtSelectionCallbackProc));
+ info->req_closure =
+ (XtPointer*)__XtMalloc((unsigned) (count * sizeof(XtPointer)));
+ (void) memmove((char*)info->req_closure, (char*)closures,
+ count * sizeof(XtPointer));
+ if (count == 1 && properties != NULL && properties[0] != None)
+ info->property = properties[0];
+ else {
+ info->property = GetSelectionProperty(XtDisplay(widget));
+ XDeleteProperty(XtDisplay(widget), XtWindow(widget),
+ info->property);
+ }
+ info->proc = HandleSelectionReplies;
+ info->widget = widget;
+ info->time = time;
+ info->incremental = (Boolean*) __XtMalloc(count * sizeof(Boolean));
+ (void) memmove((char*)info->incremental, (char*) incremental,
+ count * sizeof(Boolean));
+ info->current = 0;
+ info->value = NULL;
+ return (info);
+}
+
+static void RequestSelectionValue(
+ CallBackInfo info,
+ Atom selection,
+ Atom target)
+{
+#ifndef DEBUG_WO_TIMERS
+ XtAppContext app = XtWidgetToApplicationContext(info->widget);
+ info->timeout = XtAppAddTimeOut(app,
+ app->selectionTimeout, ReqTimedOut, (XtPointer)info);
+#endif
+ XtAddEventHandler(info->widget, (EventMask)0, TRUE,
+ HandleSelectionReplies, (XtPointer)info);
+ XConvertSelection(info->ctx->dpy, selection, target,
+ info->property, XtWindow(info->widget), info->time);
+}
+
+
+static XContext selectContext = 0;
+
+static Select NewContext(
+ Display *dpy,
+ Atom selection)
+{
+ /* assert(selectContext != 0) */
+ Select ctx = XtNew(SelectRec);
+ ctx->dpy = dpy;
+ ctx->selection = selection;
+ ctx->widget = NULL;
+ ctx->prop_list = GetPropList(dpy);
+ ctx->ref_count = 0;
+ ctx->free_when_done = FALSE;
+ ctx->was_disowned = FALSE;
+ LOCK_PROCESS;
+ (void)XSaveContext(dpy, (Window)selection, selectContext, (char *)ctx);
+ UNLOCK_PROCESS;
+ return ctx;
+}
+
+static Select FindCtx(
+ Display *dpy,
+ Atom selection)
+{
+ Select ctx;
+
+ LOCK_PROCESS;
+ if (selectContext == 0)
+ selectContext = XUniqueContext();
+ if (XFindContext(dpy, (Window)selection, selectContext, (XPointer *)&ctx))
+ ctx = NewContext(dpy, selection);
+ UNLOCK_PROCESS;
+ return ctx;
+}
+
+/*ARGSUSED*/
+static void WidgetDestroyed(
+ Widget widget,
+ XtPointer closure, XtPointer data)
+{
+ Select ctx = (Select) closure;
+ if (ctx->widget == widget) {
+ if (ctx->free_when_done)
+ XtFree((char*)ctx);
+ else
+ ctx->widget = NULL;
+ }
+}
+
+/* Selection Owner code */
+
+static void HandleSelectionEvents(Widget, XtPointer, XEvent *, Boolean *);
+
+static Boolean LoseSelection(
+ Select ctx,
+ Widget widget,
+ Atom selection,
+ Time time)
+{
+ if ((ctx->widget == widget) &&
+ (ctx->selection == selection) && /* paranoia */
+ !ctx->was_disowned &&
+ ((time == CurrentTime) || (time >= ctx->time)))
+ {
+ XtRemoveEventHandler(widget, (EventMask)0, TRUE,
+ HandleSelectionEvents, (XtPointer)ctx);
+ XtRemoveCallback(widget, XtNdestroyCallback,
+ WidgetDestroyed, (XtPointer)ctx);
+ ctx->was_disowned = TRUE; /* widget officially loses ownership */
+ /* now inform widget */
+ if (ctx->loses) {
+ if (ctx->incremental)
+ (*(XtLoseSelectionIncrProc)ctx->loses)
+ (widget, &ctx->selection, ctx->owner_closure);
+ else (*ctx->loses)(widget, &ctx->selection);
+ }
+ return(TRUE);
+ }
+ else return(FALSE);
+}
+
+static XContext selectWindowContext = 0;
+
+/* %%% Xlib.h should make this public! */
+typedef int (*xErrorHandler)(Display*, XErrorEvent*);
+
+static xErrorHandler oldErrorHandler = NULL;
+static unsigned long firstProtectRequest;
+static Window errorWindow;
+
+static int LocalErrorHandler (
+ Display *dpy,
+ XErrorEvent *error)
+{
+ int retval;
+
+ /* If BadWindow error on selection requestor, nothing to do but let
+ * the transfer timeout. Otherwise, invoke saved error handler. */
+
+ LOCK_PROCESS;
+
+ if (error->error_code == BadWindow && error->resourceid == errorWindow &&
+ error->serial >= firstProtectRequest) {
+ UNLOCK_PROCESS;
+ return 0;
+ }
+
+ if (oldErrorHandler == NULL) {
+ UNLOCK_PROCESS;
+ return 0; /* should never happen */
+ }
+
+ retval = (*oldErrorHandler)(dpy, error);
+ UNLOCK_PROCESS;
+ return retval;
+}
+
+static void StartProtectedSection(
+ Display *dpy,
+ Window window)
+{
+ /* protect ourselves against request window being destroyed
+ * before completion of transfer */
+
+ LOCK_PROCESS;
+ oldErrorHandler = XSetErrorHandler(LocalErrorHandler);
+ firstProtectRequest = NextRequest(dpy);
+ errorWindow = window;
+ UNLOCK_PROCESS;
+}
+
+static void EndProtectedSection(
+ Display *dpy)
+{
+ /* flush any generated errors on requestor and
+ * restore original error handler */
+
+ XSync(dpy, False);
+
+ LOCK_PROCESS;
+ XSetErrorHandler(oldErrorHandler);
+ oldErrorHandler = NULL;
+ UNLOCK_PROCESS;
+}
+
+static void AddHandler(
+ Request req,
+ EventMask mask,
+ XtEventHandler proc,
+ XtPointer closure)
+{
+ Display *dpy = req->ctx->dpy;
+ Window window = req->requestor;
+ Widget widget = XtWindowToWidget(dpy, window);
+
+ if (widget != NULL) req->widget = widget;
+ else widget = req->widget;
+
+ if (XtWindow(widget) == window)
+ XtAddEventHandler(widget, mask, False, proc, closure);
+ else {
+ RequestWindowRec *requestWindowRec;
+ LOCK_PROCESS;
+ if (selectWindowContext == 0)
+ selectWindowContext = XUniqueContext();
+ if (XFindContext(dpy, window, selectWindowContext,
+ (XPointer *)&requestWindowRec)) {
+ requestWindowRec = XtNew(RequestWindowRec);
+ requestWindowRec->active_transfer_count = 0;
+ (void)XSaveContext(dpy, window, selectWindowContext,
+ (char *)requestWindowRec);
+ }
+ UNLOCK_PROCESS;
+ if (requestWindowRec->active_transfer_count++ == 0) {
+ XtRegisterDrawable(dpy, window, widget);
+ XSelectInput(dpy, window, mask);
+ }
+ XtAddRawEventHandler(widget, mask, FALSE, proc, closure);
+ }
+}
+
+static void RemoveHandler(
+ Request req,
+ EventMask mask,
+ XtEventHandler proc,
+ XtPointer closure)
+{
+ Display *dpy = req->ctx->dpy;
+ Window window = req->requestor;
+ Widget widget = req->widget;
+
+ if ((XtWindowToWidget(dpy, window) == widget) &&
+ (XtWindow(widget) != window)) {
+ /* we had to hang this window onto our widget; take it off */
+ RequestWindowRec* requestWindowRec;
+ XtRemoveRawEventHandler(widget, mask, TRUE, proc, closure);
+ LOCK_PROCESS;
+ (void)XFindContext(dpy, window, selectWindowContext,
+ (XPointer *)&requestWindowRec);
+ UNLOCK_PROCESS;
+ if (--requestWindowRec->active_transfer_count == 0) {
+ XtUnregisterDrawable(dpy, window);
+ StartProtectedSection(dpy, window);
+ XSelectInput(dpy, window, 0L);
+ EndProtectedSection(dpy);
+ LOCK_PROCESS;
+ (void)XDeleteContext(dpy, window, selectWindowContext);
+ UNLOCK_PROCESS;
+ XtFree((char*)requestWindowRec);
+ }
+ } else {
+ XtRemoveEventHandler(widget, mask, TRUE, proc, closure);
+ }
+}
+
+/* ARGSUSED */
+static void OwnerTimedOut(
+ XtPointer closure,
+ XtIntervalId *id)
+{
+ Request req = (Request)closure;
+ Select ctx = req->ctx;
+
+ if (ctx->incremental && (ctx->owner_cancel != NULL)) {
+ (*ctx->owner_cancel)(ctx->widget, &ctx->selection,
+ &req->target, (XtRequestId*)&req,
+ ctx->owner_closure);
+ } else {
+ if (ctx->notify == NULL)
+ XtFree((char*)req->value);
+ else {
+ /* the requestor hasn't deleted the property, but
+ * the owner needs to free the value.
+ */
+ if (ctx->incremental)
+ (*(XtSelectionDoneIncrProc)ctx->notify)
+ (ctx->widget, &ctx->selection, &req->target,
+ (XtRequestId*)&req, ctx->owner_closure);
+ else
+ (*ctx->notify)(ctx->widget, &ctx->selection, &req->target);
+ }
+ }
+
+ RemoveHandler(req, (EventMask)PropertyChangeMask,
+ HandlePropertyGone, closure);
+ XtFree((char*)req);
+ if (--ctx->ref_count == 0 && ctx->free_when_done)
+ XtFree((char*)ctx);
+}
+
+static void SendIncrement(
+ Request incr)
+{
+ Display *dpy = incr->ctx->dpy;
+
+ unsigned long incrSize = MAX_SELECTION_INCR(dpy);
+ if (incrSize > incr->bytelength - incr->offset)
+ incrSize = incr->bytelength - incr->offset;
+ StartProtectedSection(dpy, incr->requestor);
+ XChangeProperty(dpy, incr->requestor, incr->property,
+ incr->type, incr->format, PropModeReplace,
+ (unsigned char *)incr->value + incr->offset,
+ NUMELEM((int)incrSize, incr->format));
+ EndProtectedSection(dpy);
+ incr->offset += incrSize;
+}
+
+static void AllSent(
+ Request req)
+{
+ Select ctx = req->ctx;
+ StartProtectedSection(ctx->dpy, req->requestor);
+ XChangeProperty(ctx->dpy, req->requestor,
+ req->property, req->type, req->format,
+ PropModeReplace, (unsigned char *) NULL, 0);
+ EndProtectedSection(ctx->dpy);
+ req->allSent = TRUE;
+
+ if (ctx->notify == NULL) XtFree((char*)req->value);
+}
+
+/*ARGSUSED*/
+static void HandlePropertyGone(
+ Widget widget,
+ XtPointer closure,
+ XEvent *ev,
+ Boolean *cont)
+{
+ XPropertyEvent *event = (XPropertyEvent *) ev;
+ Request req = (Request)closure;
+ Select ctx = req->ctx;
+
+ if ((event->type != PropertyNotify) ||
+ (event->state != PropertyDelete) ||
+ (event->atom != req->property) ||
+ (event->window != req->requestor))
+ return;
+#ifndef DEBUG_WO_TIMERS
+ XtRemoveTimeOut(req->timeout);
+#endif
+ if (req->allSent) {
+ if (ctx->notify) {
+ if (ctx->incremental) {
+ (*(XtSelectionDoneIncrProc)ctx->notify)
+ (ctx->widget, &ctx->selection, &req->target,
+ (XtRequestId*)&req, ctx->owner_closure);
+ }
+ else (*ctx->notify)(ctx->widget, &ctx->selection, &req->target);
+ }
+ RemoveHandler(req, (EventMask)PropertyChangeMask,
+ HandlePropertyGone, closure);
+ XtFree((char*)req);
+ if (--ctx->ref_count == 0 && ctx->free_when_done)
+ XtFree((char*)ctx);
+ } else { /* is this part of an incremental transfer? */
+ if (ctx->incremental) {
+ if (req->bytelength == 0)
+ AllSent(req);
+ else {
+ unsigned long size = MAX_SELECTION_INCR(ctx->dpy);
+ SendIncrement(req);
+ (*(XtConvertSelectionIncrProc)ctx->convert)
+ (ctx->widget, &ctx->selection, &req->target,
+ &req->type, &req->value,
+ &req->bytelength, &req->format,
+ &size, ctx->owner_closure, (XtPointer*)&req);
+ if (req->bytelength)
+ req->bytelength = BYTELENGTH(req->bytelength, req->format);
+ req->offset = 0;
+ }
+ } else {
+ if (req->offset < req->bytelength)
+ SendIncrement(req);
+ else AllSent(req);
+ }
+#ifndef DEBUG_WO_TIMERS
+ {
+ XtAppContext app = XtWidgetToApplicationContext(req->widget);
+ req->timeout = XtAppAddTimeOut(app,
+ app->selectionTimeout, OwnerTimedOut, (XtPointer)req);
+ }
+#endif
+ }
+}
+
+static void PrepareIncremental(
+ Request req,
+ Widget widget,
+ Window window,
+ Atom property,
+ Atom target,
+ Atom targetType,
+ XtPointer value,
+ unsigned long length,
+ int format)
+{
+ req->type = targetType;
+ req->value = value;
+ req->bytelength = BYTELENGTH(length,format);
+ req->format = format;
+ req->offset = 0;
+ req->target = target;
+ req->widget = widget;
+ req->allSent = FALSE;
+#ifndef DEBUG_WO_TIMERS
+ {
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+ req->timeout = XtAppAddTimeOut(app,
+ app->selectionTimeout, OwnerTimedOut, (XtPointer)req);
+ }
+#endif
+ AddHandler(req, (EventMask)PropertyChangeMask,
+ HandlePropertyGone, (XtPointer)req);
+/* now send client INCR property */
+ XChangeProperty(req->ctx->dpy, window, req->property,
+ req->ctx->prop_list->incr_atom,
+ 32, PropModeReplace,
+ (unsigned char *)&req->bytelength, 1);
+}
+
+static Boolean GetConversion(
+ Select ctx, /* logical owner */
+ XSelectionRequestEvent* event,
+ Atom target,
+ Atom property, /* requestor's property */
+ Widget widget) /* physical owner (receives events) */
+{
+ XtPointer value = NULL;
+ unsigned long length;
+ int format;
+ Atom targetType;
+ Request req = XtNew(RequestRec);
+ Boolean timestamp_target = (target == ctx->prop_list->timestamp_atom);
+
+ req->ctx = ctx;
+ req->event = *event;
+ req->property = property;
+ req->requestor = event->requestor;
+
+ if (timestamp_target) {
+ value = __XtMalloc(sizeof(long));
+ *(long*)value = ctx->time;
+ targetType = XA_INTEGER;
+ length = 1;
+ format = 32;
+ }
+ else {
+ ctx->ref_count++;
+ if (ctx->incremental == TRUE) {
+ unsigned long size = MAX_SELECTION_INCR(ctx->dpy);
+ if ((*(XtConvertSelectionIncrProc)ctx->convert)
+ (ctx->widget, &event->selection, &target,
+ &targetType, &value, &length, &format,
+ &size, ctx->owner_closure, (XtRequestId*)&req)
+ == FALSE) {
+ XtFree((char*)req);
+ ctx->ref_count--;
+ return(FALSE);
+ }
+ StartProtectedSection(ctx->dpy, event->requestor);
+ PrepareIncremental(req, widget, event->requestor, property,
+ target, targetType, value, length, format);
+ return(TRUE);
+ }
+ ctx->req = req;
+ if ((*ctx->convert)(ctx->widget, &event->selection, &target,
+ &targetType, &value, &length, &format) == FALSE) {
+ XtFree((char*)req);
+ ctx->req = NULL;
+ ctx->ref_count--;
+ return(FALSE);
+ }
+ ctx->req = NULL;
+ }
+ StartProtectedSection(ctx->dpy, event->requestor);
+ if (BYTELENGTH(length,format) <= (unsigned long) MAX_SELECTION_INCR(ctx->dpy)) {
+ if (! timestamp_target) {
+ if (ctx->notify != NULL) {
+ req->target = target;
+ req->widget = widget;
+ req->allSent = TRUE;
+#ifndef DEBUG_WO_TIMERS
+ {
+ XtAppContext app = XtWidgetToApplicationContext(req->widget);
+ req->timeout = XtAppAddTimeOut(app,
+ app->selectionTimeout, OwnerTimedOut, (XtPointer)req);
+ }
+#endif
+ AddHandler(req, (EventMask)PropertyChangeMask,
+ HandlePropertyGone, (XtPointer)req);
+ }
+ else ctx->ref_count--;
+ }
+ XChangeProperty(ctx->dpy, event->requestor, property,
+ targetType, format, PropModeReplace,
+ (unsigned char *)value, (int)length);
+ /* free storage for client if no notify proc */
+ if (timestamp_target || ctx->notify == NULL) {
+ XtFree((char*)value);
+ XtFree((char*)req);
+ }
+ } else {
+ PrepareIncremental(req, widget, event->requestor, property,
+ target, targetType, value, length, format);
+ }
+ return(TRUE);
+}
+
+/*ARGSUSED*/
+static void HandleSelectionEvents(
+ Widget widget,
+ XtPointer closure,
+ XEvent *event,
+ Boolean *cont)
+{
+ Select ctx;
+ XSelectionEvent ev;
+ Atom target;
+ int count;
+ Boolean writeback = FALSE;
+
+ ctx = (Select) closure;
+ switch (event->type) {
+ case SelectionClear:
+ /* if this event is not for the selection we registered for,
+ * don't do anything */
+ if (ctx->selection != event->xselectionclear.selection ||
+ ctx->serial > event->xselectionclear.serial)
+ break;
+ (void) LoseSelection(ctx, widget, event->xselectionclear.selection,
+ event->xselectionclear.time);
+ break;
+ case SelectionRequest:
+ /* if this event is not for the selection we registered for,
+ * don't do anything */
+ if (ctx->selection != event->xselectionrequest.selection)
+ break;
+ ev.type = SelectionNotify;
+ ev.display = event->xselectionrequest.display;
+ ev.requestor = event->xselectionrequest.requestor;
+ ev.selection = event->xselectionrequest.selection;
+ ev.time = event->xselectionrequest.time;
+ ev.target = event->xselectionrequest.target;
+ if (event->xselectionrequest.property == None) /* obsolete requestor */
+ event->xselectionrequest.property = event->xselectionrequest.target;
+ if (ctx->widget != widget || ctx->was_disowned
+ || ((event->xselectionrequest.time != CurrentTime)
+ && (event->xselectionrequest.time < ctx->time)))
+ ev.property = None;
+ else {
+ if (ev.target == ctx->prop_list->indirect_atom) {
+ IndirectPair *p;
+ int format;
+ unsigned long bytesafter, length;
+ unsigned char *value;
+ ev.property = event->xselectionrequest.property;
+ StartProtectedSection(ev.display, ev.requestor);
+ (void) XGetWindowProperty(ev.display, ev.requestor,
+ event->xselectionrequest.property, 0L, 1000000,
+ False,(Atom)AnyPropertyType, &target, &format, &length,
+ &bytesafter, &value);
+ count = BYTELENGTH(length, format) / sizeof(IndirectPair);
+ for (p = (IndirectPair *)value; count; p++, count--) {
+ EndProtectedSection(ctx->dpy);
+ if (!GetConversion(ctx, (XSelectionRequestEvent*)event,
+ p->target, p->property, widget)) {
+
+ p->target = None;
+ writeback = TRUE;
+ StartProtectedSection(ctx->dpy, ev.requestor);
+ }
+ }
+ if (writeback)
+ XChangeProperty(ev.display, ev.requestor,
+ event->xselectionrequest.property, target,
+ format, PropModeReplace, value, (int)length);
+ XFree((char *)value);
+ } else /* not multiple */ {
+ if (GetConversion(ctx, (XSelectionRequestEvent*)event,
+ event->xselectionrequest.target,
+ event->xselectionrequest.property,
+ widget))
+ ev.property = event->xselectionrequest.property;
+ else {
+ ev.property = None;
+ StartProtectedSection(ctx->dpy, ev.requestor);
+ }
+ }
+ }
+ (void) XSendEvent(ctx->dpy, ev.requestor, False, (unsigned long)NULL,
+ (XEvent *) &ev);
+
+ EndProtectedSection(ctx->dpy);
+
+ break;
+ }
+}
+
+static Boolean OwnSelection(
+ Widget widget,
+ Atom selection,
+ Time time,
+ XtConvertSelectionProc convert,
+ XtLoseSelectionProc lose,
+ XtSelectionDoneProc notify,
+ XtCancelConvertSelectionProc cancel,
+ XtPointer closure,
+ Boolean incremental)
+{
+ Select ctx;
+ Select oldctx = NULL;
+
+ if (!XtIsRealized(widget)) return False;
+
+ ctx = FindCtx(XtDisplay(widget), selection);
+ if (ctx->widget != widget || ctx->time != time ||
+ ctx->ref_count || ctx->was_disowned)
+ {
+ Boolean replacement = FALSE;
+ Window window = XtWindow(widget);
+ unsigned long serial = XNextRequest(ctx->dpy);
+ XSetSelectionOwner(ctx->dpy, selection, window, time);
+ if (XGetSelectionOwner(ctx->dpy, selection) != window)
+ return FALSE;
+ if (ctx->ref_count) { /* exchange is in-progress */
+#ifdef DEBUG_ACTIVE
+ printf( "Active exchange for widget \"%s\"; selection=0x%lx, ref_count=%d\n",
+ XtName(widget), (long)selection, ctx->ref_count );
+#endif
+ if (ctx->widget != widget ||
+ ctx->convert != convert ||
+ ctx->loses != lose ||
+ ctx->notify != notify ||
+ ctx->owner_cancel != cancel ||
+ ctx->incremental != incremental ||
+ ctx->owner_closure != closure)
+ {
+ if (ctx->widget == widget) {
+ XtRemoveEventHandler(widget, (EventMask)0, TRUE,
+ HandleSelectionEvents, (XtPointer)ctx);
+ XtRemoveCallback(widget, XtNdestroyCallback,
+ WidgetDestroyed, (XtPointer)ctx);
+ replacement = TRUE;
+ }
+ else if (!ctx->was_disowned) {
+ oldctx = ctx;
+ }
+ ctx->free_when_done = TRUE;
+ ctx = NewContext(XtDisplay(widget), selection);
+ }
+ else if (!ctx->was_disowned) { /* current owner is new owner */
+ ctx->time = time;
+ return TRUE;
+ }
+ }
+ if (ctx->widget != widget || ctx->was_disowned || replacement) {
+ if (ctx->widget && !ctx->was_disowned && !replacement) {
+ oldctx = ctx;
+ oldctx->free_when_done = TRUE;
+ ctx = NewContext(XtDisplay(widget), selection);
+ }
+ XtAddEventHandler(widget, (EventMask)0, TRUE,
+ HandleSelectionEvents, (XtPointer)ctx);
+ XtAddCallback(widget, XtNdestroyCallback,
+ WidgetDestroyed, (XtPointer)ctx);
+ }
+ ctx->widget = widget; /* Selection offically changes hands. */
+ ctx->time = time;
+ ctx->serial = serial;
+ }
+ ctx->convert = convert;
+ ctx->loses = lose;
+ ctx->notify = notify;
+ ctx->owner_cancel = cancel;
+ ctx->incremental = incremental;
+ ctx->owner_closure = closure;
+ ctx->was_disowned = FALSE;
+
+ /* Defer calling the previous selection owner's lose selection procedure
+ * until the new selection is established, to allow the previous
+ * selection owner to ask for the new selection to be converted in
+ * the lose selection procedure. The context pointer is the closure
+ * of the event handler and the destroy callback, so the old context
+ * pointer and the record contents must be preserved for LoseSelection.
+ */
+ if (oldctx) {
+ (void) LoseSelection(oldctx, oldctx->widget, selection, oldctx->time);
+ if (!oldctx->ref_count && oldctx->free_when_done)
+ XtFree((char*)oldctx);
+ }
+ return TRUE;
+}
+
+
+Boolean XtOwnSelection(
+ Widget widget,
+ Atom selection,
+ Time time,
+ XtConvertSelectionProc convert,
+ XtLoseSelectionProc lose,
+ XtSelectionDoneProc notify)
+{
+ Boolean retval;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ retval = OwnSelection(widget, selection, time, convert, lose, notify,
+ (XtCancelConvertSelectionProc)NULL,
+ (XtPointer)NULL, FALSE);
+ UNLOCK_APP(app);
+ return retval;
+}
+
+
+Boolean XtOwnSelectionIncremental(
+ Widget widget,
+ Atom selection,
+ Time time,
+ XtConvertSelectionIncrProc convert,
+ XtLoseSelectionIncrProc lose,
+ XtSelectionDoneIncrProc notify,
+ XtCancelConvertSelectionProc cancel,
+ XtPointer closure)
+{
+ Boolean retval;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ retval = OwnSelection(widget, selection, time,
+ (XtConvertSelectionProc)convert,
+ (XtLoseSelectionProc)lose,
+ (XtSelectionDoneProc)notify,
+ cancel, closure, TRUE);
+ UNLOCK_APP(app);
+ return retval;
+}
+
+
+void XtDisownSelection(widget, selection, time)
+ Widget widget;
+ Atom selection;
+ Time time;
+{
+ Select ctx;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ ctx = FindCtx(XtDisplay(widget), selection);
+ if (LoseSelection(ctx, widget, selection, time))
+ XSetSelectionOwner(XtDisplay(widget), selection, None, time);
+ UNLOCK_APP(app);
+}
+
+/* Selection Requestor code */
+
+static Boolean IsINCRtype(
+ CallBackInfo info,
+ Window window,
+ Atom prop)
+{
+ unsigned long bytesafter;
+ unsigned long length;
+ int format;
+ Atom type;
+ unsigned char *value;
+
+ if (prop == None) return False;
+
+ (void)XGetWindowProperty(XtDisplay(info->widget), window, prop, 0L, 0L,
+ False, info->ctx->prop_list->incr_atom,
+ &type, &format, &length, &bytesafter, &value);
+
+ return (type == info->ctx->prop_list->incr_atom);
+}
+
+/*ARGSUSED*/
+static void ReqCleanup(
+ Widget widget,
+ XtPointer closure,
+ XEvent *ev,
+ Boolean *cont)
+{
+ CallBackInfo info = (CallBackInfo)closure;
+ unsigned long bytesafter, length;
+ char *value;
+ int format;
+ Atom target;
+
+ if (ev->type == SelectionNotify) {
+ XSelectionEvent *event = (XSelectionEvent *) ev;
+ if (!MATCH_SELECT(event, info)) return; /* not really for us */
+ XtRemoveEventHandler(widget, (EventMask)0, TRUE,
+ ReqCleanup, (XtPointer) info );
+ if (IsINCRtype(info, XtWindow(widget), event->property)) {
+ info->proc = HandleGetIncrement;
+ XtAddEventHandler(info->widget, (EventMask) PropertyChangeMask,
+ FALSE, ReqCleanup, (XtPointer) info);
+ } else {
+ if (event->property != None)
+ XDeleteProperty(event->display, XtWindow(widget),
+ event->property);
+ FreeSelectionProperty(XtDisplay(widget), info->property);
+ FreeInfo(info);
+ }
+ } else if ((ev->type == PropertyNotify) &&
+ (ev->xproperty.state == PropertyNewValue) &&
+ (ev->xproperty.atom == info->property)) {
+ XPropertyEvent *event = (XPropertyEvent *) ev;
+ (void) XGetWindowProperty(event->display, XtWindow(widget),
+ event->atom, 0L, 1000000, True, AnyPropertyType,
+ &target, &format, &length, &bytesafter,
+ (unsigned char **) &value);
+ XFree(value);
+ if (length == 0) {
+ XtRemoveEventHandler(widget, (EventMask) PropertyChangeMask, FALSE,
+ ReqCleanup, (XtPointer) info );
+ FreeSelectionProperty(XtDisplay(widget), info->property);
+ XtFree(info->value); /* requestor never got this, so free now */
+ FreeInfo(info);
+ }
+ }
+}
+
+/* ARGSUSED */
+static void ReqTimedOut(
+ XtPointer closure,
+ XtIntervalId *id)
+{
+ XtPointer value = NULL;
+ unsigned long length = 0;
+ int format = 8;
+ Atom resulttype = XT_CONVERT_FAIL;
+ CallBackInfo info = (CallBackInfo)closure;
+ unsigned long bytesafter;
+ unsigned long proplength;
+ Atom type;
+ IndirectPair *pairs;
+ XtPointer *c;
+ int i;
+
+ if (*info->target == info->ctx->prop_list->indirect_atom) {
+ (void) XGetWindowProperty(XtDisplay(info->widget),
+ XtWindow(info->widget), info->property, 0L,
+ 10000000, True, AnyPropertyType, &type, &format,
+ &proplength, &bytesafter, (unsigned char **) &pairs);
+ XFree((char*)pairs);
+ for (proplength = proplength / IndirectPairWordSize, i = 0, c = info->req_closure;
+ proplength; proplength--, c++, i++)
+ (*info->callbacks[i])(info->widget, *c,
+ &info->ctx->selection, &resulttype, value, &length, &format);
+ } else {
+ (*info->callbacks[0])(info->widget, *info->req_closure,
+ &info->ctx->selection, &resulttype, value, &length, &format);
+ }
+
+ /* change event handlers for straggler events */
+ if (info->proc == (XtEventHandler)HandleSelectionReplies) {
+ XtRemoveEventHandler(info->widget, (EventMask)0,
+ TRUE, info->proc, (XtPointer) info);
+ XtAddEventHandler(info->widget, (EventMask)0, TRUE,
+ ReqCleanup, (XtPointer) info);
+ } else {
+ XtRemoveEventHandler(info->widget,(EventMask) PropertyChangeMask,
+ FALSE, info->proc, (XtPointer) info);
+ XtAddEventHandler(info->widget, (EventMask) PropertyChangeMask,
+ FALSE, ReqCleanup, (XtPointer) info);
+ }
+
+}
+
+/*ARGSUSED*/
+static void HandleGetIncrement(
+ Widget widget,
+ XtPointer closure,
+ XEvent *ev,
+ Boolean *cont)
+{
+ XPropertyEvent *event = (XPropertyEvent *) ev;
+ CallBackInfo info = (CallBackInfo) closure;
+ Select ctx = info->ctx;
+ char *value;
+ unsigned long bytesafter;
+ unsigned long length;
+ int bad;
+ int n = info->current;
+
+ if ((event->state != PropertyNewValue) || (event->atom != info->property))
+ return;
+
+ bad = XGetWindowProperty(event->display, XtWindow(widget),
+ event->atom, 0L,
+ 10000000, True, AnyPropertyType, &info->type,
+ &info->format, &length, &bytesafter,
+ (unsigned char **) &value);
+ if (bad)
+ return;
+#ifndef DEBUG_WO_TIMERS
+ XtRemoveTimeOut(info->timeout);
+#endif
+ if (length == 0) {
+ unsigned long u_offset = NUMELEM(info->offset, info->format);
+ (*info->callbacks[n])(widget, *info->req_closure, &ctx->selection,
+ &info->type,
+ (info->offset == 0 ? value : info->value),
+ &u_offset, &info->format);
+ /* assert ((info->offset != 0) == (info->incremental[n]) */
+ if (info->offset != 0) XFree(value);
+ XtRemoveEventHandler(widget, (EventMask) PropertyChangeMask, FALSE,
+ HandleGetIncrement, (XtPointer) info);
+ FreeSelectionProperty(event->display, info->property);
+ FreeInfo(info);
+ } else { /* add increment to collection */
+ if (info->incremental[n]) {
+#ifdef XT_COPY_SELECTION
+ int size = BYTELENGTH(length, info->format) + 1;
+ char *tmp = __XtMalloc((Cardinal) size);
+ (void) memmove(tmp, value, size);
+ XFree(value);
+ value = tmp;
+#endif
+ (*info->callbacks[n])(widget, *info->req_closure, &ctx->selection,
+ &info->type, value, &length, &info->format);
+ } else {
+ int size = BYTELENGTH(length, info->format);
+ if (info->offset + size > info->bytelength) {
+ /* allocate enough for this and the next increment */
+ info->bytelength = info->offset + size * 2;
+ info->value = XtRealloc(info->value,
+ (Cardinal) info->bytelength);
+ }
+ (void) memmove(&info->value[info->offset], value, size);
+ info->offset += size;
+ XFree(value);
+ }
+ /* reset timer */
+#ifndef DEBUG_WO_TIMERS
+ {
+ XtAppContext app = XtWidgetToApplicationContext(info->widget);
+ info->timeout = XtAppAddTimeOut(app,
+ app->selectionTimeout, ReqTimedOut, (XtPointer) info);
+ }
+#endif
+ }
+}
+
+
+static void HandleNone(
+ Widget widget,
+ XtSelectionCallbackProc callback,
+ XtPointer closure,
+ Atom selection)
+{
+ unsigned long length = 0;
+ int format = 8;
+ Atom type = None;
+
+ (*callback)(widget, closure, &selection,
+ &type, NULL, &length, &format);
+}
+
+
+static long IncrPropSize(
+ Widget widget,
+ unsigned char* value,
+ int format,
+ unsigned long length)
+{
+ unsigned long size;
+ if (format == 32) {
+ size = ((long*)value)[length-1]; /* %%% what order for longs? */
+ return size;
+ }
+ else {
+ XtAppWarningMsg( XtWidgetToApplicationContext(widget),
+ "badFormat","xtGetSelectionValue",XtCXtToolkitError,
+ "Selection owner returned type INCR property with format != 32",
+ (String*)NULL, (Cardinal*)NULL );
+ return 0;
+ }
+}
+
+
+static
+Boolean HandleNormal(
+ Display *dpy,
+ Widget widget,
+ Atom property,
+ CallBackInfo info,
+ XtPointer closure,
+ Atom selection)
+{
+ unsigned long bytesafter;
+ unsigned long length;
+ int format;
+ Atom type;
+ unsigned char *value;
+ int number = info->current;
+
+ (void) XGetWindowProperty(dpy, XtWindow(widget), property, 0L,
+ 10000000, False, AnyPropertyType,
+ &type, &format, &length, &bytesafter, &value);
+
+ if (type == info->ctx->prop_list->incr_atom) {
+ unsigned long size = IncrPropSize(widget, value, format, length);
+ XFree((char *)value);
+ if (info->property != property) {
+ /* within MULTIPLE */
+ CallBackInfo ninfo;
+ ninfo = MakeInfo(info->ctx, &info->callbacks[number],
+ &info->req_closure[number], 1, widget,
+ info->time, &info->incremental[number], &property);
+ ninfo->target = (Atom *) __XtMalloc((unsigned) sizeof(Atom));
+ *ninfo->target = info->target[number + 1];
+ info = ninfo;
+ }
+ HandleIncremental(dpy, widget, property, info, size);
+ return FALSE;
+ }
+
+ XDeleteProperty(dpy, XtWindow(widget), property);
+#ifdef XT_COPY_SELECTION
+ if (value) { /* it could have been deleted after the SelectionNotify */
+ int size = BYTELENGTH(length, info->format) + 1;
+ char *tmp = __XtMalloc((Cardinal) size);
+ (void) memmove(tmp, value, size);
+ XFree(value);
+ value = (unsigned char *) tmp;
+ }
+#endif
+ (*info->callbacks[number])(widget, closure, &selection,
+ &type, (XtPointer)value, &length, &format);
+
+ if (info->incremental[number]) {
+ /* let requestor know the whole thing has been received */
+ value = (unsigned char*)__XtMalloc((unsigned)1);
+ length = 0;
+ (*info->callbacks[number])(widget, closure, &selection,
+ &type, (XtPointer)value, &length, &format);
+ }
+ return TRUE;
+}
+
+static void HandleIncremental(
+ Display *dpy,
+ Widget widget,
+ Atom property,
+ CallBackInfo info,
+ unsigned long size)
+{
+ XtAddEventHandler(widget, (EventMask) PropertyChangeMask, FALSE,
+ HandleGetIncrement, (XtPointer) info);
+
+ /* now start the transfer */
+ XDeleteProperty(dpy, XtWindow(widget), property);
+ XFlush(dpy);
+
+ info->bytelength = size;
+ if (info->incremental[info->current]) /* requestor wants incremental too */
+ info->value = NULL; /* so no need for buffer to assemble value */
+ else
+ info->value = (char *) __XtMalloc((unsigned) info->bytelength);
+ info->offset = 0;
+
+ /* reset the timer */
+ info->proc = HandleGetIncrement;
+#ifndef DEBUG_WO_TIMERS
+ {
+ XtAppContext app = XtWidgetToApplicationContext(info->widget);
+ info->timeout = XtAppAddTimeOut(app,
+ app->selectionTimeout, ReqTimedOut, (XtPointer) info);
+ }
+#endif
+}
+
+/*ARGSUSED*/
+static void HandleSelectionReplies(
+ Widget widget,
+ XtPointer closure,
+ XEvent *ev,
+ Boolean *cont)
+{
+ XSelectionEvent *event = (XSelectionEvent *) ev;
+ Display *dpy = event->display;
+ CallBackInfo info = (CallBackInfo) closure;
+ Select ctx = info->ctx;
+ IndirectPair *pairs, *p;
+ unsigned long bytesafter;
+ unsigned long length;
+ int format;
+ Atom type;
+ XtPointer *c;
+
+ if (event->type != SelectionNotify) return;
+ if (!MATCH_SELECT(event, info)) return; /* not really for us */
+#ifndef DEBUG_WO_TIMERS
+ XtRemoveTimeOut(info->timeout);
+#endif
+ XtRemoveEventHandler(widget, (EventMask)0, TRUE,
+ HandleSelectionReplies, (XtPointer) info );
+ if (event->target == ctx->prop_list->indirect_atom) {
+ (void) XGetWindowProperty(dpy, XtWindow(widget), info->property, 0L,
+ 10000000, True, AnyPropertyType, &type, &format,
+ &length, &bytesafter, (unsigned char **) &pairs);
+ for (length = length / IndirectPairWordSize, p = pairs,
+ c = info->req_closure;
+ length; length--, p++, c++, info->current++) {
+ if (event->property == None || format != 32 || p->target == None
+ || /* bug compatibility */ p->property == None) {
+ HandleNone(widget, info->callbacks[info->current],
+ *c, event->selection);
+ if (p->property != None)
+ FreeSelectionProperty(XtDisplay(widget), p->property);
+ } else {
+ if (HandleNormal(dpy, widget, p->property, info, *c,
+ event->selection)) {
+ FreeSelectionProperty(XtDisplay(widget), p->property);
+ }
+ }
+ }
+ XFree((char*)pairs);
+ FreeSelectionProperty(dpy, info->property);
+ FreeInfo(info);
+ } else if (event->property == None) {
+ HandleNone(widget, info->callbacks[0], *info->req_closure, event->selection);
+ FreeSelectionProperty(XtDisplay(widget), info->property);
+ FreeInfo(info);
+ } else {
+ if (HandleNormal(dpy, widget, event->property, info,
+ *info->req_closure, event->selection)) {
+ FreeSelectionProperty(XtDisplay(widget), info->property);
+ FreeInfo(info);
+ }
+ }
+}
+
+static void DoLocalTransfer(
+ Request req,
+ Atom selection,
+ Atom target,
+ Widget widget, /* The widget requesting the value. */
+ XtSelectionCallbackProc callback,
+ XtPointer closure, /* the closure for the callback, not the conversion */
+ Boolean incremental,
+ Atom property)
+{
+ Select ctx = req->ctx;
+ XtPointer value = NULL, temp, total = NULL;
+ unsigned long length;
+ int format;
+ Atom resulttype;
+ unsigned long totallength = 0;
+
+ req->event.type = 0;
+ req->event.target = target;
+ req->event.property = req->property = property;
+ req->event.requestor = req->requestor = XtWindow(widget);
+
+ if (ctx->incremental) {
+ unsigned long size = MAX_SELECTION_INCR(ctx->dpy);
+ if (!(*(XtConvertSelectionIncrProc)ctx->convert)
+ (ctx->widget, &selection, &target,
+ &resulttype, &value, &length, &format,
+ &size, ctx->owner_closure, (XtRequestId*)&req)) {
+ HandleNone(widget, callback, closure, selection);
+ }
+ else {
+ if (incremental) {
+ Boolean allSent = FALSE;
+ while (!allSent) {
+ if (ctx->notify && (value != NULL)) {
+ int bytelength = BYTELENGTH(length,format);
+ /* both sides think they own this storage */
+ temp = __XtMalloc((unsigned)bytelength);
+ (void) memmove(temp, value, bytelength);
+ value = temp;
+ }
+ /* use care; older clients were never warned that
+ * they must return a value even if length==0
+ */
+ if (value == NULL) value = __XtMalloc((unsigned)1);
+ (*callback)(widget, closure, &selection,
+ &resulttype, value, &length, &format);
+ if (length) {
+ /* should owner be notified on end-of-piece?
+ * Spec is unclear, but non-local transfers don't.
+ */
+ (*(XtConvertSelectionIncrProc)ctx->convert)
+ (ctx->widget, &selection, &target,
+ &resulttype, &value, &length, &format,
+ &size, ctx->owner_closure,
+ (XtRequestId*)&req);
+ }
+ else allSent = TRUE;
+ }
+ } else {
+ while (length) {
+ int bytelength = BYTELENGTH(length, format);
+ total = XtRealloc(total,
+ (unsigned) (totallength += bytelength));
+ (void) memmove((char*)total + totallength - bytelength,
+ value,
+ bytelength);
+ (*(XtConvertSelectionIncrProc)ctx->convert)
+ (ctx->widget, &selection, &target,
+ &resulttype, &value, &length, &format,
+ &size, ctx->owner_closure, (XtRequestId*)&req);
+ }
+ if (total == NULL) total = __XtMalloc(1);
+ totallength = NUMELEM(totallength, format);
+ (*callback)(widget, closure, &selection, &resulttype,
+ total, &totallength, &format);
+ }
+ if (ctx->notify)
+ (*(XtSelectionDoneIncrProc)ctx->notify)
+ (ctx->widget, &selection, &target,
+ (XtRequestId*)&req, ctx->owner_closure);
+ else XtFree((char*)value);
+ }
+ } else { /* not incremental owner */
+ if (!(*ctx->convert)(ctx->widget, &selection, &target,
+ &resulttype, &value, &length, &format)) {
+ HandleNone(widget, callback, closure, selection);
+ } else {
+ if (ctx->notify && (value != NULL)) {
+ int bytelength = BYTELENGTH(length,format);
+ /* both sides think they own this storage; better copy */
+ temp = __XtMalloc((unsigned)bytelength);
+ (void) memmove(temp, value, bytelength);
+ value = temp;
+ }
+ if (value == NULL) value = __XtMalloc((unsigned)1);
+ (*callback)(widget, closure, &selection, &resulttype,
+ value, &length, &format);
+ if (ctx->notify)
+ (*ctx->notify)(ctx->widget, &selection, &target);
+ }
+ }
+}
+
+static void GetSelectionValue(
+ Widget widget,
+ Atom selection,
+ Atom target,
+ XtSelectionCallbackProc callback,
+ XtPointer closure,
+ Time time,
+ Boolean incremental,
+ Atom property)
+{
+ Select ctx;
+ CallBackInfo info;
+ Atom properties[1];
+
+ properties[0] = property;
+
+ ctx = FindCtx(XtDisplay(widget), selection);
+ if (ctx->widget && !ctx->was_disowned) {
+ RequestRec req;
+ ctx->req = &req;
+ req.ctx = ctx;
+ req.event.time = time;
+ ctx->ref_count++;
+ DoLocalTransfer(&req, selection, target, widget,
+ callback, closure, incremental, property);
+ if (--ctx->ref_count == 0 && ctx->free_when_done)
+ XtFree((char*)ctx);
+ else
+ ctx->req = NULL;
+ }
+ else {
+ info = MakeInfo(ctx, &callback, &closure, 1, widget,
+ time, &incremental, properties);
+ info->target = (Atom *)__XtMalloc((unsigned) sizeof(Atom));
+ *(info->target) = target;
+ RequestSelectionValue(info, selection, target);
+ }
+}
+
+
+void XtGetSelectionValue(
+ Widget widget,
+ Atom selection,
+ Atom target,
+ XtSelectionCallbackProc callback,
+ XtPointer closure,
+ Time time)
+{
+ Atom property;
+ Boolean incr = False;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ property = GetParamInfo(widget, selection);
+ RemoveParamInfo(widget, selection);
+
+ if (IsGatheringRequest(widget, selection)) {
+ AddSelectionRequests(widget, selection, 1, &target, &callback, 1,
+ &closure, &incr, &property);
+ } else {
+ GetSelectionValue(widget, selection, target, callback,
+ closure, time, FALSE, property);
+ }
+ UNLOCK_APP(app);
+}
+
+
+void XtGetSelectionValueIncremental(
+ Widget widget,
+ Atom selection,
+ Atom target,
+ XtSelectionCallbackProc callback,
+ XtPointer closure,
+ Time time)
+{
+ Atom property;
+ Boolean incr = TRUE;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ property = GetParamInfo(widget, selection);
+ RemoveParamInfo(widget, selection);
+
+ if (IsGatheringRequest(widget, selection)) {
+ AddSelectionRequests(widget, selection, 1, &target, &callback, 1,
+ &closure, &incr, &property);
+ } else {
+ GetSelectionValue(widget, selection, target, callback,
+ closure, time, TRUE, property);
+ }
+
+ UNLOCK_APP(app);
+}
+
+
+static void GetSelectionValues(
+ Widget widget,
+ Atom selection,
+ Atom *targets,
+ int count,
+ XtSelectionCallbackProc *callbacks,
+ int num_callbacks,
+ XtPointer *closures,
+ Time time,
+ Boolean *incremental,
+ Atom *properties)
+{
+ Select ctx;
+ CallBackInfo info;
+ IndirectPair *pairs, *p;
+ Atom *t;
+
+ if (count == 0) return;
+ ctx = FindCtx(XtDisplay(widget), selection);
+ if (ctx->widget && !ctx->was_disowned) {
+ int j, i;
+ RequestRec req;
+ ctx->req = &req;
+ req.ctx = ctx;
+ req.event.time = time;
+ ctx->ref_count++;
+ for (i = 0, j = 0; count; count--, i++, j++ ) {
+ if (j >= num_callbacks) j = 0;
+
+ DoLocalTransfer(&req, selection, targets[i], widget,
+ callbacks[j], closures[i], incremental[i],
+ properties ? properties[i] : None);
+
+ }
+ if (--ctx->ref_count == 0 && ctx->free_when_done)
+ XtFree((char*)ctx);
+ else
+ ctx->req = NULL;
+ } else {
+ XtSelectionCallbackProc *passed_callbacks;
+ XtSelectionCallbackProc stack_cbs[32];
+ int i = 0, j = 0;
+
+ passed_callbacks = (XtSelectionCallbackProc *)
+ XtStackAlloc(sizeof(XtSelectionCallbackProc) * count, stack_cbs);
+
+ /* To deal with the old calls from XtGetSelectionValues* we
+ will repeat however many callbacks have been passed into
+ the array */
+ for(i = 0; i < count; i++) {
+ if (j >= num_callbacks) j = 0;
+ passed_callbacks[i] = callbacks[j];
+ j++;
+ }
+ info = MakeInfo(ctx, passed_callbacks, closures, count, widget,
+ time, incremental, properties);
+ XtStackFree((XtPointer) passed_callbacks, stack_cbs);
+
+ info->target = (Atom *)__XtMalloc((unsigned) ((count+1) * sizeof(Atom)));
+ (*info->target) = ctx->prop_list->indirect_atom;
+ (void) memmove((char *) info->target+sizeof(Atom), (char *) targets,
+ count * sizeof(Atom));
+ pairs = (IndirectPair*)__XtMalloc((unsigned)(count*sizeof(IndirectPair)));
+ for (p = &pairs[count-1], t = &targets[count-1], i = count - 1;
+ p >= pairs; p--, t--, i--) {
+ p->target = *t;
+ if (properties == NULL || properties[i] == None) {
+ p->property = GetSelectionProperty(XtDisplay(widget));
+ XDeleteProperty(XtDisplay(widget), XtWindow(widget),
+ p->property);
+ } else {
+ p->property = properties[i];
+ }
+ }
+ XChangeProperty(XtDisplay(widget), XtWindow(widget),
+ info->property, info->property,
+ 32, PropModeReplace, (unsigned char *) pairs,
+ count * IndirectPairWordSize);
+ XtFree((char*)pairs);
+ RequestSelectionValue(info, selection, ctx->prop_list->indirect_atom);
+ }
+}
+
+
+void XtGetSelectionValues(
+ Widget widget,
+ Atom selection,
+ Atom *targets,
+ int count,
+ XtSelectionCallbackProc callback,
+ XtPointer *closures,
+ Time time)
+{
+ Boolean incremental_values[32];
+ Boolean *incremental;
+ int i;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ incremental = XtStackAlloc(count * sizeof(Boolean), incremental_values);
+ for(i = 0; i < count; i++) incremental[i] = FALSE;
+ if (IsGatheringRequest(widget, selection)) {
+ AddSelectionRequests(widget, selection, count, targets, &callback,
+ 1, closures, incremental, NULL);
+ } else {
+ GetSelectionValues(widget, selection, targets, count, &callback, 1,
+ closures, time, incremental, NULL);
+ }
+ XtStackFree((XtPointer) incremental, incremental_values);
+ UNLOCK_APP(app);
+}
+
+
+void XtGetSelectionValuesIncremental(
+ Widget widget,
+ Atom selection,
+ Atom *targets,
+ int count,
+ XtSelectionCallbackProc callback,
+ XtPointer *closures,
+ Time time)
+{
+ Boolean incremental_values[32];
+ Boolean *incremental;
+ int i;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ incremental = XtStackAlloc(count * sizeof(Boolean), incremental_values);
+ for(i = 0; i < count; i++) incremental[i] = TRUE;
+ if (IsGatheringRequest(widget, selection)) {
+ AddSelectionRequests(widget, selection, count, targets, &callback,
+ 1, closures, incremental, NULL);
+ } else {
+ GetSelectionValues(widget, selection, targets, count,
+ &callback, 1, closures, time, incremental, NULL);
+ }
+ XtStackFree((XtPointer) incremental, incremental_values);
+ UNLOCK_APP(app);
+}
+
+
+static Request GetRequestRecord(
+ Widget widget,
+ Atom selection,
+ XtRequestId id)
+{
+ Request req = (Request)id;
+ Select ctx = NULL;
+
+ if ( (req == NULL
+ && ((ctx = FindCtx( XtDisplay(widget), selection )) == NULL
+ || ctx->req == NULL
+ || ctx->selection != selection
+ || ctx->widget == NULL))
+ || (req != NULL
+ && (req->ctx == NULL
+ || req->ctx->selection != selection
+ || req->ctx->widget != widget)))
+ {
+ String params = XtName(widget);
+ Cardinal num_params = 1;
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "notInConvertSelection", "xtGetSelectionRequest",
+ XtCXtToolkitError,
+ "XtGetSelectionRequest or XtGetSelectionParameters called for widget \"%s\" outside of ConvertSelection proc",
+ &params, &num_params
+ );
+ return NULL;
+ }
+
+ if (req == NULL) {
+ /* non-incremental owner; only one request can be
+ * outstanding at a time, so it's safe to keep ptr in ctx */
+ req = ctx->req;
+ }
+ return req;
+}
+
+XSelectionRequestEvent *XtGetSelectionRequest(
+ Widget widget,
+ Atom selection,
+ XtRequestId id)
+{
+ Request req = (Request)id;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+
+ req = GetRequestRecord(widget, selection, id);
+
+ if (! req) {
+ UNLOCK_APP(app);
+ return (XSelectionRequestEvent*) NULL;
+ }
+
+ if (req->event.type == 0) {
+ /* owner is local; construct the remainder of the event */
+ req->event.type = SelectionRequest;
+ req->event.serial = LastKnownRequestProcessed(XtDisplay(widget));
+ req->event.send_event = True;
+ req->event.display = XtDisplay(widget);
+ req->event.owner = XtWindow(req->ctx->widget);
+ req->event.selection = selection;
+ }
+ UNLOCK_APP(app);
+ return &req->event;
+}
+
+/* Property atom access */
+Atom XtReservePropertyAtom(
+ Widget w)
+{
+ return(GetSelectionProperty(XtDisplay(w)));
+}
+
+void XtReleasePropertyAtom(
+ Widget w,
+ Atom atom)
+{
+ FreeSelectionProperty(XtDisplay(w), atom);
+}
+
+
+/* Multiple utilities */
+
+/* All requests are put in a single list per widget. It is
+ very unlikely anyone will be gathering multiple MULTIPLE
+ requests at the same time, so the loss in efficiency for
+ this case is acceptable */
+
+/* Queue one or more requests to the one we're gathering */
+static void AddSelectionRequests(
+ Widget wid,
+ Atom sel,
+ int count,
+ Atom *targets,
+ XtSelectionCallbackProc *callbacks,
+ int num_cb,
+ XtPointer *closures,
+ Boolean *incrementals,
+ Atom *properties)
+{
+ QueuedRequestInfo qi;
+ Window window = XtWindow(wid);
+ Display *dpy = XtDisplay(wid);
+
+ LOCK_PROCESS;
+ if (multipleContext == 0) multipleContext = XUniqueContext();
+
+ qi = NULL;
+ (void) XFindContext(dpy, window, multipleContext, (XPointer*) &qi);
+
+ if (qi != NULL) {
+ QueuedRequest *req = qi->requests;
+ int start = qi->count;
+ int i = 0;
+ int j = 0;
+
+ qi->count += count;
+ req = (QueuedRequest*) XtRealloc((char*) req,
+ (start + count) *
+ sizeof(QueuedRequest));
+ while(i < count) {
+ QueuedRequest newreq = (QueuedRequest)
+ __XtMalloc(sizeof(QueuedRequestRec));
+ newreq->selection = sel;
+ newreq->target = targets[i];
+ if (properties != NULL)
+ newreq->param = properties[i];
+ else {
+ newreq->param = GetSelectionProperty(dpy);
+ XDeleteProperty(dpy, window, newreq->param);
+ }
+ newreq->callback = callbacks[j];
+ newreq->closure = closures[i];
+ newreq->incremental = incrementals[i];
+
+ req[start] = newreq;
+ start++;
+ i++;
+ j++;
+ if (j > num_cb) j = 0;
+ }
+
+ qi->requests = req;
+ } else {
+ /* Impossible */
+ }
+
+ UNLOCK_PROCESS;
+}
+
+/* Only call IsGatheringRequest when we have a lock already */
+
+static Boolean IsGatheringRequest(
+ Widget wid,
+ Atom sel)
+{
+ QueuedRequestInfo qi;
+ Window window = XtWindow(wid);
+ Display *dpy = XtDisplay(wid);
+ Boolean found = False;
+ int i;
+
+ if (multipleContext == 0) multipleContext = XUniqueContext();
+
+ qi = NULL;
+ (void) XFindContext(dpy, window, multipleContext, (XPointer*) &qi);
+
+ if (qi != NULL) {
+ i = 0;
+ while(qi->selections[i] != None) {
+ if (qi->selections[i] == sel) {
+ found = True;
+ break;
+ }
+ i++;
+ }
+ }
+
+ return(found);
+}
+
+/* Cleanup request scans the request queue and releases any
+ properties queued, and removes any requests queued */
+static void CleanupRequest(
+ Display *dpy,
+ QueuedRequestInfo qi,
+ Atom sel)
+{
+ int i, j, n;
+
+ i = 0;
+
+ /* Remove this selection from the list */
+ n = 0;
+ while(qi->selections[n] != sel &&
+ qi->selections[n] != None) n++;
+ if (qi->selections[n] == sel) {
+ while(qi->selections[n] != None) {
+ qi->selections[n] = qi->selections[n + 1];
+ n++;
+ }
+ }
+
+ while(i < qi->count) {
+ QueuedRequest req = qi->requests[i];
+
+ if (req->selection == sel) {
+ /* Match */
+ if (req->param != None)
+ FreeSelectionProperty(dpy, req->param);
+ qi->count--;
+
+ for(j = i; j < qi->count; j++)
+ qi->requests[j] = qi->requests[j + 1];
+
+ XtFree((char*) req);
+ } else {
+ i++;
+ }
+ }
+}
+
+extern void XtCreateSelectionRequest(
+ Widget widget,
+ Atom selection)
+{
+ QueuedRequestInfo queueInfo;
+ Window window = XtWindow(widget);
+ Display *dpy = XtDisplay(widget);
+ int n;
+
+ LOCK_PROCESS;
+ if (multipleContext == 0) multipleContext = XUniqueContext();
+
+ queueInfo = NULL;
+ (void) XFindContext(dpy, window, multipleContext, (XPointer*) &queueInfo);
+
+ /* If there is one, then cancel it */
+ if (queueInfo != 0)
+ CleanupRequest(dpy, queueInfo, selection);
+ else {
+ /* Create it */
+ queueInfo = (QueuedRequestInfo) __XtMalloc(sizeof(QueuedRequestInfoRec));
+ queueInfo->count = 0;
+ queueInfo->selections = (Atom*) __XtMalloc(sizeof(Atom) * 2);
+ queueInfo->selections[0] = None;
+ queueInfo->requests = (QueuedRequest *)
+ __XtMalloc(sizeof(QueuedRequest));
+ }
+
+ /* Append this selection to list */
+ n = 0;
+ while(queueInfo->selections[n] != None) n++;
+ queueInfo->selections =
+ (Atom*) XtRealloc((char*) queueInfo->selections,
+ (n + 2) * sizeof(Atom));
+ queueInfo->selections[n] = selection;
+ queueInfo->selections[n + 1] = None;
+
+ (void) XSaveContext(dpy, window, multipleContext, (char*) queueInfo);
+ UNLOCK_PROCESS;
+}
+
+extern void XtSendSelectionRequest(
+ Widget widget,
+ Atom selection,
+ Time time)
+{
+ QueuedRequestInfo queueInfo;
+ Window window = XtWindow(widget);
+ Display *dpy = XtDisplay(widget);
+
+ LOCK_PROCESS;
+ if (multipleContext == 0) multipleContext = XUniqueContext();
+
+ queueInfo = NULL;
+ (void) XFindContext(dpy, window, multipleContext, (XPointer*) &queueInfo);
+ if (queueInfo != NULL) {
+ int count = 0;
+ int i;
+ QueuedRequest *req = queueInfo->requests;
+
+ /* Construct the requests and send it using
+ GetSelectionValues */
+ for(i = 0; i < queueInfo->count; i++)
+ if (req[i]->selection == selection) count++;
+
+ if (count > 0) {
+ if (count == 1) {
+ for(i = 0; i < queueInfo->count; i++)
+ if (req[i]->selection == selection) break;
+
+ /* special case a multiple which isn't needed */
+ GetSelectionValue(widget, selection, req[i]->target,
+ req[i]->callback, req[i]->closure, time,
+ req[i]->incremental, req[i]->param);
+ } else {
+ Atom *targets;
+ Atom t[PREALLOCED];
+ XtSelectionCallbackProc *cbs;
+ XtSelectionCallbackProc c[PREALLOCED];
+ XtPointer *closures;
+ XtPointer cs[PREALLOCED];
+ Boolean *incrs;
+ Boolean ins[PREALLOCED];
+ Atom *props;
+ Atom p[PREALLOCED];
+ int i = 0;
+ int j = 0;
+
+ /* Allocate */
+ targets = (Atom *) XtStackAlloc(count * sizeof(Atom), t);
+ cbs = (XtSelectionCallbackProc *)
+ XtStackAlloc(count * sizeof(XtSelectionCallbackProc), c);
+ closures = (XtPointer *) XtStackAlloc(count * sizeof(XtPointer), cs);
+ incrs = (Boolean *) XtStackAlloc(count * sizeof(Boolean), ins);
+ props = (Atom *) XtStackAlloc(count * sizeof(Atom), p);
+
+ /* Copy */
+ for(i = 0; i < queueInfo->count; i++) {
+ if (req[i]->selection == selection) {
+ targets[j] = req[i]->target;
+ cbs[j] = req[i]->callback;
+ closures[j] = req[i]->closure;
+ incrs[j] = req[i]->incremental;
+ props[j] = req[i]->param;
+ j++;
+ }
+ }
+
+ /* Make the request */
+ GetSelectionValues(widget, selection, targets, count,
+ cbs, count, closures, time, incrs, props);
+
+ /* Free */
+ XtStackFree((XtPointer) targets, t);
+ XtStackFree((XtPointer) cbs, c);
+ XtStackFree((XtPointer) closures, cs);
+ XtStackFree((XtPointer) incrs, ins);
+ XtStackFree((XtPointer) props, p);
+ }
+ }
+ }
+
+ CleanupRequest(dpy, queueInfo, selection);
+ UNLOCK_PROCESS;
+}
+
+extern void XtCancelSelectionRequest(
+ Widget widget,
+ Atom selection)
+{
+ QueuedRequestInfo queueInfo;
+ Window window = XtWindow(widget);
+ Display *dpy = XtDisplay(widget);
+
+ LOCK_PROCESS;
+ if (multipleContext == 0) multipleContext = XUniqueContext();
+
+ queueInfo = NULL;
+ (void) XFindContext(dpy, window, multipleContext, (XPointer*) &queueInfo);
+ /* If there is one, then cancel it */
+ if (queueInfo != 0)
+ CleanupRequest(dpy, queueInfo, selection);
+ UNLOCK_PROCESS;
+}
+
+/* Parameter utilities */
+
+/* Parameters on a selection request */
+/* Places data on allocated parameter atom, then records the
+ parameter atom data for use in the next call to one of
+ the XtGetSelectionValue functions. */
+void XtSetSelectionParameters(
+ Widget requestor,
+ Atom selection,
+ Atom type,
+ XtPointer value,
+ unsigned long length,
+ int format)
+{
+ Display *dpy = XtDisplay(requestor);
+ Window window = XtWindow(requestor);
+ Atom property = GetParamInfo(requestor, selection);
+
+ if (property == None) {
+ property = GetSelectionProperty(dpy);
+ AddParamInfo(requestor, selection, property);
+ }
+
+ XChangeProperty(dpy, window, property,
+ type, format, PropModeReplace,
+ (unsigned char *) value, length);
+}
+
+/* Retrieves data passed in a parameter. Data for this is stored
+ on the originator's window */
+void XtGetSelectionParameters(
+ Widget owner,
+ Atom selection,
+ XtRequestId request_id,
+ Atom* type_return,
+ XtPointer* value_return,
+ unsigned long* length_return,
+ int* format_return)
+{
+ Request req;
+ Display *dpy = XtDisplay(owner);
+ WIDGET_TO_APPCON(owner);
+
+ *value_return = NULL;
+ *length_return = *format_return = 0;
+ *type_return = None;
+
+ LOCK_APP(app);
+
+ req = GetRequestRecord(owner, selection, request_id);
+
+ if (req && req->property) {
+ unsigned long bytes_after; /* unused */
+ StartProtectedSection(dpy, req->requestor);
+ XGetWindowProperty(dpy, req->requestor, req->property, 0L, 10000000,
+ False, AnyPropertyType, type_return, format_return,
+ length_return, &bytes_after,
+ (unsigned char**) value_return);
+ EndProtectedSection(dpy);
+#ifdef XT_COPY_SELECTION
+ if (*value_return) {
+ int size = BYTELENGTH(*length_return, *format_return) + 1;
+ char *tmp = __XtMalloc((Cardinal) size);
+ (void) memmove(tmp, *value_return, size);
+ XFree(*value_return);
+ *value_return = tmp;
+ }
+#endif
+ }
+ UNLOCK_APP(app);
+}
+
+/* Parameters are temporarily stashed in an XContext. A list is used because
+ * there may be more than one selection request in progress. The context
+ * data is deleted when the list is empty. In the future, the parameter
+ * context could be merged with other contexts used during selections.
+ */
+
+static void AddParamInfo(
+ Widget w,
+ Atom selection,
+ Atom param_atom)
+{
+ int n;
+ Param p;
+ ParamInfo pinfo;
+
+ LOCK_PROCESS;
+ if (paramPropertyContext == 0)
+ paramPropertyContext = XUniqueContext();
+
+ if (XFindContext(XtDisplay(w), XtWindow(w), paramPropertyContext,
+ (XPointer *) &pinfo)) {
+ pinfo = (ParamInfo) __XtMalloc(sizeof(ParamInfoRec));
+ pinfo->count = 1;
+ pinfo->paramlist = XtNew(ParamRec);
+ p = pinfo->paramlist;
+ (void) XSaveContext(XtDisplay(w), XtWindow(w), paramPropertyContext,
+ (char *)pinfo);
+ }
+ else {
+ for (n = pinfo->count, p = pinfo->paramlist; n; n--, p++) {
+ if (p->selection == None || p->selection == selection)
+ break;
+ }
+ if (n == 0) {
+ pinfo->count++;
+ pinfo->paramlist = (Param)
+ XtRealloc((char*) pinfo->paramlist,
+ pinfo->count * sizeof(ParamRec));
+ p = &pinfo->paramlist[pinfo->count - 1];
+ (void) XSaveContext(XtDisplay(w), XtWindow(w),
+ paramPropertyContext, (char *)pinfo);
+ }
+ }
+ p->selection = selection;
+ p->param = param_atom;
+ UNLOCK_PROCESS;
+}
+
+static void RemoveParamInfo(
+ Widget w,
+ Atom selection)
+{
+ int n;
+ Param p;
+ ParamInfo pinfo;
+ Boolean retain = False;
+
+ LOCK_PROCESS;
+ if (paramPropertyContext
+ && (XFindContext(XtDisplay(w), XtWindow(w), paramPropertyContext,
+ (XPointer *) &pinfo) == 0)) {
+
+ /* Find and invalidate the parameter data. */
+ for (n = pinfo->count, p = pinfo->paramlist; n; n--, p++) {
+ if (p->selection != None) {
+ if (p->selection == selection)
+ p->selection = None;
+ else
+ retain = True;
+ }
+ }
+ /* If there's no valid data remaining, release the context entry. */
+ if (! retain) {
+ XtFree((char*) pinfo->paramlist);
+ XtFree((char*) pinfo);
+ XDeleteContext(XtDisplay(w), XtWindow(w), paramPropertyContext);
+ }
+ }
+ UNLOCK_PROCESS;
+}
+
+static Atom GetParamInfo(
+ Widget w,
+ Atom selection)
+{
+ int n;
+ Param p;
+ ParamInfo pinfo;
+ Atom atom = None;
+
+ LOCK_PROCESS;
+ if (paramPropertyContext
+ && (XFindContext(XtDisplay(w), XtWindow(w), paramPropertyContext,
+ (XPointer *) &pinfo) == 0)) {
+
+ for (n = pinfo->count, p = pinfo->paramlist; n; n--, p++)
+ if (p->selection == selection) {
+ atom = p->param;
+ break;
+ }
+ }
+ UNLOCK_PROCESS;
+ return atom;
+}
diff --git a/nx-X11/lib/Xt/SelectionI.h b/nx-X11/lib/Xt/SelectionI.h
new file mode 100644
index 000000000..e589aece5
--- /dev/null
+++ b/nx-X11/lib/Xt/SelectionI.h
@@ -0,0 +1,170 @@
+/* $Xorg: SelectionI.h,v 1.4 2001/02/09 02:03:58 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+
+#ifndef _XtselectionI_h
+#define _XtselectionI_h
+
+#include "Intrinsic.h"
+
+typedef struct _RequestRec *Request;
+typedef struct _SelectRec *Select;
+
+typedef struct _RequestRec {
+ Select ctx; /* logical owner */
+ Widget widget; /* widget actually receiving Selection events */
+ Window requestor;
+ Atom property;
+ Atom target;
+ Atom type;
+ int format;
+ XtPointer value;
+ unsigned long bytelength;
+ unsigned long offset;
+ XtIntervalId timeout;
+ XSelectionRequestEvent event; /* for XtGetSelectionRequest */
+ Boolean allSent;
+} RequestRec;
+
+typedef struct {
+ Atom prop;
+ Boolean avail;
+} SelectionPropRec, *SelectionProp;
+
+typedef struct {
+ Display *dpy;
+ Atom incr_atom, indirect_atom, timestamp_atom;
+ int propCount;
+ SelectionProp list;
+} PropListRec, *PropList;
+
+typedef struct _SelectRec {
+ Atom selection; /* constant */
+ Display *dpy; /* constant */
+ Widget widget;
+ Time time;
+ unsigned long serial;
+ XtConvertSelectionProc convert;
+ XtLoseSelectionProc loses;
+ XtSelectionDoneProc notify;
+ XtCancelConvertSelectionProc owner_cancel;
+ XtPointer owner_closure;
+ PropList prop_list;
+ Request req; /* state for local non-incr xfer */
+ int ref_count; /* of active transfers */
+ unsigned int incremental:1;
+ unsigned int free_when_done:1;
+ unsigned int was_disowned:1;
+} SelectRec;
+
+typedef struct _ParamRec {
+ Atom selection;
+ Atom param;
+} ParamRec, *Param;
+
+typedef struct _ParamInfoRec {
+ unsigned int count;
+ Param paramlist;
+} ParamInfoRec, *ParamInfo;
+
+typedef struct _QueuedRequestRec {
+ Atom selection;
+ Atom target;
+ Atom param;
+ XtSelectionCallbackProc callback;
+ XtPointer closure;
+ Time time;
+ Boolean incremental;
+} QueuedRequestRec, *QueuedRequest;
+
+typedef struct _QueuedRequestInfoRec {
+ int count;
+ Atom *selections;
+ QueuedRequest *requests;
+} QueuedRequestInfoRec, *QueuedRequestInfo;
+
+typedef struct {
+ XtSelectionCallbackProc *callbacks;
+ XtPointer *req_closure;
+ Atom property;
+ Atom *target;
+ Atom type;
+ int format;
+ char *value;
+ int bytelength;
+ int offset;
+ XtIntervalId timeout;
+ XtEventHandler proc;
+ Widget widget;
+ Time time;
+ Select ctx;
+ Boolean *incremental;
+ int current;
+} CallBackInfoRec, *CallBackInfo;
+
+typedef struct {
+ Atom target;
+ Atom property;
+} IndirectPair;
+
+#define IndirectPairWordSize 2
+
+typedef struct {
+ int active_transfer_count;
+} RequestWindowRec;
+
+#define MAX_SELECTION_INCR(dpy) (((65536 < XMaxRequestSize(dpy)) ? \
+ (65536 << 2) : (XMaxRequestSize(dpy) << 2))-100)
+
+#define MATCH_SELECT(event, info) ((event->time == info->time) && \
+ (event->requestor == XtWindow(info->widget)) && \
+ (event->selection == info->ctx->selection) && \
+ (event->target == *info->target))
+
+#endif /* _XtselectionI_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/SetSens.c b/nx-X11/lib/Xt/SetSens.c
new file mode 100644
index 000000000..ad2b6f489
--- /dev/null
+++ b/nx-X11/lib/Xt/SetSens.c
@@ -0,0 +1,128 @@
+/* $Xorg: SetSens.c,v 1.4 2001/02/09 02:03:58 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+/* $XFree86: xc/lib/Xt/SetSens.c,v 1.3 2001/12/14 19:56:29 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+
+/*
+ * XtSetSensitive()
+ */
+
+static void SetAncestorSensitive(
+ register Widget widget,
+ Boolean ancestor_sensitive)
+{
+ Arg args[1];
+ register Cardinal i;
+ register WidgetList children;
+
+ if (widget->core.ancestor_sensitive == ancestor_sensitive) return;
+
+ XtSetArg(args[0], XtNancestorSensitive, ancestor_sensitive);
+ XtSetValues(widget, args, XtNumber(args));
+
+ /* If widget's sensitive is TRUE, propagate new ancestor_sensitive to
+ children's ancestor_sensitive; else do nothing as children's
+ ancestor_sensitive is already FALSE */
+
+ if (widget->core.sensitive && XtIsComposite(widget)) {
+ children = ((CompositeWidget) widget)->composite.children;
+ for (i=0; i < ((CompositeWidget)widget)->composite.num_children; i++) {
+ SetAncestorSensitive (children[i], ancestor_sensitive);
+ }
+ }
+} /* SetAncestorSensitive */
+
+
+void XtSetSensitive(
+ register Widget widget,
+ _XtBoolean sensitive)
+{
+ Arg args[1];
+ register Cardinal i;
+ register WidgetList children;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ if (widget->core.sensitive == sensitive) {
+ UNLOCK_APP(app);
+ return;
+ }
+
+ XtSetArg(args[0], XtNsensitive, sensitive);
+ XtSetValues(widget, args, XtNumber(args));
+
+ /* If widget's ancestor_sensitive is TRUE, propagate new sensitive to
+ children's ancestor_sensitive; else do nothing as children's
+ ancestor_sensitive is already FALSE */
+
+ if (widget->core.ancestor_sensitive && XtIsComposite (widget)) {
+ children = ((CompositeWidget) widget)->composite.children;
+ for (i = 0; i < ((CompositeWidget)widget)->composite.num_children; i++){
+ SetAncestorSensitive (children[i], sensitive);
+ }
+ }
+ UNLOCK_APP(app);
+} /* XtSetSensitive */
diff --git a/nx-X11/lib/Xt/SetValues.c b/nx-X11/lib/Xt/SetValues.c
new file mode 100644
index 000000000..d9e8a4695
--- /dev/null
+++ b/nx-X11/lib/Xt/SetValues.c
@@ -0,0 +1,443 @@
+/* $Xorg: SetValues.c,v 1.4 2001/02/09 02:03:58 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/SetValues.c,v 1.2 2001/08/22 22:52:19 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+
+/*
+ * XtSetValues(), XtSetSubvalues()
+ */
+
+
+static void SetValues(
+ char* base, /* Base address to write values to */
+ XrmResourceList* res, /* The current resource values. */
+ register Cardinal num_resources, /* number of items in resources */
+ ArgList args, /* The resource values to set */
+ Cardinal num_args) /* number of items in arg list */
+{
+ register ArgList arg;
+ register Cardinal i;
+ register XrmName argName;
+ register XrmResourceList* xrmres;
+
+ /* Resource lists are assumed to be in compiled form already via the
+ initial XtGetResources, XtGetSubresources calls */
+
+ for (arg = args ; num_args != 0; num_args--, arg++) {
+ argName = StringToName(arg->name);
+ for (xrmres = res, i = 0; i < num_resources; i++, xrmres++) {
+ if (argName == (*xrmres)->xrm_name) {
+ _XtCopyFromArg(arg->value,
+ base - (*xrmres)->xrm_offset - 1,
+ (*xrmres)->xrm_size);
+ break;
+ }
+ }
+ }
+} /* SetValues */
+
+static Boolean CallSetValues (
+ WidgetClass class,
+ Widget current,
+ Widget request,
+ Widget new,
+ ArgList args,
+ Cardinal num_args)
+{
+ Boolean redisplay = FALSE;
+ WidgetClass superclass;
+ XtArgsFunc set_values_hook;
+ XtSetValuesFunc set_values;
+
+ LOCK_PROCESS;
+ superclass = class->core_class.superclass;
+ UNLOCK_PROCESS;
+ if (superclass)
+ redisplay =
+ CallSetValues(superclass, current, request, new, args, num_args);
+
+ LOCK_PROCESS;
+ set_values = class->core_class.set_values;
+ UNLOCK_PROCESS;
+ if (set_values)
+ redisplay |= (*set_values) (current, request, new, args, &num_args);
+
+ LOCK_PROCESS;
+ set_values_hook = class->core_class.set_values_hook;
+ UNLOCK_PROCESS;
+ if (set_values_hook)
+ redisplay |= (*set_values_hook) (new, args, &num_args);
+ return (redisplay);
+}
+
+static Boolean
+CallConstraintSetValues (
+ ConstraintWidgetClass class,
+ Widget current,
+ Widget request,
+ Widget new,
+ ArgList args,
+ Cardinal num_args)
+{
+ Boolean redisplay = FALSE;
+ XtSetValuesFunc set_values;
+ ConstraintWidgetClass superclass;
+
+ if ((WidgetClass)class != constraintWidgetClass) {
+ if (class == NULL)
+ XtAppErrorMsg(XtWidgetToApplicationContext(current),
+ "invalidClass","constraintSetValue",XtCXtToolkitError,
+ "Subclass of Constraint required in CallConstraintSetValues",
+ (String *)NULL, (Cardinal *)NULL);
+ LOCK_PROCESS;
+ superclass = (ConstraintWidgetClass) class->core_class.superclass;
+ UNLOCK_PROCESS;
+ redisplay =
+ CallConstraintSetValues(superclass,
+ current, request, new, args, num_args);
+ }
+ LOCK_PROCESS;
+ set_values = class->constraint_class.set_values;
+ UNLOCK_PROCESS;
+ if (set_values)
+ redisplay |= (*set_values) (current, request, new, args, &num_args);
+ return (redisplay);
+}
+
+void XtSetSubvalues(
+ XtPointer base, /* Base address to write values to */
+ register XtResourceList resources, /* The current resource values. */
+ register Cardinal num_resources, /* number of items in resources */
+ ArgList args, /* The resource values to set */
+ Cardinal num_args) /* number of items in arg list */
+{
+ register XrmResourceList* xrmres;
+ xrmres = _XtCreateIndirectionTable (resources, num_resources);
+ SetValues((char*)base,xrmres,num_resources, args, num_args);
+ XtFree((char *)xrmres);
+}
+
+
+void XtSetValues(
+ register Widget w,
+ ArgList args,
+ Cardinal num_args)
+{
+ register Widget oldw, reqw;
+ /* need to use strictest alignment rules possible in next two decls. */
+ double oldwCache[100], reqwCache[100];
+ double oldcCache[20], reqcCache[20];
+ Cardinal widgetSize, constraintSize;
+ Boolean redisplay, cleared_rect_obj = False;
+ XtGeometryResult result;
+ XtWidgetGeometry geoReq, geoReply;
+ WidgetClass wc;
+ ConstraintWidgetClass cwc = 0;
+ Boolean hasConstraints;
+ XtAlmostProc set_values_almost;
+ XtAppContext app = XtWidgetToApplicationContext(w);
+ Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(w));
+
+ LOCK_APP(app);
+ wc = XtClass(w);
+ if ((args == NULL) && (num_args != 0)) {
+ XtAppErrorMsg(app,
+ "invalidArgCount","xtSetValues",XtCXtToolkitError,
+ "Argument count > 0 on NULL argument list in XtSetValues",
+ (String *)NULL, (Cardinal *)NULL);
+ }
+
+ /* Allocate and copy current widget into old widget */
+
+ LOCK_PROCESS;
+ widgetSize = wc->core_class.widget_size;
+ UNLOCK_PROCESS;
+ oldw = (Widget) XtStackAlloc(widgetSize, oldwCache);
+ reqw = (Widget) XtStackAlloc (widgetSize, reqwCache);
+ (void) memmove((char *) oldw, (char *) w, (int) widgetSize);
+
+ /* Set resource values */
+
+ LOCK_PROCESS;
+ SetValues((char*)w, (XrmResourceList *) wc->core_class.resources,
+ wc->core_class.num_resources, args, num_args);
+ UNLOCK_PROCESS;
+
+ (void) memmove ((char *) reqw, (char *) w, (int) widgetSize);
+
+ hasConstraints = (XtParent(w) != NULL && !XtIsShell(w) && XtIsConstraint(XtParent(w)));
+
+ /* Some widget sets apparently do ugly things by freeing the
+ * constraints on some children, thus the extra test here */
+ if (hasConstraints) {
+ cwc = (ConstraintWidgetClass) XtClass(w->core.parent);
+ if (w->core.constraints) {
+ LOCK_PROCESS;
+ constraintSize = cwc->constraint_class.constraint_size;
+ UNLOCK_PROCESS;
+ } else constraintSize = 0;
+ } else constraintSize = 0;
+
+ if (constraintSize) {
+ /* Allocate and copy current constraints into oldw */
+ oldw->core.constraints = XtStackAlloc(constraintSize, oldcCache);
+ reqw->core.constraints = XtStackAlloc(constraintSize, reqcCache);
+ (void) memmove((char *) oldw->core.constraints,
+ (char *) w->core.constraints, (int) constraintSize);
+
+ /* Set constraint values */
+ LOCK_PROCESS;
+ SetValues((char*)w->core.constraints,
+ (XrmResourceList *)(cwc->constraint_class.resources),
+ cwc->constraint_class.num_resources, args, num_args);
+ UNLOCK_PROCESS;
+ (void) memmove((char *) reqw->core.constraints,
+ (char *) w->core.constraints, (int) constraintSize);
+ }
+
+ /* Inform widget of changes, then inform parent of changes */
+ redisplay = CallSetValues (wc, oldw, reqw, w, args, num_args);
+ if (hasConstraints) {
+ redisplay |= CallConstraintSetValues(cwc, oldw, reqw, w, args, num_args);
+ }
+
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+ XtChangeHookSetValuesDataRec set_val;
+
+ set_val.old = oldw;
+ set_val.req = reqw;
+ set_val.args = args;
+ set_val.num_args = num_args;
+ call_data.type = XtHsetValues;
+ call_data.widget = w;
+ call_data.event_data = (XtPointer) &set_val;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+
+ if (XtIsRectObj(w)) {
+ /* Now perform geometry request if needed */
+ geoReq.request_mode = 0;
+ if (oldw->core.x != w->core.x) {
+ geoReq.x = w->core.x;
+ w->core.x = oldw->core.x;
+ geoReq.request_mode |= CWX;
+ }
+ if (oldw->core.y != w->core.y) {
+ geoReq.y = w->core.y;
+ w->core.y = oldw->core.y;
+ geoReq.request_mode |= CWY;
+ }
+ if (oldw->core.width != w->core.width) {
+ geoReq.width = w->core.width;
+ w->core.width = oldw->core.width;
+ geoReq.request_mode |= CWWidth;
+ }
+ if (oldw->core.height != w->core.height) {
+ geoReq.height = w->core.height;
+ w->core.height = oldw->core.height;
+ geoReq.request_mode |= CWHeight;
+ }
+ if (oldw->core.border_width != w->core.border_width) {
+ geoReq.border_width = w->core.border_width;
+ w->core.border_width = oldw->core.border_width;
+ geoReq.request_mode |= CWBorderWidth;
+ }
+
+ if (geoReq.request_mode != 0) {
+ /* Pass on any requests for unchanged geometry values */
+ if (geoReq.request_mode !=
+ (CWX | CWY | CWWidth | CWHeight | CWBorderWidth)) {
+ for ( ; num_args != 0; num_args--, args++) {
+ if (! (geoReq.request_mode & CWX) &&
+ strcmp(XtNx, args->name) == 0) {
+ geoReq.x = w->core.x;
+ geoReq.request_mode |= CWX;
+ } else if (! (geoReq.request_mode & CWY) &&
+ strcmp(XtNy, args->name) == 0) {
+ geoReq.y = w->core.y;
+ geoReq.request_mode |= CWY;
+ } else if (! (geoReq.request_mode & CWWidth) &&
+ strcmp(XtNwidth, args->name) == 0) {
+ geoReq.width = w->core.width;
+ geoReq.request_mode |= CWWidth;
+ } else if (! (geoReq.request_mode & CWHeight) &&
+ strcmp(XtNheight, args->name) == 0) {
+ geoReq.height = w->core.height;
+ geoReq.request_mode |= CWHeight;
+ } else if (! (geoReq.request_mode & CWBorderWidth) &&
+ strcmp(XtNborderWidth, args->name) == 0) {
+ geoReq.border_width = w->core.border_width;
+ geoReq.request_mode |= CWBorderWidth;
+ }
+ }
+ }
+ CALLGEOTAT(_XtGeoTrace(w,
+ "\nXtSetValues sees some geometry changes for \"%s\".\n",
+ XtName(w)));
+ CALLGEOTAT(_XtGeoTab(1));
+ do {
+ XtGeometryHookDataRec call_data;
+
+ if (XtHasCallbacks(hookobj, XtNgeometryHook) == XtCallbackHasSome) {
+ call_data.type = XtHpreGeometry;
+ call_data.widget = w;
+ call_data.request = &geoReq;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.geometryhook_callbacks,
+ (XtPointer)&call_data);
+ call_data.result = result =
+ _XtMakeGeometryRequest(w, &geoReq, &geoReply,
+ &cleared_rect_obj);
+ call_data.type = XtHpostGeometry;
+ call_data.reply = &geoReply;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.geometryhook_callbacks,
+ (XtPointer)&call_data);
+ } else {
+ result = _XtMakeGeometryRequest(w, &geoReq, &geoReply,
+ &cleared_rect_obj);
+ }
+ if (result == XtGeometryYes || result == XtGeometryDone)
+ break;
+
+ /* An Almost or No reply. Call widget and let it munge
+ request, reply */
+ LOCK_PROCESS;
+ set_values_almost = wc->core_class.set_values_almost;
+ UNLOCK_PROCESS;
+ if (set_values_almost == NULL) {
+ XtAppWarningMsg(app,
+ "invalidProcedure","set_values_almost",
+ XtCXtToolkitError,
+ "set_values_almost procedure shouldn't be NULL",
+ (String *)NULL, (Cardinal *)NULL);
+ break;
+ }
+ if (result == XtGeometryNo) geoReply.request_mode = 0;
+ CALLGEOTAT(_XtGeoTrace(w,"calling SetValuesAlmost.\n"));
+ (*set_values_almost) (oldw, w, &geoReq, &geoReply);
+ } while (geoReq.request_mode != 0);
+ /* call resize proc if we changed size and parent
+ * didn't already invoke resize */
+ {
+ XtWidgetProc resize;
+ LOCK_PROCESS;
+ resize = wc->core_class.resize;
+ UNLOCK_PROCESS;
+ if ((w->core.width != oldw->core.width ||
+ w->core.height != oldw->core.height)
+ && result != XtGeometryDone
+ && resize != (XtWidgetProc) NULL) {
+ CALLGEOTAT(_XtGeoTrace(w,
+ "XtSetValues calls \"%s\"'s resize proc.\n",
+ XtName(w)));
+ (*resize)(w);
+ }
+ }
+ CALLGEOTAT(_XtGeoTab(-1));
+ }
+ /* Redisplay if needed. No point in clearing if the window is
+ * about to disappear, as the Expose event will just go straight
+ * to the bit bucket. */
+ if (XtIsWidget(w)) {
+ /* widgets can distinguish between redisplay and resize, since
+ the server will cause an expose on resize */
+ if (redisplay && XtIsRealized(w) && !w->core.being_destroyed) {
+ CALLGEOTAT(_XtGeoTrace(w,
+ "XtSetValues calls ClearArea on \"%s\".\n",
+ XtName(w)));
+ XClearArea (XtDisplay(w), XtWindow(w), 0, 0, 0, 0, TRUE);
+ }
+ } else { /*non-window object */
+ if (redisplay && ! cleared_rect_obj ) {
+ Widget pw = _XtWindowedAncestor(w);
+ if (XtIsRealized(pw) && !pw->core.being_destroyed) {
+ RectObj r = (RectObj)w;
+ int bw2 = r->rectangle.border_width << 1;
+ CALLGEOTAT(_XtGeoTrace(w,
+ "XtSetValues calls ClearArea on \"%s\"'s parent \"%s\".\n",
+ XtName(w),XtName(pw)));
+ XClearArea (XtDisplay (pw), XtWindow (pw),
+ r->rectangle.x, r->rectangle.y,
+ r->rectangle.width + bw2,
+ r->rectangle.height + bw2,TRUE);
+ }
+ }
+ }
+ }
+
+
+ /* Free dynamic storage */
+ if (constraintSize) {
+ XtStackFree(oldw->core.constraints, oldcCache);
+ XtStackFree(reqw->core.constraints, reqcCache);
+ }
+ XtStackFree((XtPointer)oldw, oldwCache);
+ XtStackFree((XtPointer)reqw, reqwCache);
+ UNLOCK_APP(app);
+} /* XtSetValues */
diff --git a/nx-X11/lib/Xt/SetWMCW.c b/nx-X11/lib/Xt/SetWMCW.c
new file mode 100644
index 000000000..d714fa665
--- /dev/null
+++ b/nx-X11/lib/Xt/SetWMCW.c
@@ -0,0 +1,173 @@
+/* $Xorg: SetWMCW.c,v 1.4 2001/02/09 02:03:58 xorgcvs Exp $ */
+/* $XdotOrg: xc/lib/Xt/SetWMCW.c,v 1.4 2005/07/22 20:30:10 alanc Exp $
+ *
+ * Author: Chris D. Peterson, MIT X Consortium
+ */
+
+/* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * 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
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+/*
+
+Copyright 1989, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include <X11/Xatom.h>
+
+/* Function Name: XtSetWMColormapWindows
+ *
+ * Description: Sets the value of the WM_COLORMAP_WINDOWS
+ * property on a widget's window.
+ *
+ * Arguments: widget - specifies the widget on whose window the
+ * - WM_COLORMAP_WINDOWS property will be stored.
+ *
+ * list - Specifies a list of widgets whose windows are to be
+ * listed in the WM_COLORMAP_WINDOWS property.
+ * count - Specifies the number of widgets in list.
+ *
+ * Returns: none.
+ */
+
+void
+XtSetWMColormapWindows(
+ Widget widget,
+ Widget *list,
+ Cardinal count)
+{
+ Window *data;
+ Widget *checked, *top, *temp, hookobj;
+ Cardinal i, j, checked_count;
+ Boolean match;
+ Atom xa_wm_colormap_windows;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ if ( !XtIsRealized(widget) || (count == 0) ) {
+ UNLOCK_APP(app);
+ return;
+ }
+
+ top = checked = (Widget *) __XtMalloc( (Cardinal) sizeof(Widget) * count);
+
+
+/*
+ * The specification calls for only adding the windows that have unique
+ * colormaps to the property to this function, so we will make a pass through
+ * the widget list removing all the widgets with non-unique colormaps.
+ *
+ * We will also remove any unrealized widgets from the list at this time.
+ */
+
+ for (checked_count = 0, i = 0; i < count; i++) {
+ if (!XtIsRealized(list[i])) continue;
+
+ *checked = list[i];
+ match = FALSE;
+
+/*
+ * Don't check first element for matching colormap since there is nothing
+ * to check it against.
+ */
+
+ if (checked != top)
+ for (j = 0, temp = top; j < checked_count ; j++, temp++)
+ if ( (*temp)->core.colormap == (*checked)->core.colormap) {
+ match = TRUE;
+ break;
+ }
+
+/*
+ * If no colormap was found to match then add this widget to the linked list.
+ */
+
+ if (!match) {
+ checked++;
+ checked_count++;
+ }
+ }
+
+/*
+ * Now that we have the list of widgets we need to convert it to a list of
+ * windows and set the property.
+ */
+
+ data = (Window *) __XtMalloc( (Cardinal) sizeof(Window) * checked_count);
+
+ for ( i = 0 ; i < checked_count ; i++)
+ data[i] = XtWindow(top[i]);
+
+ xa_wm_colormap_windows = XInternAtom(XtDisplay(widget),
+ "WM_COLORMAP_WINDOWS", FALSE);
+
+ XChangeProperty(XtDisplay(widget), XtWindow(widget),
+ xa_wm_colormap_windows, XA_WINDOW, 32,
+ PropModeReplace, (unsigned char *) data, (int) i);
+
+ hookobj = XtHooksOfDisplay(XtDisplay(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHsetWMColormapWindows;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer) list;
+ call_data.num_event_data = count;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+
+ XtFree( (char *) data);
+ XtFree( (char *) top);
+ UNLOCK_APP(app);
+}
diff --git a/nx-X11/lib/Xt/Shell.c b/nx-X11/lib/Xt/Shell.c
new file mode 100644
index 000000000..b3e57b8e5
--- /dev/null
+++ b/nx-X11/lib/Xt/Shell.c
@@ -0,0 +1,3414 @@
+/* $Xorg: Shell.c,v 1.4 2001/02/09 02:03:58 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/Shell.c,v 3.16tsi Exp $ */
+
+/*
+
+Copyright 1987, 1988, 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.
+
+*/
+
+#define SHELL
+
+#ifndef DEFAULT_WM_TIMEOUT
+#define DEFAULT_WM_TIMEOUT 5000
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+#include "Shell.h"
+#include "ShellP.h"
+#include "ShellI.h"
+#include "Vendor.h"
+#include "VendorP.h"
+#include <X11/Xatom.h>
+#include <X11/Xlocale.h>
+#include <X11/ICE/ICElib.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef EDITRES
+#include <X11/Xmu/Editres.h>
+#endif
+
+/***************************************************************************
+ *
+ * Note: per the Xt spec, the Shell geometry management assumes in
+ * several places that there is only one managed child. This is
+ * *not* a bug. Any subclass that assumes otherwise is broken.
+ *
+ ***************************************************************************/
+
+#define BIGSIZE ((Dimension)32767)
+
+/***************************************************************************
+ *
+ * Default values for resource lists
+ *
+ ***************************************************************************/
+
+#ifdef CRAY
+void _XtShellDepth(Widget, int, XrmValue *);
+void _XtShellColormap(Widget, int, XrmValue *);
+void _XtShellAncestorSensitive(Widget, int, XrmValue *);
+void _XtTitleEncoding(Widget, int, XrmValue *);
+#else
+static void _XtShellDepth(Widget, int, XrmValue *);
+static void _XtShellColormap(Widget, int, XrmValue *);
+static void _XtShellAncestorSensitive(Widget, int, XrmValue *);
+static void _XtTitleEncoding(Widget, int, XrmValue *);
+#endif
+
+/***************************************************************************
+ *
+ * Shell class record
+ *
+ ***************************************************************************/
+
+#define Offset(x) (XtOffsetOf(ShellRec, x))
+static XtResource shellResources[]=
+{
+ {XtNx, XtCPosition, XtRPosition, sizeof(Position),
+ Offset(core.x), XtRImmediate, (XtPointer)BIGSIZE},
+ {XtNy, XtCPosition, XtRPosition, sizeof(Position),
+ Offset(core.y), XtRImmediate, (XtPointer)BIGSIZE},
+ { XtNdepth, XtCDepth, XtRInt, sizeof(int),
+ Offset(core.depth), XtRCallProc, (XtPointer) _XtShellDepth},
+ { XtNcolormap, XtCColormap, XtRColormap, sizeof(Colormap),
+ Offset(core.colormap), XtRCallProc, (XtPointer) _XtShellColormap},
+ { XtNancestorSensitive, XtCSensitive, XtRBoolean, sizeof(Boolean),
+ Offset(core.ancestor_sensitive), XtRCallProc,
+ (XtPointer) _XtShellAncestorSensitive},
+ { XtNallowShellResize, XtCAllowShellResize, XtRBoolean,
+ sizeof(Boolean), Offset(shell.allow_shell_resize),
+ XtRImmediate, (XtPointer)False},
+ { XtNgeometry, XtCGeometry, XtRString, sizeof(String),
+ Offset(shell.geometry), XtRString, (XtPointer)NULL},
+ { XtNcreatePopupChildProc, XtCCreatePopupChildProc, XtRFunction,
+ sizeof(XtCreatePopupChildProc), Offset(shell.create_popup_child_proc),
+ XtRFunction, NULL},
+ { XtNsaveUnder, XtCSaveUnder, XtRBoolean, sizeof(Boolean),
+ Offset(shell.save_under), XtRImmediate, (XtPointer)False},
+ { XtNpopupCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(shell.popup_callback), XtRCallback, (XtPointer) NULL},
+ { XtNpopdownCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(shell.popdown_callback), XtRCallback, (XtPointer) NULL},
+ { XtNoverrideRedirect, XtCOverrideRedirect,
+ XtRBoolean, sizeof(Boolean), Offset(shell.override_redirect),
+ XtRImmediate, (XtPointer)False},
+ { XtNvisual, XtCVisual, XtRVisual, sizeof(Visual*),
+ Offset(shell.visual), XtRImmediate, CopyFromParent}
+};
+
+static void ClassPartInitialize(WidgetClass);
+static void Initialize(Widget, Widget, ArgList, Cardinal *);
+static void Realize(Widget, Mask *, XSetWindowAttributes *);
+static void Resize(Widget);
+static Boolean SetValues(Widget, Widget, Widget, ArgList , Cardinal *);
+static void GetValuesHook(Widget, ArgList, Cardinal*);
+static void ChangeManaged(Widget);
+static XtGeometryResult GeometryManager(Widget, XtWidgetGeometry *, XtWidgetGeometry *);
+static XtGeometryResult RootGeometryManager(Widget gw, XtWidgetGeometry *request, XtWidgetGeometry *reply);
+static void Destroy(Widget);
+
+static ShellClassExtensionRec shellClassExtRec = {
+ NULL,
+ NULLQUARK,
+ XtShellExtensionVersion,
+ sizeof(ShellClassExtensionRec),
+ RootGeometryManager
+};
+
+externaldef(shellclassrec) ShellClassRec shellClassRec = {
+ { /* Core */
+ /* superclass */ (WidgetClass) &compositeClassRec,
+ /* class_name */ "Shell",
+ /* size */ sizeof(ShellRec),
+ /* Class Initializer */ NULL,
+ /* class_part_initialize*/ ClassPartInitialize,
+ /* Class init'ed ? */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_notify */ NULL,
+ /* realize */ Realize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ shellResources,
+ /* resource_count */ XtNumber(shellResources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ NULL,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ GetValuesHook,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator*/ NULL,
+ /* extension */ NULL
+ },{ /* Composite */
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },{ /* Shell */
+ /* extension */ (XtPointer)&shellClassExtRec
+ }
+};
+
+externaldef(shellwidgetclass) WidgetClass shellWidgetClass = (WidgetClass) (&shellClassRec);
+
+/***************************************************************************
+ *
+ * OverrideShell class record
+ *
+ ***************************************************************************/
+
+static XtResource overrideResources[]=
+{
+ { XtNoverrideRedirect, XtCOverrideRedirect,
+ XtRBoolean, sizeof(Boolean), Offset(shell.override_redirect),
+ XtRImmediate, (XtPointer)True},
+ { XtNsaveUnder, XtCSaveUnder, XtRBoolean, sizeof(Boolean),
+ Offset(shell.save_under), XtRImmediate, (XtPointer)True},
+};
+
+externaldef(overrideshellclassrec) OverrideShellClassRec overrideShellClassRec = {
+ {
+ /* superclass */ (WidgetClass) &shellClassRec,
+ /* class_name */ "OverrideShell",
+ /* size */ sizeof(OverrideShellRec),
+ /* Class Initializer */ NULL,
+ /* class_part_initialize*/ NULL,
+ /* Class init'ed ? */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_notify */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ overrideResources,
+ /* resource_count */ XtNumber(overrideResources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ XtInheritResize,
+ /* expose */ NULL,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL
+ },{
+ /* geometry_manager */ XtInheritGeometryManager,
+ /* change_managed */ XtInheritChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ }
+};
+
+externaldef(overrideshellwidgetclass) WidgetClass overrideShellWidgetClass =
+ (WidgetClass) (&overrideShellClassRec);
+
+/***************************************************************************
+ *
+ * WMShell class record
+ *
+ ***************************************************************************/
+
+#undef Offset
+#define Offset(x) (XtOffsetOf(WMShellRec, x))
+
+static int default_unspecified_shell_int = XtUnspecifiedShellInt;
+/*
+ * Warning, casting XtUnspecifiedShellInt (which is -1) to an (XtPointer)
+ * can result is loss of bits on some machines (i.e. crays)
+ */
+
+static XtResource wmResources[]=
+{
+ { XtNtitle, XtCTitle, XtRString, sizeof(String),
+ Offset(wm.title), XtRString, NULL},
+ { XtNtitleEncoding, XtCTitleEncoding, XtRAtom, sizeof(Atom),
+ Offset(wm.title_encoding),
+ XtRCallProc, (XtPointer) _XtTitleEncoding},
+ { XtNwmTimeout, XtCWmTimeout, XtRInt, sizeof(int),
+ Offset(wm.wm_timeout), XtRImmediate,(XtPointer)DEFAULT_WM_TIMEOUT},
+ { XtNwaitForWm, XtCWaitForWm, XtRBoolean, sizeof(Boolean),
+ Offset(wm.wait_for_wm), XtRImmediate, (XtPointer)True},
+ { XtNtransient, XtCTransient, XtRBoolean, sizeof(Boolean),
+ Offset(wm.transient), XtRImmediate, (XtPointer)False},
+/* size_hints minus things stored in core */
+ { XtNbaseWidth, XtCBaseWidth, XtRInt, sizeof(int),
+ Offset(wm.base_width),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+ { XtNbaseHeight, XtCBaseHeight, XtRInt, sizeof(int),
+ Offset(wm.base_height),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+ { XtNwinGravity, XtCWinGravity, XtRGravity, sizeof(int),
+ Offset(wm.win_gravity),
+ XtRGravity, (XtPointer) &default_unspecified_shell_int},
+ { XtNminWidth, XtCMinWidth, XtRInt, sizeof(int),
+ Offset(wm.size_hints.min_width),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+ { XtNminHeight, XtCMinHeight, XtRInt, sizeof(int),
+ Offset(wm.size_hints.min_height),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+ { XtNmaxWidth, XtCMaxWidth, XtRInt, sizeof(int),
+ Offset(wm.size_hints.max_width),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+ { XtNmaxHeight, XtCMaxHeight, XtRInt, sizeof(int),
+ Offset(wm.size_hints.max_height),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+ { XtNwidthInc, XtCWidthInc, XtRInt, sizeof(int),
+ Offset(wm.size_hints.width_inc),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+ { XtNheightInc, XtCHeightInc, XtRInt, sizeof(int),
+ Offset(wm.size_hints.height_inc),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+ { XtNminAspectX, XtCMinAspectX, XtRInt, sizeof(int),
+ Offset(wm.size_hints.min_aspect.x),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+ { XtNminAspectY, XtCMinAspectY, XtRInt, sizeof(int),
+ Offset(wm.size_hints.min_aspect.y),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+ { XtNmaxAspectX, XtCMaxAspectX, XtRInt, sizeof(int),
+ Offset(wm.size_hints.max_aspect.x),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+ { XtNmaxAspectY, XtCMaxAspectY, XtRInt, sizeof(int),
+ Offset(wm.size_hints.max_aspect.y),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+/* wm_hints */
+ { XtNinput, XtCInput, XtRBool, sizeof(Bool),
+ Offset(wm.wm_hints.input), XtRImmediate, (XtPointer)False},
+ { XtNinitialState, XtCInitialState, XtRInitialState, sizeof(int),
+ Offset(wm.wm_hints.initial_state),
+ XtRImmediate, (XtPointer)NormalState},
+ { XtNiconPixmap, XtCIconPixmap, XtRBitmap, sizeof(Pixmap),
+ Offset(wm.wm_hints.icon_pixmap), XtRPixmap, NULL},
+ { XtNiconWindow, XtCIconWindow, XtRWindow, sizeof(Window),
+ Offset(wm.wm_hints.icon_window), XtRWindow, (XtPointer) NULL},
+ { XtNiconX, XtCIconX, XtRInt, sizeof(int),
+ Offset(wm.wm_hints.icon_x),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+ { XtNiconY, XtCIconY, XtRInt, sizeof(int),
+ Offset(wm.wm_hints.icon_y),
+ XtRInt, (XtPointer) &default_unspecified_shell_int},
+ { XtNiconMask, XtCIconMask, XtRBitmap, sizeof(Pixmap),
+ Offset(wm.wm_hints.icon_mask), XtRPixmap, NULL},
+ { XtNwindowGroup, XtCWindowGroup, XtRWindow, sizeof(Window),
+ Offset(wm.wm_hints.window_group),
+ XtRImmediate, (XtPointer)XtUnspecifiedWindow},
+ { XtNclientLeader, XtCClientLeader, XtRWidget, sizeof(Widget),
+ Offset(wm.client_leader), XtRWidget, NULL},
+ { XtNwindowRole, XtCWindowRole, XtRString, sizeof(String),
+ Offset(wm.window_role), XtRString, (XtPointer) NULL},
+ { XtNurgency, XtCUrgency, XtRBoolean, sizeof(Boolean),
+ Offset(wm.urgency), XtRImmediate, (XtPointer) False}
+};
+
+static void WMInitialize(Widget, Widget, ArgList, Cardinal *);
+static Boolean WMSetValues(Widget, Widget, Widget, ArgList, Cardinal *);
+static void WMDestroy(Widget);
+
+externaldef(wmshellclassrec) WMShellClassRec wmShellClassRec = {
+ {
+ /* superclass */ (WidgetClass) &shellClassRec,
+ /* class_name */ "WMShell",
+ /* size */ sizeof(WMShellRec),
+ /* Class Initializer */ NULL,
+ /* class_part_initialize*/ NULL,
+ /* Class init'ed ? */ FALSE,
+ /* initialize */ WMInitialize,
+ /* initialize_notify */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ wmResources,
+ /* resource_count */ XtNumber(wmResources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ WMDestroy,
+ /* resize */ XtInheritResize,
+ /* expose */ NULL,
+ /* set_values */ WMSetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL
+ },{
+ /* geometry_manager */ XtInheritGeometryManager,
+ /* change_managed */ XtInheritChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ }
+};
+
+externaldef(wmshellwidgetclass) WidgetClass wmShellWidgetClass = (WidgetClass) (&wmShellClassRec);
+
+/***************************************************************************
+ *
+ * TransientShell class record
+ *
+ ***************************************************************************/
+
+#undef Offset
+#define Offset(x) (XtOffsetOf(TransientShellRec, x))
+
+static XtResource transientResources[]=
+{
+ { XtNtransient, XtCTransient, XtRBoolean, sizeof(Boolean),
+ Offset(wm.transient), XtRImmediate, (XtPointer)True},
+ { XtNtransientFor, XtCTransientFor, XtRWidget, sizeof(Widget),
+ Offset(transient.transient_for), XtRWidget, NULL},
+ { XtNsaveUnder, XtCSaveUnder, XtRBoolean, sizeof(Boolean),
+ Offset(shell.save_under), XtRImmediate, (XtPointer)True},
+};
+
+static void TransientRealize(Widget, Mask *, XSetWindowAttributes *);
+static Boolean TransientSetValues(Widget, Widget, Widget, ArgList, Cardinal *);
+
+externaldef(transientshellclassrec) TransientShellClassRec transientShellClassRec = {
+ {
+ /* superclass */ (WidgetClass) &vendorShellClassRec,
+ /* class_name */ "TransientShell",
+ /* size */ sizeof(TransientShellRec),
+ /* Class Initializer */ NULL,
+ /* class_part_initialize*/ NULL,
+ /* Class init'ed ? */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_notify */ NULL,
+ /* realize */ TransientRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ transientResources,
+ /* resource_count */ XtNumber(transientResources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ XtInheritResize,
+ /* expose */ NULL,
+ /* set_values */ TransientSetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ XtInheritTranslations,
+ /* query_geometry */ NULL,
+ /* display_accelerator*/ NULL,
+ /* extension */ NULL
+ },{
+ /* geometry_manager */ XtInheritGeometryManager,
+ /* change_managed */ XtInheritChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ }
+};
+
+externaldef(transientshellwidgetclass) WidgetClass transientShellWidgetClass =
+ (WidgetClass) (&transientShellClassRec);
+
+/***************************************************************************
+ *
+ * TopLevelShell class record
+ *
+ ***************************************************************************/
+
+#undef Offset
+#define Offset(x) (XtOffsetOf(TopLevelShellRec, x))
+
+static XtResource topLevelResources[]=
+{
+ { XtNiconName, XtCIconName, XtRString, sizeof(String),
+ Offset(topLevel.icon_name), XtRString, (XtPointer) NULL},
+ { XtNiconNameEncoding, XtCIconNameEncoding, XtRAtom, sizeof(Atom),
+ Offset(topLevel.icon_name_encoding),
+ XtRCallProc, (XtPointer) _XtTitleEncoding},
+ { XtNiconic, XtCIconic, XtRBoolean, sizeof(Boolean),
+ Offset(topLevel.iconic), XtRImmediate, (XtPointer)False}
+};
+
+static void TopLevelInitialize(Widget, Widget, ArgList, Cardinal *);
+static Boolean TopLevelSetValues(Widget, Widget, Widget, ArgList, Cardinal *);
+static void TopLevelDestroy(Widget);
+
+externaldef(toplevelshellclassrec) TopLevelShellClassRec topLevelShellClassRec = {
+ {
+ /* superclass */ (WidgetClass) &vendorShellClassRec,
+ /* class_name */ "TopLevelShell",
+ /* size */ sizeof(TopLevelShellRec),
+ /* Class Initializer */ NULL,
+ /* class_part_initialize*/ NULL,
+ /* Class init'ed ? */ FALSE,
+ /* initialize */ TopLevelInitialize,
+ /* initialize_notify */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ topLevelResources,
+ /* resource_count */ XtNumber(topLevelResources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ TopLevelDestroy,
+ /* resize */ XtInheritResize,
+ /* expose */ NULL,
+ /* set_values */ TopLevelSetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ XtInheritTranslations,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL
+ },{
+ /* geometry_manager */ XtInheritGeometryManager,
+ /* change_managed */ XtInheritChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ }
+};
+
+externaldef(toplevelshellwidgetclass) WidgetClass topLevelShellWidgetClass =
+ (WidgetClass) (&topLevelShellClassRec);
+
+/***************************************************************************
+ *
+ * ApplicationShell class record
+ *
+ ***************************************************************************/
+
+#undef Offset
+#define Offset(x) (XtOffsetOf(ApplicationShellRec, x))
+
+static XtResource applicationResources[]=
+{
+ {XtNargc, XtCArgc, XtRInt, sizeof(int),
+ Offset(application.argc), XtRImmediate, (XtPointer)0},
+ {XtNargv, XtCArgv, XtRStringArray, sizeof(String*),
+ Offset(application.argv), XtRPointer, (XtPointer) NULL}
+};
+#undef Offset
+
+static void ApplicationInitialize(Widget, Widget, ArgList, Cardinal *);
+static void ApplicationDestroy(Widget);
+static Boolean ApplicationSetValues(Widget, Widget, Widget, ArgList, Cardinal *);
+static void ApplicationShellInsertChild(Widget);
+
+static CompositeClassExtensionRec compositeClassExtension = {
+ /* next_extension */ NULL,
+ /* record_type */ NULLQUARK,
+ /* version */ XtCompositeExtensionVersion,
+ /* record_size */ sizeof(CompositeClassExtensionRec),
+ /* accepts_objects */ TRUE,
+ /* allows_change_managed_set */ FALSE
+};
+
+
+externaldef(applicationshellclassrec) ApplicationShellClassRec applicationShellClassRec = {
+ {
+ /* superclass */ (WidgetClass) &topLevelShellClassRec,
+ /* class_name */ "ApplicationShell",
+ /* size */ sizeof(ApplicationShellRec),
+ /* Class Initializer */ NULL,
+ /* class_part_initialize*/ NULL,
+ /* Class init'ed ? */ FALSE,
+ /* initialize */ ApplicationInitialize,
+ /* initialize_notify */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ applicationResources,
+ /* resource_count */ XtNumber(applicationResources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ ApplicationDestroy,
+ /* resize */ XtInheritResize,
+ /* expose */ NULL,
+ /* set_values */ ApplicationSetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ XtInheritTranslations,
+ /* query_geometry */ NULL,
+ /* display_accelerator*/ NULL,
+ /* extension */ NULL
+ },{
+ /* geometry_manager */ XtInheritGeometryManager,
+ /* change_managed */ XtInheritChangeManaged,
+ /* insert_child */ ApplicationShellInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ (XtPointer)&compositeClassExtension
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ }
+};
+
+externaldef(applicationshellwidgetclass) WidgetClass applicationShellWidgetClass =
+ (WidgetClass) (&applicationShellClassRec);
+
+/***************************************************************************
+ *
+ * SessionShell class record
+ *
+ ***************************************************************************/
+
+#undef Offset
+#define Offset(x) (XtOffsetOf(SessionShellRec, x))
+
+static XtResource sessionResources[]=
+{
+#ifndef XT_NO_SM
+ {XtNconnection, XtCConnection, XtRSmcConn, sizeof(SmcConn),
+ Offset(session.connection), XtRSmcConn, (XtPointer) NULL},
+#endif
+ {XtNsessionID, XtCSessionID, XtRString, sizeof(String),
+ Offset(session.session_id), XtRString, (XtPointer) NULL},
+ {XtNrestartCommand, XtCRestartCommand, XtRCommandArgArray, sizeof(String*),
+ Offset(session.restart_command), XtRPointer, (XtPointer) NULL},
+ {XtNcloneCommand, XtCCloneCommand, XtRCommandArgArray, sizeof(String*),
+ Offset(session.clone_command), XtRPointer, (XtPointer) NULL},
+ {XtNdiscardCommand, XtCDiscardCommand, XtRCommandArgArray, sizeof(String*),
+ Offset(session.discard_command), XtRPointer, (XtPointer) NULL},
+ {XtNresignCommand, XtCResignCommand, XtRCommandArgArray, sizeof(String*),
+ Offset(session.resign_command), XtRPointer, (XtPointer) NULL},
+ {XtNshutdownCommand, XtCShutdownCommand, XtRCommandArgArray, sizeof(String*),
+ Offset(session.shutdown_command), XtRPointer, (XtPointer) NULL},
+ {XtNenvironment, XtCEnvironment, XtREnvironmentArray, sizeof(String*),
+ Offset(session.environment), XtRPointer, (XtPointer) NULL},
+ {XtNcurrentDirectory, XtCCurrentDirectory, XtRDirectoryString, sizeof(String),
+ Offset(session.current_dir), XtRString, (XtPointer) NULL},
+ {XtNprogramPath, XtCProgramPath, XtRString, sizeof(String),
+ Offset(session.program_path), XtRString, (XtPointer) NULL},
+ {XtNrestartStyle, XtCRestartStyle, XtRRestartStyle, sizeof(unsigned char),
+ Offset(session.restart_style), XtRImmediate,
+ (XtPointer) SmRestartIfRunning},
+ {XtNjoinSession, XtCJoinSession, XtRBoolean, sizeof(Boolean),
+ Offset(session.join_session), XtRImmediate, (XtPointer) True},
+ {XtNsaveCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
+ Offset(session.save_callbacks), XtRCallback, (XtPointer) NULL},
+ {XtNinteractCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
+ Offset(session.interact_callbacks), XtRCallback, (XtPointer)NULL},
+ {XtNcancelCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
+ Offset(session.cancel_callbacks), XtRCallback, (XtPointer) NULL},
+ {XtNsaveCompleteCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
+ Offset(session.save_complete_callbacks), XtRCallback, (XtPointer) NULL},
+ {XtNdieCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
+ Offset(session.die_callbacks), XtRCallback, (XtPointer) NULL},
+ {XtNerrorCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
+ Offset(session.error_callbacks), XtRCallback, (XtPointer) NULL}
+};
+#undef Offset
+
+static void SessionInitialize(Widget, Widget, ArgList, Cardinal *);
+static void SessionDestroy(Widget);
+static Boolean SessionSetValues(Widget, Widget, Widget, ArgList, Cardinal *);
+
+static CompositeClassExtensionRec sessionCompositeClassExtension = {
+ /* next_extension */ NULL,
+ /* record_type */ NULLQUARK,
+ /* version */ XtCompositeExtensionVersion,
+ /* record_size */ sizeof(CompositeClassExtensionRec),
+ /* accepts_objects */ TRUE,
+ /* allows_change_managed_set */ FALSE
+};
+
+
+externaldef(sessionshellclassrec) SessionShellClassRec sessionShellClassRec = {
+ {
+ /* superclass */ (WidgetClass) &applicationShellClassRec,
+ /* class_name */ "SessionShell",
+ /* size */ sizeof(SessionShellRec),
+ /* Class Initializer */ NULL,
+ /* class_part_initialize*/ NULL,
+ /* Class init'ed ? */ FALSE,
+ /* initialize */ SessionInitialize,
+ /* initialize_notify */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ sessionResources,
+ /* resource_count */ XtNumber(sessionResources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ SessionDestroy,
+ /* resize */ XtInheritResize,
+ /* expose */ NULL,
+ /* set_values */ SessionSetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ XtInheritTranslations,
+ /* query_geometry */ NULL,
+ /* display_accelerator*/ NULL,
+ /* extension */ NULL
+ },{
+ /* geometry_manager */ XtInheritGeometryManager,
+ /* change_managed */ XtInheritChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ (XtPointer)&sessionCompositeClassExtension
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ }
+};
+
+externaldef(sessionshellwidgetclass) WidgetClass sessionShellWidgetClass =
+ (WidgetClass) (&sessionShellClassRec);
+
+/****************************************************************************
+ * Whew!
+ ****************************************************************************/
+
+static void ComputeWMSizeHints(
+ WMShellWidget w,
+ XSizeHints *hints)
+{
+ register long flags;
+ hints->flags = flags = w->wm.size_hints.flags;
+#define copy(field) hints->field = w->wm.size_hints.field
+ if (flags & (USPosition | PPosition)) {
+ copy(x);
+ copy(y);
+ }
+ if (flags & (USSize | PSize)) {
+ copy(width);
+ copy(height);
+ }
+ if (flags & PMinSize) {
+ copy(min_width);
+ copy(min_height);
+ }
+ if (flags & PMaxSize) {
+ copy(max_width);
+ copy(max_height);
+ }
+ if (flags & PResizeInc) {
+ copy(width_inc);
+ copy(height_inc);
+ }
+ if (flags & PAspect) {
+ copy(min_aspect.x);
+ copy(min_aspect.y);
+ copy(max_aspect.x);
+ copy(max_aspect.y);
+ }
+#undef copy
+#define copy(field) hints->field = w->wm.field
+ if (flags & PBaseSize) {
+ copy(base_width);
+ copy(base_height);
+ }
+ if (flags & PWinGravity)
+ copy(win_gravity);
+#undef copy
+}
+
+static void _SetWMSizeHints(
+ WMShellWidget w)
+{
+ XSizeHints *size_hints = XAllocSizeHints();
+
+ if (size_hints == NULL) _XtAllocError("XAllocSizeHints");
+ ComputeWMSizeHints(w, size_hints);
+ XSetWMNormalHints(XtDisplay((Widget)w), XtWindow((Widget)w), size_hints);
+ XFree((char*)size_hints);
+}
+
+static ShellClassExtension _FindClassExtension(
+ WidgetClass widget_class)
+{
+ ShellClassExtension ext;
+ for (ext = (ShellClassExtension)((ShellWidgetClass)widget_class)
+ ->shell_class.extension;
+ ext != NULL && ext->record_type != NULLQUARK;
+ ext = (ShellClassExtension)ext->next_extension);
+
+ if (ext != NULL) {
+ if ( ext->version == XtShellExtensionVersion
+ && ext->record_size == sizeof(ShellClassExtensionRec)) {
+ /* continue */
+ } else {
+ String params[1];
+ Cardinal num_params = 1;
+ params[0] = widget_class->core_class.class_name;
+ XtErrorMsg( "invalidExtension", "shellClassPartInitialize",
+ XtCXtToolkitError,
+ "widget class %s has invalid ShellClassExtension record",
+ params, &num_params);
+ }
+ }
+ return ext;
+}
+
+static void ClassPartInitialize(WidgetClass widget_class)
+{
+ ShellClassExtension ext = _FindClassExtension(widget_class);
+ if (ext != NULL) {
+ if (ext->root_geometry_manager == XtInheritRootGeometryManager) {
+ ext->root_geometry_manager =
+ _FindClassExtension(widget_class->core_class.superclass)
+ ->root_geometry_manager;
+ }
+ } else {
+ /* if not found, spec requires XtInheritRootGeometryManager */
+ XtPointer *extP
+ = &((ShellWidgetClass)widget_class)->shell_class.extension;
+ ext = XtNew(ShellClassExtensionRec);
+ (void) memmove((char*)ext,
+ (char*)_FindClassExtension(widget_class->core_class.superclass),
+ sizeof(ShellClassExtensionRec));
+ ext->next_extension = *extP;
+ *extP = (XtPointer)ext;
+ }
+}
+
+
+static void EventHandler(Widget wid, XtPointer closure, XEvent *event, Boolean *continue_to_dispatch);
+static void _popup_set_prop(ShellWidget);
+
+
+/*ARGSUSED*/
+static void XtCopyDefaultDepth(
+ Widget widget,
+ int offset,
+ XrmValue *value)
+{
+ value->addr = (XPointer)(&DefaultDepthOfScreen(XtScreenOfObject(widget)));
+}
+
+#ifndef CRAY
+static
+#endif
+void _XtShellDepth(
+ Widget widget,
+ int closure,
+ XrmValue *value)
+{
+ if (widget->core.parent == NULL) XtCopyDefaultDepth(widget,closure,value);
+ else _XtCopyFromParent (widget,closure,value);
+}
+
+/*ARGSUSED*/
+static void XtCopyDefaultColormap(
+ Widget widget,
+ int offset,
+ XrmValue *value)
+{
+ value->addr = (XPointer)(&DefaultColormapOfScreen(XtScreenOfObject(widget)));
+}
+
+#ifndef CRAY
+static
+#endif
+void _XtShellColormap(
+ Widget widget,
+ int closure,
+ XrmValue *value)
+{
+ if (widget->core.parent == NULL)
+ XtCopyDefaultColormap(widget,closure,value);
+ else _XtCopyFromParent (widget,closure,value);
+}
+
+#ifndef CRAY
+static
+#endif
+void _XtShellAncestorSensitive(
+ Widget widget,
+ int closure,
+ XrmValue *value)
+{
+ static Boolean true = True;
+ if (widget->core.parent == NULL) value->addr = (XPointer)(&true);
+ else _XtCopyFromParent (widget,closure,value);
+}
+
+/*ARGSUSED*/
+#ifndef CRAY
+static
+#endif
+void _XtTitleEncoding(
+ Widget widget,
+ int offset,
+ XrmValue *value)
+{
+ static Atom atom;
+ if (XtWidgetToApplicationContext(widget)->langProcRec.proc) atom = None;
+ else atom = XA_STRING;
+ value->addr = (XPointer) &atom;
+}
+
+
+/* ARGSUSED */
+static void Initialize(
+ Widget req,
+ Widget new,
+ ArgList args, /* unused */
+ Cardinal *num_args) /* unused */
+{
+ ShellWidget w = (ShellWidget) new;
+
+ w->shell.popped_up = FALSE;
+ w->shell.client_specified =
+ _XtShellNotReparented | _XtShellPositionValid;
+
+ if (w->core.x == BIGSIZE) {
+ w->core.x = 0;
+ if (w->core.y == BIGSIZE) w->core.y = 0;
+ } else {
+ if (w->core.y == BIGSIZE) w->core.y = 0;
+ else w->shell.client_specified |= _XtShellPPositionOK;
+ }
+
+ XtAddEventHandler(new, (EventMask) StructureNotifyMask,
+ TRUE, EventHandler, (XtPointer) NULL);
+
+#ifdef EDITRES
+ XtAddEventHandler(new, (EventMask) 0, TRUE,
+ _XEditResCheckMessages, NULL);
+#endif
+}
+
+/* ARGSUSED */
+static void WMInitialize(
+ Widget req, Widget new,
+ ArgList args, /* unused */
+ Cardinal *num_args) /* unused */
+{
+ WMShellWidget w = (WMShellWidget) new;
+ TopLevelShellWidget tls = (TopLevelShellWidget) new; /* maybe */
+
+ if(w->wm.title == NULL) {
+ if (XtIsTopLevelShell(new) &&
+ tls->topLevel.icon_name != NULL &&
+ strlen(tls->topLevel.icon_name) != 0) {
+ w->wm.title = XtNewString(tls->topLevel.icon_name);
+ } else {
+ w->wm.title = XtNewString(w->core.name);
+ }
+ } else {
+ w->wm.title = XtNewString(w->wm.title);
+ }
+ w->wm.size_hints.flags = 0;
+ w->wm.wm_hints.flags = 0;
+ if (w->wm.window_role)
+ w->wm.window_role = XtNewString(w->wm.window_role);
+}
+
+
+/* ARGSUSED */
+static void TopLevelInitialize(
+ Widget req, Widget new,
+ ArgList args, /* unused */
+ Cardinal *num_args) /* unused */
+{
+ TopLevelShellWidget w = (TopLevelShellWidget) new;
+
+ if (w->topLevel.icon_name == NULL) {
+ w->topLevel.icon_name = XtNewString(w->core.name);
+ } else {
+ w->topLevel.icon_name = XtNewString(w->topLevel.icon_name);
+ }
+
+ if (w->topLevel.iconic)
+ w->wm.wm_hints.initial_state = IconicState;
+}
+
+static String *NewArgv(int, String *);
+static String *NewStringArray(String *);
+static void FreeStringArray(String *);
+
+/* ARGSUSED */
+static void ApplicationInitialize(
+ Widget req, Widget new,
+ ArgList args, /* unused */
+ Cardinal *num_args) /* unused */
+{
+ ApplicationShellWidget w = (ApplicationShellWidget)new;
+
+ if (w->application.argc > 0)
+ w->application.argv = NewArgv(w->application.argc,
+ w->application.argv);
+}
+
+#define XtSaveInactive 0
+#define XtSaveActive 1
+#define XtInteractPending 2
+#define XtInteractActive 3
+
+#define XtCloneCommandMask (1L<<0)
+#define XtCurrentDirectoryMask (1L<<1)
+#define XtDiscardCommandMask (1L<<2)
+#define XtEnvironmentMask (1L<<3)
+#define XtProgramMask (1L<<4)
+#define XtResignCommandMask (1L<<5)
+#define XtRestartCommandMask (1L<<6)
+#define XtRestartStyleHintMask (1L<<7)
+#define XtShutdownCommandMask (1L<<8)
+
+static void JoinSession(SessionShellWidget);
+static void SetSessionProperties(SessionShellWidget, Boolean, unsigned long, unsigned long);
+static void StopManagingSession(SessionShellWidget, SmcConn);
+
+typedef struct _XtSaveYourselfRec {
+ XtSaveYourself next;
+ int save_type;
+ int interact_style;
+ Boolean shutdown;
+ Boolean fast;
+ Boolean cancel_shutdown;
+ int phase;
+ int interact_dialog_type;
+ Boolean request_cancel;
+ Boolean request_next_phase;
+ Boolean save_success;
+ int save_tokens;
+ int interact_tokens;
+} XtSaveYourselfRec;
+
+/* ARGSUSED */
+static void SessionInitialize(
+ Widget req, Widget new,
+ ArgList args, /* unused */
+ Cardinal *num_args) /* unused */
+{
+#ifndef XT_NO_SM
+ SessionShellWidget w = (SessionShellWidget)new;
+
+ if (w->session.session_id) w->session.session_id =
+ XtNewString(w->session.session_id);
+ if (w->session.restart_command) w->session.restart_command =
+ NewStringArray(w->session.restart_command);
+ if (w->session.clone_command) w->session.clone_command =
+ NewStringArray(w->session.clone_command);
+ if (w->session.discard_command) w->session.discard_command =
+ NewStringArray(w->session.discard_command);
+ if (w->session.resign_command) w->session.resign_command =
+ NewStringArray(w->session.resign_command);
+ if (w->session.shutdown_command) w->session.shutdown_command =
+ NewStringArray(w->session.shutdown_command);
+ if (w->session.environment) w->session.environment =
+ NewStringArray(w->session.environment);
+ if (w->session.current_dir) w->session.current_dir =
+ XtNewString(w->session.current_dir);
+ if (w->session.program_path) w->session.program_path =
+ XtNewString(w->session.program_path);
+
+ w->session.checkpoint_state = XtSaveInactive;
+ w->session.input_id = 0;
+ w->session.save = NULL;
+
+ if ((w->session.join_session) &&
+ (w->application.argv || w->session.restart_command))
+ JoinSession(w);
+
+ if (w->session.connection)
+ SetSessionProperties(w, True, 0L, 0L);
+#endif /* !XT_NO_SM */
+}
+
+static void Resize(
+ Widget w)
+{
+ register ShellWidget sw = (ShellWidget)w;
+ Widget childwid;
+ Cardinal i;
+ for(i = 0; i < sw->composite.num_children; i++) {
+ if (XtIsManaged(sw->composite.children[i])) {
+ childwid = sw->composite.children[i];
+ XtResizeWidget(childwid, sw->core.width, sw->core.height,
+ childwid->core.border_width);
+ break; /* can only be one managed child */
+ }
+ }
+}
+
+static void GetGeometry(Widget, Widget);
+
+static void Realize(
+ Widget wid,
+ Mask *vmask,
+ XSetWindowAttributes *attr)
+{
+ ShellWidget w = (ShellWidget) wid;
+ Mask mask = *vmask;
+
+ if (! (w->shell.client_specified & _XtShellGeometryParsed)) {
+ /* we'll get here only if there was no child the first
+ time we were realized. If the shell was Unrealized
+ and then re-Realized, we probably don't want to
+ re-evaluate the defaults anyway.
+ */
+ GetGeometry(wid, (Widget)NULL);
+ }
+ else if (w->core.background_pixmap == XtUnspecifiedPixmap) {
+ /* I attempt to inherit my child's background to avoid screen flash
+ * if there is latency between when I get resized and when my child
+ * is resized. Background=None is not satisfactory, as I want the
+ * user to get immediate feedback on the new dimensions (most
+ * particularly in the case of a non-reparenting wm). It is
+ * especially important to have the server clear any old cruft
+ * from the display when I am resized larger.
+ */
+ register Widget *childP = w->composite.children;
+ int i;
+ for (i = w->composite.num_children; i; i--, childP++) {
+ if (XtIsWidget(*childP) && XtIsManaged(*childP)) {
+ if ((*childP)->core.background_pixmap
+ != XtUnspecifiedPixmap) {
+ mask &= ~(CWBackPixel);
+ mask |= CWBackPixmap;
+ attr->background_pixmap =
+ w->core.background_pixmap =
+ (*childP)->core.background_pixmap;
+ } else {
+ attr->background_pixel =
+ w->core.background_pixel =
+ (*childP)->core.background_pixel;
+ }
+ break;
+ }
+ }
+ }
+
+ if(w->shell.save_under) {
+ mask |= CWSaveUnder;
+ attr->save_under = TRUE;
+ }
+ if(w->shell.override_redirect) {
+ mask |= CWOverrideRedirect;
+ attr->override_redirect = TRUE;
+ }
+ if (wid->core.width == 0 || wid->core.height == 0) {
+ Cardinal count = 1;
+ XtErrorMsg("invalidDimension", "shellRealize", XtCXtToolkitError,
+ "Shell widget %s has zero width and/or height",
+ &wid->core.name, &count);
+ }
+ wid->core.window = XCreateWindow(XtDisplay(wid),
+ wid->core.screen->root, (int)wid->core.x, (int)wid->core.y,
+ (unsigned int)wid->core.width, (unsigned int)wid->core.height,
+ (unsigned int)wid->core.border_width, (int) wid->core.depth,
+ (unsigned int) InputOutput, w->shell.visual,
+ mask, attr);
+
+ _popup_set_prop(w);
+}
+
+
+static void _SetTransientForHint(
+ TransientShellWidget w,
+ Boolean delete)
+{
+ Window window_group;
+
+ if (w->wm.transient) {
+ if (w->transient.transient_for != NULL
+ && XtIsRealized(w->transient.transient_for))
+ window_group = XtWindow(w->transient.transient_for);
+ else if ((window_group = w->wm.wm_hints.window_group)
+ == XtUnspecifiedWindowGroup) {
+ if (delete)
+ XDeleteProperty( XtDisplay((Widget)w),
+ XtWindow((Widget)w),
+ XA_WM_TRANSIENT_FOR
+ );
+ return;
+ }
+
+ XSetTransientForHint( XtDisplay((Widget)w),
+ XtWindow((Widget)w),
+ window_group
+ );
+ }
+}
+
+
+static void TransientRealize(
+ Widget w,
+ Mask *vmask,
+ XSetWindowAttributes *attr)
+{
+ XtRealizeProc realize;
+
+ LOCK_PROCESS;
+ realize =
+ transientShellWidgetClass->core_class.superclass->core_class.realize;
+ UNLOCK_PROCESS;
+ (*realize) (w, vmask, attr);
+
+ _SetTransientForHint((TransientShellWidget)w, False);
+}
+
+static Widget GetClientLeader(
+ Widget w)
+{
+ while ((! XtIsWMShell(w) || ! ((WMShellWidget)w)->wm.client_leader)
+ && w->core.parent)
+ w = w->core.parent;
+
+ /* ASSERT: w is a WMshell with client_leader set, or w has no parent */
+
+ if (XtIsWMShell(w) && ((WMShellWidget)w)->wm.client_leader)
+ w = ((WMShellWidget)w)->wm.client_leader;
+ return w;
+}
+
+static void EvaluateWMHints(
+ WMShellWidget w)
+{
+ XWMHints *hintp = &w->wm.wm_hints;
+
+ hintp->flags = StateHint | InputHint;
+
+ if (hintp->icon_x == XtUnspecifiedShellInt)
+ hintp->icon_x = -1;
+ else
+ hintp->flags |= IconPositionHint;
+
+ if (hintp->icon_y == XtUnspecifiedShellInt)
+ hintp->icon_y = -1;
+ else
+ hintp->flags |= IconPositionHint;
+
+ if (hintp->icon_pixmap != None) hintp->flags |= IconPixmapHint;
+ if (hintp->icon_mask != None) hintp->flags |= IconMaskHint;
+ if (hintp->icon_window != None) hintp->flags |= IconWindowHint;
+
+ if (hintp->window_group == XtUnspecifiedWindow) {
+ if(w->core.parent) {
+ Widget p;
+ for (p = w->core.parent; p->core.parent; p = p->core.parent);
+ if (XtIsRealized(p)) {
+ hintp->window_group = XtWindow(p);
+ hintp->flags |= WindowGroupHint;
+ }
+ }
+ } else if (hintp->window_group != XtUnspecifiedWindowGroup)
+ hintp->flags |= WindowGroupHint;
+
+ if (w->wm.urgency) hintp->flags |= XUrgencyHint;
+}
+
+
+static void EvaluateSizeHints(
+ WMShellWidget w)
+{
+ struct _OldXSizeHints *sizep = &w->wm.size_hints;
+
+ sizep->x = w->core.x;
+ sizep->y = w->core.y;
+ sizep->width = w->core.width;
+ sizep->height = w->core.height;
+
+ if (sizep->flags & USSize) {
+ if (sizep->flags & PSize) sizep->flags &= ~PSize;
+ } else
+ sizep->flags |= PSize;
+
+ if (sizep->flags & USPosition) {
+ if (sizep->flags & PPosition) sizep->flags &= ~PPosition;
+ } else if (w->shell.client_specified & _XtShellPPositionOK)
+ sizep->flags |= PPosition;
+
+ if (sizep->min_aspect.x != XtUnspecifiedShellInt
+ || sizep->min_aspect.y != XtUnspecifiedShellInt
+ || sizep->max_aspect.x != XtUnspecifiedShellInt
+ || sizep->max_aspect.y != XtUnspecifiedShellInt) {
+ sizep->flags |= PAspect;
+ }
+ if (sizep->flags & PBaseSize
+ || w->wm.base_width != XtUnspecifiedShellInt
+ || w->wm.base_height != XtUnspecifiedShellInt) {
+ sizep->flags |= PBaseSize;
+ if (w->wm.base_width == XtUnspecifiedShellInt)
+ w->wm.base_width = 0;
+ if (w->wm.base_height == XtUnspecifiedShellInt)
+ w->wm.base_height = 0;
+ }
+ if (sizep->flags & PResizeInc
+ || sizep->width_inc != XtUnspecifiedShellInt
+ || sizep->height_inc != XtUnspecifiedShellInt) {
+ if (sizep->width_inc < 1) sizep->width_inc = 1;
+ if (sizep->height_inc < 1) sizep->height_inc = 1;
+ sizep->flags |= PResizeInc;
+ }
+ if (sizep->flags & PMaxSize
+ || sizep->max_width != XtUnspecifiedShellInt
+ || sizep->max_height != XtUnspecifiedShellInt) {
+ sizep->flags |= PMaxSize;
+ if (sizep->max_width == XtUnspecifiedShellInt)
+ sizep->max_width = BIGSIZE;
+ if (sizep->max_height == XtUnspecifiedShellInt)
+ sizep->max_height = BIGSIZE;
+ }
+ if (sizep->flags & PMinSize
+ || sizep->min_width != XtUnspecifiedShellInt
+ || sizep->min_height != XtUnspecifiedShellInt) {
+ sizep->flags |= PMinSize;
+ if (sizep->min_width == XtUnspecifiedShellInt)
+ sizep->min_width = 1;
+ if (sizep->min_height == XtUnspecifiedShellInt)
+ sizep->min_height = 1;
+ }
+}
+
+static void _popup_set_prop(
+ ShellWidget w)
+{
+ Widget p;
+ WMShellWidget wmshell = (WMShellWidget) w;
+ TopLevelShellWidget tlshell = (TopLevelShellWidget) w;
+ ApplicationShellWidget appshell = (ApplicationShellWidget) w;
+ XTextProperty icon_name;
+ XTextProperty window_name;
+ char **argv;
+ int argc;
+ XSizeHints *size_hints;
+ Window window_group;
+ XClassHint classhint;
+ Boolean copied_iname, copied_wname;
+
+ if (!XtIsWMShell((Widget)w) || w->shell.override_redirect) return;
+
+ if ((size_hints = XAllocSizeHints()) == NULL)
+ _XtAllocError("XAllocSizeHints");
+
+ copied_iname = copied_wname = False;
+ if (wmshell->wm.title_encoding == None &&
+ XmbTextListToTextProperty(XtDisplay((Widget)w),
+ (char**)&wmshell->wm.title,
+ 1, XStdICCTextStyle,
+ &window_name) >= Success) {
+ copied_wname = True;
+ } else {
+ window_name.value = (unsigned char*)wmshell->wm.title;
+ window_name.encoding = wmshell->wm.title_encoding ?
+ wmshell->wm.title_encoding : XA_STRING;
+ window_name.format = 8;
+ window_name.nitems = strlen((char *)window_name.value);
+ }
+
+ if (XtIsTopLevelShell((Widget)w)) {
+ if (tlshell->topLevel.icon_name_encoding == None &&
+ XmbTextListToTextProperty(XtDisplay((Widget)w),
+ (char**)&tlshell->topLevel.icon_name,
+ 1, XStdICCTextStyle,
+ &icon_name) >= Success) {
+ copied_iname = True;
+ } else {
+ icon_name.value = (unsigned char*)tlshell->topLevel.icon_name;
+ icon_name.encoding = tlshell->topLevel.icon_name_encoding ?
+ tlshell->topLevel.icon_name_encoding : XA_STRING;
+ icon_name.format = 8;
+ icon_name.nitems = strlen((char *)icon_name.value);
+ }
+ }
+
+ EvaluateWMHints(wmshell);
+ EvaluateSizeHints(wmshell);
+ ComputeWMSizeHints(wmshell, size_hints);
+
+ if (wmshell->wm.transient
+ && !XtIsTransientShell((Widget)w)
+ && (window_group = wmshell->wm.wm_hints.window_group)
+ != XtUnspecifiedWindowGroup) {
+
+ XSetTransientForHint(XtDisplay((Widget)w),
+ XtWindow((Widget)w),
+ window_group
+ );
+ }
+
+ classhint.res_name = w->core.name;
+ /* For the class, look up to the top of the tree */
+ for (p = (Widget)w; p->core.parent != NULL; p = p->core.parent);
+ if (XtIsApplicationShell(p)) {
+ classhint.res_class =
+ ((ApplicationShellWidget)p)->application.class;
+ } else {
+ LOCK_PROCESS;
+ classhint.res_class = XtClass(p)->core_class.class_name;
+ UNLOCK_PROCESS;
+ }
+
+ if (XtIsApplicationShell((Widget)w)
+ && (argc = appshell->application.argc) != -1)
+ argv = (char**)appshell->application.argv;
+ else {
+ argv = NULL;
+ argc = 0;
+ }
+
+ XSetWMProperties(XtDisplay((Widget)w), XtWindow((Widget)w),
+ &window_name,
+ (XtIsTopLevelShell((Widget)w)) ? &icon_name : NULL,
+ argv, argc,
+ size_hints,
+ &wmshell->wm.wm_hints,
+ &classhint);
+ XFree((char*)size_hints);
+ if (copied_wname)
+ XFree((XPointer)window_name.value);
+ if (copied_iname)
+ XFree((XPointer)icon_name.value);
+
+ LOCK_PROCESS;
+ if (XtWidgetToApplicationContext((Widget)w)->langProcRec.proc) {
+ char *locale = setlocale(LC_CTYPE, (char *)NULL);
+ if (locale)
+ XChangeProperty(XtDisplay((Widget)w), XtWindow((Widget)w),
+ XInternAtom(XtDisplay((Widget)w),
+ "WM_LOCALE_NAME", False),
+ XA_STRING, 8, PropModeReplace,
+ (unsigned char *)locale, strlen(locale));
+ }
+ UNLOCK_PROCESS;
+
+ p = GetClientLeader((Widget)w);
+ if (XtWindow(p))
+ XChangeProperty(XtDisplay((Widget)w), XtWindow((Widget)w),
+ XInternAtom(XtDisplay((Widget)w),
+ "WM_CLIENT_LEADER", False),
+ XA_WINDOW, 32, PropModeReplace,
+ (unsigned char *)(&(p->core.window)), 1);
+#ifndef XT_NO_SM
+ if (p == (Widget) w) {
+ for ( ; p->core.parent != NULL; p = p->core.parent);
+ if (XtIsSubclass(p, sessionShellWidgetClass)) {
+ String sm_client_id =
+ ((SessionShellWidget)p)->session.session_id;
+ if (sm_client_id != NULL) {
+ XChangeProperty(XtDisplay((Widget)w), XtWindow((Widget)w),
+ XInternAtom(XtDisplay((Widget)w),
+ "SM_CLIENT_ID", False),
+ XA_STRING, 8, PropModeReplace,
+ (unsigned char *) sm_client_id,
+ strlen(sm_client_id));
+ }
+ }
+ }
+#endif /* !XT_NO_SM */
+
+ if (wmshell->wm.window_role)
+ XChangeProperty(XtDisplay((Widget)w), XtWindow((Widget)w),
+ XInternAtom(XtDisplay((Widget)w),
+ "WM_WINDOW_ROLE", False),
+ XA_STRING, 8, PropModeReplace,
+ (unsigned char *)wmshell->wm.window_role,
+ strlen(wmshell->wm.window_role));
+}
+
+/* ARGSUSED */
+static void EventHandler(
+ Widget wid,
+ XtPointer closure, /* unused */
+ XEvent *event,
+ Boolean *continue_to_dispatch) /* unused */
+{
+ register ShellWidget w = (ShellWidget) wid;
+ WMShellWidget wmshell = (WMShellWidget) w;
+ Boolean sizechanged = FALSE;
+
+ if(w->core.window != event->xany.window) {
+ XtAppErrorMsg(XtWidgetToApplicationContext(wid),
+ "invalidWindow","eventHandler",XtCXtToolkitError,
+ "Event with wrong window",
+ (String *)NULL, (Cardinal *)NULL);
+ return;
+ }
+
+ switch(event->type) {
+ case ConfigureNotify:
+ if (w->core.window != event->xconfigure.window)
+ return; /* in case of SubstructureNotify */
+#define NEQ(x) ( w->core.x != event->xconfigure.x )
+ if( NEQ(width) || NEQ(height) || NEQ(border_width) ) {
+ sizechanged = TRUE;
+#undef NEQ
+ w->core.width = event->xconfigure.width;
+ w->core.height = event->xconfigure.height;
+ w->core.border_width = event->xconfigure.border_width;
+ }
+ if (event->xany.send_event /* ICCCM compliant synthetic ev */
+ /* || w->shell.override_redirect */
+ || w->shell.client_specified & _XtShellNotReparented)
+ {
+ w->core.x = event->xconfigure.x;
+ w->core.y = event->xconfigure.y;
+ w->shell.client_specified |= _XtShellPositionValid;
+ }
+ else w->shell.client_specified &= ~_XtShellPositionValid;
+ if (XtIsWMShell(wid) && !wmshell->wm.wait_for_wm) {
+ /* Consider trusting the wm again */
+ register struct _OldXSizeHints *hintp
+ = &wmshell->wm.size_hints;
+#define EQ(x) (hintp->x == w->core.x)
+ if (EQ(x) && EQ(y) && EQ(width) && EQ(height)) {
+ wmshell->wm.wait_for_wm = TRUE;
+ }
+#undef EQ
+ }
+ break;
+
+ case ReparentNotify:
+ if (event->xreparent.window == XtWindow(w)) {
+ if (event->xreparent.parent !=
+ RootWindowOfScreen(XtScreen(w)))
+ w->shell.client_specified &=
+ ~(_XtShellNotReparented | _XtShellPositionValid);
+ else {
+ w->core.x = event->xreparent.x;
+ w->core.y = event->xreparent.y;
+ w->shell.client_specified |=
+ (_XtShellNotReparented | _XtShellPositionValid);
+ }
+ }
+ return;
+
+ case MapNotify:
+ if (XtIsTopLevelShell(wid)) {
+ ((TopLevelShellWidget)wid)->topLevel.iconic = FALSE;
+ }
+ return;
+
+ case UnmapNotify:
+ {
+ XtPerDisplayInput pdi;
+ XtDevice device;
+ Widget p;
+
+ if (XtIsTopLevelShell(wid))
+ ((TopLevelShellWidget)wid)->topLevel.iconic = TRUE;
+
+ pdi = _XtGetPerDisplayInput(event->xunmap.display);
+
+ device = &pdi->pointer;
+ if (device->grabType == XtPassiveServerGrab) {
+ p = device->grab.widget;
+ while (p && !(XtIsShell(p)))
+ p = p->core.parent;
+ if (p == wid)
+ device->grabType = XtNoServerGrab;
+ }
+
+ device = &pdi->keyboard;
+ if (IsEitherPassiveGrab(device->grabType)) {
+ p = device->grab.widget;
+ while (p && !(XtIsShell(p)))
+ p = p->core.parent;
+ if (p == wid) {
+ device->grabType = XtNoServerGrab;
+ pdi->activatingKey = 0;
+ }
+ }
+
+ return;
+ }
+ default:
+ return;
+ }
+ {
+ XtWidgetProc resize;
+
+ LOCK_PROCESS;
+ resize = XtClass(wid)->core_class.resize;
+ UNLOCK_PROCESS;
+
+ if (sizechanged && resize) {
+ CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "Shell \"%s\" is being resized to %d %d.\n",
+ XtName(wid), wid->core.width, wid->core.height ));
+ (*resize)(wid);
+ }
+ }
+}
+
+static void Destroy(
+ Widget wid)
+{
+ if (XtIsRealized(wid))
+ XDestroyWindow( XtDisplay(wid), XtWindow(wid) );
+}
+
+static void WMDestroy(
+ Widget wid)
+{
+ WMShellWidget w = (WMShellWidget) wid;
+
+ XtFree((char *) w->wm.title);
+ XtFree((char *) w->wm.window_role);
+}
+
+static void TopLevelDestroy(
+ Widget wid)
+{
+ TopLevelShellWidget w = (TopLevelShellWidget) wid;
+
+ XtFree((char *) w->topLevel.icon_name);
+}
+
+static void ApplicationDestroy(
+ Widget wid)
+{
+ ApplicationShellWidget w = (ApplicationShellWidget) wid;
+ if (w->application.argc > 0)
+ FreeStringArray(w->application.argv);
+}
+
+static void SessionDestroy(
+ Widget wid)
+{
+#ifndef XT_NO_SM
+ SessionShellWidget w = (SessionShellWidget) wid;
+
+ StopManagingSession(w, w->session.connection);
+ XtFree(w->session.session_id);
+ FreeStringArray(w->session.restart_command);
+ FreeStringArray(w->session.clone_command);
+ FreeStringArray(w->session.discard_command);
+ FreeStringArray(w->session.resign_command);
+ FreeStringArray(w->session.shutdown_command);
+ FreeStringArray(w->session.environment);
+ XtFree(w->session.current_dir);
+ XtFree(w->session.program_path);
+#endif /* !XT_NO_SM */
+}
+
+/*
+ * If the Shell has a width and a height which are zero, and as such
+ * suspect, and it has not yet been realized then it will grow to
+ * match the child before parsing the geometry resource.
+ *
+ */
+static void GetGeometry(
+ Widget W, Widget child)
+{
+ register ShellWidget w = (ShellWidget)W;
+ Boolean is_wmshell = XtIsWMShell(W);
+ int x, y, width, height, win_gravity = -1, flag;
+ XSizeHints hints;
+
+ if (child != NULL) {
+ /* we default to our child's size */
+ if (is_wmshell && (w->core.width == 0 || w->core.height == 0))
+ ((WMShellWidget)W)->wm.size_hints.flags |= PSize;
+ if (w->core.width == 0) w->core.width = child->core.width;
+ if (w->core.height == 0) w->core.height = child->core.height;
+ }
+ if(w->shell.geometry != NULL) {
+ char def_geom[64];
+ x = w->core.x;
+ y = w->core.y;
+ width = w->core.width;
+ height = w->core.height;
+ if (is_wmshell) {
+ WMShellPart* wm = &((WMShellWidget)w)->wm;
+ EvaluateSizeHints((WMShellWidget)w);
+ (void) memmove((char*)&hints, (char*)&wm->size_hints,
+ sizeof(struct _OldXSizeHints));
+ hints.win_gravity = wm->win_gravity;
+ if (wm->size_hints.flags & PBaseSize) {
+ width -= wm->base_width;
+ height -= wm->base_height;
+ hints.base_width = wm->base_width;
+ hints.base_height = wm->base_height;
+ }
+ else if (wm->size_hints.flags & PMinSize) {
+ width -= wm->size_hints.min_width;
+ height -= wm->size_hints.min_height;
+ }
+ if (wm->size_hints.flags & PResizeInc) {
+ width /= wm->size_hints.width_inc;
+ height /= wm->size_hints.height_inc;
+ }
+ }
+ else hints.flags = 0;
+
+ sprintf( def_geom, "%dx%d+%d+%d", width, height, x, y );
+ flag = XWMGeometry( XtDisplay(W),
+ XScreenNumberOfScreen(XtScreen(W)),
+ w->shell.geometry, def_geom,
+ (unsigned int)w->core.border_width,
+ &hints, &x, &y, &width, &height,
+ &win_gravity
+ );
+ if (flag) {
+ if (flag & XValue) w->core.x = (Position)x;
+ if (flag & YValue) w->core.y = (Position)y;
+ if (flag & WidthValue) w->core.width = (Dimension)width;
+ if (flag & HeightValue) w->core.height = (Dimension)height;
+ }
+ else {
+ String params[2];
+ Cardinal num_params = 2;
+ params[0] = XtName(W);
+ params[1] = w->shell.geometry;
+ XtAppWarningMsg(XtWidgetToApplicationContext(W),
+ "badGeometry", "shellRealize", XtCXtToolkitError,
+ "Shell widget \"%s\" has an invalid geometry specification: \"%s\"",
+ params, &num_params);
+ }
+ }
+ else
+ flag = 0;
+
+ if (is_wmshell) {
+ WMShellWidget wmshell = (WMShellWidget) w;
+ if (wmshell->wm.win_gravity == XtUnspecifiedShellInt) {
+ if (win_gravity != -1)
+ wmshell->wm.win_gravity = win_gravity;
+ else
+ wmshell->wm.win_gravity = NorthWestGravity;
+ }
+ wmshell->wm.size_hints.flags |= PWinGravity;
+ if ((flag & (XValue|YValue)) == (XValue|YValue))
+ wmshell->wm.size_hints.flags |= USPosition;
+ if ((flag & (WidthValue|HeightValue)) == (WidthValue|HeightValue))
+ wmshell->wm.size_hints.flags |= USSize;
+ }
+ w->shell.client_specified |= _XtShellGeometryParsed;
+}
+
+
+static void ChangeManaged(Widget wid)
+{
+ ShellWidget w = (ShellWidget) wid;
+ Widget child = NULL;
+ Cardinal i;
+
+ for (i = 0; i < w->composite.num_children; i++) {
+ if (XtIsManaged(w->composite.children[i])) {
+ child = w->composite.children[i];
+ break; /* there can only be one of them! */
+ }
+ }
+
+ if (!XtIsRealized (wid)) /* then we're about to be realized... */
+ GetGeometry(wid, child);
+
+ if (child != NULL)
+ XtConfigureWidget (child, (Position)0, (Position)0,
+ w->core.width, w->core.height, (Dimension)0 );
+}
+
+/*
+ * This is gross, I can't wait to see if the change happened so I will ask
+ * the window manager to change my size and do the appropriate X work.
+ * I will then tell the requester that he can. Care must be taken because
+ * it is possible that some time in the future the request will be
+ * asynchronusly denied and the window reverted to it's old size/shape.
+ */
+
+/*ARGSUSED*/
+static XtGeometryResult GeometryManager(
+ Widget wid,
+ XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+ ShellWidget shell = (ShellWidget)(wid->core.parent);
+ XtWidgetGeometry my_request;
+
+ if(shell->shell.allow_shell_resize == FALSE && XtIsRealized(wid))
+ return(XtGeometryNo);
+
+ if (request->request_mode & (CWX | CWY))
+ return(XtGeometryNo);
+
+ my_request.request_mode = (request->request_mode & XtCWQueryOnly);
+ if (request->request_mode & CWWidth) {
+ my_request.width = request->width;
+ my_request.request_mode |= CWWidth;
+ }
+ if (request->request_mode & CWHeight) {
+ my_request.height = request->height;
+ my_request.request_mode |= CWHeight;
+ }
+ if (request->request_mode & CWBorderWidth) {
+ my_request.border_width = request->border_width;
+ my_request.request_mode |= CWBorderWidth;
+ }
+ if (XtMakeGeometryRequest((Widget)shell, &my_request, NULL)
+ == XtGeometryYes) {
+ /* assert: if (request->request_mode & CWWidth) then
+ * shell->core.width == request->width
+ * assert: if (request->request_mode & CWHeight) then
+ * shell->core.height == request->height
+ *
+ * so, whatever the WM sized us to (if the Shell requested
+ * only one of the two) is now the correct child size
+ */
+
+ if (!(request->request_mode & XtCWQueryOnly)) {
+ wid->core.width = shell->core.width;
+ wid->core.height = shell->core.height;
+ if (request->request_mode & CWBorderWidth) {
+ wid->core.x = wid->core.y = -request->border_width;
+ }
+ }
+ return XtGeometryYes;
+ } else return XtGeometryNo;
+}
+
+typedef struct {
+ Widget w;
+ unsigned long request_num;
+ Boolean done;
+} QueryStruct;
+
+static Bool isMine(
+ Display *dpy,
+ register XEvent *event,
+ char *arg)
+{
+ QueryStruct *q = (QueryStruct *) arg;
+ register Widget w = q->w;
+
+ if ( (dpy != XtDisplay(w)) || (event->xany.window != XtWindow(w)) ) {
+ return FALSE;
+ }
+ if (event->xany.serial >= q->request_num) {
+ if (event->type == ConfigureNotify) {
+ q->done = TRUE;
+ return TRUE;
+ }
+ }
+ else if (event->type == ConfigureNotify)
+ return TRUE; /* flush old events */
+ if (event->type == ReparentNotify
+ && event->xreparent.window == XtWindow(w)) {
+ /* we might get ahead of this event, so just in case someone
+ * asks for coordinates before this event is dispatched...
+ */
+ register ShellWidget s = (ShellWidget)w;
+ if (event->xreparent.parent != RootWindowOfScreen(XtScreen(w)))
+ s->shell.client_specified &= ~_XtShellNotReparented;
+ else
+ s->shell.client_specified |= _XtShellNotReparented;
+ }
+ return FALSE;
+}
+
+static Boolean _wait_for_response(
+ ShellWidget w,
+ XEvent *event,
+ unsigned long request_num)
+{
+ XtAppContext app = XtWidgetToApplicationContext((Widget) w);
+ QueryStruct q;
+ unsigned long timeout;
+
+ if (XtIsWMShell((Widget)w))
+ timeout = ((WMShellWidget)w)->wm.wm_timeout;
+ else
+ timeout = DEFAULT_WM_TIMEOUT;
+
+ XFlush(XtDisplay(w));
+ q.w = (Widget) w;
+ q.request_num = request_num;
+ q.done = FALSE;
+
+ /*
+ * look for match event and discard all prior configures
+ */
+ while (XCheckIfEvent(XtDisplay(w),event,isMine,(char*)&q)) {
+ if (q.done) return TRUE;
+ }
+
+ while (timeout > 0) {
+ if (_XtWaitForSomething (app,
+ FALSE, TRUE, TRUE, TRUE,
+ TRUE,
+#ifdef XTHREADS
+ FALSE,
+#endif
+ &timeout) != -1) {
+ while (XCheckIfEvent(XtDisplay(w),event,isMine,(char*)&q)) {
+ if (q.done) return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+/*ARGSUSED*/
+static XtGeometryResult RootGeometryManager(
+ Widget gw,
+ XtWidgetGeometry *request, XtWidgetGeometry *reply)
+{
+ register ShellWidget w = (ShellWidget)gw;
+ XWindowChanges values;
+ unsigned int mask = request->request_mode;
+ XEvent event;
+ Boolean wm;
+ register struct _OldXSizeHints *hintp = NULL;
+ int oldx, oldy, oldwidth, oldheight, oldborder_width;
+ unsigned long request_num;
+
+ CALLGEOTAT(_XtGeoTab(1));
+
+ if (XtIsWMShell(gw)) {
+ wm = True;
+ hintp = &((WMShellWidget)w)->wm.size_hints;
+ /* for draft-ICCCM wm's, need to make sure hints reflect
+ (current) reality so client can move and size separately. */
+ hintp->x = w->core.x;
+ hintp->y = w->core.y;
+ hintp->width = w->core.width;
+ hintp->height = w->core.height;
+ } else
+ wm = False;
+
+ oldx = w->core.x;
+ oldy = w->core.y;
+ oldwidth = w->core.width;
+ oldheight = w->core.height;
+ oldborder_width = w->core.border_width;
+
+#define PutBackGeometry() \
+ { w->core.x = oldx; \
+ w->core.y = oldy; \
+ w->core.width = oldwidth; \
+ w->core.height = oldheight; \
+ w->core.border_width = oldborder_width; }
+
+ if (mask & CWX) {
+ if (w->core.x == request->x) mask &= ~CWX;
+ else {
+ w->core.x = values.x = request->x;
+ if (wm) {
+ hintp->flags &= ~USPosition;
+ hintp->flags |= PPosition;
+ hintp->x = values.x;
+ }
+ }
+ }
+ if (mask & CWY) {
+ if (w->core.y == request->y) mask &= ~CWY;
+ else {
+ w->core.y = values.y = request->y;
+ if (wm) {
+ hintp->flags &= ~USPosition;
+ hintp->flags |= PPosition;
+ hintp->y = values.y;
+ }
+ }
+ }
+ if (mask & CWBorderWidth) {
+ if (w->core.border_width == request->border_width) {
+ mask &= ~CWBorderWidth;
+ } else
+ w->core.border_width =
+ values.border_width =
+ request->border_width;
+ }
+ if (mask & CWWidth) {
+ if (w->core.width == request->width) mask &= ~CWWidth;
+ else {
+ w->core.width = values.width = request->width;
+ if (wm) {
+ hintp->flags &= ~USSize;
+ hintp->flags |= PSize;
+ hintp->width = values.width;
+ }
+ }
+ }
+ if (mask & CWHeight) {
+ if (w->core.height == request->height) mask &= ~CWHeight;
+ else {
+ w->core.height = values.height = request->height;
+ if (wm) {
+ hintp->flags &= ~USSize;
+ hintp->flags |= PSize;
+ hintp->height = values.height;
+ }
+ }
+ }
+ if (mask & CWStackMode) {
+ values.stack_mode = request->stack_mode;
+ if (mask & CWSibling)
+ values.sibling = XtWindow(request->sibling);
+ }
+
+ if (!XtIsRealized((Widget)w)) {
+ CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "Shell \"%s\" is not realized, return XtGeometryYes.\n",
+ XtName((Widget)w)));
+ CALLGEOTAT(_XtGeoTab(-1));
+ return XtGeometryYes;
+ }
+
+ request_num = NextRequest(XtDisplay(w));
+
+ CALLGEOTAT(_XtGeoTrace((Widget)w,"XConfiguring the Shell X window :\n"));
+ CALLGEOTAT(_XtGeoTab(1));
+#ifdef XT_GEO_TATTLER
+ if (mask & CWX) { CALLGEOTAT(_XtGeoTrace((Widget)w,"x = %d\n",values.x));}
+ if (mask & CWY) { CALLGEOTAT(_XtGeoTrace((Widget)w,"y = %d\n",values.y));}
+ if (mask & CWWidth) { CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "width = %d\n",values.width));}
+ if (mask & CWHeight) { CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "height = %d\n",values.height));}
+ if (mask & CWBorderWidth) { CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "border_width = %d\n",values.border_width));}
+#endif
+ CALLGEOTAT(_XtGeoTab(-1));
+
+ XConfigureWindow(XtDisplay((Widget)w), XtWindow((Widget)w), mask,&values);
+
+ if (wm && !w->shell.override_redirect
+ && mask & (CWX | CWY | CWWidth | CWHeight | CWBorderWidth)) {
+ _SetWMSizeHints((WMShellWidget)w);
+ }
+
+ if (w->shell.override_redirect) {
+ CALLGEOTAT(_XtGeoTrace((Widget)w,"Shell \"%s\" is override redirect, return XtGeometryYes.\n", XtName((Widget)w)));
+ CALLGEOTAT(_XtGeoTab(-1));
+ return XtGeometryYes;
+ }
+
+
+ /* If no non-stacking bits are set, there's no way to tell whether
+ or not this worked, so assume it did */
+
+ if (!(mask & ~(CWStackMode | CWSibling))) return XtGeometryYes;
+
+ if (wm && ((WMShellWidget)w)->wm.wait_for_wm == FALSE) {
+ /* the window manager is sick
+ * so I will do the work and
+ * say no so if a new WM starts up,
+ * or the current one recovers
+ * my size requests will be visible
+ */
+ CALLGEOTAT(_XtGeoTrace((Widget)w,"Shell \"%s\" has wait_for_wm == FALSE, return XtGeometryNo.\n",
+ XtName((Widget)w)));
+ CALLGEOTAT(_XtGeoTab(-1));
+
+ PutBackGeometry();
+ return XtGeometryNo;
+ }
+
+ if (_wait_for_response(w, &event, request_num)) {
+ /* got an event */
+ if (event.type == ConfigureNotify) {
+
+#define NEQ(x, msk) ((mask & msk) && (values.x != event.xconfigure.x))
+ if (NEQ(x, CWX) ||
+ NEQ(y, CWY) ||
+ NEQ(width, CWWidth) ||
+ NEQ(height, CWHeight) ||
+ NEQ(border_width, CWBorderWidth)) {
+#ifdef XT_GEO_TATTLER
+ if (NEQ(x, CWX)) {
+ CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "received Configure X %d\n",
+ event.xconfigure.x));
+ }
+ if (NEQ(y, CWY)) {
+ CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "received Configure Y %d\n",
+ event.xconfigure.y));
+ }
+ if (NEQ(width, CWWidth)) {
+ CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "received Configure Width %d\n",
+ event.xconfigure.width));
+ }
+ if (NEQ(height, CWHeight)) {
+ CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "received Configure Height %d\n",
+ event.xconfigure.height));
+ }
+ if (NEQ(border_width, CWBorderWidth)) {
+ CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "received Configure BorderWidth %d\n",
+ event.xconfigure.border_width));
+ }
+#endif
+#undef NEQ
+ XPutBackEvent(XtDisplay(w), &event);
+ PutBackGeometry();
+ /*
+ * We just potentially re-ordered the event queue
+ * w.r.t. ConfigureNotifies with some trepidation.
+ * But this is probably a Good Thing because we
+ * will know the new true state of the world sooner
+ * this way.
+ */
+ CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "ConfigureNotify failed, return XtGeometryNo.\n"));
+ CALLGEOTAT(_XtGeoTab(-1));
+
+ return XtGeometryNo;
+ }
+ else {
+ w->core.width = event.xconfigure.width;
+ w->core.height = event.xconfigure.height;
+ w->core.border_width = event.xconfigure.border_width;
+ if (event.xany.send_event || /* ICCCM compliant synth */
+ w->shell.client_specified & _XtShellNotReparented) {
+
+ w->core.x = event.xconfigure.x;
+ w->core.y = event.xconfigure.y;
+ w->shell.client_specified |= _XtShellPositionValid;
+ }
+ else w->shell.client_specified &= ~_XtShellPositionValid;
+ CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "ConfigureNotify succeed, return XtGeometryYes.\n"));
+ CALLGEOTAT(_XtGeoTab(-1));
+ return XtGeometryYes;
+ }
+ } else if (!wm) {
+ PutBackGeometry();
+ CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "Not wm, return XtGeometryNo.\n"));
+ CALLGEOTAT(_XtGeoTab(-1));
+ return XtGeometryNo;
+ } else XtAppWarningMsg(XtWidgetToApplicationContext((Widget)w),
+ "internalError", "shell", XtCXtToolkitError,
+ "Shell's window manager interaction is broken",
+ (String *)NULL, (Cardinal *)NULL);
+ } else if (wm) { /* no event */
+ ((WMShellWidget)w)->wm.wait_for_wm = FALSE; /* timed out; must be broken */
+ }
+ PutBackGeometry();
+#undef PutBackGeometry
+ CALLGEOTAT(_XtGeoTrace((Widget)w,
+ "Timeout passed?, return XtGeometryNo.\n"));
+ CALLGEOTAT(_XtGeoTab(-1));
+ return XtGeometryNo;
+ }
+
+/* ARGSUSED */
+static Boolean SetValues(
+ Widget old, Widget ref, Widget new,
+ ArgList args,
+ Cardinal *num_args)
+{
+ ShellWidget nw = (ShellWidget) new;
+ ShellWidget ow = (ShellWidget) old;
+ Mask mask = 0;
+ XSetWindowAttributes attr;
+
+ if (!XtIsRealized(new))
+ return False;
+
+ if (ow->shell.save_under != nw->shell.save_under) {
+ mask = CWSaveUnder;
+ attr.save_under = nw->shell.save_under;
+ }
+
+ if (ow->shell.override_redirect != nw->shell.override_redirect) {
+ mask |= CWOverrideRedirect;
+ attr.override_redirect = nw->shell.override_redirect;
+ }
+
+ if (mask) {
+ XChangeWindowAttributes(XtDisplay(new),XtWindow(new), mask, &attr);
+ if ((mask & CWOverrideRedirect) && !nw->shell.override_redirect)
+ _popup_set_prop(nw);
+ }
+
+ if (! (ow->shell.client_specified & _XtShellPositionValid)) {
+ Cardinal n;
+
+ for (n = *num_args; n; n--, args++) {
+ if (strcmp(XtNx, args->name) == 0) {
+ _XtShellGetCoordinates((Widget)ow, &ow->core.x,
+ &ow->core.y);
+ } else if (strcmp(XtNy, args->name) == 0) {
+ _XtShellGetCoordinates((Widget)ow, &ow->core.x,
+ &ow->core.y);
+ }
+ }
+ }
+ return FALSE;
+}
+
+/* ARGSUSED */
+static Boolean WMSetValues(
+ Widget old, Widget ref, Widget new,
+ ArgList args, /* unused */
+ Cardinal *num_args) /* unused */
+{
+ WMShellWidget nwmshell = (WMShellWidget) new;
+ WMShellWidget owmshell = (WMShellWidget) old;
+ Boolean set_prop
+ = XtIsRealized(new) && !nwmshell->shell.override_redirect;
+ Boolean title_changed;
+
+ EvaluateSizeHints(nwmshell);
+
+#define NEQ(f) (nwmshell->wm.size_hints.f != owmshell->wm.size_hints.f)
+
+ if (set_prop
+ && (NEQ(flags) || NEQ(min_width) || NEQ(min_height)
+ || NEQ(max_width) || NEQ(max_height)
+ || NEQ(width_inc) || NEQ(height_inc)
+ || NEQ(min_aspect.x) || NEQ(min_aspect.y)
+ || NEQ(max_aspect.x) || NEQ(max_aspect.y)
+#undef NEQ
+#define NEQ(f) (nwmshell->wm.f != owmshell->wm.f)
+
+ || NEQ(base_width) || NEQ(base_height) || NEQ(win_gravity))) {
+ _SetWMSizeHints(nwmshell);
+ }
+#undef NEQ
+
+ if (nwmshell->wm.title != owmshell->wm.title) {
+ XtFree(owmshell->wm.title);
+ if (! nwmshell->wm.title) nwmshell->wm.title = "";
+ nwmshell->wm.title = XtNewString(nwmshell->wm.title);
+ title_changed = True;
+ } else
+ title_changed = False;
+
+ if (set_prop
+ && (title_changed ||
+ nwmshell->wm.title_encoding != owmshell->wm.title_encoding)) {
+
+ XTextProperty title;
+ Boolean copied = False;
+
+ if (nwmshell->wm.title_encoding == None &&
+ XmbTextListToTextProperty(XtDisplay(new),
+ (char**)&nwmshell->wm.title,
+ 1, XStdICCTextStyle,
+ &title) >= Success) {
+ copied = True;
+ } else {
+ title.value = (unsigned char*)nwmshell->wm.title;
+ title.encoding = nwmshell->wm.title_encoding ?
+ nwmshell->wm.title_encoding : XA_STRING;
+ title.format = 8;
+ title.nitems = strlen(nwmshell->wm.title);
+ }
+ XSetWMName(XtDisplay(new), XtWindow(new), &title);
+ if (copied)
+ XFree((XPointer)title.value);
+ }
+
+ EvaluateWMHints(nwmshell);
+
+#define NEQ(f) (nwmshell->wm.wm_hints.f != owmshell->wm.wm_hints.f)
+
+ if (set_prop
+ && (NEQ(flags) || NEQ(input) || NEQ(initial_state)
+ || NEQ(icon_x) || NEQ(icon_y)
+ || NEQ(icon_pixmap) || NEQ(icon_mask) || NEQ(icon_window)
+ || NEQ(window_group))) {
+
+ XSetWMHints(XtDisplay(new), XtWindow(new), &nwmshell->wm.wm_hints);
+ }
+#undef NEQ
+
+ if (XtIsRealized(new) &&
+ nwmshell->wm.transient != owmshell->wm.transient) {
+ if (nwmshell->wm.transient) {
+ if (!XtIsTransientShell(new) &&
+ !nwmshell->shell.override_redirect &&
+ nwmshell->wm.wm_hints.window_group !=
+ XtUnspecifiedWindowGroup)
+ XSetTransientForHint(XtDisplay(new), XtWindow(new),
+ nwmshell->wm.wm_hints.window_group);
+ }
+ else XDeleteProperty(XtDisplay(new), XtWindow(new),
+ XA_WM_TRANSIENT_FOR);
+ }
+
+ if (nwmshell->wm.client_leader != owmshell->wm.client_leader
+ && XtWindow(new) && !nwmshell->shell.override_redirect) {
+ Widget leader = GetClientLeader(new);
+ if (XtWindow(leader))
+ XChangeProperty(XtDisplay(new), XtWindow(new),
+ XInternAtom(XtDisplay(new),
+ "WM_CLIENT_LEADER", False),
+ XA_WINDOW, 32, PropModeReplace,
+ (unsigned char *) &(leader->core.window), 1);
+ }
+
+ if (nwmshell->wm.window_role != owmshell->wm.window_role) {
+ XtFree(owmshell->wm.window_role);
+ if (set_prop && nwmshell->wm.window_role) {
+ XChangeProperty(XtDisplay(new), XtWindow(new),
+ XInternAtom(XtDisplay(new), "WM_WINDOW_ROLE",
+ False),
+ XA_STRING, 8, PropModeReplace,
+ (unsigned char *)nwmshell->wm.window_role,
+ strlen(nwmshell->wm.window_role));
+ } else if (XtIsRealized(new) && ! nwmshell->wm.window_role) {
+ XDeleteProperty(XtDisplay(new), XtWindow(new),
+ XInternAtom(XtDisplay(new), "WM_WINDOW_ROLE",
+ False));
+ }
+ }
+
+ return FALSE;
+}
+
+/*ARGSUSED*/
+static Boolean TransientSetValues(
+ Widget oldW, Widget refW, Widget newW,
+ ArgList args, /* unused */
+ Cardinal *num_args) /* unused */
+{
+ TransientShellWidget old = (TransientShellWidget)oldW;
+ TransientShellWidget new = (TransientShellWidget)newW;
+
+ if (XtIsRealized(newW)
+ && ((new->wm.transient && !old->wm.transient)
+ || ((new->transient.transient_for != old->transient.transient_for)
+ || (new->transient.transient_for == NULL
+ && (new->wm.wm_hints.window_group
+ != old->wm.wm_hints.window_group))))) {
+
+ _SetTransientForHint(new, True);
+ }
+ return False;
+}
+
+
+/* ARGSUSED */
+static Boolean TopLevelSetValues(
+ Widget oldW, Widget refW, Widget newW,
+ ArgList args, /* unused */
+ Cardinal *num_args) /* unused */
+{
+ TopLevelShellWidget old = (TopLevelShellWidget)oldW;
+ TopLevelShellWidget new = (TopLevelShellWidget)newW;
+ Boolean name_changed;
+
+ if (old->topLevel.icon_name != new->topLevel.icon_name) {
+ XtFree((XtPointer)old->topLevel.icon_name);
+ if (! new->topLevel.icon_name) new->topLevel.icon_name = "";
+ new->topLevel.icon_name = XtNewString(new->topLevel.icon_name);
+ name_changed = True;
+ } else
+ name_changed = False;
+
+ if (XtIsRealized(newW)) {
+ if (new->topLevel.iconic != old->topLevel.iconic) {
+ if (new->topLevel.iconic)
+ XIconifyWindow(XtDisplay(newW),
+ XtWindow(newW),
+ XScreenNumberOfScreen(XtScreen(newW))
+ );
+ else {
+ Boolean map = new->shell.popped_up;
+ XtPopup(newW, XtGrabNone);
+ if (map) XMapWindow(XtDisplay(newW), XtWindow(newW));
+ }
+ }
+
+ if (!new->shell.override_redirect &&
+ (name_changed ||
+ (old->topLevel.icon_name_encoding
+ != new->topLevel.icon_name_encoding))) {
+
+ XTextProperty icon_name;
+ Boolean copied = False;
+
+ if (new->topLevel.icon_name_encoding == None &&
+ XmbTextListToTextProperty(XtDisplay(newW),
+ (char**) &new->topLevel.icon_name,
+ 1, XStdICCTextStyle,
+ &icon_name) >= Success) {
+ copied = True;
+ } else {
+ icon_name.value = (unsigned char *)new->topLevel.icon_name;
+ icon_name.encoding = new->topLevel.icon_name_encoding ?
+ new->topLevel.icon_name_encoding : XA_STRING;
+ icon_name.format = 8;
+ icon_name.nitems = strlen((char *)icon_name.value);
+ }
+ XSetWMIconName(XtDisplay(newW), XtWindow(newW), &icon_name);
+ if (copied)
+ XFree((XPointer)icon_name.value);
+ }
+ }
+ return False;
+}
+
+static String * NewArgv(
+ int count,
+ String *str) /* do not assume it's terminated by a NULL element */
+{
+ Cardinal nbytes = 0;
+ Cardinal num = 0;
+ String *newarray, *new;
+ String *strarray = str;
+ String sptr;
+
+ if (count <= 0 || !str) return NULL;
+
+ for (num = count; num--; str++) {
+ nbytes += strlen(*str);
+ nbytes++;
+ }
+ num = (count+1) * sizeof(String);
+ new = newarray = (String *) __XtMalloc(num + nbytes);
+ sptr = ((char *) new) + num;
+
+ for (str = strarray; count--; str++) {
+ *new = sptr;
+ strcpy(*new, *str);
+ new++;
+ sptr = strchr(sptr, '\0');
+ sptr++;
+ }
+ *new = NULL;
+ return newarray;
+}
+
+
+/*ARGSUSED*/
+static Boolean ApplicationSetValues(
+ Widget current, Widget request, Widget new,
+ ArgList args,
+ Cardinal *num_args)
+{
+ ApplicationShellWidget nw = (ApplicationShellWidget) new;
+ ApplicationShellWidget cw = (ApplicationShellWidget) current;
+
+ if (cw->application.argc != nw->application.argc ||
+ cw->application.argv != nw->application.argv) {
+
+ if (nw->application.argc > 0)
+ nw->application.argv = NewArgv(nw->application.argc,
+ nw->application.argv);
+ if (cw->application.argc > 0)
+ FreeStringArray(cw->application.argv);
+
+ if (XtIsRealized(new) && !nw->shell.override_redirect) {
+ if (nw->application.argc >= 0 && nw->application.argv)
+ XSetCommand(XtDisplay(new), XtWindow(new),
+ nw->application.argv, nw->application.argc);
+ else
+ XDeleteProperty(XtDisplay(new), XtWindow(new), XA_WM_COMMAND);
+ }
+ }
+ return False;
+}
+
+/*ARGSUSED*/
+static Boolean SessionSetValues(
+ Widget current, Widget request, Widget new,
+ ArgList args,
+ Cardinal *num_args)
+{
+#ifndef XT_NO_SM
+ SessionShellWidget nw = (SessionShellWidget) new;
+ SessionShellWidget cw = (SessionShellWidget) current;
+ unsigned long set_mask = 0UL;
+ unsigned long unset_mask = 0UL;
+ Boolean initialize = False;
+
+ if (cw->session.session_id != nw->session.session_id) {
+ nw->session.session_id = XtNewString(nw->session.session_id);
+ XtFree(cw->session.session_id);
+ }
+
+ if (cw->session.clone_command != nw->session.clone_command) {
+ if (nw->session.clone_command) {
+ nw->session.clone_command =
+ NewStringArray(nw->session.clone_command);
+ set_mask |= XtCloneCommandMask;
+ } else unset_mask |= XtCloneCommandMask;
+ FreeStringArray(cw->session.clone_command);
+ }
+
+ if (cw->session.current_dir != nw->session.current_dir) {
+ if (nw->session.current_dir) {
+ nw->session.current_dir =
+ XtNewString(nw->session.current_dir);
+ set_mask |= XtCurrentDirectoryMask;
+ } else unset_mask |= XtCurrentDirectoryMask;
+ XtFree((char *) cw->session.current_dir);
+ }
+
+ if (cw->session.discard_command != nw->session.discard_command) {
+ if (nw->session.discard_command) {
+ nw->session.discard_command =
+ NewStringArray(nw->session.discard_command);
+ set_mask |= XtDiscardCommandMask;
+ } else unset_mask |= XtDiscardCommandMask;
+ FreeStringArray(cw->session.discard_command);
+ }
+
+ if (cw->session.environment != nw->session.environment) {
+ if (nw->session.environment) {
+ nw->session.environment =
+ NewStringArray(nw->session.environment);
+ set_mask |= XtEnvironmentMask;
+ } else unset_mask |= XtEnvironmentMask;
+ FreeStringArray(cw->session.environment);
+ }
+
+ if (cw->session.program_path != nw->session.program_path) {
+ if (nw->session.program_path) {
+ nw->session.program_path =
+ XtNewString(nw->session.program_path);
+ set_mask |= XtProgramMask;
+ } else unset_mask |= XtProgramMask;
+ XtFree((char *) cw->session.program_path);
+ }
+
+ if (cw->session.resign_command != nw->session.resign_command) {
+ if (nw->session.resign_command) {
+ nw->session.resign_command =
+ NewStringArray(nw->session.resign_command);
+ set_mask |= XtResignCommandMask;
+ } else set_mask |= XtResignCommandMask;
+ FreeStringArray(cw->session.resign_command);
+ }
+
+ if (cw->session.restart_command != nw->session.restart_command) {
+ if (nw->session.restart_command) {
+ nw->session.restart_command =
+ NewStringArray(nw->session.restart_command);
+ set_mask |= XtRestartCommandMask;
+ } else unset_mask |= XtRestartCommandMask;
+ FreeStringArray(cw->session.restart_command);
+ }
+
+ if (cw->session.restart_style != nw->session.restart_style)
+ set_mask |= XtRestartStyleHintMask;
+
+ if (cw->session.shutdown_command != nw->session.shutdown_command) {
+ if (nw->session.shutdown_command) {
+ nw->session.shutdown_command =
+ NewStringArray(nw->session.shutdown_command);
+ set_mask |= XtShutdownCommandMask;
+ } else unset_mask |= XtShutdownCommandMask;
+ FreeStringArray(cw->session.shutdown_command);
+ }
+
+ if ((!cw->session.join_session && nw->session.join_session) ||
+ (!cw->session.connection && nw->session.connection)) {
+ JoinSession(nw);
+ initialize = True;
+ }
+
+ if (nw->session.connection && (set_mask || unset_mask || initialize))
+ SetSessionProperties((SessionShellWidget) new, initialize, set_mask, unset_mask);
+
+ if ((cw->session.join_session && !nw->session.join_session) ||
+ (cw->session.connection && !nw->session.connection))
+ StopManagingSession(nw, nw->session.connection);
+#endif /* !XT_NO_SM */
+
+ if (cw->wm.client_leader != nw->wm.client_leader ||
+ cw->session.session_id != nw->session.session_id) {
+ Widget leader;
+ if (cw->session.session_id) {
+ leader = GetClientLeader(current);
+ if (XtWindow(leader))
+ XDeleteProperty(XtDisplay(leader), XtWindow(leader),
+ XInternAtom(XtDisplay(leader), "SM_CLIENT_ID",
+ False));
+ }
+ if (nw->session.session_id) {
+ leader = GetClientLeader(new);
+ if (XtWindow(leader))
+ XChangeProperty(XtDisplay(leader), XtWindow(leader),
+ XInternAtom(XtDisplay(leader), "SM_CLIENT_ID",
+ False),
+ XA_STRING, 8, PropModeReplace,
+ (unsigned char *) nw->session.session_id,
+ strlen(nw->session.session_id));
+ }
+ }
+ return False;
+}
+
+void _XtShellGetCoordinates(
+ Widget widget,
+ Position* x,
+ Position* y)
+{
+ ShellWidget w = (ShellWidget)widget;
+ if (XtIsRealized(widget) &&
+ !(w->shell.client_specified & _XtShellPositionValid)) {
+ int tmpx, tmpy;
+ Window tmpchild;
+ (void) XTranslateCoordinates(XtDisplay(w), XtWindow(w),
+ RootWindowOfScreen(XtScreen(w)),
+ (int) -w->core.border_width,
+ (int) -w->core.border_width,
+ &tmpx, &tmpy, &tmpchild);
+ w->core.x = tmpx;
+ w->core.y = tmpy;
+ w->shell.client_specified |= _XtShellPositionValid;
+ }
+ *x = w->core.x;
+ *y = w->core.y;
+}
+
+static void GetValuesHook(
+ Widget widget,
+ ArgList args,
+ Cardinal* num_args)
+{
+ ShellWidget w = (ShellWidget) widget;
+
+ /* x and y resource values may be invalid after a shell resize */
+ if (XtIsRealized(widget) &&
+ !(w->shell.client_specified & _XtShellPositionValid)) {
+ Cardinal n;
+ Position x, y;
+
+ for (n = *num_args; n; n--, args++) {
+ if (strcmp(XtNx, args->name) == 0) {
+ _XtShellGetCoordinates(widget, &x, &y);
+ _XtCopyToArg((char *) &x, &args->value, sizeof(Position));
+ } else if (strcmp(XtNy, args->name) == 0) {
+ _XtShellGetCoordinates(widget, &x, &y);
+ _XtCopyToArg((char *) &y, &args->value, sizeof(Position));
+ }
+ }
+ }
+}
+
+static void ApplicationShellInsertChild(
+ Widget widget)
+{
+ if (! XtIsWidget(widget) && XtIsRectObj(widget)) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "invalidClass", "applicationShellInsertChild", XtCXtToolkitError,
+ "ApplicationShell does not accept RectObj children; ignored",
+ (String*)NULL, (Cardinal*)NULL);
+ }
+ else {
+ XtWidgetProc insert_child;
+
+ LOCK_PROCESS;
+ insert_child =
+ ((CompositeWidgetClass)applicationShellClassRec.core_class.
+ superclass)->composite_class.insert_child;
+ UNLOCK_PROCESS;
+ (*insert_child) (widget);
+ }
+}
+
+/**************************************************************************
+
+ Session Protocol Participation
+
+ *************************************************************************/
+
+#define XtSessionCheckpoint 0
+#define XtSessionInteract 1
+
+static void CallSaveCallbacks(SessionShellWidget );
+static String *EditCommand(String, String *, String *);
+static Boolean ExamineToken(XtPointer);
+static void GetIceEvent(XtPointer, int *, XtInputId *);
+static XtCheckpointToken GetToken(Widget, int);
+static void XtCallCancelCallbacks(SmcConn, SmPointer);
+static void XtCallDieCallbacks(SmcConn, SmPointer);
+static void XtCallSaveCallbacks(SmcConn, SmPointer, int, Bool, int, Bool);
+static void XtCallSaveCompleteCallbacks(SmcConn, SmPointer);
+
+#ifndef XT_NO_SM
+static void StopManagingSession(
+ SessionShellWidget w,
+ SmcConn connection) /* connection to close, if any */
+{
+ if (connection)
+ SmcCloseConnection(connection, 0, NULL);
+
+ if (w->session.input_id) {
+ XtRemoveInput(w->session.input_id);
+ w->session.input_id = 0;
+ }
+ w->session.connection = NULL;
+}
+
+#define XT_MSG_LENGTH 256
+static void JoinSession(
+ SessionShellWidget w)
+{
+ IceConn ice_conn;
+ SmcCallbacks smcb;
+ char * sm_client_id;
+ unsigned long mask;
+ static char context; /* used to guarantee the connection isn't shared */
+
+ smcb.save_yourself.callback = XtCallSaveCallbacks;
+ smcb.die.callback = XtCallDieCallbacks;
+ smcb.save_complete.callback = XtCallSaveCompleteCallbacks;
+ smcb.shutdown_cancelled.callback = XtCallCancelCallbacks;
+ smcb.save_yourself.client_data = smcb.die.client_data =
+ smcb.save_complete.client_data =
+ smcb.shutdown_cancelled.client_data = (SmPointer) w;
+ mask = SmcSaveYourselfProcMask | SmcDieProcMask |
+ SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask;
+
+ if (w->session.connection) {
+ SmcModifyCallbacks(w->session.connection, mask, &smcb);
+ sm_client_id = SmcClientID(w->session.connection);
+ } else if (getenv("SESSION_MANAGER")) {
+ char error_msg[XT_MSG_LENGTH];
+ error_msg[0] = '\0';
+ w->session.connection =
+ SmcOpenConnection(NULL, &context, SmProtoMajor, SmProtoMinor,
+ mask, &smcb, w->session.session_id,
+ &sm_client_id, XT_MSG_LENGTH, error_msg);
+ if (error_msg[0]) {
+ String params[1];
+ Cardinal num_params = 1;
+ params[0] = error_msg;
+ XtAppWarningMsg(XtWidgetToApplicationContext((Widget) w),
+ "sessionManagement", "SmcOpenConnection",
+ XtCXtToolkitError,
+ "Tried to connect to session manager, %s",
+ params, &num_params);
+ }
+ }
+
+ if (w->session.connection) {
+ if (w->session.session_id == NULL
+ || (strcmp(w->session.session_id, sm_client_id) != 0)) {
+ XtFree(w->session.session_id);
+ w->session.session_id = XtNewString(sm_client_id);
+ }
+ free(sm_client_id);
+ ice_conn = SmcGetIceConnection(w->session.connection);
+ w->session.input_id =
+ XtAppAddInput(XtWidgetToApplicationContext((Widget)w),
+ IceConnectionNumber(ice_conn),
+ (XtPointer) XtInputReadMask,
+ GetIceEvent, (XtPointer) w);
+
+ w->session.restart_command =
+ EditCommand(w->session.session_id, w->session.restart_command,
+ w->application.argv);
+
+ if (! w->session.clone_command) w->session.clone_command =
+ EditCommand(NULL, NULL, w->session.restart_command);
+
+ if (! w->session.program_path)
+ w->session.program_path = w->session.restart_command
+ ? XtNewString(w->session.restart_command[0]) : NULL;
+ }
+}
+#undef XT_MSG_LENGTH
+
+#endif /* !XT_NO_SM */
+
+static String * NewStringArray(String *str)
+{
+ Cardinal nbytes = 0;
+ Cardinal num = 0;
+ String *newarray, *new;
+ String *strarray = str;
+ String sptr;
+
+ if (!str) return NULL;
+
+ for (num = 0; *str; num++, str++) {
+ nbytes += strlen(*str);
+ nbytes++;
+ }
+ num = (num + 1) * sizeof(String);
+ new = newarray = (String *) __XtMalloc(num + nbytes);
+ sptr = ((char *) new) + num;
+
+ for (str = strarray; *str; str++) {
+ *new = sptr;
+ strcpy(*new, *str);
+ new++;
+ sptr = strchr(sptr, '\0');
+ sptr++;
+ }
+ *new = NULL;
+ return newarray;
+}
+
+static void FreeStringArray(String *str)
+{
+ if (str)
+ XtFree((char *) str);
+}
+
+
+#ifndef XT_NO_SM
+static SmProp * CardPack(
+ char *name,
+ XtPointer closure)
+{
+ unsigned char *prop = (unsigned char *) closure;
+ SmProp *p;
+
+ p = (SmProp *) __XtMalloc(sizeof(SmProp) + sizeof(SmPropValue));
+ p->vals = (SmPropValue *) (((char *) p) + sizeof(SmProp));
+ p->num_vals = 1;
+ p->type = SmCARD8;
+ p->name = name;
+ p->vals->length = 1;
+ p->vals->value = (SmPointer) prop;
+ return p;
+}
+
+static SmProp * ArrayPack(char *name, XtPointer closure)
+{
+ String prop = *(String *) closure;
+ SmProp *p;
+
+ p = (SmProp *) __XtMalloc(sizeof(SmProp) + sizeof(SmPropValue));
+ p->vals = (SmPropValue *) (((char *) p) + sizeof(SmProp));
+ p->num_vals = 1;
+ p->type = SmARRAY8;
+ p->name = name;
+ p->vals->length = strlen(prop) + 1;
+ p->vals->value = prop;
+ return p;
+}
+
+static SmProp * ListPack(
+ char *name,
+ XtPointer closure)
+{
+ String *prop = *(String **) closure;
+ SmProp *p;
+ String *ptr;
+ SmPropValue *vals;
+ int n = 0;
+
+ for (ptr = prop; *ptr; ptr++)
+ n++;
+ p = (SmProp*) __XtMalloc(sizeof(SmProp) + (Cardinal)(n*sizeof(SmPropValue)));
+ p->vals = (SmPropValue *) (((char *) p) + sizeof(SmProp));
+ p->num_vals = n;
+ p->type = SmLISTofARRAY8;
+ p->name = name;
+ for (ptr = prop, vals = p->vals; *ptr; ptr++, vals++) {
+ vals->length = strlen(*ptr) + 1;
+ vals->value = *ptr;
+ }
+ return p;
+}
+
+static void FreePacks(
+ SmProp **props,
+ int num_props)
+{
+ while (--num_props >= 0)
+ XtFree((char *) props[num_props]);
+}
+
+typedef SmProp* (*PackProc)(char *, XtPointer);
+
+typedef struct PropertyRec {
+ char * name;
+ int offset;
+ PackProc proc;
+} PropertyRec, *PropertyTable;
+
+#define Offset(x) (XtOffsetOf(SessionShellRec, x))
+static PropertyRec propertyTable[] = {
+ {SmCloneCommand, Offset(session.clone_command), ListPack},
+ {SmCurrentDirectory, Offset(session.current_dir), ArrayPack},
+ {SmDiscardCommand, Offset(session.discard_command), ListPack},
+ {SmEnvironment, Offset(session.environment), ListPack},
+ {SmProgram, Offset(session.program_path), ArrayPack},
+ {SmResignCommand, Offset(session.resign_command), ListPack},
+ {SmRestartCommand, Offset(session.restart_command), ListPack},
+ {SmRestartStyleHint, Offset(session.restart_style), CardPack},
+ {SmShutdownCommand, Offset(session.shutdown_command), ListPack}
+};
+#undef Offset
+
+#define XT_NUM_SM_PROPS 11
+
+static void SetSessionProperties(
+ SessionShellWidget w,
+ Boolean initialize,
+ unsigned long set_mask,
+ unsigned long unset_mask)
+{
+ PropertyTable p = propertyTable;
+ int n;
+ int num_props = 0;
+ XtPointer *addr;
+ unsigned long mask;
+ SmProp *props[XT_NUM_SM_PROPS];
+ char *pnames[XT_NUM_SM_PROPS];
+
+ if (w->session.connection == NULL)
+ return;
+
+ if (initialize) {
+ char nam_buf[32];
+ char pid[12];
+ String user_name;
+ String pidp = pid;
+
+ /* set all non-NULL session properties, the UserID and the ProcessID */
+ for (n = XtNumber(propertyTable); n; n--, p++) {
+ addr = (XtPointer *) ((char *) w + p->offset);
+ if (p->proc == CardPack) {
+ if (*(unsigned char *)addr)
+ props[num_props++] =(*(p->proc))(p->name, (XtPointer)addr);
+ }
+ else if (* addr)
+ props[num_props++] = (*(p->proc))(p->name, (XtPointer)addr);
+
+ }
+ user_name = _XtGetUserName(nam_buf, sizeof nam_buf);
+ if (user_name)
+ props[num_props++] = ArrayPack(SmUserID, &user_name);
+ sprintf(pid, "%ld", (long)getpid());
+ props[num_props++] = ArrayPack(SmProcessID, &pidp);
+
+ if (num_props) {
+ SmcSetProperties(w->session.connection, num_props, props);
+ FreePacks(props, num_props);
+ }
+ return;
+ }
+
+ if (set_mask) {
+ mask = 1L;
+ for (n = XtNumber(propertyTable); n; n--, p++, mask <<= 1)
+ if (mask & set_mask) {
+ addr = (XtPointer *) ((char *) w + p->offset);
+ props[num_props++] = (*(p->proc))(p->name, (XtPointer)addr);
+ }
+ SmcSetProperties(w->session.connection, num_props, props);
+ FreePacks(props, num_props);
+ }
+
+ if (unset_mask) {
+ mask = 1L;
+ num_props = 0;
+ for (n = XtNumber(propertyTable); n; n--, p++, mask <<= 1)
+ if (mask & unset_mask)
+ pnames[num_props++] = p->name;
+ SmcDeleteProperties(w->session.connection, num_props, pnames);
+ }
+}
+
+/*ARGSUSED*/
+static void GetIceEvent(
+ XtPointer client_data,
+ int * source,
+ XtInputId * id)
+{
+ SessionShellWidget w = (SessionShellWidget) client_data;
+ IceProcessMessagesStatus status;
+
+ status = IceProcessMessages(SmcGetIceConnection(w->session.connection),
+ NULL, NULL);
+
+ if (status == IceProcessMessagesIOError) {
+ StopManagingSession(w, w->session.connection);
+ XtCallCallbackList((Widget)w, w->session.error_callbacks,
+ (XtPointer) NULL);
+ }
+}
+
+static void CleanUpSave(
+ SessionShellWidget w)
+{
+ XtSaveYourself next = w->session.save->next;
+ XtFree((char *)w->session.save);
+ w->session.save = next;
+ if (w->session.save)
+ CallSaveCallbacks(w);
+}
+
+static void CallSaveCallbacks(
+ SessionShellWidget w)
+{
+ XtCheckpointToken token;
+
+ if (XtHasCallbacks((Widget) w, XtNsaveCallback) != XtCallbackHasSome) {
+ /* if the application makes no attempt to save state, report failure */
+ SmcSaveYourselfDone(w->session.connection, False);
+ CleanUpSave(w);
+ } else {
+ w->session.checkpoint_state = XtSaveActive;
+ token = GetToken((Widget) w, XtSessionCheckpoint);
+ _XtCallConditionalCallbackList((Widget)w, w->session.save_callbacks,
+ (XtPointer)token, ExamineToken);
+ XtSessionReturnToken(token);
+ }
+}
+
+/*ARGSUSED*/
+static void XtCallSaveCallbacks(
+ SmcConn connection, /* unused */
+ SmPointer client_data,
+ int save_type,
+ Bool shutdown,
+ int interact,
+ Bool fast)
+{
+ SessionShellWidget w = (SessionShellWidget) client_data;
+ XtSaveYourself save;
+ XtSaveYourself prev;
+
+ save = XtNew(XtSaveYourselfRec);
+ save->next = NULL;
+ save->save_type = save_type;
+ save->interact_style = interact;
+ save->shutdown = shutdown;
+ save->fast = fast;
+ save->cancel_shutdown = False;
+ save->phase = 1;
+ save->interact_dialog_type = SmDialogNormal;
+ save->request_cancel = save->request_next_phase = False;
+ save->save_success = True;
+ save->save_tokens = save->interact_tokens = 0;
+
+ prev = (XtSaveYourself) &w->session.save;
+ while (prev->next)
+ prev = prev->next;
+ prev->next = save;
+
+ if (w->session.checkpoint_state == XtSaveInactive)
+ CallSaveCallbacks(w);
+}
+
+static void XtInteractPermission(
+ SmcConn connection,
+ SmPointer data)
+{
+ Widget w = (Widget) data;
+ SessionShellWidget sw = (SessionShellWidget) data;
+ XtCheckpointToken token;
+ XtCallbackProc callback;
+ XtPointer client_data;
+
+
+ _XtPeekCallback(w, sw->session.interact_callbacks, &callback,
+ &client_data);
+ if (callback) {
+ sw->session.checkpoint_state = XtInteractActive;
+ token = GetToken(w, XtSessionInteract);
+ XtRemoveCallback(w, XtNinteractCallback, callback, client_data);
+ (*callback)(w, client_data, (XtPointer) token);
+ } else if (! sw->session.save->cancel_shutdown) {
+ SmcInteractDone(connection, False);
+ }
+}
+
+/*ARGSUSED*/
+static void XtCallSaveCompleteCallbacks(
+ SmcConn connection,
+ SmPointer client_data)
+{
+ SessionShellWidget w = (SessionShellWidget) client_data;
+
+ XtCallCallbackList((Widget)w, w->session.save_complete_callbacks,
+ (XtPointer) NULL);
+}
+
+/*ARGSUSED*/
+static void XtCallNextPhaseCallbacks(
+ SmcConn connection, /* unused */
+ SmPointer client_data)
+{
+ SessionShellWidget w = (SessionShellWidget) client_data;
+ w->session.save->phase = 2;
+ CallSaveCallbacks(w);
+}
+
+/*ARGSUSED*/
+static void XtCallDieCallbacks(
+ SmcConn connection, /* unused */
+ SmPointer client_data)
+{
+ SessionShellWidget w = (SessionShellWidget) client_data;
+
+ StopManagingSession(w, w->session.connection);
+ XtCallCallbackList((Widget)w, w->session.die_callbacks,
+ (XtPointer) NULL);
+}
+
+/*ARGSUSED*/
+static void XtCallCancelCallbacks(
+ SmcConn connection, /* unused */
+ SmPointer client_data)
+{
+ SessionShellWidget w = (SessionShellWidget) client_data;
+ Boolean call_interacts = False;
+
+ if (w->session.checkpoint_state != XtSaveInactive) {
+ w->session.save->cancel_shutdown = True;
+ call_interacts = (w->session.save->interact_style !=
+ SmInteractStyleNone);
+ }
+
+ XtCallCallbackList((Widget)w, w->session.cancel_callbacks,
+ (XtPointer) NULL);
+
+ if (call_interacts) {
+ w->session.save->interact_style = SmInteractStyleNone;
+ XtInteractPermission(w->session.connection, (SmPointer) w);
+ }
+
+ if (w->session.checkpoint_state != XtSaveInactive) {
+ if (w->session.save->save_tokens == 0 &&
+ w->session.checkpoint_state == XtSaveActive) {
+ w->session.checkpoint_state = XtSaveInactive;
+ SmcSaveYourselfDone(w->session.connection,
+ w->session.save->save_success);
+ CleanUpSave(w);
+ }
+ }
+}
+
+static XtCheckpointToken GetToken(
+ Widget widget,
+ int type)
+{
+ SessionShellWidget w = (SessionShellWidget) widget;
+ XtCheckpointToken token;
+ XtSaveYourself save = w->session.save;
+
+ if (type == XtSessionCheckpoint)
+ w->session.save->save_tokens++;
+ else if (type == XtSessionInteract)
+ w->session.save->interact_tokens++;
+ else
+ return (XtCheckpointToken) NULL;
+
+ token = (XtCheckpointToken) __XtMalloc(sizeof(XtCheckpointTokenRec));
+ token->save_type = save->save_type;
+ token->interact_style = save->interact_style;
+ token->shutdown = save->shutdown;
+ token->fast = save->fast;
+ token->cancel_shutdown = save->cancel_shutdown;
+ token->phase = save->phase;
+ token->interact_dialog_type = save->interact_dialog_type;
+ token->request_cancel = save->request_cancel;
+ token->request_next_phase = save->request_next_phase;
+ token->save_success = save->save_success;
+ token->type = type;
+ token->widget = widget;
+ return token;
+}
+
+XtCheckpointToken XtSessionGetToken(Widget widget)
+{
+ SessionShellWidget w = (SessionShellWidget) widget;
+ XtCheckpointToken token = NULL;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ if (w->session.checkpoint_state)
+ token = GetToken(widget, XtSessionCheckpoint);
+
+ UNLOCK_APP(app);
+ return token;
+}
+
+static Boolean ExamineToken(
+ XtPointer call_data)
+{
+ XtCheckpointToken token = (XtCheckpointToken) call_data;
+ SessionShellWidget w = (SessionShellWidget) token->widget;
+
+ if (token->interact_dialog_type == SmDialogError)
+ w->session.save->interact_dialog_type = SmDialogError;
+ if (token->request_next_phase)
+ w->session.save->request_next_phase = True;
+ if (! token->save_success)
+ w->session.save->save_success = False;
+
+ token->interact_dialog_type = w->session.save->interact_dialog_type;
+ token->request_next_phase = w->session.save->request_next_phase;
+ token->save_success = w->session.save->save_success;
+ token->cancel_shutdown = w->session.save->cancel_shutdown;
+
+ return True;
+}
+
+void XtSessionReturnToken(XtCheckpointToken token)
+{
+ SessionShellWidget w = (SessionShellWidget) token->widget;
+ Boolean has_some;
+ Boolean phase_done;
+ XtCallbackProc callback;
+ XtPointer client_data;
+ WIDGET_TO_APPCON((Widget)w);
+
+ LOCK_APP(app);
+
+ has_some = (XtHasCallbacks(token->widget, XtNinteractCallback)
+ == XtCallbackHasSome);
+
+ (void) ExamineToken((XtPointer) token);
+
+ if (token->type == XtSessionCheckpoint) {
+ w->session.save->save_tokens--;
+ if (has_some && w->session.checkpoint_state == XtSaveActive) {
+ w->session.checkpoint_state = XtInteractPending;
+ SmcInteractRequest(w->session.connection,
+ w->session.save->interact_dialog_type,
+ XtInteractPermission, (SmPointer) w);
+ }
+ XtFree((char*) token);
+ } else {
+ if (token->request_cancel)
+ w->session.save->request_cancel = True;
+ token->request_cancel = w->session.save->request_cancel;
+ if (has_some) {
+ _XtPeekCallback((Widget)w, w->session.interact_callbacks,
+ &callback, &client_data);
+ XtRemoveCallback((Widget)w, XtNinteractCallback,
+ callback, client_data);
+ (*callback)((Widget)w, client_data, (XtPointer)token);
+ } else {
+ w->session.save->interact_tokens--;
+ if (w->session.save->interact_tokens == 0) {
+ w->session.checkpoint_state = XtSaveActive;
+ if (! w->session.save->cancel_shutdown)
+ SmcInteractDone(w->session.connection,
+ w->session.save->request_cancel);
+ }
+ XtFree((char *) token);
+ }
+ }
+
+ phase_done = (w->session.save->save_tokens == 0 &&
+ w->session.checkpoint_state == XtSaveActive);
+
+ if (phase_done) {
+ if (w->session.save->request_next_phase &&
+ w->session.save->phase == 1) {
+ SmcRequestSaveYourselfPhase2(w->session.connection,
+ XtCallNextPhaseCallbacks,
+ (SmPointer)w);
+ } else {
+ w->session.checkpoint_state = XtSaveInactive;
+ SmcSaveYourselfDone(w->session.connection,
+ w->session.save->save_success);
+ CleanUpSave(w);
+ }
+ }
+
+ UNLOCK_APP(app);
+}
+
+static Boolean IsInArray(
+ String str,
+ String *sarray)
+{
+ if (str == NULL || sarray == NULL)
+ return False;
+ for (; *sarray; sarray++) {
+ if (strcmp(*sarray, str) == 0)
+ return True;
+ }
+ return False;
+}
+
+static String* EditCommand(
+ String str, /* if not NULL, the sm_client_id */
+ String *src1, /* first choice */
+ String *src2) /* alternate */
+{
+ Boolean have;
+ Boolean want;
+ int count;
+ String *sarray;
+ String *s;
+ String *new;
+
+ want = (str != NULL);
+ sarray = (src1 ? src1 : src2);
+ if (! sarray) return NULL;
+ have = IsInArray("-xtsessionID", sarray);
+ if ((want && have) || (!want && !have)) {
+ if (sarray == src1)
+ return src1;
+ else
+ return NewStringArray(sarray);
+ }
+
+ count = 0;
+ for (s = sarray; *s; s++)
+ count++;
+
+ if (want) {
+ s = new = (String *) __XtMalloc((Cardinal)(count+3) * sizeof(String*));
+ *s = *sarray; s++; sarray++;
+ *s = "-xtsessionID"; s++;
+ *s = str; s++;
+ for (; --count > 0; s++, sarray++)
+ *s = *sarray;
+ *s = (String) NULL;
+ } else {
+ if (count < 3)
+ return NewStringArray(sarray);
+ s = new = (String *) __XtMalloc((Cardinal)(count-1) * sizeof(String*));
+ for (; --count >= 0; sarray++) {
+ if (strcmp(*sarray, "-xtsessionID") == 0) {
+ sarray++;
+ count--;
+ } else {
+ *s = *sarray;
+ s++;
+ }
+ }
+ *s = (String) NULL;
+ }
+ s = new;
+ new = NewStringArray(new);
+ XtFree((char *)s);
+ return new;
+}
+
+#endif /* !XT_NO_SM */
diff --git a/nx-X11/lib/Xt/ShellI.h b/nx-X11/lib/Xt/ShellI.h
new file mode 100644
index 000000000..6a093d791
--- /dev/null
+++ b/nx-X11/lib/Xt/ShellI.h
@@ -0,0 +1,12 @@
+/* $XFree86$ */
+
+#ifndef _XtShellInternal_h
+#define _XtShellInternal_h
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+extern void _XtShellGetCoordinates(Widget widget, Position *x, Position *y);
+
+#endif /* _XtShellInternal_h */
diff --git a/nx-X11/lib/Xt/ShellP.h b/nx-X11/lib/Xt/ShellP.h
new file mode 100644
index 000000000..2b08c3f5c
--- /dev/null
+++ b/nx-X11/lib/Xt/ShellP.h
@@ -0,0 +1,428 @@
+/* $Xorg: ShellP.h,v 1.4 2001/02/09 02:03:58 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+
+/*
+ * ShellP.h - Private definitions for Shell widget
+ *
+ * Author: Paul Asente
+ * Digital Equipment Corporation
+ * Western Software Laboratory
+ * Date: Thu Dec 3, 1987
+ */
+
+#ifndef _XtShellPrivate_h
+#define _XtShellPrivate_h
+
+#include <X11/Shell.h>
+
+/* *****
+ * ***** VendorP.h is included later on; it needs fields defined in the first
+ * ***** part of this header file
+ * *****
+ */
+
+/***********************************************************************
+ *
+ * Shell Widget Private Data
+ *
+ ***********************************************************************/
+
+/* New fields for the Shell widget class record */
+
+typedef struct {
+ XtPointer extension; /* pointer to extension record */
+} ShellClassPart;
+
+typedef struct {
+ XtPointer next_extension; /* 1st 4 mandated for all extension records */
+ XrmQuark record_type; /* NULLQUARK; on ShellClassPart */
+ long version; /* must be XtShellExtensionVersion */
+ Cardinal record_size; /* sizeof(ShellClassExtensionRec) */
+ XtGeometryHandler root_geometry_manager;
+} ShellClassExtensionRec, *ShellClassExtension;
+
+#define XtShellExtensionVersion 1L
+#define XtInheritRootGeometryManager ((XtGeometryHandler)_XtInherit)
+
+typedef struct _ShellClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ShellClassPart shell_class;
+} ShellClassRec;
+
+externalref ShellClassRec shellClassRec;
+
+/* New fields for the shell widget */
+
+typedef struct {
+ char *geometry;
+ XtCreatePopupChildProc create_popup_child_proc;
+ XtGrabKind grab_kind;
+ Boolean spring_loaded;
+ Boolean popped_up;
+ Boolean allow_shell_resize;
+ Boolean client_specified; /* re-using old name */
+#define _XtShellPositionValid ((Boolean)(1<<0))
+#define _XtShellNotReparented ((Boolean)(1<<1))
+#define _XtShellPPositionOK ((Boolean)(1<<2))
+#define _XtShellGeometryParsed ((Boolean)(1<<3))
+ Boolean save_under;
+ Boolean override_redirect;
+
+ XtCallbackList popup_callback;
+ XtCallbackList popdown_callback;
+ Visual* visual;
+} ShellPart;
+
+typedef struct {
+ CorePart core;
+ CompositePart composite;
+ ShellPart shell;
+} ShellRec, *ShellWidget;
+
+/***********************************************************************
+ *
+ * OverrideShell Widget Private Data
+ *
+ ***********************************************************************/
+
+/* New fields for the OverrideShell widget class record */
+
+typedef struct {
+ XtPointer extension; /* pointer to extension record */
+} OverrideShellClassPart;
+
+typedef struct _OverrideShellClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ShellClassPart shell_class;
+ OverrideShellClassPart override_shell_class;
+} OverrideShellClassRec;
+
+externalref OverrideShellClassRec overrideShellClassRec;
+
+/* No new fields for the override shell widget */
+
+typedef struct {int frabjous;} OverrideShellPart;
+
+typedef struct {
+ CorePart core;
+ CompositePart composite;
+ ShellPart shell;
+ OverrideShellPart override;
+} OverrideShellRec, *OverrideShellWidget;
+
+/***********************************************************************
+ *
+ * WMShell Widget Private Data
+ *
+ ***********************************************************************/
+
+/* New fields for the WMShell widget class record */
+
+typedef struct {
+ XtPointer extension; /* pointer to extension record */
+} WMShellClassPart;
+
+typedef struct _WMShellClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ShellClassPart shell_class;
+ WMShellClassPart wm_shell_class;
+} WMShellClassRec;
+
+externalref WMShellClassRec wmShellClassRec;
+
+/* New fields for the WM shell widget */
+
+typedef struct {
+ char *title;
+ int wm_timeout;
+ Boolean wait_for_wm;
+ Boolean transient;
+ Boolean urgency;
+ Widget client_leader;
+ String window_role;
+ struct _OldXSizeHints { /* pre-R4 Xlib structure */
+ long flags;
+ int x, y;
+ int width, height;
+ int min_width, min_height;
+ int max_width, max_height;
+ int width_inc, height_inc;
+ struct {
+ int x;
+ int y;
+ } min_aspect, max_aspect;
+ } size_hints;
+ XWMHints wm_hints;
+ int base_width, base_height;
+ int win_gravity;
+ Atom title_encoding;
+} WMShellPart;
+
+typedef struct {
+ CorePart core;
+ CompositePart composite;
+ ShellPart shell;
+ WMShellPart wm;
+} WMShellRec, *WMShellWidget;
+
+#include <X11/VendorP.h>
+
+/***********************************************************************
+ *
+ * TransientShell Widget Private Data
+ *
+ ***********************************************************************/
+
+/* New fields for the TransientShell widget class record */
+
+typedef struct {
+ XtPointer extension; /* pointer to extension record */
+} TransientShellClassPart;
+
+typedef struct _TransientShellClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ShellClassPart shell_class;
+ WMShellClassPart wm_shell_class;
+ VendorShellClassPart vendor_shell_class;
+ TransientShellClassPart transient_shell_class;
+} TransientShellClassRec;
+
+externalref TransientShellClassRec transientShellClassRec;
+
+/* New fields for the transient shell widget */
+
+typedef struct {
+ Widget transient_for;
+} TransientShellPart;
+
+typedef struct {
+ CorePart core;
+ CompositePart composite;
+ ShellPart shell;
+ WMShellPart wm;
+ VendorShellPart vendor;
+ TransientShellPart transient;
+} TransientShellRec, *TransientShellWidget;
+
+/***********************************************************************
+ *
+ * TopLevelShell Widget Private Data
+ *
+ ***********************************************************************/
+
+/* New fields for the TopLevelShell widget class record */
+
+typedef struct {
+ XtPointer extension; /* pointer to extension record */
+} TopLevelShellClassPart;
+
+typedef struct _TopLevelShellClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ShellClassPart shell_class;
+ WMShellClassPart wm_shell_class;
+ VendorShellClassPart vendor_shell_class;
+ TopLevelShellClassPart top_level_shell_class;
+} TopLevelShellClassRec;
+
+externalref TopLevelShellClassRec topLevelShellClassRec;
+
+/* New fields for the top level shell widget */
+
+typedef struct {
+ char *icon_name;
+ Boolean iconic;
+ Atom icon_name_encoding;
+} TopLevelShellPart;
+
+typedef struct {
+ CorePart core;
+ CompositePart composite;
+ ShellPart shell;
+ WMShellPart wm;
+ VendorShellPart vendor;
+ TopLevelShellPart topLevel;
+} TopLevelShellRec, *TopLevelShellWidget;
+
+/***********************************************************************
+ *
+ * ApplicationShell Widget Private Data
+ *
+ ***********************************************************************/
+
+/* New fields for the ApplicationShell widget class record */
+
+typedef struct {
+ XtPointer extension; /* pointer to extension record */
+} ApplicationShellClassPart;
+
+typedef struct _ApplicationShellClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ShellClassPart shell_class;
+ WMShellClassPart wm_shell_class;
+ VendorShellClassPart vendor_shell_class;
+ TopLevelShellClassPart top_level_shell_class;
+ ApplicationShellClassPart application_shell_class;
+} ApplicationShellClassRec;
+
+externalref ApplicationShellClassRec applicationShellClassRec;
+
+/* New fields for the application shell widget */
+
+typedef struct {
+#if defined(__cplusplus) || defined(c_plusplus)
+ char *c_class;
+#else
+ char *class;
+#endif
+ XrmClass xrm_class;
+ int argc;
+ char **argv;
+} ApplicationShellPart;
+
+typedef struct {
+ CorePart core;
+ CompositePart composite;
+ ShellPart shell;
+ WMShellPart wm;
+ VendorShellPart vendor;
+ TopLevelShellPart topLevel;
+ ApplicationShellPart application;
+} ApplicationShellRec, *ApplicationShellWidget;
+
+/***********************************************************************
+ *
+ * SessionShell Widget Private Data
+ *
+ ***********************************************************************/
+
+/* New fields for the SessionShell widget class record */
+
+typedef struct {
+ XtPointer extension; /* pointer to extension record */
+} SessionShellClassPart;
+
+typedef struct _SessionShellClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ShellClassPart shell_class;
+ WMShellClassPart wm_shell_class;
+ VendorShellClassPart vendor_shell_class;
+ TopLevelShellClassPart top_level_shell_class;
+ ApplicationShellClassPart application_shell_class;
+ SessionShellClassPart session_shell_class;
+} SessionShellClassRec;
+
+externalref SessionShellClassRec sessionShellClassRec;
+
+typedef struct _XtSaveYourselfRec *XtSaveYourself; /* implementation-private */
+
+/* New fields for the session shell widget */
+
+typedef struct {
+ SmcConn connection;
+ String session_id;
+ String* restart_command;
+ String* clone_command;
+ String* discard_command;
+ String* resign_command;
+ String* shutdown_command;
+ String* environment;
+ String current_dir;
+ String program_path;
+ unsigned char restart_style;
+ unsigned char checkpoint_state;
+ Boolean join_session;
+ XtCallbackList save_callbacks;
+ XtCallbackList interact_callbacks;
+ XtCallbackList cancel_callbacks;
+ XtCallbackList save_complete_callbacks;
+ XtCallbackList die_callbacks;
+ XtCallbackList error_callbacks;
+ XtSaveYourself save;
+ XtInputId input_id;
+ XtPointer ses20;
+ XtPointer ses19;
+ XtPointer ses18;
+ XtPointer ses17;
+ XtPointer ses16;
+ XtPointer ses15;
+ XtPointer ses14;
+ XtPointer ses13;
+ XtPointer ses12;
+ XtPointer ses11;
+ XtPointer ses10;
+ XtPointer ses9;
+ XtPointer ses8;
+ XtPointer ses7;
+ XtPointer ses6;
+ XtPointer ses5;
+ XtPointer ses4;
+ XtPointer ses3;
+ XtPointer ses2;
+ XtPointer ses1;
+} SessionShellPart;
+
+typedef struct {
+ CorePart core;
+ CompositePart composite;
+ ShellPart shell;
+ WMShellPart wm;
+ VendorShellPart vendor;
+ TopLevelShellPart topLevel;
+ ApplicationShellPart application;
+ SessionShellPart session;
+} SessionShellRec, *SessionShellWidget;
+
+#endif /* _XtShellPrivate_h */
diff --git a/nx-X11/lib/Xt/TMaction.c b/nx-X11/lib/Xt/TMaction.c
new file mode 100644
index 000000000..54a8402ec
--- /dev/null
+++ b/nx-X11/lib/Xt/TMaction.c
@@ -0,0 +1,1056 @@
+/* $Xorg: TMaction.c,v 1.5 2001/02/09 02:03:58 xorgcvs Exp $ */
+/*LINTLIBRARY*/
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+/* $XFree86: xc/lib/Xt/TMaction.c,v 3.7 2001/12/14 19:56:30 dawes Exp $ */
+
+/* TMaction.c -- maintains the state table of actions for the translation
+ * manager.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+
+#if defined(__STDC__) && !defined(NORCONST)
+#define RConst const
+#else
+#define RConst /**/
+#endif
+
+static String XtNtranslationError = "translationError";
+
+typedef struct _CompiledAction{
+ XrmQuark signature;
+ XtActionProc proc;
+}CompiledAction, *CompiledActionTable;
+
+
+#define GetClassActions(wc) \
+ ((wc->core_class.actions) \
+? (((TMClassCache)wc->core_class.actions)->actions) \
+: NULL)
+
+static CompiledActionTable CompileActionTable(
+ register RConst struct _XtActionsRec *actions,
+ register Cardinal count, /* may be 0 */
+ Boolean stat, /* if False, copy before compiling in place */
+ Boolean perm) /* if False, use XrmStringToQuark */
+{
+ register CompiledActionTable cActions;
+ register int i;
+ CompiledAction hold;
+ CompiledActionTable cTableHold;
+ XrmQuark (*func)(_Xconst char*);
+
+ if (!count)
+ return (CompiledActionTable) NULL;
+ func = (perm ? XrmPermStringToQuark : XrmStringToQuark);
+
+ if (! stat) {
+ cTableHold = cActions = (CompiledActionTable)
+ __XtMalloc(count * sizeof(CompiledAction));
+
+ for (i=count; --i >= 0; cActions++, actions++) {
+ cActions->proc = actions->proc;
+ cActions->signature = (*func)(actions->string);
+ }
+ } else {
+ cTableHold = (CompiledActionTable) actions;
+
+ for (i=count; --i >= 0; actions++)
+ ((CompiledActionTable) actions)->signature =
+ (*func)(actions->string);
+ }
+ cActions = cTableHold;
+
+ /* Insertion sort. Whatever sort is used, it must be stable. */
+ for (i=1; (Cardinal) i <= count - 1; i++) {
+ register Cardinal j;
+ hold = cActions[i];
+ j = i;
+ while (j && cActions[j-1].signature > hold.signature) {
+ cActions[j] = cActions[j-1];
+ j--;
+ }
+ cActions[j] = hold;
+ }
+
+ return cActions;
+}
+
+
+typedef struct _ActionListRec *ActionList;
+typedef struct _ActionListRec {
+ ActionList next;
+ CompiledActionTable table;
+ TMShortCard count;
+} ActionListRec;
+
+static void ReportUnboundActions(
+ XtTranslations xlations,
+ TMBindData bindData)
+{
+ TMSimpleStateTree stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0];
+ Cardinal num_unbound = 0;
+ Cardinal num_params = 1;
+ char* message;
+ char messagebuf[1000];
+ String params[1];
+ register Cardinal num_chars = 0;
+ register Cardinal i, j;
+ XtActionProc *procs;
+
+ for (i=0; i < xlations->numStateTrees; i++) {
+ if (bindData->simple.isComplex)
+ procs = TMGetComplexBindEntry(bindData, i)->procs;
+ else
+ procs = TMGetSimpleBindEntry(bindData, i)->procs;
+
+ stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i];
+ for (j=0; j < stateTree->numQuarks; j++) {
+ if (procs[j] == NULL) {
+ String s = XrmQuarkToString(stateTree->quarkTbl[j]);
+ if (num_unbound != 0)
+ num_chars += 2;
+ num_chars += strlen(s);
+ num_unbound++;
+ }
+ }
+ }
+ if (num_unbound == 0)
+ return;
+ message = XtStackAlloc (num_chars + 1, messagebuf);
+ if (message != NULL) {
+ *message = '\0';
+ num_unbound = 0;
+ stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0];
+ for (i=0; i < xlations->numStateTrees; i++) {
+ if (bindData->simple.isComplex)
+ procs = TMGetComplexBindEntry(bindData, i)->procs;
+ else
+ procs = TMGetSimpleBindEntry(bindData, i)->procs;
+
+ stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i];
+ for (j=0; j < stateTree->numQuarks; j++) {
+ if (procs[j] == NULL) {
+ String s = XrmQuarkToString(stateTree->quarkTbl[j]);
+ if (num_unbound != 0)
+ (void) strcat(message, ", ");
+ (void) strcat(message, s);
+ num_unbound++;
+ }
+ }
+ }
+ message[num_chars] = '\0';
+ params[0] = message;
+ XtWarningMsg(XtNtranslationError,"unboundActions",XtCXtToolkitError,
+ "Actions not found: %s",
+ params, &num_params);
+ XtStackFree (message, messagebuf);
+ }
+}
+
+
+static CompiledAction *SearchActionTable(
+ XrmQuark signature,
+ CompiledActionTable actionTable,
+ Cardinal numActions)
+{
+ register int i, left, right;
+
+ left = 0;
+ right = numActions - 1;
+ while (left <= right) {
+ i = (left + right) >> 1;
+ if (signature < actionTable[i].signature)
+ right = i - 1;
+ else if (signature > actionTable[i].signature)
+ left = i + 1;
+ else {
+ while (i && actionTable[i - 1].signature == signature)
+ i--;
+ return &actionTable[i];
+ }
+ }
+ return (CompiledAction *) NULL;
+}
+
+static int BindActions(
+ TMSimpleStateTree stateTree,
+ XtActionProc *procs,
+ CompiledActionTable compiledActionTable,
+ TMShortCard numActions,
+ Cardinal *ndxP)
+{
+ register int unbound = stateTree->numQuarks - *ndxP;
+ CompiledAction* action;
+ register Cardinal ndx;
+ register Boolean savedNdx = False;
+
+ for (ndx = *ndxP; ndx < stateTree->numQuarks; ndx++) {
+ if (procs[ndx] == NULL) {
+ /* attempt to bind it */
+ XrmQuark q = stateTree->quarkTbl[ndx];
+
+ action = SearchActionTable(q, compiledActionTable, numActions);
+ if (action) {
+ procs[ndx] = action->proc;
+ unbound--;
+ } else if (!savedNdx) {
+ *ndxP= ndx;
+ savedNdx = True;
+ }
+ } else {
+ /* already bound, leave it alone */
+ unbound--;
+ }
+ }
+ return unbound;
+}
+
+typedef struct _TMBindCacheStatusRec{
+ unsigned int boundInClass:1;
+ unsigned int boundInHierarchy:1;
+ unsigned int boundInContext:1;
+ unsigned int notFullyBound:1;
+ unsigned int refCount:28;
+}TMBindCacheStatusRec, *TMBindCacheStatus;
+
+typedef struct _TMBindCacheRec{
+ struct _TMBindCacheRec *next;
+ TMBindCacheStatusRec status;
+ TMStateTree stateTree;
+#ifdef TRACE_TM
+ WidgetClass widgetClass;
+#endif /* TRACE_TM */
+ XtActionProc procs[1]; /* variable length */
+}TMBindCacheRec, *TMBindCache;
+
+typedef struct _TMClassCacheRec {
+ CompiledActionTable actions;
+ TMBindCacheRec *bindCache;
+}TMClassCacheRec, *TMClassCache;
+
+#define IsPureClassBind(bc) \
+ (bc->status.boundInClass && \
+ !(bc->status.boundInHierarchy || \
+ bc->status.boundInContext || \
+ bc->status.notFullyBound))
+
+#define GetClassCache(w) \
+ ((TMClassCache)w->core.widget_class->core_class.actions)
+
+
+static int BindProcs(
+ Widget widget,
+ TMSimpleStateTree stateTree,
+ XtActionProc *procs,
+ TMBindCacheStatus bindStatus)
+{
+ register WidgetClass class;
+ register ActionList actionList;
+ int unbound = -1, newUnbound = -1;
+ Cardinal ndx = 0;
+ Widget w = widget;
+
+ LOCK_PROCESS;
+ do {
+ class = w->core.widget_class;
+ do {
+ if (class->core_class.actions != NULL)
+ unbound =
+ BindActions(stateTree,
+ procs,
+ GetClassActions(class),
+ class->core_class.num_actions,
+ &ndx);
+ class = class->core_class.superclass;
+ } while (unbound != 0 && class != NULL);
+ if (unbound < (int)stateTree->numQuarks)
+ bindStatus->boundInClass = True;
+ else
+ bindStatus->boundInClass = False;
+ if (newUnbound == -1)
+ newUnbound = unbound;
+ w = XtParent(w);
+ } while (unbound != 0 && w != NULL);
+
+ if (newUnbound > unbound)
+ bindStatus->boundInHierarchy = True;
+ else
+ bindStatus->boundInHierarchy = False;
+
+ if (unbound) {
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+ newUnbound = unbound;
+ for (actionList = app->action_table;
+ unbound != 0 && actionList != NULL;
+ actionList = actionList->next) {
+ unbound = BindActions(stateTree,
+ procs,
+ actionList->table,
+ actionList->count,
+ &ndx);
+ }
+ if (newUnbound > unbound)
+ bindStatus->boundInContext = True;
+ else
+ bindStatus->boundInContext = False;
+
+ } else {
+ bindStatus->boundInContext = False;
+ }
+ UNLOCK_PROCESS;
+ return unbound;
+}
+
+static XtActionProc *TryBindCache(
+ Widget widget,
+ TMStateTree stateTree)
+{
+ TMClassCache classCache;
+
+ LOCK_PROCESS;
+ classCache = GetClassCache(widget);
+
+ if (classCache == NULL)
+ {
+ WidgetClass wc = XtClass(widget);
+
+ wc->core_class.actions = (XtActionList)
+ _XtInitializeActionData(NULL, 0, True);
+ }
+ else
+ {
+ TMBindCache bindCache =
+ (TMBindCache)(classCache->bindCache);
+ for (; bindCache; bindCache = bindCache->next)
+ {
+ if (IsPureClassBind(bindCache) &&
+ (stateTree == bindCache->stateTree))
+ {
+ bindCache->status.refCount++;
+ UNLOCK_PROCESS;
+ return &bindCache->procs[0];
+ }
+ }
+ }
+ UNLOCK_PROCESS;
+ return NULL;
+}
+
+
+
+/*
+ * The class record actions field will point to the bind cache header
+ * after this call is made out of coreClassPartInit.
+ */
+XtPointer _XtInitializeActionData(
+ register struct _XtActionsRec *actions,
+ register Cardinal count,
+ _XtBoolean inPlace)
+{
+ TMClassCache classCache;
+
+ classCache = XtNew(TMClassCacheRec);
+ classCache->actions = CompileActionTable(actions, count, inPlace, True);
+ classCache->bindCache = NULL;
+ return (XtPointer)classCache;
+}
+
+
+#define TM_BIND_CACHE_REALLOC 2
+
+static XtActionProc *EnterBindCache(
+ Widget w,
+ TMSimpleStateTree stateTree,
+ XtActionProc *procs,
+ TMBindCacheStatus bindStatus)
+{
+ TMClassCache classCache;
+ TMBindCache* bindCachePtr;
+ TMShortCard procsSize;
+ TMBindCache bindCache;
+
+ LOCK_PROCESS;
+ classCache = GetClassCache(w);
+ bindCachePtr = &classCache->bindCache;
+ procsSize = stateTree->numQuarks * sizeof(XtActionProc);
+
+ for (bindCache = *bindCachePtr;
+ (*bindCachePtr);
+ bindCachePtr = &(*bindCachePtr)->next, bindCache = *bindCachePtr)
+ {
+ TMBindCacheStatus cacheStatus = &bindCache->status;
+
+ if ((bindStatus->boundInClass == cacheStatus->boundInClass) &&
+ (bindStatus->boundInHierarchy == cacheStatus->boundInHierarchy) &&
+ (bindStatus->boundInContext == cacheStatus->boundInContext) &&
+ (bindCache->stateTree == (TMStateTree)stateTree) &&
+ !XtMemcmp(&bindCache->procs[0], procs, procsSize))
+ {
+ bindCache->status.refCount++;
+ break;
+ }
+ }
+ if (*bindCachePtr == NULL)
+ {
+ *bindCachePtr =
+ bindCache = (TMBindCache)
+ __XtMalloc(sizeof(TMBindCacheRec) +
+ (procsSize - sizeof(XtActionProc)));
+ bindCache->next = NULL;
+ bindCache->status = *bindStatus;
+ bindCache->status.refCount = 1;
+ bindCache->stateTree = (TMStateTree)stateTree;
+#ifdef TRACE_TM
+ bindCache->widgetClass = XtClass(w);
+ if (_XtGlobalTM.numBindCache == _XtGlobalTM.bindCacheTblSize)
+ {
+ _XtGlobalTM.bindCacheTblSize += 16;
+ _XtGlobalTM.bindCacheTbl = (TMBindCache *)
+ XtRealloc((char *)_XtGlobalTM.bindCacheTbl,
+ ((_XtGlobalTM.bindCacheTblSize) *
+ sizeof(TMBindCache)));
+ }
+ _XtGlobalTM.bindCacheTbl[_XtGlobalTM.numBindCache++] = bindCache;
+#endif /* TRACE_TM */
+ XtMemmove((XtPointer)&bindCache->procs[0],
+ (XtPointer)procs, procsSize);
+ }
+ UNLOCK_PROCESS;
+ return &bindCache->procs[0];
+}
+
+static void RemoveFromBindCache(
+ Widget w,
+ XtActionProc *procs)
+{
+ TMClassCache classCache;
+ TMBindCache* bindCachePtr;
+ TMBindCache bindCache;
+ XtAppContext app = XtWidgetToApplicationContext (w);
+
+ LOCK_PROCESS;
+ classCache = GetClassCache(w);
+ bindCachePtr = (TMBindCache *)&classCache->bindCache;
+
+ for (bindCache = *bindCachePtr;
+ *bindCachePtr;
+ bindCachePtr = &(*bindCachePtr)->next, bindCache = *bindCachePtr)
+ {
+ if (&bindCache->procs[0] == procs)
+ {
+ if (--bindCache->status.refCount == 0)
+ {
+#ifdef TRACE_TM
+ TMShortCard j;
+ Boolean found = False;
+ TMBindCache *tbl = _XtGlobalTM.bindCacheTbl;
+
+ for (j = 0; j < _XtGlobalTM.numBindCache; j++) {
+ if (found)
+ tbl[j-1] = tbl[j];
+ if (tbl[j] == bindCache)
+ found = True;
+ }
+ if (!found)
+ XtWarning("where's the action ??? ");
+ else
+ _XtGlobalTM.numBindCache--;
+#endif /* TRACE_TM */
+ *bindCachePtr = bindCache->next;
+ bindCache->next = app->free_bindings;
+ app->free_bindings = bindCache;
+ }
+ break;
+ }
+ }
+ UNLOCK_PROCESS;
+}
+
+/* ARGSUSED */
+static void RemoveAccelerators(
+ Widget widget,
+ XtPointer closure, XtPointer data)
+{
+ Widget destination = (Widget)closure;
+ TMComplexBindProcs bindProcs;
+ XtTranslations stackXlations[16];
+ XtTranslations *xlationsList, destXlations;
+ TMShortCard i, numXlations = 0;
+
+ if ((destXlations = destination->core.tm.translations) == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ XtNtranslationError,"nullTable",XtCXtToolkitError,
+ "Can't remove accelerators from NULL table",
+ (String *)NULL, (Cardinal *)NULL);
+ return;
+ }
+
+ xlationsList = (XtTranslations *)
+ XtStackAlloc((destXlations->numStateTrees * sizeof(XtTranslations)),
+ stackXlations);
+
+ for (i = 0, bindProcs = TMGetComplexBindEntry(destination->core.tm.proc_table, i);
+ i < destXlations->numStateTrees;
+ i++, bindProcs++) {
+ if (bindProcs->widget == widget) {
+ /*
+ * if it's being destroyed don't do all the work
+ */
+ if (destination->core.being_destroyed) {
+ bindProcs->procs = NULL;
+ }
+ else
+ xlationsList[numXlations] = bindProcs->aXlations;
+ numXlations++;
+ }
+ }
+
+ if (numXlations == 0)
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ XtNtranslationError,"nullTable",XtCXtToolkitError,
+ "Tried to remove nonexistent accelerators",
+ (String *)NULL, (Cardinal *)NULL);
+ else {
+ if (!destination->core.being_destroyed)
+ for (i = 0; i < numXlations; i++)
+ _XtUnmergeTranslations(destination, xlationsList[i]);
+ }
+ XtStackFree((char *)xlationsList, stackXlations);
+}
+
+void _XtBindActions(
+ Widget widget,
+ XtTM tm)
+{
+ XtTranslations xlations = tm->translations;
+ TMSimpleStateTree stateTree;
+ int globalUnbound = 0;
+ Cardinal i;
+ TMBindData bindData = (TMBindData)tm->proc_table;
+ TMSimpleBindProcs simpleBindProcs = NULL;
+ TMComplexBindProcs complexBindProcs = NULL;
+ XtActionProc *newProcs;
+ Widget bindWidget;
+
+ if ((xlations == NULL) || widget->core.being_destroyed)
+ return;
+
+ stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0];
+
+ for (i = 0; i < xlations->numStateTrees; i++)
+ {
+ stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i];
+ if (bindData->simple.isComplex) {
+ complexBindProcs = TMGetComplexBindEntry(bindData, i);
+ if (complexBindProcs->widget) {
+ bindWidget = complexBindProcs->widget;
+
+ if (bindWidget->core.destroy_callbacks != NULL)
+ _XtAddCallbackOnce((InternalCallbackList *)
+ &bindWidget->core.destroy_callbacks,
+ RemoveAccelerators,
+ (XtPointer)widget);
+ else
+ _XtAddCallback((InternalCallbackList *)
+ &bindWidget->core.destroy_callbacks,
+ RemoveAccelerators,
+ (XtPointer)widget);
+ }
+ else
+ bindWidget = widget;
+ }
+ else {
+ simpleBindProcs = TMGetSimpleBindEntry(bindData, i);
+ bindWidget = widget;
+ }
+ if ((newProcs =
+ TryBindCache(bindWidget,(TMStateTree)stateTree)) == NULL)
+ {
+ XtActionProc *procs, stackProcs[256];
+ int localUnbound;
+ TMBindCacheStatusRec bcStatusRec;
+
+ procs = (XtActionProc *)
+ XtStackAlloc(stateTree->numQuarks * sizeof(XtActionProc),
+ stackProcs);
+ XtBZero((XtPointer)procs,
+ stateTree->numQuarks * sizeof(XtActionProc));
+
+ localUnbound = BindProcs(bindWidget,
+ stateTree,
+ procs,
+ &bcStatusRec);
+
+ if (localUnbound)
+ bcStatusRec.notFullyBound = True;
+ else
+ bcStatusRec.notFullyBound = False;
+
+ newProcs =
+ EnterBindCache(bindWidget,
+ stateTree,
+ procs,
+ &bcStatusRec);
+ XtStackFree((XtPointer)procs, (XtPointer)stackProcs);
+ globalUnbound += localUnbound;
+ }
+ if (bindData->simple.isComplex)
+ complexBindProcs->procs = newProcs;
+ else
+ simpleBindProcs->procs = newProcs;
+ }
+ if (globalUnbound)
+ ReportUnboundActions(xlations,
+ (TMBindData)tm->proc_table);
+}
+
+
+void _XtUnbindActions(
+ Widget widget,
+ XtTranslations xlations,
+ TMBindData bindData)
+{
+ Cardinal i;
+ Widget bindWidget;
+ XtActionProc *procs;
+
+ if ((xlations == NULL) || !XtIsRealized(widget)) return;
+
+ for (i = 0; i < xlations->numStateTrees; i++) {
+ if (bindData->simple.isComplex) {
+ TMComplexBindProcs complexBindProcs;
+
+ complexBindProcs = TMGetComplexBindEntry(bindData, i);
+
+ if (complexBindProcs->widget) {
+ /*
+ * check for this being an accelerator binding whose
+ * source is gone ( set by RemoveAccelerators)
+ */
+ if (complexBindProcs->procs == NULL)
+ continue;
+
+ XtRemoveCallback(complexBindProcs->widget,
+ XtNdestroyCallback,
+ RemoveAccelerators,
+ (XtPointer)widget);
+ bindWidget = complexBindProcs->widget;
+ }
+ else
+ bindWidget = widget;
+ procs = complexBindProcs->procs;
+ complexBindProcs->procs = NULL;
+ }
+ else {
+ TMSimpleBindProcs simpleBindProcs;
+ simpleBindProcs = TMGetSimpleBindEntry(bindData,i);
+ procs = simpleBindProcs->procs;
+ simpleBindProcs->procs = NULL;
+ bindWidget = widget;
+ }
+ RemoveFromBindCache(bindWidget, procs);
+ }
+}
+
+#ifdef notdef
+void _XtRemoveBindProcsByIndex(
+ Widget w,
+ TMBindData bindData,
+ TMShortCard ndx)
+{
+ TMShortCard i = ndx;
+ TMBindProcs bindProcs = (TMBindProcs)&bindData->bindTbl[0];
+
+ RemoveFromBindCache(bindProcs->widget ? bindProcs->widget : w,
+ bindProcs[i].procs);
+
+ for (; i < bindData->bindTblSize; i++)
+ bindProcs[i] = bindProcs[i+1];
+}
+#endif /* notdef */
+
+/*
+ * used to free all copied action tables, called from DestroyAppContext
+ */
+void _XtFreeActions(
+ ActionList actions)
+{
+ ActionList curr, next;
+
+ for (curr = actions; curr;) {
+ next = curr->next;
+ XtFree((char *)curr->table);
+ XtFree((char *)curr);
+ curr = next;
+ }
+}
+
+void XtAddActions(
+ XtActionList actions,
+ Cardinal num_actions)
+{
+ XtAppAddActions(_XtDefaultAppContext(), actions, num_actions);
+}
+
+void XtAppAddActions(
+ XtAppContext app,
+ XtActionList actions,
+ Cardinal num_actions)
+{
+ register ActionList rec;
+
+ LOCK_APP(app);
+ rec = XtNew(ActionListRec);
+ rec->next = app->action_table;
+ app->action_table = rec;
+ rec->table = CompileActionTable(actions, num_actions, False, False);
+ rec->count = num_actions;
+ UNLOCK_APP(app);
+}
+
+void XtGetActionList(
+ WidgetClass widget_class,
+ XtActionList* actions_return,
+ Cardinal* num_actions_return)
+{
+ XtActionList list;
+ CompiledActionTable table;
+ int i;
+
+ *actions_return = NULL;
+ *num_actions_return = 0;
+
+ LOCK_PROCESS;
+ if (! widget_class->core_class.class_inited) {
+ UNLOCK_PROCESS;
+ return;
+ }
+ if (! (widget_class->core_class.class_inited & WidgetClassFlag)) {
+ UNLOCK_PROCESS;
+ return;
+ }
+ *num_actions_return = widget_class->core_class.num_actions;
+ if (*num_actions_return) {
+ list = *actions_return = (XtActionList)
+ __XtMalloc(*num_actions_return * sizeof(XtActionsRec));
+ table = GetClassActions(widget_class);
+ for (i= (*num_actions_return); --i >= 0; list++, table++) {
+ list->string = XrmQuarkToString(table->signature);
+ list->proc = table->proc;
+ }
+ }
+ UNLOCK_PROCESS;
+}
+
+/***********************************************************************
+ *
+ * Pop-up and Grab stuff
+ *
+ ***********************************************************************/
+
+static Widget _XtFindPopup(
+ Widget widget,
+ String name)
+{
+ register Cardinal i;
+ register XrmQuark q;
+ register Widget w;
+
+ q = XrmStringToQuark(name);
+
+ for (w=widget; w != NULL; w=w->core.parent)
+ for (i=0; i<w->core.num_popups; i++)
+ if (w->core.popup_list[i]->core.xrm_name == q)
+ return w->core.popup_list[i];
+
+ return NULL;
+}
+
+void XtMenuPopupAction(
+ Widget widget,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
+{
+ Boolean spring_loaded;
+ register Widget popup_shell;
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+
+ LOCK_APP(app);
+ if (*num_params != 1) {
+ XtAppWarningMsg(app,
+ "invalidParameters","xtMenuPopupAction",XtCXtToolkitError,
+ "MenuPopup wants exactly one argument",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_APP(app);
+ return;
+ }
+
+ if (event->type == ButtonPress)
+ spring_loaded = True;
+ else if (event->type == KeyPress || event->type == EnterNotify)
+ spring_loaded = False;
+ else {
+ XtAppWarningMsg(app,
+ "invalidPopup","unsupportedOperation",XtCXtToolkitError,
+"Pop-up menu creation is only supported on ButtonPress, KeyPress or EnterNotify events.",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_APP(app);
+ return;
+ }
+
+ popup_shell = _XtFindPopup(widget, params[0]);
+ if (popup_shell == NULL) {
+ XtAppWarningMsg(app,
+ "invalidPopup","xtMenuPopup",XtCXtToolkitError,
+ "Can't find popup widget \"%s\" in XtMenuPopup",
+ params, num_params);
+ UNLOCK_APP(app);
+ return;
+ }
+
+ if (spring_loaded) _XtPopup(popup_shell, XtGrabExclusive, TRUE);
+ else _XtPopup(popup_shell, XtGrabNonexclusive, FALSE);
+ UNLOCK_APP(app);
+}
+
+
+/*ARGSUSED*/
+static void _XtMenuPopdownAction(
+ Widget widget,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
+{
+ Widget popup_shell;
+
+ if (*num_params == 0) {
+ XtPopdown(widget);
+ } else if (*num_params == 1) {
+ popup_shell = _XtFindPopup(widget, params[0]);
+ if (popup_shell == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "invalidPopup","xtMenuPopdown",XtCXtToolkitError,
+ "Can't find popup widget \"%s\" in XtMenuPopdown",
+ params, num_params);
+ return;
+ }
+ XtPopdown(popup_shell);
+ } else {
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "invalidParameters","xtMenuPopdown",XtCXtToolkitError,
+ "XtMenuPopdown called with num_params != 0 or 1",
+ (String *)NULL, (Cardinal *)NULL);
+ }
+}
+
+static XtActionsRec RConst tmActions[] = {
+ {"XtMenuPopup", XtMenuPopupAction},
+ {"XtMenuPopdown", _XtMenuPopdownAction},
+ {"MenuPopup", XtMenuPopupAction}, /* old & obsolete */
+ {"MenuPopdown", _XtMenuPopdownAction}, /* ditto */
+#ifndef NO_MIT_HACKS
+ {"XtDisplayTranslations", _XtDisplayTranslations},
+ {"XtDisplayAccelerators", _XtDisplayAccelerators},
+ {"XtDisplayInstalledAccelerators", _XtDisplayInstalledAccelerators},
+#endif
+};
+
+
+void _XtPopupInitialize(
+ XtAppContext app)
+{
+ register ActionList rec;
+
+ /*
+ * The _XtGlobalTM.newMatchSemantics flag determines whether
+ * we support old or new matching
+ * behavior. This is mainly an issue of whether subsequent lhs will
+ * get pushed up in the match table if a lhs containing thier initial
+ * sequence has already been encountered. Currently inited to False;
+ */
+#ifdef NEW_TM
+ _XtGlobalTM.newMatchSemantics = True;
+#else
+ _XtGlobalTM.newMatchSemantics = False;
+#endif
+
+ rec = XtNew(ActionListRec);
+ rec->next = app->action_table;
+ app->action_table = rec;
+ LOCK_PROCESS;
+ rec->table = CompileActionTable(tmActions, XtNumber(tmActions), False,
+ True);
+ rec->count = XtNumber(tmActions);
+ UNLOCK_PROCESS;
+ _XtGrabInitialize(app);
+}
+
+
+void XtCallActionProc(
+ Widget widget,
+ _Xconst char* action,
+ XEvent *event,
+ String *params,
+ Cardinal num_params)
+{
+ CompiledAction* actionP;
+ XrmQuark q = XrmStringToQuark(action);
+ Widget w = widget;
+ XtAppContext app = XtWidgetToApplicationContext(widget);
+ ActionList actionList;
+ Cardinal i;
+
+ LOCK_APP(app);
+ XtCheckSubclass(widget, coreWidgetClass,
+ "XtCallActionProc first argument is not a subclass of Core");
+ LOCK_PROCESS;
+ do {
+ WidgetClass class = XtClass(w);
+ do {
+ if ((actionP = GetClassActions(class)) != NULL)
+ for (i = 0;
+ i < class->core_class.num_actions;
+ i++, actionP++) {
+
+ if (actionP->signature == q) {
+ ActionHook hook = app->action_hook_list;
+ while (hook != NULL) {
+ (*hook->proc)( widget,
+ hook->closure,
+ (String)action,
+ event,
+ params,
+ &num_params
+ );
+ hook= hook->next;
+ }
+ (*(actionP->proc))
+ (widget, event, params, &num_params);
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return;
+ }
+ }
+ class = class->core_class.superclass;
+ } while (class != NULL);
+ w = XtParent(w);
+ } while (w != NULL);
+ UNLOCK_PROCESS;
+
+ for (actionList = app->action_table;
+ actionList != NULL;
+ actionList = actionList->next) {
+
+ for (i = 0, actionP = actionList->table;
+ i < actionList->count;
+ i++, actionP++) {
+ if (actionP->signature == q) {
+ ActionHook hook = app->action_hook_list;
+ while (hook != NULL) {
+ (*hook->proc)( widget,
+ hook->closure,
+ (String)action,
+ event,
+ params,
+ &num_params
+ );
+ hook= hook->next;
+ }
+ (*(actionP->proc))
+ (widget, event, params, &num_params);
+ UNLOCK_APP(app);
+ return;
+ }
+ }
+
+ }
+
+ {
+ String params[2];
+ Cardinal num_params = 2;
+ params[0] = (String)action;
+ params[1] = XtName(widget);
+ XtAppWarningMsg(app,
+ "noActionProc", "xtCallActionProc", XtCXtToolkitError,
+ "No action proc named \"%s\" is registered for widget \"%s\"",
+ params, &num_params
+ );
+ }
+ UNLOCK_APP(app);
+}
+
+void _XtDoFreeBindings(
+ XtAppContext app)
+{
+ TMBindCache bcp;
+
+ while (app->free_bindings) {
+ bcp = app->free_bindings->next;
+ XtFree ((char *) app->free_bindings);
+ app->free_bindings = bcp;
+ }
+}
diff --git a/nx-X11/lib/Xt/TMgrab.c b/nx-X11/lib/Xt/TMgrab.c
new file mode 100644
index 000000000..9fc4df982
--- /dev/null
+++ b/nx-X11/lib/Xt/TMgrab.c
@@ -0,0 +1,336 @@
+/* $Xorg: TMgrab.c,v 1.4 2001/02/09 02:03:58 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+/* $XFree86: xc/lib/Xt/TMgrab.c,v 1.3 2001/12/14 19:56:30 dawes Exp $ */
+
+/*LINTLIBRARY*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+
+typedef struct _GrabActionRec {
+ struct _GrabActionRec* next;
+ XtActionProc action_proc;
+ Boolean owner_events;
+ unsigned int event_mask;
+ int pointer_mode, keyboard_mode;
+} GrabActionRec;
+
+static GrabActionRec *grabActionList = NULL;
+
+static void GrabAllCorrectKeys(
+ Widget widget,
+ TMTypeMatch typeMatch,
+ TMModifierMatch modMatch,
+ GrabActionRec* grabP)
+{
+ Display *dpy = XtDisplay(widget);
+ KeyCode *keycodes, *keycodeP;
+ Cardinal keycount;
+ Modifiers careOn = 0;
+ Modifiers careMask = 0;
+
+ if (modMatch->lateModifiers) {
+ Boolean resolved;
+ resolved = _XtComputeLateBindings(dpy, modMatch->lateModifiers,
+ &careOn, &careMask);
+ if (!resolved) return;
+ }
+ careOn |= modMatch->modifiers;
+ careMask |= modMatch->modifierMask;
+
+ XtKeysymToKeycodeList(
+ dpy,
+ (KeySym)typeMatch->eventCode,
+ &keycodes,
+ &keycount
+ );
+ if (keycount == 0) return;
+ for (keycodeP = keycodes; keycount--; keycodeP++) {
+ if (modMatch->standard) {
+ /* find standard modifiers that produce this keysym */
+ KeySym keysym;
+ int std_mods, least_mod;
+ Modifiers modifiers_return;
+ XtTranslateKeycode( dpy, *keycodeP, (Modifiers)0,
+ &modifiers_return, &keysym );
+ if (careOn & modifiers_return)
+ return;
+ if (keysym == typeMatch->eventCode) {
+ XtGrabKey(widget, *keycodeP, careOn,
+ grabP->owner_events,
+ grabP->pointer_mode,
+ grabP->keyboard_mode
+ );
+ /* continue; */ /* grab all modifier combinations */
+ }
+ least_mod = modifiers_return & (~modifiers_return + 1);
+ for (std_mods = modifiers_return;
+ std_mods >= least_mod; std_mods--) {
+ Modifiers dummy;
+ /* check all useful combinations of modifier bits */
+ if (modifiers_return & std_mods &&
+ !(~modifiers_return & std_mods)) {
+ XtTranslateKeycode( dpy, *keycodeP,
+ (Modifiers)std_mods,
+ &dummy, &keysym );
+ if (keysym == typeMatch->eventCode) {
+ XtGrabKey(widget, *keycodeP,
+ careOn | (Modifiers) std_mods,
+ grabP->owner_events,
+ grabP->pointer_mode,
+ grabP->keyboard_mode
+ );
+ /* break; */ /* grab all modifier combinations */
+ }
+ }
+ }
+ } else /* !event->standard */ {
+ XtGrabKey(widget, *keycodeP, careOn,
+ grabP->owner_events,
+ grabP->pointer_mode,
+ grabP->keyboard_mode
+ );
+ }
+ }
+ XtFree((char *)keycodes);
+}
+
+typedef struct {
+ TMShortCard count;
+ Widget widget;
+ GrabActionRec *grabP;
+}DoGrabRec;
+
+static Boolean DoGrab(
+ StatePtr state,
+ XtPointer data)
+{
+ DoGrabRec *doGrabP = (DoGrabRec *)data;
+ GrabActionRec* grabP = doGrabP->grabP;
+ Widget widget = doGrabP->widget;
+ TMShortCard count = doGrabP->count;
+ TMShortCard typeIndex = state->typeIndex;
+ TMShortCard modIndex = state->modIndex;
+ ActionRec *action;
+ TMTypeMatch typeMatch;
+ TMModifierMatch modMatch;
+ Modifiers careOn = 0;
+ Modifiers careMask = 0;
+ Boolean resolved;
+
+ LOCK_PROCESS;
+ typeMatch = TMGetTypeMatch(typeIndex);
+ modMatch = TMGetModifierMatch(modIndex);
+
+ for (action = state->actions; action; action = action->next)
+ if (count == action->idx) break;
+ if (!action) {
+ UNLOCK_PROCESS;
+ return False;
+ }
+
+ switch (typeMatch->eventType) {
+ case ButtonPress:
+ case ButtonRelease:
+ if (modMatch->lateModifiers) {
+ resolved = _XtComputeLateBindings(XtDisplay(widget),
+ modMatch->lateModifiers,
+ &careOn, &careMask);
+ if (!resolved) break;
+ }
+ careOn |= modMatch->modifiers;
+ XtGrabButton(
+ widget,
+ (unsigned) typeMatch->eventCode,
+ careOn,
+ grabP->owner_events,
+ grabP->event_mask,
+ grabP->pointer_mode,
+ grabP->keyboard_mode,
+ None,
+ None
+ );
+ break;
+
+ case KeyPress:
+ case KeyRelease:
+ GrabAllCorrectKeys(widget, typeMatch, modMatch, grabP);
+ break;
+
+ case EnterNotify:
+ break;
+
+ default:
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "invalidPopup","unsupportedOperation",XtCXtToolkitError,
+ "Pop-up menu creation is only supported on Button, Key or EnterNotify events.",
+ (String *)NULL, (Cardinal *)NULL);
+ break;
+ }
+ UNLOCK_PROCESS;
+ return False;
+}
+
+void _XtRegisterGrabs(
+ Widget widget)
+{
+ XtTranslations xlations = widget->core.tm.translations;
+ TMComplexStateTree *stateTreePtr;
+ unsigned int count;
+ TMShortCard i;
+ TMBindData bindData = (TMBindData) widget->core.tm.proc_table;
+ XtActionProc *procs;
+
+ if (! XtIsRealized(widget) || widget->core.being_destroyed)
+ return;
+
+ /* walk the widget instance action bindings table looking for */
+ /* actions registered as grab actions. */
+ /* when you find one, do a grab on the triggering event */
+
+ if (xlations == NULL) return;
+ stateTreePtr = (TMComplexStateTree *) xlations->stateTreeTbl;
+ if (*stateTreePtr == NULL) return;
+ for (i = 0; i < xlations->numStateTrees; i++, stateTreePtr++) {
+ if (bindData->simple.isComplex)
+ procs = TMGetComplexBindEntry(bindData, i)->procs;
+ else
+ procs = TMGetSimpleBindEntry(bindData, i)->procs;
+ for (count=0; count < (*stateTreePtr)->numQuarks; count++) {
+ GrabActionRec* grabP;
+ DoGrabRec doGrab;
+
+ LOCK_PROCESS;
+ for (grabP = grabActionList; grabP != NULL; grabP = grabP->next) {
+ if (grabP->action_proc == procs[count]) {
+ /* we've found a "grabber" in the action table. Find the
+ * states that call this action. Note that if there is
+ * more than one "grabber" in the action table, we end
+ * up searching all of the states multiple times.
+ */
+ doGrab.widget = widget;
+ doGrab.grabP = grabP;
+ doGrab.count = count;
+ _XtTraverseStateTree((TMStateTree)*stateTreePtr,
+ DoGrab,
+ (XtPointer)&doGrab);
+ }
+ }
+ UNLOCK_PROCESS;
+ }
+ }
+}
+
+void XtRegisterGrabAction(
+ XtActionProc action_proc,
+ _XtBoolean owner_events,
+ unsigned int event_mask,
+ int pointer_mode,
+ int keyboard_mode)
+{
+ GrabActionRec* actionP;
+
+ LOCK_PROCESS;
+ for (actionP = grabActionList; actionP != NULL; actionP = actionP->next) {
+ if (actionP->action_proc == action_proc) break;
+ }
+ if (actionP == NULL) {
+ actionP = XtNew(GrabActionRec);
+ actionP->action_proc = action_proc;
+ actionP->next = grabActionList;
+ grabActionList = actionP;
+ }
+#ifdef DEBUG
+ else
+ if ( actionP->owner_events != owner_events
+ || actionP->event_mask != event_mask
+ || actionP->pointer_mode != pointer_mode
+ || actionP->keyboard_mode != keyboard_mode) {
+ Cardinal n = 0;
+ XtWarningMsg(
+ "argsReplaced", "xtRegisterGrabAction", XtCXtToolkitError,
+ "XtRegisterGrabAction called on same proc with different args",
+ NULL, &n);
+ }
+#endif /*DEBUG*/
+
+ actionP->owner_events = owner_events;
+ actionP->event_mask = event_mask;
+ actionP->pointer_mode = pointer_mode;
+ actionP->keyboard_mode = keyboard_mode;
+ UNLOCK_PROCESS;
+}
+
+/*ARGSUSED*/
+void _XtGrabInitialize(
+ XtAppContext app)
+{
+ LOCK_PROCESS;
+ if (grabActionList == NULL)
+ XtRegisterGrabAction( XtMenuPopupAction, True,
+ (unsigned)(ButtonPressMask | ButtonReleaseMask),
+ GrabModeAsync,
+ GrabModeAsync
+ );
+ UNLOCK_PROCESS;
+
+}
diff --git a/nx-X11/lib/Xt/TMkey.c b/nx-X11/lib/Xt/TMkey.c
new file mode 100644
index 000000000..41944452a
--- /dev/null
+++ b/nx-X11/lib/Xt/TMkey.c
@@ -0,0 +1,715 @@
+/* $Xorg: TMkey.c,v 1.4 2001/02/09 02:03:58 xorgcvs Exp $ */
+/*LINTLIBRARY*/
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/TMkey.c,v 3.10 2001/12/14 19:56:30 dawes Exp $ */
+
+#define XK_MISCELLANY
+#define XK_LATIN1
+#define XK_LATIN2
+#define XK_LATIN3
+#define XK_LATIN4
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include <X11/keysymdef.h>
+#ifdef XKB
+#include <X11/XKBlib.h>
+#endif
+
+#define FLUSHKEYCACHE(ctx) \
+ bzero((char *)&ctx->keycache, sizeof(TMKeyCache))
+
+/*
+ * The following array reorders the modifier bits so that the most common ones
+ * (used by a translator) are in the top-most bits with respect to the size of
+ * the keycache. The array currently just reverses the bits as a good guess.
+ * This might be more trouble than it is worth, but it seems to help.
+ */
+
+#define FM(i) i >> (8 - TMKEYCACHELOG2)
+static const unsigned char modmix[256] = {
+FM(0x0f), FM(0x8f), FM(0x4f), FM(0xcf), FM(0x2f), FM(0xaf), FM(0x6f), FM(0xef),
+FM(0x1f), FM(0x9f), FM(0x5f), FM(0xdf), FM(0x3f), FM(0xbf), FM(0x7f), FM(0xff),
+FM(0x07), FM(0x87), FM(0x47), FM(0xc7), FM(0x27), FM(0xa7), FM(0x67), FM(0xe7),
+FM(0x17), FM(0x97), FM(0x57), FM(0xd7), FM(0x37), FM(0xb7), FM(0x77), FM(0xf7),
+FM(0x0b), FM(0x8b), FM(0x4b), FM(0xcb), FM(0x2b), FM(0xab), FM(0x6b), FM(0xeb),
+FM(0x1b), FM(0x9b), FM(0x5b), FM(0xdb), FM(0x3b), FM(0xbb), FM(0x7b), FM(0xfb),
+FM(0x03), FM(0x83), FM(0x43), FM(0xc3), FM(0x23), FM(0xa3), FM(0x63), FM(0xe3),
+FM(0x13), FM(0x93), FM(0x53), FM(0xd3), FM(0x33), FM(0xb3), FM(0x73), FM(0xf3),
+FM(0x0d), FM(0x8d), FM(0x4d), FM(0xcd), FM(0x2d), FM(0xad), FM(0x6d), FM(0xed),
+FM(0x1d), FM(0x9d), FM(0x5d), FM(0xdd), FM(0x3d), FM(0xbd), FM(0x7d), FM(0xfd),
+FM(0x05), FM(0x85), FM(0x45), FM(0xc5), FM(0x25), FM(0xa5), FM(0x65), FM(0xe5),
+FM(0x15), FM(0x95), FM(0x55), FM(0xd5), FM(0x35), FM(0xb5), FM(0x75), FM(0xf5),
+FM(0x09), FM(0x89), FM(0x49), FM(0xc9), FM(0x29), FM(0xa9), FM(0x69), FM(0xe9),
+FM(0x19), FM(0x99), FM(0x59), FM(0xd9), FM(0x39), FM(0xb9), FM(0x79), FM(0xf9),
+FM(0x01), FM(0x81), FM(0x41), FM(0xc1), FM(0x21), FM(0xa1), FM(0x61), FM(0xe1),
+FM(0x11), FM(0x91), FM(0x51), FM(0xd1), FM(0x31), FM(0xb1), FM(0x71), FM(0xf1),
+FM(0x00), FM(0x8e), FM(0x4e), FM(0xce), FM(0x2e), FM(0xae), FM(0x6e), FM(0xee),
+FM(0x1e), FM(0x9e), FM(0x5e), FM(0xde), FM(0x3e), FM(0xbe), FM(0x7e), FM(0xfe),
+FM(0x08), FM(0x88), FM(0x48), FM(0xc8), FM(0x28), FM(0xa8), FM(0x68), FM(0xe8),
+FM(0x18), FM(0x98), FM(0x58), FM(0xd8), FM(0x38), FM(0xb8), FM(0x78), FM(0xf8),
+FM(0x04), FM(0x84), FM(0x44), FM(0xc4), FM(0x24), FM(0xa4), FM(0x64), FM(0xe4),
+FM(0x14), FM(0x94), FM(0x54), FM(0xd4), FM(0x34), FM(0xb4), FM(0x74), FM(0xf4),
+FM(0x0c), FM(0x8c), FM(0x4c), FM(0xcc), FM(0x2c), FM(0xac), FM(0x6c), FM(0xec),
+FM(0x1c), FM(0x9c), FM(0x5c), FM(0xdc), FM(0x3c), FM(0xbc), FM(0x7c), FM(0xfc),
+FM(0x02), FM(0x82), FM(0x42), FM(0xc2), FM(0x22), FM(0xa2), FM(0x62), FM(0xe2),
+FM(0x12), FM(0x92), FM(0x52), FM(0xd2), FM(0x32), FM(0xb2), FM(0x72), FM(0xf2),
+FM(0x0a), FM(0x8a), FM(0x4a), FM(0xca), FM(0x2a), FM(0xaa), FM(0x6a), FM(0xea),
+FM(0x1a), FM(0x9a), FM(0x5a), FM(0xda), FM(0x3a), FM(0xba), FM(0x7a), FM(0xfa),
+FM(0x06), FM(0x86), FM(0x46), FM(0xc6), FM(0x26), FM(0xa6), FM(0x66), FM(0xe6),
+FM(0x16), FM(0x96), FM(0x56), FM(0xd6), FM(0x36), FM(0xb6), FM(0x76), FM(0xf6),
+FM(0x0e), FM(0x8e), FM(0x4e), FM(0xce), FM(0x2e), FM(0xae), FM(0x6e), FM(0xee),
+FM(0x1e), FM(0x9e), FM(0x5e), FM(0xde), FM(0x3e), FM(0xbe), FM(0x7e), FM(0xfe)
+};
+#undef FM
+
+#define MOD_RETURN(ctx, key) (ctx)->keycache.modifiers_return[key]
+
+#define TRANSLATE(ctx,pd,dpy,key,mod,mod_ret,sym_ret) \
+{ \
+ int _i_ = (((key) - (pd)->min_keycode + modmix[(mod) & 0xff]) & \
+ (TMKEYCACHESIZE-1)); \
+ if ((key) != 0 && /* Xlib XIM composed input */ \
+ (ctx)->keycache.keycode[_i_] == (key) && \
+ (ctx)->keycache.modifiers[_i_] == (mod)) { \
+ mod_ret = MOD_RETURN(ctx, key); \
+ sym_ret = (ctx)->keycache.keysym[_i_]; \
+ } else { \
+ XtTranslateKeycode(dpy, key, mod, &mod_ret, &sym_ret); \
+ (ctx)->keycache.keycode[_i_] = key; \
+ (ctx)->keycache.modifiers[_i_] = (unsigned char)(mod); \
+ (ctx)->keycache.keysym[_i_] = sym_ret; \
+ MOD_RETURN(ctx, key) = (unsigned char)mod_ret; \
+ } \
+}
+
+#define UPDATE_CACHE(ctx, pd, key, mod, mod_ret, sym_ret) \
+{ \
+ int _i_ = (((key) - (pd)->min_keycode + modmix[(mod) & 0xff]) & \
+ (TMKEYCACHESIZE-1)); \
+ (ctx)->keycache.keycode[_i_] = key; \
+ (ctx)->keycache.modifiers[_i_] = (unsigned char)(mod); \
+ (ctx)->keycache.keysym[_i_] = sym_ret; \
+ MOD_RETURN(ctx, key) = (unsigned char)mod_ret; \
+}
+
+/* usual number of expected keycodes in XtKeysymToKeycodeList */
+#define KEYCODE_ARRAY_SIZE 10
+
+Boolean _XtComputeLateBindings(
+ Display *dpy,
+ LateBindingsPtr lateModifiers,
+ Modifiers *computed,
+ Modifiers *computedMask)
+{
+ int i,j,ref;
+ ModToKeysymTable* temp;
+ XtPerDisplay perDisplay;
+ Boolean found;
+ KeySym tempKeysym = NoSymbol;
+
+ perDisplay = _XtGetPerDisplay(dpy);
+ if (perDisplay == NULL) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "displayError","invalidDisplay",XtCXtToolkitError,
+ "Can't find display structure",
+ (String *)NULL, (Cardinal *)NULL);
+ return FALSE;
+ }
+ _InitializeKeysymTables(dpy, perDisplay);
+ for (ref=0; lateModifiers[ref].keysym; ref++) {
+ found = FALSE;
+ for (i=0;i<8;i++) {
+ temp = &(perDisplay->modsToKeysyms[i]);
+ for (j=0;j<temp->count;j++){
+ if (perDisplay->modKeysyms[temp->idx+j] ==
+ lateModifiers[ref].keysym) {
+ *computedMask = *computedMask | temp->mask;
+ if (!lateModifiers[ref].knot)
+ *computed |= temp->mask;
+ tempKeysym = lateModifiers[ref].keysym;
+ found = TRUE; break;
+ }
+ }
+ if (found) break;
+ }
+ if (!found && !lateModifiers[ref].knot)
+ if (!lateModifiers[ref].pair && (tempKeysym == NoSymbol))
+ return FALSE;
+ /* if you didn't find the modifier and the modifier must be
+ asserted then return FALSE. If you didn't find the modifier
+ and the modifier must be off, then it is OK . Don't
+ return FALSE if this is the first member of a pair or if
+ it is the second member of a pair when the first member
+ was bound to a modifier */
+ if (!lateModifiers[ref].pair) tempKeysym = NoSymbol;
+ }
+ return TRUE;
+}
+
+void _XtAllocTMContext(
+ XtPerDisplay pd)
+{
+ TMKeyContext ctx;
+ ctx = (TMKeyContext)_XtHeapAlloc(&pd->heap,
+ sizeof(TMKeyContextRec));
+ ctx->event = NULL;
+ ctx->serial = 0;
+ ctx->keysym = NoSymbol;
+ ctx->modifiers = 0;
+ FLUSHKEYCACHE(ctx);
+ pd->tm_context = ctx;
+}
+
+static unsigned int num_bits(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));
+}
+
+Boolean _XtMatchUsingDontCareMods(
+ TMTypeMatch typeMatch,
+ TMModifierMatch modMatch,
+ TMEventPtr eventSeq)
+{
+ Modifiers modifiers_return;
+ KeySym keysym_return;
+ Modifiers useful_mods;
+ int i, num_modbits;
+ Modifiers computed = 0;
+ Modifiers computedMask = 0;
+ Boolean resolved = TRUE;
+ Display *dpy = eventSeq->xev->xany.display;
+ XtPerDisplay pd;
+ TMKeyContext tm_context;
+
+ if (modMatch->lateModifiers != NULL)
+ resolved = _XtComputeLateBindings(dpy, modMatch->lateModifiers,
+ &computed, &computedMask);
+ if (!resolved) return FALSE;
+ computed |= modMatch->modifiers;
+ computedMask |= modMatch->modifierMask; /* gives do-care mask */
+
+ if ( (computed & computedMask) ==
+ (eventSeq->event.modifiers & computedMask) ) {
+
+ pd = _XtGetPerDisplay(dpy);
+ tm_context = pd->tm_context;
+ TRANSLATE(tm_context, pd, dpy, (KeyCode)eventSeq->event.eventCode,
+ (unsigned)0, modifiers_return, keysym_return);
+
+ if ((keysym_return & typeMatch->eventCodeMask) == typeMatch->eventCode ) {
+ tm_context->event = eventSeq->xev;
+ tm_context->serial = eventSeq->xev->xany.serial;
+ tm_context->keysym = keysym_return;
+ tm_context->modifiers = (Modifiers)0;
+ return TRUE;
+ }
+ useful_mods = ~computedMask & modifiers_return;
+ if (useful_mods == 0) return FALSE;
+
+ switch (num_modbits = num_bits(useful_mods)) {
+ case 1:
+ case 8:
+ /*
+ * one modbit should never happen, in fact the implementation
+ * of XtTranslateKey and XmTranslateKey guarantee that it
+ * won't, so don't care if the loop is set up for the case
+ * when one modbit is set.
+ * The performance implications of all eight modbits being
+ * set is horrendous. This isn't a problem with Xt/Xaw based
+ * applications. We can only hope that Motif's virtual
+ * modifiers won't result in all eight modbits being set.
+ */
+ for (i = useful_mods; i > 0; i--) {
+ TRANSLATE(tm_context, pd, dpy, eventSeq->event.eventCode,
+ (Modifiers)i, modifiers_return, keysym_return);
+ if (keysym_return ==
+ (typeMatch->eventCode & typeMatch->eventCodeMask)) {
+ tm_context->event = eventSeq->xev;
+ tm_context->serial = eventSeq->xev->xany.serial;
+ tm_context->keysym = keysym_return;
+ tm_context->modifiers = (Modifiers)i;
+ return TRUE;
+ }
+ }
+ break;
+ default: /* (2..7) */
+ {
+ /*
+ * Only translate using combinations of the useful modifiers.
+ * to minimize the chance of invalidating the cache.
+ */
+ static char pows[] = { 0, 1, 3, 7, 15, 31, 63, 127 };
+ Modifiers tmod, mod_masks[8];
+ int j;
+ for (tmod = 1, i = 0; tmod <= (Mod5Mask<<1); tmod <<= 1)
+ if (tmod & useful_mods) mod_masks[i++] = tmod;
+ for (j = (int) pows[num_modbits]; j > 0; j--) {
+ tmod = 0;
+ for (i = 0; i < num_modbits; i++)
+ if (j & (1<<i)) tmod |= mod_masks[i];
+ TRANSLATE(tm_context, pd, dpy, eventSeq->event.eventCode,
+ tmod, modifiers_return, keysym_return);
+ if (keysym_return ==
+ (typeMatch->eventCode & typeMatch->eventCodeMask)) {
+ tm_context->event = eventSeq->xev;
+ tm_context->serial = eventSeq->xev->xany.serial;
+ tm_context->keysym = keysym_return;
+ tm_context->modifiers = (Modifiers)i;
+ return TRUE;
+ }
+ }
+ }
+ break;
+ } /* switch (num_modbits) */
+ }
+ return FALSE;
+}
+
+void XtConvertCase(
+ Display *dpy,
+ KeySym keysym,
+ KeySym *lower_return,
+ KeySym *upper_return)
+{
+ XtPerDisplay pd;
+ CaseConverterPtr ptr;
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ pd = _XtGetPerDisplay(dpy);
+
+ *lower_return = *upper_return = keysym;
+ for (ptr=pd->case_cvt; ptr; ptr = ptr->next)
+ if (ptr->start <= keysym && keysym <= ptr->stop) {
+ (*ptr->proc)(dpy, keysym, lower_return, upper_return);
+ return;
+ }
+ XConvertCase(keysym, lower_return, upper_return);
+ UNLOCK_APP(app);
+}
+
+Boolean _XtMatchUsingStandardMods (
+ TMTypeMatch typeMatch,
+ TMModifierMatch modMatch,
+ TMEventPtr eventSeq)
+{
+ Modifiers modifiers_return;
+ KeySym keysym_return;
+ Modifiers computed= 0;
+ Modifiers computedMask = 0;
+ Boolean resolved = TRUE;
+ Display *dpy = eventSeq->xev->xany.display;
+ XtPerDisplay pd = _XtGetPerDisplay(dpy);
+ TMKeyContext tm_context = pd->tm_context;
+ Modifiers translateModifiers;
+
+ /* To maximize cache utilization, we mask off nonstandard modifiers
+ before cache lookup. For a given key translator, standard modifiers
+ are constant per KeyCode. If a key translator uses no standard
+ modifiers this implementation will never reference the cache.
+ */
+
+ modifiers_return = MOD_RETURN(tm_context, eventSeq->event.eventCode);
+ if (!modifiers_return) {
+ XtTranslateKeycode(dpy, (KeyCode)eventSeq->event.eventCode,
+ eventSeq->event.modifiers, &modifiers_return,
+ &keysym_return);
+ translateModifiers = eventSeq->event.modifiers & modifiers_return;
+ UPDATE_CACHE(tm_context, pd, eventSeq->event.eventCode,
+ translateModifiers, modifiers_return, keysym_return);
+ } else {
+ translateModifiers = eventSeq->event.modifiers & modifiers_return;
+ TRANSLATE(tm_context, pd, dpy, (KeyCode)eventSeq->event.eventCode,
+ translateModifiers, modifiers_return, keysym_return);
+ }
+
+ if ((typeMatch->eventCode & typeMatch->eventCodeMask) ==
+ (keysym_return & typeMatch->eventCodeMask)) {
+ if (modMatch->lateModifiers != NULL)
+ resolved = _XtComputeLateBindings(dpy, modMatch->lateModifiers,
+ &computed, &computedMask);
+ if (!resolved) return FALSE;
+ computed |= modMatch->modifiers;
+ computedMask |= modMatch->modifierMask;
+
+ if ((computed & computedMask) ==
+ (eventSeq->event.modifiers & ~modifiers_return & computedMask)) {
+ tm_context->event = eventSeq->xev;
+ tm_context->serial = eventSeq->xev->xany.serial;
+ tm_context->keysym = keysym_return;
+ tm_context->modifiers = translateModifiers;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+void _XtBuildKeysymTables(
+ Display *dpy,
+ register XtPerDisplay pd)
+{
+ ModToKeysymTable *table;
+ int maxCount,i,j,k,tempCount,idx;
+ KeySym keysym,tempKeysym;
+ XModifierKeymap* modKeymap;
+ KeyCode keycode;
+#define KeysymTableSize 16
+
+ FLUSHKEYCACHE(pd->tm_context);
+ if (pd->keysyms)
+ XFree( (char *)pd->keysyms );
+ pd->keysyms_serial = NextRequest(dpy);
+ pd->keysyms = XGetKeyboardMapping(dpy, pd->min_keycode,
+ pd->max_keycode-pd->min_keycode+1,
+ &pd->keysyms_per_keycode);
+ if (pd->modKeysyms)
+ XtFree((char *)pd->modKeysyms);
+ if (pd->modsToKeysyms)
+ XtFree((char *)pd->modsToKeysyms);
+ pd->modKeysyms = (KeySym*)__XtMalloc((Cardinal)KeysymTableSize*sizeof(KeySym));
+ maxCount = KeysymTableSize;
+ tempCount = 0;
+
+ table = (ModToKeysymTable*)__XtMalloc((Cardinal)8*sizeof(ModToKeysymTable));
+ pd->modsToKeysyms = table;
+
+ table[0].mask = ShiftMask;
+ table[1].mask = LockMask;
+ table[2].mask = ControlMask;
+ table[3].mask = Mod1Mask;
+ table[4].mask = Mod2Mask;
+ table[5].mask = Mod3Mask;
+ table[6].mask = Mod4Mask;
+ table[7].mask = Mod5Mask;
+ tempKeysym = 0;
+
+ modKeymap = XGetModifierMapping(dpy);
+ for (i=0;i<32;i++)
+ pd->isModifier[i] = 0;
+ pd->mode_switch = 0;
+ pd->num_lock = 0;
+ for (i=0;i<8;i++) {
+ table[i].idx = tempCount;
+ table[i].count = 0;
+ for (j=0;j<modKeymap->max_keypermod;j++) {
+ keycode = modKeymap->modifiermap[i*modKeymap->max_keypermod+j];
+ if (keycode != 0) {
+ pd->isModifier[keycode>>3] |= 1 << (keycode & 7);
+ for (k=0; k<pd->keysyms_per_keycode;k++) {
+ idx = ((keycode-pd->min_keycode)*
+ pd->keysyms_per_keycode)+k;
+ keysym = pd->keysyms[idx];
+ if ((keysym == XK_Mode_switch) && (i > 2))
+ pd->mode_switch |= 1 << i;
+ if ((keysym == XK_Num_Lock) && (i > 2))
+ pd->num_lock |= 1 << i;
+ if (keysym != 0 && keysym != tempKeysym ){
+ if (tempCount==maxCount) {
+ maxCount += KeysymTableSize;
+ pd->modKeysyms = (KeySym*)XtRealloc(
+ (char*)pd->modKeysyms,
+ (unsigned) (maxCount*sizeof(KeySym)) );
+ }
+ pd->modKeysyms[tempCount++] = keysym;
+ table[i].count++;
+ tempKeysym = keysym;
+ }
+ }
+ }
+ }
+ }
+ pd->lock_meaning = NoSymbol;
+ for (i = 0; i < table[1].count; i++) {
+ keysym = pd->modKeysyms[table[1].idx + i];
+ if (keysym == XK_Caps_Lock) {
+ pd->lock_meaning = XK_Caps_Lock;
+ break;
+ } else if (keysym == XK_Shift_Lock) {
+ pd->lock_meaning = XK_Shift_Lock;
+ }
+ }
+ XFreeModifiermap(modKeymap);
+}
+
+void XtTranslateKeycode (
+ Display *dpy,
+ _XtKeyCode keycode,
+ Modifiers modifiers,
+ Modifiers *modifiers_return,
+ KeySym *keysym_return)
+{
+ XtPerDisplay pd;
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ pd = _XtGetPerDisplay(dpy);
+ _InitializeKeysymTables(dpy, pd);
+ (*pd->defaultKeycodeTranslator)(
+ dpy,keycode,modifiers,modifiers_return,keysym_return);
+ UNLOCK_APP(app);
+}
+
+/* This code should match XTranslateKey (internal, sigh) in Xlib */
+void XtTranslateKey(
+ register Display *dpy,
+ _XtKeyCode keycode,
+ Modifiers modifiers,
+ Modifiers *modifiers_return,
+ KeySym *keysym_return)
+{
+#ifndef XKB
+ XtPerDisplay pd;
+ int per;
+ register KeySym *syms;
+ KeySym sym, lsym, usym;
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ pd = _XtGetPerDisplay(dpy);
+ *modifiers_return = (ShiftMask|LockMask) | pd->mode_switch | pd->num_lock;
+ if (((int)keycode < pd->min_keycode) || ((int)keycode > pd->max_keycode)) {
+ *keysym_return = NoSymbol;
+ UNLOCK_APP(app);
+ return;
+ }
+ per = pd->keysyms_per_keycode;
+ syms = &pd->keysyms[(keycode - pd->min_keycode) * per];
+ while ((per > 2) && (syms[per - 1] == NoSymbol))
+ per--;
+ if ((per > 2) && (modifiers & pd->mode_switch)) {
+ syms += 2;
+ per -= 2;
+ }
+ if ((modifiers & pd->num_lock) &&
+ (per > 1 && (IsKeypadKey(syms[1]) || IsPrivateKeypadKey(syms[1])))) {
+ if ((modifiers & ShiftMask) ||
+ ((modifiers & LockMask) && (pd->lock_meaning == XK_Shift_Lock)))
+ *keysym_return = syms[0];
+ else
+ *keysym_return = syms[1];
+ } else if (!(modifiers & ShiftMask) &&
+ (!(modifiers & LockMask) || (pd->lock_meaning == NoSymbol))) {
+ if ((per == 1) || (syms[1] == NoSymbol))
+ XtConvertCase(dpy, syms[0], keysym_return, &usym);
+ else
+ *keysym_return = syms[0];
+ } else if (!(modifiers & LockMask) ||
+ (pd->lock_meaning != XK_Caps_Lock)) {
+ if ((per == 1) || ((usym = syms[1]) == NoSymbol))
+ XtConvertCase(dpy, syms[0], &lsym, &usym);
+ *keysym_return = usym;
+ } else {
+ if ((per == 1) || ((sym = syms[1]) == NoSymbol))
+ sym = syms[0];
+ XtConvertCase(dpy, sym, &lsym, &usym);
+ if (!(modifiers & ShiftMask) && (sym != syms[0]) &&
+ ((sym != usym) || (lsym == usym)))
+ XtConvertCase(dpy, syms[0], &lsym, &usym);
+ *keysym_return = usym;
+ }
+
+ if (*keysym_return == XK_VoidSymbol)
+ *keysym_return = NoSymbol;
+ UNLOCK_APP(app);
+#else
+ XkbLookupKeySym(dpy, keycode, modifiers, modifiers_return, keysym_return);
+#endif
+}
+
+void XtSetKeyTranslator(
+ Display *dpy,
+ XtKeyProc translator)
+{
+ XtPerDisplay pd;
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ pd = _XtGetPerDisplay(dpy);
+
+ pd->defaultKeycodeTranslator = translator;
+ FLUSHKEYCACHE(pd->tm_context);
+ /* XXX should now redo grabs */
+ UNLOCK_APP(app);
+}
+
+void XtRegisterCaseConverter(
+ Display *dpy,
+ XtCaseProc proc,
+ KeySym start,
+ KeySym stop)
+{
+ XtPerDisplay pd;
+ CaseConverterPtr ptr, prev;
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ pd = _XtGetPerDisplay(dpy);
+
+ ptr = (CaseConverterPtr) __XtMalloc(sizeof(CaseConverterRec));
+ ptr->start = start;
+ ptr->stop = stop;
+ ptr->proc = proc;
+ ptr->next = pd->case_cvt;
+ pd->case_cvt = ptr;
+
+ /* Remove obsolete case converters from the list */
+ prev = ptr;
+ for (ptr=ptr->next; ptr; ptr=prev->next) {
+ if (start <= ptr->start && stop >= ptr->stop) {
+ prev->next = ptr->next;
+ XtFree((char *)ptr);
+ }
+ else prev = ptr;
+ }
+ FLUSHKEYCACHE(pd->tm_context);
+ /* XXX should now redo grabs */
+ UNLOCK_APP(app);
+}
+
+KeySym *XtGetKeysymTable(
+ Display *dpy,
+ KeyCode *min_keycode_return,
+ int *keysyms_per_keycode_return)
+{
+ XtPerDisplay pd;
+ KeySym* retval;
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ pd = _XtGetPerDisplay(dpy);
+ _InitializeKeysymTables(dpy, pd);
+ *min_keycode_return = pd->min_keycode; /* %%% */
+ *keysyms_per_keycode_return = pd->keysyms_per_keycode;
+ retval = pd->keysyms;
+ UNLOCK_APP(app);
+ return retval;
+}
+
+void XtKeysymToKeycodeList(
+ Display *dpy,
+ KeySym keysym,
+ KeyCode **keycodes_return,
+ Cardinal *keycount_return)
+{
+ XtPerDisplay pd;
+ unsigned keycode;
+ int per, match;
+ register KeySym *syms;
+ register int i, j;
+ KeySym lsym, usym;
+ unsigned maxcodes = 0;
+ unsigned ncodes = 0;
+ KeyCode *keycodes, *codeP = NULL;
+ DPY_TO_APPCON(dpy);
+
+ LOCK_APP(app);
+ pd = _XtGetPerDisplay(dpy);
+ _InitializeKeysymTables(dpy, pd);
+ keycodes = NULL;
+ per = pd->keysyms_per_keycode;
+ for (syms = pd->keysyms, keycode = (unsigned) pd->min_keycode;
+ (int)keycode <= pd->max_keycode;
+ syms += per, keycode++) {
+ match = 0;
+ for (j = 0; j < per; j++) {
+ if (syms[j] == keysym) {
+ match = 1;
+ break;
+ }
+ }
+ if (!match)
+ for (i = 1; i < 5; i += 2) {
+ if ((per == i) || ((per > i) && (syms[i] == NoSymbol))) {
+ XtConvertCase(dpy, syms[i-1], &lsym, &usym);
+ if ((lsym == keysym) || (usym == keysym)) {
+ match = 1;
+ break;
+ }
+ }
+ }
+ if (match) {
+ if (ncodes == maxcodes) {
+ KeyCode *old = keycodes;
+ maxcodes += KEYCODE_ARRAY_SIZE;
+ keycodes = (KeyCode*)__XtMalloc(maxcodes*sizeof(KeyCode));
+ if (ncodes) {
+ (void) memmove((char *)keycodes, (char *)old,
+ ncodes*sizeof(KeyCode) );
+ XtFree((char *)old);
+ }
+ codeP = &keycodes[ncodes];
+ }
+ *codeP++ = (KeyCode) keycode;
+ ncodes++;
+ }
+ }
+ *keycodes_return = keycodes;
+ *keycount_return = ncodes;
+ UNLOCK_APP(app);
+}
diff --git a/nx-X11/lib/Xt/TMparse.c b/nx-X11/lib/Xt/TMparse.c
new file mode 100644
index 000000000..25522fb59
--- /dev/null
+++ b/nx-X11/lib/Xt/TMparse.c
@@ -0,0 +1,2135 @@
+/* $Xorg: TMparse.c,v 1.6 2001/02/09 02:03:58 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/TMparse.c,v 3.10tsi 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+#include <ctype.h>
+#include <stdlib.h>
+#ifndef NOTASCII
+#define XK_LATIN1
+#endif
+#define XK_MISCELLANY
+#include <X11/keysymdef.h>
+
+#ifdef CACHE_TRANSLATIONS
+# ifdef REFCNT_TRANSLATIONS
+# define CACHED XtCacheAll | XtCacheRefCount
+# else
+# define CACHED XtCacheAll
+# endif
+#else
+# define CACHED XtCacheNone
+#endif
+
+#ifndef MAX
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+
+#ifndef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+static String XtNtranslationParseError = "translationParseError";
+
+typedef int EventType;
+
+typedef String (*ParseProc)(
+ String /* str; */,
+ Opaque /* closure; */,
+ EventPtr /* event; */,
+ Boolean* /* error */);
+
+typedef TMShortCard Value;
+typedef void (*ModifierProc)(Value, LateBindingsPtr*, Boolean, Value*);
+
+typedef struct _ModifierRec {
+ char* name;
+ XrmQuark signature;
+ ModifierProc modifierParseProc;
+ Value value;
+} ModifierRec, *ModifierKeys;
+
+typedef struct _EventKey {
+ char *event;
+ XrmQuark signature;
+ EventType eventType;
+ ParseProc parseDetail;
+ Opaque closure;
+}EventKey, *EventKeys;
+
+typedef struct {
+ char *name;
+ XrmQuark signature;
+ Value value;
+} NameValueRec, *NameValueTable;
+
+static void ParseModImmed(Value, LateBindingsPtr*, Boolean, Value*);
+static void ParseModSym(Value, LateBindingsPtr*, Boolean, Value*);
+static String PanicModeRecovery(String);
+static String CheckForPoundSign(String, _XtTranslateOp, _XtTranslateOp *);
+static KeySym StringToKeySym(String, Boolean *);
+static ModifierRec modifiers[] = {
+ {"Shift", 0, ParseModImmed,ShiftMask},
+ {"Lock", 0, ParseModImmed,LockMask},
+ {"Ctrl", 0, ParseModImmed,ControlMask},
+ {"Mod1", 0, ParseModImmed,Mod1Mask},
+ {"Mod2", 0, ParseModImmed,Mod2Mask},
+ {"Mod3", 0, ParseModImmed,Mod3Mask},
+ {"Mod4", 0, ParseModImmed,Mod4Mask},
+ {"Mod5", 0, ParseModImmed,Mod5Mask},
+ {"Meta", 0, ParseModSym, XK_Meta_L},
+ {"m", 0, ParseModSym, XK_Meta_L},
+ {"h", 0, ParseModSym, XK_Hyper_L},
+ {"su", 0, ParseModSym, XK_Super_L},
+ {"a", 0, ParseModSym, XK_Alt_L},
+ {"Hyper", 0, ParseModSym, XK_Hyper_L},
+ {"Super", 0, ParseModSym, XK_Super_L},
+ {"Alt", 0, ParseModSym, XK_Alt_L},
+ {"Button1", 0, ParseModImmed,Button1Mask},
+ {"Button2", 0, ParseModImmed,Button2Mask},
+ {"Button3", 0, ParseModImmed,Button3Mask},
+ {"Button4", 0, ParseModImmed,Button4Mask},
+ {"Button5", 0, ParseModImmed,Button5Mask},
+ {"c", 0, ParseModImmed,ControlMask},
+ {"s", 0, ParseModImmed,ShiftMask},
+ {"l", 0, ParseModImmed,LockMask},
+};
+
+static NameValueRec buttonNames[] = {
+ {"Button1", 0, Button1},
+ {"Button2", 0, Button2},
+ {"Button3", 0, Button3},
+ {"Button4", 0, Button4},
+ {"Button5", 0, Button5},
+ {NULL, NULLQUARK, 0},
+};
+
+static NameValueRec motionDetails[] = {
+ {"Normal", 0, NotifyNormal},
+ {"Hint", 0, NotifyHint},
+ {NULL, NULLQUARK, 0},
+};
+
+static NameValueRec notifyModes[] = {
+ {"Normal", 0, NotifyNormal},
+ {"Grab", 0, NotifyGrab},
+ {"Ungrab", 0, NotifyUngrab},
+ {"WhileGrabbed", 0, NotifyWhileGrabbed},
+ {NULL, NULLQUARK, 0},
+};
+
+#if 0
+static NameValueRec notifyDetail[] = {
+ {"Ancestor", 0, NotifyAncestor},
+ {"Virtual", 0, NotifyVirtual},
+ {"Inferior", 0, NotifyInferior},
+ {"Nonlinear", 0, NotifyNonlinear},
+ {"NonlinearVirtual", 0, NotifyNonlinearVirtual},
+ {"Pointer", 0, NotifyPointer},
+ {"PointerRoot", 0, NotifyPointerRoot},
+ {"DetailNone", 0, NotifyDetailNone},
+ {NULL, NULLQUARK, 0},
+};
+
+static NameValueRec visibilityNotify[] = {
+ {"Unobscured", 0, VisibilityUnobscured},
+ {"PartiallyObscured", 0, VisibilityPartiallyObscured},
+ {"FullyObscured", 0, VisibilityFullyObscured},
+ {NULL, NULLQUARK, 0},
+};
+
+static NameValueRec circulation[] = {
+ {"OnTop", 0, PlaceOnTop},
+ {"OnBottom", 0, PlaceOnBottom},
+ {NULL, NULLQUARK, 0},
+};
+
+static NameValueRec propertyChanged[] = {
+ {"NewValue", 0, PropertyNewValue},
+ {"Delete", 0, PropertyDelete},
+ {NULL, NULLQUARK, 0},
+};
+#endif /*0*/
+
+static NameValueRec mappingNotify[] = {
+ {"Modifier", 0, MappingModifier},
+ {"Keyboard", 0, MappingKeyboard},
+ {"Pointer", 0, MappingPointer},
+ {NULL, NULLQUARK, 0},
+};
+
+static String ParseKeySym(String, Opaque, EventPtr, Boolean*);
+static String ParseKeyAndModifiers(String, Opaque, EventPtr, Boolean*);
+static String ParseTable(String, Opaque, EventPtr, Boolean*);
+static String ParseImmed(String, Opaque, EventPtr, Boolean*);
+static String ParseAddModifier(String, Opaque, EventPtr, Boolean*);
+static String ParseNone(String, Opaque, EventPtr, Boolean*);
+static String ParseAtom(String, Opaque, EventPtr, Boolean*);
+
+static EventKey events[] = {
+
+/* Event Name, Quark, Event Type, Detail Parser, Closure */
+
+{"KeyPress", NULLQUARK, KeyPress, ParseKeySym, NULL},
+{"Key", NULLQUARK, KeyPress, ParseKeySym, NULL},
+{"KeyDown", NULLQUARK, KeyPress, ParseKeySym, NULL},
+{"Ctrl", NULLQUARK, KeyPress, ParseKeyAndModifiers,(Opaque)ControlMask},
+{"Shift", NULLQUARK, KeyPress, ParseKeyAndModifiers,(Opaque)ShiftMask},
+{"Meta", NULLQUARK, KeyPress, ParseKeyAndModifiers,(Opaque)NULL},
+{"KeyUp", NULLQUARK, KeyRelease, ParseKeySym, NULL},
+{"KeyRelease", NULLQUARK, KeyRelease, ParseKeySym, NULL},
+
+{"ButtonPress", NULLQUARK, ButtonPress, ParseTable,(Opaque)buttonNames},
+{"BtnDown", NULLQUARK, ButtonPress, ParseTable,(Opaque)buttonNames},
+{"Btn1Down", NULLQUARK, ButtonPress, ParseImmed,(Opaque)Button1},
+{"Btn2Down", NULLQUARK, ButtonPress, ParseImmed,(Opaque)Button2},
+{"Btn3Down", NULLQUARK, ButtonPress, ParseImmed,(Opaque)Button3},
+{"Btn4Down", NULLQUARK, ButtonPress, ParseImmed,(Opaque)Button4},
+{"Btn5Down", NULLQUARK, ButtonPress, ParseImmed,(Opaque)Button5},
+
+/* Event Name, Quark, Event Type, Detail Parser, Closure */
+
+{"ButtonRelease", NULLQUARK, ButtonRelease, ParseTable,(Opaque)buttonNames},
+{"BtnUp", NULLQUARK, ButtonRelease, ParseTable,(Opaque)buttonNames},
+{"Btn1Up", NULLQUARK, ButtonRelease, ParseImmed,(Opaque)Button1},
+{"Btn2Up", NULLQUARK, ButtonRelease, ParseImmed,(Opaque)Button2},
+{"Btn3Up", NULLQUARK, ButtonRelease, ParseImmed,(Opaque)Button3},
+{"Btn4Up", NULLQUARK, ButtonRelease, ParseImmed,(Opaque)Button4},
+{"Btn5Up", NULLQUARK, ButtonRelease, ParseImmed,(Opaque)Button5},
+
+{"MotionNotify", NULLQUARK, MotionNotify, ParseTable, (Opaque)motionDetails},
+{"PtrMoved", NULLQUARK, MotionNotify, ParseTable, (Opaque)motionDetails},
+{"Motion", NULLQUARK, MotionNotify, ParseTable, (Opaque)motionDetails},
+{"MouseMoved", NULLQUARK, MotionNotify, ParseTable, (Opaque)motionDetails},
+{"BtnMotion", NULLQUARK, MotionNotify, ParseAddModifier, (Opaque)AnyButtonMask},
+{"Btn1Motion", NULLQUARK, MotionNotify, ParseAddModifier, (Opaque)Button1Mask},
+{"Btn2Motion", NULLQUARK, MotionNotify, ParseAddModifier, (Opaque)Button2Mask},
+{"Btn3Motion", NULLQUARK, MotionNotify, ParseAddModifier, (Opaque)Button3Mask},
+{"Btn4Motion", NULLQUARK, MotionNotify, ParseAddModifier, (Opaque)Button4Mask},
+{"Btn5Motion", NULLQUARK, MotionNotify, ParseAddModifier, (Opaque)Button5Mask},
+
+{"EnterNotify", NULLQUARK, EnterNotify, ParseTable,(Opaque)notifyModes},
+{"Enter", NULLQUARK, EnterNotify, ParseTable,(Opaque)notifyModes},
+{"EnterWindow", NULLQUARK, EnterNotify, ParseTable,(Opaque)notifyModes},
+
+{"LeaveNotify", NULLQUARK, LeaveNotify, ParseTable,(Opaque)notifyModes},
+{"LeaveWindow", NULLQUARK, LeaveNotify, ParseTable,(Opaque)notifyModes},
+{"Leave", NULLQUARK, LeaveNotify, ParseTable,(Opaque)notifyModes},
+
+/* Event Name, Quark, Event Type, Detail Parser, Closure */
+
+{"FocusIn", NULLQUARK, FocusIn, ParseTable,(Opaque)notifyModes},
+
+{"FocusOut", NULLQUARK, FocusOut, ParseTable,(Opaque)notifyModes},
+
+{"KeymapNotify", NULLQUARK, KeymapNotify, ParseNone, NULL},
+{"Keymap", NULLQUARK, KeymapNotify, ParseNone, NULL},
+
+{"Expose", NULLQUARK, Expose, ParseNone, NULL},
+
+{"GraphicsExpose", NULLQUARK, GraphicsExpose, ParseNone, NULL},
+{"GrExp", NULLQUARK, GraphicsExpose, ParseNone, NULL},
+
+{"NoExpose", NULLQUARK, NoExpose, ParseNone, NULL},
+{"NoExp", NULLQUARK, NoExpose, ParseNone, NULL},
+
+{"VisibilityNotify",NULLQUARK, VisibilityNotify,ParseNone, NULL},
+{"Visible", NULLQUARK, VisibilityNotify,ParseNone, NULL},
+
+{"CreateNotify", NULLQUARK, CreateNotify, ParseNone, NULL},
+{"Create", NULLQUARK, CreateNotify, ParseNone, NULL},
+
+/* Event Name, Quark, Event Type, Detail Parser, Closure */
+
+{"DestroyNotify", NULLQUARK, DestroyNotify, ParseNone, NULL},
+{"Destroy", NULLQUARK, DestroyNotify, ParseNone, NULL},
+
+{"UnmapNotify", NULLQUARK, UnmapNotify, ParseNone, NULL},
+{"Unmap", NULLQUARK, UnmapNotify, ParseNone, NULL},
+
+{"MapNotify", NULLQUARK, MapNotify, ParseNone, NULL},
+{"Map", NULLQUARK, MapNotify, ParseNone, NULL},
+
+{"MapRequest", NULLQUARK, MapRequest, ParseNone, NULL},
+{"MapReq", NULLQUARK, MapRequest, ParseNone, NULL},
+
+{"ReparentNotify", NULLQUARK, ReparentNotify, ParseNone, NULL},
+{"Reparent", NULLQUARK, ReparentNotify, ParseNone, NULL},
+
+{"ConfigureNotify", NULLQUARK, ConfigureNotify, ParseNone, NULL},
+{"Configure", NULLQUARK, ConfigureNotify, ParseNone, NULL},
+
+{"ConfigureRequest",NULLQUARK, ConfigureRequest,ParseNone, NULL},
+{"ConfigureReq", NULLQUARK, ConfigureRequest,ParseNone, NULL},
+
+/* Event Name, Quark, Event Type, Detail Parser, Closure */
+
+{"GravityNotify", NULLQUARK, GravityNotify, ParseNone, NULL},
+{"Grav", NULLQUARK, GravityNotify, ParseNone, NULL},
+
+{"ResizeRequest", NULLQUARK, ResizeRequest, ParseNone, NULL},
+{"ResReq", NULLQUARK, ResizeRequest, ParseNone, NULL},
+
+{"CirculateNotify", NULLQUARK, CirculateNotify, ParseNone, NULL},
+{"Circ", NULLQUARK, CirculateNotify, ParseNone, NULL},
+
+{"CirculateRequest",NULLQUARK, CirculateRequest,ParseNone, NULL},
+{"CircReq", NULLQUARK, CirculateRequest,ParseNone, NULL},
+
+{"PropertyNotify", NULLQUARK, PropertyNotify, ParseAtom, NULL},
+{"Prop", NULLQUARK, PropertyNotify, ParseAtom, NULL},
+
+{"SelectionClear", NULLQUARK, SelectionClear, ParseAtom, NULL},
+{"SelClr", NULLQUARK, SelectionClear, ParseAtom, NULL},
+
+{"SelectionRequest",NULLQUARK, SelectionRequest,ParseAtom, NULL},
+{"SelReq", NULLQUARK, SelectionRequest,ParseAtom, NULL},
+
+/* Event Name, Quark, Event Type, Detail Parser, Closure */
+
+{"SelectionNotify", NULLQUARK, SelectionNotify, ParseAtom, NULL},
+{"Select", NULLQUARK, SelectionNotify, ParseAtom, NULL},
+
+{"ColormapNotify", NULLQUARK, ColormapNotify, ParseNone, NULL},
+{"Clrmap", NULLQUARK, ColormapNotify, ParseNone, NULL},
+
+{"ClientMessage", NULLQUARK, ClientMessage, ParseAtom, NULL},
+{"Message", NULLQUARK, ClientMessage, ParseAtom, NULL},
+
+{"MappingNotify", NULLQUARK, MappingNotify, ParseTable, (Opaque)mappingNotify},
+{"Mapping", NULLQUARK, MappingNotify, ParseTable, (Opaque)mappingNotify},
+
+#ifdef DEBUG
+# ifdef notdef
+{"Timer", NULLQUARK, _XtTimerEventType,ParseNone, NULL},
+# endif /* notdef */
+{"EventTimer", NULLQUARK, _XtEventTimerEventType,ParseNone,NULL},
+#endif /* DEBUG */
+
+/* Event Name, Quark, Event Type, Detail Parser, Closure */
+
+};
+
+#ifndef __UNIXOS2__
+#define IsNewline(str) ((str) == '\n')
+#else
+#define IsNewline(str) ((str) == '\n' || (str) == '\r')
+#endif
+
+#define ScanFor(str, ch) \
+ while ((*(str) != (ch)) && (*(str) != '\0') && !IsNewline(*(str))) (str)++
+
+#define ScanNumeric(str) while ('0' <= *(str) && *(str) <= '9') (str)++
+
+#define ScanAlphanumeric(str) \
+ while (('A' <= *(str) && *(str) <= 'Z') || \
+ ('a' <= *(str) && *(str) <= 'z') || \
+ ('0' <= *(str) && *(str) <= '9')) (str)++
+
+#ifndef __UNIXOS2__
+#define ScanWhitespace(str) \
+ while (*(str) == ' ' || *(str) == '\t') (str)++
+#else
+#define ScanWhitespace(str) \
+ while (*(str) == ' ' || *(str) == '\t' || *(str) == '\r') (str)++
+#endif
+
+static Boolean initialized = FALSE;
+static XrmQuark QMeta;
+static XrmQuark QCtrl;
+static XrmQuark QNone;
+static XrmQuark QAny;
+
+static void FreeEventSeq(
+ EventSeqPtr eventSeq)
+{
+ register EventSeqPtr evs = eventSeq;
+
+ while (evs != NULL) {
+ evs->state = (StatePtr) evs;
+ if (evs->next != NULL
+ && evs->next->state == (StatePtr) evs->next)
+ evs->next = NULL;
+ evs = evs->next;
+ }
+
+ evs = eventSeq;
+ while (evs != NULL) {
+ register EventPtr event = evs;
+ evs = evs->next;
+ if (evs == event) evs = NULL;
+ XtFree((char *)event);
+ }
+}
+
+static void CompileNameValueTable(
+ NameValueTable table)
+{
+ register int i;
+
+ for (i=0; table[i].name; i++)
+ table[i].signature = XrmPermStringToQuark(table[i].name);
+}
+
+static int OrderEvents(_Xconst void *a, _Xconst void *b)
+{
+ return ((((_Xconst EventKey *)a)->signature <
+ ((_Xconst EventKey *)b)->signature) ? -1 : 1);
+}
+
+static void Compile_XtEventTable(
+ EventKeys table,
+ Cardinal count)
+{
+ register int i;
+ register EventKeys entry = table;
+
+ for (i=count; --i >= 0; entry++)
+ entry->signature = XrmPermStringToQuark(entry->event);
+ qsort(table, count, sizeof(EventKey), OrderEvents);
+}
+
+static int OrderModifiers(_Xconst void *a, _Xconst void *b)
+{
+ return ((((_Xconst ModifierRec *)a)->signature <
+ ((_Xconst ModifierRec *)b)->signature) ? -1 : 1);
+}
+
+static void Compile_XtModifierTable(
+ ModifierKeys table,
+ Cardinal count)
+{
+ register int i;
+ register ModifierKeys entry = table;
+
+ for (i=count; --i >= 0; entry++)
+ entry->signature = XrmPermStringToQuark(entry->name);
+ qsort(table, count, sizeof(ModifierRec), OrderModifiers);
+}
+
+static String PanicModeRecovery(
+ String str)
+{
+ ScanFor(str,'\n');
+ if (*str == '\n') str++;
+ return str;
+
+}
+
+
+static void Syntax(
+ String str0,String str1)
+{
+ Cardinal num_params = 2;
+ String params[2];
+
+ params[0] = str0;
+ params[1] = str1;
+ XtWarningMsg(XtNtranslationParseError,"parseError",XtCXtToolkitError,
+ "translation table syntax error: %s %s",params,&num_params);
+}
+
+
+
+static Cardinal LookupTMEventType(
+ String eventStr,
+ Boolean *error)
+{
+ register int i = 0, left, right;
+ register XrmQuark signature;
+ static int previous = 0;
+
+ LOCK_PROCESS;
+ if ((signature = StringToQuark(eventStr)) == events[previous].signature) {
+ UNLOCK_PROCESS;
+ return (Cardinal) previous;
+ }
+
+ left = 0;
+ right = XtNumber(events) - 1;
+ while (left <= right) {
+ i = (left + right) >> 1;
+ if (signature < events[i].signature)
+ right = i - 1;
+ else if (signature > events[i].signature)
+ left = i + 1;
+ else {
+ previous = i;
+ UNLOCK_PROCESS;
+ return (Cardinal) i;
+ }
+ }
+
+ Syntax("Unknown event type : ",eventStr);
+ *error = TRUE;
+ UNLOCK_PROCESS;
+ return (Cardinal) i;
+}
+
+static void StoreLateBindings(
+ KeySym keysymL,
+ Boolean notL,
+ KeySym keysymR,
+ Boolean notR,
+ LateBindingsPtr* lateBindings)
+{
+ LateBindingsPtr temp;
+ Boolean pair = FALSE;
+ unsigned long count,number;
+ if (lateBindings != NULL){
+ temp = *lateBindings;
+ if (temp != NULL) {
+ for (count = 0; temp[count].keysym; count++){/*EMPTY*/}
+ }
+ else count = 0;
+ if (! keysymR){
+ number = 1;pair = FALSE;
+ } else{
+ number = 2;pair = TRUE;
+ }
+
+ temp = (LateBindingsPtr)XtRealloc((char *)temp,
+ (unsigned)((count+number+1) * sizeof(LateBindings)) );
+ *lateBindings = temp;
+ temp[count].knot = notL;
+ temp[count].pair = pair;
+ if (count == 0)
+ temp[count].ref_count = 1;
+ temp[count++].keysym = keysymL;
+ if (keysymR){
+ temp[count].knot = notR;
+ temp[count].pair = FALSE;
+ temp[count].ref_count = 0;
+ temp[count++].keysym = keysymR;
+ }
+ temp[count].knot = temp[count].pair = FALSE;
+ temp[count].ref_count = 0;
+ temp[count].keysym = 0;
+ }
+}
+
+static void _XtParseKeysymMod(
+ String name,
+ LateBindingsPtr* lateBindings,
+ Boolean notFlag,
+ Value *valueP,
+ Boolean *error)
+{
+ KeySym keySym;
+ keySym = StringToKeySym(name, error);
+ *valueP = 0;
+ if (keySym != NoSymbol) {
+ StoreLateBindings(keySym,notFlag,(KeySym) NULL,FALSE,lateBindings);
+ }
+}
+
+static Boolean _XtLookupModifier(
+ XrmQuark signature,
+ LateBindingsPtr* lateBindings,
+ Boolean notFlag,
+ Value *valueP,
+ Bool constMask)
+{
+ register int i, left, right;
+ static int previous = 0;
+
+ LOCK_PROCESS;
+ if (signature == modifiers[previous].signature) {
+ if (constMask) *valueP = modifiers[previous].value;
+ else /* if (modifiers[previous].modifierParseProc) always true */
+ (*modifiers[previous].modifierParseProc)
+ (modifiers[previous].value, lateBindings, notFlag, valueP);
+ UNLOCK_PROCESS;
+ return TRUE;
+ }
+
+ left = 0;
+ right = XtNumber(modifiers) - 1;
+ while (left <= right) {
+ i = (left + right) >> 1;
+ if (signature < modifiers[i].signature)
+ right = i - 1;
+ else if (signature > modifiers[i].signature)
+ left = i + 1;
+ else {
+ previous = i;
+ if (constMask) *valueP = modifiers[i].value;
+ else /* if (modifiers[i].modifierParseProc) always true */
+ (*modifiers[i].modifierParseProc)
+ (modifiers[i].value, lateBindings, notFlag, valueP);
+ UNLOCK_PROCESS;
+ return TRUE;
+ }
+ }
+ UNLOCK_PROCESS;
+ return FALSE;
+}
+
+
+static String ScanIdent(
+ register String str)
+{
+ ScanAlphanumeric(str);
+ while (
+ ('A' <= *str && *str <= 'Z')
+ || ('a' <= *str && *str <= 'z')
+ || ('0' <= *str && *str <= '9')
+ || (*str == '-')
+ || (*str == '_')
+ || (*str == '$')
+ ) str++;
+ return str;
+}
+
+static String FetchModifierToken(
+ String str,
+ XrmQuark *token_return)
+{
+ String start = str;
+
+ if (*str == '$') {
+ *token_return = QMeta;
+ str++;
+ return str;
+ }
+ if (*str == '^') {
+ *token_return = QCtrl;
+ str++;
+ return str;
+ }
+ str = ScanIdent(str);
+ if (start != str) {
+ char modStrbuf[100];
+ char* modStr;
+
+ modStr = XtStackAlloc ((size_t)(str - start + 1), modStrbuf);
+ if (modStr == NULL) _XtAllocError (NULL);
+ (void) memmove(modStr, start, str-start);
+ modStr[str-start] = '\0';
+ *token_return = XrmStringToQuark(modStr);
+ XtStackFree (modStr, modStrbuf);
+ return str;
+ }
+ return str;
+}
+
+static String ParseModifiers(
+ register String str,
+ EventPtr event,
+ Boolean* error)
+{
+ register String start;
+ Boolean notFlag, exclusive, keysymAsMod;
+ Value maskBit;
+ XrmQuark Qmod;
+
+ ScanWhitespace(str);
+ start = str;
+ str = FetchModifierToken(str, &Qmod);
+ exclusive = FALSE;
+ if (start != str) {
+ if (Qmod == QNone) {
+ event->event.modifierMask = ~0;
+ event->event.modifiers = 0;
+ ScanWhitespace(str);
+ return str;
+ } else if (Qmod == QAny) { /*backward compatability*/
+ event->event.modifierMask = 0;
+ event->event.modifiers = AnyModifier;
+ ScanWhitespace(str);
+ return str;
+ }
+ str = start; /*if plain modifier, reset to beginning */
+ }
+ else while (*str == '!' || *str == ':') {
+ if (*str == '!') {
+ exclusive = TRUE;
+ str++;
+ ScanWhitespace(str);
+ }
+ if (*str == ':') {
+ event->event.standard = TRUE;
+ str++;
+ ScanWhitespace(str);
+ }
+ }
+
+ while (*str != '<') {
+ if (*str == '~') {
+ notFlag = TRUE;
+ str++;
+ } else
+ notFlag = FALSE;
+ if (*str == '@') {
+ keysymAsMod = TRUE;
+ str++;
+ }
+ else keysymAsMod = FALSE;
+ start = str;
+ str = FetchModifierToken(str, &Qmod);
+ if (start == str) {
+ Syntax("Modifier or '<' expected","");
+ *error = TRUE;
+ return PanicModeRecovery(str);
+ }
+ if (keysymAsMod) {
+ _XtParseKeysymMod(XrmQuarkToString(Qmod),
+ &event->event.lateModifiers,
+ notFlag,&maskBit, error);
+ if (*error)
+ return PanicModeRecovery(str);
+
+ } else
+ if (!_XtLookupModifier(Qmod, &event->event.lateModifiers,
+ notFlag, &maskBit, FALSE)) {
+ Syntax("Unknown modifier name: ", XrmQuarkToString(Qmod));
+ *error = TRUE;
+ return PanicModeRecovery(str);
+ }
+ event->event.modifierMask |= maskBit;
+ if (notFlag) event->event.modifiers &= ~maskBit;
+ else event->event.modifiers |= maskBit;
+ ScanWhitespace(str);
+ }
+ if (exclusive) event->event.modifierMask = ~0;
+ return str;
+}
+
+static String ParseXtEventType(
+ register String str,
+ EventPtr event,
+ Cardinal *tmEventP,
+ Boolean* error)
+{
+ String start = str;
+ char eventTypeStrbuf[100];
+ char* eventTypeStr;
+
+ ScanAlphanumeric(str);
+ eventTypeStr = XtStackAlloc ((size_t)(str - start + 1), eventTypeStrbuf);
+ if (eventTypeStr == NULL) _XtAllocError (NULL);
+ (void) memmove(eventTypeStr, start, str-start);
+ eventTypeStr[str-start] = '\0';
+ *tmEventP = LookupTMEventType(eventTypeStr,error);
+ XtStackFree (eventTypeStr, eventTypeStrbuf);
+ if (*error)
+ return PanicModeRecovery(str);
+ event->event.eventType = events[*tmEventP].eventType;
+ return str;
+}
+
+static unsigned long StrToHex(
+ String str)
+{
+ register char c;
+ register unsigned long val = 0;
+
+ while ((c = *str)) {
+ if ('0' <= c && c <= '9') val = val*16+c-'0';
+ else if ('a' <= c && c <= 'z') val = val*16+c-'a'+10;
+ else if ('A' <= c && c <= 'Z') val = val*16+c-'A'+10;
+ else return 0;
+ str++;
+ }
+
+ return val;
+}
+
+static unsigned long StrToOct(
+ String str)
+{
+ register char c;
+ register unsigned long val = 0;
+
+ while ((c = *str)) {
+ if ('0' <= c && c <= '7') val = val*8+c-'0'; else return 0;
+ str++;
+ }
+
+ return val;
+}
+
+static unsigned long StrToNum(
+ String str)
+{
+ register char c;
+ register unsigned long val = 0;
+
+ if (*str == '0') {
+ str++;
+ if (*str == 'x' || *str == 'X') return StrToHex(++str);
+ else return StrToOct(str);
+ }
+
+ while ((c = *str)) {
+ if ('0' <= c && c <= '9') val = val*10+c-'0';
+ else return 0;
+ str++;
+ }
+
+ return val;
+}
+
+static KeySym StringToKeySym(
+ String str,
+ Boolean *error)
+{
+ KeySym k;
+
+ if (str == NULL || *str == '\0') return (KeySym) 0;
+
+#ifndef NOTASCII
+ /* special case single character ASCII, for speed */
+ if (*(str+1) == '\0') {
+ if (' ' <= *str && *str <= '~') return XK_space + (*str - ' ');
+ }
+#endif
+
+ if ('0' <= *str && *str <= '9') return (KeySym) StrToNum(str);
+ k = XStringToKeysym(str);
+ if (k != NoSymbol) return k;
+
+#ifdef NOTASCII
+ /* fall-back case to preserve backwards compatibility; no-one
+ * should be relying upon this!
+ */
+ if (*(str+1) == '\0') return (KeySym) *str;
+#endif
+
+ Syntax("Unknown keysym name: ", str);
+ *error = TRUE;
+ return NoSymbol;
+}
+/* ARGSUSED */
+static void ParseModImmed(
+ Value value,
+ LateBindingsPtr* lateBindings,
+ Boolean notFlag,
+ Value* valueP)
+{
+ *valueP = value;
+}
+
+ /* is only valid with keysyms that have an _L and _R in their name;
+ * and ignores keysym lookup errors (i.e. assumes only valid keysyms)
+ */
+static void ParseModSym(
+ Value value,
+ LateBindingsPtr* lateBindings,
+ Boolean notFlag,
+ Value* valueP)
+{
+ register KeySym keysymL = (KeySym)value;
+ register KeySym keysymR = keysymL + 1; /* valid for supported keysyms */
+ StoreLateBindings(keysymL,notFlag,keysymR,notFlag,lateBindings);
+ *valueP = 0;
+}
+
+#ifdef sparc
+/*
+ * The stupid optimizer in SunOS 4.0.3 and below generates bogus code that
+ * causes the value of the most recently used variable to be returned instead
+ * of the value passed in.
+ */
+static String stupid_optimizer_kludge;
+#define BROKEN_OPTIMIZER_HACK(val) stupid_optimizer_kludge = (val)
+#else
+#define BROKEN_OPTIMIZER_HACK(val) val
+#endif
+
+/* ARGSUSED */
+static String ParseImmed(
+ register String str,
+ register Opaque closure,
+ register EventPtr event,
+ Boolean* error)
+{
+ event->event.eventCode = (unsigned long)closure;
+ event->event.eventCodeMask = ~0UL;
+
+ return BROKEN_OPTIMIZER_HACK(str);
+}
+
+/* ARGSUSED */
+static String ParseAddModifier(
+ register String str,
+ register Opaque closure,
+ register EventPtr event,
+ Boolean* error)
+{
+ register unsigned long modval = (unsigned long)closure;
+ event->event.modifiers |= modval;
+ if (modval != AnyButtonMask) /* AnyButtonMask is don't-care mask */
+ event->event.modifierMask |= modval;
+
+ return BROKEN_OPTIMIZER_HACK(str);
+}
+
+
+static String ParseKeyAndModifiers(
+ String str,
+ Opaque closure,
+ EventPtr event,
+ Boolean* error)
+{
+ str = ParseKeySym(str, closure, event,error);
+ if ((unsigned long) closure == 0) {
+ Value metaMask; /* unused */
+ (void) _XtLookupModifier(QMeta, &event->event.lateModifiers, FALSE,
+ &metaMask, FALSE);
+ } else {
+ event->event.modifiers |= (unsigned long) closure;
+ event->event.modifierMask |= (unsigned long) closure;
+ }
+ return str;
+}
+
+/*ARGSUSED*/
+static String ParseKeySym(
+ register String str,
+ Opaque closure,
+ EventPtr event,
+ Boolean* error)
+{
+ char *start;
+ char keySymNamebuf[100];
+ char* keySymName;
+
+ ScanWhitespace(str);
+
+ if (*str == '\\') {
+ keySymName = keySymNamebuf;
+ str++;
+ keySymName[0] = *str;
+ if (*str != '\0' && !IsNewline(*str)) str++;
+ keySymName[1] = '\0';
+ event->event.eventCode = StringToKeySym(keySymName, error);
+ event->event.eventCodeMask = ~0L;
+ } else if (*str == ',' || *str == ':' ||
+ /* allow leftparen to be single char symbol,
+ * for backwards compatibility
+ */
+ (*str == '(' && *(str+1) >= '0' && *(str+1) <= '9')) {
+ keySymName = keySymNamebuf; /* just so we can stackfree it later */
+ /* no detail */
+ event->event.eventCode = 0L;
+ event->event.eventCodeMask = 0L;
+ } else {
+ start = str;
+ while (
+ *str != ','
+ && *str != ':'
+ && *str != ' '
+ && *str != '\t'
+ && !IsNewline(*str)
+ && (*str != '(' || *(str+1) <= '0' || *(str+1) >= '9')
+ && *str != '\0') str++;
+ keySymName = XtStackAlloc ((size_t)(str - start + 1), keySymNamebuf);
+ (void) memmove(keySymName, start, str-start);
+ keySymName[str-start] = '\0';
+ event->event.eventCode = StringToKeySym(keySymName, error);
+ event->event.eventCodeMask = ~0L;
+ }
+ if (*error) {
+ /* We never get here when keySymName hasn't been allocated */
+ if (keySymName[0] == '<') {
+ /* special case for common error */
+ XtWarningMsg(XtNtranslationParseError, "missingComma",
+ XtCXtToolkitError,
+ "... possibly due to missing ',' in event sequence.",
+ (String*)NULL, (Cardinal*)NULL);
+ }
+ XtStackFree (keySymName, keySymNamebuf);
+ return PanicModeRecovery(str);
+ }
+ if (event->event.standard)
+ event->event.matchEvent = _XtMatchUsingStandardMods;
+ else
+ event->event.matchEvent = _XtMatchUsingDontCareMods;
+
+ XtStackFree (keySymName, keySymNamebuf);
+
+ return str;
+}
+
+static String ParseTable(
+ register String str,
+ Opaque closure,
+ EventPtr event,
+ Boolean* error)
+{
+ register String start = str;
+ register XrmQuark signature;
+ NameValueTable table = (NameValueTable) closure;
+ char tableSymName[100];
+
+ event->event.eventCode = 0L;
+ ScanAlphanumeric(str);
+ if (str == start) {event->event.eventCodeMask = 0L; return str; }
+ if (str-start >= 99) {
+ Syntax("Invalid Detail Type (string is too long).", "");
+ *error = TRUE;
+ return str;
+ }
+ (void) memmove(tableSymName, start, str-start);
+ tableSymName[str-start] = '\0';
+ signature = StringToQuark(tableSymName);
+ for (; table->signature != NULLQUARK; table++)
+ if (table->signature == signature) {
+ event->event.eventCode = table->value;
+ event->event.eventCodeMask = ~0L;
+ return str;
+ }
+
+ Syntax("Unknown Detail Type: ", tableSymName);
+ *error = TRUE;
+ return PanicModeRecovery(str);
+}
+
+/*ARGSUSED*/
+static String ParseNone(
+ String str,
+ Opaque closure,
+ EventPtr event,
+ Boolean* error)
+{
+ event->event.eventCode = 0;
+ event->event.eventCodeMask = 0;
+
+ return BROKEN_OPTIMIZER_HACK(str);
+}
+
+/*ARGSUSED*/
+static String ParseAtom(
+ String str,
+ Opaque closure,
+ EventPtr event,
+ Boolean* error)
+{
+ ScanWhitespace(str);
+
+ if (*str == ',' || *str == ':') {
+ /* no detail */
+ event->event.eventCode = 0L;
+ event->event.eventCodeMask = 0L;
+ } else {
+ char *start, atomName[1000];
+ start = str;
+ while (
+ *str != ','
+ && *str != ':'
+ && *str != ' '
+ && *str != '\t'
+ && !IsNewline(*str)
+ && *str != '\0') str++;
+ if (str-start >= 999) {
+ Syntax( "Atom name must be less than 1000 characters long.", "" );
+ *error = TRUE;
+ return str;
+ }
+ (void) memmove(atomName, start, str-start);
+ atomName[str-start] = '\0';
+ event->event.eventCode = XrmStringToQuark(atomName);
+ event->event.matchEvent = _XtMatchAtom;
+ }
+ return str;
+}
+
+static ModifierMask buttonModifierMasks[] = {
+ 0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
+};
+static String ParseRepeat(String, int *, Boolean *, Boolean *);
+
+static String ParseEvent(
+ register String str,
+ EventPtr event,
+ int* reps,
+ Boolean* plus,
+ Boolean* error)
+{
+ Cardinal tmEvent;
+
+ str = ParseModifiers(str, event,error);
+ if (*error) return str;
+ if (*str != '<') {
+ Syntax("Missing '<' while parsing event type.","");
+ *error = TRUE;
+ return PanicModeRecovery(str);
+ }
+ else str++;
+ str = ParseXtEventType(str, event, &tmEvent,error);
+ if (*error) return str;
+ if (*str != '>'){
+ Syntax("Missing '>' while parsing event type","");
+ *error = TRUE;
+ return PanicModeRecovery(str);
+ }
+ else str++;
+ if (*str == '(') {
+ str = ParseRepeat(str, reps, plus, error);
+ if (*error) return str;
+ }
+ str = (*(events[tmEvent].parseDetail))(
+ str, events[tmEvent].closure, event,error);
+ if (*error) return str;
+
+/* gross hack! ||| this kludge is related to the X11 protocol deficiency w.r.t.
+ * modifiers in grabs.
+ */
+ if ((event->event.eventType == ButtonRelease)
+ && (event->event.modifiers | event->event.modifierMask) /* any */
+ && (event->event.modifiers != AnyModifier))
+ {
+ event->event.modifiers
+ |= buttonModifierMasks[event->event.eventCode];
+ /* the button that is going up will always be in the modifiers... */
+ }
+
+ return str;
+}
+
+static String ParseQuotedStringEvent(
+ register String str,
+ register EventPtr event,
+ Boolean *error)
+{
+ Value metaMask;
+ char s[2];
+
+ if (*str=='^') {
+ str++;
+ event->event.modifiers = ControlMask;
+ } else if (*str == '$') {
+ str++;
+ (void) _XtLookupModifier(QMeta, &event->event.lateModifiers, FALSE,
+ &metaMask, FALSE);
+ }
+ if (*str == '\\')
+ str++;
+ s[0] = *str;
+ s[1] = '\0';
+ if (*str != '\0' && !IsNewline(*str)) str++;
+ event->event.eventType = KeyPress;
+ event->event.eventCode = StringToKeySym(s, error);
+ if (*error) return PanicModeRecovery(str);
+ event->event.eventCodeMask = ~0L;
+ event->event.matchEvent = _XtMatchUsingStandardMods;
+ event->event.standard = TRUE;
+
+ return str;
+}
+
+
+static EventSeqRec timerEventRec = {
+ {0, 0, NULL, _XtEventTimerEventType, 0L, 0L, NULL, False},
+ /* (StatePtr) -1 */ NULL,
+ NULL,
+ NULL
+};
+
+static void RepeatDown(
+ EventPtr *eventP,
+ int reps,
+ ActionPtr **actionsP)
+{
+ EventRec upEventRec;
+ register EventPtr event, downEvent;
+ EventPtr upEvent = &upEventRec;
+ register int i;
+
+ downEvent = event = *eventP;
+ *upEvent = *downEvent;
+ upEvent->event.eventType = ((event->event.eventType == ButtonPress) ?
+ ButtonRelease : KeyRelease);
+ if ((upEvent->event.eventType == ButtonRelease)
+ && (upEvent->event.modifiers != AnyModifier)
+ && (upEvent->event.modifiers | upEvent->event.modifierMask))
+ upEvent->event.modifiers
+ |= buttonModifierMasks[event->event.eventCode];
+
+ if (event->event.lateModifiers)
+ event->event.lateModifiers->ref_count += (reps - 1) * 2;
+
+ for (i=1; i<reps; i++) {
+
+ /* up */
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = *upEvent;
+
+ /* timer */
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = timerEventRec;
+
+ /* down */
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = *downEvent;
+
+ }
+
+ event->next = NULL;
+ *eventP = event;
+ *actionsP = &event->actions;
+}
+
+static void RepeatDownPlus(
+ EventPtr *eventP,
+ int reps,
+ ActionPtr **actionsP)
+{
+ EventRec upEventRec;
+ register EventPtr event, downEvent, lastDownEvent = NULL;
+ EventPtr upEvent = &upEventRec;
+ register int i;
+
+ downEvent = event = *eventP;
+ *upEvent = *downEvent;
+ upEvent->event.eventType = ((event->event.eventType == ButtonPress) ?
+ ButtonRelease : KeyRelease);
+ if ((upEvent->event.eventType == ButtonRelease)
+ && (upEvent->event.modifiers != AnyModifier)
+ && (upEvent->event.modifiers | upEvent->event.modifierMask))
+ upEvent->event.modifiers
+ |= buttonModifierMasks[event->event.eventCode];
+
+ if (event->event.lateModifiers)
+ event->event.lateModifiers->ref_count += reps * 2 - 1;
+
+ for (i=0; i<reps; i++) {
+
+ if (i > 0) {
+ /* down */
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = *downEvent;
+ }
+ lastDownEvent = event;
+
+ /* up */
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = *upEvent;
+
+ /* timer */
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = timerEventRec;
+
+ }
+
+ event->next = lastDownEvent;
+ *eventP = event;
+ *actionsP = &lastDownEvent->actions;
+}
+
+static void RepeatUp(
+ EventPtr *eventP,
+ int reps,
+ ActionPtr **actionsP)
+{
+ EventRec upEventRec;
+ register EventPtr event, downEvent;
+ EventPtr upEvent = &upEventRec;
+ register int i;
+
+ /* the event currently sitting in *eventP is an "up" event */
+ /* we want to make it a "down" event followed by an "up" event, */
+ /* so that sequence matching on the "state" side works correctly. */
+
+ downEvent = event = *eventP;
+ *upEvent = *downEvent;
+ downEvent->event.eventType = ((event->event.eventType == ButtonRelease) ?
+ ButtonPress : KeyPress);
+ if ((downEvent->event.eventType == ButtonPress)
+ && (downEvent->event.modifiers != AnyModifier)
+ && (downEvent->event.modifiers | downEvent->event.modifierMask))
+ downEvent->event.modifiers
+ &= ~buttonModifierMasks[event->event.eventCode];
+
+ if (event->event.lateModifiers)
+ event->event.lateModifiers->ref_count += reps * 2 - 1;
+
+ /* up */
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = *upEvent;
+
+ for (i=1; i<reps; i++) {
+
+ /* timer */
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = timerEventRec;
+
+ /* down */
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = *downEvent;
+
+ /* up */
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = *upEvent;
+
+ }
+
+ event->next = NULL;
+ *eventP = event;
+ *actionsP = &event->actions;
+}
+
+static void RepeatUpPlus(
+ EventPtr *eventP,
+ int reps,
+ ActionPtr **actionsP)
+{
+ EventRec upEventRec;
+ register EventPtr event, downEvent, lastUpEvent = NULL;
+ EventPtr upEvent = &upEventRec;
+ register int i;
+
+ /* the event currently sitting in *eventP is an "up" event */
+ /* we want to make it a "down" event followed by an "up" event, */
+ /* so that sequence matching on the "state" side works correctly. */
+
+ downEvent = event = *eventP;
+ *upEvent = *downEvent;
+ downEvent->event.eventType = ((event->event.eventType == ButtonRelease) ?
+ ButtonPress : KeyPress);
+ if ((downEvent->event.eventType == ButtonPress)
+ && (downEvent->event.modifiers != AnyModifier)
+ && (downEvent->event.modifiers | downEvent->event.modifierMask))
+ downEvent->event.modifiers
+ &= ~buttonModifierMasks[event->event.eventCode];
+
+ if (event->event.lateModifiers)
+ event->event.lateModifiers->ref_count += reps * 2;
+
+ for (i=0; i<reps; i++) {
+
+ /* up */
+ event->next = XtNew(EventSeqRec);
+ lastUpEvent = event = event->next;
+ *event = *upEvent;
+
+ /* timer */
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = timerEventRec;
+
+ /* down */
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = *downEvent;
+
+ }
+
+ event->next = lastUpEvent;
+ *eventP = event;
+ *actionsP = &lastUpEvent->actions;
+}
+
+static void RepeatOther(
+ EventPtr *eventP,
+ int reps,
+ ActionPtr **actionsP)
+{
+ register EventPtr event, tempEvent;
+ register int i;
+
+ tempEvent = event = *eventP;
+
+ if (event->event.lateModifiers)
+ event->event.lateModifiers->ref_count += reps - 1;
+
+ for (i=1; i<reps; i++) {
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = *tempEvent;
+ }
+
+ *eventP = event;
+ *actionsP = &event->actions;
+}
+
+static void RepeatOtherPlus(
+ EventPtr *eventP,
+ int reps,
+ ActionPtr **actionsP)
+{
+ register EventPtr event, tempEvent;
+ register int i;
+
+ tempEvent = event = *eventP;
+
+ if (event->event.lateModifiers)
+ event->event.lateModifiers->ref_count += reps - 1;
+
+ for (i=1; i<reps; i++) {
+ event->next = XtNew(EventSeqRec);
+ event = event->next;
+ *event = *tempEvent;
+ }
+
+ event->next = event;
+ *eventP = event;
+ *actionsP = &event->actions;
+}
+
+static void RepeatEvent(
+ EventPtr *eventP,
+ int reps,
+ Boolean plus,
+ ActionPtr **actionsP)
+{
+ switch ((*eventP)->event.eventType) {
+
+ case ButtonPress:
+ case KeyPress:
+ if (plus) RepeatDownPlus(eventP, reps, actionsP);
+ else RepeatDown(eventP, reps, actionsP);
+ break;
+
+ case ButtonRelease:
+ case KeyRelease:
+ if (plus) RepeatUpPlus(eventP, reps, actionsP);
+ else RepeatUp(eventP, reps, actionsP);
+ break;
+
+ default:
+ if (plus) RepeatOtherPlus(eventP, reps, actionsP);
+ else RepeatOther(eventP, reps, actionsP);
+ }
+}
+
+static String ParseRepeat(
+ register String str,
+ int *reps,
+ Boolean *plus, Boolean *error)
+{
+
+ /*** Parse the repetitions, for double click etc... ***/
+ if (*str != '(' || !(isdigit(str[1]) || str[1] == '+' || str[1] == ')'))
+ return str;
+ str++;
+ if (isdigit(*str)) {
+ String start = str;
+ char repStr[7];
+ size_t len;
+
+ ScanNumeric(str);
+ len = (str - start);
+ if (len < sizeof repStr) {
+ (void) memmove(repStr, start, len);
+ repStr[len] = '\0';
+ *reps = StrToNum(repStr);
+ } else {
+ Syntax("Repeat count too large.", "");
+ *error = TRUE;
+ return str;
+ }
+ }
+ if (*reps == 0) {
+ Syntax("Missing repeat count.","");
+ *error = True;
+ return str;
+ }
+
+ if (*str == '+') {
+ *plus = TRUE;
+ str++;
+ }
+ if (*str == ')')
+ str++;
+ else {
+ Syntax("Missing ')'.","");
+ *error = TRUE;
+ }
+
+ return str;
+}
+
+/***********************************************************************
+ * ParseEventSeq
+ * Parses the left hand side of a translation table production
+ * up to, and consuming the ":".
+ * Takes a pointer to a char* (where to start parsing) and returns an
+ * event seq (in a passed in variable), having updated the String
+ **********************************************************************/
+
+static String ParseEventSeq(
+ register String str,
+ EventSeqPtr *eventSeqP,
+ ActionPtr **actionsP,
+ Boolean *error)
+{
+ EventSeqPtr *nextEvent = eventSeqP;
+
+ *eventSeqP = NULL;
+
+ while ( *str != '\0' && !IsNewline(*str)) {
+ static Event nullEvent =
+ {0, 0,0L, 0, 0L, 0L,_XtRegularMatch,FALSE};
+ EventPtr event;
+
+ ScanWhitespace(str);
+
+ if (*str == '"') {
+ str++;
+ while (*str != '"' && *str != '\0' && !IsNewline(*str)) {
+ event = XtNew(EventRec);
+ event->event = nullEvent;
+ event->state = /* (StatePtr) -1 */ NULL;
+ event->next = NULL;
+ event->actions = NULL;
+ str = ParseQuotedStringEvent(str, event,error);
+ if (*error) {
+ XtWarningMsg(XtNtranslationParseError, "nonLatin1",
+ XtCXtToolkitError,
+ "... probably due to non-Latin1 character in quoted string",
+ (String*)NULL, (Cardinal*)NULL);
+ return PanicModeRecovery(str);
+ }
+ *nextEvent = event;
+ *actionsP = &event->actions;
+ nextEvent = &event->next;
+ }
+ if (*str != '"') {
+ Syntax("Missing '\"'.","");
+ *error = TRUE;
+ return PanicModeRecovery(str);
+ }
+ else str++;
+ } else {
+ int reps = 0;
+ Boolean plus = FALSE;
+
+ event = XtNew(EventRec);
+ event->event = nullEvent;
+ event->state = /* (StatePtr) -1 */ NULL;
+ event->next = NULL;
+ event->actions = NULL;
+
+ str = ParseEvent(str, event, &reps, &plus, error);
+ if (*error) return str;
+ *nextEvent = event;
+ *actionsP = &event->actions;
+ if (reps > 1 || plus)
+ RepeatEvent(&event, reps, plus, actionsP);
+ nextEvent = &event->next;
+ }
+ ScanWhitespace(str);
+ if (*str == ':') break;
+ else {
+ if (*str != ',') {
+ Syntax("',' or ':' expected while parsing event sequence.","");
+ *error = TRUE;
+ return PanicModeRecovery(str);
+ } else str++;
+ }
+ }
+
+ if (*str != ':') {
+ Syntax("Missing ':'after event sequence.","");
+ *error = TRUE;
+ return PanicModeRecovery(str);
+ } else str++;
+
+ return str;
+}
+
+
+static String ParseActionProc(
+ register String str,
+ XrmQuark *actionProcNameP,
+ Boolean *error)
+{
+ register String start = str;
+ char procName[200];
+
+ str = ScanIdent(str);
+ if (str-start >= 199) {
+ Syntax("Action procedure name is longer than 199 chars","");
+ *error = TRUE;
+ return str;
+ }
+ (void) memmove(procName, start, str-start);
+ procName[str-start] = '\0';
+ *actionProcNameP = XrmStringToQuark( procName );
+ return str;
+}
+
+
+static String ParseString(
+ register String str,
+ String *strP)
+{
+ register String start;
+
+ if (*str == '"') {
+ register unsigned prev_len, len;
+ str++;
+ start = str;
+ *strP = NULL;
+ prev_len = 0;
+
+ while (*str != '"' && *str != '\0') {
+ /* \" produces double quote embedded in a quoted parameter
+ * \\" produces backslash as last character of a quoted parameter
+ */
+ if (*str == '\\' &&
+ (*(str+1) == '"' || (*(str+1) == '\\' && *(str+2) == '"'))) {
+ len = prev_len + (str-start+2);
+ *strP = XtRealloc(*strP, len);
+ (void) memmove(*strP + prev_len, start, str-start);
+ prev_len = len-1;
+ str++;
+ (*strP)[prev_len-1] = *str;
+ (*strP)[prev_len] = '\0';
+ start = str+1;
+ }
+ str++;
+ }
+ len = prev_len + (str-start+1);
+ *strP = XtRealloc(*strP, len);
+ (void) memmove( *strP + prev_len, start, str-start);
+ (*strP)[len-1] = '\0';
+ if (*str == '"') str++; else
+ XtWarningMsg(XtNtranslationParseError,"parseString",
+ XtCXtToolkitError,"Missing '\"'.",
+ (String *)NULL, (Cardinal *)NULL);
+ } else {
+ /* scan non-quoted string, stop on whitespace, ',' or ')' */
+ start = str;
+ while (*str != ' '
+ && *str != '\t'
+ && *str != ','
+ && *str != ')'
+ && !IsNewline(*str)
+ && *str != '\0') str++;
+ *strP = __XtMalloc((unsigned)(str-start+1));
+ (void) memmove(*strP, start, str-start);
+ (*strP)[str-start] = '\0';
+ }
+ return str;
+}
+
+
+static String ParseParamSeq(
+ register String str,
+ String **paramSeqP,
+ Cardinal *paramNumP)
+{
+ typedef struct _ParamRec *ParamPtr;
+ typedef struct _ParamRec {
+ ParamPtr next;
+ String param;
+ } ParamRec;
+
+ ParamPtr params = NULL;
+ register Cardinal num_params = 0;
+ register Cardinal i;
+
+ ScanWhitespace(str);
+ while (*str != ')' && *str != '\0' && !IsNewline(*str)) {
+ String newStr;
+ str = ParseString(str, &newStr);
+ if (newStr != NULL) {
+ ParamPtr temp = (ParamRec*)
+ ALLOCATE_LOCAL( (unsigned)sizeof(ParamRec) );
+ if (temp == NULL) _XtAllocError (NULL);
+
+ num_params++;
+ temp->next = params;
+ params = temp;
+ temp->param = newStr;
+ ScanWhitespace(str);
+ if (*str == ',') {
+ str++;
+ ScanWhitespace(str);
+ }
+ }
+ }
+
+ if (num_params != 0) {
+ String *paramP = (String *)
+ __XtMalloc( (unsigned)(num_params+1) * sizeof(String) );
+ *paramSeqP = paramP;
+ *paramNumP = num_params;
+ paramP += num_params; /* list is LIFO right now */
+ *paramP-- = NULL;
+ for (i=0; i < num_params; i++) {
+ ParamPtr next = params->next;
+ *paramP-- = params->param;
+ DEALLOCATE_LOCAL( (char *)params );
+ params = next;
+ }
+ } else {
+ *paramSeqP = NULL;
+ *paramNumP = 0;
+ }
+
+ return str;
+}
+
+static String ParseAction(
+ String str,
+ ActionPtr actionP,
+ XrmQuark* quarkP,
+ Boolean* error)
+{
+ str = ParseActionProc(str, quarkP, error);
+ if (*error) return str;
+
+ if (*str == '(') {
+ str++;
+ str = ParseParamSeq(str, &actionP->params, &actionP->num_params);
+ } else {
+ Syntax("Missing '(' while parsing action sequence","");
+ *error = TRUE;
+ return str;
+ }
+ if (*str == ')') str++;
+ else{
+ Syntax("Missing ')' while parsing action sequence","");
+ *error = TRUE;
+ return str;
+ }
+ return str;
+}
+
+
+static String ParseActionSeq(
+ TMParseStateTree parseTree,
+ String str,
+ ActionPtr *actionsP,
+ Boolean *error)
+{
+ ActionPtr *nextActionP = actionsP;
+
+ *actionsP = NULL;
+ while (*str != '\0' && !IsNewline(*str)) {
+ register ActionPtr action;
+ XrmQuark quark;
+
+ action = XtNew(ActionRec);
+ action->params = NULL;
+ action->num_params = 0;
+ action->next = NULL;
+
+ str = ParseAction(str, action, &quark, error);
+ if (*error) return PanicModeRecovery(str);
+
+ action->idx = _XtGetQuarkIndex(parseTree, quark);
+ ScanWhitespace(str);
+ *nextActionP = action;
+ nextActionP = &action->next;
+ }
+ if (IsNewline(*str)) str++;
+ ScanWhitespace(str);
+ return str;
+}
+
+
+static void ShowProduction(
+ String currentProduction)
+{
+ Cardinal num_params = 1;
+ String params[1];
+ size_t len;
+ char *eol, *production, productionbuf[500];
+
+#ifdef __UNIXOS2__
+ eol = strchr(currentProduction, '\r');
+ if (!eol) /* try '\n' as well below */
+#endif
+ eol = strchr(currentProduction, '\n');
+ if (eol) len = eol - currentProduction;
+ else len = strlen (currentProduction);
+ production = XtStackAlloc (len + 1, productionbuf);
+ if (production == NULL) _XtAllocError (NULL);
+ (void) memmove(production, currentProduction, len);
+ production[len] = '\0';
+
+ params[0] = production;
+ XtWarningMsg(XtNtranslationParseError, "showLine", XtCXtToolkitError,
+ "... found while parsing '%s'", params, &num_params);
+
+ XtStackFree (production, productionbuf);
+}
+
+/***********************************************************************
+ * ParseTranslationTableProduction
+ * Parses one line of event bindings.
+ ***********************************************************************/
+
+static String ParseTranslationTableProduction(
+ TMParseStateTree parseTree,
+ register String str,
+ Boolean* error)
+{
+ EventSeqPtr eventSeq = NULL;
+ ActionPtr *actionsP;
+ String production = str;
+
+ str = ParseEventSeq(str, &eventSeq, &actionsP,error);
+ if (*error == TRUE) {
+ ShowProduction(production);
+ FreeEventSeq(eventSeq);
+ return (str);
+ }
+ ScanWhitespace(str);
+ str = ParseActionSeq(parseTree, str, actionsP, error);
+ if (*error == TRUE) {
+ ShowProduction(production);
+ FreeEventSeq(eventSeq);
+ return (str);
+ }
+
+ _XtAddEventSeqToStateTree(eventSeq, parseTree);
+ FreeEventSeq(eventSeq);
+ return (str);
+}
+
+static String CheckForPoundSign(
+ String str,
+ _XtTranslateOp defaultOp,
+ _XtTranslateOp *actualOpRtn)
+{
+ String start;
+ char operation[20];
+ _XtTranslateOp opType;
+
+ opType = defaultOp;
+ ScanWhitespace(str);
+ if (*str == '#') {
+ int len;
+ str++;
+ start = str;
+ str = ScanIdent(str);
+ len = MIN(19, str-start);
+ (void) memmove(operation, start, len);
+ operation[len] = '\0';
+ if (!strcmp(operation,"replace"))
+ opType = XtTableReplace;
+ else if (!strcmp(operation,"augment"))
+ opType = XtTableAugment;
+ else if (!strcmp(operation,"override"))
+ opType = XtTableOverride;
+ ScanWhitespace(str);
+ if (IsNewline(*str)) {
+ str++;
+ ScanWhitespace(str);
+ }
+ }
+ *actualOpRtn = opType;
+ return str;
+}
+
+static XtTranslations ParseTranslationTable(
+ String source,
+ Boolean isAccelerator,
+ _XtTranslateOp defaultOp,
+ Boolean* error)
+{
+ XtTranslations xlations;
+ TMStateTree stateTrees[8];
+ TMParseStateTreeRec parseTreeRec, *parseTree = &parseTreeRec;
+ XrmQuark stackQuarks[200];
+ TMBranchHeadRec stackBranchHeads[200];
+ StatePtr stackComplexBranchHeads[200];
+ _XtTranslateOp actualOp;
+
+ if (source == NULL)
+ return (XtTranslations)NULL;
+
+ source = CheckForPoundSign(source, defaultOp, &actualOp);
+ if (isAccelerator && actualOp == XtTableReplace)
+ actualOp = defaultOp;
+
+ parseTree->isSimple = TRUE;
+ parseTree->mappingNotifyInterest = FALSE;
+ parseTree->isAccelerator = isAccelerator;
+ parseTree->isStackBranchHeads =
+ parseTree->isStackQuarks =
+ parseTree->isStackComplexBranchHeads = TRUE;
+
+ parseTree->numQuarks =
+ parseTree->numBranchHeads =
+ parseTree->numComplexBranchHeads = 0;
+
+ parseTree->quarkTblSize =
+ parseTree->branchHeadTblSize =
+ parseTree->complexBranchHeadTblSize = 200;
+
+ parseTree->quarkTbl = stackQuarks;
+ parseTree->branchHeadTbl = stackBranchHeads;
+ parseTree->complexBranchHeadTbl = stackComplexBranchHeads;
+
+ while (source != NULL && *source != '\0') {
+ source = ParseTranslationTableProduction(parseTree, source, error);
+ if (*error == TRUE) break;
+ }
+ stateTrees[0] = _XtParseTreeToStateTree(parseTree);
+
+ if (!parseTree->isStackQuarks)
+ XtFree((char *)parseTree->quarkTbl);
+ if (!parseTree->isStackBranchHeads)
+ XtFree((char *)parseTree->branchHeadTbl);
+ if (!parseTree->isStackComplexBranchHeads)
+ XtFree((char *)parseTree->complexBranchHeadTbl);
+
+ xlations = _XtCreateXlations(stateTrees, 1, NULL, NULL);
+ xlations->operation = actualOp;
+
+#ifdef notdef
+ XtFree(stateTrees);
+#endif /* notdef */
+ return xlations;
+}
+
+/*** public procedures ***/
+
+/*ARGSUSED*/
+Boolean XtCvtStringToAcceleratorTable(
+ Display* dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr from,
+ XrmValuePtr to,
+ XtPointer *closure)
+{
+ String str;
+ Boolean error = FALSE;
+
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "wrongParameters","cvtStringToAcceleratorTable",XtCXtToolkitError,
+ "String to AcceleratorTable conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ str = (String)(from->addr);
+ if (str == NULL) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "badParameters","cvtStringToAcceleratorTable",XtCXtToolkitError,
+ "String to AcceleratorTable conversion needs string",
+ (String *)NULL, (Cardinal *)NULL);
+ return FALSE;
+ }
+ if (to->addr != NULL) {
+ if (to->size < sizeof(XtAccelerators)) {
+ to->size = sizeof(XtAccelerators);
+ return FALSE;
+ }
+ *(XtAccelerators*)to->addr =
+ (XtAccelerators) ParseTranslationTable(str, TRUE, XtTableAugment, &error);
+ }
+ else {
+ static XtAccelerators staticStateTable;
+ staticStateTable =
+ (XtAccelerators) ParseTranslationTable(str, TRUE, XtTableAugment, &error);
+ to->addr = (XPointer) &staticStateTable;
+ to->size = sizeof(XtAccelerators);
+ }
+ if (error == TRUE)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "parseError","cvtStringToAcceleratorTable",XtCXtToolkitError,
+ "String to AcceleratorTable conversion encountered errors",
+ (String *)NULL, (Cardinal *)NULL);
+ return (error != TRUE);
+}
+
+
+/*ARGSUSED*/
+Boolean
+XtCvtStringToTranslationTable(
+ Display *dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr from,
+ XrmValuePtr to,
+ XtPointer *closure_ret)
+{
+ String str;
+ Boolean error = FALSE;
+
+ if (*num_args != 0)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "wrongParameters","cvtStringToTranslationTable",XtCXtToolkitError,
+ "String to TranslationTable conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ str = (String)(from->addr);
+ if (str == NULL) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "badParameters","cvtStringToTranslation",XtCXtToolkitError,
+ "String to TranslationTable conversion needs string",
+ (String *)NULL, (Cardinal *)NULL);
+ return FALSE;
+ }
+ if (to->addr != NULL) {
+ if (to->size < sizeof(XtTranslations)) {
+ to->size = sizeof(XtTranslations);
+ return FALSE;
+ }
+ *(XtTranslations*)to->addr =
+ ParseTranslationTable(str, FALSE, XtTableReplace, &error);
+ }
+ else {
+ static XtTranslations staticStateTable;
+ staticStateTable =
+ ParseTranslationTable(str, FALSE, XtTableReplace, &error);
+ to->addr = (XPointer) &staticStateTable;
+ to->size = sizeof(XtTranslations);
+ }
+ if (error == TRUE)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "parseError","cvtStringToTranslationTable",XtCXtToolkitError,
+ "String to TranslationTable conversion encountered errors",
+ (String *)NULL, (Cardinal *)NULL);
+ return (error != TRUE);
+}
+
+
+/*
+ * Parses a user's or applications translation table
+ */
+XtAccelerators XtParseAcceleratorTable(
+ _Xconst char* source)
+{
+ Boolean error = FALSE;
+ XtAccelerators ret =
+ (XtAccelerators) ParseTranslationTable ((char *)source, TRUE, XtTableAugment, &error);
+ if (error == TRUE)
+ XtWarningMsg ("parseError", "cvtStringToAcceleratorTable",
+ XtCXtToolkitError,
+ "String to AcceleratorTable conversion encountered errors",
+ (String *)NULL, (Cardinal *)NULL);
+ return ret;
+}
+
+XtTranslations XtParseTranslationTable(
+ _Xconst char* source)
+{
+ Boolean error = FALSE;
+ XtTranslations ret = ParseTranslationTable((char *)source, FALSE, XtTableReplace, &error);
+ if (error == TRUE)
+ XtWarningMsg ("parseError",
+ "cvtStringToTranslationTable", XtCXtToolkitError,
+ "String to TranslationTable conversion encountered errors",
+ (String *)NULL, (Cardinal *)NULL);
+ return ret;
+}
+
+void _XtTranslateInitialize(void)
+{
+ LOCK_PROCESS;
+ if (initialized) {
+ XtWarningMsg("translationError","xtTranslateInitialize",
+ XtCXtToolkitError,"Initializing Translation manager twice.",
+ (String *)NULL, (Cardinal *)NULL);
+ UNLOCK_PROCESS;
+ return;
+ }
+
+ initialized = TRUE;
+ UNLOCK_PROCESS;
+ QMeta = XrmPermStringToQuark("Meta");
+ QCtrl = XrmPermStringToQuark("Ctrl");
+ QNone = XrmPermStringToQuark("None");
+ QAny = XrmPermStringToQuark("Any");
+
+ Compile_XtEventTable( events, XtNumber(events) );
+ Compile_XtModifierTable( modifiers, XtNumber(modifiers) );
+ CompileNameValueTable( buttonNames );
+ CompileNameValueTable( notifyModes );
+ CompileNameValueTable( motionDetails );
+#if 0
+ CompileNameValueTable( notifyDetail );
+ CompileNameValueTable( visibilityNotify );
+ CompileNameValueTable( circulation );
+ CompileNameValueTable( propertyChanged );
+#endif
+ CompileNameValueTable( mappingNotify );
+}
+
+void _XtAddTMConverters(
+ ConverterTable table)
+{
+ _XtTableAddConverter(table,
+ _XtQString,
+ XrmPermStringToQuark(XtRTranslationTable),
+ XtCvtStringToTranslationTable, (XtConvertArgList) NULL,
+ (Cardinal)0, True, CACHED, _XtFreeTranslations, True);
+ _XtTableAddConverter(table, _XtQString,
+ XrmPermStringToQuark(XtRAcceleratorTable),
+ XtCvtStringToAcceleratorTable, (XtConvertArgList) NULL,
+ (Cardinal)0, True, CACHED, _XtFreeTranslations, True);
+ _XtTableAddConverter(table,
+ XrmPermStringToQuark( _XtRStateTablePair ),
+ XrmPermStringToQuark(XtRTranslationTable),
+ _XtCvtMergeTranslations, (XtConvertArgList) NULL,
+ (Cardinal)0, True, CACHED, _XtFreeTranslations, True);
+}
diff --git a/nx-X11/lib/Xt/TMprint.c b/nx-X11/lib/Xt/TMprint.c
new file mode 100644
index 000000000..7b7bde22b
--- /dev/null
+++ b/nx-X11/lib/Xt/TMprint.c
@@ -0,0 +1,881 @@
+/* $Xorg: TMprint.c,v 1.4 2001/02/09 02:03:58 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+*/
+/* $XFree86: xc/lib/Xt/TMprint.c,v 1.6 2001/12/14 19:56:31 dawes Exp $ */
+
+/*LINTLIBRARY*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include <stdio.h>
+
+typedef struct _TMStringBufRec{
+ String start;
+ String current;
+ Cardinal max;
+}TMStringBufRec, *TMStringBuf;
+
+
+#define STR_THRESHOLD 25
+#define STR_INCAMOUNT 100
+#define CHECK_STR_OVERFLOW(sb) \
+if (sb->current - sb->start > (int)sb->max - STR_THRESHOLD) \
+{ String old = sb->start; \
+ sb->start = XtRealloc(old, (Cardinal)(sb->max += STR_INCAMOUNT)); \
+ sb->current = sb->current - old + sb->start; \
+}
+
+#define ExpandForChars(sb, nchars ) \
+ if ((unsigned)(sb->current - sb->start) > sb->max - STR_THRESHOLD - nchars) { \
+ String old = sb->start; \
+ sb->start = XtRealloc(old, \
+ (Cardinal)(sb->max += STR_INCAMOUNT + nchars)); \
+ sb->current = sb->current - old + sb->start; \
+ }
+
+#define ExpandToFit(sb, more) \
+{ \
+ size_t l = strlen(more); \
+ ExpandForChars(sb, l); \
+ }
+
+static void PrintModifiers(
+ TMStringBuf sb,
+ unsigned long mask, unsigned long mod)
+{
+ Boolean notfirst = False;
+ CHECK_STR_OVERFLOW(sb);
+
+ if (mask == ~0UL && mod == 0) {
+ *sb->current++ = '!';
+ *sb->current = '\0';
+ return;
+ }
+
+#define PRINTMOD(modmask,modstring) \
+ if (mask & modmask) { \
+ if (! (mod & modmask)) { \
+ *sb->current++ = '~'; \
+ notfirst = True; \
+ } \
+ else if (notfirst) \
+ *sb->current++ = ' '; \
+ else notfirst = True; \
+ strcpy(sb->current, modstring); \
+ sb->current += strlen(sb->current); \
+ }
+
+ PRINTMOD(ShiftMask, "Shift");
+ PRINTMOD(ControlMask, "Ctrl"); /* name is not CtrlMask... */
+ PRINTMOD(LockMask, "Lock");
+ PRINTMOD(Mod1Mask, "Mod1");
+ CHECK_STR_OVERFLOW(sb);
+ PRINTMOD(Mod2Mask, "Mod2");
+ PRINTMOD(Mod3Mask, "Mod3");
+ PRINTMOD(Mod4Mask, "Mod4");
+ PRINTMOD(Mod5Mask, "Mod5");
+ CHECK_STR_OVERFLOW(sb);
+ PRINTMOD(Button1Mask, "Button1");
+ PRINTMOD(Button2Mask, "Button2");
+ PRINTMOD(Button3Mask, "Button3");
+ CHECK_STR_OVERFLOW(sb);
+ PRINTMOD(Button4Mask, "Button4");
+ PRINTMOD(Button5Mask, "Button5");
+
+#undef PRINTMOD
+}
+
+static void PrintEventType(
+ TMStringBuf sb,
+ unsigned long event)
+{
+ CHECK_STR_OVERFLOW(sb);
+ switch (event) {
+#define PRINTEVENT(event, name) case event: (void) strcpy(sb->current, name); break;
+ PRINTEVENT(KeyPress, "<KeyPress>")
+ PRINTEVENT(KeyRelease, "<KeyRelease>")
+ PRINTEVENT(ButtonPress, "<ButtonPress>")
+ PRINTEVENT(ButtonRelease, "<ButtonRelease>")
+ PRINTEVENT(MotionNotify, "<MotionNotify>")
+ PRINTEVENT(EnterNotify, "<EnterNotify>")
+ PRINTEVENT(LeaveNotify, "<LeaveNotify>")
+ PRINTEVENT(FocusIn, "<FocusIn>")
+ PRINTEVENT(FocusOut, "<FocusOut>")
+ PRINTEVENT(KeymapNotify, "<KeymapNotify>")
+ PRINTEVENT(Expose, "<Expose>")
+ PRINTEVENT(GraphicsExpose, "<GraphicsExpose>")
+ PRINTEVENT(NoExpose, "<NoExpose>")
+ PRINTEVENT(VisibilityNotify, "<VisibilityNotify>")
+ PRINTEVENT(CreateNotify, "<CreateNotify>")
+ PRINTEVENT(DestroyNotify, "<DestroyNotify>")
+ PRINTEVENT(UnmapNotify, "<UnmapNotify>")
+ PRINTEVENT(MapNotify, "<MapNotify>")
+ PRINTEVENT(MapRequest, "<MapRequest>")
+ PRINTEVENT(ReparentNotify, "<ReparentNotify>")
+ PRINTEVENT(ConfigureNotify, "<ConfigureNotify>")
+ PRINTEVENT(ConfigureRequest, "<ConfigureRequest>")
+ PRINTEVENT(GravityNotify, "<GravityNotify>")
+ PRINTEVENT(ResizeRequest, "<ResizeRequest>")
+ PRINTEVENT(CirculateNotify, "<CirculateNotify>")
+ PRINTEVENT(CirculateRequest, "<CirculateRequest>")
+ PRINTEVENT(PropertyNotify, "<PropertyNotify>")
+ PRINTEVENT(SelectionClear, "<SelectionClear>")
+ PRINTEVENT(SelectionRequest, "<SelectionRequest>")
+ PRINTEVENT(SelectionNotify, "<SelectionNotify>")
+ PRINTEVENT(ColormapNotify, "<ColormapNotify>")
+ PRINTEVENT(ClientMessage, "<ClientMessage>")
+ case _XtEventTimerEventType:
+ (void) strcpy(sb->current,"<EventTimer>");
+ break;
+ default:
+ (void) sprintf(sb->current, "<0x%x>", (int) event);
+#undef PRINTEVENT
+ }
+ sb->current += strlen(sb->current);
+}
+
+static void PrintCode(
+ TMStringBuf sb,
+ unsigned long mask, unsigned long code)
+{
+ CHECK_STR_OVERFLOW(sb);
+ if (mask != 0) {
+ if (mask != ~0UL)
+ (void) sprintf(sb->current, "0x%lx:0x%lx", mask, code);
+ else (void) sprintf(sb->current, /*"0x%lx"*/ "%d", (unsigned)code);
+ sb->current += strlen(sb->current);
+ }
+}
+
+static void PrintKeysym(
+ TMStringBuf sb,
+ KeySym keysym)
+{
+ String keysymName;
+
+ if (keysym == 0) return;
+
+ CHECK_STR_OVERFLOW(sb);
+ keysymName = XKeysymToString(keysym);
+ if (keysymName == NULL)
+ PrintCode(sb,~0UL,(unsigned long)keysym);
+ else {
+ ExpandToFit(sb, keysymName);
+ strcpy(sb->current, keysymName);
+ sb->current += strlen(sb->current);
+ }
+}
+
+static void PrintAtom(
+ TMStringBuf sb,
+ Display *dpy,
+ Atom atom)
+{
+ String atomName;
+
+ if (atom == 0) return;
+
+ atomName = (dpy ? XGetAtomName(dpy, atom) : NULL);
+
+ if (! atomName)
+ PrintCode(sb,~0UL,(unsigned long)atom);
+ else {
+ ExpandToFit( sb, atomName );
+ strcpy(sb->current, atomName);
+ sb->current += strlen(sb->current);
+ XFree(atomName);
+ }
+}
+
+static void PrintLateModifiers(
+ TMStringBuf sb,
+ LateBindingsPtr lateModifiers)
+{
+ for (; lateModifiers->keysym; lateModifiers++) {
+ CHECK_STR_OVERFLOW(sb);
+ if (lateModifiers->knot) {
+ *sb->current++ = '~';
+ } else {
+ *sb->current++ = ' ';
+ }
+ strcpy(sb->current, XKeysymToString(lateModifiers->keysym));
+ sb->current += strlen(sb->current);
+ if (lateModifiers->pair) {
+ *(sb->current -= 2) = '\0'; /* strip "_L" */
+ lateModifiers++; /* skip _R keysym */
+ }
+ }
+}
+
+static void PrintEvent(
+ TMStringBuf sb,
+ register TMTypeMatch typeMatch,
+ register TMModifierMatch modMatch,
+ Display *dpy)
+{
+ if (modMatch->standard) *sb->current++ = ':';
+
+ PrintModifiers(sb, modMatch->modifierMask, modMatch->modifiers);
+ if (modMatch->lateModifiers != NULL)
+ PrintLateModifiers(sb, modMatch->lateModifiers);
+ PrintEventType(sb, typeMatch->eventType);
+ switch (typeMatch->eventType) {
+ case KeyPress:
+ case KeyRelease:
+ PrintKeysym(sb, (KeySym)typeMatch->eventCode);
+ break;
+
+ case PropertyNotify:
+ case SelectionClear:
+ case SelectionRequest:
+ case SelectionNotify:
+ case ClientMessage:
+ PrintAtom(sb, dpy, (Atom)typeMatch->eventCode);
+ break;
+
+ default:
+ PrintCode(sb, typeMatch->eventCodeMask, typeMatch->eventCode);
+ }
+}
+
+static void PrintParams(
+ TMStringBuf sb,
+ String *params,
+ Cardinal num_params)
+{
+ register Cardinal i;
+ for (i = 0; i<num_params; i++) {
+ ExpandToFit( sb, params[i] );
+ if (i != 0) {
+ *sb->current++ = ',';
+ *sb->current++ = ' ';
+ }
+ *sb->current++ = '"';
+ strcpy(sb->current, params[i]);
+ sb->current += strlen(sb->current);
+ *sb->current++ = '"';
+ }
+ *sb->current = '\0';
+}
+
+static void PrintActions(
+ TMStringBuf sb,
+ register ActionPtr actions,
+ XrmQuark *quarkTbl,
+ Widget accelWidget)
+{
+ while (actions != NULL) {
+ String proc;
+
+ *sb->current++ = ' ';
+
+ if (accelWidget) {
+ /* accelerator */
+ String name = XtName(accelWidget);
+ int nameLen = strlen(name);
+ ExpandForChars(sb, nameLen );
+ XtMemmove(sb->current, name, nameLen );
+ sb->current += nameLen;
+ *sb->current++ = '`';
+ }
+ proc = XrmQuarkToString(quarkTbl[actions->idx]);
+ ExpandToFit( sb, proc );
+ strcpy(sb->current, proc);
+ sb->current += strlen(proc);
+ *sb->current++ = '(';
+ PrintParams(sb, actions->params, actions->num_params);
+ *sb->current++ = ')';
+ actions = actions->next;
+ }
+ *sb->current = '\0';
+}
+
+static Boolean LookAheadForCycleOrMulticlick(
+ register StatePtr state,
+ StatePtr *state_return, /* state to print, usually startState */
+ int *countP,
+ StatePtr *nextLevelP)
+{
+ int repeatCount = 0;
+ StatePtr startState = state;
+ Boolean isCycle = startState->isCycleEnd;
+ TMTypeMatch sTypeMatch;
+ TMModifierMatch sModMatch;
+
+ LOCK_PROCESS;
+ sTypeMatch = TMGetTypeMatch(startState->typeIndex);
+ sModMatch = TMGetModifierMatch(startState->modIndex);
+
+ *state_return = startState;
+
+ for (state = state->nextLevel; state != NULL; state = state->nextLevel) {
+ TMTypeMatch typeMatch = TMGetTypeMatch(state->typeIndex);
+ TMModifierMatch modMatch = TMGetModifierMatch(state->modIndex);
+
+ /* try to pick up the correct state with actions, to be printed */
+ /* This is to accommodate <ButtonUp>(2+), for example */
+ if (state->isCycleStart)
+ *state_return = state;
+
+ if (state->isCycleEnd) {
+ *countP = repeatCount;
+ UNLOCK_PROCESS;
+ return True;
+ }
+ if ((startState->typeIndex == state->typeIndex) &&
+ (startState->modIndex == state->modIndex)) {
+ repeatCount++;
+ *nextLevelP = state;
+ }
+ else if (typeMatch->eventType == _XtEventTimerEventType)
+ continue;
+ else /* not same event as starting event and not timer */ {
+ unsigned int type = sTypeMatch->eventType;
+ unsigned int t = typeMatch->eventType;
+ if ( (type == ButtonPress && t != ButtonRelease)
+ || (type == ButtonRelease && t != ButtonPress)
+ || (type == KeyPress && t != KeyRelease)
+ || (type == KeyRelease && t != KeyPress)
+ || typeMatch->eventCode != sTypeMatch->eventCode
+ || modMatch->modifiers != sModMatch->modifiers
+ || modMatch->modifierMask != sModMatch->modifierMask
+ || modMatch->lateModifiers != sModMatch->lateModifiers
+ || typeMatch->eventCodeMask != sTypeMatch->eventCodeMask
+ || typeMatch->matchEvent != sTypeMatch->matchEvent
+ || modMatch->standard != sModMatch->standard)
+ /* not inverse of starting event, either */
+ break;
+ }
+ }
+ *countP = repeatCount;
+ UNLOCK_PROCESS;
+ return isCycle;
+}
+
+static void PrintComplexState(
+ TMStringBuf sb,
+ Boolean includeRHS,
+ StatePtr state,
+ TMStateTree stateTree,
+ Widget accelWidget,
+ Display *dpy)
+{
+ int clickCount = 0;
+ Boolean cycle;
+ StatePtr nextLevel = NULL;
+ StatePtr triggerState = NULL;
+
+ /* print the current state */
+ if (! state) return;
+ LOCK_PROCESS;
+ cycle = LookAheadForCycleOrMulticlick(state, &triggerState, &clickCount,
+ &nextLevel);
+
+ PrintEvent(sb, TMGetTypeMatch(triggerState->typeIndex),
+ TMGetModifierMatch(triggerState->modIndex), dpy);
+
+ if (cycle || clickCount) {
+ if (clickCount)
+ sprintf(sb->current, "(%d%s)", clickCount+1, cycle ? "+" : "");
+ else
+ (void) strncpy(sb->current, "(+)", 4);
+ sb->current += strlen(sb->current);
+ if (! state->actions && nextLevel)
+ state = nextLevel;
+ while (! state->actions && ! state->isCycleEnd)
+ state = state->nextLevel; /* should be trigger state */
+ }
+
+ if (state->actions) {
+ if (includeRHS) {
+ CHECK_STR_OVERFLOW(sb);
+ *sb->current++ = ':';
+ PrintActions(sb,
+ state->actions,
+ ((TMSimpleStateTree)stateTree)->quarkTbl,
+ accelWidget);
+ *sb->current++ = '\n';
+ }
+ }
+ else {
+ if (state->nextLevel && !cycle && !clickCount)
+ *sb->current++ = ',';
+ else {
+ /* no actions are attached to this production */
+ *sb->current++ = ':';
+ *sb->current++ = '\n';
+ }
+ }
+ *sb->current = '\0';
+
+ /* print succeeding states */
+ if (state->nextLevel && !cycle && !clickCount)
+ PrintComplexState(sb, includeRHS, state->nextLevel,
+ stateTree, accelWidget, dpy);
+ UNLOCK_PROCESS;
+}
+
+typedef struct{
+ TMShortCard tIndex;
+ TMShortCard bIndex;
+}PrintRec, *Print;
+
+static int FindNextMatch(
+ PrintRec *printData,
+ TMShortCard numPrints,
+ XtTranslations xlations,
+ TMBranchHead branchHead,
+ StatePtr nextLevel,
+ TMShortCard startIndex)
+{
+ TMShortCard i;
+ TMComplexStateTree stateTree;
+ StatePtr currState, candState;
+ Boolean noMatch = True;
+ TMBranchHead prBranchHead;
+
+ for (i = startIndex; noMatch && i < numPrints; i++) {
+ stateTree = (TMComplexStateTree)
+ xlations->stateTreeTbl[printData[i].tIndex];
+ prBranchHead =
+ &(stateTree->branchHeadTbl[printData[i].bIndex]);
+
+ if ((prBranchHead->typeIndex == branchHead->typeIndex) &&
+ (prBranchHead->modIndex == branchHead->modIndex)) {
+ if (prBranchHead->isSimple) {
+ if (!nextLevel)
+ return i;
+ }
+ else {
+ currState = TMComplexBranchHead(stateTree, prBranchHead);
+ currState = currState->nextLevel;
+ candState = nextLevel;
+ for (;
+ ((currState && !currState->isCycleEnd) &&
+ (candState && !candState->isCycleEnd));
+ currState = currState->nextLevel,
+ candState = candState->nextLevel) {
+ if ((currState->typeIndex != candState->typeIndex) ||
+ (currState->modIndex != candState->modIndex))
+ break;
+ }
+ if (candState == currState) {
+ return i;
+ }
+ }
+ }
+ }
+ return TM_NO_MATCH;
+}
+
+static void ProcessLaterMatches(
+ PrintRec *printData,
+ XtTranslations xlations,
+ TMShortCard tIndex,
+ int bIndex,
+ TMShortCard *numPrintsRtn)
+{
+ TMComplexStateTree stateTree;
+ int i, j;
+ TMBranchHead branchHead, matchBranch = NULL;
+
+ for (i = tIndex; i < (int)xlations->numStateTrees; i++) {
+ stateTree = (TMComplexStateTree)xlations->stateTreeTbl[i];
+ if (i == tIndex) {
+ matchBranch = &stateTree->branchHeadTbl[bIndex];
+ j = bIndex+1;
+ }
+ else j = 0;
+ for (branchHead = &stateTree->branchHeadTbl[j];
+ j < (int)stateTree->numBranchHeads;
+ j++, branchHead++) {
+ if ((branchHead->typeIndex == matchBranch->typeIndex) &&
+ (branchHead->modIndex == matchBranch->modIndex)) {
+ StatePtr state;
+ if (!branchHead->isSimple)
+ state = TMComplexBranchHead(stateTree, branchHead);
+ else
+ state = NULL;
+ if ((!branchHead->isSimple || branchHead->hasActions) &&
+ (FindNextMatch(printData,
+ *numPrintsRtn,
+ xlations,
+ branchHead,
+ (state ? state->nextLevel : NULL),
+ 0) == TM_NO_MATCH)) {
+ printData[*numPrintsRtn].tIndex = i;
+ printData[*numPrintsRtn].bIndex = j;
+ (*numPrintsRtn)++;
+ }
+ }
+ }
+ }
+}
+
+static void ProcessStateTree(
+ PrintRec *printData,
+ XtTranslations xlations,
+ TMShortCard tIndex,
+ TMShortCard *numPrintsRtn)
+{
+ TMComplexStateTree stateTree;
+ int i;
+ TMBranchHead branchHead;
+
+ stateTree = (TMComplexStateTree)xlations->stateTreeTbl[tIndex];
+
+ for (i = 0, branchHead = stateTree->branchHeadTbl;
+ i < (int)stateTree->numBranchHeads;
+ i++, branchHead++) {
+ StatePtr state;
+ if (!branchHead->isSimple)
+ state = TMComplexBranchHead(stateTree, branchHead);
+ else
+ state = NULL;
+ if (FindNextMatch(printData, *numPrintsRtn, xlations, branchHead,
+ (state ? state->nextLevel : NULL), 0)
+ == TM_NO_MATCH) {
+ if (!branchHead->isSimple || branchHead->hasActions) {
+ printData[*numPrintsRtn].tIndex = tIndex;
+ printData[*numPrintsRtn].bIndex = i;
+ (*numPrintsRtn)++;
+ }
+ LOCK_PROCESS;
+ if (_XtGlobalTM.newMatchSemantics == False)
+ ProcessLaterMatches(printData,
+ xlations,
+ tIndex,
+ i,
+ numPrintsRtn);
+ UNLOCK_PROCESS;
+ }
+ }
+}
+
+static void PrintState(
+ TMStringBuf sb,
+ TMStateTree tree,
+ TMBranchHead branchHead,
+ Boolean includeRHS,
+ Widget accelWidget,
+ Display *dpy)
+{
+ TMComplexStateTree stateTree = (TMComplexStateTree)tree;
+ LOCK_PROCESS;
+ if (branchHead->isSimple) {
+ PrintEvent(sb,
+ TMGetTypeMatch(branchHead->typeIndex),
+ TMGetModifierMatch(branchHead->modIndex),
+ dpy);
+ if (includeRHS) {
+ ActionRec actRec;
+
+ CHECK_STR_OVERFLOW(sb);
+ *sb->current++ = ':';
+ actRec.idx = TMBranchMore(branchHead);
+ actRec.num_params = 0;
+ actRec.params = NULL;
+ actRec.next = NULL;
+ PrintActions(sb,
+ &actRec,
+ stateTree->quarkTbl,
+ accelWidget);
+ *sb->current++ = '\n';
+ }
+ else
+ *sb->current++ = ',';
+#ifdef TRACE_TM
+ if (!branchHead->hasActions)
+ printf(" !! no actions !! ");
+#endif
+ }
+ else { /* it's a complex branchHead */
+ StatePtr state = TMComplexBranchHead(stateTree, branchHead);
+ PrintComplexState(sb,
+ includeRHS,
+ state,
+ tree,
+ accelWidget,
+ (Display *)NULL);
+ }
+ *sb->current = '\0';
+ UNLOCK_PROCESS;
+}
+
+String _XtPrintXlations(
+ Widget w,
+ XtTranslations xlations,
+ Widget accelWidget,
+ _XtBoolean includeRHS)
+{
+ register Cardinal i;
+#define STACKPRINTSIZE 250
+ PrintRec stackPrints[STACKPRINTSIZE];
+ PrintRec *prints;
+ TMStringBufRec sbRec, *sb = &sbRec;
+ TMShortCard numPrints, maxPrints;
+#ifdef TRACE_TM
+ TMBindData bindData = (TMBindData)w->core.tm.proc_table;
+ Boolean hasAccel = (accelWidget ? True : False);
+#endif /* TRACE_TM */
+ if (xlations == NULL) return NULL;
+
+ sb->current = sb->start = __XtMalloc((Cardinal)1000);
+ sb->max = 1000;
+ maxPrints = 0;
+ for (i = 0; i < xlations->numStateTrees; i++)
+ maxPrints +=
+ ((TMSimpleStateTree)(xlations->stateTreeTbl[i]))->numBranchHeads;
+ prints = (PrintRec *)
+ XtStackAlloc(maxPrints * sizeof(PrintRec), stackPrints);
+
+ numPrints = 0;
+ for (i = 0; i < xlations->numStateTrees; i++)
+ ProcessStateTree(prints, xlations, i, &numPrints);
+
+ for (i = 0; i < numPrints; i++) {
+ TMSimpleStateTree stateTree = (TMSimpleStateTree)
+ xlations->stateTreeTbl[prints[i].tIndex];
+ TMBranchHead branchHead =
+ &stateTree->branchHeadTbl[prints[i].bIndex];
+#ifdef TRACE_TM
+ TMComplexBindProcs complexBindProcs;
+
+ if (hasAccel == False) {
+ accelWidget = NULL;
+ if (bindData->simple.isComplex) {
+ complexBindProcs = TMGetComplexBindEntry(bindData, 0);
+ accelWidget = complexBindProcs[prints[i].tIndex].widget;
+ }
+ }
+#endif /* TRACE_TM */
+ PrintState(sb, (TMStateTree)stateTree, branchHead,
+ includeRHS, accelWidget, XtDisplay(w));
+ }
+ XtStackFree((XtPointer)prints, (XtPointer)stackPrints);
+ return (sb->start);
+}
+
+
+#ifndef NO_MIT_HACKS
+/*ARGSUSED*/
+void _XtDisplayTranslations(
+ Widget widget,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
+{
+ String xString;
+
+ xString = _XtPrintXlations(widget,
+ widget->core.tm.translations,
+ NULL,
+ True);
+ printf("%s\n",xString);
+ XtFree(xString);
+}
+
+/*ARGSUSED*/
+void _XtDisplayAccelerators(
+ Widget widget,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
+{
+ String xString;
+
+
+ xString = _XtPrintXlations(widget,
+ widget->core.accelerators,
+ NULL,
+ True);
+ printf("%s\n",xString);
+ XtFree(xString);
+}
+
+/*ARGSUSED*/
+void _XtDisplayInstalledAccelerators(
+ Widget widget,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
+{
+ Widget eventWidget
+ = XtWindowToWidget(event->xany.display, event->xany.window);
+ register Cardinal i;
+ TMStringBufRec sbRec, *sb = &sbRec;
+ XtTranslations xlations;
+#define STACKPRINTSIZE 250
+ PrintRec stackPrints[STACKPRINTSIZE];
+ PrintRec *prints;
+ TMShortCard numPrints, maxPrints;
+ TMBindData bindData = (TMBindData) eventWidget->core.tm.proc_table;
+ TMComplexBindProcs complexBindProcs;
+
+ if ((eventWidget == NULL) ||
+ ((xlations = eventWidget->core.tm.translations) == NULL) ||
+ (bindData->simple.isComplex == False))
+ return;
+
+ sb->current = sb->start = __XtMalloc((Cardinal)1000);
+ sb->start[0] = '\0';
+ sb->max = 1000;
+ maxPrints = 0;
+ for (i = 0; i < xlations->numStateTrees; i++)
+ maxPrints +=
+ ((TMSimpleStateTree)xlations->stateTreeTbl[i])->numBranchHeads;
+ prints = (PrintRec *)
+ XtStackAlloc(maxPrints * sizeof(PrintRec), stackPrints);
+
+ numPrints = 0;
+
+ complexBindProcs = TMGetComplexBindEntry(bindData, 0);
+ for (i = 0;
+ i < xlations->numStateTrees;
+ i++, complexBindProcs++) {
+ if (complexBindProcs->widget)
+ {
+ ProcessStateTree(prints, xlations, i, &numPrints);
+ }
+ }
+ for (i = 0; i < numPrints; i++) {
+ TMSimpleStateTree stateTree = (TMSimpleStateTree)
+ xlations->stateTreeTbl[prints[i].tIndex];
+ TMBranchHead branchHead =
+ &stateTree->branchHeadTbl[prints[i].bIndex];
+
+ complexBindProcs = TMGetComplexBindEntry(bindData, 0);
+
+ PrintState(sb, (TMStateTree)stateTree, branchHead, True,
+ complexBindProcs[prints[i].tIndex].widget,
+ XtDisplay(widget));
+ }
+ XtStackFree((XtPointer)prints, (XtPointer)stackPrints);
+ printf("%s\n", sb->start);
+ XtFree(sb->start);
+}
+#endif /*NO_MIT_HACKS*/
+
+String _XtPrintActions(
+ register ActionRec *actions,
+ XrmQuark *quarkTbl)
+{
+ TMStringBufRec sbRec, *sb = &sbRec;
+
+ sb->max = 1000;
+ sb->current = sb->start = __XtMalloc((Cardinal)1000);
+ PrintActions(sb,
+ actions,
+ quarkTbl,
+ (Widget)NULL);
+ return sb->start;
+}
+
+String _XtPrintState(
+ TMStateTree stateTree,
+ TMBranchHead branchHead)
+{
+ TMStringBufRec sbRec, *sb = &sbRec;
+
+ sb->current = sb->start = __XtMalloc((Cardinal)1000);
+ sb->max = 1000;
+ PrintState(sb, stateTree, branchHead,
+ True, (Widget)NULL, (Display *)NULL);
+ return sb->start;
+}
+
+
+String _XtPrintEventSeq(
+ register EventSeqPtr eventSeq,
+ Display *dpy)
+{
+ TMStringBufRec sbRec, *sb = &sbRec;
+ TMTypeMatch typeMatch;
+ TMModifierMatch modMatch;
+#define MAXSEQS 100
+ EventSeqPtr eventSeqs[MAXSEQS];
+ TMShortCard i, j;
+ Boolean cycle = False;
+
+ sb->current = sb->start = __XtMalloc((Cardinal)1000);
+ sb->max = 1000;
+ for (i = 0;
+ i < MAXSEQS && eventSeq != NULL && !cycle;
+ eventSeq = eventSeq->next, i++)
+ {
+ eventSeqs[i] = eventSeq;
+ for (j = 0; j < i && !cycle; j++)
+ if (eventSeqs[j] == eventSeq)
+ cycle = True;
+ }
+ LOCK_PROCESS;
+ for (j = 0; j < i; j++) {
+ typeMatch =
+ TMGetTypeMatch(_XtGetTypeIndex(&eventSeqs[j]->event));
+ modMatch =
+ TMGetModifierMatch(_XtGetModifierIndex(&eventSeqs[j]->event));
+ PrintEvent(sb, typeMatch, modMatch, dpy);
+ if (j < i)
+ *sb->current++ = ',';
+ }
+ UNLOCK_PROCESS;
+ return sb->start;
+}
diff --git a/nx-X11/lib/Xt/TMstate.c b/nx-X11/lib/Xt/TMstate.c
new file mode 100644
index 000000000..604947496
--- /dev/null
+++ b/nx-X11/lib/Xt/TMstate.c
@@ -0,0 +1,2349 @@
+/* $Xorg: TMstate.c,v 1.6 2001/02/09 02:03:58 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 names of Digital or Sun 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.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/TMstate.c,v 1.8 2001/12/14 19:56:31 dawes Exp $ */
+
+/*
+
+Copyright 1987, 1988, 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.
+
+*/
+
+/* TMstate.c -- maintains the state table of actions for the translation
+ * manager.
+ */
+/*LINTLIBRARY*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+
+#ifndef TM_NO_MATCH
+#define TM_NO_MATCH (-2)
+#endif /* TM_NO_MATCH */
+
+/* forward definitions */
+static StatePtr NewState(TMParseStateTree, TMShortCard, TMShortCard);
+
+
+static String XtNtranslationError = "translationError";
+
+#ifndef __EMX__
+TMGlobalRec _XtGlobalTM; /* initialized to zero K&R */
+#else
+TMGlobalRec _XtGlobalTM = {0};
+#endif
+
+#define MatchIncomingEvent(tmEvent, typeMatch, modMatch) \
+ (typeMatch->eventType == tmEvent->event.eventType && \
+ (typeMatch->matchEvent != NULL) && \
+ (*typeMatch->matchEvent)(typeMatch, modMatch, tmEvent))
+
+
+#define NumStateTrees(xlations) \
+ ((translateData->isSimple) ? 1 : (TMComplexXlations(xlations))->numTrees)
+
+static TMShortCard GetBranchHead(
+ TMParseStateTree parseTree,
+ TMShortCard typeIndex,
+ TMShortCard modIndex,
+ Boolean isDummy)
+{
+#define TM_BRANCH_HEAD_TBL_ALLOC 8
+#define TM_BRANCH_HEAD_TBL_REALLOC 8
+
+ TMBranchHead branchHead = parseTree->branchHeadTbl;
+ TMShortCard newSize, i;
+
+ /*
+ * dummy is used as a place holder for later matching in old-style
+ * matching behavior. If there's already an entry we don't need
+ * another dummy.
+ */
+ if (isDummy) {
+ for (i = 0; i < parseTree->numBranchHeads; i++, branchHead++) {
+ if ((branchHead->typeIndex == typeIndex) &&
+ (branchHead->modIndex == modIndex))
+ return i;
+ }
+ }
+ if (parseTree->numBranchHeads == parseTree->branchHeadTblSize)
+ {
+ if (parseTree->branchHeadTblSize == 0)
+ parseTree->branchHeadTblSize += TM_BRANCH_HEAD_TBL_ALLOC;
+ else
+ parseTree->branchHeadTblSize +=
+ TM_BRANCH_HEAD_TBL_REALLOC;
+ newSize = (parseTree->branchHeadTblSize * sizeof(TMBranchHeadRec));
+ if (parseTree->isStackBranchHeads) {
+ TMBranchHead oldBranchHeadTbl = parseTree->branchHeadTbl;
+ parseTree->branchHeadTbl = (TMBranchHead) __XtMalloc(newSize);
+ XtMemmove(parseTree->branchHeadTbl, oldBranchHeadTbl, newSize);
+ parseTree->isStackBranchHeads = False;
+ }
+ else {
+ parseTree->branchHeadTbl = (TMBranchHead)
+ XtRealloc((char *)parseTree->branchHeadTbl,
+ (parseTree->branchHeadTblSize *
+ sizeof(TMBranchHeadRec)));
+ }
+ }
+#ifdef TRACE_TM
+ LOCK_PROCESS;
+ _XtGlobalTM.numBranchHeads++;
+ UNLOCK_PROCESS;
+#endif /* TRACE_TM */
+ branchHead =
+ &parseTree->branchHeadTbl[parseTree->numBranchHeads++];
+ branchHead->typeIndex = typeIndex;
+ branchHead->modIndex = modIndex;
+ branchHead->more = 0;
+ branchHead->isSimple = True;
+ branchHead->hasActions = False;
+ branchHead->hasCycles = False;
+ return parseTree->numBranchHeads-1;
+}
+
+TMShortCard _XtGetQuarkIndex(
+ TMParseStateTree parseTree,
+ XrmQuark quark)
+{
+#define TM_QUARK_TBL_ALLOC 16
+#define TM_QUARK_TBL_REALLOC 16
+ TMShortCard i = parseTree->numQuarks;
+
+ for (i=0; i < parseTree->numQuarks; i++)
+ if (parseTree->quarkTbl[i] == quark)
+ break;
+
+ if (i == parseTree->numQuarks)
+ {
+ if (parseTree->numQuarks == parseTree->quarkTblSize)
+ {
+ TMShortCard newSize;
+
+ if (parseTree->quarkTblSize == 0)
+ parseTree->quarkTblSize += TM_QUARK_TBL_ALLOC;
+ else
+ parseTree->quarkTblSize += TM_QUARK_TBL_REALLOC;
+ newSize = (parseTree->quarkTblSize * sizeof(XrmQuark));
+
+ if (parseTree->isStackQuarks) {
+ XrmQuark *oldquarkTbl = parseTree->quarkTbl;
+ parseTree->quarkTbl = (XrmQuark *) __XtMalloc(newSize);
+ XtMemmove(parseTree->quarkTbl, oldquarkTbl, newSize);
+ parseTree->isStackQuarks = False;
+ }
+ else {
+ parseTree->quarkTbl = (XrmQuark *)
+ XtRealloc((char *)parseTree->quarkTbl,
+ (parseTree->quarkTblSize *
+ sizeof(XrmQuark)));
+ }
+ }
+ parseTree->quarkTbl[parseTree->numQuarks++] = quark;
+ }
+ return i;
+}
+
+/*
+ * Get an entry from the parseTrees complex branchHead tbl. If there's none
+ * there then allocate one
+ */
+/*ARGSUSED*/
+static TMShortCard GetComplexBranchIndex(
+ TMParseStateTree parseTree,
+ TMShortCard typeIndex,
+ TMShortCard modIndex)
+{
+#define TM_COMPLEXBRANCH_HEAD_TBL_ALLOC 8
+#define TM_COMPLEXBRANCH_HEAD_TBL_REALLOC 4
+
+ if (parseTree->numComplexBranchHeads == parseTree->complexBranchHeadTblSize) {
+ TMShortCard newSize;
+
+ if (parseTree->complexBranchHeadTblSize == 0)
+ parseTree->complexBranchHeadTblSize += TM_COMPLEXBRANCH_HEAD_TBL_ALLOC;
+ else
+ parseTree->complexBranchHeadTblSize += TM_COMPLEXBRANCH_HEAD_TBL_REALLOC;
+
+ newSize = (parseTree->complexBranchHeadTblSize * sizeof(StatePtr));
+
+ if (parseTree->isStackComplexBranchHeads) {
+ StatePtr *oldcomplexBranchHeadTbl
+ = parseTree->complexBranchHeadTbl;
+ parseTree->complexBranchHeadTbl = (StatePtr *) __XtMalloc(newSize);
+ XtMemmove(parseTree->complexBranchHeadTbl,
+ oldcomplexBranchHeadTbl, newSize);
+ parseTree->isStackComplexBranchHeads = False;
+ }
+ else {
+ parseTree->complexBranchHeadTbl = (StatePtr *)
+ XtRealloc((char *)parseTree->complexBranchHeadTbl,
+ (parseTree->complexBranchHeadTblSize *
+ sizeof(StatePtr)));
+ }
+ }
+ parseTree->complexBranchHeadTbl[parseTree->numComplexBranchHeads++] = NULL;
+ return parseTree->numComplexBranchHeads-1;
+}
+
+TMShortCard _XtGetTypeIndex(
+ Event *event)
+{
+ TMShortCard i, j = TM_TYPE_SEGMENT_SIZE;
+ TMShortCard typeIndex = 0;
+ TMTypeMatch typeMatch;
+ TMTypeMatch segment = NULL;
+
+ LOCK_PROCESS;
+ for (i = 0; i < _XtGlobalTM.numTypeMatchSegments; i++) {
+ segment = _XtGlobalTM.typeMatchSegmentTbl[i];
+ for (j = 0;
+ typeIndex < _XtGlobalTM.numTypeMatches && j < TM_TYPE_SEGMENT_SIZE;
+ j++, typeIndex++)
+ {
+ typeMatch = &(segment[j]);
+ if (event->eventType == typeMatch->eventType &&
+ event->eventCode == typeMatch->eventCode &&
+ event->eventCodeMask == typeMatch->eventCodeMask &&
+ event->matchEvent == typeMatch->matchEvent) {
+ UNLOCK_PROCESS;
+ return typeIndex;
+ }
+ }
+ }
+
+ if (j == TM_TYPE_SEGMENT_SIZE) {
+ if (_XtGlobalTM.numTypeMatchSegments == _XtGlobalTM.typeMatchSegmentTblSize) {
+ _XtGlobalTM.typeMatchSegmentTblSize += 4;
+ _XtGlobalTM.typeMatchSegmentTbl = (TMTypeMatch *)
+ XtRealloc((char *)_XtGlobalTM.typeMatchSegmentTbl,
+ (_XtGlobalTM.typeMatchSegmentTblSize * sizeof(TMTypeMatch)));
+ }
+ _XtGlobalTM.typeMatchSegmentTbl[_XtGlobalTM.numTypeMatchSegments++] =
+ segment = (TMTypeMatch)
+ __XtMalloc(TM_TYPE_SEGMENT_SIZE * sizeof(TMTypeMatchRec));
+ j = 0;
+ }
+ typeMatch = &segment[j];
+ typeMatch->eventType = event->eventType;
+ typeMatch->eventCode = event->eventCode;
+ typeMatch->eventCodeMask = event->eventCodeMask;
+ typeMatch->matchEvent = event->matchEvent;
+ _XtGlobalTM.numTypeMatches++;
+ UNLOCK_PROCESS;
+ return typeIndex;
+}
+
+static Boolean CompareLateModifiers(
+ LateBindingsPtr lateBind1P,
+ LateBindingsPtr lateBind2P)
+{
+ LateBindingsPtr late1P = lateBind1P;
+ LateBindingsPtr late2P = lateBind2P;
+
+ if (late1P != NULL || late2P != NULL) {
+ int i = 0;
+ int j = 0;
+ if (late1P != NULL)
+ for (; late1P->keysym != NoSymbol; i++) late1P++;
+ if (late2P != NULL)
+ for (; late2P->keysym != NoSymbol; j++) late2P++;
+ if (i != j) return FALSE;
+ late1P--;
+ while (late1P >= lateBind1P) {
+ Boolean last = True;
+ for (late2P = lateBind2P + i - 1;
+ late2P >= lateBind2P;
+ late2P--) {
+ if (late1P->keysym == late2P->keysym
+ && late1P->knot == late2P->knot) {
+ j--;
+ if (last) i--;
+ break;
+ }
+ last = False;
+ }
+ late1P--;
+ }
+ if (j != 0) return FALSE;
+ }
+ return TRUE;
+}
+
+TMShortCard _XtGetModifierIndex(
+ Event *event)
+{
+ TMShortCard i, j = TM_MOD_SEGMENT_SIZE;
+ TMShortCard modIndex = 0;
+ TMModifierMatch modMatch;
+ TMModifierMatch segment = NULL;
+
+ LOCK_PROCESS;
+ for (i = 0; i < _XtGlobalTM.numModMatchSegments; i++) {
+ segment = _XtGlobalTM.modMatchSegmentTbl[i];
+ for (j = 0;
+ modIndex < _XtGlobalTM.numModMatches && j < TM_MOD_SEGMENT_SIZE;
+ j++, modIndex++) {
+ modMatch = &(segment[j]);
+ if (event->modifiers == modMatch->modifiers &&
+ event->modifierMask == modMatch->modifierMask &&
+ event->standard == modMatch->standard &&
+ ((!event->lateModifiers && !modMatch->lateModifiers) ||
+ CompareLateModifiers(event->lateModifiers,
+ modMatch->lateModifiers))) {
+ /*
+ * if we found a match then we can free the parser's
+ * late modifiers. If there isn't a match we use the
+ * parser's copy
+ */
+ if (event->lateModifiers &&
+ --event->lateModifiers->ref_count == 0) {
+ XtFree((char *)event->lateModifiers);
+ event->lateModifiers = NULL;
+ }
+ UNLOCK_PROCESS;
+ return modIndex;
+ }
+ }
+ }
+
+ if (j == TM_MOD_SEGMENT_SIZE) {
+ if (_XtGlobalTM.numModMatchSegments == _XtGlobalTM.modMatchSegmentTblSize) {
+ _XtGlobalTM.modMatchSegmentTblSize += 4;
+ _XtGlobalTM.modMatchSegmentTbl = (TMModifierMatch *)
+ XtRealloc((char *)_XtGlobalTM.modMatchSegmentTbl,
+ (_XtGlobalTM.modMatchSegmentTblSize * sizeof(TMModifierMatch)));
+ }
+ _XtGlobalTM.modMatchSegmentTbl[_XtGlobalTM.numModMatchSegments++] =
+ segment = (TMModifierMatch)
+ __XtMalloc(TM_MOD_SEGMENT_SIZE * sizeof(TMModifierMatchRec));
+ j = 0;
+ }
+ modMatch = &segment[j];
+ modMatch->modifiers = event->modifiers;;
+ modMatch->modifierMask = event->modifierMask;
+ modMatch->standard = event->standard;
+ /*
+ * We use the parser's copy of the late binding array
+ */
+#ifdef TRACE_TM
+ if (event->lateModifiers)
+ _XtGlobalTM.numLateBindings++;
+#endif /* TRACE_TM */
+ modMatch->lateModifiers = event->lateModifiers;
+ _XtGlobalTM.numModMatches++;
+ UNLOCK_PROCESS;
+ return modIndex;
+}
+
+
+/*
+ * This is called from the SimpleStateHandler to match a stateTree
+ * entry to the event coming in
+ */
+static int MatchBranchHead(
+ TMSimpleStateTree stateTree,
+ int startIndex,
+ TMEventPtr event)
+{
+ TMBranchHead branchHead = &stateTree->branchHeadTbl[startIndex];
+ int i;
+
+ LOCK_PROCESS;
+ for (i = startIndex;
+ i < (int)stateTree->numBranchHeads;
+ i++, branchHead++)
+ {
+ TMTypeMatch typeMatch;
+ TMModifierMatch modMatch;
+
+ typeMatch = TMGetTypeMatch(branchHead->typeIndex);
+ modMatch = TMGetModifierMatch(branchHead->modIndex);
+
+ if (MatchIncomingEvent(event, typeMatch, modMatch)) {
+ UNLOCK_PROCESS;
+ return i;
+ }
+ }
+ UNLOCK_PROCESS;
+ return (TM_NO_MATCH);
+}
+
+Boolean _XtRegularMatch(
+ TMTypeMatch typeMatch,
+ TMModifierMatch modMatch,
+ TMEventPtr eventSeq)
+{
+ Modifiers computed =0;
+ Modifiers computedMask =0;
+ Boolean resolved = TRUE;
+ if (typeMatch->eventCode != (eventSeq->event.eventCode &
+ typeMatch->eventCodeMask)) return FALSE;
+ if (modMatch->lateModifiers != NULL)
+ resolved = _XtComputeLateBindings(eventSeq->xev->xany.display,
+ modMatch->lateModifiers,
+ &computed, &computedMask);
+ if (!resolved) return FALSE;
+ computed |= modMatch->modifiers;
+ computedMask |= modMatch->modifierMask;
+
+ return ( (computed & computedMask) ==
+ (eventSeq->event.modifiers & computedMask));
+}
+
+/*ARGSUSED*/
+Boolean _XtMatchAtom(
+ TMTypeMatch typeMatch,
+ TMModifierMatch modMatch,
+ TMEventPtr eventSeq)
+{
+ Atom atom;
+
+ atom = XInternAtom(eventSeq->xev->xany.display,
+ XrmQuarkToString(typeMatch->eventCode),
+ False);
+ return (atom == eventSeq->event.eventCode);
+}
+
+#define IsOn(vec,idx) ((vec)[(idx)>>3] & (1 << ((idx) & 7)))
+
+/*
+ * there are certain cases where you want to ignore the event and stay
+ * in the same state.
+ */
+static Boolean Ignore(
+ TMEventPtr event)
+{
+ Display *dpy;
+ XtPerDisplay pd;
+
+ if (event->event.eventType == MotionNotify)
+ return TRUE;
+ if (!(event->event.eventType == KeyPress ||
+ event->event.eventType == KeyRelease))
+ return FALSE;
+ dpy = event->xev->xany.display;
+ pd = _XtGetPerDisplay(dpy);
+ _InitializeKeysymTables(dpy, pd);
+ return IsOn(pd->isModifier, event->event.eventCode) ? TRUE : FALSE;
+}
+
+
+static void XEventToTMEvent(
+ XEvent *event,
+ TMEventPtr tmEvent)
+{
+ tmEvent->xev = event;
+ tmEvent->event.eventCodeMask = 0;
+ tmEvent->event.modifierMask = 0;
+ tmEvent->event.eventType = event->type;
+ tmEvent->event.lateModifiers = NULL;
+ tmEvent->event.matchEvent = NULL;
+ tmEvent->event.standard = FALSE;
+
+ switch (event->type) {
+
+ case KeyPress:
+ case KeyRelease:
+ tmEvent->event.eventCode = event->xkey.keycode;
+ tmEvent->event.modifiers = event->xkey.state;
+ break;
+
+ case ButtonPress:
+ case ButtonRelease:
+ tmEvent->event.eventCode = event->xbutton.button;
+ tmEvent->event.modifiers = event->xbutton.state;
+ break;
+
+ case MotionNotify:
+ tmEvent->event.eventCode = event->xmotion.is_hint;
+ tmEvent->event.modifiers = event->xmotion.state;
+ break;
+
+ case EnterNotify:
+ case LeaveNotify:
+ tmEvent->event.eventCode = event->xcrossing.mode;
+ tmEvent->event.modifiers = event->xcrossing.state;
+ break;
+
+ case PropertyNotify:
+ tmEvent->event.eventCode = event->xproperty.atom;
+ tmEvent->event.modifiers = 0;
+ break;
+
+ case SelectionClear:
+ tmEvent->event.eventCode = event->xselectionclear.selection;
+ tmEvent->event.modifiers = 0;
+ break;
+
+ case SelectionRequest:
+ tmEvent->event.eventCode = event->xselectionrequest.selection;
+ tmEvent->event.modifiers = 0;
+ break;
+
+ case SelectionNotify:
+ tmEvent->event.eventCode = event->xselection.selection;
+ tmEvent->event.modifiers = 0;
+ break;
+
+ case ClientMessage:
+ tmEvent->event.eventCode = event->xclient.message_type;
+ tmEvent->event.modifiers = 0;
+ break;
+
+ case MappingNotify:
+ tmEvent->event.eventCode = event->xmapping.request;
+ tmEvent->event.modifiers = 0;
+ break;
+
+ case FocusIn:
+ case FocusOut:
+ tmEvent->event.eventCode = event->xfocus.mode;
+ tmEvent->event.modifiers = 0;
+ break;
+
+ default:
+ tmEvent->event.eventCode = 0;
+ tmEvent->event.modifiers = 0;
+ break;
+ }
+}
+
+
+static unsigned long GetTime(
+ XtTM tm,
+ XEvent *event)
+{
+ switch (event->type) {
+
+ case KeyPress:
+ case KeyRelease:
+ return event->xkey.time;
+
+ case ButtonPress:
+ case ButtonRelease:
+ return event->xbutton.time;
+
+ default:
+ return tm->lastEventTime;
+
+ }
+
+}
+
+static void HandleActions(
+ Widget w,
+ XEvent *event,
+ TMSimpleStateTree stateTree,
+ Widget accelWidget,
+ XtActionProc *procs,
+ ActionRec *actions)
+{
+ ActionHook actionHookList;
+ Widget bindWidget;
+
+ bindWidget = accelWidget ? accelWidget : w;
+ if (accelWidget && !XtIsSensitive(accelWidget) &&
+ (event->type == KeyPress || event->type == KeyRelease ||
+ event->type == ButtonPress || event->type == ButtonRelease ||
+ event->type == MotionNotify || event->type == EnterNotify ||
+ event->type == LeaveNotify || event->type == FocusIn ||
+ event->type == FocusOut))
+ return;
+
+ actionHookList = XtWidgetToApplicationContext(w)->action_hook_list;
+
+ while (actions != NULL) {
+ /* perform any actions */
+ if (procs[actions->idx] != NULL) {
+ if (actionHookList) {
+ ActionHook hook;
+ ActionHook next_hook;
+ String procName =
+ XrmQuarkToString(stateTree->quarkTbl[actions->idx] );
+
+ for (hook = actionHookList; hook != NULL; ) {
+ /*
+ * Need to cache hook->next because the following action
+ * proc may free hook via XtRemoveActionHook making
+ * hook->next invalid upon return from the action proc.
+ */
+ next_hook = hook->next;
+ (*hook->proc)(bindWidget,
+ hook->closure,
+ procName,
+ event,
+ actions->params,
+ &actions->num_params
+ );
+ hook = next_hook;
+ }
+ }
+ (*(procs[actions->idx]))
+ (bindWidget, event,
+ actions->params, &actions->num_params );
+ }
+ actions = actions->next;
+ }
+}
+
+typedef struct {
+ unsigned int isCycleStart:1;
+ unsigned int isCycleEnd:1;
+ TMShortCard typeIndex;
+ TMShortCard modIndex;
+}MatchPairRec, *MatchPair;
+
+typedef struct TMContextRec{
+ TMShortCard numMatches;
+ TMShortCard maxMatches;
+ MatchPair matches;
+}TMContextRec, *TMContext;
+
+static TMContextRec contextCache[2];
+
+#define GetContextPtr(tm) ((TMContext *)&(tm->current_state))
+
+#define TM_CONTEXT_MATCHES_ALLOC 4
+#define TM_CONTEXT_MATCHES_REALLOC 2
+
+static void PushContext(
+ TMContext *contextPtr,
+ StatePtr newState)
+{
+ TMContext context = *contextPtr;
+
+ LOCK_PROCESS;
+ if (context == NULL)
+ {
+ if (contextCache[0].numMatches == 0)
+ context = &contextCache[0];
+ else if (contextCache[1].numMatches == 0)
+ context = &contextCache[1];
+ if (!context)
+ {
+ context = XtNew(TMContextRec);
+ context->matches = NULL;
+ context->numMatches =
+ context->maxMatches = 0;
+ }
+ }
+ if (context->numMatches &&
+ context->matches[context->numMatches-1].isCycleEnd)
+ {
+ TMShortCard i;
+ for (i = 0;
+ i < context->numMatches &&
+ !(context->matches[i].isCycleStart);
+ i++){};
+ if (i < context->numMatches)
+ context->numMatches = i+1;
+#ifdef DEBUG
+ else
+ XtWarning("pushing cycle end with no cycle start");
+#endif /* DEBUG */
+ }
+ else
+ {
+ if (context->numMatches == context->maxMatches)
+ {
+ if (context->maxMatches == 0)
+ context->maxMatches += TM_CONTEXT_MATCHES_ALLOC;
+ else
+ context->maxMatches += TM_CONTEXT_MATCHES_REALLOC;
+ context->matches = (MatchPairRec *)
+ XtRealloc((char *)context->matches,
+ context->maxMatches * sizeof(MatchPairRec));
+ }
+ context->matches[context->numMatches].isCycleStart = newState->isCycleStart;
+ context->matches[context->numMatches].isCycleEnd = newState->isCycleEnd;
+ context->matches[context->numMatches].typeIndex = newState->typeIndex;
+ context->matches[context->numMatches++].modIndex = newState->modIndex;
+ *contextPtr = context;
+ }
+ UNLOCK_PROCESS;
+}
+
+static void FreeContext(
+ TMContext *contextPtr)
+{
+ TMContext context = NULL;
+
+ LOCK_PROCESS;
+
+ if (&contextCache[0] == *contextPtr)
+ context = &contextCache[0];
+ else if (&contextCache[1] == *contextPtr)
+ context = &contextCache[1];
+
+ if (context)
+ context->numMatches = 0;
+ else if (*contextPtr)
+ {
+ if ((*contextPtr)->matches)
+ XtFree ((char *) ((*contextPtr)->matches));
+ XtFree((char *)*contextPtr);
+ }
+
+ *contextPtr = NULL;
+ UNLOCK_PROCESS;
+}
+
+static int MatchExact(
+ TMSimpleStateTree stateTree,
+ int startIndex,
+ TMShortCard typeIndex,
+ TMShortCard modIndex)
+{
+ TMBranchHead branchHead = &(stateTree->branchHeadTbl[startIndex]);
+ int i;
+
+ for (i = startIndex;
+ i < (int)stateTree->numBranchHeads;
+ i++, branchHead++)
+ {
+ if ((branchHead->typeIndex == typeIndex) &&
+ (branchHead->modIndex == modIndex))
+ return i;
+ }
+ return (TM_NO_MATCH);
+}
+
+
+
+static void HandleSimpleState(
+ Widget w,
+ XtTM tmRecPtr,
+ TMEventRec *curEventPtr)
+{
+ XtTranslations xlations = tmRecPtr->translations;
+ TMSimpleStateTree stateTree;
+ TMContext *contextPtr = GetContextPtr(tmRecPtr);
+ TMShortCard i;
+ ActionRec *actions = NULL;
+ Boolean matchExact = False;
+ Boolean match = False;
+ StatePtr complexMatchState = NULL;
+ int currIndex;
+ TMShortCard typeIndex = 0, modIndex = 0;
+ int matchTreeIndex = TM_NO_MATCH;
+
+ LOCK_PROCESS;
+ stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0];
+
+ for (i = 0;
+ ((!match || !complexMatchState) && (i < xlations->numStateTrees));
+ i++){
+ stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i];
+ currIndex = -1;
+ /*
+ * don't process this tree if we're only looking for a
+ * complexMatchState and there are no complex states
+ */
+ while (!(match && stateTree->isSimple) &&
+ ((!match || !complexMatchState) && (currIndex != TM_NO_MATCH))) {
+ currIndex++;
+ if (matchExact)
+ currIndex = MatchExact(stateTree,currIndex,typeIndex,modIndex);
+ else
+ currIndex = MatchBranchHead(stateTree,currIndex,curEventPtr);
+ if (currIndex != TM_NO_MATCH) {
+ TMBranchHead branchHead;
+ StatePtr currState;
+
+ branchHead = &stateTree->branchHeadTbl[currIndex];
+ if (branchHead->isSimple)
+ currState = NULL;
+ else
+ currState = ((TMComplexStateTree)stateTree)
+ ->complexBranchHeadTbl[TMBranchMore(branchHead)];
+
+ /*
+ * first check for a complete match
+ */
+ if (!match) {
+ if (branchHead->hasActions) {
+ if (branchHead->isSimple) {
+ static ActionRec dummyAction;
+
+ dummyAction.idx = TMBranchMore(branchHead);
+ actions = &dummyAction;
+ }
+ else
+ actions = currState->actions;
+ tmRecPtr->lastEventTime =
+ GetTime(tmRecPtr, curEventPtr->xev);
+ FreeContext((TMContext
+ *)&tmRecPtr->current_state);
+ match = True;
+ matchTreeIndex = i;
+ }
+ /*
+ * if it doesn't have actions and
+ * it's bc mode then it's a potential match node that is
+ * used to match later sequences.
+ */
+ if (!TMNewMatchSemantics() && !matchExact) {
+ matchExact = True;
+ typeIndex = branchHead->typeIndex;
+ modIndex = branchHead->modIndex;
+ }
+ }
+ /*
+ * check for it being an event sequence which can be
+ * a future match
+ */
+ if (!branchHead->isSimple &&
+ !branchHead->hasActions &&
+ !complexMatchState)
+ complexMatchState = currState;
+ }
+ }
+ }
+ if (match)
+ {
+ TMBindData bindData = (TMBindData) tmRecPtr->proc_table;
+ XtActionProc *procs;
+ Widget accelWidget;
+
+ if (bindData->simple.isComplex) {
+ TMComplexBindProcs bindProcs =
+ TMGetComplexBindEntry(bindData, matchTreeIndex);
+ procs = bindProcs->procs;
+ accelWidget = bindProcs->widget;
+ }
+ else {
+ TMSimpleBindProcs bindProcs =
+ TMGetSimpleBindEntry(bindData, matchTreeIndex);
+ procs = bindProcs->procs;
+ accelWidget = NULL;
+ }
+ HandleActions
+ (w,
+ curEventPtr->xev,
+ (TMSimpleStateTree)xlations->stateTreeTbl[matchTreeIndex],
+ accelWidget,
+ procs,
+ actions);
+ }
+ if (complexMatchState)
+ PushContext(contextPtr, complexMatchState);
+ UNLOCK_PROCESS;
+}
+
+static int MatchComplexBranch(
+ TMComplexStateTree stateTree,
+ int startIndex,
+ TMContext context,
+ StatePtr *leafStateRtn)
+{
+ TMShortCard i;
+
+ LOCK_PROCESS;
+ for (i = startIndex; i < stateTree->numComplexBranchHeads; i++)
+ {
+ StatePtr candState;
+ TMShortCard numMatches = context->numMatches;
+ MatchPair statMatch = context->matches;
+
+ for (candState = stateTree->complexBranchHeadTbl[i];
+ numMatches && candState;
+ numMatches--, statMatch++, candState = candState->nextLevel)
+ {
+ if ((statMatch->typeIndex != candState->typeIndex) ||
+ (statMatch->modIndex != candState->modIndex))
+ break;
+ }
+ if (numMatches == 0) {
+ *leafStateRtn = candState;
+ UNLOCK_PROCESS;
+ return i;
+ }
+ }
+ *leafStateRtn = NULL;
+ UNLOCK_PROCESS;
+ return (TM_NO_MATCH);
+}
+
+static StatePtr TryCurrentTree(
+ TMComplexStateTree *stateTreePtr,
+ XtTM tmRecPtr,
+ TMEventRec *curEventPtr)
+{
+ StatePtr candState = NULL, matchState = NULL;
+ TMContext *contextPtr = GetContextPtr(tmRecPtr);
+ TMTypeMatch typeMatch;
+ TMModifierMatch modMatch;
+ int currIndex = -1;
+
+ /*
+ * we want the first sequence that both matches and has actions.
+ * we keep on looking till we find both
+ */
+ LOCK_PROCESS;
+ while ((currIndex =
+ MatchComplexBranch(*stateTreePtr,
+ ++currIndex,
+ (*contextPtr),
+ &candState))
+ != TM_NO_MATCH) {
+ if (candState != NULL) {
+ typeMatch = TMGetTypeMatch(candState->typeIndex);
+ modMatch = TMGetModifierMatch(candState->modIndex);
+
+ /* does this state's index match? --> done */
+ if (MatchIncomingEvent(curEventPtr, typeMatch, modMatch))
+ {
+ if (candState->actions) {
+ UNLOCK_PROCESS;
+ return candState;
+ }
+ else
+ matchState = candState;
+ }
+ /* is this an event timer? */
+ if (typeMatch->eventType == _XtEventTimerEventType) {
+ StatePtr nextState = candState->nextLevel;
+
+ /* does the succeeding state match? */
+ if (nextState != NULL) {
+ TMTypeMatch nextTypeMatch;
+ TMModifierMatch nextModMatch;
+
+ nextTypeMatch = TMGetTypeMatch(nextState->typeIndex);
+ nextModMatch = TMGetModifierMatch(nextState->modIndex);
+
+ /* is it within the timeout? */
+ if (MatchIncomingEvent(curEventPtr,
+ nextTypeMatch,
+ nextModMatch)) {
+ XEvent *xev = curEventPtr->xev;
+ unsigned long time = GetTime(tmRecPtr, xev);
+ XtPerDisplay pd = _XtGetPerDisplay(xev->xany.display);
+ unsigned long delta = pd->multi_click_time;
+
+ if ((tmRecPtr->lastEventTime + delta) >= time) {
+ if (nextState->actions) {
+ UNLOCK_PROCESS;
+ return candState;
+ }
+ else
+ matchState = candState;
+ }
+ }
+ }
+ }
+ }
+ }
+ UNLOCK_PROCESS;
+ return matchState;
+}
+
+static void HandleComplexState(
+ Widget w,
+ XtTM tmRecPtr,
+ TMEventRec *curEventPtr)
+{
+ XtTranslations xlations = tmRecPtr->translations;
+ TMContext *contextPtr = GetContextPtr(tmRecPtr);
+ TMShortCard i, matchTreeIndex = 0;
+ StatePtr matchState = NULL, candState;
+ TMComplexStateTree *stateTreePtr =
+ (TMComplexStateTree *)&xlations->stateTreeTbl[0];
+
+ LOCK_PROCESS;
+ for (i = 0;
+ i < xlations->numStateTrees;
+ i++, stateTreePtr++) {
+ /*
+ * some compilers sign extend Boolean bit fields so test for
+ * false |||
+ */
+ if (((*stateTreePtr)->isSimple == False) &&
+ (candState = TryCurrentTree(stateTreePtr,
+ tmRecPtr,
+ curEventPtr))) {
+ if (!matchState || candState->actions) {
+ matchTreeIndex = i;
+ matchState = candState;
+ if (candState->actions)
+ break;
+ }
+ }
+ }
+ if (matchState == NULL){
+ /* couldn't find it... */
+ if (!Ignore(curEventPtr))
+ {
+ FreeContext(contextPtr);
+ HandleSimpleState(w, tmRecPtr, curEventPtr);
+ }
+ }
+ else {
+ TMBindData bindData = (TMBindData) tmRecPtr->proc_table;
+ XtActionProc *procs;
+ Widget accelWidget;
+ TMTypeMatch typeMatch;
+
+ typeMatch = TMGetTypeMatch(matchState->typeIndex);
+
+ PushContext(contextPtr, matchState);
+ if (typeMatch->eventType == _XtEventTimerEventType) {
+ matchState = matchState->nextLevel;
+ PushContext(contextPtr, matchState);
+ }
+ tmRecPtr->lastEventTime = GetTime (tmRecPtr, curEventPtr->xev);
+
+ if (bindData->simple.isComplex) {
+ TMComplexBindProcs bindProcs =
+ TMGetComplexBindEntry(bindData, matchTreeIndex);
+ procs = bindProcs->procs;
+ accelWidget = bindProcs->widget;
+ }
+ else {
+ TMSimpleBindProcs bindProcs =
+ TMGetSimpleBindEntry(bindData, matchTreeIndex);
+ procs = bindProcs->procs;
+ accelWidget = NULL;
+ }
+ HandleActions(w,
+ curEventPtr->xev,
+ (TMSimpleStateTree)
+ xlations->stateTreeTbl[matchTreeIndex],
+ accelWidget,
+ procs,
+ matchState->actions);
+ }
+ UNLOCK_PROCESS;
+}
+
+
+void _XtTranslateEvent (
+ Widget w,
+ XEvent * event)
+{
+ XtTM tmRecPtr = &w->core.tm;
+ TMEventRec curEvent;
+ StatePtr current_state = tmRecPtr->current_state;
+
+ XEventToTMEvent (event, &curEvent);
+
+ if (! tmRecPtr->translations) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(w),
+ XtNtranslationError,"nullTable",XtCXtToolkitError,
+ "Can't translate event through NULL table",
+ (String *)NULL, (Cardinal *)NULL);
+ return ;
+ }
+ if (current_state == NULL)
+ HandleSimpleState(w, tmRecPtr, &curEvent);
+ else
+ HandleComplexState(w, tmRecPtr, &curEvent);
+}
+
+
+/*ARGSUSED*/
+static StatePtr NewState(
+ TMParseStateTree stateTree,
+ TMShortCard typeIndex,
+ TMShortCard modIndex)
+{
+ StatePtr state = XtNew(StateRec);
+
+#ifdef TRACE_TM
+ LOCK_PROCESS;
+ _XtGlobalTM.numComplexStates++;
+ UNLOCK_PROCESS;
+#endif /* TRACE_TM */
+ state->typeIndex = typeIndex;
+ state->modIndex = modIndex;
+ state->nextLevel = NULL;
+ state->actions = NULL;
+ state->isCycleStart = state->isCycleEnd = False;
+ return state;
+}
+
+/*
+ * This routine is an iterator for state trees. If the func returns
+ * true then iteration is over.
+ */
+void _XtTraverseStateTree(
+ TMStateTree tree,
+ _XtTraversalProc func,
+ XtPointer data)
+{
+ TMComplexStateTree stateTree = (TMComplexStateTree)tree;
+ TMBranchHead currBH;
+ TMShortCard i;
+ StateRec dummyStateRec, *dummyState = &dummyStateRec;
+ ActionRec dummyActionRec, *dummyAction = &dummyActionRec;
+ Boolean firstSimple = True;
+ StatePtr currState;
+
+ /* first traverse the complex states */
+ if (stateTree->isSimple == False)
+ for (i = 0; i < stateTree->numComplexBranchHeads; i++) {
+ currState = stateTree->complexBranchHeadTbl[i];
+ for (; currState; currState = currState->nextLevel) {
+ if (func(currState, data))
+ return;
+ if (currState->isCycleEnd)
+ break;
+ }
+ }
+
+ /* now traverse the simple ones */
+ for (i = 0, currBH = stateTree->branchHeadTbl;
+ i < stateTree->numBranchHeads;
+ i++, currBH++)
+ {
+ if (currBH->isSimple && currBH->hasActions)
+ {
+ if (firstSimple)
+ {
+ XtBZero((char *) dummyState, sizeof(StateRec));
+ XtBZero((char *) dummyAction, sizeof(ActionRec));
+ dummyState->actions = dummyAction;
+ firstSimple = False;
+ }
+ dummyState->typeIndex = currBH->typeIndex;
+ dummyState->modIndex = currBH->modIndex;
+ dummyAction->idx = currBH->more;
+ if (func(dummyState, data))
+ return;
+ }
+ }
+}
+
+static EventMask EventToMask(
+ TMTypeMatch typeMatch,
+ TMModifierMatch modMatch)
+{
+ EventMask returnMask;
+ unsigned long eventType = typeMatch->eventType;
+
+ if (eventType == MotionNotify) {
+ Modifiers modifierMask = modMatch->modifierMask;
+ Modifiers tempMask;
+
+ returnMask = 0;
+ if (modifierMask == 0) {
+ if (modMatch->modifiers == AnyButtonMask)
+ return ButtonMotionMask;
+ else
+ return PointerMotionMask;
+ }
+ tempMask = modifierMask &
+ (Button1Mask | Button2Mask | Button3Mask
+ | Button4Mask | Button5Mask);
+ if (tempMask == 0)
+ return PointerMotionMask;
+ if (tempMask & Button1Mask)
+ returnMask |= Button1MotionMask;
+ if (tempMask & Button2Mask)
+ returnMask |= Button2MotionMask;
+ if (tempMask & Button3Mask)
+ returnMask |= Button3MotionMask;
+ if (tempMask & Button4Mask)
+ returnMask |= Button4MotionMask;
+ if (tempMask & Button5Mask)
+ returnMask |= Button5MotionMask;
+ return returnMask;
+ }
+ returnMask = _XtConvertTypeToMask(eventType);
+ if (returnMask == (StructureNotifyMask|SubstructureNotifyMask))
+ returnMask = StructureNotifyMask;
+ return returnMask;
+}
+
+/*ARGSUSED*/
+static void DispatchMappingNotify(
+ Widget widget, /* will be NULL from _RefreshMapping */
+ XtPointer closure, /* real Widget */
+ XtPointer call_data) /* XEvent* */
+{
+ _XtTranslateEvent( (Widget)closure, (XEvent*)call_data);
+}
+
+
+/*ARGSUSED*/
+static void RemoveFromMappingCallbacks(
+ Widget widget,
+ XtPointer closure, /* target widget */
+ XtPointer call_data)
+{
+ _XtRemoveCallback( &_XtGetPerDisplay(XtDisplay(widget))->mapping_callbacks,
+ DispatchMappingNotify,
+ closure
+ );
+}
+
+static Boolean AggregateEventMask(
+ StatePtr state,
+ XtPointer data)
+{
+ LOCK_PROCESS;
+ *((EventMask *)data) |= EventToMask(TMGetTypeMatch(state->typeIndex),
+ TMGetModifierMatch(state->modIndex));
+ UNLOCK_PROCESS;
+ return False;
+}
+
+void _XtInstallTranslations(
+ Widget widget)
+{
+ XtTranslations xlations;
+ Cardinal i;
+ TMStateTree stateTree;
+ Boolean mappingNotifyInterest = False;
+
+ xlations = widget->core.tm.translations;
+ if (xlations == NULL) return;
+
+ /*
+ * check for somebody stuffing the translations directly into the
+ * instance structure. We will end up being called again out of
+ * ComposeTranslations but we *should* have bindings by then
+ */
+ if (widget->core.tm.proc_table == NULL) {
+ _XtMergeTranslations(widget, NULL, XtTableReplace);
+ /*
+ * if we're realized then we'll be called out of
+ * ComposeTranslations
+ */
+ if (XtIsRealized(widget))
+ return;
+ }
+
+ xlations->eventMask = 0;
+ for (i = 0;
+ i < xlations->numStateTrees;
+ i++)
+ {
+ stateTree = xlations->stateTreeTbl[i];
+ _XtTraverseStateTree(stateTree,
+ AggregateEventMask,
+ (XtPointer)&xlations->eventMask);
+ mappingNotifyInterest |= stateTree->simple.mappingNotifyInterest;
+ }
+ /* double click needs to make sure that you have selected on both
+ button down and up. */
+
+ if (xlations->eventMask & ButtonPressMask)
+ xlations->eventMask |= ButtonReleaseMask;
+ if (xlations->eventMask & ButtonReleaseMask)
+ xlations->eventMask |= ButtonPressMask;
+
+ if (mappingNotifyInterest) {
+ XtPerDisplay pd = _XtGetPerDisplay(XtDisplay(widget));
+ if (pd->mapping_callbacks)
+ _XtAddCallbackOnce(&(pd->mapping_callbacks),
+ DispatchMappingNotify,
+ (XtPointer)widget);
+ else
+ _XtAddCallback(&(pd->mapping_callbacks),
+ DispatchMappingNotify,
+ (XtPointer)widget);
+
+ if (widget->core.destroy_callbacks != NULL)
+ _XtAddCallbackOnce( (InternalCallbackList *)
+ &widget->core.destroy_callbacks,
+ RemoveFromMappingCallbacks,
+ (XtPointer)widget
+ );
+ else
+ _XtAddCallback((InternalCallbackList *)
+ &widget->core.destroy_callbacks,
+ RemoveFromMappingCallbacks,
+ (XtPointer)widget
+ );
+ }
+ _XtBindActions(widget, (XtTM)&widget->core.tm);
+ _XtRegisterGrabs(widget);
+}
+
+void _XtRemoveTranslations(
+ Widget widget)
+{
+ Cardinal i;
+ TMSimpleStateTree stateTree;
+ Boolean mappingNotifyInterest = False;
+ XtTranslations xlations = widget->core.tm.translations;
+
+ if (xlations == NULL)
+ return;
+
+ for (i = 0;
+ i < xlations->numStateTrees;
+ i++)
+ {
+ stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i];
+ mappingNotifyInterest |= stateTree->mappingNotifyInterest;
+ }
+ if (mappingNotifyInterest)
+ RemoveFromMappingCallbacks(widget, (XtPointer)widget, NULL);
+}
+
+static void _XtUninstallTranslations(
+ Widget widget)
+{
+ XtTranslations xlations = widget->core.tm.translations;
+
+ _XtUnbindActions(widget,
+ xlations,
+ (TMBindData)widget->core.tm.proc_table);
+ _XtRemoveTranslations(widget);
+ widget->core.tm.translations = NULL;
+ FreeContext((TMContext *)&widget->core.tm.current_state);
+}
+
+void _XtDestroyTMData(
+ Widget widget)
+{
+ TMComplexBindData cBindData;
+
+ _XtUninstallTranslations(widget);
+
+ if ((cBindData = (TMComplexBindData)widget->core.tm.proc_table)) {
+ if (cBindData->isComplex) {
+ ATranslations aXlations, nXlations;
+
+ nXlations = (ATranslations) cBindData->accel_context;
+ while (nXlations){
+ aXlations = nXlations;
+ nXlations = nXlations->next;
+ XtFree((char *)aXlations);
+ }
+ }
+ XtFree((char *)cBindData);
+ }
+}
+
+/*** Public procedures ***/
+
+
+void XtUninstallTranslations(
+ Widget widget)
+{
+ EventMask oldMask;
+ Widget hookobj;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ if (! widget->core.tm.translations) {
+ UNLOCK_APP(app);
+ return;
+ }
+ oldMask = widget->core.tm.translations->eventMask;
+ _XtUninstallTranslations(widget);
+ if (XtIsRealized(widget) && oldMask)
+ XSelectInput(XtDisplay(widget), XtWindow(widget),
+ XtBuildEventMask(widget));
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHuninstallTranslations;
+ call_data.widget = widget;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ UNLOCK_APP(app);
+}
+
+XtTranslations _XtCreateXlations(
+ TMStateTree *stateTrees,
+ TMShortCard numStateTrees,
+ XtTranslations first,
+ XtTranslations second)
+{
+ XtTranslations xlations;
+ TMShortCard i;
+
+ xlations = (XtTranslations)
+ __XtMalloc(sizeof(TranslationData) +
+ (numStateTrees-1) * sizeof(TMStateTree));
+#ifdef TRACE_TM
+ LOCK_PROCESS;
+ if (_XtGlobalTM.numTms == _XtGlobalTM.tmTblSize) {
+ _XtGlobalTM.tmTblSize += 16;
+ _XtGlobalTM.tmTbl = (XtTranslations *)
+ XtRealloc((char *)_XtGlobalTM.tmTbl,
+ _XtGlobalTM.tmTblSize * sizeof(XtTranslations));
+ }
+ _XtGlobalTM.tmTbl[_XtGlobalTM.numTms++] = xlations;
+ UNLOCK_PROCESS;
+#endif /* TRACE_TM */
+
+ xlations->composers[0] = first;
+ xlations->composers[1] = second;
+ xlations->hasBindings = False;
+ xlations->operation = XtTableReplace;
+
+ for (i = 0;i < numStateTrees; i++)
+ {
+ xlations->stateTreeTbl[i] = (TMStateTree) stateTrees[i];
+ stateTrees[i]->simple.refCount++;
+ }
+ xlations->numStateTrees = numStateTrees;
+ xlations->eventMask = 0;
+ return xlations;
+}
+
+TMStateTree _XtParseTreeToStateTree(
+ TMParseStateTree parseTree)
+{
+ TMSimpleStateTree simpleTree;
+ unsigned int tableSize;
+
+ if (parseTree->numComplexBranchHeads) {
+ TMComplexStateTree complexTree;
+
+ complexTree = XtNew(TMComplexStateTreeRec);
+ complexTree->isSimple = False;
+ tableSize = parseTree->numComplexBranchHeads * sizeof(StatePtr);
+ complexTree->complexBranchHeadTbl = (StatePtr *)
+ __XtMalloc(tableSize);
+ XtMemmove(complexTree->complexBranchHeadTbl,
+ parseTree->complexBranchHeadTbl, tableSize);
+ complexTree->numComplexBranchHeads =
+ parseTree->numComplexBranchHeads;
+ simpleTree = (TMSimpleStateTree)complexTree;
+ }
+ else {
+ simpleTree = XtNew(TMSimpleStateTreeRec);
+ simpleTree->isSimple = True;
+ }
+ simpleTree->isAccelerator = parseTree->isAccelerator;
+ simpleTree->refCount = 0;
+ simpleTree->mappingNotifyInterest = parseTree->mappingNotifyInterest;
+
+ tableSize = parseTree->numBranchHeads * sizeof(TMBranchHeadRec);
+ simpleTree->branchHeadTbl = (TMBranchHead)
+ __XtMalloc(tableSize);
+ XtMemmove(simpleTree->branchHeadTbl, parseTree->branchHeadTbl, tableSize);
+ simpleTree->numBranchHeads = parseTree->numBranchHeads;
+
+ tableSize = parseTree->numQuarks * sizeof(XrmQuark);
+ simpleTree->quarkTbl = (XrmQuark *) __XtMalloc(tableSize);
+ XtMemmove(simpleTree->quarkTbl, parseTree->quarkTbl, tableSize);
+ simpleTree->numQuarks = parseTree->numQuarks;
+
+ return (TMStateTree)simpleTree;
+}
+
+static void FreeActions(
+ ActionPtr actions)
+{
+ ActionPtr action;
+ TMShortCard i;
+ for (action = actions; action;) {
+ ActionPtr nextAction = action->next;
+ for (i = action->num_params; i;) {
+ XtFree( action->params[--i] );
+ }
+ XtFree( (char*)action->params );
+ XtFree((char*) action);
+ action = nextAction;
+ }
+}
+
+/*ARGSUSED*/
+static void AmbigActions(
+ EventSeqPtr initialEvent,
+ StatePtr *state,
+ TMParseStateTree stateTree)
+{
+ String params[3];
+ Cardinal numParams = 0;
+
+ params[numParams++] = _XtPrintEventSeq(initialEvent, NULL);
+ params[numParams++] = _XtPrintActions((*state)->actions,
+ stateTree->quarkTbl);
+ XtWarningMsg (XtNtranslationError,"oldActions",XtCXtToolkitError,
+ "Previous entry was: %s %s", params, &numParams);
+ XtFree((char *)params[0]);
+ XtFree((char *)params[1]);
+ numParams = 0;
+ params[numParams++] = _XtPrintActions(initialEvent->actions,
+ stateTree->quarkTbl);
+ XtWarningMsg (XtNtranslationError,"newActions",XtCXtToolkitError,
+ "New actions are:%s", params, &numParams);
+ XtFree((char *)params[0]);
+ XtWarningMsg (XtNtranslationError,"ambiguousActions",
+ XtCXtToolkitError,
+ "Overriding earlier translation manager actions.",
+ (String *)NULL, (Cardinal *)NULL);
+
+ FreeActions((*state)->actions);
+ (*state)->actions = NULL;
+}
+
+
+void _XtAddEventSeqToStateTree(
+ EventSeqPtr eventSeq,
+ TMParseStateTree stateTree)
+{
+ StatePtr *state;
+ EventSeqPtr initialEvent = eventSeq;
+ TMBranchHead branchHead;
+ TMShortCard idx, modIndex, typeIndex;
+
+ if (eventSeq == NULL) return;
+
+ /* note that all states in the event seq passed in start out null */
+ /* we fill them in with the matching state as we traverse the list */
+
+ /*
+ * We need to free the parser data structures !!!
+ */
+
+ typeIndex = _XtGetTypeIndex(&eventSeq->event);
+ modIndex = _XtGetModifierIndex(&eventSeq->event);
+ idx = GetBranchHead(stateTree, typeIndex, modIndex, False);
+ branchHead = &stateTree->branchHeadTbl[idx];
+
+ /*
+ * Need to check for pre-existing actions with same lhs |||
+ */
+
+ /*
+ * Check for optimized case. Don't assume that the eventSeq has actions.
+ */
+ if (!eventSeq->next &&
+ eventSeq->actions &&
+ !eventSeq->actions->next &&
+ !eventSeq->actions->num_params)
+ {
+ if (eventSeq->event.eventType == MappingNotify)
+ stateTree->mappingNotifyInterest = True;
+ branchHead->hasActions = True;
+ branchHead->more = eventSeq->actions->idx;
+ FreeActions(eventSeq->actions);
+ eventSeq->actions = NULL;
+ return;
+ }
+
+ branchHead->isSimple = False;
+ if (!eventSeq->next)
+ branchHead->hasActions = True;
+ branchHead->more = GetComplexBranchIndex(stateTree, typeIndex, modIndex);
+ state = &stateTree->complexBranchHeadTbl[TMBranchMore(branchHead)];
+
+ for (;;) {
+ *state = NewState(stateTree, typeIndex, modIndex);
+
+ if (eventSeq->event.eventType == MappingNotify)
+ stateTree->mappingNotifyInterest = True;
+
+ /* *state now points at state record matching event */
+ eventSeq->state = *state;
+
+ if (eventSeq->actions != NULL) {
+ if ((*state)->actions != NULL)
+ AmbigActions(initialEvent, state, stateTree);
+ (*state)->actions = eventSeq->actions;
+#ifdef TRACE_TM
+ LOCK_PROCESS
+ _XtGlobalTM.numComplexActions++;
+ UNLOCK_PROCESS;
+#endif /* TRACE_TM */
+ }
+
+ if (((eventSeq = eventSeq->next) == NULL) || (eventSeq->state))
+ break;
+
+ state = &(*state)->nextLevel;
+ typeIndex = _XtGetTypeIndex(&eventSeq->event);
+ modIndex = _XtGetModifierIndex(&eventSeq->event);
+ LOCK_PROCESS;
+ if (!TMNewMatchSemantics()) {
+ /*
+ * force a potential empty entry into the branch head
+ * table in order to emulate old matching behavior
+ */
+ (void) GetBranchHead(stateTree, typeIndex, modIndex, True);
+ }
+ UNLOCK_PROCESS;
+ }
+
+ if (eventSeq && eventSeq->state) {
+ /* we've been here before... must be a cycle in the event seq. */
+ branchHead->hasCycles = True;
+ (*state)->nextLevel = eventSeq->state;
+ eventSeq->state->isCycleStart = True;
+ (*state)->isCycleEnd = TRUE;
+ }
+}
+
+
+/*
+ * Internal Converter for merging. Old and New must both be valid xlations
+ */
+
+/*ARGSUSED*/
+Boolean _XtCvtMergeTranslations(
+ Display *dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr from,
+ XrmValuePtr to,
+ XtPointer *closure_ret)
+{
+ XtTranslations first, second, xlations;
+ TMStateTree *stateTrees, stackStateTrees[16];
+ TMShortCard numStateTrees, i;
+
+ if (*num_args != 0)
+ XtWarningMsg("invalidParameters","mergeTranslations",XtCXtToolkitError,
+ "MergeTM to TranslationTable needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if (to->addr != NULL && to->size < sizeof(XtTranslations)) {
+ to->size = sizeof(XtTranslations);
+ return False;
+ }
+
+ first = ((TMConvertRec*)from->addr)->old;
+ second = ((TMConvertRec*)from->addr)->new;
+
+ numStateTrees = first->numStateTrees + second->numStateTrees;
+
+ stateTrees = (TMStateTree *)
+ XtStackAlloc(numStateTrees * sizeof(TMStateTree), stackStateTrees);
+
+ for (i = 0; i < first->numStateTrees; i++)
+ stateTrees[i] = first->stateTreeTbl[i];
+ for (i = 0; i < second->numStateTrees; i++)
+ stateTrees[i + first->numStateTrees] = second->stateTreeTbl[i];
+
+ xlations = _XtCreateXlations(stateTrees, numStateTrees, first, second);
+
+ if (to->addr != NULL) {
+ *(XtTranslations*)to->addr = xlations;
+ }
+ else {
+ static XtTranslations staticStateTable;
+ staticStateTable = xlations;
+ to->addr= (XPointer)&staticStateTable;
+ to->size = sizeof(XtTranslations);
+ }
+
+ XtStackFree((XtPointer)stateTrees, (XtPointer)stackStateTrees);
+ return True;
+}
+
+
+static XtTranslations MergeThem(
+ Widget dest,
+ XtTranslations first,
+ XtTranslations second)
+{
+ XtCacheRef cache_ref;
+ static XrmQuark from_type = NULLQUARK, to_type;
+ XrmValue from, to;
+ TMConvertRec convert_rec;
+ XtTranslations newTable;
+
+ LOCK_PROCESS;
+ if (from_type == NULLQUARK) {
+ from_type = XrmPermStringToQuark(_XtRStateTablePair);
+ to_type = XrmPermStringToQuark(XtRTranslationTable);
+ }
+ UNLOCK_PROCESS;
+ from.addr = (XPointer)&convert_rec;
+ from.size = sizeof(TMConvertRec);
+ to.addr = (XPointer)&newTable;
+ to.size = sizeof(XtTranslations);
+ convert_rec.old = first;
+ convert_rec.new = second;
+
+ LOCK_PROCESS;
+ if (! _XtConvert(dest, from_type, &from, to_type, &to, &cache_ref)) {
+ UNLOCK_PROCESS;
+ return NULL;
+ }
+ UNLOCK_PROCESS;
+
+#ifndef REFCNT_TRANSLATIONS
+
+ if (cache_ref)
+ XtAddCallback(dest, XtNdestroyCallback,
+ XtCallbackReleaseCacheRef, (XtPointer)cache_ref);
+
+#endif
+
+ return newTable;
+}
+
+/*
+ * Unmerge will recursively traverse the xlation compose tree and
+ * generate a new xlation that is the result of all instances of
+ * xlations being removed. It currently doesn't differentiate between
+ * the potential that an xlation will be both an accelerator and
+ * normal. This is not supported by the spec anyway.
+ */
+static XtTranslations UnmergeTranslations(
+ Widget widget,
+ XtTranslations xlations,
+ XtTranslations unmergeXlations,
+ TMShortCard currIndex,
+ TMComplexBindProcs oldBindings,
+ TMShortCard numOldBindings,
+ TMComplexBindProcs newBindings,
+ TMShortCard *numNewBindingsRtn)
+
+{
+ XtTranslations first, second, result;
+
+ if (!xlations || (xlations == unmergeXlations))
+ return NULL;
+
+ if (xlations->composers[0]) {
+ first = UnmergeTranslations(widget, xlations->composers[0],
+ unmergeXlations, currIndex,
+ oldBindings, numOldBindings,
+ newBindings, numNewBindingsRtn);
+ }
+ else
+ first = NULL;
+
+ if (xlations->composers[1]) {
+ second = UnmergeTranslations(widget, xlations->composers[1],
+ unmergeXlations,
+ currIndex +
+ xlations->composers[0]->numStateTrees,
+ oldBindings, numOldBindings,
+ newBindings, numNewBindingsRtn);
+ }
+ else
+ second = NULL;
+
+ if (first || second) {
+ if (first && second) {
+ if ((first != xlations->composers[0]) ||
+ (second != xlations->composers[1]))
+ result = MergeThem(widget, first, second);
+ else result = xlations;
+ }
+ else {
+ if (first)
+ result = first;
+ else
+ result = second;
+ }
+ } else { /* only update for leaf nodes */
+ if (numOldBindings) {
+ Cardinal i;
+ for (i = 0; i < xlations->numStateTrees; i++) {
+ if (xlations->stateTreeTbl[i]->simple.isAccelerator)
+ newBindings[*numNewBindingsRtn] =
+ oldBindings[currIndex + i];
+ (*numNewBindingsRtn)++;
+ }
+ }
+ result = xlations;
+ }
+ return result;
+}
+
+typedef struct {
+ XtTranslations xlations;
+ TMComplexBindProcs bindings;
+}MergeBindRec, *MergeBind;
+
+static XtTranslations MergeTranslations(
+ Widget widget,
+ XtTranslations oldXlations,
+ XtTranslations newXlations,
+ _XtTranslateOp operation,
+ Widget source,
+ TMComplexBindProcs oldBindings,
+ TMComplexBindProcs newBindings,
+ TMShortCard *numNewRtn)
+{
+ XtTranslations newTable = NULL, xlations;
+ TMComplexBindProcs bindings;
+ TMShortCard i, j;
+ TMStateTree *treePtr;
+ TMShortCard numNew = *numNewRtn;
+ MergeBindRec bindPair[2];
+
+ /* If the new translation has an accelerator context then pull it
+ * off and pass it and the real xlations in to the caching merge
+ * routine.
+ */
+ if (newXlations->hasBindings) {
+ xlations = ((ATranslations) newXlations)->xlations;
+ bindings = (TMComplexBindProcs)
+ &((ATranslations) newXlations)->bindTbl[0];
+ }
+ else {
+ xlations = newXlations;
+ bindings = NULL;
+ }
+ switch(operation) {
+ case XtTableReplace:
+ newTable = bindPair[0].xlations = xlations;
+ bindPair[0].bindings = bindings;
+ bindPair[1].xlations = NULL;
+ bindPair[1].bindings = NULL;
+ break;
+ case XtTableAugment:
+ bindPair[0].xlations = oldXlations;
+ bindPair[0].bindings = oldBindings;
+ bindPair[1].xlations = xlations;
+ bindPair[1].bindings = bindings;
+ newTable = NULL;
+ break;
+ case XtTableOverride:
+ bindPair[0].xlations = xlations;
+ bindPair[0].bindings = bindings;
+ bindPair[1].xlations = oldXlations;
+ bindPair[1].bindings = oldBindings;
+ newTable = NULL;
+ break;
+ }
+ if (!newTable)
+ newTable = MergeThem(widget, bindPair[0].xlations, bindPair[1].xlations);
+
+ for (i = 0, numNew = 0; i < 2; i++) {
+ if (bindPair[i].xlations)
+ for (j = 0; j < bindPair[i].xlations->numStateTrees; j++, numNew++) {
+ if (bindPair[i].xlations->stateTreeTbl[j]->simple.isAccelerator) {
+ if (bindPair[i].bindings)
+ newBindings[numNew] = bindPair[i].bindings[j];
+ else {
+ newBindings[numNew].widget = source;
+ newBindings[numNew].aXlations =
+ bindPair[i].xlations;
+ }
+ }
+ }
+ }
+ *numNewRtn = numNew;
+ treePtr = &newTable->stateTreeTbl[0];
+ for (i = 0; i < newTable->numStateTrees; i++, treePtr++)
+ (*treePtr)->simple.refCount++;
+ return newTable;
+}
+
+static TMBindData MakeBindData(
+ TMComplexBindProcs bindings,
+ TMShortCard numBindings,
+ TMBindData oldBindData)
+{
+ TMLongCard bytes;
+ TMShortCard i;
+ Boolean isComplex;
+ TMBindData bindData;
+
+ if (numBindings == 0)
+ return NULL;
+ for (i = 0; i < numBindings; i++)
+ if (bindings[i].widget)
+ break;
+ isComplex = (i < numBindings);
+ if (isComplex)
+ bytes = (sizeof(TMComplexBindDataRec) +
+ ((numBindings - 1) *
+ sizeof(TMComplexBindProcsRec)));
+ else
+ bytes = (sizeof(TMSimpleBindDataRec) +
+ ((numBindings - 1) *
+ sizeof(TMSimpleBindProcsRec)));
+
+ bindData = (TMBindData) __XtCalloc(sizeof(char), bytes);
+ bindData->simple.isComplex = isComplex;
+ if (isComplex) {
+ TMComplexBindData cBindData = (TMComplexBindData)bindData;
+ /*
+ * If there were any accelerator contexts in the old bindData
+ * then propagate them to the new one.
+ */
+ if (oldBindData && oldBindData->simple.isComplex)
+ cBindData->accel_context =
+ ((TMComplexBindData) oldBindData)->accel_context;
+ XtMemmove((char *)&cBindData->bindTbl[0], (char *)bindings,
+ numBindings * sizeof(TMComplexBindProcsRec));
+ }
+ return bindData;
+}
+
+/*
+ * This routine is the central clearinghouse for merging translations
+ * into a widget. It takes care of preping the action bindings for
+ * realize time and calling the converter or doing a straight merge if
+ * the destination is empty.
+ */
+static Boolean ComposeTranslations(
+ Widget dest,
+ _XtTranslateOp operation,
+ Widget source,
+ XtTranslations newXlations)
+{
+ XtTranslations newTable, oldXlations;
+ XtTranslations accNewXlations;
+ EventMask oldMask = 0;
+ TMBindData bindData;
+ TMComplexBindProcs oldBindings = NULL;
+ TMShortCard numOldBindings = 0, numNewBindings = 0, numBytes;
+ TMComplexBindProcsRec stackBindings[16], *newBindings;
+
+ /*
+ * how should we be handling the refcount decrement for the
+ * replaced translation table ???
+ */
+ if (!newXlations)
+ {
+ XtAppWarningMsg(XtWidgetToApplicationContext(dest),
+ XtNtranslationError,"nullTable",XtCXtToolkitError,
+ "table to (un)merge must not be null",
+ (String *)NULL, (Cardinal *)NULL);
+ return False;
+ }
+
+ accNewXlations = newXlations;
+ newXlations = ((newXlations->hasBindings)
+ ? ((ATranslations)newXlations)->xlations
+ : newXlations);
+
+ if (!(oldXlations = dest->core.tm.translations))
+ operation = XtTableReplace;
+
+ /*
+ * try to avoid generation of duplicate state trees. If the source
+ * isn't simple (1 state Tree) then it's too much hassle
+ */
+ if (((operation == XtTableAugment) ||
+ (operation == XtTableOverride)) &&
+ (newXlations->numStateTrees == 1)) {
+ Cardinal i;
+ for (i = 0; i < oldXlations->numStateTrees; i++)
+ if (oldXlations->stateTreeTbl[i] ==
+ newXlations->stateTreeTbl[0])
+ break;
+ if (i < oldXlations->numStateTrees) {
+ if (operation == XtTableAugment) {
+ /*
+ * we don't need to do anything since it's already
+ * there
+ */
+ return True;
+ }
+ else {/* operation == XtTableOverride */
+ /*
+ * We'll get rid of the duplicate trees throughout the
+ * and leave it with a pruned translation table. This
+ * will only work if the same table has been merged
+ * into this table (or one of it's composers
+ */
+ _XtUnmergeTranslations(dest, newXlations);
+ /*
+ * reset oldXlations so we're back in sync
+ */
+ if (!(oldXlations = dest->core.tm.translations))
+ operation = XtTableReplace;
+ }
+ }
+ }
+
+ bindData = (TMBindData) dest->core.tm.proc_table;
+ if (bindData) {
+ numOldBindings = (oldXlations ? oldXlations->numStateTrees : 0);
+ if (bindData->simple.isComplex)
+ oldBindings = &((TMComplexBindData)bindData)->bindTbl[0];
+ else
+ oldBindings = (TMComplexBindProcs)
+ (&((TMSimpleBindData)bindData)->bindTbl[0]);
+ }
+
+ numBytes =(((oldXlations ? oldXlations->numStateTrees : 0)
+ + newXlations->numStateTrees) * sizeof(TMComplexBindProcsRec));
+ newBindings = (TMComplexBindProcs) XtStackAlloc(numBytes, stackBindings);
+ XtBZero((char *)newBindings, numBytes);
+
+ if (operation == XtTableUnmerge) {
+ newTable = UnmergeTranslations(dest,
+ oldXlations,
+ newXlations,
+ 0,
+ oldBindings, numOldBindings,
+ newBindings, &numNewBindings);
+#ifdef DEBUG
+ /* check for no match for unmerge */
+ if (newTable == oldXlations) {
+ XtWarning("attempt to unmerge invalid table");
+ XtStackFree((char *)newBindings, (char *)stackBindings);
+ return(newTable != NULL);
+ }
+#endif /* DEBUG */
+ }
+ else {
+ newTable = MergeTranslations(dest,
+ oldXlations,
+ accNewXlations,
+ operation,
+ source,
+ oldBindings,
+ newBindings,
+ &numNewBindings);
+ }
+ if (XtIsRealized(dest)) {
+ oldMask = 0;
+ if (oldXlations)
+ oldMask = oldXlations->eventMask;
+ _XtUninstallTranslations(dest);
+ }
+
+ dest->core.tm.proc_table =
+ (XtActionProc *) MakeBindData(newBindings, numNewBindings, bindData);
+
+ if (bindData) XtFree((char *)bindData);
+
+ dest->core.tm.translations = newTable;
+
+ if (XtIsRealized(dest)) {
+ EventMask mask = 0;
+ _XtInstallTranslations(dest);
+ if (newTable)
+ mask = newTable->eventMask;
+ if (mask != oldMask)
+ XSelectInput(XtDisplay(dest), XtWindow(dest),
+ XtBuildEventMask(dest));
+ }
+ XtStackFree((XtPointer)newBindings, (XtPointer)stackBindings);
+ return(newTable != NULL);
+}
+
+/*
+ * If a GetValues is done on a translation resource that contains
+ * accelerators we need to return the accelerator context in addition
+ * to the pure translations. Since this means returning memory that
+ * the client controlls but we still own, we will track the "headers"
+ * that we return (via a linked list pointed to from the bindData) and
+ * free it at destroy time.
+ */
+XtTranslations _XtGetTranslationValue(
+ Widget w)
+{
+ XtTM tmRecPtr = (XtTM) &w->core.tm;
+ ATranslations *aXlationsPtr;
+ TMComplexBindData cBindData = (TMComplexBindData) tmRecPtr->proc_table;
+ XtTranslations xlations = tmRecPtr->translations;
+
+ if (!xlations || !cBindData || !cBindData->isComplex)
+ return xlations;
+
+ /* Walk the list looking to see if we already have generated a
+ * header for the currently installed translations. If we have,
+ * just return that header. Otherwise create a new header.
+ */
+ for (aXlationsPtr = (ATranslations *) &cBindData->accel_context;
+ *aXlationsPtr && (*aXlationsPtr)->xlations != xlations;
+ aXlationsPtr = &(*aXlationsPtr)->next)
+ ;
+ if (*aXlationsPtr)
+ return (XtTranslations) *aXlationsPtr;
+ else {
+ /* create a new aXlations context */
+ ATranslations aXlations;
+ Cardinal numBindings = xlations->numStateTrees;
+
+ (*aXlationsPtr) = aXlations = (ATranslations)
+ __XtMalloc(sizeof(ATranslationData) +
+ (numBindings - 1) * sizeof(TMComplexBindProcsRec));
+
+ aXlations->hasBindings = True;
+ aXlations->xlations = xlations;
+ aXlations->next = NULL;
+ XtMemmove((char *) &aXlations->bindTbl[0],
+ (char *) &cBindData->bindTbl[0],
+ numBindings * sizeof(TMComplexBindProcsRec));
+ return (XtTranslations) aXlations;
+ }
+}
+
+
+/*ARGSUSED*/
+static void RemoveStateTree(
+ TMStateTree tree)
+{
+#ifdef REFCNT_TRANSLATIONS
+ TMComplexStateTree stateTree = (TMComplexStateTree)tree;
+
+ if (--stateTree->refCount == 0) {
+ /*
+ * should we free/refcount the match recs ?
+ */
+ if (!stateTree->isSimple) {
+ StatePtr currState, nextState;
+ TMShortCard i;
+ for (i = 0; i < stateTree->numComplexBranchHeads; i++) {
+ currState =
+ nextState =
+ stateTree->complexBranchHeadTbl[i];
+ for (; nextState;){
+ FreeActions(currState->actions);
+ currState->actions = NULL;
+ if (!currState->isCycleEnd)
+ nextState = currState->nextLevel;
+ else
+ nextState = NULL;
+ XtFree( (char*)currState );
+ }
+ }
+ XtFree((char*)stateTree->complexBranchHeadTbl);
+ }
+ XtFree((char*)stateTree->branchHeadTbl);
+ XtFree((char*)stateTree);
+ }
+#endif /* REFCNT_TRANSLATIONS */
+}
+
+void _XtRemoveStateTreeByIndex(
+ XtTranslations xlations,
+ TMShortCard i)
+{
+ TMStateTree *stateTrees = xlations->stateTreeTbl;
+
+ RemoveStateTree(stateTrees[i]);
+ xlations->numStateTrees--;
+
+ for (; i < xlations->numStateTrees; i++)
+ {
+ stateTrees[i] = stateTrees[i+1];
+ }
+}
+
+/* ARGSUSED */
+void _XtFreeTranslations(
+ XtAppContext app,
+ XrmValuePtr toVal,
+ XtPointer closure,
+ XrmValuePtr args,
+ Cardinal *num_args)
+{
+ XtTranslations xlations;
+ int i;
+
+ if (*num_args != 0)
+ XtAppWarningMsg(app,
+ "invalidParameters","freeTranslations",XtCXtToolkitError,
+ "Freeing XtTranslations requires no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+
+ xlations = *(XtTranslations*)toVal->addr;
+ for (i = 0; i < (int)xlations->numStateTrees; i++)
+ RemoveStateTree(xlations->stateTreeTbl[i]);
+ XtFree((char *)xlations);
+}
+
+/* The spec is not clear on when actions specified in accelerators are bound;
+ * Bind them at Realize the same as translations
+ */
+void XtInstallAccelerators(
+ Widget destination, Widget source)
+{
+ XtTranslations aXlations;
+ _XtTranslateOp op;
+ String buf;
+ WIDGET_TO_APPCON(destination);
+
+ /*
+ * test that it was parsed as an accelarator table. Even though
+ * there doesn't need to be a distinction it makes life easier if
+ * we honor the spec implication that aXlations is an accelerator
+ */
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if ((!XtIsWidget(source)) ||
+ ((aXlations = source->core.accelerators) == NULL) ||
+ (aXlations->stateTreeTbl[0]->simple.isAccelerator == False)) {
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+ return;
+ }
+
+ aXlations = source->core.accelerators;
+ op = aXlations->operation;
+
+ if (ComposeTranslations(destination, op, source, aXlations) &&
+ (XtClass(source)->core_class.display_accelerator != NULL)) {
+
+ buf = _XtPrintXlations(destination, aXlations, source, False);
+ (*(XtClass(source)->core_class.display_accelerator))(source,buf);
+ XtFree(buf);
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+void XtInstallAllAccelerators(
+ Widget destination,
+ Widget source)
+{
+ Cardinal i;
+ CompositeWidget cw;
+ WIDGET_TO_APPCON(destination);
+
+ /* Recurse down normal children */
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ if (XtIsComposite(source)) {
+ cw = (CompositeWidget) source;
+ for (i = 0; i < cw->composite.num_children; i++) {
+ XtInstallAllAccelerators(destination,cw->composite.children[i]);
+ }
+ }
+
+ /* Recurse down popup children */
+ if (XtIsWidget(source)) {
+ for (i = 0; i < source->core.num_popups; i++) {
+ XtInstallAllAccelerators(destination,source->core.popup_list[i]);
+ }
+ }
+ /* Finally, apply procedure to this widget */
+ XtInstallAccelerators(destination,source);
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+#if 0 /* dead code */
+static _XtTranslateOp _XtGetTMOperation(
+ XtTranslations xlations)
+{
+ return ((xlations->hasBindings)
+ ? ((ATranslations)xlations)->xlations->operation
+ : xlations->operation);
+}
+#endif
+
+void XtAugmentTranslations(
+ Widget widget,
+ XtTranslations new)
+{
+ Widget hookobj;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ (void)ComposeTranslations(widget, XtTableAugment, (Widget)NULL, new);
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHaugmentTranslations;
+ call_data.widget = widget;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+void XtOverrideTranslations(
+ Widget widget,
+ XtTranslations new)
+{
+ Widget hookobj;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ LOCK_PROCESS;
+ (void) ComposeTranslations(widget, XtTableOverride, (Widget)NULL, new);
+ hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHoverrideTranslations;
+ call_data.widget = widget;
+ XtCallCallbackList(hookobj,
+ ((HookObject)hookobj)->hooks.changehook_callbacks,
+ (XtPointer)&call_data);
+ }
+ UNLOCK_PROCESS;
+ UNLOCK_APP(app);
+}
+
+void _XtMergeTranslations(
+ Widget widget,
+ XtTranslations newXlations,
+ _XtTranslateOp op)
+{
+ if (!newXlations){
+ if (!widget->core.tm.translations)
+ return;
+ else {
+ newXlations = widget->core.tm.translations;
+ widget->core.tm.translations = NULL;
+ }
+ }
+ (void) ComposeTranslations(widget,
+ op,
+ (Widget)NULL,
+ newXlations);
+}
+
+void _XtUnmergeTranslations(
+ Widget widget,
+ XtTranslations xlations)
+{
+ ComposeTranslations(widget, XtTableUnmerge, (Widget)NULL, xlations);
+}
diff --git a/nx-X11/lib/Xt/Threads.c b/nx-X11/lib/Xt/Threads.c
new file mode 100644
index 000000000..aad17ca79
--- /dev/null
+++ b/nx-X11/lib/Xt/Threads.c
@@ -0,0 +1,428 @@
+/* $Xorg: Threads.c,v 1.4 2001/02/09 02:03:59 xorgcvs Exp $ */
+
+/************************************************************
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the name Sun not be used in advertising
+or publicity pertaining to distribution of the software
+without specific prior written permission. Sun makes no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/Threads.c,v 3.6 2001/12/14 19:56:31 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+
+#ifdef XTHREADS
+
+#define xmalloc __XtMalloc
+#define xfree XtFree
+#include <X11/Xthreads.h>
+
+#ifndef NDEBUG
+#define NDEBUG
+#endif
+#include <assert.h>
+#include <stdio.h>
+
+typedef struct _ThreadStack {
+ unsigned int size;
+ int sp;
+ struct _Tstack {
+ xthread_t t;
+ xcondition_t c;
+ } *st;
+} ThreadStack;
+
+typedef struct _LockRec {
+ xmutex_t mutex;
+ int level;
+ ThreadStack stack;
+#ifndef _XMUTEX_NESTS
+ xthread_t holder;
+ xcondition_t cond;
+#endif
+} LockRec;
+
+
+#define STACK_INCR 16
+
+static LockPtr process_lock = NULL;
+
+static void
+InitProcessLock(void)
+{
+ if(!process_lock) {
+ process_lock = XtNew(LockRec);
+ process_lock->mutex = xmutex_malloc();
+ xmutex_init(process_lock->mutex);
+ process_lock->level = 0;
+#ifndef _XMUTEX_NESTS
+ process_lock->cond = xcondition_malloc();
+ xcondition_init(process_lock->cond);
+ xthread_clear_id(process_lock->holder);
+#endif
+ }
+}
+
+static void
+ProcessLock(void)
+{
+#ifdef _XMUTEX_NESTS
+ xmutex_lock(process_lock->mutex);
+ process_lock->level++;
+#else
+ xthread_t this_thread = xthread_self();
+
+ xmutex_lock(process_lock->mutex);
+
+ if (!xthread_have_id(process_lock->holder)) {
+ process_lock->holder = this_thread;
+ xmutex_unlock(process_lock->mutex);
+ return;
+ }
+
+ if (xthread_equal(process_lock->holder,this_thread)) {
+ process_lock->level++;
+ xmutex_unlock(process_lock->mutex);
+ return;
+ }
+
+ while(xthread_have_id(process_lock->holder))
+ xcondition_wait(process_lock->cond, process_lock->mutex);
+
+ process_lock->holder = this_thread;
+ assert(xthread_equal(process_lock->holder, this_thread));
+ xmutex_unlock(process_lock->mutex);
+#endif
+}
+
+static void
+ProcessUnlock(void)
+{
+#ifdef _XMUTEX_NESTS
+ process_lock->level--;
+ xmutex_unlock(process_lock->mutex);
+#else
+ xmutex_lock(process_lock->mutex);
+ assert(xthread_equal(process_lock->holder, xthread_self()));
+ if (process_lock->level != 0) {
+ process_lock->level--;
+ xmutex_unlock(process_lock->mutex);
+ return;
+ }
+
+ xthread_clear_id(process_lock->holder);
+ xcondition_signal(process_lock->cond);
+
+ xmutex_unlock(process_lock->mutex);
+#endif
+}
+
+
+static void
+AppLock(XtAppContext app)
+{
+ LockPtr app_lock = app->lock_info;
+#ifdef _XMUTEX_NESTS
+ xmutex_lock(app_lock->mutex);
+ app_lock->level++;
+#else
+ xthread_t self = xthread_self();
+ xmutex_lock(app_lock->mutex);
+ if (!xthread_have_id(app_lock->holder)) {
+ app_lock->holder = self;
+ assert(xthread_equal(app_lock->holder, self));
+ xmutex_unlock(app_lock->mutex);
+ return;
+ }
+ if (xthread_equal(app_lock->holder, self)) {
+ app_lock->level++;
+ xmutex_unlock(app_lock->mutex);
+ return;
+ }
+ while(xthread_have_id(app_lock->holder)) {
+ xcondition_wait(app_lock->cond, app_lock->mutex);
+ }
+ app_lock->holder = self;
+ assert(xthread_equal(app_lock->holder, self));
+ xmutex_unlock(app_lock->mutex);
+#endif
+}
+
+static void
+AppUnlock(XtAppContext app)
+{
+ LockPtr app_lock = app->lock_info;
+#ifdef _XMUTEX_NESTS
+ app_lock->level--;
+ xmutex_unlock(app_lock->mutex);
+#else
+ xthread_t self;
+
+ self = xthread_self();
+ xmutex_lock(app_lock->mutex);
+ assert(xthread_equal(app_lock->holder, self));
+ if (app_lock->level != 0) {
+ app_lock->level--;
+ xmutex_unlock(app_lock->mutex);
+ return;
+ }
+ xthread_clear_id(app_lock->holder);
+ xcondition_signal(app_lock->cond);
+ xmutex_unlock(app_lock->mutex);
+#endif
+}
+
+static void
+YieldAppLock(
+ XtAppContext app,
+ Boolean* push_thread,
+ Boolean* pushed_thread,
+ int* level)
+{
+ LockPtr app_lock = app->lock_info;
+ xthread_t self = xthread_self();
+#ifndef _XMUTEX_NESTS
+ xmutex_lock(app_lock->mutex);
+ assert(xthread_equal(app_lock->holder, self));
+#endif
+ *level = app_lock->level;
+ if (*push_thread) {
+ *push_thread = FALSE;
+ *pushed_thread = TRUE;
+
+ if(app_lock->stack.sp == (int)app_lock->stack.size - 1) {
+ unsigned ii;
+ app_lock->stack.st = (struct _Tstack *)
+ XtRealloc ((char *)app_lock->stack.st,
+ (app_lock->stack.size + STACK_INCR) * sizeof (struct _Tstack));
+ ii = app_lock->stack.size;
+ app_lock->stack.size += STACK_INCR;
+ for ( ; ii < app_lock->stack.size; ii++) {
+ app_lock->stack.st[ii].c = xcondition_malloc();
+ xcondition_init(app_lock->stack.st[ii].c);
+ }
+ }
+ app_lock->stack.st[++(app_lock->stack.sp)].t = self;
+ }
+#ifdef _XMUTEX_NESTS
+ while (app_lock->level > 0) {
+ app_lock->level--;
+ xmutex_unlock(app_lock->mutex);
+ }
+#else
+ xcondition_signal(app_lock->cond);
+ app_lock->level = 0;
+ xthread_clear_id(app_lock->holder);
+ xmutex_unlock(app_lock->mutex);
+#endif
+}
+
+static void
+RestoreAppLock(
+ XtAppContext app,
+ int level,
+ Boolean* pushed_thread)
+{
+ LockPtr app_lock = app->lock_info;
+ xthread_t self = xthread_self();
+ xmutex_lock(app_lock->mutex);
+#ifdef _XMUTEX_NESTS
+ app_lock->level++;
+#else
+ while(xthread_have_id(app_lock->holder)) {
+ xcondition_wait(app_lock->cond, app_lock->mutex);
+ }
+#endif
+ if (!xthread_equal(app_lock->stack.st[app_lock->stack.sp].t, self)) {
+ int ii;
+ for (ii = app_lock->stack.sp - 1; ii >= 0; ii--) {
+ if (xthread_equal(app_lock->stack.st[ii].t, self)) {
+ xcondition_wait(app_lock->stack.st[ii].c, app_lock->mutex);
+ break;
+ }
+ }
+#ifndef _XMUTEX_NESTS
+ while(xthread_have_id(app_lock->holder)) {
+ xcondition_wait(app_lock->cond, app_lock->mutex);
+ }
+#endif
+ }
+#ifdef _XMUTEX_NESTS
+ while (app_lock->level < level) {
+ xmutex_lock(app_lock->mutex);
+ app_lock->level++;
+ }
+#else
+ app_lock->holder = self;
+ app_lock->level = level;
+ assert(xthread_equal(app_lock->holder, self));
+#endif
+ if (*pushed_thread) {
+ *pushed_thread = FALSE;
+ (app_lock->stack.sp)--;
+ if (app_lock->stack.sp >= 0) {
+ xcondition_signal (app_lock->stack.st[app_lock->stack.sp].c);
+ }
+ }
+#ifndef _XMUTEX_NESTS
+ xmutex_unlock(app_lock->mutex);
+#endif
+}
+
+static void
+FreeAppLock(XtAppContext app)
+{
+ unsigned ii;
+ LockPtr app_lock = app->lock_info;
+
+ if(app_lock) {
+ xmutex_clear(app_lock->mutex);
+ xmutex_free(app_lock->mutex);
+#ifndef _XMUTEX_NESTS
+ xcondition_clear(app_lock->cond);
+ xcondition_free(app_lock->cond);
+#endif
+ if(app_lock->stack.st != (struct _Tstack *)NULL) {
+ for (ii = 0; ii < app_lock->stack.size; ii++) {
+ xcondition_clear(app_lock->stack.st[ii].c);
+ xcondition_free(app_lock->stack.st[ii].c);
+ }
+ XtFree((char *)app_lock->stack.st);
+ }
+ XtFree((char *)app_lock);
+ app->lock_info = NULL;
+ }
+}
+
+static void
+InitAppLock(XtAppContext app)
+{
+ int ii;
+ LockPtr app_lock;
+
+ app->lock = AppLock;
+ app->unlock = AppUnlock;
+ app->yield_lock = YieldAppLock;
+ app->restore_lock = RestoreAppLock;
+ app->free_lock = FreeAppLock;
+
+ app_lock = app->lock_info = XtNew(LockRec);
+ app_lock->mutex = xmutex_malloc();
+ xmutex_init(app_lock->mutex);
+ app_lock->level = 0;
+#ifndef _XMUTEX_NESTS
+ app_lock->cond = xcondition_malloc();
+ xcondition_init(app_lock->cond);
+ xthread_clear_id(app_lock->holder);
+#endif
+ app_lock->stack.size = STACK_INCR;
+ app_lock->stack.sp = -1;
+ app_lock->stack.st =
+ (struct _Tstack *)__XtMalloc(sizeof(struct _Tstack)*STACK_INCR);
+ for (ii = 0; ii < STACK_INCR; ii++) {
+ app_lock->stack.st[ii].c = xcondition_malloc();
+ xcondition_init(app_lock->stack.st[ii].c);
+ }
+}
+
+#endif /* defined(XTHREADS) */
+
+void XtAppLock(XtAppContext app)
+{
+#ifdef XTHREADS
+ if(app->lock)
+ (*app->lock)(app);
+#endif
+}
+
+void XtAppUnlock(XtAppContext app)
+{
+#ifdef XTHREADS
+ if(app->unlock)
+ (*app->unlock)(app);
+#endif
+}
+
+void XtProcessLock(void)
+{
+#ifdef XTHREADS
+ if(_XtProcessLock)
+ (*_XtProcessLock)();
+#endif
+}
+
+void XtProcessUnlock(void)
+{
+#ifdef XTHREADS
+ if(_XtProcessUnlock)
+ (*_XtProcessUnlock)();
+#endif
+}
+
+Boolean XtToolkitThreadInitialize(void)
+{
+#ifdef XTHREADS
+ if (_XtProcessLock == NULL) {
+#ifdef xthread_init
+ xthread_init();
+#endif
+ InitProcessLock();
+ _XtProcessLock = ProcessLock;
+ _XtProcessUnlock = ProcessUnlock;
+ _XtInitAppLock = InitAppLock;
+ }
+ return True;
+#else
+ return False;
+#endif
+}
+
diff --git a/nx-X11/lib/Xt/ThreadsI.h b/nx-X11/lib/Xt/ThreadsI.h
new file mode 100644
index 000000000..1492d7711
--- /dev/null
+++ b/nx-X11/lib/Xt/ThreadsI.h
@@ -0,0 +1,130 @@
+/* $Xorg: ThreadsI.h,v 1.4 2001/02/09 02:03:59 xorgcvs Exp $ */
+
+/************************************************************
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, 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 no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the name Sun not be used in advertising
+or publicity pertaining to distribution of the software
+without specific prior written permission. Sun makes no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/ThreadsI.h,v 3.5 2001/12/14 19:56:31 dawes Exp $ */
+
+#ifndef _XtThreadsI_h
+#define _XtThreadsI_h
+
+#include <X11/XlibConf.h>
+
+#ifdef XTHREADS
+
+typedef struct _LockRec *LockPtr;
+
+typedef void (*ThreadAppProc)(
+ XtAppContext /* app */
+);
+
+typedef void (*ThreadAppYieldLockProc)(
+ XtAppContext, /* app */
+ Boolean*, /* push_thread */
+ Boolean*, /* pushed_thread */
+ int* /* level */
+);
+
+typedef void (*ThreadAppRestoreLockProc)(
+ XtAppContext /* app */,
+ int, /* level */
+ Boolean* /* pushed_thread */
+);
+
+extern void (*_XtProcessLock)(
+ void
+);
+
+extern void (*_XtProcessUnlock)(
+ void
+);
+
+extern void (*_XtInitAppLock)(
+ XtAppContext /* app */
+);
+
+#define INIT_APP_LOCK(app) if(_XtInitAppLock) (*_XtInitAppLock)(app)
+#define FREE_APP_LOCK(app) if(app && app->free_lock)(*app->free_lock)(app)
+
+#define LOCK_PROCESS if(_XtProcessLock)(*_XtProcessLock)()
+#define UNLOCK_PROCESS if(_XtProcessUnlock)(*_XtProcessUnlock)()
+#define LOCK_APP(app) if(app && app->lock)(*app->lock)(app)
+#define UNLOCK_APP(app) if(app && app->unlock)(*app->unlock)(app)
+
+#define YIELD_APP_LOCK(app,push,pushed,level)\
+ if(app && app->yield_lock) (*app->yield_lock)(app,push,pushed,level)
+#define RESTORE_APP_LOCK(app,level,pushed)\
+ if(app && app->restore_lock) (*app->restore_lock)(app,level,pushed)
+
+#define WIDGET_TO_APPCON(w) \
+ XtAppContext app = (w && _XtProcessLock ? \
+ XtWidgetToApplicationContext(w) : NULL)
+
+#define DPY_TO_APPCON(d) \
+ XtAppContext app = (_XtProcessLock ? XtDisplayToApplicationContext(d): 0)
+
+#else /* defined(XTHREADS) */
+
+#define LOCK_PROCESS
+#define UNLOCK_PROCESS
+#define LOCK_APP(app)
+#define UNLOCK_APP(app)
+
+#define INIT_APP_LOCK(app)
+#define FREE_APP_LOCK(app)
+
+#define WIDGET_TO_APPCON(w)
+#define DPY_TO_APPCON(d)
+
+#endif /* !defined(XTHREADS) */
+#endif /* _XtThreadsI_h */
diff --git a/nx-X11/lib/Xt/TranslateI.h b/nx-X11/lib/Xt/TranslateI.h
new file mode 100644
index 000000000..122487523
--- /dev/null
+++ b/nx-X11/lib/Xt/TranslateI.h
@@ -0,0 +1,606 @@
+/* $Xorg: TranslateI.h,v 1.4 2001/02/09 02:03:59 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/TranslateI.h,v 1.3 2001/12/14 19:56:32 dawes Exp $ */
+
+/*
+ * TranslateI.h - Header file private to translation management
+ *
+ * Author: Gabe Beged-Dov, HP
+ *
+ * Former Author: Charles Haynes
+ * Digital Equipment Corporation
+ * Western Research Laboratory
+ * Date: Sat Aug 29 1987
+ */
+
+/*#define REFCNT_TRANSLATIONS*/
+#define CACHE_TRANSLATIONS
+
+#define TM_NO_MATCH (-2)
+
+#define _XtRStateTablePair "_XtStateTablePair"
+
+typedef unsigned char TMByteCard;
+typedef unsigned short TMShortCard;
+typedef unsigned long TMLongCard;
+typedef short TMShortInt;
+
+typedef struct _TMTypeMatchRec *TMTypeMatch;
+typedef struct _TMModifierMatchRec *TMModifierMatch;
+typedef struct _TMEventRec *TMEventPtr;
+
+typedef Boolean (*MatchProc)(TMTypeMatch typeMatch,
+ TMModifierMatch modMatch,
+ TMEventPtr eventSeq);
+
+typedef struct _ModToKeysymTable {
+ Modifiers mask;
+ int count;
+ int idx;
+} ModToKeysymTable;
+
+typedef struct _LateBindings {
+ unsigned int knot:1;
+ unsigned int pair:1;
+ unsigned short ref_count; /* garbage collection */
+ KeySym keysym;
+} LateBindings, *LateBindingsPtr;
+
+typedef short ModifierMask;
+
+typedef struct _ActionsRec *ActionPtr;
+typedef struct _ActionsRec {
+ int idx; /* index into quarkTable to find proc */
+ String *params; /* pointer to array of params */
+ Cardinal num_params; /* number of params */
+ ActionPtr next; /* next action to perform */
+} ActionRec;
+
+typedef struct _XtStateRec *StatePtr;
+typedef struct _XtStateRec {
+ unsigned int isCycleStart:1;
+ unsigned int isCycleEnd:1;
+ TMShortCard typeIndex;
+ TMShortCard modIndex;
+ ActionPtr actions; /* rhs list of actions to perform */
+ StatePtr nextLevel;
+}StateRec;
+
+
+#define XtTableReplace 0
+#define XtTableAugment 1
+#define XtTableOverride 2
+#define XtTableUnmerge 3
+
+typedef unsigned int _XtTranslateOp;
+
+/*
+ * New Definitions
+ */
+typedef struct _TMModifierMatchRec{
+ TMLongCard modifiers;
+ TMLongCard modifierMask;
+ LateBindingsPtr lateModifiers;
+ Boolean standard;
+}TMModifierMatchRec;
+
+typedef struct _TMTypeMatchRec{
+ TMLongCard eventType;
+ TMLongCard eventCode;
+ TMLongCard eventCodeMask;
+ MatchProc matchEvent;
+}TMTypeMatchRec;
+
+typedef struct _TMBranchHeadRec {
+ unsigned int isSimple:1;
+ unsigned int hasActions:1;
+ unsigned int hasCycles:1;
+ unsigned int more:13;
+ TMShortCard typeIndex;
+ TMShortCard modIndex;
+}TMBranchHeadRec, *TMBranchHead;
+
+/* NOTE: elements of this structure must match those of
+ * TMComplexStateTreeRec and TMParseStateTreeRec.
+ */
+typedef struct _TMSimpleStateTreeRec{
+ unsigned int isSimple:1;
+ unsigned int isAccelerator:1;
+ unsigned int mappingNotifyInterest:1;
+ unsigned int refCount:13;
+ TMShortCard numBranchHeads;
+ TMShortCard numQuarks; /* # of entries in quarkTbl */
+ TMShortCard unused; /* to ensure same alignment */
+ TMBranchHeadRec *branchHeadTbl;
+ XrmQuark *quarkTbl; /* table of quarkified rhs*/
+}TMSimpleStateTreeRec, *TMSimpleStateTree;
+
+/* NOTE: elements of this structure must match those of
+ * TMSimpleStateTreeRec and TMParseStateTreeRec.
+ */
+typedef struct _TMComplexStateTreeRec{
+ unsigned int isSimple:1;
+ unsigned int isAccelerator:1;
+ unsigned int mappingNotifyInterest:1;
+ unsigned int refCount:13;
+ TMShortCard numBranchHeads;
+ TMShortCard numQuarks; /* # of entries in quarkTbl */
+ TMShortCard numComplexBranchHeads;
+ TMBranchHeadRec *branchHeadTbl;
+ XrmQuark *quarkTbl; /* table of quarkified rhs*/
+ StatePtr *complexBranchHeadTbl;
+}TMComplexStateTreeRec, *TMComplexStateTree;
+
+/* NOTE: elements of this structure must match those of
+ * TMSimpleStateTreeRec and TMComplexStateTreeRec.
+ */
+typedef struct _TMParseStateTreeRec{
+ unsigned int isSimple:1;
+ unsigned int isAccelerator:1;
+ unsigned int mappingNotifyInterest:1;
+ unsigned int isStackQuarks:1;
+ unsigned int isStackBranchHeads:1;
+ unsigned int isStackComplexBranchHeads:1;
+ unsigned int unused:10; /* to ensure correct alignment */
+ TMShortCard numBranchHeads;
+ TMShortCard numQuarks; /* # of entries in quarkTbl */
+ TMShortCard numComplexBranchHeads;
+ TMBranchHeadRec *branchHeadTbl;
+ XrmQuark *quarkTbl; /* table of quarkified rhs*/
+ StatePtr *complexBranchHeadTbl;
+ TMShortCard branchHeadTblSize;
+ TMShortCard quarkTblSize; /*total size of quarkTbl */
+ TMShortCard complexBranchHeadTblSize;
+ StatePtr head;
+}TMParseStateTreeRec, *TMParseStateTree;
+
+typedef union _TMStateTreeRec{
+ TMSimpleStateTreeRec simple;
+ TMParseStateTreeRec parse;
+ TMComplexStateTreeRec complex;
+}*TMStateTree, **TMStateTreePtr, **TMStateTreeList;
+
+typedef struct _TMSimpleBindProcsRec {
+ XtActionProc *procs;
+}TMSimpleBindProcsRec, *TMSimpleBindProcs;
+
+typedef struct _TMComplexBindProcsRec {
+ Widget widget; /*widgetID to pass to action Proc*/
+ XtTranslations aXlations;
+ XtActionProc *procs;
+}TMComplexBindProcsRec, *TMComplexBindProcs;
+
+typedef struct _TMSimpleBindDataRec {
+ unsigned int isComplex:1; /* must be first */
+ TMSimpleBindProcsRec bindTbl[1]; /* variable length */
+}TMSimpleBindDataRec, *TMSimpleBindData;
+
+typedef struct _TMComplexBindDataRec {
+ unsigned int isComplex:1; /* must be first */
+ struct _ATranslationData *accel_context; /* for GetValues */
+ TMComplexBindProcsRec bindTbl[1]; /* variable length */
+}TMComplexBindDataRec, *TMComplexBindData;
+
+typedef union _TMBindDataRec{
+ TMSimpleBindDataRec simple;
+ TMComplexBindDataRec complex;
+}*TMBindData;
+
+typedef struct _TranslationData{
+ unsigned char hasBindings; /* must be first */
+ unsigned char operation; /*replace,augment,override*/
+ TMShortCard numStateTrees;
+ struct _TranslationData *composers[2];
+ EventMask eventMask;
+ TMStateTree stateTreeTbl[1]; /* variable length */
+}TranslationData;
+
+/*
+ * ATranslations is returned by GetValues for translations that contain
+ * accelerators. The TM can differentiate between this and TranslationData
+ * (that don't have a bindTbl) by looking at the first field (hasBindings)
+ * of either structure. All ATranslationData structures associated with a
+ * widget are chained off the BindData record of the widget.
+ */
+typedef struct _ATranslationData{
+ unsigned char hasBindings; /* must be first */
+ unsigned char operation;
+ struct _TranslationData *xlations; /* actual translations */
+ struct _ATranslationData *next; /* chain the contexts together */
+ TMComplexBindProcsRec bindTbl[1]; /* accelerator bindings */
+}ATranslationData, *ATranslations;
+
+typedef struct _TMConvertRec {
+ XtTranslations old; /* table to merge into */
+ XtTranslations new; /* table to merge from */
+} TMConvertRec;
+
+#define _XtEventTimerEventType ((TMLongCard)~0L)
+#define KeysymModMask (1L<<27) /* private to TM */
+#define AnyButtonMask (1L<<28) /* private to TM */
+
+typedef struct _EventRec {
+ TMLongCard modifiers;
+ TMLongCard modifierMask;
+ LateBindingsPtr lateModifiers;
+ TMLongCard eventType;
+ TMLongCard eventCode;
+ TMLongCard eventCodeMask;
+ MatchProc matchEvent;
+ Boolean standard;
+} Event;
+
+typedef struct _EventSeqRec *EventSeqPtr;
+typedef struct _EventSeqRec {
+ Event event; /* X event description */
+ StatePtr state; /* private to state table builder */
+ EventSeqPtr next; /* next event on line */
+ ActionPtr actions; /* r.h.s. list of actions to perform */
+} EventSeqRec;
+
+typedef EventSeqRec EventRec;
+typedef EventSeqPtr EventPtr;
+
+typedef struct _TMEventRec {
+ XEvent *xev;
+ Event event;
+}TMEventRec;
+
+typedef struct _ActionHookRec {
+ struct _ActionHookRec* next; /* must remain first */
+ XtAppContext app;
+ XtActionHookProc proc;
+ XtPointer closure;
+} ActionHookRec, *ActionHook;
+
+/* choose a number between 2 and 8 */
+#define TMKEYCACHELOG2 6
+#define TMKEYCACHESIZE (1<<TMKEYCACHELOG2)
+
+typedef struct _KeyCacheRec {
+ unsigned char modifiers_return[256]; /* constant per KeyCode, key proc */
+ KeyCode keycode[TMKEYCACHESIZE];
+ unsigned char modifiers[TMKEYCACHESIZE];
+ KeySym keysym[TMKEYCACHESIZE];
+} TMKeyCache;
+
+typedef struct _TMKeyContextRec {
+ XEvent *event;
+ unsigned long serial;
+ KeySym keysym;
+ Modifiers modifiers;
+ TMKeyCache keycache; /* keep this last, to keep offsets to others small */
+} TMKeyContextRec, *TMKeyContext;
+
+typedef struct _TMGlobalRec{
+ TMTypeMatchRec **typeMatchSegmentTbl;
+ TMShortCard numTypeMatches;
+ TMShortCard numTypeMatchSegments;
+ TMShortCard typeMatchSegmentTblSize;
+ TMModifierMatchRec **modMatchSegmentTbl;
+ TMShortCard numModMatches;
+ TMShortCard numModMatchSegments;
+ TMShortCard modMatchSegmentTblSize;
+ Boolean newMatchSemantics;
+#ifdef TRACE_TM
+ XtTranslations *tmTbl;
+ TMShortCard numTms;
+ TMShortCard tmTblSize;
+ struct _TMBindCacheRec **bindCacheTbl;
+ TMShortCard numBindCache;
+ TMShortCard bindCacheTblSize;
+ TMShortCard numLateBindings;
+ TMShortCard numBranchHeads;
+ TMShortCard numComplexStates;
+ TMShortCard numComplexActions;
+#endif /* TRACE_TM */
+}TMGlobalRec;
+
+extern TMGlobalRec _XtGlobalTM;
+
+#define TM_MOD_SEGMENT_SIZE 16
+#define TM_TYPE_SEGMENT_SIZE 16
+
+#define TMGetTypeMatch(idx) \
+ ((TMTypeMatch) \
+ &((_XtGlobalTM.typeMatchSegmentTbl[((idx) >> 4)])[(idx) & 15]))
+#define TMGetModifierMatch(idx) \
+ ((TMModifierMatch) \
+ &((_XtGlobalTM.modMatchSegmentTbl[(idx) >> 4])[(idx) & 15]))
+
+/* Useful Access Macros */
+#define TMNewMatchSemantics() (_XtGlobalTM.newMatchSemantics)
+#define TMBranchMore(branch) (branch->more)
+#define TMComplexBranchHead(tree, br) \
+ (((TMComplexStateTree)tree)->complexBranchHeadTbl[TMBranchMore(br)])
+
+#define TMGetComplexBindEntry(bindData, idx) \
+ ((TMComplexBindProcs)&(((TMComplexBindData)bindData)->bindTbl[idx]))
+
+#define TMGetSimpleBindEntry(bindData, idx) \
+ ((TMSimpleBindProcs)&(((TMSimpleBindData)bindData)->bindTbl[idx]))
+
+
+#define _InitializeKeysymTables(dpy, pd) \
+ if (pd->keysyms == NULL) \
+ _XtBuildKeysymTables(dpy, pd)
+
+/*
+ * Internal Functions
+ */
+
+extern void _XtPopup(
+ Widget /* widget */,
+ XtGrabKind /* grab_kind */,
+ _XtBoolean /* spring_loaded */
+);
+
+extern String _XtPrintXlations(
+ Widget /* w */,
+ XtTranslations /* xlations */,
+ Widget /* accelWidget */,
+ _XtBoolean /* includeRHS */
+);
+
+extern void _XtRegisterGrabs(
+ Widget /* widget */
+);
+
+extern XtPointer _XtInitializeActionData(
+ struct _XtActionsRec * /* actions */,
+ Cardinal /* count */,
+ _XtBoolean /* inPlace */
+);
+
+extern void _XtAddEventSeqToStateTree(
+ EventSeqPtr /* eventSeq */,
+ TMParseStateTree /* stateTree */
+);
+
+extern Boolean _XtMatchUsingStandardMods(
+ TMTypeMatch /* typeMatch */,
+ TMModifierMatch /* modMatch */,
+ TMEventPtr /* eventSeq */
+);
+
+extern Boolean _XtMatchUsingDontCareMods(
+ TMTypeMatch /* typeMatch */,
+ TMModifierMatch /* modMatch */,
+ TMEventPtr /* eventSeq */
+);
+
+extern Boolean _XtRegularMatch(
+ TMTypeMatch /* typeMatch */,
+ TMModifierMatch /* modMatch */,
+ TMEventPtr /* eventSeq */
+);
+
+extern Boolean _XtMatchAtom(
+ TMTypeMatch /* typeMatch */,
+ TMModifierMatch /* modMatch */,
+ TMEventPtr /* eventSeq */
+);
+
+extern void _XtTranslateEvent(
+ Widget /* widget */,
+ XEvent* /* event */
+);
+
+#include "CallbackI.h"
+#include "EventI.h"
+#include "HookObjI.h"
+#include "PassivGraI.h"
+#include "ThreadsI.h"
+#include "InitialI.h"
+#include "ResourceI.h"
+#include "StringDefs.h"
+
+extern void _XtBuildKeysymTables(Display *dpy, XtPerDisplay pd);
+
+#ifndef NO_MIT_HACKS
+extern void _XtDisplayTranslations(
+ Widget /* widget */,
+ XEvent* /* event */,
+ String* /* params */,
+ Cardinal* /* num_params */
+);
+
+extern void _XtDisplayAccelerators(
+ Widget /* widget */,
+ XEvent* /* event */,
+ String* /* params */,
+ Cardinal* /* num_params */
+);
+
+extern void _XtDisplayInstalledAccelerators(
+ Widget /* widget */,
+ XEvent* /* event */,
+ String* /* params */,
+ Cardinal* /* num_params */
+);
+#endif /* ifndef NO_MIT_HACKS */
+
+extern void _XtPopupInitialize(
+ XtAppContext /* app_context */
+);
+
+extern void _XtBindActions(
+ Widget /* widget */,
+ XtTM /* tm_rec */
+);
+
+extern Boolean _XtComputeLateBindings(
+ Display* /* dpy */,
+ LateBindingsPtr /* lateModifiers */,
+ Modifiers* /* computed */,
+ Modifiers* /* computedMask */
+);
+
+extern XtTranslations _XtCreateXlations(
+ TMStateTree * /* stateTrees */,
+ TMShortCard /* numStateTrees */,
+ XtTranslations /* first */,
+ XtTranslations /* second */
+);
+
+extern Boolean _XtCvtMergeTranslations(
+ Display* /* dpy */,
+ XrmValuePtr /* args */,
+ Cardinal* /* num_args */,
+ XrmValuePtr /* from */,
+ XrmValuePtr /* to */,
+ XtPointer* /* closure_ret */
+);
+
+void _XtRemoveStateTreeByIndex(
+ XtTranslations /* xlations */,
+ TMShortCard /* i */);
+
+void _XtFreeTranslations(
+ XtAppContext /* app */,
+ XrmValuePtr /* toVal */,
+ XtPointer /* closure */,
+ XrmValuePtr /* args */,
+ Cardinal* /* num_args */
+);
+
+extern TMShortCard _XtGetModifierIndex(
+ Event* /* event */
+);
+
+extern TMShortCard _XtGetQuarkIndex(
+ TMParseStateTree /* stateTreePtr */,
+ XrmQuark /* quark */
+);
+
+extern XtTranslations _XtGetTranslationValue(
+ Widget /* widget */
+);
+
+extern TMShortCard _XtGetTypeIndex(
+ Event* /* event */
+);
+
+extern void _XtGrabInitialize(
+ XtAppContext /* app */
+);
+
+extern void _XtInstallTranslations(
+ Widget /* widget */
+);
+
+extern void _XtRemoveTranslations(
+ Widget /* widget */
+);
+
+extern void _XtDestroyTMData(
+ Widget /* widget */
+);
+
+extern void _XtMergeTranslations(
+ Widget /* widget */,
+ XtTranslations /* newXlations */,
+ _XtTranslateOp /* operation */
+);
+
+extern void _XtActionInitialize(
+ XtAppContext /* app */
+);
+
+extern TMStateTree _XtParseTreeToStateTree(
+ TMParseStateTree /* parseTree */
+);
+
+extern String _XtPrintActions(
+ ActionRec* /* actions */,
+ XrmQuark* /* quarkTbl */
+);
+
+extern String _XtPrintState(
+ TMStateTree /* stateTree */,
+ TMBranchHead /* branchHead */);
+
+extern String _XtPrintEventSeq(
+ EventSeqPtr /* eventSeq */,
+ Display* /* dpy */
+);
+
+typedef Boolean (*_XtTraversalProc)(
+ StatePtr /* state */,
+ XtPointer /* data */
+);
+
+extern void _XtTraverseStateTree(
+ TMStateTree /* tree */,
+ _XtTraversalProc /* func */,
+ XtPointer /* data */
+);
+
+extern void _XtTranslateInitialize(
+ void
+);
+
+extern void _XtAddTMConverters(
+ ConverterTable /* table */
+);
+
+extern void _XtUnbindActions(
+ Widget /* widget */,
+ XtTranslations /* xlations */,
+ TMBindData /* bindData */
+);
+
+extern void _XtUnmergeTranslations(
+ Widget /* widget */,
+ XtTranslations /* xlations */
+);
+
+/* TMKey.c */
+extern void _XtAllocTMContext(XtPerDisplay pd);
+
diff --git a/nx-X11/lib/Xt/VarCreate.c b/nx-X11/lib/Xt/VarCreate.c
new file mode 100644
index 000000000..b3761e8b8
--- /dev/null
+++ b/nx-X11/lib/Xt/VarCreate.c
@@ -0,0 +1,399 @@
+/* $Xorg: VarCreate.c,v 1.4 2001/02/09 02:03:59 xorgcvs Exp $ */
+
+/*
+
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, CA.
+
+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 Sun not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+Sun makes no representations about the suitability of
+this software for any purpose. It is provided "as is"
+without express or implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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 1885, 1986, 1987, 1988, 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/VarCreate.c,v 3.6 2001/08/22 22:52:20 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+#include "Shell.h"
+#include "VarargsI.h"
+#include "CreateI.h"
+
+#if (defined(SUNSHLIB) || defined(AIXSHLIB)) && defined(SHAREDCODE)
+#define XtToolkitInitialize _XtToolkitInitialize
+#endif /* (SUNSHLIB || AIXSHLIB) && SHAREDCODE */
+
+static Widget
+_XtVaCreateWidget(
+ String name,
+ WidgetClass widget_class,
+ Widget parent,
+ va_list var,
+ int count)
+{
+ register Widget widget;
+ XtTypedArgList typed_args = NULL;
+ Cardinal num_args;
+
+ _XtVaToTypedArgList(var, count, &typed_args, &num_args);
+
+ widget = _XtCreateWidget(name, widget_class, parent, (ArgList)NULL,
+ (Cardinal)0, typed_args, num_args);
+
+ if (typed_args != NULL) {
+ XtFree((XtPointer)typed_args);
+ }
+
+ return widget;
+}
+
+
+Widget
+XtVaCreateWidget(
+ _Xconst char* name,
+ WidgetClass widget_class,
+ Widget parent,
+ ...)
+{
+ va_list var;
+ register Widget widget;
+ int total_count, typed_count;
+ WIDGET_TO_APPCON(parent);
+
+ LOCK_APP(app);
+ va_start(var,parent);
+ _XtCountVaList(var, &total_count, &typed_count);
+ va_end(var);
+
+ va_start(var,parent);
+ widget = _XtVaCreateWidget((String)name, widget_class, parent, var,
+ total_count);
+ va_end(var);
+ UNLOCK_APP(app);
+ return widget;
+}
+
+
+Widget
+XtVaCreateManagedWidget(
+ _Xconst char* name,
+ WidgetClass widget_class,
+ Widget parent,
+ ...)
+{
+ va_list var;
+ register Widget widget;
+ int total_count, typed_count;
+ WIDGET_TO_APPCON(parent);
+
+ LOCK_APP(app);
+ va_start(var,parent);
+ _XtCountVaList(var, &total_count, &typed_count);
+ va_end(var);
+
+ va_start(var,parent);
+ widget = _XtVaCreateWidget((String)name, widget_class, parent, var,
+ total_count);
+ XtManageChild(widget);
+ va_end(var);
+ UNLOCK_APP(app);
+ return widget;
+}
+
+
+Widget
+XtVaAppCreateShell(
+ _Xconst char* name,
+ _Xconst char* class,
+ WidgetClass widget_class,
+ Display* display,
+ ...)
+{
+ va_list var;
+ register Widget widget;
+ XtTypedArgList typed_args = NULL;
+ Cardinal num_args;
+ int total_count, typed_count;
+ DPY_TO_APPCON(display);
+
+ LOCK_APP(app);
+ va_start(var,display);
+ _XtCountVaList(var, &total_count, &typed_count);
+ va_end(var);
+
+ va_start(var,display);
+
+ _XtVaToTypedArgList(var, total_count, &typed_args, &num_args);
+ widget = _XtAppCreateShell((String)name, (String)class, widget_class,
+ display, (ArgList)NULL, (Cardinal)0, typed_args, num_args);
+ if (typed_args != NULL) {
+ XtFree((XtPointer)typed_args);
+ }
+
+ va_end(var);
+ UNLOCK_APP(app);
+ return widget;
+}
+
+
+Widget
+XtVaCreatePopupShell(
+ _Xconst char* name,
+ WidgetClass widget_class,
+ Widget parent,
+ ...)
+{
+ va_list var;
+ register Widget widget;
+ XtTypedArgList typed_args = NULL;
+ Cardinal num_args;
+ int total_count, typed_count;
+ WIDGET_TO_APPCON(parent);
+
+ LOCK_APP(app);
+ va_start(var,parent);
+ _XtCountVaList(var, &total_count, &typed_count);
+ va_end(var);
+
+ va_start(var,parent);
+
+ _XtVaToTypedArgList(var, total_count, &typed_args, &num_args);
+ widget = _XtCreatePopupShell((String)name, widget_class, parent,
+ (ArgList)NULL, (Cardinal)0, typed_args, num_args);
+ if (typed_args != NULL) {
+ XtFree((XtPointer)typed_args);
+ }
+
+ va_end(var);
+ UNLOCK_APP(app);
+ return widget;
+}
+
+void
+XtVaSetValues(Widget widget, ...)
+{
+ va_list var;
+ ArgList args = NULL;
+ Cardinal num_args;
+ int total_count, typed_count;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ va_start(var,widget);
+ _XtCountVaList(var, &total_count, &typed_count);
+ va_end(var);
+
+ va_start(var,widget);
+
+ _XtVaToArgList(widget, var, total_count, &args, &num_args);
+ XtSetValues(widget, args, num_args);
+ _XtFreeArgList(args, total_count, typed_count);
+
+ UNLOCK_APP(app);
+ va_end(var);
+}
+
+
+void
+XtVaSetSubvalues(XtPointer base, XtResourceList resources, Cardinal num_resources, ...)
+{
+ va_list var;
+ ArgList args;
+ Cardinal num_args;
+ int total_count, typed_count;
+
+ va_start(var, num_resources);
+ _XtCountVaList(var, &total_count, &typed_count);
+ va_end(var);
+
+ if (typed_count != 0) {
+ XtWarning("XtVaTypedArg is not valid in XtVaSetSubvalues()\n");
+ }
+
+ va_start(var, num_resources);
+ _XtVaToArgList((Widget)NULL, var, total_count, &args, &num_args);
+
+ XtSetSubvalues(base, resources, num_resources, args, num_args);
+
+ if (num_args != 0) {
+ XtFree((XtPointer)args);
+ }
+
+ va_end(var);
+}
+
+Widget
+_XtVaOpenApplication(
+ XtAppContext *app_context_return,
+ _Xconst char* application_class,
+ XrmOptionDescList options,
+ Cardinal num_options,
+ int *argc_in_out,
+ String *argv_in_out,
+ String *fallback_resources,
+ WidgetClass widget_class,
+ va_list var_args)
+{
+ XtAppContext app_con;
+ Display * dpy;
+ register int saved_argc = *argc_in_out;
+ Widget root;
+ String attr;
+ int count = 0;
+ XtTypedArgList typed_args;
+
+ XtToolkitInitialize(); /* cannot be moved into _XtAppInit */
+
+ dpy = _XtAppInit(&app_con, (String)application_class, options, num_options,
+ argc_in_out, &argv_in_out, fallback_resources);
+
+ typed_args = (XtTypedArgList) __XtMalloc((unsigned) sizeof(XtTypedArg));
+ attr = va_arg (var_args, String);
+ for(; attr != NULL; attr = va_arg (var_args, String)) {
+ if (strcmp(attr, XtVaTypedArg) == 0) {
+ typed_args[count].name = va_arg(var_args, String);
+ typed_args[count].type = va_arg(var_args, String);
+ typed_args[count].value = va_arg(var_args, XtArgVal);
+ typed_args[count].size = va_arg(var_args, int);
+ } else {
+ typed_args[count].name = attr;
+ typed_args[count].type = NULL;
+ typed_args[count].value = va_arg(var_args, XtArgVal);
+ typed_args[count].size = 0;
+ }
+ count++;
+ typed_args = (XtTypedArgList)
+ XtRealloc((char *) typed_args,
+ (unsigned) (count + 1) * sizeof(XtTypedArg));
+ }
+ typed_args[count].name = NULL;
+
+ va_end (var_args);
+
+ root =
+ XtVaAppCreateShell( NULL, application_class,
+ widget_class, dpy,
+ XtNscreen, (XtArgVal)DefaultScreenOfDisplay(dpy),
+ XtNargc, (XtArgVal)saved_argc,
+ XtNargv, (XtArgVal)argv_in_out,
+ XtVaNestedList, (XtVarArgsList)typed_args,
+ NULL );
+
+ if (app_context_return != NULL)
+ *app_context_return = app_con;
+
+ XtFree((XtPointer)typed_args);
+ XtFree((XtPointer)argv_in_out);
+ return(root);
+}
+
+Widget
+_XtVaAppInitialize(
+ XtAppContext *app_context_return,
+ _Xconst char* application_class,
+ XrmOptionDescList options,
+ Cardinal num_options,
+ int *argc_in_out,
+ String *argv_in_out,
+ String *fallback_resources,
+ va_list var_args)
+{
+ return _XtVaOpenApplication(app_context_return, application_class,
+ options, num_options,
+ argc_in_out, argv_in_out, fallback_resources,
+ applicationShellWidgetClass, var_args);
+}
+
+#if !((defined(SUNSHLIB) || defined(AIXSHLIB)) && defined(SHAREDCODE))
+
+/*
+ * If not used as a shared library, we still need a front end to
+ * _XtVaOpenApplication and to _XtVaAppInitialize.
+ */
+
+Widget
+XtVaOpenApplication(
+ XtAppContext *app_context_return,
+ _Xconst char* application_class,
+ XrmOptionDescList options,
+ Cardinal num_options,
+ int *argc_in_out,
+ String *argv_in_out,
+ String *fallback_resources,
+ WidgetClass widget_class,
+ ...)
+{
+ va_list var;
+
+ va_start(var, widget_class);
+ return _XtVaOpenApplication(app_context_return, (String)application_class,
+ options, num_options, argc_in_out, argv_in_out,
+ fallback_resources, widget_class, var);
+}
+
+Widget
+XtVaAppInitialize(
+ XtAppContext *app_context_return,
+ _Xconst char* application_class,
+ XrmOptionDescList options,
+ Cardinal num_options,
+ int *argc_in_out,
+ String *argv_in_out,
+ String *fallback_resources,
+ ...)
+{
+ va_list var;
+
+ va_start(var, fallback_resources);
+ return _XtVaOpenApplication(app_context_return, (String)application_class,
+ options, num_options, argc_in_out, argv_in_out,
+ fallback_resources,
+ applicationShellWidgetClass, var);
+}
+
+#endif /* !((SUNSHLIB || AIXSHLIB) && SHAREDCODE) */
+
diff --git a/nx-X11/lib/Xt/VarGet.c b/nx-X11/lib/Xt/VarGet.c
new file mode 100644
index 000000000..cdb425a71
--- /dev/null
+++ b/nx-X11/lib/Xt/VarGet.c
@@ -0,0 +1,317 @@
+/* $Xorg: VarGet.c,v 1.4 2001/02/09 02:03:59 xorgcvs Exp $ */
+/*
+
+Copyright 1993 by Sun Microsystems, Inc. Mountain View, CA.
+
+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 Sun not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+Sun makes no representations about the suitability of
+this software for any purpose. It is provided "as is"
+without express or implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE 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 1985, 1986, 1987, 1988, 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.
+
+*/
+/* $XFree86: xc/lib/Xt/VarGet.c,v 1.7 2001/07/29 05:01:12 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "VarargsI.h"
+#include "StringDefs.h"
+
+static String XtNxtGetTypedArg = "xtGetTypedArg";
+
+void
+XtVaGetSubresources(
+ Widget widget,
+ XtPointer base,
+ _Xconst char* name,
+ _Xconst char* class,
+ XtResourceList resources,
+ Cardinal num_resources,
+ ...)
+{
+ va_list var;
+ XtTypedArgList args;
+ Cardinal num_args;
+ int total_count, typed_count;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ va_start(var, num_resources);
+ _XtCountVaList(var, &total_count, &typed_count);
+ va_end(var);
+
+ va_start(var, num_resources);
+
+ _XtVaToTypedArgList(var, total_count, &args, &num_args);
+
+ _XtGetSubresources(widget, base, name, class, resources, num_resources,
+ NULL, 0, args, num_args);
+
+ if (num_args != 0) {
+ XtFree((XtPointer)args);
+ }
+
+ va_end(var);
+ UNLOCK_APP(app);
+}
+
+
+void
+XtVaGetApplicationResources(Widget widget, XtPointer base, XtResourceList resources, Cardinal num_resources, ...)
+{
+ va_list var;
+ XtTypedArgList args;
+ Cardinal num_args;
+ int total_count, typed_count;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ va_start(var,num_resources);
+ _XtCountVaList(var, &total_count, &typed_count);
+ va_end(var);
+
+ va_start(var,num_resources);
+
+ _XtVaToTypedArgList(var, total_count, &args, &num_args);
+
+ _XtGetApplicationResources(widget, base, resources, num_resources,
+ NULL, 0, args, num_args);
+
+ if (num_args != 0) {
+ XtFree((XtPointer)args);
+ }
+
+ va_end(var);
+ UNLOCK_APP(app);
+}
+
+
+static void
+GetTypedArg(
+ Widget widget,
+ XtTypedArgList typed_arg,
+ XtResourceList resources,
+ Cardinal num_resources)
+{
+ String from_type = NULL;
+ Cardinal from_size = 0;
+ XrmValue from_val, to_val;
+ register Cardinal i;
+ Arg arg;
+ XtPointer value;
+
+ /* note we presume that the XtResourceList to be un-compiled */
+
+ for (i = 0; i < num_resources; i++) {
+ if (StringToName(typed_arg->name) == StringToName(resources[i].resource_name)) {
+ from_type = resources[i].resource_type;
+ from_size = resources[i].resource_size;
+ break;
+ }
+ }
+
+ if (i == num_resources) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "unknownType", XtNxtGetTypedArg, XtCXtToolkitError,
+ "Unable to find type of resource for conversion",
+ (String *)NULL, (Cardinal *)NULL);
+ return;
+ }
+
+ value = ALLOCATE_LOCAL(from_size);
+ if (value == NULL) _XtAllocError(NULL);
+ XtSetArg(arg, typed_arg->name, value);
+ XtGetValues(widget, &arg, 1);
+
+ from_val.size = from_size;
+ from_val.addr = (XPointer)value;
+ to_val.addr = (XPointer)typed_arg->value;
+ to_val.size = typed_arg->size;
+
+ if (!XtConvertAndStore(widget, from_type, &from_val,
+ typed_arg->type, &to_val)) {
+ if (to_val.size > (unsigned) typed_arg->size) {
+ String params[2];
+ Cardinal num_params = 2;
+ params[0] = typed_arg->type;
+ params[1] = XtName(widget);
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "insufficientSpace", XtNxtGetTypedArg, XtCXtToolkitError,
+ "Insufficient space for converted type '%s' in widget '%s'",
+ params, &num_params);
+ }
+ else {
+ String params[3];
+ Cardinal num_params = 3;
+ params[0] = from_type;
+ params[1] = typed_arg->type;
+ params[2] = XtName(widget);
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "conversionFailed", XtNxtGetTypedArg, XtCXtToolkitError,
+ "Type conversion (%s to %s) failed for widget '%s'",
+ params, &num_params);
+ }
+ }
+ DEALLOCATE_LOCAL(value);
+}
+
+static int
+GetNestedArg(
+ Widget widget,
+ XtTypedArgList avlist,
+ ArgList args,
+ XtResourceList resources,
+ Cardinal num_resources)
+{
+ int count = 0;
+
+ for (; avlist->name != NULL; avlist++) {
+ if (avlist->type != NULL) {
+ GetTypedArg(widget, avlist, resources, num_resources);
+ } else if(strcmp(avlist->name, XtVaNestedList) == 0) {
+ count += GetNestedArg(widget, (XtTypedArgList)avlist->value,
+ args, resources, num_resources);
+ } else {
+ (args+count)->name = avlist->name;
+ (args+count)->value = avlist->value;
+ ++count;
+ }
+ }
+
+ return(count);
+}
+
+void
+XtVaGetValues(Widget widget, ...)
+{
+ va_list var;
+ String attr;
+ ArgList args;
+ XtTypedArg typed_arg;
+ XtResourceList resources = (XtResourceList)NULL;
+ Cardinal num_resources;
+ int count, total_count, typed_count;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+ va_start(var,widget);
+
+ _XtCountVaList(var, &total_count, &typed_count);
+
+ if (total_count != typed_count) {
+ args = (ArgList)__XtMalloc((unsigned)((total_count - typed_count)
+ * sizeof(Arg)));
+ }
+ else args = NULL; /* for lint; really unused */
+ va_end(var);
+
+ va_start(var,widget);
+ for(attr = va_arg(var, String), count = 0 ; attr != NULL;
+ attr = va_arg(var, String)) {
+ if (strcmp(attr, XtVaTypedArg) == 0) {
+ typed_arg.name = va_arg(var, String);
+ typed_arg.type = va_arg(var, String);
+ typed_arg.value = va_arg(var, XtArgVal);
+ typed_arg.size = va_arg(var, int);
+
+ if (resources == NULL) {
+ XtGetResourceList(XtClass(widget), &resources,&num_resources);
+ }
+
+ GetTypedArg(widget, &typed_arg, resources, num_resources);
+ } else if (strcmp(attr, XtVaNestedList) == 0) {
+ if (resources == NULL) {
+ XtGetResourceList(XtClass(widget),&resources, &num_resources);
+ }
+
+ count += GetNestedArg(widget, va_arg(var, XtTypedArgList),
+ (args+count), resources, num_resources);
+ } else {
+ args[count].name = attr;
+ args[count].value = va_arg(var, XtArgVal);
+ count ++;
+ }
+ }
+ va_end(var);
+
+ if (resources != (XtResourceList)NULL) {
+ XtFree((XtPointer)resources);
+ }
+
+ if (total_count != typed_count) {
+ XtGetValues(widget, args, count);
+ XtFree((XtPointer)args);
+ }
+ UNLOCK_APP(app);
+}
+
+void
+XtVaGetSubvalues(XtPointer base,XtResourceList resources, Cardinal num_resources, ...)
+{
+ va_list var;
+ ArgList args;
+ Cardinal num_args;
+ int total_count, typed_count;
+
+ va_start(var,num_resources);
+
+ _XtCountVaList(var, &total_count, &typed_count);
+
+ if (typed_count != 0) {
+ XtWarning("XtVaTypedArg is an invalid argument to XtVaGetSubvalues()\n");
+ }
+ va_end(var);
+
+ va_start(var,num_resources);
+ _XtVaToArgList((Widget)NULL, var, total_count, &args, &num_args);
+ va_end(var);
+
+ XtGetSubvalues(base, resources, num_resources, args, num_args);
+
+ if (num_args != 0) {
+ XtFree((XtPointer)args);
+ }
+}
diff --git a/nx-X11/lib/Xt/Varargs.c b/nx-X11/lib/Xt/Varargs.c
new file mode 100644
index 000000000..37d3c64db
--- /dev/null
+++ b/nx-X11/lib/Xt/Varargs.c
@@ -0,0 +1,519 @@
+/* $Xorg: Varargs.c,v 1.4 2001/02/09 02:03:59 xorgcvs Exp $ */
+
+/*
+
+Copyright 1985, 1986, 1987, 1988, 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/Varargs.c,v 3.10 2001/12/14 19:56:32 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "VarargsI.h"
+#include "StringDefs.h"
+
+static String XtNxtConvertVarToArgList = "xtConvertVarToArgList";
+
+/*
+ * Given a nested list, _XtCountNestedList() returns counts of the
+ * total number of attribute-value pairs and the count of those
+ * attributes that are typed. The list is counted recursively.
+ */
+static void
+_XtCountNestedList(
+ XtTypedArgList avlist,
+ int *total_count,
+ int *typed_count)
+{
+ for (; avlist->name != NULL; avlist++) {
+ if (strcmp(avlist->name, XtVaNestedList) == 0) {
+ _XtCountNestedList((XtTypedArgList)avlist->value, total_count,
+ typed_count);
+ } else {
+ if (avlist->type != NULL) {
+ ++(*typed_count);
+ }
+ ++(*total_count);
+ }
+ }
+}
+
+
+/*
+ * Given a variable length attribute-value list, _XtCountVaList()
+ * returns counts of the total number of attribute-value pairs,
+ * and the count of the number of those attributes that are typed.
+ * The list is counted recursively.
+ */
+void
+_XtCountVaList(va_list var, int* total_count, int* typed_count)
+{
+ String attr;
+
+ *total_count = 0;
+ *typed_count = 0;
+
+ for(attr = va_arg(var, String) ; attr != NULL;
+ attr = va_arg(var, String)) {
+ if (strcmp(attr, XtVaTypedArg) == 0) {
+ (void)va_arg(var, String);
+ (void)va_arg(var, String);
+ (void)va_arg(var, XtArgVal);
+ (void)va_arg(var, int);
+ ++(*total_count);
+ ++(*typed_count);
+ } else if (strcmp(attr, XtVaNestedList) == 0) {
+ _XtCountNestedList(va_arg(var, XtTypedArgList), total_count,
+ typed_count);
+ } else {
+ (void)va_arg(var, XtArgVal);
+ ++(*total_count);
+ }
+ }
+}
+
+
+/*
+ * Given a variable length attribute-value list, XtVaCreateArgsList()
+ * constructs an attribute-value list of type XtTypedArgList and
+ * returns the list.
+ */
+XtVarArgsList
+XtVaCreateArgsList(XtPointer unused, ...)
+{
+ va_list var;
+ XtTypedArgList avlist;
+ int count = 0;
+ String attr;
+
+ /*
+ * Count the number of attribute-value pairs in the list.
+ * Note: The count is required only to allocate enough space to store
+ * the list. Therefore nested lists are not counted recursively.
+ */
+ va_start(var,unused);
+ for(attr = va_arg(var, String) ; attr != NULL;
+ attr = va_arg(var, String)) {
+ ++count;
+ if (strcmp(attr, XtVaTypedArg) == 0) {
+ (void)va_arg(var, String);
+ (void)va_arg(var, String);
+ (void)va_arg(var, XtArgVal);
+ (void)va_arg(var, int);
+ } else {
+ (void)va_arg(var, XtArgVal);
+ }
+ }
+ va_end(var);
+
+ va_start(var,unused);
+ avlist = _XtVaCreateTypedArgList(var, count);
+ va_end(var);
+ return (XtVarArgsList)avlist;
+}
+
+
+XtTypedArgList _XtVaCreateTypedArgList(va_list var, register int count)
+{
+ String attr;
+ XtTypedArgList avlist;
+
+ avlist = (XtTypedArgList)
+ __XtCalloc((int)count + 1, (unsigned)sizeof(XtTypedArg));
+
+ for(attr = va_arg(var, String), count = 0; attr != NULL;
+ attr = va_arg(var, String)) {
+ if (strcmp(attr, XtVaTypedArg) == 0) {
+ avlist[count].name = va_arg(var, String);
+ avlist[count].type = va_arg(var, String);
+ avlist[count].value = va_arg(var, XtArgVal);
+ avlist[count].size = va_arg(var, int);
+ } else {
+ avlist[count].name = attr;
+ avlist[count].type = NULL;
+ avlist[count].value = va_arg(var, XtArgVal);
+ }
+ ++count;
+ }
+ avlist[count].name = NULL;
+
+ return avlist;
+}
+
+
+/*
+ * TypedArgToArg() invokes a resource converter to convert the
+ * passed typed arg into a name/value pair and stores the name/value
+ * pair in the passed Arg structure. If memory is allocated for the
+ * converted value, the address is returned in the value field of
+ * memory_return; otherwise that field is NULL. The function returns
+ * 1 if the conversion succeeded and 0 if the conversion failed.
+ */
+static int
+TypedArgToArg(
+ Widget widget,
+ XtTypedArgList typed_arg,
+ ArgList arg_return,
+ XtResourceList resources,
+ Cardinal num_resources,
+ ArgList memory_return)
+{
+ String to_type = NULL;
+ XrmValue from_val, to_val;
+
+
+ if (widget == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "nullWidget", XtNxtConvertVarToArgList, XtCXtToolkitError,
+ "XtVaTypedArg conversion needs non-NULL widget handle",
+ (String *)NULL, (Cardinal *)NULL);
+ return(0);
+ }
+
+ /* again we assume that the XtResourceList is un-compiled */
+
+ for (; num_resources--; resources++)
+ if (strcmp(typed_arg->name, resources->resource_name) == 0) {
+ to_type = resources->resource_type;
+ break;
+ }
+
+ if (to_type == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "unknownType", XtNxtConvertVarToArgList, XtCXtToolkitError,
+ "Unable to find type of resource for conversion",
+ (String *)NULL, (Cardinal *)NULL);
+ return(0);
+ }
+
+ to_val.addr = NULL;
+ from_val.size = typed_arg->size;
+ if ((strcmp(typed_arg->type, XtRString) == 0) ||
+ ((unsigned) typed_arg->size > sizeof(XtArgVal))) {
+ from_val.addr = (XPointer)typed_arg->value;
+ } else {
+ from_val.addr = (XPointer)&typed_arg->value;
+ }
+
+ LOCK_PROCESS;
+ XtConvertAndStore(widget, typed_arg->type, &from_val, to_type, &to_val);
+
+ if (to_val.addr == NULL) {
+ UNLOCK_PROCESS;
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
+ "conversionFailed", XtNxtConvertVarToArgList, XtCXtToolkitError,
+ "Type conversion failed", (String *)NULL, (Cardinal *)NULL);
+ return(0);
+ }
+
+ arg_return->name = typed_arg->name;
+ memory_return->value = (XtArgVal) NULL;
+
+ if (strcmp(to_type, XtRString) == 0) {
+ arg_return->value = (XtArgVal) to_val.addr;
+ }
+ else {
+ if (to_val.size == sizeof(long))
+ arg_return->value = (XtArgVal) *(long *)to_val.addr;
+ else if (to_val.size == sizeof(short))
+ arg_return->value = (XtArgVal) *(short *)to_val.addr;
+ else if (to_val.size == sizeof(char))
+ arg_return->value = (XtArgVal) *(char *)to_val.addr;
+ else if (to_val.size == sizeof(XtArgVal))
+ arg_return->value = *(XtArgVal *)to_val.addr;
+ else if (to_val.size > sizeof(XtArgVal)) {
+ arg_return->value = (XtArgVal) __XtMalloc(to_val.size);
+ memory_return->value = (XtArgVal)
+ memcpy((void *)arg_return->value, to_val.addr, to_val.size);
+ }
+ }
+ UNLOCK_PROCESS;
+
+ return(1);
+}
+
+
+/*
+ * NestedArgtoArg() converts the passed nested list into
+ * an ArgList/count.
+ */
+static int
+NestedArgtoArg(
+ Widget widget,
+ XtTypedArgList avlist,
+ ArgList args,
+ XtResourceList resources,
+ Cardinal num_resources,
+ ArgList memory_return)
+{
+ int count = 0;
+
+ for (; avlist->name != NULL; avlist++) {
+ if (avlist->type != NULL) {
+ /* If widget is NULL, the typed arg is ignored */
+ if (widget != NULL) {
+ /* this is a typed arg */
+ count += TypedArgToArg(widget, avlist, (args+count),
+ resources, num_resources,
+ (memory_return+count));
+ }
+ } else if (strcmp(avlist->name, XtVaNestedList) == 0) {
+ count += NestedArgtoArg(widget, (XtTypedArgList)avlist->value,
+ (args+count), resources, num_resources,
+ (memory_return+count));
+ } else {
+ (args+count)->name = avlist->name;
+ (args+count)->value = avlist->value;
+ ++count;
+ }
+ }
+
+ return(count);
+}
+
+/*
+ * Free memory allocated through _XtVaToArgList. The actual args array
+ * size is expected to be total_count * 2, where total_count is the number
+ * of elements needed for resource representations. The lower half of the
+ * array contains pairs of resource names and values as usual. For each
+ * element [n] in the lower half of the array, the value field of the
+ * corresponding element [n + total_count] in the upper half of the array
+ * has been pressed into service in order to note whether the resource value
+ * is a pointer to memory that was allocated in TypedArgToArg. In the
+ * upper half, if the value field is not NULL, it contains the address of
+ * memory which should now be freed. That memory could have been allocated
+ * only as a result of the conversion of typed arguments. Therefore, if
+ * there were no typed arguments in the original varargs, there is no need
+ * to examine the upper half of the array. In the choice of data structure
+ * to make this representation, priority was given to the wish to retrofit
+ * the release of memory around the existing signature of _XtVaToArgList.
+ */
+void
+_XtFreeArgList(
+ ArgList args, /* as returned by _XtVaToArgList */
+ int total_count, /* argument count returned by _XtCountVaList */
+ int typed_count) /* typed arg count returned by _XtCountVaList */
+{
+ ArgList p;
+
+ if (args) {
+ if (typed_count)
+ for (p = args + total_count; total_count--; ++p) {
+ if (p->value) XtFree((char *)p->value);
+ }
+ XtFree((char *)args);
+ }
+}
+
+
+static void GetResources(Widget widget, XtResourceList *res_list,
+ Cardinal *number);
+
+
+/*
+ * Given a variable argument list, _XtVaToArgList() returns the
+ * equivalent ArgList and count. _XtVaToArgList() handles nested
+ * lists and typed arguments. If typed arguments are present, the
+ * ArgList should be freed with _XtFreeArgList.
+ */
+void
+_XtVaToArgList(
+ Widget widget,
+ va_list var,
+ int max_count,
+ ArgList *args_return,
+ Cardinal *num_args_return)
+{
+ String attr;
+ int count;
+ ArgList args = (ArgList)NULL;
+ XtTypedArg typed_arg;
+ XtResourceList resources = (XtResourceList)NULL;
+ Cardinal num_resources;
+ Boolean fetched_resource_list = False;
+
+ if (max_count == 0) {
+ *num_args_return = 0;
+ *args_return = (ArgList)NULL;
+ return;
+ }
+
+ args = (ArgList)__XtMalloc((unsigned)(max_count * 2 * sizeof(Arg)));
+ for (count = max_count * 2; --count >= 0; )
+ args[count].value = (XtArgVal) NULL;
+ count = 0;
+
+ for(attr = va_arg(var, String) ; attr != NULL;
+ attr = va_arg(var, String)) {
+ if (strcmp(attr, XtVaTypedArg) == 0) {
+ typed_arg.name = va_arg(var, String);
+ typed_arg.type = va_arg(var, String);
+ typed_arg.value = va_arg(var, XtArgVal);
+ typed_arg.size = va_arg(var, int);
+
+ /* if widget is NULL, typed args are ignored */
+ if (widget != NULL) {
+ if (!fetched_resource_list) {
+ GetResources(widget, &resources, &num_resources);
+ fetched_resource_list = True;
+ }
+ count += TypedArgToArg(widget, &typed_arg, &args[count],
+ resources, num_resources,
+ &args[max_count + count]);
+ }
+ } else if (strcmp(attr, XtVaNestedList) == 0) {
+ if (widget != NULL) {
+ if (!fetched_resource_list) {
+ GetResources(widget, &resources, &num_resources);
+ fetched_resource_list = True;
+ }
+ }
+
+ count += NestedArgtoArg(widget, va_arg(var, XtTypedArgList),
+ &args[count], resources, num_resources,
+ &args[max_count + count]);
+ } else {
+ args[count].name = attr;
+ args[count].value = va_arg(var, XtArgVal);
+ count ++;
+ }
+ }
+
+ if (resources != NULL)
+ XtFree((XtPointer)resources);
+
+ *num_args_return = (Cardinal)count;
+ *args_return = (ArgList)args;
+}
+
+/* Function Name: GetResources
+ * Description: Retreives the normal and constraint resources
+ * for this widget.
+ * Arguments: widget - the widget.
+ * RETURNED res_list - the list of resource for this widget
+ * RETURNED number - the number of resources in the above list.
+ * Returns: none
+ */
+
+static void
+GetResources(
+ Widget widget,
+ XtResourceList * res_list,
+ Cardinal * number)
+{
+ Widget parent = XtParent(widget);
+
+ XtInitializeWidgetClass(XtClass(widget));
+ XtGetResourceList(XtClass(widget), res_list, number);
+
+ if (!XtIsShell(widget) && parent && XtIsConstraint(parent)) {
+ XtResourceList res, constraint, cons_top;
+ Cardinal num_constraint, temp;
+
+ XtGetConstraintResourceList(XtClass(parent), &constraint,
+ &num_constraint);
+
+ cons_top = constraint;
+ *res_list = (XtResourceList) XtRealloc((char*)*res_list,
+ ((*number + num_constraint) *
+ sizeof(XtResource)));
+
+ for (temp= num_constraint, res= *res_list + *number; temp != 0; temp--)
+ *res++ = *constraint++;
+
+ *number += num_constraint;
+ XtFree( (XtPointer) cons_top);
+ }
+}
+
+static int NestedArgtoTypedArg(
+ XtTypedArgList args,
+ XtTypedArgList avlist)
+{
+ int count = 0;
+
+ for (; avlist->name != NULL; avlist++) {
+ if (avlist->type != NULL) {
+ (args+count)->name = avlist->name;
+ (args+count)->type = avlist->type;
+ (args+count)->size = avlist->size;
+ (args+count)->value = avlist->value;
+ ++count;
+ } else if(strcmp(avlist->name, XtVaNestedList) == 0) {
+ count += NestedArgtoTypedArg((args+count),
+ (XtTypedArgList)avlist->value);
+ } else {
+ (args+count)->name = avlist->name;
+ (args+count)->type = NULL;
+ (args+count)->value = avlist->value;
+ ++count;
+ }
+ }
+ return(count);
+}
+
+
+/*
+ * Given a variable argument list, _XtVaToTypedArgList() returns
+ * the equivalent TypedArgList. _XtVaToTypedArgList() handles nested
+ * lists.
+ * Note: _XtVaToTypedArgList() does not do type conversions.
+ */
+void
+_XtVaToTypedArgList(
+ va_list var,
+ int max_count,
+ XtTypedArgList *args_return,
+ Cardinal *num_args_return)
+{
+ XtTypedArgList args = NULL;
+ String attr;
+ int count;
+
+ args = (XtTypedArgList)
+ __XtMalloc((unsigned)(max_count * sizeof(XtTypedArg)));
+
+ for(attr = va_arg(var, String), count = 0 ; attr != NULL;
+ attr = va_arg(var, String)) {
+ if (strcmp(attr, XtVaTypedArg) == 0) {
+ args[count].name = va_arg(var, String);
+ args[count].type = va_arg(var, String);
+ args[count].value = va_arg(var, XtArgVal);
+ args[count].size = va_arg(var, int);
+ ++count;
+ } else if (strcmp(attr, XtVaNestedList) == 0) {
+ count += NestedArgtoTypedArg(&args[count],
+ va_arg(var, XtTypedArgList));
+ } else {
+ args[count].name = attr;
+ args[count].type = NULL;
+ args[count].value = va_arg(var, XtArgVal);
+ ++count;
+ }
+ }
+
+ *args_return = args;
+ *num_args_return = count;
+}
diff --git a/nx-X11/lib/Xt/VarargsI.h b/nx-X11/lib/Xt/VarargsI.h
new file mode 100644
index 000000000..e15404aab
--- /dev/null
+++ b/nx-X11/lib/Xt/VarargsI.h
@@ -0,0 +1,65 @@
+/* $Xorg: VarargsI.h,v 1.4 2001/02/09 02:03:59 xorgcvs Exp $ */
+
+/*
+
+Copyright 1985, 1986, 1987, 1988, 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.
+
+*/
+/* $XFree86: xc/lib/Xt/VarargsI.h,v 3.6 2001/12/14 19:56:32 dawes Exp $ */
+
+#ifndef _VarargsI_h_
+#define _VarargsI_h_
+
+#include <stdarg.h>
+
+/* private routines */
+
+extern void _XtCountVaList(
+ va_list /*var*/, int* /*total_count*/, int* /*typed_count*/
+);
+
+extern void _XtVaToArgList(
+ Widget /*widget*/, va_list /*var*/, int /*max_count*/, ArgList* /*args_return*/, Cardinal* /*num_args_return*/
+);
+
+extern void _XtVaToTypedArgList(
+ va_list /*var*/, int /*count*/, XtTypedArgList* /*args_return*/, Cardinal* /*num_args_return*/
+);
+
+extern XtTypedArgList _XtVaCreateTypedArgList(
+ va_list /*var*/, int /*count*/
+);
+
+extern void _XtFreeArgList(
+ ArgList /*args*/, int /*total_count*/, int /*typed_count*/
+);
+
+extern void _XtGetApplicationResources(
+ Widget /*w*/, XtPointer /*base*/, XtResourceList /*resources*/, Cardinal /*num_resources*/, ArgList /*args*/, Cardinal /*num_args*/, XtTypedArgList /*typed_args*/, Cardinal /*num_typed_args*/
+);
+
+extern void _XtGetSubresources(
+ Widget /*w*/, XtPointer /*base*/, const char* /*name*/, const char* /*class*/, XtResourceList /*resources*/, Cardinal /*num_resources*/, ArgList /*args*/, Cardinal /*num_args*/, XtTypedArgList /*typed_args*/, Cardinal /*num_typed_args*/
+);
+
+#endif /* _VarargsI_h_ */
diff --git a/nx-X11/lib/Xt/Vendor.c b/nx-X11/lib/Xt/Vendor.c
new file mode 100644
index 000000000..42c289c16
--- /dev/null
+++ b/nx-X11/lib/Xt/Vendor.c
@@ -0,0 +1,159 @@
+/* $Xorg: Vendor.c,v 1.4 2001/02/09 02:03:59 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/Vendor.c,v 1.7 2002/05/31 18:45:46 dawes Exp $ */
+
+/* Make sure all wm properties can make it out of the resource manager */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "StringDefs.h"
+#include "Shell.h"
+#include "ShellP.h"
+#include "Vendor.h"
+#include "VendorP.h"
+#include <stdio.h>
+
+/***************************************************************************
+ *
+ * Vendor shell class record
+ *
+ ***************************************************************************/
+
+#if defined(__UNIXOS2__) || defined(__CYGWIN__)
+/* to fix the EditRes problem because of wrong linker semantics */
+extern WidgetClass vendorShellWidgetClass;
+
+#if defined(__UNIXOS2__)
+unsigned long _DLL_InitTerm(unsigned long mod,unsigned long flag)
+{
+ switch (flag) {
+ case 0: /*called on init*/
+ _CRT_init();
+ vendorShellWidgetClass = (WidgetClass)(&vendorShellClassRec);
+ return 1;
+ case 1: /*called on exit*/
+ return 1;
+ default:
+ return 0;
+ }
+}
+#endif
+
+#if defined(__CYGWIN__)
+int __stdcall
+DllMain(unsigned long mod_handle, unsigned long flag, void *routine)
+{
+ switch (flag)
+ {
+ case 1: /* DLL_PROCESS_ATTACH - process attach */
+ vendorShellWidgetClass = (WidgetClass)(&vendorShellClassRec);
+ break;
+ case 0: /* DLL_PROCESS_DETACH - process detach */
+ break;
+ }
+ return 1;
+}
+#endif
+#endif
+
+externaldef(vendorshellclassrec) VendorShellClassRec vendorShellClassRec = {
+ {
+ /* superclass */ (WidgetClass) &wmShellClassRec,
+ /* class_name */ "VendorShell",
+ /* size */ sizeof(VendorShellRec),
+ /* Class Initializer */ NULL,
+ /* class_part_initialize*/ NULL,
+ /* Class init'ed ? */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_notify */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ NULL,
+ /* resource_count */ 0,
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ XtInheritResize,
+ /* expose */ NULL,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL
+ },{
+ /* geometry_manager */ XtInheritGeometryManager,
+ /* change_managed */ XtInheritChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ }
+};
+
+#if !defined(AIXSHLIB) || !defined(SHAREDCODE)
+externaldef(vendorshellwidgetclass) WidgetClass vendorShellWidgetClass =
+ (WidgetClass) (&vendorShellClassRec);
+#endif
diff --git a/nx-X11/lib/Xt/Vendor.h b/nx-X11/lib/Xt/Vendor.h
new file mode 100644
index 000000000..65e7c38b0
--- /dev/null
+++ b/nx-X11/lib/Xt/Vendor.h
@@ -0,0 +1,71 @@
+/*
+* $Xorg: Vendor.h,v 1.5 2001/02/09 02:03:59 xorgcvs Exp $
+* $oHeader: Vendor.h,v 1.2 88/08/18 15:56:44 asente 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.
+
+******************************************************************/
+
+#ifndef _XtVendor_h
+#define _XtVendor_h
+
+#include <X11/Intrinsic.h>
+
+/***********************************************************************
+ *
+ * VendorShell Widget
+ *
+ ***********************************************************************/
+
+/* Class record constants */
+
+typedef struct _VendorShellClassRec *VendorShellWidgetClass;
+
+externalref WidgetClass vendorShellWidgetClass;
+
+#endif /* _XtVendor_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/VendorP.h b/nx-X11/lib/Xt/VendorP.h
new file mode 100644
index 000000000..08bf6890b
--- /dev/null
+++ b/nx-X11/lib/Xt/VendorP.h
@@ -0,0 +1,103 @@
+/*
+* $Xorg: VendorP.h,v 1.4 2001/02/09 02:03:59 xorgcvs Exp $
+* $oHeader: VendorP.h,v 1.2 88/08/18 15:56:48 asente 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.
+
+******************************************************************/
+
+/*
+ * VendorP.h - Private definitions for VendorShell widget
+ *
+ * Author: Paul Asente
+ * Digital Equipment Corporation
+ * Western Software Laboratory
+ * Date: Thu Dec 3, 1987
+ */
+
+/***********************************************************************
+ *
+ * VendorShell Widget Private Data
+ *
+ ***********************************************************************/
+
+#ifndef _XtVendorPrivate_h
+#define _XtVendorPrivate_h
+
+#include <X11/Vendor.h>
+
+/* New fields for the VendorShell widget class record */
+
+typedef struct {
+ XtPointer extension; /* pointer to extension record */
+} VendorShellClassPart;
+
+typedef struct _VendorShellClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ShellClassPart shell_class;
+ WMShellClassPart wm_shell_class;
+ VendorShellClassPart vendor_shell_class;
+} VendorShellClassRec;
+
+externalref VendorShellClassRec vendorShellClassRec;
+
+/* New fields for the vendor shell widget. */
+
+typedef struct {
+ int vendor_specific;
+} VendorShellPart;
+
+typedef struct {
+ CorePart core;
+ CompositePart composite;
+ ShellPart shell;
+ WMShellPart wm;
+ VendorShellPart vendor;
+} VendorShellRec, *VendorShellWidget;
+
+#endif /* _XtVendorPrivate_h */
diff --git a/nx-X11/lib/Xt/Xt-def.cpp b/nx-X11/lib/Xt/Xt-def.cpp
new file mode 100644
index 000000000..4f0420aa0
--- /dev/null
+++ b/nx-X11/lib/Xt/Xt-def.cpp
@@ -0,0 +1,352 @@
+LIBRARY Xt
+VERSION LIBRARY_VERSION
+EXPORTS
+ applicationShellClassRec DATA
+ applicationShellWidgetClass DATA
+ compositeClassRec DATA
+ compositeWidgetClass DATA
+ constraintClassRec DATA
+ constraintWidgetClass DATA
+ coreWidgetClass DATA
+ hookObjClassRec DATA
+ hookObjectClass DATA
+ objectClass DATA
+ objectClassRec DATA
+ overrideShellClassRec DATA
+ overrideShellWidgetClass DATA
+ rectObjClass DATA
+ rectObjClassRec DATA
+ screenConvertArg DATA
+ sessionShellClassRec DATA
+ sessionShellWidgetClass DATA
+ shellClassRec DATA
+ shellWidgetClass DATA
+ topLevelShellClassRec DATA
+ topLevelShellWidgetClass DATA
+ transientShellClassRec DATA
+ transientShellWidgetClass DATA
+ vendorShellClassRec DATA
+ vendorShellWidgetClass DATA
+ widgetClass DATA
+ widgetClassRec DATA
+ wmShellClassRec DATA
+ wmShellWidgetClass DATA
+ _XtCheckSubclassFlag
+ _XtCopyFromArg
+ _XtInherit
+ _XtInheritTranslations
+ _XtIsSubclassOf
+ XtAddActions
+ XtAddCallback
+ XtAddCallbacks
+ XtAddConverter
+ XtAddEventHandler
+ XtAddExposureToRegion
+ XtAddGrab
+ XtAddInput
+ XtAddRawEventHandler
+ XtAddSignal
+ XtAddTimeOut
+ XtAddWorkProc
+ XtAllocateGC
+ XtAppAddActionHook
+ XtAppAddActions
+ XtAppAddBlockHook
+ XtAppAddConverter
+ XtAppAddInput
+ XtAppAddSignal
+ XtAppAddTimeOut
+ XtAppAddWorkProc
+ XtAppCreateShell
+ XtAppError
+ XtAppErrorMsg
+ XtAppGetErrorDatabase
+ XtAppGetErrorDatabaseText
+ XtAppGetExitFlag
+ XtAppGetSelectionTimeout
+ XtAppInitialize
+ XtAppLock
+ XtAppMainLoop
+ XtAppNextEvent
+ XtAppPeekEvent
+ XtAppPending
+ XtAppProcessEvent
+ XtAppReleaseCacheRefs
+ XtAppSetErrorHandler
+ XtAppSetErrorMsgHandler
+ XtAppSetExitFlag
+ XtAppSetFallbackResources
+ XtAppSetSelectionTimeout
+ XtAppSetTypeConverter
+ XtAppSetWarningHandler
+ XtAppSetWarningMsgHandler
+ XtAppUnlock
+ XtAppWarning
+ XtAppWarningMsg
+ XtAugmentTranslations
+ XtBuildEventMask
+ XtCallAcceptFocus
+ XtCallActionProc
+ XtCallbackExclusive
+ XtCallbackNone
+ XtCallbackNonexclusive
+ XtCallbackPopdown
+ XtCallbackReleaseCacheRef
+ XtCallbackReleaseCacheRefList
+ XtCallCallbackList
+ XtCallCallbacks
+ XtCallConverter
+ XtCalloc
+ XtCancelSelectionRequest
+ XtChangeManagedSet
+ XtClass
+ XtCloseDisplay
+ XtConfigureWidget
+ XtConvert
+ XtConvertAndStore
+ XtConvertCase
+ XtCreateApplicationContext
+ XtCreateApplicationShell
+ XtCreateManagedWidget
+ XtCreatePopupShell
+ XtCreateSelectionRequest
+ XtCreateWidget
+ XtCreateWindow
+ XtCvtColorToPixel
+ XtCvtIntToBool
+ XtCvtIntToBoolean
+ XtCvtIntToColor
+ XtCvtIntToFloat
+ XtCvtIntToFont
+ XtCvtIntToPixel
+ XtCvtIntToPixmap
+ XtCvtIntToShort
+ XtCvtIntToUnsignedChar
+ XtCvtStringToAcceleratorTable
+ XtCvtStringToAtom
+ XtCvtStringToBool
+ XtCvtStringToBoolean
+ XtCvtStringToCommandArgArray
+ XtCvtStringToCursor
+ XtCvtStringToDimension
+ XtCvtStringToDirectoryString
+ XtCvtStringToDisplay
+ XtCvtStringToFile
+ XtCvtStringToFloat
+ XtCvtStringToFont
+ XtCvtStringToFontSet
+ XtCvtStringToFontStruct
+ XtCvtStringToGravity
+ XtCvtStringToInitialState
+ XtCvtStringToInt
+ XtCvtStringToPixel
+ XtCvtStringToRestartStyle
+ XtCvtStringToShort
+ XtCvtStringToTranslationTable
+ XtCvtStringToUnsignedChar
+ XtCvtStringToVisual
+ XtCXtToolkitError
+ XtDatabase
+ XtDestroyApplicationContext
+ XtDestroyGC
+ XtDestroyWidget
+ XtDirectConvert
+ XtDisownSelection
+ XtDispatchEvent
+ XtDispatchEventToWidget
+ XtDisplay
+ XtDisplayInitialize
+ XtDisplayOfObject
+ XtDisplayStringConversionWarning
+ XtDisplayToApplicationContext
+ XtError
+ XtErrorMsg
+ XtFindFile
+ XtFree
+ XtGetActionKeysym
+ XtGetActionList
+ XtGetApplicationNameAndClass
+ XtGetApplicationResources
+ XtGetClassExtension
+ XtGetConstraintResourceList
+ XtGetDisplays
+ XtGetErrorDatabase
+ XtGetErrorDatabaseText
+ XtGetGC
+ XtGetKeyboardFocusWidget
+ XtGetKeysymTable
+ XtGetMultiClickTime
+ XtGetResourceList
+ XtGetSelectionParameters
+ XtGetSelectionRequest
+ XtGetSelectionTimeout
+ XtGetSelectionValue
+ XtGetSelectionValueIncremental
+ XtGetSelectionValues
+ XtGetSelectionValuesIncremental
+ XtGetSubresources
+ XtGetSubvalues
+ XtGetValues
+ XtGrabButton
+ XtGrabKey
+ XtGrabKeyboard
+ XtGrabPointer
+ XtHasCallbacks
+ XtHooksOfDisplay
+ XtInitialize
+ XtInitializeWidgetClass
+ XtInsertEventHandler
+ XtInsertEventTypeHandler
+ XtInsertRawEventHandler
+ XtInstallAccelerators
+ XtInstallAllAccelerators
+ XtIsApplicationShell
+ XtIsComposite
+ XtIsConstraint
+ XtIsManaged
+ XtIsObject
+ XtIsOverrideShell
+ XtIsRealized
+ XtIsRectObj
+ XtIsSensitive
+ XtIsSessionShell
+ XtIsShell
+ XtIsSubclass
+ XtIsTopLevelShell
+ XtIsTransientShell
+ XtIsVendorShell
+ XtIsWidget
+ XtIsWMShell
+ XtKeysymToKeycodeList
+ XtLastEventProcessed
+ XtLastTimestampProcessed
+ XtMainLoop
+ XtMakeGeometryRequest
+ XtMakeResizeRequest
+ XtMalloc
+ XtManageChild
+ XtManageChildren
+ XtMapWidget
+ XtMenuPopupAction
+ XtMergeArgLists
+ XtMoveWidget
+ XtName
+ XtNameToWidget
+ XtNewString
+ XtNextEvent
+ XtNoticeSignal
+ XtOpenApplication
+ XtOpenDisplay
+ XtOverrideTranslations
+ XtOwnSelection
+ XtOwnSelectionIncremental
+ XtParent
+ XtParseAcceleratorTable
+ XtParseTranslationTable
+ XtPeekEvent
+ XtPending
+ XtPopdown
+ XtPopup
+ XtPopupSpringLoaded
+ XtProcessEvent
+ XtProcessLock
+ XtProcessUnlock
+ XtQueryGeometry
+ XtRealizeWidget
+ XtRealloc
+ XtRegisterCaseConverter
+ XtRegisterDrawable
+ XtRegisterExtensionSelector
+ XtRegisterGrabAction
+ XtReleaseGC
+ XtReleasePropertyAtom
+ XtRemoveActionHook
+ XtRemoveAllCallbacks
+ XtRemoveBlockHook
+ XtRemoveCallback
+ XtRemoveCallbacks
+ XtRemoveEventHandler
+ XtRemoveEventTypeHandler
+ XtRemoveGrab
+ XtRemoveInput
+ XtRemoveRawEventHandler
+ XtRemoveSignal
+ XtRemoveTimeOut
+ XtRemoveWorkProc
+ XtReservePropertyAtom
+ XtResizeWidget
+ XtResizeWindow
+ XtResolvePathname
+ XtScreen
+ XtScreenDatabase
+ XtScreenOfObject
+ XtSendSelectionRequest
+ XtSessionGetToken
+ XtSessionReturnToken
+ XtSetErrorHandler
+ XtSetErrorMsgHandler
+ XtSetEventDispatcher
+ XtSetKeyboardFocus
+ XtSetKeyTranslator
+ XtSetLanguageProc
+ XtSetMappedWhenManaged
+ XtSetMultiClickTime
+ XtSetSelectionParameters
+ XtSetSelectionTimeout
+ XtSetSensitive
+ XtSetSubvalues
+ XtSetTypeConverter
+ XtSetValues
+ XtSetWarningHandler
+ XtSetWarningMsgHandler
+ XtSetWMColormapWindows
+ XtShellStrings
+ XtStringConversionWarning
+ XtStrings
+ XtSuperclass
+ XtToolkitInitialize
+ XtToolkitThreadInitialize
+ XtTranslateCoords
+ XtTranslateKey
+ XtTranslateKeycode
+ XtUngrabButton
+ XtUngrabKey
+ XtUngrabKeyboard
+ XtUngrabPointer
+ XtUninstallTranslations
+ XtUnmanageChild
+ XtUnmanageChildren
+ XtUnmapWidget
+ XtUnrealizeWidget
+ XtUnregisterDrawable
+ XtVaAppCreateShell
+ XtVaAppInitialize
+ XtVaCreateArgsList
+ XtVaCreateManagedWidget
+ XtVaCreatePopupShell
+ XtVaCreateWidget
+ XtVaGetApplicationResources
+ XtVaGetSubresources
+ XtVaGetSubvalues
+ XtVaGetValues
+ XtVaOpenApplication
+ XtVaSetSubvalues
+ XtVaSetValues
+ XtWarning
+ XtWarningMsg
+ XtWidgetToApplicationContext
+ XtWindow
+ XtWindowOfObject
+ XtWindowToWidget
+ _XtWaitForSomething
+#ifdef __UNIXOS2__
+ _XtAddCallback
+ _XtRemoveCallback
+ _XtRemoveAllCallbacks
+ _XtPrintXlations
+ _XtAllocError
+ _XtCountVaList
+ _XtVaToArgList
+#endif
+/* $Xorg: Xt-def.cpp,v 1.3 2000/08/17 19:46:20 cpqbld Exp $ */
+/* $XFree86: xc/lib/Xt/Xt-def.cpp,v 1.3 2003/03/25 04:18:12 dawes Exp $ */
diff --git a/nx-X11/lib/Xt/Xtos.h b/nx-X11/lib/Xt/Xtos.h
new file mode 100644
index 000000000..013b2416c
--- /dev/null
+++ b/nx-X11/lib/Xt/Xtos.h
@@ -0,0 +1,77 @@
+/*
+* $Xorg: Xtos.h,v 1.4 2001/02/09 02:03:59 xorgcvs Exp $
+*/
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/Xtos.h,v 3.12tsi Exp $ */
+
+#ifndef _Xtos_h
+#define _Xtos_h
+
+#define ALLOCATE_LOCAL_FALLBACK(_size) XtMalloc((unsigned long)(_size))
+#define DEALLOCATE_LOCAL_FALLBACK(_ptr) XtFree((XtPointer)(_ptr))
+#include <X11/Xalloca.h>
+
+#ifdef CRAY
+#define WORD64
+#endif
+
+#if defined (_LP64) || \
+ defined(__alpha) || defined(__alpha__) || \
+ defined(__ia64__) || defined(ia64) || \
+ defined(__sparc64__) || \
+ defined(__s390x__) || \
+ (defined(__hppa__) && defined(__LP64__)) || \
+ defined(__amd64__) || defined(amd64) || \
+ defined(__powerpc64__) || \
+ (defined(sgi) && (_MIPS_SZLONG == 64))
+#define LONG64
+#endif
+
+#endif /* _Xtos_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/jump_funcs b/nx-X11/lib/Xt/jump_funcs
new file mode 100644
index 000000000..6a5dc2bd5
--- /dev/null
+++ b/nx-X11/lib/Xt/jump_funcs
@@ -0,0 +1,756 @@
+# $Xorg: jump_funcs,v 1.3 2000/08/17 19:46:20 cpqbld Exp $
+#
+#
+#
+#
+# $XFree86: xc/lib/Xt/jump_funcs,v 3.5 1996/12/30 13:58:31 dawes Exp $
+#
+00000000 T _XtAppAddActionHook libXt ActionHook
+00000000 T _XtRemoveActionHook libXt ActionHook
+00000000 T __XtAllocError libXt Alloc
+00000000 T __XtHeapInit libXt Alloc
+00000000 T _XtMalloc libXt Alloc
+00000000 T _XtRealloc libXt Alloc
+00000000 T _XtCalloc libXt Alloc
+00000000 T _XtFree libXt Alloc
+00000000 T __XtHeapAlloc libXt Alloc
+00000000 T __XtHeapFree libXt Alloc
+00000000 T _XtMergeArgLists libXt ArgList
+00000000 T __XtAddCallback libXt Callback
+00000000 T __XtAddCallbackOnce libXt Callback
+00000000 T _XtAddCallback libXt Callback
+00000000 T _XtAddCallbacks libXt Callback
+00000000 T __XtRemoveCallback libXt Callback
+00000000 T _XtRemoveCallback libXt Callback
+00000000 T _XtRemoveCallbacks libXt Callback
+00000000 T __XtRemoveAllCallbacks libXt Callback
+00000000 T _XtRemoveAllCallbacks libXt Callback
+00000000 T __XtCompileCallbackList libXt Callback
+00000000 T __XtGetCallbackList libXt Callback
+00000000 T _XtCallCallbacks libXt Callback
+00000000 T _XtHasCallbacks libXt Callback
+00000000 T _XtCallCallbackList libXt Callback
+00000000 T __XtCallConditionalCallbackList libXt Callback
+00000000 T _XtSetMultiClickTime libXt ClickTime
+00000000 T _XtGetMultiClickTime libXt ClickTime
+00000000 T __XtSetDefaultConverterTable libXt Convert
+00000000 T __XtFreeConverterTable libXt Convert
+00000000 T __XtTableAddConverter libXt Convert
+00000000 T _XtSetTypeConverter libXt Convert
+00000000 T _XtAppSetTypeConverter libXt Convert
+00000000 T _XtAddConverter libXt Convert
+00000000 T _XtAppAddConverter libXt Convert
+00000000 T __XtCacheFlushTag libXt Convert
+00000000 T _XtDirectConvert libXt Convert
+00000000 T _XtCallConverter libXt Convert
+00000000 T __XtConvert libXt Convert
+00000000 T _XtConvert libXt Convert
+00000000 T _XtConvertAndStore libXt Convert
+00000000 T _XtAppReleaseCacheRefs libXt Convert
+00000000 T _XtCallbackReleaseCacheRefList libXt Convert
+00000000 T _XtCallbackReleaseCacheRef libXt Convert
+00000000 T __XtConvertInitialize libXt Converters
+00000000 T _XtDisplayStringConversionWarning libXt Converters
+00000000 T _XtStringConversionWarning libXt Converters
+00000000 T _XtCvtIntToBoolean libXt Converters
+00000000 T _XtCvtIntToShort libXt Converters
+00000000 T _XtCvtStringToBoolean libXt Converters
+00000000 T _XtCvtIntToBool libXt Converters
+00000000 T _XtCvtStringToBool libXt Converters
+00000000 T _XtCvtIntToColor libXt Converters
+00000000 T _XtCvtStringToPixel libXt Converters
+00000000 T _XtCvtStringToCursor libXt Converters
+00000000 T _XtCvtStringToDisplay libXt Converters
+00000000 T _XtCvtStringToFile libXt Converters
+00000000 T _XtCvtIntToFloat libXt Converters
+00000000 T _XtCvtStringToFloat libXt Converters
+00000000 T _XtCvtStringToFont libXt Converters
+00000000 T _XtCvtIntToFont libXt Converters
+00000000 T _XtCvtStringToFontSet libXt Converters
+00000000 T _XtCvtStringToFontStruct libXt Converters
+00000000 T _XtCvtStringToInt libXt Converters
+00000000 T _XtCvtStringToShort libXt Converters
+00000000 T _XtCvtStringToDimension libXt Converters
+00000000 T _XtCvtIntToUnsignedChar libXt Converters
+00000000 T _XtCvtStringToUnsignedChar libXt Converters
+00000000 T _XtCvtColorToPixel libXt Converters
+00000000 T _XtCvtIntToPixel libXt Converters
+00000000 T _XtCvtIntToPixmap libXt Converters
+00000000 T _XtCvtStringToInitialState libXt Converters
+00000000 T _XtCvtStringToVisual libXt Converters
+00000000 T _XtCvtStringToAtom libXt Converters
+00000000 T __XtAddDefaultConverters libXt Converters
+00000000 T _XtCvtStringToDirectoryString libXt Converters
+00000000 T _XtCvtStringToCommandArgArray libXt Converters
+00000000 T _XtInitializeWidgetClass libXt Create
+00000000 T __XtCreateWidget libXt Create
+00000000 T _XtCreateWidget libXt Create
+00000000 T _XtCreateManagedWidget libXt Create
+00000000 T __XtCreatePopupShell libXt Create
+00000000 T _XtCreatePopupShell libXt Create
+00000000 T __XtAppCreateShell libXt Create
+00000000 T _XtAppCreateShell libXt Create
+00000000 T _XtCreateApplicationShell libXt Create
+00000000 T __XtDoPhase2Destroy libXt Destroy
+00000000 T _XtDestroyWidget libXt Destroy
+00000000 T __XtGetProcessContext libXt Display
+00000000 T __XtDefaultAppContext libXt Display
+00000000 T _XtOpenDisplay libXt Display
+00000000 T __XtAppInit libXt Display
+00000000 T _XtDisplayInitialize libXt Display
+00000000 T _XtCreateApplicationContext libXt Display
+00000000 T _XtDestroyApplicationContext libXt Display
+00000000 T __XtDestroyAppContexts libXt Display
+00000000 T _XtDatabase libXt Display
+00000000 T __XtSortPerDisplayList libXt Display
+00000000 T _XtDisplayToApplicationContext libXt Display
+00000000 T _XtCloseDisplay libXt Display
+00000000 T __XtCloseDisplays libXt Display
+00000000 T _XtWidgetToApplicationContext libXt Display
+00000000 T _XtGetApplicationNameAndClass libXt Display
+00000000 T _XtGetErrorDatabase libXt Error
+00000000 T _XtAppGetErrorDatabase libXt Error
+00000000 T _XtGetErrorDatabaseText libXt Error
+00000000 T _XtAppGetErrorDatabaseText libXt Error
+00000000 T __XtDefaultErrorMsg libXt Error
+00000000 T __XtDefaultWarningMsg libXt Error
+00000000 T _XtErrorMsg libXt Error
+00000000 T _XtAppErrorMsg libXt Error
+00000000 T _XtWarningMsg libXt Error
+00000000 T _XtAppWarningMsg libXt Error
+00000000 T _XtSetErrorMsgHandler libXt Error
+00000000 T _XtAppSetErrorMsgHandler libXt Error
+00000000 T _XtSetWarningMsgHandler libXt Error
+00000000 T _XtAppSetWarningMsgHandler libXt Error
+00000000 T __XtDefaultError libXt Error
+00000000 T __XtDefaultWarning libXt Error
+00000000 T _XtError libXt Error
+00000000 T _XtAppError libXt Error
+00000000 T _XtWarning libXt Error
+00000000 T _XtAppWarning libXt Error
+00000000 T _XtSetErrorHandler libXt Error
+00000000 T _XtAppSetErrorHandler libXt Error
+00000000 T _XtSetWarningHandler libXt Error
+00000000 T _XtAppSetWarningHandler libXt Error
+00000000 T __XtSetDefaultErrorHandlers libXt Error
+00000000 T _XtBuildEventMask libXt Event
+00000000 T _XtRemoveEventHandler libXt Event
+00000000 T _XtAddEventHandler libXt Event
+00000000 T _XtInsertEventHandler libXt Event
+00000000 T _XtRemoveRawEventHandler libXt Event
+00000000 T _XtInsertRawEventHandler libXt Event
+00000000 T _XtAddRawEventHandler libXt Event
+00000000 T _XtWindowToWidget libXt Event
+00000000 T __XtAllocWWTable libXt Event
+00000000 T __XtFreeWWTable libXt Event
+00000000 T __XtConvertTypeToMask libXt Event
+00000000 T __XtOnGrabList libXt Event
+00000000 T _XtDispatchEvent libXt Event
+00000000 T _XtAddGrab libXt Event
+00000000 T _XtRemoveGrab libXt Event
+00000000 T _XtMainLoop libXt Event
+00000000 T _XtAppMainLoop libXt Event
+00000000 T __XtEventInitialize libXt Event
+00000000 T _XtAddExposureToRegion libXt Event
+00000000 T __XtFreeEventTable libXt Event
+00000000 T _XtLastTimestampProcessed libXt Event
+00000000 T __XtSendFocusEvent libXt Event
+00000000 T __XtFreePerWidgetInput libXt EventUtil
+00000000 T __XtGetPerWidgetInput libXt EventUtil
+00000000 T __XtFillAncestorList libXt EventUtil
+00000000 T __XtFindRemapWidget libXt EventUtil
+00000000 T __XtUngrabBadGrabs libXt EventUtil
+00000000 T _XtIsRectObj libXt Functions
+00000000 T _XtIsWidget libXt Functions
+00000000 T _XtIsComposite libXt Functions
+00000000 T _XtIsConstraint libXt Functions
+00000000 T _XtIsShell libXt Functions
+00000000 T _XtIsOverrideShell libXt Functions
+00000000 T _XtIsWMShell libXt Functions
+00000000 T _XtIsVendorShell libXt Functions
+00000000 T _XtIsTransientShell libXt Functions
+00000000 T _XtIsTopLevelShell libXt Functions
+00000000 T _XtIsApplicationShell libXt Functions
+00000000 T _XtMapWidget libXt Functions
+00000000 T _XtUnmapWidget libXt Functions
+00000000 T _XtNewString libXt Functions
+00000000 T _XtIsSessionShell libXt Functions
+00000000 T __XtGClistFree libXt GCManager
+00000000 T _XtAllocateGC libXt GCManager
+00000000 T _XtGetGC libXt GCManager
+00000000 T _XtReleaseGC libXt GCManager
+00000000 T _XtDestroyGC libXt GCManager
+00000000 T __XtMakeGeometryRequest libXt Geometry
+00000000 T _XtMakeGeometryRequest libXt Geometry
+00000000 T _XtMakeResizeRequest libXt Geometry
+00000000 T _XtResizeWindow libXt Geometry
+00000000 T _XtResizeWidget libXt Geometry
+00000000 T _XtConfigureWidget libXt Geometry
+00000000 T _XtMoveWidget libXt Geometry
+00000000 T _XtTranslateCoords libXt Geometry
+00000000 T _XtQueryGeometry libXt Geometry
+00000000 T _XtGetActionKeysym libXt GetActKey
+00000000 T _XtGetResourceList libXt GetResList
+00000000 T _XtGetConstraintResourceList libXt GetResList
+00000000 T _XtGetValues libXt GetValues
+00000000 T _XtGetSubvalues libXt GetValues
+00000000 T __XtInherit libXt Initialize
+00000000 T _XtToolkitInitialize libXt Initialize
+00000000 T _XtSetLanguageProc libXt Initialize
+00000000 T _XtScreenDatabase libXt Initialize
+00000000 T __XtPreparseCommandLine libXt Initialize
+00000000 T __XtDisplayInitialize libXt Initialize
+00000000 T _XtAppSetFallbackResources libXt Initialize
+00000000 T _XtAppInitialize libXt Initialize
+00000000 T _XtInitialize libXt Initialize
+00000000 T _XtOpenApplication libXt Initialize
+00000000 T _XtIsSubclass libXt Intrinsic
+00000000 T __XtCheckSubclassFlag libXt Intrinsic
+00000000 T __XtIsSubclassOf libXt Intrinsic
+00000000 T _XtRealizeWidget libXt Intrinsic
+00000000 T _XtUnrealizeWidget libXt Intrinsic
+00000000 T _XtCreateWindow libXt Intrinsic
+00000000 T _XtNameToWidget libXt Intrinsic
+00000000 T _XtDisplayOfObject libXt Intrinsic
+00000000 T _XtDisplay libXt Intrinsic
+00000000 T _XtScreenOfObject libXt Intrinsic
+00000000 T _XtScreen libXt Intrinsic
+00000000 T _XtWindowOfObject libXt Intrinsic
+00000000 T _XtWindow libXt Intrinsic
+00000000 T _XtSuperclass libXt Intrinsic
+00000000 T _XtClass libXt Intrinsic
+00000000 T _XtIsManaged libXt Intrinsic
+00000000 T _XtIsRealized libXt Intrinsic
+00000000 T _XtIsSensitive libXt Intrinsic
+00000000 T __XtWindowedAncestor libXt Intrinsic
+00000000 T _XtParent libXt Intrinsic
+00000000 T _XtName libXt Intrinsic
+00000000 T _XtIsObject libXt Intrinsic
+00000000 T _XtFindFile libXt Intrinsic
+00000000 T _XtResolvePathname libXt Intrinsic
+00000000 T _XtCallAcceptFocus libXt Intrinsic
+00000000 T __XtProcessKeyboardEvent libXt Keyboard
+00000000 T __XtHandleFocus libXt Keyboard
+00000000 T _XtSetKeyboardFocus libXt Keyboard
+00000000 T _XtUnmanageChildren libXt Manage
+00000000 T _XtUnmanageChild libXt Manage
+00000000 T _XtManageChildren libXt Manage
+00000000 T _XtManageChild libXt Manage
+00000000 T _XtSetMappedWhenManaged libXt Manage
+00000000 T _XtAddTimeOut libXt NextEvent
+00000000 T _XtAppAddTimeOut libXt NextEvent
+00000000 T _XtRemoveTimeOut libXt NextEvent
+00000000 T _XtAddWorkProc libXt NextEvent
+00000000 T _XtAppAddWorkProc libXt NextEvent
+00000000 T _XtRemoveWorkProc libXt NextEvent
+00000000 T _XtAddInput libXt NextEvent
+00000000 T _XtAppAddInput libXt NextEvent
+00000000 T _XtRemoveInput libXt NextEvent
+00000000 T __XtRemoveAllInputs libXt NextEvent
+00000000 T _XtNextEvent libXt NextEvent
+00000000 T __XtRefreshMapping libXt NextEvent
+00000000 T _XtAppNextEvent libXt NextEvent
+00000000 T _XtProcessEvent libXt NextEvent
+00000000 T _XtAppProcessEvent libXt NextEvent
+00000000 T _XtPending libXt NextEvent
+00000000 T _XtAppPending libXt NextEvent
+00000000 T _XtPeekEvent libXt NextEvent
+00000000 T _XtAppPeekEvent libXt NextEvent
+00000000 T __XtDestroyServerGrabs libXt PassivGrab
+00000000 T __XtCheckServerGrabsOnWidget libXt PassivGrab
+00000000 T _XtGrabKey libXt PassivGrab
+00000000 T _XtGrabButton libXt PassivGrab
+00000000 T _XtUngrabKey libXt PassivGrab
+00000000 T _XtUngrabButton libXt PassivGrab
+00000000 T _XtGrabKeyboard libXt PassivGrab
+00000000 T _XtUngrabKeyboard libXt PassivGrab
+00000000 T _XtGrabPointer libXt PassivGrab
+00000000 T _XtUngrabPointer libXt PassivGrab
+00000000 T __XtProcessPointerEvent libXt Pointer
+00000000 T __XtPopup libXt Popup
+00000000 T _XtPopup libXt Popup
+00000000 T _XtPopupSpringLoaded libXt Popup
+00000000 T _XtPopdown libXt Popup
+00000000 T _XtCallbackPopdown libXt Popup
+00000000 T _XtCallbackNone libXt PopupCB
+00000000 T _XtCallbackNonexclusive libXt PopupCB
+00000000 T _XtCallbackExclusive libXt PopupCB
+00000000 T __XtCopyFromParent libXt Resources
+00000000 T __XtCopyFromArg libXt Resources
+00000000 T __XtCopyToArg libXt Resources
+00000000 T __XtCompileResourceList libXt Resources
+00000000 T __XtDependencies libXt Resources
+00000000 T __XtResourceDependencies libXt Resources
+00000000 T __XtConstraintResDependencies libXt Resources
+00000000 T __XtCreateIndirectionTable libXt Resources
+00000000 T __XtGetResources libXt Resources
+00000000 T _XtGetSubresources libXt Resources
+00000000 T _XtGetApplicationResources libXt Resources
+00000000 T __XtResourceListInitialize libXt Resources
+00000000 T __XtSetDefaultSelectionTimeout libXt Selection
+00000000 T _XtSetSelectionTimeout libXt Selection
+00000000 T _XtAppSetSelectionTimeout libXt Selection
+00000000 T _XtGetSelectionTimeout libXt Selection
+00000000 T _XtAppGetSelectionTimeout libXt Selection
+00000000 T _XtOwnSelection libXt Selection
+00000000 T _XtOwnSelectionIncremental libXt Selection
+00000000 T _XtDisownSelection libXt Selection
+00000000 T _XtGetSelectionValue libXt Selection
+00000000 T _XtGetSelectionValueIncremental libXt Selection
+00000000 T _XtGetSelectionValues libXt Selection
+00000000 T _XtGetSelectionValuesIncremental libXt Selection
+00000000 T _XtGetSelectionRequest libXt Selection
+00000000 T _XtSetSensitive libXt SetSens
+00000000 T _XtSetSubvalues libXt SetValues
+00000000 T _XtSetValues libXt SetValues
+00000000 T _XtSetWMColormapWindows libXt SetWMCW
+00000000 T __XtShellGetCoordinates libXt Shell
+00000000 T __XtInitializeActionData libXt TMaction
+00000000 T __XtBindActions libXt TMaction
+00000000 T __XtUnbindActions libXt TMaction
+00000000 T __XtFreeActions libXt TMaction
+00000000 T _XtAddActions libXt TMaction
+00000000 T _XtAppAddActions libXt TMaction
+00000000 T _XtGetActionList libXt TMaction
+00000000 T _XtMenuPopupAction libXt TMaction
+00000000 T _XtCallActionProc libXt TMaction
+00000000 T __XtRegisterGrabs libXt TMgrab
+00000000 T _XtRegisterGrabAction libXt TMgrab
+00000000 T __XtGrabInitialize libXt TMgrab
+00000000 T __XtComputeLateBindings libXt TMkey
+00000000 T __XtAllocTMContext libXt TMkey
+00000000 T __XtMatchUsingDontCareMods libXt TMkey
+00000000 T _XtConvertCase libXt TMkey
+00000000 T __XtMatchUsingStandardMods libXt TMkey
+00000000 T __XtBuildKeysymTables libXt TMkey
+00000000 T _XtTranslateKeycode libXt TMkey
+00000000 T _XtTranslateKey libXt TMkey
+00000000 T _XtSetKeyTranslator libXt TMkey
+00000000 T _XtRegisterCaseConverter libXt TMkey
+00000000 T _XtGetKeysymTable libXt TMkey
+00000000 T _XtKeysymToKeycodeList libXt TMkey
+00000000 T _XtCvtStringToAcceleratorTable libXt TMparse
+00000000 T _XtCvtStringToTranslationTable libXt TMparse
+00000000 T _XtParseAcceleratorTable libXt TMparse
+00000000 T _XtParseTranslationTable libXt TMparse
+00000000 T __XtTranslateInitialize libXt TMparse
+00000000 T __XtAddTMConverters libXt TMparse
+00000000 T __XtPrintXlations libXt TMprint
+00000000 T __XtDisplayTranslations libXt TMprint
+00000000 T __XtDisplayAccelerators libXt TMprint
+00000000 T __XtDisplayInstalledAccelerators libXt TMprint
+00000000 T __XtPrintActions libXt TMprint
+00000000 T __XtPrintState libXt TMprint
+00000000 T __XtPrintEventSeq libXt TMprint
+00000000 T __XtGetQuarkIndex libXt TMstate
+00000000 T __XtGetTypeIndex libXt TMstate
+00000000 T __XtGetModifierIndex libXt TMstate
+00000000 T __XtRegularMatch libXt TMstate
+00000000 T __XtMatchAtom libXt TMstate
+00000000 T __XtTranslateEvent libXt TMstate
+00000000 T __XtTraverseStateTree libXt TMstate
+00000000 T __XtInstallTranslations libXt TMstate
+00000000 T __XtRemoveTranslations libXt TMstate
+00000000 T __XtDestroyTMData libXt TMstate
+00000000 T _XtUninstallTranslations libXt TMstate
+00000000 T __XtCreateXlations libXt TMstate
+00000000 T __XtParseTreeToStateTree libXt TMstate
+00000000 T __XtAddEventSeqToStateTree libXt TMstate
+00000000 T __XtCvtMergeTranslations libXt TMstate
+00000000 T __XtGetTranslationValue libXt TMstate
+00000000 T __XtRemoveStateTreeByIndex libXt TMstate
+00000000 T __XtFreeTranslations libXt TMstate
+00000000 T _XtInstallAccelerators libXt TMstate
+00000000 T _XtInstallAllAccelerators libXt TMstate
+00000000 T _XtAugmentTranslations libXt TMstate
+00000000 T _XtOverrideTranslations libXt TMstate
+00000000 T __XtMergeTranslations libXt TMstate
+00000000 T __XtUnmergeTranslations libXt TMstate
+00000000 T __XtPopupInitialize libXt TMstate
+00000000 T _XtVaCreateWidget libXt VarCreate
+00000000 T _XtVaCreateManagedWidget libXt VarCreate
+00000000 T _XtVaAppCreateShell libXt VarCreate
+00000000 T _XtVaCreatePopupShell libXt VarCreate
+00000000 T _XtVaSetValues libXt VarCreate
+00000000 T _XtVaSetSubvalues libXt VarCreate
+00000000 T __XtVaAppInitialize libXt VarCreate
+00000000 T _XtVaAppInitialize libXt VarCreate
+00000000 T __XtVaOpenApplication libXt VarCreate
+00000000 T _XtVaOpenApplication libXt VarCreate
+00000000 T _XtVaGetSubresources libXt VarGet
+00000000 T _XtVaGetApplicationResources libXt VarGet
+00000000 T _XtVaGetValues libXt VarGet
+00000000 T _XtVaGetSubvalues libXt VarGet
+00000000 T __XtCountVaList libXt Varargs
+00000000 T _XtVaCreateArgsList libXt Varargs
+00000000 T __XtVaCreateTypedArgList libXt Varargs
+00000000 T __XtVaToArgList libXt Varargs
+00000000 T __XtVaToTypedArgList libXt Varargs
+00000000 T _XmuAllStandardColormaps libXmu AllCmap
+00000000 T _XmuMakeAtom libXmu Atoms
+00000000 T _XmuNameOfAtom libXmu Atoms
+00000000 T _XmuInternAtom libXmu Atoms
+00000000 T _XmuGetAtomName libXmu Atoms
+00000000 T _XmuInternStrings libXmu Atoms
+00000000 T _XmuClientWindow libXmu ClientWin
+00000000 T _XmuAddCloseDisplayHook libXmu CloseHook
+00000000 T _XmuRemoveCloseDisplayHook libXmu CloseHook
+00000000 T _XmuLookupCloseDisplayHook libXmu CloseHook
+00000000 T _XmuGetColormapAllocation libXmu CmapAlloc
+00000000 T _XmuCreateColormap libXmu CrCmap
+00000000 T _XmuCreatePixmapFromBitmap libXmu CrPixFBit
+00000000 T _XmuCursorNameToIndex libXmu CursorName
+00000000 T __XmuCCLookupDisplay libXmu CvtCache
+00000000 T _XmuConvertStandardSelection libXmu CvtStdSel
+00000000 T _XmuPrintDefaultErrorMessage libXmu DefErrMsg
+00000000 T _XmuSimpleErrorHandler libXmu DefErrMsg
+00000000 T _XmuDeleteStandardColormap libXmu DelCmap
+00000000 T _XmuDQCreate libXmu DisplayQue
+00000000 T _XmuDQDestroy libXmu DisplayQue
+00000000 T _XmuDQLookupDisplay libXmu DisplayQue
+00000000 T _XmuDQAddDisplay libXmu DisplayQue
+00000000 T _XmuDQRemoveDisplay libXmu DisplayQue
+00000000 T _XmuDistinguishableColors libXmu Distinct
+00000000 T _XmuDistinguishablePixels libXmu Distinct
+00000000 T _XmuDrawLogo libXmu DrawLogo
+00000000 T _XmuDrawRoundedRectangle libXmu DrRndRect
+00000000 T _XmuFillRoundedRectangle libXmu DrRndRect
+00000000 T __XEditResCheckMessages libXmu EditresCom
+00000000 T __XEditResPutString8 libXmu EditresCom
+00000000 T __XEditResPut8 libXmu EditresCom
+00000000 T __XEditResPut16 libXmu EditresCom
+00000000 T __XEditResPut32 libXmu EditresCom
+00000000 T __XEditResPutWidgetInfo libXmu EditresCom
+00000000 T __XEditResResetStream libXmu EditresCom
+00000000 T __XEditResGet8 libXmu EditresCom
+00000000 T __XEditResGet16 libXmu EditresCom
+00000000 T __XEditResGetSigned16 libXmu EditresCom
+00000000 T __XEditResGet32 libXmu EditresCom
+00000000 T __XEditResGetString8 libXmu EditresCom
+00000000 T __XEditResGetWidgetInfo libXmu EditresCom
+00000000 T _XmuRegisterExternalAgent libXmu ExtAgent
+00000000 T _XmuCvtFunctionToCallback libXmu FToCback
+00000000 T _XmuGetHostname libXmu GetHost
+00000000 T _XmuCreateStippledPixmap libXmu GrayPixmap
+00000000 T _XmuReleaseStippledPixmap libXmu GrayPixmap
+00000000 T _XmuAddInitializer libXmu Initer
+00000000 T _XmuCallInitializers libXmu Initer
+00000000 T _XmuLocateBitmapFile libXmu LocBitmap
+00000000 T _XmuLocatePixmapFile libXmu LocBitmap
+00000000 T __XmuStringToBitmapInitCache libXmu LocBitmap
+00000000 T __XmuStringToBitmapFreeCache libXmu LocBitmap
+00000000 T _XmuLookupString libXmu Lookup
+00000000 T _XmuLookupLatin1 libXmu Lookup
+00000000 T _XmuLookupLatin2 libXmu Lookup
+00000000 T _XmuLookupLatin3 libXmu Lookup
+00000000 T _XmuLookupLatin4 libXmu Lookup
+00000000 T _XmuLookupKana libXmu Lookup
+00000000 T _XmuLookupJISX0201 libXmu Lookup
+00000000 T _XmuLookupArabic libXmu Lookup
+00000000 T _XmuLookupCyrillic libXmu Lookup
+00000000 T _XmuLookupGreek libXmu Lookup
+00000000 T _XmuLookupAPL libXmu Lookup
+00000000 T _XmuLookupHebrew libXmu Lookup
+00000000 T _XmuLookupStandardColormap libXmu LookupCmap
+00000000 T _XmuCopyISOLatin1Lowered libXmu Lower
+00000000 T _XmuCopyISOLatin1Uppered libXmu Lower
+00000000 T _XmuCompareISOLatin1 libXmu Lower
+00000000 T _XmuReadBitmapData libXmu RdBitF
+00000000 T _XmuReadBitmapDataFromFile libXmu RdBitF
+00000000 T _XmuScreenOfWindow libXmu ScrOfWin
+00000000 T _XmuReshapeWidget libXmu ShapeWidg
+00000000 T _XmuStandardColormap libXmu StdCmap
+00000000 T _XmuCvtStringToBackingStore libXmu StrToBS
+00000000 T _XmuCvtStringToBitmap libXmu StrToBmap
+00000000 T _XmuCvtStringToCursor libXmu StrToCurs
+00000000 T _XmuCvtStringToColorCursor libXmu StrToCurs
+00000000 T _XmuCvtStringToGravity libXmu StrToGrav
+00000000 T _XmuCvtStringToJustify libXmu StrToJust
+00000000 T _XmuCvtStringToLong libXmu StrToLong
+00000000 T _XmuCvtStringToOrientation libXmu StrToOrnt
+00000000 T _XmuCvtStringToShapeStyle libXmu StrToShap
+00000000 T _XmuCvtStringToWidget libXmu StrToWidg
+00000000 T _XmuNewCvtStringToWidget libXmu StrToWidg
+00000000 T _XmuUpdateMapHints libXmu UpdMapHint
+00000000 T _XmuVisualStandardColormaps libXmu VisCmap
+00000000 T _XmuWnInitializeNodes libXmu WidgetNode
+00000000 T _XmuWnFetchResources libXmu WidgetNode
+00000000 T _XmuWnCountOwnedResources libXmu WidgetNode
+00000000 T _XmuWnNameToNode libXmu WidgetNode
+00000000 T _XctCreate libXmu Xct
+00000000 T _XctReset libXmu Xct
+00000000 T _XctNextItem libXmu Xct
+00000000 T _XctFree libXmu Xct
+00000000 T _XextCreateExtension libXext extutil
+00000000 T _XextDestroyExtension libXext extutil
+00000000 T _XextAddDisplay libXext extutil
+00000000 T _XextRemoveDisplay libXext extutil
+00000000 T _XextFindDisplay libXext extutil
+00000000 T _XSetExtensionErrorHandler libXext extutil
+00000000 T _XMissingExtension libXext extutil
+00000000 T _XmbufQueryExtension libXext XMultibuf
+00000000 T _XmbufGetVersion libXext XMultibuf
+00000000 T _XmbufCreateBuffers libXext XMultibuf
+00000000 T _XmbufDestroyBuffers libXext XMultibuf
+00000000 T _XmbufDisplayBuffers libXext XMultibuf
+00000000 T _XmbufGetWindowAttributes libXext XMultibuf
+00000000 T _XmbufChangeWindowAttributes libXext XMultibuf
+00000000 T _XmbufGetBufferAttributes libXext XMultibuf
+00000000 T _XmbufChangeBufferAttributes libXext XMultibuf
+00000000 T _XmbufGetScreenInfo libXext XMultibuf
+00000000 T _XmbufCreateStereoWindow libXext XMultibuf
+00000000 T _XShapeQueryExtension libXext XShape
+00000000 T _XShapeQueryVersion libXext XShape
+00000000 T _XShapeCombineRegion libXext XShape
+00000000 T _XShapeCombineRectangles libXext XShape
+00000000 T _XShapeCombineMask libXext XShape
+00000000 T _XShapeCombineShape libXext XShape
+00000000 T _XShapeOffsetShape libXext XShape
+00000000 T _XShapeQueryExtents libXext XShape
+00000000 T _XShapeSelectInput libXext XShape
+00000000 T _XShapeInputSelected libXext XShape
+00000000 T _XShapeGetRectangles libXext XShape
+00000000 T _XMITMiscQueryExtension libXext MITMisc
+00000000 T _XMITMiscSetBugMode libXext MITMisc
+00000000 T _XMITMiscGetBugMode libXext MITMisc
+00000000 T _XTestFakeInput libXext XTestExt1
+00000000 T _XTestGetInput libXext XTestExt1
+00000000 T _XTestStopInput libXext XTestExt1
+00000000 T _XTestReset libXext XTestExt1
+00000000 T _XTestQueryInputSize libXext XTestExt1
+00000000 T _XTestPressKey libXext XTestExt1
+00000000 T _XTestPressButton libXext XTestExt1
+00000000 T _XTestMovePointer libXext XTestExt1
+00000000 T _XTestFlush libXext XTestExt1
+00000000 T _XAllowDeviceEvents libXi XAllowDv
+00000000 T _XChangeDeviceControl libXi XChgDCtl
+00000000 T _XChangeFeedbackControl libXi XChgFCtl
+00000000 T _XChangeKeyboardDevice libXi XChgKbd
+00000000 T _XChangeDeviceKeyMapping libXi XChgKMap
+00000000 T _XChangePointerDevice libXi XChgPnt
+00000000 T _XChangeDeviceDontPropagateList libXi XChgProp
+00000000 T _XCloseDevice libXi XCloseDev
+00000000 T _XDeviceBell libXi XDevBell
+00000000 T _XGetDeviceButtonMapping libXi XGetBMap
+00000000 T _XGetDeviceControl libXi XGetDCtl
+00000000 T _XFreeDeviceControl libXi XGetDCtl
+00000000 T _XGetFeedbackControl libXi XGetFCtl
+00000000 T _XFreeFeedbackList libXi XGetFCtl
+00000000 T _XGetDeviceKeyMapping libXi XGetKMap
+00000000 T _XGetDeviceModifierMapping libXi XGetMMap
+00000000 T _XGetDeviceDontPropagateList libXi XGetProp
+00000000 T _XGetExtensionVersion libXi XGetVers
+00000000 T _XGetDeviceMotionEvents libXi XGMotion
+00000000 T _XFreeDeviceMotionEvents libXi XGMotion
+00000000 T _XGrabDevice libXi XGrabDev
+00000000 T _XGrabDeviceButton libXi XGrDvBut
+00000000 T _XGrabDeviceKey libXi XGrDvKey
+00000000 T _XGetDeviceFocus libXi XGtFocus
+00000000 T _XGetSelectedExtensionEvents libXi XGtSelect
+00000000 T _XListInputDevices libXi XListDev
+00000000 T _XFreeDeviceList libXi XListDev
+00000000 T _XOpenDevice libXi XOpenDev
+00000000 T _XQueryDeviceState libXi XQueryDv
+00000000 T _XFreeDeviceState libXi XQueryDv
+00000000 T _XSelectExtensionEvent libXi XSelect
+00000000 T _XSetDeviceButtonMapping libXi XSetBMap
+00000000 T _XSetDeviceValuators libXi XSetDVal
+00000000 T _XSetDeviceModifierMapping libXi XSetMMap
+00000000 T _XSetDeviceMode libXi XSetMode
+00000000 T _XSendExtensionEvent libXi XSndExEv
+00000000 T _XSetDeviceFocus libXi XStFocus
+00000000 T _XUngrabDevice libXi XUngrDev
+00000000 T _XUngrabDeviceButton libXi XUngrDvB
+00000000 T _XUngrabDeviceKey libXi XUngrDvK
+00000000 T _XInput_find_display libXi XExtInt
+00000000 T __xibaddevice libXi XExtInt
+00000000 T __xibadclass libXi XExtInt
+00000000 T __xibadevent libXi XExtInt
+00000000 T __xibadmode libXi XExtInt
+00000000 T __xidevicebusy libXi XExtInt
+00000000 T _XTestQueryExtension libXtst XTest
+00000000 T _XTestCompareCursorWithWindow libXtst XTest
+00000000 T _XTestCompareCurrentCursorWithWindow libXtst XTest
+00000000 T _XTestFakeKeyEvent libXtst XTest
+00000000 T _XTestFakeButtonEvent libXtst XTest
+00000000 T _XTestFakeMotionEvent libXtst XTest
+00000000 T _XTestFakeRelativeMotionEvent libXtst XTest
+00000000 T _XTestSetGContextOfGC libXtst XTest
+00000000 T _XTestSetVisualIDOfVisual libXtst XTest
+00000000 T _XTestDiscard libXtst XTest
+00000000 T _XShmQueryExtension libXext XShm
+00000000 T _XShmGetEventBase libXext XShm
+00000000 T _XShmQueryVersion libXext XShm
+00000000 T _XShmPixmapFormat libXext XShm
+00000000 T _XShmAttach libXext XShm
+00000000 T _XShmDetach libXext XShm
+00000000 T _XShmCreateImage libXext XShm
+00000000 T _XShmPutImage libXext XShm
+00000000 T _XShmGetImage libXext XShm
+00000000 T _XShmCreatePixmap libXext XShm
+00000000 T __XtPeekCallback libXt Callback
+00000000 T _XtCvtStringToRestartStyle libXt Converters
+00000000 T _XtCvtStringToGravity libXt Converters
+00000000 T __XtCreateHookObj libXt Create
+00000000 T _XtAppSetExitFlag libXt Display
+00000000 T _XtAppGetExitFlag libXt Display
+00000000 T __XtGetPerDisplay libXt Display
+00000000 T __XtGetPerDisplayInput libXt Display
+00000000 T _XtGetDisplays libXt Display
+00000000 T _XtRemoveEventTypeHandler libXt Event
+00000000 T _XtInsertEventTypeHandler libXt Event
+00000000 T _XtRegisterDrawable libXt Event
+00000000 T _XtUnregisterDrawable libXt Event
+00000000 T _XtDispatchEventToWidget libXt Event
+00000000 T _XtLastEventProcessed libXt Event
+00000000 T _XtSetEventDispatcher libXt Event
+00000000 T _XtRegisterExtensionSelector libXt Event
+00000000 T __XtExtensionSelect libXt Event
+00000000 T _XtAppAddBlockHook libXt Hooks
+00000000 T _XtRemoveBlockHook libXt Hooks
+00000000 T __XtAddShellToHookObj libXt Hooks
+00000000 T __XtIsHookObject libXt Hooks
+00000000 T _XtHooksOfDisplay libXt Hooks
+00000000 T __XtGetUserName libXt Initialize
+00000000 T _XtGetClassExtension libXt Intrinsic
+00000000 T _XtGetKeyboardFocusWidget libXt Keyboard
+00000000 T _XtChangeManagedSet libXt Manage
+00000000 T __XtWaitForSomething libXt NextEvent
+00000000 T _XtAddSignal libXt NextEvent
+00000000 T _XtAppAddSignal libXt NextEvent
+00000000 T _XtRemoveSignal libXt NextEvent
+00000000 T _XtNoticeSignal libXt NextEvent
+00000000 T _XtReservePropertyAtom libXt Selection
+00000000 T _XtReleasePropertyAtom libXt Selection
+00000000 T _XtCreateSelectionRequest libXt Selection
+00000000 T _XtSendSelectionRequest libXt Selection
+00000000 T _XtCancelSelectionRequest libXt Selection
+00000000 T _XtSetSelectionParameters libXt Selection
+00000000 T _XtGetSelectionParameters libXt Selection
+00000000 T _XtSessionGetToken libXt Shell
+00000000 T _XtSessionReturnToken libXt Shell
+00000000 T _XtAppLock libXt Threads
+00000000 T _XtAppUnlock libXt Threads
+00000000 T _XtProcessLock libXt Threads
+00000000 T _XtProcessUnlock libXt Threads
+00000000 T _XtToolkitThreadInitialize libXt Threads
+00000000 T __XtDoFreeBindings libXt TMaction
+00000000 T _XmbufClearBufferArea libXext XMultibuf
+00000000 T _XSyncQueryExtension libXext XSync
+00000000 T _XSyncInitialize libXext XSync
+00000000 T _XSyncListSystemCounters libXext XSync
+00000000 T _XSyncFreeSystemCounterList libXext XSync
+00000000 T _XSyncCreateCounter libXext XSync
+00000000 T _XSyncSetCounter libXext XSync
+00000000 T _XSyncChangeCounter libXext XSync
+00000000 T _XSyncDestroyCounter libXext XSync
+00000000 T _XSyncQueryCounter libXext XSync
+00000000 T _XSyncAwait libXext XSync
+00000000 T _XSyncCreateAlarm libXext XSync
+00000000 T _XSyncDestroyAlarm libXext XSync
+00000000 T _XSyncQueryAlarm libXext XSync
+00000000 T _XSyncChangeAlarm libXext XSync
+00000000 T _XSyncSetPriority libXext XSync
+00000000 T _XSyncGetPriority libXext XSync
+00000000 T _XSyncIntToValue libXext XSync
+00000000 T _XSyncIntsToValue libXext XSync
+00000000 T _XSyncValueGreaterThan libXext XSync
+00000000 T _XSyncValueLessThan libXext XSync
+00000000 T _XSyncValueGreaterOrEqual libXext XSync
+00000000 T _XSyncValueLessOrEqual libXext XSync
+00000000 T _XSyncValueEqual libXext XSync
+00000000 T _XSyncValueIsNegative libXext XSync
+00000000 T _XSyncValueIsZero libXext XSync
+00000000 T _XSyncValueIsPositive libXext XSync
+00000000 T _XSyncValueLow32 libXext XSync
+00000000 T _XSyncValueHigh32 libXext XSync
+00000000 T _XSyncValueAdd libXext XSync
+00000000 T _XSyncValueSubtract libXext XSync
+00000000 T _XSyncMaxValue libXext XSync
+00000000 T _XSyncMinValue libXext XSync
+00000000 T __XiEventToWire libXi XExtToWire
+00000000 T __XiCheckExtInit libXi XExtInt
+00000000 T _XTestFakeDeviceKeyEvent libXtst XTest
+00000000 T _XTestFakeDeviceButtonEvent libXtst XTest
+00000000 T _XTestFakeProximityEvent libXtst XTest
+00000000 T _XTestFakeDeviceMotionEvent libXtst XTest
+00000000 T _XTestGrabControl libXtst XTest
+00000000 T _XdbeQueryExtension libXext Xdbe
+00000000 T _XdbeAllocateBackBufferName libXext Xdbe
+00000000 T _XdbeDeallocateBackBufferName libXext Xdbe
+00000000 T _XdbeSwapBuffers libXext Xdbe
+00000000 T _XdbeBeginIdiom libXext Xdbe
+00000000 T _XdbeEndIdiom libXext Xdbe
+00000000 T _XdbeGetVisualInfo libXext Xdbe
+00000000 T _XdbeFreeVisualInfo libXext Xdbe
+00000000 T _XdbeGetBackBufferAttributes libXext Xdbe
+00000000 T _XRecordIdBaseMask libXtst XRecord
+00000000 T _XRecordQueryVersion libXtst XRecord
+00000000 T _XRecordCreateContext libXtst XRecord
+00000000 T _XRecordAllocRange libXtst XRecord
+00000000 T _XRecordRegisterClients libXtst XRecord
+00000000 T _XRecordUnregisterClients libXtst XRecord
+00000000 T _XRecordGetContext libXtst XRecord
+00000000 T _XRecordFreeState libXtst XRecord
+00000000 T _XRecordFreeData libXtst XRecord
+00000000 T _XRecordEnableContext libXtst XRecord
+00000000 T _XRecordEnableContextAsync libXtst XRecord
+00000000 T _XRecordProcessReplies libXtst XRecord
+00000000 T _XRecordDisableContext libXtst XRecord
+00000000 T _XRecordFreeContext libXtst XRecord
+00000000 T _XLbxQueryExtension libXext XLbx
+00000000 T _XLbxGetEventBase libXext XLbx
+00000000 T _XLbxQueryVersion libXext XLbx
+00000000 T _XSecurityQueryExtension libXext XSecurity
+00000000 T _XSecurityAllocXauth libXext XSecurity
+00000000 T _XSecurityFreeXauth libXext XSecurity
+00000000 T _XSecurityGenerateAuthorization libXext XSecurity
+00000000 T _XSecurityRevokeAuthorization libXext XSecurity
+00000000 T _XagQueryVersion libXext XAppgroup
+00000000 T _XagCreateEmbeddedApplicationGroup libXext XAppgroup
+00000000 T _XagCreateNonembeddedApplicationGroup libXext XAppgroup
+00000000 T _XagDestroyApplicationGroup libXext XAppgroup
+00000000 T _XagGetApplicationGroupAttributes libXext XAppgroup
+00000000 T _XagQueryApplicationGroup libXext XAppgroup
+00000000 T _XagCreateAssociation libXext XAppgroup
+00000000 T _XagDestroyAssociation libXext XAppgroup
+00000000 T _XpGetAttributes libXp XpAttr
+00000000 T _XpGetOneAttribute libXp XpAttr
+00000000 T _XpSetAttributes libXp XpAttr
+00000000 T _XpCreateContext libXp XpContext
+00000000 T _XpSetContext libXp XpContext
+00000000 T _XpGetContext libXp XpContext
+00000000 T _XpDestroyContext libXp XpContext
+00000000 T _XpGetScreenOfContext libXp XpContext
+00000000 T _XpStartDoc libXp XpDoc
+00000000 T _XpEndDoc libXp XpDoc
+00000000 T _XpCancelDoc libXp XpDoc
+00000000 T _xp_find_display libXp XpExtUtil
+00000000 T _XpCheckExtInit libXp XpExtUtil
+00000000 T _XpQueryExtension libXp XpExtVer
+00000000 T _XpQueryVersion libXp XpExtVer
+00000000 T _XpGetDocumentData libXp XpGetData
+00000000 T _XpSelectInput libXp XpInput
+00000000 T _XpInputSelected libXp XpInput
+00000000 T _XpStartJob libXp XpJob
+00000000 T _XpEndJob libXp XpJob
+00000000 T _XpCancelJob libXp XpJob
+00000000 T _XpSetLocaleHinter libXp XpLocale
+00000000 T _XpGetLocaleHinter libXp XpLocale
+00000000 T _XpGetLocaleNetString libXp XpLocale
+00000000 T _XpStartPage libXp XpPage
+00000000 T _XpEndPage libXp XpPage
+00000000 T _XpCancelPage libXp XpPage
+00000000 T _XpGetPdmStartParams libXp XpNotifyPdm
+00000000 T _XpSendOneTicket libXp XpNotifyPdm
+00000000 T _XpSendAuth libXp XpNotifyPdm
+00000000 T _XpGetAuthParams libXp XpNotifyPdm
+00000000 T _XpNotifyPdm libXp XpNotifyPdm
+00000000 T _XpGetPrinterList libXp XpPrinter
+00000000 T _XpFreePrinterList libXp XpPrinter
+00000000 T _XpRehashPrinterList libXp XpPrinter
+00000000 T _XpPutDocumentData libXp XpPutData
+00000000 T _XpQueryScreens libXp XpScreens
+00000000 T _XpGetPageDimensions libXp XpPageDim
+00000000 T _XpSetImageResolution libXp XpImageRes
+00000000 T _XpGetImageResolution libXp XpImageRes
diff --git a/nx-X11/lib/Xt/jump_ignore b/nx-X11/lib/Xt/jump_ignore
new file mode 100644
index 000000000..d2bfe7fcc
--- /dev/null
+++ b/nx-X11/lib/Xt/jump_ignore
@@ -0,0 +1,15 @@
+# $Xorg: jump_ignore,v 1.3 2000/08/17 19:46:21 cpqbld Exp $
+#
+#
+#
+#
+# $XFree86: xc/lib/Xt/jump_ignore,v 3.7 1996/12/30 13:58:32 dawes Exp $
+# jump_ignore
+00000000 T __XtFreeArgList libXt Varargs
+00000000 T __XtClearAncestorCache libXt Keyboard
+00000000 T __XtSnprintf libXt snprintf
+00000000 T __XtVsnprintf libXt snprintf
+00000000 D __xp_hinter_proc libXp XpLocale
+00000000 D __xp_hinter_desc libXp XpLocale
+00000000 D __xp_hinter_init libXp XpLocale
+00000000 T __xpstrdup libXp XpNotifyPdm
diff --git a/nx-X11/lib/Xt/jump_vars b/nx-X11/lib/Xt/jump_vars
new file mode 100644
index 000000000..2727363a2
--- /dev/null
+++ b/nx-X11/lib/Xt/jump_vars
@@ -0,0 +1,71 @@
+# $Xorg: jump_vars,v 1.3 2000/08/17 19:46:21 cpqbld Exp $
+#
+#
+#
+#
+# $XFree86: xc/lib/Xt/jump_vars,v 3.2 1995/01/28 15:44:05 dawes Exp $
+#
+00000100 D _compositeClassRec libXt Composite
+00000004 D _compositeWidgetClass libXt Composite
+00000140 D _constraintClassRec libXt Constraint
+00000004 D _constraintWidgetClass libXt Constraint
+00000040 D _colorConvertArgs libXt Converters
+00000020 D _screenConvertArg libXt Converters
+00000004 D __XtQString libXt Converters
+00000004 D __XtInheritTranslations libXt Core
+00000100 D _widgetClassRec libXt Core
+00000004 D _widgetClass libXt Core
+00000004 D _coreWidgetClass libXt Core
+00000004 D __XtAppDestroyCount libXt Display
+00000004 D __XtperDisplayList libXt Display
+00000004 D _XtCXtToolkitError libXt Intrinsic
+00000100 D _objectClassRec libXt Object
+00000004 D _objectClass libXt Object
+00000100 D _rectObjClassRec libXt RectObj
+00000004 D _rectObjClass libXt RectObj
+00000100 D _shellClassRec libXt Shell
+00000004 D _shellWidgetClass libXt Shell
+00000100 D _overrideShellClassRec libXt Shell
+00000004 D _overrideShellWidgetClass libXt Shell
+00000100 D _wmShellClassRec libXt Shell
+00000004 D _wmShellWidgetClass libXt Shell
+00000100 D _transientShellClassRec libXt Shell
+00000004 D _transientShellWidgetClass libXt Shell
+00000100 D _topLevelShellClassRec libXt Shell
+00000004 D _topLevelShellWidgetClass libXt Shell
+00000100 D _applicationShellClassRec libXt Shell
+00000004 D _applicationShellWidgetClass libXt Shell
+00000100 D _sessionShellClassRec libXt Shell
+00000004 D _sessionShellWidgetClass libXt Shell
+00001000 D _XtStrings libXt StringDefs
+00000800 D _XtShellStrings libXt StringDefs
+00000040 D __XtGlobalTM libXt TMstate
+00000100 D _vendorShellClassRec libXt Vendor
+00000004 D _vendorShellWidgetClass libXt Vendor
+00000004 D __XA_ATOM_PAIR libXmu Atoms
+00000004 D __XA_CHARACTER_POSITION libXmu Atoms
+00000004 D __XA_CLASS libXmu Atoms
+00000004 D __XA_CLIENT_WINDOW libXmu Atoms
+00000004 D __XA_CLIPBOARD libXmu Atoms
+00000004 D __XA_COMPOUND_TEXT libXmu Atoms
+00000004 D __XA_DECNET_ADDRESS libXmu Atoms
+00000004 D __XA_DELETE libXmu Atoms
+00000004 D __XA_FILENAME libXmu Atoms
+00000004 D __XA_HOSTNAME libXmu Atoms
+00000004 D __XA_IP_ADDRESS libXmu Atoms
+00000004 D __XA_LENGTH libXmu Atoms
+00000004 D __XA_LIST_LENGTH libXmu Atoms
+00000004 D __XA_NAME libXmu Atoms
+00000004 D __XA_NET_ADDRESS libXmu Atoms
+00000004 D __XA_NULL libXmu Atoms
+00000004 D __XA_OWNER_OS libXmu Atoms
+00000004 D __XA_SPAN libXmu Atoms
+00000004 D __XA_TARGETS libXmu Atoms
+00000004 D __XA_TEXT libXmu Atoms
+00000004 D __XA_TIMESTAMP libXmu Atoms
+00000004 D __XA_USER libXmu Atoms
+00000004 D __XExtensionErrorFunction libXext globals
+00000004 D _XTestInputActionType libXext XTestExt1
+00000004 D _XTestFakeAckType libXext XTestExt1
+00000100 D _hookObjClassRec libXt HookObj
+00000004 D _hookObjectClass libXt HookObj
diff --git a/nx-X11/lib/Xt/libXt.elist b/nx-X11/lib/Xt/libXt.elist
new file mode 100644
index 000000000..8f9fc8695
--- /dev/null
+++ b/nx-X11/lib/Xt/libXt.elist
@@ -0,0 +1,42 @@
+/* $Xorg: libXt.elist,v 1.3 2000/08/17 19:46:21 cpqbld Exp $ */
+
+/*************************************************************************
+ * Export list for libXt
+ * This list *must* be updated whenever a change is made to the API.
+ *
+ * The syntax for the symbol declarations in this list is below.
+ * public sym => Public C symbol, i.e., publicized API
+ * publicC++ sym => Public C++ symbol, i.e., publicized API
+ * private sym => Private C symbol, i.e., unpublicized API
+ * privateC++ sym => Private C++ symbol, i.e., unpublicized API
+ * internal sym => Internal C symbol, i.e., not part of API
+ * internalC++ sym => Internal C++ symbol, i.e., not part of API
+ * force sym => symbol to be exported even if not found. Some
+ * restrictions may apply. Avoid this directive.
+ *
+ * Note that exporting C++ symbols is not portable; different
+ * compilers may use different name mangling schemes and different
+ * hidden name (e.g. virtual function table) generation schemes.
+ *
+ * In addition a single "default" directive may appear, specifying how
+ * unmentioned symbols should be treated. The possible options are:
+ * default Warn about implicit symbols and hide them.
+ * default public Export public symbols implicitly.
+ * default private Export public symbols implicitly.
+ * default internal Hide public symbols implicitly.
+ *
+ *
+ **************************************************************************/
+
+/* We will not be naming symbols; export all public symbols in the library. */
+default public
+
+#ifdef AIXV4
+/*
+ * In earlier releases of this library, IBM exported some standard
+ * symbols from the system libraries. We must keep re-exporting these
+ * symbols for binary compatibility.
+ */
+force errno
+force _iob
+#endif
diff --git a/nx-X11/lib/Xt/sharedlib.c b/nx-X11/lib/Xt/sharedlib.c
new file mode 100644
index 000000000..699302ced
--- /dev/null
+++ b/nx-X11/lib/Xt/sharedlib.c
@@ -0,0 +1,236 @@
+/* $Xorg: sharedlib.c,v 1.4 2001/02/09 02:03:59 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/Xt/sharedlib.c,v 3.7 2002/05/31 18:45:46 dawes Exp $ */
+
+#if (defined(SUNSHLIB) || defined(AIXSHLIB)) && !defined(SHAREDCODE)
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "IntrinsicI.h"
+#include "VarargsI.h"
+#include "ShellP.h"
+#include "VendorP.h"
+#include "CreateI.h"
+
+
+#if defined(AIXSHLIB) || defined(__UNIXOS2__)
+WidgetClass vendorShellWidgetClass = (WidgetClass) &vendorShellClassRec;
+
+static void _XtVendorInitialize()
+{
+ transientShellWidgetClass->core_class.superclass =
+ (WidgetClass) &vendorShellClassRec;
+ topLevelShellWidgetClass->core_class.superclass =
+ (WidgetClass) &vendorShellClassRec;
+}
+
+#define VENDORINIT _XtVendorInitialize();
+
+#else
+
+#define VENDORINIT /* as nothing */
+
+#endif
+
+#ifdef SUNSHLIB
+/*
+ * _XtInherit needs to be statically linked since it is compared against as
+ * well as called.
+ */
+void _XtInherit()
+{
+ extern void __XtInherit();
+ __XtInherit();
+}
+#endif
+
+/*
+ * The following routine will be called by every toolkit
+ * application, forcing this file to be statically linked.
+ *
+ * Note: XtInitialize, XtAppInitialize, and XtOpenApplication
+ * call XtToolkitInitialize.
+ */
+
+void XtToolkitInitialize()
+{
+ extern void _XtToolkitInitialize();
+ VENDORINIT
+ _XtToolkitInitialize();
+}
+
+Widget
+XtInitialize(
+ _Xconst char* name,
+ _Xconst char* classname,
+ XrmOptionDescRec *options,
+ Cardinal num_options,
+ int *argc,
+ String *argv)
+{
+ extern Widget _XtInitialize();
+ VENDORINIT
+ return _XtInitialize (name, classname, options, num_options, argc, argv);
+}
+
+Widget
+XtAppInitialize(
+ XtAppContext * app_context_return,
+ _Xconst char* application_class,
+ XrmOptionDescRec *options,
+ Cardinal num_options,
+ int *argc_in_out,
+ String *argv_in_out,
+ String *fallback_resources,
+ ArgList args_in,
+ Cardinal num_args_in)
+{
+ extern Widget _XtAppInitialize();
+ VENDORINIT
+ return _XtAppInitialize (app_context_return, application_class, options,
+ num_options, argc_in_out, argv_in_out,
+ fallback_resources, args_in, num_args_in);
+}
+
+Widget
+XtVaAppInitialize(
+ XtAppContext *app_context_return,
+ _Xconst char* application_class,
+ XrmOptionDescList options,
+ Cardinal num_options,
+ int *argc_in_out,
+ String *argv_in_out,
+ String *fallback_resources,
+ ...)
+{
+ va_list var;
+ extern Widget _XtVaAppInitialize();
+
+ VENDORINIT
+ va_start(var, fallback_resources);
+ return _XtVaAppInitialize(app_context_return, application_class, options,
+ num_options, argc_in_out, argv_in_out,
+ fallback_resources, var);
+}
+
+Widget
+XtOpenApplication(
+ XtAppContext * app_context_return,
+ _Xconst char* application_class,
+ XrmOptionDescRec *options,
+ Cardinal num_options,
+ int *argc_in_out,
+ String *argv_in_out,
+ String *fallback_resources,
+ WidgetClass widget_class,
+ ArgList args_in,
+ Cardinal num_args_in)
+{
+ extern Widget _XtOpenApplication();
+ VENDORINIT
+ return _XtOpenApplication (app_context_return, application_class, options,
+ num_options, argc_in_out, argv_in_out,
+ fallback_resources, widget_class,
+ args_in, num_args_in);
+}
+
+Widget
+XtVaOpenApplication(
+ XtAppContext *app_context_return,
+ _Xconst char* application_class,
+ XrmOptionDescList options,
+ Cardinal num_options,
+ int *argc_in_out,
+ String *argv_in_out,
+ String *fallback_resources,
+ WidgetClass widget_class,
+ ...)
+{
+ va_list var;
+ extern Widget _XtVaOpenApplication();
+
+ VENDORINIT
+ va_start(var, widget_class);
+ return _XtVaOpenApplication(app_context_return, application_class, options,
+ num_options, argc_in_out, argv_in_out,
+ fallback_resources, widget_class, var);
+}
+
+#else
+
+#ifndef lint
+static int dummy; /* avoid warning from ranlib */
+#endif
+
+#endif /* SUNSHLIB or AIXSHLIB */
+
+#if defined(SUNSHLIB) && !defined(SHAREDCODE)
+
+int _XtInheritTranslations = 0;
+
+extern CompositeClassRec compositeClassRec;
+WidgetClass compositeWidgetClass = (WidgetClass) &compositeClassRec;
+
+extern ConstraintClassRec constraintClassRec;
+WidgetClass constraintWidgetClass = (WidgetClass) &constraintClassRec;
+
+extern WidgetClassRec widgetClassRec;
+WidgetClass widgetClass = &widgetClassRec;
+WidgetClass coreWidgetClass = &widgetClassRec;
+
+extern ObjectClassRec objectClassRec;
+WidgetClass objectClass = (WidgetClass)&objectClassRec;
+
+extern RectObjClassRec rectObjClassRec;
+WidgetClass rectObjClass = (WidgetClass)&rectObjClassRec;
+
+extern ShellClassRec shellClassRec;
+WidgetClass shellWidgetClass = (WidgetClass) &shellClassRec;
+
+extern OverrideShellClassRec overrideShellClassRec;
+WidgetClass overrideShellWidgetClass = (WidgetClass) &overrideShellClassRec;
+
+extern WMShellClassRec wmShellClassRec;
+WidgetClass wmShellWidgetClass = (WidgetClass) &wmShellClassRec;
+
+extern TransientShellClassRec transientShellClassRec;
+WidgetClass transientShellWidgetClass = (WidgetClass) &transientShellClassRec;
+
+extern TopLevelShellClassRec topLevelShellClassRec;
+WidgetClass topLevelShellWidgetClass = (WidgetClass) &topLevelShellClassRec;
+
+extern ApplicationShellClassRec applicationShellClassRec;
+WidgetClass applicationShellWidgetClass = (WidgetClass) &applicationShellClassRec;
+
+extern SessionShellClassRec sessionShellClassRec;
+WidgetClass sessionShellWidgetClass = (WidgetClass) &sessionShellClassRec;
+
+extern HookObjClassRec hookObjClassRec;
+WidgetClass hookObjectClass = (WidgetClass) &hookObjClassRec;
+
+#endif /* SUNSHLIB */
diff --git a/nx-X11/lib/Xt/util/Shell.ht b/nx-X11/lib/Xt/util/Shell.ht
new file mode 100644
index 000000000..c9e7e01ea
--- /dev/null
+++ b/nx-X11/lib/Xt/util/Shell.ht
@@ -0,0 +1,97 @@
+/* $Xorg: Shell.ht,v 1.5 2001/02/09 02:03:59 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/util/Shell.ht,v 3.4 2001/07/29 05:01:12 tsi Exp $ */
+
+#ifndef _XtShell_h
+#define _XtShell_h
+
+#include <X11/SM/SMlib.h>
+#include <X11/Intrinsic.h>
+
+/***********************************************************************
+ *
+ * Shell Widget
+ *
+ ***********************************************************************/
+/*
+ * Shell-specific resources names, classes, and a representation type.
+ */
+
+#ifndef XTSTRINGDEFINES
+#define _XtShell_h_Const const
+#endif
+
+<<<STRING_TABLE_GOES_HERE>>>
+
+#ifndef XTSTRINGDEFINES
+#undef _XtShell_h_Const
+#endif
+
+/* Class record constants */
+
+typedef struct _ShellClassRec *ShellWidgetClass;
+typedef struct _OverrideShellClassRec *OverrideShellWidgetClass;
+typedef struct _WMShellClassRec *WMShellWidgetClass;
+typedef struct _TransientShellClassRec *TransientShellWidgetClass;
+typedef struct _TopLevelShellClassRec *TopLevelShellWidgetClass;
+typedef struct _ApplicationShellClassRec *ApplicationShellWidgetClass;
+typedef struct _SessionShellClassRec *SessionShellWidgetClass;
+
+#ifndef SHELL
+externalref WidgetClass shellWidgetClass;
+externalref WidgetClass overrideShellWidgetClass;
+externalref WidgetClass wmShellWidgetClass;
+externalref WidgetClass transientShellWidgetClass;
+externalref WidgetClass topLevelShellWidgetClass;
+externalref WidgetClass applicationShellWidgetClass;
+externalref WidgetClass sessionShellWidgetClass;
+#endif
+
+#endif /* _XtShell_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/nx-X11/lib/Xt/util/StrDefs.ct b/nx-X11/lib/Xt/util/StrDefs.ct
new file mode 100644
index 000000000..ea971f153
--- /dev/null
+++ b/nx-X11/lib/Xt/util/StrDefs.ct
@@ -0,0 +1,54 @@
+/* $Xorg: StrDefs.ct,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/util/StrDefs.ct,v 3.4 2001/07/29 05:01:12 tsi Exp $ */
+
+#define Const const
+
+<<<STRING_TABLE_GOES_HERE>>>
+
diff --git a/nx-X11/lib/Xt/util/StrDefs.ht b/nx-X11/lib/Xt/util/StrDefs.ht
new file mode 100644
index 000000000..c23759c46
--- /dev/null
+++ b/nx-X11/lib/Xt/util/StrDefs.ht
@@ -0,0 +1,64 @@
+/* $Xorg: StrDefs.ht,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 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.
+
+
+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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xt/util/StrDefs.ht,v 3.4 2001/07/29 05:01:12 tsi Exp $ */
+
+#ifndef _XtStringDefs_h_
+#define _XtStringDefs_h_
+
+#ifndef XTSTRINGDEFINES
+#define _XtStringDefs_h_Const const
+#endif
+
+<<<STRING_TABLE_GOES_HERE>>>
+
+#ifndef XTSTRINGDEFINES
+#undef _XtStringDefs_h_Const
+#endif
+
+#endif /* _XtStringDefs_h_ */
diff --git a/nx-X11/lib/Xt/util/string.list b/nx-X11/lib/Xt/util/string.list
new file mode 100644
index 000000000..bef098c2f
--- /dev/null
+++ b/nx-X11/lib/Xt/util/string.list
@@ -0,0 +1,399 @@
+! $Xorg: string.list,v 1.3 2000/08/17 19:46:22 cpqbld Exp $
+! NOTE: To maintain binary compatibility, you can only APPEND items within
+! a given list!!!!
+!
+! See the makestrs(1) manual.
+!
+
+#prefix Xt
+#feature XTSTRINGDEFINES
+#externref extern
+#externdef
+! note that the trailing space is required in the #externdef line.
+#ctmpl util/StrDefs.ct
+
+#file StringDefs.h
+#table XtStrings
+#htmpl util/StrDefs.ht
+
+Naccelerators
+NallowHoriz
+NallowVert
+NancestorSensitive
+Nbackground
+NbackgroundPixmap
+Nbitmap
+NborderColor
+Nborder borderColor
+NborderPixmap
+NborderWidth
+Ncallback
+Nchildren
+Ncolormap
+Ndepth
+NdestroyCallback
+NeditType
+Nfile
+Nfont
+NforceBars
+Nforeground
+Nfunction
+Nheight
+Nhighlight
+NhSpace
+Nindex
+NinitialResourcesPersistent
+NinnerHeight
+NinnerWidth
+NinnerWindow
+NinsertPosition
+NinternalHeight
+NinternalWidth
+NjumpProc
+Njustify
+NknobHeight
+NknobIndent
+NknobPixel
+NknobWidth
+Nlabel
+Nlength
+NlowerRight
+NmappedWhenManaged
+NmenuEntry
+Nname
+Nnotify
+NnumChildren
+Norientation
+Nparameter
+Npixmap
+NpopupCallback
+NpopdownCallback
+Nresize
+NreverseVideo
+Nscreen
+NscrollProc
+NscrollDCursor
+NscrollHCursor
+NscrollLCursor
+NscrollRCursor
+NscrollUCursor
+NscrollVCursor
+Nselection
+NselectionArray
+Nsensitive
+Nshown
+Nspace
+Nstring
+NtextOptions
+NtextSink
+NtextSource
+Nthickness
+Nthumb
+NthumbProc
+Ntop
+Ntranslations
+NunrealizeCallback
+Nupdate
+NuseBottom
+NuseRight
+Nvalue
+NvSpace
+Nwidth
+Nwindow
+Nx
+Ny
+CAccelerators
+CBackground
+CBitmap
+CBoolean
+CBorderColor
+CBorderWidth
+CCallback
+CColormap
+CColor
+CCursor
+CDepth
+CEditType
+CEventBindings
+CFile
+CFont
+CForeground
+CFraction
+CFunction
+CHeight
+CHSpace
+CIndex
+CInitialResourcesPersistent
+CInsertPosition
+CInterval
+CJustify
+CKnobIndent
+CKnobPixel
+CLabel
+CLength
+CMappedWhenManaged
+CMargin
+CMenuEntry
+CNotify
+COrientation
+CParameter
+CPixmap
+CPosition
+CReadOnly
+CResize
+CReverseVideo
+CScreen
+CScrollProc
+CScrollDCursor
+CScrollHCursor
+CScrollLCursor
+CScrollRCursor
+CScrollUCursor
+CScrollVCursor
+CSelection
+CSensitive
+CSelectionArray
+CSpace
+CString
+CTextOptions
+CTextPosition
+CTextSink
+CTextSource
+CThickness
+CThumb
+CTranslations
+CValue
+CVSpace
+CWidth
+CWindow
+CX
+CY
+RAcceleratorTable
+RAtom
+RBitmap
+RBool
+RBoolean
+RCallback
+RCallProc
+RCardinal
+RColor
+RColormap
+RCursor
+RDimension
+RDisplay
+REditMode
+REnum
+RFile
+RFloat
+RFont
+RFontStruct
+RFunction
+RGeometry
+RImmediate
+RInitialState
+RInt
+RJustify
+RLongBoolean Bool
+RObject
+ROrientation
+RPixel
+RPixmap
+RPointer
+RPosition
+RScreen
+RShort
+RString
+RStringArray
+RStringTable
+RUnsignedChar
+RTranslationTable
+RVisual
+RWidget
+RWidgetClass
+RWidgetList
+RWindow
+Eoff
+Efalse
+Eno
+Eon
+Etrue
+Eyes
+Evertical
+Ehorizontal
+EtextRead read
+EtextAppend append
+EtextEdit edit
+Extdefaultbackground
+Extdefaultforeground
+Extdefaultfont
+NfontSet
+RFontSet
+CFontSet
+
+#table XtStringsR6
+
+RGravity
+NcreateHook
+NchangeHook
+NconfigureHook
+NgeometryHook
+NdestroyHook
+Nshells
+NnumShells
+RCommandArgArray
+RDirectoryString
+REnvironmentArray
+RRestartStyle
+RSmcConn
+Hcreate
+HsetValues
+HmanageChildren
+HunmanageChildren
+HmanageSet
+HunmanageSet
+HrealizeWidget
+HunrealizeWidget
+HaddCallback
+HaddCallbacks
+HremoveCallback
+HremoveCallbacks
+HremoveAllCallbacks
+HaugmentTranslations
+HoverrideTranslations
+HuninstallTranslations
+HsetKeyboardFocus
+HsetWMColormapWindows
+HsetMappedWhenManaged
+HmapWidget
+HunmapWidget
+Hpopup
+HpopupSpringLoaded
+Hpopdown
+Hconfigure
+HpreGeometry
+HpostGeometry
+Hdestroy
+
+#file Shell.h
+#table XtShellStrings
+#htmpl util/Shell.ht
+
+NiconName
+CIconName
+NiconPixmap
+CIconPixmap
+NiconWindow
+CIconWindow
+NiconMask
+CIconMask
+NwindowGroup
+CWindowGroup
+Nvisual
+CVisual
+NtitleEncoding
+CTitleEncoding
+NsaveUnder
+CSaveUnder
+Ntransient
+CTransient
+NoverrideRedirect
+COverrideRedirect
+NtransientFor
+CTransientFor
+NiconNameEncoding
+CIconNameEncoding
+NallowShellResize
+CAllowShellResize
+NcreatePopupChildProc
+CCreatePopupChildProc
+Ntitle
+CTitle
+RAtom
+Nargc
+CArgc
+Nargv
+CArgv
+NiconX
+CIconX
+NiconY
+CIconY
+Ninput
+CInput
+Niconic
+CIconic
+NinitialState
+CInitialState
+Ngeometry
+CGeometry
+NbaseWidth
+CBaseWidth
+NbaseHeight
+CBaseHeight
+NwinGravity
+CWinGravity
+NminWidth
+CMinWidth
+NminHeight
+CMinHeight
+NmaxWidth
+CMaxWidth
+NmaxHeight
+CMaxHeight
+NwidthInc
+CWidthInc
+NheightInc
+CHeightInc
+NminAspectY
+CMinAspectY
+NmaxAspectY
+CMaxAspectY
+NminAspectX
+CMinAspectX
+NmaxAspectX
+CMaxAspectX
+NwmTimeout
+CWmTimeout
+NwaitForWm waitforwm
+CWaitForWm Waitforwm
+
+#table XtShellStringsR6
+
+Nwaitforwm
+CWaitforwm
+NclientLeader
+CClientLeader
+NwindowRole
+CWindowRole
+Nurgency
+CUrgency
+NcancelCallback
+NcloneCommand
+CCloneCommand
+Nconnection
+CConnection
+NcurrentDirectory
+CCurrentDirectory
+NdieCallback
+NdiscardCommand
+CDiscardCommand
+Nenvironment
+CEnvironment
+NinteractCallback
+NjoinSession
+CJoinSession
+NprogramPath
+CProgramPath
+NresignCommand
+CResignCommand
+NrestartCommand
+CRestartCommand
+NrestartStyle
+CRestartStyle
+NsaveCallback
+NsaveCompleteCallback
+NsessionID
+CSessionID
+NshutdownCommand
+CShutdownCommand
+NerrorCallback
+
diff --git a/nx-X11/lib/Xtst/Imakefile b/nx-X11/lib/Xtst/Imakefile
new file mode 100644
index 000000000..b3dd9f7e7
--- /dev/null
+++ b/nx-X11/lib/Xtst/Imakefile
@@ -0,0 +1,32 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:23 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/Xtst/Imakefile,v 1.2 1998/12/20 11:57:12 dawes Exp $
+
+#define DoNormalLib NormalLibXtst
+#define DoSharedLib SharedLibXtst
+#define DoExtraLib SharedLibXtst
+#define DoDebugLib DebugLibXtst
+#define DoProfileLib ProfileLibXtst
+#define LibName Xtst
+#define SoRev SOXTESTREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXtstReqs
+REQUIREDLIBS = SharedXtstReqs
+#endif
+
+INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC)
+
+SRCS = XTest.c XRecord.c
+OBJS = XTest.o XRecord.o
+
+LINTLIBS = $(LINTXLIB)
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/Xtst/XRecord.c b/nx-X11/lib/Xtst/XRecord.c
new file mode 100644
index 000000000..16eaeffd7
--- /dev/null
+++ b/nx-X11/lib/Xtst/XRecord.c
@@ -0,0 +1,1103 @@
+/*
+$Xorg: XRecord.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $
+
+XRecord.c - client-side library for RECORD extension
+
+Copyright 1995, 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 1995 Network Computing Devices
+ *
+ * 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 of Network Computing Devices
+ * not be used in advertising or publicity pertaining to distribution
+ * of the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES DISCLAIMs ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES 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.
+ **************************************************************************/
+/*
+ * By Stephen Gildea, X Consortium, and Martha Zimet, NCD.
+ */
+/* $XFree86: xc/lib/Xtst/XRecord.c,v 1.6 2002/10/16 00:37:33 dawes Exp $ */
+
+#include <stdio.h>
+#include <assert.h>
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/recordstr.h>
+
+static XExtensionInfo _xrecord_info_data;
+static XExtensionInfo *xrecord_info = &_xrecord_info_data;
+static /* const */ char *xrecord_extension_name = RECORD_NAME;
+
+#define XRecordCheckExtension(dpy,i,val) \
+ XextCheckExtension(dpy, i, xrecord_extension_name, val)
+
+/**************************************************************************
+ * *
+ * private utility routines *
+ * *
+ **************************************************************************/
+
+static XExtDisplayInfo *find_display();
+
+/*
+ * A reply buffer holds a reply from RecordEnableContext.
+ * Pieces of that buffer are passed to the XRecordEnableContext callback.
+ * ref_count is incremented each time we do that.
+ * ref_count is decremented each time XRecordFreeData is called on
+ * the buffer. When ref_count is 0, we can free or reuse the buffer.
+ */
+struct reply_buffer
+{
+ struct reply_buffer *next; /* next in list or NULL */
+ unsigned char *buf; /* pointer to malloc'd buffer */
+ int nbytes; /* size of buf */
+ int ref_count; /* callback uses pending */
+};
+
+
+/*
+ * There's some extra information the implementation finds useful
+ * to attach to an XRecordInterceptData packet to handle memory
+ * management. So we really allocate one of these.
+ */
+struct intercept_queue
+{
+ /* this struct gets passed to the user as an XRecordInterceptData,
+ so the data field must come first so we can cast the address
+ back and forth */
+ XRecordInterceptData data;
+ struct intercept_queue *next; /* next in free list or NULL */
+ struct mem_cache_str *cache; /* contains head of free list */
+};
+
+/*
+ * per-display pointers to cache of malloc'd but unused memory
+ */
+struct mem_cache_str
+{
+ struct intercept_queue *inter_data; /* free structs only */
+ struct reply_buffer *reply_buffers; /* all reply buffers */
+ int inter_data_count; /* total allocated, free and in use */
+ Bool display_closed; /* so we know when to free ourself */
+};
+
+static int close_display(dpy, codes)
+ Display *dpy;
+ XExtCodes *codes; /* not used */
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ LockDisplay(dpy);
+ if (info && info->data) {
+ struct mem_cache_str *cache = (struct mem_cache_str *)info->data;
+ struct intercept_queue *iq, *iq_next;
+ struct reply_buffer *rbp, **rbp_next_p;
+
+ for (iq=cache->inter_data; iq; iq=iq_next) {
+ iq_next = iq->next;
+ XFree(iq);
+ cache->inter_data_count--;
+ }
+
+ /* this is a little trickier, because some of these
+ might still be in use */
+ for (rbp_next_p = &cache->reply_buffers; *rbp_next_p; ) {
+ rbp = *rbp_next_p;
+ if (rbp->ref_count == 0) {
+ *rbp_next_p = rbp->next;
+ XFree(rbp->buf);
+ XFree(rbp);
+ } else {
+ rbp_next_p = &rbp->next;
+ }
+ }
+
+ if (cache->reply_buffers == NULL && cache->inter_data_count == 0) {
+ /* every thing has been freed, can free ourselves, too */
+ XFree(cache);
+ } else {
+ cache->display_closed = True;
+ cache->inter_data = NULL; /* neatness only; won't be used */
+ }
+ }
+ UnlockDisplay(dpy);
+ return XextRemoveDisplay(xrecord_info, dpy);
+}
+
+static XPointer alloc_mem_cache()
+{
+ struct mem_cache_str *cache;
+
+ /* note that an error will go unnoticed */
+ cache = (struct mem_cache_str *) Xmalloc(sizeof(struct mem_cache_str));
+ if (cache) {
+ cache->display_closed = False;
+ cache->inter_data = NULL;
+ cache->inter_data_count = 0;
+ cache->reply_buffers = NULL;
+ }
+ return (XPointer) cache;
+}
+
+static char *xrecord_error_list[] = {
+ "XRecordBadContext (Not a defined RECORD context)",
+};
+
+static XEXT_GENERATE_ERROR_STRING (error_string, xrecord_extension_name,
+ RecordNumErrors, xrecord_error_list)
+
+static XExtensionHooks xrecord_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ error_string /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xrecord_info,
+ xrecord_extension_name, &xrecord_extension_hooks, RecordNumEvents,
+ alloc_mem_cache())
+
+/**************************************************************************
+ * *
+ * private library routines *
+ * *
+ **************************************************************************/
+
+static void
+SendRange(dpy, range_item, nranges)
+ Display *dpy;
+ XRecordRange **range_item;
+ int nranges;
+{
+ int rlen = SIZEOF(xRecordRange);
+ while(nranges--)
+ {
+ xRecordRange xrange;
+
+ xrange.coreRequestsFirst = (*range_item)->core_requests.first;
+ xrange.coreRequestsLast = (*range_item)->core_requests.last;
+ xrange.coreRepliesFirst = (*range_item)->core_replies.first;
+ xrange.coreRepliesLast = (*range_item)->core_replies.last;
+ xrange.extRequestsMajorFirst = (*range_item)->ext_requests.ext_major.first;
+ xrange.extRequestsMajorLast = (*range_item)->ext_requests.ext_major.last;
+ xrange.extRequestsMinorFirst = (*range_item)->ext_requests.ext_minor.first;
+ xrange.extRequestsMinorLast = (*range_item)->ext_requests.ext_minor.last;
+ xrange.extRepliesMajorFirst = (*range_item)->ext_replies.ext_major.first;
+ xrange.extRepliesMajorLast = (*range_item)->ext_replies.ext_major.last;
+ xrange.extRepliesMinorFirst = (*range_item)->ext_replies.ext_minor.first;
+ xrange.extRepliesMinorLast = (*range_item)->ext_replies.ext_minor.last;
+ xrange.deliveredEventsFirst = (*range_item)->delivered_events.first;
+ xrange.deliveredEventsLast = (*range_item)->delivered_events.last;
+ xrange.deviceEventsFirst = (*range_item)->device_events.first;
+ xrange.deviceEventsLast = (*range_item)->device_events.last;
+ xrange.errorsFirst = (*range_item)->errors.first;
+ xrange.errorsLast = (*range_item)->errors.last;
+ xrange.clientStarted = (*range_item)->client_started;
+ xrange.clientDied = (*range_item)->client_died;
+
+ Data(dpy, (char *)&xrange, rlen);
+ range_item++;
+ }
+}
+
+/**************************************************************************
+ * *
+ * public routines *
+ * *
+ **************************************************************************/
+
+XID
+XRecordIdBaseMask(dpy)
+ Display *dpy;
+{
+ return 0x1fffffff & ~dpy->resource_mask;
+}
+
+Status
+XRecordQueryVersion (dpy, cmajor_return, cminor_return)
+ Display *dpy;
+ int *cmajor_return, *cminor_return;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xRecordQueryVersionReq *req;
+ xRecordQueryVersionReply rep;
+
+ XRecordCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(RecordQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->recordReqType = X_RecordQueryVersion;
+ req->majorVersion = RECORD_MAJOR_VERSION;
+ req->minorVersion = RECORD_MINOR_VERSION;
+ if (!_XReply(dpy,(xReply *)&rep, 0, True)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *cmajor_return = rep.majorVersion;
+ *cminor_return = rep.minorVersion;
+ return ((rep.majorVersion == RECORD_MAJOR_VERSION) &&
+ (rep.minorVersion >= RECORD_LOWEST_MINOR_VERSION));
+}
+
+XRecordContext
+XRecordCreateContext(dpy, datum_flags, clients, nclients, ranges, nranges)
+ Display *dpy;
+ int datum_flags;
+ XRecordClientSpec *clients;
+ int nclients;
+ XRecordRange **ranges;
+ int nranges;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xRecordCreateContextReq *req;
+ int clen = 4 * nclients;
+
+ XRecordCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RecordCreateContext, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->recordReqType = X_RecordCreateContext;
+ req->context = XAllocID(dpy);
+ req->length += (nclients * 4 +
+ nranges * SIZEOF(xRecordRange)) >> 2;
+ req->elementHeader = datum_flags;
+ req->nClients = nclients;
+ req->nRanges = nranges;
+
+ Data32(dpy, (long *)clients, clen);
+ SendRange(dpy, ranges, nranges);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return req->context;
+}
+
+XRecordRange *
+XRecordAllocRange()
+{
+ return (XRecordRange*)Xcalloc(1, sizeof(XRecordRange));
+}
+
+Status
+XRecordRegisterClients(dpy, context, datum_flags, clients, nclients, ranges, nranges)
+ Display *dpy;
+ XRecordContext context;
+ int datum_flags;
+ XRecordClientSpec *clients;
+ int nclients;
+ XRecordRange **ranges;
+ int nranges;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xRecordRegisterClientsReq *req;
+ int clen = 4 * nclients;
+
+ XRecordCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RecordRegisterClients, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->recordReqType = X_RecordRegisterClients;
+ req->context = context;
+ req->length += (nclients * 4 +
+ nranges * SIZEOF(xRecordRange)) >> 2;
+ req->elementHeader = datum_flags;
+ req->nClients = nclients;
+ req->nRanges = nranges;
+
+ Data32(dpy, (long *)clients, clen);
+ SendRange(dpy, ranges, nranges);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+Status
+XRecordUnregisterClients(dpy, context, clients, nclients)
+ Display *dpy;
+ XRecordContext context;
+ XRecordClientSpec *clients;
+ int nclients;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xRecordUnregisterClientsReq *req;
+ int clen = 4 * nclients;
+
+ XRecordCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RecordUnregisterClients, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->recordReqType = X_RecordUnregisterClients;
+ req->context = context;
+ req->length += nclients;
+ req->nClients = nclients;
+
+ Data32(dpy, (long *)clients, clen);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+static void
+WireToLibRange(wire_range, lib_range)
+ xRecordRange *wire_range;
+ XRecordRange *lib_range;
+{
+ lib_range->core_requests.first = wire_range->coreRequestsFirst;
+ lib_range->core_requests.last = wire_range->coreRequestsLast;
+ lib_range->core_replies.first = wire_range->coreRepliesFirst;
+ lib_range->core_replies.last = wire_range->coreRepliesLast;
+ lib_range->ext_requests.ext_major.first = wire_range->extRequestsMajorFirst;
+ lib_range->ext_requests.ext_major.last = wire_range->extRequestsMajorLast;
+ lib_range->ext_requests.ext_minor.first = wire_range->extRequestsMinorFirst;
+ lib_range->ext_requests.ext_minor.last = wire_range->extRequestsMinorLast;
+ lib_range->ext_replies.ext_major.first = wire_range->extRepliesMajorFirst;
+ lib_range->ext_replies.ext_major.last = wire_range->extRepliesMajorLast;
+ lib_range->ext_replies.ext_minor.first = wire_range->extRepliesMinorFirst;
+ lib_range->ext_replies.ext_minor.last = wire_range->extRepliesMinorLast;
+ lib_range->delivered_events.first = wire_range->deliveredEventsFirst;
+ lib_range->delivered_events.last = wire_range->deliveredEventsLast;
+ lib_range->device_events.first = wire_range->deviceEventsFirst;
+ lib_range->device_events.last = wire_range->deviceEventsLast;
+ lib_range->errors.first = wire_range->errorsFirst;
+ lib_range->errors.last = wire_range->errorsLast;
+ lib_range->client_started = wire_range->clientStarted;
+ lib_range->client_died = wire_range->clientDied;
+}
+
+Status
+XRecordGetContext(dpy, context, state_return)
+ Display *dpy;
+ XRecordContext context;
+ XRecordState **state_return;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xRecordGetContextReq *req;
+ xRecordGetContextReply rep;
+ int count, i, rn;
+ xRecordRange xrange;
+ XRecordRange *ranges;
+ xRecordClientInfo xclient_inf;
+ XRecordClientInfo **client_inf, *client_inf_str;
+ XRecordState *ret;
+
+ XRecordCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RecordGetContext, req);
+ req->reqType = info->codes->major_opcode;
+ req->recordReqType = X_RecordGetContext;
+ req->context = context;
+ if (!_XReply(dpy,(xReply *)&rep, 0, False)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ count = rep.nClients;
+
+ ret = (XRecordState*)Xmalloc(sizeof(XRecordState));
+ if (!ret) {
+ /* XXX - eat data */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+
+ ret->enabled = rep.enabled;
+ ret->datum_flags = rep.elementHeader;
+ ret->nclients = count;
+
+ if (count)
+ {
+ client_inf = (XRecordClientInfo **) Xcalloc(count, sizeof(XRecordClientInfo*));
+ ret->client_info = client_inf;
+ client_inf_str = (XRecordClientInfo *) Xmalloc(count*sizeof(XRecordClientInfo));
+ if (!client_inf || !client_inf_str)
+ {
+ for(i = 0; i < count; i++)
+ {
+ _XEatData (dpy, sizeof(xRecordClientInfo));
+ _XEatData (dpy, SIZEOF(xRecordRange)); /* XXX - don't know how many */
+ }
+ UnlockDisplay(dpy);
+ XRecordFreeState(ret);
+ SyncHandle();
+ return 0;
+ }
+ for(i = 0; i < count; i++)
+ {
+ client_inf[i] = &(client_inf_str[i]);
+ _XRead(dpy, (char *)&xclient_inf, (long)sizeof(xRecordClientInfo));
+ client_inf_str[i].client = xclient_inf.clientResource;
+ client_inf_str[i].nranges = xclient_inf.nRanges;
+
+ if (xclient_inf.nRanges)
+ {
+ client_inf_str[i].ranges = (XRecordRange**) Xcalloc(xclient_inf.nRanges, sizeof(XRecordRange*));
+ ranges = (XRecordRange*) Xmalloc(xclient_inf.nRanges * sizeof(XRecordRange));
+ if (!client_inf_str[i].ranges || !ranges) {
+ /* XXX eat data */
+ UnlockDisplay(dpy);
+ XRecordFreeState(ret);
+ SyncHandle();
+ return 0;
+ }
+ for (rn=0; rn<xclient_inf.nRanges; rn++) {
+ client_inf_str[i].ranges[rn] = &(ranges[rn]);
+ _XRead(dpy, (char *)&xrange, (long)sizeof(xRecordRange));
+ WireToLibRange(&xrange, &(ranges[rn]));
+ }
+ } else {
+ client_inf_str[i].ranges = NULL;
+ }
+ }
+ } else {
+ ret->client_info = NULL;
+ }
+
+ *state_return = ret;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+void
+XRecordFreeState(state)
+ XRecordState *state;
+{
+ int i;
+
+ for(i=0; i<state->nclients; i++) {
+ if (state->client_info[i]->ranges) {
+ if (state->client_info[i]->ranges[0])
+ Xfree(state->client_info[i]->ranges[0]);
+ Xfree(state->client_info[i]->ranges);
+ }
+ }
+ if (state->client_info) {
+ if (state->client_info[0])
+ Xfree(state->client_info[0]);
+ Xfree(state->client_info);
+ }
+ Xfree(state);
+}
+
+static struct reply_buffer *alloc_reply_buffer(info, nbytes)
+ XExtDisplayInfo *info;
+ int nbytes;
+{
+ struct mem_cache_str *cache = (struct mem_cache_str *)info->data;
+ struct reply_buffer *rbp;
+ struct reply_buffer *saved_rb = NULL;
+ /*
+ * First look for an allocated buffer that is not in use.
+ * If we have a big enough buffer, use that, otherwise
+ * realloc an existing one.
+ */
+ for (rbp = cache->reply_buffers; rbp; rbp = rbp->next) {
+ if (rbp->ref_count == 0) {
+ if (rbp->nbytes >= nbytes)
+ return rbp;
+ else
+ saved_rb = rbp;
+ }
+ }
+ if (saved_rb) {
+ saved_rb->buf = (unsigned char *)Xrealloc(saved_rb->buf, nbytes);
+ if (!saved_rb->buf) {
+ saved_rb->nbytes = 0;
+ return NULL;
+ }
+ saved_rb->nbytes = nbytes;
+ return saved_rb;
+ }
+
+ /*
+ * nothing available; malloc a new struct
+ */
+ rbp = (struct reply_buffer *)Xmalloc(sizeof(struct reply_buffer));
+ if (!rbp)
+ return NULL;
+ rbp->buf = (unsigned char *)Xmalloc(nbytes);
+ if (!rbp->buf) {
+ Xfree(rbp);
+ return NULL;
+ }
+ rbp->nbytes = nbytes;
+ rbp->ref_count = 0;
+ rbp->next = cache->reply_buffers;
+ cache->reply_buffers = rbp;
+ return rbp;
+}
+
+static XRecordInterceptData *alloc_inter_data(info)
+ XExtDisplayInfo *info;
+{
+ struct mem_cache_str *cache = (struct mem_cache_str *)info->data;
+ struct intercept_queue *iq;
+
+ /* if there is one on the free list, pop it */
+ if (cache->inter_data) {
+ iq = cache->inter_data;
+ cache->inter_data = iq->next;
+ return &iq->data;
+ }
+ /* allocate a new one */
+ iq = (struct intercept_queue *)Xmalloc(sizeof(struct intercept_queue));
+ if (!iq)
+ return NULL;
+ iq->cache = cache;
+ cache->inter_data_count++;
+ return &iq->data;
+}
+
+void
+XRecordFreeData(data)
+ XRecordInterceptData *data;
+{
+ /* we can do this cast because that is what we really allocated */
+ struct intercept_queue *iq = (struct intercept_queue *)data;
+ struct reply_buffer *rbp = NULL;
+ struct mem_cache_str *cache = iq->cache;
+
+ /*
+ * figure out what reply_buffer this points at
+ * and decrement its ref_count.
+ */
+ if (data->data) {
+
+ for (rbp = cache->reply_buffers; rbp; rbp = rbp->next) {
+ if (data->data >= rbp->buf
+ && data->data < rbp->buf + rbp->nbytes)
+ {
+ assert(rbp->ref_count > 0);
+ rbp->ref_count--;
+ break;
+ }
+ }
+ /* it's an error if we didn't find something to free */
+ assert(rbp);
+ }
+ /*
+ * If the display is still open, put this back on the free queue.
+ *
+ * Otherwise the display is closed and we won't reuse this, so free it.
+ * See if we can free the reply buffer, too.
+ * If we can, see if this is the last reply buffer and if so
+ * free the list of reply buffers.
+ */
+ if (cache->display_closed == False) {
+ iq->next = cache->inter_data;
+ cache->inter_data = iq;
+ } else {
+ if (rbp && rbp->ref_count == 0) {
+ struct reply_buffer *rbp2, **rbp_next_p;
+
+ /* Have to search the list again to find the prev element.
+ This is not the common case, so don't slow down the code
+ above by doing it then. */
+ for (rbp_next_p = &cache->reply_buffers; *rbp_next_p; ) {
+ rbp2 = *rbp_next_p;
+ if (rbp == rbp2) {
+ *rbp_next_p = rbp2->next;
+ break;
+ } else {
+ rbp_next_p = &rbp2->next;
+ }
+ }
+ XFree(rbp->buf);
+ XFree(rbp);
+ }
+
+ XFree(iq);
+ cache->inter_data_count--;
+
+ if (cache->reply_buffers == NULL && cache->inter_data_count == 0) {
+ XFree(cache); /* all finished */
+ }
+ }
+}
+
+/* the EXTRACT macros are adapted from ICElibint.h */
+
+#ifndef WORD64
+
+#define EXTRACT_CARD16(swap, src, dst) \
+{ \
+ (dst) = *((CARD16 *) (src)); \
+ if (swap) \
+ (dst) = lswaps (dst); \
+}
+
+#define EXTRACT_CARD32(swap, src, dst) \
+{ \
+ (dst) = *((CARD32 *) (src)); \
+ if (swap) \
+ (dst) = lswapl (dst); \
+}
+
+#else /* WORD64 */
+
+#define EXTRACT_CARD16(swap, src, dst) \
+{ \
+ (dst) = *((src) + 0); \
+ (dst) <<= 8; \
+ (dst) |= *((src) + 1); \
+ if (swap) \
+ (dst) = lswaps (dst); \
+}
+
+#define EXTRACT_CARD32(swap, src, dst) \
+{ \
+ (dst) = *((src) + 0); \
+ (dst) <<= 8; \
+ (dst) |= *((src) + 1); \
+ (dst) <<= 8; \
+ (dst) |= *((src) + 2); \
+ (dst) <<= 8; \
+ (dst) |= *((src) + 3); \
+ if (swap) \
+ (dst) = lswapl (dst); \
+}
+
+#endif /* WORD64 */
+
+/* byte swapping macros from xfs/include/misc.h */
+
+/* byte swap a long literal */
+#define lswapl(x) ((((x) & 0xff) << 24) |\
+ (((x) & 0xff00) << 8) |\
+ (((x) & 0xff0000) >> 8) |\
+ (((x) >> 24) & 0xff))
+
+/* byte swap a short literal */
+#define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
+
+enum parser_return { Continue, End, Error };
+
+static enum parser_return
+parse_reply_call_callback(dpy, info, rep, reply, callback, closure)
+ Display *dpy;
+ XExtDisplayInfo *info;
+ xRecordEnableContextReply *rep;
+ struct reply_buffer *reply;
+ XRecordInterceptProc callback;
+ XPointer closure;
+{
+ int current_index;
+ int datum_bytes = 0;
+ XRecordInterceptData *data;
+
+ /* call the callback for each protocol element in the reply */
+ current_index = 0;
+ do {
+ data = alloc_inter_data(info);
+ if (!data)
+ return Error;
+
+ data->id_base = rep->idBase;
+ data->category = rep->category;
+ data->client_swapped = rep->clientSwapped;
+ data->server_time = rep->serverTime;
+ data->client_seq = rep->recordedSequenceNumber;
+ /*
+ * compute the size of this protocol element.
+ */
+ switch (rep->category) {
+ case XRecordFromServer:
+ if (rep->elementHeader&XRecordFromServerTime) {
+ EXTRACT_CARD32(rep->clientSwapped,
+ reply->buf+current_index,
+ data->server_time);
+ current_index += 4;
+ }
+ switch (reply->buf[current_index]) {
+ case X_Reply: /* reply */
+ EXTRACT_CARD32(rep->clientSwapped,
+ reply->buf+current_index+4, datum_bytes);
+ datum_bytes = (datum_bytes+8) << 2;
+ break;
+ default: /* error or event */
+ datum_bytes = 32;
+ }
+ break;
+ case XRecordFromClient:
+ if (rep->elementHeader&XRecordFromClientTime) {
+ EXTRACT_CARD32(rep->clientSwapped,
+ reply->buf+current_index,
+ data->server_time);
+ current_index += 4;
+ }
+ if (rep->elementHeader&XRecordFromClientSequence) {
+ EXTRACT_CARD32(rep->clientSwapped,
+ reply->buf+current_index,
+ data->client_seq);
+ current_index += 4;
+ }
+ if (reply->buf[current_index+2] == 0
+ && reply->buf[current_index+3] == 0) /* needn't swap 0 */
+ { /* BIG-REQUESTS */
+ EXTRACT_CARD32(rep->clientSwapped,
+ reply->buf+current_index+4, datum_bytes);
+ } else {
+ EXTRACT_CARD16(rep->clientSwapped,
+ reply->buf+current_index+2, datum_bytes);
+ }
+ datum_bytes <<= 2;
+ break;
+ case XRecordClientStarted:
+ EXTRACT_CARD16(rep->clientSwapped,
+ reply->buf+current_index+6, datum_bytes);
+ datum_bytes = (datum_bytes+2) << 2;
+ break;
+ case XRecordClientDied:
+ if (rep->elementHeader&XRecordFromClientSequence) {
+ EXTRACT_CARD32(rep->clientSwapped,
+ reply->buf+current_index,
+ data->client_seq);
+ current_index += 4;
+ }
+ /* fall through */
+ case XRecordStartOfData:
+ case XRecordEndOfData:
+ datum_bytes = 0;
+ }
+
+ if (datum_bytes > 0) {
+ if (current_index + datum_bytes > rep->length << 2)
+ fprintf(stderr,
+ "XRecord: %lu-byte reply claims %d-byte element (seq %lu)\n",
+ (long)rep->length << 2, current_index + datum_bytes,
+ dpy->last_request_read);
+ /*
+ * This assignment (and indeed the whole buffer sharing
+ * scheme) assumes arbitrary 4-byte boundaries are
+ * addressable.
+ */
+ data->data = reply->buf+current_index;
+ reply->ref_count++;
+ } else {
+ data->data = NULL;
+ }
+ data->data_len = datum_bytes >> 2;
+
+ (*callback)(closure, data);
+
+ current_index += datum_bytes;
+ } while (current_index<rep->length<<2);
+
+ if (rep->category == XRecordEndOfData)
+ return End;
+
+ return Continue;
+}
+
+Status
+XRecordEnableContext(dpy, context, callback, closure)
+ Display *dpy;
+ XRecordContext context;
+ XRecordInterceptProc callback;
+ XPointer closure;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xRecordEnableContextReq *req;
+ xRecordEnableContextReply rep;
+ struct reply_buffer *reply;
+ enum parser_return status;
+
+ XRecordCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RecordEnableContext, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->recordReqType = X_RecordEnableContext;
+ req->context = context;
+
+ while (1)
+ {
+ /* This code should match that in XRecordEnableContextAsync */
+ if (!_XReply (dpy, (xReply *)&rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+
+ if (rep.length > 0) {
+ reply = alloc_reply_buffer(info, rep.length<<2);
+ if (!reply) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ _XRead (dpy, (char *)reply->buf, rep.length<<2);
+ } else {
+ reply = NULL;
+ }
+
+ status = parse_reply_call_callback(dpy, info, &rep, reply,
+ callback, closure);
+ switch (status) {
+ case Continue:
+ break;
+ case End:
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ case Error:
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ }
+}
+
+
+typedef struct _record_async_state
+{
+ unsigned long enable_seq;
+ _XAsyncHandler *async;
+ _XAsyncErrorState *error_state;
+ XExtDisplayInfo *info;
+ XRecordInterceptProc callback;
+ XPointer closure;
+} record_async_state;
+
+static Bool
+record_async_handler(dpy, rep, buf, len, adata)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer adata;
+{
+ register record_async_state *state = (record_async_state *)adata;
+ struct reply_buffer *reply;
+ enum parser_return status;
+
+ if (dpy->last_request_read != state->enable_seq)
+ {
+ if (dpy->last_request_read > state->enable_seq) {
+ /* it is an error that we are still on the handler list */
+ fprintf(stderr, "XRecord: handler for seq %lu never saw XRecordEndOfData. (seq now %lu)\n",
+ state->enable_seq, dpy->last_request_read);
+ DeqAsyncHandler(dpy, state->async);
+ Xfree(state->async);
+ }
+ return False;
+ }
+ if (rep->generic.type == X_Error)
+ {
+ DeqAsyncHandler(dpy, state->async);
+ Xfree(state->async);
+ return False;
+ }
+
+ if (rep->generic.length > 0) {
+ reply = alloc_reply_buffer(state->info, rep->generic.length<<2);
+
+ if (!reply) {
+ DeqAsyncHandler(dpy, state->async);
+ Xfree(state->async);
+ return False;
+ }
+
+ _XGetAsyncData(dpy, (char *)reply->buf, buf, len,
+ SIZEOF(xRecordEnableContextReply),
+ rep->generic.length << 2, 0);
+ } else {
+ reply = NULL;
+ }
+
+ status = parse_reply_call_callback(dpy, state->info,
+ (xRecordEnableContextReply*) rep,
+ reply, state->callback, state->closure);
+
+ if (status != Continue)
+ {
+ DeqAsyncHandler(dpy, state->async);
+ Xfree(state->async);
+ if (status == Error)
+ return False;
+ }
+
+ return True;
+}
+
+/*
+ * reads the first reply, StartOfData, synchronously,
+ * then returns allowing the app to call XRecordProcessReplies
+ * to get the rest.
+ */
+Status
+XRecordEnableContextAsync(dpy, context, callback, closure)
+ Display *dpy;
+ XRecordContext context;
+ XRecordInterceptProc callback;
+ XPointer closure;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xRecordEnableContextReq *req;
+ xRecordEnableContextReply rep;
+ struct reply_buffer *reply;
+ enum parser_return status;
+ _XAsyncHandler *async;
+ record_async_state *async_state;
+
+ XRecordCheckExtension (dpy, info, 0);
+ async = (_XAsyncHandler *)Xmalloc(sizeof(_XAsyncHandler) +
+ sizeof(record_async_state));
+ if (!async)
+ return 0;
+ async_state = (record_async_state *)(async + 1);
+
+ LockDisplay(dpy);
+ GetReq(RecordEnableContext, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->recordReqType = X_RecordEnableContext;
+ req->context = context;
+
+ /* Get the StartOfData reply. */
+ /* This code should match that in XRecordEnableContext */
+ if (!_XReply (dpy, (xReply *)&rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ Xfree(async);
+ return 0;
+ }
+
+ /* this had better be a StartOfData, which has no extra data. */
+ if (rep.length != 0) {
+ fprintf(stderr, "XRecord: malformed StartOfData for sequence %lu\n",
+ dpy->last_request_read);
+ }
+ reply = NULL;
+
+ status = parse_reply_call_callback(dpy, info, &rep, reply,
+ callback, closure);
+ if (status != Continue)
+ {
+ UnlockDisplay(dpy);
+ Xfree(async);
+ return 0;
+ }
+
+ /* hook in the async handler for the rest of the replies */
+ async_state->enable_seq = dpy->request;
+ async_state->async = async;
+ async_state->info = info;
+ async_state->callback = callback;
+ async_state->closure = closure;
+
+ async->next = dpy->async_handlers;
+ async->handler = record_async_handler;
+ async->data = (XPointer)async_state;
+ dpy->async_handlers = async;
+
+ UnlockDisplay(dpy);
+ /* Don't invoke SyncHandle here, since this is an async
+ function. Does this break XSetAfterFunction() ? */
+ return 1;
+}
+
+void
+XRecordProcessReplies(dpy)
+ Display *dpy;
+{
+ (void) XPending(dpy);
+}
+
+Status
+XRecordDisableContext(dpy, context)
+ Display *dpy;
+ XRecordContext context;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xRecordDisableContextReq *req;
+
+ XRecordCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RecordDisableContext, req);
+ req->reqType = info->codes->major_opcode;
+ req->recordReqType = X_RecordDisableContext;
+ req->context = context;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+Status
+XRecordFreeContext(dpy, context)
+ Display *dpy;
+ XRecordContext context;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xRecordFreeContextReq *req;
+
+ XRecordCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(RecordFreeContext, req);
+ req->reqType = info->codes->major_opcode;
+ req->recordReqType = X_RecordFreeContext;
+ req->context = context;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/nx-X11/lib/Xtst/XTest.c b/nx-X11/lib/Xtst/XTest.c
new file mode 100644
index 000000000..2c3ae2b41
--- /dev/null
+++ b/nx-X11/lib/Xtst/XTest.c
@@ -0,0 +1,498 @@
+/* $Xorg: XTest.c,v 1.5 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+Copyright 1990, 1991 by UniSoft Group Limited
+*/
+
+/*
+
+Copyright 1992, 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.
+
+*/
+/* $XFree86: xc/lib/Xtst/XTest.c,v 1.5 2001/12/14 19:56:40 dawes Exp $ */
+
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/XTest.h>
+#include <X11/extensions/xteststr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/XIproto.h>
+
+static XExtensionInfo _xtest_info_data;
+static XExtensionInfo *xtest_info = &_xtest_info_data;
+static /* const */ char *xtest_extension_name = XTestExtensionName;
+
+#define XTestCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xtest_extension_name, val)
+
+#define XTestICheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xtest_extension_name, val); \
+ if (!i->data) return val
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display();
+static /* const */ XExtensionHooks xtest_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL /* error_string */
+};
+
+static XPointer
+get_xinput_base(dpy)
+ Display *dpy;
+{
+ int major_opcode, first_event, first_error;
+ first_event = 0;
+
+ XQueryExtension(dpy, INAME, &major_opcode, &first_event, &first_error);
+ return (XPointer)(long)first_event;
+}
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xtest_info,
+ xtest_extension_name,
+ &xtest_extension_hooks, XTestNumberEvents,
+ get_xinput_base(dpy))
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xtest_info)
+
+/*****************************************************************************
+ * *
+ * public routines *
+ * *
+ *****************************************************************************/
+
+Bool
+XTestQueryExtension (dpy, event_basep, error_basep, majorp, minorp)
+ Display *dpy;
+ int *event_basep, *error_basep;
+ int *majorp, *minorp;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xXTestGetVersionReq *req;
+ xXTestGetVersionReply rep;
+
+ if (XextHasExtension(info)) {
+ LockDisplay(dpy);
+ GetReq(XTestGetVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xtReqType = X_XTestGetVersion;
+ req->majorVersion = XTestMajorVersion;
+ req->minorVersion = XTestMinorVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ *majorp = rep.majorVersion;
+ *minorp = rep.minorVersion;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+Bool
+XTestCompareCursorWithWindow(dpy, window, cursor)
+ Display *dpy;
+ Window window;
+ Cursor cursor;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xXTestCompareCursorReq *req;
+ xXTestCompareCursorReply rep;
+
+ XTestCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(XTestCompareCursor, req);
+ req->reqType = info->codes->major_opcode;
+ req->xtReqType = X_XTestCompareCursor;
+ req->window = window;
+ req->cursor = cursor;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.same;
+}
+
+Bool
+XTestCompareCurrentCursorWithWindow(dpy, window)
+ Display *dpy;
+ Window window;
+{
+ return XTestCompareCursorWithWindow(dpy, window, XTestCurrentCursor);
+}
+
+int
+XTestFakeKeyEvent(dpy, keycode, is_press, delay)
+ Display *dpy;
+ unsigned int keycode;
+ Bool is_press;
+ unsigned long delay;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xXTestFakeInputReq *req;
+
+ XTestCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(XTestFakeInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->xtReqType = X_XTestFakeInput;
+ req->type = is_press ? KeyPress : KeyRelease;
+ req->detail = keycode;
+ req->time = delay;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+int
+XTestFakeButtonEvent(dpy, button, is_press, delay)
+ Display *dpy;
+ unsigned int button;
+ Bool is_press;
+ unsigned long delay;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xXTestFakeInputReq *req;
+
+ XTestCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(XTestFakeInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->xtReqType = X_XTestFakeInput;
+ req->type = is_press ? ButtonPress : ButtonRelease;
+ req->detail = button;
+ req->time = delay;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+int
+XTestFakeMotionEvent(dpy, screen, x, y, delay)
+ Display *dpy;
+ int screen;
+ int x, y;
+ unsigned long delay;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xXTestFakeInputReq *req;
+
+ XTestCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(XTestFakeInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->xtReqType = X_XTestFakeInput;
+ req->type = MotionNotify;
+ req->detail = False;
+ if (screen == -1)
+ req->root = None;
+ else
+ req->root = RootWindow(dpy, screen);
+ req->rootX = x;
+ req->rootY = y;
+ req->time = delay;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+int
+XTestFakeRelativeMotionEvent(dpy, dx, dy, delay)
+ Display *dpy;
+ int dx, dy;
+ unsigned long delay;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xXTestFakeInputReq *req;
+
+ XTestCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(XTestFakeInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->xtReqType = X_XTestFakeInput;
+ req->type = MotionNotify;
+ req->detail = True;
+ req->root = None;
+ req->rootX = dx;
+ req->rootY = dy;
+ req->time = delay;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+static void
+send_axes(dpy, info, req, dev, first_axis, axes, n_axes)
+ Display *dpy;
+ XExtDisplayInfo *info;
+ xXTestFakeInputReq *req;
+ XDevice *dev;
+ int first_axis;
+ int *axes;
+ int n_axes;
+{
+ deviceValuator ev;
+ int n;
+
+ req->deviceid |= MORE_EVENTS;
+ req->length += ((n_axes + 5) / 6) * (SIZEOF(xEvent) >> 2);
+ ev.type = XI_DeviceValuator + (long)info->data;
+ ev.deviceid = dev->device_id;
+ ev.num_valuators = n_axes;
+ ev.first_valuator = first_axis;
+ while (n_axes > 0) {
+ n = n_axes;
+ if (n > 6)
+ n = 6;
+ switch (n) {
+ case 6:
+ ev.valuator5 = *(axes+5);
+ case 5:
+ ev.valuator4 = *(axes+4);
+ case 4:
+ ev.valuator3 = *(axes+3);
+ case 3:
+ ev.valuator2 = *(axes+2);
+ case 2:
+ ev.valuator1 = *(axes+1);
+ case 1:
+ ev.valuator0 = *axes;
+ }
+ Data(dpy, (char *)&ev, SIZEOF(xEvent));
+ axes += n;
+ n_axes -= n;
+ ev.first_valuator += n;
+ }
+}
+
+int
+XTestFakeDeviceKeyEvent(dpy, dev, keycode, is_press, axes, n_axes, delay)
+ Display *dpy;
+ XDevice *dev;
+ unsigned int keycode;
+ Bool is_press;
+ int *axes;
+ int n_axes;
+ unsigned long delay;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xXTestFakeInputReq *req;
+
+ XTestICheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(XTestFakeInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->xtReqType = X_XTestFakeInput;
+ req->type = is_press ? XI_DeviceKeyPress : XI_DeviceKeyRelease;
+ req->type += (int)(long)info->data;
+ req->detail = keycode;
+ req->time = delay;
+ req->deviceid = dev->device_id;
+ if (n_axes)
+ send_axes(dpy, info, req, dev, 0, axes, n_axes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+int
+XTestFakeDeviceButtonEvent(dpy, dev, button, is_press, axes, n_axes, delay)
+ Display *dpy;
+ XDevice *dev;
+ unsigned int button;
+ Bool is_press;
+ int *axes;
+ int n_axes;
+ unsigned long delay;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xXTestFakeInputReq *req;
+
+ XTestICheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(XTestFakeInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->xtReqType = X_XTestFakeInput;
+ req->type = is_press ? XI_DeviceButtonPress : XI_DeviceButtonRelease;
+ req->type += (int)(long)info->data;
+ req->detail = button;
+ req->time = delay;
+ req->deviceid = dev->device_id;
+ if (n_axes)
+ send_axes(dpy, info, req, dev, 0, axes, n_axes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+int
+XTestFakeProximityEvent(dpy, dev, in_prox, axes, n_axes, delay)
+ Display *dpy;
+ XDevice *dev;
+ Bool in_prox;
+ int *axes;
+ int n_axes;
+ unsigned long delay;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xXTestFakeInputReq *req;
+
+ XTestICheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(XTestFakeInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->xtReqType = X_XTestFakeInput;
+ req->type = in_prox ? XI_ProximityIn : XI_ProximityOut;
+ req->type += (int)(long)info->data;
+ req->time = delay;
+ req->deviceid = dev->device_id;
+ if (n_axes)
+ send_axes(dpy, info, req, dev, 0, axes, n_axes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+int
+XTestFakeDeviceMotionEvent(dpy, dev, is_relative,
+ first_axis, axes, n_axes, delay)
+ Display *dpy;
+ XDevice *dev;
+ Bool is_relative;
+ int first_axis;
+ int *axes;
+ int n_axes;
+ unsigned long delay;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xXTestFakeInputReq *req;
+
+ XTestICheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(XTestFakeInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->xtReqType = X_XTestFakeInput;
+ req->type = XI_DeviceMotionNotify + (int)(long)info->data;
+ req->detail = is_relative;
+ req->time = delay;
+ req->deviceid = dev->device_id;
+ send_axes(dpy, info, req, dev, first_axis, axes, n_axes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+int
+XTestGrabControl(dpy, impervious)
+ Display *dpy;
+ Bool impervious;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xXTestGrabControlReq *req;
+
+ XTestCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(XTestGrabControl, req);
+ req->reqType = info->codes->major_opcode;
+ req->xtReqType = X_XTestGrabControl;
+ req->impervious = impervious;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+void
+XTestSetGContextOfGC(gc, gid)
+ GC gc;
+ GContext gid;
+{
+ gc->gid = gid;
+}
+
+void
+XTestSetVisualIDOfVisual(visual, visualid)
+ Visual *visual;
+ VisualID visualid;
+{
+ visual->visualid = visualid;
+}
+
+static xReq _dummy_request = {
+ 0, 0, 0
+};
+
+Status
+XTestDiscard(dpy)
+ Display *dpy;
+{
+ Bool something;
+ register char *ptr;
+
+ LockDisplay(dpy);
+ if ((something = (dpy->bufptr != dpy->buffer))) {
+ for (ptr = dpy->buffer;
+ ptr < dpy->bufptr;
+ ptr += (((xReq *)ptr)->length << 2))
+ dpy->request--;
+ dpy->bufptr = dpy->buffer;
+ dpy->last_req = (char *)&_dummy_request;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return something;
+}
diff --git a/nx-X11/lib/Xtst/Xtst-def.cpp b/nx-X11/lib/Xtst/Xtst-def.cpp
new file mode 100644
index 000000000..a103ad497
--- /dev/null
+++ b/nx-X11/lib/Xtst/Xtst-def.cpp
@@ -0,0 +1,32 @@
+LIBRARY XTST
+VERSION LIBRARY_VERSION
+EXPORTS
+ XTestCompareCurrentCursorWithWindow
+ XTestCompareCursorWithWindow
+ XTestDiscard
+ XTestFakeButtonEvent
+ XTestFakeDeviceButtonEvent
+ XTestFakeDeviceKeyEvent
+ XTestFakeDeviceMotionEvent
+ XTestFakeKeyEvent
+ XTestFakeMotionEvent
+ XTestFakeProximityEvent
+ XTestFakeRelativeMotionEvent
+ XTestGrabControl
+ XTestQueryExtension
+ XTestSetGContextOfGC
+ XTestSetVisualIDOfVisual
+ XRecordQueryVersion
+ XRecordCreateContext
+ XRecordAllocRange
+ XRecordRegisterClients
+ XRecordUnregisterClients
+ XRecordGetContext
+ XRecordFreeState
+ XRecordEnableContext
+ XRecordEnableContextAsync
+ XRecordProcessReplies
+ XRecordFreeData
+ XRecordDisableContext
+ XRecordFreeContext
+/* $Xorg: Xtst-def.cpp,v 1.3 2000/08/17 19:46:23 cpqbld Exp $ */
diff --git a/nx-X11/lib/Xv/Imakefile b/nx-X11/lib/Xv/Imakefile
new file mode 100644
index 000000000..cf8febf2a
--- /dev/null
+++ b/nx-X11/lib/Xv/Imakefile
@@ -0,0 +1,30 @@
+XCOMM $XFree86: xc/lib/Xv/Imakefile,v 1.7 2002/10/16 00:37:33 dawes Exp $
+
+#define DoNormalLib NormalLibXv
+#define DoSharedLib SharedLibXv
+#define DoDebugLib DebugLibXv
+#define DoProfileLib ProfileLibXv
+#define LibName Xv
+#define SoRev SOXVREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXvReqs
+REQUIREDLIBS = SharedXvReqs
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ SRCS = Xv.c
+ OBJS = Xv.o
+ LINTLIBS = $(LINTXLIB)
+
+#define IncludeSharedObjectInNormalLib
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/Xv/Xv-def.cpp b/nx-X11/lib/Xv/Xv-def.cpp
new file mode 100644
index 000000000..30544cd8e
--- /dev/null
+++ b/nx-X11/lib/Xv/Xv-def.cpp
@@ -0,0 +1,27 @@
+LIBRARY Xv
+VERSION LIBRARY_VERSION
+EXPORTS
+XvCreateImage
+XvFreeAdaptorInfo
+XvFreeEncodingInfo
+XvGetPortAttribute
+XvGetStill
+XvGetVideo
+XvGrabPort
+XvListImageFormats
+XvPutImage
+XvPutStill
+XvPutVideo
+XvQueryAdaptors
+XvQueryBestSize
+XvQueryEncodings
+XvQueryExtension
+XvQueryPortAttributes
+XvSelectPortNotify
+XvSelectVideoNotify
+XvSetPortAttribute
+XvShmCreateImage
+XvShmPutImage
+XvStopVideo
+XvUngrabPort
+/* $XFree86$ */
diff --git a/nx-X11/lib/Xv/Xv.c b/nx-X11/lib/Xv/Xv.c
new file mode 100644
index 000000000..0097a3fa5
--- /dev/null
+++ b/nx-X11/lib/Xv/Xv.c
@@ -0,0 +1,1155 @@
+/***********************************************************
+Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
+and the Massachusetts Institute of Technology, Cambridge, 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 names of Digital or MIT 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xv/Xv.c,v 1.17 2003/04/28 16:56:27 dawes Exp $ */
+/* $XdotOrg: xc/lib/Xv/Xv.c,v 1.3 2005/07/03 07:00:57 daniels Exp $ */
+/*
+** File:
+**
+** Xv.c --- Xv library extension module.
+**
+** Author:
+**
+** David Carver (Digital Workstation Engineering/Project Athena)
+**
+** Revisions:
+**
+** 26.06.91 Carver
+** - changed XvFreeAdaptors to XvFreeAdaptorInfo
+** - changed XvFreeEncodings to XvFreeEncodingInfo
+**
+** 11.06.91 Carver
+** - changed SetPortControl to SetPortAttribute
+** - changed GetPortControl to GetPortAttribute
+** - changed QueryBestSize
+**
+** 15.05.91 Carver
+** - version 2.0 upgrade
+**
+** 240.01.91 Carver
+** - version 1.4 upgrade
+**
+*/
+
+#include <stdio.h>
+#include "Xvlibint.h"
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/XShm.h>
+
+static XExtensionInfo _xv_info_data;
+static XExtensionInfo *xv_info = &_xv_info_data;
+static char *xv_extension_name = XvName;
+
+#define XvCheckExtension(dpy, i, val) \
+ XextCheckExtension(dpy, i, xv_extension_name, val)
+
+static char *xv_error_string();
+static int xv_close_display();
+static Bool xv_wire_to_event();
+
+static XExtensionHooks xv_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ xv_close_display, /* close_display */
+ xv_wire_to_event, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ xv_error_string /* error_string */
+};
+
+
+static char *xv_error_list[] =
+{
+ "BadPort", /* XvBadPort */
+ "BadEncoding", /* XvBadEncoding */
+ "BadControl" /* XvBadControl */
+};
+
+static XEXT_GENERATE_CLOSE_DISPLAY (xv_close_display, xv_info)
+
+
+static XEXT_GENERATE_FIND_DISPLAY (xv_find_display, xv_info,
+ xv_extension_name,
+ &xv_extension_hooks,
+ XvNumEvents, NULL)
+
+
+static XEXT_GENERATE_ERROR_STRING (xv_error_string, xv_extension_name,
+ XvNumErrors, xv_error_list)
+
+
+int
+XvQueryExtension(
+ Display *dpy,
+ unsigned int *p_version,
+ unsigned int *p_revision,
+ unsigned int *p_requestBase,
+ unsigned int *p_eventBase,
+ unsigned int *p_errorBase
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvQueryExtensionReq *req;
+ xvQueryExtensionReply rep;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ XvGetReq(QueryExtension, req);
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return XvBadExtension;
+ }
+
+ *p_version = rep.version;
+ *p_revision = rep.revision;
+ *p_requestBase = info->codes->major_opcode;
+ *p_eventBase = info->codes->first_event;
+ *p_errorBase = info->codes->first_error;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
+
+int
+XvQueryAdaptors(
+ Display *dpy,
+ Window window,
+ unsigned int *p_nAdaptors,
+ XvAdaptorInfo **p_pAdaptors
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvQueryAdaptorsReq *req;
+ xvQueryAdaptorsReply rep;
+ int size,ii,jj;
+ char *name;
+ XvAdaptorInfo *pas, *pa;
+ XvFormat *pfs, *pf;
+ char *buffer;
+ union
+ {
+ char *buffer;
+ char *string;
+ xvAdaptorInfo *pa;
+ xvFormat *pf;
+ } u;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ XvGetReq(QueryAdaptors, req);
+ req->window = window;
+
+ /* READ THE REPLY */
+
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(XvBadReply);
+ }
+
+ size = rep.length << 2;
+ if ( (buffer = (char *)Xmalloc ((unsigned) size)) == NULL) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(XvBadAlloc);
+ }
+ _XRead (dpy, buffer, size);
+
+ u.buffer = buffer;
+
+ /* GET INPUT ADAPTORS */
+
+ if (rep.num_adaptors == 0) {
+ pas = NULL;
+ } else {
+ size = rep.num_adaptors*sizeof(XvAdaptorInfo);
+ if ((pas=(XvAdaptorInfo *)Xmalloc(size))==NULL) {
+ Xfree(buffer);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(XvBadAlloc);
+ }
+ }
+
+ /* INIT ADAPTOR FIELDS */
+
+ pa = pas;
+ for (ii=0; ii<rep.num_adaptors; ii++) {
+ pa->num_adaptors = 0;
+ pa->name = (char *)NULL;
+ pa->formats = (XvFormat *)NULL;
+ pa++;
+ }
+
+ pa = pas;
+ for (ii=0; ii<rep.num_adaptors; ii++) {
+ pa->type = u.pa->type;
+ pa->base_id = u.pa->base_id;
+ pa->num_ports = u.pa->num_ports;
+ pa->num_formats = u.pa->num_formats;
+ pa->num_adaptors = rep.num_adaptors - ii;
+
+ /* GET ADAPTOR NAME */
+
+ size = u.pa->name_size;
+ u.buffer += (sz_xvAdaptorInfo + 3) & ~3;
+
+ if ( (name = (char *)Xmalloc(size+1)) == NULL)
+ {
+ XvFreeAdaptorInfo(pas);
+ Xfree(buffer);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(XvBadAlloc);
+ }
+ (void)strncpy(name, u.string, size);
+ name[size] = '\0';
+ pa->name = name;
+
+ u.buffer += (size + 3) & ~3;
+
+ /* GET FORMATS */
+
+ size = pa->num_formats*sizeof(XvFormat);
+ if ((pfs=(XvFormat *)Xmalloc(size))==NULL) {
+ XvFreeAdaptorInfo(pas);
+ Xfree(buffer);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(XvBadAlloc);
+ }
+
+ pf = pfs;
+ for (jj=0; jj<pa->num_formats; jj++) {
+ pf->depth = u.pf->depth;
+ pf->visual_id = u.pf->visual;
+ pf++;
+
+ u.buffer += (sz_xvFormat + 3) & ~3;
+ }
+
+ pa->formats = pfs;
+
+ pa++;
+
+ }
+
+ *p_nAdaptors = rep.num_adaptors;
+ *p_pAdaptors = pas;
+
+ Xfree(buffer);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return (Success);
+}
+
+
+void
+XvFreeAdaptorInfo(XvAdaptorInfo *pAdaptors)
+{
+
+ XvAdaptorInfo *pa;
+ int ii;
+
+ if (!pAdaptors) return;
+
+ pa = pAdaptors;
+
+ for (ii=0; ii<pAdaptors->num_adaptors; ii++, pa++)
+ {
+ if (pa->name)
+ {
+ Xfree(pa->name);
+ }
+ if (pa->formats)
+ {
+ Xfree(pa->formats);
+ }
+ }
+
+ Xfree(pAdaptors);
+}
+
+int
+XvQueryEncodings(
+ Display *dpy,
+ XvPortID port,
+ unsigned int *p_nEncodings,
+ XvEncodingInfo **p_pEncodings
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvQueryEncodingsReq *req;
+ xvQueryEncodingsReply rep;
+ int size, jj;
+ char *name;
+ XvEncodingInfo *pes, *pe;
+ char *buffer;
+ union
+ {
+ char *buffer;
+ char *string;
+ xvEncodingInfo *pe;
+ } u;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ XvGetReq(QueryEncodings, req);
+ req->port = port;
+
+ /* READ THE REPLY */
+
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(XvBadReply);
+ }
+
+ size = rep.length << 2;
+ if ( (buffer = (char *)Xmalloc ((unsigned) size)) == NULL) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(XvBadAlloc);
+ }
+ _XRead (dpy, buffer, size);
+
+ u.buffer = buffer;
+
+ /* GET ENCODINGS */
+
+ size = rep.num_encodings*sizeof(XvEncodingInfo);
+ if ( (pes = (XvEncodingInfo *)Xmalloc(size)) == NULL) {
+ Xfree(buffer);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(XvBadAlloc);
+ }
+
+ /* INITIALIZE THE ENCODING POINTER */
+
+ pe = pes;
+ for (jj=0; jj<rep.num_encodings; jj++) {
+ pe->name = (char *)NULL;
+ pe->num_encodings = 0;
+ pe++;
+ }
+
+ pe = pes;
+ for (jj=0; jj<rep.num_encodings; jj++) {
+ pe->encoding_id = u.pe->encoding;
+ pe->width = u.pe->width;
+ pe->height = u.pe->height;
+ pe->rate.numerator = u.pe->rate.numerator;
+ pe->rate.denominator = u.pe->rate.denominator;
+ pe->num_encodings = rep.num_encodings - jj;
+
+ size = u.pe->name_size;
+ u.buffer += (sz_xvEncodingInfo + 3) & ~3;
+
+ if ( (name = (char *)Xmalloc(size+1)) == NULL) {
+ Xfree(buffer);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(XvBadAlloc);
+ }
+ strncpy(name, u.string, size);
+ name[size] = '\0';
+ pe->name = name;
+ pe++;
+
+ u.buffer += (size + 3) & ~3;
+ }
+
+ *p_nEncodings = rep.num_encodings;
+ *p_pEncodings = pes;
+
+ Xfree(buffer);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return (Success);
+}
+
+void
+XvFreeEncodingInfo(XvEncodingInfo *pEncodings)
+{
+
+ XvEncodingInfo *pe;
+ int ii;
+
+ if (!pEncodings) return;
+
+ pe = pEncodings;
+
+ for (ii=0; ii<pEncodings->num_encodings; ii++, pe++) {
+ if (pe->name) Xfree(pe->name);
+ }
+
+ Xfree(pEncodings);
+}
+
+int
+XvPutVideo(
+ Display *dpy,
+ XvPortID port,
+ Drawable d,
+ GC gc,
+ int vx, int vy,
+ unsigned int vw, unsigned int vh,
+ int dx, int dy,
+ unsigned int dw, unsigned int dh
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvPutVideoReq *req;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ FlushGC(dpy, gc);
+
+ XvGetReq(PutVideo, req);
+
+ req->port = port;
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->vid_x = vx;
+ req->vid_y = vy;
+ req->vid_w = vw;
+ req->vid_h = vh;
+ req->drw_x = dx;
+ req->drw_y = dy;
+ req->drw_w = dw;
+ req->drw_h = dh;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
+
+int
+XvPutStill(
+ Display *dpy,
+ XvPortID port,
+ Drawable d,
+ GC gc,
+ int vx, int vy,
+ unsigned int vw, unsigned int vh,
+ int dx, int dy,
+ unsigned int dw, unsigned int dh
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvPutStillReq *req;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ FlushGC(dpy, gc);
+
+ XvGetReq(PutStill, req);
+ req->port = port;
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->vid_x = vx;
+ req->vid_y = vy;
+ req->vid_w = vw;
+ req->vid_h = vh;
+ req->drw_x = dx;
+ req->drw_y = dy;
+ req->drw_w = dw;
+ req->drw_h = dh;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
+
+int
+XvGetVideo(
+ Display *dpy,
+ XvPortID port,
+ Drawable d,
+ GC gc,
+ int vx, int vy,
+ unsigned int vw, unsigned int vh,
+ int dx, int dy,
+ unsigned int dw, unsigned int dh
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvGetVideoReq *req;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ FlushGC(dpy, gc);
+
+ XvGetReq(GetVideo, req);
+ req->port = port;
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->vid_x = vx;
+ req->vid_y = vy;
+ req->vid_w = vw;
+ req->vid_h = vh;
+ req->drw_x = dx;
+ req->drw_y = dy;
+ req->drw_w = dw;
+ req->drw_h = dh;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
+
+int
+XvGetStill(
+ Display *dpy,
+ XvPortID port,
+ Drawable d,
+ GC gc,
+ int vx, int vy,
+ unsigned int vw, unsigned int vh,
+ int dx, int dy,
+ unsigned int dw, unsigned int dh
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvGetStillReq *req;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ FlushGC(dpy, gc);
+
+ XvGetReq(GetStill, req);
+ req->port = port;
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->vid_x = vx;
+ req->vid_y = vy;
+ req->vid_w = vw;
+ req->vid_h = vh;
+ req->drw_x = dx;
+ req->drw_y = dy;
+ req->drw_w = dw;
+ req->drw_h = dh;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
+
+int
+XvStopVideo(
+ Display *dpy,
+ XvPortID port,
+ Drawable draw
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvStopVideoReq *req;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ XvGetReq(StopVideo, req);
+ req->port = port;
+ req->drawable = draw;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
+
+int
+XvGrabPort(
+ Display *dpy,
+ XvPortID port,
+ Time time
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ int result;
+ xvGrabPortReply rep;
+ xvGrabPortReq *req;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ XvGetReq(GrabPort, req);
+ req->port = port;
+ req->time = time;
+
+ if (_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0)
+ rep.result = GrabSuccess;
+
+ result = rep.result;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return result;
+}
+
+int
+XvUngrabPort(
+ Display *dpy,
+ XvPortID port,
+ Time time
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvUngrabPortReq *req;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ XvGetReq(UngrabPort, req);
+ req->port = port;
+ req->time = time;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
+
+int
+XvSelectVideoNotify(
+ Display *dpy,
+ Drawable drawable,
+ Bool onoff
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvSelectVideoNotifyReq *req;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ XvGetReq(SelectVideoNotify, req);
+ req->drawable = drawable;
+ req->onoff = onoff;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
+
+int
+XvSelectPortNotify(
+ Display *dpy,
+ XvPortID port,
+ Bool onoff
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvSelectPortNotifyReq *req;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ XvGetReq(SelectPortNotify, req);
+ req->port = port;
+ req->onoff = onoff;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
+
+int
+XvSetPortAttribute (
+ Display *dpy,
+ XvPortID port,
+ Atom attribute,
+ int value
+)
+{
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvSetPortAttributeReq *req;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ XvGetReq(SetPortAttribute, req);
+ req->port = port;
+ req->attribute = attribute;
+ req->value = value;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return (Success);
+}
+
+int
+XvGetPortAttribute (
+ Display *dpy,
+ XvPortID port,
+ Atom attribute,
+ int *p_value
+)
+{
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvGetPortAttributeReq *req;
+ xvGetPortAttributeReply rep;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ XvGetReq(GetPortAttribute, req);
+ req->port = port;
+ req->attribute = attribute;
+
+ /* READ THE REPLY */
+
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(XvBadReply);
+ }
+
+ *p_value = rep.value;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return (Success);
+}
+
+int
+XvQueryBestSize(
+ Display *dpy,
+ XvPortID port,
+ Bool motion,
+ unsigned int vid_w,
+ unsigned int vid_h,
+ unsigned int drw_w,
+ unsigned int drw_h,
+ unsigned int *p_actual_width,
+ unsigned int *p_actual_height
+)
+{
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvQueryBestSizeReq *req;
+ xvQueryBestSizeReply rep;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ XvGetReq(QueryBestSize, req);
+ req->port = port;
+ req->motion = motion;
+ req->vid_w = vid_w;
+ req->vid_h = vid_h;
+ req->drw_w = drw_w;
+ req->drw_h = drw_h;
+
+ /* READ THE REPLY */
+
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(XvBadReply);
+ }
+
+ *p_actual_width = rep.actual_width;
+ *p_actual_height = rep.actual_height;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return (Success);
+}
+
+
+XvAttribute*
+XvQueryPortAttributes(Display *dpy, XvPortID port, int *num)
+{
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvQueryPortAttributesReq *req;
+ xvQueryPortAttributesReply rep;
+ XvAttribute *ret = NULL;
+
+ *num = 0;
+
+ XvCheckExtension(dpy, info, NULL);
+
+ LockDisplay(dpy);
+
+ XvGetReq(QueryPortAttributes, req);
+ req->port = port;
+
+ /* READ THE REPLY */
+
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ret;
+ }
+
+ if(rep.num_attributes) {
+ int size = (rep.num_attributes * sizeof(XvAttribute)) + rep.text_size;
+
+ if((ret = Xmalloc(size))) {
+ char* marker = (char*)(&ret[rep.num_attributes]);
+ xvAttributeInfo Info;
+ int i;
+
+ for(i = 0; i < rep.num_attributes; i++) {
+ _XRead(dpy, (char*)(&Info), sz_xvAttributeInfo);
+ ret[i].flags = (int)Info.flags;
+ ret[i].min_value = Info.min;
+ ret[i].max_value = Info.max;
+ ret[i].name = marker;
+ _XRead(dpy, marker, Info.size);
+ marker += Info.size;
+ (*num)++;
+ }
+ } else
+ _XEatData(dpy, rep.length << 2);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return ret;
+}
+
+XvImageFormatValues * XvListImageFormats (
+ Display *dpy,
+ XvPortID port,
+ int *num
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvListImageFormatsReq *req;
+ xvListImageFormatsReply rep;
+ XvImageFormatValues *ret = NULL;
+
+ *num = 0;
+
+ XvCheckExtension(dpy, info, NULL);
+
+ LockDisplay(dpy);
+
+ XvGetReq(ListImageFormats, req);
+ req->port = port;
+
+ /* READ THE REPLY */
+
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+
+ if(rep.num_formats) {
+ int size = (rep.num_formats * sizeof(XvImageFormatValues));
+
+ if((ret = Xmalloc(size))) {
+ xvImageFormatInfo Info;
+ int i;
+
+ for(i = 0; i < rep.num_formats; i++) {
+ _XRead(dpy, (char*)(&Info), sz_xvImageFormatInfo);
+ ret[i].id = Info.id;
+ ret[i].type = Info.type;
+ ret[i].byte_order = Info.byte_order;
+ memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16);
+ ret[i].bits_per_pixel = Info.bpp;
+ ret[i].format = Info.format;
+ ret[i].num_planes = Info.num_planes;
+ ret[i].depth = Info.depth;
+ ret[i].red_mask = Info.red_mask;
+ ret[i].green_mask = Info.green_mask;
+ ret[i].blue_mask = Info.blue_mask;
+ ret[i].y_sample_bits = Info.y_sample_bits;
+ ret[i].u_sample_bits = Info.u_sample_bits;
+ ret[i].v_sample_bits = Info.v_sample_bits;
+ ret[i].horz_y_period = Info.horz_y_period;
+ ret[i].horz_u_period = Info.horz_u_period;
+ ret[i].horz_v_period = Info.horz_v_period;
+ ret[i].vert_y_period = Info.vert_y_period;
+ ret[i].vert_u_period = Info.vert_u_period;
+ ret[i].vert_v_period = Info.vert_v_period;
+ memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32);
+ ret[i].scanline_order = Info.scanline_order;
+ (*num)++;
+ }
+ } else
+ _XEatData(dpy, rep.length << 2);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return ret;
+}
+
+XvImage * XvCreateImage (
+ Display *dpy,
+ XvPortID port,
+ int id,
+ char *data,
+ int width,
+ int height
+) {
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvQueryImageAttributesReq *req;
+ xvQueryImageAttributesReply rep;
+ XvImage *ret = NULL;
+
+ XvCheckExtension(dpy, info, NULL);
+
+ LockDisplay(dpy);
+
+ XvGetReq(QueryImageAttributes, req);
+ req->id = id;
+ req->port = port;
+ req->width = width;
+ req->height = height;
+
+ /* READ THE REPLY */
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+
+ if((ret = (XvImage*)Xmalloc(sizeof(XvImage) + (rep.num_planes << 3)))) {
+ ret->id = id;
+ ret->width = rep.width;
+ ret->height = rep.height;
+ ret->data_size = rep.data_size;
+ ret->num_planes = rep.num_planes;
+ ret->pitches = (int*)(&ret[1]);
+ ret->offsets = ret->pitches + rep.num_planes;
+ ret->data = data;
+ ret->obdata = NULL;
+ _XRead(dpy, (char*)(ret->pitches), rep.num_planes << 2);
+ _XRead(dpy, (char*)(ret->offsets), rep.num_planes << 2);
+ } else
+ _XEatData(dpy, rep.length << 2);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return ret;
+}
+
+XvImage * XvShmCreateImage (
+ Display *dpy,
+ XvPortID port,
+ int id,
+ char *data,
+ int width,
+ int height,
+ XShmSegmentInfo *shminfo
+){
+ XvImage *ret;
+
+ ret = XvCreateImage(dpy, port, id, data, width, height);
+
+ if(ret) ret->obdata = (XPointer)shminfo;
+
+ return ret;
+}
+
+int XvPutImage (
+ Display *dpy,
+ XvPortID port,
+ Drawable d,
+ GC gc,
+ XvImage *image,
+ int src_x,
+ int src_y,
+ unsigned int src_w,
+ unsigned int src_h,
+ int dest_x,
+ int dest_y,
+ unsigned int dest_w,
+ unsigned int dest_h
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvPutImageReq *req;
+ int len;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ FlushGC(dpy, gc);
+
+ XvGetReq(PutImage, req);
+
+ req->port = port;
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->id = image->id;
+ req->src_x = src_x;
+ req->src_y = src_y;
+ req->src_w = src_w;
+ req->src_h = src_h;
+ req->drw_x = dest_x;
+ req->drw_y = dest_y;
+ req->drw_w = dest_w;
+ req->drw_h = dest_h;
+ req->width = image->width;
+ req->height = image->height;
+
+ len = (image->data_size + 3) >> 2;
+ SetReqLen(req, len, len);
+
+ /* Yes it's kindof lame that we are sending the whole thing,
+ but for video all of it may be needed even if displaying
+ only a subsection, and I don't want to go through the
+ trouble of creating subregions to send */
+ Data(dpy, (char *)image->data, image->data_size);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
+
+int XvShmPutImage (
+ Display *dpy,
+ XvPortID port,
+ Drawable d,
+ GC gc,
+ XvImage *image,
+ int src_x,
+ int src_y,
+ unsigned int src_w,
+ unsigned int src_h,
+ int dest_x,
+ int dest_y,
+ unsigned int dest_w,
+ unsigned int dest_h,
+ Bool send_event
+){
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ XShmSegmentInfo *shminfo = (XShmSegmentInfo *)image->obdata;
+ xvShmPutImageReq *req;
+
+ XvCheckExtension(dpy, info, XvBadExtension);
+
+ LockDisplay(dpy);
+
+ FlushGC(dpy, gc);
+
+ XvGetReq(ShmPutImage, req);
+
+ req->port = port;
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->shmseg = shminfo->shmseg;
+ req->id = image->id;
+ req->src_x = src_x;
+ req->src_y = src_y;
+ req->src_w = src_w;
+ req->src_h = src_h;
+ req->drw_x = dest_x;
+ req->drw_y = dest_y;
+ req->drw_w = dest_w;
+ req->drw_h = dest_h;
+ req->offset = image->data - shminfo->shmaddr;
+ req->width = image->width;
+ req->height = image->height;
+ req->send_event = send_event;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
+
+
+static Bool
+xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire)
+{
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ XvEvent *re = (XvEvent *)host;
+ xvEvent *event = (xvEvent *)wire;
+
+ XvCheckExtension(dpy, info, False);
+
+ switch((event->u.u.type & 0x7F) - info->codes->first_event)
+ {
+ case XvVideoNotify:
+ re->xvvideo.type = event->u.u.type & 0x7f;
+ re->xvvideo.serial =
+ _XSetLastRequestRead(dpy, (xGenericReply *)event);
+ re->xvvideo.send_event = ((event->u.u.type & 0x80) != 0);
+ re->xvvideo.display = dpy;
+ re->xvvideo.time = event->u.videoNotify.time;
+ re->xvvideo.reason = event->u.videoNotify.reason;
+ re->xvvideo.drawable = event->u.videoNotify.drawable;
+ re->xvvideo.port_id = event->u.videoNotify.port;
+ break;
+ case XvPortNotify:
+ re->xvport.type = event->u.u.type & 0x7f;
+ re->xvport.serial =
+ _XSetLastRequestRead(dpy, (xGenericReply *)event);
+ re->xvport.send_event = ((event->u.u.type & 0x80) != 0);
+ re->xvport.display = dpy;
+ re->xvport.time = event->u.portNotify.time;
+ re->xvport.port_id = event->u.portNotify.port;
+ re->xvport.attribute = event->u.portNotify.attribute;
+ re->xvport.value = event->u.portNotify.value;
+ break;
+ default:
+ return False;
+ }
+
+ return (True);
+}
+
+
diff --git a/nx-X11/lib/Xv/Xvlibint.h b/nx-X11/lib/Xv/Xvlibint.h
new file mode 100644
index 000000000..501a211e4
--- /dev/null
+++ b/nx-X11/lib/Xv/Xvlibint.h
@@ -0,0 +1,76 @@
+/***********************************************************
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+and the Massachusetts Institute of Technology, Cambridge, 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 names of Digital or MIT 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.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xv/Xvlibint.h,v 1.5 2001/07/25 15:04:53 dawes Exp $ */
+
+#ifndef XVLIBINT_H
+#define XVLIBINT_H
+/*
+** File:
+**
+** Xvlibint.h --- Xv library internal header file
+**
+** Author:
+**
+** David Carver (Digital Workstation Engineering/Project Athena)
+**
+** Revisions:
+**
+** 01.24.91 Carver
+** - version 1.4 upgrade
+**
+*/
+
+#define NEED_REPLIES
+
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xvproto.h>
+#include <X11/extensions/Xvlib.h>
+
+#if !defined(UNIXCPP)
+#define XvGetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xv##name##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xv##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = info->codes->major_opcode;\
+ req->xvReqType = xv_##name; \
+ req->length = (SIZEOF(xv##name##Req))>>2;\
+ dpy->bufptr += SIZEOF(xv##name##Req);\
+ dpy->request++
+
+#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
+#define XvGetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xv/**/name/**/Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xv/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = info->codes->major_opcode;\
+ req->xvReqType = xv_/**/name;\
+ req->length = (SIZEOF(xv/**/name/**/Req))>>2;\
+ dpy->bufptr += SIZEOF(xv/**/name/**/Req);\
+ dpy->request++
+#endif
+
+
+#endif /* XVLIBINT_H */
diff --git a/nx-X11/lib/XvMC/Imakefile b/nx-X11/lib/XvMC/Imakefile
new file mode 100644
index 000000000..ee0bcded7
--- /dev/null
+++ b/nx-X11/lib/XvMC/Imakefile
@@ -0,0 +1,49 @@
+XCOMM $XFree86: xc/lib/XvMC/Imakefile,v 1.5 2002/10/16 00:37:33 dawes Exp $
+
+#define DoNormalLib NormalLibXvMC
+#define DoSharedLib SharedLibXvMC
+#define DoDebugLib DebugLibXvMC
+#define DoProfileLib ProfileLibXvMC
+#define LibName XvMC
+#define SoRev SOXVMCREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXvMCReqs
+REQUIREDLIBS = SharedXvMCReqs
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if HasShm
+SHM_DEFINES = -DHAS_SHM
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) $(SHM_DEFINES)
+ INCLUDES = -I$(XF86OSSRC)
+ SRCS = XvMC.c
+ OBJS = XvMC.o
+ LINTLIBS = $(LINTXLIB)
+
+#include <Library.tmpl>
+
+#define PassCDebugFlags
+
+#if defined(LinuxArchitecture) && BuildXF86DRI
+#define IHaveSubdirs
+
+#if defined(i386Architecture) || defined(AMD64Architecture)
+VIA_SUBDIRS = hw/via/unichrome hw/via/unichromeProA
+INTEL_SUBDIRS = hw/i810
+#endif
+
+SUBDIRS = $(INTEL_SUBDIRS) $(VIA_SUBDIRS) wrapper
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/XvMC/XvMC-def.cpp b/nx-X11/lib/XvMC/XvMC-def.cpp
new file mode 100644
index 000000000..645d03a99
--- /dev/null
+++ b/nx-X11/lib/XvMC/XvMC-def.cpp
@@ -0,0 +1,8 @@
+LIBRARY XvMC
+VERSION LIBRARY_VERSION
+EXPORTS
+ XvMCListSubpictureTypes
+ XvMCListSurfaceTypes
+ XvMCQueryExtension
+ XvMCQueryVersion
+/* $XFree86$ */
diff --git a/nx-X11/lib/XvMC/XvMC.c b/nx-X11/lib/XvMC/XvMC.c
new file mode 100644
index 000000000..8db64098c
--- /dev/null
+++ b/nx-X11/lib/XvMC/XvMC.c
@@ -0,0 +1,599 @@
+/* $XFree86: xc/lib/XvMC/XvMC.c,v 1.4 2001/11/14 21:54:38 mvojkovi Exp $ */
+
+#define NEED_REPLIES
+
+#include <stdio.h>
+#include "XvMClibint.h"
+#ifdef HAS_SHM
+#ifndef Lynx
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#else
+#include <ipc.h>
+#include <shm.h>
+#endif /* Lynx */
+#endif /* HAS_SHM */
+#include <unistd.h>
+#include <sys/time.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+static XExtensionInfo _xvmc_info_data;
+static XExtensionInfo *xvmc_info = &_xvmc_info_data;
+static char *xvmc_extension_name = XvMCName;
+
+static char *xvmc_error_list[] =
+{
+ "BadContext",
+ "BadSurface",
+ "BadSubpicture"
+};
+
+static XEXT_GENERATE_CLOSE_DISPLAY (xvmc_close_display, xvmc_info)
+
+
+static XEXT_GENERATE_ERROR_STRING (xvmc_error_string, xvmc_extension_name,
+ XvMCNumErrors, xvmc_error_list)
+
+
+static XExtensionHooks xvmc_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ xvmc_close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ xvmc_error_string /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (xvmc_find_display, xvmc_info,
+ xvmc_extension_name,
+ &xvmc_extension_hooks,
+ XvMCNumEvents, NULL)
+
+Bool XvMCQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = xvmc_find_display(dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+Status XvMCQueryVersion (Display *dpy, int *major, int *minor)
+{
+ XExtDisplayInfo *info = xvmc_find_display(dpy);
+ xvmcQueryVersionReply rep;
+ xvmcQueryVersionReq *req;
+
+ XvMCCheckExtension (dpy, info, BadImplementation);
+
+ LockDisplay (dpy);
+ XvMCGetReq (QueryVersion, req);
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return BadImplementation;
+ }
+ *major = rep.major;
+ *minor = rep.minor;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return Success;
+}
+
+
+XvMCSurfaceInfo * XvMCListSurfaceTypes(Display *dpy, XvPortID port, int *num)
+{
+ XExtDisplayInfo *info = xvmc_find_display(dpy);
+ xvmcListSurfaceTypesReply rep;
+ xvmcListSurfaceTypesReq *req;
+ XvMCSurfaceInfo *surface_info = NULL;
+
+ *num = 0;
+
+ XvMCCheckExtension (dpy, info, NULL);
+
+ LockDisplay (dpy);
+ XvMCGetReq (ListSurfaceTypes, req);
+ req->port = port;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return NULL;
+ }
+
+ if(rep.num > 0) {
+ surface_info =
+ (XvMCSurfaceInfo*)Xmalloc(rep.num * sizeof(XvMCSurfaceInfo));
+
+ if(surface_info) {
+ xvmcSurfaceInfo sinfo;
+ int i;
+
+ *num = rep.num;
+
+ for(i = 0; i < rep.num; i++) {
+ _XRead(dpy, (char*)&sinfo, sizeof(xvmcSurfaceInfo));
+ surface_info[i].surface_type_id = sinfo.surface_type_id;
+ surface_info[i].chroma_format = sinfo.chroma_format;
+ surface_info[i].max_width = sinfo.max_width;
+ surface_info[i].max_height = sinfo.max_height;
+ surface_info[i].subpicture_max_width =
+ sinfo.subpicture_max_width;
+ surface_info[i].subpicture_max_height =
+ sinfo.subpicture_max_height;
+ surface_info[i].mc_type = sinfo.mc_type;
+ surface_info[i].flags = sinfo.flags;
+ }
+ } else
+ _XEatData(dpy, rep.length << 2);
+ }
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return surface_info;
+}
+
+
+XvImageFormatValues * XvMCListSubpictureTypes (
+ Display * dpy,
+ XvPortID port,
+ int surface_type_id,
+ int *count_return
+)
+{
+ XExtDisplayInfo *info = xvmc_find_display(dpy);
+ xvmcListSubpictureTypesReply rep;
+ xvmcListSubpictureTypesReq *req;
+ XvImageFormatValues *ret = NULL;
+
+
+ *count_return = 0;
+
+ XvMCCheckExtension (dpy, info, NULL);
+
+
+ LockDisplay (dpy);
+ XvMCGetReq (ListSubpictureTypes, req);
+ req->port = port;
+ req->surface_type_id = surface_type_id;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return NULL;
+ }
+
+ if(rep.num > 0) {
+ ret =
+ (XvImageFormatValues*)Xmalloc(rep.num * sizeof(XvImageFormatValues));
+
+ if(ret) {
+ xvImageFormatInfo Info;
+ int i;
+
+ *count_return = rep.num;
+
+ for(i = 0; i < rep.num; i++) {
+ _XRead(dpy, (char*)(&Info), sz_xvImageFormatInfo);
+ ret[i].id = Info.id;
+ ret[i].type = Info.type;
+ ret[i].byte_order = Info.byte_order;
+ memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16);
+ ret[i].bits_per_pixel = Info.bpp;
+ ret[i].format = Info.format;
+ ret[i].num_planes = Info.num_planes;
+ ret[i].depth = Info.depth;
+ ret[i].red_mask = Info.red_mask;
+ ret[i].green_mask = Info.green_mask;
+ ret[i].blue_mask = Info.blue_mask;
+ ret[i].y_sample_bits = Info.y_sample_bits;
+ ret[i].u_sample_bits = Info.u_sample_bits;
+ ret[i].v_sample_bits = Info.v_sample_bits;
+ ret[i].horz_y_period = Info.horz_y_period;
+ ret[i].horz_u_period = Info.horz_u_period;
+ ret[i].horz_v_period = Info.horz_v_period;
+ ret[i].vert_y_period = Info.vert_y_period;
+ ret[i].vert_u_period = Info.vert_u_period;
+ ret[i].vert_v_period = Info.vert_v_period;
+ memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32);
+ ret[i].scanline_order = Info.scanline_order;
+ }
+ } else
+ _XEatData(dpy, rep.length << 2);
+ }
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return ret;
+}
+
+
+/******************************************************************
+ These are intended as a protocol interface to be used by direct
+ rendering libraries. They are not intended to be client viewable
+ functions. These will stay in place until we have a mechanism in
+ place similar to that of OpenGL with an libXvMCcore library.
+*******************************************************************/
+
+/*
+ _xvmc_create_context -
+
+ Pass in the context with the surface_type_id, width, height,
+ port and flags filled out. This function will fill out the
+ context_id and update the width, height and flags field.
+ The server may return implementation-specific information
+ back in the priv_data. The size of that information will
+ an array of priv_count CARD32s. This data is allocated by
+ this function. If returned, the caller is responsible for
+ freeing it! Generally, such information is only returned if
+ an XVMC_DIRECT context was specified.
+*/
+
+
+Status _xvmc_create_context (
+ Display *dpy,
+ XvMCContext *context,
+ int *priv_count,
+ CARD32 **priv_data
+)
+{
+ XExtDisplayInfo *info = xvmc_find_display(dpy);
+ xvmcCreateContextReply rep;
+ xvmcCreateContextReq *req;
+
+ *priv_count = 0;
+ *priv_data = NULL;
+
+ XvMCCheckExtension (dpy, info, BadImplementation);
+
+ LockDisplay (dpy);
+ XvMCGetReq (CreateContext, req);
+ context->context_id = XAllocID(dpy);
+ req->context_id = context->context_id;
+ req->port = context->port;
+ req->surface_type_id = context->surface_type_id;
+ req->width = context->width;
+ req->height = context->height;
+ req->flags = context->flags;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return BadImplementation;
+ }
+ context->width = rep.width_actual;
+ context->height = rep.height_actual;
+ context->flags = rep.flags_return;
+
+ if(rep.length) {
+ *priv_data = Xmalloc(rep.length << 2);
+ if(*priv_data) {
+ _XRead(dpy, (char*)(*priv_data), rep.length << 2);
+ *priv_count = rep.length;
+ } else
+ _XEatData(dpy, rep.length << 2);
+ }
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return Success;
+}
+
+Status _xvmc_destroy_context (
+ Display *dpy,
+ XvMCContext *context
+)
+{
+ XExtDisplayInfo *info = xvmc_find_display(dpy);
+ xvmcDestroyContextReq *req;
+
+ XvMCCheckExtension (dpy, info, BadImplementation);
+
+ LockDisplay (dpy);
+ XvMCGetReq (DestroyContext, req);
+ req->context_id = context->context_id;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return Success;
+}
+
+
+/*
+ _xvmc_create_surface -
+
+ Pass the context and this function will fill out all the
+ information in the surface.
+ The server may return implementation-specific information
+ back in the priv_data. The size of that information will
+ an array of priv_count CARD32s. This data is allocated by
+ this function. If returned, the caller is responsible for
+ freeing it! Generally, such information is returned only if
+ the context was a direct context.
+
+*/
+
+Status _xvmc_create_surface (
+ Display *dpy,
+ XvMCContext *context,
+ XvMCSurface *surface,
+ int *priv_count,
+ CARD32 **priv_data
+)
+{
+ XExtDisplayInfo *info = xvmc_find_display(dpy);
+ xvmcCreateSurfaceReply rep;
+ xvmcCreateSurfaceReq *req;
+
+ *priv_count = 0;
+ *priv_data = NULL;
+
+ XvMCCheckExtension (dpy, info, BadImplementation);
+
+ LockDisplay (dpy);
+ XvMCGetReq (CreateSurface, req);
+
+ surface->surface_id = XAllocID(dpy);
+ surface->context_id = context->context_id;
+ surface->surface_type_id = context->surface_type_id;
+ surface->width = context->width;
+ surface->height = context->height;
+
+ req->surface_id = surface->surface_id;
+ req->context_id = surface->context_id;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return BadImplementation;
+ }
+
+ if(rep.length) {
+ *priv_data = Xmalloc(rep.length << 2);
+ if(*priv_data) {
+ _XRead(dpy, (char*)(*priv_data), rep.length << 2);
+ *priv_count = rep.length;
+ } else
+ _XEatData(dpy, rep.length << 2);
+ }
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return Success;
+}
+
+Status _xvmc_destroy_surface (
+ Display *dpy,
+ XvMCSurface *surface
+)
+{
+ XExtDisplayInfo *info = xvmc_find_display(dpy);
+ xvmcDestroySurfaceReq *req;
+
+ XvMCCheckExtension (dpy, info, BadImplementation);
+
+ LockDisplay (dpy);
+ XvMCGetReq (DestroySurface, req);
+ req->surface_id = surface->surface_id;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return Success;
+}
+
+/*
+ _xvmc_create_subpicture -
+
+ Pass the subpicture with the width, height and xvimage_id filled
+ out and this function will fill out everything else in the
+ subpicture as well as adjust the width and height if needed.
+ The server may return implementation-specific information
+ back in the priv_data. The size of that information will
+ an array of priv_count CARD32s. This data is allocated by
+ this function. If returned, the caller is responsible for
+ freeing it! Generally, such information is returned only if
+ the context was a direct context.
+
+*/
+
+Status _xvmc_create_subpicture (
+ Display *dpy,
+ XvMCContext *context,
+ XvMCSubpicture *subpicture,
+ int *priv_count,
+ CARD32 **priv_data
+)
+{
+ XExtDisplayInfo *info = xvmc_find_display(dpy);
+ xvmcCreateSubpictureReply rep;
+ xvmcCreateSubpictureReq *req;
+
+ *priv_count = 0;
+ *priv_data = NULL;
+
+ XvMCCheckExtension (dpy, info, BadImplementation);
+
+ LockDisplay (dpy);
+ XvMCGetReq (CreateSubpicture, req);
+
+ subpicture->subpicture_id = XAllocID(dpy);
+ subpicture->context_id = context->context_id;
+
+ req->subpicture_id = subpicture->subpicture_id;
+ req->context_id = subpicture->context_id;
+ req->xvimage_id = subpicture->xvimage_id;
+ req->width = subpicture->width;
+ req->height = subpicture->height;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return BadImplementation;
+ }
+
+ subpicture->width = rep.width_actual;
+ subpicture->height = rep.height_actual;
+ subpicture->num_palette_entries = rep.num_palette_entries;
+ subpicture->entry_bytes = rep.entry_bytes;
+ subpicture->component_order[0] = rep.component_order[0];
+ subpicture->component_order[1] = rep.component_order[1];
+ subpicture->component_order[2] = rep.component_order[2];
+ subpicture->component_order[3] = rep.component_order[3];
+
+ if(rep.length) {
+ *priv_data = Xmalloc(rep.length << 2);
+ if(*priv_data) {
+ _XRead(dpy, (char*)(*priv_data), rep.length << 2);
+ *priv_count = rep.length;
+ } else
+ _XEatData(dpy, rep.length << 2);
+ }
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return Success;
+}
+
+Status _xvmc_destroy_subpicture(
+ Display *dpy,
+ XvMCSubpicture *subpicture
+)
+{
+ XExtDisplayInfo *info = xvmc_find_display(dpy);
+ xvmcDestroySubpictureReq *req;
+
+ XvMCCheckExtension (dpy, info, BadImplementation);
+
+ LockDisplay (dpy);
+ XvMCGetReq (DestroySubpicture, req);
+ req->subpicture_id = subpicture->subpicture_id;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return Success;
+}
+
+Status XvMCGetDRInfo(Display *dpy, XvPortID port,
+ char **name, char **busID,
+ int *major, int *minor,
+ int *patchLevel,
+ int *isLocal)
+{
+ XExtDisplayInfo *info = xvmc_find_display(dpy);
+ xvmcGetDRInfoReply rep;
+ xvmcGetDRInfoReq *req;
+ char *tmpBuf = NULL;
+ CARD32 magic;
+
+#ifdef HAS_SHM
+ volatile CARD32 *shMem;
+ struct timezone here;
+ struct timeval now;
+ here.tz_minuteswest = 0;
+ here.tz_dsttime = 0;
+#endif
+
+ XvMCCheckExtension (dpy, info, BadImplementation);
+
+ LockDisplay (dpy);
+ XvMCGetReq (GetDRInfo, req);
+
+ req->port = port;
+ magic = 0;
+ req->magic = 0;
+#ifdef HAS_SHM
+ req->shmKey = shmget(IPC_PRIVATE, 1024, IPC_CREAT | 0600);
+
+ /*
+ * We fill a shared memory page with a repetitive pattern. If the
+ * X server can read this pattern, we probably have a local connection.
+ * Note that we can trigger the remote X server to read any shared
+ * page on the remote machine, so we shouldn't be able to guess and verify
+ * any complicated data on those pages. Thats the explanation of this
+ * otherwise stupid-looking pattern algorithm.
+ */
+
+ if (req->shmKey >= 0) {
+ shMem = (CARD32 *) shmat(req->shmKey, 0, 0);
+ shmctl( req->shmKey, IPC_RMID, 0);
+ if ( shMem ) {
+
+ register volatile CARD32 *shMemC = shMem;
+ register int i;
+
+ gettimeofday( &now, &here);
+ magic = now.tv_usec & 0x000FFFFF;
+ req->magic = magic;
+ i = 1024 / sizeof(CARD32);
+ while(i--) {
+ *shMemC++ = magic;
+ magic = ~magic;
+ }
+ } else {
+ req->shmKey = -1;
+ }
+ }
+#else
+ req->shmKey = 0;
+#endif
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+#ifdef HAS_SHM
+ if ( req->shmKey >= 0) {
+ shmdt( (const void *) shMem );
+ }
+#endif
+ return -1;
+ }
+#ifdef HAS_SHM
+ shmdt( (const void *) shMem );
+#endif
+
+ if (rep.length > 0) {
+
+ int realSize = rep.length << 2;
+
+ tmpBuf = (char *) Xmalloc(realSize);
+ if (tmpBuf) {
+ *name = (char *) Xmalloc(rep.nameLen);
+ if (*name) {
+ *busID = (char *) Xmalloc(rep.busIDLen);
+ if (! *busID) {
+ XFree(*name);
+ XFree(tmpBuf);
+ }
+ } else {
+ XFree(tmpBuf);
+ }
+ }
+
+ if (*name && *busID && tmpBuf) {
+
+ _XRead(dpy, tmpBuf, realSize);
+ strncpy(*name,tmpBuf,rep.nameLen);
+ strncpy(*busID,tmpBuf+rep.nameLen,rep.busIDLen);
+ XFree(tmpBuf);
+
+ } else {
+
+ _XEatData(dpy, realSize);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return -1;
+
+ }
+ }
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ *major = rep.major;
+ *minor = rep.minor;
+ *patchLevel = rep.patchLevel;
+ *isLocal = (req->shmKey > 0) ? rep.isLocal : 1;
+ return (rep.length > 0) ? Success : BadImplementation;
+}
+
diff --git a/nx-X11/lib/XvMC/XvMClibint.h b/nx-X11/lib/XvMC/XvMClibint.h
new file mode 100644
index 000000000..1db39249a
--- /dev/null
+++ b/nx-X11/lib/XvMC/XvMClibint.h
@@ -0,0 +1,40 @@
+/* $XFree86: xc/lib/XvMC/XvMClibint.h,v 1.4 2001/07/25 15:04:54 dawes Exp $ */
+
+#ifndef _XVMCLIBINT_H
+#define _XVMCLIBINT_H
+#define NEED_REPLIES
+
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xvproto.h>
+#include <X11/extensions/XvMCproto.h>
+#include <X11/extensions/XvMClib.h>
+
+#define XvMCCheckExtension(dpy, i, val) \
+ XextCheckExtension(dpy, i, xvmc_extension_name, val)
+
+
+#if !defined(UNIXCPP)
+#define XvMCGetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + sizeof(xvmc##name##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xvmc##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = info->codes->major_opcode;\
+ req->xvmcReqType = xvmc_##name; \
+ req->length = sizeof(xvmc##name##Req)>>2;\
+ dpy->bufptr += sizeof(xvmc##name##Req);\
+ dpy->request++
+#else
+#define XvMCGetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + sizeof(xvmc/**/name/**/Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xvmc/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = info->codes->major_opcode;\
+ req->xvmcReqType = xvmc_/**/name;\
+ req->length = sizeof(xvmc/**/name/**/Req)>>2;\
+ dpy->bufptr += sizeof(xvmc/**/name/**/Req);\
+ dpy->request++
+#endif
+
+#endif /* XVMCLIBINT_H */
diff --git a/nx-X11/lib/XvMC/hw/i810/I810XvMC.c b/nx-X11/lib/XvMC/hw/i810/I810XvMC.c
new file mode 100644
index 000000000..89aa3ea4b
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/i810/I810XvMC.c
@@ -0,0 +1,4507 @@
+/***************************************************************************
+
+Copyright 2001 Intel Corporation. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*************************************************************************
+** File libI810XvMC.c
+**
+** Authors:
+** Matt Sottek <matthew.j.sottek@intel.com>
+** Bob Paauwe <bob.j.paauwe@intel.com>
+**
+**
+***************************************************************************/
+/* $XFree86: xc/lib/XvMC/hw/i810/I810XvMC.c,v 1.10 2002/10/30 12:52:01 alanh Exp $ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <string.h>
+
+#include <sys/ioctl.h>
+#include <X11/Xlibint.h>
+#include <fourcc.h>
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvlib.h>
+#include <X11/extensions/XvMC.h>
+#include <X11/extensions/XvMClib.h>
+#include "I810XvMC.h"
+
+static int error_base;
+static int event_base;
+
+/***************************************************************************
+// Function: i810_get_free_buffer
+// Description: Allocates a free dma page using kernel ioctls, then
+// programs the data into the already allocated dma buffer list.
+// Arguments: pI810XvMC private data structure from the current context.
+// Notes: We faked the drmMapBufs for the i810's security so now we have
+// to insert an allocated page into the correct spot in the faked
+// list to keep up appearences.
+// Concept for this function was taken from Mesa sources.
+// Returns: drmBufPtr containing the information about the allocated page.
+***************************************************************************/
+drmBufPtr i810_get_free_buffer(i810XvMCContext *pI810XvMC) {
+ drmI810DMA dma;
+ drmBufPtr buf;
+
+ dma.granted = 0;
+ dma.request_size = 4096;
+ while(!dma.granted) {
+ if(GET_BUFFER(pI810XvMC, dma) || !dma.granted)
+ FLUSH(pI810XvMC);
+ } /* No DMA granted */
+
+ buf = &(pI810XvMC->dmabufs->list[dma.request_idx]);
+ buf->idx = dma.request_idx;
+ buf->used = 0;
+ buf->total = dma.request_size;
+ buf->address = (drmAddress)dma.virtual;
+ return buf;
+}
+
+/***************************************************************************
+// Function: free_privContext
+// Description: Free's the private context structure if the reference
+// count is 0.
+***************************************************************************/
+void i810_free_privContext(i810XvMCContext *pI810XvMC) {
+
+ I810_LOCK(pI810XvMC,DRM_LOCK_QUIESCENT);
+
+
+ pI810XvMC->ref--;
+ if(!pI810XvMC->ref) {
+ drmUnmapBufs(pI810XvMC->dmabufs);
+ drmUnmap(pI810XvMC->overlay.address,pI810XvMC->overlay.size);
+ drmUnmap(pI810XvMC->surfaces.address,pI810XvMC->surfaces.size);
+ drmClose(pI810XvMC->fd);
+
+ free(pI810XvMC->dmabufs->list);
+ free(pI810XvMC);
+ }
+
+ I810_UNLOCK(pI810XvMC);
+}
+
+
+/***************************************************************************
+// Function: XvMCCreateContext
+// Description: Create a XvMC context for the given surface parameters.
+// Arguments:
+// display - Connection to the X server.
+// port - XvPortID to use as avertised by the X connection.
+// surface_type_id - Unique identifier for the Surface type.
+// width - Width of the surfaces.
+// height - Height of the surfaces.
+// flags - one or more of the following
+// XVMC_DIRECT - A direct rendered context is requested.
+//
+// Notes: surface_type_id and width/height parameters must match those
+// returned by XvMCListSurfaceTypes.
+// Returns: Status
+***************************************************************************/
+Status XvMCCreateContext(Display *display, XvPortID port,
+ int surface_type_id, int width, int height, int flags,
+ XvMCContext *context) {
+ i810XvMCContext *pI810XvMC;
+ char busIdString[10];
+ int priv_count;
+ uint *priv_data;
+ uint magic;
+ Status ret;
+ int major, minor;
+
+ /* Verify Obvious things first */
+ if(context == NULL) {
+ return XvMCBadContext;
+ }
+
+ if(!(flags & XVMC_DIRECT)) {
+ /* Indirect */
+ printf("Indirect Rendering not supported!\nUsing Direct.");
+ }
+
+ /* Limit use to root for now */
+ if(geteuid()) {
+ printf("Use of XvMC on i810 is currently limited to root\n");
+ return BadAccess;
+ }
+
+ /* FIXME: Check $DISPLAY for legal values here */
+
+ context->surface_type_id = surface_type_id;
+ context->width = (unsigned short)width;
+ context->height = (unsigned short)height;
+ context->flags = flags;
+ context->port = port;
+ /*
+ Width, Height, and flags are checked against surface_type_id
+ and port for validity inside the X server, no need to check
+ here.
+ */
+
+ /* Allocate private Context data */
+ context->privData = (void *)malloc(sizeof(i810XvMCContext));
+ if(!context->privData) {
+ printf("Unable to allocate resources for XvMC context.\n");
+ return BadAlloc;
+ }
+ pI810XvMC = (i810XvMCContext *)context->privData;
+
+
+ /* Verify the XvMC extension exists */
+ if(! XvMCQueryExtension(display, &event_base,
+ &error_base)) {
+ printf("XvMC Extension is not available!\n");
+ return BadAlloc;
+ }
+ /* Verify XvMC version */
+ ret = XvMCQueryVersion(display, &major, &minor);
+ if(ret) {
+ printf("XvMCQuery Version Failed, unable to determine protocol version\n");
+ }
+ /* FIXME: Check Major and Minor here */
+
+ /* Check for drm */
+ if(! drmAvailable()) {
+ printf("Direct Rendering is not avilable on this system!\n");
+ return BadAlloc;
+ }
+
+ /*
+ Build the Attribute Atoms, and Initialize the ones that exist
+ in Xv.
+ */
+ pI810XvMC->xv_colorkey = XInternAtom(display,"XV_COLORKEY",0);
+ if(!pI810XvMC->xv_colorkey) {
+ return XvBadPort;
+ }
+ ret = XvGetPortAttribute(display,port,pI810XvMC->xv_colorkey,
+ &pI810XvMC->colorkey);
+ if(ret) {
+ return ret;
+ }
+ pI810XvMC->xv_brightness = XInternAtom(display,"XV_BRIGHTNESS",0);
+ pI810XvMC->xv_saturation = XInternAtom(display,"XV_SATURATION",0);
+ pI810XvMC->xv_contrast = XInternAtom(display,"XV_CONTRAST",0);
+ pI810XvMC->brightness = 0;
+ pI810XvMC->saturation = 0x80; /* 1.0 in 3.7 format */
+ pI810XvMC->contrast = 0x40; /* 1.0 in 3.6 format */
+
+ /* Open DRI Device */
+ if((pI810XvMC->fd = drmOpen("i810",NULL)) < 0) {
+ printf("DRM Device for i810 could not be opened.\n");
+ free(busIdString);
+ free(pI810XvMC);
+ return BadAccess;
+ } /* !pI810XvMC->fd */
+
+ /* Get magic number and put it in privData for passing */
+ drmGetMagic(pI810XvMC->fd,&magic);
+ context->flags = (unsigned long)magic;
+
+ /*
+ Pass control to the X server to create a drm_context_t for us and
+ validate the with/height and flags.
+ */
+ if((ret = _xvmc_create_context(display, context, &priv_count, &priv_data))) {
+ printf("Unable to create XvMC Context.\n");
+ return ret;
+ }
+
+ /*
+ X server returns a structure like this:
+ drm_context_t
+ fbBase
+ OverlayOffset
+ OverlaySize
+ SurfacesOffset
+ SurfacesSize
+ busIdString = 9 char + 1
+ */
+ if(priv_count != 9) {
+ printf("_xvmc_create_context() returned incorrect data size!\n");
+ printf("\tExpected 9, got %d\n",priv_count);
+ _xvmc_destroy_context(display, context);
+ free(pI810XvMC);
+ return BadAlloc;
+ }
+ pI810XvMC->drmcontext = priv_data[0];
+ pI810XvMC->fb_base = priv_data[1];
+ pI810XvMC->overlay.offset = priv_data[2] + priv_data[1];
+ pI810XvMC->overlay.size = priv_data[3];
+ pI810XvMC->surfaces.offset = priv_data[4] + priv_data[1];
+ pI810XvMC->surfaces.size = priv_data[5];
+ strncpy(pI810XvMC->busIdString,(char *)&priv_data[6],9);
+ pI810XvMC->busIdString[9] = '\0';
+
+ /* Must free the private data we were passed from X */
+ free(priv_data);
+
+ /* Initialize private context values */
+ pI810XvMC->current = 0;
+ pI810XvMC->lock = 0;
+ pI810XvMC->last_flip = 0;
+ pI810XvMC->dual_prime = 0;
+
+ /*
+ Map dma Buffers: Not really, this would be a drmMapBufs
+ but due to the i810 security model we have to just create an
+ empty data structure to fake it.
+ */
+ pI810XvMC->dmabufs = (drmBufMapPtr)malloc(sizeof(drmBufMap));
+ if(pI810XvMC->dmabufs == NULL) {
+ printf("Dma Bufs could not be mapped.\n");
+ _xvmc_destroy_context(display, context);
+ free(pI810XvMC);
+ return BadAlloc;
+ } /* pI810XvMC->dmabufs == NULL */
+ memset(pI810XvMC->dmabufs, 0, sizeof(drmBufMap));
+ pI810XvMC->dmabufs->list = (drmBufPtr)malloc(sizeof(drmBuf) *
+ I810_DMA_BUF_NR);
+ if(pI810XvMC->dmabufs->list == NULL) {
+ printf("Dma Bufs could not be mapped.\n");
+ _xvmc_destroy_context(display, context);
+ free(pI810XvMC);
+ return BadAlloc;
+ } /* pI810XvMC->dmabufs->list == NULL */
+ memset(pI810XvMC->dmabufs->list, 0, sizeof(drmBuf) * I810_DMA_BUF_NR);
+
+ /* Map the Overlay memory */
+ if(drmMap(pI810XvMC->fd,pI810XvMC->overlay.offset,
+ pI810XvMC->overlay.size,&(pI810XvMC->overlay.address)) < 0) {
+ printf("Unable to map Overlay at offset 0x%x and size 0x%x\n",
+ (unsigned int)pI810XvMC->overlay.offset,pI810XvMC->overlay.size);
+ _xvmc_destroy_context(display, context);
+ free(pI810XvMC->dmabufs->list);
+ free(pI810XvMC);
+ return BadAlloc;
+ } /* drmMap() < 0 */
+
+ /* Overlay Regs are offset 1024 into Overlay Map */
+ pI810XvMC->oregs = (i810OverlayRec *)
+ ((unsigned char *)pI810XvMC->overlay.address + 1024);
+
+ /* Map Surfaces */
+ if(drmMap(pI810XvMC->fd,pI810XvMC->surfaces.offset,
+ pI810XvMC->surfaces.size,&(pI810XvMC->surfaces.address)) < 0) {
+ printf("Unable to map XvMC Surfaces.\n");
+ _xvmc_destroy_context(display, context);
+ free(pI810XvMC->dmabufs->list);
+ free(pI810XvMC);
+ return BadAlloc;
+ } /* drmMap() < 0 */
+
+ /*
+ There is a tiny chance that someone was using the overlay and
+ issued a flip that hasn't finished. To be 100% sure I'll just
+ take the lock and sleep for the worst case time for a flip.
+ */
+ I810_LOCK(pI810XvMC,DRM_LOCK_QUIESCENT);
+ usleep(20000); /* 1/50th Sec for 50hz refresh */
+
+ /* Set up Overlay regs with Initial Values */
+ pI810XvMC->oregs->YRGB_VPH = 0;
+ pI810XvMC->oregs->UV_VPH = 0;
+ pI810XvMC->oregs->HORZ_PH = 0;
+ pI810XvMC->oregs->INIT_PH = 0;
+ pI810XvMC->oregs->DWINPOS = 0;
+ pI810XvMC->oregs->DWINSZ = (I810_XVMC_MAXHEIGHT << 16) |
+ I810_XVMC_MAXWIDTH;
+ pI810XvMC->oregs->SWID = I810_XVMC_MAXWIDTH | (I810_XVMC_MAXWIDTH << 15);
+ pI810XvMC->oregs->SWIDQW = (I810_XVMC_MAXWIDTH >> 3) |
+ (I810_XVMC_MAXWIDTH << 12);
+ pI810XvMC->oregs->SHEIGHT = I810_XVMC_MAXHEIGHT |
+ (I810_XVMC_MAXHEIGHT << 15);
+ pI810XvMC->oregs->YRGBSCALE = 0x80004000; /* scale factor 1 */
+ pI810XvMC->oregs->UVSCALE = 0x80004000; /* scale factor 1 */
+ pI810XvMC->oregs->OV0CLRC0 = 0x4000; /* brightness: 0 contrast: 1.0 */
+ pI810XvMC->oregs->OV0CLRC1 = 0x80; /* saturation: bypass */
+
+ /* Destination Colorkey Setup */
+ pI810XvMC->oregs->DCLRKV = RGB16ToColorKey(pI810XvMC->colorkey);
+ pI810XvMC->oregs->DCLRKM = 0x80070307;
+
+
+ pI810XvMC->oregs->SCLRKVH = 0;
+ pI810XvMC->oregs->SCLRKVL = 0;
+ pI810XvMC->oregs->SCLRKM = 0; /* source color key disable */
+ pI810XvMC->oregs->OV0CONF = 0; /* two 720 pixel line buffers */
+
+ pI810XvMC->oregs->OV0CMD = VC_UP_INTERPOLATION | HC_UP_INTERPOLATION |
+ Y_ADJUST | YUV_420;
+
+ pI810XvMC->ref = 1;
+
+ I810_UNLOCK(pI810XvMC);
+
+ return Success;
+
+}
+
+/***************************************************************************
+// Function: XvMCDestroyContext
+// Description: Destorys the specified context.
+//
+// Arguments:
+// display - Specifies the connection to the server.
+// context - The context to be destroyed.
+//
+// Returns: Status
+***************************************************************************/
+Status XvMCDestroyContext(Display *display, XvMCContext *context) {
+ i810XvMCContext *pI810XvMC;
+
+ if(context == NULL) {
+ return (error_base + XvMCBadContext);
+ }
+ if(context->privData == NULL) {
+ return (error_base + XvMCBadContext);
+ }
+ pI810XvMC = (i810XvMCContext *)context->privData;
+
+ /* Turn off the overlay */
+ if(pI810XvMC->last_flip) {
+ I810_LOCK(pI810XvMC,DRM_LOCK_QUIESCENT);
+
+ /* Make sure last flip is done */
+ BLOCK_OVERLAY(pI810XvMC,pI810XvMC->current);
+
+ pI810XvMC->oregs->OV0CMD = VC_UP_INTERPOLATION | HC_UP_INTERPOLATION |
+ Y_ADJUST;
+ pI810XvMC->current = !pI810XvMC->current;
+ if(pI810XvMC->current == 1) {
+ pI810XvMC->oregs->OV0CMD |= BUFFER1_FIELD0;
+ }
+ else {
+ pI810XvMC->oregs->OV0CMD |= BUFFER0_FIELD0;
+ }
+ OVERLAY_FLIP(pI810XvMC);
+ pI810XvMC->last_flip++;
+
+ /* Wait for the flip */
+ BLOCK_OVERLAY(pI810XvMC,pI810XvMC->current);
+
+ I810_UNLOCK(pI810XvMC);
+ }
+
+ /* Pass Control to the X server to destroy the drm_context_t */
+ _xvmc_destroy_context(display, context);
+
+ i810_free_privContext(pI810XvMC);
+ context->privData = NULL;
+
+ return Success;
+}
+
+
+/***************************************************************************
+// Function: XvMCCreateSurface
+***************************************************************************/
+Status XvMCCreateSurface( Display *display, XvMCContext *context,
+ XvMCSurface *surface) {
+ i810XvMCContext *pI810XvMC;
+ i810XvMCSurface *pI810Surface;
+ int priv_count;
+ uint *priv_data;
+ Status ret;
+
+ if((surface == NULL) || (context == NULL) || (display == NULL)){
+ return BadValue;
+ }
+
+ pI810XvMC = (i810XvMCContext *)context->privData;
+ if(pI810XvMC == NULL) {
+ return (error_base + XvMCBadContext);
+ }
+
+
+ surface->privData = (i810XvMCSurface *)malloc(sizeof(i810XvMCSurface));
+ if(!surface->privData) {
+ return BadAlloc;
+ }
+ pI810Surface = (i810XvMCSurface *)surface->privData;
+
+ /* Initialize private values */
+ pI810Surface->privContext = pI810XvMC;
+ pI810Surface->last_render = 0;
+ pI810Surface->last_flip = 0;
+ pI810Surface->second_field = 0;
+
+ if((ret = _xvmc_create_surface(display, context, surface,
+ &priv_count, &priv_data))) {
+ free(pI810Surface);
+ printf("Unable to create XvMCSurface.\n");
+ return ret;
+ }
+
+ /*
+ _xvmc_create_subpicture returns 2 uints with the offset into
+ the DRM map for the Y surface and UV surface.
+ */
+ if(priv_count != 2) {
+ printf("_xvmc_create_surface() return incorrect data size.\n");
+ printf("Expected 2 got %d\n",priv_count);
+ free(priv_data);
+ free(pI810Surface);
+ return BadAlloc;
+ }
+ /* Data == Client Address, offset == Physical address offset */
+ pI810Surface->data = pI810XvMC->surfaces.address;
+ pI810Surface->offset = pI810XvMC->surfaces.offset;
+
+
+ /*
+ i810's MC Engine needs surfaces of 2^x (x= 9,10,11,12) pitch
+ and the Tiler need 512k aligned surfaces, basically we are
+ stuck with fixed memory with pitch 1024 for Y data. UV = 512.
+ */
+ pI810Surface->pitch = 10;
+ if((surface->surface_type_id == FOURCC_UYVY) ||
+ (surface->surface_type_id == FOURCC_YUY2)) {
+ /* This is not implemented server side. */
+ pI810Surface->pitch++;
+ }
+
+ /*
+ offsets[0,1,2] == Offsets from either data or offset for the Y
+ U and V surfaces.
+ */
+ pI810Surface->offsets[0] = priv_data[0];
+ if(((unsigned long)pI810Surface->data + pI810Surface->offsets[0]) & 4095) {
+ printf("XvMCCreateSurface: Surface offset 0 is not 4096 aligned\n");
+ }
+
+ if((surface->surface_type_id == FOURCC_UYVY) ||
+ (surface->surface_type_id == FOURCC_YUY2)) {
+ /* Packed surface, not fully implemented */
+ pI810Surface->offsets[1] = 0;
+ pI810Surface->offsets[2] = 0;
+ }
+ else {
+ /* Planar surface */
+ pI810Surface->offsets[1] = priv_data[1];
+ if(((unsigned long)pI810Surface->data + pI810Surface->offsets[1]) & 2047) {
+ printf("XvMCCreateSurface: Surface offset 1 is not 2048 aligned\n");
+ }
+
+ pI810Surface->offsets[2] = ((unsigned long)pI810Surface->offsets[1] +
+ (1<<(pI810Surface->pitch - 1)) * 288);
+ if(((unsigned long)pI810Surface->data + pI810Surface->offsets[2]) & 2047) {
+ printf("XvMCCreateSurface: Surface offset 2 is not 2048 aligned\n");
+ }
+
+ }
+
+ /* Free data returned from xvmc_create_surface */
+ free(priv_data);
+
+ /* Clear the surface to 0 */
+ memset((void *)((unsigned long)pI810Surface->data + (unsigned long)pI810Surface->offsets[0]),
+ 0, ((1<<pI810Surface->pitch) * surface->height));
+
+ switch(surface->surface_type_id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ /* Destination buffer info command */
+ pI810Surface->dbi1y = ((((unsigned int)pI810Surface->offset +
+ pI810Surface->offsets[0]) & ~0xfc000fff) |
+ (pI810Surface->pitch - 9));
+ pI810Surface->dbi1u = ((((unsigned int)pI810Surface->offset +
+ pI810Surface->offsets[1]) & ~0xfc000fff) |
+ (pI810Surface->pitch - 10));
+ pI810Surface->dbi1v = ((((unsigned int)pI810Surface->offset +
+ pI810Surface->offsets[2]) & ~0xfc000fff) |
+ (pI810Surface->pitch - 10));
+
+ /* Destination buffer variables command */
+ pI810Surface->dbv1 = (0x8<<20) | (0x8<<16);
+ /* Map info command */
+ pI810Surface->mi1y = (0x1<<24) | (1<<9) | (pI810Surface->pitch - 3);
+ pI810Surface->mi1u = (0x1<<24) | (1<<9) | (pI810Surface->pitch - 4);
+ pI810Surface->mi1v = (0x1<<24) | (1<<9) | (pI810Surface->pitch - 4);
+
+ pI810Surface->mi2y = (((unsigned int)surface->height - 1)<<16) |
+ ((unsigned int)surface->width - 1);
+ pI810Surface->mi2u = (((unsigned int)surface->height - 1)<<15) |
+ (((unsigned int)surface->width - 1)>>1);
+ pI810Surface->mi2v = pI810Surface->mi2u;
+
+ pI810Surface->mi3y = ((unsigned int)pI810Surface->offset +
+ pI810Surface->offsets[0]) & ~0x0000000f;
+ pI810Surface->mi3u = ((unsigned int)pI810Surface->offset +
+ pI810Surface->offsets[1]) & ~0x0000000f;
+ pI810Surface->mi3v = ((unsigned int)pI810Surface->offset +
+ pI810Surface->offsets[2]) & ~0x0000000f;
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ /* Destination buffer info command */
+ pI810Surface->dbi1y = ((((unsigned int)pI810Surface->offset +
+ pI810Surface->offsets[0]) & ~0xfc000fff) |
+ (pI810Surface->pitch - 9));
+ /* Destination buffer variables command */
+ if(surface->surface_type_id == FOURCC_YUY2) {
+ pI810Surface->dbv1 = 0x5<<8;
+ pI810Surface->mi1y = 0x5<<24 | pI810Surface->pitch | 0x1<<21;
+ }
+ else {
+ pI810Surface->dbv1 = 0x4<<8;
+ pI810Surface->mi1y = 0x5<<24 | (pI810Surface->pitch - 3);
+ }
+ pI810Surface->mi2y = (((unsigned int)surface->width - 1)<<16) |
+ ((unsigned int)surface->height - 1);
+ pI810Surface->mi3y = ((unsigned int)pI810Surface->offset +
+ pI810Surface->offsets[0]) & ~0xfc000fff;
+ break;
+ }
+ pI810XvMC->ref++;
+
+ return Success;
+}
+
+
+/***************************************************************************
+// Function: XvMCDestroySurface
+***************************************************************************/
+Status XvMCDestroySurface(Display *display, XvMCSurface *surface) {
+ i810XvMCSurface *pI810Surface;
+ i810XvMCContext *pI810XvMC;
+
+ if((display == NULL) || (surface == NULL)) {
+ return BadValue;
+ }
+ if(surface->privData == NULL) {
+ return (error_base + XvMCBadSurface);
+ }
+
+ pI810Surface = (i810XvMCSurface *)surface->privData;
+ if(pI810Surface->last_flip) {
+ XvMCSyncSurface(display,surface);
+ }
+ pI810XvMC = (i810XvMCContext *)pI810Surface->privContext;
+
+ _xvmc_destroy_surface(display,surface);
+
+ i810_free_privContext(pI810XvMC);
+
+ free(pI810Surface);
+ surface->privData = NULL;
+ return Success;
+}
+
+/***************************************************************************
+// Function: XvMCCreateBlocks
+***************************************************************************/
+Status XvMCCreateBlocks(Display *display, XvMCContext *context,
+ unsigned int num_blocks,
+ XvMCBlockArray *block) {
+
+ if((display == NULL) || (context == NULL) || (num_blocks == 0)) {
+ return BadValue;
+ }
+
+ block->blocks = (short *)malloc(num_blocks<<6 * sizeof(short));
+ if(block->blocks == NULL) {
+ return BadAlloc;
+ }
+
+ block->num_blocks = num_blocks;
+ block->context_id = context->context_id;
+
+ block->privData = NULL;
+
+ return Success;
+}
+
+/***************************************************************************
+// Function: XvMCDestroyBlocks
+***************************************************************************/
+Status XvMCDestroyBlocks(Display *display, XvMCBlockArray *block) {
+ if(display == NULL) {
+ return BadValue;
+ }
+
+ free(block->blocks);
+ block->num_blocks = 0;
+ block->context_id = 0;
+ block->privData = NULL;
+ return Success;
+}
+
+/***************************************************************************
+// Function: XvMCCreateMacroBlocks
+***************************************************************************/
+Status XvMCCreateMacroBlocks(Display *display, XvMCContext *context,
+ unsigned int num_blocks,
+ XvMCMacroBlockArray *blocks) {
+
+ if((display == NULL) || (context == NULL) || (blocks == NULL) ||
+ (num_blocks == 0)) {
+ return BadValue;
+ }
+ memset(blocks,0,sizeof(XvMCMacroBlockArray));
+ blocks->context_id = context->context_id;
+ blocks->privData = NULL;
+
+ blocks->macro_blocks = (XvMCMacroBlock *)
+ malloc(num_blocks * sizeof(XvMCMacroBlock));
+ if(blocks->macro_blocks == NULL) {
+ return BadAlloc;
+ }
+ blocks->num_blocks = num_blocks;
+
+ return Success;
+}
+
+/***************************************************************************
+// Function: XvMCDestroyMacroBlocks
+***************************************************************************/
+Status XvMCDestroyMacroBlocks(Display *display, XvMCMacroBlockArray *block) {
+ if((display == NULL) || (block == NULL)) {
+ return BadValue;
+ }
+ if(block->macro_blocks) {
+ free(block->macro_blocks);
+ }
+ block->context_id = 0;
+ block->num_blocks = 0;
+ block->privData = NULL;
+
+ return Success;
+}
+
+
+/***************************************************************************
+// Function: dp (Debug Print)
+// Description: This function prints out in hex i * uint32_t at the address
+// supplied. This enables you to print out the dma buffers from
+// within the debugger even though they are not in your address space.
+***************************************************************************/
+void dp(unsigned int *address, unsigned int i) {
+ int j;
+
+ printf("DebugPrint:\n");
+ for(j=0; j<i; j++) {
+ printf("0x%8.8x ",address[j]);
+ if(j && !(j & 7)) { printf("\n");}
+ }
+}
+
+/***************************************************************************
+// Macro: PACK_*
+// Description: Packs 16bit signed data from blocks into either 8bit unsigned
+// intra data or 16bit signed correction data, both packed into
+// 32 bit integers.
+***************************************************************************/
+#define PACK_INTRA_DATA(d,b,n) \
+ do { \
+ char *dp = (char *)d; \
+ char *bp = (char *)b; \
+ int counter; \
+ for(counter = 0; counter < n; counter++) { \
+ *dp++ = *bp; \
+ bp += 2; \
+ } \
+ }while(0);
+
+#define PACK_CORR_DATA(d,b,n) \
+ memcpy(d,b,n); \
+ d = (uint *)((unsigned long)d + n);
+
+#define MARK_CORR_DATA(d,n) \
+ do { \
+ uint* q = (uint*)((unsigned long)d - n); \
+ while((unsigned long)q < (unsigned long)d) { \
+ *q++ += 0x00330033; \
+ } \
+ }while(0);
+
+#define MARK_INTRA_BLOCK(d) \
+ do { \
+ int q; \
+ for(q=0; q<16; q++) { \
+ d[q] += 0x33333333; \
+ } \
+ }while(0);
+
+/*
+ Used for DCT 1 when we need DCT 0. Instead
+ of reading from one block we read from two and
+ interlace.
+*/
+#define PACK_CORR_DATA_1to0(d,top,bottom) \
+ do { \
+ short *t = top,*b = bottom; \
+ PACK_CORR_DATA(d,t,16); \
+ t = (short *)((unsigned long)t + 16); \
+ PACK_CORR_DATA(d,b,16); \
+ b = (short *)((unsigned long)b + 16); \
+ PACK_CORR_DATA(d,t,16); \
+ t = (short *)((unsigned long)t + 16); \
+ PACK_CORR_DATA(d,b,16); \
+ b = (short *)((unsigned long)b + 16); \
+ PACK_CORR_DATA(d,t,16); \
+ t = (short *)((unsigned long)t + 16); \
+ PACK_CORR_DATA(d,b,16); \
+ b = (short *)((unsigned long)b + 16); \
+ PACK_CORR_DATA(d,t,16); \
+ t = (short *)((unsigned long)t + 16); \
+ PACK_CORR_DATA(d,b,16); \
+ b = (short *)((unsigned long)b + 16); \
+ }while(0);
+
+/* Used for DCT 0 when we need DCT 1. */
+#define PACK_CORR_DATA_0to1(d,top,bottom) \
+ do{ \
+ short *t = top,*b = bottom; \
+ PACK_CORR_DATA(d,t,16); \
+ t = (short *)((unsigned long)t + 32); \
+ PACK_CORR_DATA(d,t,16); \
+ t = (short *)((unsigned long)t + 32); \
+ PACK_CORR_DATA(d,t,16); \
+ t = (short *)((unsigned long)t + 32); \
+ PACK_CORR_DATA(d,t,16); \
+ t = (short *)((unsigned long)t + 32); \
+ PACK_CORR_DATA(d,b,16); \
+ b = (short *)((unsigned long)b + 32); \
+ PACK_CORR_DATA(d,b,16); \
+ b = (short *)((unsigned long)b + 32); \
+ PACK_CORR_DATA(d,b,16); \
+ b = (short *)((unsigned long)b + 32); \
+ PACK_CORR_DATA(d,b,16); \
+ b = (short *)((unsigned long)b + 32); \
+ }while(0);
+
+#define PACK_CORR_DATA_SHORT(d,block) \
+ do { \
+ short *b = block; \
+ PACK_CORR_DATA(d,b,16); \
+ b = (short *)((unsigned long)b + 32); \
+ PACK_CORR_DATA(d,b,16); \
+ b = (short *)((unsigned long)b + 32); \
+ PACK_CORR_DATA(d,b,16); \
+ b = (short *)((unsigned long)b + 32); \
+ PACK_CORR_DATA(d,b,16); \
+ b = (short *)((unsigned long)b + 32); \
+ }while(0);
+
+/* Lookup tables to speed common calculations */
+static unsigned int drps_table[] = {2<<6,3<<6};
+
+static unsigned int mvfs_table[] = {
+ 0x12,
+ 0x1a,
+ 0x13,
+ 0x1b
+};
+
+static unsigned int type_table[] = {
+ 0x1<<12, /* This is an error so make it Forward motion */
+ 0x1<<12,
+ 0x1<<12,
+ 0x1<<12,
+ 0x2<<12,
+ 0x2<<12,
+ 0x3<<12,
+ 0x3<<12,
+ 0x1<<12, /* Pattern but no Motion, Make motion Forward */
+ 0x1<<12,
+ 0x1<<12,
+ 0x1<<12,
+ 0x2<<12,
+ 0x2<<12,
+ 0x3<<12,
+ 0x3<<12
+};
+
+static unsigned int y_frame_bytes[] = {
+ 0,0,0,0,128,128,128,128,
+ 128,128,128,128,256,256,256,256,
+ 128,128,128,128,256,256,256,256,
+ 256,256,256,256,384,384,384,384,
+ 128,128,128,128,256,256,256,256,
+ 256,256,256,256,384,384,384,384,
+ 256,256,256,256,384,384,384,384,
+ 384,384,384,384,512,512,512,512
+};
+
+static unsigned int u_frame_bytes[] = {
+ 0,0,128,128,0,0,128,128,
+ 0,0,128,128,0,0,128,128,
+ 0,0,128,128,0,0,128,128,
+ 0,0,128,128,0,0,128,128,
+ 0,0,128,128,0,0,128,128,
+ 0,0,128,128,0,0,128,128,
+ 0,0,128,128,0,0,128,128,
+ 0,0,128,128,0,0,128,128
+};
+
+static unsigned int v_frame_bytes[] = {
+ 0,128,0,128,0,128,0,128,
+ 0,128,0,128,0,128,0,128,
+ 0,128,0,128,0,128,0,128,
+ 0,128,0,128,0,128,0,128,
+ 0,128,0,128,0,128,0,128,
+ 0,128,0,128,0,128,0,128,
+ 0,128,0,128,0,128,0,128,
+ 0,128,0,128,0,128,0,128
+};
+
+static unsigned int y_first_field_bytes[] = {
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 128,128,128,128,128,128,128,128,
+ 128,128,128,128,128,128,128,128,
+ 128,128,128,128,128,128,128,128,
+ 128,128,128,128,128,128,128,128,
+ 256,256,256,256,256,256,256,256,
+ 256,256,256,256,256,256,256,256
+};
+
+static unsigned int y_second_field_bytes[] = {
+ 0,0,0,0,128,128,128,128,
+ 128,128,128,128,256,256,256,256,
+ 0,0,0,0,128,128,128,128,
+ 128,128,128,128,256,256,256,256,
+ 0,0,0,0,128,128,128,128,
+ 128,128,128,128,256,256,256,256,
+ 0,0,0,0,128,128,128,128,
+ 128,128,128,128,256,256,256,256
+};
+
+static unsigned int y_dct0_field_bytes[] = {
+ 0,0,0,0,128,128,128,128,
+ 128,128,128,128,256,256,256,256,
+ 128,128,128,128,128,128,128,128,
+ 256,256,256,256,256,256,256,256,
+ 128,128,128,128,256,256,256,256,
+ 128,128,128,128,256,256,256,256,
+ 256,256,256,256,256,256,256,256,
+ 256,256,256,256,256,256,256,256
+};
+
+static unsigned int y_dct1_frame_bytes[] = {
+ 0,0,0,0,256,256,256,256,
+ 256,256,256,256,512,512,512,512,
+ 256,256,256,256,256,256,256,256,
+ 512,512,512,512,512,512,512,512,
+ 256,256,256,256,512,512,512,512,
+ 256,256,256,256,512,512,512,512,
+ 512,512,512,512,512,512,512,512,
+ 512,512,512,512,512,512,512,512
+};
+
+static unsigned int u_field_bytes[] = {
+ 0,0,64,64,0,0,64,64,
+ 0,0,64,64,0,0,64,64,
+ 0,0,64,64,0,0,64,64,
+ 0,0,64,64,0,0,64,64,
+ 0,0,64,64,0,0,64,64,
+ 0,0,64,64,0,0,64,64,
+ 0,0,64,64,0,0,64,64,
+ 0,0,64,64,0,0,64,64
+};
+
+static unsigned int v_field_bytes[] = {
+ 0,64,0,64,0,64,0,64,
+ 0,64,0,64,0,64,0,64,
+ 0,64,0,64,0,64,0,64,
+ 0,64,0,64,0,64,0,64,
+ 0,64,0,64,0,64,0,64,
+ 0,64,0,64,0,64,0,64,
+ 0,64,0,64,0,64,0,64,
+ 0,64,0,64,0,64,0,64
+};
+
+static short empty_block[] = {
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0
+};
+
+
+/***************************************************************************
+// Function: dispatchYContext
+// Description: Allocate a DMA buffer write the Y MC Context info in it,
+// and dispatch it to hardware.
+***************************************************************************/
+
+static __inline__ void dispatchYContext(i810XvMCSurface *privTarget,
+ i810XvMCSurface *privPast,
+ i810XvMCSurface *privFuture,
+ i810XvMCContext *pI810XvMC) {
+ uint *data;
+ drmBufPtr pDMA;
+ drm_i810_mc_t mc;
+
+ pDMA = i810_get_free_buffer(pI810XvMC);
+ data = pDMA->address;
+ *data++ = CMD_FLUSH;
+ *data++ = BOOLEAN_ENA_2;
+ *data++ = CMD_FLUSH;
+ *data++ = DEST_BUFFER_INFO;
+ *data++ = privTarget->dbi1y;
+ *data++ = DEST_BUFFER_VAR;
+ *data++ = privTarget->dbv1;
+ /* Past Surface */
+ *data++ = CMD_MAP_INFO;
+ *data++ = privPast->mi1y;
+ *data++ = privPast->mi2y;
+ *data++ = privPast->mi3y;
+ /* Future Surface */
+ *data++ = CMD_MAP_INFO;
+ *data++ = privFuture->mi1y | 0x1<<28;
+ *data++ = privFuture->mi2y;
+ *data++ = privFuture->mi3y;
+
+ mc.idx = pDMA->idx;
+ mc.used = (unsigned long)data - (unsigned long)pDMA->address;
+ mc.last_render = ++pI810XvMC->last_render;
+ privTarget->last_render = pI810XvMC->last_render;
+ I810_MC(pI810XvMC,mc);
+}
+
+static __inline__ void renderError(void) {
+ printf("Invalid Macroblock Parameters found.\n");
+ return;
+}
+
+/***************************************************************************
+// Function: renderIntrainFrame
+// Description: inline function that sets hardware parameters for an Intra
+// encoded macroblock in a Frame picture.
+***************************************************************************/
+static __inline__ void renderIntrainFrame(uint **datay,uint **datau,
+ uint **datav,
+ XvMCMacroBlock *mb,
+ short *block_ptr) {
+
+ register uint *dy = *datay;
+ register uint *du = *datau;
+ register uint *dv = *datav;
+
+ /* Y Blocks */
+ *dy++ = GFXBLOCK + 68;
+ *dy++ = (1<<30) | (3<<28) | (0xf<<24);
+ *dy++ = ((uint)mb->x<<20) | ((uint)mb->y<<4);
+ *dy++ = (16<<16) | 16;
+ *dy++ = 0;
+ *dy++ = 0;
+ PACK_INTRA_DATA(dy,block_ptr,256);
+ dy += 64;
+ block_ptr += 256;
+ /* End Y Blocks */
+
+ /* U Block */
+ *du++ = GFXBLOCK + 20;
+ *du++ = (2<<30) | (1<<28) | (1<<23);
+ *du++ = (((uint)mb->x)<<19) | (((uint)mb->y)<<3);
+ *du++ = (8<<16) | 8;
+ *du++ = 0;
+ *du++ = 0;
+ PACK_INTRA_DATA(du,block_ptr,64);
+ du += 16;
+ block_ptr += 64;
+
+ /* V Block */
+ *dv++ = GFXBLOCK + 20;
+ *dv++ = (3<<30) | (1<<28) | (1<<22);
+ *dv++ = (((uint)mb->x)<<19) | (((uint)mb->y)<<3);
+ *dv++ = (8<<16) | 8;
+ *dv++ = 0;
+ *dv++ = 0;
+ PACK_INTRA_DATA(dv,block_ptr,64);
+ dv += 16;
+ block_ptr += 64;
+
+ *datay = dy;
+ *datau = du;
+ *datav = dv;
+}
+
+/***************************************************************************
+// Function: renderIntrainFrameDCT1
+// Description: inline function that sets hardware parameters for an Intra
+// encoded macroblock in a Frame picture with DCT type 1.
+***************************************************************************/
+static __inline__ void renderIntrainFrameDCT1(uint **datay,uint **datau,
+ uint **datav,XvMCMacroBlock *mb,
+ short *block_ptr,uint flags) {
+
+ register uint *dy = *datay;
+ register uint *du = *datau;
+ register uint *dv = *datav;
+
+
+ /* Y Blocks */
+ *dy++ = GFXBLOCK + 36;
+ *dy++ = (1<<30) | (2<<28) | (0x3<<26) | (0x2<<6);
+ *dy++ = ((uint)mb->x<<20) | ((uint)mb->y<<3);
+ *dy++ = (8<<16) | 16;
+ *dy++ = 0;
+ *dy++ = 0;
+ PACK_INTRA_DATA(dy,block_ptr,128);
+ dy += 32;
+ block_ptr += 128;
+
+ /* Second Y block */
+ *dy++ = GFXBLOCK + 36;
+ *dy++ = (1<<30) | (2<<28) | (0x3<<26) | (0x3<<6);
+ *dy++ = ((uint)mb->x<<20) | ((uint)mb->y<<3);
+ *dy++ = (8<<16) | 16;
+ *dy++ = 0;
+ *dy++ = 0;
+ PACK_INTRA_DATA(dy,block_ptr,128);
+ dy += 32;
+ block_ptr += 128;
+ /* End Y Blocks */
+
+
+ /* U Block */
+ *du++ = GFXBLOCK + 20;
+ *du++ = (2<<30) | (1<<28) | (1<<23);
+ *du++ = (((uint)mb->x)<<19) | (((uint)mb->y)<<3);
+ *du++ = (8<<16) | 8;
+ *du++ = 0;
+ *du++ = 0;
+ PACK_INTRA_DATA(du,block_ptr,64);
+ du += 16;
+ block_ptr += 64;
+
+ /* V Block */
+ *dv++ = GFXBLOCK + 20;
+ *dv++ = (3<<30) | (1<<28) | (1<<22);
+ *dv++ = (((uint)mb->x)<<19) | (((uint)mb->y)<<3);
+ *dv++ = (8<<16) | 8;
+ *dv++ = 0;
+ *dv++ = 0;
+ PACK_INTRA_DATA(dv,block_ptr,64);
+ dv += 16;
+ block_ptr += 64;
+
+ *datay = dy;
+ *datau = du;
+ *datav = dv;
+}
+
+
+/***************************************************************************
+// Function: renderIntrainField
+// Description: inline function that sets hardware parameters for an Intra
+// encoded macroblock in Field pictures.
+***************************************************************************/
+static __inline__ void renderIntrainField(uint **datay,uint **datau,
+ uint **datav,
+ XvMCMacroBlock *mb,short *block_ptr,
+ uint ps) {
+
+ register uint *dy = *datay;
+ register uint *du = *datau;
+ register uint *dv = *datav;
+
+ uint xy = ((uint)mb->x<<20) | ((uint)mb->y<<4);
+ uint dw1 = drps_table[~ps & 0x1];
+
+ /* Y Blocks */
+ *dy++ = GFXBLOCK + 68;
+ *dy++ = (1<<30) | (3<<28) | (0xf<<24) | dw1;
+ *dy++ = xy;
+ *dy++ = (16<<16) | 16;
+ *dy++ = 0;
+ *dy++ = 0;
+ PACK_INTRA_DATA(dy,block_ptr,256);
+ dy += 64;
+ block_ptr += 256;
+ /* End Y Blocks */
+
+ xy >>= 1;
+
+ /* U Block */
+ *du++ = GFXBLOCK + 20;
+ *du++ = (2<<30) | (1<<28) | (1<<23) | dw1;
+ *du++ = xy;
+ *du++ = (8<<16) | 8;
+ *du++ = 0;
+ *du++ = 0;
+ PACK_INTRA_DATA(du,block_ptr,64);
+ du += 16;
+ block_ptr += 64;
+
+ /* V Block */
+ *dv++ = GFXBLOCK + 20;
+ *dv++ = (3<<30) | (1<<28) | (1<<22) | dw1;
+ *dv++ = xy;
+ *dv++ = (8<<16) | 8;
+ *dv++ = 0;
+ *dv++ = 0;
+ PACK_INTRA_DATA(dv,block_ptr,64);
+ dv += 16;
+ block_ptr += 64;
+
+ *datay = dy;
+ *datau = du;
+ *datav = dv;
+}
+
+
+/***************************************************************************
+// Function: renderFieldinField
+// Description: inline function that sets hardware parameters for a Field
+// encoded macroblock in a Field Picture.
+***************************************************************************/
+static __inline__ void renderFieldinField(uint **datay,uint **datau,
+ uint **datav,
+ XvMCMacroBlock *mb,short *block_ptr,
+ uint ps, uint flags) {
+
+ register uint *dy = *datay;
+ register uint *du = *datau;
+ register uint *dv = *datav;
+
+ /* Motion Vectors */
+ short fmv[2];
+ short bmv[2];
+ /* gfxblock dword 1 */
+ uint dw1;
+
+ uint parity = ~ps & XVMC_TOP_FIELD;
+
+ uint ysize = y_frame_bytes[mb->coded_block_pattern];
+ uint usize = u_frame_bytes[mb->coded_block_pattern];
+ uint vsize = v_frame_bytes[mb->coded_block_pattern];
+
+ uint xy = ((uint)mb->x<<20) | ((uint)mb->y<<4);
+
+ /* i810 Specific flag used to identify the second field in a P frame */
+ if(flags & 0x80000000) {
+ /* P Frame */
+ if((mb->motion_vertical_field_select & XVMC_SELECT_FIRST_FORWARD) ==
+ parity) {
+ /* Same parity, use reference field (map0) */
+ dw1 = 1<<12 | ((0x2 + parity)<<6) | ((0x2 + parity)<<3) |
+ (((uint)mb->coded_block_pattern)<<22);
+ fmv[0] = mb->PMV[0][0][1];
+ fmv[1] = mb->PMV[0][0][0];
+ bmv[0] = 0;
+ bmv[1] = 0;
+ }
+ else {
+ /*
+ Opposite parity, set up as if it were backward
+ motion and use map1.
+ */
+ dw1 = 2<<12 | ((0x2 + parity)<<6) | (0x3 - parity) |
+ (((uint)mb->coded_block_pattern)<<22);
+ bmv[0] = mb->PMV[0][0][1];
+ bmv[1] = mb->PMV[0][0][0];
+ fmv[0] = 0;
+ fmv[1] = 0;
+ }
+ }
+ else {
+ dw1 = type_table[mb->macroblock_type & 0xf] |
+ drps_table[~ps & 0x1] |
+ mvfs_table[mb->motion_vertical_field_select & 3] |
+ (((uint)mb->coded_block_pattern)<<22);
+
+ fmv[0] = mb->PMV[0][0][1];
+ fmv[1] = mb->PMV[0][0][0];
+
+ bmv[0] = mb->PMV[0][1][1];
+ bmv[1] = mb->PMV[0][1][0];
+ }
+
+ /* Y Block */
+ *dy++ = GFXBLOCK + 4 + (ysize>>2);
+ *dy++ = (1<<30) | (3<<28) | dw1;
+ *dy++ = xy;
+ *dy++ = (16<<16) | 16;
+ *dy++ = *(uint *)fmv;
+ *dy++ = *(uint *)bmv;
+ PACK_CORR_DATA(dy,block_ptr,ysize);
+ block_ptr = (short *)((unsigned long)block_ptr + ysize);
+ /* End Y Blocks */
+
+ fmv[0] /= 2;
+ fmv[1] /= 2;
+ bmv[0] /= 2;
+ bmv[1] /= 2;
+ xy >>= 1;
+
+ /* U Block */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1;
+ *du++ = xy;
+ *du++ = (8<<16) | 8;
+ *du++ = *(uint *)fmv;
+ *du++ = *(uint *)bmv;
+ PACK_CORR_DATA(du,block_ptr,usize);
+ block_ptr = (short *)((unsigned long)block_ptr + usize);
+
+ /* V Block */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1;
+ *dv++ = xy;
+ *dv++ = (8<<16) | 8;
+ *dv++ = *(uint *)fmv;
+ *dv++ = *(uint *)bmv;
+ PACK_CORR_DATA(dv,block_ptr,vsize);
+ block_ptr = (short *)((unsigned long)block_ptr + vsize);
+
+ *datay = dy;
+ *datau = du;
+ *datav = dv;
+}
+
+/***************************************************************************
+// Function: render16x8inField
+// Description: inline function that sets hardware parameters for a 16x8
+// encoded macroblock in a field picture.
+***************************************************************************/
+static __inline__ void render16x8inField(uint **datay,uint **datau,
+ uint **datav,
+ XvMCMacroBlock *mb,short *block_ptr,
+ uint ps, uint flags) {
+
+ register uint *dy = *datay;
+ register uint *du = *datau;
+ register uint *dv = *datav;
+
+ /* Motion Vectors */
+ short fmv[4];
+ short bmv[4];
+ /* gfxblock dword 1 */
+ uint dw1[2];
+
+ uint y1size = y_first_field_bytes[mb->coded_block_pattern];
+ uint y2size = y_second_field_bytes[mb->coded_block_pattern];
+ uint usize = u_field_bytes[mb->coded_block_pattern];
+ uint vsize = v_field_bytes[mb->coded_block_pattern];
+
+ uint parity = ~ps & XVMC_TOP_FIELD;
+
+ uint xy = ((uint)mb->x<<20) | ((uint)mb->y<<4);
+
+ /* i810 Specific flag used to identify the second field in a P frame */
+ if(flags & 0x80000000) {
+ /* P Frame */
+ if((mb->motion_vertical_field_select & XVMC_SELECT_FIRST_FORWARD) ==
+ parity) {
+ /* Same parity, use reference field (map0) */
+ dw1[0] = 1<<12 | ((0x2 + parity)<<6) | ((0x2 + parity)<<3) |
+ (((uint)mb->coded_block_pattern)<<22);
+
+ fmv[0] = mb->PMV[0][0][1];
+ fmv[1] = mb->PMV[0][0][0];
+ bmv[0] = 0;
+ bmv[1] = 0;
+ }
+ else {
+ /*
+ Opposite parity, set up as if it were backward
+ motion and use map1.
+ */
+ dw1[0] = 2<<12 | ((0x2 + parity)<<6) | (0x3 - parity) |
+ (((uint)mb->coded_block_pattern)<<22);
+
+ bmv[0] = mb->PMV[0][0][1];
+ bmv[1] = mb->PMV[0][0][0];
+ fmv[0] = 0;
+ fmv[1] = 0;
+ }
+ if((mb->motion_vertical_field_select & XVMC_SELECT_SECOND_FORWARD) ==
+ (parity<<2)) {
+ /* Same parity, use reference field (map0) */
+ dw1[1] = 1<<12 | ((0x2 + parity)<<6) | ((0x2 + parity)<<3) |
+ ((((uint)mb->coded_block_pattern<<22) & (0x3<<22)) |
+ (((uint)mb->coded_block_pattern<<24) & (0x3<<26)));
+
+ fmv[2] = mb->PMV[1][0][1];
+ fmv[3] = mb->PMV[1][0][0];
+ bmv[2] = 0;
+ bmv[3] = 0;
+ }
+ else {
+ /*
+ Opposite parity, set up as if it were backward
+ motion and use map1.
+ */
+ dw1[1] = 2<<12 | ((0x2 + parity)<<6) | (0x3 - parity) |
+ ((((uint)mb->coded_block_pattern<<22) & (0x3<<22)) |
+ (((uint)mb->coded_block_pattern<<24) & (0x3<<26)));
+
+ bmv[2] = mb->PMV[1][0][1];
+ bmv[3] = mb->PMV[1][0][0];
+ fmv[2] = 0;
+ fmv[3] = 0;
+ }
+ }
+ else {
+ dw1[0] = type_table[mb->macroblock_type & 0xf] |
+ drps_table[~ps & 0x1] |
+ mvfs_table[mb->motion_vertical_field_select & 3] |
+ (((uint)mb->coded_block_pattern)<<22);
+
+ dw1[1] = type_table[mb->macroblock_type & 0xf] |
+ drps_table[~ps & 0x1] |
+ mvfs_table[(mb->motion_vertical_field_select>>2) & 0x3] |
+ ((((uint)mb->coded_block_pattern<<22) & (0x3<<22)) |
+ (((uint)mb->coded_block_pattern<<24) & (0x3<<26)));
+
+ fmv[0] = mb->PMV[0][0][1];
+ fmv[1] = mb->PMV[0][0][0];
+ fmv[2] = mb->PMV[1][0][1];
+ fmv[3] = mb->PMV[1][0][0];
+
+ bmv[0] = mb->PMV[0][1][1];
+ bmv[1] = mb->PMV[0][1][0];
+ bmv[2] = mb->PMV[1][1][1];
+ bmv[3] = mb->PMV[1][1][0];
+ }
+
+ /* First Y Block */
+ *dy++ = GFXBLOCK + 4 + (y1size>>2);
+ *dy++ = (1<<30) | (2<<28) | dw1[0];
+ *dy++ = xy;
+ *dy++ = (8<<16) | 16;
+ *dy++ = *(uint *)fmv;
+ *dy++ = *(uint *)bmv;
+ PACK_CORR_DATA(dy,block_ptr,y1size);
+ block_ptr = (short *)((unsigned long)block_ptr + y1size);
+
+ /* Second Y Block */
+ *dy++ = GFXBLOCK + 4 + (y2size>>2);
+ *dy++ = (1<<30) | (2<<28) | dw1[1];
+ *dy++ = (xy + 8);
+ *dy++ = (8<<16) | 16;
+ *dy++ = *(uint *)&fmv[2];
+ *dy++ = *(uint *)&bmv[2];
+ PACK_CORR_DATA(dy,block_ptr,y2size);
+ block_ptr = (short *)((unsigned long)block_ptr + y2size);
+ /* End Y Blocks */
+
+ fmv[0] /= 2;
+ fmv[1] /= 2;
+ fmv[2] /= 2;
+ fmv[3] /= 2;
+
+ bmv[0] /= 2;
+ bmv[1] /= 2;
+ bmv[2] /= 2;
+ bmv[3] /= 2;
+
+ xy >>= 1;
+
+ /* U Blocks */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1[0];
+ *du++ = xy;
+ *du++ = (4<<16) | 8;
+ *du++ = *(uint *)fmv;
+ *du++ = *(uint *)bmv;
+ PACK_CORR_DATA(du,block_ptr,usize);
+ block_ptr = (short *)((unsigned long)block_ptr + usize);
+
+ /* Second U block */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1[1];
+ *du++ = (xy + 4);
+ *du++ = (4<<16) | 8;
+ *du++ = *(uint *)&fmv[2];
+ *du++ = *(uint *)&bmv[2];
+ PACK_CORR_DATA(du,block_ptr,usize);
+ block_ptr = (short *)((unsigned long)block_ptr + usize);
+ /* End U Blocks */
+
+ /* V Blocks */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1[0];
+ *dv++ = xy;
+ *dv++ = (4<<16) | 8;
+ *dv++ = *(uint *)fmv;
+ *dv++ = *(uint *)bmv;
+ PACK_CORR_DATA(dv,block_ptr,vsize);
+ block_ptr = (short *)((unsigned long)block_ptr + vsize);
+
+ /* Second V Block */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1[1];
+ *dv++ = (xy + 4);
+ *dv++ = (4<<16) | 8;
+ *dv++ = *(uint *)&fmv[2];
+ *dv++ = *(uint *)&bmv[2];
+ PACK_CORR_DATA(dv,block_ptr,vsize);
+ block_ptr = (short *)((unsigned long)block_ptr + vsize);
+ /* End V Blocks */
+
+ *datay = dy;
+ *datau = du;
+ *datav = dv;
+}
+
+/***************************************************************************
+// Function: renderDualPrimeinField
+// Description: inline function that sets hardware parameters for a Dual
+// prime encoded macroblock in a field picture.
+***************************************************************************/
+static __inline__ void renderDualPrimeinField(uint **datay,uint **datau,
+ uint **datav,XvMCMacroBlock *mb,
+ short *block_ptr,uint ps,
+ uint flags) {
+
+ register uint *dy = *datay;
+ register uint *du = *datau;
+ register uint *dv = *datav;
+
+ /* Motion Vectors */
+ short fmv[2];
+ short bmv[2];
+ /* gfxblock dword 1 */
+ uint dw1;
+
+
+ uint ysize = y_frame_bytes[mb->coded_block_pattern];
+ uint usize = u_frame_bytes[mb->coded_block_pattern];
+ uint vsize = v_frame_bytes[mb->coded_block_pattern];
+
+ uint xy = ((uint)mb->x<<20) | ((uint)mb->y<<4);
+
+
+ if(ps & XVMC_TOP_FIELD) {
+ dw1 = (mb->coded_block_pattern<<22) | 3<<12 | 2<<6 | 2<<3 | 3;
+ }
+ else {
+ dw1 = (mb->coded_block_pattern<<22) | 3<<12 | 3<<6 | 3<<3 | 2;
+ }
+ fmv[0] = mb->PMV[0][0][1];
+ fmv[1] = mb->PMV[0][0][0];
+ bmv[0] = mb->PMV[0][1][1];
+ bmv[1] = mb->PMV[0][1][0];
+
+ /* Y Block */
+ *dy++ = GFXBLOCK + 4 + (ysize>>2);
+ *dy++ = (1<<30) | (3<<28) | dw1;
+ *dy++ = xy;
+ *dy++ = (16<<16) | 16;
+ *dy++ = *(uint *)fmv;
+ *dy++ = *(uint *)bmv;
+ PACK_CORR_DATA(dy,block_ptr,ysize);
+ block_ptr = (short *)((unsigned long)block_ptr + ysize);
+ /* End Y Blocks */
+
+ fmv[0] /= 2;
+ fmv[1] /= 2;
+ bmv[0] /= 2;
+ bmv[1] /= 2;
+ xy >>= 1;
+
+ /* U Block */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1;
+ *du++ = xy;
+ *du++ = (8<<16) | 8;
+ *du++ = *(uint *)fmv;
+ *du++ = *(uint *)bmv;
+ PACK_CORR_DATA(du,block_ptr,usize);
+ block_ptr = (short *)((unsigned long)block_ptr + usize);
+
+ /* V Block */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1;
+ *dv++ = xy;
+ *dv++ = (8<<16) | 8;
+ *dv++ = *(uint *)fmv;
+ *dv++ = *(uint *)bmv;
+ PACK_CORR_DATA(dv,block_ptr,vsize);
+ block_ptr = (short *)((unsigned long)block_ptr + vsize);
+
+ *datay = dy;
+ *datau = du;
+ *datav = dv;
+}
+
+/***************************************************************************
+// Function: renderFieldinFrame
+// Description: inline function that sets hardware parameters for a Field
+// encoded macroblock in a frame picture.
+***************************************************************************/
+static __inline__ void renderFieldinFrame(uint **datay,uint **datau,
+ uint **datav,
+ XvMCMacroBlock *mb,short *block_ptr,
+ uint flags) {
+
+ register uint *dy = *datay;
+ register uint *du = *datau;
+ register uint *dv = *datav;
+
+ /* Motion Vectors */
+ short fmv[4];
+ short bmv[4];
+ /* gfxblock dword 1 */
+ uint dw1[2];
+
+ uint y1size = y_first_field_bytes[mb->coded_block_pattern];
+ uint y2size = y_second_field_bytes[mb->coded_block_pattern];
+ uint usize = u_field_bytes[mb->coded_block_pattern];
+ uint vsize = v_field_bytes[mb->coded_block_pattern];
+
+ uint xy = ((uint)mb->x<<20) | ((uint)mb->y<<3);
+
+ dw1[0] = type_table[mb->macroblock_type & 0xf] | (0x2<<6) |
+ mvfs_table[mb->motion_vertical_field_select & 3] |
+ (((uint)mb->coded_block_pattern)<<22);
+
+ dw1[1] = type_table[mb->macroblock_type & 0xf] | (0x3<<6) |
+ mvfs_table[mb->motion_vertical_field_select>>2] |
+ (((mb->coded_block_pattern & 0x3) |
+ ((mb->coded_block_pattern & 0xc)<<2))<<22);
+
+ fmv[0] = mb->PMV[0][0][1]/2;
+ fmv[1] = mb->PMV[0][0][0];
+ fmv[2] = mb->PMV[1][0][1]/2;
+ fmv[3] = mb->PMV[1][0][0];
+
+ bmv[0] = mb->PMV[0][1][1]/2;
+ bmv[1] = mb->PMV[0][1][0];
+ bmv[2] = mb->PMV[1][1][1]/2;
+ bmv[3] = mb->PMV[1][1][0];
+
+ /* First Y Block */
+ *dy++ = GFXBLOCK + 4 + (y1size>>2);
+ *dy++ = (1<<30) | (2<<28) | dw1[0];
+ *dy++ = xy;
+ *dy++ = (8<<16) | 16;
+ *dy++ = *(uint *)&fmv[0];
+ *dy++ = *(uint *)&bmv[0];
+ PACK_CORR_DATA(dy,block_ptr,y1size);
+ block_ptr = (short *)((unsigned long)block_ptr + y1size);
+
+ /* Second Y Block */
+ *dy++ = GFXBLOCK + 4 + (y2size>>2);
+ *dy++ = (1<<30) | (2<<28) | dw1[1];
+ *dy++ = xy;
+ *dy++ = (8<<16) | 16;
+ *dy++ = *(uint *)&fmv[2];
+ *dy++ = *(uint *)&bmv[2];
+ PACK_CORR_DATA(dy,block_ptr,y2size);
+ block_ptr = (short *)((unsigned long)block_ptr + y2size);
+ /* End Y Blocks */
+
+ fmv[0] /= 2;
+ fmv[1] /= 2;
+ fmv[2] /= 2;
+ fmv[3] /= 2;
+
+ bmv[0] /= 2;
+ bmv[1] /= 2;
+ bmv[2] /= 2;
+ bmv[3] /= 2;
+
+ xy >>= 1;
+
+ /* U Blocks */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1[0];
+ *du++ = xy;
+ *du++ = (4<<16) | 8;
+ *du++ = *(uint *)&fmv[0];
+ *du++ = *(uint *)&bmv[0];
+ if(usize) {
+ PACK_CORR_DATA_SHORT(du,block_ptr);
+ }
+
+ /* Second U Block */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1[1];
+ *du++ = xy;
+ *du++ = (4<<16) | 8;
+ *du++ = *(uint *)&fmv[2];
+ *du++ = *(uint *)&bmv[2];
+ if(usize) {
+ block_ptr = (short *)((unsigned long)block_ptr + 16);
+ PACK_CORR_DATA_SHORT(du,block_ptr);
+ block_ptr = (short *)((unsigned long)block_ptr + 112);
+ }
+ /* End U Blocks */
+
+ /* V Blocks */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1[0];
+ *dv++ = xy;
+ *dv++ = (4<<16) | 8;
+ *dv++ = *(uint *)&fmv[0];
+ *dv++ = *(uint *)&bmv[0];
+ if(vsize) {
+ PACK_CORR_DATA_SHORT(dv,block_ptr);
+ }
+
+ /* Second V Block */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1[1];
+ *dv++ = xy;
+ *dv++ = (4<<16) | 8;
+ *dv++ = *(uint *)&fmv[2];
+ *dv++ = *(uint *)&bmv[2];
+ if(vsize) {
+ block_ptr = (short *)((unsigned long)block_ptr + 16);
+ PACK_CORR_DATA_SHORT(dv,block_ptr);
+ block_ptr = (short *)((unsigned long)block_ptr + 112);
+ }
+ /* End V Blocks */
+
+ *datay = dy;
+ *datau = du;
+ *datav = dv;
+}
+
+/***************************************************************************
+// Function: renderFieldinFrameDCT0
+// Description: inline function that sets hardware parameters for a Field
+// encoded macroblock in a frame picture with DCT0.
+***************************************************************************/
+static __inline__ void renderFieldinFrameDCT0(uint **datay,uint **datau,
+ uint **datav,XvMCMacroBlock *mb,
+ short *block_ptr,uint flags) {
+
+ register uint *dy = *datay;
+ register uint *du = *datau;
+ register uint *dv = *datav;
+
+ /* Motion Vectors */
+ short fmv[4];
+ short bmv[4];
+ /* CBP */
+ uint cbp = (uint)mb->coded_block_pattern;
+ /* gfxblock dword 1 */
+ uint dw1[2];
+
+ short * top_left_b = NULL;
+ short * top_right_b = NULL;
+ short * bottom_left_b = NULL;
+ short * bottom_right_b = NULL;
+
+ unsigned int ysize = y_dct0_field_bytes[cbp];
+ unsigned int usize = u_field_bytes[cbp];
+ unsigned int vsize = v_field_bytes[cbp];
+
+ uint xy = ((uint)mb->x<<20) | ((uint)mb->y<<3);
+
+ dw1[0] = type_table[mb->macroblock_type & 0xf] | (0x2<<6) |
+ mvfs_table[mb->motion_vertical_field_select & 3] |
+ ((cbp | ((cbp<<2) & 0x30))<<22);
+
+ dw1[1] = type_table[mb->macroblock_type & 0xf] | (0x3<<6) |
+ mvfs_table[mb->motion_vertical_field_select>>2] |
+ ((cbp | ((cbp<<2) & 0x30))<<22);
+
+
+ fmv[0] = mb->PMV[0][0][1]/2;
+ fmv[1] = mb->PMV[0][0][0];
+ fmv[2] = mb->PMV[1][0][1]/2;
+ fmv[3] = mb->PMV[1][0][0];
+
+ bmv[0] = mb->PMV[0][1][1]/2;
+ bmv[1] = mb->PMV[0][1][0];
+ bmv[2] = mb->PMV[1][1][1]/2;
+ bmv[3] = mb->PMV[1][1][0];
+
+ /*
+ The i810 cannot use DCT0 directly with field motion, we have to
+ interlace the data for it. We use a zero block when the CBP has
+ one half of the to-be-interlaced data but not the other half.
+ */
+ top_left_b = &empty_block[0];
+ if(cbp & 0x20) {
+ top_left_b = block_ptr;
+ block_ptr += 64;
+ }
+
+ top_right_b = &empty_block[0];
+ if(cbp & 0x10) {
+ top_right_b = block_ptr;
+ block_ptr += 64;
+ }
+
+ bottom_left_b = &empty_block[0];
+ if(cbp & 0x8) {
+ bottom_left_b = block_ptr;
+ block_ptr += 64;
+ }
+
+ bottom_right_b = &empty_block[0];
+ if(cbp & 0x4) {
+ bottom_right_b = block_ptr;
+ block_ptr += 64;
+ }
+
+ /* First Y Block */
+ *dy++ = GFXBLOCK + 4 + (ysize>>2);
+ *dy++ = (1<<30) | (2<<28) | dw1[0];
+ *dy++ = xy;
+ *dy++ = (8<<16) | 16;
+ *dy++ = *(uint *)&fmv[0];
+ *dy++ = *(uint *)&bmv[0];
+ if(dw1[0] & (1<<27)) {
+ PACK_CORR_DATA_0to1(dy,top_left_b,bottom_left_b);
+ }
+ if(dw1[0] & (1<<26)) {
+ PACK_CORR_DATA_0to1(dy,top_right_b,bottom_right_b);
+ }
+
+ /* Second Y Block */
+ *dy++ = GFXBLOCK + 4 + (ysize>>2);
+ *dy++ = (1<<30) | (2<<28) | dw1[1];
+ *dy++ = xy;
+ *dy++ = (8<<16) | 16;
+ *dy++ = *(uint *)&fmv[2];
+ *dy++ = *(uint *)&bmv[2];
+ if(dw1[1] & (1<<27)) {
+ top_left_b = (short *)((unsigned long)top_left_b + 16);
+ bottom_left_b = (short *)((unsigned long)bottom_left_b + 16);
+ PACK_CORR_DATA_0to1(dy,top_left_b,bottom_left_b);
+ }
+ if(dw1[1] & (1<<26)) {
+ top_right_b = (short *)((unsigned long)top_right_b + 16);
+ bottom_right_b = (short *)((unsigned long)bottom_right_b + 16);
+ PACK_CORR_DATA_0to1(dy,top_right_b,bottom_right_b);
+ }
+ /* End Y Blocks */
+
+ fmv[0] /= 2;
+ fmv[1] /= 2;
+ fmv[2] /= 2;
+ fmv[3] /= 2;
+
+ bmv[0] /= 2;
+ bmv[1] /= 2;
+ bmv[2] /= 2;
+ bmv[3] /= 2;
+
+ xy >>= 1;
+
+ /* U Blocks */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1[0];
+ *du++ = xy;
+ *du++ = (4<<16) | 8;
+ *du++ = *(uint *)&fmv[0];
+ *du++ = *(uint *)&bmv[0];
+ if(usize) {
+ PACK_CORR_DATA_SHORT(du,block_ptr);
+ }
+
+ /* Second U Block */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1[1];
+ *du++ = xy;
+ *du++ = (4<<16) | 8;
+ *du++ = *(uint *)&fmv[2];
+ *du++ = *(uint *)&bmv[2];
+ if(usize) {
+ block_ptr = (short *)((unsigned long)block_ptr + 16);
+ PACK_CORR_DATA_SHORT(du,block_ptr);
+ block_ptr = (short *)((unsigned long)block_ptr + 112);
+ }
+ /* End U Blocks */
+
+ /* V Blocks */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1[0];
+ *dv++ = xy;
+ *dv++ = (4<<16) | 8;
+ *dv++ = *(uint *)&fmv[0];
+ *dv++ = *(uint *)&bmv[0];
+ if(vsize) {
+ PACK_CORR_DATA_SHORT(dv,block_ptr);
+ }
+
+ /* Second V Block */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1[1];
+ *dv++ = xy;
+ *dv++ = (4<<16) | 8;
+ *dv++ = *(uint *)&fmv[2];
+ *dv++ = *(uint *)&bmv[2];
+ if(vsize) {
+ block_ptr = (short *)((unsigned long)block_ptr + 16);
+ PACK_CORR_DATA_SHORT(dv,block_ptr);
+ block_ptr = (short *)((unsigned long)block_ptr + 112);
+ }
+ /* End V Blocks */
+
+ *datay = dy;
+ *datau = du;
+ *datav = dv;
+}
+
+/***************************************************************************
+// Function: renderFrameinFrame
+// Description: inline function that sets hardware parameters for a Frame
+// encoded macroblock in a frame picture.
+***************************************************************************/
+static __inline__ void renderFrameinFrame(uint **datay,uint **datau,
+ uint **datav,
+ XvMCMacroBlock *mb,short *block_ptr,
+ uint flags) {
+
+ register uint *dy = *datay;
+ register uint *du = *datau;
+ register uint *dv = *datav;
+
+ /* Motion Vectors */
+ short fmv[2];
+ short bmv[2];
+ /* gfxblock dword 1 */
+ uint dw1;
+
+ unsigned int ysize = y_frame_bytes[mb->coded_block_pattern];
+ unsigned int usize = u_frame_bytes[mb->coded_block_pattern];
+ unsigned int vsize = v_frame_bytes[mb->coded_block_pattern];
+
+ uint xy = ((uint)mb->x<<20) | ((uint)mb->y<<4);
+
+ dw1 = type_table[mb->macroblock_type & 0xf] |
+ (((uint)mb->coded_block_pattern)<<22);
+
+
+ fmv[0] = mb->PMV[0][0][1];
+ fmv[1] = mb->PMV[0][0][0];
+
+ bmv[0] = mb->PMV[0][1][1];
+ bmv[1] = mb->PMV[0][1][0];
+
+ /* Y Block */
+ *dy++ = GFXBLOCK + 4 + (ysize>>2);
+ *dy++ = (1<<30) | (3<<28) | dw1;
+ *dy++ = xy;
+ *dy++ = (16<<16) | 16;
+ *dy++ = *(uint *)fmv;
+ *dy++ = *(uint *)bmv;
+ PACK_CORR_DATA(dy,block_ptr,ysize);
+ block_ptr = (short *)((unsigned long)block_ptr + ysize);
+ /* End Y Blocks */
+
+ fmv[0] /= 2;
+ fmv[1] /= 2;
+
+ bmv[0] /= 2;
+ bmv[1] /= 2;
+
+ xy >>= 1;
+
+ /* U Block */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1;
+ *du++ = xy;
+ *du++ = (8<<16) | 8;
+ *du++ = *(uint *)fmv;
+ *du++ = *(uint *)bmv;
+ PACK_CORR_DATA(du,block_ptr,usize);
+ block_ptr = (short *)((unsigned long)block_ptr + usize);
+ /* End U Block */
+
+ /* V Block */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1;
+ *dv++ = xy;
+ *dv++ = (8<<16) | 8;
+ *dv++ = *(uint *)fmv;
+ *dv++ = *(uint *)bmv;
+ PACK_CORR_DATA(dv,block_ptr,vsize);
+ block_ptr = (short *)((unsigned long)block_ptr + vsize);
+ /* End V Block */
+
+ *datay = dy;
+ *datau = du;
+ *datav = dv;
+}
+
+/***************************************************************************
+// Function: renderFrameinFrameDCT1
+// Description: inline function that sets hardware parameters for a Frame
+// encoded macroblock in a frame picture with DCT type 1.
+***************************************************************************/
+static __inline__ void renderFrameinFrameDCT1(uint **datay,uint **datau,
+ uint **datav,XvMCMacroBlock *mb,
+ short *block_ptr,uint flags) {
+
+ register uint *dy = *datay;
+ register uint *du = *datau;
+ register uint *dv = *datav;
+
+ /* Motion Vectors */
+ short fmv[4];
+ short bmv[4];
+
+ short * top_left_b = NULL;
+ short * top_right_b = NULL;
+ short * bottom_left_b = NULL;
+ short * bottom_right_b = NULL;
+
+ uint temp_bp = 0;
+
+ uint ysize = y_dct1_frame_bytes[mb->coded_block_pattern];
+ uint usize = u_frame_bytes[mb->coded_block_pattern];
+ uint vsize = v_frame_bytes[mb->coded_block_pattern];
+
+ uint xy = ((uint)mb->x<<20) | ((uint)mb->y<<4);
+
+ uint dw1 = type_table[mb->macroblock_type & 0xf] |
+ (((uint)mb->coded_block_pattern)<<22);
+
+ fmv[0] = mb->PMV[0][0][1];
+ fmv[1] = mb->PMV[0][0][0];
+
+ bmv[0] = mb->PMV[0][1][1];
+ bmv[1] = mb->PMV[0][1][0];
+
+ /*
+ It is easiest to find out what blocks are in need of reading first
+ rather than as we go.
+ */
+ top_left_b = &empty_block[0];
+ if(dw1 & (1<<27)) {
+ temp_bp |= (1<<25);
+ top_left_b = block_ptr;
+ block_ptr += 64;
+ }
+
+ top_right_b = &empty_block[0];
+ if(dw1 & (1<<26)) {
+ temp_bp |= (1<<24);
+ top_right_b = block_ptr;
+ block_ptr += 64;
+ }
+
+ bottom_left_b = &empty_block[0];
+ if(dw1 & (1<<25)) {
+ temp_bp |= (1<<27);
+ bottom_left_b = block_ptr;
+ block_ptr += 64;
+ }
+
+ bottom_right_b = &empty_block[0];
+ if(dw1 & (1<<24)) {
+ temp_bp |= (1<<26);
+ bottom_right_b = block_ptr;
+ block_ptr += 64;
+ }
+ dw1 |= temp_bp;
+
+ /* Y Block */
+ *dy++ = GFXBLOCK + 4 + (ysize>>2);
+ *dy++ = (1<<30) | (3<<28) | dw1;
+ *dy++ = xy;
+ *dy++ = (16<<16) | 16;
+ *dy++ = *(uint *)fmv;
+ *dy++ = *(uint *)bmv;
+ if(dw1 & (1<<27)) {
+ PACK_CORR_DATA_1to0(dy,top_left_b,bottom_left_b);
+ top_left_b = (short *)((unsigned long)top_left_b + 64);
+ bottom_left_b = (short *)((unsigned long)bottom_left_b + 64);
+ }
+ if(dw1 & (1<<26)) {
+ PACK_CORR_DATA_1to0(dy,top_right_b,bottom_right_b);
+ top_right_b = (short *)((unsigned long)top_right_b + 64);
+ bottom_right_b = (short *)((unsigned long)bottom_right_b + 64);
+ }
+ if(dw1 & (1<<27)) {
+ PACK_CORR_DATA_1to0(dy,top_left_b,bottom_left_b);
+ }
+ if(dw1 & (1<<26)) {
+ PACK_CORR_DATA_1to0(dy,top_right_b,bottom_right_b);
+ }
+ /* End Y Block */
+
+ fmv[0] /= 2;
+ fmv[1] /= 2;
+
+ bmv[0] /= 2;
+ bmv[1] /= 2;
+
+ xy >>= 1;
+
+ /* U Block */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1;
+ *du++ = xy;
+ *du++ = (8<<16) | 8;
+ *du++ = *(uint *)fmv;
+ *du++ = *(uint *)bmv;
+ PACK_CORR_DATA(du,block_ptr,usize);
+ block_ptr = (short *)((unsigned long)block_ptr + usize);
+
+ /* V Block */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1;
+ *dv++ = xy;
+ *dv++ = (8<<16) | 8;
+ *dv++ = *(uint *)fmv;
+ *dv++ = *(uint *)bmv;
+ PACK_CORR_DATA(dv,block_ptr,vsize);
+ block_ptr = (short *)((unsigned long)block_ptr + vsize);
+
+ *datay = dy;
+ *datau = du;
+ *datav = dv;
+}
+
+/***************************************************************************
+// Function: renderDualPrimeinFrame
+// Description: inline function that sets hardware parameters for a Dual
+// Prime encoded macroblock in a frame picture with dct 1.
+***************************************************************************/
+static __inline__ void renderDualPrimeinFrame(uint **datay,uint **datau,
+ uint **datav,XvMCMacroBlock *mb,
+ short *block_ptr,uint flags) {
+
+ register uint *dy = *datay;
+ register uint *du = *datau;
+ register uint *dv = *datav;
+
+ /* Motion Vectors */
+ short fmv[4];
+ short bmv[4];
+ /* gfxblock dword 1 */
+ uint dw1[2];
+
+ uint y1size = y_first_field_bytes[mb->coded_block_pattern];
+ uint y2size = y_second_field_bytes[mb->coded_block_pattern];
+ uint usize = u_field_bytes[mb->coded_block_pattern];
+ uint vsize = v_field_bytes[mb->coded_block_pattern];
+
+ uint xy = ((uint)mb->x<<20) | ((uint)mb->y<<3);
+
+ /*
+ Past Surface (map 0) is used for same parity prediction,
+ Future surface (map 1) is used for opposite.
+ */
+ dw1[0] = (((uint)mb->coded_block_pattern)<<22) |
+ 3<<12 | 2<<6 | 2<<3 | 3;
+ dw1[1] = (((mb->coded_block_pattern & 0x3) |
+ ((mb->coded_block_pattern & 0xc)<<2))<<22) |
+ 3<<12 | 3<<6 | 3<<3 | 2;
+
+ fmv[0] = mb->PMV[0][0][1];
+ fmv[1] = mb->PMV[0][0][0];
+ bmv[0] = mb->PMV[1][0][1];
+ bmv[1] = mb->PMV[1][0][0];
+
+ fmv[2] = mb->PMV[0][0][1];
+ fmv[3] = mb->PMV[0][0][0];
+ bmv[2] = mb->PMV[1][1][1];
+ bmv[3] = mb->PMV[1][1][0];
+
+ /* First Y Block */
+ *dy++ = GFXBLOCK + 4 + (y1size>>2);
+ *dy++ = (1<<30) | (2<<28) | dw1[0];
+ *dy++ = xy;
+ *dy++ = (8<<16) | 16;
+ *dy++ = *(uint *)fmv;
+ *dy++ = *(uint *)bmv;;
+ PACK_CORR_DATA(dy,block_ptr,y1size);
+ block_ptr = (short *)((unsigned long)block_ptr + y1size);
+
+ /* Second Y Block */
+ *dy++ = GFXBLOCK + 4 + (y2size>>2);
+ *dy++ = (1<<30) | (2<<28) | dw1[1];
+ *dy++ = xy;
+ *dy++ = (8<<16) | 16;
+ *dy++ = *(uint *)&fmv[2];
+ *dy++ = *(uint *)&bmv[2];
+ PACK_CORR_DATA(dy,block_ptr,y2size);
+ block_ptr = (short *)((unsigned long)block_ptr + y2size);
+
+ fmv[0] /= 2;
+ fmv[1] /= 2;
+ bmv[0] /= 2;
+ bmv[1] /= 2;
+
+ fmv[2] /= 2;
+ fmv[3] /= 2;
+ bmv[2] /= 2;
+ bmv[3] /= 2;
+
+ xy >>= 1;
+
+ /* U Blocks */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1[0];
+ *du++ = xy;
+ *du++ = (4<<16) | 8;
+ *du++ = *(uint *)fmv;
+ *du++ = *(uint *)bmv;
+ if(dw1[0] & (1<<23)) {
+ PACK_CORR_DATA_SHORT(du,block_ptr);
+ }
+
+ /* Second U Block */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1[1];
+ *du++ = xy;
+ *du++ = (4<<16) | 8;
+ *du++ = *(uint *)&fmv[2];
+ *du++ = *(uint *)&bmv[2];
+ if(dw1[1] & (1<<23)) {
+ block_ptr = (short *)((unsigned long)block_ptr + 16);
+ PACK_CORR_DATA_SHORT(du,block_ptr);
+ block_ptr = (short *)((unsigned long)block_ptr + 112);
+ }
+ /* End U Blocks */
+
+ /* V Blocks */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1[0];
+ *dv++ = xy;
+ *dv++ = (4<<16) | 8;
+ *dv++ = *(uint *)fmv;
+ *dv++ = *(uint *)bmv;
+ if(dw1[0] & (1<<22)) {
+ PACK_CORR_DATA_SHORT(dv,block_ptr);
+ }
+
+ /* Second V Block */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1[1];
+ *dv++ = xy;
+ *dv++ = (4<<16) | 8;
+ *dv++ = *(uint *)&fmv[2];
+ *dv++ = *(uint *)&bmv[2];
+ if(dw1[1] & (1<<22)) {
+ block_ptr = (short *)((unsigned long)block_ptr + 16);
+ PACK_CORR_DATA_SHORT(dv,block_ptr);
+ block_ptr = (short *)((unsigned long)block_ptr + 112);
+ }
+ /* End V Blocks */
+
+ *datay = dy;
+ *datau = du;
+ *datav = dv;
+}
+
+/***************************************************************************
+// Function: renderDualPrimeinFrameDCT0
+// Description: inline function that sets hardware parameters for a Dual
+// Prime encoded macroblock in a frame picture with dct 0.
+***************************************************************************/
+static __inline__ void renderDualPrimeinFrameDCT0(uint **datay,uint **datau,
+ uint **datav,
+ XvMCMacroBlock *mb,
+ short *block_ptr,
+ uint flags) {
+
+ register uint *dy = *datay;
+ register uint *du = *datau;
+ register uint *dv = *datav;
+
+ /* Motion Vectors */
+ short fmv[4];
+ short bmv[4];
+ /* gfxblock dword 1 */
+ uint dw1[2];
+
+ short * top_left_b = NULL;
+ short * top_right_b = NULL;
+ short * bottom_left_b = NULL;
+ short * bottom_right_b = NULL;
+
+ uint cbp = (uint)mb->coded_block_pattern;
+
+ uint ysize = y_dct0_field_bytes[cbp];
+ uint usize = u_field_bytes[cbp];
+ uint vsize = v_field_bytes[cbp];
+
+ uint xy = ((uint)mb->x<<20) | ((uint)mb->y<<3);
+
+ /*
+ Past Surface (map 0) is used for same parity prediction,
+ Future surface (map 1) is used for opposite.
+ */
+ dw1[0] = ((cbp | ((cbp<<2) & 0x30))<<22) |
+ 3<<12 | 2<<6 | 2<<3 | 3;
+ dw1[1] = ((cbp | ((cbp<<2) & 0x30))<<22) |
+ 3<<12 | 3<<6 | 3<<3 | 2;
+
+ fmv[0] = mb->PMV[0][0][1];
+ fmv[1] = mb->PMV[0][0][0];
+ bmv[0] = mb->PMV[1][0][1];
+ bmv[1] = mb->PMV[1][0][0];
+
+ fmv[2] = mb->PMV[0][0][1];
+ fmv[3] = mb->PMV[0][0][0];
+ bmv[2] = mb->PMV[1][1][1];
+ bmv[3] = mb->PMV[1][1][0];
+
+ /*
+ The i810 cannot use DCT0 directly with field motion, we have to
+ interlace the data for it. We use a zero block when the CBP has
+ one half of the to-be-interlaced data but not the other half.
+ */
+ top_left_b = &empty_block[0];
+ if(cbp & 0x20) {
+ top_left_b = block_ptr;
+ block_ptr += 64;
+ }
+
+ top_right_b = &empty_block[0];
+ if(cbp & 0x10) {
+ top_right_b = block_ptr;
+ block_ptr += 64;
+ }
+
+ bottom_left_b = &empty_block[0];
+ if(cbp & 0x8) {
+ bottom_left_b = block_ptr;
+ block_ptr += 64;
+ }
+
+ bottom_right_b = &empty_block[0];
+ if(cbp & 0x4) {
+ bottom_right_b = block_ptr;
+ block_ptr += 64;
+ }
+
+ /* First Y Block */
+ *dy++ = GFXBLOCK + 4 + (ysize>>2);
+ *dy++ = (1<<30) | (2<<28) | dw1[0];
+ *dy++ = xy;
+ *dy++ = (8<<16) | 16;
+ *dy++ = *(uint *)fmv;
+ *dy++ = *(uint *)bmv;
+ if(cbp & 0x20) {
+ PACK_CORR_DATA_0to1(dy,top_left_b,bottom_left_b);
+ }
+ if(cbp & 0x10) {
+ PACK_CORR_DATA_0to1(dy,top_right_b,bottom_right_b);
+ }
+
+ /* Second Y Block */
+ *dy++ = GFXBLOCK + 4 + (ysize>>2);
+ *dy++ = (1<<30) | (2<<28) | dw1[1];
+ *dy++ = xy;
+ *dy++ = (8<<16) | 16;
+ *dy++ = *(uint *)&fmv[2];
+ *dy++ = *(uint *)&bmv[2];
+ if(cbp & 0x20) {
+ top_left_b = (short *)((unsigned long)top_left_b + 16);
+ bottom_left_b = (short *)((unsigned long)bottom_left_b + 16);
+ PACK_CORR_DATA_0to1(dy,top_left_b,bottom_left_b);
+ }
+ if(cbp & 0x10) {
+ top_right_b = (short *)((unsigned long)top_right_b + 16);
+ bottom_right_b = (short *)((unsigned long)bottom_right_b + 16);
+ PACK_CORR_DATA_0to1(dy,top_right_b,bottom_right_b);
+ }
+ /* End Y Blocks */
+
+
+ fmv[0] /= 2;
+ fmv[1] /= 2;
+ bmv[0] /= 2;
+ bmv[1] /= 2;
+
+ fmv[2] /= 2;
+ fmv[3] /= 2;
+ bmv[2] /= 2;
+ bmv[3] /= 2;
+
+ xy >>= 1;
+
+ /* U Blocks */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1[0];
+ *du++ = xy;
+ *du++ = (4<<16) | 8;
+ *du++ = *(uint *)fmv;
+ *du++ = *(uint *)bmv;
+ if(cbp & (1<<23)) {
+ PACK_CORR_DATA_SHORT(du,block_ptr);
+ }
+
+ /* Second U Block */
+ *du++ = GFXBLOCK + 4 + (usize>>2);
+ *du++ = (2<<30) | (1<<28) | dw1[1];
+ *du++ = xy;
+ *du++ = (4<<16) | 8;
+ *du++ = *(uint *)&fmv[2];
+ *du++ = *(uint *)&bmv[2];
+ if(cbp & (1<<23)) {
+ block_ptr = (short *)((unsigned long)block_ptr + 16);
+ PACK_CORR_DATA_SHORT(du,block_ptr);
+ block_ptr = (short *)((unsigned long)block_ptr + 112);
+ }
+ /* End U Blocks */
+
+ /* V Blocks */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1[0];
+ *dv++ = xy;
+ *dv++ = (4<<16) | 8;
+ *dv++ = *(uint *)fmv;
+ *dv++ = *(uint *)bmv;
+ if(cbp & (1<<22)) {
+ PACK_CORR_DATA_SHORT(dv,block_ptr);
+ }
+
+ /* Second V Block */
+ *dv++ = GFXBLOCK + 4 + (vsize>>2);
+ *dv++ = (3<<30) | (1<<28) | dw1[1];
+ *dv++ = xy;
+ *dv++ = (4<<16) | 8;
+ *dv++ = *(uint *)&fmv[2];
+ *dv++ = *(uint *)&bmv[2];
+ if(cbp & (1<<22)) {
+ block_ptr = (short *)((unsigned long)block_ptr + 16);
+ PACK_CORR_DATA_SHORT(dv,block_ptr);
+ block_ptr = (short *)((unsigned long)block_ptr + 112);
+ }
+ /* End V Blocks */
+
+ *datay = dy;
+ *datau = du;
+ *datav = dv;
+}
+
+
+/***************************************************************************
+// Function: XvMCRenderSurface
+// Description: This function does the actual HWMC. Given a list of
+// macroblock structures it dispatched the hardware commands to execute
+// them. DMA buffer containing Y data are dispatched as they fill up
+// U and V DMA buffers are queued until all Y's are done. This minimizes
+// the context flipping and flushing required when switching between Y
+// U and V surfaces.
+***************************************************************************/
+#define UV_QUEUE 14
+Status XvMCRenderSurface(Display *display, XvMCContext *context,
+ unsigned int picture_structure,
+ XvMCSurface *target_surface,
+ XvMCSurface *past_surface,
+ XvMCSurface *future_surface,
+ unsigned int flags,
+ unsigned int num_macroblocks,
+ unsigned int first_macroblock,
+ XvMCMacroBlockArray *macroblock_array,
+ XvMCBlockArray *blocks) {
+ /* Dma Data Structures */
+ drmBufPtr pDMAy = NULL,pDMAu[UV_QUEUE],pDMAv[UV_QUEUE];
+ int u_index = 0,v_index = 0;
+ int dirty_context = 1;
+
+ /* Block Pointer */
+ short *block_ptr;
+ /* Current Macroblock Pointer */
+ XvMCMacroBlock *mb;
+
+ drm_i810_mc_t mc;
+ int i,j;
+ i810XvMCSurface *privTarget;
+ i810XvMCSurface *privFuture = NULL;
+ i810XvMCSurface *privPast = NULL;
+ i810XvMCContext *pI810XvMC;
+
+ /* DMA Pointers set to NULL */
+ uint *datay = NULL;
+ uint *datau = NULL;
+ uint *datav = NULL;
+
+
+ /* Check Parameters for validity */
+ if((target_surface == NULL) || (context == NULL) || (display == NULL)) {
+ printf("Error, Invalid Target,Context, or DIsplay!\n");
+ return BadValue;
+ }
+
+ if(num_macroblocks == 0) {return Success;}
+ if((macroblock_array == NULL) || (blocks == NULL)) {return BadValue;}
+ if(context->privData == NULL) {return BadValue;}
+ pI810XvMC = (i810XvMCContext *)context->privData;
+
+
+ if(target_surface->privData == NULL) {
+ printf("Error, Invalid Target Surface!\n");
+ return BadValue;
+ }
+ privTarget = (i810XvMCSurface *)target_surface->privData;
+
+ if(macroblock_array->num_blocks < (num_macroblocks + first_macroblock)) {
+ printf("Error, Too many macroblocks requested for MB array size.\n");
+ return BadValue;
+ }
+
+ /* Test For YV12 Surface */
+ if(context->surface_type_id != FOURCC_YV12) {
+ printf("Error, HWMC only possible on YV12 Surfaces\n");
+ return BadValue;
+ }
+
+ /* P Frame Test */
+ if(past_surface == NULL) {
+ /* Just to avoid some ifs later. */
+ privPast = privTarget;
+ }
+ else {
+ if(past_surface->privData == NULL) {
+ printf("Error, Invalid Past Surface!\n");
+ return BadValue;
+ }
+ privPast = (i810XvMCSurface *)past_surface->privData;
+ }
+
+
+ /* B Frame Test */
+ if(future_surface == NULL) {
+ privFuture = privTarget;
+ if(pI810XvMC->dual_prime) {
+ privFuture = privPast;
+ /* I810 Specific flag for marking when dual prime is in use. */
+ flags |= 0x40000000;
+ }
+
+ /*
+ References are different for the Second Field Picture. The
+ i810 needs to know if it is the second field picture in a
+ P picture. We use a Private flag to mark this.
+ */
+ if(flags & XVMC_SECOND_FIELD) {
+ /* I810 Specific flag for marking second fields. */
+ flags |= 0x80000000;
+ }
+ }
+ else {
+ if((future_surface->privData == NULL) || (past_surface == NULL)) {
+ printf("Error, Invalid Future Surface or No Past Surface!\n");
+ return BadValue;
+ }
+ privFuture = (i810XvMCSurface *)future_surface->privData;
+
+ /*
+ Undo Second Field flag since the second field in B frames is just like
+ the first.
+ */
+ flags &= ~0x80000000;
+ }
+
+ /* Lock For DMA */
+ I810_LOCK(pI810XvMC,0);
+
+ for(i=first_macroblock; i<(num_macroblocks + first_macroblock); i++) {
+ /* Set up values needed for each macroblock */
+ mb = &macroblock_array->macro_blocks[i];
+ block_ptr = &(blocks->blocks[mb->index<<6]);
+
+ /* Lockup can happen if the coordinates are too far out of range */
+ if(mb->x > target_surface->width>>4) {
+ mb->x = 0;
+ }
+ if(mb->y > target_surface->height>>4) {
+ mb->y = 0;
+ }
+
+ /* If buffers are almost full dispatch them */
+ if(datay) {
+ pDMAy->used = (unsigned long)datay - (unsigned long)pDMAy->address;
+ if(pDMAy->used > 3520) {
+ if(dirty_context) {
+ dispatchYContext(privTarget,privPast,privFuture,pI810XvMC);
+ }
+ dirty_context = 0;
+ mc.idx = pDMAy->idx;
+ mc.used = pDMAy->used;
+ datay = NULL;
+ mc.last_render = ++pI810XvMC->last_render;
+ privTarget->last_render = pI810XvMC->last_render;
+ I810_MC(pI810XvMC,mc);
+ } /* datay near full */
+ } /* if(datay) */
+ if(datau) {
+ pDMAu[u_index]->used = (unsigned long)datau - (unsigned long)pDMAu[u_index]->address;
+ if(pDMAu[u_index]->used > 3904) {
+ u_index++;
+ datau = NULL;
+ if(u_index == UV_QUEUE) {
+ for(j=0; j<UV_QUEUE; j++) {
+ mc.idx = pDMAu[j]->idx;
+ mc.used = pDMAu[j]->used;
+ mc.last_render = ++pI810XvMC->last_render;
+ privTarget->last_render = pI810XvMC->last_render;
+ I810_MC(pI810XvMC,mc);
+ }
+ u_index = 0;
+ dirty_context = 1;
+ } /* if(u_index == UV_QUEUE) */
+ } /* datau near full */
+ } /* if(datau) */
+ if(datav) {
+ pDMAv[v_index]->used = (unsigned long)datav - (unsigned long)pDMAv[v_index]->address;
+ if(pDMAv[v_index]->used > 3904) {
+ v_index++;
+ datav = NULL;
+ if(v_index == UV_QUEUE) {
+ for(j=0; j<UV_QUEUE; j++) {
+ mc.idx = pDMAv[j]->idx;
+ mc.used = pDMAv[j]->used;
+ mc.last_render = ++pI810XvMC->last_render;
+ privTarget->last_render = pI810XvMC->last_render;
+ I810_MC(pI810XvMC,mc);
+ }
+ v_index = 0;
+ dirty_context = 1;
+ } /* if(v_index == UV_QUEUE) */
+ } /* datav near full */
+ } /* if(datav) */
+
+ /* Allocate buffers if this is the first loop,or if we just dispatched */
+ if(datay == NULL) {
+ pDMAy = i810_get_free_buffer(pI810XvMC);
+ datay = pDMAy->address;
+ }/* if(datay == NULL) */
+ if(datau == NULL) {
+ pDMAu[u_index] = i810_get_free_buffer(pI810XvMC);
+ datau = pDMAu[u_index]->address;
+ if(u_index == 0) {
+ *datau++ = CMD_FLUSH;
+ *datau++ = BOOLEAN_ENA_2;
+ *datau++ = CMD_FLUSH;
+ *datau++ = DEST_BUFFER_INFO;
+ *datau++ = privTarget->dbi1u;
+ *datau++ = DEST_BUFFER_VAR;
+ *datau++ = privTarget->dbv1;
+ /* Past Surface */
+ *datau++ = CMD_MAP_INFO;
+ *datau++ = privPast->mi1u;
+ *datau++ = privPast->mi2u;
+ *datau++ = privPast->mi3u;
+ /* Future Surface */
+ *datau++ = CMD_MAP_INFO;
+ *datau++ = privFuture->mi1u | 0x1<<28;
+ *datau++ = privFuture->mi2u;
+ *datau++ = privFuture->mi3u;
+ }
+ } /* if(datau == NULL) */
+ if(datav == NULL) {
+ pDMAv[v_index] = i810_get_free_buffer(pI810XvMC);
+ datav = pDMAv[v_index]->address;
+ if(v_index == 0) {
+ *datav++ = CMD_FLUSH;
+ *datav++ = BOOLEAN_ENA_2;
+ *datav++ = CMD_FLUSH;
+ *datav++ = DEST_BUFFER_INFO;
+ *datav++ = privTarget->dbi1v;
+ *datav++ = DEST_BUFFER_VAR;
+ *datav++ = privTarget->dbv1;
+ /* Past Surface */
+ *datav++ = CMD_MAP_INFO;
+ *datav++ = privPast->mi1v;
+ *datav++ = privPast->mi2v;
+ *datav++ = privPast->mi3v;
+ /* Future Surface */
+ *datav++ = CMD_MAP_INFO;
+ *datav++ = privFuture->mi1v | 0x1<<28;
+ *datav++ = privFuture->mi2v;
+ *datav++ = privFuture->mi3v;
+ }
+ }/* if(datav == NULL) */
+
+ /* Catch no pattern case */
+ if(!(mb->macroblock_type & 0x8)) {
+ mb->coded_block_pattern = 0;
+ }
+
+
+ if(mb->motion_type == XVMC_PREDICTION_DUAL_PRIME) {
+ /*
+ By default the maps will not be set up for dual
+ prime. We have to change them.
+ */
+ if(!pI810XvMC->dual_prime) {
+ pI810XvMC->dual_prime = 1;
+ privFuture = privPast;
+ /* Y */
+ *datay++ = CMD_MAP_INFO;
+ *datay++ = privFuture->mi1y | 0x1<<28;
+ *datay++ = privFuture->mi2y;
+ *datay++ = privFuture->mi3y;
+ /* U */
+ *datau++ = CMD_MAP_INFO;
+ *datau++ = privFuture->mi1u | 0x1<<28;
+ *datau++ = privFuture->mi2u;
+ *datau++ = privFuture->mi3u;
+ /* V */
+ *datav++ = CMD_MAP_INFO;
+ *datav++ = privFuture->mi1v | 0x1<<28;
+ *datav++ = privFuture->mi2v;
+ *datav++ = privFuture->mi3v;
+ }
+ }
+ if((pI810XvMC->dual_prime) &&
+ (mb->motion_type != XVMC_PREDICTION_DUAL_PRIME)) {
+ pI810XvMC->dual_prime = 0;
+ privFuture = privTarget;
+ /* Y */
+ *datay++ = CMD_MAP_INFO;
+ *datay++ = privFuture->mi1y | 0x1<<28;
+ *datay++ = privFuture->mi2y;
+ *datay++ = privFuture->mi3y;
+ /* U */
+ *datau++ = CMD_MAP_INFO;
+ *datau++ = privFuture->mi1u | 0x1<<28;
+ *datau++ = privFuture->mi2u;
+ *datau++ = privFuture->mi3u;
+ /* V */
+ *datav++ = CMD_MAP_INFO;
+ *datav++ = privFuture->mi1v | 0x1<<28;
+ *datav++ = privFuture->mi2v;
+ *datav++ = privFuture->mi3v;
+ }
+
+
+ /* Frame Picture */
+ if((picture_structure & XVMC_FRAME_PICTURE) == XVMC_FRAME_PICTURE) {
+ /* Intra Blocks */
+ if(mb->macroblock_type & XVMC_MB_TYPE_INTRA) {
+ if(mb->dct_type) {
+ renderIntrainFrameDCT1(&datay,&datau,&datav,mb,block_ptr,flags);
+ continue;
+ }
+ renderIntrainFrame(&datay,&datau,&datav,mb,block_ptr);
+ continue;
+ }
+ switch((mb->motion_type & 0x3) | (mb->dct_type<<2)) {
+ case 0x2: /* Frame DCT0 */
+ renderFrameinFrame(&datay,&datau,&datav,mb,block_ptr,flags);
+ continue;
+ case 0x5: /* Field DCT1 */
+ renderFieldinFrame(&datay,&datau,&datav,mb,block_ptr,flags);
+ continue;
+ case 0x6: /* Frame DCT1 */
+ renderFrameinFrameDCT1(&datay,&datau,&datav,mb,block_ptr,flags);
+ continue;
+ case 0x1: /* Field DCT0 */
+ renderFieldinFrameDCT0(&datay,&datau,&datav,mb,block_ptr,flags);
+ continue;
+ case 0x3: /* Dual Prime DCT0 */
+ renderDualPrimeinFrame(&datay,&datau,&datav,mb,block_ptr,flags);
+ continue;
+ case 0x7: /* Dual Prime DCT1 */
+ renderDualPrimeinFrameDCT0(&datay,&datau,&datav,mb,block_ptr,flags);
+ continue;
+ default: /* No Motion Type */
+ renderError();
+ continue;
+ } /* Switch */
+ } /* Frame Picture */
+
+ /* Field Pictures */
+ if(mb->macroblock_type & XVMC_MB_TYPE_INTRA) {
+ renderIntrainField(&datay,&datau,&datav,mb,block_ptr,picture_structure);
+ continue;
+ }
+ switch(mb->motion_type & 0x3) {
+ case 0x1: /* Field Motion */
+ renderFieldinField(&datay,&datau,&datav,mb,block_ptr,picture_structure,
+ flags);
+ continue;
+ case 0x2: /* 16x8 Motion */
+ render16x8inField(&datay,&datau,&datav,mb,block_ptr,picture_structure,
+ flags);
+ continue;
+ case 0x3: /* Dual Prime */
+ renderDualPrimeinField(&datay,&datau,&datav,mb,block_ptr,
+ picture_structure,flags);
+ continue;
+ default: /* No Motion Type */
+ renderError();
+ continue;
+ }
+ continue;
+
+ } /* for each Macroblock */
+
+ /* Dispatch remaining DMA buffers */
+ if(dirty_context) {
+ dispatchYContext(privTarget,privPast,privFuture,pI810XvMC);
+ }
+ mc.idx = pDMAy->idx;
+ mc.used = (unsigned long)datay - (unsigned long)pDMAy->address;
+ mc.last_render = ++pI810XvMC->last_render;
+ privTarget->last_render = pI810XvMC->last_render;
+ I810_MC(pI810XvMC,mc);
+
+ pDMAu[u_index]->used = (unsigned long)datau - (unsigned long)pDMAu[u_index]->address;
+ for(j=0; j<=u_index; j++) {
+ mc.idx = pDMAu[j]->idx;
+ mc.used = pDMAu[j]->used;
+ mc.last_render = ++pI810XvMC->last_render;
+ privTarget->last_render = pI810XvMC->last_render;
+ I810_MC(pI810XvMC,mc);
+ }
+ pDMAv[v_index]->used = (unsigned long)datav - (unsigned long)pDMAv[v_index]->address;
+ for(j=0; j<=v_index; j++) {
+ mc.idx = pDMAv[j]->idx;
+ mc.used = pDMAv[j]->used;
+ mc.last_render = ++pI810XvMC->last_render;
+ privTarget->last_render = pI810XvMC->last_render;
+ I810_MC(pI810XvMC,mc);
+ }
+
+ I810_UNLOCK(pI810XvMC);
+
+ return Success;
+}
+
+/***************************************************************************
+// Function: XvMCPutSurface
+// Description:
+// Arguments:
+// display: Connection to X server
+// surface: Surface to be displayed
+// draw: X Drawable on which to display the surface
+// srcx: X coordinate of the top left corner of the region to be
+// displayed within the surface.
+// srcy: Y coordinate of the top left corner of the region to be
+// displayed within the surface.
+// srcw: Width of the region to be displayed.
+// srch: Height of the region to be displayed.
+// destx: X cordinate of the top left corner of the destination region
+// in the drawable coordinates.
+// desty: Y cordinate of the top left corner of the destination region
+// in the drawable coordinates.
+// destw: Width of the destination region.
+// desth: Height of the destination region.
+// flags: One or more of the following.
+// XVMC_TOP_FIELD - Display only the Top field of the surface.
+// XVMC_BOTTOM_FIELD - Display only the Bottom Field of the surface.
+// XVMC_FRAME_PICTURE - Display both fields or frame.
+//
+// Info: Portions of this function derived from i810_video.c (XFree86)
+//
+// This function is organized so that we wait as long as possible before
+// touching the overlay registers. Since we don't know that the last
+// flip has happened yet we want to give the overlay as long as
+// possible to catch up before we have to check on its progress. This
+// makes it unlikely that we have to wait on the last flip.
+***************************************************************************/
+Status XvMCPutSurface(Display *display,XvMCSurface *surface,
+ Drawable draw, short srcx, short srcy,
+ unsigned short srcw, unsigned short srch,
+ short destx, short desty,
+ unsigned short destw, unsigned short desth,
+ int flags) {
+ i810XvMCContext *pI810XvMC;
+ i810XvMCSurface *pI810Surface;
+ i810OverlayRecPtr pORegs;
+ unsigned int ysrc_offset,uvsrc_offset;
+ Box extents;
+ uint window_width,window_height;
+ unsigned int xscaleInt = 0,xscaleFract = 0,yscaleInt = 0,yscaleFract = 0;
+ unsigned int xscaleFractUV = 0,xscaleIntUV = 0,yscaleFractUV = 0;
+ unsigned int yscaleIntUV = 0,yPitch = 0,uvPitch = 0;
+ unsigned int ovcmd = 0;
+ uint d;
+ double xscale,yscale;
+ int diff;
+ int clipped_srcx, clipped_srcy, clipped_destx, clipped_desty;
+ int clipped_srcw, clipped_srch, clipped_destw, clipped_desth;
+ uint x1,y1,root_width,root_height;
+ int x2 = 0, y2 = 0,unused;
+ uint nChilds;
+ int stat;
+ Window win,root,parent,*pChilds;
+
+
+ if((display == NULL) || (surface == NULL)) {
+ return BadValue;
+ }
+
+ if(surface->privData == NULL) {
+ return (error_base + XvMCBadSurface);
+ }
+ pI810Surface = (i810XvMCSurface *)surface->privData;
+ pI810XvMC = (i810XvMCContext *)pI810Surface->privContext;
+ pORegs = (i810OverlayRecPtr)pI810XvMC->oregs;
+
+
+ switch(surface->surface_type_id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ yPitch = (srcw + 7) & ~7;
+ uvPitch = ((srcw>>1) + 7) & ~7;
+ if((flags & XVMC_FRAME_PICTURE) != XVMC_FRAME_PICTURE) {
+ srch = srch>>1;
+ }
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ /* FIXME: Non Planar not fully implemented. */
+ return BadValue;
+ yPitch = ((srcw + 7) & ~7) << 1;
+ break;
+ }/* switch(surface->surface_type_id) */
+
+ /*
+ FIXME: This should be using the DRI's clip rect but that isn't
+ all hooked up yet. This has some latency but we get by.
+ */
+ win = draw;
+ XQueryTree(display,win,&root,&parent,&pChilds,&nChilds);
+ if(nChilds) XFree(pChilds);
+ XGetGeometry(display,win, &root, &x2, &y2, &window_width,
+ &window_height, &d, &d);
+ x1 = x2;
+ y1 = y2;
+ win = parent;
+ do {
+ XQueryTree(display,win,&root,&parent,&pChilds,&nChilds);
+ if(nChilds) XFree(pChilds);
+ XGetGeometry(display,win, &root, &x2, &y2, &d, &d, &d, &d);
+ x1 += x2;
+ y1 += y2;
+ win = parent;
+ }while(win != root);
+ XGetGeometry(display,root, &root, &unused, &unused,
+ &root_width, &root_height, &d, &d);
+
+ /* Left edge of Video window clipped to screen */
+ extents.x1 = 0;
+ if(x1 > extents.x1) {
+ extents.x1 = x1;
+ }
+ /* Right edge of Video window clipped to screen */
+ extents.x2 = root_width;
+ if(extents.x2 > (x1 + window_width)) {
+ extents.x2 = x1 + window_width;
+ }
+ /* Top edge of Video window clipped to screen */
+ extents.y1 = 0;
+ if(y1 > extents.y1) {
+ extents.y1 = y1;
+ }
+ /* Bottom edge of Video window clipped to screen */
+ extents.y2 = root_height;
+ if(extents.y2 > (y1 + window_height)) {
+ extents.y2 = y1 + window_height;
+ }
+
+ /*
+ Clipping is more difficult than is seems. We need to keep the
+ scaling factors even if the destination window needs to be clipped.
+ We clip the destination window first then apply a scaled version
+ to the source window.
+ */
+
+ /* Put destination coords in screen coords */
+ destx += x1;
+ desty += y1;
+
+ /* Scale factors requested */
+ xscale = (double)srcw / (double)destw;
+ yscale = (double)srch / (double)desth;
+
+ /*
+ If destination window needs to be clipped we actually adjust both
+ the src and dest window so as to keep the scaling that was requested
+ */
+ clipped_srcx = srcx;
+ clipped_srcy = srcy;
+ clipped_destx = destx;
+ clipped_desty = desty;
+ clipped_srcw = srcw;
+ clipped_srch = srch;
+ clipped_destw = destw;
+ clipped_desth = desth;
+
+ /* Clip to the source surface boundaries */
+ if(clipped_srcx < 0) {
+ clipped_destx += (0 - clipped_srcx) / xscale;
+ clipped_srcw -= clipped_srcx;
+ clipped_destw -= clipped_srcx / xscale;
+ clipped_srcx = 0;
+ }
+ if((clipped_srcw + clipped_srcx) > surface->width) {
+ clipped_srcw = surface->width - clipped_srcx;
+ clipped_destw -= (clipped_srcw - srcw) / xscale;
+ }
+ if(clipped_srcy < 0) {
+ clipped_desty += (0 - clipped_srcy) / yscale;
+ clipped_srch -= clipped_srcy;
+ clipped_desth -= clipped_srcy / yscale;
+ clipped_srcy = 0;
+ }
+ if((clipped_srch + clipped_srcy) > surface->height) {
+ clipped_srch = surface->height - clipped_srcy;
+ clipped_desth -= (clipped_srch - srch) / yscale;
+ }
+
+ /* Clip to the extents */
+ if(clipped_destx < extents.x1) {
+ diff = extents.x1 - clipped_destx;
+ clipped_srcx += diff * xscale;
+ clipped_srcw -= diff * xscale;
+ clipped_destw -= diff;
+ clipped_destx = extents.x1;
+ }
+
+ diff = (clipped_destx + clipped_destw) - extents.x2;
+ if(diff > 0) {
+ clipped_destw -= diff;
+ clipped_srcw -= diff * xscale;
+ }
+
+ if(clipped_desty < extents.y1) {
+ diff = extents.y1 - clipped_desty;
+ clipped_srcy += diff * yscale;
+ clipped_srch -= diff * yscale;
+ clipped_desth -= diff;
+ clipped_desty = 0;
+ }
+
+ diff = (clipped_desty + clipped_desth) - extents.y2;
+ if(diff > 0) {
+ clipped_desth -= diff;
+ clipped_srch -= diff * yscale;
+ }
+
+ /* If the whole window is clipped turn off the overlay */
+ if((clipped_destx + clipped_destw < extents.x1) ||
+ (clipped_desty + clipped_desth < extents.y1) ||
+ (clipped_destx > extents.x2) ||
+ (clipped_desty > extents.y2)) {
+ return XvMCHideSurface(display, surface);
+ }
+
+ /*
+ Adjust the source offset width and height according to the clipped
+ destination window.
+ */
+ ysrc_offset = ((clipped_srcx + 1) & ~1) +
+ ((clipped_srcy + 1) & ~1) * (1<<pI810Surface->pitch);
+ uvsrc_offset = (clipped_srcx>>1) +
+ (clipped_srcy>>1) * (1<<(pI810Surface->pitch - 1));
+
+ /*
+ Initially, YCbCr and Overlay Enable and
+ vertical chrominance up interpolation and horozontal chrominance
+ up interpolation
+ */
+ ovcmd = VC_UP_INTERPOLATION | HC_UP_INTERPOLATION |
+ Y_ADJUST | OVERLAY_ENABLE;
+
+ if ((clipped_destw != clipped_srcw) ||
+ (clipped_desth != clipped_srch)) {
+ xscaleInt = (clipped_srcw / clipped_destw) & 0x3;
+ xscaleFract = (clipped_srcw << 12) / clipped_destw;
+ yscaleInt = (clipped_srch / clipped_desth) & 0x3;
+ yscaleFract = (clipped_srch << 12) / clipped_desth;
+
+ if (clipped_destw > clipped_srcw) {
+ /* horizontal up-scaling */
+ ovcmd &= ~HORIZONTAL_CHROMINANCE_FILTER;
+ ovcmd &= ~HORIZONTAL_LUMINANCE_FILTER;
+ ovcmd |= (HC_UP_INTERPOLATION | HL_UP_INTERPOLATION);
+ }
+
+ if (clipped_desth > clipped_srch) {
+ /* vertical up-scaling */
+ ovcmd &= ~VERTICAL_CHROMINANCE_FILTER;
+ ovcmd &= ~VERTICAL_LUMINANCE_FILTER;
+ ovcmd |= (VC_UP_INTERPOLATION | VL_UP_INTERPOLATION);
+ }
+
+ if (clipped_destw < clipped_srcw) {
+ /* horizontal down-scaling */
+ ovcmd &= ~HORIZONTAL_CHROMINANCE_FILTER;
+ ovcmd &= ~HORIZONTAL_LUMINANCE_FILTER;
+ ovcmd |= (HC_DOWN_INTERPOLATION | HL_DOWN_INTERPOLATION);
+ }
+
+ if (clipped_desth < clipped_srch) {
+ /* vertical down-scaling */
+ ovcmd &= ~VERTICAL_CHROMINANCE_FILTER;
+ ovcmd &= ~VERTICAL_LUMINANCE_FILTER;
+ ovcmd |= (VC_DOWN_INTERPOLATION | VL_DOWN_INTERPOLATION);
+ }
+
+ /* now calculate the UV scaling factor */
+ if (xscaleFract) {
+ xscaleFractUV = xscaleFract >> MINUV_SCALE;
+ ovcmd &= ~HC_DOWN_INTERPOLATION;
+ ovcmd |= HC_UP_INTERPOLATION;
+ }
+
+ if (xscaleInt) {
+ xscaleIntUV = xscaleInt >> MINUV_SCALE;
+ if (xscaleIntUV) {
+ ovcmd &= ~HC_UP_INTERPOLATION;
+ }
+ }
+
+ if (yscaleFract) {
+ yscaleFractUV = yscaleFract >> MINUV_SCALE;
+ ovcmd &= ~VC_DOWN_INTERPOLATION;
+ ovcmd |= VC_UP_INTERPOLATION;
+ }
+
+ if (yscaleInt) {
+ yscaleIntUV = yscaleInt >> MINUV_SCALE;
+ if (yscaleIntUV) {
+ ovcmd &= ~VC_UP_INTERPOLATION;
+ ovcmd |= VC_DOWN_INTERPOLATION;
+ }
+ }
+
+ }/* if((destw != srcw) || (desth != srch)) */
+
+ /* Lock the DRM */
+ I810_LOCK(pI810XvMC,0);
+
+ /* Block until rendering on this surface is finished */
+ stat = XVMC_RENDERING;
+ while(stat & XVMC_RENDERING) {
+ XvMCGetSurfaceStatus(display,surface,&stat);
+ }
+ /* Block until the last flip is finished */
+ if(pI810XvMC->last_flip) {
+ BLOCK_OVERLAY(pI810XvMC,pI810XvMC->current);
+ }
+
+ pI810XvMC->current = !pI810XvMC->current;
+ pORegs->OV0CMD = ovcmd;
+
+ if ((clipped_destw != clipped_srcw) ||
+ (clipped_desth != clipped_srch)) {
+ pORegs->YRGBSCALE = (xscaleInt << 15) |
+ ((xscaleFract & 0xFFF) << 3) | (yscaleInt) |
+ ((yscaleFract & 0xFFF) << 20);
+
+ pORegs->UVSCALE = yscaleIntUV | ((xscaleFractUV & 0xFFF) << 3) |
+ ((yscaleFractUV & 0xFFF) << 20);
+ }
+ else {
+ /* Normal 1:1 scaling */
+ pORegs->YRGBSCALE = 0x80004000;
+ pORegs->UVSCALE = 0x80004000;
+ }
+
+ pORegs->SHEIGHT = clipped_srch | (clipped_srch << 15);
+ pORegs->DWINPOS = (clipped_desty << 16) | clipped_destx;
+ pORegs->DWINSZ = ((clipped_desth<< 16) | (clipped_destw));
+
+ /* Attributes */
+ pORegs->OV0CLRC0 = ((pI810XvMC->contrast & 0x1ff)<<8) |
+ (pI810XvMC->brightness & 0xff);
+ pORegs->OV0CLRC1 = (pI810XvMC->saturation & 0x3ff);
+
+ /* Destination Colorkey Setup */
+ pI810XvMC->oregs->DCLRKV = RGB16ToColorKey(pI810XvMC->colorkey);
+
+ /* buffer locations, add the offset from the clipping */
+ if(pI810XvMC->current) {
+ pORegs->OBUF_1Y = (unsigned long)pI810Surface->offset +
+ (unsigned long)pI810Surface->offsets[0] + ysrc_offset;
+ pORegs->OBUF_1V = (unsigned long)pI810Surface->offset +
+ (unsigned long)pI810Surface->offsets[2] + uvsrc_offset;
+ pORegs->OBUF_1U = (unsigned long)pI810Surface->offset +
+ (unsigned long)pI810Surface->offsets[1] + uvsrc_offset;
+ }
+ else {
+ pORegs->OBUF_0Y = (unsigned long)pI810Surface->offset +
+ (unsigned long)pI810Surface->offsets[0] + ysrc_offset;
+ pORegs->OBUF_0V = (unsigned long)pI810Surface->offset +
+ (unsigned long)pI810Surface->offsets[2] + uvsrc_offset;
+ pORegs->OBUF_0U = (unsigned long)pI810Surface->offset +
+ (unsigned long)pI810Surface->offsets[1] + uvsrc_offset;
+ }
+
+ switch(surface->surface_type_id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ pORegs->SWID = (uvPitch << 16) | yPitch;
+ pORegs->SWIDQW = (uvPitch << 13) | (yPitch >> 3);
+ pORegs->OV0STRIDE = (1<<pI810Surface->pitch) |
+ ((1<<pI810Surface->pitch) << 15);
+ pORegs->OV0CMD &= ~SOURCE_FORMAT;
+ pORegs->OV0CMD |= YUV_420;
+ if((flags & XVMC_FRAME_PICTURE) != XVMC_FRAME_PICTURE) {
+ /* Top Field Only */
+ if(flags & XVMC_TOP_FIELD) {
+ if(pI810XvMC->current == 1) {
+ pORegs->OV0CMD |= (VERTICAL_PHASE_BOTH | FLIP_TYPE_FIELD |
+ BUFFER1_FIELD0);
+ }
+ else {
+ pORegs->OV0CMD |= (VERTICAL_PHASE_BOTH | FLIP_TYPE_FIELD |
+ BUFFER0_FIELD0);
+ }
+ pORegs->YRGB_VPH = 1<<15 | 1<<31;
+ pORegs->UV_VPH = 3<<14 | 3<<30;
+ pORegs->INIT_PH = 0x06 | 0x18;
+ }
+ /* Bottom Field Only */
+ else {
+ if(pI810XvMC->current == 1) {
+ pORegs->OV0CMD |= (VERTICAL_PHASE_BOTH | FLIP_TYPE_FIELD |
+ BUFFER1_FIELD1);
+ }
+ else {
+ pORegs->OV0CMD |= (VERTICAL_PHASE_BOTH | FLIP_TYPE_FIELD |
+ BUFFER0_FIELD1);
+ }
+ pORegs->YRGB_VPH = 0;
+ pORegs->UV_VPH = 7<<29 | 7<<13;
+ pORegs->INIT_PH = 0x06;
+ }
+ }
+ /* Frame Picture */
+ else {
+ if(pI810XvMC->current == 1) {
+ pORegs->OV0CMD |= BUFFER1_FIELD0;
+ }
+ else {
+ pORegs->OV0CMD |= BUFFER0_FIELD0;
+ }
+ pORegs->YRGB_VPH = 0;
+ pORegs->UV_VPH = 0;
+ pORegs->INIT_PH = 0;
+ }
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ pORegs->SWID = srcw;
+ pORegs->SWIDQW = srcw >> 3;
+ pORegs->OV0STRIDE = pI810Surface->pitch;
+ pORegs->OV0CMD &= ~SOURCE_FORMAT;
+ pORegs->OV0CMD |= YUV_422;
+ pORegs->OV0CMD &= ~OV_BYTE_ORDER;
+ if (surface->surface_type_id == FOURCC_UYVY) {
+ pORegs->OV0CMD |= Y_SWAP;
+ }
+
+ pORegs->OV0CMD &= ~BUFFER_AND_FIELD;
+ if(pI810XvMC->current == 1) {
+ pORegs->OV0CMD |= BUFFER1_FIELD0;
+ }
+ else {
+ pORegs->OV0CMD |= BUFFER0_FIELD0;
+ }
+
+ break;
+ } /* switch(surface->surface_type_id) */
+
+
+
+ OVERLAY_FLIP(pI810XvMC);
+
+ /*
+ The Overlay only flips when it knows you changed
+ something. So the first time change stuff while it
+ is watching to be sure.
+ */
+ if(!pI810XvMC->last_flip) {
+ pORegs->OV0CMD &= ~0x4;
+ if(pI810XvMC->current == 1) {
+ pORegs->OV0CMD |= BUFFER1_FIELD0;
+ }
+ else {
+ pORegs->OV0CMD |= BUFFER0_FIELD0;
+ }
+ }
+ pI810Surface->last_flip = ++pI810XvMC->last_flip;
+ I810_UNLOCK(pI810XvMC);
+
+ return Success;
+}
+
+/***************************************************************************
+// Function: XvMCSyncSurface
+// Arguments:
+// display - Connection to the X server
+// surface - The surface to synchronize
+// Info:
+// Returns: Status
+***************************************************************************/
+Status XvMCSyncSurface(Display *display,XvMCSurface *surface) {
+ Status ret;
+ int stat=0;
+ /*
+ FIXME: Perhaps a timer here to prevent lockup?
+ FIXME: Perhaps a usleep to not be busy waiting?
+ */
+ do {
+ ret = XvMCGetSurfaceStatus(display,surface,&stat);
+ }while(!ret && (stat & XVMC_RENDERING));
+ return ret;
+}
+
+/***************************************************************************
+// Function: XvMCFlushSurface
+// Description:
+// This function commits pending rendering requests to ensure that they
+// wll be completed in a finite amount of time.
+// Arguments:
+// display - Connection to X server
+// surface - Surface to flush
+// Info:
+// This command is a noop for i810 becuase we always dispatch buffers in
+// render. There is little gain to be had with 4k buffers.
+// Returns: Status
+***************************************************************************/
+Status XvMCFlushSurface(Display * display, XvMCSurface *surface) {
+ return Success;
+}
+
+/***************************************************************************
+// Function: XvMCGetSurfaceStatus
+// Description:
+// Arguments:
+// display: connection to X server
+// surface: The surface to query
+// stat: One of the Following
+// XVMC_RENDERING - The last XvMCRenderSurface command has not
+// completed.
+// XVMC_DISPLAYING - The surface is currently being displayed or a
+// display is pending.
+***************************************************************************/
+Status XvMCGetSurfaceStatus(Display *display, XvMCSurface *surface,
+ int *stat) {
+ i810XvMCSurface *privSurface;
+ i810XvMCContext *pI810XvMC;
+ int temp;
+
+ if((display == NULL) || (surface == NULL) || (stat == NULL)) {
+ return BadValue;
+ }
+ if(surface->privData == NULL) {
+ return BadValue;
+ }
+ *stat = 0;
+ privSurface = surface->privData;
+
+ pI810XvMC = privSurface->privContext;
+ if(pI810XvMC == NULL) {
+ return (error_base + XvMCBadSurface);
+ }
+
+ I810_LOCK(pI810XvMC,0);
+ if(privSurface->last_flip) {
+ /* This can not happen */
+ if(pI810XvMC->last_flip < privSurface->last_flip) {
+ printf("Error: Context last flip is less than surface last flip.\n");
+ return BadValue;
+ }
+ /*
+ If the context has 2 or more flips after this surface it
+ cannot be displaying. Don't bother to check.
+ */
+ if(!(pI810XvMC->last_flip > (privSurface->last_flip + 1))) {
+ /*
+ If this surface was the last flipped it is either displaying
+ or about to be so don't bother checking.
+ */
+ if(pI810XvMC->last_flip == privSurface->last_flip) {
+ *stat |= XVMC_DISPLAYING;
+ }
+ else {
+ /*
+ In this case there has been one more flip since our surface's
+ but we need to check if it is finished or not.
+ */
+ temp = GET_FSTATUS(pI810XvMC);
+ if(((temp & (1<<20))>>20) != pI810XvMC->current) {
+ *stat |= XVMC_DISPLAYING;
+ }
+ }
+ }
+ }
+
+ if(privSurface->last_render &&
+ (privSurface->last_render > GET_RSTATUS(pI810XvMC))) {
+ *stat |= XVMC_RENDERING;
+ }
+ I810_UNLOCK(pI810XvMC);
+
+ return Success;
+}
+
+/***************************************************************************
+//
+// Surface manipulation functions
+//
+***************************************************************************/
+
+/***************************************************************************
+// Function: XvMCHideSurface
+// Description: Stops the display of a surface.
+// Arguments:
+// display - Connection to the X server.
+// surface - surface to be hidden.
+//
+// Returns: Status
+***************************************************************************/
+Status XvMCHideSurface(Display *display, XvMCSurface *surface) {
+ i810XvMCSurface *pI810Surface;
+ i810XvMCContext *pI810XvMC;
+ int ss, xx;
+
+ /* Did we get a good display and surface passed into us? */
+ if(display == NULL) {
+ return BadValue;
+ }
+
+ if(surface == NULL) {
+ return (error_base + XvMCBadSurface);
+ }
+
+ XvMCSyncSurface(display, surface);
+
+ /* Get surface private data pointer */
+ if(surface->privData == NULL) {
+ return (error_base + XvMCBadSurface);
+ }
+ pI810Surface = (i810XvMCSurface *)surface->privData;
+
+ /*
+ Get the status of the surface, if it is not currently displayed
+ we don't need to worry about it.
+ */
+ if((xx = XvMCGetSurfaceStatus(display, surface, &ss)) != Success) {
+ return xx;
+ }
+ if(! (ss & XVMC_DISPLAYING)) {
+ return Success;
+ }
+
+ /* Get the associated context pointer */
+ pI810XvMC = (i810XvMCContext *)pI810Surface->privContext;
+ if(pI810XvMC == NULL) {
+ return (error_base + XvMCBadSurface);
+ }
+
+ if(pI810XvMC->last_flip) {
+ I810_LOCK(pI810XvMC,DRM_LOCK_QUIESCENT);
+
+ /* Make sure last flip is done */
+ BLOCK_OVERLAY(pI810XvMC,pI810XvMC->current);
+
+ /* Set the registers to turn the overlay off */
+ pI810XvMC->oregs->OV0CMD = VC_UP_INTERPOLATION | HC_UP_INTERPOLATION |
+ Y_ADJUST;
+ pI810XvMC->current = !pI810XvMC->current;
+ if(pI810XvMC->current == 1) {
+ pI810XvMC->oregs->OV0CMD |= BUFFER1_FIELD0;
+ }
+ else {
+ pI810XvMC->oregs->OV0CMD |= BUFFER0_FIELD0;
+ }
+ OVERLAY_FLIP(pI810XvMC);
+ /*
+ Increment the context flip but not the surface. This way no
+ surface has the last flip #.
+ */
+ pI810XvMC->last_flip++;
+
+
+ /* Now wait until the hardware reads the registers and makes the change. */
+ BLOCK_OVERLAY(pI810XvMC,pI810XvMC->current)
+
+ I810_UNLOCK(pI810XvMC);
+ }
+
+ return Success;
+}
+
+
+
+
+/***************************************************************************
+//
+// Functions that deal with subpictures
+//
+***************************************************************************/
+
+
+
+/***************************************************************************
+// Function: XvMCCreateSubpicture
+// Description: This creates a subpicture by filling out the XvMCSubpicture
+// structure passed to it and returning Success.
+// Arguments:
+// display - Connection to the X server.
+// context - The context to create the subpicture for.
+// subpicture - Pre-allocated XvMCSubpicture structure to be filled in.
+// width - of subpicture
+// height - of subpicture
+// xvimage_id - The id describing the XvImage format.
+//
+// Returns: Status
+***************************************************************************/
+Status XvMCCreateSubpicture(Display *display, XvMCContext *context,
+ XvMCSubpicture *subpicture,
+ unsigned short width, unsigned short height,
+ int xvimage_id) {
+ i810XvMCContext *pI810XvMC;
+ i810XvMCSubpicture *pI810Subpicture;
+ int priv_count;
+ uint *priv_data;
+ Status ret;
+
+ if((subpicture == NULL) || (context == NULL) || (display == NULL)){
+ return BadValue;
+ }
+
+ pI810XvMC = (i810XvMCContext *)context->privData;
+ if(pI810XvMC == NULL) {
+ return (error_base + XvMCBadContext);
+ }
+
+
+ subpicture->context_id = context->context_id;
+ subpicture->xvimage_id = xvimage_id;
+
+ /* These need to be checked to make sure they are not too big! */
+ subpicture->width = width;
+ subpicture->height = height;
+
+ subpicture->privData =
+ (i810XvMCSubpicture *)malloc(sizeof(i810XvMCSubpicture));
+
+ if(!subpicture->privData) {
+ return BadAlloc;
+ }
+ pI810Subpicture = (i810XvMCSubpicture *)subpicture->privData;
+
+
+ if((ret = _xvmc_create_subpicture(display, context, subpicture,
+ &priv_count, &priv_data))) {
+ printf("Unable to create XvMCSubpicture.\n");
+ return ret;
+ }
+
+ if(priv_count != 1) {
+ printf("_xvmc_create_subpicture() returned incorrect data size.\n");
+ printf("Expected 1 got %d\n",priv_count);
+ free(priv_data);
+ return BadAlloc;
+ }
+ /* Data == Client Address, offset == Physical address offset */
+ pI810Subpicture->data = pI810XvMC->surfaces.address;
+ pI810Subpicture->offset = pI810XvMC->surfaces.offset;
+
+ /* Initialize private values */
+ pI810Subpicture->privContext = pI810XvMC;
+
+ pI810Subpicture->last_render = 0;
+ pI810Subpicture->last_flip = 0;
+
+ /* Based on the xvimage_id we will need to set the other values */
+ subpicture->num_palette_entries = 16;
+ subpicture->entry_bytes = 3;
+ strcpy(subpicture->component_order,"YUV");
+
+ /*
+ i810's MC Engine needs surfaces of 2^x (x= 9,10,11,12) pitch
+ and the Tiler need 512k aligned surfaces, basically we are
+ stuck with fixed memory with pitch 1024.
+ */
+ pI810Subpicture->pitch = 10;
+
+ /*
+ offsets[0] == offset into the map described by either
+ address (Client memeory address) or offset (physical offset from fb base)
+ */
+ pI810Subpicture->offsets[0] = priv_data[0];
+ if(((unsigned long)pI810Subpicture->data + pI810Subpicture->offsets[0]) & 4095) {
+ printf("XvMCCreateSubpicture: Subpicture offset 0 is not 4096 aligned\n");
+ }
+
+ /* Free data returned from xvmc_create_surface */
+ free(priv_data);
+
+ /* Clear the surface to 0 */
+ memset((void *)((unsigned long)pI810Subpicture->data + (unsigned long)pI810Subpicture->offsets[0]),
+ 0, ((1<<pI810Subpicture->pitch) * subpicture->height));
+
+ switch(subpicture->xvimage_id) {
+ case FOURCC_IA44:
+ case FOURCC_AI44:
+ /* Destination buffer info command */
+ pI810Subpicture->dbi1 = ((((unsigned int)pI810Subpicture->offset +
+ pI810Subpicture->offsets[0]) & ~0xfc000fff) |
+ (pI810Subpicture->pitch - 9));
+
+ /* Destination buffer variables command */
+ pI810Subpicture->dbv1 = (0x8<<20) | (0x8<<16);
+
+ /* Map info command */
+ pI810Subpicture->mi1 = (0x0<<24) | (3<<21) | (1<<9) |
+ (pI810Subpicture->pitch - 3);
+
+ pI810Subpicture->mi2 = (((unsigned int)subpicture->height - 1)<<16) |
+ ((unsigned int)subpicture->width - 1);
+
+ pI810Subpicture->mi3 = ((unsigned int)pI810Subpicture->offset +
+ pI810Subpicture->offsets[0]) & ~0xfc00000f;
+ break;
+ default:
+ free(subpicture->privData);
+ return BadMatch;
+ }
+
+ pI810XvMC->ref++;
+ return Success;
+}
+
+
+
+/***************************************************************************
+// Function: XvMCClearSubpicture
+// Description: Clear the area of the given subpicture to "color".
+// structure passed to it and returning Success.
+// Arguments:
+// display - Connection to the X server.
+// subpicture - Subpicture to clear.
+// x, y, width, height - rectangle in the subpicture to clear.
+// color - The data to file the rectangle with.
+//
+// Returns: Status
+***************************************************************************/
+Status XvMCClearSubpicture(Display *display, XvMCSubpicture *subpicture,
+ short x, short y,
+ unsigned short width, unsigned short height,
+ unsigned int color) {
+
+ i810XvMCContext *pI810XvMC;
+ i810XvMCSubpicture *pI810Subpicture;
+ int i;
+
+ if((subpicture == NULL) || (display == NULL)){
+ return BadValue;
+ }
+
+ if(!subpicture->privData) {
+ return (error_base + XvMCBadSubpicture);
+ }
+ pI810Subpicture = (i810XvMCSubpicture *)subpicture->privData;
+
+ pI810XvMC = (i810XvMCContext *)pI810Subpicture->privContext;
+ if(pI810XvMC == NULL) {
+ return (error_base + XvMCBadSubpicture);
+ }
+
+ if((x < 0) || (x + width > subpicture->width)) {
+ return BadValue;
+ }
+
+ if((y < 0) || (y + height > subpicture->height)) {
+ return BadValue;
+ }
+
+ for(i=y; i<y + height; i++) {
+ memset((void *)((unsigned long)pI810Subpicture->data +
+ (unsigned long)pI810Subpicture->offsets[0] + x +
+ (1<<pI810Subpicture->pitch) * i),(char)color,width);
+ }
+
+ return Success;
+}
+
+/***************************************************************************
+// Function: XvMCCompositeSubpicture
+// Description: Composite the XvImae on the subpicture. This composit uses
+// non-premultiplied alpha. Destination alpha is utilized
+// except for with indexed subpictures. Indexed subpictures
+// use a simple "replace".
+// Arguments:
+// display - Connection to the X server.
+// subpicture - Subpicture to clear.
+// image - the XvImage to be used as the source of the composite.
+// srcx, srcy, width, height - The rectangle from the image to be used.
+// dstx, dsty - location in the subpicture to composite the source.
+//
+// Returns: Status
+***************************************************************************/
+Status XvMCCompositeSubpicture(Display *display, XvMCSubpicture *subpicture,
+ XvImage *image,
+ short srcx, short srcy,
+ unsigned short width, unsigned short height,
+ short dstx, short dsty) {
+
+ i810XvMCContext *pI810XvMC;
+ i810XvMCSubpicture *pI810Subpicture;
+ int i;
+
+ if((subpicture == NULL) || (display == NULL)){
+ return BadValue;
+ }
+
+ if(!subpicture->privData) {
+ return (error_base + XvMCBadSubpicture);
+ }
+ pI810Subpicture = (i810XvMCSubpicture *)subpicture->privData;
+
+ pI810XvMC = (i810XvMCContext *)pI810Subpicture->privContext;
+ if(pI810XvMC == NULL) {
+ return (error_base + XvMCBadSubpicture);
+ }
+
+ if((srcx < 0) || (srcx + width > image->width)) {
+ return BadValue;
+ }
+
+ if((dstx < 0) || (dstx + width > subpicture->width)) {
+ return BadValue;
+ }
+
+ if((srcy < 0) || (srcy + height > image->height)) {
+ return BadValue;
+ }
+
+ if((dsty < 0) || (dsty + height > subpicture->height)) {
+ return BadValue;
+ }
+
+ for(i=0; i<height; i++) {
+ memcpy((void *)((unsigned long)pI810Subpicture->data +
+ (unsigned long)pI810Subpicture->offsets[0] + dstx +
+ (1<<pI810Subpicture->pitch) * (i + dsty)),
+ (void *)((unsigned long)image->data +
+ (unsigned long)image->offsets[0] + srcx +
+ image->pitches[0] * (i + srcy))
+ ,width);
+ }
+
+ return Success;
+
+}
+
+
+/***************************************************************************
+// Function: XvMCDestroySubpicture
+// Description: Destroys the specified subpicture.
+// Arguments:
+// display - Connection to the X server.
+// subpicture - Subpicture to be destroyed.
+//
+// Returns: Status
+***************************************************************************/
+Status XvMCDestroySubpicture(Display *display, XvMCSubpicture *subpicture) {
+
+ i810XvMCSubpicture *pI810Subpicture;
+ i810XvMCContext *pI810XvMC;
+
+ if((display == NULL) || (subpicture == NULL)) {
+ return BadValue;
+ }
+ if(!subpicture->privData) {
+ return (error_base + XvMCBadSubpicture);
+ }
+ pI810Subpicture = (i810XvMCSubpicture *)subpicture->privData;
+
+ pI810XvMC = (i810XvMCContext *)pI810Subpicture->privContext;
+ if(!pI810XvMC) {
+ return (error_base + XvMCBadSubpicture);
+ }
+
+
+ if(pI810Subpicture->last_render) {
+ XvMCSyncSubpicture(display,subpicture);
+ }
+
+ _xvmc_destroy_subpicture(display,subpicture);
+
+ i810_free_privContext(pI810XvMC);
+
+ free(pI810Subpicture);
+ subpicture->privData = NULL;
+ return Success;
+}
+
+
+/***************************************************************************
+// Function: XvMCSetSubpicturePalette
+// Description: Set the subpictures palette
+// Arguments:
+// display - Connection to the X server.
+// subpicture - Subpiture to set palette for.
+// palette - A pointer to an array holding the palette data. The array
+// is num_palette_entries * entry_bytes in size.
+// Returns: Status
+***************************************************************************/
+
+Status XvMCSetSubpicturePalette(Display *display, XvMCSubpicture *subpicture,
+ unsigned char *palette) {
+ i810XvMCSubpicture *privSubpicture;
+ int i,j;
+
+ if((display == NULL) || (subpicture == NULL)) {
+ return BadValue;
+ }
+ if(subpicture->privData == NULL) {
+ return (error_base + XvMCBadSubpicture);
+ }
+ privSubpicture = (i810XvMCSubpicture *)subpicture->privData;
+
+ j=0;
+ for(i=0; i<16; i++) {
+ privSubpicture->palette[0][i] = palette[j++];
+ privSubpicture->palette[1][i] = palette[j++];
+ privSubpicture->palette[2][i] = palette[j++];
+ }
+ return Success;
+}
+
+/***************************************************************************
+// Function: XvMCBlendSubpicture
+// Description:
+// The behavior of this function is different depending on whether
+// or not the XVMC_BACKEND_SUBPICTURE flag is set in the XvMCSurfaceInfo.
+// i810 only support frontend behavior.
+//
+// XVMC_BACKEND_SUBPICTURE not set ("frontend" behavior):
+//
+// XvMCBlendSubpicture is a no-op in this case.
+//
+// Arguments:
+// display - Connection to the X server.
+// subpicture - The subpicture to be blended into the video.
+// target_surface - The surface to be displayed with the blended subpic.
+// source_surface - Source surface prior to blending.
+// subx, suby, subw, subh - The rectangle from the subpicture to use.
+// surfx, surfy, surfw, surfh - The rectangle in the surface to blend
+// blend the subpicture rectangle into. Scaling can ocure if
+// XVMC_SUBPICTURE_INDEPENDENT_SCALING is set.
+//
+// Returns: Status
+***************************************************************************/
+Status XvMCBlendSubpicture(Display *display, XvMCSurface *target_surface,
+ XvMCSubpicture *subpicture,
+ short subx, short suby,
+ unsigned short subw, unsigned short subh,
+ short surfx, short surfy,
+ unsigned short surfw, unsigned short surfh) {
+
+ return BadMatch;
+}
+
+
+
+/***************************************************************************
+// Function: XvMCBlendSubpicture2
+// Description:
+// The behavior of this function is different depending on whether
+// or not the XVMC_BACKEND_SUBPICTURE flag is set in the XvMCSurfaceInfo.
+// i810 only supports frontend blending.
+//
+// XVMC_BACKEND_SUBPICTURE not set ("frontend" behavior):
+//
+// XvMCBlendSubpicture2 blends the source_surface and subpicture and
+// puts it in the target_surface. This does not effect the status of
+// the source surface but will cause the target_surface to query
+// XVMC_RENDERING until the blend is completed.
+//
+// Arguments:
+// display - Connection to the X server.
+// subpicture - The subpicture to be blended into the video.
+// target_surface - The surface to be displayed with the blended subpic.
+// source_surface - Source surface prior to blending.
+// subx, suby, subw, subh - The rectangle from the subpicture to use.
+// surfx, surfy, surfw, surfh - The rectangle in the surface to blend
+// blend the subpicture rectangle into. Scaling can ocure if
+// XVMC_SUBPICTURE_INDEPENDENT_SCALING is set.
+//
+// Returns: Status
+***************************************************************************/
+Status XvMCBlendSubpicture2(Display *display,
+ XvMCSurface *source_surface,
+ XvMCSurface *target_surface,
+ XvMCSubpicture *subpicture,
+ short subx, short suby,
+ unsigned short subw, unsigned short subh,
+ short surfx, short surfy,
+ unsigned short surfw, unsigned short surfh) {
+ drmBufPtr pDMA;
+ unsigned int *data;
+ i810XvMCContext *pI810XvMC;
+ i810XvMCSubpicture *privSubpicture;
+ i810XvMCSurface *privTarget;
+ i810XvMCSurface *privSource;
+ drm_i810_mc_t mc;
+ int i,j;
+
+ if(display == NULL) {
+ return BadValue;
+ }
+
+ if(subpicture == NULL) {
+ return (error_base + XvMCBadSubpicture);
+ }
+
+ if((target_surface == NULL) || (source_surface == NULL)) {
+ return (error_base + XvMCBadSurface);
+ }
+
+ if((subpicture->xvimage_id != FOURCC_AI44) &&
+ (subpicture->xvimage_id != FOURCC_IA44)) {
+ return (error_base + XvMCBadSubpicture);
+ }
+
+ if(!subpicture->privData) {
+ return (error_base + XvMCBadSubpicture);
+ }
+ privSubpicture = (i810XvMCSubpicture *)subpicture->privData;
+
+ pI810XvMC = (i810XvMCContext *)privSubpicture->privContext;
+ if(pI810XvMC == NULL) {
+ return (error_base + XvMCBadSubpicture);
+ }
+
+ if(!target_surface->privData) {
+ return (error_base + XvMCBadSurface);
+ }
+ privTarget = (i810XvMCSurface *)target_surface->privData;
+
+ if(!source_surface->privData) {
+ return (error_base + XvMCBadSurface);
+ }
+ privSource = (i810XvMCSurface *)source_surface->privData;
+
+
+ /* Check that size isn't bigger than subpicture */
+ if((subx + subw) > subpicture->width) {
+ return BadValue;
+ }
+ if((suby + subh) > subpicture->height) {
+ return BadValue;
+ }
+ /* Check that dest isn't bigger than surface */
+ if((surfx + surfw) > target_surface->width) {
+ return BadValue;
+ }
+ if((surfy + surfh) > target_surface->height) {
+ return BadValue;
+ }
+ /* Make sure surfaces match */
+ if(target_surface->width != source_surface->width) {
+ return BadValue;
+ }
+ if(target_surface->height != source_surface->height) {
+ return BadValue;
+ }
+
+ /* Lock For DMA */
+ I810_LOCK(pI810XvMC,0);
+
+ /* Allocate DMA buffer */
+ pDMA = i810_get_free_buffer(pI810XvMC);
+ data = pDMA->address;
+
+ /* Copy Y data first */
+ /* SOURCE_COPY_BLT */
+ *data++ = (2<<29) | (0x43<<22) | 0x4;
+ *data++ = (0xcc<<16) | (1<<26) | (1<<privTarget->pitch);
+ *data++ = (target_surface->height<<16) | target_surface->width;
+ *data++ = privTarget->offset + privTarget->offsets[0];
+ *data++ = (1<<privSource->pitch);
+ *data++ = privSource->offset + privSource->offsets[0];
+
+ /* Select Context 1 for loading */
+ *data++ = CMD_FLUSH;
+ *data++ = (5<<23) | (1<<17) | (1<<8);
+ *data++ = CMD_FLUSH;
+
+ /* Load Palette */
+ *data++ = MAP_PALETTE_LOAD;
+ /* 16 levels of alpha for each Y */
+ switch(subpicture->xvimage_id) {
+ case FOURCC_IA44:
+ for(i=0; i<16; i++) {
+ for(j=0; j<16; j++) {
+ *data++ = (j<<12) | (j<<8) | privSubpicture->palette[0][i];
+ }
+ }
+ break;
+ case FOURCC_AI44:
+ for(i=0; i<16; i++) {
+ for(j=0; j<16; j++) {
+ *data++ = (i<<12) | (i<<8) | privSubpicture->palette[0][j];
+ }
+ }
+ break;
+ }
+ /* TARGET */
+ /* *data++ = CMD_FLUSH; */
+ /* *data++ = BOOLEAN_ENA_2; */
+ *data++ = CMD_FLUSH;
+ *data++ = DEST_BUFFER_INFO;
+ *data++ = privTarget->dbi1y;
+ *data++ = DEST_BUFFER_VAR;
+ *data++ = privTarget->dbv1;
+
+ /* ALPHA */
+ *data++ = CMD_MAP_INFO;
+ *data++ = privSubpicture->mi1;
+ *data++ = privSubpicture->mi2;
+ *data++ = privSubpicture->mi3;
+
+ *data++ = VERTEX_FORMAT | (1<<8) | (3<<1);
+ *data++ = BOOLEAN_ENA_1;
+ *data++ = SRC_DEST_BLEND_MONO | (0x940);
+ /* Map Filter */
+ *data++ = (3<<29) | (0x1c<<24) | (2<<19) | (0x224);
+
+ /* Use context 1 */
+ *data++ = CMD_FLUSH;
+ *data++ = (5<<23) | (1<<16) | 1;
+ *data++ = CMD_FLUSH;
+
+ /* Drawing Rect Info */
+ *data++ = DRAWING_RECT_INFO;
+ *data++ = 0x0;
+ *data++ = 0x0;
+ *data++ = 0x0;
+ *data++ = 0x0;
+ *data++ = 0x0;
+
+ /* GFXPRIMITIVE RECTANGLE */
+ *data++ = (3<<29) | (0x1f<<24) | (0x7<<18) | 11;
+ /* Bottom Right Vertex */
+ *(float *)data++ = (float) (surfx + surfw);
+ *(float *)data++ = (float) (surfy + surfh);
+ *(float *)data++ = (float) (subx + subw);
+ *(float *)data++ = (float) (suby + subh);
+ /* Bottom Left Vertex */
+ *(float *)data++ = (float) surfx;
+ *(float *)data++ = (float) (surfy + surfh);
+ *(float *)data++ = (float) subx;
+ *(float *)data++ = (float) (suby + subh);
+ /* Top Left Vertex */
+ *(float *)data++ = (float) surfx;
+ *(float *)data++ = (float) surfy;
+ *(float *)data++ = (float) subx;
+ *(float *)data++ = (float) suby;
+
+ /* Load and Use Context 0 */
+ *data++ = CMD_FLUSH;
+ *data++ = (5<<23) | (1<<17) | (1<<16);
+ *data++ = CMD_FLUSH;
+
+ /* U data */
+ /* SOURCE_COPY_BLT */
+ *data++ = (2<<29) | (0x43<<22) | 0x4;
+ *data++ = (0xcc<<16) | (1<<26) | (1<<(privTarget->pitch - 1));
+ *data++ = (target_surface->height<<15) | (target_surface->width>>1);
+ *data++ = (unsigned long)privTarget->offset + (unsigned long)privTarget->offsets[1];
+ *data++ = (1<<(privSource->pitch - 1));
+ *data++ = (unsigned long)privSource->offset + (unsigned long)privSource->offsets[1];
+
+ /* Context 1 select */
+ *data++ = CMD_FLUSH;
+ *data++ = (5<<23) | (1<<17) | (1<<8);
+ *data++ = CMD_FLUSH;
+ /* ALPHA PALETTE */
+ *data++ = MAP_PALETTE_LOAD;
+ /* 16 levels of alpha for each Y */
+ switch(subpicture->xvimage_id) {
+ case FOURCC_IA44:
+ for(i=0; i<16; i++) {
+ for(j=0; j<16; j++) {
+ *data++ = (j<<12) | (j<<8) | privSubpicture->palette[2][i];
+ }
+ }
+ break;
+ case FOURCC_AI44:
+ for(i=0; i<16; i++) {
+ for(j=0; j<16; j++) {
+ *data++ = (i<<12) | (i<<8) | privSubpicture->palette[2][j];
+ }
+ }
+ break;
+ }
+ /* TARGET */
+ *data++ = CMD_FLUSH;
+ *data++ = BOOLEAN_ENA_2;
+ *data++ = CMD_FLUSH;
+ *data++ = DEST_BUFFER_INFO;
+ *data++ = privTarget->dbi1u;
+ *data++ = DEST_BUFFER_VAR;
+ *data++ = privTarget->dbv1;
+
+ /* ALPHA */
+ *data++ = CMD_MAP_INFO;
+ *data++ = privSubpicture->mi1;
+ *data++ = privSubpicture->mi2;
+ *data++ = privSubpicture->mi3;
+
+ *data++ = VERTEX_FORMAT | (1<<8) | (3<<1);
+ *data++ = BOOLEAN_ENA_1;
+ *data++ = SRC_DEST_BLEND_MONO | (0x940);
+ /* Map Filter */
+ *data++ = (3<<29) | (0x1c<<24) | (2<<19) | (1<<16) | (0x224);
+
+ /* Use context 1 */
+ *data++ = CMD_FLUSH;
+ *data++ = (5<<23) | (1<<16) | 1;
+ *data++ = CMD_FLUSH;
+
+ /* Drawing Rect Info */
+ *data++ = (3<<29) | (0x1d<<24) | (0x80<<16) | 3;
+ *data++ = 0;
+ *data++ = 0;
+ *data++ = 0;
+ *data++ = 0;
+ *data++ = 0;
+
+ /* Rectangle */
+ *data++ = (3<<29) | (0x1f<<24) | (0x7<<18) | 11;
+ /* Bottom Right */
+ *(float *)data++ = (float) ((surfx + surfw)>>1);
+ *(float *)data++ = (float) ((surfy + surfh)>>1);
+ *(float *)data++ = (float) subx + subw;
+ *(float *)data++ = (float) suby + subh;
+ /* Bottom Left */
+ *(float *)data++ = (float) (surfx>>1);
+ *(float *)data++ = (float) ((surfy + surfh)>>1);
+ *(float *)data++ = (float) subx;
+ *(float *)data++ = (float) suby + subh;
+ /* Top Left */
+ *(float *)data++ = (float) (surfx>>1);
+ *(float *)data++ = (float) (surfy>>1);
+ *(float *)data++ = (float) subx;
+ *(float *)data++ = (float) suby;
+
+ /* Load and Use Context 0 */
+ *data++ = CMD_FLUSH;
+ *data++ = (5<<23) | (1<<17) | (1<<16);
+ *data++ = CMD_FLUSH;
+
+ /* V data */
+ /* SOURCE_COPY_BLT */
+ *data++ = (2<<29) | (0x43<<22) | 0x4;
+ *data++ = (0xcc<<16) | (1<<26) | (1<<(privTarget->pitch - 1));
+ *data++ = (target_surface->height<<15) | (target_surface->width>>1);
+ *data++ = (unsigned long)privTarget->offset + (unsigned long)privTarget->offsets[2];
+ *data++ = (1<<(privSource->pitch - 1));
+ *data++ = (unsigned long)privSource->offset + (unsigned long)privSource->offsets[2];
+
+ /* Context 1 select */
+ *data++ = CMD_FLUSH;
+ *data++ = (5<<23) | (1<<17) | (1<<8);
+ *data++ = CMD_FLUSH;
+
+ /* ALPHA PALETTE */
+ *data++ = MAP_PALETTE_LOAD;
+ /* 16 levels of alpha for each Y */
+ switch(subpicture->xvimage_id) {
+ case FOURCC_IA44:
+ for(i=0; i<16; i++) {
+ for(j=0; j<16; j++) {
+ *data++ = (j<<12) | (j<<8) | privSubpicture->palette[1][i];
+ }
+ }
+ break;
+ case FOURCC_AI44:
+ for(i=0; i<16; i++) {
+ for(j=0; j<16; j++) {
+ *data++ = (i<<12) | (i<<8) | privSubpicture->palette[1][j];
+ }
+ }
+ break;
+ }
+ /* TARGET */
+ *data++ = CMD_FLUSH;
+ *data++ = BOOLEAN_ENA_2;
+ *data++ = CMD_FLUSH;
+ *data++ = DEST_BUFFER_INFO;
+ *data++ = privTarget->dbi1v;
+ *data++ = DEST_BUFFER_VAR;
+ *data++ = privTarget->dbv1;
+
+ /* ALPHA */
+ *data++ = CMD_MAP_INFO;
+ *data++ = privSubpicture->mi1;
+ *data++ = privSubpicture->mi2;
+ *data++ = privSubpicture->mi3;
+
+ *data++ = VERTEX_FORMAT | (1<<8) | (3<<1);
+ *data++ = BOOLEAN_ENA_1;
+ *data++ = SRC_DEST_BLEND_MONO | (0x940);
+ /* Map Filter */
+ *data++ = (3<<29) | (0x1c<<24) | (2<<19) | (1<<16) | (0x224);
+
+ /* Use context 1 */
+ *data++ = CMD_FLUSH;
+ *data++ = (5<<23) | (1<<16) | 1;
+ *data++ = CMD_FLUSH;
+
+ /* Drawing Rect Info */
+ *data++ = (3<<29) | (0x1d<<24) | (0x80<<16) | 3;
+ *data++ = 0;
+ *data++ = 0;
+ *data++ = 0;
+ *data++ = 0;
+ *data++ = 0;
+
+ /* Rectangle */
+ *data++ = (3<<29) | (0x1f<<24) | (0x7<<18) | 11;
+ /* Bottom Right */
+ *(float *)data++ = (float) ((surfx + surfw)>>1);
+ *(float *)data++ = (float) ((surfy + surfh)>>1);
+ *(float *)data++ = (float) subx + subw;
+ *(float *)data++ = (float) suby + subh;
+ /* Bottom Left */
+ *(float *)data++ = (float) (surfx>>1);
+ *(float *)data++ = (float) ((surfy + surfh)>>1);
+ *(float *)data++ = (float) subx;
+ *(float *)data++ = (float) suby + subh;
+ /* Top Left */
+ *(float *)data++ = (float) (surfx>>1);
+ *(float *)data++ = (float) (surfy>>1);
+ *(float *)data++ = (float) subx;
+ *(float *)data++ = (float) suby;
+
+ /* Load and Use Context 0 */
+ *data++ = CMD_FLUSH;
+ *data++ = (5<<23) | (1<<17) | (1<<16);
+ *data++ = CMD_FLUSH;
+
+
+ /* Dispatch */
+ pDMA->used = (unsigned long)data - (unsigned long)pDMA->address;
+ mc.idx = pDMA->idx;
+ mc.used = pDMA->used;
+ mc.last_render = ++pI810XvMC->last_render;
+ privTarget->last_render = pI810XvMC->last_render;
+ I810_MC(pI810XvMC,mc);
+
+ I810_UNLOCK(pI810XvMC);
+ return Success;
+}
+
+
+
+/***************************************************************************
+// Function: XvMCSyncSubpicture
+// Description: This function blocks until all composite/clear requests on
+// the subpicture have been complete.
+// Arguments:
+// display - Connection to the X server.
+// subpicture - The subpicture to synchronize
+//
+// Returns: Status
+***************************************************************************/
+Status XvMCSyncSubpicture(Display *display, XvMCSubpicture *subpicture) {
+ Status ret;
+ int stat=0;
+ do {
+ ret = XvMCGetSubpictureStatus(display,subpicture,&stat);
+ }while(!ret && (stat & XVMC_RENDERING));
+ return ret;
+}
+
+
+
+/***************************************************************************
+// Function: XvMCFlushSubpicture
+// Description: This function commits pending composite/clear requests to
+// ensure that they will be completed in a finite amount of
+// time.
+// Arguments:
+// display - Connection to the X server.
+// subpicture - The subpicture whos compsiting should be flushed
+//
+// Returns: Status
+// NOTES: i810 always dispatches commands so flush is a no-op
+***************************************************************************/
+Status XvMCFlushSubpicture(Display *display, XvMCSubpicture *subpicture) {
+ if(display == NULL) {
+ return BadValue;
+ }
+ if(subpicture == NULL) {
+ return (error_base + XvMCBadSubpicture);
+ }
+
+ return Success;
+}
+
+
+
+/***************************************************************************
+// Function: XvMCGetSubpictureStatus
+// Description: This function gets the current status of a subpicture
+//
+// Arguments:
+// display - Connection to the X server.
+// subpicture - The subpicture whos status is being queried
+// stat - The status of the subpicture. It can be any of the following
+// OR'd together:
+// XVMC_RENDERING - Last composite or clear request not completed
+// XVMC_DISPLAYING - Suppicture currently being displayed.
+//
+// Returns: Status
+// Notes: i810 always blends into a third surface so the subpicture is
+// never actually displaying, only a copy of it is displaying. We only
+// have to worry about the rendering case.
+***************************************************************************/
+Status XvMCGetSubpictureStatus(Display *display, XvMCSubpicture *subpicture,
+ int *stat) {
+
+ i810XvMCSubpicture *privSubpicture;
+ i810XvMCContext *pI810XvMC;
+
+ if((display == NULL) || (stat == NULL)) {
+ return BadValue;
+ }
+ if((subpicture == NULL) || (subpicture->privData == NULL)) {
+ return (error_base + XvMCBadSubpicture);
+ }
+ *stat = 0;
+ privSubpicture = (i810XvMCSubpicture *)subpicture->privData;
+
+ pI810XvMC = (i810XvMCContext *)privSubpicture->privContext;
+ if(pI810XvMC == NULL) {
+ return (error_base + XvMCBadSubpicture);
+ }
+
+ I810_LOCK(pI810XvMC,0);
+
+ if(privSubpicture->last_render &&
+ (privSubpicture->last_render > GET_RSTATUS(pI810XvMC))) {
+ *stat |= XVMC_RENDERING;
+ }
+ I810_UNLOCK(pI810XvMC);
+
+ return Success;
+}
+
+#define NUM_XVMC_ATTRIBUTES 4
+static XvAttribute I810_XVMC_ATTRIBUTES[] = {
+ {XvGettable | XvSettable, 0, 0xffffff, "XV_COLORKEY"},
+ {XvGettable | XvSettable, -127, +127, "XV_BRIGHTNESS"},
+ {XvGettable | XvSettable, 0, 0x1ff, "XV_CONTRAST"},
+ {XvGettable | XvSettable, 0, 0x3ff, "XV_SATURATION"}
+};
+
+
+/***************************************************************************
+// Function: XvMCQueryAttributes
+// Description: An array of XvAttributes of size "number" is returned by
+// this function. If there are no attributes, NULL is returned and number
+// is set to 0. The array may be freed with xfree().
+//
+// Arguments:
+// display - Connection to the X server.
+// context - The context whos attributes we are querying.
+// number - The number of returned atoms.
+//
+// Returns:
+// An array of XvAttributes.
+// Notes:
+// For i810 we support these Attributes:
+// XV_COLORKEY: The colorkey value, initialized from the Xv value at
+// context creation time.
+// XV_BRIGHTNESS
+// XV_CONTRAST
+// XV_SATURATION
+***************************************************************************/
+XvAttribute *XvMCQueryAttributes(Display *display, XvMCContext *context,
+ int *number) {
+ i810XvMCContext *pI810XvMC;
+ XvAttribute *attributes;
+
+ if(number == NULL) {
+ return NULL;
+ }
+ if(display == NULL) {
+ *number = 0;
+ return NULL;
+ }
+ if(context == NULL) {
+ *number = 0;
+ return NULL;
+ }
+ pI810XvMC = context->privData;
+ if(pI810XvMC == NULL) {
+ *number = 0;
+ return NULL;
+ }
+
+ attributes = (XvAttribute *)malloc(NUM_XVMC_ATTRIBUTES *
+ sizeof(XvAttribute));
+ if(attributes == NULL) {
+ *number = 0;
+ return NULL;
+ }
+
+ memcpy(attributes,I810_XVMC_ATTRIBUTES,(NUM_XVMC_ATTRIBUTES *
+ sizeof(XvAttribute)));
+
+ *number = NUM_XVMC_ATTRIBUTES;
+ return attributes;
+}
+
+/***************************************************************************
+// Function: XvMCSetAttribute
+// Description: This function sets a context-specific attribute.
+//
+// Arguments:
+// display - Connection to the X server.
+// context - The context whos attributes we are querying.
+// attribute - The X atom of the attribute to be changed.
+// value - The new value for the attribute.
+//
+// Returns:
+// Status
+// Notes:
+// For i810 we support these Attributes:
+// XV_COLORKEY: The colorkey value, initialized from the Xv value at
+// context creation time.
+// XV_BRIGHTNESS
+// XV_CONTRAST
+// XV_SATURATION
+***************************************************************************/
+Status XvMCSetAttribute(Display *display, XvMCContext *context,
+ Atom attribute, int value) {
+ i810XvMCContext *pI810XvMC;
+
+ if(display == NULL) {
+ return BadValue;
+ }
+ if(context == NULL) {
+ return (error_base + XvMCBadContext);
+ }
+ pI810XvMC = context->privData;
+ if(pI810XvMC == NULL) {
+ return (error_base + XvMCBadContext);
+ }
+
+ if(attribute == pI810XvMC->xv_colorkey) {
+ if((value < I810_XVMC_ATTRIBUTES[0].min_value) ||
+ (value > I810_XVMC_ATTRIBUTES[0].max_value)) {
+ return BadValue;
+ }
+ pI810XvMC->colorkey = value;
+ return Success;
+ }
+ if(attribute == pI810XvMC->xv_brightness) {
+ if((value < I810_XVMC_ATTRIBUTES[1].min_value) ||
+ (value > I810_XVMC_ATTRIBUTES[1].max_value)) {
+ return BadValue;
+ }
+ pI810XvMC->brightness = value;
+ return Success;
+ }
+ if(attribute == pI810XvMC->xv_saturation) {
+ if((value < I810_XVMC_ATTRIBUTES[2].min_value) ||
+ (value > I810_XVMC_ATTRIBUTES[2].max_value)) {
+ return BadValue;
+ }
+ pI810XvMC->saturation = value;
+ return Success;
+ }
+ if(attribute == pI810XvMC->xv_contrast) {
+ if((value < I810_XVMC_ATTRIBUTES[3].min_value) ||
+ (value > I810_XVMC_ATTRIBUTES[3].max_value)) {
+ return BadValue;
+ }
+ pI810XvMC->contrast = value;
+ return Success;
+ }
+ return BadValue;
+}
+
+/***************************************************************************
+// Function: XvMCGetAttribute
+// Description: This function queries a context-specific attribute and
+// returns the value.
+//
+// Arguments:
+// display - Connection to the X server.
+// context - The context whos attributes we are querying.
+// attribute - The X atom of the attribute to be queried
+// value - The returned attribute value
+//
+// Returns:
+// Status
+// Notes:
+// For i810 we support these Attributes:
+// XV_COLORKEY: The colorkey value, initialized from the Xv value at
+// context creation time.
+// XV_BRIGHTNESS
+// XV_CONTRAST
+// XV_SATURATION
+***************************************************************************/
+Status XvMCGetAttribute(Display *display, XvMCContext *context,
+ Atom attribute, int *value) {
+ i810XvMCContext *pI810XvMC;
+
+ if(display == NULL) {
+ return BadValue;
+ }
+ if(context == NULL) {
+ return (error_base + XvMCBadContext);
+ }
+ pI810XvMC = context->privData;
+ if(pI810XvMC == NULL) {
+ return (error_base + XvMCBadContext);
+ }
+ if(value == NULL) {
+ return BadValue;
+ }
+
+ if(attribute == pI810XvMC->xv_colorkey) {
+ *value = pI810XvMC->colorkey;
+ return Success;
+ }
+ if(attribute == pI810XvMC->xv_brightness) {
+ *value = pI810XvMC->brightness;
+ return Success;
+ }
+ if(attribute == pI810XvMC->xv_saturation) {
+ *value = pI810XvMC->saturation;
+ return Success;
+ }
+ if(attribute == pI810XvMC->xv_contrast) {
+ *value = pI810XvMC->contrast;
+ return Success;
+ }
+ return BadValue;
+}
+
+
+
+
diff --git a/nx-X11/lib/XvMC/hw/i810/I810XvMC.h b/nx-X11/lib/XvMC/hw/i810/I810XvMC.h
new file mode 100644
index 000000000..ba8c792d0
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/i810/I810XvMC.h
@@ -0,0 +1,469 @@
+/***************************************************************************
+
+Copyright 2001 Intel Corporation. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/***************************************************************************
+ * libI810XvMC.h: MC Driver i810 includes
+ *
+ * Authors:
+ * Matt Sottek <matthew.j.sottek@intel.com>
+ *
+ *
+ ***************************************************************************/
+/* $XFree86: xc/lib/XvMC/hw/i810/I810XvMC.h,v 1.3 2002/10/30 12:52:02 alanh Exp $ */
+
+
+#ifndef I810XVMC_H
+#define I810XVMC_H
+
+/* #define XVMC_DEBUG(x) do {x; }while(0); */
+#define XVMC_DEBUG(x)
+
+#include "xf86drm.h"
+#include "i810_common.h"
+#include <X11/Xlibint.h>
+
+
+/***************************************************************************
+// i810OverlayRec: Structure that is used to reference the overlay
+// register memory. A i810OverlayRecPtr is set to the address of the
+// allocated overlay registers.
+***************************************************************************/
+typedef struct _i810OverlayRec {
+ unsigned int OBUF_0Y;
+ unsigned int OBUF_1Y;
+ unsigned int OBUF_0U;
+ unsigned int OBUF_0V;
+ unsigned int OBUF_1U;
+ unsigned int OBUF_1V;
+ unsigned int OV0STRIDE;
+ unsigned int YRGB_VPH;
+ unsigned int UV_VPH;
+ unsigned int HORZ_PH;
+ unsigned int INIT_PH;
+ unsigned int DWINPOS;
+ unsigned int DWINSZ;
+ unsigned int SWID;
+ unsigned int SWIDQW;
+ unsigned int SHEIGHT;
+ unsigned int YRGBSCALE;
+ unsigned int UVSCALE;
+ unsigned int OV0CLRC0;
+ unsigned int OV0CLRC1;
+ unsigned int DCLRKV;
+ unsigned int DCLRKM;
+ unsigned int SCLRKVH;
+ unsigned int SCLRKVL;
+ unsigned int SCLRKM;
+ unsigned int OV0CONF;
+ unsigned int OV0CMD;
+} i810OverlayRec, *i810OverlayRecPtr;
+
+
+/***************************************************************************
+// i810XvMCDrmMap: Holds the data about the DRM maps
+***************************************************************************/
+typedef struct _i810XvMCDrmMap {
+ drm_handle_t offset;
+ drmAddress address;
+ unsigned int size;
+} i810XvMCDrmMap, *i810XvMCDrmMapPtr;
+
+/***************************************************************************
+// i810XvMCContext: Private Context data referenced via the privData
+// pointer in the XvMCContext structure.
+***************************************************************************/
+typedef struct _i810XvMCContext {
+ int fd; /* File descriptor for /dev/dri */
+ i810XvMCDrmMap overlay;
+ i810XvMCDrmMap surfaces;
+ drmBufMapPtr dmabufs; /* Data structure to hold available dma buffers */
+ drm_context_t drmcontext;
+ unsigned int last_render;
+ unsigned int last_flip;
+ unsigned short ref;
+ unsigned short current;
+ int lock; /* Lightweight lock to avoid locking twice */
+ char busIdString[10]; /* PCI:0:1:0 or PCI:0:2:0 */
+ i810OverlayRecPtr oregs;
+ unsigned int dual_prime; /* Flag to identify when dual prime is in use. */
+ unsigned int fb_base;
+ Atom xv_colorkey;
+ Atom xv_brightness;
+ Atom xv_contrast;
+ Atom xv_saturation;
+ int brightness;
+ int saturation;
+ int contrast;
+ int colorkey;
+} i810XvMCContext;
+
+/***************************************************************************
+// i810XvMCSurface: Private data structure for each XvMCSurface. This
+// structure is referenced by the privData pointer in the XvMCSurface
+// structure.
+***************************************************************************/
+typedef struct _i810XvMCSurface {
+ unsigned int pitch;
+ unsigned int dbi1y; /* Destination buffer info command word 1 for Y */
+ unsigned int dbi1u; /* Destination buffer info command word 1 for U */
+ unsigned int dbi1v; /* Destination buffer info command word 1 for V */
+ unsigned int dbv1; /* Destination buffer variables command word 1 */
+ unsigned int mi1y; /* Map Info command word 1 (Minus bit 28) for Y */
+ unsigned int mi1u; /* Map Info command word 1 (Minus bit 28) for U */
+ unsigned int mi1v; /* Map Info command word 1 (Minus bit 28) for V */
+ unsigned int mi2y; /* Map info command word 2 for y */
+ unsigned int mi2u; /* Map info command word 2 for y */
+ unsigned int mi2v; /* Map info command word 2 for y */
+ unsigned int mi3y; /* Map info command word 3 */
+ unsigned int mi3u; /* Map info command word 3 */
+ unsigned int mi3v; /* Map info command word 3 */
+ unsigned int last_render;
+ unsigned int last_flip;
+ unsigned int second_field; /* Flags a surface that is only half done */
+ drmAddress data;
+ drm_handle_t offset;
+ unsigned int offsets[3];
+ i810XvMCContext *privContext;
+} i810XvMCSurface;
+
+/***************************************************************************
+// i810XvMCSubpicture: Private data structure for each XvMCSubpicture. This
+// structure is referenced by the privData pointer in the XvMCSubpicture
+// structure.
+***************************************************************************/
+typedef struct _i810XvMCSubpicture {
+ unsigned int pitch;
+ unsigned int dbi1; /* Destination buffer info command word 1 */
+ unsigned int dbv1; /* Destination buffer variables command word */
+ unsigned int mi1; /* Map Info command word 1 (Minus bit 28) */
+ unsigned int mi2; /* Map info command word 2 */
+ unsigned int mi3; /* Map info command word 3 */
+ unsigned int last_render;
+ unsigned int last_flip;
+ drmAddress data;
+ drm_handle_t offset;
+ unsigned int offsets[1];
+ unsigned char palette[3][16];
+ i810XvMCContext *privContext;
+} i810XvMCSubpicture;
+
+typedef struct _Box {
+ int x1,y1,x2,y2;
+} Box, *BoxPtr;
+
+/***************************************************************************
+// drm_i810_overlay_t: Structure returned by overlay info ioctl.
+// NOTE: If you change this structure you will have to change the equiv.
+// structure in the kernel.
+***************************************************************************/
+typedef struct _drm_i810_overlay_t {
+ unsigned int offset;
+ unsigned int physical;
+} drm_i810_overlay_t;
+
+/***************************************************************************
+// drm_i810_dma_t: Structure used by dma allocation ioctl.
+// NOTE: If you change this structure you will have to change the equiv.
+// structure in the kernel.
+***************************************************************************/
+typedef struct _drm_i810_dma {
+ void *virtual;
+ int request_idx;
+ int request_size;
+ int granted;
+} drm_i810_dma_t;
+
+/***************************************************************************
+// drm_i810_mc_t: Structure used by mc dispatch ioctl.
+// NOTE: If you change this structure you will have to change the equiv.
+// structure in the kernel.
+***************************************************************************/
+typedef struct _drm_i810_mc {
+ int idx; /* buffer index */
+ int used; /* nr bytes in use */
+ int num_blocks; /* number of GFXBlocks */
+ int *length; /* List of lengths for GFXBlocks */
+ unsigned int last_render; /* Last render request */
+} drm_i810_mc_t;
+
+/* Subpicture fourcc */
+#define FOURCC_IA44 0x34344149
+
+/* Static Parameters */
+#define I810_XVMC_MAXWIDTH 720
+#define I810_XVMC_MAXHEIGHT 576
+#define I810_DEFAULT16_COLORKEY 31
+#define I810_DMA_BUF_NR 256
+
+/* COMMANDS */
+#define CMD_FLUSH ((4<<23) | 0x1)
+#define BOOLEAN_ENA_1 ((3<<29) | (3<<24) | (3<<2))
+#define BOOLEAN_ENA_2 ((3<<29) | (4<<24) | (3<<16) | (1<<3) | (1<<2))
+#define DEST_BUFFER_INFO (0x15<<23)
+#define DEST_BUFFER_VAR ((0x3<<29) | (0x1d<<24) | (0x85<<16))
+#define DRAWING_RECT_INFO ((3<<29) | (0x1d<<24) | (0x80<<16) | 3)
+#define GFXBLOCK ((0x3<<29) | (0x1e<<24))
+#define CMD_MAP_INFO ((0x3<<29) | (0x1d<<24) | 0x2)
+#define MAP_PALETTE_LOAD ((3<<29) | (0x1d<<24) | (0x82<<16) | 0xff)
+#define VERTEX_FORMAT ((3<<29) | (0x5<<24))
+#define SRC_DEST_BLEND_MONO ((3<<29) | (8<<24))
+
+/* Bit Patterns */
+
+/*
+ * OV0CMD - Overlay Command Register
+ */
+#define VERTICAL_CHROMINANCE_FILTER 0x70000000
+#define VC_SCALING_OFF 0x00000000
+#define VC_LINE_REPLICATION 0x10000000
+#define VC_UP_INTERPOLATION 0x20000000
+#define VC_PIXEL_DROPPING 0x50000000
+#define VC_DOWN_INTERPOLATION 0x60000000
+#define VERTICAL_LUMINANCE_FILTER 0x0E000000
+#define VL_SCALING_OFF 0x00000000
+#define VL_LINE_REPLICATION 0x02000000
+#define VL_UP_INTERPOLATION 0x04000000
+#define VL_PIXEL_DROPPING 0x0A000000
+#define VL_DOWN_INTERPOLATION 0x0C000000
+#define HORIZONTAL_CHROMINANCE_FILTER 0x01C00000
+#define HC_SCALING_OFF 0x00000000
+#define HC_LINE_REPLICATION 0x00400000
+#define HC_UP_INTERPOLATION 0x00800000
+#define HC_PIXEL_DROPPING 0x01400000
+#define HC_DOWN_INTERPOLATION 0x01800000
+#define HORIZONTAL_LUMINANCE_FILTER 0x00380000
+#define HL_SCALING_OFF 0x00000000
+#define HL_LINE_REPLICATION 0x00080000
+#define HL_UP_INTERPOLATION 0x00100000
+#define HL_PIXEL_DROPPING 0x00280000
+#define HL_DOWN_INTERPOLATION 0x00300000
+
+#define Y_ADJUST 0x00010000
+#define OV_BYTE_ORDER 0x0000C000
+#define UV_SWAP 0x00004000
+#define Y_SWAP 0x00008000
+#define Y_AND_UV_SWAP 0x0000C000
+#define SOURCE_FORMAT 0x00003C00
+#define RGB_555 0x00000800
+#define RGB_565 0x00000C00
+#define YUV_422 0x00002000
+#define YUV_411 0x00002400
+#define YUV_420 0x00003000
+#define YUV_410 0x00003800
+#define VERTICAL_PHASE_BOTH 0x00000020
+#define FLIP_TYPE_FIELD 0x00000020
+#define FLIP_TYPE_FRAME 0x00000000
+#define BUFFER_AND_FIELD 0x00000006
+#define BUFFER0_FIELD0 0x00000000
+#define BUFFER0_FIELD1 0x00000002
+#define BUFFER1_FIELD0 0x00000004
+#define BUFFER1_FIELD1 0x00000006
+#define OVERLAY_ENABLE 0x00000001
+
+/*
+ * DOV0STA - Display/Overlay 0 Status Register
+ */
+#define DOV0STA 0x30008
+#define OV0ADD 0x30000
+#define MINUV_SCALE 0x1
+
+#define RGB16ToColorKey(c) \
+ (((c & 0xF800) << 8) | ((c & 0x07E0) << 5) | ((c & 0x001F) << 3))
+
+/* Locking Macros lightweight lock used to prevent relocking */
+#define I810_LOCK(c,f) \
+ if(!c->lock) { \
+ drmGetLock(c->fd, c->drmcontext, f); \
+ } \
+ c->lock++;
+
+#define I810_UNLOCK(c) \
+ c->lock--; \
+ if(!c->lock) { \
+ drmUnlock(c->fd, c->drmcontext); \
+ }
+
+/*
+ Block until the passed in value (n) is the active
+ buffer on the overlay.
+*/
+#define BLOCK_OVERLAY(c,n) \
+ do { \
+ int temp,i=0; \
+ while(i < 100000) { \
+ temp = GET_FSTATUS(c); \
+ if(((temp & (1<<20))>>20) == n) { \
+ break; \
+ } \
+ usleep(10); \
+ } \
+ if(i == 100000) { \
+ printf("Overlay Lockup.\n"); \
+ return BadAlloc; \
+ } \
+ }while(0);
+
+#define OVERLAY_INFO(c,i) drmCommandRead(c->fd, DRM_I810_OV0INFO, &i, sizeof(i))
+#define OVERLAY_FLIP(c) drmCommandNone(c->fd, DRM_I810_OV0FLIP)
+#define GET_FSTATUS(c) drmCommandNone(c->fd, DRM_I810_FSTATUS)
+#define I810_MC(c,mc) drmCommandWrite(c->fd, DRM_I810_MC, &mc, sizeof(mc))
+#define GET_RSTATUS(c) drmCommandNone(c->fd, DRM_I810_RSTATUS)
+#define GET_BUFFER(c,dma) drmCommandWriteRead(c->fd, DRM_I810_GETBUF, &dma, sizeof(drmI810DMA))
+#define FLUSH(c) drmCommandNone(c->fd, DRM_I810_FLUSH)
+
+/*
+ Definitions for temporary wire protocol hooks to be replaced
+ when a HW independent libXvMC is created.
+*/
+extern Status _xvmc_create_context(Display *dpy, XvMCContext *context,
+ int *priv_count, uint **priv_data);
+
+extern Status _xvmc_destroy_context(Display *dpy, XvMCContext *context);
+
+extern Status _xvmc_create_surface(Display *dpy, XvMCContext *context,
+ XvMCSurface *surface, int *priv_count,
+ uint **priv_data);
+
+extern Status _xvmc_destroy_surface(Display *dpy, XvMCSurface *surface);
+
+extern Status _xvmc_create_subpicture(Display *dpy, XvMCContext *context,
+ XvMCSubpicture *subpicture,
+ int *priv_count, uint **priv_data);
+
+extern Status _xvmc_destroy_subpicture(Display *dpy,
+ XvMCSubpicture *subpicture);
+
+/*
+ Prototypes
+*/
+drmBufPtr i810_get_free_buffer(i810XvMCContext *pI810XvMC);
+void i810_free_privContext(i810XvMCContext *pI810XvMC);
+void dp(unsigned int *address, unsigned int i);
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nx-X11/lib/XvMC/hw/i810/Imakefile b/nx-X11/lib/XvMC/hw/i810/Imakefile
new file mode 100644
index 000000000..b7956d01e
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/i810/Imakefile
@@ -0,0 +1,44 @@
+XCOMM $XFree86: xc/lib/XvMC/hw/i810/Imakefile,v 1.2 2002/10/30 12:52:02 alanh Exp $
+#define DoNormalLib NormalLibXvMC
+#define DoSharedLib SharedLibXvMC
+#define DoDebugLib DebugLibXvMC
+#define DoProfileLib ProfileLibXvMC
+#define LibName I810XvMC
+#define SoRev SOXVMCREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXvMCReqs
+REQUIREDLIBS = SharedXvMCReqs
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) -DTRUE=1 -DFALSE=0
+ INCLUDES = -I$(XINCLUDESRC) -I$(INCLUDESRC) -I$(XLIBSRC) -I$(EXTINCSRC) \
+ -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86DRIVERSRC)/i810
+ SRCS = I810XvMC.c
+ OBJS = I810XvMC.o xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o
+ LINTLIBS = $(LINTXLIB)
+
+
+#include <Library.tmpl>
+
+
+#if defined(LinuxArchitecture)
+
+LIBDRM_DIR = ../../../../extras/drm/libdrm
+
+LinkSourceFile(xf86drm.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmHash.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmRandom.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmSL.c,$(LIBDRM_DIR))
+
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/XvMC/hw/via/driDrawable.c b/nx-X11/lib/XvMC/hw/via/driDrawable.c
new file mode 100644
index 000000000..35934d89d
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/via/driDrawable.c
@@ -0,0 +1,176 @@
+/*****************************************************************************
+ * driDrawable.c: Lean Version of DRI utilities.
+ *
+ * Copyright (c) 2005 Thomas Hellstrom. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "xf86drm.h"
+#include "drm.h"
+#include "xf86dri.h"
+#include "drm_sarea.h"
+#include "driDrawable.h"
+
+
+static unsigned
+drawStamp(volatile drm_sarea_t *pSarea, int index)
+{
+ return pSarea->drawableTable[index].stamp;
+}
+
+int
+getDRIDrawableInfoLocked(void *drawHash, Display *display, int screen, Drawable draw,
+ unsigned lockFlags, int drmFD, drm_context_t drmContext,
+ drmAddress sarea, Bool updateInfo, drawableInfo **info,
+ unsigned long infoSize)
+{
+ drawableInfo *drawInfo;
+ void *res;
+ drm_drawable_t drmDraw=0;
+ volatile drm_sarea_t *pSarea = (drm_sarea_t *) sarea;
+ drm_clip_rect_t *clipFront, *clipBack;
+
+ int ret;
+
+
+ if (drmHashLookup(drawHash, (unsigned long) draw, &res)) {
+
+ /*
+ * The drawable is unknown to us. Create it and put it in the
+ * hash table.
+ */
+
+ DRM_UNLOCK(drmFD, &pSarea->lock, drmContext);
+ if (!uniDRICreateDrawable(display, screen, draw,
+ &drmDraw)) {
+ DRM_LOCK(drmFD, &pSarea->lock, drmContext, lockFlags);
+ return 1;
+ }
+ DRM_LOCK(drmFD, &pSarea->lock, drmContext, lockFlags);
+
+
+ drawInfo = (drawableInfo *) malloc(infoSize);
+ if (!drawInfo) return 1;
+
+ drawInfo->drmDraw = drmDraw;
+ drawInfo->stamp = 0;
+ drawInfo->clipFront = 0;
+ drawInfo->clipBack = 0;
+
+ drmHashInsert( drawHash, (unsigned long) draw, drawInfo);
+
+ } else {
+ drawInfo = res;
+ }
+
+
+ drawInfo->touched = FALSE;
+ while (!drawInfo->clipFront || drawInfo->stamp != drawStamp(pSarea, drawInfo->index)) {
+
+ /*
+ * The drawable has been touched since we last got info about it.
+ * obtain new info from the X server.
+ */
+
+ drawInfo->touched = TRUE;
+
+ if (updateInfo || !drawInfo->clipFront) {
+ DRM_UNLOCK(drmFD, &pSarea->lock, drmContext);
+
+ ret = uniDRIGetDrawableInfo(display, screen, draw,
+ &drawInfo->index, &drawInfo->stamp, &drawInfo->x,
+ &drawInfo->y, &drawInfo->w, &drawInfo->h,
+ &drawInfo->numClipFront, &clipFront,
+ &drawInfo->backX, &drawInfo->backY,
+ &drawInfo->numClipBack, &clipBack);
+
+ DRM_LIGHT_LOCK(drmFD, &pSarea->lock, drmContext);
+
+ /*
+ * Error. Probably the drawable is destroyed. Return error and old values.
+ */
+
+ if (!ret) {
+ free(drawInfo);
+ drawInfo = NULL;
+ drmHashDelete(drawHash, (unsigned long) draw);
+
+ DRM_UNLOCK(drmFD, &pSarea->lock, drmContext);
+ uniDRIDestroyDrawable( display, screen, draw);
+ DRM_LOCK(drmFD, &pSarea->lock, drmContext, lockFlags);
+
+ return 1;
+ }
+
+ if (drawInfo->stamp != drawStamp(pSarea, drawInfo->index)) {
+
+ /*
+ * The info is already outdated. Sigh. Have another go.
+ */
+
+ XFree(clipFront);
+ XFree(clipBack);
+ continue;
+ }
+
+ if (drawInfo->clipFront) XFree(drawInfo->clipFront);
+ drawInfo->clipFront = clipFront;
+ if (drawInfo->clipBack) XFree(drawInfo->clipBack);
+ drawInfo->clipBack = clipBack;
+ } else {
+ if (!drawInfo->clipFront) drawInfo->clipFront = (drm_clip_rect_t *) ~0UL;
+ drawInfo->stamp = drawStamp(pSarea, drawInfo->index);
+ }
+ }
+ *info = drawInfo;
+ return 0;
+}
+
+void
+driDestroyHashContents(void *drawHash)
+{
+ unsigned long key;
+ void *content;
+ drawableInfo *drawInfo;
+
+
+ if (drmHashFirst(drawHash, &key, &content) < 1)
+ return;
+ drawInfo = (drawableInfo *) content;
+ if (drawInfo->clipBack) XFree(drawInfo->clipBack);
+ if (drawInfo->clipFront) XFree(drawInfo->clipFront);
+ free(drawInfo);
+ while(drmHashNext(drawHash, &key, &content) == 1) {
+ drawInfo = (drawableInfo *) content;
+ if (drawInfo->clipBack) XFree(drawInfo->clipBack);
+ if (drawInfo->clipFront) XFree(drawInfo->clipFront);
+ free(drawInfo);
+ }
+
+ return ;
+}
+
+
diff --git a/nx-X11/lib/XvMC/hw/via/driDrawable.h b/nx-X11/lib/XvMC/hw/via/driDrawable.h
new file mode 100644
index 000000000..e5651058b
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/via/driDrawable.h
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * driDrawable.h: Lean Version of DRI utilities.
+ *
+ * Copyright (c) 2005 Thomas Hellstrom. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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.
+ */
+
+#ifndef _DRIDRAWABLE_H
+#define _DRIDRAWABLE_H
+
+typedef struct _drawableInfo {
+ drm_drawable_t drmDraw;
+ unsigned stamp;
+ unsigned index;
+ drm_clip_rect_t *clipFront;
+ drm_clip_rect_t *clipBack;
+ int x;
+ int y;
+ int w;
+ int h;
+ int backX;
+ int backY;
+ int numClipFront;
+ int numClipBack;
+ Bool touched;
+} drawableInfo;
+
+/*
+ * Get updated info about the drawable "draw". The drawableInfo record returned is malloced
+ * and administrated internally. Never free it unless you know exactly what you are doing.
+ * The drm hash table "drawHash" needs to be initialized externally.
+ */
+
+extern int
+getDRIDrawableInfoLocked (void *drawHash, Display *display, int screen, Drawable draw,
+ unsigned lockFlags, int drmFD, drm_context_t drmContext,
+ drmAddress sarea, Bool updateInfo, drawableInfo **info,
+ unsigned long infoSize);
+
+/*
+ * Free all resources created by the above function. Typically done on exit.
+ */
+
+extern void
+driDestroyHashContents(void *drawHash);
+
+#endif
diff --git a/nx-X11/lib/XvMC/hw/via/unichrome/Imakefile b/nx-X11/lib/XvMC/hw/via/unichrome/Imakefile
new file mode 100644
index 000000000..bc9120972
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/via/unichrome/Imakefile
@@ -0,0 +1,51 @@
+#define DoNormalLib NormalLibXvMC
+#define DoSharedLib SharedLibXvMC
+#define DoDebugLib DebugLibXvMC
+#define DoProfileLib ProfileLibXvMC
+#define LibName viaXvMC
+#define SoRev SOXVMCREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXvMCReqs
+REQUIREDLIBS = SharedXvMCReqs -lXv
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) -DTRUE=1 -DFALSE=0
+ INCLUDES = -I$(XINCLUDESRC) -I$(INCLUDESRC) -I$(XLIBSRC) -I$(EXTINCSRC) \
+ -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86OSSRC)/linux/drm/kernel -I$(XF86DRIVERSRC)/via
+ SRCS = viaLowLevel.c
+ OBJS = viaXvMC.o viaLowLevel.o xf86drm.o xf86drmHash.o \
+ xf86drmRandom.o xf86drmSL.o xf86dri.o driDrawable.o
+ LINTLIBS = $(LINTXLIB)
+
+
+#include <Library.tmpl>
+
+
+#if defined(LinuxArchitecture)
+
+LIBDRM_DIR = ../../../../../extras/drm/libdrm
+
+LinkSourceFile(xf86drm.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmHash.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmRandom.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmSL.c,$(LIBDRM_DIR))
+LinkSourceFile(viaLowLevel.h,..)
+LinkSourceFile(driDrawable.h,..)
+LinkSourceFile(viaXvMCPriv.h,..)
+LinkSourceFile(xf86dri.h,..)
+LinkSourceFile(xf86dristr.h,..)
+LinkSourceFile(xf86dri.c,..)
+LinkSourceFile(driDrawable.c,..)
+LinkSourceFile(viaXvMC.c,..)
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/XvMC/hw/via/unichrome/viaLowLevel.c b/nx-X11/lib/XvMC/hw/via/unichrome/viaLowLevel.c
new file mode 100644
index 000000000..1add1ca5d
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/via/unichrome/viaLowLevel.c
@@ -0,0 +1,1056 @@
+/*****************************************************************************
+ * VIA Unichrome XvMC extension client lib.
+ *
+ * Copyright (c) 2004 Thomas Hellström. All rights reserved.
+ * Copyright (c) 2003 Andreas Robinson. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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.
+ */
+
+
+/*
+ * Low-level functions that deal directly with the hardware. In the future,
+ * these functions might be implemented in a kernel module. Also, some of them
+ * would benefit from DMA.
+ *
+ * Authors: Andreas Robinson 2003. Thomas Hellström 2004.
+ */
+
+
+
+#include "viaXvMCPriv.h"
+#include "viaLowLevel.h"
+#include <time.h>
+#include <sys/time.h>
+#include <stdio.h>
+
+typedef struct{
+ CARD32 agp_buffer[LL_AGP_CMDBUF_SIZE];
+ CARD32 pci_buffer[LL_PCI_CMDBUF_SIZE];
+ unsigned agp_pos;
+ unsigned pci_pos;
+ unsigned flip_pos;
+ int use_agp;
+ int agp_mode;
+ int agp_header_start;
+ int agp_index;
+ int fd;
+ drm_context_t *drmcontext;
+ drmLockPtr hwLock;
+ drmAddress mmioAddress;
+ drmAddress fbAddress;
+ unsigned fbStride;
+ unsigned fbDepth;
+ unsigned width;
+ unsigned height;
+ unsigned curWaitFlags;
+ int performLocking;
+ unsigned errors;
+ drm_via_mem_t tsMem;
+ CARD32 tsOffset;
+ volatile CARD32 *tsP;
+ CARD32 curTimeStamp;
+ CARD32 lastReadTimeStamp;
+ int agpSync;
+ CARD32 agpSyncTimeStamp;
+ unsigned chipId;
+}XvMCLowLevel;
+
+
+
+
+
+/*
+ * For Other architectures than i386 these might have to be modified for
+ * bigendian etc.
+ */
+
+#define MPEGIN(xl,reg) \
+ *((volatile CARD32 *)(((CARD8 *)(xl)->mmioAddress) + 0xc00 + (reg)))
+
+#define VIDIN(ctx,reg) \
+ *((volatile CARD32 *)(((CARD8 *)(ctx)->mmioAddress) + 0x200 + (reg)))
+
+#define REGIN(ctx,reg) \
+ *((volatile CARD32 *)(((CARD8 *)(ctx)->mmioAddress) + 0x0000 + (reg)))
+
+#define HQV_CONTROL 0x1D0
+#define HQV_SRC_STARTADDR_Y 0x1D4
+#define HQV_SRC_STARTADDR_U 0x1D8
+#define HQV_SRC_STARTADDR_V 0x1DC
+#define HQV_MINIFY_DEBLOCK 0x1E8
+
+#define HQV_SW_FLIP 0x00000010
+#define HQV_FLIP_STATUS 0x00000001
+#define HQV_SUBPIC_FLIP 0x00008000
+#define HQV_FLIP_ODD 0x00000020
+#define HQV_DEINTERLACE 0x00010000
+#define HQV_FIELD_2_FRAME 0x00020000
+#define HQV_FRAME_2_FIELD 0x00040000
+#define HQV_FIELD_UV 0x00100000
+#define HQV_DEBLOCK_HOR 0x00008000
+#define HQV_DEBLOCK_VER 0x80000000
+
+#define V_COMPOSE_MODE 0x98
+#define V1_COMMAND_FIRE 0x80000000
+#define V3_COMMAND_FIRE 0x40000000
+
+/* SUBPICTURE Registers */
+#define SUBP_CONTROL_STRIDE 0x1C0
+#define SUBP_STARTADDR 0x1C4
+#define RAM_TABLE_CONTROL 0x1C8
+#define RAM_TABLE_READ 0x1CC
+
+/* SUBP_CONTROL_STRIDE 0x3c0 */
+#define SUBP_HQV_ENABLE 0x00010000
+#define SUBP_IA44 0x00020000
+#define SUBP_AI44 0x00000000
+#define SUBP_STRIDE_MASK 0x00001fff
+#define SUBP_CONTROL_MASK 0x00070000
+
+/* RAM_TABLE_CONTROL 0x3c8 */
+#define RAM_TABLE_RGB_ENABLE 0x00000007
+
+
+#define VIA_REG_STATUS 0x400
+#define VIA_REG_GEMODE 0x004
+#define VIA_REG_SRCBASE 0x030
+#define VIA_REG_DSTBASE 0x034
+#define VIA_REG_PITCH 0x038
+#define VIA_REG_SRCCOLORKEY 0x01C
+#define VIA_REG_KEYCONTROL 0x02C
+#define VIA_REG_SRCPOS 0x008
+#define VIA_REG_DSTPOS 0x00C
+#define VIA_REG_GECMD 0x000
+#define VIA_REG_DIMENSION 0x010 /* width and height */
+#define VIA_REG_FGCOLOR 0x018
+
+
+#define VIA_VR_QUEUE_BUSY 0x00020000 /* Virtual Queue is busy */
+#define VIA_CMD_RGTR_BUSY 0x00000080 /* Command Regulator is busy */
+#define VIA_2D_ENG_BUSY 0x00000001 /* 2D Engine is busy */
+#define VIA_3D_ENG_BUSY 0x00000002 /* 3D Engine is busy */
+#define VIA_GEM_8bpp 0x00000000
+#define VIA_GEM_16bpp 0x00000100
+#define VIA_GEM_32bpp 0x00000300
+#define VIA_GEC_BLT 0x00000001
+#define VIA_PITCH_ENABLE 0x80000000
+#define VIA_GEC_INCX 0x00000000
+#define VIA_GEC_DECY 0x00004000
+#define VIA_GEC_INCY 0x00000000
+#define VIA_GEC_DECX 0x00008000
+#define VIA_GEC_FIXCOLOR_PAT 0x00002000
+
+
+#define VIA_BLIT_CLEAR 0x00
+#define VIA_BLIT_COPY 0xCC
+#define VIA_BLIT_FILL 0xF0
+#define VIA_BLIT_SET 0xFF
+
+#define VIA_SYNCWAITTIMEOUT 50000 /* Might be a bit conservative */
+#define VIA_DMAWAITTIMEOUT 150000
+#define VIA_VIDWAITTIMEOUT 50000
+#define VIA_XVMC_DECODERTIMEOUT 50000 /*(microseconds)*/
+
+#define H1_ADDR(val) (((val) >> 2) | 0xF0000000)
+#define WAITFLAGS(xl, flags) \
+ (xl)->curWaitFlags |= (flags)
+#define BEGIN_RING_AGP(xl,size) \
+ do { \
+ if ((xl)->agp_pos > (LL_AGP_CMDBUF_SIZE-(size))) { \
+ agpFlush(xl); \
+ } \
+ } while(0)
+#define OUT_RING_AGP(xl, val) \
+ (xl)->agp_buffer[(xl)->agp_pos++] = (val)
+#define OUT_RING_QW_AGP(xl, val1, val2) \
+ do { \
+ (xl)->agp_buffer[(xl)->agp_pos++] = (val1); \
+ (xl)->agp_buffer[(xl)->agp_pos++] = (val2); \
+ } while (0)
+
+
+#define LL_HW_LOCK(xl) \
+ do { \
+ DRM_LOCK((xl)->fd,(xl)->hwLock,*(xl)->drmcontext,0); \
+ } while(0);
+#define LL_HW_UNLOCK(xl) \
+ do { \
+ DRM_UNLOCK((xl)->fd,(xl)->hwLock,*(xl)->drmcontext); \
+ } while(0);
+
+
+/*
+ * We want to have two concurrent types of thread taking the hardware
+ * lock simulataneously. One is the video out thread that needs immediate
+ * access to flip an image. The other is everything else which may have
+ * the lock for quite some time. This is only so the video out thread can
+ * sneak in and display an image while other resources are busy.
+ */
+
+
+void
+hwlLock(void *xlp, int videoLock)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ LL_HW_LOCK(xl);
+}
+
+void
+hwlUnlock(void *xlp, int videoLock)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ LL_HW_UNLOCK(xl);
+}
+
+static unsigned
+timeDiff(struct timeval *now,struct timeval *then) {
+ return (now->tv_usec >= then->tv_usec) ?
+ now->tv_usec - then->tv_usec :
+ 1000000 - (then->tv_usec - now->tv_usec);
+}
+
+void
+setAGPSyncLowLevel(void *xlp, int val, CARD32 timeStamp)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ xl->agpSync = val;
+ xl->agpSyncTimeStamp = timeStamp;
+}
+
+CARD32
+viaDMATimeStampLowLevel(void *xlp)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ if (xl->use_agp) {
+ viaBlit(xl, 32, xl->tsOffset, 1, xl->tsOffset, 1, 1, 1, 0, 0,
+ VIABLIT_FILL, xl->curTimeStamp);
+ return xl->curTimeStamp++;
+ }
+ return 0;
+}
+
+static void
+viaDMAWaitTimeStamp(XvMCLowLevel *xl, CARD32 timeStamp, int doSleep)
+{
+ struct timeval now, then;
+ struct timezone here;
+ struct timespec sleep, rem;
+
+ if (xl->use_agp && (timeStamp > xl->lastReadTimeStamp)) {
+ sleep.tv_nsec = 1;
+ sleep.tv_sec = 0;
+ here.tz_minuteswest = 0;
+ here.tz_dsttime = 0;
+ gettimeofday(&then,&here);
+
+ while(timeStamp > (xl->lastReadTimeStamp = *xl->tsP)) {
+ gettimeofday(&now,&here);
+ if (timeDiff(&now,&then) > VIA_DMAWAITTIMEOUT) {
+ if((timeStamp > (xl->lastReadTimeStamp = *xl->tsP))) {
+ xl->errors |= LL_DMA_TIMEDOUT;
+ break;
+ }
+ }
+ if (doSleep) nanosleep(&sleep, &rem);
+ }
+ }
+}
+
+static int
+viaDMAInitTimeStamp(XvMCLowLevel *xl)
+{
+ int ret = 0;
+
+ if (xl->use_agp) {
+ xl->tsMem.context = *(xl->drmcontext);
+ xl->tsMem.size = 64;
+ xl->tsMem.type = VIA_MEM_VIDEO;
+ if (drmCommandWriteRead(xl->fd, DRM_VIA_ALLOCMEM, &xl->tsMem, sizeof(xl->tsMem)) < 0)
+ return ret;
+ if (xl->tsMem.size != 64)
+ return -1;
+ xl->tsOffset = (xl->tsMem.offset + 31) & ~31;
+ xl->tsP = (CARD32 *)xl->fbAddress + (xl->tsOffset >> 2);
+ xl->curTimeStamp = 1;
+ *xl->tsP = 0;
+ }
+ return 0;
+}
+
+static int
+viaDMACleanupTimeStamp(XvMCLowLevel *xl)
+{
+
+ if (!(xl->tsMem.size) || !xl->use_agp) return 0;
+ return drmCommandWrite(xl->fd, DRM_VIA_FREEMEM, &xl->tsMem, sizeof(xl->tsMem));
+}
+
+
+static CARD32
+viaMpegGetStatus(XvMCLowLevel *xl)
+{
+ return MPEGIN(xl,0x54);
+}
+
+static int
+viaMpegIsBusy(XvMCLowLevel *xl, CARD32 mask, CARD32 idle)
+{
+ CARD32 tmp = viaMpegGetStatus(xl);
+
+ /*
+ * Error detected.
+ * FIXME: Are errors really shown when error concealment is on?
+ */
+
+ if (tmp & 0x70) return 0;
+
+ return (tmp & mask) != idle;
+}
+
+
+static void
+syncDMA(XvMCLowLevel *xl, unsigned int doSleep)
+{
+
+ /*
+ * Ideally, we'd like to have an interrupt wait here, but, according to second hand
+ * information, the hardware does not support this, although earlier S3 chips do that.
+ * It is therefore not implemented into the DRM, and we'll do a user space wait here.
+ */
+
+ struct timeval now, then;
+ struct timezone here;
+ struct timespec sleep, rem;
+
+ sleep.tv_nsec = 1;
+ sleep.tv_sec = 0;
+ here.tz_minuteswest = 0;
+ here.tz_dsttime = 0;
+ gettimeofday(&then,&here);
+ while( !(REGIN(xl, VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY)) {
+ gettimeofday(&now,&here);
+ if (timeDiff(&now,&then) > VIA_DMAWAITTIMEOUT) {
+ if( !(REGIN(xl, VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY)) {
+ xl->errors |= LL_DMA_TIMEDOUT;
+ break;
+ }
+ }
+ if (doSleep) nanosleep(&sleep, &rem);
+ }
+ while( REGIN(xl, VIA_REG_STATUS) & VIA_CMD_RGTR_BUSY ) {
+ gettimeofday(&now,&here);
+ if (timeDiff(&now,&then) > VIA_DMAWAITTIMEOUT) {
+ if( REGIN(xl, VIA_REG_STATUS) & VIA_CMD_RGTR_BUSY ) {
+ xl->errors |= LL_DMA_TIMEDOUT;
+ break;
+ }
+ }
+ if (doSleep) nanosleep(&sleep, &rem);
+ }
+}
+
+static void
+syncVideo(XvMCLowLevel *xl, unsigned int doSleep)
+{
+ /*
+ * Wait for HQV completion. Nothing strange here. We assume that the HQV
+ * Handles syncing to the V1 / V3 engines by itself. It should be safe to
+ * always wait for SUBPIC_FLIP completion although subpictures are not always
+ * used.
+ */
+
+ struct timeval now, then;
+ struct timezone here;
+ struct timespec sleep, rem;
+
+ sleep.tv_nsec = 1;
+ sleep.tv_sec = 0;
+ here.tz_minuteswest = 0;
+ here.tz_dsttime = 0;
+ gettimeofday(&then,&here);
+ while(VIDIN(xl, HQV_CONTROL) & (HQV_SW_FLIP | HQV_SUBPIC_FLIP)) {
+ gettimeofday(&now,&here);
+ if (timeDiff(&now,&then) > VIA_SYNCWAITTIMEOUT) {
+ if(VIDIN(xl, HQV_CONTROL) & (HQV_SW_FLIP | HQV_SUBPIC_FLIP)) {
+ xl->errors |= LL_VIDEO_TIMEDOUT;
+ break;
+ }
+ }
+ if (doSleep) nanosleep(&sleep, &rem);
+ }
+}
+
+static void
+syncAccel(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep)
+{
+ struct timeval now, then;
+ struct timezone here;
+ struct timespec sleep, rem;
+ CARD32 mask = ((mode & LL_MODE_2D) ? VIA_2D_ENG_BUSY : 0) |
+ ((mode & LL_MODE_3D) ? VIA_3D_ENG_BUSY : 0);
+
+ sleep.tv_nsec = 1;
+ sleep.tv_sec = 0;
+ here.tz_minuteswest = 0;
+ here.tz_dsttime = 0;
+ gettimeofday(&then,&here);
+ while( REGIN(xl, VIA_REG_STATUS) & mask) {
+ gettimeofday(&now,&here);
+ if (timeDiff(&now,&then) > VIA_SYNCWAITTIMEOUT) {
+ if( REGIN(xl, VIA_REG_STATUS) & mask) {
+ xl->errors |= LL_ACCEL_TIMEDOUT;
+ break;
+ }
+ }
+ if (doSleep) nanosleep(&sleep, &rem);
+ }
+}
+
+
+static void
+syncMpeg(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep)
+{
+ /*
+ * Ideally, we'd like to have an interrupt wait here, but from information from VIA
+ * at least the MPEG completion interrupt is broken on the CLE266, which was
+ * discovered during validation of the chip.
+ */
+
+ struct timeval now, then;
+ struct timezone here;
+ struct timespec sleep, rem;
+ CARD32 busyMask = 0;
+ CARD32 idleVal = 0;
+ CARD32 ret;
+
+ sleep.tv_nsec = 1;
+ sleep.tv_sec = 0;
+ here.tz_minuteswest = 0;
+ here.tz_dsttime = 0;
+ gettimeofday(&then,&here);
+ if (mode & LL_MODE_DECODER_SLICE) {
+ busyMask = VIA_SLICEBUSYMASK;
+ idleVal = VIA_SLICEIDLEVAL;
+ }
+ if (mode & LL_MODE_DECODER_IDLE) {
+ busyMask |= VIA_BUSYMASK;
+ idleVal = VIA_IDLEVAL;
+ }
+ while(viaMpegIsBusy(xl, busyMask, idleVal)) {
+ gettimeofday(&now,&here);
+ if (timeDiff(&now,&then) > VIA_XVMC_DECODERTIMEOUT) {
+ if (viaMpegIsBusy(xl, busyMask, idleVal)) {
+ xl->errors |= LL_DECODER_TIMEDOUT;
+ }
+ break;
+ }
+ if (doSleep) nanosleep(&sleep, &rem);
+ }
+
+ ret = viaMpegGetStatus(xl);
+ if (ret & 0x70) {
+ xl->errors |= ((ret & 0x70) >> 3);
+ }
+ return;
+}
+
+static void
+pciFlush(XvMCLowLevel *xl)
+{
+ int ret;
+ drm_via_cmdbuffer_t b;
+ unsigned mode=xl->curWaitFlags;
+
+ b.buf = (char *)xl->pci_buffer;
+ b.size = xl->pci_pos * sizeof(CARD32);
+ if (xl->performLocking) hwlLock(xl,0);
+ if ((mode != LL_MODE_VIDEO) && (mode != 0))
+ syncDMA(xl, 0);
+ if ((mode & LL_MODE_2D) || (mode & LL_MODE_3D))
+ syncAccel(xl, mode, 0);
+ if (mode & LL_MODE_VIDEO)
+ syncVideo(xl, 0);
+ if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE))
+ syncMpeg(xl, mode, 0);
+ ret = drmCommandWrite(xl->fd, DRM_VIA_PCICMD, &b, sizeof(b));
+ if (xl->performLocking) hwlUnlock(xl,0);
+ if (ret) {
+ xl->errors |= LL_PCI_COMMAND_ERR;
+ }
+ xl->pci_pos = 0;
+ xl->curWaitFlags = 0;
+}
+
+static void
+agpFlush(XvMCLowLevel *xl)
+{
+ drm_via_cmdbuffer_t b;
+ int ret;
+
+ if (xl->use_agp) {
+ b.buf = (char *)xl->agp_buffer;
+ b.size = xl->agp_pos * sizeof(CARD32);
+ if (xl->agpSync) {
+ syncXvMCLowLevel(xl, LL_MODE_DECODER_IDLE, 1, xl->agpSyncTimeStamp);
+ xl->agpSync = 0;
+ }
+ if (xl->performLocking) hwlLock(xl,0);
+ do {
+ ret = drmCommandWrite(xl->fd, DRM_VIA_CMDBUFFER, &b, sizeof(b));
+ } while (-EAGAIN == ret);
+ if (xl->performLocking) hwlUnlock(xl,0);
+
+ if (ret) {
+ xl->errors |= LL_AGP_COMMAND_ERR;
+ } else {
+ xl->agp_pos = 0;
+ }
+ xl->curWaitFlags &= LL_MODE_VIDEO;
+ } else {
+ unsigned mode=xl->curWaitFlags;
+
+ b.buf = (char *)xl->agp_buffer;
+ b.size = xl->agp_pos * sizeof(CARD32);
+ if (xl->performLocking) hwlLock(xl,0);
+ if ((mode != LL_MODE_VIDEO) && (mode != 0))
+ syncDMA(xl, 0);
+ if ((mode & LL_MODE_2D) || (mode & LL_MODE_3D))
+ syncAccel(xl, mode, 0);
+ if (mode & LL_MODE_VIDEO)
+ syncVideo(xl, 0);
+ if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE))
+ syncMpeg(xl, mode, 0);
+ ret = drmCommandWrite(xl->fd, DRM_VIA_PCICMD, &b, sizeof(b));
+ if (xl->performLocking) hwlUnlock(xl,0);
+ if (ret) {
+ xl->errors |= LL_PCI_COMMAND_ERR;
+ }
+ xl->agp_pos = 0;
+ xl->curWaitFlags = 0;
+ }
+}
+
+unsigned
+flushXvMCLowLevel(void *xlp)
+{
+ unsigned
+ errors;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ if(xl->pci_pos) pciFlush(xl);
+ if(xl->agp_pos) agpFlush(xl);
+ errors = xl->errors;
+ xl->errors = 0;
+ return errors;
+}
+
+void
+flushPCIXvMCLowLevel(void *xlp)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ if(xl->pci_pos) pciFlush(xl);
+ if (!xl->use_agp && xl->agp_pos) agpFlush(xl);
+}
+
+
+__inline static void pciCommand(XvMCLowLevel *xl, unsigned offset, unsigned value, unsigned flags)
+{
+ if (xl->pci_pos > (LL_PCI_CMDBUF_SIZE-2)) pciFlush(xl);
+ if (flags) xl->curWaitFlags |= flags;
+ xl->pci_buffer[xl->pci_pos++] = (offset >> 2) | 0xF0000000;
+ xl->pci_buffer[xl->pci_pos++] = value;
+}
+
+void
+viaMpegSetSurfaceStride(void *xlp, ViaXvMCContext *ctx)
+{
+ CARD32 y_stride = ctx->yStride;
+ CARD32 uv_stride = y_stride >> 1;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+
+ BEGIN_RING_AGP(xl, 2);
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc50), (y_stride >> 3) | ((uv_stride >> 3) << 16));
+ WAITFLAGS(xl, LL_MODE_DECODER_IDLE);
+}
+
+
+void
+viaVideoSetSWFLipLocked(void *xlp, unsigned yOffs, unsigned uOffs,
+ unsigned vOffs, unsigned yStride, unsigned uvStride)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ pciCommand(xl,HQV_SRC_STARTADDR_Y | 0x200,yOffs,LL_MODE_VIDEO);
+ pciCommand(xl,HQV_SRC_STARTADDR_U | 0x200,uOffs,0);
+ pciCommand(xl,HQV_SRC_STARTADDR_V | 0x200,vOffs,0);
+}
+
+void
+viaVideoSWFlipLocked(void *xlp, unsigned flags,
+ int progressiveSequence)
+{
+ CARD32 andWd,orWd;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ andWd = 0;
+ orWd = 0;
+
+ if ((flags & XVMC_FRAME_PICTURE) == XVMC_BOTTOM_FIELD) {
+ andWd = 0xFFFFFFFFU;
+ orWd = HQV_FIELD_UV |
+ HQV_DEINTERLACE |
+ HQV_FIELD_2_FRAME |
+ HQV_FRAME_2_FIELD |
+ HQV_SW_FLIP |
+ HQV_FLIP_ODD |
+ HQV_FLIP_STATUS |
+ HQV_SUBPIC_FLIP;
+ } else if ((flags & XVMC_FRAME_PICTURE) == XVMC_TOP_FIELD) {
+ andWd = ~HQV_FLIP_ODD;
+ orWd = HQV_FIELD_UV |
+ HQV_DEINTERLACE |
+ HQV_FIELD_2_FRAME |
+ HQV_FRAME_2_FIELD |
+ HQV_SW_FLIP |
+ HQV_FLIP_STATUS |
+ HQV_SUBPIC_FLIP;
+ } else if ((flags & XVMC_FRAME_PICTURE) == XVMC_FRAME_PICTURE) {
+ andWd = ~(HQV_DEINTERLACE |
+ HQV_FRAME_2_FIELD |
+ HQV_FIELD_2_FRAME |
+ HQV_FIELD_UV);
+ orWd = HQV_SW_FLIP |
+ HQV_FLIP_STATUS |
+ HQV_SUBPIC_FLIP;
+ }
+ if (progressiveSequence) {
+ andWd &= ~HQV_FIELD_UV;
+ orWd &= ~HQV_FIELD_UV;
+ }
+
+ pciCommand(xl,HQV_CONTROL | 0x200,(VIDIN(xl,HQV_CONTROL) & andWd) | orWd, 0);
+}
+
+void
+viaMpegSetFB(void *xlp,unsigned i,
+ unsigned yOffs,
+ unsigned uOffs,
+ unsigned vOffs)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ i *= 12;
+ BEGIN_RING_AGP(xl, 6);
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc20 + i), yOffs >> 3);
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc24 + i), uOffs >> 3);
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc28 + i), vOffs >> 3);
+ WAITFLAGS(xl, LL_MODE_DECODER_IDLE);
+}
+
+void
+viaMpegBeginPicture(void *xlp,ViaXvMCContext *ctx,
+ unsigned width,
+ unsigned height,
+ const XvMCMpegControl *control) {
+
+ unsigned j, mb_width, mb_height;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ mb_width = (width + 15) >> 4;
+
+ mb_height =
+ ((control->mpeg_coding == XVMC_MPEG_2) &&
+ (control->flags & XVMC_PROGRESSIVE_SEQUENCE)) ?
+ 2*((height+31) >> 5) : (((height+15) >> 4));
+
+ BEGIN_RING_AGP(xl, 144);
+ WAITFLAGS(xl, LL_MODE_DECODER_IDLE);
+
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc00),
+ ((control->picture_structure & XVMC_FRAME_PICTURE) << 2) |
+ ((control->picture_coding_type & 3) << 4) |
+ ((control->flags & XVMC_ALTERNATE_SCAN) ? (1 << 6) : 0));
+
+ if (!(ctx->intraLoaded)) {
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc5c), 0);
+ for (j = 0; j < 64; j += 4) {
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc60),
+ ctx->intra_quantiser_matrix[j] |
+ (ctx->intra_quantiser_matrix[j+1] << 8) |
+ (ctx->intra_quantiser_matrix[j+2] << 16) |
+ (ctx->intra_quantiser_matrix[j+3] << 24));
+ }
+ ctx->intraLoaded = 1;
+ }
+
+ if (!(ctx->nonIntraLoaded)) {
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc5c), 1);
+ for (j = 0; j < 64; j += 4) {
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc60),
+ ctx->non_intra_quantiser_matrix[j] |
+ (ctx->non_intra_quantiser_matrix[j+1] << 8) |
+ (ctx->non_intra_quantiser_matrix[j+2] << 16) |
+ (ctx->non_intra_quantiser_matrix[j+3] << 24));
+ }
+ ctx->nonIntraLoaded = 1;
+ }
+
+ if (!(ctx->chromaIntraLoaded)) {
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc5c), 2);
+ for (j = 0; j < 64; j += 4) {
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc60),
+ ctx->chroma_intra_quantiser_matrix[j] |
+ (ctx->chroma_intra_quantiser_matrix[j+1] << 8) |
+ (ctx->chroma_intra_quantiser_matrix[j+2] << 16) |
+ (ctx->chroma_intra_quantiser_matrix[j+3] << 24));
+ }
+ ctx->chromaIntraLoaded = 1;
+ }
+
+ if (!(ctx->chromaNonIntraLoaded)) {
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc5c), 3);
+ for (j = 0; j < 64; j += 4) {
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc60),
+ ctx->chroma_non_intra_quantiser_matrix[j] |
+ (ctx->chroma_non_intra_quantiser_matrix[j+1] << 8) |
+ (ctx->chroma_non_intra_quantiser_matrix[j+2] << 16) |
+ (ctx->chroma_non_intra_quantiser_matrix[j+3] << 24));
+ }
+ ctx->chromaNonIntraLoaded = 1;
+ }
+
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc90),
+ ((mb_width * mb_height) & 0x3fff) |
+ ((control->flags & XVMC_PRED_DCT_FRAME) ? ( 1 << 14) : 0) |
+ ((control->flags & XVMC_TOP_FIELD_FIRST) ? (1 << 15) : 0 ) |
+ ((control->mpeg_coding == XVMC_MPEG_2) ? (1 << 16) : 0) |
+ ((mb_width & 0xff) << 18));
+
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc94),
+ ((control->flags & XVMC_CONCEALMENT_MOTION_VECTORS) ? 1 : 0) |
+ ((control->flags & XVMC_Q_SCALE_TYPE) ? 2 : 0) |
+ ((control->intra_dc_precision & 3) << 2) |
+ (((1 + 0x100000 / mb_width) & 0xfffff) << 4) |
+ ((control->flags & XVMC_INTRA_VLC_FORMAT) ? (1 << 24) : 0));
+
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc98),
+ (((control->FHMV_range) & 0xf) << 0) |
+ (((control->FVMV_range) & 0xf) << 4) |
+ (((control->BHMV_range) & 0xf) << 8) |
+ (((control->BVMV_range) & 0xf) << 12) |
+ ((control->flags & XVMC_SECOND_FIELD) ? (1 << 20) : 0) |
+ (0x0a6 << 16));
+
+}
+
+
+
+void
+viaMpegReset(void *xlp)
+{
+ int i,j;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ BEGIN_RING_AGP(xl, 100);
+ WAITFLAGS(xl, LL_MODE_DECODER_IDLE);
+
+ for (i = 0; i < 14; i++)
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc08) ,0);
+
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc98), 0x400000);
+
+ for (i = 0; i < 6; i++) {
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc0c), 0x43 | 0x20);
+ for (j = 0xc10; j < 0xc20; j += 4)
+ OUT_RING_QW_AGP(xl, H1_ADDR(j), 0);
+ }
+
+
+ OUT_RING_QW_AGP(xl,H1_ADDR(0xc0c), 0xc3 | 0x20);
+ for (j = 0xc10; j < 0xc20; j += 4)
+ OUT_RING_QW_AGP(xl,H1_ADDR(j),0);
+
+}
+
+void
+viaMpegWriteSlice(void *xlp, CARD8* slice, int nBytes, CARD32 sCode)
+{
+ int i, n, r;
+ CARD32* buf;
+ int count;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+
+ if (xl->errors & (LL_DECODER_TIMEDOUT |
+ LL_IDCT_FIFO_ERROR |
+ LL_SLICE_FIFO_ERROR |
+ LL_SLICE_FAULT)) return;
+
+ n = nBytes >> 2;
+ if (sCode) nBytes += 4;
+ r = nBytes & 3;
+ buf = (CARD32*) slice;
+
+ if (r) nBytes += 4 - r;
+
+ nBytes += 8;
+
+ BEGIN_RING_AGP(xl, 4);
+ WAITFLAGS(xl, LL_MODE_DECODER_IDLE);
+
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xc9c), nBytes);
+
+ if (sCode) OUT_RING_QW_AGP(xl, H1_ADDR(0xca0), sCode);
+
+ i = 0;
+ count = 0;
+
+ do {
+ count += (LL_AGP_CMDBUF_SIZE -20) >> 1;
+ count = (count > n) ? n : count;
+ BEGIN_RING_AGP(xl, (count - i) << 1);
+
+ for (; i < count; i++) {
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xca0), *buf++);
+ }
+ } while (i < n);
+
+ BEGIN_RING_AGP(xl, 6);
+
+ if (r) {
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xca0), *buf & ((1 << (r << 3)) - 1));
+ }
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xca0), 0);
+ OUT_RING_QW_AGP(xl, H1_ADDR(0xca0), 0);
+
+}
+
+void
+viaVideoSubPictureOffLocked(void *xlp) {
+
+ CARD32 stride;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+
+ stride = VIDIN(xl,SUBP_CONTROL_STRIDE);
+
+ pciCommand(xl, SUBP_CONTROL_STRIDE | 0x200, stride & ~SUBP_HQV_ENABLE,LL_MODE_VIDEO);
+}
+
+void
+viaVideoSubPictureLocked(void *xlp,ViaXvMCSubPicture *pViaSubPic) {
+
+ unsigned i;
+ CARD32 cWord;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+
+ for (i=0; i<VIA_SUBPIC_PALETTE_SIZE; ++i) {
+ pciCommand(xl, RAM_TABLE_CONTROL | 0x200, pViaSubPic->palette[i],LL_MODE_VIDEO);
+ }
+
+ pciCommand(xl, SUBP_STARTADDR | 0x200, pViaSubPic->offset, 0);
+ cWord = (pViaSubPic->stride & SUBP_STRIDE_MASK) | SUBP_HQV_ENABLE;
+ cWord |= (pViaSubPic->ia44) ? SUBP_IA44 : SUBP_AI44;
+ pciCommand(xl, SUBP_CONTROL_STRIDE | 0x200, cWord, 0);
+}
+
+void
+viaBlit(void *xlp,unsigned bpp,unsigned srcBase,
+ unsigned srcPitch,unsigned dstBase,unsigned dstPitch,
+ unsigned w,unsigned h,int xdir,int ydir, unsigned blitMode,
+ unsigned color)
+{
+
+ CARD32 dwGEMode = 0, srcY=0, srcX, dstY=0, dstX;
+ CARD32 cmd;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+
+ if (!w || !h)
+ return;
+
+ switch (bpp) {
+ case 16:
+ dwGEMode |= VIA_GEM_16bpp;
+ break;
+ case 32:
+ dwGEMode |= VIA_GEM_32bpp;
+ break;
+ default:
+ dwGEMode |= VIA_GEM_8bpp;
+ break;
+ }
+
+ srcX = srcBase & 31;
+ dstX = dstBase & 31;
+ switch (bpp) {
+ case 16:
+ dwGEMode |= VIA_GEM_16bpp;
+ srcX >>= 2;
+ dstX >>= 2;
+ break;
+ case 32:
+ dwGEMode |= VIA_GEM_32bpp;
+ srcX >>= 4;
+ dstX >>= 4;
+ break;
+ default:
+ dwGEMode |= VIA_GEM_8bpp;
+ break;
+ }
+
+ BEGIN_RING_AGP(xl, 20);
+ WAITFLAGS(xl, LL_MODE_2D);
+
+
+ OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_GEMODE), dwGEMode);
+ cmd = 0;
+
+ if (xdir < 0) {
+ cmd |= VIA_GEC_DECX;
+ srcX += (w - 1);
+ dstX += (w - 1);
+ }
+ if (ydir < 0) {
+ cmd |= VIA_GEC_DECY;
+ srcY += (h - 1);
+ dstY += (h - 1);
+ }
+
+ switch(blitMode) {
+ case VIABLIT_TRANSCOPY:
+ OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_SRCCOLORKEY), color);
+ OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_KEYCONTROL), 0x4000);
+ cmd |= VIA_GEC_BLT | (VIA_BLIT_COPY << 24);
+ break;
+ case VIABLIT_FILL:
+ OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_FGCOLOR), color);
+ cmd |= VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | (VIA_BLIT_FILL << 24);
+ break;
+ default:
+ OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_KEYCONTROL), 0x0);
+ cmd |= VIA_GEC_BLT | (VIA_BLIT_COPY << 24);
+ }
+
+ OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_SRCBASE), (srcBase & ~31) >> 3);
+ OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_DSTBASE), (dstBase & ~31) >> 3);
+ OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_PITCH), VIA_PITCH_ENABLE |
+ (srcPitch >> 3) | (((dstPitch) >> 3) << 16));
+ OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_SRCPOS), ((srcY << 16) | srcX));
+ OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_DSTPOS), ((dstY << 16) | dstX));
+ OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_DIMENSION), (((h - 1) << 16) | (w - 1)));
+ OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_GECMD), cmd);
+}
+
+unsigned
+syncXvMCLowLevel(void *xlp, unsigned int mode, unsigned int doSleep,
+ CARD32 timeStamp)
+{
+ unsigned
+ errors;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ if (mode == 0) {
+ errors = xl->errors;
+ xl->errors = 0;
+ return errors;
+ }
+
+ if ((mode & (LL_MODE_VIDEO | LL_MODE_3D)) || !xl->use_agp) {
+ if (xl->performLocking)
+ hwlLock(xl,0);
+ if ((mode != LL_MODE_VIDEO))
+ syncDMA(xl, doSleep);
+ if (mode & LL_MODE_3D)
+ syncAccel(xl, mode, doSleep);
+ if (mode & LL_MODE_VIDEO)
+ syncVideo(xl, doSleep);
+ if (xl->performLocking)
+ hwlUnlock(xl,0);
+ } else {
+ viaDMAWaitTimeStamp(xl, timeStamp, doSleep);
+ }
+
+ if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE))
+ syncMpeg(xl, mode, doSleep);
+
+ errors = xl->errors;
+ xl->errors = 0;
+
+ return errors;
+}
+
+
+extern void
+*initXvMCLowLevel(int fd, drm_context_t *ctx,
+ drmLockPtr hwLock, drmAddress mmioAddress,
+ drmAddress fbAddress, unsigned fbStride, unsigned fbDepth,
+ unsigned width, unsigned height, int useAgp, unsigned chipId )
+
+{
+ int ret;
+
+ XvMCLowLevel *xl = (XvMCLowLevel *)malloc(sizeof(XvMCLowLevel));
+ if (!xl) return NULL;
+
+ xl->agp_pos = 0;
+ xl->pci_pos = 0;
+ xl->use_agp = useAgp;
+ xl->fd = fd;
+ xl->drmcontext = ctx;
+ xl->hwLock = hwLock;
+ xl->mmioAddress = mmioAddress;
+ xl->fbAddress = fbAddress;
+ xl->curWaitFlags = 0;
+ xl->performLocking = 1;
+ xl->errors = 0;
+ xl->agpSync = 0;
+ ret = viaDMAInitTimeStamp(xl);
+ if (ret) {
+ free(xl);
+ return NULL;
+ }
+ return xl;
+}
+
+void
+setLowLevelLocking(void *xlp, int performLocking)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ xl->performLocking = performLocking;
+}
+
+void
+closeXvMCLowLevel(void *xlp)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ viaDMACleanupTimeStamp(xl);
+ free(xl);
+}
+
diff --git a/nx-X11/lib/XvMC/hw/via/unichromeProA/Imakefile b/nx-X11/lib/XvMC/hw/via/unichromeProA/Imakefile
new file mode 100644
index 000000000..f87ae9b05
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/via/unichromeProA/Imakefile
@@ -0,0 +1,50 @@
+#define DoNormalLib NormalLibXvMC
+#define DoSharedLib SharedLibXvMC
+#define DoDebugLib DebugLibXvMC
+#define DoProfileLib ProfileLibXvMC
+#define LibName viaXvMCPro
+#define SoRev SOXVMCREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXvMCReqs
+REQUIREDLIBS = SharedXvMCReqs -lXv
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) -DTRUE=1 -DFALSE=0
+ INCLUDES = -I$(XINCLUDESRC) -I$(INCLUDESRC) -I$(XLIBSRC) -I$(EXTINCSRC) \
+ -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(DRMSRCDIR)/shared-core \
+ -I$(XF86OSSRC)/linux/drm/kernel -I$(XF86DRIVERSRC)/via
+ SRCS = viaLowLevelPro.c
+ OBJS = viaXvMC.o viaLowLevelPro.o xf86drm.o xf86drmHash.o \
+ xf86drmRandom.o xf86drmSL.o xf86dri.o driDrawable.o
+ LINTLIBS = $(LINTXLIB)
+
+
+#include <Library.tmpl>
+
+
+#if defined(LinuxArchitecture)
+LIBDRM_DIR = ../../../../../extras/drm/libdrm
+
+LinkSourceFile(xf86drm.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmHash.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmRandom.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmSL.c,$(LIBDRM_DIR))
+LinkSourceFile(viaLowLevel.h,..)
+LinkSourceFile(driDrawable.h,..)
+LinkSourceFile(viaXvMCPriv.h,..)
+LinkSourceFile(xf86dri.h,..)
+LinkSourceFile(xf86dristr.h,..)
+LinkSourceFile(xf86dri.c,..)
+LinkSourceFile(driDrawable.c,..)
+LinkSourceFile(viaXvMC.c,..)
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/XvMC/hw/via/unichromeProA/viaLowLevelPro.c b/nx-X11/lib/XvMC/hw/via/unichromeProA/viaLowLevelPro.c
new file mode 100644
index 000000000..666166c96
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/via/unichromeProA/viaLowLevelPro.c
@@ -0,0 +1,1465 @@
+/*****************************************************************************
+ * VIA Unichrome XvMC extension client lib.
+ *
+ * Copyright (c) 2004 Thomas Hellström. All rights reserved.
+ * Copyright (c) 2003 Andreas Robinson. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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.
+ */
+
+
+/*
+ * Low-level functions that deal directly with the hardware. In the future,
+ * these functions might be implemented in a kernel module. Also, some of them
+ * would benefit from DMA.
+ *
+ * Authors:
+ * Andreas Robinson 2003. (Initial decoder interface functions).
+ * Thomas Hellstrom 2004, 2005 (Blitting functions, AGP and locking, Unichrome Pro Video AGP).
+ * Ivor Hewitt 2005 (Unichrome Pro modifications and merging).
+ */
+
+/* IH
+ * I've left the proReg or-ing in case we need/want to implement the V1/V3
+ * register toggle too, which also moves the register locations.
+ * The CN400 has dual mpeg decoders, not sure at the moment whether these
+ * are also operated through independent registers also.
+ */
+
+#undef VIDEO_DMA
+#define HQV_USE_IRQ
+#define UNICHROME_PRO
+
+#include "viaXvMCPriv.h"
+#include "viaLowLevel.h"
+#include "driDrawable.h"
+#include <time.h>
+#include <sys/time.h>
+#include <stdio.h>
+
+typedef enum {ll_init, ll_agpBuf, ll_pciBuf, ll_timeStamp, ll_llBuf}
+ LLState;
+
+
+typedef struct {
+ drm_via_mem_t mem;
+ unsigned offset;
+ unsigned stride;
+ unsigned height;
+} LowLevelBuffer;
+
+struct _XvMCLowLevel;
+
+typedef struct _ViaCommandBuffer {
+ CARD32 *buf;
+ CARD32 waitFlags;
+ unsigned pos;
+ unsigned bufSize;
+ int mode;
+ int header_start;
+ int rindex;
+ void (*flushFunc)(struct _ViaCommandBuffer *cb, struct _XvMCLowLevel *xl);
+} ViaCommandBuffer;
+
+typedef struct _XvMCLowLevel{
+ ViaCommandBuffer agpBuf, pciBuf, *videoBuf;
+ int use_agp;
+ int fd;
+ drm_context_t *drmcontext;
+ drmLockPtr hwLock;
+ drmAddress mmioAddress;
+ drmAddress fbAddress;
+ unsigned fbStride;
+ unsigned fbDepth;
+ unsigned width;
+ unsigned height;
+ int performLocking;
+ unsigned errors;
+ drm_via_mem_t tsMem;
+ CARD32 tsOffset;
+ volatile CARD32 *tsP;
+ CARD32 curTimeStamp;
+ CARD32 lastReadTimeStamp;
+ int agpSync;
+ CARD32 agpSyncTimeStamp;
+ unsigned chipId;
+
+ /*
+ * Data for video-engine less display
+ */
+
+ XvMCRegion sRegion;
+ XvMCRegion dRegion;
+ LowLevelBuffer scale;
+ LowLevelBuffer back;
+ Bool downScaling;
+ CARD32 downScaleW;
+ CARD32 downScaleH;
+ CARD32 upScaleW;
+ CARD32 upScaleH;
+ unsigned fetch;
+ unsigned line;
+ LLState state;
+}XvMCLowLevel;
+
+
+/*
+ * For Other architectures than i386 these might have to be modified for
+ * bigendian etc.
+ */
+
+
+#define MPEGIN(xl,reg) \
+ *((volatile CARD32 *)(((CARD8 *)(xl)->mmioAddress) + 0xc00 + (reg)))
+
+#define VIDIN(ctx,reg) \
+ *((volatile CARD32 *)(((CARD8 *)(ctx)->mmioAddress) + 0x200 + (reg)))
+
+#define REGIN(ctx,reg) \
+ *((volatile CARD32 *)(((CARD8 *)(ctx)->mmioAddress) + 0x0000 + (reg)))
+
+#define HQV_CONTROL 0x1D0
+#define HQV_SRC_OFFSET 0x1CC
+#define HQV_SRC_STARTADDR_Y 0x1D4
+#define HQV_SRC_STARTADDR_U 0x1D8
+#define HQV_SRC_STARTADDR_V 0x1DC
+#define HQV_MINIFY_DEBLOCK 0x1E8
+
+#define REG_HQV1_INDEX 0x00001000
+
+#define HQV_SW_FLIP 0x00000010
+#define HQV_FLIP_STATUS 0x00000001
+#define HQV_SUBPIC_FLIP 0x00008000
+#define HQV_FLIP_ODD 0x00000020
+#define HQV_DEINTERLACE 0x00010000
+#define HQV_FIELD_2_FRAME 0x00020000
+#define HQV_FRAME_2_FIELD 0x00040000
+#define HQV_FIELD_UV 0x00100000
+#define HQV_DEBLOCK_HOR 0x00008000
+#define HQV_DEBLOCK_VER 0x80000000
+#define HQV_YUV420 0xC0000000
+#define HQV_YUV422 0x80000000
+#define HQV_ENABLE 0x08000000
+#define HQV_GEN_IRQ 0x00000080
+
+#define HQV_SCALE_ENABLE 0x00000800
+#define HQV_SCALE_DOWN 0x00001000
+
+#define V_COMPOSE_MODE 0x98
+#define V1_COMMAND_FIRE 0x80000000
+#define V3_COMMAND_FIRE 0x40000000
+
+/* SUBPICTURE Registers */
+#define SUBP_CONTROL_STRIDE 0x1C0
+#define SUBP_STARTADDR 0x1C4
+#define RAM_TABLE_CONTROL 0x1C8
+#define RAM_TABLE_READ 0x1CC
+
+/* SUBP_CONTROL_STRIDE 0x3c0 */
+#define SUBP_HQV_ENABLE 0x00010000
+#define SUBP_IA44 0x00020000
+#define SUBP_AI44 0x00000000
+#define SUBP_STRIDE_MASK 0x00001fff
+#define SUBP_CONTROL_MASK 0x00070000
+
+/* RAM_TABLE_CONTROL 0x3c8 */
+#define RAM_TABLE_RGB_ENABLE 0x00000007
+
+
+#define VIA_REG_STATUS 0x400
+#define VIA_REG_GEMODE 0x004
+#define VIA_REG_SRCBASE 0x030
+#define VIA_REG_DSTBASE 0x034
+#define VIA_REG_PITCH 0x038
+#define VIA_REG_SRCCOLORKEY 0x01C
+#define VIA_REG_KEYCONTROL 0x02C
+#define VIA_REG_SRCPOS 0x008
+#define VIA_REG_DSTPOS 0x00C
+#define VIA_REG_GECMD 0x000
+#define VIA_REG_DIMENSION 0x010 /* width and height */
+#define VIA_REG_FGCOLOR 0x018
+
+
+#define VIA_VR_QUEUE_BUSY 0x00020000 /* Virtual Queue is busy */
+#define VIA_CMD_RGTR_BUSY 0x00000080 /* Command Regulator is busy */
+#define VIA_2D_ENG_BUSY 0x00000001 /* 2D Engine is busy */
+#define VIA_3D_ENG_BUSY 0x00000002 /* 3D Engine is busy */
+#define VIA_GEM_8bpp 0x00000000
+#define VIA_GEM_16bpp 0x00000100
+#define VIA_GEM_32bpp 0x00000300
+#define VIA_GEC_BLT 0x00000001
+#define VIA_PITCH_ENABLE 0x80000000
+#define VIA_GEC_INCX 0x00000000
+#define VIA_GEC_DECY 0x00004000
+#define VIA_GEC_INCY 0x00000000
+#define VIA_GEC_DECX 0x00008000
+#define VIA_GEC_FIXCOLOR_PAT 0x00002000
+
+
+#define VIA_BLIT_CLEAR 0x00
+#define VIA_BLIT_COPY 0xCC
+#define VIA_BLIT_FILL 0xF0
+#define VIA_BLIT_SET 0xFF
+
+#define VIA_SYNCWAITTIMEOUT 50000 /* Might be a bit conservative */
+#define VIA_DMAWAITTIMEOUT 150000
+#define VIA_VIDWAITTIMEOUT 50000
+#define VIA_XVMC_DECODERTIMEOUT 50000 /*(microseconds)*/
+
+#define VIA_AGP_HEADER5 0xFE040000
+#define VIA_AGP_HEADER6 0xFE050000
+
+typedef struct{
+ CARD32 data;
+ Bool set;
+} HQVRegister;
+
+
+#define H1_ADDR(val) (((val) >> 2) | 0xF0000000)
+#define WAITFLAGS(cb, flags) \
+ (cb)->waitFlags |= (flags)
+#define BEGIN_RING_AGP(cb, xl, size) \
+ do { \
+ if ((cb)->pos > ((cb)->bufSize-(size))) { \
+ cb->flushFunc(cb, xl); \
+ } \
+ } while(0)
+#define OUT_RING_AGP(cb, val) do{ \
+ (cb)->buf[(cb)->pos++] = (val); \
+ } while(0);
+
+#define OUT_RING_QW_AGP(cb, val1, val2) \
+ do { \
+ (cb)->buf[(cb)->pos++] = (val1); \
+ (cb)->buf[(cb)->pos++] = (val2); \
+ } while (0)
+
+
+#define BEGIN_HEADER5_AGP(cb, xl, index) \
+ do { \
+ BEGIN_RING_AGP(cb, xl, 8); \
+ (cb)->mode = VIA_AGP_HEADER5; \
+ (cb)->rindex = (index); \
+ (cb)->header_start = (cb)->pos; \
+ (cb)->pos += 4; \
+ } while (0)
+
+#define BEGIN_HEADER6_AGP(cb, xl) \
+ do { \
+ BEGIN_RING_AGP(cb, xl, 8); \
+ (cb)->mode = VIA_AGP_HEADER6; \
+ (cb)->header_start = (cb)->pos; \
+ (cb)->pos += 4; \
+ } while (0)
+
+#define BEGIN_HEADER5_DATA(cb, xl, size, index) \
+ do { \
+ if ((cb)->pos > ((cb)->bufSize - ((size) + 16))) { \
+ cb->flushFunc(cb, xl); \
+ BEGIN_HEADER5_AGP(cb, xl, index); \
+ } else if ((cb)->mode && (((cb)->mode != VIA_AGP_HEADER5) || \
+ ((cb)->rindex != index))) { \
+ finish_header_agp(cb); \
+ BEGIN_HEADER5_AGP((cb), xl, (index)); \
+ } else if (cb->mode != VIA_AGP_HEADER5) { \
+ BEGIN_HEADER5_AGP((cb), xl, (index)); \
+ } \
+ }while(0)
+
+#define BEGIN_HEADER6_DATA(cb, xl, size) \
+ do{ \
+ if ((cb)->pos > (cb->bufSize-(((size) << 1) + 16))) { \
+ cb->flushFunc(cb, xl); \
+ BEGIN_HEADER6_AGP(cb, xl); \
+ } else if ((cb)->mode && ((cb)->mode != VIA_AGP_HEADER6)) { \
+ finish_header_agp(cb); \
+ BEGIN_HEADER6_AGP(cb, xl); \
+ } \
+ else if ((cb->mode != VIA_AGP_HEADER6)) { \
+ BEGIN_HEADER6_AGP(cb, (xl)); \
+ } \
+ }while(0)
+
+#define HQV_SHADOW_BASE 0x3CC
+#define HQV_SHADOW_SIZE 13
+
+#define SETHQVSHADOW(shadow, offset, value) \
+ do { \
+ HQVRegister *r = (shadow) + (((offset) - HQV_SHADOW_BASE) >> 2); \
+ r->data = (value); \
+ r->set = TRUE; \
+ } while(0)
+
+#define GETHQVSHADOW(shadow, offset) ((shadow)[(offset - HQV_SHADOW_BASE) >> 2].data)
+
+#define LL_HW_LOCK(xl) \
+ do { \
+ DRM_LOCK((xl)->fd,(xl)->hwLock,*(xl)->drmcontext,0); \
+ } while(0);
+#define LL_HW_UNLOCK(xl) \
+ do { \
+ DRM_UNLOCK((xl)->fd,(xl)->hwLock,*(xl)->drmcontext); \
+ } while(0);
+
+static HQVRegister hqvShadow[HQV_SHADOW_SIZE];
+
+
+static void
+initHQVShadow(HQVRegister *r)
+{
+ int i;
+
+ for(i=0; i<HQV_SHADOW_SIZE; ++i) {
+ r->data = 0;
+ r++->set = FALSE;
+ }
+}
+
+static void
+setHQVDeblocking(HQVRegister *shadow, Bool on, Bool lowPass)
+{
+ CARD32 tmp = GETHQVSHADOW(shadow, 0x3DC);
+
+ if (!on) {
+ tmp &= ~(1 << 27);
+ SETHQVSHADOW(shadow, 0x3DC , tmp);
+ return;
+ }
+
+ tmp |= (8 << 16) | (1 << 27);
+ if (lowPass)
+ tmp |= (1 << 26);
+ SETHQVSHADOW(shadow, 0x3DC , tmp);
+
+ tmp = GETHQVSHADOW(shadow, 0x3D4);
+ tmp |= (6 << 27);
+ SETHQVSHADOW(shadow, 0x3D4, tmp);
+
+ tmp = GETHQVSHADOW(shadow, 0x3D8);
+ tmp |= (19 << 27);
+ SETHQVSHADOW(shadow, 0x3D8, tmp);
+}
+
+static void
+setHQVStartAddress(HQVRegister *shadow, unsigned yOffs, unsigned uOffs,
+ unsigned stride, unsigned format)
+{
+ CARD32 tmp = GETHQVSHADOW(shadow, 0x3D4);
+
+ tmp |= yOffs & 0x03FFFFF0;
+ SETHQVSHADOW(shadow, 0x3D4, tmp);
+ tmp = GETHQVSHADOW(shadow, 0x3D8);
+ tmp |= uOffs & 0x03FFFFF0;
+ SETHQVSHADOW(shadow, 0x3D8, tmp);
+ tmp = GETHQVSHADOW(shadow, 0x3F8);
+ tmp |= (stride & 0x1FF8);
+ SETHQVSHADOW(shadow, 0x3F8, tmp);
+ tmp = GETHQVSHADOW(shadow, 0x3D0);
+
+ if (format == 0) {
+ /*
+ * NV12
+ */
+ tmp |= (0x0C << 28);
+ } else if (format == 1) {
+ /*
+ * RGB16
+ */
+ tmp |= (0x02 << 28);
+ } else if (format == 2) {
+ /*
+ * RGB32
+ */
+ ;
+ }
+ SETHQVSHADOW(shadow, 0x3D0, tmp);
+}
+
+static void
+setHQVDeinterlacing(HQVRegister *shadow, CARD32 frameType)
+{
+ CARD32 tmp = GETHQVSHADOW(shadow, 0x3D0);
+
+
+ if ((frameType & XVMC_FRAME_PICTURE) == XVMC_TOP_FIELD) {
+ tmp |= HQV_FIELD_UV |
+ HQV_DEINTERLACE |
+ HQV_FIELD_2_FRAME |
+ HQV_FRAME_2_FIELD;
+ } else if ((frameType & XVMC_FRAME_PICTURE) == XVMC_BOTTOM_FIELD) {
+ tmp |= HQV_FIELD_UV |
+ HQV_DEINTERLACE |
+ HQV_FIELD_2_FRAME |
+ HQV_FRAME_2_FIELD |
+ HQV_FLIP_ODD;
+ }
+ SETHQVSHADOW(shadow, 0x3D0, tmp);
+}
+
+static void
+setHQVTripleBuffer(HQVRegister *shadow, Bool on)
+{
+ CARD32 tmp = GETHQVSHADOW(shadow, 0x3D0);
+
+ if (on)
+ tmp |= ( 1 << 26 );
+ else
+ tmp &= ~( 1 << 26 );
+ SETHQVSHADOW(shadow, 0x3D0, tmp);
+}
+
+static void
+finish_header_agp(ViaCommandBuffer *cb)
+{
+ int
+ numDWords,i;
+ CARD32
+ *hb;
+
+ if (!cb->mode) return;
+ numDWords = cb->pos - cb->header_start - 4;
+ hb = cb->buf + cb->header_start;
+ switch (cb->mode) {
+ case VIA_AGP_HEADER5:
+ hb[0] = VIA_AGP_HEADER5 | cb->rindex;
+ hb[1] = numDWords ;
+ hb[2] = 0x00F50000; /* SW debug flag. (?) */
+ break;
+ default:
+ hb[0] = VIA_AGP_HEADER6;
+ hb[1] = numDWords >> 1 ;
+ hb[2] = 0x00F60000; /* SW debug flag. (?) */
+ break;
+ }
+ hb[3] = 0;
+ if (numDWords & 3) {
+ for (i=0; i<(4 - (numDWords & 3)); ++i)
+ OUT_RING_AGP(cb, 0x00000000);
+ }
+ cb->mode = 0;
+}
+
+void
+hwlLock(void *xlp, int videoLock)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ LL_HW_LOCK(xl);
+}
+
+void
+hwlUnlock(void *xlp, int videoLock)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ LL_HW_UNLOCK(xl);
+}
+
+static unsigned
+timeDiff(struct timeval *now,struct timeval *then) {
+ return (now->tv_usec >= then->tv_usec) ?
+ now->tv_usec - then->tv_usec :
+ 1000000 - (then->tv_usec - now->tv_usec);
+}
+
+void
+setAGPSyncLowLevel(void *xlp, int val, CARD32 timeStamp)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ xl->agpSync = val;
+ xl->agpSyncTimeStamp = timeStamp;
+}
+
+CARD32
+viaDMATimeStampLowLevel(void *xlp)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ if (xl->use_agp) {
+ viaBlit(xl, 32, xl->tsOffset, 1, xl->tsOffset, 1, 1, 1, 0, 0,
+ VIABLIT_FILL, xl->curTimeStamp);
+ return xl->curTimeStamp++;
+ }
+ return 0;
+}
+
+static void
+viaDMAWaitTimeStamp(XvMCLowLevel *xl, CARD32 timeStamp, int doSleep)
+{
+ struct timeval now, then;
+ struct timezone here;
+ struct timespec sleep, rem;
+
+ if (xl->use_agp && (xl->lastReadTimeStamp - timeStamp > (1 << 23))) {
+ sleep.tv_nsec = 1;
+ sleep.tv_sec = 0;
+ here.tz_minuteswest = 0;
+ here.tz_dsttime = 0;
+ gettimeofday(&then,&here);
+
+ while(((xl->lastReadTimeStamp = *xl->tsP) - timeStamp) > (1 << 23)) {
+ gettimeofday(&now,&here);
+ if (timeDiff(&now,&then) > VIA_DMAWAITTIMEOUT) {
+ if(((xl->lastReadTimeStamp = *xl->tsP) - timeStamp) > (1 << 23)) {
+ xl->errors |= LL_DMA_TIMEDOUT;
+ break;
+ }
+ }
+ if (doSleep) nanosleep(&sleep, &rem);
+ }
+ }
+}
+
+static int
+viaDMAInitTimeStamp(XvMCLowLevel *xl)
+{
+ int ret = 0;
+
+ if (xl->use_agp) {
+ xl->tsMem.context = *(xl->drmcontext);
+ xl->tsMem.size = 64;
+ xl->tsMem.type = VIA_MEM_VIDEO;
+ if ((ret = drmCommandWriteRead(xl->fd, DRM_VIA_ALLOCMEM,
+ &xl->tsMem, sizeof(xl->tsMem))) < 0)
+ return ret;
+ if (xl->tsMem.size != 64)
+ return -1;
+ xl->tsOffset = (xl->tsMem.offset + 31) & ~31;
+ xl->tsP = (CARD32 *)xl->fbAddress + (xl->tsOffset >> 2);
+ xl->curTimeStamp = 1;
+ *xl->tsP = 0;
+ }
+ return 0;
+}
+
+static int
+viaDMACleanupTimeStamp(XvMCLowLevel *xl)
+{
+
+ if (!(xl->tsMem.size) || !xl->use_agp) return 0;
+ return drmCommandWrite(xl->fd, DRM_VIA_FREEMEM, &xl->tsMem, sizeof(xl->tsMem));
+}
+
+
+static CARD32
+viaMpegGetStatus(XvMCLowLevel *xl)
+{
+ return MPEGIN(xl,0x54);
+}
+
+static int
+viaMpegIsBusy(XvMCLowLevel *xl, CARD32 mask, CARD32 idle)
+{
+ CARD32 tmp = viaMpegGetStatus(xl);
+
+ /*
+ * Error detected.
+ * FIXME: Are errors really shown when error concealment is on?
+ */
+
+ if (tmp & 0x70) return 0;
+
+ return (tmp & mask) != idle;
+}
+
+
+static void
+syncDMA(XvMCLowLevel *xl, unsigned int doSleep)
+{
+
+ /*
+ * Ideally, we'd like to have an interrupt wait here, but, according to second hand
+ * information, the hardware does not support this, although earlier S3 chips do that.
+ * It is therefore not implemented into the DRM, and we'll do a user space wait here.
+ */
+
+ struct timeval now, then;
+ struct timezone here;
+ struct timespec sleep, rem;
+
+ sleep.tv_nsec = 1;
+ sleep.tv_sec = 0;
+ here.tz_minuteswest = 0;
+ here.tz_dsttime = 0;
+ gettimeofday(&then,&here);
+ while( !(REGIN(xl, VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY)) {
+ gettimeofday(&now,&here);
+ if (timeDiff(&now,&then) > VIA_DMAWAITTIMEOUT) {
+ if( !(REGIN(xl, VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY)) {
+ xl->errors |= LL_DMA_TIMEDOUT;
+ break;
+ }
+ }
+ if (doSleep) nanosleep(&sleep, &rem);
+ }
+ while( REGIN(xl, VIA_REG_STATUS) & VIA_CMD_RGTR_BUSY ) {
+ gettimeofday(&now,&here);
+ if (timeDiff(&now,&then) > VIA_DMAWAITTIMEOUT) {
+ if( REGIN(xl, VIA_REG_STATUS) & VIA_CMD_RGTR_BUSY ) {
+ xl->errors |= LL_DMA_TIMEDOUT;
+ break;
+ }
+ }
+ if (doSleep) nanosleep(&sleep, &rem);
+ }
+}
+
+#ifdef HQV_USE_IRQ
+static void
+syncVideo(XvMCLowLevel *xl, unsigned int doSleep)
+{
+ int proReg = REG_HQV1_INDEX;
+
+ /*
+ * Wait for HQV completion using completion interrupt. Nothing strange here.
+ * Note that the interrupt handler clears the HQV_FLIP_STATUS bit, so we
+ * can't wait on that one.
+ */
+
+ if ((VIDIN(xl, HQV_CONTROL|proReg) & (HQV_SW_FLIP | HQV_SUBPIC_FLIP))) {
+ drm_via_irqwait_t irqw;
+ irqw.request.irq = 1;
+ irqw.request.type = VIA_IRQ_ABSOLUTE;
+ if (drmCommandWriteRead(xl->fd, DRM_VIA_WAIT_IRQ, &irqw, sizeof(irqw)) < 0)
+ xl->errors |= LL_VIDEO_TIMEDOUT;
+ }
+}
+#else
+static void
+syncVideo(XvMCLowLevel *xl, unsigned int doSleep)
+{
+ /*
+ * Wait for HQV completion. Nothing strange here. We assume that the HQV
+ * Handles syncing to the V1 / V3 engines by itself. It should be safe to
+ * always wait for SUBPIC_FLIP completion although subpictures are not always
+ * used.
+ */
+
+ struct timeval now, then;
+ struct timezone here;
+ struct timespec sleep, rem;
+
+ int proReg = REG_HQV1_INDEX;
+
+ sleep.tv_nsec = 1;
+ sleep.tv_sec = 0;
+ here.tz_minuteswest = 0;
+ here.tz_dsttime = 0;
+ gettimeofday(&then,&here);
+ while((VIDIN(xl, HQV_CONTROL|proReg) & (HQV_SW_FLIP | HQV_SUBPIC_FLIP )) ) {
+ gettimeofday(&now,&here);
+ if (timeDiff(&now,&then) > VIA_SYNCWAITTIMEOUT) {
+ if((VIDIN(xl, HQV_CONTROL|proReg) & (HQV_SW_FLIP | HQV_SUBPIC_FLIP )) ) {
+ xl->errors |= LL_VIDEO_TIMEDOUT;
+ break;
+ }
+ }
+ if (doSleep) nanosleep(&sleep, &rem);
+ }
+}
+#endif
+
+static void
+syncAccel(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep)
+{
+ struct timeval now, then;
+ struct timezone here;
+ struct timespec sleep, rem;
+ CARD32 mask = ((mode & LL_MODE_2D) ? VIA_2D_ENG_BUSY : 0) |
+ ((mode & LL_MODE_3D) ? VIA_3D_ENG_BUSY : 0);
+
+ sleep.tv_nsec = 1;
+ sleep.tv_sec = 0;
+ here.tz_minuteswest = 0;
+ here.tz_dsttime = 0;
+ gettimeofday(&then,&here);
+ while( REGIN(xl, VIA_REG_STATUS) & mask) {
+ gettimeofday(&now,&here);
+ if (timeDiff(&now,&then) > VIA_SYNCWAITTIMEOUT) {
+ if( REGIN(xl, VIA_REG_STATUS) & mask) {
+ xl->errors |= LL_ACCEL_TIMEDOUT;
+ break;
+ }
+ }
+ if (doSleep) nanosleep(&sleep, &rem);
+ }
+}
+
+
+static void
+syncMpeg(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep)
+{
+ /*
+ * Ideally, we'd like to have an interrupt wait here, but from information from VIA
+ * at least the MPEG completion interrupt is broken on the CLE266, which was
+ * discovered during validation of the chip.
+ */
+
+ struct timeval now, then;
+ struct timezone here;
+ struct timespec sleep, rem;
+ CARD32 busyMask = 0;
+ CARD32 idleVal = 0;
+ CARD32 ret;
+
+ sleep.tv_nsec = 1;
+ sleep.tv_sec = 0;
+ here.tz_minuteswest = 0;
+ here.tz_dsttime = 0;
+ gettimeofday(&then,&here);
+ if (mode & LL_MODE_DECODER_SLICE) {
+ busyMask = VIA_SLICEBUSYMASK;
+ idleVal = VIA_SLICEIDLEVAL;
+ }
+ if (mode & LL_MODE_DECODER_IDLE) {
+ busyMask |= VIA_BUSYMASK;
+ idleVal = VIA_IDLEVAL;
+ }
+ while(viaMpegIsBusy(xl, busyMask, idleVal)) {
+ gettimeofday(&now,&here);
+ if (timeDiff(&now,&then) > VIA_XVMC_DECODERTIMEOUT) {
+ if (viaMpegIsBusy(xl, busyMask, idleVal)) {
+ xl->errors |= LL_DECODER_TIMEDOUT;
+ }
+ break;
+ }
+ if (doSleep) nanosleep(&sleep, &rem);
+ }
+
+ ret = viaMpegGetStatus(xl);
+ if (ret & 0x70) {
+ xl->errors |= ((ret & 0x70) >> 3);
+ }
+ return;
+}
+
+static void
+pciFlush(ViaCommandBuffer *cb, XvMCLowLevel *xl)
+{
+ int ret;
+ drm_via_cmdbuffer_t b;
+ unsigned mode = cb->waitFlags;
+
+ finish_header_agp(cb);
+ b.buf = (char *)cb->buf;
+ b.size = cb->pos * sizeof(CARD32);
+ if (xl->performLocking) hwlLock(xl,0);
+ if (((mode == LL_MODE_VIDEO) && (xl->videoBuf == &xl->agpBuf)) ||
+ ((mode != LL_MODE_VIDEO) && (mode != 0)))
+ syncDMA(xl, 0);
+ if ((mode & LL_MODE_2D) || (mode & LL_MODE_3D)) {
+ syncAccel(xl, mode, 0);
+ }
+ if (mode & LL_MODE_VIDEO) {
+ syncVideo(xl, 1);
+ }
+ if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE)) {
+ syncMpeg(xl, mode, 0);
+ }
+ ret = drmCommandWrite(xl->fd, DRM_VIA_PCICMD, &b, sizeof(b));
+ if (xl->performLocking) hwlUnlock(xl,0);
+ if (ret) {
+ xl->errors |= LL_PCI_COMMAND_ERR;
+ }
+ cb->pos = 0;
+ cb->waitFlags = 0;
+}
+
+static void
+agpFlush(ViaCommandBuffer *cb, XvMCLowLevel *xl)
+{
+ drm_via_cmdbuffer_t b;
+ int ret;
+ int i;
+
+ finish_header_agp(cb);
+ if (xl->use_agp) {
+ b.buf = (char *)cb->buf;
+ b.size = cb->pos * sizeof(CARD32);
+ if (xl->agpSync) {
+ syncXvMCLowLevel(xl, LL_MODE_DECODER_IDLE, 1, xl->agpSyncTimeStamp);
+ xl->agpSync = 0;
+ }
+ if (xl->performLocking) hwlLock(xl,0);
+ do {
+ ret = drmCommandWrite(xl->fd, DRM_VIA_CMDBUFFER, &b, sizeof(b));
+ } while (-EAGAIN == ret);
+ if (xl->performLocking) hwlUnlock(xl,0);
+
+ if (ret) {
+ xl->errors |= LL_AGP_COMMAND_ERR;
+ for(i=0; i<cb->pos; i+=2) {
+ printf("0x%x, 0x%x\n", (unsigned) cb->buf[i], (unsigned) cb->buf[i+1]);
+ }
+ exit(-1);
+ } else {
+ cb->pos = 0;
+ }
+ cb->waitFlags &= LL_MODE_VIDEO; /* FIXME: Check this! */
+ } else {
+ unsigned mode=cb->waitFlags;
+
+ b.buf = (char *)cb->buf;
+ b.size = cb->pos * sizeof(CARD32);
+ if (xl->performLocking) hwlLock(xl,0);
+ if (((mode == LL_MODE_VIDEO) && (cb == &xl->agpBuf)) ||
+ ((mode != LL_MODE_VIDEO) && (mode != 0)))
+ syncDMA(xl, 0);
+ if ((mode & LL_MODE_2D) || (mode & LL_MODE_3D))
+ syncAccel(xl, mode, 0);
+ if (mode & LL_MODE_VIDEO)
+ syncVideo(xl, 1);
+ if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE))
+ syncMpeg(xl, mode, 0);
+ ret = drmCommandWrite(xl->fd, DRM_VIA_PCICMD, &b, sizeof(b));
+ if (xl->performLocking) hwlUnlock(xl,0);
+ if (ret) {
+ xl->errors |= LL_PCI_COMMAND_ERR;
+ }
+ cb->pos = 0;
+ cb->waitFlags = 0;
+ }
+}
+
+static void
+uploadHQVShadow(XvMCLowLevel *xl, unsigned offset, HQVRegister *shadow,
+ Bool flip)
+{
+ int i;
+ CARD32 tmp;
+ ViaCommandBuffer *cb = xl->videoBuf;
+
+ BEGIN_HEADER6_DATA(cb, xl, HQV_SHADOW_SIZE);
+ WAITFLAGS(cb, LL_MODE_VIDEO);
+
+ if (shadow[0].set)
+ OUT_RING_QW_AGP(cb, 0x3CC + offset, 0);
+
+ for (i=2; i < HQV_SHADOW_SIZE; ++i) {
+ if (shadow[i].set) {
+ OUT_RING_QW_AGP(cb, offset + HQV_SHADOW_BASE + ( i << 2) , shadow[i].data);
+ shadow[i].set = FALSE;
+ }
+ }
+
+ /*
+ * Finally the control register for flip.
+ */
+
+ if (flip) {
+ tmp = GETHQVSHADOW( shadow, 0x3D0);
+ OUT_RING_QW_AGP(cb, offset + HQV_CONTROL + 0x200 ,
+ HQV_ENABLE | HQV_GEN_IRQ | HQV_SUBPIC_FLIP | HQV_SW_FLIP | tmp);
+ }
+ shadow[0].set = FALSE;
+ shadow[1].set = FALSE;
+}
+
+
+
+
+unsigned
+flushXvMCLowLevel(void *xlp)
+{
+ unsigned
+ errors;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+
+ if(xl->pciBuf.pos) pciFlush(&xl->pciBuf, xl);
+ if(xl->agpBuf.pos) agpFlush(&xl->agpBuf, xl);
+ errors = xl->errors;
+ if (errors) printf("Error 0x%x\n", errors);
+ xl->errors = 0;
+ return errors;
+}
+
+void
+flushPCIXvMCLowLevel(void *xlp)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+
+ if(xl->pciBuf.pos) pciFlush(&xl->pciBuf, xl);
+ if ((!xl->use_agp && xl->agpBuf.pos)) agpFlush(&xl->agpBuf, xl);
+}
+
+
+void
+viaMpegSetSurfaceStride(void *xlp, ViaXvMCContext *ctx)
+{
+ CARD32 y_stride = ctx->yStride;
+ CARD32 uv_stride = y_stride >> 1;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+ ViaCommandBuffer *cb = &xl->agpBuf;
+
+ BEGIN_HEADER6_DATA(cb, xl, 1);
+ OUT_RING_QW_AGP(cb, 0xc50, (y_stride >> 3) | ((uv_stride >> 3) << 16));
+ WAITFLAGS(cb, LL_MODE_DECODER_IDLE);
+}
+
+
+void
+viaVideoSetSWFLipLocked(void *xlp, unsigned yOffs, unsigned uOffs,
+ unsigned vOffs, unsigned yStride, unsigned uvStride)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ initHQVShadow(hqvShadow);
+ setHQVStartAddress(hqvShadow, yOffs, vOffs, yStride, 0);
+ if (xl->videoBuf == &xl->agpBuf)
+ syncDMA(xl, 1);
+ syncVideo(xl, 1);
+ uploadHQVShadow(xl, REG_HQV1_INDEX, hqvShadow, FALSE);
+ xl->videoBuf->flushFunc(xl->videoBuf, xl);
+}
+
+void
+viaVideoSWFlipLocked(void *xlp, unsigned flags,
+ Bool progressiveSequence)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ setHQVDeinterlacing(hqvShadow, flags);
+ setHQVDeblocking(hqvShadow,( (flags & XVMC_FRAME_PICTURE) == XVMC_FRAME_PICTURE), TRUE);
+ setHQVTripleBuffer(hqvShadow, TRUE);
+ if (xl->videoBuf == &xl->agpBuf)
+ syncDMA(xl, 1);
+ syncVideo(xl, 1);
+ uploadHQVShadow(xl, REG_HQV1_INDEX, hqvShadow, TRUE);
+ xl->videoBuf->flushFunc(xl->videoBuf, xl);
+}
+
+
+void
+viaMpegSetFB(void *xlp,unsigned i,
+ unsigned yOffs,
+ unsigned uOffs,
+ unsigned vOffs)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+ ViaCommandBuffer *cb = &xl->agpBuf;
+
+ i *= (4*2);
+ BEGIN_HEADER6_DATA(cb,xl, 2);
+ OUT_RING_QW_AGP(cb, 0xc28 + i, yOffs >> 3);
+ OUT_RING_QW_AGP(cb, 0xc2c + i, vOffs >> 3);
+
+ WAITFLAGS(cb, LL_MODE_DECODER_IDLE);
+}
+
+void
+viaMpegBeginPicture(void *xlp,ViaXvMCContext *ctx,
+ unsigned width,
+ unsigned height,
+ const XvMCMpegControl *control) {
+
+ unsigned j, mb_width, mb_height;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+ ViaCommandBuffer *cb = &xl->agpBuf;
+
+ mb_width = (width + 15) >> 4;
+
+ mb_height =
+ ((control->mpeg_coding == XVMC_MPEG_2) &&
+ (control->flags & XVMC_PROGRESSIVE_SEQUENCE)) ?
+ 2*((height+31) >> 5) : (((height+15) >> 4));
+
+ BEGIN_HEADER6_DATA(cb,xl, 72);
+ WAITFLAGS(cb, LL_MODE_DECODER_IDLE);
+
+ OUT_RING_QW_AGP(cb, 0xc00,
+ ((control->picture_structure & XVMC_FRAME_PICTURE) << 2) |
+ ((control->picture_coding_type & 3) << 4) |
+ ((control->flags & XVMC_ALTERNATE_SCAN) ? (1 << 6) : 0));
+
+ if (!(ctx->intraLoaded)) {
+ OUT_RING_QW_AGP(cb, 0xc5c, 0);
+ for (j = 0; j < 64; j += 4) {
+ OUT_RING_QW_AGP(cb, 0xc60,
+ ctx->intra_quantiser_matrix[j] |
+ (ctx->intra_quantiser_matrix[j+1] << 8) |
+ (ctx->intra_quantiser_matrix[j+2] << 16) |
+ (ctx->intra_quantiser_matrix[j+3] << 24));
+ }
+ ctx->intraLoaded = 1;
+ }
+
+ if (!(ctx->nonIntraLoaded)) {
+ OUT_RING_QW_AGP(cb, 0xc5c, 1);
+ for (j = 0; j < 64; j += 4) {
+ OUT_RING_QW_AGP(cb, 0xc60,
+ ctx->non_intra_quantiser_matrix[j] |
+ (ctx->non_intra_quantiser_matrix[j+1] << 8) |
+ (ctx->non_intra_quantiser_matrix[j+2] << 16) |
+ (ctx->non_intra_quantiser_matrix[j+3] << 24));
+ }
+ ctx->nonIntraLoaded = 1;
+ }
+
+ if (!(ctx->chromaIntraLoaded)) {
+ OUT_RING_QW_AGP(cb, 0xc5c, 2);
+ for (j = 0; j < 64; j += 4) {
+ OUT_RING_QW_AGP(cb, 0xc60,
+ ctx->chroma_intra_quantiser_matrix[j] |
+ (ctx->chroma_intra_quantiser_matrix[j+1] << 8) |
+ (ctx->chroma_intra_quantiser_matrix[j+2] << 16) |
+ (ctx->chroma_intra_quantiser_matrix[j+3] << 24));
+ }
+ ctx->chromaIntraLoaded = 1;
+ }
+
+ if (!(ctx->chromaNonIntraLoaded)) {
+ OUT_RING_QW_AGP(cb, 0xc5c, 3);
+ for (j = 0; j < 64; j += 4) {
+ OUT_RING_QW_AGP(cb, 0xc60,
+ ctx->chroma_non_intra_quantiser_matrix[j] |
+ (ctx->chroma_non_intra_quantiser_matrix[j+1] << 8) |
+ (ctx->chroma_non_intra_quantiser_matrix[j+2] << 16) |
+ (ctx->chroma_non_intra_quantiser_matrix[j+3] << 24));
+ }
+ ctx->chromaNonIntraLoaded = 1;
+ }
+
+ OUT_RING_QW_AGP(cb, 0xc90,
+ ((mb_width * mb_height) & 0x3fff) |
+ ((control->flags & XVMC_PRED_DCT_FRAME) ? ( 1 << 14) : 0) |
+ ((control->flags & XVMC_TOP_FIELD_FIRST) ? (1 << 15) : 0 ) |
+ ((control->mpeg_coding == XVMC_MPEG_2) ? (1 << 16) : 0) |
+ ((mb_width & 0xff) << 18));
+
+ OUT_RING_QW_AGP(cb, 0xc94,
+ ((control->flags & XVMC_CONCEALMENT_MOTION_VECTORS) ? 1 : 0) |
+ ((control->flags & XVMC_Q_SCALE_TYPE) ? 2 : 0) |
+ ((control->intra_dc_precision & 3) << 2) |
+ (((1 + 0x100000 / mb_width) & 0xfffff) << 4) |
+ ((control->flags & XVMC_INTRA_VLC_FORMAT) ? (1 << 24) : 0));
+
+ OUT_RING_QW_AGP(cb, 0xc98,
+ (((control->FHMV_range) & 0xf) << 0) |
+ (((control->FVMV_range) & 0xf) << 4) |
+ (((control->BHMV_range) & 0xf) << 8) |
+ (((control->BVMV_range) & 0xf) << 12) |
+ ((control->flags & XVMC_SECOND_FIELD) ? (1 << 20) : 0) |
+ (0x0a6 << 16));
+
+}
+
+
+
+void
+viaMpegReset(void *xlp)
+{
+ int i,j;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+ ViaCommandBuffer *cb = &xl->agpBuf;
+
+ BEGIN_HEADER6_DATA(cb,xl, 99);
+ WAITFLAGS(cb, LL_MODE_DECODER_IDLE);
+
+ OUT_RING_QW_AGP(cb, 0xcf0 ,0);
+
+ for (i = 0; i < 6; i++) {
+ OUT_RING_QW_AGP(cb, 0xcc0 ,0);
+ OUT_RING_QW_AGP(cb, 0xc0c, 0x43|0x20 );
+ for (j = 0xc10; j < 0xc20; j += 4)
+ OUT_RING_QW_AGP(cb, j, 0);
+ }
+
+ OUT_RING_QW_AGP(cb, 0xc0c, 0x1c3);
+ for (j = 0xc10; j < 0xc20; j += 4)
+ OUT_RING_QW_AGP(cb,j,0);
+
+ for (i = 0; i < 19; i++)
+ OUT_RING_QW_AGP(cb, 0xc08 ,0);
+
+ OUT_RING_QW_AGP(cb, 0xc98, 0x400000);
+
+ for (i = 0; i < 6; i++) {
+ OUT_RING_QW_AGP(cb, 0xcc0 ,0);
+ OUT_RING_QW_AGP(cb, 0xc0c, 0x1c3|0x20);
+ for (j = 0xc10; j < 0xc20; j += 4)
+ OUT_RING_QW_AGP(cb,j,0);
+ }
+ OUT_RING_QW_AGP(cb, 0xcf0 ,0);
+
+}
+
+void
+viaMpegWriteSlice(void *xlp, CARD8* slice, int nBytes, CARD32 sCode)
+{
+ int i, n, r;
+ CARD32* buf;
+ int count;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+ ViaCommandBuffer *cb = &xl->agpBuf;
+
+ if (xl->errors & (LL_DECODER_TIMEDOUT |
+ LL_IDCT_FIFO_ERROR |
+ LL_SLICE_FIFO_ERROR |
+ LL_SLICE_FAULT)) return;
+
+ n = nBytes >> 2;
+ if (sCode) nBytes += 4;
+ r = nBytes & 3;
+ buf = (CARD32*) slice;
+
+ if (r) nBytes += 4 - r;
+
+ nBytes += 8;
+
+ BEGIN_HEADER6_DATA(cb,xl, 2);
+ WAITFLAGS(cb, LL_MODE_DECODER_IDLE);
+ OUT_RING_QW_AGP(cb, 0xc9c, nBytes);
+
+ if (sCode) OUT_RING_QW_AGP(cb, 0xca0, sCode);
+
+ i = 0;
+ count = 0;
+
+ do {
+ count += (LL_AGP_CMDBUF_SIZE -20);
+ count = (count > n) ? n : count;
+ BEGIN_HEADER5_DATA(cb, xl, (count - i), 0xca0);
+
+ for (; i < count; i++) {
+ OUT_RING_AGP(cb, *buf++);
+ }
+ finish_header_agp(cb);
+ } while (i < n);
+
+ BEGIN_HEADER5_DATA(cb, xl, 3, 0xca0);
+
+ if (r) {
+ OUT_RING_AGP(cb, *buf & ((1 << (r << 3)) - 1));
+ }
+ OUT_RING_AGP(cb,0);
+ OUT_RING_AGP(cb,0);
+ finish_header_agp(cb);
+}
+
+void
+viaVideoSubPictureOffLocked(void *xlp) {
+
+ CARD32 stride;
+ int proReg = REG_HQV1_INDEX;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+ ViaCommandBuffer *cb = xl->videoBuf;
+
+ if (xl->videoBuf == &xl->agpBuf)
+ syncDMA(xl, 1);
+ stride = VIDIN(xl,proReg|SUBP_CONTROL_STRIDE);
+ WAITFLAGS(cb, LL_MODE_VIDEO);
+ BEGIN_HEADER6_DATA(cb, xl, 1);
+ OUT_RING_QW_AGP(cb, proReg|SUBP_CONTROL_STRIDE | 0x200, stride & ~SUBP_HQV_ENABLE);
+}
+
+void
+viaVideoSubPictureLocked(void *xlp, ViaXvMCSubPicture *pViaSubPic) {
+
+ unsigned i;
+ CARD32 cWord;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+ int proReg = REG_HQV1_INDEX;
+ ViaCommandBuffer *cb = xl->videoBuf;
+
+ if (xl->videoBuf == &xl->agpBuf)
+ syncDMA(xl, 1);
+ WAITFLAGS(cb, LL_MODE_VIDEO);
+ BEGIN_HEADER6_DATA(cb, xl, VIA_SUBPIC_PALETTE_SIZE + 2);
+ for (i=0; i<VIA_SUBPIC_PALETTE_SIZE; ++i) {
+ OUT_RING_QW_AGP(cb, proReg|RAM_TABLE_CONTROL | 0x200, pViaSubPic->palette[i]);
+ }
+
+ cWord = (pViaSubPic->stride & SUBP_STRIDE_MASK) | SUBP_HQV_ENABLE;
+ cWord |= (pViaSubPic->ia44) ? SUBP_IA44 : SUBP_AI44;
+ OUT_RING_QW_AGP(cb, proReg|SUBP_STARTADDR | 0x200, pViaSubPic->offset);
+ OUT_RING_QW_AGP(cb, proReg|SUBP_CONTROL_STRIDE | 0x200, cWord);
+}
+
+void
+viaBlit(void *xlp,unsigned bpp,unsigned srcBase,
+ unsigned srcPitch,unsigned dstBase,unsigned dstPitch,
+ unsigned w,unsigned h,int xdir,int ydir, unsigned blitMode,
+ unsigned color)
+{
+
+ CARD32 dwGEMode = 0, srcY=0, srcX, dstY=0, dstX;
+ CARD32 cmd;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+ ViaCommandBuffer *cb = &xl->agpBuf;
+
+ if (!w || !h)
+ return;
+
+ finish_header_agp(cb);
+
+ switch (bpp) {
+ case 16:
+ dwGEMode |= VIA_GEM_16bpp;
+ break;
+ case 32:
+ dwGEMode |= VIA_GEM_32bpp;
+ break;
+ default:
+ dwGEMode |= VIA_GEM_8bpp;
+ break;
+ }
+
+ srcX = srcBase & 31;
+ dstX = dstBase & 31;
+ switch (bpp) {
+ case 16:
+ dwGEMode |= VIA_GEM_16bpp;
+ srcX >>= 2;
+ dstX >>= 2;
+ break;
+ case 32:
+ dwGEMode |= VIA_GEM_32bpp;
+ srcX >>= 4;
+ dstX >>= 4;
+ break;
+ default:
+ dwGEMode |= VIA_GEM_8bpp;
+ break;
+ }
+
+ BEGIN_RING_AGP(cb, xl, 20);
+ WAITFLAGS(cb, LL_MODE_2D);
+
+
+ OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_GEMODE), dwGEMode);
+ cmd = 0;
+
+ if (xdir < 0) {
+ cmd |= VIA_GEC_DECX;
+ srcX += (w - 1);
+ dstX += (w - 1);
+ }
+ if (ydir < 0) {
+ cmd |= VIA_GEC_DECY;
+ srcY += (h - 1);
+ dstY += (h - 1);
+ }
+
+ switch(blitMode) {
+ case VIABLIT_TRANSCOPY:
+ OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_SRCCOLORKEY), color);
+ OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_KEYCONTROL), 0x4000);
+ cmd |= VIA_GEC_BLT | (VIA_BLIT_COPY << 24);
+ break;
+ case VIABLIT_FILL:
+ OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_FGCOLOR), color);
+ cmd |= VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | (VIA_BLIT_FILL << 24);
+ break;
+ default:
+ OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_KEYCONTROL), 0x0);
+ cmd |= VIA_GEC_BLT | (VIA_BLIT_COPY << 24);
+ }
+
+ OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_SRCBASE), (srcBase & ~31) >> 3);
+ OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_DSTBASE), (dstBase & ~31) >> 3);
+ OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_PITCH), VIA_PITCH_ENABLE |
+ (srcPitch >> 3) | (((dstPitch) >> 3) << 16));
+ OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_SRCPOS), ((srcY << 16) | srcX));
+ OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_DSTPOS), ((dstY << 16) | dstX));
+ OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_DIMENSION), (((h - 1) << 16) | (w - 1)));
+ OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_GECMD), cmd);
+}
+
+unsigned
+syncXvMCLowLevel(void *xlp, unsigned int mode, unsigned int doSleep,
+ CARD32 timeStamp)
+{
+ unsigned
+ errors;
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+
+ if (mode == 0) {
+ errors = xl->errors;
+ xl->errors = 0;
+ return errors;
+ }
+
+ if ((mode & (LL_MODE_VIDEO | LL_MODE_3D)) || !xl->use_agp) {
+ if (xl->performLocking)
+ hwlLock(xl,0);
+ if ((xl->videoBuf == &xl->agpBuf) || (mode != LL_MODE_VIDEO))
+ syncDMA(xl, doSleep);
+ if (mode & LL_MODE_3D)
+ syncAccel(xl, mode, doSleep);
+ if (mode & LL_MODE_VIDEO)
+ syncVideo(xl, doSleep);
+ if (xl->performLocking)
+ hwlUnlock(xl,0);
+ } else {
+ viaDMAWaitTimeStamp(xl, timeStamp, doSleep);
+ }
+
+ if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE))
+ syncMpeg(xl, mode, doSleep);
+
+ errors = xl->errors;
+ xl->errors = 0;
+
+ return errors;
+}
+
+static int
+updateLowLevelBuf(XvMCLowLevel *xl, LowLevelBuffer *buf,
+ unsigned width, unsigned height)
+{
+ unsigned
+ stride, size;
+ drm_via_mem_t *mem = &buf->mem;
+ int ret;
+
+ stride = (width + 31) & ~31;
+ size = stride * height + (xl->fbDepth >> 3);
+
+ if (size != mem->size) {
+ if (mem->size)
+ drmCommandWrite(xl->fd, DRM_VIA_FREEMEM, mem, sizeof(*mem));
+ mem->context = *(xl->drmcontext);
+ mem->size = size;
+ mem->type = VIA_MEM_VIDEO;
+
+ if (((ret = drmCommandWriteRead(xl->fd, DRM_VIA_ALLOCMEM, mem, sizeof(mem))) < 0) ||
+ mem->size != size) {
+ mem->size = 0;
+ return -1;
+ }
+ }
+
+ buf->offset = (mem->offset + 31) & ~31;
+ buf->stride = stride;
+ buf->height = height;
+ return 0;
+}
+
+static void
+cleanupLowLevelBuf(XvMCLowLevel *xl, LowLevelBuffer *buf)
+{
+ drm_via_mem_t *mem = &buf->mem;
+
+ if (mem->size)
+ drmCommandWrite(xl->fd, DRM_VIA_FREEMEM, mem, sizeof(mem));
+ mem->size = 0;
+}
+
+
+static void
+*releaseXvMCLowLevel(XvMCLowLevel *xl)
+{
+ switch(xl->state) {
+ case ll_llBuf:
+ cleanupLowLevelBuf(xl, &xl->scale);
+ case ll_timeStamp:
+ viaDMACleanupTimeStamp(xl);
+ case ll_pciBuf:
+ free(xl->pciBuf.buf);
+ case ll_agpBuf:
+ free(xl->agpBuf.buf);
+ case ll_init:
+ free(xl);
+ default:
+ ;
+ }
+ return NULL;
+}
+
+
+void
+*initXvMCLowLevel(int fd, drm_context_t *ctx,
+ drmLockPtr hwLock, drmAddress mmioAddress,
+ drmAddress fbAddress, unsigned fbStride, unsigned fbDepth,
+ unsigned width, unsigned height, int useAgp, unsigned chipId )
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *)malloc(sizeof(XvMCLowLevel));
+
+ if (!xl) return NULL;
+ xl->state = ll_init;
+
+ xl->agpBuf.buf = (CARD32 *)malloc(LL_AGP_CMDBUF_SIZE * sizeof(CARD32));
+ if (!xl->agpBuf.buf) return releaseXvMCLowLevel(xl);
+ xl->state = ll_agpBuf;
+ xl->agpBuf.bufSize = LL_AGP_CMDBUF_SIZE;
+ xl->agpBuf.flushFunc = &agpFlush;
+ xl->agpBuf.pos = 0;
+ xl->agpBuf.mode = 0;
+ xl->agpBuf.waitFlags = 0;
+
+ xl->pciBuf.buf = (CARD32 *)malloc(LL_PCI_CMDBUF_SIZE * sizeof(CARD32));
+ if (!xl->pciBuf.buf) return releaseXvMCLowLevel(xl);
+ xl->state = ll_pciBuf;
+ xl->pciBuf.bufSize = LL_PCI_CMDBUF_SIZE;
+ xl->pciBuf.flushFunc = &pciFlush;
+ xl->pciBuf.pos = 0;
+ xl->pciBuf.mode = 0;
+ xl->pciBuf.waitFlags = 0;
+
+ xl->use_agp = useAgp;
+ xl->fd = fd;
+ xl->drmcontext = ctx;
+ xl->hwLock = hwLock;
+ xl->mmioAddress = mmioAddress;
+ xl->fbAddress = fbAddress;
+ xl->fbDepth = fbDepth;
+ xl->fbStride = fbStride;
+ xl->width = width;
+ xl->height = height;
+ xl->performLocking = 1;
+ xl->errors = 0;
+ xl->agpSync = 0;
+ xl->chipId = chipId;
+
+ if (viaDMAInitTimeStamp(xl))
+ return releaseXvMCLowLevel(xl);
+ xl->state = ll_timeStamp;
+
+ xl->scale.mem.size = 0;
+ xl->back.mem.size = 0;
+
+ if (updateLowLevelBuf(xl, &xl->scale, width, height))
+ return releaseXvMCLowLevel(xl);
+ xl->state = ll_llBuf;
+
+#ifdef VIDEO_DMA
+ xl->videoBuf = &xl->agpBuf;
+#else
+ xl->videoBuf = &xl->pciBuf;
+#endif
+
+ return xl;
+}
+
+void
+setLowLevelLocking(void *xlp, int performLocking)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+ xl->performLocking = performLocking;
+}
+
+void
+closeXvMCLowLevel(void *xlp)
+{
+ XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
+ releaseXvMCLowLevel(xl);
+}
diff --git a/nx-X11/lib/XvMC/hw/via/viaLowLevel.h b/nx-X11/lib/XvMC/hw/via/viaLowLevel.h
new file mode 100644
index 000000000..12e5fe373
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/via/viaLowLevel.h
@@ -0,0 +1,148 @@
+/*****************************************************************************
+ * VIA Unichrome XvMC extension client lib.
+ *
+ * Copyright (c) 2004 The Unichrome Project. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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.
+ */
+
+
+/*
+ * Authors: Thomas Hellström 2004 - 2005.
+ */
+
+
+#ifndef VIA_LOWLEVEL_H
+#define VIA_LOWLEVEL_H
+
+
+/*
+ * The below define is cache size sensitive. Increasing the AGP buffer size
+ * will enable the library to do deeper pipelining, but will degrade the
+ * performance in the drm dma command verifier.
+ */
+
+#define LL_AGP_CMDBUF_SIZE (4096*2)
+#define LL_PCI_CMDBUF_SIZE (4096)
+
+#define LL_MODE_DECODER_SLICE 0x01
+#define LL_MODE_DECODER_IDLE 0x02
+#define LL_MODE_VIDEO 0x04
+#define LL_MODE_2D 0x08
+#define LL_MODE_3D 0x10
+
+/*
+ * Errors
+ */
+
+#define LL_DECODER_TIMEDOUT 0x00000001
+#define LL_IDCT_FIFO_ERROR 0x00000002
+#define LL_SLICE_FIFO_ERROR 0x00000004
+#define LL_SLICE_FAULT 0x00000008
+#define LL_DMA_TIMEDOUT 0x00000010
+#define LL_VIDEO_TIMEDOUT 0x00000020
+#define LL_ACCEL_TIMEDOUT 0x00000040
+#define LL_PCI_COMMAND_ERR 0x00000080
+#define LL_AGP_COMMAND_ERR 0x00000100
+
+#define VIA_SLICEBUSYMASK 0x00000200
+#define VIA_BUSYMASK 0x00000207
+#define VIA_SLICEIDLEVAL 0x00000200
+#define VIA_IDLEVAL 0x00000204
+
+#include "via_drm.h"
+#include "viaXvMCPriv.h"
+
+#define setRegion(xx,yy,ww,hh,region) \
+ do { \
+ (region).x = (xx); \
+ (region).y = (yy); \
+ (region).w = (ww); \
+ (region).h = (hh); \
+ } while(0)
+
+#define regionEqual(r1, r2) \
+ ((r1).x == (r2).x && \
+ (r1).y == (r2).y && \
+ (r1).w == (r2).w && \
+ (r1).h == (r2).h)
+
+
+
+extern void
+*initXvMCLowLevel(int fd, drm_context_t *ctx,
+ drmLockPtr hwLock, drmAddress mmioAddress,
+ drmAddress fbAddress, unsigned fbStride, unsigned fbDepth,
+ unsigned width, unsigned height, int useAgp, unsigned chipId );
+
+extern void setLowLevelLocking(void *xlp, int perFormLocking);
+extern void closeXvMCLowLevel(void *xlp);
+extern void flushPCIXvMCLowLevel(void *xlp);
+extern CARD32 viaDMATimeStampLowLevel(void *xlp);
+extern void setAGPSyncLowLevel(void *xlp, int val, CARD32 timeStamp);
+
+
+/*
+ * These two functions also return and clear the current error status.
+ */
+
+extern unsigned flushXvMCLowLevel(void *xlp);
+extern unsigned syncXvMCLowLevel(void *xlp, unsigned int mode,
+ unsigned int doSleep, CARD32 timeStamp);
+
+extern void hwlUnlock(void *xlp, int videoLock);
+extern void hwlLock(void *xlp, int videoLock);
+
+extern void viaVideoSetSWFLipLocked(void *xlp, unsigned yOffs, unsigned uOffs,
+ unsigned vOffs, unsigned yStride, unsigned uvStride);
+
+extern void viaMpegReset(void *xlp);
+extern void viaMpegWriteSlice(void *xlp, CARD8* slice,
+ int nBytes, CARD32 sCode);
+extern void viaMpegSetSurfaceStride(void *xlp, ViaXvMCContext *ctx);
+extern void viaMpegSetFB(void *xlp,unsigned i, unsigned yOffs,
+ unsigned uOffs, unsigned vOffs);
+extern void viaMpegBeginPicture(void *xlp, ViaXvMCContext *ctx,unsigned width,
+ unsigned height,const XvMCMpegControl *control);
+
+/*
+ * Low-level Video functions in viaLowLevel.c
+ */
+
+
+extern void viaBlit(void *xlp,unsigned bpp,unsigned srcBase,
+ unsigned srcPitch,unsigned dstBase,unsigned dstPitch,
+ unsigned w,unsigned h,int xdir,int ydir,
+ unsigned blitMode, unsigned color);
+
+extern void viaVideoSWFlipLocked(void *xlp, unsigned flags,
+ int progressiveSequence);
+
+extern void viaVideoSubPictureLocked(void *xlp,ViaXvMCSubPicture *pViaSubPic);
+extern void viaVideoSubPictureOffLocked(void *xlp);
+
+
+
+
+#define PCI_CHIP_VT3204 0x3108 /* K8M800 */
+#define PCI_CHIP_VT3259 0x3118 /* PM800/PM880/CN400 */
+#define PCI_CHIP_CLE3122 0x3122 /* CLE266 */
+#define PCI_CHIP_VT3205 0x7205 /* KM400 */
+
+#endif
diff --git a/nx-X11/lib/XvMC/hw/via/viaXvMC.c b/nx-X11/lib/XvMC/hw/via/viaXvMC.c
new file mode 100644
index 000000000..eebc87ea8
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/via/viaXvMC.c
@@ -0,0 +1,1964 @@
+/*****************************************************************************
+ * VIA Unichrome XvMC extension client lib.
+ *
+ * Copyright (c) 2004-2005 Thomas Hellström. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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.
+ */
+
+
+/*
+ *Author: Thomas Hellström, 2004.
+ *Bugfixes by among others Pascal Brisset and Terry Barnaby.
+ *DRI protocol support by Thomas Hellström, 2005.
+ */
+
+#undef WAITPAUSE
+
+#include "viaXvMCPriv.h"
+#include "viaLowLevel.h"
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <time.h>
+#include <fourcc.h>
+#include <X11/extensions/Xv.h>
+#include <xf86drm.h>
+#include <pthread.h>
+#include <X11/extensions/vldXvMC.h>
+#include "xf86dri.h"
+#include "driDrawable.h"
+
+#define SAREAPTR(ctx) ((ViaXvMCSAreaPriv *) \
+ (((CARD8 *)(ctx)->sAreaAddress) + \
+ (ctx)->sAreaPrivOffset))
+
+
+
+static int error_base;
+static int event_base;
+static unsigned numContexts = 0;
+static int globalFD;
+static drmAddress sAreaAddress;
+static drmAddress fbAddress;
+static drmAddress mmioAddress;
+
+
+#define FOURCC_XVMC (('C' << 24) + ('M' << 16) + ('V' << 8) + 'X')
+
+#define ppthread_mutex_lock(arg) \
+ { \
+ pthread_mutex_lock(arg); \
+ } \
+
+#define ppthread_mutex_unlock(arg) \
+ { \
+ pthread_mutex_unlock(arg); \
+ } \
+
+static unsigned yOffs (ViaXvMCSurface *srf)
+{
+ return srf->offsets[0];
+}
+
+static unsigned vOffs (ViaXvMCSurface *srf)
+{
+ return srf->offsets[0] + srf->yStride * srf->height;
+}
+
+static unsigned uOffs (ViaXvMCSurface *srf)
+{
+ return srf->offsets[0] + ( srf->yStride * srf->height) +
+ (srf->yStride >> 1) * (srf->height >> 1);
+}
+
+
+static void defaultQMatrices(ViaXvMCContext *ctx)
+{
+ int i;
+
+ static const char intra[64] = {
+ 8, 16, 19, 22, 26, 27, 29, 34, 16, 16, 22, 24, 27, 29, 34, 37,
+ 19, 22, 26, 27, 29, 34, 34, 38, 22, 22, 26, 27, 29, 34, 37, 40,
+ 22, 26, 27, 29, 32, 35, 40, 48, 26, 27, 29, 32, 35, 40, 48, 58,
+ 26, 27, 29, 34, 38, 46, 56, 69, 27, 29, 35, 38, 46, 56, 69, 83
+ };
+
+ for( i=0; i<64; ++i) {
+ ctx->intra_quantiser_matrix[i] = intra[i];
+ ctx->non_intra_quantiser_matrix[i] = 16;
+ }
+ ctx->intraLoaded = 0;
+ ctx->nonIntraLoaded = 0;
+}
+
+
+static void releaseDecoder(ViaXvMCContext *ctx,int clearCtx)
+{
+ volatile ViaXvMCSAreaPriv *sAPriv;
+
+ sAPriv = SAREAPTR(ctx);
+ UNICHROME_UNLOCK(ctx->fd, UNICHROME_LOCK_DECODER1, sAPriv, ctx->drmcontext);
+}
+
+
+static int grabDecoder( ViaXvMCContext *ctx, int *hadLastLock)
+{
+ volatile ViaXvMCSAreaPriv *sAPriv = SAREAPTR(ctx);
+ int retFtx, lc;
+
+ /*
+ * Try to grab the decoder. If it is not available we will sleep until
+ * it becomes available or for a maximum of 20 ms.
+ * Then try to grab it again, unless a timeout occured. If the decoder is
+ * available, the lock should be reasonably fast.
+ */
+
+ if (ctx->haveDecoder) {
+ flushXvMCLowLevel(ctx->xl); /* Ignore errors here. */
+
+ /*fprintf(stderr,"ViaXvMC: ERROR: Trying to re-lock decoder.\n"); */
+ *hadLastLock = 1;
+ return 0;
+ }
+ UNICHROME_LOCK(ctx->fd, UNICHROME_LOCK_DECODER1, sAPriv, ctx->drmcontext, lc,
+ retFtx);
+ *hadLastLock = (ctx->drmcontext == lc);
+
+ return retFtx;
+}
+
+static void setupAttribDesc(Display *display, XvPortID port,
+ const ViaXvMCAttrHolder *attrib,
+ XvAttribute attribDesc[])
+{
+ XvAttribute *XvAttribs,*curAD;
+ int num;
+ unsigned i,j;
+
+ XLockDisplay(display);
+ XvAttribs = XvQueryPortAttributes(display, port, &num);
+ for(i=0; i<attrib->numAttr; ++i) {
+ curAD = attribDesc + i;
+ curAD->flags = 0;
+ curAD->min_value = 0;
+ curAD->max_value = 0;
+ curAD->name = NULL;
+ for(j=0; j<num; ++j) {
+ if (attrib->attributes[i].attribute ==
+ XInternAtom(display,XvAttribs[j].name,TRUE)) {
+ *curAD = XvAttribs[j];
+ curAD->name = strdup(XvAttribs[j].name);
+ break;
+ }
+ }
+ }
+ if (XvAttribs) XFree(XvAttribs);
+ XUnlockDisplay(display);
+
+}
+
+static void releaseAttribDesc(int numAttr, XvAttribute attribDesc[])
+{
+ int i;
+
+ for (i=0; i<numAttr; ++i) {
+ if (attribDesc[i].name)
+ free(attribDesc[i].name);
+ }
+}
+
+static Status releaseContextResources(Display *display, XvMCContext *context,
+ int freePrivate, Status errType)
+{
+ ViaXvMCContext *pViaXvMC = (ViaXvMCContext *) context->privData;
+
+ switch(pViaXvMC->resources) {
+ case context_drawHash:
+ driDestroyHashContents( pViaXvMC->drawHash );
+ drmHashDestroy( pViaXvMC->drawHash );
+ case context_lowLevel:
+ closeXvMCLowLevel(pViaXvMC->xl);
+ case context_mutex:
+ pthread_mutex_destroy(&pViaXvMC->ctxMutex);
+ case context_drmContext:
+ XLockDisplay(display);
+ uniDRIDestroyContext(display, pViaXvMC->screen, pViaXvMC->id);
+ XUnlockDisplay(display);
+ case context_sAreaMap:
+ numContexts--;
+ if (numContexts == 0)
+ drmUnmap(pViaXvMC->sAreaAddress,pViaXvMC->sAreaSize);
+ case context_fbMap:
+ if (numContexts == 0)
+ drmUnmap(pViaXvMC->fbAddress,pViaXvMC->fbSize);
+ case context_mmioMap:
+ if (numContexts == 0)
+ drmUnmap(pViaXvMC->mmioAddress,pViaXvMC->mmioSize);
+ case context_fd:
+ if (numContexts == 0) {
+ if (pViaXvMC->fd >= 0)
+ drmClose(pViaXvMC->fd);
+ }
+ pViaXvMC->fd = -1;
+ case context_driConnection:
+ if (numContexts == 0) {
+ XLockDisplay(display);
+ uniDRICloseConnection(display, pViaXvMC->screen);
+ XUnlockDisplay(display);
+ }
+ case context_context:
+ XLockDisplay(display);
+ _xvmc_destroy_context(display, context);
+ XUnlockDisplay(display);
+ if (!freePrivate) break;
+ default:
+ free(pViaXvMC);
+ }
+ return errType;
+}
+
+Status XvMCCreateContext(Display *display, XvPortID port,
+ int surface_type_id, int width, int height, int flags,
+ XvMCContext *context)
+{
+ ViaXvMCContext *pViaXvMC;
+ int priv_count;
+ uint *priv_data;
+ uint magic;
+ unsigned i;
+ Status ret;
+ int major, minor;
+ ViaXvMCCreateContextRec *tmpComm;
+ drmVersionPtr drmVer;
+ char *curBusID;
+ int isCapable;
+
+ /*
+ * Verify Obvious things first
+ */
+
+ if(context == NULL) {
+ return XvMCBadContext;
+ }
+
+ if(!(flags & XVMC_DIRECT)) {
+ fprintf(stderr,"Indirect Rendering not supported! Using Direct.\n");
+ }
+
+ /*
+ *FIXME: Check $DISPLAY for legal values here
+ */
+
+ context->surface_type_id = surface_type_id;
+ context->width = (unsigned short)((width + 15) & ~15);
+ context->height = (unsigned short)((height + 15) & ~15);
+ context->flags = flags;
+ context->port = port;
+
+ /*
+ * Width, Height, and flags are checked against surface_type_id
+ * and port for validity inside the X server, no need to check
+ * here.
+ */
+
+ /* Allocate private Context data */
+ context->privData = (void *)malloc(sizeof(ViaXvMCContext));
+ if(!context->privData) {
+ fprintf(stderr,"Unable to allocate resources for XvMC context.\n");
+ return BadAlloc;
+ }
+
+ pViaXvMC = (ViaXvMCContext *)context->privData;
+ pViaXvMC->resources = context_none;
+
+ /* Verify the XvMC extension exists */
+
+ XLockDisplay(display);
+ if(! XvMCQueryExtension(display, &event_base,
+ &error_base)) {
+ fprintf(stderr,"XvMC Extension is not available!\n");
+ free(pViaXvMC);
+ XUnlockDisplay(display);
+ return BadAlloc;
+ }
+
+ /* Verify XvMC version */
+ ret = XvMCQueryVersion(display, &major, &minor);
+ if(ret) {
+ fprintf(stderr,"XvMCQuery Version Failed, unable to determine "
+ "protocol version!\n");
+ }
+ XUnlockDisplay(display);
+
+ /* FIXME: Check Major and Minor here */
+
+ XLockDisplay(display);
+ if((ret = _xvmc_create_context(display, context, &priv_count,
+ &priv_data))) {
+ XUnlockDisplay(display);
+ fprintf(stderr,"Unable to create XvMC Context.\n");
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+ XUnlockDisplay(display);
+
+ /*
+ * Check size and version of returned data.
+ */
+
+ tmpComm = ( ViaXvMCCreateContextRec *) priv_data;
+ if(priv_count != (sizeof(ViaXvMCCreateContextRec) >> 2)) {
+ fprintf(stderr,"_xvmc_create_context() returned incorrect "
+ "data size!\n");
+ fprintf(stderr,"\tExpected %d, got %d\n",
+ (int) (sizeof(ViaXvMCCreateContextRec) >> 2),
+ (int) priv_count);
+ XFree(priv_data);
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+ pViaXvMC->resources = context_context;
+
+ if ((tmpComm->major != VIAXVMC_MAJOR) ||
+ (tmpComm->minor != VIAXVMC_MINOR)) {
+ fprintf(stderr,"Version mismatch between the X via driver\n"
+ "and the XvMC library. Cannot continue!\n");
+ XFree(priv_data);
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+
+ pViaXvMC->ctxNo = tmpComm->ctxNo;
+ pViaXvMC->fbOffset = tmpComm->fbOffset;
+ pViaXvMC->fbSize = tmpComm->fbSize;
+ pViaXvMC->mmioOffset = tmpComm->mmioOffset;
+ pViaXvMC->mmioSize = tmpComm->mmioSize;
+ pViaXvMC->sAreaSize = tmpComm->sAreaSize;
+ pViaXvMC->sAreaPrivOffset = tmpComm->sAreaPrivOffset;
+ pViaXvMC->decoderOn = 0;
+ pViaXvMC->xvMCPort = tmpComm->xvmc_port;
+ pViaXvMC->useAGP = tmpComm->useAGP;
+ pViaXvMC->attrib = tmpComm->initAttrs;
+ pViaXvMC->screen = tmpComm->screen;
+ pViaXvMC->depth = tmpComm->depth;
+ pViaXvMC->stride = tmpComm->stride;
+ pViaXvMC->chipId = tmpComm->chipId;
+
+ /*
+ * Must free the private data we were passed from X
+ */
+
+ XFree(priv_data);
+
+ /*
+ * Check for direct rendering capable, establish DRI and DRM connections,
+ * map framebuffer, DRI shared area and read-only register areas.
+ * Initial checking for drm has already been done by the server.
+ * Only do this for the first context we create.
+ */
+
+ if (numContexts == 0) {
+ XLockDisplay(display);
+ ret = uniDRIQueryDirectRenderingCapable(display, pViaXvMC->screen, &isCapable);
+ if (!ret || !isCapable) {
+ XUnlockDisplay(display);
+ fprintf(stderr,"Direct Rendering is not available on this system!\n");
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+
+ if (!uniDRIOpenConnection(display, pViaXvMC->screen, &pViaXvMC->sAreaOffset,
+ &curBusID)) {
+ XUnlockDisplay(display);
+ fprintf(stderr,"Could not open DRI connection to X server!\n");
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+ XUnlockDisplay(display);
+
+ strncpy(pViaXvMC->busIdString,curBusID,20);
+ pViaXvMC->busIdString[20] = '\0';
+ XFree(curBusID);
+
+ pViaXvMC->resources = context_driConnection;
+
+ if((pViaXvMC->fd = drmOpen("via",pViaXvMC->busIdString)) < 0) {
+ fprintf(stderr,"DRM Device for via could not be opened.\n");
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+ globalFD = pViaXvMC->fd;
+ pViaXvMC->resources = context_fd;
+
+ if (NULL == (drmVer = drmGetVersion(pViaXvMC->fd))) {
+ fprintf(stderr,
+ "viaXvMC: Could not get drm version.");
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+ if (((drmVer->version_major != 2 ) || (drmVer->version_minor < 0))) {
+ fprintf(stderr,
+ "viaXvMC: Kernel drm is not compatible with XvMC.\n");
+ fprintf(stderr,
+ "viaXvMC: Kernel drm version: %d.%d.%d "
+ "and I need at least version 2.0.0.\n"
+ "Please update.\n",
+ drmVer->version_major,drmVer->version_minor,
+ drmVer->version_patchlevel);
+ drmFreeVersion(drmVer);
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+ drmFreeVersion(drmVer);
+ drmGetMagic(pViaXvMC->fd,&magic);
+
+ XLockDisplay(display);
+ if (!uniDRIAuthConnection(display, pViaXvMC->screen, magic)) {
+ XUnlockDisplay(display);
+ fprintf(stderr, "viaXvMC: X server did not allow DRI. Check permissions.\n");
+ XFree(priv_data);
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+ XUnlockDisplay(display);
+
+ /*
+ * Map the register memory
+ */
+
+ if(drmMap(pViaXvMC->fd,pViaXvMC->mmioOffset,
+ pViaXvMC->mmioSize,&mmioAddress) < 0) {
+ fprintf(stderr,"Unable to map the display chip mmio registers.\n");
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+ pViaXvMC->mmioAddress = mmioAddress;
+ pViaXvMC->resources = context_mmioMap;
+
+ /*
+ * Map Framebuffer memory
+ */
+
+ if(drmMap(pViaXvMC->fd,pViaXvMC->fbOffset,
+ pViaXvMC->fbSize,&fbAddress) < 0) {
+ fprintf(stderr,"Unable to map XvMC Framebuffer.\n");
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+ pViaXvMC->fbAddress = fbAddress;
+ pViaXvMC->resources = context_fbMap;
+
+
+ /*
+ * Map DRI Sarea.
+ */
+
+ if(drmMap(pViaXvMC->fd,pViaXvMC->sAreaOffset,
+ pViaXvMC->sAreaSize,&sAreaAddress) < 0) {
+ fprintf(stderr,"Unable to map DRI SAREA.\n");
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+ } else {
+ pViaXvMC->fd = globalFD;
+ pViaXvMC->mmioAddress = mmioAddress;
+ pViaXvMC->fbAddress = fbAddress;
+ }
+
+ pViaXvMC->sAreaAddress = sAreaAddress;
+ pViaXvMC->resources = context_sAreaMap;
+ numContexts++;
+
+ /*
+ * Find a matching visual. Important only for direct drawing to the visible
+ * frame-buffer.
+ */
+
+ XLockDisplay(display);
+ ret = XMatchVisualInfo(display, pViaXvMC->screen,
+ (pViaXvMC->depth == 32) ? 24 : pViaXvMC->depth, TrueColor,
+ &pViaXvMC->visualInfo);
+ XUnlockDisplay(display);
+ if (!ret) {
+ fprintf(stderr, "viaXvMC: Could not find a matching TrueColor visual.\n");
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+
+ if (!uniDRICreateContext(display, pViaXvMC->screen, pViaXvMC->visualInfo.visual,
+ &pViaXvMC->id, &pViaXvMC->drmcontext)) {
+
+ fprintf(stderr, "viaXvMC: Could not create DRI context.\n");
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+
+ pViaXvMC->resources = context_drmContext;
+
+ for (i=0; i<VIA_MAX_RENDSURF; ++i) {
+ pViaXvMC->rendSurf[i] = 0;
+ }
+ pViaXvMC->lastSrfDisplaying = ~0;
+ setupAttribDesc(display, port, &pViaXvMC->attrib, pViaXvMC->attribDesc);
+
+ pViaXvMC->hwLock = (drmLockPtr) pViaXvMC->sAreaAddress;
+ defaultQMatrices(pViaXvMC);
+ pViaXvMC->chromaIntraLoaded = 1;
+ pViaXvMC->chromaNonIntraLoaded = 1;
+ pViaXvMC->yStride = (width + 31) & ~31;
+ pViaXvMC->haveDecoder = 0;
+ pViaXvMC->attribChanged = 1;
+ pViaXvMC->haveXv = 0;
+ pViaXvMC->port = context->port;
+ pthread_mutex_init(&pViaXvMC->ctxMutex,NULL);
+ pViaXvMC->resources = context_mutex;
+ pViaXvMC->timeStamp = 0;
+ setRegion(0,0,-1,-1,pViaXvMC->sRegion);
+ setRegion(0,0,-1,-1,pViaXvMC->dRegion);
+
+ if (NULL == (pViaXvMC->xl =
+ initXvMCLowLevel(pViaXvMC->fd, &pViaXvMC->drmcontext,
+ pViaXvMC->hwLock, pViaXvMC->mmioAddress,
+ pViaXvMC->fbAddress, pViaXvMC->stride, pViaXvMC->depth,
+ context->width, context->height,
+ pViaXvMC->useAGP, pViaXvMC->chipId))) {
+
+ fprintf(stderr,"ViaXvMC: Could not allocate timestamp blit area.\n");
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+ pViaXvMC->resources = context_lowLevel;
+ setAGPSyncLowLevel(pViaXvMC->xl, 1, 0);
+
+ if (NULL == (pViaXvMC->drawHash = drmHashCreate())) {
+ fprintf(stderr,"ViaXvMC: Could not allocate drawable hash table.\n");
+ return releaseContextResources(display, context, 1, BadAlloc);
+ }
+ pViaXvMC->resources = context_drawHash;
+
+
+ if (numContexts == 1) {
+ hwlLock(pViaXvMC->xl,1);
+ setLowLevelLocking(pViaXvMC->xl,0);
+ viaVideoSubPictureOffLocked(pViaXvMC->xl);
+ flushXvMCLowLevel(pViaXvMC->xl);
+ setLowLevelLocking(pViaXvMC->xl,1);
+ hwlUnlock(pViaXvMC->xl,1);
+ }
+
+ return Success;
+}
+
+
+Status XvMCDestroyContext(Display *display, XvMCContext *context)
+{
+ ViaXvMCContext *pViaXvMC;
+
+
+ if(context == NULL) {
+ return (error_base + XvMCBadContext);
+ }
+ if(NULL == (pViaXvMC = context->privData)) {
+ return (error_base + XvMCBadContext);
+ }
+
+ /*
+ * Release decoder if we have it. In case of crash or termination
+ * before XvMCDestroyContext, the X server will take care of this.
+ */
+
+ releaseAttribDesc(pViaXvMC->attrib.numAttr,pViaXvMC->attribDesc);
+ releaseDecoder(pViaXvMC,1);
+ return releaseContextResources(display, context, 1, Success);
+}
+
+Status XvMCCreateSurface( Display *display, XvMCContext *context,
+ XvMCSurface *surface)
+{
+ ViaXvMCContext *pViaXvMC;
+ ViaXvMCSurface *pViaSurface;
+ int priv_count;
+ unsigned *priv_data;
+ unsigned i;
+ Status ret;
+
+ if((surface == NULL) || (context == NULL) || (display == NULL)){
+ return BadValue;
+ }
+
+ pViaXvMC = (ViaXvMCContext *)context->privData;
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+
+ if(pViaXvMC == NULL) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return (error_base + XvMCBadContext);
+ }
+
+ pViaSurface = surface->privData = (ViaXvMCSurface *)malloc(sizeof(ViaXvMCSurface));
+ if(!surface->privData) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return BadAlloc;
+ }
+ XLockDisplay(display);
+ if((ret = _xvmc_create_surface(display, context, surface,
+ &priv_count, &priv_data))) {
+ XUnlockDisplay(display);
+ free(pViaSurface);
+ fprintf(stderr,"Unable to create XvMC Surface.\n");
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return ret;
+ }
+ XUnlockDisplay(display);
+
+ pViaSurface->srfNo = priv_data[0];
+
+ /*
+ * Store framebuffer offsets to the buffers allocated for this surface.
+ * For some chipset revisions, surfaces may be double-buffered.
+ */
+
+ pViaSurface->numBuffers = priv_data[1];
+ for (i=0; i < pViaSurface->numBuffers; ++i) {
+ pViaSurface->offsets[i] = priv_data[i+2];
+ }
+ pViaSurface->curBuf = 0;
+
+
+ /* Free data returned from xvmc_create_surface */
+
+ XFree(priv_data);
+
+ pViaSurface->width = context->width;
+ pViaSurface->height = context->height;
+ pViaSurface->yStride = pViaXvMC->yStride;
+ pViaSurface->privContext = pViaXvMC;
+ pViaSurface->privSubPic = NULL;
+ pViaSurface->needsSync = 0;
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+}
+
+Status XvMCDestroySurface(Display *display, XvMCSurface *surface)
+{
+ ViaXvMCSurface *pViaSurface;
+
+ if((display == NULL) || (surface == NULL)) {
+ return BadValue;
+ }
+ if(surface->privData == NULL) {
+ return (error_base + XvMCBadSurface);
+ }
+
+ pViaSurface = (ViaXvMCSurface *)surface->privData;
+
+ XLockDisplay(display);
+ _xvmc_destroy_surface(display,surface);
+ XUnlockDisplay(display);
+
+ free(pViaSurface);
+ surface->privData = NULL;
+ return Success;
+}
+
+Status XvMCPutSlice2(Display *display,XvMCContext *context, char *slice,
+ int nBytes, int sliceCode)
+{
+ ViaXvMCContext *pViaXvMC;
+ CARD32 sCode = 0x00010000 | (sliceCode & 0xFF) << 24;
+
+ if((display == NULL) || (context == NULL)) {
+ return BadValue;
+ }
+ if(NULL == (pViaXvMC = context->privData)) {
+ return (error_base + XvMCBadContext);
+ }
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+ if (!pViaXvMC->haveDecoder) {
+ fprintf(stderr,"XvMCPutSlice: This context does not own decoder!\n");
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return BadAlloc;
+ }
+
+ viaMpegWriteSlice(pViaXvMC->xl, (CARD8 *)slice, nBytes, sCode);
+
+ flushPCIXvMCLowLevel(pViaXvMC->xl);
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+}
+
+Status XvMCPutSlice(Display *display,XvMCContext *context, char *slice,
+ int nBytes)
+{
+ ViaXvMCContext *pViaXvMC;
+
+ if((display == NULL) || (context == NULL)) {
+ return BadValue;
+ }
+ if(NULL == (pViaXvMC = context->privData)) {
+ return (error_base + XvMCBadContext);
+ }
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+
+ if (!pViaXvMC->haveDecoder) {
+ fprintf(stderr,"XvMCPutSlice: This context does not own decoder!\n");
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return BadAlloc;
+ }
+
+ viaMpegWriteSlice(pViaXvMC->xl, (CARD8 *)slice, nBytes, 0);
+ flushPCIXvMCLowLevel(pViaXvMC->xl);
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+}
+
+
+static Status updateXVOverlay(Display *display,ViaXvMCContext *pViaXvMC,
+ ViaXvMCSurface *pViaSurface, Drawable draw,
+ short srcx, short srcy, unsigned short srcw,
+ unsigned short srch,short destx,short desty,
+ unsigned short destw,unsigned short desth)
+{
+ ViaXvMCCommandBuffer buf;
+ ViaXvMCSubPicture *pViaSubPic;
+ Status ret;
+
+ if (!pViaXvMC->haveXv) {
+ pViaXvMC->xvImage =
+ XvCreateImage(display,pViaXvMC->port,FOURCC_XVMC,
+ (char *)&buf,pViaSurface->width,
+ pViaSurface->height);
+ pViaXvMC->gc = XCreateGC(display,draw,0,0);
+ pViaXvMC->haveXv = 1;
+ }
+ pViaXvMC->draw = draw;
+ pViaXvMC->xvImage->data = (char *)&buf;
+
+ buf.command = (pViaXvMC->attribChanged) ?
+ VIA_XVMC_COMMAND_FDISPLAY : VIA_XVMC_COMMAND_DISPLAY;
+ buf.ctxNo = pViaXvMC->ctxNo | VIA_XVMC_VALID;
+ buf.srfNo = pViaSurface->srfNo | VIA_XVMC_VALID;
+ pViaSubPic = pViaSurface->privSubPic;
+ buf.subPicNo = ((NULL == pViaSubPic) ? 0 : pViaSubPic->srfNo )
+ | VIA_XVMC_VALID;
+ buf.attrib = pViaXvMC->attrib;
+
+ XLockDisplay(display);
+
+ if ((ret = XvPutImage(display,pViaXvMC->port,draw,pViaXvMC->gc,
+ pViaXvMC->xvImage,srcx,srcy,srcw,srch,
+ destx,desty,destw,desth))) {
+ XUnlockDisplay(display);
+ return ret;
+ }
+ XSync(display, 0);
+ XUnlockDisplay(display);
+ pViaXvMC->attribChanged = 0;
+ return Success;
+}
+
+
+Status XvMCPutSurface(Display *display,XvMCSurface *surface,Drawable draw,
+ short srcx, short srcy, unsigned short srcw,
+ unsigned short srch,short destx,short desty,
+ unsigned short destw,unsigned short desth, int flags)
+{
+ /*
+ * This function contains some hairy locking logic. What we really want to
+ * do is to flip the picture ASAP, to get a low latency and smooth playback.
+ * However, if somebody else used the overlay since we used it last or if it is
+ * our first time, we'll have to call X to update the overlay first. Otherwise
+ * we'll do the overlay update once we've flipped. Since we release the hardware
+ * lock when we call X, X needs to verify using the SAREA that nobody else flipped
+ * in a picture between the lock release and the X server control. Similarly
+ * when the overlay update returns, we have to make sure that we still own the
+ * overlay.
+ */
+
+ ViaXvMCSurface *pViaSurface;
+ ViaXvMCContext *pViaXvMC;
+ ViaXvMCSubPicture *pViaSubPic;
+ volatile ViaXvMCSAreaPriv *sAPriv;
+ Status ret;
+ unsigned dispSurface, lastSurface;
+ int overlayUpdated;
+ drawableInfo *drawInfo;
+ XvMCRegion sReg, dReg;
+ Bool forceUpdate = FALSE;
+
+ if((display == NULL) || (surface == NULL)) {
+ return BadValue;
+ }
+ if(NULL == (pViaSurface = surface->privData )) {
+ return (error_base + XvMCBadSurface);
+ }
+ if (NULL == (pViaXvMC = pViaSurface->privContext)) {
+ return (error_base + XvMCBadContext);
+ }
+
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+ pViaSubPic = pViaSurface->privSubPic;
+ sAPriv = SAREAPTR( pViaXvMC );
+
+ setRegion(srcx, srcy, srcw, srch, sReg);
+ setRegion(destx, desty, destw, desth, dReg);
+
+
+ if ((!regionEqual(sReg, pViaXvMC->sRegion)) ||
+ (!regionEqual(dReg, pViaXvMC->dRegion))) {
+
+ /*
+ * Force update of the video overlay to match the new format.
+ */
+
+ pViaXvMC->sRegion = sReg;
+ pViaXvMC->dRegion = dReg;
+ forceUpdate = TRUE;
+ }
+
+
+ hwlLock(pViaXvMC->xl,1);
+
+ if (getDRIDrawableInfoLocked(pViaXvMC->drawHash, display, pViaXvMC->screen, draw, 0,
+ pViaXvMC->fd, pViaXvMC->drmcontext, pViaXvMC->sAreaAddress,
+ FALSE, &drawInfo, sizeof(*drawInfo))) {
+
+ hwlUnlock(pViaXvMC->xl,1);
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return BadAccess;
+ }
+
+ setLowLevelLocking(pViaXvMC->xl,0);
+
+
+ /*
+ * Put a surface ID in the SAREA to "authenticate" to the
+ * X server.
+ */
+
+ dispSurface = sAPriv->XvMCDisplaying[pViaXvMC->xvMCPort];
+ lastSurface = pViaXvMC->lastSrfDisplaying;
+ sAPriv->XvMCDisplaying[pViaXvMC->xvMCPort] =
+ pViaXvMC->lastSrfDisplaying = pViaSurface->srfNo | VIA_XVMC_VALID;
+ overlayUpdated = 0;
+
+ viaVideoSetSWFLipLocked(pViaXvMC->xl, yOffs(pViaSurface), uOffs(pViaSurface),
+ vOffs(pViaSurface), pViaSurface->yStride, pViaSurface->yStride >> 1);
+
+ while ((lastSurface != dispSurface) || forceUpdate) {
+
+ forceUpdate = FALSE;
+ flushPCIXvMCLowLevel(pViaXvMC->xl);
+ setLowLevelLocking(pViaXvMC->xl,1);
+ hwlUnlock(pViaXvMC->xl,1);
+
+ /*
+ * We weren't the last to display. Update the overlay before flipping.
+ */
+
+ ret = updateXVOverlay(display,pViaXvMC,pViaSurface,draw,srcx,srcy,srcw,
+ srch,destx,desty,destw,desth);
+ if (ret) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return ret;
+ }
+
+ hwlLock(pViaXvMC->xl,1);
+
+ if (getDRIDrawableInfoLocked(pViaXvMC->drawHash, display, pViaXvMC->screen, draw, 0,
+ pViaXvMC->fd, pViaXvMC->drmcontext, pViaXvMC->sAreaAddress,
+ FALSE, &drawInfo, sizeof(*drawInfo))) {
+
+ hwlUnlock(pViaXvMC->xl,1);
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return BadAccess;
+ }
+
+ setLowLevelLocking(pViaXvMC->xl,0);
+ lastSurface = pViaSurface->srfNo | VIA_XVMC_VALID;
+ dispSurface = sAPriv->XvMCDisplaying[pViaXvMC->xvMCPort];
+ overlayUpdated = 1;
+ }
+
+
+ /*
+ * Subpictures
+ */
+
+ if (NULL != pViaSubPic) {
+ if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort]
+ != (pViaSubPic->srfNo | VIA_XVMC_VALID)) {
+ sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] =
+ pViaSubPic->srfNo | VIA_XVMC_VALID;
+ viaVideoSubPictureLocked(pViaXvMC->xl, pViaSubPic);
+ }
+ } else {
+ if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] & VIA_XVMC_VALID) {
+ viaVideoSubPictureOffLocked(pViaXvMC->xl);
+ sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] &= ~VIA_XVMC_VALID;
+ }
+ }
+
+ /*
+ * Flip
+ */
+
+ viaVideoSWFlipLocked(pViaXvMC->xl, flags, pViaSurface->progressiveSequence);
+ flushXvMCLowLevel(pViaXvMC->xl);
+
+ setLowLevelLocking(pViaXvMC->xl,1);
+ hwlUnlock(pViaXvMC->xl,1);
+
+ if (overlayUpdated || !drawInfo->touched ) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+ }
+
+ /*
+ * Update overlay
+ */
+
+ ret = updateXVOverlay(display,pViaXvMC,pViaSurface,draw,srcx,srcy,srcw,
+ srch,destx,desty,destw,desth);
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return ret;
+
+}
+
+Status XvMCBeginSurface(Display *display,
+ XvMCContext *context,
+ XvMCSurface *target_surface,
+ XvMCSurface *past_surface,
+ XvMCSurface *future_surface,
+ const XvMCMpegControl *control)
+{
+ ViaXvMCSurface *targS,*futS,*pastS;
+ ViaXvMCContext *pViaXvMC;
+ int hadDecoderLast;
+ CARD32 timeStamp;
+
+ if((display == NULL) || (context == NULL) || (target_surface == NULL)) {
+ return BadValue;
+ }
+
+ pViaXvMC = context->privData;
+
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+ if (grabDecoder(pViaXvMC, &hadDecoderLast)) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return BadAlloc;
+ }
+ pViaXvMC->haveDecoder = 1;
+
+ /*
+ * We need to wait for decoder idle at next flush, since hardware doesn't queue
+ * beginsurface requests until the decoder is idle. This is
+ * done by waiting on the last previous timestamp, or if there was another context
+ * having the decoder before us, by emitting a new one.
+ */
+
+ if (pViaXvMC->useAGP) {
+ if (!hadDecoderLast || pViaXvMC->timeStamp == 0) {
+ timeStamp = viaDMATimeStampLowLevel(pViaXvMC->xl);
+ if (flushXvMCLowLevel(pViaXvMC->xl)) {
+ releaseDecoder(pViaXvMC, 0);
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return BadAlloc;
+ }
+ pViaXvMC->timeStamp = timeStamp;
+ } else {
+ timeStamp = pViaXvMC->timeStamp;
+ }
+ setAGPSyncLowLevel(pViaXvMC->xl, 1, timeStamp);
+ }
+
+ if (!hadDecoderLast || !pViaXvMC->decoderOn) {
+ pViaXvMC->intraLoaded = 0;
+ pViaXvMC->nonIntraLoaded = 0;
+ }
+
+ viaMpegReset(pViaXvMC->xl);
+
+ targS = (ViaXvMCSurface *)target_surface->privData;
+ futS = NULL;
+ pastS = NULL;
+
+
+ pViaXvMC->rendSurf[0] = targS->srfNo | VIA_XVMC_VALID;
+ if (future_surface) {
+ futS = (ViaXvMCSurface *)future_surface->privData;
+ futS->needsSync = 0;
+ }
+ if (past_surface) {
+ pastS = (ViaXvMCSurface *)past_surface->privData;
+ pastS->needsSync = 0;
+ }
+
+
+ targS->progressiveSequence = (control->flags & XVMC_PROGRESSIVE_SEQUENCE);
+ targS->topFieldFirst = (control->flags & XVMC_TOP_FIELD_FIRST);
+ targS->privSubPic = NULL;
+
+ viaMpegSetSurfaceStride(pViaXvMC->xl,pViaXvMC);
+
+ viaMpegSetFB(pViaXvMC->xl,0,yOffs(targS),uOffs(targS),vOffs(targS));
+ if (past_surface) {
+ viaMpegSetFB(pViaXvMC->xl,1,yOffs(pastS),uOffs(pastS),vOffs(pastS));
+ } else {
+ viaMpegSetFB(pViaXvMC->xl,1,0,0,0);
+ }
+
+ if (future_surface) {
+ viaMpegSetFB(pViaXvMC->xl,2,yOffs(futS),uOffs(futS),vOffs(futS));
+ } else {
+ viaMpegSetFB(pViaXvMC->xl,2,0,0,0);
+ }
+
+ viaMpegBeginPicture(pViaXvMC->xl,pViaXvMC,context->width,context->height,control);
+ flushPCIXvMCLowLevel(pViaXvMC->xl);
+ targS->needsSync = 1;
+ targS->syncMode = LL_MODE_DECODER_IDLE;
+ pViaXvMC->decoderOn = 1;
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+}
+
+
+Status XvMCSyncSurface(Display *display,XvMCSurface *surface)
+{
+ ViaXvMCSurface *pViaSurface;
+ ViaXvMCContext *pViaXvMC;
+ unsigned i;
+
+ if((display == NULL) || (surface == NULL)) {
+ return BadValue;
+ }
+ if(surface->privData == NULL) {
+ return (error_base + XvMCBadSurface);
+ }
+
+ pViaSurface = (ViaXvMCSurface *)surface->privData;
+ pViaXvMC = pViaSurface->privContext;
+
+ if(pViaXvMC == NULL) {
+ return (error_base + XvMCBadSurface);
+ }
+
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+
+ if (pViaSurface->needsSync) {
+ CARD32 timeStamp = pViaSurface->timeStamp;
+ int syncMode = pViaSurface->syncMode;
+
+ if (pViaXvMC->useAGP) {
+
+ syncMode = (pViaSurface->syncMode == LL_MODE_2D ||
+ pViaSurface->timeStamp < pViaXvMC->timeStamp) ?
+ LL_MODE_2D : LL_MODE_DECODER_IDLE;
+ if (pViaSurface->syncMode != LL_MODE_2D)
+ timeStamp = pViaXvMC->timeStamp;
+
+ } else if (syncMode != LL_MODE_2D &&
+ pViaXvMC->rendSurf[0] != (pViaSurface->srfNo | VIA_XVMC_VALID)) {
+
+ pViaSurface->needsSync = 0;
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+ }
+
+ if (syncXvMCLowLevel(pViaXvMC->xl, syncMode, 1,
+ pViaSurface->timeStamp)) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return BadValue;
+ }
+ pViaSurface->needsSync = 0;
+ }
+
+ if (pViaXvMC->rendSurf[0] == (pViaSurface->srfNo | VIA_XVMC_VALID)) {
+ pViaSurface->needsSync = 0;
+ for (i=0; i<VIA_MAX_RENDSURF; ++i) {
+ pViaXvMC->rendSurf[i] = 0;
+ }
+ }
+
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+}
+
+Status XvMCLoadQMatrix(Display *display, XvMCContext *context,
+ const XvMCQMatrix *qmx)
+{
+ ViaXvMCContext
+ *pViaXvMC;
+
+ if((display == NULL) || (context == NULL)) {
+ return BadValue;
+ }
+ if(NULL == (pViaXvMC = context->privData)) {
+ return (error_base + XvMCBadContext);
+ }
+
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+ if (qmx->load_intra_quantiser_matrix) {
+ memcpy(pViaXvMC->intra_quantiser_matrix,
+ qmx->intra_quantiser_matrix,
+ sizeof(qmx->intra_quantiser_matrix));
+ pViaXvMC->intraLoaded = 0;
+ }
+
+ if (qmx->load_non_intra_quantiser_matrix) {
+ memcpy(pViaXvMC->non_intra_quantiser_matrix,
+ qmx->non_intra_quantiser_matrix,
+ sizeof(qmx->non_intra_quantiser_matrix));
+ pViaXvMC->nonIntraLoaded = 0;
+ }
+
+ if (qmx->load_chroma_intra_quantiser_matrix) {
+ memcpy(pViaXvMC->chroma_intra_quantiser_matrix,
+ qmx->chroma_intra_quantiser_matrix,
+ sizeof(qmx->chroma_intra_quantiser_matrix));
+ pViaXvMC->chromaIntraLoaded = 0;
+ }
+
+ if (qmx->load_chroma_non_intra_quantiser_matrix) {
+ memcpy(pViaXvMC->chroma_non_intra_quantiser_matrix,
+ qmx->chroma_non_intra_quantiser_matrix,
+ sizeof(qmx->chroma_non_intra_quantiser_matrix));
+ pViaXvMC->chromaNonIntraLoaded = 0;
+ }
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+
+ return Success;
+}
+
+/*
+ * Below, we provide functions unusable for this implementation, but for
+ * standard completeness.
+ */
+
+
+Status XvMCRenderSurface
+(
+ Display *display,
+ XvMCContext *context,
+ unsigned int picture_structure,
+ XvMCSurface *target_surface,
+ XvMCSurface *past_surface,
+ XvMCSurface *future_surface,
+ unsigned int flags,
+ unsigned int num_macroblocks,
+ unsigned int first_macroblock,
+ XvMCMacroBlockArray *macroblock_array,
+ XvMCBlockArray *blocks
+ )
+{
+ return (error_base + XvMCBadContext);
+}
+
+Status XvMCCreateBlocks
+(
+ Display *display,
+ XvMCContext *context,
+ unsigned int num_blocks,
+ XvMCBlockArray * block
+ )
+{
+ return (error_base + XvMCBadContext);
+}
+
+Status XvMCDestroyBlocks (Display *display, XvMCBlockArray * block)
+{
+ return Success;
+}
+
+Status XvMCCreateMacroBlocks
+(
+ Display *display,
+ XvMCContext *context,
+ unsigned int num_blocks,
+ XvMCMacroBlockArray * blocks
+ )
+{
+ return (error_base + XvMCBadContext);
+}
+
+Status XvMCDestroyMacroBlocks(Display *display, XvMCMacroBlockArray * block)
+{
+ return (error_base + XvMCBadContext);
+}
+
+Status XvMCCreateSubpicture( Display *display,
+ XvMCContext *context,
+ XvMCSubpicture *subpicture,
+ unsigned short width,
+ unsigned short height,
+ int xvimage_id)
+{
+ ViaXvMCContext *pViaXvMC;
+ ViaXvMCSubPicture *pViaSubPic;
+ int priv_count;
+ unsigned *priv_data;
+ Status ret;
+
+ if((subpicture == NULL) || (context == NULL) || (display == NULL)){
+ return BadValue;
+ }
+
+ pViaXvMC = (ViaXvMCContext *)context->privData;
+ if(pViaXvMC == NULL) {
+ return (error_base + XvMCBadContext);
+ }
+
+ subpicture->privData = (ViaXvMCSubPicture *)
+ malloc(sizeof(ViaXvMCSubPicture));
+ if(!subpicture->privData) {
+ return BadAlloc;
+ }
+
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+ subpicture->width = context->width;
+ subpicture->height = context->height;
+ subpicture->xvimage_id = xvimage_id;
+ pViaSubPic = (ViaXvMCSubPicture *)subpicture->privData;
+
+ XLockDisplay(display);
+ if((ret = _xvmc_create_subpicture(display, context, subpicture,
+ &priv_count, &priv_data))) {
+ XUnlockDisplay(display);
+ free(pViaSubPic);
+ fprintf(stderr,"Unable to create XvMC Subpicture.\n");
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return ret;
+ }
+ XUnlockDisplay(display);
+
+
+ subpicture->num_palette_entries = VIA_SUBPIC_PALETTE_SIZE;
+ subpicture->entry_bytes = 3;
+ strncpy(subpicture->component_order,"YUV",4);
+ pViaSubPic->srfNo = priv_data[0];
+ pViaSubPic->offset = priv_data[1];
+ pViaSubPic->stride = (subpicture->width + 31) & ~31;
+ pViaSubPic->privContext = pViaXvMC;
+ pViaSubPic->ia44 = (xvimage_id == FOURCC_IA44);
+ pViaSubPic->needsSync = 0;
+
+ /* Free data returned from _xvmc_create_subpicture */
+
+ XFree(priv_data);
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+}
+
+Status
+XvMCSetSubpicturePalette (Display *display, XvMCSubpicture *subpicture,
+ unsigned char *palette)
+{
+ ViaXvMCSubPicture *pViaSubPic;
+ ViaXvMCContext *pViaXvMC;
+ volatile ViaXvMCSAreaPriv *sAPriv;
+ unsigned i;
+ CARD32 tmp;
+
+ if((subpicture == NULL) || (display == NULL)){
+ return BadValue;
+ }
+ if(subpicture->privData == NULL) {
+ return (error_base + XvMCBadSubpicture);
+ }
+ pViaSubPic = (ViaXvMCSubPicture *) subpicture->privData;
+ for (i=0; i < VIA_SUBPIC_PALETTE_SIZE; ++i) {
+ tmp = *palette++ << 8;
+ tmp |= *palette++ << 16;
+ tmp |= *palette++ << 24;
+ tmp |= ((i & 0x0f) << 4) | 0x07;
+ pViaSubPic->palette[i] = tmp;
+ }
+
+ pViaXvMC = pViaSubPic->privContext;
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+ sAPriv = SAREAPTR( pViaXvMC );
+ hwlLock(pViaXvMC->xl,1);
+ setLowLevelLocking(pViaXvMC->xl,0);
+
+ /*
+ * If the subpicture is displaying, Immeadiately update it with the
+ * new palette.
+ */
+
+ if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] ==
+ (pViaSubPic->srfNo | VIA_XVMC_VALID)) {
+ viaVideoSubPictureLocked(pViaXvMC->xl,pViaSubPic);
+ }
+ flushPCIXvMCLowLevel(pViaXvMC->xl);
+ setLowLevelLocking(pViaXvMC->xl,1);
+ hwlUnlock(pViaXvMC->xl,1);
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+}
+
+
+static int findOverlap(unsigned width,unsigned height,
+ short *dstX, short *dstY,
+ short *srcX, short *srcY,
+ unsigned short *areaW, unsigned short *areaH)
+{
+ int
+ w,h;
+ unsigned
+ mWidth,mHeight;
+
+ w = *areaW;
+ h = *areaH;
+
+ if ((*dstX >= width) || (*dstY >= height))
+ return 1;
+ if (*dstX < 0) {
+ w += *dstX;
+ *srcX -= *dstX;
+ *dstX = 0;
+ }
+ if (*dstY < 0) {
+ h += *dstY;
+ *srcY -= *dstY;
+ *dstY = 0;
+ }
+ if ((w <= 0) || ((h <= 0)))
+ return 1;
+ mWidth = width - *dstX;
+ mHeight = height - *dstY;
+ *areaW = (w <= mWidth) ? w : mWidth;
+ *areaH = (h <= mHeight) ? h : mHeight;
+ return 0;
+}
+
+
+
+Status XvMCClearSubpicture (
+ Display *display,
+ XvMCSubpicture *subpicture,
+ short x,
+ short y,
+ unsigned short width,
+ unsigned short height,
+ unsigned int color
+ )
+{
+
+ ViaXvMCContext *pViaXvMC;
+ ViaXvMCSubPicture *pViaSubPic;
+ short dummyX,dummyY;
+ unsigned long bOffs;
+
+ if((subpicture == NULL) || (display == NULL)) {
+ return BadValue;
+ }
+ if(subpicture->privData == NULL) {
+ return (error_base + XvMCBadSubpicture);
+ }
+ pViaSubPic = (ViaXvMCSubPicture *) subpicture->privData;
+ pViaXvMC = pViaSubPic->privContext;
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+
+ /* Clip clearing area so that it fits inside subpicture. */
+
+ if (findOverlap(subpicture->width, subpicture->height, &x, &y,
+ &dummyX, &dummyY, &width, &height)) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+ }
+
+ bOffs = pViaSubPic->offset + y*pViaSubPic->stride + x;
+ viaBlit(pViaXvMC->xl, 8, 0, pViaSubPic->stride, bOffs, pViaSubPic->stride,
+ width, height, 1, 1, VIABLIT_FILL, color);
+ pViaSubPic->needsSync = 1;
+ pViaSubPic->timeStamp = viaDMATimeStampLowLevel(pViaXvMC->xl);
+ if (flushXvMCLowLevel(pViaXvMC->xl)) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return BadValue;
+ }
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+}
+
+Status
+XvMCCompositeSubpicture (
+ Display *display,
+ XvMCSubpicture *subpicture,
+ XvImage *image,
+ short srcx,
+ short srcy,
+ unsigned short width,
+ unsigned short height,
+ short dstx,
+ short dsty
+ )
+{
+
+ unsigned i;
+ ViaXvMCContext *pViaXvMC;
+ ViaXvMCSubPicture *pViaSubPic;
+ CARD8 *dAddr, *sAddr;
+
+ if((subpicture == NULL) || (display == NULL) || (image == NULL)){
+ return BadValue;
+ }
+ if(NULL == (pViaSubPic = (ViaXvMCSubPicture *)subpicture->privData)) {
+ return (error_base + XvMCBadSubpicture);
+ }
+
+ pViaXvMC = pViaSubPic->privContext;
+
+
+ if (image->id != subpicture->xvimage_id)
+ return BadMatch;
+
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+
+
+ /*
+ * Clip copy area so that it fits inside subpicture and image.
+ */
+
+ if (findOverlap(subpicture->width, subpicture->height,
+ &dstx, &dsty, &srcx, &srcy, &width, &height)) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+ }
+ if (findOverlap(image->width, image->height,
+ &srcx, &srcy, &dstx, &dsty, &width, &height)) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+ }
+
+ if (pViaSubPic->needsSync) {
+ if (syncXvMCLowLevel(pViaXvMC->xl, LL_MODE_2D, 0, pViaSubPic->timeStamp)) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return BadValue;
+ }
+ pViaSubPic->needsSync = 0;
+ }
+
+ for(i=0; i<height; ++i) {
+ dAddr = (((CARD8 *)pViaXvMC->fbAddress) +
+ (pViaSubPic->offset + (dsty+i)*pViaSubPic->stride + dstx));
+ sAddr = (((CARD8 *)image->data) +
+ (image->offsets[0] + (srcy+i)*image->pitches[0] + srcx));
+ memcpy(dAddr,sAddr,width);
+ }
+
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+}
+
+
+
+Status
+XvMCBlendSubpicture (
+ Display *display,
+ XvMCSurface *target_surface,
+ XvMCSubpicture *subpicture,
+ short subx,
+ short suby,
+ unsigned short subw,
+ unsigned short subh,
+ short surfx,
+ short surfy,
+ unsigned short surfw,
+ unsigned short surfh
+ )
+{
+ ViaXvMCSurface *pViaSurface;
+ ViaXvMCSubPicture *pViaSubPic;
+
+ if((display == NULL) || target_surface == NULL){
+ return BadValue;
+ }
+
+ if (subx || suby || surfx || surfy ||
+ (subw != surfw) || (subh != surfh)) {
+ fprintf(stderr,"ViaXvMC: Only completely overlapping subpicture "
+ "supported.\n");
+ return BadValue;
+ }
+
+ if(NULL == (pViaSurface = target_surface->privData)) {
+ return (error_base + XvMCBadSurface);
+ }
+
+ if (subpicture) {
+
+ if(NULL == (pViaSubPic = subpicture->privData)) {
+ return (error_base + XvMCBadSubpicture);
+ }
+
+ pViaSurface->privSubPic = pViaSubPic;
+ } else {
+ pViaSurface->privSubPic = NULL;
+ }
+ return Success;
+}
+
+Status
+XvMCBlendSubpicture2 (
+ Display *display,
+ XvMCSurface *source_surface,
+ XvMCSurface *target_surface,
+ XvMCSubpicture *subpicture,
+ short subx,
+ short suby,
+ unsigned short subw,
+ unsigned short subh,
+ short surfx,
+ short surfy,
+ unsigned short surfw,
+ unsigned short surfh
+ )
+{
+ ViaXvMCSurface *pViaSurface,*pViaSSurface;
+ ViaXvMCSubPicture *pViaSubPic;
+ ViaXvMCContext *pViaXvMC;
+
+ unsigned width,height;
+
+ if((display == NULL) || target_surface == NULL || source_surface == NULL){
+ return BadValue;
+ }
+
+ if (subx || suby || surfx || surfy ||
+ (subw != surfw) || (subh != surfh)) {
+ fprintf(stderr,"ViaXvMC: Only completely overlapping subpicture "
+ "supported.\n");
+ return BadMatch;
+ }
+
+ if(NULL == (pViaSurface = target_surface->privData)) {
+ return (error_base + XvMCBadSurface);
+ }
+
+ if(NULL == (pViaSSurface = source_surface->privData)) {
+ return (error_base + XvMCBadSurface);
+ }
+ pViaXvMC = pViaSurface->privContext;
+ width = pViaSSurface->width;
+ height = pViaSSurface->height;
+ if (width != pViaSurface->width || height != pViaSSurface->height) {
+ return BadMatch;
+ }
+
+ if (XvMCSyncSurface(display,source_surface)) {
+ return BadValue;
+ }
+
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+ viaBlit(pViaXvMC->xl, 8, yOffs(pViaSSurface), pViaSSurface->yStride,
+ yOffs(pViaSurface), pViaSurface->yStride,
+ width, height, 1, 1, VIABLIT_COPY, 0);
+ flushPCIXvMCLowLevel(pViaXvMC->xl);
+ if (pViaXvMC->chipId != PCI_CHIP_VT3259) {
+
+ /*
+ * YV12 Chroma blit.
+ */
+
+ viaBlit(pViaXvMC->xl, 8, uOffs(pViaSSurface), pViaSSurface->yStride >> 1,
+ uOffs(pViaSurface), pViaSurface->yStride >> 1,
+ width >> 1, height >> 1, 1, 1, VIABLIT_COPY, 0);
+ flushPCIXvMCLowLevel(pViaXvMC->xl);
+ viaBlit(pViaXvMC->xl, 8, vOffs(pViaSSurface), pViaSSurface->yStride >> 1,
+ vOffs(pViaSurface), pViaSurface->yStride >> 1,
+ width >> 1, height >> 1, 1, 1, VIABLIT_COPY, 0);
+ } else {
+
+ /*
+ * NV12 Chroma blit.
+ */
+
+ viaBlit(pViaXvMC->xl, 8, vOffs(pViaSSurface), pViaSSurface->yStride,
+ vOffs(pViaSurface), pViaSurface->yStride,
+ width, height >> 1, 1, 1, VIABLIT_COPY, 0);
+ }
+ pViaSurface->needsSync = 1;
+ pViaSurface->syncMode = LL_MODE_2D;
+ pViaSurface->timeStamp = viaDMATimeStampLowLevel(pViaXvMC->xl);
+ if (flushXvMCLowLevel(pViaXvMC->xl)) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return BadValue;
+ }
+ if (subpicture) {
+
+ if(NULL == (pViaSubPic = subpicture->privData)) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return (error_base + XvMCBadSubpicture);
+ }
+
+ pViaSurface->privSubPic = pViaSubPic;
+ } else {
+ pViaSurface->privSubPic = NULL;
+ }
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+}
+
+
+Status
+XvMCSyncSubpicture (Display *display, XvMCSubpicture *subpicture)
+{
+ ViaXvMCSubPicture *pViaSubPic;
+ ViaXvMCContext *pViaXvMC;
+ Status retVal=0;
+
+ if((display == NULL) || subpicture == NULL){
+ return BadValue;
+ }
+ if(NULL == (pViaSubPic = subpicture->privData)) {
+ return (error_base + XvMCBadSubpicture);
+ }
+
+ pViaXvMC = pViaSubPic->privContext;
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+ if (pViaSubPic->needsSync) {
+ if (syncXvMCLowLevel(pViaXvMC->xl, LL_MODE_2D,
+ 0, pViaSubPic->timeStamp)) {
+ retVal = BadValue;
+ }
+ pViaSubPic->needsSync = 0;
+ }
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return retVal;
+}
+
+Status
+XvMCFlushSubpicture (Display *display, XvMCSubpicture *subpicture)
+{
+ ViaXvMCSubPicture *pViaSubPic;
+
+ if((display == NULL) || subpicture == NULL){
+ return BadValue;
+ }
+ if(NULL == (pViaSubPic = subpicture->privData)) {
+ return (error_base + XvMCBadSubpicture);
+ }
+
+ return Success;
+}
+
+Status
+XvMCDestroySubpicture (Display *display, XvMCSubpicture *subpicture)
+{
+ ViaXvMCSubPicture *pViaSubPic;
+ ViaXvMCContext *pViaXvMC;
+ volatile ViaXvMCSAreaPriv *sAPriv;
+
+ if((display == NULL) || subpicture == NULL){
+ return BadValue;
+ }
+ if(NULL == (pViaSubPic = subpicture->privData)) {
+ return (error_base + XvMCBadSubpicture);
+ }
+ pViaXvMC = pViaSubPic->privContext;
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+
+
+ sAPriv = SAREAPTR(pViaXvMC);
+ hwlLock(pViaXvMC->xl,1);
+ setLowLevelLocking(pViaXvMC->xl,0);
+ if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] ==
+ ( pViaSubPic->srfNo | VIA_XVMC_VALID )) {
+ viaVideoSubPictureOffLocked(pViaXvMC->xl);
+ sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] = 0;
+ }
+ flushPCIXvMCLowLevel(pViaXvMC->xl);
+ setLowLevelLocking(pViaXvMC->xl,1);
+ hwlUnlock(pViaXvMC->xl,1);
+
+ XLockDisplay(display);
+ _xvmc_destroy_subpicture(display,subpicture);
+ XUnlockDisplay(display);
+
+ free(pViaSubPic);
+ subpicture->privData = NULL;
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+
+ return Success;
+}
+
+Status
+XvMCGetSubpictureStatus (Display *display, XvMCSubpicture *subpic, int *stat)
+{
+ ViaXvMCSubPicture *pViaSubPic;
+ ViaXvMCContext *pViaXvMC;
+ volatile ViaXvMCSAreaPriv *sAPriv;
+
+
+ if((display == NULL) || subpic == NULL){
+ return BadValue;
+ }
+ if(NULL == (pViaSubPic = subpic->privData)) {
+ return (error_base + XvMCBadSubpicture);
+ }
+ if (stat) {
+ *stat = 0;
+ pViaXvMC = pViaSubPic->privContext;
+ sAPriv = SAREAPTR( pViaXvMC );
+ if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] ==
+ (pViaSubPic->srfNo | VIA_XVMC_VALID))
+ *stat |= XVMC_DISPLAYING;
+ }
+ return Success;
+}
+
+Status
+XvMCFlushSurface (Display *display, XvMCSurface *surface)
+{
+ ViaXvMCSurface *pViaSurface;
+ ViaXvMCContext *pViaXvMC;
+ Status ret;
+
+ if((display == NULL) || surface == NULL){
+ return BadValue;
+ }
+ if(NULL == (pViaSurface = surface->privData)) {
+ return (error_base + XvMCBadSurface);
+ }
+
+ pViaXvMC = pViaSurface->privContext;
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+ if (pViaSurface->needsSync)
+ pViaSurface->timeStamp = pViaXvMC->timeStamp =
+ viaDMATimeStampLowLevel(pViaXvMC->xl);
+ ret = (flushXvMCLowLevel(pViaXvMC->xl)) ? BadValue : Success;
+ if (pViaXvMC->rendSurf[0] == (pViaSurface->srfNo | VIA_XVMC_VALID)) {
+ hwlLock(pViaXvMC->xl,0);
+ pViaXvMC->haveDecoder = 0;
+ releaseDecoder(pViaXvMC, 0);
+ hwlUnlock(pViaXvMC->xl,0);
+ }
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return ret;
+}
+
+Status
+XvMCGetSurfaceStatus (Display *display, XvMCSurface *surface, int *stat)
+{
+ ViaXvMCSurface *pViaSurface;
+ ViaXvMCContext *pViaXvMC;
+ volatile ViaXvMCSAreaPriv *sAPriv;
+ unsigned i;
+ int ret = 0;
+
+ if((display == NULL) || surface == NULL){
+ return BadValue;
+ }
+ if(NULL == (pViaSurface = surface->privData)) {
+ return (error_base + XvMCBadSurface);
+ }
+ if (stat) {
+ *stat = 0;
+ pViaXvMC = pViaSurface->privContext;
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+ sAPriv = SAREAPTR( pViaXvMC );
+ if (sAPriv->XvMCDisplaying[pViaXvMC->xvMCPort]
+ == (pViaSurface->srfNo | VIA_XVMC_VALID))
+ *stat |= XVMC_DISPLAYING;
+ for (i=0; i<VIA_MAX_RENDSURF; ++i) {
+ if(pViaXvMC->rendSurf[i] ==
+ (pViaSurface->srfNo | VIA_XVMC_VALID)) {
+ *stat |= XVMC_RENDERING;
+ break;
+ }
+ }
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ }
+ return ret;
+}
+
+XvAttribute *
+XvMCQueryAttributes (
+ Display *display,
+ XvMCContext *context,
+ int *number
+ )
+{
+ ViaXvMCContext *pViaXvMC;
+ XvAttribute *ret;
+ unsigned long siz;
+
+ *number = 0;
+ if ((display == NULL) || (context == NULL)) {
+ return NULL;
+ }
+
+ if (NULL == (pViaXvMC = context->privData)) {
+ return NULL;
+ }
+
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+ if (NULL != (ret = (XvAttribute *)
+ malloc(siz = VIA_NUM_XVMC_ATTRIBUTES*sizeof(XvAttribute)))) {
+ memcpy(ret,pViaXvMC->attribDesc,siz);
+ *number = VIA_NUM_XVMC_ATTRIBUTES;
+ }
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+
+ return ret;
+}
+
+Status
+XvMCSetAttribute (
+ Display *display,
+ XvMCContext *context,
+ Atom attribute,
+ int value
+ )
+{
+ int found;
+ unsigned i;
+ ViaXvMCContext *pViaXvMC;
+ ViaXvMCCommandBuffer buf;
+
+ if ((display == NULL) || (context == NULL)) {
+ return (error_base + XvMCBadContext);
+ }
+
+ if (NULL == (pViaXvMC = context->privData)) {
+ return (error_base + XvMCBadContext);
+ }
+
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+
+ found = 0;
+ for (i=0; i < pViaXvMC->attrib.numAttr; ++i) {
+ if (attribute == pViaXvMC->attrib.attributes[i].attribute) {
+ if ((!(pViaXvMC->attribDesc[i].flags & XvSettable)) ||
+ value < pViaXvMC->attribDesc[i].min_value ||
+ value > pViaXvMC->attribDesc[i].max_value)
+ return BadValue;
+ pViaXvMC->attrib.attributes[i].value = value;
+ found = 1;
+ pViaXvMC->attribChanged = 1;
+ break;
+ }
+ }
+ if (!found) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return BadMatch;
+ }
+ if (pViaXvMC->haveXv) {
+ buf.command = VIA_XVMC_COMMAND_ATTRIBUTES;
+ pViaXvMC->xvImage->data = (char *)&buf;
+ buf.ctxNo = pViaXvMC->ctxNo | VIA_XVMC_VALID;
+ buf.attrib = pViaXvMC->attrib;
+ XLockDisplay(display);
+ pViaXvMC->attribChanged =
+ XvPutImage(display,pViaXvMC->port,pViaXvMC->draw,
+ pViaXvMC->gc,
+ pViaXvMC->xvImage,0,0,1,1,0,0,1,1);
+ XUnlockDisplay(display);
+ }
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+}
+
+
+Status
+XvMCGetAttribute (
+ Display *display,
+ XvMCContext *context,
+ Atom attribute,
+ int *value
+ )
+{
+ int found;
+ unsigned i;
+ ViaXvMCContext *pViaXvMC;
+
+ if ((display == NULL) || (context == NULL)) {
+ return (error_base + XvMCBadContext);
+ }
+
+ if (NULL == (pViaXvMC = context->privData)) {
+ return (error_base + XvMCBadContext);
+ }
+
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+ found = 0;
+ for (i=0; i < pViaXvMC->attrib.numAttr; ++i) {
+ if (attribute == pViaXvMC->attrib.attributes[i].attribute) {
+ if (pViaXvMC->attribDesc[i].flags & XvGettable) {
+ *value = pViaXvMC->attrib.attributes[i].value;
+ found = 1;
+ break;
+ }
+ }
+ }
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+
+ if (!found)
+ return BadMatch;
+ return Success;
+}
+
+
+Status XvMCHideSurface(Display *display,XvMCSurface *surface)
+{
+
+ ViaXvMCSurface *pViaSurface;
+ ViaXvMCContext *pViaXvMC;
+ ViaXvMCSubPicture *pViaSubPic;
+ volatile ViaXvMCSAreaPriv *sAPriv;
+ ViaXvMCCommandBuffer buf;
+ Status ret;
+
+ if ((display == NULL) || (surface == NULL)) {
+ return BadValue;
+ }
+ if (NULL == (pViaSurface = surface->privData )) {
+ return (error_base + XvMCBadSurface);
+ }
+ if (NULL == (pViaXvMC = pViaSurface->privContext)) {
+ return (error_base + XvMCBadContext);
+ }
+
+ ppthread_mutex_lock( &pViaXvMC->ctxMutex );
+ if (!pViaXvMC->haveXv) {
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+ }
+
+ sAPriv = SAREAPTR( pViaXvMC );
+ hwlLock(pViaXvMC->xl,1);
+
+ if (sAPriv->XvMCDisplaying[pViaXvMC->xvMCPort] !=
+ (pViaSurface->srfNo | VIA_XVMC_VALID)) {
+ hwlUnlock(pViaXvMC->xl,1);
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+ }
+ setLowLevelLocking(pViaXvMC->xl,0);
+ if (NULL != (pViaSubPic = pViaSurface->privSubPic)) {
+ if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] ==
+ (pViaSubPic->srfNo | VIA_XVMC_VALID)) {
+ sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] &= ~VIA_XVMC_VALID;
+ viaVideoSubPictureOffLocked(pViaXvMC->xl);
+ }
+ }
+ flushPCIXvMCLowLevel(pViaXvMC->xl);
+ setLowLevelLocking(pViaXvMC->xl,1);
+ hwlUnlock(pViaXvMC->xl,1);
+
+ buf.command = VIA_XVMC_COMMAND_UNDISPLAY;
+ buf.ctxNo = pViaXvMC->ctxNo | VIA_XVMC_VALID;
+ buf.srfNo = pViaSurface->srfNo | VIA_XVMC_VALID;
+ pViaXvMC->xvImage->data = (char *)&buf;
+ if ((ret = XvPutImage(display,pViaXvMC->port,pViaXvMC->draw,
+ pViaXvMC->gc,
+ pViaXvMC->xvImage,0,0,1,1,0,0,1,1))) {
+ fprintf(stderr,"XvMCPutSurface: Hiding overlay failed.\n");
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return ret;
+ }
+ ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
+ return Success;
+}
diff --git a/nx-X11/lib/XvMC/hw/via/viaXvMCPriv.h b/nx-X11/lib/XvMC/hw/via/viaXvMCPriv.h
new file mode 100644
index 000000000..de4976a25
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/via/viaXvMCPriv.h
@@ -0,0 +1,198 @@
+/*****************************************************************************
+ * VIA Unichrome XvMC extension client lib.
+ *
+ * Copyright (c) 2004 Thomas Hellström. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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.
+ */
+
+#ifndef _VIAXVMCPRIV_H
+#define _VIAXVMCPRIV_H 1
+
+#include <X11/Xlibint.h>
+#include <X11/extensions/XvMC.h>
+#include <X11/extensions/XvMClib.h>
+#include <stdlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/vldXvMC.h>
+#include "via_xvmc.h"
+
+typedef struct{
+ int x;
+ int y;
+ int w;
+ int h;
+} XvMCRegion;
+
+
+extern Status _xvmc_create_context(Display *dpy, XvMCContext *context,
+ int *priv_count, uint **priv_data);
+extern Status _xvmc_destroy_context(Display *dpy, XvMCContext *context);
+extern Status _xvmc_create_surface(Display *dpy, XvMCContext *context,
+ XvMCSurface *surface, int *priv_count,
+ uint **priv_data);
+extern Status _xvmc_destroy_surface(Display *dpy, XvMCSurface *surface);
+extern Status _xvmc_create_subpicture(Display *dpy, XvMCContext *context,
+ XvMCSubpicture *subpicture,
+ int *priv_count, uint **priv_data);
+extern Status _xvmc_destroy_subpicture(Display *dpy,
+ XvMCSubpicture *subpicture);
+
+#define VIA_SUBPIC_PALETTE_SIZE 16 /*Number of colors in subpicture palette*/
+#define VIA_CBUFFERSIZE 4096 /*Hardware command buffer size*/
+#define VIA_MAX_BUFS 2 /*Number of YUV buffers per surface*/
+#define VIA_MAX_RENDSURF 3 /*Maximum numbers of surfaces per context
+ that can answer RENDERING to a rendering
+ query*/
+
+typedef enum{
+ context_drawHash,
+ context_lowLevel,
+ context_mutex,
+ context_sAreaMap,
+ context_fbMap,
+ context_mmioMap,
+ context_drmContext,
+ context_fd,
+ context_driConnection,
+ context_context,
+ context_none
+} ContextRes;
+
+
+typedef struct{
+ unsigned ctxNo; /* XvMC private context reference number */
+ pthread_mutex_t ctxMutex; /* Mutex for multi-threading. Not used */
+ drm_context_t drmcontext; /* The drm context */
+ drm_handle_t fbOffset; /* Handle to drm frame-buffer area */
+ drm_handle_t mmioOffset; /* Handle to drm mmio area */
+ drm_handle_t sAreaOffset; /* Handle to drm shared memory area */
+ unsigned fbSize; /* Size of drm frame-buffer area */
+ unsigned mmioSize; /* Size of drm mmio area */
+ unsigned sAreaSize; /* Size of drm shared memory area */
+ unsigned sAreaPrivOffset; /* Offset in sarea to private part */
+ drmAddress fbAddress; /* Virtual address of frame buffer area */
+ drmAddress mmioAddress; /* Virtual address of mmio area */
+ drmAddress sAreaAddress; /* Virtual address of shared memory area */
+ char busIdString[21]; /* Busid of video card */
+ unsigned yStride; /* Y stride of surfaces in this context */
+ int fd; /* FD for connection to drm module */
+ unsigned char intra_quantiser_matrix[64];
+ unsigned char non_intra_quantiser_matrix[64];
+ unsigned char chroma_intra_quantiser_matrix[64];
+ unsigned char chroma_non_intra_quantiser_matrix[64];
+ unsigned rendSurf[VIA_MAX_RENDSURF]; /* Which surfaces answer rendering to
+ a rendering query */
+ int decoderOn; /* Decoder switched on ? */
+ int intraLoaded; /* Intra quantiser matrix loaded in
+ decoder? */
+ int nonIntraLoaded; /* Non-Intra quantiser matrix loaded
+ in decoder */
+ int chromaIntraLoaded;
+ int chromaNonIntraLoaded;
+ int haveDecoder; /* Does this context own decoder? */
+ int attribChanged; /* Attributes have changed and need to
+ be uploaded to Xv at next frame
+ display */
+ drmLockPtr hwLock; /* Virtual address Pointer to the
+ heavyweight drm hardware lock */
+ unsigned xvMCPort; /* XvMC private port. Corresponds to
+ an Xv port, but not by number */
+ ViaXvMCAttrHolder attrib; /* This contexts attributes and their
+ values */
+ XvAttribute attribDesc[VIA_NUM_XVMC_ATTRIBUTES]; /* Attribute decriptions */
+ int useAGP; /* Use the AGP ringbuffer to upload data to the chip */
+ void *xl; /* Lowlevel context. Opaque to us. */
+ int haveXv; /* Have I initialized the Xv
+ connection for this surface? */
+ XvImage *xvImage; /* Fake Xv Image used for command
+ buffer transport to the X server */
+ GC gc; /* X GC needed for displaying */
+ Drawable draw; /* Drawable to undisplay from */
+ XvPortID port; /* Xv Port ID when displaying */
+ int lastSrfDisplaying;
+ ContextRes resources;
+ CARD32 timeStamp;
+ CARD32 videoTimeStamp;
+ XID id;
+ unsigned screen;
+ unsigned depth;
+ unsigned stride;
+ XVisualInfo visualInfo;
+ void *drawHash;
+ CARD32 chipId;
+ XvMCRegion sRegion;
+ XvMCRegion dRegion;
+}ViaXvMCContext;
+
+typedef struct{
+ pthread_mutex_t subMutex; /* Currently not used. */
+ unsigned srfNo; /* XvMC private surface number */
+ unsigned offset; /* Offset into frame-buffer area */
+ unsigned stride; /* Storage stride */
+ unsigned width; /* Width */
+ unsigned height; /* Height */
+ CARD32 palette[VIA_SUBPIC_PALETTE_SIZE]; /* YUV Palette */
+ ViaXvMCContext *privContext; /* Pointer to context private data */
+ int ia44; /* IA44 or AI44 format */
+ int needsSync;
+ CARD32 timeStamp;
+}ViaXvMCSubPicture;
+
+
+typedef struct{
+ pthread_mutex_t srfMutex; /* For multithreading. Not used. */
+ pthread_cond_t bufferAvailable; /* For multithreading. Not used. */
+ unsigned srfNo; /* XvMC private surface numbers */
+ unsigned numBuffers; /* Number of picture buffers */
+ unsigned curBuf; /* Which is the current buffer? */
+ unsigned offsets[VIA_MAX_BUFS]; /* Offsets of picture buffers
+ into the frame-buffer area */
+ unsigned yStride; /* Stride of YUV420 Y component. */
+ unsigned width; /* Dimensions */
+ unsigned height;
+ int progressiveSequence; /* Mpeg progressive picture? Hmm? */
+ ViaXvMCContext *privContext; /* XvMC context private part. */
+ ViaXvMCSubPicture *privSubPic; /* Subpicture to be blended when
+ displaying. NULL if none. */
+ int needsSync;
+ int syncMode;
+ CARD32 timeStamp;
+ int topFieldFirst;
+}ViaXvMCSurface;
+
+/*
+ * Take and release the global drm hardware lock.
+ */
+
+#define HW_LOCK(ctx) \
+ DRM_LOCK((ctx)->fd,(ctx)->hwLock,(ctx)->drmcontext,0)
+#define HW_UNLOCK(ctx) \
+ DRM_UNLOCK((ctx)->fd,(ctx->hwLock),(ctx)->drmcontext)
+
+/*
+ * Low-level Mpeg functions in viaLowLevel.c
+ */
+
+#define VIABLIT_TRANSCOPY 0
+#define VIABLIT_COPY 1
+#define VIABLIT_FILL 2
+
+
+#endif
diff --git a/nx-X11/lib/XvMC/hw/via/xf86dri.c b/nx-X11/lib/XvMC/hw/via/xf86dri.c
new file mode 100644
index 000000000..dd1d1e072
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/via/xf86dri.c
@@ -0,0 +1,592 @@
+/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.13 2002/10/30 12:51:25 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Jens Owen <jens@tungstengraphics.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+/* #include "glheader.h" */
+#include "xf86dristr.h"
+
+static XExtensionInfo _xf86dri_info_data;
+static XExtensionInfo *xf86dri_info = &_xf86dri_info_data;
+static char xf86dri_extension_name[] = XF86DRINAME;
+
+#define uniDRICheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xf86dri_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *extCodes);
+static /* const */ XExtensionHooks xf86dri_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86dri_info,
+ xf86dri_extension_name,
+ &xf86dri_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info)
+
+
+/*****************************************************************************
+ * *
+ * public XFree86-DRI Extension routines *
+ * *
+ *****************************************************************************/
+
+#if 0
+#include <stdio.h>
+#define TRACE(msg) fprintf(stderr,"uniDRI%s\n", msg);
+#else
+#define TRACE(msg)
+#endif
+
+
+ Bool uniDRIQueryExtension (dpy, event_basep, error_basep)
+ Display *dpy;
+ int *event_basep, *error_basep;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ TRACE("QueryExtension...");
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ TRACE("QueryExtension... return True");
+ return True;
+ } else {
+ TRACE("QueryExtension... return False");
+ return False;
+ }
+}
+
+ Bool uniDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
+ Display* dpy;
+ int* majorVersion;
+ int* minorVersion;
+ int* patchVersion;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIQueryVersionReply rep;
+ xXF86DRIQueryVersionReq *req;
+
+ TRACE("QueryVersion...");
+ uniDRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return False");
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ *patchVersion = rep.patchVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return True");
+ return True;
+}
+
+ Bool uniDRIQueryDirectRenderingCapable(dpy, screen, isCapable)
+ Display* dpy;
+ int screen;
+ Bool* isCapable;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIQueryDirectRenderingCapableReply rep;
+ xXF86DRIQueryDirectRenderingCapableReq *req;
+
+ TRACE("QueryDirectRenderingCapable...");
+ uniDRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIQueryDirectRenderingCapable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIQueryDirectRenderingCapable;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryDirectRenderingCapable... return False");
+ return False;
+ }
+ *isCapable = rep.isCapable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryDirectRenderingCapable... return True");
+ return True;
+}
+
+ Bool uniDRIOpenConnection(dpy, screen, hSAREA, busIdString)
+ Display* dpy;
+ int screen;
+ drm_handle_t * hSAREA;
+ char **busIdString;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIOpenConnectionReply rep;
+ xXF86DRIOpenConnectionReq *req;
+
+ TRACE("OpenConnection...");
+ uniDRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIOpenConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIOpenConnection;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return False");
+ return False;
+ }
+
+ *hSAREA = rep.hSAREALow;
+#ifdef LONG64
+ *hSAREA |= ((drm_handle_t)rep.hSAREAHigh) << 32;
+#endif
+
+ if (rep.length) {
+ if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) {
+ _XEatData(dpy, ((rep.busIdStringLength+3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return False");
+ return False;
+ }
+ _XReadPad(dpy, *busIdString, rep.busIdStringLength);
+ } else {
+ *busIdString = NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return True");
+ return True;
+}
+
+ Bool uniDRIAuthConnection(dpy, screen, magic)
+ Display* dpy;
+ int screen;
+ drm_magic_t magic;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIAuthConnectionReq *req;
+ xXF86DRIAuthConnectionReply rep;
+
+ TRACE("AuthConnection...");
+ uniDRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIAuthConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIAuthConnection;
+ req->screen = screen;
+ req->magic = magic;
+ rep.authenticated = 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("AuthConnection... return False");
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("AuthConnection... return True");
+ return True;
+}
+
+ Bool uniDRICloseConnection(dpy, screen)
+ Display* dpy;
+ int screen;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRICloseConnectionReq *req;
+
+ TRACE("CloseConnection...");
+
+ uniDRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICloseConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICloseConnection;
+ req->screen = screen;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CloseConnection... return True");
+ return True;
+}
+
+ Bool uniDRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion,
+ ddxDriverMinorVersion, ddxDriverPatchVersion, clientDriverName)
+ Display* dpy;
+ int screen;
+ int* ddxDriverMajorVersion;
+ int* ddxDriverMinorVersion;
+ int* ddxDriverPatchVersion;
+ char** clientDriverName;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIGetClientDriverNameReply rep;
+ xXF86DRIGetClientDriverNameReq *req;
+
+ TRACE("GetClientDriverName...");
+ uniDRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetClientDriverName, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetClientDriverName;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return False");
+ return False;
+ }
+
+ *ddxDriverMajorVersion = rep.ddxDriverMajorVersion;
+ *ddxDriverMinorVersion = rep.ddxDriverMinorVersion;
+ *ddxDriverPatchVersion = rep.ddxDriverPatchVersion;
+
+ if (rep.length) {
+ if (!(*clientDriverName = (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) {
+ _XEatData(dpy, ((rep.clientDriverNameLength+3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return False");
+ return False;
+ }
+ _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength);
+ } else {
+ *clientDriverName = NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return True");
+ return True;
+}
+
+ Bool uniDRICreateContextWithConfig(dpy, screen, configID, context,
+ hHWContext)
+ Display* dpy;
+ int screen;
+ int configID;
+ XID* context;
+ drm_context_t * hHWContext;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRICreateContextReply rep;
+ xXF86DRICreateContextReq *req;
+
+ TRACE("CreateContext...");
+ uniDRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICreateContext, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICreateContext;
+ req->visual = configID;
+ req->screen = screen;
+ *context = XAllocID(dpy);
+ req->context = *context;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateContext... return False");
+ return False;
+ }
+ *hHWContext = rep.hHWContext;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateContext... return True");
+ return True;
+}
+
+ Bool uniDRICreateContext(dpy, screen, visual, context, hHWContext)
+ Display* dpy;
+ int screen;
+ Visual* visual;
+ XID* context;
+ drm_context_t * hHWContext;
+{
+ return uniDRICreateContextWithConfig( dpy, screen, visual->visualid,
+ context, hHWContext );
+}
+
+ Bool uniDRIDestroyContext( Display * ndpy, int screen,
+ XID context )
+{
+ Display * const dpy = (Display *) ndpy;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIDestroyContextReq *req;
+
+ TRACE("DestroyContext...");
+ uniDRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIDestroyContext, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIDestroyContext;
+ req->screen = screen;
+ req->context = context;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("DestroyContext... return True");
+ return True;
+}
+
+Bool uniDRICreateDrawable( Display * ndpy, int screen,
+ Drawable drawable, drm_drawable_t * hHWDrawable )
+{
+ Display * const dpy = (Display *) ndpy;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRICreateDrawableReply rep;
+ xXF86DRICreateDrawableReq *req;
+
+ TRACE("CreateDrawable...");
+ uniDRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICreateDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICreateDrawable;
+ req->screen = screen;
+ req->drawable = drawable;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateDrawable... return False");
+ return False;
+ }
+ *hHWDrawable = rep.hHWDrawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateDrawable... return True");
+ return True;
+}
+
+Bool uniDRIDestroyDrawable( Display * ndpy, int screen,
+ Drawable drawable )
+{
+ Display * const dpy = (Display *) ndpy;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIDestroyDrawableReq *req;
+
+ TRACE("DestroyDrawable...");
+ uniDRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIDestroyDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIDestroyDrawable;
+ req->screen = screen;
+ req->drawable = drawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("DestroyDrawable... return True");
+ return True;
+}
+
+ Bool uniDRIGetDrawableInfo(Display* dpy, int screen, Drawable drawable,
+ unsigned int* index, unsigned int* stamp,
+ int* X, int* Y, int* W, int* H,
+ int* numClipRects, drm_clip_rect_t ** pClipRects,
+ int* backX, int* backY,
+ int* numBackClipRects, drm_clip_rect_t ** pBackClipRects )
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIGetDrawableInfoReply rep;
+ xXF86DRIGetDrawableInfoReq *req;
+ int total_rects;
+
+ TRACE("GetDrawableInfo...");
+ uniDRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetDrawableInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetDrawableInfo;
+ req->screen = screen;
+ req->drawable = drawable;
+
+ if (!_XReply(dpy, (xReply *)&rep, 1, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return False");
+ return False;
+ }
+ *index = rep.drawableTableIndex;
+ *stamp = rep.drawableTableStamp;
+ *X = (int)rep.drawableX;
+ *Y = (int)rep.drawableY;
+ *W = (int)rep.drawableWidth;
+ *H = (int)rep.drawableHeight;
+ *numClipRects = rep.numClipRects;
+ total_rects = *numClipRects;
+
+ *backX = rep.backX;
+ *backY = rep.backY;
+ *numBackClipRects = rep.numBackClipRects;
+ total_rects += *numBackClipRects;
+
+#if 0
+ /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks
+ * backwards compatibility (Because of the >> 2 shift) but the fix
+ * enables multi-threaded apps to work.
+ */
+ if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) -
+ SIZEOF(xGenericReply) +
+ total_rects * sizeof(drm_clip_rect_t)) + 3) & ~3) >> 2)) {
+ _XEatData(dpy, rep.length);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return False");
+ return False;
+ }
+#endif
+
+ if (*numClipRects) {
+ int len = sizeof(drm_clip_rect_t) * (*numClipRects);
+
+ *pClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
+ if (*pClipRects)
+ _XRead(dpy, (char*)*pClipRects, len);
+ } else {
+ *pClipRects = NULL;
+ }
+
+ if (*numBackClipRects) {
+ int len = sizeof(drm_clip_rect_t) * (*numBackClipRects);
+
+ *pBackClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
+ if (*pBackClipRects)
+ _XRead(dpy, (char*)*pBackClipRects, len);
+ } else {
+ *pBackClipRects = NULL;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return True");
+ return True;
+}
+
+ Bool uniDRIGetDeviceInfo(dpy, screen, hFrameBuffer,
+ fbOrigin, fbSize, fbStride, devPrivateSize, pDevPrivate)
+ Display* dpy;
+ int screen;
+ drm_handle_t * hFrameBuffer;
+ int* fbOrigin;
+ int* fbSize;
+ int* fbStride;
+ int* devPrivateSize;
+ void** pDevPrivate;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIGetDeviceInfoReply rep;
+ xXF86DRIGetDeviceInfoReq *req;
+
+ TRACE("GetDeviceInfo...");
+ uniDRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetDeviceInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetDeviceInfo;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return False");
+ return False;
+ }
+
+ *hFrameBuffer = rep.hFrameBufferLow;
+#ifdef LONG64
+ *hFrameBuffer |= ((drm_handle_t)rep.hFrameBufferHigh) << 32;
+#endif
+
+ *fbOrigin = rep.framebufferOrigin;
+ *fbSize = rep.framebufferSize;
+ *fbStride = rep.framebufferStride;
+ *devPrivateSize = rep.devPrivateSize;
+
+ if (rep.length) {
+ if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) {
+ _XEatData(dpy, ((rep.devPrivateSize+3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return False");
+ return False;
+ }
+ _XRead(dpy, (char*)*pDevPrivate, rep.devPrivateSize);
+ } else {
+ *pDevPrivate = NULL;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return True");
+ return True;
+}
+
diff --git a/nx-X11/lib/XvMC/hw/via/xf86dri.h b/nx-X11/lib/XvMC/hw/via/xf86dri.h
new file mode 100644
index 000000000..f82b573fe
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/via/xf86dri.h
@@ -0,0 +1,121 @@
+/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.8 2002/10/30 12:51:25 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/**
+ * \file xf86dri.h
+ * Protocol numbers and function prototypes for DRI X protocol.
+ *
+ * \author Kevin E. Martin <martin@valinux.com>
+ * \author Jens Owen <jens@tungstengraphics.com>
+ * \author Rickard E. (Rik) Faith <faith@valinux.com>
+ */
+
+#ifndef _XF86DRI_H_
+#define _XF86DRI_H_
+
+#include <X11/Xfuncproto.h>
+#include <xf86drm.h>
+
+#define X_XF86DRIQueryVersion 0
+#define X_XF86DRIQueryDirectRenderingCapable 1
+#define X_XF86DRIOpenConnection 2
+#define X_XF86DRICloseConnection 3
+#define X_XF86DRIGetClientDriverName 4
+#define X_XF86DRICreateContext 5
+#define X_XF86DRIDestroyContext 6
+#define X_XF86DRICreateDrawable 7
+#define X_XF86DRIDestroyDrawable 8
+#define X_XF86DRIGetDrawableInfo 9
+#define X_XF86DRIGetDeviceInfo 10
+#define X_XF86DRIAuthConnection 11
+#define X_XF86DRIOpenFullScreen 12 /* Deprecated */
+#define X_XF86DRICloseFullScreen 13 /* Deprecated */
+
+#define XF86DRINumberEvents 0
+
+#define XF86DRIClientNotLocal 0
+#define XF86DRIOperationNotSupported 1
+#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1)
+
+#ifndef _XF86DRI_SERVER_
+
+
+_XFUNCPROTOBEGIN
+
+Bool uniDRIQueryExtension( Display *dpy, int *event_base, int *error_base );
+
+Bool uniDRIQueryVersion( Display *dpy, int *majorVersion, int *minorVersion,
+ int *patchVersion );
+
+Bool uniDRIQueryDirectRenderingCapable( Display *dpy, int screen,
+ Bool *isCapable );
+
+Bool uniDRIOpenConnection( Display *dpy, int screen, drm_handle_t *hSAREA,
+ char **busIDString );
+
+Bool uniDRIAuthConnection( Display *dpy, int screen, drm_magic_t magic );
+
+Bool uniDRICloseConnection( Display *dpy, int screen );
+
+Bool uniDRIGetClientDriverName( Display *dpy, int screen,
+ int *ddxDriverMajorVersion, int *ddxDriverMinorVersion,
+ int *ddxDriverPatchVersion, char **clientDriverName );
+
+Bool uniDRICreateContext( Display *dpy, int screen, Visual *visual,
+ XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
+
+Bool uniDRICreateContextWithConfig( Display *dpy, int screen, int configID,
+ XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
+
+extern Bool uniDRIDestroyContext( Display *dpy, int screen,
+ XID context_id );
+
+extern Bool uniDRICreateDrawable( Display *dpy, int screen,
+ Drawable drawable, drm_drawable_t *hHWDrawable );
+
+extern Bool uniDRIDestroyDrawable( Display *dpy, int screen,
+ Drawable drawable);
+
+Bool uniDRIGetDrawableInfo( Display *dpy, int screen, Drawable drawable,
+ unsigned int *index, unsigned int *stamp,
+ int *X, int *Y, int *W, int *H,
+ int *numClipRects, drm_clip_rect_t ** pClipRects,
+ int *backX, int *backY,
+ int *numBackClipRects, drm_clip_rect_t **pBackClipRects );
+
+Bool uniDRIGetDeviceInfo( Display *dpy, int screen,
+ drm_handle_t *hFrameBuffer, int *fbOrigin, int *fbSize,
+ int *fbStride, int *devPrivateSize, void **pDevPrivate );
+
+_XFUNCPROTOEND
+
+#endif /* _XF86DRI_SERVER_ */
+
+#endif /* _XF86DRI_H_ */
+
diff --git a/nx-X11/lib/XvMC/hw/via/xf86dristr.h b/nx-X11/lib/XvMC/hw/via/xf86dristr.h
new file mode 100644
index 000000000..ac05b183b
--- /dev/null
+++ b/nx-X11/lib/XvMC/hw/via/xf86dristr.h
@@ -0,0 +1,343 @@
+/* $XFree86: xc/lib/GL/dri/xf86dristr.h,v 1.10 2002/10/30 12:51:25 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Jens Owen <jens@tungstengraphics.com>
+ * Rickard E. (Rik) Fiath <faith@valinux.com>
+ *
+ */
+
+#ifndef _XF86DRISTR_H_
+#define _XF86DRISTR_H_
+
+#include "xf86dri.h"
+
+#define XF86DRINAME "XFree86-DRI"
+
+/* The DRI version number. This was originally set to be the same of the
+ * XFree86 version number. However, this version is really indepedent of
+ * the XFree86 version.
+ *
+ * Version History:
+ * 4.0.0: Original
+ * 4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02
+ * 4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02
+ */
+#define XF86DRI_MAJOR_VERSION 4
+#define XF86DRI_MINOR_VERSION 1
+#define XF86DRI_PATCH_VERSION 0
+
+typedef struct _XF86DRIQueryVersion {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIQueryVersion */
+ CARD16 length B16;
+} xXF86DRIQueryVersionReq;
+#define sz_xXF86DRIQueryVersionReq 4
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD16 majorVersion B16; /* major version of DRI protocol */
+ CARD16 minorVersion B16; /* minor version of DRI protocol */
+ CARD32 patchVersion B32; /* patch version of DRI protocol */
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRIQueryVersionReply;
+#define sz_xXF86DRIQueryVersionReply 32
+
+typedef struct _XF86DRIQueryDirectRenderingCapable {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRIQueryDirectRenderingCapableReq;
+#define sz_xXF86DRIQueryDirectRenderingCapableReq 8
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ BOOL isCapable;
+ BOOL pad2;
+ BOOL pad3;
+ BOOL pad4;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+ CARD32 pad8 B32;
+ CARD32 pad9 B32;
+} xXF86DRIQueryDirectRenderingCapableReply;
+#define sz_xXF86DRIQueryDirectRenderingCapableReply 32
+
+typedef struct _XF86DRIOpenConnection {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIOpenConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRIOpenConnectionReq;
+#define sz_xXF86DRIOpenConnectionReq 8
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hSAREALow B32;
+ CARD32 hSAREAHigh B32;
+ CARD32 busIdStringLength B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+ CARD32 pad8 B32;
+} xXF86DRIOpenConnectionReply;
+#define sz_xXF86DRIOpenConnectionReply 32
+
+typedef struct _XF86DRIAuthConnection {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 magic B32;
+} xXF86DRIAuthConnectionReq;
+#define sz_xXF86DRIAuthConnectionReq 12
+
+typedef struct {
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 authenticated B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRIAuthConnectionReply;
+#define zx_xXF86DRIAuthConnectionReply 32
+
+typedef struct _XF86DRICloseConnection {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRICloseConnectionReq;
+#define sz_xXF86DRICloseConnectionReq 8
+
+typedef struct _XF86DRIGetClientDriverName {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIGetClientDriverName */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRIGetClientDriverNameReq;
+#define sz_xXF86DRIGetClientDriverNameReq 8
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 ddxDriverMajorVersion B32;
+ CARD32 ddxDriverMinorVersion B32;
+ CARD32 ddxDriverPatchVersion B32;
+ CARD32 clientDriverNameLength B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRIGetClientDriverNameReply;
+#define sz_xXF86DRIGetClientDriverNameReply 32
+
+typedef struct _XF86DRICreateContext {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICreateContext */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 visual B32;
+ CARD32 context B32;
+} xXF86DRICreateContextReq;
+#define sz_xXF86DRICreateContextReq 16
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hHWContext B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRICreateContextReply;
+#define sz_xXF86DRICreateContextReply 32
+
+typedef struct _XF86DRIDestroyContext {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIDestroyContext */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 context B32;
+} xXF86DRIDestroyContextReq;
+#define sz_xXF86DRIDestroyContextReq 12
+
+typedef struct _XF86DRICreateDrawable {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICreateDrawable */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRICreateDrawableReq;
+#define sz_xXF86DRICreateDrawableReq 12
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hHWDrawable B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRICreateDrawableReply;
+#define sz_xXF86DRICreateDrawableReply 32
+
+typedef struct _XF86DRIDestroyDrawable {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIDestroyDrawable */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRIDestroyDrawableReq;
+#define sz_xXF86DRIDestroyDrawableReq 12
+
+typedef struct _XF86DRIGetDrawableInfo {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIGetDrawableInfo */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRIGetDrawableInfoReq;
+#define sz_xXF86DRIGetDrawableInfoReq 12
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 drawableTableIndex B32;
+ CARD32 drawableTableStamp B32;
+ INT16 drawableX B16;
+ INT16 drawableY B16;
+ INT16 drawableWidth B16;
+ INT16 drawableHeight B16;
+ CARD32 numClipRects B32;
+ INT16 backX B16;
+ INT16 backY B16;
+ CARD32 numBackClipRects B32;
+} xXF86DRIGetDrawableInfoReply;
+
+#define sz_xXF86DRIGetDrawableInfoReply 36
+
+
+typedef struct _XF86DRIGetDeviceInfo {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIGetDeviceInfo */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRIGetDeviceInfoReq;
+#define sz_xXF86DRIGetDeviceInfoReq 8
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hFrameBufferLow B32;
+ CARD32 hFrameBufferHigh B32;
+ CARD32 framebufferOrigin B32;
+ CARD32 framebufferSize B32;
+ CARD32 framebufferStride B32;
+ CARD32 devPrivateSize B32;
+} xXF86DRIGetDeviceInfoReply;
+#define sz_xXF86DRIGetDeviceInfoReply 32
+
+typedef struct _XF86DRIOpenFullScreen {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIOpenFullScreen */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRIOpenFullScreenReq;
+#define sz_xXF86DRIOpenFullScreenReq 12
+
+typedef struct {
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 isFullScreen B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRIOpenFullScreenReply;
+#define sz_xXF86DRIOpenFullScreenReply 32
+
+typedef struct _XF86DRICloseFullScreen {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseFullScreen */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRICloseFullScreenReq;
+#define sz_xXF86DRICloseFullScreenReq 12
+
+typedef struct {
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+} xXF86DRICloseFullScreenReply;
+#define sz_xXF86DRICloseFullScreenReply 32
+
+
+#endif /* _XF86DRISTR_H_ */
diff --git a/nx-X11/lib/XvMC/wrapper/Imakefile b/nx-X11/lib/XvMC/wrapper/Imakefile
new file mode 100644
index 000000000..4438437c9
--- /dev/null
+++ b/nx-X11/lib/XvMC/wrapper/Imakefile
@@ -0,0 +1,34 @@
+XCOMM $XFree86: xc/lib/XvMC/wrapper/Imakefile,v 1.2 2002/10/30 12:52:02 alanh Exp $
+#define DoNormalLib NormalLibXvMC
+#define DoSharedLib SharedLibXvMC
+#define DoDebugLib DebugLibXvMC
+#define DoProfileLib ProfileLibXvMC
+#define LibName XvMCW
+#define SoRev SOXVMCREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXvMCReqs
+REQUIREDLIBS = -ldl
+#endif
+
+#ifdef XConfigDir
+XVMC_DEFINES = -DXVMC_CONFIGDIR=XConfigDir -DXVMC_SOVERSION=\".$(SOXVMCREV)\" \
+ -DXV_SOVERSION=\".$(SOXVREV)\"
+#endif
+
+
+ DEFINES = $(XVMC_DEFINES)
+ INCLUDES = -I$(XINCLUDESRC) -I$(INCLUDESRC) -I$(XLIBSRC) -I$(EXTINCSRC)
+ SRCS = XvMCWrapper.c
+ OBJS = XvMCWrapper.o
+ LINTLIBS = $(LINTXLIB)
+
+
+#if ((SharedLibXvMC == 1) && (SharedLibXv == 1))
+#include <Library.tmpl>
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/XvMC/wrapper/XvMCWrapper.c b/nx-X11/lib/XvMC/wrapper/XvMCWrapper.c
new file mode 100644
index 000000000..9fa0c99ab
--- /dev/null
+++ b/nx-X11/lib/XvMC/wrapper/XvMCWrapper.c
@@ -0,0 +1,779 @@
+/*****************************************************************************
+ * XvMC Wrapper including the Nonstandard VLD extension.
+ *
+ * Copyright (c) 2004 The Unichrome project. All rights reserved.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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.
+ *
+ * Author: Thomas Hellström (2004)
+ */
+
+/*
+ * BUGS: The wrapper really should maintain one symbol table per port. This
+ * could possibly be impemented, To do that, the port-independent symbols need to be lifted out,
+ * and one would have to create a number of mapping tables:
+ *
+ * port -> symbol table
+ * context -> port
+ * surface -> port
+ * subpicture -> port
+ *
+ * and reference the right table when needed.
+ * This needs to be done only if there is a player that wants to access two displays with different
+ * hardware simultaneously. Not likely as of today.
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <X11/extensions/XvMC.h>
+#include <X11/extensions/vldXvMC.h>
+#include <dlfcn.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+
+typedef Bool (*XvMCQueryExtensionP) (Display *, int *, int *);
+typedef Status (*XvMCQueryVersionP) (Display *, int *,int *);
+typedef XvMCSurfaceInfo * (*XvMCListSurfaceTypesP)(Display *, XvPortID, int *);
+typedef Status (* XvMCCreateContextP) (Display *,XvPortID,int ,int ,int ,int ,XvMCContext * );
+typedef Status (*XvMCDestroyContextP) (Display *, XvMCContext * );
+typedef Status (*XvMCCreateSurfaceP)(Display *,XvMCContext *,XvMCSurface *);
+typedef Status (*XvMCDestroySurfaceP)(Display *, XvMCSurface *);
+typedef XvImageFormatValues * (*XvMCListSubpictureTypesP) (Display *,XvPortID ,int ,int *);
+typedef Status (*XvMCPutSurfaceP)(Display *,XvMCSurface *,Drawable ,short , short , unsigned short ,
+ unsigned short ,short ,short ,unsigned short ,unsigned short ,int );
+typedef Status (*XvMCHideSurfaceP)(Display *, XvMCSurface *);
+typedef Status (*XvMCCreateSubpictureP) (Display *, XvMCContext *, XvMCSubpicture *,
+ unsigned short, unsigned short,int);
+typedef Status (*XvMCClearSubpictureP) (Display *,XvMCSubpicture *,short,short,unsigned short,unsigned short,
+ unsigned int);
+typedef Status (*XvMCCompositeSubpictureP) (Display *, XvMCSubpicture *,XvImage *,short,short,
+ unsigned short, unsigned short,short,short);
+typedef Status (*XvMCDestroySubpictureP) (Display *, XvMCSubpicture *);
+typedef Status (*XvMCSetSubpicturePaletteP) (Display *, XvMCSubpicture *, unsigned char *);
+typedef Status (*XvMCBlendSubpictureP) (Display *d,XvMCSurface *,XvMCSubpicture *,short,
+ short,unsigned short,unsigned short,short,short,
+ unsigned short,unsigned short);
+typedef Status (*XvMCBlendSubpicture2P) (Display *,XvMCSurface *,XvMCSurface *,
+ XvMCSubpicture *,short,short,unsigned short,
+ unsigned short,short,short,unsigned short,
+ unsigned short);
+typedef Status (*XvMCSyncSurfaceP) (Display *, XvMCSurface *);
+typedef Status (*XvMCFlushSurfaceP) (Display *, XvMCSurface *);
+typedef Status (*XvMCGetSurfaceStatusP) (Display *, XvMCSurface *, int *);
+typedef Status (*XvMCRenderSurfaceP) (Display *,XvMCContext *,unsigned int,XvMCSurface *,
+ XvMCSurface *,XvMCSurface *,unsigned int,unsigned int,
+ unsigned int,XvMCMacroBlockArray *,XvMCBlockArray *);
+typedef Status (*XvMCSyncSubpictureP) (Display *, XvMCSubpicture *);
+typedef Status (*XvMCFlushSubpictureP) (Display *, XvMCSubpicture *);
+typedef Status (*XvMCGetSubpictureStatusP) (Display *, XvMCSubpicture *, int *);
+typedef Status (*XvMCCreateBlocksP) (Display *, XvMCContext *,unsigned int,XvMCBlockArray *);
+typedef Status (*XvMCDestroyBlocksP) (Display *,XvMCBlockArray *);
+typedef Status (*XvMCCreateMacroBlocksP) (Display *,XvMCContext *,unsigned int,
+ XvMCMacroBlockArray *);
+typedef Status (*XvMCDestroyMacroBlocksP) (Display *,XvMCMacroBlockArray *);
+typedef XvAttribute *(*XvMCQueryAttributesP) (Display *,XvMCContext *,int *);
+typedef Status (*XvMCSetAttributeP) (Display *,XvMCContext *, Atom, int);
+typedef Status (*XvMCGetAttributeP) (Display *,XvMCContext *, Atom, int *);
+
+/*
+ * Nonstandard VLD acceleration level:
+ */
+
+typedef Status (*XvMCBeginSurfaceP) (Display *,XvMCContext *,XvMCSurface *,
+ XvMCSurface *,XvMCSurface *f,const XvMCMpegControl *);
+typedef Status (*XvMCLoadQMatrixP) (Display *, XvMCContext *,const XvMCQMatrix *);
+typedef Status (*XvMCPutSliceP)(Display *,XvMCContext *, char *,int);
+typedef Status (*XvMCPutSlice2P)(Display *,XvMCContext *, char *,int, unsigned);
+typedef Status (*XvMCGetDRInfoP)(Display *, XvPortID, char **, char **, int *, int *,
+ int *, int *);
+
+
+typedef struct {
+ XvMCQueryExtensionP XvMCQueryExtension;
+ XvMCQueryVersionP XvMCQueryVersion;
+ XvMCListSurfaceTypesP XvMCListSurfaceTypes;
+ XvMCCreateContextP XvMCCreateContext;
+ XvMCDestroyContextP XvMCDestroyContext;
+ XvMCCreateSurfaceP XvMCCreateSurface;
+ XvMCDestroySurfaceP XvMCDestroySurface;
+ XvMCListSubpictureTypesP XvMCListSubpictureTypes;
+ XvMCPutSurfaceP XvMCPutSurface;
+ XvMCHideSurfaceP XvMCHideSurface;
+ XvMCCreateSubpictureP XvMCCreateSubpicture;
+ XvMCClearSubpictureP XvMCClearSubpicture;
+ XvMCCompositeSubpictureP XvMCCompositeSubpicture;
+ XvMCDestroySubpictureP XvMCDestroySubpicture;
+ XvMCSetSubpicturePaletteP XvMCSetSubpicturePalette;
+ XvMCBlendSubpictureP XvMCBlendSubpicture;
+ XvMCBlendSubpicture2P XvMCBlendSubpicture2;
+ XvMCSyncSurfaceP XvMCSyncSurface;
+ XvMCFlushSurfaceP XvMCFlushSurface;
+ XvMCGetSurfaceStatusP XvMCGetSurfaceStatus;
+ XvMCRenderSurfaceP XvMCRenderSurface;
+ XvMCSyncSubpictureP XvMCSyncSubpicture;
+ XvMCFlushSubpictureP XvMCFlushSubpicture;
+ XvMCGetSubpictureStatusP XvMCGetSubpictureStatus;
+ XvMCCreateBlocksP XvMCCreateBlocks;
+ XvMCDestroyBlocksP XvMCDestroyBlocks;
+ XvMCCreateMacroBlocksP XvMCCreateMacroBlocks;
+ XvMCDestroyMacroBlocksP XvMCDestroyMacroBlocks;
+ XvMCQueryAttributesP XvMCQueryAttributes;
+ XvMCSetAttributeP XvMCSetAttribute;
+ XvMCGetAttributeP XvMCGetAttribute;
+
+ /*
+ * Nonstandard VLD acceleration level:
+ */
+
+ XvMCBeginSurfaceP XvMCBeginSurface;
+ XvMCLoadQMatrixP XvMCLoadQMatrix;
+ XvMCPutSliceP XvMCPutSlice;
+ XvMCPutSlice2P XvMCPutSlice2;
+
+ /*
+ * Driver name function.
+ */
+
+ XvMCGetDRInfoP XvMCGetDRInfo;
+
+ int preInitialised;
+ int initialised;
+ int vldextension;
+} XvMCWrapper;
+
+static XvMCWrapper xW;
+static int wrapperInit = 0;
+static int wrapperPreInit = 0;
+static void *xvhandle;
+static void *handle2;
+
+#define BUFLEN 200
+
+#define STRS(ARG) STR(ARG)
+#define STR(ARG) #ARG
+
+#define XW_RSYM(base,handle,handle2,pointer, retval) \
+ do { \
+ register char *err; \
+ base.pointer = (pointer##P) dlsym((handle),#pointer); \
+ if ((err = dlerror()) != NULL) { \
+ if (!handle2) { \
+ fprintf(stderr,"%s\n",err); return retval; \
+ } \
+ base.pointer = (pointer##P) dlsym((handle2),#pointer); \
+ if ((err = dlerror()) != NULL) { \
+ fprintf(stderr,"%s\n",err); return retval; \
+ } \
+ } \
+ } while (0);
+
+#define XW_RSYM2(base,handle,handle2,pointer) \
+ base.pointer = (pointer##P) dlsym((handle),#pointer); \
+ if (dlerror() != NULL) { \
+ base.pointer = (pointer##P) dlsym((handle2),#pointer); \
+ if (dlerror() != NULL) return; \
+ }
+
+
+/*
+ * Try to dlopen a shared library, versionless first.
+ */
+
+
+static void *dlopenversion(const char *lib, const char *version, int flag)
+{
+ void *ret;
+ int curLen,verLen;
+ char *curName;
+ const char *tail;
+
+
+ curLen = strlen(lib) + (verLen = strlen(version)) + 1;
+ curName = (char *) malloc(curLen * sizeof(char));
+ strncpy( curName, lib, curLen);
+ if (verLen > 1) {
+ if (NULL != (tail = strstr(version+1,"."))) {
+ strncat( curName, version, tail - version);
+ } else {
+ strncat( curName, version, verLen);
+ }
+ }
+ ret = dlopen(curName, flag);
+ free(curName);
+ return ret;
+}
+
+static int preInitW(Display *dpy)
+{
+
+ /*
+ * Resolve functions that are not hw driver specific.
+ */
+
+ void *handleZ = 0;
+
+ wrapperPreInit = 1;
+ xW.preInitialised = 0;
+ xW.initialised = 0;
+ xvhandle = dlopenversion("libXv.so", XV_SOVERSION, RTLD_LAZY | RTLD_GLOBAL);
+ if (!xvhandle) {
+ fprintf(stderr,"XvMCWrapper: Warning! Could not open shared "
+ "library \"libXv.so" XV_SOVERSION "\"\nThis may cause relocation "
+ "errors later.\nError was: \"%s\".\n",dlerror());
+ }
+ handle2 = dlopenversion("libXvMC.so", XVMC_SOVERSION, RTLD_LAZY | RTLD_GLOBAL);
+ if (!handle2) {
+ fprintf(stderr,"XvMCWrapper: Could not load XvMC "
+ "library \"libXvMC.so" XVMC_SOVERSION "\". Failing\n");
+ fprintf(stderr,"%s\n",dlerror());
+ return 1;
+ }
+ XW_RSYM(xW, handle2, handleZ, XvMCQueryExtension, 1);
+ XW_RSYM(xW, handle2, handleZ, XvMCQueryVersion, 1);
+ xW.preInitialised = 1;
+ return 0;
+}
+
+static void initW(Display *dpy, XvPortID port)
+{
+ char nameBuffer[BUFLEN];
+ void *handle;
+ int tmp;
+ char *clientName = NULL;
+ char *err;
+ FILE *configFile;
+ int nameLen = 0;
+ int major,minor,patchLevel,isLocal;
+ char *busID = NULL;
+
+ wrapperInit = 1;
+ xW.initialised = 0;
+
+ if (!wrapperPreInit)
+ if (preInitW( dpy )) return;
+
+ /*
+ * Will the DDX tell us the client driver name?
+ */
+
+ xW.XvMCGetDRInfo = (XvMCGetDRInfoP)
+ dlsym(handle2,"XvMCGetDRInfo");
+
+ if ((err = dlerror()) == NULL) {
+ if (0 == xW.XvMCGetDRInfo( dpy, port, &clientName, &busID, &major,
+ &minor,&patchLevel, &isLocal)) {
+ nameLen = strlen(clientName);
+ XFree(busID);
+ if (!isLocal) {
+ fprintf(stderr,"XvMCWrapper: X server is not local. Cannot run XvMC.\n");
+ XFree(clientName);
+ return;
+ }
+ } else {
+ clientName = NULL;
+ }
+ }
+
+ if (clientName && (nameLen < BUFLEN-7) && (nameLen > 0)) {
+ nameLen += 3;
+ strncpy(nameBuffer,"lib",BUFLEN-1);
+ strncpy(nameBuffer+3, clientName, BUFLEN-4);
+ strncpy(nameBuffer + nameLen, ".so", BUFLEN-nameLen-1);
+ nameBuffer[BUFLEN-1] = 0;
+ XFree(clientName);
+ handle = dlopenversion(nameBuffer, XVMC_SOVERSION,RTLD_LAZY);
+ } else {
+ /*
+ * No. Try to obtain it from the config file.
+ */
+
+ if (clientName) XFree(clientName);
+
+ configFile = fopen(STRS(XVMC_CONFIGDIR) "/XvMCConfig","r");
+
+ xW.initialised = 0;
+ xW.vldextension = 0;
+
+ if (0 == configFile) {
+ fprintf(stderr,"XvMCWrapper: Could not open config file \"%s\".\n",
+ STRS(XVMC_CONFIGDIR) "/XvMCConfig");
+ perror("XvMCWrapper");
+ return;
+ }
+
+ if (0 == fgets(nameBuffer, BUFLEN, configFile)) {
+ fclose(configFile);
+ fprintf(stderr,"XvMCWrapper: Could not read XvMC library name.\n");
+ perror("XvMCWrapper");
+ return;
+ }
+
+ fclose(configFile);
+ if ((tmp = strlen(nameBuffer)) == 0) {
+ fprintf(stderr,"XvMCWrapper: Zero length XvMC library name.\n");
+ fprintf(stderr,"%s\n",dlerror());
+ return;
+ }
+
+ /*
+ * Skip trailing newlines and garbage.
+ */
+
+ while (iscntrl(nameBuffer[tmp-1])) {
+ nameBuffer[tmp-1] = 0;
+ if (--tmp == 0) {
+ fprintf(stderr,"XvMCWrapper: Zero length XvMC library name.\n");
+ return;
+ }
+ }
+ handle = dlopen(nameBuffer,RTLD_LAZY);
+ }
+ if (!handle) {
+ fprintf(stderr,"XvMCWrapper: Could not load hardware specific XvMC "
+ "library \"%s\".\n",nameBuffer);
+ fprintf(stderr,"%s\n",dlerror());
+ return;
+ }
+
+ XW_RSYM(xW, handle, handle2, XvMCListSurfaceTypes,);
+ XW_RSYM(xW, handle, handle2, XvMCCreateContext,);
+ XW_RSYM(xW, handle, handle2, XvMCDestroyContext,);
+ XW_RSYM(xW, handle, handle2, XvMCCreateSurface,);
+ XW_RSYM(xW, handle, handle2, XvMCDestroySurface,);
+ XW_RSYM(xW, handle, handle2, XvMCListSubpictureTypes,);
+ XW_RSYM(xW, handle, handle2, XvMCHideSurface,);
+ XW_RSYM(xW, handle, handle2, XvMCCreateSubpicture,);
+ XW_RSYM(xW, handle, handle2, XvMCClearSubpicture,);
+ XW_RSYM(xW, handle, handle2, XvMCCompositeSubpicture,);
+ XW_RSYM(xW, handle, handle2, XvMCDestroySubpicture,);
+ XW_RSYM(xW, handle, handle2, XvMCSetSubpicturePalette,);
+ XW_RSYM(xW, handle, handle2, XvMCBlendSubpicture,);
+ XW_RSYM(xW, handle, handle2, XvMCBlendSubpicture2,);
+ XW_RSYM(xW, handle, handle2, XvMCPutSurface,);
+ XW_RSYM(xW, handle, handle2, XvMCSyncSurface,);
+ XW_RSYM(xW, handle, handle2, XvMCFlushSurface,);
+ XW_RSYM(xW, handle, handle2, XvMCGetSurfaceStatus,);
+ XW_RSYM(xW, handle, handle2, XvMCRenderSurface,);
+ XW_RSYM(xW, handle, handle2, XvMCSyncSubpicture,);
+ XW_RSYM(xW, handle, handle2, XvMCFlushSubpicture,);
+ XW_RSYM(xW, handle, handle2, XvMCGetSubpictureStatus,);
+ XW_RSYM(xW, handle, handle2, XvMCCreateBlocks,);
+ XW_RSYM(xW, handle, handle2, XvMCDestroyBlocks,);
+ XW_RSYM(xW, handle, handle2, XvMCCreateMacroBlocks,);
+ XW_RSYM(xW, handle, handle2, XvMCDestroyMacroBlocks,);
+ XW_RSYM(xW, handle, handle2, XvMCQueryAttributes,);
+ XW_RSYM(xW, handle, handle2, XvMCSetAttribute,);
+ XW_RSYM(xW, handle, handle2, XvMCGetAttribute,);
+ xW.initialised = 1;
+ XW_RSYM2(xW, handle, handle2, XvMCBeginSurface);
+ XW_RSYM(xW, handle, handle2, XvMCLoadQMatrix,);
+ XW_RSYM(xW, handle, handle2, XvMCPutSlice,);
+ XW_RSYM(xW, handle, handle2, XvMCPutSlice2,);
+ xW.vldextension = 1;
+}
+
+
+Bool XvMCQueryExtension (Display *display, int *eventBase, int *errBase)
+{
+ if (!wrapperPreInit) preInitW( display );
+ if (!xW.preInitialised) return 0;
+ return (*xW.XvMCQueryExtension)(display, eventBase, errBase);
+}
+
+Status XvMCQueryVersion (Display *display, int *major_versionp,
+ int *minor_versionp)
+{
+ if (!wrapperPreInit) preInitW( display );
+ if (!xW.preInitialised) return 0;
+ return (*xW.XvMCQueryVersion)(display, major_versionp, minor_versionp);
+}
+
+
+XvMCSurfaceInfo * XvMCListSurfaceTypes(Display *dpy, XvPortID port, int *num)
+{
+ if (!wrapperInit) initW( dpy, port);
+ if (!xW.initialised) return NULL;
+ return (*xW.XvMCListSurfaceTypes)(dpy, port, num);
+}
+
+Status XvMCCreateContext (
+ Display *display,
+ XvPortID port,
+ int surface_type_id,
+ int width,
+ int height,
+ int flags,
+ XvMCContext * context
+ )
+{
+ if (!wrapperInit) initW(display, port);
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCCreateContext)(display, port, surface_type_id,
+ width, height, flags, context);
+}
+
+Status XvMCDestroyContext (Display *display, XvMCContext * context)
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCDestroyContext)(display, context);
+}
+
+Status
+XvMCCreateSurface(
+ Display *display,
+ XvMCContext * context,
+ XvMCSurface * surface
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCCreateSurface)(display, context, surface);
+}
+
+Status XvMCDestroySurface(Display *display, XvMCSurface *surface)
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCDestroySurface)(display, surface);
+}
+
+
+XvImageFormatValues * XvMCListSubpictureTypes (
+ Display * display,
+ XvPortID port,
+ int surface_type_id,
+ int *count_return
+ )
+{
+ if (!xW.initialised) return NULL;
+ return (*xW.XvMCListSubpictureTypes)(display, port, surface_type_id,
+ count_return);
+}
+
+
+Status
+XvMCPutSurface(
+ Display *display,
+ XvMCSurface *surface,
+ Drawable draw,
+ short srcx,
+ short srcy,
+ unsigned short srcw,
+ unsigned short srch,
+ short destx,
+ short desty,
+ unsigned short destw,
+ unsigned short desth,
+ int flags
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCPutSurface)(display, surface, draw, srcx, srcy, srcw, srch,
+ destx, desty, destw, desth, flags);
+}
+
+Status XvMCHideSurface(Display *display, XvMCSurface *surface)
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCHideSurface)(display, surface);
+}
+
+
+Status
+XvMCCreateSubpicture (
+ Display *display,
+ XvMCContext *context,
+ XvMCSubpicture *subpicture,
+ unsigned short width,
+ unsigned short height,
+ int xvimage_id
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCCreateSubpicture)(display, context, subpicture, width, height,
+ xvimage_id);
+}
+
+
+Status
+XvMCClearSubpicture (
+ Display *display,
+ XvMCSubpicture *subpicture,
+ short x,
+ short y,
+ unsigned short width,
+ unsigned short height,
+ unsigned int color
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCClearSubpicture)(display, subpicture, x, y, width, height, color);
+}
+
+
+Status
+XvMCCompositeSubpicture (
+ Display *display,
+ XvMCSubpicture *subpicture,
+ XvImage *image,
+ short srcx,
+ short srcy,
+ unsigned short width,
+ unsigned short height,
+ short dstx,
+ short dsty
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCCompositeSubpicture)(display, subpicture, image, srcx, srcy,
+ width, height, dstx, dsty);
+}
+
+Status
+XvMCDestroySubpicture (Display *display, XvMCSubpicture *subpicture)
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCDestroySubpicture)(display, subpicture);
+}
+
+Status
+XvMCSetSubpicturePalette (
+ Display *display,
+ XvMCSubpicture *subpicture,
+ unsigned char *palette
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCSetSubpicturePalette)(display, subpicture, palette);
+}
+
+
+Status
+XvMCBlendSubpicture (
+ Display *display,
+ XvMCSurface *target_surface,
+ XvMCSubpicture *subpicture,
+ short subx,
+ short suby,
+ unsigned short subw,
+ unsigned short subh,
+ short surfx,
+ short surfy,
+ unsigned short surfw,
+ unsigned short surfh
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCBlendSubpicture)(display, target_surface, subpicture,
+ subx, suby, subw, subh, surfx, surfy,
+ surfw, surfh);
+}
+
+Status
+XvMCBlendSubpicture2 (
+ Display *display,
+ XvMCSurface *source_surface,
+ XvMCSurface *target_surface,
+ XvMCSubpicture *subpicture,
+ short subx,
+ short suby,
+ unsigned short subw,
+ unsigned short subh,
+ short surfx,
+ short surfy,
+ unsigned short surfw,
+ unsigned short surfh
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCBlendSubpicture2)(display, source_surface, target_surface, subpicture,
+ subx, suby, subw, subh, surfx, surfy, surfw, surfh);
+}
+
+
+Status XvMCSyncSurface (Display *display, XvMCSurface *surface)
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCSyncSurface)(display, surface);
+}
+
+Status XvMCFlushSurface (Display *display, XvMCSurface *surface)
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCFlushSurface)(display, surface);
+}
+
+Status XvMCGetSurfaceStatus (Display *display, XvMCSurface *surface, int *stat)
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCGetSurfaceStatus)(display, surface, stat);
+}
+
+Status XvMCRenderSurface (
+ Display *display,
+ XvMCContext *context,
+ unsigned int picture_structure,
+ XvMCSurface *target_surface,
+ XvMCSurface *past_surface,
+ XvMCSurface *future_surface,
+ unsigned int flags,
+ unsigned int num_macroblocks,
+ unsigned int first_macroblock,
+ XvMCMacroBlockArray *macroblock_array,
+ XvMCBlockArray *blocks
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCRenderSurface)(display, context, picture_structure, target_surface,
+ past_surface, future_surface, flags, num_macroblocks,
+ first_macroblock, macroblock_array, blocks);
+}
+
+Status XvMCSyncSubpicture (Display *display, XvMCSubpicture *subpicture)
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCSyncSubpicture)(display, subpicture);
+}
+
+Status XvMCFlushSubpicture (Display *display, XvMCSubpicture *subpicture)
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCFlushSubpicture)(display, subpicture);
+}
+Status
+XvMCGetSubpictureStatus (Display *display, XvMCSubpicture *subpic, int *stat)
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCGetSubpictureStatus)(display, subpic, stat);
+}
+
+Status XvMCCreateBlocks (
+ Display *display,
+ XvMCContext *context,
+ unsigned int num_blocks,
+ XvMCBlockArray *block
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCCreateBlocks)(display, context, num_blocks, block);
+}
+
+
+Status XvMCDestroyBlocks (Display *display,XvMCBlockArray *block)
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCDestroyBlocks)(display, block);
+}
+
+Status XvMCCreateMacroBlocks (
+ Display *display,
+ XvMCContext *context,
+ unsigned int num_blocks,
+ XvMCMacroBlockArray *blocks
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCCreateMacroBlocks)(display, context, num_blocks, blocks);
+}
+
+
+Status XvMCDestroyMacroBlocks (
+ Display *display,
+ XvMCMacroBlockArray *block
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCDestroyMacroBlocks)(display, block);
+}
+
+
+XvAttribute *
+XvMCQueryAttributes (
+ Display *display,
+ XvMCContext *context,
+ int *number
+ )
+{
+ if (!xW.initialised) return NULL;
+ return (*xW.XvMCQueryAttributes)(display, context, number);
+}
+
+
+Status
+XvMCSetAttribute (
+ Display *display,
+ XvMCContext *context,
+ Atom attribute,
+ int value
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCSetAttribute)(display, context, attribute, value);
+}
+
+
+Status
+XvMCGetAttribute (
+ Display *display,
+ XvMCContext *context,
+ Atom attribute,
+ int *value
+ )
+{
+ if (!xW.initialised) return BadValue;
+ return (*xW.XvMCGetAttribute)(display, context, attribute, value);
+}
+
+
+Status XvMCBeginSurface(Display *display,
+ XvMCContext *context,
+ XvMCSurface *target_surface,
+ XvMCSurface *past_surface,
+ XvMCSurface *future_surface,
+ const XvMCMpegControl *control)
+{
+ if (!xW.vldextension) return BadValue;
+ return (*xW.XvMCBeginSurface)(display, context, target_surface, past_surface, future_surface,
+ control);
+}
+
+Status XvMCLoadQMatrix(Display *display, XvMCContext *context,
+ const XvMCQMatrix *qmx)
+{
+ if (!xW.vldextension) return BadValue;
+ return (*xW.XvMCLoadQMatrix)(display, context, qmx);
+}
+
+Status XvMCPutSlice(Display *display,XvMCContext *context,
+ char *slice, int nBytes)
+{
+ if (!xW.vldextension) return BadValue;
+ return (*xW.XvMCPutSlice)(display, context, slice, nBytes);
+}
+
+Status XvMCPutSlice2(Display *display,XvMCContext *context,
+ char *slice, int nBytes, int sliceCode)
+{
+ if (!xW.vldextension) return BadValue;
+ return (*xW.XvMCPutSlice2)(display, context, slice, nBytes, sliceCode);
+}
diff --git a/nx-X11/lib/Xxf86dga/Imakefile b/nx-X11/lib/Xxf86dga/Imakefile
new file mode 100644
index 000000000..0be675720
--- /dev/null
+++ b/nx-X11/lib/Xxf86dga/Imakefile
@@ -0,0 +1,63 @@
+XCOMM $XdotOrg: xc/lib/Xxf86dga/Imakefile,v 1.3 2005/10/18 14:58:52 alanc Exp $
+XCOMM $XFree86: xc/lib/Xxf86dga/Imakefile,v 3.6 2003/05/05 20:42:30 tsi Exp $
+
+#define DoNormalLib NormalLibXxf86dga
+#define DoSharedLib SharedLibXxf86dga
+#define DoExtraLib SharedLibXxf86dga
+#define DoDebugLib DebugLibXxf86dga
+#define DoProfileLib ProfileLibXxf86dga
+#define LibName Xxf86dga
+#define SoRev SOXXF86DGAREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXxf86dgaReqs
+REQUIREDLIBS = SharedXxf86dgaReqs
+#endif
+
+XF86DGASRCS = XF86DGA.c XF86DGA2.c
+XF86DGAOBJS = XF86DGA.o XF86DGA2.o
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if defined(HasNetBSDApertureDriver) && HasNetBSDApertureDriver
+APERTURE_DEFINES = -DHAS_APERTURE_DRV
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) $(APERTURE_DEFINES)
+ SRCS = $(XF86DGASRCS)
+ OBJS = $(XF86DGAOBJS)
+ LINTLIBS = $(LINTXLIB)
+
+#define IncludeSharedObjectInNormalLib
+
+#include <Library.tmpl>
+
+InstallGenManPage(XDGA,$(LIBMANDIR),$(LIBMANSUFFIX))
+#if ExpandManNames
+DGAFUNCS = XDGAQueryExtension \
+ XDGAQueryVersion \
+ XDGAQueryModes \
+ XDGASetMode \
+ XDGAOpenFramebuffer \
+ XDGACloseFramebuffer \
+ XDGASetViewport \
+ XDGAInstallColormap \
+ XDGACreateColormap \
+ XDGASelectInput \
+ XDGAFillRectangle \
+ XDGACopyArea \
+ XDGACopyTransparentArea \
+ XDGAGetViewportStatus \
+ XDGASync \
+ XDGASetClientVersion \
+ XDGAChangePixmapMode \
+ XDGAKeyEventToXKeyEvent
+
+InstallGenManPageAliases(XDGA,$(LIBMANDIR),$(LIBMANSUFFIX),XF86DGA XFree86-DGA $(DGAFUNCS))
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/Xxf86dga/XDGA.man b/nx-X11/lib/Xxf86dga/XDGA.man
new file mode 100644
index 000000000..9c7beefbb
--- /dev/null
+++ b/nx-X11/lib/Xxf86dga/XDGA.man
@@ -0,0 +1,673 @@
+.\" $XFree86$
+.\"
+.TH XDGA 3 __vendorversion__
+.SH NAME
+XDGA \- Client library for the XFree86-DGA extension.
+.SH SYNOPSIS
+.B #include <X11/extensions/xf86dga.h>
+.HP
+Bool
+.BR XDGAQueryExtension (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int *" eventBase ,
+.br
+.RI "int *" errorBase )
+.HP
+Bool
+.BR XDGAQueryVersion (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int *" majorVersion ,
+.br
+.RI "int *" minorVersion )
+.HP
+XDGAMode
+.RB * XDGAQueryModes (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen ,
+.br
+.RI "int *" num )
+.HP
+XDGADevice
+.RB * XDGASetMode (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen ,
+.br
+.RI "int " mode )
+.HP
+Bool
+.BR XDGAOpenFramebuffer (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen )
+.HP
+void
+.BR XDGACloseFramebuffer (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen )
+.HP
+void
+.BR XDGASetViewport (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen ,
+.br
+.RI "int " x ,
+.br
+.RI "int " y ,
+.br
+.RI "int " flags )
+.HP
+void
+.BR XDGAInstallColormap (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen ,
+.br
+.RI "Colormap " cmap )
+.HP
+Colormap
+.BR XDGACreateColormap (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen ,
+.br
+.RI "XDGADevice *" device ,
+.br
+.RI "int " alloc )
+.HP
+void
+.BR XDGASelectInput (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen ,
+.br
+.RI "long " event_mask )
+.HP
+void
+.BR XDGAFillRectangle (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen ,
+.br
+.RI "int " x ,
+.br
+.RI "int " y ,
+.br
+.RI "unsigned int " width ,
+.br
+.RI "unsigned int " height ,
+.br
+.RI "unsigned long " color )
+.HP
+void
+.BR XDGACopyArea (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen ,
+.br
+.RI "int " srcx ,
+.br
+.RI "int " srcy ,
+.br
+.RI "unsigned int " width ,
+.br
+.RI "unsigned int " height ,
+.br
+.RI "int " dstx ,
+.br
+.RI "int " dsty )
+.HP
+void
+.BR XDGACopyTransparentArea (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen ,
+.br
+.RI "int " srcx ,
+.br
+.RI "int " srcy ,
+.br
+.RI "unsigned int " width ,
+.br
+.RI "unsigned int " height ,
+.br
+.RI "int " dstx ,
+.br
+.RI "int " dsty ,
+.br
+.RI "unsigned long " key )
+.HP
+int
+.BR XDGAGetViewportStatus (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen )
+.HP
+void
+.BR XDGASync (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen )
+.HP
+Bool
+.BR XDGASetClientVersion (
+.br
+.RI "Display *" dpy )
+.HP
+void
+.BR XDGAChangePixmapMode (
+.br
+.RI "Display *" dpy ,
+.br
+.RI "int " screen ,
+.br
+.RI "int *" x ,
+.br
+.RI "int *" y ,
+.br
+.RI "int " mode )
+.HP
+void
+.BR XDGAKeyEventToXKeyEvent (
+.br
+.RI "XDGAKeyEvent *" dk ,
+.br
+.RI "XKeyEvent *" xk )
+
+.SH DESCRIPTION
+The
+.B XFree86-DGA
+extension is an X server extension for allowing client programs direct
+access to the video frame buffer. This is a brief description of the
+programming interface for version 2.0 of the
+.B XFree86-DGA
+extension.
+.PP
+.B XFree86-DGA
+is not intended as a direct rendering API, but rather, as a mechanism
+to "get the X Server out of the way" so that some other direct rendering
+API can have full access to the hardware. With this in mind, DGA does
+provide clients some direct access to the hardware without requiring a
+separate rendering API, but this access is limited to direct linear
+framebuffer access.
+.PP
+Most of the reasons for the
+.B XFree86-DGA
+extension's existence are now better served in other ways. Further
+development of this extension is not expected, and it may be deprecated
+in a future release. The features that continue to be useful will either
+be provided through other existing mechanisms, or through an extension
+that address those needs more specifically.
+.PP
+.B XFree86-DGA
+is initialized by passing a number corresponding to a valid
+.I XDGAMode
+to
+.BR XDGASetMode ().
+Clients can get a list of valid modes from
+.BR XDGAQueryModes ().
+Each
+.I XDGAMode
+corresponds to a different framebuffer layout.
+.PP
+.BR XDGAQueryModes ()
+returns a pointer to an array of
+.IR XDGAMode s
+which are valid for the given screen.
+.I num
+is the number of elements in the array. The returned array can be freed
+with XFree(3). The
+.I XDGAMode
+structure is as follows:
+.PP
+.nf
+.ta .5i 2i
+typedef struct {
+ int num;
+ char *name;
+ float verticalRefresh;
+ int flags;
+ int imageWidth;
+ int imageHeight;
+ int pixmapWidth;
+ int pixmapHeight;
+ int bytesPerScanline;
+ int byteOrder;
+ int depth;
+ int bitsPerPixel;
+ unsigned long redMask;
+ unsigned long greenMask;
+ unsigned long blueMask;
+ short visualClass;
+ int viewportWidth;
+ int viewportHeight;
+ int xViewportStep;
+ int yViewportStep;
+ int maxViewportX;
+ int maxViewportY;
+ int viewportFlags;
+ int reserved1;
+ int reserved2;
+.br
+} XDGAMode;
+.fi
+.TP 8
+.I num
+A unique identifying number
+.RI ( num
+> 0) for the mode. This is the number referenced when initializing the mode.
+.TP 8
+.I name
+The name of the corresponding modeline as given in the __xconfigfile__ file.
+.TP 8
+.I verticalRefresh
+The vertical refresh rate for the modeline (in Hz).
+.TP 8
+.I flags
+Any of the following may be OR'd together:
+.RS 8
+.TP 4
+.B XDGAConcurrentAccess
+Indicates that concurrent client/server access to the framebuffer is
+possible. If this flag is not set it is very important to call
+.BR XDGASync ()
+before directly accessing the framebuffer if a call to
+.BR XDGAFillRectangle (),
+.BR XDGACopyArea ()
+or
+.BR XDGACopyTransparentArea ()
+or any Xlib rendering function has been made prior to such accesses.
+.TP 4
+.B XDGASolidFillRect
+Indicates that
+.BR XDGAFillRectangle ()
+is supported.
+.TP 4
+.B XDGABlitRect
+Indicates that
+.BR XDGACopyArea ()
+is supported.
+.TP 4
+.B XDGABlitTransRect
+Indicates that
+.BR XDGACopyTransparentArea ()
+is supported.
+.TP 4
+.B XDGAPixmap
+Indicates that a Pixmap will be returned when the mode is initialized.
+This means that rendering with Xlib is possible for this mode.
+.TP 4
+.B XDGAInterlaced
+.TP 4
+.B XDGADoublescan
+Indicates that the mode is an interlaced or doublescan mode.
+.RE
+.TP 8
+.I imageWidth
+.TP 8
+.I imageHeight
+The width and height of the framebuffer area accessible by the client.
+This rectangle is always justified to the upper left-hand corner.
+.TP 8
+.I pixmapWidth
+.TP 8
+.I pixmapHeight
+The width and height of the framebuffer area accessible by Xlib. This
+rectangle is always justified to the upper left-hand corner. These
+fields are only valid if the
+.B XDGAPixmap
+flag is set in the
+.I flags
+field.
+.TP 8
+.I bytesPerScanline
+The pitch of the framebuffer in bytes.
+.TP 8
+.I byteOrder
+.B MSBFirst
+or
+.BR LSBFirst .
+.TP 8
+.I depth
+The number of bits in each pixel which contain usable data.
+.TP 8
+.I bitsPerPixel
+The number of bits taken up by each pixel.
+.TP 8
+.I redMask
+.TP 8
+.I greenMask
+.TP 8
+.I blueMask
+The RGB masks. These do not apply to color-indexed modes.
+.TP 8
+.I visualClass
+.BR TrueColor ,
+.BR PseudoColor ,
+.BR DirectColor ,
+etc.
+.TP 8
+.I viewportWidth
+.TP 8
+.I viewportHeight
+The dimensions of the portion of the framebuffer which will be displayed
+on the screen.
+.TP 8
+.I xViewPortStep
+.TP 8
+.I yViewPortStep
+The granularity of the x,y viewport positioning possible with the
+.BR XDGASetViewport ()
+function.
+.TP 8
+.I maxViewportX
+.TP 8
+.I maxViewportY
+The maximum x and y positions possible with the
+.BR XDGASetViewport ()
+function.
+.TP 8
+.I viewportFlags
+Any of the following may be OR'd together
+.RS 8
+.TP 4
+.B XDGAFlipRetrace
+Indicates that the hardware can switch viewports during the vertical
+retrace.
+.TP 4
+.B XDGAFlipImmediate
+Indicates that the hardware can switch viewports immediately without
+waiting for the vertical retrace.
+.RE
+.PP
+.BR XDGASetMode ()
+initialises the
+.I XDGAMode
+corresponding to
+.IR num .
+To exit DGA mode and return to normal server operation, call
+.BR XDGASetMode ()
+with
+.I num
+set to zero.
+.BR XDGASetMode ()
+returns a pointer to an
+.I XDGADevice
+if successful. The XDGADevice can be freed with XFree(3). The
+.I XDGADevice
+structure is as follows:
+.PP
+.nf
+.ta .5i 2i
+typedef struct {
+ XDGAMode mode;
+ unsigned char *data;
+ Pixmap pixmap;
+.br
+} XDGADevice;
+.fi
+.TP 8
+.I mode
+The
+.I XDGAMode
+structure, identical to the information returned by
+.BR XDGAQueryModes ().
+.TP 8
+.I data
+If direct framebuffer access is desired and possible, this field will
+contain a pointer to the mapped framebuffer memory. Generally, this
+field will be zero unless a call to
+.BR XDGAOpenFramebuffer ()
+is made prior to initialization of the mode.
+.TP 8
+.I pixmap
+If the mode supports Xlib rendering as indicated by
+.B XDGAPixmap
+in the
+.I flags
+field, this will contain a Pixmap handle suitable for passing as the
+drawable argument to Xlib functions. This field will be zero if Xlib
+rendering is not supported.
+.PP
+.BR XDGAQueryExtension ()
+checks for the presence of the extension and returns the event and error bases.
+.PP
+.BR XDGAQueryVersion ()
+returns the
+.B XFree86-DGA
+major and minor version numbers.
+.PP
+.BR XDGAOpenFramebuffer ()
+maps the framebuffer memory. The client needs sufficient privileges to be
+able to do this.
+.BR XDGAOpenFramebuffer ()
+should be called prior to initializing a DGA mode if direct framebuffer
+access is desired for that mode.
+.BR XDGAOpenFramebuffer ()
+does not need to be called if direct framebuffer access is not required.
+If the framebuffer is opened,
+.PP
+.BR XDGACloseFramebuffer ()
+should be called prior to client exit to unmap the memory.
+.PP
+.BR XDGAChangePixmapMode ()
+can be used to change between two pixmap sizes in cases where a Pixmap is
+available for Xlib rendering. The following values for the
+.I mode
+parameter are available:
+.RS 8
+.TP 4
+.B XDGAPixmapModeLarge
+The pixmap size is defined by the
+.I pixmapWidth
+and
+.I pixmapHeight
+fields in the
+.I XDGAMode
+structure. The
+.I x
+and
+.I y
+values are ignored in this case.
+.TP 4
+.B XDGAPixmapModeSmall
+The pixmap size is defined by the
+.I viewportWidth
+and
+.I viewportHeight
+fields in the
+.I XDGAMode
+structure. In this mode, the
+.I x
+and
+.I y
+values specify where in the framebuffer this pixmap rectangle is located.
+It may be placed anywhere within the Xlib renderable region described
+by the
+.I pixmapWidth
+and
+.I pixmapHeight
+fields in the
+.IR XDGAMode .
+The
+.I x
+and
+.I y
+values returned are the resultant location of the pixmap and may be
+different from the requested x,y location due to platform specific
+alignment constraints. All Xlib rendering is clipped to this pixmap
+rectangle.
+.RE
+.PP
+.BR XDGASetViewport ()
+sets the upper left-hand corner of the rectangle of framebuffer that is
+to be displayed on the screen. Not all locations may be supported by
+the hardware and requested locations will be adjusted according to the
+.I xViewPortStep
+and
+.I yViewPortStep
+fields in the
+.IR XDGAMode .
+.PP
+.I flags
+can be
+.B XDGAFlipRetrace
+or
+.B XDGAFlipImmediate
+to adjust the viewport location at the next vertical retrace or
+immediately. Values other than the supported values advertised in the
+mode's
+.I viewportFlags
+field will result in hardware-specific default behavior.
+.B XDGAFlipImmediate
+will block until the flip is completed.
+.B XDGAFlipRetrace
+will generally NOT block so it is necessary to monitor the viewport
+status with
+.BR XDGAGetViewportStatus ().
+.B XDGAFlipImmediate
+requests during pending
+.B XDGAFlipRetrace
+requests will be ignored.
+.PP
+.BR XDGAGetViewportStatus ()
+keeps track of the
+.BR XDGASetViewport ()
+requests still pending. The return value of the function will have
+consecutive bits set (LSB justified), each bit representing a pending
+viewport change. For example:
+.PP
+.nf
+ while(XDGAGetViewportStatus(dpy, screen));
+.fi
+.PP
+waits for all pending viewport changes to finish.
+.PP
+.nf
+ while(0x2 & XDGAGetViewportStatus(dpy, screen));
+.fi
+.PP
+waits until all but the last viewport changes have completed.
+.PP
+.BR XDGACreateColormap ()
+is similar to the Xlib function XCreateColormap(3) except that it takes
+an
+.I XDGADevice
+as an argument instead of a Window and Visual. Though XCreateColormap(3)
+may create usable colormaps in some cases,
+.BR XDGACreateColormap ()
+is the preferred method for creating colormaps in DGA since there may
+not be an advertised visual compatible with the DGA device.
+.PP
+.BR XDGAInstallColormap ()
+must be used to install colormaps in DGA mode. XInstallColormap(3) will
+not work.
+.PP
+.BR XDGASelectInput ()
+enables DGA's own event mechanism. This function is similar to
+XSelectInput(3), and all Xlib Key, Button and Motion masks are supported.
+The following DGA events are defined:
+.PP
+.nf
+.ta .5i 2i
+typedef struct {
+ int type; /\(** ButtonPress or ButtonRelease + the DGA event base*/
+ unsigned long serial; /\(** # or last request processed by the server */
+ Display *display; /\(** Display the event was read from */
+ int screen; /\(** The screen number the event came from */
+ Time time; /\(** milliseconds */
+ unsigned int state; /\(** key or button mask */
+ unsigned int button; /\(** detail */
+.br
+} XDGAButtonEvent;
+.fi
+.PP
+.nf
+.ta .5i 2i
+typedef struct {
+ int type; /\(** KeyPress or KeyRelease + the DGA event base*/
+ unsigned long serial; /\(** # or last request processed by the server */
+ Display *display; /\(** Display the event was read from */
+ int screen; /\(** The screen number the event came from */
+ Time time; /\(** milliseconds */
+ unsigned int state; /\(** key or button mask */
+ unsigned int keycode; /\(** detail */
+.br
+} XDGAKeyEvent;
+.fi
+.PP
+.nf
+.ta .5i 2i
+typedef struct {
+ int type; /\(** MotionNotify + the DGA event base*/
+ unsigned long serial; /\(** # or last request processed by the server */
+ Display *display; /\(** Display the event was read from */
+ int screen; /\(** The screen number the event came from */
+ Time time; /\(** milliseconds */
+ unsigned int state; /\(** key or button mask */
+ int dx; /\(** relative pointer motion */
+ int dy; /\(** relative pointer motion */
+.br
+} XDGAMotionEvent;
+.fi
+.PP
+.BR XDGAKeyEventToXKeyEvent ()
+is a helper function to translate
+.IR XDGAKeyEvent s
+into
+.IR XKeyEvent s
+suitable for use with XLookupKeysym(3).
+.PP
+.BR XDGAFillRectangle (),
+.BR XDGACopyArea (),
+and
+.BR XDGACopyTransparentArea ()
+are included with some reservation since DGA is not intended as a
+rendering API. These are merely convenience routines and are optionally
+supported. The associated flags will be set in the
+.IR XDGAMode 's
+.I flags
+field if these functions are supported. These functions will be no-ops
+otherwise. they do not provide direct access to the hardware, but are
+simply context-less operations performed by the server.
+.PP
+.BR XDGASync ()
+blocks until all server rendering to the framebuffer completes. If Xlib
+or the 3 rendering functions above are used,
+.BR XDGASync ()
+must be called before the client directly accesses the framebuffer as
+the server rendering is asynchronous with the client and may have not
+completed. This is especially important if the
+.B XDGAConcurrentAccess
+flag is not set in the
+.IR XDGAMode 's
+.I flags
+field since concurrent access by the server and client may result in a
+system lockup.
+.SH SEE ALSO
+__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__)
+.SH AUTHORS
+.B XFree86-DGA
+version 2 was written by Mark Vojkovich. Version 1 was written by Jon
+Tombs, Harm Hanemaayer, Mark Vojkovich.
+
diff --git a/nx-X11/lib/Xxf86dga/XF86DGA.c b/nx-X11/lib/Xxf86dga/XF86DGA.c
new file mode 100644
index 000000000..95d7596e2
--- /dev/null
+++ b/nx-X11/lib/Xxf86dga/XF86DGA.c
@@ -0,0 +1,722 @@
+/* $XFree86: xc/lib/Xxf86dga/XF86DGA.c,v 3.23tsi Exp $ */
+/*
+
+Copyright (c) 1995 Jon Tombs
+Copyright (c) 1995,1996 The XFree86 Project, Inc
+
+*/
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#ifdef __UNIXOS2__ /* needed here to override certain constants in X headers */
+#define INCL_DOS
+#define INCL_DOSIOCTL
+#define I_NEED_OS2_H
+#include <os2.h>
+#endif
+
+#if defined(linux)
+#define HAS_MMAP_ANON
+#include <sys/types.h>
+#include <sys/mman.h>
+/* kernel header doesn't work with -ansi */
+/* #include <asm/page.h> */ /* PAGE_SIZE */
+#define HAS_SC_PAGESIZE /* _SC_PAGESIZE may be an enum for Linux */
+#define HAS_GETPAGESIZE
+#endif /* linux */
+
+#if defined(CSRG_BASED)
+#define HAS_MMAP_ANON
+#define HAS_GETPAGESIZE
+#include <sys/types.h>
+#include <sys/mman.h>
+#endif /* CSRG_BASED */
+
+#if defined(DGUX)
+#define HAS_GETPAGESIZE
+#define MMAP_DEV_ZERO
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#endif /* DGUX */
+
+#if defined(SVR4) && !defined(DGUX)
+#define MMAP_DEV_ZERO
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#endif /* SVR4 && !DGUX */
+
+#if defined(sun) && !defined(SVR4) /* SunOS */
+#define MMAP_DEV_ZERO /* doesn't SunOS have MAP_ANON ?? */
+#define HAS_GETPAGESIZE
+#include <sys/types.h>
+#include <sys/mman.h>
+#endif /* sun && !SVR4 */
+
+#ifdef XNO_SYSCONF
+#undef _SC_PAGESIZE
+#endif
+
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/xf86dga.h>
+#include <X11/extensions/xf86dgastr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+extern XExtDisplayInfo* xdga_find_display(Display*);
+extern char *xdga_extension_name;
+
+#define XF86DGACheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xdga_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * public XFree86-DGA Extension routines *
+ * *
+ *****************************************************************************/
+
+Bool XF86DGAQueryExtension (
+ Display *dpy,
+ int *event_basep,
+ int *error_basep
+){
+ return XDGAQueryExtension(dpy, event_basep, error_basep);
+}
+
+Bool XF86DGAQueryVersion(
+ Display* dpy,
+ int* majorVersion,
+ int* minorVersion
+){
+ return XDGAQueryVersion(dpy, majorVersion, minorVersion);
+}
+
+Bool XF86DGAGetVideoLL(
+ Display* dpy,
+ int screen,
+ int *offset,
+ int *width,
+ int *bank_size,
+ int *ram_size
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXF86DGAGetVideoLLReply rep;
+ xXF86DGAGetVideoLLReq *req;
+
+ XF86DGACheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DGAGetVideoLL, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XF86DGAGetVideoLL;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ *offset = /*(char *)*/rep.offset;
+ *width = rep.width;
+ *bank_size = rep.bank_size;
+ *ram_size = rep.ram_size;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+
+Bool XF86DGADirectVideoLL(
+ Display* dpy,
+ int screen,
+ int enable
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXF86DGADirectVideoReq *req;
+
+ XF86DGACheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DGADirectVideo, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XF86DGADirectVideo;
+ req->screen = screen;
+ req->enable = enable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ XSync(dpy,False);
+ return True;
+}
+
+Bool XF86DGAGetViewPortSize(
+ Display* dpy,
+ int screen,
+ int *width,
+ int *height
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXF86DGAGetViewPortSizeReply rep;
+ xXF86DGAGetViewPortSizeReq *req;
+
+ XF86DGACheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DGAGetViewPortSize, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XF86DGAGetViewPortSize;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ *width = rep.width;
+ *height = rep.height;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+
+Bool XF86DGASetViewPort(
+ Display* dpy,
+ int screen,
+ int x,
+ int y
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXF86DGASetViewPortReq *req;
+
+ XF86DGACheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DGASetViewPort, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XF86DGASetViewPort;
+ req->screen = screen;
+ req->x = x;
+ req->y = y;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ XSync(dpy,False);
+ return True;
+}
+
+
+Bool XF86DGAGetVidPage(
+ Display* dpy,
+ int screen,
+ int *vpage
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXF86DGAGetVidPageReply rep;
+ xXF86DGAGetVidPageReq *req;
+
+ XF86DGACheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DGAGetVidPage, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XF86DGAGetVidPage;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ *vpage = rep.vpage;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+
+Bool XF86DGASetVidPage(
+ Display* dpy,
+ int screen,
+ int vpage
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXF86DGASetVidPageReq *req;
+
+ XF86DGACheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DGASetVidPage, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XF86DGASetVidPage;
+ req->screen = screen;
+ req->vpage = vpage;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ XSync(dpy,False);
+ return True;
+}
+
+Bool XF86DGAInstallColormap(
+ Display* dpy,
+ int screen,
+ Colormap cmap
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXF86DGAInstallColormapReq *req;
+
+ XF86DGACheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DGAInstallColormap, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XF86DGAInstallColormap;
+ req->screen = screen;
+ req->id = cmap;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ XSync(dpy,False);
+ return True;
+}
+
+Bool XF86DGAQueryDirectVideo(
+ Display *dpy,
+ int screen,
+ int *flags
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXF86DGAQueryDirectVideoReply rep;
+ xXF86DGAQueryDirectVideoReq *req;
+
+ XF86DGACheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DGAQueryDirectVideo, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XF86DGAQueryDirectVideo;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *flags = rep.flags;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XF86DGAViewPortChanged(
+ Display *dpy,
+ int screen,
+ int n
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXF86DGAViewPortChangedReply rep;
+ xXF86DGAViewPortChangedReq *req;
+
+ XF86DGACheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DGAViewPortChanged, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XF86DGAViewPortChanged;
+ req->screen = screen;
+ req->n = n;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.result;
+}
+
+
+
+/* Helper functions */
+
+#include <X11/Xmd.h>
+#include <X11/extensions/xf86dga.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#if defined(ISC)
+# define HAS_SVR3_MMAP
+# include <sys/types.h>
+# include <errno.h>
+
+# include <sys/at_ansi.h>
+# include <sys/kd.h>
+
+# include <sys/sysmacros.h>
+# include <sys/immu.h>
+# include <sys/region.h>
+
+# include <sys/mmap.h>
+#else
+# if defined(Lynx) && defined(NO_MMAP)
+# include <sys/types.h>
+# include <errno.h>
+# include <smem.h>
+# else
+# if !defined(__UNIXOS2__)
+# include <sys/mman.h>
+# endif
+# endif
+#endif
+#include <sys/wait.h>
+#include <signal.h>
+#include <unistd.h>
+
+#if defined(SVR4) && !defined(sun)
+#define DEV_MEM "/dev/pmem"
+#elif defined(SVR4) && defined(sun)
+#define DEV_MEM "/dev/xsvc"
+#elif defined(HAS_APERTURE_DRV)
+#define DEV_MEM "/dev/xf86"
+#else
+#define DEV_MEM "/dev/mem"
+#endif
+
+typedef struct {
+ unsigned long physaddr; /* actual requested physical address */
+ unsigned long size; /* actual requested map size */
+ unsigned long delta; /* delta to account for page alignment */
+ void * vaddr; /* mapped address, without the delta */
+ int refcount; /* reference count */
+} MapRec, *MapPtr;
+
+typedef struct {
+ Display * display;
+ int screen;
+ MapPtr map;
+} ScrRec, *ScrPtr;
+
+static int mapFd = -1;
+static int numMaps = 0;
+static int numScrs = 0;
+static MapPtr *mapList = NULL;
+static ScrPtr *scrList = NULL;
+
+static MapPtr
+AddMap(void)
+{
+ MapPtr *old;
+
+ old = mapList;
+ mapList = realloc(mapList, sizeof(MapPtr) * (numMaps + 1));
+ if (!mapList) {
+ mapList = old;
+ return NULL;
+ }
+ mapList[numMaps] = malloc(sizeof(MapRec));
+ if (!mapList[numMaps])
+ return NULL;
+ return mapList[numMaps++];
+}
+
+static ScrPtr
+AddScr(void)
+{
+ ScrPtr *old;
+
+ old = scrList;
+ scrList = realloc(scrList, sizeof(ScrPtr) * (numScrs + 1));
+ if (!scrList) {
+ scrList = old;
+ return NULL;
+ }
+ scrList[numScrs] = malloc(sizeof(ScrRec));
+ if (!scrList[numScrs])
+ return NULL;
+ return scrList[numScrs++];
+}
+
+static MapPtr
+FindMap(unsigned long address, unsigned long size)
+{
+ int i;
+
+ for (i = 0; i < numMaps; i++) {
+ if (mapList[i]->physaddr == address &&
+ mapList[i]->size == size)
+ return mapList[i];
+ }
+ return NULL;
+}
+
+static ScrPtr
+FindScr(Display *display, int screen)
+{
+ int i;
+
+ for (i = 0; i < numScrs; i++) {
+ if (scrList[i]->display == display &&
+ scrList[i]->screen == screen)
+ return scrList[i];
+ }
+ return NULL;
+}
+
+static void *
+MapPhysAddress(unsigned long address, unsigned long size)
+{
+ unsigned long offset, delta;
+ int pagesize = -1;
+ void *vaddr;
+ MapPtr mp;
+#if defined(ISC) && defined(HAS_SVR3_MMAP)
+ struct kd_memloc mloc;
+#elif defined(__UNIXOS2__)
+ APIRET rc;
+ ULONG action;
+ HFILE hfd;
+#endif
+
+ if ((mp = FindMap(address, size))) {
+ mp->refcount++;
+ return (void *)((unsigned long)mp->vaddr + mp->delta);
+ }
+
+#if defined(_SC_PAGESIZE) && defined(HAS_SC_PAGESIZE)
+ pagesize = sysconf(_SC_PAGESIZE);
+#endif
+#ifdef _SC_PAGE_SIZE
+ if (pagesize == -1)
+ pagesize = sysconf(_SC_PAGE_SIZE);
+#endif
+#ifdef HAS_GETPAGESIZE
+ if (pagesize == -1)
+ pagesize = getpagesize();
+#endif
+#ifdef PAGE_SIZE
+ if (pagesize == -1)
+ pagesize = PAGE_SIZE;
+#endif
+ if (pagesize == -1)
+ pagesize = 4096;
+
+ delta = address % pagesize;
+ offset = address - delta;
+
+#if defined(ISC) && defined(HAS_SVR3_MMAP)
+ if (mapFd < 0) {
+ if ((mapFd = open("/dev/mmap", O_RDWR)) < 0)
+ return NULL;
+ }
+ mloc.vaddr = (char *)0;
+ mloc.physaddr = (char *)offset;
+ mloc.length = size + delta;
+ mloc.ioflg=1;
+
+ if ((vaddr = (void *)ioctl(mapFd, MAP, &mloc)) == (void *)-1)
+ return NULL;
+#elif defined (__UNIXOS2__)
+ /*
+ * Dragon warning here! /dev/pmap$ is never closed, except on progam exit.
+ * Consecutive calling of this routine will make PMAP$ driver run out
+ * of memory handles. Some umap/close mechanism should be provided
+ */
+
+ rc = DosOpen("/dev/pmap$", &hfd, &action, 0, FILE_NORMAL, FILE_OPEN,
+ OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, (PEAOP2)NULL);
+ if (rc != 0)
+ return NULL;
+ {
+ struct map_ioctl {
+ union {
+ ULONG phys;
+ void* user;
+ } a;
+ ULONG size;
+ } pmap,dmap;
+ ULONG plen,dlen;
+#define XFREE86_PMAP 0x76
+#define PMAP_MAP 0x44
+
+ pmap.a.phys = offset;
+ pmap.size = size + delta;
+ rc = DosDevIOCtl(hfd, XFREE86_PMAP, PMAP_MAP,
+ (PULONG)&pmap, sizeof(pmap), &plen,
+ (PULONG)&dmap, sizeof(dmap), &dlen);
+ if (rc == 0) {
+ vaddr = dmap.a.user;
+ }
+ }
+ if (rc != 0)
+ return NULL;
+#elif defined(Lynx) && defined(NO_MMAP)
+ vaddr = (void *)smem_create("XF86DGA", (char *)offset,
+ size + delta, SM_READ|SM_WRITE);
+#else
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
+ if (mapFd < 0) {
+ if ((mapFd = open(DEV_MEM, O_RDWR)) < 0)
+ return NULL;
+ }
+ vaddr = (void *)mmap(NULL, size + delta, PROT_READ | PROT_WRITE,
+ MAP_FILE | MAP_SHARED, mapFd, (off_t)offset);
+ if (vaddr == (void *)-1)
+ return NULL;
+#endif
+
+ if (!vaddr) {
+ if (!(mp = AddMap()))
+ return NULL;
+ mp->physaddr = address;
+ mp->size = size;
+ mp->delta = delta;
+ mp->vaddr = vaddr;
+ mp->refcount = 1;
+ }
+ return (void *)((unsigned long)vaddr + delta);
+}
+
+/*
+ * Still need to find a clean way of detecting the death of a DGA app
+ * and returning things to normal - Jon
+ * This is here to help debugging without rebooting... Also C-A-BS
+ * should restore text mode.
+ */
+
+int
+XF86DGAForkApp(int screen)
+{
+ pid_t pid;
+ int status;
+ int i;
+
+ /* fork the app, parent hangs around to clean up */
+ if ((pid = fork()) > 0) {
+ ScrPtr sp;
+
+ waitpid(pid, &status, 0);
+ for (i = 0; i < numScrs; i++) {
+ sp = scrList[i];
+ XF86DGADirectVideoLL(sp->display, sp->screen, 0);
+ XSync(sp->display, False);
+ }
+ if (WIFEXITED(status))
+ _exit(0);
+ else
+ _exit(-1);
+ }
+ return pid;
+}
+
+
+Bool
+XF86DGADirectVideo(
+ Display *dis,
+ int screen,
+ int enable
+){
+ ScrPtr sp;
+ MapPtr mp = NULL;
+
+ if ((sp = FindScr(dis, screen)))
+ mp = sp->map;
+
+ if (enable & XF86DGADirectGraphics) {
+#if !defined(ISC) && !defined(HAS_SVR3_MMAP) \
+ && !(defined(Lynx) && defined(NO_MMAP)) \
+ && !defined(__UNIXOS2__)
+ if (mp && mp->vaddr)
+ mprotect(mp->vaddr, mp->size + mp->delta, PROT_READ | PROT_WRITE);
+#endif
+ } else {
+#if !defined(ISC) && !defined(HAS_SVR3_MMAP) \
+ && !(defined(Lynx) && defined(NO_MMAP)) \
+ && !defined(__UNIXOS2__)
+ if (mp && mp->vaddr)
+ mprotect(mp->vaddr, mp->size + mp->delta, PROT_READ);
+#elif defined(Lynx) && defined(NO_MMAP)
+ /* XXX this doesn't allow enable after disable */
+ smem_create(NULL, mp->vaddr, mp->size + mp->delta, SM_DETACH);
+ smem_remove("XF86DGA");
+#endif
+ }
+
+ XF86DGADirectVideoLL(dis, screen, enable);
+ return 1;
+}
+
+
+static void
+XF86cleanup(int sig)
+{
+ ScrPtr sp;
+ int i;
+ static char beenhere = 0;
+
+ if (beenhere)
+ _exit(3);
+ beenhere = 1;
+
+ for (i = 0; i < numScrs; i++) {
+ sp = scrList[i];
+ XF86DGADirectVideo(sp->display, sp->screen, 0);
+ XSync(sp->display, False);
+ }
+ _exit(3);
+}
+
+Bool
+XF86DGAGetVideo(
+ Display *dis,
+ int screen,
+ char **addr,
+ int *width,
+ int *bank,
+ int *ram
+){
+ /*unsigned long*/ int offset;
+ static int beenHere = 0;
+ ScrPtr sp;
+ MapPtr mp;
+
+ if (!(sp = FindScr(dis, screen))) {
+ if (!(sp = AddScr())) {
+ fprintf(stderr, "XF86DGAGetVideo: malloc failure\n");
+ exit(-2);
+ }
+ sp->display = dis;
+ sp->screen = screen;
+ sp->map = NULL;
+ }
+
+ XF86DGAGetVideoLL(dis, screen , &offset, width, bank, ram);
+
+ *addr = MapPhysAddress(offset, *bank);
+ if (*addr == NULL) {
+ fprintf(stderr, "XF86DGAGetVideo: failed to map video memory (%s)\n",
+ strerror(errno));
+ exit(-2);
+ }
+
+ if ((mp = FindMap(offset, *bank)))
+ sp->map = mp;
+
+ if (!beenHere) {
+ beenHere = 1;
+ atexit((void(*)(void))XF86cleanup);
+ /* one shot XF86cleanup attempts */
+ signal(SIGSEGV, XF86cleanup);
+#ifdef SIGBUS
+ signal(SIGBUS, XF86cleanup);
+#endif
+ signal(SIGHUP, XF86cleanup);
+ signal(SIGFPE, XF86cleanup);
+ }
+
+ return 1;
+}
+
diff --git a/nx-X11/lib/Xxf86dga/XF86DGA2.c b/nx-X11/lib/Xxf86dga/XF86DGA2.c
new file mode 100644
index 000000000..533901fca
--- /dev/null
+++ b/nx-X11/lib/Xxf86dga/XF86DGA2.c
@@ -0,0 +1,968 @@
+/* $XFree86: xc/lib/Xxf86dga/XF86DGA2.c,v 1.23 2003/05/05 20:42:30 tsi Exp $ */
+/*
+
+Copyright (c) 1995 Jon Tombs
+Copyright (c) 1995,1996 The XFree86 Project, Inc
+
+*/
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#ifdef __UNIXOS2__ /* needed here to override certain constants in X headers */
+#define INCL_DOS
+#define INCL_DOSIOCTL
+#define I_NEED_OS2_H
+#include <os2.h>
+#endif
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/xf86dga.h>
+#include <X11/extensions/xf86dgastr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <stdio.h>
+
+
+/* If you change this, change the Bases[] array below as well */
+#define MAX_HEADS 16
+
+char *xdga_extension_name = XF86DGANAME;
+
+static XExtensionInfo _xdga_info_data;
+static XExtensionInfo *xdga_info = &_xdga_info_data;
+
+
+Bool XDGAMapFramebuffer(int, char *, unsigned char*, CARD32, CARD32, CARD32);
+void XDGAUnmapFramebuffer(int);
+unsigned char* XDGAGetMappedMemory(int);
+
+#define XDGACheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xdga_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int xdga_close_display(Display *dpy, XExtCodes *codes);
+static Bool xdga_wire_to_event(Display *dpy, XEvent *event, xEvent *wire_ev);
+static Status xdga_event_to_wire(Display *dpy, XEvent *event, xEvent *wire_ev);
+
+static XExtensionHooks xdga_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ xdga_close_display, /* close_display */
+ xdga_wire_to_event, /* wire_to_event */
+ xdga_event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_CLOSE_DISPLAY (xdga_close_display, xdga_info)
+
+
+XExtDisplayInfo* xdga_find_display(Display*);
+XEXT_GENERATE_FIND_DISPLAY (xdga_find_display, xdga_info,
+ "XFree86-DGA",
+ &xdga_extension_hooks,
+ 0, NULL)
+
+
+static Status
+xdga_event_to_wire(
+ Display *dpy,
+ XEvent *event,
+ xEvent *wire_ev
+){
+ return True;
+}
+
+static Bool
+xdga_wire_to_event(
+ Display *dpy,
+ XEvent *event,
+ xEvent *wire_ev
+){
+ dgaEvent *wire = (dgaEvent *) wire_ev;
+ XDGAButtonEvent *bevent;
+ XDGAKeyEvent *kevent;
+ XDGAMotionEvent *mevent;
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+
+ XDGACheckExtension (dpy, info, False);
+
+ switch((wire->u.u.type & 0x7f) - info->codes->first_event) {
+ case MotionNotify:
+ mevent = (XDGAMotionEvent*)event;
+ mevent->type = wire->u.u.type & 0x7F;
+ mevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *)wire);
+ mevent->display = dpy;
+ mevent->screen = wire->u.event.screen;
+ mevent->time = wire->u.event.time;
+ mevent->state = wire->u.event.state;
+ mevent->dx = wire->u.event.dx;
+ mevent->dy = wire->u.event.dy;
+ return True;
+ case ButtonPress:
+ case ButtonRelease:
+ bevent = (XDGAButtonEvent*)event;
+ bevent->type = wire->u.u.type & 0x7F;
+ bevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *)wire);
+ bevent->display = dpy;
+ bevent->screen = wire->u.event.screen;
+ bevent->time = wire->u.event.time;
+ bevent->state = wire->u.event.state;
+ bevent->button = wire->u.u.detail;
+ return True;
+ case KeyPress:
+ case KeyRelease:
+ kevent = (XDGAKeyEvent*)event;
+ kevent->type = wire->u.u.type & 0x7F;
+ kevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *)wire);
+ kevent->display = dpy;
+ kevent->screen = wire->u.event.screen;
+ kevent->time = wire->u.event.time;
+ kevent->state = wire->u.event.state;
+ kevent->keycode = wire->u.u.detail;
+ return True;
+ }
+
+ return False;
+}
+
+
+Bool XDGAQueryExtension (
+ Display *dpy,
+ int *event_basep,
+ int *error_basep
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+Bool XDGAQueryVersion(
+ Display *dpy,
+ int *majorVersion,
+ int *minorVersion
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGAQueryVersionReply rep;
+ xXDGAQueryVersionReq *req;
+
+ XDGACheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XDGAQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGAQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (*majorVersion >= 2)
+ {
+ int i, j;
+
+ for (i = 0, j = info->codes->first_event;
+ i < XF86DGANumberEvents;
+ i++, j++)
+ {
+ XESetWireToEvent (dpy, j, xdga_wire_to_event);
+ XESetEventToWire (dpy, j, xdga_event_to_wire);
+ }
+ XDGASetClientVersion(dpy);
+ }
+ return True;
+}
+
+Bool XDGASetClientVersion(
+ Display *dpy
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGASetClientVersionReq *req;
+
+ XDGACheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XDGASetClientVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGASetClientVersion;
+ req->major = XDGA_MAJOR_VERSION;
+ req->minor = XDGA_MINOR_VERSION;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XDGAOpenFramebuffer(
+ Display *dpy,
+ int screen
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGAOpenFramebufferReply rep;
+ xXDGAOpenFramebufferReq *req;
+ char *deviceName = NULL;
+ Bool ret;
+
+ XDGACheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XDGAOpenFramebuffer, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGAOpenFramebuffer;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ if(rep.length) {
+ deviceName = Xmalloc(rep.length << 2);
+ _XRead(dpy, deviceName, rep.length << 2);
+ }
+
+ ret = XDGAMapFramebuffer(screen, deviceName,
+ (unsigned char*)(long)rep.mem1,
+ rep.size, rep.offset, rep.extra);
+
+ if(deviceName)
+ Xfree(deviceName);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ret;
+}
+
+void XDGACloseFramebuffer(
+ Display *dpy,
+ int screen
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGACloseFramebufferReq *req;
+
+ XextSimpleCheckExtension (dpy, info, xdga_extension_name);
+
+ XDGAUnmapFramebuffer(screen);
+
+ LockDisplay(dpy);
+ GetReq(XDGACloseFramebuffer, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGACloseFramebuffer;
+ req->screen = screen;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+
+
+XDGAMode* XDGAQueryModes(
+ Display *dpy,
+ int screen,
+ int *num
+){
+ XExtDisplayInfo *dinfo = xdga_find_display (dpy);
+ xXDGAQueryModesReply rep;
+ xXDGAQueryModesReq *req;
+ XDGAMode *modes = NULL;
+
+ *num = 0;
+
+ XDGACheckExtension (dpy, dinfo, NULL);
+
+ LockDisplay(dpy);
+ GetReq(XDGAQueryModes, req);
+ req->reqType = dinfo->codes->major_opcode;
+ req->dgaReqType = X_XDGAQueryModes;
+ req->screen = screen;
+
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ if(rep.length) {
+ xXDGAModeInfo info;
+ int i, size;
+ char *offset;
+
+ size = rep.length << 2;
+ size -= rep.number * sz_xXDGAModeInfo; /* find text size */
+ modes = (XDGAMode*)Xmalloc((rep.number * sizeof(XDGAMode)) + size);
+ offset = (char*)(&modes[rep.number]); /* start of text */
+
+
+ if(modes) {
+ for(i = 0; i < rep.number; i++) {
+ _XRead(dpy, (char*)(&info), sz_xXDGAModeInfo);
+
+ modes[i].num = info.num;
+ modes[i].verticalRefresh =
+ (float)info.vsync_num / (float)info.vsync_den;
+ modes[i].flags = info.flags;
+ modes[i].imageWidth = info.image_width;
+ modes[i].imageHeight = info.image_height;
+ modes[i].pixmapWidth = info.pixmap_width;
+ modes[i].pixmapHeight = info.pixmap_height;
+ modes[i].bytesPerScanline = info.bytes_per_scanline;
+ modes[i].byteOrder = info.byte_order;
+ modes[i].depth = info.depth;
+ modes[i].bitsPerPixel = info.bpp;
+ modes[i].redMask = info.red_mask;
+ modes[i].greenMask = info.green_mask;
+ modes[i].blueMask = info.blue_mask;
+ modes[i].visualClass = info.visual_class;
+ modes[i].viewportWidth = info.viewport_width;
+ modes[i].viewportHeight = info.viewport_height;
+ modes[i].xViewportStep = info.viewport_xstep;
+ modes[i].yViewportStep = info.viewport_ystep;
+ modes[i].maxViewportX = info.viewport_xmax;
+ modes[i].maxViewportY = info.viewport_ymax;
+ modes[i].viewportFlags = info.viewport_flags;
+ modes[i].reserved1 = info.reserved1;
+ modes[i].reserved2 = info.reserved2;
+
+ _XRead(dpy, offset, info.name_size);
+ modes[i].name = offset;
+ offset += info.name_size;
+ }
+ *num = rep.number;
+ } else
+ _XEatData(dpy, rep.length << 2);
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return modes;
+}
+
+
+XDGADevice *
+XDGASetMode(
+ Display *dpy,
+ int screen,
+ int mode
+){
+ XExtDisplayInfo *dinfo = xdga_find_display (dpy);
+ xXDGASetModeReply rep;
+ xXDGASetModeReq *req;
+ XDGADevice *dev = NULL;
+ Pixmap pid;
+
+ XDGACheckExtension (dpy, dinfo, NULL);
+
+ LockDisplay(dpy);
+ GetReq(XDGASetMode, req);
+ req->reqType = dinfo->codes->major_opcode;
+ req->dgaReqType = X_XDGASetMode;
+ req->screen = screen;
+ req->mode = mode;
+ req->pid = pid = XAllocID(dpy);
+
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ if(rep.length) {
+ xXDGAModeInfo info;
+ int size;
+
+ size = rep.length << 2;
+ size -= sz_xXDGAModeInfo; /* get text size */
+
+ dev = (XDGADevice*)Xmalloc(sizeof(XDGADevice) + size);
+
+ if(dev) {
+ _XRead(dpy, (char*)(&info), sz_xXDGAModeInfo);
+
+ dev->mode.num = info.num;
+ dev->mode.verticalRefresh =
+ (float)info.vsync_num / (float)info.vsync_den;
+ dev->mode.flags = info.flags;
+ dev->mode.imageWidth = info.image_width;
+ dev->mode.imageHeight = info.image_height;
+ dev->mode.pixmapWidth = info.pixmap_width;
+ dev->mode.pixmapHeight = info.pixmap_height;
+ dev->mode.bytesPerScanline = info.bytes_per_scanline;
+ dev->mode.byteOrder = info.byte_order;
+ dev->mode.depth = info.depth;
+ dev->mode.bitsPerPixel = info.bpp;
+ dev->mode.redMask = info.red_mask;
+ dev->mode.greenMask = info.green_mask;
+ dev->mode.blueMask = info.blue_mask;
+ dev->mode.visualClass = info.visual_class;
+ dev->mode.viewportWidth = info.viewport_width;
+ dev->mode.viewportHeight = info.viewport_height;
+ dev->mode.xViewportStep = info.viewport_xstep;
+ dev->mode.yViewportStep = info.viewport_ystep;
+ dev->mode.maxViewportX = info.viewport_xmax;
+ dev->mode.maxViewportY = info.viewport_ymax;
+ dev->mode.viewportFlags = info.viewport_flags;
+ dev->mode.reserved1 = info.reserved1;
+ dev->mode.reserved2 = info.reserved2;
+
+ dev->mode.name = (char*)(&dev[1]);
+ _XRead(dpy, dev->mode.name, info.name_size);
+
+ dev->pixmap = (rep.flags & XDGAPixmap) ? pid : 0;
+ dev->data = XDGAGetMappedMemory(screen);
+
+ if(dev->data)
+ dev->data += rep.offset;
+ }
+ /* not sure what to do if the allocation fails */
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return dev;
+}
+
+
+void XDGASetViewport(
+ Display *dpy,
+ int screen,
+ int x,
+ int y,
+ int flags
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGASetViewportReq *req;
+
+ XextSimpleCheckExtension (dpy, info, xdga_extension_name);
+
+ LockDisplay(dpy);
+ GetReq(XDGASetViewport, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGASetViewport;
+ req->screen = screen;
+ req->x = x;
+ req->y = y;
+ req->flags = flags;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+
+void XDGAInstallColormap(
+ Display *dpy,
+ int screen,
+ Colormap cmap
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGAInstallColormapReq *req;
+
+ XextSimpleCheckExtension (dpy, info, xdga_extension_name);
+
+ LockDisplay(dpy);
+ GetReq(XDGAInstallColormap, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGAInstallColormap;
+ req->screen = screen;
+ req->cmap = cmap;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void XDGASelectInput(
+ Display *dpy,
+ int screen,
+ long mask
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGASelectInputReq *req;
+
+ XextSimpleCheckExtension (dpy, info, xdga_extension_name);
+
+ LockDisplay(dpy);
+ GetReq(XDGASelectInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGASelectInput;
+ req->screen = screen;
+ req->mask = mask;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void XDGAFillRectangle(
+ Display *dpy,
+ int screen,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height,
+ unsigned long color
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGAFillRectangleReq *req;
+
+ XextSimpleCheckExtension (dpy, info, xdga_extension_name);
+
+ LockDisplay(dpy);
+ GetReq(XDGAFillRectangle, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGAFillRectangle;
+ req->screen = screen;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->color = color;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void XDGACopyArea(
+ Display *dpy,
+ int screen,
+ int srcx,
+ int srcy,
+ unsigned int width,
+ unsigned int height,
+ int dstx,
+ int dsty
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGACopyAreaReq *req;
+
+ XextSimpleCheckExtension (dpy, info, xdga_extension_name);
+
+ LockDisplay(dpy);
+ GetReq(XDGACopyArea, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGACopyArea;
+ req->screen = screen;
+ req->srcx = srcx;
+ req->srcy = srcy;
+ req->width = width;
+ req->height = height;
+ req->dstx = dstx;
+ req->dsty = dsty;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void XDGACopyTransparentArea(
+ Display *dpy,
+ int screen,
+ int srcx,
+ int srcy,
+ unsigned int width,
+ unsigned int height,
+ int dstx,
+ int dsty,
+ unsigned long key
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGACopyTransparentAreaReq *req;
+
+ XextSimpleCheckExtension (dpy, info, xdga_extension_name);
+
+ LockDisplay(dpy);
+ GetReq(XDGACopyTransparentArea, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGACopyTransparentArea;
+ req->screen = screen;
+ req->srcx = srcx;
+ req->srcy = srcy;
+ req->width = width;
+ req->height = height;
+ req->dstx = dstx;
+ req->dsty = dsty;
+ req->key = key;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+
+int XDGAGetViewportStatus(
+ Display *dpy,
+ int screen
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGAGetViewportStatusReply rep;
+ xXDGAGetViewportStatusReq *req;
+ int status = 0;
+
+ XDGACheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(XDGAGetViewportStatus, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGAGetViewportStatus;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
+ status = rep.status;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+void XDGASync(
+ Display *dpy,
+ int screen
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGASyncReply rep;
+ xXDGASyncReq *req;
+
+ XextSimpleCheckExtension (dpy, info, xdga_extension_name);
+
+ LockDisplay(dpy);
+ GetReq(XDGASync, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGASync;
+ req->screen = screen;
+ _XReply(dpy, (xReply *)&rep, 0, xFalse);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+
+void XDGAChangePixmapMode(
+ Display *dpy,
+ int screen,
+ int *x,
+ int *y,
+ int mode
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGAChangePixmapModeReq *req;
+ xXDGAChangePixmapModeReply rep;
+
+ XextSimpleCheckExtension (dpy, info, xdga_extension_name);
+
+ LockDisplay(dpy);
+ GetReq(XDGAChangePixmapMode, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGAChangePixmapMode;
+ req->screen = screen;
+ req->x = *x;
+ req->y = *y;
+ req->flags = mode;
+ _XReply(dpy, (xReply *)&rep, 0, xFalse);
+ *x = rep.x;
+ *y = rep.y;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+Colormap XDGACreateColormap(
+ Display *dpy,
+ int screen,
+ XDGADevice *dev,
+ int alloc
+){
+ XExtDisplayInfo *info = xdga_find_display (dpy);
+ xXDGACreateColormapReq *req;
+ Colormap cid;
+
+ XDGACheckExtension (dpy, info, -1);
+
+ LockDisplay(dpy);
+ GetReq(XDGACreateColormap, req);
+ req->reqType = info->codes->major_opcode;
+ req->dgaReqType = X_XDGACreateColormap;
+ req->screen = screen;
+ req->mode = dev->mode.num;
+ req->alloc = alloc;
+ cid = req->id = XAllocID(dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return cid;
+}
+
+
+void XDGAKeyEventToXKeyEvent(
+ XDGAKeyEvent* dk,
+ XKeyEvent* xk
+){
+ xk->type = dk->type;
+ xk->serial = dk->serial;
+ xk->send_event = False;
+ xk->display = dk->display;
+ xk->window = RootWindow(dk->display, dk->screen);
+ xk->root = xk->window;
+ xk->subwindow = None;
+ xk->time = dk->time;
+ xk->x = xk->y = xk->x_root = xk->y_root = 0;
+ xk->state = dk->state;
+ xk->keycode = dk->keycode;
+ xk->same_screen = True;
+}
+
+#include <X11/Xmd.h>
+#include <X11/extensions/xf86dga.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#if defined(ISC)
+# define HAS_SVR3_MMAP
+# include <sys/types.h>
+# include <errno.h>
+
+# include <sys/at_ansi.h>
+# include <sys/kd.h>
+
+# include <sys/sysmacros.h>
+# include <sys/immu.h>
+# include <sys/region.h>
+
+# include <sys/mmap.h>
+#else
+# if defined(Lynx) && defined(NO_MMAP)
+# include <sys/types.h>
+# include <errno.h>
+# include <smem.h>
+# else
+# if !defined(__UNIXOS2__)
+# include <sys/mman.h>
+# endif
+# endif
+#endif
+#include <sys/wait.h>
+#include <signal.h>
+#include <unistd.h>
+
+#if defined(SVR4) && !defined(sun)
+#define DEV_MEM "/dev/pmem"
+#elif defined(SVR4) && defined(sun)
+#define DEV_MEM "/dev/xsvc"
+#elif defined(HAS_APERTURE_DRV)
+#define DEV_MEM "/dev/xf86"
+#else
+#define DEV_MEM "/dev/mem"
+#endif
+
+
+
+typedef struct _DGAMapRec{
+ unsigned char *physical;
+ unsigned char *virtual;
+ CARD32 size;
+ int fd;
+ int screen;
+ struct _DGAMapRec *next;
+} DGAMapRec, *DGAMapPtr;
+
+static Bool
+DGAMapPhysical(int, char*, unsigned char*, CARD32, CARD32, CARD32, DGAMapPtr);
+static void DGAUnmapPhysical(DGAMapPtr);
+
+static DGAMapPtr _Maps = NULL;
+
+
+unsigned char*
+XDGAGetMappedMemory(int screen)
+{
+ DGAMapPtr pMap = _Maps;
+ unsigned char *pntr = NULL;
+
+ while(pMap != NULL) {
+ if(pMap->screen == screen) {
+ pntr = pMap->virtual;
+ break;
+ }
+ pMap = pMap->next;
+ }
+
+ return pntr;
+}
+
+Bool
+XDGAMapFramebuffer(
+ int screen,
+ char *name, /* optional device name */
+ unsigned char* base, /* physical memory */
+ CARD32 size, /* size */
+ CARD32 offset, /* optional offset */
+ CARD32 extra /* optional extra data */
+){
+ DGAMapPtr pMap = _Maps;
+ Bool result;
+
+ /* is it already mapped ? */
+ while(pMap != NULL) {
+ if(pMap->screen == screen)
+ return True;
+ pMap = pMap->next;
+ }
+
+ if(extra & XDGANeedRoot) {
+ /* we should probably check if we have root permissions and
+ return False here */
+
+ }
+
+ pMap = (DGAMapPtr)Xmalloc(sizeof(DGAMapRec));
+
+ result = DGAMapPhysical(screen, name, base, size, offset, extra, pMap);
+
+ if(result) {
+ pMap->next = _Maps;
+ _Maps = pMap;
+ } else
+ Xfree(pMap);
+
+ return result;
+}
+
+void
+XDGAUnmapFramebuffer(int screen)
+{
+ DGAMapPtr pMap = _Maps;
+ DGAMapPtr pPrev = NULL;
+
+ /* is it already mapped */
+ while(pMap != NULL) {
+ if(pMap->screen == screen)
+ break;
+ pPrev = pMap;
+ pMap = pMap->next;
+ }
+
+ if(!pMap)
+ return;
+
+ DGAUnmapPhysical(pMap);
+
+ if(!pPrev)
+ _Maps = pMap->next;
+ else
+ pPrev->next = pMap->next;
+
+ Xfree(pMap);
+}
+
+
+static Bool
+DGAMapPhysical(
+ int screen,
+ char *name, /* optional device name */
+ unsigned char* base, /* physical memory */
+ CARD32 size, /* size */
+ CARD32 offset, /* optional offset */
+ CARD32 extra, /* optional extra data */
+ DGAMapPtr pMap
+) {
+#if defined(ISC) && defined(HAS_SVR3_MMAP)
+ struct kd_memloc mloc;
+#elif defined(__UNIXOS2__)
+ APIRET rc;
+ ULONG action;
+ HFILE hfd;
+#endif
+
+ base += offset;
+
+ pMap->screen = screen;
+ pMap->physical = base;
+ pMap->size = size;
+
+#if defined(ISC) && defined(HAS_SVR3_MMAP)
+ if ((pMap->fd = open("/dev/mmap", O_RDWR)) < 0)
+ return False;
+ mloc.vaddr = (char *)0;
+ mloc.physaddr = (char *)base;
+ mloc.length = size;
+ mloc.ioflg=1;
+
+ if ((pMap->virtual = (void *)ioctl(pMap->fd, MAP, &mloc)) == (void *)-1)
+ return False;
+#elif defined (__UNIXOS2__)
+ /*
+ * Dragon warning here! /dev/pmap$ is never closed, except on progam exit.
+ * Consecutive calling of this routine will make PMAP$ driver run out
+ * of memory handles. Some umap/close mechanism should be provided
+ */
+
+ rc = DosOpen("/dev/pmap$", &hfd, &action, 0, FILE_NORMAL, FILE_OPEN,
+ OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, (PEAOP2)NULL);
+ if (rc != 0)
+ return False;
+ {
+ struct map_ioctl {
+ union {
+ ULONG phys;
+ void* user;
+ } a;
+ ULONG size;
+ } pmap,dmap;
+ ULONG plen,dlen;
+#define XFREE86_PMAP 0x76
+#define PMAP_MAP 0x44
+
+ pmap.a.phys = base;
+ pmap.size = size;
+ rc = DosDevIOCtl(hfd, XFREE86_PMAP, PMAP_MAP,
+ (PULONG)&pmap, sizeof(pmap), &plen,
+ (PULONG)&dmap, sizeof(dmap), &dlen);
+ if (rc == 0) {
+ pMap->virtual = dmap.a.user;
+ }
+ }
+ if (rc != 0)
+ return False;
+#elif defined (Lynx) && defined(NO_MMAP)
+ pMap->virtual = smem_create("XF86DGA", (char*)base, size, SM_READ|SM_WRITE);
+#else
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
+ if (!name)
+ name = DEV_MEM;
+ if ((pMap->fd = open(name, O_RDWR)) < 0)
+ return False;
+ pMap->virtual = mmap(NULL, size, PROT_READ | PROT_WRITE,
+ MAP_FILE | MAP_SHARED, pMap->fd, (off_t)base);
+ if (pMap->virtual == (void *)-1)
+ return False;
+ mprotect(pMap->virtual, size, PROT_READ | PROT_WRITE);
+#endif
+
+ return True;
+}
+
+
+
+static void
+DGAUnmapPhysical(DGAMapPtr pMap)
+{
+#if defined(ISC) && defined(HAS_SVR3_MMAP)
+ /* XXX Add unmapping code here. */
+#elif defined (__UNIXOS2__)
+ /* XXX Add unmapping code here. */
+#elif defined(Lynx) && defined(NO_MMAP)
+ /* XXX this doesn't allow enable after disable */
+ smem_create(NULL, pMap->virtual, pMap->size, SM_DETACH);
+ smem_remove("XF86DGA");
+#else
+ if (pMap->virtual && pMap->virtual != (void *)-1) {
+ mprotect(pMap->virtual,pMap->size, PROT_READ);
+ munmap(pMap->virtual, pMap->size);
+ pMap->virtual = 0;
+ }
+ if (pMap->fd >= 0) {
+ close(pMap->fd);
+ pMap->fd = -1;
+ }
+#endif
+}
diff --git a/nx-X11/lib/Xxf86dga/Xxf86dga-def.cpp b/nx-X11/lib/Xxf86dga/Xxf86dga-def.cpp
new file mode 100644
index 000000000..2318b39c3
--- /dev/null
+++ b/nx-X11/lib/Xxf86dga/Xxf86dga-def.cpp
@@ -0,0 +1,16 @@
+LIBRARY libXxf86dga
+EXPORTS
+ XF86DGAQueryExtension
+ XF86DGAQueryDirectVideo
+ XF86DGAQueryVersion
+ XF86DGAInstallColormap
+ XF86DGAGetVideoLL
+ XF86DGADirectVideoLL
+; XF86DGAGetViewPort
+ XF86DGASetViewPort
+ XF86DGAGetVidPage
+ XF86DGASetVidPage
+ XF86DGADirectVideo
+ XF86DGAGetVideo
+
+/* $XFree86$ */
diff --git a/nx-X11/lib/Xxf86misc/Imakefile b/nx-X11/lib/Xxf86misc/Imakefile
new file mode 100644
index 000000000..db46af416
--- /dev/null
+++ b/nx-X11/lib/Xxf86misc/Imakefile
@@ -0,0 +1,40 @@
+XCOMM $XFree86: xc/lib/Xxf86misc/Imakefile,v 3.3 2002/10/16 00:37:34 dawes Exp $
+XCOMM $XdotOrg: xc/lib/Xxf86misc/Imakefile,v 1.3 2005/05/14 18:35:56 alanc Exp $
+
+#define DoNormalLib NormalLibXxf86misc
+#define DoSharedLib SharedLibXxf86misc
+#define DoExtraLib SharedLibXxf86misc
+#define DoDebugLib DebugLibXxf86misc
+#define DoProfileLib ProfileLibXxf86misc
+#define LibName Xxf86misc
+#define SoRev SOXXF86MISCREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXxf86miscReqs
+REQUIREDLIBS = SharedXxf86miscReqs
+#endif
+
+XF86MISCSRCS = XF86Misc.c
+XF86MISCOBJS = XF86Misc.o
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ SRCS = $(XF86MISCSRCS)
+ OBJS = $(XF86MISCOBJS)
+ LINTLIBS = $(LINTXLIB)
+
+#define IncludeSharedObjectInNormalLib
+
+#include <Library.tmpl>
+
+InstallGenManPage(XF86Misc,$(LIBMANDIR),$(LIBMANSUFFIX))
+#if ExpandManNames
+InstallGenManPageAliases(XF86Misc,$(LIBMANDIR),$(LIBMANSUFFIX),XF86MiscQueryExtension XF86MiscQueryVersion XF86MiscGetSaver XF86MiscSetSaver XF86MiscGetMouseSettings XF86MiscSetMouseSettings XF86MiscGetKbdSettings XF86MiscSetKbdSettings)
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/Xxf86misc/XF86Misc.c b/nx-X11/lib/Xxf86misc/XF86Misc.c
new file mode 100644
index 000000000..b0669d527
--- /dev/null
+++ b/nx-X11/lib/Xxf86misc/XF86Misc.c
@@ -0,0 +1,406 @@
+/* $XFree86: xc/lib/Xxf86misc/XF86Misc.c,v 3.12 2002/11/20 04:04:57 dawes Exp $ */
+
+/*
+ * Copyright (c) 1995, 1996 The XFree86 Project, Inc
+ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/xf86mscstr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+static XExtensionInfo _xf86misc_info_data;
+static XExtensionInfo *xf86misc_info = &_xf86misc_info_data;
+static char *xf86misc_extension_name = XF86MISCNAME;
+
+#define XF86MiscCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xf86misc_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *codes);
+
+static /* const */ XExtensionHooks xf86misc_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86misc_info,
+ xf86misc_extension_name,
+ &xf86misc_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86misc_info)
+
+
+/*****************************************************************************
+ * *
+ * public XFree86-Misc Extension routines *
+ * *
+ *****************************************************************************/
+
+Bool XF86MiscQueryExtension (dpy, event_basep, error_basep)
+ Display *dpy;
+ int *event_basep, *error_basep;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+Bool XF86MiscQueryVersion(dpy, majorVersion, minorVersion)
+ Display* dpy;
+ int* majorVersion;
+ int* minorVersion;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86MiscQueryVersionReply rep;
+ xXF86MiscQueryVersionReq *req;
+
+ XF86MiscCheckExtension (dpy, info, False);
+ LockDisplay(dpy);
+ GetReq(XF86MiscQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86miscReqType = X_XF86MiscQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (*majorVersion > 0 || *minorVersion > 5)
+ XF86MiscSetClientVersion(dpy);
+
+ return True;
+}
+
+Bool
+XF86MiscSetClientVersion(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86MiscSetClientVersionReq *req;
+
+ XF86MiscCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86MiscSetClientVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86miscReqType = X_XF86MiscSetClientVersion;
+ req->major = XF86MISC_MAJOR_VERSION;
+ req->minor = XF86MISC_MINOR_VERSION;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XF86MiscGetMouseSettings(dpy, mouseinfo)
+ Display* dpy;
+ XF86MiscMouseSettings *mouseinfo;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86MiscGetMouseSettingsReply rep;
+ xXF86MiscGetMouseSettingsReq *req;
+
+ XF86MiscCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86MiscGetMouseSettings, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86miscReqType = X_XF86MiscGetMouseSettings;
+ if (!_XReply(dpy, (xReply *)&rep,
+ (SIZEOF(xXF86MiscGetMouseSettingsReply) - SIZEOF(xReply))>>2,
+ xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ mouseinfo->type = rep.mousetype;
+ mouseinfo->baudrate = rep.baudrate;
+ mouseinfo->samplerate = rep.samplerate;
+ mouseinfo->resolution = rep.resolution;
+ mouseinfo->buttons = rep.buttons;
+ mouseinfo->emulate3buttons = rep.emulate3buttons;
+ mouseinfo->emulate3timeout = rep.emulate3timeout;
+ mouseinfo->chordmiddle = rep.chordmiddle;
+ mouseinfo->flags = rep.flags;
+ if (rep.devnamelen > 0) {
+ if (!(mouseinfo->device = Xcalloc(rep.devnamelen + 1, 1))) {
+ _XEatData(dpy, (rep.devnamelen+3) & ~3);
+ Xfree(mouseinfo->device);
+ return False;
+ }
+ _XReadPad(dpy, mouseinfo->device, rep.devnamelen);
+ } else
+ mouseinfo->device = NULL;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XF86MiscGetKbdSettings(dpy, kbdinfo)
+ Display* dpy;
+ XF86MiscKbdSettings *kbdinfo;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86MiscGetKbdSettingsReply rep;
+ xXF86MiscGetKbdSettingsReq *req;
+
+ XF86MiscCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86MiscGetKbdSettings, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86miscReqType = X_XF86MiscGetKbdSettings;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ kbdinfo->type = rep.kbdtype;
+ kbdinfo->rate = rep.rate;
+ kbdinfo->delay = rep.delay;
+ kbdinfo->servnumlock = rep.servnumlock;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XF86MiscSetMouseSettings(dpy, mouseinfo)
+ Display* dpy;
+ XF86MiscMouseSettings *mouseinfo;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86MiscSetMouseSettingsReq *req;
+ int majorVersion, minorVersion;
+
+ XF86MiscCheckExtension (dpy, info, False);
+ XF86MiscQueryVersion(dpy, &majorVersion, &minorVersion);
+
+ LockDisplay(dpy);
+ GetReq(XF86MiscSetMouseSettings, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->xf86miscReqType = X_XF86MiscSetMouseSettings;
+ req->mousetype = mouseinfo->type;
+ req->baudrate = mouseinfo->baudrate;
+ req->samplerate = mouseinfo->samplerate;
+ req->resolution = mouseinfo->resolution;
+ req->buttons = mouseinfo->buttons;
+ req->emulate3buttons = mouseinfo->emulate3buttons;
+ req->emulate3timeout = mouseinfo->emulate3timeout;
+ req->chordmiddle = mouseinfo->chordmiddle;
+ req->flags = mouseinfo->flags;
+ if (majorVersion > 0 || minorVersion > 5) {
+ int len;
+ if ((len = strlen(mouseinfo->device))) {
+ req->devnamelen = len + 1;
+ len = (req->devnamelen + 3) >> 2;
+ SetReqLen(req,len,len);
+ Data(dpy, mouseinfo->device, req->devnamelen);
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XF86MiscSetKbdSettings(dpy, kbdinfo)
+ Display* dpy;
+ XF86MiscKbdSettings *kbdinfo;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86MiscSetKbdSettingsReq *req;
+
+ XF86MiscCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86MiscSetKbdSettings, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86miscReqType = X_XF86MiscSetKbdSettings;
+ req->kbdtype = kbdinfo->type;
+ req->rate = kbdinfo->rate;
+ req->delay = kbdinfo->delay;
+ req->servnumlock = kbdinfo->servnumlock;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+int XF86MiscSetGrabKeysState(dpy, enable)
+ Display* dpy;
+ Bool enable;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86MiscSetGrabKeysStateReply rep;
+ xXF86MiscSetGrabKeysStateReq *req;
+
+ XF86MiscCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86MiscSetGrabKeysState, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86miscReqType = X_XF86MiscSetGrabKeysState;
+ req->enable = enable;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.status;
+}
+
+Bool XF86MiscGetFilePaths(dpy, filpaths)
+ Display* dpy;
+ XF86MiscFilePaths *filpaths;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86MiscGetFilePathsReply rep;
+ xXF86MiscGetFilePathsReq *req;
+
+ XF86MiscCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86MiscGetFilePaths, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86miscReqType = X_XF86MiscGetFilePaths;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ if (rep.configlen) {
+ if (!(filpaths->configfile = Xcalloc(rep.configlen + 1, 1))) {
+ _XEatData(dpy, ((rep.configlen+3) & ~3) + ((rep.modulelen+3) & ~3)
+ + ((rep.loglen+3) & ~3));
+ return False;
+ }
+ }
+
+ if (rep.modulelen) {
+ if (!(filpaths->modulepath = Xcalloc(rep.modulelen + 1, 1))) {
+ _XEatData(dpy, ((rep.configlen+3) & ~3) + ((rep.modulelen+3) & ~3)
+ + ((rep.loglen+3) & ~3));
+ if (filpaths->configfile)
+ Xfree(filpaths->configfile);
+ return False;
+ }
+ }
+
+ if (rep.loglen) {
+ if (!(filpaths->logfile = Xcalloc(rep.loglen + 1, 1))) {
+ _XEatData(dpy, ((rep.configlen+3) & ~3) + ((rep.modulelen+3) & ~3)
+ + ((rep.loglen+3) & ~3));
+ if (filpaths->configfile)
+ Xfree(filpaths->configfile);
+ if (filpaths->modulepath)
+ Xfree(filpaths->modulepath);
+ return False;
+ }
+ }
+
+ if (rep.configlen)
+ _XReadPad(dpy, filpaths->configfile, rep.configlen);
+ else
+ filpaths->configfile = "";
+
+ if (rep.modulelen)
+ _XReadPad(dpy, filpaths->modulepath, rep.modulelen);
+ else
+ filpaths->modulepath = "";
+
+ if (rep.loglen)
+ _XReadPad(dpy, filpaths->logfile, rep.loglen);
+ else
+ filpaths->logfile = "";
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status XF86MiscPassMessage(dpy, screen, msgtype, msgval, retmsg)
+ Display* dpy;
+ int screen;
+ const char* msgtype;
+ const char* msgval;
+ char** retmsg;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86MiscPassMessageReply rep;
+ xXF86MiscPassMessageReq *req;
+ int len;
+
+ XF86MiscCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86MiscPassMessage, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86miscReqType = X_XF86MiscPassMessage;
+ req->screen = screen;
+ if ((len = strlen(msgtype))) {
+ req->typelen = len + 1;
+ len = (req->typelen + 3) >> 2;
+ SetReqLen(req,len,len);
+ Data(dpy, msgtype, req->typelen);
+ }
+ if ((len = strlen(msgval))) {
+ req->vallen = len + 1;
+ len = (req->vallen + 3) >> 2;
+ SetReqLen(req,len,len);
+ Data(dpy, msgval, req->vallen);
+ }
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadImplementation;
+ }
+
+ if (rep.mesglen) {
+ if (!(*retmsg = Xcalloc(rep.mesglen + 1, 1))) {
+ _XEatData(dpy, ((rep.mesglen+3) & ~3));
+ return BadAlloc;
+ }
+ _XReadPad(dpy, *retmsg, rep.mesglen);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.status;
+}
+
diff --git a/nx-X11/lib/Xxf86misc/XF86Misc.man b/nx-X11/lib/Xxf86misc/XF86Misc.man
new file mode 100644
index 000000000..2c80dff0b
--- /dev/null
+++ b/nx-X11/lib/Xxf86misc/XF86Misc.man
@@ -0,0 +1,217 @@
+.\" $XdotOrg: xc/lib/Xxf86misc/XF86Misc.man,v 1.2 2004/04/23 19:23:08 eich Exp $
+.\" $TOG: XF86Misc.man /main/7 1997/07/19 10:30:32 kaleb $
+.\"
+.\"
+.\"
+.\" Copyright (c) 1996 Joe Moss, The XFree86 Project
+.\"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/doc/man/XF86Misc.man,v 3.12 2002/12/22 00:46:54 dawes Exp $
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.TH XF86MISC __libmansuffix__ __vendorversion__ "X FUNCTIONS"
+.SH NAME
+XF86MiscQueryExtension, XF86MiscQueryVersion, XF86MiscGetMouseSettings, XF86MiscSetMouseSettings, XF86MiscGetKbdSettings, XF86MiscSetKbdSettings \- Extension library for the XFree86-Misc X extension.
+.SH SYNTAX
+.nf
+.LP
+\&#include <X11/extensions/xf86misc.h>
+.LP
+Bool XF86MiscQueryExtension(
+ Display *\fIdisplay\fP\^,
+ int *\fIevent_base_return\fP\^,
+ int *\fIerror_base_return\fP\^);
+.LP
+Bool XF86MiscQueryVersion(
+ Display *\fIdisplay\fP\^,
+ int *\fImajor_version_return\fP\^,
+ int *\fIminor_version_return\fP\^);
+.ig
+.LP
+Status XF86MiscGetSaver(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ int *\fIsuspend_time_return\fP\^,
+ int *\fIoff_time_return\fP\^);
+.LP
+Status XF86MiscSetSaver(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ int \fIsuspend_time\fP\^,
+ int \fIoff_time\fP\^);
+..
+.LP
+Status XF86MiscGetMouseSettings(
+ Display *\fIdisplay\fP\^,
+ XF86MiscMouseSettings *\fImseinfo\fP\^);
+.LP
+Status XF86MiscSetMouseSettings(
+ Display *\fIdisplay\fP\^,
+ XF86MiscMouseSettings *\fImseinfo\fP\^);
+.LP
+Status XF86MiscGetKbdSettings(
+ Display *\fIdisplay\fP\^,
+ XF86MiscKbdSettings *\fIkbdinfo\fP\^);
+.LP
+Status XF86MiscSetKbdSettings(
+ Display *\fIdisplay\fP\^,
+ XF86MiscKbdSettings *\fIkbdinfo\fP\^);
+.fi
+.SH ARGUMENTS
+.IP \fIdisplay\fP 2i
+Specifies the connection to the X server.
+.IP \fIscreen\fP 2i
+Specifies which screen number the setting apply to.
+.IP \fIevent_base_return\fP 2i
+Returns the base event number for the extension.
+.IP \fIerror_base_return\fP 2i
+Returns the base error number for the extension.
+.IP \fImajor_version_return\fP 2i
+Returns the major version number of the extension.
+.IP \fIminor_version_return\fP 2i
+Returns the minor version number of the extension.
+.ig
+.IP \fIsuspend_time_return\fP 2i
+Returns the number of seconds of idle time the server
+will wait before activating the monitor's suspend mode.
+.IP \fIoff_time_return\fP 2i
+Returns the number of seconds of idle time the server
+will wait before causing the monitor to powerdown.
+.IP \fIsuspend_time\fP 2i
+Specifies the number of seconds of idle time the server
+should wait before activating the monitor's suspend mode.
+.IP \fIoff_time\fP 2i
+Specifies the number of seconds of idle time the server
+should wait before causing the monitor to powerdown.
+..
+.IP \fImseinfo\fP 2i
+Specifies a structure which contains the mouse parameters.
+.IP \fIkbdinfo\fP 2i
+Specifies a structure which contains the keyboard parameters.
+.SH STRUCTURES
+.nf
+.ta 3i
+\fIMouse:\fP
+typedef struct {
+ char *device; /\(** returned path to device */
+ int type; /\(** mouse protocol */
+ int baudrate; /\(** 1200, 2400, 4800, or 9600 */
+ int samplerate; /\(** samples per second */
+ int resolution; /\(** resolution, count per inch */
+ int buttons; /\(** number of buttons */
+ Bool emulate3buttons; /\(** Button1+Button3 -> Button2 ? */
+ int emulate3timeout; /\(** in milliseconds */
+ Bool chordmiddle; /\(** Button1+Button3 == Button2 ? */
+ int flags; /\(** Device open flags */
+} XF86MiscMouseSettings;
+.LP
+\fIKeyboard:\fP
+typedef struct {
+ int type; /\(** of keyboard: 84-key, 101-key, Xqueue */
+ int rate; /\(** repeat rate */
+ int delay; /\(** delay until repeat starts */
+ Bool servnumlock; /\(** Server handles NumLock ? */
+} XF86MiscKbdSettings;
+.fi
+.SH DESCRIPTION
+These functions provide an interface to the
+\fIXFree86-Misc\fP extension
+which allows various server settings to be
+queried and changed dynamically.
+Applications that use these functions must be linked with
+.ZN -lXxf86misc
+.SS "POWER-SAVER FUNCTIONS"
+The
+.ZN XF86MiscGetSaver
+and
+.ZN XF86MiscSetSaver
+functions have been removed. This functionality is now provided by
+the DPMS extension.
+.SS "MOUSE FUNCTIONS"
+Mouse parameters can be queried using the function
+.ZN XF86MiscGetMouseSettings .
+The structure pointed to by its second argument is filled in
+with the current mouse settings.
+.PP
+Not all fields are valid in all cases.
+For example, when the protocol indicates a bus mouse (i.e. the
+type field has value
+.ZN MTYPE_BUSMOUSE
+as defined in
+.ZN xf86misc.h ),
+then the value in the
+.ZN baudrate
+field should be ignored as it does not apply to bus mice.
+.PP
+The
+.ZN samplerate
+field contains the resolution in lines per inch when
+using the Hitachi tablet protocol.
+.PP
+The device field of the structure points to dynamically
+allocated storage which should be freed by the caller.
+.PP
+Any of the fields of the structure can be altered and then passed
+to the
+.ZN XF86MiscSetMouseSettings
+function to change their value in the server,
+with the following restrictions:
+.RS 5
+.IP 1) 3
+The device can not be changed
+.IP 2) 3
+The protocol can not be changed to or from Xqueue or OsMouse
+.IP 3) 3
+The buttons field can not be changed
+.IP 4) 3
+Invalid combinations of parameters are not allowed
+.RE
+.PP
+The server will generate an error if any of the above is attempted,
+except the first \- the contents of the device field are simply ignored.
+.PP
+A change of the protocol causes the device to be closed and reopened.
+Changes to the baud rate, sample rate, resolution or flags,
+when applicable to the
+selected protocol, also cause a reopen of the device.
+A reopen can be forced by using the MF_REOPEN flag, except in the
+case of the OsMouse and Xqueue protocols which ignore all attempts
+to reopen the device.
+.SS "KEYBOARD FUNCTIONS"
+The
+.ZN XF86MiscGetKbdSettings
+function allows you to retrieve the current keyboard-related
+settings from the server.
+.PP
+Using the
+.ZN XF86MiscSetKbdSettings
+function, the keyboard autorepeat delay and rate can be set.
+Requests to change the
+.ZN type
+and
+.ZN servnumlock
+fields are ignored (except for checking for an invalid keyboard type).
+This is expected to change in a future release.
+.SS "OTHER FUNCTIONS"
+Two functions,
+.ZN XF86MiscQueryExtension
+and
+.ZN XF86MiscQueryVersion ,
+are provided which allow the client to query some information
+regarding the extension itself.
+.SH PREDEFINED VALUES
+The header file
+.ZN X11/extensions/xf86misc.h
+contains definitions for
+.IP \fBMTYPE_\fP* 1i
+Mouse protocols
+.IP \fBKTYPE_\fP* 1i
+Keyboard types
+.IP \fBMF_\fP* 1i
+Mouse flags
+.SH "SEE ALSO"
+xset(__appmansuffix__), __xconfigfile__(__filemansuffix__)
+.SH AUTHORS
+Joe Moss and David Dawes, The XFree86 Project, Inc.
+
diff --git a/nx-X11/lib/Xxf86misc/Xxf86misc-def.cpp b/nx-X11/lib/Xxf86misc/Xxf86misc-def.cpp
new file mode 100644
index 000000000..74b1df8e6
--- /dev/null
+++ b/nx-X11/lib/Xxf86misc/Xxf86misc-def.cpp
@@ -0,0 +1,14 @@
+LIBRARY XXF86MISC
+EXPORTS
+ XF86MiscQueryExtension
+ XF86MiscQueryVersion
+ XF86MiscSetKbdSettings
+ XF86MiscGetKbdSettings
+ XF86MiscSetMouseSettings
+ XF86MiscGetMouseSettings
+ XF86MiscGetFilePaths
+; XF86MiscSetSaver
+; XF86MiscGetSaver
+
+
+/* $XFree86: xc/lib/Xxf86misc/Xxf86misc-def.cpp,v 1.1 2000/08/09 23:40:14 dawes Exp $ */
diff --git a/nx-X11/lib/Xxf86rush/Imakefile b/nx-X11/lib/Xxf86rush/Imakefile
new file mode 100644
index 000000000..40eb1dd52
--- /dev/null
+++ b/nx-X11/lib/Xxf86rush/Imakefile
@@ -0,0 +1,30 @@
+XCOMM $XFree86: xc/lib/Xxf86rush/Imakefile,v 1.1 1999/09/04 09:14:09 dawes Exp $
+#define DoNormalLib NormalLibXxf86rush
+#define DoSharedLib SharedLibXxf86rush
+#define DoDebugLib DebugLibXxf86rush
+#define DoProfileLib ProfileLibXxf86rush
+#define LibName Xxf86rush
+#define SoRev SOXXF86RUSHREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXxf86rushReqs
+REQUIREDLIBS = SharedXxf86rushReqs
+#endif
+
+XF86RUSHSRCS = XF86Rush.c
+XF86RUSHOBJS = XF86Rush.o
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ SRCS = $(XF86RUSHSRCS)
+ OBJS = $(XF86RUSHOBJS)
+ LINTLIBS = $(LINTXLIB)
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/Xxf86rush/XF86Rush.c b/nx-X11/lib/Xxf86rush/XF86Rush.c
new file mode 100644
index 000000000..df3a71de1
--- /dev/null
+++ b/nx-X11/lib/Xxf86rush/XF86Rush.c
@@ -0,0 +1,291 @@
+/* $XFree86: xc/lib/Xxf86rush/XF86Rush.c,v 1.5 2000/09/26 15:56:59 tsi Exp $ */
+/*
+
+Copyright (c) 1998 Daryll Strauss
+
+*/
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/xf86rushstr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+static XExtensionInfo _xf86rush_info_data;
+static XExtensionInfo *xf86rush_info = &_xf86rush_info_data;
+static char *xf86rush_extension_name = XF86RUSHNAME;
+
+#define XF86RushCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xf86rush_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display();
+static /* const */ XExtensionHooks xf86rush_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86rush_info,
+ xf86rush_extension_name,
+ &xf86rush_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86rush_info)
+
+
+/*****************************************************************************
+ * *
+ * public XFree86-DGA Extension routines *
+ * *
+ *****************************************************************************/
+
+Bool XF86RushQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+Bool XF86RushQueryVersion(Display *dpy, int *majorVersion, int *minorVersion)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86RushQueryVersionReply rep;
+ xXF86RushQueryVersionReq *req;
+
+ XF86RushCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86RushQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->rushReqType = X_XF86RushQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XF86RushLockPixmap(Display *dpy, int screen, Pixmap pixmap, void **addr)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86RushLockPixmapReply rep;
+ xXF86RushLockPixmapReq *req;
+
+ XF86RushCheckExtension (dpy, info, False);
+ LockDisplay(dpy);
+ GetReq(XF86RushLockPixmap, req);
+ req->reqType = info->codes->major_opcode;
+ req->rushReqType = X_XF86RushLockPixmap;
+ req->screen = screen;
+ req->pixmap = pixmap;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ if (addr)
+ *addr = (void *)(long)rep.addr;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XF86RushUnlockPixmap(Display *dpy, int screen, Pixmap pixmap)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86RushUnlockPixmapReq *req;
+
+ XF86RushCheckExtension (dpy, info, False);
+ LockDisplay(dpy);
+ GetReq(XF86RushUnlockPixmap, req);
+ req->reqType = info->codes->major_opcode;
+ req->rushReqType = X_XF86RushUnlockPixmap;
+ req->screen=screen;
+ req->pixmap=pixmap;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XF86RushUnlockAllPixmaps(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86RushUnlockAllPixmapsReq *req;
+
+ XF86RushCheckExtension (dpy, info, False);
+ LockDisplay(dpy);
+ GetReq(XF86RushUnlockAllPixmaps, req);
+ req->reqType = info->codes->major_opcode;
+ req->rushReqType = X_XF86RushUnlockAllPixmaps;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XF86RushSetCopyMode(Display *dpy, int screen, int mode)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86RushSetCopyModeReq *req;
+
+ XF86RushCheckExtension (dpy, info, False);
+ LockDisplay(dpy);
+ GetReq(XF86RushSetCopyMode, req);
+ req->reqType = info->codes->major_opcode;
+ req->rushReqType = X_XF86RushSetCopyMode;
+ req->screen = screen;
+ req->CopyMode = mode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XF86RushSetPixelStride(Display *dpy, int screen, int stride)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86RushSetPixelStrideReq *req;
+
+ XF86RushCheckExtension (dpy, info, False);
+ LockDisplay(dpy);
+ GetReq(XF86RushSetPixelStride, req);
+ req->reqType = info->codes->major_opcode;
+ req->rushReqType = X_XF86RushSetPixelStride;
+ req->screen = screen;
+ req->PixelStride = stride;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+int XF86RushOverlayPixmap (Display *dpy, XvPortID port, Drawable d,
+ GC gc, Pixmap pixmap, int src_x, int src_y,
+ unsigned int src_w, unsigned int src_h,
+ int dest_x, int dest_y,
+ unsigned int dest_w, unsigned int dest_h,
+ unsigned int id)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86RushOverlayPixmapReq *req;
+
+ XF86RushCheckExtension (dpy, info, False);
+
+ FlushGC(dpy, gc);
+
+ LockDisplay(dpy);
+ GetReq(XF86RushOverlayPixmap, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->rushReqType = X_XF86RushOverlayPixmap;
+ req->port = port;
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->id = id;
+ req->pixmap = pixmap;
+ req->src_x = src_x;
+ req->src_y = src_y;
+ req->src_w = src_w;
+ req->src_h = src_h;
+ req->drw_x = dest_x;
+ req->drw_y = dest_y;
+ req->drw_w = dest_w;
+ req->drw_h = dest_h;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return Success;
+}
+
+int XF86RushStatusRegOffset (Display *dpy, int screen)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86RushStatusRegOffsetReq *req;
+ xXF86RushStatusRegOffsetReply rep;
+
+ XF86RushCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86RushStatusRegOffset, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->rushReqType = X_XF86RushStatusRegOffset;
+ req->screen = screen;
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.offset;
+}
+
+Bool XF86RushAT3DEnableRegs (Display *dpy, int screen)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86RushAT3DEnableRegsReq *req;
+
+ XF86RushCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86RushAT3DEnableRegs, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->rushReqType = X_XF86RushAT3DEnableRegs;
+ req->screen = screen;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ /*
+ * The request has to be processed to stay in sync...
+ */
+ XSync(dpy, False);
+ return Success;
+}
+
+Bool XF86RushAT3DDisableRegs (Display *dpy, int screen)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86RushAT3DDisableRegsReq *req;
+
+ XF86RushCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86RushAT3DDisableRegs, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->rushReqType = X_XF86RushAT3DDisableRegs;
+ req->screen = screen;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return Success;
+}
diff --git a/nx-X11/lib/Xxf86vm/Imakefile b/nx-X11/lib/Xxf86vm/Imakefile
new file mode 100644
index 000000000..84a29eb1d
--- /dev/null
+++ b/nx-X11/lib/Xxf86vm/Imakefile
@@ -0,0 +1,40 @@
+XCOMM $XFree86: xc/lib/Xxf86vm/Imakefile,v 3.3 2002/10/16 00:37:34 dawes Exp $
+XCOMM $XdotOrg: xc/lib/Xxf86vm/Imakefile,v 1.3 2005/05/14 18:35:56 alanc Exp $
+
+#define DoNormalLib NormalLibXxf86vm
+#define DoSharedLib SharedLibXxf86vm
+#define DoExtraLib SharedLibXxf86vm
+#define DoDebugLib DebugLibXxf86vm
+#define DoProfileLib ProfileLibXxf86vm
+#define LibName Xxf86vm
+#define SoRev SOXXF86VMREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#ifdef SharedXxf86vmReqs
+REQUIREDLIBS = SharedXxf86vmReqs
+#endif
+
+VIDMODESRCS = XF86VMode.c
+VIDMODEOBJS = XF86VMode.o
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ SRCS = $(VIDMODESRCS)
+ OBJS = $(VIDMODEOBJS)
+ LINTLIBS = $(LINTXLIB)
+
+#define IncludeSharedObjectInNormalLib
+
+#include <Library.tmpl>
+
+InstallGenManPageLong(XF86VM,$(LIBMANDIR),XF86VidMode,$(LIBMANSUFFIX))
+#if ExpandManNames
+InstallGenManPageAliases(XF86VidMode,$(LIBMANDIR),$(LIBMANSUFFIX),XF86VidModeQueryExtension XF86VidModeQueryVersion XF86VidModeGetModeLine XF86VidModeGetAllModeLines XF86VidModeDeleteModeLine XF86VidModeModModeLine XF86VidModeSwitchMode XF86VidModeSwitchToMode XF86VidModeLockModeSwitch XF86VidModeGetMonitor XF86VidModeGetViewPort XF86VidModeSetViewPort XF86VidModeValidateModeLine XF86VidModeSetClientVersion XF86VidModeGetDotClocks XF86VidModeGetGamma XF86VidModeSetGamma XF86VidModeSetGammaRamp XF86VidModeGetGammaRamp XF86VidModeGetGammaRampSize XF86VidModeGetPermissions)
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/Xxf86vm/XF86VM.man b/nx-X11/lib/Xxf86vm/XF86VM.man
new file mode 100644
index 000000000..6e53ad158
--- /dev/null
+++ b/nx-X11/lib/Xxf86vm/XF86VM.man
@@ -0,0 +1,425 @@
+.\" $XdotOrg: xc/lib/Xxf86vm/XF86VM.man,v 1.2 2004/04/23 19:23:08 eich Exp $
+.\" $TOG: XF86VM.man /main/6 1997/07/19 10:30:39 kaleb $
+.\"
+.\"
+.\"
+.\"
+.\" Copyright (c) 1996 Joe Moss, The XFree86 Project
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/doc/man/XF86VM.man,v 3.14 2003/10/02 13:29:56 eich Exp $
+.\"
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.TH XF86VIDMODE __libmansuffix__ __vendorversion__
+.SH NAME
+XF86VidModeQueryExtension, XF86VidModeQueryVersion, XF86VidModeSetClientVersion, XF86VidModeGetModeLine, XF86VidModeGetAllModeLines, XF86VidModeDeleteModeLine, XF86VidModeModModeLine, XF86VidModeValidateModeLine, XF86VidModeSwitchMode, XF86VidModeSwitchToMode, XF86VidModeLockModeSwitch, XF86VidModeGetMonitor, XF86VidModeGetViewPort, XF86VidModeSetViewPort, XF86VidModeGetDotClocks, XF86VidModeGetGamma, XF86VidModeSetGamma, XF86VidModeGetGammaRamp, XF86VidModeSetGammaRamp, XF86VidModeGetGammaRampSize, XF86VidModeGetPermissions \- Extension libary for the XFree86-VidMode X extension
+.SH SYNTAX
+.nf
+.LP
+\&#include <X11/extensions/xf86vmode.h>
+.LP
+Bool XF86VidModeQueryExtension(
+ Display *\fIdisplay\fP\^,
+ int *\fIevent_base_return\fP\^,
+ int *\fIerror_base_return\fP\^);
+.LP
+Bool XF86VidModeQueryVersion(
+ Display *\fIdisplay\fP\^,
+ int *\fImajor_version_return\fP\^,
+ int *\fIminor_version_return\fP\^);
+.LP
+Bool XF86VidModeSetClientVersion(
+ Display *\fIdisplay\fP\^);
+.LP
+Bool XF86VidModeGetModeLine(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ int *\fIdotclock_return\fP\^,
+ XF86VidModeModeLine *\fImodeline\fP\^);
+.LP
+Bool XF86VidModeGetAllModeLines(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ int *\fImodecount_return\fP\^,
+ XF86VidModeModeInfo ***\fImodesinfo\fP\^);
+.ig
+.LP
+Bool XF86VidModeAddModeLine(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ XF86VidModeModeInfo *\fImodeline\fP\,
+ XF86VidModeModeInfo *\fIaftermode\fP\^);
+..
+.LP
+Bool XF86VidModeDeleteModeLine(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ XF86VidModeModeInfo *\fImodeline\fP\^);
+.LP
+Bool XF86VidModeModModeLine(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ XF86VidModeModeLine *\fImodeline\fP\^);
+.LP
+Status XF86VidModeValidateModeLine(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ XF86VidModeModeLine *\fImodeline\fP\^);
+.LP
+Bool XF86VidModeSwitchMode(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ int \fIzoom\fP\^);
+.LP
+Bool XF86VidModeSwitchToMode(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ XF86VidModeModeInfo *\fImodeline\fP\^);
+.LP
+Bool XF86VidModeLockModeSwitch(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ int \fIlock\fP\^);
+.LP
+Bool XF86VidModeGetMonitor(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ XF86VidModeMonitor *\fImonitor\fP\^);
+.LP
+Bool XF86VidModeGetViewPort(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ int *\fIx_return\fP\^,
+ int *\fIy_return\fP\^);
+.LP
+Bool XF86VidModeSetViewPort(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ int \fIx\fP\^,
+ int \fIy\fP\^);
+.LP
+XF86VidModeGetDotClocks(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ int *\fIflags return\fP\^,
+ int *\fInumber of clocks return\fP\^,
+ int *\fImax dot clock return\fP\^,
+ int **\fIclocks return\fP\^);
+.LP
+XF86VidModeGetGamma(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ XF86VidModeGamma *\fIGamma\fP\^);
+.LP
+XF86VidModeSetGamma(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ XF86VidModeGamma *\fIGamma\fP\^);
+.LP
+XF86VidModeGetGammaRamp(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ int \fIsize\fP\^,
+ unsigned short *\fIred array\fP\^,
+ unsigned short *\fIgreen array\fP\^,
+ unsigned short *\fIblue array\fP\^);
+.LP
+XF86VidModeSetGammaRamp(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ int \fIsize\fP\^,
+ unsigned short *\fIred array\fP\^,
+ unsigned short *\fIgreen array\fP\^,
+ unsigned short *\fIblue array\fP\^);
+.LP
+XF86VidModeGetGammaRampSize(
+ Display *\fIdisplay\fP\^,
+ int \fIscreen\fP\^,
+ int *\fIsize\fP\^);
+.fi
+.SH ARGUMENTS
+.IP \fIdisplay\fP 2i
+Specifies the connection to the X server.
+.IP \fIscreen\fP 2i
+Specifies which screen number the setting apply to.
+.IP \fIevent_base_return\fP 2i
+Returns the base event number for the extension.
+.IP \fIerror_base_return\fP 2i
+Returns the base error number for the extension.
+.IP \fImajor_version_return\fP 2i
+Returns the major version number of the extension.
+.IP \fIminor_version_return\fP 2i
+Returns the minor version number of the extension.
+.IP \fIdotclock_return\fP 2i
+Returns the clock for the mode line.
+.IP \fImodecount_return\fP 2i
+Returns the number of video modes available in the server.
+.IP \fIzoom\fP 2i
+If greater than zero, indicates that the server should switch to
+the next mode, otherwise switch to the previous mode.
+.IP \fIlock\fP 2i
+Indicates that mode switching should be locked, if non-zero.
+.IP \fImodeline\fP 2i
+Specifies or returns the timing values for a video mode.
+.ig
+.IP \fIaftermode\fP 2i
+Specifies the timing values for the video mode after which the
+new mode will added.
+..
+.IP \fImodesinfo\fP 2i
+Returns the timing values and dotclocks for all of the available
+video modes.
+.IP \fImonitor\fP 2i
+Returns information about the monitor.
+.IP \fIx\fP 2i
+Specifies the desired X location for the viewport.
+.IP \fIx_return\fP 2i
+Returns the current X location of the viewport.
+.IP \fIy\fP 2i
+Specifies the desired Y location for the viewport.
+.IP \fIy_return\fP 2i
+Returns the current Y location of the viewport.
+.SH STRUCTURES
+.nf
+.ta 2.25i 3.5i
+\fIVideo Mode Settings:\fP
+typedef struct {
+ unsigned short hdisplay; /\(** Number of display pixels horizontally */
+ unsigned short hsyncstart; /\(** Horizontal sync start */
+ unsigned short hsyncend; /\(** Horizontal sync end */
+ unsigned short htotal; /\(** Total horizontal pixels */
+ unsigned short vdisplay; /\(** Number of display pixels vertically */
+ unsigned short vsyncstart; /\(** Vertical sync start */
+ unsigned short vsyncend; /\(** Vertical sync start */
+ unsigned short vtotal; /\(** Total vertical pixels */
+ unsigned int flags; /\(** Mode flags */
+ int privsize; /\(** Size of private */
+ INT32 *private; /\(** Server privates */
+} XF86VidModeModeLine;
+.sp
+typedef struct {
+ unsigned int dotclock; /\(** Pixel clock */
+ unsigned short hdisplay; /\(** Number of display pixels horizontally */
+ unsigned short hsyncstart; /\(** Horizontal sync start */
+ unsigned short hsyncend; /\(** Horizontal sync end */
+ unsigned short htotal; /\(** Total horizontal pixels */
+ unsigned short vdisplay; /\(** Number of display pixels vertically */
+ unsigned short vsyncstart; /\(** Vertical sync start */
+ unsigned short vsyncend; /\(** Vertical sync start */
+ unsigned short vtotal; /\(** Total vertical pixels */
+ unsigned int flags; /\(** Mode flags */
+ int privsize; /\(** Size of private */
+ INT32 *private; /\(** Server privates */
+} XF86VidModeModeInfo;
+.LP
+\fIMonitor information:\fP
+typedef struct {
+ char* vendor; /\(** Name of manufacturer */
+ char* model; /\(** Model name */
+ float EMPTY; /\(** unused, for backward compatibility */
+ unsigned char nhsync; /\(** Number of horiz sync ranges */
+ XF86VidModeSyncRange* hsync; /\(** Horizontal sync ranges */
+ unsigned char nvsync; /\(** Number of vert sync ranges */
+ XF86VidModeSyncRange* vsync; /\(** Vertical sync ranges */
+} XF86VidModeMonitor;
+.sp
+typedef struct {
+ float hi; /\(** Top of range */
+ float lo; /\(** Bottom of range */
+} XF86VidModeSyncRange;
+.LP
+typedef struct {
+ int type; /\(** of event */
+ unsigned long serial; /\(** # of last request processed by server */
+ Bool send_event; /\(** true if this came from a SendEvent req */
+ Display *display; /\(** Display the event was read from */
+ Window root; /\(** root window of event screen */
+ int state; /\(** What happened */
+ int kind; /\(** What happened */
+ Bool forced; /\(** extents of new region */
+ Time time; /\(** event timestamp */
+} XF86VidModeNotifyEvent;
+.LP
+typedef struct {
+ float red; /\(** Red Gamma value */
+ float green; /\(** Green Gamma value */
+ float blue; /\(** Blue Gamma value */
+} XF86VidModeGamma;
+.fi
+.SH DESCRIPTION
+These functions provide an interface to the server extension
+\fIXFree86-VidModeExtension\fP
+which allows the video modes to be
+queried and adjusted dynamically and mode switching to be controlled.
+Applications that use these functions must be linked with
+.ZN -lXxf86vm
+.SS "MODELINE FUNCTIONS"
+The
+.ZN XF86VidModeGetModeLine
+function is used to query the settings for the currently selected
+video mode. The calling program should pass a pointer to a
+.ZN XF86VidModeModeLine
+structure that it has already allocated. The function fills in
+the fields of the structure.
+.PP
+If there are any server private values (currently only applicable to
+the S3 server) the function will allocate storage for them.
+Therefore, if the
+.ZN privsize
+field is non-zero, the calling program should call
+.ZN Xfree(private)
+to free the storage.
+.PP
+.ZN XF86VidModeGetAllModeLines
+returns the settings for all video modes.
+The calling program supplies the address of a pointer which will be
+set by the function to point to an array of
+.ZN XF86VidModeModeInfo
+structures. The memory occupied by the array is dynamically allocated
+by the
+.ZN XF86VidModeGetAllModeLines
+function and should be freed by the caller.
+The first element of the array corresponds to the current video mode.
+.PP
+The
+.ZN XF86VidModeModModeLine
+function can be used to change the settings of the current video mode
+provided the requested settings are valid (e.g. they don't exceed the
+capabilities of the monitor).
+.PP
+.ig
+To add a mode to the list of available modes, the
+.ZN XF86VidModeAddModeLine
+function can be used.
+Assuming the settings are valid, the video mode will be added after
+the existing mode which matches the timings specified by the
+.ZN aftermode
+parameter.
+To be considered a match, all of the fields of the given
+.ZN XF86VidModeModeInfo
+structure must match, except the
+.ZN privsize
+and
+.ZN private
+fields.
+If the
+.ZN aftermode
+parameter is zero, the mode will be added
+after the current mode.
+.PP
+..
+Modes can be deleted with the
+.ZN XF86VidModeDeleteModeLine
+function. The specified mode must match an existing mode.
+To be considered a match, all of the fields of the given
+.ZN XF86VidModeModeInfo
+structure must match, except the
+.ZN privsize
+and
+.ZN private
+fields.
+If the mode to be deleted is the current mode, a mode switch
+to the next mode will occur first. The last remaining mode can not
+be deleted.
+.PP
+The validity of a mode can be checked with the
+.ZN XF86VidModeValidateModeLine
+function.
+If the specified mode can be used by the server (i.e. meets all the
+constraints placed upon a mode by the combination of the server, card,
+and monitor) the function returns
+.ZN MODE_OK ,
+otherwise it returns a value indicating the reason why the mode is
+invalid (as defined in \fIxf86.h\fP)
+.SS "MODE SWITCH FUNCTIONS"
+When the function
+.ZN XF86VidModeSwitchMode
+is called, the server will change the video mode to next (or previous)
+video mode. The
+.ZN XF86VidModeSwitchToMode
+function can be used to switch directly to the specified mode.
+Matching is as specified in the description of the
+.ZN XF86VidModeAddModeLine
+function above.
+The
+.ZN XF86VidModeLockModeSwitch
+function can be used to allow or disallow mode switching whether
+the request to switch modes comes from a call to the
+.ZN XF86VidModeSwitchMode
+or
+.ZN XF86VidModeSwitchToMode
+functions or from one of the mode switch key sequences.
+.PP
+.RB Note:
+Because of the asynchronous nature of the X protocol, a call to
+.ZN XFlush
+is needed if the application wants to see the mode change immediately.
+To be informed of the execution status of the request, a
+custom error handler should be installed using
+.ZN XSetErrorHandler
+before calling the mode switching function.
+.SS "MONITOR FUNCTIONS"
+Information known to the server about the monitor is returned by the
+.ZN XF86VidModeGetMonitor
+function. The
+.ZN hsync
+and
+.ZN vsync
+fields each point to an array of
+.ZN XF86VidModeSyncRange
+structures. The arrays contain
+.ZN nhsync
+and
+.ZN nvsync
+elements, respectively.
+The
+.ZN hi
+and
+.ZN low
+values will be equal if a discreate value was given in the
+.ZN XF86Config
+file.
+.PP
+The
+.ZN vendor ,
+.ZN model ,
+.ZN hsync ,
+and
+.ZN vsync
+fields point to dynamically allocated storage that should be freed
+by the caller.
+.SS "VIEWPORT FUNCTIONS"
+The
+.ZN XF86VidModeGetViewPort
+and
+.ZN XF86VidModeSetViewPort
+functions can be used to, respectively, query and change the location
+of the upper left corner of the viewport into the virtual screen.
+.SS "OTHER FUNCTIONS"
+The
+.ZN XF86VidModeQueryVersion
+function can be used to determine the version of the extension
+built into the server.
+.PP
+The function
+.ZN XF86VidModeQueryExtension
+returns the lowest numbered error and event values
+assigned to the extension.
+.SH BUGS
+The
+XF86VidModeSetClientVersion,
+XF86VidModeGetDotClocks,
+XF86VidModeGetGamma,
+XF86VidModeSetGamma,
+XF86VidModeSetGammaRamp,
+XF86VidModeGetGammaRamp,
+XF86VidModeGetGammaRampSize,
+and
+XF86VidModeGetPermissions
+functions need to be documented. In the meantime, check the source
+code for information about how to use them.
+.SH SEE ALSO
+__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), XFlush(__libmansuffix__), XSetErrorHandler(__libmansuffix__), xvidtune(__appmansuffix__)
+.SH AUTHORS
+Kaleb Keithley, Jon Tombs, David Dawes, and Joe Moss
diff --git a/nx-X11/lib/Xxf86vm/XF86VMode.c b/nx-X11/lib/Xxf86vm/XF86VMode.c
new file mode 100644
index 000000000..75a49d2ba
--- /dev/null
+++ b/nx-X11/lib/Xxf86vm/XF86VMode.c
@@ -0,0 +1,1233 @@
+/* $XConsortium: XF86VMode.c /main/2 1995/11/14 18:17:58 kaleb $ */
+/* $XFree86: xc/lib/Xxf86vm/XF86VMode.c,v 3.33 2002/10/16 00:37:34 dawes Exp $ */
+/*
+
+Copyright (c) 1995 Kaleb S. KEITHLEY
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+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 Kaleb S. KEITHLEY 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 Kaleb S. KEITHLEY
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+from Kaleb S. KEITHLEY.
+
+*/
+/* $XConsortium: XF86VMode.c /main/4 1996/01/16 07:52:25 kaleb CHECKEDOUT $ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/xf86vmstr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
+#ifndef MODE_BAD
+#define MODE_BAD 255
+#endif
+
+static XExtensionInfo _xf86vidmode_info_data;
+static XExtensionInfo *xf86vidmode_info = &_xf86vidmode_info_data;
+static char *xf86vidmode_extension_name = XF86VIDMODENAME;
+
+#define XF86VidModeCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xf86vidmode_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static XEXT_CLOSE_DISPLAY_PROTO(close_display);
+static /* const */ XExtensionHooks xf86vidmode_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86vidmode_info,
+ xf86vidmode_extension_name,
+ &xf86vidmode_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86vidmode_info)
+
+
+/*****************************************************************************
+ * *
+ * public XFree86-VidMode Extension routines *
+ * *
+ *****************************************************************************/
+
+Bool
+XF86VidModeQueryExtension (dpy, event_basep, error_basep)
+ Display *dpy;
+ int *event_basep, *error_basep;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+Bool
+XF86VidModeQueryVersion(dpy, majorVersion, minorVersion)
+ Display* dpy;
+ int* majorVersion;
+ int* minorVersion;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeQueryVersionReply rep;
+ xXF86VidModeQueryVersionReq *req;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (*majorVersion >= 2)
+ XF86VidModeSetClientVersion(dpy);
+ return True;
+}
+
+Bool
+XF86VidModeSetClientVersion(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86VidModeSetClientVersionReq *req;
+
+ XF86VidModeCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeSetClientVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeSetClientVersion;
+ req->major = XF86VIDMODE_MAJOR_VERSION;
+ req->minor = XF86VIDMODE_MINOR_VERSION;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XF86VidModeSetGamma(Display *dpy, int screen, XF86VidModeGamma *Gamma)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86VidModeSetGammaReq *req;
+
+ XF86VidModeCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeSetGamma, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeSetGamma;
+ req->screen = screen;
+ req->red = (CARD32)(Gamma->red * 10000.);
+ req->green = (CARD32)(Gamma->green * 10000.);
+ req->blue = (CARD32)(Gamma->blue * 10000.);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XF86VidModeGetGamma(Display *dpy, int screen, XF86VidModeGamma *Gamma)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeGetGammaReply rep;
+ xXF86VidModeGetGammaReq *req;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeGetGamma, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeGetGamma;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ Gamma->red = ((float)rep.red) / 10000.;
+ Gamma->green = ((float)rep.green) / 10000.;
+ Gamma->blue = ((float)rep.blue) / 10000.;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XF86VidModeGetModeLine(dpy, screen, dotclock, modeline)
+ Display* dpy;
+ int screen;
+ int* dotclock;
+ XF86VidModeModeLine* modeline;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeGetModeLineReply rep;
+ xXF86OldVidModeGetModeLineReply oldrep;
+ xXF86VidModeGetModeLineReq *req;
+ int majorVersion, minorVersion;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+ XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion);
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeGetModeLine, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeGetModeLine;
+ req->screen = screen;
+
+ if (majorVersion < 2) {
+ if (!_XReply(dpy, (xReply *)&oldrep,
+ (SIZEOF(xXF86OldVidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *dotclock = oldrep.dotclock;
+ modeline->hdisplay = oldrep.hdisplay;
+ modeline->hsyncstart = oldrep.hsyncstart;
+ modeline->hsyncend = oldrep.hsyncend;
+ modeline->htotal = oldrep.htotal;
+ modeline->hskew = 0;
+ modeline->vdisplay = oldrep.vdisplay;
+ modeline->vsyncstart = oldrep.vsyncstart;
+ modeline->vsyncend = oldrep.vsyncend;
+ modeline->vtotal = oldrep.vtotal;
+ modeline->flags = oldrep.flags;
+ modeline->privsize = oldrep.privsize;
+ } else {
+ if (!_XReply(dpy, (xReply *)&rep,
+ (SIZEOF(xXF86VidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *dotclock = rep.dotclock;
+ modeline->hdisplay = rep.hdisplay;
+ modeline->hsyncstart = rep.hsyncstart;
+ modeline->hsyncend = rep.hsyncend;
+ modeline->htotal = rep.htotal;
+ modeline->hskew = rep.hskew;
+ modeline->vdisplay = rep.vdisplay;
+ modeline->vsyncstart = rep.vsyncstart;
+ modeline->vsyncend = rep.vsyncend;
+ modeline->vtotal = rep.vtotal;
+ modeline->flags = rep.flags;
+ modeline->privsize = rep.privsize;
+ }
+
+ if (modeline->privsize > 0) {
+ if (!(modeline->private = Xcalloc(modeline->privsize, sizeof(INT32)))) {
+ _XEatData(dpy, (modeline->privsize) * sizeof(INT32));
+ Xfree(modeline->private);
+ return False;
+ }
+ _XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32));
+ } else {
+ modeline->private = NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XF86VidModeGetAllModeLines(dpy, screen, modecount, modelinesPtr)
+ Display* dpy;
+ int screen;
+ int* modecount;
+ XF86VidModeModeInfo ***modelinesPtr;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeGetAllModeLinesReply rep;
+ xXF86VidModeGetAllModeLinesReq *req;
+ XF86VidModeModeInfo *mdinfptr, **modelines;
+ xXF86VidModeModeInfo xmdline;
+ xXF86OldVidModeModeInfo oldxmdline;
+ int i;
+ int majorVersion, minorVersion;
+ Bool protocolBug = False;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+
+ /*
+ * Note: There was a bug in the protocol implementation in versions
+ * 0.x with x < 8 (the .private field wasn't being passed over the wire).
+ * Check the server's version, and accept the old format if appropriate.
+ */
+
+ XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion);
+ if (majorVersion == 0 && minorVersion < 8) {
+ protocolBug = True;
+#ifdef DEBUG
+ fprintf(stderr, "XF86VidModeGetAllModeLines: Warning: Xserver is"
+ "running an old version (%d.%d)\n", majorVersion,
+ minorVersion);
+#endif
+ }
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeGetAllModeLines, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeGetAllModeLines;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep,
+ (SIZEOF(xXF86VidModeGetAllModeLinesReply) - SIZEOF(xReply)) >> 2, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ *modecount = rep.modecount;
+
+ if (!(modelines = (XF86VidModeModeInfo **) Xcalloc(rep.modecount,
+ sizeof(XF86VidModeModeInfo *)
+ +sizeof(XF86VidModeModeInfo)))) {
+ if (majorVersion < 2)
+ _XEatData(dpy, (rep.modecount) * sizeof(xXF86OldVidModeModeInfo));
+ else
+ _XEatData(dpy, (rep.modecount) * sizeof(xXF86VidModeModeInfo));
+ Xfree(modelines);
+ return False;
+ }
+ mdinfptr = (XF86VidModeModeInfo *) (
+ (char *) modelines
+ + rep.modecount*sizeof(XF86VidModeModeInfo *)
+ );
+
+ for (i = 0; i < rep.modecount; i++) {
+ modelines[i] = mdinfptr++;
+ if (majorVersion < 2) {
+ _XRead(dpy, (char*)&oldxmdline, sizeof(xXF86OldVidModeModeInfo));
+ modelines[i]->dotclock = oldxmdline.dotclock;
+ modelines[i]->hdisplay = oldxmdline.hdisplay;
+ modelines[i]->hsyncstart = oldxmdline.hsyncstart;
+ modelines[i]->hsyncend = oldxmdline.hsyncend;
+ modelines[i]->htotal = oldxmdline.htotal;
+ modelines[i]->hskew = 0;
+ modelines[i]->vdisplay = oldxmdline.vdisplay;
+ modelines[i]->vsyncstart = oldxmdline.vsyncstart;
+ modelines[i]->vsyncend = oldxmdline.vsyncend;
+ modelines[i]->vtotal = oldxmdline.vtotal;
+ modelines[i]->flags = oldxmdline.flags;
+ if (protocolBug) {
+ modelines[i]->privsize = 0;
+ modelines[i]->private = NULL;
+ } else {
+ modelines[i]->privsize = oldxmdline.privsize;
+ if (oldxmdline.privsize > 0) {
+ if (!(modelines[i]->private =
+ Xcalloc(oldxmdline.privsize, sizeof(INT32)))) {
+ _XEatData(dpy, (oldxmdline.privsize) * sizeof(INT32));
+ Xfree(modelines[i]->private);
+ } else {
+ _XRead(dpy, (char*)modelines[i]->private,
+ oldxmdline.privsize * sizeof(INT32));
+ }
+ } else {
+ modelines[i]->private = NULL;
+ }
+ }
+ } else {
+ _XRead(dpy, (char*)&xmdline, sizeof(xXF86VidModeModeInfo));
+ modelines[i]->dotclock = xmdline.dotclock;
+ modelines[i]->hdisplay = xmdline.hdisplay;
+ modelines[i]->hsyncstart = xmdline.hsyncstart;
+ modelines[i]->hsyncend = xmdline.hsyncend;
+ modelines[i]->htotal = xmdline.htotal;
+ modelines[i]->hskew = xmdline.hskew;
+ modelines[i]->vdisplay = xmdline.vdisplay;
+ modelines[i]->vsyncstart = xmdline.vsyncstart;
+ modelines[i]->vsyncend = xmdline.vsyncend;
+ modelines[i]->vtotal = xmdline.vtotal;
+ modelines[i]->flags = xmdline.flags;
+ if (protocolBug) {
+ modelines[i]->privsize = 0;
+ modelines[i]->private = NULL;
+ } else {
+ modelines[i]->privsize = xmdline.privsize;
+ if (xmdline.privsize > 0) {
+ if (!(modelines[i]->private =
+ Xcalloc(xmdline.privsize, sizeof(INT32)))) {
+ _XEatData(dpy, (xmdline.privsize) * sizeof(INT32));
+ Xfree(modelines[i]->private);
+ } else {
+ _XRead(dpy, (char*)modelines[i]->private,
+ xmdline.privsize * sizeof(INT32));
+ }
+ } else {
+ modelines[i]->private = NULL;
+ }
+ }
+ }
+ }
+ *modelinesPtr = modelines;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/*
+ * GetReq replacement for use with VidMode protocols earlier than 2.0
+ */
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetOldReq(name, oldname, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##oldname##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##oldname##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = (SIZEOF(x##oldname##Req))>>2;\
+ dpy->bufptr += SIZEOF(x##oldname##Req);\
+ dpy->request++
+
+#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
+#define GetOldReq(name, oldname, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/oldname/**/Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/oldname/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = (SIZEOF(x/**/oldname/**/Req))>>2;\
+ dpy->bufptr += SIZEOF(x/**/oldname/**/Req);\
+ dpy->request++
+#endif
+
+Bool
+XF86VidModeAddModeLine (dpy, screen, newmodeline, aftermodeline)
+ Display *dpy;
+ int screen;
+ XF86VidModeModeInfo* newmodeline;
+ XF86VidModeModeInfo* aftermodeline;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeAddModeLineReq *req;
+ xXF86OldVidModeAddModeLineReq *oldreq;
+ int majorVersion, minorVersion;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+ XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion);
+
+ LockDisplay(dpy);
+ if (majorVersion < 2) {
+ GetOldReq(XF86VidModeAddModeLine, XF86OldVidModeAddModeLine, oldreq);
+ oldreq->reqType = info->codes->major_opcode;
+ oldreq->xf86vidmodeReqType = X_XF86VidModeAddModeLine;
+ oldreq->screen = screen;
+ oldreq->dotclock = newmodeline->dotclock;
+ oldreq->hdisplay = newmodeline->hdisplay;
+ oldreq->hsyncstart = newmodeline->hsyncstart;
+ oldreq->hsyncend = newmodeline->hsyncend;
+ oldreq->htotal = newmodeline->htotal;
+ oldreq->vdisplay = newmodeline->vdisplay;
+ oldreq->vsyncstart = newmodeline->vsyncstart;
+ oldreq->vsyncend = newmodeline->vsyncend;
+ oldreq->vtotal = newmodeline->vtotal;
+ oldreq->flags = newmodeline->flags;
+ oldreq->privsize = newmodeline->privsize;
+ if (aftermodeline != NULL) {
+ oldreq->after_dotclock = aftermodeline->dotclock;
+ oldreq->after_hdisplay = aftermodeline->hdisplay;
+ oldreq->after_hsyncstart = aftermodeline->hsyncstart;
+ oldreq->after_hsyncend = aftermodeline->hsyncend;
+ oldreq->after_htotal = aftermodeline->htotal;
+ oldreq->after_vdisplay = aftermodeline->vdisplay;
+ oldreq->after_vsyncstart = aftermodeline->vsyncstart;
+ oldreq->after_vsyncend = aftermodeline->vsyncend;
+ oldreq->after_vtotal = aftermodeline->vtotal;
+ oldreq->after_flags = aftermodeline->flags;
+ } else {
+ oldreq->after_dotclock = 0;
+ oldreq->after_hdisplay = 0;
+ oldreq->after_hsyncstart = 0;
+ oldreq->after_hsyncend = 0;
+ oldreq->after_htotal = 0;
+ oldreq->after_vdisplay = 0;
+ oldreq->after_vsyncstart = 0;
+ oldreq->after_vsyncend = 0;
+ oldreq->after_vtotal = 0;
+ oldreq->after_flags = 0;
+ }
+ if (newmodeline->privsize) {
+ oldreq->length += newmodeline->privsize;
+ Data32(dpy, (long *) newmodeline->private,
+ newmodeline->privsize * sizeof(INT32));
+ }
+ } else {
+ GetReq(XF86VidModeAddModeLine, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeAddModeLine;
+ req->screen = screen;
+ req->dotclock = newmodeline->dotclock;
+ req->hdisplay = newmodeline->hdisplay;
+ req->hsyncstart = newmodeline->hsyncstart;
+ req->hsyncend = newmodeline->hsyncend;
+ req->htotal = newmodeline->htotal;
+ req->hskew = newmodeline->hskew;
+ req->vdisplay = newmodeline->vdisplay;
+ req->vsyncstart = newmodeline->vsyncstart;
+ req->vsyncend = newmodeline->vsyncend;
+ req->vtotal = newmodeline->vtotal;
+ req->flags = newmodeline->flags;
+ req->privsize = newmodeline->privsize;
+ if (aftermodeline != NULL) {
+ req->after_dotclock = aftermodeline->dotclock;
+ req->after_hdisplay = aftermodeline->hdisplay;
+ req->after_hsyncstart = aftermodeline->hsyncstart;
+ req->after_hsyncend = aftermodeline->hsyncend;
+ req->after_htotal = aftermodeline->htotal;
+ req->after_hskew = aftermodeline->hskew;
+ req->after_vdisplay = aftermodeline->vdisplay;
+ req->after_vsyncstart = aftermodeline->vsyncstart;
+ req->after_vsyncend = aftermodeline->vsyncend;
+ req->after_vtotal = aftermodeline->vtotal;
+ req->after_flags = aftermodeline->flags;
+ } else {
+ req->after_dotclock = 0;
+ req->after_hdisplay = 0;
+ req->after_hsyncstart = 0;
+ req->after_hsyncend = 0;
+ req->after_htotal = 0;
+ req->after_hskew = 0;
+ req->after_vdisplay = 0;
+ req->after_vsyncstart = 0;
+ req->after_vsyncend = 0;
+ req->after_vtotal = 0;
+ req->after_flags = 0;
+ }
+ if (newmodeline->privsize) {
+ req->length += newmodeline->privsize;
+ Data32(dpy, (long *) newmodeline->private,
+ newmodeline->privsize * sizeof(INT32));
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XF86VidModeDeleteModeLine (dpy, screen, modeline)
+ Display *dpy;
+ int screen;
+ XF86VidModeModeInfo* modeline;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeDeleteModeLineReq *req;
+ xXF86OldVidModeDeleteModeLineReq *oldreq;
+ int majorVersion, minorVersion;
+
+ XF86VidModeCheckExtension (dpy, info, 0);
+ XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion);
+
+ LockDisplay(dpy);
+ if (majorVersion < 2) {
+ GetOldReq(XF86VidModeDeleteModeLine, XF86OldVidModeDeleteModeLine, oldreq);
+ oldreq->reqType = info->codes->major_opcode;
+ oldreq->xf86vidmodeReqType = X_XF86VidModeDeleteModeLine;
+ oldreq->screen = screen;
+ oldreq->dotclock = modeline->dotclock;
+ oldreq->hdisplay = modeline->hdisplay;
+ oldreq->hsyncstart = modeline->hsyncstart;
+ oldreq->hsyncend = modeline->hsyncend;
+ oldreq->htotal = modeline->htotal;
+ oldreq->vdisplay = modeline->vdisplay;
+ oldreq->vsyncstart = modeline->vsyncstart;
+ oldreq->vsyncend = modeline->vsyncend;
+ oldreq->vtotal = modeline->vtotal;
+ oldreq->flags = modeline->flags;
+ oldreq->privsize = modeline->privsize;
+ if (modeline->privsize) {
+ oldreq->length += modeline->privsize;
+ Data32(dpy, (long *) modeline->private,
+ modeline->privsize * sizeof(INT32));
+ }
+ } else {
+ GetReq(XF86VidModeDeleteModeLine, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeDeleteModeLine;
+ req->screen = screen;
+ req->dotclock = modeline->dotclock;
+ req->hdisplay = modeline->hdisplay;
+ req->hsyncstart = modeline->hsyncstart;
+ req->hsyncend = modeline->hsyncend;
+ req->htotal = modeline->htotal;
+ req->hskew = modeline->hskew;
+ req->vdisplay = modeline->vdisplay;
+ req->vsyncstart = modeline->vsyncstart;
+ req->vsyncend = modeline->vsyncend;
+ req->vtotal = modeline->vtotal;
+ req->flags = modeline->flags;
+ req->privsize = modeline->privsize;
+ if (modeline->privsize) {
+ req->length += modeline->privsize;
+ Data32(dpy, (long *) modeline->private,
+ modeline->privsize * sizeof(INT32));
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XF86VidModeModModeLine (dpy, screen, modeline)
+ Display *dpy;
+ int screen;
+ XF86VidModeModeLine* modeline;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeModModeLineReq *req;
+ xXF86OldVidModeModModeLineReq *oldreq;
+ int majorVersion, minorVersion;
+
+ XF86VidModeCheckExtension (dpy, info, 0);
+ XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion);
+
+ LockDisplay(dpy);
+ if (majorVersion < 2) {
+ GetOldReq(XF86VidModeModModeLine, XF86OldVidModeModModeLine, oldreq);
+ oldreq->reqType = info->codes->major_opcode;
+ oldreq->xf86vidmodeReqType = X_XF86VidModeModModeLine;
+ oldreq->screen = screen;
+ oldreq->hdisplay = modeline->hdisplay;
+ oldreq->hsyncstart = modeline->hsyncstart;
+ oldreq->hsyncend = modeline->hsyncend;
+ oldreq->htotal = modeline->htotal;
+ oldreq->vdisplay = modeline->vdisplay;
+ oldreq->vsyncstart = modeline->vsyncstart;
+ oldreq->vsyncend = modeline->vsyncend;
+ oldreq->vtotal = modeline->vtotal;
+ oldreq->flags = modeline->flags;
+ oldreq->privsize = modeline->privsize;
+ if (modeline->privsize) {
+ oldreq->length += modeline->privsize;
+ Data32(dpy, (long *) modeline->private,
+ modeline->privsize * sizeof(INT32));
+ }
+ } else {
+ GetReq(XF86VidModeModModeLine, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeModModeLine;
+ req->screen = screen;
+ req->hdisplay = modeline->hdisplay;
+ req->hsyncstart = modeline->hsyncstart;
+ req->hsyncend = modeline->hsyncend;
+ req->htotal = modeline->htotal;
+ req->hskew = modeline->hskew;
+ req->vdisplay = modeline->vdisplay;
+ req->vsyncstart = modeline->vsyncstart;
+ req->vsyncend = modeline->vsyncend;
+ req->vtotal = modeline->vtotal;
+ req->flags = modeline->flags;
+ req->privsize = modeline->privsize;
+ if (modeline->privsize) {
+ req->length += modeline->privsize;
+ Data32(dpy, (long *) modeline->private,
+ modeline->privsize * sizeof(INT32));
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XF86VidModeValidateModeLine (dpy, screen, modeline)
+ Display *dpy;
+ int screen;
+ XF86VidModeModeInfo* modeline;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeValidateModeLineReq *req;
+ xXF86OldVidModeValidateModeLineReq *oldreq;
+ xXF86VidModeValidateModeLineReply rep;
+ int majorVersion, minorVersion;
+
+ XF86VidModeCheckExtension (dpy, info, 0);
+ XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion);
+
+ LockDisplay(dpy);
+
+ if (majorVersion < 2) {
+ GetOldReq(XF86VidModeValidateModeLine, XF86OldVidModeValidateModeLine, oldreq);
+ oldreq->reqType = info->codes->major_opcode;
+ oldreq->xf86vidmodeReqType = X_XF86VidModeValidateModeLine;
+ oldreq->screen = screen;
+ oldreq->dotclock = modeline->dotclock;
+ oldreq->hdisplay = modeline->hdisplay;
+ oldreq->hsyncstart = modeline->hsyncstart;
+ oldreq->hsyncend = modeline->hsyncend;
+ oldreq->htotal = modeline->htotal;
+ oldreq->vdisplay = modeline->vdisplay;
+ oldreq->vsyncstart = modeline->vsyncstart;
+ oldreq->vsyncend = modeline->vsyncend;
+ oldreq->vtotal = modeline->vtotal;
+ oldreq->flags = modeline->flags;
+ oldreq->privsize = modeline->privsize;
+ if (modeline->privsize) {
+ oldreq->length += modeline->privsize;
+ Data32(dpy, (long *) modeline->private,
+ modeline->privsize * sizeof(INT32));
+ }
+ } else {
+ GetReq(XF86VidModeValidateModeLine, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeValidateModeLine;
+ req->screen = screen;
+ req->dotclock = modeline->dotclock;
+ req->hdisplay = modeline->hdisplay;
+ req->hsyncstart = modeline->hsyncstart;
+ req->hsyncend = modeline->hsyncend;
+ req->htotal = modeline->htotal;
+ req->hskew = modeline->hskew;
+ req->vdisplay = modeline->vdisplay;
+ req->vsyncstart = modeline->vsyncstart;
+ req->vsyncend = modeline->vsyncend;
+ req->vtotal = modeline->vtotal;
+ req->flags = modeline->flags;
+ req->privsize = modeline->privsize;
+ if (modeline->privsize) {
+ req->length += modeline->privsize;
+ Data32(dpy, (long *) modeline->private,
+ modeline->privsize * sizeof(INT32));
+ }
+ }
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return MODE_BAD;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.status;
+}
+
+Bool
+XF86VidModeSwitchMode(dpy, screen, zoom)
+ Display* dpy;
+ int screen;
+ int zoom;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeSwitchModeReq *req;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeSwitchMode, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeSwitchMode;
+ req->screen = screen;
+ req->zoom = zoom;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XF86VidModeSwitchToMode(dpy, screen, modeline)
+ Display* dpy;
+ int screen;
+ XF86VidModeModeInfo* modeline;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeSwitchToModeReq *req;
+ xXF86OldVidModeSwitchToModeReq *oldreq;
+ int majorVersion, minorVersion;
+ Bool protocolBug = False;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+
+ /*
+ * Note: There was a bug in the protocol implementation in versions
+ * 0.x with x < 8 (the .private field wasn't expected to be sent over
+ * the wire). Check the server's version, and accept the old format
+ * if appropriate.
+ */
+
+ XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion);
+ if (majorVersion == 0 && minorVersion < 8) {
+ protocolBug = True;
+#ifdef DEBUG
+ fprintf(stderr, "XF86VidModeSwitchToMode: Warning: Xserver is"
+ "running an old version (%d.%d)\n", majorVersion,
+ minorVersion);
+#endif
+ }
+
+ LockDisplay(dpy);
+ if (majorVersion < 2) {
+ GetOldReq(XF86VidModeSwitchToMode, XF86OldVidModeSwitchToMode, oldreq);
+ oldreq->reqType = info->codes->major_opcode;
+ oldreq->xf86vidmodeReqType = X_XF86VidModeSwitchToMode;
+ oldreq->screen = screen;
+ oldreq->dotclock = modeline->dotclock;
+ oldreq->hdisplay = modeline->hdisplay;
+ oldreq->hsyncstart = modeline->hsyncstart;
+ oldreq->hsyncend = modeline->hsyncend;
+ oldreq->htotal = modeline->htotal;
+ oldreq->vdisplay = modeline->vdisplay;
+ oldreq->vsyncstart = modeline->vsyncstart;
+ oldreq->vsyncend = modeline->vsyncend;
+ oldreq->vtotal = modeline->vtotal;
+ oldreq->flags = modeline->flags;
+ if (protocolBug) {
+ oldreq->privsize = 0;
+ } else {
+ oldreq->privsize = modeline->privsize;
+ if (modeline->privsize) {
+ oldreq->length += modeline->privsize;
+ Data32(dpy, (long *) modeline->private,
+ modeline->privsize * sizeof(INT32));
+ }
+ }
+ } else {
+ GetReq(XF86VidModeSwitchToMode, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeSwitchToMode;
+ req->screen = screen;
+ req->dotclock = modeline->dotclock;
+ req->hdisplay = modeline->hdisplay;
+ req->hsyncstart = modeline->hsyncstart;
+ req->hsyncend = modeline->hsyncend;
+ req->htotal = modeline->htotal;
+ req->hskew = modeline->hskew;
+ req->vdisplay = modeline->vdisplay;
+ req->vsyncstart = modeline->vsyncstart;
+ req->vsyncend = modeline->vsyncend;
+ req->vtotal = modeline->vtotal;
+ req->flags = modeline->flags;
+ if (protocolBug) {
+ req->privsize = 0;
+ } else {
+ req->privsize = modeline->privsize;
+ if (modeline->privsize) {
+ req->length += modeline->privsize;
+ Data32(dpy, (long *) modeline->private,
+ modeline->privsize * sizeof(INT32));
+ }
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XF86VidModeLockModeSwitch(dpy, screen, lock)
+ Display* dpy;
+ int screen;
+ int lock;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeLockModeSwitchReq *req;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeLockModeSwitch, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeLockModeSwitch;
+ req->screen = screen;
+ req->lock = lock;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XF86VidModeGetMonitor(dpy, screen, monitor)
+ Display* dpy;
+ int screen;
+ XF86VidModeMonitor* monitor;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeGetMonitorReply rep;
+ xXF86VidModeGetMonitorReq *req;
+ CARD32 syncrange;
+ int i;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeGetMonitor, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeGetMonitor;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ monitor->nhsync = rep.nhsync;
+ monitor->nvsync = rep.nvsync;
+#if 0
+ monitor->bandwidth = (float)rep.bandwidth / 1e6;
+#endif
+ if (rep.vendorLength) {
+ if (!(monitor->vendor = (char *)Xcalloc(rep.vendorLength + 1, 1))) {
+ _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 +
+ ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3));
+ return False;
+ }
+ } else {
+ monitor->vendor = NULL;
+ }
+ if (rep.modelLength) {
+ if (!(monitor->model = Xcalloc(rep.modelLength + 1, 1))) {
+ _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 +
+ ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3));
+ if (monitor->vendor)
+ Xfree(monitor->vendor);
+ return False;
+ }
+ } else {
+ monitor->model = NULL;
+ }
+ if (!(monitor->hsync = Xcalloc(rep.nhsync, sizeof(XF86VidModeSyncRange)))) {
+ _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 +
+ ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3));
+
+ if (monitor->vendor)
+ Xfree(monitor->vendor);
+ if (monitor->model)
+ Xfree(monitor->model);
+ return False;
+ }
+ if (!(monitor->vsync = Xcalloc(rep.nvsync, sizeof(XF86VidModeSyncRange)))) {
+ _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 +
+ ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3));
+ if (monitor->vendor)
+ Xfree(monitor->vendor);
+ if (monitor->model)
+ Xfree(monitor->model);
+ Xfree(monitor->hsync);
+ return False;
+ }
+ for (i = 0; i < rep.nhsync; i++) {
+ _XRead(dpy, (char *)&syncrange, 4);
+ monitor->hsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0;
+ monitor->hsync[i].hi = (float)(syncrange >> 16) / 100.0;
+ }
+ for (i = 0; i < rep.nvsync; i++) {
+ _XRead(dpy, (char *)&syncrange, 4);
+ monitor->vsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0;
+ monitor->vsync[i].hi = (float)(syncrange >> 16) / 100.0;
+ }
+ if (rep.vendorLength)
+ _XReadPad(dpy, monitor->vendor, rep.vendorLength);
+ else
+ monitor->vendor = "";
+ if (rep.modelLength)
+ _XReadPad(dpy, monitor->model, rep.modelLength);
+ else
+ monitor->model = "";
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XF86VidModeGetViewPort(dpy, screen, x, y)
+ Display* dpy;
+ int screen;
+ int *x, *y;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeGetViewPortReply rep;
+ xXF86VidModeGetViewPortReq *req;
+ int majorVersion, minorVersion;
+ Bool protocolBug = False;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+
+ /*
+ * Note: There was a bug in the protocol implementation in versions
+ * 0.x with x < 8 (no reply was sent, so the client would hang)
+ * Check the server's version, and don't wait for a reply with older
+ * versions.
+ */
+
+ XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion);
+ if (majorVersion == 0 && minorVersion < 8) {
+ protocolBug = True;
+#ifdef DEBUG
+ fprintf(stderr, "XF86VidModeGetViewPort: Warning: Xserver is"
+ "running an old version (%d.%d)\n", majorVersion,
+ minorVersion);
+#endif
+ }
+ LockDisplay(dpy);
+ GetReq(XF86VidModeGetViewPort, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeGetViewPort;
+ req->screen = screen;
+ if (protocolBug) {
+ *x = 0;
+ *y = 0;
+ } else {
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *x = rep.x;
+ *y = rep.y;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XF86VidModeSetViewPort(dpy, screen, x, y)
+ Display* dpy;
+ int screen;
+ int x, y;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeSetViewPortReq *req;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeSetViewPort, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeSetViewPort;
+ req->screen = screen;
+ req->x = x;
+ req->y = y;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XF86VidModeGetDotClocks(dpy, screen,
+ flagsPtr, numclocksPtr, maxclocksPtr, clocksPtr)
+ Display* dpy;
+ int screen;
+ int *flagsPtr, *numclocksPtr, *maxclocksPtr, *clocksPtr[];
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeGetDotClocksReply rep;
+ xXF86VidModeGetDotClocksReq *req;
+ int i, *dotclocks;
+ CARD32 dotclk;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeGetDotClocks, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeGetDotClocks;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep,
+ (SIZEOF(xXF86VidModeGetDotClocksReply) - SIZEOF(xReply)) >> 2, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *numclocksPtr = rep.clocks;
+ *maxclocksPtr = rep.maxclocks;
+ *flagsPtr = rep.flags;
+
+ if (!(dotclocks = (int*) Xcalloc(rep.clocks, sizeof(int)))) {
+ _XEatData(dpy, (rep.clocks) * 4);
+ Xfree(dotclocks);
+ return False;
+ }
+
+ for (i = 0; i < rep.clocks; i++) {
+ _XRead(dpy, (char*)&dotclk, 4);
+ dotclocks[i] = dotclk;
+ }
+ *clocksPtr = dotclocks;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XF86VidModeSetGammaRamp (
+ Display *dpy,
+ int screen,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+)
+{
+ int length = (size + 1) & ~1;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeSetGammaRampReq *req;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+ LockDisplay(dpy);
+ GetReq(XF86VidModeSetGammaRamp, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeSetGammaRamp;
+ req->screen = screen;
+ req->length += (length >> 1) * 3;
+ req->size = size;
+ _XSend(dpy, (char*)red, size * 2);
+ _XSend(dpy, (char*)green, size * 2);
+ _XSend(dpy, (char*)blue, size * 2);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+
+Bool
+XF86VidModeGetGammaRamp (
+ Display *dpy,
+ int screen,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeGetGammaRampReq *req;
+ xXF86VidModeGetGammaRampReply rep;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeGetGammaRamp, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeGetGammaRamp;
+ req->screen = screen;
+ req->size = size;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return False;
+ }
+ if(rep.size) {
+ _XRead(dpy, (char*)red, rep.size << 1);
+ _XRead(dpy, (char*)green, rep.size << 1);
+ _XRead(dpy, (char*)blue, rep.size << 1);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XF86VidModeGetGammaRampSize(
+ Display *dpy,
+ int screen,
+ int *size
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeGetGammaRampSizeReq *req;
+ xXF86VidModeGetGammaRampSizeReply rep;
+
+ *size = 0;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeGetGammaRampSize, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeGetGammaRampSize;
+ req->screen = screen;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return False;
+ }
+ *size = rep.size;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XF86VidModeGetPermissions(
+ Display *dpy,
+ int screen,
+ int *permissions
+)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86VidModeGetPermissionsReq *req;
+ xXF86VidModeGetPermissionsReply rep;
+
+ *permissions = 0;
+
+ XF86VidModeCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86VidModeGetPermissions, req);
+ req->reqType = info->codes->major_opcode;
+ req->xf86vidmodeReqType = X_XF86VidModeGetPermissions;
+ req->screen = screen;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return False;
+ }
+ *permissions = rep.permissions;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
diff --git a/nx-X11/lib/Xxf86vm/Xxf86vm-def.cpp b/nx-X11/lib/Xxf86vm/Xxf86vm-def.cpp
new file mode 100644
index 000000000..0f7b4f335
--- /dev/null
+++ b/nx-X11/lib/Xxf86vm/Xxf86vm-def.cpp
@@ -0,0 +1,16 @@
+LIBRARY XXF86VM
+EXPORTS
+ XF86VidModeQueryExtension
+ XF86VidModeQueryVersion
+ XF86VidModeGetModeLine
+ XF86VidModeGetAllModeLines
+ XF86VidModeModModeLine
+ XF86VidModeSwitchMode
+ XF86VidModeLockModeSwitch
+ XF86VidModeGetMonitor
+ XF86VidModeGetGamma
+ XF86VidModeSetGamma
+ XF86VidModeSwitchToMode
+ XF86VidModeAddModeLine
+
+/* $XFree86$ */
diff --git a/nx-X11/lib/apple/AppleWM.man b/nx-X11/lib/apple/AppleWM.man
new file mode 100644
index 000000000..bb81470c9
--- /dev/null
+++ b/nx-X11/lib/apple/AppleWM.man
@@ -0,0 +1,340 @@
+.\"
+.\" $XFree86: xc/lib/apple/AppleWM.man,v 1.1 2003/08/12 23:47:10 torrey Exp $
+.\"
+.\" Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+.\" Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining a
+.\" copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sub license, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice (including the
+.\" next paragraph) 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 NON-INFRINGEMENT.
+.\" IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+.\"
+.de TQ
+.br
+.ns
+.TP \\$1
+..
+.TH APPLEWM __libmansuffix__ __vendorversion__
+
+.SH NAME
+ AppleWM \- Apple rootless window management extension.
+.SH SYNTAX
+\&#include <X11/extensions/applewm.h>
+.nf
+.sp
+Bool XAppleWMQueryExtension \^(\^Display *\fIdpy\fP,
+ int *\fIevent_basep\fP, int *\fIerror_basep\fP\^);
+.sp
+Status XAppleWMQueryVersion \^(\^Display *\fIdpy\fP,
+ int *\fImajor_versionp\fP, int *\fIminor_versionp\fP\^);
+.sp
+Bool XAppleWMDisableUpdate \^(\^Display *\fIdpy\fP, int \fIscreen\fP\^);
+.sp
+Bool XAppleWMReenableUpdate \^(\^Display *\fIdpy\fP, int \fIscreen\fP\^);
+.sp
+Bool XAppleWMSelectInput \^(\^Display *\fIdpy\fP, unsigned long \fImask\fP\^);
+.sp
+Bool XAppleWMSetWindowMenu \^(\^Display *\fIdpy\fP, int \fInitems\fP,
+ const char **\fIitems\fP\^);
+.sp
+Bool XAppleWMSetWindowMenuWithShortcuts \^(\^Display *\fIdpy\fP,
+ int \fInitems\fP, const char **\fIitems\fP,
+ const char *\fIshortcuts\fP\^);
+.sp
+Bool XAppleWMSetWindowMenuCheck \^(\^Display *\fIdpy\fP, int \fIindex\fP\^);
+.sp
+Bool XAppleWMSetFrontProcess \^(\^Display *\fIdpy\fP\^);
+.sp
+Bool XAppleWMSetWindowLevel \^(\^Display *\fIdpy\fP, Window \fIwindow\fP,
+ int \fIlevel\fP\^);
+.sp
+Bool XAppleWMSetCanQuit \^(\^Display *\fIdpy\fP, Bool \fIstate\fP\^);
+.sp
+Bool XAppleWMFrameGetRect \^(\^Display *\fIdpy\fP,
+ unsigned int \fIframe_class\fP,
+ unsigned int \fIframe_rect\fP,
+ short \fIinner_x\fP, short \fIinner_y\fP,
+ short \fIinner_w\fP, short \fIinner_h\fP,
+ short \fIouter_x\fP, short \fIouter_y\fP,
+ short \fIouter_w\fP, short \fIouter_h\fP,
+ short *\fIret_x\fP, short *\fIret_y\fP,
+ short *\fIret_w\fP, short *\fIret_h\fP\^);
+.sp
+unsigned int XAppleWMFrameHitTest \^(\^Display *\fIdpy\fP,
+ unsigned int \fIframe_class\fP,
+ short \fIpoint_x\fP, short \fIpoint_y\fP,
+ short \fIinner_x\fP, short \fIinner_y\fP,
+ short \fIinner_w\fP, short \fIinner_h\fP,
+ short \fIouter_x\fP, short \fIouter_y\fP,
+ short \fIouter_w\fP, short \fIouter_h\fP\^);
+.sp
+Bool XAppleWMFrameDraw \^(\^Display *\fIdpy\fP, int \fIscreen\fP,
+ Window \fIwindow\fP,
+ unsigned int \fIframe_class\fP,
+ unsigned int \fIframe_attr\fP,
+ short \fIinner_x\fP, short \fIinner_y\fP,
+ short \fIinner_w\fP, short \fIinner_h\fP,
+ short \fIouter_x\fP, short \fIouter_y\fP,
+ short \fIouter_w\fP, short \fIouter_h\fP,
+ unsigned int \fItitle_length\fP,
+ const unsigned char *\fItitle_bytes\fP);
+.fi
+.SH ARGUMENTS
+.IP \fIdpy\fP 1i
+Specifies the connection to the X server.
+.IP \fIscreen\fP 1i
+Specifies which screen.
+.IP \fImask\fP 1i
+Mask of event types the client is interested in.
+.IP \fIwindow\fP 1i
+Specifies which window.
+.IP \fIlevel\fP 1i
+Specifies the window level.
+.IP \fIframe_class\fP 1i
+Specifies the class of window frame decoration.
+.IP \fIframe_rect\fP 1i
+Specifies which rectangle to return from the window frame decoration.
+.IP \fIframe_attr\fP 1i
+A mask specifying the attributes of the window frame decoration.
+.IP \fIinner_x\fP,\fIinner_y\fP,\fIinner_w\fP,\fIinner_h\fP 1i
+Rectangle of the window content inside the window frame decoration.
+.IP \fIouter_x\fP,\fIouter_y\fP,\fIouter_w\fP,\fIouter_h\fP 1i
+Rectangle of the outer border of the window frame decoration.
+.IP \fIpoint_x\fP,\fIpoint_y\fP 1i
+Specifies the coordinates of the mouse up event.
+
+.SH DATATYPES
+
+.PP
+.B Events
+.nf
+typedef struct {
+ int type; \/* of event *\/
+ unsigned long serial; \/* # of last request processed by server *\/
+ Bool send_event; \/* true if came from a SendEvent request *\/
+ Display *display; \/* Display the event was read from *\/
+ Window window; \/* window of event *\/
+ Time time; \/* server timestamp when event happened *\/
+ int kind; \/* subtype of event *\/
+ int arg;
+} XAppleWMNotifyEvent;
+.fi
+.B XAppleWMNotifyEvent
+is sent to a client who has requested notification of AppleWM events with
+\fBXAppleWMSelectInput\fP.
+
+.PP
+Event types:
+.nf
+\&#define AppleWMControllerNotify 0
+\&#define AppleWMActivationNotify 1
+\&#define AppleWMPasteboardNotify 2
+.fi
+.PP
+Event masks:
+.nf
+\&#define AppleWMControllerNotifyMask (1L << 0)
+\&#define AppleWMActivationNotifyMask (1L << 1)
+\&#define AppleWMPasteboardNotifyMask (1L << 2)
+.fi
+.PP
+Kinds of ControllerNotify events:
+.nf
+\&#define AppleWMMinimizeWindow 0
+\&#define AppleWMZoomWindow 1
+\&#define AppleWMCloseWindow 2
+\&#define AppleWMBringAllToFront 3
+\&#define AppleWMHideWindow 4
+\&#define AppleWMHideAll 5
+\&#define AppleWMShowAll 6
+\&#define AppleWMWindowMenuItem 9
+\&#define AppleWMWindowMenuNotify 10
+\&#define AppleWMNextWindow 11
+\&#define AppleWMPreviousWindow 12
+.fi
+.PP
+Kinds of ActivationNotify events:
+.nf
+\&#define AppleWMIsActive 0
+\&#define AppleWMIsInactive 1
+.fi
+.PP
+Kinds of PasteboardNotify events:
+.nf
+\&#define AppleWMCopyToPasteboard 0
+.sp
+.fi
+.PP
+.B Window Parameters
+.PP
+Window level ids for \fBXAppleWMSetWindowLevel\fP:
+.nf
+\&#define AppleWMWindowLevelNormal 0
+\&#define AppleWMWindowLevelFloating 1
+\&#define AppleWMWindowLevelTornOff 2
+\&#define AppleWMWindowLevelDock 3
+\&#define AppleWMWindowLevelDesktop 4
+\&#define AppleWMNumWindowLevels 5
+.fi
+.PP
+Values for \fIframe_rect\fP argument to \fBXAppleWMFrameGetRect\fP:
+.nf
+\&#define AppleWMFrameRectTitleBar 1
+\&#define AppleWMFrameRectTracking 2
+\&#define AppleWMFrameRectGrowBox 3
+.fi
+.PP
+Window frame classes:
+.nf
+\&#define AppleWMFrameClassDocument 1 << 0
+\&#define AppleWMFrameClassDialog 1 << 1
+\&#define AppleWMFrameClassModalDialog 1 << 2
+\&#define AppleWMFrameClassSystemModalDialog 1 << 3
+\&#define AppleWMFrameClassUtility 1 << 4
+\&#define AppleWMFrameClassToolbar 1 << 5
+\&#define AppleWMFrameClassMenu 1 << 6
+\&#define AppleWMFrameClassSplash 1 << 7
+\&#define AppleWMFrameClassBorderless 1 << 8
+.fi
+.PP
+Window frame attributes:
+.nf
+\&#define AppleWMFrameActive 0x0001
+\&#define AppleWMFrameUrgent 0x0002
+\&#define AppleWMFrameTitle 0x0004
+\&#define AppleWMFramePrelight 0x0008
+\&#define AppleWMFrameShaded 0x0010
+\&#define AppleWMFrameCloseBox 0x0100
+\&#define AppleWMFrameCollapseBox 0x0200
+\&#define AppleWMFrameZoomBox 0x0400
+\&#define AppleWMFrameAnyBox 0x0700
+\&#define AppleWMFrameCloseBoxClicked 0x0800
+\&#define AppleWMFrameCollapseBoxClicked 0x1000
+\&#define AppleWMFrameZoomBoxClicked 0x2000
+\&#define AppleWMFrameAnyBoxClicked 0x3800
+\&#define AppleWMFrameGrowBox 0x4000
+.fi
+
+.SH DESCRIPTION
+.B AppleWM
+is a simple library designed to interface with the Apple-WM extension.
+This extension allows X window managers to better interact with
+the Mac OS X Aqua user interface when running X11 in a rootless mode.
+.PP
+A more complete description will be forthcoming eventually.
+
+.SH FUNCTIONS
+.B XAppleWMDisableUpdate
+causes any updates to the windows on the screen to be queued until updates
+are reenabled with \fBXAppleWMReenableUpdate\fP. This is useful to avoid
+intermediate redraws to the screen if a number of changes are going to be
+made at once. Updates should only be disabled temporarily while drawing
+to a window. These calls may be nested and each call to
+\fBXAppleWMDisableUpdate\fP must be paired with a subsequent call to
+\fBXAppleWMReenableUpdate\fP. Updating is not reenabled until the last
+unnested call to \fBXAppleWMReenableUpdate\fP. Disabling updates applies
+to window content; however, it is implementation dependent whether window
+size and position changes are disabled as well.
+.PP
+.B XAppleWMSelectInput
+is used to request that a client receive notification of the
+.B AppleWM
+events listed above. The event mask specifies the event types the client is
+interested in receiving. Passing an event mask of 0 stops notification of
+events.
+.PP
+.B XAppleWMSetWindowMenu
+and
+.B XAppleWMSetWindowMenuWithShortcuts
+set the list of windows displayed in the X server's "Window" menu in the
+Aqua menu bar. Other items may be listed in this menu by the X server, but
+a part of this menu is set aside for use by the Apple-WM extension. This
+is intended to be used to set a list of important top-level X11 windows.
+.PP
+One item of the X server's "Window" menu can have a checkmark beside it to
+indicate it is the active or front most window.
+.B XAppleWMSetWindowMenuCheck
+can be used to set the item number to put a checkmark beside.
+.PP
+.B XAppleWMSetFrontProcess
+directs the X server to make itself the front most application among all
+the other Mac OS X applications. This causes X11 windows to move above
+other applications' windows and for the X server to start receiving
+keyboard and mouse events.
+.PP
+Windows can be placed into different Aqua window levels with
+\fBXAppleWMSetWindowLevel\fP. The stacking of window levels takes precedence
+over the stacking of windows within a level. Thus the bottom window in a level
+will obscure even the top most window of a lower window level. By default all
+windows are placed in the lowest window level, AppleWMWindowLevelNormal. When
+a window is moved to a new level, it is ordered in front of all of its peers
+at the new level. \fINote, X11 does not have the concept of window levels and
+this function does not change the X11 window order. The result of trying to
+reorder an X11 window above another window of higher level is undefined.
+This should probably be changed.\fP
+.PP
+By default, the X server will ask for confirmation whenever the user requests
+that it quit from the Aqua UI.
+.B XAppleWMSetCanQuit
+can be used to change this behavior. If a \fIstate\fP of TRUE is passed, the
+X server will quit without confirmation when requested. If FALSE is passed,
+the default behavior is used.
+.PP
+.B XAppleWMFrameDraw
+can be used to decorate a top-level window with the standard Aqua window
+frame and widgets. The \fIframe_class\fP controls the overall look of the
+window frame and \fIframe_attr\fP specifies the details of how the various
+UI elements should be drawn. The dimensions of the X11 window content are
+passed as the \fIinner_*\fP rectangle and the dimensions of the Aqua window
+frame are passed as the \fIouter_*\fP rectangle.
+.B XAppleWMFrameGetRect
+is used to calculate the size of the outer rectangle from the size of the
+window content, which is being reparented.
+.PP
+.B XAppleWMFrameGetRect
+returns a rectangle that encloses an element of the window frame decoration.
+The \fIframe_rect\fP argument specifies the element of interest. The
+\fIinner_*\fP and \fIouter_*\fP rectangles (as described above) specify the
+window geometry. If AppleWMFrameRectTitleBar is passed for \fIframe_rect\fP,
+the \fIinner_*\fP parameters are ignored. The returned rectangle has the
+dimensions of the \fIouter_*\fP rectangle except that its height is equal
+to the constant title bar height for the specified \fIframe_class\fP. The
+proper outer rectangle for a given window content size is the union of inner
+rectangle and the title bar rectangle. The AppleWMFrameRectTracking and
+AppleWMFrameRectGrowBox rectangles are primarily intended to be used by the
+window manager to determine the correct placement for child windows to
+receive events. The tracking rectangle is the area of the window containing
+the close, collapse and zoom boxes. Typically when the cursor is over this
+area, the window manager will highlight the close, collapse, and zoom
+buttons to conform to the standard Aqua interface.
+.PP
+If a mouse up or down event is received in the tracking rectangle,
+.B XAppleWMFrameHitTest
+is used to determine which button was clicked.
+.B XAppleWMFrameHitTest
+returns AppleWMFrameCloseBox, AppleWMFrameCollapseBox, or AppleWMFrameZoomBox
+to indicate which button was clicked. If no button was clicked, 0 will be
+returned.
+.PP
+Other functions include: \fBXAppleWMQueryExtension\fP, which returns the event
+and error base codes and \fBXAppleWMQueryVersion\fP, which returns the current
+version of the extension. (This information is cached by the library.)
+
+.SH RESTRICTIONS
+.B AppleWM
+is only intended to be used on Mac OS X when running a rootless X server.
diff --git a/nx-X11/lib/apple/Imakefile b/nx-X11/lib/apple/Imakefile
new file mode 100644
index 000000000..a3dabf455
--- /dev/null
+++ b/nx-X11/lib/apple/Imakefile
@@ -0,0 +1,37 @@
+XCOMM $XFree86: xc/lib/Xrandr/Imakefile,v 1.2 2002/10/02 16:55:41 keithp Exp $
+
+
+#define DoNormalLib NormalLibAppleWM
+#define DoSharedLib SharedLibAppleWM
+#define DoDebugLib DebugLibAppleWM
+#define DoProfileLib ProfileLibAppleWM
+#define LibName AppleWM
+#define SoRev SOAPPLEWMREV
+#define IncSubdir X11
+#define IncSubSubdir extensions
+
+#include <Threads.tmpl>
+
+#ifdef SharedAppleWMReqs
+REQUIREDLIBS = SharedAppleWMReqs
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC)
+ SRCS = applewm.c
+ OBJS = applewm.o
+ LINTLIBS = $(LINTXLIB)
+
+HEADERS = applewm.h applewmstr.h
+
+#include <Library.tmpl>
+
+MANSUFFIX = $(LIBMANSUFFIX)
+
+InstallManPage(AppleWM,$(LIBMANDIR))
+
+DependTarget()
diff --git a/nx-X11/lib/apple/applewm.c b/nx-X11/lib/apple/applewm.c
new file mode 100644
index 000000000..c627762fb
--- /dev/null
+++ b/nx-X11/lib/apple/applewm.c
@@ -0,0 +1,530 @@
+/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.12 2001/08/27 17:40:57 dawes Exp $ */
+/**************************************************************************
+
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/extensions/applewmstr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <stdio.h>
+
+static XExtensionInfo _applewm_info_data;
+static XExtensionInfo *applewm_info = &_applewm_info_data;
+static char *applewm_extension_name = APPLEWMNAME;
+
+#define AppleWMCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, applewm_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *extCodes);
+static Bool wire_to_event();
+static Status event_to_wire();
+
+static /* const */ XExtensionHooks applewm_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, applewm_info,
+ applewm_extension_name,
+ &applewm_extension_hooks,
+ AppleWMNumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, applewm_info)
+
+static Bool wire_to_event (dpy, re, event)
+ Display *dpy;
+ XEvent *re;
+ xEvent *event;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XAppleWMNotifyEvent *se;
+ xAppleWMNotifyEvent *sevent;
+
+ AppleWMCheckExtension (dpy, info, False);
+
+ switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
+ case AppleWMControllerNotify:
+ case AppleWMActivationNotify:
+ case AppleWMPasteboardNotify:
+ se = (XAppleWMNotifyEvent *) re;
+ sevent = (xAppleWMNotifyEvent *) event;
+ se->type = sevent->type & 0x7f;
+ se->serial = _XSetLastRequestRead(dpy,(xGenericReply *) event);
+ se->send_event = (sevent->type & 0x80) != 0;
+ se->display = dpy;
+ se->window = 0;
+ se->time = sevent->time;
+ se->kind = sevent->kind;
+ se->arg = sevent->arg;
+ return True;
+ }
+ return False;
+}
+
+static Status event_to_wire (dpy, re, event)
+ Display *dpy;
+ XEvent *re;
+ xEvent *event;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XAppleWMNotifyEvent *se;
+ xAppleWMNotifyEvent *sevent;
+
+ AppleWMCheckExtension (dpy, info, False);
+
+ switch ((re->type & 0x7f) - info->codes->first_event) {
+ case AppleWMControllerNotify:
+ case AppleWMActivationNotify:
+ case AppleWMPasteboardNotify:
+ se = (XAppleWMNotifyEvent *) re;
+ sevent = (xAppleWMNotifyEvent *) event;
+ sevent->type = se->type | (se->send_event ? 0x80 : 0);
+ sevent->sequenceNumber = se->serial & 0xffff;
+ sevent->kind = se->kind;
+ sevent->arg = se->arg;
+ sevent->time = se->time;
+ return 1;
+ }
+ return 0;
+}
+
+/*****************************************************************************
+ * *
+ * public Apple-WM Extension routines *
+ * *
+ *****************************************************************************/
+
+#if 0
+#include <stdio.h>
+#define TRACE(msg) fprintf(stderr, "AppleWM%s\n", msg);
+#else
+#define TRACE(msg)
+#endif
+
+
+Bool XAppleWMQueryExtension (dpy, event_basep, error_basep)
+ Display *dpy;
+ int *event_basep, *error_basep;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ TRACE("QueryExtension...");
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ TRACE("QueryExtension... return True");
+ return True;
+ } else {
+ TRACE("QueryExtension... return False");
+ return False;
+ }
+}
+
+Bool XAppleWMQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
+ Display* dpy;
+ int* majorVersion;
+ int* minorVersion;
+ int* patchVersion;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xAppleWMQueryVersionReply rep;
+ xAppleWMQueryVersionReq *req;
+
+ TRACE("QueryVersion...");
+ AppleWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleWMQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_AppleWMQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return False");
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ *patchVersion = rep.patchVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return True");
+ return True;
+}
+
+Bool XAppleWMDisableUpdate(dpy, screen)
+ Display* dpy;
+ int screen;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xAppleWMDisableUpdateReq *req;
+
+ TRACE("DisableUpdate...");
+ AppleWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleWMDisableUpdate, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_AppleWMDisableUpdate;
+ req->screen = screen;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("DisableUpdate... return True");
+ return True;
+}
+
+Bool XAppleWMReenableUpdate(dpy, screen)
+ Display* dpy;
+ int screen;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xAppleWMReenableUpdateReq *req;
+
+ TRACE("ReenableUpdate...");
+ AppleWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleWMReenableUpdate, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_AppleWMReenableUpdate;
+ req->screen = screen;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("ReenableUpdate... return True");
+ return True;
+}
+
+Bool XAppleWMSelectInput(dpy, mask)
+ Display* dpy;
+ unsigned long mask;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xAppleWMSelectInputReq *req;
+
+ TRACE("SelectInput...");
+ AppleWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleWMSelectInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_AppleWMSelectInput;
+ req->mask = mask;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("SetlectInput... return True");
+ return True;
+}
+
+Bool XAppleWMSetWindowMenuWithShortcuts(dpy, nitems, items, shortcuts)
+ Display* dpy;
+ int nitems;
+ const char **items;
+ const char *shortcuts;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xAppleWMSetWindowMenuReq *req;
+ int i, total_length, len;
+ char *buf, *ptr;
+
+ TRACE("SetWindowMenu...");
+ AppleWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleWMSetWindowMenu, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_AppleWMSetWindowMenu;
+ req->nitems = nitems;
+
+ total_length = 0;
+ for (i = 0; i < nitems; i++)
+ total_length += strlen (items[i]) + 2;
+
+ ptr = buf = alloca (total_length);
+ for (i = 0; i < nitems; i++)
+ {
+ len = strlen (items[i]);
+ *ptr++ = shortcuts ? shortcuts[i] : 0;
+ memcpy (ptr, items[i], len);
+ ptr[len] = 0;
+ ptr += len + 1;
+ }
+
+ req->length += (total_length + 3) >> 2;
+ Data (dpy, buf, total_length);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("SetlectInput... return True");
+ return True;
+}
+
+Bool XAppleWMSetWindowMenu(dpy, nitems, items)
+ Display* dpy;
+ int nitems;
+ const char **items;
+{
+ return XAppleWMSetWindowMenuWithShortcuts (dpy, nitems, items, NULL);
+}
+
+Bool XAppleWMSetWindowMenuCheck(dpy, idx)
+ Display* dpy;
+ int idx;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xAppleWMSetWindowMenuCheckReq *req;
+
+ TRACE("SetWindowMenuCheck...");
+ AppleWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleWMSetWindowMenuCheck, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_AppleWMSetWindowMenuCheck;
+ req->index = idx;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("SetWindowMenuCheck... return True");
+ return True;
+}
+
+Bool XAppleWMSetFrontProcess(dpy)
+ Display* dpy;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xAppleWMSetFrontProcessReq *req;
+
+ TRACE("SetFrontProcess...");
+ AppleWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleWMSetFrontProcess, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_AppleWMSetFrontProcess;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("SetFrontProcess... return True");
+ return True;
+}
+
+Bool XAppleWMSetWindowLevel(dpy, id, level)
+ Display* dpy;
+ Window id;
+ int level;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xAppleWMSetWindowLevelReq *req;
+
+ TRACE("SetWindowLevel...");
+ AppleWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleWMSetWindowLevel, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_AppleWMSetWindowLevel;
+ req->window = id;
+ req->level = level;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("SetWindowLevel... return True");
+ return True;
+}
+
+Bool XAppleWMSetCanQuit(dpy, state)
+ Display* dpy;
+ Bool state;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xAppleWMSetCanQuitReq *req;
+
+ TRACE("SetCanQuit...");
+ AppleWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleWMSetCanQuit, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_AppleWMSetCanQuit;
+ req->state = state;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("SetCanQuit... return True");
+ return True;
+}
+
+Bool XAppleWMFrameGetRect(dpy, frame_class, frame_rect,
+ ix, iy, iw, ih, ox, oy, ow, oh, rx, ry, rw, rh)
+ Display* dpy;
+ unsigned int frame_class, frame_rect;
+ short ix, iy, iw, ih;
+ short ox, oy, ow, oh;
+ short *rx, *ry, *rw, *rh;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xAppleWMFrameGetRectReply rep;
+ xAppleWMFrameGetRectReq *req;
+
+ TRACE("FrameGetRect...");
+ AppleWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleWMFrameGetRect, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_AppleWMFrameGetRect;
+ req->frame_class = frame_class;
+ req->frame_rect = frame_rect;
+ req->ix = ix;
+ req->iy = iy;
+ req->iw = iw;
+ req->ih = ih;
+ req->ox = ox;
+ req->oy = oy;
+ req->ow = ow;
+ req->oh = oh;
+ rep.x = rep.y = rep.w = rep.h = 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("FrameGetRect... return False");
+ return False;
+ }
+ *rx = rep.x; *ry = rep.y;
+ *rw = rep.w; *rh = rep.h;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("FrameGetRect... return True");
+ return True;
+}
+
+unsigned int XAppleWMFrameHitTest(dpy, frame_class, px, py,
+ ix, iy, iw, ih, ox, oy, ow, oh)
+ Display* dpy;
+ unsigned int frame_class;
+ short px, py;
+ short ix, iy, iw, ih;
+ short ox, oy, ow, oh;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xAppleWMFrameHitTestReply rep;
+ xAppleWMFrameHitTestReq *req;
+
+ TRACE("FrameHitTest...");
+ AppleWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleWMFrameHitTest, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_AppleWMFrameHitTest;
+ req->frame_class = frame_class;
+ req->px = px;
+ req->py = py;
+ req->ix = ix;
+ req->iy = iy;
+ req->iw = iw;
+ req->ih = ih;
+ req->ox = ox;
+ req->oy = oy;
+ req->ow = ow;
+ req->oh = oh;
+ rep.ret = 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("FrameHitTest... return False");
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("FrameHiTest... return True");
+ return rep.ret;
+}
+
+Bool XAppleWMFrameDraw(dpy, screen, window,
+ frame_class, frame_attr,
+ ix, iy, iw, ih, ox, oy, ow, oh,
+ title_length, title_bytes)
+ Display* dpy;
+ int screen;
+ Window window;
+ unsigned int frame_class, frame_attr;
+ short ix, iy, iw, ih;
+ short ox, oy, ow, oh;
+ unsigned int title_length;
+ const unsigned char *title_bytes;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xAppleWMFrameDrawReq *req;
+
+ TRACE("FrameDraw...");
+ AppleWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(AppleWMFrameDraw, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_AppleWMFrameDraw;
+ req->screen = screen;
+ req->window = window;
+ req->frame_class = frame_class;
+ req->frame_attr = frame_attr;
+ req->ix = ix;
+ req->iy = iy;
+ req->iw = iw;
+ req->ih = ih;
+ req->ox = ox;
+ req->oy = oy;
+ req->ow = ow;
+ req->oh = oh;
+ req->title_length = title_length;
+
+ req->length += (title_length + 3)>>2;
+ Data (dpy, title_bytes, title_length);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("FrameDraw... return True");
+ return True;
+}
diff --git a/nx-X11/lib/apple/applewm.h b/nx-X11/lib/apple/applewm.h
new file mode 100644
index 000000000..884d5cb91
--- /dev/null
+++ b/nx-X11/lib/apple/applewm.h
@@ -0,0 +1,190 @@
+/* $XFree86: xc/lib/apple/applewm.h,v 1.1 2003/08/12 23:47:10 torrey Exp $ */
+/**************************************************************************
+
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+#ifndef _APPLEWM_H_
+#define _APPLEWM_H_
+
+#include <X11/Xfuncproto.h>
+
+#define X_AppleWMQueryVersion 0
+#define X_AppleWMFrameGetRect 1
+#define X_AppleWMFrameHitTest 2
+#define X_AppleWMFrameDraw 3
+#define X_AppleWMDisableUpdate 4
+#define X_AppleWMReenableUpdate 5
+#define X_AppleWMSelectInput 6
+#define X_AppleWMSetWindowMenuCheck 7
+#define X_AppleWMSetFrontProcess 8
+#define X_AppleWMSetWindowLevel 9
+#define X_AppleWMSetCanQuit 10
+#define X_AppleWMSetWindowMenu 11
+
+/* Events */
+#define AppleWMControllerNotify 0
+#define AppleWMActivationNotify 1
+#define AppleWMPasteboardNotify 2
+#define AppleWMNumberEvents 3
+
+#define AppleWMControllerNotifyMask (1L << 0)
+#define AppleWMActivationNotifyMask (1L << 1)
+#define AppleWMPasteboardNotifyMask (1L << 2)
+
+/* "Kinds" of ControllerNotify events */
+#define AppleWMMinimizeWindow 0
+#define AppleWMZoomWindow 1
+#define AppleWMCloseWindow 2
+#define AppleWMBringAllToFront 3
+#define AppleWMHideWindow 4
+#define AppleWMHideAll 5
+#define AppleWMShowAll 6
+#define AppleWMWindowMenuItem 9
+#define AppleWMWindowMenuNotify 10
+#define AppleWMNextWindow 11
+#define AppleWMPreviousWindow 12
+
+/* "Kinds" of ActivationNotify events */
+#define AppleWMIsActive 0
+#define AppleWMIsInactive 1
+
+/* "Kinds" of PasteboardNotify events */
+#define AppleWMCopyToPasteboard 0
+
+/* Errors */
+#define AppleWMClientNotLocal 0
+#define AppleWMOperationNotSupported 1
+#define AppleWMNumberErrors (AppleWMOperationNotSupported + 1)
+
+/* Window level ids */
+#define AppleWMWindowLevelNormal 0
+#define AppleWMWindowLevelFloating 1
+#define AppleWMWindowLevelTornOff 2
+#define AppleWMWindowLevelDock 3
+#define AppleWMWindowLevelDesktop 4
+#define AppleWMNumWindowLevels 5
+
+/* Possible value for frame_rect argument to XAppleWMFrameGetRect() */
+#define AppleWMFrameRectTitleBar 1
+#define AppleWMFrameRectTracking 2
+#define AppleWMFrameRectGrowBox 3
+
+/* Window frame classes */
+#define AppleWMFrameClassDocument 1 << 0
+#define AppleWMFrameClassDialog 1 << 1
+#define AppleWMFrameClassModalDialog 1 << 2
+#define AppleWMFrameClassSystemModalDialog 1 << 3
+#define AppleWMFrameClassUtility 1 << 4
+#define AppleWMFrameClassToolbar 1 << 5
+#define AppleWMFrameClassMenu 1 << 6
+#define AppleWMFrameClassSplash 1 << 7
+#define AppleWMFrameClassBorderless 1 << 8
+
+/* Window frame attributes */
+#define AppleWMFrameActive 0x0001
+#define AppleWMFrameUrgent 0x0002
+#define AppleWMFrameTitle 0x0004
+#define AppleWMFramePrelight 0x0008
+#define AppleWMFrameShaded 0x0010
+#define AppleWMFrameCloseBox 0x0100
+#define AppleWMFrameCollapseBox 0x0200
+#define AppleWMFrameZoomBox 0x0400
+#define AppleWMFrameAnyBox 0x0700
+#define AppleWMFrameCloseBoxClicked 0x0800
+#define AppleWMFrameCollapseBoxClicked 0x1000
+#define AppleWMFrameZoomBoxClicked 0x2000
+#define AppleWMFrameAnyBoxClicked 0x3800
+#define AppleWMFrameGrowBox 0x4000
+
+#ifndef _APPLEWM_SERVER_
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came frome a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* window of event */
+ Time time; /* server timestamp when event happened */
+ int kind; /* subtype of event */
+ int arg;
+} XAppleWMNotifyEvent;
+
+_XFUNCPROTOBEGIN
+
+Bool XAppleWMQueryExtension (Display *dpy, int *event_base, int *error_base);
+
+Bool XAppleWMQueryVersion (Display *dpy, int *majorVersion,
+ int *minorVersion, int *patchVersion);
+
+Bool XAppleWMDisableUpdate (Display *dpy, int screen);
+
+Bool XAppleWMReenableUpdate (Display *dpy, int screen);
+
+Bool XAppleWMSelectInput (Display *dpy, unsigned long mask);
+
+Bool XAppleWMSetWindowMenu (Display *dpy, int nitems, const char **items);
+Bool XAppleWMSetWindowMenuWithShortcuts (Display *dpy, int nitems,
+ const char **items,
+ const char *shortcuts);
+
+Bool XAppleWMSetWindowMenuCheck (Display *dpy, int index);
+
+Bool XAppleWMSetFrontProcess (Display *dpy);
+
+Bool XAppleWMSetWindowLevel (Display *dpy, Window id, int level);
+
+Bool XAppleWMSetCanQuit (Display *dpy, Bool state);
+
+Bool XAppleWMFrameGetRect (Display *dpy,
+ unsigned int frame_class, unsigned int frame_rect,
+ short inner_x, short inner_y,
+ short inner_w, short inner_h,
+ short outer_x, short outer_y,
+ short outer_w, short outer_h,
+ short *ret_x, short *ret_y,
+ short *ret_w, short *ret_h);
+
+unsigned int XAppleWMFrameHitTest (Display *dpy,
+ unsigned int frame_class,
+ short point_x, short point_y,
+ short inner_x, short inner_y,
+ short inner_w, short inner_h,
+ short outer_x, short outer_y,
+ short outer_w, short outer_h);
+
+Bool XAppleWMFrameDraw (Display *dpy, int screen, Window window,
+ unsigned int frame_class, unsigned int frame_attr,
+ short inner_x, short inner_y,
+ short inner_w, short inner_h,
+ short outer_x, short outer_y,
+ short outer_w, short outer_h,
+ unsigned int title_length,
+ const unsigned char * title_bytes);
+
+_XFUNCPROTOEND
+
+#endif /* _APPLEWM_SERVER_ */
+#endif /* _APPLEWM_H_ */
diff --git a/nx-X11/lib/apple/applewmstr.h b/nx-X11/lib/apple/applewmstr.h
new file mode 100644
index 000000000..392eaa885
--- /dev/null
+++ b/nx-X11/lib/apple/applewmstr.h
@@ -0,0 +1,226 @@
+/* $XFree86: xc/lib/apple/applewmstr.h,v 1.1 2003/08/12 23:47:10 torrey Exp $ */
+/**************************************************************************
+
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+#ifndef _APPLEWMSTR_H_
+#define _APPLEWMSTR_H_
+
+#include <X11/extensions/applewm.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#define APPLEWMNAME "Apple-WM"
+
+#define APPLE_WM_MAJOR_VERSION 1 /* current version numbers */
+#define APPLE_WM_MINOR_VERSION 0
+#define APPLE_WM_PATCH_VERSION 0
+
+typedef struct _AppleWMQueryVersion {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMQueryVersion */
+ CARD16 length B16;
+} xAppleWMQueryVersionReq;
+#define sz_xAppleWMQueryVersionReq 4
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD16 majorVersion B16; /* major version of WM protocol */
+ CARD16 minorVersion B16; /* minor version of WM protocol */
+ CARD32 patchVersion B32; /* patch version of WM protocol */
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xAppleWMQueryVersionReply;
+#define sz_xAppleWMQueryVersionReply 32
+
+typedef struct _AppleWMDisableUpdate {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMDisableUpdate */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xAppleWMDisableUpdateReq;
+#define sz_xAppleWMDisableUpdateReq 8
+
+typedef struct _AppleWMReenableUpdate {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMReenableUpdate */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xAppleWMReenableUpdateReq;
+#define sz_xAppleWMReenableUpdateReq 8
+
+typedef struct _AppleWMSelectInput {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMSelectInput */
+ CARD16 length B16;
+ CARD32 mask B32;
+} xAppleWMSelectInputReq;
+#define sz_xAppleWMSelectInputReq 8
+
+typedef struct _AppleWMNotify {
+ BYTE type; /* always eventBase + event type */
+ BYTE kind;
+ CARD16 sequenceNumber B16;
+ Time time B32; /* time of change */
+ CARD16 pad1 B16;
+ CARD32 arg B32;
+ CARD32 pad3 B32;
+} xAppleWMNotifyEvent;
+#define sz_xAppleWMNotifyEvent 20
+
+typedef struct _AppleWMSetWindowMenu {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMSetWindowMenu */
+ CARD16 length B16;
+ CARD16 nitems B16;
+ CARD16 pad1 B16;
+} xAppleWMSetWindowMenuReq;
+#define sz_xAppleWMSetWindowMenuReq 8
+
+typedef struct _AppleWMSetWindowMenuCheck {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMSetWindowMenuCheck */
+ CARD16 length B16;
+ CARD32 index;
+} xAppleWMSetWindowMenuCheckReq;
+#define sz_xAppleWMSetWindowMenuCheckReq 8
+
+typedef struct _AppleWMSetFrontProcess {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMSetFrontProcess */
+ CARD16 length B16;
+} xAppleWMSetFrontProcessReq;
+#define sz_xAppleWMSetFrontProcessReq 4
+
+typedef struct _AppleWMSetWindowLevel {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMSetWindowLevel */
+ CARD16 length B16;
+ CARD32 window;
+ CARD32 level;
+} xAppleWMSetWindowLevelReq;
+#define sz_xAppleWMSetWindowLevelReq 12
+
+typedef struct _AppleWMSetCanQuit {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMSetCanQuit */
+ CARD16 length B16;
+ CARD32 state;
+} xAppleWMSetCanQuitReq;
+#define sz_xAppleWMSetCanQuitReq 8
+
+typedef struct _AppleWMFrameGetRect {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMFrameGetRect */
+ CARD16 length B16;
+ CARD16 frame_class B16;
+ CARD16 frame_rect B16;
+ CARD16 ix B16;
+ CARD16 iy B16;
+ CARD16 iw B16;
+ CARD16 ih B16;
+ CARD16 ox B16;
+ CARD16 oy B16;
+ CARD16 ow B16;
+ CARD16 oh B16;
+} xAppleWMFrameGetRectReq;
+#define sz_xAppleWMFrameGetRectReq 24
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD16 x B16;
+ CARD16 y B16;
+ CARD16 w B16;
+ CARD16 h B16;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xAppleWMFrameGetRectReply;
+#define sz_xAppleWMFrameGetRectReply 32
+
+typedef struct _AppleWMFrameHitTest {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMFrameHitTest */
+ CARD16 length B16;
+ CARD16 frame_class B16;
+ CARD16 pad1 B16;
+ CARD16 px B16;
+ CARD16 py B16;
+ CARD16 ix B16;
+ CARD16 iy B16;
+ CARD16 iw B16;
+ CARD16 ih B16;
+ CARD16 ox B16;
+ CARD16 oy B16;
+ CARD16 ow B16;
+ CARD16 oh B16;
+} xAppleWMFrameHitTestReq;
+#define sz_xAppleWMFrameHitTestReq 28
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 ret B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xAppleWMFrameHitTestReply;
+#define sz_xAppleWMFrameHitTestReply 32
+
+typedef struct _AppleWMFrameDraw {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMFrameDraw */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 window B32;
+ CARD16 frame_class B16;
+ CARD16 frame_attr B16;
+ CARD16 ix B16;
+ CARD16 iy B16;
+ CARD16 iw B16;
+ CARD16 ih B16;
+ CARD16 ox B16;
+ CARD16 oy B16;
+ CARD16 ow B16;
+ CARD16 oh B16;
+ CARD32 title_length B32;
+} xAppleWMFrameDrawReq;
+#define sz_xAppleWMFrameDrawReq 36
+
+#endif /* _APPLEWMSTR_H_ */
diff --git a/nx-X11/lib/dmx/Imakefile b/nx-X11/lib/dmx/Imakefile
new file mode 100644
index 000000000..c4296de6f
--- /dev/null
+++ b/nx-X11/lib/dmx/Imakefile
@@ -0,0 +1,26 @@
+XCOMM $XFree86$
+
+#define DoNormalLib NormalLibDmx
+#define DoSharedLib SharedLibDmx
+#define DoDebugLib DebugLibDmx
+#define DoProfileLib ProfileLibDmx
+
+#define LibName dmx
+#define SoRev SODMXREV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC)
+ SRCS = dmx.c
+ OBJS = dmx.o
+ LINTLIBS = $(LINTXLIB)
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/dmx/dmx.c b/nx-X11/lib/dmx/dmx.c
new file mode 100644
index 000000000..1df28e690
--- /dev/null
+++ b/nx-X11/lib/dmx/dmx.c
@@ -0,0 +1,802 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+/** \file
+ * This file implements the client-side part of the DMX protocol. It
+ * can be included in client applications by linking with the libdmx.a
+ * library. */
+
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#define EXTENSION_PROC_ARGS void *
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/dmxproto.h>
+#include <X11/extensions/dmxext.h>
+
+static XExtensionInfo dmx_extension_info_data;
+static XExtensionInfo *dmx_extension_info = &dmx_extension_info_data;
+static const char *dmx_extension_name = DMX_EXTENSION_NAME;
+
+#define DMXCheckExtension(dpy,i,val) \
+ XextCheckExtension(dpy, i, dmx_extension_name, val)
+#define DMXSimpleCheckExtension(dpy,i) \
+ XextSimpleCheckExtension(dpy, i, dmx_extension_name)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *extCodes);
+static /* const */ XExtensionHooks dmx_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY(find_display, dmx_extension_info,
+ (char *)dmx_extension_name,
+ &dmx_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY(close_display, dmx_extension_info)
+
+
+/*****************************************************************************
+ * *
+ * public DMX Extension routines *
+ * *
+ *****************************************************************************/
+
+/** If the server has the DMX extension, the event and error bases will
+ * be placed in \a event_basep and \a error_basep, and True will be
+ * returned. Otherwise, False will be returned.
+ *
+ * Available in DMX Protocol Version 1.0 */
+Bool DMXQueryExtension(Display *dpy, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+/** If the DMXQueryVersion protocol request returns version information
+ * from the server, \a majorVersion, \a minorVersion, and \a
+ * patchVersion are filled in with the appropriate information and True
+ * is returned. Otherwise, False will be returned.
+ *
+ * Available in DMX Protocol Version 1.0 */
+Bool DMXQueryVersion(Display *dpy,
+ int *majorVersion, int *minorVersion, int *patchVersion)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXQueryVersionReply rep;
+ xDMXQueryVersionReq *req;
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ *patchVersion = rep.patchVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/** Flush all pending dmxSync requests in DMX server.
+ *
+ * Available in DMX Protocol Version 1.5 */
+Bool DMXSync(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXSyncReply rep;
+ xDMXSyncReq *req;
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXSync, req);
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXSync;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.status == Success ? True : False;
+}
+
+/** The creation of the specified \a window will be forced.
+ *
+ * Available in DMX Protocol Version 1.2
+ * Reply added in DMX Protocol Version 2.0 */
+Bool DMXForceWindowCreation(Display *dpy, Window window)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXForceWindowCreationReq *req;
+ xDMXForceWindowCreationReply rep;
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXForceWindowCreation, req);
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXForceWindowCreation;
+ req->window = window;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.status == Success ? True : False;
+}
+
+/** If the DMXGetScreenCount protocol request returns the screen count,
+ * the value will be placed in \a screen_count, and True will be
+ * returned. Otherwise, False will be returned.
+ *
+ * Available in DMX Protocol Version 1.0 */
+Bool DMXGetScreenCount(Display *dpy, int *screen_count)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXGetScreenCountReply rep;
+ xDMXGetScreenCountReq *req;
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXGetScreenCount, req);
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXGetScreenCount;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *screen_count = rep.screenCount;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/** If the DMXGetScreenAttributes protocol request returns information
+ * for the specified \a physical_screen, information about the screen
+ * will be placed in \a attr, and True will be returned. Otherwise,
+ * False will be returned.
+ *
+ * Available in DMX Protocol Version 1.0; Modified in Version 2.0 */
+Bool DMXGetScreenAttributes(Display *dpy, int physical_screen,
+ DMXScreenAttributes *attr)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXGetScreenAttributesReply rep;
+ xDMXGetScreenAttributesReq *req;
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXGetScreenAttributes, req);
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXGetScreenAttributes;
+ req->physicalScreen = physical_screen;
+ if (!_XReply(dpy, (xReply *)&rep,
+ (SIZEOF(xDMXGetScreenAttributesReply) - 32) >> 2, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ attr->displayName = Xmalloc(rep.displayNameLength + 1 + 4 /* for pad */);
+ _XReadPad(dpy, attr->displayName, rep.displayNameLength);
+ attr->displayName[rep.displayNameLength] = '\0';
+ attr->logicalScreen = rep.logicalScreen;
+
+ attr->screenWindowWidth = rep.screenWindowWidth;
+ attr->screenWindowHeight = rep.screenWindowHeight;
+ attr->screenWindowXoffset = rep.screenWindowXoffset;
+ attr->screenWindowYoffset = rep.screenWindowYoffset;
+
+ attr->rootWindowWidth = rep.rootWindowWidth;
+ attr->rootWindowHeight = rep.rootWindowHeight;
+ attr->rootWindowXoffset = rep.rootWindowXoffset;
+ attr->rootWindowYoffset = rep.rootWindowYoffset;
+ attr->rootWindowXorigin = rep.rootWindowXorigin;
+ attr->rootWindowYorigin = rep.rootWindowYorigin;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+static CARD32 _DMXGetScreenAttribute(int bit, DMXScreenAttributes *attr)
+{
+ switch (1 << bit) {
+ case DMXScreenWindowWidth: return attr->screenWindowWidth;
+ case DMXScreenWindowHeight: return attr->screenWindowHeight;
+ case DMXScreenWindowXoffset: return attr->screenWindowXoffset;
+ case DMXScreenWindowYoffset: return attr->screenWindowYoffset;
+ case DMXRootWindowWidth: return attr->rootWindowWidth;
+ case DMXRootWindowHeight: return attr->rootWindowHeight;
+ case DMXRootWindowXoffset: return attr->rootWindowXoffset;
+ case DMXRootWindowYoffset: return attr->rootWindowYoffset;
+ case DMXRootWindowXorigin: return attr->rootWindowXorigin;
+ case DMXRootWindowYorigin: return attr->rootWindowYorigin;
+ default: return 0;
+ }
+}
+
+static int _DMXDumpScreenAttributes(Display *dpy,
+ unsigned long mask,
+ DMXScreenAttributes *attr)
+{
+ int i;
+ unsigned long value_list[32];
+ unsigned long *value = value_list;
+ int count = 0;
+
+ for (i = 0; i < 32; i++) {
+ if (mask & (1 << i)) {
+ *value++ = _DMXGetScreenAttribute(i, attr);
+ ++count;
+ }
+ }
+ Data32(dpy, value_list, count * sizeof(CARD32));
+ return count;
+}
+
+static CARD32 _DMXGetInputAttribute(int bit, DMXInputAttributes *attr)
+{
+ switch (1 << bit) {
+ case DMXInputType:
+ switch (attr->inputType) {
+ case DMXLocalInputType: return 0;
+ case DMXConsoleInputType: return 1;
+ case DMXBackendInputType: return 2;
+ }
+ return attr->inputType;
+ case DMXInputPhysicalScreen: return attr->physicalScreen;
+ case DMXInputSendsCore: return attr->sendsCore;
+ default: return 0;
+ }
+}
+
+static int _DMXDumpInputAttributes(Display *dpy,
+ unsigned long mask,
+ DMXInputAttributes *attr)
+{
+ int i;
+ unsigned long value_list[32];
+ unsigned long *value = value_list;
+ int count = 0;
+
+ for (i = 0; i < 32; i++) {
+ if (mask & (1 << i)) {
+ *value++ = _DMXGetInputAttribute(i, attr);
+ ++count;
+ }
+ }
+ Data32(dpy, value_list, count * sizeof(CARD32));
+ return count;
+}
+
+/** Change geometries and positions of the DMX screen and root windows
+ * on the back-end X server. */
+int DMXChangeScreensAttributes(Display *dpy,
+ int screen_count,
+ int *screens,
+ int mask_count,
+ unsigned int *masks,
+ DMXScreenAttributes *attrs, /* vector */
+ int *error_screen)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXChangeScreensAttributesReply rep;
+ xDMXChangeScreensAttributesReq *req;
+ int i;
+ unsigned int mask = 0;
+ CARD32 *screen_list;
+ CARD32 *mask_list;
+
+ DMXCheckExtension(dpy, info, False);
+
+ if (screen_count < 1 || mask_count < 1) return DmxBadValue;
+
+ LockDisplay(dpy);
+ GetReq(DMXChangeScreensAttributes, req);
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXChangeScreensAttributes;
+ req->screenCount = screen_count;
+ req->maskCount = mask_count;
+ req->length += screen_count + mask_count;
+
+ screen_list = (CARD32 *)Xmalloc(sizeof(*screen_list) * screen_count);
+ for (i = 0; i < screen_count; i++) screen_list[i] = screens[i];
+ Data32(dpy, screen_list, screen_count * sizeof(CARD32));
+ Xfree(screen_list);
+
+ mask_list = (CARD32 *)Xmalloc(sizeof(*mask_list) * mask_count);
+ for (i = 0; i < mask_count; i++) mask_list[i] = masks[i];
+ Data32(dpy, mask_list, mask_count * sizeof(CARD32));
+ Xfree(mask_list);
+
+ for (i = 0; i < screen_count; i++) {
+ if (i < mask_count) mask = masks[i];
+ req->length += _DMXDumpScreenAttributes(dpy, mask, attrs + i);
+ }
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return DmxBadReply;
+ }
+ if (error_screen) *error_screen = rep.errorScreen;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.status;
+}
+
+/** Add a screen. */
+Bool DMXAddScreen(Display *dpy, const char *displayName, unsigned int mask,
+ DMXScreenAttributes *attr, int *screen)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXAddScreenReply rep;
+ xDMXAddScreenReq *req;
+ int length;
+ int paddedLength;
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXAddScreen, req);
+ length = displayName ? strlen(displayName) : 0;
+ paddedLength = (length + 3) & ~3;
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXAddScreen;
+ req->displayNameLength = length;
+ req->physicalScreen = *screen;
+ req->valueMask = mask;
+ req->length += paddedLength/4;
+ req->length += _DMXDumpScreenAttributes(dpy, mask, attr);
+
+ if (length) {
+ char *buffer = Xmalloc(paddedLength);
+ memset(buffer, 0, paddedLength);
+ memcpy(buffer, displayName, length);
+ Data32(dpy, buffer, paddedLength);
+ Xfree(buffer);
+ }
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ if (screen) *screen = rep.physicalScreen;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.status == Success ? True : False;
+}
+
+/** Remove a screen. */
+Bool DMXRemoveScreen(Display *dpy, int screen)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXRemoveScreenReply rep;
+ xDMXRemoveScreenReq *req;
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXRemoveScreen, req);
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXRemoveScreen;
+ req->physicalScreen = screen;
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.status == Success ? True : False;
+}
+
+/** If the DMXGetWindowAttributes protocol request returns information
+ * about the specified \a window, the number of screens for which
+ * information is available will be returned in \a screen_count and
+ * information about the first \a available_count of those screens will
+ * be placed in \a inf. Because this call transports a great deal of
+ * information over the wire, please call #DMXGetScreenCount first, and
+ * make sure \a inf is that large.
+ *
+ * Note that if the specified \a window has not yet been mapped when
+ * #DMXGetWindowAttributes is called, then a subsequent XMapWindow call
+ * might be buffered in xlib while requests directly to the back-end X
+ * servers are processed. This race condition can be solved by calling
+ * #DMXSync before talking directly to the back-end X servers.
+ *
+ * Available in DMX Protocol Version 1.0, but not working correctly
+ * until DMX Protocol Version 1.4 */
+Bool DMXGetWindowAttributes(Display *dpy, Window window,
+ int *screen_count, int available_count,
+ DMXWindowAttributes *inf)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXGetWindowAttributesReply rep;
+ xDMXGetWindowAttributesReq *req;
+ unsigned long current;
+ CARD32 *screens; /* Must match protocol size */
+ CARD32 *windows; /* Must match protocol size */
+ XRectangle *pos; /* Must match protocol size */
+ XRectangle *vis; /* Must match protocol size */
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXGetWindowAttributes, req);
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXGetWindowAttributes;
+ req->window = window;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ /* FIXME: check for NULL? */
+ screens = Xmalloc(rep.screenCount * sizeof(*screens));
+ windows = Xmalloc(rep.screenCount * sizeof(*windows));
+ pos = Xmalloc(rep.screenCount * sizeof(*pos));
+ vis = Xmalloc(rep.screenCount * sizeof(*vis));
+
+ _XRead(dpy, (char *)screens, rep.screenCount * sizeof(*screens));
+ _XRead(dpy, (char *)windows, rep.screenCount * sizeof(*windows));
+ _XRead(dpy, (char *)pos, rep.screenCount * sizeof(*pos));
+ _XRead(dpy, (char *)vis, rep.screenCount * sizeof(*vis));
+
+ *screen_count = rep.screenCount;
+ for (current = 0;
+ current < rep.screenCount && current < (unsigned)available_count;
+ current++, inf++) {
+ inf->screen = screens[current];
+ inf->window = windows[current];
+ inf->pos = pos[current];
+ inf->vis = vis[current];
+ }
+
+ Xfree(vis);
+ Xfree(pos);
+ Xfree(windows);
+ Xfree(screens);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/** If the DMXGetDesktopAttributes protocol request returns information
+ * correctly, the information will be placed in \a attr, and True will
+ * be returned. Otherwise, False will be returned.
+ *
+ * Available in DMX Protocol Version 2.0 */
+Bool DMXGetDesktopAttributes(Display *dpy, DMXDesktopAttributes *attr)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXGetDesktopAttributesReply rep;
+ xDMXGetDesktopAttributesReq *req;
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXGetDesktopAttributes, req);
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXGetDesktopAttributes;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ attr->width = rep.width;
+ attr->height = rep.height;
+ attr->shiftX = rep.shiftX;
+ attr->shiftY = rep.shiftY;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+static CARD32 _DMXGetDesktopAttribute(int bit, DMXDesktopAttributes *attr)
+{
+ switch (1 << bit) {
+ case DMXDesktopWidth: return attr->width;
+ case DMXDesktopHeight: return attr->height;
+ case DMXDesktopShiftX: return attr->shiftX;
+ case DMXDesktopShiftY: return attr->shiftY;
+ default: return 0;
+ }
+}
+
+static int _DMXDumpDesktopAttributes(Display *dpy,
+ unsigned long mask,
+ DMXDesktopAttributes *attr)
+{
+ int i;
+ unsigned long value_list[32];
+ unsigned long *value = value_list;
+ int count = 0;
+
+ for (i = 0; i < 32; i++) {
+ if (mask & (1 << i)) {
+ *value++ = _DMXGetDesktopAttribute(i, attr);
+ ++count;
+ }
+ }
+ Data32(dpy, value_list, count * sizeof(CARD32));
+ return count;
+}
+
+/** Change the global bounding box and origin offset.
+ *
+ * Available in DMX Protocol Version 2.0 */
+int DMXChangeDesktopAttributes(Display *dpy,
+ unsigned int mask,
+ DMXDesktopAttributes *attr)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXChangeDesktopAttributesReply rep;
+ xDMXChangeDesktopAttributesReq *req;
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXChangeDesktopAttributes, req);
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXChangeDesktopAttributes;
+ req->valueMask = mask;
+ req->length +=_DMXDumpDesktopAttributes(dpy, mask, attr);
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return DmxBadReply;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.status;
+}
+
+/** If the DMXGetInputCount protocol request returns the input count,
+ * the value will be placed in \a input_count, and True will be
+ * returned. Otherwise, False will be returned.
+ *
+ * Available in DMX Protocol Version 1.1 */
+Bool DMXGetInputCount(Display *dpy, int *input_count)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXGetInputCountReply rep;
+ xDMXGetInputCountReq *req;
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXGetInputCount, req);
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXGetInputCount;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *input_count = rep.inputCount;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/** If the DMXGetInputAttributes protocol request returns information
+ * about the input device with the specified \a id, information about
+ * the input device will be placed in \a inf, and True will be returned.
+ * Otherwise, False will be returned.
+ *
+ * Available in DMX Protocol Version 1.1 */
+Bool DMXGetInputAttributes(Display *dpy, int id, DMXInputAttributes *inf)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXGetInputAttributesReply rep;
+ xDMXGetInputAttributesReq *req;
+ char *buffer;
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXGetInputAttributes, req);
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXGetInputAttributes;
+ req->deviceId = id;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ switch (rep.inputType) {
+ case 0: inf->inputType = DMXLocalInputType; break;
+ case 1: inf->inputType = DMXConsoleInputType; break;
+ case 2: inf->inputType = DMXBackendInputType; break;
+ }
+
+ inf->physicalScreen = rep.physicalScreen;
+ inf->physicalId = rep.physicalId;
+ inf->isCore = rep.isCore;
+ inf->sendsCore = rep.sendsCore;
+ inf->detached = rep.detached;
+ buffer = Xmalloc(rep.nameLength + 1 + 4 /* for pad */);
+ _XReadPad(dpy, buffer, rep.nameLength);
+ buffer[rep.nameLength] = '\0';
+ inf->name = buffer;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/** Add input. */
+Bool DMXAddInput(Display *dpy, unsigned int mask, DMXInputAttributes *attr,
+ int *id)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXAddInputReply rep;
+ xDMXAddInputReq *req;
+ int length;
+ int paddedLength;
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXAddInput, req);
+ length = attr->name ? strlen(attr->name) : 0;
+ paddedLength = (length + 3) & ~3;
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXAddInput;
+ req->displayNameLength = length;
+ req->valueMask = mask;
+ req->length += paddedLength/4;
+ req->length += _DMXDumpInputAttributes(dpy, mask, attr);
+
+ if (length) {
+ char *buffer = Xmalloc(paddedLength);
+ memset(buffer, 0, paddedLength);
+ memcpy(buffer, attr->name, paddedLength);
+ Data32(dpy, buffer, paddedLength);
+ Xfree(buffer);
+ }
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ if (id) *id = rep.physicalId;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.status == Success ? True : False;
+}
+
+/** Add backend input (a helper function that calls #DMXAddInput). */
+Bool DMXAddBackendInput(Display *dpy, int screen, int sendsCore, int *newId)
+{
+ DMXInputAttributes attr;
+ unsigned int mask = (DMXInputType
+ | DMXInputPhysicalScreen
+ | DMXInputSendsCore);
+
+ attr.inputType = DMXBackendInputType;
+ attr.physicalScreen = screen;
+ attr.sendsCore = sendsCore;
+ attr.name = NULL;
+ return DMXAddInput(dpy, mask, &attr, newId);
+}
+
+/** Add console input (a helper function that calls #DMXAddInput). */
+Bool DMXAddConsoleInput(Display *dpy, const char *name, int sendsCore,
+ int *newId)
+{
+ DMXInputAttributes attr;
+ unsigned int mask = (DMXInputType
+ | DMXInputSendsCore);
+
+ attr.inputType = DMXConsoleInputType;
+ attr.physicalScreen = 0;
+ attr.sendsCore = sendsCore;
+ attr.name = name;
+ return DMXAddInput(dpy, mask, &attr, newId);
+}
+
+/** Remove an input. */
+Bool DMXRemoveInput(Display *dpy, int id)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xDMXRemoveInputReply rep;
+ xDMXRemoveInputReq *req;
+
+ DMXCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(DMXRemoveInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->dmxReqType = X_DMXRemoveInput;
+ req->physicalId = id;
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.status == Success ? True : False;
+}
diff --git a/nx-X11/lib/dps/DPSCAP.h b/nx-X11/lib/dps/DPSCAP.h
new file mode 100644
index 000000000..cb36016c2
--- /dev/null
+++ b/nx-X11/lib/dps/DPSCAP.h
@@ -0,0 +1,77 @@
+/*
+ * DPSCAP.h -- CAP constants, analogous to X.h
+ *
+ * (c) Copyright 1990-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#ifndef _DPSCAP_h
+#define _DPSCAP_h
+
+/* DPSCAPConnSetup functional hint flags */
+
+#define DPSCAPNONEFLAG 0x0000
+
+/* Values for DPSCAPNotify */
+
+#define DPSCAPNOTE_GRAB 0
+#define DPSCAPNOTE_UNGRAB 1
+#define DPSCAPNOTE_FREEGC 2
+#define DPSCAPNOTE_SYNC 3
+#define DPSCAPNOTE_PAUSE 4
+
+/* Minor opcodes for CAP errors */
+
+#define DPSCAPDEADLOCK 0
+
+/* Pnames for ClientMessage type atoms */
+
+
+#define DPSCAP_TYPE_PSOUTPUT "_ADOBE_DPSCAP_TYPE_PSOUTPUT"
+#define DPSCAP_TYPE_PSOUTPUT_LEN "_ADOBE_DPSCAP_TYPE_PSOUTPUT_WITH_LEN"
+#define DPSCAP_TYPE_PSSTATUS "_ADOBE_DPSCAP_TYPE_PSSTATUS"
+#define DPSCAP_TYPE_NOOP "_ADOBE_DPSCAP_TYPE_NOOP"
+#define DPSCAP_TYPE_SYNC "_ADOBE_DPSCAP_TYPE_SYNC"
+#define DPSCAP_TYPE_XERROR "_ADOBE_DPSCAP_TYPE_XERROR"
+#define DPSCAP_TYPE_PSREADY "_ADOBE_DPSCAP_TYPE_PSREADY"
+#define DPSCAP_TYPE_RESUME "_ADOBE_DPSCAP_TYPE_RESUME"
+
+#define DPSCAP_ATOMS 8
+
+/* Translate argument names for X_CAPSetArg, see dpsNXargs.h */
+
+#define DPSCAP_ARG_SMALLFONTS 1
+#define DPSCAP_ARG_PIXMEM 2
+
+#endif /* _DPSCAP_h */
diff --git a/nx-X11/lib/dps/DPSCAPClient.h b/nx-X11/lib/dps/DPSCAPClient.h
new file mode 100644
index 000000000..803acf3ed
--- /dev/null
+++ b/nx-X11/lib/dps/DPSCAPClient.h
@@ -0,0 +1,139 @@
+/*
+ * DPSCAPClient.h -- DPSCAP client definitions
+ *
+ * (c) Copyright 1990-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#ifndef DPSCAPCLIENT_H
+#define DPSCAPCLIENT_H 1
+
+#include "DPSCAP.h"
+#include "DPSCAPproto.h"
+#include <X11/Xlib.h>
+#ifndef Xmalloc
+#endif
+#include <DPS/XDPSlib.h>
+
+/* === DEFINES === */
+
+#ifndef _NFILE
+#define _NFILE 128
+#endif
+
+#define DPSCAPFAILED -1
+#define DPSCAPSUCCESS 0
+
+#define DPSGCBITS \
+(GCPlaneMask|GCSubwindowMode|GCClipXOrigin|GCClipYOrigin|GCClipMask)
+
+/* === TYPEDEFS === */
+
+typedef enum {
+ dpscap_nopad,
+ dpscap_pad,
+ dpscap_insert,
+ dpscap_append
+} DPSCAPIOFlags;
+
+typedef struct _t_DPSCAPData {
+ struct _t_DPSCAPData *next;
+ Display *dpy;
+ /* shadow connection to agent */
+ Display *agent; /* Dummy display structure is agent */
+ char *otherConnID; /* VMS AST? */
+ XExtCodes *codes;
+ XExtData *extData; /* Back pointer for clearing private */
+ Atom typePSOutput;
+ Atom typePSOutputWithLen;
+ Atom typePSStatus;
+ Atom typeNoop;
+ Atom typeSync;
+ Atom typeXError;
+ Atom typePSReady; /* L2-DPS/PROTO 9 addition */
+ Atom typeResume;
+ unsigned long saveseq;
+ int dpscapVersion;
+ Window agentWindow;
+} DPSCAPDataRec, *DPSCAPData;
+
+typedef struct {
+ struct _t_DPSCAPData *head; /* list of active agent connections */
+ char *defaultAgentName; /* settable agent name */
+ char *map[_NFILE]; /* map DPY_NUMBER to agent name */
+} DPSCAPGlobalsRec, *DPSCAPGlobals;
+
+/* === GLOBALS === */
+
+extern DPSCAPGlobals gCSDPS;
+
+/* === PUBLIC PROCS === */
+
+extern int CSDPSInit(Display * /* dpy */, int * /* numberType */, char ** /* floatingName */);
+
+extern XExtData **CSDPSHeadOfDpyExt(Display * /* dpy */);
+
+/* === SUPPORT PROCS === */
+
+extern void DPSCAPChangeGC(Display * /* agent */, GC /* gc */, unsigned long /* valuemask */, XGCValues * /* values */);
+
+extern DPSCAPData DPSCAPCreate(Display * /* dpy */, Display * /* agent */);
+
+extern int DPSCAPDestroy(XExtData * /* extData */);
+
+extern XExtData * DPSCAPOpenAgent(Display * /* dpy */, char * /* trueDisplayName */);
+
+extern void DPSCAPRead(DPSCAPData /* my */, char * /* buf */, unsigned /* len */, DPSCAPIOFlags /* includePad */);
+
+extern void DPSCAPStartUp(void);
+
+extern void DPSCAPWrite(Display * /* my */, char * /* buf */, unsigned /* len */, DPSCAPIOFlags /* writePad */, DPSCAPIOFlags /* bufMode */);
+
+/* ext callback hooks */
+
+extern int DPSCAPCloseDisplayProc(Display * /* dpy */, XExtCodes * /* codes */);
+
+extern int DPSCAPGrabServerProc(Display * /* dpy */, XExtCodes * /* codes */);
+
+extern int DPSCAPUngrabServerProc(Display * /* dpy */, XExtCodes * /* codes */);
+
+extern void DPSCAPCloseAgent(Display * /* agent */);
+
+extern int DPSCAPCopyGCProc(Display * /* dpy */, GC /* gc */, XExtCodes * /* codes */);
+
+extern int DPSCAPFreeGCProc(Display * /* pdpy */, GC /* gc */, XExtCodes * /* codes */);
+
+extern int DPSCAPFlushGCProc(Display * /* dpy */, GC /* gc */, XExtCodes * /* codes */);
+
+#endif /* DPSCAPCLIENT_H */
diff --git a/nx-X11/lib/dps/DPSCAPproto.h b/nx-X11/lib/dps/DPSCAPproto.h
new file mode 100644
index 000000000..e35487b2b
--- /dev/null
+++ b/nx-X11/lib/dps/DPSCAPproto.h
@@ -0,0 +1,180 @@
+/*
+ * DPSCAPproto.h -- CAP requests constants and alignment values,
+ * analgous to Xproto.h
+ *
+ * (c) Copyright 1991-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+
+#ifndef _DPSCAPproto_h
+#define _DPSCAPproto_h
+
+/* === DEFINITIONS === */
+
+#define DPSCAPPROTOVERSION 3
+#define DPSCAPPROTOVERSION_2 2
+
+#define CSDPSPORT 6016 /* add agent instance number */
+#define DPS_NX_SERV_NAME "dpsnx" /* name to look up in /etc/services */
+
+/* Request Opcodes */
+
+#define DPSCAPOPCODEBASE 126
+#define DPSXOPCODEBASE 125
+
+#define X_CAPFlushAgent 1
+#define X_CAPNotify 2
+#define X_CAPSetArg 3
+
+/* === REQUESTS === */
+
+typedef struct _CAPConnSetup {
+ BYTE byteorder; /* #x42 MSB, #x6C LSB */
+ BYTE dpscapVersion; /* proto version of connecting client */
+ CARD16 flags B16; /* functional hint flags */
+ CARD32 libraryversion B32; /* as for XPSInit */
+ CARD16 authProtoNameLength B16; /* in bytes */
+ CARD16 authProtoDataLength B16; /* in bytes */
+ CARD16 displayStringLength B16; /* in bytes */
+ CARD16 nodeStringLength B16; /* in bytes */
+ CARD16 transportStringLength B16; /* in bytes */
+ CARD16 display B16; /* Display number */
+ CARD16 screen B16; /* Screen number */
+ CARD16 reserved B16;
+ CARD32 clientWindow B32; /* window for ClientMessage */
+} xCAPConnSetupReq;
+#define sz_xCAPConnSetupReq 28
+
+typedef struct {
+ BYTE success;
+ BYTE reasonLength;
+ CARD16 additionalLength B16;
+} xCAPConnReplyPrefix;
+#define sz_xCAPConnReplyPrefix 4
+
+typedef struct _CAPConnFailed {
+ BYTE success; /* failed = 0, success = 1 */
+ BYTE reasonLength; /* in bytes if failed, ignore if success */
+ CARD16 additionalLength B16;/* quadbytes ADDITIONAL length */
+ CARD32 serverVersion B32; /* as for XPSInit */
+ CARD8 dpscapVersion; /* proto version of agent */
+ CARD8 pad;
+ CARD16 reserved B16;
+} xCAPConnFailed;
+#define sz_xCAPConnFailed 12
+
+typedef struct _CAPConnSuccess {
+ BYTE success; /* failed = 0, success = 1 */
+ BYTE reasonLength; /* in bytes if failed, ignore if success */
+ CARD16 additionalLength B16;/* quadbytes ADDITIONAL length */
+ CARD32 serverVersion B32; /* as for XPSInit */
+ CARD8 dpscapVersion; /* proto version of agent */
+ CARD8 reserved;
+ CARD16 flagsUsed B16; /* mask of functional hint flags used */
+ CARD32 preferredNumberFormat B32; /* as for XPSInit */
+ CARD32 floatingNameLength B32; /* as for XPSInit */
+ CARD32 agentWindow B32; /* client sends messages to this window */
+} xCAPConnSuccess;
+#define sz_xCAPConnSuccess 24
+
+typedef struct _CAPFlushAgent {
+ CARD8 reqType; /* always DPSCAPOPCODEBASE */
+ CARD8 type; /* always X_CAPFlushAgent */
+ CARD16 length B16; /* quadbyte length of request */
+ CARD32 cxid B32; /* context XID */
+} xCAPFlushAgentReq;
+#define sz_xCAPFlushAgentReq 8
+
+typedef struct _CAPNotify {
+ CARD8 reqType; /* always DPSCAPOPCODEBASE */
+ CARD8 type; /* always X_CAPNotify */
+ CARD16 length B16; /* quadbyte length of request */
+ CARD32 cxid B32; /* context XID */
+ CARD32 notification B32; /* notify code */
+ CARD32 data B32; /* data word */
+ CARD32 extra B32; /* extra word */
+} xCAPNotifyReq;
+#define sz_xCAPNotifyReq 20
+
+typedef struct _CAPSetArg {
+ CARD8 reqType; /* always DPSCAPOPCODEBASE */
+ CARD8 type; /* always X_CAPNotify */
+ CARD16 length B16; /* quadbyte length of request */
+ CARD32 arg B32; /* argument type */
+ CARD32 val B32; /* value */
+} xCAPSetArgReq;
+#define sz_xCAPSetArgReq 12
+
+/* === ERRORS === */
+
+typedef struct _DPSCAPError {
+ BYTE type; /* always 0 */
+ BYTE errorCode; /* always 255 */
+ CARD16 sequenceNumber B16; /* the nth request from this client */
+ CARD8 subLength; /* how much of 21 bytes are used */
+ CARD8 unused;
+ CARD16 reserved B16;
+ CARD16 minorOpcode B16;
+ CARD8 majorOpcode; /* always 0 */
+ BYTE subData1;
+ CARD32 subData2 B32;
+ CARD32 subData3 B32;
+ CARD32 subData4 B32;
+ CARD32 subData5 B32;
+ CARD32 subData6 B32;
+ CARD32 subData7 B32;
+} xDPSCAPError;
+
+/* === EVENTS === */
+
+/* Events sent from agent to client via XSendEvent */
+
+#define DPSCAP_OUTPUT_OVERHEAD 4
+#define DPSCAP_BYTESPEROUTPUTEVENT (20 - DPSCAP_OUTPUT_OVERHEAD)
+#define DPSCAP_DATA_LEN (DPSCAP_BYTESPEROUTPUTEVENT-1)
+
+typedef struct {
+ CARD32 cxid;
+ CARD8 data[DPSCAP_BYTESPEROUTPUTEVENT];
+} DPSCAPOutputEvent;
+
+typedef struct {
+ BYTE status;
+ BYTE unused;
+ CARD16 sequenceNumber;
+ CARD32 cxid;
+} DPSCAPStatusEvent;
+
+#endif /* _DPSCAPproto_h */
diff --git a/nx-X11/lib/dps/Imakefile b/nx-X11/lib/dps/Imakefile
new file mode 100644
index 000000000..119b3429e
--- /dev/null
+++ b/nx-X11/lib/dps/Imakefile
@@ -0,0 +1,265 @@
+XCOMM $XFree86: xc/lib/dps/Imakefile,v 1.16tsi Exp $
+
+#define DoNormalLib NormalLibDps
+#define DoSharedLib SharedLibDps
+#define DoExtraLib SharedLibDps
+#define DoDebugLib DebugLibDps
+#define DoProfileLib ProfileLibDps
+#define LibName dps
+#define SoRev SODPSREV
+#define IncSubdir DPS
+
+#ifdef SharedDPSReqs
+REQUIREDLIBS = SharedDPSReqs
+#endif
+
+XCOMM The Client Library uses definitions just like Xlib for network
+XCOMM capabilities, such as TCPCONN, UNIXCONN, and DNETCONN. See
+XCOMM csconndi.c and csopendi.c
+
+XCOMM The connection code should be rewritten to use xtrans. The STREAMSCONN
+XCOMM code here needs work. For now force ConnectionFlags to be
+XCOMM -DTCPCONN -DUNIXCONN
+
+#undef ConnectionFlags
+#define ConnectionFlags -DTCPCONN -DUNIXCONN
+
+ DEFINES = -DXDPS -DCSDPS ConnectionFlags
+ CAT = cat
+ SED = sed
+ AWK = awk
+ SORT = sort
+ PSWRAP = PsWrap
+
+COMMONOBJECTFILES = \
+ dpsclient.o\
+ dpsprintf.o\
+ dpsexcept.o\
+ dpsdict.o\
+ dpsabbrev.o
+
+COMMONSOURCEFILES = \
+ dpsclient.c\
+ dpsprintf.c\
+ dpsexcept.c\
+ dpsdict.c\
+ dpsabbrev.c
+
+XOBJECTFILES = \
+ dpsXclient.o\
+ dpssysnames.o\
+ dpsXpriv.o\
+ XDPS.o\
+ dpsXtdisp.o\
+ dpsXcmu.o
+
+XSOURCEFILES = \
+ dpsXclient.c\
+ dpssysnames.c\
+ dpsXpriv.c\
+ XDPS.c\
+ dpsXtdisp.c\
+ dpsXcmu.c
+
+XCSDPSOBJECTFILES = \
+ cslibext.o\
+ csopendi.o\
+ csconndi.o\
+ csstartNX.o\
+ csfindNX.o\
+ cslibint.o
+
+XCSDPSSOURCEFILES = \
+ cslibext.c\
+ csopendi.c\
+ csconndi.c\
+ csstartNX.c\
+ csfindNX.c\
+ cslibint.c
+
+DPSOPSOBJECTS = \
+ dpsclrops.o\
+ dpsctrlops.o\
+ dpsctxtops.o\
+ dpsdataops.o\
+ dpsfontops.o\
+ dpsgsttops.o\
+ dpsioops.o\
+ dpsmathops.o\
+ dpsmtrxops.o\
+ dpsmiscops.o\
+ dpspntops.o\
+ dpspathops.o\
+ dpssysops.o\
+ dpswinops.o\
+ dpsopstack.o\
+ dpsXops.o\
+ dpsl2ops.o
+
+PSOPSOBJECTS = \
+ psclrops.o\
+ psctrlops.o\
+ psctxtops.o\
+ psdataops.o\
+ psfontops.o\
+ psgsttops.o\
+ psioops.o\
+ psmathops.o\
+ psmtrxops.o\
+ psmiscops.o\
+ pspntops.o\
+ pspathops.o\
+ pssysops.o\
+ pswinops.o\
+ psopstack.o\
+ psXops.o\
+ psl2ops.o
+
+DPSOPSHEADERFILES = \
+ dpsclrops.h\
+ dpsctrlops.h\
+ dpsctxtops.h\
+ dpsdataops.h\
+ dpsfontops.h\
+ dpsgsttops.h\
+ dpsioops.h\
+ dpsmathops.h\
+ dpsmtrxops.h\
+ dpsmiscops.h\
+ dpsopstack.h\
+ dpspntops.h\
+ dpspathops.h\
+ dpssysops.h\
+ dpswinops.h\
+ dpsXops.h\
+ dpsl2ops.h
+
+PSOPSHEADERFILES = \
+ psclrops.h\
+ psctrlops.h\
+ psctxtops.h\
+ psdataops.h\
+ psfontops.h\
+ psgsttops.h\
+ psioops.h\
+ psmathops.h\
+ psmtrxops.h\
+ psmiscops.h\
+ pspntops.h\
+ pspathops.h\
+ pssysops.h\
+ pswinops.h\
+ psopstack.h\
+ psXops.h\
+ psl2ops.h
+
+DPSOPSCFILES = \
+ dpsclrops.c\
+ dpsctrlops.c\
+ dpsctxtops.c\
+ dpsdataops.c\
+ dpsfontops.c\
+ dpsgsttops.c\
+ dpsioops.c\
+ dpsmathops.c\
+ dpsmtrxops.c\
+ dpsmiscops.c\
+ dpsopstack.c\
+ dpspntops.c\
+ dpspathops.c\
+ dpssysops.c\
+ dpswinops.c\
+ dpsXops.c\
+ dpsl2ops.c
+
+PSOPSCFILES = \
+ psclrops.c\
+ psctrlops.c\
+ psctxtops.c\
+ psdataops.c\
+ psfontops.c\
+ psgsttops.c\
+ psioops.c\
+ psmathops.c\
+ psmtrxops.c\
+ psmiscops.c\
+ pspntops.c\
+ pspathops.c\
+ pssysops.c\
+ pswinops.c\
+ psopstack.c\
+ psXops.c\
+ psl2ops.c
+
+/*
+ * hv: HEADERS must be here, otherwise IncSubdir-triggered BuildIncludes
+ * will fail on systems without ln cmd
+ */
+HEADERS = psops.h dpsops.h
+
+all:: $(HEADERS)
+
+includes:: $(DPSOPSCFILES) $(PSOPSCFILES) $(HEADERS)
+
+$(DPSOPSCFILES) $(PSOPSCFILES): HostProgramTargetName($(PSWRAP))
+
+SRCS = \
+ ${COMMONSOURCEFILES} \
+ ${XSOURCEFILES} \
+ ${XCSDPSSOURCEFILES} \
+ ${DPSOPSCFILES} \
+ ${PSOPSCFILES}
+
+OBJS = \
+ ${COMMONOBJECTFILES} \
+ ${XOBJECTFILES} \
+ ${XCSDPSOBJECTFILES} \
+ ${DPSOPSOBJECTS} \
+ ${PSOPSOBJECTS}
+
+DERIVED_FILES = $(DPSOPSHEADERFILES) $(PSOPSHEADERFILES) \
+ $(DPSOPSCFILES) $(PSOPSCFILES)
+
+#include <Library.tmpl>
+
+.SUFFIXES: .psw .h
+
+.psw.c : HostProgramTargetName($(PSWRAP))
+ RunProgram(PSWRAP,-a -o $*.c -h $*.h $<)
+
+.psw.h : HostProgramTargetName($(PSWRAP))
+ RunProgram(PSWRAP,-a -h $*.h $< > /dev/null)
+
+HostProgramTargetName($(PSWRAP)):
+ @echo "checking $@ over in $(PSWRAPSRC) first..."; \
+ test -d $(PSWRAPSRC) && cd $(PSWRAPSRC) && $(MAKE) pswraponly; \
+ echo "okay, continuing in $(CURRENT_DIR)"
+
+includes :: $(HEADERS)
+depend :: $(DPSOPSCFILES) $(PSOPSCFILES)
+
+psops.h : $(PSOPSHEADERFILES)
+ RemoveFile($@)
+ ${CAT} $(PSOPSHEADERFILES) |\
+ ${SED} -e '/^$$/D' -e '/#/D' -e '/^\//D'\
+ -e '/^ gener/D' -e '/^.\//D' |\
+ ${SORT} > .sort
+ ${AWK} '/;/ {print; printf("\n");}' .sort > .ttt
+ ${CAT} psname.txt header.txt psifdef.txt .ttt psendif.txt > psops.h
+ RemoveFiles(.sort .ttt .attt)
+
+dpsops.h : psops.h $(DPSOPSHEADERFILES)
+ RemoveFile($@)
+ ${CAT} $(DPSOPSHEADERFILES) |\
+ ${SED} -e '/^$$/D' -e '/#/D' -e '/^\//D'\
+ -e '/^ gener/D' -e '/^.\//D' |\
+ ${SORT} > .sort
+ ${AWK} '/;/ {print; printf("\n");}' .sort > .ttt
+ ${CAT} dpsname.txt header.txt dpsifdef.txt .ttt dpsendif.txt > dpsops.h
+ RemoveFiles(.sort .ttt .attt)
+
+clean ::
+ ${RM} $(DERIVED_FILES) .sort .ttt .att psops.h dpsops.h *%
+
+DependTarget()
+
diff --git a/nx-X11/lib/dps/XDPS.c b/nx-X11/lib/dps/XDPS.c
new file mode 100644
index 000000000..5b1614e4c
--- /dev/null
+++ b/nx-X11/lib/dps/XDPS.c
@@ -0,0 +1,2235 @@
+/*
+ * XDPS.c -- implementation of low-level Xlib routines for XDPS extension
+ *
+ * (c) Copyright 1989-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86: xc/lib/dps/XDPS.c,v 1.4tsi Exp $ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+
+#include <stdio.h>
+/* Include this first so that Xasync.h, included from Xlibint.h, can find
+ the definition of NOFILE */
+#include <stdlib.h>
+#include <sys/param.h>
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+
+#include "DPS/XDPS.h"
+#include "DPS/XDPSproto.h"
+#include "DPS/XDPSlib.h"
+#include "DPS/dpsNXargs.h"
+
+#include "cslibint.h"
+#include "dpsassert.h"
+#include "DPSCAPClient.h"
+
+#include "publictypes.h"
+#include "dpsXpriv.h"
+
+/* === DEFINITIONS === */
+
+#ifndef _NFILE
+#define DPSMAXDISPLAYS 128
+#else
+#define DPSMAXDISPLAYS _NFILE
+#endif /* _NFILE */
+
+#define MajorOpCode(dpy) (Codes[DPY_NUMBER(dpy)] ? \
+ Codes[DPY_NUMBER(dpy)]->major_opcode : \
+ Punt())
+
+#define DPSCAP_INITCTXTS 4 /* per display */
+
+/* === TYPES === */
+
+typedef Status (*PSCMProc)(Display *, XEvent *, xEvent *);
+
+typedef struct {
+ char passEvents;
+ char wrapWaiting;
+ char syncMask; /* CSDPS only */
+ char debugMask; /* CSDPS only */
+} DPSDisplayFlags;
+
+/* For now DPSDisplayFlags is no larger than a pointer. Revisit this if the
+ structure grows. */
+
+typedef int (*GenericProcPtrReturnsInt)(Display *);
+
+typedef struct _t_DPSCAPPausedContextData {
+ struct _t_DPSCAPPausedContextData *next;
+ Bool paused;
+ ContextXID cxid;
+ unsigned int seqnum;
+} DPSCAPPausedContextData;
+
+typedef struct {
+ char showSmallSizes;
+ char pixMem;
+} DPSCAPAgentArgs;
+
+typedef struct {
+ void (*Flush)(Display *);
+ int (*Read)(Display*, char*, long);
+ void (*ReadPad)(Display*, char*, long);
+ Status (*Reply)(Display*, xReply*, int, Bool);
+ void (*Send)(Display*, _Xconst char*, long);
+} XDPSLIOProcs;
+
+/* === GLOBALS === */
+
+/* For debugging, allows client to force the library to use an agent */
+int gForceCSDPS = 0;
+
+/* Force all DPS NX protocol requests to flush if CSDPS */
+int gAutoFlush = 1;
+
+/* Force all NX XDPSLGiveInputs to flush independent of gAutoFlush */
+int gForceFlush = 1;
+
+/* Quick check for any paused contexts */
+int gTotalPaused = 0;
+
+/* === LOCALS === */
+
+/* Common stuff */
+static XExtCodes *Codes[DPSMAXDISPLAYS];
+static int version[DPSMAXDISPLAYS];
+static XDPSLEventHandler StatusProc[DPSMAXDISPLAYS];
+static DPSDisplayFlags displayFlags[DPSMAXDISPLAYS];
+static XDPSLEventHandler TextProc = NULL;
+static XDPSLEventHandler ReadyProc[DPSMAXDISPLAYS]; /* L2-DPS/PROTO 9 */
+static int NumberType[DPSMAXDISPLAYS]; /* Garbage okay after dpy closed */
+static char *FloatingName[DPSMAXDISPLAYS]; /* Garbage okay after dpy closed */
+
+/* CSDPS stuff */
+static Display *ShuntMap[DPSMAXDISPLAYS];
+static PSCMProc ClientMsgProc[DPSMAXDISPLAYS];
+static GenericProcPtrReturnsInt AfterProcs[DPSMAXDISPLAYS];
+static DPSCAPPausedContextData *PausedPerDisplay[DPSMAXDISPLAYS];
+static DPSCAPAgentArgs AgentArgs[DPSMAXDISPLAYS];
+static unsigned int LastXRequest[DPSMAXDISPLAYS];
+static int GCFlushMode[DPSMAXDISPLAYS];
+
+#ifdef VMS
+static Display *dpys[DPSMAXDISPLAYS];
+static nextDpy = 0;
+#endif /* VMS */
+
+static void DPSCAPInitGC(Display *dpy, Display *agent, GC gc);
+static Status DPSCAPClientMessageProc(Display *dpy, XEvent *re, xEvent *event);
+static int DPSCAPAfterProc(Display *xdpy);
+static unsigned int DPSCAPSetPause(Display *xdpy, ContextXID cxid);
+static Bool DPSCAPResumeContext(Display *xdpy, ContextXID cxid);
+static Bool WaitForSyncProc(Display *xdpy, XEvent *event, char *arg);
+
+static XDPSLIOProcs xlProcs = { /* Use these for DPS/X extension */
+ _XFlush,
+ _XRead,
+ _XReadPad,
+ _XReply,
+ _XSend
+ };
+
+static XDPSLIOProcs nxlProcs = { /* Use these for NX */
+ N_XFlush,
+ N_XRead,
+ N_XReadPad,
+ N_XReply,
+ N_XSend
+ };
+
+/* === MACROS === */
+
+#define IFNXSETCALL(a, x) call = ((a) != (x)) ? &nxlProcs : &xlProcs
+
+/* === PRIVATE PROCS === */
+
+static int Punt(void)
+{
+ DPSFatalProc(NULL, "Extension has not been initialized");
+ exit(1);
+}
+
+#ifdef VMS
+/* This is a terribly inefficient way to find a per-display index, but we
+ need it till we get dpy->fd fixed in VMS%%%%%*/
+static int FindDpyNum(Display *dpy)
+{
+int i;
+for (i=0; dpys[i] != dpy ; i++)
+ {
+ if (i == nextDpy)
+ {
+ dpys[nextDpy++]=dpy;
+ break;
+ }
+ }
+return i;
+}
+#define DPY_NUMBER(dpy) FindDpyNum(dpy)
+#else /* VMS */
+#define DPY_NUMBER(dpy) ((dpy)->fd)
+#endif /* VMS */
+
+/* === PROCEDURES === */
+
+/* ARGSUSED */
+void
+XDPSLSetTextEventHandler(Display *dpy, XDPSLEventHandler proc)
+{
+ TextProc = proc;
+}
+
+/* ARGSUSED */
+void
+XDPSLCallOutputEventHandler(Display *dpy, XEvent *event)
+{
+ (*TextProc)(event);
+}
+
+void
+XDPSLSetStatusEventHandler(Display *dpy, XDPSLEventHandler proc)
+{
+ StatusProc[DPY_NUMBER(dpy)] = proc;
+}
+
+void
+XDPSLCallStatusEventHandler(Display *dpy, XEvent *event)
+{
+ (*(StatusProc[DPY_NUMBER(dpy)]))(event);
+}
+
+/* Added for L2-DPS/PROTO 9 */
+void
+XDPSLSetReadyEventHandler(Display *dpy, XDPSLEventHandler proc)
+{
+ ReadyProc[DPY_NUMBER(dpy)] = proc;
+}
+
+/* Added for L2-DPS/PROTO 9 */
+void
+XDPSLCallReadyEventHandler(Display *dpy, XEvent *event)
+{
+ (*(ReadyProc[DPY_NUMBER(dpy)]))(event);
+}
+
+/* Added for L2-DPS/PROTO 9 */
+int
+XDPSLGetVersion(Display *dpy)
+{
+ return(version[DPY_NUMBER(dpy)]);
+}
+/* See CSDPS additions for XDPSLSetVersion */
+
+void
+XDPSLInitDisplayFlags(Display *dpy)
+{
+ int d = DPY_NUMBER(dpy);
+ displayFlags[d].wrapWaiting = False;
+
+ /* Instead of explicitly setting the pass-event flag, rely upon the fact
+ that it gets initialized to 0 by the compiler. This means that you
+ can set the event delivery mode on a display before creating any
+ contexts, which is a Good Thing */
+}
+
+XExtCodes *XDPSLGetCodes(Display *dpy)
+{
+ return Codes[DPY_NUMBER(dpy)];
+}
+
+/* ARGSUSED */
+static int
+CloseDisplayProc(Display *dpy, XExtCodes *codes)
+{
+ /* This proc is for native DPS/X only, not CSDPS */
+ Codes[DPY_NUMBER(dpy)] = NULL;
+ /* Clear list */
+ XDPSPrivZapDpy(dpy);
+#ifdef VMS
+ dpys[DPY_NUMBER(dpy)] = NULL;
+ /*%%%%Temp till we fix dpy->fd*/
+#endif /* VMS */
+ return 0; /* return-value is ignored */
+}
+
+Bool
+XDPSLGetPassEventsFlag(Display *dpy)
+{
+ return displayFlags[DPY_NUMBER(dpy)].passEvents;
+}
+
+void
+XDPSLSetPassEventsFlag(Display *dpy, Bool flag)
+{
+ displayFlags[DPY_NUMBER(dpy)].passEvents = flag;
+}
+
+Bool
+XDPSLGetWrapWaitingFlag(Display *dpy)
+{
+ return displayFlags[DPY_NUMBER(dpy)].wrapWaiting;
+}
+
+void
+XDPSLSetWrapWaitingFlag(Display *dpy, Bool flag)
+{
+ displayFlags[DPY_NUMBER(dpy)].wrapWaiting = flag;
+}
+
+static Status
+ConvertOutputEvent(Display *dpy, XEvent *ce, xEvent *we)
+{
+ register PSOutputEvent *wireevent = (PSOutputEvent *) we;
+ register XDPSLOutputEvent *clientevent = (XDPSLOutputEvent *) ce;
+
+ clientevent->type = wireevent->type & 0x7f;
+ clientevent->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)wireevent);
+ clientevent->send_event = (wireevent->type & 0x80) != 0;
+ clientevent->display = dpy;
+ clientevent->cxid = wireevent->cxid;
+ clientevent->length = wireevent->length;
+ bcopy((char *) wireevent->data, clientevent->data, wireevent->length);
+ if (TextProc && !XDPSLGetPassEventsFlag(dpy)) {
+ (*TextProc)((XEvent *) clientevent);
+ return False;
+ }
+ return True;
+}
+
+static Status
+ConvertStatusEvent(Display *dpy, XEvent *ce, xEvent *we)
+{
+ register PSStatusEvent *wireevent = (PSStatusEvent *) we;
+ register XDPSLStatusEvent *clientevent = (XDPSLStatusEvent *) ce;
+
+ clientevent->type = wireevent->type & 0x7f;
+ clientevent->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)wireevent);
+ clientevent->send_event = (wireevent->type & 0x80) != 0;
+ clientevent->display = dpy;
+ clientevent->cxid = wireevent->cxid;
+ clientevent->status = wireevent->status;
+ if (StatusProc[DPY_NUMBER(dpy)] && !XDPSLGetPassEventsFlag(dpy)) {
+ (*(StatusProc[DPY_NUMBER(dpy)]))((XEvent *) clientevent);
+ return False;
+ }
+ return True;
+}
+
+/* Added for L2-DPS/PROTO 9 */
+static Status
+ConvertReadyEvent(Display *dpy, XEvent *ce, xEvent *we)
+{
+ register PSReadyEvent *wireevent = (PSReadyEvent *) we;
+ register XDPSLReadyEvent *clientevent = (XDPSLReadyEvent *) ce;
+
+ clientevent->type = wireevent->type & 0x7f;
+ clientevent->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)wireevent);
+ clientevent->send_event = (wireevent->type & 0x80) != 0;
+ clientevent->display = dpy;
+ clientevent->cxid = wireevent->cxid;
+ clientevent->val[0] = wireevent->val1;
+ clientevent->val[1] = wireevent->val2;
+ clientevent->val[2] = wireevent->val3;
+ clientevent->val[3] = wireevent->val4;
+ if (ReadyProc[DPY_NUMBER(dpy)] && !XDPSLGetPassEventsFlag(dpy)) {
+ (*(ReadyProc[DPY_NUMBER(dpy)]))((XEvent *) clientevent);
+ return False;
+ }
+ return True;
+}
+
+/* Added for L2-DPS/PROTO 9 */
+/* ARGSUSED */
+
+static int
+CatchBadMatch(Display *dpy, xError *err, XExtCodes *codes, int *ret_code)
+{
+ if (err->errorCode == BadMatch)
+ {
+ *ret_code = 0;
+ return 1; /* suppress error */
+ }
+ else
+ {
+ *ret_code = 1;
+ return 0; /* pass error along */
+ }
+}
+
+
+int
+XDPSLInit(
+ Display *dpy,
+ int *numberType, /* RETURN */
+ char **floatingName) /* RETURN: CALLER MUST NOT MODIFY OR FREE! */
+{
+ XExtCodes *codes = (XExtCodes *)NULL;
+ register xPSInitReq *req;
+ xPSInitReply rep;
+ char *ptr;
+ int first_event;
+
+ {
+ char *ddt;
+
+ if ((ddt = getenv("DPSNXOVER")) != NULL) {
+ gForceCSDPS = (*ddt == 't' || *ddt == 'T');
+ if (gForceCSDPS)
+ DPSWarnProc(NULL, "*** USING DPS NX ***");
+ }
+ }
+
+ if ((codes = Codes[DPY_NUMBER(dpy)]) != NULL) {
+ if (numberType)
+ *numberType = NumberType[DPY_NUMBER(dpy)];
+ if (floatingName)
+ *floatingName = FloatingName[DPY_NUMBER(dpy)];
+ return codes->first_event;
+ } else {
+ if (gForceCSDPS)
+ goto try_dps_nx;
+ codes = XInitExtension(dpy, DPSNAME);
+ if (codes == NULL) {
+ /* try DEC UWS 2.2 server */
+ codes = XInitExtension(dpy, DECDPSNAME);
+try_dps_nx:
+ if (codes == NULL) {
+ int myNumberType;
+ char *myFloatingName;
+
+ first_event = CSDPSInit(dpy, &myNumberType, &myFloatingName);
+ NumberType[DPY_NUMBER(dpy)] = myNumberType;
+ FloatingName[DPY_NUMBER(dpy)] = myFloatingName;
+ if (numberType)
+ *numberType = myNumberType;
+ if (floatingName)
+ *floatingName = myFloatingName;
+ return first_event;
+ }
+ }
+ Codes[DPY_NUMBER(dpy)] = codes;
+ ShuntMap[DPY_NUMBER(dpy)] = dpy;
+ /* set procs for native DPS/X */
+ XESetCloseDisplay(dpy, codes->extension, CloseDisplayProc);
+ XESetWireToEvent(dpy, codes->first_event + PSEVENTOUTPUT,
+ ConvertOutputEvent);
+ XESetWireToEvent(dpy, codes->first_event + PSEVENTSTATUS,
+ ConvertStatusEvent);
+ XESetWireToEvent(dpy, codes->first_event + PSEVENTREADY,
+ ConvertReadyEvent);
+ first_event = codes->first_event;
+ }
+
+ /* We have to handle a BadMatch error, in the case where
+ the client has a later (higher) version of
+ the protocol than the server */
+ {
+ int (*oldErrorProc)(Display*, xError*, XExtCodes*, int*);
+ int libVersion;
+ Bool doneIt;
+
+ XSync(dpy, False);
+ LockDisplay(dpy);
+ oldErrorProc = XESetError(dpy, codes->extension, CatchBadMatch);
+ libVersion = DPSPROTOCOLVERSION;
+ doneIt = False;
+ while (libVersion >= DPSPROTO_OLDEST)
+ {
+ GetReq(PSInit, req);
+ req->reqType = MajorOpCode(dpy);
+ req->dpsReqType = X_PSInit;
+ req->libraryversion = libVersion;
+ if (_XReply(dpy, (xReply *) &rep, 0, xFalse))
+ {
+ doneIt = True;
+ break;
+ }
+ /* otherwise, try previous version */
+ --libVersion;
+ }
+ oldErrorProc = XESetError(dpy, codes->extension, oldErrorProc);
+ if (!doneIt)
+ {
+ DPSFatalProc(NULL, "Incompatible protocol versions");
+ exit(1);
+ }
+
+ /* NOTE *************************************************
+ We made a boo-boo in the 1007.2 and earlier versions of
+ our X server glue code. Instead of sending a
+ BadMatch error if the client's version is newer (higher)
+ than the server's, it just replies with success. We
+ could test for that situation here by looking at
+ rep.serverversion, but it turns out that we don't need
+ to do anything special. Since rep.serverversion gets
+ assigned to our version[] array, it is as if we handled
+ the BadMatch correctly. Just for safety's sake, we'll
+ do some bulletproofing here instead.
+ Fixes 2ps_xdps BUG #6 */
+
+ else if (rep.serverversion < DPSPROTO_OLDEST
+ || rep.serverversion > DPSPROTOCOLVERSION)
+ {
+ DPSFatalProc(NULL, "Server replied with bogus version");
+ exit(1);
+ }
+ }
+
+ version[DPY_NUMBER(dpy)] = rep.serverversion;
+ NumberType[DPY_NUMBER(dpy)] = rep.preferredNumberFormat;
+ if (numberType)
+ *numberType = rep.preferredNumberFormat;
+
+ ptr = (char *) Xmalloc(rep.floatingNameLength + 1);
+ _XReadPad(dpy, ptr, rep.floatingNameLength);
+ ptr[rep.floatingNameLength] = 0;
+ FloatingName[DPY_NUMBER(dpy)] = ptr;
+ if (floatingName)
+ *floatingName = ptr;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return first_event;
+}
+
+
+
+
+static void CopyColorMapsIntoCreateContextReq(
+ xPSCreateContextReq *req,
+ XStandardColormap *colorcube,
+ XStandardColormap *grayramp)
+{
+ req->cmap = 0;
+ if (colorcube != NULL) {
+ req->cmap = colorcube->colormap;
+ req->redmax = colorcube->red_max;
+ req->redmult = colorcube->red_mult;
+ req->greenmax = colorcube->green_max;
+ req->greenmult = colorcube->green_mult;
+ req->bluemax = colorcube->blue_max;
+ req->bluemult = colorcube->blue_mult;
+ req->colorbase = colorcube->base_pixel;
+ }
+ else {
+ req->redmult = 0;
+ /* The rest of this shouldn't be necessary, but there are some
+ servers out there that erroneously check the other fields
+ even when redmult is 0 */
+ req->redmax = 0;
+ req->greenmult = 0;
+ req->greenmax = 0;
+ req->bluemult = 0;
+ req->bluemax = 0;
+ req->colorbase = 0;
+ }
+
+ if (grayramp != NULL) {
+ req->cmap = grayramp->colormap;
+ req->graymax = grayramp->red_max;
+ req->graymult = grayramp->red_mult;
+ req->graybase = grayramp->base_pixel;
+ }
+ else req->graymult = 0;
+}
+
+
+
+
+
+
+/* ARGSUSED */
+ContextXID
+XDPSLCreateContextAndSpace(
+ register Display *xdpy,
+ Drawable draw,
+ GC gc,
+ int x, int y,
+ unsigned int eventMask,
+ XStandardColormap *grayRamp,
+ XStandardColormap *colorCube,
+ unsigned int actual,
+ ContextPSID *cpsid, /* RETURN */
+ SpaceXID *sxid, /* RETURN */
+ Bool secure) /* Added for L2-DPS/PROTO 9 */
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ ContextXID cxid;
+ register xPSCreateContextReq *req; /* Same struct for CreateSecureContext */
+ xPSCreateContextReply rep;
+ XStandardColormap defColorcube, defGrayramp;
+ XStandardColormap *requestCube, *requestRamp;
+ int index;
+ XDPSLIOProcs *call;
+
+ if (grayRamp == NULL && colorCube == NULL) return(None);
+
+ if (secure && version[dpyix] < DPSPROTO_V09)
+ return(None); /* No secure contexts before PROTO 9 */
+
+ /* Index gets encoded as follows:
+ *
+ * 0 grayRamp = Default, colorCube = Default
+ * 1 grayRamp = non-Default, colorcube = Default
+ * 2 grayRamp = Default, colorcube = non-Default
+ * 3 grayRamp = non-Default, colorcube = non-Default
+ *
+ */
+ index = ((grayRamp == DefaultStdCMap || grayRamp == NULL) ? 0 : 1) +
+ (colorCube == DefaultStdCMap ? 0 : 2);
+
+ switch (index)
+ {
+ default:
+ case 0: /* Both are default */
+ XDPSGetDefaultColorMaps(xdpy, (Screen *) NULL, draw,
+ &defColorcube, &defGrayramp);
+ requestCube = &defColorcube;
+ requestRamp = &defGrayramp;
+ break;
+
+ case 1: /* gray specified, Color default */
+ XDPSGetDefaultColorMaps(xdpy, (Screen *) NULL, draw,
+ &defColorcube, (XStandardColormap *) NULL);
+ requestCube = &defColorcube;
+ requestRamp = grayRamp;
+ break;
+
+ case 2: /* gray default, Color specified */
+ XDPSGetDefaultColorMaps(xdpy, (Screen *) NULL, draw,
+ (XStandardColormap *) NULL, &defGrayramp);
+ requestCube = colorCube;
+ requestRamp = &defGrayramp;
+ break;
+
+ case 3: /* Both specified */
+ requestCube = colorCube;
+ requestRamp = grayRamp;
+ break;
+ }
+
+ if (gc != NULL)
+ XDPSLFlushGC(xdpy, gc);
+ if (dpy != xdpy)
+ {
+ int syncMask = displayFlags[dpyix].syncMask;
+
+ /* Don't worry about pauses here, since we are just
+ now creating the context! */
+ if (syncMask & (DPSCAP_SYNCMASK_SYNC|DPSCAP_SYNCMASK_RECONCILE))
+ XSync(xdpy, False);
+ }
+ LockDisplay(dpy);
+
+ NXMacroGetReq(PSCreateContext, req);
+ CopyColorMapsIntoCreateContextReq(req, requestCube, requestRamp);
+
+ req->reqType = MajorOpCode(xdpy);
+ req->dpsReqType = (secure) ? X_PSCreateSecureContext : X_PSCreateContext;
+ req->x = x;
+ req->y = y;
+ req->drawable = draw;
+ req->gc = (gc != NULL) ? XGContextFromGC(gc) : None;
+ cxid = req->cxid = XAllocID(xdpy);
+ req->sxid = XAllocID(xdpy);
+ if (sxid)
+ *sxid = req->sxid;
+ req->eventmask = 0; /* %%% */
+ req->actual = actual;
+ IFNXSETCALL(dpy, xdpy);
+ (void) (*call->Reply) (dpy, (xReply *)&rep, 0, xTrue);
+
+ if (cpsid)
+ *cpsid = (int)rep.cpsid;
+
+ UnlockDisplay(dpy);
+ /* If the context creation succeeded and we are CSDPS, send GC values */
+ if (rep.cpsid && xdpy != dpy && gc != NULL)
+ {
+ DPSCAPInitGC(xdpy, dpy, gc);
+ }
+ SyncHandle();
+
+ if (dpy != xdpy)
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+ return (cxid);
+}
+
+
+/* ARGSUSED */
+ContextXID
+XDPSLCreateContext(
+ register Display *xdpy,
+ SpaceXID sxid,
+ Drawable draw,
+ GC gc,
+ int x, int y,
+ unsigned int eventMask,
+ XStandardColormap *grayRamp,
+ XStandardColormap *colorCube,
+ unsigned int actual,
+ ContextPSID *cpsid, /* RETURN */
+ Bool secure) /* L2-DPS/PROTO 9 addition */
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ register xPSCreateContextReq *req;
+ xPSCreateContextReply rep;
+ ContextXID cxid; /* RETURN */
+ XStandardColormap defColorcube, defGrayramp;
+ XStandardColormap *requestCube, *requestRamp;
+ int index;
+ XDPSLIOProcs *call;
+
+ if (secure && version[dpyix] < DPSPROTO_V09)
+ return(None); /* No secure contexts before PROTO 9 */
+
+ /* Index gets encoded as follows:
+ *
+ * 0 grayRamp = Default, colorCube = Default
+ * 1 grayRamp = non-Default, colorcube = Default
+ * 2 grayRamp = Default, colorcube = non-Default
+ * 3 grayRamp = non-Default, colorcube = non-Default
+ *
+ * Note that only the first or last case should ever happen.
+ */
+ index = ((grayRamp == DefaultStdCMap) ? 0 : 1) +
+ ((colorCube == DefaultStdCMap) ? 0 : 2);
+
+ switch (index)
+ {
+ default:
+ case 0: /* Both are default */
+ XDPSGetDefaultColorMaps(xdpy, (Screen *) NULL, draw,
+ &defColorcube, &defGrayramp);
+ requestCube = &defColorcube;
+ requestRamp = &defGrayramp;
+ break;
+
+ case 1: /* gray specified, Color default */
+ XDPSGetDefaultColorMaps(xdpy, (Screen *) NULL, draw,
+ &defColorcube, (XStandardColormap *) NULL);
+ requestCube = &defColorcube;
+ requestRamp = grayRamp;
+ break;
+
+ case 2: /* gray default, Color specified */
+ XDPSGetDefaultColorMaps(xdpy, (Screen *) NULL, draw,
+ (XStandardColormap *) NULL, &defGrayramp);
+ requestCube = colorCube;
+ requestRamp = &defGrayramp;
+ break;
+
+ case 3: /* Both specified */
+ requestCube = colorCube;
+ requestRamp = grayRamp;
+ break;
+ }
+
+
+ if (gc != NULL)
+ XDPSLFlushGC(xdpy, gc);
+ if (dpy != xdpy)
+ {
+ int syncMask = displayFlags[dpyix].syncMask;
+
+ /* Don't worry about pauses here, since we are
+ just now creating this context! */
+ if (syncMask & (DPSCAP_SYNCMASK_SYNC|DPSCAP_SYNCMASK_RECONCILE))
+ XSync(xdpy, False);
+ }
+ LockDisplay(dpy);
+
+ NXMacroGetReq(PSCreateContext, req);
+ CopyColorMapsIntoCreateContextReq(req, requestCube, requestRamp);
+
+ req->reqType = MajorOpCode(xdpy);
+ req->dpsReqType = (secure) ? X_PSCreateSecureContext : X_PSCreateContext;
+ req->x = x;
+ req->y = y;
+ req->drawable = draw;
+ req->gc = (gc != NULL) ? XGContextFromGC(gc) : None;
+ cxid = req->cxid = XAllocID(xdpy);
+ req->sxid = sxid;
+ req->actual = actual;
+
+ IFNXSETCALL(dpy, xdpy);
+ (void) (*call->Reply) (dpy, (xReply *)&rep, 0, xTrue);
+ if (cpsid)
+ *cpsid = (int)rep.cpsid;
+
+ UnlockDisplay(dpy);
+ /* If the context creation succeeded and we are CSDPS, send GC values */
+ if (rep.cpsid && xdpy != dpy && gc != NULL)
+ {
+ DPSCAPInitGC(xdpy, dpy, gc);
+ }
+
+ SyncHandle();
+
+ if (dpy != xdpy)
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+ return cxid;
+}
+
+SpaceXID
+XDPSLCreateSpace(Display *xdpy)
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ register xPSCreateSpaceReq *req;
+ SpaceXID sxid;
+
+ LockDisplay(dpy);
+
+ NXMacroGetReq(PSCreateSpace, req);
+ req->reqType = MajorOpCode(xdpy);
+ req->dpsReqType = X_PSCreateSpace;
+ sxid = req->sxid = XAllocID(xdpy);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (dpy != xdpy)
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+ return sxid;
+}
+
+
+
+/*
+ * I'm not sure how portable my coalescing code is, so I've provided the
+ * below define. If it turns out this code just breaks somewhere, you
+ * can simply undefine COALESCEGIVEINPUT, and then everything will work
+ * (but slower). 6/16/89 (tw)
+ */
+
+#define COALESCEGIVEINPUT
+
+void
+XDPSLGiveInput(Display *xdpy, ContextXID cxid, char *data, int length)
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ register xPSGiveInputReq *req;
+ Bool didFlush = False;
+
+ if (dpy != xdpy)
+ {
+ register int syncMask = displayFlags[dpyix].syncMask;
+
+ if (syncMask & DPSCAP_SYNCMASK_RECONCILE)
+ {
+ XDPSLReconcileRequests(xdpy, cxid);
+ didFlush = True;
+ }
+
+ /* If this context got paused, no matter how, ignore
+ mode and resume it */
+ if (gTotalPaused && DPSCAPResumeContext(xdpy, cxid))
+ {
+ /* xdpy was flushed by DPSCAPResumeContext */
+ if (!didFlush)
+ {
+ N_XFlush(dpy);
+ didFlush = True;
+ }
+ }
+ else if (syncMask & DPSCAP_SYNCMASK_SYNC)
+ {
+ didFlush = True;
+ XSync(xdpy, False);
+ }
+ }
+ LockDisplay(dpy);
+
+#ifdef COALESCEGIVEINPUT
+ req = (xPSGiveInputReq *) dpy->last_req;
+ if (req->reqType == MajorOpCode(xdpy)
+ && req->dpsReqType == X_PSGiveInput
+ && req->cxid == cxid
+ && dpy->bufptr + length + 3 < dpy->bufmax) {
+ bcopy(data, ((char *) req) + sizeof(xPSGiveInputReq) + req->nunits,
+ length);
+ req->nunits += length;
+ req->length = (sizeof(xPSGiveInputReq) + req->nunits + 3) >> 2;
+ dpy->bufptr = dpy->last_req + sizeof(xPSGiveInputReq) +
+ ((req->nunits + 3) & ~3);
+ } else
+#endif /* COALESCEGIVEINPUT */
+ {
+ int flushOnce = 1;
+ int maxedOutLen = xdpy->max_request_size - sizeof(xPSGiveInputReq) - 4;
+ int nunits;
+
+ /* We have the rare opportunity to chop up a buffer that is larger
+ than the max request size into separate requests, unlike
+ most other X requests (such as DrawText). The -4 is to
+ force these maxed out requests to be less than the maximum
+ padding that would ever be needed, and to minimize padding
+ in the case where the input buffer is several times
+ larger than max request length. */
+
+ nunits = maxedOutLen;
+ do {
+ if (length < maxedOutLen)
+ nunits = length; /* Normal size block */
+ NXMacroGetReq(PSGiveInput, req);
+ req->reqType = MajorOpCode(xdpy);
+ req->dpsReqType = X_PSGiveInput;
+ req->cxid = cxid;
+ req->nunits = nunits;
+ req->length += ((nunits + 3) >> 2);
+ if (dpy != xdpy) {
+ if (flushOnce && !didFlush) {
+ LockDisplay(xdpy);
+ _XFlush(xdpy);
+ UnlockDisplay(xdpy);
+ flushOnce = 0;
+ }
+ NXProcData(dpy, (char *) data, nunits);
+ } else
+ {Data(dpy, (char *) data, nunits);}
+ data += nunits;
+ length -= nunits;
+ } while (length);
+ }
+
+ /* In the NX case (didFlush is always False for the non-NX case),
+ the xdpy may have been flushed, but there is stuff left
+ buffered in dpy (NX connection). We can't leave the stuff
+ there, since we may never call a DPS routine again. Until
+ we can be notified about xdpy being flushed, we have to
+ clear out the dpy buffer after we cleared out the xdpy
+ buffer (didFlush == True). */
+
+ if (dpy != xdpy
+ && dpy->bufptr != dpy->buffer
+ && (gForceFlush || didFlush))
+ N_XFlush(dpy);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (dpy != xdpy)
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+}
+
+
+int
+XDPSLGetStatus(Display *xdpy, ContextXID cxid)
+{
+ int dpyix;
+ Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ register xPSGetStatusReq *req;
+ xPSGetStatusReply rep;
+ XDPSLIOProcs *call;
+
+ if (dpy != xdpy)
+ {
+ register int syncMask = displayFlags[dpyix].syncMask;
+
+ /* ASSERT: There is no reason to pause the context for this
+ request, so just sync. */
+ if (syncMask & (DPSCAP_SYNCMASK_SYNC|DPSCAP_SYNCMASK_RECONCILE))
+ XSync(xdpy, False);
+ }
+ LockDisplay(dpy);
+
+ NXMacroGetReq(PSGetStatus, req);
+ req->reqType = MajorOpCode(xdpy);
+ req->dpsReqType = X_PSGetStatus;
+ req->cxid = cxid;
+ req->notifyIfChange = 0;
+
+ IFNXSETCALL(dpy, xdpy);
+ if (! (*call->Reply)(dpy, (xReply *)&rep, 0, xTrue))
+ rep.status = PSSTATUSERROR;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ /* For CSDPS, guarantee that status events arrive just like DPS/X */
+ if (dpy != xdpy)
+ {
+ XDPSLSync(xdpy);
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+ }
+ return (int) rep.status;
+}
+
+void
+XDPSLDestroySpace(Display *xdpy, SpaceXID sxid)
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ register xPSDestroySpaceReq *req;
+
+ if (dpy != xdpy)
+ {
+ int syncMask = displayFlags[dpyix].syncMask;
+
+ /* ASSERT: There is no reason to pause the context for this
+ request, so just sync. */
+ if (syncMask & (DPSCAP_SYNCMASK_SYNC|DPSCAP_SYNCMASK_RECONCILE))
+ XSync(xdpy, False);
+ }
+ LockDisplay(dpy);
+
+ NXMacroGetReq(PSDestroySpace, req);
+ req->reqType = MajorOpCode(xdpy);
+ req->dpsReqType = X_PSDestroySpace;
+ req->sxid = sxid;
+
+ if (gAutoFlush && dpy != xdpy)
+ {
+ N_XFlush(dpy);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (dpy != xdpy)
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+}
+
+
+void
+XDPSLReset(Display *xdpy, ContextXID cxid)
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ register xPSResetReq *req;
+
+ if (dpy != xdpy)
+ {
+ register int syncMask = displayFlags[dpyix].syncMask;
+
+ /* ASSERT: There is no reason to pause the context for this
+ request, so just sync. */
+ if (syncMask & (DPSCAP_SYNCMASK_SYNC|DPSCAP_SYNCMASK_RECONCILE))
+ XSync(xdpy, False);
+ }
+ LockDisplay(dpy);
+
+ NXMacroGetReq(PSReset, req);
+ req->reqType = MajorOpCode(xdpy);
+ req->dpsReqType = X_PSReset;
+ req->cxid = cxid;
+
+ if (gAutoFlush && dpy != xdpy)
+ {
+ N_XFlush(dpy);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (dpy != xdpy)
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+}
+
+void
+XDPSLNotifyContext(
+ Display *xdpy,
+ ContextXID cxid,
+ int ntype) /* should this be an enum?? %%% */
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ register xPSNotifyContextReq *req;
+
+ if (dpy != xdpy)
+ {
+ register int syncMask = displayFlags[dpyix].syncMask;
+
+ /* ASSERT: There is no reason to pause the context for this
+ request, so just sync. */
+ if (syncMask & (DPSCAP_SYNCMASK_SYNC|DPSCAP_SYNCMASK_RECONCILE))
+ XSync(xdpy, False);
+ }
+ LockDisplay(dpy);
+
+ NXMacroGetReq(PSNotifyContext, req);
+ req->reqType = MajorOpCode(xdpy);
+ req->dpsReqType = X_PSNotifyContext;
+ req->cxid = cxid;
+ req->notifyType = ntype;
+
+ if (dpy != xdpy)
+ {
+ N_XFlush(dpy); /* THIS IS CRITICAL TO AVOID HANGING! */
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (dpy != xdpy)
+ {
+ if (ntype == PSKILL)
+ XDPSLCleanContext(xdpy, cxid);
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+ }
+}
+
+
+ContextXID
+XDPSLCreateContextFromID(
+ Display *xdpy,
+ ContextPSID cpsid,
+ SpaceXID *sxid) /* RETURN */
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ register xPSCreateContextFromIDReq *req;
+ xPSCreateContextFromIDReply rep;
+ ContextXID cxid;
+ XDPSLIOProcs *call;
+
+ if (dpy != xdpy)
+ {
+ int syncMask = displayFlags[dpyix].syncMask;
+
+ /* ASSERT: There is no reason to pause the context for this
+ request, so just sync. */
+ if (syncMask & (DPSCAP_SYNCMASK_SYNC|DPSCAP_SYNCMASK_RECONCILE))
+ XSync(xdpy, False);
+ }
+ LockDisplay(dpy);
+
+ NXMacroGetReq(PSCreateContextFromID, req);
+ req->reqType = MajorOpCode(xdpy);
+ req->dpsReqType = X_PSCreateContextFromID;
+ req->cpsid = cpsid;
+ cxid = req->cxid = XAllocID(xdpy);
+
+ IFNXSETCALL(dpy, xdpy);
+ (void) (*call->Reply) (dpy, (xReply *)&rep, 0, xTrue);
+ if (sxid)
+ *sxid = (int)rep.sxid;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (dpy != xdpy)
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+ return(cxid);
+}
+
+
+/* Returns 1 on success, 0 on failure (cpsid not a valid context). */
+
+Status
+XDPSLIDFromContext(
+ Display *xdpy,
+ ContextPSID cpsid,
+ ContextXID *cxid, /* RETURN */
+ SpaceXID *sxid) /* RETURN */
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ register xPSXIDFromContextReq *req;
+ xPSXIDFromContextReply rep;
+ XDPSLIOProcs *call;
+
+ if (dpy != xdpy)
+ {
+ int syncMask = displayFlags[dpyix].syncMask;
+
+ /* ASSERT: There is no reason to pause the context for this
+ request, so just sync. */
+ if (syncMask & (DPSCAP_SYNCMASK_SYNC|DPSCAP_SYNCMASK_RECONCILE))
+ XSync(xdpy, False);
+ }
+ LockDisplay(dpy);
+
+ NXMacroGetReq(PSXIDFromContext, req);
+ req->reqType = MajorOpCode(xdpy);
+ req->dpsReqType = X_PSXIDFromContext;
+ req->cpsid = cpsid;
+
+ IFNXSETCALL(dpy, xdpy);
+ (void) (*call->Reply) (dpy, (xReply *)&rep, 0, xTrue);
+ *sxid = (int)rep.sxid;
+ *cxid = (int)rep.cxid;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (dpy != xdpy)
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+ return((Status)(*sxid != None && *cxid != None));
+}
+
+
+ContextPSID
+XDPSLContextFromXID(Display *xdpy, ContextXID cxid)
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ register xPSContextFromXIDReq *req;
+ xPSContextFromXIDReply rep;
+ XDPSLIOProcs *call;
+
+ if (dpy != xdpy)
+ {
+ int syncMask = displayFlags[dpyix].syncMask;
+
+ /* ASSERT: There is no reason to pause the context for this
+ request, so just sync. */
+ if (syncMask & (DPSCAP_SYNCMASK_SYNC|DPSCAP_SYNCMASK_RECONCILE))
+ XSync(xdpy, False);
+ }
+ LockDisplay(dpy);
+
+ NXMacroGetReq(PSContextFromXID, req);
+ req->reqType = MajorOpCode(xdpy);
+ req->dpsReqType = X_PSContextFromXID;
+ req->cxid = cxid;
+
+ IFNXSETCALL(dpy, xdpy);
+ (void) (*call->Reply) (dpy, (xReply *)&rep, 0, xTrue);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (dpy != xdpy)
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+ return (int)rep.cpsid;
+}
+
+
+void
+XDPSLSetStatusMask(
+ Display *xdpy,
+ ContextXID cxid,
+ unsigned int enableMask,
+ unsigned int disableMask,
+ unsigned int nextMask)
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ register xPSSetStatusMaskReq *req;
+
+ if (dpy != xdpy)
+ {
+ register int syncMask = displayFlags[dpyix].syncMask;
+
+ /* ASSERT: There is no reason to pause the context for this
+ request, so just sync. */
+ if (syncMask & (DPSCAP_SYNCMASK_SYNC|DPSCAP_SYNCMASK_RECONCILE))
+ XSync(xdpy, False);
+ }
+ LockDisplay(dpy);
+
+ NXMacroGetReq(PSSetStatusMask, req);
+ req->reqType = MajorOpCode(xdpy);
+ req->dpsReqType = X_PSSetStatusMask;
+ req->cxid = cxid;
+ req->enableMask = enableMask;
+ req->disableMask = disableMask;
+ req->nextMask = nextMask;
+
+ if (gAutoFlush && dpy != xdpy)
+ {
+ N_XFlush(dpy);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (dpy != xdpy)
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+}
+
+
+#ifdef VMS
+/*
+ * _XReadPad - Read bytes from the socket taking into account incomplete
+ * reads. If the number of bytes is not 0 mod 32, read additional pad
+ * bytes. This routine may have to be reworked if int < long.
+ */
+
+/* This is really in xlib, but is not in the sharable image transfer vector
+ * so I am copying it here for now. BF
+
+The following notice applies only to the functions
+_XReadPad and XFlush
+
+Copyright 1985, 1986, 1987, 1988, 1989 by the
+Massachusetts Institute of Technology
+
+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 of M.I.T. not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+written prior permission. M.I.T. makes no representations about the
+suitability of this software for any purpose. It is provided "as is"
+without express or implied warranty.
+
+*/
+void
+_XReadPad (Display *dpy, char *data, long size)
+{
+ static int padlength[4] = {0,3,2,1};
+ register long bytes_read;
+ char pad[3];
+
+ CheckLock(dpy);
+ if (size == 0) return;
+ _XRead( dpy, data, size );
+ if ( padlength[size & 3] ) {
+ _XRead( dpy, pad, padlength[size & 3] );
+ }
+
+}
+#endif /* VMS */
+
+/* _____________ LEVEL 2 DPS/PROTOCOL 9 ADDITIONS _____________ */
+
+void
+XDPSLNotifyWhenReady(
+ Display *xdpy,
+ ContextXID cxid,
+ int val[4])
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ register xPSNotifyWhenReadyReq *req;
+
+ if (version[dpyix] < DPSPROTO_V09)
+ {
+ DPSWarnProc(NULL, "Attempted use of XDPSLNotifyWhenReady with incompatible server ignored");
+ return; /* PROTO 9 or later only */
+ }
+
+ if (dpy != xdpy)
+ {
+ register int syncMask = displayFlags[dpyix].syncMask;
+
+ if (syncMask & DPSCAP_SYNCMASK_RECONCILE)
+ XDPSLReconcileRequests(xdpy, cxid);
+
+ /* If this context got paused, no matter how, ignore
+ mode and resume it */
+ if (gTotalPaused && DPSCAPResumeContext(xdpy, cxid))
+ {
+ /* xdpy was flushed by DPSCAPResumeContext */
+ if (gAutoFlush)
+ N_XFlush(dpy);
+ }
+ else if (syncMask & DPSCAP_SYNCMASK_SYNC)
+ XSync(xdpy, False);
+ }
+ LockDisplay(dpy);
+
+ NXMacroGetReq(PSNotifyWhenReady, req);
+ req->reqType = MajorOpCode(xdpy);
+ req->dpsReqType = X_PSNotifyWhenReady;
+ req->cxid = cxid;
+ req->val1 = val[0];
+ req->val2 = val[1];
+ req->val3 = val[2];
+ req->val4 = val[3];
+
+ if (gAutoFlush && dpy != xdpy)
+ {
+ N_XFlush(dpy);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (dpy != xdpy)
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+}
+
+XDPSLPSErrors
+XDPSLTestErrorCode(Display *dpy, int ecode)
+{
+ XExtCodes *c = XDPSLGetCodes(dpy);
+
+ if (c == NULL)
+ return not_pserror;
+
+ switch (ecode - c->first_error)
+ {
+ case PSERRORBADCONTEXT: return(pserror_badcontext);
+ case PSERRORBADSPACE: return(pserror_badspace);
+ case PSERRORABORT:
+ if (version[DPY_NUMBER(dpy)] < DPSPROTO_V09)
+ return(not_pserror);
+ else
+ return(pserror_abort);
+ default: return(not_pserror);
+ }
+}
+
+/* _____________ CLIENT SIDE DPS ADDITIONS _____________ */
+
+/* === NEW HOOKS INTO XDPS === */
+
+void
+XDPSLSetVersion(Display *dpy, unsigned ver)
+{
+ version[DPY_NUMBER(dpy)] = ver;
+}
+
+void
+XDPSLSetCodes(Display *dpy, XExtCodes *codes)
+{
+ Codes[DPY_NUMBER(dpy)] = codes;
+}
+
+Display *
+XDPSLGetShunt(Display *dpy_in)
+{
+ return(ShuntMap[DPY_NUMBER(dpy_in)]);
+}
+
+void
+XDPSLSetShunt(Display *dpy_in, Display *dpy_out)
+{
+ ShuntMap[DPY_NUMBER(dpy_in)] = dpy_out;
+}
+
+int
+XDPSLGetSyncMask(Display *dpy)
+{
+ return (int)displayFlags[DPY_NUMBER(dpy)].syncMask;
+}
+
+void
+XDPSLSetSyncMask(Display *dpy, int mask)
+{
+ displayFlags[DPY_NUMBER(dpy)].syncMask = (char)mask;
+ gForceFlush = (mask & DPSCAP_SYNCMASK_RECONCILE);
+}
+
+void
+XDPSLFlush(Display *xdpy)
+{
+ register Display *dpy = ShuntMap[DPY_NUMBER(xdpy)];
+
+ _XFlush(xdpy);
+ if (dpy != xdpy)
+ N_XFlush(dpy);
+}
+
+void
+XDPSLSyncGCClip(Display *xdpy, GC gc)
+{
+ register unsigned long oldDirty;
+ register int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+
+ /* We DON'T want to notice all gc changes, just the clip */
+ oldDirty = gc->dirty;
+ gc->dirty = (GCClipXOrigin|GCClipYOrigin);
+ XDPSLFlushGC(xdpy, gc);
+ gc->dirty = oldDirty;
+ if (dpy == xdpy || gNXSyncGCMode != 1) /* 1 means sync always */
+ {
+ /* For DPS NX and SLOW mode, flushing the gc cache has
+ the side-effect of synching agent and server connections.
+ So, to have consistent behavior, we sync for the DPS/X
+ or FAST cases too. */
+
+ if (GCFlushMode[dpyix] == XDPSNX_GC_UPDATES_FAST
+ || dpy == xdpy)
+ XDPSLSync(xdpy);
+ }
+}
+
+
+#ifdef VMS
+void
+XDPSLSetDisplay(Display *dpy)
+{
+ dpys[DPY_NUMBER(dpy)] = dpy;
+}
+#endif /* VMS */
+
+char *
+XDPSLSetAgentName(Display *dpy, char *name, int deflt)
+{
+ char *old;
+
+ if (gCSDPS == NULL)
+ DPSCAPStartUp();
+ if (deflt)
+ {
+ old = gCSDPS->defaultAgentName;
+ gCSDPS->defaultAgentName = name;
+ }
+ else
+ {
+ old = gCSDPS->map[DPY_NUMBER(dpy)];
+ gCSDPS->map[DPY_NUMBER(dpy)] = name;
+ }
+ return(old);
+}
+
+
+void
+XDPSLSetClientMessageHandler(Display *dpy)
+{
+ if (dpy == NULL) return;
+ ClientMsgProc[DPY_NUMBER(dpy)] = XESetWireToEvent(
+ dpy,
+ ClientMessage,
+ DPSCAPClientMessageProc);
+}
+
+void
+XDPSLSetAfterProc(Display *xdpy)
+{
+ if (xdpy == NULL) return;
+ AfterProcs[DPY_NUMBER(xdpy)] = (GenericProcPtrReturnsInt)
+ XSetAfterFunction(xdpy, DPSCAPAfterProc);
+ /* +++ Consider using agent->synchandler to store old proc */
+}
+
+
+CSDPSFakeEventTypes
+XDPSLGetCSDPSFakeEventType(Display *dpy, XEvent *event)
+{
+ XExtCodes *codes = Codes[DPY_NUMBER(dpy)];
+ XExtData *extData;
+ DPSCAPData my;
+
+ if (event->type != ClientMessage || codes == NULL)
+ return(csdps_not);
+ extData = XFindOnExtensionList(
+ CSDPSHeadOfDpyExt(dpy),
+ codes->extension);
+ if (!extData)
+ return(csdps_not);
+ my = (DPSCAPData) extData->private_data;
+
+ if (event->xclient.message_type == my->typePSOutput)
+ return(csdps_output);
+ if (event->xclient.message_type == my->typePSOutputWithLen)
+ return(csdps_output_with_len);
+ if (event->xclient.message_type == my->typePSStatus)
+ return(csdps_status);
+ if (event->xclient.message_type == my->typeNoop)
+ return(csdps_noop);
+ if (event->xclient.message_type == my->typePSReady)
+ return(csdps_ready);
+ return(csdps_not);
+}
+
+Bool
+XDPSLDispatchCSDPSFakeEvent(
+ Display *dpy,
+ XEvent *event,
+ CSDPSFakeEventTypes t)
+{
+ register XDPSLOutputEvent *oce;
+ register DPSCAPOutputEvent *oev;
+ XDPSLOutputEvent fakeOutput;
+ XExtCodes *codes = Codes[DPY_NUMBER(dpy)];
+
+ if (codes == NULL)
+ return(False);
+
+ /* Fake up an event in the client's format. Bypasses
+ extension wire-to-event conversion */
+ switch (t)
+ {
+ case csdps_output:
+ oce = &fakeOutput;
+ oev = (DPSCAPOutputEvent *)event->xclient.data.b;
+ oce->length = DPSCAP_BYTESPEROUTPUTEVENT;
+ goto samo_samo;
+ case csdps_output_with_len:
+ oce = &fakeOutput;
+ oev = (DPSCAPOutputEvent *)event->xclient.data.b;
+ oce->length = oev->data[DPSCAP_DATA_LEN];
+samo_samo:
+ oce->type = codes->first_event + PSEVENTOUTPUT;
+ oce->serial = event->xclient.serial;
+ oce->send_event = True; /* ??? */
+ oce->display = dpy;
+ oce->cxid = oev->cxid;
+ bcopy((char *) oev->data, oce->data, oce->length);
+ XDPSLCallOutputEventHandler(dpy, (XEvent *) oce);
+ break;
+ case csdps_status:
+ {
+ register XDPSLStatusEvent *sce;
+ register DPSCAPStatusEvent *sev;
+ XDPSLStatusEvent fakeStatus;
+
+ sev = (DPSCAPStatusEvent *)event->xclient.data.b;
+ sce = &fakeStatus;
+ sce->type = codes->first_event + PSEVENTSTATUS;
+ sce->serial = event->xclient.serial;
+ sce->send_event = True; /* ??? */
+ sce->display = dpy;
+ sce->status = sev->status;
+ sce->cxid = sev->cxid;
+ XDPSLCallStatusEventHandler(dpy, (XEvent *) sce);
+ break;
+ }
+ case csdps_ready: /* L2-DPS/PROTO 9 addition */
+ {
+ register XDPSLReadyEvent *rce;
+ XDPSLReadyEvent fakeReady;
+
+ rce = &fakeReady;
+ rce->type = codes->first_event + PSEVENTREADY;
+ rce->serial = event->xclient.serial;
+ rce->send_event = True;
+ rce->display = dpy;
+ rce->cxid = event->xclient.data.l[0];
+ rce->val[0] = event->xclient.data.l[1];
+ rce->val[1] = event->xclient.data.l[2];
+ rce->val[2] = event->xclient.data.l[3];
+ rce->val[3] = event->xclient.data.l[4];
+ XDPSLCallReadyEventHandler(dpy, (XEvent *) rce);
+ break;
+ }
+ default:
+ return(False);
+ }
+ return(True);
+}
+
+void
+XDPSLGetCSDPSStatus(
+ Display *xdpy,
+ XEvent *event,
+ void **ret_ctxt,
+ int *ret_status)
+{
+ register DPSCAPStatusEvent *sev;
+
+ /* Assert: event is ClientMessage with typePSStatus */
+ sev = (DPSCAPStatusEvent *)event->xclient.data.b;
+
+ if (ret_ctxt != NULL)
+ *ret_ctxt = XDPSContextFromXID(xdpy, sev->cxid);
+ if (ret_status != NULL)
+ *ret_status = sev->status;
+}
+
+void
+XDPSLGetCSDPSReady(
+ Display *xdpy,
+ XEvent *event,
+ void **ret_ctxt,
+ int *ret_val)
+{
+ /* Assert: event is ClientMessage with typePSReady */
+
+ if (ret_ctxt != NULL)
+ *ret_ctxt =
+ XDPSContextFromXID(xdpy, (ContextXID)event->xclient.data.l[0]);
+ if (ret_val != NULL)
+ {
+ ret_val[0] = event->xclient.data.l[1];
+ ret_val[1] = event->xclient.data.l[2];
+ ret_val[2] = event->xclient.data.l[3];
+ ret_val[3] = event->xclient.data.l[4];
+ }
+}
+
+void
+XDPSLCAPNotify(
+ Display *xdpy,
+ ContextXID cxid,
+ unsigned int ntype, /* should this be an enum?? %%% */
+ unsigned int data,
+ unsigned int extra)
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ register xCAPNotifyReq *req;
+
+ if (dpy == xdpy) return;
+
+ /* We _have_ to sync client and server here in order to guarantee
+ correct execution sequencing. We call this procedure alot
+ to keep track of GC's going away, so this is a major
+ performance hit. */
+ if (ntype == DPSCAPNOTE_FREEGC)
+ XSync(xdpy, False);
+
+ LockDisplay(dpy);
+
+ NXMacroGetReq(CAPNotify, req);
+ req->reqType = DPSCAPOPCODEBASE;
+ req->type = X_CAPNotify;
+ req->cxid = cxid;
+ req->notification = ntype;
+ req->data = data;
+ req->extra = extra;
+
+ if (gAutoFlush)
+ N_XFlush(dpy);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+}
+
+void
+XDPSLSync(Display *xdpy)
+{
+ register Display *dpy = ShuntMap[DPY_NUMBER(xdpy)];
+
+ if (dpy == xdpy)
+ {
+ /* DPS/X */
+ XSync(dpy, False);
+ }
+ else
+ {
+ /* CSDPS */
+ XEvent event;
+ DPSCAPData my;
+ XExtData *extData;
+ XExtCodes *codes = Codes[DPY_NUMBER(xdpy)];
+
+ if (codes == NULL)
+ return;
+ /* Get private data */
+ extData = XFindOnExtensionList(
+ CSDPSHeadOfDpyExt(xdpy),
+ codes->extension);
+ if (!extData)
+ return;
+ my = (DPSCAPData) extData->private_data;
+ my->saveseq = XNextRequest(dpy)-1;
+ /* first send notification to agent */
+ XDPSLCAPNotify(xdpy, 0, DPSCAPNOTE_SYNC, my->saveseq, 0);
+#ifdef XXX
+fprintf(stderr, "\nXDPSLSync(DPSCAPNOTE_SYNC) sending ... ");
+#endif
+ _XFlush(xdpy);
+ N_XFlush(dpy);
+#ifdef XXX
+fprintf(stderr, "sent.\nWaiting for reply ... ");
+#endif
+ /* agent should send a ClientMessage, so wait for it */
+ XIfEvent(xdpy, &event, WaitForSyncProc, (char *) my);
+
+#ifdef XXX
+fprintf(stderr, "received.\n");
+#endif
+ /* now client, agent, and server are synchronized */
+ }
+}
+
+void
+XDPSLReconcileRequests(Display *xdpy, ContextXID cxid)
+{
+ int dpyix;
+ unsigned int seqnum;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+
+ if (dpy == xdpy)
+ return; /* No-op for DPS/X */
+
+ /* Get the sequence number and set the pause flag
+ IFF we are sure that some X protocol has occurred
+ since the last time we did a DPS request. This
+ minimizes pause/resume requests */
+
+ if (LastXRequest[dpyix] == XNextRequest(xdpy)-1)
+ {
+ if (gAutoFlush)
+ N_XFlush(dpy); /* This is what XDPSLCAPNotify would do */
+ return;
+ }
+ else
+ seqnum = DPSCAPSetPause(xdpy, cxid);
+
+ /* Pause the context specified. */
+ XDPSLCAPNotify(xdpy, cxid, DPSCAPNOTE_PAUSE, seqnum, 0);
+
+ /* We don't even need to flush. All we have to do is make
+ sure that the notify request is queued before any
+ DPS requests that follow. */
+}
+
+Status
+XDPSLSetAgentArg(Display *xdpy, int arg, int val)
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+ CARD32 capArg;
+ register xCAPSetArgReq *req;
+
+ if (dpy == xdpy)
+ return(Success); /* No-op for DPS/X */
+
+ /* dpy will be NIL if we haven't opened a connection yet,
+ but that's okay since we need to save the value anyway. */
+
+ if (dpy)
+ {
+ int syncMask = displayFlags[dpyix].syncMask;
+
+ /* ASSERT: There is no reason to pause the context for this
+ request, so just sync. */
+ if (syncMask & (DPSCAP_SYNCMASK_SYNC|DPSCAP_SYNCMASK_RECONCILE))
+ XSync(xdpy, False);
+ }
+
+ switch (arg)
+ {
+ case AGENT_ARG_SMALLFONTS:
+ AgentArgs[dpyix].showSmallSizes = val;
+ capArg = DPSCAP_ARG_SMALLFONTS;
+ break;
+ case AGENT_ARG_PIXMEM:
+ AgentArgs[dpyix].pixMem = val;
+ capArg = DPSCAP_ARG_PIXMEM;
+ break;
+ default:
+ return(!Success);
+ }
+ if (!dpy)
+ return(Success);
+
+ LockDisplay(dpy);
+
+ NXMacroGetReq(CAPSetArg, req);
+ req->reqType = DPSCAPOPCODEBASE;
+ req->type = X_CAPSetArg;
+ req->arg = capArg;
+ req->val = val;
+
+ if (gAutoFlush)
+ N_XFlush(dpy);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ LastXRequest[dpyix] = XNextRequest(xdpy)-1;
+ return(Success);
+}
+
+
+void
+XDPSLCleanAll(xdpy)
+ register Display *xdpy;
+{
+ /* Clean up all state associated with dpy */
+ register DPSCAPPausedContextData *slot;
+ int dpyix = DPY_NUMBER(xdpy);
+
+ /* Clean up paused context list */
+ for (slot = PausedPerDisplay[dpyix]; slot; slot = PausedPerDisplay[dpyix])
+ {
+ PausedPerDisplay[dpyix] = slot->next;
+ Xfree(slot);
+ }
+
+ /* Clear agent args */
+ AgentArgs[dpyix].showSmallSizes = 0;
+ AgentArgs[dpyix].pixMem = 0;
+}
+
+void
+XDPSLUpdateAgentArgs(xdpy)
+ register Display *xdpy;
+{
+ int dpyix = DPY_NUMBER(xdpy);
+
+ if (AgentArgs[dpyix].showSmallSizes)
+ XDPSLSetAgentArg(xdpy, AGENT_ARG_SMALLFONTS, AgentArgs[dpyix].showSmallSizes);
+ if (AgentArgs[dpyix].pixMem)
+ XDPSLSetAgentArg(xdpy, AGENT_ARG_PIXMEM, AgentArgs[dpyix].pixMem);
+}
+
+void
+XDPSLCleanContext(xdpy, cxid)
+ Display *xdpy;
+ ContextXID cxid;
+{
+ /* Clean up all state associated with cxid on this dpy */
+ register DPSCAPPausedContextData *slot, *prev;
+ int dpyix = DPY_NUMBER(xdpy);
+
+ /* If this is DPS/X, then slot will never have been initialized.
+ See XDPSLNotifyContext */
+
+ /* Clean up paused context list */
+ prev = (DPSCAPPausedContextData *)NULL;
+ for (slot = PausedPerDisplay[dpyix]; slot; prev = slot, slot = slot->next)
+ {
+ if (slot->cxid != cxid)
+ continue;
+ if (!prev)
+ PausedPerDisplay[dpyix] = slot->next;
+ else
+ prev->next = slot->next;
+ Xfree(slot);
+ break;
+ }
+}
+
+/* DPS NX 2.0 */
+void
+XDPSLSetGCFlushMode(dpy, value)
+ Display *dpy;
+ int value;
+{
+ int dpyix;
+ register Display *agent = ShuntMap[dpyix = DPY_NUMBER(dpy)];
+
+ if (value != XDPSNX_GC_UPDATES_SLOW && value != XDPSNX_GC_UPDATES_FAST)
+ {
+ DPSWarnProc(NULL, "DPS NX: Bogus GC flush mode.\n");
+ return;
+ }
+ /* 0 means no NX */
+ GCFlushMode[dpyix] = (agent == dpy) ? 0 : value;
+}
+
+int
+XDPSLGetGCFlushMode(dpy)
+ Display *dpy;
+{
+ return(GCFlushMode[DPY_NUMBER(dpy)]);
+}
+
+void
+XDPSLFlushGC(xdpy, gc)
+ Display *xdpy;
+ GC gc;
+{
+ int dpyix;
+ register Display *dpy = ShuntMap[dpyix = DPY_NUMBER(xdpy)];
+
+ if (!gc->dirty) return;
+
+ if (GCFlushMode[dpyix] == XDPSNX_GC_UPDATES_FAST)
+ {
+ XGCValues vals;
+ static unsigned long valuemask = DPSGCBITS & ~(GCClipMask);
+
+ /* Okay to call Xlib, since dpy isn't locked */
+ DPSAssertWarn(XGetGCValues(xdpy, gc, valuemask, &vals),
+ NULL, "DPS NX: XGetGCValues returned False\n");
+ vals.clip_mask = gc->values.clip_mask;
+ LockDisplay(dpy);
+ DPSCAPChangeGC(dpy, gc, DPSGCBITS, &vals);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ /* Fall thru. Either the GCFlushMode is SLOW, which means
+ we will DPSCAPChangeGC as a side-effect of FlushGC when
+ the GC hook is called, or we just did it in the FAST case. */
+ FlushGC(xdpy, gc);
+ XDPSLFlush(xdpy);
+}
+
+/* === PRIVATE CSDPS PROCS === */
+
+static Status
+DPSCAPClientMessageProc(
+ Display *dpy,
+ XEvent *re,
+ xEvent *event)
+{
+ register XDPSLOutputEvent *oce;
+ register DPSCAPOutputEvent *oev;
+ XDPSLOutputEvent fakeOutput;
+ XExtCodes *codes = Codes[DPY_NUMBER(dpy)];
+ PSCMProc oldProc = ClientMsgProc[DPY_NUMBER(dpy)];
+
+ if (codes != NULL)
+ {
+ /* Get private data */
+ XExtData *extData = XFindOnExtensionList(
+ CSDPSHeadOfDpyExt(dpy),
+ codes->extension);
+ DPSCAPData my;
+
+ /* There's no extension, or there is an extension but we are
+ passing events uninterpreted, so just pass it along
+ unless it is a DPSCAP error. */
+
+ if (!extData)
+ goto pass_the_buck;
+ my = (DPSCAPData) extData->private_data;
+ if (XDPSLGetPassEventsFlag(dpy) &&
+ (event->u.clientMessage.u.l.type != my->typeXError))
+ goto pass_the_buck;
+
+ /* Fake up a DPS extension event and handle it transparently,
+ without going through the Xlib event queue */
+
+ if (event->u.clientMessage.u.b.type == my->typePSOutput)
+ {
+ oce = &fakeOutput;
+ oce->length = DPSCAP_BYTESPEROUTPUTEVENT;
+ oev = (DPSCAPOutputEvent *)event->u.clientMessage.u.b.bytes;
+ goto common_stuff;
+ }
+ else if (event->u.clientMessage.u.b.type == my->typePSOutputWithLen)
+ {
+ oce = &fakeOutput;
+ oev = (DPSCAPOutputEvent *)event->u.clientMessage.u.b.bytes;
+ oce->length = oev->data[DPSCAP_DATA_LEN];
+common_stuff:
+ oce->type = codes->first_event + PSEVENTOUTPUT;
+ oce->serial = _XSetLastRequestRead(dpy, (xGenericReply *)event);
+ oce->send_event = True; /* ??? */
+ oce->display = dpy;
+ oce->cxid = oev->cxid;
+ bcopy((char *) oev->data, oce->data, oce->length);
+ /* We've converted the event, give it to DPS */
+ if (TextProc)
+ (*TextProc)((XEvent *) oce);
+ return(False);
+ }
+ else if (event->u.clientMessage.u.b.type == my->typePSStatus)
+ {
+ register XDPSLStatusEvent *sce;
+ register DPSCAPStatusEvent *sev;
+ XDPSLStatusEvent fakeStatus;
+
+ sev = (DPSCAPStatusEvent *)event->u.clientMessage.u.b.bytes;
+ sce = &fakeStatus;
+ sce->type = codes->first_event + PSEVENTSTATUS;
+ sce->serial = _XSetLastRequestRead(dpy, (xGenericReply *)event);
+ sce->send_event = True; /* ??? */
+ sce->display = dpy;
+ sce->cxid = sev->cxid;
+ sce->status = sev->status;
+ /* We've converted the event, give it to DPS */
+ if (StatusProc[DPY_NUMBER(dpy)])
+ (*(StatusProc[DPY_NUMBER(dpy)]))((XEvent *) sce);
+ return(False);
+ }
+ else if (event->u.clientMessage.u.l.type == my->typeXError)
+ {
+ xError err;
+ register xError *e = &err;
+
+ e->type = X_Error;
+ e->errorCode = event->u.clientMessage.u.l.longs0;
+ e->sequenceNumber = event->u.u.sequenceNumber;
+ e->resourceID = event->u.clientMessage.u.l.longs3;
+ e->minorCode = event->u.clientMessage.u.l.longs2;
+ e->majorCode = event->u.clientMessage.u.l.longs1;
+ /* Smash the wire event here, before going off deep end */
+ event->u.clientMessage.u.l.type = my->typeNoop;
+ /* Jump! */
+ return(_XError(dpy, e));
+ }
+ else if (event->u.clientMessage.u.l.type == my->typePSReady)
+ /* L2-DPS/PROTO 9 addition */
+ {
+ register XDPSLReadyEvent *rce;
+ XDPSLReadyEvent fakeReady;
+
+ rce = &fakeReady;
+ rce->type = codes->first_event + PSEVENTREADY;
+ rce->serial = _XSetLastRequestRead(dpy, (xGenericReply *)event);
+ rce->send_event = True;
+ rce->display = dpy;
+ rce->cxid = event->u.clientMessage.u.l.longs0;
+ rce->val[0] = event->u.clientMessage.u.l.longs1;
+ rce->val[1] = event->u.clientMessage.u.l.longs2;
+ rce->val[2] = event->u.clientMessage.u.l.longs3;
+ rce->val[3] = event->u.clientMessage.u.l.longs4;
+ XDPSLCallReadyEventHandler(dpy, (XEvent *) rce);
+ return(False);
+ }
+ }
+
+ /* Put the event on the queue, so that Xlib is happy */
+pass_the_buck:
+ return(oldProc(dpy, re, event));
+}
+
+
+static void
+DPSCAPInitGC(Display *dpy, Display *agent, GC gc)
+{
+ XGCValues values;
+ unsigned long valuemask = DPSGCBITS & ~(GCClipMask);
+
+ /* Okay to call Xlib, since dpy isn't locked */
+ DPSAssertWarn(XGetGCValues(dpy, gc, valuemask, &values),
+ NULL, "DPS NX: XGetGCValues returned False\n");
+ values.clip_mask = gc->values.clip_mask;
+ DPSCAPChangeGC(agent, gc, DPSGCBITS, &values);
+ SyncHandle();
+ XDPSLSync(dpy);
+}
+
+
+/* ARGSUSED */
+
+static Bool
+WaitForSyncProc(Display *xdpy, XEvent *event, char *arg)
+{
+ DPSCAPData my = (DPSCAPData)arg;
+
+ if ((event->type & 0x7F) == ClientMessage
+ && event->xclient.message_type == my->typeSync
+ && event->xclient.data.l[0] == (long) my->saveseq) {
+ return(True);
+ } else {
+ return(False);
+ }
+}
+
+
+static int
+DPSCAPAfterProc(Display *xdpy)
+{
+ register Display *dpy = ShuntMap[DPY_NUMBER(xdpy)];
+ GenericProcPtrReturnsInt proc;
+
+ if (dpy != (Display *)NULL && dpy != xdpy)
+ {
+ LockDisplay(dpy);
+ N_XFlush(dpy);
+ UnlockDisplay(dpy);
+ LockDisplay(xdpy);
+ _XFlush(xdpy);
+ UnlockDisplay(xdpy);
+ }
+ if ((proc = AfterProcs[DPY_NUMBER(xdpy)]) != NULL)
+ return((*proc)(xdpy));
+ else
+ return(0);
+}
+
+
+static unsigned int
+DPSCAPSetPause(Display *xdpy, ContextXID cxid)
+{
+ register DPSCAPPausedContextData *slot;
+ int dpyix;
+ unsigned int ret;
+
+ /* Find or create slot */
+
+ slot = PausedPerDisplay[dpyix = DPY_NUMBER(xdpy)];
+ if (!slot)
+ {
+ slot = (DPSCAPPausedContextData *)
+ Xcalloc(1, sizeof(DPSCAPPausedContextData));
+ PausedPerDisplay[dpyix] = slot;
+ goto common_code;
+ /* IMPLICATION: it is okay to fall through common_code
+ and do test_ret. */
+ }
+ while (1)
+ if (slot->cxid == cxid)
+ {
+ if (!slot->paused)
+ {
+ slot->paused = True;
+ ++gTotalPaused;
+ }
+ /* Back-to-back pauses get different sequence numbers */
+ ret = ++slot->seqnum;
+ goto test_ret;
+ }
+ else if (slot->next) slot = slot->next;
+ else break;
+ /* cxid wasn't found, so add it */
+ /* ASSERT: slot points to last record of the list */
+ slot->next = (DPSCAPPausedContextData *)
+ Xcalloc(1, sizeof(DPSCAPPausedContextData));
+ slot = slot->next;
+common_code:
+ slot->paused = True;
+ ++gTotalPaused;
+ slot->cxid = cxid;
+ ret = ++slot->seqnum;
+test_ret:
+ if (!ret)
+ {
+ DPSWarnProc(NULL, "Pause sequence wrapped around!");
+ }
+ return(ret);
+}
+
+static Bool
+DPSCAPResumeContext(Display *xdpy, ContextXID cxid)
+{
+ register DPSCAPPausedContextData *slot;
+ int dpyix = DPY_NUMBER(xdpy);
+
+ /* Try to match cxid to list of paused contexts */
+ for (slot = PausedPerDisplay[dpyix]; slot; slot = slot->next)
+ if (slot->cxid == cxid && slot->paused)
+ {
+ /* Send resume event */
+ register XClientMessageEvent *ee;
+ XEvent e;
+ XExtData *extData;
+ DPSCAPData my;
+ XExtCodes *codes = Codes[dpyix];
+
+ extData = XFindOnExtensionList(
+ CSDPSHeadOfDpyExt(xdpy),
+ codes->extension);
+ if (!extData)
+ return(False);
+ my = (DPSCAPData) extData->private_data;
+
+ ee = &e.xclient;
+ ee->type = ClientMessage;
+ ee->display = xdpy;
+ ee->window = my->agentWindow;
+ ee->format = 32;
+ ee->message_type = my->typeResume;
+ ee->data.l[0] = cxid;
+ ee->data.l[1] = slot->seqnum;
+ (void) XSendEvent(
+ xdpy,
+ my->agentWindow,
+ False,
+ NoEventMask,
+ &e);
+ XFlush(xdpy);
+ /* Turn off flag */
+ slot->paused = False;
+ --gTotalPaused;
+ return(True);
+ }
+ /* Fall thru */
+ return(False);
+}
diff --git a/nx-X11/lib/dps/Xlibnet.h b/nx-X11/lib/dps/Xlibnet.h
new file mode 100644
index 000000000..f86c3542b
--- /dev/null
+++ b/nx-X11/lib/dps/Xlibnet.h
@@ -0,0 +1,284 @@
+/* $XConsortium: Xlibnet.h,v 1.18 91/07/23 19:01:27 rws Exp $ */
+
+/*
+Copyright 1991 Massachusetts Institute of Technology
+
+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 of M.I.T. not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+written prior permission. M.I.T. makes no representations about the
+suitability of this software for any purpose. It is provided "as is"
+without express or implied warranty.
+*/
+/* $XFree86: xc/lib/dps/Xlibnet.h,v 1.6 2001/06/30 22:41:44 tsi Exp $ */
+/*
+ * Xlibnet.h - Xlib networking include files for UNIX Systems.
+ */
+
+#ifndef X_UNIX_PATH
+#ifdef hpux
+#define X_UNIX_PATH "/usr/spool/sockets/X11/"
+#define OLD_UNIX_PATH "/tmp/.X11-unix/X"
+#else
+#define X_UNIX_PATH "/tmp/.X11-unix/X"
+#endif
+#endif /* X_UNIX_PATH */
+
+#ifdef STREAMSCONN
+#ifdef SYSV
+/*
+ * UNIX System V Release 3.2
+ */
+#define BytesReadable(fd,ptr) (_XBytesReadable ((fd), (ptr)))
+#define MALLOC_0_RETURNS_NULL
+#include <sys/ioctl.h>
+
+#endif /* SYSV */
+#ifdef SVR4
+/*
+ * TLI (Streams-based) networking
+ */
+#define BytesReadable(fd,ptr) (_XBytesReadable ((fd), (ptr)))
+#include <sys/uio.h> /* define struct iovec */
+
+#endif /* SVR4 */
+#else /* not STREAMSCONN */
+/*
+ * socket-based systems
+ */
+#include <netinet/in.h>
+#include <sys/ioctl.h>
+#include <netdb.h>
+#include <sys/uio.h> /* needed for XlibInt.c */
+#ifdef SVR4
+#include <sys/filio.h>
+#endif
+
+#if defined(i386) && defined(SYSV)
+#if !defined(__SCO__)
+#include <net/errno.h>
+#endif
+#include <sys/stropts.h>
+#define BytesReadable(fd,ptr) ioctl((fd), I_NREAD, (ptr))
+#else
+#define BytesReadable(fd, ptr) ioctl ((fd), FIONREAD, (ptr))
+#endif
+
+#endif /* STREAMSCONN else */
+
+/*
+ * If your BytesReadable correctly detects broken connections, then
+ * you should NOT define XCONN_CHECK_FREQ.
+ */
+#define XCONN_CHECK_FREQ 256
+
+#ifndef X_NOT_POSIX
+#ifdef _POSIX_SOURCE
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif
+#endif
+#ifndef OPEN_MAX
+#ifdef SVR4
+#define OPEN_MAX 256
+#else
+#include <sys/param.h>
+#ifndef OPEN_MAX
+#ifdef NOFILE
+#define OPEN_MAX NOFILE
+#else
+#if !defined(__UNIXOS2__) && !defined(__QNX__)
+#define OPEN_MAX NOFILES_MAX
+#else
+#define OPEN_MAX 256
+#endif
+#endif
+#endif
+#endif
+#endif
+
+#if OPEN_MAX > 256
+#undef OPEN_MAX
+#define OPEN_MAX 256
+#endif
+
+/* Adobe additions */
+#ifdef MSKCNT
+#undef MSKCNT
+#endif
+#ifdef BITMASK
+#undef BITMASK
+#endif
+#ifdef MASKIDX
+#undef MASKIDX
+#endif
+
+#define MSKCNT ((OPEN_MAX + 31) / 32)
+
+#if (MSKCNT==1)
+#define BITMASK(i) (1 << (i))
+#define MASKIDX(i) 0
+#endif
+#if (MSKCNT>1)
+#define BITMASK(i) (1 << ((i) & 31))
+#define MASKIDX(i) ((i) >> 5)
+#endif
+
+#define MASKWORD(buf, i) buf[MASKIDX(i)]
+#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
+#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
+#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
+
+/* Adobe additions */
+#ifdef COPYBITS
+#undef COPYBITS
+#undef CLEARBITS
+#undef MASKANDSETBITS
+#undef ORBITS
+#undef UNSETBITS
+#endif
+
+#if (MSKCNT==1)
+#define COPYBITS(src, dst) dst[0] = src[0]
+#define CLEARBITS(buf) buf[0] = 0
+#define MASKANDSETBITS(dst, b1, b2) dst[0] = (b1[0] & b2[0])
+#define ORBITS(dst, b1, b2) dst[0] = (b1[0] | b2[0])
+#define UNSETBITS(dst, b1) (dst[0] &= ~b1[0])
+#define _XANYSET(src) (src[0])
+#endif
+#if (MSKCNT==2)
+#define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; }
+#define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; }
+#define MASKANDSETBITS(dst, b1, b2) {\
+ dst[0] = (b1[0] & b2[0]);\
+ dst[1] = (b1[1] & b2[1]); }
+#define ORBITS(dst, b1, b2) {\
+ dst[0] = (b1[0] | b2[0]);\
+ dst[1] = (b1[1] | b2[1]); }
+#define UNSETBITS(dst, b1) {\
+ dst[0] &= ~b1[0]; \
+ dst[1] &= ~b1[1]; }
+#define _XANYSET(src) (src[0] || src[1])
+#endif
+#if (MSKCNT==3)
+#define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; \
+ dst[2] = src[2]; }
+#define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; buf[2] = 0; }
+#define MASKANDSETBITS(dst, b1, b2) {\
+ dst[0] = (b1[0] & b2[0]);\
+ dst[1] = (b1[1] & b2[1]);\
+ dst[2] = (b1[2] & b2[2]); }
+#define ORBITS(dst, b1, b2) {\
+ dst[0] = (b1[0] | b2[0]);\
+ dst[1] = (b1[1] | b2[1]);\
+ dst[2] = (b1[2] | b2[2]); }
+#define UNSETBITS(dst, b1) {\
+ dst[0] &= ~b1[0]; \
+ dst[1] &= ~b1[1]; \
+ dst[2] &= ~b1[2]; }
+#define _XANYSET(src) (src[0] || src[1] || src[2])
+#endif
+#if (MSKCNT==4)
+#define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; \
+ dst[2] = src[2]; dst[3] = src[3]
+#define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0
+#define MASKANDSETBITS(dst, b1, b2) \
+ dst[0] = (b1[0] & b2[0]);\
+ dst[1] = (b1[1] & b2[1]);\
+ dst[2] = (b1[2] & b2[2]);\
+ dst[3] = (b1[3] & b2[3])
+#define ORBITS(dst, b1, b2) \
+ dst[0] = (b1[0] | b2[0]);\
+ dst[1] = (b1[1] | b2[1]);\
+ dst[2] = (b1[2] | b2[2]);\
+ dst[3] = (b1[3] | b2[3])
+#define UNSETBITS(dst, b1) \
+ dst[0] &= ~b1[0]; \
+ dst[1] &= ~b1[1]; \
+ dst[2] &= ~b1[2]; \
+ dst[3] &= ~b1[3]
+#define _XANYSET(src) (src[0] || src[1] || src[2] || src[3])
+#endif
+
+#if (MSKCNT>4)
+#define COPYBITS(src, dst) bcopy((char *) src, (char *) dst,\
+ MSKCNT*sizeof(long))
+#define CLEARBITS(buf) bzero((char *) buf, MSKCNT*sizeof(long))
+#define MASKANDSETBITS(dst, b1, b2) \
+ { int cri; \
+ for (cri=MSKCNT; --cri>=0; ) \
+ dst[cri] = (b1[cri] & b2[cri]); }
+#define ORBITS(dst, b1, b2) \
+ { int cri; \
+ for (cri=MSKCNT; --cri>=0; ) \
+ dst[cri] = (b1[cri] | b2[cri]); }
+#define UNSETBITS(dst, b1) \
+ { int cri; \
+ for (cri=MSKCNT; --cri>=0; ) \
+ dst[cri] &= ~b1[cri]; }
+/*
+ * If MSKCNT>4, then _XANYSET is a routine defined in XlibInt.c.
+ *
+ * #define _XANYSET(src) (src[0] || src[1] || src[2] || src[3] || src[4] ...)
+ */
+extern int N_XANYSET(unsigned long *);
+#endif
+
+/*
+ * ReadvFromServer and WritevToSever use struct iovec, normally found
+ * in Berkeley systems in <sys/uio.h>. See the readv(2) and writev(2)
+ * manual pages for details.
+ *
+ * struct iovec {
+ * caddr_t iov_base;
+ * int iov_len;
+ * };
+ */
+#if defined(USG) && !defined(CRAY) && !defined(umips) && !defined(MOTOROLA)
+struct iovec {
+ caddr_t iov_base;
+ int iov_len;
+};
+#endif /* USG */
+
+
+#ifdef STREAMSCONN
+#include "Xstreams.h"
+
+extern char _XsTypeOfStream[];
+extern Xstream _XsStream[];
+
+#define ReadFromServer(dpy, data, size) \
+ (*_XsStream[_XsTypeOfStream[dpy]].ReadFromStream)((dpy), (data), (size), \
+ BUFFERING)
+#define WriteToServer(dpy, bufind, size) \
+ (*_XsStream[_XsTypeOfStream[dpy]].WriteToStream)((dpy), (bufind), (size))
+
+#else /* else not STREAMSCONN */
+
+/*
+ * bsd can read from sockets directly
+ */
+#define ReadFromServer(dpy, data, size) read((dpy), (data), (size))
+#define WriteToServer(dpy, bufind, size) write((dpy), (bufind), (size))
+
+#endif /* STREAMSCONN */
+
+
+#ifndef USL_COMPAT
+#if !defined(USG) || defined(MOTOROLA) || \
+ defined(__SCO__) || (!(defined(SYSV) && defined(i386))) || \
+ defined(__UNIXWARE__)
+#define _XReadV readv
+#define _XWriteV writev
+#endif
+#endif /* !USL_COMPAT */
+
+#define ReadvFromServer(dpy, iov, iovcnt) _XReadV((dpy), (iov), (iovcnt))
+#define WritevToServer(dpy, iov, iovcnt) _XWriteV((dpy), (iov), (iovcnt))
diff --git a/nx-X11/lib/dps/Xstreams.h b/nx-X11/lib/dps/Xstreams.h
new file mode 100644
index 000000000..a7419131b
--- /dev/null
+++ b/nx-X11/lib/dps/Xstreams.h
@@ -0,0 +1,218 @@
+/* $XConsortium: Xstreams.h,v 1.6 91/07/19 23:22:53 gildea Exp $ */
+/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
+/* Copyright (c) 1988 AT&T */
+/* 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 AT&T or USL not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. AT&T and USL make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * AT&T and USL DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL AT&T or USL 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.
+ */
+/* $XFree86$ */
+
+
+#ifndef _XSTREAMS_H_
+#define _XSTREAMS_H_
+/*
+ Xstreams.h (C header file)
+ Acc: 575304412 Tue Apr 26 09:46:52 1988
+ Mod: 574017273 Tue Apr 26 12:14:33 1988
+ Sta: 574017273 Tue Apr 26 12:14:33 1988
+ Owner: 2011
+ Group: 1985
+ Permissions: 644
+*/
+/*
+ START USER STAMP AREA
+*/
+/*
+ END USER STAMP AREA
+*/
+
+
+
+#define MEM_ALLIGN(ptr) ((((unsigned) (ptr + 3)) >> 2) << 2)
+
+#define CONNECT_TIMEOUT 60
+#define MAX_AUTO_BUF_LEN 256
+#define MAX_DISP_DIGITS 20
+#define MAX_NETS 8
+
+typedef struct _host {
+ char host_name[32];
+ int host_len;
+ struct _host *next;
+} HOST;
+
+/*
+ * Structure for handling multiple connection requests on the same stream.
+ */
+
+struct listenCall {
+ struct t_call *CurrentCall;
+ struct listenCall *NextCall;
+};
+
+struct listenQue {
+ struct listenCall *QueHead;
+ struct listenCall *QueTail;
+};
+
+#define EMPTY(p) (p->QueHead == (struct listenCall *) NULL)
+
+
+typedef struct {
+ int flags;
+ char type;
+ int display;
+ char *inputbuf;
+ int buflen;
+ int bufptr;
+ int msglen;
+ } IOBUFFER;
+
+typedef struct {
+ int _nnets;
+#ifdef SVR4
+ struct netconfig *_net[MAX_NETS];
+#else
+ char *_net[MAX_NETS];
+#endif
+ struct listenQue FreeList[MAX_NETS];
+ struct listenQue PendingQue[MAX_NETS];
+ int _npeers;
+ char **_peer;
+ int *_peerlen;
+ HOST *_validhosts;
+ } networkInfo;
+
+
+typedef struct _Xstream {
+ int (*SetupTheListener)();
+ int (*ConnectNewClient)();
+ int (*CallTheListener)();
+ int (*ReadFromStream)();
+ int (*BytesCanBeRead)();
+ int (*WriteToStream)();
+ int (*CloseStream)();
+ int (*CreateAddress)();
+ union ext {
+ int (*NameServer)();
+ networkInfo *NetInfo;
+ } u;
+ } Xstream;
+
+/* old shared libraries have the names already fixed */
+#ifdef USL_COMPAT
+#define _XsStream xstream
+#define _XReadV _readv
+#define _XWriteV _writev
+#define _XSelect XSelect
+#define _XsErrorCall ErrorCall
+#define _XsSetupLocalStream SetupLocalStream
+#define _XsConnectLocalClient ConnectLocalClient
+#define _XsOpenSpServer OpenSpServer
+#define _XsReadLocalStream ReadLocalStream
+#define _XsConnectTliClient ConnectTliClient
+#define _XsSetupTliStrean SetupTliStream
+#define _XsCallTliServer CallTliServer
+#define _XsCallLocalServer CallLocalServer
+#define _XsTypeOfStream TypeOfStream
+#ifdef SVR4
+#define _XsSetupNamedStream SetupNamedStream
+#define _XsSetupSpStream SetupSpStream
+#endif /* SVR4 */
+#endif /* USL_COMPAT */
+
+extern Xstream _XsStream[];
+
+#define NO_BUFFERING 0
+#define BUFFERING 1
+
+/* Network services */
+
+#define OpenDaemonConnection 0
+#define PEER_NAME 1
+#define PEER_ALLOC 2
+#define PEER_FREE 3
+#define ConvertNetAddrToName 4
+#define ConvertNameToNetAddr 5
+#define ConvertNameToTliCall 6
+#define ConvertTliCallToName 7
+#define ConvertNameToTliBind 8
+
+#define UNAME_LENGTH 14
+
+#define X_LOCAL_STREAM 0
+#define X_NAMED_STREAM 1
+/* Enhanced Application Compatibility Support */
+#define X_SP_STREAM 2
+/* End Enhanced Application Compatibility Support */
+
+#define X_TLI_STREAM 3
+#define CLOSED_STREAM -1
+
+/*
+ The following are defined in X.h. Any changes to FamilyUname
+ should take X.h into consideration.
+*/
+ /* protocol families */
+
+ /*
+
+ #define FamilyInternet 0
+ #define FamilyDECnet 1
+ #define FamilyChaos 2
+
+ */
+
+#define FamilyUname 3
+
+#define X_TCP_PORT 6000
+
+#define NAMED_LISTENER "/dev/X/Nserver"
+#define LOCAL_LISTENER "/dev/X/server"
+/* Enhanced Application Compatibility Support */
+/* End Enhanced Application Compatibility Support */
+
+#define NAME_SERVER_NODE "/dev/X/nameserver"
+#define XNETSPECDIR "lib/net"
+#define XROOTDIR "/usr/X"
+
+#define MAX_SIMUL_TLI_CALLS 20
+
+#define SetupNetworkInfo() _XsStream[X_LOCAL_STREAM].u.NetInfo = &Network; \
+ _XsStream[X_NAMED_STREAM].u.NetInfo = &Network; \
+/* Enhanced Application Compatibility Support */ \
+/* End Enhanced Application Compatibility Support */ \
+ _XsStream[X_TLI_STREAM].u.NameServer = nameserver
+
+#define NetworkInfo (_XsStream[X_LOCAL_STREAM].u.NetInfo)
+#define GetNetworkInfo (*_XsStream[X_TLI_STREAM].u.NameServer)
+#define validhosts _XsStream[X_LOCAL_STREAM].u.NetInfo->_validhosts
+
+/*
+ * header of messages sent by X to the nameserver
+ * 1st int: the size of the entire message.
+ * 2nd int: the size of the header itself.
+ * 3rd int: the service number.
+ * 4th int: the display number.
+ * 5th int: the length of the network name.
+ */
+
+#define HEADERSIZE (5*sizeof(int))
+#endif /* _XSTREAMS_H_ */
diff --git a/nx-X11/lib/dps/csconndi.c b/nx-X11/lib/dps/csconndi.c
new file mode 100644
index 000000000..64205f8dc
--- /dev/null
+++ b/nx-X11/lib/dps/csconndi.c
@@ -0,0 +1,839 @@
+/*
+ * csconndi.c -- low level connection maker for CSDPS
+ *
+ * (c) Copyright 1990-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Portions Copyright 1989 Massachusetts Institute of Technology
+ *
+ * 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 of M.I.T. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. M.I.T. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * Author: Adobe Systems Incorporated and MIT X Consortium
+ */
+/* $XFree86: xc/lib/dps/csconndi.c,v 1.11tsi Exp $ */
+
+#if defined(sun) && !defined(SVR4)
+#define memmove(t,f,c) bcopy(f,t,c)
+#endif
+
+#define NEED_EVENTS
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xos.h>
+/* Include this first so that Xasync.h, included from Xlibint.h, can find
+ the definition of NOFILE */
+#include <sys/param.h>
+#include <X11/Xlibint.h>
+#include "Xlibnet.h" /* New for R5, delete for R4 */
+#include <arpa/inet.h>
+
+#ifndef hpux /* HP doesn't include Xauth.h :-( */
+#include <X11/Xauth.h>
+#else
+#define FamilyLocal (256)
+#endif
+
+#include <ctype.h>
+#ifdef DNETCONN
+#include <netdnet/dn.h>
+#include <netdnet/dnetdb.h>
+#endif
+
+#include <netdb.h>
+
+#include "DPSCAPproto.h"
+#include "cslibint.h"
+#include "dpsassert.h"
+
+#if defined(hpux) || defined(AIXV3)
+#define SELECT_TYPE int *
+#else
+#define SELECT_TYPE fd_set *
+#endif
+
+#ifndef _XANYSET
+#define _XANYSET N_XANYSET
+#endif /* _XANYSET */
+
+#ifndef X_CONNECTION_RETRIES /* number retries on ECONNREFUSED */
+#define X_CONNECTION_RETRIES 5
+#endif
+
+#define CONN_PARAMS char *, int , int , int *, int *, char **
+
+#ifdef DNETCONN
+static int MakeDECnetConnection(CONN_PARAMS);
+#endif
+#ifdef UNIXCONN
+static int MakeUNIXSocketConnection(CONN_PARAMS);
+#endif
+#ifdef TCPCONN
+static int MakeTCPConnection(CONN_PARAMS);
+#endif
+#ifdef STREAMSCONN
+extern int _XMakeStreamsConnection(CONN_PARAMS);
+#endif
+
+/* This global controls the size of the output socket buffer. Zero
+ means to use the system default size. */
+int gNXSndBufSize = 0;
+
+static char *copystring (char *src, int len)
+{
+ char *dst = Xmalloc (len + 1);
+
+ if (dst) {
+ strncpy (dst, src, len);
+ dst[len] = '\0';
+ }
+
+ return dst;
+}
+
+
+/*
+ * Attempts to connect to agent, given name. Returns file descriptor
+ * (network socket) or -1 if connection fails. Names may be of the
+ * following format:
+ *
+ * [hostname] : [:] agentnumber
+ *
+ * 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
+ */
+
+int
+DPSCAPConnect(
+ char *display_name,
+ char **fullnamep, /* RETURN */
+ int *dpynump, /* RETURN */
+ int *familyp, /* RETURN */
+ int *saddrlenp, /* RETURN */
+ char **saddrp) /* RETURN, freed by caller */
+{
+ char *lastp, *p; /* char pointers */
+ 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 iagent; /* required display number */
+ int (*connfunc)(CONN_PARAMS); /* method to create connection */
+ int fd = -1; /* file descriptor to return */
+ int len; /* length tmp variable */
+
+ p = display_name;
+
+ *saddrlenp = 0; /* set so that we can clear later */
+ *saddrp = NULL;
+
+ /*
+ * Step 1, find the hostname. This is delimited by the required
+ * first colon.
+ */
+ for (lastp = p; *p && *p != ':'; p++) ;
+ if (!*p) return -1; /* must have a colon */
+
+ if (p != lastp) { /* no hostname given */
+ phostname = copystring (lastp, p - lastp);
+ if (!phostname) goto bad; /* no memory */
+ }
+
+
+ /*
+ * Step 2, see if this is a DECnet address by looking for the optional
+ * second colon.
+ */
+ if (p[1] == ':') { /* then DECnet format */
+ dnet = True;
+ p++;
+ }
+
+ /*
+ * see if we're allowed to have a DECnet address
+ */
+#ifndef DNETCONN
+ if (dnet) goto bad;
+#endif
+
+
+ /*
+ * Step 3, find the port number. This field is required.
+ * Zero is acceptable as a port number, meaning use the default.
+ */
+
+ 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;
+ iagent = atoi (pdpynum);
+
+
+ /*
+ * At this point, we know the following information:
+ *
+ * phostname hostname string or NULL
+ * iagent agent port 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).
+ *
+ * First, choose default transports: DECnet else (TCP or STREAMS)
+ */
+
+
+#ifdef DNETCONN
+ if (dnet)
+ connfunc = MakeDECnetConnection;
+ else
+#endif
+#ifdef TCPCONN
+ connfunc = MakeTCPConnection;
+#else
+#ifdef STREAMSCONN
+ connfunc = _XMakeStreamsConnection;
+#else
+ connfunc = NULL;
+#endif
+#endif
+
+#ifdef UNIXCONN
+ /*
+ * 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) {
+ connfunc = MakeUNIXSocketConnection;
+ }
+ else if (strcmp (phostname, "unix") == 0) {
+ connfunc = MakeUNIXSocketConnection;
+ }
+#endif
+ if (!connfunc)
+ goto bad;
+
+
+#ifdef UNIXCONN
+#define LOCALCONNECTION (!phostname || connfunc == MakeUNIXSocketConnection)
+#else
+#define LOCALCONNECTION (!phostname)
+#endif
+
+ if (LOCALCONNECTION) {
+ /*
+ * Get the auth info for local hosts so that it doesn't have to be
+ * repeated everywhere; the particular values in these fields are
+ * not part of the protocol.
+ */
+ char hostnamebuf[256];
+ int len = N_XGetHostname (hostnamebuf, sizeof hostnamebuf);
+
+ *familyp = FamilyLocal;
+ if (len > 0) {
+ *saddrp = Xmalloc (len + 1);
+ if (*saddrp) {
+ strcpy (*saddrp, hostnamebuf);
+ *saddrlenp = len;
+ } else {
+ *saddrlenp = 0;
+ }
+ }
+ }
+#undef LOCALCONNECTION
+
+#ifndef ultrix
+ /* Ultrix has a nasty bug in getservbyname(); if the name passed to
+ it is not in the services list it seg faults! *sigh* So, we
+ don't ever look in the services info for ultrix... */
+ if (iagent == 0) { /* find service default, if one's defined */
+ struct servent *serventInfo;
+
+ if ((serventInfo = getservbyname(DPS_NX_SERV_NAME,
+ (char *) NULL)) != NULL) {
+ if (strcmp("tcp", serventInfo->s_proto) != 0) {
+ DPSWarnProc(NULL, "Services database specifies a protocol other than tcp. Using default port.\n");
+ } else /* extract the port number */
+ iagent = ntohs(serventInfo->s_port);
+ }
+ }
+#endif /* ultrix */
+ /*
+ * Make the connection, also need to get the auth address info for
+ * non-local connections. 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).
+ */
+ if ((fd = (*connfunc) (phostname, iagent, X_CONNECTION_RETRIES,
+ familyp, saddrlenp, saddrp)) < 0)
+ goto bad;
+
+
+ /*
+ * Set the connection non-blocking since we use select() to block; also
+ * set close-on-exec so that programs that fork() doesn't get confused.
+ */
+#ifdef FIOSNBIO
+ {
+ int arg = 1;
+ ioctl (fd, FIOSNBIO, &arg);
+ }
+#else
+#if defined(O_NONBLOCK)
+ (void) fcntl (fd, F_SETFL, O_NONBLOCK);
+#elif defined(FNDELAY)
+ (void) fcntl (fd, F_SETFL, FNDELAY);
+#else
+ (void) fcntl (fd, F_SETFL, O_NDELAY);
+#endif /* O_NONBLOCK/FNDELAY */
+#endif /* FIOSNBIO */
+
+ (void) fcntl (fd, F_SETFD, 1);
+
+
+ /*
+ * Build the expanded display name:
+ *
+ * [host] : [:] agent \0
+ */
+ len = ((phostname ? strlen(phostname) : 0) + 1 + (dnet ? 1 : 0) +
+ strlen(pdpynum) + 1);
+ *fullnamep = (char *) Xmalloc (len);
+ if (!*fullnamep) goto bad;
+
+ sprintf (*fullnamep, "%s%s%d",
+ (phostname ? phostname : ""), (dnet ? "::" : ":"),
+ iagent);
+
+ *dpynump = iagent;
+ if (phostname) Xfree (phostname);
+ if (pdpynum) Xfree (pdpynum);
+ if (pscrnum) Xfree (pscrnum);
+ return fd;
+
+
+ /*
+ * error return; make sure everything is cleaned up.
+ */
+ bad:
+ if (fd >= 0) (void) close (fd);
+ if (*saddrp) {
+ Xfree (*saddrp);
+ *saddrp = NULL;
+ }
+ *saddrlenp = 0;
+ if (phostname) Xfree (phostname);
+ if (pdpynum) Xfree (pdpynum);
+ return -1;
+
+}
+
+
+/*****************************************************************************
+ * *
+ * Make Connection Routines *
+ * *
+ *****************************************************************************/
+
+#ifdef DNETCONN /* stupid makedepend */
+#define NEED_BSDISH
+#endif
+#ifdef UNIXCONN
+#define NEED_BSDISH
+#endif
+#ifdef TCPCONN
+#define NEED_BSDISH
+#endif
+
+#ifdef NEED_BSDISH /* makedepend can't handle #if */
+/*
+ * 4.2bsd-based systems
+ */
+#include <sys/socket.h>
+
+#ifndef hpux
+#ifdef apollo /* nest if(n)defs because makedepend is broken */
+#ifndef NO_TCP_H
+#include <netinet/tcp.h>
+#endif /* NO_TCP_H */
+#else /* apollo */
+#include <netinet/tcp.h>
+#endif /* apollo */
+#endif
+#endif /* NEED_BSDISH */
+
+
+#ifdef DNETCONN
+static int MakeDECnetConnection (phostname, iagent, retries,
+ familyp, saddrlenp, saddrp)
+ char *phostname;
+ int iagent;
+ int retries;
+ int *familyp; /* RETURN */
+ int *saddrlenp; /* RETURN */
+ char **saddrp; /* RETURN */
+{
+ int fd;
+ char objname[20];
+ extern int dnet_conn();
+ struct dn_naddr *dnaddrp, dnaddr;
+ struct nodeent *np;
+
+ if (!phostname) phostname = "0";
+
+ /*
+ * build the target object name.
+ */
+ sprintf (objname, "DPS$EXECUTIVE_%d", iagent);
+
+ /*
+ * Attempt to open the DECnet connection, return -1 if fails; ought to
+ * do some retries here....
+ */
+ if ((fd = dnet_conn (phostname, objname, SOCK_STREAM, 0, 0, 0, 0)) < 0) {
+ return -1;
+ }
+
+ *familyp = FamilyDECnet;
+ if (dnaddrp = dnet_addr (phostname)) { /* stolen from xhost */
+ dnaddr = *dnaddrp;
+ } else {
+ if ((np = getnodebyname (phostname)) == NULL) {
+ (void) close (fd);
+ return -1;
+ }
+ dnaddr.a_len = np->n_length;
+ memmove(dnaddr.a_addr, np->n_addr, np->n_length);
+ }
+
+ *saddrlenp = sizeof (struct dn_naddr);
+ *saddrp = Xmalloc (*saddrlenp);
+ if (!*saddrp) {
+ (void) close (fd);
+ return -1;
+ }
+ memmove (*saddrp, (char *)&dnaddr, *saddrlenp);
+ return fd;
+}
+#endif /* DNETCONN */
+
+
+#ifdef UNIXCONN
+
+#ifndef X_NO_SYS_UN
+#include <sys/un.h>
+#endif
+
+#ifndef CSDPS_UNIX_PATH
+#ifdef hpux
+#define CSDPS_UNIX_DIR "/usr/spool/sockets/DPSNX"
+#define CSDPS_UNIX_PATH "/usr/spool/sockets/DPSNX/"
+#else
+#define CSDPS_UNIX_DIR "/tmp/.DPSNX-unix"
+#define CSDPS_UNIX_PATH "/tmp/.DPSNX-unix/AGENT"
+#endif
+#endif
+
+static int MakeUNIXSocketConnection (
+ char *phostname,
+ int iagent,
+ int retries,
+ int *familyp, /* RETURN */
+ int *saddrlenp, /* RETURN */
+ char **saddrp) /* RETURN */
+{
+ struct sockaddr_un unaddr; /* UNIX socket data block */
+ struct sockaddr *addr; /* generic socket pointer */
+ int addrlen; /* length of addr */
+ int fd; /* socket file descriptor */
+ int port = (iagent == 0) ? CSDPSPORT : iagent;
+
+ unaddr.sun_family = AF_UNIX;
+ sprintf (unaddr.sun_path, "%s_%d", CSDPS_UNIX_PATH, port);
+
+ addr = (struct sockaddr *) &unaddr;
+ addrlen = strlen(unaddr.sun_path) + sizeof(unaddr.sun_family);
+
+ /*
+ * Open the network connection.
+ */
+ do {
+ if ((fd = socket ((int) addr->sa_family, SOCK_STREAM, 0)) < 0) {
+ return -1;
+ }
+
+ if (gNXSndBufSize > 0)
+ setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *) &gNXSndBufSize, sizeof(gNXSndBufSize));
+
+ if (connect (fd, addr, addrlen) < 0) {
+ int olderrno = errno;
+ (void) close (fd);
+ if (olderrno != ENOENT || retries <= 0) {
+ errno = olderrno;
+ return -1;
+ }
+ sleep (1);
+ } else {
+ break;
+ }
+ } while (retries-- > 0);
+
+ /*
+ * Don't need to get auth info since we're local
+ */
+ return fd;
+}
+#endif /* UNIXCONN */
+
+
+#ifdef TCPCONN
+static int MakeTCPConnection (
+ char *phostname,
+ int iagent,
+ int retries,
+ int *familyp, /* RETURN */
+ int *saddrlenp, /* RETURN */
+ char **saddrp) /* RETURN */
+{
+ char hostnamebuf[256]; /* tmp space */
+ unsigned long hostinetaddr; /* result of inet_addr of arpa addr */
+ struct sockaddr_in inaddr; /* IP socket */
+ struct sockaddr *addr; /* generic socket pointer */
+ int addrlen; /* length of addr */
+ struct hostent *hp; /* entry in hosts table */
+ char *cp; /* character pointer iterator */
+ int fd; /* file descriptor to return */
+ int len; /* length tmp variable */
+
+#define INVALID_INETADDR ((unsigned long) -1)
+
+ if (!phostname) {
+ hostnamebuf[0] = '\0';
+ (void) N_XGetHostname (hostnamebuf, sizeof hostnamebuf);
+ phostname = hostnamebuf;
+ }
+
+ /*
+ * if numeric host name then try to parse it as such; do the number
+ * first because some systems return garbage instead of INVALID_INETADDR
+ */
+ if (isascii(phostname[0]) && isdigit(phostname[0])) {
+ hostinetaddr = inet_addr (phostname);
+ } else {
+ hostinetaddr = INVALID_INETADDR;
+ }
+
+ /*
+ * try numeric
+ */
+ if (hostinetaddr == INVALID_INETADDR) {
+ if ((hp = gethostbyname(phostname)) == NULL) {
+ /* No such host! */
+ return -1;
+ }
+ if (hp->h_addrtype != AF_INET) { /* is IP host? */
+ /* Not an Internet host! */
+ return -1;
+ }
+
+ /* Set up the socket data. */
+ inaddr.sin_family = hp->h_addrtype;
+#if defined(CRAY) && defined(OLDTCP)
+ /* Only Cray UNICOS3 and UNICOS4 will define this */
+ {
+ long t;
+ memmove ((char *)&t, (char *)hp->h_addr, sizeof(t));
+ inaddr.sin_addr = t;
+ }
+#else
+ memmove ((char *)&inaddr.sin_addr, (char *)hp->h_addr,
+ sizeof(inaddr.sin_addr));
+#endif /* CRAY and OLDTCP */
+ } else {
+#if defined(CRAY) && defined(OLDTCP)
+ /* Only Cray UNICOS3 and UNICOS4 will define this */
+ inaddr.sin_addr = hostinetaddr;
+#else
+ inaddr.sin_addr.s_addr = hostinetaddr;
+#endif /* CRAY and OLDTCP */
+ inaddr.sin_family = AF_INET;
+ }
+
+ addr = (struct sockaddr *) &inaddr;
+ addrlen = sizeof (struct sockaddr_in);
+ inaddr.sin_port = (iagent == 0) ? CSDPSPORT : iagent;
+ inaddr.sin_port = htons (inaddr.sin_port); /* may be funky macro */
+
+
+ /*
+ * Open the network connection.
+ */
+ do {
+ if ((fd = socket ((int) addr->sa_family, SOCK_STREAM, 0)) < 0) {
+ return -1;
+ }
+
+ /*
+ * turn off TCP coalescence
+ */
+#ifdef TCP_NODELAY
+ {
+ int tmp = 1;
+ setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, (char *)&tmp, sizeof (int));
+ }
+#endif
+ if (gNXSndBufSize > 0)
+ len = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *) &gNXSndBufSize, sizeof(gNXSndBufSize));
+
+ /*
+ * connect to the socket; if there is no X server or if the backlog has
+ * been reached, then ECONNREFUSED will be returned.
+ */
+ if (connect (fd, addr, addrlen) < 0) {
+ int olderrno = errno;
+ (void) close (fd);
+ if (olderrno != ECONNREFUSED || retries <= 0) {
+ errno = olderrno;
+ return -1;
+ }
+ sleep (1);
+ } else {
+ break;
+ }
+ } while (retries-- > 0);
+
+
+ /*
+ * Success! So, save the auth information
+ */
+#ifdef CRAY
+#ifdef OLDTCP
+ len = sizeof(inaddr.sin_addr);
+#else
+ len = SIZEOF_in_addr;
+#endif /* OLDTCP */
+ cp = (char *) &inaddr.sin_addr;
+#else /* else not CRAY */
+ len = sizeof(inaddr.sin_addr.s_addr);
+ cp = (char *) &inaddr.sin_addr.s_addr;
+#endif /* CRAY */
+
+ /*
+ * We are special casing the BSD hack localhost address
+ * 127.0.0.1, since this address shouldn't be copied to
+ * other machines. So, we simply omit generating the auth info
+ * since we set it to the local machine before calling this routine!
+ */
+ if (!((len == 4) && (cp[0] == 127) && (cp[1] == 0) &&
+ (cp[2] == 0) && (cp[3] == 1))) {
+ *saddrp = Xmalloc (len);
+ if (*saddrp) {
+ *saddrlenp = len;
+ memmove (*saddrp, cp, len);
+ *familyp = FamilyInternet;
+ } else {
+ *saddrlenp = 0;
+ }
+ }
+
+ return fd;
+}
+#undef INVALID_INETADDR
+#endif /* TCPCONN */
+
+
+/*****************************************************************************
+ * *
+ * Connection Utility Routines *
+ * *
+ *****************************************************************************/
+
+/*
+ * Disconnect from server.
+ */
+
+int N_XDisconnectDisplay (int server)
+{
+ (void) close(server);
+ return 0;
+}
+
+
+#include <stddef.h>
+/*
+ * This is an OS dependent routine which:
+ * 1) returns as soon as the connection can be written on....
+ * 2) if the connection can be read, must enqueue events and handle errors,
+ * until the connection is writable.
+ */
+void N_XWaitForWritable(Display *dpy)
+{
+ unsigned long r_mask[MSKCNT];
+ unsigned long w_mask[MSKCNT];
+ int nfound;
+
+ CLEARBITS(r_mask);
+ CLEARBITS(w_mask);
+
+ while (1) {
+ BITSET(r_mask, dpy->fd);
+ BITSET(w_mask, dpy->fd);
+
+ do {
+ nfound = select (dpy->fd + 1, (SELECT_TYPE) r_mask,
+ (SELECT_TYPE) w_mask, (SELECT_TYPE) NULL,
+ (struct timeval *) NULL);
+ if (nfound < 0 && errno != EINTR)
+ _XIOError(dpy);
+ } while (nfound <= 0);
+
+ if (_XANYSET(r_mask)) {
+ char buf[BUFSIZE];
+ long pend_not_register;
+ register long pend;
+ register xEvent *ev;
+
+ /* find out how much data can be read */
+ if (BytesReadable(dpy->fd, (char *) &pend_not_register) < 0)
+ _XIOError(dpy);
+ pend = pend_not_register;
+
+ /* must read at least one xEvent; if none is pending, then
+ we'll just block waiting for it */
+ if (pend < SIZEOF(xEvent)) pend = SIZEOF(xEvent);
+
+ /* but we won't read more than the max buffer size */
+ if (pend > BUFSIZE) pend = BUFSIZE;
+
+ /* round down to an integral number of XReps */
+ pend = (pend / SIZEOF(xEvent)) * SIZEOF(xEvent);
+
+ N_XRead (dpy, buf, pend);
+
+ /* no space between comma and type or else macro will die */
+ STARTITERATE (ev,xEvent, buf, (pend > 0),
+ (pend -= SIZEOF(xEvent))) {
+ if (ev->u.u.type == X_Error)
+ _XError (dpy, (xError *) ev);
+ else /* it's an event packet; die */
+ DPSFatalProc((DPSContext)0, "N_XWaitForWritable read bogus X event");
+ }
+ ENDITERATE
+ }
+ if (_XANYSET(w_mask))
+ return;
+ }
+}
+
+
+void N_XWaitForReadable(Display *dpy)
+{
+ unsigned long r_mask[MSKCNT];
+ int result;
+
+ CLEARBITS(r_mask);
+ do {
+ BITSET(r_mask, dpy->fd);
+ result = select(dpy->fd + 1, (SELECT_TYPE) r_mask, (SELECT_TYPE) NULL,
+ (SELECT_TYPE) NULL, (struct timeval *) NULL);
+ if (result == -1 && errno != EINTR) _XIOError(dpy);
+ } while (result <= 0);
+}
+
+#ifdef XXX
+
+static int padlength[4] = {0, 3, 2, 1}; /* make sure auth is multiple of 4 */
+
+_XSendClientPrefix (
+ Display *dpy,
+ xConnClientPrefix *client, /* contains count for auth_* */
+ char *auth_proto, /* NOT null-terminated */
+ char char *auth_string) /* NOT null-terminated */
+{
+ 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;
+
+#define add_to_iov(b,l) \
+ { iov->iov_base = (b); iov->iov_len = (l); iov++, niov++; }
+
+ 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
+
+ (void) WritevToServer (dpy->fd, iovarray, niov);
+ return;
+}
+
+#endif /* XXX */
diff --git a/nx-X11/lib/dps/csfindNX.c b/nx-X11/lib/dps/csfindNX.c
new file mode 100644
index 000000000..63b40acbc
--- /dev/null
+++ b/nx-X11/lib/dps/csfindNX.c
@@ -0,0 +1,657 @@
+/*
+ * csfindNX.c -- DPSCAP client Xlib extension hookup
+ *
+ * (c) Copyright 1992-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86: xc/lib/dps/csfindNX.c,v 1.7tsi Exp $ */
+
+#include <sys/param.h> /* for MAXHOSTNAMELEN */
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h> /* getuid() */
+#include <string.h>
+#include <pwd.h>
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xresource.h>
+
+#include "csfindNX.h"
+#include "dpsNXprops.h"
+#include "Xlibnet.h"
+#include "DPS/dpsXclient.h"
+#include "DPS/dpsNXargs.h"
+#include <DPS/XDPSlib.h>
+
+#include "dpsassert.h"
+#include "cslibint.h"
+
+/* ---Defines--- */
+
+#define CANTSTARTAGENT "Unable to start agent.\n"
+
+/* ---Types--- */
+
+typedef struct {
+ Window id;
+ int willingness;
+} Agent, *AgentIdList;
+
+/* ---Globals--- */
+
+static char *XDPSLNXHost = NULL;
+static int XDPSLNXPort = 0; /* default port to be used */
+static int XDPSLNXTrans = XDPSNX_TRANS_UNIX;
+static int gXDPSNXLaunchedAgentTrans = XDPSNX_USE_BEST;
+static int gXDPSNXLaunchedAgentPort = XDPSNX_USE_BEST;
+static char *gXDPSNXExecObj = XDPSNX_DEFAULT_EXEC_NAME; /* NX object file */
+static char **gXDPSNXExecArgs = NULL; /* the args for gXDPSNXExecObj */
+static Bool gWasAgentSet = False;
+static Bool gXDPSNXAutoLaunch = False;
+unsigned char gXDPSNXErrorCode;
+extern int gNXSndBufSize; /* Output buffer size, zero means default */
+
+static char *getHomeDir(char *);
+
+/* ---Private Functions--- */
+
+static int
+TmpErrorHandler(
+ Display *dpy,
+ XErrorEvent *err)
+{
+ gXDPSNXErrorCode = err->error_code;
+ return 0;
+}
+
+
+static int
+GetProperty(
+ Display *dpy,
+ Window w,
+ Atom prop,
+ Atom type,
+ unsigned long *nitems, /* IN: if non-null then RETURN val */
+ char **data) /* RETURN */
+{
+ long largest_len = ((((unsigned long) -1) >> 1) / 4);
+ Atom actual_type;
+ int actual_format;
+ unsigned long actual_number;
+ unsigned long remaining;
+
+ if (type == None) return(!Success); /* We need to have a type */
+ if ((XGetWindowProperty(dpy, w, prop, 0, largest_len, False, type,
+ &actual_type, &actual_format, &actual_number,
+ &remaining, (unsigned char **) data) == Success)
+ && (actual_type == type)) {
+ if (nitems != NULL) *nitems = actual_number;
+ return(Success);
+ } else {
+ if (*nitems != 0) { /* if data returned, clean up */
+ XFree(*data);
+ *data = NULL; /* is this necessary? */
+ *nitems = 0;
+ }
+ return(!Success);
+ }
+}
+
+
+/*
+ GetAgentIdList returns a list of agents advertising on the passed display (dpy),
+ and it returns the number of agents in the list in the parameter nAgents.
+ The returned list is sorted in most to least willing order.
+ GetAgentIdList assumes that it has exclusive access to the server associated with
+ dpy (ie. it assumes that the caller has done an XGrabServer).
+ */
+static AgentIdList
+GetAgentIdList(
+ Display *dpy,
+ unsigned long *nAgents) /* RETURN: number of agents in list */
+{
+ Atom serverListAtom = XInternAtom(dpy, XDPSNX_BILLBOARD_PROP, True);
+ Window *agents = NULL;
+ AgentIdList agentList = NULL;
+ int (*oldErrorHandler)(Display *, XErrorEvent *) = 0; /* the current error handler */
+ unsigned long i, current;
+
+ if (serverListAtom == None) { /* Servers registered on dpy */
+ goto failed;
+ }
+
+ XSync(dpy, False); /* force processing of pending requests */
+
+ if (GetProperty(dpy, RootWindow(dpy, DefaultScreen(dpy)),
+ serverListAtom, XA_WINDOW, nAgents,
+ (char **) &agents) != Success) {
+ goto failed;
+ }
+
+ if ((agentList = (AgentIdList)
+ Xcalloc(*nAgents, (unsigned) sizeof(Agent))) == NULL)
+ goto failed;
+
+ /* let's go through the list and figure out which servers are okay */
+ oldErrorHandler = XSetErrorHandler(TmpErrorHandler);
+ current = 0;
+ for (i=0; i < *nAgents; i++) {
+ unsigned long len;
+ int *agentWillingness;
+ unsigned long k;
+
+ for (k=0; k < i; k++) /* Search for duplicate ids */
+ if (agents[i] == agents[k]) { /* uh oh... */
+ agents[i] = None;
+ break;
+ }
+ if (k == i) { /* No duplicate ids */
+ if (GetProperty(dpy, agents[i],
+ XInternAtom(dpy, XDPSNX_WILLINGNESS_PROP, True),
+ XA_INTEGER, &len, (char **) &agentWillingness)
+ != Success) {
+ /* Assume that Agent i is dead... */
+ /* reap the agent */
+ agents[i] = None;
+ gXDPSNXErrorCode = None;
+ } else {
+ unsigned long j = 0;
+
+ /* insert the agents into agentList in "most to least willing" order */
+ while ((j < current) && (agentList[j].willingness > *agentWillingness))
+ j++;
+ if (j < current)
+ (void) bcopy((char *) &agentList[j], (char *) &agentList[j+1],
+ sizeof(Agent) * (*nAgents - j - 1));
+ agents[current] = agents[i];
+ agentList[j].id = agents[current++];
+ agentList[j].willingness = *agentWillingness;
+ XFree(agentWillingness);
+ }
+ }
+ }
+ (void) XSetErrorHandler(oldErrorHandler);
+ oldErrorHandler = NULL;
+ if (*nAgents != current) { /* agent list changed */
+ if (current > 0) { /* are there living ones? */
+ *nAgents = current;
+ /* write the list back out onto the root window */
+ (void) XChangeProperty(dpy, RootWindow(dpy, DefaultScreen(dpy)),
+ serverListAtom, XA_WINDOW, 32,
+ PropModeReplace, (unsigned char *) agents, *nAgents);
+ } else {
+ (void) XDeleteProperty(dpy, RootWindow(dpy, DefaultScreen(dpy)),
+ serverListAtom);
+ goto failed;
+ }
+ }
+ (void) XFree(agents);
+ return(agentList);
+
+ failed:
+ if (agents != NULL) XFree(agents);
+ if (agentList != NULL) XFree(agentList);
+ if (oldErrorHandler != NULL) (void) XSetErrorHandler(oldErrorHandler);
+ *nAgents = 0;
+ return(NULL);
+}
+
+
+static int
+XDPSNXOnDisplay(
+ Display *dpy,
+ char *licenseMethod,
+ char **host,
+ int *transport,
+ int *port)
+{
+ unsigned long nAgents = 0;
+ AgentIdList agentList = NULL;
+ Bool match = False;
+ unsigned long i = 0;
+ int status = !Success;
+
+#ifdef DPSLNKL
+ extern unsigned ANXKFunc();
+#endif /* DPSLNKL */
+
+ (void) XGrabServer(dpy); /* Can we do this later? */
+ if ((agentList = GetAgentIdList(dpy, &nAgents)) == NULL)
+ goto cleanup;
+ /* NOTE: agentList was sorted most to least willing by GetAgentIdList */
+ if (agentList[i].willingness <= 0) { /* Is there a willing agent? */
+ DPSWarnProc(NULL, "Found agent(s) for display, but none willing to accept connections.\n");
+ goto cleanup;
+ }
+
+#ifdef DPSLNKL
+ /* Masterkey bypass code */
+ if (ANXKFunc() != 0) {
+ /* We have a willing agent and the client has masterkeys so... */
+ match = True;
+ } else /* Search for appropriate agent */
+#endif /* DPSLNKL */
+ {
+ /* need to get licensing info from dpy */
+ Atom desiredLicenseMethod, openLicenseMethod;
+ char openLicenseString[256];
+
+ (void) sprintf(openLicenseString, "%s:%d",
+ LICENSE_METHOD_OPEN,
+ OPEN_LICENSE_VERSION);
+ openLicenseMethod = XInternAtom(dpy, openLicenseString, True);
+
+ if (licenseMethod != NULL)
+ desiredLicenseMethod = XInternAtom(dpy, licenseMethod, True);
+ else
+ desiredLicenseMethod = None;
+
+ if ((desiredLicenseMethod != None) || (openLicenseMethod != None)) {
+ for (i=0;
+ (i < nAgents) && (agentList[i].willingness > 0) && (match == False);
+ i++) {
+ Atom *licenseMethods = NULL;
+ unsigned long nMethods;
+ unsigned long j;
+
+ if (GetProperty(dpy, agentList[i].id,
+ XInternAtom(dpy, XDPSNX_LICENSE_METHOD_PROP, True),
+ XA_ATOM,
+ &nMethods, (char **) &licenseMethods) != Success)
+ goto cleanup;
+
+ /*
+ Check to see if the agent supports either our desired license method or
+ if it is an open service.
+ */
+ j = 0;
+ while((j < nMethods)
+ && (licenseMethods[j] != desiredLicenseMethod)
+ && (licenseMethods[j] != openLicenseMethod)) j++;
+ if (j < nMethods) { /* We found one */
+ match = True;
+ break;
+ }
+ (void) XFree(licenseMethods);
+ }
+ }
+ }
+
+ if (match) { /* We had a match on license method */
+ TransportInfo *transInfo;
+
+ if (GetProperty(dpy, agentList[i].id,
+ XInternAtom(dpy, XDPSNX_TRANSPORT_INFO_PROP, True),
+ XA_INTEGER, NULL, (char **) &transInfo) != Success) {
+ goto cleanup;
+ } else { /* We got one! */
+ *transport = transInfo->transport;
+ *port = transInfo->port;
+ match = True;
+ XFree(transInfo);
+ }
+ if (GetProperty(dpy, agentList[i].id,
+ XInternAtom(dpy, XDPSNX_HOST_NAME_PROP, True), XA_STRING,
+ NULL, (char **) host) == Success) {
+ status = Success;
+ /*
+ * If transport is TCP, but we are on the same host as the agent then
+ * trade-up to the more efficient UNIX transport...
+ */
+ if (*transport == XDPSNX_TRANS_TCP) {
+ char hostname[MAXHOSTNAMELEN];
+ (void) N_XGetHostname(hostname, MAXHOSTNAMELEN);
+ if (strcmp(hostname, *host) == 0)
+ *transport = XDPSNX_TRANS_UNIX;
+ }
+ }
+ }
+ /*
+ * Exit Clauses: status inited to FAILURE. Therefore cleanup "assumes"
+ * a failure unless noted otherwise.
+ */
+ cleanup:
+ (void) XUngrabServer(dpy);
+ (void) XDPSLFlush(dpy); /* Flush the ungrab */
+ if (agentList != NULL) XFree(agentList);
+ return(status);
+}
+
+
+static int
+ParseAgentString(
+ char *string,
+ char **hostname, /* RETURN */
+ int *transport, /* RETURN */
+ int *port) /* RETURN */
+{
+ int dnet = 0;
+ Bool transportSpecified = False;
+ char namebuf[255];
+ char *p;
+
+ (void) strncpy(namebuf, string, strlen(string)+1);
+ p = &namebuf[0];
+ /*
+ * Step 1, find the hostname. This is delimited by a required colon.
+ */
+ for (; *p && *p != ':'; p++);
+ if (!*p) return(!Success); /* There must be a colon */
+
+ if (*(p+1) == ':') {
+ dnet++;
+ *(p++) = '\0';
+ }
+ *(p++) = '\0';
+
+ /*
+ * Step 2, get the port number. It follows the colon(s)
+ */
+ if (*p == '\0') /* No port number specified... */
+ return(!Success);
+
+ *port = atoi(p);
+
+ /*
+ * Step 3, transport?
+ */
+ if (namebuf[0] == '\0') { /* no transport/hostname specified... */
+ if (dnet)
+ (void) strcpy(namebuf, "0");
+ else { /* no hostname, so must be UNIX */
+ *hostname = NULL;
+ *transport = XDPSNX_TRANS_UNIX;
+ return(Success);
+ }
+ } else {
+ /* find the delimiting '/' */
+ for (p = &namebuf[0]; *p && *p != '/'; p++);
+ if (*p == '/') {
+ transportSpecified = True;
+ *p = '\0';
+ p++;
+ } else /* no transport specified */
+ p = &namebuf[0];
+ if ((*hostname = (char *) Xmalloc(strlen(p))) == NULL)
+ return(!Success); /* can't alloc space for hostname */
+ (void) strcpy(*hostname, p);
+
+ /* identify protocol */
+ if (dnet)
+ *transport = XDPSNX_TRANS_DECNET;
+ else if (transportSpecified) {
+ if (strcmp(namebuf, "unix") == 0)
+ *transport = XDPSNX_TRANS_UNIX;
+ else /* assume tcp */
+ *transport = XDPSNX_TRANS_TCP;
+ } else
+ *transport = XDPSNX_TRANS_TCP;
+ }
+ return(Success);
+}
+
+static int
+FindXDPSNXInXrmDatabase(
+ Display *dpy,
+ char **host,
+ int *transport,
+ int *port)
+{
+ XrmDatabase rDB = NULL; /* for merged database */
+ XrmDatabase serverDB;
+ char filenamebuf[1024];
+ char *filename = &filenamebuf[0];
+ char *env, *str_type;
+ char name[255];
+ XrmValue value;
+ int retVal = !Success;
+
+ XrmInitialize();
+ (void) strcpy(name, "/usr/lib/X11/app-defaults/");
+ (void) strcat(name, XDPSNX_X_CLASS_NAME);
+
+ /* try to get application defaults file, if there is any */
+ XrmMergeDatabases(XrmGetFileDatabase(name), &rDB);
+
+ /* try to merge the server defaults. if not defined then use .Xdefaults */
+ if (XResourceManagerString(dpy) != NULL) {
+ serverDB = XrmGetStringDatabase(XResourceManagerString(dpy));
+ } else { /* use the .Xdefaults */
+ (void) getHomeDir(filename);
+ (void) strcat(filename, "/.Xdefaults");
+
+ serverDB = XrmGetFileDatabase(filename);
+ }
+ XrmMergeDatabases(serverDB, &rDB);
+
+ /* try the XENVIRONMENT file, or if not defined, then .Xdefaults */
+ if ((env = getenv("XENVIRONMENT")) == NULL) {
+ int len;
+ env = getHomeDir(filename);
+ (void) strcat(filename, "/.Xdefaults-");
+ len = strlen(env);
+ (void) gethostname(env+len, 1024-len);
+ }
+ XrmMergeDatabases(XrmGetFileDatabase(env), &rDB);
+
+ /* Now that the database is built, try to extract the values we want. */
+
+ if (XrmGetResource(rDB, XDPSNX_X_RESOURCE, XDPSNX_X_CLASS_NAME, &str_type,
+ &value) == True) {
+ retVal = ParseAgentString((char *) value.addr, host, transport, port);
+ }
+ (void) XrmDestroyDatabase(rDB);
+ return(retVal);
+}
+
+
+static char *
+getHomeDir(char *dest)
+{
+ register char *ptr;
+
+ if ((ptr = getenv("HOME")) != NULL) {
+ (void) strcpy(dest, ptr);
+ } else {
+ struct passwd *pw;
+
+ if ((ptr = getenv("USER")) != NULL) {
+ pw = getpwnam(ptr);
+ } else {
+ pw = getpwuid(getuid());
+ }
+ if (pw) {
+ (void) strcpy(dest, pw->pw_dir);
+ } else {
+ *dest = ' ';
+ }
+ }
+ return (dest);
+}
+
+
+
+/* ---Public Functions--- */
+
+int gForceLaunchHack = 0; /* Undocumented way to force autolaunch */
+
+XDPSNXFindNXResult
+XDPSNXFindNX(
+ Display *dpy,
+ char *licenseMethod,
+ char **host,
+ int *transport,
+ int *port)
+{
+ char *agentenv;
+
+ if (gForceLaunchHack)
+ return(findnx_not_found);
+
+ if (gWasAgentSet) { /* check if client set up host */
+ *host = XDPSLNXHost;
+ *transport = XDPSLNXTrans;
+ *port = XDPSLNXPort;
+ return(findnx_found);
+ /* check DPSNXHOST environment variable */
+ } else if ((agentenv = getenv(AGENT_ENV_VAR)) != NULL) {
+ int status = ParseAgentString(agentenv, host, transport, port);
+ if (status != Success) {
+ DPSWarnProc((DPSContext) NULL, "Illegal syntax for DPSNXHOST");
+ return(findnx_error);
+ } else return(findnx_found);
+ /* check advertisements... */
+ } else if (XDPSNXOnDisplay(dpy, licenseMethod, host, transport, port) ==
+ Success) {
+ return(findnx_found);
+ /* check XrmDatabase */
+ } else if (FindXDPSNXInXrmDatabase(dpy, host, transport, port) == Success) {
+ return(findnx_found);
+ }
+ /* Nada */
+ return(findnx_not_found);
+}
+
+
+Status
+XDPSNXSetClientArg(int arg, void *value)
+{
+ Display *dpy;
+
+ if (arg == XDPSNX_AGENT) {
+ gWasAgentSet = True;
+ return(ParseAgentString(value,
+ &XDPSLNXHost, &XDPSLNXTrans, &XDPSLNXPort));
+ }
+ else if (arg == XDPSNX_EXEC_FILE) {
+ if ((gXDPSNXExecObj = Xmalloc(strlen((char *) value) + 1)) == NULL) {
+ return(!Success);
+ }
+ gXDPSNXExecObj = strcpy(gXDPSNXExecObj, (char *) value);
+ } else if (arg == XDPSNX_EXEC_ARGS) {
+ int i;
+ char **cpp, **execInfo;
+
+ execInfo = (char **) value;
+ for(cpp = execInfo, i = 1; *cpp != NULL; i++, cpp++); /* count */
+ gXDPSNXExecArgs = (char **) Xcalloc(i, sizeof(char *));
+ if (gXDPSNXExecArgs == NULL) return(!Success);
+ for(cpp = gXDPSNXExecArgs; *execInfo != NULL;
+ execInfo++, cpp++) {
+ /* copy each entry */
+ if ((*cpp = Xmalloc(strlen(*execInfo) + 1)) == NULL)
+ return(!Success);
+ *cpp = strcpy(*cpp, *execInfo);
+ }
+ } else if (arg == XDPSNX_AUTO_LAUNCH) {
+ gXDPSNXAutoLaunch = (Bool)(long) value;
+ } else if (arg == XDPSNX_LAUNCHED_AGENT_TRANS) {
+ gXDPSNXLaunchedAgentTrans = (long) value;
+ } else if (arg == XDPSNX_LAUNCHED_AGENT_PORT) {
+ gXDPSNXLaunchedAgentPort = (long) value;
+ } else if (arg == XDPSNX_REQUEST_XSYNC) {
+ dpy = (Display *) value;
+ if (dpy == (Display *)NULL)
+ return(Success);
+ XDPSLSetSyncMask(dpy, DPSCAP_SYNCMASK_SYNC);
+ } else if (arg == XDPSNX_REQUEST_RECONCILE) {
+ dpy = (Display *) value;
+ if (dpy == (Display *)NULL)
+ return(Success);
+ XDPSLSetSyncMask(dpy, DPSCAP_SYNCMASK_RECONCILE);
+ } else if (arg == XDPSNX_REQUEST_BUFFER) {
+ dpy = (Display *) value;
+ if (dpy == (Display *)NULL)
+ return(Success);
+ XDPSLSetSyncMask(dpy, DPSCAP_SYNCMASK_BUFFER);
+ } else if (arg == XDPSNX_GC_UPDATES_SLOW) {
+ dpy = (Display *) value;
+ if (dpy == (Display *)NULL)
+ return(Success);
+ XDPSLSetGCFlushMode(dpy, XDPSNX_GC_UPDATES_SLOW);
+ } else if (arg == XDPSNX_GC_UPDATES_FAST) {
+ dpy = (Display *) value;
+ if (dpy == (Display *)NULL)
+ return(Success);
+ XDPSLSetGCFlushMode(dpy, XDPSNX_GC_UPDATES_FAST);
+ } else if (arg == XDPSNX_SEND_BUF_SIZE) {
+ int i = (long)value;
+ if (i >= 4096 && i <= 65536) gNXSndBufSize = i;
+ }
+ return(Success);
+}
+
+
+void
+XDPSGetNXArg(int arg, void **value)
+{
+ static char agentBuffer[255];
+
+ if (arg == XDPSNX_AGENT) {
+ switch(XDPSLNXTrans) {
+ case XDPSNX_TRANS_UNIX:
+ (void) sprintf(agentBuffer, "unix/");
+ break;
+ case XDPSNX_TRANS_TCP:
+ (void) sprintf(agentBuffer, "tcp/");
+ break;
+ case XDPSNX_TRANS_DECNET:
+ (void) sprintf(agentBuffer, "decnet/");
+ break;
+ default:
+ DPSWarnProc(NULL, "Unknown transport passed to XDPSGetNXArg ignored.\n");
+ agentBuffer[0] = '\0';
+ break;
+ }
+ (void) strcat(agentBuffer, XDPSLNXHost);
+ (void) strcat(agentBuffer,
+ (XDPSLNXTrans == XDPSNX_TRANS_DECNET ? "::" : ":"));
+ (void) sprintf(&agentBuffer[strlen(agentBuffer)], "%d", XDPSLNXPort);
+ *value = (void *) agentBuffer;
+ }
+ else if (arg == XDPSNX_EXEC_FILE) {
+ *value = (void *) gXDPSNXExecObj;
+ } else if (arg == XDPSNX_EXEC_ARGS) {
+ *value = (void *) gXDPSNXExecArgs;
+ } else if (arg == XDPSNX_AUTO_LAUNCH) {
+ *value = (void *) (long)gXDPSNXAutoLaunch;
+ } else if (arg == XDPSNX_LAUNCHED_AGENT_TRANS) {
+ *value = (void *) (long)gXDPSNXLaunchedAgentTrans;
+ } else if (arg == XDPSNX_LAUNCHED_AGENT_PORT) {
+ *value = (void *) (long)gXDPSNXLaunchedAgentPort;
+ }
+}
diff --git a/nx-X11/lib/dps/csfindNX.h b/nx-X11/lib/dps/csfindNX.h
new file mode 100644
index 000000000..f5bf3bdc9
--- /dev/null
+++ b/nx-X11/lib/dps/csfindNX.h
@@ -0,0 +1,93 @@
+/*
+ * csfindNX.h
+ *
+ * (c) Copyright 1992-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#ifndef CSFINDNX_H
+#define CSFINDNX_H
+
+
+/* ---DEFINES--- */
+
+#define XDPSNX_DEFAULT_EXEC_NAME "dpsnx.agent"
+
+/* ---TYPES--- */
+
+typedef enum {
+ findnx_found,
+ findnx_not_found,
+ findnx_error
+} XDPSNXFindNXResult;
+
+
+/* ---Functions--- */
+
+extern XDPSNXFindNXResult
+XDPSNXFindNX (
+ Display *dpy, /* Display client wants to attach to */
+ char *licenseMethod, /* license method client speaks */
+ char **host, /* RETURN: Agent host name */
+ int *transport, /* RETURN: Agent transport */
+ int *port); /* RETURN: Agent's port */
+ /*
+ * Find an agent for this client that will service display dpy.
+ * The licenseMethod arg. specifies the type of licensing that the client
+ * is capable of speaking. A (char *) NULL, means that it can handle
+ * any type (i.e. master key in lock & key).
+ * Return values indicates success in finding an agent.
+ * Success: host, transport, and port indicate where the agent is.
+ * !Success: the values of host, transport, and port are undefined.
+ * The client of the call is responsible for freeing the space (XFree())
+ * allocated for the host name string.
+ */
+
+
+extern void
+XDPSGetNXArg (
+ int arg, /* Argument to be retrieved */
+ void **value); /* value of the argument */
+ /*
+ Gets the value of the given argument. Returns the value in val. If the
+ value will fit in val (ie, a Bool) then the value is placed there,
+ otherwise a pointer to the value is placed there. It is assumed that
+ the caller will know the correct type. The types of arguments are
+ detailed with the argument definitions in dpsNXargs.h.
+ NOTE: the caller should NOT modify any values returned via pointer.
+ XDPSGetNXArg does not copy the data, rather it returns a pointer to the
+ internally held structure.
+ */
+
+#endif /* CSFINDNX_H */
diff --git a/nx-X11/lib/dps/cslibext.c b/nx-X11/lib/dps/cslibext.c
new file mode 100644
index 000000000..831f0ad65
--- /dev/null
+++ b/nx-X11/lib/dps/cslibext.c
@@ -0,0 +1,762 @@
+/*
+ * cslibext.c -- DPSCAP client Xlib extension hookup
+ *
+ * (c) Copyright 1991-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86: xc/lib/dps/cslibext.c,v 1.4tsi Exp $ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sys/param.h> /* for MAXHOSTNAMELEN */
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/Xlibint.h>
+#include "cslibint.h"
+#include <DPS/XDPS.h>
+#include <DPS/XDPSproto.h>
+#include <DPS/dpsXclient.h>
+#include <DPS/dpsNXargs.h>
+#include "DPSCAPClient.h"
+#include "dpsassert.h"
+#include <DPS/XDPSlib.h>
+
+#include "publictypes.h"
+#include "dpsXpriv.h"
+
+/* === DEFINES === */
+
+#define DPSNXSYNCGCMODE_FLUSH 0
+#define DPSNXSYNCGCMODE_SYNC 1
+#define DPSNXSYNCGCMODE_DELAYED 2
+#define DPSNXSYNCGCMODE_DEFAULT DPSNXSYNCGCMODE_DELAYED
+
+/* === GLOBALS === */
+
+DPSCAPGlobals gCSDPS = NULL;
+
+#ifdef DPSLNKL
+#define ANXCYAN
+#define ANXMAGENTA
+#define ANXYELLOW
+#define ANXBLACK
+#define ANXSPOT
+#include "dpslnkl.inc"
+#endif /* DPSLNKL */
+
+int gNXSyncGCMode = DPSNXSYNCGCMODE_DEFAULT;
+
+/* === PUBLIC PROCS === */
+
+#ifdef MAHALO
+static int
+DPSCAPFlushAfterProc(Display *agent)
+{
+ LockDisplay(agent);
+ N_XFlush(agent);
+ UnlockDisplay(agent);
+}
+#endif
+
+int
+CSDPSInit(
+ Display *dpy,
+ int *numberType, /* RETURN */
+ char **floatingName) /* RETURN */
+{
+ register Display *agent;
+ register xCAPConnReplyPrefix *p;
+ register char *c;
+ DPSCAPData my;
+ xCAPConnSetupReq setup;
+ union {
+ xCAPConnSuccess good;
+ xCAPConnFailed bad;
+ } reply;
+ XExtData *extData;
+ XExtCodes *codes;
+ int indian;
+ int rest;
+ Window clientWindow;
+ char fullDisplayName[MAXHOSTNAMELEN+10];
+
+ if (gCSDPS == NULL)
+ DPSCAPStartUp();
+
+ /* To fix dps-nx #68, Motif too slow on HP */
+ if ((c = getenv("DPSNXGCMODE")) != 0)
+ {
+ gNXSyncGCMode = atoi(c);
+ if (gNXSyncGCMode < DPSNXSYNCGCMODE_FLUSH
+ || gNXSyncGCMode > DPSNXSYNCGCMODE_DELAYED)
+ gNXSyncGCMode = DPSNXSYNCGCMODE_DEFAULT;
+ }
+
+ /* We may have already called this routine via XDPSExtensionPresent,
+ so don't do it again! */
+
+ if ((codes = XDPSLGetCodes(dpy))
+ && (agent = XDPSLGetShunt(dpy))
+ && agent != dpy
+ && codes->major_opcode == DPSXOPCODEBASE)
+ return(DPSCAPSUCCESS);
+
+ /* Try to create a window for ClientMessage communication */
+
+ clientWindow = XCreateSimpleWindow(
+ dpy,
+ DefaultRootWindow(dpy),
+ 0, 0,
+ 1, 1,
+ 0,
+ BlackPixel(dpy, DefaultScreen(dpy)),
+ WhitePixel(dpy, DefaultScreen(dpy)));
+ if (clientWindow == None)
+ return(DPSCAPFAILED);
+
+ /* Try to open a connection to an agent */
+
+ if ((extData = DPSCAPOpenAgent(dpy, fullDisplayName)) == NULL)
+ {
+ XDestroyWindow(dpy, clientWindow);
+ return(DPSCAPFAILED);
+ }
+
+ /* DPSCAPOpenAgent only partially fills in extData, so finish it */
+
+ codes = XAddExtension(dpy);
+ codes->major_opcode = DPSXOPCODEBASE;
+ codes->first_event = 0; /* REQUIRED */
+ codes->first_error = FirstExtensionError;
+ extData->number = codes->extension;
+ extData->free_private = DPSCAPDestroy;
+ my = (DPSCAPData) extData->private_data;
+ my->codes = codes;
+ agent = my->agent;
+ /* +++ Is this all we have to do here? */
+
+ /* Send opening handshake */
+
+ indian = 1;
+ if (*(char *) &indian)
+ setup.byteorder = 'l';
+ else
+ setup.byteorder = 'B';
+ setup.dpscapVersion = DPSCAPPROTOVERSION;
+ setup.flags = DPSCAPNONEFLAG;
+ setup.libraryversion = DPSPROTOCOLVERSION;
+ setup.authProtoNameLength = 0;
+ setup.authProtoDataLength = 0;
+ setup.displayStringLength = strlen(fullDisplayName);
+ setup.nodeStringLength = 0;
+ setup.transportStringLength = 0;
+ setup.display = 0;
+ setup.screen = 0;
+ setup.reserved = 0;
+ setup.clientWindow = clientWindow;
+
+#ifndef DPSLNKL
+ DPSCAPWrite(agent, (char *)&setup, sizeof(xCAPConnSetupReq), dpscap_nopad,dpscap_insert);
+ DPSCAPWrite(agent, fullDisplayName, setup.displayStringLength, dpscap_pad, dpscap_append);
+ N_XFlush(agent);
+#else /* DPSLNKL */
+ if (CSDPSConfirmDisplay(agent, dpy, &setup, &reply, fullDisplayName) == 1)
+ {
+ p = (xCAPConnReplyPrefix *)&reply.good;
+ goto skip_read;
+ }
+ /* Read normal reply */
+#endif /* DPSLNKL */
+
+ /* Read common reply prefix */
+
+ p = (xCAPConnReplyPrefix *)&reply.good;
+ N_XRead(agent, (char *)p, (long)sizeof(xCAPConnReplyPrefix));
+#ifdef DPSLNKL
+skip_read:
+#endif
+ if (!p->success)
+ {
+ char mbuf[512];
+ /* read the rest */
+ c = (char *)&reply.bad.serverVersion;
+ N_XRead(agent, c, sz_xCAPConnFailed - sz_xCAPConnReplyPrefix);
+ sprintf(mbuf, "DPS NX: connection to \"%s\" refused by agent.", DisplayString(agent));
+ DPSWarnProc(NULL, mbuf);
+ c = (char *)Xmalloc(reply.bad.reasonLength);
+ if (!c) return(DPSCAPFAILED);
+ N_XReadPad(agent, c, (long)reply.bad.reasonLength);
+ if (!reply.bad.reasonLength)
+ sprintf(mbuf, "DPS NX: (no reason given)\n");
+ else
+ {
+ strcpy(mbuf, "DPS NX: ");
+ strncat(mbuf, c, reply.bad.reasonLength);
+ mbuf[reply.bad.reasonLength+7] = '\0';
+ }
+ DPSWarnProc(NULL, mbuf);
+ Xfree(c);
+ DPSCAPDestroy(extData);
+ Xfree(extData);
+ XDestroyWindow(dpy, clientWindow);
+ return(DPSCAPFAILED);
+ }
+
+ /* read the rest of the fixed length reply */
+ c = (char *)&reply.good.serverVersion;
+ rest = sizeof(xCAPConnSuccess) - sizeof(xCAPConnReplyPrefix);
+ N_XRead(agent, c, rest);
+
+ /* verify */
+
+ if (reply.good.serverVersion < DPSPROTOCOLVERSION)
+ {
+ /* Fine, we downgrade the client */
+ char qbuf[256];
+ sprintf(qbuf, "NX: server version %ld older than expected %d, client will downgrade", (long)reply.good.serverVersion, DPSPROTOCOLVERSION);
+ DPSWarnProc(NULL, qbuf);
+ }
+ my->dpscapVersion = reply.good.dpscapVersion;
+ if (my->dpscapVersion < DPSCAPPROTOVERSION)
+ {
+ /* Fine, we downgrade the client */
+ char kbuf[256];
+ sprintf(kbuf, "NX: agent version %d older than expected %d, client will downgrade", my->dpscapVersion, DPSCAPPROTOVERSION);
+ DPSWarnProc(NULL, kbuf);
+#ifdef XXX
+ /* Saving this code as a reminder about what needs to be
+ cleaned up if we exit here */
+ DPSCAPDestroy(extData);
+ Xfree(extData);
+ XDestroyWindow(clientWindow);
+ return(DPSCAPFAILED);
+#endif
+ }
+
+ if (numberType)
+ *numberType = reply.good.preferredNumberFormat;
+
+ /* read additional data */
+
+ c = (char *)Xmalloc(reply.good.floatingNameLength + 1);
+ N_XReadPad(agent, c, reply.good.floatingNameLength);
+ c[reply.good.floatingNameLength] = 0;
+ if (floatingName)
+ *floatingName = c;
+ else
+ Xfree(c);
+
+ /* set library extension data */
+
+ XDPSLSetVersion(agent, reply.good.serverVersion);
+ XDPSLSetVersion(dpy, reply.good.serverVersion);
+ XDPSLSetShunt(dpy, agent);
+ XDPSLSetCodes(dpy, codes);
+ if (XDPSLGetSyncMask(dpy) == DPSCAP_SYNCMASK_NONE)
+ XDPSLSetSyncMask(dpy, DPSCAP_SYNCMASK_DFLT);
+ my->agentWindow = reply.good.agentWindow;
+ XDPSLSetGCFlushMode(dpy, XDPSNX_GC_UPDATES_SLOW); /* default */
+
+ /* Hook my extension data on the dpy */
+
+ my->extData = extData;
+ XAddToExtensionList(CSDPSHeadOfDpyExt(dpy), extData);
+ (void) XESetCloseDisplay(dpy, codes->extension, DPSCAPCloseDisplayProc);
+ (void) XESetCopyGC(dpy, codes->extension, DPSCAPCopyGCProc);
+ (void) XESetFreeGC(dpy, codes->extension, DPSCAPFreeGCProc);
+ (void) XESetFlushGC(dpy, codes->extension, DPSCAPFlushGCProc);
+ XDPSLSetClientMessageHandler(dpy);
+
+ /* Chain my data on global list */
+
+ my->next = gCSDPS->head;
+ gCSDPS->head = my;
+
+#ifdef MAHALO
+ /* Set function that is called after every Xlib protocol proc */
+ XDPSLSetAfterProc(dpy);
+
+ /* All CSDPS protocol is auto-flushed */
+ (void) XSetAfterFunction(agent, DPSCAPFlushAfterProc);
+#endif /* MAHALO */
+
+ /* set agent arguments, if needed */
+ /* must follow setting of ShuntMap at least, so safest to
+ do here when everything has been setup */
+ XDPSLUpdateAgentArgs(dpy);
+
+ return(DPSCAPSUCCESS);
+}
+
+
+XExtData **
+CSDPSHeadOfDpyExt(
+ Display *dpy)
+{
+ XEDataObject object;
+
+ object.display = dpy;
+ return(XEHeadOfExtensionList(object));
+}
+
+void
+XDPSSyncGCClip(
+ register Display *dpy,
+ register GC gc)
+{
+ /* The primary utility of this function is for DPS NX correctness,
+ but it also helps DPS/X do less work in tracking GC changes. */
+ XDPSLSyncGCClip(dpy, gc);
+}
+
+void
+XDPSReconcileRequests(
+ register DPSContext ctxt)
+{
+ Display *dpy;
+ register ContextXID cxid;
+ register DPSContext curCtxt;
+
+ for (curCtxt = ctxt; curCtxt; curCtxt = curCtxt->chainChild)
+ {
+ cxid = XDPSXIDFromContext(&dpy, curCtxt);
+ if (dpy == (Display *)NULL || cxid == None)
+ break; /* Skip text contexts */
+ XDPSLReconcileRequests(dpy, cxid);
+ }
+}
+
+Status
+XDPSNXSetAgentArg(
+ Display *dpy,
+ int arg, int val)
+{
+ if (!dpy || arg >= 0 || arg < AGENTLASTARG)
+ return(!Success);
+ else
+ return(XDPSLSetAgentArg(dpy, arg, val));
+}
+
+/* New for DPS NX 2.0 */
+void
+XDPSFlushGC(
+ Display *dpy,
+ GC gc)
+{
+ if (dpy && gc)
+ XDPSLFlushGC(dpy, gc);
+}
+
+/* === SUPPORT PROCS === */
+
+void
+DPSCAPChangeGC(
+ register Display *agent,
+ GC gc,
+ unsigned long valuemask,
+ XGCValues *values)
+{
+ register xChangeGCReq *req;
+ unsigned long oldDirty = gc->dirty;
+
+ /* ASSERT: called from within LockDisplay section */
+
+ /* Always include the clip_mask */
+ valuemask |= GCClipMask;
+ /* +++ HACK! Hide the gc->rects flag in arc_mode */
+ valuemask |= GCArcMode;
+ valuemask &= (1L << (GCLastBit + 1)) - 1;
+
+ /* Stupid macro insists on Display being called 'dpy' */
+ {
+ Display *dpy = agent;
+ Display *xdpy = (Display *)NULL;
+ NXMacroGetReq(ChangeGC, req);
+ }
+ req->gc = XGContextFromGC(gc);
+ gc->dirty = req->mask = valuemask;
+ {
+/* Derived from MIT XCrGC.c, _XGenerateGCList:
+Copyright 1985, 1986, 1987, 1988, 1989 by the
+Massachusetts Institute of Technology
+
+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 of M.I.T. not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+written prior permission. M.I.T. makes no representations about the
+suitability of this software for any purpose. It is provided "as is"
+without express or implied warranty.
+*/
+ /* Warning! This code assumes that "unsigned int" is 32-bits wide */
+
+ unsigned int vals[32];
+ register unsigned int *value = vals;
+ long nvalues;
+ register XGCValues *gv = 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;
+ /* +++ HACK! Hide gc->rects flag in GCArcMode */
+ if (dirty & GCArcMode) *value++ = gc->rects;
+
+ req->length += (nvalues = value - vals);
+
+ /*
+ * note: Data is a macro that uses its arguments multiple
+ * times, so "nvalues" is changed in a separate assignment
+ * statement
+ */
+
+ nvalues <<= 2;
+ Data32 (agent, (long *) vals, nvalues);
+ }
+
+ gc->dirty = oldDirty;
+
+ /* ASSERT: SyncHandle called by caller */
+}
+
+
+DPSCAPData
+DPSCAPCreate(
+ Display *dpy, Display *agent)
+{
+ register DPSCAPData my = (DPSCAPData)Xcalloc(1, sizeof(DPSCAPDataRec));
+
+ if (my == (DPSCAPData)NULL) return(NULL);
+ my->dpy = dpy;
+ my->agent = agent;
+ my->typePSOutput = XInternAtom(
+ dpy,
+ DPSCAP_TYPE_PSOUTPUT,
+ False);
+ my->typePSOutputWithLen = XInternAtom(
+ dpy,
+ DPSCAP_TYPE_PSOUTPUT_LEN,
+ False);
+ my->typePSStatus = XInternAtom(
+ dpy,
+ DPSCAP_TYPE_PSSTATUS,
+ False);
+ my->typeNoop = XInternAtom(
+ dpy,
+ DPSCAP_TYPE_NOOP,
+ False);
+ my->typeSync = XInternAtom(
+ dpy,
+ DPSCAP_TYPE_SYNC,
+ False);
+ my->typeXError = XInternAtom(
+ dpy,
+ DPSCAP_TYPE_XERROR,
+ False);
+ my->typePSReady = XInternAtom(
+ dpy,
+ DPSCAP_TYPE_PSREADY,
+ False);
+ my->typeResume = XInternAtom(
+ dpy,
+ DPSCAP_TYPE_RESUME,
+ False);
+ return(my);
+}
+
+int
+DPSCAPDestroy(
+ XExtData *extData)
+{
+ register DPSCAPData my = (DPSCAPData) extData->private_data;
+ register DPSCAPData n;
+
+ if (my == (DPSCAPData)NULL) return(0);
+ DPSCAPCloseAgent(my->agent);
+ my->agent = NULL;
+ /* my->extData->private_data = NIL; ???? +++ */
+ if (my == gCSDPS->head)
+ gCSDPS->head = my->next;
+ else for (n = gCSDPS->head; n != NULL; n = n->next)
+ if (n->next == my)
+ {
+ n->next = my->next;
+ break;
+ }
+ Xfree(my);
+ /* extData freed by caller (e.g., _XFreeExtData) */
+ return(0);
+}
+
+void
+DPSCAPStartUp(void)
+{
+ gCSDPS = (DPSCAPGlobals)Xcalloc(1, sizeof(DPSCAPGlobalsRec));
+}
+
+
+static unsigned char padAdd[] = {0, 3, 2, 1};
+
+void
+DPSCAPWrite(
+ Display *agent,
+ char *buf,
+ unsigned len,
+ DPSCAPIOFlags writePad,
+ DPSCAPIOFlags bufMode)
+{
+ int pad = padAdd[len & 3];
+ unsigned fullLen = (writePad == dpscap_pad) ? len + pad : len;
+
+ if (agent->bufptr + fullLen > agent->bufmax)
+ N_XFlush(agent);
+ if (agent->max_request_size && fullLen > agent->max_request_size)
+ {
+ DPSWarnProc(NULL, "DPS Client Library: request length exceeds max request size. Truncated.\n");
+ len = agent->max_request_size;
+ pad = 0;
+ }
+ if (bufMode == dpscap_insert)
+ {
+ agent->last_req = agent->bufptr;
+ agent->request++;
+ }
+ bcopy(buf, agent->bufptr, len);
+ agent->bufptr += len;
+ if (writePad == dpscap_pad && pad)
+ {
+ bcopy((char *) padAdd, agent->bufptr, pad);
+ agent->bufptr += pad;
+ }
+}
+
+
+/* === EXT CALLBACK HOOKS === */
+
+int
+DPSCAPCloseDisplayProc(
+ Display *dpy,
+ XExtCodes *codes)
+{
+#ifdef CSDPS
+ fprintf(stderr, "NX: Closing agent \"%s\"\n", dpy->display_name);
+#endif
+
+ /* Although it seems that we should free codes here, we can't
+ because Xlib owns the storage */
+
+ XDPSLSetShunt(dpy, (Display *) NULL);
+ XDPSLSetCodes(dpy, (XExtCodes *) NULL);
+ XDPSLSetSyncMask(dpy, DPSCAP_SYNCMASK_NONE);
+ XDPSLCleanAll(dpy);
+ XDPSPrivZapDpy(dpy);
+ return(0);
+}
+
+
+int
+DPSCAPCopyGCProc(
+ Display *dpy,
+ GC gc,
+ XExtCodes *codes)
+{
+ XGCValues values;
+ DPSCAPData my;
+ XExtData *extData = XFindOnExtensionList(
+ CSDPSHeadOfDpyExt(dpy),
+ codes->extension);
+
+ if (extData)
+ my = (DPSCAPData) extData->private_data;
+ else
+ return(0);
+
+ /* We change the GC unconditionally, since friggin' XCopyGC
+ clears the dirty bits of the values that are copied! */
+
+ DPSAssertWarn(XGetGCValues(dpy, gc, DPSGCBITS & ~(GCClipMask), &values),
+ NULL, "DPS NX: XGetGCValues returned False\n");
+ values.clip_mask = gc->values.clip_mask;
+ DPSCAPChangeGC(my->agent, gc, DPSGCBITS, &values);
+ /* We have to make sure that the agent completely processes
+ the change to the GC. If we allow the agent to update the
+ GC in its own sweet time, the stupid client may delete the
+ GC after the agent has already queued a request to, e.g.,
+ copy the GC, but before the request is flushed. */
+ XDPSLSync(dpy);
+ return(1);
+}
+
+int
+DPSCAPFreeGCProc(
+ Display *pdpy,
+ GC gc,
+ XExtCodes *codes)
+{
+ register xCAPNotifyReq *req;
+ DPSCAPData my;
+ Display *dpy = pdpy; /* Stupid macros insists on Display being 'dpy' */
+ XExtData *extData = XFindOnExtensionList(
+ CSDPSHeadOfDpyExt(dpy),
+ codes->extension);
+
+ if (extData)
+ my = (DPSCAPData) extData->private_data;
+ else
+ return(0);
+
+ /* Notify the agent that the client deleted a GC. Let the
+ agent figure out if it cares. */
+
+ /* ASSERT: called from within LockDisplay section */
+
+ dpy = my->agent;
+ if (dpy == (Display *)NULL || dpy == pdpy)
+ return(0);
+
+ /* May need to sync changes to GC */
+ if (gNXSyncGCMode == DPSNXSYNCGCMODE_DELAYED)
+ XDPSLSync(pdpy);
+
+ {
+ Display *xdpy = pdpy; /* pdpy is X server */
+ NXMacroGetReq(CAPNotify, req);
+ }
+ req->reqType = DPSCAPOPCODEBASE;
+ req->type = X_CAPNotify;
+ req->cxid = 0;
+ req->notification = DPSCAPNOTE_FREEGC;
+ req->data = XGContextFromGC(gc);
+ req->extra = 0;
+ /* Guarantee that everyone sees GC go away */
+ XSync(pdpy, False); /* pdpy is X server */
+ if (gNXSyncGCMode == DPSNXSYNCGCMODE_FLUSH)
+ {
+ LockDisplay(dpy); /* dpy means agent here */
+ N_XFlush(dpy);
+ UnlockDisplay(dpy);
+ }
+ else
+ XDPSLSync(pdpy);
+
+ /* ASSERT: SynchHandle called by caller */
+ return(1);
+}
+
+#ifdef CSDPSDEBUG
+static unsigned int gcCountFlushedClean = 0;
+static unsigned int gcCountFlushedDirty = 0;
+#endif /* CSDPSDEBUG */
+
+int
+DPSCAPFlushGCProc(
+ Display *dpy,
+ GC gc,
+ XExtCodes *codes)
+{
+ XGCValues values;
+ DPSCAPData my;
+ XExtData *extData;
+#ifdef CSDPSDEBUG
+ unsigned long int dirty;
+#endif /* CSDPSDEBUG */
+
+ /* When GC is created, it is flushed with no dirty bits set,
+ so we have to notice that situation. */
+
+ if (gc->dirty)
+ {
+ if (XDPSLGetGCFlushMode(dpy) == XDPSNX_GC_UPDATES_FAST
+ || !(gc->dirty & DPSGCBITS))
+ return(0);
+ }
+ extData = XFindOnExtensionList(CSDPSHeadOfDpyExt(dpy), codes->extension);
+ if (extData)
+ my = (DPSCAPData) extData->private_data;
+ else
+ return(0);
+ /* HERE IF (gc->dirty & DPSGCBITS || !gc->dirty) */
+#ifdef CSDPSDEBUG
+ dirty = gc->dirty;
+#endif /* CSDPSDEBUG */
+ DPSAssertWarn(XGetGCValues(dpy, gc, DPSGCBITS & ~(GCClipMask), &values),
+ NULL, "NX: XGetGCValues returned False\n");
+ values.clip_mask = gc->values.clip_mask;
+ /* Must guarantee that gc change is registered by X server
+ before notification is sent to agent. */
+ XSync(dpy, False);
+ DPSCAPChangeGC(my->agent, gc, DPSGCBITS, &values);
+ /* We have to make sure that the agent completely processes
+ the change to the GC. If we allow the agent to update the
+ GC in its own sweet time, the stupid client may delete the
+ GC after the agent has already queued a request to, e.g.,
+ copy the GC, but before the request is flushed. */
+ if (gNXSyncGCMode == DPSNXSYNCGCMODE_SYNC)
+ XDPSLSync(dpy);
+ else
+ XDPSLFlush(dpy);
+#ifdef CSDPSDEBUG
+ if (dirty)
+ ++gcCountFlushedDirty;
+ else
+ ++gcCountFlushedClean;
+#endif /* CSDPSDEBUG */
+ return(1);
+}
diff --git a/nx-X11/lib/dps/cslibint.c b/nx-X11/lib/dps/cslibint.c
new file mode 100644
index 000000000..84d7b753e
--- /dev/null
+++ b/nx-X11/lib/dps/cslibint.c
@@ -0,0 +1,1910 @@
+/*
+ * cslibint.c -- low level I/O
+ *
+ * (c) Copyright 1993-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Portions Copyright 1985, 1986, 1987 Massachusetts Institute of Technology
+ *
+ * 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 of M.I.T. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. M.I.T. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * Author: Adobe Systems Incorporated and MIT X Consortium
+ */
+/* $XFree86: xc/lib/dps/cslibint.c,v 1.4tsi Exp $ */
+
+/*
+ * XlibInternal.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 <X11/Xlibint.h>
+#include <X11/Xos.h>
+#include "Xlibnet.h"
+#include <stdio.h>
+
+#include "dpsassert.h"
+#include "cslibint.h"
+
+static void _EatData32 (Display *dpy, unsigned long n);
+
+/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ */
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define ETEST(err) (err == EAGAIN)
+#else
+#define ETEST(err) (err == EWOULDBLOCK)
+#endif
+#endif
+
+#ifdef LACHMAN
+#ifdef EMSGSIZE
+#undef EMSGSIZE
+#endif
+#define EMSGSIZE ERANGE
+#endif
+
+#if defined(SVR4) && defined(sun)
+#define SUNSYSV 1
+#endif
+
+/*
+ * The following routines are internal routines used by Xlib for protocol
+ * packet transmission and reception.
+ *
+ * XIOError(Display *) will be called if any sort of system call error occurs.
+ * This is assumed to be a fatal condition, i.e., XIOError should not return.
+ *
+ * XError(Display *, XErrorEvent *) will be called whenever an X_Error event is
+ * received. This is not assumed to be a fatal condition, i.e., it is
+ * acceptable for this procedure to return. However, XError should NOT
+ * perform any operations (directly or indirectly) on the DISPLAY.
+ *
+ * Routines declared with a return type of 'Status' return 0 on failure,
+ * and non 0 on success. Routines with no declared return type don't
+ * return anything. Whenever possible routines that create objects return
+ * the object they have created.
+ */
+
+extern _XQEvent *_qfree;
+
+static int padlength[4] = {0, 3, 2, 1};
+ /* lookup table for adding padding bytes to data that is read from
+ or written to the X socket. */
+
+static xReq _dummy_request = {
+ 0, 0, 0
+};
+/*
+ * N_XFlush - Flush the X request buffer. If the buffer is empty, no
+ * action is taken. This routine correctly handles incremental writes.
+ * This routine may have to be reworked if int < long.
+ */
+void N_XFlush (Display *dpy)
+{
+ register long size, todo;
+ register int write_stat;
+ register char *bufindex;
+
+ if (!dpy) return;
+
+ if (dpy->flags & XlibDisplayIOError) return;
+
+ size = todo = dpy->bufptr - dpy->buffer;
+ bufindex = dpy->bufptr = dpy->buffer;
+ /*
+ * While write has not written the entire buffer, keep looping
+ * until the entire buffer is written. bufindex will be incremented
+ * and size decremented as buffer is written out.
+ */
+ while (size) {
+ errno = 0;
+ write_stat = WriteToServer(dpy->fd, bufindex, (int) todo);
+ if (write_stat >= 0) {
+ size -= write_stat;
+ todo = size;
+ bufindex += write_stat;
+ } else if (ETEST(errno)) {
+ N_XWaitForWritable(dpy);
+#ifdef SUNSYSV
+ } else if (errno == 0) {
+ N_XWaitForWritable(dpy);
+#endif
+#ifdef EMSGSIZE
+ } else if (errno == EMSGSIZE) {
+ if (todo > 1)
+ todo >>= 1;
+ else
+ N_XWaitForWritable(dpy);
+#endif
+ } else if (errno != EINTR) {
+ /* Write failed! */
+ /* errno set by write system call. */
+ _XIOError(dpy);
+ }
+ }
+ dpy->last_req = (char *)&_dummy_request;
+}
+
+#ifdef NEEDFORNX
+
+int
+_XEventsQueued (Display *dpy, int mode)
+{
+ register int len;
+ int pend;
+ char buf[BUFSIZE];
+ register xReply *rep;
+
+ if (mode == QueuedAfterFlush)
+ {
+ _XFlush(dpy);
+ if (dpy->qlen)
+ return(dpy->qlen);
+ }
+ if (dpy->flags & XlibDisplayIOError) return(dpy->qlen);
+ if (BytesReadable(dpy->fd, (char *) &pend) < 0)
+ _XIOError(dpy);
+#ifdef XCONN_CHECK_FREQ
+ /* This is a crock, required because FIONREAD or equivalent is
+ * not guaranteed to detect a broken connection.
+ */
+ if (!pend && !dpy->qlen && ++dpy->conn_checker >= XCONN_CHECK_FREQ)
+ {
+ unsigned long r_mask[MSKCNT];
+ static struct timeval zero_time;
+
+ dpy->conn_checker = 0;
+ CLEARBITS(r_mask);
+ BITSET(r_mask, dpy->fd);
+ if (pend = select(dpy->fd + 1, (int *)r_mask, NULL, NULL,
+ &zero_time))
+ {
+ if (pend > 0)
+ {
+ if (BytesReadable(dpy->fd, (char *) &pend) < 0)
+ _XIOError(dpy);
+ /* we should not get zero, if we do, force a read */
+ if (!pend)
+ pend = SIZEOF(xReply);
+ }
+ else if (pend < 0 && errno != EINTR)
+ _XIOError(dpy);
+ }
+ }
+#endif /* XCONN_CHECK_FREQ */
+ if (!(len = pend))
+ return(dpy->qlen); /* _XFlush can enqueue events */
+ /* Force a read if there is not enough data. Otherwise,
+ * a select() loop at a higher-level will spin undesirably,
+ * and we've seen at least one OS that appears to not update
+ * the result from FIONREAD once it has returned nonzero.
+ */
+ if (len < SIZEOF(xReply))
+ len = SIZEOF(xReply);
+ else if (len > BUFSIZE)
+ len = BUFSIZE;
+ len /= SIZEOF(xReply);
+ pend = len * SIZEOF(xReply);
+#ifdef XCONN_CHECK_FREQ
+ dpy->conn_checker = 0;
+#endif
+ _XRead (dpy, buf, (long) pend);
+
+ /* no space between comma and type or else macro will die */
+ STARTITERATE (rep,xReply, buf, (len > 0), len--) {
+ if (rep->generic.type == X_Error)
+ _XError(dpy, (xError *)rep);
+ else /* must be an event packet */
+ _XEnq(dpy, (xEvent *) rep);
+ }
+ ENDITERATE
+ return(dpy->qlen);
+}
+
+/* _XReadEvents - Flush the output queue,
+ * then read as many events as possible (but at least 1) and enqueue them
+ */
+void _XReadEvents(Display *dpy)
+{
+ char buf[BUFSIZE];
+ long pend_not_register; /* because can't "&" a register variable */
+ register long pend;
+ register xEvent *ev;
+ Bool not_yet_flushed = True;
+
+ do {
+ /* find out how much data can be read */
+ if (BytesReadable(dpy->fd, (char *) &pend_not_register) < 0)
+ _XIOError(dpy);
+ pend = pend_not_register;
+
+ /* must read at least one xEvent; if none is pending, then
+ we'll just flush and block waiting for it */
+ if (pend < SIZEOF(xEvent)) {
+ pend = SIZEOF(xEvent);
+ /* don't flush until we block the first time */
+ if (not_yet_flushed) {
+ int qlen = dpy->qlen;
+ _XFlush (dpy);
+ if (qlen != dpy->qlen) return;
+ not_yet_flushed = False;
+ }
+ }
+
+ /* but we won't read more than the max buffer size */
+ if (pend > BUFSIZE)
+ pend = BUFSIZE;
+
+ /* round down to an integral number of XReps */
+ pend = (pend / SIZEOF(xEvent)) * SIZEOF(xEvent);
+
+ _XRead (dpy, buf, pend);
+
+ /* no space between comma and type or else macro will die */
+ STARTITERATE (ev,xEvent, buf, (pend > 0),
+ pend -= SIZEOF(xEvent)) {
+ if (ev->u.u.type == X_Error)
+ _XError (dpy, (xError *) ev);
+ else /* it's an event packet; enqueue it */
+ _XEnq (dpy, ev);
+ }
+ ENDITERATE
+ } while (dpy->head == NULL);
+}
+
+#endif /* NEEDFORNX */
+
+/*
+ * N_XRead - Read bytes from the socket taking into account incomplete
+ * reads. This routine may have to be reworked if int < long.
+ */
+int N_XRead (Display *dpy, char *data, long size)
+{
+ register long bytes_read;
+
+ if (!dpy) return 0;
+ if ((dpy->flags & XlibDisplayIOError) || size == 0) return 0;
+ errno = 0;
+ while ((bytes_read = ReadFromServer(dpy->fd, data, (int)size))
+ != size) {
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ data += bytes_read;
+ }
+ else if (ETEST(errno)) {
+ N_XWaitForReadable(dpy);
+ errno = 0;
+ }
+#ifdef SUNSYSV
+ else if (errno == 0) {
+ N_XWaitForReadable(dpy);
+ }
+#endif
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ errno = EPIPE;
+ _XIOError(dpy);
+ }
+
+ else /* bytes_read is less than 0; presumably -1 */ {
+ /* If it's a system call interrupt, it's not an error. */
+ if (errno != EINTR)
+ _XIOError(dpy);
+ }
+ }
+ return 0;
+}
+
+#ifdef WORD64
+
+/*
+ * XXX This is a *really* stupid way of doing this....
+ * PACKBUFFERSIZE must be a multiple of 4.
+ */
+
+#define PACKBUFFERSIZE 4096
+
+
+/*
+ * _XRead32 - Read bytes from the socket unpacking each 32 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static void _doXRead32 (Display *dpy, long *data, long size, char *packbuffer)
+{
+ long *lpack,*lp;
+ long mask32 = 0x00000000ffffffff;
+ long maskw, nwords, i, bits;
+
+ _XReadPad (dpy, packbuffer, size);
+
+ lp = data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 2;
+ bits = 32;
+
+ for(i=0;i<nwords;i++){
+ maskw = mask32 << bits;
+ *lp++ = ( *lpack & maskw ) >> bits;
+ bits = bits ^32;
+ if(bits){
+ lpack++;
+ }
+ }
+}
+
+void _XRead32 (Display *dpy, long *data, long len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 2;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ _doXRead32 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) _doXRead32 (dpy, data, len, packbuffer);
+}
+
+
+
+/*
+ * _XRead16 - Read bytes from the socket unpacking each 16 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static void _doXRead16 (Display *dpy, short *data, long size, char *packbuffer)
+{
+ long *lpack,*lp;
+ long mask16 = 0x000000000000ffff;
+ long maskw, nwords, i, bits;
+
+ _XRead(dpy,packbuffer,size); /* don't do a padded read... */
+
+ lp = (long *) data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 1; /* number of 16 bit words to be unpacked */
+ bits = 48;
+ for(i=0;i<nwords;i++){
+ maskw = mask16 << bits;
+ *lp++ = ( *lpack & maskw ) >> bits;
+ bits -= 16;
+ if(bits < 0){
+ lpack++;
+ bits = 48;
+ }
+ }
+}
+
+void _XRead16 (Display *dpy, short *data, long len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 1;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ _doXRead16 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) _doXRead16 (dpy, data, len, packbuffer);
+}
+
+void _XRead16Pad (Display *dpy, short *data, long size)
+{
+ int slop = (size & 3);
+ short slopbuf[3];
+
+ _XRead16 (dpy, data, size);
+ if (slop > 0) {
+ _XRead16 (dpy, slopbuf, 4 - slop);
+ }
+}
+#endif /* WORD64 */
+
+
+/*
+ * N_XReadPad - Read bytes from the socket taking into account incomplete
+ * reads. If the number of bytes is not 0 mod 32, read additional pad
+ * bytes. This routine may have to be reworked if int < long.
+ */
+void N_XReadPad (Display *dpy, char *data, long size)
+{
+ register long bytes_read;
+ struct iovec iov[2];
+ char pad[3];
+
+ if (!dpy) return;
+ if ((dpy->flags & XlibDisplayIOError) || size == 0) return;
+ iov[0].iov_len = (int)size;
+ iov[0].iov_base = data;
+ /*
+ * The following hack is used to provide 32 bit long-word
+ * aligned padding. The [1] vector is of length 0, 1, 2, or 3,
+ * whatever is needed.
+ */
+
+ iov[1].iov_len = padlength[size & 3];
+ iov[1].iov_base = pad;
+ size += iov[1].iov_len;
+ errno = 0;
+ while ((bytes_read = ReadvFromServer (dpy->fd, iov, 2)) != size) {
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ if (iov[0].iov_len < bytes_read) {
+ iov[1].iov_len += iov[0].iov_len - bytes_read;
+ iov[1].iov_base =
+ (char *)iov[1].iov_base + bytes_read - iov[0].iov_len;
+ iov[0].iov_len = 0;
+ }
+ else {
+ iov[0].iov_len -= bytes_read;
+ iov[0].iov_base = (char *)iov[0].iov_base + bytes_read;
+ }
+ }
+ else if (ETEST(errno)) {
+ N_XWaitForReadable(dpy);
+ errno = 0;
+ }
+#ifdef SUNSYSV
+ else if (errno == 0) {
+ N_XWaitForReadable(dpy);
+ }
+#endif
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ errno = EPIPE;
+ _XIOError(dpy);
+ }
+
+ else /* bytes_read is less than 0; presumably -1 */ {
+ /* If it's a system call interrupt, it's not an error. */
+ if (errno != EINTR)
+ _XIOError(dpy);
+ }
+ }
+}
+
+/*
+ * N_XSend - Flush the buffer and send the client data. 32 bit word aligned
+ * transmission is used, if size is not 0 mod 4, extra bytes are transmitted.
+ * This routine may have to be reworked if int < long;
+ */
+void N_XSend (Display *dpy, _Xconst char *data, long size)
+{
+ struct iovec iov[3];
+ static char pad[3] = {0, 0, 0};
+ /* XText8 and XText16 require that the padding bytes be zero! */
+
+ long skip = 0;
+ long dpybufsize = (dpy->bufptr - dpy->buffer);
+ long padsize = padlength[size & 3];
+ long total = dpybufsize + size + padsize;
+ long todo = total;
+
+ if (dpy->flags & XlibDisplayIOError) return;
+
+ /*
+ * There are 3 pieces that may need to be written out:
+ *
+ * o whatever is in the display buffer
+ * o the data passed in by the user
+ * o any padding needed to 32bit align the whole mess
+ *
+ * This loop looks at all 3 pieces each time through. It uses skip
+ * to figure out whether or not a given piece is needed.
+ */
+ while (total) {
+ long before = skip; /* amount of whole thing written */
+ long remain = todo; /* amount to try this time, <= total */
+ int i = 0;
+ long len;
+
+ /* You could be very general here and have "in" and "out" iovecs
+ * and write a loop without using a macro, but what the heck. This
+ * translates to:
+ *
+ * how much of this piece is new?
+ * if more new then we are trying this time, clamp
+ * if nothing new
+ * then bump down amount already written, for next piece
+ * else put new stuff in iovec, will need all of next piece
+ *
+ * Note that todo had better be at least 1 or else we'll end up
+ * writing 0 iovecs.
+ */
+#define InsertIOV(pointer, length) \
+ len = (length) - before; \
+ if (len > remain) \
+ len = remain; \
+ if (len <= 0) { \
+ before = (-len); \
+ } else { \
+ iov[i].iov_len = len; \
+ iov[i].iov_base = (pointer) + before; \
+ i++; \
+ remain -= len; \
+ before = 0; \
+ }
+
+ InsertIOV (dpy->buffer, dpybufsize)
+ InsertIOV ((char *)data, size)
+ InsertIOV (pad, padsize)
+
+ errno = 0;
+ if ((len = WritevToServer(dpy->fd, iov, i)) >= 0) {
+ skip += len;
+ total -= len;
+ todo = total;
+ } else if (ETEST(errno)) {
+ N_XWaitForWritable(dpy);
+#ifdef SUNSYSV
+ } else if (errno == 0) {
+ N_XWaitForWritable(dpy);
+#endif
+#ifdef EMSGSIZE
+ } else if (errno == EMSGSIZE) {
+ if (todo > 1)
+ todo >>= 1;
+ else
+ N_XWaitForWritable(dpy);
+#endif
+ } else if (errno != EINTR) {
+ _XIOError(dpy);
+ }
+ }
+
+ dpy->bufptr = dpy->buffer;
+ dpy->last_req = (char *) & _dummy_request;
+ return;
+}
+
+#ifdef NEEDFORNX
+/*
+ * _XAllocID - normal resource ID allocation routine. A client
+ * can roll his own and instatantiate it if he wants, but must
+ * follow the rules.
+ */
+XID _XAllocID(Display *dpy)
+{
+ XID id;
+
+ id = dpy->resource_id << dpy->resource_shift;
+ if (id <= dpy->resource_mask) {
+ dpy->resource_id++;
+ return (dpy->resource_base + id);
+ }
+ if (id != 0x10000000) {
+ (void) fprintf(stderr,
+ "Xlib: resource ID allocation space exhausted!\n");
+ id = 0x10000000;
+ dpy->resource_id = id >> dpy->resource_shift;
+ }
+ return id;
+}
+
+/*
+ * The hard part about this is that we only get 16 bits from a reply. Well,
+ * then, we have three values that will march along, with the following
+ * invariant:
+ * dpy->last_request_read <= rep->sequenceNumber <= dpy->request
+ * The right choice for rep->sequenceNumber is the largest that
+ * still meets these constraints.
+ */
+
+unsigned long
+_XSetLastRequestRead(Display *dpy, xGenericReply *rep)
+{
+ register unsigned long newseq, lastseq;
+
+ /*
+ * KeymapNotify has no sequence number, but is always guaranteed
+ * to immediately follow another event, except when generated via
+ * SendEvent (hmmm).
+ */
+ if ((rep->type & 0x7f) == KeymapNotify)
+ return(dpy->last_request_read);
+
+ newseq = (dpy->last_request_read & ~((unsigned long)0xffff)) |
+ rep->sequenceNumber;
+ lastseq = dpy->last_request_read;
+ while (newseq < lastseq) {
+ newseq += 0x10000;
+ if (newseq > dpy->request) {
+ (void) fprintf (stderr,
+ "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
+ newseq, dpy->request,
+ (unsigned int) rep->type);
+ newseq -= 0x10000;
+ break;
+ }
+ }
+
+ dpy->last_request_read = newseq;
+ return(newseq);
+}
+
+#endif /* NEEDFORNX */
+
+/*
+ * N_XReply - Wait for a reply packet and copy its contents into the
+ * specified rep. Mean while we must handle error and event packets that
+ * we may encounter.
+ */
+Status N_XReply (
+ Display *dpy,
+ xReply *rep,
+ int extra, /* number of 32-bit words expected after the reply */
+ Bool discard) /* should I discard data following "extra" words? */
+{
+ /* Pull out the serial number now, so that (currently illegal) requests
+ * generated by an error handler don't confuse us.
+ */
+ unsigned long cur_request = dpy->request;
+
+ if (dpy->flags & XlibDisplayIOError) return (0);
+
+ N_XFlush(dpy);
+ while (1) {
+ N_XRead(dpy, (char *)rep, (long)SIZEOF(xReply));
+ switch ((int)rep->generic.type) {
+
+ case X_Reply:
+ /* Reply received. Fast update for synchronous replies,
+ * but deal with multiple outstanding replies.
+ */
+ if (rep->generic.sequenceNumber == (cur_request & 0xffff))
+ dpy->last_request_read = cur_request;
+ else
+ (void) _XSetLastRequestRead(dpy, &rep->generic);
+ if (extra == 0) {
+ if (discard && (rep->generic.length > 0))
+ /* unexpectedly long reply! */
+ _EatData32 (dpy, rep->generic.length);
+ return (1);
+ }
+ if ((unsigned) extra == rep->generic.length) {
+ /*
+ * Read the extra data into storage immediately following
+ * the GenericReply structure.
+ */
+ N_XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
+ ((long)extra) << 2);
+ return (1);
+ }
+ if ((unsigned) extra < rep->generic.length) {
+ /* Actual reply is longer than "extra" */
+ N_XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
+ ((long)extra) << 2);
+ if (discard)
+ _EatData32 (dpy, rep->generic.length - extra);
+ return (1);
+ }
+ /*
+ *if we get here, then extra > rep->generic.length--meaning we
+ * read a reply that's shorter than we expected. This is an
+ * error, but we still need to figure out how to handle it...
+ */
+ N_XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
+ ((long) rep->generic.length) << 2);
+ _XIOError (dpy);
+ return (0);
+
+ case X_Error:
+ {
+ register _XExtension *ext;
+ register Bool ret = False;
+ int ret_code;
+ xError *err = (xError *) rep;
+ unsigned long serial;
+
+ serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
+ /*
+ * we better see if there is an extension who may
+ * want to suppress the error.
+ */
+ for (ext = dpy->ext_procs; !ret && ext; ext = ext->next) {
+ if (ext->error)
+ ret = (*ext->error)(dpy, err, &ext->codes, &ret_code);
+ }
+ if (!ret) {
+ _XError(dpy, err);
+ ret_code = 0;
+ }
+ if (serial == cur_request)
+ return(ret_code);
+ }
+ break;
+ default:
+ /* There should never be any events on this connection! */
+ DPSFatalProc(NULL, "N_XReply read bogus X event");
+ break;
+ }
+ }
+}
+
+
+/* Read and discard "n" 8-bit bytes of data */
+
+static void
+N_XEatData (Display *dpy, unsigned long n)
+{
+#define SCRATCHSIZE 2048
+ char buf[SCRATCHSIZE];
+
+ while (n > 0) {
+ register long bytes_read = (n > SCRATCHSIZE) ? SCRATCHSIZE : n;
+ N_XRead (dpy, buf, bytes_read);
+ n -= bytes_read;
+ }
+#undef SCRATCHSIZE
+}
+
+
+/* Read and discard "n" 32-bit words. */
+
+static void _EatData32 (Display *dpy, unsigned long n)
+{
+ N_XEatData (dpy, n << 2);
+}
+
+
+#ifdef NEEDFORNX
+/*
+ * _XEnq - Place event packets on the display's queue.
+ * note that no squishing of move events in V11, since there
+ * is pointer motion hints....
+ */
+void _XEnq (Display *dpy, xEvent *event)
+{
+ register _XQEvent *qelt;
+
+/*NOSTRICT*/
+ if (qelt = _qfree) {
+ /* If _qfree is non-NULL do this, else malloc a new one. */
+ _qfree = qelt->next;
+ }
+ else if ((qelt =
+ (_XQEvent *) Xmalloc((unsigned)sizeof(_XQEvent))) == NULL) {
+ /* Malloc call failed! */
+ errno = ENOMEM;
+ _XIOError(dpy);
+ }
+ qelt->next = NULL;
+ /* go call through display to find proper event reformatter */
+ if ((*dpy->event_vec[event->u.u.type & 0177])(dpy, &qelt->event, event)) {
+ if (dpy->tail) dpy->tail->next = qelt;
+ else dpy->head = qelt;
+
+ dpy->tail = qelt;
+ dpy->qlen++;
+ } else {
+ /* ignored, or stashed away for many-to-one compression */
+ qelt->next = _qfree;
+ _qfree = qelt;
+ }
+}
+/*
+ * EventToWire in separate file in that often not needed.
+ */
+#endif /* NEEDFORNX */
+
+/*ARGSUSED*/
+Bool
+N_XUnknownWireEvent(
+ Display *dpy, /* pointer to display structure */
+ XEvent *re, /* pointer to where event should be reformatted */
+ xEvent *event) /* wire protocol event */
+{
+ char mbuf[256];
+
+ sprintf(mbuf, "NX: unhandled wire event %d, agent = %lx", re->type, (long)dpy);
+ DPSWarnProc(NULL, mbuf);
+ return(False);
+}
+
+/*ARGSUSED*/
+Status
+N_XUnknownNativeEvent(
+ Display *dpy, /* pointer to display structure */
+ XEvent *re, /* pointer to where event should be reformatted */
+ xEvent *event) /* wire protocol event */
+{
+ char mbuf[256];
+
+ sprintf(mbuf, "NX: unhandled native event %d, agent = %lx", re->type, (long)dpy);
+ DPSWarnProc(NULL, mbuf);
+ return(0);
+}
+
+#ifdef NEEDFORNX
+/*
+ * reformat a wire event into an XEvent structure of the right type.
+ */
+Bool
+_XWireToEvent(
+ Display *dpy, /* pointer to display structure */
+ XEvent *re, /* pointer to where event should be reformatted */
+ xEvent *event) /* wire protocol event */
+{
+
+ re->type = event->u.u.type & 0x7f;
+ ((XAnyEvent *)re)->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ ((XAnyEvent *)re)->send_event = ((event->u.u.type & 0x80) != 0);
+ ((XAnyEvent *)re)->display = dpy;
+
+ /* Ignore the leading bit of the event type since it is set when a
+ client sends an event rather than the server. */
+
+ switch (event-> u.u.type & 0177) {
+ case KeyPress:
+ case KeyRelease:
+ {
+ register XKeyEvent *ev = (XKeyEvent*) re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->keycode = event->u.u.detail;
+ }
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ {
+ register XButtonEvent *ev = (XButtonEvent *) re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->button = event->u.u.detail;
+ }
+ break;
+ case MotionNotify:
+ {
+ register XMotionEvent *ev = (XMotionEvent *)re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->is_hint = event->u.u.detail;
+ }
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ {
+ register XCrossingEvent *ev = (XCrossingEvent *) re;
+ ev->root = event->u.enterLeave.root;
+ ev->window = event->u.enterLeave.event;
+ ev->subwindow = event->u.enterLeave.child;
+ ev->time = event->u.enterLeave.time;
+ ev->x = cvtINT16toInt(event->u.enterLeave.eventX);
+ ev->y = cvtINT16toInt(event->u.enterLeave.eventY);
+ ev->x_root = cvtINT16toInt(event->u.enterLeave.rootX);
+ ev->y_root = cvtINT16toInt(event->u.enterLeave.rootY);
+ ev->state = event->u.enterLeave.state;
+ ev->mode = event->u.enterLeave.mode;
+ ev->same_screen = (event->u.enterLeave.flags &
+ ELFlagSameScreen) && True;
+ ev->focus = (event->u.enterLeave.flags &
+ ELFlagFocus) && True;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case FocusIn:
+ case FocusOut:
+ {
+ register XFocusChangeEvent *ev = (XFocusChangeEvent *) re;
+ ev->window = event->u.focus.window;
+ ev->mode = event->u.focus.mode;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case KeymapNotify:
+ {
+ register XKeymapEvent *ev = (XKeymapEvent *) re;
+ ev->window = dpy->current;
+ bcopy ((char *)((xKeymapEvent *) event)->map,
+ &ev->key_vector[1],
+ sizeof (((xKeymapEvent *) event)->map));
+ }
+ break;
+ case Expose:
+ {
+ register XExposeEvent *ev = (XExposeEvent *) re;
+ ev->window = event->u.expose.window;
+ ev->x = event->u.expose.x;
+ ev->y = event->u.expose.y;
+ ev->width = event->u.expose.width;
+ ev->height = event->u.expose.height;
+ ev->count = event->u.expose.count;
+ }
+ break;
+ case GraphicsExpose:
+ {
+ register XGraphicsExposeEvent *ev =
+ (XGraphicsExposeEvent *) re;
+ ev->drawable = event->u.graphicsExposure.drawable;
+ ev->x = event->u.graphicsExposure.x;
+ ev->y = event->u.graphicsExposure.y;
+ ev->width = event->u.graphicsExposure.width;
+ ev->height = event->u.graphicsExposure.height;
+ ev->count = event->u.graphicsExposure.count;
+ ev->major_code = event->u.graphicsExposure.majorEvent;
+ ev->minor_code = event->u.graphicsExposure.minorEvent;
+ }
+ break;
+ case NoExpose:
+ {
+ register XNoExposeEvent *ev = (XNoExposeEvent *) re;
+ ev->drawable = event->u.noExposure.drawable;
+ ev->major_code = event->u.noExposure.majorEvent;
+ ev->minor_code = event->u.noExposure.minorEvent;
+ }
+ break;
+ case VisibilityNotify:
+ {
+ register XVisibilityEvent *ev = (XVisibilityEvent *) re;
+ ev->window = event->u.visibility.window;
+ ev->state = event->u.visibility.state;
+ }
+ break;
+ case CreateNotify:
+ {
+ register XCreateWindowEvent *ev =
+ (XCreateWindowEvent *) re;
+ ev->window = event->u.createNotify.window;
+ ev->parent = event->u.createNotify.parent;
+ ev->x = cvtINT16toInt(event->u.createNotify.x);
+ ev->y = cvtINT16toInt(event->u.createNotify.y);
+ ev->width = event->u.createNotify.width;
+ ev->height = event->u.createNotify.height;
+ ev->border_width = event->u.createNotify.borderWidth;
+ ev->override_redirect = event->u.createNotify.override;
+ }
+ break;
+ case DestroyNotify:
+ {
+ register XDestroyWindowEvent *ev =
+ (XDestroyWindowEvent *) re;
+ ev->window = event->u.destroyNotify.window;
+ ev->event = event->u.destroyNotify.event;
+ }
+ break;
+ case UnmapNotify:
+ {
+ register XUnmapEvent *ev = (XUnmapEvent *) re;
+ ev->window = event->u.unmapNotify.window;
+ ev->event = event->u.unmapNotify.event;
+ ev->from_configure = event->u.unmapNotify.fromConfigure;
+ }
+ break;
+ case MapNotify:
+ {
+ register XMapEvent *ev = (XMapEvent *) re;
+ ev->window = event->u.mapNotify.window;
+ ev->event = event->u.mapNotify.event;
+ ev->override_redirect = event->u.mapNotify.override;
+ }
+ break;
+ case MapRequest:
+ {
+ register XMapRequestEvent *ev = (XMapRequestEvent *) re;
+ ev->window = event->u.mapRequest.window;
+ ev->parent = event->u.mapRequest.parent;
+ }
+ break;
+ case ReparentNotify:
+ {
+ register XReparentEvent *ev = (XReparentEvent *) re;
+ ev->event = event->u.reparent.event;
+ ev->window = event->u.reparent.window;
+ ev->parent = event->u.reparent.parent;
+ ev->x = cvtINT16toInt(event->u.reparent.x);
+ ev->y = cvtINT16toInt(event->u.reparent.y);
+ ev->override_redirect = event->u.reparent.override;
+ }
+ break;
+ case ConfigureNotify:
+ {
+ register XConfigureEvent *ev = (XConfigureEvent *) re;
+ ev->event = event->u.configureNotify.event;
+ ev->window = event->u.configureNotify.window;
+ ev->above = event->u.configureNotify.aboveSibling;
+ ev->x = cvtINT16toInt(event->u.configureNotify.x);
+ ev->y = cvtINT16toInt(event->u.configureNotify.y);
+ ev->width = event->u.configureNotify.width;
+ ev->height = event->u.configureNotify.height;
+ ev->border_width = event->u.configureNotify.borderWidth;
+ ev->override_redirect = event->u.configureNotify.override;
+ }
+ break;
+ case ConfigureRequest:
+ {
+ register XConfigureRequestEvent *ev =
+ (XConfigureRequestEvent *) re;
+ ev->window = event->u.configureRequest.window;
+ ev->parent = event->u.configureRequest.parent;
+ ev->above = event->u.configureRequest.sibling;
+ ev->x = cvtINT16toInt(event->u.configureRequest.x);
+ ev->y = cvtINT16toInt(event->u.configureRequest.y);
+ ev->width = event->u.configureRequest.width;
+ ev->height = event->u.configureRequest.height;
+ ev->border_width = event->u.configureRequest.borderWidth;
+ ev->value_mask = event->u.configureRequest.valueMask;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case GravityNotify:
+ {
+ register XGravityEvent *ev = (XGravityEvent *) re;
+ ev->window = event->u.gravity.window;
+ ev->event = event->u.gravity.event;
+ ev->x = cvtINT16toInt(event->u.gravity.x);
+ ev->y = cvtINT16toInt(event->u.gravity.y);
+ }
+ break;
+ case ResizeRequest:
+ {
+ register XResizeRequestEvent *ev =
+ (XResizeRequestEvent *) re;
+ ev->window = event->u.resizeRequest.window;
+ ev->width = event->u.resizeRequest.width;
+ ev->height = event->u.resizeRequest.height;
+ }
+ break;
+ case CirculateNotify:
+ {
+ register XCirculateEvent *ev = (XCirculateEvent *) re;
+ ev->window = event->u.circulate.window;
+ ev->event = event->u.circulate.event;
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case CirculateRequest:
+ {
+ register XCirculateRequestEvent *ev =
+ (XCirculateRequestEvent *) re;
+ ev->window = event->u.circulate.window;
+ ev->parent = event->u.circulate.event;
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case PropertyNotify:
+ {
+ register XPropertyEvent *ev = (XPropertyEvent *) re;
+ ev->window = event->u.property.window;
+ ev->atom = event->u.property.atom;
+ ev->time = event->u.property.time;
+ ev->state = event->u.property.state;
+ }
+ break;
+ case SelectionClear:
+ {
+ register XSelectionClearEvent *ev =
+ (XSelectionClearEvent *) re;
+ ev->window = event->u.selectionClear.window;
+ ev->selection = event->u.selectionClear.atom;
+ ev->time = event->u.selectionClear.time;
+ }
+ break;
+ case SelectionRequest:
+ {
+ register XSelectionRequestEvent *ev =
+ (XSelectionRequestEvent *) re;
+ ev->owner = event->u.selectionRequest.owner;
+ ev->requestor = event->u.selectionRequest.requestor;
+ ev->selection = event->u.selectionRequest.selection;
+ ev->target = event->u.selectionRequest.target;
+ ev->property = event->u.selectionRequest.property;
+ ev->time = event->u.selectionRequest.time;
+ }
+ break;
+ case SelectionNotify:
+ {
+ register XSelectionEvent *ev = (XSelectionEvent *) re;
+ ev->requestor = event->u.selectionNotify.requestor;
+ ev->selection = event->u.selectionNotify.selection;
+ ev->target = event->u.selectionNotify.target;
+ ev->property = event->u.selectionNotify.property;
+ ev->time = event->u.selectionNotify.time;
+ }
+ break;
+ case ColormapNotify:
+ {
+ register XColormapEvent *ev = (XColormapEvent *) re;
+ ev->window = event->u.colormap.window;
+ ev->colormap = event->u.colormap.colormap;
+ ev->new = event->u.colormap.new;
+ ev->state = event->u.colormap.state;
+ }
+ break;
+ case ClientMessage:
+ {
+ register int i;
+ register XClientMessageEvent *ev
+ = (XClientMessageEvent *) re;
+ ev->window = event->u.clientMessage.window;
+ ev->format = event->u.u.detail;
+ switch (ev->format) {
+ case 8:
+ ev->message_type = event->u.clientMessage.u.b.type;
+ for (i = 0; i < 20; i++)
+ ev->data.b[i] = event->u.clientMessage.u.b.bytes[i];
+ break;
+ case 16:
+ ev->message_type = event->u.clientMessage.u.s.type;
+ ev->data.s[0] = cvtINT16toShort(event->u.clientMessage.u.s.shorts0);
+ ev->data.s[1] = cvtINT16toShort(event->u.clientMessage.u.s.shorts1);
+ ev->data.s[2] = cvtINT16toShort(event->u.clientMessage.u.s.shorts2);
+ ev->data.s[3] = cvtINT16toShort(event->u.clientMessage.u.s.shorts3);
+ ev->data.s[4] = cvtINT16toShort(event->u.clientMessage.u.s.shorts4);
+ ev->data.s[5] = cvtINT16toShort(event->u.clientMessage.u.s.shorts5);
+ ev->data.s[6] = cvtINT16toShort(event->u.clientMessage.u.s.shorts6);
+ ev->data.s[7] = cvtINT16toShort(event->u.clientMessage.u.s.shorts7);
+ ev->data.s[8] = cvtINT16toShort(event->u.clientMessage.u.s.shorts8);
+ ev->data.s[9] = cvtINT16toShort(event->u.clientMessage.u.s.shorts9);
+ break;
+ case 32:
+ ev->message_type = event->u.clientMessage.u.l.type;
+ ev->data.l[0] = cvtINT32toLong(event->u.clientMessage.u.l.longs0);
+ ev->data.l[1] = cvtINT32toLong(event->u.clientMessage.u.l.longs1);
+ ev->data.l[2] = cvtINT32toLong(event->u.clientMessage.u.l.longs2);
+ ev->data.l[3] = cvtINT32toLong(event->u.clientMessage.u.l.longs3);
+ ev->data.l[4] = cvtINT32toLong(event->u.clientMessage.u.l.longs4);
+ break;
+ default: /* XXX should never occur */
+ break;
+ }
+ }
+ break;
+ case MappingNotify:
+ {
+ register XMappingEvent *ev = (XMappingEvent *)re;
+ ev->window = 0;
+ ev->first_keycode = event->u.mappingNotify.firstKeyCode;
+ ev->request = event->u.mappingNotify.request;
+ ev->count = event->u.mappingNotify.count;
+ }
+ break;
+ default:
+ return(_XUnknownWireEvent(dpy, re, event));
+ }
+ return(True);
+}
+
+
+#ifndef USL_SHARELIB
+
+static char *_SysErrorMsg (int n)
+{
+ extern char *sys_errlist[];
+ extern int sys_nerr;
+ char *s = ((n >= 0 && n < sys_nerr) ? sys_errlist[n] : "unknown error");
+
+ return (s ? s : "no such error");
+}
+
+#endif /* USL sharedlibs in don't define for SVR3.2 */
+
+
+/*
+ * _XDefaultIOError - Default fatal system error reporting routine. Called
+ * when an X internal system error is encountered.
+ */
+_XDefaultIOError (Display *dpy)
+{
+ (void) fprintf (stderr,
+ "XIO: fatal IO error %d (%s) on X server \"%s\"\r\n",
+ errno, _SysErrorMsg (errno), DisplayString (dpy));
+ (void) fprintf (stderr,
+ " after %lu requests (%lu known processed) with %d events remaining.\r\n",
+ NextRequest(dpy) - 1, LastKnownRequestProcessed(dpy),
+ QLength(dpy));
+
+ if (errno == EPIPE) {
+ (void) fprintf (stderr,
+ " The connection was probably broken by a server shutdown or KillClient.\r\n");
+ }
+ exit(1);
+}
+
+
+static int _XPrintDefaultError (Display *dpy, XErrorEvent *event, FILE *fp)
+{
+ char buffer[BUFSIZ];
+ char mesg[BUFSIZ];
+ char number[32];
+ char *mtype = "XlibMessage";
+ register _XExtension *ext = (_XExtension *)NULL;
+ _XExtension *bext = (_XExtension *)NULL;
+ XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
+ XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
+ (void) fprintf(fp, "%s: %s\n ", mesg, buffer);
+ XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->request_code);
+ if (event->request_code < 128) {
+ sprintf(number, "%d", event->request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
+ } else {
+ for (ext = dpy->ext_procs;
+ ext && (ext->codes.major_opcode != event->request_code);
+ ext = ext->next)
+ ;
+ if (ext)
+ strcpy(buffer, ext->name);
+ else
+ buffer[0] = '\0';
+ }
+ (void) fprintf(fp, " (%s)\n", buffer);
+ if (event->request_code >= 128) {
+ XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->minor_code);
+ if (ext) {
+ sprintf(mesg, "%s.%d", ext->name, event->minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
+ (void) fprintf(fp, " (%s)", buffer);
+ }
+ fputs("\n", fp);
+ }
+ if (event->error_code >= 128) {
+ /* kludge, try to find the extension that caused it */
+ buffer[0] = '\0';
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_string)
+ (*ext->error_string)(dpy, event->error_code, &ext->codes,
+ buffer, BUFSIZ);
+ if (buffer[0]) {
+ bext = ext;
+ break;
+ }
+ if (ext->codes.first_error &&
+ ext->codes.first_error < event->error_code &&
+ (!bext || ext->codes.first_error > bext->codes.first_error))
+ bext = ext;
+ }
+ if (bext)
+ sprintf(buffer, "%s.%d", bext->name,
+ event->error_code - bext->codes.first_error);
+ else
+ strcpy(buffer, "Value");
+ XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
+ if (mesg[0]) {
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ /* let extensions try to print the values */
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_values)
+ (*ext->error_values)(dpy, event, fp);
+ }
+ } else if ((event->error_code == BadWindow) ||
+ (event->error_code == BadPixmap) ||
+ (event->error_code == BadCursor) ||
+ (event->error_code == BadFont) ||
+ (event->error_code == BadDrawable) ||
+ (event->error_code == BadColor) ||
+ (event->error_code == BadGC) ||
+ (event->error_code == BadIDChoice) ||
+ (event->error_code == BadValue) ||
+ (event->error_code == BadAtom)) {
+ if (event->error_code == BadValue)
+ XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
+ mesg, BUFSIZ);
+ else if (event->error_code == BadAtom)
+ XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
+ mesg, BUFSIZ);
+ else
+ XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->serial);
+ XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
+ mesg, BUFSIZ);
+ fputs("\n ", fp);
+ (void) fprintf(fp, mesg, dpy->request);
+ fputs("\n", fp);
+ if (event->error_code == BadImplementation) return 0;
+ return 1;
+}
+
+int _XDefaultError(Display *dpy, XErrorEvent *event)
+{
+ if (_XPrintDefaultError (dpy, event, stderr) == 0) return 0;
+ exit(1);
+ /*NOTREACHED*/
+}
+
+/*ARGSUSED*/
+Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we)
+{
+ return True;
+}
+
+/*
+ * _XError - prepare to upcall user protocol error handler
+ */
+int _XError (Display *dpy, xError *rep)
+{
+ /*
+ * X_Error packet encountered! We need to unpack the error before
+ * giving it to the user.
+ */
+ XEvent event; /* make it a large event */
+
+ event.xerror.display = dpy;
+ event.xerror.type = X_Error;
+ event.xerror.serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
+ event.xerror.resourceid = rep->resourceID;
+ event.xerror.error_code = rep->errorCode;
+ event.xerror.request_code = rep->majorCode;
+ event.xerror.minor_code = rep->minorCode;
+ if (dpy->error_vec &&
+ !(*dpy->error_vec[rep->errorCode])(dpy, &event.xerror, rep))
+ return 0;
+ if (_XErrorFunction != NULL) {
+ return ((*_XErrorFunction)(dpy, &event)); /* upcall */
+ } else {
+ return _XDefaultError(dpy, &event);
+ }
+}
+
+/*
+ * _XIOError - call user connection error handler and exit
+ */
+int _XIOError (Display *dpy)
+{
+ dpy->flags |= XlibDisplayIOError;
+ if (_XIOErrorFunction != NULL)
+ (*_XIOErrorFunction)(dpy);
+ else
+ _XDefaultIOError(dpy);
+ exit (1);
+}
+
+
+/*
+ * This routine can be used to (cheaply) get some memory within a single
+ * Xlib routine for scratch space. It is reallocated from the same place
+ * each time, unless the library needs a large scratch space.
+ */
+char *_XAllocScratch (Display *dpy, unsigned long nbytes)
+{
+ if (nbytes > dpy->scratch_length) {
+ if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer);
+ if (dpy->scratch_buffer = Xmalloc((unsigned) nbytes))
+ dpy->scratch_length = nbytes;
+ else dpy->scratch_length = 0;
+ }
+ return (dpy->scratch_buffer);
+}
+
+/*
+ * Given a visual id, find the visual structure for this id on this display.
+ */
+Visual *_XVIDtoVisual (Display *dpy, VisualID id)
+{
+ register int i, j, k;
+ register Screen *sp;
+ register Depth *dp;
+ register Visual *vp;
+ for (i = 0; i < dpy->nscreens; i++) {
+ sp = &dpy->screens[i];
+ for (j = 0; j < sp->ndepths; j++) {
+ dp = &sp->depths[j];
+ /* if nvisuals == 0 then visuals will be NULL */
+ for (k = 0; k < dp->nvisuals; k++) {
+ vp = &dp->visuals[k];
+ if (vp->visualid == id) return (vp);
+ }
+ }
+ }
+ return (NULL);
+}
+
+void XFree (void *data)
+{
+ Xfree (data);
+}
+
+#ifdef _XNEEDBCOPYFUNC
+void _Xbcopy(char *b1, char *b2, length)
+{
+ if (b1 < b2) {
+ b2 += length;
+ b1 += length;
+ while (length--)
+ *--b2 = *--b1;
+ } else {
+ while (length--)
+ *b2++ = *b1++;
+ }
+}
+#endif
+
+#endif /* NEEDFORNX */
+
+void NXProcData (Display *dpy, char *data, long len)
+{
+ if (dpy->bufptr + (len) <= dpy->bufmax) {
+ bcopy(data, dpy->bufptr, (int)len);
+ dpy->bufptr += ((len) + 3) & ~3;
+ } else {
+ N_XSend(dpy, data, len);
+ }
+}
+
+
+#ifdef WORD64
+
+/*
+ * XXX This is a *really* stupid way of doing this. It should just use
+ * dpy->bufptr directly, taking into account where in the word it is.
+ */
+
+/*
+ * Data16 - Place 16 bit data in the buffer.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static void
+doData16(Display *dpy, short *data, unsigned len, char *packbuffer)
+{
+ long *lp,*lpack;
+ long i, nwords,bits;
+ long mask16 = 0x000000000000ffff;
+
+ lp = (long *)data;
+ lpack = (long *)packbuffer;
+
+/* nwords is the number of 16 bit values to be packed,
+ * the low order 16 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 1;
+ bits = 48;
+
+ for(i=0;i<nwords;i++){
+ if (bits == 48) *lpack = 0;
+ *lpack ^= (*lp & mask16) << bits;
+ bits -= 16 ;
+ lp++;
+ if(bits < 0){
+ lpack++;
+ bits = 48;
+ }
+ }
+ Data(dpy, packbuffer, len);
+}
+
+void
+Data16 (Display *dpy, short *data, unsigned len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 1;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ doData16 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) doData16 (dpy, data, len, packbuffer);
+}
+
+/*
+ * Data32 - Place 32 bit data in the buffer.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static doData32 (Display *dpy, long *data, unsigned len, char *packbuffer)
+{
+ long *lp,*lpack;
+ long i,bits,nwords;
+ long mask32 = 0x00000000ffffffff;
+
+ lpack = (long *) packbuffer;
+ lp = data;
+
+/* nwords is the number of 32 bit values to be packed
+ * the low order 32 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 2;
+ bits = 32;
+
+ for(i=0;i<nwords;i++){
+ if (bits == 32) *lpack = 0;
+ *lpack ^= (*lp & mask32) << bits;
+ bits = bits ^32;
+ lp++;
+ if(bits)
+ lpack++;
+ }
+ Data(dpy, packbuffer, len);
+}
+
+Data32 (Display *dpy, long *data, unsigned len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 2;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ doData32 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) doData32 (dpy, data, len, packbuffer);
+}
+
+#endif /* WORD64 */
+
+
+#ifdef NEEDFORNX
+
+/*
+ * _XFreeQ - free the queue of events, called by XCloseDisplay
+ */
+
+void _XFreeQ (void)
+{
+ register _XQEvent *qelt = _qfree;
+
+ while (qelt) {
+ register _XQEvent *qnxt = qelt->next;
+ Xfree ((char *) qelt);
+ qelt = qnxt;
+ }
+ _qfree = NULL;
+ return;
+}
+#endif /* NEEDFORNX */
+
+/* Make sure this produces the same string as DefineLocal/DefineSelf in xdm.
+ * Otherwise, Xau will not be able to find your cookies in the Xauthority file.
+ *
+ * Note: POSIX says that the ``nodename'' member of utsname does _not_ have
+ * to have sufficient information for interfacing to the network,
+ * and so, you may be better off using gethostname (if it exists).
+ */
+
+#if (defined(_POSIX_SOURCE) && !defined(AIXV3)) || defined(hpux) || defined(USG) || defined(SVR4)
+#define NEED_UTSNAME
+#include <sys/utsname.h>
+#endif
+
+/*
+ * N_XGetHostname - similar to gethostname but allows special processing.
+ */
+int N_XGetHostname (char *buf, int maxlen)
+{
+ int len;
+
+#ifdef NEED_UTSNAME
+ struct utsname name;
+
+ uname (&name);
+ len = strlen (name.nodename);
+ if (len >= maxlen) len = maxlen - 1;
+ strncpy (buf, name.nodename, len);
+ buf[len] = '\0';
+#else
+ buf[0] = '\0';
+ (void) gethostname (buf, maxlen);
+ buf [maxlen - 1] = '\0';
+ len = strlen(buf);
+#endif /* NEED_UTSNAME */
+ return len;
+}
+
+#ifdef NEEDFORNX
+/*
+ * _XScreenOfWindow - get the Screen of a given window
+ */
+
+Screen *_XScreenOfWindow (Display *dpy, Window w)
+{
+ register int i;
+ Window root;
+ int x, y; /* dummy variables */
+ unsigned int width, height, bw, depth; /* dummy variables */
+
+ if (XGetGeometry (dpy, w, &root, &x, &y, &width, &height,
+ &bw, &depth) == False) {
+ return None;
+ }
+ for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */
+ if (root == RootWindow (dpy, i)) {
+ return ScreenOfDisplay (dpy, i);
+ }
+ }
+ return NULL;
+}
+#endif /* NEEDFORNX */
+
+#if (MSKCNT > 4)
+/*
+ * This is a macro if MSKCNT <= 4
+ */
+int
+N_XANYSET(unsigned long *src)
+{
+ int i;
+
+ for (i=0; i<MSKCNT; i++)
+ if (src[ i ])
+ return (1);
+ return (0);
+}
+#endif
+
+#ifdef NEEDFORNX
+#ifdef CRAY
+/*
+ * Cray UniCOS does not have readv and writev so we emulate
+ */
+#include <sys/socket.h>
+
+int _XReadV (int fd, struct iovec *iov, int iovcnt)
+{
+ struct msghdr hdr;
+
+ hdr.msg_iov = iov;
+ hdr.msg_iovlen = iovcnt;
+ hdr.msg_accrights = 0;
+ hdr.msg_accrightslen = 0;
+ hdr.msg_name = 0;
+ hdr.msg_namelen = 0;
+
+ return (recvmsg (fd, &hdr, 0));
+}
+
+int _XWriteV (int fd, struct iovec *iov, int iovcnt)
+{
+ struct msghdr hdr;
+
+ hdr.msg_iov = iov;
+ hdr.msg_iovlen = iovcnt;
+ hdr.msg_accrights = 0;
+ hdr.msg_accrightslen = 0;
+ hdr.msg_name = 0;
+ hdr.msg_namelen = 0;
+
+ return (sendmsg (fd, &hdr, 0));
+}
+
+#endif /* CRAY */
+
+#if defined(SYSV) && defined(i386) && !defined(STREAMSCONN)
+/*
+ * SYSV/386 does not have readv so we emulate
+ */
+#include <sys/uio.h>
+
+int _XReadV (int fd, struct iovec *iov, int iovcnt)
+{
+ int i, len, total;
+ char *base;
+
+ errno = 0;
+ for (i=0, total=0; i<iovcnt; i++, iov++) {
+ len = iov->iov_len;
+ base = iov->iov_base;
+ while (len > 0) {
+ register int nbytes;
+ nbytes = read(fd, base, len);
+ if (nbytes < 0 && total == 0) return -1;
+ if (nbytes <= 0) return total;
+ errno = 0;
+ len -= nbytes;
+ total += nbytes;
+ base += nbytes;
+ }
+ }
+ return total;
+}
+
+#endif /* SYSV && i386 && !STREAMSCONN */
+
+#ifdef STREAMSCONN
+/*
+ * Copyright 1988, 1989 AT&T, Inc.
+ *
+ * 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 AT&T not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. AT&T makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * AT&T DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL AT&T
+ * 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.
+ *
+ */
+
+/*
+ iovec.c (C source file)
+ Acc: 575557389 Mon Mar 28 08:03:09 1988
+ Mod: 575557397 Mon Mar 28 08:03:17 1988
+ Sta: 575557397 Mon Mar 28 08:03:17 1988
+ Owner: 2011
+ Group: 1985
+ Permissions: 664
+*/
+/*
+ START USER STAMP AREA
+*/
+/*
+ END USER STAMP AREA
+*/
+
+
+extern char _XsTypeofStream[];
+extern Xstream _XsStream[];
+
+#define MAX_WORKAREA 4096
+static char workarea[MAX_WORKAREA];
+
+
+
+int
+_XReadV (int fd, struct iovec v[], int n)
+{
+ int i, rc, len, size = 0;
+ char * buf = workarea;
+ char * p;
+
+ if (n <= 0 || n > 16)
+ {
+ errno = EINVAL;
+ return (-1);
+ }
+ for (i = 0; i < n; ++i)
+ {
+ if ((len = v[i].iov_len) < 0 || v[i].iov_base == NULL)
+ {
+ errno = EINVAL;
+ return (-1);
+ }
+ size += len;
+ }
+ if ((size > MAX_WORKAREA) && ((buf = malloc (size)) == NULL))
+ {
+ errno = EINVAL;
+ return (-1);
+ }
+ if((rc = (*_XsStream[_XsTypeOfStream[fd]].ReadFromStream)(fd, buf, size,
+ BUFFERING))> 0)
+ {
+ for (i = 0, p = buf; i < n; ++i)
+ {
+ memcpy (v[i].iov_base, p, len = v[i].iov_len);
+ p += len;
+ }
+ }
+ if (size > MAX_WORKAREA)
+ free (buf);
+
+ return (rc);
+}
+
+int
+_XWriteV (int fd, struct iovec v[], int n)
+{
+ int i, rc, len, size = 0;
+ char * buf = workarea;
+ char * p;
+
+ if (n <= 0 || n > 16)
+ {
+ errno = EINVAL;
+ return (-1);
+ }
+ for (i = 0; i < n; ++i)
+ {
+ if ((len = v[i].iov_len) < 0 || v[i].iov_base == NULL)
+ {
+ errno = EINVAL;
+ return (-1);
+ }
+ size += len;
+ }
+
+ if ((size > MAX_WORKAREA) && ((buf = malloc (size)) == NULL))
+ {
+ errno = EINVAL;
+ return (-1);
+ }
+ for (i = 0, p = buf; i < n; ++i)
+ {
+ memcpy (p, v[i].iov_base, len = v[i].iov_len);
+ p += len;
+ }
+ rc = (*_XsStream[_XsTypeOfStream[fd]].WriteToStream)(fd, buf, size);
+
+ if (size > MAX_WORKAREA)
+ free (buf);
+
+ return (rc);
+}
+
+
+
+#endif /* STREAMSCONN */
+#endif /* NEEDFORNX */
diff --git a/nx-X11/lib/dps/cslibint.h b/nx-X11/lib/dps/cslibint.h
new file mode 100644
index 000000000..b16770504
--- /dev/null
+++ b/nx-X11/lib/dps/cslibint.h
@@ -0,0 +1,302 @@
+/*
+ * cslibint.h -- low level I/O
+ *
+ * (c) Copyright 1993-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Portions Copyright 1984, 1985, 1987, 1989 Massachusetts Institute of
+ * Technology
+ * 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 of M.I.T. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. M.I.T. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * Author: Adobe Systems Incorporated and MIT X Consortium
+ */
+/* $XFree86: xc/lib/dps/cslibint.h,v 1.3 2001/06/30 22:41:44 tsi Exp $ */
+
+/*
+ * XlibInternal.h - Header definition and support file for the internal
+ * support routines (XlibInternal) used by the C subroutine interface
+ * library (Xlib) to the X Window System.
+ *
+ * Warning, there be dragons here....
+ */
+
+#ifndef _CSLIBINT_H
+#define _CSLIBINT_H
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+
+/* For SYSV, no gethostname, so fake it */
+#include <sys/param.h>
+#if defined(__SCO__)
+/* SCO systems define MAXHOSTNAMELEN here */
+#include <sys/socket.h>
+#endif
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 64
+#endif
+
+
+/* === MACROS === */
+
+/*
+ * GetReq - Get the next avilable X request packet in the buffer and
+ * return it.
+ *
+ * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
+ * "req" is the name of the request pointer.
+ *
+ */
+
+#if !defined(UNIXCPP)
+#define NXMacroGetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
+ {if (dpy != xdpy) N_XFlush(dpy); else _XFlush(dpy);}\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = (SIZEOF(x##name##Req))>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req);\
+ dpy->request++
+
+#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
+#define NXMacroGetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
+ {if (dpy != xdpy) N_XFlush(dpy); else _XFlush(dpy);}\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = (SIZEOF(x/**/name/**/Req))>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req);\
+ dpy->request++
+#endif
+
+#ifdef NEEDFORNX
+
+/* GetReqExtra is the same as GetReq, but allocates "n" additional
+ bytes after the request. "n" must be a multiple of 4! */
+
+#if !defined(UNIXCPP)
+#define GetReqExtra(name, n, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = (SIZEOF(x##name##Req) + n)>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req) + n;\
+ dpy->request++
+#else
+#define GetReqExtra(name, n, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\
+ dpy->request++
+#endif
+
+
+/*
+ * GetResReq is for those requests that have a resource ID
+ * (Window, Pixmap, GContext, etc.) as their single argument.
+ * "rid" is the name of the resource.
+ */
+
+#if !defined(UNIXCPP)
+#define GetResReq(name, rid, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = 2;\
+ req->id = (rid);\
+ dpy->bufptr += SIZEOF(xResourceReq);\
+ dpy->request++
+#else
+#define GetResReq(name, rid, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = 2;\
+ req->id = (rid);\
+ dpy->bufptr += SIZEOF(xResourceReq);\
+ dpy->request++
+#endif
+
+/*
+ * GetEmptyReq is for those requests that have no arguments
+ * at all.
+ */
+#if !defined(UNIXCPP)
+#define GetEmptyReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = 1;\
+ dpy->bufptr += SIZEOF(xReq);\
+ dpy->request++
+#else
+#define GetEmptyReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = 1;\
+ dpy->bufptr += SIZEOF(xReq);\
+ dpy->request++
+#endif
+
+
+#define SyncHandle() \
+ if (dpy->synchandler) (*dpy->synchandler)(dpy)
+
+#define FlushGC(dpy, gc) \
+ if ((gc)->dirty) _XFlushGCCache((dpy), (gc))
+/*
+ * Data - Place data in the buffer and pad the end to provide
+ * 32 bit word alignment. Transmit if the buffer fills.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pinter to a data buffer.
+ * "len" is the length of the data buffer.
+ * we can presume buffer less than 2^16 bytes, so bcopy can be used safely.
+ */
+#ifndef DataRoutineIsProcedure
+#define Data(dpy, data, len) \
+ if (dpy->bufptr + (len) <= dpy->bufmax) {\
+ bcopy(data, dpy->bufptr, (int)len);\
+ dpy->bufptr += ((len) + 3) & ~3;\
+ } else\
+ _XSend(dpy, data, len)
+#endif /* DataRoutineIsProcedure */
+
+
+/* Allocate bytes from the buffer. No padding is done, so if
+ * the length is not a multiple of 4, the caller must be
+ * careful to leave the buffer aligned after sending the
+ * current request.
+ *
+ * "type" is the type of the pointer being assigned to.
+ * "ptr" is the pointer being assigned to.
+ * "n" is the number of bytes to allocate.
+ *
+ * Example:
+ * xTextElt *elt;
+ * BufAlloc (xTextElt *, elt, nbytes)
+ */
+
+#define BufAlloc(type, ptr, n) \
+ if (dpy->bufptr + (n) > dpy->bufmax) \
+ _XFlush (dpy); \
+ ptr = (type) dpy->bufptr; \
+ dpy->bufptr += (n);
+
+/*
+ * provide emulation routines for smaller architectures
+ */
+#ifndef WORD64
+#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
+#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
+#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
+#endif /* not WORD64 */
+
+#define PackData16(dpy,data,len) Data16 (dpy, data, len)
+#define PackData32(dpy,data,len) Data32 (dpy, data, len)
+
+/* Xlib manual is bogus */
+#define PackData(dpy,data,len) PackData16 (dpy, data, len)
+
+
+
+#endif /* NEEDFORNX */
+
+#if !defined(STARTITERATE) && !defined(WORD64)
+
+#define STARTITERATE(tpvar,type,start,endcond,decr) \
+ for (tpvar = (type *) start; endcond; tpvar++, decr) {
+#define ENDITERATE }
+
+#endif /* STARTITERATE */
+
+
+#ifndef WORD64
+#undef Data32
+#define Data32(dpy, data, len) NXProcData((dpy), (char *)(data), (len))
+#endif /* not WORD64 */
+
+extern int gNXSyncGCMode;
+
+/* extension hooks */
+
+extern Bool N_XUnknownWireEvent(Display *, XEvent *, xEvent *);
+extern Status N_XReply(Display *, xReply *, int, Bool);
+extern Status N_XUnknownNativeEvent(Display *, XEvent *, xEvent *);
+extern int DPSCAPConnect( char *, char **, int *, int *, int *, char **);
+extern int N_XDisconnectDisplay(int);
+extern int N_XGetHostname (char *, int);
+extern int N_XRead(Display*, char *, long);
+extern void NXProcData (Display *, char *, long);
+extern void N_XFlush(Display *);
+extern void N_XReadPad(Display*, char *, long);
+extern void N_XSend(Display *, _Xconst char *, long);
+extern void N_XWaitForReadable(Display *);
+extern void N_XWaitForWritable(Display *);
+
+extern void XDPSGetDefaultColorMaps(
+ Display *dpy,
+ Screen *screen,
+ Drawable drawable,
+ XStandardColormap *colorCube,
+ XStandardColormap *grayRamp);
+
+#endif /* _CSLIBINT_H */
+
diff --git a/nx-X11/lib/dps/csopendi.c b/nx-X11/lib/dps/csopendi.c
new file mode 100644
index 000000000..c0eb1d373
--- /dev/null
+++ b/nx-X11/lib/dps/csopendi.c
@@ -0,0 +1,567 @@
+/*
+ * csopendi.c -- open connection to CSDPS agent
+ *
+ * (c) Copyright 1990-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Portions Copyright Massachusetts Institute of Technology 1985, 1986
+ * 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 of M.I.T. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. M.I.T. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * Author: Adobe Systems Incorporated and MIT X Consortium
+ */
+/* $XFree86$ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/param.h> /* for MAXHOSTNAMELEN */
+#define NEED_EVENTS
+#include <X11/Xlibint.h>
+#include <X11/Xos.h>
+#include "cslibint.h"
+#ifdef XXX
+#include <X11/Xauth.h>
+#include <X11/Xatom.h>
+
+extern int _Xdebug;
+extern Display *_XHeadOfDisplayList;
+
+#ifndef lint
+static int lock; /* get rid of ifdefs when locking implemented */
+#endif
+
+#endif /* XXX */
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+
+#include "DPSCAPClient.h"
+#include <DPS/dpsXclient.h>
+#include <DPS/dpsNXargs.h>
+#include "dpsassert.h"
+#include "dpsNXprops.h"
+#include "csfindNX.h"
+#include "csstartNX.h"
+
+#ifdef DPSLNKL
+#include "dpslnkl.inc"
+#endif /* DPSLNKL */
+
+
+/* +++ Someday make this common with XDPS.c version */
+#define DPY_NUMBER(dpy) ((dpy)->fd)
+
+static xReq _dummy_request = {
+ 0, 0, 0
+};
+
+static void OutOfMemory (Display *);
+
+#ifdef XXX
+/*
+ * 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 */
+
+void XSetAuthorization (char *name, int namelen, char *data, int datalen)
+{
+ char *tmpname, *tmpdata;
+
+ 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;
+
+ 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;
+ bcopy (name, tmpname, namelen);
+ } else {
+ tmpname = NULL;
+ }
+
+ if (datalen > 0) {
+ tmpdata = Xmalloc ((unsigned) datalen);
+ if (!tmpdata) {
+ if (tmpname) (void) Xfree (tmpname);
+ return;
+ }
+ bcopy (data, tmpdata, datalen);
+ } else {
+ tmpdata = NULL;
+ }
+
+ xauth_name = tmpname; /* and store the suckers */
+ xauth_namelen = namelen;
+ xauth_data = tmpdata;
+ xauth_datalen = datalen;
+ return;
+}
+
+#endif /* XXX */
+
+/*
+ * Connects to a server, creates a Display object and returns a pointer to
+ * the newly created Display back to the caller.
+ */
+XExtData *
+DPSCAPOpenAgent(Display *dpy, char *trueDisplayName)
+{
+ register Display *agent;
+ char *agentHost = (char *)NULL;
+ register int i;
+ char display_name[256]; /* pointer to display name */
+ char licMethBuf[256];
+ char *licMeth = licMethBuf;
+ char *fullname = NULL;
+ int idisplay;
+ char *server_addr = NULL;
+ int server_addrlen = 0;
+ int conn_family;
+ int transport, port;
+ XExtData *ext;
+ DPSCAPData my;
+ char hostname[MAXHOSTNAMELEN];
+
+/*
+ * Find an agent to talk to.
+ */
+#ifdef DPSLNKL
+ extern unsigned ANXPFunc();
+#ifdef PSUSEPN
+ (void) sprintf(licMeth, "%s%s:%d",
+ LICENSE_METHOD_PREFIX,
+ ANXVENDOR, /* From dpslnkl.inc */
+ ANXPFunc());
+#else /* PSUSEPN */
+ (void) sprintf(licMeth, "%s%s",
+ LICENSE_METHOD_PREFIX,
+ ANXVENDOR); /* From dpslnkl.inc */
+#endif /* PSUSEPN */
+#else /* DPSLNKL */
+ licMeth = NULL; /* We want an open service */
+#endif /* DPSLNKL */
+ (void) N_XGetHostname(hostname, MAXHOSTNAMELEN);
+ switch(XDPSNXFindNX(dpy, licMeth, &agentHost, &transport, &port)) {
+ case findnx_not_found: {
+ /* try to start-up an NX? */
+ Bool autoLaunch;
+
+ XDPSGetNXArg(XDPSNX_AUTO_LAUNCH, (void **) &autoLaunch);
+ if (autoLaunch == True) {
+ int requestedTrans;
+ int requestedPort = 0;
+ char **args = NULL;
+ char *additionalArgs[2];
+ char transportArg[256];
+
+ (void) DPSWarnProc(NULL, "Auto-launching DPS NX agent.");
+ XDPSGetNXArg(XDPSNX_LAUNCHED_AGENT_TRANS, (void **) &requestedTrans);
+ if (requestedTrans == XDPSNX_USE_BEST) {
+ XDPSNXSetClientArg(XDPSNX_LAUNCHED_AGENT_TRANS,
+ (void *)XDPSNX_TRANS_UNIX);
+ requestedTrans = XDPSNX_TRANS_UNIX;
+ }
+ /* cons-up an arg. to pass to Agent we are forking */
+
+ additionalArgs[1] = (char *) NULL;
+ additionalArgs[0] = transportArg;
+ XDPSGetNXArg(XDPSNX_LAUNCHED_AGENT_PORT, (void **) &requestedPort);
+ if (requestedPort == XDPSNX_USE_BEST) {
+ requestedPort = XDPSNXRecommendPort(requestedTrans);
+ if (requestedPort < 0) {
+ DPSWarnProc(NULL, "Auto-launcher can't get a port.");
+ return(NULL);
+ }
+ }
+ (void) sprintf(transportArg, "%s/%d",
+ (requestedTrans == XDPSNX_TRANS_DECNET ?
+ "dec" : "tcp"),
+ requestedPort);
+ args = additionalArgs;
+ /* ASSERT: first argument in additionalArgs must be
+ transport/port, unless agent changes to take this
+ anywhere */
+ if (StartXDPSNX(args) != Success) {
+ char tb[256], *fs, **as;
+ (void) XDPSGetNXArg(XDPSNX_EXEC_FILE, (void **) &fs);
+ (void) XDPSGetNXArg(XDPSNX_EXEC_ARGS, (void **) &as);
+ (void) sprintf(tb, "FAILED to auto-launch:\n %s", fs);
+ if (as != NULL)
+ for (; *as != NULL; as++) {
+ if ((int) (strlen(*as) + 1 + (i = strlen(tb))) > 256-1) {
+ if (i > 256-1-4)
+ strcpy(&(tb[256-1-1-4]), " ...");
+ else
+ strcat(tb, " ...");
+ break;
+ }
+ (void) strcat(tb, " ");
+ (void) strcat(tb, *as);
+ }
+ DPSWarnProc(NULL, tb);
+ return(NULL);
+ } else {
+ (void) sprintf(display_name, "%s%s%d", hostname,
+ (requestedTrans == XDPSNX_TRANS_DECNET ?
+ "::" : ":"),
+ requestedPort);
+ }
+ } else { /* autoLaunch != True */
+ return(NULL);
+ }
+ }
+ break;
+ case findnx_found: { /* XDPSNXFindNX() == Success */
+ (void) sprintf(display_name, "%s%s%d",
+ (transport == XDPSNX_TRANS_UNIX ?
+ "unix" : agentHost),
+ (transport == XDPSNX_TRANS_DECNET ? "::" : ":"),
+ port);
+ /* Free agentHost later */
+ }
+ break;
+ case findnx_error:
+ return(NULL);
+ break;
+ default:
+ DPSFatalProc(NULL, "Illegal value returned by XDPSNXFindNX");
+ break;
+ }
+
+
+/*
+ * Attempt to allocate a display structure. Return NULL if allocation fails.
+ */
+ if ((agent = (Display *)Xcalloc(1, sizeof(Display))) == NULL) {
+ return(NULL);
+ }
+
+/*
+ * Call the Connect routine to get the network socket. If -1 is returned, the
+ * connection failed. The connect routine will set fullname to point to the
+ * expanded name.
+ */
+
+ if ((agent->fd = DPSCAPConnect(display_name, &fullname, &idisplay,
+ &conn_family,
+ &server_addrlen, &server_addr)) < 0) {
+ Xfree ((char *) agent);
+ return(NULL);
+ }
+#ifdef XXX
+/*
+ * Look up the authorization protocol name and data if necessary.
+ */
+ if (xauth_name && xauth_data) {
+ conn_auth_namelen = xauth_namelen;
+ conn_auth_name = xauth_name;
+ conn_auth_datalen = xauth_datalen;
+ conn_auth_data = xauth_data;
+ } else {
+ char dpynumbuf[40]; /* big enough to hold 2^64 and more */
+ (void) sprintf (dpynumbuf, "%d", idisplay);
+
+ authptr = XauGetAuthByAddr ((unsigned short) conn_family,
+ (unsigned short) server_addrlen,
+ server_addr,
+ (unsigned short) strlen (dpynumbuf),
+ dpynumbuf,
+ (unsigned short) xauth_namelen,
+ xauth_name);
+ if (authptr) {
+ conn_auth_namelen = authptr->name_length;
+ conn_auth_name = (char *)authptr->name;
+ conn_auth_datalen = authptr->data_length;
+ conn_auth_data = (char *)authptr->data;
+ } else {
+ conn_auth_namelen = 0;
+ conn_auth_name = NULL;
+ conn_auth_datalen = 0;
+ conn_auth_data = NULL;
+ }
+ }
+#ifdef HASDES
+ /*
+ * build XDM-AUTHORIZATION-1 data
+ */
+ if (conn_auth_namelen == 19 &&
+ !strncmp (conn_auth_name, "XDM-AUTHORIZATION-1", 19))
+ {
+ static char encrypted_data[192/8];
+ int i, j;
+ struct sockaddr_in in_addr;
+ int addrlen;
+ long now;
+
+ j = 0;
+ for (i = 0; i < 8; i++)
+ {
+ encrypted_data[j] = conn_auth_data[i];
+ j++;
+ }
+ addrlen = sizeof (in_addr);
+ getsockname (dpy->fd, (struct sockaddr *) &in_addr, &addrlen);
+ if (in_addr.sin_family == 2)
+ {
+ encrypted_data[j] = in_addr.sin_addr.s_net; j++;
+ encrypted_data[j] = in_addr.sin_addr.s_host; j++;
+ encrypted_data[j] = in_addr.sin_addr.s_lh; j++;
+ encrypted_data[j] = in_addr.sin_addr.s_impno; j++;
+ encrypted_data[j] = (in_addr.sin_port >> 8) & 0xff; j++;
+ encrypted_data[j] = (in_addr.sin_port) & 0xff; j++;
+ }
+ else
+ {
+ encrypted_data[j] = 0xff; j++;
+ encrypted_data[j] = 0xff; j++;
+ encrypted_data[j] = 0xff; j++;
+ encrypted_data[j] = 0xff; j++;
+ i = getpid ();
+ encrypted_data[j] = (i >> 8) & 0xff; j++;
+ encrypted_data[j] = (i) & 0xff; j++;
+ }
+ time (&now);
+ for (i = 3; i >= 0; i--)
+ {
+ encrypted_data[j] = (now >> (i * 8)) & 0xff;
+ j++;
+ }
+ XdmcpEncrypt (encrypted_data, conn_auth_data + 8,
+ encrypted_data, 192/8);
+ conn_auth_data = encrypted_data;
+ conn_auth_datalen = 192 / 8;
+ }
+#endif /* HASDES */
+ if (server_addr) (void) Xfree (server_addr);
+
+#endif /* XXX */
+
+/*
+ * We succeeded at authorization, so let us move the data into
+ * the display structure.
+ */
+ agent->lock_meaning = NoSymbol;
+#ifdef XXX
+ /* this field is not present in post X11R5 */
+ agent->current = None;
+#endif
+ agent->event_vec[X_Error] = N_XUnknownWireEvent;
+ agent->event_vec[X_Reply] = N_XUnknownWireEvent;
+ agent->wire_vec[X_Error] = N_XUnknownNativeEvent;
+ agent->wire_vec[X_Reply] = N_XUnknownNativeEvent;
+ for (i = KeyPress; i < 128; i++) {
+ agent->event_vec[i] = N_XUnknownWireEvent;
+ agent->wire_vec[i] = N_XUnknownNativeEvent;
+ }
+ agent->cursor_font = None;
+ agent->last_req = (char *)&_dummy_request;
+
+ /* Salt away the host:display string for later use.
+ Storage owned by agent, Xmalloc'd by connection
+ call above */
+ agent->display_name = fullname;
+
+ /* Set up the output buffers. */
+ if ((agent->bufptr = agent->buffer = Xmalloc(BUFSIZE)) == NULL) {
+ OutOfMemory (dpy);
+ return(NULL);
+ }
+ agent->bufmax = agent->buffer + BUFSIZE;
+
+
+ /* Create extension data */
+
+ my = DPSCAPCreate(dpy, agent);
+ if (my == (DPSCAPData)NULL)
+ {
+ OutOfMemory(agent);
+ return(NULL);
+ }
+ ext = (XExtData *)Xcalloc(1, sizeof(XExtData));
+ ext->private_data = (char *)my;
+
+ /* Parse names to get true display name */
+ if (agentHost && strcmp(hostname, agentHost))
+ {
+ register char *s, *p;
+ char *dxname;
+ char nametmp[MAXHOSTNAMELEN];
+ /* Agent is not on the same host as client, so fix
+ up the stupid abbreviations used for the display,
+ and whoever came up with the syntax should be shot. */
+ dxname = DisplayString(dpy);
+ for (s = dxname, p = nametmp; *s; ++s)
+ if (*s == ':')
+ break;
+ else
+ *p++ = *s;
+ *p = '\0';
+ if (nametmp[0] == '\0'
+ || !strcmp(nametmp, "unix")
+ || !strcmp(nametmp, "localhost"))
+ {
+ strcpy(trueDisplayName, hostname);
+ if (*s)
+ strcat(trueDisplayName, s);
+ else
+ strcat(trueDisplayName, ":0.0");
+ }
+ else
+ strcpy(trueDisplayName, dxname);
+ }
+ else
+ strcpy(trueDisplayName, DisplayString(dpy));
+ if (agentHost)
+ Xfree(agentHost);
+ return(ext);
+}
+
+
+/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL
+ after this returns. */
+
+static void OutOfMemory (Display *dpy)
+{
+ DPSCAPCloseAgent(dpy);
+}
+
+#ifdef NEEDFORNX
+/* XFreeDisplayStructure frees all the storage associated with a
+ * Display. It is used by XOpenDisplay if it runs out of memory,
+ * and also by XCloseDisplay. It needs to check whether all pointers
+ * are non-NULL before dereferencing them, since it may be called
+ * by XOpenDisplay before the Display structure is fully formed.
+ * XOpenDisplay must be sure to initialize all the pointers to NULL
+ * before the first possible call on this.
+ */
+
+static void
+_XFreeDisplayStructure(register Display *dpy)
+{
+ if (dpy->screens) {
+ register int i;
+
+ for (i = 0; i < dpy->nscreens; i++) {
+ Screen *sp = &dpy->screens[i];
+
+ if (sp->depths) {
+ register int j;
+
+ for (j = 0; j < sp->ndepths; j++) {
+ Depth *dp = &sp->depths[j];
+
+ if (dp->visuals) {
+ register int k;
+
+ for (k = 0; k < dp->nvisuals; k++)
+ _XFreeExtData (dp->visuals[k].ext_data);
+ Xfree ((char *) dp->visuals);
+ }
+ }
+
+ Xfree ((char *) sp->depths);
+ }
+
+ _XFreeExtData (sp->ext_data);
+ }
+
+ Xfree ((char *)dpy->screens);
+ }
+
+ if (dpy->pixmap_format) {
+ register int i;
+
+ for (i = 0; i < dpy->nformats; i++)
+ _XFreeExtData (dpy->pixmap_format[i].ext_data);
+ Xfree ((char *)dpy->pixmap_format);
+ }
+
+ if (dpy->display_name)
+ Xfree (dpy->display_name);
+ if (dpy->vendor)
+ Xfree (dpy->vendor);
+
+ if (dpy->buffer)
+ Xfree (dpy->buffer);
+ if (dpy->atoms)
+ Xfree ((char *) dpy->atoms);
+ if (dpy->keysyms)
+ Xfree ((char *) dpy->keysyms);
+ if (dpy->modifiermap)
+ XFreeModifiermap(dpy->modifiermap);
+ if (dpy->xdefaults)
+ Xfree (dpy->xdefaults);
+ if (dpy->key_bindings)
+ _XFreeKeyBindings(dpy);
+
+ while (dpy->ext_procs) {
+ _XExtension *ext = dpy->ext_procs;
+ dpy->ext_procs = ext->next;
+ if (ext->name)
+ Xfree (ext->name);
+ Xfree ((char *)ext);
+ }
+
+ _XFreeExtData (dpy->ext_data);
+
+ Xfree ((char *)dpy);
+}
+#endif /* NEEDFORNX */
+
+
+
+void
+DPSCAPCloseAgent(Display *agent)
+{
+ if (!agent) return;
+ N_XDisconnectDisplay(agent->fd);
+ if (agent->display_name)
+ Xfree(agent->display_name);
+ if (agent->buffer)
+ Xfree(agent->buffer);
+ Xfree((char *)agent);
+}
diff --git a/nx-X11/lib/dps/csstartNX.c b/nx-X11/lib/dps/csstartNX.c
new file mode 100644
index 000000000..0db2cbe5b
--- /dev/null
+++ b/nx-X11/lib/dps/csstartNX.c
@@ -0,0 +1,237 @@
+/*
+ csstartNX.c
+
+ * (c) Copyright 1992-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86: xc/lib/dps/csstartNX.c,v 1.6 2001/10/28 03:32:43 tsi Exp $ */
+
+#include <sys/param.h>
+#include <X11/X.h>
+#include <X11/Xlibint.h>
+#include <sys/wait.h>
+#include <DPS/dpsNXargs.h>
+#include <sys/socket.h>
+#include <errno.h>
+#include <X11/Xos.h>
+
+#include "DPSCAPproto.h"
+#include "Xlibnet.h" /* New for R5, delete for R4 */
+#include "dpsassert.h"
+#include "csfindNX.h"
+#include "csstartNX.h"
+
+/* ---Defines--- */
+
+#include <stddef.h>
+
+#define DOZETIME 1 /* time to wait for agent to start up (sec) */
+
+#define BASE_TCP_PORT CSDPSPORT
+
+#ifndef CSDPSMAXPORT
+#define CSDPSMAXPORT 16
+#endif
+
+#ifndef SO_REUSEADDR
+#define SO_REUSEADDR 1
+#endif
+
+/* ---Globals--- */
+
+pid_t gSecretAgentPID = 0; /* PID of launched agent *Shh!* Not public! */
+
+/* ---Private Functions--- */
+
+static int
+TryTCP(void)
+{
+ struct sockaddr_in insock;
+ int request;
+ unsigned short port, startPort = 0;
+ struct servent *serventInfo;
+ int okay;
+
+#ifndef ultrix
+ /* Ultrix has a nasty bug in getservbyname(). If the name passed
+ to it doesn't exist in the services list it will seg. fault...
+ * sigh * */
+ if ((serventInfo = getservbyname(DPS_NX_SERV_NAME,
+ (char *) 0)) != 0)
+ if (strcmp("tcp", serventInfo->s_proto) == 0) {
+ startPort = ntohs(serventInfo->s_port);
+ }
+ /* So, for Ultrix we just default to the default default port :-) */
+#endif /* ultrix */
+ if (startPort == 0) startPort = BASE_TCP_PORT;
+ if ((request = socket (AF_INET, SOCK_STREAM, 0)) < 0)
+ {
+ DPSWarnProc(NULL, "Creating TCP socket while recommending port\n");
+ return -1;
+ }
+#ifdef SO_REUSEADDR
+ /* Necesary to restart the server without a reboot */
+ {
+ int one = 1;
+ setsockopt(request, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(int));
+ }
+ /* What the hell is all this? I'll tell you. We don't know
+ a prioi what port is free, so we try to bind to each
+ in sequence and return the one that works. */
+#if !defined(AIXV3)
+ {
+ struct linger lingere;
+
+ lingere.l_onoff = 0; /* off */
+ lingere.l_linger = 0; /* don't */
+ if(setsockopt(request, SOL_SOCKET, SO_LINGER, (char *)&lingere,
+ sizeof(struct linger)) != 0)
+ DPSWarnProc(NULL,
+ "Couldn't set TCP SO_DONTLINGER while recommending port.");
+ }
+#endif /* AIXV3 */
+#endif /* SO_REUSEADDR */
+ bzero((char *)&insock, sizeof (insock));
+ insock.sin_family = AF_INET;
+ insock.sin_addr.s_addr = htonl(INADDR_ANY);
+ okay = 0;
+
+ for (port = startPort; (int) port < (int) startPort + CSDPSMAXPORT; port++)
+ {
+ int result;
+ insock.sin_port = htons(port);
+
+ errno = 0;
+ result = bind(request, (struct sockaddr *) &insock, sizeof (insock));
+ if (result < 0)
+ {
+ if (errno != EADDRINUSE)
+ {
+ DPSWarnProc(NULL, "Binding TCP socket while recommending port.\n");
+ close(request);
+ return -1;
+ }
+ continue;
+ }
+ else
+ {
+ /* We have a good port number */
+ okay = 1;
+ break;
+ }
+ }
+ close(request);
+ return (okay) ? port : -1;
+}
+
+/* ---Functions--- */
+
+int
+XDPSNXRecommendPort(int transport)
+{
+ int ret;
+
+ switch (transport)
+ {
+ case XDPSNX_TRANS_UNIX:
+ /* If the TCP socket exists, we just assume the UNIX one
+ is there too. FALL THRU! */
+ case XDPSNX_TRANS_TCP: /* TCP */
+ ret = TryTCP();
+ break;
+ default: ret = -1;
+ }
+ return(ret);
+}
+
+int
+StartXDPSNX(char **additionalArgs)
+{
+ char **args, **cpp;
+ pid_t childPid;
+ int argc = 1; /* 1, args[0]:=path, args[1]:=null */
+ int i = 0;
+ int status = Success; /* assume we'll succeed */
+ char *execObj, **execArgs;
+
+ (void) XDPSGetNXArg(XDPSNX_EXEC_FILE, (void **) &execObj);
+ if (execObj == 0) return (!Success);
+
+ /* Create the argv list for the execl() call */
+ (void) XDPSGetNXArg(XDPSNX_EXEC_ARGS, (void **) &execArgs);
+ if (execArgs != 0)
+ for(cpp = execArgs; *cpp != 0; cpp++, argc++); /* count args. */
+ if (additionalArgs != 0) /* add on the add-on args. */
+ for(cpp = additionalArgs; *cpp != 0; cpp++, argc++);
+
+ args = (char **) Xmalloc(sizeof(char *) * (argc+1));
+ if (args == 0)
+ return(!Success);
+ args[argc] = 0; /* cap end of args */
+ args[i++] = execObj;
+ if (additionalArgs != 0)
+ for(cpp = additionalArgs; *cpp != 0; cpp++, i++) args[i] = *cpp;
+ if (execArgs != 0)
+ for(cpp = execArgs; *cpp != 0; cpp++, i++) args[i] = *cpp;
+
+ /* now try to start up the agent... */
+ if ((childPid = fork()) != -1) {
+ if (childPid == 0) { /* Child process */
+#ifndef __UNIXOS2__
+ if (setsid() < 0)
+ DPSWarnProc(NULL, "Agent unable to create session. Continuing...\n");
+#endif
+
+ /* Try to start the agent */
+ if (execvp(args[0], args) < 0) { /* Error!! */
+ exit(1); /* This is OKAY, we're the child here */
+ }
+ /* SHOULD NEVER REACH HERE */
+ } else { /* Parent (NX Client) */
+ (void) sleep(DOZETIME);
+ /* if decmips, pray that we hesitate long enough for the child... */
+ /* Check on child (NX Agent) */
+ if (waitpid(childPid, NULL, WNOHANG) != 0) {
+ /* Server terminated or stopped; don't care, result is same... */
+ status = !Success;
+ } else { /* we think the agent started okay */
+ gSecretAgentPID = childPid; /* set secret global */
+ }
+ }
+ } else { /* Error in fork */
+ status = !Success;
+ }
+ if (args != 0) (void) XFree(args);
+ return(status);
+}
diff --git a/nx-X11/lib/dps/csstartNX.h b/nx-X11/lib/dps/csstartNX.h
new file mode 100644
index 000000000..5e80e60aa
--- /dev/null
+++ b/nx-X11/lib/dps/csstartNX.h
@@ -0,0 +1,67 @@
+/*
+ * csstartNX.h -- handles fork()/execl() for starting DPSNX from dps lib
+ *
+ * (c) Copyright 1992-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#ifndef CSSTARTNX_H
+#define CSSTARTNX_H
+
+#include <X11/Xlib.h>
+
+/* ---Globals--- */
+
+extern Bool gStartXDPSNXIsPresent;
+ /*
+ * Indicates whether the function "StartXDPSNX" is live or just
+ * a stubbed out version.
+ */
+
+/* ---Functions--- */
+
+extern int StartXDPSNX (char **additionalArgs);
+ /*
+ * StartXDPSNX attempts to fork and exec the object file specified by
+ * the DPSSetNXArg argument "DPSNXEXEC". It passes as arguments to the
+ * object file the DPSSetNXArg argument "DPSNXEXECARGS" with the
+ * additionalArgs (if there are any) appended.
+ * RETURNS:
+ * StartXDPSNX will return Success if it believes that the child has
+ * started correctly. Otherwise it returns !Success
+ */
+
+extern int XDPSNXRecommendPort(int transport);
+
+#endif /* CSSTARTNX_H */
diff --git a/nx-X11/lib/dps/dps-def.cpp b/nx-X11/lib/dps/dps-def.cpp
new file mode 100644
index 000000000..d88841d66
--- /dev/null
+++ b/nx-X11/lib/dps/dps-def.cpp
@@ -0,0 +1,991 @@
+LIBRARY Dps
+VERSION LIBRARY_VERSION
+EXPORTS
+DPSAddContextExtensionRec
+DPSAwaitReturnValues
+DPSBinObjSeqWrite
+DPSChainContext
+DPSCheckInitClientGlobals
+DPSCheckRaiseError
+DPSCreateContext
+DPSCreateTextContext
+DPSDefaultErrorProc
+DPSDestroyContext
+DPSDestroySpace
+DPSFlushContext
+DPSGenerateExtensionRecID
+DPSGetContextExtensionRec
+DPSGetContextType
+DPSGetCurrentContext
+DPSGetCurrentErrorBackstop
+DPSGetCurrentTextBackstop
+DPSInitCommonContextProcs
+DPSInitCommonSpaceProcs
+DPSInitCommonTextContextProcs
+DPSInitialize
+DPSInterruptContext
+DPSKnownContext
+DPSKnownSpace
+DPSMapNames
+DPSNameFromIndex
+DPSPrivCurrentContext
+DPSRemoveContextExtensionRec
+DPSResetContext
+DPSSafeSetLastNameIndex
+DPSSetAbbrevMode
+DPSSetContext
+DPSSetErrorBackstop
+DPSSetNumStringConversion
+DPSSetResultTable
+DPSSetTextBackstop
+DPSSetWh
+DPSSetWrapSynchronization
+DPSSuppressBinaryConversion
+DPSUnchainContext
+DPSUpdateNameMap
+DPSWaitContext
+DPSWriteData
+DPSWriteNumString
+DPSWritePostScript
+DPSWriteStringChars
+DPSWriteTypedObjectArray
+DPScalloc
+DPSclientPrintProc
+DPSPrintf
+DPSRaise
+DPSCreatePSWDict
+DPSDestroyPSWDict
+DPSMakeAtom
+DPSWDictEnter
+DPSWDictLookup
+DPSWDictRemove
+DPSFetchAbbrevList
+DPSGetOperatorAbbrev
+DPSGetSysnameAbbrev
+DPSCantHappen
+DPSChangeEncoding
+DPSCheckShared
+DPSContextFromContextID
+DPSDefaultPrivateHandler
+DPSFatalProc
+DPSHandleBogusError
+DPSInitPrivateContextFields
+DPSInitPrivateContextProcs
+DPSInitPrivateSpaceFields
+DPSInitPrivateTextContextFields
+DPSNewUserObjectIndex
+DPSPrivateCheckWait
+DPSPrivateDestroyContext
+DPSPrivateDestroySpace
+DPSServicePostScript
+DPSWarnProc
+DPSinnerProcWriteData
+XDPSContextFromSharedID
+XDPSContextFromXID
+XDPSCreateContext
+XDPSCreateSecureContext
+XDPSCreateSimpleContext
+XDPSDispatchEvent
+XDPSFindContext
+XDPSGetContextStatus
+XDPSGetProtocolVersion
+XDPSIsDPSEvent
+XDPSIsOutputEvent
+XDPSIsReadyEvent
+XDPSIsStatusEvent
+XDPSNotifyWhenReady
+XDPSReadyEventHandler
+XDPSRegisterReadyProc
+XDPSRegisterStatusProc
+XDPSSetEventDelivery
+XDPSSetProcs
+XDPSSetStatusMask
+XDPSSpaceFromSharedID
+XDPSSpaceFromXID
+XDPSStatusEventHandler
+XDPSUnfreezeContext
+XDPSXIDFromContext
+XDPSXIDFromSpace
+DPSInitSysNames
+DPSCreatePrivContext
+DPSDefaultTextBackstop
+DPSIncludePrivContext
+DPSInitClient
+DPSOutOfMemory
+DPSSendDestroySpace
+DPSSendEOF
+DPSSendInterrupt
+DPSSendPostScript
+DPSSendTerminate
+XDPSCreatePrivContextRec
+XDPSForceEvents
+XDPSNumFormat
+XDPSPrivZapDpy
+XDPSSendUnfreeze
+XDPSSetContextEncoding
+XDPSLCAPNotify
+XDPSLCallOutputEventHandler
+XDPSLCallReadyEventHandler
+XDPSLCallStatusEventHandler
+XDPSLCleanAll
+XDPSLCleanContext
+XDPSLContextFromXID
+XDPSLCreateContext
+XDPSLCreateContextAndSpace
+XDPSLCreateContextFromID
+XDPSLCreateSpace
+XDPSLDestroySpace
+XDPSLDispatchCSDPSFakeEvent
+XDPSLFlush
+XDPSLFlushGC
+XDPSLGetCSDPSFakeEventType
+XDPSLGetCSDPSReady
+XDPSLGetCSDPSStatus
+XDPSLGetCodes
+XDPSLGetGCFlushMode
+XDPSLGetPassEventsFlag
+XDPSLGetShunt
+XDPSLGetStatus
+XDPSLGetSyncMask
+XDPSLGetVersion
+XDPSLGetWrapWaitingFlag
+XDPSLGiveInput
+XDPSLIDFromContext
+XDPSLInit
+XDPSLInitDisplayFlags
+XDPSLNotifyContext
+XDPSLNotifyWhenReady
+XDPSLReconcileRequests
+XDPSLReset
+XDPSLSetAfterProc
+XDPSLSetAgentArg
+XDPSLSetAgentName
+XDPSLSetClientMessageHandler
+XDPSLSetCodes
+XDPSLSetGCFlushMode
+XDPSLSetPassEventsFlag
+XDPSLSetReadyEventHandler
+XDPSLSetShunt
+XDPSLSetStatusEventHandler
+XDPSLSetStatusMask
+XDPSLSetSyncMask
+XDPSLSetTextEventHandler
+XDPSLSetVersion
+XDPSLSetWrapWaitingFlag
+XDPSLSync
+XDPSLSyncGCClip
+XDPSLTestErrorCode
+XDPSLUpdateAgentArgs
+XDPSSetXtEventDispatching
+;XDPSCreateStandardColormaps
+XDPSGetDefaultColorMaps
+CSDPSHeadOfDpyExt
+CSDPSInit
+DPSCAPChangeGC
+DPSCAPCloseDisplayProc
+DPSCAPCopyGCProc
+DPSCAPCreate
+DPSCAPDestroy
+DPSCAPFlushGCProc
+DPSCAPFreeGCProc
+DPSCAPStartUp
+DPSCAPWrite
+XDPSFlushGC
+XDPSNXSetAgentArg
+XDPSReconcileRequests
+XDPSSyncGCClip
+DPSCAPCloseAgent
+DPSCAPOpenAgent
+DPSCAPConnect
+N_XDisconnectDisplay
+N_XWaitForReadable
+N_XWaitForWritable
+StartXDPSNX
+XDPSNXRecommendPort
+XDPSGetNXArg
+XDPSNXFindNX
+XDPSNXSetClientArg
+NXProcData
+N_XANYSET
+N_XFlush
+N_XGetHostname
+N_XRead
+N_XReadPad
+N_XReply
+N_XSend
+N_XUnknownNativeEvent
+N_XUnknownWireEvent
+DPScolorimage
+DPScurrentblackgeneration
+DPScurrentcmykcolor
+DPScurrentcolorscreen
+DPScurrentcolortransfer
+DPScurrentundercolorremoval
+DPSsetblackgeneration
+DPSsetcmykcolor
+DPSsetcolorscreen
+DPSsetcolortransfer
+DPSsetundercolorremoval
+DPSeq
+DPSexit
+DPSfalse
+DPSfor
+DPSforall
+DPSge
+DPSgt
+DPSif
+DPSifelse
+DPSle
+DPSloop
+DPSlt
+DPSne
+DPSnot
+DPSor
+DPSrepeat
+DPSstop
+DPSstopped
+DPStrue
+DPSUserObjects
+DPScondition
+DPScurrentcontext
+DPScurrentobjectformat
+DPSdefineusername
+DPSdefineuserobject
+DPSdetach
+DPSexecuserobject
+DPSfork
+DPSjoin
+DPSlock
+DPSmonitor
+DPSnotify
+DPSsetobjectformat
+DPSsetvmthreshold
+DPSundefineuserobject
+DPSwait
+DPSyield
+DPSaload
+DPSanchorsearch
+DPSarray
+DPSastore
+DPSbegin
+DPSclear
+DPScleartomark
+DPScopy
+DPScount
+DPScounttomark
+DPScvi
+DPScvlit
+DPScvn
+DPScvr
+DPScvrs
+DPScvs
+DPScvx
+DPSdef
+DPSdict
+DPSdictstack
+DPSdup
+DPSend
+DPSexch
+DPSexecstack
+DPSexecuteonly
+DPSget
+DPSgetinterval
+DPSindex
+DPSknown
+DPSlength
+DPSload
+DPSmark
+DPSmatrix
+DPSmaxlength
+DPSnoaccess
+DPSnull
+DPSpackedarray
+DPSpop
+DPSput
+DPSputinterval
+DPSrcheck
+DPSreadonly
+DPSroll
+DPSscheck
+DPSsearch
+DPSshareddict
+DPSstatusdict
+DPSstore
+DPSstring
+DPSstringwidth
+DPSsystemdict
+DPSuserdict
+DPSwcheck
+DPSwhere
+DPSxcheck
+DPSFontDirectory
+DPSISOLatin1Encoding
+DPSSharedFontDirectory
+DPSStandardEncoding
+DPScachestatus
+DPScurrentcacheparams
+DPScurrentfont
+DPSdefinefont
+DPSfindfont
+DPSmakefont
+DPSscalefont
+DPSselectfont
+DPSsetcachedevice
+DPSsetcachelimit
+DPSsetcacheparams
+DPSsetcharwidth
+DPSsetfont
+DPSundefinefont
+DPSconcat
+DPScurrentdash
+DPScurrentflat
+DPScurrentgray
+DPScurrentgstate
+DPScurrenthalftone
+DPScurrenthalftonephase
+DPScurrenthsbcolor
+DPScurrentlinecap
+DPScurrentlinejoin
+DPScurrentlinewidth
+DPScurrentmatrix
+DPScurrentmiterlimit
+DPScurrentpoint
+DPScurrentrgbcolor
+DPScurrentscreen
+DPScurrentstrokeadjust
+DPScurrenttransfer
+DPSdefaultmatrix
+DPSgrestore
+DPSgrestoreall
+DPSgsave
+DPSgstate
+DPSinitgraphics
+DPSinitmatrix
+DPSrotate
+DPSscale
+DPSsetdash
+DPSsetflat
+DPSsetgray
+DPSsetgstate
+DPSsethalftone
+DPSsethalftonephase
+DPSsethsbcolor
+DPSsetlinecap
+DPSsetlinejoin
+DPSsetlinewidth
+DPSsetmatrix
+DPSsetmiterlimit
+DPSsetrgbcolor
+DPSsetscreen
+DPSsetstrokeadjust
+DPSsettransfer
+DPStranslate
+DPSbytesavailable
+DPSclosefile
+DPScurrentfile
+DPSdeletefile
+DPSecho
+DPSequals
+DPSequalsequals
+DPSfile
+DPSfilenameforall
+DPSfileposition
+DPSflush
+DPSflushfile
+DPSprint
+DPSprintobject
+DPSpstack
+DPSread
+DPSreadhexstring
+DPSreadline
+DPSreadstring
+DPSrenamefile
+DPSresetfile
+DPSsetfileposition
+DPSstack
+DPSstatus
+DPStoken
+DPSwrite
+DPSwritehexstring
+DPSwriteobject
+DPSwritestring
+DPSabs
+DPSadd
+DPSand
+DPSatan
+DPSbitshift
+DPSceiling
+DPScos
+DPSdiv
+DPSexp
+DPSfloor
+DPSidiv
+DPSln
+DPSlog
+DPSmod
+DPSmul
+DPSneg
+DPSround
+DPSsin
+DPSsqrt
+DPSsub
+DPStruncate
+DPSxor
+DPSconcatmatrix
+DPSdtransform
+DPSidentmatrix
+DPSidtransform
+DPSinvertmatrix
+DPSitransform
+DPStransform
+DPSbanddevice
+DPSframedevice
+DPSnulldevice
+DPSrenderbands
+DPSashow
+DPSawidthshow
+DPScopypage
+DPSeofill
+DPSerasepage
+DPSfill
+DPSimage
+DPSimagemask
+DPSkshow
+DPSrectfill
+DPSrectstroke
+DPSshow
+DPSshowpage
+DPSstroke
+DPSstrokepath
+DPSueofill
+DPSufill
+DPSustroke
+DPSustrokepath
+DPSwidthshow
+DPSxshow
+DPSxyshow
+DPSyshow
+DPSarc
+DPSarcn
+DPSarct
+DPSarcto
+DPScharpath
+DPSclip
+DPSclippath
+DPSclosepath
+DPScurveto
+DPSeoclip
+DPSeoviewclip
+DPSflattenpath
+DPSinitclip
+DPSinitviewclip
+DPSlineto
+DPSmoveto
+DPSnewpath
+DPSpathbbox
+DPSpathforall
+DPSrcurveto
+DPSrectclip
+DPSrectviewclip
+DPSreversepath
+DPSrlineto
+DPSrmoveto
+DPSsetbbox
+DPSsetucacheparams
+DPSuappend
+DPSucache
+DPSucachestatus
+DPSupath
+DPSviewclip
+DPSviewclippath
+DPSbind
+DPScleardictstack
+DPScountdictstack
+DPScountexecstack
+DPScurrentdict
+DPScurrentpacking
+DPScurrentshared
+DPSdeviceinfo
+DPSerrordict
+DPSexec
+DPSprompt
+DPSquit
+DPSrand
+DPSrealtime
+DPSrestore
+DPSrrand
+DPSrun
+DPSsave
+DPSsetpacking
+DPSsetshared
+DPSsrand
+DPSstart
+DPStype
+DPSundef
+DPSusertime
+DPSversion
+DPSvmreclaim
+DPSvmstatus
+DPSineofill
+DPSinfill
+DPSinstroke
+DPSinueofill
+DPSinufill
+DPSinustroke
+DPSwtranslation
+DPSgetboolean
+DPSgetchararray
+DPSgetfloat
+DPSgetfloatarray
+DPSgetint
+DPSgetintarray
+DPSgetstring
+DPSsendboolean
+DPSsendchararray
+DPSsendfloat
+DPSsendfloatarray
+DPSsendint
+DPSsendintarray
+DPSsendstring
+DPSclientXready
+DPSclientsync
+DPScurrentXdrawingfunction
+DPScurrentXgcdrawable
+DPScurrentXgcdrawablecolor
+DPScurrentXoffset
+DPSsetXdrawingfunction
+DPSsetXgcdrawable
+DPSsetXgcdrawablecolor
+DPSsetXoffset
+DPSsetXrgbactual
+DPSGlobalFontDirectory
+DPScshow
+DPScurrentcolor
+DPScurrentcolorrendering
+DPScurrentcolorspace
+DPScurrentdevparams
+DPScurrentglobal
+DPScurrentoverprint
+DPScurrentpagedevice
+DPScurrentsystemparams
+DPScurrentuserparams
+DPSdefineresource
+DPSexecform
+DPSfilter
+DPSfindencoding
+DPSfindresource
+DPSgcheck
+DPSglobaldict
+DPSglyphshow
+DPSlanguagelevel
+DPSleftbracket
+DPSleftleft
+DPSmakepattern
+DPSproduct
+DPSresourceforall
+DPSresourcestatus
+DPSrevision
+DPSrightbracket
+DPSrightright
+DPSrootfont
+DPSserialnumber
+DPSsetcolor
+DPSsetcolorrendering
+DPSsetcolorspace
+DPSsetdevparams
+DPSsetglobal
+DPSsetoverprint
+DPSsetpagedevice
+DPSsetpattern
+DPSsetsystemparams
+DPSsetuserparams
+DPSstartjob
+DPSundefineresource
+PScolorimage
+PScurrentblackgeneration
+PScurrentcmykcolor
+PScurrentcolorscreen
+PScurrentcolortransfer
+PScurrentundercolorremoval
+PSsetblackgeneration
+PSsetcmykcolor
+PSsetcolorscreen
+PSsetcolortransfer
+PSsetundercolorremoval
+PSeq
+PSexit
+PSfalse
+PSfor
+PSforall
+PSge
+PSgt
+PSif
+PSifelse
+PSle
+PSloop
+PSlt
+PSne
+PSnot
+PSor
+PSrepeat
+PSstop
+PSstopped
+PStrue
+PSUserObjects
+PScondition
+PScurrentcontext
+PScurrentobjectformat
+PSdefineusername
+PSdefineuserobject
+PSdetach
+PSexecuserobject
+PSfork
+PSjoin
+PSlock
+PSmonitor
+PSnotify
+PSsetobjectformat
+PSsetvmthreshold
+PSundefineuserobject
+PSwait
+PSyield
+PSaload
+PSanchorsearch
+PSarray
+PSastore
+PSbegin
+PSclear
+PScleartomark
+PScopy
+PScount
+PScounttomark
+PScvi
+PScvlit
+PScvn
+PScvr
+PScvrs
+PScvs
+PScvx
+PSdef
+PSdict
+PSdictstack
+PSdup
+PSend
+PSexch
+PSexecstack
+PSexecuteonly
+PSget
+PSgetinterval
+PSindex
+PSknown
+PSlength
+PSload
+PSmark
+PSmatrix
+PSmaxlength
+PSnoaccess
+PSnull
+PSpackedarray
+PSpop
+PSput
+PSputinterval
+PSrcheck
+PSreadonly
+PSroll
+PSscheck
+PSsearch
+PSshareddict
+PSstatusdict
+PSstore
+PSstring
+PSstringwidth
+PSsystemdict
+PSuserdict
+PSwcheck
+PSwhere
+PSxcheck
+PSFontDirectory
+PSISOLatin1Encoding
+PSSharedFontDirectory
+PSStandardEncoding
+PScachestatus
+PScurrentcacheparams
+PScurrentfont
+PSdefinefont
+PSfindfont
+PSmakefont
+PSscalefont
+PSselectfont
+PSsetcachedevice
+PSsetcachelimit
+PSsetcacheparams
+PSsetcharwidth
+PSsetfont
+PSundefinefont
+PSconcat
+PScurrentdash
+PScurrentflat
+PScurrentgray
+PScurrentgstate
+PScurrenthalftone
+PScurrenthalftonephase
+PScurrenthsbcolor
+PScurrentlinecap
+PScurrentlinejoin
+PScurrentlinewidth
+PScurrentmatrix
+PScurrentmiterlimit
+PScurrentpoint
+PScurrentrgbcolor
+PScurrentscreen
+PScurrentstrokeadjust
+PScurrenttransfer
+PSdefaultmatrix
+PSgrestore
+PSgrestoreall
+PSgsave
+PSgstate
+PSinitgraphics
+PSinitmatrix
+PSrotate
+PSscale
+PSsetdash
+PSsetflat
+PSsetgray
+PSsetgstate
+PSsethalftone
+PSsethalftonephase
+PSsethsbcolor
+PSsetlinecap
+PSsetlinejoin
+PSsetlinewidth
+PSsetmatrix
+PSsetmiterlimit
+PSsetrgbcolor
+PSsetscreen
+PSsetstrokeadjust
+PSsettransfer
+PStranslate
+PSbytesavailable
+PSclosefile
+PScurrentfile
+PSdeletefile
+PSecho
+PSequals
+PSequalsequals
+PSfile
+PSfilenameforall
+PSfileposition
+PSflush
+PSflushfile
+PSprint
+PSprintobject
+PSpstack
+PSread
+PSreadhexstring
+PSreadline
+PSreadstring
+PSrenamefile
+PSresetfile
+PSsetfileposition
+PSstack
+PSstatus
+PStoken
+PSwrite
+PSwritehexstring
+PSwriteobject
+PSwritestring
+PSabs
+PSadd
+PSand
+PSatan
+PSbitshift
+PSceiling
+PScos
+PSdiv
+PSexp
+PSfloor
+PSidiv
+PSln
+PSlog
+PSmod
+PSmul
+PSneg
+PSround
+PSsin
+PSsqrt
+PSsub
+PStruncate
+PSxor
+PSconcatmatrix
+PSdtransform
+PSidentmatrix
+PSidtransform
+PSinvertmatrix
+PSitransform
+PStransform
+PSbanddevice
+PSframedevice
+PSnulldevice
+PSrenderbands
+PSashow
+PSawidthshow
+PScopypage
+PSeofill
+PSerasepage
+PSfill
+PSimage
+PSimagemask
+PSkshow
+PSrectfill
+PSrectstroke
+PSshow
+PSshowpage
+PSstroke
+PSstrokepath
+PSueofill
+PSufill
+PSustroke
+PSustrokepath
+PSwidthshow
+PSxshow
+PSxyshow
+PSyshow
+PSarc
+PSarcn
+PSarct
+PSarcto
+PScharpath
+PSclip
+PSclippath
+PSclosepath
+PScurveto
+PSeoclip
+PSeoviewclip
+PSflattenpath
+PSinitclip
+PSinitviewclip
+PSlineto
+PSmoveto
+PSnewpath
+PSpathbbox
+PSpathforall
+PSrcurveto
+PSrectclip
+PSrectviewclip
+PSreversepath
+PSrlineto
+PSrmoveto
+PSsetbbox
+PSsetucacheparams
+PSuappend
+PSucache
+PSucachestatus
+PSupath
+PSviewclip
+PSviewclippath
+PSbind
+PScleardictstack
+PScountdictstack
+PScountexecstack
+PScurrentdict
+PScurrentpacking
+PScurrentshared
+PSdeviceinfo
+PSerrordict
+PSexec
+PSprompt
+PSquit
+PSrand
+PSrealtime
+PSrestore
+PSrrand
+PSrun
+PSsave
+PSsetpacking
+PSsetshared
+PSsrand
+PSstart
+PStype
+PSundef
+PSusertime
+PSversion
+PSvmreclaim
+PSvmstatus
+PSineofill
+PSinfill
+PSinstroke
+PSinueofill
+PSinufill
+PSinustroke
+PSwtranslation
+PSgetboolean
+PSgetchararray
+PSgetfloat
+PSgetfloatarray
+PSgetint
+PSgetintarray
+PSgetstring
+PSsendboolean
+PSsendchararray
+PSsendfloat
+PSsendfloatarray
+PSsendint
+PSsendintarray
+PSsendstring
+PSclientXready
+PSclientsync
+PScurrentXdrawingfunction
+PScurrentXgcdrawable
+PScurrentXgcdrawablecolor
+PScurrentXoffset
+PSsetXdrawingfunction
+PSsetXgcdrawable
+PSsetXgcdrawablecolor
+PSsetXoffset
+PSsetXrgbactual
+PSGlobalFontDirectory
+PScshow
+PScurrentcolor
+PScurrentcolorrendering
+PScurrentcolorspace
+PScurrentdevparams
+PScurrentglobal
+PScurrentoverprint
+PScurrentpagedevice
+PScurrentsystemparams
+PScurrentuserparams
+PSdefineresource
+PSexecform
+PSfilter
+PSfindencoding
+PSfindresource
+PSgcheck
+PSglobaldict
+PSglyphshow
+PSlanguagelevel
+PSleftbracket
+PSleftleft
+PSmakepattern
+PSproduct
+PSresourceforall
+PSresourcestatus
+PSrevision
+PSrightbracket
+PSrightright
+PSrootfont
+PSserialnumber
+PSsetcolor
+PSsetcolorrendering
+PSsetcolorspace
+PSsetdevparams
+PSsetglobal
+PSsetoverprint
+PSsetpagedevice
+PSsetpattern
+PSsetsystemparams
+PSsetuserparams
+PSstartjob
+PSundefineresource
+
+/* $XFree86$ */
diff --git a/nx-X11/lib/dps/dpsNXprops.h b/nx-X11/lib/dps/dpsNXprops.h
new file mode 100644
index 000000000..c3a8e8d39
--- /dev/null
+++ b/nx-X11/lib/dps/dpsNXprops.h
@@ -0,0 +1,90 @@
+/*
+ * dpsNXprops.h
+ *
+ * (c) Copyright 1992-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+#ifndef DPSNXPROPS_H
+#define DPSNXPROPS_H
+
+
+/* ---DEFINES--- */
+
+/* --- X Window Properties --- */
+
+#define XDPSNX_BILLBOARD_PROP "_ADOBE_DPS_NX_BILLBOARD" /* On dpy root win */
+
+/* Following are per Agent window properties */
+
+#define XDPSNX_WILLINGNESS_PROP "_ADOBE_DPS_NX_WILLINGNESS_PROP"
+#define XDPSNX_LICENSE_METHOD_PROP "_ADOBE_DPS_NX_LICENSE_METHODS_PROP"
+#define XDPSNX_TRANSPORT_INFO_PROP "_ADOBE_DPS_NX_TRANSPORT_INFO_PROP"
+#define XDPSNX_HOST_NAME_PROP "_ADOBE_DPS_NX_HOST_NAME_PROP"
+
+#define XDPSNX_X_CLASS_NAME "XDPSNX"
+#define XDPSNX_X_RESOURCE "xdpsnx.agenthost"
+#define XDPSNX_X_CLASS "XDPSNX.AgentHost"
+
+#define AGENT_ENV_VAR "DPSNXHOST"
+
+
+/* - Predefined Willingness Prop. Values. Range: [0, 100] - */
+
+#define XDPSNX_MAX_WILLINGNESS 100
+#define XDPSNX_NOT_WILLING 0 /* 0:= agent wishes to "refuses" service to
+ new clients */
+#define XDPSNX_MIN_WILLINGNESS 1 /* 1:= agent may delegate a client's request
+ for a connection to another "more willing"
+ agent */
+
+/* ---Predefined License Method Values--- */
+
+#define LICENSE_METHOD_PREFIX "_ADOBE_DPS_NX_LICENSE_LOCK_&_KEY_"
+#define LICENSE_METHOD_OPEN "_ADOBE_DPS_NX_LICENSE_OPEN_SERVICE"
+#define OPEN_LICENSE_VERSION 1
+
+#include <stddef.h>
+
+
+/* ---Types--- */
+
+typedef struct {
+ int transport;
+ int port;
+} TransportInfo;
+
+
+#endif /* DPSNXPROPS_H */
diff --git a/nx-X11/lib/dps/dpsXclient.c b/nx-X11/lib/dps/dpsXclient.c
new file mode 100644
index 000000000..212030ecc
--- /dev/null
+++ b/nx-X11/lib/dps/dpsXclient.c
@@ -0,0 +1,1134 @@
+/*
+ * dpsXclient.c -- Implementation of the Display PostScript Client Library.
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+#include <stdlib.h>
+#include <unistd.h> /* sleep() */
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#ifdef VMS
+/* Xlib does not like UNIX defined to any value under VMS. */
+#undef UNIX
+#include <decw$include/X.h>
+#include <decw$include/Xlib.h>
+
+#else /* VMS */
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#endif /* VMS */
+
+#include "DPS/XDPSlib.h"
+#include "DPS/XDPS.h"
+
+#include "publictypes.h"
+#include "DPS/dpsclient.h"
+#include "dpsprivate.h"
+
+#include "dpsXpriv.h"
+#include "DPS/dpsXclient.h"
+
+#include "dpsdict.h"
+#include "DPS/dpsexcept.h"
+
+#include "dpsXint.h"
+
+static DPSPrivContext FindPrivContext (
+ Display * dpy,
+ long int cid)
+{
+ DPSPrivSpace ss;
+ DPSPrivContext cc;
+
+ for (ss = spaces; ss != NIL; ss = ss->next)
+ for (cc = ss->firstContext; cc != NIL; cc = cc->next)
+ if (cc->cid == cid && ((XDPSPrivContext) cc->wh)->dpy == dpy)
+ return (cc);
+ return (NIL);
+}
+
+DPSContext XDPSFindContext (
+ Display * dpy,
+ int cid)
+{
+ return ((DPSContext) FindPrivContext (dpy, cid));
+}
+
+DPSContext DPSContextFromContextID(
+ DPSContext ctxt,
+ int contextID,
+ DPSTextProc textProc,
+ DPSErrorProc errorProc)
+{
+ DPSPrivSpace ss;
+ Display *dpy = ((XDPSPrivContext) ((DPSPrivContext) ctxt)->wh)->dpy;
+ DPSPrivContext c, cc = FindPrivContext (dpy, contextID);
+ DPSPrivContext oldc = (DPSPrivContext)ctxt;
+
+ if (cc != NIL) return (DPSContext)cc;
+
+ c = (DPSPrivContext)DPScalloc(sizeof(DPSPrivContextRec), 1);
+ if (!c) return NIL;
+ *c = *oldc;
+ ss = (DPSPrivSpace)c->space;
+
+ if (textProc) c->textProc = textProc;
+ if (errorProc) c->errorProc = errorProc;
+
+ c->eofReceived = false;
+ c->cid = contextID;
+ c->buf = c->outBuf = c->objBuf = NIL;
+ c->chainParent = c->chainChild = NIL;
+
+ c->nBufChars = c->nOutBufChars = c->nObjBufChars = 0;
+
+ c->next = ss->firstContext;
+ DPSAssert(c->next != c);
+ ss->firstContext = c;
+
+ /* Note: there's no way to determine whether the new context id was obtained
+ ** as a result of a fork operation or from another application. so, it must
+ ** be assumed that the application is the creator of the new context.
+ ** Otherwise, it would have called the XDPSContextFromSharedID.
+ */
+ c->creator = true;
+ c->zombie = false;
+ c->numstringOffsets = NULL;
+
+ DPSIncludePrivContext(
+ (XDPSPrivContext) c->wh, (DPSContext)c, c->cid, ss->sid, DPSclientPrintProc);
+
+ return (DPSContext)c;
+}
+
+boolean DPSPrivateCheckWait(
+ DPSContext ctxt)
+{
+ DPSPrivContext cc = (DPSPrivContext) ctxt;
+
+ if (!cc->creator || cc->zombie) {
+ DPSSafeSetLastNameIndex(ctxt);
+ if (cc->errorProc != NIL) {
+ (*cc->errorProc) (ctxt, cc->zombie ? dps_err_deadContext :
+ dps_err_invalidAccess,
+ (unsigned long) ctxt, 0);
+ }
+ return true;
+ }
+ return false;
+}
+
+static void procFlushContext(
+ DPSContext ctxt)
+{
+ DPSPrivContext c = (DPSPrivContext) ctxt;
+ XDPSLFlush (((XDPSPrivContext) c->wh)->dpy);
+ if (ctxt->chainChild != NIL) DPSFlushContext(ctxt->chainChild);
+}
+
+/* ARGSUSED */
+static Bool FindDPSEvent(
+ Display *dpy,
+ XEvent *event,
+ char *arg)
+{
+ return XDPSIsDPSEvent(event);
+}
+
+static void procAwaitReturnValues(DPSContext ctxt)
+{
+ DPSPrivContext c = (DPSPrivContext)ctxt;
+
+ XDPSPrivContext xwh = (XDPSPrivContext) c->wh;
+ XEvent ev;
+
+ /* Output currently goes only to creator! */
+ if (!c->creator)
+ {
+ DPSSafeSetLastNameIndex(ctxt);
+ c->resultTable = NIL;
+ c->resultTableLength = 0;
+ if (c->errorProc != NIL)
+ (*c->errorProc) (ctxt, dps_err_invalidAccess, 0, 0);
+ return;
+ }
+ if (c->resultTable != NIL)
+ {
+ DPSCheckInitClientGlobals();
+
+ if (XDPSLGetWrapWaitingFlag(xwh->dpy)) {
+ DPSSafeSetLastNameIndex(ctxt);
+ c->resultTable = NIL;
+ c->resultTableLength = 0;
+ if (c->errorProc != NIL)
+ (*c->errorProc) (ctxt, dps_err_recursiveWait,
+ (unsigned long) xwh->dpy, 0);
+ return;
+ }
+ XDPSLSetWrapWaitingFlag(xwh->dpy, True);
+
+ DURING
+ DPSFlushContext(ctxt);
+ while (c->resultTable != NIL)
+ {
+ /* We may block indefinitely if the context is frozen or it
+ somehow needs more input. */
+ if (c->zombie)
+ {
+ DPSSafeSetLastNameIndex(ctxt);
+ c->resultTable = NIL;
+ c->resultTableLength = 0;
+ if (c->errorProc != NIL)
+ (*c->errorProc) (ctxt, dps_err_deadContext, (unsigned long) c, 0);
+ XDPSLSetWrapWaitingFlag(xwh->dpy, False);
+ E_RTRN_VOID;
+ }
+
+ /* Someone could conceivably change the event delivery mode in the
+ middle of this...best to check every time */
+
+ if (XDPSLGetPassEventsFlag(xwh->dpy)) {
+ XIfEvent(xwh->dpy, &ev, FindDPSEvent, (char *) NULL);
+ if (!XDPSDispatchEvent(&ev)) DPSCantHappen();
+ } else DPSSendPostScript((XDPSPrivContext) c->wh, DPSclientPrintProc,
+ c->cid, NIL, 0, NIL);
+ }
+ HANDLER
+ XDPSLSetWrapWaitingFlag(xwh->dpy, False);
+ RERAISE;
+ END_HANDLER
+
+ XDPSLSetWrapWaitingFlag(xwh->dpy, False);
+
+ }
+
+ /* update space's name map.
+ space->lastNameIndex is the highest index known to be known to the
+ server for this space.
+ c->lastNameIndex is the highest index sent so far to the context
+ */
+
+ if (((DPSPrivSpace)(c->space))->lastNameIndex < c->lastNameIndex)
+ ((DPSPrivSpace)(c->space))->lastNameIndex = c->lastNameIndex;
+}
+
+void DPSinnerProcWriteData(
+ DPSContext ctxt,
+ char *buf,
+ unsigned int count)
+{
+ DPSPrivContext c = (DPSPrivContext) ctxt;
+
+ /* ASSERT: safe to call with chain */
+
+ /* No local buffering */
+ DPSSendPostScript ((XDPSPrivContext) c->wh, DPSclientPrintProc,
+ c->cid, buf, count, NIL);
+} /* DPSinnerProcWriteData */
+
+static void procResetContext(DPSContext ctxt)
+{
+ DPSPrivContext c = (DPSPrivContext) ctxt;
+ int currStatus;
+ register XDPSPrivContext xwh = (XDPSPrivContext) c->wh;
+ int retries = 0;
+ int backoff = 2;
+
+ /* First make sure context isn't frozen, try to unfreeze. */
+
+#define DPS_SLEEP_SECS 2
+
+ while((currStatus = XDPSLGetStatus(xwh->dpy, xwh->cxid)) == PSFROZEN)
+ {
+ XDPSLNotifyContext(xwh->dpy, xwh->cxid, PSUNFREEZE);
+ sleep(DPS_SLEEP_SECS);
+ /* Okay if context is PSRUNNING, since the EOF will
+ be handled at the next PSNEEDSINPUT */
+ }
+
+ /* Remove events from Xlib Qs before sending the reset request. */
+ XDPSForceEvents (xwh->dpy);
+
+ if (currStatus == PSSTATUSERROR)
+ /* +++ report error? */;
+ else /* Didn't become zombie. */
+ {
+ currStatus = 0;
+ XDPSLReset(xwh->dpy, xwh->cxid);
+ XDPSLFlush(xwh->dpy);
+ /* Be optmistic for the first try. Assume the app set up a status mask
+ correctly, we should get a status event without asking the
+ server for status. */
+
+ XDPSForceEvents(xwh->dpy);
+ currStatus = c->statusFromEvent;
+
+ while (currStatus != PSNEEDSINPUT && currStatus != PSZOMBIE)
+ {
+ if (currStatus == PSFROZEN)
+ XDPSLNotifyContext(xwh->dpy, xwh->cxid, PSUNFREEZE);
+ if (retries > backoff)
+ {
+ /* Optimism failed. App probably didn't set up a status mask.
+ Ask the server for status. */
+ currStatus = XDPSLGetStatus(xwh->dpy, xwh->cxid);
+ retries = 0;
+ backoff = (backoff > 30) ? 2 : backoff + 1;
+ continue;
+ }
+ else
+ ++retries;
+ sleep(DPS_SLEEP_SECS);
+ XDPSForceEvents(xwh->dpy);
+ currStatus = c->statusFromEvent;
+ }
+ }
+
+ c->eofReceived = false;
+}
+
+void DPSPrivateDestroyContext(DPSContext ctxt)
+{
+ DPSPrivContext c = (DPSPrivContext)ctxt;
+ DPSPrivSpace s = (DPSPrivSpace) c->space;
+
+ if (c->creator)
+ DPSSendTerminate((XDPSPrivContext) c->wh, c->cid, DPSclientPrintProc);
+ else
+ XDPSSetStatusMask(ctxt, 0, XDPSL_ALL_EVENTS, 0); /* Stop status events */
+ /* Don't free the space's wh out from under it */
+ if (c->wh != s->wh) free(c->wh);
+}
+
+void DPSPrivateDestroySpace(DPSSpace space)
+{
+ DPSPrivSpace ss = (DPSPrivSpace) space;
+
+ if (ss->creator) DPSSendDestroySpace((XDPSPrivContext) ss->wh, ss->sid,
+ DPSclientPrintProc);
+
+ free (ss->wh);
+}
+
+boolean DPSCheckShared(DPSPrivContext ctxt)
+{
+ return ctxt->creator == false && ctxt->resultTable != NIL;
+ /* let procAwaitReturnValues generate error */
+}
+
+/* ARGSUSED */
+void DPSServicePostScript(boolean (*returnControl)(void))
+{
+} /* DPSServicePostScript */
+
+void DPSHandleBogusError(DPSContext ctxt, char *prefix, char *suffix)
+{
+ char *buf = "bogus error output from context";
+ DPSDefaultPrivateHandler(ctxt, dps_err_warning,
+ (long unsigned int)buf, 0, prefix, suffix);
+}
+
+void DPSDefaultPrivateHandler(
+ DPSContext ctxt,
+ DPSErrorCode errorCode,
+ long unsigned int arg1,
+ long unsigned int arg2,
+ char *prefix,
+ char *suffix)
+{
+
+ DPSTextProc textProc = DPSGetCurrentTextBackstop();
+
+ switch (errorCode) {
+ case dps_err_invalidAccess:
+ if (textProc != NIL)
+ {
+ char m[100];
+ (void) sprintf (m, "%sInvalid context access.%s", prefix, suffix);
+ (*textProc) (ctxt, m, strlen (m));
+ }
+ break;
+ case dps_err_encodingCheck:
+ if (textProc != NIL)
+ {
+ char m[100];
+ (void) sprintf (m, "%sInvalid name/program encoding: %d/%d.%s",
+ prefix, (int) arg1, (int) arg2, suffix);
+ (*textProc) (ctxt, m, strlen (m));
+ }
+ break;
+ case dps_err_closedDisplay:
+ if (textProc != NIL)
+ {
+ char m[100];
+ (void) sprintf (m, "%sBroken display connection %d.%s",
+ prefix, (int) arg1, suffix);
+ (*textProc) (ctxt, m, strlen (m));
+ }
+ break;
+ case dps_err_deadContext:
+ if (textProc != NIL)
+ {
+ char m[100];
+ (void) sprintf (m, "%sDead context 0x0%x.%s", prefix,
+ (int) arg1, suffix);
+ (*textProc) (ctxt, m, strlen (m));
+ }
+ break;
+ case dps_err_warning:
+ if (textProc != NIL)
+ {
+ char *warn = (char *)arg1;
+ char *msg = "%% DPS Client Library Warning:\n ";
+ (*textProc)(ctxt, msg, strlen(msg));
+ (*textProc)(ctxt, warn, strlen(warn));
+ msg = "\n";
+ (*textProc)(ctxt, msg, strlen(msg));
+ /* flush convention */
+ (*textProc)(ctxt, msg, 0);
+ }
+ break;
+ case dps_err_fatal:
+ if (textProc != NIL)
+ {
+ char *fatal = (char *)arg1;
+ char *msg = "%% DPS Client Library Fatal Internal Error:\n ";
+ (*textProc)(ctxt, msg, strlen(msg));
+ (*textProc)(ctxt, fatal, strlen(fatal));
+ msg = ".\nAborting ...\n";
+ (*textProc)(ctxt, msg, strlen(msg));
+ /* flush convention */
+ (*textProc)(ctxt, msg, 0);
+ abort();
+ }
+ break;
+ case dps_err_recursiveWait:
+ if (textProc != NIL)
+ {
+ char m[100];
+ (void) sprintf (m,
+ "%sRecursive wait for return values, display 0x%x.%s",
+ prefix, (int) arg1, suffix);
+ (*textProc) (ctxt, m, strlen (m));
+ }
+ break;
+ }
+}
+
+void DPSInitPrivateSpaceFields(DPSPrivSpace s)
+{
+ s->creator = true;
+}
+
+void DPSInitPrivateContextFields(DPSPrivContext c, DPSPrivSpace s)
+{
+ c->creator = true;
+ c->zombie = false;
+ if (!s->creator) {
+ c->procs = XDPSconvProcs;
+ c->nameEncoding = dps_strings;
+ }
+}
+
+void DPSInitPrivateTextContextFields(DPSPrivContext c, DPSPrivSpace s)
+{
+ c->creator = true;
+ c->zombie = false;
+ c->space = (DPSSpace) s;
+ c->next = s->firstContext;
+ s->firstContext = c;
+}
+
+long int DPSLastUserObjectIndex = 0;
+
+long int DPSNewUserObjectIndex (void)
+{
+ return (DPSLastUserObjectIndex++);
+}
+
+void XDPSSetProcs (void)
+{
+ DPSCheckInitClientGlobals ();
+ if (!textCtxProcs)
+ {
+ textCtxProcs = (DPSProcs) DPScalloc (sizeof (DPSProcsRec), 1);
+ DPSInitCommonTextContextProcs(textCtxProcs);
+ DPSInitSysNames();
+ }
+ if (!ctxProcs)
+ {
+ ctxProcs = (DPSProcs) DPScalloc (sizeof (DPSProcsRec), 1);
+ DPSInitCommonContextProcs(ctxProcs);
+ DPSInitPrivateContextProcs(ctxProcs);
+ }
+ if (!XDPSconvProcs)
+ XDPSconvProcs = (DPSProcs) DPScalloc (sizeof (DPSProcsRec), 1);
+ if (!XDPSrawProcs)
+ XDPSrawProcs = ctxProcs;
+ *XDPSconvProcs = *ctxProcs;
+ XDPSconvProcs->BinObjSeqWrite = textCtxProcs->BinObjSeqWrite;
+ XDPSconvProcs->WriteStringChars = textCtxProcs->WriteStringChars;
+ XDPSconvProcs->WritePostScript = textCtxProcs->WritePostScript;
+ XDPSconvProcs->WriteNumString = textCtxProcs->WriteNumString;
+}
+
+void DPSInitPrivateContextProcs(DPSProcs p)
+{
+ p->FlushContext = procFlushContext;
+ p->ResetContext = procResetContext;
+ p->AwaitReturnValues = procAwaitReturnValues;
+}
+
+DPSContext XDPSCreateSimpleContext (
+ Display *dpy,
+ Drawable draw,
+ GC gc,
+ int x,
+ int y,
+ DPSTextProc textProc,
+ DPSErrorProc errorProc,
+ DPSSpace space)
+{
+ XDPSPrivContext xwh = XDPSCreatePrivContextRec (dpy, draw, gc, x, y,
+ 0, DefaultStdCMap,
+ DefaultStdCMap, 0, false);
+ DPSContext newCtxt;
+
+ if (xwh == NIL)
+ return (NIL);
+ else
+ {
+ newCtxt = DPSCreateContext ((char *) xwh, textProc, errorProc, space);
+ if (newCtxt == NIL)
+ free ((char *) xwh);
+ return (newCtxt);
+ }
+}
+
+
+DPSContext XDPSCreateContext (
+ Display *dpy,
+ Drawable draw,
+ GC gc,
+ int x,
+ int y,
+ unsigned int eventmask,
+ XStandardColormap *grayramp,
+ XStandardColormap *ccube,
+ int actual,
+ DPSTextProc textProc,
+ DPSErrorProc errorProc,
+ DPSSpace space)
+{
+ XDPSPrivContext xwh = XDPSCreatePrivContextRec (dpy, draw, gc, x, y,
+ eventmask, grayramp,
+ ccube, actual, false);
+ DPSContext newCtxt;
+
+ if (xwh == NIL)
+ return (NIL);
+ else
+ {
+ newCtxt = DPSCreateContext ((char *) xwh, textProc, errorProc, space);
+ if (newCtxt == NIL)
+ free ((char *) xwh);
+ return (newCtxt);
+ }
+}
+
+DPSContext XDPSCreateSecureContext (
+ Display *dpy,
+ Drawable draw,
+ GC gc,
+ int x,
+ int y,
+ unsigned int eventmask,
+ XStandardColormap *grayramp,
+ XStandardColormap *ccube,
+ int actual,
+ DPSTextProc textProc,
+ DPSErrorProc errorProc,
+ DPSSpace space)
+{
+ XDPSPrivContext xwh = XDPSCreatePrivContextRec (dpy, draw, gc, x, y,
+ eventmask, grayramp,
+ ccube, actual, true);
+ DPSContext newCtxt;
+
+ if (xwh == NIL)
+ return (NIL);
+ else
+ {
+ newCtxt = DPSCreateContext ((char *) xwh, textProc, errorProc, space);
+ if (newCtxt == NIL)
+ free ((char *) xwh);
+ return (newCtxt);
+ }
+}
+
+
+DPSContext XDPSContextFromSharedID (dpy, cid, textProc, errorProc)
+ Display *dpy;
+ ContextPSID cid;
+ DPSTextProc textProc;
+ DPSErrorProc errorProc;
+{
+ DPSPrivContext c;
+ DPSPrivSpace s;
+ ContextXID cxid;
+ SpaceXID sxid;
+ XDPSPrivContext xwh;
+
+ if (DPSInitialize () != 0)
+ return (NIL);
+
+ c = FindPrivContext (dpy, cid);
+ if (c != NIL)
+ return ((DPSContext) c);
+
+ xwh = XDPSCreatePrivContextRec (dpy, 0, 0, 0, 0, 0, NIL, NIL, 0, false);
+ if (xwh == NIL)
+ return (NIL);
+ else if (XDPSLIDFromContext (dpy, cid, &cxid, &sxid) != 1)
+ {
+ free ((char *) xwh);
+ return (NIL);
+ }
+ xwh->cxid = cxid;
+
+ if (spaceProcs == NIL)
+ {
+ spaceProcs = (DPSSpaceProcs) DPScalloc (sizeof (DPSSpaceProcsRec), 1);
+ DPSInitCommonSpaceProcs(spaceProcs);
+ }
+
+ s = spaces;
+ while (s != NIL)
+ if ((SpaceXID)s->sid == sxid && ((XDPSPrivContext) s->wh)->dpy == dpy)
+ break;
+ else
+ s = s->next;
+
+ if (s == NIL) /* Create new space record. */
+ {
+ s = (DPSPrivSpace) DPScalloc (sizeof (DPSPrivSpaceRec), 1);
+ s->procs = spaceProcs;
+ s->lastNameIndex = -1;
+ s->sid = sxid;
+ s->wh = (char *) xwh;
+ s->creator = false;
+ s->next = spaces;
+ spaces = s;
+ }
+
+ c = (DPSPrivContext) DPScalloc (sizeof (DPSPrivContextRec), 1);
+ c->space = (DPSSpace) s;
+ c->procs = XDPSconvProcs;
+ c->textProc = textProc;
+ c->errorProc = errorProc;
+ c->programEncoding = DPSDefaultProgramEncoding;
+ c->nameEncoding = dps_strings;
+ c->next = s->firstContext;
+ s->firstContext = c;
+ c->lastNameIndex = s->lastNameIndex;
+ c->cid = cid;
+ c->numstringOffsets = NULL;
+ c->creator = false;
+ c->zombie = false;
+ c->numFormat = XDPSNumFormat (dpy);
+ c->wh = (char *) xwh;
+
+ xwh->ctxt = (DPSContext) c;
+
+ return ((DPSContext) c);
+}
+
+
+void DPSChangeEncoding (ctxt, newProgEncoding, newNameEncoding)
+ DPSContext ctxt;
+ DPSProgramEncoding newProgEncoding;
+ DPSNameEncoding newNameEncoding;
+{
+ if (ctxt->programEncoding != newProgEncoding ||
+ ctxt->nameEncoding != newNameEncoding)
+ {
+ DPSPrivContext cc = (DPSPrivContext) ctxt;
+ DPSPrivSpace ss = (DPSPrivSpace) (cc->space);
+
+ if ((!cc->creator || !ss->creator) && newNameEncoding != dps_strings)
+ {
+ DPSSafeSetLastNameIndex(ctxt);
+ if (cc->errorProc != NIL)
+ (*cc->errorProc) (ctxt, dps_err_encodingCheck,
+ (unsigned long) newNameEncoding,
+ (unsigned long) newProgEncoding);
+ return;
+ }
+ if (ctxt->procs == textCtxProcs)
+ {
+ ctxt->programEncoding = newProgEncoding;
+ ctxt->nameEncoding = newNameEncoding;
+ }
+ else
+ XDPSSetContextEncoding (ctxt, newProgEncoding, newNameEncoding);
+ }
+}
+
+
+DPSSpace XDPSSpaceFromSharedID (dpy, sid)
+ Display *dpy;
+ SpaceXID sid;
+{
+ DPSPrivSpace s;
+ XDPSPrivContext xwh;
+
+ if (DPSInitialize () != 0)
+ return (NIL);
+
+ if (spaceProcs == NIL)
+ {
+ spaceProcs = (DPSSpaceProcs) DPScalloc (sizeof (DPSSpaceProcsRec), 1);
+ DPSInitCommonSpaceProcs(spaceProcs);
+ }
+
+ s = spaces;
+ while (s != NIL)
+ if ((SpaceXID)s->sid == sid && ((XDPSPrivContext) s->wh)->dpy == dpy)
+ break;
+ else
+ s = s->next;
+
+ if (s == NIL) /* Create new space record. */
+ {
+ xwh = XDPSCreatePrivContextRec (dpy, 0, 0, 0, 0, 0, NIL, NIL, 0, false);
+ if (xwh == NIL)
+ return (NIL);
+
+ s = (DPSPrivSpace) DPScalloc (sizeof (DPSPrivSpaceRec), 1);
+ s->procs = spaceProcs;
+ s->lastNameIndex = -1;
+ s->sid = sid;
+ s->wh = (char *) xwh;
+ s->creator = false;
+ s->next = spaces;
+ spaces = s;
+ }
+
+ return ((DPSSpace) s);
+}
+
+
+void XDPSUnfreezeContext (ctxt)
+ DPSContext ctxt;
+{
+ XDPSPrivContext wh = (XDPSPrivContext) (((DPSPrivContext) ctxt)->wh);
+
+ if (wh != NIL && wh->cxid != 0)
+ XDPSSendUnfreeze (wh->dpy, wh->cxid);
+}
+
+
+ContextXID XDPSXIDFromContext (Pdpy, ctxt)
+ Display **Pdpy;
+ DPSContext ctxt;
+{
+ XDPSPrivContext xwh = (XDPSPrivContext) (((DPSPrivContext) ctxt)->wh);
+
+ if (xwh == NIL || xwh->cxid == 0)
+ {
+ *Pdpy = NULL;
+ return (0);
+ }
+ else
+ {
+ *Pdpy = xwh->dpy;
+ return (xwh->cxid);
+ }
+}
+
+
+SpaceXID XDPSXIDFromSpace (Pdpy, space)
+ Display **Pdpy;
+ DPSSpace space;
+{
+ DPSPrivSpace ss = (DPSPrivSpace) space;
+ XDPSPrivContext xwh = (XDPSPrivContext) ss->wh;
+
+ if (xwh != NIL && xwh->dpy != NULL)
+ {
+ *Pdpy = xwh->dpy;
+ return (ss->sid);
+ }
+ else
+ {
+ *Pdpy = NULL;
+ return (0);
+ }
+}
+
+
+DPSContext XDPSContextFromXID (dpy, cxid)
+ Display *dpy;
+ ContextXID cxid;
+{
+ DPSPrivContext c;
+ DPSPrivSpace ss;
+
+ for (ss = spaces; ss != NIL; ss = ss->next)
+ if (((XDPSPrivContext) ss->wh)->dpy == dpy)
+ for (c = ss->firstContext; c != NIL; c = c->next)
+ if (((XDPSPrivContext) c->wh)->cxid == cxid)
+ return ((DPSContext) c);
+
+ return (NIL);
+}
+
+
+DPSSpace XDPSSpaceFromXID (dpy, sxid)
+ Display *dpy;
+ SpaceXID sxid;
+{
+ DPSPrivSpace ss;
+
+ for (ss = spaces; ss != NIL; ss = ss->next)
+ if ((SpaceXID)ss->sid == sxid && ((XDPSPrivContext) ss->wh)->dpy == dpy)
+ return ((DPSSpace) ss);
+
+ return (NIL);
+}
+
+
+XDPSStatusProc XDPSRegisterStatusProc (ctxt, statusProc)
+ DPSContext ctxt;
+ XDPSStatusProc statusProc;
+{
+ DPSPrivContext c = (DPSPrivContext) ctxt;
+ XDPSStatusProc old = c->statusProc;
+
+ if (c->wh != NIL) c->statusProc = statusProc;
+ return old;
+}
+
+
+XDPSReadyProc XDPSRegisterReadyProc (ctxt, readyProc)
+ DPSContext ctxt;
+ XDPSReadyProc readyProc;
+{
+ DPSPrivContext c = (DPSPrivContext) ctxt;
+ XDPSReadyProc old = c->readyProc;
+
+ if (c->wh != NIL) c->readyProc = readyProc;
+ return old;
+}
+
+
+void XDPSSetStatusMask(ctxt, enableMask, disableMask, nextMask)
+ DPSContext ctxt;
+ unsigned long enableMask, disableMask, nextMask;
+{
+ XDPSPrivContext xwh = (XDPSPrivContext) (((DPSPrivContext) ctxt)->wh);
+
+ if (xwh != NIL && xwh->cxid != 0)
+ XDPSLSetStatusMask(xwh->dpy, xwh->cxid, enableMask, disableMask, nextMask);
+}
+
+
+int XDPSGetContextStatus(ctxt)
+ DPSContext ctxt;
+{
+ DPSPrivContext c = (DPSPrivContext) ctxt;
+ XDPSPrivContext xwh = (XDPSPrivContext) c->wh;
+
+ if (xwh != NIL && xwh->cxid != 0)
+ return (XDPSLGetStatus(xwh->dpy, xwh->cxid));
+ else
+ return (0);
+}
+
+void XDPSNotifyWhenReady(ctxt, i0, i1, i2, i3)
+ DPSContext ctxt;
+ int i0, i1, i2, i3;
+{
+ DPSPrivContext c = (DPSPrivContext) ctxt;
+ XDPSPrivContext xwh = (XDPSPrivContext) c->wh;
+ int i[4];
+
+ i[0] = i0;
+ i[1] = i1;
+ i[2] = i2;
+ i[3] = i3;
+
+ XDPSLNotifyWhenReady(xwh->dpy, xwh->cxid, i);
+}
+
+void XDPSStatusEventHandler (e)
+ XDPSLStatusEvent *e;
+{
+ DPSPrivContext c = (DPSPrivContext) XDPSContextFromXID(e->display, e->cxid);
+
+ if (c == NIL)
+ return;
+
+ c->statusFromEvent = e->status;
+ if (e->status == PSZOMBIE)
+ {
+ c->zombie = true;
+ if (c->resultTable != NIL) /* Currently waiting for results */
+ XDPSQuitBlocking = true;
+ }
+
+ if (c->statusProc != NIL)
+ (*(c->statusProc)) ((DPSContext) c, e->status);
+}
+
+void XDPSReadyEventHandler (e)
+ XDPSLReadyEvent *e;
+{
+ DPSPrivContext c = (DPSPrivContext) XDPSContextFromXID(e->display, e->cxid);
+
+ if (c == NIL)
+ return;
+
+ if (c->readyProc != NIL)
+ (*(c->readyProc)) ((DPSContext) c, e->val);
+}
+
+
+
+void DPSWarnProc(
+ DPSContext ctxt,
+ char *msg)
+{
+ DPSErrorProc ep;
+
+ if (DPSInitialize() != 0) return;
+ ep = DPSGetCurrentErrorBackstop();
+ if (ep == NULL) ep = DPSDefaultErrorProc;
+ (*ep)(ctxt, dps_err_warning, (long unsigned int)msg, 0);
+}
+
+void DPSFatalProc(
+ DPSContext ctxt,
+ char *msg)
+{
+ DPSErrorProc ep;
+
+ if (DPSInitialize() != 0) return;
+ ep = DPSGetCurrentErrorBackstop();
+ if (ep == NULL) ep = DPSDefaultErrorProc;
+ (*ep)(ctxt, dps_err_fatal, (long unsigned int)msg, 0);
+}
+
+void DPSCantHappen(void)
+{
+ static int locked = 0;
+ char *msg = "assertion failure or DPSCantHappen";
+ if (locked > 0) abort();
+ ++locked;
+ DPSFatalProc((DPSContext)NULL, msg);
+ /* Fatal proc shouldn't return, but client can override and do anything. */
+ --locked;
+}
+
+
+/* Procedures for delayed event dispatching */
+
+DPSEventDelivery XDPSSetEventDelivery(
+ Display *dpy,
+ DPSEventDelivery newMode)
+{
+ Bool old = XDPSLGetPassEventsFlag(dpy);
+
+ switch (newMode) {
+ case dps_event_pass_through:
+ XDPSLSetPassEventsFlag(dpy, True);
+ break;
+ case dps_event_internal_dispatch:
+ XDPSLSetPassEventsFlag(dpy, False);
+ break;
+ default:
+ break;
+ }
+
+ if (old) return dps_event_pass_through;
+ else return dps_event_internal_dispatch;
+}
+
+Bool XDPSIsStatusEvent(
+ XEvent *event,
+ DPSContext *ctxt,
+ int *status)
+{
+ Display *d = event->xany.display;
+ XExtCodes *c = XDPSLGetCodes(d);
+ XDPSLStatusEvent *se = (XDPSLStatusEvent *) event;
+
+ if (c == NULL) return False; /* Not inited on that display;
+ must be False */
+
+ if (!c->first_event) /* Check CSDPS first */
+ {
+ if (XDPSLGetCSDPSFakeEventType(d, event) == csdps_status)
+ { /* Check CSDPS first */
+ XDPSLGetCSDPSStatus(d, event, (void **)ctxt, status);
+ return True;
+ }
+ else
+ return False;
+ }
+
+ if (event->type != c->first_event + PSEVENTSTATUS) return False;
+
+ if (ctxt != NULL) *ctxt = XDPSContextFromXID(d, se->cxid);
+ if (status != NULL) *status = se->status;
+ return True;
+}
+
+Bool XDPSIsOutputEvent(
+ XEvent *event)
+{
+ Display *d = event->xany.display;
+ XExtCodes *c = XDPSLGetCodes(d);
+ CSDPSFakeEventTypes t;
+
+ if (c == NULL) return False; /* Not inited on that display;
+ must be False */
+
+ if (!c->first_event) /* Check CSDPS first */
+ {
+ if ((t = XDPSLGetCSDPSFakeEventType(d, event)) == csdps_output
+ || t == csdps_output_with_len)
+ return True;
+ else
+ return False;
+ }
+
+ return event->type == c->first_event + PSEVENTOUTPUT;
+}
+
+Bool XDPSIsDPSEvent(
+ XEvent *event)
+{
+ Display *d = event->xany.display;
+ XExtCodes *c = XDPSLGetCodes(d);
+
+ if (c == NULL) return False; /* Not inited on that display;
+ must be False */
+
+ if (!c->first_event) /* Check CSDPS first */
+ {
+ if (XDPSLGetCSDPSFakeEventType(d, event) != csdps_not)
+ return True;
+ else
+ return False;
+ }
+
+ return event->type >= c->first_event &&
+ event->type < c->first_event + NPSEVENTS;
+}
+
+Bool XDPSDispatchEvent(
+ XEvent *event)
+{
+ Display *d = event->xany.display;
+ XExtCodes *c = XDPSLGetCodes(d);
+ CSDPSFakeEventTypes t;
+
+ if (c == NULL) return False; /* Not inited on that display;
+ must be False */
+
+ if (!c->first_event) /* Check CSDPS first */
+ {
+ if ((t = XDPSLGetCSDPSFakeEventType(d, event)) != csdps_not)
+ return(XDPSLDispatchCSDPSFakeEvent(d, event, t));
+ else
+ return False;
+ }
+
+ if (event->type == c->first_event + PSEVENTSTATUS) {
+ XDPSLCallStatusEventHandler(d, event);
+ } else if (event->type == c->first_event + PSEVENTOUTPUT) {
+ XDPSLCallOutputEventHandler(d, event);
+ } else if (event->type == c->first_event + PSEVENTREADY) {
+ XDPSLCallReadyEventHandler(d, event);
+ } else return False;
+ return True;
+}
+
+/* L2-DPS/PROTO 9 addition */
+Bool XDPSIsReadyEvent(
+ XEvent *event,
+ DPSContext *ctxt,
+ int *val)
+{
+ Display *d = event->xany.display;
+ XExtCodes *c = XDPSLGetCodes(d);
+ XDPSLReadyEvent *re = (XDPSLReadyEvent *) event;
+
+ if (c == NULL) return False; /* Not inited on that display;
+ must be False */
+
+ if (!c->first_event) /* Check CSDPS first */
+ {
+ if (XDPSLGetCSDPSFakeEventType(d, event) == csdps_ready)
+ {
+ XDPSLGetCSDPSReady(d, event, (void **)ctxt, val);
+ return True;
+ }
+ else
+ return False;
+ }
+
+ if (event->type != c->first_event + PSEVENTREADY) return False;
+
+ if (ctxt != NULL) *ctxt = XDPSContextFromXID(d, re->cxid);
+ if (val != NULL) {
+ val[0] = re->val[0];
+ val[1] = re->val[1];
+ val[2] = re->val[2];
+ val[4] = re->val[3];
+ }
+ return True;
+}
+
+int XDPSGetProtocolVersion(
+ Display *dpy)
+{
+ return XDPSLGetVersion(dpy);
+}
diff --git a/nx-X11/lib/dps/dpsXcmu.c b/nx-X11/lib/dps/dpsXcmu.c
new file mode 100644
index 000000000..502649d51
--- /dev/null
+++ b/nx-X11/lib/dps/dpsXcmu.c
@@ -0,0 +1,1602 @@
+/*
+ * dpsXcmu.c -- Simple color management/allocation utility
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Portions Copyright 1989 by the Massachusetts Institute of Technology
+ *
+ * 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 M.I.T. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. M.I.T. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
+ * 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.
+ *
+ * Author: Adobe Systems Incorporated and Donna Converse, MIT X Consortium
+ */
+/* $XFree86: xc/lib/dps/dpsXcmu.c,v 1.4 2000/09/26 15:56:59 tsi Exp $ */
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Xresource.h>
+#include <X11/Xos.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <pwd.h>
+
+#include "dpsassert.h"
+#include "cslibint.h"
+
+/* Defines for standard colormap routines */
+
+#define PrivSort qsort
+#include <stddef.h>
+
+static char redsName[] = "reds";
+static char greensName[] = "greens";
+static char bluesName[] = "blues";
+static char graysName[] = "grays";
+
+/* Database containing DPS default color cube values */
+
+typedef struct _dpyRec {
+ Display *dpy;
+ XrmDatabase db;
+ Atom XA_GRAY_DEFAULT_MAP;
+ struct _dpyRec *next;
+} DpyRec;
+
+static DpyRec *dpyRec = NULL;
+static DpyRec *curDpyRec;
+static DpyRec *FindDpyRec(Display *);
+
+typedef struct {
+ unsigned long *pixels;
+ int npixels;
+} PixelRec;
+
+static Bool AllocateColor(Display *, Colormap, XColor *);
+static Bool AllocateColormap(Display *, XStandardColormap *, XVisualInfo *, int *, PixelRec *, int *, int *, unsigned long);
+static Bool CheckCube(XColor *, XColor *, XStandardColormap *);
+static Bool CubicCube(XStandardColormap *);
+static Bool GetColorCubeFromProperty(Display *, XVisualInfo *, XStandardColormap *, XStandardColormap **, int *);
+static Bool GetGrayRampFromProperty(Display *, XVisualInfo *, XStandardColormap *, XStandardColormap **, int *);
+Status XDPSCreateStandardColormaps(Display *, Drawable, Visual *, int, int, int, int, XStandardColormap *, XStandardColormap *, Bool);
+static Status contiguous(unsigned long *, int, int *, unsigned long, int *, int *);
+static XVisualInfo *PickCorrectVisual(Display *, XVisualInfo *, int, Colormap);
+static int FindRampSize(XColor *, XColor *);
+static long NumColors(char *, char *, char *);
+static void AllocateColorCube(Display *, XVisualInfo *, XStandardColormap *, PixelRec *);
+static void AllocateGrayRamp(Display *, XVisualInfo *, XStandardColormap *, XStandardColormap *, PixelRec *);
+static void ColorValuesFromMask(unsigned long, unsigned long *, unsigned long *);
+static void CreateDefaultsDb(Display *);
+static void DefineProperty(Display *, XStandardColormap *, XVisualInfo *, XStandardColormap *, int, Atom);
+static void FindStaticColorCube(Display *, XVisualInfo *, XStandardColormap *);
+static void FindStaticGrayRamp(Display *, XVisualInfo *, XStandardColormap *, XStandardColormap *);
+static void GetDatabaseValues(Display *, XVisualInfo *, XStandardColormap *, XStandardColormap *);
+static void GetHomeDir(char *);
+static void SetRamp(XColor *, XColor *, int, int *, unsigned long *);
+static void ShrinkMapToFit(XStandardColormap *, int *, XVisualInfo *);
+static void UseGrayCorners(XStandardColormap *, XStandardColormap *);
+static void UseGrayDiagonal(XStandardColormap *, XStandardColormap *);
+
+#define SCALE 65535
+#undef ABS
+#define ABS(x) ((x) < 0 ? -(x) : (x))
+
+void XDPSGetDefaultColorMaps(
+ Display *dpy,
+ Screen *screen,
+ Drawable drawable,
+ XStandardColormap *colorCube,
+ XStandardColormap *grayRamp)
+{
+ Window root;
+ Visual *visual;
+ XStandardColormap g;
+
+ /* If there is a screen specified, use it; otherwise use the drawable */
+
+ if (screen == NULL) {
+ if (drawable == None || ScreenCount(dpy) == 1) {
+ root = DefaultRootWindow(dpy);
+ screen = DefaultScreenOfDisplay(dpy);
+ } else {
+ /* Have to get the root for this drawable */
+ int x, y;
+ int i;
+ unsigned int width, height, bwidth, depth;
+ if (!XGetGeometry(dpy, drawable, &root, &x, &y, &width, &height,
+ &bwidth, &depth)) root = DefaultRootWindow(dpy);
+ for (i = 0;
+ i < ScreenCount(dpy) && root != RootWindow(dpy, i);
+ i++) {}
+ screen = ScreenOfDisplay(dpy, i);
+ }
+ } else root = RootWindowOfScreen(screen);
+
+ if (grayRamp == NULL) grayRamp = &g;
+
+ visual = DefaultVisualOfScreen(screen);
+ grayRamp->colormap = DefaultColormapOfScreen(screen);
+ if (colorCube != NULL) colorCube->colormap = grayRamp->colormap;
+
+ (void) XDPSCreateStandardColormaps(dpy, root, visual,
+ 0, 0, 0, 0, colorCube, grayRamp, True);
+}
+
+Status XDPSCreateStandardColormaps(
+ Display *dpy,
+ Drawable drawable,
+ Visual *visual,
+ int reds, int greens, int blues, int grays,
+ XStandardColormap *colorCube,
+ XStandardColormap *grayRamp,
+ Bool retain)
+{
+ XVisualInfo vtemp, *vinfo;
+ int nvis;
+ XStandardColormap *propCube = NULL, *propRamp = NULL;
+ int nPropCube = 0, nPropRamp = 0;
+ Bool gotCube = False, gotRamp;
+ PixelRec pixels;
+
+ if (grayRamp == NULL) return 0;
+ if (colorCube != NULL &&
+ colorCube->colormap != grayRamp->colormap) return 0;
+
+ if (dpy == NULL || (drawable == None && visual == NULL)) return 0;
+
+ if (visual == NULL) {
+ XWindowAttributes attr;
+ if (XGetWindowAttributes(dpy, drawable, &attr) == 0) return 0;
+ visual = attr.visual;
+ }
+
+ if (grayRamp->colormap == None && drawable == None) return 0;
+
+ curDpyRec = FindDpyRec(dpy);
+ if (curDpyRec == NULL) return 0;
+
+ vtemp.visualid = XVisualIDFromVisual(visual);
+ vinfo = XGetVisualInfo(dpy, VisualIDMask, &vtemp, &nvis);
+ if (nvis == 0) return 0;
+
+ if (nvis > 1) {
+ vinfo = PickCorrectVisual(dpy, vinfo, nvis, grayRamp->colormap);
+ }
+ if (vinfo == NULL) return 0;
+
+ if (grays <= 1) grayRamp->red_max = 0;
+ else grayRamp->red_max = grays - 1;
+
+ if (colorCube != NULL) {
+ if (reds <= 1) colorCube->red_max = 0;
+ else colorCube->red_max = reds - 1;
+ if (greens <= 1) colorCube->green_max = 0;
+ else colorCube->green_max = greens - 1;
+ if (blues <= 1) colorCube->blue_max = 0;
+ else colorCube->blue_max = blues - 1;
+ }
+
+ if ((vinfo->class == StaticGray || vinfo->class == GrayScale) &&
+ colorCube != NULL) {
+ /* Can't do a color cube in a gray visual! */
+ colorCube->red_max = colorCube->green_max = colorCube->blue_max =
+ colorCube->red_mult = colorCube->green_mult = colorCube->blue_mult =
+ colorCube->base_pixel = 0;
+ colorCube = NULL;
+ }
+
+ if (retain) {
+ Display *newDpy = XOpenDisplay(XDisplayString(dpy));
+ if (newDpy == NULL) retain = False;
+ else dpy = newDpy;
+ XGrabServer(dpy);
+ }
+
+ if (grayRamp->colormap == None) {
+ grayRamp->colormap = XCreateColormap(dpy, drawable, vinfo->visual,
+ AllocNone);
+ if (colorCube != NULL) colorCube->colormap = grayRamp->colormap;
+ }
+
+ if (colorCube != NULL) {
+ gotCube = GetColorCubeFromProperty(dpy, vinfo, colorCube,
+ &propCube, &nPropCube);
+ }
+ gotRamp = GetGrayRampFromProperty(dpy, vinfo, grayRamp,
+ &propRamp, &nPropRamp);
+
+ if (!gotRamp || (colorCube != NULL && !gotCube)) {
+ /* Couldn't find at least one thing we wanted, so let's look in the
+ database */
+
+ GetDatabaseValues(dpy, vinfo, colorCube, grayRamp);
+
+ pixels.pixels = NULL;
+ pixels.npixels = 0;
+
+ if (colorCube != NULL) {
+ if (colorCube->red_max != 0) {
+ AllocateColorCube(dpy, vinfo, colorCube, &pixels);
+ }
+ if (colorCube->red_max == 0) {
+ colorCube->green_max = colorCube->blue_max =
+ colorCube->red_mult = colorCube->green_mult =
+ colorCube->blue_mult = 0;
+ }
+ }
+
+ if (grayRamp->red_max != 0) {
+ AllocateGrayRamp(dpy, vinfo, grayRamp, colorCube, &pixels);
+ }
+
+ if (pixels.pixels != NULL) {
+ if (pixels.npixels != 0) {
+ XFreeColors(dpy, grayRamp->colormap,
+ pixels.pixels, pixels.npixels, 0);
+ }
+ free((char *) pixels.pixels);
+ }
+
+ if (retain) {
+ Pixmap p;
+
+ /* Create something to put in killid field so the entries can
+ be deleted sometime */
+ p = XCreatePixmap(dpy, RootWindow(dpy, vinfo->screen), 1, 1, 1);
+ if (colorCube != NULL && !gotCube && colorCube->red_max != 0) {
+ colorCube->visualid = vinfo->visualid;
+ colorCube->killid = p;
+ DefineProperty(dpy, colorCube, vinfo, propCube, nPropCube,
+ XA_RGB_DEFAULT_MAP);
+ }
+ if (!gotRamp && grayRamp->red_max != 0) {
+ grayRamp->visualid = vinfo->visualid;
+ grayRamp->killid = p;
+ DefineProperty(dpy, grayRamp, vinfo, propRamp, nPropRamp,
+ (vinfo->class == GrayScale ? XA_RGB_GRAY_MAP :
+ curDpyRec->XA_GRAY_DEFAULT_MAP));
+ }
+ XSetCloseDownMode(dpy, RetainTemporary);
+ }
+ }
+
+ if (grayRamp->red_max == 0) {
+ /* Use special magic values. If this is a default colormap,
+ the server recognizes a gray ramp with red_max=1, red_mult=1,
+ base_pixel=0 to mean a 2 gray ramp with BlackPixel being
+ the lowest intensity gray and WhitePixel being the highest
+ intensity gray. If it's not a default colormap, then the
+ server will either generate a BadValue error, or just happily
+ use pixel values 0 and 1; either is better than the alternative,
+ silently converting into a null device. */
+ grayRamp->red_max = 1;
+ grayRamp->red_mult = 1;
+ grayRamp->base_pixel = 0;
+ }
+
+ if (retain) {
+ XUngrabServer(dpy);
+ XCloseDisplay(dpy);
+ }
+ if (propCube != NULL) XFree((void *) propCube);
+ if (propRamp != NULL) XFree((void *) propRamp);
+ XFree((void *) vinfo);
+ return 1;
+}
+
+static DpyRec *FindDpyRec(Display *dpy)
+{
+ DpyRec *d;
+
+ for (d = dpyRec; d != NULL; d = d->next) {
+ if (d->dpy == dpy) return d;
+ }
+
+ d = (DpyRec *) malloc(sizeof(DpyRec));
+ if (d == NULL) return NULL;
+ d->XA_GRAY_DEFAULT_MAP = XInternAtom(dpy, "DEFAULT_GRAY", False);
+ d->db = NULL;
+ d->next = dpyRec;
+ dpyRec = d;
+ return d;
+}
+
+static XVisualInfo *PickCorrectVisual(
+ Display *dpy,
+ XVisualInfo *vlist,
+ int n,
+ Colormap cmap)
+{
+ register int i;
+ register int screen_number;
+ Bool def_cmap = False;
+
+ /* A visual id may be valid on multiple screens. Also, there may
+ * be multiple visuals with identical visual ids at different depths.
+ * If the colormap is the Default Colormap, use the Default Visual.
+ * Otherwise, arbitrarily, use the deepest visual.
+ */
+
+ for (screen_number = ScreenCount(dpy); --screen_number >= 0; /**/) {
+ if (cmap == DefaultColormap(dpy, screen_number)) {
+ def_cmap = True;
+ break;
+ }
+ }
+
+ if (def_cmap) {
+ for (i = 0; i < n; i++, vlist++) {
+ if (vlist->visual == DefaultVisual(dpy, screen_number)) {
+ return vlist;
+ }
+ }
+ return NULL; /* Visual does not match colormap */
+ } else {
+ int maxdepth = 0;
+ XVisualInfo *v = 0;
+
+ for (i = 0; i < n; i++, vlist++) {
+ if (vlist->depth > maxdepth) {
+ maxdepth = vlist->depth;
+ v = vlist;
+ }
+ }
+ return v;
+ }
+}
+
+/* Do some rudimentary checking of the properties to avoid obviously bad ones.
+ How did they get there, anyway? */
+
+static Bool ValidCube(
+ XStandardColormap *c,
+ XVisualInfo *vinfo)
+{
+ unsigned long max = 1 << vinfo->depth;
+ unsigned long pixel;
+
+ if (c->red_max < 1 || c->green_max < 1 || c->blue_max < 1) return False;
+ if (c->base_pixel > max) return False;
+ pixel = (c->red_max * c->red_mult + c->green_max * c->green_mult +
+ c->blue_max * c->blue_mult + c->base_pixel) & 0xFFFFFFFF;
+ if (pixel > max) return False;
+
+ return True;
+}
+
+static Bool ValidRamp(
+ XStandardColormap *c,
+ XVisualInfo *vinfo)
+{
+ unsigned long max = 1 << vinfo->depth;
+ unsigned long pixel;
+
+ if (c->red_max < 1) return False;
+ if (c->base_pixel > max) return False;
+ pixel = (c->red_max * c->red_mult + c->base_pixel) & 0xFFFFFFFF;
+ if (pixel > max) return False;
+
+ return True;
+}
+
+static Bool GetColorCubeFromProperty(
+ Display *dpy,
+ XVisualInfo *vinfo,
+ XStandardColormap *colorCube,
+ XStandardColormap **cube,
+ int *ncube)
+{
+ int gotCube;
+ int i;
+ register XStandardColormap *c;
+
+ gotCube = XGetRGBColormaps(dpy, RootWindow(dpy, vinfo->screen), cube,
+ ncube, XA_RGB_DEFAULT_MAP);
+
+ if (gotCube) {
+ /* Try to find a match with the visual */
+ c = *cube;
+ for (i = 0; i < *ncube; i++) {
+ if (c->colormap == colorCube->colormap &&
+ c->visualid == vinfo->visualid &&
+ ValidCube(c, vinfo)) {
+ colorCube->red_max = c->red_max;
+ colorCube->red_mult = c->red_mult;
+ colorCube->green_max = c->green_max;
+ colorCube->green_mult = c->green_mult;
+ colorCube->blue_max = c->blue_max;
+ colorCube->blue_mult = c->blue_mult;
+ colorCube->base_pixel = c->base_pixel;
+ colorCube->visualid = c->visualid;
+ colorCube->killid = c->killid;
+ break;
+ }
+ c++;
+ }
+ if (i == *ncube) gotCube = False;
+ }
+ return gotCube;
+}
+
+static Bool GetGrayRampFromProperty(
+ Display *dpy,
+ XVisualInfo *vinfo,
+ XStandardColormap *grayRamp,
+ XStandardColormap **ramp,
+ int *nramp)
+{
+ int gotRamp;
+ int i;
+ Atom grayAtom;
+ register XStandardColormap *c;
+
+ if (vinfo->class == GrayScale) grayAtom = XA_RGB_GRAY_MAP;
+ else grayAtom = curDpyRec->XA_GRAY_DEFAULT_MAP;
+
+ gotRamp = XGetRGBColormaps(dpy, RootWindow(dpy, vinfo->screen), ramp,
+ nramp, grayAtom);
+
+ if (gotRamp) {
+ /* Try to find a match with the visual */
+ c = *ramp;
+ for (i = 0; i < *nramp; i++) {
+ if (c->colormap == grayRamp->colormap &&
+ c->visualid == vinfo->visualid &&
+ ValidRamp(c, vinfo)) {
+ grayRamp->red_max = c->red_max;
+ grayRamp->red_mult = c->red_mult;
+ grayRamp->base_pixel = c->base_pixel;
+ grayRamp->visualid = c->visualid;
+ grayRamp->killid = c->killid;
+ break;
+ }
+ c++;
+ }
+ if (i == *nramp) gotRamp = False;
+ }
+ return gotRamp;
+}
+
+static void GetDatabaseValues(
+ Display *dpy,
+ XVisualInfo *vinfo,
+ XStandardColormap *colorCube,
+ XStandardColormap *grayRamp)
+{
+ char *class, *depth;
+ char namePrefix[40], classPrefix[40];
+ unsigned long max;
+ XStandardColormap fakeCube;
+
+ switch (vinfo->class) {
+ default:
+ case StaticGray: class = "StaticGray."; break;
+ case GrayScale: class = "GrayScale."; break;
+ case StaticColor: class = "StaticColor."; break;
+ case PseudoColor: class = "PseudoColor."; break;
+ case TrueColor: class = "TrueColor."; break;
+ case DirectColor: class = "DirectColor."; break;
+ }
+
+ if (vinfo->depth >= 24) depth = "24.";
+ else if (vinfo->depth >= 12) depth = "12.";
+ else if (vinfo->depth >= 8) depth = "8.";
+ else if (vinfo->depth >= 4) depth = "4.";
+ else if (vinfo->depth >= 2) depth = "2.";
+ else depth = "1.";
+
+ (void) strcpy(namePrefix, "dpsColorCube.");
+ (void) strcat(strcat(namePrefix, class), depth);
+ (void) strcpy(classPrefix, "DPSColorCube.");
+ (void) strcat(strcat(classPrefix, class), depth);
+
+ CreateDefaultsDb(dpy);
+
+ if (colorCube == NULL && vinfo->class == TrueColor) {
+ /* We'll need the color cube information to compute the gray ramp,
+ even if it wasn't asked for, so make colorCube point to a
+ temporary structure */
+ colorCube = &fakeCube;
+ }
+
+ if (colorCube != NULL) {
+ switch (vinfo->class) {
+ case StaticGray:
+ case GrayScale:
+ /* We can't do a color cube for these visuals */
+ break;
+
+ case TrueColor:
+ /* Rewrite whatever was there before with real values */
+ ColorValuesFromMask(vinfo->red_mask, &colorCube->red_max,
+ &colorCube->red_mult);
+ ColorValuesFromMask(vinfo->green_mask, &colorCube->green_max,
+ &colorCube->green_mult);
+ ColorValuesFromMask(vinfo->blue_mask, &colorCube->blue_max,
+ &colorCube->blue_mult);
+ colorCube->base_pixel = 0;
+ break;
+
+ case DirectColor:
+ /* Get the mults from the masks; ignore maxes */
+ ColorValuesFromMask(vinfo->red_mask, &max,
+ &colorCube->red_mult);
+ ColorValuesFromMask(vinfo->green_mask, &max,
+ &colorCube->green_mult);
+ ColorValuesFromMask(vinfo->blue_mask, &max,
+ &colorCube->blue_mult);
+ /* Get the maxes from the database */
+ if (colorCube->red_max == 0) {
+ colorCube->red_max =
+ NumColors(namePrefix, classPrefix, redsName) - 1;
+ }
+ if (colorCube->green_max == 0) {
+ colorCube->green_max =
+ NumColors(namePrefix, classPrefix, greensName) - 1;
+ }
+ if (colorCube->blue_max == 0) {
+ colorCube->blue_max =
+ NumColors(namePrefix, classPrefix, bluesName) - 1;
+ }
+ colorCube->base_pixel = 0;
+ break;
+
+ case PseudoColor:
+ if (colorCube->red_max == 0) {
+ colorCube->red_max =
+ NumColors(namePrefix, classPrefix, redsName) - 1;
+ }
+ if (colorCube->green_max == 0) {
+ colorCube->green_max =
+ NumColors(namePrefix, classPrefix, greensName) - 1;
+ }
+ if (colorCube->blue_max == 0) {
+ colorCube->blue_max =
+ NumColors(namePrefix, classPrefix, bluesName) - 1;
+ }
+ colorCube->red_mult = (colorCube->green_max + 1) *
+ (colorCube->blue_max + 1);
+ colorCube->green_mult = colorCube->blue_max + 1;
+ colorCube->blue_mult = 1;
+ break;
+
+ case StaticColor:
+ FindStaticColorCube(dpy, vinfo, colorCube);
+ break;
+ }
+ }
+
+ switch (vinfo->class) {
+ case GrayScale:
+ case PseudoColor:
+ case DirectColor:
+ if (grayRamp->red_max == 0) {
+ grayRamp->red_max =
+ NumColors(namePrefix, classPrefix, graysName) - 1;
+ }
+ grayRamp->red_mult = 1;
+ break;
+
+ case TrueColor:
+ /* If the color cube is truly a cube, use its diagonal. Otherwise
+ were SOL and have to use a two-element ramp. */
+ if (CubicCube(colorCube)) UseGrayDiagonal(colorCube, grayRamp);
+ else UseGrayCorners(colorCube, grayRamp);
+ break;
+
+ case StaticColor:
+ case StaticGray:
+ FindStaticGrayRamp(dpy, vinfo, grayRamp, colorCube);
+ break;
+ }
+}
+
+static Bool CubicCube(XStandardColormap *cube)
+{
+ return cube->red_max == cube->green_max && cube->red_max ==
+ cube->blue_max;
+}
+
+static void UseGrayDiagonal(XStandardColormap *cube, XStandardColormap *ramp)
+{
+ ramp->red_max = cube->red_max;
+ ramp->red_mult = cube->red_mult + cube->green_mult + cube->blue_mult;
+ ramp->base_pixel = cube->base_pixel;
+}
+
+static void UseGrayCorners(XStandardColormap *cube, XStandardColormap *ramp)
+{
+ ramp->red_max = 1;
+ ramp->red_mult = (cube->red_max + 1) * (cube->green_max + 1) *
+ (cube->blue_max + 1) - 1;
+ if (* (int *) &(cube->red_mult) < 0) ramp->red_mult *= -1;
+ ramp->base_pixel = cube->base_pixel;
+}
+
+static void ColorValuesFromMask(
+ unsigned long mask,
+ unsigned long *maxColor,
+ unsigned long *mult)
+{
+ *mult = 1;
+ while ((mask & 1) == 0) {
+ *mult <<= 1;
+ mask >>= 1;
+ }
+ *maxColor = mask;
+}
+
+/*
+Resource definitions for default color cube / gray ramp sizes
+are based on visual class and depth. Working from least choices
+to most, here's motivation for the defaults:
+
+If unspecified, default is 0 values for red, green, and blue,
+and 2 (black and white) for grays. This covers StaticGray, StaticColor,
+and depths less than 4 of the other visual classes.
+
+If we have a choice, we try to allocate a gray ramp with an odd number
+of colors; this is so 50% gray can be rendered without dithering.
+In general we don't want to allocate a large cube (even when many
+colormap entries are available) because allocation of each entry
+requires a round-trip to the server (entries allocated read-only
+via XAllocColor).
+
+For GrayScale, any depth less than 4 is treated as monochrome.
+
+PseudoColor depth 4 we try for a 2x2x2 cube with the gray ramp on
+the diagonal. Depth 8 uses a 4x4x4 cube with a separate 9 entry
+gray ramp. Depth 12 uses a 6x6x5 "cube" with a separate 17 entry gray
+ramp. The cube is non-symmetrical; we don't want to use the diagonal
+for a gray ramp and we can get by with fewer blues than reds or greens.
+
+For DirectColor, allocating a gray ramp separate from the color cube
+is wasteful of map entries, so we specify a symmetrical cube and
+share the diagonal entries for the gray ramp.
+
+For TrueColor, # color shades is set equal to the # shades / primary;
+we don't actually allocate map entries, but it's handy to be able to
+do the resource lookup blindly and get the right value.
+*/
+
+static char dpsDefaults[] = "\
+*reds: 0\n\
+*greens: 0\n\
+*blues: 0\n\
+*grays: 2\n\
+\
+*GrayScale.4.grays: 9\n\
+*GrayScale.8.grays: 17\n\
+\
+*PseudoColor.4.reds: 2\n\
+*PseudoColor.4.greens: 2\n\
+*PseudoColor.4.blues: 2\n\
+*PseudoColor.4.grays: 2\n\
+*PseudoColor.8.reds: 4\n\
+*PseudoColor.8.greens: 4\n\
+*PseudoColor.8.blues: 4\n\
+*PseudoColor.8.grays: 9\n\
+*PseudoColor.12.reds: 6\n\
+*PseudoColor.12.greens: 6\n\
+*PseudoColor.12.blues: 5\n\
+*PseudoColor.12.grays: 17\n\
+\
+*DirectColor.8.reds: 4\n\
+*DirectColor.8.greens: 4\n\
+*DirectColor.8.blues: 4\n\
+*DirectColor.8.grays: 4\n\
+*DirectColor.12.reds: 6\n\
+*DirectColor.12.greens: 6\n\
+*DirectColor.12.blues: 6\n\
+*DirectColor.12.grays: 6\n\
+*DirectColor.24.reds: 7\n\
+*DirectColor.24.greens: 7\n\
+*DirectColor.24.blues: 7\n\
+*DirectColor.24.grays: 7\n\
+\
+*TrueColor.12.reds: 16\n\
+*TrueColor.12.greens: 16\n\
+*TrueColor.12.blues: 16\n\
+*TrueColor.12.grays: 16\n\
+*TrueColor.24.reds: 256\n\
+*TrueColor.24.greens: 256\n\
+*TrueColor.24.blues: 256\n\
+*TrueColor.24.grays: 256\n\
+";
+
+static XrmDatabase defaultDB = NULL;
+
+static void CreateDefaultsDb(Display *dpy)
+{
+ char home[256], *dpyDefaults;
+
+ if (defaultDB == NULL) defaultDB = XrmGetStringDatabase(dpsDefaults);
+
+ if (curDpyRec->db != NULL) return;
+
+ dpyDefaults = XResourceManagerString(dpy);
+ if (dpyDefaults != NULL) {
+ curDpyRec->db = XrmGetStringDatabase(dpyDefaults);
+ }
+
+ if (curDpyRec->db == NULL) {
+ GetHomeDir(home);
+ strcpy(home, "/.Xdefaults");
+ curDpyRec->db = XrmGetFileDatabase(home);
+ }
+}
+
+static void GetHomeDir(char *buf)
+{
+#ifndef X_NOT_POSIX
+ uid_t uid;
+#else
+ int uid;
+ extern int getuid();
+#ifndef SYSV386
+ extern struct passwd *getpwuid(), *getpwnam();
+#endif
+#endif
+ struct passwd *pw;
+ static char *ptr = NULL;
+
+ if (ptr == NULL) {
+ if (!(ptr = getenv("HOME"))) {
+ if ((ptr = getenv("USER")) != 0) pw = getpwnam(ptr);
+ else {
+ uid = getuid();
+ pw = getpwuid(uid);
+ }
+ if (pw) ptr = pw->pw_dir;
+ else {
+ ptr = NULL;
+ *buf = '\0';
+ }
+ }
+ }
+
+ if (ptr)
+ (void) strcpy(buf, ptr);
+
+ buf += strlen(buf);
+ *buf = '/';
+ buf++;
+ *buf = '\0';
+ return;
+}
+
+static long NumColors(char *namePrefix, char *classPrefix, char *color)
+{
+ char name[40], class[40];
+ XrmValue rtnValue;
+ char *rtnType;
+ long value;
+
+ (void) strcpy(name, namePrefix);
+ (void) strcpy(class, classPrefix);
+ if (! XrmGetResource(curDpyRec->db, strcat(name, color),
+ strcat(class, color), &rtnType, &rtnValue)) {
+ if (! XrmGetResource(defaultDB, name, class, &rtnType, &rtnValue)) {
+ /* This should never happen, as our defaults cover all cases */
+ return 0;
+ }
+ }
+
+ /* Resource value is number of shades of specified color. If value
+ is not an integer, atoi returns 0, so we return 0. If value
+ is less than 2, it is invalid (need at least 2 shades of a color).
+ Explicitly setting 0 is ok for colors (means to not use a color
+ cube) but merits a warning for gray. */
+
+ if (strcmp(rtnValue.addr, "0") == 0 && strcmp(color, "grays") != 0) {
+ return 0;
+ }
+
+ value = atol(rtnValue.addr);
+ if (value < 2) {
+ char mbuf[512];
+ sprintf(mbuf, "%% Value '%s' is invalid for %s resource\n",
+ rtnValue.addr, name);
+ DPSWarnProc(NULL, mbuf);
+ }
+ return value;
+}
+
+/* Query the entire colormap in the static color case, then try to find
+ a color cube. Check pairs of black and white cells trying to find
+ a cube between them and take the first one you find. */
+
+static void FindStaticColorCube(
+ Display *dpy,
+ XVisualInfo *vinfo,
+ XStandardColormap *colorCube)
+{
+ XColor *ramp, *black, *white, *altBlack, *altWhite;
+ int i, entries;
+
+ entries = 1 << vinfo->depth;
+ ramp = (XColor *) calloc(entries, sizeof(XColor));
+
+ if (ramp == NULL) {
+ colorCube->red_max = 0;
+ return;
+ }
+
+ /* Query the colormap */
+ for (i = 0; i < entries; i++) ramp[i].pixel = i;
+ XQueryColors(dpy, colorCube->colormap, ramp, entries);
+
+ /* Find the white and black entries */
+
+ black = white = altBlack = altWhite = NULL;
+ for (i = 0; i < entries; i++) {
+ if (ramp[i].flags != (DoRed | DoBlue | DoGreen)) continue;
+ if (ramp[i].red == 0 && ramp[i].blue == 0 &&
+ ramp[i].green == 0) {
+ if (black == NULL) black = ramp+i;
+ else if (altBlack == NULL) altBlack = ramp+i;
+ } else if (ramp[i].red == SCALE && ramp[i].blue == SCALE &&
+ ramp[i].green == SCALE) {
+ if (white == NULL) white = ramp+i;
+ else if (altWhite == NULL) altWhite = ramp+i;
+ }
+ }
+
+ if (black == NULL || white == NULL) {
+ colorCube->red_max = 0;
+ free(ramp);
+ return;
+ }
+
+ /* Look for cubes between pairs of black & white */
+ if (!CheckCube(black, white, colorCube) &&
+ !CheckCube(altBlack, white, colorCube) &&
+ !CheckCube(black, altWhite, colorCube) &&
+ !CheckCube(altBlack, altWhite, colorCube)) {
+ colorCube->red_max = 0;
+ }
+
+ free(ramp);
+}
+
+#define R 1
+#define G 2
+#define B 4
+#define C 8
+#define M 16
+#define Y 32
+
+#define SMALLSCALE 255
+#define CheckColor(color,r,g,b) ((((color)->red >> 8) == (r) * SMALLSCALE) && \
+ (((color)->green >> 8) == (g) * SMALLSCALE) && \
+ (((color)->blue >> 8) == (b) * SMALLSCALE))
+
+static Bool CheckCube(
+ XColor *black,
+ XColor *white,
+ XStandardColormap *cube)
+{
+ int r = 0, g = 0, b = 0, c = 0, m = 0, y = 0, k, w;
+ XColor *color;
+ unsigned int found = 0;
+ int small, middle, large;
+ int smallMult, smallMax, middleMult, middleMax, largeMult, largeMax;
+ Bool backwards = False;
+ int mult = 1;
+ XStandardColormap test; /* Test cube */
+ int i;
+ int size;
+
+ if (black == NULL || white == NULL) return False;
+
+ k = black->pixel;
+ w = white->pixel - k;
+
+ size = ABS(w);
+ if (w < 0) {
+ backwards = True;
+ mult = -1;
+ }
+
+ for (i = 1; i < size; i++) {
+ color = black + i*mult;
+ if (color->flags != (DoRed | DoBlue | DoGreen)) return False;
+
+ /* If black or white is in the middle of the cube, can't work */
+ if (CheckColor(color, 0, 0, 0)) return False;
+ if (CheckColor(color, 1, 1, 1)) return False;
+
+ /* Check for red, green, blue, cyan, magenta, and yellow */
+ if (CheckColor(color, 1, 0, 0)) {r = color->pixel-k; found |= R;}
+ else if (CheckColor(color, 0, 1, 0)) {g = color->pixel-k; found |= G;}
+ else if (CheckColor(color, 0, 0, 1)) {b = color->pixel-k; found |= B;}
+ else if (CheckColor(color, 0, 1, 1)) {c = color->pixel-k; found |= C;}
+ else if (CheckColor(color, 1, 0, 1)) {m = color->pixel-k; found |= M;}
+ else if (CheckColor(color, 1, 1, 0)) {y = color->pixel-k; found |= Y;}
+ }
+
+ /* If any color is missing no cube is possible */
+ if (found != (R | G | B | C | M | Y)) return False;
+
+ /* Next test. Make sure B + G = C, R + B = M, R + G = Y,
+ and R + G + B = W */
+ if (b + g != c) return False;
+ if (r + b != m) return False;
+ if (r + g != y) return False;
+ if (r + g + b != w) return False;
+
+ /* Looking good! Compensate for backwards cubes */
+ if (backwards) {
+ w = ABS(w);
+ r = ABS(r);
+ g = ABS(g);
+ b = ABS(b);
+ }
+
+ /* Find the smallest, middle, and largest difference */
+ if (r < b && b < g) {
+ small = r; middle = b; large = g;
+ } else if (r < g && g < b) {
+ small = r; middle = g; large = b;
+ } else if (b < r && r < g) {
+ small = b; middle = r; large = g;
+ } else if (b < g && g < r) {
+ small = b; middle = g; large = r;
+ } else if (g < r && r < b) {
+ small = g; middle = r; large = b;
+ } else {
+ small = g; middle = b; large = r;
+ }
+
+ /* The smallest must divide the middle, and the middle the large */
+ if ((middle % (small + 1)) != 0) return False;
+ if ((large % (small + middle + 1)) != 0) return False;
+
+ /* OK, we believe we have a cube. Compute the description */
+ smallMult = 1;
+ smallMax = small;
+ middleMult = small + 1;
+ middleMax = middle / middleMult;
+ largeMult = small + middle + 1;
+ largeMax = large / largeMult;
+
+ if (small == r) {
+ test.red_max = smallMax; test.red_mult = smallMult;
+ if (middle == b) {
+ test.blue_max = middleMax; test.blue_mult = middleMult;
+ test.green_max = largeMax; test.green_mult = largeMult;
+ } else {
+ test.green_max = middleMax; test.green_mult = middleMult;
+ test.blue_max = largeMax; test.blue_mult = largeMult;
+ }
+ } else if (small == g) {
+ test.green_max = smallMax; test.green_mult = smallMult;
+ if (middle == b) {
+ test.blue_max = middleMax; test.blue_mult = middleMult;
+ test.red_max = largeMax; test.red_mult = largeMult;
+ } else {
+ test.red_max = middleMax; test.red_mult = middleMult;
+ test.blue_max = largeMax; test.blue_mult = largeMult;
+ }
+ } else { /* small == b */
+ test.blue_max = smallMax; test.blue_mult = smallMult;
+ if (middle == r) {
+ test.red_max = middleMax; test.red_mult = middleMult;
+ test.green_max = largeMax; test.green_mult = largeMult;
+ } else {
+ test.green_max = middleMax; test.green_mult = middleMult;
+ test.red_max = largeMax; test.red_mult = largeMult;
+ }
+ }
+
+ /* Re-compensate for backwards cube */
+ if (backwards) {
+ test.red_mult *= -1;
+ test.green_mult *= -1;
+ test.blue_mult *= -1;
+ }
+
+ /* Finally, test the hypothesis! The answer must be correct within 1
+ bit. Only look at the top 8 bits; the others are too noisy */
+
+ for (i = 1; i < size; i++) {
+#define calc(i, max, mult) ((((i / test.mult) % \
+ (test.max + 1)) * SCALE) / test.max)
+ r = ((unsigned short) calc(i, red_max, red_mult) >> 8) -
+ (black[i*mult].red >> 8);
+ g = ((unsigned short) calc(i, green_max, green_mult) >> 8) -
+ (black[i*mult].green >> 8);
+ b = ((unsigned short) calc(i, blue_max, blue_mult) >> 8) -
+ (black[i*mult].blue >> 8);
+#undef calc
+ if (ABS(r) > 2 || ABS(g) > 2 || ABS(b) > 2) return False;
+ }
+ cube->red_max = test.red_max;
+ cube->red_mult = test.red_mult;
+ cube->green_max = test.green_max;
+ cube->green_mult = test.green_mult;
+ cube->blue_max = test.blue_max;
+ cube->blue_mult = test.blue_mult;
+ cube->base_pixel = k;
+ return True;
+}
+
+#undef R
+#undef G
+#undef B
+#undef C
+#undef M
+#undef Y
+
+/* Query the entire colormap in the static gray case, then try to find
+ a gray ramp. This handles there being 2 white or black entries
+ in the colormap and finds the longest linear ramp between pairs of
+ white and black. If there is a color cube, also check its diagonal and
+ use its corners if we need to */
+
+static void FindStaticGrayRamp(
+ Display *dpy,
+ XVisualInfo *vinfo,
+ XStandardColormap *grayRamp,
+ XStandardColormap *colorCube)
+{
+ XColor *ramp, *black, *white, *altBlack, *altWhite;
+ int i, r0, r1, r2, r3, size, entries, redMult;
+ unsigned long base;
+
+ entries = 1 << vinfo->depth;
+ ramp = (XColor *) calloc(entries, sizeof(XColor));
+
+ if (ramp == NULL) {
+ grayRamp->red_max = 0;
+ return;
+ }
+
+ /* Query the colormap */
+ for (i = 0; i < entries; i++) ramp[i].pixel = i;
+ XQueryColors(dpy, grayRamp->colormap, ramp, entries);
+
+ /* Find the white and black entries */
+
+ black = white = altBlack = altWhite = NULL;
+ for (i = 0; i < entries; i++) {
+ if (ramp[i].flags != (DoRed | DoBlue | DoGreen)) continue;
+ if (CheckColor(ramp+i, 0, 0, 0)) {
+ if (black == NULL) black = ramp+i;
+ else if (altBlack == NULL) altBlack = ramp+i;
+ } else if (CheckColor(ramp+i, 1, 1, 1)) {
+ if (white == NULL) white = ramp+i;
+ else if (altWhite == NULL) altWhite = ramp+i;
+ }
+ }
+
+ if (black == NULL || white == NULL) {
+ grayRamp->red_max = 0;
+ free(ramp);
+ return;
+ }
+
+ /* Find out how large a ramp exists between pairs of black & white */
+ r0 = FindRampSize(black, white);
+ r1 = FindRampSize(altBlack, white);
+ r2 = FindRampSize(black, altWhite);
+ r3 = FindRampSize(altBlack, altWhite);
+
+ size = r0;
+ if (r1 > size) size = r1;
+ if (r2 > size) size = r2;
+ if (r3 > size) size = r3;
+ if (size == r0) SetRamp(black, white, size, &redMult, &base);
+ else if (size == r1) SetRamp(altBlack, white, size, &redMult, &base);
+ else if (size == r2) SetRamp(black, altWhite, size, &redMult, &base);
+ else if (size == r3) SetRamp(altBlack, altWhite, size, &redMult, &base);
+
+ if (colorCube != NULL && CubicCube(colorCube) &&
+ colorCube->red_max > size) {
+ UseGrayDiagonal(colorCube, grayRamp);
+ } else {
+ grayRamp->red_max = size;
+ grayRamp->red_mult = redMult;
+ grayRamp->base_pixel = base;
+ }
+
+ free(ramp);
+}
+
+static int FindRampSize(XColor *black, XColor *white)
+{
+ XColor *c;
+ int r;
+ int mult = 1;
+ int i, size;
+
+ if (black == NULL || white == NULL) return 0;
+ size = ABS(white - black);
+
+ /* See if we have a backwards ramp */
+ if (black > white) mult = -1;
+
+ /* See if all cells between black and white are linear, to within 1 bit.
+ Only look at the high order 8 bits */
+
+ for (i = 1; i < size; i++) {
+ c = &black[i*mult];
+ if (c->red != c->blue || c->red != c->green) return 1;
+ r = ((unsigned short) ((i * SCALE) / size) >> 8) - (c->red >> 8);
+ if (ABS(r) > 2) return 1;
+ }
+ return size;
+}
+
+static void SetRamp(
+ XColor *black,
+ XColor *white,
+ int size,
+ int *mult,
+ unsigned long *base)
+{
+ *base = black->pixel;
+ *mult = (white - black) / size;
+}
+
+#define lowbit(x) ((x) & (~(x) + 1))
+
+static unsigned long shiftdown(unsigned long x)
+{
+ while ((x & 1) == 00) {
+ x = x >> 1;
+ }
+ return x;
+}
+
+static void AllocateColorCube(
+ Display *dpy,
+ XVisualInfo *vinfo,
+ XStandardColormap *colorCube,
+ PixelRec *pixels)
+{
+ int count, first, remain, n, j;
+ unsigned long i;
+ Colormap cmap = colorCube->colormap;
+ unsigned long delta;
+ XColor color;
+
+ /* We do no allocation for TrueColor or StaticColor */
+ if (vinfo->class == TrueColor || vinfo->class == StaticColor) return;
+
+ if (vinfo->class == DirectColor) {
+ if ((i = shiftdown(vinfo->red_mask)) > colorCube->red_max)
+ colorCube->red_max = i;
+ if ((i = shiftdown(vinfo->green_mask)) > colorCube->green_max)
+ colorCube->green_max = i;
+ if ((i = shiftdown(vinfo->blue_mask)) > colorCube->blue_max)
+ colorCube->blue_max = i;
+
+ /* We only handle symmetric DirectColor */
+ count = colorCube->red_max + 1;
+ if (colorCube->blue_max + 1 < count) count = colorCube->blue_max + 1;
+ if (colorCube->green_max + 1 < count) count = colorCube->green_max + 1;
+ colorCube->red_max = colorCube->blue_max = colorCube->green_max =
+ count - 1;
+
+ delta = lowbit(vinfo->red_mask) + lowbit(vinfo->green_mask) +
+ lowbit(vinfo->blue_mask);
+ } else {
+ count = (colorCube->red_max + 1) * (colorCube->blue_max + 1) *
+ (colorCube->green_max + 1);
+ delta = 1;
+ }
+
+ colorCube->base_pixel = 0; /* temporary, may change */
+
+ pixels->pixels = (unsigned long *) calloc(vinfo->colormap_size,
+ sizeof(unsigned long));
+ if (pixels->pixels == NULL) {
+ colorCube->red_max = 0;
+ return;
+ }
+
+ if (!AllocateColormap(dpy, colorCube, vinfo, &count, pixels,
+ &first, &remain, delta)) {
+ free((char *) pixels->pixels);
+ pixels->pixels = NULL;
+ colorCube->red_max = 0;
+ return;
+ }
+
+ colorCube->base_pixel = pixels->pixels[first];
+ color.flags = DoRed | DoGreen | DoBlue;
+
+ /* Define colors */
+ for (n = 0, j = 0; j < count; ++j, n += delta) {
+ color.pixel = n + pixels->pixels[first];
+ if (vinfo->class == PseudoColor) {
+#define calc(i, max, mult) ((((i / colorCube->mult) % \
+ (colorCube->max + 1)) * SCALE) / colorCube->max)
+ color.red = (unsigned short) calc(n, red_max, red_mult);
+ color.green = (unsigned short) calc(n, green_max, green_mult);
+ color.blue = (unsigned short) calc(n, blue_max, blue_mult);
+#undef calc
+ } else {
+ color.red = color.green = color.blue =
+ (j * SCALE) / colorCube->red_max;
+ }
+ if (!AllocateColor(dpy, cmap, &color)) {
+ XFreeColors(dpy, cmap, pixels->pixels, count+first+remain, 0);
+ free((char *) pixels->pixels);
+ pixels->pixels = NULL;
+ colorCube->red_max = 0;
+ return;
+ }
+ }
+
+ /* Smush down unused pixels, if any */
+
+ for (j = 0; j < remain; j++) {
+ pixels->pixels[first+j] = pixels->pixels[first+count+j];
+ }
+ pixels->npixels -= count;
+}
+
+static void AllocateGrayRamp(
+ Display *dpy,
+ XVisualInfo *vinfo,
+ XStandardColormap *grayRamp,
+ XStandardColormap *colorCube,
+ PixelRec *pixels)
+{
+ int count, first, remain, n, i;
+ Colormap cmap = grayRamp->colormap;
+ XColor color;
+ unsigned long delta;
+
+ /* Allocate cells in read/write visuals only */
+ if (vinfo->class != PseudoColor && vinfo->class != GrayScale &&
+ vinfo->class != DirectColor) return;
+
+ if (vinfo->class == DirectColor) {
+ delta = lowbit(vinfo->red_mask) + lowbit(vinfo->green_mask) +
+ lowbit(vinfo->blue_mask);
+ } else delta = 1;
+
+ /* First of all see if there's a usable gray ramp in the color cube */
+
+ if (colorCube != NULL) {
+ if (CubicCube(colorCube)) {
+ if (colorCube->red_max >= grayRamp->red_max) {
+ /* diagonal is long enough! use it */
+ UseGrayDiagonal(colorCube, grayRamp);
+ return;
+ }
+ }
+ }
+
+ grayRamp->base_pixel = 0; /* temporary, may change */
+
+ count = grayRamp->red_max + 1;
+
+ if (pixels->pixels == NULL) {
+ pixels->pixels = (unsigned long *) calloc(vinfo->colormap_size,
+ sizeof(unsigned long));
+ if (pixels->pixels == NULL) {
+ grayRamp->red_max = 0;
+ return;
+ }
+ }
+
+ if (!AllocateColormap(dpy, grayRamp, vinfo, &count, pixels,
+ &first, &remain, delta)) {
+ /* Last gasp: try any diagonal or the corners of the color cube */
+ if (colorCube != NULL) {
+ if (CubicCube(colorCube)) UseGrayDiagonal(colorCube, grayRamp);
+ else UseGrayCorners(colorCube, grayRamp);
+ } else {
+ grayRamp->red_max = 0;
+ }
+ return;
+ }
+
+ grayRamp->base_pixel = pixels->pixels[first];
+ color.flags = DoRed | DoGreen | DoBlue;
+
+ /* Define colors */
+ for (n = 0, i = 0; i < count; ++i, n += delta) {
+ color.pixel = n + pixels->pixels[first];
+ color.red = (unsigned short)((n * SCALE) / (grayRamp->red_max));
+ color.green = color.red;
+ color.blue = color.red;
+
+ if (!AllocateColor(dpy, cmap, &color)) {
+ /* Don't need to free pixels here; we'll do it on return */
+ grayRamp->red_max = 0;
+ return;
+ }
+ }
+
+ /* Smush down unused pixels, if any */
+
+ for (i = 0; i < remain; i++) {
+ pixels->pixels[first+i] = pixels->pixels[first+count+i];
+ }
+ pixels->npixels -= count;
+}
+
+static int compare(const void *a1, const void *a2)
+{
+ register unsigned long *e1 = (unsigned long *) a1,
+ *e2 = (unsigned long *) a2;
+
+ if (*e1 < *e2) return -1;
+ if (*e1 > *e2) return 1;
+ return 0;
+}
+
+static Bool AllocateColormap(
+ Display *dpy,
+ XStandardColormap *map,
+ XVisualInfo *vinfo,
+ int *count,
+ PixelRec *pixels,
+ int *first, int *remain,
+ unsigned long delta)
+{
+ Colormap cmap = map->colormap;
+ int npixels, ok, i;
+ Bool success = False;
+
+ if (pixels->npixels == 0) {
+ /* First try to allocate the entire colormap */
+ npixels = vinfo->colormap_size;
+ ok = XAllocColorCells(dpy, cmap, 1, NULL, 0, pixels->pixels, npixels);
+ if (ok) success = True;
+ else {
+ int total;
+ int top, mid = 0;
+
+ /* If it's a gray ramp or direct color we need at least 2;
+ others 8 */
+ if (map->blue_max == 0 || vinfo->class == DirectColor) total = 2;
+ else total = 8;
+
+ /* Allocate all available cells, using binary backoff */
+ top = vinfo->colormap_size - 1;
+ while (total <= top) {
+ mid = total + ((top - total + 1) / 2);
+ ok = XAllocColorCells(dpy, cmap, 1, NULL, 0,
+ pixels->pixels, mid);
+ if (ok) {
+ if (mid == top) {
+ success = True;
+ break;
+ } else {
+ XFreeColors(dpy, cmap, pixels->pixels, mid, 0);
+ total = mid;
+ }
+ } else top = mid - 1;
+ }
+ if (success) npixels = mid;
+ else npixels = 0;
+ }
+ } else {
+ /* We must be in the gray ramp case, so we need at least 2 entries */
+ npixels = pixels->npixels;
+ if (map->blue_max != 0 || npixels >= 2) success = True;
+ }
+
+ if (success) {
+ /* Avoid pessimal case by testing to see if already sorted */
+ for (i = 0; i < npixels-1; ++i) {
+ if (pixels->pixels[i] != pixels->pixels[i+1]-1) break;
+ }
+
+ if (i < npixels-1) {
+ PrivSort((char *)pixels->pixels, npixels,
+ sizeof(unsigned long), compare);
+ }
+
+ if (!contiguous(pixels->pixels, npixels, count, delta,
+ first, remain)) {
+ /* If there are enough free cells, shrink the map to fit.
+ Otherwise fail; we'll free the pixels later */
+ if (((map->blue_max == 0 || vinfo->class == DirectColor) &&
+ *count >= 2) || *count >=8) {
+ ShrinkMapToFit(map, count, vinfo);
+ *remain = npixels - *first - *count;
+ } else success = False;
+ }
+ }
+
+ pixels->npixels = npixels;
+ return success;
+}
+
+static Bool contiguous(
+ unsigned long pixels[], /* specifies allocated pixels */
+ int npixels, /* specifies count of alloc'd pixels */
+ int *ncolors, /* specifies needed sequence length
+ If not available, returns max
+ available contiguous sequence */
+ unsigned long delta,
+ int *first, /* returns first index of sequence */
+ int *rem) /* returns first index after sequence,
+ * or 0, if none follow */
+{
+ register int i = 1; /* walking index into the pixel array */
+ register int count = 1; /* length of sequence discovered so far */
+ int max = 1; /* longest sequence we found */
+ int maxstart = 0;
+
+ *first = 0;
+ while (count < *ncolors && i < npixels) {
+ if (pixels[i-1] + delta == pixels[i]) count++;
+ else {
+ if (count > max) {
+ max = count;
+ maxstart = *first;
+ }
+ count = 1;
+ *first = i;
+ }
+ i++;
+ }
+ if (i == npixels && count > max) {
+ max = count;
+ maxstart = *first;
+ }
+ *rem = npixels - i;
+ if (count != *ncolors) {
+ *ncolors = max;
+ *first = maxstart;
+ return False;
+ } return True;
+}
+
+static Bool AllocateColor(
+ Display *dpy,
+ Colormap cmap,
+ XColor *color)
+{
+ unsigned long pix = color->pixel;
+ XColor request;
+ int ok;
+
+ request = *color;
+
+ /* Free RW, Alloc RO, if fails, try RW */
+ XFreeColors(dpy, cmap, &pix, 1, 0);
+ ok = XAllocColor(dpy, cmap, &request);
+
+ /* If the pixel we get back isn't the request one, probably RO
+ White or Black, so shove it in RW so our cube is correct.
+ If alloc fails, try RW. */
+
+ if (!ok || request.pixel != color->pixel) {
+ ok = XAllocColorCells(dpy, cmap, 0, NULL, 0, &pix, 1);
+
+ if (pix != color->pixel) XFreeColors(dpy, cmap, &pix, 1, 0);
+ if (!ok || pix != color->pixel) {
+ return False;
+ }
+ request = *color;
+ XStoreColor(dpy, cmap, &request);
+ }
+ return True;
+}
+
+static void ShrinkMapToFit(
+ XStandardColormap *map,
+ int *space,
+ XVisualInfo *vinfo)
+{
+ if (map->blue_max == 0) map->red_max = *space - 1;
+ else if (vinfo->class == DirectColor) {
+ if (map->red_max > *space - 1) map->red_max = *space - 1;
+ if (map->green_max > *space - 1) map->green_max = *space - 1;
+ if (map->blue_max > *space - 1) map->blue_max = *space - 1;
+ } else {
+ int which = 2;
+ while ((map->red_max + 1) * (map->green_max + 1) *
+ (map->blue_max + 1) > *space) {
+ if (which == 0) {
+ if (map->red_max > 1) map->red_max--;
+ which = 1;
+ } else if (which == 1) {
+ if (map->green_max > 1) map->green_max--;
+ which = 2;
+ } else {
+ if (map->blue_max > 1) map->blue_max--;
+ which = 0;
+ }
+ }
+ *space = (map->red_max + 1) * (map->green_max + 1) *
+ (map->blue_max + 1);
+
+ map->red_mult = (map->green_max + 1) * (map->blue_max + 1);
+ map->green_mult = map->blue_max + 1;
+ map->blue_mult = 1;
+ }
+}
+
+static void DefineProperty(
+ Display *dpy,
+ XStandardColormap *map,
+ XVisualInfo *vinfo,
+ XStandardColormap *prop,
+ int nProp,
+ Atom atom)
+{
+ XStandardColormap *copy;
+ int i;
+
+ if (nProp == 0) {
+ XSetRGBColormaps(dpy, RootWindow(dpy, vinfo->screen), map, 1, atom);
+ return;
+ }
+
+ copy = (XStandardColormap *) calloc(nProp+1, sizeof(XStandardColormap));
+
+ /* Hm. If I can't allocate the list, is it better to just put our
+ property on, or to leave the ones there? I'll guess the latter... */
+ if (copy == NULL) return;
+
+ if (vinfo->visual == DefaultVisual(dpy, vinfo->screen) &&
+ map->colormap == DefaultColormap(dpy, vinfo->screen)) {
+ /* Put new entry first; it's more likely to be useful */
+ for (i = 0; i < nProp; i++) copy[i+1] = prop[i];
+ i = 0;
+ } else {
+ /* Put it at the end */
+ for (i = 0; i < nProp; i++) copy[i] = prop[i];
+ /* i = nProp; (it does already) */
+ }
+
+ copy[i] = *map;
+ XSetRGBColormaps(dpy, RootWindow(dpy, vinfo->screen), copy, nProp+1, atom);
+
+ free((void *) copy);
+}
diff --git a/nx-X11/lib/dps/dpsXint.h b/nx-X11/lib/dps/dpsXint.h
new file mode 100644
index 000000000..08c4d233a
--- /dev/null
+++ b/nx-X11/lib/dps/dpsXint.h
@@ -0,0 +1,104 @@
+/*
+ * dpsXint.h -- internal definitions to dpsXclient.c
+ *
+ * (c) Copyright 1989-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#ifndef DPSXINT_H
+#define DPSXINT_H
+
+#include <X11/X.h>
+#include <DPS/dpsXclient.h>
+
+/* The first part of this structure is generic; the last part is
+ implementation-specific. */
+
+typedef struct _t_DPSPrivContextRec {
+ char *priv;
+ DPSSpace space;
+ DPSProgramEncoding programEncoding;
+ DPSNameEncoding nameEncoding;
+ DPSProcs procs;
+ DPSTextProc textProc;
+ DPSErrorProc errorProc;
+ DPSResults resultTable;
+ unsigned int resultTableLength;
+ struct _t_DPSContextRec *chainParent, *chainChild;
+ unsigned int contextFlags;
+ DPSContextExtensionRec *extension;
+
+ struct _t_DPSPrivContextRec *next;
+ integer lastNameIndex, cid;
+ boolean eofReceived;
+ char *wh;
+ char *buf, *outBuf, *objBuf;
+ integer nBufChars, nOutBufChars, nObjBufChars;
+ DPSNumFormat numFormat;
+ boolean resyncing; /* Error has occurred and waiting ResetContext */
+ int *numstringOffsets; /* see comment below */
+
+/* Everthing after this is XDPS-specific */
+
+ boolean creator; /* Did this app. create the context? */
+ int statusFromEvent; /* Latest status reported by an event during reset. */
+ XDPSStatusProc statusProc;
+ boolean zombie; /* To avoid DPSAwaitReturnValues */
+ XDPSReadyProc readyProc;
+} DPSPrivContextRec, *DPSPrivContext;
+
+/* The numstringOffsets field lists offsets of encoded number strings in
+ the current buffer. If non NULL, the first entry contains the size of
+ the allocated offset buffer and the second entry contains the next
+ available offset entry for use. */
+
+/* The first part of this structure is generic; the last part is
+ implementation-specific. */
+
+typedef struct _t_DPSPrivSpaceRec {
+ DPSSpaceProcs procs;
+
+ struct _t_DPSPrivSpaceRec *next;
+ long int lastNameIndex, sid;
+ char *wh; /* KLUDGE to support DPSSendDestroySpace */
+ DPSPrivContext firstContext;
+
+/* Everthing after this is XDPS-specific */
+
+ boolean creator; /* Did this app. create the space? */
+} DPSPrivSpaceRec, *DPSPrivSpace;
+
+#include "dpsint.h"
+
+#endif /* DPSXINT_H */
diff --git a/nx-X11/lib/dps/dpsXops.psw b/nx-X11/lib/dps/dpsXops.psw
new file mode 100644
index 000000000..a14335739
--- /dev/null
+++ b/nx-X11/lib/dps/dpsXops.psw
@@ -0,0 +1,80 @@
+/* dpsXops.psw
+ *
+ * (c) Copyright 1991-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSclientsync(DPSContext ctxt)
+ clientsync
+endps
+
+defineps DPScurrentXgcdrawable(DPSContext ctxt | int *gc, *draw, *x, *y)
+ currentXgcdrawable y x draw gc
+endps
+
+defineps DPScurrentXgcdrawablecolor(DPSContext ctxt | int *gc, *draw, *x, *y, colorInfo[12])
+ currentXgcdrawablecolor colorInfo y x draw gc
+endps
+
+defineps DPScurrentXoffset(DPSContext ctxt | int *x, *y)
+ currentXoffset y x
+endps
+
+defineps DPSsetXgcdrawable(DPSContext ctxt; int gc, draw, x, y)
+ gc draw x y setXgcdrawable
+endps
+
+defineps DPSsetXgcdrawablecolor(DPSContext ctxt; int gc, draw, x, y, colorInfo[12])
+ gc draw x y colorInfo setXgcdrawablecolor
+endps
+
+defineps DPSsetXoffset(DPSContext ctxt; int x, y)
+ x y setXoffset
+endps
+
+defineps DPSsetXrgbactual(DPSContext ctxt; float r, g, b | boolean *success)
+ r g b setXrgbactual success
+endps
+
+defineps DPSclientXready(DPSContext ctxt; int i0, i1, i2, i3)
+ [ i0 i1 i2 i3 ] clientXready
+endps
+
+defineps DPSsetXdrawingfunction(DPSContext ctxt; int function)
+ function setXdrawingfunction
+endps
+
+defineps DPScurrentXdrawingfunction(DPSContext ctxt | int *function)
+ currentXdrawingfunction function
+endps
diff --git a/nx-X11/lib/dps/dpsXpriv.c b/nx-X11/lib/dps/dpsXpriv.c
new file mode 100644
index 000000000..c0f12545c
--- /dev/null
+++ b/nx-X11/lib/dps/dpsXpriv.c
@@ -0,0 +1,534 @@
+/*
+ * dpsXpriv.c
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86: xc/lib/dps/dpsXpriv.c,v 1.7 2002/03/05 21:50:14 herrb Exp $ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+#ifdef GC
+#undef GC
+#endif /* GC */
+
+#ifdef VMS
+/* Xlib does not like UNIX defined to any value under VMS. */
+#undef UNIX
+#include <decw$include/X.h>
+#include <decw$include/Xproto.h>
+#include <decw$include/Xlib.h>
+#include <decw$include/Xutil.h>
+#else /* VMS */
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#endif /* VMS */
+#include "DPS/XDPSlib.h"
+#include "DPS/XDPS.h"
+#include "dpsprivate.h"
+#include "DPS/dpsconfig.h"
+#include "publictypes.h"
+#include "dpsXpriv.h"
+#include "DPS/dpsXclient.h"
+#include "DPS/dpsexcept.h"
+#include "dpsassert.h"
+
+#ifdef ISC
+#include <sys/bsdtypes.h>
+#endif
+
+#ifdef __QNX__
+#include <sys/select.h>
+#endif
+
+#if defined(hpux) || defined(AIXV3)
+#define SELECT_TYPE int *
+#else
+#define SELECT_TYPE fd_set *
+#endif
+
+typedef struct _RegstDPY
+ {
+ Display *dpy;
+ int firstEvent;
+ struct _RegstDPY *next;
+ unsigned char ctxtTokenType; /* establish for each context. */
+ unsigned char prefTokenType; /* ...of the server. */
+ } RegstDPYRec, *PRegstDPY;
+
+
+/* XDPSContextTimedOut is set to true by the BlockForEvent routine
+ when expected return values are not received within a certain
+ amount of time. In this case, BlockForEvent will return and the
+ higher callers may take appropriate action to avoid deadlocks. */
+int XDPSContextTimedOut = false; /* Unimplemented */
+DPSProcs XDPSconvProcs = NIL;
+DPSProcs XDPSrawProcs = NIL;
+
+/* XDPSQuitBlocking is set to false by the BlockForEvent routine and
+ becomes true if either a zombie status event or an output event
+ is received for the context waiting for return values. */
+int XDPSQuitBlocking = false;
+
+
+static DPSClientPrintProc clientPrintProc = NIL;
+static PRegstDPY firstDPY = NIL;
+/* operands for "setobjectformat" if we must agree with server. */
+static char *format_operands[] = {"1", "2", "3", "4"};
+
+
+
+static PRegstDPY IsRegistered (
+ register Display *dpy)
+{
+ register PRegstDPY rdpy;
+
+ for (rdpy = firstDPY; rdpy != NIL; rdpy = rdpy->next)
+ if (rdpy->dpy == dpy)
+ return (rdpy);
+ return (NIL);
+}
+
+
+void XDPSPrivZapDpy(
+ register Display *dpy)
+{
+ register PRegstDPY rdpy, prev = NIL;
+
+ for (rdpy = firstDPY; rdpy != NIL; prev = rdpy,rdpy = rdpy->next)
+ if (rdpy->dpy == dpy)
+ {
+ if (prev == NIL)
+ firstDPY = rdpy->next;
+ else
+ prev->next = rdpy->next;
+ break;
+ }
+ free(rdpy);
+}
+
+
+/* ARGSUSED */
+static int UsuallyFalse (
+ Display *dpy,
+ XEvent *event,
+ char *arg)
+{
+ return((event->type & 0x7F) == X_Error);
+}
+
+void XDPSForceEvents (
+ Display *dpy)
+{
+ XEvent event;
+
+ while (XCheckIfEvent (dpy, &event, UsuallyFalse, (char *) NULL)) {
+ int (*proc)(Display *, XErrorEvent *) = XSetErrorHandler(NULL);
+ (void) XSetErrorHandler(proc);
+ if (proc != 0 && event.type < 256)
+ (void)(*proc)(dpy, &event.xerror);
+ }
+}
+
+
+static void OutputEventHandler (
+ register XDPSLOutputEvent *event)
+{
+ PRegstDPY rdpy;
+ register DPSContext ctxt;
+
+ if ((rdpy = IsRegistered (event->display)) == NIL ||
+ rdpy->firstEvent != event->type)
+ return;
+
+ ctxt = XDPSContextFromXID (event->display, event->cxid);
+ if (ctxt != NIL)
+ {
+ if (ctxt->resultTable != NIL)
+ XDPSQuitBlocking = true;
+ (*clientPrintProc) (ctxt, event->data, event->length);
+ }
+}
+
+
+static int BlockForEvent (
+ Display *dpy)
+{
+ fd_set readfds;
+
+ XDPSQuitBlocking = false;
+ /* XDPSQuitBlocking becomes true if a zombie status event or
+ any output event is received by the status event handler for
+ the currently-awaiting-results context. */
+ while (1) {
+ FD_SET(ConnectionNumber(dpy), &readfds);
+ if (select (ConnectionNumber(dpy)+1, (SELECT_TYPE) &readfds,
+ (SELECT_TYPE) NULL, (SELECT_TYPE) NULL,
+ (struct timeval *) NULL) < 0) {
+ if (errno == EINTR) {
+ /* Ignore interrupt signals */
+ errno = 0;
+ continue;
+ }
+ return (-1); /* Broken connection (errno == EBADF) */
+ } else {
+ XDPSForceEvents (dpy);
+ if (XDPSQuitBlocking) break;
+ XNoOp(dpy);
+ /* The noop is necessary to force proper behavior when the
+ connection goes away - listen carefully! When the dpy
+ connection is closed, the above select returns indicating
+ activity on the connection. We call XDPSForceEvents, which
+ calls XCheckIfEvent, which ultimately may call XFlush
+ (if there are no events queued). The XNoOp call puts
+ a message in the outgoing queue, so that XFlush is forced
+ to write on the connection. When it tries to write, the
+ error condition will be noted and XIOError will be called,
+ usually causing the application to terminate. Note that
+ the error won't happen until the second time thru this
+ loop, but that's ok. */
+ }
+ }
+ return (0);
+}
+
+
+void XDPSSetContextEncoding (
+ DPSContext ctxt,
+ DPSProgramEncoding progEncoding,
+ DPSNameEncoding nameEncoding)
+{
+ /* This routine should not be called if ctxt is a text context */
+
+ if ((nameEncoding != dps_indexed && nameEncoding != dps_strings) ||
+ (progEncoding != dps_ascii && progEncoding != dps_encodedTokens &&
+ progEncoding != dps_binObjSeq))
+ {
+ if (ctxt->errorProc != NIL)
+ (*ctxt->errorProc) (ctxt, dps_err_encodingCheck,
+ nameEncoding, progEncoding);
+ return;
+ }
+ else if (progEncoding == dps_ascii || progEncoding == dps_encodedTokens ||
+ nameEncoding == dps_strings)
+ ctxt->procs = XDPSconvProcs;
+ else
+ ctxt->procs = XDPSrawProcs;
+
+ ctxt->nameEncoding = nameEncoding;
+ ctxt->programEncoding = progEncoding;
+}
+
+
+/* ARGSUSED */
+void DPSDefaultTextBackstop (ctxt, buf, count)
+ DPSContext ctxt;
+ char *buf;
+ long unsigned int count;
+{
+ if (buf == NULL || count == 0)
+ {
+ (void) fflush(stdout);
+ return;
+ }
+ (void) fwrite (buf, sizeof (char), count, stdout);
+ (void) fflush (stdout);
+}
+
+/* ARGSUSED */
+void DPSInitClient(
+ DPSTextProc textProc,
+ void (*releaseProc) (char *, char *))
+{
+ DPSAssert (releaseProc != NIL);
+ XDPSSetProcs ();
+ DPSSetTextBackstop (DPSDefaultTextBackstop);
+ DPSSetErrorBackstop (DPSDefaultErrorProc);
+}
+
+
+DPSNumFormat XDPSNumFormat (
+ Display *dpy)
+{
+ PRegstDPY rdpy;
+
+ if ((rdpy = IsRegistered (dpy)) == NIL)
+ return ((DPSNumFormat) -1);
+ else
+ return ((rdpy->ctxtTokenType < DPS_HI_NATIVE) ? dps_ieee : dps_native);
+}
+
+XDPSPrivContext XDPSCreatePrivContextRec (
+ Display *dpy,
+ Drawable drawable,
+ GC gc,
+ int x,
+ int y,
+ unsigned int eventmask,
+ XStandardColormap *grayramp,
+ XStandardColormap *ccube,
+ int actual,
+ int secure)
+{
+ int event_base;
+ int token_type; /* From server. */
+ char *num_format_name; /* From server. */
+ PRegstDPY rdpy;
+ XDPSPrivContext wh;
+
+ if (DPSInitialize() != 0) return(NULL);
+ if ((rdpy = IsRegistered (dpy)) == NIL)
+ {
+ /* DPS extension on this dpy? */
+ event_base = XDPSLInit (dpy, &token_type, &num_format_name);
+ if (event_base >= 0 &&
+ (rdpy = (PRegstDPY) calloc (sizeof (RegstDPYRec), 1)))
+ {
+ XDPSLSetTextEventHandler (dpy, (XDPSLEventHandler) OutputEventHandler);
+ XDPSLSetStatusEventHandler (dpy, (XDPSLEventHandler) XDPSStatusEventHandler);
+ XDPSLSetReadyEventHandler (dpy, (XDPSLEventHandler) XDPSReadyEventHandler);
+ XDPSLInitDisplayFlags(dpy);
+ rdpy->dpy = dpy;
+ rdpy->firstEvent = event_base;
+ rdpy->next = firstDPY;
+
+ rdpy->prefTokenType = (unsigned char) token_type;
+
+ if (strcmp (num_format_name, DPS_FORMATNAME) == 0)
+ rdpy->ctxtTokenType = DPS_DEF_TOKENTYPE;
+ else
+ /* Everybody must talk ieee! */
+#if SWAPBITS
+ rdpy->ctxtTokenType = DPS_LO_IEEE;
+#else /* SWAPBITS */
+ rdpy->ctxtTokenType = DPS_HI_IEEE;
+#endif /* SWAPBITS */
+
+ firstDPY = rdpy;
+ }
+ else
+ return (NULL);
+ }
+
+ if ((wh = (XDPSPrivContext) calloc (sizeof (XDPSPrivContextRec), 1)) != 0)
+ {
+ wh->dpy = dpy;
+ wh->drawable = drawable;
+ wh->gc = gc;
+ wh->x = x;
+ wh->y = y;
+ wh->eventmask = eventmask;
+ wh->grayramp = grayramp;
+ wh->ccube = ccube;
+ wh->actual = actual;
+ wh->newObjFormat = format_operands[rdpy->ctxtTokenType - DPS_HI_IEEE];
+ wh->secure = secure;
+ return (wh);
+ }
+ else
+ return (NULL);
+}
+
+
+DPSNumFormat DPSCreatePrivContext (
+ XDPSPrivContext wh,
+ DPSContext ctxt,
+ ContextPSID *cidP,
+ SpaceXID *sxidP,
+ boolean newSpace,
+ DPSClientPrintProc printProc)
+{
+ PRegstDPY rdpy;
+
+ if (clientPrintProc == NIL)
+ clientPrintProc = printProc;
+
+ if ((rdpy = IsRegistered (wh->dpy)) == NIL)
+ return ((DPSNumFormat) -1);
+
+ if (newSpace || sxidP == NIL)
+ wh->cxid = XDPSLCreateContextAndSpace (wh->dpy, wh->drawable, wh->gc,
+ wh->x, wh->y, wh->eventmask,
+ wh->grayramp, wh->ccube,
+ wh->actual, cidP, sxidP,
+ wh->secure); /* L2-DPS/PROTO 9 */
+ else
+ wh->cxid = XDPSLCreateContext (wh->dpy, *sxidP, wh->drawable, wh->gc,
+ wh->x, wh->y, wh->eventmask,
+ wh->grayramp, wh->ccube, wh->actual, cidP,
+ wh->secure); /* L2-DPS/PROTO 9 */
+ if (wh->cxid == None) return((DPSNumFormat) -1);
+ wh->ctxt = ctxt;
+ if (wh->newObjFormat != NIL)
+ {
+ XDPSLGiveInput (wh->dpy, wh->cxid, wh->newObjFormat, 1);
+ XDPSLGiveInput (wh->dpy, wh->cxid, " setobjectformat\n", 17);
+ }
+
+ if (rdpy->ctxtTokenType != DPS_DEF_TOKENTYPE)
+ ctxt->procs = XDPSconvProcs;
+ return ((rdpy->ctxtTokenType < DPS_HI_NATIVE) ? dps_ieee : dps_native);
+}
+
+
+void DPSIncludePrivContext (
+ XDPSPrivContext wh,
+ DPSContext ctxt,
+ ContextPSID cid,
+ SpaceXID sxid,
+ DPSClientPrintProc printProc)
+{
+ XDPSPrivContext newWh;
+ SpaceXID space;
+
+ if (clientPrintProc == NIL)
+ clientPrintProc = printProc;
+
+ newWh = (XDPSPrivContext) calloc (sizeof (XDPSPrivContextRec), 1);
+ if (!newWh) DPSOutOfMemory();
+ *newWh = *wh;
+ if (IsRegistered (wh->dpy) != NIL)
+ {
+ newWh->cxid = XDPSLCreateContextFromID (wh->dpy, cid, &space);
+ DPSAssertWarn (space == sxid, ctxt, "attempting context from context ID from different space");
+ newWh->ctxt = ctxt;
+ /* Did we have to change object format for parent context? */
+ /* Note: the child context must inherit the object format of
+ its parent. When this happens in the server there
+ will be no need for the following code segment. */
+ if (wh->newObjFormat != NIL) /* Yes, do it for the child too. */
+ {
+ XDPSLGiveInput (wh->dpy, newWh->cxid, wh->newObjFormat, 1);
+ XDPSLGiveInput (wh->dpy, newWh->cxid, " setobjectformat\n", 17);
+ }
+ }
+ else
+ {
+ newWh->cxid = 0; /* Must not refer to a good context. */
+ newWh->ctxt = NIL;
+ }
+
+ (void) DPSSetWh (ctxt, (char *) newWh);
+}
+
+/* ARGSUSED */
+void DPSSendPostScript (
+ register XDPSPrivContext wh,
+ DPSClientPrintProc printProc,
+ ContextPSID cid,
+ char *buffer,
+ long int count,
+ boolean (*returnControl)(void))
+{
+ boolean blocking = buffer == NIL;
+
+ if (IsRegistered (wh->dpy) == NIL)
+ (*printProc) (wh->ctxt, NIL, 0);
+ else {
+ if (count > 0)
+ XDPSLGiveInput (wh->dpy, wh->cxid, buffer, count);
+
+ if (blocking) {
+ XDPSLFlush (wh->dpy);
+ if (BlockForEvent (wh->dpy) < 0 && wh->ctxt->errorProc != NIL) {
+ (*(wh->ctxt->errorProc)) (wh->ctxt, dps_err_closedDisplay,
+ ConnectionNumber(wh->dpy),
+ 0);
+ }
+ }
+ DPSCheckRaiseError(wh->ctxt);
+ }
+}
+
+
+/* ARGSUSED */
+void DPSSendInterrupt (
+ XDPSPrivContext wh,
+ ContextPSID cid,
+ DPSClientPrintProc printProc)
+{
+ XDPSLNotifyContext (wh->dpy, wh->cxid, PSINTERRUPT);
+}
+
+
+/* ARGSUSED */
+void DPSSendEOF (
+ XDPSPrivContext wh,
+ ContextPSID cid,
+ DPSClientPrintProc printProc)
+{
+ XDPSLReset (wh->dpy, wh->cxid);
+}
+
+
+/* ARGSUSED */
+void DPSSendTerminate (
+ XDPSPrivContext wh,
+ ContextPSID cid,
+ DPSClientPrintProc printProc)
+{
+ XDPSLNotifyContext (wh->dpy, wh->cxid, PSKILL);
+}
+
+
+void XDPSSendUnfreeze (
+ Display *dpy,
+ ContextXID cxid)
+{
+ XDPSLNotifyContext (dpy, cxid, PSUNFREEZE);
+}
+
+
+/* ARGSUSED */
+void DPSSendDestroySpace(
+ XDPSPrivContext wh,
+ SpaceXID sxid,
+ DPSClientPrintProc printProc)
+{
+ XDPSLDestroySpace (wh->dpy, sxid);
+}
+
+
+void DPSOutOfMemory (void)
+{
+ DPSFatalProc(NULL, "DPS Client Library Error: Out of memory.\n");
+ exit (1);
+}
diff --git a/nx-X11/lib/dps/dpsXpriv.h b/nx-X11/lib/dps/dpsXpriv.h
new file mode 100644
index 000000000..56b25b757
--- /dev/null
+++ b/nx-X11/lib/dps/dpsXpriv.h
@@ -0,0 +1,187 @@
+/*
+ * dpsXpriv.h -- client lib internal impl interface for the X version
+ *
+ * (c) Copyright 1989-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#ifndef DPSXPRIVATE_H
+#define DPSXPRIVATE_H
+
+#ifdef VMS
+#include <decw$include/X.h>
+#include <decw$include/Xlib.h>
+#include <decw$include/Xutil.h>
+#else /* VMS */
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#endif /* VMS */
+
+#include <DPS/XDPSlib.h>
+#include "DPS/dpsclient.h"
+#include "dpsprivate.h"
+#include "DPS/dpsXclient.h"
+#include "publictypes.h"
+
+/* typedefs */
+
+typedef struct _t_XDPSPrivContextRec
+ {
+ Display *dpy;
+ Drawable drawable;
+ GC gc;
+ int x;
+ int y;
+ unsigned int eventmask;
+ XStandardColormap *grayramp;
+ XStandardColormap *ccube;
+ int actual;
+ DPSContext ctxt; /* Points back to its context */
+ ContextXID cxid;
+ char *newObjFormat; /* This is the object format that a */
+ /* new context must use for sending */
+ /* BOS's to the client. If the */
+ /* server and client have the same */
+ /* number formats then this will be */
+ /* null. */
+ int secure;
+ } XDPSPrivContextRec, *XDPSPrivContext;
+
+
+extern DPSProcs XDPSconvProcs;
+extern DPSProcs XDPSrawProcs;
+extern int XDPSQuitBlocking;
+
+
+extern XDPSPrivContext XDPSCreatePrivContextRec (
+ Display * /* dpy */,
+ Drawable /* drawable */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* eventmask */,
+ XStandardColormap * /* grayramp */,
+ XStandardColormap * /* ccube */,
+ int /* actual */,
+ int /* secure */);
+
+ /* See if dpy supports the DPS extension. If not, return NULL. If so,
+ it sets up a private context object that is used for creating
+ contexts and spaces. */
+
+extern DPSNumFormat DPSCreatePrivContext(
+ XDPSPrivContext /* wh */,
+ DPSContext /* ctxt */,
+ ContextPSID * /* cidP */,
+ SpaceXID * /* sxidP */,
+ boolean /* newSpace */,
+ DPSClientPrintProc /* printProc */);
+ /* returns -1 if server can't create the context */
+
+extern void DPSIncludePrivContext(
+ XDPSPrivContext /* wh */,
+ DPSContext /* ctxt */,
+ ContextPSID /* cid */,
+ SpaceXID /* sxid */,
+ DPSClientPrintProc /* printProc */);
+
+extern void DPSSendPostScript(
+ XDPSPrivContext /* wh */,
+ DPSClientPrintProc /* printProc */,
+ ContextPSID /* cid */,
+ char * /* buffer */,
+ long int /* count */,
+ boolean (* /* returnControl */)(void));
+
+extern void DPSSendInterrupt(
+ XDPSPrivContext /* wh */,
+ ContextPSID /* cid */,
+ DPSClientPrintProc /* printProc */);
+
+extern void DPSSendEOF(
+ XDPSPrivContext /* wh */,
+ ContextPSID /* cid */,
+ DPSClientPrintProc /* printProc */);
+
+extern void DPSSendTerminate(
+ XDPSPrivContext /* wh */,
+ ContextPSID /* cid */,
+ DPSClientPrintProc /* printProc */);
+
+extern void XDPSPrivZapDpy(
+ Display * /* dpy */);
+
+extern DPSNumFormat XDPSNumFormat (Display * /* dpy */);
+
+ /* Determine the number format for server over the "dpy" connection. */
+
+extern void XDPSSetProcs (void);
+
+ /* Set pointers to raw and conversion context procs. */
+
+extern void XDPSSetContextEncoding (
+ DPSContext /* ctxt */,
+ DPSProgramEncoding /* progEncoding */,
+ DPSNameEncoding /* nameEncoding */);
+
+ /* Sets context's program and name encodings to new values. */
+
+extern void XDPSStatusEventHandler (XDPSLStatusEvent * /* event */);
+
+ /* Is registered with Xlib and is called when a dps status event is
+ received. It determines what context the event belongs to and,
+ if that context has a status event handler, calls its handler
+ passing it the status type. */
+
+extern void XDPSReadyEventHandler (XDPSLReadyEvent * /* event */);
+
+ /* Is registered with Xlib and is called when a dps ready event is
+ received. It determines what context the event belongs to and,
+ if that context has a status event handler, calls its handler
+ passing it the ready data. */
+
+extern void XDPSForceEvents (Display * /* dpy */);
+
+ /* Forces processing of events that are pending over the 'dpy'
+ connection. This causes DPS events to be handled by their handlers. */
+
+extern void XDPSSendUnfreeze (Display * /* dpy */, ContextXID /* cxid */);
+
+extern void DPSSendDestroySpace(
+ XDPSPrivContext /* wh */,
+ SpaceXID /* sxid */,
+ DPSClientPrintProc /* printProc */);
+
+#endif /* DPSXPRIVATE_H */
diff --git a/nx-X11/lib/dps/dpsXtdisp.c b/nx-X11/lib/dps/dpsXtdisp.c
new file mode 100644
index 000000000..d778a3245
--- /dev/null
+++ b/nx-X11/lib/dps/dpsXtdisp.c
@@ -0,0 +1,109 @@
+/*
+ * dpsXtdisp.c
+ *
+ * (c) Copyright 1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#include <X11/Intrinsic.h>
+
+#if XtSpecificationRelease < 6
+
+#include "dpsassert.h"
+
+void XDPSSetXtEventDispatching(Display *dpy)
+{
+ DPSFatalProc(NULL, "Attempt to use XDPSSetXtEventDispatching with pre-R6 Intrinsics\n");
+ exit(1);
+}
+
+#else
+
+#include <DPS/XDPSlib.h>
+#include <DPS/dpsXclient.h>
+
+typedef struct _DpyProcRec {
+ Display *dpy;
+ XtEventDispatchProc oldproc;
+ struct _DpyProcRec *next;
+} DpyProcRec;
+
+static DpyProcRec *dpyProcList = NULL;
+
+static Boolean NXDispatcher(XEvent *event)
+{
+ DpyProcRec *d;
+
+ if (XDPSDispatchEvent(event)) return True;
+
+ for (d = dpyProcList; d != NULL && d->dpy != event->xany.display;
+ d = d->next) {}
+ if (d != NULL) return (*(d->oldproc))(event);
+ else return False;
+}
+
+void XDPSSetXtEventDispatching(Display *dpy)
+{
+ int codes;
+ XExtCodes *c;
+
+ codes = XDPSLInit(dpy, (int *) NULL, (char **) NULL);
+
+ if (codes == -1) return; /* No extension or NX, so nothing to do */
+ else {
+ (void) XDPSSetEventDelivery(dpy, dps_event_pass_through);
+ c = XDPSLGetCodes(dpy);
+
+ /* First check for NX */
+ if (!c->first_event) {
+ DpyProcRec *d = XtNew(DpyProcRec);
+ d->dpy = dpy;
+ d->next = dpyProcList;
+ d->oldproc =
+ XtSetEventDispatcher(dpy, ClientMessage, NXDispatcher);
+ dpyProcList = d;
+
+ } else {
+ /* Extension */
+ (void) XtSetEventDispatcher(dpy, c->first_event + PSEVENTSTATUS,
+ (XtEventDispatchProc) XDPSDispatchEvent);
+ (void) XtSetEventDispatcher(dpy, c->first_event + PSEVENTOUTPUT,
+ (XtEventDispatchProc) XDPSDispatchEvent);
+ (void) XtSetEventDispatcher(dpy, c->first_event + PSEVENTREADY,
+ (XtEventDispatchProc) XDPSDispatchEvent);
+ }
+ }
+}
+
+#endif
diff --git a/nx-X11/lib/dps/dpsabbrev.c b/nx-X11/lib/dps/dpsabbrev.c
new file mode 100644
index 000000000..20b3ef713
--- /dev/null
+++ b/nx-X11/lib/dps/dpsabbrev.c
@@ -0,0 +1,360 @@
+/*
+ * dpsabbrev.c -- Implementation of Client Library abbrev mode
+ *
+ * (c) Copyright 1993-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+#include <string.h>
+#include "publictypes.h"
+#include "DPS/dpsclient.h"
+#include "dpsprivate.h"
+
+static DPSAbbrevRec abbrev[] = {
+ {1, "add", "!+"},
+ {10, "ashow", "!a"},
+ {12, "awidthshow", "!A"},
+ {13, "begin", "!B"},
+ {14, "bind", "!b"},
+ {20, "clip", "!CL"},
+ {22, "closepath", "!c"},
+ {23, "concat", "!CC"},
+ {25, "copy", "!CP"},
+ {39, "currentmatrix", "!CM"},
+ {40, "currentpoint", "!Cp"},
+ {43, "curveto", "!C"},
+ {51, "def", "!D"},
+ {53, "dict", "!d"},
+ {62, "exch", "!E"},
+ {63, "exec", "!e"},
+ {66, "fill", "!F"},
+ {67, "findfont", "!f"},
+ {77, "grestore", "!G"},
+ {78, "gsave", "!g"},
+ {85, "ifelse", "!I"},
+ {88, "index", "!i"},
+ {98, "length", "!LE"},
+ {99, "lineto", "!L"},
+ {100, "load", "!l"},
+ {103, "makefont", "!MF"},
+ {104, "matrix", "!m"},
+ {107, "moveto", "!M"},
+ {111, "newpath", "!N"},
+ {113, "null", "!n"},
+ {117, "pop", "!p"},
+ {122, "rcurveto", "!RC"},
+ {127, "rectclip", "!R"},
+ {128, "rectfill", "!RF"},
+ {129, "rectstroke", "!RS"},
+ {131, "repeat", "!RP"},
+ {132, "restore", "!Rs"},
+ {133, "rlineto", "!r"},
+ {134, "rmoveto", "!RM"},
+ {135, "roll", "!RL"},
+ {136, "rotate", "!RO"},
+ {137, "round", "!RN"},
+ {138, "save", "!SV"},
+ {139, "scale", "!SC"},
+ {140, "scalefont", "!SF"},
+ {142, "selectfont", "!s"},
+ {147, "setcmykcolor", "!Sc"},
+ {148, "setdash", "!SD"},
+ {149, "setfont", "!Sf"},
+ {150, "setgray", "!Sg"},
+ {152, "sethsbcolor", "!Sh"},
+ {153, "setlinecap", "!SL"},
+ {154, "setlinejoin", "!SJ"},
+ {155, "setlinewidth", "!SW"},
+ {156, "setmatrix", "!SM"},
+ {157, "setrgbcolor", "!Sr"},
+ {158, "setshared", "!SS"},
+ {160, "show", "!S"},
+ {161, "showpage", "!SP"},
+ {167, "stroke", "!ST"},
+ {170, "systemdict", "!Sd"},
+ {173, "translate", "!T"},
+ {182, "userdict", "!u"},
+ {186, "where", "!w"},
+ {187, "widthshow", "!W"},
+ {194, "xshow", "!X"},
+ {195, "xyshow", "!x"},
+ {196, "yshow", "!Y"},
+};
+
+static short abbrevPtr[] = {
+ -1, /* 0 */
+ 0, /* 1 */
+ -1, /* 2 */
+ -1, /* 3 */
+ -1, /* 4 */
+ -1, /* 5 */
+ -1, /* 6 */
+ -1, /* 7 */
+ -1, /* 8 */
+ -1, /* 9 */
+ 1, /* 10 */
+ -1, /* 11 */
+ 2, /* 12 */
+ 3, /* 13 */
+ 4, /* 14 */
+ -1, /* 15 */
+ -1, /* 16 */
+ -1, /* 17 */
+ -1, /* 18 */
+ -1, /* 19 */
+ 5, /* 20 */
+ -1, /* 21 */
+ 6, /* 22 */
+ 7, /* 23 */
+ -1, /* 24 */
+ 8, /* 25 */
+ -1, /* 26 */
+ -1, /* 27 */
+ -1, /* 28 */
+ -1, /* 29 */
+ -1, /* 30 */
+ -1, /* 31 */
+ -1, /* 32 */
+ -1, /* 33 */
+ -1, /* 34 */
+ -1, /* 35 */
+ -1, /* 36 */
+ -1, /* 37 */
+ -1, /* 38 */
+ 9, /* 39 */
+ 10, /* 40 */
+ -1, /* 41 */
+ -1, /* 42 */
+ 11, /* 43 */
+ -1, /* 44 */
+ -1, /* 45 */
+ -1, /* 46 */
+ -1, /* 47 */
+ -1, /* 48 */
+ -1, /* 49 */
+ -1, /* 50 */
+ 12, /* 51 */
+ -1, /* 52 */
+ 13, /* 53 */
+ -1, /* 54 */
+ -1, /* 55 */
+ -1, /* 56 */
+ -1, /* 57 */
+ -1, /* 58 */
+ -1, /* 59 */
+ -1, /* 60 */
+ -1, /* 61 */
+ 14, /* 62 */
+ 15, /* 63 */
+ -1, /* 64 */
+ -1, /* 65 */
+ 16, /* 66 */
+ 17, /* 67 */
+ -1, /* 68 */
+ -1, /* 69 */
+ -1, /* 70 */
+ -1, /* 71 */
+ -1, /* 72 */
+ -1, /* 73 */
+ -1, /* 74 */
+ -1, /* 75 */
+ -1, /* 76 */
+ 18, /* 77 */
+ 19, /* 78 */
+ -1, /* 79 */
+ -1, /* 80 */
+ -1, /* 81 */
+ -1, /* 82 */
+ -1, /* 83 */
+ -1, /* 84 */
+ 20, /* 85 */
+ -1, /* 86 */
+ -1, /* 87 */
+ 21, /* 88 */
+ -1, /* 89 */
+ -1, /* 90 */
+ -1, /* 91 */
+ -1, /* 92 */
+ -1, /* 93 */
+ -1, /* 94 */
+ -1, /* 95 */
+ -1, /* 96 */
+ -1, /* 97 */
+ 22, /* 98 */
+ 23, /* 99 */
+ 24, /* 100 */
+ -1, /* 101 */
+ -1, /* 102 */
+ 25, /* 103 */
+ 26, /* 104 */
+ -1, /* 105 */
+ -1, /* 106 */
+ 27, /* 107 */
+ -1, /* 108 */
+ -1, /* 109 */
+ -1, /* 110 */
+ 28, /* 111 */
+ -1, /* 112 */
+ 29, /* 113 */
+ -1, /* 114 */
+ -1, /* 115 */
+ -1, /* 116 */
+ 30, /* 117 */
+ -1, /* 118 */
+ -1, /* 119 */
+ -1, /* 120 */
+ -1, /* 121 */
+ 31, /* 122 */
+ -1, /* 123 */
+ -1, /* 124 */
+ -1, /* 125 */
+ -1, /* 126 */
+ 32, /* 127 */
+ 33, /* 128 */
+ 34, /* 129 */
+ -1, /* 130 */
+ 35, /* 131 */
+ 36, /* 132 */
+ 37, /* 133 */
+ 38, /* 134 */
+ 39, /* 135 */
+ 40, /* 136 */
+ 41, /* 137 */
+ 42, /* 138 */
+ 43, /* 139 */
+ 44, /* 140 */
+ -1, /* 141 */
+ 45, /* 142 */
+ -1, /* 143 */
+ -1, /* 144 */
+ -1, /* 145 */
+ -1, /* 146 */
+ 46, /* 147 */
+ 47, /* 148 */
+ 48, /* 149 */
+ 49, /* 150 */
+ -1, /* 151 */
+ 50, /* 152 */
+ 51, /* 153 */
+ 52, /* 154 */
+ 53, /* 155 */
+ 54, /* 156 */
+ 55, /* 157 */
+ 56, /* 158 */
+ -1, /* 159 */
+ 57, /* 160 */
+ 58, /* 161 */
+ -1, /* 162 */
+ -1, /* 163 */
+ -1, /* 164 */
+ -1, /* 165 */
+ -1, /* 166 */
+ 59, /* 167 */
+ -1, /* 168 */
+ -1, /* 169 */
+ 60, /* 170 */
+ -1, /* 171 */
+ -1, /* 172 */
+ 61, /* 173 */
+ -1, /* 174 */
+ -1, /* 175 */
+ -1, /* 176 */
+ -1, /* 177 */
+ -1, /* 178 */
+ -1, /* 179 */
+ -1, /* 180 */
+ -1, /* 181 */
+ 62, /* 182 */
+ -1, /* 183 */
+ -1, /* 184 */
+ -1, /* 185 */
+ 63, /* 186 */
+ 64, /* 187 */
+ -1, /* 188 */
+ -1, /* 189 */
+ -1, /* 190 */
+ -1, /* 191 */
+ -1, /* 192 */
+ -1, /* 193 */
+ 65, /* 194 */
+ 66, /* 195 */
+ 67, /* 196 */
+ -1, /* 197 */
+ -1, /* 198 */
+ -1, /* 199 */
+ -1, /* 200 */
+ -1, /* 201 */
+ -1, /* 202 */
+ -1, /* 203 */
+ -1, /* 204 */
+ -1, /* 205 */
+ -1, /* 206 */
+ -1, /* 207 */
+ -1, /* 208 */
+ -1, /* 209 */
+ -1, /* 210 */
+ -1, /* 211 */
+};
+
+void DPSFetchAbbrevList(DPSAbbrevRec **list, int *count)
+{
+ *list = abbrev;
+ *count = sizeof(abbrev) / sizeof(abbrev[0]);
+}
+
+char *DPSGetSysnameAbbrev(int n)
+{
+ if ((unsigned) n > sizeof(abbrevPtr) / sizeof(abbrevPtr[0])) return NULL;
+ if (abbrevPtr[n] == -1) return NULL;
+ return abbrev[abbrevPtr[n]].abbrev;
+}
+
+char *DPSGetOperatorAbbrev(char *op)
+{
+ int min, max, n;
+ int res;
+
+ min = 0;
+ max = sizeof(abbrev) / sizeof(abbrev[0]) - 1;
+
+ while (min <= max) {
+ n = (max + min) / 2;
+ res = strcmp(op, abbrev[n].operatorName);
+ if (res == 0) return abbrev[n].abbrev;
+ if (res < 0) max = n - 1;
+ if (res > 0) min = n + 1;
+ }
+ return NULL;
+}
diff --git a/nx-X11/lib/dps/dpsassert.h b/nx-X11/lib/dps/dpsassert.h
new file mode 100644
index 000000000..00632a111
--- /dev/null
+++ b/nx-X11/lib/dps/dpsassert.h
@@ -0,0 +1,57 @@
+/*
+ * dpsassert.h
+ *
+ * (c) Copyright 1991-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#ifndef DPSASSERT_H
+#define DPSASSERT_H
+
+#include "DPS/dpsclient.h"
+
+#define DPSAssertWarn(cndtn, cntxt, mssg)\
+ if (!(cndtn)) DPSWarnProc((DPSContext)(cntxt),(mssg))
+
+extern void DPSWarnProc(DPSContext ctxt, char *msg);
+extern void DPSFatalProc(DPSContext ctxt, char *msg);
+extern void DPSCantHappen(void);
+
+#define DPSAssert(condition) \
+ if (! (condition)) DPSCantHappen();
+/* Tests whether the specified condition is true and aborts the
+ entire application if not.
+ */
+
+#endif /* DPSASSERT_H */
diff --git a/nx-X11/lib/dps/dpsclient.c b/nx-X11/lib/dps/dpsclient.c
new file mode 100644
index 000000000..c75d76ce8
--- /dev/null
+++ b/nx-X11/lib/dps/dpsclient.c
@@ -0,0 +1,2969 @@
+/*
+ * dpsclient.c -- Implementation of the Display PostScript Client Library.
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+#include "dpsXpriv.h"
+#include "DPS/dpsclient.h"
+#include "dpsprivate.h"
+#include "dpsdict.h"
+#include "DPS/dpsexcept.h"
+#include "dpsassert.h"
+
+#ifdef XDPS
+#include "dpsXint.h"
+#endif /* XDPS */
+
+#if defined(SVR4) || defined(SYSV) || defined(SystemV)
+#define os_bcopy(f,t,c) memcpy(t,f,c)
+#else
+#define os_bcopy(f,t,c) bcopy(f,t,c)
+#endif
+
+#if !IEEEFLOAT
+extern void IEEEHighToNative(/* FloatRep *from, real *to */);
+/* Converts from IEEE high-byte-first real to native real. */
+
+extern void NativeToIEEEHigh(/* real *from, FloatRep *to */);
+/* Converts from native real to IEEE high-byte-first real. */
+
+extern void IEEELowToNative(/* FloatRep *from, real *to */);
+/* Converts from IEEE low-byte-first real to native real. */
+
+extern void NativeToIEEELow(/* real *from, FloatRep *to */);
+/* Converts from native real to IEEE low-byte-first real. */
+#endif /* !IEEEFLOAT */
+
+typedef union { /* 32 bit number representations */
+ unsigned int u;
+ int i;
+ float f;
+ unsigned char bytes[4];
+ /* raw bytes, in whatever order they appear in memory */
+ } Swap32Rec;
+
+typedef union { /* 16 bit number representations */
+ unsigned short u;
+ short i;
+ unsigned char bytes[2];
+ } Swap16Rec;
+
+#if SWAPBITS
+#define Copy4SrcLo(src, dst)\
+ (((Swap32Rec *) dst)->bytes[0] = ((Swap32Rec *) src)->bytes[0], \
+ ((Swap32Rec *) dst)->bytes[1] = ((Swap32Rec *) src)->bytes[1], \
+ ((Swap32Rec *) dst)->bytes[2] = ((Swap32Rec *) src)->bytes[2], \
+ ((Swap32Rec *) dst)->bytes[3] = ((Swap32Rec *) src)->bytes[3] )
+#define Copy4SrcHi(src, dst)\
+ (((Swap32Rec *) dst)->bytes[0] = ((Swap32Rec *) src)->bytes[3], \
+ ((Swap32Rec *) dst)->bytes[1] = ((Swap32Rec *) src)->bytes[2], \
+ ((Swap32Rec *) dst)->bytes[2] = ((Swap32Rec *) src)->bytes[1], \
+ ((Swap32Rec *) dst)->bytes[3] = ((Swap32Rec *) src)->bytes[0] )
+#define Copy2SrcLo(src, dst)\
+ (((Swap16Rec *) dst)->bytes[0] = ((Swap16Rec *) src)->bytes[0], \
+ ((Swap16Rec *) dst)->bytes[1] = ((Swap16Rec *) src)->bytes[1] )
+#define Copy2SrcHi(src, dst)\
+ (((Swap16Rec *) dst)->bytes[0] = ((Swap16Rec *) src)->bytes[1], \
+ ((Swap16Rec *) dst)->bytes[1] = ((Swap16Rec *) src)->bytes[0] )
+#else /* SWAPBITS */
+#define Copy4SrcHi(src, dst)\
+ (((Swap32Rec *) dst)->bytes[0] = ((Swap32Rec *) src)->bytes[0], \
+ ((Swap32Rec *) dst)->bytes[1] = ((Swap32Rec *) src)->bytes[1], \
+ ((Swap32Rec *) dst)->bytes[2] = ((Swap32Rec *) src)->bytes[2], \
+ ((Swap32Rec *) dst)->bytes[3] = ((Swap32Rec *) src)->bytes[3] )
+#define Copy4SrcLo(src, dst)\
+ (((Swap32Rec *) dst)->bytes[0] = ((Swap32Rec *) src)->bytes[3], \
+ ((Swap32Rec *) dst)->bytes[1] = ((Swap32Rec *) src)->bytes[2], \
+ ((Swap32Rec *) dst)->bytes[2] = ((Swap32Rec *) src)->bytes[1], \
+ ((Swap32Rec *) dst)->bytes[3] = ((Swap32Rec *) src)->bytes[0] )
+#define Copy2SrcHi(src, dst)\
+ (((Swap16Rec *) dst)->bytes[0] = ((Swap16Rec *) src)->bytes[0], \
+ ((Swap16Rec *) dst)->bytes[1] = ((Swap16Rec *) src)->bytes[1] )
+#define Copy2SrcLo(src, dst)\
+ (((Swap16Rec *) dst)->bytes[0] = ((Swap16Rec *) src)->bytes[1], \
+ ((Swap16Rec *) dst)->bytes[1] = ((Swap16Rec *) src)->bytes[0] )
+#endif /* SWAPBITS */
+
+
+#define DPS_ERR_TAG 250
+
+#define CONTEXTBUFFERSIZE 256
+#define MAXQUEUEDBUFFERS 5
+
+DPSContext DPSGlobalContext;
+
+Globals DPSglobals = NULL;
+
+char *DPScalloc(integer e, integer n)
+{
+ char *p;
+ while (!(p = (char *)calloc(e, n))) {
+ DPSOutOfMemory();
+ }
+ return p;
+}
+
+
+
+void DPSSafeSetLastNameIndex(DPSContext ctxt)
+{
+ /* we're about to call the error handler, so roll back the
+ lastNameIndex to the last known valid index */
+ DPSCheckInitClientGlobals();
+ if (ctxt != dummyCtx && ctxt->space != NIL)
+ ((DPSPrivContext)ctxt)->lastNameIndex = ((DPSPrivSpace)(ctxt->space))->lastNameIndex;
+}
+
+void DPSCheckInitClientGlobals(void)
+{
+ if (!DPSglobals) {
+ DPSglobals = (Globals)DPScalloc(sizeof(GlobalsRec), 1);
+ globLastNameIndex = -1;
+ }
+}
+
+/**************************************************************/
+/* Procedures that support the DPSCreateContext context procs */
+/**************************************************************/
+
+/* ARGSUSED */
+static void ReleaseInput(
+ char *unused, char *buffer)
+{
+ ContextBuffer cb = (ContextBuffer)buffer;
+ if (cb == NIL) return;
+ cb->next = contextBuffers;
+ contextBuffers = cb;
+ queuedBuffers--;
+}
+
+/* ARGSUSED */
+static void StuffResultVal(
+ DPSContext ctxt,
+ DPSResults result,
+ integer tag,
+ DPSBinObj obj)
+{
+
+ integer type = obj->attributedType & ~DPS_EXEC;
+ integer nObjs = 1;
+
+ /* check if array */
+ if (type == DPS_ARRAY) {
+ nObjs = obj->length;
+ if (nObjs < 1) return;
+ if (result->count == -1 && nObjs != 1) {
+ DPSSafeSetLastNameIndex(ctxt);
+ if (ctxt->errorProc != NIL)
+ (*ctxt->errorProc)(ctxt, dps_err_resultTypeCheck, (long unsigned)obj, 0);
+ return;
+ }
+ obj = (DPSBinObj) ((char *)obj + obj->val.arrayVal);
+ type = obj->attributedType & ~DPS_EXEC;
+ }
+
+ do {
+ integer bump = 0;
+ if (result->count == 0) return;
+ switch (result->type) {
+ case dps_tBoolean:
+ if (type == DPS_BOOL) {
+ int *b = (int *) result->value;
+ *b = (int) obj->val.booleanVal;
+ bump = sizeof(int);
+ }
+ break;
+ case dps_tFloat: {
+ float *f = (float *) result->value;
+ if (type == DPS_REAL) {
+ *f = obj->val.realVal;
+ bump = sizeof(float);
+ }
+ else if (type == DPS_INT) {
+ *f = (float) obj->val.integerVal;
+ bump = sizeof(float);
+ }
+ break;
+ }
+ case dps_tDouble: {
+ double *d = (double *) result->value;
+ if (type == DPS_REAL) {
+ *d = (double) obj->val.realVal;
+ bump = sizeof(double);
+ }
+ else if (type == DPS_INT) {
+ *d = (double) obj->val.integerVal;
+ bump = sizeof(double);
+ }
+ break;
+ }
+ case dps_tShort:
+ if (type == DPS_INT) {
+ short *s = (short *) result->value;
+ *s = (short) obj->val.integerVal;
+ bump = sizeof(short);
+ }
+ break;
+ case dps_tUShort:
+ if (type == DPS_INT) {
+ unsigned short *us = (unsigned short *) result->value;
+ *us = (unsigned short) obj->val.integerVal;
+ bump = sizeof(unsigned short);
+ }
+ break;
+ case dps_tInt:
+ if (type == DPS_INT) {
+ int *i = (int *) result->value;
+ *i = (int) obj->val.integerVal;
+ bump = sizeof(int);
+ }
+ break;
+ case dps_tUInt:
+ if (type == DPS_INT) {
+ unsigned int *ui = (unsigned int *) result->value;
+ *ui = (unsigned int) obj->val.integerVal;
+ bump = sizeof(unsigned int);
+ }
+ break;
+ case dps_tLong:
+ if (type == DPS_INT) {
+ long int *li = (long int *) result->value;
+ *li = obj->val.integerVal;
+ bump = sizeof(long int);
+ }
+ break;
+ case dps_tULong:
+ if (type == DPS_INT) {
+ unsigned long *u = (unsigned long *) result->value;
+ *u = (unsigned long) obj->val.integerVal;
+ bump = sizeof(unsigned long);
+ }
+ break;
+ case dps_tChar:
+ case dps_tUChar:
+ if (nObjs != 1) {
+ DPSSafeSetLastNameIndex(ctxt);
+ if (ctxt->errorProc != NIL)
+ (*ctxt->errorProc)(ctxt, dps_err_resultTypeCheck, (long unsigned)obj, 0);
+ }
+ else if (type == DPS_STRING) {
+ if (result->count == -1) {
+ /* char * result, copy first, ignore subsequent, null terminate */
+ os_bcopy(((integer)(obj->val.stringVal)) + (char *)obj,
+ result->value, obj->length);
+ (result->value)[obj->length] = '\0';
+ result->count = 0;
+ }
+ else {
+ unsigned slen;
+ if (result->count >= (int) obj->length) {
+ /* copy entire string into char array */
+ slen = obj->length;
+ }
+ else if (result->count > 0) {
+ /* copy partial string into char array */
+ slen = result->count;
+ }
+ else return; /* ignore string result, no room left */
+ os_bcopy(((integer)(obj->val.stringVal)) + (char *)obj,
+ result->value, slen);
+ result->value += slen;
+ result->count -= slen;
+ }
+ return;
+ }
+ break;
+
+ default:
+ DPSSafeSetLastNameIndex(ctxt);
+ if (ctxt->errorProc != NIL)
+ (*ctxt->errorProc)(ctxt, dps_err_resultTypeCheck, (long unsigned)obj, 0);
+ } /* switch (result->type) */
+
+ if (bump == 0) {
+ DPSSafeSetLastNameIndex(ctxt);
+ if (ctxt->errorProc != NIL)
+ (*ctxt->errorProc)(ctxt, dps_err_resultTypeCheck, (long unsigned)obj, 0);
+ return;
+ }
+ if (result->count != -1) {
+ result->count--;
+ result->value += bump;
+ }
+ obj += 1;
+ nObjs--;
+ } while (nObjs > 0); /* do */
+
+} /* StuffResultVal */
+
+
+static void NumFormatFromTokenType(
+ unsigned char t,
+ DPSNumFormat *numFormat)
+{
+ switch (t) {
+ case DPS_HI_IEEE:
+ *numFormat = dps_ieee;
+ break;
+ case DPS_LO_IEEE:
+ *numFormat = dps_ieee;
+ break;
+ case DPS_HI_NATIVE:
+ *numFormat = dps_native;
+ break;
+ case DPS_LO_NATIVE:
+ *numFormat = dps_native;
+ break;
+ default: DPSCantHappen();
+ }
+}
+
+
+#if !IEEEFLOAT
+/* called to deal with results from the server */
+static void ConvSeqInPlace(nObjs, currObj, base, tokenType)
+ integer nObjs;
+ DPSBinObj currObj;
+ char *base;
+ unsigned char tokenType;
+{
+ DPSNumFormat numFormat;
+
+ NumFormatFromTokenType(tokenType, &numFormat);
+
+ while (nObjs--) {
+ unsigned char t = currObj->attributedType & 0x07f;
+ integer i;
+ switch (t) {
+ case DPS_REAL: {
+ float f;
+ if (numFormat == dps_ieee) {
+ if (DPSDefaultByteOrder == dps_hiFirst)
+ IEEEHighToNative(&currObj->val.realVal, &f);
+ else
+ IEEELowToNative(&currObj->val.realVal, &f);
+ }
+ else break; /* switch */
+ currObj->val.realVal = f;
+ break;
+ }
+ case DPS_ARRAY:
+ if (currObj->length > 0)
+ ConvSeqInPlace(currObj->length, (DPSBinObj)(base + currObj->val.arrayVal), base, tokenType);
+ break;
+ case DPS_NAME:
+ case DPS_STRING:
+ break;
+ default:;
+ } /* end switch */
+ ++currObj;
+ } /* end while */
+}
+#endif /* !IEEEFLOAT */
+
+boolean DPSKnownContext(DPSContext ctxt)
+{
+ DPSPrivContext cc, c = (DPSPrivContext) ctxt;
+ DPSPrivSpace ss;
+ for (ss = spaces; ss != NIL; ss = ss->next)
+ for (cc = ss->firstContext; cc != NIL; cc = cc->next)
+ if (cc == c) return true;
+ return false;
+}
+
+boolean DPSKnownSpace(DPSSpace space)
+{
+ DPSPrivSpace ss, s = (DPSPrivSpace) space;
+ for (ss = spaces; ss != NIL; ss = ss->next)
+ if (ss == s) return true;
+ return false;
+}
+
+void DPSclientPrintProc (
+ DPSContext ctxt,
+ char *buf,
+ unsigned nch)
+{
+ DPSPrivContext cc = (DPSPrivContext) ctxt;
+
+#define DPS_SEQ_MIN 2
+
+ DPSCheckInitClientGlobals();
+ if (cc == NIL) cc = (DPSPrivContext)dummyCtx;
+ if (cc == NIL) return;
+
+ if (nch == 0) { /* this is an EOF */
+ DPSAssertWarn(buf == NIL, cc, "non-nil output buffer with 0 length");
+ cc->eofReceived = true;
+ if (cc->objBuf) {
+ /* we were buffering; drop buffered chars on the floor */
+ free(cc->objBuf);
+ cc->objBuf = NIL;
+ cc->nObjBufChars = 0;
+ }
+ }
+ while (nch > 0) {
+ char *oldBuf = NIL;
+ unsigned oldNch = 0;
+ unsigned n;
+ if (cc->objBuf) { /* we're buffering */
+ unsigned long int m;
+ char *b = cc->objBuf + cc->nObjBufChars;
+ integer minSize;
+ while (cc->nObjBufChars < DPS_SEQ_MIN) {
+ if (nch == 0) return;
+ *b++ = *buf++;
+ ++cc->nObjBufChars;
+ --nch;
+ }
+ b = cc->objBuf;
+ minSize = (*(b+1) == 0) ? DPS_EXT_HEADER_SIZE : DPS_HEADER_SIZE;
+ if (cc->nObjBufChars < minSize) {
+ if (nch + cc->nObjBufChars < (unsigned) minSize) {
+ os_bcopy(buf, b + cc->nObjBufChars, nch);
+ cc->nObjBufChars += nch;
+ return;
+ }
+ else {
+ os_bcopy(buf, b + cc->nObjBufChars, minSize - cc->nObjBufChars);
+ buf += minSize - cc->nObjBufChars;
+ nch -= minSize - cc->nObjBufChars;
+ cc->nObjBufChars = minSize;
+ }
+ }
+
+ if (minSize == DPS_HEADER_SIZE) {
+ unsigned short *sizeP = (unsigned short *)(cc->objBuf+2);
+ m = *sizeP;
+ }
+ else {
+ unsigned long *extSizeP = (unsigned long *)(cc->objBuf+4);
+ m = *extSizeP;
+ }
+
+ /* here with m = BOS total length in bytes, b = cc->objBuf */
+ cc->objBuf = (char *)realloc(b, m);
+
+ if (nch + cc->nObjBufChars < m) {
+ os_bcopy(buf, cc->objBuf + cc->nObjBufChars, nch);
+ cc->nObjBufChars += nch;
+ return;
+ }
+ else {
+ os_bcopy(buf, cc->objBuf + cc->nObjBufChars, m - cc->nObjBufChars);
+ buf += m - cc->nObjBufChars;
+ nch -= m - cc->nObjBufChars;
+ cc->nObjBufChars = m;
+ }
+ /* we're here only if cc->objBuf contains a complete BOS */
+ oldBuf = buf;
+ oldNch = nch;
+ buf = cc->objBuf;
+ nch = cc->nObjBufChars;
+ cc->objBuf = NIL;
+ cc->nObjBufChars = 0;
+ } /* if we're buffering */
+
+ /* dispose of any plain text. If no binary conversion, all output
+ is plain text */
+ if (cc->contextFlags & DPS_FLAG_NO_BINARY_CONVERSION) n = nch;
+ else {
+ for (n = 0; n < nch &&
+ ((unsigned char) buf[n] < 128 || (unsigned char) buf[n] > 159); n++);
+ }
+ if ((n > 0) && (cc->textProc != NIL)) {
+ (*cc->textProc)((DPSContext)cc, buf, n);
+ }
+ buf += n;
+ nch -= n;
+
+ if (nch != 0) {
+ /* here with the next binary object sequence from a server */
+ DPSExtendedBinObjSeq bos;
+ DPSExtendedBinObjSeqRec bosRec;
+ DPSBinObj firstObj;
+ unsigned t;
+ unsigned long int m;
+ unsigned minSize;
+
+ if (nch < DPS_SEQ_MIN) {
+ /* gotta buffer it */
+ DPSAssertWarn(nch == 1 && !oldBuf, cc, "illegal binary output from context (oldBuf)");
+ cc->objBuf = (char *)DPScalloc(DPS_EXT_HEADER_SIZE, 1);
+ cc->nObjBufChars = nch;
+ *cc->objBuf = *buf;
+ return;
+ }
+ /* check for quadbyte alignment */
+ if ((long int)buf & (MIN_POINTER_ALIGN - 1)) {
+ /* not aligned, we gotta copy the buffer */
+ /* we assert that we can't have an oldBuf if we're not aligned,
+ since we only get an oldBuf if we copied to a new buffer,
+ and we have already tested nch to be at least DPS_SEQ_MIN */
+ DPSAssertWarn(!oldBuf && nch > 1, cc, "return values garbled (oldBuf||nch<DPS_SEQ_MIN");
+ /* copy DPS_SEQ_MIN bytes, so we can use existing buffering code */
+ cc->objBuf = (char *)DPScalloc(DPS_EXT_HEADER_SIZE, 1);
+ cc->nObjBufChars = DPS_SEQ_MIN;
+ os_bcopy(buf, cc->objBuf, cc->nObjBufChars);
+ buf += DPS_SEQ_MIN;
+ nch -= DPS_SEQ_MIN;
+ /* now go to top of loop and go through the buffer update code */
+ continue;
+ }
+ bos = (DPSExtendedBinObjSeq) buf;
+ t = bos->tokenType;
+ minSize = (bos->escape == 0) ? DPS_EXT_HEADER_SIZE : DPS_HEADER_SIZE;
+ if (nch < minSize) {
+ /* gotta buffer it */
+ char *tb;
+ DPSAssertWarn(!oldBuf, cc, "return values garbled (oldBuf)");
+ tb = cc->objBuf = (char *)DPScalloc(minSize, 1);
+ cc->nObjBufChars = nch;
+ while (nch--) *tb++ = *buf++;
+ return;
+ }
+ else if (minSize == DPS_HEADER_SIZE) {
+ /* this is not an extended BOS */
+ DPSBinObjSeq seqHead = (DPSBinObjSeq) buf;
+ bos = &bosRec;
+ bos->tokenType = t;
+ bos->nTopElements = seqHead->nTopElements;
+ bos->length = seqHead->length;
+ firstObj = &(seqHead->objects[0]);
+ }
+ else firstObj = &(bos->objects[0]);
+ m = bos->length;
+ if (nch < m) {
+ /* gotta buffer it */
+ DPSAssertWarn(!oldBuf, cc, "return values garbled (oldBuf&&nch<m");
+ cc->objBuf = (char *)DPScalloc(bos->length, 1);
+ cc->nObjBufChars = nch;
+ os_bcopy(buf, cc->objBuf, nch);
+ return;
+ }
+ DPSAssertWarn(bos->nTopElements == 1, cc, "illegal binary output detected (bos->nTopElements!=1)");
+#if !IEEEFLOAT
+ if (t != DPS_DEF_TOKENTYPE)
+ ConvSeqInPlace(1, firstObj, firstObj, bos->tokenType);
+#endif /* !IEEEFLOAT */
+ t = firstObj->tag;
+ if (t == DPS_ERR_TAG) {
+ cc->resultTable = NIL;
+ DPSSafeSetLastNameIndex((DPSContext)cc);
+ DURING
+ if (cc->errorProc != NIL)
+ (*cc->errorProc)((DPSContext)cc, dps_err_ps, (unsigned long)buf, m);
+ HANDLER
+ if (oldBuf) free(buf);
+ RERAISE;
+ END_HANDLER
+ }
+ else { /* dispatch this result */
+ if (!cc->resultTable || t > cc->resultTableLength) {
+ if (cc->chainParent == NIL && cc->errorProc != NIL) {
+ DPSSafeSetLastNameIndex((DPSContext)cc);
+ (*cc->errorProc)((DPSContext)cc, dps_err_resultTagCheck, (unsigned long)buf, m);
+ }
+ }
+ else if (t == cc->resultTableLength) {
+ cc->resultTable = NIL;
+ }
+ else {
+ StuffResultVal((DPSContext)cc, &cc->resultTable[t], t, firstObj);
+ }
+ }
+ if (!oldBuf)
+ buf += m;
+ nch -= m;
+ } /* if (nch != 0) ... the next binary object sequence from a server */
+ if (oldBuf) {
+ DPSAssertWarn(nch == 0, cc, "some return values/data lost (nch)");
+ free(buf);
+ buf = oldBuf;
+ nch = oldNch;
+ }
+ } /* while (nch > 0) */
+
+} /* DPSclientPrintProc */
+
+/**************************************/
+/* Context procs for DPSCreateContext */
+/**************************************/
+
+
+static void procWaitContext(DPSContext ctxt)
+{
+ typedef struct {
+ unsigned char tokenType;
+ unsigned char topLevelCount;
+ unsigned short int nBytes;
+
+ DPSBinObjGeneric obj0;
+ DPSBinObjGeneric obj1;
+ DPSBinObjGeneric obj2;
+ DPSBinObjGeneric obj3;
+ } DPSQ;
+ static DPSQ dpsF = {
+ DPS_DEF_TOKENTYPE, 4, sizeof(DPSQ),
+ {DPS_LITERAL|DPS_INT, 0, 0, -23}, /* arbitrary int */
+ {DPS_LITERAL|DPS_INT, 0, 0, 0}, /* termination tag = 0 */
+ {DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 119}, /* printobject */
+ {DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 70}, /* flush */
+ }; /* DPSQ */
+ DPSResultsRec DPSR;
+
+ if (DPSPrivateCheckWait(ctxt)) return;
+
+ ctxt->resultTable = &DPSR; /* must be non-null for handler to work */
+ ctxt->resultTableLength = 0; /* same value as termination tag */
+ DPSBinObjSeqWrite(ctxt, (char *) &dpsF,sizeof(DPSQ));
+ DPSAwaitReturnValues(ctxt);
+}
+
+static void procUpdateNameMap(DPSContext ctxt)
+{
+ integer i;
+ DPSPrivContext c = (DPSPrivContext) ctxt;
+ DPSPrivSpace s = (DPSPrivSpace) ctxt->space;
+ DPSContext children = ctxt->chainChild;
+
+ /* unlink context from chain temporarily, so DPSPrintf can be called */
+ if (children != NIL) ctxt->chainChild = NIL;
+ DURING
+ for (i = s->lastNameIndex+1; i <= globLastNameIndex; i++)
+ DPSPrintf(ctxt, "%d /%s defineusername\n", i, userNames[i]);
+ HANDLER
+ if (children != NIL) ctxt->chainChild = children;
+ RERAISE;
+ END_HANDLER
+ c->lastNameIndex = globLastNameIndex;
+ if (children != NIL) {
+ /* update any children */
+ ctxt->chainChild = children;
+ DPSUpdateNameMap(ctxt->chainChild);
+ }
+}
+
+static void procWriteData(
+ DPSContext ctxt,
+ char *buf,
+ unsigned int count)
+{
+ /* safe to call with chain */
+ DPSinnerProcWriteData(ctxt, buf, count);
+ if (ctxt->chainChild != NIL) DPSWriteData(ctxt->chainChild, buf, count);
+}
+
+static void procBinObjSeqWrite(
+ DPSContext ctxt,
+ char *buf,
+ unsigned int count)
+{
+ if (((DPSPrivContext)ctxt)->lastNameIndex < globLastNameIndex) DPSUpdateNameMap(ctxt);
+ DPSinnerProcWriteData(ctxt, buf, count);
+ if (ctxt->chainChild != NIL) DPSBinObjSeqWrite(ctxt->chainChild, buf, count);
+}
+
+static void procWriteStringChars(
+ DPSContext ctxt,
+ char *buf,
+ unsigned int count)
+{
+ DPSinnerProcWriteData(ctxt, buf, count);
+ if (ctxt->chainChild != NIL) DPSWriteStringChars(ctxt->chainChild, buf, count);
+}
+
+static void procWritePostScript(
+ DPSContext ctxt,
+ char *buf,
+ unsigned int count)
+{
+ DPSinnerProcWriteData(ctxt, buf, count);
+ if (ctxt->chainChild != NIL) DPSWritePostScript(ctxt->chainChild, buf, count);
+}
+
+static void innerProcWriteNumstring(
+ DPSContext ctxt,
+ DPSDefinedType type,
+ char *data,
+ unsigned int size,
+ int scale,
+ void (*writeProc)(DPSContext, char *, unsigned))
+{
+ unsigned char HNumHeader[4];
+ register int i;
+#define NBUFSIZE 10
+ int ibuf[NBUFSIZE]; /* This needs to be a 32 bit datatype */
+
+ HNumHeader[0] = 149;
+ switch (type) {
+ case dps_tLong:
+ HNumHeader[1] = (DPS_DEF_TOKENTYPE % 2) * 128 + scale;
+ break;
+
+ case dps_tInt:
+ HNumHeader[1] = ((sizeof(int) >= 4) ? 0 : 32)
+ + ((DPS_DEF_TOKENTYPE % 2) * 128) + scale;
+ break;
+
+ case dps_tShort:
+ HNumHeader[1] = 32 + ((DPS_DEF_TOKENTYPE % 2) * 128) + scale;
+ break;
+
+ case dps_tFloat:
+ HNumHeader[1] = 48 + ((DPS_DEF_TOKENTYPE % 2) * 128)
+ + ((DPS_DEF_TOKENTYPE >= 130) ? 1 : 0);
+ break;
+
+ default:
+ break;
+ }
+
+ HNumHeader[(DPS_DEF_TOKENTYPE % 2) ? 2 : 3] = (unsigned char) size;
+ HNumHeader[(DPS_DEF_TOKENTYPE % 2) ? 3 : 2] = (unsigned char) (size >> 8);
+
+ (*writeProc)(ctxt, (char *)HNumHeader, 4);
+
+ switch (type) {
+ case dps_tLong:
+ if (sizeof(long) == 4) {
+ (*writeProc)(ctxt, (char *) data, size * 4);
+ } else {
+ while (size > 0) {
+ for (i = 0; i < NBUFSIZE && (unsigned) i < size; i++) {
+ ibuf[i] = ((long *) data)[i];
+ }
+ (*writeProc)(ctxt, (char *) ibuf,
+ 4 * (size < NBUFSIZE ? size : NBUFSIZE));
+ size -= NBUFSIZE;
+ }
+ }
+ break;
+
+ case dps_tInt:
+ (*writeProc)(ctxt, (char *) data, size * sizeof(int));
+ break;
+
+ case dps_tShort:
+ (*writeProc)(ctxt, (char *) data, size * sizeof(short));
+ break;
+
+ case dps_tFloat:
+ (*writeProc)(ctxt, (char *) data, size * sizeof(float));
+
+ default:
+ break;
+ }
+} /* innerProcWriteNumstring */
+
+static void procWriteNumstring(
+ DPSContext ctxt,
+ DPSDefinedType type,
+ char *data,
+ unsigned int size,
+ int scale)
+{
+ innerProcWriteNumstring(ctxt, type, data, size, scale, DPSinnerProcWriteData);
+ if (ctxt->chainChild != NIL) DPSWriteNumString(ctxt->chainChild, type, data, size, scale);
+}
+
+static void writeTypedObjectArray(
+ DPSContext ctxt,
+ DPSDefinedType type,
+ char *array,
+ unsigned int length)
+{
+
+#define DPSMAX_SEQ 10
+ unsigned int i;
+ DPSPrivContext c = (DPSPrivContext)(ctxt);
+ static DPSBinObjGeneric bboolObj[DPSMAX_SEQ] = {
+ {DPS_LITERAL | DPS_BOOL, 0,0,0},
+ {DPS_LITERAL | DPS_BOOL, 0,0,0},
+ {DPS_LITERAL | DPS_BOOL, 0,0,0},
+ {DPS_LITERAL | DPS_BOOL, 0,0,0},
+ {DPS_LITERAL | DPS_BOOL, 0,0,0},
+ {DPS_LITERAL | DPS_BOOL, 0,0,0},
+ {DPS_LITERAL | DPS_BOOL, 0,0,0},
+ {DPS_LITERAL | DPS_BOOL, 0,0,0},
+ {DPS_LITERAL | DPS_BOOL, 0,0,0},
+ {DPS_LITERAL | DPS_BOOL, 0,0,0},
+ };
+ static DPSBinObjReal rrealObj[DPSMAX_SEQ] = {
+ {DPS_LITERAL | DPS_REAL, 0,0,0},
+ {DPS_LITERAL | DPS_REAL, 0,0,0},
+ {DPS_LITERAL | DPS_REAL, 0,0,0},
+ {DPS_LITERAL | DPS_REAL, 0,0,0},
+ {DPS_LITERAL | DPS_REAL, 0,0,0},
+ {DPS_LITERAL | DPS_REAL, 0,0,0},
+ {DPS_LITERAL | DPS_REAL, 0,0,0},
+ {DPS_LITERAL | DPS_REAL, 0,0,0},
+ {DPS_LITERAL | DPS_REAL, 0,0,0},
+ {DPS_LITERAL | DPS_REAL, 0,0,0},
+ };
+ static DPSBinObjGeneric iintObj[DPSMAX_SEQ] = {
+ {DPS_LITERAL | DPS_INT, 0,0,0},
+ {DPS_LITERAL | DPS_INT, 0,0,0},
+ {DPS_LITERAL | DPS_INT, 0,0,0},
+ {DPS_LITERAL | DPS_INT, 0,0,0},
+ {DPS_LITERAL | DPS_INT, 0,0,0},
+ {DPS_LITERAL | DPS_INT, 0,0,0},
+ {DPS_LITERAL | DPS_INT, 0,0,0},
+ {DPS_LITERAL | DPS_INT, 0,0,0},
+ {DPS_LITERAL | DPS_INT, 0,0,0},
+ {DPS_LITERAL | DPS_INT, 0,0,0},
+ };
+
+ if (DPSCheckShared(c)) return;
+
+ switch (type) {
+ case dps_tChar:
+ case dps_tUChar:
+ DPSCantHappen();
+ break;
+
+ case dps_tBoolean: {
+ while (length > 0) {
+ for (i = 0; i < MIN(DPSMAX_SEQ, length); i++) {
+ bboolObj[i].val = *((int *)array);
+ array += sizeof(int);
+ }
+ DPSWritePostScript(ctxt, (char *) bboolObj, sizeof(DPSBinObjGeneric) * i);
+ length -= i;
+ }
+ break;
+ }
+
+ case dps_tFloat: {
+ while (length > 0) {
+ for (i = 0; i < MIN(DPSMAX_SEQ, length); i++) {
+ rrealObj[i].realVal = *((float *)array);
+ array += sizeof(float);
+ }
+ DPSWritePostScript(ctxt, (char *) rrealObj, sizeof(DPSBinObjReal) * i);
+ length -= i;
+ }
+ break;
+ }
+
+ case dps_tDouble: {
+ while (length > 0) {
+ for (i = 0; i < MIN(DPSMAX_SEQ, length); i++) {
+ rrealObj[i].realVal = *((double *)array);
+ array += sizeof(double);
+ }
+ DPSWritePostScript(ctxt, (char *) rrealObj, sizeof(DPSBinObjReal) * i);
+ length -= i;
+ }
+ break;
+ }
+
+ case dps_tShort: {
+ while (length > 0) {
+ for (i = 0; i < MIN(DPSMAX_SEQ, length); i++) {
+ iintObj[i].val = *((short *)array);
+ array += sizeof(short);
+ }
+ DPSWritePostScript(ctxt, (char *) iintObj, sizeof(DPSBinObjGeneric) * i);
+ length -= i;
+ }
+ break;
+ }
+
+ case dps_tUShort: {
+ while (length > 0) {
+ for (i = 0; i < MIN(DPSMAX_SEQ, length); i++) {
+ iintObj[i].val = *((unsigned short *)array);
+ array += sizeof(unsigned short);
+ }
+ DPSWritePostScript(ctxt, (char *) iintObj, sizeof(DPSBinObjGeneric) * i);
+ length -= i;
+ }
+ break;
+ }
+
+ case dps_tInt: {
+ while (length > 0) {
+ for (i = 0; i < MIN(DPSMAX_SEQ, length); i++) {
+ iintObj[i].val = *((int *)array);
+ array += sizeof(int);
+ }
+ DPSWritePostScript(ctxt, (char *) iintObj, sizeof(DPSBinObjGeneric) * i);
+ length -= i;
+ }
+ break;
+ }
+
+ case dps_tUInt: {
+ while (length > 0) {
+ for (i = 0; i < MIN(DPSMAX_SEQ, length); i++) {
+ iintObj[i].val = *((unsigned int *)array);
+ array += sizeof(unsigned int);
+ }
+ DPSWritePostScript(ctxt, (char *) iintObj, sizeof(DPSBinObjGeneric) * i);
+ length -= i;
+ }
+ break;
+ }
+
+ case dps_tLong: {
+ while (length > 0) {
+ for (i = 0; i < MIN(DPSMAX_SEQ, length); i++) {
+ iintObj[i].val = *((long *)array);
+ array += sizeof(long);
+ }
+ DPSWritePostScript(ctxt, (char *) iintObj, sizeof(DPSBinObjGeneric) * i);
+ length -= i;
+ }
+ break;
+ }
+
+ case dps_tULong: {
+ while (length > 0) {
+ for (i = 0; i < MIN(DPSMAX_SEQ, length); i++) {
+ iintObj[i].val = *((unsigned long *)array);
+ array += sizeof(unsigned long);
+ }
+ DPSWritePostScript(ctxt, (char *) iintObj, sizeof(DPSBinObjGeneric) * i);
+ length -= i;
+ }
+ break;
+
+
+ }
+
+ default:;
+ }
+} /* writeTypedObjectArray */
+
+static void procDestroyContext(DPSContext ctxt)
+{
+ DPSPrivContext c = (DPSPrivContext)ctxt, cc, prev;
+ DPSPrivSpace ss = (DPSPrivSpace)(c->space);
+
+ if (c->buf != NIL) {
+ ContextBuffer b = (ContextBuffer)(c->buf);
+ b->next = contextBuffers;
+ contextBuffers = b;
+ c->buf = NIL;
+ }
+ if (c->objBuf != NIL) {
+ free(c->objBuf);
+ c->objBuf = NIL;
+ }
+
+ DPSUnchainContext(ctxt);
+
+ prev = NIL;
+ DPSAssert(ss != NIL);
+ for (cc = ss->firstContext; (cc != NIL) && (cc != c); cc = cc->next)
+ prev = cc;
+ DPSAssert(cc != NIL);
+ DPSAssert(cc != prev);
+ if (prev == NIL) ss->firstContext = cc->next;
+ else {
+ prev->next = cc->next;
+ DPSAssert(prev->next != prev);
+ }
+
+ DPSPrivateDestroyContext(ctxt);
+ free(c);
+}
+
+static void procDestroySpace(DPSSpace space)
+{
+ DPSPrivSpace ns, prevS, ss = (DPSPrivSpace)space;
+ integer sid = ss->sid;
+
+ while (ss->firstContext != NIL)
+ DPSDestroyContext((DPSContext)(ss->firstContext));
+
+ prevS = NIL;
+ for (ns = spaces; (ns != NIL) && (ns->sid != sid); ns = ns->next)
+ prevS = ns;
+ DPSAssert(ns != NIL);
+ DPSAssert(ns == ss);
+ if (prevS == NIL) spaces = ns->next;
+ else {
+ prevS->next = ns->next;
+ DPSAssert(prevS->next != prevS);
+ }
+
+ DPSPrivateDestroySpace(space);
+ free(ss);
+}
+
+static void procInterrupt(DPSContext ctxt)
+{
+ DPSPrivContext c = (DPSPrivContext)ctxt;
+ DPSSendInterrupt((XDPSPrivContext)c->wh, c->cid, DPSclientPrintProc);
+ if (ctxt->chainChild != NIL) DPSInterruptContext(ctxt->chainChild);
+}
+
+
+/****************************************************************/
+/* Procedures that support the DPSCreateTextContext context procs */
+/****************************************************************/
+
+/* precondition: (c >= 129 && c <= 159), which means that c is the
+ first byte of either a binary token or a binary object sequence */
+
+static boolean IsBinaryToken(unsigned char c)
+{
+ return (c != DPS_HI_IEEE && c != DPS_LO_IEEE
+ && c != DPS_HI_NATIVE && c != DPS_LO_NATIVE);
+}
+
+/* returns the number of initial bytes of a given goody that are
+ required to figure out how many bytes are needed for the entire goody */
+
+static unsigned GetHdrNBytes(unsigned char *t)
+{
+ if (!IsBinaryToken(*t)) {
+ if (*(++t) == 0) return DPS_EXT_HEADER_SIZE;
+ else return DPS_HEADER_SIZE;
+ }
+ switch (*t) {
+ case 137:
+ case 142:
+ return(2);
+ case 143:
+ case 144:
+ return(3);
+ case 149:
+ return(4);
+ default:
+ if (*t > 149 && *t < 160) return(1); /* unassigned */
+ else return(1);
+ }
+}
+
+
+static void WriteHomogeneousArrayAsASCII(
+ DPSContext ctxt,
+ register unsigned char *buf)
+{
+ Swap32Rec n32;
+ Swap16Rec n16;
+ register unsigned char *b;
+
+ unsigned char r = *buf++;
+ float f;
+ boolean hi = (r < 128);
+
+ if (!hi) r -= 128;
+ DPSPrintf(ctxt, "[ ");
+ b = n16.bytes;
+ if (hi) {Copy2SrcHi(buf, b);} else {Copy2SrcLo(buf, b);}
+ buf += 2;
+ if (r < 32) /* 32-bit fixed */
+ while (n16.u--) {
+ b = n32.bytes;
+ if (hi) {Copy4SrcHi(buf, b);} else {Copy4SrcLo(buf, b);}
+ if (r == 0)
+ DPSPrintf(ctxt, "%d ", n32.i);
+ else {
+ f = n32.i; /* convert to float */
+ n32.f = f / (1 << r); /* scale */
+ DPSPrintf(ctxt, "%g ", n32.f);
+ }
+ buf += 4;
+ }
+ else if (r < 48) { /* 16-bit fixed */
+ unsigned l = n16.u;
+ r -= 32;
+ while (l--) {
+ b = n16.bytes;
+ if (hi) {Copy2SrcHi(buf, b);} else {Copy2SrcLo(buf, b);}
+ if (r == 0)
+ DPSPrintf(ctxt, "%d ", n16.i);
+ else {
+ f = n16.i; /* convert to float */
+ n32.f = f / (1 << r); /* scale */
+ DPSPrintf(ctxt, "%g ", n32.f);
+ }
+ buf += 2;
+ }
+ }
+ else if (r == 48) /* 32-bit IEEE */
+ while (n16.u--) {
+#if IEEEFLOAT
+ b = n32.bytes;
+ if (hi) {Copy4SrcHi(buf, b);} else {Copy4SrcLo(buf, b);}
+#else /* IEEEFLOAT */
+ if (hi) IEEEHighToNative(buf, &n32.f);
+ else IEEELowToNative(buf, &n32.f);
+#endif /* IEEEFLOAT */
+ DPSPrintf(ctxt, "%g ", n32.f);
+ buf += 4;
+ }
+ else if (r == 49) /* 32-bit native */
+ while (n16.u--) {
+ b = n32.bytes;
+ *b++ = *buf++,*b++ = *buf++,*b++ = *buf++,*b = *buf++;
+ DPSPrintf(ctxt, "%g ", n32.f);
+ }
+ else DPSCantHappen();
+ DPSPrintf(ctxt, "\n] ");
+} /* WriteHomogeneousArrayAsASCII */
+
+/* returns the number of bytes needed for the entire goody. buf points
+ to enough initial bytes of the goody to figure this out (see above). */
+
+static integer GetNBytes(register unsigned char *buf)
+{
+ unsigned short int nBytes;
+ register unsigned char *r = (unsigned char *)&nBytes;
+
+ switch (*buf) {
+ case DPS_HI_IEEE:
+ case DPS_HI_NATIVE:
+ if (*(buf+1) == 0) {
+ unsigned int nb;
+ r = (unsigned char *)&nb;
+ buf += 4;
+ Copy4SrcHi(buf, r);
+ return(nb);
+ }
+ else {
+ buf += 2;
+ Copy2SrcHi(buf, r);
+ }
+ break;
+ case DPS_LO_IEEE:
+ case DPS_LO_NATIVE:
+ if (*(buf+1) == 0) {
+ unsigned int nb;
+ r = (unsigned char *)&nb;
+ buf += 4;
+ Copy4SrcLo(buf, r);
+ return(nb);
+ }
+ else {
+ buf += 2;
+ Copy2SrcLo(buf, r);
+ }
+ break;
+ case 132:
+ case 133:
+ case 138:
+ case 139:
+ case 140:
+ nBytes = 5; break;
+ case 134:
+ case 135:
+ nBytes = 3; break;
+ case 136:
+ case 141:
+ case 145:
+ case 146:
+ case 147:
+ case 148:
+ nBytes = 2; break;
+ case 137: {
+ unsigned int l = *(buf+1);
+ if (l < 32) {nBytes = 6; break;}
+ if (l < 48) {nBytes = 4; break;}
+ if (l-128 < 32) {nBytes = 6; break;}
+ if (l-128 < 48) {nBytes = 4; break;}
+ DPSCantHappen();
+ }
+ case 142:
+ nBytes = *(buf+1);
+ nBytes += 2;
+ break;
+ case 143:
+ buf++;
+ Copy2SrcHi(buf, r);
+ nBytes += 3;
+ break;
+ case 144:
+ buf++;
+ Copy2SrcLo(buf, r);
+ nBytes += 3;
+ break;
+ case 149: {
+ unsigned char scale = *(buf+1);
+ buf += 2;
+ if (scale < 128)
+ Copy2SrcHi(buf, r);
+ else {
+ scale -= 128;
+ Copy2SrcLo(buf, r);
+ }
+ if (scale < 32)
+ nBytes *= 4;
+ else if (scale < 48)
+ nBytes *= 2;
+ else
+ nBytes *= 4;
+ nBytes += 4;
+ break;
+ }
+ default: nBytes = 1; /* unassigned */
+ }
+ return(nBytes);
+}
+
+static void WriteSeqAsAscii(
+ DPSContext ctxt,
+ char *base,
+ DPSBinObj currObj,
+ unsigned int nObjs,
+ unsigned char tokenType,
+ int *numstringOffsets)
+{
+ integer nLineObjs = 0;
+ DPSNumFormat numFormat;
+ float f;
+ long int i;
+ unsigned short int length;
+
+ /* NOTE: It's ok to call DPSPrintf (which calls DPSWritePostScript)
+ from here since we are only sending text, so there's no problem
+ with re-entering DPSWritePostScript. Caller guarantees
+ that this context has no children. */
+
+ NumFormatFromTokenType(tokenType, &numFormat);
+
+ while (nObjs--) {
+ unsigned char type = currObj->attributedType & ~DPS_EXEC;
+ boolean lit = ((currObj->attributedType & DPS_EXEC) == 0);
+
+ switch (type) {
+ case DPS_NULL:
+ break;
+ case DPS_BOOL:
+ i = currObj->val.booleanVal;
+ if (i)
+ DPSPrintf(ctxt, "true ");
+ else
+ DPSPrintf(ctxt, "false ");
+ break;
+ case DPS_INT:
+ i = currObj->val.integerVal;
+ DPSPrintf(ctxt, "%d ", i);
+ break;
+ case DPS_REAL:
+#if IEEEFLOAT
+ f = currObj->val.realVal;
+#else /* IEEEFLOAT */
+ if (numFormat != DPSDefaultNumFormat)
+#if SWAPBITS
+ IEEELowToNative(&currObj->val.realVal, &f);
+#else /* SWAPBITS */
+ IEEEHighToNative(&currObj->val.realVal, &f);
+#endif /* SWAPBITS */
+ else
+ f = currObj->val.realVal;
+#endif /* IEEEFLOAT */
+
+ DPSPrintf(ctxt, "%g ", f);
+ break;
+ case DPS_NAME: {
+ char *p = 0;
+ integer index;
+
+ index = currObj->val.nameVal;
+ length = currObj->length;
+
+ if (lit) DPSPrintf(ctxt, "/");
+
+ if (length == DPSSYSNAME) { /* system name index */
+ if (index <= DPS_LAST_COMMON_SYSNAME) {
+ if (!lit && (ctxt->contextFlags & DPS_FLAG_USE_ABBREVS)) {
+ p = DPSGetSysnameAbbrev(index);
+ if (p == NULL) p = DPSSysNames[index];
+ } else p = DPSSysNames[index];
+ } else if (DPS_FIRST_AUX_SYSNAME <= index
+ && index <= DPS_LAST_AUX_SYSNAME)
+ p = DPSSysNamesAux[index - DPS_FIRST_AUX_SYSNAME];
+ else DPSCantHappen();
+ length = strlen(p);
+ }
+ else if (length == 0) { /* user name index */
+ p = DPSNameFromIndex(index);
+ length = strlen(p);
+ }
+ else
+ p = base + index;
+
+ DPSWriteData(ctxt, p, length);
+ DPSPrintf(ctxt, " ");
+ break;
+ }
+ case DPS_ARRAY:
+ DPSPrintf(ctxt, (lit ? "[ " : "{ "));
+ WriteSeqAsAscii(
+ ctxt,
+ base,
+ (DPSBinObj)(base+currObj->val.arrayVal),
+ currObj->length,
+ tokenType, numstringOffsets);
+ DPSPrintf(ctxt, (lit ? " ] " : " } "));
+ break;
+ case DPS_MARK:
+ if (lit)
+ DPSPrintf(ctxt, "/mark ");
+ else
+ DPSPrintf(ctxt, "mark ");
+ break;
+ case DPS_STRING: {
+ char *p;
+ int j;
+ i = currObj->val.stringVal;
+ length = currObj->length;
+ p = base + i;
+ if (numstringOffsets != NULL) {
+ for (j = 2; j < numstringOffsets[1] &&
+ numstringOffsets[j] != i; j++) ;
+ if (numstringOffsets[j] == i) {
+ DPSAssert(*(unsigned char *) p++ == 149);
+ WriteHomogeneousArrayAsASCII(ctxt, (unsigned char *) p);
+ break;
+ }
+ }
+ DPSPrintf(ctxt, "(");
+#ifdef VMS
+ WriteVMSStringBody(ctxt, p, length); /* write this */
+#else /* VMS */
+ /* render string bytes correctly */
+ while (length--) {
+ char c = *p++;
+ if (c == '(' || c == ')' || c == '\\')
+ DPSPrintf(ctxt, "\\%c", c);
+ else if (c == '\n')
+ DPSPrintf(ctxt, "\\n");
+ else if (!(isascii(c) && isprint(c)))
+ DPSPrintf(ctxt, "\\%03.3o", (unsigned char) c);
+ else DPSWriteData(ctxt, &c, 1);
+ }
+#endif /* VMS */
+ DPSPrintf(ctxt, ") ");
+ break;
+ }
+ default: DPSCantHappen();
+ }
+
+ currObj++;
+ if (++nLineObjs == 15) {
+ nLineObjs = 0;
+ DPSPrintf(ctxt, "\n ");
+ }
+ } /* end while */
+
+ DPSPrintf(ctxt, "\n");
+
+} /* WriteSeqAsAscii */
+
+static void ConvertAndWriteSeqAsData(
+ DPSContext ctxt,
+ char *bosBuf,
+ int pass)
+{
+ DPSPrivContext cc = (DPSPrivContext) ctxt;
+ DPSExtendedBinObjSeq bos;
+ DPSExtendedBinObjSeqRec bosRec;
+ DPSNumFormat numFormat;
+ unsigned int offset, firstCharOffset;
+ unsigned int nameOffset;
+ unsigned int len = 0;
+ DPSBinObj currObj;
+ integer headSize;
+ char *seqBase;
+
+ if (*(bosBuf+1) != 0) {
+ /* not an extended BOS */
+ DPSBinObjSeq seqHead = (DPSBinObjSeq) bosBuf;
+ bos = &bosRec;
+ bos->tokenType = seqHead->tokenType;
+ bos->escape = seqHead->nTopElements;
+ bos->nTopElements = seqHead->nTopElements;
+ bos->length = seqHead->length;
+ currObj = &(seqHead->objects[0]);
+ seqBase = (char *) &(seqHead->objects[0]);
+ headSize = DPS_HEADER_SIZE;
+ }
+ else {
+ bos = (DPSExtendedBinObjSeq) bosBuf;
+ currObj = &(bos->objects[0]);
+ seqBase = (char *) &(bos->objects[0]);
+ headSize = DPS_EXT_HEADER_SIZE;
+ }
+ firstCharOffset = bos->length - headSize;
+ nameOffset = firstCharOffset;
+
+ /* Caller guarantees that this context has no children,
+ so it is okay to call DPSWriteData */
+
+ NumFormatFromTokenType(bos->tokenType, &numFormat);
+
+ /* Pass 0: If we're expanding name indices, find all name objects,
+ lookup their strings, sum the lengths.
+ Write the modified sequence header regardless.
+ Pass 1: we're converting indices to strings and/or
+ converting numbers. Write each modified object, and
+ subsidiary strings.
+ Pass 2: Find all name objects, lookup and write the strings. */
+
+ if (pass == 0 && ctxt->nameEncoding != dps_strings)
+ /* we're just converting numbers, so skip while loop */
+ offset = firstCharOffset;
+ else
+ offset = 0;
+
+ while (offset < firstCharOffset) {
+ DPSBinObjRec newObj;
+ unsigned char type = (currObj->attributedType & ~DPS_EXEC);
+
+ newObj = *currObj;
+
+#if !IEEEFLOAT
+ if (type == DPS_REAL) {
+ if (numFormat != cc->numFormat) {
+ if (numFormat == dps_ieee) {
+ if (DPSDefaultByteOrder == dps_loFirst)
+ IEEELowToNative(&currObj->val.realVal, &newObj.val.realVal);
+ else
+ IEEEHighToNative(&currObj->val.realVal, &newObj.val.realVal);
+ }
+ else { /* numFormat is native */
+ if (DPSDefaultByteOrder == dps_loFirst)
+ NativeToIEEELow(&currObj->val.realVal, &newObj.val.realVal);
+ else
+ NativeToIEEEHigh(&currObj->val.realVal, &newObj.val.realVal);
+ }
+ }
+ }
+#endif /* !IEEEFLOAT */
+
+ if (type == DPS_STRING && newObj.length > 0) {
+ /* keep track of where strings start */
+ firstCharOffset = ((unsigned) newObj.val.stringVal < firstCharOffset)
+ ? newObj.val.stringVal : firstCharOffset;
+ }
+ if (type == DPS_NAME) {
+ if (newObj.length == DPSSYSNAME) { /* system name index, never expand to string body */
+ if (pass != 1) goto next_obj;
+ }
+ else if (newObj.length == 0) { /* user name index */
+ register char *p = DPSNameFromIndex(newObj.val.nameVal);
+ switch (pass) {
+ case 0: len += strlen(p); goto next_obj;
+ case 1:
+ if (ctxt->nameEncoding == dps_strings) {
+ newObj.length = strlen(p);
+ newObj.val.nameVal = nameOffset;
+ nameOffset += newObj.length;
+ }
+ break;
+ case 2: DPSWriteData(ctxt, p, strlen(p)); goto next_obj;
+ default:;
+ }
+ }
+ else { /* name is already a string */
+ /* keep track of where strings start */
+ firstCharOffset = ((unsigned) newObj.val.nameVal < firstCharOffset)
+ ? newObj.val.nameVal : firstCharOffset;
+ }
+ } /* end if type == DPS_NAME */
+ if (pass == 1) {
+ DPSWriteData(ctxt, (char *) &newObj, sizeof(newObj));
+ }
+
+next_obj:
+ offset += sizeof(newObj);
+ ++currObj;
+ } /* end while */
+
+ /* finish pass */
+ switch (pass) {
+ case 0: {
+ unsigned char t;
+ /* write modified seqHead */
+ if (DPSDefaultByteOrder == dps_hiFirst && cc->numFormat == dps_ieee)
+ t = DPS_HI_IEEE;
+ else if (DPSDefaultByteOrder == dps_loFirst && cc->numFormat == dps_ieee)
+ t = DPS_LO_IEEE;
+ else if (DPSDefaultByteOrder == dps_hiFirst && cc->numFormat == dps_native)
+ t = DPS_HI_NATIVE;
+ else
+ t = DPS_LO_NATIVE;
+ DPSWriteData(ctxt, (char *) &t, 1);
+ if (headSize == DPS_HEADER_SIZE) {
+ unsigned short int nBytes;
+ unsigned char c = bos->nTopElements;
+ /* write top level count */
+ DPSWriteData(ctxt, (char *) &c, 1);
+ /* write nBytes */
+ nBytes = (ctxt->nameEncoding == dps_strings) ? bos->length + len :
+ bos->length;
+ DPSWriteData(ctxt, (char *)&nBytes, 2);
+ }
+ else {
+ unsigned int nBytes;
+ /* write escape code & top level count */
+ DPSWriteData(ctxt, (char *)&bos->escape, 3);
+ /* write nBytes */
+ nBytes = (ctxt->nameEncoding == dps_strings) ? bos->length + len :
+ bos->length;
+ DPSWriteData(ctxt, (char *)&nBytes, 4);
+ }
+ break;
+ }
+ case 1: {
+ char *stringStart = seqBase + firstCharOffset;
+ DPSWriteData(ctxt, stringStart, (bos->length - headSize - firstCharOffset));
+ break;
+ }
+ default:;
+ }
+
+} /* ConvertAndWriteSeqAsData */
+
+#define MIN16 -32768
+#define MAX16 32767
+
+/* TestHomogeneous will return a non-negative representation code 'r'
+ if all of the array elements are "integers", or all are "reals".
+ Will return -1 for any other case. */
+
+static integer TestHomogeneous(
+ DPSBinObj aryObj,
+ unsigned short length,
+ DPSNumFormat numFormat)
+{
+ integer tmp, r = -1;
+
+ while (length--) {
+ switch (aryObj->attributedType & ~DPS_EXEC) {
+ case DPS_INT:
+#if SWAPBITS
+ tmp = (aryObj->val.integerVal < MIN16
+ || aryObj->val.integerVal > MAX16) ? 128 : 128+32;
+#else /* SWAPBITS */
+ tmp = (aryObj->val.integerVal < MIN16
+ || aryObj->val.integerVal > MAX16) ? 0 : 32;
+#endif /* SWAPBITS */
+ if ((r == -1) || ((r & 0x07F) == 32 && (tmp & 0x07F) == 0))
+ r = tmp; /* first element, or was 16-bit => bump to 32-bit */
+ else if ((r & 0x07F) == 0 && (tmp & 0x07F) == 32)
+ goto bump_obj; /* is 32-bit => stay 32-bit */
+ else if (r != tmp)
+ return(-1);
+ /* else fall thru, r == tmp */
+ break;
+ case DPS_REAL:
+#if SWAPBITS
+ tmp = (numFormat == dps_ieee) ? 128+48 : 128+49;
+#else /* SWAPBITS */
+ tmp = (numFormat == dps_ieee) ? 48 : 49;
+#endif /* SWAPBITS */
+ if (r == -1)
+ r = tmp;
+ else if (r != tmp) return(-1);
+ break;
+ default: return(-1);
+ }
+bump_obj:
+ ++aryObj;
+ }
+ return(r);
+} /* TestHomogeneous */
+
+static void WriteSeqAsTokens(
+ DPSContext ctxt,
+ char *base,
+ DPSBinObj currObj,
+ unsigned int nObjs,
+ unsigned char tokenType,
+ int *numstringOffsets)
+{
+ int nLineObjs = 0;
+ DPSNumFormat numFormat;
+ unsigned short length;
+ Swap32Rec n32;
+ Swap16Rec n16;
+ unsigned char c;
+
+#define PB(byte) c = (byte),DPSWriteData(ctxt, (char *) &c, 1)
+#if SWAPBITS
+#define WTT(byte) PB((byte)+1)
+#else /* SWAPBITS */
+#define WTT(byte) PB(byte)
+#endif /* SWAPBITS */
+
+ NumFormatFromTokenType(tokenType, &numFormat);
+
+ while (nObjs--) {
+ unsigned char type = currObj->attributedType & ~DPS_EXEC;
+ boolean lit = ((currObj->attributedType & DPS_EXEC) == 0);
+
+ switch (type) {
+ case DPS_NULL:
+ break;
+ case DPS_BOOL:
+ PB(141); /* boolean */
+ if (currObj->val.booleanVal)
+ PB(true);
+ else
+ PB(false);
+ break;
+ case DPS_INT:
+ n32.i = currObj->val.integerVal;
+ if (n32.i < MIN16 || n32.i > MAX16) {
+ WTT(132); /* 32-bit int */
+ DPSWriteData(ctxt, (char *) n32.bytes, 4);
+ }
+ else if (n32.i < -128 || n32.i > 127) {
+ WTT(134); /* 16-bit int */
+ n16.i = n32.i;
+ DPSWriteData(ctxt, (char *) n16.bytes, 2);
+ }
+ else {
+ WTT(136); /* 8-bit int */
+ PB(n32.i);
+ }
+ break;
+ case DPS_REAL:
+#if IEEEFLOAT
+ WTT(138); /* 32-bit IEEE float */
+#else /* IEEEFLOAT */
+ if (numFormat != DPSDefaultNumFormat)
+ /* then it must be IEEE */
+ WTT(138); /* 32-bit IEEE float */
+ else
+ PB(140); /* 32-bit native float */
+#endif /* IEEEFLOAT */
+
+ DPSWriteData(ctxt, (char *) &currObj->val.realVal, 4);
+ break;
+ case DPS_NAME: {
+ char *p = 0;
+ integer index = currObj->val.nameVal;
+
+ length = currObj->length;
+ if (length == DPSSYSNAME) {/* system name index */
+ if (index >= 0 && index < 256) {
+ if (lit)
+ PB(145); /* literal system name */
+ else
+ PB(146); /* exec. system name */
+ PB(index);
+ goto next_obj;
+ }
+ else if (DPS_FIRST_AUX_SYSNAME <= index
+ && index <= DPS_LAST_AUX_SYSNAME)
+ p = DPSSysNamesAux[index - DPS_FIRST_AUX_SYSNAME];
+ else DPSCantHappen();
+ length = strlen(p);
+ }
+ else if (length == 0) { /* user name index */
+ if (ctxt->nameEncoding == dps_indexed && index < 256) {
+ if (lit)
+ PB(147); /* literal user name index */
+ else
+ PB(148); /* executable user name index */
+ PB(index);
+ goto next_obj;
+ }
+ else {
+ p = DPSNameFromIndex(index);
+ length = strlen(p);
+ }
+ }
+ else
+ p = base + index;
+ if (lit) DPSPrintf(ctxt, "/");
+ DPSWriteData(ctxt, p, length);
+ DPSPrintf(ctxt, " ");
+ break;
+ }
+ case DPS_ARRAY: {
+ DPSBinObj aryObj = (DPSBinObj)(base+currObj->val.arrayVal);
+ integer r;
+ length = currObj->length;
+ if (lit && (r = TestHomogeneous(aryObj, length, numFormat)) != -1) {
+ PB(149); /* homogeneous number array */
+ PB(r);
+ DPSWriteData(ctxt, (char *) &length, 2);
+ if (r > 127) r -= 128;
+ while (length--) {
+ switch (r) {
+ case 0:
+ DPSWriteData(ctxt, (char *) &aryObj->val.integerVal, 4);
+ break;
+ case 32:
+ n16.i = aryObj->val.integerVal;
+ DPSWriteData(ctxt, (char *) n16.bytes, 2);
+ break;
+ case 48:
+ case 49:
+ DPSWriteData(ctxt, (char *) &aryObj->val.realVal, 4);
+ break;
+ default: DPSCantHappen();
+ }
+ ++aryObj;
+ }
+ }
+ else {
+ DPSPrintf(ctxt, (lit ? "[ " : "{ "));
+ WriteSeqAsTokens(ctxt, base, aryObj, length, tokenType,
+ numstringOffsets);
+ DPSPrintf(ctxt, (lit ? " ] " : " } "));
+ }
+ break; }
+ case DPS_MARK:
+ if (lit)
+ DPSPrintf(ctxt, "/mark ");
+ else
+ DPSPrintf(ctxt, "mark ");
+ break;
+ case DPS_STRING: {
+ char *p = base + currObj->val.stringVal;
+ int i;
+ if (numstringOffsets != NULL) {
+ for (i = 2; i < numstringOffsets[1] &&
+ numstringOffsets[i] != currObj->val.stringVal; i++) ;
+ if (numstringOffsets[i] == currObj->val.stringVal) {
+ DPSAssert(*(unsigned char *) p == 149);
+ DPSWriteData(ctxt, p, length);
+ break;
+ }
+ }
+ length = currObj->length;
+ if (length < 256) {
+ PB(142); /* short string */
+ PB(length);
+ }
+ else {
+ WTT(143); /* long string */
+ DPSWriteData(ctxt, (char *) &length, 2);
+ }
+ DPSWriteData(ctxt, p, length);
+ break;
+ }
+ default: DPSCantHappen();
+ }
+next_obj:
+ ++currObj;
+ if (++nLineObjs == 15) {
+ nLineObjs = 0;
+ DPSPrintf(ctxt, "\n ");
+ }
+ } /* end while */
+
+ DPSPrintf(ctxt, "\n");
+} /* WriteSeqAsTokens */
+
+static void WriteTokenAsAscii(
+ DPSContext ctxt,
+ register unsigned char *buf)
+{
+ Swap32Rec n32;
+ Swap16Rec n16;
+ register unsigned char *b;
+
+ switch (*buf++) {
+ case 132: /* 32-bit int, hi */
+ b = n32.bytes;
+ Copy4SrcHi(buf, b);
+ DPSPrintf(ctxt, "%d ", n32.i);
+ break;
+ case 133: /* 32-bit int, lo */
+ b = n32.bytes;
+ Copy4SrcLo(buf, b);
+ DPSPrintf(ctxt, "%d ", n32.i);
+ break;
+ case 134: /* 16-bit int, hi */
+ b = n16.bytes;
+ Copy2SrcHi(buf, b);
+ DPSPrintf(ctxt, "%d ", n16.i);
+ break;
+ case 135: /* 16-bit int, lo */
+ b = n16.bytes;
+ Copy2SrcLo(buf, b);
+ DPSPrintf(ctxt, "%d ", n16.i);
+ break;
+ case 136: /* 8-bit int, signed */
+ n32.i = (char) *buf;
+ DPSPrintf(ctxt, "%d ", n32.i);
+ break;
+ case 137: { /* 16 or 32-bit fixed */
+ unsigned char r = *buf++;
+ float f = 0.0;
+ boolean hi = (r < 128);
+
+ if (!hi) r -= 128;
+ if (r < 32) { /* 32-bit */
+ b = n32.bytes;
+ if (hi) {Copy4SrcHi(buf, b);} else {Copy4SrcLo(buf, b);}
+ if (r == 0) {
+ DPSPrintf(ctxt, "%d ", n32.i);
+ break;
+ }
+ else {
+ f = n32.i; /* convert to float */
+ goto do_scale;
+ }
+ }
+ else if (r < 48) { /* 16-bit */
+ b = n16.bytes;
+ if (hi) {Copy2SrcHi(buf, b);} else {Copy2SrcLo(buf, b);};
+ if (r == 0) {
+ DPSPrintf(ctxt, "%d ", n16.i);
+ break;
+ }
+ else {
+ r -= 32;
+ f = n16.i; /* convert to float */
+ goto do_scale;
+ }
+ }
+ else DPSCantHappen();
+do_scale:
+ n32.f = f / (1 << r); /* scale */
+ DPSPrintf(ctxt, "%g ", n32.f);
+ break;
+ }
+ case 138: /* 32-bit IEEE float, hi */
+#if IEEEFLOAT
+ b = n32.bytes;
+ Copy4SrcHi(buf, b);
+#else /* IEEEFLOAT */
+ IEEEHighToNative(buf, &n32.f);
+#endif /* IEEEFLOAT */
+ DPSPrintf(ctxt, "%g ", n32.f);
+ break;
+ case 139: /* 32-bit IEEE float, lo */
+#if IEEEFLOAT
+ b = n32.bytes;
+ Copy4SrcLo(buf, b);
+#else /* IEEEFLOAT */
+ IEEELowToNative(buf, &n32.f);
+#endif /* IEEEFLOAT */
+ DPSPrintf(ctxt, "%g ", n32.f);
+ break;
+ case 140: /* 32-bit native float */
+ b = n32.bytes;
+ *b++ = *buf++,*b++ = *buf++,*b++ = *buf++,*b = *buf;
+ DPSPrintf(ctxt, "%g ", n32.f);
+ break;
+ case 141: /* boolean */
+ if (*buf)
+ DPSPrintf(ctxt, "true ");
+ else
+ DPSPrintf(ctxt, "false ");
+ break;
+ case 142: /* short string */
+ DPSPrintf(ctxt, "(");
+ n16.u = *buf++;
+ goto share_str_code;
+ case 143: /* long string, hi */
+ b = n16.bytes;
+ Copy2SrcHi(buf, b);
+ DPSPrintf(ctxt, "(");
+ buf += 2;
+ goto share_str_code;
+ case 144: /* long string, lo */
+ b = n16.bytes;
+ Copy2SrcLo(buf, b);
+ DPSPrintf(ctxt, "(");
+ buf += 2;
+share_str_code:
+#ifdef VMS
+ WriteVMSStringBody(ctxt, buf, n16.u); /* write this */
+#else /* VMS */
+ /* render string bytes correctly */
+ while (n16.u--) {
+ unsigned char c = *buf++;
+ if (c == '(' || c == ')' || c == '\\')
+ DPSPrintf(ctxt, "\\%c", c);
+ else if (c == '\n')
+ DPSPrintf(ctxt, "\\n");
+ else if (!(isascii(c) && isprint(c)))
+ DPSPrintf(ctxt, "\\%03.3o", c);
+ else DPSWriteData(ctxt, (char *) &c, 1);
+ }
+#endif /* VMS */
+ DPSPrintf(ctxt, ") ");
+ break;
+ case 145: /* literal system name index */
+ DPSPrintf(ctxt, "/%s ", DPSSysNames[*buf]);
+ break;
+ case 146: /* executable system name index */
+ DPSPrintf(ctxt, "%s ", DPSSysNames[*buf]);
+ break;
+ case 147: /* literal user name index */
+ DPSPrintf(ctxt, "/%s ", DPSNameFromIndex(*buf));
+ break;
+ case 148: /* executable user name index */
+ DPSPrintf(ctxt, "%s ", DPSNameFromIndex(*buf));
+ break;
+ case 149: { /* homogeneous number array */
+ WriteHomogeneousArrayAsASCII(ctxt, buf);
+ break;
+ }
+ default:; /* unassigned */
+ }
+} /* WriteTokenAsAscii */
+
+
+/* WriteEntireGoody converts an entire binary token or binary object
+ sequence as specified by ctxt's encoding parameters. Write the
+ converted bytes via DPSWriteData. buf points to the complete goody. */
+
+static void WriteEntireGoody(
+ DPSContext ctxt,
+ unsigned char *buf,
+ int *numstringOffsets)
+{
+
+ DPSExtendedBinObjSeq bos = (DPSExtendedBinObjSeq) buf;
+ DPSExtendedBinObjSeqRec bosRec;
+ DPSBinObj currObj;
+ DPSPrivContext cc = (DPSPrivContext) ctxt;
+
+ if (IsBinaryToken(*buf)) {
+ /* only supported conversion is binary token to ASCII */
+ WriteTokenAsAscii(ctxt, buf);
+ if (numstringOffsets) numstringOffsets[1] = 2;
+ return;
+ }
+
+ if (bos->escape != 0) {
+ /* not extended BOS */
+ DPSBinObjSeq seqHead = (DPSBinObjSeq) buf;
+ bos = &bosRec;
+ bos->tokenType = seqHead->tokenType;
+ bos->escape = seqHead->nTopElements;
+ bos->nTopElements = seqHead->nTopElements;
+ bos->length = seqHead->length;
+ currObj = &(seqHead->objects[0]);
+ }
+ else currObj = &(bos->objects[0]);
+
+ switch (ctxt->programEncoding) {
+ case dps_binObjSeq:
+ if (ctxt->nameEncoding == dps_strings) {
+ /* takes three passes to do conversions */
+ ConvertAndWriteSeqAsData(ctxt, (char *) buf, 0);
+ ConvertAndWriteSeqAsData(ctxt, (char *) buf, 1);
+ ConvertAndWriteSeqAsData(ctxt, (char *) buf, 2);
+ }
+ else if (bos->tokenType != DPS_DEF_TOKENTYPE
+ || cc->numFormat != DPSDefaultNumFormat) {
+ /* first pass just writes modified seqHead */
+ ConvertAndWriteSeqAsData(ctxt, (char *) buf, 0);
+ /* second pass converts numbers and writes the sequence */
+ ConvertAndWriteSeqAsData(ctxt, (char *) buf, 1);
+ }
+ else DPSWriteData(ctxt, (char *) buf, bos->length);
+ break;
+ case dps_ascii:
+ case dps_encodedTokens: {
+
+ if (ctxt->programEncoding == dps_ascii)
+ {
+ WriteSeqAsAscii(
+ ctxt, (char *)currObj, currObj, bos->nTopElements,
+ bos->tokenType, numstringOffsets);
+ }
+ else
+ WriteSeqAsTokens(
+ ctxt, (char *)currObj, currObj, bos->nTopElements,
+ bos->tokenType, numstringOffsets);
+ DPSWriteData(ctxt, "\n", 1);
+ break;
+ }
+ default:;
+ }
+ if (numstringOffsets) numstringOffsets[1] = 2;
+} /* WriteEntireGoody */
+
+
+/**************************************/
+/* Context procs for DPSCreateTextContext */
+/**************************************/
+
+static void textWriteData(DPSContext ctxt, char *buf, unsigned int nch)
+{
+ (*ctxt->textProc)(ctxt, buf, nch);
+ if (ctxt->chainChild != NIL) DPSWriteData(ctxt->chainChild, buf, nch);
+}
+
+static void textFlushContext(DPSContext ctxt)
+{
+ if (ctxt->chainChild != NIL) DPSFlushContext(ctxt->chainChild);
+}
+
+static void textInterruptContext(DPSContext ctxt)
+{
+ if (ctxt->chainChild != NIL) DPSInterruptContext(ctxt->chainChild);
+}
+
+static void textDestroyContext(DPSContext ctxt)
+{
+ DPSPrivContext c = (DPSPrivContext)ctxt;
+
+ DPSUnchainContext(ctxt);
+
+ free(c);
+}
+
+static void textInnerWritePostScript(
+ DPSContext ctxt, char *buf, unsigned int nch)
+{
+ DPSPrivContext cc = (DPSPrivContext)ctxt;
+ while (nch > 0) {
+ char *oldBuf = NIL;
+ integer oldNch = 0;
+ unsigned n;
+ if (cc->outBuf) { /* we're buffering */
+ unsigned m;
+ integer bst;
+ if (!IsBinaryToken(cc->outBuf[0]) && cc->nOutBufChars < DPS_SEQ_MIN) {
+ char *tb = cc->outBuf + cc->nOutBufChars;
+ integer nn = DPS_SEQ_MIN - cc->nOutBufChars;
+ DPSAssert(nn == 1);
+ cc->nOutBufChars += nn;
+ nch -= nn;
+ *tb++ = *buf++;
+ }
+ bst = GetHdrNBytes((unsigned char *) cc->outBuf);
+ /* # bytes needed to determine size */
+ if (cc->nOutBufChars < bst) {
+ char *b = cc->outBuf;
+ if (nch + cc->nOutBufChars < (unsigned) bst) {
+ os_bcopy(buf, cc->outBuf + cc->nOutBufChars, nch);
+ cc->nOutBufChars += nch;
+ return;
+ }
+ os_bcopy(buf, b + cc->nOutBufChars, bst - cc->nOutBufChars);
+ buf += bst - cc->nOutBufChars;
+ nch -= bst - cc->nOutBufChars;
+ cc->nOutBufChars = bst;
+ m = GetNBytes((unsigned char *) cc->outBuf);
+ cc->outBuf = (char *)DPScalloc(m, 1);
+ os_bcopy(b, cc->outBuf, bst);
+ free(b);
+ }
+ else m = GetNBytes((unsigned char *) cc->outBuf);
+
+ /* here with size of entire goody in m and outBuf set up */
+ if (nch + cc->nOutBufChars < m) {
+ os_bcopy(buf, cc->outBuf + cc->nOutBufChars, nch);
+ cc->nOutBufChars += nch;
+ return;
+ }
+ os_bcopy(buf, cc->outBuf + cc->nOutBufChars, m - cc->nOutBufChars);
+ buf += m - cc->nOutBufChars;
+ nch -= m - cc->nOutBufChars;
+ cc->nOutBufChars = m;
+ oldBuf = buf;
+ oldNch = nch;
+ buf = cc->outBuf;
+ nch = cc->nOutBufChars;
+ cc->outBuf = NIL;
+ cc->nOutBufChars = 0;
+ } /* if (cc->outBuf) */
+
+ /* dispose of any plain text. If no binary conversion, all output
+ is plain text */
+ if (cc->contextFlags & DPS_FLAG_NO_BINARY_CONVERSION) n = nch;
+ else {
+ for (n = 0; n < nch &&
+ ((unsigned char) buf[n] < 128 || (unsigned char) buf[n] > 159); n++);
+ }
+ if (n > 0) {
+ /* Assumes below that any error proc called uses dpsexcept.h
+ if it rips control away */
+ DURING
+ DPSWriteData((DPSContext)cc, buf, n);
+ HANDLER
+ if (oldBuf) free(buf);
+ RERAISE;
+ END_HANDLER
+ }
+ buf += n;
+ nch -= n;
+
+ if (nch != 0) {
+ /* here with the next binary object sequence or encoded token */
+ unsigned m = 0;
+ integer bst;
+ if (!IsBinaryToken(buf[0]) && nch < DPS_SEQ_MIN) {
+ /* gotta buffer it */
+ DPSAssertWarn(nch == 1 && !oldBuf, cc, "problem converting binary token/sequence (nch!=1||oldBuf)");
+ cc->outBuf = (char *)DPScalloc(DPS_EXT_HEADER_SIZE, 1);
+ cc->nOutBufChars = nch;
+ cc->outBuf[0] = *buf;
+ return;
+ }
+ bst = GetHdrNBytes((unsigned char *) buf);
+ if (nch < (unsigned)bst || nch < (m = GetNBytes((unsigned char *) buf))) {
+ /* gotta buffer it */
+ DPSAssertWarn(!oldBuf, cc, "problem converting binary token/sequence (oldBuf)");
+ if (nch < (unsigned) bst) {
+ cc->outBuf = (char *)DPScalloc(bst, 1);
+ }
+ else {
+ cc->outBuf = (char *)DPScalloc(m, 1);
+ }
+ cc->nOutBufChars = nch;
+ os_bcopy(buf, cc->outBuf, nch);
+ return;
+ }
+
+ /* Assumes below that any error proc called uses dpsexcept.h
+ if it rips control away */
+ DURING
+ WriteEntireGoody(ctxt, (unsigned char *) buf, cc->numstringOffsets);
+ HANDLER
+ if (oldBuf) {
+ DPSAssertWarn(nch == m, cc, "some converted PostScript language may be lost during error recovery (nch!=m)");
+ free(buf);
+ }
+ RERAISE;
+ END_HANDLER
+
+ if (oldBuf) {
+ DPSAssertWarn(nch == m, cc, "some converted PostScript language may be lost (nch!=m)");
+ free(buf);
+ buf = oldBuf;
+ nch = oldNch;
+ oldBuf = NIL;
+ }
+ else {
+ buf += m;
+ nch -= m;
+ }
+ } /* if (nch != 0) */
+ } /* while (nch > 0) */
+} /* textInnerWritePostScript */
+
+static void textWritePostScript(
+ DPSContext ctxt, char *buf, unsigned int nch)
+{
+ DPSContext children = ctxt->chainChild;
+ /* disconnect temporarily so that high level procs can
+ be called safely */
+ if (children != NIL) ctxt->chainChild = NIL;
+ DURING
+ textInnerWritePostScript(ctxt, buf, nch);
+ HANDLER
+ if (children != NIL) ctxt->chainChild = children;
+ RERAISE;
+ END_HANDLER
+ if (children != NIL) {
+ ctxt->chainChild = children;
+ DPSWritePostScript(ctxt->chainChild, buf, nch);
+ }
+}
+
+static void textWriteStringChars(
+ DPSContext ctxt, char *buf, unsigned int nch)
+{
+ DPSContext children = ctxt->chainChild;
+
+ if (DPSCheckShared((DPSPrivContext)ctxt)) return;
+ /* disconnect temporarily so that high level procs can
+ be called safely */
+ if (children != NIL) ctxt->chainChild = NIL;
+ DURING
+ textInnerWritePostScript(ctxt, buf, nch);
+ HANDLER
+ if (children != NIL) ctxt->chainChild = children;
+ RERAISE;
+ END_HANDLER
+ if (children != NIL) {
+ ctxt->chainChild = children;
+ DPSWriteStringChars(ctxt->chainChild, buf, nch);
+ }
+}
+
+static void textBinObjSeqWrite(
+ DPSContext ctxt, char *buf, unsigned int nch)
+{
+ DPSContext children = ctxt->chainChild;
+ DPSPrivContext c = (DPSPrivContext) ctxt;
+
+ if (DPSCheckShared(c)) return;
+ if (c->lastNameIndex < globLastNameIndex)
+ DPSUpdateNameMap(ctxt);
+ /* disconnect temporarily so that high level procs can
+ be called safely */
+ if (children != NIL) ctxt->chainChild = NIL;
+ DURING
+ textInnerWritePostScript(ctxt, buf, nch);
+ HANDLER
+ if (children != NIL) ctxt->chainChild = children;
+ RERAISE;
+ END_HANDLER
+ if (children != NIL) {
+ ctxt->chainChild = children;
+ DPSBinObjSeqWrite(ctxt->chainChild, buf, nch);
+ }
+}
+
+static void textWriteNumstring(
+ DPSContext ctxt,
+ DPSDefinedType type,
+ char *data,
+ unsigned int size,
+ int scale)
+{
+ DPSPrivContext cc = (DPSPrivContext) ctxt;
+#define BUFFER_GROW 10
+
+ if (cc->contextFlags & DPS_FLAG_CONVERT_NUMSTRINGS) {
+ if (cc->numstringOffsets == NULL) {
+ cc->numstringOffsets = (int *) DPScalloc(sizeof(int),
+ BUFFER_GROW + 2);
+ cc->numstringOffsets[0] = BUFFER_GROW + 2; /* Current size */
+ cc->numstringOffsets[1] = 2; /* Next slot */
+ } else if (cc->numstringOffsets[1] >= cc->numstringOffsets[0]) {
+ cc->numstringOffsets[0] += BUFFER_GROW;
+ cc->numstringOffsets =
+ (int *) realloc(cc->numstringOffsets,
+ sizeof(int)* cc->numstringOffsets[0]);
+ }
+
+ /* Subtract 4 because of binary object sequence header */
+ cc->numstringOffsets[cc->numstringOffsets[1]] = cc->nOutBufChars - 4;
+ cc->numstringOffsets[1] += 1;
+ }
+
+ innerProcWriteNumstring(ctxt, type, data, size, scale, textInnerWritePostScript);
+#undef BUFFER_GROW
+} /* textWriteNumstring */
+
+/*********************/
+/* Public procedures */
+/*********************/
+
+/********************************************/
+/* Public procs for dealing with user names */
+
+char *DPSNameFromIndex(long int index)
+{
+ if (DPSglobals == NIL || index < 0 || index > globLastNameIndex
+ || userNameDict == NIL)
+ return NIL;
+ return (char *) userNames[index];
+}
+
+void DPSMapNames(
+ DPSContext ctxt,
+ unsigned int nNames,
+ char **names,
+ int **indices)
+{
+ unsigned i;
+ char *last = names[0];
+
+ DPSCheckInitClientGlobals();
+
+#define USERNAMEDICTLENGTH 100
+
+ if (userNameDict == NIL) {
+ userNameDict = DPSCreatePSWDict(USERNAMEDICTLENGTH);
+ userNames = (char **)DPScalloc(sizeof(char *), USERNAMEDICTLENGTH);
+ userNamesLength = USERNAMEDICTLENGTH;
+ }
+
+ for (i = 0; i < nNames; i++) {
+ integer j;
+ char *n = names[i];
+ DPSContext c;
+
+ if (n == NIL)
+ n = last;
+ else
+ last = n;
+ DPSAssert(n != NIL);
+ if (strlen(n) > 128) {
+ DPSSafeSetLastNameIndex(ctxt);
+ (*ctxt->errorProc)(ctxt, dps_err_nameTooLong, (unsigned long) n, strlen(n));
+ return;
+ }
+ j = DPSWDictLookup(userNameDict, n);
+ if (j >= 0) {
+ *(indices[i]) = j;
+ /* handle the case where another context in another space has
+ defined this name */
+ if (((DPSPrivContext)ctxt)->lastNameIndex < j)
+ DPSUpdateNameMap(ctxt);
+ }
+ else {
+ /* handle other cases where another context in another
+ space has defined names */
+ if (((DPSPrivContext)ctxt)->lastNameIndex < globLastNameIndex)
+ DPSUpdateNameMap(ctxt);
+ globLastNameIndex++;
+ if (((globLastNameIndex + 1) > userNamesLength)) {
+ char **t = (char **)DPScalloc(sizeof(char *),
+ userNamesLength + USERNAMEDICTLENGTH);
+ for (j = 0; j < userNamesLength; j++) {
+ t[j] = userNames[j];
+ }
+ free(userNames);
+ userNames = t;
+ userNamesLength += USERNAMEDICTLENGTH;
+ }
+ userNames[globLastNameIndex] = n;
+ DPSWDictEnter(userNameDict, n, globLastNameIndex);
+ *(indices[i]) = globLastNameIndex;
+ DPSPrintf(ctxt, "%d /%s defineusername\n", globLastNameIndex, n);
+ for (c = ctxt; c != NIL; c = c->chainChild)
+ ((DPSPrivContext)c)->lastNameIndex = globLastNameIndex;
+ }
+ } /* for */
+}
+
+/**********************/
+/* Other public procs */
+
+void DPSDefaultErrorProc(
+ DPSContext ctxt,
+ DPSErrorCode errorCode,
+ long unsigned int arg1, long unsigned int arg2)
+{
+
+ DPSTextProc textProc = DPSGetCurrentTextBackstop();
+
+ char *prefix = "%%[ Error: ";
+ char *suffix = " ]%%\n";
+
+ char *infix = "; OffendingCommand: ";
+ char *nameinfix = "User name too long; Name: ";
+ char *contextinfix = "Invalid context: ";
+ char *taginfix = "Unexpected wrap result tag: ";
+ char *typeinfix = "Unexpected wrap result type; tag: ";
+
+ switch (errorCode) {
+ case dps_err_ps: {
+ char *buf = (char *)arg1;
+ DPSBinObj ary = (DPSBinObj) (buf+DPS_HEADER_SIZE);
+ DPSBinObj elements;
+ char *error, *errorName;
+ integer errorCount, errorNameCount;
+ boolean resyncFlg;
+
+ if ((ary->attributedType & 0x7f) != DPS_ARRAY
+ || ary->length != 4) {
+ DPSHandleBogusError(ctxt, prefix, suffix);
+ }
+
+ elements = (DPSBinObj)(((char *) ary) + ary->val.arrayVal);
+
+ errorName = (char *)(((char *) ary) + elements[1].val.nameVal);
+ errorNameCount = elements[1].length;
+
+ error = (char *)(((char *) ary) + elements[2].val.nameVal);
+ errorCount = elements[2].length;
+
+ resyncFlg = elements[3].val.booleanVal;
+
+ if (textProc != NIL) {
+ (*textProc)(ctxt, prefix, strlen(prefix));
+ (*textProc)(ctxt, errorName, errorNameCount);
+ (*textProc)(ctxt, infix, strlen(infix));
+ (*textProc)(ctxt, error, errorCount);
+ (*textProc)(ctxt, suffix, strlen(suffix));
+ }
+ if (resyncFlg && (ctxt != dummyCtx) && (ctxt != NULL)) {
+#if 0 /* Postpone the raise 'til later to avoid RAISEing through Xlib */
+ RAISE(dps_err_ps, (char *) ctxt);
+ DPSCantHappen();
+#else
+ DPSPrivContext cc = (DPSPrivContext) ctxt;
+ cc->resyncing = true;
+#endif
+ }
+ break;
+ }
+ case dps_err_nameTooLong:
+ if (textProc != NIL) {
+ char *buf = (char *)arg1;
+ (*textProc)(ctxt, prefix, strlen(prefix));
+ (*textProc)(ctxt, nameinfix, strlen(nameinfix));
+ (*textProc)(ctxt, buf, arg2);
+ (*textProc)(ctxt, suffix, strlen(suffix));
+ }
+ break;
+ case dps_err_invalidContext:
+ if (textProc != NIL) {
+ char m[100];
+ (void) sprintf(m, "%s%s%ld%s", prefix, contextinfix, arg1, suffix);
+ (*textProc)(ctxt, m, strlen(m));
+ }
+ break;
+ case dps_err_resultTagCheck:
+ if (textProc != NIL) {
+ char m[100];
+ unsigned char tag = *((unsigned char *) arg1+1);
+ (void) sprintf(m, "%s%s%d%s", prefix, taginfix, tag, suffix);
+ (*textProc)(ctxt, m, strlen(m));
+ }
+ break;
+ case dps_err_resultTypeCheck:
+ if (textProc != NIL) {
+ char m[100];
+ unsigned char tag = *((unsigned char *) arg1+1);
+ (void) sprintf(m, "%s%s%d%s", prefix, typeinfix, tag, suffix);
+ (*textProc)(ctxt, m, strlen(m));
+ }
+ break;
+ default:
+ DPSDefaultPrivateHandler(ctxt, errorCode, arg1, arg2, prefix, suffix);
+ break;
+ }
+} /* DPSDefaultErrorProc */
+
+void DPSCheckRaiseError(DPSContext c)
+{
+ DPSPrivContext cc = (DPSPrivContext) c;
+ if (cc != NULL && cc->resyncing) {
+ cc->resyncing = false;
+ RAISE(dps_err_ps, (char *) c);
+ DPSCantHappen();
+ }
+}
+
+/**************************************/
+/* Public procs for creating contexts */
+
+/* dps_err_invalidAccess is now defined for all clients. */
+
+static void textAwaitReturnValues(DPSContext ctxt)
+{
+ (*ctxt->errorProc)(ctxt, dps_err_invalidAccess, 0, 0);
+}
+
+static void Noop(void)
+{
+}
+
+DPSContext DPSCreateTextContext(
+ DPSTextProc textProc, DPSErrorProc errorProc)
+{
+ DPSPrivContext c;
+
+ if (DPSInitialize () != 0) return((DPSContext) NIL);
+ if (!textCtxProcs) {
+ textCtxProcs = (DPSProcs)DPScalloc(sizeof(DPSProcsRec), 1);
+ DPSInitCommonTextContextProcs(textCtxProcs);
+ DPSInitSysNames();
+ }
+
+ c = (DPSPrivContext)DPScalloc(sizeof(DPSPrivContextRec), 1);
+ c->textProc = textProc;
+ c->procs = textCtxProcs;
+ c->textProc = textProc;
+ c->errorProc = errorProc;
+ c->programEncoding = dps_ascii;
+ c->nameEncoding = dps_strings; /* don't write user name indices on a file */
+ c->contextFlags = DPS_FLAG_CONVERT_NUMSTRINGS; /* Convert by default */
+ c->numFormat = DPSDefaultNumFormat;
+ c->numstringOffsets = NULL;
+ c->lastNameIndex = -1;
+
+ /* Setup a dummy space */
+ if (textSpace == NIL)
+ {
+ textSpace = (DPSPrivSpace) DPScalloc(sizeof (DPSPrivSpaceRec), 1);
+ textSpace->procs = (DPSSpaceProcs) DPScalloc(sizeof (DPSSpaceProcsRec), 1);
+ textSpace->procs->DestroySpace = (DPSSpaceProc) Noop;
+ textSpace->lastNameIndex = -1;
+ DPSInitPrivateSpaceFields(textSpace);
+ }
+ c->space = (DPSSpace) textSpace;
+
+ DPSInitPrivateTextContextFields(c, textSpace);
+ return (DPSContext)c;
+} /* DPSCreateTextContext */
+
+
+static DPSContext CreateDummyContext(void)
+{
+ DPSPrivContext c;
+
+ DPSCheckInitClientGlobals();
+ if (!dummyCtxProcs) {
+ dummyCtxProcs = (DPSProcs)DPScalloc(sizeof(DPSProcsRec), 1);
+ dummyCtxProcs->BinObjSeqWrite = (DPSContextBufProc) Noop;
+ dummyCtxProcs->WriteTypedObjectArray = (DPSContextTypedArrayProc) Noop;
+ dummyCtxProcs->WriteStringChars = (DPSContextBufProc) Noop;
+ dummyCtxProcs->WritePostScript = (DPSContextBufProc) Noop;
+ dummyCtxProcs->WriteData = (DPSContextBufProc) Noop;
+ dummyCtxProcs->FlushContext = (DPSContextProc) Noop;
+ dummyCtxProcs->ResetContext = (DPSContextProc) Noop;
+ dummyCtxProcs->WaitContext = (DPSContextProc) Noop;
+ dummyCtxProcs->UpdateNameMap = (DPSContextProc) Noop;
+ dummyCtxProcs->AwaitReturnValues = (DPSContextProc) Noop;
+ dummyCtxProcs->Interrupt = (DPSContextProc) Noop;
+ dummyCtxProcs->DestroyContext = (DPSContextProc) Noop;
+ dummyCtxProcs->WriteNumString = (DPSWriteNumStringProc) Noop;
+ }
+
+ c = (DPSPrivContext)DPScalloc(sizeof(DPSPrivContextRec), 1);
+ c->procs = dummyCtxProcs;
+ c->programEncoding = DPSDefaultProgramEncoding;
+ c->nameEncoding = DPSDefaultNameEncoding; /* don't care */
+ c->numFormat = DPSDefaultNumFormat;
+ c->lastNameIndex = -1;
+ c->numstringOffsets = NULL;
+
+ return (DPSContext)c;
+} /* CreateDummyContext */
+
+void DPSSetTextBackstop(DPSTextProc textProc)
+{
+ DPSCheckInitClientGlobals();
+ if (!dummyCtx) dummyCtx = CreateDummyContext();
+ dummyCtx->textProc = textProc;
+}
+
+DPSTextProc DPSGetCurrentTextBackstop(void)
+{
+ DPSCheckInitClientGlobals();
+ if (dummyCtx == NIL) return NIL;
+ else return dummyCtx->textProc;
+}
+
+void DPSSetErrorBackstop(DPSErrorProc errorProc)
+{
+ DPSCheckInitClientGlobals();
+ if (!dummyCtx) dummyCtx = CreateDummyContext();
+ dummyCtx->errorProc = errorProc;
+}
+
+DPSErrorProc DPSGetCurrentErrorBackstop(void)
+{
+ DPSCheckInitClientGlobals();
+ if (dummyCtx == NIL) return NIL;
+ else return dummyCtx->errorProc;
+}
+
+static void NoteInitFailure(DPSContext ctxt, char *buf, long unsigned length)
+{
+ initFailed = -1;
+}
+
+int DPSInitialize(void)
+{
+ DPSCheckInitClientGlobals();
+ if (!clientStarted) {
+ clientStarted = true;
+ initFailed = 0;
+ DPSInitClient(NoteInitFailure, ReleaseInput); /* may call DPSCreateContext */
+ /* textProc will not be used unless DPS initialization fails */
+ }
+ return initFailed;
+}
+
+DPSContext DPSCreateContext(
+ char *wh,
+ DPSTextProc textProc,
+ DPSErrorProc errorProc,
+ DPSSpace space)
+{
+
+ DPSPrivSpace ss;
+ DPSPrivContext c;
+
+ if (DPSInitialize() != 0) return NIL;
+
+ if (!ctxProcs) {
+ ctxProcs = (DPSProcs)DPScalloc(sizeof(DPSProcsRec), 1);
+ ctxProcs->BinObjSeqWrite = procBinObjSeqWrite;
+ ctxProcs->WriteTypedObjectArray = writeTypedObjectArray;
+ ctxProcs->WriteStringChars = procWriteStringChars;
+ ctxProcs->WritePostScript = procWritePostScript;
+ ctxProcs->WriteData = procWriteData;
+ ctxProcs->UpdateNameMap = procUpdateNameMap;
+ ctxProcs->Interrupt = procInterrupt;
+ ctxProcs->WriteNumString = (DPSWriteNumStringProc) procWriteNumstring;
+ }
+ if (!spaceProcs) {
+ spaceProcs = (DPSSpaceProcs)DPScalloc(sizeof(DPSSpaceProcsRec), 1);
+ DPSInitCommonSpaceProcs(spaceProcs);
+ }
+
+ ss = (DPSPrivSpace)space;
+
+ if (ss == NIL) {
+ ss = (DPSPrivSpace)DPScalloc(sizeof(DPSPrivSpaceRec), 1);
+ ss->procs = spaceProcs;
+ ss->lastNameIndex = -1;
+ ss->next = spaces;
+ DPSAssert(ss->next != ss);
+ spaces = ss;
+ DPSInitPrivateSpaceFields(ss);
+ }
+
+ if (ss->wh == NIL) ss->wh = wh; /* KLUDGE to support DPSSendDestroySpace */
+
+ c = (DPSPrivContext)DPScalloc(sizeof(DPSPrivContextRec), 1);
+ c->procs = ctxProcs;
+ c->wh = wh;
+ c->textProc = textProc;
+ c->errorProc = errorProc;
+ c->programEncoding = DPSDefaultProgramEncoding;
+ c->nameEncoding = DPSDefaultNameEncoding;
+ c->lastNameIndex = -1;
+ c->space = (DPSSpace)ss;
+ c->numstringOffsets = NULL;
+
+ c->next = ss->firstContext;
+ DPSAssert(c->next != c);
+ ss->firstContext = c;
+
+ DPSInitPrivateContextFields(c, ss);
+
+ c->numFormat = DPSCreatePrivContext(
+ (XDPSPrivContext)wh,
+ (DPSContext)c,
+ (ContextPSID *)&c->cid,
+ (SpaceXID *)&ss->sid,
+ (space == NIL), DPSclientPrintProc);
+ if (c->numFormat == (DPSNumFormat) -1)
+ { /* can't create the context */
+ if (space == NIL) {
+ spaces = ss->next;
+ free(ss);
+ }
+ else ss->firstContext = c->next;
+ free(c);
+ return NIL;
+ }
+ else return (DPSContext)c;
+} /* DPSCreateContext */
+
+char *DPSSetWh(
+ DPSContext ctxt,
+ char *newWh)
+{
+ DPSPrivContext cc = (DPSPrivContext) ctxt;
+ char *tmp = cc->wh;
+ cc->wh = newWh;
+ return(tmp);
+}
+
+/*
+ The chainParent field is non-NIL if this context automatically receives
+ a copy of the PostScript code sent to the referenced (parent) context.
+
+ The chainChild field is non-NIL if this context automatically sends along
+ to the referenced (child) context a copy of any PostScript code received.
+*/
+int DPSChainContext(DPSContext parent, DPSContext child)
+{
+ DPSContext cc = child->chainChild;
+
+ if (child->chainParent != NIL)
+ return -1; /* report an error */
+
+ /* insert new child between parent and existing children */
+ child->chainChild = parent->chainChild;
+ if (parent->chainChild != NIL) {
+ DPSAssertWarn(parent->chainChild->chainParent == parent, (DPSPrivContext)parent, "attempting to chain context on invalid chain");
+ child->chainChild->chainParent = child;
+ }
+ child->chainParent = parent;
+ parent->chainChild = child;
+ /* if child has children, recursively chain them */
+ if (cc != NIL) {
+ cc->chainParent = NIL;
+ (void) DPSChainContext(child, cc);
+ }
+ return 0;
+}
+
+void DPSUnchainContext(DPSContext ctxt)
+{
+ DPSContext p = ctxt->chainParent;
+ DPSContext c = ctxt->chainChild;
+
+ if (p != NIL) { /* remove ctxt from parent's chain */
+ DPSAssertWarn(p->chainChild == ctxt, (DPSPrivContext)p, "attempting to unchain context from wrong chain (parent)");
+ p->chainChild = c;
+ ctxt->chainParent = NIL;
+ }
+ if (c != NIL) { /* remove ctxt's child (if any) from ctxt's chain */
+ DPSAssertWarn(c->chainParent == ctxt, (DPSPrivContext)c, "attempting to unchain context from wrong chain (child)");
+ c->chainParent = p;
+ ctxt->chainChild = NIL;
+ }
+}
+
+/****************/
+/* Veneer procs */
+
+void DPSAwaitReturnValues(DPSContext ctxt)
+{
+ (*(ctxt)->procs->AwaitReturnValues)((ctxt));
+}
+
+void DPSDestroyContext(DPSContext ctxt)
+{
+ (*(ctxt)->procs->DestroyContext)((ctxt));
+}
+
+void DPSDestroySpace(DPSSpace spc)
+{
+ (*(spc)->procs->DestroySpace)((spc));
+}
+
+void DPSFlushContext(DPSContext ctxt)
+{
+ (*(ctxt)->procs->FlushContext)((ctxt));
+}
+
+DPSContext DPSGetCurrentContext(void) { return DPSGlobalContext; }
+
+void DPSInterruptContext(DPSContext ctxt)
+{
+ (*(ctxt)->procs->Interrupt)((ctxt));
+}
+
+DPSContext DPSPrivCurrentContext(void) { return DPSGlobalContext; }
+
+void DPSResetContext(DPSContext ctxt)
+{
+ (*(ctxt)->procs->ResetContext)((ctxt));
+}
+
+void DPSSetResultTable(
+ register DPSContext ctxt,
+ DPSResults tbl,
+ unsigned int len)
+{
+ (ctxt)->resultTable = (tbl);
+ (ctxt)->resultTableLength = (len);
+}
+
+void DPSSetContext(
+ DPSContext ctxt)
+{
+ DPSGlobalContext = ctxt;
+}
+
+void DPSUpdateNameMap(
+ DPSContext ctxt)
+{
+ (*(ctxt)->procs->UpdateNameMap)((ctxt));
+}
+
+void DPSWaitContext(
+ DPSContext ctxt)
+{
+ (*(ctxt)->procs->WaitContext)(ctxt);
+}
+
+void DPSBinObjSeqWrite(
+ DPSContext ctxt,
+ char *buf,
+ unsigned int count)
+{
+ (*(ctxt)->procs->BinObjSeqWrite)((ctxt), (buf), (count));
+}
+
+void DPSWriteData(
+ DPSContext ctxt,
+ char *buf,
+ unsigned int count)
+{
+ (*(ctxt)->procs->WriteData)((ctxt), (buf), (count));
+}
+
+void DPSWritePostScript(
+ DPSContext ctxt,
+ char *buf,
+ unsigned int count)
+{
+ (*(ctxt)->procs->WritePostScript)((ctxt), (buf), (count));
+}
+
+void DPSWriteStringChars(
+ DPSContext ctxt,
+ char *buf,
+ unsigned int count)
+{
+ (*(ctxt)->procs->WriteStringChars)((ctxt), (buf), (count));
+}
+
+void DPSWriteNumString(ctxt, type, data, size, scale)
+ DPSContext ctxt;
+ DPSDefinedType type;
+ char *data;
+ unsigned int size;
+ int scale;
+{
+ (*(ctxt)->procs->WriteNumString)((ctxt), (type), (data), (size), (scale));
+}
+
+void DPSWriteTypedObjectArray(ctxt, type, array, length)
+ DPSContext ctxt;
+ DPSDefinedType type;
+ char *array;
+ unsigned int length; {
+ (*(ctxt)->procs->WriteTypedObjectArray)((ctxt), (type), (array), (length));
+ }
+
+void DPSInitCommonTextContextProcs(DPSProcs p)
+{
+ p->BinObjSeqWrite = textBinObjSeqWrite;
+ p->WriteTypedObjectArray = writeTypedObjectArray;
+ p->WriteStringChars = textWriteStringChars;
+ p->WritePostScript = textWritePostScript;
+ p->WriteData = textWriteData;
+ p->FlushContext = textFlushContext;
+ p->ResetContext = (DPSContextProc) Noop;
+ p->WaitContext = (DPSContextProc) Noop;
+ p->UpdateNameMap = procUpdateNameMap;
+ p->AwaitReturnValues = textAwaitReturnValues;
+ p->Interrupt = textInterruptContext;
+ p->DestroyContext = textDestroyContext;
+ p->WriteNumString = (DPSWriteNumStringProc) textWriteNumstring;
+}
+
+void DPSInitCommonContextProcs(DPSProcs p)
+{
+ p->BinObjSeqWrite = procBinObjSeqWrite;
+ p->WriteTypedObjectArray = writeTypedObjectArray;
+ p->WriteStringChars = procWriteStringChars;
+ p->WritePostScript = procWritePostScript;
+ p->WaitContext = procWaitContext;
+ p->DestroyContext = procDestroyContext;
+ p->WriteData = procWriteData;
+ p->UpdateNameMap = procUpdateNameMap;
+ p->Interrupt = procInterrupt;
+ p->WriteNumString = (DPSWriteNumStringProc) procWriteNumstring;
+}
+
+void DPSInitCommonSpaceProcs(DPSSpaceProcs p)
+{
+ p->DestroySpace = procDestroySpace;
+}
+
+void DPSSetNumStringConversion(ctxt, flag)
+ DPSContext ctxt;
+ int flag;
+{
+ if (flag) ctxt->contextFlags |= DPS_FLAG_CONVERT_NUMSTRINGS;
+ else ctxt->contextFlags &= ~DPS_FLAG_CONVERT_NUMSTRINGS;
+}
+
+void DPSSetWrapSynchronization(ctxt, flag)
+ DPSContext ctxt;
+ int flag;
+{
+ if (flag) ctxt->contextFlags |= DPS_FLAG_SYNC;
+ else ctxt->contextFlags &= ~DPS_FLAG_SYNC;
+}
+
+void DPSSuppressBinaryConversion(ctxt, flag)
+ DPSContext ctxt;
+ int flag;
+{
+ if (flag) ctxt->contextFlags |= DPS_FLAG_NO_BINARY_CONVERSION;
+ else ctxt->contextFlags &= ~DPS_FLAG_NO_BINARY_CONVERSION;
+}
+
+void DPSSetAbbrevMode(ctxt, flag)
+ DPSContext ctxt;
+ int flag;
+{
+ if (flag) ctxt->contextFlags |= DPS_FLAG_USE_ABBREVS;
+ else ctxt->contextFlags &= ~DPS_FLAG_USE_ABBREVS;
+}
+
+DPSContextExtensionRec *DPSGetContextExtensionRec(ctxt, extensionId)
+ DPSContext ctxt;
+ int extensionId;
+{
+ DPSContextExtensionRec *r = ctxt->extension;
+
+ while (r != NULL && r->extensionId != extensionId) r = r->next;
+ return r;
+}
+
+void DPSAddContextExtensionRec(ctxt, rec)
+ DPSContext ctxt;
+ DPSContextExtensionRec *rec;
+{
+ rec->next = ctxt->extension;
+ ctxt->extension = rec;
+}
+
+DPSContextExtensionRec *DPSRemoveContextExtensionRec(ctxt, extensionId)
+ DPSContext ctxt;
+ int extensionId;
+{
+ DPSContextExtensionRec *rret, **r = &ctxt->extension;
+
+
+ while (*r != NULL && (*r)->extensionId != extensionId) {
+ r = &(*r)->next;
+ }
+ rret = *r;
+ if (*r != NULL) *r = (*r)->next;
+ return rret;
+}
+
+int DPSGenerateExtensionRecID(void)
+{
+ static int id = 1;
+
+ return id++;
+}
+
+DPSContextType DPSGetContextType(ctxt)
+ DPSContext ctxt;
+{
+ DPSPrivContext c = (DPSPrivContext) ctxt;
+
+ if (c->procs == textCtxProcs) return dps_context_text;
+ else return dps_context_execution;
+}
diff --git a/nx-X11/lib/dps/dpsclrops.psw b/nx-X11/lib/dps/dpsclrops.psw
new file mode 100644
index 000000000..f8ec18269
--- /dev/null
+++ b/nx-X11/lib/dps/dpsclrops.psw
@@ -0,0 +1,81 @@
+/* dpsclrops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPScolorimage(DPSContext ctxt)
+ colorimage
+endps
+
+defineps DPScurrentblackgeneration(DPSContext ctxt)
+ currentblackgeneration
+endps
+
+defineps DPScurrentcmykcolor(DPSContext ctxt | float *c, *m, *y, *k)
+ currentcmykcolor k y m c
+endps
+
+defineps DPScurrentcolorscreen(DPSContext ctxt)
+ currentcolorscreen
+endps
+
+defineps DPScurrentcolortransfer(DPSContext ctxt)
+ currentcolortransfer
+endps
+
+defineps DPScurrentundercolorremoval(DPSContext ctxt)
+ currentundercolorremoval
+endps
+
+defineps DPSsetblackgeneration(DPSContext ctxt)
+ setblackgeneration
+endps
+
+defineps DPSsetcmykcolor(DPSContext ctxt; float c, m, y, k)
+ c m y k setcmykcolor
+endps
+
+defineps DPSsetcolorscreen(DPSContext ctxt)
+ setcolorscreen
+endps
+
+defineps DPSsetcolortransfer(DPSContext ctxt)
+ setcolortransfer
+endps
+
+defineps DPSsetundercolorremoval(DPSContext ctxt)
+ setundercolorremoval
+endps
+
diff --git a/nx-X11/lib/dps/dpsctrlops.psw b/nx-X11/lib/dps/dpsctrlops.psw
new file mode 100644
index 000000000..d00707d4c
--- /dev/null
+++ b/nx-X11/lib/dps/dpsctrlops.psw
@@ -0,0 +1,114 @@
+/*
+ * dpsctrlops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSeq(DPSContext ctxt)
+ eq
+endps
+
+defineps DPSexit(DPSContext ctxt)
+ exit
+endps
+
+defineps DPSfalse(DPSContext ctxt)
+ false
+endps
+
+defineps DPSfor(DPSContext ctxt)
+ for
+endps
+
+defineps DPSforall(DPSContext ctxt)
+ forall
+endps
+
+defineps DPSge(DPSContext ctxt)
+ ge
+endps
+
+defineps DPSgt(DPSContext ctxt)
+ gt
+endps
+
+defineps DPSif(DPSContext ctxt)
+ if
+endps
+
+defineps DPSifelse(DPSContext ctxt)
+ ifelse
+endps
+
+defineps DPSle(DPSContext ctxt)
+ le
+endps
+
+defineps DPSloop(DPSContext ctxt)
+ loop
+endps
+
+defineps DPSlt(DPSContext ctxt)
+ lt
+endps
+
+defineps DPSne(DPSContext ctxt)
+ ne
+endps
+
+defineps DPSnot(DPSContext ctxt)
+ not
+endps
+
+defineps DPSor(DPSContext ctxt)
+ or
+endps
+
+defineps DPSrepeat(DPSContext ctxt)
+ repeat
+endps
+
+defineps DPSstop(DPSContext ctxt)
+ stop
+endps
+
+defineps DPSstopped(DPSContext ctxt)
+ stopped
+endps
+
+defineps DPStrue(DPSContext ctxt)
+ true
+endps
+
diff --git a/nx-X11/lib/dps/dpsctxtops.psw b/nx-X11/lib/dps/dpsctxtops.psw
new file mode 100644
index 000000000..00f6f8f18
--- /dev/null
+++ b/nx-X11/lib/dps/dpsctxtops.psw
@@ -0,0 +1,110 @@
+/*
+ * dpsctxtops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSUserObjects(DPSContext ctxt)
+ UserObjects
+endps
+
+defineps DPScondition(DPSContext ctxt)
+ condition
+endps
+
+defineps DPScurrentcontext(DPSContext ctxt | int *cid)
+ currentcontext cid
+endps
+
+defineps DPScurrentobjectformat(DPSContext ctxt | int *code)
+ currentobjectformat code
+endps
+
+defineps DPSdefineusername(DPSContext ctxt; int i; char *username)
+ i /username defineusername
+endps
+
+defineps DPSdefineuserobject(DPSContext ctxt)
+ defineuserobject
+endps
+
+defineps DPSdetach(DPSContext ctxt)
+ detach
+endps
+
+defineps DPSexecuserobject(DPSContext ctxt; int userObjIndex)
+ userObjIndex execuserobject
+endps
+
+defineps DPSfork(DPSContext ctxt)
+ fork
+endps
+
+defineps DPSjoin(DPSContext ctxt)
+ join
+endps
+
+defineps DPSlock(DPSContext ctxt)
+ lock
+endps
+
+defineps DPSmonitor(DPSContext ctxt)
+ monitor
+endps
+
+defineps DPSnotify(DPSContext ctxt)
+ notify
+endps
+
+defineps DPSsetobjectformat(DPSContext ctxt; int code)
+ code setobjectformat
+endps
+
+defineps DPSsetvmthreshold(DPSContext ctxt; int i)
+ i setvmthreshold
+endps
+
+defineps DPSundefineuserobject(DPSContext ctxt; int userObjIndex)
+ userObjIndex undefineuserobject
+endps
+
+defineps DPSwait(DPSContext ctxt)
+ wait
+endps
+
+defineps DPSyield(DPSContext ctxt)
+ yield
+endps
+
diff --git a/nx-X11/lib/dps/dpsdataops.psw b/nx-X11/lib/dps/dpsdataops.psw
new file mode 100644
index 000000000..c38893678
--- /dev/null
+++ b/nx-X11/lib/dps/dpsdataops.psw
@@ -0,0 +1,258 @@
+/*
+ * dpsdataops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSaload(DPSContext ctxt)
+ aload
+endps
+
+defineps DPSanchorsearch(DPSContext ctxt| boolean *truth)
+ anchorsearch truth
+endps
+
+defineps DPSarray(DPSContext ctxt; int len)
+ len array
+endps
+
+defineps DPSastore(DPSContext ctxt)
+ astore
+endps
+
+defineps DPSbegin(DPSContext ctxt)
+ begin
+endps
+
+defineps DPSclear(DPSContext ctxt)
+ clear
+endps
+
+defineps DPScleartomark(DPSContext ctxt)
+ cleartomark
+endps
+
+defineps DPScopy(DPSContext ctxt; int n)
+ n copy
+endps
+
+defineps DPScount(DPSContext ctxt | int *n)
+ count n
+endps
+
+defineps DPScounttomark(DPSContext ctxt | int *n)
+ counttomark n
+endps
+
+defineps DPScvi(DPSContext ctxt)
+ cvi
+endps
+
+defineps DPScvlit(DPSContext ctxt)
+ cvlit
+endps
+
+defineps DPScvn(DPSContext ctxt)
+ cvn
+endps
+
+defineps DPScvr(DPSContext ctxt)
+ cvr
+endps
+
+defineps DPScvrs(DPSContext ctxt)
+ cvrs
+endps
+
+defineps DPScvs(DPSContext ctxt)
+ cvs
+endps
+
+defineps DPScvx(DPSContext ctxt)
+ cvx
+endps
+
+defineps DPSdef(DPSContext ctxt)
+ def
+endps
+
+defineps DPSdict(DPSContext ctxt; int len)
+ len dict
+endps
+
+defineps DPSdictstack(DPSContext ctxt)
+ dictstack
+endps
+
+defineps DPSdup(DPSContext ctxt)
+ dup
+endps
+
+defineps DPSend(DPSContext ctxt)
+ end
+endps
+
+defineps DPSexch(DPSContext ctxt)
+ exch
+endps
+
+defineps DPSexecstack(DPSContext ctxt)
+ execstack
+endps
+
+defineps DPSexecuteonly(DPSContext ctxt)
+ executeonly
+endps
+
+defineps DPSget(DPSContext ctxt)
+ get
+endps
+
+defineps DPSgetinterval(DPSContext ctxt)
+ getinterval
+endps
+
+defineps DPSindex(DPSContext ctxt; int i)
+ i index
+endps
+
+defineps DPSknown(DPSContext ctxt | boolean *b)
+ known b
+endps
+
+defineps DPSlength(DPSContext ctxt | int *len)
+ length len
+endps
+
+defineps DPSload(DPSContext ctxt)
+ load
+endps
+
+defineps DPSmark(DPSContext ctxt)
+ mark
+endps
+
+defineps DPSmatrix(DPSContext ctxt)
+ matrix
+endps
+
+defineps DPSmaxlength(DPSContext ctxt | int *len)
+ maxlength len
+endps
+
+defineps DPSnoaccess(DPSContext ctxt)
+ noaccess
+endps
+
+defineps DPSnull(DPSContext ctxt)
+ null
+endps
+
+defineps DPSpackedarray(DPSContext ctxt)
+ packedarray
+endps
+
+defineps DPSpop(DPSContext ctxt)
+ pop
+endps
+
+defineps DPSput(DPSContext ctxt)
+ put
+endps
+
+defineps DPSputinterval(DPSContext ctxt)
+ putinterval
+endps
+
+defineps DPSrcheck(DPSContext ctxt | boolean *b)
+ rcheck b
+endps
+
+defineps DPSreadonly(DPSContext ctxt)
+ readonly
+endps
+
+defineps DPSroll(DPSContext ctxt; int n, j)
+ n j roll
+endps
+
+defineps DPSscheck(DPSContext ctxt | boolean *b)
+ scheck b
+endps
+
+defineps DPSsearch(DPSContext ctxt| boolean *b)
+ search b
+endps
+
+defineps DPSshareddict(DPSContext ctxt)
+ shareddict
+endps
+
+defineps DPSstatusdict(DPSContext ctxt)
+ statusdict
+endps
+
+defineps DPSstore(DPSContext ctxt)
+ store
+endps
+
+defineps DPSstring(DPSContext ctxt; int len)
+ len string
+endps
+
+defineps DPSstringwidth(DPSContext ctxt; char *s | float *xp, *yp)
+ (s) stringwidth yp xp
+endps
+
+defineps DPSsystemdict(DPSContext ctxt)
+ systemdict
+endps
+
+defineps DPSuserdict(DPSContext ctxt)
+ userdict
+endps
+
+defineps DPSwcheck(DPSContext ctxt | boolean *b)
+ wcheck b
+endps
+
+defineps DPSwhere(DPSContext ctxt| boolean *b)
+ where b
+endps
+
+defineps DPSxcheck(DPSContext ctxt | boolean *b)
+ xcheck b
+endps
+
diff --git a/nx-X11/lib/dps/dpsdict.c b/nx-X11/lib/dps/dpsdict.c
new file mode 100644
index 000000000..b2e8a04b2
--- /dev/null
+++ b/nx-X11/lib/dps/dpsdict.c
@@ -0,0 +1,189 @@
+/*
+ * dpsdict.c
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+/***********/
+/* Imports */
+/***********/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "dpsint.h"
+
+/********************/
+/* Types */
+/********************/
+
+typedef struct _EntryRec {
+ struct _EntryRec *next;
+ char *name;
+ PSWDictValue value;
+ } EntryRec, *Entry;
+
+ /* The concrete definition for a dictionary */
+ typedef struct _PSWDictRec {
+ integer nEntries;
+ Entry *entries;
+ } PSWDictRec;
+
+static PSWDict atoms;
+
+/**************************/
+/* Procedure Declarations */
+/**************************/
+
+/* Creates and returns a new dictionary. nEntries is a hint. */
+PSWDict DPSCreatePSWDict(integer nEntries)
+{
+ PSWDict d = (PSWDict)DPScalloc(sizeof(PSWDictRec), 1);
+ d->nEntries = nEntries;
+ d->entries = (Entry *)DPScalloc(sizeof(EntryRec), d->nEntries);
+ return d;
+}
+
+/* Destroys a dictionary */
+void DPSDestroyPSWDict(PSWDict dict)
+{
+ integer links = dict->nEntries;
+ Entry next;
+ Entry prev;
+
+ while (links > 0)
+ {
+ next = (dict->entries)[links];
+ while (next != NIL)
+ {
+ prev = next;
+ next = next->next;
+ free (prev);
+ }
+ links--;
+ }
+ free(dict->entries);
+ free(dict);
+}
+
+static integer Hash(char *name, integer nEntries)
+{
+ register integer val = 0;
+ while (*name) val += *name++;
+ if (val < 0) val = -val;
+ return (val % nEntries);
+}
+
+static Entry Probe(PSWDict d, integer x, char *name)
+{
+ register Entry e;
+ for (e = (d->entries)[x]; e != NIL; e = e->next) {
+ if (strcmp(name, e->name) == 0) break;
+ }
+ return e;
+}
+
+static Entry PrevProbe(Entry *prev, PSWDict d, integer x, char *name)
+{
+ register Entry e;
+ *prev = NIL;
+ for (e = (d->entries)[x]; e != NIL; e = e->next) {
+ if (strcmp(name, e->name) == 0) break;
+ *prev = e;
+ }
+ return e;
+}
+
+/* -1 => not found */
+PSWDictValue DPSWDictLookup(PSWDict dict, char *name)
+{
+ Entry e;
+ e = Probe(dict, Hash(name, dict->nEntries), name);
+ if (e == NIL) return -1;
+ return e->value;
+}
+
+/* 0 => normal return (not found)
+ -1 => found. If found, value is replaced. */
+PSWDictValue DPSWDictEnter(PSWDict dict, char *name, PSWDictValue value)
+{
+ Entry e;
+ integer x = Hash(name, dict->nEntries);
+ e = Probe(dict, x, name);
+ if (e != NIL) {
+ e->value = value;
+ return -1;
+ }
+ e = (Entry)DPScalloc(sizeof(EntryRec), 1);
+ e->next = (dict->entries)[x]; (dict->entries)[x] = e;
+ e->value = value;
+ e->name = name; /* MakeAtom(name); */
+ return 0;
+}
+
+/* -1 => not found. If found, value is returned. */
+PSWDictValue DPSWDictRemove(PSWDict dict, char *name)
+{
+ Entry e, prev;
+ PSWDictValue value;
+ integer x = Hash(name, dict->nEntries);
+
+ e = PrevProbe(&prev, dict, x, name);
+ if (e == NIL) return -1;
+ value = e->value;
+ if (prev == NIL) (dict->entries)[x] = e->next; else prev->next = e->next;
+ free(e);
+ return value;
+}
+
+Atom DPSMakeAtom(char *name)
+{
+ Entry e;
+ integer x = Hash(name, 511);
+ char *newname;
+
+ if (atoms == NIL) atoms = DPSCreatePSWDict(511);
+ e = Probe(atoms, x, name);
+ if (e == NIL) {
+ e = (Entry)DPScalloc(sizeof(EntryRec), 1);
+ e->next = (atoms->entries)[x]; (atoms->entries)[x] = e;
+ e->value = 0;
+ newname = (char *)DPScalloc(strlen(name)+1, 1);
+ strcpy(newname, name);
+ e->name = newname;
+ }
+ return (Atom) e->name;
+}
diff --git a/nx-X11/lib/dps/dpsdict.h b/nx-X11/lib/dps/dpsdict.h
new file mode 100644
index 000000000..18b40d42b
--- /dev/null
+++ b/nx-X11/lib/dps/dpsdict.h
@@ -0,0 +1,78 @@
+/*
+ * dpsdict.h
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#ifndef PSWDICT_H
+#define PSWDICT_H
+
+#include <X11/X.h>
+
+#include "publictypes.h"
+
+typedef struct _PSWDictRec *PSWDict;
+/* Opaque designator for a dictionary */
+
+typedef int PSWDictValue; /* non-negative */
+
+/* PROCEDURES */
+
+/* The name parameters defined below are NULL-terminated C strings.
+ None of the name parameters are handed off, i.e. the caller is
+ responsible for managing their storage. */
+
+extern PSWDict DPSCreatePSWDict(integer /* nEntries */);
+/* nEntries is a hint. Creates and returns a new dictionary */
+
+extern void DPSDestroyPSWDict(PSWDict /* dict */);
+/* Destroys a dictionary */
+
+extern PSWDictValue DPSWDictLookup(PSWDict /* dict */, char * /* name */);
+/* -1 => not found. */
+
+extern PSWDictValue DPSWDictEnter
+ (PSWDict /* dict */, char * /* name */, PSWDictValue /* value */);
+/* 0 => normal return (not found)
+ -1 => found. If found, the old value gets replaced with the new one.
+ caller must ensure continuing validity of name. */
+
+extern PSWDictValue DPSWDictRemove(PSWDict /* dict */, char * /* name */);
+/* -1 => not found. If found, value is returned. */
+
+extern Atom DPSMakeAtom(char * /* name */);
+/* name characters are copied. */
+
+#endif /* PSWDICT_H */
diff --git a/nx-X11/lib/dps/dpsendif.txt b/nx-X11/lib/dps/dpsendif.txt
new file mode 100644
index 000000000..80dd08085
--- /dev/null
+++ b/nx-X11/lib/dps/dpsendif.txt
@@ -0,0 +1,5 @@
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* DPSOPS_H */
diff --git a/nx-X11/lib/dps/dpsexcept.c b/nx-X11/lib/dps/dpsexcept.c
new file mode 100644
index 000000000..cd404dd86
--- /dev/null
+++ b/nx-X11/lib/dps/dpsexcept.c
@@ -0,0 +1,73 @@
+/*
+ * dpsexcept.c
+ *
+ * (c) Copyright 1984-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86: $ */
+
+/*
+Original version: Jeffrey Mogul, Stanford, 18 February 1983
+*/
+
+#ifdef VMS
+/* Add publictype.h to get a lowercase definition of "false" */
+#include "publictypes.h"
+#endif /* VMS */
+
+#include "DPS/dpsexcept.h"
+
+_Exc_Buf *_Exc_Header;
+
+
+
+void DPSRaise(code, msg)
+ int code; char *msg; {
+ register _Exc_Buf *EBp = _Exc_Header;
+
+ if (EBp == 0) { /* uncaught exception */
+ DPSCantHappen();
+ }
+
+ EBp->Code = code;
+ EBp->Message = msg;
+ _Exc_Header = EBp->Prev;
+ longjmp(EBp->Environ, 1);
+ }
+
+#ifndef XDPS
+void DPSCantHappen() {
+ abort();
+ }
+#endif /* XDPS */
diff --git a/nx-X11/lib/dps/dpsfontops.psw b/nx-X11/lib/dps/dpsfontops.psw
new file mode 100644
index 000000000..9958e776a
--- /dev/null
+++ b/nx-X11/lib/dps/dpsfontops.psw
@@ -0,0 +1,109 @@
+/* dpsfontops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSFontDirectory(DPSContext ctxt)
+ FontDirectory
+endps
+
+defineps DPSISOLatin1Encoding(DPSContext ctxt)
+ ISOLatin1Encoding
+endps
+
+defineps DPSSharedFontDirectory(DPSContext ctxt)
+ SharedFontDirectory
+endps
+
+defineps DPSStandardEncoding(DPSContext ctxt)
+ StandardEncoding
+endps
+
+defineps DPScachestatus(DPSContext ctxt)
+ cachestatus
+endps
+
+defineps DPScurrentcacheparams(DPSContext ctxt)
+ currentcacheparams
+endps
+
+defineps DPScurrentfont(DPSContext ctxt)
+ currentfont
+endps
+
+defineps DPSdefinefont(DPSContext ctxt)
+ definefont
+endps
+
+defineps DPSfindfont(DPSContext ctxt; char *name)
+ /name findfont
+endps
+
+defineps DPSmakefont(DPSContext ctxt)
+ makefont
+endps
+
+defineps DPSscalefont(DPSContext ctxt; float size)
+ size scalefont
+endps
+
+defineps DPSselectfont(DPSContext ctxt; char *name; float scale)
+ /name scale selectfont
+endps
+
+defineps DPSsetcachedevice(DPSContext ctxt; float wx, wy, llx, lly, urx, ury)
+ wx wy llx lly urx ury setcachedevice
+endps
+
+defineps DPSsetcachelimit(DPSContext ctxt; int n)
+ n setcachelimit
+endps
+
+defineps DPSsetcacheparams(DPSContext ctxt)
+ setcacheparams
+endps
+
+defineps DPSsetcharwidth(DPSContext ctxt; float wx, wy)
+ wx wy setcharwidth
+endps
+
+defineps DPSsetfont(DPSContext ctxt; userobject f)
+ f setfont
+endps
+
+defineps DPSundefinefont(DPSContext ctxt; char *name)
+ /name undefinefont
+endps
+
diff --git a/nx-X11/lib/dps/dpsgsttops.psw b/nx-X11/lib/dps/dpsgsttops.psw
new file mode 100644
index 000000000..d9b2728e7
--- /dev/null
+++ b/nx-X11/lib/dps/dpsgsttops.psw
@@ -0,0 +1,213 @@
+/* dpsgsttops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSconcat(DPSContext ctxt; float m[6])
+ m concat
+endps
+
+defineps DPScurrentdash(DPSContext ctxt)
+ currentdash
+endps
+
+defineps DPScurrentflat(DPSContext ctxt | float *flatness)
+ currentflat flatness
+endps
+
+defineps DPScurrentgray(DPSContext ctxt | float *gray)
+ currentgray gray
+endps
+
+defineps DPScurrentgstate(DPSContext ctxt; userobject gst)
+ gst currentgstate
+endps
+
+defineps DPScurrenthalftone(DPSContext ctxt)
+ currenthalftone
+endps
+
+defineps DPScurrenthalftonephase(DPSContext ctxt | float *x, *y)
+ currenthalftonephase y x
+endps
+
+defineps DPScurrenthsbcolor(DPSContext ctxt | float *h, *s, *b)
+ currenthsbcolor b s h
+endps
+
+defineps DPScurrentlinecap(DPSContext ctxt | int *linecap)
+ currentlinecap linecap
+endps
+
+defineps DPScurrentlinejoin(DPSContext ctxt | int *linejoin)
+ currentlinejoin linejoin
+endps
+
+defineps DPScurrentlinewidth(DPSContext ctxt | float *width)
+ currentlinewidth width
+endps
+
+defineps DPScurrentmatrix(DPSContext ctxt)
+ currentmatrix
+endps
+
+defineps DPScurrentmiterlimit(DPSContext ctxt | float *limit)
+ currentmiterlimit limit
+endps
+
+defineps DPScurrentpoint(DPSContext ctxt | float *x, *y)
+ currentpoint y x
+endps
+
+defineps DPScurrentrgbcolor(DPSContext ctxt | float *r, *g, *b)
+ currentrgbcolor b g r
+endps
+
+defineps DPScurrentscreen(DPSContext ctxt)
+ currentscreen
+endps
+
+defineps DPScurrentstrokeadjust(DPSContext ctxt | boolean *b)
+ currentstrokeadjust b
+endps
+
+defineps DPScurrenttransfer(DPSContext ctxt)
+ currenttransfer
+endps
+
+defineps DPSdefaultmatrix(DPSContext ctxt)
+ defaultmatrix
+endps
+
+defineps DPSgrestore(DPSContext ctxt)
+ grestore
+endps
+
+defineps DPSgrestoreall(DPSContext ctxt)
+ grestoreall
+endps
+
+defineps DPSgsave(DPSContext ctxt)
+ gsave
+endps
+
+defineps DPSgstate(DPSContext ctxt)
+ gstate
+endps
+
+defineps DPSinitgraphics(DPSContext ctxt)
+ initgraphics
+endps
+
+defineps DPSinitmatrix(DPSContext ctxt)
+ initmatrix
+endps
+
+defineps DPSrotate(DPSContext ctxt; float angle)
+ angle rotate
+endps
+
+defineps DPSscale(DPSContext ctxt; float x, y)
+ x y scale
+endps
+
+defineps DPSsetdash(DPSContext ctxt; float pat[size]; int size; float offset)
+ pat offset setdash
+endps
+
+defineps DPSsetflat(DPSContext ctxt; float flatness)
+ flatness setflat
+endps
+
+defineps DPSsetgray(DPSContext ctxt; float gray)
+ gray setgray
+endps
+
+defineps DPSsetgstate(DPSContext ctxt; userobject gst)
+ gst setgstate
+endps
+
+defineps DPSsethalftone(DPSContext ctxt)
+ sethalftone
+endps
+
+defineps DPSsethalftonephase(DPSContext ctxt; float x, y)
+ x y sethalftonephase
+endps
+
+defineps DPSsethsbcolor(DPSContext ctxt; float h, s, b)
+ h s b sethsbcolor
+endps
+
+defineps DPSsetlinecap(DPSContext ctxt; int linecap)
+ linecap setlinecap
+endps
+
+defineps DPSsetlinejoin(DPSContext ctxt; int linejoin)
+ linejoin setlinejoin
+endps
+
+defineps DPSsetlinewidth(DPSContext ctxt; float width)
+ width setlinewidth
+endps
+
+defineps DPSsetmatrix(DPSContext ctxt)
+ setmatrix
+endps
+
+defineps DPSsetmiterlimit(DPSContext ctxt; float limit)
+ limit setmiterlimit
+endps
+
+defineps DPSsetrgbcolor(DPSContext ctxt; float r, g, b)
+ r g b setrgbcolor
+endps
+
+defineps DPSsetscreen(DPSContext ctxt)
+ setscreen
+endps
+
+defineps DPSsetstrokeadjust(DPSContext ctxt; boolean b)
+ b setstrokeadjust
+endps
+
+defineps DPSsettransfer(DPSContext ctxt)
+ settransfer
+endps
+
+defineps DPStranslate(DPSContext ctxt; float x, y)
+ x y translate
+endps
+
diff --git a/nx-X11/lib/dps/dpsifdef.txt b/nx-X11/lib/dps/dpsifdef.txt
new file mode 100644
index 000000000..d44b7c85f
--- /dev/null
+++ b/nx-X11/lib/dps/dpsifdef.txt
@@ -0,0 +1,7 @@
+#ifndef DPSOPS_H
+#define DPSOPS_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
diff --git a/nx-X11/lib/dps/dpsint.h b/nx-X11/lib/dps/dpsint.h
new file mode 100644
index 000000000..8d5ede870
--- /dev/null
+++ b/nx-X11/lib/dps/dpsint.h
@@ -0,0 +1,125 @@
+/*
+ * dpsint.h -- internal definitions to dpsclient.c
+ *
+ * (c) Copyright 1989-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#ifndef DPSINT_H
+#define DPSINT_H
+
+#include <DPS/dpsXclient.h>
+
+#include "publictypes.h"
+#include "dpsassert.h"
+
+#include "dpsprivate.h"
+#include "dpsXint.h"
+#include "dpsdict.h"
+
+typedef struct _t_ContextBufferRec {
+ struct _t_ContextBufferRec *next;
+ } ContextBufferRec, *ContextBuffer;
+
+typedef struct {
+ ContextBuffer gcontextBuffers;
+ integer gqueuedBuffers;
+ DPSProcs gctxProcs, gtextCtxProcs, gdummyCtxProcs;
+ DPSSpaceProcs gspaceProcs;
+ DPSPrivSpace gspaces;
+ char **guserNames;
+ integer guserNamesLength;
+ PSWDict guserNameDict;
+ boolean gclientStarted;
+ DPSContext gdummyCtx;
+ integer ginitFailed, gglobLastNameIndex;
+ DPSPrivSpace gTextSpace;
+} GlobalsRec, *Globals;
+
+extern Globals DPSglobals;
+
+#define contextBuffers DPSglobals->gcontextBuffers
+#define queuedBuffers DPSglobals->gqueuedBuffers
+#define ctxProcs DPSglobals->gctxProcs
+#define textCtxProcs DPSglobals->gtextCtxProcs
+#define dummyCtxProcs DPSglobals->gdummyCtxProcs
+#define spaceProcs DPSglobals->gspaceProcs
+#define spaces DPSglobals->gspaces
+#define userNames DPSglobals->guserNames
+#define userNamesLength DPSglobals->guserNamesLength
+#define userNameDict DPSglobals->guserNameDict
+#define clientStarted DPSglobals->gclientStarted
+#define dummyCtx DPSglobals->gdummyCtx
+#define initFailed DPSglobals->ginitFailed
+#define globLastNameIndex DPSglobals->gglobLastNameIndex
+#define textSpace DPSglobals->gTextSpace
+
+extern boolean DPSCheckShared(DPSPrivContext ctxt);
+extern boolean DPSKnownContext(DPSContext ctxt);
+extern boolean DPSKnownSpace(DPSSpace space);
+extern boolean DPSPrivateCheckWait(DPSContext ctxt);
+extern void DPSCheckInitClientGlobals(void);
+extern void DPSPrivateDestroyContext(DPSContext ctxt);
+extern void DPSPrivateDestroySpace(DPSSpace space);
+extern void DPSSafeSetLastNameIndex(DPSContext ctxt);
+extern void DPSclientPrintProc(DPSContext ctxt, char *buf, unsigned nch);
+extern void DPSinnerProcWriteData(DPSContext ctxt, char *buf, unsigned int count);
+
+extern void DPSDefaultPrivateHandler(
+ DPSContext ctxt,
+ DPSErrorCode errorCode,
+ long unsigned int arg1,
+ long unsigned int arg2,
+ char *prefix,
+ char *suffix);
+
+extern char *DPScalloc(integer e, integer n);
+
+extern DPSContext DPSCreateContext(
+ char *wh,
+ DPSTextProc textProc,
+ DPSErrorProc errorProc,
+ DPSSpace space);
+
+extern void DPSHandleBogusError(DPSContext ctxt, char *prefix, char *suffix);
+extern void DPSInitCommonContextProcs(DPSProcs p);
+extern void DPSInitCommonSpaceProcs(DPSSpaceProcs p);
+extern void DPSInitCommonTextContextProcs(DPSProcs p);
+extern void DPSInitPrivateContextFields(DPSPrivContext c, DPSPrivSpace s);
+extern void DPSInitPrivateContextProcs(DPSProcs p);
+extern void DPSInitPrivateSpaceFields(DPSPrivSpace s);
+extern void DPSInitPrivateTextContextFields(DPSPrivContext c, DPSPrivSpace s);
+extern void DPSServicePostScript(boolean (*returnControl)(void));
+
+#endif /* DPSINT_H */
diff --git a/nx-X11/lib/dps/dpsioops.psw b/nx-X11/lib/dps/dpsioops.psw
new file mode 100644
index 000000000..dec3bb7c3
--- /dev/null
+++ b/nx-X11/lib/dps/dpsioops.psw
@@ -0,0 +1,153 @@
+/* dpsioops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSequals(DPSContext ctxt)
+ =
+endps
+
+defineps DPSequalsequals(DPSContext ctxt)
+ ==
+endps
+
+defineps DPSbytesavailable(DPSContext ctxt | int *n)
+ bytesavailable n
+endps
+
+defineps DPSclosefile(DPSContext ctxt)
+ closefile
+endps
+
+defineps DPScurrentfile(DPSContext ctxt)
+ currentfile
+endps
+
+defineps DPSdeletefile(DPSContext ctxt; char *filename)
+ (filename) deletefile
+endps
+
+defineps DPSecho(DPSContext ctxt; boolean b)
+ b echo
+endps
+
+defineps DPSfile(DPSContext ctxt; char *name, *access)
+ (name) (access) file
+endps
+
+defineps DPSfilenameforall(DPSContext ctxt)
+ filenameforall
+endps
+
+defineps DPSfileposition(DPSContext ctxt | int *pos)
+ fileposition pos
+endps
+
+defineps DPSflush(DPSContext ctxt)
+ flush
+endps
+
+defineps DPSflushfile(DPSContext ctxt)
+ flushfile
+endps
+
+defineps DPSprint(DPSContext ctxt)
+ print
+endps
+
+defineps DPSprintobject(DPSContext ctxt; int tag)
+ tag printobject
+endps
+
+defineps DPSpstack(DPSContext ctxt)
+ pstack
+endps
+
+defineps DPSread(DPSContext ctxt| boolean *b)
+ read b
+endps
+
+defineps DPSreadhexstring(DPSContext ctxt| boolean *b)
+ readhexstring b
+endps
+
+defineps DPSreadline(DPSContext ctxt| boolean *b)
+ readline b
+endps
+
+defineps DPSreadstring(DPSContext ctxt| boolean *b)
+ readstring b
+endps
+
+defineps DPSrenamefile(DPSContext ctxt; char *oldname, *newname)
+ (oldname) (newname) renamefile
+endps
+
+defineps DPSresetfile(DPSContext ctxt)
+ resetfile
+endps
+
+defineps DPSsetfileposition(DPSContext ctxt; int pos)
+ pos setfileposition
+endps
+
+defineps DPSstack(DPSContext ctxt)
+ stack
+endps
+
+defineps DPSstatus(DPSContext ctxt | boolean *b)
+ status b
+endps
+
+defineps DPStoken(DPSContext ctxt| boolean *b)
+ token b
+endps
+
+defineps DPSwrite(DPSContext ctxt)
+ write
+endps
+
+defineps DPSwritehexstring(DPSContext ctxt)
+ writehexstring
+endps
+
+defineps DPSwriteobject(DPSContext ctxt; int tag)
+ tag writeobject
+endps
+
+defineps DPSwritestring(DPSContext ctxt)
+ writestring
+endps
+
diff --git a/nx-X11/lib/dps/dpsl2ops.psw b/nx-X11/lib/dps/dpsl2ops.psw
new file mode 100644
index 000000000..67c1aee22
--- /dev/null
+++ b/nx-X11/lib/dps/dpsl2ops.psw
@@ -0,0 +1,208 @@
+/* dpsl2ops.psw
+ * (c) Copyright 1991-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSleftbracket(DPSContext ctxt)
+ mark % [ annoys pswrap
+endps
+
+defineps DPSrightbracket(DPSContext ctxt)
+ counttomark array astore exch pop % ] annoys pswrap
+endps
+
+defineps DPSleftleft(DPSContext ctxt)
+ <<
+endps
+
+defineps DPSrightright(DPSContext ctxt)
+ >>
+endps
+
+defineps DPScshow(DPSContext ctxt; char *s)
+ (s) cshow
+endps
+
+defineps DPScurrentcolor(DPSContext ctxt)
+ currentcolor
+endps
+
+defineps DPScurrentcolorrendering(DPSContext ctxt)
+ currentcolorrendering
+endps
+
+defineps DPScurrentcolorspace(DPSContext ctxt)
+ currentcolorspace
+endps
+
+defineps DPScurrentdevparams(DPSContext ctxt; char *dev)
+ (dev) currentdevparams
+endps
+
+defineps DPScurrentglobal(DPSContext ctxt | boolean *b)
+ currentglobal b
+endps
+
+defineps DPScurrentoverprint(DPSContext ctxt | boolean *b)
+ currentoverprint b
+endps
+
+defineps DPScurrentpagedevice(DPSContext ctxt)
+ currentpagedevice
+endps
+
+defineps DPScurrentsystemparams(DPSContext ctxt)
+ currentsystemparams
+endps
+
+defineps DPScurrentuserparams(DPSContext ctxt)
+ currentuserparams
+endps
+
+defineps DPSdefineresource(DPSContext ctxt; char *category)
+ /category defineresource
+endps
+
+defineps DPSexecform(DPSContext ctxt)
+ execform
+endps
+
+defineps DPSfilter(DPSContext ctxt)
+ filter
+endps
+
+defineps DPSfindencoding(DPSContext ctxt; char *key)
+ /key findencoding
+endps
+
+defineps DPSfindresource(DPSContext ctxt; char *key, *category)
+ /key /category findresource
+endps
+
+defineps DPSgcheck(DPSContext ctxt | boolean *b)
+ gcheck b
+endps
+
+defineps DPSglobaldict(DPSContext ctxt)
+ globaldict
+endps
+
+defineps DPSGlobalFontDirectory(DPSContext ctxt)
+ GlobalFontDirectory
+endps
+
+defineps DPSglyphshow(DPSContext ctxt; char *name)
+ /name glyphshow
+endps
+
+defineps DPSlanguagelevel(DPSContext ctxt | int *n)
+ languagelevel n
+endps
+
+defineps DPSmakepattern(DPSContext ctxt)
+ makepattern
+endps
+
+defineps DPSproduct(DPSContext ctxt)
+ product
+endps
+
+defineps DPSresourceforall(DPSContext ctxt; char *category)
+ /category resourceforall
+endps
+
+defineps DPSresourcestatus(DPSContext ctxt; char *key, *category; | boolean *b)
+ /key /category resourcestatus b
+endps
+
+defineps DPSrevision(DPSContext ctxt | int *n)
+ revision n
+endps
+
+defineps DPSrootfont(DPSContext ctxt)
+ rootfont
+endps
+
+defineps DPSserialnumber(DPSContext ctxt | int *n)
+ serialnumber n
+endps
+
+defineps DPSsetcolor(DPSContext ctxt)
+ setcolor
+endps
+
+defineps DPSsetcolorrendering(DPSContext ctxt)
+ setcolorrendering
+endps
+
+defineps DPSsetcolorspace(DPSContext ctxt)
+ setcolorspace
+endps
+
+defineps DPSsetdevparams(DPSContext ctxt)
+ setdevparams
+endps
+
+defineps DPSsetglobal(DPSContext ctxt; boolean b)
+ b setglobal
+endps
+
+defineps DPSsetoverprint(DPSContext ctxt; boolean b)
+ b setoverprint
+endps
+
+defineps DPSsetpagedevice(DPSContext ctxt)
+ setpagedevice
+endps
+
+defineps DPSsetpattern(DPSContext ctxt)
+ setpattern
+endps
+
+defineps DPSsetsystemparams(DPSContext ctxt)
+ setsystemparams
+endps
+
+defineps DPSsetuserparams(DPSContext ctxt)
+ setuserparams
+endps
+
+defineps DPSstartjob(DPSContext ctxt; boolean b; char *password)
+ b password startjob
+endps
+
+defineps DPSundefineresource(DPSContext ctxt; char *key, *category)
+ /key /category undefineresource
+endps
+
diff --git a/nx-X11/lib/dps/dpsmathops.psw b/nx-X11/lib/dps/dpsmathops.psw
new file mode 100644
index 000000000..e7ada11af
--- /dev/null
+++ b/nx-X11/lib/dps/dpsmathops.psw
@@ -0,0 +1,125 @@
+/* dpsmathops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSabs(DPSContext ctxt)
+ abs
+endps
+
+defineps DPSadd(DPSContext ctxt)
+ add
+endps
+
+defineps DPSand(DPSContext ctxt)
+ and
+endps
+
+defineps DPSatan(DPSContext ctxt)
+ atan
+endps
+
+defineps DPSbitshift(DPSContext ctxt; int shift)
+ shift bitshift
+endps
+
+defineps DPSceiling(DPSContext ctxt)
+ ceiling
+endps
+
+defineps DPScos(DPSContext ctxt)
+ cos
+endps
+
+defineps DPSdiv(DPSContext ctxt)
+ div
+endps
+
+defineps DPSexp(DPSContext ctxt)
+ exp
+endps
+
+defineps DPSfloor(DPSContext ctxt)
+ floor
+endps
+
+defineps DPSidiv(DPSContext ctxt)
+ idiv
+endps
+
+defineps DPSln(DPSContext ctxt)
+ ln
+endps
+
+defineps DPSlog(DPSContext ctxt)
+ log
+endps
+
+defineps DPSmod(DPSContext ctxt)
+ mod
+endps
+
+defineps DPSmul(DPSContext ctxt)
+ mul
+endps
+
+defineps DPSneg(DPSContext ctxt)
+ neg
+endps
+
+defineps DPSround(DPSContext ctxt)
+ round
+endps
+
+defineps DPSsin(DPSContext ctxt)
+ sin
+endps
+
+defineps DPSsqrt(DPSContext ctxt)
+ sqrt
+endps
+
+defineps DPSsub(DPSContext ctxt)
+ sub
+endps
+
+defineps DPStruncate(DPSContext ctxt)
+ truncate
+endps
+
+defineps DPSxor(DPSContext ctxt)
+ xor
+endps
+
diff --git a/nx-X11/lib/dps/dpsmiscops.psw b/nx-X11/lib/dps/dpsmiscops.psw
new file mode 100644
index 000000000..6b5bb8078
--- /dev/null
+++ b/nx-X11/lib/dps/dpsmiscops.psw
@@ -0,0 +1,53 @@
+/* dpsmiscops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSbanddevice(DPSContext ctxt)
+ banddevice
+endps
+
+defineps DPSframedevice(DPSContext ctxt)
+ framedevice
+endps
+
+defineps DPSnulldevice(DPSContext ctxt)
+ nulldevice
+endps
+
+defineps DPSrenderbands(DPSContext ctxt)
+ renderbands
+endps
+
diff --git a/nx-X11/lib/dps/dpsmtrxops.psw b/nx-X11/lib/dps/dpsmtrxops.psw
new file mode 100644
index 000000000..6b5303ba0
--- /dev/null
+++ b/nx-X11/lib/dps/dpsmtrxops.psw
@@ -0,0 +1,65 @@
+/* dpsmtrxops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSconcatmatrix(DPSContext ctxt)
+ concatmatrix
+endps
+
+defineps DPSdtransform(DPSContext ctxt; float x1, y1 | float *x2, *y2)
+ x1 y1 dtransform y2 x2
+endps
+
+defineps DPSidentmatrix(DPSContext ctxt)
+ identmatrix
+endps
+
+defineps DPSidtransform(DPSContext ctxt; float x1, y1 | float *x2, *y2)
+ x1 y1 idtransform y2 x2
+endps
+
+defineps DPSinvertmatrix(DPSContext ctxt)
+ invertmatrix
+endps
+
+defineps DPSitransform(DPSContext ctxt; float x1, y1 | float *x2, *y2)
+ x1 y1 itransform y2 x2
+endps
+
+defineps DPStransform(DPSContext ctxt; float x1, y1 | float *x2, *y2)
+ x1 y1 transform y2 x2
+endps
+
diff --git a/nx-X11/lib/dps/dpsname.txt b/nx-X11/lib/dps/dpsname.txt
new file mode 100644
index 000000000..ab32b7f7d
--- /dev/null
+++ b/nx-X11/lib/dps/dpsname.txt
@@ -0,0 +1,4 @@
+/*
+ * dpsops.h
+ */
+
diff --git a/nx-X11/lib/dps/dpsopstack.psw b/nx-X11/lib/dps/dpsopstack.psw
new file mode 100644
index 000000000..ac10d77c5
--- /dev/null
+++ b/nx-X11/lib/dps/dpsopstack.psw
@@ -0,0 +1,96 @@
+/*
+ * dpsopstack.psw -- wrapped procedures for sending and getting operands
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSgetboolean(DPSContext ctxt | boolean *it)
+ it
+endps
+
+defineps DPSgetchararray(DPSContext ctxt; int size | char s[size])
+ s
+endps
+
+defineps DPSgetfloat(DPSContext ctxt | float *it)
+ it
+endps
+
+defineps DPSgetfloatarray(DPSContext ctxt; int size | float a[size])
+ dup type /arraytype eq { a } { size { a } repeat } ifelse
+endps
+
+defineps DPSgetint(DPSContext ctxt | int *it)
+ it
+endps
+
+defineps DPSgetintarray(DPSContext ctxt; int size | int a[size])
+ dup type /arraytype eq { a } { size { a } repeat } ifelse
+endps
+
+defineps DPSgetstring(DPSContext ctxt | char *s)
+ s
+endps
+
+defineps DPSsendboolean(DPSContext ctxt; boolean it)
+ it
+endps
+
+defineps DPSsendchararray(DPSContext ctxt; char s[size]; int size)
+ (s)
+endps
+
+defineps DPSsendfloat(DPSContext ctxt; float it)
+ it
+endps
+
+defineps DPSsendfloatarray(DPSContext ctxt; float a[size]; int size)
+ a
+endps
+
+defineps DPSsendint(DPSContext ctxt; int it)
+ it
+endps
+
+defineps DPSsendintarray(DPSContext ctxt; int a[size]; int size)
+ a
+endps
+
+defineps DPSsendstring(DPSContext ctxt; char *s)
+ (s)
+endps
+
+
+
diff --git a/nx-X11/lib/dps/dpspathops.psw b/nx-X11/lib/dps/dpspathops.psw
new file mode 100644
index 000000000..7c0ed7600
--- /dev/null
+++ b/nx-X11/lib/dps/dpspathops.psw
@@ -0,0 +1,169 @@
+/* dpspathops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSarc(DPSContext ctxt; float x, y, r, angle1, angle2)
+ x y r angle1 angle2 arc
+endps
+
+defineps DPSarcn(DPSContext ctxt; float x, y, r, angle1, angle2)
+ x y r angle1 angle2 arcn
+endps
+
+defineps DPSarct(DPSContext ctxt; float x1, y1, x2, y2, r)
+ x1 y1 x2 y2 r arct
+endps
+
+defineps DPSarcto(DPSContext ctxt; float x1, y1, x2, y2, r | float *xt1, *yt1, *xt2, *yt2)
+ x1 y1 x2 y2 r arcto yt2 xt2 yt1 xt1
+endps
+
+defineps DPScharpath(DPSContext ctxt; char *s; boolean b)
+ (s) b charpath
+endps
+
+defineps DPSclip(DPSContext ctxt)
+ clip
+endps
+
+defineps DPSclippath(DPSContext ctxt)
+ clippath
+endps
+
+defineps DPSclosepath(DPSContext ctxt)
+ closepath
+endps
+
+defineps DPScurveto(DPSContext ctxt; float x1, y1, x2, y2, x3, y3)
+ x1 y1 x2 y2 x3 y3 curveto
+endps
+
+defineps DPSeoclip(DPSContext ctxt)
+ eoclip
+endps
+
+defineps DPSeoviewclip(DPSContext ctxt)
+ eoviewclip
+endps
+
+defineps DPSflattenpath(DPSContext ctxt)
+ flattenpath
+endps
+
+defineps DPSinitclip(DPSContext ctxt)
+ initclip
+endps
+
+defineps DPSinitviewclip(DPSContext ctxt)
+ initviewclip
+endps
+
+defineps DPSlineto(DPSContext ctxt; float x, y)
+ x y lineto
+endps
+
+defineps DPSmoveto(DPSContext ctxt; float x, y)
+ x y moveto
+endps
+
+defineps DPSnewpath(DPSContext ctxt)
+ newpath
+endps
+
+defineps DPSpathbbox(DPSContext ctxt | float *llx, *lly, *urx, *ury)
+ pathbbox ury urx lly llx
+endps
+
+defineps DPSpathforall(DPSContext ctxt)
+ pathforall
+endps
+
+defineps DPSrcurveto(DPSContext ctxt; float x1, y1, x2, y2, x3, y3)
+ x1 y1 x2 y2 x3 y3 rcurveto
+endps
+
+defineps DPSrectclip(DPSContext ctxt; float x, y, w, h)
+ x y w h rectclip
+endps
+
+defineps DPSrectviewclip(DPSContext ctxt; float x, y, w, h)
+ x y w h rectviewclip
+endps
+
+defineps DPSreversepath(DPSContext ctxt)
+ reversepath
+endps
+
+defineps DPSrlineto(DPSContext ctxt; float x, y)
+ x y rlineto
+endps
+
+defineps DPSrmoveto(DPSContext ctxt; float x, y)
+ x y rmoveto
+endps
+
+defineps DPSsetbbox(DPSContext ctxt; float llx, lly, urx, ury)
+ llx lly urx ury setbbox
+endps
+
+defineps DPSsetucacheparams(DPSContext ctxt)
+ setucacheparams
+endps
+
+defineps DPSuappend(DPSContext ctxt; char nums[n]; int n; char ops[l]; int l)
+ [(nums) (ops)] uappend
+endps
+
+defineps DPSucache(DPSContext ctxt)
+ ucache
+endps
+
+defineps DPSucachestatus(DPSContext ctxt)
+ ucachestatus
+endps
+
+defineps DPSupath(DPSContext ctxt; boolean b)
+ b upath
+endps
+
+defineps DPSviewclip(DPSContext ctxt)
+ viewclip
+endps
+
+defineps DPSviewclippath(DPSContext ctxt)
+ viewclippath
+endps
+
diff --git a/nx-X11/lib/dps/dpspntops.psw b/nx-X11/lib/dps/dpspntops.psw
new file mode 100644
index 000000000..e57de4997
--- /dev/null
+++ b/nx-X11/lib/dps/dpspntops.psw
@@ -0,0 +1,129 @@
+/* dpspntops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSashow(DPSContext ctxt; float x, y; char *s)
+ x y (s) ashow
+endps
+
+defineps DPSawidthshow(DPSContext ctxt; float cx, cy; int c; float ax, ay; char *s)
+ cx cy c ax ay (s) awidthshow
+endps
+
+defineps DPScopypage(DPSContext ctxt)
+ copypage
+endps
+
+defineps DPSeofill(DPSContext ctxt)
+ eofill
+endps
+
+defineps DPSerasepage(DPSContext ctxt)
+ erasepage
+endps
+
+defineps DPSfill(DPSContext ctxt)
+ fill
+endps
+
+defineps DPSimage(DPSContext ctxt)
+ image
+endps
+
+defineps DPSimagemask(DPSContext ctxt)
+ imagemask
+endps
+
+defineps DPSkshow(DPSContext ctxt; char *s)
+ (s) kshow
+endps
+
+defineps DPSrectfill(DPSContext ctxt; float x, y, w, h)
+ x y w h rectfill
+endps
+
+defineps DPSrectstroke(DPSContext ctxt; float x, y, w, h)
+ x y w h rectstroke
+endps
+
+defineps DPSshow(DPSContext ctxt; char *s)
+ (s) show
+endps
+
+defineps DPSshowpage(DPSContext ctxt)
+ showpage
+endps
+
+defineps DPSstroke(DPSContext ctxt)
+ stroke
+endps
+
+defineps DPSstrokepath(DPSContext ctxt)
+ strokepath
+endps
+
+defineps DPSueofill(DPSContext ctxt; char nums[n]; int n; char ops[l]; int l)
+ [(nums) (ops)] ueofill
+endps
+
+defineps DPSufill(DPSContext ctxt; char nums[n]; int n; char ops[l]; int l)
+ [(nums) (ops)] ufill
+endps
+
+defineps DPSustroke(DPSContext ctxt; char nums[n]; int n; char ops[l]; int l)
+ [(nums) (ops)] ustroke
+endps
+
+defineps DPSustrokepath(DPSContext ctxt; char nums[n]; int n; char ops[l]; int l)
+ [(nums) (ops)] ustrokepath
+endps
+
+defineps DPSwidthshow(DPSContext ctxt; float x, y; int c; char *s)
+ x y c (s) widthshow
+endps
+
+defineps DPSxshow(DPSContext ctxt; char *s; float numarray[size]; int size)
+ (s) numarray xshow
+endps
+
+defineps DPSxyshow(DPSContext ctxt; char *s; float numarray[size]; int size)
+ (s) numarray xyshow
+endps
+
+defineps DPSyshow(DPSContext ctxt; char *s; float numarray[size]; int size)
+ (s) numarray yshow
+endps
+
diff --git a/nx-X11/lib/dps/dpsprintf.c b/nx-X11/lib/dps/dpsprintf.c
new file mode 100644
index 000000000..79d8172b6
--- /dev/null
+++ b/nx-X11/lib/dps/dpsprintf.c
@@ -0,0 +1,68 @@
+/*
+ * dpsprintf.c
+ *
+ * (c) Copyright 1985-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86: xc/lib/dps/dpsprintf.c,v 1.3 2000/09/26 15:57:00 tsi Exp $ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "publictypes.h"
+#include "DPS/dpsclient.h"
+
+#ifdef USE_DOPRINT
+extern void DPSdoprint();
+#endif /* USE_DOPRINT */
+
+#include <stdarg.h>
+
+void DPSPrintf(DPSContext ctxt, char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+
+#ifdef USE_DOPRINT
+ DPSdoprint(ctxt, fmt, &args);
+#else /* USE_DOPRINT */
+ {
+ char buffer[10000];
+ vsprintf(buffer, fmt, args);
+ DPSWritePostScript(ctxt, buffer, strlen(buffer));
+ }
+#endif /* USE_DOPRINT */
+ va_end(args);
+}
diff --git a/nx-X11/lib/dps/dpsprivate.h b/nx-X11/lib/dps/dpsprivate.h
new file mode 100644
index 000000000..0392eedd6
--- /dev/null
+++ b/nx-X11/lib/dps/dpsprivate.h
@@ -0,0 +1,127 @@
+/*
+ * dpsprivate.h -- Private interface for the DPS client library implementation.
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#ifndef DPSPRIVATE_H
+#define DPSPRIVATE_H
+
+#include "DPS/dpsconfig.h"
+#include "DPS/dpsclient.h"
+
+typedef enum {
+ dps_hiFirst, dps_loFirst
+ } DPSByteOrder;
+
+typedef enum {
+ dps_ieee, dps_native
+ } DPSNumFormat;
+
+typedef void (*DPSClientPrintProc)(
+ DPSContext /* cid */,
+ char * /* buf */,
+ unsigned int /* count */);
+ /* Call-back procedure to handle output from the PostScript server for
+ context with id 'cid'. Passed to DPSServicePostScript.
+ 'buf' contains 'count' bytes. */
+
+extern void DPSInitClient(
+ DPSTextProc textProc,
+ void (* /* releaseProc */) (char *, char *));
+/* Initialize the environment-specific parts of the client library */
+
+#ifndef DPSDefaultProgramEncoding
+#define DPSDefaultProgramEncoding dps_binObjSeq
+#endif /* not DPSDefaultProgramEncoding */
+
+#ifndef DPSDefaultByteOrder
+#if SWAPBITS
+#define DPSDefaultByteOrder dps_loFirst
+#else /* SWAPBITS */
+#define DPSDefaultByteOrder dps_hiFirst
+#endif /* SWAPBITS */
+#endif /* DPSDefaultByteOrder */
+
+#ifndef DPSDefaultNumFormat
+#if IEEEFLOAT
+#define DPSDefaultNumFormat dps_ieee
+#else /* IEEEFLOAT */
+#define DPSDefaultNumFormat dps_native
+#endif /* IEEEFLOAT */
+#endif /* not DPSDefaultNumFormat */
+
+#ifndef DPSDefaultNameEncoding
+#define DPSDefaultNameEncoding dps_indexed
+#endif /* not DPSDefaultNameEncoding */
+
+extern void DPSCheckRaiseError(DPSContext c);
+ /* Checks the resynching flag in a DPSPrivContext and raises an exception
+ if true */
+
+/* system name table boundaries */
+#define DPS_LAST_COMMON_SYSNAME 212
+#define DPS_FIRST_AUX_SYSNAME 256
+#define DPS_LAST_AUX_SYSNAME 427
+
+extern char **DPSSysNames;
+extern char **DPSSysNamesAux;
+
+ /* System name tables. DPSSysNames[index] is the string for the name.
+ DPSSysNamesAux[index - DPS_FIRST_AUX_SYSNAME] is the string
+ for an uncommon system name. */
+
+extern int DPSInitialize(void);
+extern void DPSInitSysNames(void);
+
+extern char *DPSSetWh(DPSContext /* ctxt */, char * /* newWh */);
+ /* set new window handle, returns old window handle */
+
+extern void DPSOutOfMemory(void);
+ /*
+ This is called by the DPS software when it cannot allocate any more
+ storage from the heap (e.g., when malloc returns NIL).
+
+ MAC ONLY
+ DPSOutOfMemory calls CantHappen (see dpsexcept.h) unless you
+ have used DPSSetOutOfMemoryProc to establish a different procedure
+ to be called, in which case DPSOutOfMemory calls your procedure instead.
+ If your procedure returns, DPSOutOfMemory returns to its caller, which
+ re-attempts the allocation. Note that another allocation failure will
+ cause DPSOutOfMemory to be called again (and again ...).
+
+ */
+
+#endif /* DPSPRIVATE_H */
diff --git a/nx-X11/lib/dps/dpssimpint.h b/nx-X11/lib/dps/dpssimpint.h
new file mode 100644
index 000000000..8485bc389
--- /dev/null
+++ b/nx-X11/lib/dps/dpssimpint.h
@@ -0,0 +1,88 @@
+/*
+ * dpsXint.h -- internal definitions to dpsXclient.c
+ *
+ * (c) Copyright 1989-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#ifndef DPSXINT_H
+#define DPSXINT_H
+
+/* The first part of this structure is generic; the last part is
+ implementation-specific. */
+
+typedef struct _t_DPSPrivContextRec {
+ char *priv;
+ DPSSpace space;
+ DPSProgramEncoding programEncoding;
+ DPSNameEncoding nameEncoding;
+ DPSProcs procs;
+ void (*textProc)();
+ void (*errorProc)();
+ DPSResults resultTable;
+ unsigned int resultTableLength;
+ struct _t_DPSContextRec *chainParent, *chainChild;
+ unsigned int contextFlags;
+ DPSContextExtensionRec *extension;
+
+ struct _t_DPSPrivContextRec *next;
+ integer lastNameIndex, cid;
+ boolean eofReceived;
+ char *wh;
+ char *buf, *outBuf, *objBuf;
+ integer nBufChars, nOutBufChars, nObjBufChars;
+ DPSNumFormat numFormat;
+
+/* Nothing is simple-specific */
+
+} DPSPrivContextRec, *DPSPrivContext;
+
+/* The first part of this structure is generic; the last part is
+ implementation-specific. */
+
+typedef struct _t_DPSPrivSpaceRec {
+ DPSSpaceProcs procs;
+
+ struct _t_DPSPrivSpaceRec *next;
+ long int lastNameIndex, sid;
+ char *wh; /* KLUDGE to support DPSSendDestroySpace */
+ DPSPrivContext firstContext;
+
+/* Nothing is simple-specific */
+
+} DPSPrivSpaceRec, *DPSPrivSpace;
+
+#include "dpsint.h"
+
+#endif /* DPSXINT_H */
diff --git a/nx-X11/lib/dps/dpssysnames.c b/nx-X11/lib/dps/dpssysnames.c
new file mode 100644
index 000000000..54bf07431
--- /dev/null
+++ b/nx-X11/lib/dps/dpssysnames.c
@@ -0,0 +1,444 @@
+/* dpssysnames.c -- system name table
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#include "publictypes.h"
+#include "DPS/dpsclient.h"
+#include "dpsprivate.h"
+
+char **DPSSysNames;
+char **DPSSysNamesAux;
+
+static char *sysNames[] = {
+ "abs",
+ "add",
+ "aload",
+ "anchorsearch",
+ "and",
+ "arc",
+ "arcn",
+ "arct",
+ "arcto",
+ "array",
+ "ashow",
+ "astore",
+ "awidthshow",
+ "begin",
+ "bind",
+ "bitshift",
+ "ceiling",
+ "charpath",
+ "clear",
+ "cleartomark",
+ "clip",
+ "clippath",
+ "closepath",
+ "concat",
+ "concatmatrix",
+ "copy",
+ "count",
+ "counttomark",
+ "currentcmykcolor",
+ "currentdash",
+ "currentdict",
+ "currentfile",
+ "currentfont",
+ "currentgray",
+ "currentgstate",
+ "currenthsbcolor",
+ "currentlinecap",
+ "currentlinejoin",
+ "currentlinewidth",
+ "currentmatrix",
+ "currentpoint",
+ "currentrgbcolor",
+ "currentshared",
+ "curveto",
+ "cvi",
+ "cvlit",
+ "cvn",
+ "cvr",
+ "cvrs",
+ "cvs",
+ "cvx",
+ "def",
+ "defineusername",
+ "dict",
+ "div",
+ "dtransform",
+ "dup",
+ "end",
+ "eoclip",
+ "eofill",
+ "eoviewclip",
+ "eq",
+ "exch",
+ "exec",
+ "exit",
+ "file",
+ "fill",
+ "findfont",
+ "flattenpath",
+ "floor",
+ "flush",
+ "flushfile",
+ "for",
+ "forall",
+ "ge",
+ "get",
+ "getinterval",
+ "grestore",
+ "gsave",
+ "gstate",
+ "gt",
+ "identmatrix",
+ "idiv",
+ "idtransform",
+ "if",
+ "ifelse",
+ "image",
+ "imagemask",
+ "index",
+ "ineofill",
+ "infill",
+ "initviewclip",
+ "inueofill",
+ "inufill",
+ "invertmatrix",
+ "itransform",
+ "known",
+ "le",
+ "length",
+ "lineto",
+ "load",
+ "loop",
+ "lt",
+ "makefont",
+ "matrix",
+ "maxlength",
+ "mod",
+ "moveto",
+ "mul",
+ "ne",
+ "neg",
+ "newpath",
+ "not",
+ "null",
+ "or",
+ "pathbbox",
+ "pathforall",
+ "pop",
+ "print",
+ "printobject",
+ "put",
+ "putinterval",
+ "rcurveto",
+ "read",
+ "readhexstring",
+ "readline",
+ "readstring",
+ "rectclip",
+ "rectfill",
+ "rectstroke",
+ "rectviewclip",
+ "repeat",
+ "restore",
+ "rlineto",
+ "rmoveto",
+ "roll",
+ "rotate",
+ "round",
+ "save",
+ "scale",
+ "scalefont",
+ "search",
+ "selectfont",
+ "setbbox",
+ "setcachedevice",
+ "setcachedevice2",
+ "setcharwidth",
+ "setcmykcolor",
+ "setdash",
+ "setfont",
+ "setgray",
+ "setgstate",
+ "sethsbcolor",
+ "setlinecap",
+ "setlinejoin",
+ "setlinewidth",
+ "setmatrix",
+ "setrgbcolor",
+ "setshared",
+ "shareddict",
+ "show",
+ "showpage",
+ "stop",
+ "stopped",
+ "store",
+ "string",
+ "stringwidth",
+ "stroke",
+ "strokepath",
+ "sub",
+ "systemdict",
+ "token",
+ "transform",
+ "translate",
+ "truncate",
+ "type",
+ "uappend",
+ "ucache",
+ "ueofill",
+ "ufill",
+ "undef",
+ "upath",
+ "userdict",
+ "ustroke",
+ "viewclip",
+ "viewclippath",
+ "where",
+ "widthshow",
+ "write",
+ "writehexstring",
+ "writeobject",
+ "writestring",
+ "wtranslation",
+ "xor",
+ "xshow",
+ "xyshow",
+ "yshow",
+ "FontDirectory",
+ "SharedFontDirectory",
+ "Courier",
+ "Courier-Bold",
+ "Courier-BoldOblique",
+ "Courier-Oblique",
+ "Helvetica",
+ "Helvetica-Bold",
+ "Helvetica-BoldOblique",
+ "Helvetica-Oblique",
+ "Symbol",
+ "Times-Bold",
+ "Times-BoldItalic",
+ "Times-Italic",
+ "Times-Roman",
+ "execuserobject", /* 212 */
+ ""
+};
+
+static char *sysNamesAux[] = {
+ "=", /* 256 */
+ "==",
+ "ISOLatin1Encoding",
+ "StandardEncoding",
+ "[",
+ "]",
+ "atan",
+ "banddevice",
+ "bytesavailable",
+ "cachestatus",
+ "closefile",
+ "colorimage",
+ "condition",
+ "copypage",
+ "cos",
+ "countdictstack",
+ "countexecstack",
+ "cshow",
+ "currentblackgeneration",
+ "currentcacheparams",
+ "currentcolorscreen",
+ "currentcolortransfer",
+ "currentcontext",
+ "currentflat",
+ "currenthalftone",
+ "currenthalftonephase",
+ "currentmiterlimit",
+ "currentobjectformat",
+ "currentpacking",
+ "currentscreen",
+ "currentstrokeadjust",
+ "currenttransfer",
+ "currentundercolorremoval",
+ "defaultmatrix",
+ "definefont",
+ "deletefile",
+ "detach",
+ "deviceinfo",
+ "dictstack",
+ "echo",
+ "erasepage",
+ "errordict",
+ "execstack",
+ "executeonly",
+ "exp",
+ "false",
+ "filenameforall",
+ "fileposition",
+ "fork",
+ "framedevice",
+ "grestoreall",
+ "handleerror",
+ "initclip",
+ "initgraphics",
+ "initmatrix",
+ "instroke",
+ "inustroke",
+ "join",
+ "kshow",
+ "ln",
+ "lock",
+ "log",
+ "mark",
+ "monitor",
+ "noaccess",
+ "notify",
+ "nulldevice",
+ "packedarray",
+ "quit",
+ "rand",
+ "rcheck",
+ "readonly",
+ "realtime",
+ "renamefile",
+ "renderbands",
+ "resetfile",
+ "reversepath",
+ "rootfont",
+ "rrand",
+ "run",
+ "scheck",
+ "setblackgeneration",
+ "setcachelimit",
+ "setcacheparams",
+ "setcolorscreen",
+ "setcolortransfer",
+ "setfileposition",
+ "setflat",
+ "sethalftone",
+ "sethalftonephase",
+ "setmiterlimit",
+ "setobjectformat",
+ "setpacking",
+ "setscreen",
+ "setstrokeadjust",
+ "settransfer",
+ "setucacheparams",
+ "setundercolorremoval",
+ "sin",
+ "sqrt",
+ "srand",
+ "stack",
+ "status",
+ "statusdict",
+ "true",
+ "ucachestatus",
+ "undefinefont",
+ "usertime",
+ "ustrokepath",
+ "version",
+ "vmreclaim",
+ "vmstatus",
+ "wait",
+ "wcheck",
+ "xcheck",
+ "yield",
+ "defineuserobject",
+ "undefineuserobject",
+ "UserObjects",
+ "cleardictstack",
+ "A", /* 376 */
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ "K",
+ "L",
+ "M",
+ "N",
+ "O",
+ "P",
+ "Q",
+ "R",
+ "S",
+ "T",
+ "U",
+ "V",
+ "W",
+ "X",
+ "Y",
+ "Z",
+ "a",
+ "b",
+ "c",
+ "d",
+ "e",
+ "f",
+ "g",
+ "h",
+ "i",
+ "j",
+ "k",
+ "l",
+ "m",
+ "n",
+ "o",
+ "p",
+ "q",
+ "r",
+ "s",
+ "t",
+ "u",
+ "v",
+ "w",
+ "x",
+ "y",
+ "z", /* 427 */
+ "setvmthreshold", /* 428 */
+ "<<", /* 429 */
+ ">>", /* 430 */
+ ""
+};
+
+void DPSInitSysNames() {
+ DPSSysNames = (char **)sysNames;
+ DPSSysNamesAux = (char **)sysNamesAux;
+ }
diff --git a/nx-X11/lib/dps/dpssysops.psw b/nx-X11/lib/dps/dpssysops.psw
new file mode 100644
index 000000000..731287930
--- /dev/null
+++ b/nx-X11/lib/dps/dpssysops.psw
@@ -0,0 +1,149 @@
+/* dpssysops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSbind(DPSContext ctxt)
+ bind
+endps
+
+defineps DPScleardictstack(DPSContext ctxt)
+ cleardictstack
+endps
+
+defineps DPScountdictstack(DPSContext ctxt | int *n)
+ countdictstack n
+endps
+
+defineps DPScountexecstack(DPSContext ctxt | int *n)
+ countexecstack n
+endps
+
+defineps DPScurrentdict(DPSContext ctxt)
+ currentdict
+endps
+
+defineps DPScurrentpacking(DPSContext ctxt | boolean *b)
+ currentpacking b
+endps
+
+defineps DPScurrentshared(DPSContext ctxt | boolean *b)
+ currentshared b
+endps
+
+defineps DPSdeviceinfo(DPSContext ctxt)
+ deviceinfo
+endps
+
+defineps DPSerrordict(DPSContext ctxt)
+ errordict
+endps
+
+defineps DPSexec(DPSContext ctxt)
+ exec
+endps
+
+defineps DPSprompt(DPSContext ctxt)
+ prompt
+endps
+
+defineps DPSquit(DPSContext ctxt)
+ quit
+endps
+
+defineps DPSrand(DPSContext ctxt)
+ rand
+endps
+
+defineps DPSrealtime(DPSContext ctxt | int *i)
+ realtime i
+endps
+
+defineps DPSrestore(DPSContext ctxt)
+ restore
+endps
+
+defineps DPSrrand(DPSContext ctxt)
+ rrand
+endps
+
+defineps DPSrun(DPSContext ctxt; char *filename)
+ (filename) run
+endps
+
+defineps DPSsave(DPSContext ctxt)
+ save
+endps
+
+defineps DPSsetpacking(DPSContext ctxt; boolean b)
+ b setpacking
+endps
+
+defineps DPSsetshared(DPSContext ctxt; boolean b)
+ b setshared
+endps
+
+defineps DPSsrand(DPSContext ctxt)
+ srand
+endps
+
+defineps DPSstart(DPSContext ctxt)
+ start
+endps
+
+defineps DPStype(DPSContext ctxt)
+ type
+endps
+
+defineps DPSundef(DPSContext ctxt; char *name)
+ /name undef
+endps
+
+defineps DPSusertime(DPSContext ctxt | int *milliseconds)
+ usertime milliseconds
+endps
+
+defineps DPSversion(DPSContext ctxt; int bufsize | char buf[bufsize])
+ version buf
+endps
+
+defineps DPSvmreclaim(DPSContext ctxt; int code)
+ code vmreclaim
+endps
+
+defineps DPSvmstatus(DPSContext ctxt | int *level, *used, *maximum)
+ vmstatus maximum used level
+endps
+
diff --git a/nx-X11/lib/dps/dpswinops.psw b/nx-X11/lib/dps/dpswinops.psw
new file mode 100644
index 000000000..6ccf77b4c
--- /dev/null
+++ b/nx-X11/lib/dps/dpswinops.psw
@@ -0,0 +1,65 @@
+/* dpswinops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps DPSineofill(DPSContext ctxt; float x, y | boolean *b)
+ x y ineofill b
+endps
+
+defineps DPSinfill(DPSContext ctxt; float x, y | boolean *b)
+ x y infill b
+endps
+
+defineps DPSinstroke(DPSContext ctxt; float x, y | boolean *b)
+ x y instroke b
+endps
+
+defineps DPSinueofill(DPSContext ctxt; float x, y; char nums[n]; int n; char ops[l]; int l | boolean *b)
+ x y [(nums) (ops)] inueofill b
+endps
+
+defineps DPSinufill(DPSContext ctxt; float x, y; char nums[n]; int n; char ops[l]; int l | boolean *b)
+ x y [(nums) (ops)] inufill b
+endps
+
+defineps DPSinustroke(DPSContext ctxt; float x, y; char nums[n]; int n; char ops[l]; int l | boolean *b)
+ x y [(nums) (ops)] inustroke b
+endps
+
+defineps DPSwtranslation(DPSContext ctxt | float *x, *y)
+ wtranslation y x
+endps
+
diff --git a/nx-X11/lib/dps/else.txt b/nx-X11/lib/dps/else.txt
new file mode 100644
index 000000000..b74df412a
--- /dev/null
+++ b/nx-X11/lib/dps/else.txt
@@ -0,0 +1,6 @@
+#else /* _NO_PROTO */
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
diff --git a/nx-X11/lib/dps/genheader.cmd b/nx-X11/lib/dps/genheader.cmd
new file mode 100644
index 000000000..b1784e232
--- /dev/null
+++ b/nx-X11/lib/dps/genheader.cmd
@@ -0,0 +1,14 @@
+REM
+/* OS/2 generate header files */
+/* $XFree86: xc/lib/dps/genheader.cmd,v 1.1 2000/04/05 18:13:22 dawes Exp $ */
+cat psclrops.h psctrlops.h psctxtops.h psdataops.h psfontops.h psgsttops.h psioops.h psmathops.h psmtrxops.h psmiscops.h pspntops.h pspathops.h pssysops.h pswinops.h psopstack.h psXops.h psl2ops.h >.ph
+sed -e "/^$$/D" -e "/#/D" -e "/^\//D" -e "/^ gener/D" -e "/^.\//D" .ph | sort >.sort
+awk "/;/ {print;printf(\"\n\");}" .sort >.ttt
+cat psname.txt header.txt psifdef.txt .ttt psendif.txt > psops.h.os2
+rm .ph .sort .ttt
+
+cat dpsclrops.h dpsctrlops.h dpsctxtops.h dpsdataops.h dpsfontops.h dpsgsttops.h dpsioops.h dpsmathops.h dpsmtrxops.h dpsmiscops.h dpspntops.h dpspathops.h dpssysops.h dpswinops.h dpsopstack.h dpsXops.h dpsl2ops.h >.ph
+sed -e "/^$$/D" -e "/#/D" -e "/^\//D" -e "/^ gener/D" -e "/^.\//D" .ph | sort >.sort
+awk "/;/ {print;printf(\"\n\");}" .sort >.ttt
+cat dpsname.txt header.txt dpsifdef.txt .ttt dpsendif.txt > dpsops.h.os2
+rm .ph .sort .ttt
diff --git a/nx-X11/lib/dps/header.txt b/nx-X11/lib/dps/header.txt
new file mode 100644
index 000000000..8b37ebe67
--- /dev/null
+++ b/nx-X11/lib/dps/header.txt
@@ -0,0 +1,35 @@
+/*
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
diff --git a/nx-X11/lib/dps/psXops.psw b/nx-X11/lib/dps/psXops.psw
new file mode 100644
index 000000000..5d350418f
--- /dev/null
+++ b/nx-X11/lib/dps/psXops.psw
@@ -0,0 +1,81 @@
+/* psXops.psw
+ *
+ * (c) Copyright 1991-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+defineps PSclientsync()
+ clientsync
+endps
+
+defineps PScurrentXgcdrawable(| int *gc, *draw, *x, *y)
+ currentXgcdrawable y x draw gc
+endps
+
+defineps PScurrentXgcdrawablecolor(| int *gc, *draw, *x, *y, colorInfo[12])
+ currentXgcdrawablecolor colorInfo y x draw gc
+endps
+
+defineps PScurrentXoffset(| int *x, *y)
+ currentXoffset y x
+endps
+
+defineps PSsetXgcdrawable(int gc, draw, x, y)
+ gc draw x y setXgcdrawable
+endps
+
+defineps PSsetXgcdrawablecolor(int gc, draw, x, y, colorInfo[12])
+ gc draw x y colorInfo setXgcdrawablecolor
+endps
+
+defineps PSsetXoffset(int x, y)
+ x y setXoffset
+endps
+
+defineps PSsetXrgbactual(float r, g, b | boolean *success)
+ r g b setXrgbactual success
+endps
+
+defineps PSclientXready(int i0, i1, i2, i3)
+ [ i0 i1 i2 i3 ] clientXready
+endps
+
+defineps PSsetXdrawingfunction(int function)
+ function setXdrawingfunction
+endps
+
+defineps PScurrentXdrawingfunction(| int *function)
+ currentXdrawingfunction function
+endps
diff --git a/nx-X11/lib/dps/psclrops.psw b/nx-X11/lib/dps/psclrops.psw
new file mode 100644
index 000000000..986f85176
--- /dev/null
+++ b/nx-X11/lib/dps/psclrops.psw
@@ -0,0 +1,81 @@
+/* psclrops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PScolorimage()
+ colorimage
+endps
+
+defineps PScurrentblackgeneration()
+ currentblackgeneration
+endps
+
+defineps PScurrentcmykcolor( | float *c, *m, *y, *k)
+ currentcmykcolor k y m c
+endps
+
+defineps PScurrentcolorscreen()
+ currentcolorscreen
+endps
+
+defineps PScurrentcolortransfer()
+ currentcolortransfer
+endps
+
+defineps PScurrentundercolorremoval()
+ currentundercolorremoval
+endps
+
+defineps PSsetblackgeneration()
+ setblackgeneration
+endps
+
+defineps PSsetcmykcolor(float c, m, y, k)
+ c m y k setcmykcolor
+endps
+
+defineps PSsetcolorscreen()
+ setcolorscreen
+endps
+
+defineps PSsetcolortransfer()
+ setcolortransfer
+endps
+
+defineps PSsetundercolorremoval()
+ setundercolorremoval
+endps
+
diff --git a/nx-X11/lib/dps/psctrlops.psw b/nx-X11/lib/dps/psctrlops.psw
new file mode 100644
index 000000000..882020d63
--- /dev/null
+++ b/nx-X11/lib/dps/psctrlops.psw
@@ -0,0 +1,113 @@
+/* psctrlops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSeq()
+ eq
+endps
+
+defineps PSexit()
+ exit
+endps
+
+defineps PSfalse()
+ false
+endps
+
+defineps PSfor()
+ for
+endps
+
+defineps PSforall()
+ forall
+endps
+
+defineps PSge()
+ ge
+endps
+
+defineps PSgt()
+ gt
+endps
+
+defineps PSif()
+ if
+endps
+
+defineps PSifelse()
+ ifelse
+endps
+
+defineps PSle()
+ le
+endps
+
+defineps PSloop()
+ loop
+endps
+
+defineps PSlt()
+ lt
+endps
+
+defineps PSne()
+ ne
+endps
+
+defineps PSnot()
+ not
+endps
+
+defineps PSor()
+ or
+endps
+
+defineps PSrepeat()
+ repeat
+endps
+
+defineps PSstop()
+ stop
+endps
+
+defineps PSstopped()
+ stopped
+endps
+
+defineps PStrue()
+ true
+endps
+
diff --git a/nx-X11/lib/dps/psctxtops.psw b/nx-X11/lib/dps/psctxtops.psw
new file mode 100644
index 000000000..43ca803fc
--- /dev/null
+++ b/nx-X11/lib/dps/psctxtops.psw
@@ -0,0 +1,109 @@
+/* psctxtops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSUserObjects()
+ UserObjects
+endps
+
+defineps PScondition()
+ condition
+endps
+
+defineps PScurrentcontext( | int *cid)
+ currentcontext cid
+endps
+
+defineps PScurrentobjectformat( | int *code)
+ currentobjectformat code
+endps
+
+defineps PSdefineusername(int i; char *username)
+ i /username defineusername
+endps
+
+defineps PSdefineuserobject()
+ defineuserobject
+endps
+
+defineps PSdetach()
+ detach
+endps
+
+defineps PSexecuserobject(int userObjIndex)
+ userObjIndex execuserobject
+endps
+
+defineps PSfork()
+ fork
+endps
+
+defineps PSjoin()
+ join
+endps
+
+defineps PSlock()
+ lock
+endps
+
+defineps PSmonitor()
+ monitor
+endps
+
+defineps PSnotify()
+ notify
+endps
+
+defineps PSsetobjectformat(int code)
+ code setobjectformat
+endps
+
+defineps PSsetvmthreshold(int i)
+ i setvmthreshold
+endps
+
+defineps PSundefineuserobject(int userObjIndex)
+ userObjIndex undefineuserobject
+endps
+
+defineps PSwait()
+ wait
+endps
+
+defineps PSyield()
+ yield
+endps
+
diff --git a/nx-X11/lib/dps/psdataops.psw b/nx-X11/lib/dps/psdataops.psw
new file mode 100644
index 000000000..ee89313f6
--- /dev/null
+++ b/nx-X11/lib/dps/psdataops.psw
@@ -0,0 +1,257 @@
+/* psdataops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSaload()
+ aload
+endps
+
+defineps PSanchorsearch(| boolean *truth)
+ anchorsearch truth
+endps
+
+defineps PSarray(int len)
+ len array
+endps
+
+defineps PSastore()
+ astore
+endps
+
+defineps PSbegin()
+ begin
+endps
+
+defineps PSclear()
+ clear
+endps
+
+defineps PScleartomark()
+ cleartomark
+endps
+
+defineps PScopy(int n)
+ n copy
+endps
+
+defineps PScount( | int *n)
+ count n
+endps
+
+defineps PScounttomark( | int *n)
+ counttomark n
+endps
+
+defineps PScvi()
+ cvi
+endps
+
+defineps PScvlit()
+ cvlit
+endps
+
+defineps PScvn()
+ cvn
+endps
+
+defineps PScvr()
+ cvr
+endps
+
+defineps PScvrs()
+ cvrs
+endps
+
+defineps PScvs()
+ cvs
+endps
+
+defineps PScvx()
+ cvx
+endps
+
+defineps PSdef()
+ def
+endps
+
+defineps PSdict(int len)
+ len dict
+endps
+
+defineps PSdictstack()
+ dictstack
+endps
+
+defineps PSdup()
+ dup
+endps
+
+defineps PSend()
+ end
+endps
+
+defineps PSexch()
+ exch
+endps
+
+defineps PSexecstack()
+ execstack
+endps
+
+defineps PSexecuteonly()
+ executeonly
+endps
+
+defineps PSget()
+ get
+endps
+
+defineps PSgetinterval()
+ getinterval
+endps
+
+defineps PSindex(int i)
+ i index
+endps
+
+defineps PSknown( | boolean *b)
+ known b
+endps
+
+defineps PSlength( | int *len)
+ length len
+endps
+
+defineps PSload()
+ load
+endps
+
+defineps PSmark()
+ mark
+endps
+
+defineps PSmatrix()
+ matrix
+endps
+
+defineps PSmaxlength( | int *len)
+ maxlength len
+endps
+
+defineps PSnoaccess()
+ noaccess
+endps
+
+defineps PSnull()
+ null
+endps
+
+defineps PSpackedarray()
+ packedarray
+endps
+
+defineps PSpop()
+ pop
+endps
+
+defineps PSput()
+ put
+endps
+
+defineps PSputinterval()
+ putinterval
+endps
+
+defineps PSrcheck( | boolean *b)
+ rcheck b
+endps
+
+defineps PSreadonly()
+ readonly
+endps
+
+defineps PSroll(int n, j)
+ n j roll
+endps
+
+defineps PSscheck( | boolean *b)
+ scheck b
+endps
+
+defineps PSsearch(| boolean *b)
+ search b
+endps
+
+defineps PSshareddict()
+ shareddict
+endps
+
+defineps PSstatusdict()
+ statusdict
+endps
+
+defineps PSstore()
+ store
+endps
+
+defineps PSstring(int len)
+ len string
+endps
+
+defineps PSstringwidth(char *s | float *xp, *yp)
+ (s) stringwidth yp xp
+endps
+
+defineps PSsystemdict()
+ systemdict
+endps
+
+defineps PSuserdict()
+ userdict
+endps
+
+defineps PSwcheck( | boolean *b)
+ wcheck b
+endps
+
+defineps PSwhere(| boolean *b)
+ where b
+endps
+
+defineps PSxcheck( | boolean *b)
+ xcheck b
+endps
+
diff --git a/nx-X11/lib/dps/psendif.txt b/nx-X11/lib/dps/psendif.txt
new file mode 100644
index 000000000..cd3eae5f3
--- /dev/null
+++ b/nx-X11/lib/dps/psendif.txt
@@ -0,0 +1,6 @@
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* PSOPS_H */
diff --git a/nx-X11/lib/dps/psfontops.psw b/nx-X11/lib/dps/psfontops.psw
new file mode 100644
index 000000000..9d9b99914
--- /dev/null
+++ b/nx-X11/lib/dps/psfontops.psw
@@ -0,0 +1,109 @@
+/* psfontops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSFontDirectory()
+ FontDirectory
+endps
+
+defineps PSISOLatin1Encoding()
+ ISOLatin1Encoding
+endps
+
+defineps PSSharedFontDirectory()
+ SharedFontDirectory
+endps
+
+defineps PSStandardEncoding()
+ StandardEncoding
+endps
+
+defineps PScachestatus()
+ cachestatus
+endps
+
+defineps PScurrentcacheparams()
+ currentcacheparams
+endps
+
+defineps PScurrentfont()
+ currentfont
+endps
+
+defineps PSdefinefont()
+ definefont
+endps
+
+defineps PSfindfont(char *name)
+ /name findfont
+endps
+
+defineps PSmakefont()
+ makefont
+endps
+
+defineps PSscalefont(float size)
+ size scalefont
+endps
+
+defineps PSselectfont(char *name; float scale)
+ /name scale selectfont
+endps
+
+defineps PSsetcachedevice(float wx, wy, llx, lly, urx, ury)
+ wx wy llx lly urx ury setcachedevice
+endps
+
+defineps PSsetcachelimit(int n)
+ n setcachelimit
+endps
+
+defineps PSsetcacheparams()
+ setcacheparams
+endps
+
+defineps PSsetcharwidth(float wx, wy)
+ wx wy setcharwidth
+endps
+
+defineps PSsetfont(userobject f)
+ f setfont
+endps
+
+defineps PSundefinefont(char *name)
+ /name undefinefont
+endps
+
diff --git a/nx-X11/lib/dps/psgsttops.psw b/nx-X11/lib/dps/psgsttops.psw
new file mode 100644
index 000000000..a6eb87b62
--- /dev/null
+++ b/nx-X11/lib/dps/psgsttops.psw
@@ -0,0 +1,213 @@
+/* psgsttops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSconcat(float m[6])
+ m concat
+endps
+
+defineps PScurrentdash()
+ currentdash
+endps
+
+defineps PScurrentflat( | float *flatness)
+ currentflat flatness
+endps
+
+defineps PScurrentgray( | float *gray)
+ currentgray gray
+endps
+
+defineps PScurrentgstate(userobject gst)
+ gst currentgstate
+endps
+
+defineps PScurrenthalftone()
+ currenthalftone
+endps
+
+defineps PScurrenthalftonephase( | float *x, *y)
+ currenthalftonephase y x
+endps
+
+defineps PScurrenthsbcolor( | float *h, *s, *b)
+ currenthsbcolor b s h
+endps
+
+defineps PScurrentlinecap( | int *linecap)
+ currentlinecap linecap
+endps
+
+defineps PScurrentlinejoin( | int *linejoin)
+ currentlinejoin linejoin
+endps
+
+defineps PScurrentlinewidth( | float *width)
+ currentlinewidth width
+endps
+
+defineps PScurrentmatrix()
+ currentmatrix
+endps
+
+defineps PScurrentmiterlimit( | float *limit)
+ currentmiterlimit limit
+endps
+
+defineps PScurrentpoint( | float *x, *y)
+ currentpoint y x
+endps
+
+defineps PScurrentrgbcolor( | float *r, *g, *b)
+ currentrgbcolor b g r
+endps
+
+defineps PScurrentscreen()
+ currentscreen
+endps
+
+defineps PScurrentstrokeadjust( | boolean *b)
+ currentstrokeadjust b
+endps
+
+defineps PScurrenttransfer()
+ currenttransfer
+endps
+
+defineps PSdefaultmatrix()
+ defaultmatrix
+endps
+
+defineps PSgrestore()
+ grestore
+endps
+
+defineps PSgrestoreall()
+ grestoreall
+endps
+
+defineps PSgsave()
+ gsave
+endps
+
+defineps PSgstate()
+ gstate
+endps
+
+defineps PSinitgraphics()
+ initgraphics
+endps
+
+defineps PSinitmatrix()
+ initmatrix
+endps
+
+defineps PSrotate(float angle)
+ angle rotate
+endps
+
+defineps PSscale(float x, y)
+ x y scale
+endps
+
+defineps PSsetdash(float pat[size]; int size; float offset)
+ pat offset setdash
+endps
+
+defineps PSsetflat(float flatness)
+ flatness setflat
+endps
+
+defineps PSsetgray(float gray)
+ gray setgray
+endps
+
+defineps PSsetgstate(userobject gst)
+ gst setgstate
+endps
+
+defineps PSsethalftone()
+ sethalftone
+endps
+
+defineps PSsethalftonephase(float x, y)
+ x y sethalftonephase
+endps
+
+defineps PSsethsbcolor(float h, s, b)
+ h s b sethsbcolor
+endps
+
+defineps PSsetlinecap(int linecap)
+ linecap setlinecap
+endps
+
+defineps PSsetlinejoin(int linejoin)
+ linejoin setlinejoin
+endps
+
+defineps PSsetlinewidth(float width)
+ width setlinewidth
+endps
+
+defineps PSsetmatrix()
+ setmatrix
+endps
+
+defineps PSsetmiterlimit(float limit)
+ limit setmiterlimit
+endps
+
+defineps PSsetrgbcolor(float r, g, b)
+ r g b setrgbcolor
+endps
+
+defineps PSsetscreen()
+ setscreen
+endps
+
+defineps PSsetstrokeadjust(boolean b)
+ b setstrokeadjust
+endps
+
+defineps PSsettransfer()
+ settransfer
+endps
+
+defineps PStranslate(float x, y)
+ x y translate
+endps
+
diff --git a/nx-X11/lib/dps/psifdef.txt b/nx-X11/lib/dps/psifdef.txt
new file mode 100644
index 000000000..0de071a23
--- /dev/null
+++ b/nx-X11/lib/dps/psifdef.txt
@@ -0,0 +1,7 @@
+#ifndef PSOPS_H
+#define PSOPS_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
diff --git a/nx-X11/lib/dps/psioops.psw b/nx-X11/lib/dps/psioops.psw
new file mode 100644
index 000000000..c4d4b4bb9
--- /dev/null
+++ b/nx-X11/lib/dps/psioops.psw
@@ -0,0 +1,153 @@
+/* psioops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSequals()
+ =
+endps
+
+defineps PSequalsequals()
+ ==
+endps
+
+defineps PSbytesavailable( | int *n)
+ bytesavailable n
+endps
+
+defineps PSclosefile()
+ closefile
+endps
+
+defineps PScurrentfile()
+ currentfile
+endps
+
+defineps PSdeletefile(char *filename)
+ (filename) deletefile
+endps
+
+defineps PSecho(boolean b)
+ b echo
+endps
+
+defineps PSfile(char *name, *access)
+ (name) (access) file
+endps
+
+defineps PSfilenameforall()
+ filenameforall
+endps
+
+defineps PSfileposition( | int *pos)
+ fileposition pos
+endps
+
+defineps PSflush()
+ flush
+endps
+
+defineps PSflushfile()
+ flushfile
+endps
+
+defineps PSprint()
+ print
+endps
+
+defineps PSprintobject(int tag)
+ tag printobject
+endps
+
+defineps PSpstack()
+ pstack
+endps
+
+defineps PSread(| boolean *b)
+ read b
+endps
+
+defineps PSreadhexstring(| boolean *b)
+ readhexstring b
+endps
+
+defineps PSreadline(| boolean *b)
+ readline b
+endps
+
+defineps PSreadstring(| boolean *b)
+ readstring b
+endps
+
+defineps PSrenamefile(char *oldname, *newname)
+ (oldname) (newname) renamefile
+endps
+
+defineps PSresetfile()
+ resetfile
+endps
+
+defineps PSsetfileposition(int pos)
+ pos setfileposition
+endps
+
+defineps PSstack()
+ stack
+endps
+
+defineps PSstatus( | boolean *b)
+ status b
+endps
+
+defineps PStoken(| boolean *b)
+ token b
+endps
+
+defineps PSwrite()
+ write
+endps
+
+defineps PSwritehexstring()
+ writehexstring
+endps
+
+defineps PSwriteobject(int tag)
+ tag writeobject
+endps
+
+defineps PSwritestring()
+ writestring
+endps
+
diff --git a/nx-X11/lib/dps/psl2ops.psw b/nx-X11/lib/dps/psl2ops.psw
new file mode 100644
index 000000000..684b5b2e0
--- /dev/null
+++ b/nx-X11/lib/dps/psl2ops.psw
@@ -0,0 +1,208 @@
+/* psl2ops.psw
+ * (c) Copyright 1991-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSleftbracket()
+ mark % [ annoys pswrap
+endps
+
+defineps PSrightbracket()
+ counttomark array astore exch pop % ] annoys pswrap
+endps
+
+defineps PSleftleft()
+ <<
+endps
+
+defineps PSrightright()
+ >>
+endps
+
+defineps PScshow(char *s)
+ (s) cshow
+endps
+
+defineps PScurrentcolor()
+ currentcolor
+endps
+
+defineps PScurrentcolorrendering()
+ currentcolorrendering
+endps
+
+defineps PScurrentcolorspace()
+ currentcolorspace
+endps
+
+defineps PScurrentdevparams(char *dev)
+ (dev) currentdevparams
+endps
+
+defineps PScurrentglobal(| boolean *b)
+ currentglobal b
+endps
+
+defineps PScurrentoverprint(| boolean *b)
+ currentoverprint b
+endps
+
+defineps PScurrentpagedevice()
+ currentpagedevice
+endps
+
+defineps PScurrentsystemparams()
+ currentsystemparams
+endps
+
+defineps PScurrentuserparams()
+ currentuserparams
+endps
+
+defineps PSdefineresource(char *category)
+ /category defineresource
+endps
+
+defineps PSexecform()
+ execform
+endps
+
+defineps PSfilter()
+ filter
+endps
+
+defineps PSfindencoding(char *key)
+ /key findencoding
+endps
+
+defineps PSfindresource(char *key, *category)
+ /key /category findresource
+endps
+
+defineps PSgcheck(| boolean *b)
+ gcheck b
+endps
+
+defineps PSglobaldict()
+ globaldict
+endps
+
+defineps PSGlobalFontDirectory()
+ GlobalFontDirectory
+endps
+
+defineps PSglyphshow(char *name)
+ /name glyphshow
+endps
+
+defineps PSlanguagelevel(| int *n)
+ languagelevel n
+endps
+
+defineps PSmakepattern()
+ makepattern
+endps
+
+defineps PSproduct()
+ product
+endps
+
+defineps PSresourceforall(char *category)
+ /category resourceforall
+endps
+
+defineps PSresourcestatus(char *key, *category; | boolean *b)
+ /key /category resourcestatus b
+endps
+
+defineps PSrevision(| int *n)
+ revision n
+endps
+
+defineps PSrootfont()
+ rootfont
+endps
+
+defineps PSserialnumber(| int *n)
+ serialnumber n
+endps
+
+defineps PSsetcolor()
+ setcolor
+endps
+
+defineps PSsetcolorrendering()
+ setcolorrendering
+endps
+
+defineps PSsetcolorspace()
+ setcolorspace
+endps
+
+defineps PSsetdevparams()
+ setdevparams
+endps
+
+defineps PSsetglobal(boolean b)
+ b setglobal
+endps
+
+defineps PSsetoverprint(boolean b)
+ b setoverprint
+endps
+
+defineps PSsetpagedevice()
+ setpagedevice
+endps
+
+defineps PSsetpattern()
+ setpattern
+endps
+
+defineps PSsetsystemparams()
+ setsystemparams
+endps
+
+defineps PSsetuserparams()
+ setuserparams
+endps
+
+defineps PSstartjob(boolean b; char *password)
+ b password startjob
+endps
+
+defineps PSundefineresource(char *key, *category)
+ /key /category undefineresource
+endps
+
diff --git a/nx-X11/lib/dps/psmathops.psw b/nx-X11/lib/dps/psmathops.psw
new file mode 100644
index 000000000..268535348
--- /dev/null
+++ b/nx-X11/lib/dps/psmathops.psw
@@ -0,0 +1,125 @@
+/* psmathops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSabs()
+ abs
+endps
+
+defineps PSadd()
+ add
+endps
+
+defineps PSand()
+ and
+endps
+
+defineps PSatan()
+ atan
+endps
+
+defineps PSbitshift(int shift)
+ shift bitshift
+endps
+
+defineps PSceiling()
+ ceiling
+endps
+
+defineps PScos()
+ cos
+endps
+
+defineps PSdiv()
+ div
+endps
+
+defineps PSexp()
+ exp
+endps
+
+defineps PSfloor()
+ floor
+endps
+
+defineps PSidiv()
+ idiv
+endps
+
+defineps PSln()
+ ln
+endps
+
+defineps PSlog()
+ log
+endps
+
+defineps PSmod()
+ mod
+endps
+
+defineps PSmul()
+ mul
+endps
+
+defineps PSneg()
+ neg
+endps
+
+defineps PSround()
+ round
+endps
+
+defineps PSsin()
+ sin
+endps
+
+defineps PSsqrt()
+ sqrt
+endps
+
+defineps PSsub()
+ sub
+endps
+
+defineps PStruncate()
+ truncate
+endps
+
+defineps PSxor()
+ xor
+endps
+
diff --git a/nx-X11/lib/dps/psmiscops.psw b/nx-X11/lib/dps/psmiscops.psw
new file mode 100644
index 000000000..35bc092d0
--- /dev/null
+++ b/nx-X11/lib/dps/psmiscops.psw
@@ -0,0 +1,53 @@
+/* psmiscops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSbanddevice()
+ banddevice
+endps
+
+defineps PSframedevice()
+ framedevice
+endps
+
+defineps PSnulldevice()
+ nulldevice
+endps
+
+defineps PSrenderbands()
+ renderbands
+endps
+
diff --git a/nx-X11/lib/dps/psmtrxops.psw b/nx-X11/lib/dps/psmtrxops.psw
new file mode 100644
index 000000000..cd9ae1b79
--- /dev/null
+++ b/nx-X11/lib/dps/psmtrxops.psw
@@ -0,0 +1,65 @@
+/* psmtrxops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSconcatmatrix()
+ concatmatrix
+endps
+
+defineps PSdtransform(float x1, y1 | float *x2, *y2)
+ x1 y1 dtransform y2 x2
+endps
+
+defineps PSidentmatrix()
+ identmatrix
+endps
+
+defineps PSidtransform(float x1, y1 | float *x2, *y2)
+ x1 y1 idtransform y2 x2
+endps
+
+defineps PSinvertmatrix()
+ invertmatrix
+endps
+
+defineps PSitransform(float x1, y1 | float *x2, *y2)
+ x1 y1 itransform y2 x2
+endps
+
+defineps PStransform(float x1, y1 | float *x2, *y2)
+ x1 y1 transform y2 x2
+endps
+
diff --git a/nx-X11/lib/dps/psname.txt b/nx-X11/lib/dps/psname.txt
new file mode 100644
index 000000000..508b7a86d
--- /dev/null
+++ b/nx-X11/lib/dps/psname.txt
@@ -0,0 +1,3 @@
+/*
+ * psops.h
+ */
diff --git a/nx-X11/lib/dps/psopstack.psw b/nx-X11/lib/dps/psopstack.psw
new file mode 100644
index 000000000..d78ad6b7c
--- /dev/null
+++ b/nx-X11/lib/dps/psopstack.psw
@@ -0,0 +1,96 @@
+/*
+ * psopstack.psw -- wrapped procedures for sending and getting operands
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSgetboolean(| boolean *it)
+ it
+endps
+
+defineps PSgetchararray(int size | char s[size])
+ s
+endps
+
+defineps PSgetfloat(| float *it)
+ it
+endps
+
+defineps PSgetfloatarray(int size | float a[size])
+ dup type /arraytype eq { a } { size { a } repeat } ifelse
+endps
+
+defineps PSgetint(| int *it)
+ it
+endps
+
+defineps PSgetintarray(int size | int a[size])
+ dup type /arraytype eq { a } { size { a } repeat } ifelse
+endps
+
+defineps PSgetstring(| char *s)
+ s
+endps
+
+defineps PSsendboolean(boolean it)
+ it
+endps
+
+defineps PSsendchararray(char s[size]; int size)
+ (s)
+endps
+
+defineps PSsendfloat(float it)
+ it
+endps
+
+defineps PSsendfloatarray(float a[size]; int size)
+ a
+endps
+
+defineps PSsendint(int it)
+ it
+endps
+
+defineps PSsendintarray(int a[size]; int size)
+ a
+endps
+
+defineps PSsendstring(char *s)
+ (s)
+endps
+
+
+
diff --git a/nx-X11/lib/dps/pspathops.psw b/nx-X11/lib/dps/pspathops.psw
new file mode 100644
index 000000000..e4c378282
--- /dev/null
+++ b/nx-X11/lib/dps/pspathops.psw
@@ -0,0 +1,169 @@
+/* pspathops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSarc(float x, y, r, angle1, angle2)
+ x y r angle1 angle2 arc
+endps
+
+defineps PSarcn(float x, y, r, angle1, angle2)
+ x y r angle1 angle2 arcn
+endps
+
+defineps PSarct(float x1, y1, x2, y2, r)
+ x1 y1 x2 y2 r arct
+endps
+
+defineps PSarcto(float x1, y1, x2, y2, r | float *xt1, *yt1, *xt2, *yt2)
+ x1 y1 x2 y2 r arcto yt2 xt2 yt1 xt1
+endps
+
+defineps PScharpath(char *s; boolean b)
+ (s) b charpath
+endps
+
+defineps PSclip()
+ clip
+endps
+
+defineps PSclippath()
+ clippath
+endps
+
+defineps PSclosepath()
+ closepath
+endps
+
+defineps PScurveto(float x1, y1, x2, y2, x3, y3)
+ x1 y1 x2 y2 x3 y3 curveto
+endps
+
+defineps PSeoclip()
+ eoclip
+endps
+
+defineps PSeoviewclip()
+ eoviewclip
+endps
+
+defineps PSflattenpath()
+ flattenpath
+endps
+
+defineps PSinitclip()
+ initclip
+endps
+
+defineps PSinitviewclip()
+ initviewclip
+endps
+
+defineps PSlineto(float x, y)
+ x y lineto
+endps
+
+defineps PSmoveto(float x, y)
+ x y moveto
+endps
+
+defineps PSnewpath()
+ newpath
+endps
+
+defineps PSpathbbox( | float *llx, *lly, *urx, *ury)
+ pathbbox ury urx lly llx
+endps
+
+defineps PSpathforall()
+ pathforall
+endps
+
+defineps PSrcurveto(float x1, y1, x2, y2, x3, y3)
+ x1 y1 x2 y2 x3 y3 rcurveto
+endps
+
+defineps PSrectclip(float x, y, w, h)
+ x y w h rectclip
+endps
+
+defineps PSrectviewclip(float x, y, w, h)
+ x y w h rectviewclip
+endps
+
+defineps PSreversepath()
+ reversepath
+endps
+
+defineps PSrlineto(float x, y)
+ x y rlineto
+endps
+
+defineps PSrmoveto(float x, y)
+ x y rmoveto
+endps
+
+defineps PSsetbbox(float llx, lly, urx, ury)
+ llx lly urx ury setbbox
+endps
+
+defineps PSsetucacheparams()
+ setucacheparams
+endps
+
+defineps PSuappend(char nums[n]; int n; char ops[l]; int l)
+ [(nums) (ops)] uappend
+endps
+
+defineps PSucache()
+ ucache
+endps
+
+defineps PSucachestatus()
+ ucachestatus
+endps
+
+defineps PSupath(boolean b)
+ b upath
+endps
+
+defineps PSviewclip()
+ viewclip
+endps
+
+defineps PSviewclippath()
+ viewclippath
+endps
+
diff --git a/nx-X11/lib/dps/pspntops.psw b/nx-X11/lib/dps/pspntops.psw
new file mode 100644
index 000000000..2f7beef00
--- /dev/null
+++ b/nx-X11/lib/dps/pspntops.psw
@@ -0,0 +1,129 @@
+/* pspntops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSashow(float x, y; char *s)
+ x y (s) ashow
+endps
+
+defineps PSawidthshow(float cx, cy; int c; float ax, ay; char *s)
+ cx cy c ax ay (s) awidthshow
+endps
+
+defineps PScopypage()
+ copypage
+endps
+
+defineps PSeofill()
+ eofill
+endps
+
+defineps PSerasepage()
+ erasepage
+endps
+
+defineps PSfill()
+ fill
+endps
+
+defineps PSimage()
+ image
+endps
+
+defineps PSimagemask()
+ imagemask
+endps
+
+defineps PSkshow(char *s)
+ (s) kshow
+endps
+
+defineps PSrectfill(float x, y, w, h)
+ x y w h rectfill
+endps
+
+defineps PSrectstroke(float x, y, w, h)
+ x y w h rectstroke
+endps
+
+defineps PSshow(char *s)
+ (s) show
+endps
+
+defineps PSshowpage()
+ showpage
+endps
+
+defineps PSstroke()
+ stroke
+endps
+
+defineps PSstrokepath()
+ strokepath
+endps
+
+defineps PSueofill(char nums[n]; int n; char ops[l]; int l)
+ [(nums) (ops)] ueofill
+endps
+
+defineps PSufill(char nums[n]; int n; char ops[l]; int l)
+ [(nums) (ops)] ufill
+endps
+
+defineps PSustroke(char nums[n]; int n; char ops[l]; int l)
+ [(nums) (ops)] ustroke
+endps
+
+defineps PSustrokepath(char nums[n]; int n; char ops[l]; int l)
+ [(nums) (ops)] ustrokepath
+endps
+
+defineps PSwidthshow(float x, y; int c; char *s)
+ x y c (s) widthshow
+endps
+
+defineps PSxshow(char *s; float numarray[size]; int size)
+ (s) numarray xshow
+endps
+
+defineps PSxyshow(char *s; float numarray[size]; int size)
+ (s) numarray xyshow
+endps
+
+defineps PSyshow(char *s; float numarray[size]; int size)
+ (s) numarray yshow
+endps
+
diff --git a/nx-X11/lib/dps/pssysops.psw b/nx-X11/lib/dps/pssysops.psw
new file mode 100644
index 000000000..024d4fd52
--- /dev/null
+++ b/nx-X11/lib/dps/pssysops.psw
@@ -0,0 +1,150 @@
+/*
+ * pssysops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSbind()
+ bind
+endps
+
+defineps PScleardictstack()
+ cleardictstack
+endps
+
+defineps PScountdictstack( | int *n)
+ countdictstack n
+endps
+
+defineps PScountexecstack( | int *n)
+ countexecstack n
+endps
+
+defineps PScurrentdict()
+ currentdict
+endps
+
+defineps PScurrentpacking( | boolean *b)
+ currentpacking b
+endps
+
+defineps PScurrentshared( | boolean *b)
+ currentshared b
+endps
+
+defineps PSdeviceinfo()
+ deviceinfo
+endps
+
+defineps PSerrordict()
+ errordict
+endps
+
+defineps PSexec()
+ exec
+endps
+
+defineps PSprompt()
+ prompt
+endps
+
+defineps PSquit()
+ quit
+endps
+
+defineps PSrand()
+ rand
+endps
+
+defineps PSrealtime( | int *i)
+ realtime i
+endps
+
+defineps PSrestore()
+ restore
+endps
+
+defineps PSrrand()
+ rrand
+endps
+
+defineps PSrun(char *filename)
+ (filename) run
+endps
+
+defineps PSsave()
+ save
+endps
+
+defineps PSsetpacking(boolean b)
+ b setpacking
+endps
+
+defineps PSsetshared(boolean b)
+ b setshared
+endps
+
+defineps PSsrand()
+ srand
+endps
+
+defineps PSstart()
+ start
+endps
+
+defineps PStype()
+ type
+endps
+
+defineps PSundef(char *name)
+ /name undef
+endps
+
+defineps PSusertime( | int *milliseconds)
+ usertime milliseconds
+endps
+
+defineps PSversion(int bufsize | char buf[bufsize])
+ version buf
+endps
+
+defineps PSvmreclaim(int code)
+ code vmreclaim
+endps
+
+defineps PSvmstatus( | int *level, *used, *maximum)
+ vmstatus maximum used level
+endps
+
diff --git a/nx-X11/lib/dps/pswinops.psw b/nx-X11/lib/dps/pswinops.psw
new file mode 100644
index 000000000..4a6a2db5a
--- /dev/null
+++ b/nx-X11/lib/dps/pswinops.psw
@@ -0,0 +1,66 @@
+/*
+ * pswinops.psw
+ *
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps PSineofill(float x, y | boolean *b)
+ x y ineofill b
+endps
+
+defineps PSinfill(float x, y | boolean *b)
+ x y infill b
+endps
+
+defineps PSinstroke(float x, y | boolean *b)
+ x y instroke b
+endps
+
+defineps PSinueofill(float x, y; char nums[n]; int n; char ops[l]; int l | boolean *b)
+ x y [(nums) (ops)] inueofill b
+endps
+
+defineps PSinufill(float x, y; char nums[n]; int n; char ops[l]; int l | boolean *b)
+ x y [(nums) (ops)] inufill b
+endps
+
+defineps PSinustroke(float x, y; char nums[n]; int n; char ops[l]; int l | boolean *b)
+ x y [(nums) (ops)] inustroke b
+endps
+
+defineps PSwtranslation( | float *x, *y)
+ wtranslation y x
+endps
+
diff --git a/nx-X11/lib/dps/publictypes.h b/nx-X11/lib/dps/publictypes.h
new file mode 100644
index 000000000..871766e69
--- /dev/null
+++ b/nx-X11/lib/dps/publictypes.h
@@ -0,0 +1,71 @@
+/*
+ * publictypes.h
+ *
+ * (c) Copyright 1984-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86: xc/lib/dps/publictypes.h,v 1.2 2000/06/07 22:02:58 tsi Exp $ */
+
+#ifndef PUBLICTYPES_H
+#define PUBLICTYPES_H
+
+/*
+ * Note: for the moment we depend absolutely on an int being the same
+ * as a long int and being at least 32 bits.
+ */
+
+/* Inline Functions */
+
+#undef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#undef MAX
+#define MAX(a,b) ((a)>(b)?(a):(b))
+
+/* Declarative Sugar */
+
+/* Type boolean based derived from unsigned int */
+
+typedef unsigned int boolean;
+typedef long int integer;
+
+#define true 1
+#define false 0
+
+/* Generic Pointers */
+
+#include <stddef.h>
+
+#define NIL NULL
+
+#endif /* PUBLICTYPES_H */
diff --git a/nx-X11/lib/dpstk/CSBwraps.psw b/nx-X11/lib/dpstk/CSBwraps.psw
new file mode 100644
index 000000000..02a2041ee
--- /dev/null
+++ b/nx-X11/lib/dpstk/CSBwraps.psw
@@ -0,0 +1,343 @@
+/*
+ * CSBwraps.psw
+ *
+ * (c) Copyright 1993-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps _DPSCColormapMatch(DPSContext ctxt; int colormap | boolean *match)
+ currentXgcdrawablecolor % gc draw x y [....colormap...]
+ 10 get colormap eq match % gc draw x y
+ pop pop pop pop
+endps
+
+defineps _DPSCTriangle(DPSContext ctxt; double h, w)
+ newpath
+ 0 0 moveto
+ w 0 rlineto
+ 0 h rlineto
+ closepath
+ fill
+endps
+
+defineps _DPSCShowFillMe(DPSContext ctxt; char *str)
+ /Helvetica-Bold 12 selectfont
+ 2 5 moveto
+ 0 setgray
+ (str) show
+endps
+
+defineps _DPSCShowMessage(DPSContext ctxt; char *str)
+ 1 setgray
+ 0 0 1000 1000 rectfill
+ /Helvetica-Bold 12 selectfont
+ 10 2 moveto
+ 0 setgray
+ (str) show
+endps
+
+defineps _DPSCRGBBlend(DPSContext ctxt; double x, y, width, height;
+ char *function; int steps)
+ gsave
+ x y translate
+ width steps div
+ 0 1 steps 1 sub {
+ steps div (function) cvx exec setrgbcolor
+ dup 0 0 3 -1 roll height rectfill
+ dup 0 translate
+ } for
+ pop
+ grestore
+endps
+
+defineps _DPSCHSBBlend(DPSContext ctxt; double x, y, width, height;
+ char *function; int steps)
+ gsave
+ x y translate
+ width steps div
+ 0 1 steps 1 sub {
+ steps div (function) cvx exec sethsbcolor
+ dup 0 0 3 -1 roll height rectfill
+ dup 0 translate
+ } for
+ pop
+ grestore
+endps
+
+defineps _DPSCCMYKBlend(DPSContext ctxt; double x, y, width, height;
+ char *function; int steps)
+ gsave
+ x y translate
+ width steps div
+ 0 1 steps 1 sub {
+ steps div (function) cvx exec setcmykcolor
+ dup 0 0 3 -1 roll height rectfill
+ dup 0 translate
+ } for
+ pop
+ grestore
+endps
+
+defineps _DPSCGrayBlend(DPSContext ctxt; double x, y, width, height;
+ char *function; int steps)
+ gsave
+ x y translate
+ width steps div
+ 0 1 steps 1 sub {
+ steps div (function) cvx exec setgray
+ dup 0 0 3 -1 roll height rectfill
+ dup 0 translate
+ } for
+ pop
+ grestore
+endps
+
+defineps _DPSCGetInvCTM(DPSContext ctxt; | float invctm[6])
+ matrix currentmatrix matrix invertmatrix invctm
+endps
+
+defineps _DPSCDoRGBColorPalette(DPSContext ctxt; char *func;
+ double red, green, blue; double width, height;
+ int steps | boolean *success)
+ mark {
+ gsave
+ 0 0 translate
+ width steps div
+ 0 1 steps 1 sub {
+ steps div red green blue 4 -1 roll func setrgbcolor
+ dup 0 0 3 -1 roll height rectfill
+ dup 0 translate
+ } for
+ pop
+ grestore
+ } stopped not success cleartomark
+endps
+
+defineps _DPSCDoCMYKColorPalette(DPSContext ctxt; char *func;
+ double cyan, magenta, yellow, black;
+ double width, height;
+ int steps | boolean *success)
+ mark {
+ gsave
+ 0 0 translate
+ width steps div
+ 0 1 steps 1 sub {
+ steps div cyan magenta yellow black 5 -1 roll func setcmykcolor
+ dup 0 0 3 -1 roll height rectfill
+ dup 0 translate
+ } for
+ pop
+ grestore
+ } stopped not success cleartomark
+endps
+
+defineps _DPSCDoHSBColorPalette(DPSContext ctxt; char *func;
+ double hue, sat, bright;
+ double width, height;
+ int steps | boolean *success)
+ mark {
+ gsave
+ 0 0 translate
+ width steps div
+ 0 1 steps 1 sub {
+ steps div hue sat bright 4 -1 roll func sethsbcolor
+ dup 0 0 3 -1 roll height rectfill
+ dup 0 translate
+ } for
+ pop
+ grestore
+ } stopped not success cleartomark
+endps
+
+defineps _DPSCDoGrayColorPalette(DPSContext ctxt; char *func;
+ double gray; double width, height;
+ int steps | boolean *success)
+ mark {
+ gsave
+ 0 0 translate
+ width steps div
+ 0 1 steps 1 sub {
+ steps div gray exch func setgray
+ dup 0 0 3 -1 roll height rectfill
+ dup 0 translate
+ } for
+ pop
+ grestore
+ } stopped not success cleartomark
+endps
+
+
+defineps _DPSCDoRGBPalette(DPSContext ctxt; char *func;
+ double width, height;
+ int steps | boolean *success)
+ mark {
+ gsave
+ 0 0 translate
+ width steps div
+ 0 1 steps 1 sub {
+ steps div func setrgbcolor
+ dup 0 0 3 -1 roll height rectfill
+ dup 0 translate
+ } for
+ pop
+ grestore
+ } stopped not success cleartomark
+endps
+
+defineps _DPSCDoCMYKPalette(DPSContext ctxt; char *func;
+ double width, height;
+ int steps | boolean *success)
+ mark {
+ gsave
+ 0 0 translate
+ width steps div
+ 0 1 steps 1 sub {
+ steps div func setcmykcolor
+ dup 0 0 3 -1 roll height rectfill
+ dup 0 translate
+ } for
+ pop
+ grestore
+ } stopped not success cleartomark
+endps
+
+defineps _DPSCDoHSBPalette(DPSContext ctxt; char *func;
+ double width, height;
+ int steps | boolean *success)
+ mark {
+ gsave
+ 0 0 translate
+ width steps div
+ 0 1 steps 1 sub {
+ steps div func sethsbcolor
+ dup 0 0 3 -1 roll height rectfill
+ dup 0 translate
+ } for
+ pop
+ grestore
+ } stopped not success cleartomark
+endps
+
+defineps _DPSCDoGrayPalette(DPSContext ctxt; char *func;
+ double width, height;
+ int steps | boolean *success)
+ mark {
+ gsave
+ 0 0 translate
+ width steps div
+ 0 1 steps 1 sub {
+ steps div func setgray
+ dup 0 0 3 -1 roll height rectfill
+ dup 0 translate
+ } for
+ pop
+ grestore
+ } stopped not success cleartomark
+endps
+
+defineps _DPSCQueryRGBColorPalette(DPSContext ctxt; char *func;
+ double pct, red, green, blue; |
+ float *redOut, *greenOut, *blueOut;
+ boolean *success)
+ mark {
+ red green blue pct func
+ } stopped dup not success {0 0 0} if
+ blueOut greenOut redOut cleartomark
+endps
+
+defineps _DPSCQueryCMYKColorPalette(DPSContext ctxt; char *func;
+ double pct, cyan, magenta, yellow, black; |
+ float *cyanOut, *magentaOut, *yellowOut,
+ *blackOut; boolean *success)
+ mark {
+ cyan magenta yellow black pct func
+ } stopped dup not success {0 0 0 0} if
+ blackOut yellowOut magentaOut cyanOut cleartomark
+endps
+
+defineps _DPSCQueryHSBColorPalette(DPSContext ctxt; char *func;
+ double pct, hue, sat, bright; |
+ float *hueOut, *satOut, *brightOut;
+ boolean *success)
+ mark {
+ hue sat bright pct func
+ } stopped dup not success {0 0 0} if
+ brightOut satOut hueOut cleartomark
+endps
+
+defineps _DPSCQueryGrayColorPalette(DPSContext ctxt; char *func;
+ double pct, gray; |
+ float *grayOut; boolean *success)
+ mark {
+ gray pct func
+ } stopped dup not success {0} if
+ grayOut cleartomark
+endps
+
+
+defineps _DPSCQueryRGBPalette(DPSContext ctxt; char *func; double pct; |
+ float *redOut, *greenOut, *blueOut;
+ boolean *success)
+ mark {
+ pct func
+ } stopped dup not success {0 0 0} if
+ blueOut greenOut redOut cleartomark
+endps
+
+defineps _DPSCQueryCMYKPalette(DPSContext ctxt; char *func; double pct; |
+ float *cyanOut, *magentaOut, *yellowOut,
+ *blackOut; boolean *success)
+ mark {
+ pct func
+ } stopped dup not success {0 0 0 0} if
+ blackOut yellowOut magentaOut cyanOut cleartomark
+endps
+
+defineps _DPSCQueryHSBPalette(DPSContext ctxt; char *func; double pct; |
+ float *hueOut, *satOut, *brightOut;
+ boolean *success)
+ mark {
+ pct func
+ } stopped dup not success {0 0 0} if
+ brightOut satOut hueOut cleartomark
+endps
+
+defineps _DPSCQueryGrayPalette(DPSContext ctxt; char *func; double pct; |
+ float *grayOut; boolean *success)
+ mark {
+ pct func
+ } stopped dup not success {0} if
+ grayOut cleartomark
+endps
+
diff --git a/nx-X11/lib/dpstk/ColorSB.c b/nx-X11/lib/dpstk/ColorSB.c
new file mode 100644
index 000000000..d2d71088e
--- /dev/null
+++ b/nx-X11/lib/dpstk/ColorSB.c
@@ -0,0 +1,3388 @@
+/*
+ * ColorSB.c
+ *
+ * (c) Copyright 1993-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+#ifndef X_NOT_POSIX
+#include <unistd.h>
+#endif
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/ShellP.h>
+#include <stdlib.h>
+#include <Xm/Xm.h>
+
+/* There are no words to describe how I feel about having to do this */
+
+#if XmVersion > 1001
+#include <Xm/ManagerP.h>
+#else
+#include <Xm/XmP.h>
+#endif
+
+#include <Xm/Form.h>
+#include <Xm/Label.h>
+#include <Xm/LabelG.h>
+#include <Xm/PushB.h>
+#include <Xm/PushBG.h>
+#include <Xm/SeparatoG.h>
+#include <Xm/DrawingA.h>
+#include <Xm/Scale.h>
+#include <Xm/RowColumn.h>
+#include <Xm/Frame.h>
+#include <Xm/MessageB.h>
+
+#include <DPS/dpsXclient.h>
+#include "dpsXcommonI.h"
+#include <DPS/dpsXshare.h>
+#include "eyedrop16.xbm"
+#include "eyedropmask16.xbm"
+#include "eyedrop32.xbm"
+#include "eyedropmask32.xbm"
+#include "heyedrop.xbm"
+#include "square.xbm"
+#include "squaremask.xbm"
+#include "CSBwraps.h"
+#include <math.h>
+#include <stdio.h>
+#include <pwd.h>
+#include <DPS/ColorSBP.h>
+
+#define PATH_BUF_SIZE 1024
+
+/* Turn a string into a compound string */
+#define CS(str, w) CreateSharedCS(str, w)
+
+#undef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#undef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#define TO_PCT(val) ((int) (val * 100.0 + 0.5))
+#define TO_X(color) ((color) * 65535)
+
+#define Offset(field) XtOffsetOf(ColorSelectionBoxRec, csb.field)
+
+static XtResource resources[] = {
+ {XtNcontext, XtCContext, XtRDPSContext, sizeof(DPSContext),
+ Offset(context), XtRDPSContext, (XtPointer) NULL},
+ {XtNrgbLabels, XtCRgbLabels, XtRString, sizeof(String),
+ Offset(rgb_labels), XtRString, (XtPointer) "R:G:B"},
+ {XtNcmykLabels, XtCCmykLabels, XtRString, sizeof(String),
+ Offset(cmyk_labels), XtRString, (XtPointer) "C:M:Y:K"},
+ {XtNhsbLabels, XtCHsbLabels, XtRString, sizeof(String),
+ Offset(hsb_labels), XtRString, (XtPointer) "H:S:B"},
+ {XtNgrayLabels, XtCGrayLabels, XtRString, sizeof(String),
+ Offset(gray_labels), XtRString, (XtPointer) "Gray"},
+ {XtNcellSize, XtCCellSize, XtRDimension, sizeof(Dimension),
+ Offset(cell_size), XtRImmediate, (XtPointer) 15},
+ {XtNnumCells, XtCNumCells, XtRShort, sizeof(short),
+ Offset(num_cells), XtRImmediate, (XtPointer) 30},
+ {XtNfillMe, XtCFillMe, XtRString, sizeof(String),
+ Offset(fill_me), XtRString, (XtPointer) "Fill me with colors"},
+ {XtNcurrentSpace, XtCCurrentSpace, XtRColorSpace, sizeof(CSBColorSpace),
+ Offset(current_space), XtRImmediate, (XtPointer) CSBSpaceHSB},
+ {XtNcurrentRendering, XtCCurrentRendering, XtRRenderingType,
+ sizeof(CSBRenderingType), Offset(current_rendering),
+ XtRImmediate, (XtPointer) CSBDisplayDPS},
+ {XtNcurrentPalette, XtCCurrentPalette, XtRShort, sizeof(short),
+ Offset(current_palette), XtRImmediate, (XtPointer) 0},
+ {XtNbrokenPaletteLabel, XtCBrokenPaletteLabel, XtRString,
+ sizeof(String), Offset(broken_palette_label),
+ XtRString, (XtPointer) "(broken)"},
+ {XtNbrokenPaletteMessage, XtCBrokenPaletteMessage, XtRString,
+ sizeof(String), Offset(broken_palette_message),
+ XtRString, (XtPointer) "The current palette contains an error"},
+
+ {XtNpalette0Label, XtCPaletteLabel, XtRString, sizeof(String),
+ Offset(palette_label[0]), XtRString, (XtPointer) NULL},
+ {XtNpalette0Space, XtCPaletteSpace, XtRColorSpace, sizeof(CSBColorSpace),
+ Offset(palette_space[0]), XtRImmediate, (XtPointer) CSBSpaceRGB},
+ {XtNpalette0ColorDependent, XtCPaletteColorDependent,
+ XtRBoolean, sizeof(Boolean),
+ Offset(palette_color_dependent[0]), XtRImmediate, (XtPointer) False},
+ {XtNpalette0Function, XtCPaletteFunction, XtRString, sizeof(String),
+ Offset(palette_function[0]), XtRImmediate, (XtPointer) NULL},
+
+ {XtNpalette1Label, XtCPaletteLabel, XtRString, sizeof(String),
+ Offset(palette_label[1]), XtRString, (XtPointer) NULL},
+ {XtNpalette1Space, XtCPaletteSpace, XtRColorSpace, sizeof(CSBColorSpace),
+ Offset(palette_space[1]), XtRImmediate, (XtPointer) CSBSpaceRGB},
+ {XtNpalette1ColorDependent, XtCPaletteColorDependent,
+ XtRBoolean, sizeof(Boolean),
+ Offset(palette_color_dependent[1]), XtRImmediate, (XtPointer) False},
+ {XtNpalette1Function, XtCPaletteFunction, XtRString, sizeof(String),
+ Offset(palette_function[1]), XtRImmediate, (XtPointer) NULL},
+
+ {XtNpalette2Label, XtCPaletteLabel, XtRString, sizeof(String),
+ Offset(palette_label[2]), XtRString, (XtPointer) NULL},
+ {XtNpalette2Space, XtCPaletteSpace, XtRColorSpace, sizeof(CSBColorSpace),
+ Offset(palette_space[2]), XtRImmediate, (XtPointer) CSBSpaceRGB},
+ {XtNpalette2ColorDependent, XtCPaletteColorDependent,
+ XtRBoolean, sizeof(Boolean),
+ Offset(palette_color_dependent[2]), XtRImmediate, (XtPointer) False},
+ {XtNpalette2Function, XtCPaletteFunction, XtRString, sizeof(String),
+ Offset(palette_function[2]), XtRImmediate, (XtPointer) NULL},
+
+ {XtNpalette3Label, XtCPaletteLabel, XtRString, sizeof(String),
+ Offset(palette_label[3]), XtRString, (XtPointer) NULL},
+ {XtNpalette3Space, XtCPaletteSpace, XtRColorSpace, sizeof(CSBColorSpace),
+ Offset(palette_space[3]), XtRImmediate, (XtPointer) CSBSpaceRGB},
+ {XtNpalette3ColorDependent, XtCPaletteColorDependent,
+ XtRBoolean, sizeof(Boolean),
+ Offset(palette_color_dependent[3]), XtRImmediate, (XtPointer) False},
+ {XtNpalette3Function, XtCPaletteFunction, XtRString, sizeof(String),
+ Offset(palette_function[3]), XtRImmediate, (XtPointer) NULL},
+
+ {XtNpalette4Label, XtCPaletteLabel, XtRString, sizeof(String),
+ Offset(palette_label[4]), XtRString, (XtPointer) NULL},
+ {XtNpalette4Space, XtCPaletteSpace, XtRColorSpace, sizeof(CSBColorSpace),
+ Offset(palette_space[4]), XtRImmediate, (XtPointer) CSBSpaceRGB},
+ {XtNpalette4ColorDependent, XtCPaletteColorDependent,
+ XtRBoolean, sizeof(Boolean),
+ Offset(palette_color_dependent[4]), XtRImmediate, (XtPointer) False},
+ {XtNpalette4Function, XtCPaletteFunction, XtRString, sizeof(String),
+ Offset(palette_function[4]), XtRImmediate, (XtPointer) NULL},
+
+ {XtNpalette5Label, XtCPaletteLabel, XtRString, sizeof(String),
+ Offset(palette_label[5]), XtRString, (XtPointer) NULL},
+ {XtNpalette5Space, XtCPaletteSpace, XtRColorSpace, sizeof(CSBColorSpace),
+ Offset(palette_space[5]), XtRImmediate, (XtPointer) CSBSpaceRGB},
+ {XtNpalette5ColorDependent, XtCPaletteColorDependent,
+ XtRBoolean, sizeof(Boolean),
+ Offset(palette_color_dependent[5]), XtRImmediate, (XtPointer) False},
+ {XtNpalette5Function, XtCPaletteFunction, XtRString, sizeof(String),
+ Offset(palette_function[5]), XtRImmediate, (XtPointer) NULL},
+
+ {XtNpalette6Label, XtCPaletteLabel, XtRString, sizeof(String),
+ Offset(palette_label[6]), XtRString, (XtPointer) NULL},
+ {XtNpalette6Space, XtCPaletteSpace, XtRColorSpace, sizeof(CSBColorSpace),
+ Offset(palette_space[6]), XtRImmediate, (XtPointer) CSBSpaceRGB},
+ {XtNpalette6ColorDependent, XtCPaletteColorDependent,
+ XtRBoolean, sizeof(Boolean),
+ Offset(palette_color_dependent[6]), XtRImmediate, (XtPointer) False},
+ {XtNpalette6Function, XtCPaletteFunction, XtRString, sizeof(String),
+ Offset(palette_function[6]), XtRImmediate, (XtPointer) NULL},
+
+ {XtNpalette7Label, XtCPaletteLabel, XtRString, sizeof(String),
+ Offset(palette_label[7]), XtRString, (XtPointer) NULL},
+ {XtNpalette7Space, XtCPaletteSpace, XtRColorSpace, sizeof(CSBColorSpace),
+ Offset(palette_space[7]), XtRImmediate, (XtPointer) CSBSpaceRGB},
+ {XtNpalette7ColorDependent, XtCPaletteColorDependent,
+ XtRBoolean, sizeof(Boolean),
+ Offset(palette_color_dependent[7]), XtRImmediate, (XtPointer) False},
+ {XtNpalette7Function, XtCPaletteFunction, XtRString, sizeof(String),
+ Offset(palette_function[7]), XtRImmediate, (XtPointer) NULL},
+
+ {XtNpalette8Label, XtCPaletteLabel, XtRString, sizeof(String),
+ Offset(palette_label[8]), XtRString, (XtPointer) NULL},
+ {XtNpalette8Space, XtCPaletteSpace, XtRColorSpace, sizeof(CSBColorSpace),
+ Offset(palette_space[8]), XtRImmediate, (XtPointer) CSBSpaceRGB},
+ {XtNpalette8ColorDependent, XtCPaletteColorDependent,
+ XtRBoolean, sizeof(Boolean),
+ Offset(palette_color_dependent[8]), XtRImmediate, (XtPointer) False},
+ {XtNpalette8Function, XtCPaletteFunction, XtRString, sizeof(String),
+ Offset(palette_function[8]), XtRImmediate, (XtPointer) NULL},
+
+ {XtNpalette9Label, XtCPaletteLabel, XtRString, sizeof(String),
+ Offset(palette_label[9]), XtRString, (XtPointer) NULL},
+ {XtNpalette9Space, XtCPaletteSpace, XtRColorSpace, sizeof(CSBColorSpace),
+ Offset(palette_space[9]), XtRImmediate, (XtPointer) CSBSpaceRGB},
+ {XtNpalette9ColorDependent, XtCPaletteColorDependent,
+ XtRBoolean, sizeof(Boolean),
+ Offset(palette_color_dependent[9]), XtRImmediate, (XtPointer) False},
+ {XtNpalette9Function, XtCPaletteFunction, XtRString, sizeof(String),
+ Offset(palette_function[9]), XtRImmediate, (XtPointer) NULL},
+
+ {XtNokCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(ok_callback), XtRCallback, (XtPointer) NULL},
+ {XtNapplyCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(apply_callback), XtRCallback, (XtPointer) NULL},
+ {XtNresetCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(reset_callback), XtRCallback, (XtPointer) NULL},
+ {XtNcancelCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(cancel_callback), XtRCallback, (XtPointer) NULL},
+ {XtNvalueChangedCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(value_changed_callback), XtRCallback, (XtPointer) NULL}
+};
+
+static Boolean SetColor (Widget w, CSBColorSpace space, double c1, double c2, double c3, double c4, Bool setSpace);
+static Boolean SetValues (Widget old, Widget req, Widget new, ArgList args, Cardinal *num_args);
+static XtGeometryResult GeometryManager (Widget w, XtWidgetGeometry *desired, XtWidgetGeometry *allowed);
+static void ChangeLabel (Widget label, double n);
+static void ChangeManaged (Widget w);
+static void ClassInitialize (void);
+static void ClassPartInitialize (WidgetClass widget_class);
+static void CreateChildren (ColorSelectionBoxWidget csb);
+static void Destroy (Widget widget);
+static void DrawDock (ColorSelectionBoxWidget csb);
+static void DrawPalette (ColorSelectionBoxWidget csb);
+static void FillPatch (ColorSelectionBoxWidget csb);
+static void GetColor (Widget w, CSBColorSpace space, float *c1, float *c2, float *c3, float *c4);
+static void Initialize (Widget request, Widget new, ArgList args, Cardinal *num_args);
+static void InitializeDock (ColorSelectionBoxWidget csb);
+static void Realize (Widget w, XtValueMask *mask, XSetWindowAttributes *attr);
+static void Resize (Widget widget);
+static void SaveDockContents (ColorSelectionBoxWidget csb);
+static void SetBackground (ColorSelectionBoxWidget csb);
+static void SetCMYKValues (ColorSelectionBoxWidget csb);
+static void SetColorSpace (ColorSelectionBoxWidget csb);
+static void SetGrayValues (ColorSelectionBoxWidget csb);
+static void SetHSBValues (ColorSelectionBoxWidget csb);
+static void SetRGBValues (ColorSelectionBoxWidget csb);
+static void SetRendering (ColorSelectionBoxWidget csb);
+static void SetSliders (ColorSelectionBoxWidget csb);
+static void UpdateColorSpaces (ColorSelectionBoxWidget csb, CSBColorSpace masterSpace);
+
+static void DockPress (Widget w, XtPointer data, XEvent *event, Boolean *goOn);
+static void EyedropPointer (Widget w, XtPointer data, XEvent *event, Boolean *goOn);
+static void FormResize (Widget w, XtPointer data, XEvent *event, Boolean *goOn);
+static void PalettePress (Widget w, XtPointer data, XEvent *event, Boolean *goOn);
+static void PatchPress (Widget w, XtPointer data, XEvent *event, Boolean *goOn);
+static void PatchRelease (Widget w, XtPointer data, XEvent *event, Boolean *goOn);
+
+static void ApplyCallback (Widget w, XtPointer clientData, XtPointer callData);
+static void DoEyedropCallback (Widget w, XtPointer clientData, XtPointer callData);
+static void DrawDockCallback (Widget w, XtPointer clientData, XtPointer callData);
+static void DrawPaletteCallback (Widget w, XtPointer clientData, XtPointer callData);
+static void FillPatchCallback (Widget w, XtPointer clientData, XtPointer callData);
+static void OKCallback (Widget w, XtPointer clientData, XtPointer callData);
+static void SetCMYKCallback (Widget w, XtPointer clientData, XtPointer callData);
+static void SetGrayCallback (Widget w, XtPointer clientData, XtPointer callData);
+static void SetHSBCallback (Widget w, XtPointer clientData, XtPointer callData);
+static void SetRGBCallback (Widget w, XtPointer clientData, XtPointer callData);
+static void Slider1Callback (Widget w, XtPointer clientData, XtPointer callData);
+static void Slider2Callback (Widget w, XtPointer clientData, XtPointer callData);
+static void Slider3Callback (Widget w, XtPointer clientData, XtPointer callData);
+static void Slider4Callback (Widget w, XtPointer clientData, XtPointer callData);
+
+ColorSelectionBoxClassRec colorSelectionBoxClassRec = {
+ /* Core class part */
+ {
+ /* superclass */ (WidgetClass) &xmManagerClassRec,
+ /* class_name */ "ColorSelectionBox",
+ /* widget_size */ sizeof(ColorSelectionBoxRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_initialize */ ClassPartInitialize,
+ /* class_inited */ False,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ True,
+ /* compress_exposure */ XtExposeCompressMultiple,
+ /* compress_enterleave */ True,
+ /* visible_interest */ False,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ NULL,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL,
+ },
+ /* Composite class part */
+ {
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL,
+ },
+ /* Constraint class part */
+ {
+ /* resources */ NULL,
+ /* num_resources */ 0,
+ /* constraint_size */ 0,
+ /* initialize */ NULL,
+ /* destroy */ NULL,
+ /* set_values */ NULL,
+ /* extension */ NULL,
+ },
+ /* Manager class part */
+ {
+ /* translations */ XtInheritTranslations,
+ /* syn_resources */ NULL,
+ /* num_syn_resources */ 0,
+ /* syn_constraint_resources */ NULL,
+ /* num_syn_constraint_resources */ 0,
+ /* parent_process */ XmInheritParentProcess,
+ /* extension */ NULL,
+ },
+ /* ColorSelectionBox class part */
+ {
+ /* set_color */ SetColor,
+ /* get_color */ GetColor,
+ /* extension */ NULL,
+ }
+};
+
+WidgetClass colorSelectionBoxWidgetClass =
+ (WidgetClass) &colorSelectionBoxClassRec;
+
+static XmString CreateSharedCS(String str, Widget w)
+{
+ XrmValue src, dst;
+ XmString result;
+
+ src.addr = str;
+ src.size = strlen(str);
+
+ dst.addr = (caddr_t) &result;
+ dst.size = sizeof(result);
+
+ if (XtConvertAndStore(w, XtRString, &src, XmRXmString, &dst)) {
+ return result;
+ } else return NULL;
+}
+
+static Boolean LowerCase(String from, String to, int size)
+{
+ register char ch;
+ register int i;
+
+ for (i = 0; i < size; i++) {
+ ch = from[i];
+ if (ch >= 'A' && ch <= 'Z') to[i] = ch - 'A' + 'a';
+ else to[i] = ch;
+ if (ch == '\0') return False;
+ }
+ return TRUE;
+}
+
+/* ARGSUSED */
+
+static Boolean CvtStringToColorSpace(
+ Display *dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr from,
+ XrmValuePtr to,
+ XtPointer *data)
+{
+#define LOWER_SIZE 5
+ char lower[LOWER_SIZE]; /* Lower cased string value */
+ Boolean badConvert;
+ static CSBColorSpace c;
+
+ if (*num_args != 0) { /* Check for correct number */
+ XtAppErrorMsg(XtDisplayToApplicationContext(dpy),
+ "cvtStringToColorSpace", "wrongParameters",
+ "XtToolkitError",
+ "String to colorspace conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *) NULL);
+ }
+
+ /* Lower case the value */
+ badConvert = LowerCase(from->addr, lower, LOWER_SIZE);
+
+ /* Try to convert if a short enough string specified */
+ if (!badConvert) {
+ if (strcmp(lower, "rgb") == 0) c = CSBSpaceRGB;
+ else if (strcmp(lower, "cmyk") == 0) c = CSBSpaceCMYK;
+ else if (strcmp(lower, "hsb") == 0) c = CSBSpaceHSB;
+ else if (strcmp(lower, "gray") == 0) c = CSBSpaceGray;
+ else if (strcmp(lower, "grey") == 0) c = CSBSpaceGray;
+ else badConvert = True;
+ }
+
+ /* String too long or unknown value -- issue warning */
+ if (badConvert) {
+ XtDisplayStringConversionWarning(dpy, from->addr, "ColorSpace");
+ } else {
+ if (to->addr == NULL) to->addr = (caddr_t) &c;
+
+ else if (to->size < sizeof(CSBColorSpace)) badConvert = TRUE;
+ else *(CSBColorSpace *) to->addr = c;
+
+ to->size = sizeof(CSBColorSpace);
+ }
+ return !badConvert;
+#undef LOWER_SIZE
+}
+
+/* ARGSUSED */
+
+static Boolean CvtStringToRenderingType(
+ Display *dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr from,
+ XrmValuePtr to,
+ XtPointer *data)
+{
+#define LOWER_SIZE 5
+ char lower[LOWER_SIZE]; /* Lower cased string value */
+ Boolean badConvert;
+ static CSBRenderingType c;
+
+ if (*num_args != 0) { /* Check for correct number */
+ XtAppErrorMsg(XtDisplayToApplicationContext(dpy),
+ "cvtStringToRenderingType", "wrongParameters",
+ "XtToolkitError",
+ "String to rendering type conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *) NULL);
+ }
+
+ /* Lower case the value */
+ badConvert = LowerCase(from->addr, lower, LOWER_SIZE);
+
+ /* Try to convert if a short enough string specified */
+ if (!badConvert) {
+ if (strcmp(lower, "x") == 0) c = CSBDisplayX;
+ else if (strcmp(lower, "dps") == 0) c = CSBDisplayDPS;
+ else if (strcmp(lower, "both") == 0) c = CSBDisplayBoth;
+ else badConvert = True;
+ }
+
+ /* String too long or unknown value -- issue warning */
+ if (badConvert) {
+ XtDisplayStringConversionWarning(dpy, from->addr, "RenderingType");
+ } else {
+ if (to->addr == NULL) to->addr = (caddr_t) &c;
+
+ else if (to->size < sizeof(CSBRenderingType)) badConvert = TRUE;
+ else *(CSBRenderingType *) to->addr = c;
+
+ to->size = sizeof(CSBRenderingType);
+ }
+ return !badConvert;
+#undef LOWER_SIZE
+}
+
+static void ClassInitialize(void)
+{
+ /* Register converters */
+
+ XtSetTypeConverter(XtRString, XtRColorSpace,
+ CvtStringToColorSpace, (XtConvertArgList) NULL, 0,
+ XtCacheAll, (XtDestructor) NULL);
+ XtSetTypeConverter(XtRString, XtRRenderingType,
+ CvtStringToRenderingType, (XtConvertArgList) NULL, 0,
+ XtCacheAll, (XtDestructor) NULL);
+}
+
+/* ARGSUSED */
+
+static void ClassPartInitialize(WidgetClass widget_class)
+{
+ register ColorSelectionBoxWidgetClass wc =
+ (ColorSelectionBoxWidgetClass) widget_class;
+ ColorSelectionBoxWidgetClass super =
+ (ColorSelectionBoxWidgetClass) wc->core_class.superclass;
+
+ if (wc->csb_class.set_color == InheritSetColor) {
+ wc->csb_class.set_color = super->csb_class.set_color;
+ }
+ if (wc->csb_class.get_color == InheritGetColor) {
+ wc->csb_class.get_color = super->csb_class.get_color;
+ }
+}
+
+static void ToUserSpace(
+ ColorSelectionBoxWidget csb,
+ int xWidth, int xHeight,
+ float *uWidth, float *uHeight)
+{
+ register float *i = csb->csb.itransform;
+
+ *uWidth = i[0] * xWidth - i[2] * xHeight + i[4];
+ *uHeight= i[1] * xWidth - i[3] * xHeight + i[5];
+}
+
+static void ColorizeRGB(ColorSelectionBoxWidget csb)
+{
+ Dimension height, width;
+ int depth, steps;
+ float w, h;
+
+ XtVaGetValues(csb->csb.slider_child[0], XtNwidth, &width,
+ XtNheight, &height,
+ XtNdepth, &depth, NULL);
+
+ if (csb->csb.red_pixmap != None && width != csb->csb.rgb_slider_width) {
+ XFreePixmap(XtDisplay(csb), csb->csb.red_pixmap);
+ XFreePixmap(XtDisplay(csb), csb->csb.green_pixmap);
+ XFreePixmap(XtDisplay(csb), csb->csb.blue_pixmap);
+ csb->csb.red_pixmap = None;
+ }
+
+ if (csb->csb.red_pixmap == None) {
+ csb->csb.rgb_slider_width = width;
+ if (csb->csb.visual_class == TrueColor) steps = width / 2;
+ else steps = width / 4;
+
+ ToUserSpace(csb, width, height, &w, &h);
+
+ csb->csb.red_pixmap = XCreatePixmap(XtDisplay(csb), XtWindow(csb),
+ width, height, depth);
+
+ XDPSSetContextGState(csb->csb.context, csb->csb.base_gstate);
+ XDPSSetContextDrawable(csb->csb.context, csb->csb.red_pixmap, height);
+
+ _DPSCRGBBlend(csb->csb.context, 0.0, 0.0, w, h, "0 0", steps);
+
+ csb->csb.green_pixmap = XCreatePixmap(XtDisplay(csb), XtWindow(csb),
+ width, height, depth);
+
+ XDPSSetContextDrawable(csb->csb.context,
+ csb->csb.green_pixmap, height);
+
+ _DPSCRGBBlend(csb->csb.context, 0.0, 0.0, w, h, "0 exch 0", steps);
+
+ csb->csb.blue_pixmap = XCreatePixmap(XtDisplay(csb), XtWindow(csb),
+ width, height, depth);
+
+ XDPSSetContextDrawable(csb->csb.context, csb->csb.blue_pixmap, height);
+
+ _DPSCRGBBlend(csb->csb.context,
+ 0.0, 0.0, w, h, "0 0 3 -1 roll", steps);
+
+ DPSWaitContext(csb->csb.context);
+ }
+
+ XtVaSetValues(csb->csb.slider_child[0],
+ XtNbackgroundPixmap, csb->csb.red_pixmap, NULL);
+ XtVaSetValues(csb->csb.slider_child[1],
+ XtNbackgroundPixmap, csb->csb.green_pixmap, NULL);
+ XtVaSetValues(csb->csb.slider_child[2],
+ XtNbackgroundPixmap, csb->csb.blue_pixmap, NULL);
+}
+
+static void ColorizeCMYK(ColorSelectionBoxWidget csb)
+{
+ Dimension height, width;
+ int depth, steps;
+ float w, h;
+
+ XtVaGetValues(csb->csb.slider_child[0], XtNwidth, &width,
+ XtNheight, &height,
+ XtNdepth, &depth, NULL);
+
+ if (csb->csb.cyan_pixmap != None && width != csb->csb.cmyk_slider_width) {
+ XFreePixmap(XtDisplay(csb), csb->csb.cyan_pixmap);
+ XFreePixmap(XtDisplay(csb), csb->csb.magenta_pixmap);
+ XFreePixmap(XtDisplay(csb), csb->csb.yellow_pixmap);
+ XFreePixmap(XtDisplay(csb), csb->csb.black_pixmap);
+ csb->csb.cyan_pixmap = None;
+ }
+
+ if (csb->csb.cyan_pixmap == None) {
+ csb->csb.cmyk_slider_width = width;
+ if (csb->csb.visual_class == TrueColor) steps = width / 2;
+ else steps = width / 4;
+
+ ToUserSpace(csb, width, height, &w, &h);
+
+ csb->csb.cyan_pixmap = XCreatePixmap(XtDisplay(csb), XtWindow(csb),
+ width, height, depth);
+
+ XDPSSetContextGState(csb->csb.context, csb->csb.base_gstate);
+ XDPSSetContextDrawable(csb->csb.context, csb->csb.cyan_pixmap, height);
+
+ _DPSCCMYKBlend(csb->csb.context, 0.0, 0.0, w, h, "0 0 0", steps);
+
+ csb->csb.magenta_pixmap = XCreatePixmap(XtDisplay(csb), XtWindow(csb),
+ width, height, depth);
+
+ XDPSSetContextDrawable(csb->csb.context, csb->csb.magenta_pixmap,
+ height);
+
+ _DPSCCMYKBlend(csb->csb.context, 0.0, 0.0, w, h, "0 exch 0 0", steps);
+
+ csb->csb.yellow_pixmap = XCreatePixmap(XtDisplay(csb), XtWindow(csb),
+ width, height, depth);
+
+ XDPSSetContextDrawable(csb->csb.context, csb->csb.yellow_pixmap,
+ height);
+
+ _DPSCCMYKBlend(csb->csb.context, 0.0, 0.0, w, h, "0 0 3 -1 roll 0",
+ steps);
+
+ csb->csb.black_pixmap = XCreatePixmap(XtDisplay(csb), XtWindow(csb),
+ width, height, depth);
+
+ XDPSSetContextDrawable(csb->csb.context, csb->csb.black_pixmap,
+ height);
+
+ _DPSCCMYKBlend(csb->csb.context, 0.0, 0.0, w, h, "0 0 0 4 -1 roll",
+ steps);
+
+ DPSWaitContext(csb->csb.context);
+ }
+
+ XtVaSetValues(csb->csb.slider_child[0], XtNbackgroundPixmap,
+ csb->csb.cyan_pixmap, NULL);
+ XtVaSetValues(csb->csb.slider_child[1], XtNbackgroundPixmap,
+ csb->csb.magenta_pixmap, NULL);
+ XtVaSetValues(csb->csb.slider_child[2], XtNbackgroundPixmap,
+ csb->csb.yellow_pixmap, NULL);
+ XtVaSetValues(csb->csb.slider_child[3], XtNbackgroundPixmap,
+ csb->csb.black_pixmap, NULL);
+}
+
+static void ColorizeHSB(ColorSelectionBoxWidget csb)
+{
+ Dimension height, width;
+ int depth, steps;
+ float w, h;
+
+ XtVaGetValues(csb->csb.slider_child[0], XtNwidth, &width,
+ XtNheight, &height,
+ XtNdepth, &depth, NULL);
+
+ if (csb->csb.hue_pixmap != None && width != csb->csb.hsb_slider_width) {
+ XFreePixmap(XtDisplay(csb), csb->csb.hue_pixmap);
+ XFreePixmap(XtDisplay(csb), csb->csb.sat_pixmap);
+ XFreePixmap(XtDisplay(csb), csb->csb.bright_pixmap);
+ csb->csb.hue_pixmap = None;
+ }
+
+ if (csb->csb.hue_pixmap == None) {
+ csb->csb.hsb_slider_width = width;
+ if (csb->csb.visual_class == TrueColor) steps = width / 2;
+ else steps = width / 4;
+
+ ToUserSpace(csb, width, height, &w, &h);
+
+ csb->csb.hue_pixmap = XCreatePixmap(XtDisplay(csb), XtWindow(csb),
+ width, height, depth);
+
+ XDPSSetContextGState(csb->csb.context, csb->csb.base_gstate);
+ XDPSSetContextDrawable(csb->csb.context, csb->csb.hue_pixmap, height);
+
+ _DPSCHSBBlend(csb->csb.context, 0.0, 0.0, w, h, "1 1", steps);
+
+ csb->csb.sat_pixmap = XCreatePixmap(XtDisplay(csb), XtWindow(csb),
+ width, height, depth);
+
+ XDPSSetContextDrawable(csb->csb.context, csb->csb.sat_pixmap, height);
+
+ _DPSCHSBBlend(csb->csb.context, 0.0, 0.0, w, h, "0 exch 1", steps);
+
+ csb->csb.bright_pixmap = XCreatePixmap(XtDisplay(csb), XtWindow(csb),
+ width, height, depth);
+
+ XDPSSetContextDrawable(csb->csb.context, csb->csb.bright_pixmap,
+ height);
+
+ _DPSCHSBBlend(csb->csb.context, 0.0, 0.0, w, h, "0 1 3 -1 roll",
+ steps);
+
+ DPSWaitContext(csb->csb.context);
+ }
+
+ XtVaSetValues(csb->csb.slider_child[0], XtNbackgroundPixmap,
+ csb->csb.hue_pixmap, NULL);
+ XtVaSetValues(csb->csb.slider_child[1], XtNbackgroundPixmap,
+ csb->csb.sat_pixmap, NULL);
+ XtVaSetValues(csb->csb.slider_child[2], XtNbackgroundPixmap,
+ csb->csb.bright_pixmap, NULL);
+}
+
+static void ColorizeGray(ColorSelectionBoxWidget csb)
+{
+ Dimension height, width;
+ int depth, steps;
+ float w, h;
+
+ XtVaGetValues(csb->csb.slider_child[0], XtNwidth, &width,
+ XtNheight, &height,
+ XtNdepth, &depth, NULL);
+
+ if (csb->csb.gray_pixmap != None && width != csb->csb.gray_slider_width) {
+ XFreePixmap(XtDisplay(csb), csb->csb.gray_pixmap);
+ csb->csb.gray_pixmap = None;
+ }
+
+ if (csb->csb.gray_pixmap == None) {
+ csb->csb.gray_slider_width = width;
+ if (csb->csb.visual_class == TrueColor) steps = width / 2;
+ else steps = width / 4;
+
+ ToUserSpace(csb, width, height, &w, &h);
+
+ csb->csb.gray_pixmap = XCreatePixmap(XtDisplay(csb), XtWindow(csb),
+ width, height, depth);
+
+ XDPSSetContextGState(csb->csb.context, csb->csb.base_gstate);
+ XDPSSetContextDrawable(csb->csb.context, csb->csb.gray_pixmap, height);
+
+ _DPSCGrayBlend(csb->csb.context, 0.0, 0.0, w, h, " ", steps);
+
+ DPSWaitContext(csb->csb.context);
+ }
+
+ XtVaSetValues(csb->csb.slider_child[0], XtNbackgroundPixmap,
+ csb->csb.gray_pixmap, NULL);
+}
+
+static void ColorizeSliders(ColorSelectionBoxWidget csb)
+{
+ if (!XtIsRealized(csb)) return;
+
+ switch (csb->csb.current_space) {
+ case CSBSpaceRGB:
+ ColorizeRGB(csb);
+ break;
+ case CSBSpaceCMYK:
+ ColorizeCMYK(csb);
+ break;
+ case CSBSpaceHSB:
+ ColorizeHSB(csb);
+ break;
+ case CSBSpaceGray:
+ ColorizeGray(csb);
+ break;
+ }
+}
+
+/* ARGSUSED */
+
+static void FormResize(
+ Widget w,
+ XtPointer data,
+ XEvent *event,
+ Boolean *goOn)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) data;
+
+ if (event->type != ConfigureNotify && event->type != MapNotify) return;
+
+ csb->csb.rgb_slider_width = csb->csb.cmyk_slider_width =
+ csb->csb.hsb_slider_width = csb->csb.gray_slider_width = 0;
+ csb->csb.palette_pixmap_valid = False;
+ if (csb->csb.patch_gstate != 0) {
+ XDPSFreeContextGState(csb->csb.context, csb->csb.patch_gstate);
+ csb->csb.patch_gstate = 0;
+ }
+ if (csb->csb.dock_gstate != 0) {
+ XDPSFreeContextGState(csb->csb.context, csb->csb.dock_gstate);
+ csb->csb.dock_gstate = 0;
+ }
+ ColorizeSliders(csb);
+ DrawPalette(csb);
+ if (XtIsRealized(csb->csb.patch_child)) {
+ XClearArea(XtDisplay(csb), XtWindow(csb->csb.patch_child),
+ 0, 0, 1000, 1000, True);
+ }
+}
+
+static void FillCallbackRec(
+ ColorSelectionBoxWidget csb,
+ CSBCallbackRec *rec)
+{
+ rec->current_space = csb->csb.current_space;
+ rec->red = csb->csb.current_color.red;
+ rec->green = csb->csb.current_color.green;
+ rec->blue = csb->csb.current_color.blue;
+ rec->cyan = csb->csb.current_color.cyan;
+ rec->magenta = csb->csb.current_color.magenta;
+ rec->yellow = csb->csb.current_color.yellow;
+ rec->black = csb->csb.current_color.black;
+ rec->hue = csb->csb.current_color.hue;
+ rec->saturation = csb->csb.current_color.saturation;
+ rec->brightness = csb->csb.current_color.brightness;
+ rec->gray = csb->csb.current_color.gray;
+}
+
+/* ARGSUSED */
+
+static void OKCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ CSBCallbackRec rec;
+
+ csb->csb.save_color = csb->csb.current_color;
+ FillCallbackRec(csb, &rec);
+ rec.reason = CSBOK;
+ XtCallCallbackList((Widget) csb, csb->csb.ok_callback, (XtPointer) &rec);
+ if (XtIsShell(XtParent(csb))) XtPopdown(XtParent(csb));
+
+ SaveDockContents(csb);
+}
+
+/* ARGSUSED */
+
+static void ApplyCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ CSBCallbackRec rec;
+
+ csb->csb.save_color = csb->csb.current_color;
+ FillCallbackRec(csb, &rec);
+ rec.reason = CSBApply;
+ XtCallCallbackList((Widget) csb, csb->csb.apply_callback,
+ (XtPointer) &rec);
+
+ SaveDockContents(csb);
+}
+
+/* ARGSUSED */
+
+static void ResetCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ CSBCallbackRec rec;
+
+ csb->csb.current_color = csb->csb.save_color;
+ FillPatch(csb);
+ SetSliders(csb);
+ FillCallbackRec(csb, &rec);
+ rec.reason = CSBReset;
+ XtCallCallbackList((Widget) csb, csb->csb.reset_callback,
+ (XtPointer) &rec);
+}
+
+/* ARGSUSED */
+
+static void CancelCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ CSBCallbackRec rec;
+
+ csb->csb.current_color = csb->csb.save_color;
+ FillPatch(csb);
+ SetSliders(csb);
+ FillCallbackRec(csb, &rec);
+ rec.reason = CSBCancel;
+ XtCallCallbackList((Widget) csb, csb->csb.cancel_callback,
+ (XtPointer) &rec);
+ if (XtIsShell(XtParent(csb))) XtPopdown(XtParent(csb));
+}
+
+/* ARGSUSED */
+
+static void DoValueChangedCallback(ColorSelectionBoxWidget csb)
+{
+ CSBCallbackRec rec;
+
+ FillCallbackRec(csb, &rec);
+ rec.reason = CSBValueChanged;
+ XtCallCallbackList((Widget) csb, csb->csb.value_changed_callback,
+ (XtPointer) &rec);
+}
+
+/* ARGSUSED */
+
+static void ChangeLabelCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ XmScaleCallbackStruct *scaleData = (XmScaleCallbackStruct *) callData;
+
+ ChangeLabel((Widget) clientData, ((float) scaleData->value) / 100.0);
+}
+
+static void ChangeLabel(Widget label, double n)
+{
+ char buf[10];
+
+ sprintf(buf, "%d", TO_PCT(n));
+ XtVaSetValues(label, XmNlabelString, CS(buf, label), NULL);
+}
+
+static void CreateModelMenu(Widget parent, Widget csb)
+{
+ Widget kids[4];
+
+ kids[0] = XmCreatePushButtonGadget(parent, "rgb", (ArgList) NULL, 0);
+ XtAddCallback(kids[0], XmNactivateCallback,
+ SetRGBCallback, (XtPointer) csb);
+ kids[1] = XmCreatePushButtonGadget(parent, "cmyk", (ArgList) NULL, 0);
+ XtAddCallback(kids[1], XmNactivateCallback,
+ SetCMYKCallback, (XtPointer) csb);
+ kids[2] = XmCreatePushButtonGadget(parent, "hsb", (ArgList) NULL, 0);
+ XtAddCallback(kids[2], XmNactivateCallback,
+ SetHSBCallback, (XtPointer) csb);
+ kids[3] = XmCreatePushButtonGadget(parent, "gray", (ArgList) NULL, 0);
+ XtAddCallback(kids[3], XmNactivateCallback,
+ SetGrayCallback, (XtPointer) csb);
+
+ XtManageChildren(kids, 4);
+}
+
+typedef struct {
+ ColorSelectionBoxWidget csb;
+ CSBRenderingType rendering;
+} RenderingRec;
+
+/* ARGSUSED */
+
+static void SetRenderingCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ RenderingRec *r = (RenderingRec *) clientData;
+
+ r->csb->csb.current_rendering = r->rendering;
+ FillPatch(r->csb);
+}
+
+static void CreateDisplayMenu(Widget parent, ColorSelectionBoxWidget csb)
+{
+ Widget kids[3];
+ RenderingRec *r;
+
+ r = XtNew(RenderingRec);
+ r->csb = csb;
+ r->rendering = CSBDisplayDPS;
+ kids[0] = XmCreatePushButtonGadget(parent, "displayDPS",
+ (ArgList) NULL, 0);
+ XtAddCallback(kids[0], XmNactivateCallback,
+ SetRenderingCallback, (XtPointer) r);
+ r = XtNew(RenderingRec);
+ r->csb = csb;
+ r->rendering = CSBDisplayX;
+ kids[1] = XmCreatePushButtonGadget(parent, "displayX", (ArgList) NULL, 0);
+ XtAddCallback(kids[1], XmNactivateCallback,
+ SetRenderingCallback, (XtPointer) r);
+ r = XtNew(RenderingRec);
+ r->csb = csb;
+ r->rendering = CSBDisplayBoth;
+ kids[2] = XmCreatePushButtonGadget(parent, "displayBoth",
+ (ArgList) NULL, 0);
+ XtAddCallback(kids[2], XmNactivateCallback,
+ SetRenderingCallback, (XtPointer) r);
+
+ XtManageChildren(kids, 3);
+}
+
+typedef struct {
+ ColorSelectionBoxWidget csb;
+ int n;
+} PaletteRec;
+
+/* ARGSUSED */
+
+static void SetPaletteCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ PaletteRec *p = (PaletteRec *) clientData;
+
+ if (p->csb->csb.palette_broken[p->n]) return;
+
+ if (p->n != p->csb->csb.current_palette ||
+ p->csb->csb.palette_color_dependent[p->n]) {
+ p->csb->csb.palette_pixmap_valid = False;
+ }
+
+ p->csb->csb.current_palette = p->n;
+ DrawPalette(p->csb);
+}
+
+static void CreatePaletteMenu(Widget parent, ColorSelectionBoxWidget csb)
+{
+ Widget w, managed[PALETTE_MAX];
+ int j, k;
+ char buf[10];
+ PaletteRec *p;
+
+ j = 0;
+
+ for (k = 0; k < PALETTE_MAX; k++) {
+ p = XtNew(PaletteRec);
+ p->csb = csb;
+ p->n = k;
+ sprintf(buf, "palette%d", k);
+ w = XtVaCreateWidget(buf, xmPushButtonGadgetClass, parent, NULL);
+ if (csb->csb.palette_label[k] != NULL) {
+ XtVaSetValues(w, XtVaTypedArg, XmNlabelString,
+ XtRString, csb->csb.palette_label[k],
+ strlen(csb->csb.palette_label[k])+1,
+ NULL);
+ }
+ XtAddCallback(w, XmNactivateCallback,
+ SetPaletteCallback, (XtPointer) p);
+ if (csb->csb.palette_function[k] != NULL) managed[j++] = w;
+ }
+
+ if (j != 0) XtManageChildren(managed, j);
+}
+
+static void CreateChildren(ColorSelectionBoxWidget csb)
+{
+ int i;
+ Arg args[20];
+ Widget form, menu, button, w, dock_frame, palette_frame;
+ Pixel fg, bg;
+ int depth;
+ Pixmap eyedrop;
+
+ i = 0;
+ XtSetArg(args[i], XmNresizePolicy, XmRESIZE_NONE); i++;
+ form = XtCreateManagedWidget("panel", xmFormWidgetClass,
+ (Widget) csb, args, i);
+ csb->csb.form_child = form;
+ XtAddEventHandler(form, StructureNotifyMask, False, FormResize,
+ (XtPointer) csb);
+
+ i = 0;
+ menu = XmCreatePulldownMenu(form, "modelMenu", args, i);
+ CreateModelMenu(menu, (Widget) csb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNsubMenuId, menu); i++;
+ csb->csb.model_option_menu_child =
+ XmCreateOptionMenu(form, "modelOptionMenu",
+ args, i);
+ XtManageChild(csb->csb.model_option_menu_child);
+
+ XtVaGetValues(form, XtNbackground, &bg, XmNforeground, &fg,
+ XtNdepth, &depth, NULL);
+ eyedrop = XCreatePixmapFromBitmapData(XtDisplay(csb),
+ RootWindowOfScreen(XtScreen(csb)),
+ (char *) heyedrop_bits,
+ heyedrop_width, heyedrop_height,
+ fg, bg, depth);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, csb->csb.model_option_menu_child); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.model_option_menu_child); i++;
+ XtSetArg(args[i], XmNlabelPixmap, eyedrop); i++;
+ button = XtCreateManagedWidget("eyedropButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(button, XmNactivateCallback,
+ DoEyedropCallback, (XtPointer) csb);
+ XtInsertRawEventHandler(button, PointerMotionMask | ButtonReleaseMask,
+ False, EyedropPointer, (XtPointer) csb,
+ XtListHead);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.model_option_menu_child); i++;
+ csb->csb.label_child[0] =
+ XtCreateManagedWidget("label1", xmLabelWidgetClass, form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.model_option_menu_child); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_POSITION); i++;
+ csb->csb.value_child[0] =
+ XtCreateManagedWidget("value1", xmLabelWidgetClass, form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, csb->csb.label_child[0]); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.model_option_menu_child); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, csb->csb.value_child[0]); i++;
+ csb->csb.slider_child[0] =
+ XtCreateManagedWidget("slider1", xmScaleWidgetClass,
+ form, args, i);
+ XtAddCallback(csb->csb.slider_child[0], XmNvalueChangedCallback,
+ ChangeLabelCallback, (XtPointer) csb->csb.value_child[0]);
+ XtAddCallback(csb->csb.slider_child[0], XmNdragCallback,
+ ChangeLabelCallback, (XtPointer) csb->csb.value_child[0]);
+ XtAddCallback(csb->csb.slider_child[0], XmNvalueChangedCallback,
+ Slider1Callback, (XtPointer) csb);
+ XtAddCallback(csb->csb.slider_child[0], XmNdragCallback,
+ Slider1Callback, (XtPointer) csb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.slider_child[0]); i++;
+ csb->csb.label_child[1] =
+ XtCreateManagedWidget("label2", xmLabelWidgetClass, form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.slider_child[0]); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, csb->csb.value_child[0]); i++;
+ csb->csb.value_child[1] =
+ XtCreateManagedWidget("value2", xmLabelWidgetClass, form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, csb->csb.slider_child[0]); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.slider_child[0]); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, csb->csb.slider_child[0]); i++;
+ csb->csb.slider_child[1] =
+ XtCreateManagedWidget("slider2", xmScaleWidgetClass,
+ form, args, i);
+ XtAddCallback(csb->csb.slider_child[1], XmNvalueChangedCallback,
+ ChangeLabelCallback, (XtPointer) csb->csb.value_child[1]);
+ XtAddCallback(csb->csb.slider_child[1], XmNdragCallback,
+ ChangeLabelCallback, (XtPointer) csb->csb.value_child[1]);
+ XtAddCallback(csb->csb.slider_child[1], XmNvalueChangedCallback,
+ Slider2Callback, (XtPointer) csb);
+ XtAddCallback(csb->csb.slider_child[1], XmNdragCallback,
+ Slider2Callback, (XtPointer) csb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.slider_child[1]); i++;
+ csb->csb.label_child[2] =
+ XtCreateManagedWidget("label3", xmLabelWidgetClass, form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.slider_child[1]); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, csb->csb.value_child[0]); i++;
+ csb->csb.value_child[2] =
+ XtCreateManagedWidget("value3", xmLabelWidgetClass, form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, csb->csb.slider_child[0]); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.slider_child[1]); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, csb->csb.slider_child[0]); i++;
+ csb->csb.slider_child[2] =
+ XtCreateManagedWidget("slider3", xmScaleWidgetClass,
+ form, args, i);
+ XtAddCallback(csb->csb.slider_child[2], XmNvalueChangedCallback,
+ ChangeLabelCallback, (XtPointer) csb->csb.value_child[2]);
+ XtAddCallback(csb->csb.slider_child[2], XmNdragCallback,
+ ChangeLabelCallback, (XtPointer) csb->csb.value_child[2]);
+ XtAddCallback(csb->csb.slider_child[2], XmNvalueChangedCallback,
+ Slider3Callback, (XtPointer) csb);
+ XtAddCallback(csb->csb.slider_child[2], XmNdragCallback,
+ Slider3Callback, (XtPointer) csb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.slider_child[2]); i++;
+ csb->csb.label_child[3] =
+ XtCreateManagedWidget("label4", xmLabelWidgetClass, form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.slider_child[2]); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, csb->csb.value_child[0]); i++;
+ csb->csb.value_child[3] =
+ XtCreateManagedWidget("value4", xmLabelWidgetClass, form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, csb->csb.slider_child[0]); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.slider_child[2]); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, csb->csb.slider_child[0]); i++;
+ csb->csb.slider_child[3] =
+ XtCreateManagedWidget("slider4", xmScaleWidgetClass,
+ form, args, i);
+ XtAddCallback(csb->csb.slider_child[3], XmNvalueChangedCallback,
+ ChangeLabelCallback, (XtPointer) csb->csb.value_child[3]);
+ XtAddCallback(csb->csb.slider_child[3], XmNdragCallback,
+ ChangeLabelCallback, (XtPointer) csb->csb.value_child[3]);
+ XtAddCallback(csb->csb.slider_child[3], XmNvalueChangedCallback,
+ Slider4Callback, (XtPointer) csb);
+ XtAddCallback(csb->csb.slider_child[3], XmNdragCallback,
+ Slider4Callback, (XtPointer) csb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ button = XtCreateManagedWidget("okButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(button, XmNactivateCallback, OKCallback, (XtPointer) csb);
+
+ i = 0;
+ XtSetArg(args[i], XmNdefaultButton, button); i++;
+ XtSetValues(form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, button); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ button = XtCreateManagedWidget("applyButton", xmPushButtonWidgetClass,
+ form, args, i);
+
+ XtAddCallback(button, XmNactivateCallback, ApplyCallback, (XtPointer) csb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, button); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ button = XtCreateManagedWidget("resetButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(button, XmNactivateCallback, ResetCallback, (XtPointer) csb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, button); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ button = XtCreateManagedWidget("cancelButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(button, XmNactivateCallback,
+ CancelCallback, (XtPointer) csb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, button); i++;
+ w = XtCreateManagedWidget("separator", xmSeparatorGadgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, w); i++;
+ palette_frame = XtCreateManagedWidget("paletteFrame", xmFrameWidgetClass,
+ form, args, i);
+
+ i = 0;
+ csb->csb.palette_child =
+ XtCreateManagedWidget("palette", xmDrawingAreaWidgetClass,
+ palette_frame, args, i);
+ XtAddCallback(csb->csb.palette_child, XmNexposeCallback,
+ DrawPaletteCallback, (XtPointer) csb);
+ XtAddEventHandler(csb->csb.palette_child, ButtonPressMask, False,
+ PalettePress, (XtPointer) csb);
+
+ i = 0;
+ menu = XmCreatePulldownMenu(form, "paletteMenu", args, i);
+ CreatePaletteMenu(menu, csb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, palette_frame); i++;
+ XtSetArg(args[i], XmNsubMenuId, menu); i++;
+ csb->csb.palette_option_menu_child =
+ XmCreateOptionMenu(form, "paletteOptionMenu",
+ args, i);
+ XtManageChild(csb->csb.palette_option_menu_child);
+
+ i = 0;
+ menu = XmCreatePulldownMenu(form, "displayMenu", args, i);
+ CreateDisplayMenu(menu, csb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNsubMenuId, menu); i++;
+ csb->csb.display_option_menu_child =
+ XmCreateOptionMenu(form, "displayOptionMenu",
+ args, i);
+ XtManageChild(csb->csb.display_option_menu_child);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, csb->csb.display_option_menu_child);i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, palette_frame); i++;
+ dock_frame = XtCreateManagedWidget("dockFrame", xmFrameWidgetClass,
+ form, args, i);
+
+ i = 0;
+ csb->csb.dock_child =
+ XtCreateManagedWidget("dock", xmDrawingAreaWidgetClass,
+ dock_frame, args, i);
+ XtAddCallback(csb->csb.dock_child, XmNexposeCallback,
+ DrawDockCallback, (XtPointer) csb);
+ XtAddEventHandler(csb->csb.dock_child, ButtonPressMask, False, DockPress,
+ (XtPointer) csb);
+
+ {
+ Dimension height;
+ int q;
+
+ XtVaGetValues(csb->csb.dock_child, XtNheight, &height, NULL);
+ if (height < csb->csb.cell_size) height = csb->csb.cell_size;
+ else if (height % csb->csb.cell_size != 0) {
+ q = height / csb->csb.cell_size;
+ height = csb->csb.cell_size * q;
+ }
+ XtVaSetValues(csb->csb.dock_child, XtNheight, height, NULL);
+ }
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, dock_frame); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, csb->csb.display_option_menu_child);i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, dock_frame); i++;
+ w = XtCreateManagedWidget("patchFrame", xmFrameWidgetClass,
+ form, args, i);
+
+ i = 0;
+ csb->csb.patch_child =
+ XtCreateManagedWidget("patch", xmDrawingAreaWidgetClass,
+ w, args, i);
+ XtAddCallback(csb->csb.patch_child, XmNexposeCallback,
+ FillPatchCallback, (XtPointer) csb);
+ XtAddRawEventHandler(csb->csb.patch_child, ButtonPressMask,
+ False, PatchPress, (XtPointer) csb);
+ XtAddRawEventHandler(csb->csb.patch_child, ButtonReleaseMask,
+ False, PatchRelease, (XtPointer) csb);
+}
+
+static void NoBackgroundPixel(ColorSelectionBoxWidget csb)
+{
+ Widget w, message;
+
+ csb->csb.no_background = True;
+ w = XtNameToWidget((Widget) csb, "*displayX");
+ XtSetSensitive(w, False);
+ w = XtNameToWidget((Widget) csb, "*displayBoth");
+ XtSetSensitive(w, False);
+ w = XtNameToWidget((Widget) csb, "*displayDPS");
+ XtVaSetValues(csb->csb.display_option_menu_child, XmNmenuHistory, w, NULL);
+
+ message = XmCreateInformationDialog(csb->csb.form_child,
+ "noBackgroundMessage",
+ (ArgList) NULL, 0);
+ w = XmMessageBoxGetChild(message, XmDIALOG_CANCEL_BUTTON);
+ XtUnmanageChild(w);
+ w = XmMessageBoxGetChild(message, XmDIALOG_HELP_BUTTON);
+ XtUnmanageChild(w);
+
+ XtManageChild(message);
+}
+
+/* labelString is changed by this */
+
+static void ParseLabels(String labelString, String labels[4], int n)
+{
+ register char *ch;
+ int i;
+
+ ch = labelString;
+ for (i = 0; i < n; i++) {
+ labels[i] = ch;
+ while (*ch != ':' && *ch != '\0') ch++;
+ *ch++ = '\0';
+ }
+
+ for (i = n; i < 4; i++) labels[i] = NULL;
+}
+
+static void SetLabels(ColorSelectionBoxWidget csb, String *labels)
+{
+ Widget w = (Widget) csb;
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ if (labels[i] != NULL) {
+ XtVaSetValues(csb->csb.label_child[i],
+ XmNlabelString, CS(labels[i], w), NULL);
+ }
+ }
+}
+
+static void MapChildren(Widget *children, int n)
+{
+ XtManageChildren(children, n);
+}
+
+static void UnmapChildren(Widget *children, int n)
+{
+ XtUnmanageChildren(children, n);
+}
+
+static void SetSliders(ColorSelectionBoxWidget csb)
+{
+ switch(csb->csb.current_space) {
+ case CSBSpaceRGB: SetRGBValues(csb); break;
+ case CSBSpaceCMYK: SetCMYKValues(csb); break;
+ case CSBSpaceHSB: SetHSBValues(csb); break;
+ case CSBSpaceGray: SetGrayValues(csb); break;
+ }
+}
+
+static void SetRGBValues(ColorSelectionBoxWidget csb)
+{
+ XmScaleSetValue(csb->csb.slider_child[0],
+ TO_PCT(csb->csb.current_color.red));
+ XmScaleSetValue(csb->csb.slider_child[1],
+ TO_PCT(csb->csb.current_color.green));
+ XmScaleSetValue(csb->csb.slider_child[2],
+ TO_PCT(csb->csb.current_color.blue));
+ ChangeLabel(csb->csb.value_child[0], csb->csb.current_color.red);
+ ChangeLabel(csb->csb.value_child[1], csb->csb.current_color.green);
+ ChangeLabel(csb->csb.value_child[2], csb->csb.current_color.blue);
+}
+
+/* ARGSUSED */
+
+static void SetRGBCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ Widget rgb;
+ Widget children[6];
+ String labels[4];
+ int i, j;
+
+ csb->csb.current_space = CSBSpaceRGB;
+
+ ParseLabels(csb->csb.rgb_labels, labels, 3);
+
+ rgb = XtNameToWidget((Widget) csb, "*rgb");
+
+ XtVaSetValues(csb->csb.model_option_menu_child, XmNmenuHistory, rgb, NULL);
+
+ SetLabels(csb, labels);
+
+ SetRGBValues(csb);
+
+ j = 0;
+ for (i = 1; i < 3; i++) {
+ children[j++] = csb->csb.label_child[i];
+ children[j++] = csb->csb.slider_child[i];
+ children[j++] = csb->csb.value_child[i];
+ }
+
+ MapChildren(children, 6);
+
+ children[0] = csb->csb.label_child[3];
+ children[1] = csb->csb.slider_child[3];
+ children[2] = csb->csb.value_child[3];
+
+ UnmapChildren(children, 3);
+
+ ColorizeSliders(csb);
+ FillPatch(csb);
+}
+
+static void SetCMYKValues(ColorSelectionBoxWidget csb)
+{
+ XmScaleSetValue(csb->csb.slider_child[0],
+ TO_PCT(csb->csb.current_color.cyan));
+ XmScaleSetValue(csb->csb.slider_child[1],
+ TO_PCT(csb->csb.current_color.magenta));
+ XmScaleSetValue(csb->csb.slider_child[2],
+ TO_PCT(csb->csb.current_color.yellow));
+ XmScaleSetValue(csb->csb.slider_child[3],
+ TO_PCT(csb->csb.current_color.black));
+ ChangeLabel(csb->csb.value_child[0], csb->csb.current_color.cyan);
+ ChangeLabel(csb->csb.value_child[1], csb->csb.current_color.magenta);
+ ChangeLabel(csb->csb.value_child[2], csb->csb.current_color.yellow);
+ ChangeLabel(csb->csb.value_child[3], csb->csb.current_color.black);
+}
+
+/* ARGSUSED */
+
+static void SetCMYKCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ Widget cmyk;
+ Widget children[9];
+ String labels[4];
+ int i, j;
+
+ csb->csb.current_space = CSBSpaceCMYK;
+
+ ParseLabels(csb->csb.cmyk_labels, labels, 4);
+
+ cmyk = XtNameToWidget((Widget) csb, "*cmyk");
+
+ XtVaSetValues(csb->csb.model_option_menu_child,
+ XmNmenuHistory, cmyk, NULL);
+
+ SetLabels(csb, labels);
+
+ SetCMYKValues(csb);
+
+ j = 0;
+ for (i = 1; i < 4; i++) {
+ children[j++] = csb->csb.label_child[i];
+ children[j++] = csb->csb.slider_child[i];
+ children[j++] = csb->csb.value_child[i];
+ }
+
+ MapChildren(children, 9);
+
+ ColorizeSliders(csb);
+ FillPatch(csb);
+}
+
+static void SetHSBValues(ColorSelectionBoxWidget csb)
+{
+ XmScaleSetValue(csb->csb.slider_child[0],
+ TO_PCT(csb->csb.current_color.hue));
+ XmScaleSetValue(csb->csb.slider_child[1],
+ TO_PCT(csb->csb.current_color.saturation));
+ XmScaleSetValue(csb->csb.slider_child[2],
+ TO_PCT(csb->csb.current_color.brightness));
+ ChangeLabel(csb->csb.value_child[0], csb->csb.current_color.hue);
+ ChangeLabel(csb->csb.value_child[1], csb->csb.current_color.saturation);
+ ChangeLabel(csb->csb.value_child[2], csb->csb.current_color.brightness);
+}
+
+/* ARGSUSED */
+
+static void SetHSBCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ Widget hsb;
+ Widget children[6];
+ String labels[4];
+ int i, j;
+
+ csb->csb.current_space = CSBSpaceHSB;
+
+ ParseLabels(csb->csb.hsb_labels, labels, 3);
+
+ hsb = XtNameToWidget((Widget) csb, "*hsb");
+
+ XtVaSetValues(csb->csb.model_option_menu_child, XmNmenuHistory, hsb, NULL);
+
+ SetLabels(csb, labels);
+
+ SetHSBValues(csb);
+
+ j = 0;
+ for (i = 1; i < 3; i++) {
+ children[j++] = csb->csb.label_child[i];
+ children[j++] = csb->csb.slider_child[i];
+ children[j++] = csb->csb.value_child[i];
+ }
+
+ MapChildren(children, 6);
+
+ children[0] = csb->csb.label_child[3];
+ children[1] = csb->csb.slider_child[3];
+ children[2] = csb->csb.value_child[3];
+
+ UnmapChildren(children, 3);
+
+ ColorizeSliders(csb);
+ FillPatch(csb);
+}
+
+static void SetGrayValues(ColorSelectionBoxWidget csb)
+{
+ XmScaleSetValue(csb->csb.slider_child[0],
+ TO_PCT(csb->csb.current_color.gray));
+ ChangeLabel(csb->csb.value_child[0], csb->csb.current_color.gray);
+}
+
+/* ARGSUSED */
+
+static void SetGrayCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ Widget gray;
+ Widget children[9];
+ String labels[4];
+ int i, j;
+
+ csb->csb.current_space = CSBSpaceGray;
+
+ gray = XtNameToWidget((Widget) csb, "*gray");
+
+ XtVaSetValues(csb->csb.model_option_menu_child, XmNmenuHistory, gray, NULL);
+
+ labels[0] = csb->csb.gray_labels;
+ labels[1] = labels[2] = labels[3] = NULL;
+ SetLabels(csb, labels);
+
+ SetGrayValues(csb);
+
+ j = 0;
+ for (i = 1; i < 4; i++) {
+ children[j++] = csb->csb.label_child[i];
+ children[j++] = csb->csb.slider_child[i];
+ children[j++] = csb->csb.value_child[i];
+ }
+
+ UnmapChildren(children, 9);
+
+ ColorizeSliders(csb);
+ FillPatch(csb);
+}
+
+static void RGBToCMYK(ColorSelectionBoxWidget csb)
+{
+ csb->csb.current_color.cyan = 1.0 - csb->csb.current_color.red;
+ csb->csb.current_color.magenta = 1.0 - csb->csb.current_color.green;
+ csb->csb.current_color.yellow = 1.0 - csb->csb.current_color.blue;
+ csb->csb.current_color.black = 0.0;
+}
+
+static void RGBToGray(ColorSelectionBoxWidget csb)
+{
+ csb->csb.current_color.gray = .3 * csb->csb.current_color.red +
+ .59 * csb->csb.current_color.green +
+ .11 * csb->csb.current_color.blue;
+}
+
+static void HSBToRGB(ColorSelectionBoxWidget csb)
+{
+ double r, g, bl;
+ double h, s, b;
+ double f, m, n, k;
+ int i;
+
+ if (csb->csb.current_color.saturation == 0) {
+ r = g = bl = csb->csb.current_color.brightness;
+ } else {
+ h = csb->csb.current_color.hue;
+ s = csb->csb.current_color.saturation;
+ b = csb->csb.current_color.brightness;
+
+ h = 6.0 * h;
+ if (h >= 6.0) h = 0.0;
+ i = (int) h;
+ f = h - (double)i;
+ m = b * (1.0 - s);
+ n = b * (1.0 - (s * f));
+ k = b * (1.0 - (s * (1.0 - f)));
+
+ switch(i) {
+ default:
+ case 0: r = b; g = k; bl = m; break;
+ case 1: r = n; g = b; bl = m; break;
+ case 2: r = m; g = b; bl = k; break;
+ case 3: r = m; g = n; bl = b; break;
+ case 4: r = k; g = m; bl = b; break;
+ case 5: r = b; g = m; bl = n; break;
+ }
+ }
+
+ csb->csb.current_color.red = r;
+ csb->csb.current_color.green = g;
+ csb->csb.current_color.blue = bl;
+}
+
+static void RGBToHSB(ColorSelectionBoxWidget csb)
+{
+ double hue, sat, value;
+ double diff, x, r, g, b;
+ double red, green, blue;
+
+ red = csb->csb.current_color.red;
+ green = csb->csb.current_color.green;
+ blue = csb->csb.current_color.blue;
+
+ hue = sat = 0.0;
+ value = x = red;
+ if (green > value) value = green; else x = green;
+ if (blue > value) value = blue;
+ if (blue < x) x = blue;
+
+ if (value != 0.0) {
+ diff = value - x;
+ if (diff != 0.0) {
+ sat = diff / value;
+ r = (value - red) / diff;
+ g = (value - green) / diff;
+ b = (value - blue) / diff;
+ if (red == value) hue = (green == x) ? 5.0 + b : 1.0 - g;
+ else if (green == value) hue = (blue == x) ? 1.0 + r : 3.0 - b;
+ else hue = (red == x) ? 3.0 + g : 5.0 - r;
+ hue /= 6.0; if (hue >= 1.0 || hue <= 0.0) hue = 0.0;
+ }
+ }
+ csb->csb.current_color.hue = hue;
+ csb->csb.current_color.saturation = sat;
+ csb->csb.current_color.brightness = value;
+}
+
+static void UpdateColorSpaces(
+ ColorSelectionBoxWidget csb,
+ CSBColorSpace masterSpace)
+{
+ switch (masterSpace) {
+ case CSBSpaceRGB:
+ RGBToCMYK(csb);
+ RGBToHSB(csb);
+ RGBToGray(csb);
+ break;
+
+ case CSBSpaceCMYK:
+ csb->csb.current_color.red =
+ 1.0 - MIN(1.0, csb->csb.current_color.cyan +
+ csb->csb.current_color.black);
+ csb->csb.current_color.green =
+ 1.0 - MIN(1.0, csb->csb.current_color.magenta +
+ csb->csb.current_color.black);
+ csb->csb.current_color.blue =
+ 1.0 - MIN(1.0, csb->csb.current_color.yellow +
+ csb->csb.current_color.black);
+ RGBToHSB(csb);
+ RGBToGray(csb);
+ break;
+
+ case CSBSpaceHSB:
+ HSBToRGB(csb);
+ RGBToCMYK(csb);
+ RGBToGray(csb);
+ break;
+
+ case CSBSpaceGray:
+ csb->csb.current_color.red = csb->csb.current_color.green =
+ csb->csb.current_color.blue = csb->csb.current_color.gray;
+
+ csb->csb.current_color.hue =
+ csb->csb.current_color.saturation = 0.0;
+ csb->csb.current_color.brightness = csb->csb.current_color.gray;
+
+ csb->csb.current_color.cyan = csb->csb.current_color.magenta =
+ csb->csb.current_color.yellow = 0.0;
+ csb->csb.current_color.black = 1.0 - csb->csb.current_color.gray;
+ break;
+ }
+}
+
+/* ARGSUSED */
+
+static void Slider1Callback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ XmScaleCallbackStruct *scaleData = (XmScaleCallbackStruct *) callData;
+
+ switch(csb->csb.current_space) {
+ case CSBSpaceRGB:
+ csb->csb.current_color.red = scaleData->value / 100.0;
+ break;
+ case CSBSpaceCMYK:
+ csb->csb.current_color.cyan = scaleData->value / 100.0;
+ break;
+ case CSBSpaceHSB:
+ csb->csb.current_color.hue = scaleData->value / 100.0;
+ break;
+ case CSBSpaceGray:
+ csb->csb.current_color.gray = scaleData->value / 100.0;
+ break;
+ }
+
+ UpdateColorSpaces(csb, csb->csb.current_space);
+ DoValueChangedCallback(csb);
+ FillPatch(csb);
+}
+
+/* ARGSUSED */
+
+static void Slider2Callback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ XmScaleCallbackStruct *scaleData = (XmScaleCallbackStruct *) callData;
+
+ switch(csb->csb.current_space) {
+ case CSBSpaceRGB:
+ csb->csb.current_color.green = scaleData->value / 100.0;
+ break;
+ case CSBSpaceCMYK:
+ csb->csb.current_color.magenta = scaleData->value / 100.0;
+ break;
+ case CSBSpaceHSB:
+ csb->csb.current_color.saturation = scaleData->value / 100.0;
+ break;
+ case CSBSpaceGray:
+ break;
+ }
+
+ UpdateColorSpaces(csb, csb->csb.current_space);
+ DoValueChangedCallback(csb);
+ FillPatch(csb);
+}
+
+/* ARGSUSED */
+
+static void Slider3Callback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ XmScaleCallbackStruct *scaleData = (XmScaleCallbackStruct *) callData;
+
+ switch(csb->csb.current_space) {
+ case CSBSpaceRGB:
+ csb->csb.current_color.blue = scaleData->value / 100.0;
+ break;
+ case CSBSpaceCMYK:
+ csb->csb.current_color.yellow = scaleData->value / 100.0;
+ break;
+ case CSBSpaceHSB:
+ csb->csb.current_color.brightness = scaleData->value / 100.0;
+ break;
+ case CSBSpaceGray:
+ break;
+ }
+
+ UpdateColorSpaces(csb, csb->csb.current_space);
+ DoValueChangedCallback(csb);
+ FillPatch(csb);
+}
+
+/* ARGSUSED */
+
+static void Slider4Callback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ XmScaleCallbackStruct *scaleData = (XmScaleCallbackStruct *) callData;
+
+ csb->csb.current_color.black = scaleData->value / 100.0;
+
+ UpdateColorSpaces(csb, csb->csb.current_space);
+ DoValueChangedCallback(csb);
+ FillPatch(csb);
+}
+
+static void FillPatch(ColorSelectionBoxWidget csb)
+{
+ Colormap c;
+ XColor xc;
+ Widget patch = csb->csb.patch_child;
+
+ if (!XtIsRealized(csb->csb.patch_child)) return;
+
+ if (csb->csb.no_background) {
+ XClearArea(XtDisplay(patch), XtWindow(patch), 0, 0, 1000, 1000, True);
+ return;
+ }
+
+ /* All we have to do is set the background; the expose event will
+ do the rest */
+
+ XtVaGetValues(patch, XtNcolormap, (XtPointer) &c, NULL);
+
+ if (csb->csb.current_space == CSBSpaceGray) {
+ xc.red = xc.green = xc.blue = TO_X(csb->csb.current_color.gray);
+ } else {
+ xc.red = TO_X(csb->csb.current_color.red);
+ xc.green = TO_X(csb->csb.current_color.green);
+ xc.blue = TO_X(csb->csb.current_color.blue);
+ }
+
+ if (csb->csb.static_visual) {
+ (void) XAllocColor(XtDisplay(patch), c, &xc);
+ csb->csb.background = xc.pixel;
+ XtVaSetValues(patch, XtNbackground, csb->csb.background, NULL);
+ } else {
+ xc.pixel = csb->csb.background;
+ xc.flags = DoRed | DoGreen | DoBlue;
+ XStoreColor(XtDisplay(patch), c, &xc);
+ }
+
+ XClearArea(XtDisplay(patch), XtWindow(patch), 0, 0, 1000, 1000, True);
+}
+
+/* ARGSUSED */
+
+static void FillPatchCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ Dimension height, width;
+ float fh, fw;
+
+ if (csb->csb.current_rendering != CSBDisplayX) {
+ XtVaGetValues(w, XtNheight, &height, XtNwidth, &width, NULL);
+ if (csb->csb.patch_gstate == 0) {
+ XDPSSetContextGState(csb->csb.context, csb->csb.base_gstate);
+ XDPSSetContextDrawable(csb->csb.context, XtWindow(w), height);
+ (void) XDPSCaptureContextGState(csb->csb.context,
+ &csb->csb.patch_gstate);
+ } else XDPSSetContextGState(csb->csb.context, csb->csb.patch_gstate);
+
+ switch (csb->csb.current_space) {
+ case CSBSpaceRGB:
+ DPSsetrgbcolor(csb->csb.context, csb->csb.current_color.red,
+ csb->csb.current_color.green,
+ csb->csb.current_color.blue);
+ break;
+ case CSBSpaceCMYK:
+ DPSsetcmykcolor(csb->csb.context, csb->csb.current_color.cyan,
+ csb->csb.current_color.magenta,
+ csb->csb.current_color.yellow,
+ csb->csb.current_color.black);
+ break;
+ case CSBSpaceHSB:
+ DPSsethsbcolor(csb->csb.context, csb->csb.current_color.hue,
+ csb->csb.current_color.saturation,
+ csb->csb.current_color.brightness);
+ break;
+ case CSBSpaceGray:
+ DPSsetgray(csb->csb.context, csb->csb.current_color.gray);
+ break;
+ }
+ }
+
+ switch (csb->csb.current_rendering) {
+ case CSBDisplayDPS:
+ DPSrectfill(csb->csb.context, 0.0, 0.0, 1000.0, 1000.0);
+ break;
+ case CSBDisplayX:
+ break;
+ case CSBDisplayBoth:
+ ToUserSpace(csb, width, height, &fw, &fh);
+ _DPSCTriangle(csb->csb.context, fh, fw);
+ break;
+ }
+}
+
+/* The following function Copyright 1987, 1988 by Digital Equipment
+Corporation, Maynard, Massachusetts, and the Massachusetts Institute of
+Technology, Cambridge, Massachusetts. */
+
+static String GetRootDirName(String buf)
+{
+#ifndef X_NOT_POSIX
+ uid_t uid;
+#else
+ int uid;
+ extern int getuid();
+#ifndef SYSV386
+ extern struct passwd *getpwuid(), *getpwnam();
+#endif
+#endif
+ struct passwd *pw;
+ static char *ptr = NULL;
+
+ if (ptr == NULL) {
+ if (!(ptr = getenv("HOME"))) {
+ if ((ptr = getenv("USER")) != 0) {
+ pw = getpwnam(ptr);
+ } else {
+ uid = getuid();
+ pw = getpwuid(uid);
+ }
+ if (pw) ptr = pw->pw_dir;
+ else {
+ ptr = NULL;
+ *buf = '\0';
+ }
+ }
+ }
+
+ if (ptr)
+ (void) strcpy(buf, ptr);
+
+ buf += strlen(buf);
+ *buf = '/';
+ buf++;
+ *buf = '\0';
+ return buf;
+}
+
+static void AllocateDock(ColorSelectionBoxWidget csb)
+{
+ int entry;
+
+ csb->csb.dock_cyan = (float *) XtCalloc(csb->csb.num_cells, sizeof(float));
+ csb->csb.dock_magenta =
+ (float *) XtCalloc(csb->csb.num_cells, sizeof(float));
+ csb->csb.dock_yellow =
+ (float *) XtCalloc(csb->csb.num_cells, sizeof(float));
+ csb->csb.dock_black =
+ (float *) XtCalloc(csb->csb.num_cells, sizeof(float));
+ csb->csb.dock_used =
+ (Boolean *) XtCalloc(csb->csb.num_cells, sizeof(Boolean));
+
+ for (entry = 0; entry < csb->csb.num_cells; entry++) {
+ csb->csb.dock_used[entry] = 0;
+ }
+}
+
+static void InitializeDock(ColorSelectionBoxWidget csb)
+{
+ String dockEnv;
+ char homeDir[PATH_BUF_SIZE];
+ FILE *dockFile = NULL;
+ char fileName[PATH_BUF_SIZE];
+#define BUF 256
+ char buf[BUF+1];
+ int entry;
+ float cyan, magenta, yellow, black;
+#define CHECK(v) ((v) > 1.0 ? 1.0 : ((v) < 0.0 ? 0.0 : (v)))
+
+ AllocateDock(csb);
+ csb->csb.dock_changed = False;
+
+ dockEnv = getenv("DPSCPICKRC");
+
+ if (dockEnv != NULL) dockFile = fopen(dockEnv, "r");
+
+ if (dockFile == NULL) {
+ (void) GetRootDirName(homeDir);
+
+ if (dockFile == NULL) {
+ sprintf(fileName, "%s/.dpscpickrc", homeDir);
+ dockFile = fopen(fileName, "r");
+
+ if (dockFile == NULL) return;
+ }
+ }
+
+ while (1) {
+ if (fgets(buf, BUF, dockFile) == NULL) {
+ fclose(dockFile);
+ return;
+ }
+ if (sscanf(buf, "%d %f %f %f %f",
+ &entry, &cyan, &magenta, &yellow, &black) == 5) {
+ if (entry <= csb->csb.num_cells) {
+ csb->csb.dock_cyan[entry] = CHECK(cyan);
+ csb->csb.dock_magenta[entry] = CHECK(magenta);
+ csb->csb.dock_yellow[entry] = CHECK(yellow);
+ csb->csb.dock_black[entry] = CHECK(black);
+ csb->csb.dock_used[entry] = True;
+ }
+ }
+ }
+
+#undef BUF
+#undef CHECK
+}
+
+static void SaveDockContents(ColorSelectionBoxWidget csb)
+{
+ String dockEnv;
+ char homeDir[PATH_BUF_SIZE];
+ FILE *dockFile = NULL;
+ char fileName[PATH_BUF_SIZE];
+ int i;
+
+ if (!csb->csb.dock_changed) return;
+
+ dockEnv = getenv("DPSCPICKRC");
+
+ if (dockEnv != NULL) dockFile = fopen(dockEnv, "w");
+
+ if (dockFile == NULL) {
+ (void) GetRootDirName(homeDir);
+
+ if (dockFile == NULL) {
+ sprintf(fileName, "%s/.dpscpickrc", homeDir);
+ dockFile = fopen(fileName, "w");
+
+ if (dockFile == NULL) return;
+ }
+ }
+
+ for (i = 0; i < csb->csb.num_cells; i++) {
+ if (!csb->csb.dock_used[i]) continue;
+ fprintf(dockFile, "%d %g %g %g %g\n", i, csb->csb.dock_cyan[i],
+ csb->csb.dock_magenta[i], csb->csb.dock_yellow[i],
+ csb->csb.dock_black[i]);
+ }
+ fclose(dockFile);
+ csb->csb.dock_changed = False;
+}
+
+/* ARGSUSED */
+
+static void DrawDockCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+
+ XClearArea(XtDisplay(csb), XtWindow(csb->csb.dock_child),
+ 0, 0, 1000, 1000, False);
+ DrawDock(csb);
+}
+
+static void DrawDock(ColorSelectionBoxWidget csb)
+{
+ Dimension height;
+ float w, h;
+ int lines;
+ int i, row, col;
+ Boolean didAny = False;
+
+ XtVaGetValues(csb->csb.dock_child, XtNheight, &height, NULL);
+
+ lines = height / csb->csb.cell_size;
+
+ if (csb->csb.dock_gstate == 0) {
+ XDPSSetContextGState(csb->csb.context, csb->csb.base_gstate);
+ XDPSSetContextDrawable(csb->csb.context,
+ XtWindow(csb->csb.dock_child), height);
+ (void) XDPSCaptureContextGState(csb->csb.context,
+ &csb->csb.dock_gstate);
+ } else XDPSSetContextGState(csb->csb.context, csb->csb.dock_gstate);
+
+ ToUserSpace(csb, csb->csb.cell_size, csb->csb.cell_size, &w, &h);
+
+ for (i = 0; i < csb->csb.num_cells; i++) {
+ if (!csb->csb.dock_used[i]) continue;
+ row = (lines - 1) - (i % lines);
+ col = i / lines;
+
+ DPSsetcmykcolor(csb->csb.context, csb->csb.dock_cyan[i],
+ csb->csb.dock_magenta[i], csb->csb.dock_yellow[i],
+ csb->csb.dock_black[i]);
+
+ DPSrectfill(csb->csb.context,
+ (float) (col * w), (float) (row * h), w, h);
+ didAny = True;
+ }
+ if (!didAny) _DPSCShowFillMe(csb->csb.context, csb->csb.fill_me);
+}
+
+static void StoreColorInDock(
+ ColorSelectionBoxWidget csb,
+ int x_offset,
+ int y_offset,
+ Dimension dockHeight)
+{
+ int i, lines, row, col;
+
+ lines = dockHeight / csb->csb.cell_size;
+
+ row = y_offset / (int) csb->csb.cell_size;
+ col = x_offset / (int) csb->csb.cell_size;
+ i = col * lines + row;
+
+ if (i >= csb->csb.num_cells) i = csb->csb.num_cells;
+ csb->csb.dock_cyan[i] = csb->csb.current_color.cyan;
+ csb->csb.dock_magenta[i] = csb->csb.current_color.magenta;
+ csb->csb.dock_yellow[i] = csb->csb.current_color.yellow;
+ csb->csb.dock_black[i] = csb->csb.current_color.black;
+ csb->csb.dock_used[i] = True;
+ csb->csb.dock_changed = True;
+ DrawDock(csb);
+}
+
+/* ARGSUSED */
+
+static void DockPress(
+ Widget w,
+ XtPointer data,
+ XEvent *event,
+ Boolean *goOn)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) data;
+ Dimension height;
+ int i, lines, row, col;
+
+ XtVaGetValues(csb->csb.dock_child, XtNheight, &height, NULL);
+
+ lines = height / csb->csb.cell_size;
+
+ row = event->xbutton.y / (int) csb->csb.cell_size;
+ col = event->xbutton.x / (int) csb->csb.cell_size;
+ i = col * lines + row;
+ if (i >= csb->csb.num_cells) i = csb->csb.num_cells;
+
+ if (!csb->csb.dock_used[i]) return;
+
+ csb->csb.current_color.cyan = csb->csb.dock_cyan[i];
+ csb->csb.current_color.magenta = csb->csb.dock_magenta[i];
+ csb->csb.current_color.yellow = csb->csb.dock_yellow[i];
+ csb->csb.current_color.black = csb->csb.dock_black[i];
+ UpdateColorSpaces(csb, CSBSpaceCMYK);
+ DoValueChangedCallback(csb);
+ FillPatch(csb);
+ SetSliders(csb);
+}
+
+static void InitializePalettes(ColorSelectionBoxWidget csb)
+{
+ int k;
+
+ for (k = 0; k < PALETTE_MAX; k++) {
+ if (csb->csb.palette_function[k] != NULL) {
+ DPSPrintf(csb->csb.context,
+ "/palette%dfunc%d { %s } bind def\n", k, (int) csb,
+ csb->csb.palette_function[k]);
+ }
+ csb->csb.palette_broken[k] = False;
+ }
+}
+
+static void InvalidatePalette(ColorSelectionBoxWidget csb)
+{
+ int len;
+ char *buf;
+ Widget w;
+ register int i = csb->csb.current_palette;
+
+ len = strlen(csb->csb.palette_label[i]) +
+ strlen(csb->csb.broken_palette_label) + 2;
+ len = MAX(len, 11);
+ buf = (char *) XtMalloc(len);
+
+ csb->csb.palette_broken[i] = True;
+ sprintf(buf, "*palette%d", csb->csb.current_palette);
+ w = XtNameToWidget((Widget) csb, buf);
+ if (w != NULL) XtSetSensitive(w, False);
+ sprintf(buf, "%s %s", csb->csb.palette_label[i],
+ csb->csb.broken_palette_label);
+ len = strlen(buf);
+ XtVaSetValues(w, XtVaTypedArg, XmNlabelString, XtRString, buf, len, NULL);
+}
+
+static void DoPalette(
+ ColorSelectionBoxWidget csb,
+ Dimension pixelWidth,
+ float w,
+ float h)
+{
+ char whichFunc[25];
+ int steps;
+ int success;
+
+ sprintf(whichFunc, "palette%dfunc%d", csb->csb.current_palette, (int) csb);
+ if (csb->csb.visual_class == TrueColor) steps = pixelWidth / 2;
+ else steps = pixelWidth / 4;
+
+ if (csb->csb.palette_color_dependent[csb->csb.current_palette]) {
+ switch (csb->csb.palette_space[csb->csb.current_palette]) {
+ case CSBSpaceRGB:
+ _DPSCDoRGBColorPalette(csb->csb.context, whichFunc,
+ csb->csb.current_color.red,
+ csb->csb.current_color.green,
+ csb->csb.current_color.blue,
+ w, h, steps, &success);
+ break;
+ case CSBSpaceCMYK:
+ _DPSCDoCMYKColorPalette(csb->csb.context, whichFunc,
+ csb->csb.current_color.cyan,
+ csb->csb.current_color.magenta,
+ csb->csb.current_color.yellow,
+ csb->csb.current_color.black,
+ w, h, steps, &success);
+ break;
+ case CSBSpaceHSB:
+ _DPSCDoHSBColorPalette(csb->csb.context, whichFunc,
+ csb->csb.current_color.hue,
+ csb->csb.current_color.saturation,
+ csb->csb.current_color.brightness,
+ w, h, steps, &success);
+ break;
+ case CSBSpaceGray:
+ _DPSCDoGrayColorPalette(csb->csb.context, whichFunc,
+ csb->csb.current_color.gray,
+ w, h, steps, &success);
+ break;
+ }
+ } else {
+ switch (csb->csb.palette_space[csb->csb.current_palette]) {
+ case CSBSpaceRGB:
+ _DPSCDoRGBPalette(csb->csb.context, whichFunc, w, h,
+ steps, &success);
+ break;
+ case CSBSpaceCMYK:
+ _DPSCDoCMYKPalette(csb->csb.context, whichFunc, w, h,
+ steps, &success);
+ break;
+ case CSBSpaceHSB:
+ _DPSCDoHSBPalette(csb->csb.context, whichFunc, w, h,
+ steps, &success);
+ break;
+ case CSBSpaceGray:
+ _DPSCDoGrayPalette(csb->csb.context, whichFunc, w, h,
+ steps, &success);
+ break;
+ }
+ }
+ if (!success) {
+ InvalidatePalette(csb);
+ _DPSCShowMessage(csb->csb.context, csb->csb.broken_palette_message);
+ }
+}
+
+static void DrawPalette(ColorSelectionBoxWidget csb)
+{
+ DrawPaletteCallback(csb->csb.palette_child,
+ (XtPointer) csb, (XtPointer) NULL);
+}
+
+/* ARGSUSED */
+
+static void DrawPaletteCallback(
+ Widget wid,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ Dimension width, height;
+ Pixmap palette_pixmap;
+ int depth;
+ float w, h;
+
+ if (csb->csb.palette_broken[csb->csb.current_palette]) return;
+ if (!csb->csb.palette_pixmap_valid) {
+ XtVaGetValues(csb->csb.palette_child,
+ XtNwidth, &width, XtNheight, &height,
+ XtNdepth, &depth, NULL);
+
+ ToUserSpace(csb, width, height, &w, &h);
+
+ palette_pixmap =
+ XCreatePixmap(XtDisplay(csb), XtWindow(csb->csb.palette_child),
+ width, height, depth);
+
+ XDPSSetContextGState(csb->csb.context, csb->csb.base_gstate);
+ XDPSSetContextDrawable(csb->csb.context, palette_pixmap, height);
+
+ DoPalette(csb, width, w, h);
+ csb->csb.palette_color = csb->csb.current_color;
+ DPSWaitContext(csb->csb.context);
+ XtVaSetValues(csb->csb.palette_child,
+ XtNbackgroundPixmap, palette_pixmap, NULL);
+ XFreePixmap(XtDisplay(csb), palette_pixmap);
+ csb->csb.palette_pixmap_valid = True;
+ }
+}
+
+/* ARGSUSED */
+
+static void PalettePress(
+ Widget w,
+ XtPointer data,
+ XEvent *event,
+ Boolean *goOn)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) data;
+ Dimension width;
+ float pct;
+ char whichFunc[25];
+ int success;
+ float f1, f2, f3, f4;
+
+ if (csb->csb.palette_broken[csb->csb.current_palette]) return;
+
+ sprintf(whichFunc, "palette%dfunc%d", csb->csb.current_palette, (int) csb);
+
+ XtVaGetValues(csb->csb.palette_child, XtNwidth, &width, NULL);
+
+ pct = ((float) event->xbutton.x) / ((float) width);
+
+ if (csb->csb.palette_color_dependent[csb->csb.current_palette]) {
+ switch (csb->csb.palette_space[csb->csb.current_palette]) {
+ case CSBSpaceRGB:
+ _DPSCQueryRGBColorPalette(csb->csb.context, whichFunc, pct,
+ csb->csb.palette_color.red,
+ csb->csb.palette_color.green,
+ csb->csb.palette_color.blue,
+ &f1, &f2, &f3, &success);
+ if (success) {
+ csb->csb.current_color.red = f1;
+ csb->csb.current_color.green = f2;
+ csb->csb.current_color.blue = f3;
+ }
+ break;
+ case CSBSpaceCMYK:
+ _DPSCQueryCMYKColorPalette(csb->csb.context, whichFunc, pct,
+ csb->csb.palette_color.cyan,
+ csb->csb.palette_color.magenta,
+ csb->csb.palette_color.yellow,
+ csb->csb.palette_color.black,
+ &f1, &f2, &f3, &f4, &success);
+ if (success) {
+ csb->csb.current_color.cyan = f1;
+ csb->csb.current_color.magenta = f2;
+ csb->csb.current_color.yellow = f3;
+ csb->csb.current_color.black = f4;
+ }
+ break;
+ case CSBSpaceHSB:
+ _DPSCQueryHSBColorPalette(csb->csb.context, whichFunc, pct,
+ csb->csb.palette_color.hue,
+ csb->csb.palette_color.saturation,
+ csb->csb.palette_color.brightness,
+ &f1, &f2, &f3, &success);
+ if (success) {
+ csb->csb.current_color.hue = f1;
+ csb->csb.current_color.saturation = f2;
+ csb->csb.current_color.brightness = f3;
+ }
+ break;
+ case CSBSpaceGray:
+ _DPSCQueryGrayColorPalette(csb->csb.context, whichFunc, pct,
+ csb->csb.palette_color.gray,
+ &f1, &success);
+ if (success) csb->csb.current_color.gray = f1;
+ break;
+ }
+ } else {
+ switch (csb->csb.palette_space[csb->csb.current_palette]) {
+ case CSBSpaceRGB:
+ _DPSCQueryRGBPalette(csb->csb.context, whichFunc, pct,
+ &f1, &f2, &f3, &success);
+ if (success) {
+ csb->csb.current_color.red = f1;
+ csb->csb.current_color.green = f2;
+ csb->csb.current_color.blue = f3;
+ }
+ break;
+ case CSBSpaceCMYK:
+ _DPSCQueryCMYKPalette(csb->csb.context, whichFunc, pct,
+ &f1, &f2, &f3, &f4, &success);
+ if (success) {
+ csb->csb.current_color.cyan = f1;
+ csb->csb.current_color.magenta = f2;
+ csb->csb.current_color.yellow = f3;
+ csb->csb.current_color.black = f4;
+ }
+ break;
+ case CSBSpaceHSB:
+ _DPSCQueryHSBPalette(csb->csb.context, whichFunc, pct,
+ &f1, &f2, &f3, &success);
+ if (success) {
+ csb->csb.current_color.hue = f1;
+ csb->csb.current_color.saturation = f2;
+ csb->csb.current_color.brightness = f3;
+ }
+ break;
+ case CSBSpaceGray:
+ _DPSCQueryGrayPalette(csb->csb.context, whichFunc, pct,
+ &f1, &success);
+ if (success) csb->csb.current_color.gray = f1;
+ break;
+ }
+ }
+ if (!success) InvalidatePalette(csb);
+ else {
+ UpdateColorSpaces(csb,
+ csb->csb.palette_space[csb->csb.current_palette]);
+ DoValueChangedCallback(csb);
+ FillPatch(csb);
+ SetSliders(csb);
+ }
+}
+
+/* ARGSUSED */
+
+static void DoEyedropCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) clientData;
+ Pixmap eyedropBitmap, eyedropMaskBitmap;
+ XColor black, fg;
+ Display *dpy;
+ unsigned int x, y;
+ XEvent ev;
+
+ dpy = XtDisplay(w);
+
+ black.red = 0;
+ black.green = 0;
+ black.blue = 0;
+
+ fg.red = 65535;
+ fg.green = 65535;
+ fg.blue = 65535;
+
+ if (csb->csb.eyedrop == None) {
+ XQueryBestCursor(dpy, XtWindow(w), 32, 32,
+ &x, &y);
+
+ if (x >= 32 && y >= 32) {
+ eyedropBitmap =
+ XCreateBitmapFromData(dpy, XtWindow(w),
+ (char *) eyedrop32_bits,
+ eyedrop32_width, eyedrop32_height);
+
+ eyedropMaskBitmap =
+ XCreateBitmapFromData(dpy, XtWindow(w),
+ (char *) eyedropmask32_bits,
+ eyedropmask32_width,
+ eyedropmask32_height);
+
+ csb->csb.eyedrop =
+ XCreatePixmapCursor(dpy, eyedropBitmap,
+ eyedropMaskBitmap,
+ &fg, &black,
+ eyedrop32_x_hot, eyedrop32_y_hot);
+ } else {
+ eyedropBitmap =
+ XCreateBitmapFromData(dpy, XtWindow(w),
+ (char *) eyedrop16_bits,
+ eyedrop16_width, eyedrop16_height);
+
+ eyedropMaskBitmap =
+ XCreateBitmapFromData(dpy, XtWindow(w),
+ (char *) eyedropmask16_bits,
+ eyedropmask16_width,
+ eyedropmask16_height);
+
+ csb->csb.eyedrop =
+ XCreatePixmapCursor(dpy, eyedropBitmap,
+ eyedropMaskBitmap,
+ &fg, &black,
+ eyedrop16_x_hot, eyedrop16_y_hot);
+ }
+ } else {
+ XRecolorCursor(dpy, csb->csb.eyedrop, &fg, &black);
+ }
+
+ (void) XtGrabPointer(w, False,
+ PointerMotionMask | PointerMotionHintMask |
+ ButtonReleaseMask,
+ GrabModeAsync, GrabModeAsync,
+ None, csb->csb.eyedrop,
+ XtLastTimestampProcessed(dpy));
+ csb->csb.eyedrop_grabbed = True;
+
+ ev.type = 0;
+ EyedropPointer(w, (XtPointer) csb, &ev, (Boolean *) NULL);
+}
+
+/* ARGSUSED */
+
+static void EyedropPointer(
+ Widget w,
+ XtPointer data,
+ XEvent *event,
+ Boolean *goOn)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) data;
+ XColor fg, black;
+ Window root, child, stop, old_child = None;
+ int root_x, root_y, x, y;
+ unsigned int mask;
+ XWindowAttributes att;
+ XImage *image;
+ Pixel pixel;
+ Colormap colormap = 0;
+ Display *dpy = XtDisplay(w);
+
+ if (!csb->csb.eyedrop_grabbed) return;
+
+ if (event->type == ButtonPress || event->type == ButtonRelease) {
+ root = event->xbutton.root;
+ root_x = event->xbutton.x_root;
+ root_y = event->xbutton.y_root;
+
+ XTranslateCoordinates(dpy, root, root, root_x, root_y, &x, &y, &child);
+
+ } else {
+ XQueryPointer(dpy, RootWindowOfScreen(XtScreen(w)),
+ &root, &child, &root_x, &root_y, &x, &y, &mask);
+ }
+
+ if (child == None) child = root;
+ else {
+ stop = child;
+
+ while (stop != None) {
+ XTranslateCoordinates(dpy, root, stop, x, y, &x, &y, &child);
+ root = stop;
+ if (child != None && XGetWindowAttributes(dpy, child, &att) &&
+ att.class != InputOutput) break;
+ stop = child;
+ }
+ child = root;
+ }
+
+ if (child != old_child) {
+ XGetWindowAttributes(dpy, child, &att);
+ colormap = att.colormap;
+ old_child = child;
+ }
+
+ image = XGetImage(dpy, child, x, y, 1, 1, AllPlanes, XYPixmap);
+
+ pixel = XGetPixel(image, 0, 0);
+
+ XDestroyImage(image);
+ fg.pixel = pixel;
+ XQueryColors(dpy, colormap, &fg, 1);
+
+ black.red = 0;
+ black.green = 0;
+ black.blue = 0;
+
+ XRecolorCursor(dpy, csb->csb.eyedrop, &fg, &black);
+
+ if (event->type == ButtonRelease) {
+ XtUngrabPointer(w, XtLastTimestampProcessed(dpy));
+ csb->csb.eyedrop_grabbed = False;
+
+ csb->csb.current_color.red = (float) fg.red / 65535.0;
+ csb->csb.current_color.green = (float) fg.green / 65535.0;
+ csb->csb.current_color.blue = (float) fg.blue / 65535.0;
+ UpdateColorSpaces(csb, CSBSpaceRGB);
+ DoValueChangedCallback(csb);
+ FillPatch(csb);
+ SetSliders(csb);
+ }
+}
+
+/* ARGSUSED */
+
+static void PatchPress(
+ Widget w,
+ XtPointer data,
+ XEvent *event,
+ Boolean *goOn)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) data;
+ Pixmap squareBitmap, squareMaskBitmap;
+ XColor black, fg;
+ Display *dpy;
+
+ dpy = XtDisplay(w);
+
+ black.red = 0;
+ black.green = 0;
+ black.blue = 0;
+
+ fg.red = TO_X(csb->csb.current_color.red);
+ fg.green = TO_X(csb->csb.current_color.green);
+ fg.blue = TO_X(csb->csb.current_color.blue);
+
+ if (csb->csb.square == None) {
+ squareBitmap =
+ XCreateBitmapFromData(dpy, XtWindow(w), (char *) square_bits,
+ square_width, square_height);
+
+ squareMaskBitmap =
+ XCreateBitmapFromData(dpy, XtWindow(w),
+ (char *) squaremask_bits,
+ squaremask_width, squaremask_height);
+
+ csb->csb.square =
+ XCreatePixmapCursor(dpy, squareBitmap, squareMaskBitmap,
+ &fg, &black, square_x_hot, square_y_hot);
+ } else {
+ XRecolorCursor(dpy, csb->csb.square, &fg, &black);
+ }
+
+ (void) XtGrabPointer(w, False, ButtonReleaseMask,
+ GrabModeAsync, GrabModeAsync,
+ None, csb->csb.square, XtLastTimestampProcessed(dpy));
+}
+
+/* ARGSUSED */
+
+static void PatchRelease(
+ Widget w,
+ XtPointer data,
+ XEvent *event,
+ Boolean *goOn)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) data;
+ Dimension width, height;
+ Position left, top;
+
+ XtUngrabPointer(w, XtLastTimestampProcessed(XtDisplay(w)));
+ XFlush(XtDisplay(w));
+
+ XtVaGetValues(csb->csb.dock_child, XtNwidth, &width,
+ XtNheight, &height, NULL);
+
+ XtTranslateCoords(csb->csb.dock_child, (Position) 0, (Position) 0,
+ &left, &top);
+
+ if ((int) event->xbutton.x_root >= left &&
+ (int) event->xbutton.x_root <= left + (int) width &&
+ (int) event->xbutton.y_root >= top &&
+ (int) event->xbutton.y_root <= top + (int) height) {
+ StoreColorInDock(csb, event->xbutton.x_root - left,
+ event->xbutton.y_root - top, height);
+ }
+}
+
+static void GetVisualInfo(
+ ColorSelectionBoxWidget csb,
+ Visual **visual)
+{
+ Widget w = (Widget) csb;
+ XVisualInfo *vip, viproto;
+ int n;
+ XWindowAttributes xwa;
+
+ XGetWindowAttributes(XtDisplay(w), XtWindow(w), &xwa);
+
+ *visual = viproto.visual = xwa.visual;
+ viproto.visualid = XVisualIDFromVisual(xwa.visual);
+ vip = XGetVisualInfo(XtDisplay(w), VisualIDMask, &viproto, &n);
+
+ if (n != 1) {
+ csb->csb.static_visual = False; /* Actually we have no idea, but... */
+ csb->csb.visual_class = PseudoColor;
+ } else {
+ csb->csb.visual_class = vip->class;
+ csb->csb.static_visual = (vip->class == StaticGray ||
+ vip->class == TrueColor ||
+ vip->class == StaticColor);
+ }
+
+ if (n > 0) XFree((char *) vip);
+}
+
+static void SetBackground(ColorSelectionBoxWidget csb)
+{
+ Colormap c;
+ XColor xc;
+ int status;
+ unsigned long pix;
+ unsigned long mask;
+
+ XtVaGetValues(csb->csb.patch_child, XtNcolormap, (XtPointer) &c, NULL);
+
+ if (csb->csb.current_space == CSBSpaceGray) {
+ xc.red = xc.green = xc.blue = TO_X(csb->csb.current_color.gray);
+ } else {
+ xc.red = TO_X(csb->csb.current_color.red);
+ xc.green = TO_X(csb->csb.current_color.green);
+ xc.blue = TO_X(csb->csb.current_color.blue);
+ }
+
+ if (csb->csb.static_visual) {
+ status = XAllocColor(XtDisplay(csb), c, &xc);
+ if (status == 0) NoBackgroundPixel(csb);
+ else {
+ csb->csb.background = xc.pixel;
+ XtVaSetValues(csb->csb.patch_child,
+ XtNbackground, csb->csb.background, NULL);
+ }
+
+ } else {
+ if (csb->csb.visual_class == DirectColor) {
+ status = XAllocColorPlanes(XtDisplay(csb), c,
+ False, &pix, 1, 0, 0, 0,
+ &mask, &mask, &mask);
+ } else {
+ status = XAllocColorCells(XtDisplay(csb), c,
+ False, (unsigned long *) NULL, 0,
+ &pix, 1);
+ }
+
+ if (status == 0) NoBackgroundPixel(csb);
+ else {
+ xc.pixel = pix;
+ xc.flags = DoRed | DoGreen | DoBlue;
+ XStoreColor(XtDisplay(csb), c, &xc);
+
+ csb->csb.background = xc.pixel;
+ XtVaSetValues(csb->csb.patch_child,
+ XtNbackground, csb->csb.background, NULL);
+ }
+ }
+}
+
+/* ARGSUSED */
+
+static void Initialize(
+ Widget request, Widget new,
+ ArgList args,
+ Cardinal *num_args)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) new;
+ Bool inited;
+ int i;
+
+ if (csb->csb.rgb_labels != NULL) {
+ csb->csb.rgb_labels = XtNewString(csb->csb.rgb_labels);
+ }
+ if (csb->csb.cmyk_labels != NULL) {
+ csb->csb.cmyk_labels = XtNewString(csb->csb.cmyk_labels);
+ }
+ if (csb->csb.hsb_labels != NULL) {
+ csb->csb.hsb_labels = XtNewString(csb->csb.hsb_labels);
+ }
+ if (csb->csb.gray_labels != NULL) {
+ csb->csb.gray_labels = XtNewString(csb->csb.gray_labels);
+ }
+ if (csb->csb.fill_me != NULL) {
+ csb->csb.fill_me = XtNewString(csb->csb.fill_me);
+ }
+ if (csb->csb.broken_palette_label != NULL) {
+ csb->csb.broken_palette_label =
+ XtNewString(csb->csb.broken_palette_label);
+ }
+ if (csb->csb.broken_palette_message != NULL) {
+ csb->csb.broken_palette_message =
+ XtNewString(csb->csb.broken_palette_message);
+ }
+
+ for (i = 0; i < PALETTE_MAX; i++) {
+ if (csb->csb.palette_function[i] != NULL) {
+ csb->csb.palette_function[i] =
+ XtNewString(csb->csb.palette_function[i]);
+ }
+ }
+
+ if (csb->csb.num_cells <= 0) csb->csb.num_cells = 1;
+
+ /* Get the context */
+
+ if (csb->csb.context == NULL) {
+ csb->csb.context = XDPSGetSharedContext(XtDisplay(csb));
+ }
+
+ if (_XDPSTestComponentInitialized(csb->csb.context,
+ dps_init_bit_csb, &inited) ==
+ dps_status_unregistered_context) {
+ XDPSRegisterContext(csb->csb.context, False);
+ }
+
+ if (!inited) {
+ (void) _XDPSSetComponentInitialized(csb->csb.context,
+ dps_init_bit_csb);
+ InitializePalettes(csb);
+ }
+
+ if (csb->csb.current_palette < 0 ||
+ csb->csb.current_palette > PALETTE_MAX ||
+ csb->csb.palette_function[csb->csb.current_palette] == NULL) {
+ csb->csb.current_palette = 0;
+ }
+
+ /* Initialize non-resource fields */
+
+ CreateChildren(csb);
+ csb->csb.no_background = False;
+ csb->csb.patch_gstate = csb->csb.dock_gstate = 0;
+ csb->csb.red_pixmap = csb->csb.green_pixmap = csb->csb.blue_pixmap =
+ csb->csb.cyan_pixmap = csb->csb.magenta_pixmap =
+ csb->csb.yellow_pixmap = csb->csb.black_pixmap =
+ csb->csb.hue_pixmap = csb->csb.sat_pixmap =
+ csb->csb.bright_pixmap = csb->csb.gray_pixmap = None;
+
+ csb->csb.square = csb->csb.eyedrop = None;
+ csb->csb.eyedrop_grabbed = False;
+
+ for (i = 0; i < PALETTE_MAX; i++) csb->csb.palette_broken[i] = False;
+ csb->csb.palette_pixmap_valid = False;
+
+ csb->csb.current_color.hue = 0.0;
+ csb->csb.current_color.saturation = 1.0;
+ csb->csb.current_color.brightness = 1.0;
+ UpdateColorSpaces(csb, CSBSpaceHSB);
+ csb->csb.save_color = csb->csb.current_color;
+ SetSliders(csb);
+
+ InitializeDock(csb);
+ SetColorSpace(csb);
+ SetRendering(csb);
+}
+
+static void Destroy(Widget widget)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) widget;
+ Display *dpy = XtDisplay(csb);
+ int i;
+
+ /* Lots of stuff to destroy! */
+
+ if (csb->csb.patch_gstate != 0) {
+ XDPSFreeContextGState(csb->csb.context, csb->csb.patch_gstate);
+ }
+ if (csb->csb.dock_gstate != 0) {
+ XDPSFreeContextGState(csb->csb.context, csb->csb.dock_gstate);
+ }
+ if (csb->csb.base_gstate != 0) {
+ XDPSFreeContextGState(csb->csb.context, csb->csb.base_gstate);
+ }
+
+ if (csb->csb.rgb_labels != NULL) XtFree(csb->csb.rgb_labels);
+ if (csb->csb.cmyk_labels != NULL) XtFree(csb->csb.cmyk_labels);
+ if (csb->csb.hsb_labels != NULL) XtFree(csb->csb.hsb_labels);
+ if (csb->csb.gray_labels != NULL) XtFree(csb->csb.gray_labels);
+ if (csb->csb.fill_me != NULL) XtFree(csb->csb.fill_me);
+ if (csb->csb.broken_palette_message != NULL) {
+ XtFree(csb->csb.broken_palette_message);
+ }
+ if (csb->csb.broken_palette_label != NULL) {
+ XtFree(csb->csb.broken_palette_label);
+ }
+
+ XtFree((XtPointer) csb->csb.dock_cyan);
+ XtFree((XtPointer) csb->csb.dock_magenta);
+ XtFree((XtPointer) csb->csb.dock_yellow);
+ XtFree((XtPointer) csb->csb.dock_black);
+ XtFree((XtPointer) csb->csb.dock_used);
+
+ for (i = 0; i < PALETTE_MAX; i++) {
+ if (csb->csb.palette_function[i] != NULL) {
+ XtFree(csb->csb.palette_function[i]);
+ }
+ }
+
+ if (csb->csb.eyedrop != None) XFreeCursor(dpy, csb->csb.eyedrop);
+ if (csb->csb.square != None) XFreeCursor(dpy, csb->csb.square);
+
+ if (csb->csb.red_pixmap != None) XFreePixmap(dpy, csb->csb.red_pixmap);
+ if (csb->csb.green_pixmap != None) XFreePixmap(dpy, csb->csb.green_pixmap);
+ if (csb->csb.blue_pixmap != None) XFreePixmap(dpy, csb->csb.blue_pixmap);
+ if (csb->csb.cyan_pixmap != None) XFreePixmap(dpy, csb->csb.cyan_pixmap);
+ if (csb->csb.magenta_pixmap != None)
+ XFreePixmap(dpy, csb->csb.magenta_pixmap);
+ if (csb->csb.yellow_pixmap != None)
+ XFreePixmap(dpy, csb->csb.yellow_pixmap);
+ if (csb->csb.black_pixmap != None) XFreePixmap(dpy, csb->csb.black_pixmap);
+ if (csb->csb.hue_pixmap != None) XFreePixmap(dpy, csb->csb.hue_pixmap);
+ if (csb->csb.sat_pixmap != None) XFreePixmap(dpy, csb->csb.sat_pixmap);
+ if (csb->csb.bright_pixmap != None)
+ XFreePixmap(dpy, csb->csb.bright_pixmap);
+ if (csb->csb.gray_pixmap != None) XFreePixmap(dpy, csb->csb.gray_pixmap);
+}
+
+static void ChangeManaged(Widget w)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) w;
+
+ w->core.width = csb->composite.children[0]->core.width;
+ w->core.height = csb->composite.children[0]->core.height;
+}
+
+/* ARGSUSED */
+
+static XtGeometryResult GeometryManager(
+ Widget w,
+ XtWidgetGeometry *desired, XtWidgetGeometry *allowed)
+{
+#define WANTS(flag) (desired->request_mode & flag)
+
+ if (WANTS(XtCWQueryOnly)) return XtGeometryYes;
+
+ if (WANTS(CWWidth)) w->core.width = desired->width;
+ if (WANTS(CWHeight)) w->core.height = desired->height;
+ if (WANTS(CWX)) w->core.x = desired->x;
+ if (WANTS(CWY)) w->core.y = desired->y;
+ if (WANTS(CWBorderWidth)) {
+ w->core.border_width = desired->border_width;
+ }
+
+ return XtGeometryYes;
+#undef WANTS
+}
+
+static void SetColorSpace(ColorSelectionBoxWidget csb)
+{
+ switch(csb->csb.current_space) {
+ case CSBSpaceRGB:
+ SetRGBCallback((Widget) csb, (XtPointer) csb, (XtPointer) NULL);
+ break;
+
+ case CSBSpaceCMYK:
+ SetCMYKCallback((Widget) csb, (XtPointer) csb, (XtPointer) NULL);
+ break;
+
+ case CSBSpaceHSB:
+ SetHSBCallback((Widget) csb, (XtPointer) csb, (XtPointer) NULL);
+ break;
+
+ case CSBSpaceGray:
+ SetGrayCallback((Widget) csb, (XtPointer) csb, (XtPointer) NULL);
+ break;
+ }
+}
+
+static void SetRendering(ColorSelectionBoxWidget csb)
+{
+ Widget w;
+
+ switch(csb->csb.current_rendering) {
+ default:
+ case CSBDisplayDPS:
+ w = XtNameToWidget((Widget) csb, "*displayDPS");
+ break;
+ case CSBDisplayX:
+ w = XtNameToWidget((Widget) csb, "*displayX");
+ break;
+ case CSBDisplayBoth:
+ w = XtNameToWidget((Widget) csb, "*displayBoth");
+ break;
+ }
+ XtVaSetValues(csb->csb.display_option_menu_child, XmNmenuHistory, w, NULL);
+ if (XtIsRealized(csb->csb.patch_child)) {
+ XClearArea(XtDisplay(csb), XtWindow(csb->csb.patch_child),
+ 0, 0, 1000, 1000, True);
+ }
+}
+
+static void SetPalette(ColorSelectionBoxWidget csb)
+{
+ Widget w;
+ char buf[10];
+
+ sprintf(buf, "*palette%d", csb->csb.current_palette);
+ w = XtNameToWidget((Widget) csb, buf);
+
+ XtVaSetValues(csb->csb.palette_option_menu_child, XmNmenuHistory, w, NULL);
+
+ csb->csb.palette_pixmap_valid = False;
+ DrawPalette(csb);
+}
+
+static void SetBaseGState(
+ ColorSelectionBoxWidget csb,
+ Visual *visual)
+{
+ XStandardColormap colorCube, grayRamp;
+ int match;
+
+ /* If the context's colormap matches the widget's colormap, assume that
+ everything is already set up right in the color cube department. This
+ allows an application to supply us with a custom color cube by
+ installing it in the context before calling us */
+
+ _DPSCColormapMatch(csb->csb.context, csb->core.colormap, &match);
+
+ if (match) {
+ XDPSSetContextParameters(csb->csb.context, XtScreen(csb),
+ csb->core.depth, XtWindow(csb),
+ csb->core.height, NULL, NULL,
+ XDPSContextScreenDepth | XDPSContextDrawable);
+ } else {
+ grayRamp.colormap = colorCube.colormap = csb->core.colormap;
+
+ XDPSCreateStandardColormaps(XtDisplay(csb), XtWindow(csb), visual,
+ 0, 0, 0, 0, &colorCube, &grayRamp, False);
+
+ XDPSSetContextParameters(csb->csb.context, XtScreen(csb),
+ csb->core.depth, XtWindow(csb),
+ csb->core.height,
+ (XDPSStandardColormap *) &colorCube,
+ (XDPSStandardColormap *) &grayRamp,
+ XDPSContextScreenDepth | XDPSContextDrawable |
+ XDPSContextRGBMap | XDPSContextGrayMap);
+ }
+
+ XDPSCaptureContextGState(csb->csb.context, &csb->csb.base_gstate);
+}
+
+/* ARGSUSED */
+
+static Boolean SetValues(
+ Widget old, Widget req, Widget new,
+ ArgList args,
+ Cardinal *num_args)
+{
+ ColorSelectionBoxWidget oldcsb = (ColorSelectionBoxWidget) old;
+ ColorSelectionBoxWidget newcsb = (ColorSelectionBoxWidget) new;
+ Bool inited;
+ char buf[10];
+ Widget w = 0;
+ int i;
+
+#define NE(field) newcsb->csb.field != oldcsb->csb.field
+
+ if (NE(rgb_labels)) {
+ XtFree(oldcsb->csb.rgb_labels);
+ newcsb->csb.rgb_labels = XtNewString(newcsb->csb.rgb_labels);
+ }
+ if (NE(cmyk_labels)) {
+ XtFree(oldcsb->csb.cmyk_labels);
+ newcsb->csb.cmyk_labels = XtNewString(newcsb->csb.cmyk_labels);
+ }
+ if (NE(hsb_labels)) {
+ XtFree(oldcsb->csb.hsb_labels);
+ newcsb->csb.hsb_labels = XtNewString(newcsb->csb.hsb_labels);
+ }
+ if (NE(gray_labels)) {
+ XtFree(oldcsb->csb.gray_labels);
+ newcsb->csb.gray_labels = XtNewString(newcsb->csb.gray_labels);
+ }
+
+ if (NE(context)) {
+ if (newcsb->csb.context == NULL) {
+ newcsb->csb.context = XDPSGetSharedContext(XtDisplay(newcsb));
+ }
+ if (_XDPSTestComponentInitialized(newcsb->csb.context,
+ dps_init_bit_csb, &inited) ==
+ dps_status_unregistered_context) {
+ XDPSRegisterContext(newcsb->csb.context, False);
+ }
+ if (!inited) {
+ (void) _XDPSSetComponentInitialized(newcsb->csb.context,
+ dps_init_bit_csb);
+ InitializePalettes(newcsb);
+ }
+ newcsb->csb.patch_gstate = newcsb->csb.dock_gstate = 0;
+ XDPSFreeContextGState(newcsb->csb.context, newcsb->csb.patch_gstate);
+ XDPSFreeContextGState(newcsb->csb.context, newcsb->csb.dock_gstate);
+ if (XtIsRealized(newcsb)) {
+ XWindowAttributes xwa;
+
+ XGetWindowAttributes(XtDisplay(newcsb), XtWindow(newcsb), &xwa);
+ SetBaseGState(newcsb, xwa.visual);
+ }
+ }
+
+ if (NE(fill_me)) {
+ XtFree(oldcsb->csb.fill_me);
+ newcsb->csb.fill_me = XtNewString(newcsb->csb.fill_me);
+ }
+
+ if (NE(broken_palette_label)) {
+ XtFree(oldcsb->csb.broken_palette_label);
+ newcsb->csb.broken_palette_label =
+ XtNewString(newcsb->csb.broken_palette_label);
+ }
+
+ if (NE(broken_palette_message)) {
+ XtFree(oldcsb->csb.broken_palette_message);
+ newcsb->csb.broken_palette_message =
+ XtNewString(newcsb->csb.broken_palette_message);
+ }
+
+ if (newcsb->csb.num_cells <= 0) newcsb->csb.num_cells = 1;
+ if (NE(num_cells)) {
+ int i, min;
+
+ AllocateDock(newcsb);
+ min = MIN(newcsb->csb.num_cells, oldcsb->csb.num_cells);
+ for (i = 0; i < min; i++) {
+ newcsb->csb.dock_cyan[i] = oldcsb->csb.dock_cyan[i];
+ newcsb->csb.dock_magenta[i] = oldcsb->csb.dock_magenta[i];
+ newcsb->csb.dock_yellow[i] = oldcsb->csb.dock_yellow[i];
+ newcsb->csb.dock_black[i] = oldcsb->csb.dock_black[i];
+ newcsb->csb.dock_used[i] = oldcsb->csb.dock_used[i];
+ }
+ XtFree((XtPointer) oldcsb->csb.dock_cyan);
+ XtFree((XtPointer) oldcsb->csb.dock_magenta);
+ XtFree((XtPointer) oldcsb->csb.dock_yellow);
+ XtFree((XtPointer) oldcsb->csb.dock_black);
+ XtFree((XtPointer) oldcsb->csb.dock_used);
+ }
+
+ for (i = 0; i < PALETTE_MAX; i++) {
+ if (NE(palette_function[i]) || NE(palette_label[i])) {
+ sprintf(buf, "*palette%d", i);
+ w = XtNameToWidget((Widget) newcsb, buf);
+ }
+ if (NE(palette_function[i])) {
+ if (newcsb->csb.palette_function[i] != NULL) {
+ DPSPrintf(newcsb->csb.context,
+ "/palette%dfunc%d { %s } bind def\n", i,
+ (int) newcsb, newcsb->csb.palette_function[i]);
+ /* Assume the best... */
+ newcsb->csb.palette_broken[i] = False;
+ XtManageChild(w);
+ } else {
+ XtUnmanageChild(w);
+ if (newcsb->csb.current_palette == i) {
+ newcsb->csb.current_palette = -1;
+ }
+ }
+ }
+ if (NE(palette_label[i]) || NE(palette_function[i])) {
+ XtSetSensitive(w, True);
+ XtVaSetValues(w, XtVaTypedArg, XmNlabelString, XtRString,
+ newcsb->csb.palette_label[i],
+ strlen(newcsb->csb.palette_label[i])+1, NULL);
+ }
+ }
+
+ if (NE(current_palette)) {
+ if (newcsb->csb.current_palette < 0 ||
+ newcsb->csb.current_palette > PALETTE_MAX ||
+ newcsb->csb.palette_function[newcsb->csb.current_palette] == NULL ||
+ newcsb->csb.palette_broken[newcsb->csb.current_palette]) {
+ newcsb->csb.current_palette = 0;
+ }
+ }
+ if (NE(current_palette) ||
+ NE(palette_function[newcsb->csb.current_palette])) SetPalette(newcsb);
+
+ if ((NE(cell_size) || NE(fill_me)) &&
+ XtIsRealized(newcsb->csb.dock_child)) {
+ XClearArea(XtDisplay(newcsb), XtWindow(newcsb->csb.dock_child),
+ 0, 0, 1000, 1000, True);
+ }
+
+ if (NE(current_space)) SetColorSpace(newcsb);
+ if (NE(current_rendering)) SetRendering(newcsb);
+
+ return False;
+#undef NE
+}
+
+static void Realize(
+ Widget w,
+ XtValueMask *mask,
+ XSetWindowAttributes *attr)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) w;
+ Visual *v;
+
+ (*colorSelectionBoxClassRec.core_class.superclass->core_class.realize)
+ (w, mask, attr);
+
+ GetVisualInfo(csb, &v);
+ SetBackground(csb);
+ SetBaseGState(csb, v);
+ _DPSCGetInvCTM(csb->csb.context, csb->csb.itransform);
+}
+
+static void Resize(Widget widget)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) widget;
+
+ XtResizeWidget(csb->csb.form_child, csb->core.width, csb->core.height, 0);
+}
+
+static Boolean SetColor(
+ Widget w,
+ CSBColorSpace space,
+ double c1, double c2, double c3, double c4,
+ Bool setSpace)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) w;
+#define CHECK(c) if ((c) > 1.0 || (c) < 0.0) return False;
+
+ CHECK(c1);
+ switch (space) {
+ case CSBSpaceRGB:
+ CHECK(c2);
+ CHECK(c3);
+ csb->csb.current_color.red = c1;
+ csb->csb.current_color.green = c2;
+ csb->csb.current_color.blue = c3;
+ break;
+ case CSBSpaceCMYK:
+ CHECK(c2);
+ CHECK(c3);
+ CHECK(c4);
+ csb->csb.current_color.cyan = c1;
+ csb->csb.current_color.magenta = c2;
+ csb->csb.current_color.yellow = c3;
+ csb->csb.current_color.black = c4;
+ break;
+ case CSBSpaceHSB:
+ CHECK(c2);
+ CHECK(c3);
+ csb->csb.current_color.hue = c1;
+ csb->csb.current_color.saturation = c2;
+ csb->csb.current_color.brightness = c3;
+ break;
+ case CSBSpaceGray:
+ csb->csb.current_color.gray = c1;
+ break;
+ }
+ UpdateColorSpaces(csb, space);
+ csb->csb.save_color = csb->csb.current_color;
+ DoValueChangedCallback(csb);
+ FillPatch(csb);
+ SetSliders(csb);
+ if (setSpace) XtVaSetValues(w, XtNcurrentSpace, space, NULL);
+ return True;
+#undef CHECK
+}
+
+Boolean CSBSetColor(
+ Widget w,
+ CSBColorSpace space,
+ double c1, double c2, double c3, double c4,
+ Bool setSpace)
+{
+ XtCheckSubclass(w, colorSelectionBoxWidgetClass, NULL);
+
+ return (*((ColorSelectionBoxWidgetClass) XtClass(w))->
+ csb_class.set_color) (w, space, c1, c2, c3, c4, setSpace);
+}
+
+static void GetColor(
+ Widget w,
+ CSBColorSpace space,
+ float *c1, float *c2, float *c3, float *c4)
+{
+ ColorSelectionBoxWidget csb = (ColorSelectionBoxWidget) w;
+
+ switch (space) {
+ case CSBSpaceRGB:
+ *c1 = csb->csb.current_color.red;
+ *c2 = csb->csb.current_color.green;
+ *c3 = csb->csb.current_color.blue;
+ break;
+ case CSBSpaceCMYK:
+ *c1 = csb->csb.current_color.cyan;
+ *c2 = csb->csb.current_color.magenta;
+ *c3 = csb->csb.current_color.yellow;
+ *c4 = csb->csb.current_color.black;
+ break;
+ case CSBSpaceHSB:
+ *c1 = csb->csb.current_color.hue;
+ *c2 = csb->csb.current_color.saturation;
+ *c3 = csb->csb.current_color.brightness;
+ break;
+ case CSBSpaceGray:
+ *c1 = csb->csb.current_color.gray;
+ break;
+ }
+}
+
+void CSBGetColor(
+ Widget w,
+ CSBColorSpace space,
+ float *c1, float *c2, float *c3, float *c4)
+{
+ XtCheckSubclass(w, colorSelectionBoxWidgetClass, NULL);
+
+ (*((ColorSelectionBoxWidgetClass) XtClass(w))->
+ csb_class.get_color) (w, space, c1, c2, c3, c4);
+}
diff --git a/nx-X11/lib/dpstk/ColorSelect.ad b/nx-X11/lib/dpstk/ColorSelect.ad
new file mode 100644
index 000000000..8c3baa8c6
--- /dev/null
+++ b/nx-X11/lib/dpstk/ColorSelect.ad
@@ -0,0 +1,162 @@
+! ColorSelect
+!
+! (c) Copyright 1991-1994 Adobe Systems Incorporated.
+! All rights reserved.
+!
+! Permission to use, copy, modify, distribute, and sublicense this software
+! and its documentation for any purpose and without fee is hereby granted,
+! provided that the above copyright notices appear in all copies and that
+! both those copyright notices and this permission notice appear in
+! supporting documentation and that the name of Adobe Systems Incorporated
+! not be used in advertising or publicity pertaining to distribution of the
+! software without specific, written prior permission. No trademark license
+! to use the Adobe trademarks is hereby granted. If the Adobe trademark
+! "Display PostScript"(tm) is used to describe this software, its
+! functionality or for any other purpose, such use shall be limited to a
+! statement that this software works in conjunction with the Display
+! PostScript system. Proper trademark attribution to reflect Adobe's
+! ownership of the trademark shall be given whenever any such reference to
+! the Display PostScript system is made.
+!
+! ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+! ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+! ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+! IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+! NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+! TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+! DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+! NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+! CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+! PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+!
+! Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+! Incorporated which may be registered in certain jurisdictions
+!
+! Author: Adobe Systems Incorporated
+!
+! Resource file for Color Picker
+!
+! This resource file must be merged into the resource file for
+! any application that uses the Color Picker
+!
+!
+*ColorSelectionBox*fontList: -adobe-helvetica-bold-r-normal--*-120-*-*-*-*-iso8859-1
+*ColorSelectionBox*XmPushButton.marginLeft: 5
+*ColorSelectionBox*XmPushButton.marginRight: 5
+*ColorSelectionBox*XmScale.orientation: horizontal
+*ColorSelectionBox*XmScale.highlightThickness: 0
+
+*ColorSelectionBox*panel.width: 350
+*ColorSelectionBox*panel.height: 250
+
+*ColorSelectionBox*panel.horizontalSpacing: 5
+*ColorSelectionBox*panel.verticalSpacing: 5
+*ColorSelectionBox*panel.shadowThickness: 0
+
+*ColorSelectionBox*okButton.labelString: OK
+*ColorSelectionBox*applyButton.labelString: Apply
+*ColorSelectionBox*resetButton.labelString: Reset
+*ColorSelectionBox*cancelButton.labelString: Cancel
+
+*ColorSelectionBox*XmScale.topOffset: 8
+*ColorSelectionBox*slider2.leftOffset: 0
+*ColorSelectionBox*slider2.rightOffset: 0
+*ColorSelectionBox*slider3.leftOffset: 0
+*ColorSelectionBox*slider3.rightOffset: 0
+*ColorSelectionBox*slider4.leftOffset: 0
+*ColorSelectionBox*slider4.rightOffset: 0
+
+*ColorSelectionBox*displayX.labelString: X Rendering
+*ColorSelectionBox*displayDPS.labelString: DPS Rendering
+*ColorSelectionBox*displayBoth.labelString: Both
+
+*ColorSelectionBox*noBackgroundMessage.messageString: Unable to allocate solid color\n\
+for color patch. Patch can only be\n\
+displayed using DPS rendering.
+*ColorSelectionBox*noBackgroundMessage.dialogTitle: Color Picker Alert
+
+*ColorSelectionBox*rgb.labelString: RGB
+*ColorSelectionBox*cmyk.labelString: CMYK
+*ColorSelectionBox*hsb.labelString: HSB
+*ColorSelectionBox*gray.labelString: Gray
+
+*ColorSelectionBox*value1.rightPosition: 60
+*ColorSelectionBox*value2.rightOffset:0
+*ColorSelectionBox*value3.rightOffset:0
+*ColorSelectionBox*value4.rightOffset:0
+
+*ColorSelectionBox*label1.alignment: alignment_end
+*ColorSelectionBox*label2.alignment: alignment_end
+*ColorSelectionBox*label3.alignment: alignment_end
+*ColorSelectionBox*label4.alignment: alignment_end
+
+*ColorSelectionBox*value1.recomputeSize: false
+*ColorSelectionBox*value2.recomputeSize: false
+*ColorSelectionBox*value3.recomputeSize: false
+*ColorSelectionBox*value4.recomputeSize: false
+*ColorSelectionBox*value1.width: 20
+*ColorSelectionBox*value2.width: 20
+*ColorSelectionBox*value3.width: 20
+*ColorSelectionBox*value4.width: 20
+*ColorSelectionBox*value1.labelString: 0
+*ColorSelectionBox*value2.labelString: 0
+*ColorSelectionBox*value3.labelString: 0
+*ColorSelectionBox*value4.labelString: 0
+
+*ColorSelectionBox*displayOptionMenu.leftPosition: 60
+*ColorSelectionBox*displayOptionMenu.labelString:
+*ColorSelectionBox*modelOptionMenu.labelString:
+*ColorSelectionBox*modelOptionMenu.leftOffset: 10
+*ColorSelectionBox*paletteOptionMenu.labelString:
+*ColorSelectionBox*paletteOptionMenu.leftOffset: 10
+
+*ColorSelectionBox*eyedropButton.topOffset: -3
+*ColorSelectionBox*eyedropButton.labelType: pixmap
+*ColorSelectionBox*eyedropButton.marginLeft: 2
+*ColorSelectionBox*eyedropButton.marginRight: 2
+*ColorSelectionBox*paletteFrame.shadowType: shadow_in
+*ColorSelectionBox*palette.height: 15
+
+*ColorSelectionBox*dockFrame.leftOffset: 12
+*ColorSelectionBox*dockFrame.shadowType: shadow_in
+
+*ColorSelectionBox*dock.height: 30
+
+*ColorSelectionBox*patchFrame.leftOffset: 0
+*ColorSelectionBox*patchFrame.shadowType: shadow_in
+*ColorSelectionBox*patchFrame.bottomOffset: 0
+*ColorSelectionBox*patch.shadowThickness: 0
+
+*ColorSelectionBox*palette0Label: Full Spectrum
+*ColorSelectionBox*palette0Space: HSB
+*ColorSelectionBox*palette0ColorDependent: False
+*ColorSelectionBox*palette0Function: 1 1
+
+*ColorSelectionBox*palette1Label: NarrowSpectrum
+*ColorSelectionBox*palette1Space: HSB
+*ColorSelectionBox*palette1ColorDependent: True
+*ColorSelectionBox*palette1Function: .5 sub .3 mul \
+ 4 -1 roll add \
+ dup 0.0 lt {1.0 add} if \
+ dup 1.0 gt {1.0 sub} if \
+ 3 1 roll
+
+*ColorSelectionBox*palette2Label: Shades
+*ColorSelectionBox*palette2Space: HSB
+*ColorSelectionBox*palette2ColorDependent: True
+*ColorSelectionBox*palette2Function: exch pop
+
+*ColorSelectionBox*palette3Label: Pastels
+*ColorSelectionBox*palette3Space: HSB
+*ColorSelectionBox*palette3ColorDependent: True
+*ColorSelectionBox*palette3Function: 3 -1 roll pop exch
+
+*ColorSelectionBox*palette4Label:Black to White
+*ColorSelectionBox*palette4Space: HSB
+*ColorSelectionBox*palette4ColorDependent: True
+*ColorSelectionBox*palette4Function: dup .5 lt {2 mul 3 1 roll pop pop 1 exch} {.5 sub 2 mul 1 sub neg 3 1 roll pop pop 1} ifelse
+
+*ColorSelectionBox*palette5Label: Grays
+*ColorSelectionBox*palette5Space: Gray
+*ColorSelectionBox*palette5ColorDependent: False
+*ColorSelectionBox*palette5Function:
diff --git a/nx-X11/lib/dpstk/DPSScrollW.c b/nx-X11/lib/dpstk/DPSScrollW.c
new file mode 100644
index 000000000..9c2f7e005
--- /dev/null
+++ b/nx-X11/lib/dpstk/DPSScrollW.c
@@ -0,0 +1,3500 @@
+ /*
+ * DPSScrollW.c
+ *
+ * (c) Copyright 1993-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/ShellP.h>
+#include <X11/Xproto.h>
+#include <stdlib.h>
+#include <Xm/Xm.h>
+
+/* There are no words to describe how I feel about having to do this */
+
+#if XmVersion > 1001
+#include <Xm/ManagerP.h>
+#else
+#include <Xm/XmP.h>
+#endif
+
+#include <Xm/DrawingA.h>
+#include <Xm/ScrolledW.h>
+#include <Xm/ScrollBar.h>
+
+#include <DPS/dpsXclient.h>
+#include "dpsXcommonI.h"
+#include <DPS/dpsXshare.h>
+#include "DSWwraps.h"
+#include <stdio.h>
+#include <DPS/DPSScrollWP.h>
+
+#undef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#undef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#undef ABS
+#define ABS(x) ((x) >= 0 ? (x) : -(x))
+#undef CEIL
+#define CEIL(x) ((int) ((float)((int)(x)) == (x) ? (x) : (x) + 1))
+
+/* Define macros to get rectangle entries. All rectangles are stored as
+ x, y, width, height. NOTE: ONLY FOR USER SPACE RECTANGLES, NOT X
+ RECTANGLES!!!! */
+
+#define LEFT(r) ((r)[0])
+#define RIGHT(r) ((r)[0] + (r)[2])
+#define BOTTOM(r) ((r)[1])
+#define TOP(r) ((r)[1] + (r)[3])
+#define WIDTH(r) ((r)[2])
+#define HEIGHT(r) ((r)[3])
+
+/* This is used in converting bounding boxes into user space to ensure
+ that we don't end up slopping over into another pixel */
+
+#define DELTA .001
+
+#define Offset(field) XtOffsetOf(DPSScrolledWindowRec, sw.field)
+
+static float initScale = 1.0;
+
+static XtResource resources[] = {
+ {XtNcontext, XtCContext, XtRDPSContext, sizeof(DPSContext),
+ Offset(context), XtRImmediate, (XtPointer) NULL},
+ {XtNareaWidth, XtCAreaWidth, XtRInt, sizeof(int),
+ Offset(area_width), XtRImmediate, (XtPointer) ((int) (8.5*72))},
+ {XtNareaHeight, XtCAreaHeight, XtRInt, sizeof(int),
+ Offset(area_height), XtRImmediate, (XtPointer) (11*72)},
+ {XtNscale, XtCScale, XtRFloat, sizeof(float),
+ Offset(scale), XtRFloat, (XtPointer) &initScale},
+ {XtNctm, XtCCtm, XtRFloatArray, sizeof(float *),
+ Offset(ctm_ptr), XtRImmediate, (XtPointer) NULL},
+ {XtNinvCtm, XtCInvCtm, XtRFloatArray, sizeof(float *),
+ Offset(inv_ctm_ptr), XtRImmediate, (XtPointer) NULL},
+ {XtNuseBackingPixmap, XtCUseBackingPixmap, XtRBoolean, sizeof(Boolean),
+ Offset(use_backing_pixmap), XtRImmediate, (XtPointer) True},
+ {XtNuseFeedbackPixmap, XtCUseFeedbackPixmap, XtRBoolean, sizeof(Boolean),
+ Offset(use_feedback_pixmap), XtRImmediate, (XtPointer) True},
+ {XtNbackingPixmap, XtCBackingPixmap, XtRPixmap, sizeof(Pixmap),
+ Offset(backing_pixmap), XtRImmediate, (XtPointer) None},
+ {XtNfeedbackPixmap, XtCFeedbackPixmap, XtRPixmap, sizeof(Pixmap),
+ Offset(feedback_pixmap), XtRImmediate, (XtPointer) None},
+ {XtNdocumentSizePixmaps, XtCDocumentSizePixmaps,
+ XtRBoolean, sizeof(Boolean),
+ Offset(document_size_pixmaps), XtRImmediate, (XtPointer) False},
+ {XtNwindowGState, XtCWindowGState, XtRDPSGState, sizeof(DPSGState),
+ Offset(window_gstate), XtRImmediate, (XtPointer) 0},
+ {XtNbackingGState, XtCBackingGState, XtRDPSGState, sizeof(DPSGState),
+ Offset(backing_gstate), XtRImmediate, (XtPointer) 0},
+ {XtNfeedbackGState, XtCFeedbackGState, XtRDPSGState, sizeof(DPSGState),
+ Offset(feedback_gstate), XtRImmediate, (XtPointer) 0},
+ {XtNdirtyAreas, XtCDirtyAreas, XtRFloatArray, sizeof(float *),
+ Offset(dirty_areas), XtRImmediate, (XtPointer) NULL},
+ {XtNnumDirtyAreas, XtCNumDirtyAreas, XtRShort, sizeof(short),
+ Offset(num_dirty_areas), XtRImmediate, (XtPointer) 0},
+ {XtNpixmapLimit, XtCPixmapLimit, XtRInt, sizeof(int),
+ Offset(pixmap_limit), XtRImmediate, (XtPointer) -1},
+ {XtNabsolutePixmapLimit, XtCAbsolutePixmapLimit, XtRInt, sizeof(int),
+ Offset(absolute_pixmap_limit), XtRImmediate, (XtPointer) 0},
+ {XtNwatchProgress, XtCWatchProgress, XtRBoolean, sizeof(Boolean),
+ Offset(watch_progress), XtRImmediate, (XtPointer) False},
+ {XtNwatchProgressDelay, XtCWatchProgressDelay, XtRInt, sizeof(int),
+ Offset(watch_progress_delay), XtRImmediate, (XtPointer) 1000},
+ {XtNminimalDrawing, XtCMinimalDrawing, XtRBoolean, sizeof(Boolean),
+ Offset(minimal_drawing), XtRImmediate, (XtPointer) False},
+ {XtNapplicationScrolling, XtCApplicationScrolling,
+ XtRBoolean, sizeof(Boolean),
+ Offset(application_scrolling), XtRImmediate, (XtPointer) False},
+ {XtNsetupCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(setup_callback), XtRCallback, (XtPointer) NULL},
+ {XtNexposeCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(expose_callback), XtRCallback, (XtPointer) NULL},
+ {XtNbackgroundCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(background_callback), XtRCallback, (XtPointer) NULL},
+ {XtNfeedbackCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(feedback_callback), XtRCallback, (XtPointer) NULL},
+ {XtNresizeCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(resize_callback), XtRCallback, (XtPointer) NULL},
+};
+
+static Boolean GiveFeedbackPixmap(Widget w, Pixmap p, int width, int height, int depth, Screen *screen);
+static Boolean SetValues(Widget old, Widget req, Widget new, ArgList args, Cardinal *num_args);
+static Boolean TakeFeedbackPixmap(Widget w, Pixmap *p, int *width, int *height, int *depth, Screen **screen);
+static XtGeometryResult GeometryManager(Widget w, XtWidgetGeometry *desired, XtWidgetGeometry *allowed);
+static XtGeometryResult QueryGeometry(Widget w, XtWidgetGeometry *desired, XtWidgetGeometry *allowed);
+static void AbortPendingDrawing(Widget w);
+static void AddExposureToPending(DPSScrolledWindowWidget dsw, XExposeEvent *ev);
+static void AddRectsToDirtyArea(DPSScrolledWindowWidget dsw, float *newRect, int n);
+static void AddRectsToPending(DPSScrolledWindowWidget dsw, int *newRect, int n);
+static void AddToDirtyArea(Widget w, float *rect, long n);
+static void AddUserSpaceRectsToPending(DPSScrolledWindowWidget dsw, float *newRect, int n);
+static void CallFeedbackCallback(DPSScrolledWindowWidget dsw, float *r, int n);
+static void CheckFeedbackPixmap(DPSScrolledWindowWidget dsw);
+static void ClassPartInitialize(WidgetClass widget_class);
+static void ConvertPSToX(Widget w, double psX, double psY, int *xX, int *xY);
+static void ConvertToOrigPS(DPSScrolledWindowWidget dsw, int xX, int xY, float *psX, float *psY);
+static void ConvertToPS(DPSScrolledWindowWidget dsw, float xX, float xY, float *psX, float *psY);
+static void ConvertToX(DPSScrolledWindowWidget dsw, float psX, float psY, int *xX, int *xY);
+static void ConvertXToPS(Widget w, long xX, long xY, float *psX, float *psY);
+static void CopyRectsToCurrentDrawing(DPSScrolledWindowWidget dsw, float *newRect, int n);
+static void CopyRectsToDirtyArea(DPSScrolledWindowWidget dsw, float *newRect, int n);
+static void CopyToFeedbackPixmap(DPSScrolledWindowWidget dsw, float *rects, int n);
+static void Destroy(Widget widget);
+static void DrawingAreaExpose(Widget w, XtPointer clientData, XtPointer callData);
+static void DrawingAreaGraphicsExpose(Widget w, XtPointer clientData, XEvent *event, Boolean *goOn);
+static void EndFeedbackDrawing(Widget w, int restore);
+static void FinishDrawing(DPSScrolledWindowWidget dsw);
+static void FinishPendingDrawing(Widget w);
+static void GetDrawingInfo(Widget w, DSWDrawableType *type, Drawable *drawable, DPSGState *gstate, DPSContext *context);
+static void GetScrollInfo(Widget w, int *h_value, int *h_size, int *h_max, int *v_value, int *v_size, int *v_max);
+static void HScrollCallback(Widget w, XtPointer clientData, XtPointer callData);
+static void Initialize(Widget request, Widget new, ArgList args, Cardinal *num_args);
+static void Realize(Widget w, XtValueMask *mask, XSetWindowAttributes *attr);
+static void Resize(Widget w);
+static void ScrollBy(Widget w, long dx, long dy);
+static void ScrollMoved(DPSScrolledWindowWidget dsw);
+static void ScrollPoint(Widget w, double psX, double psY, long xX, long xY);
+static void ScrollTo(Widget w, long x, long y);
+static void SetFeedbackDirtyArea(Widget w, float *rects, int count, XtPointer continue_feedback_data);
+static void SetScale(Widget w, double scale, long fixedX, long fixedY);
+static void SetScaleAndScroll(Widget w, double scale, double psX, double psY, long xX, long xY);
+static void StartFeedbackDrawing(Widget w, XtPointer start_feedback_data);
+static void UpdateDrawing(Widget w, float *rects, int count);
+static void VScrollCallback(Widget w, XtPointer clientData, XtPointer callData);
+
+DPSScrolledWindowClassRec dpsScrolledWindowClassRec = {
+ /* Core class part */
+ {
+ /* superclass */ (WidgetClass) &xmManagerClassRec,
+ /* class_name */ "DPSScrolledWindow",
+ /* widget_size */ sizeof(DPSScrolledWindowRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize */ ClassPartInitialize,
+ /* class_inited */ False,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ True,
+ /* compress_exposure */ XtExposeCompressMultiple,
+ /* compress_enterleave */ True,
+ /* visible_interest */ False,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ NULL,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL,
+ },
+ /* Composite class part */
+ {
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ NULL,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL,
+ },
+ /* Constraint class part */
+ {
+ /* resources */ NULL,
+ /* num_resources */ 0,
+ /* constraint_size */ 0,
+ /* initialize */ NULL,
+ /* destroy */ NULL,
+ /* set_values */ NULL,
+ /* extension */ NULL,
+ },
+ /* Manager class part */
+ {
+ /* translations */ XtInheritTranslations,
+ /* syn_resources */ NULL,
+ /* num_syn_resources */ 0,
+ /* syn_constraint_resources */ NULL,
+ /* num_syn_constraint_resources */ 0,
+ /* parent_process */ XmInheritParentProcess,
+ /* extension */ NULL,
+ },
+ /* DPSScrolledWindow class part */
+ {
+ /* set_scale */ SetScale,
+ /* scroll_point */ ScrollPoint,
+ /* scroll_by */ ScrollBy,
+ /* scroll_to */ ScrollTo,
+ /* set_scale_and_scroll */ SetScaleAndScroll,
+ /* convert_x_to_ps */ ConvertXToPS,
+ /* convert_ps_to_x */ ConvertPSToX,
+ /* add_to_dirty_area */ AddToDirtyArea,
+ /* take_feedback_pixmap */ TakeFeedbackPixmap,
+ /* give_feedback_pixmap */ GiveFeedbackPixmap,
+ /* start_feedback_drawing */ StartFeedbackDrawing,
+ /* end_feedback_drawing */ EndFeedbackDrawing,
+ /* set_feedback_dirty_area */ SetFeedbackDirtyArea,
+ /* finish_pending_drawing */ FinishPendingDrawing,
+ /* abort_pending_drawing */ AbortPendingDrawing,
+ /* get_drawing_info */ GetDrawingInfo,
+ /* update_drawing */ UpdateDrawing,
+ /* get_scroll_info */ GetScrollInfo,
+ /* extension */ NULL,
+ }
+};
+
+WidgetClass dpsScrolledWindowWidgetClass =
+ (WidgetClass) &dpsScrolledWindowClassRec;
+
+/***** UTILITY FUNCTIONS *****/
+
+static void PrintRectList(float *r, short num_r)
+{
+ int i;
+
+ for (i = 0; i < num_r; i++) {
+ printf("Rectangle %d: ", i);
+ printf("X %g Y %g W %g H %g\n", r[0], r[1], r[2], r[3]);
+ r += 4;
+ }
+}
+
+/* Make sure the list pointed to by r can hold n more rectangles. Always
+ grow by at least min_grow */
+
+static void GrowRectList(
+ float **r,
+ short *r_size,
+ short num_r,
+ int n, int min_grow)
+{
+ if (*r_size < num_r + n) {
+ if (min_grow > 1 && num_r + n - *r_size < min_grow) {
+ *r_size += min_grow;
+ } else *r_size = num_r + n;
+ *r = (float *) XtRealloc((char *) *r, *r_size * 4 * sizeof(float));
+ }
+}
+
+static void GrowIntRectList(
+ int **r,
+ short *r_size,
+ short num_r,
+ int n, int min_grow)
+{
+ if (*r_size < num_r + n) {
+ if (min_grow > 1 && num_r + n - *r_size < min_grow) {
+ *r_size += min_grow;
+ } else *r_size = num_r + n;
+ *r = (int *) XtRealloc((char *) *r, *r_size * 4 * sizeof(int));
+ }
+}
+
+static Boolean Intersects(float *r1, float *r2)
+{
+ if (RIGHT(r1) <= LEFT(r2)) return False;
+ if (RIGHT(r2) <= LEFT(r1)) return False;
+ if (TOP(r1) <= BOTTOM(r2)) return False;
+ if (TOP(r2) <= BOTTOM(r1)) return False;
+
+ return True;
+}
+
+/* Subtract sub from src, putting result into dst. Return rectangle count */
+
+static int Subtract(float *src, float *sub, float *dst)
+{
+ int n = 0;
+
+ /* If bottom of sub is greater than bottom of src, there's a
+ rectangle across the bottom */
+ if (BOTTOM(sub) > BOTTOM(src)) {
+ LEFT(dst) = LEFT(src);
+ BOTTOM(dst) = BOTTOM(src);
+ WIDTH(dst) = WIDTH(src);
+ HEIGHT(dst) = BOTTOM(sub) - BOTTOM(src);
+ n++;
+ dst += 4;
+ }
+
+ /* If left of sub is greater than left of src, there's a left rectangle. */
+ if (LEFT(sub) > LEFT(src)) {
+ LEFT(dst) = LEFT(src);
+ BOTTOM(dst) = MAX(BOTTOM(src), BOTTOM(sub));
+ WIDTH(dst) = LEFT(sub) - LEFT(src);
+ HEIGHT(dst) = MIN(TOP(src), TOP(sub)) - BOTTOM(dst);
+ n++;
+ dst += 4;
+ }
+
+ /* If right of sub is less than right of src, there's a right rect */
+ if (RIGHT(sub) < RIGHT(src)) {
+ LEFT(dst) = RIGHT(sub);
+ BOTTOM(dst) = MAX(BOTTOM(src), BOTTOM(sub));
+ WIDTH(dst) = RIGHT(src) - RIGHT(sub);
+ HEIGHT(dst) = MIN(TOP(src), TOP(sub)) - BOTTOM(dst);
+ n++;
+ dst += 4;
+ }
+
+ /* If top of sub is less than top of src, there's a top rectangle */
+ if (TOP(sub) < TOP(src)) {
+ LEFT(dst) = LEFT(src);
+ BOTTOM(dst) = TOP(sub);
+ WIDTH(dst) = WIDTH(src);
+ HEIGHT(dst) = TOP(src) - TOP(sub);
+ n++;
+ dst += 4;
+ }
+
+ return n;
+}
+
+static void Copy(float *src, float *dst)
+{
+ LEFT(dst) = LEFT(src);
+ BOTTOM(dst) = BOTTOM(src);
+ WIDTH(dst) = WIDTH(src);
+ HEIGHT(dst) = HEIGHT(src);
+}
+
+static void Intersection(float *r1, float *r2, float *dst)
+{
+ LEFT(dst) = MAX(LEFT(r1), LEFT(r2));
+ BOTTOM(dst) = MAX(BOTTOM(r1), BOTTOM(r2));
+ WIDTH(dst) = MIN(RIGHT(r1), RIGHT(r2)) - LEFT(dst);
+ HEIGHT(dst) = MIN(TOP(r1), TOP(r2)) - BOTTOM(dst);
+}
+
+/* These are used by the SubtractRects and IntersectRects procedures */
+
+static float *rbuf = NULL;
+static short rbuf_size = 0;
+#define GROW_BUF 10
+
+/* Replace the rectangle list in src with src minus sub */
+
+static void SubtractRects(
+ float **src,
+ short *src_size,
+ short *num_src,
+ float *sub,
+ int num_sub)
+{
+ short num_rbuf;
+ float *r;
+ int i;
+
+ /* Go through, subtracting the first sub rectangle from each src
+ rectangle. Put the result in the internal buffer, then copy this
+ list to the src. Repeat for each sub rectangle. */
+
+ while (num_sub > 0) {
+ num_rbuf = 0;
+ for (r = *src, i = 0; i < *num_src; r += 4, i++) {
+ if (Intersects(r, sub)) {
+ /* Subtract sub from r, putting result into rbuf. First
+ make sure there are at least 4 spaces in the buffer */
+ GrowRectList(&rbuf, &rbuf_size, num_rbuf, 4, GROW_BUF);
+
+ /* Do the subtraction */
+ num_rbuf += Subtract(r, sub, rbuf + (num_rbuf*4));
+ } else {
+ /* Copy r into buffer */
+ GrowRectList(&rbuf, &rbuf_size, num_rbuf, 1, GROW_BUF);
+ Copy(r, rbuf + (num_rbuf*4));
+ num_rbuf++;
+ }
+ }
+
+ /* Copy buffered rectangles back into src */
+ GrowRectList(src, src_size, 0, num_rbuf, 1);
+ for (i = 0; i < num_rbuf * 4; i++) (*src)[i] = rbuf[i];
+ *num_src = num_rbuf;
+
+ /* Check if we've taken everything away */
+ if (*num_src == 0) return;
+
+ /* Skip on to the next sub rectangle */
+ num_sub--;
+ sub += 4;
+ }
+}
+
+/* Replace list r1 with the intersection of r1 and r2 */
+
+static void IntersectRects(
+ float **r1,
+ short *r1_size,
+ short *num_r1,
+ float *r2,
+ int num_r2)
+{
+ short num_rbuf = 0;
+ float *r;
+ int i;
+
+ /* Fairly straightforward. Intersect each rectangle in r1 with each
+ rectangle in r2, then copy the results to r1 */
+
+ while (num_r2 > 0) {
+ for (r = *r1, i = 0; i < *num_r1; r += 4, i++) {
+ if (Intersects(r, r2)) {
+ GrowRectList(&rbuf, &rbuf_size, num_rbuf, 1, GROW_BUF);
+ Intersection(r, r2, rbuf + (num_rbuf*4));
+ num_rbuf++;
+ }
+ }
+ num_r2--;
+ r2 += 4;
+ }
+
+ /* Copy intersection rectangles back into r1 */
+ GrowRectList(r1, r1_size, 0, num_rbuf, 1);
+ for (i = 0; i < num_rbuf * 4; i++) (*r1)[i] = rbuf[i];
+ *num_r1 = num_rbuf;
+}
+
+static void SimplifyRects(float *rect, short *num)
+{
+ int i, j, k;
+ float *r, *r1;
+
+ i = 0;
+ while (i < *num) {
+ r = rect + (i * 4);
+ if (WIDTH(r) == 0 || HEIGHT(r) == 0) {
+ for (k = 4*(i+1); k < *num * 4; k++) rect[k-4] = rect[k];
+ (*num)--;
+ goto LOOPEND;
+ }
+ j = i+1;
+ while (j < *num) {
+ r1 = rect + (j * 4);
+ if (TOP(r1) <= TOP(r) && BOTTOM(r1) >= BOTTOM(r) &&
+ LEFT(r1) >= LEFT(r) && RIGHT(r1) <= RIGHT(r)) {
+ for (k = 4*(j+1); k < *num * 4; k++) rect[k-4] = rect[k];
+ (*num)--;
+ } else if (TOP(r) <= TOP(r1) && BOTTOM(r) >= BOTTOM(r1) &&
+ LEFT(r) >= LEFT(r1) && RIGHT(r) <= RIGHT(r1)) {
+ for (k = 4*(i+1); k < *num * 4; k++) rect[k-4] = rect[k];
+ (*num)--;
+ goto LOOPEND;
+ } else j++;
+ }
+ i++;
+LOOPEND:;
+ }
+}
+
+static void ComputeOffsets(DPSScrolledWindowWidget dsw, int *dx, int *dy)
+{
+ if (dsw->sw.doing_feedback && dsw->sw.feedback_pixmap != None) {
+ *dx = *dy = 0;
+ } else {
+ if (dsw->sw.pixmap_width == dsw->sw.drawing_area->core.width) *dx = 0;
+ else *dx = -dsw->sw.origin_x;
+ if (dsw->sw.pixmap_height == dsw->sw.drawing_area->core.height) *dy = 0;
+ else *dy = CEIL(dsw->sw.drawing_height) - dsw->sw.origin_y;
+ }
+}
+
+static void ClassPartInitialize(WidgetClass widget_class)
+{
+ register DPSScrolledWindowWidgetClass wc =
+ (DPSScrolledWindowWidgetClass) widget_class;
+ DPSScrolledWindowWidgetClass super =
+ (DPSScrolledWindowWidgetClass) wc->core_class.superclass;
+
+ if (wc->sw_class.set_scale == InheritSetScale) {
+ wc->sw_class.set_scale = super->sw_class.set_scale;
+ }
+ if (wc->sw_class.scroll_point == InheritScrollPoint) {
+ wc->sw_class.scroll_point = super->sw_class.scroll_point;
+ }
+ if (wc->sw_class.scroll_by == InheritScrollBy) {
+ wc->sw_class.scroll_by = super->sw_class.scroll_by;
+ }
+ if (wc->sw_class.scroll_to == InheritScrollTo) {
+ wc->sw_class.scroll_to = super->sw_class.scroll_to;
+ }
+ if (wc->sw_class.set_scale_and_scroll == InheritSetScaleAndScroll) {
+ wc->sw_class.set_scale_and_scroll =
+ super->sw_class.set_scale_and_scroll;
+ }
+ if (wc->sw_class.convert_x_to_ps == InheritConvertXToPS) {
+ wc->sw_class.convert_x_to_ps = super->sw_class.convert_x_to_ps;
+ }
+ if (wc->sw_class.convert_ps_to_x == InheritConvertPSToX) {
+ wc->sw_class.convert_ps_to_x = super->sw_class.convert_ps_to_x;
+ }
+ if (wc->sw_class.add_to_dirty_area == InheritAddToDirtyArea) {
+ wc->sw_class.add_to_dirty_area = super->sw_class.add_to_dirty_area;
+ }
+ if (wc->sw_class.take_feedback_pixmap == InheritTakeFeedbackPixmap) {
+ wc->sw_class.take_feedback_pixmap =
+ super->sw_class.take_feedback_pixmap;
+ }
+ if (wc->sw_class.give_feedback_pixmap == InheritGiveFeedbackPixmap) {
+ wc->sw_class.give_feedback_pixmap =
+ super->sw_class.give_feedback_pixmap;
+ }
+ if (wc->sw_class.start_feedback_drawing == InheritStartFeedbackDrawing) {
+ wc->sw_class.start_feedback_drawing =
+ super->sw_class.start_feedback_drawing;
+ }
+ if (wc->sw_class.end_feedback_drawing == InheritEndFeedbackDrawing) {
+ wc->sw_class.end_feedback_drawing =
+ super->sw_class.end_feedback_drawing;
+ }
+ if (wc->sw_class.set_feedback_dirty_area == InheritSetFeedbackDirtyArea) {
+ wc->sw_class.set_feedback_dirty_area =
+ super->sw_class.set_feedback_dirty_area;
+ }
+ if (wc->sw_class.finish_pending_drawing == InheritFinishPendingDrawing) {
+ wc->sw_class.finish_pending_drawing =
+ super->sw_class.finish_pending_drawing;
+ }
+ if (wc->sw_class.abort_pending_drawing == InheritAbortPendingDrawing) {
+ wc->sw_class.abort_pending_drawing =
+ super->sw_class.abort_pending_drawing;
+ }
+ if (wc->sw_class.get_drawing_info == InheritGetDrawingInfo) {
+ wc->sw_class.get_drawing_info = super->sw_class.get_drawing_info;
+ }
+ if (wc->sw_class.update_drawing == InheritUpdateDrawing) {
+ wc->sw_class.update_drawing = super->sw_class.update_drawing;
+ }
+ if (wc->sw_class.get_scroll_info == InheritGetScrollInfo) {
+ wc->sw_class.get_scroll_info = super->sw_class.get_scroll_info;
+ }
+}
+
+static void CreateChildren(DPSScrolledWindowWidget dsw)
+{
+ Widget w;
+
+ w = dsw->sw.scrolled_window =
+ XtVaCreateManagedWidget("scrolledWindow",
+ xmScrolledWindowWidgetClass,
+ (Widget) dsw,
+ XtNwidth, dsw->core.width,
+ XtNheight, dsw->core.height,
+ XmNscrollingPolicy, XmAPPLICATION_DEFINED,
+ NULL);
+
+ dsw->sw.h_scroll =
+ XtVaCreateManagedWidget("horizontalScrollBar",
+ xmScrollBarWidgetClass, w,
+ XmNorientation, XmHORIZONTAL,
+ NULL);
+ XtAddCallback(dsw->sw.h_scroll, XmNvalueChangedCallback, HScrollCallback,
+ (XtPointer) dsw);
+ XtAddCallback(dsw->sw.h_scroll, XmNdragCallback, HScrollCallback,
+ (XtPointer) dsw);
+
+ dsw->sw.v_scroll =
+ XtVaCreateManagedWidget("verticalScrollBar",
+ xmScrollBarWidgetClass, w,
+ XmNorientation, XmVERTICAL,
+ NULL);
+ XtAddCallback(dsw->sw.v_scroll, XmNvalueChangedCallback, VScrollCallback,
+ (XtPointer) dsw);
+ XtAddCallback(dsw->sw.v_scroll, XmNdragCallback, VScrollCallback,
+ (XtPointer) dsw);
+
+
+ dsw->sw.drawing_area =
+ XtVaCreateManagedWidget("drawingArea",
+ xmDrawingAreaWidgetClass, w, NULL);
+ XtAddCallback(dsw->sw.drawing_area, XtNexposeCallback, DrawingAreaExpose,
+ (XtPointer) dsw);
+ XtAddRawEventHandler(dsw->sw.drawing_area, 0, True,
+ DrawingAreaGraphicsExpose, (XtPointer) dsw);
+
+ XmScrolledWindowSetAreas(w, dsw->sw.h_scroll, dsw->sw.v_scroll,
+ dsw->sw.drawing_area);
+}
+
+/* ARGSUSED */
+
+static void Initialize(Widget request, Widget new, ArgList args, Cardinal *num_args)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) new;
+ XGCValues gcVal;
+ Bool inited;
+
+ if (dsw->sw.area_width <= 0) dsw->sw.area_width = 8.5*72;
+ if (dsw->sw.area_height <= 0) dsw->sw.area_height = 11*72;
+ if (dsw->sw.scale <= 0) dsw->sw.scale = 1.0;
+ dsw->sw.ctm_ptr = dsw->sw.ctm;
+ dsw->sw.inv_ctm_ptr = dsw->sw.inv_ctm;
+ dsw->sw.backing_pixmap = None;
+ dsw->sw.feedback_pixmap = None;
+ dsw->sw.window_gstate = 0;
+ dsw->sw.backing_gstate = 0;
+ dsw->sw.feedback_gstate = 0;
+ dsw->sw.scrolling = False;
+ dsw->sw.num_pending_expose = dsw->sw.pending_expose_size = 0;
+ dsw->sw.pending_expose = NULL;
+ dsw->sw.num_pending_dirty = dsw->sw.pending_dirty_size = 0;
+ dsw->sw.pending_dirty = NULL;
+ dsw->sw.num_current_drawing = dsw->sw.current_drawing_size = 0;
+ dsw->sw.current_drawing = NULL;
+ dsw->sw.num_prev_dirty_areas = dsw->sw.prev_dirty_areas_size = 0;
+ dsw->sw.prev_dirty_areas = NULL;
+ dsw->sw.drawing_stage = DSWStart;
+ dsw->sw.work = 0;
+ dsw->sw.big_pixmap = False;
+
+ /* Set the initial dirty area to everything */
+
+ dsw->sw.dirty_areas_size = 0;
+ dsw->sw.dirty_areas = NULL;
+
+ GrowRectList(&dsw->sw.dirty_areas, &dsw->sw.dirty_areas_size, 0, 1, 1);
+ dsw->sw.num_dirty_areas = 1;
+ LEFT(dsw->sw.dirty_areas) = 0.0;
+ BOTTOM(dsw->sw.dirty_areas) = 0.0;
+ WIDTH(dsw->sw.dirty_areas) = dsw->sw.area_width;
+ HEIGHT(dsw->sw.dirty_areas) = dsw->sw.area_height;
+
+ /* Make the scratch list have at least one element */
+
+ dsw->sw.num_scratch = dsw->sw.scratch_size = 0;
+ dsw->sw.scratch = NULL;
+ GrowRectList(&dsw->sw.scratch, &dsw->sw.scratch_size, 0, 1, 1);
+
+ /* Get the context */
+
+ if (dsw->sw.context == NULL) {
+ dsw->sw.context = XDPSGetSharedContext(XtDisplay(dsw));
+ }
+
+ /* Watch progress only works with pass-through event dispatching */
+
+ if (dsw->sw.watch_progress &&
+ XDPSSetEventDelivery(XtDisplay(dsw), dps_event_query) !=
+ dps_event_pass_through) dsw->sw.watch_progress = False;
+
+ if (_XDPSTestComponentInitialized(dsw->sw.context,
+ dps_init_bit_dsw, &inited) ==
+ dps_status_unregistered_context) {
+ XDPSRegisterContext(dsw->sw.context, False);
+ }
+
+ dsw->sw.use_saved_scroll = False;
+ dsw->sw.context_inited = False;
+ dsw->sw.doing_feedback = False;
+ dsw->sw.feedback_displayed = False;
+
+ CreateChildren(dsw);
+
+ dsw->sw.ge_gc = XtGetGC(dsw->sw.drawing_area, 0, (XGCValues *) NULL);
+
+ gcVal.graphics_exposures = False;
+ dsw->sw.no_ge_gc = XtGetGC(dsw->sw.drawing_area, GCGraphicsExposures,
+ &gcVal);
+}
+
+static void Destroy(Widget widget)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) widget;
+
+ if (dsw->sw.backing_pixmap != None) {
+ XFreePixmap(XtDisplay(dsw), dsw->sw.backing_pixmap);
+ }
+ if (dsw->sw.feedback_pixmap != None) {
+ XFreePixmap(XtDisplay(dsw), dsw->sw.feedback_pixmap);
+ }
+
+ if (dsw->sw.window_gstate != 0) {
+ XDPSFreeContextGState(dsw->sw.context, dsw->sw.window_gstate);
+ }
+ if (dsw->sw.backing_gstate != 0) {
+ XDPSFreeContextGState(dsw->sw.context, dsw->sw.backing_gstate);
+ }
+ if (dsw->sw.feedback_gstate != 0) {
+ XDPSFreeContextGState(dsw->sw.context, dsw->sw.feedback_gstate);
+ }
+
+ if (dsw->sw.pending_expose != NULL) {
+ XtFree((char *) dsw->sw.pending_expose);
+ }
+ if (dsw->sw.current_drawing != NULL) {
+ XtFree((char *) dsw->sw.current_drawing);
+ }
+ if (dsw->sw.prev_dirty_areas != NULL) {
+ XtFree((char *) dsw->sw.prev_dirty_areas);
+ }
+ if (dsw->sw.dirty_areas != NULL) XtFree((char *) dsw->sw.dirty_areas);
+ if (dsw->sw.pending_dirty != NULL) XtFree((char *) dsw->sw.pending_dirty);
+ if (dsw->sw.scratch != NULL) XtFree((char *) dsw->sw.scratch);
+
+ XtReleaseGC(widget, dsw->sw.ge_gc);
+ XtReleaseGC(widget, dsw->sw.no_ge_gc);
+}
+
+static void SetOriginAndGetTransform(DPSScrolledWindowWidget dsw)
+{
+ float psX, psY;
+
+ ConvertToOrigPS(dsw, dsw->sw.origin_x, dsw->sw.origin_y, &psX, &psY);
+ _DPSSWSetMatrixAndGetTransform(dsw->sw.context, psX, psY, dsw->sw.scale,
+ dsw->sw.origin_x, dsw->sw.origin_y,
+ dsw->sw.ctm, dsw->sw.inv_ctm,
+ &dsw->sw.x_offset, &dsw->sw.y_offset);
+}
+
+static void SetPixmapOrigin(DPSScrolledWindowWidget dsw)
+{
+ float psX, psY;
+
+ ConvertToOrigPS(dsw, dsw->sw.origin_x, dsw->sw.origin_y, &psX, &psY);
+ _DPSSWSetMatrix(dsw->sw.context, psX, psY, dsw->sw.scale,
+ dsw->sw.origin_x, dsw->sw.origin_y);
+}
+
+static void SetPixmapOffset(DPSScrolledWindowWidget dsw)
+{
+ int ox, oy;
+
+ if (dsw->sw.pixmap_width <= (int) dsw->sw.drawing_area->core.width) ox = 0;
+ else ox = -dsw->sw.origin_x;
+ if (dsw->sw.pixmap_height <= (int) dsw->sw.drawing_area->core.height) {
+ oy = dsw->sw.drawing_area->core.height;
+ } else oy = dsw->sw.pixmap_height - dsw->sw.origin_y +
+ dsw->sw.drawing_area->core.height;
+
+ DPSsetXoffset(dsw->sw.context, ox, oy);
+}
+
+static Boolean pixmapError;
+static int (*oldHandler)(Display *, XErrorEvent *);
+
+static int PixmapHandler(Display *dpy, XErrorEvent *error)
+{
+ if (error->error_code == BadAlloc &&
+ error->request_code == X_CreatePixmap) {
+ pixmapError = True;
+ return 0;
+ } else return (*oldHandler) (dpy, error);
+}
+
+static Pixmap AllocPixmap(DPSScrolledWindowWidget dsw, unsigned w, unsigned h)
+{
+ Pixmap p;
+ unsigned int dBytes;
+ Widget wid = dsw->sw.drawing_area;
+ unsigned area = (w * h);
+
+ if (dsw->sw.pixmap_limit > 0) {
+ if (area > (unsigned)dsw->sw.pixmap_limit) return None;
+ } else if (dsw->sw.pixmap_limit < 0
+ && area > (unsigned)(dsw->sw.unscaled_width * dsw->sw.unscaled_height)
+ && area > (unsigned)(wid->core.width * wid->core.height)) return None;
+
+ if (dsw->sw.absolute_pixmap_limit > 0) {
+ dBytes = (wid->core.depth + 7) / 8; /* Convert into bytes */
+ if (area * dBytes > (unsigned)dsw->sw.absolute_pixmap_limit * 1024) {
+ return None;
+ }
+ }
+
+ XSync(XtDisplay(dsw), False);
+ oldHandler = XSetErrorHandler(PixmapHandler);
+ pixmapError = False;
+ p = XCreatePixmap(XtDisplay(dsw), XtWindow(dsw->sw.drawing_area), w, h,
+ wid->core.depth);
+ XSync(XtDisplay(dsw), False);
+ (void) XSetErrorHandler(oldHandler);
+ if (pixmapError) return None;
+ else return p;
+}
+
+static void CreateBackingPixmap(DPSScrolledWindowWidget dsw)
+{
+ Pixmap p;
+
+ if (dsw->sw.document_size_pixmaps) {
+ dsw->sw.pixmap_width =
+ MAX(CEIL(dsw->sw.drawing_width),
+ (int) dsw->sw.drawing_area->core.width);
+ dsw->sw.pixmap_height =
+ MAX(CEIL(dsw->sw.drawing_height),
+ (int) dsw->sw.drawing_area->core.height);
+
+ p = dsw->sw.backing_pixmap =
+ AllocPixmap(dsw, dsw->sw.pixmap_width, dsw->sw.pixmap_height);
+ if (p != None) {
+ dsw->sw.big_pixmap =
+ dsw->sw.pixmap_width >
+ (int) dsw->sw.drawing_area->core.width ||
+ dsw->sw.pixmap_height >
+ (int) dsw->sw.drawing_area->core.height;
+ return;
+ }
+ }
+ dsw->sw.big_pixmap = False;
+ dsw->sw.pixmap_width = dsw->sw.drawing_area->core.width;
+ dsw->sw.pixmap_height = dsw->sw.drawing_area->core.height;
+ p = dsw->sw.backing_pixmap =
+ AllocPixmap(dsw, dsw->sw.pixmap_width, dsw->sw.pixmap_height);
+ if (p == None) dsw->sw.pixmap_width = dsw->sw.pixmap_height = 0;
+}
+
+static void FreeBackingPixmap(DPSScrolledWindowWidget dsw)
+{
+ if (dsw->sw.backing_pixmap == None) return;
+ XFreePixmap(XtDisplay(dsw), dsw->sw.backing_pixmap);
+ dsw->sw.backing_pixmap = None;
+ dsw->sw.big_pixmap = False;
+ dsw->sw.pixmap_width = dsw->sw.pixmap_height = 0;
+ XDPSFreeContextGState(dsw->sw.context, dsw->sw.backing_gstate);
+}
+
+static void SetDrawingAreaPosition(
+ DPSScrolledWindowWidget dsw,
+ float ix,
+ float iy,
+ int vx,
+ int vy,
+ Boolean setOrigin)
+{
+ int xoff, yoff;
+ int hSize, vSize;
+ float scrollX, scrollY;
+
+ /* Convert ix, iy into X units */
+
+ ix *= dsw->sw.drawing_width / dsw->sw.area_width;
+ iy *= dsw->sw.drawing_height / dsw->sw.area_height;
+
+ if ((int)dsw->sw.drawing_area->core.width >= CEIL(dsw->sw.drawing_width)) {
+ /* The scaled width is narrower than the view window, so
+ center the picture and set scroll bar to be unscrollable */
+
+ xoff = ((int) dsw->sw.drawing_area->core.width -
+ CEIL(dsw->sw.drawing_width))
+ / 2.0;
+ scrollX = 0;
+ hSize = CEIL(dsw->sw.drawing_width);
+ } else {
+ /* The scaled width is larger than the view window, so
+ turn on the scroll bar, and set up its maximum and
+ slider size. Do this by converting the image offset into X
+ coordinates and subtracting the view offset */
+
+ scrollX = ix - vx;
+ scrollX = MAX(scrollX, 0);
+ scrollX = MIN(scrollX, CEIL(dsw->sw.drawing_width) -
+ (int) dsw->sw.drawing_area->core.width);
+ hSize = dsw->sw.drawing_area->core.width;
+ xoff = -(int) (scrollX + 0.5);
+ }
+
+ /* Now do the same thing for the height. We want to compute the offset
+ relative to the lower left corner, but X coordinates are relative
+ to the upper left, so the drawing height must be added in. Also, since
+ the coordinates go in the other direction, the view offset must be
+ added, not subtracted. */
+
+ if ((int) dsw->sw.drawing_area->core.height >=
+ CEIL(dsw->sw.drawing_height)) {
+ yoff = ((int) dsw->sw.drawing_area->core.height -
+ CEIL(dsw->sw.drawing_height)) / 2.0;
+ scrollY = CEIL(dsw->sw.drawing_height) -
+ (int) dsw->sw.drawing_area->core.height;
+ vSize = CEIL(dsw->sw.drawing_height);
+ } else {
+ scrollY = iy + vy - (int) dsw->sw.drawing_area->core.height;
+ scrollY = MAX(scrollY, 0);
+ scrollY = MIN(scrollY, CEIL(dsw->sw.drawing_height) -
+ (int) dsw->sw.drawing_area->core.height);
+ vSize = dsw->sw.drawing_area->core.height;
+ yoff = -(int) (scrollY + 0.5);
+ }
+
+ /* Update the scrollbars */
+ dsw->sw.scroll_x = (int) (scrollX + 0.5);
+ dsw->sw.scroll_y = (int) (CEIL(dsw->sw.drawing_height) -
+ (int) dsw->sw.drawing_area->core.height -
+ scrollY + 0.5);
+
+ yoff = dsw->sw.drawing_area->core.height - yoff;
+
+ dsw->sw.scroll_h_value = dsw->sw.scroll_x;
+ dsw->sw.scroll_h_size = hSize;
+ dsw->sw.scroll_h_max = CEIL(dsw->sw.drawing_width);
+ dsw->sw.scroll_v_value = dsw->sw.scroll_y;
+ dsw->sw.scroll_v_size = vSize;
+ dsw->sw.scroll_v_max = CEIL(dsw->sw.drawing_height);
+
+ if (!dsw->sw.application_scrolling) {
+ XtVaSetValues(dsw->sw.h_scroll, XmNmaximum, dsw->sw.scroll_h_max,
+ XmNvalue, dsw->sw.scroll_x, XmNsliderSize, hSize, NULL);
+ XtVaSetValues(dsw->sw.v_scroll, XmNmaximum, dsw->sw.scroll_v_max,
+ XmNvalue, dsw->sw.scroll_y, XmNsliderSize, vSize, NULL);
+ }
+
+ if (setOrigin) {
+ /* Set the origin in the X window to reflect the new location */
+ dsw->sw.origin_x = xoff;
+ dsw->sw.origin_y = yoff;
+ }
+}
+
+static void DrawBackground(
+ DPSScrolledWindowWidget dsw,
+ DSWDrawableType which)
+{
+ DSWExposeCallbackRec e;
+
+ e.type = which;
+ e.directions = DSWFinish;
+ e.results = DSWUndefined;
+ e.first = True;
+ e.background = True;
+ if (which == DSWBackingPixmap) {
+ e.drawable = dsw->sw.backing_pixmap;
+ e.gstate = dsw->sw.backing_gstate;
+ } else if (which == DSWFeedbackPixmap) {
+ e.drawable = dsw->sw.feedback_pixmap;
+ e.gstate = dsw->sw.feedback_gstate;
+ } else {
+ e.drawable = XtWindow(dsw->sw.drawing_area);
+ e.gstate = dsw->sw.window_gstate;
+ }
+ e.context = dsw->sw.context;
+
+ SimplifyRects(dsw->sw.current_drawing, &dsw->sw.num_current_drawing);
+
+ XDPSSetContextGState(dsw->sw.context, e.gstate);
+ _DPSSWSetRectViewClip(dsw->sw.context, dsw->sw.current_drawing,
+ dsw->sw.num_current_drawing * 4);
+
+ e.rects = dsw->sw.current_drawing;
+ e.rect_count = dsw->sw.num_current_drawing;
+
+ do {
+ XtCallCallbackList((Widget) dsw, dsw->sw.background_callback,
+ (XtPointer) &e);
+ if (e.results == DSWUndefined) {
+ if (XtHasCallbacks((Widget) dsw, XtNbackgroundCallback) !=
+ XtCallbackHasNone) {
+ XtAppWarningMsg(XtWidgetToApplicationContext((Widget) dsw),
+ "returnError", "backgroundCallback",
+ "DPSScrollError",
+ "Background callback did not set result field",
+ (String *) NULL, (Cardinal *) NULL);
+ }
+ e.results = DSWFinished;
+ }
+ } while (e.results != DSWFinished);
+
+
+ DPSinitviewclip(dsw->sw.context);
+}
+
+static void ClipToDrawingSize(
+ DPSScrolledWindowWidget dsw,
+ DSWDrawableType which)
+{
+ int i;
+ float r[4];
+
+ if (CEIL(dsw->sw.drawing_width) >= (int) dsw->sw.drawing_area->core.width &&
+ CEIL(dsw->sw.drawing_height) >= (int) dsw->sw.drawing_area->core.height) return;
+
+ /* Copy current drawing area to scratch */
+
+ GrowRectList(&dsw->sw.scratch, &dsw->sw.scratch_size, 0,
+ dsw->sw.num_current_drawing, 1);
+ dsw->sw.num_scratch = dsw->sw.num_current_drawing;
+ for (i = 0; i < dsw->sw.num_current_drawing * 4; i++) {
+ dsw->sw.scratch[i] = dsw->sw.current_drawing[i];
+ }
+
+ /* Construct a rectangle of the drawing area */
+
+ ConvertToPS(dsw, dsw->sw.origin_x + DELTA, dsw->sw.origin_y - DELTA,
+ r, r+1);
+ ConvertToPS(dsw, dsw->sw.origin_x + CEIL(dsw->sw.drawing_width) - DELTA,
+ dsw->sw.origin_y - CEIL(dsw->sw.drawing_height) + DELTA,
+ r+2, r+3);
+ r[2] -= r[0];
+ r[3] -= r[1];
+
+ /* Subtract the area of the drawing from the current drawing list */
+
+ SubtractRects(&dsw->sw.current_drawing, &dsw->sw.current_drawing_size,
+ &dsw->sw.num_current_drawing, r, 1);
+
+ if (dsw->sw.num_current_drawing != 0) {
+ DrawBackground(dsw, which);
+ /* Now intersect the rectangle with the current drawing area */
+ IntersectRects(&dsw->sw.scratch, &dsw->sw.scratch_size,
+ &dsw->sw.num_scratch, r, 1);
+ /* If nothing left, we won't be drawing anything more, so
+ synchronize. Otherwise wait until we're done drawing */
+ if (dsw->sw.num_scratch == 0) DPSWaitContext(dsw->sw.context);
+ }
+
+ /* Copy scratch back into the current drawing list */
+ GrowRectList(&dsw->sw.current_drawing, &dsw->sw.current_drawing_size, 0,
+ dsw->sw.num_scratch, 1);
+ dsw->sw.num_current_drawing = dsw->sw.num_scratch;
+ for (i = 0; i < dsw->sw.num_scratch * 4; i++) {
+ dsw->sw.current_drawing[i] = dsw->sw.scratch[i];
+ }
+}
+
+static DSWResults ClipAndDraw(
+ DPSScrolledWindowWidget dsw,
+ DSWDrawableType which,
+ DSWDirections howMuch,
+ Boolean first)
+{
+ DSWExposeCallbackRec e;
+
+ e.type = which;
+ e.directions = howMuch;
+ e.results = DSWUndefined;
+ e.first = first;
+ e.background = False;
+ if (which == DSWBackingPixmap) {
+ e.drawable = dsw->sw.backing_pixmap;
+ e.gstate = dsw->sw.backing_gstate;
+ } else if (which == DSWFeedbackPixmap) {
+ e.drawable = dsw->sw.feedback_pixmap;
+ e.gstate = dsw->sw.feedback_gstate;
+ } else {
+ e.drawable = XtWindow(dsw->sw.drawing_area);
+ e.gstate = dsw->sw.window_gstate;
+ }
+ e.context = dsw->sw.context;
+
+ if (first) {
+ XDPSSetContextGState(dsw->sw.context, e.gstate);
+ if (howMuch != DSWAbort) {
+ ClipToDrawingSize(dsw, which);
+ SimplifyRects(dsw->sw.current_drawing,
+ &dsw->sw.num_current_drawing);
+ if (dsw->sw.num_current_drawing == 0) return DSWFinished;
+ _DPSSWSetRectViewClip(dsw->sw.context, dsw->sw.current_drawing,
+ dsw->sw.num_current_drawing * 4);
+ }
+ }
+
+ e.rects = dsw->sw.current_drawing;
+ e.rect_count = dsw->sw.num_current_drawing;
+
+ do {
+ XtCallCallbackList((Widget) dsw, dsw->sw.expose_callback,
+ (XtPointer) &e);
+ if (e.results == DSWUndefined) {
+ if (XtHasCallbacks((Widget) dsw,
+ XtNexposeCallback) != XtCallbackHasNone) {
+ XtAppWarningMsg(XtWidgetToApplicationContext((Widget) dsw),
+ "returnError", "exposeCallback",
+ "DPSScrollError",
+ "Expose callback did not set result field",
+ (String *) NULL, (Cardinal *) NULL);
+ }
+ e.results = DSWFinished;
+ }
+ } while ((e.results != DSWFinished && howMuch == DSWFinish) ||
+ (e.results != DSWFinished && e.results != DSWAborted &&
+ howMuch == DSWAbortOrFinish) ||
+ (e.results != DSWAborted && howMuch == DSWAbort));
+
+ if (e.results == DSWFinished) {
+ DPSinitviewclip(dsw->sw.context);
+ DPSWaitContext(dsw->sw.context);
+ }
+ return e.results;
+}
+
+static void SplitExposeEvent(
+ DPSScrolledWindowWidget dsw,
+ XExposeEvent *ev)
+{
+ float *r;
+ float llx, lly, urx, ury;
+ int xr[4];
+ int i;
+ int dx, dy;
+
+ ComputeOffsets(dsw, &dx, &dy);
+
+ /* Put the expose event into the scratch list */
+ dsw->sw.num_scratch = 1;
+ r = dsw->sw.scratch;
+ ConvertToPS(dsw, ev->x + DELTA, ev->y + ev->height - DELTA, &llx, &lly);
+ ConvertToPS(dsw, ev->x + ev->width - DELTA, ev->y + DELTA, &urx, &ury);
+ LEFT(r) = llx;
+ BOTTOM(r) = lly;
+ WIDTH(r) = urx - llx;
+ HEIGHT(r) = ury - lly;
+
+ /* Subtract the dirty area from the exposed area and copy the resulting
+ area to the window */
+ SubtractRects(&dsw->sw.scratch, &dsw->sw.scratch_size,
+ &dsw->sw.num_scratch,
+ dsw->sw.dirty_areas, dsw->sw.num_dirty_areas);
+ for (i = 0; i < dsw->sw.num_scratch; i++) {
+ r = dsw->sw.scratch + 4*i;
+ ConvertToX(dsw, LEFT(r), TOP(r), xr, xr+1);
+ ConvertToX(dsw, RIGHT(r), BOTTOM(r), xr+2, xr+3);
+ xr[2] -= xr[0];
+ xr[3] -= xr[1];
+ XCopyArea(XtDisplay(dsw), dsw->sw.backing_pixmap,
+ XtWindow(dsw->sw.drawing_area), dsw->sw.no_ge_gc,
+ xr[0] + dx, xr[1] + dy, xr[2], xr[3], xr[0], xr[1]);
+ }
+
+ /* Now do it again, but intersect the exposed area with the dirty area
+ and add the intersection to the pending list */
+
+ dsw->sw.num_scratch = 1;
+ r = dsw->sw.scratch;
+ LEFT(r) = llx;
+ BOTTOM(r) = lly;
+ WIDTH(r) = urx - llx;
+ HEIGHT(r) = ury - lly;
+ IntersectRects(&dsw->sw.scratch, &dsw->sw.scratch_size,
+ &dsw->sw.num_scratch,
+ dsw->sw.dirty_areas, dsw->sw.num_dirty_areas);
+ AddUserSpaceRectsToPending(dsw, dsw->sw.scratch, dsw->sw.num_scratch);
+}
+
+/* ARGSUSED */
+
+static Bool CheckWatchProgressEvent(
+ Display *dpy,
+ XEvent *e,
+ char *arg)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) arg;
+
+ return (e->xany.window == dsw->sw.backing_pixmap &&
+ (e->type == GraphicsExpose || e->type == NoExpose)) ||
+ (e->xany.window == XtWindow(dsw->sw.drawing_area) &&
+ e->type == Expose);
+}
+
+static void CopyWindowToBackingPixmap(
+ DPSScrolledWindowWidget dsw)
+{
+ int llx, lly, urx, ury;
+ XEvent e;
+ XExposeEvent *ev = (XExposeEvent *) &e;
+ int i;
+ float *r;
+ int copies = 0;
+ int dx, dy;
+
+ ComputeOffsets(dsw, &dx, &dy);
+
+ for (i = 0; i < dsw->sw.num_dirty_areas; i++) {
+ r = dsw->sw.dirty_areas + i*4;
+ ConvertToX(dsw, LEFT(r), BOTTOM(r), &llx, &lly);
+ ConvertToX(dsw, RIGHT(r), TOP(r), &urx, &ury);
+ XCopyArea(XtDisplay(dsw), XtWindow(dsw->sw.drawing_area),
+ dsw->sw.backing_pixmap, dsw->sw.ge_gc,
+ llx, ury, urx-llx, lly-ury, llx + dx, ury + dy);
+ copies++;
+ }
+
+ /* Unfortunately the Intrinsics won't let us get ahold of the the
+ GraphicsExpose events for the pixmap, so we have to wait and
+ get them the old fashioned way. Yuck. */
+
+ while (copies > 0) {
+ XIfEvent(XtDisplay(dsw), &e, CheckWatchProgressEvent,
+ (char *) dsw);
+ if (e.type == Expose) {
+ SplitExposeEvent(dsw, ev);
+ continue;
+ } else if (e.type == GraphicsExpose) {
+ ev->x -= dx;
+ ev->y -= dy;
+ AddExposureToPending(dsw, ev);
+ if (ev->count == 0) copies--;
+ } else copies--; /* NoExpose */
+ }
+ CopyRectsToCurrentDrawing(dsw, dsw->sw.pending_dirty,
+ dsw->sw.num_pending_dirty);
+
+ dsw->sw.num_pending_dirty = 0;
+ dsw->sw.num_pending_expose = 0;
+ if (dsw->sw.num_current_drawing == 0) {
+ dsw->sw.drawing_stage = DSWDone;
+ dsw->sw.num_dirty_areas = 0;
+ } else {
+ /* The dirty area is now the intersection of the old dirty area and
+ the newly-created current drawing list */
+ IntersectRects(&dsw->sw.dirty_areas, &dsw->sw.dirty_areas_size,
+ &dsw->sw.num_dirty_areas,
+ dsw->sw.current_drawing, dsw->sw.num_current_drawing);
+ }
+}
+
+/* Subtract the window area from the dirty area, and make the
+ result be the new current drawing list */
+
+static void SetCurrentDrawingToBackground(
+ DPSScrolledWindowWidget dsw)
+{
+ int i;
+ float r[4];
+
+ ConvertToPS(dsw, 0 + DELTA, dsw->sw.drawing_area->core.height - DELTA,
+ r, r+1);
+ ConvertToPS(dsw, dsw->sw.drawing_area->core.width - DELTA, 0 + DELTA,
+ r+2, r+3);
+ r[2] -= r[0];
+ r[3] -= r[1];
+
+ SubtractRects(&dsw->sw.dirty_areas, &dsw->sw.dirty_areas_size,
+ &dsw->sw.num_dirty_areas, r, 1);
+
+ GrowRectList(&dsw->sw.current_drawing, &dsw->sw.current_drawing_size,
+ 0, dsw->sw.num_dirty_areas, 1);
+ for (i = 0; i < 4 * dsw->sw.num_dirty_areas; i++) {
+ dsw->sw.current_drawing[i] = dsw->sw.dirty_areas[i];
+ }
+ dsw->sw.num_current_drawing = dsw->sw.num_dirty_areas;
+}
+
+static void CopyPendingExpose(DPSScrolledWindowWidget dsw)
+{
+ int dx, dy;
+ int i;
+ int *r;
+
+ ComputeOffsets(dsw, &dx, &dy);
+
+ for (i = 0; i < dsw->sw.num_pending_expose; i++) {
+ r = dsw->sw.pending_expose + 4*i;
+ XCopyArea(XtDisplay(dsw), dsw->sw.backing_pixmap,
+ XtWindow(dsw->sw.drawing_area),
+ dsw->sw.no_ge_gc,
+ LEFT(r) + dx, BOTTOM(r) + dy, WIDTH(r), HEIGHT(r),
+ LEFT(r), BOTTOM(r));
+ }
+ dsw->sw.num_pending_expose = dsw->sw.num_pending_dirty = 0;
+}
+
+static void UpdateWindowFromBackingPixmap(
+ DPSScrolledWindowWidget dsw,
+ float *rects,
+ int n)
+{
+ int dx, dy;
+ int llx, lly, urx, ury;
+ int i;
+ float *r;
+
+ ComputeOffsets(dsw, &dx, &dy);
+
+ for (i = 0; i < n; i++) {
+ r = rects + 4*i;
+ ConvertToX(dsw, LEFT(r), BOTTOM(r), &llx, &lly);
+ ConvertToX(dsw, RIGHT(r), TOP(r), &urx, &ury);
+
+ XCopyArea(XtDisplay(dsw), dsw->sw.backing_pixmap,
+ XtWindow(dsw->sw.drawing_area),
+ dsw->sw.no_ge_gc,
+ llx+dx-1, ury+dy-1, urx-llx+2, lly-ury+2, llx-1, ury-1);
+ }
+}
+
+static void UpdateWindowFromFeedbackPixmap(
+ DPSScrolledWindowWidget dsw,
+ float *rects,
+ int n)
+{
+ int llx, lly, urx, ury;
+ int i;
+ float *r;
+
+ for (i = 0; i < n; i++) {
+ r = rects + (i * 4);
+ ConvertToX(dsw, LEFT(r), BOTTOM(r), &llx, &lly);
+ ConvertToX(dsw, RIGHT(r), TOP(r), &urx, &ury);
+
+ XCopyArea(XtDisplay(dsw), dsw->sw.feedback_pixmap,
+ XtWindow(dsw->sw.drawing_area), dsw->sw.no_ge_gc,
+ llx-1, ury-1, urx-llx+2, lly-ury+2, llx-1, ury-1);
+ }
+}
+
+/* This is the heart of the drawing code; it does one piece of drawing.
+ It can be called either directly or as a work procedure */
+
+static Boolean DoDrawing(XtPointer clientData)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) clientData;
+ DSWResults results;
+ DSWDrawableType which;
+
+ if (dsw->sw.drawing_stage == DSWStart && dsw->sw.watch_progress &&
+ dsw->sw.backing_pixmap != None && dsw->sw.num_current_drawing == 0) {
+ dsw->sw.drawing_stage = DSWDrewVisible;
+ CopyWindowToBackingPixmap(dsw);
+ }
+
+ switch (dsw->sw.drawing_stage) {
+ case DSWStart:
+ case DSWDrawingVisible:
+ if (dsw->sw.watch_progress || dsw->sw.backing_pixmap == None) {
+ which = DSWWindow;
+ } else which = DSWBackingPixmap;
+ results = ClipAndDraw(dsw, which, DSWDrawSome,
+ (dsw->sw.drawing_stage == DSWStart));
+ if (results == DSWFinished) {
+ if (dsw->sw.watch_progress && dsw->sw.backing_pixmap != None) {
+ dsw->sw.drawing_stage = DSWDrewVisible;
+ CopyWindowToBackingPixmap(dsw);
+ } else {
+ if (dsw->sw.minimal_drawing && dsw->sw.big_pixmap) {
+ dsw->sw.drawing_stage = DSWDrewVisible;
+ SetCurrentDrawingToBackground(dsw);
+ } else {
+ dsw->sw.drawing_stage = DSWDone;
+ dsw->sw.num_dirty_areas = 0;
+ }
+ if (dsw->sw.num_pending_expose != 0 &&
+ dsw->sw.backing_pixmap != None) {
+ CopyPendingExpose(dsw);
+ }
+ }
+ } else dsw->sw.drawing_stage = DSWDrawingVisible;
+ break;
+
+ case DSWDrewVisible:
+ case DSWDrawingBackground:
+ results = ClipAndDraw(dsw, DSWBackingPixmap, DSWDrawSome,
+ (dsw->sw.drawing_stage == DSWDrewVisible));
+ if (results == DSWFinished) {
+ dsw->sw.drawing_stage = DSWDone;
+ dsw->sw.num_dirty_areas = 0;
+ }
+ else dsw->sw.drawing_stage = DSWDrawingBackground;
+ break;
+
+ case DSWDone:
+ break;
+ }
+
+ if (dsw->sw.drawing_stage == DSWDone && dsw->sw.num_pending_dirty != 0) {
+ CopyRectsToCurrentDrawing(dsw, dsw->sw.pending_dirty,
+ dsw->sw.num_pending_dirty);
+ CopyRectsToDirtyArea(dsw, dsw->sw.pending_dirty,
+ dsw->sw.num_pending_dirty);
+ dsw->sw.num_pending_dirty = 0;
+ dsw->sw.num_pending_expose = 0;
+ dsw->sw.drawing_stage = DSWStart;
+ }
+
+ if (dsw->sw.drawing_stage == DSWDone) {
+ dsw->sw.work = 0;
+ if (dsw->sw.watch_progress) {
+ /* Some of the background drawing may have been to areas that
+ are visible */
+ UpdateWindowFromBackingPixmap(dsw, dsw->sw.current_drawing,
+ dsw->sw.num_current_drawing);
+ }
+ dsw->sw.num_current_drawing = 0;
+ if (dsw->sw.scrolling) {
+ dsw->sw.scrolling = False;
+ ScrollMoved(dsw);
+ }
+ return True;
+ } else return False;
+}
+
+static void StartDrawing(DPSScrolledWindowWidget dsw)
+{
+ float r[4];
+
+ CopyRectsToCurrentDrawing(dsw, dsw->sw.dirty_areas,
+ dsw->sw.num_dirty_areas);
+
+ if (dsw->sw.watch_progress || dsw->sw.backing_pixmap == None) {
+ /* Intersect the current drawing area with the pending dirty area
+ (The pending dirty area represents the window exposures that
+ have happened so far) */
+ IntersectRects(&dsw->sw.current_drawing, &dsw->sw.current_drawing_size,
+ &dsw->sw.num_current_drawing,
+ dsw->sw.pending_dirty, dsw->sw.num_pending_dirty);
+ dsw->sw.num_pending_dirty = dsw->sw.num_pending_expose = 0;
+ } else {
+ if (!dsw->sw.big_pixmap || dsw->sw.minimal_drawing) {
+ /* Intersect the current drawing area to the window to start */
+ ConvertToPS(dsw, 0 + DELTA,
+ dsw->sw.drawing_area->core.height - DELTA, r, r+1);
+ ConvertToPS(dsw, dsw->sw.drawing_area->core.width - DELTA,
+ 0 + DELTA, r+2, r+3);
+ r[2] -= r[0];
+ r[3] -= r[1];
+ IntersectRects(&dsw->sw.current_drawing,
+ &dsw->sw.current_drawing_size,
+ &dsw->sw.num_current_drawing, r, 1);
+ }
+ }
+
+ if (dsw->sw.num_current_drawing == 0 && !dsw->sw.watch_progress) {
+ dsw->sw.drawing_stage = DSWFinished;
+ dsw->sw.num_dirty_areas = 0;
+ return;
+ }
+
+ dsw->sw.drawing_stage = DSWStart;
+ if (!DoDrawing((XtPointer) dsw)) {
+ dsw->sw.work =
+ XtAppAddWorkProc(XtWidgetToApplicationContext((Widget) dsw),
+ DoDrawing, (XtPointer) dsw);
+ }
+}
+
+static void RedisplaySliver(DPSScrolledWindowWidget dsw, int deltaX, int deltaY)
+{
+ float r[8];
+ int xr[8];
+ int n;
+ int xllx, xlly, xurx, xury;
+ float llx, lly, urx, ury;
+
+ /* If one of the deltas is 0, then the area to update is just a
+ single rectangle. */
+ if (deltaX == 0 || deltaY == 0) {
+ if (deltaX == 0) {
+ /* Just a single horizontal rectangle */
+
+ xllx = 0;
+ xurx = dsw->sw.drawing_area->core.width;
+ if (deltaY > 0) {
+ xlly = dsw->sw.drawing_area->core.height;
+ xury = dsw->sw.drawing_area->core.height - deltaY;
+ } else {
+ xlly = -deltaY;
+ xury = 0;
+ }
+
+ } else if (deltaY == 0) {
+ /* Just a single vertical rectangle */
+ xlly = dsw->sw.drawing_area->core.height;
+ xury = 0;
+ if (deltaX > 0) {
+ xllx = dsw->sw.drawing_area->core.width - deltaX;
+ xurx = dsw->sw.drawing_area->core.width;
+ } else {
+ xllx = 0;
+ xurx = -deltaX;
+ }
+ }
+ /* Convert the rectangle into PS coordinates */
+ ConvertToPS(dsw, xllx + DELTA, xlly - DELTA, &llx, &lly);
+ ConvertToPS(dsw, xurx - DELTA, xury + DELTA, &urx, &ury);
+ r[0] = llx;
+ r[1] = lly;
+ r[2] = urx - llx;
+ r[3] = ury - lly;
+ xr[0] = xllx;
+ xr[1] = xury;
+ xr[2] = xurx - xllx;
+ xr[3] = xlly - xury;
+ n = 1;
+
+ } else {
+ /* Scrolling in both directions, so there are two rectangles.
+ It's easiest to do if we let them overlap; fortunately that is
+ legal! First do the horizontal rectangle. */
+ xllx = 0;
+ xurx = dsw->sw.drawing_area->core.width;
+ if (deltaY > 0) {
+ xlly = dsw->sw.drawing_area->core.height;
+ xury = dsw->sw.drawing_area->core.height - deltaY;
+ } else {
+ xlly = -deltaY;
+ xury = 0;
+ }
+ ConvertToPS(dsw, xllx + DELTA, xlly - DELTA, &llx, &lly);
+ ConvertToPS(dsw, xurx - DELTA, xury + DELTA, &urx, &ury);
+
+ /* Store in point array */
+ r[0] = llx;
+ r[1] = lly;
+ r[2] = urx - llx;
+ r[3] = ury - lly;
+ xr[0] = xllx;
+ xr[1] = xury;
+ xr[2] = xurx - xllx;
+ xr[3] = xlly - xury;
+
+ /* Now do vertical rectangle and store in point array */
+ xlly = dsw->sw.drawing_area->core.height;
+ xury = 0;
+ if (deltaX > 0) {
+ xllx = dsw->sw.drawing_area->core.width - deltaX;
+ xurx = dsw->sw.drawing_area->core.width;
+ } else {
+ xllx = 0;
+ xurx = -deltaX;
+ }
+ ConvertToPS(dsw, xllx + DELTA, xlly - DELTA, &llx, &lly);
+ ConvertToPS(dsw, xurx - DELTA, xury + DELTA, &urx, &ury);
+ r[4] = llx;
+ r[5] = lly;
+ r[6] = urx - llx;
+ r[7] = ury - lly;
+ xr[4] = xllx;
+ xr[5] = xury;
+ xr[6] = xurx - xllx;
+ xr[7] = xlly - xury;
+ n = 2;
+ }
+
+ AddRectsToDirtyArea(dsw, r, n);
+ AddRectsToPending(dsw, xr, n);
+ StartDrawing(dsw);
+}
+
+static void SetUpInitialPixmap(DPSScrolledWindowWidget dsw)
+{
+ float *r = dsw->sw.dirty_areas;
+ int llx, lly, urx, ury;
+
+ CreateBackingPixmap(dsw);
+ if (dsw->sw.backing_pixmap != None) {
+ XDPSSetContextDrawable(dsw->sw.context, dsw->sw.backing_pixmap,
+ dsw->sw.pixmap_height);
+
+ SetPixmapOffset(dsw);
+ SetPixmapOrigin(dsw);
+ XDPSCaptureContextGState(dsw->sw.context, &dsw->sw.backing_gstate);
+
+ if (dsw->sw.pixmap_width != CEIL(dsw->sw.drawing_width) ||
+ dsw->sw.pixmap_height != CEIL(dsw->sw.drawing_height)) {
+
+ /* Make the dirty area match the window */
+ if (dsw->sw.pixmap_width > (int)dsw->sw.drawing_area->core.width) {
+ llx = dsw->sw.origin_x;
+ urx = llx + CEIL(dsw->sw.drawing_width);
+ } else {
+ llx = 0;
+ urx = dsw->sw.drawing_area->core.width;
+ }
+ if (dsw->sw.pixmap_height >
+ (int) dsw->sw.drawing_area->core.height) {
+ lly = dsw->sw.origin_y;
+ ury = dsw->sw.origin_y - CEIL(dsw->sw.drawing_height);
+ } else {
+ lly = dsw->sw.drawing_area->core.height;
+ ury = 0;
+ }
+ ConvertToPS(dsw, llx + DELTA, lly - DELTA, r, r+1);
+ ConvertToPS(dsw, urx - DELTA, ury + DELTA, r+2, r+3);
+ r[2] -= r[0];
+ r[3] -= r[1];
+ dsw->sw.num_dirty_areas = 1;
+ }
+ if (dsw->sw.doing_feedback) {
+ CopyRectsToCurrentDrawing(dsw, dsw->sw.dirty_areas,
+ dsw->sw.num_dirty_areas);
+ FinishDrawing(dsw);
+ } else if (!dsw->sw.watch_progress) StartDrawing(dsw);
+ }
+}
+
+/* ARGSUSED */
+
+static void TimerStart(XtPointer clientData, XtIntervalId *id)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) clientData;
+
+ if (dsw->sw.drawing_stage == DSWStart) StartDrawing(dsw);
+}
+
+static void SetUpInitialInformation(DPSScrolledWindowWidget dsw)
+{
+ int i;
+ float llx, lly, urx, ury;
+ float xScale, yScale;
+ XExposeEvent ev;
+ XStandardColormap colorCube, grayRamp;
+ int match;
+
+ /* If the context's colormap matches the widget's colormap, assume that
+ everything is already set up right in the color cube department. This
+ allows an application to supply us with a custom color cube by
+ installing it in the context before calling us */
+
+ _DPSSWColormapMatch(dsw->sw.context,
+ dsw->sw.drawing_area->core.colormap, &match);
+
+ if (match) {
+ XDPSSetContextParameters(dsw->sw.context, XtScreen(dsw),
+ dsw->sw.drawing_area->core.depth,
+ XtWindow(dsw->sw.drawing_area),
+ dsw->sw.drawing_area->core.height, NULL, NULL,
+ XDPSContextScreenDepth | XDPSContextDrawable);
+ } else {
+ grayRamp.colormap = colorCube.colormap =
+ dsw->sw.drawing_area->core.colormap;
+
+ XDPSCreateStandardColormaps(XtDisplay(dsw), XtWindow(dsw),
+ (Visual *) NULL, 0, 0, 0, 0,
+ &colorCube, &grayRamp, False);
+
+ XDPSSetContextParameters(dsw->sw.context, XtScreen(dsw),
+ dsw->sw.drawing_area->core.depth,
+ XtWindow(dsw->sw.drawing_area),
+ dsw->sw.drawing_area->core.height,
+ (XDPSStandardColormap *) &colorCube,
+ (XDPSStandardColormap *) &grayRamp,
+ XDPSContextScreenDepth | XDPSContextDrawable |
+ XDPSContextRGBMap | XDPSContextGrayMap);
+ }
+
+ DPSinitgraphics(dsw->sw.context);
+ _DPSSWGetTransform(dsw->sw.context, dsw->sw.ctm, dsw->sw.orig_inv_ctm);
+ dsw->sw.x_offset = 0;
+ dsw->sw.y_offset = dsw->sw.drawing_area->core.height;
+ for (i = 0; i < 6; i++) dsw->sw.inv_ctm[i] = dsw->sw.orig_inv_ctm[i];
+
+ ConvertToPS(dsw, 0.0, 100.0, &llx, &lly);
+ ConvertToPS(dsw, 100.0, 0.0, &urx, &ury);
+ xScale = ABS(100.0 / (urx - llx));
+ yScale = ABS(100.0 / (ury - lly));
+
+ if (dsw->sw.scale != 1.0) {
+ DPSscale(dsw->sw.context, dsw->sw.scale, dsw->sw.scale);
+ _DPSSWGetTransform(dsw->sw.context, dsw->sw.ctm, dsw->sw.inv_ctm);
+ }
+
+ dsw->sw.drawing_width = dsw->sw.area_width * xScale * dsw->sw.scale;
+ dsw->sw.drawing_height = dsw->sw.area_height * yScale * dsw->sw.scale;
+
+ dsw->sw.unscaled_width = dsw->sw.drawing_width / dsw->sw.scale + 1;
+ dsw->sw.unscaled_height = dsw->sw.drawing_height / dsw->sw.scale + 1;
+
+ if (!dsw->sw.use_saved_scroll) {
+ dsw->sw.scroll_pic_x = dsw->sw.area_width / 2;
+ dsw->sw.scroll_pic_y = dsw->sw.area_height / 2;
+ dsw->sw.scroll_win_x = dsw->sw.drawing_area->core.width / 2;
+ dsw->sw.scroll_win_y = dsw->sw.drawing_area->core.height / 2;
+ }
+
+ SetDrawingAreaPosition(dsw, dsw->sw.scroll_pic_x, dsw->sw.scroll_pic_y,
+ dsw->sw.scroll_win_x, dsw->sw.scroll_win_y, True);
+ SetOriginAndGetTransform(dsw);
+ XDPSCaptureContextGState(dsw->sw.context, &dsw->sw.window_gstate);
+
+ dsw->sw.drawing_stage = DSWStart;
+
+ if (dsw->sw.use_backing_pixmap) SetUpInitialPixmap(dsw);
+
+ if (dsw->sw.doing_feedback) return;
+
+ if (dsw->sw.watch_progress || dsw->sw.backing_pixmap == None) {
+ /* If watching progress or no pixmap, clear the window to ensure
+ that things get started */
+ XClearArea(XtDisplay(dsw), XtWindow(dsw->sw.drawing_area),
+ 0, 0, 0, 0, True);
+ XSync(XtDisplay(dsw), False);
+ if (dsw->sw.watch_progress && dsw->sw.watch_progress_delay > 0) {
+ /* Set a timer so that we start drawing if nothing is visible */
+ (void) XtAppAddTimeOut(XtWidgetToApplicationContext((Widget) dsw),
+ dsw->sw.watch_progress_delay,
+ TimerStart, (XtPointer) dsw);
+ }
+ } else {
+ /* Put a synthetic expose event in the pending queue */
+ ev.x = ev.y = 0;
+ ev.width = dsw->sw.drawing_area->core.width;
+ ev.height = dsw->sw.drawing_area->core.height;
+ SplitExposeEvent(dsw, &ev);
+ }
+}
+
+static void Realize(
+ Widget w,
+ XtValueMask *mask,
+ XSetWindowAttributes *attr)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+ DSWSetupCallbackRec setup;
+
+ /* Let my parent do all the hard work */
+ (*dpsScrolledWindowClassRec.core_class.superclass->core_class.realize)
+ (w, mask, attr);
+
+ /* We delay calling the setup callback so that the caller can use
+ XtAddCallback to add it */
+ setup.context = dsw->sw.context;
+ XtCallCallbackList((Widget) dsw, dsw->sw.setup_callback,
+ (XtPointer) &setup);
+
+ /* Now, explicitly realize my children */
+ XtRealizeWidget(dsw->sw.scrolled_window);
+
+ /* Et voila, now we have windows! */
+ SetUpInitialInformation(dsw);
+}
+
+static void AbortOrFinish(DPSScrolledWindowWidget dsw)
+{
+ DSWResults results;
+ DSWDrawableType which;
+
+ if (dsw->sw.work != 0) {
+ XtRemoveWorkProc(dsw->sw.work);
+ dsw->sw.work = 0;
+ }
+
+ switch (dsw->sw.drawing_stage) {
+ case DSWStart:
+ return;
+ /* break; */
+
+ case DSWDrawingVisible:
+ if (dsw->sw.watch_progress || dsw->sw.backing_pixmap == None) {
+ which = DSWWindow;
+ } else which = DSWBackingPixmap;
+ results = ClipAndDraw(dsw, which, DSWAbortOrFinish, False);
+ if (results == DSWAborted) {
+ dsw->sw.drawing_stage = DSWStart;
+ if (dsw->sw.backing_pixmap == None || dsw->sw.watch_progress) {
+ /* Add the current drawing area back into the pending
+ expose area */
+ AddUserSpaceRectsToPending(dsw, dsw->sw.current_drawing,
+ dsw->sw.num_current_drawing);
+ }
+ return;
+ }
+ if (dsw->sw.watch_progress && dsw->sw.backing_pixmap != None) {
+ dsw->sw.drawing_stage = DSWDrewVisible;
+ CopyWindowToBackingPixmap(dsw);
+ if (dsw->sw.num_current_drawing != 0) {
+ results = ClipAndDraw(dsw, DSWBackingPixmap,
+ DSWAbortOrFinish, True);
+ }
+ if (results == DSWAborted) {
+ dsw->sw.drawing_stage = DSWStart;
+ return;
+ }
+ } else {
+ if (dsw->sw.backing_pixmap != None) {
+ if (dsw->sw.num_pending_expose != 0) {
+ CopyPendingExpose(dsw);
+ }
+
+ if (dsw->sw.minimal_drawing && dsw->sw.big_pixmap) {
+ dsw->sw.drawing_stage = DSWDrewVisible;
+ SetCurrentDrawingToBackground(dsw);
+ results = ClipAndDraw(dsw, which,
+ DSWAbortOrFinish, True);
+ if (results == DSWAborted) {
+ dsw->sw.drawing_stage = DSWStart;
+ return;
+ }
+ }
+ }
+ }
+ break;
+
+ case DSWDrewVisible:
+ case DSWDrawingBackground:
+ results = ClipAndDraw(dsw, DSWBackingPixmap, DSWAbortOrFinish,
+ (dsw->sw.drawing_stage == DSWDrewVisible));
+ if (results == DSWAborted) {
+ dsw->sw.drawing_stage = DSWStart;
+ return;
+ }
+ break;
+
+ case DSWDone:
+ break;
+ }
+
+ dsw->sw.drawing_stage = DSWDone;
+ dsw->sw.num_dirty_areas = 0;
+ return;
+}
+
+static void AbortDrawing(DPSScrolledWindowWidget dsw)
+{
+ DSWDrawableType which;
+
+ if (dsw->sw.work != 0) {
+ XtRemoveWorkProc(dsw->sw.work);
+ dsw->sw.work = 0;
+ }
+
+ switch (dsw->sw.drawing_stage) {
+ case DSWStart:
+ case DSWDone:
+ case DSWDrewVisible:
+ break;
+
+ case DSWDrawingVisible:
+ if (dsw->sw.watch_progress || dsw->sw.backing_pixmap == None) {
+ which = DSWWindow;
+ } else which = DSWBackingPixmap;
+ (void) ClipAndDraw(dsw, which, DSWAbort, False);
+ break;
+
+ case DSWDrawingBackground:
+ (void) ClipAndDraw(dsw, DSWBackingPixmap, DSWAbort, False);
+ break;
+
+ }
+
+ dsw->sw.num_pending_expose = dsw->sw.num_pending_dirty = 0;
+}
+
+static void FinishDrawing(DPSScrolledWindowWidget dsw)
+{
+ DSWDrawableType which;
+
+ if (dsw->sw.work != 0) {
+ XtRemoveWorkProc(dsw->sw.work);
+ dsw->sw.work = 0;
+ }
+
+ switch (dsw->sw.drawing_stage) {
+ case DSWStart:
+ case DSWDrawingVisible:
+ if (dsw->sw.watch_progress || dsw->sw.backing_pixmap == None) {
+ which = DSWWindow;
+ } else which = DSWBackingPixmap;
+ if (dsw->sw.drawing_stage == DSWStart) {
+ ClipToDrawingSize(dsw, which);
+ if (dsw->sw.num_current_drawing == 0) return;
+ }
+ (void) ClipAndDraw(dsw, which, DSWFinish,
+ dsw->sw.drawing_stage == DSWStart);
+ if (dsw->sw.watch_progress && dsw->sw.backing_pixmap != None) {
+ dsw->sw.drawing_stage = DSWDrewVisible;
+ CopyWindowToBackingPixmap(dsw);
+ if (dsw->sw.num_current_drawing != 0) {
+ (void) ClipAndDraw(dsw, DSWBackingPixmap, DSWFinish, True);
+ }
+ } else {
+ if (dsw->sw.backing_pixmap != None) {
+ if (dsw->sw.num_pending_expose != 0) {
+ CopyPendingExpose(dsw);
+ }
+
+ if (dsw->sw.minimal_drawing && dsw->sw.big_pixmap) {
+ dsw->sw.drawing_stage = DSWDrewVisible;
+ SetCurrentDrawingToBackground(dsw);
+ (void) ClipAndDraw(dsw, which, DSWFinish, True);
+ }
+ }
+ }
+ break;
+
+ case DSWDrewVisible:
+ case DSWDrawingBackground:
+ (void) ClipAndDraw(dsw, DSWBackingPixmap, DSWFinish,
+ (dsw->sw.drawing_stage == DSWDrewVisible));
+ break;
+
+ case DSWDone:
+ break;
+ }
+
+ dsw->sw.drawing_stage = DSWDone;
+ dsw->sw.num_dirty_areas = 0;
+}
+
+static void DoScroll(
+ DPSScrolledWindowWidget dsw,
+ int deltaX, int deltaY)
+{
+ /* Set the PS origin in the X window to the new settings of
+ the scrollbars */
+ dsw->sw.origin_x -= deltaX;
+ dsw->sw.origin_y -= deltaY;
+
+ /* Update the graphics states for the window and backing pixmap to
+ reflect new origin */
+ (void) XDPSSetContextGState(dsw->sw.context, dsw->sw.window_gstate);
+ SetOriginAndGetTransform(dsw);
+ (void) XDPSUpdateContextGState(dsw->sw.context, dsw->sw.window_gstate);
+
+ if (dsw->sw.backing_pixmap != None && !dsw->sw.big_pixmap) {
+ (void) XDPSSetContextGState(dsw->sw.context, dsw->sw.backing_gstate);
+ SetPixmapOrigin(dsw);
+ (void) XDPSUpdateContextGState(dsw->sw.context,
+ dsw->sw.backing_gstate);
+ }
+
+ /* Update the stored position of the scroll bars */
+ dsw->sw.scroll_x += deltaX;
+ dsw->sw.scroll_y += deltaY;
+}
+
+static void ShiftPendingExpose(
+ DPSScrolledWindowWidget dsw,
+ int deltaX, int deltaY)
+{
+ int i;
+ int *r;
+
+ for (i = 0; i < dsw->sw.num_pending_expose; i++) {
+ r = dsw->sw.pending_expose + 4*i;
+ r[0] -= deltaX;
+ r[1] -= deltaY;
+ }
+}
+
+static void HScrollCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) clientData;
+ XmScrollBarCallbackStruct *sb = (XmScrollBarCallbackStruct *) callData;
+
+ if (!dsw->sw.application_scrolling) {
+ dsw->sw.scroll_h_value = sb->value;
+ ScrollMoved(dsw);
+ }
+}
+
+static void VScrollCallback(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) clientData;
+ XmScrollBarCallbackStruct *sb = (XmScrollBarCallbackStruct *) callData;
+
+ if (!dsw->sw.application_scrolling) {
+ dsw->sw.scroll_v_value = sb->value;
+ ScrollMoved(dsw);
+ }
+}
+
+/* ARGSUSED */
+
+static void ScrollMoved(DPSScrolledWindowWidget dsw)
+{
+ int deltaX, deltaY;
+
+ /* If we haven't started drawing yet, it must be because we're waiting
+ for GraphicsExpose events. Delay scrolling until they come in */
+ if (dsw->sw.scrolling && dsw->sw.drawing_stage == DSWStart) return;
+
+ /* Calculate the delta in the scrolling */
+ deltaX = dsw->sw.scroll_h_value - dsw->sw.scroll_x;
+ deltaY = dsw->sw.scroll_v_value - dsw->sw.scroll_y;
+
+ /* If there is some scrolling to do, then scroll the pixmap and
+ copy the pixmap to the window */
+ if (deltaX == 0 && deltaY == 0) return;
+
+ ShiftPendingExpose(dsw, deltaX, deltaY);
+
+ AbortOrFinish(dsw);
+
+ DoScroll(dsw, deltaX, deltaY);
+
+ if (!dsw->sw.big_pixmap) {
+ /* Copy visible area to new location */
+ if (dsw->sw.backing_pixmap != None) {
+ XCopyArea(XtDisplay(dsw), dsw->sw.backing_pixmap,
+ dsw->sw.backing_pixmap, dsw->sw.no_ge_gc,
+ deltaX, deltaY, dsw->sw.drawing_area->core.width,
+ dsw->sw.drawing_area->core.height, 0, 0);
+ if (!dsw->sw.doing_feedback || dsw->sw.feedback_pixmap == None) {
+ XCopyArea(XtDisplay(dsw), dsw->sw.backing_pixmap,
+ XtWindow(dsw->sw.drawing_area), dsw->sw.no_ge_gc,
+ 0, 0, dsw->sw.drawing_area->core.width,
+ dsw->sw.drawing_area->core.height, 0, 0);
+ }
+ RedisplaySliver(dsw, deltaX, deltaY);
+ } else {
+ if (!dsw->sw.doing_feedback || dsw->sw.feedback_pixmap == None) {
+ XCopyArea(XtDisplay(dsw), XtWindow(dsw->sw.drawing_area),
+ XtWindow(dsw->sw.drawing_area), dsw->sw.ge_gc,
+ deltaX, deltaY, dsw->sw.drawing_area->core.width,
+ dsw->sw.drawing_area->core.height, 0, 0);
+ }
+ if (dsw->sw.doing_feedback) RedisplaySliver(dsw, deltaX, deltaY);
+ else dsw->sw.drawing_stage = DSWStart;
+ }
+ }
+
+ if (dsw->sw.doing_feedback) {
+ float *r;
+
+ FinishDrawing(dsw);
+
+ r = dsw->sw.prev_dirty_areas;
+ ConvertToPS(dsw, 0 + DELTA, dsw->sw.drawing_area->core.height - DELTA,
+ r, r+1);
+ ConvertToPS(dsw, dsw->sw.drawing_area->core.width - DELTA, 0 + DELTA,
+ r+2, r+3);
+ r[2] -= r[0];
+ r[3] -= r[1];
+ dsw->sw.num_prev_dirty_areas = 1;
+
+ if (dsw->sw.feedback_pixmap != None) {
+ XDPSSetContextDrawable(dsw->sw.context, dsw->sw.feedback_pixmap,
+ dsw->sw.drawing_area->core.height);
+ SetPixmapOrigin(dsw);
+ XDPSCaptureContextGState(dsw->sw.context,
+ &dsw->sw.feedback_gstate);
+
+ /* Initialize the feedback pixmap with a copy of the drawing */
+ if (dsw->sw.backing_pixmap != None) {
+ CopyToFeedbackPixmap(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ } else {
+ CopyRectsToCurrentDrawing(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ (void) ClipAndDraw(dsw, DSWFeedbackPixmap, DSWFinish, True);
+ }
+ if (!dsw->sw.feedback_displayed) {
+ XCopyArea(XtDisplay(dsw), dsw->sw.feedback_pixmap,
+ XtWindow(dsw->sw.drawing_area),
+ dsw->sw.no_ge_gc, 0, 0,
+ dsw->sw.drawing_area->core.width,
+ dsw->sw.drawing_area->core.height, 0, 0);
+ }
+ }
+
+ if (dsw->sw.feedback_displayed) {
+ CallFeedbackCallback(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ }
+ if (dsw->sw.feedback_pixmap != None) {
+ UpdateWindowFromFeedbackPixmap(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ }
+ dsw->sw.num_pending_dirty = dsw->sw.num_pending_expose = 0;
+
+ } else {
+ if (dsw->sw.backing_pixmap != None &&
+ dsw->sw.drawing_stage == DSWDone) {
+ ComputeOffsets(dsw, &deltaX, &deltaY);
+ if (!dsw->sw.big_pixmap) dsw->sw.scrolling = True;
+
+ XCopyArea(XtDisplay(dsw), dsw->sw.backing_pixmap,
+ XtWindow(dsw->sw.drawing_area), dsw->sw.no_ge_gc,
+ deltaX, deltaY,
+ dsw->sw.drawing_area->core.width,
+ dsw->sw.drawing_area->core.height, 0, 0);
+ } else dsw->sw.scrolling = True;
+ }
+}
+
+static void AddExposureToPending(
+ DPSScrolledWindowWidget dsw,
+ XExposeEvent *ev)
+{
+ float *f;
+ int *i;
+
+ if (dsw->sw.backing_pixmap == None || dsw->sw.watch_progress ||
+ dsw->sw.doing_feedback) {
+ GrowRectList(&dsw->sw.pending_dirty, &dsw->sw.pending_dirty_size,
+ dsw->sw.num_pending_dirty, 1, 1);
+
+ f = dsw->sw.pending_dirty + (dsw->sw.num_pending_dirty * 4);
+ ConvertToPS(dsw, ev->x + DELTA, ev->y + ev->height - DELTA, f, f+1);
+ ConvertToPS(dsw, ev->x + ev->width - DELTA, ev->y + DELTA, f+2, f+3);
+ f[2] -= f[0];
+ f[3] -= f[1];
+ dsw->sw.num_pending_dirty++;
+ }
+
+ GrowIntRectList(&dsw->sw.pending_expose, &dsw->sw.pending_expose_size,
+ dsw->sw.num_pending_expose, 1, 1);
+
+ i = dsw->sw.pending_expose + (dsw->sw.num_pending_expose * 4);
+ i[0] = ev->x;
+ i[1] = ev->y;
+ i[2] = ev->width;
+ i[3] = ev->height;
+ dsw->sw.num_pending_expose++;
+}
+
+static void AddRectsToPending(
+ DPSScrolledWindowWidget dsw,
+ int *newRect,
+ int n)
+{
+ int *r;
+ int i;
+ float *f;
+
+ if (dsw->sw.backing_pixmap == None || dsw->sw.watch_progress) {
+ GrowRectList(&dsw->sw.pending_dirty, &dsw->sw.pending_dirty_size,
+ dsw->sw.num_pending_dirty, n, 1);
+
+ for (i = 0; i < n; i++) {
+ f = dsw->sw.pending_dirty + (dsw->sw.num_pending_dirty * 4);
+ r = newRect + (i * 4);
+ ConvertToPS(dsw, r[0] + DELTA, r[1] + r[3] - DELTA, f, f+1);
+ ConvertToPS(dsw, r[0] + r[2] - DELTA, r[1] + DELTA, f+2, f+3);
+ f[2] -= f[0];
+ f[3] -= f[1];
+ dsw->sw.num_pending_dirty++;
+ }
+ }
+
+ GrowIntRectList(&dsw->sw.pending_expose, &dsw->sw.pending_expose_size,
+ dsw->sw.num_pending_expose, n, 1);
+
+ r = dsw->sw.pending_expose + (dsw->sw.num_pending_expose * 4);
+ for (i = 0; i < 4*n; i++) r[i] = newRect[i];
+ dsw->sw.num_pending_expose += n;
+}
+
+static void AddUserSpaceRectsToPending(
+ DPSScrolledWindowWidget dsw,
+ float *newRect,
+ int n)
+{
+ int *r;
+ int i;
+ float *f;
+
+ if (dsw->sw.backing_pixmap == None || dsw->sw.watch_progress) {
+ GrowRectList(&dsw->sw.pending_dirty, &dsw->sw.pending_dirty_size,
+ dsw->sw.num_pending_dirty, n, 1);
+
+ f = dsw->sw.pending_dirty + (dsw->sw.num_pending_dirty * 4);
+ for (i = 0; i < 4*n; i++) f[i] = newRect[i];
+ dsw->sw.num_pending_dirty += n;
+ }
+
+ GrowIntRectList(&dsw->sw.pending_expose, &dsw->sw.pending_expose_size,
+ dsw->sw.num_pending_expose, n, 1);
+
+ for (i = 0; i < n; i++) {
+ r = dsw->sw.pending_expose + (dsw->sw.num_pending_expose * 4);
+ f = newRect + (i * 4);
+ ConvertToX(dsw, LEFT(f), TOP(f), r, r+1);
+ ConvertToX(dsw, RIGHT(f), BOTTOM(f), r+2, r+3);
+ r[2] -= r[0];
+ r[3] -= r[1];
+ dsw->sw.num_pending_expose++;
+ }
+}
+
+static void CopyRectsToCurrentDrawing(
+ DPSScrolledWindowWidget dsw,
+ float *newRect,
+ int n)
+{
+ float *r;
+ int i;
+
+ GrowRectList(&dsw->sw.current_drawing, &dsw->sw.current_drawing_size,
+ 0, n, 1);
+
+ r = dsw->sw.current_drawing;
+ for (i = 0; i < 4*n; i++) r[i] = newRect[i];
+ dsw->sw.num_current_drawing = n;
+}
+
+static void CopyRectsToDirtyArea(
+ DPSScrolledWindowWidget dsw,
+ float *newRect,
+ int n)
+{
+ float *r;
+ int i;
+
+ GrowRectList(&dsw->sw.dirty_areas, &dsw->sw.dirty_areas_size, 0, n, 1);
+
+ r = dsw->sw.dirty_areas;
+ for (i = 0; i < 4*n; i++) r[i] = newRect[i];
+ dsw->sw.num_dirty_areas = n;
+}
+
+static void AddRectsToDirtyArea(
+ DPSScrolledWindowWidget dsw,
+ float *newRect,
+ int n)
+{
+ float *r;
+ int i;
+
+ GrowRectList(&dsw->sw.dirty_areas, &dsw->sw.dirty_areas_size,
+ dsw->sw.num_dirty_areas, n, 1);
+
+ r = dsw->sw.dirty_areas + (4 * dsw->sw.num_dirty_areas);
+ for (i = 0; i < 4*n; i++) r[i] = newRect[i];
+ dsw->sw.num_dirty_areas += n;
+}
+
+static void CopyRectsToPrevDirtyArea(
+ DPSScrolledWindowWidget dsw,
+ float *newRect,
+ int n)
+{
+ float *r;
+ int i;
+
+ GrowRectList(&dsw->sw.prev_dirty_areas,
+ &dsw->sw.prev_dirty_areas_size, 0, n, 1);
+
+ r = dsw->sw.prev_dirty_areas;
+ for (i = 0; i < 4*n; i++) r[i] = newRect[i];
+ dsw->sw.num_prev_dirty_areas = n;
+}
+
+/* ARGSUSED */
+
+static void DrawingAreaGraphicsExpose(
+ Widget w,
+ XtPointer clientData,
+ XEvent *event,
+ Boolean *goOn)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) clientData;
+ XExposeEvent *ev = (XExposeEvent *) event;
+
+ switch (event->type) {
+ case GraphicsExpose:
+ /* GraphicsExpose occur during unbuffered scrolling */
+ if (dsw->sw.backing_pixmap == None && dsw->sw.scrolling) {
+ /* Unbuffered scrolling case */
+ AddExposureToPending(dsw, ev);
+
+ if (ev->count == 0) {
+ AddRectsToDirtyArea(dsw, dsw->sw.pending_dirty,
+ dsw->sw.num_pending_dirty);
+ StartDrawing(dsw);
+ dsw->sw.num_pending_dirty = dsw->sw.num_pending_expose = 0;
+ }
+ }
+ break;
+ }
+}
+
+static Boolean MoreExposes(Widget w)
+{
+ XEvent event;
+
+ if (XPending(XtDisplay(w)) > 0) {
+ if (XCheckTypedWindowEvent(XtDisplay(w), XtWindow(w),
+ Expose, &event)) {
+ XPutBackEvent(XtDisplay(w), &event);
+ return True;;
+ }
+ }
+ return False;
+}
+
+static void DrawingAreaExpose(
+ Widget w,
+ XtPointer clientData, XtPointer callData)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) clientData;
+ XmDrawingAreaCallbackStruct *d = (XmDrawingAreaCallbackStruct *) callData;
+ XExposeEvent *ev = (XExposeEvent *) d->event;
+ int dx, dy;
+
+ if (dsw->sw.doing_feedback) {
+ if (dsw->sw.feedback_pixmap != None) {
+ XCopyArea(XtDisplay(dsw), dsw->sw.feedback_pixmap,
+ XtWindow(dsw->sw.drawing_area),
+ dsw->sw.no_ge_gc,
+ ev->x, ev->y, ev->width, ev->height, ev->x, ev->y);
+ } else {
+ if (dsw->sw.backing_pixmap != None) {
+ ComputeOffsets(dsw, &dx, &dy);
+
+ XCopyArea(XtDisplay(dsw), dsw->sw.backing_pixmap,
+ XtWindow(dsw->sw.drawing_area),
+ dsw->sw.no_ge_gc, ev->x + dx, ev->y + dy,
+ ev->width, ev->height, ev->x, ev->y);
+ }
+ AddExposureToPending(dsw, ev);
+ if (ev->count != 0 || MoreExposes(w)) return;
+
+ if (dsw->sw.backing_pixmap == None) {
+ CopyRectsToCurrentDrawing(dsw, dsw->sw.pending_dirty,
+ dsw->sw.num_pending_dirty);
+ dsw->sw.drawing_stage = DSWStart;
+ FinishDrawing(dsw);
+ }
+ if (dsw->sw.feedback_displayed) {
+ CallFeedbackCallback(dsw, dsw->sw.pending_dirty,
+ dsw->sw.num_pending_dirty);
+ }
+ dsw->sw.num_pending_dirty = dsw->sw.num_pending_expose = 0;
+ }
+ return;
+ }
+
+ if (dsw->sw.backing_pixmap != None) {
+ if (dsw->sw.drawing_stage == DSWStart && dsw->sw.watch_progress) {
+ SplitExposeEvent(dsw, ev);
+ if (ev->count == 0) {
+ if (MoreExposes(w)) return;
+ StartDrawing(dsw);
+ dsw->sw.num_pending_dirty = dsw->sw.num_pending_expose = 0;
+ }
+ return;
+ }
+
+ if (dsw->sw.drawing_stage < DSWDrewVisible) {
+ SplitExposeEvent(dsw, ev);
+ return;
+ }
+ ComputeOffsets(dsw, &dx, &dy);
+
+ XCopyArea(XtDisplay(dsw), dsw->sw.backing_pixmap,
+ XtWindow(dsw->sw.drawing_area),
+ dsw->sw.no_ge_gc,
+ ev->x + dx, ev->y + dy, ev->width, ev->height, ev->x, ev->y);
+ } else {
+ AddExposureToPending(dsw, ev);
+ if (ev->count == 0) {
+ if (MoreExposes(w)) return;
+ if (dsw->sw.drawing_stage == DSWDone ||
+ dsw->sw.drawing_stage == DSWStart) {
+ CopyRectsToDirtyArea(dsw, dsw->sw.pending_dirty,
+ dsw->sw.num_pending_dirty);
+ StartDrawing(dsw);
+ dsw->sw.num_pending_dirty = dsw->sw.num_pending_expose = 0;
+ }
+ }
+ }
+}
+
+static void Resize(Widget w)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+ DSWResizeCallbackRec r;
+ float x, y;
+
+ if (XtIsRealized(w)) (void) AbortOrFinish(dsw);
+
+ r.oldw = dsw->sw.scrolled_window->core.width;
+ r.oldh = dsw->sw.scrolled_window->core.height;
+ r.neww = dsw->core.width;
+ r.newh = dsw->core.height;
+ r.x = r.y = 0;
+
+ XtCallCallbackList(w, dsw->sw.resize_callback, (XtPointer) &r);
+
+ if (XtIsRealized(w)) {
+ ConvertToPS(dsw, (float) r.x, (float) r.y, &x, &y);
+ } else if (r.x != 0 || r.y != 0) ScrollBy(w, r.x, r.y);
+
+ XtResizeWidget(dsw->sw.scrolled_window, w->core.width, w->core.height, 0);
+
+ if (!XtIsRealized(w)) return;
+
+ if (dsw->sw.backing_pixmap != None &&
+ dsw->sw.pixmap_width == CEIL(dsw->sw.drawing_width) &&
+ dsw->sw.pixmap_height == CEIL(dsw->sw.drawing_height) &&
+ dsw->sw.pixmap_width >= (int) dsw->sw.drawing_area->core.width &&
+ dsw->sw.pixmap_height >= (int) dsw->sw.drawing_area->core.width) {
+
+ XDPSSetContextGState(dsw->sw.context, dsw->sw.window_gstate);
+ DPSinitclip(dsw->sw.context);
+ DPSinitviewclip(dsw->sw.context);
+ SetDrawingAreaPosition(dsw, x, y, r.x, r.y, True);
+ SetOriginAndGetTransform(dsw);
+ XDPSUpdateContextGState(dsw->sw.context, dsw->sw.window_gstate);
+ XClearArea(XtDisplay(dsw), XtWindow(dsw->sw.drawing_area),
+ 0, 0, 0, 0, True);
+ } else {
+ dsw->sw.use_saved_scroll = True;
+ dsw->sw.scroll_pic_x = x;
+ dsw->sw.scroll_pic_y = y;
+ dsw->sw.scroll_win_x = r.x;
+ dsw->sw.scroll_win_y = r.y;
+
+ if (dsw->sw.backing_pixmap != None) {
+ XFreePixmap(XtDisplay(dsw), dsw->sw.backing_pixmap);
+ XDPSFreeContextGState(dsw->sw.context, dsw->sw.backing_gstate);
+ }
+ dsw->sw.backing_pixmap = None;
+ dsw->sw.big_pixmap = False;
+ dsw->sw.pixmap_width = dsw->sw.pixmap_height = 0;
+
+ dsw->sw.num_dirty_areas = 1;
+ LEFT(dsw->sw.dirty_areas) = 0.0;
+ BOTTOM(dsw->sw.dirty_areas) = 0.0;
+ WIDTH(dsw->sw.dirty_areas) = dsw->sw.area_width;
+ HEIGHT(dsw->sw.dirty_areas) = dsw->sw.area_height;
+
+ SetUpInitialInformation(dsw);
+ }
+
+ if (dsw->sw.doing_feedback) {
+ float *r;
+ int dx, dy;
+
+ CheckFeedbackPixmap(dsw);
+ r = dsw->sw.prev_dirty_areas;
+ ConvertToPS(dsw, 0 + DELTA, dsw->sw.drawing_area->core.height - DELTA,
+ r, r+1);
+ ConvertToPS(dsw, dsw->sw.drawing_area->core.width - DELTA, 0 + DELTA,
+ r+2, r+3);
+ r[2] -= r[0];
+ r[3] -= r[1];
+ dsw->sw.num_prev_dirty_areas = 1;
+
+ if (dsw->sw.feedback_pixmap != None) {
+ /* Initialize the feedback pixmap with a copy of the drawing */
+ if (dsw->sw.backing_pixmap != None) {
+ CopyToFeedbackPixmap(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ } else {
+ CopyRectsToCurrentDrawing(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ (void) ClipAndDraw(dsw, DSWFeedbackPixmap, DSWFinish, True);
+ }
+ XCopyArea(XtDisplay(dsw), dsw->sw.feedback_pixmap,
+ XtWindow(dsw->sw.drawing_area),
+ dsw->sw.no_ge_gc, 0, 0,
+ dsw->sw.drawing_area->core.width,
+ dsw->sw.drawing_area->core.height, 0, 0);
+ } else {
+ if (dsw->sw.backing_pixmap != None) {
+ ComputeOffsets(dsw, &dx, &dy);
+
+ XCopyArea(XtDisplay(dsw), dsw->sw.backing_pixmap,
+ XtWindow(dsw->sw.drawing_area),
+ dsw->sw.no_ge_gc, dx, dy,
+ dsw->sw.drawing_area->core.width,
+ dsw->sw.drawing_area->core.height, 0, 0);
+ } else {
+ CopyRectsToCurrentDrawing(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ dsw->sw.drawing_stage = DSWStart;
+ FinishDrawing(dsw);
+ }
+ }
+ if (dsw->sw.feedback_displayed) {
+ CallFeedbackCallback(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ }
+ if (dsw->sw.feedback_pixmap != None) {
+ UpdateWindowFromFeedbackPixmap(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ }
+ dsw->sw.num_pending_dirty = dsw->sw.num_pending_expose = 0;
+ }
+}
+
+static void CheckFeedbackPixmap(DPSScrolledWindowWidget dsw)
+{
+ if (dsw->sw.feedback_pixmap != None &&
+ (dsw->sw.feedback_width < (int) dsw->sw.drawing_area->core.width ||
+ dsw->sw.feedback_height < (int) dsw->sw.drawing_area->core.height)) {
+ XFreePixmap(XtDisplay(dsw), dsw->sw.feedback_pixmap);
+ dsw->sw.feedback_pixmap = None;
+ dsw->sw.feedback_width = dsw->sw.feedback_height = 0;
+ }
+ if (dsw->sw.use_feedback_pixmap && dsw->sw.feedback_pixmap == None) {
+ dsw->sw.feedback_pixmap =
+ AllocPixmap(dsw, dsw->sw.drawing_area->core.width,
+ dsw->sw.drawing_area->core.height);
+ if (dsw->sw.feedback_pixmap != None) {
+ dsw->sw.feedback_width = dsw->sw.drawing_area->core.width;
+ dsw->sw.feedback_height = dsw->sw.drawing_area->core.height;
+ }
+ }
+ if (dsw->sw.feedback_pixmap != None) {
+ XDPSSetContextDrawable(dsw->sw.context, dsw->sw.feedback_pixmap,
+ dsw->sw.drawing_area->core.height);
+ SetPixmapOrigin(dsw);
+ XDPSCaptureContextGState(dsw->sw.context, &dsw->sw.feedback_gstate);
+ }
+}
+
+static void UpdateGStates(DPSScrolledWindowWidget dsw)
+{
+ /* Create graphics states for the window and backing pixmap in
+ the new context */
+ XDPSSetContextDrawable(dsw->sw.context, XtWindow(dsw->sw.drawing_area),
+ dsw->sw.drawing_area->core.height);
+ DPSinitgraphics(dsw->sw.context);
+ if (dsw->sw.scale != 1.0) {
+ DPSscale(dsw->sw.context, dsw->sw.scale, dsw->sw.scale);
+ }
+
+ SetOriginAndGetTransform(dsw);
+ (void) XDPSCaptureContextGState(dsw->sw.context, &dsw->sw.window_gstate);
+ if (dsw->sw.backing_pixmap != None) {
+ XDPSSetContextDrawable(dsw->sw.context, dsw->sw.backing_pixmap,
+ dsw->sw.pixmap_height);
+
+ SetPixmapOffset(dsw);
+ SetPixmapOrigin(dsw);
+ XDPSCaptureContextGState(dsw->sw.context, &dsw->sw.backing_gstate);
+ }
+}
+
+static void CheckPixmapSize(DPSScrolledWindowWidget dsw)
+{
+ Boolean freeIt = False;
+ int w = dsw->sw.pixmap_width, h = dsw->sw.pixmap_height;
+ Widget wid = dsw->sw.drawing_area;
+ unsigned int dBytes;
+
+ if (dsw->sw.pixmap_limit > 0) {
+ if (w * h > dsw->sw.pixmap_limit) freeIt = True;
+ } else if (dsw->sw.pixmap_limit < 0 &&
+ w * h > dsw->sw.unscaled_width * dsw->sw.unscaled_height &&
+ w * h > (int) wid->core.width * (int) wid->core.height) {
+ freeIt = True;
+ }
+
+ if (dsw->sw.absolute_pixmap_limit > 0) {
+ dBytes = (wid->core.depth + 7) / 8; /* Convert into bytes */
+ if (w * h * dBytes > (unsigned)dsw->sw.absolute_pixmap_limit * 1024) {
+ freeIt = True;
+ }
+ }
+ if (freeIt) {
+ XFreePixmap(XtDisplay(dsw), dsw->sw.backing_pixmap);
+ dsw->sw.backing_pixmap = None;
+ dsw->sw.big_pixmap = False;
+ dsw->sw.pixmap_width = dsw->sw.pixmap_height = 0;
+ XDPSFreeContextGState(dsw->sw.context, dsw->sw.backing_gstate);
+ }
+}
+
+static void ResizeArea(DPSScrolledWindowWidget dsw)
+{
+ AbortDrawing(dsw);
+
+ /* Make everything dirty */
+ dsw->sw.num_dirty_areas = 1;
+ LEFT(dsw->sw.dirty_areas) = 0.0;
+ BOTTOM(dsw->sw.dirty_areas) = 0.0;
+ WIDTH(dsw->sw.dirty_areas) = dsw->sw.area_width;
+ HEIGHT(dsw->sw.dirty_areas) = dsw->sw.area_height;
+
+ if (dsw->sw.big_pixmap) {
+ XFreePixmap(XtDisplay(dsw), dsw->sw.backing_pixmap);
+ dsw->sw.backing_pixmap = None;
+ dsw->sw.big_pixmap = False;
+ dsw->sw.pixmap_width = dsw->sw.pixmap_height = 0;
+ XDPSFreeContextGState(dsw->sw.context, dsw->sw.backing_gstate);
+ }
+
+ if (!dsw->sw.use_saved_scroll) {
+ /* Keep the upper left in the same place */
+ dsw->sw.scroll_win_x = 0;
+ dsw->sw.scroll_win_y = 0;
+ ConvertToPS(dsw, 0.0, 0.0,
+ &dsw->sw.scroll_pic_x, &dsw->sw.scroll_pic_y);
+ dsw->sw.use_saved_scroll = True;
+ }
+
+ SetUpInitialInformation(dsw);
+}
+
+static void ClearDirtyAreas(DPSScrolledWindowWidget dsw)
+{
+ int i;
+ float *r;
+ int llx, lly, urx, ury;
+
+ for (i = 0; i < dsw->sw.num_dirty_areas; i++) {
+ r = dsw->sw.dirty_areas + (i * 4);
+ ConvertToX(dsw, LEFT(r), BOTTOM(r), &llx, &lly);
+ ConvertToX(dsw, RIGHT(r), TOP(r), &urx, &ury);
+ XClearArea(XtDisplay(dsw), XtWindow(dsw->sw.drawing_area),
+ llx, ury, urx-llx, lly-ury, True);
+ }
+}
+
+static void HandleFeedbackPixmapChange(DPSScrolledWindowWidget dsw)
+{
+ if (!dsw->sw.use_feedback_pixmap) {
+ /* Get rid of one if we have it */
+ if (dsw->sw.feedback_pixmap != None) {
+ XFreePixmap(XtDisplay(dsw), dsw->sw.feedback_pixmap);
+ dsw->sw.feedback_pixmap = None;
+ dsw->sw.feedback_width = dsw->sw.feedback_height = 0;
+ }
+ } else {
+ if (dsw->sw.doing_feedback) {
+ float *r;
+
+ CheckFeedbackPixmap(dsw);
+ if (dsw->sw.feedback_pixmap == None) return;
+
+ r = dsw->sw.prev_dirty_areas;
+ ConvertToPS(dsw, 0 + DELTA,
+ dsw->sw.drawing_area->core.height - DELTA, r, r+1);
+ ConvertToPS(dsw, dsw->sw.drawing_area->core.width - DELTA,
+ 0 + DELTA, r+2, r+3);
+ r[2] -= r[0];
+ r[3] -= r[1];
+ dsw->sw.num_prev_dirty_areas = 1;
+
+ /* Initialize the feedback pixmap with a copy of the drawing */
+ if (dsw->sw.backing_pixmap != None) {
+ CopyToFeedbackPixmap(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ } else {
+ CopyRectsToCurrentDrawing(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ (void) ClipAndDraw(dsw, DSWFeedbackPixmap, DSWFinish, True);
+ }
+ if (dsw->sw.feedback_displayed) {
+ CallFeedbackCallback(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ }
+ }
+ }
+}
+
+/* ARGSUSED */
+
+static Boolean SetValues(
+ Widget old, Widget req, Widget new,
+ ArgList args,
+ Cardinal *num_args)
+{
+ DPSScrolledWindowWidget olddsw = (DPSScrolledWindowWidget) old;
+ DPSScrolledWindowWidget newdsw = (DPSScrolledWindowWidget) new;
+ Bool inited;
+
+#define NE(field) newdsw->sw.field != olddsw->sw.field
+#define DONT_CHANGE(field) \
+ if (NE(field)) newdsw->sw.field = olddsw->sw.field;
+
+ DONT_CHANGE(ctm_ptr);
+ DONT_CHANGE(inv_ctm_ptr);
+ DONT_CHANGE(backing_pixmap);
+ DONT_CHANGE(feedback_pixmap);
+ DONT_CHANGE(window_gstate);
+ DONT_CHANGE(backing_gstate);
+ DONT_CHANGE(feedback_gstate);
+
+ if (NE(context)) {
+ DSWSetupCallbackRec setup;
+
+ if (newdsw->sw.context == NULL) {
+ newdsw->sw.context = XDPSGetSharedContext(XtDisplay(newdsw));
+ }
+ if (_XDPSTestComponentInitialized(newdsw->sw.context,
+ dps_init_bit_dsw, &inited) ==
+ dps_status_unregistered_context) {
+ XDPSRegisterContext(newdsw->sw.context, False);
+ }
+ if (XtIsRealized(newdsw)) {
+ setup.context = newdsw->sw.context;
+ XtCallCallbackList((Widget) newdsw, newdsw->sw.setup_callback,
+ (XtPointer) &setup);
+ }
+ UpdateGStates(newdsw);
+ }
+
+ /* Watch progress only works with pass-through event dispatching */
+
+ if (NE(watch_progress)) {
+ if (newdsw->sw.watch_progress &&
+ XDPSSetEventDelivery(XtDisplay(newdsw), dps_event_query) !=
+ dps_event_pass_through) newdsw->sw.watch_progress = False;
+ }
+
+ if (NE(application_scrolling) && !newdsw->sw.application_scrolling) {
+ XtVaSetValues(newdsw->sw.h_scroll, XmNmaximum, newdsw->sw.scroll_h_max,
+ XmNvalue, newdsw->sw.scroll_h_value,
+ XmNsliderSize, newdsw->sw.scroll_h_size, NULL);
+ XtVaSetValues(newdsw->sw.v_scroll, XmNmaximum, newdsw->sw.scroll_v_max,
+ XmNvalue, newdsw->sw.scroll_v_value,
+ XmNsliderSize, newdsw->sw.scroll_v_size, NULL);
+ }
+
+ if (newdsw->sw.doing_feedback) {
+ DONT_CHANGE(scale);
+ DONT_CHANGE(area_width);
+ DONT_CHANGE(area_height);
+ }
+
+ if (NE(pixmap_limit) || NE(absolute_pixmap_limit)) CheckPixmapSize(newdsw);
+
+ if (NE(area_width) || NE(area_height) || NE(scale)) ResizeArea(newdsw);
+
+ /* It's too confusing to let any of these things change in the middle
+ of drawing */
+
+ if (NE(use_backing_pixmap) || NE(watch_progress) ||
+ NE(minimal_drawing) || NE(document_size_pixmaps)) {
+ Boolean freeIt = False, setUp = False;
+ AbortOrFinish(newdsw);
+ if (NE(use_backing_pixmap)) {
+ if (newdsw->sw.use_backing_pixmap) setUp = True;
+ else freeIt = True;
+ }
+ if (NE(document_size_pixmaps)) {
+ if (newdsw->sw.backing_pixmap != None) freeIt = True;
+ setUp = True;
+ }
+ if (freeIt) FreeBackingPixmap(newdsw);
+ if (setUp) SetUpInitialPixmap(newdsw);
+ }
+
+ if (NE(dirty_areas)) {
+ float *r = newdsw->sw.dirty_areas;
+ int n = newdsw->sw.num_dirty_areas;
+ DONT_CHANGE(dirty_areas);
+ DONT_CHANGE(num_dirty_areas);
+ AbortOrFinish(newdsw);
+ AddRectsToDirtyArea(newdsw, r, n);
+ if (newdsw->sw.watch_progress || newdsw->sw.backing_pixmap == None) {
+ ClearDirtyAreas(newdsw);
+ newdsw->sw.drawing_stage = DSWStart;
+ } else {
+ AddUserSpaceRectsToPending(newdsw, r, n);
+ StartDrawing(newdsw);
+ }
+ }
+
+ if (NE(use_feedback_pixmap)) HandleFeedbackPixmapChange(newdsw);
+
+ return False;
+#undef DONT_CHANGE
+}
+
+static XtGeometryResult GeometryManager(
+ Widget w,
+ XtWidgetGeometry *desired, XtWidgetGeometry *allowed)
+{
+ /* Pass geometry requests up to our parent */
+ return XtMakeGeometryRequest(XtParent(w), desired, allowed);
+}
+
+static XtGeometryResult QueryGeometry(
+ Widget w,
+ XtWidgetGeometry *desired, XtWidgetGeometry *allowed)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+
+ /* Pass geometry requests down to our child */
+ return XtQueryGeometry(dsw->sw.scrolled_window, desired, allowed);
+}
+
+static void CopyToFeedbackPixmap(
+ DPSScrolledWindowWidget dsw,
+ float *rects,
+ int n)
+{
+ int llx, lly, urx, ury;
+ int dx, dy;
+ int i;
+ float *r;
+
+ ComputeOffsets(dsw, &dx, &dy);
+
+ for (i = 0; i < n; i++) {
+ r = rects + (i * 4);
+ ConvertToX(dsw, LEFT(r), BOTTOM(r), &llx, &lly);
+ ConvertToX(dsw, RIGHT(r), TOP(r), &urx, &ury);
+
+ XCopyArea(XtDisplay(dsw), dsw->sw.backing_pixmap,
+ dsw->sw.feedback_pixmap, dsw->sw.no_ge_gc,
+ llx+dx-1, ury+dy-1, urx-llx+2, lly-ury+2, llx-1, ury-1);
+ }
+}
+
+static void CallFeedbackCallback(
+ DPSScrolledWindowWidget dsw,
+ float *r,
+ int n)
+{
+ DSWFeedbackCallbackRec f;
+
+ f.start_feedback_data = dsw->sw.start_feedback_data;
+ f.continue_feedback_data = dsw->sw.continue_feedback_data;
+ if (dsw->sw.feedback_pixmap == None) {
+ f.type = DSWWindow;
+ f.drawable = XtWindow(dsw->sw.drawing_area);
+ f.gstate = dsw->sw.window_gstate;
+ } else {
+ f.type = DSWFeedbackPixmap;
+ f.drawable = dsw->sw.feedback_pixmap;
+ f.gstate = dsw->sw.feedback_gstate;
+ }
+ f.context = dsw->sw.context;
+ f.dirty_rects = r;
+ f.dirty_count = n;
+
+ XDPSSetContextGState(dsw->sw.context, f.gstate);
+ _DPSSWSetRectViewClip(dsw->sw.context, r, n * 4);
+ XtCallCallbackList((Widget) dsw, dsw->sw.feedback_callback,
+ (XtPointer) &f);
+ DPSWaitContext(dsw->sw.context);
+}
+
+static void SetScale(
+ Widget w,
+ double scale,
+ long fixedX, long fixedY)
+{
+ float psX, psY;
+
+ ConvertToPS((DPSScrolledWindowWidget) w, (float) fixedX, (float) fixedY,
+ &psX, &psY);
+ SetScaleAndScroll(w, scale, psX, psY, fixedX, fixedY);
+}
+
+void DSWSetScale(
+ Widget w,
+ double scale,
+ long fixedX, long fixedY)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.set_scale) (w, scale, fixedX, fixedY);
+}
+
+static void ScrollPoint(
+ Widget w,
+ double psX, double psY,
+ long xX, long xY)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+
+ if (!XtIsRealized(w)) {
+ dsw->sw.use_saved_scroll = True;
+ dsw->sw.scroll_pic_x = psX;
+ dsw->sw.scroll_pic_y = psY;
+ dsw->sw.scroll_win_x = xX;
+ dsw->sw.scroll_win_y = xY;
+ return;
+ } else {
+ SetDrawingAreaPosition(dsw, psX, psY, xX, xY, False);
+ ScrollMoved(dsw);
+ }
+}
+
+void DSWScrollPoint(
+ Widget w,
+ double psX, double psY,
+ long xX, long xY)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.scroll_point) (w, psX, psY, xX, xY);
+}
+
+static void ScrollBy(Widget w, long dx, long dy)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+ int value;
+
+ if (dx == 0 && dy == 0) return;
+
+ if (!XtIsRealized(w) && dsw->sw.use_saved_scroll) {
+ dsw->sw.scroll_win_x += dx;
+ dsw->sw.scroll_win_y += dy;
+ } else {
+ value = dsw->sw.scroll_h_value + dx;
+
+ if (value < 0) value = 0;
+ else if (value > dsw->sw.scroll_h_max - dsw->sw.scroll_h_size) {
+ value = dsw->sw.scroll_h_max - dsw->sw.scroll_h_size;
+ }
+ dsw->sw.scroll_h_value = value;
+
+ if (!dsw->sw.application_scrolling) {
+ XtVaSetValues(dsw->sw.h_scroll, XmNvalue, value, NULL);
+ }
+
+ value = dsw->sw.scroll_v_value + dy;
+
+ if (value < 0) value = 0;
+ else if (value > dsw->sw.scroll_v_max - dsw->sw.scroll_v_size) {
+ value = dsw->sw.scroll_v_max - dsw->sw.scroll_v_size;
+ }
+ dsw->sw.scroll_v_value = value;
+
+ if (!dsw->sw.application_scrolling) {
+ XtVaSetValues(dsw->sw.v_scroll, XmNvalue, value, NULL);
+ }
+
+ ScrollMoved(dsw);
+ }
+}
+
+void DSWScrollBy(Widget w, long dx, long dy)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.scroll_by) (w, dx, dy);
+}
+
+static void ScrollTo(Widget w, long x, long y)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+ int max, size;
+
+ if (XtIsRealized(w)) {
+ if (x < 0) x = 0;
+ else if (x > dsw->sw.scroll_h_max - dsw->sw.scroll_h_size) {
+ x = dsw->sw.scroll_h_max - dsw->sw.scroll_h_size;
+ }
+ dsw->sw.scroll_h_value = x;
+
+ if (y < 0) y = 0;
+ else if (y > dsw->sw.scroll_v_max - dsw->sw.scroll_v_size) {
+ y = dsw->sw.scroll_v_max - dsw->sw.scroll_v_size;
+ }
+ dsw->sw.scroll_v_value = y;
+
+ if (!dsw->sw.application_scrolling) {
+ XtVaSetValues(dsw->sw.h_scroll, XmNvalue, x, NULL);
+ XtVaSetValues(dsw->sw.v_scroll, XmNvalue, y, NULL);
+ }
+
+ ScrollMoved(dsw);
+ }
+}
+
+void DSWScrollTo(Widget w, long x, long y)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.scroll_to) (w, x, y);
+}
+
+static void SetScaleAndScroll(
+ Widget w,
+ double scale,
+ double psX, double psY,
+ long xX, long xY)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+ Arg arg;
+ union {
+ int i;
+ float f;
+ } kludge;
+
+ dsw->sw.use_saved_scroll = True;
+ dsw->sw.scroll_pic_x = psX;
+ dsw->sw.scroll_pic_y = psY;
+ dsw->sw.scroll_win_x = xX;
+ dsw->sw.scroll_win_y = xY;
+
+ kludge.f = scale;
+ arg.name = XtNscale;
+ if (sizeof(float) > sizeof(XtArgVal)) arg.value = (XtArgVal) &kludge.f;
+ else arg.value = (XtArgVal) kludge.i;
+ XtSetValues(w, &arg, 1);
+}
+
+void DSWSetScaleAndScroll(
+ Widget w,
+ double scale,
+ double psX, double psY,
+ long xX, long xY)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.set_scale_and_scroll) (w, scale, psX, psY, xX, xY);
+}
+
+static void ConvertXToPS(
+ Widget w,
+ long xX, long xY,
+ float *psX, float *psY)
+{
+ ConvertToPS((DPSScrolledWindowWidget) w, (float) xX, (float) xY, psX, psY);
+}
+
+void DSWConvertXToPS(
+ Widget w,
+ long xX, long xY,
+ float *psX, float *psY)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.convert_x_to_ps) (w, xX, xY, psX, psY);
+}
+
+static void ConvertPSToX(
+ Widget w,
+ double psX, double psY,
+ int *xX, int *xY)
+{
+ ConvertToX((DPSScrolledWindowWidget) w, psX, psY, xX, xY);
+}
+
+void DSWConvertPSToX(
+ Widget w,
+ double psX, double psY,
+ int *xX, int *xY)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.convert_ps_to_x) (w, psX, psY, xX, xY);
+}
+
+static void AddToDirtyArea(
+ Widget w,
+ float *rect,
+ long n)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+
+ if (n == 1 && rect[0] == 0 && rect[1] == 0 &&
+ rect[2] == -1 && rect[2] == -1) {
+ rect[2] = dsw->sw.area_width;
+ rect[3] = dsw->sw.area_height;
+ }
+
+ XtVaSetValues(w, XtNdirtyAreas, rect, XtNnumDirtyAreas, n, NULL);
+}
+
+void DSWAddToDirtyArea(
+ Widget w,
+ float *rect,
+ long n)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.add_to_dirty_area) (w, rect, n);
+}
+
+static Boolean TakeFeedbackPixmap(
+ Widget w,
+ Pixmap *p,
+ int *width, int *height, int *depth,
+ Screen **screen)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+
+ if (dsw->sw.doing_feedback) return False;
+
+ *p = dsw->sw.feedback_pixmap;
+ if (*p == None) {
+ *width = *height = *depth;
+ *screen = NULL;
+ return True;
+ }
+
+ *width = dsw->sw.feedback_width;
+ *height = dsw->sw.feedback_height;
+ *depth = dsw->sw.drawing_area->core.depth;
+ *screen = dsw->core.screen;
+
+ dsw->sw.feedback_pixmap = None;
+ dsw->sw.feedback_width = dsw->sw.feedback_height = 0;
+ return True;
+}
+
+Boolean DSWTakeFeedbackPixmap(
+ Widget w,
+ Pixmap *p,
+ int *width, int *height, int *depth,
+ Screen **screen)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ return (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.take_feedback_pixmap) (w, p, width, height,
+ depth, screen);
+}
+
+static void StartFeedbackDrawing(
+ Widget w,
+ XtPointer start_feedback_data)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+ float *r;
+
+ FinishDrawing(dsw);
+ CheckFeedbackPixmap(dsw);
+ if (dsw->sw.feedback_pixmap != None) {
+ /* Initialize the feedback pixmap with a copy of the drawing */
+ GrowRectList(&dsw->sw.prev_dirty_areas, &dsw->sw.prev_dirty_areas_size,
+ 0, 1, 1);
+ r = dsw->sw.prev_dirty_areas;
+ ConvertToPS(dsw, 0 + DELTA, dsw->sw.drawing_area->core.height - DELTA,
+ r, r+1);
+ ConvertToPS(dsw, dsw->sw.drawing_area->core.width - DELTA, 0 + DELTA,
+ r+2, r+3);
+ r[2] -= r[0];
+ r[3] -= r[1];
+ dsw->sw.num_prev_dirty_areas = 1;
+
+ if (dsw->sw.backing_pixmap != None) {
+ CopyToFeedbackPixmap(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ } else {
+ CopyRectsToCurrentDrawing(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ (void) ClipAndDraw(dsw, DSWFeedbackPixmap, DSWFinish, True);
+ }
+ }
+ dsw->sw.num_prev_dirty_areas = 0;
+ dsw->sw.doing_feedback = True;
+ dsw->sw.start_feedback_data = start_feedback_data;
+}
+
+void DSWStartFeedbackDrawing(
+ Widget w,
+ XtPointer start_feedback_data)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.start_feedback_drawing) (w, start_feedback_data);
+}
+
+static void EndFeedbackDrawing(
+ Widget w,
+ int restore)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+
+ if (restore) {
+ if (dsw->sw.backing_pixmap != None) {
+ UpdateWindowFromBackingPixmap(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ } else {
+ CopyRectsToCurrentDrawing(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ (void) ClipAndDraw(dsw, DSWWindow, DSWFinish, True);
+ }
+ }
+ if (dsw->sw.feedback_gstate != 0) {
+ XDPSFreeContextGState(dsw->sw.context, dsw->sw.feedback_gstate);
+ }
+ dsw->sw.doing_feedback = dsw->sw.feedback_displayed = False;
+}
+
+void DSWEndFeedbackDrawing(
+ Widget w,
+ Bool restore)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.end_feedback_drawing) (w, restore);
+}
+
+static void SetFeedbackDirtyArea(
+ Widget w,
+ float *rects,
+ int count,
+ XtPointer continue_feedback_data)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+ int i;
+ float *r;
+
+ for (i = 0; i < count; i++) {
+ r = rects + (i * 4);
+ if (WIDTH(r) < 0) {
+ LEFT(r) += WIDTH(r);
+ WIDTH(r) = -WIDTH(r);
+ }
+ if (HEIGHT(r) < 0) {
+ BOTTOM(r) += HEIGHT(r);
+ HEIGHT(r) = -HEIGHT(r);
+ }
+ }
+
+ if (dsw->sw.backing_pixmap != None) {
+ if (dsw->sw.feedback_pixmap != None) {
+ CopyToFeedbackPixmap(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ } else {
+ UpdateWindowFromBackingPixmap(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ }
+ } else {
+ CopyRectsToCurrentDrawing(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ (void) ClipAndDraw(dsw, (dsw->sw.feedback_pixmap == None ?
+ DSWWindow : DSWFeedbackPixmap),
+ DSWFinish, True);
+ }
+ dsw->sw.continue_feedback_data = continue_feedback_data;
+ CallFeedbackCallback(dsw, rects, count);
+
+ if (dsw->sw.feedback_pixmap != None) {
+ CopyRectsToDirtyArea(dsw, dsw->sw.prev_dirty_areas,
+ dsw->sw.num_prev_dirty_areas);
+ AddRectsToDirtyArea(dsw, rects, count);
+ SimplifyRects(dsw->sw.dirty_areas, &dsw->sw.num_dirty_areas);
+ UpdateWindowFromFeedbackPixmap(dsw, dsw->sw.dirty_areas,
+ dsw->sw.num_dirty_areas);
+ dsw->sw.num_dirty_areas = 0;
+ }
+ CopyRectsToPrevDirtyArea(dsw, rects, count);
+ dsw->sw.feedback_displayed = True;
+}
+
+void DSWSetFeedbackDirtyArea(
+ Widget w,
+ float *rects,
+ int count,
+ XtPointer continue_feedback_data)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.set_feedback_dirty_area) (w, rects, count,
+ continue_feedback_data);
+}
+
+static void FinishPendingDrawing(Widget w)
+{
+ FinishDrawing((DPSScrolledWindowWidget) w);
+}
+
+void DSWFinishPendingDrawing(Widget w)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.finish_pending_drawing) (w);
+}
+
+static void AbortPendingDrawing(Widget w)
+{
+ AbortDrawing((DPSScrolledWindowWidget) w);
+}
+
+void DSWAbortPendingDrawing(Widget w)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.abort_pending_drawing) (w);
+}
+
+static void UpdateDrawing(
+ Widget w,
+ float *rects,
+ int count)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+ int i;
+ float *r;
+ int llx, lly, urx, ury;
+ int dx, dy;
+
+ if (dsw->sw.backing_pixmap == None) {
+ AddToDirtyArea(w, rects, count);
+ return;
+ }
+
+ ComputeOffsets(dsw, &dx, &dy);
+
+ for (i = 0; i < count; i++) {
+ r = rects + (i * 4);
+ ConvertToX(dsw, LEFT(r), BOTTOM(r), &llx, &lly);
+ ConvertToX(dsw, RIGHT(r), TOP(r), &urx, &ury);
+ XCopyArea(XtDisplay(dsw), XtWindow(dsw->sw.drawing_area),
+ dsw->sw.backing_pixmap, dsw->sw.no_ge_gc,
+ llx-1, ury-1, urx-llx+2, lly-ury+2, llx+dx-1, ury+dy-1);
+ }
+}
+
+void DSWUpdateDrawing(
+ Widget w,
+ float *rects,
+ int count)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.update_drawing) (w, rects, count);
+}
+
+static void GetScrollInfo(
+ Widget w,
+ int *h_value, int *h_size, int *h_max, int *v_value, int *v_size, int *v_max)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+
+ if (h_value != NULL) *h_value = dsw->sw.scroll_h_value;
+ if (h_size != NULL) *h_size = dsw->sw.scroll_h_size;
+ if (h_max != NULL) *h_max = dsw->sw.scroll_h_max;
+ if (v_value != NULL) *v_value = dsw->sw.scroll_v_value;
+ if (v_size != NULL) *v_size = dsw->sw.scroll_v_size;
+ if (v_max != NULL) *v_max = dsw->sw.scroll_v_max;
+}
+
+void DSWGetScrollInfo(
+ Widget w,
+ int *h_value, int *h_size, int *h_max, int *v_value, int *v_size, int *v_max)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.get_scroll_info) (w, h_value, h_size, h_max,
+ v_value, v_size, v_max);
+}
+
+static void GetDrawingInfo(
+ Widget w,
+ DSWDrawableType *type,
+ Drawable *drawable,
+ DPSGState *gstate,
+ DPSContext *context)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+
+ if (dsw->sw.backing_pixmap != None) {
+ *type = DSWBackingPixmap;
+ *drawable = dsw->sw.backing_pixmap;
+ *gstate = dsw->sw.backing_gstate;
+ } else {
+ *type = DSWWindow;
+ *drawable = XtWindow(dsw->sw.drawing_area);
+ *gstate = dsw->sw.window_gstate;
+ }
+ *context = dsw->sw.context;
+}
+
+void DSWGetDrawingInfo(
+ Widget w,
+ DSWDrawableType *type,
+ Drawable *drawable,
+ DPSGState *gstate,
+ DPSContext *context)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.get_drawing_info) (w, type, drawable, gstate, context);
+}
+
+static Boolean GiveFeedbackPixmap(
+ Widget w,
+ Pixmap p,
+ int width, int height, int depth,
+ Screen *screen)
+{
+ DPSScrolledWindowWidget dsw = (DPSScrolledWindowWidget) w;
+
+ if ((unsigned) depth != dsw->sw.drawing_area->core.depth
+ || screen != dsw->core.screen
+ || dsw->sw.feedback_pixmap != None) return False;
+
+ dsw->sw.feedback_pixmap = p;
+ dsw->sw.feedback_width = width;
+ dsw->sw.feedback_height = height;
+
+ return True;
+}
+
+Boolean DSWGiveFeedbackPixmap(
+ Widget w,
+ Pixmap p,
+ int width, int height, int depth,
+ Screen *screen)
+{
+ XtCheckSubclass(w, dpsScrolledWindowWidgetClass, NULL);
+
+ return (*((DPSScrolledWindowWidgetClass) XtClass(w))->
+ sw_class.give_feedback_pixmap) (w, p, width, height,
+ depth, screen);
+}
+
+static void ConvertToX(
+ DPSScrolledWindowWidget dsw,
+ float psX,
+ float psY,
+ int *xX,
+ int *xY)
+{
+ *xX = dsw->sw.ctm[0] * psX + dsw->sw.ctm[2] * psY + dsw->sw.ctm[4] +
+ dsw->sw.x_offset + 0.5;
+ *xY = dsw->sw.ctm[1] * psX + dsw->sw.ctm[3] * psY + dsw->sw.ctm[5] +
+ dsw->sw.y_offset + 0.5;
+}
+
+static void ConvertToPS(
+ DPSScrolledWindowWidget dsw,
+ float xX, float xY,
+ float *psX, float *psY)
+{
+ xX -= dsw->sw.x_offset;
+ xY -= dsw->sw.y_offset;
+
+ *psX = dsw->sw.inv_ctm[0] * xX + dsw->sw.inv_ctm[2] * xY +
+ dsw->sw.inv_ctm[4];
+ *psY = dsw->sw.inv_ctm[1] * xX + dsw->sw.inv_ctm[3] * xY +
+ dsw->sw.inv_ctm[5];
+}
+
+static void ConvertToOrigPS(
+ DPSScrolledWindowWidget dsw,
+ int xX, int xY,
+ float *psX, float *psY)
+{
+ xX -= dsw->sw.x_offset;
+ xY -= dsw->sw.y_offset;
+
+ *psX = dsw->sw.orig_inv_ctm[0] * xX + dsw->sw.orig_inv_ctm[2] * xY +
+ dsw->sw.orig_inv_ctm[4];
+ *psY = dsw->sw.orig_inv_ctm[1] * xX + dsw->sw.orig_inv_ctm[3] * xY +
+ dsw->sw.orig_inv_ctm[5];
+}
diff --git a/nx-X11/lib/dpstk/DSWwraps.psw b/nx-X11/lib/dpstk/DSWwraps.psw
new file mode 100644
index 000000000..84c4268a4
--- /dev/null
+++ b/nx-X11/lib/dpstk/DSWwraps.psw
@@ -0,0 +1,75 @@
+/*
+ * DSWwraps.psw
+ *
+ * (c) Copyright 1993-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps _DPSSWGetTransform(DPSContext ctxt | float ctm[6], invctm[6])
+ matrix currentmatrix dup ctm
+ matrix invertmatrix invctm
+endps
+
+defineps _DPSSWSetMatrixAndGetTransform(DPSContext ctxt;
+ float tx, ty, s; int hx, hy
+ | float ctm[6], invctm[6]; int *xoffset, *yoffset)
+ initmatrix
+ tx ty translate
+ s s scale
+ hx hy sethalftonephase
+ initclip
+ matrix currentmatrix dup ctm
+ matrix invertmatrix invctm
+ currentXoffset yoffset xoffset
+endps
+
+defineps _DPSSWSetMatrix(DPSContext ctxt; float tx, ty, s; int hx, hy)
+ initmatrix
+ tx ty translate
+ s s scale
+ hx hy sethalftonephase
+ initclip
+endps
+
+defineps _DPSSWSetRectViewClip(DPSContext ctxt;
+ float numstring rect[numrect]; int numrect)
+ rect rectviewclip
+endps
+
+defineps _DPSSWColormapMatch(DPSContext ctxt; int colormap | boolean *match)
+ currentXgcdrawablecolor % gc draw x y [....colormap...]
+ 10 get colormap eq match % gc draw x y
+ pop pop pop pop
+endps
+
diff --git a/nx-X11/lib/dpstk/FSBwraps.psw b/nx-X11/lib/dpstk/FSBwraps.psw
new file mode 100644
index 000000000..c36a0d78c
--- /dev/null
+++ b/nx-X11/lib/dpstk/FSBwraps.psw
@@ -0,0 +1,491 @@
+/*
+ * FSBwraps.psw
+ *
+ * (c) Copyright 1991-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps _DPSFClearWindow(DPSContext ctxt)
+ 1 setgray
+ 0 0 2000 2000 rectfill
+endps
+
+defineps _DPSFPreviewString(DPSContext ctxt; char *font; float size;
+ char *text; int height | boolean *bogus)
+ mark {
+ /font size selectfont
+ 0 height neg 5 div itransform
+ exch pop 5 exch moveto
+ 0 setgray
+ (text) show
+ } stopped bogus cleartomark
+endps
+
+defineps _DPSFReclip(DPSContext ctxt)
+ initclip
+ initviewclip
+endps
+
+defineps _DPSFUndefineFont(DPSContext ctxt; char *font; boolean oldServer)
+ currentshared true setshared % currentshared
+ {/font undefinefont} stopped % currentshared [font] stopped
+ {
+ false setshared % currentshared font
+ {undefinefont} stopped {
+ pop
+ } if
+ } if
+ setshared
+ oldServer { 2 vmreclaim } if
+endps
+
+defineps _DPSFDefineFontEnumFunctions(DPSContext ctxt)
+ $Adobe$DPS$Lib$Dict begin
+ /GetFontName { % int GetFontName string
+ $Adobe$DPS$Lib$Dict /FontDict get begin
+ dup maxItems div truncate cvi baseArray exch get
+ exch maxItems mod get
+ end
+ } bind def
+
+ % (str) x y SafeBBox left bottom right top
+ /SafeBBox {
+ 3 copy % (str) x y (str) x y
+ newpath
+ moveto % (str) x y (str)
+ {
+ mark exch false charpath flattenpath pathbbox
+ } stopped {
+ cleartomark
+ 3 -1 roll dup length dup % x y (str) len len
+ 1 le {
+ pop
+ % punt; we can't divide it any more
+ 0 0 moveto stringwidth pop % x y wx
+ dup 2 index add exch 3 index add exch
+ } {
+ 2 copy % x y (str) len (str) len
+ 2 idiv % x y (str) len (str) len/2
+ 0 exch % x y (str) len (str) 0 len/2
+ getinterval dup % x y (str) len (s1) (s1)
+ 5 index 5 index % x y (str) len (s1) (s1) x y
+ $Adobe$DPS$Lib$Dict /SafeBBox get exec
+ % x y (str) len (s1) l1 b1 r1 t1
+ 9 4 roll % l1 b1 r1 t1 x y (str) len (s1)
+ stringwidth % ... x y (str) len wx wy
+ 5 -1 roll add exch % ... x (str) len y+wy wx
+ 5 -1 roll add exch % ... (str) len x+wx y+wy
+ 4 2 roll % ... x+wx y+wy (str) len
+ dup 2 idiv % ... x+wx y+wy (str) len len/2
+ exch 2 div ceiling cvi
+ % ... x+wx y+wy (str) len/2 ceil(len/2)
+ getinterval % ... x+wx y+wy (s2)
+ 3 1 roll % ... (s2) x+wx y+wy
+ $Adobe$DPS$Lib$Dict /SafeBBox get exec
+ % l1 b1 r1 t1 l2 b2 r2 t2
+ 5 -1 roll 2 copy % l1 b1 r1 l2 b2 r2 t2 t1 t2 t1
+ gt {pop} {exch pop} ifelse % l1 b1 r1 l2 b2 r2 t
+ 7 1 roll % t l1 b1 r1 l2 b2 r2
+ 4 -1 roll 2 copy % t l1 b1 l2 b2 r2 r1 r2 r1
+ gt {pop} {exch pop} ifelse % t l1 b1 l2 b2 r
+ 6 1 roll % r t l1 b1 l2 b2
+ 3 -1 roll 2 copy % r t l1 l2 b2 b1 b2 b1
+ lt {pop} {exch pop} ifelse % r t l1 l2 b
+ 5 1 roll % b r t l1 l2
+ 2 copy % b r t l1 l2 l1 l2
+ lt {pop} {exch pop} ifelse % b r t l
+ 4 1 roll % l b r t
+ } ifelse
+ } { % mark (str) x y l b r t
+ 8 -4 roll pop pop pop pop
+ } ifelse
+ } bind def
+ /DownloadPS {
+ $Adobe$DPS$Lib$Dict /downloadSuccess false put
+ (%stdin) (r) file
+ cvx stopped
+ pop % always true
+ % Flush until you get the magic line
+ {
+ {currentfile 256 string readline} stopped
+ pop % don't care stopped result
+ pop % don't care readline bool result
+(Magic end of data line \)\)\)\)\)\)\)\)\)\) 99#2 2#99 <xyz> // 7gsad,32h4ghNmndFgj2)
+ eq
+ {exit} if
+ } loop
+ } bind def
+ end
+endps
+
+defineps _DPSFEnumFonts(DPSContext ctxt | int *count; int *totalLength)
+ $Adobe$DPS$Lib$Dict begin
+ /FontDict 5 dict def
+ FontDict begin
+ /currentItem 0 def
+ /maxItems 100 def
+ /maxArrays 20 def % This is the max index, not the array size!
+ /baseArray maxArrays 1 add array def
+ /currentArray 0 def
+ baseArray 0 maxItems array put
+ end
+
+ /AddFontName { % string AddFontName success
+ $Adobe$DPS$Lib$Dict /FontDict get begin
+ 1 { % provides enclosing loop for exit
+ currentItem maxItems eq
+ {
+ currentArray maxArrays eq {pop false exit} if
+ /currentArray currentArray 1 add def
+ baseArray currentArray maxItems array put
+ /currentItem 0 def
+ } if
+ dup length string copy
+ baseArray currentArray get currentItem 3 -1 roll put
+ /currentItem currentItem 1 add def
+ true
+ } repeat % provides enclosing loop for exit
+ end
+ } bind def
+
+ 3 dict begin
+ /$listString 256 string def
+ /countFonts 0 def
+ /totalLen 0 def
+
+ % Enumerate SharedFontDirectory
+ SharedFontDirectory { % forall
+ pop % /fontname
+ $listString cvs % (fontname)
+ dup AddFontName % (name) success
+ {
+ /countFonts countFonts 1 add def
+ length 1 add totalLen add /totalLen exch def
+ } {
+ pop
+ } ifelse
+ } forall
+
+ % Enumerate %font% storage device, if available.
+ /filenameforall where { % if
+ pop
+ (%font%*) { % filenameforall
+ % Check if name is something we really believe
+ % is a font. Leave either "false" or "(name) true"
+ % on stack
+
+ % Discard filenames containing "."
+ (.) search { % if
+ pop pop pop null false
+ } { % else
+ dup % (%font%name) (%font%name)
+ (%font%) anchorsearch { % if
+ % (%font%name) (name) (%font%)
+ pop exch pop % (name)
+ dup AddFontName % (name) success
+ } { % else
+ pop null false
+ } ifelse
+ } ifelse
+
+ % Stack is either "<something> false" or "(name) true"
+ {
+ /countFonts countFonts 1 add def
+ length 1 add totalLen add /totalLen exch def
+ } {
+ pop
+ } ifelse
+ } $listString filenameforall
+ } if
+ totalLen totalLength countFonts count
+ end
+ end
+
+ $Adobe$DPS$Lib$Dict /AddFontName undef
+endps
+
+defineps _DPSFGetAllFontNames(DPSContext ctxt; int fontCount; int arrLen |
+ char fontNames[arrLen])
+ $Adobe$DPS$Lib$Dict begin
+ FontDict begin
+ 0 1 fontCount 1 sub {
+ GetFontName fontNames
+ ( ) fontNames
+ } for
+ end
+ end
+endps
+
+defineps _DPSFGetFontInfo(DPSContext ctxt; int fontNum; boolean oldServer |
+ char *familyName; char *fullName; char *weight;
+ boolean *blendedFont, *undefineIt, *bogus)
+ fontNum $Adobe$DPS$Lib$Dict /GetFontName get exec
+
+ dup dup % fontname fontname fontname
+ SharedFontDirectory exch known % fontname fontname known
+ dup undefineIt exch % fontname known fontname
+ % (leave fontname and known on stack
+ % for the duration of this call
+ % even though I don't list them in
+ % the comments)
+ { % stopped
+ findfont dup % fontdir fontdir
+ /FontInfo known { % fontdir bool
+ /FontInfo get dup dup % fontinfo fontinfo fontinfo
+ /FamilyName known { % fontinfo fontinfo bool
+ /FamilyName get % fontinfo (familyname)
+ } {
+ pop ()
+ } ifelse
+ exch dup dup % (familyname) fontinfo fontinfo fontinfo
+ /FullName known { % (familyname) fontinfo fontinfo bool
+ /FullName get % (familyname) fontinfo (fullname)
+ } {
+ pop ()
+ } ifelse
+ exch dup dup % (familyname) (fullname) fontinfo*3
+ /Weight known { % (familyname) (fullname) fontinfo*2 bool
+ /Weight get % (familyname) (fullname) fontinfo (weight)
+ } {
+ pop (Medium)
+ } ifelse
+ exch % (familyname) (fullname) (weight) fontinfo
+ /BlendAxisTypes known % (familyname) (fullname) (weight) blendedFont
+
+ dup blendedFont % (familyname) (fullname) (weight) blendedFont
+ } {
+ pop () () ()
+ false false blendedFont
+ } ifelse % (familyname) (fullname) (weight) blendedFont
+ false bogus
+
+ } stopped {
+ () () ()
+ false false blendedFont
+ true bogus
+ } if
+
+ 4 1 roll % blendedFont (familyname) (fullname) (weight)
+ weight fullName familyName
+ % fontname known is still on the stack so...
+ % fontname known blendedFont
+
+ % if blendedFont (the bool on the stack) is true, don't undefine things
+ % just yet since we'll be coming back quite soon for more stuff
+
+ not and { % undefine font if we just defined
+ % it to get this information
+ currentshared true setshared
+ exch % currentshared fontname
+ {undefinefont} stopped % currentshared [fontname] stopped
+ {
+ false setshared % currentshared fontname
+
+ {undefinefont} stopped {
+ pop
+ } if
+ } if
+ setshared
+
+ oldServer {2 vmreclaim} if
+ } {
+ pop
+ } ifelse
+endps
+
+defineps _DPSFFreeFontInfo(DPSContext ctxt)
+ $Adobe$DPS$Lib$Dict /FontDict undef
+ $Adobe$DPS$Lib$Dict /GetFontName undef
+ 1 vmreclaim
+endps
+
+defineps _DPSFIsFontResident(DPSContext ctxt; char *name; | boolean *resident)
+ SharedFontDirectory /name known {
+ true resident
+ } {
+ /buf (name) length 6 add string def
+ buf 0 (%font%) putinterval
+ buf 6 (name) putinterval
+ buf status dup resident { pop pop pop pop } if
+ } ifelse
+endps
+
+defineps _DPSFGetBlendedFontInfo(DPSContext ctxt; int fontNum;
+ boolean undefineIt; boolean oldServer |
+ int *axes; int *designs;
+ char axisNames[256];
+ float blendPos[64]; int breakCount[4];
+ int blendBreak[48]; float blendBreakValue[48];
+ boolean *bogus)
+
+ fontNum $Adobe$DPS$Lib$Dict /GetFontName get exec
+ $Adobe$DPS$Lib$Dict /stringbuf 256 string put
+ dup % duplicate fontname; we'll need it later
+
+ findfont /FontInfo get dup % fontinfo fontinfo
+ /BlendAxisTypes get % fontinfo array
+ dup length axes % fontinfo array
+ { % Concatenate all the names into axisNames
+ $Adobe$DPS$Lib$Dict /stringbuf get cvs
+ axisNames
+ ( ) axisNames
+ } forall
+ dup dup % fontinfo fontinfo fontinfo
+ /BlendDesignPositions known { % fontinfo fontinfo known
+ /BlendDesignPositions get % fontinfo array
+ dup length designs % fontinfo array
+ { % enumerate the subarrays
+ {
+ blendPos
+ } forall
+ } forall
+ false
+ } {
+ pop true
+ } ifelse % fontinfo bool
+ exch dup % bool fontinfo fontinfo
+ /BlendDesignMap known { % bool fontinfo known
+ /BlendDesignMap get % bool array
+ {
+ dup length % bool subarray len
+ breakCount % bool subarray len
+ {
+ aload pop % bool break breakvalue
+ blendBreakValue
+ blendBreak
+ } forall
+ } forall
+ false
+ } {
+ pop true
+ } ifelse % bool bool
+
+ or bogus
+
+ undefineIt { % undefine font if we just defined
+ % it to get this information
+ currentshared true setshared
+ exch % currentshared fontname
+ {undefinefont} stopped % currentshared [fontname] stopped
+ {
+ false setshared % currentshared fontname
+
+ {undefinefont} stopped {
+ pop
+ } if
+ } if
+ setshared
+ oldServer { 2 vmreclaim } if
+ } {
+ pop
+ } ifelse
+ $Adobe$DPS$Lib$Dict /stringbuf undef
+endps
+
+defineps _DPSFShowText(DPSContext ctxt; char *text; char *font; float size;
+ int x, y | boolean *bogus)
+ mark {
+ /font size selectfont
+ x y moveto
+ (text) show
+ } stopped dup bogus cleartomark
+endps
+
+defineps _DPSFShowTextAndGetDimensions(DPSContext ctxt;
+ char *text; char *font; float size;
+ int x, y |
+ float *width, *left, *right,
+ *top, *bottom)
+ mark {
+ /font size selectfont
+ x y moveto
+ (text) show
+ (text) stringwidth pop width
+ (text) x y $Adobe$DPS$Lib$Dict /SafeBBox get exec
+ } stopped {0 0 0 0} if
+ top right bottom left
+ cleartomark
+endps
+
+defineps _DPSFGetTextDimensions(DPSContext ctxt;
+ char *text; char *font; float size;
+ float x, y |
+ float *width, *height,
+ *left, *right, *top, *bottom;
+ boolean *bogus)
+ mark {
+ /font size selectfont
+ (text) stringwidth height width
+
+ (text) x y $Adobe$DPS$Lib$Dict /SafeBBox get exec
+ } stopped dup bogus {0 0 0 0} if
+ top right bottom left
+ cleartomark
+endps
+
+defineps _DPSFGetCTM(DPSContext ctx | float ctm[6], invctm[6])
+ matrix currentmatrix dup ctm matrix invertmatrix invctm
+endps
+
+defineps _DPSFSetUpMM(DPSContext ctxt; char *font, *str; float size;
+ int height; float p[n]; int n | boolean *bogus)
+ userdict /fontDefined known {
+ /tempfont undefinefont
+ } if
+ mark {
+ /tempfont /font findfont p makeblendedfont definefont
+ size scalefont setfont
+ 0 height neg 5 div itransform
+ exch pop 5 exch moveto
+ (str) stringwidth pop pop
+ /fontDefined true def
+ } stopped bogus cleartomark
+endps
+
+defineps _DPSFDrawMM(DPSContext ctxt; char *str; int height)
+ 0 height neg 5 div itransform
+ exch pop 5 exch moveto
+ (str) show
+endps
+
+defineps _DPSFPrepareToDownload(DPSContext ctxt; boolean makeShared |
+ boolean *currShared)
+ $Adobe$DPS$Lib$Dict /DownloadPS get
+ currentshared currShared makeShared setshared
+endps
+
+defineps _DPSFFinishDownload(DPSContext ctxt; boolean shared | boolean *ok)
+ shared setshared
+ $Adobe$DPS$Lib$Dict /downloadSuccess get ok
+endps
diff --git a/nx-X11/lib/dpstk/FontCreato.c b/nx-X11/lib/dpstk/FontCreato.c
new file mode 100644
index 000000000..5164665cc
--- /dev/null
+++ b/nx-X11/lib/dpstk/FontCreato.c
@@ -0,0 +1,1610 @@
+/*
+ * FontCreato.c
+ *
+ * (c) Copyright 1992-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+#include <stdio.h>
+#include <ctype.h>
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/ShellP.h>
+#include <Xm/Xm.h>
+
+/* There are no words to describe how I feel about having to do this */
+
+#if XmVersion > 1001
+#include <Xm/ManagerP.h>
+#else
+#include <Xm/XmP.h>
+#endif
+
+#include <Xm/Form.h>
+#include <Xm/LabelG.h>
+#include <Xm/PushBG.h>
+#include <Xm/DrawingA.h>
+#include <Xm/Scale.h>
+#include <Xm/MessageB.h>
+#include <Xm/TextF.h>
+#include <Xm/PanedW.h>
+#include <Xm/List.h>
+#include <Xm/SeparatoG.h>
+#include <Xm/ToggleBG.h>
+#include <Xm/RowColumn.h>
+#include <DPS/dpsXclient.h>
+#include <DPS/dpsXshare.h>
+#include <DPS/FontSBP.h>
+#include <DPS/FontCreatP.h>
+#include <stdlib.h>
+#include <math.h>
+#include "FontSBI.h"
+#include "FSBwraps.h"
+
+/* Turn a string into a compound string */
+#define UnsharedCS(str) XmStringCreate(str, XmSTRING_DEFAULT_CHARSET)
+#define CS(str, w) _FSBCreateSharedCS(str, w)
+static XmString CSempty;
+static char *opticalSize = NULL;
+
+#define Canonical(str) XrmQuarkToString(XrmStringToQuark(str))
+
+static float defaultSizeList[] = {
+#ifndef CREATOR_DEFAULT_SIZE_LIST
+ 8, 10, 12, 14, 16, 18, 24, 36, 48, 72
+#else
+ CREATOR_DEFAULT_SIZE_LIST
+#endif /* CREATOR_DEFAULT_SIZE_LIST */
+};
+
+#ifndef CREATOR_DEFAULT_SIZE_LIST_COUNT
+#define CREATOR_DEFAULT_SIZE_LIST_COUNT 10
+#endif /* CREATOR_DEFAULT_SIZE_LIST_COUNT */
+
+#define Offset(field) XtOffsetOf(FontCreatorRec, creator.field)
+
+static XtResource resources[] = {
+ {XtNsizes, XtCSizes, XtRFloatList, sizeof(float*),
+ Offset(sizes), XtRImmediate, (XtPointer) defaultSizeList},
+ {XtNsizeCount, XtCSizeCount, XtRInt, sizeof(int),
+ Offset(size_count), XtRImmediate,
+ (XtPointer) CREATOR_DEFAULT_SIZE_LIST_COUNT},
+ {XtNdismissCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(dismiss_callback), XtRCallback, (XtPointer) NULL},
+ {XtNfontSelectionBox, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(fsb), XtRWidget, (XtPointer) NULL},
+};
+
+/* Forward declarations */
+
+static Boolean SetValues(Widget old, Widget req, Widget new, ArgList args, Cardinal *num_args);
+static XtGeometryResult GeometryManager(Widget w, XtWidgetGeometry *desired, XtWidgetGeometry *allowed);
+static void ChangeManaged(Widget w);
+static void ClassInitialize(void);
+static void Destroy(Widget widget);
+static void Initialize(Widget request, Widget new, ArgList args, Cardinal *num_args);
+static void Resize(Widget widget);
+
+FontCreatorClassRec fontCreatorClassRec = {
+ /* Core class part */
+ {
+ /* superclass */ (WidgetClass) &xmManagerClassRec,
+ /* class_name */ "FontCreator",
+ /* widget_size */ sizeof(FontCreatorRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ XtExposeCompressMultiple,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ NULL,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL,
+ },
+ /* Composite class part */
+ {
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL,
+ },
+ /* Constraint class part */
+ {
+ /* resources */ NULL,
+ /* num_resources */ 0,
+ /* constraint_size */ 0,
+ /* initialize */ NULL,
+ /* destroy */ NULL,
+ /* set_values */ NULL,
+ /* extension */ NULL,
+ },
+ /* Manager class part */
+ {
+ /* translations */ XtInheritTranslations,
+ /* syn_resources */ NULL,
+ /* num_syn_resources */ 0,
+ /* syn_constraint_resources */ NULL,
+ /* num_syn_constraint_resources */ 0,
+ /* parent_process */ XmInheritParentProcess,
+ /* extension */ NULL,
+ },
+ /* FontCreator class part */
+ {
+ /* extension */ NULL,
+ }
+};
+
+WidgetClass fontCreatorWidgetClass =
+ (WidgetClass) &fontCreatorClassRec;
+
+static void ClassInitialize(void)
+{
+ XtInitializeWidgetClass(fontSelectionBoxWidgetClass);
+
+ CSempty = UnsharedCS("");
+ opticalSize = Canonical("OpticalSize");
+}
+
+/* ARGSUSED */
+
+static void ResizePreview(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ Dimension height;
+ Cardinal depth;
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+
+ if (!XtIsRealized(widget) || fc->creator.gstate == 0) return;
+
+ XtVaGetValues(widget, XmNheight, &height,
+ XmNdepth, &depth, NULL);
+
+ XDPSSetContextGState(fc->creator.fsb->fsb.context, fc->creator.gstate);
+
+ XDPSSetContextParameters(fc->creator.fsb->fsb.context, XtScreen(widget),
+ depth, XtWindow(widget), height,
+ (XDPSStandardColormap *) NULL,
+ (XDPSStandardColormap *) NULL,
+ XDPSContextScreenDepth | XDPSContextDrawable);
+
+ _DPSFReclip(fc->creator.fsb->fsb.context);
+
+ XDPSUpdateContextGState(fc->creator.fsb->fsb.context, fc->creator.gstate);
+}
+
+static void DrawMM(FontCreatorWidget fc)
+{
+ int i, j;
+ String str;
+ float p[MAX_AXES];
+ float b[MAX_BLENDS];
+ int val;
+ float size;
+ char *chSize;
+ DPSContext context;
+ Dimension hgt;
+ BlendDataRec *bd = fc->creator.font->blend_data;
+ float total;
+ int bogusFont;
+
+ str = XmTextFieldGetString(fc->creator.display_text_child);
+
+ for (i = 0; i < bd->num_axes; i++) {
+ XtVaGetValues(fc->creator.axis_scale_child[i], XmNvalue, &val, NULL);
+ p[i] = _FSBNormalize(val, bd, i);
+ }
+
+ XtVaGetValues(fc->creator.preview_child, XtNheight, &hgt, NULL);
+ context = fc->creator.fsb->fsb.context;
+ if (fc->creator.gstate == 0) {
+ XDPSSetContextDrawable(context,
+ XtWindow(fc->creator.preview_child), hgt);
+ XDPSCaptureContextGState(context, &fc->creator.gstate);
+ } else XDPSSetContextGState(context, fc->creator.gstate);
+
+ /* Force b[0] to be 1 - total(b[1..n]) to avoid round-off error */
+
+ total = 0.0;
+ for (i = 1; i < bd->num_designs; i++) {
+ b[i] = 1.0;
+ for (j = 0; j < bd->num_axes; j++) {
+ if (bd->design_positions[i*bd->num_axes + j] == 1.0) b[i] *= p[j];
+ else b[i] *= 1.0 - p[j];
+ }
+ total += b[i];
+ }
+ b[0] = 1.0 - total;
+
+ XtVaGetValues(fc->creator.size_text_field_child,
+ XmNvalue, &chSize, NULL);
+
+ if (chSize == NULL || *chSize == '\0') return;
+ size = atof(chSize);
+
+ _DPSFSetUpMM(context, fc->creator.font->font_name,
+ str, size, hgt, b, bd->num_designs, &bogusFont);
+ DPSWaitContext(context);
+ XClearWindow(XtDisplay(fc->creator.preview_child),
+ XtWindow(fc->creator.preview_child));
+ _DPSFDrawMM(context, str, hgt);
+}
+
+/* ARGSUSED */
+
+static void DrawMMCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+
+ DrawMM(fc);
+}
+
+/* ARGSUSED */
+
+static void ExposeCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+ XmDrawingAreaCallbackStruct *dac =
+ (XmDrawingAreaCallbackStruct *) callData;
+
+ if (!fc->creator.preview_fixed) {
+ XSetWindowAttributes att;
+ att.bit_gravity = ForgetGravity;
+ XChangeWindowAttributes(XtDisplay(fc),
+ XtWindow(fc->creator.preview_child),
+ CWBitGravity, &att);
+ fc->creator.preview_fixed = TRUE;
+ }
+
+ if (dac != NULL && dac->event->type == Expose &&
+ dac->event->xexpose.count != 0) return;
+
+ DrawMM(fc);
+}
+
+static void SetUpBlendList(FontCreatorWidget fc)
+{
+ XmString *CSblends;
+ int count, i;
+ BlendRec *b;
+ char buf[256];
+ FontRec *f = fc->creator.font;
+
+ sprintf(buf, "%s Blends", f->face_name);
+ XtVaSetValues(fc->creator.blend_label_child,
+ XtVaTypedArg, XmNlabelString, XtRString,
+ buf, strlen(buf)+1,
+ NULL);
+
+ if (f->blend_count == 0) {
+ count = 1;
+ CSblends = &CSempty;
+
+ } else {
+ count = f->blend_count;
+ CSblends = (XmString *) XtCalloc(count, sizeof(XmString));
+
+ for (i = 0, b = f->blend_data->blends; i < f->blend_count;
+ i++, b = b->next) {
+ CSblends[i] = b->CS_blend_name;
+ }
+ }
+
+ XtVaSetValues(fc->creator.blend_scrolled_list_child, XmNitemCount, count,
+ XmNitems, CSblends, NULL);
+
+ if (f->blend_count != 0) XtFree((XtPointer) CSblends);
+}
+
+static void CalcCarryValues(FontCreatorWidget fc, FontRec *oldf, int *carry_values)
+{
+ FontRec *f = fc->creator.font;
+ BlendDataRec *bd = f->blend_data, *oldbd = oldf->blend_data;
+ int i, j;
+
+ for (i = 0; i < bd->num_axes; i++) {
+ carry_values[i] = -1;
+ for (j = 0; j < oldbd->num_axes; j++) {
+ if (bd->name[i] == oldbd->name[j]) {
+ XmScaleGetValue(fc->creator.axis_scale_child[j],
+ carry_values+i);
+ break;
+ }
+ }
+ }
+}
+
+static void SetUpAxisLabels(FontCreatorWidget fc, FontRec *oldf, int *carry_values)
+{
+ int i;
+ char buf[20];
+ XmString cs;
+ BlendDataRec *bd = fc->creator.font->blend_data, *oldbd = 0;
+ char *value;
+
+ if (oldf != NULL) oldbd = oldf->blend_data;
+
+ for (i = 0; i < bd->num_axes; i++) {
+ if (oldf == NULL || i >= oldbd->num_axes ||
+ oldbd->name[i] != bd->name[i]) {
+ cs = UnsharedCS(bd->name[i]);
+ XtVaSetValues(fc->creator.axis_label_child[i],
+ XmNlabelString, cs, NULL);
+ XmStringFree(cs);
+ }
+ if (oldf == NULL || i >= oldbd->num_axes ||
+ oldbd->min[i] != bd->min[i]) {
+ sprintf(buf, "%d", bd->min[i]);
+ cs = UnsharedCS(buf);
+ XtVaSetValues(fc->creator.axis_min_label_child[i],
+ XmNlabelString, cs, NULL);
+ XmStringFree(cs);
+ }
+ if (oldf == NULL || i >= oldbd->num_axes ||
+ oldbd->max[i] != bd->max[i]) {
+ sprintf(buf, "%d", bd->max[i]);
+ cs = UnsharedCS(buf);
+ XtVaSetValues(fc->creator.axis_max_label_child[i],
+ XmNlabelString, cs, NULL);
+ XmStringFree(cs);
+ }
+ if (oldf == NULL || carry_values[i] == -1) {
+ if (bd->name[i] == opticalSize &&
+ XmToggleButtonGadgetGetState(
+ fc->creator.follow_size_toggle_child)) {
+ XtVaGetValues(fc->creator.fsb->fsb.size_text_field_child,
+ XmNvalue, &value, NULL);
+ if (value == NULL || *value == '\0') {
+ carry_values[i] = bd->min[i];
+ } else carry_values[i] = atof(value) + 0.5;
+ } else carry_values[i] = bd->min[i];
+ }
+ if (carry_values[i] < bd->min[i]) carry_values[i] = bd->min[i];
+ else if (carry_values[i] > bd->max[i]) carry_values[i] = bd->max[i];
+ XtVaSetValues(fc->creator.axis_scale_child[i],
+ XmNminimum, bd->min[i], XmNmaximum, bd->max[i],
+ XmNvalue, carry_values[i], NULL);
+ }
+}
+
+static void ManageAxes(FontCreatorWidget fc)
+{
+ Widget w[5*MAX_AXES];
+ int i, j;
+ int diff;
+
+ diff = fc->creator.managed_axes - fc->creator.font->blend_data->num_axes;
+
+ if (diff == 0) return;
+
+ if (diff < 0) {
+ for (i = fc->creator.managed_axes, j=0; j < -diff * 5; i++, j+=5) {
+ w[j] = fc->creator.axis_label_child[i];
+ w[j+1] = fc->creator.axis_scale_child[i];
+ w[j+2] = fc->creator.axis_value_text_child[i];
+ w[j+3] = fc->creator.axis_min_label_child[i];
+ w[j+4] = fc->creator.axis_max_label_child[i];
+ }
+ XtManageChildren(w, -diff * 5);
+ } else {
+ for (i = fc->creator.font->blend_data->num_axes, j=0; j < diff * 5;
+ i++, j+=5) {
+ w[j] = fc->creator.axis_label_child[i];
+ w[j+1] = fc->creator.axis_scale_child[i];
+ w[j+2] = fc->creator.axis_value_text_child[i];
+ w[j+3] = fc->creator.axis_min_label_child[i];
+ w[j+4] = fc->creator.axis_max_label_child[i];
+ }
+ XtUnmanageChildren(w, diff * 5);
+ }
+ fc->creator.managed_axes = fc->creator.font->blend_data->num_axes;
+}
+
+static void SetScaleValues(FontCreatorWidget fc)
+{
+ int val;
+ char buf[32];
+ int i, axes;
+
+ axes = fc->creator.font->blend_data->num_axes;
+
+ for (i = 0; i < axes; i++) {
+ XmScaleGetValue(fc->creator.axis_scale_child[i], &val);
+ sprintf(buf, "%d", val);
+ XmTextFieldSetString(fc->creator.axis_value_text_child[i], buf);
+ }
+}
+
+static void SetUpAxes(FontCreatorWidget fc, FontRec *oldf)
+{
+ int carry_values[MAX_AXES];
+
+ if (oldf != NULL) CalcCarryValues(fc, oldf, carry_values);
+ SetUpAxisLabels(fc, oldf, carry_values);
+ SetScaleValues(fc);
+ ManageAxes(fc);
+}
+
+/* ARGSUSED */
+
+static void FaceSelect(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ XmListCallbackStruct *listCB = (XmListCallbackStruct *) callData;
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+ FontRec *f, *oldf = fc->creator.font;
+ int i;
+
+ i = 0;
+ f = fc->creator.family->fonts;
+ while (f != NULL) {
+ if (f->blend_data != NULL) i++;
+ if (i == listCB->item_position) break;
+ f = f->next;
+ }
+
+ if (f == NULL) return;
+ if (!_FSBDownloadFontIfNecessary(f, fc->creator.fsb)) {
+ _FSBFlushFont(fc->creator.fsb, f);
+ return;
+ }
+ if (fc->creator.font != NULL) fc->creator.font->in_font_creator = False;
+ fc->creator.font = f;
+ f->in_font_creator = True;
+ SetUpBlendList(fc);
+ SetUpAxes(fc, oldf);
+
+ DrawMM(fc);
+}
+
+static void HandleSelectedBlend(FontCreatorWidget fc, int n)
+{
+ BlendDataRec *bd = fc->creator.font->blend_data;
+ BlendRec *b;
+ int i;
+ int value;
+ char buf[32];
+
+ b = bd->blends;
+ /* List uses 1-based addressing!! */
+ for (i = 1; i < n; i++) b = b->next;
+
+ XmTextFieldSetString(fc->creator.name_text_child, b->blend_name);
+
+ for (i = 0; i < bd->num_axes; i++) {
+ value = _FSBUnnormalize(b->data[i], bd, i);
+ XmScaleSetValue(fc->creator.axis_scale_child[i], value);
+ sprintf(buf, "%d", value);
+ XmTextFieldSetString(fc->creator.axis_value_text_child[i], buf);
+ }
+}
+
+/* ARGSUSED */
+
+static void BlendSelect(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ XmListCallbackStruct *listCB = (XmListCallbackStruct *) callData;
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+
+ if (fc->creator.font->blend_count == 0) return;
+
+ HandleSelectedBlend(fc, listCB->item_position);
+
+ DrawMM(fc);
+}
+
+/* ARGSUSED */
+
+static void SetValue(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ XmScaleCallbackStruct *scaleData = (XmScaleCallbackStruct *) callData;
+ Widget text = (Widget) clientData;
+ char buf[32];
+
+ sprintf(buf, "%d", scaleData->value);
+ XmTextFieldSetString(text, buf);
+}
+
+/* ARGSUSED */
+
+static void SetScale(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ Widget scale = (Widget) clientData;
+ char *value;
+ int val, min, max;
+ char buf[32];
+
+ value = XmTextFieldGetString(widget);
+ val = atoi(value);
+ XtVaGetValues(scale, XmNminimum, &min, XmNmaximum, &max, NULL);
+ if (val < min) val = min;
+ if (val > max) val = max;
+ XmScaleSetValue(scale, val);
+
+ /* Handle range and illegal characters this way...*/
+
+ sprintf(buf, "%d", val);
+ XmTextFieldSetString(widget, buf);
+}
+
+/* ARGSUSED */
+
+static void DeleteMessage(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ XtDestroyWidget(widget);
+}
+
+static void PutUpDialog(FontCreatorWidget fc, char *name)
+{
+ Widget message, w;
+
+ message = XmCreateInformationDialog((Widget) fc, name, (ArgList) NULL, 0);
+ w = XmMessageBoxGetChild(message, XmDIALOG_CANCEL_BUTTON);
+ XtUnmanageChild(w);
+ w = XmMessageBoxGetChild(message, XmDIALOG_HELP_BUTTON);
+ XtUnmanageChild(w);
+ XtAddCallback(message, XmNokCallback, DeleteMessage, (XtPointer) NULL);
+
+ XtManageChild(message);
+}
+
+static void NoName(FontCreatorWidget fc)
+{
+ PutUpDialog(fc, "noNameMessage");
+}
+
+static void UsedName(FontCreatorWidget fc)
+{
+ PutUpDialog(fc, "usedNameMessage");
+}
+
+static void SomeUsedName(FontCreatorWidget fc)
+{
+ PutUpDialog(fc, "someUsedNameMessage");
+}
+
+static void NoSuchName(FontCreatorWidget fc)
+{
+ PutUpDialog(fc, "noSuchNameMessage");
+}
+
+static Boolean DoAdd(FontCreatorWidget fc, FontRec *f, String name)
+{
+ char *spaceName;
+ BlendRec *b, *newb, **last;
+ BlendDataRec *bd = f->blend_data;
+ int val[MAX_AXES], i;
+
+ for (b = bd->blends; b != NULL; b = b->next) {
+ if (strcmp(name, b->blend_name) == 0) return True;
+ }
+
+ newb = (BlendRec *) XtMalloc(sizeof(BlendRec));
+ newb->blend_name = Canonical(name);
+ newb->CS_blend_name = CS(newb->blend_name, (Widget) fc);
+
+ spaceName = (char *) XtMalloc(strlen(name) + 4);
+ spaceName[0] = spaceName[1] = spaceName[2] = ' ';
+ strcpy(spaceName+3, name);
+ newb->CS_space_blend_name = CS(spaceName, (Widget) fc);
+ XtFree((XtPointer) spaceName);
+
+ for (i = 0; i < bd->num_axes; i++) {
+ XtVaGetValues(fc->creator.axis_scale_child[i],
+ XmNvalue, val+i, NULL);
+ newb->data[i] = _FSBNormalize(val[i], bd, i);
+ }
+ for (/**/; i < MAX_AXES; i++) newb->data[i] = 0.0;
+
+ newb->font_name = _FSBGenFontName(f->font_name, val, bd);
+
+ f->blend_count++;
+ fc->creator.family->blend_count++;
+
+ last = &bd->blends;
+ for (b = bd->blends; b != NULL; b = b->next) {
+ if (strcmp(name, b->blend_name) < 0) break;
+ last = &b->next;
+ }
+ newb->next = b;
+ *last = newb;
+
+ SetUpBlendList(fc);
+ _FSBSetUpFaceList(fc->creator.fsb, False);
+ return False;
+}
+
+/* ARGSUSED */
+
+static void AddCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+ char *value;
+ FontRec *f;
+ Boolean failures = False;
+ BlendDataRec *bd = fc->creator.font->blend_data;
+ int i;
+
+ value = XmTextFieldGetString(fc->creator.name_text_child);
+
+ if (value == NULL || *value == '\0') {
+ NoName(fc);
+ return;
+ }
+
+ if (XmToggleButtonGadgetGetState(fc->creator.do_all_toggle_child)) {
+ for (f = fc->creator.family->fonts; f != NULL; f = f->next) {
+ if (f->blend_data != NULL &&
+ f->blend_data->num_axes == bd->num_axes) {
+ for (i = 0; i < bd->num_axes; i++) {
+ if (f->blend_data->name[i] != bd->name[i]) break;
+ }
+ if (i == bd->num_axes) failures |= DoAdd(fc, f, value);
+ }
+ }
+ if (failures) SomeUsedName(fc);
+ } else if (DoAdd(fc, fc->creator.font, value)) UsedName(fc);
+}
+
+static Boolean DoReplace(FontCreatorWidget fc, FontRec *f, String name)
+{
+ BlendDataRec *bd = f->blend_data;
+ BlendRec *b;
+ int val[MAX_AXES], i;
+
+ name = Canonical(name);
+ for (b = bd->blends; b != NULL; b = b->next) {
+ if (name == b->blend_name) {
+ for (i = 0; i < bd->num_axes; i++) {
+ XtVaGetValues(fc->creator.axis_scale_child[i],
+ XmNvalue, val+i, NULL);
+ b->data[i] = _FSBNormalize(val[i], bd, i);
+ }
+ b->font_name = _FSBGenFontName(f->font_name, val, bd);
+ if (fc->creator.fsb->fsb.currently_selected_blend == b) {
+ _FSBSetUpFaceList(fc->creator.fsb, True);
+ }
+ return False;
+ }
+ }
+ return True;
+}
+
+/* ARGSUSED */
+
+static void ReplaceCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+ char *value;
+ FontRec *f;
+ Boolean failures = True;
+ BlendDataRec *bd = fc->creator.font->blend_data;
+ int i;
+
+ value = XmTextFieldGetString(fc->creator.name_text_child);
+
+ if (value == NULL || *value == '\0') {
+ NoName(fc);
+ return;
+ }
+
+ if (XmToggleButtonGadgetGetState(fc->creator.do_all_toggle_child)) {
+ for (f = fc->creator.family->fonts; f != NULL; f = f->next) {
+ if (f->blend_data != NULL &&
+ f->blend_data->num_axes == bd->num_axes) {
+ for (i = 0; i < bd->num_axes; i++) {
+ if (f->blend_data->name[i] != bd->name[i]) break;
+ }
+ if (i == bd->num_axes) failures &= DoReplace(fc, f, value);
+ }
+ }
+ if (failures) NoSuchName(fc);
+ } else if (DoReplace(fc, fc->creator.font, value)) NoSuchName(fc);
+}
+
+static Boolean DoDelete(FontCreatorWidget fc, FontRec *f, String name)
+{
+ BlendDataRec *bd = f->blend_data;
+ BlendRec *b, *oldb;
+ Boolean current = FALSE;
+
+ name = Canonical(name);
+ for (b = bd->blends, oldb = NULL; b != NULL; oldb = b, b = b->next) {
+ if (name == b->blend_name) {
+ if (oldb == NULL) bd->blends = b->next;
+ else oldb->next = b->next;
+ if (fc->creator.fsb->fsb.currently_selected_blend == b) {
+ fc->creator.fsb->fsb.currently_selected_blend = NULL;
+ current = TRUE;
+ }
+ XtFree((XtPointer) b);
+ f->blend_count--;
+ fc->creator.family->blend_count--;
+ SetUpBlendList(fc);
+ _FSBSetUpFaceList(fc->creator.fsb, current);
+ return False;
+ }
+ }
+ return True;
+}
+
+/* ARGSUSED */
+
+static void DeleteCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+ char *value;
+ FontRec *f;
+ Boolean failures = True;
+
+ value = XmTextFieldGetString(fc->creator.name_text_child);
+
+ if (value == NULL || *value == '\0') {
+ NoName(fc);
+ return;
+ }
+
+ if (XmToggleButtonGadgetGetState(fc->creator.do_all_toggle_child)) {
+ for (f = fc->creator.family->fonts; f != NULL; f = f->next) {
+ if (f->blend_data != NULL) {
+ failures &= DoDelete(fc, f, value);
+ }
+ }
+ if (failures) NoSuchName(fc);
+ } else if (DoDelete(fc, fc->creator.font, value)) NoSuchName(fc);
+}
+
+/* ARGSUSED */
+
+static void UnmanageOptions(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+
+ XtUnmanageChild(fc->creator.option_box);
+}
+
+/* ARGSUSED */
+
+static void ShowOptions(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+
+ XtManageChild(fc->creator.option_box);
+}
+
+/* ARGSUSED */
+
+static void GenerateCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+ BlendDataRec *bd = fc->creator.font->blend_data;
+ int i, val[MAX_AXES];
+ char nameBuf[256];
+ char *ch;
+
+ for (i = 0; i < bd->num_axes; i++) {
+ XtVaGetValues(fc->creator.axis_scale_child[i],
+ XmNvalue, val+i, NULL);
+ }
+
+ ch = nameBuf;
+
+ for (i = 0; i < bd->num_axes - 1; i++) {
+ sprintf(ch, "%d ", val[i]);
+ ch = ch + strlen(ch);
+ }
+
+ sprintf(ch, "%d", val[bd->num_axes - 1]);
+
+ XmTextFieldSetString(fc->creator.name_text_child, nameBuf);
+}
+
+/* ARGSUSED */
+
+static void DismissCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+
+ if (XtIsShell(XtParent(fc))) XtPopdown(XtParent(fc));
+ XtCallCallbackList(widget, fc->creator.dismiss_callback, (XtPointer) NULL);
+}
+
+/* ARGSUSED */
+
+static void SizeChanged(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ String value;
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+ int size;
+ FontRec *f = fc->creator.font;
+ BlendDataRec *bd;
+ int i;
+ char buf[32];
+
+ if (f == NULL || f->blend_data == NULL) return;
+
+ /* See if we have an optical size scale */
+ bd = f->blend_data;
+
+ for (i = 0; i < bd->num_axes; i++) {
+ if (bd->name[i] == opticalSize) break;
+ }
+ if (i == bd->num_axes) return;
+
+ if (!XmToggleButtonGadgetGetState(fc->creator.follow_size_toggle_child)) {
+ return;
+ }
+
+ XtVaGetValues(widget, XmNvalue, &value, NULL);
+
+ if (value == NULL || *value == '\0') return;
+ size = atof(value) + 0.5;
+ sprintf(buf, "%d", size);
+ XmTextFieldSetString(fc->creator.axis_value_text_child[i], buf);
+
+ SetScale(fc->creator.axis_value_text_child[i],
+ (XtPointer) fc->creator.axis_scale_child[i], (XtPointer) NULL);
+ DrawMM(fc);
+}
+
+/* There's a problem; sometimes the change has already been made in the field,
+ and sometimes it hasn't. The times when it has seem to correspond to
+ making changes with the size option menu, so we use this disgusting
+ global flag to notice when this happens. We also use this to tell whether
+ or not the change is coming from internal to the widget or as a result
+ of user interaction. */
+
+static Boolean changingSize = False;
+
+/* ARGSUSED */
+
+static void SizeSelect(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ String value;
+ Widget option;
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+ char *ch;
+
+ XtVaGetValues(widget, XmNvalue, &value, NULL);
+
+ if (value == NULL) option = fc->creator.other_size;
+ else {
+ for (ch = value; *ch != '\0'; ch++) if (*ch == '.') *ch = '-';
+
+ option = XtNameToWidget(fc->creator.size_menu, value);
+ if (option == NULL) option = fc->creator.other_size;
+ }
+
+ XtVaSetValues(fc->creator.size_option_menu_child,
+ XmNmenuHistory, option, NULL);
+}
+
+/* ARGSUSED */
+
+static void TextVerify(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ XmTextVerifyPtr v = (XmTextVerifyPtr) callData;
+ char ch, *cp;
+ int decimalPoints = 0;
+ int i;
+
+ if (changingSize) return; /* We know what we're doing; allow it */
+
+ /* Should probably look at format field, but seems to contain garbage */
+
+ if (v->text->length == 0) return;
+
+ for (i = 0; i < v->text->length; i++) {
+ ch = v->text->ptr[i];
+ if (ch == '.') decimalPoints++;
+ else if (!isdigit(ch)) {
+ v->doit = False;
+ return;
+ }
+ }
+
+ if (decimalPoints > 1) {
+ v->doit = False;
+ return;
+ }
+
+ XtVaGetValues(widget, XmNvalue, &cp, NULL);
+
+ for (/**/; *cp != '\0'; cp++) {
+ if (*cp == '.') decimalPoints++;
+ }
+
+ if (decimalPoints > 1) v->doit = False;
+}
+
+/* ARGSUSED */
+
+static void SetSize(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ char buf[20];
+ char *ch;
+ FontCreatorWidget fc = (FontCreatorWidget) clientData;
+
+ strcpy(buf, XtName(widget));
+ for (ch = buf; *ch != '\0'; ch++) if (*ch == '-') *ch++ = '.';
+
+ changingSize = True;
+ XtVaSetValues(fc->creator.size_text_field_child, XmNvalue, buf, NULL);
+ changingSize = False;
+}
+
+/* This makes sure the selected item is visible */
+
+static void ListSelectPos(Widget w, int pos, Boolean notify)
+{
+ int topPos, items, visible;
+
+ XmListSelectPos(w, pos, notify);
+
+ XtVaGetValues(w, XmNtopItemPosition, &topPos,
+ XmNvisibleItemCount, &visible,
+ XmNitemCount, &items, NULL);
+
+ if (pos >= topPos && pos < topPos + visible) return;
+ topPos = pos - (visible-1)/2;
+ if (topPos + visible > items) topPos = items - visible + 1;
+ if (topPos < 1) topPos = 1;
+
+ XtVaSetValues(w, XmNtopItemPosition, topPos, NULL);
+}
+
+static void CreateSizeMenu(
+ FontCreatorWidget fc,
+ Boolean destroyOldChildren)
+{
+ Arg args[20];
+ int i, j;
+ Widget *sizes;
+ char buf[20];
+ Widget *children;
+ Cardinal num_children;
+ XmString csName;
+ char *ch;
+
+ if (destroyOldChildren) {
+ XtVaGetValues(fc->creator.size_menu, XtNchildren, &children,
+ XtNnumChildren, &num_children, NULL);
+
+ /* Don't destroy first child ("other") */
+ for (j = 1; (Cardinal)j < num_children; j++) XtDestroyWidget(children[j]);
+
+ sizes = (Widget *) XtMalloc((fc->creator.size_count+1) *
+ sizeof(Widget));
+ sizes[0] = children[0];
+ } else {
+ sizes = (Widget *) XtMalloc((fc->creator.size_count+1) *
+ sizeof(Widget));
+ i = 0;
+ fc->creator.other_size = sizes[0] =
+ XtCreateManagedWidget("other", xmPushButtonGadgetClass,
+ fc->creator.size_menu, args, i);
+ }
+
+ for (j = 0; j < fc->creator.size_count; j++) {
+ (void) sprintf(buf, "%g", fc->creator.sizes[j]);
+ csName = UnsharedCS(buf);
+ for (ch = buf; *ch != '\0'; ch++) if (*ch == '.') *ch = '-';
+ i = 0;
+ XtSetArg(args[i], XmNlabelString, csName); i++;
+ sizes[j+1] =
+ XmCreatePushButtonGadget(fc->creator.size_menu, buf, args, i);
+ XmStringFree(csName);
+ XtAddCallback(sizes[j+1], XmNactivateCallback,
+ SetSize, (XtPointer) fc);
+ XtAddCallback(sizes[j+1], XmNactivateCallback,
+ DrawMMCallback, (XtPointer) fc);
+ }
+ XtManageChildren(sizes, j+1);
+ XtFree((char *) sizes);
+}
+
+static void CreateChildren(FontCreatorWidget fc)
+{
+ Arg args[20];
+ int i, j;
+ Widget form, prev, w, label, sep, button;
+ char buf[20];
+
+ i = 0;
+ fc->creator.pane_child =
+ XtCreateManagedWidget("pane", xmPanedWindowWidgetClass,
+ (Widget) fc, args, i);
+
+ i = 0;
+ fc->creator.preview_child =
+ XtCreateManagedWidget("preview", xmDrawingAreaWidgetClass,
+ fc->creator.pane_child, args, i);
+ XtAddCallback(fc->creator.preview_child, XmNexposeCallback,
+ ExposeCallback, (XtPointer) fc);
+ XtAddCallback(fc->creator.preview_child, XmNresizeCallback,
+ ResizePreview, (XtPointer) fc);
+
+ i = 0;
+ form = XtCreateManagedWidget("panel", xmFormWidgetClass,
+ fc->creator.pane_child, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ button = XtCreateManagedWidget("deleteButton", xmPushButtonGadgetClass,
+ form, args, i);
+ XtAddCallback(button, XmNactivateCallback, DeleteCallback, (XtPointer) fc);
+
+ i = 0;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, button); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ button = XtCreateManagedWidget("replaceButton", xmPushButtonGadgetClass,
+ form, args, i);
+ XtAddCallback(button, XmNactivateCallback,
+ ReplaceCallback, (XtPointer) fc);
+
+ i = 0;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, button); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ button = XtCreateManagedWidget("addButton", xmPushButtonGadgetClass,
+ form, args, i);
+ XtAddCallback(button, XmNactivateCallback, AddCallback, (XtPointer) fc);
+
+ i = 0;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, button); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ fc->creator.generate_button_child =
+ XtCreateManagedWidget("generateButton", xmPushButtonGadgetClass,
+ form, args, i);
+ XtAddCallback(fc->creator.generate_button_child, XmNactivateCallback,
+ GenerateCallback, (XtPointer) fc);
+
+ i = 0;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, fc->creator.generate_button_child);i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ button = XtCreateManagedWidget("optionsButton", xmPushButtonGadgetClass,
+ form, args, i);
+ XtAddCallback(button, XmNactivateCallback, ShowOptions, (XtPointer) fc);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ button = XtCreateManagedWidget("dismissButton", xmPushButtonGadgetClass,
+ form, args, i);
+ XtAddCallback(button, XmNactivateCallback,
+ DismissCallback, (XtPointer) fc);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, button); i++;
+ sep = XtCreateManagedWidget("separator", xmSeparatorGadgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, sep); i++;
+ label = XtCreateManagedWidget("sizeLabel", xmLabelGadgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, label); i++;
+ fc->creator.size_text_field_child =
+ XtCreateManagedWidget("sizeTextField", xmTextFieldWidgetClass,
+ form, args, i);
+ XtAddCallback(fc->creator.size_text_field_child, XmNvalueChangedCallback,
+ SizeSelect, (XtPointer) fc);
+ XtAddCallback(fc->creator.size_text_field_child, XmNmodifyVerifyCallback,
+ TextVerify, (XtPointer) fc);
+ XtAddCallback(fc->creator.size_text_field_child, XmNactivateCallback,
+ DrawMMCallback, (XtPointer) fc);
+
+ i = 0;
+ fc->creator.size_menu = XmCreatePulldownMenu(form, "sizeMenu", args, i);
+
+ CreateSizeMenu(fc, FALSE);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, fc->creator.size_text_field_child);i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, label); i++;
+ XtSetArg(args[i], XmNsubMenuId, fc->creator.size_menu); i++;
+ fc->creator.size_option_menu_child =
+ XmCreateOptionMenu(form, "sizeOptionMenu", args, i);
+ XtManageChild(fc->creator.size_option_menu_child);
+
+ SizeSelect(fc->creator.size_text_field_child, (XtPointer) fc,
+ (XtPointer) NULL);
+
+ i = 0;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, sep); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_POSITION); i++;
+ fc->creator.name_text_child =
+ XtCreateManagedWidget("nameText", xmTextFieldWidgetClass,
+ form, args, i);
+ XtAddCallback(fc->creator.name_text_child, XmNactivateCallback,
+ AddCallback, (XtPointer) fc);
+
+ i = 0;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, fc->creator.name_text_child); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_POSITION); i++;
+ label = XtCreateManagedWidget("nameLabel", xmLabelGadgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ label = XtCreateManagedWidget("faceLabel",xmLabelGadgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNitemCount, 1); i++;
+ XtSetArg(args[i], XmNitems, &CSempty); i++;
+ fc->creator.face_scrolled_list_child =
+ XmCreateScrolledList(form, "faceList", args, i);
+ XtAddCallback(fc->creator.face_scrolled_list_child,
+ XmNbrowseSelectionCallback, FaceSelect, (XtPointer) fc);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, label); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
+ XtSetValues(XtParent(fc->creator.face_scrolled_list_child), args, i);
+ XtManageChild(fc->creator.face_scrolled_list_child);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ fc->creator.blend_label_child =
+ XtCreateManagedWidget("blendLabel",xmLabelGadgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNitemCount, 1); i++;
+ XtSetArg(args[i], XmNitems, &CSempty); i++;
+ fc->creator.blend_scrolled_list_child =
+ XmCreateScrolledList(form, "blendList", args, i);
+ XtAddCallback(fc->creator.blend_scrolled_list_child,
+ XmNbrowseSelectionCallback, BlendSelect, (XtPointer) fc);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, fc->creator.blend_label_child); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, fc->creator.name_text_child); i++;
+ XtSetValues(XtParent(fc->creator.blend_scrolled_list_child), args, i);
+ XtManageChild(fc->creator.blend_scrolled_list_child);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget,
+ XtParent(fc->creator.face_scrolled_list_child)); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_POSITION); i++;
+ fc->creator.display_text_child =
+ XtCreateManagedWidget("displayText", xmTextFieldWidgetClass,
+ form, args, i);
+ XtAddCallback(fc->creator.display_text_child, XmNactivateCallback,
+ DrawMMCallback, (XtPointer) fc);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, fc->creator.display_text_child); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_POSITION); i++;
+ label = XtCreateManagedWidget("displayTextLabel", xmLabelGadgetClass,
+ form, args, i);
+
+ prev = fc->creator.display_text_child;
+
+ for (j = 0; j < 4; j++) {
+ i = 0;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, prev); i++;
+ sprintf(buf, "axisValue%d", j+1);
+ fc->creator.axis_value_text_child[j] =
+ XtCreateWidget(buf, xmTextFieldWidgetClass, form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget,
+ fc->creator.axis_value_text_child[j]); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget,
+ fc->creator.axis_value_text_child[j]); i++;
+ sprintf(buf, "axisScale%d", j+1);
+ fc->creator.axis_scale_child[j] =
+ XtCreateWidget(buf, xmScaleWidgetClass, form, args, i);
+ XtAddCallback(fc->creator.axis_scale_child[j],
+ XmNvalueChangedCallback, DrawMMCallback, (XtPointer) fc);
+ XtAddCallback(fc->creator.axis_scale_child[j],
+ XmNdragCallback, DrawMMCallback, (XtPointer) fc);
+ XtAddCallback(fc->creator.axis_scale_child[j],
+ XmNvalueChangedCallback, SetValue,
+ (XtPointer) fc->creator.axis_value_text_child[j]);
+ XtAddCallback(fc->creator.axis_scale_child[j],
+ XmNdragCallback, SetValue,
+ (XtPointer) fc->creator.axis_value_text_child[j]);
+ XtAddCallback(fc->creator.axis_value_text_child[j],
+ XmNactivateCallback, SetScale,
+ (XtPointer) fc->creator.axis_scale_child[j]);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget,
+ fc->creator.axis_scale_child[j]); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET);i++;
+ XtSetArg(args[i], XmNrightWidget,
+ fc->creator.axis_scale_child[j]); i++;
+ sprintf(buf, "axisMax%d", j+1);
+ fc->creator.axis_max_label_child[j] =
+ XtCreateWidget(buf, xmLabelGadgetClass, form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget,
+ fc->creator.axis_scale_child[j]); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget,
+ fc->creator.axis_scale_child[j]); i++;
+ sprintf(buf, "axisMin%d", j+1);
+ fc->creator.axis_min_label_child[j] =
+ XtCreateWidget(buf, xmLabelGadgetClass, form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget,
+ fc->creator.axis_value_text_child[j]); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_POSITION); i++;
+ sprintf(buf, "axisLabel%d", j+1);
+ fc->creator.axis_label_child[j] =
+ XtCreateWidget(buf, xmLabelGadgetClass, form, args, i);
+
+ prev = fc->creator.axis_value_text_child[j];
+ }
+
+ /* Create the options box so we have the toggles */
+
+ fc->creator.option_box = XmCreateFormDialog((Widget) fc, "optionBox",
+ (Arg *) NULL, 0);
+ w = XtCreateManagedWidget("filterBox", xmRowColumnWidgetClass,
+ fc->creator.option_box, (Arg *) NULL, 0);
+ fc->creator.do_all_toggle_child =
+ XtCreateManagedWidget("doAllToggle", xmToggleButtonGadgetClass,
+ w, (Arg *) NULL, 0);
+ fc->creator.follow_size_toggle_child =
+ XtCreateManagedWidget("followSizeToggle",
+ xmToggleButtonGadgetClass,
+ w, (Arg *) NULL, 0);
+ button = XtCreateManagedWidget("dismissOptionButton",
+ xmPushButtonGadgetClass,
+ w, (Arg *) NULL, 0);
+ XtAddCallback(button, XmNactivateCallback,
+ UnmanageOptions, (XtPointer) fc);
+}
+
+/* ARGSUSED */
+
+static void Initialize(
+ Widget request, Widget new,
+ ArgList args,
+ Cardinal *num_args)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) new;
+
+ /* Must have a fsb */
+
+ if (fc->creator.fsb == NULL) {
+ XtAppErrorMsg(XtWidgetToApplicationContext(new),
+ "initializeFontCreator", "noFontSelectionBox",
+ "FontSelectionBoxError",
+ "No font selection box given to font creator",
+ (String *) NULL, (Cardinal *) NULL);
+ }
+
+ /* Verify size list */
+
+ if (fc->creator.size_count > 0 && fc->creator.sizes == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "initializeFontCreator", "sizeMismatch",
+ "FontSelectionBoxError",
+ "Size count specified but no sizes present",
+ (String *) NULL, (Cardinal *) NULL);
+ fc->creator.size_count = 0;
+ }
+
+ if (fc->creator.size_count < 0) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "initializeFontCreator", "negativeSize",
+ "FontSelectionBoxError",
+ "Size count should not be negative",
+ (String *) NULL, (Cardinal *) NULL);
+ fc->creator.size_count = 0;
+ }
+
+ fc->creator.gstate = 0;
+ fc->creator.family = NULL;
+ fc->creator.font = NULL;
+ fc->creator.managed_axes = 0;
+ fc->creator.preview_fixed = False;
+ fc->creator.option_box = NULL;
+
+ CreateChildren(fc);
+ XtAddCallback(fc->creator.fsb->fsb.size_text_field_child,
+ XmNvalueChangedCallback, SizeChanged, (XtPointer) fc);
+}
+
+static void SelectBlend(FontCreatorWidget fc, BlendRec *cur_b)
+{
+ int i, cur = 0;
+ BlendRec *b;
+ int *selectList, selectCount;
+
+ if (cur_b == NULL) {
+ if (!XmListGetSelectedPos(fc->creator.blend_scrolled_list_child,
+ &selectList, &selectCount)) return;
+ if (selectCount == 0 || *selectList < 1) return;
+ cur = *selectList;
+ XtFree((XtPointer) selectList);
+ } else {
+ for (i = 0, b = fc->creator.font->blend_data->blends;
+ i < fc->creator.font->blend_count; i++, b = b->next) {
+ if (b == cur_b) {
+ cur = i+1;
+ break;
+ }
+ }
+ }
+ ListSelectPos(fc->creator.blend_scrolled_list_child, cur, FALSE);
+ HandleSelectedBlend(fc, cur);
+}
+
+void _FSBSetCreatorFamily(Widget w, FontFamilyRec *ff)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) w;
+ int i, count = 0, cur = 1;
+ FontRec *newf = NULL, *f, *oldf = fc->creator.font;
+ XmString *CSfaces;
+
+ if (ff != fc->creator.family) {
+ fc->creator.family = ff;
+
+ CSfaces = (XmString *) XtCalloc(ff->font_count, sizeof(XmString));
+
+ for (i = 0, f = ff->fonts; i < ff->font_count; i++, f = f->next) {
+ if (f->blend_data == NULL) continue;
+
+ if (newf == NULL) newf = f;
+ CSfaces[count] = f->CS_face_name;
+ count++;
+ if (f == fc->creator.fsb->fsb.currently_selected_face) {
+ cur = count;
+ newf = f;
+ }
+ }
+
+ XtVaSetValues(fc->creator.face_scrolled_list_child,
+ XmNitemCount, count, XmNitems, CSfaces, NULL);
+
+ XtFree((XtPointer) CSfaces);
+
+ } else {
+ for (i = 0, f = ff->fonts; i < ff->font_count; i++, f = f->next) {
+ if (f->blend_data == NULL) continue;
+ count++;
+ if (newf == NULL) newf = f;
+ if (f == fc->creator.fsb->fsb.currently_selected_face) {
+ cur = count;
+ newf = f;
+ break;
+ }
+ }
+ }
+
+ if (fc->creator.font != NULL) fc->creator.font->in_font_creator = False;
+ fc->creator.font = newf;
+ newf->in_font_creator = True;
+ ListSelectPos(fc->creator.face_scrolled_list_child, cur, FALSE);
+ SetUpBlendList(fc);
+ SetUpAxes(fc, oldf);
+ if (fc->creator.fsb->fsb.currently_selected_blend != 0) {
+ SelectBlend(fc, fc->creator.fsb->fsb.currently_selected_blend);
+ } else {
+ SelectBlend(fc, NULL);
+ }
+ SetScaleValues(fc);
+ XmTextFieldSetString(fc->creator.display_text_child, ff->family_name);
+ DrawMM(fc);
+}
+
+static void Destroy(Widget widget)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) widget;
+
+ if (fc->creator.gstate != 0) {
+ XDPSFreeContextGState(fc->creator.fsb->fsb.context,
+ fc->creator.gstate);
+ }
+}
+
+static void Resize(Widget widget)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) widget;
+
+ XtResizeWidget(fc->creator.pane_child, fc->core.width, fc->core.height, 0);
+}
+
+/* ARGSUSED */
+
+static Boolean SetValues(
+ Widget old, Widget req, Widget new,
+ ArgList args,
+ Cardinal *num_args)
+{
+ FontCreatorWidget oldfc = (FontCreatorWidget) old;
+ FontCreatorWidget newfc = (FontCreatorWidget) new;
+
+#define NE(field) newfc->creator.field != oldfc->creator.field
+
+ if (NE(fsb)) newfc->creator.fsb = oldfc->creator.fsb;
+
+ if (newfc->creator.size_count > 0 && newfc->creator.sizes == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "setValuesFontCreator", "sizeMismatch",
+ "FontSelectionBoxError",
+ "Size count specified but no sizes present",
+ (String *) NULL, (Cardinal *) NULL);
+ newfc->creator.size_count = 0;
+ }
+
+ if (newfc->creator.size_count < 0) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "setValuesFontCreator", "negativeSize",
+ "FontSelectionBoxError",
+ "Size count should not be negative",
+ (String *) NULL, (Cardinal *) NULL);
+ newfc->creator.size_count = 0;
+ }
+
+ if (NE(sizes)) CreateSizeMenu(newfc, TRUE);
+#undef NE
+ return False;
+}
+
+/* ARGSUSED */
+
+static XtGeometryResult GeometryManager(
+ Widget w,
+ XtWidgetGeometry *desired, XtWidgetGeometry *allowed)
+{
+#define WANTS(flag) (desired->request_mode & flag)
+
+ if (WANTS(XtCWQueryOnly)) return XtGeometryYes;
+
+ if (WANTS(CWWidth)) w->core.width = desired->width;
+ if (WANTS(CWHeight)) w->core.height = desired->height;
+ if (WANTS(CWX)) w->core.x = desired->x;
+ if (WANTS(CWY)) w->core.y = desired->y;
+ if (WANTS(CWBorderWidth)) {
+ w->core.border_width = desired->border_width;
+ }
+
+ return XtGeometryYes;
+#undef WANTS
+}
+
+static void ChangeManaged(Widget w)
+{
+ FontCreatorWidget fc = (FontCreatorWidget) w;
+
+ w->core.width = fc->composite.children[0]->core.width;
+ w->core.height = fc->composite.children[0]->core.height;
+}
diff --git a/nx-X11/lib/dpstk/FontSB.c b/nx-X11/lib/dpstk/FontSB.c
new file mode 100644
index 000000000..a529f3af0
--- /dev/null
+++ b/nx-X11/lib/dpstk/FontSB.c
@@ -0,0 +1,4884 @@
+/*
+ * FontSB.c
+ *
+ * (c) Copyright 1991-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <math.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <Xm/Xm.h>
+
+/* There are no words to describe how I feel about having to do this */
+
+#if XmVersion > 1001
+#include <Xm/ManagerP.h>
+#else
+#include <Xm/XmP.h>
+#endif
+
+#include <Xm/Form.h>
+#include <Xm/List.h>
+#include <Xm/Label.h>
+#include <Xm/LabelG.h>
+#include <Xm/PushB.h>
+#include <Xm/PanedW.h>
+#include <Xm/PushBG.h>
+#include <Xm/SeparatoG.h>
+#include <Xm/TextF.h>
+#include <Xm/RowColumn.h>
+#include <Xm/DrawingA.h>
+#include <Xm/MessageB.h>
+#include <DPS/dpsXclient.h>
+#include "dpsXcommonI.h"
+#include <DPS/dpsXcommon.h>
+#include <DPS/dpsXshare.h>
+#include <DPS/PSres.h>
+#include <DPS/FontSBP.h>
+#include "FSBwraps.h"
+#include "FontSBI.h"
+#include <DPS/FontSample.h>
+#include <DPS/FontCreato.h>
+#include <pwd.h>
+
+#define PATH_BUF_SIZE 1024
+
+/* Turn a string into a compound string */
+#define UnsharedCS(str) XmStringCreate(str, XmSTRING_DEFAULT_CHARSET)
+#define CS(str, w) _FSBCreateSharedCS(str, w)
+static XmString CSempty;
+
+/* Create a canonical representation of a string, and as a side effect
+ make sure the string is in permanent storage. This implementation may
+ not work under all Xlibs */
+
+#define Canonical(str) XrmQuarkToString(XrmStringToQuark(str))
+
+static float defaultSizeList[] = {
+#ifndef DEFAULT_SIZE_LIST
+ 8, 10, 12, 14, 16, 18, 24, 36, 48, 72
+#else
+ DEFAULT_SIZE_LIST
+#endif /* DEFAULT_SIZE_LIST */
+};
+
+#ifndef DEFAULT_SIZE_LIST_COUNT
+#define DEFAULT_SIZE_LIST_COUNT 10
+#endif /* DEFAULT_SIZE_LIST_COUNT */
+
+#ifndef DEFAULT_SIZE
+static float default_size = 12.0;
+#else
+static float default_size = DEFAULT_SIZE
+#endif /* DEFAULT_SIZE */
+
+#ifndef DEFAULT_RESOURCE_PATH
+#define DEFAULT_RESOURCE_PATH NULL
+#endif /* DEFAULT_RESOURCE_PATH */
+
+#ifndef DEFAULT_MAX_PENDING
+#define DEFAULT_MAX_PENDING 10
+#endif /* DEFAULT_MAX_PENDING */
+
+#define Offset(field) XtOffsetOf(FontSelectionBoxRec, fsb.field)
+
+static XtResource resources[] = {
+ {XtNcontext, XtCContext, XtRDPSContext, sizeof(DPSContext),
+ Offset(context), XtRDPSContext, (XtPointer) NULL},
+ {XtNpreviewString, XtCPreviewString, XtRString, sizeof(String),
+ Offset(preview_string), XtRString, (XtPointer) NULL},
+ {XtNsizes, XtCSizes, XtRFloatList, sizeof(float*),
+ Offset(sizes), XtRImmediate, (XtPointer) defaultSizeList},
+ {XtNsizeCount, XtCSizeCount, XtRInt, sizeof(int),
+ Offset(size_count), XtRImmediate, (XtPointer) DEFAULT_SIZE_LIST_COUNT},
+ {XtNdefaultResourcePath, XtCDefaultResourcePath, XtRString, sizeof(String),
+ Offset(default_resource_path), XtRImmediate,
+ (XtPointer) DEFAULT_RESOURCE_PATH},
+ {XtNresourcePathOverride, XtCResourcePathOverride,
+ XtRString, sizeof(String),
+ Offset(resource_path_override), XtRString, (XtPointer) NULL},
+ {XtNuseFontName, XtCUseFontName, XtRBoolean, sizeof(Boolean),
+ Offset(use_font_name), XtRImmediate, (XtPointer) True},
+ {XtNfontName, XtCFontName, XtRString, sizeof(String),
+ Offset(font_name), XtRString, (XtPointer) NULL},
+ {XtNfontFamily, XtCFontFamily, XtRString, sizeof(String),
+ Offset(font_family), XtRString, (XtPointer) NULL},
+ {XtNfontFace, XtCFontFace, XtRString, sizeof(String),
+ Offset(font_face), XtRString, (XtPointer) NULL},
+ {XtNfontBlend, XtCFontBlend, XtRString, sizeof(String),
+ Offset(font_blend), XtRString, (XtPointer) NULL},
+ {XtNfontSize, XtCFontSize, XtRFloat, sizeof(String),
+ Offset(font_size), XtRFloat, (XtPointer) &default_size},
+ {XtNfontNameMultiple, XtCFontNameMultiple, XtRBoolean, sizeof(Boolean),
+ Offset(font_name_multiple), XtRImmediate, (XtPointer) False},
+ {XtNfontFamilyMultiple, XtCFontFamilyMultiple, XtRBoolean, sizeof(Boolean),
+ Offset(font_family_multiple), XtRImmediate, (XtPointer) False},
+ {XtNfontFaceMultiple, XtCFontFaceMultiple, XtRBoolean, sizeof(Boolean),
+ Offset(font_face_multiple), XtRImmediate, (XtPointer) False},
+ {XtNfontSizeMultiple, XtCFontSizeMultiple, XtRBoolean, sizeof(Boolean),
+ Offset(font_size_multiple), XtRImmediate, (XtPointer) False},
+ {XtNgetServerFonts, XtCGetServerFonts, XtRBoolean, sizeof(Boolean),
+ Offset(get_server_fonts), XtRImmediate, (XtPointer) True},
+ {XtNgetAFM, XtCGetAFM, XtRBoolean, sizeof(Boolean),
+ Offset(get_afm), XtRImmediate, (XtPointer) False},
+ {XtNautoPreview, XtCAutoPreview, XtRBoolean, sizeof(Boolean),
+ Offset(auto_preview), XtRImmediate, (XtPointer) True},
+ {XtNpreviewOnChange, XtCPreviewOnChange, XtRBoolean, sizeof(Boolean),
+ Offset(preview_on_change), XtRImmediate, (XtPointer) True},
+ {XtNundefUnusedFonts, XtCUndefUnusedFonts, XtRBoolean, sizeof(Boolean),
+ Offset(undef_unused_fonts), XtRImmediate, (XtPointer) True},
+ {XtNmaxPendingDeletes, XtCMaxPendingDeletes, XtRCardinal, sizeof(Cardinal),
+ Offset(max_pending_deletes), XtRImmediate,
+ (XtPointer) DEFAULT_MAX_PENDING},
+ {XtNmakeFontsShared, XtCMakeFontsShared, XtRBoolean, sizeof(Boolean),
+ Offset(make_fonts_shared), XtRImmediate, (XtPointer) True},
+ {XtNshowSampler, XtCShowSampler, XtRBoolean, sizeof(Boolean),
+ Offset(show_sampler), XtRImmediate, (XtPointer) False},
+ {XtNshowSamplerButton, XtCShowSamplerButton, XtRBoolean, sizeof(Boolean),
+ Offset(show_sampler_button), XtRImmediate, (XtPointer) True},
+ {XtNtypographicSort, XtCTypographicSort, XtRBoolean, sizeof(Boolean),
+ Offset(typographic_sort), XtRImmediate, (XtPointer) True},
+
+ {XtNokCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(ok_callback), XtRCallback, (XtPointer) NULL},
+ {XtNapplyCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(apply_callback), XtRCallback, (XtPointer) NULL},
+ {XtNresetCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(reset_callback), XtRCallback, (XtPointer) NULL},
+ {XtNcancelCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(cancel_callback), XtRCallback, (XtPointer) NULL},
+ {XtNvalidateCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(validate_callback), XtRCallback, (XtPointer) NULL},
+ {XtNfaceSelectCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(face_select_callback), XtRCallback, (XtPointer) NULL},
+ {XtNcreateSamplerCallback, XtCCallback, XtRCallback,
+ sizeof(XtCallbackList), Offset(create_sampler_callback),
+ XtRCallback, (XtPointer) NULL},
+ {XtNcreateCreatorCallback, XtCCallback, XtRCallback,
+ sizeof(XtCallbackList), Offset(create_creator_callback),
+ XtRCallback, (XtPointer) NULL},
+ {XtNvalueChangedCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(value_changed_callback), XtRCallback, (XtPointer) NULL},
+
+ {XtNpaneChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(pane_child), XtRWidget, (XtPointer) NULL},
+ {XtNpreviewChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(preview_child), XtRWidget, (XtPointer) NULL},
+ {XtNpanelChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(panel_child), XtRWidget, (XtPointer) NULL},
+ {XtNfamilyLabelChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(family_label_child), XtRWidget, (XtPointer) NULL},
+ {XtNfamilyMultipleLabelChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(family_multiple_label_child), XtRWidget, (XtPointer) NULL},
+ {XtNfamilyScrolledListChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(family_scrolled_list_child), XtRWidget, (XtPointer) NULL},
+ {XtNfaceLabelChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(face_label_child), XtRWidget, (XtPointer) NULL},
+ {XtNfaceMultipleLabelChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(face_multiple_label_child), XtRWidget, (XtPointer) NULL},
+ {XtNfaceScrolledListChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(face_scrolled_list_child), XtRWidget, (XtPointer) NULL},
+ {XtNsizeLabelChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(size_label_child), XtRWidget, (XtPointer) NULL},
+ {XtNsizeTextFieldChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(size_text_field_child), XtRWidget, (XtPointer) NULL},
+ {XtNsizeOptionMenuChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(size_option_menu_child), XtRWidget, (XtPointer) NULL},
+ {XtNsizeMultipleLabelChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(size_multiple_label_child), XtRWidget, (XtPointer) NULL},
+ {XtNpreviewButtonChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(preview_button_child), XtRWidget, (XtPointer) NULL},
+ {XtNsamplerButtonChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(sampler_button_child), XtRWidget, (XtPointer) NULL},
+ {XtNseparatorChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(separator_child), XtRWidget, (XtPointer) NULL},
+ {XtNokButtonChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(ok_button_child), XtRWidget, (XtPointer) NULL},
+ {XtNapplyButtonChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(apply_button_child), XtRWidget, (XtPointer) NULL},
+ {XtNresetButtonChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(reset_button_child), XtRWidget, (XtPointer) NULL},
+ {XtNcancelButtonChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(cancel_button_child), XtRWidget, (XtPointer) NULL},
+ {XtNmultipleMasterButtonChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(multiple_master_button_child), XtRWidget, (XtPointer) NULL}
+};
+
+/* Forward declarations */
+
+static Boolean ChangeBlends(Widget w, String base_name, String blend_name, FSBBlendAction action, int *axis_values, float *axis_percents);
+static Boolean DownloadFontName(Widget w, String name);
+static Boolean MatchFontFace(Widget w, String old_face, String new_family, String *new_face);
+static Boolean SetValues(Widget old, Widget req, Widget new, ArgList args, Cardinal *num_args);
+static Boolean Verify(FontSelectionBoxWidget fsb, FSBValidateCallbackRec *cb, String afm, Boolean doIt);
+static String FindAFM(Widget w, String name);
+static String FindFontFile(Widget w, String name);
+static XtGeometryResult GeometryManager(Widget w, XtWidgetGeometry *desired, XtWidgetGeometry *allowed);
+static void ChangeManaged(Widget w);
+static void ClassInitialize(void);
+static void ClassPartInitialize(WidgetClass widget_class);
+static void Destroy(Widget widget);
+static void DisplayFontFamilies(FontSelectionBoxWidget fsb);
+static void FontFamilyFaceBlendToName(Widget w, String family, String face, String blend, String *font_name);
+static void FontFamilyFaceToName(Widget w, String family, String face, String *font_name);
+static void FontNameToFamilyFace(Widget w, String font_name, String *family, String *face);
+static void FontNameToFamilyFaceBlend(Widget w, String font_name, String *family, String *face, String *blend);
+static void FreeFontRec(FontRec *f);
+static void GetBlendInfo(Widget w, String name, int *num_axes_return, int *num_designs_return, String **axis_names_return, float **blend_positions_return, int **blend_map_count_return, int **blend_design_coords_return, float **blend_normalized_coords_return);
+static void GetBlendList(Widget w, String name, int *count_return, String **blend_return, String **font_name_return, float **axis_values_return);
+static void GetFaceList(Widget w, String family, int *count, String **face_list, String **font_list);
+static void GetFamilyList(Widget w, int *count, String **list);
+static void GetTextDimensions(Widget w, String text, String font, double size, double x, double y, float *dx, float *dy, float *left, float *right, float *top, float *bottom);
+static void Initialize(Widget request, Widget new, ArgList args, Cardinal *num_args);
+static void ReadBlends(FontSelectionBoxWidget fsb);
+static void RefreshFontList(Widget w);
+static void Resize(Widget widget);
+static void SetFontFamilyFace(Widget w, String family, String face, Bool family_multiple, Bool face_multiple);
+static void SetFontFamilyFaceBlend(Widget w, String family, String face, String blend, Bool family_multiple, Bool face_multiple);
+static void SetFontName(Widget w, String name, Bool name_multiple);
+static void SetFontSize(Widget w, double size, Bool size_multiple);
+static void SetUpCurrentSelections(FontSelectionBoxWidget fsb);
+static void UndefUnusedFonts(Widget w);
+static void WriteBlends(FontSelectionBoxWidget fsb);
+
+FontSelectionBoxClassRec fontSelectionBoxClassRec = {
+ /* Core class part */
+ {
+ /* superclass */ (WidgetClass) &xmManagerClassRec,
+ /* class_name */ "FontSelectionBox",
+ /* widget_size */ sizeof(FontSelectionBoxRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_initialize */ ClassPartInitialize,
+ /* class_inited */ False,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ True,
+ /* compress_exposure */ XtExposeCompressMultiple,
+ /* compress_enterleave */ True,
+ /* visible_interest */ False,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ NULL,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL,
+ },
+ /* Composite class part */
+ {
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL,
+ },
+ /* Constraint class part */
+ {
+ /* resources */ NULL,
+ /* num_resources */ 0,
+ /* constraint_size */ 0,
+ /* initialize */ NULL,
+ /* destroy */ NULL,
+ /* set_values */ NULL,
+ /* extension */ NULL,
+ },
+ /* Manager class part */
+ {
+ /* translations */ XtInheritTranslations,
+ /* syn_resources */ NULL,
+ /* num_syn_resources */ 0,
+ /* syn_constraint_resources */ NULL,
+ /* num_syn_constraint_resources */ 0,
+ /* parent_process */ XmInheritParentProcess,
+ /* extension */ NULL,
+ },
+ /* FontSelectionBox class part */
+ {
+ /* set_font_name */ SetFontName,
+ /* set_font_family_face */ SetFontFamilyFace,
+ /* set_font_size */ SetFontSize,
+ /* refresh_font_list */ RefreshFontList,
+ /* get_family_list */ GetFamilyList,
+ /* get_face_list */ GetFaceList,
+ /* undef_unused_fonts */ UndefUnusedFonts,
+ /* download_font_name */ DownloadFontName,
+ /* match_font_face */ MatchFontFace,
+ /* font_name_to_family_face */ FontNameToFamilyFace,
+ /* font_family_face_to_name */ FontFamilyFaceToName,
+ /* find_afm */ FindAFM,
+ /* find_font_file */ FindFontFile,
+ /* get_text_dimensions */ GetTextDimensions,
+ /* set_font_family_face_blend */ SetFontFamilyFaceBlend,
+ /* font_name_to_family_face_blend */ FontNameToFamilyFaceBlend,
+ /* font_family_face_blend_to_name */ FontFamilyFaceBlendToName,
+ /* get_blend_list */ GetBlendList,
+ /* get_blend_info */ GetBlendInfo,
+ /* change_blends */ ChangeBlends,
+ /* extension */ NULL,
+ }
+};
+
+WidgetClass fontSelectionBoxWidgetClass =
+ (WidgetClass) &fontSelectionBoxClassRec;
+
+/* ARGSUSED */
+
+static Boolean CvtStringToFloatList(
+ Display *dpy,
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr from,
+ XrmValuePtr to,
+ XtPointer *data)
+{
+ register int i, count = 1;
+ register char *ch, *start = from->addr;
+ static float *list;
+ char save;
+
+ if (*num_args != 0) { /* Check for correct number */
+ XtAppErrorMsg(XtDisplayToApplicationContext(dpy),
+ "cvtStringToFloatList", "wrongParameters",
+ "XtToolkitError",
+ "String to integer list conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *) NULL);
+ }
+
+ if (to->addr != NULL && to->size < sizeof(int *)) {
+ to->size = sizeof(int *);
+ return False;
+ }
+ if (start == NULL || *start == '\0') list = NULL;
+ else {
+ for (ch = start; *ch != '\0'; ch++) { /* Count floats */
+ if (!isdigit(*ch) && *ch != '.' && *ch != ',') {
+ XtDisplayStringConversionWarning(dpy, from->addr, "FloatList");
+ return False;
+ }
+ if (*ch == ',') count++;
+ }
+ list = (float *) XtCalloc(count+1, sizeof(float));
+
+ for (i = 0; i < count; i++) {
+ for (ch = start; *ch != ',' && *ch != '\0'; ch++) {}
+ save = *ch;
+ *ch = '\0';
+ list[i] = atof(start);
+ *ch = save;
+ start = ch + 1;
+ }
+ }
+ if (to->addr == NULL) to->addr = (caddr_t) &list;
+ else *(float **) to->addr = list;
+ to->size = sizeof(int *);
+ return True;
+}
+
+/* ARGSUSED */
+
+static void FloatListDestructor(
+ XtAppContext app,
+ XrmValuePtr to,
+ XtPointer converter_data,
+ XrmValuePtr args,
+ Cardinal *num_args)
+{
+ float *list = (float *) to->addr;
+
+ if (list == NULL) return;
+ XtFree((XtPointer) list);
+}
+
+XmString _FSBCreateSharedCS(String str, Widget w)
+{
+ XrmValue src, dst;
+ XmString result;
+
+ src.addr = str;
+ src.size = strlen(str);
+
+ dst.addr = (caddr_t) &result;
+ dst.size = sizeof(result);
+
+ if (XtConvertAndStore(w, XtRString, &src, XmRXmString, &dst)) {
+ return result;
+ } else return NULL;
+}
+
+static Boolean ScanFloat(char *src, float *f, char **past)
+{
+ char buf[20], *ch;
+ int countDecimals;
+
+ ch = buf;
+ countDecimals = 0;
+ while (*src == '.' || isdigit(*src)) {
+ if (*src == '.') {
+ if (countDecimals) return False;
+ else countDecimals++;
+ }
+ *ch++ = *src++;
+ }
+ if (ch == buf) return False;
+ *ch++ = '\0';
+ *f = atof(buf);
+ *past = src;
+ return True;
+}
+
+static Boolean ScanInt(char *src, int *i, char **past)
+{
+ char buf[20], *ch;
+
+ ch = buf;
+ while (isdigit(*src)) *ch++ = *src++;
+ if (ch == buf) return False;
+ *ch++ = '\0';
+ *i = atoi(buf);
+ *past = src;
+ return True;
+}
+
+static void ClassInitialize(void)
+{
+ /* Register a converter for string to int list */
+
+ XtSetTypeConverter(XtRString, XtRFloatList,
+ CvtStringToFloatList, (XtConvertArgList) NULL, 0,
+ XtCacheAll | XtCacheRefCount, FloatListDestructor);
+
+ CSempty = UnsharedCS("");
+}
+
+static void ClassPartInitialize(WidgetClass widget_class)
+{
+ register FontSelectionBoxWidgetClass wc =
+ (FontSelectionBoxWidgetClass) widget_class;
+ FontSelectionBoxWidgetClass super =
+ (FontSelectionBoxWidgetClass) wc->core_class.superclass;
+
+ if (wc->fsb_class.set_font_name == InheritSetFontName) {
+ wc->fsb_class.set_font_name = super->fsb_class.set_font_name;
+ }
+ if (wc->fsb_class.set_font_family_face == InheritSetFontFamilyFace) {
+ wc->fsb_class.set_font_family_face =
+ super->fsb_class.set_font_family_face;
+ }
+ if (wc->fsb_class.set_font_size == InheritSetFontSize) {
+ wc->fsb_class.set_font_size = super->fsb_class.set_font_size;
+ }
+ if (wc->fsb_class.refresh_font_list == InheritRefreshFontList) {
+ wc->fsb_class.refresh_font_list = super->fsb_class.refresh_font_list;
+ }
+ if (wc->fsb_class.get_family_list == InheritGetFamilyList) {
+ wc->fsb_class.get_family_list = super->fsb_class.get_family_list;
+ }
+ if (wc->fsb_class.get_face_list == InheritGetFaceList) {
+ wc->fsb_class.get_face_list = super->fsb_class.get_face_list;
+ }
+ if (wc->fsb_class.undef_unused_fonts == InheritUndefUnusedFonts) {
+ wc->fsb_class.undef_unused_fonts = super->fsb_class.undef_unused_fonts;
+ }
+ if (wc->fsb_class.download_font_name == InheritDownloadFontName) {
+ wc->fsb_class.download_font_name = super->fsb_class.download_font_name;
+ }
+ if (wc->fsb_class.match_font_face == InheritMatchFontFace) {
+ wc->fsb_class.match_font_face = super->fsb_class.match_font_face;
+ }
+ if (wc->fsb_class.font_name_to_family_face ==
+ InheritFontNameToFamilyFace) {
+ wc->fsb_class.font_name_to_family_face =
+ super->fsb_class.font_name_to_family_face;
+ }
+ if (wc->fsb_class.font_family_face_to_name ==
+ InheritFontFamilyFaceToName) {
+ wc->fsb_class.font_family_face_to_name =
+ super->fsb_class.font_family_face_to_name;
+ }
+ if (wc->fsb_class.find_afm == InheritFindAFM) {
+ wc->fsb_class.find_afm = super->fsb_class.find_afm;
+ }
+ if (wc->fsb_class.find_font_file == InheritFindFontFile) {
+ wc->fsb_class.find_font_file = super->fsb_class.find_font_file;
+ }
+ if (wc->fsb_class.get_text_dimensions == InheritGetTextDimensions) {
+ wc->fsb_class.get_text_dimensions =
+ super->fsb_class.get_text_dimensions;
+ }
+ if (wc->fsb_class.set_font_family_face_blend ==
+ InheritSetFontFamilyFaceBlend) {
+ wc->fsb_class.set_font_family_face_blend =
+ super->fsb_class.set_font_family_face_blend;
+ }
+ if (wc->fsb_class.font_name_to_family_face_blend ==
+ InheritFontNameToFamilyFaceBlend) {
+ wc->fsb_class.font_name_to_family_face_blend =
+ super->fsb_class.font_name_to_family_face_blend;
+ }
+ if (wc->fsb_class.font_family_face_blend_to_name ==
+ InheritFontFamilyFaceBlendToName) {
+ wc->fsb_class.font_family_face_blend_to_name =
+ super->fsb_class.font_family_face_blend_to_name;
+ }
+ if (wc->fsb_class.get_blend_list == InheritGetBlendList) {
+ wc->fsb_class.get_blend_list =
+ super->fsb_class.get_blend_list;
+ }
+ if (wc->fsb_class.get_blend_info == InheritGetBlendInfo) {
+ wc->fsb_class.get_blend_info =
+ super->fsb_class.get_blend_info;
+ }
+ if (wc->fsb_class.change_blends == InheritChangeBlends) {
+ wc->fsb_class.change_blends =
+ super->fsb_class.change_blends;
+ }
+}
+
+static String bugFamilies[] = {
+ "Berkeley", "CaslonFiveForty", "CaslonThree", "GaramondThree",
+ "Music", "TimesTen", NULL
+};
+
+static String fixedFamilies[] = {
+ "ITC Berkeley Oldstyle", "Caslon 540", "Caslon 3", "Garamond 3",
+ "Sonata", "Times 10", NULL
+};
+
+static String missingFoundries[] = {
+ "Berthold ", "ITC ", "Linotype ", NULL
+};
+
+static int missingFoundryLen[] = {
+ 9, 4, 9, 0
+};
+
+/* I wish we didn't have to do this! */
+
+static void MungeFontNames(
+ String name, String family, String fullname, String weight,
+ String *familyReturn, String *fullnameReturn, String *faceReturn)
+{
+ register char *src, *dst, prev;
+ char buf[256];
+ int digits = 0;
+ int i, diff;
+ static Bool inited = False;
+ static String FetteFrakturDfr, LinotextDfr;
+
+ /* Don't make bugFamilies canonical; we'd have to make the initial
+ family canonical to do anything with it and there's no point in that */
+
+ if (!inited) {
+ for (i = 0; fixedFamilies[i] != NULL; i++) {
+ fixedFamilies[i] = Canonical(fixedFamilies[i]);
+ }
+ FetteFrakturDfr = Canonical("FetteFraktur-Dfr");
+ LinotextDfr = Canonical("Linotext-Dfr");
+ inited = True;
+ }
+
+ /* Copy the fullname into buf, enforcing one space between words.
+ Eliminate leading digits and spaces, ignore asterisks, if the
+ full name ends with 5 digits strip them, and replace periods that
+ aren't followed by a space with a space. If leading digits are
+ followed by " pt " skip that too. */
+
+ dst = buf;
+ prev = ' ';
+ src = fullname;
+ while (isdigit(*src)) src++;
+ while (*src == ' ' || *src == '\t') src++;
+ if (strncmp(src, "pt ", 3) == 0) src += 3;
+ else if (strncmp(src, "pt. ", 4) == 0) src += 4;
+
+ while (*src != '\0') {
+ if (*src == '*') {
+ src++;
+ continue;
+ }
+
+ if (*src == '.') {
+ if (*(src+1) != ' ') {
+ prev = *dst++ = ' ';
+ } else prev = *dst++ = '.';
+ src++;
+ continue;
+ }
+
+ if (isdigit(*src)) digits++;
+ else digits = 0;
+
+ if (isupper(*src)) {
+ if (prev != ' ' && (islower(*(src+1)) || islower(prev))) {
+ *dst++ = ' ';
+ prev = *dst++ = *src++;
+ } else prev = *dst++ = *src++;
+
+ } else if (*src == ' ' || *src == '\t') {
+ if (prev == ' ') {
+ src++;
+ continue;
+ }
+ prev = *dst++ = ' ';
+ src++;
+
+ } else prev = *dst++ = *src++;
+ }
+
+ if (digits == 5) {
+ dst -= 5;
+ }
+ if (dst > buf && *(dst-1) == ' ') dst--;
+
+ *dst = '\0';
+
+ /* Stupid Fette Fraktur */
+
+ if (name == FetteFrakturDfr) {
+ strcat(buf, " Black Dfr");
+ } else if (name == LinotextDfr) {
+ strcat(buf, " Dfr");
+ }
+
+ if (strncmp(fullname, "pt ", 3) == 0) {
+ src = buf + 2;
+ while (*++src != '\0') *(src-3) = *src;
+ *(src-3) = '\0';
+ }
+ *fullnameReturn = XtNewString(buf);
+
+ /* From here on fullname should not be used */
+
+ /* Done with the full name; now onto the family */
+
+ for (i = 0; bugFamilies[i] != NULL; i++) {
+ diff = strcmp(family, bugFamilies[i]);
+ if (diff < 0) break;
+ if (diff == 0) {
+ *familyReturn = fixedFamilies[i];
+ goto FAMILY_DONE;
+ }
+ }
+
+ /* Copy the family into buf, enforcing one space between words */
+
+ dst = buf;
+ prev = ' ';
+ src = family;
+
+ while (*src != '\0') {
+ if (isupper(*src)) {
+ if (prev != ' ' && (islower(*(src+1)) || islower(prev))) {
+ *dst++ = ' ';
+ prev = *dst++ = *src++;
+ } else prev = *dst++ = *src++;
+
+ } else if (*src == ' ' || *src == '\t') {
+ if (prev == ' ') {
+ src++;
+ continue;
+ }
+ prev = *dst++ = ' ';
+ src++;
+
+ } else prev = *dst++ = *src++;
+ }
+
+ if (dst > buf && *(dst-1) == ' ') dst--;
+ *dst = '\0';
+
+ /* Compensate for fonts with foundries in the full name but not the
+ family name by adding to the family name */
+
+ for (i = 0; missingFoundries[i] != NULL; i++) {
+ diff = strncmp(*fullnameReturn, missingFoundries[i],
+ missingFoundryLen[i]);
+ if (diff > 0) continue;
+ if (diff == 0 && strncmp(buf, missingFoundries[i],
+ missingFoundryLen[i] != 0)) {
+ while (dst >= buf) {
+ *(dst+missingFoundryLen[i]) = *dst;
+ dst--;
+ }
+ strncpy(buf, missingFoundries[i], missingFoundryLen[i]);
+ }
+ break;
+ }
+
+ /* From here on dst no longer points to the end of the buffer */
+
+ /* Stupid Helvetica Rounded! */
+
+ if (strncmp(*fullnameReturn, "Helvetica Rounded ", 18) == 0) {
+ strcat(buf, " Rounded");
+ }
+
+ *familyReturn = Canonical(buf);
+
+ /* From here on family should not be used */
+
+FAMILY_DONE:
+
+ /* Now to find the face in all this */
+
+ src = *fullnameReturn;
+ dst = *familyReturn;
+ while (*dst == *src && *dst != '\0') {
+ src++;
+ dst++;
+ }
+ if (*src == ' ') src++;
+
+ if (*src != '\0') *faceReturn = Canonical(src);
+ else if (*weight != '\0') {
+ /* Handle Multiple Master fonts */
+ if (strcmp(weight, "All") == 0) *faceReturn = Canonical("Roman");
+ else {
+ if (islower(weight[0])) weight[0] = toupper(weight[0]);
+ *faceReturn = Canonical(weight);
+ }
+ } else *faceReturn = Canonical("Medium");
+}
+
+static String strip[] = {
+ "Adobe ", "Bauer ", "Berthold ", "ITC ", "Linotype ",
+ "New ", "Simoncini ", "Stempel ", NULL};
+
+static int striplen[] = {6, 6, 9, 4, 9, 4, 10, 8, 0};
+
+#define STEMPELINDEX 7
+
+static Boolean CreateSortKey(String family, String key)
+{
+ char newkey[256];
+ int len = strlen(family);
+ register int i, diff;
+
+ if (family[len-2] == 'P' && family[len-1] == 'i') {
+ key[0] = 'P';
+ key[1] = 'i';
+ key[2] = ' ';
+ strcpy(key+3, family);
+ key[len] = '\0';
+ return True;
+ }
+
+ for (i = 0; strip[i] != NULL; i++) {
+ diff = strncmp(family, strip[i], striplen[i]);
+ if (diff < 0) break;
+ if (diff == 0) {
+ if (i == STEMPELINDEX) {
+ if (strcmp(family, "Stempel Schneidler") == 0) break;
+ }
+ strcpy(key, family + striplen[i]);
+ key[len - striplen[i]] = ' ';
+ strcpy(key + len - striplen[i] + 1, strip[i]);
+ key[len] = '\0';
+ if (CreateSortKey(key, newkey)) strcpy(key, newkey);
+ return True;
+ }
+ }
+ strcpy(key, family);
+ return False;
+}
+
+#define SKIP_SPACE(buf) while (*buf == ' ' || *buf == '\t') buf++;
+
+static int CountAxes(char *buf)
+{
+ int count = 0;
+
+ while (*buf != '\0') {
+ SKIP_SPACE(buf)
+ if (*buf != '/') return 0;
+ buf++;
+ count++;
+ if (*buf == ' ' || *buf == '\t' || *buf == '\0') return 0;
+ while (*buf != ' ' && *buf != '\t' && *buf != '\0') buf++;
+ }
+ return count;
+}
+
+static Boolean ParseBlendPositions(
+ char *buf,
+ float *blendPos,
+ int *axes, int *designs)
+{
+ int i, j = 0;
+ float f;
+
+ *designs = 0;
+
+ while (*buf != '\0') {
+ SKIP_SPACE(buf)
+ if (*buf++ != '[') return True;
+
+ /* Now there should be *axes positive floats, separated by space */
+ SKIP_SPACE(buf)
+ for (i = 0; i < *axes; i++) {
+ if (!ScanFloat(buf, &f, &buf)) return True;
+ blendPos[j++] = f;
+ SKIP_SPACE(buf)
+ }
+ if (*buf++ != ']') return True;
+ (*designs)++;
+ }
+ return False;
+}
+
+static Boolean ParseBlendMap(
+ char *buf,
+ int *breakCount,
+ int *blendBreak,
+ float *blendBreakValue,
+ int *axes)
+{
+ int i, j = 0;
+ int n;
+ float f;
+
+ /* OK. What we expect to see here is *axes arrays. Each one contains at
+ least 2 and no more than 12 subarrays, each of which contains 2 values,
+ an int and a float */
+
+ for (i = 0; i < *axes; i++) {
+
+ breakCount[i] = 0;
+
+ SKIP_SPACE(buf)
+ if (*buf++ != '[') return True;
+ SKIP_SPACE(buf)
+
+ while (*buf == '[') {
+ buf++;
+ SKIP_SPACE(buf)
+ /* Now there should be an integer */
+ if (!ScanInt(buf, &n, &buf)) return True;
+ blendBreak[j] = n;
+
+ SKIP_SPACE(buf)
+
+ /* Now there should be a float */
+ if (!ScanFloat(buf, &f, &buf)) return True;
+ blendBreakValue[j++] = f;
+ SKIP_SPACE(buf)
+
+ /* Nothing more in the array */
+ if (*buf++ != ']') return True;
+ SKIP_SPACE(buf)
+
+ breakCount[i]++;
+ if (breakCount[i] == 12 && *buf != ']') return True;
+ }
+ if (*buf++ != ']') return True;
+ }
+ SKIP_SPACE(buf)
+ if (*buf != '\0') return True;
+ return False;
+}
+
+static Boolean ParseAxisNames(
+ int axes,
+ char *buf,
+ char *names[])
+{
+ int i = 0;
+
+ /* We expect to see axes names, each optionally preceded with a / and
+ separated by space */
+
+ while (*buf != '\0') {
+ SKIP_SPACE(buf)
+ if (*buf == '/') buf++;
+ names[i] = buf;
+ while (*buf != ' ' && *buf != '\t' && *buf != '\0') buf++;
+ if (buf != names[i]) i++;
+ if (*buf != '\0') *buf++ = '\0';
+ if (i >= axes) return True;
+ }
+ return False;
+}
+#undef SKIP_SPACE
+
+static void GetPSFontInfo(
+ FontSelectionBoxWidget fsb,
+ char *name,
+ int *axes,
+ int *designs,
+ char *axisNames,
+ float *blendPos,
+ int *breakCount,
+ int *blendBreak,
+ float *blendBreakValue)
+{
+ int entries;
+ char **names, **data;
+
+ entries = ListPSResourceFiles(fsb->fsb.resource_path_override,
+ fsb->fsb.default_resource_path,
+ "FontAxes", name,
+ &names, &data);
+ if (entries < 1) {
+ *axes = 0;
+ return;
+ }
+ *axes = CountAxes(data[0]);
+ if (*axes == 0) return;
+ strcpy(axisNames, data[0]);
+
+ entries = ListPSResourceFiles(fsb->fsb.resource_path_override,
+ fsb->fsb.default_resource_path,
+ "FontBlendMap", name,
+ &names, &data);
+ if (entries < 1) {
+ *axes = 0;
+ return;
+ }
+ if (ParseBlendMap(data[0], breakCount,
+ blendBreak, blendBreakValue, axes)) {
+ *axes = 0;
+ return;
+ }
+
+ entries = ListPSResourceFiles(fsb->fsb.resource_path_override,
+ fsb->fsb.default_resource_path,
+ "FontBlendPositions", name,
+ &names, &data);
+ if (entries < 1) {
+ *axes = 0;
+ return;
+ }
+ if (ParseBlendPositions(data[0], blendPos, axes, designs)) {
+ *axes = 0;
+ return;
+ }
+}
+
+static void AddFontRecord(
+ FontSelectionBoxWidget fsb,
+ int serverNum,
+ String name, String family, String fullname, String weight,
+ Boolean resident)
+{
+ FontFamilyRec *ff;
+ FontRec *f;
+ String familyReturn, fullnameReturn, faceReturn;
+ char axisNameBuf[256];
+ char *axisName[MAX_AXES];
+ int blendedFont, undefineIt, brokenFont;
+ int axes, designs, breakCount[MAX_AXES],
+ blendBreak[12 * MAX_AXES];
+ float blendBreakValue[12 * MAX_AXES], blendPos[MAX_AXES * MAX_BLENDS];
+ char key[256];
+ int i, j, k, n;
+
+ name = Canonical(name);
+
+ /* First see if it's there already */
+
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ if (f->font_name == name) {
+ if (!f->resident && resident) f->resident = True;
+ return;
+ }
+ }
+ }
+
+ /* We believe that names gotten from PS resource files have been
+ pre-munged, so no need to do it again */
+
+ if (resident) {
+ /* Have to get the info from the server */
+ _DPSFGetFontInfo(fsb->fsb.context, serverNum, fsb->fsb.old_server,
+ family, fullname,
+ weight, &blendedFont, &undefineIt, &brokenFont);
+
+ if (brokenFont) return;
+
+ /* Deal with fonts that don't have useful information */
+
+ if (family[0] == '\0') {
+ if (fullname[0] == '\0') {
+ strcpy(family, name);
+ strcpy(fullname, name);
+ } else strcpy(family, fullname);
+ } else if (fullname[0] == '\0') strcpy(fullname, family);
+
+ MungeFontNames(name, family, fullname, weight,
+ &familyReturn, &fullnameReturn, &faceReturn);
+ if (blendedFont) {
+ _DPSFGetBlendedFontInfo(fsb->fsb.context, serverNum,
+ undefineIt, fsb->fsb.old_server,
+ &axes, &designs, axisNameBuf,
+ blendPos, breakCount, blendBreak,
+ blendBreakValue, &brokenFont);
+ if (brokenFont) axes = 0;
+ } else axes = 0;
+
+ } else {
+ familyReturn = Canonical(family);
+ fullnameReturn = XtNewString(fullname);
+ faceReturn = Canonical(weight);
+ GetPSFontInfo(fsb, name, &axes, &designs, axisNameBuf, blendPos,
+ breakCount, blendBreak, blendBreakValue);
+ }
+
+ /* We didn't get an exact match, go for family match */
+
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ if (ff->family_name == familyReturn) break;
+ }
+
+ if (ff == NULL) {
+ ff = (FontFamilyRec *) XtMalloc(sizeof(FontFamilyRec));
+ ff->next = fsb->fsb.known_families;
+ ff->family_name = familyReturn;
+ ff->fonts = NULL;
+ ff->font_count = 0;
+ ff->blend_count = 0;
+ if (fsb->fsb.typographic_sort) {
+ (void) CreateSortKey(familyReturn, key);
+ ff->sort_key = XtNewString(key);
+ } else ff->sort_key = ff->family_name;
+ fsb->fsb.known_families = ff;
+ fsb->fsb.family_count++;
+ }
+
+ f = (FontRec *) XtMalloc(sizeof(FontRec));
+ f->next = ff->fonts;
+ f->font_name = name;
+ f->full_name = fullnameReturn;
+ f->resident = resident;
+ f->temp_resident = False;
+ f->in_font_creator = False;
+ f->pending_delete_next = NULL;
+ f->face_name = faceReturn;
+ f->CS_face_name = CS(f->face_name, (Widget) fsb);
+ f->blend_count = 0;
+
+ if (axes != 0 && ParseAxisNames(axes, axisNameBuf, axisName)) {
+ BlendDataRec *b;
+
+ f->blend_data = b = XtNew(BlendDataRec);
+ b->num_axes = axes;
+ b->num_designs = designs;
+ k = 0;
+
+ for (i = 0; i < axes; i++) {
+ b->internal_points[i] = breakCount[i] - 2;
+ if (b->internal_points[i] <= 0) {
+ b->internal_break[i] = NULL;
+ b->internal_value[i] = NULL;
+ b->internal_points[i] = 0;
+ } else {
+ b->internal_break[i] = (int *)
+ XtMalloc(b->internal_points[i] * sizeof(int));
+ b->internal_value[i] = (float *)
+ XtMalloc(b->internal_points[i] * sizeof(float));
+ }
+
+ n = 0;
+ for (j = 0; j < breakCount[i]; j++) {
+ if (blendBreakValue[k] == 0.0) b->min[i] = blendBreak[k];
+ else if (blendBreakValue[k] == 1.0) b->max[i] = blendBreak[k];
+ else {
+ b->internal_break[i][n] = blendBreak[k];
+ b->internal_value[i][n++] = blendBreakValue[k];
+ }
+ k++;
+ }
+ b->name[i] = Canonical(axisName[i]);
+ }
+
+ b->design_positions =
+ (float *) XtMalloc(axes * designs * sizeof(float));
+ for (i = 0; i < axes * designs; i++) {
+ b->design_positions[i] = blendPos[i];
+ }
+ b->blends = NULL;
+ } else f->blend_data = NULL;
+
+ ff->fonts = f;
+ ff->font_count++;
+}
+
+static void SortFontNames(FontFamilyRec *ff)
+{
+ FontRec *f, *highest, **prev, **highestPrev;
+ FontRec *newFontList = NULL;
+
+ while (ff->fonts != NULL) {
+ prev = highestPrev = &ff->fonts;
+ highest = ff->fonts;
+
+ for (f = ff->fonts->next; f != NULL; f = f->next) {
+ prev = &(*prev)->next;
+ if (strcmp(f->face_name, highest->face_name) > 0) {
+ highest = f;
+ highestPrev = prev;
+ }
+ }
+
+ *highestPrev = highest->next;
+ highest->next = newFontList;
+ newFontList = highest;
+ }
+ ff->fonts = newFontList;
+}
+
+static void SortFontFamilies(FontSelectionBoxWidget fsb)
+{
+ FontFamilyRec *ff, *highest, **prev, **highestPrev;
+ FontFamilyRec *newFamilyList = NULL;
+
+ while (fsb->fsb.known_families != NULL) {
+ prev = highestPrev = &fsb->fsb.known_families;
+ highest = fsb->fsb.known_families;
+
+ for (ff = fsb->fsb.known_families->next; ff != NULL; ff = ff->next) {
+ prev = &(*prev)->next;
+ if (strcmp(ff->sort_key, highest->sort_key) > 0) {
+ highest = ff;
+ highestPrev = prev;
+ }
+ }
+
+ *highestPrev = highest->next;
+ highest->next = newFamilyList;
+ newFamilyList = highest;
+ SortFontNames(highest);
+ if (fsb->fsb.typographic_sort) XtFree(highest->sort_key);
+ highest->sort_key = NULL;
+ }
+ fsb->fsb.known_families = newFamilyList;
+}
+
+static void AddFamily(
+ FontSelectionBoxWidget fsb,
+ char *family, char *fonts, char *weight, char *fullname, char *name)
+{
+ int j;
+ char *ch;
+
+ ch = fonts;
+ while (*ch != '\0') {
+ j = 0;
+ while (1) {
+ if (*ch == '\\' && (*(ch+1) == '\\' || *(ch+1) == ',')) {
+ ch++;
+ weight[j++] = *ch++;
+ } else if (*ch == '\0' || *ch == ',') {
+ weight[j] = '\0';
+ break;
+ } else weight[j++] = *ch++;
+ }
+ if (*ch == ',') {
+ j = 0;
+ ch++;
+ while (1) {
+ if (*ch == '\\' && (*(ch+1) == '\\' || *(ch+1) == ',')) {
+ ch++;
+ name[j++] = *ch++;
+ } else if (*ch == '\0' || *ch == ',') {
+ name[j] = '\0';
+ break;
+ } else name[j++] = *ch++;
+ }
+ strcpy(fullname, family);
+ strcat(fullname, " ");
+ strcat(fullname, weight);
+ AddFontRecord(fsb, 0, name, family, fullname, weight, False);
+ if (*ch == ',') ch++;
+ }
+ }
+}
+
+static void GetFontNames(FontSelectionBoxWidget fsb)
+{
+ int i;
+ char name[256], family[256], fullname[256], weight[256];
+ char *buffer, *ch, *start;
+ int fontCount, totalLength;
+ char **loadableFamilies = NULL, **loadableFamilyFonts = NULL;
+
+ fsb->fsb.family_count = 0;
+
+ fontCount = ListPSResourceFiles(fsb->fsb.resource_path_override,
+ fsb->fsb.default_resource_path,
+ PSResFontFamily, NULL,
+ &loadableFamilies, &loadableFamilyFonts);
+ for (i = 0; i < fontCount; i++) {
+ AddFamily(fsb, loadableFamilies[i], loadableFamilyFonts[i],
+ weight, fullname, name);
+ }
+
+ XtFree((XtPointer) loadableFamilies);
+ XtFree((XtPointer) loadableFamilyFonts);
+ FreePSResourceStorage(False);
+
+ if (fsb->fsb.get_server_fonts) {
+ _DPSFEnumFonts(fsb->fsb.context, &fontCount, &totalLength);
+
+ buffer = XtMalloc(totalLength);
+ _DPSFGetAllFontNames(fsb->fsb.context, fontCount, totalLength, buffer);
+ ch = start = buffer;
+ for (i = 0; i < fontCount; i++) {
+ while (*ch != ' ') ch++;
+ *ch = '\0';
+ AddFontRecord(fsb, i, start, family, fullname, weight, True);
+ start = ch+1;
+ }
+ XtFree(buffer);
+ }
+
+ _DPSFFreeFontInfo(fsb->fsb.context);
+ SortFontFamilies(fsb);
+ ReadBlends(fsb);
+}
+
+static void SensitizeReset(FontSelectionBoxWidget fsb)
+{
+ XtSetSensitive(fsb->fsb.reset_button_child, True);
+}
+
+static void DesensitizeReset(FontSelectionBoxWidget fsb)
+{
+ XtSetSensitive(fsb->fsb.reset_button_child, False);
+}
+
+static void ManageFamilyMultiple(FontSelectionBoxWidget fsb)
+{
+ XtManageChild(fsb->fsb.family_multiple_label_child);
+
+ XtVaSetValues(XtParent(fsb->fsb.family_scrolled_list_child),
+ XmNtopWidget, fsb->fsb.family_multiple_label_child, NULL);
+}
+
+static void ManageFaceMultiple(FontSelectionBoxWidget fsb)
+{
+ XtManageChild(fsb->fsb.face_multiple_label_child);
+
+ XtVaSetValues(XtParent(fsb->fsb.face_scrolled_list_child),
+ XmNtopWidget, fsb->fsb.face_multiple_label_child, NULL);
+}
+
+static void ManageMultipleMaster(FontSelectionBoxWidget fsb)
+{
+ XtManageChild(fsb->fsb.multiple_master_button_child);
+
+ XtVaSetValues(XtParent(fsb->fsb.face_scrolled_list_child),
+ XmNbottomWidget, fsb->fsb.multiple_master_button_child,
+ NULL);
+}
+
+static void ManageSizeMultiple(FontSelectionBoxWidget fsb)
+{
+ XtManageChild(fsb->fsb.size_multiple_label_child);
+}
+
+static void UnmanageFamilyMultiple(FontSelectionBoxWidget fsb)
+{
+ XtVaSetValues(XtParent(fsb->fsb.family_scrolled_list_child),
+ XmNtopWidget, fsb->fsb.family_label_child, NULL);
+
+ XtUnmanageChild(fsb->fsb.family_multiple_label_child);
+}
+
+static void UnmanageFaceMultiple(FontSelectionBoxWidget fsb)
+{
+ XtVaSetValues(XtParent(fsb->fsb.face_scrolled_list_child),
+ XmNtopWidget, fsb->fsb.face_label_child, NULL);
+
+ XtUnmanageChild(fsb->fsb.face_multiple_label_child);
+}
+
+static void UnmanageMultipleMaster(FontSelectionBoxWidget fsb)
+{
+ XtUnmanageChild(fsb->fsb.multiple_master_button_child);
+
+ XtVaSetValues(XtParent(fsb->fsb.face_scrolled_list_child),
+ XmNbottomWidget, fsb->fsb.size_text_field_child, NULL);
+}
+
+static void UnmanageSizeMultiple(FontSelectionBoxWidget fsb)
+{
+ XtUnmanageChild(fsb->fsb.size_multiple_label_child);
+}
+
+/* Callbacks for subwidgets */
+
+static Boolean DownloadFont(
+ FontSelectionBoxWidget fsb,
+ String name,
+ DPSContext ctxt,
+ Boolean make_shared)
+{
+ int count;
+ char **names, **files;
+ FILE *f;
+#define BUFLEN 256
+ char buf[BUFLEN];
+ static char eobuf[] = "\n$Adobe$DPS$Lib$Dict /downloadSuccess true put\n\
+stop\n\
+Magic end of data line )))))))))) 99#2 2#99 <xyz> // 7gsad,32h4ghNmndFgj2\n";
+ int currentShared, ok;
+
+ /* Assume context is correct */
+
+ count = ListPSResourceFiles(fsb->fsb.resource_path_override,
+ fsb->fsb.default_resource_path,
+ PSResFontOutline, name,
+ &names, &files);
+ if (count == 0) return False;
+
+ f = fopen(files[0], "r");
+ if (f == NULL) return False;
+
+ /* A bug in 1006.9 and earlier servers prevents the more robust
+ downloading method from working reliably. */
+
+ if (fsb->fsb.old_server) {
+ DPSPrintf(ctxt, "\ncurrentshared %s setshared\n",
+ (make_shared ? "true" : "false"));
+ while (fgets(buf, BUFLEN, f) != NULL) {
+ DPSWritePostScript(ctxt, buf, strlen(buf));
+ }
+ DPSWritePostScript(ctxt, "\nsetshared\n", 11);
+ ok = True;
+
+ } else {
+ _DPSFPrepareToDownload(ctxt, make_shared, &currentShared);
+ DPSWriteData(ctxt, "\nexec\n", 6);
+
+ while (fgets(buf, BUFLEN, f) != NULL) {
+ DPSWriteData(ctxt, buf, strlen(buf));
+ }
+
+ /* This marks the end of the data stream */
+ DPSWriteData(ctxt, eobuf, strlen(eobuf));
+
+ /* Check the results of the download by getting the error status */
+ _DPSFFinishDownload(ctxt, currentShared, &ok);
+ }
+
+ fclose (f);
+ free(names);
+ free(files);
+ return ok;
+
+#undef BUFLEN
+}
+
+static void UndefSomeUnusedFonts(
+ FontSelectionBoxWidget fsb,
+ Boolean all)
+{
+ FontRec *f, *nextf, **start;
+ int i;
+
+ if (!all
+ && (Cardinal)fsb->fsb.pending_delete_count < fsb->fsb.max_pending_deletes) {
+ return;
+ }
+
+ if (all) start = &fsb->fsb.pending_delete_font;
+ else {
+ /* Skip to the end of the ones we're keeping */
+ f = fsb->fsb.pending_delete_font;
+ for (i = 1; f != NULL && (Cardinal)i < fsb->fsb.max_pending_deletes; i++) {
+ f = f->pending_delete_next;
+ }
+ if (f == NULL) return;
+ start = &f->pending_delete_next;
+ }
+
+ for (f = *start; f != NULL; f = nextf) {
+ nextf = f->pending_delete_next;
+ if (f == fsb->fsb.currently_previewed) {
+ start = &f->pending_delete_next;
+ continue;
+ }
+ *start = nextf;
+ if (!f->resident && !f->in_font_creator) {
+ _DPSFUndefineFont(fsb->fsb.context, f->font_name,
+ fsb->fsb.old_server);
+ }
+ f->temp_resident = False;
+ fsb->fsb.pending_delete_count--;
+ f->pending_delete_next = NULL;
+ }
+}
+
+static void UndefUnusedFonts(Widget w)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+
+ UndefSomeUnusedFonts(fsb, True);
+}
+
+Boolean _FSBDownloadFontIfNecessary(
+ FontRec *f,
+ FontSelectionBoxWidget fsb)
+{
+ Boolean shared;
+
+ if (!f->resident && !f->temp_resident) {
+
+ shared = fsb->fsb.make_fonts_shared && !fsb->fsb.undef_unused_fonts;
+ if (!fsb->fsb.get_server_fonts) {
+ int resident;
+ /* This font might already be there, so check before downloading */
+ _DPSFIsFontResident(fsb->fsb.context, f->font_name, &resident);
+ if (resident) {
+ f->resident = True;
+ return True;
+ }
+ }
+ if (!DownloadFont(fsb, f->font_name, fsb->fsb.context, shared)) {
+ _FSBFlushFont(fsb, f);
+ return False;
+ }
+ if (shared) f->resident = True;
+ else f->temp_resident = True;
+
+ if (f->pending_delete_next == NULL && fsb->fsb.undef_unused_fonts) {
+ f->pending_delete_next = fsb->fsb.pending_delete_font;
+ fsb->fsb.pending_delete_font = f;
+ fsb->fsb.pending_delete_count++;
+ UndefSomeUnusedFonts(fsb, False);
+ }
+ }
+ return True;
+}
+
+static void DoPreview(
+ FontSelectionBoxWidget fsb,
+ Boolean override)
+{
+ int i, n;
+ int *selectList, selectCount;
+ float size;
+ FontFamilyRec *ff = fsb->fsb.known_families;
+ FontRec *f;
+ BlendRec *b;
+ char *chSize, *fontName;
+ Dimension height;
+ Cardinal depth;
+ int bogusFont;
+
+ if (!XtIsRealized(fsb)) return;
+
+ XtVaGetValues(fsb->fsb.preview_child, XmNheight, &height,
+ XmNdepth, &depth, NULL);
+
+ if (fsb->fsb.gstate == 0) {
+ XDPSSetContextParameters(fsb->fsb.context, XtScreen(fsb), depth,
+ XtWindow(fsb->fsb.preview_child), height,
+ (XDPSStandardColormap *) NULL,
+ (XDPSStandardColormap *) NULL,
+ XDPSContextScreenDepth | XDPSContextDrawable |
+ XDPSContextRGBMap | XDPSContextGrayMap);
+ XDPSCaptureContextGState(fsb->fsb.context, &fsb->fsb.gstate);
+ } else XDPSSetContextGState(fsb->fsb.context, fsb->fsb.gstate);
+
+ _DPSFClearWindow(fsb->fsb.context);
+
+ if (override) {
+ if (fsb->fsb.current_family_multiple ||
+ fsb->fsb.current_face_multiple ||
+ fsb->fsb.current_size_multiple) return;
+ f = fsb->fsb.currently_previewed;
+ size = fsb->fsb.currently_previewed_size;
+ b = fsb->fsb.currently_previewed_blend;
+ }
+
+ if (!override || f == NULL || size == 0.0) {
+ if (!XmListGetSelectedPos(fsb->fsb.family_scrolled_list_child,
+ &selectList, &selectCount)) return;
+ if (selectCount == 0 ||
+ *selectList < 1 || *selectList > fsb->fsb.family_count) return;
+
+ for (i = 1; i < *selectList; i++) ff = ff->next;
+
+ XtFree((XtPointer) selectList);
+
+ if (!XmListGetSelectedPos(fsb->fsb.face_scrolled_list_child,
+ &selectList, &selectCount)) return;
+ if (selectCount == 0 ||
+ *selectList < 1 ||
+ *selectList > ff->font_count + ff->blend_count) return;
+
+ f = ff->fonts;
+ n = 0;
+ while (1) {
+ n += f->blend_count + 1;
+ if (n >= *selectList) {
+ n -= f->blend_count;
+ if (n == *selectList) b = NULL;
+ else for (b = f->blend_data->blends;
+ n < *selectList - 1; b = b->next) n++;
+ break;
+ }
+ f = f->next;
+ }
+
+ XtFree((XtPointer) selectList);
+
+ XtVaGetValues(fsb->fsb.size_text_field_child,
+ XmNvalue, &chSize, NULL);
+
+ if (chSize == NULL || *chSize == '\0') return;
+ size = atof(chSize);
+ }
+
+ if (size <= 0.0) return;
+
+ fsb->fsb.currently_previewed = f;
+ fsb->fsb.currently_previewed_blend = b;
+ fsb->fsb.currently_previewed_size = size;
+
+ if (!_FSBDownloadFontIfNecessary(f, fsb)) return;
+
+ if (b == NULL) fontName = f->font_name;
+ else fontName = b->font_name;
+
+ if (fsb->fsb.preview_string == NULL) {
+ _DPSFPreviewString(fsb->fsb.context, fontName, size,
+ f->full_name, height, &bogusFont);
+ } else _DPSFPreviewString(fsb->fsb.context, fontName, size,
+ fsb->fsb.preview_string, height, &bogusFont);
+ if (bogusFont) {
+ _FSBBogusFont(fsb, f);
+ }
+}
+
+static void DoValueChangedCallback(FontSelectionBoxWidget fsb)
+{
+ String afm = NULL;
+ FSBValidateCallbackRec cb;
+
+ if (fsb->fsb.get_afm) {
+ if (fsb->fsb.currently_selected_face == NULL) afm = NULL;
+ else afm = FindAFM((Widget) fsb,
+ fsb->fsb.currently_selected_face->font_name);
+ }
+
+ (void) Verify(fsb, &cb, afm, False);
+ cb.reason = FSBValueChanged;
+
+ XtCallCallbackList((Widget) fsb, fsb->fsb.value_changed_callback, &cb);
+}
+
+static void ValueChanged(FontSelectionBoxWidget fsb)
+{
+ if (fsb->fsb.auto_preview) DoPreview(fsb, False);
+ DoValueChangedCallback(fsb);
+}
+
+/* ARGSUSED */
+
+static void PreviewText(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+ XmAnyCallbackStruct *cb = (XmAnyCallbackStruct *) callData;
+
+ if (!fsb->fsb.preview_fixed) {
+ XSetWindowAttributes att;
+ att.bit_gravity = ForgetGravity;
+ XChangeWindowAttributes(XtDisplay(fsb),
+ XtWindow(fsb->fsb.preview_child),
+ CWBitGravity, &att);
+ fsb->fsb.preview_fixed = True;
+ }
+
+ if (cb != NULL && cb->event->type == Expose &&
+ cb->event->xexpose.count != 0) return;
+
+ DoPreview(fsb, True);
+}
+
+/* ARGSUSED */
+
+static void PreviewCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+
+ DoPreview(fsb, False);
+}
+
+/* ARGSUSED */
+
+static void DismissSamplerCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+
+ fsb->fsb.show_sampler = False;
+}
+
+static void ShowSampler(FontSelectionBoxWidget fsb)
+{
+ int i;
+ Arg args[2];
+ Widget s;
+
+ if (fsb->fsb.sampler == NULL) {
+ FSBCreateSamplerCallbackRec cs;
+
+ cs.sampler_shell = NULL;
+
+ XtCallCallbackList((Widget) fsb, fsb->fsb.create_sampler_callback,
+ (XtPointer) &cs);
+
+ if (cs.sampler_shell == NULL || cs.sampler == NULL) {
+ fsb->fsb.sampler =
+ XtCreatePopupShell("samplerShell",
+ transientShellWidgetClass,
+ (Widget) fsb, (ArgList) NULL, 0);
+ i = 0;
+ XtSetArg(args[i], XtNfontSelectionBox, fsb); i++;
+ s = XtCreateManagedWidget("sampler", fontSamplerWidgetClass,
+ fsb->fsb.sampler, args, i);
+ XtAddCallback(s, XtNdismissCallback,
+ DismissSamplerCallback, (XtPointer) fsb);
+ } else {
+ fsb->fsb.sampler = cs.sampler_shell;
+ XtAddCallback(cs.sampler, XtNdismissCallback,
+ DismissSamplerCallback, (XtPointer) fsb);
+ }
+ }
+ XtPopup(fsb->fsb.sampler, XtGrabNone);
+ XRaiseWindow(XtDisplay(fsb->fsb.sampler), XtWindow(fsb->fsb.sampler));
+ fsb->fsb.show_sampler = True;
+}
+
+static void ShowCreator(FontSelectionBoxWidget fsb)
+{
+ int i;
+ Arg args[2];
+ FSBCreateCreatorCallbackRec cc;
+
+ if (fsb->fsb.creator == NULL) {
+
+ cc.creator_shell = NULL;
+
+ XtCallCallbackList((Widget) fsb, fsb->fsb.create_creator_callback,
+ (XtPointer) &cc);
+
+ if (cc.creator_shell == NULL || cc.creator == NULL) {
+ cc.creator_shell =
+ XtCreatePopupShell("creatorShell",
+ transientShellWidgetClass,
+ (Widget) fsb, (ArgList) NULL, 0);
+ i = 0;
+ XtSetArg(args[i], XtNfontSelectionBox, fsb); i++;
+ cc.creator =
+ XtCreateManagedWidget("creator", fontCreatorWidgetClass,
+ cc.creator_shell, args, i);
+ }
+ fsb->fsb.creator_shell = cc.creator_shell;
+ fsb->fsb.creator = cc.creator;
+ }
+
+ XtPopup(fsb->fsb.creator_shell, XtGrabNone);
+ XRaiseWindow(XtDisplay(fsb->fsb.creator_shell),
+ XtWindow(fsb->fsb.creator_shell));
+
+ _FSBSetCreatorFamily(fsb->fsb.creator, fsb->fsb.currently_selected_family);
+}
+
+/* ARGSUSED */
+
+static void ShowCreatorCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+
+ ShowCreator(fsb);
+}
+
+/* ARGSUSED */
+
+static void ShowSamplerCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+
+ ShowSampler(fsb);
+}
+
+/* ARGSUSED */
+
+static void PreviewDoubleClick(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+
+ DoPreview(fsb, False);
+}
+
+/* ARGSUSED */
+
+static void ResizePreview(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ Dimension height;
+ Cardinal depth;
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+
+ if (!XtIsRealized(widget) || fsb->fsb.gstate == 0) return;
+
+ XtVaGetValues(widget, XmNheight, &height, XmNdepth, &depth, NULL);
+
+ XDPSSetContextGState(fsb->fsb.context, fsb->fsb.gstate);
+
+ XDPSSetContextParameters(fsb->fsb.context, XtScreen(widget), depth,
+ XtWindow(widget), height,
+ (XDPSStandardColormap *) NULL,
+ (XDPSStandardColormap *) NULL,
+ XDPSContextScreenDepth | XDPSContextDrawable);
+
+ _DPSFReclip(fsb->fsb.context);
+
+ XDPSUpdateContextGState(fsb->fsb.context, fsb->fsb.gstate);
+}
+
+static String FindAFMRecursive(
+ Widget w,
+ String name,
+ Boolean recur)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+ int count;
+ char **names, **files;
+ String ret, ch;
+
+ if (name == NULL) return NULL;
+
+ count = ListPSResourceFiles(fsb->fsb.resource_path_override,
+ fsb->fsb.default_resource_path,
+ PSResFontAFM,
+ name,
+ &names, &files);
+
+ if (count == 0 && recur) {
+ for (ch = name; *ch != '_' && *ch != '\0'; ch++) {}
+ if (*ch == '\0') return NULL;
+ *ch = '\0';
+ ret = FindAFMRecursive(w, name, False);
+ *ch = '_';
+ return ret;
+ }
+
+ if (count == 0) return NULL;
+ ret = files[0];
+ free(names);
+ free(files);
+ return ret;
+}
+
+static String FindAFM(Widget w, String name)
+{
+ return FindAFMRecursive(w, name, True);
+}
+
+static String FindFontFileRecursive(
+ Widget w,
+ String name,
+ Boolean recur)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+ int count;
+ char **names, **files;
+ String ret, ch;
+
+ if (name == NULL) return NULL;
+
+ count = ListPSResourceFiles(fsb->fsb.resource_path_override,
+ fsb->fsb.default_resource_path,
+ PSResFontOutline,
+ name,
+ &names, &files);
+
+ if (count == 0 && recur) {
+ for (ch = name; *ch != '_' && *ch != '\0'; ch++) {}
+ if (*ch == '\0') return NULL;
+ *ch = '\0';
+ ret = FindFontFileRecursive(w, name, False);
+ *ch = '_';
+ return ret;
+ }
+
+ if (count == 0) return NULL;
+ ret = files[0];
+ free(names);
+ free(files);
+ return ret;
+}
+
+static String FindFontFile(Widget w, String name)
+{
+ return FindFontFileRecursive(w, name, True);
+}
+
+static Boolean Verify(
+ FontSelectionBoxWidget fsb,
+ FSBValidateCallbackRec *cb,
+ String afm,
+ Boolean doIt)
+{
+ char *chSize;
+ int i;
+
+ if (fsb->fsb.current_family_multiple) {
+ cb->family = NULL;
+ cb->family_selection = FSBMultiple;
+ } else if (fsb->fsb.currently_selected_family == NULL) {
+ cb->family = NULL;
+ cb->family_selection = FSBNone;
+ } else {
+ cb->family = fsb->fsb.currently_selected_family->family_name;
+ cb->family_selection = FSBOne;
+ }
+
+ if (fsb->fsb.current_face_multiple) {
+ cb->face = NULL;
+ cb->face_selection = FSBMultiple;
+ } else if (fsb->fsb.currently_selected_face == NULL) {
+ cb->face = NULL;
+ cb->face_selection = FSBNone;
+ } else {
+ cb->face = fsb->fsb.currently_selected_face->face_name;
+ cb->face_selection = FSBOne;
+ }
+
+ if (cb->family_selection == FSBMultiple ||
+ cb->face_selection == FSBMultiple) {
+ cb->name = NULL;
+ cb->name_selection = FSBMultiple;
+ } else if (fsb->fsb.currently_selected_face == NULL) {
+ cb->name = NULL;
+ cb->name_selection = FSBNone;
+ } else {
+ if (fsb->fsb.currently_selected_blend != NULL) {
+ cb->name = fsb->fsb.currently_selected_blend->font_name;
+ } else cb->name = fsb->fsb.currently_selected_face->font_name;
+ cb->name_selection = FSBOne;
+ }
+
+ if (fsb->fsb.current_size_multiple) {
+ cb->size = 0.0;
+ cb->size_selection = FSBMultiple;
+ } else {
+ XtVaGetValues(fsb->fsb.size_text_field_child, XmNvalue, &chSize, NULL);
+
+ if (chSize == NULL || *chSize == '\0') {
+ cb->size = 0.0;
+ cb->size_selection = FSBNone;
+ } else {
+ cb->size = atof(chSize);
+ cb->size_selection = FSBOne;
+ }
+ }
+
+ cb->afm_filename = afm;
+ cb->afm_present = (afm != NULL);
+ cb->doit = True;
+
+ if (fsb->fsb.currently_selected_blend == NULL) {
+ cb->blend = cb->base_name = NULL;
+ for (i = 0; i < MAX_AXES; i++) cb->axis_percent[i] = 0.0;
+ } else {
+ cb->blend = fsb->fsb.currently_selected_blend->blend_name;
+ cb->base_name = fsb->fsb.currently_selected_face->font_name;
+ for (i = 0; i < MAX_AXES; i++) {
+ cb->axis_percent[i] = fsb->fsb.currently_selected_blend->data[i];
+ }
+ }
+
+ if (doIt) XtCallCallbackList((Widget) fsb, fsb->fsb.validate_callback, cb);
+ return cb->doit;
+}
+
+static Boolean VerifyAndCallback(
+ FontSelectionBoxWidget fsb,
+ FSBCallbackReason reason,
+ XtCallbackList callback)
+{
+ String afm = NULL;
+ FSBValidateCallbackRec cb;
+ FontRec *fsave, *face;
+
+ if (fsb->fsb.get_afm) {
+ if (fsb->fsb.currently_selected_face == NULL) afm = NULL;
+ else afm = FindAFM((Widget) fsb,
+ fsb->fsb.currently_selected_face->font_name);
+ }
+
+ DoPreview(fsb, False);
+
+ cb.reason = reason;
+ if (!Verify(fsb, &cb, afm, True)) return False;
+
+ fsb->fsb.font_family_multiple = fsb->fsb.current_family_multiple;
+ if (!fsb->fsb.font_family_multiple &&
+ fsb->fsb.currently_selected_family != NULL) {
+ fsb->fsb.font_family =
+ fsb->fsb.currently_selected_family->family_name;
+ } else fsb->fsb.font_family = NULL;
+
+ fsb->fsb.font_face_multiple = fsb->fsb.current_face_multiple;
+ if (!fsb->fsb.font_face_multiple &&
+ fsb->fsb.currently_selected_face != NULL) {
+ fsb->fsb.font_face = fsb->fsb.currently_selected_face->face_name;
+ } else fsb->fsb.font_face = NULL;
+
+ fsb->fsb.font_name_multiple =
+ fsb->fsb.font_family_multiple || fsb->fsb.font_face_multiple;
+ if (!fsb->fsb.font_name_multiple &&
+ fsb->fsb.currently_selected_face != NULL) {
+ fsb->fsb.font_name = fsb->fsb.currently_selected_face->font_name;
+ } else fsb->fsb.font_name = NULL;
+
+ fsb->fsb.font_size_multiple = fsb->fsb.current_size_multiple;
+ if (!fsb->fsb.font_size_multiple) {
+ fsb->fsb.font_size = cb.size;
+ }
+
+ if (fsb->fsb.currently_selected_blend != NULL) {
+ fsb->fsb.font_blend = fsb->fsb.currently_selected_blend->blend_name;
+ } else fsb->fsb.font_blend = NULL;
+
+ if (fsb->fsb.undef_unused_fonts) {
+ fsave = fsb->fsb.currently_previewed;
+ if (fsb->fsb.make_fonts_shared) {
+ fsb->fsb.currently_previewed = NULL;
+ }
+ UndefUnusedFonts((Widget)fsb);
+ fsb->fsb.currently_previewed = fsave;
+ face = fsb->fsb.currently_selected_face;
+ if (face != NULL && !face->resident) {
+ face->resident = True;
+ if (fsb->fsb.make_fonts_shared) {
+ (void) DownloadFont(fsb, face->font_name,
+ fsb->fsb.context, True);
+ /* If making it shared, be sure to synchronize with
+ the caller who might be using a different context */
+ DPSWaitContext(fsb->fsb.context);
+ }
+ }
+ }
+
+ XtCallCallbackList((Widget) fsb, callback, &cb);
+ return True;
+}
+
+/* ARGSUSED */
+
+static void OKCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+
+ if (!VerifyAndCallback(fsb, FSBOK, fsb->fsb.ok_callback)) return;
+ if (XtIsShell(XtParent(fsb))) XtPopdown(XtParent(fsb));
+ WriteBlends(fsb);
+ DesensitizeReset(fsb);
+ if (fsb->fsb.show_sampler) XtPopdown(fsb->fsb.sampler);
+}
+
+/* ARGSUSED */
+
+static void ApplyCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+
+ (void) VerifyAndCallback(fsb, FSBApply, fsb->fsb.apply_callback);
+ WriteBlends(fsb);
+ DesensitizeReset(fsb);
+}
+
+static void ResetFSB(
+ FontSelectionBoxWidget fsb,
+ FSBCallbackReason reason)
+{
+ FSBCallbackRec cb;
+ int i;
+
+ fsb->fsb.currently_previewed = NULL;
+ fsb->fsb.currently_previewed_size = fsb->fsb.currently_selected_size = 0.0;
+ SetUpCurrentSelections(fsb);
+ if (fsb->fsb.undef_unused_fonts) UndefUnusedFonts((Widget)fsb);
+
+ cb.reason = reason;
+ if (fsb->fsb.font_family_multiple) {
+ cb.family = NULL;
+ cb.family_selection = FSBMultiple;
+ } else if (fsb->fsb.font_family == NULL) {
+ cb.family = NULL;
+ cb.family_selection = FSBNone;
+ } else {
+ cb.family = fsb->fsb.font_family;
+ cb.family_selection = FSBOne;
+ }
+
+ if (fsb->fsb.font_face_multiple) {
+ cb.face = NULL;
+ cb.face_selection = FSBMultiple;
+ } else if (fsb->fsb.font_face == NULL) {
+ cb.face = NULL;
+ cb.face_selection = FSBNone;
+ } else {
+ cb.face = fsb->fsb.font_face;
+ cb.face_selection = FSBOne;
+ }
+
+ if (cb.family_selection == FSBMultiple ||
+ cb.face_selection == FSBMultiple) {
+ cb.name = NULL;
+ cb.name_selection = FSBMultiple;
+ } else if (fsb->fsb.font_face == NULL) {
+ cb.name = NULL;
+ cb.name_selection = FSBNone;
+ } else {
+ cb.name = fsb->fsb.font_name;
+ cb.name_selection = FSBOne;
+ }
+
+ if (fsb->fsb.font_size_multiple) {
+ cb.size = 0.0;
+ cb.size_selection = FSBMultiple;
+ } else {
+ cb.size = fsb->fsb.font_size;
+ cb.size_selection = FSBOne;
+ }
+
+ cb.afm_filename = NULL;
+ cb.afm_present = False;
+
+ cb.blend = fsb->fsb.font_blend;
+ if (cb.blend == NULL || fsb->fsb.currently_selected_blend == NULL) {
+ cb.base_name = NULL;
+ for (i = 0; i < MAX_AXES; i++) cb.axis_percent[i] = 0;
+ } else {
+ cb.base_name = fsb->fsb.currently_selected_face->font_name;
+ for (i = 0; i < MAX_AXES; i++) {
+ cb.axis_percent[i] = fsb->fsb.currently_selected_blend->data[i];
+ }
+ }
+
+ if (reason == FSBReset) {
+ XtCallCallbackList((Widget) fsb, fsb->fsb.reset_callback, &cb);
+ } else XtCallCallbackList((Widget) fsb, fsb->fsb.cancel_callback, &cb);
+}
+
+/* ARGSUSED */
+
+static void ResetCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+
+ ResetFSB(fsb, FSBReset);
+ DesensitizeReset(fsb);
+}
+
+/* ARGSUSED */
+
+static void CancelCallback(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+
+ ResetFSB(fsb, FSBCancel);
+ if (XtIsShell(XtParent(fsb))) XtPopdown(XtParent(fsb));
+ DesensitizeReset(fsb);
+ if (fsb->fsb.show_sampler) XtPopdown(fsb->fsb.sampler);
+}
+
+/* There's a problem; sometimes the change has already been made in the field,
+ and sometimes it hasn't. The times when it has seem to correspond to
+ making changes with the size option menu, so we use this disgusting
+ global flag to notice when this happens. We also use this to tell whether
+ or not the change is coming from internal to the widget or as a result
+ of user interaction. */
+
+static Boolean changingSize = False;
+
+/* ARGSUSED */
+
+static void SizeSelect(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ String value;
+ Widget option;
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+ char *ch;
+
+ XtVaGetValues(widget, XmNvalue, &value, NULL);
+
+ if (value == NULL) option = fsb->fsb.other_size;
+ else {
+ if (value[0] != '\0' && fsb->fsb.current_size_multiple) {
+ fsb->fsb.current_size_multiple = False;
+ UnmanageSizeMultiple(fsb);
+ }
+ for (ch = value; *ch != '\0'; ch++) if (*ch == '.') *ch = '-';
+
+ option = XtNameToWidget(fsb->fsb.size_menu, value);
+ if (option == NULL) option = fsb->fsb.other_size;
+ }
+
+ XtVaSetValues(fsb->fsb.size_option_menu_child,
+ XmNmenuHistory, option, NULL);
+
+ if (value != NULL && value[0] != '\0') {
+ fsb->fsb.currently_selected_size = atof(value);
+ } else fsb->fsb.currently_selected_size = 0.0;
+
+ if (!changingSize) SensitizeReset(fsb);
+ fsb->fsb.current_size_multiple = False;
+}
+
+/* ARGSUSED */
+
+static void TextVerify(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ int i;
+ XmTextVerifyPtr v = (XmTextVerifyPtr) callData;
+ char ch, *cp;
+ int decimalPoints = 0;
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+
+ if (changingSize) return; /* We know what we're doing; allow it */
+
+ /* Should probably look at format field, but seems to contain garbage */
+
+ if (v->text->length == 0) return;
+
+ if (v->text->length == 1) {
+ ch = v->text->ptr[0];
+ if (ch == 'p' || ch == 'P') {
+ XtCallCallbacks(fsb->fsb.preview_button_child,
+ XmNactivateCallback, NULL);
+ v->doit = False;
+ return;
+ }
+ }
+
+ for (i = 0; i < v->text->length; i++) {
+ ch = v->text->ptr[i];
+ if (ch == '.') decimalPoints++;
+ else if (!isdigit(ch)) {
+ v->doit = False;
+ return;
+ }
+ }
+
+ if (decimalPoints > 1) {
+ v->doit = False;
+ return;
+ }
+
+ XtVaGetValues(widget, XmNvalue, &cp, NULL);
+
+ for (/**/; *cp != '\0'; cp++) {
+ if (*cp == '.') decimalPoints++;
+ }
+
+ if (decimalPoints > 1) v->doit = False;
+}
+
+/* ARGSUSED */
+
+static void SetSize(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ char buf[20];
+ char *ch;
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+
+ if (fsb->fsb.current_size_multiple) {
+ fsb->fsb.current_size_multiple = False;
+ UnmanageSizeMultiple(fsb);
+ }
+
+ strcpy(buf, XtName(widget));
+ for (ch = buf; *ch != '\0'; ch++) if (*ch == '-') *ch++ = '.';
+
+ changingSize = True;
+ XtVaSetValues(fsb->fsb.size_text_field_child, XmNvalue, buf, NULL);
+ changingSize = False;
+
+ SensitizeReset(fsb);
+ ValueChanged(fsb);
+}
+
+/* This makes sure the selected item is visible */
+
+static void ListSelectPos(
+ Widget w,
+ int pos,
+ Boolean notify)
+{
+ int topPos, items, visible;
+
+ XmListSelectPos(w, pos, notify);
+
+ XtVaGetValues(w, XmNtopItemPosition, &topPos,
+ XmNvisibleItemCount, &visible, XmNitemCount, &items, NULL);
+
+ if (pos >= topPos && pos < topPos + visible) return;
+ topPos = pos - (visible-1)/2;
+ if (topPos + visible > items) topPos = items - visible + 1;
+ if (topPos < 1) topPos = 1;
+
+ XtVaSetValues(w, XmNtopItemPosition, topPos, NULL);
+}
+
+/* The following function Copyright 1987, 1988 by Digital Equipment
+Corporation, Maynard, Massachusetts, and the Massachusetts Institute of
+Technology, Cambridge, Massachusetts. */
+
+static String GetRootDirName(String buf)
+{
+#ifndef X_NOT_POSIX
+ uid_t uid;
+#else
+ int uid;
+ extern int getuid();
+#ifndef SYSV386
+ extern struct passwd *getpwuid(), *getpwnam();
+#endif
+#endif
+ struct passwd *pw;
+ static char *ptr = NULL;
+
+ if (ptr == NULL) {
+ if (!(ptr = getenv("HOME"))) {
+ if ((ptr = getenv("USER")) != NULL) pw = getpwnam(ptr);
+ else {
+ uid = getuid();
+ pw = getpwuid(uid);
+ }
+ if (pw) ptr = pw->pw_dir;
+ else {
+ ptr = NULL;
+ *buf = '\0';
+ }
+ }
+ }
+
+ if (ptr)
+ (void) strcpy(buf, ptr);
+
+ buf += strlen(buf);
+ *buf = '/';
+ buf++;
+ *buf = '\0';
+ return buf;
+}
+
+static void WriteBlendLine(
+ FILE *f,
+ String family, String face, String blend, String name,
+ int axes,
+ float *p)
+{
+ register char *ch;
+ int i;
+
+ ch = family;
+ while (*ch != '\0') {
+ if (*ch == ',' || *ch == '\\') (void) putc('\\', f);
+ (void) putc(*ch++, f);
+ }
+ putc(',', f);
+ ch = face;
+ while (*ch != '\0') {
+ if (*ch == ',' || *ch == '\\') (void) putc('\\', f);
+ (void) putc(*ch++, f);
+ }
+ putc(',', f);
+ ch = blend;
+ while (*ch != '\0') {
+ if (*ch == ',' || *ch == '\\') (void) putc('\\', f);
+ (void) putc(*ch++, f);
+ }
+ (void) putc(',', f);
+ ch = name;
+ while (*ch != '\0') {
+ if (*ch == ',' || *ch == '\\') (void) putc('\\', f);
+ (void) putc(*ch++, f);
+ }
+ for (i = 0; i < axes; i++) fprintf(f, ",%f", p[i]);
+ (void) putc('\n', f);
+}
+
+static void WriteBlends(FontSelectionBoxWidget fsb)
+{
+ FontFamilyRec *ff;
+ FontRec *f;
+ BlendRec *b;
+ String blendEnv;
+ char homeDir[PATH_BUF_SIZE];
+ FILE *blendFile = NULL;
+ char fileName[PATH_BUF_SIZE];
+
+ if (!fsb->fsb.blends_changed) return;
+
+ blendEnv = getenv("DPSFONTRC");
+
+ if (blendEnv != NULL) blendFile = fopen(blendEnv, "w");
+
+ if (blendFile == NULL) {
+ (void) GetRootDirName(homeDir);
+ sprintf(fileName, "%s/.dpsfontrc", homeDir);
+ blendFile = fopen(fileName, "w");
+
+ if (blendFile == NULL) return;
+ }
+
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ if (f->blend_data != NULL) {
+ for (b = f->blend_data->blends; b != NULL; b = b->next) {
+ WriteBlendLine(blendFile, ff->family_name, f->face_name,
+ b->blend_name, b->font_name,
+ f->blend_data->num_axes, b->data);
+ }
+ }
+ }
+ }
+
+ fclose(blendFile);
+ fsb->fsb.blends_changed = False;
+}
+
+static Boolean ParseBlendLine(
+ String buf, String family, String face, String blend, String name,
+ float *p)
+{
+ char *src, *dst;
+ int i;
+ float f;
+
+ src = buf;
+ dst = family;
+ while (*src != ',' && *src != '\0') {
+ if (*src == '\\') src++;
+ if (*src == '\0') return False;
+ *dst++ = *src++;
+ }
+ if (*src == '\0') return False;
+ *dst = '\0';
+ src++;
+ dst = face;
+ while (*src != ',' && *src != '\0') {
+ if (*src == '\\') src++;
+ if (*src == '\0') return False;
+ *dst++ = *src++;
+ }
+ if (*src == '\0') return False;
+ *dst = '\0';
+ src++;
+ dst = blend;
+ while (*src != ',' && *src != '\0') {
+ if (*src == '\\') src++;
+ if (*src == '\0') return False;
+ *dst++ = *src++;
+ }
+ if (*src == '\0') return False;
+ *dst = '\0';
+ src++;
+ dst = name;
+ while (*src != ',' && *src != '\0') {
+ if (*src == '\\') src++;
+ if (*src == '\0') return False;
+ *dst++ = *src++;
+ }
+ if (*src == '\0') return False;
+ *dst = '\0';
+ for (i = 0; i < MAX_AXES; i++) {
+ src++;
+ if (!ScanFloat(src, &f, &src)) {
+ for (/**/; i < MAX_AXES; i++) p[i] = 0;
+ return True;;
+ }
+ else p[i] = f;
+ }
+ return True;
+}
+
+static void ReadBlends(FontSelectionBoxWidget fsb)
+{
+ String blendEnv;
+ char homeDir[PATH_BUF_SIZE];
+ FILE *blendFile = NULL;
+ char fileName[PATH_BUF_SIZE];
+#define BUF 256
+ char buf[BUF+1], family[BUF+1], face[BUF+1], blend[BUF+1], name[BUF+1];
+ char *cfamily, *cface;
+ float p[MAX_AXES];
+ FontRec *f;
+ FontFamilyRec *ff = 0;
+ BlendRec *b, *newb, **lastb;
+ char *spaceBlend;
+ char *lastFamily = NULL;
+ int cmp, i;
+
+ blendEnv = getenv("DPSFONTRC");
+
+ if (blendEnv != NULL) blendFile = fopen(blendEnv, "r");
+
+ if (blendFile == NULL) {
+ (void) GetRootDirName(homeDir);
+ sprintf(fileName, "%s/.dpsfontrc", homeDir);
+ blendFile = fopen(fileName, "r");
+
+ if (blendFile == NULL) return;
+ }
+
+ while (1) {
+ if (fgets(buf, BUF, blendFile) == NULL) {
+ fclose(blendFile);
+ return;
+ }
+ if (ParseBlendLine(buf, family, face, blend, name, p)) {
+ cfamily = Canonical(family);
+ if (cfamily != lastFamily) {
+ for (ff = fsb->fsb.known_families;
+ ff != NULL && ff->family_name != cfamily;
+ ff = ff->next) {}
+ }
+ if (ff == NULL) continue;
+ lastFamily = cfamily;
+ cface = Canonical(face);
+ for (f = ff->fonts; f != NULL && f->face_name != cface;
+ f = f->next) {}
+ /* If the blend data is NULL, we have a blend line for a font
+ that we don't believe is a MM font. Ignore it */
+ if (f != NULL && f->blend_data != NULL) {
+ lastb = &f->blend_data->blends;
+ cmp = -1;
+ for (b = f->blend_data->blends; b != NULL; b = b->next) {
+ cmp = strcmp(blend, b->blend_name);
+ if (cmp < 0) break;
+ lastb = &b->next;
+ }
+ if (cmp != 0) {
+ newb = XtNew(BlendRec);
+ newb->blend_name = Canonical(blend);
+ newb->CS_blend_name = CS(newb->blend_name, (Widget) fsb);
+
+ spaceBlend = (char *) XtMalloc(strlen(blend) + 4);
+ spaceBlend[0] = spaceBlend[1] = spaceBlend[2] = ' ';
+ strcpy(spaceBlend+3, blend);
+ newb->CS_space_blend_name = CS(spaceBlend, (Widget) fsb);
+ XtFree((XtPointer) spaceBlend);
+
+ for (i = 0; i < MAX_AXES; i++) newb->data[i] = p[i];
+ newb->font_name = Canonical(name);
+
+ f->blend_count++;
+ ff->blend_count++;
+
+ newb->next = b;
+ *lastb = newb;
+ }
+ }
+ }
+ }
+}
+
+static void SetUpFaceList(
+ FontSelectionBoxWidget fsb,
+ FontFamilyRec *ff)
+{
+ FontRec *f;
+ BlendRec *b;
+ XmString *CSfaces;
+ Boolean multiple = False;
+ int i;
+
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ if (f->blend_data != NULL) {
+ multiple = True;
+ break;
+ }
+ }
+ if (multiple) ManageMultipleMaster(fsb);
+ else UnmanageMultipleMaster(fsb);
+
+ CSfaces = (XmString *) XtCalloc(ff->font_count + ff->blend_count,
+ sizeof(XmString));
+
+ i = 0;
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ CSfaces[i++] = f->CS_face_name;
+ if (f->blend_data != NULL) {
+ for (b = f->blend_data->blends; b != NULL; b = b->next) {
+ CSfaces[i++] = b->CS_space_blend_name;
+ }
+ }
+ }
+
+ XtVaSetValues(fsb->fsb.face_scrolled_list_child,
+ XmNitemCount, ff->font_count + ff->blend_count,
+ XmNitems, CSfaces, NULL);
+ XtFree((XtPointer) CSfaces);
+}
+
+/* ARGSUSED */
+
+static void DeleteMessage(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ XtDestroyWidget(widget);
+}
+
+static void FlushFont(
+ FontSelectionBoxWidget fsb,
+ FontRec *font)
+{
+ FontRec *f = 0, *f1;
+ FontFamilyRec *ff, *ff1;
+ Boolean previewedFamily = False;
+
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ if (f == font) goto FOUND_BOGUS;
+ }
+ }
+
+FOUND_BOGUS:
+ if (f != NULL) {
+ for (f1 = ff->fonts; f1 != NULL; f1 = f1->next) {
+ if (f1 == fsb->fsb.currently_previewed) {
+ previewedFamily = True;
+ break;
+ }
+ }
+
+ if (ff->fonts == f) {
+ ff->fonts = f->next;
+ } else {
+ for (f1 = ff->fonts; f1 != NULL && f1->next != f; f1 = f1->next) {}
+ if (f1 != NULL) f1->next = f->next;
+ }
+
+ ff->font_count--;
+ ff->blend_count -= f->blend_count;
+
+ if (f == fsb->fsb.currently_selected_face) {
+ fsb->fsb.currently_selected_face = NULL;
+ fsb->fsb.currently_selected_blend = NULL;
+ }
+
+ if (previewedFamily) SetUpFaceList(fsb, ff);
+
+ if (f == fsb->fsb.currently_previewed) {
+ fsb->fsb.currently_previewed = NULL;
+ fsb->fsb.currently_previewed_blend = NULL;
+ ValueChanged(fsb);
+ }
+
+ /* We do not free the FontRec or FontFamilyRec. In the long
+ run we don't expect to leak much storage this way, since we
+ shouldn't have many bogus fonts, and invalidating every
+ reference here, in the sampler, and in the creator isn't
+ worth the small storage waste. */
+
+ if (ff->fonts == NULL) {
+ if (fsb->fsb.known_families == ff) {
+ fsb->fsb.known_families = ff->next;
+ } else {
+ for (ff1 = fsb->fsb.known_families;
+ ff1 != NULL && ff1->next != ff; ff1 = ff1->next) {}
+ if (ff1 != NULL) ff1->next = ff->next;
+ }
+
+ fsb->fsb.family_count--;
+
+ if (ff == fsb->fsb.currently_selected_family) {
+ fsb->fsb.currently_selected_family = NULL;
+ }
+
+ DisplayFontFamilies(fsb);
+ }
+ }
+}
+
+void _FSBFlushFont(
+ FontSelectionBoxWidget fsb,
+ FontRec *font)
+{
+ if (font == fsb->fsb.currently_previewed) _FSBBogusFont(fsb, font);
+ else FlushFont(fsb, font);
+}
+
+void _FSBBogusFont(
+ FontSelectionBoxWidget fsb,
+ FontRec *font)
+{
+ Widget message, w;
+
+ message = XmCreateInformationDialog((Widget) fsb, "invalidFontMessage",
+ (ArgList) NULL, 0);
+ w = XmMessageBoxGetChild(message, XmDIALOG_CANCEL_BUTTON);
+ XtUnmanageChild(w);
+ w = XmMessageBoxGetChild(message, XmDIALOG_HELP_BUTTON);
+ XtUnmanageChild(w);
+ XtAddCallback(message, XmNokCallback, DeleteMessage, (XtPointer) NULL);
+
+ XtManageChild(message);
+
+ /* Now get this blasted thing out of here */
+ FlushFont(fsb, font);
+}
+
+void _FSBSetUpFaceList(
+ FontSelectionBoxWidget fsb,
+ Bool redisplay)
+{
+ FontRec *f;
+ BlendRec *b;
+ int i;
+
+ SetUpFaceList(fsb, fsb->fsb.currently_selected_family);
+
+ f = fsb->fsb.currently_selected_family->fonts;
+ i = 1;
+ while (f != NULL) {
+ if (f == fsb->fsb.currently_selected_face) {
+ if (f->blend_data != NULL) {
+ b = f->blend_data->blends;
+ if (fsb->fsb.currently_selected_blend != NULL) {
+ i++;
+ while (b != NULL &&
+ b != fsb->fsb.currently_selected_blend) {
+ i++;
+ b = b->next;
+ }
+ }
+ }
+ break;
+ } else {
+ i += f->blend_count+1;
+ f = f->next;
+ }
+ }
+
+ ListSelectPos(fsb->fsb.face_scrolled_list_child, i, False);
+ if (redisplay) ValueChanged(fsb);
+ fsb->fsb.blends_changed = True;
+}
+
+static String categories[][6] = {
+ {"Regular", "Roman", "Medium", "Book", "Light", NULL},
+ {"Italic", "Slanted", "Oblique", NULL},
+ {"Demi", "Semibold", "Heavy", "Bold", NULL},
+ {NULL},
+};
+
+#define NORMALINDEX 0][0
+#define ITALICINDEX 1][0
+#define BOLDINDEX 2][3
+#define DEMIINDEX 2][0
+#define LIGHTINDEX 0][4
+#define BOOKINDEX 0][3
+
+static String extraNormalFaces[] = {"Demi", "Semibold", NULL};
+
+static int MatchFaceName(
+ FSBFaceSelectCallbackRec *rec,
+ Boolean *gaveUp)
+{
+ int i, j, k, face;
+#define PIECEMAX 10
+ String pieces[PIECEMAX];
+ int numPieces;
+ int pass;
+ char *ch, *start, *compare;
+ char save;
+ static Boolean categoriesInited = False;
+ static char *canonicalBold, *canonicalLight, *canonicalBook;
+
+ *gaveUp = False;
+
+ if (!categoriesInited) {
+ for (i = 0; categories[i][0] != NULL; i++) {
+ for (j = 0; categories[i][j] != NULL; j++) {
+ categories[i][j] = Canonical(categories[i][j]);
+ }
+ }
+ for (i = 0; extraNormalFaces[i] != NULL; i++) {
+ extraNormalFaces[i] = Canonical(extraNormalFaces[i]);
+ }
+ canonicalBold = categories[BOLDINDEX];
+ canonicalLight = categories[LIGHTINDEX];
+ canonicalBook = categories[BOOKINDEX];
+ categoriesInited = True;
+ }
+
+ if (rec->current_face == NULL || rec->current_face[0] == '\0') {
+ goto GIVE_UP;
+ }
+
+ /* First check for an exact match */
+
+ for (i = 0; i < rec->num_available_faces; i++) {
+ if (rec->available_faces[i] == rec->current_face) return i;
+ }
+
+ /* Try some category matching. We make two passes; in the first pass
+ we remove "Bold" from the "Demi" family and "Light" and "Book" from
+ the "Regular" family; in the second pass we include them. We ignore
+ leading digits in the face name. */
+
+ categories[BOLDINDEX] = categories[LIGHTINDEX] =
+ categories[BOOKINDEX] = NULL;
+
+ i = 0;
+ ch = rec->current_face;
+ while (*ch == ' ' || isdigit(*ch)) ch++;
+ start = ch;
+
+ while (1) {
+ while (*ch != ' ' && *ch != '\0') ch++;
+ save = *ch;
+ *ch = '\0';
+ compare = Canonical(start);
+ for (j = 0; categories[j][0] != NULL; j++) {
+ for (k = 0; categories[j][k] != NULL; k++) {
+ if (compare == categories[j][k]) {
+ pieces[i++] = categories[j][0];
+ goto FOUND_PIECE;
+ }
+ }
+ }
+ pieces[i++] = compare; /* A unique piece */
+FOUND_PIECE:
+ *ch = save;
+ while (*ch == ' ') ch++;
+ if (*ch == '\0') break;
+ if (i >= PIECEMAX) goto GIVE_UP;
+ start = ch;
+ }
+ numPieces = i;
+ if (numPieces == 0) goto GIVE_UP;
+
+ /* Special case starting with the italic category */
+
+ if (pieces[0] == categories[ITALICINDEX] && numPieces < PIECEMAX-1) {
+ for (i = numPieces; i > 0; i--) pieces[i] = pieces[i-1];
+ pieces[0] = categories[NORMALINDEX];
+ numPieces++;
+ }
+
+ for (pass = 0; pass < 2; pass++) {
+ if (pass == 1) {
+ categories[BOLDINDEX] = canonicalBold;
+ categories[LIGHTINDEX] = canonicalLight;
+ categories[BOOKINDEX] = canonicalBook;
+ for (i = 0; i < numPieces; i++) {
+ if (pieces[i] == canonicalBold) {
+ pieces[i] = categories[DEMIINDEX];
+ } else if (pieces[i] == canonicalLight) {
+ pieces[i] = categories[NORMALINDEX];
+ } else if (pieces[i] == canonicalBook) {
+ pieces[i] = categories[NORMALINDEX];
+ }
+ }
+ }
+
+ /* Now match against each face */
+
+ for (face = 0; face < rec->num_available_faces; face++) {
+ i = 0;
+ ch = rec->available_faces[face];
+ while (*ch == ' ' || isdigit(*ch)) ch++;
+ start = ch;
+
+ while (1) {
+ while (*ch != ' ' && *ch != '\0') ch++;
+ save = *ch;
+ *ch = '\0';
+ compare = Canonical(start);
+ for (j = 0; categories[j][0] != NULL; j++) {
+ for (k = 0; categories[j][k] != NULL; k++) {
+ if (compare == categories[j][k]) {
+ compare = categories[j][0];
+ goto MATCH;
+ }
+ }
+ }
+ MATCH:
+ /* Special case matching the italic category again */
+
+ if (i == 0 && compare == categories[ITALICINDEX] &&
+ pieces[0] == categories[NORMALINDEX] &&
+ numPieces > 1 &&
+ pieces[1] == categories[ITALICINDEX]) i = 1;
+
+ if (pieces[i] != compare) {
+ *ch = save;
+ goto NEXT_FACE;
+ } else i++;
+
+ *ch = save;
+ while (*ch == ' ') ch++;
+ if (*ch == '\0') break;
+ if (i >= numPieces) goto NEXT_FACE;
+ start = ch;
+ }
+ if (i == numPieces) return face; /* Found a match! */
+ NEXT_FACE:
+ ;
+ }
+ }
+
+ /* Couldn't find a match. Look for a "normal face". Make sure "Light"
+ and "Book" are installed. Again, ignore leading spaces. */
+GIVE_UP:
+ *gaveUp = True;
+ categories[LIGHTINDEX] = canonicalLight;
+ categories[BOOKINDEX] = canonicalBook;
+
+ for (i = 0; categories[0][i] != NULL; i++) {
+ for (face = 0; face < rec->num_available_faces; face++) {
+ compare = rec->available_faces[face];
+ while (*compare == ' ' || isdigit(*compare)) compare++;
+ if (compare != rec->available_faces[face]) {
+ compare = Canonical(compare);
+ }
+ if (categories[0][i] == compare) return face;
+ }
+ }
+
+ for (i = 0; extraNormalFaces[i] != NULL; i++) {
+ for (face = 0; face < rec->num_available_faces; face++) {
+ compare = rec->available_faces[face];
+ while (*compare == ' ' || isdigit(*compare)) compare++;
+ if (compare != rec->available_faces[face]) {
+ compare = Canonical(compare);
+ }
+ if (extraNormalFaces[i] == compare) return face;
+ }
+ }
+
+ /* Oh, well. Use the first one */
+ return 0;
+}
+
+static void GetInitialFace(
+ FontSelectionBoxWidget fsb,
+ FontFamilyRec *ff)
+{
+ FSBFaceSelectCallbackRec rec;
+ String *faces;
+ int i, j;
+ FontRec *f;
+ Boolean junk;
+
+ faces = (String *) XtMalloc(ff->font_count * sizeof(String));
+ i = 0;
+ for (f = ff->fonts; f != NULL; f = f->next) faces[i++] = f->face_name;
+
+ rec.available_faces = faces;
+ rec.num_available_faces = ff->font_count;
+
+ if (fsb->fsb.currently_selected_face != NULL) {
+ rec.current_face = fsb->fsb.currently_selected_face->face_name;
+ } else rec.current_face = fsb->fsb.font_face;
+
+ rec.new_face = NULL;
+
+ XtCallCallbackList((Widget) fsb, fsb->fsb.face_select_callback, &rec);
+ if (rec.new_face != NULL) {
+ for (i = 0; i < ff->font_count; i++) {
+ if (rec.new_face == faces[i]) break;
+ }
+ }
+ if (rec.new_face == NULL || i >= ff->font_count) {
+ i = MatchFaceName(&rec, &junk);
+ }
+ XtFree((XtPointer) faces);
+
+ j = 0;
+ for (f = ff->fonts; i != 0; f= f->next) {
+ j += f->blend_count + 1;
+ i--;
+ }
+
+ ListSelectPos(fsb->fsb.face_scrolled_list_child, j+1, False);
+ fsb->fsb.currently_selected_face = f;
+ fsb->fsb.currently_selected_blend = NULL;
+}
+
+/* ARGSUSED */
+
+static void FamilySelect(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ XmListCallbackStruct *listCB = (XmListCallbackStruct *) callData;
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+ FontFamilyRec *ff = fsb->fsb.known_families;
+ int i;
+
+ if (fsb->fsb.current_family_multiple) {
+ fsb->fsb.current_family_multiple = False;
+ UnmanageFamilyMultiple(fsb);
+ }
+
+ /* List uses 1-based addressing!! */
+ for (i = 1; i < listCB->item_position; i++) ff = ff->next;
+
+ fsb->fsb.currently_selected_family = ff;
+
+ SensitizeReset(fsb);
+ SetUpFaceList(fsb, ff);
+ if (!fsb->fsb.current_face_multiple) GetInitialFace(fsb, ff);
+ ValueChanged(fsb);
+}
+
+/* ARGSUSED */
+
+static void FaceSelect(
+ Widget widget,
+ XtPointer clientData, XtPointer callData)
+{
+ XmListCallbackStruct *listCB = (XmListCallbackStruct *) callData;
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) clientData;
+ FontRec *f;
+ BlendRec *b;
+ int n;
+
+ if (fsb->fsb.currently_selected_family == NULL) return;
+ f = fsb->fsb.currently_selected_family->fonts;
+
+ if (fsb->fsb.current_face_multiple) {
+ fsb->fsb.current_face_multiple = False;
+ UnmanageFaceMultiple(fsb);
+ }
+
+ /* List uses 1-based addressing!! */
+ n = 0;
+ while (1) {
+ n += f->blend_count + 1;
+ if (n >= listCB->item_position) {
+ n -= f->blend_count;
+ if (n == listCB->item_position) b = NULL;
+ else for (b = f->blend_data->blends; n < listCB->item_position - 1;
+ b = b->next) n++;
+ break;
+ }
+ f = f->next;
+ }
+
+ fsb->fsb.currently_selected_face = f;
+ fsb->fsb.currently_selected_blend = b;
+
+ SensitizeReset(fsb);
+ ValueChanged(fsb);
+}
+
+static void CreateSizeMenu(
+ FontSelectionBoxWidget fsb,
+ Boolean destroyOldChildren)
+{
+ Arg args[20];
+ int i, j;
+ Widget *sizes;
+ char buf[20];
+ Widget *children;
+ Cardinal num_children;
+ XmString csName;
+ char *ch;
+
+ if (destroyOldChildren) {
+ XtVaGetValues(fsb->fsb.size_menu, XtNchildren, &children,
+ XtNnumChildren, &num_children, NULL);
+
+ /* Don't destroy first child ("other") */
+ for (j = 1; (Cardinal)j < num_children; j++) XtDestroyWidget(children[j]);
+
+ sizes = (Widget *) XtMalloc((fsb->fsb.size_count+1) * sizeof(Widget));
+ sizes[0] = children[0];
+ } else {
+ i = 0;
+ sizes = (Widget *) XtMalloc((fsb->fsb.size_count+1) * sizeof(Widget));
+ fsb->fsb.other_size = sizes[0] =
+ XtCreateManagedWidget("other", xmPushButtonGadgetClass,
+ fsb->fsb.size_menu, args, i);
+ }
+
+ for (j = 0; j < fsb->fsb.size_count; j++) {
+ (void) sprintf(buf, "%g", fsb->fsb.sizes[j]);
+ csName = UnsharedCS(buf);
+ for (ch = buf; *ch != '\0'; ch++) if (*ch == '.') *ch = '-';
+ i = 0;
+ XtSetArg(args[i], XmNlabelString, csName); i++;
+ sizes[j+1] =
+ XmCreatePushButtonGadget(fsb->fsb.size_menu, buf, args, i);
+ XmStringFree(csName);
+ XtAddCallback(sizes[j+1], XmNactivateCallback,
+ SetSize, (XtPointer) fsb);
+ }
+ XtManageChildren(sizes, j+1);
+ XtFree((char *) sizes);
+}
+
+static void CreateChildren(FontSelectionBoxWidget fsb)
+{
+ Arg args[20];
+ int i;
+ Widget form;
+
+ i = 0;
+ fsb->fsb.pane_child =
+ XtCreateManagedWidget("pane", xmPanedWindowWidgetClass,
+ (Widget) fsb, args, i);
+
+ i = 0;
+ fsb->fsb.preview_child =
+ XtCreateManagedWidget("preview", xmDrawingAreaWidgetClass,
+ fsb->fsb.pane_child, args, i);
+ XtAddCallback(fsb->fsb.preview_child, XmNexposeCallback,
+ PreviewText, (XtPointer) fsb);
+ XtAddCallback(fsb->fsb.preview_child, XmNresizeCallback,
+ ResizePreview, (XtPointer) fsb);
+
+ i = 0;
+ form = XtCreateManagedWidget("panel", xmFormWidgetClass,
+ fsb->fsb.pane_child, args, i);
+ fsb->fsb.panel_child = form;
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ fsb->fsb.ok_button_child =
+ XtCreateManagedWidget("okButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(fsb->fsb.ok_button_child, XmNactivateCallback,
+ OKCallback, (XtPointer) fsb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget,fsb->fsb.ok_button_child ); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ fsb->fsb.apply_button_child =
+ XtCreateManagedWidget("applyButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(fsb->fsb.apply_button_child, XmNactivateCallback,
+ ApplyCallback, (XtPointer) fsb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget,fsb->fsb.apply_button_child ); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ fsb->fsb.reset_button_child =
+ XtCreateManagedWidget("resetButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(fsb->fsb.reset_button_child, XmNactivateCallback,
+ ResetCallback, (XtPointer) fsb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget,fsb->fsb.reset_button_child ); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ fsb->fsb.cancel_button_child =
+ XtCreateManagedWidget("cancelButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(fsb->fsb.cancel_button_child, XmNactivateCallback,
+ CancelCallback, (XtPointer) fsb);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, fsb->fsb.ok_button_child); i++;
+ fsb->fsb.separator_child =
+ XtCreateManagedWidget("separator", xmSeparatorGadgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, fsb->fsb.separator_child); i++;
+ fsb->fsb.size_label_child =
+ XtCreateManagedWidget("sizeLabel", xmLabelWidgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, fsb->fsb.size_label_child); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, fsb->fsb.size_label_child); i++;
+ fsb->fsb.size_text_field_child =
+ XtCreateManagedWidget("sizeTextField", xmTextFieldWidgetClass,
+ form, args, i);
+ XtAddCallback(fsb->fsb.size_text_field_child, XmNvalueChangedCallback,
+ SizeSelect, (XtPointer) fsb);
+ XtAddCallback(fsb->fsb.size_text_field_child, XmNmodifyVerifyCallback,
+ TextVerify, (XtPointer) fsb);
+
+ i = 0;
+ fsb->fsb.size_menu = XmCreatePulldownMenu(form, "sizeMenu", args, i);
+
+ CreateSizeMenu(fsb, False);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, fsb->fsb.size_text_field_child); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, fsb->fsb.size_label_child); i++;
+ XtSetArg(args[i], XmNsubMenuId, fsb->fsb.size_menu); i++;
+ fsb->fsb.size_option_menu_child =
+ XmCreateOptionMenu(form, "sizeOptionMenu", args, i);
+ XtManageChild(fsb->fsb.size_option_menu_child);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, fsb->fsb.size_option_menu_child); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, fsb->fsb.separator_child); i++;
+ fsb->fsb.size_multiple_label_child =
+ XtCreateWidget("sizeMultipleLabel", xmLabelWidgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, fsb->fsb.size_label_child); i++;
+ fsb->fsb.preview_button_child =
+ XtCreateManagedWidget("previewButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(fsb->fsb.preview_button_child, XmNactivateCallback,
+ PreviewCallback, (XtPointer) fsb);
+
+ i = 0;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, fsb->fsb.preview_button_child); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, fsb->fsb.preview_button_child); i++;
+ fsb->fsb.sampler_button_child =
+ XtCreateWidget("samplerButton", xmPushButtonWidgetClass,
+ form, args, i);
+ if (fsb->fsb.show_sampler_button) {
+ XtManageChild(fsb->fsb.sampler_button_child);
+ }
+ XtAddCallback(fsb->fsb.sampler_button_child, XmNactivateCallback,
+ ShowSamplerCallback, (XtPointer) fsb);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNrightPosition, 50); i++;
+ fsb->fsb.family_label_child =
+ XtCreateManagedWidget("familyLabel", xmLabelGadgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNleftPosition, 50); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ fsb->fsb.face_label_child =
+ XtCreateManagedWidget("faceLabel", xmLabelGadgetClass,
+ form, args, i);
+
+ /* The next two must be widgets in order to be reversed in color */
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, fsb->fsb.family_label_child); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNrightPosition, 50); i++;
+ fsb->fsb.family_multiple_label_child =
+ XtCreateWidget("familyMultipleLabel", xmLabelWidgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, fsb->fsb.face_label_child); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNleftPosition, 50); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ fsb->fsb.face_multiple_label_child =
+ XtCreateWidget("faceMultipleLabel", xmLabelWidgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNitemCount, 1); i++;
+ XtSetArg(args[i], XmNitems, &CSempty); i++;
+ fsb->fsb.family_scrolled_list_child =
+ XmCreateScrolledList(form, "familyScrolledList", args, i);
+ XtAddCallback(fsb->fsb.family_scrolled_list_child,
+ XmNbrowseSelectionCallback, FamilySelect, (XtPointer) fsb);
+ XtAddCallback(fsb->fsb.family_scrolled_list_child,
+ XmNdefaultActionCallback,
+ PreviewDoubleClick, (XtPointer) fsb);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, fsb->fsb.family_label_child); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, fsb->fsb.size_text_field_child); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNrightPosition, 50); i++;
+ XtSetValues(XtParent(fsb->fsb.family_scrolled_list_child), args, i);
+ XtManageChild(fsb->fsb.family_scrolled_list_child);
+
+ i = 0;
+ XtSetArg(args[i], XmNitemCount, 1); i++;
+ XtSetArg(args[i], XmNitems, &CSempty); i++;
+ fsb->fsb.face_scrolled_list_child =
+ XmCreateScrolledList(form, "faceScrolledList", args, i);
+ XtAddCallback(fsb->fsb.face_scrolled_list_child,
+ XmNbrowseSelectionCallback, FaceSelect, (XtPointer) fsb);
+ XtAddCallback(fsb->fsb.face_scrolled_list_child,
+ XmNdefaultActionCallback, PreviewDoubleClick,
+ (XtPointer) fsb);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, fsb->fsb.face_label_child); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, fsb->fsb.size_text_field_child); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNleftPosition, 50); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ XtSetValues(XtParent(fsb->fsb.face_scrolled_list_child), args, i);
+ XtManageChild(fsb->fsb.face_scrolled_list_child);
+
+ i = 0;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, fsb->fsb.size_text_field_child); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_POSITION); i++;
+ XtSetArg(args[i], XmNleftPosition, 50); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ fsb->fsb.multiple_master_button_child =
+ XtCreateWidget("multipleMasterButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(fsb->fsb.multiple_master_button_child, XmNactivateCallback,
+ ShowCreatorCallback, (XtPointer) fsb);
+
+ i = 0;
+ XtSetArg(args[i], XmNdefaultButton, fsb->fsb.ok_button_child); i++;
+ XtSetValues(form, args, i);
+}
+
+static void DisplayFontFamilies(FontSelectionBoxWidget fsb)
+{
+ FontFamilyRec *ff;
+ XmString *CSlist, *str;
+
+ CSlist = (XmString *) XtMalloc(fsb->fsb.family_count * sizeof(XmString));
+ str = CSlist;
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ *str++ = UnsharedCS(ff->family_name);
+ }
+
+ XtVaSetValues(fsb->fsb.family_scrolled_list_child,
+ XmNitemCount, fsb->fsb.family_count,
+ XmNitems, CSlist, NULL);
+
+ /* The list makes a copy, so we can delete the list */
+ XtFree((char *) CSlist);
+}
+
+static void SetUpCurrentFontFromName(FontSelectionBoxWidget fsb)
+{
+ FontFamilyRec *ff;
+ FontRec *f;
+ BlendRec *b;
+ int i, j;
+
+ fsb->fsb.currently_selected_face = NULL;
+ fsb->fsb.currently_selected_family = NULL;
+ fsb->fsb.currently_selected_blend = NULL;
+
+ if (fsb->fsb.font_name_multiple || fsb->fsb.font_name == NULL) {
+ fsb->fsb.font_name = NULL;
+ fsb->fsb.font_family = NULL;
+ fsb->fsb.font_blend = NULL;
+ fsb->fsb.font_face = NULL;
+ if (fsb->fsb.font_name_multiple) {
+ fsb->fsb.current_family_multiple = True;
+ fsb->fsb.current_face_multiple = True;
+ ManageFamilyMultiple(fsb);
+ ManageFaceMultiple(fsb);
+ }
+ XmListDeselectAllItems(fsb->fsb.family_scrolled_list_child);
+ XmListDeselectAllItems(fsb->fsb.face_scrolled_list_child);
+ XmListDeleteAllItems(fsb->fsb.face_scrolled_list_child);
+ XmListAddItem(fsb->fsb.face_scrolled_list_child, CSempty, 1);
+ return;
+ }
+
+ if (!fsb->fsb.font_name_multiple) {
+ fsb->fsb.current_family_multiple = False;
+ fsb->fsb.current_face_multiple = False;
+ UnmanageFamilyMultiple(fsb);
+ UnmanageFaceMultiple(fsb);
+ }
+
+ fsb->fsb.font_name = Canonical(fsb->fsb.font_name);
+ i = 1;
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ j = 1;
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ if (f->font_name == fsb->fsb.font_name) {
+ fsb->fsb.font_family = ff->family_name;
+ fsb->fsb.font_face = f->face_name;
+ SetUpFaceList(fsb, ff);
+ ListSelectPos(fsb->fsb.family_scrolled_list_child, i, False);
+ ListSelectPos(fsb->fsb.face_scrolled_list_child, j, False);
+ fsb->fsb.currently_selected_face = f;
+ fsb->fsb.currently_selected_family = ff;
+ fsb->fsb.currently_selected_blend = NULL;
+ return;
+ }
+ j++;
+ if (f->blend_data != NULL && f->blend_data->blends != NULL) {
+ for (b = f->blend_data->blends; b != NULL; b = b->next) {
+ if (b->font_name == fsb->fsb.font_name) {
+ fsb->fsb.font_family = ff->family_name;
+ fsb->fsb.font_face = f->face_name;
+ SetUpFaceList(fsb, ff);
+ ListSelectPos(fsb->fsb.family_scrolled_list_child, i,
+ False);
+ ListSelectPos(fsb->fsb.face_scrolled_list_child, j,
+ False);
+ fsb->fsb.currently_selected_face = f;
+ fsb->fsb.currently_selected_family = ff;
+ fsb->fsb.currently_selected_blend = b;
+ return;
+ }
+ j++;
+ }
+ }
+
+ }
+ i++;
+ }
+
+ /* Didn't find it! */
+ fsb->fsb.font_name = NULL;
+ fsb->fsb.font_family = NULL;
+ fsb->fsb.font_face = NULL;
+ fsb->fsb.font_blend = NULL;
+ XmListDeselectAllItems(fsb->fsb.family_scrolled_list_child);
+ XmListDeselectAllItems(fsb->fsb.face_scrolled_list_child);
+ XmListDeleteAllItems(fsb->fsb.face_scrolled_list_child);
+ XmListAddItem(fsb->fsb.face_scrolled_list_child, CSempty, 1);
+}
+
+static void SetUpCurrentFontFromFamilyFace(FontSelectionBoxWidget fsb)
+{
+ FontFamilyRec *ff;
+ FontRec *f;
+ BlendRec *b;
+ int i;
+
+ fsb->fsb.currently_selected_face = NULL;
+ fsb->fsb.currently_selected_family = NULL;
+ fsb->fsb.currently_selected_blend = NULL;
+
+ if (fsb->fsb.font_family_multiple) {
+ fsb->fsb.font_family = NULL;
+ fsb->fsb.current_family_multiple = True;
+ ManageFamilyMultiple(fsb);
+ } else {
+ fsb->fsb.current_family_multiple = False;
+ UnmanageFamilyMultiple(fsb);
+ }
+
+ if (fsb->fsb.font_face_multiple) {
+ fsb->fsb.font_face = NULL;
+ fsb->fsb.current_face_multiple = True;
+ ManageFaceMultiple(fsb);
+ } else {
+ fsb->fsb.current_face_multiple = False;
+ UnmanageFaceMultiple(fsb);
+ }
+
+ fsb->fsb.font_name_multiple =
+ fsb->fsb.font_family_multiple || fsb->fsb.font_face_multiple;
+
+ if (fsb->fsb.font_family != NULL) {
+ fsb->fsb.font_family = Canonical(fsb->fsb.font_family);
+ i = 1;
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ if (fsb->fsb.font_family == ff->family_name) {
+ ListSelectPos(fsb->fsb.family_scrolled_list_child, i, False);
+ fsb->fsb.currently_selected_family = ff;
+ SetUpFaceList(fsb, ff);
+ break;
+ }
+ i++;
+ }
+ if (ff == NULL) fsb->fsb.font_family = NULL;
+ }
+
+ if (fsb->fsb.font_family == NULL) {
+ fsb->fsb.font_face = NULL;
+ fsb->fsb.font_blend = NULL;
+ fsb->fsb.font_name = NULL;
+ XmListDeselectAllItems(fsb->fsb.family_scrolled_list_child);
+ XmListDeselectAllItems(fsb->fsb.face_scrolled_list_child);
+ XmListDeleteAllItems(fsb->fsb.face_scrolled_list_child);
+ XmListAddItem(fsb->fsb.face_scrolled_list_child, CSempty, 1);
+ return;
+ }
+
+ if (fsb->fsb.font_face != NULL) {
+ fsb->fsb.font_face = Canonical(fsb->fsb.font_face);
+
+ i = 1;
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ if (fsb->fsb.font_face == f->face_name) {
+ fsb->fsb.currently_selected_face = f;
+ if (fsb->fsb.font_blend != NULL) {
+ fsb->fsb.font_blend = Canonical(fsb->fsb.font_blend);
+ for (b = f->blend_data->blends; b != NULL; b = b->next) {
+ i++;
+ if (b->blend_name == fsb->fsb.font_blend) {
+ fsb->fsb.currently_selected_blend = b;
+ break;
+ }
+ }
+ if (b == NULL) {
+ fsb->fsb.font_blend = NULL;
+ i -= f->blend_count;
+ }
+ }
+ ListSelectPos(fsb->fsb.face_scrolled_list_child, i, False);
+ break;
+ }
+ i += f->blend_count + 1;
+ }
+ if (f == NULL) fsb->fsb.font_face = NULL;
+ } else {
+ f = NULL;
+ XmListDeselectAllItems(fsb->fsb.face_scrolled_list_child);
+ }
+
+ if (f == NULL && !fsb->fsb.font_face_multiple) GetInitialFace(fsb, ff);
+}
+
+static void SetUpCurrentFont(FontSelectionBoxWidget fsb)
+{
+ if (fsb->fsb.use_font_name) SetUpCurrentFontFromName(fsb);
+ else SetUpCurrentFontFromFamilyFace(fsb);
+}
+
+static void SetUpCurrentSize(FontSelectionBoxWidget fsb)
+{
+ char buf[20];
+
+ if (fsb->fsb.font_size_multiple) {
+ changingSize = True;
+ XtVaSetValues(fsb->fsb.size_text_field_child, XmNvalue, "", NULL);
+ changingSize = False;
+ fsb->fsb.current_size_multiple = True;
+ ManageSizeMultiple(fsb);
+ return;
+ } else UnmanageSizeMultiple(fsb);
+
+ if (fsb->fsb.currently_selected_size == 0.0) {
+ sprintf(buf, "%g", fsb->fsb.font_size);
+ } else sprintf(buf, "%g", fsb->fsb.currently_selected_size);
+
+ changingSize = True;
+ XtVaSetValues(fsb->fsb.size_text_field_child, XmNvalue, buf, NULL);
+ changingSize = False;
+}
+
+static void SetUpCurrentSelections(FontSelectionBoxWidget fsb)
+{
+ SetUpCurrentFont(fsb);
+ SetUpCurrentSize(fsb);
+ if (fsb->fsb.preview_on_change) DoPreview(fsb, False);
+ DoValueChangedCallback(fsb);
+}
+
+/* ARGSUSED */
+
+static void Initialize(
+ Widget request, Widget new,
+ ArgList args,
+ Cardinal *num_args)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) new;
+ Bool inited;
+ char version[20];
+
+ /* Verify size list */
+
+ if (fsb->fsb.size_count > 0 && fsb->fsb.sizes == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "initializeFontBox", "sizeMismatch",
+ "FontSelectionBoxError",
+ "Size count specified but no sizes present",
+ (String *) NULL, (Cardinal *) NULL);
+ fsb->fsb.size_count = 0;
+ }
+
+ if (fsb->fsb.size_count < 0) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "initializeFontBox", "negativeSize",
+ "FontSelectionBoxError",
+ "Size count should not be negative",
+ (String *) NULL, (Cardinal *) NULL);
+ fsb->fsb.size_count = 0;
+ }
+
+ if (fsb->fsb.max_pending_deletes <= 0) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "initializeFontBox", "nonPositivePendingDelete",
+ "FontSelectionBoxError",
+ "Pending delete max must be positive",
+ (String *) NULL, (Cardinal *) NULL);
+ fsb->fsb.max_pending_deletes = 1;
+ }
+
+ /* Copy strings. SetUpCurrentSelection will copy the font strings */
+
+ if (fsb->fsb.preview_string != NULL) {
+ fsb->fsb.preview_string = XtNewString(fsb->fsb.preview_string);
+ }
+ if (fsb->fsb.default_resource_path != NULL) {
+ fsb->fsb.default_resource_path =
+ XtNewString(fsb->fsb.default_resource_path);
+ }
+ if (fsb->fsb.resource_path_override != NULL) {
+ fsb->fsb.resource_path_override =
+ XtNewString(fsb->fsb.resource_path_override);
+ }
+
+ /* Get the context */
+
+ if (fsb->fsb.context == NULL) {
+ fsb->fsb.context = XDPSGetSharedContext(XtDisplay(fsb));
+ }
+
+ if (_XDPSTestComponentInitialized(fsb->fsb.context,
+ dps_init_bit_fsb, &inited) ==
+ dps_status_unregistered_context) {
+ XDPSRegisterContext(fsb->fsb.context, False);
+ }
+
+ if (!inited) {
+ (void) _XDPSSetComponentInitialized(fsb->fsb.context,
+ dps_init_bit_fsb);
+ _DPSFDefineFontEnumFunctions(fsb->fsb.context);
+ }
+
+ DPSversion(fsb->fsb.context, 20, version);
+ fsb->fsb.old_server = (atof(version) < 1007);
+
+ /* Initialize non-resource fields */
+
+ fsb->fsb.gstate = 0;
+ fsb->fsb.sampler = fsb->fsb.creator = NULL;
+ fsb->fsb.known_families = NULL;
+ fsb->fsb.family_count = 0;
+ fsb->fsb.currently_previewed = NULL;
+ fsb->fsb.currently_selected_face = NULL;
+ fsb->fsb.currently_selected_family = NULL;
+ fsb->fsb.currently_previewed_blend = NULL;
+ fsb->fsb.currently_selected_blend = NULL;
+ fsb->fsb.currently_previewed_size = 0.0;
+ fsb->fsb.currently_selected_size = 0.0;
+ fsb->fsb.pending_delete_count = 0;
+ fsb->fsb.pending_delete_font = NULL;
+ fsb->fsb.preview_fixed = False;
+ fsb->fsb.current_family_multiple = False;
+ fsb->fsb.current_face_multiple = False;
+ fsb->fsb.current_size_multiple = False;
+ fsb->fsb.blends_changed = False;
+
+ GetFontNames(fsb);
+ CreateChildren(fsb);
+
+ DisplayFontFamilies(fsb);
+ SetUpCurrentSelections(fsb);
+ DesensitizeReset(fsb);
+ if (fsb->fsb.show_sampler) ShowSampler(fsb);
+}
+
+static void FreeFontRec(FontRec *f)
+{
+ BlendDataRec *bd;
+ BlendRec *b, *next_b;
+
+ if (f->blend_data != NULL) {
+ bd = f->blend_data;
+ for (b = bd->blends; b != NULL; b = next_b) {
+ next_b = b->next;
+ XtFree((char *) b);
+ }
+ XtFree((char *) bd->internal_break);
+ XtFree((char *) bd->internal_value);
+ XtFree((char *) bd->design_positions);
+ XtFree((char *) bd);
+ }
+ XtFree(f->full_name);
+}
+
+static void FreeFontLists(
+ FontSelectionBoxWidget fsb)
+{
+ FontFamilyRec *ff, *next_ff;
+ FontRec *f, *next_f;
+
+ /* font_name, face_name, family_name, and blend_name are canonical
+ strings and so should not be freed. The face and blend compound
+ strings were gotten from converters and so should likewise remain. */
+
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = next_ff) {
+ for (f = ff->fonts; f != NULL; f = next_f) {
+ FreeFontRec(f);
+ next_f = f->next;
+ XtFree((char *) f);
+ }
+ next_ff = ff->next;
+ XtFree((char *) ff);
+ }
+ fsb->fsb.known_families = NULL;
+}
+
+static void Destroy(Widget widget)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) widget;
+
+ /* Lots of stuff to destroy! */
+
+ if (fsb->fsb.gstate != 0) XDPSFreeContextGState(fsb->fsb.context,
+ fsb->fsb.gstate);
+ if (fsb->fsb.preview_string != NULL) XtFree(fsb->fsb.preview_string);
+ if (fsb->fsb.default_resource_path != NULL) {
+ XtFree(fsb->fsb.default_resource_path);
+ }
+ if (fsb->fsb.resource_path_override != NULL) {
+ XtFree(fsb->fsb.resource_path_override);
+ }
+
+ FreeFontLists(fsb);
+}
+
+static void Resize(Widget widget)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) widget;
+
+ XtResizeWidget(fsb->fsb.pane_child, fsb->core.width, fsb->core.height, 0);
+}
+
+/* ARGSUSED */
+
+static Boolean SetValues(
+ Widget old, Widget req, Widget new,
+ ArgList args,
+ Cardinal *num_args)
+{
+ FontSelectionBoxWidget oldfsb = (FontSelectionBoxWidget) old;
+ FontSelectionBoxWidget newfsb = (FontSelectionBoxWidget) new;
+ Boolean refreshLists = False, setSelection = False, do_preview = False;
+ Bool inited;
+
+#define NE(field) newfsb->fsb.field != oldfsb->fsb.field
+#define DONT_CHANGE(field) \
+ if (NE(field)) newfsb->fsb.field = oldfsb->fsb.field;
+
+ DONT_CHANGE(typographic_sort);
+ DONT_CHANGE(pane_child);
+ DONT_CHANGE(preview_child);
+ DONT_CHANGE(panel_child);
+ DONT_CHANGE(family_label_child);
+ DONT_CHANGE(family_multiple_label_child);
+ DONT_CHANGE(family_scrolled_list_child);
+ DONT_CHANGE(face_label_child);
+ DONT_CHANGE(face_multiple_label_child);
+ DONT_CHANGE(face_scrolled_list_child);
+ DONT_CHANGE(size_label_child);
+ DONT_CHANGE(size_text_field_child);
+ DONT_CHANGE(size_option_menu_child);
+ DONT_CHANGE(preview_button_child);
+ DONT_CHANGE(sampler_button_child);
+ DONT_CHANGE(separator_child);
+ DONT_CHANGE(ok_button_child);
+ DONT_CHANGE(apply_button_child);
+ DONT_CHANGE(reset_button_child);
+ DONT_CHANGE(cancel_button_child);
+#undef DONT_CHANGE
+
+ if (newfsb->fsb.size_count > 0 && newfsb->fsb.sizes == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "setValuesFontBox", "sizeMismatch",
+ "FontSelectionBoxError",
+ "Size count specified but no sizes present",
+ (String *) NULL, (Cardinal *) NULL);
+ newfsb->fsb.size_count = 0;
+ }
+
+ if (newfsb->fsb.size_count < 0) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "setValuesFontBox", "negativeSize",
+ "FontSelectionBoxError",
+ "Size count should not be negative",
+ (String *) NULL, (Cardinal *) NULL);
+ newfsb->fsb.size_count = 0;
+ }
+
+ if (newfsb->fsb.max_pending_deletes <= 0) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "setValuesFontBox", "nonPositivePendingDelete",
+ "FontSelectionBoxError",
+ "Pending delete max must be positive",
+ (String *) NULL, (Cardinal *) NULL);
+ newfsb->fsb.max_pending_deletes = 1;
+ }
+
+ if (NE(preview_string)) {
+ XtFree(oldfsb->fsb.preview_string);
+ newfsb->fsb.preview_string = XtNewString(newfsb->fsb.preview_string);
+ do_preview = True;
+ }
+
+ if (NE(default_resource_path)) {
+ XtFree(oldfsb->fsb.default_resource_path);
+ newfsb->fsb.default_resource_path =
+ XtNewString(newfsb->fsb.default_resource_path);
+ refreshLists = True;
+ }
+
+ if (NE(resource_path_override)) {
+ XtFree(oldfsb->fsb.resource_path_override);
+ newfsb->fsb.resource_path_override =
+ XtNewString(newfsb->fsb.resource_path_override);
+ refreshLists = True;
+ }
+
+ if (newfsb->fsb.undef_unused_fonts) UndefSomeUnusedFonts(newfsb, False);
+
+ if (NE(context)) {
+ if (newfsb->fsb.context == NULL) {
+ newfsb->fsb.context = XDPSGetSharedContext(XtDisplay(newfsb));
+ }
+ if (_XDPSTestComponentInitialized(newfsb->fsb.context,
+ dps_init_bit_fsb, &inited) ==
+ dps_status_unregistered_context) {
+ XDPSRegisterContext(newfsb->fsb.context, False);
+ }
+ if (!inited) {
+ (void) _XDPSSetComponentInitialized(newfsb->fsb.context,
+ dps_init_bit_fsb);
+ _DPSFDefineFontEnumFunctions(newfsb->fsb.context);
+ }
+ }
+
+ if (refreshLists) {
+ UndefUnusedFonts((Widget)newfsb);
+ newfsb->fsb.pending_delete_font = NULL;
+ newfsb->fsb.pending_delete_count = 0;
+ FreeFontLists(newfsb);
+ GetFontNames(newfsb);
+ DisplayFontFamilies(newfsb);
+ setSelection = True;
+ }
+
+ if (NE(sizes)) {
+ CreateSizeMenu(newfsb, True);
+ setSelection = True;
+ }
+
+ if (NE(show_sampler)) {
+ if (newfsb->fsb.show_sampler) ShowSampler(newfsb);
+ else XtPopdown(newfsb->fsb.sampler);
+ }
+
+ if (NE(show_sampler_button)) {
+ if (newfsb->fsb.show_sampler_button) {
+ XtManageChild(newfsb->fsb.sampler_button_child);
+ } else XtUnmanageChild(newfsb->fsb.sampler_button_child);
+ }
+
+ if (NE(font_size)) newfsb->fsb.currently_selected_size = 0.0;
+
+ if (NE(use_font_name) || NE(font_name) || NE(font_family) ||
+ NE(font_face) || NE(font_size) || NE(font_name_multiple) ||
+ NE(font_family_multiple) || NE(font_face_multiple) ||
+ NE(font_size_multiple) || NE(font_blend)) setSelection = True;
+
+ if (setSelection) SetUpCurrentSelections(newfsb);
+ else if (do_preview && newfsb->fsb.preview_on_change) {
+ DoPreview(newfsb, False);
+ }
+
+ if ((NE(font_name) || NE(font_size)) &&
+ XtIsSensitive(newfsb->fsb.reset_button_child)) {
+
+ if ((newfsb->fsb.font_size_multiple ||
+ newfsb->fsb.font_size == newfsb->fsb.currently_selected_size) &&
+ (newfsb->fsb.font_name_multiple ||
+ newfsb->fsb.currently_selected_face == NULL ||
+ newfsb->fsb.font_name ==
+ newfsb->fsb.currently_selected_face->font_name)) {
+ DesensitizeReset(newfsb);
+ }
+ }
+
+ return False;
+#undef NE
+}
+
+/* ARGSUSED */
+
+static XtGeometryResult GeometryManager(
+ Widget w,
+ XtWidgetGeometry *desired, XtWidgetGeometry *allowed)
+{
+#define WANTS(flag) (desired->request_mode & flag)
+
+ if (WANTS(XtCWQueryOnly)) return XtGeometryYes;
+
+ if (WANTS(CWWidth)) w->core.width = desired->width;
+ if (WANTS(CWHeight)) w->core.height = desired->height;
+ if (WANTS(CWX)) w->core.x = desired->x;
+ if (WANTS(CWY)) w->core.y = desired->y;
+ if (WANTS(CWBorderWidth)) {
+ w->core.border_width = desired->border_width;
+ }
+
+ return XtGeometryYes;
+#undef WANTS
+}
+
+static void ChangeManaged(Widget w)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+
+ w->core.width = fsb->composite.children[0]->core.width;
+ w->core.height = fsb->composite.children[0]->core.height;
+}
+
+static void SetFontName(
+ Widget w,
+ String name,
+ Bool name_multiple)
+{
+ XtVaSetValues(w, XtNfontName, name, XtNuseFontName, True,
+ XtNfontNameMultiple, name_multiple, NULL);
+}
+
+void FSBSetFontName(
+ Widget w,
+ String name,
+ Bool name_multiple)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass) XtClass(w))->fsb_class.set_font_name)
+ (w, name, name_multiple);
+}
+
+static void SetFontFamilyFace(
+ Widget w,
+ String family, String face,
+ Bool family_multiple, Bool face_multiple)
+{
+ XtVaSetValues(w, XtNfontFamily, family, XtNfontFace, face,
+ XtNuseFontName, False,
+ XtNfontFamilyMultiple, family_multiple,
+ XtNfontFaceMultiple, face_multiple, NULL);
+}
+
+void FSBSetFontFamilyFace(
+ Widget w,
+ String family, String face,
+ Bool family_multiple, Bool face_multiple)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass)
+ XtClass(w))->fsb_class.set_font_family_face)
+ (w, family, face, family_multiple, face_multiple);
+}
+
+static void SetFontSize(
+ Widget w,
+ double size,
+ Bool size_multiple)
+{
+ int i;
+ Arg args[2];
+
+ union {
+ int i;
+ float f;
+ } kludge;
+
+ kludge.f = size;
+
+ i = 0;
+ if (sizeof(float) > sizeof(XtArgVal)) {
+ XtSetArg(args[i], XtNfontSize, &kludge.f); i++;
+ } else XtSetArg(args[i], XtNfontSize, kludge.i); i++;
+ XtSetArg(args[i], XtNfontSizeMultiple, size_multiple); i++;
+ XtSetValues(w, args, i);
+}
+
+void FSBSetFontSize(
+ Widget w,
+ double size,
+ Bool size_multiple)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass) XtClass(w))->fsb_class.set_font_size)
+ (w, size, size_multiple);
+}
+
+static void RefreshFontList(Widget w)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+
+ UndefUnusedFonts((Widget)fsb);
+ fsb->fsb.pending_delete_font = NULL;
+ fsb->fsb.pending_delete_count = 0;
+ FreeFontLists(fsb);
+ FreePSResourceStorage(True);
+ GetFontNames(fsb);
+ DisplayFontFamilies(fsb);
+ SetUpCurrentSelections(fsb);
+}
+
+void FSBRefreshFontList(
+ Widget w)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass)
+ XtClass(w))->fsb_class.refresh_font_list) (w);
+}
+
+static void GetFamilyList(
+ Widget w,
+ int *count,
+ String **list)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+ String *buf;
+ FontFamilyRec *ff;
+
+ *count = fsb->fsb.family_count;
+ *list = buf = (String *) XtMalloc(*count * sizeof(String));
+
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ *buf++ = ff->family_name;
+ }
+}
+
+void FSBGetFamilyList(
+ Widget w,
+ int *count,
+ String **list)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass)
+ XtClass(w))->fsb_class.get_family_list) (w, count, list);
+}
+
+static void GetFaceList(
+ Widget w,
+ String family,
+ int *count,
+ String **face_list, String **font_list)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+ String *buf1, *buf2;
+ FontFamilyRec *ff;
+ FontRec *f;
+
+ family = Canonical(family);
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ if (ff->family_name == family) break;
+ }
+
+ if (ff == NULL) {
+ *count = 0;
+ *face_list = *font_list = NULL;
+ return;
+ }
+
+ *count = ff->font_count;
+ *face_list = buf1 = (String *) XtMalloc(*count * sizeof(String));
+ *font_list = buf2 = (String *) XtMalloc(*count * sizeof(String));
+
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ *buf1++ = f->face_name;
+ *buf2++ = f->font_name;
+ }
+}
+
+void FSBGetFaceList(
+ Widget w,
+ String family,
+ int *count_return,
+ String **face_list, String **font_list)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass)
+ XtClass(w))->fsb_class.get_face_list) (w, family, count_return,
+ face_list, font_list);
+}
+
+void FSBUndefineUnusedFonts(
+ Widget w)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass)
+ XtClass(w))->fsb_class.undef_unused_fonts) (w);
+}
+
+static Boolean DownloadFontName(Widget w, String name)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+ FontFamilyRec *ff;
+ FontRec *f;
+ Boolean ret;
+
+ name = Canonical(name);
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ if (f->font_name == name) {
+ if (!fsb->fsb.get_server_fonts) {
+ int resident;
+ _DPSFIsFontResident(fsb->fsb.context, f->font_name,
+ &resident);
+ if (resident) f->resident = True;
+ }
+ if (f->resident) return True;
+ else {
+ ret = DownloadFont(fsb, name, fsb->fsb.context,
+ fsb->fsb.make_fonts_shared);
+ if (fsb->fsb.make_fonts_shared && ret) f->resident = True;
+ return ret;
+ }
+ }
+ }
+ }
+
+ return DownloadFont(fsb, name, fsb->fsb.context,
+ fsb->fsb.make_fonts_shared);
+}
+
+Boolean FSBDownloadFontName(
+ Widget w,
+ String name)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ if (name == NULL) return False;
+ return (*((FontSelectionBoxWidgetClass)
+ XtClass(w))->fsb_class.download_font_name) (w, name);
+}
+
+static Boolean MatchFontFace(
+ Widget w,
+ String old_face, String new_family,
+ String *new_face)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+ FSBFaceSelectCallbackRec rec;
+ String *faces;
+ int i;
+ FontFamilyRec *ff;
+ FontRec *f;
+ Boolean retVal;
+
+ new_family = Canonical(new_family);
+ old_face = Canonical(old_face);
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ if (ff->family_name == new_family) break;
+ }
+ if (ff == NULL) {
+ *new_face = NULL;
+ return False;
+ }
+
+ faces = (String *) XtMalloc(ff->font_count * sizeof(String));
+ i = 0;
+ for (f = ff->fonts; f != NULL; f = f->next) faces[i++] = f->face_name;
+
+ rec.available_faces = faces;
+ rec.num_available_faces = ff->font_count;
+ rec.current_face = old_face;
+ rec.new_face = NULL;
+
+ i = MatchFaceName(&rec, &retVal);
+ *new_face = faces[i];
+ XtFree((XtPointer) faces);
+ return !retVal;
+}
+
+Boolean FSBMatchFontFace(
+ Widget w,
+ String old_face, String new_family,
+ String *new_face)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ return (*((FontSelectionBoxWidgetClass)
+ XtClass(w))->fsb_class.match_font_face) (w, old_face,
+ new_family, new_face);
+}
+
+static void FontNameToFamilyFaceBlend(
+ Widget w,
+ String font_name,
+ String *family, String *face, String *blend)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+ FontFamilyRec *ff;
+ FontRec *f;
+ BlendRec *b;
+
+ font_name = Canonical(font_name);
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ if (f->font_name == font_name) {
+ *family = ff->family_name;
+ *face = f->face_name;
+ *blend = NULL;
+ return;
+ }
+ if (f->blend_data != NULL) {
+ for (b = f->blend_data->blends; b != NULL; b = b->next) {
+ if (b->font_name == font_name) {
+ *family = ff->family_name;
+ *face = f->face_name;
+ *blend = b->blend_name;
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ *family = NULL;
+ *face = NULL;
+ *blend = NULL;
+}
+
+static void FontNameToFamilyFace(
+ Widget w,
+ String font_name,
+ String *family, String *face)
+{
+ String blend;
+
+ FontNameToFamilyFaceBlend(w, font_name, family, face, &blend);
+}
+
+void FSBFontNameToFamilyFace(
+ Widget w,
+ String font_name,
+ String *family, String *face)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass)
+ XtClass(w))->fsb_class.font_name_to_family_face) (w, font_name,
+ family, face);
+}
+
+static void FontFamilyFaceBlendToName(
+ Widget w,
+ String family, String face, String blend,
+ String *font_name)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+ FontFamilyRec *ff;
+ FontRec *f;
+ BlendRec *b;
+
+ family = Canonical(family);
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ if (ff->family_name == family) break;
+ }
+ if (ff == NULL) {
+ *font_name = NULL;
+ return;
+ }
+
+ face = Canonical(face);
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ if (f->face_name == face) break;
+ }
+ if (f == NULL) {
+ *font_name = NULL;
+ return;
+ }
+
+ if (blend == NULL) {
+ *font_name = f->font_name;
+ return;
+ }
+ if (f->blend_data == NULL) {
+ *font_name = NULL;
+ return;
+ }
+
+ blend = Canonical(blend);
+ for (b = f->blend_data->blends; b != NULL; b = b->next) {
+ if (b->blend_name == blend) {
+ *font_name = b->font_name;
+ return;
+ }
+ }
+ *font_name = NULL;
+}
+
+static void FontFamilyFaceToName(
+ Widget w,
+ String family, String face,
+ String *font_name)
+{
+ FontFamilyFaceBlendToName(w, family, face, NULL, font_name);
+}
+
+void FSBFontFamilyFaceToName(
+ Widget w,
+ String family, String face,
+ String *font_name)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass)
+ XtClass(w))->fsb_class.font_family_face_to_name) (w, family, face,
+ font_name);
+}
+
+String FSBFindAFM(
+ Widget w,
+ String font_name)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ return (*((FontSelectionBoxWidgetClass) XtClass(w))->
+ fsb_class.find_afm) (w, font_name);
+}
+
+String FSBFindFontFile(
+ Widget w,
+ String font_name)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ return (*((FontSelectionBoxWidgetClass) XtClass(w))->
+ fsb_class.find_font_file) (w, font_name);
+}
+
+static void GetTextDimensions(
+ Widget w,
+ String text, String font,
+ double size, double x, double y,
+ float *dx, float *dy, float *left, float *right, float *top, float *bottom)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+ int bogusFont;
+
+ _DPSFGetTextDimensions(fsb->fsb.context, text, font, size, x, y,
+ dx, dy, left, right, top, bottom, &bogusFont);
+}
+
+void FSBGetTextDimensions(
+ Widget w,
+ String text, String font,
+ double size, double x, double y,
+ float *dx, float *dy, float *left, float *right, float *top, float *bottom)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass) XtClass(w))->
+ fsb_class.get_text_dimensions) (w, text, font, size, x, y,
+ dx, dy, left, right, top, bottom);
+}
+
+static void SetFontFamilyFaceBlend(
+ Widget w,
+ String family,
+ String face,
+ String blend,
+ Bool family_multiple,
+ Bool face_multiple)
+{
+ XtVaSetValues(w, XtNfontFamily, family, XtNfontFace, face,
+ XtNfontBlend, blend, XtNuseFontName, False,
+ XtNfontFamilyMultiple, family_multiple,
+ XtNfontFaceMultiple, face_multiple, NULL);
+}
+
+void FSBSetFontFamilyFaceBlend(
+ Widget w,
+ String font_family,
+ String font_face,
+ String font_blend,
+ Bool font_family_multiple,
+ Bool font_face_multiple)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass) XtClass(w))->
+ fsb_class.set_font_family_face_blend) (w, font_family, font_face,
+ font_blend,
+ font_family_multiple,
+ font_face_multiple);
+}
+
+void FSBFontNameToFamilyFaceBlend(
+ Widget w,
+ String font_name,
+ String *family,
+ String *face,
+ String *blend)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass) XtClass(w))->
+ fsb_class.font_name_to_family_face_blend) (w, font_name, family,
+ face, blend);
+}
+
+void FSBFontFamilyFaceBlendToName(
+ Widget w,
+ String family,
+ String face,
+ String blend,
+ String *font_name)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass) XtClass(w))->
+ fsb_class.font_family_face_blend_to_name) (w, family, face,
+ blend, font_name);
+}
+
+static void GetBlendList(
+ Widget w,
+ String name,
+ int *count_return,
+ String **blend_return,
+ String **font_name_return,
+ float **axis_values_return)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+ String *buf1, *buf2;
+ float *buf3;
+ FontFamilyRec *ff;
+ FontRec *f;
+ BlendRec *b;
+ int i;
+
+ name = Canonical(name);
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ if (f->font_name == name) break;
+ }
+ }
+
+ if (ff == NULL || f == NULL || f->blend_data == NULL) {
+ *count_return = 0;
+ *blend_return = *font_name_return = NULL;
+ *axis_values_return = NULL;
+ return;
+ }
+
+ *count_return = f->blend_count;
+ *blend_return = buf1 = (String *) XtMalloc(*count_return * sizeof(String));
+ *font_name_return = buf2 =
+ (String *) XtMalloc(*count_return * sizeof(String));
+ *axis_values_return = buf3 =
+ (float *) XtMalloc(*count_return * MAX_AXES * sizeof(float));
+
+
+ for (b = f->blend_data->blends; b != NULL; b = b->next) {
+ *buf1++ = b->blend_name;
+ *buf2++ = b->font_name;
+ for (i = 0; i < MAX_AXES; i++) *buf3++ = b->data[i];
+ }
+}
+
+void FSBGetBlendList(
+ Widget w,
+ String name,
+ int *count_return,
+ String **blend_return,
+ String **font_name_return,
+ float **axis_values_return)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass) XtClass(w))->
+ fsb_class.get_blend_list) (w, name, count_return, blend_return,
+ font_name_return, axis_values_return);
+}
+
+static void GetBlendInfo(
+ Widget w,
+ String name,
+ int *num_axes_return,
+ int *num_designs_return,
+ String **axis_names_return,
+ float **blend_positions_return,
+ int **blend_map_count_return,
+ int **blend_design_coords_return,
+ float **blend_normalized_coords_return)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+ FontFamilyRec *ff;
+ FontRec *f;
+ BlendDataRec *bd;
+ int i, j;
+ float *fbuf;
+ int *ibuf;
+ String *sbuf;
+ int coords;
+
+ name = Canonical(name);
+ if (fsb->fsb.currently_selected_face->font_name == name) {
+ bd = fsb->fsb.currently_selected_face->blend_data;
+ } else {
+
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ if (f->font_name == name) goto FOUND_IT;
+ }
+ }
+ *num_axes_return = *num_designs_return = 0;
+ *axis_names_return = NULL;
+ *blend_positions_return = *blend_normalized_coords_return = NULL;
+ *blend_map_count_return = *blend_design_coords_return = NULL;
+ return;
+
+FOUND_IT:
+ bd = f->blend_data;
+ }
+
+ *num_axes_return = bd->num_axes;
+ *num_designs_return = bd->num_designs;
+
+ *axis_names_return = sbuf =
+ (String *) XtMalloc(bd->num_axes * sizeof(String));
+ *blend_map_count_return = ibuf =
+ (int *) XtMalloc(bd->num_axes * sizeof(int));
+ coords = 0;
+ for (i = 0; i < bd->num_axes; i++) {
+ *sbuf++ = bd->name[i];
+ *ibuf++ = bd->internal_points[i] + 2;
+ coords += bd->internal_points[i] + 2;
+ }
+
+ *blend_positions_return = fbuf =
+ (float *) XtMalloc(bd->num_axes * bd->num_designs * sizeof(float));
+ for (i = 0; i < bd->num_axes * bd->num_designs; i++) {
+ *fbuf++ = bd->design_positions[i];
+ }
+
+ *blend_design_coords_return = ibuf =
+ (int *) XtMalloc(coords * sizeof(int));
+ *blend_normalized_coords_return = fbuf =
+ (float *) XtMalloc(coords * sizeof(float));
+
+ for (i = 0; i < bd->num_axes; i++) {
+ *ibuf++ = bd->min[i];
+ *fbuf++ = 0.0;
+ for (j = 0; j < bd->internal_points[i]; j++) {
+ *ibuf++ = bd->internal_break[i][j];
+ *fbuf++ = bd->internal_value[i][j];
+ }
+ *ibuf++ = bd->max[i];
+ *fbuf++ = 1.0;
+ }
+}
+
+void FSBGetBlendInfo(
+ Widget w,
+ String name,
+ int *num_axes_return,
+ int *num_designs_return,
+ String **axis_names_return,
+ float **blend_positions_return,
+ int **blend_map_count_return,
+ int **blend_design_coords_return,
+ float **blend_normalized_coords_return)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ (*((FontSelectionBoxWidgetClass) XtClass(w))->
+ fsb_class.get_blend_info) (w, name, num_axes_return,
+ num_designs_return, axis_names_return,
+ blend_positions_return,
+ blend_map_count_return,
+ blend_design_coords_return,
+ blend_normalized_coords_return);
+}
+
+static Boolean ChangeBlends(
+ Widget w,
+ String base_name,
+ String blend_name,
+ FSBBlendAction action,
+ int *axis_values,
+ float *axis_percents)
+{
+ FontSelectionBoxWidget fsb = (FontSelectionBoxWidget) w;
+ FontFamilyRec *ff;
+ FontRec *f;
+ BlendRec *b = NULL, *newb, **lastb;
+ BlendDataRec *bd;
+ String spaceBlend;
+ int val[4];
+ float pct[4];
+ int i;
+
+ base_name = Canonical(base_name);
+ blend_name = Canonical(blend_name);
+
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ if (f->font_name == base_name) {
+ if ((bd = f->blend_data) == NULL) return False;
+
+ for (b = f->blend_data->blends; b != NULL; b = b->next) {
+ if (b->blend_name == blend_name) break;
+ }
+ goto FOUND_BASE;
+ }
+ }
+ }
+ return False;
+
+FOUND_BASE:
+ if (action != FSBDeleteBlend) {
+ if (axis_values != NULL) {
+ for (i = 0; i < bd->num_axes; i++) {
+ val[i] = axis_values[i];
+ pct[i] = _FSBNormalize(val[i], bd, i);
+ }
+ for (/**/; i < 4; i++) pct[i] = 0.0;
+ } else {
+ if (axis_percents == NULL) return False;
+ for (i = 0; i < bd->num_axes; i++) {
+ pct[i] = axis_percents[i];
+ val[i] = _FSBUnnormalize(pct[i], bd, i);
+ }
+ for (/**/; i < 4; i++) pct[i] = 0.0;
+ }
+ }
+
+ switch (action) {
+ case FSBAddBlend:
+ if (b != NULL) return False;
+ newb = XtNew(BlendRec);
+ newb->blend_name = blend_name;
+ newb->CS_blend_name = CS(blend_name, (Widget) fsb);
+
+ spaceBlend = (char *) XtMalloc(strlen(blend_name) + 4);
+ spaceBlend[0] = spaceBlend[1] = spaceBlend[2] = ' ';
+ strcpy(spaceBlend+3, blend_name);
+ newb->CS_space_blend_name = CS(spaceBlend, (Widget) fsb);
+ XtFree((XtPointer) spaceBlend);
+
+ for (i = 0; i < MAX_AXES; i++) newb->data[i] = pct[i];
+ newb->font_name = _FSBGenFontName(base_name, val, bd);
+
+ f->blend_count++;
+ ff->blend_count++;
+
+ lastb = &bd->blends;
+ for (b = bd->blends; b != NULL; b = b->next) {
+ if (strcmp(blend_name, b->blend_name) < 0) break;
+ lastb = &b->next;
+ }
+
+ newb->next = b;
+ *lastb = newb;
+ break;
+
+ case FSBReplaceBlend:
+ if (b == NULL) return False;
+
+ for (i = 0; i < MAX_AXES; i++) b->data[i] = pct[i];
+ b->font_name = _FSBGenFontName(base_name, val, bd);
+ if (b == fsb->fsb.currently_previewed_blend) DoPreview(fsb, False);
+
+ break;
+
+ case FSBDeleteBlend:
+ if (b == NULL) return False;
+
+ if (bd->blends == b) {
+ bd->blends = b->next;
+ } else {
+ for (newb = bd->blends; newb->next != b; newb = newb->next) {}
+ newb->next = b->next;
+ }
+
+ f->blend_count--;
+ ff->blend_count--;
+
+ /* Don't actually delete the blend record, in case it's displayed
+ in the sampler. */
+ break;
+ }
+ if (f->in_font_creator) _FSBSetCreatorFamily(fsb->fsb.creator, ff);
+ if (ff == fsb->fsb.currently_selected_family) SetUpFaceList(fsb, ff);
+ fsb->fsb.blends_changed = True;
+ WriteBlends(fsb);
+ return True;
+}
+
+Boolean FSBChangeBlends(
+ Widget w,
+ String base_name,
+ String blend_name,
+ FSBBlendAction action,
+ int *axis_values,
+ float *axis_percents)
+{
+ XtCheckSubclass(w, fontSelectionBoxWidgetClass, NULL);
+
+ return (*((FontSelectionBoxWidgetClass) XtClass(w))->
+ fsb_class.change_blends) (w, base_name, blend_name, action,
+ axis_values, axis_percents);
+}
+
+void _FSBSetCurrentFont(
+ FontSelectionBoxWidget fsb,
+ String name)
+{
+ FontFamilyRec *ff;
+ FontRec *f;
+ BlendRec *b;
+ int i, j;
+
+ fsb->fsb.current_family_multiple = False;
+ fsb->fsb.current_face_multiple = False;
+ UnmanageFamilyMultiple(fsb);
+ UnmanageFaceMultiple(fsb);
+
+ name = Canonical(name);
+ i = 1;
+ for (ff = fsb->fsb.known_families; ff != NULL; ff = ff->next) {
+ j = 1;
+ for (f = ff->fonts; f != NULL; f = f->next) {
+ if (f->font_name == name) {
+ b = NULL;
+ goto FOUND_NAME;
+ }
+ j++;
+ if (f->blend_data != NULL && f->blend_data->blends != NULL) {
+ for (b = f->blend_data->blends; b != NULL; b = b->next) {
+ if (b->font_name == name) {
+ goto FOUND_NAME;
+ }
+ j++;
+ }
+ }
+
+ }
+ i++;
+ }
+ return;
+FOUND_NAME:
+ SetUpFaceList(fsb, ff);
+ ListSelectPos(fsb->fsb.family_scrolled_list_child, i, False);
+ ListSelectPos(fsb->fsb.face_scrolled_list_child, j, False);
+ fsb->fsb.currently_selected_face = f;
+ fsb->fsb.currently_selected_family = ff;
+ fsb->fsb.currently_selected_blend = b;
+ SensitizeReset(fsb);
+ DoPreview(fsb, False);
+}
+
+float _FSBNormalize(
+ int val,
+ BlendDataRec *bd,
+ int i)
+{
+ int j;
+ int lessBreak, moreBreak;
+ float lessValue, moreValue;
+
+ if (bd->internal_points[i] == 0) {
+ return ((float) (val - bd->min[i])) /
+ ((float) (bd->max[i] - bd->min[i]));
+ }
+
+ /* Find the largest breakpoint less than val and the smallest one greater
+ than it */
+
+ lessBreak = bd->min[i];
+ lessValue = 0.0;
+ moreBreak = bd->max[i];
+ moreValue = 1.0;
+
+ for (j = 0; j < bd->internal_points[i]; j++) {
+ if (bd->internal_break[i][j] > lessBreak &&
+ bd->internal_break[i][j] <= val) {
+ lessBreak = bd->internal_break[i][j];
+ lessValue = bd->internal_value[i][j];
+ }
+ if (bd->internal_break[i][j] < moreBreak &&
+ bd->internal_break[i][j] >= val) {
+ moreBreak = bd->internal_break[i][j];
+ moreValue = bd->internal_value[i][j];
+ }
+ }
+
+ if (moreBreak == lessBreak) return moreValue;
+
+ return lessValue + (moreValue - lessValue) *
+ ((float) (val - lessBreak)) / ((float) (moreBreak - lessBreak));
+}
+
+int _FSBUnnormalize(val, bd, i)
+ float val;
+ BlendDataRec *bd;
+ int i;
+{
+ int j;
+ int lessBreak, moreBreak;
+ float lessValue, moreValue;
+
+ if (bd->internal_points[i] == 0) {
+ return val * (bd->max[i] - bd->min[i]) + bd->min[i] + 0.5;
+ }
+
+ /* Find the largest breakpoint less than val and the smallest one greater
+ than it */
+
+ lessBreak = bd->min[i];
+ lessValue = 0.0;
+ moreBreak = bd->max[i];
+ moreValue = 1.0;
+
+ for (j = 0; j < bd->internal_points[i]; j++) {
+ if (bd->internal_value[i][j] > lessValue &&
+ bd->internal_value[i][j] <= val) {
+ lessBreak = bd->internal_break[i][j];
+ lessValue = bd->internal_value[i][j];
+ }
+ if (bd->internal_value[i][j] < moreBreak &&
+ bd->internal_value[i][j] >= val) {
+ moreBreak = bd->internal_break[i][j];
+ moreValue = bd->internal_value[i][j];
+ }
+ }
+
+ if (moreBreak == lessBreak) return moreBreak;
+
+ return ((float) (val - lessValue)) / ((float) (moreValue - lessValue)) *
+ (moreBreak - lessBreak) + lessBreak + 0.5;
+}
+
+String _FSBGenFontName(
+ String name,
+ int *val,
+ BlendDataRec *bd)
+{
+ char nameBuf[256];
+ int i;
+ char *ch;
+
+ strcpy(nameBuf, name);
+ ch = nameBuf + strlen(nameBuf);
+
+ for (i = 0; i < bd->num_axes; i++) {
+ sprintf(ch, "_%d_%s", val[i], bd->name[i]);
+ ch = ch + strlen(ch);
+ }
+
+ return Canonical(nameBuf);
+}
diff --git a/nx-X11/lib/dpstk/FontSBI.h b/nx-X11/lib/dpstk/FontSBI.h
new file mode 100644
index 000000000..87d59df40
--- /dev/null
+++ b/nx-X11/lib/dpstk/FontSBI.h
@@ -0,0 +1,57 @@
+/*
+ * FontSBI.h
+ *
+ * (c) Copyright 1991-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+#ifndef _FontSelectionBoxI_H
+#define _FontSelectionBoxI_H
+
+extern Widget _FSBCreateFontSampler(FontSelectionBoxWidget fsb);
+extern Boolean _FSBDownloadFontIfNecessary(FontRec *f,
+ FontSelectionBoxWidget fsb);
+extern XmString _FSBCreateSharedCS(String str, Widget w);
+extern void _FSBSetCreatorFamily(Widget w, FontFamilyRec *ff);
+extern void _FSBSetUpFaceList(FontSelectionBoxWidget fsb, Bool redisplay);
+extern void _FSBBogusFont(FontSelectionBoxWidget fsb, FontRec *f);
+extern void _FSBFlushFont(FontSelectionBoxWidget fsb, FontRec *f);
+extern void _FSBSetCurrentFont(FontSelectionBoxWidget fsb, String name);
+extern float _FSBNormalize(int val, BlendDataRec *bd, int i);
+extern int _FSBUnnormalize(double val, BlendDataRec *bd, int i);
+extern String _FSBGenFontName(String name, int *val, BlendDataRec *bd);
+
+#endif /* _FontSelectionBoxI_H */
+/* DON'T ADD ANYTHING AFTER THIS #endif */
diff --git a/nx-X11/lib/dpstk/FontSample.c b/nx-X11/lib/dpstk/FontSample.c
new file mode 100644
index 000000000..9bccdf30d
--- /dev/null
+++ b/nx-X11/lib/dpstk/FontSample.c
@@ -0,0 +1,1814 @@
+/*
+ * FontSample.c
+ *
+ * (c) Copyright 1991-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <X11/Xos.h>
+#include <stdlib.h>
+#include <math.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <Xm/Xm.h>
+
+/* There are no words to describe how I feel about having to do this */
+
+#if XmVersion > 1001
+#include <Xm/ManagerP.h>
+#else
+#include <Xm/XmP.h>
+#endif
+
+#include <Xm/Form.h>
+#include <Xm/List.h>
+#include <Xm/Label.h>
+#include <Xm/LabelG.h>
+#include <Xm/PushB.h>
+#include <Xm/PanedW.h>
+#include <Xm/PushBG.h>
+#include <Xm/SeparatoG.h>
+#include <Xm/TextF.h>
+#include <Xm/RowColumn.h>
+#include <Xm/DrawingA.h>
+#include <Xm/ScrolledW.h>
+#include <Xm/ToggleBG.h>
+#include <Xm/Frame.h>
+#include <Xm/RowColumn.h>
+#include <DPS/dpsXclient.h>
+#include <DPS/dpsops.h>
+#include <DPS/dpsXcommon.h>
+#include <DPS/dpsXshare.h>
+#include <DPS/FontSBP.h>
+#include "FSBwraps.h"
+#include "FontSBI.h"
+#include <DPS/FontSamplP.h>
+
+#if 0
+/* This is not in Xos.h for some reason */
+char *strstr();
+#endif
+
+#undef MAX
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+
+#define UnsharedCS(str) XmStringCreate(str, XmSTRING_DEFAULT_CHARSET)
+
+static float defaultSizeList[] = {
+#ifndef SAMPLER_DEFAULT_SIZE_LIST
+ 8, 10, 12, 14, 16, 18, 24, 36, 48, 72
+#else
+ SAMPLER_DEFAULT_SIZE_LIST
+#endif /* DEFAULT_SIZE_LIST */
+};
+
+#ifndef SAMPLER_DEFAULT_SIZE_LIST_COUNT
+#define SAMPLER_DEFAULT_SIZE_LIST_COUNT 10
+#endif /* DEFAULT_SIZE_LIST_COUNT */
+
+#ifndef SAMPLER_DEFAULT_SIZE
+#define SAMPLER_DEFAULT_SIZE 24.0
+#endif /* SAMPLER_DEFAULT_SIZE */
+
+static Boolean DisplayAllWorkProc(XtPointer client_data);
+static Boolean DisplaySelectedWorkProc(XtPointer client_data);
+static Boolean DisplaySelectedFamilyWorkProc(XtPointer client_data);
+static Boolean DisplayFilteredWorkProc(XtPointer client_data);
+
+#define Offset(field) XtOffsetOf(FontSamplerRec, sampler.field)
+
+static XtResource resources[] = {
+ {XtNsizes, XtCSizes, XtRFloatList, sizeof(float*),
+ Offset(sizes), XtRImmediate, (XtPointer) defaultSizeList},
+ {XtNsizeCount, XtCSizeCount, XtRInt, sizeof(int),
+ Offset(size_count), XtRImmediate,
+ (XtPointer) SAMPLER_DEFAULT_SIZE_LIST_COUNT},
+ {XtNdismissCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
+ Offset(dismiss_callback), XtRCallback, (XtPointer) NULL},
+ {XtNfontSelectionBox, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(fsb), XtRWidget, (XtPointer) NULL},
+ {XtNminimumWidth, XtCMinimumWidth, XtRDimension, sizeof(Dimension),
+ Offset(minimum_width), XtRImmediate, (XtPointer) 100},
+ {XtNminimumHeight, XtCMinimumHeight, XtRDimension, sizeof(Dimension),
+ Offset(minimum_height), XtRImmediate, (XtPointer) 100},
+ {XtNnoRoomMessage, XtCMessage, XmRXmString, sizeof(XmString),
+ Offset(no_room_message), XtRString,
+ "Current size is too large or panel is too small"},
+ {XtNnoFontMessage, XtCMessage, XmRXmString, sizeof(XmString),
+ Offset(no_font_message), XtRString,
+ "There are no fonts!"},
+ {XtNnoSelectedFontMessage, XtCMessage, XmRXmString, sizeof(XmString),
+ Offset(no_selected_font_message), XtRString,
+ "No font is currently selected"},
+ {XtNnoSelectedFamilyMessage, XtCMessage, XmRXmString, sizeof(XmString),
+ Offset(no_selected_family_message), XtRString,
+ "No family is currently selected"},
+ {XtNnoFamilyFontMessage, XtCMessage, XmRXmString, sizeof(XmString),
+ Offset(no_family_font_message), XtRString,
+ "Selected family has no fonts!"},
+ {XtNnoMatchMessage, XtCMessage, XmRXmString, sizeof(XmString),
+ Offset(no_match_message), XtRString,
+ "No fonts match filters"},
+ {XtNpanelChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(panel_child), XtRImmediate, (XtPointer) NULL},
+ {XtNareaChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(area_child), XtRImmediate, (XtPointer) NULL},
+ {XtNtextChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(text_child), XtRImmediate, (XtPointer) NULL},
+ {XtNfontLabelChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(font_label_child), XtRImmediate, (XtPointer) NULL},
+ {XtNscrolledWindowChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(scrolled_window_child), XtRImmediate, (XtPointer) NULL},
+ {XtNdisplayButtonChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(display_button_child), XtRImmediate, (XtPointer) NULL},
+ {XtNdismissButtonChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(dismiss_button_child), XtRImmediate, (XtPointer) NULL},
+ {XtNstopButtonChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(stop_button_child), XtRImmediate, (XtPointer) NULL},
+ {XtNclearButtonChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(clear_button_child), XtRImmediate, (XtPointer) NULL},
+ {XtNradioFrameChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(radio_frame_child), XtRImmediate, (XtPointer) NULL},
+ {XtNradioBoxChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(radio_box_child), XtRImmediate, (XtPointer) NULL},
+ {XtNallToggleChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(all_toggle_child), XtRImmediate, (XtPointer) NULL},
+ {XtNselectedToggleChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(selected_toggle_child), XtRImmediate, (XtPointer) NULL},
+ {XtNselectedFamilyToggleChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(selected_family_toggle_child), XtRImmediate, (XtPointer) NULL},
+ {XtNfilterToggleChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(filter_toggle_child), XtRImmediate, (XtPointer) NULL},
+ {XtNfilterTextChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(filter_text_child), XtRImmediate, (XtPointer) NULL},
+ {XtNfilterBoxChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(filter_box_child), XtRImmediate, (XtPointer) NULL},
+ {XtNfilterFrameChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(filter_frame_child), XtRImmediate, (XtPointer) NULL},
+ {XtNsizeLabelChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(size_label_child), XtRWidget, (XtPointer) NULL},
+ {XtNsizeTextFieldChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(size_text_field_child), XtRWidget, (XtPointer) NULL},
+ {XtNsizeOptionMenuChild, XtCReadOnly, XtRWidget, sizeof(Widget),
+ Offset(size_option_menu_child), XtRWidget, (XtPointer) NULL},
+};
+
+/* Forward declarations */
+
+static Boolean SetValues(Widget old, Widget req, Widget new, ArgList args, Cardinal *num_args);
+static XtGeometryResult GeometryManager(Widget w, XtWidgetGeometry *desired, XtWidgetGeometry *allowed);
+static void Cancel(Widget w);
+static void ChangeManaged(Widget w);
+static void ClassInitialize(void);
+static void ClassPartInitialize(WidgetClass widget_class);
+static void ClickAction(Widget widget, XEvent *event, String *params, Cardinal *num_params);
+static void Destroy(Widget widget);
+static void Initialize(Widget request, Widget new, ArgList args, Cardinal *num_args);
+static void Resize(Widget widget);
+
+static XtActionsRec actions[] = {
+ {"FSBClickAction", ClickAction}
+};
+
+FontSamplerClassRec fontSamplerClassRec = {
+ /* Core class part */
+ {
+ /* superclass */ (WidgetClass) &xmManagerClassRec,
+ /* class_name */ "FontSampler",
+ /* widget_size */ sizeof(FontSamplerRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_initialize */ ClassPartInitialize,
+ /* class_inited */ False,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ True,
+ /* compress_exposure */ XtExposeCompressMultiple,
+ /* compress_enterleave */ True,
+ /* visible_interest */ False,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ NULL,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL,
+ },
+ /* Composite class part */
+ {
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL,
+ },
+ /* Constraint class part */
+ {
+ /* resources */ NULL,
+ /* num_resources */ 0,
+ /* constraint_size */ 0,
+ /* initialize */ NULL,
+ /* destroy */ NULL,
+ /* set_values */ NULL,
+ /* extension */ NULL,
+ },
+ /* Manager class part */
+ {
+ /* translations */ XtInheritTranslations,
+ /* syn_resources */ NULL,
+ /* num_syn_resources */ 0,
+ /* syn_constraint_resources */ NULL,
+ /* num_syn_constraint_resources */ 0,
+ /* parent_process */ XmInheritParentProcess,
+ /* extension */ NULL,
+ },
+ /* FontSampler class part */
+ {
+ /* cancel */ Cancel,
+ /* extension */ NULL,
+ }
+};
+
+WidgetClass fontSamplerWidgetClass =
+ (WidgetClass) &fontSamplerClassRec;
+
+struct _FilterRec;
+
+typedef Boolean (*MatchProc)(String name, struct _FilterRec *filter);
+
+typedef struct _FilterRec {
+ char *name;
+ char *particles[9];
+ MatchProc special;
+} FilterRec;
+
+static Boolean MatchRoman(String name, FilterRec *filter);
+static Boolean MatchMedium(String name, FilterRec *filter);
+static Boolean MatchBlack(String name, FilterRec *filter);
+
+FilterRec filters[] = {
+ {"roman", {"Roman", NULL}, MatchRoman},
+ {"italic", {"Italic", "Kursiv", "Oblique", "Slanted", NULL}},
+ {"symbol", {"Pi", "Symbol", "Logo", "Math", "Ornaments",
+ "Carta", "Sonata", "Dingbats", NULL}},
+ {"display", {"Display", "Titling", NULL}},
+ {"alternate", {"Alternate", NULL}},
+ {"expert", {"Expert", NULL}},
+ {"oldstyle", {"Oldstyle Figures", "Old Style Figures",
+ "Expert", NULL}},
+ {"smallcaps", {"Small Caps", NULL}},
+ {"swash", {"Swash", NULL}},
+ {"script", {"Script", NULL}},
+ {"separator1", { NULL}},
+ {"condensed", {"Condensed", "Compressed", "Narrow", NULL}},
+ {"extended", {"Extended", NULL}},
+ {"separator2", { NULL}},
+ {"light", {"Light", "Thin", NULL}},
+ {"book", {"Book", NULL}},
+ {"medium", {"Medium", "Normal", "Regular",
+ "Roman", NULL}, MatchMedium},
+ {"demi", {"Demi", "Semi", "Demibold", "Semibold", NULL}},
+ {"bold", {"Bold", NULL}},
+ {"black", {"Black", "Heavy", "Poster", "Scal",
+ "Ultra", NULL}, MatchBlack},
+ {"separator3", { NULL}},
+ { NULL, { NULL}}
+};
+
+#define ITALIC_FILTER 1
+#define SYMBOL_FILTER 2
+#define TYPE_FILTERS 0
+#define WIDTH_FILTERS 11
+#define WEIGHT_FILTERS 14
+
+static int class_indices[] = {TYPE_FILTERS, WIDTH_FILTERS, WEIGHT_FILTERS, -1};
+
+static void ShowLabel(FontSamplerWidget s, XmString string)
+{
+ XtVaSetValues(s->sampler.font_label_child, XmNlabelString, string, NULL);
+}
+
+static void UnhighlightFont(FontSamplerWidget s)
+{
+ DisplayedFontRec *d = s->sampler.highlighted_font;
+
+ XCopyArea(XtDisplay(s->sampler.area_child), s->sampler.pixmap,
+ XtWindow(s->sampler.area_child),
+ s->sampler.gc, d->l-1, d->t-1, d->r - d->l + 2, d->b - d->t + 2,
+ d->l-1, d->t-1);
+}
+
+static void HighlightFont(FontSamplerWidget s)
+{
+ DisplayedFontRec *d = s->sampler.highlighted_font;
+ FontRec *f = d->font;
+ BlendRec *b = d->blend;
+ String fontName;
+ int bogusFont;
+
+ if (b == NULL) fontName = f->font_name;
+ else fontName = b->font_name;
+
+ (void) _FSBDownloadFontIfNecessary(d->font, s->sampler.fsb);
+
+ XDPSSetContextGState(s->sampler.fsb->fsb.context, s->sampler.gstate);
+ DPSsetrgbcolor(s->sampler.fsb->fsb.context, 1.0, 0.0, 0.0);
+ _DPSFShowText(s->sampler.fsb->fsb.context, d->text->str,
+ fontName, d->text->size, d->x, d->y, &bogusFont);
+}
+
+/* ARGSUSED */
+
+static void ClickAction(
+ Widget widget,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
+{
+ XButtonEvent *b = (XButtonEvent *) event;
+ DisplayedFontRec *f;
+ FontSamplerWidget s =
+ (FontSamplerWidget) XtParent(XtParent(XtParent(XtParent(widget))));
+ XmString CSname;
+ char buf[512];
+
+ if (event->type != ButtonPress) return;
+
+ if (s->sampler.current_display_info == NULL) return;
+
+ f = s->sampler.current_display_info->shown_fonts;
+
+ while (f != NULL &&
+ (b->x < f->l || b->y < f->t || b->x > f->r || b->y > f->b)) {
+ f = f->next;
+ }
+
+ if (f != NULL) {
+ if (s->sampler.highlighted_font == f) return;
+ if (s->sampler.highlighted_font != NULL) UnhighlightFont(s);
+ s->sampler.highlighted_font = f;
+ HighlightFont(s);
+ if (f->blend == NULL) CSname = UnsharedCS(f->font->full_name);
+ else {
+ sprintf(buf, "%s %s", f->font->full_name, f->blend->blend_name);
+ CSname = UnsharedCS(buf);
+ }
+ ShowLabel(s, CSname);
+ XmStringFree(CSname);
+ if (f->blend == NULL) {
+ _FSBSetCurrentFont(s->sampler.fsb, f->font->font_name);
+ } else {
+ _FSBSetCurrentFont(s->sampler.fsb, f->blend->font_name);
+ }
+ }
+}
+
+static void UpdateDisplayedFontRecs(
+ DisplayRecord *info,
+ Position newHeight,
+ Position oldHeight,
+ Position newWidth)
+{
+ float *m = info->sampler->sampler.invctm;
+ float h, w;
+ Position oldInfoHeight = info->height;
+ DisplayedFontRec *f;
+
+ info->window_height = newHeight;
+ h = newHeight;
+ w = newWidth;
+
+ info->width = (int) (m[0] * w - m[2] * h + m[4]);
+ info->height = (int) (m[1] * w - m[3] * h + m[5]);
+
+ info->y += info->height - oldInfoHeight;
+
+ for (f = info->shown_fonts; f != NULL; f = f->next) {
+ f->y += info->height - oldInfoHeight;
+ }
+}
+
+/* ARGSUSED */
+
+static void ResizeEventHandler(
+ Widget widget,
+ XtPointer clientData,
+ XEvent *event,
+ Boolean *continueToDispatch)
+{
+ Dimension clip_width, clip_height, new_width, new_height,
+ area_width, area_height;
+ int depth;
+ FontSamplerWidget s = (FontSamplerWidget) clientData;
+ Pixmap p;
+
+ if (event->type != ConfigureNotify) return;
+
+ XtVaGetValues(s->sampler.clip_widget, XtNwidth, &clip_width,
+ XtNheight, &clip_height, NULL);
+ XtVaGetValues(s->sampler.area_child, XtNwidth, &area_width,
+ XtNheight, &area_height, XtNdepth, &depth, NULL);
+
+ /* Trying to make it fit exactly causes looooping... */
+
+ new_width = clip_width-2;
+ new_height = clip_height-2;
+
+ if (clip_width < s->sampler.minimum_width) {
+ new_width = s->sampler.minimum_width;
+ }
+ if (clip_height < s->sampler.minimum_height) {
+ new_height = s->sampler.minimum_height;
+ }
+
+ if (new_height != area_height || new_width != area_width) {
+ XtVaSetValues(s->sampler.area_child, XtNwidth, new_width,
+ XtNheight, new_height, NULL);
+
+ p = XCreatePixmap(XtDisplay(s->sampler.area_child),
+ RootWindowOfScreen(XtScreen(s->sampler.area_child)),
+ new_width, new_height, depth);
+
+ if (s->sampler.gstate != 0) {
+ XDPSSetContextGState(s->sampler.fsb->fsb.context,
+ s->sampler.gstate);
+ XDPSSetContextParameters(s->sampler.fsb->fsb.context,
+ XtScreen(s->sampler.area_child), depth,
+ XtWindow(s->sampler.area_child),
+ new_height,
+ (XDPSStandardColormap *) NULL,
+ (XDPSStandardColormap *) NULL,
+ XDPSContextScreenDepth | XDPSContextDrawable |
+ XDPSContextRGBMap | XDPSContextGrayMap);
+ _DPSFReclip(s->sampler.fsb->fsb.context);
+ _DPSFGetCTM(s->sampler.fsb->fsb.context,
+ s->sampler.ctm, s->sampler.invctm);
+ XDPSUpdateContextGState(s->sampler.fsb->fsb.context,
+ s->sampler.gstate);
+ XDPSSetContextGState(s->sampler.fsb->fsb.context,
+ s->sampler.pixmap_gstate);
+ XDPSSetContextParameters(s->sampler.fsb->fsb.context,
+ (Screen *) NULL, 0,
+ p, new_height,
+ (XDPSStandardColormap *) NULL,
+ (XDPSStandardColormap *) NULL,
+ XDPSContextDrawable);
+ XDPSUpdateContextGState(s->sampler.fsb->fsb.context,
+ s->sampler.pixmap_gstate);
+
+ _DPSFClearWindow(s->sampler.fsb->fsb.context);
+ /* La di dah */
+ DPSWaitContext(s->sampler.fsb->fsb.context);
+ XCopyArea(XtDisplay(s), s->sampler.pixmap, p,
+ s->sampler.gc, 0, 0, new_width, new_height, 0, 0);
+ }
+ XFreePixmap(XtDisplay(s), s->sampler.pixmap);
+ s->sampler.pixmap = p;
+ UpdateDisplayedFontRecs(s->sampler.current_display_info,
+ new_height, area_height, new_width);
+ }
+}
+
+static void ClassInitialize(void)
+{
+ XtInitializeWidgetClass(fontSelectionBoxWidgetClass);
+}
+
+static void ClassPartInitialize(WidgetClass widget_class)
+{
+ register FontSamplerWidgetClass wc =
+ (FontSamplerWidgetClass) widget_class;
+ FontSamplerWidgetClass super =
+ (FontSamplerWidgetClass) wc->core_class.superclass;
+
+ if (wc->sampler_class.cancel == InheritCancel) {
+ wc->sampler_class.cancel = super->sampler_class.cancel;
+ }
+}
+
+static void FreeDisplayInfo(DisplayRecord *info)
+{
+ DisplayedFontRec *f;
+ DisplayedTextRec *t;
+
+ if (info == NULL) return;
+
+ XtVaSetValues(info->sampler->sampler.font_label_child,
+ XtVaTypedArg, XmNlabelString, XtRString,
+ " ", 2, NULL);
+
+ while ((f = info->shown_fonts) != NULL) {
+ info->shown_fonts = f->next;
+ XtFree((char *) f);
+ }
+
+ while ((t = info->text_list) != NULL) {
+ info->text_list = t->next;
+ XtFree((char *) t->str);
+ XtFree((char *) t);
+ }
+
+ XtFree((char *) info);
+}
+
+static Boolean IsSet(Widget widget)
+{
+ return XmToggleButtonGadgetGetState(widget);
+}
+
+/* ARGSUSED */
+
+static void DisplayCallback(Widget widget, XtPointer clientData, XtPointer callData)
+{
+ XtAppContext app;
+ float h, w;
+ DisplayRecord *info;
+ FontSamplerWidget s = (FontSamplerWidget) clientData;
+ float *m;
+ char *value;
+ DisplayedTextRec *t;
+
+ if (s->sampler.current_display_proc != None) {
+ XtRemoveWorkProc(s->sampler.current_display_proc);
+ }
+ FreeDisplayInfo(s->sampler.current_display_info);
+ s->sampler.highlighted_font = NULL;
+
+ app = XtDisplayToApplicationContext(XtDisplay(widget));
+
+ info = s->sampler.current_display_info =
+ (DisplayRecord *) XtNew(DisplayRecord);
+
+ XtVaGetValues(s->sampler.area_child,
+ XtNwidth, &info->width,
+ XtNheight, &info->window_height,
+ XtNdepth, &info->depth,
+ NULL);
+
+ if (s->sampler.gstate == 0) {
+ XDPSSetContextParameters(s->sampler.fsb->fsb.context,
+ XtScreen(s->sampler.area_child), info->depth,
+ XtWindow(s->sampler.area_child),
+ info->window_height,
+ (XDPSStandardColormap *) NULL,
+ (XDPSStandardColormap *) NULL,
+ XDPSContextScreenDepth | XDPSContextDrawable |
+ XDPSContextRGBMap | XDPSContextGrayMap);
+ DPSsetgray(s->sampler.fsb->fsb.context, 0.0);
+ XDPSCaptureContextGState(s->sampler.fsb->fsb.context,
+ &s->sampler.gstate);
+ _DPSFGetCTM(s->sampler.fsb->fsb.context,
+ s->sampler.ctm, s->sampler.invctm);
+ XDPSSetContextParameters(s->sampler.fsb->fsb.context,
+ (Screen *) NULL, 0,
+ s->sampler.pixmap, info->window_height,
+ (XDPSStandardColormap *) NULL,
+ (XDPSStandardColormap *) NULL,
+ XDPSContextDrawable);
+ DPSsetgray(s->sampler.fsb->fsb.context, 0.0);
+ XDPSCaptureContextGState(s->sampler.fsb->fsb.context,
+ &s->sampler.pixmap_gstate);
+ }
+
+ h = info->window_height;
+ w = info->width;
+
+ m = s->sampler.invctm;
+
+ info->width = (int) (m[0] * w - m[2] * h + m[4]);
+ info->height = (int) (m[1] * w - m[3] * h + m[5]);
+ info->sampler = s;
+ info->inited = info->any_shown = False;
+ info->column_width = 0;
+ info->x = 5;
+ info->y = info->height;
+ info->shown_fonts = NULL;
+
+ t = info->text_list = XtNew(DisplayedTextRec);
+ t->next = NULL;
+ value = XmTextFieldGetString(s->sampler.text_child);
+ t->str = XtNewString(value);
+
+ value = XmTextFieldGetString(s->sampler.size_text_field_child);
+
+ if (value == NULL || *value == '\0') t->size = SAMPLER_DEFAULT_SIZE;
+ else {
+ t->size = atof(value);
+ if (t->size <= 0) t->size = SAMPLER_DEFAULT_SIZE;
+ }
+
+ s->sampler.displaying = True;
+
+ XDPSSetContextGState(s->sampler.fsb->fsb.context, s->sampler.gstate);
+ _DPSFClearWindow(s->sampler.fsb->fsb.context);
+ XDPSSetContextGState(s->sampler.fsb->fsb.context,
+ s->sampler.pixmap_gstate);
+ _DPSFClearWindow(s->sampler.fsb->fsb.context);
+
+ XtSetSensitive(s->sampler.stop_button_child, True);
+
+ if (IsSet(s->sampler.all_toggle_child)) {
+ s->sampler.current_display_proc =
+ XtAppAddWorkProc(app, DisplayAllWorkProc,
+ (XtPointer) info);
+ } else if (IsSet(s->sampler.selected_toggle_child)) {
+ s->sampler.current_display_proc =
+ XtAppAddWorkProc(app, DisplaySelectedWorkProc,
+ (XtPointer) info);
+ } else if (IsSet(s->sampler.selected_family_toggle_child)) {
+ s->sampler.current_display_proc =
+ XtAppAddWorkProc(app, DisplaySelectedFamilyWorkProc,
+ (XtPointer) info);
+ } else if (IsSet(s->sampler.filter_toggle_child)) {
+ s->sampler.current_display_proc =
+ XtAppAddWorkProc(app, DisplayFilteredWorkProc,
+ (XtPointer) info);
+ }
+}
+
+static void FinishUpDisplaying(FontSamplerWidget s)
+{
+ XtSetSensitive(s->sampler.stop_button_child, False);
+ s->sampler.current_display_proc = None;
+}
+
+/* ARGSUSED */
+
+static void FilterCallback(Widget widget, XtPointer clientData, XtPointer callData)
+{
+ FontSamplerWidget s = (FontSamplerWidget) clientData;
+
+ s->sampler.filters_changed = True;
+
+ if (IsSet(s->sampler.filter_toggle_child)) return;
+
+ XmToggleButtonGadgetSetState(s->sampler.filter_toggle_child, True, True);
+
+ XmToggleButtonGadgetSetState(s->sampler.all_toggle_child, False, False);
+ XmToggleButtonGadgetSetState(s->sampler.selected_toggle_child,
+ False, False);
+ XmToggleButtonGadgetSetState(s->sampler.selected_family_toggle_child,
+ False, False);
+}
+
+/* ARGSUSED */
+
+static void TextCallback(Widget widget, XtPointer clientData, XtPointer callData)
+{
+ FontSamplerWidget s = (FontSamplerWidget) clientData;
+ DisplayedTextRec *t;
+ char *value;
+
+ if (!s->sampler.displaying) return;
+
+ t = XtNew(DisplayedTextRec);
+
+ value = XmTextFieldGetString(s->sampler.text_child);
+ t->str = XtNewString(value);
+ t->size = s->sampler.current_display_info->text_list->size;
+ t->next = s->sampler.current_display_info->text_list;
+ s->sampler.current_display_info->text_list = t;
+}
+
+/* ARGSUSED */
+
+static void StopCallback(Widget widget, XtPointer clientData, XtPointer callData)
+{
+ FontSamplerWidget s = (FontSamplerWidget) clientData;
+
+ if (s->sampler.current_display_proc == None) return;
+
+ XtRemoveWorkProc(s->sampler.current_display_proc);
+ FinishUpDisplaying(s);
+}
+
+/* ARGSUSED */
+
+static void DismissCallback(Widget widget, XtPointer clientData, XtPointer callData)
+{
+ FontSamplerWidget s = (FontSamplerWidget) clientData;
+
+ if (XtIsShell(XtParent(s))) XtPopdown(XtParent(s));
+
+ if (s->sampler.current_display_proc != None) {
+ XtRemoveWorkProc(s->sampler.current_display_proc);
+ }
+ FinishUpDisplaying(s);
+
+ XtCallCallbackList(widget, s->sampler.dismiss_callback, (XtPointer) NULL);
+}
+
+/* ARGSUSED */
+
+static void PopdownCallback(Widget widget, XtPointer clientData, XtPointer callData)
+{
+ FontSamplerWidget s =
+ (FontSamplerWidget)
+ (((CompositeWidget) widget)->composite.children[0]);
+
+ if (s->sampler.current_display_proc != None) {
+ XtRemoveWorkProc(s->sampler.current_display_proc);
+ }
+}
+
+/* ARGSUSED */
+
+static void ExposeCallback(Widget widget, XtPointer clientData, XtPointer callData)
+{
+ XmDrawingAreaCallbackStruct *da = (XmDrawingAreaCallbackStruct *) callData;
+ XExposeEvent *ev = (XExposeEvent *) da->event;
+ FontSamplerWidget s = (FontSamplerWidget) clientData;
+
+ if (ev->type != Expose || !s->sampler.displaying) return;
+
+ XCopyArea(XtDisplay(widget), s->sampler.pixmap, XtWindow(widget),
+ s->sampler.gc, ev->x, ev->y, ev->width, ev->height,
+ ev->x, ev->y);
+ if (s->sampler.highlighted_font != NULL) HighlightFont(s);
+}
+
+/* ARGSUSED */
+
+static void ClearCallback(Widget widget, XtPointer clientData, XtPointer callData)
+{
+ int j;
+ FontSamplerWidget s = (FontSamplerWidget) clientData;
+
+ for (j = 0; filters[j].name != NULL; j++) {
+ if (filters[j].particles[0] != NULL) {
+ XmToggleButtonGadgetSetState(s->sampler.filter_widgets[j],
+ False, False);
+ }
+ }
+
+ XmTextFieldSetString(s->sampler.filter_text_child, "");
+}
+
+/* ARGSUSED */
+
+static void SizeSelect(Widget widget, XtPointer clientData, XtPointer callData)
+{
+ FontSamplerWidget s = (FontSamplerWidget) clientData;
+ String value;
+ Widget option;
+ char *ch;
+ DisplayedTextRec *t;
+
+ value = XmTextFieldGetString(widget);
+
+ if (value == NULL) option = s->sampler.other_size;
+ else {
+ for (ch = value; *ch != '\0'; ch++) if (*ch == '.') *ch = '-';
+
+ option = XtNameToWidget(s->sampler.size_menu, value);
+ if (option == NULL) option = s->sampler.other_size;
+ }
+
+ XtVaSetValues(s->sampler.size_option_menu_child,
+ XmNmenuHistory, option, NULL);
+
+ if (!s->sampler.displaying) return;
+
+ t = XtNew(DisplayedTextRec);
+
+ t->str = XtNewString(s->sampler.current_display_info->text_list->str);
+ if (value == NULL || *value == '\0') t->size = SAMPLER_DEFAULT_SIZE;
+ else {
+ t->size = atof(value);
+ if (t->size <= 0) t->size = SAMPLER_DEFAULT_SIZE;
+ }
+ t->next = s->sampler.current_display_info->text_list;
+ s->sampler.current_display_info->text_list = t;
+}
+
+/* There's a problem; sometimes the change has already been made in the field,
+ and sometimes it hasn't. The times when it has seem to correspond to
+ making changes with the size option menu, so we use this disgusting
+ global flag to notice when this happens. */
+
+static Boolean changingSize = False;
+
+/* ARGSUSED */
+
+static void TextVerify(Widget widget, XtPointer clientData, XtPointer callData)
+{
+ int i;
+ XmTextVerifyPtr v = (XmTextVerifyPtr) callData;
+ char ch, *cp;
+ int decimalPoints = 0;
+
+ if (changingSize) return; /* We know what we're doing; allow it */
+
+ /* Should probably look at format field, but seems to contain garbage */
+
+ if (v->text->length == 0) return;
+
+ for (i = 0; i < v->text->length; i++) {
+ ch = v->text->ptr[i];
+ if (ch == '.') decimalPoints++;
+ else if (!isdigit(ch)) {
+ v->doit = False;
+ return;
+ }
+ }
+
+ if (decimalPoints > 1) {
+ v->doit = False;
+ return;
+ }
+
+ cp = XmTextFieldGetString(widget);
+
+ for (/**/; *cp != '\0'; cp++) {
+ if (*cp == '.') decimalPoints++;
+ }
+
+ if (decimalPoints > 1) v->doit = False;
+}
+
+/* ARGSUSED */
+
+static void SetSize(Widget widget, XtPointer clientData, XtPointer callData)
+{
+ char buf[20], *ch;
+ FontSamplerWidget s = (FontSamplerWidget) clientData;
+
+ strcpy(buf, XtName(widget));
+ for (ch = buf; *ch != '\0'; ch++) if (*ch == '-') *ch++ = '.';
+
+ changingSize = True;
+ XmTextFieldSetString(s->sampler.size_text_field_child, buf);
+ changingSize = False;
+}
+
+static void CreateSizeMenu(FontSamplerWidget s, Boolean destroyOldChildren)
+{
+ Arg args[20];
+ int i, j;
+ Widget *sizes;
+ char buf[20];
+ Widget *children;
+ Cardinal num_children;
+ XmString csName;
+ char *ch;
+
+ if (destroyOldChildren) {
+ XtVaGetValues(s->sampler.size_menu, XtNchildren, &children,
+ XtNnumChildren, &num_children, NULL);
+
+ /* Don't destroy first child ("other") */
+ for (j = 1; (Cardinal)j < num_children; j++) XtDestroyWidget(children[j]);
+
+ sizes = (Widget *) XtMalloc((s->sampler.size_count+1) *
+ sizeof(Widget));
+ sizes[0] = children[0];
+ } else {
+ i = 0;
+ sizes = (Widget *) XtMalloc((s->sampler.size_count+1) *
+ sizeof(Widget));
+ s->sampler.other_size = sizes[0] =
+ XtCreateManagedWidget("other", xmPushButtonGadgetClass,
+ s->sampler.size_menu, args, i);
+ }
+
+ for (j = 0; j < s->sampler.size_count; j++) {
+ (void) sprintf(buf, "%g", s->sampler.sizes[j]);
+ csName = UnsharedCS(buf);
+ for (ch = buf; *ch != '\0'; ch++) if (*ch == '.') *ch = '-';
+ i = 0;
+ XtSetArg(args[i], XmNlabelString, csName); i++;
+ sizes[j+1] =
+ XmCreatePushButtonGadget(s->sampler.size_menu, buf, args, i);
+ XmStringFree(csName);
+ XtAddCallback(sizes[j+1], XmNactivateCallback, SetSize, (XtPointer) s);
+ }
+ XtManageChildren(sizes, j+1);
+ XtFree((char *) sizes);
+}
+
+static void CreateFilters(FontSamplerWidget s)
+{
+ FilterRec *f;
+ int i;
+
+ s->sampler.filter_widgets =
+ (Widget *) XtCalloc(XtNumber(filters)-1, sizeof(Widget));
+
+ s->sampler.filter_flags =
+ (Boolean *) XtCalloc(XtNumber(filters)-1, sizeof(Boolean));
+
+ for (i = 0; filters[i].name != NULL; i++) {
+ f = filters+i;
+ if (f->particles[0] == NULL) {
+ s->sampler.filter_widgets[i] =
+ XtCreateManagedWidget(f->name, xmSeparatorGadgetClass,
+ s->sampler.filter_box_child,
+ (ArgList) NULL, 0);
+ } else {
+ s->sampler.filter_widgets[i] =
+ XtCreateManagedWidget(f->name, xmToggleButtonGadgetClass,
+ s->sampler.filter_box_child,
+ (ArgList) NULL, 0);
+ XtAddCallback(s->sampler.filter_widgets[i],
+ XmNvalueChangedCallback,
+ FilterCallback, (XtPointer) s);
+ }
+ }
+}
+
+static void CreateChildren(FontSamplerWidget s)
+{
+ Arg args[20];
+ int i;
+ Widget form;
+ Dimension area_width, area_height;
+ int depth;
+ Widget w, rowcol;
+
+ form = s->sampler.panel_child =
+ XtCreateManagedWidget("panel", xmFormWidgetClass,
+ (Widget) s, (ArgList) NULL, 0);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ s->sampler.display_button_child =
+ XtCreateManagedWidget("displayButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(s->sampler.display_button_child, XmNactivateCallback,
+ DisplayCallback, (XtPointer) s);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, s->sampler.display_button_child); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XtNsensitive, False); i++;
+ s->sampler.stop_button_child =
+ XtCreateManagedWidget("stopButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(s->sampler.stop_button_child, XmNactivateCallback,
+ StopCallback, (XtPointer) s);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, s->sampler.stop_button_child); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ s->sampler.dismiss_button_child =
+ XtCreateManagedWidget("dismissButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(s->sampler.dismiss_button_child, XmNactivateCallback,
+ DismissCallback, (XtPointer) s);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, s->sampler.dismiss_button_child); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ s->sampler.size_label_child =
+ XtCreateManagedWidget("sizeLabel", xmLabelWidgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, s->sampler.size_label_child); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, s->sampler.size_label_child); i++;
+ s->sampler.size_text_field_child =
+ XtCreateManagedWidget("sizeTextField",
+ xmTextFieldWidgetClass,
+ form, args, i);
+ XtAddCallback(s->sampler.size_text_field_child, XmNvalueChangedCallback,
+ SizeSelect, (XtPointer) s);
+ XtAddCallback(s->sampler.size_text_field_child, XmNmodifyVerifyCallback,
+ TextVerify, (XtPointer) NULL);
+
+ i = 0;
+ s->sampler.size_menu = XmCreatePulldownMenu(form, "sizeMenu", args, i);
+
+ CreateSizeMenu(s, False);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, s->sampler.size_text_field_child); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, s->sampler.size_label_child); i++;
+ XtSetArg(args[i], XmNsubMenuId, s->sampler.size_menu); i++;
+ s->sampler.size_option_menu_child =
+ XmCreateOptionMenu(form, "sizeOptionMenu", args, i);
+ XtManageChild(s->sampler.size_option_menu_child);
+
+ SizeSelect(s->sampler.size_text_field_child, (XtPointer) s,
+ (XtPointer) NULL);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_FORM); i++;
+ rowcol = XtCreateManagedWidget("rowColumn", xmRowColumnWidgetClass,
+ form, args, i);
+
+ i = 0;
+ s->sampler.radio_frame_child =
+ XtCreateManagedWidget("radioFrame", xmFrameWidgetClass,
+ rowcol, args, i);
+
+ i = 0;
+ s->sampler.radio_box_child = XmCreateRadioBox(s->sampler.radio_frame_child,
+ "radioBox", args, i);
+ XtManageChild(s->sampler.radio_box_child);
+
+ i = 0;
+ s->sampler.all_toggle_child =
+ XtCreateManagedWidget("allToggle", xmToggleButtonGadgetClass,
+ s->sampler.radio_box_child, args, i);
+
+ i = 0;
+ s->sampler.selected_toggle_child =
+ XtCreateManagedWidget("selectedToggle", xmToggleButtonGadgetClass,
+ s->sampler.radio_box_child, args, i);
+
+ i = 0;
+ s->sampler.selected_family_toggle_child =
+ XtCreateManagedWidget("selectedFamilyToggle",
+ xmToggleButtonGadgetClass,
+ s->sampler.radio_box_child, args, i);
+
+ i = 0;
+ s->sampler.filter_toggle_child =
+ XtCreateManagedWidget("filterToggle",
+ xmToggleButtonGadgetClass,
+ s->sampler.radio_box_child, args, i);
+
+ i = 0;
+ s->sampler.filter_frame_child =
+ XtCreateManagedWidget("filterFrame", xmFrameWidgetClass,
+ rowcol, args, i);
+
+ i = 0;
+ s->sampler.filter_box_child =
+ XtCreateManagedWidget("filterBox", xmRowColumnWidgetClass,
+ s->sampler.filter_frame_child, args, i);
+
+ CreateFilters(s);
+
+ i = 0;
+ s->sampler.filter_text_child =
+ XtCreateManagedWidget("filterText", xmTextFieldWidgetClass,
+ s->sampler.filter_box_child, args, i);
+ XtAddCallback(s->sampler.filter_text_child,
+ XmNvalueChangedCallback,
+ FilterCallback, (XtPointer) s);
+
+ i = 0;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, rowcol); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, rowcol); i++;
+ s->sampler.clear_button_child =
+ XtCreateManagedWidget("clearButton", xmPushButtonWidgetClass,
+ form, args, i);
+ XtAddCallback(s->sampler.clear_button_child, XmNactivateCallback,
+ ClearCallback, (XtPointer) s);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, rowcol); i++;
+ s->sampler.text_child =
+ XtCreateManagedWidget("text", xmTextFieldWidgetClass,
+ form, args, i);
+ XtAddCallback(s->sampler.text_child,
+ XmNvalueChangedCallback,
+ TextCallback, (XtPointer) s);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, s->sampler.text_child); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNleftWidget, s->sampler.text_child); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, s->sampler.text_child); i++;
+ s->sampler.font_label_child =
+ XtCreateManagedWidget("fontLabel", xmLabelGadgetClass,
+ form, args, i);
+
+ i = 0;
+ XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNtopWidget, s->sampler.font_label_child); i++;
+ XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
+ XtSetArg(args[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNrightWidget, rowcol); i++;
+ XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
+ XtSetArg(args[i], XmNbottomWidget, s->sampler.display_button_child);i++;
+ XtSetArg(args[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
+ s->sampler.scrolled_window_child =
+ XtCreateManagedWidget("scrolledWindow",
+ xmScrolledWindowWidgetClass,
+ form, args, i);
+ i = 0;
+ s->sampler.area_child =
+ XtCreateManagedWidget("area", xmDrawingAreaWidgetClass,
+ s->sampler.scrolled_window_child, args, i);
+ XtAddCallback(s->sampler.area_child, XmNexposeCallback,
+ ExposeCallback, (XtPointer) s);
+
+ XtVaGetValues(s->sampler.scrolled_window_child,
+ XmNclipWindow, &s->sampler.clip_widget,
+ NULL);
+
+ /* I would like to use translations for this, but Motif overwrites the
+ clip window's translation. Grr... */
+
+ XtAddEventHandler(s->sampler.clip_widget, StructureNotifyMask, False,
+ ResizeEventHandler, (XtPointer) s);
+
+ XtVaSetValues(s->sampler.scrolled_window_child,
+ XmNworkWindow, s->sampler.area_child, NULL);
+
+ XtVaGetValues(s->sampler.area_child,
+ XtNheight, &area_height,
+ XtNwidth, &area_width,
+ XtNdepth, &depth,
+ NULL);
+
+ if (area_height < s->sampler.minimum_height ||
+ area_width < s->sampler.minimum_width) {
+ area_height = MAX(area_height, s->sampler.minimum_height);
+ area_width = MAX(area_width, s->sampler.minimum_width);
+
+ XtVaSetValues(s->sampler.area_child, XtNwidth, area_width,
+ XtNheight, area_height, NULL);
+ }
+
+ s->sampler.pixmap =
+ XCreatePixmap(XtDisplay(s->sampler.area_child),
+ RootWindowOfScreen(XtScreen(s->sampler.area_child)),
+ area_width, area_height, depth);
+
+ XtVaSetValues(form, XmNdefaultButton, s->sampler.display_button_child,
+ NULL);
+
+ s->sampler.gc = XtGetGC(s->sampler.area_child, 0, (XGCValues *) NULL);
+
+ for (w = XtParent(s); !XtIsShell(w); w = XtParent(w)) {}
+ XtAddCallback(w, XtNpopdownCallback, PopdownCallback, (XtPointer) NULL);
+}
+
+/* ARGSUSED */
+
+static void Initialize(
+ Widget request, Widget new,
+ ArgList args,
+ Cardinal *num_args)
+{
+ FontSamplerWidget sampler = (FontSamplerWidget) new;
+
+ /* Must have a fsb */
+
+ if (sampler->sampler.fsb == NULL) {
+ XtAppErrorMsg(XtWidgetToApplicationContext(new),
+ "initializeFontSampler", "noFontSelectionBox",
+ "FontSelectionBoxError",
+ "No font selection box given to font sampler",
+ (String *) NULL, (Cardinal *) NULL);
+ }
+
+ /* Verify size list */
+
+ if (sampler->sampler.size_count > 0 && sampler->sampler.sizes == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "initializeFontSampler", "sizeMismatch",
+ "FontSelectionBoxError",
+ "Size count specified but no sizes present",
+ (String *) NULL, (Cardinal *) NULL);
+ sampler->sampler.size_count = 0;
+ }
+
+ if (sampler->sampler.size_count < 0) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "initializeFontSampler", "negativeSize",
+ "FontSelectionBoxError",
+ "Size count should not be negative",
+ (String *) NULL, (Cardinal *) NULL);
+ sampler->sampler.size_count = 0;
+ }
+
+ /* Initialize non-resource fields */
+
+ sampler->sampler.displaying = False;
+ sampler->sampler.current_display_proc = None;
+ sampler->sampler.current_display_info = NULL;
+ sampler->sampler.gstate = sampler->sampler.pixmap_gstate = 0;
+
+ CreateChildren(sampler);
+}
+
+static void AdvanceInfoToNextFont(DisplayRecord *info)
+{
+ if (info->current_font->blend_data != NULL) {
+ if (info->current_blend == NULL) {
+ info->current_blend = info->current_font->blend_data->blends;
+ } else info->current_blend = info->current_blend->next;
+ if (info->current_blend == NULL) {
+ info->current_font = info->current_font->next;
+ }
+ } else info->current_font = info->current_font->next;
+
+ if (info->current_font == NULL) {
+ info->current_family = info->current_family->next;
+ if (info->current_family != NULL) {
+ info->current_font = info->current_family->fonts;
+ }
+ }
+}
+
+static Boolean ShowFont(DisplayRecord *info)
+{
+ float width, left, right, top, bottom;
+ FontRec *f = info->current_font;
+ BlendRec *b = info->current_blend;
+ DisplayedFontRec *d;
+ FontSamplerWidget s = info->sampler;
+ float *m;
+ DisplayedTextRec *t = info->text_list;
+ String fontName;
+ int bogusFont;
+ int oldx, oldy;
+
+ if (f == NULL) return True;
+
+ oldx = info->x;
+ oldy = info->y;
+
+ info->y -= t->size * 5 / 4;
+
+ if (info->y < 0) {
+ if (info->column_width == 0) return False;
+ info->y = info->height - (t->size * 5 / 4);
+ info->x += info->column_width + (t->size / 4);
+ if (info->x > (int) info->width) return False;
+ info->column_width = 0;
+ }
+
+ if (!_FSBDownloadFontIfNecessary(f, s->sampler.fsb)) {
+ AdvanceInfoToNextFont(info);
+ return True;
+ }
+
+ if (b == NULL) fontName = f->font_name;
+ else fontName = b->font_name;
+
+ /* Do ...AndGetDimensions on the pixmap to make sure that it's synced.
+ That way we can reliably do an XCopyArea without first doing a
+ WaitContext. */
+
+ XDPSSetContextGState(s->sampler.fsb->fsb.context, s->sampler.gstate);
+ _DPSFShowText(s->sampler.fsb->fsb.context, t->str, fontName,
+ t->size, info->x, info->y, &bogusFont);
+
+ AdvanceInfoToNextFont(info);
+
+ if (bogusFont) {
+ info->x = oldx;
+ info->y = oldy;
+
+ XCopyArea(XtDisplay(s), s->sampler.pixmap,
+ XtWindow(s->sampler.area_child),
+ s->sampler.gc, 0, 0, info->width, info->height, 0, 0);
+
+ if (info->current_font == f) {
+ /* Must be the same font, different blend */
+ info->current_font = info->current_font->next;
+
+ if (info->current_font == NULL) {
+ info->current_family = info->current_family->next;
+ if (info->current_family != NULL) {
+ info->current_font = info->current_family->fonts;
+ }
+ }
+ }
+
+ _FSBFlushFont(s->sampler.fsb, f);
+ return True;
+ }
+
+ XDPSSetContextGState(s->sampler.fsb->fsb.context,
+ s->sampler.pixmap_gstate);
+ _DPSFShowTextAndGetDimensions(s->sampler.fsb->fsb.context,
+ t->str, fontName,
+ t->size, info->x, info->y,
+ &width, &left, &right, &top, &bottom);
+
+ width = ceil(width);
+
+ if (width > (int) info->column_width) info->column_width = (int) width;
+
+ d = XtNew(DisplayedFontRec);
+
+ m = s->sampler.ctm;
+
+ d->l = (int) (m[0] * left + m[2] * top + m[4]);
+ d->r = (int) ceil(m[0] * right + m[2] * bottom + m[4]);
+ d->t = (int) ceil(m[1] * left + m[3] * top + m[5] + info->window_height);
+ d->b = (int) (m[1] * right + m[3] * bottom + m[5] + info->window_height);
+ d->x = info->x;
+ d->y = info->y;
+ d->font = f;
+ d->blend = b;
+ d->text = info->text_list;
+ d->next = info->shown_fonts;
+ info->shown_fonts = d;
+
+ return True;
+}
+
+static Boolean DisplayAllWorkProc(XtPointer client_data)
+{
+ DisplayRecord *info = (DisplayRecord *) client_data;
+ FontSamplerWidget s = info->sampler;
+
+ if (!info->inited) {
+ info->inited = True;
+ info->current_family = s->sampler.fsb->fsb.known_families;
+ info->current_font = info->current_family->fonts;
+ info->current_blend = NULL;
+ }
+
+ if (!ShowFont(info)) {
+ if (!info->any_shown) ShowLabel(s, s->sampler.no_room_message);
+ FinishUpDisplaying(s);
+ return True;
+ }
+
+ info->any_shown = True;
+ if (info->current_family == NULL) {
+ if (!info->any_shown) ShowLabel(s, s->sampler.no_font_message);
+ FinishUpDisplaying(s);
+ return True;
+ }
+ return False;
+}
+
+static Boolean DisplaySelectedWorkProc(XtPointer client_data)
+{
+ DisplayRecord *info = (DisplayRecord *) client_data;
+ FontSamplerWidget s = info->sampler;
+
+ info->current_family = s->sampler.fsb->fsb.currently_selected_family;
+ info->current_font = s->sampler.fsb->fsb.currently_selected_face;
+ info->current_blend = s->sampler.fsb->fsb.currently_selected_blend;
+
+ if (info->current_font != NULL) {
+ if (!ShowFont(info)) ShowLabel(s, s->sampler.no_room_message);
+ } else ShowLabel(s, s->sampler.no_selected_font_message);
+
+ FinishUpDisplaying(s);
+ return True;
+}
+
+static Boolean DisplaySelectedFamilyWorkProc(XtPointer client_data)
+{
+ DisplayRecord *info = (DisplayRecord *) client_data;
+ FontSamplerWidget s = info->sampler;
+ FontFamilyRec *currentFamily;
+
+ if (!info->inited) {
+ info->inited = True;
+ info->current_family = s->sampler.fsb->fsb.currently_selected_family;
+ if (info->current_family != NULL) {
+ info->current_font = info->current_family->fonts;
+ info->current_blend = NULL;
+ } else {
+ ShowLabel(s, s->sampler.no_selected_family_message);
+ FinishUpDisplaying(s);
+ return True;
+ }
+ }
+
+ currentFamily = info->current_family;
+
+ if (!ShowFont(info)) {
+ if (!info->any_shown) ShowLabel(s, s->sampler.no_room_message);
+ FinishUpDisplaying(s);
+ return True;
+ }
+
+ info->any_shown = True;
+ if (info->current_family != currentFamily) {
+ if (!info->any_shown) ShowLabel(s, s->sampler.no_family_font_message);
+ FinishUpDisplaying(s);
+ return True;
+ }
+ return False;
+}
+
+/* ARGSUSED */
+
+static Boolean MatchRoman(String name, FilterRec *filter)
+{
+ FilterRec *f;
+ char *ch, **search, *start;
+ int len;
+
+ /* Roman means not italic and not symbol */
+
+ for (f = filters + ITALIC_FILTER; f <= filters + SYMBOL_FILTER; f++) {
+ for (search = f->particles; *search != NULL; search++) {
+ start = name;
+ do {
+ ch = strstr(start, *search);
+ if (ch != NULL) {
+ len = strlen(*search);
+ if (ch[len] == ' ' || ch[len] == '\0') return False;
+ else start = ch+1;
+ }
+ } while (ch != NULL);
+ }
+ }
+ return True;
+}
+
+static Boolean MatchMedium(String name, FilterRec *filter)
+{
+ FilterRec *f;
+ char *ch, **search, *start;
+ int len;
+
+ for (search = filter->particles; *search != NULL; search++) {
+ start = name;
+ do {
+ ch = strstr(start, *search);
+ if (ch != NULL) {
+ len = strlen(*search);
+ if (ch[len] == ' ' || ch[len] == '\0') return True;
+ else start = ch+1;
+ }
+ } while (ch != NULL);
+ }
+
+ /* Also match anything that has none of the other weight particles */
+
+ for (f = filters + WEIGHT_FILTERS; f->name != NULL; f++) {
+ if (f == filter) continue;
+ for (search = f->particles; *search != NULL; search++) {
+ start = name;
+ do {
+ ch = strstr(start, *search);
+ if (ch != NULL) {
+ len = strlen(*search);
+ if (ch[len] == ' ' || ch[len] == '\0') return False;
+ else start = ch+1;
+ }
+ } while (ch != NULL);
+ }
+ }
+ return True;
+}
+
+static Boolean MatchBlack(String name, FilterRec *filter)
+{
+ char *ch, **search, *start;
+ int len;
+ Boolean ultra;
+
+ for (search = filter->particles; *search != NULL; search++) {
+ ultra = (strcmp(*search, "Ultra") == 0);
+ start = name;
+ do {
+ ch = strstr(start, *search);
+ if (ch != NULL) {
+ len = strlen(*search);
+ if (ch[len] == '\0') return True;
+ if (ch[len] == ' ') {
+ if (!ultra) return True;
+ /* Only match "Ultra" if not followed by "Compressed" or
+ "Light". We'd also like to add "Condensed" to this
+ list, but some fonts use "Ultra Condensed" to mean
+ "Ultra & Condensed" while others use it to mean "Very
+ much Condensed". Sigh... */
+ start = ch+len+1;
+ if (strncmp(start, "Compressed", 10) != 0 &&
+ strncmp(start, "Light", 5) != 0) return True;
+ else start = ch+1;
+ }
+ else start = ch+1;
+ }
+ } while (ch != NULL);
+ }
+ return False;
+}
+
+static void UpdateFilters(FontSamplerWidget s)
+{
+ int i;
+
+ for (i = 0; filters[i].name != NULL; i++) {
+ if (filters[i].particles[0] != NULL) {
+ s->sampler.filter_flags[i] = IsSet(s->sampler.filter_widgets[i]);
+ }
+ }
+
+ s->sampler.filter_text =
+ XmTextFieldGetString(s->sampler.filter_text_child);
+}
+
+static Boolean FontMatchesFilters(
+ FontRec *font,
+ BlendRec *blend,
+ FontSamplerWidget s)
+{
+ int *cl, i;
+ FilterRec *f;
+ char *ch, **search, *start;
+ int len;
+ Boolean anyset, foundone, allmatch;
+ char *name;
+ char buf[512];
+
+ if (blend != NULL) {
+ sprintf(buf, "%s %s", font->full_name, blend->blend_name);
+ name = buf;
+ } else name = font->full_name;
+
+ allmatch = False;
+ if (s->sampler.filters_changed) UpdateFilters(s);
+
+ for (cl = class_indices; *cl != -1; cl++) {
+ anyset = foundone = False;
+ for (i = *cl;
+ filters[i].particles[0] != NULL && filters[i].name != NULL; i++) {
+
+ f = filters+i;
+
+ if (!s->sampler.filter_flags[i]) continue;
+ anyset = True;
+
+ if (f->special != NULL) {
+ if ((*f->special)(name, f)) {
+ foundone = True;
+ goto NEXT_CLASS;
+ }
+ continue;
+ }
+
+ for (search = f->particles; *search != NULL; search++) {
+ start = name;
+ do {
+ ch = strstr(start, *search);
+ if (ch != NULL) {
+ len = strlen(*search);
+ if (ch[len] == ' ' || ch[len] == '\0') {
+ foundone = True;
+ goto NEXT_CLASS;
+ }
+ else start = ch+1;
+ }
+ } while (ch != NULL);
+ }
+ }
+NEXT_CLASS: ;
+ /* If there were any filters set in this class, but we didn't match,
+ return False */
+ if (anyset && !foundone) return False;
+ if (anyset && foundone) allmatch = True;
+ }
+
+ /* Now check against the text field */
+
+ if (s->sampler.filter_text == NULL || s->sampler.filter_text[0] == '\0') {
+ return allmatch;
+ }
+
+ ch = strstr(name, s->sampler.filter_text);
+
+ return (ch != NULL);
+}
+
+static Boolean DisplayFilteredWorkProc(XtPointer client_data)
+{
+ DisplayRecord *info = (DisplayRecord *) client_data;
+ FontSamplerWidget s = info->sampler;
+
+ if (!info->inited) {
+ info->inited = True;
+ info->current_family = s->sampler.fsb->fsb.known_families;
+ info->current_font = info->current_family->fonts;
+ info->current_blend = NULL;
+ s->sampler.filters_changed = True;
+ }
+
+ if (FontMatchesFilters(info->current_font, info->current_blend, s)) {
+ if (!ShowFont(info)) {
+ if (!info->any_shown) ShowLabel(s, s->sampler.no_room_message);
+ FinishUpDisplaying(s);
+ return True;
+ }
+ info->any_shown = True;
+ } else AdvanceInfoToNextFont(info);
+
+ if (info->current_font == NULL) {
+ if (!info->any_shown) ShowLabel(s, s->sampler.no_match_message);
+ FinishUpDisplaying(s);
+ return True;
+ }
+ return False;
+}
+
+static void Destroy(Widget widget)
+{
+ FontSamplerWidget s = (FontSamplerWidget) widget;
+
+ if (s->sampler.gstate != 0) {
+ XDPSFreeContextGState(s->sampler.fsb->fsb.context,
+ s->sampler.pixmap_gstate);
+ XDPSFreeContextGState(s->sampler.fsb->fsb.context, s->sampler.gstate);
+ }
+ XtReleaseGC(widget, s->sampler.gc);
+ XFreePixmap(XtDisplay(widget), s->sampler.pixmap);
+ if (s->sampler.current_display_proc != None) {
+ XtRemoveWorkProc(s->sampler.current_display_proc);
+ }
+ if (s->sampler.current_display_info != NULL) {
+ FreeDisplayInfo(s->sampler.current_display_info);
+ }
+ XtFree((char *) s->sampler.filter_widgets);
+ XtFree((char *) s->sampler.filter_flags);
+}
+
+static void Resize(Widget widget)
+{
+ FontSamplerWidget s = (FontSamplerWidget) widget;
+
+ XtResizeWidget(s->sampler.panel_child, s->core.width, s->core.height, 0);
+}
+
+/* ARGSUSED */
+
+static XtGeometryResult GeometryManager(
+ Widget w,
+ XtWidgetGeometry *desired, XtWidgetGeometry *allowed)
+{
+#define WANTS(flag) (desired->request_mode & flag)
+
+ if (WANTS(XtCWQueryOnly)) return XtGeometryYes;
+
+ if (WANTS(CWWidth)) w->core.width = desired->width;
+ if (WANTS(CWHeight)) w->core.height = desired->height;
+ if (WANTS(CWX)) w->core.x = desired->x;
+ if (WANTS(CWY)) w->core.y = desired->y;
+ if (WANTS(CWBorderWidth)) {
+ w->core.border_width = desired->border_width;
+ }
+
+ return XtGeometryYes;
+#undef WANTS
+}
+
+static void ChangeManaged(Widget w)
+{
+ FontSamplerWidget s = (FontSamplerWidget) w;
+
+ w->core.width = s->composite.children[0]->core.width;
+ w->core.height = s->composite.children[0]->core.height;
+}
+
+/* ARGSUSED */
+
+static Boolean SetValues(
+ Widget old, Widget req, Widget new,
+ ArgList args,
+ Cardinal *num_args)
+{
+ FontSamplerWidget olds = (FontSamplerWidget) old;
+ FontSamplerWidget news = (FontSamplerWidget) new;
+
+#define NE(field) news->sampler.field != olds->sampler.field
+#define DONT_CHANGE(field) \
+ if (NE(field)) news->sampler.field = olds->sampler.field;
+
+ DONT_CHANGE(panel_child);
+ DONT_CHANGE(area_child);
+ DONT_CHANGE(text_child);
+ DONT_CHANGE(font_label_child);
+ DONT_CHANGE(scrolled_window_child);
+ DONT_CHANGE(display_button_child);
+ DONT_CHANGE(dismiss_button_child);
+ DONT_CHANGE(stop_button_child);
+ DONT_CHANGE(clear_button_child);
+ DONT_CHANGE(radio_frame_child);
+ DONT_CHANGE(radio_box_child);
+ DONT_CHANGE(all_toggle_child);
+ DONT_CHANGE(selected_toggle_child);
+ DONT_CHANGE(selected_family_toggle_child);
+ DONT_CHANGE(filter_toggle_child);
+ DONT_CHANGE(filter_box_child);
+ DONT_CHANGE(filter_frame_child);
+ DONT_CHANGE(size_option_menu_child);
+ DONT_CHANGE(size_text_field_child);
+ DONT_CHANGE(size_label_child);
+ DONT_CHANGE(fsb);
+#undef DONT_CHANGE
+
+ if (news->sampler.size_count > 0 && news->sampler.sizes == NULL) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "setValuesFontSampler", "sizeMismatch",
+ "FontSelectionBoxError",
+ "Size count specified but no sizes present",
+ (String *) NULL, (Cardinal *) NULL);
+ news->sampler.size_count = 0;
+ }
+
+ if (news->sampler.size_count < 0) {
+ XtAppWarningMsg(XtWidgetToApplicationContext(new),
+ "setValuesFontSampler", "negativeSize",
+ "FontSelectionBoxError",
+ "Size count should not be negative",
+ (String *) NULL, (Cardinal *) NULL);
+ news->sampler.size_count = 0;
+ }
+
+ if (NE(sizes)) CreateSizeMenu(news, True);
+
+ return False;
+#undef NE
+}
+
+static void Cancel(Widget w)
+{
+ FontSamplerWidget s = (FontSamplerWidget) w;
+
+ if (s->sampler.current_display_proc != None) {
+ XtRemoveWorkProc(s->sampler.current_display_proc);
+ }
+}
+
+void FSBCancelSampler(Widget w)
+{
+ XtCheckSubclass(w, fontSamplerWidgetClass, NULL);
+
+ (*((FontSamplerWidgetClass) XtClass(w))->sampler_class.cancel) (w);
+}
+
+#ifdef NO_STRSTR_AVAILABLE
+String strstr(String s1, String s2)
+{
+ register int len1, len2;
+
+ len1 = strlen(s1);
+ len2 = strlen(s2);
+
+ while (len1 >= len2) {
+ if (*s1 == *s2) {
+ if (strncmp(s1+1, s2+1, len2-1) == 0) return s1;
+ }
+ len1--;
+ s1++;
+ }
+}
+#endif /* NO_STRSTR_AVAILABLE */
diff --git a/nx-X11/lib/dpstk/FontSelect.ad b/nx-X11/lib/dpstk/FontSelect.ad
new file mode 100644
index 000000000..6d3440a9e
--- /dev/null
+++ b/nx-X11/lib/dpstk/FontSelect.ad
@@ -0,0 +1,415 @@
+! FontSelect
+!
+! (c) Copyright 1991-1994 Adobe Systems Incorporated.
+! All rights reserved.
+!
+! Permission to use, copy, modify, distribute, and sublicense this software
+! and its documentation for any purpose and without fee is hereby granted,
+! provided that the above copyright notices appear in all copies and that
+! both those copyright notices and this permission notice appear in
+! supporting documentation and that the name of Adobe Systems Incorporated
+! not be used in advertising or publicity pertaining to distribution of the
+! software without specific, written prior permission. No trademark license
+! to use the Adobe trademarks is hereby granted. If the Adobe trademark
+! "Display PostScript"(tm) is used to describe this software, its
+! functionality or for any other purpose, such use shall be limited to a
+! statement that this software works in conjunction with the Display
+! PostScript system. Proper trademark attribution to reflect Adobe's
+! ownership of the trademark shall be given whenever any such reference to
+! the Display PostScript system is made.
+!
+! ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+! ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+! ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+! IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+! NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+! TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+! DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+! NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+! CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+! PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+!
+! Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+! Incorporated which may be registered in certain jurisdictions
+!
+! Author: Adobe Systems Incorporated
+!
+! Resource file for Font Selection Box
+!
+! This resource file must be merged into the resource file for
+! any application that uses the Font Selection Box
+!
+!
+*FontSelectionBox*fontList: -adobe-helvetica-bold-r-normal--*-120-*-*-*-*-iso8859-1
+*FontSelectionBox*XmPushButton.marginLeft:5
+*FontSelectionBox*XmPushButton.marginRight:5
+
+*FontSelectionBox*preview.background: white
+*FontSelectionBox*preview.height: 40
+
+*FontSelectionBox*panel.width: 397
+*FontSelectionBox*panel.height: 286
+
+*FontSelectionBox*panel.horizontalSpacing: 5
+*FontSelectionBox*panel.verticalSpacing: 2
+
+*FontSelectionBox*okButton.labelString: OK
+
+*FontSelectionBox*applyButton.labelString: Apply
+
+*FontSelectionBox*resetButton.labelString: Reset
+
+*FontSelectionBox*cancelButton.labelString: Cancel
+
+*FontSelectionBox*sizeLabel.labelString: Size:
+*FontSelectionBox*sizeLabel.leftOffset: 10
+*FontSelectionBox*sizeLabel.bottomOffset: 12
+
+*FontSelectionBox*sizeTextField.columns: 4
+*FontSelectionBox*sizeTextField.leftOffset: 2
+*FontSelectionBox*sizeTextField.bottomOffset: -7
+*FontSelectionBox*sizeTextField.value: 12
+*FontSelectionBox*sizeTextField.verifyBell: False
+
+*FontSelectionBox*other.labelString: ...
+
+*FontSelectionBox*sizeOptionMenu.labelString:
+*FontSelectionBox*sizeOptionMenu.bottomOffset: -9
+*FontSelectionBox*sizeOptionMenu.leftOffset: -5
+
+*FontSelectionBox*sizeMultipleLabel.labelString: Multiple
+*FontSelectionBox*sizeMultipleLabel.leftOffset: 0
+*FontSelectionBox*sizeMultipleLabel.bottomOffset: 10
+
+*FontSelectionBox*previewButton.labelString: Preview
+*FontSelectionBox*previewButton.bottomOffset: -11
+*FontSelectionBox*previewButton.rightOffset: 5
+
+*FontSelectionBox*samplerButton.labelString: Sampler...
+*FontSelectionBox*samplerButton.bottomOffset: 0
+*FontSelectionBox*samplerButton.rightOffset: 0
+
+*FontSelectionBox*familyLabel.labelString: Family
+*FontSelectionBox*familyLabel.rightOffset: 7
+*FontSelectionBox*familyLabel.leftOffset: 10
+
+*FontSelectionBox*faceLabel.labelString: Face
+*FontSelectionBox*faceLabel.rightOffset: 10
+*FontSelectionBox*faceLabel.leftOffset: 7
+
+*FontSelectionBox*familyMultipleLabel.labelString: MULTIPLE
+*FontSelectionBox*familyMultipleLabel.background: black
+*FontSelectionBox*familyMultipleLabel.foreground: #729FFF
+*FontSelectionBox*familyMultipleLabel.leftOffset: 10
+*FontSelectionBox*familyMultipleLabel.rightOffset: 7
+*FontSelectionBox*familyMultipleLabel.topOffset: 2
+
+*FontSelectionBox*faceMultipleLabel.labelString: MULTIPLE
+*FontSelectionBox*faceMultipleLabel.background: black
+*FontSelectionBox*faceMultipleLabel.foreground: #729FFF
+*FontSelectionBox*faceMultipleLabel.leftOffset: 7
+*FontSelectionBox*faceMultipleLabel.topOffset: 2
+*FontSelectionBox*faceMultipleLabel.rightOffset: 10
+
+*FontSelectionBox*familyScrolledListSW.leftOffset: 10
+*FontSelectionBox*familyScrolledListSW.topOffset: 2
+*FontSelectionBox*familyScrolledListSW.rightOffset: 7
+
+*FontSelectionBox*faceScrolledListSW.topOffset: 2
+*FontSelectionBox*faceScrolledListSW.leftOffset: 7
+*FontSelectionBox*faceScrolledListSW.rightOffset: 10
+
+*FontSelectionBox*XmList.listSizePolicy: constant
+*FontSelectionBox*XmList.scrollBarDisplayPolicy: as_needed
+
+*FontSelectionBox*multipleMasterButton.labelString: Multiple Master...
+
+*FontSelectionBox*invalidFontMessage.dialogTitle: Font Alert
+*FontSelectionBox*invalidFontMessage.messageString: The selected font contains\n\
+an error and is not usable.
+
+! Font sampler resources
+
+! Keep mwm from deleting this window; it confuses everyone
+*FontSelectionBox*samplerShell.deleteResponse: unmap
+
+*FontSelectionBox*samplerShell.width: 530
+*FontSelectionBox*samplerShell.height: 620
+*FontSelectionBox*samplerShell.title: Font Sampler
+
+*FontSelectionBox*sampler.minimumWidth: 1000
+*FontSelectionBox*sampler.minimumHeight: 400
+
+*FontSelectionBox*sampler*panel.horizontalSpacing: 5
+*FontSelectionBox*sampler*panel.verticalSpacing: 5
+
+*FontSelectionBox*sampler*area.width: 1000
+*FontSelectionBox*sampler*area.height: 476
+*FontSelectionBox*sampler*area.background: white
+*FontSelectionBox*sampler*ScrolledWindowClipWindow.background: white
+
+*FontSelectionBox*sampler*area.translations: #override\n\
+ <ButtonPress> : FSBClickAction()
+
+*FontSelectionBox*sampler*text.value: Abc
+
+*FontSelectionBox*sampler*fontLabel.labelString: \040
+*FontSelectionBox*sampler*fontLabel.recomputeSize: FALSE
+
+*FontSelectionBox*sampler*displayButton.labelString: Display
+*FontSelectionBox*sampler*stopButton.labelString: Stop
+*FontSelectionBox*sampler*dismissButton.labelString: Dismiss
+*FontSelectionBox*sampler*clearButton.labelString: Reset Filters
+
+*FontSelectionBox*sampler*allToggle.labelString: All
+*FontSelectionBox*sampler*allToggle.set: true
+*FontSelectionBox*sampler*selectedToggle.labelString: Selected
+*FontSelectionBox*sampler*selectedFamilyToggle.labelString: Family
+*FontSelectionBox*sampler*filterToggle.labelString: Filter
+
+*FontSelectionBox*sampler*filterText.leftOffset: 0
+*FontSelectionBox*sampler*filterText.columns:10
+*FontSelectionBox*sampler*filterText.marginHeight: 5
+
+*FontSelectionBox*sampler*radioBox*marginHeight: 1
+*FontSelectionBox*sampler*radioBox.spacing: 0
+*FontSelectionBox*sampler*filterBox*XmToggleButtonGadget.marginHeight: 0
+*FontSelectionBox*sampler*filterBox.spacing: 0
+*FontSelectionBox*sampler*filterBox*packing: PACK_TIGHT
+
+*FontSelectionBox*sampler*filterBox*XmSeparatorGadget.height: 8
+
+*FontSelectionBox*sampler*radioBox.width: 129
+*FontSelectionBox*sampler*radioBox.resizeWidth: FALSE
+
+*FontSelectionBox*sampler*roman.labelString: Roman
+*FontSelectionBox*sampler*italic.labelString: Italic
+*FontSelectionBox*sampler*symbol.labelString: Symbol
+*FontSelectionBox*sampler*display.labelString: Display
+*FontSelectionBox*sampler*alternate.labelString: Alternate
+*FontSelectionBox*sampler*expert.labelString: Expert
+*FontSelectionBox*sampler*oldstyle.labelString: Oldstyle Figures
+*FontSelectionBox*sampler*smallcaps.labelString: Small Caps
+*FontSelectionBox*sampler*swash.labelString: Swash
+*FontSelectionBox*sampler*script.labelString: Script
+
+*FontSelectionBox*sampler*condensed.labelString: Condensed
+*FontSelectionBox*sampler*extended.labelString: Extended
+
+*FontSelectionBox*sampler*light.labelString: Light
+*FontSelectionBox*sampler*book.labelString: Book
+*FontSelectionBox*sampler*medium.labelString: Medium
+*FontSelectionBox*sampler*demi.labelString: Demi
+*FontSelectionBox*sampler*bold.labelString: Bold
+*FontSelectionBox*sampler*black.labelString: Black +
+
+*FontSelectionBox*sampler*sizeLabel.labelString: Size:
+*FontSelectionBox*sampler*sizeLabel.bottomOffset: 15
+*FontSelectionBox*sampler*sizeLabel.leftOffset: 0
+
+*FontSelectionBox*sampler*sizeTextField.columns: 4
+*FontSelectionBox*sampler*sizeTextField.leftOffset: 2
+*FontSelectionBox*sampler*sizeTextField.bottomOffset: -7
+*FontSelectionBox*sampler*sizeTextField.value: 24
+*FontSelectionBox*sampler*sizeTextField.verifyBell: False
+
+*FontSelectionBox*sampler*sizeOptionMenu.labelString:
+*FontSelectionBox*sampler*sizeOptionMenu.bottomOffset: -9
+*FontSelectionBox*sampler*sizeOptionMenu.leftOffset: -5
+
+*FontSelectionBox*creatorShell.title: Multiple Master Font Creator
+
+*FontSelectionBox*creatorShell*preview.height: 50
+*FontSelectionBox*creatorShell*preview.leftOffset: 4
+*FontSelectionBox*creatorShell*preview.rightOffset: 4
+*FontSelectionBox*creatorShell*preview.topOffset: 4
+
+*FontSelectionBox*creatorShell*panel.horizontalSpacing: 10
+*FontSelectionBox*creatorShell*panel.verticalSpacing: 5
+*FontSelectionBox*creatorShell*panel.width: 500
+*FontSelectionBox*creatorShell*panel.height: 325
+*FontSelectionBox*creatorShell*panel.marginHeight: 5
+*FontSelectionBox*creatorShell*panel.marginWidth: 5
+
+*FontSelectionBox*creatorShell*displayTextLabel.labelString: String
+*FontSelectionBox*creatorShell*displayTextLabel.rightPosition: 15
+*FontSelectionBox*creatorShell*displayTextLabel.rightOffset: 5
+*FontSelectionBox*creatorShell*displayTextLabel.topOffset: 5
+
+*FontSelectionBox*creatorShell*displayText.leftPosition: 15
+*FontSelectionBox*creatorShell*displayText.rightPosition: 60
+*FontSelectionBox*creatorShell*displayText.rightOffset: 10
+*FontSelectionBox*creatorShell*displayText.topOffset: 0
+
+*FontSelectionBox*creatorShell*axisLabel1.rightPosition: 15
+*FontSelectionBox*creatorShell*axisLabel1.bottomOffset: 0
+*FontSelectionBox*creatorShell*axisLabel1.rightOffset: 5
+*FontSelectionBox*creatorShell*axisLabel1.topOffset: 5
+
+*FontSelectionBox*creatorShell*axisValue1.rightPosition: 60
+*FontSelectionBox*creatorShell*axisValue1.rightOffset: 10
+*FontSelectionBox*creatorShell*axisValue1.columns: 4
+
+*FontSelectionBox*creatorShell*axisScale1.rightOffset: 5
+*FontSelectionBox*creatorShell*axisScale1.leftPosition: 15
+*FontSelectionBox*creatorShell*axisScale1.topOffset: 5
+*FontSelectionBox*creatorShell*axisScale1.decimalPoints: 0
+*FontSelectionBox*creatorShell*axisScale1.orientation: horizontal
+*FontSelectionBox*creatorShell*axisScale1.showValue: false
+
+*FontSelectionBox*creatorShell*axisMin1.topOffset: 0
+*FontSelectionBox*creatorShell*axisMin1.leftOffset: 0
+
+*FontSelectionBox*creatorShell*axisMax1.topOffset: 0
+*FontSelectionBox*creatorShell*axisMax1.rightOffset: 0
+
+*FontSelectionBox*creatorShell*axisLabel2.rightPosition: 15
+*FontSelectionBox*creatorShell*axisLabel2.bottomOffset: 0
+*FontSelectionBox*creatorShell*axisLabel2.rightOffset: 5
+*FontSelectionBox*creatorShell*axisLabel2.topOffset: 5
+
+*FontSelectionBox*creatorShell*axisValue2.rightPosition: 60
+*FontSelectionBox*creatorShell*axisValue2.rightOffset: 10
+*FontSelectionBox*creatorShell*axisValue2.topOffset: 15
+*FontSelectionBox*creatorShell*axisValue2.columns: 4
+
+*FontSelectionBox*creatorShell*axisScale2.rightOffset: 5
+*FontSelectionBox*creatorShell*axisScale2.leftPosition: 15
+*FontSelectionBox*creatorShell*axisScale2.decimalPoints: 0
+*FontSelectionBox*creatorShell*axisScale2.orientation: horizontal
+*FontSelectionBox*creatorShell*axisScale2.showValue: false
+*FontSelectionBox*creatorShell*axisScale2.topOffset: 5
+
+*FontSelectionBox*creatorShell*axisMin2.topOffset: 0
+*FontSelectionBox*creatorShell*axisMin2.leftOffset: 0
+
+*FontSelectionBox*creatorShell*axisMax2.topOffset: 0
+*FontSelectionBox*creatorShell*axisMax2.rightOffset: 0
+
+*FontSelectionBox*creatorShell*axisLabel3.rightPosition: 15
+*FontSelectionBox*creatorShell*axisLabel3.bottomOffset: 0
+*FontSelectionBox*creatorShell*axisLabel3.rightOffset: 5
+*FontSelectionBox*creatorShell*axisLabel3.topOffset: 5
+
+*FontSelectionBox*creatorShell*axisValue3.rightPosition: 60
+*FontSelectionBox*creatorShell*axisValue3.rightOffset: 10
+*FontSelectionBox*creatorShell*axisValue3.topOffset: 15
+*FontSelectionBox*creatorShell*axisValue3.columns: 4
+
+*FontSelectionBox*creatorShell*axisScale3.rightOffset: 5
+*FontSelectionBox*creatorShell*axisScale3.leftPosition: 15
+*FontSelectionBox*creatorShell*axisScale3.decimalPoints: 0
+*FontSelectionBox*creatorShell*axisScale3.orientation: horizontal
+*FontSelectionBox*creatorShell*axisScale3.showValue: false
+*FontSelectionBox*creatorShell*axisScale3.topOffset: 5
+
+*FontSelectionBox*creatorShell*axisMin3.topOffset: 0
+*FontSelectionBox*creatorShell*axisMin3.leftOffset: 0
+
+*FontSelectionBox*creatorShell*axisMax3.topOffset: 0
+*FontSelectionBox*creatorShell*axisMax3.rightOffset: 0
+
+*FontSelectionBox*creatorShell*axisLabel4.rightPosition: 15
+*FontSelectionBox*creatorShell*axisLabel4.bottomOffset: 0
+*FontSelectionBox*creatorShell*axisLabel4.rightOffset: 5
+*FontSelectionBox*creatorShell*axisLabel4.topOffset: 5
+
+*FontSelectionBox*creatorShell*axisValue4.rightPosition: 60
+*FontSelectionBox*creatorShell*axisValue4.rightOffset: 10
+*FontSelectionBox*creatorShell*axisValue4.topOffset: 15
+*FontSelectionBox*creatorShell*axisValue4.columns: 4
+
+*FontSelectionBox*creatorShell*axisScale4.rightOffset: 5
+*FontSelectionBox*creatorShell*axisScale4.leftPosition: 15
+*FontSelectionBox*creatorShell*axisScale4.decimalPoints: 0
+*FontSelectionBox*creatorShell*axisScale4.orientation: horizontal
+*FontSelectionBox*creatorShell*axisScale4.showValue: false
+*FontSelectionBox*creatorShell*axisScale4.topOffset: 5
+
+*FontSelectionBox*creatorShell*axisMin4.topOffset: 0
+*FontSelectionBox*creatorShell*axisMin4.leftOffset: 0
+
+*FontSelectionBox*creatorShell*axisMax4.topOffset: 0
+*FontSelectionBox*creatorShell*axisMax4.rightOffset: 0
+
+*FontSelectionBox*creatorShell*faceLabel.leftPosition: 60
+*FontSelectionBox*creatorShell*faceLabel.leftOffset: 10
+*FontSelectionBox*creatorShell*faceLabel.labelString: Faces
+*FontSelectionBox*creatorShell*faceLabel.topOffset: 0
+
+*FontSelectionBox*creatorShell*faceListSW.leftPosition: 60
+*FontSelectionBox*creatorShell*faceListSW.leftOffset: 10
+*FontSelectionBox*creatorShell*faceListSW.topOffset: 0
+*FontSelectionBox*creatorShell*faceListSW.bottomPosition: 30
+
+*FontSelectionBox*creatorShell*blendLabel.leftPosition: 60
+*FontSelectionBox*creatorShell*blendLabel.leftOffset: 10
+*FontSelectionBox*creatorShell*blendLabel.topPosition: 30
+*FontSelectionBox*creatorShell*blendLabel.topOffset: 8
+*FontSelectionBox*creatorShell*blendLabel.labelString: Blends
+
+*FontSelectionBox*creatorShell*blendListSW.leftPosition: 60
+*FontSelectionBox*creatorShell*blendListSW.leftOffset: 10
+*FontSelectionBox*creatorShell*blendListSW.topOffset: 0
+
+*FontSelectionBox*creatorShell*nameLabel.labelString: Name
+*FontSelectionBox*creatorShell*nameLabel.rightPosition: 60
+*FontSelectionBox*creatorShell*nameLabel.rightOffset:-5
+*FontSelectionBox*creatorShell*nameLabel.bottomOffset: 8
+
+*FontSelectionBox*creatorShell*nameText.leftPosition: 60
+*FontSelectionBox*creatorShell*nameText.leftOffset: 8
+*FontSelectionBox*creatorShell*nameText.rightOffset: 3
+
+*FontSelectionBox*creatorShell*deleteButton.labelString: Delete
+
+*FontSelectionBox*creatorShell*replaceButton.labelString: Replace
+
+*FontSelectionBox*creatorShell*addButton.labelString: Add
+
+*FontSelectionBox*creatorShell*generateButton.labelString: Generate Name
+*FontSelectionBox*creatorShell*generateButton.rightOffset: 20
+
+*FontSelectionBox*creatorShell*optionsButton.labelString: Options...
+
+*FontSelectionBox*creatorShell*dismissButton.labelString: Dismiss
+
+*FontSelectionBox*creatorShell*noNameMessage.messageString: You must enter a\n\
+name in the Name field.
+*FontSelectionBox*creatorShell*noNameMessage.dialogTitle: Font Alert
+
+*FontSelectionBox*creatorShell*usedNameMessage.messageString: That name is already in use;\n\
+pick another or use the Replace button\n\
+to change its definition.
+*FontSelectionBox*creatorShell*usedNameMessage.dialogTitle: Font Alert
+
+*FontSelectionBox*creatorShell*someUsedNameMessage.messageString: That name was already in use in\n\
+some faces; use the Replace button\n\
+to change the definition in all faces.
+*FontSelectionBox*creatorShell*someUsedNameMessage.dialogTitle: Font Alert
+
+*FontSelectionBox*creatorShell*noSuchNameMessage.messageString: That blend does not exist.
+*FontSelectionBox*creatorShell*noSuchNameMessage.dialogTitle: Font Alert
+
+*FontSelectionBox*creatorShell*sizeLabel.labelString: Size
+*FontSelectionBox*creatorShell*sizeLabel.rightPosition: 15
+*FontSelectionBox*creatorShell*sizeLabel.rightOffset: 5
+*FontSelectionBox*creatorShell*sizeLabel.bottomOffset: 12
+
+*FontSelectionBox*creatorShell*sizeTextField.columns: 4
+*FontSelectionBox*creatorShell*sizeTextField.leftPosition: 15
+*FontSelectionBox*creatorShell*sizeTextField.bottomOffset: -7
+*FontSelectionBox*creatorShell*sizeTextField.verifyBell: False
+*FontSelectionBox*sizeTextField.value: 36
+
+*FontSelectionBox*creatorShell*other.labelString: ...
+
+*FontSelectionBox*creatorShell*sizeOptionMenu.labelString:
+*FontSelectionBox*creatorShell*sizeOptionMenu.bottomOffset: -9
+*FontSelectionBox*creatorShell*sizeOptionMenu.leftOffset: -5
+
+*FontSelectionBox*creatorShell*optionBox_popup.title: Font Creator Options
+*FontSelectionBox*creatorShell*doAllToggle.labelString: Apply blend list changes to all faces
+*FontSelectionBox*creatorShell*followSizeToggle.labelString: Reflect font size in OpticalSize axis
+*FontSelectionBox*creatorShell*dismissOptionButton.labelString: Dismiss
+
diff --git a/nx-X11/lib/dpstk/Imakefile b/nx-X11/lib/dpstk/Imakefile
new file mode 100644
index 000000000..323e584f6
--- /dev/null
+++ b/nx-X11/lib/dpstk/Imakefile
@@ -0,0 +1,91 @@
+XCOMM $XFree86: xc/lib/dpstk/Imakefile,v 1.5 2000/05/23 19:32:52 dawes Exp $
+
+#define DoNormalLib NormalLibDpsTk
+#define DoSharedLib SharedLibDpsTk
+#define DoExtraLib SharedLibDpsTk
+#define DoDebugLib DebugLibDpsTk
+#define DoProfileLib ProfileLibDpsTk
+#define LibName dpstk
+#define SoRev SODPSTKREV
+#define LibHeaders NO
+
+#ifdef SharedDPSTKReqs
+REQUIREDLIBS = SharedDPSTKReqs
+#endif
+
+ PSWRAP = PsWrap
+
+#if HasMotif
+INCLUDES = $(MOTIFINCLUDES)
+
+MOTIFSRCS = FSBwraps.c FontSample.c FontSB.c FontCreato.c \
+ CSBwraps.c ColorSB.c DSWwraps.c DPSScrollW.c
+MOTIFOBJS = FSBwraps.o FontSample.o FontSB.o FontCreato.o \
+ CSBwraps.o ColorSB.o DSWwraps.o DPSScrollW.o
+#endif
+
+#ifndef DefaultResourcePath
+#define DefaultResourcePath NULL
+#endif
+RESPATH = DefaultResourcePath
+
+#if NoStrstr
+ DEFINES = -DNO_STRSTR_AVAILABLE -DDEFAULT_RESOURCE_PATH=\"${RESPATH}\"
+#else
+ DEFINES = -DDEFAULT_RESOURCE_PATH=\"${RESPATH}\"
+#endif
+
+
+DERIVED_FILES = FSBwraps.c FSBwraps.h XDPSpwraps.c XDPSpwraps.h \
+ XDPSswraps.c XDPSswraps.h CSBwraps.c CSBwraps.h \
+ DSWwraps.c DSWwraps.h
+
+SRCS = XDPSpwraps.c XDPSswraps.c XDPSshare.c XDPSpreview.c \
+ XDPSuserpath.c
+
+OBJS = XDPSpwraps.o XDPSswraps.o XDPSshare.o XDPSpreview.o \
+ XDPSuserpath.o
+
+#include <Library.tmpl>
+
+.SUFFIXES: .psw
+
+.psw.c :
+ RunProgram(PSWRAP,-o $*.c -a -f $*.h -h $*.h $<)
+
+includes:: $(SRCS)
+
+#if HasMotif
+
+includes:: $(MOTIFSRCS)
+
+#if DoSharedLib
+SharedDepLibraryTarget(dpstkXm,$(SODPSREV),$(MOTIFOBJS),$(MOTIFOBJS) $(MOTIFLIB) $(DPSTKLIB) $(PSRESLIB),.,.)
+InstallSharedLibrary(dpstkXm,$(SODPSREV),$(USRLIBDIR))
+#endif
+#if DoNormalLib
+#if DoSharedLib
+UnsharedLibraryTarget(dpstkXm,$(MOTIFOBJS),unshared,..)
+#else
+NormalLibraryTarget(dpstkXm,$(MOTIFOBJS))
+#endif
+InstallLibrary(dpstkXm,$(USRLIBDIR))
+#endif
+#if DebugLibDps
+DebuggedLibraryTarget(dpstkXm,$(MOTIFOBJS))
+InstallLibrary(dpstkXm_d,$(USRLIBDIR))
+#endif
+#if ProfileLibDps
+ProfiledLibraryTarget(dpstkXm,$(MOTIFOBJS))
+InstallDpsProfiledLibrary(dpstkXm_p,$(USRLIBDIR))
+#endif
+
+InstallAppDefaults(FontSelect)
+InstallAppDefaults(ColorSelect)
+#endif /* HasMotif */
+
+clean ::
+ ${RM} $(DERIVED_FILES) $(MOTIFOBJS)
+
+DependTarget()
+
diff --git a/nx-X11/lib/dpstk/XDPSpreview.c b/nx-X11/lib/dpstk/XDPSpreview.c
new file mode 100644
index 000000000..d36331b71
--- /dev/null
+++ b/nx-X11/lib/dpstk/XDPSpreview.c
@@ -0,0 +1,636 @@
+/*
+ * XDPSpreview.c
+ *
+ * (c) Copyright 1990-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+#include <X11/Xlib.h>
+#include <DPS/dpsXclient.h>
+#include <DPS/XDPSlib.h>
+#include <DPS/psops.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef NeXT
+#include <unistd.h>
+#endif
+
+#include <DPS/dpsXshare.h>
+#include <DPS/dpsXpreview.h>
+#include "XDPSpwraps.h"
+#include "dpsXcommonI.h"
+#include <math.h>
+#include <X11/Xos.h>
+
+#if defined(hpux) || defined(AIXV3)
+#define SELECT_TYPE int *
+#else
+#define SELECT_TYPE fd_set *
+#endif
+
+#define BEGINDOCUMENTLEN 15 /* Length of "%%BeginDocument" */
+#define BEGINBINARYLEN 14 /* Length of "%%BeginBinary:" */
+
+static int ParseFileForBBox(FILE *file, XRectangle *bb);
+static void FillPixmapWithGray(
+ Screen *screen,
+ Drawable dest,
+ XRectangle *bbox,
+ int xOffset, int yOffset,
+ double pixelsPerPoint,
+ Bool createMask);
+
+static XDPSRewindFunction rewindFunction = XDPSFileRewindFunc;
+static DPSPointer rewindClientData = NULL;
+static XDPSGetsFunction getsFunction = XDPSFileGetsFunc;
+static DPSPointer getsClientData = NULL;
+
+int XDPSSetFileFunctions(
+ XDPSRewindFunction rewindFunc,
+ DPSPointer rewindData,
+ XDPSGetsFunction getsFunc,
+ DPSPointer getsData)
+{
+ if (rewindFunc != NULL) {
+ rewindFunction = rewindFunc;
+ rewindClientData = rewindData;
+ }
+ if (getsFunc != NULL) {
+ getsFunction = getsFunc;
+ getsClientData = getsData;
+ }
+ return 0;
+}
+
+/* ARGSUSED */
+
+void XDPSFileRewindFunc(FILE *f, DPSPointer data)
+{
+ rewind(f);
+}
+
+/* ARGSUSED */
+
+char *XDPSFileGetsFunc(char *buf, int n, FILE *f, DPSPointer data)
+{
+ return fgets(buf, n, f);
+}
+
+void XDPSEmbeddedEPSFRewindFunc(FILE *f, DPSPointer data)
+{
+ XDPSPosition *p = (XDPSPosition *) data;
+
+ p->nestingLevel = 0;
+ p->continuedLine = False;
+ p->binaryCount = 0;
+
+ if (fseek(f, p->startPos, SEEK_SET) != 0) {
+ (void) fseek(f, 0L, SEEK_END); /* Go to the end */
+ }
+}
+
+static Bool imaging = False;
+
+char *XDPSEmbeddedGetsFunc(char *buf, int n, FILE *f, DPSPointer data)
+{
+ XDPSPosition *p = (XDPSPosition *) data;
+ int count;
+ unsigned len;
+
+ if (fgets(buf, n, f) == NULL) {
+ if (imaging) p->startPos = -1;
+ return NULL;
+ }
+
+ /* If previous call didn't get a whole line, we're somewhere in the
+ middle, so don't check for comments. Also, if we're in the middle of
+ binary data, don't look for comments either. */
+
+ len = strlen(buf);
+
+ if (p->binaryCount != 0) {
+ if (len > p->binaryCount) p->binaryCount = 0;
+ else p->binaryCount -= len;
+
+ } else if (!p->continuedLine) {
+ if (strncmp(buf, "%%BeginDocument", BEGINDOCUMENTLEN) == 0) {
+ p->nestingLevel++;
+
+ } else if (strncmp(buf, "%%BeginBinary:", BEGINBINARYLEN) == 0) {
+ count = sscanf(buf, "%%%%BeginBinary: %lu", &p->binaryCount);
+ if (count != 1) p->binaryCount = 0; /* Malformed comment */
+
+ } else if (strcmp(buf, "%%EndDocument\n") == 0) {
+ if (p->nestingLevel == 0) {
+ if (imaging) p->startPos = ftell(f);
+ return NULL;
+ }
+ else p->nestingLevel--;
+ }
+ }
+
+ if ((int)len == n-1 && buf[n-1] != '\n') p->continuedLine = True;
+ else p->continuedLine = False;
+
+ return buf;
+}
+
+int XDPSCreatePixmapForEPSF(
+ DPSContext context,
+ Screen *screen,
+ FILE *epsf,
+ int depth,
+ double pixelsPerPoint,
+ Pixmap *pixmap,
+ XRectangle *pixelSize,
+ XRectangle *bbox)
+{
+ Pixmap p;
+ int width, height;
+ XRectangle bb;
+
+ if (screen == NULL || depth <= 0 ||
+ pixelsPerPoint <= 0) {
+ return dps_status_illegal_value;
+ }
+
+ if (context == NULL) {
+ context = XDPSGetSharedContext(DisplayOfScreen(screen));
+ }
+
+ (*rewindFunction)(epsf, rewindClientData);
+
+ if (ParseFileForBBox(epsf, &bb) == dps_status_failure) {
+ return dps_status_failure;
+ }
+
+ width = ceil(bb.width * pixelsPerPoint);
+ height = ceil(bb.height * pixelsPerPoint);
+ if (width <= 0 || height <= 0) return dps_status_failure;
+
+ p = XCreatePixmap(DisplayOfScreen(screen), RootWindowOfScreen(screen),
+ width, height, depth);
+
+ if (pixmap != NULL) *pixmap = p;
+ if (pixelSize != NULL) {
+ pixelSize->x = pixelSize->y = 0;
+ pixelSize->width = width;
+ pixelSize->height = height;
+ }
+ if (bbox != NULL) *bbox = bb;
+
+ if (context != NULL) return dps_status_success;
+ else return dps_status_no_extension;
+}
+
+static int ParseFileForBBox(FILE *file, XRectangle *bb)
+{
+#define BBOXLEN 14 /* Length of "%%BoundingBox:" */
+#define BUFLEN 256
+#define ATENDLEN 8 /* Length of "(atend)" plus one byte for \0 */
+ char buf[BUFLEN];
+ char buf2[ATENDLEN];
+ Bool atend = False; /* Found a %%BoundingBox: (atend) */
+ float x, y, r, t;
+ int n;
+ int nestingLevel = 0;
+ unsigned long binaryCount = 0;
+ Bool continuedLine = False;
+ unsigned len;
+
+ while (1) {
+ if ((*getsFunction)(buf, BUFLEN, file, getsClientData) == NULL) {
+ return dps_status_failure;
+ }
+
+ len = strlen(buf);
+
+ /* If in binary data or continued line, ignore everything */
+
+ if (binaryCount != 0) {
+ if (len > binaryCount) binaryCount = 0;
+ else binaryCount -= len;
+
+ } else if (!continuedLine) {
+ if (strncmp(buf, "%%BeginBinary:", BEGINBINARYLEN) == 0) {
+ n = sscanf(buf, "%%%%BeginBinary: %lu", &binaryCount);
+ if (n != 1) binaryCount = 0; /* Malformed comment */
+
+ } else if (strncmp(buf, "%%BeginDocument", BEGINDOCUMENTLEN) == 0) {
+ nestingLevel++;
+
+ } else if (strcmp(buf, "%%EndDocument\n") == 0) {
+ nestingLevel--;
+
+ /* Only check for bounding box comments at nesting level 0 */
+
+ } else if (nestingLevel == 0) {
+
+ /* If we haven't already hit an (atend), the end of the
+ comments is a good place to stop looking for the bbox */
+
+ if (!atend && (strcmp(buf, "%%EndComments\n") == 0 ||
+ strcmp(buf, "%%EndProlog\n") == 0)) {
+ return dps_status_failure;
+ }
+
+ if (strncmp(buf, "%%BoundingBox:", BBOXLEN) == 0) {
+ n = sscanf(buf, "%%%%BoundingBox: %f %f %f %f",
+ &x, &y, &r, &t);
+
+ if (n != 4) {
+ n = sscanf(buf, "%%%%BoundingBox: %7s", buf2);
+
+ if (n == 1 && strcmp(buf2, "(atend)") == 0) {
+ atend = True;
+ } else return dps_status_failure;
+
+ } else {
+ bb->x = (int) x;
+ bb->y = (int) y;
+ bb->width = r - bb->x;
+ if ((float)((int) r) != r) bb->width++;
+ bb->height = t - bb->y;
+ if ((float)((int) t) != t) bb->height++;
+ return dps_status_success;
+ }
+ }
+ }
+ }
+
+ /* See if this line fills the buffer */
+ if (len == BUFLEN-1 && buf[BUFLEN-1] != '\n') continuedLine = True;
+ }
+
+#undef ATENDLEN
+#undef BUFLEN
+#undef BBOXLEN
+}
+
+#define mmPerPoint (25.4/72.0)
+
+double XDPSPixelsPerPoint(Screen *screen)
+{
+ return (float) WidthOfScreen(screen) * mmPerPoint /
+ (float) WidthMMOfScreen(screen);
+}
+
+static int timeStart = 200, maxDoubles = 3;
+
+void XDPSSetImagingTimeout(int timeout, int max)
+{
+ timeStart = timeout;
+ maxDoubles = max;
+}
+
+typedef struct _StatusInfo {
+ DPSContext ctxt;
+ DPSPointer cookie;
+ Bool *doneFlag;
+ unsigned long startReqNum, endReqNum;
+ XDPSStatusProc oldProc;
+ struct _StatusInfo *next, *prev;
+} StatusInfo;
+
+static StatusInfo *StatusList;
+
+static void SetUpStatusVariables(
+ DPSContext context,
+ DPSPointer cookie,
+ Bool *doneFlag,
+ unsigned long startReq,
+ XDPSStatusProc oldProc)
+{
+ StatusInfo *info = (StatusInfo *) malloc(sizeof(StatusInfo));
+
+ info->ctxt = context;
+ info->cookie = cookie;
+ info->doneFlag = doneFlag;
+ info->startReqNum = startReq;
+ info->endReqNum = 0xFFFFFFFF;
+ info->oldProc = oldProc;
+ if (StatusList != NULL) StatusList->prev = info;
+ info->next = StatusList;
+ info->prev = NULL;
+ StatusList = info;
+}
+
+static void SetEndReqNum(
+ DPSContext context,
+ unsigned long endReq)
+{
+ StatusInfo *info = StatusList;
+
+ while (info != NULL && info->ctxt != context) info = info->next;
+ if (info != NULL) info->endReqNum = endReq;
+}
+
+static void HandlePreviewStatus(
+ DPSContext context,
+ int status)
+{
+ unsigned long serial;
+ Display *dpy;
+ StatusInfo *info = StatusList;
+
+ while (info != NULL && info->ctxt != context) info = info->next;
+ if (info == NULL) return;
+
+ (void) XDPSXIDFromContext(&dpy, context);
+ serial = LastKnownRequestProcessed(dpy);
+
+ /* This event is from before our imaging; send to old status proc. */
+ if (serial < info->startReqNum) {
+ (*info->oldProc) (context, status);
+ return;
+ }
+
+ /* This event is from during our imaging; ignore it */
+ if (serial < info->endReqNum) return;
+
+ /* This event is juuuuust right. */
+ if (status == PSFROZEN) *info->doneFlag = True;
+}
+
+static int FinishUp(
+ DPSContext context,
+ DPSPointer cookie)
+{
+ static char restorebuf[] =
+ "\n$Adobe$DPS$Lib$Dict /EPSFsave get restore grestore\n";
+ StatusInfo *info = StatusList;
+ int err;
+
+ /* Check the results of the imaging: Get the error status and restore the
+ context */
+
+ _DPSPCheckForError(context, &err);
+
+ /* Can't do this is a wrap because of restore semantics */
+ DPSWritePostScript(context, restorebuf, strlen(restorebuf));
+
+ (void) XDPSPopContextParameters(cookie);
+
+ /* See if we have an info record and delete it if so */
+ while (info != NULL && info->ctxt != context) info = info->next;
+ if (info != NULL) {
+ if (info == StatusList) StatusList = info->next;
+ else info->prev->next = info->next;
+ if (info->next != NULL) info->next->prev = info->prev;
+ XDPSRegisterStatusProc(context, info->oldProc);
+ free(info);
+ }
+
+ if (err) return dps_status_postscript_error;
+ else return dps_status_success;
+}
+
+int XDPSCheckImagingResults(
+ DPSContext context,
+ Screen *screen)
+{
+ StatusInfo *info = StatusList;
+ int status;
+
+ if (context == NULL) {
+ context = XDPSGetSharedContext(DisplayOfScreen(screen));
+ if (context == NULL) return dps_status_no_extension;
+ }
+
+ while (info != NULL && info->ctxt != context) info = info->next;
+ if (info == NULL) return dps_status_illegal_value;
+
+ status = XDPSGetContextStatus(context);
+ if (status != PSFROZEN) return dps_status_imaging_incomplete;
+
+ XDPSUnfreezeContext(context);
+ return FinishUp(context, info->cookie);
+}
+
+static void msleep(int ms)
+{
+ struct timeval incr;
+
+ incr.tv_sec = ms / 1000;
+ incr.tv_usec = (ms % 1000) * 1000;
+ (void) select (0, (SELECT_TYPE) NULL, (SELECT_TYPE) NULL,
+ (SELECT_TYPE) NULL, &incr);
+}
+
+int XDPSImageFileIntoDrawable(
+ DPSContext context,
+ Screen *screen,
+ Drawable dest,
+ FILE *file,
+ int drawableHeight,
+ int drawableDepth,
+ XRectangle *bbox,
+ int xOffset, int yOffset,
+ double pixelsPerPoint,
+ Bool clear, Bool createMask,
+ Bool waitForCompletion,
+ Bool *doneFlag)
+{
+#define BUFSIZE 256
+#define EXECLEN 6
+ char buf[BUFSIZE];
+ static char eobuf[] = "\n$Adobe$DPS$Lib$Dict /execSuccess true put\n\
+stop\n\
+Magic end of data line )))))))))) 99#2 2#99 <xyz> // 7gsad,32h4ghNmndFgj2\n";
+ XDPSStandardColormap maskMap;
+ XDPSStandardColormap rgbMap;
+ unsigned int flags = 0;
+ int status;
+ Bool inited;
+ DPSPointer cookie;
+ int doublings;
+ int ms;
+ XDPSStatusProc oldProc;
+ unsigned long startReqNum = 0, endReqNum;
+
+ if (screen == NULL || dest == None ||
+ drawableHeight <= 0 || drawableDepth <= 0 ||
+ pixelsPerPoint <= 0) {
+ return dps_status_illegal_value;
+ }
+
+ if (context == NULL) {
+ context = XDPSGetSharedContext(DisplayOfScreen(screen));
+ if (context == NULL) {
+ FillPixmapWithGray(screen, dest, bbox, xOffset, yOffset,
+ pixelsPerPoint,
+ createMask);
+ return dps_status_no_extension;
+ }
+ }
+
+ (*rewindFunction)(file, rewindClientData);
+
+ if (!waitForCompletion) {
+ DPSWaitContext(context);
+ /* Any status events before this point go to old handler */
+ startReqNum = NextRequest(DisplayOfScreen(screen));
+ }
+
+ status = _XDPSTestComponentInitialized(context,
+ dps_init_bit_preview, &inited);
+ if (status != dps_status_success) return status;
+ if (!inited) {
+ (void) _XDPSSetComponentInitialized(context, dps_init_bit_preview);
+ _DPSPDefineExecFunction(context);
+ }
+
+ if (createMask) {
+ if (drawableDepth != 1) return dps_status_illegal_value;
+ maskMap.colormap = None;
+ maskMap.red_max = 1;
+ maskMap.red_mult = -1;
+ maskMap.base_pixel = 1;
+ rgbMap.colormap = None;
+ rgbMap.red_max = rgbMap.green_max = rgbMap.blue_max =
+ rgbMap.red_mult = rgbMap.green_mult = rgbMap.blue_mult =
+ rgbMap.base_pixel = 0;
+ flags = XDPSContextGrayMap | XDPSContextRGBMap;
+ }
+
+ status = XDPSPushContextParameters(context, screen, drawableDepth,
+ dest, drawableHeight,
+ &rgbMap, &maskMap,
+ flags | XDPSContextScreenDepth |
+ XDPSContextDrawable, &cookie);
+
+ if (status != dps_status_success) return status;
+
+ _DPSPSetMatrix(context, xOffset, yOffset, pixelsPerPoint);
+
+ if (clear) _DPSPClearArea(context, (int) bbox->x, (int) bbox->y,
+ (int) bbox->width, (int) bbox->height);
+
+ if (createMask) _DPSPSetMaskTransfer(context);
+
+ /* Prepare to read PostScript code */
+ _DPSPSaveBeforeExec(context, !waitForCompletion);
+ DPSWritePostScript(context, "\nexec\n", EXECLEN);
+
+ imaging = True;
+ while ((*getsFunction)(buf, BUFSIZE, file, getsClientData) != NULL) {
+ DPSWritePostScript(context, buf, strlen(buf));
+ }
+ imaging = False;
+
+ /* This marks the end of the data stream */
+ DPSWritePostScript(context, eobuf, strlen(eobuf));
+
+ if (!waitForCompletion) {
+ *doneFlag = False;
+ oldProc = XDPSRegisterStatusProc(context, HandlePreviewStatus);
+ SetUpStatusVariables(context, cookie, doneFlag, startReqNum, oldProc);
+ XDPSSetStatusMask(context, 0, 0, PSFROZENMASK);
+
+ ms = timeStart;
+
+ /* Check for done until we run out of time */
+ doublings = 0;
+ while (1) {
+ if (XDPSGetContextStatus(context) == PSFROZEN) {
+ waitForCompletion = True;
+ XDPSUnfreezeContext(context);
+ break;
+ }
+ if (doublings >= maxDoubles) break;
+
+ /* Wait a while */
+ msleep(ms);
+ ms *= 2;
+ doublings++;
+ }
+ }
+
+ /* If previous decided imaging is done, it changed waitForCompletion */
+
+ if (waitForCompletion) return FinishUp(context, cookie);
+ else {
+ endReqNum = NextRequest(DisplayOfScreen(screen)) - 1;
+ SetEndReqNum(context, endReqNum);
+ return dps_status_imaging_incomplete;
+ }
+#undef EXECLEN
+#undef BUFSIZE
+}
+
+static void FillPixmapWithGray(
+ Screen *screen,
+ Drawable dest,
+ XRectangle *bbox,
+ int xOffset, int yOffset,
+ double pixelsPerPoint,
+ Bool createMask)
+{
+ int width, height, x, y;
+ GC gc;
+ XGCValues v;
+ static char grayBits[] = {0x01, 0x02};
+ Pixmap grayStipple;
+ Display *dpy = DisplayOfScreen(screen);
+
+ width = ceil(bbox->width * pixelsPerPoint);
+ height = ceil(bbox->height * pixelsPerPoint);
+ x = (bbox->x + xOffset) * pixelsPerPoint;
+ y = (bbox->y + yOffset) * pixelsPerPoint;
+
+ if (createMask) {
+ v.foreground = 1;
+ v.function = GXcopy;
+
+ gc = XCreateGC(dpy, dest, GCForeground | GCFunction, &v);
+ XFillRectangle(dpy, dest, gc, x, y, width, height);
+ XFreeGC(dpy, gc);
+ return;
+ }
+
+ grayStipple = XCreateBitmapFromData(dpy, dest, grayBits, 2, 2);
+
+ v.foreground = BlackPixelOfScreen(screen);
+ v.background = WhitePixelOfScreen(screen);
+ v.function = GXcopy;
+ v.stipple = grayStipple;
+ v.fill_style = FillOpaqueStippled;
+ gc = XCreateGC(dpy, dest, GCForeground | GCBackground | GCFunction |
+ GCStipple | GCFillStyle, &v);
+ XFillRectangle(dpy, dest, gc, x, y, width, height);
+ XFreeGC(dpy, gc);
+ XFreePixmap(dpy, grayStipple);
+}
diff --git a/nx-X11/lib/dpstk/XDPSpwraps.psw b/nx-X11/lib/dpstk/XDPSpwraps.psw
new file mode 100644
index 000000000..b5ff4c4bd
--- /dev/null
+++ b/nx-X11/lib/dpstk/XDPSpwraps.psw
@@ -0,0 +1,97 @@
+/*
+ * XDPSpwraps.psw
+ *
+ * (c) Copyright 1990-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps _DPSPSetMatrix(DPSContext ctxt; int xOffset, yOffset;
+ double pixelsPerPoint)
+ gsave
+ initmatrix
+ 1 1 idtransform abs exch abs exch scale
+ % matrix is identity modulo sign
+ pixelsPerPoint dup scale
+ xOffset yOffset translate
+endps
+
+defineps _DPSPClearArea(DPSContext ctxt; int x, y, width, height)
+ 1 setgray
+ x y width height rectfill
+endps
+
+defineps _DPSPSetMaskTransfer(DPSContext ctxt)
+ {pop 0} dup dup dup setcolortransfer
+ {pop 0} settransfer
+endps
+
+defineps _DPSPDefineExecFunction(DPSContext ctxt)
+ $Adobe$DPS$Lib$Dict begin
+ /ExecPS {
+ $Adobe$DPS$Lib$Dict /doclientsync 3 -1 roll put
+ $Adobe$DPS$Lib$Dict /execSuccess false put
+ (%stdin) (r) file
+ cvx stopped
+ pop % always true
+ % Flush until you get the magic line
+ {
+ {currentfile 256 string readline} stopped
+ pop % don't care stopped result
+ pop % don't care readline bool result
+(Magic end of data line \)\)\)\)\)\)\)\)\)\) 99#2 2#99 <xyz> // 7gsad,32h4ghNmndFgj2)
+ eq
+ {exit} if
+ } loop
+ $Adobe$DPS$Lib$Dict /doclientsync get {
+ clientsync
+ } if
+ } def end
+endps
+
+defineps _DPSPSaveBeforeExec(DPSContext ctxt; boolean noWait)
+ $Adobe$DPS$Lib$Dict /EPSFsave save put
+ clear cleardictstack
+ /showpage {} def
+ 0 setgray 0 setlinecap
+ 1 setlinewidth 0 setlinejoin
+ 10 setmiterlimit [] 0 setdash newpath
+ noWait
+ $Adobe$DPS$Lib$Dict /ExecPS get
+endps
+
+defineps _DPSPCheckForError(DPSContext ctxt | boolean *err)
+ $Adobe$DPS$Lib$Dict /execSuccess get not err
+ clear
+ cleardictstack
+endps
diff --git a/nx-X11/lib/dpstk/XDPSshare.c b/nx-X11/lib/dpstk/XDPSshare.c
new file mode 100644
index 000000000..ef146db4e
--- /dev/null
+++ b/nx-X11/lib/dpstk/XDPSshare.c
@@ -0,0 +1,727 @@
+/*
+ * XDPSshare.c
+ *
+ * (c) Copyright 1990-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86: xc/lib/dpstk/XDPSshare.c,v 1.2 2000/06/07 22:03:01 tsi Exp $ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <X11/Xlib.h>
+
+#include <DPS/dpsXclient.h>
+#include <DPS/dpsops.h>
+#include <DPS/XDPSlib.h>
+#include <DPS/dpsXshare.h>
+
+#include "XDPSswraps.h"
+#include "dpsXcommonI.h"
+
+static int extensionId = 0;
+
+/*
+ Alloc...Info allocates an info entry and stores it at the head of the list.
+ Find...Info looks for an info entry and returns NULL if not found.
+ Lookup...Info looks for an info entry and creates one if not found.
+*/
+
+typedef struct _ContextInfoRec {
+ int extensionId;
+ DPSContextExtensionRec next;
+ DPSContext text;
+ Bool enableText;
+ unsigned long initFlags;
+ struct _DisplayInfoRec *displayInfo;
+} ContextInfoRec, *ContextInfo;
+
+typedef enum {ext_yes, ext_no, ext_no_idea} ExtensionStatus;
+
+typedef struct _DisplayInfoRec {
+ Display *display;
+ ExtensionStatus extensionPresent;
+ DPSContext defaultContext;
+ int *depthsForScreen;
+ int **validDepths;
+ GC **gcForDepth;
+ struct _DisplayInfoRec *next;
+} DisplayInfoRec, *DisplayInfo;
+
+/* If a display is in displayList, it means that we have looked to see if
+ the extension exists on the display. If context is not NULL, the
+ display has a default context associated with it. */
+
+static DisplayInfo displayList = NULL;
+
+static DisplayInfo LookupDisplayInfo(Display *display);
+
+static ContextInfo AllocContextInfo(DPSContext context)
+{
+ ContextInfo c = (ContextInfo) calloc(1, sizeof(ContextInfoRec));
+
+ if (extensionId == 0) extensionId = DPSGenerateExtensionRecID();
+
+ c->extensionId = extensionId;
+ DPSAddContextExtensionRec(context, (DPSContextExtensionRec *) c);
+
+ return c;
+}
+
+static ContextInfo FindContextInfo(DPSContext context)
+{
+ if (extensionId == 0) extensionId = DPSGenerateExtensionRecID();
+
+ return (ContextInfo) DPSGetContextExtensionRec(context, extensionId);
+}
+
+static ContextInfo RemoveContextInfo(DPSContext context)
+{
+ return (ContextInfo) DPSRemoveContextExtensionRec(context,
+ extensionId);
+}
+
+/* May only be called for a display in the display list. */
+
+static ContextInfo LookupContext(
+ Display *display,
+ DPSContext context)
+{
+ ContextInfo c = FindContextInfo(context);
+
+ if (c != NULL) return c;
+
+ /* Create one */
+
+ c = AllocContextInfo(context);
+ c->displayInfo = LookupDisplayInfo(display);
+ return c;
+}
+
+static DisplayInfo AllocDisplayInfo(
+ Display *display,
+ DPSContext context)
+{
+ DisplayInfo d = (DisplayInfo) malloc(sizeof(DisplayInfoRec));
+ register int i;
+
+ if (d == NULL) return NULL;
+ d->next = displayList;
+ displayList = d;
+
+ d->display = display;
+ d->defaultContext = context;
+ d->extensionPresent = (context == NULL) ? ext_no_idea : ext_yes;
+
+ d->depthsForScreen = (int *) calloc(ScreenCount(display), sizeof(int));
+ d->validDepths = (int **) calloc(ScreenCount(display), sizeof(int *));
+ d->gcForDepth = (GC **) calloc(ScreenCount(display), sizeof(GC *));
+
+ for (i = 0; i < ScreenCount(display); i++) {
+ d->validDepths[i] = XListDepths(display, i, &d->depthsForScreen[i]);
+ d->gcForDepth[i] = (GC *) calloc(d->depthsForScreen[i], sizeof(GC));
+ }
+
+ return d;
+}
+
+static DisplayInfo FindDisplayInfo(Display *display)
+{
+ DisplayInfo d = displayList;
+
+ while (d != NULL && d->display != display) d = d->next;
+ return d;
+}
+
+static DisplayInfo LookupDisplayInfo(Display *display)
+{
+ DisplayInfo d = FindDisplayInfo(display);
+
+ if (d == NULL) d = AllocDisplayInfo(display, (DPSContext) NULL);
+
+ return d;
+}
+
+int _XDPSSetComponentInitialized(DPSContext context, unsigned long bit)
+{
+ ContextInfo c = FindContextInfo(context);
+
+ if (c == NULL) return dps_status_unregistered_context;
+ c->initFlags |= bit;
+ return dps_status_success;
+}
+
+int _XDPSTestComponentInitialized(
+ DPSContext context,
+ unsigned long bit,
+ Bool *result)
+{
+ ContextInfo c = FindContextInfo(context);
+
+ if (c == NULL) {
+ *result = False;
+ return dps_status_unregistered_context;
+ }
+ *result = ((c->initFlags & bit) != 0);
+ return dps_status_success;
+}
+
+int XDPSSetContextDepth(
+ DPSContext context,
+ Screen *screen,
+ int depth)
+{
+ return XDPSSetContextParameters(context, screen, depth, None, 0,
+ (XDPSStandardColormap *) NULL,
+ (XDPSStandardColormap *) NULL,
+ XDPSContextScreenDepth);
+}
+
+int XDPSSetContextDrawable(
+ DPSContext context,
+ Drawable drawable,
+ int height)
+{
+ if (drawable != None && height <= 0) return dps_status_illegal_value;
+ _DPSSSetContextDrawable(context, drawable, height);
+ return dps_status_success;
+}
+
+int XDPSSetContextRGBMap(
+ DPSContext context,
+ XDPSStandardColormap *map)
+{
+ return XDPSSetContextParameters(context, (Screen *) NULL, 0, None, 0,
+ map, (XDPSStandardColormap *) NULL,
+ XDPSContextRGBMap);
+}
+
+int XDPSSetContextGrayMap(
+ DPSContext context,
+ XDPSStandardColormap *map)
+{
+ return XDPSSetContextParameters(context, (Screen *) NULL, 0, None, 0,
+ map, (XDPSStandardColormap *) NULL,
+ XDPSContextGrayMap);
+}
+
+static GC DisplayInfoSharedGC(DisplayInfo d, Screen *screen, int depth)
+{
+ int s = XScreenNumberOfScreen(screen);
+ register int i;
+ XGCValues v;
+ Pixmap p;
+
+ if (s >= ScreenCount(DisplayOfScreen(screen))) return NULL;
+
+ for (i = 0; i < d->depthsForScreen[s] &&
+ d->validDepths[s][i] != depth; i++) {}
+
+ if (i >= d->depthsForScreen[s]) return NULL;
+
+ if (d->gcForDepth[s][i] == 0) { /* Not "None" -- used calloc */
+ if (depth == DefaultDepthOfScreen(screen)) {
+ d->gcForDepth[s][i] = XCreateGC(d->display,
+ RootWindowOfScreen(screen), 0, &v);
+ } else {
+ p = XCreatePixmap(d->display,
+ RootWindowOfScreen(screen),
+ 1, 1, depth);
+ d->gcForDepth[s][i] = XCreateGC(d->display, p, 0, &v);
+ XFreePixmap(d->display, p);
+ }
+ }
+
+ return d->gcForDepth[s][i];
+}
+
+int XDPSSetContextParameters(
+ DPSContext context,
+ Screen *screen,
+ int depth,
+ Drawable drawable,
+ int height,
+ XDPSStandardColormap *rgbMap,
+ XDPSStandardColormap *grayMap,
+ unsigned int flags)
+{
+ ContextInfo c = FindContextInfo(context);
+ Bool doDepth = False, doDrawable = False, doRGB = False, doGray = False;
+ Colormap map = None;
+ XStandardColormap cmap;
+ GC gc;
+ GContext gctx = None;
+ DisplayInfo d;
+ Display *dpy;
+ int rgb_base_pixel = 0;
+ int red_max = 0;
+ int red_mult = 0;
+ int green_max = 0;
+ int green_mult = 0;
+ int blue_max = 0;
+ int blue_mult = 0;
+ int gray_base_pixel = 0;
+ int gray_max = 0;
+ int gray_mult = 0;
+
+ if (c == NULL) return dps_status_unregistered_context;
+ d = c->displayInfo;
+
+ (void) XDPSXIDFromContext(&dpy, context);
+
+ if (flags & XDPSContextScreenDepth) {
+ doDepth = True;
+
+ if (DisplayOfScreen(screen) != dpy) {
+ return dps_status_illegal_value;
+ }
+
+ gc = DisplayInfoSharedGC(d, screen, depth);
+ if (gc == NULL) return dps_status_illegal_value;
+
+ gctx = XGContextFromGC(gc);
+ }
+
+ if (flags & XDPSContextDrawable) {
+ doDrawable = True;
+ if (drawable != None && height <= 0) return dps_status_illegal_value;
+ }
+
+ if (flags & XDPSContextRGBMap) {
+ doRGB = True;
+ if (rgbMap == NULL) {
+ XDPSGetDefaultColorMaps(dpy, screen, drawable, &cmap,
+ (XStandardColormap *) NULL);
+ rgb_base_pixel = cmap.base_pixel;
+ red_max = cmap.red_max;
+ red_mult = cmap.red_mult;
+ green_max = cmap.green_max;
+ green_mult = cmap.green_mult;
+ blue_max = cmap.blue_max;
+ blue_mult = cmap.blue_mult;
+ map = cmap.colormap;
+ } else {
+ rgb_base_pixel = rgbMap->base_pixel;
+ red_max = rgbMap->red_max;
+ red_mult = rgbMap->red_mult;
+ green_max = rgbMap->green_max;
+ green_mult = rgbMap->green_mult;
+ blue_max = rgbMap->blue_max;
+ blue_mult = rgbMap->blue_mult;
+ map = rgbMap->colormap;
+ }
+ }
+
+ if (flags & XDPSContextGrayMap) {
+ doGray = True;
+ if (grayMap == NULL) {
+ XDPSGetDefaultColorMaps(dpy, screen, drawable,
+ (XStandardColormap *) NULL, &cmap);
+ gray_base_pixel = cmap.base_pixel;
+ gray_max = cmap.red_max;
+ gray_mult = cmap.red_mult;
+ if (doRGB && map != cmap.colormap) {
+ return dps_status_illegal_value;
+ } else map = cmap.colormap;
+ } else {
+ gray_base_pixel = grayMap->base_pixel;
+ gray_max = grayMap->red_max;
+ gray_mult = grayMap->red_mult;
+ if (doRGB && map != grayMap->colormap) {
+ return dps_status_illegal_value;
+ } else map = grayMap->colormap;
+ }
+ }
+
+ if (doDepth || doDrawable || doRGB || doGray) {
+ _DPSSSetContextParameters(context, gctx, drawable, height, map,
+ rgb_base_pixel, red_max, red_mult,
+ green_max, green_mult, blue_max, blue_mult,
+ gray_base_pixel, gray_max, gray_mult,
+ doDepth, doDrawable, doRGB, doGray);
+ }
+ return dps_status_success;
+}
+
+int XDPSPushContextParameters(
+ DPSContext context,
+ Screen *screen,
+ int depth,
+ Drawable drawable,
+ int height,
+ XDPSStandardColormap *rgbMap,
+ XDPSStandardColormap *grayMap,
+ unsigned int flags,
+ DPSPointer *pushCookieReturn)
+{
+ ContextInfo c = FindContextInfo(context);
+ int status;
+
+ if (c == NULL) return dps_status_unregistered_context;
+
+ DPSgsave(context);
+
+ status = XDPSSetContextParameters(context, screen, depth, drawable, height,
+ rgbMap, grayMap, flags);
+
+ *pushCookieReturn = (DPSPointer) context;
+ return status;
+}
+
+int XDPSPopContextParameters(DPSPointer pushCookie)
+{
+ DPSContext context = (DPSContext) pushCookie;
+ ContextInfo c = FindContextInfo(context);
+
+ if (c == NULL) return dps_status_illegal_value;
+
+ DPSgrestore(context);
+
+ return dps_status_success;
+}
+
+int XDPSCaptureContextGState(DPSContext context, DPSGState *gsReturn)
+{
+ *gsReturn = DPSNewUserObjectIndex();
+ /* We want to keep 0 as an unassigned value */
+ if (*gsReturn == 0) *gsReturn = DPSNewUserObjectIndex();
+
+ _DPSSCaptureGState(context, *gsReturn);
+
+ return dps_status_success;
+}
+
+int XDPSUpdateContextGState(DPSContext context, DPSGState gs)
+{
+ _DPSSUpdateGState(context, gs);
+
+ return dps_status_success;
+}
+
+int XDPSFreeContextGState(DPSContext context, DPSGState gs)
+{
+ _DPSSUndefineUserObject(context, gs);
+
+ return dps_status_success;
+}
+
+int XDPSSetContextGState(
+ DPSContext context,
+ DPSGState gs)
+{
+ _DPSSRestoreGState(context, gs);
+
+ return dps_status_success;
+}
+
+int XDPSPushContextGState(
+ DPSContext context,
+ DPSGState gs,
+ DPSPointer *pushCookieReturn)
+{
+ int status;
+
+ DPSgsave(context);
+
+ status = XDPSSetContextGState(context, gs);
+ *pushCookieReturn = (DPSPointer) context;
+ return status;
+}
+
+int XDPSPopContextGState(DPSPointer pushCookie)
+{
+ DPSContext context = (DPSContext) pushCookie;
+
+ DPSgrestore(context);
+ return dps_status_success;
+}
+
+void XDPSRegisterContext(DPSContext context, Bool makeSharedContext)
+{
+ Display *display;
+ Bool inited;
+ ContextInfo c;
+
+ /* Get the display */
+ (void) XDPSXIDFromContext(&display, context);
+
+ if (makeSharedContext) { /* Install as shared ctxt for this display */
+ c = LookupContext(display, context);
+ c->displayInfo->defaultContext = context;
+ } else { /* Just add to the context list */
+ c = LookupContext(display, context);
+ }
+
+ c->displayInfo->extensionPresent = ext_yes;
+
+ (void) _XDPSTestComponentInitialized(context, dps_init_bit_share, &inited);
+ if (!inited) {
+ (void) _XDPSSetComponentInitialized(context, dps_init_bit_share);
+ _DPSSInstallDPSlibDict(context);
+ }
+}
+
+DPSContext XDPSGetSharedContext(Display *display)
+{
+ DisplayInfo d = LookupDisplayInfo(display);
+ ContextInfo c;
+ DPSContext context;
+
+ if (d->extensionPresent == ext_no) return NULL;
+
+ if (d->defaultContext != NULL) context = d->defaultContext;
+ else {
+ context = XDPSCreateSimpleContext(display,
+ None, None, 0, 0,
+ DPSDefaultTextBackstop,
+ DPSDefaultErrorProc, NULL);
+ if (context != NULL) {
+ c = AllocContextInfo(context);
+ d->defaultContext = context;
+ c->displayInfo = d;
+ (void) _XDPSSetComponentInitialized(context, dps_init_bit_share);
+ _DPSSInstallDPSlibDict(context);
+ (void) XDPSSetContextDepth(context,
+ DefaultScreenOfDisplay(display),
+ DefaultDepth(display,
+ DefaultScreen(display)));
+ }
+ }
+
+ if (context == NULL) d->extensionPresent = ext_no;
+ else d->extensionPresent = ext_yes;
+
+ return context;
+}
+
+void XDPSDestroySharedContext(DPSContext context)
+{
+ ContextInfo c = RemoveContextInfo(context);
+
+ if (c == NULL) return;
+
+ if (c->displayInfo->defaultContext == context) {
+ c->displayInfo->defaultContext = NULL;
+ }
+ DPSDestroySpace(DPSSpaceFromContext(context)); /* Also gets context */
+ if (c->text != NULL) DPSDestroySpace(DPSSpaceFromContext(c->text));
+ free((char *) c);
+}
+
+void XDPSUnregisterContext(DPSContext context)
+{
+ ContextInfo c = RemoveContextInfo(context);
+
+ if (c == NULL) return;
+
+ if (c->displayInfo->defaultContext == context) {
+ c->displayInfo->defaultContext = NULL;
+ }
+ if (c->text != NULL) DPSDestroySpace(DPSSpaceFromContext(c->text));
+ free((char *) c);
+}
+
+void XDPSFreeDisplayInfo(Display *display)
+{
+ DisplayInfo *dp = &displayList;
+ DisplayInfo d;
+ register int i, j;
+
+ while (*dp != NULL && (*dp)->display != display) dp = &((*dp)->next);
+
+ if (*dp == NULL) return;
+
+ d = *dp;
+ *dp = d->next; /* remove from list */
+
+ for (i = 0; i < ScreenCount(display); i++) {
+#ifdef NO_XLISTDEPTHS
+ free((char *) d->validDepths[i]);
+#else
+ XFree((char *) d->validDepths[i]);
+#endif
+ for (j = 0; j < d->depthsForScreen[i]; j++) {
+ if (d->gcForDepth[i][j] != 0) {
+ XFreeGC(display, d->gcForDepth[i][j]);
+ }
+ }
+ }
+
+ free((char *) d->depthsForScreen);
+ free((char *) d->validDepths);
+ free((char *) d->gcForDepth);
+ free((char *) d);
+}
+
+int XDPSChainTextContext(DPSContext context, Bool enable)
+{
+ ContextInfo c = FindContextInfo(context);
+
+ if (c == NULL) return dps_status_unregistered_context;
+
+ /* Check if already in desired state */
+
+ if (c->enableText == enable) return dps_status_success;
+
+ if (enable) {
+ if (c->text == NULL) {
+ c->text = DPSCreateTextContext(DPSDefaultTextBackstop,
+ DPSDefaultErrorProc);
+ if (c->text == NULL) return dps_status_no_extension;
+ }
+ DPSChainContext(context, c->text);
+ c->enableText = True;
+ return dps_status_success;
+ }
+
+ /* disabling, currently enabled */
+
+ DPSUnchainContext(c->text);
+ c->enableText = False;
+ return dps_status_success;
+}
+
+Bool XDPSExtensionPresent(Display *display)
+{
+ DisplayInfo d = LookupDisplayInfo(display);
+
+ if (d->extensionPresent != ext_no_idea) {
+ return (d->extensionPresent == ext_yes);
+ }
+
+ /* Check if the extension is present by trying to initialize it */
+
+ if (XDPSLInit(display, (int *) NULL, (char **) NULL) == -1) {
+ d->extensionPresent = ext_no;
+ } else d->extensionPresent = ext_yes;
+
+ return (d->extensionPresent == ext_yes);
+}
+
+int PSDefineAsUserObj(void)
+{
+ return DPSDefineAsUserObj(DPSGetCurrentContext());
+}
+
+void PSRedefineUserObj(int uo)
+{
+ DPSRedefineUserObj(DPSGetCurrentContext(), uo);
+}
+
+void PSUndefineUserObj(int uo)
+{
+ DPSUndefineUserObj(DPSGetCurrentContext(), uo);
+}
+
+int DPSDefineAsUserObj(DPSContext ctxt)
+{
+ int out = DPSNewUserObjectIndex();
+ /* We want to keep 0 as an unassigned value */
+ if (out == 0) out = DPSNewUserObjectIndex();
+
+ _DPSSDefineUserObject(ctxt, out);
+ return out;
+}
+
+void DPSRedefineUserObj(DPSContext ctxt, int uo)
+{
+ _DPSSDefineUserObject(ctxt, uo);
+}
+
+void DPSUndefineUserObj(DPSContext ctxt, int uo)
+{
+ _DPSSUndefineUserObject(ctxt, uo);
+}
+
+int PSReserveUserObjIndices(int number)
+{
+ return DPSReserveUserObjIndices(DPSGetCurrentContext(), number);
+}
+
+int DPSReserveUserObjIndices(DPSContext ctxt, int number)
+{
+ int out = DPSNewUserObjectIndex();
+
+ /* We want to keep 0 as an unassigned value */
+ if (out == 0) out = DPSNewUserObjectIndex();
+
+ number--;
+ while (number-- > 0) (void) DPSNewUserObjectIndex();
+ return out;
+}
+
+void PSReturnUserObjIndices(int start, int number)
+{
+ DPSReturnUserObjIndices(DPSGetCurrentContext(), start, number);
+}
+
+void DPSReturnUserObjIndices(DPSContext ctxt, int start, int number)
+{
+ /* Nothing left any more */
+}
+
+#ifdef NO_XLISTDEPTHS
+/* This function copyright 1989 Massachusetts Institute of Technology */
+
+/*
+ * XListDepths - return info from connection setup
+ */
+int *XListDepths (
+ 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 *) malloc (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;
+}
+#endif /* NO_XLISTDEPTHS */
diff --git a/nx-X11/lib/dpstk/XDPSswraps.psw b/nx-X11/lib/dpstk/XDPSswraps.psw
new file mode 100644
index 000000000..f878c765a
--- /dev/null
+++ b/nx-X11/lib/dpstk/XDPSswraps.psw
@@ -0,0 +1,110 @@
+/*
+ * XDPSswraps.psw
+ *
+ * (c) Copyright 1990-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+defineps _DPSSSetContextParameters(DPSContext ctxt;
+ int gc, drawable, drawableHeight,
+ map, rgbBase, redMax, redMult,
+ greenMax, greenMult, blueMax, blueMult,
+ grayBase, grayMax, grayMult;
+ boolean doGC, doDrawable, doRGB, doGray)
+ $Adobe$DPS$Lib$Dict begin
+ currentXgcdrawablecolor
+ /colorinfo exch def
+
+ doGC {
+ 4 -1 roll pop gc 4 1 roll
+ } if
+
+ doDrawable {
+ pop pop 0 drawableHeight
+ 3 -1 roll pop drawable 3 1 roll
+ } if
+
+ doRGB {
+ colorinfo 3 redMax put
+ colorinfo 4 redMult put
+ colorinfo 5 greenMax put
+ colorinfo 6 greenMult put
+ colorinfo 7 blueMax put
+ colorinfo 8 blueMult put
+ colorinfo 9 rgbBase put
+ colorinfo 10 map put
+ } if
+
+ doGray {
+ colorinfo 0 grayMax put
+ colorinfo 1 grayMult put
+ colorinfo 2 grayBase put
+ colorinfo 10 map put
+ } if
+
+ colorinfo setXgcdrawablecolor
+ end
+endps
+
+defineps _DPSSSetContextDrawable(DPSContext ctxt;
+ int drawable, drawableHeight)
+ currentXgcdrawable
+ pop pop pop drawable 0 drawableHeight
+ setXgcdrawable
+endps
+
+defineps _DPSSInstallDPSlibDict(DPSContext c)
+ userdict /$Adobe$DPS$Lib$Dict 20 dict put
+endps
+
+defineps _DPSSCaptureGState(DPSContext c; int gs)
+ gs gstate defineuserobject
+endps
+
+defineps _DPSSUpdateGState(DPSContext c; userobject gs)
+ gs currentgstate pop
+endps
+
+defineps _DPSSRestoreGState(DPSContext c; userobject gs)
+ gs setgstate
+endps
+
+defineps _DPSSDefineUserObject(DPSContext c; int uo)
+ uo exch defineuserobject
+endps
+
+defineps _DPSSUndefineUserObject(DPSContext c; int uo)
+ uo undefineuserobject
+endps
+
diff --git a/nx-X11/lib/dpstk/XDPSuserpath.c b/nx-X11/lib/dpstk/XDPSuserpath.c
new file mode 100644
index 000000000..251f74574
--- /dev/null
+++ b/nx-X11/lib/dpstk/XDPSuserpath.c
@@ -0,0 +1,240 @@
+/*
+ * XDPSuserpath.c
+ *
+ * (c) Copyright 1990-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86$ */
+
+#include <DPS/dpsXclient.h>
+#include <DPS/dpsops.h>
+#include <DPS/dpsXuserpath.h>
+
+typedef struct _t_NumStrHeader {
+ unsigned char type;
+ unsigned char representation;
+ unsigned short length;
+} NumStrHeader;
+
+void PSDoUserPath(coords, numCoords, numType, ops, numOps, bbox, action)
+ DPSPointer coords;
+ int numCoords;
+ DPSNumberFormat numType;
+ DPSUserPathOp *ops;
+ int numOps;
+ DPSPointer bbox;
+ DPSUserPathAction action;
+{
+ DPSDoUserPath(DPSGetCurrentContext(), coords, numCoords, numType, ops,
+ numOps, bbox, action);
+}
+
+void DPSDoUserPath(ctxt, coords, numCoords, numType, ops, numOps, bbox, action)
+ DPSContext ctxt;
+ DPSPointer coords;
+ int numCoords;
+ DPSNumberFormat numType;
+ DPSUserPathOp *ops;
+ int numOps;
+ DPSPointer bbox;
+ DPSUserPathAction action;
+{
+ typedef struct {
+ unsigned char tokenType;
+ unsigned char topLevelCount;
+ unsigned short nBytes;
+ DPSBinObjGeneric obj0;
+ DPSBinObjGeneric obj1;
+ DPSBinObjGeneric obj2;
+ DPSBinObjGeneric obj3;
+ } _dpsQ;
+ static _dpsQ _dpsF = {
+ DPS_DEF_TOKENTYPE, 0, 36, /* will fill in topLevelCount later */
+ {DPS_LITERAL|DPS_ARRAY, 0, 2, 16},
+ {DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 0},
+ {DPS_LITERAL|DPS_STRING, 0, 0, 32}, /* param nums */
+ {DPS_LITERAL|DPS_STRING, 0, 0, 32}, /* param ops */
+ }; /* _dpsQ */
+ register DPSBinObjRec *_dpsP = (DPSBinObjRec *)&_dpsF.obj0;
+ register int _dps_offset = 32;
+ int needBBox, hasUCache, numberSize;
+ DPSUserPathOp setbboxOp;
+ NumStrHeader nsHeader;
+
+ if (numType >= dps_short && numType < dps_float) numberSize = 2;
+ else numberSize = 4;
+
+ hasUCache = (*ops == dps_ucache);
+
+ if (hasUCache) {
+ needBBox = (numOps > 1 && ops[1] != dps_setbbox);
+ } else needBBox = (*ops != dps_setbbox);
+
+ if (needBBox) {
+ numOps += 1;
+ setbboxOp = dps_setbbox;
+ }
+
+ numCoords += 4; /* Account for bbox */
+
+ nsHeader.type = 149; /* Homogeneous Number Array */
+ nsHeader.representation = numType;
+ nsHeader.length = numCoords;
+
+ /* If we're using the send operation, we modify the sequence so that
+ it never gets to the action. This leaves a hole in the sequence,
+ but that's ok. */
+
+ if (action == dps_send) _dpsF.topLevelCount = 1;
+ else _dpsF.topLevelCount = 2;
+
+ _dpsP[1].val.nameVal = action;
+ _dpsP[2].length = (sizeof(NumStrHeader) + numCoords * numberSize);
+ _dpsP[3].length = numOps;
+ _dpsP[3].val.stringVal = _dps_offset;
+ _dps_offset += numOps;
+ _dpsP[2].val.stringVal = _dps_offset;
+ _dps_offset += _dpsP[2].length;
+ _dpsF.nBytes = _dps_offset+4;
+
+ if (needBBox) numOps -= 1;
+
+ numCoords -= 4; /* Unaccount for bbox */
+
+ DPSBinObjSeqWrite(ctxt, (char *) &_dpsF, 36);
+ if (needBBox) {
+ if (hasUCache) {
+ DPSWriteStringChars(ctxt, (char *) ops, 1);
+ ops++; numOps--;
+ }
+ DPSWriteStringChars(ctxt, (char *) &setbboxOp, 1);
+ }
+ DPSWriteStringChars(ctxt, (char *) ops, numOps);
+ DPSWriteStringChars(ctxt, (char *) &nsHeader, sizeof(NumStrHeader));
+ DPSWriteStringChars(ctxt, (char *) bbox, 4 * numberSize);
+ DPSWriteStringChars(ctxt, (char *) coords, numCoords * numberSize);
+}
+
+Bool PSHitUserPath(x, y, radius,
+ coords, numCoords, numType, ops, numOps, bbox, action)
+ double x, y, radius;
+ DPSPointer coords;
+ int numCoords;
+ DPSNumberFormat numType;
+ DPSUserPathOp *ops;
+ int numOps;
+ DPSPointer bbox;
+ DPSUserPathAction action;
+{
+ return DPSHitUserPath(DPSGetCurrentContext(), x, y, radius,
+ coords, numCoords, numType, ops,
+ numOps, bbox, action);
+}
+
+Bool DPSHitUserPath(ctxt, x, y, radius,
+ coords, numCoords, numType, ops, numOps, bbox, action)
+ DPSContext ctxt;
+ double x, y, radius;
+ DPSPointer coords;
+ int numCoords;
+ DPSNumberFormat numType;
+ DPSUserPathOp *ops;
+ int numOps;
+ DPSPointer bbox;
+ DPSUserPathAction action;
+{
+ float aCoords[5];
+ DPSUserPathOp aOps[1];
+ float aBbox[4];
+ int result;
+
+ if (radius != 0.0) {
+ aCoords[0] = x;
+ aCoords[1] = y;
+ aCoords[2] = radius;
+ aCoords[3] = 0.0;
+ aCoords[4] = 360.0;
+ aOps[0] = dps_arc;
+ aBbox[0] = x - radius;
+ aBbox[1] = y - radius;
+ aBbox[2] = x + radius;
+ aBbox[3] = y + radius;
+
+ switch (action) {
+ case dps_infill:
+ case dps_ineofill:
+ case dps_instroke:
+ DPSDoUserPath(ctxt, (DPSPointer) aCoords, 5, dps_float,
+ aOps, 1, (DPSPointer) aBbox, action);
+ break;
+ case dps_inufill:
+ case dps_inueofill:
+ case dps_inustroke:
+ DPSDoUserPath(ctxt, (DPSPointer) aCoords, 5, dps_float,
+ aOps, 1, (DPSPointer) aBbox, dps_send);
+ DPSDoUserPath(ctxt, coords, numCoords, numType, ops,
+ numOps, bbox, action);
+ break;
+ default:
+ return False;
+ }
+ DPSgetboolean(ctxt, &result);
+
+ } else {
+ switch (action) {
+ case dps_infill:
+ DPSinfill(ctxt, x, y, &result);
+ break;
+ case dps_ineofill:
+ DPSineofill(ctxt, x, y, &result);
+ break;
+ case dps_instroke:
+ DPSinstroke(ctxt, x, y, &result);
+ break;
+ case dps_inufill:
+ case dps_inueofill:
+ case dps_inustroke:
+ DPSsendfloat(ctxt, x);
+ DPSsendfloat(ctxt, y);
+ DPSDoUserPath(ctxt, coords, numCoords, numType, ops,
+ numOps, bbox, action);
+ DPSgetboolean(ctxt, &result);
+ break;
+ default:
+ return False;
+ }
+ }
+ return result;
+}
+
diff --git a/nx-X11/lib/dpstk/dpsXcommonI.h b/nx-X11/lib/dpstk/dpsXcommonI.h
new file mode 100644
index 000000000..2e91dc629
--- /dev/null
+++ b/nx-X11/lib/dpstk/dpsXcommonI.h
@@ -0,0 +1,73 @@
+/*
+ * dpsXcommonI.h
+ *
+ * (c) Copyright 1990-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+
+#ifndef DPS_X_COMMON_I_H
+#define DPS_X_COMMON_I_H
+
+#define dps_init_bit_share (1<<0)
+#define dps_init_bit_preview (1<<1)
+#define dps_init_bit_fsb (1<<2)
+#define dps_init_bit_csb (1<<3)
+#define dps_init_bit_dsw (1<<4)
+
+#ifdef _NO_PROTO
+
+extern int _XDPSSetComponentInitialized();
+
+extern int _XDPSTestComponentInitialized();
+
+#else /* _NO_PROTO */
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+extern int _XDPSSetComponentInitialized(DPSContext context,
+ unsigned long componentBit);
+
+extern int _XDPSTestComponentInitialized(DPSContext context,
+ unsigned long componentBit,
+ Bool *result);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _NO_PROTO */
+
+#endif /* DPS_X_COMMON_I_H */
diff --git a/nx-X11/lib/dpstk/dpstk-def.cpp b/nx-X11/lib/dpstk/dpstk-def.cpp
new file mode 100644
index 000000000..ada432c37
--- /dev/null
+++ b/nx-X11/lib/dpstk/dpstk-def.cpp
@@ -0,0 +1,65 @@
+LIBRARY DPSTK
+VERSION LIBRARY_VERSION
+EXPORTS
+_DPSPCheckForError
+_DPSPClearArea
+_DPSPDefineExecFunction
+_DPSPSaveBeforeExec
+_DPSPSetMaskTransfer
+_DPSPSetMatrix
+_DPSSCaptureGState
+_DPSSDefineUserObject
+_DPSSInstallDPSlibDict
+_DPSSRestoreGState
+_DPSSSetContextDrawable
+_DPSSSetContextParameters
+_DPSSUndefineUserObject
+_DPSSUpdateGState
+DPSDefineAsUserObj
+DPSRedefineUserObj
+DPSReserveUserObjIndices
+DPSReturnUserObjIndices
+DPSUndefineUserObj
+PSDefineAsUserObj
+PSRedefineUserObj
+PSReserveUserObjIndices
+PSReturnUserObjIndices
+PSUndefineUserObj
+XDPSCaptureContextGState
+XDPSChainTextContext
+XDPSDestroySharedContext
+XDPSExtensionPresent
+XDPSFreeContextGState
+XDPSFreeDisplayInfo
+XDPSGetSharedContext
+XDPSPopContextGState
+XDPSPopContextParameters
+XDPSPushContextGState
+XDPSPushContextParameters
+XDPSRegisterContext
+XDPSSetContextDepth
+XDPSSetContextDrawable
+XDPSSetContextGState
+XDPSSetContextGrayMap
+XDPSSetContextParameters
+XDPSSetContextRGBMap
+XDPSUnregisterContext
+XDPSUpdateContextGState
+_XDPSSetComponentInitialized
+_XDPSTestComponentInitialized
+XDPSCheckImagingResults
+XDPSCreatePixmapForEPSF
+XDPSEmbeddedEPSFRewindFunc
+XDPSEmbeddedGetsFunc
+XDPSFileGetsFunc
+XDPSFileRewindFunc
+XDPSImageFileIntoDrawable
+XDPSPixelsPerPoint
+XDPSSetFileFunctions
+XDPSSetImagingTimeout
+DPSDoUserPath
+DPSHitUserPath
+PSDoUserPath
+PSHitUserPath
+
+/* $XFree86$ */
diff --git a/nx-X11/lib/dpstk/eyedrop16.xbm b/nx-X11/lib/dpstk/eyedrop16.xbm
new file mode 100644
index 000000000..2f5a772d7
--- /dev/null
+++ b/nx-X11/lib/dpstk/eyedrop16.xbm
@@ -0,0 +1,8 @@
+#define eyedrop16_width 16
+#define eyedrop16_height 16
+#define eyedrop16_x_hot 0
+#define eyedrop16_y_hot 13
+static unsigned char eyedrop16_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x03,
+ 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x07, 0xf8, 0x03, 0xf8, 0x01, 0xf8, 0x00,
+ 0x7c, 0x00, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x00};
diff --git a/nx-X11/lib/dpstk/eyedrop32.xbm b/nx-X11/lib/dpstk/eyedrop32.xbm
new file mode 100644
index 000000000..5bc98a02c
--- /dev/null
+++ b/nx-X11/lib/dpstk/eyedrop32.xbm
@@ -0,0 +1,16 @@
+#define eyedrop32_width 32
+#define eyedrop32_height 32
+#define eyedrop32_x_hot 0
+#define eyedrop32_y_hot 29
+static unsigned char eyedrop32_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xf0, 0x0f, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00,
+ 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01, 0x00, 0x80, 0xff, 0x00, 0x00,
+ 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00,
+ 0xf8, 0x0f, 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00,
+ 0xf8, 0x01, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
+ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/nx-X11/lib/dpstk/eyedropmask16.xbm b/nx-X11/lib/dpstk/eyedropmask16.xbm
new file mode 100644
index 000000000..e1a696dd6
--- /dev/null
+++ b/nx-X11/lib/dpstk/eyedropmask16.xbm
@@ -0,0 +1,8 @@
+#define eyedropmask16_width 16
+#define eyedropmask16_height 16
+#define eyedropmask16_x_hot 0
+#define eyedropmask16_y_hot 13
+static unsigned char eyedropmask16_bits[] = {
+ 0x00, 0x7c, 0x00, 0xfe, 0x80, 0xff, 0x00, 0xff, 0x80, 0xff, 0xc0, 0xff,
+ 0xe0, 0x7f, 0xf0, 0x3f, 0xf8, 0x2f, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01,
+ 0xfe, 0x00, 0x7f, 0x00, 0x0e, 0x00, 0x04, 0x00};
diff --git a/nx-X11/lib/dpstk/eyedropmask32.xbm b/nx-X11/lib/dpstk/eyedropmask32.xbm
new file mode 100644
index 000000000..8e12f00e7
--- /dev/null
+++ b/nx-X11/lib/dpstk/eyedropmask32.xbm
@@ -0,0 +1,16 @@
+#define eyedropmask32_width 32
+#define eyedropmask32_height 32
+#define eyedropmask32_x_hot 0
+#define eyedropmask32_y_hot 29
+static unsigned char eyedropmask32_bits[] = {
+ 0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0xf0, 0x7f,
+ 0x00, 0x00, 0xf8, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x00, 0x00, 0xfe, 0xff,
+ 0x00, 0x00, 0xff, 0xff, 0x00, 0xc0, 0xff, 0xff, 0x00, 0xe0, 0xff, 0xff,
+ 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x80, 0xff, 0x7f, 0x00, 0xc0, 0xff, 0x3f,
+ 0x00, 0xe0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x0f, 0x00, 0xf8, 0xff, 0x07,
+ 0x00, 0xfc, 0xff, 0x03, 0x00, 0xfe, 0xff, 0x01, 0x00, 0xff, 0xdf, 0x01,
+ 0x80, 0xff, 0x8f, 0x00, 0xc0, 0xff, 0x07, 0x00, 0xe0, 0xff, 0x03, 0x00,
+ 0xf0, 0xff, 0x01, 0x00, 0xf8, 0xff, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00,
+ 0xfc, 0x3f, 0x00, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00,
+ 0xfc, 0x07, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01, 0x00, 0x00,
+ 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00};
diff --git a/nx-X11/lib/dpstk/heyedrop.xbm b/nx-X11/lib/dpstk/heyedrop.xbm
new file mode 100644
index 000000000..ea51ae599
--- /dev/null
+++ b/nx-X11/lib/dpstk/heyedrop.xbm
@@ -0,0 +1,7 @@
+#define heyedrop_width 32
+#define heyedrop_height 12
+static unsigned char heyedrop_bits[] = {
+ 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xf8, 0x3f, 0xe0, 0xff, 0xff, 0x7f,
+ 0x38, 0x00, 0xf8, 0xff, 0x0f, 0x00, 0xf8, 0xff, 0x00, 0x00, 0xf8, 0xff,
+ 0x00, 0x00, 0xf8, 0xff, 0x0f, 0x00, 0xf8, 0xff, 0x38, 0x00, 0xf8, 0xff,
+ 0xe0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0x08, 0x00};
diff --git a/nx-X11/lib/dpstk/square.xbm b/nx-X11/lib/dpstk/square.xbm
new file mode 100644
index 000000000..d05789431
--- /dev/null
+++ b/nx-X11/lib/dpstk/square.xbm
@@ -0,0 +1,8 @@
+#define square_width 16
+#define square_height 16
+#define square_x_hot 6
+#define square_y_hot 6
+static unsigned char square_bits[] = {
+ 0x00, 0x00, 0xfe, 0x0f, 0xfe, 0x0f, 0xfe, 0x0f, 0xfe, 0x0f, 0xfe, 0x0f,
+ 0xfe, 0x0f, 0xfe, 0x0f, 0xfe, 0x0f, 0xfe, 0x0f, 0xfe, 0x0f, 0xfe, 0x0f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/nx-X11/lib/dpstk/squaremask.xbm b/nx-X11/lib/dpstk/squaremask.xbm
new file mode 100644
index 000000000..ea2e0d96b
--- /dev/null
+++ b/nx-X11/lib/dpstk/squaremask.xbm
@@ -0,0 +1,6 @@
+#define squaremask_width 16
+#define squaremask_height 16
+static unsigned char squaremask_bits[] = {
+ 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f,
+ 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f,
+ 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/nx-X11/lib/expat/Imakefile b/nx-X11/lib/expat/Imakefile
new file mode 100644
index 000000000..c7ff20bb3
--- /dev/null
+++ b/nx-X11/lib/expat/Imakefile
@@ -0,0 +1,53 @@
+XCOMM $XFree86: xc/lib/expat/Imakefile,v 1.8tsi Exp $
+
+#define DoNormalLib NormalLibExpat
+#define DoSharedLib SharedLibExpat
+#define DoExtraLib SharedLibExpat
+#define DoDebugLib DebugLibExpat
+#define DoProfileLib ProfileLibExpat
+#define HasSharedData YES
+#define LibName expat
+#define SoRev SOEXPATREV
+#ifdef SharedLibtoolExpatRev
+#define SharedLibtoolRev SharedLibtoolExpatRev
+#endif
+#define LibHeaders YES
+
+#include <Threads.tmpl>
+
+EXPATTOP = $(TOP)/extras/expat
+EXPATSRC = $(EXPATTOP)/lib
+EXPATINC = $(EXPATTOP)/lib
+
+INCLUDES = -I$(EXPATINC) -I$(EXPATTOP) -I.
+
+/*
+ * Endianness (for short's)
+ *
+ * XML_BYTE_ORDER == 12 big endian
+ * XML_BYTE_ORDER == 21 little endian
+ * XML_BYTE_ORDER == anything else determined at run-time.
+ */
+DEFINES = -DXML_BYTE_ORDER=0 -DX_BYTE_ORDER=$(X_BYTE_ORDER)
+REQUIREDLIBS=$(LDPRELIBS)
+
+SRCS = xmlparse.c xmltok.c xmlrole.c
+OBJS = xmlparse.o xmltok.o xmlrole.o
+
+HEADERS = expat.h
+
+#include <Library.tmpl>
+
+#if DoSharedLib && SharedDataSeparation
+SpecialCObjectRule(sharedlib,NullParameter,$(SHLIBDEF))
+#endif
+
+
+DependTarget()
+
+LinkSourceFile(xmlparse.c,$(EXPATSRC))
+LinkSourceFile(xmltok.c,$(EXPATSRC))
+LinkSourceFile(xmlrole.c,$(EXPATSRC))
+LinkSourceFile(expat.h,$(EXPATINC))
+
+
diff --git a/nx-X11/lib/expat/expat-def.cpp b/nx-X11/lib/expat/expat-def.cpp
new file mode 100644
index 000000000..d5fd2e3cc
--- /dev/null
+++ b/nx-X11/lib/expat/expat-def.cpp
@@ -0,0 +1,73 @@
+LIBRARY expat
+VERSION LIBRARY_VERSION
+EXPORTS
+XML_DefaultCurrent
+XML_ErrorString
+XML_ExpatVersion
+XML_ExpatVersionInfo
+XML_ExternalEntityParserCreate
+XML_GetBase
+XML_GetBuffer
+XML_GetCurrentByteCount
+XML_GetCurrentByteIndex
+XML_GetCurrentColumnNumber
+XML_GetCurrentLineNumber
+XML_GetErrorCode
+XML_GetIdAttributeIndex
+XML_GetInputContext
+XML_GetSpecifiedAttributeCount
+XML_Parse
+XML_ParseBuffer
+XML_ParserCreate
+XML_ParserCreateNS
+XML_ParserCreate_MM
+XML_ParserFree
+XML_SetAttlistDeclHandler
+XML_SetBase
+XML_SetCdataSectionHandler
+XML_SetCharacterDataHandler
+XML_SetCommentHandler
+XML_SetDefaultHandler
+XML_SetDefaultHandlerExpand
+XML_SetDoctypeDeclHandler
+XML_SetElementDeclHandler
+XML_SetElementHandler
+XML_SetEncoding
+XML_SetEndCdataSectionHandler
+XML_SetEndDoctypeDeclHandler
+XML_SetEndElementHandler
+XML_SetEndNamespaceDeclHandler
+XML_SetEntityDeclHandler
+XML_SetExternalEntityRefHandler
+XML_SetExternalEntityRefHandlerArg
+XML_SetNamespaceDeclHandler
+XML_SetNotStandaloneHandler
+XML_SetNotationDeclHandler
+XML_SetParamEntityParsing
+XML_SetProcessingInstructionHandler
+XML_SetReturnNSTriplet
+XML_SetStartCdataSectionHandler
+XML_SetStartDoctypeDeclHandler
+XML_SetStartElementHandler
+XML_SetStartNamespaceDeclHandler
+XML_SetUnknownEncodingHandler
+XML_SetUnparsedEntityDeclHandler
+XML_SetUserData
+XML_SetXmlDeclHandler
+XML_UseParserAsHandlerArg
+XmlPrologStateInit
+XmlPrologStateInitExternalEntity
+XmlGetUtf16InternalEncoding
+XmlGetUtf16InternalEncodingNS
+XmlGetUtf8InternalEncoding
+XmlGetUtf8InternalEncodingNS
+XmlInitEncoding
+XmlInitEncodingNS
+XmlInitUnknownEncoding
+XmlInitUnknownEncodingNS
+XmlParseXmlDecl
+XmlParseXmlDeclNS
+XmlSizeOfUnknownEncoding
+XmlUtf16Encode
+XmlUtf8Encode
+/* $XFree86$ */
diff --git a/nx-X11/lib/expat/expat_config.h b/nx-X11/lib/expat/expat_config.h
new file mode 100644
index 000000000..4a0e05c16
--- /dev/null
+++ b/nx-X11/lib/expat/expat_config.h
@@ -0,0 +1,65 @@
+/* $XFree86: xc/lib/expat/expat_config.h,v 1.2 2003/04/12 13:50:16 tsi Exp $ */
+/* config.h. Generated automatically by configure. */
+/* config.h.in. Generated automatically from configure.in by autoheader. */
+
+#include <X11/Xos.h>
+
+/* Define to empty if the keyword does not work. */
+/* #undef const */
+
+/* Define if you have a working `mmap' system call. */
+/* #undef HAVE_MMAP */
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+/* #undef off_t */
+
+/* Define to `unsigned' if <sys/types.h> doesn't define. */
+/* #undef size_t */
+
+#ifndef X_NOT_POSIX
+
+/* Define if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+#endif
+
+/* Define if you have the bcopy function. */
+/* #undef HAVE_BCOPY */
+
+/* Define if you have the getpagesize function. */
+/* #undef HAVE_GETPAGESIZE */
+
+/* Define if you have the memmove function. */
+#define HAVE_MEMMOVE 1
+
+#if X_BYTE_ORDER==X_BIG_ENDIAN
+#define BYTEORDER 4321
+#endif
+
+#if X_BYTE_ORDER==X_LITTLE_ENDIAN
+#define BYTEORDER 1234
+#endif
+
+#ifndef BYTEORDER
+#error "Unknown byte order"
+#endif
+
+#define XML_NS
+#define XML_DTD
+
+#define XML_CONTEXT_BYTES 1024
+
+#ifndef HAVE_MEMMOVE
+#ifdef HAVE_BCOPY
+#define memmove(d,s,l) bcopy((s),(d),(l))
+#else
+#define memmove(d,s,l) ;punting on memmove;
+#endif
+
+#endif
diff --git a/nx-X11/lib/font/FreeType/Imakefile b/nx-X11/lib/font/FreeType/Imakefile
new file mode 100644
index 000000000..57361471b
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/Imakefile
@@ -0,0 +1,47 @@
+XCOMM $XFree86: xc/lib/font/FreeType/Imakefile,v 1.30 2003/11/05 16:54:28 tsi Exp $
+
+#if BuildServer && DoLoadableServer
+#define IHaveSubdirs
+#define NoLibSubdirs
+#define PassCDebugFlags
+SUBDIRS = module
+#endif
+
+#if !HasFreetype2
+EXTRAINCLUDES = -I$(FT2SOURCEDIR)/truetype
+INTERNALDEFINES = -DUSE_INTERNAL_FREETYPE
+#endif
+
+DEFINES = ServerExtraDefines StrcasecmpDefines Freetype2BuildDefines \
+ -DXFREE86_FT2 $(INTERNALDEFINES)
+
+FT2SOURCEDIR = $(TOP)/extras/freetype2/src
+FT2INCS = $(FREETYPE2INCLUDES)
+
+INCLUDES = $(FT2INCS) -I. -I$(FONTINCSRC) -I../include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/include $(EXTRAINCLUDES) \
+ -I$(INCLUDESRC)
+
+SRCS = xttcap.c ftfuncs.c ftenc.c fttools.c
+OBJS = xttcap.o ftfuncs.o ftenc.o fttools.o
+
+#if BuildFontLib
+#define DoNormalLib NormalLibFont
+#define DoSharedLib SharedLibFont
+#define DoDebugLib DebugLibFont
+#define DoProfileLib ProfileLibFont
+#include <Library.tmpl>
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+#endif
+
+#if BuildServer && DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/font/FreeType/ft.h b/nx-X11/lib/font/FreeType/ft.h
new file mode 100644
index 000000000..8ad8403d5
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/ft.h
@@ -0,0 +1,96 @@
+/*
+Copyright (c) 1997 by Mark Leisher
+Copyright (c) 1998-2002 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+
+/* $XFree86: xc/lib/font/FreeType/ft.h,v 1.22 2003/06/08 15:41:13 herrb Exp $ */
+
+#ifndef _FT_H_
+#define _FT_H_
+
+#include <X11/Xfuncproto.h>
+
+#define FREETYPE_VERSION (FREETYPE_MAJOR * 1000000 + FREETYPE_MINOR * 1000 + FREETYPE_PATCH)
+
+#undef DEBUG_TRUETYPE
+
+#ifdef DEBUG_TRUETYPE
+#define MUMBLE(s) (ErrorF((s)))
+#define MUMBLE1(s,x) (ErrorF((s),(x)))
+#else
+#define MUMBLE(s)
+#define MUMBLE1(s,x)
+#endif
+
+#undef MAX
+#define MAX(h,i) ((h) > (i) ? (h) : (i))
+#define ADJUSTMAX(m,v) if((v)>(m)) (m)=(v)
+#undef MIN
+#define MIN(l,o) ((l) < (o) ? (l) : (o))
+#define ADJUSTMIN(m,v) if ((v)<(m)) (m)=(v)
+
+/* When comparing floating point values, we want to ignore small errors. */
+#define NEGLIGIBLE ((double)0.001)
+/* Are x and y significantly different? */
+#define DIFFER(x,y) (fabs((x)-(y))>=NEGLIGIBLE*fabs(x))
+/* Is x significantly different from 0 w.r.t. y? */
+#define DIFFER0(x,y) (fabs(x)>=NEGLIGIBLE*fabs(y))
+
+#ifndef ABS
+#define ABS(x) ((x) >= 0 ? (x) : -(x))
+#endif
+
+/* Two to the sixteenth power, as a double. */
+#define TWO_SIXTEENTH ((double)(1<<16))
+#define TWO_SIXTH ((double)(1<<6))
+
+/* Data structures used across files */
+
+typedef struct _FTMapping
+{
+ int named;
+ FT_CharMap cmap;
+ int base;
+ struct _FontMap *mapping; /* allow inclusion without fontenc.h */
+} FTMappingRec, *FTMappingPtr;
+
+/* Prototypes */
+
+/* ftfuncs.c */
+
+#if 0
+void FreeTypeRegisterFontFileFunctions(void);
+#endif
+
+/* ftenc.c */
+
+int FTPickMapping(char*, int, char*, FT_Face, FTMappingPtr);
+unsigned FTRemap(FT_Face face, FTMappingPtr, unsigned code);
+
+/* fttools.c */
+
+int FTtoXReturnCode(int);
+int FTGetEnglishName(FT_Face, int, char *, int);
+int FTcheckForTTCName(char*, char**, int*);
+
+extern void ErrorF(const char*, ...);
+
+#endif /* _FT_H_ */
diff --git a/nx-X11/lib/font/FreeType/ftenc.c b/nx-X11/lib/font/FreeType/ftenc.c
new file mode 100644
index 000000000..a9d6494ff
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/ftenc.c
@@ -0,0 +1,242 @@
+/*
+Copyright (c) 1998-2003 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+/* $XFree86: xc/lib/font/FreeType/ftenc.c,v 1.24 2003/10/19 18:53:49 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifndef FONTMODULE
+#include <string.h>
+#else
+#include "Xmd.h"
+#include "Xdefs.h"
+#include "xf86_ansic.h"
+#endif
+
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/fontutil.h>
+#include <X11/fonts/FSproto.h>
+
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontenc.h>
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_TRUETYPE_IDS_H
+#include FT_TRUETYPE_TABLES_H
+#include FT_TYPE1_TABLES_H
+#include FT_BDF_H
+#include FT_XFREE86_H
+#include "ft.h"
+
+static int find_cmap(int, int, int, FT_Face, FT_CharMap *);
+
+static int
+FTEncFontSpecific(char *encoding)
+{
+ char *p = encoding;
+
+ if(strcasecmp(encoding, "microsoft-symbol") == 0)
+ return 1;
+
+ while(*p != '-') {
+ if(*p == '\0')
+ return 0;
+ p++;
+ }
+ p++;
+ return (strcasecmp(p, "fontspecific") == 0);
+}
+
+int
+FTPickMapping(char *xlfd, int length, char *filename, FT_Face face,
+ FTMappingPtr tm)
+{
+ FontEncPtr encoding;
+ FontMapPtr mapping;
+ FT_CharMap cmap;
+ int ftrc;
+ int symbol = 0;
+ const char *enc, *reg;
+ char *encoding_name = 0;
+ char buf[20];
+
+ if(xlfd)
+ encoding_name = FontEncFromXLFD(xlfd, length);
+ if(!encoding_name)
+ encoding_name = "iso8859-1";
+
+ symbol = FTEncFontSpecific(encoding_name);
+
+ ftrc = FT_Get_BDF_Charset_ID(face, &enc, &reg);
+ if(ftrc == 0) {
+ /* Disable reencoding for non-Unicode fonts. This will
+ currently only work for BDFs. */
+ if(strlen(enc) + strlen(reg) > 18)
+ goto native;
+ strcpy(buf, enc);
+ strcat(buf, "-");
+ strcat(buf, reg);
+ ErrorF("%s %s\n", buf, encoding_name);
+ if(strcasecmp(buf, "iso10646-1") != 0) {
+ if(strcasecmp(buf, encoding_name) == 0)
+ goto native;
+ return BadFontFormat;
+ }
+ } else if(symbol) {
+ ftrc = FT_Select_Charmap(face, ft_encoding_adobe_custom);
+ if(ftrc == 0)
+ goto native;
+ }
+
+ encoding = FontEncFind(encoding_name, filename);
+ if(symbol && encoding == NULL)
+ encoding = FontEncFind("microsoft-symbol", filename);
+ if(encoding == NULL) {
+ ErrorF("FreeType: couldn't find encoding '%s' for '%s'\n",
+ encoding_name, filename);
+ return BadFontName;
+ }
+
+ if(FT_Has_PS_Glyph_Names(face)) {
+ for(mapping = encoding->mappings; mapping; mapping = mapping->next) {
+ if(mapping->type == FONT_ENCODING_POSTSCRIPT) {
+ tm->named = 1;
+ tm->base = 0;
+ tm->mapping = mapping;
+ return Successful;
+ }
+ }
+ }
+
+ for(mapping = encoding->mappings; mapping; mapping = mapping->next) {
+ if(find_cmap(mapping->type, mapping->pid, mapping->eid, face,
+ &cmap)) {
+ tm->named = 0;
+ tm->cmap = cmap;
+ if(symbol) {
+ /* deal with an undocumented ``feature'' of the
+ Microsft-Symbol cmap */
+ TT_OS2 *os2;
+ os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
+ if(os2)
+ tm->base = os2->usFirstCharIndex - 0x20;
+ else
+ tm->base = 0;
+ } else
+ tm->base = 0;
+ tm->mapping = mapping;
+ return Successful;
+ }
+ }
+
+ return BadFontFormat;
+
+ native:
+ tm->named = 0;
+ tm->cmap = face->charmap;
+ tm->base = 0;
+ tm->mapping = NULL;
+ return Successful;
+}
+
+static int
+find_cmap(int type, int pid, int eid, FT_Face face, FT_CharMap *cmap_return)
+{
+ int i, n;
+ FT_CharMap cmap = NULL;
+
+ n = face->num_charmaps;
+
+ switch(type) {
+ case FONT_ENCODING_TRUETYPE: /* specific cmap */
+ for(i=0; i<n; i++) {
+ cmap = face->charmaps[i];
+ if(cmap->platform_id == pid && cmap->encoding_id == eid) {
+ *cmap_return = cmap;
+ return 1;
+ }
+ }
+ break;
+ case FONT_ENCODING_UNICODE: /* any Unicode cmap */
+ /* prefer Microsoft Unicode */
+ for(i=0; i<n; i++) {
+ cmap = face->charmaps[i];
+ if(cmap->platform_id == TT_PLATFORM_MICROSOFT &&
+ cmap->encoding_id == TT_MS_ID_UNICODE_CS) {
+ *cmap_return = cmap;
+ return 1;
+ }
+ }
+ break;
+ /* Try Apple Unicode */
+ for(i=0; i<n; i++) {
+ cmap = face->charmaps[i];
+ if(cmap->platform_id == TT_PLATFORM_APPLE_UNICODE) {
+ *cmap_return = cmap;
+ return 1;
+ }
+ }
+ /* ISO Unicode? */
+ for(i=0; i<n; i++) {
+ cmap = face->charmaps[i];
+ if(cmap->platform_id == TT_PLATFORM_ISO) {
+ *cmap_return = cmap;
+ return 1;
+ }
+ }
+ break;
+ default:
+ return 0;
+ }
+ return 0;
+}
+
+unsigned
+FTRemap(FT_Face face, FTMappingPtr tm, unsigned code)
+{
+ unsigned index;
+ char *name;
+ unsigned glyph_index;
+
+ if(tm->mapping) {
+ if(tm->named) {
+ name = FontEncName(code, tm->mapping);
+ if(!name)
+ return 0;
+ glyph_index = FT_Get_Name_Index(face, name);
+ return glyph_index;
+ } else {
+ index = FontEncRecode(code, tm->mapping) + tm->base;
+ FT_Set_Charmap(face, tm->cmap);
+ glyph_index = FT_Get_Char_Index(face, index);
+ return glyph_index;
+ }
+ } else {
+ if(code < 0x100) {
+ index = code;
+ FT_Set_Charmap(face, tm->cmap);
+ glyph_index = FT_Get_Char_Index(face, index);
+ return glyph_index;
+ } else
+ return 0;
+ }
+}
diff --git a/nx-X11/lib/font/FreeType/ftfuncs.c b/nx-X11/lib/font/FreeType/ftfuncs.c
new file mode 100644
index 000000000..d3c9d9eeb
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/ftfuncs.c
@@ -0,0 +1,3851 @@
+/*
+Copyright (c) 1997 by Mark Leisher
+Copyright (c) 1998-2003 by Juliusz Chroboczek
+Copyright (c) 1998 Go Watanabe, All rights reserved.
+Copyright (c) 1998 Kazushi (Jam) Marukawa, All rights reserved.
+Copyright (c) 1998 Takuya SHIOZAKI, All rights reserved.
+Copyright (c) 1998 X-TrueType Server Project, All rights reserved.
+Copyright (c) 2003-2004 After X-TT Project, All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+/* $XdotOrg: xc/lib/font/FreeType/ftfuncs.c,v 1.13 2005/10/23 18:32:05 ajax Exp $ */
+
+/* $XFree86: xc/lib/font/FreeType/ftfuncs.c,v 1.43 2004/02/07 04:37:18 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+
+#ifndef FONTMODULE
+#include <string.h>
+#include <math.h>
+#else
+#include "Xmd.h"
+#include "Xdefs.h"
+#include "xf86_ansic.h"
+#endif
+
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/fontutil.h>
+#include <X11/fonts/FSproto.h>
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_SIZES_H
+#include FT_TRUETYPE_IDS_H
+#include FT_TRUETYPE_TABLES_H
+#include FT_TYPE1_TABLES_H
+#include FT_XFREE86_H
+#include FT_BBOX_H
+#include FT_INTERNAL_TRUETYPE_TYPES_H
+#include FT_TRUETYPE_TAGS_H
+#include FT_INTERNAL_SFNT_H
+#include FT_INTERNAL_STREAM_H
+/*
+ * If you want to use FT_Outline_Get_CBox instead of
+ * FT_Outline_Get_BBox, define here.
+ */
+/* #define USE_GET_CBOX */
+#ifdef USE_GET_CBOX
+#include FT_OUTLINE_H
+#endif
+
+#include <X11/fonts/fontenc.h>
+#include "ft.h"
+#include "ftfuncs.h"
+#include "xttcap.h"
+
+/* Work around FreeType bug */
+#define WORK_AROUND_UPM 2048
+
+#ifndef True
+#define True (-1)
+#endif /* True */
+#ifndef False
+#define False (0)
+#endif /* False */
+
+#define FLOOR64(x) ((x) & -64)
+#define CEIL64(x) (((x) + 64 - 1) & -64)
+
+/*
+ * If you want very lazy method(vl=y) AS DEFAULT when
+ * handling large charset, define here.
+ */
+/* #define DEFAULT_VERY_LAZY 1 */ /* Always */
+#define DEFAULT_VERY_LAZY 2 /* Multi-byte only */
+/* #define DEFAULT_VERY_LAZY 256 */ /* Unicode only */
+
+/* Does the X accept noSuchChar? */
+#define X_ACCEPTS_NO_SUCH_CHAR
+/* Does the XAA accept NULL noSuchChar.bits?(dangerous) */
+/* #define XAA_ACCEPTS_NULL_BITS */
+
+#ifdef X_ACCEPTS_NO_SUCH_CHAR
+static CharInfoRec noSuchChar = { /* metrics */{0,0,0,0,0,0},
+ /* bits */ NULL };
+#endif
+
+/* The propery names for all the XLFD properties. */
+
+static char *xlfd_props[] = {
+ "FOUNDRY",
+ "FAMILY_NAME",
+ "WEIGHT_NAME",
+ "SLANT",
+ "SETWIDTH_NAME",
+ "ADD_STYLE_NAME",
+ "PIXEL_SIZE",
+ "POINT_SIZE",
+ "RESOLUTION_X",
+ "RESOLUTION_Y",
+ "SPACING",
+ "AVERAGE_WIDTH",
+ "CHARSET_REGISTRY",
+ "CHARSET_ENCODING",
+};
+
+
+static int ftypeInitP = 0; /* is the engine initialised? */
+FT_Library ftypeLibrary;
+
+static FTFacePtr faceTable[NUMFACEBUCKETS];
+
+static unsigned
+hash(char *string)
+{
+ int i;
+ unsigned u = 0;
+ for(i = 0; string[i] != '\0'; i++)
+ u = (u<<5) + (u >> (NUMFACEBUCKETS - 5)) + (unsigned char)string[i];
+ return u;
+}
+
+static int
+ifloor(int x, int y)
+{
+ if(x >= 0)
+ return x/y;
+ else
+ return x/y - 1;
+}
+
+static int
+iceil(int x, int y)
+{
+ return ifloor(x + y - 1, y);
+}
+
+static int
+FreeTypeOpenFace(FTFacePtr *facep, char *FTFileName, char *realFileName, int faceNumber)
+{
+ FT_Error ftrc;
+ int bucket;
+ FTFacePtr face, otherFace;
+
+ if (!ftypeInitP) {
+ ftrc = FT_Init_FreeType(&ftypeLibrary);
+ if (ftrc != 0) {
+ ErrorF("FreeType: error initializing ftypeEngine: %d\n", ftrc);
+ return AllocError;
+ }
+ ftypeInitP = 1;
+ }
+
+ /* Try to find a matching face in the hashtable */
+ bucket = hash(FTFileName)%NUMFACEBUCKETS;
+ otherFace = faceTable[bucket];
+ while(otherFace) {
+ if( strcmp(otherFace->filename, FTFileName) == 0 ) break;
+ otherFace = otherFace->next;
+ }
+ if(otherFace) {
+ MUMBLE1("Returning cached face: %s\n", otherFace->filename);
+ *facep = otherFace;
+ return Successful;
+ }
+
+ /* No cached match; need to make a new one */
+ face = (FTFacePtr)xalloc(sizeof(FTFaceRec));
+ if(face == NULL) {
+ return AllocError;
+ }
+ memset(face, 0, sizeof(FTFaceRec));
+
+ face->filename = (char*)xalloc(strlen(FTFileName)+1);
+ if(face->filename == NULL) {
+ xfree(face);
+ return AllocError;
+ }
+ strcpy(face->filename, FTFileName);
+
+ ftrc = FT_New_Face(ftypeLibrary, realFileName, faceNumber, &face->face);
+ if(ftrc != 0) {
+ ErrorF("FreeType: couldn't open face %s: %d\n", FTFileName, ftrc);
+ xfree(face->filename);
+ xfree(face);
+ return BadFontName;
+ }
+
+ face->bitmap = ((face->face->face_flags & FT_FACE_FLAG_SCALABLE) == 0);
+ if(!face->bitmap) {
+ TT_MaxProfile *maxp;
+ maxp = FT_Get_Sfnt_Table(face->face, ft_sfnt_maxp);
+ if(maxp && maxp->maxContours == 0)
+ face->bitmap = 1;
+ }
+ /* Insert face in hashtable and return it */
+ face->next = faceTable[bucket];
+ faceTable[bucket] = face;
+ *facep = face;
+ return Successful;
+}
+
+static void
+FreeTypeFreeFace(FTFacePtr face)
+{
+ int bucket;
+ FTFacePtr otherFace;
+
+ if(!face->instances) {
+ bucket = hash(face->filename) % NUMFACEBUCKETS;
+ if(faceTable[bucket] == face)
+ faceTable[bucket] = face->next;
+ else {
+ otherFace = faceTable[bucket];
+ while(otherFace) {
+ if(otherFace->next == face)
+ break;
+ otherFace = otherFace->next;
+ }
+ if(otherFace && otherFace->next)
+ otherFace->next = otherFace->next->next;
+ else
+ ErrorF("FreeType: freeing unknown face\n");
+ }
+ MUMBLE1("Closing face: %s\n", face->filename);
+ FT_Done_Face(face->face);
+ xfree(face->filename);
+ xfree(face);
+ }
+}
+
+static int
+TransEqual(FTNormalisedTransformationPtr t1, FTNormalisedTransformationPtr t2)
+{
+ if(t1->scale != t2->scale)
+ return 0;
+ else if(t1->xres != t2->xres || t1->yres != t2->yres)
+ return 0;
+ else if(t1->nonIdentity != t2->nonIdentity)
+ return 0;
+ else if(t1->nonIdentity && t2->nonIdentity) {
+ return
+ t1->matrix.xx == t2->matrix.xx &&
+ t1->matrix.yx == t2->matrix.yx &&
+ t1->matrix.yy == t2->matrix.yy &&
+ t1->matrix.xy == t2->matrix.xy;
+ } else
+ return 1;
+}
+
+static int
+BitmapFormatEqual(FontBitmapFormatPtr f1, FontBitmapFormatPtr f2)
+{
+ return
+ f1->bit == f2->bit &&
+ f1->byte == f2->byte &&
+ f1->glyph == f2->glyph;
+}
+
+static int
+TTCapEqual(struct TTCapInfo *t1, struct TTCapInfo *t2)
+{
+ return
+ t1->autoItalic == t2->autoItalic &&
+ t1->scaleWidth == t2->scaleWidth &&
+ t1->scaleBBoxWidth == t2->scaleBBoxWidth &&
+ t1->scaleBBoxHeight == t2->scaleBBoxHeight &&
+ t1->doubleStrikeShift == t2->doubleStrikeShift &&
+ t1->adjustBBoxWidthByPixel == t2->adjustBBoxWidthByPixel &&
+ t1->adjustLeftSideBearingByPixel == t2->adjustLeftSideBearingByPixel &&
+ t1->adjustRightSideBearingByPixel == t2->adjustRightSideBearingByPixel &&
+ t1->flags == t2->flags &&
+ t1->scaleBitmap == t2->scaleBitmap &&
+ /*
+ If we use forceConstantSpacing,
+ we *MUST* allocate new instance.
+ */
+ t1->forceConstantSpacingEnd < 0 &&
+ t2->forceConstantSpacingEnd < 0;
+}
+
+static int
+FTInstanceMatch(FTInstancePtr instance,
+ char *FTFileName, FTNormalisedTransformationPtr trans,
+ int spacing, FontBitmapFormatPtr bmfmt,
+ struct TTCapInfo *tmp_ttcap, FT_Int32 load_flags)
+{
+ if(strcmp(instance->face->filename, FTFileName) != 0) {
+ return 0;
+ } else if(!TransEqual(&instance->transformation, trans)) {
+ return 0;
+ } else if( spacing != instance->spacing ) {
+ return 0;
+ } else if( load_flags != instance->load_flags ) {
+ return 0;
+ } else if(!BitmapFormatEqual(&instance->bmfmt, bmfmt)) {
+ return 0;
+ } else if(!TTCapEqual(&instance->ttcap, tmp_ttcap)) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+static int
+FreeTypeActivateInstance(FTInstancePtr instance)
+{
+ FT_Error ftrc;
+ if(instance->face->active_instance == instance)
+ return Successful;
+
+ ftrc = FT_Activate_Size(instance->size);
+ if(ftrc != 0) {
+ instance->face->active_instance = NULL;
+ ErrorF("FreeType: couldn't activate instance: %d\n", ftrc);
+ return FTtoXReturnCode(ftrc);
+ }
+ FT_Set_Transform(instance->face->face,
+ instance->transformation.nonIdentity ?
+ &instance->transformation.matrix : 0,
+ 0);
+
+ instance->face->active_instance = instance;
+ return Successful;
+}
+
+static int
+FTFindSize(FT_Face face, FTNormalisedTransformationPtr trans,
+ int *x_return, int *y_return)
+{
+ int tx, ty, x, y;
+ int i, j;
+ int d, dd;
+
+ if(trans->nonIdentity)
+ return BadFontName;
+
+ tx = (int)(trans->scale * trans->xres / 72.0 + 0.5);
+ ty = (int)(trans->scale * trans->yres / 72.0 + 0.5);
+
+ d = 100;
+ j = -1;
+ for(i = 0; i < face->num_fixed_sizes; i++) {
+ x = face->available_sizes[i].width;
+ y = face->available_sizes[i].height;
+ if(ABS(x - tx) <= 1 && ABS(y - ty) <= 1) {
+ dd = ABS(x - tx) * ABS(x - tx) + ABS(y - ty) * ABS(y - ty);
+ if(dd < d) {
+ j = i;
+ d = dd;
+ }
+ }
+ }
+ if(j < 0)
+ return BadFontName;
+
+ *x_return = face->available_sizes[j].width;
+ *y_return = face->available_sizes[j].height;
+ return Successful;
+}
+
+static int
+FreeTypeOpenInstance(FTInstancePtr *instance_return, FTFacePtr face,
+ char *FTFileName, FTNormalisedTransformationPtr trans,
+ int spacing, FontBitmapFormatPtr bmfmt,
+ struct TTCapInfo *tmp_ttcap, FT_Int32 load_flags)
+{
+ FT_Error ftrc;
+ int xrc;
+ FTInstancePtr instance, otherInstance;
+
+ /* Search for a matching instance */
+ for(otherInstance = face->instances;
+ otherInstance;
+ otherInstance = otherInstance->next) {
+ if(FTInstanceMatch(otherInstance, FTFileName, trans, spacing, bmfmt,
+ tmp_ttcap, load_flags)) break;
+ }
+ if(otherInstance) {
+ MUMBLE("Returning cached instance\n");
+ otherInstance->refcount++;
+ *instance_return = otherInstance;
+ return Successful;
+ }
+
+ /* None matching found */
+ instance = (FTInstancePtr)xalloc(sizeof(FTInstanceRec));
+ if(instance == NULL) {
+ return AllocError;
+ }
+
+ instance->refcount = 1;
+ instance->face = face;
+
+ instance->load_flags = load_flags;
+ instance->spacing = spacing; /* Actual spacing */
+ instance->pixel_size =0;
+ instance->pixel_width_unit_x =0;
+ instance->pixel_width_unit_y =0;
+ instance->charcellMetrics = NULL;
+ instance->averageWidth = 0;
+ instance->rawAverageWidth = 0;
+ instance->forceConstantMetrics = NULL;
+
+ instance->transformation = *trans;
+ instance->bmfmt = *bmfmt;
+ instance->glyphs = NULL;
+ instance->available = NULL;
+
+ if( 0 <= tmp_ttcap->forceConstantSpacingEnd )
+ instance->nglyphs = 2 * instance->face->face->num_glyphs;
+ else
+ instance->nglyphs = instance->face->face->num_glyphs;
+
+ /* Store the TTCap info. */
+ memcpy((char*)&instance->ttcap, (char*)tmp_ttcap,
+ sizeof(struct TTCapInfo));
+
+ ftrc = FT_New_Size(instance->face->face, &instance->size);
+ if(ftrc != 0) {
+ ErrorF("FreeType: couldn't create size object: %d\n", ftrc);
+ xfree(instance);
+ return FTtoXReturnCode(ftrc);
+ }
+ FreeTypeActivateInstance(instance);
+ if(!face->bitmap) {
+ ftrc = FT_Set_Char_Size(instance->face->face,
+ (int)(trans->scale*(1<<6) + 0.5),
+ (int)(trans->scale*(1<<6) + 0.5),
+ trans->xres, trans->yres);
+ } else {
+ int xsize, ysize;
+ xrc = FTFindSize(face->face, trans, &xsize, &ysize);
+ if(xrc != Successful) {
+ xfree(instance);
+ return xrc;
+ }
+ ftrc = FT_Set_Pixel_Sizes(instance->face->face, xsize, ysize);
+ }
+ if(ftrc != 0) {
+ FT_Done_Size(instance->size);
+ xfree(instance);
+ return FTtoXReturnCode(ftrc);
+ }
+
+ if( FT_IS_SFNT( face->face ) ) {
+ /* See Set_Char_Sizes() in ttdriver.c */
+ FT_Error err;
+ TT_Face tt_face;
+ FT_Long tt_dim_x, tt_dim_y;
+ FT_UShort tt_x_ppem, tt_y_ppem;
+ FT_F26Dot6 tt_char_width, tt_char_height;
+ SFNT_Service sfnt;
+ tt_face=(TT_Face)face->face;
+ tt_char_width = (int)(trans->scale*(1<<6) + 0.5);
+ tt_char_height = (int)(trans->scale*(1<<6) + 0.5);
+ if ( ( tt_face->header.Flags & 8 ) != 0 ) {
+ tt_dim_x = ( ( tt_char_width * trans->xres + (36+32*72) ) / 72 ) & -64;
+ tt_dim_y = ( ( tt_char_height * trans->yres + (36+32*72) ) / 72 ) & -64;
+ }
+ else{
+ tt_dim_x = ( ( tt_char_width * trans->xres + 36 ) / 72 );
+ tt_dim_y = ( ( tt_char_height * trans->yres + 36 ) / 72 );
+ }
+ tt_x_ppem = (FT_UShort)( tt_dim_x >> 6 );
+ tt_y_ppem = (FT_UShort)( tt_dim_y >> 6 );
+ /* See Reset_SBit_Size() in ttobjs.c */
+ sfnt = (SFNT_Service)tt_face->sfnt;
+ err = sfnt->set_sbit_strike(tt_face,tt_x_ppem,tt_y_ppem,&instance->strike_index);
+ if ( err ) instance->strike_index=0xFFFFU;
+ }
+
+ /* maintain a linked list of instances */
+ instance->next = instance->face->instances;
+ instance->face->instances = instance;
+
+ *instance_return = instance;
+ return Successful;
+}
+
+static void
+FreeTypeFreeInstance(FTInstancePtr instance)
+{
+ FTInstancePtr otherInstance;
+
+ if( instance == NULL ) return;
+
+ if(instance->face->active_instance == instance)
+ instance->face->active_instance = NULL;
+ instance->refcount--;
+ if(instance->refcount <= 0) {
+ int i,j;
+
+ if(instance->face->instances == instance)
+ instance->face->instances = instance->next;
+ else {
+ for(otherInstance = instance->face->instances;
+ otherInstance;
+ otherInstance = otherInstance->next)
+ if(otherInstance->next == instance) {
+ otherInstance->next = instance->next;
+ break;
+ }
+ }
+
+ FT_Done_Size(instance->size);
+ FreeTypeFreeFace(instance->face);
+
+ if(instance->charcellMetrics) {
+ xfree(instance->charcellMetrics);
+ }
+ if(instance->forceConstantMetrics) {
+ xfree(instance->forceConstantMetrics);
+ }
+ if(instance->glyphs) {
+ for(i = 0; i < iceil(instance->nglyphs, FONTSEGMENTSIZE); i++) {
+ if(instance->glyphs[i]) {
+ for(j = 0; j < FONTSEGMENTSIZE; j++) {
+ if(instance->available[i][j] ==
+ FT_AVAILABLE_RASTERISED)
+ xfree(instance->glyphs[i][j].bits);
+ }
+ xfree(instance->glyphs[i]);
+ }
+ }
+ xfree(instance->glyphs);
+ }
+ if(instance->available) {
+ for(i = 0; i < iceil(instance->nglyphs, FONTSEGMENTSIZE); i++) {
+ if(instance->available[i])
+ xfree(instance->available[i]);
+ }
+ xfree(instance->available);
+ }
+ xfree(instance);
+ }
+}
+
+static int
+FreeTypeInstanceFindGlyph(unsigned idx_in, int flags, FTInstancePtr instance,
+ CharInfoPtr **glyphs, int ***available,
+ int *found, int *segmentP, int *offsetP)
+{
+ int segment, offset;
+ unsigned idx = idx_in;
+
+ if( 0 <= instance->ttcap.forceConstantSpacingEnd ){
+ if( (flags & FT_FORCE_CONSTANT_SPACING) )
+ idx += instance->nglyphs / 2 ;
+ }
+
+ if(idx > instance->nglyphs) {
+ *found = 0;
+ return Successful;
+ }
+
+ if(*available == NULL) {
+ *available =
+ (int**)xalloc(sizeof(int*) * iceil(instance->nglyphs,
+ FONTSEGMENTSIZE));
+ if(*available == NULL)
+ return AllocError;
+ memset((char*)(*available), 0,
+ sizeof(int*) * iceil(instance->nglyphs, FONTSEGMENTSIZE));
+ }
+
+ segment = ifloor(idx, FONTSEGMENTSIZE);
+ offset = idx - segment * FONTSEGMENTSIZE;
+
+ if((*available)[segment] == NULL) {
+ (*available)[segment] = (int*)xalloc(sizeof(int) * FONTSEGMENTSIZE);
+ if((*available)[segment] == NULL)
+ return AllocError;
+ memset((char*)(*available)[segment], 0, sizeof(int) * FONTSEGMENTSIZE);
+ }
+
+ if(*glyphs == NULL) {
+ *glyphs = (CharInfoPtr*)xalloc(sizeof(CharInfoPtr)*
+ iceil(instance->nglyphs,
+ FONTSEGMENTSIZE));
+ if(*glyphs == NULL)
+ return AllocError;
+ memset((char*)(*glyphs), 0,
+ sizeof(CharInfoPtr)*iceil(instance->nglyphs, FONTSEGMENTSIZE));
+ }
+
+ if((*glyphs)[segment] == NULL) {
+ (*glyphs)[segment]=
+ (CharInfoPtr)xalloc(sizeof(CharInfoRec) * FONTSEGMENTSIZE);
+ if((*glyphs)[segment] == NULL)
+ return AllocError;
+ }
+
+ *found = 1;
+ *segmentP = segment;
+ *offsetP = offset;
+ return Successful;
+}
+
+static int
+FreeTypeInstanceGetGlyph(unsigned idx, int flags, CharInfoPtr *g, FTInstancePtr instance)
+{
+ int found, segment, offset;
+ int xrc;
+ int ***available;
+ CharInfoPtr **glyphs;
+
+ available = &instance->available;
+ glyphs = &instance->glyphs;
+
+ xrc = FreeTypeInstanceFindGlyph(idx, flags, instance, glyphs, available,
+ &found, &segment, &offset);
+ if(xrc != Successful)
+ return xrc;
+
+ if(!found || (*available)[segment][offset] == FT_AVAILABLE_NO) {
+ *g = NULL;
+ return Successful;
+ }
+
+ if((*available)[segment][offset] == FT_AVAILABLE_RASTERISED) {
+ *g = &(*glyphs)[segment][offset];
+ return Successful;
+ }
+
+ flags |= FT_GET_GLYPH_BOTH;
+
+ xrc = FreeTypeRasteriseGlyph(idx, flags,
+ &(*glyphs)[segment][offset], instance,
+ (*available)[segment][offset] >= FT_AVAILABLE_METRICS);
+ if(xrc != Successful && (*available)[segment][offset] >= FT_AVAILABLE_METRICS) {
+ ErrorF("Warning: FreeTypeRasteriseGlyph() returns an error,\n");
+ ErrorF("\tso the backend tries to set a white space.\n");
+ xrc = FreeTypeRasteriseGlyph(idx, flags | FT_GET_DUMMY,
+ &(*glyphs)[segment][offset], instance,
+ (*available)[segment][offset] >= FT_AVAILABLE_METRICS);
+ }
+ if(xrc == Successful) {
+ (*available)[segment][offset] = FT_AVAILABLE_RASTERISED;
+ /* return the glyph */
+ *g = &(*glyphs)[segment][offset];
+ }
+ return xrc;
+}
+
+static int
+FreeTypeInstanceGetGlyphMetrics(unsigned idx, int flags,
+ xCharInfo **metrics, FTInstancePtr instance )
+{
+ int xrc;
+ int found, segment, offset;
+
+ /* Char cell */
+ if(instance->spacing == FT_CHARCELL) {
+ *metrics = instance->charcellMetrics;
+ return Successful;
+ }
+ /* Force constant metrics */
+ if( flags & FT_FORCE_CONSTANT_SPACING) {
+ *metrics = instance->forceConstantMetrics;
+ return Successful;
+ }
+
+ /* Not char cell */
+
+ xrc = FreeTypeInstanceFindGlyph(idx, flags, instance,
+ &instance->glyphs, &instance->available,
+ &found, &segment, &offset);
+ if(xrc != Successful)
+ return xrc;
+ if(!found) {
+ *metrics = NULL;
+ return Successful;
+ }
+ if( instance->available[segment][offset] == FT_AVAILABLE_NO ) {
+ *metrics = NULL;
+ return Successful;
+ }
+
+ if( instance->available[segment][offset] >= FT_AVAILABLE_METRICS ) {
+ *metrics = &instance->glyphs[segment][offset].metrics;
+ return Successful;
+ }
+
+ flags |= FT_GET_GLYPH_METRICS_ONLY;
+
+ xrc = FreeTypeRasteriseGlyph(idx, flags,
+ &instance->glyphs[segment][offset],
+ instance, 0);
+ if(xrc == Successful) {
+ instance->available[segment][offset] = FT_AVAILABLE_METRICS;
+ *metrics = &instance->glyphs[segment][offset].metrics;
+ }
+ return xrc;
+}
+
+/*
+ * Pseudo enbolding similar as Microsoft Windows.
+ * It is useful but poor.
+ */
+static void
+ft_make_up_bold_bitmap( char *raster, int bpr, int ht, int ds_mode)
+{
+ int x, y;
+ unsigned char *p = (unsigned char *)raster;
+ if ( ds_mode & TTCAP_DOUBLE_STRIKE_MKBOLD_EDGE_LEFT ) {
+ for (y=0; y<ht; y++) {
+ unsigned char rev_pat=0;
+ unsigned char lsb = 0;
+ for (x=0; x<bpr; x++) {
+ unsigned char tmp = *p<<7;
+ if ( (rev_pat & 0x01) && (*p & 0x80) ) p[-1] &= 0xfe;
+ rev_pat = ~(*p);
+ *p |= (*p>>1) | lsb;
+ *p &= ~(rev_pat & (*p << 1));
+ lsb = tmp;
+ p++;
+ }
+ }
+ }
+ else {
+ for (y=0; y<ht; y++) {
+ unsigned char lsb = 0;
+ for (x=0; x<bpr; x++) {
+ unsigned char tmp = *p<<7;
+ *p |= (*p>>1) | lsb;
+ lsb = tmp;
+ p++;
+ }
+ }
+ }
+}
+
+static void
+ft_make_up_italic_bitmap( char *raster, int bpr, int ht, int shift,
+ int h_total, int h_offset, double a_italic)
+{
+ int x, y;
+ unsigned char *p = (unsigned char *)raster;
+ if ( a_italic < 0 ) shift = -shift;
+ for (y=0; y<ht; y++) {
+ unsigned char *tmp_p = p + y*bpr;
+ int tmp_shift = shift * (h_total -1 -(y+h_offset)) / h_total;
+ int tmp_byte_shift;
+ if ( 0 <= tmp_shift ) {
+ tmp_byte_shift = tmp_shift/8;
+ tmp_shift %= 8;
+ if ( tmp_shift ) {
+ for (x=bpr-1;0<=x;x--) {
+ if ( x != bpr-1 )
+ tmp_p[x+1] |= tmp_p[x]<<(8-tmp_shift);
+ tmp_p[x]>>=tmp_shift;
+ }
+ }
+ if ( tmp_byte_shift ) {
+ for (x=bpr-1;0<x;x--) {
+ tmp_p[x] = tmp_p[x-1];
+ }
+ tmp_p[x]=0;
+ }
+ }
+ else {
+ tmp_shift = -tmp_shift;
+ tmp_byte_shift = tmp_shift/8;
+ tmp_shift %= 8;
+ if ( tmp_shift ) {
+ for (x=0;x<bpr;x++) {
+ if ( x != 0 )
+ tmp_p[x-1] |= tmp_p[x]>>(8-tmp_shift);
+ tmp_p[x]<<=tmp_shift;
+ }
+ }
+ if ( tmp_byte_shift ) {
+ for (x=0;x<bpr-1;x++) {
+ tmp_p[x] = tmp_p[x+1];
+ }
+ tmp_p[x]=0;
+ }
+ }
+ }
+}
+
+/*
+ * The very lazy method,
+ * parse the htmx field in TrueType font.
+ */
+
+/* from src/truetype/ttgload.c */
+static void
+tt_get_metrics( TT_HoriHeader* header,
+ FT_UInt idx,
+ FT_Short* bearing,
+ FT_UShort* advance )
+/* Copyright 1996-2001, 2002 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+{
+ TT_LongMetrics longs_m;
+ FT_UShort k = header->number_Of_HMetrics;
+
+ if ( k == 0 ) {
+ *bearing = *advance = 0;
+ return;
+ }
+
+ if ( idx < (FT_UInt)k ) {
+ longs_m = (TT_LongMetrics )header->long_metrics + idx;
+ *bearing = longs_m->bearing;
+ *advance = longs_m->advance;
+ }
+ else {
+ *bearing = ((TT_ShortMetrics*)header->short_metrics)[idx - k];
+ *advance = ((TT_LongMetrics )header->long_metrics)[k - 1].advance;
+ }
+}
+
+static int
+ft_get_very_lazy_bbox( FT_UInt index,
+ FT_Face face,
+ FT_Size size,
+ double slant,
+ FT_Matrix *matrix,
+ FT_BBox *bbox,
+ FT_Long *horiAdvance,
+ FT_Long *vertAdvance)
+{
+ if ( FT_IS_SFNT( face ) ) {
+ TT_Face ttface = (TT_Face)face;
+ FT_Size_Metrics *smetrics = &size->metrics;
+ FT_Short leftBearing = 0;
+ FT_UShort advance = 0;
+ FT_Vector p0, p1, p2, p3;
+
+ /* horizontal */
+ tt_get_metrics(&ttface->horizontal, index,
+ &leftBearing, &advance);
+
+#if 0
+ fprintf(stderr,"x_scale=%f y_scale=%f\n",
+ (double)smetrics->x_scale,(double)smetrics->y_scale);
+#endif
+ bbox->xMax = *horiAdvance =
+ FT_MulFix( advance, smetrics->x_scale );
+ bbox->xMin =
+ FT_MulFix( leftBearing, smetrics->x_scale );
+ /* vertical */
+ bbox->yMin = FT_MulFix( face->bbox.yMin,
+ smetrics->y_scale );
+ bbox->yMax = FT_MulFix( face->bbox.yMax,
+ smetrics->y_scale );
+ /* slant */
+ if( 0 < slant ) {
+ bbox->xMax += slant * bbox->yMax;
+ bbox->xMin += slant * bbox->yMin;
+ }
+ else if( slant < 0 ) {
+ bbox->xMax += slant * bbox->yMin;
+ bbox->xMin += slant * bbox->yMax;
+ }
+
+ *vertAdvance = -1; /* We don't support */
+
+ p0.x = p2.x = bbox->xMin;
+ p1.x = p3.x = bbox->xMax;
+ p0.y = p1.y = bbox->yMin;
+ p2.y = p3.y = bbox->yMax;
+
+ FT_Vector_Transform(&p0, matrix);
+ FT_Vector_Transform(&p1, matrix);
+ FT_Vector_Transform(&p2, matrix);
+ FT_Vector_Transform(&p3, matrix);
+
+#if 0
+ fprintf(stderr,
+ "->(%.1f %.1f) (%.1f %.1f)"
+ " (%.1f %.1f) (%.1f %.1f)\n",
+ p0.x / 64.0, p0.y / 64.0,
+ p1.x / 64.0, p1.y / 64.0,
+ p2.x / 64.0, p2.y / 64.0,
+ p3.x / 64.0, p3.y / 64.0);
+#endif
+ bbox->xMin = MIN(p0.x, MIN(p1.x, MIN(p2.x, p3.x)));
+ bbox->xMax = MAX(p0.x, MAX(p1.x, MAX(p2.x, p3.x)));
+ bbox->yMin = MIN(p0.y, MIN(p1.y, MIN(p2.y, p3.y)));
+ bbox->yMax = MAX(p0.y, MAX(p1.y, MAX(p2.y, p3.y)));
+ return 0; /* Successful */
+ }
+ return -1;
+}
+
+static FT_Error
+FT_Do_SBit_Metrics( FT_Face ft_face, FT_Size ft_size, FT_ULong strike_index,
+ FT_UShort glyph_index, FT_Glyph_Metrics *metrics_return,
+ int *sbitchk_incomplete_but_exist )
+{
+#if (FREETYPE_VERSION >= 2001008)
+ SFNT_Service sfnt;
+ TT_Face face;
+ FT_Error error;
+ FT_Stream stream;
+ TT_SBit_Strike strike;
+ TT_SBit_Range range;
+ TT_SBit_MetricsRec elem_metrics;
+ FT_ULong ebdt_pos;
+ FT_ULong glyph_offset;
+ ;
+
+ if ( ! FT_IS_SFNT( ft_face ) )
+ {
+ error=-1;
+ goto Exit;
+ }
+
+ face = (TT_Face)ft_face;
+ sfnt = (SFNT_Service)face->sfnt;
+
+ if (strike_index != 0xFFFFU && sfnt && sfnt->find_sbit_image &&
+ sfnt->load_sbits) {
+ /* Check whether there is a glyph sbit for the current index */
+ error = sfnt->find_sbit_image( face, glyph_index, strike_index,
+ &range, &strike, &glyph_offset );
+ }
+ else error=-1;
+ if ( error ) goto Exit;
+
+ if ( metrics_return == NULL ) goto Exit;
+
+ stream = face->root.stream;
+
+ /* now, find the location of the `EBDT' table in */
+ /* the font file */
+ error = face->goto_table( face, TTAG_EBDT, stream, 0 );
+ if ( error )
+ error = face->goto_table( face, TTAG_bdat, stream, 0 );
+ if (error)
+ goto Exit;
+
+ ebdt_pos = FT_STREAM_POS();
+
+ /* place stream at beginning of glyph data and read metrics */
+ if ( FT_STREAM_SEEK( ebdt_pos + glyph_offset ) )
+ goto Exit;
+
+ error = sfnt->load_sbit_metrics( stream, range, &elem_metrics );
+ if ( error )
+ goto Exit;
+
+ metrics_return->width = (FT_Pos)elem_metrics.width << 6;
+ metrics_return->height = (FT_Pos)elem_metrics.height << 6;
+
+ metrics_return->horiBearingX = (FT_Pos)elem_metrics.horiBearingX << 6;
+ metrics_return->horiBearingY = (FT_Pos)elem_metrics.horiBearingY << 6;
+ metrics_return->horiAdvance = (FT_Pos)elem_metrics.horiAdvance << 6;
+
+ metrics_return->vertBearingX = (FT_Pos)elem_metrics.vertBearingX << 6;
+ metrics_return->vertBearingY = (FT_Pos)elem_metrics.vertBearingY << 6;
+ metrics_return->vertAdvance = (FT_Pos)elem_metrics.vertAdvance << 6;
+
+ Exit:
+ return error;
+#else /* if (FREETYPE_VERSION < 2001008) */
+ TT_Face face;
+ SFNT_Service sfnt;
+ if ( ! FT_IS_SFNT( ft_face ) ) return -1;
+ face = (TT_Face)ft_face;
+ sfnt = (SFNT_Service)face->sfnt;
+ if ( strike_index != 0xFFFFU && sfnt->load_sbits ) {
+ if ( sbitchk_incomplete_but_exist ) *sbitchk_incomplete_but_exist=1;
+ }
+ return -1;
+#endif
+}
+
+int
+FreeTypeRasteriseGlyph(unsigned idx, int flags, CharInfoPtr tgp,
+ FTInstancePtr instance, int hasMetrics)
+{
+ FTFacePtr face;
+ FT_BBox bbox;
+ FT_Long outline_hori_advance, outline_vert_advance;
+ FT_Glyph_Metrics sbit_metrics;
+ FT_Glyph_Metrics *bitmap_metrics=NULL, *metrics = NULL;
+ char *raster;
+ int wd, ht, bpr; /* width, height, bytes per row */
+ int wd_actual, ht_actual;
+ int ftrc, is_outline, correct, b_shift=0;
+ int dx, dy;
+ int leftSideBearing, rightSideBearing, characterWidth, rawCharacterWidth,
+ ascent, descent;
+ int sbitchk_incomplete_but_exist;
+ double bbox_center_raw;
+
+ face = instance->face;
+
+ FreeTypeActivateInstance(instance);
+
+ if(!tgp) return AllocError;
+
+ /*
+ * PREPARE METRICS
+ */
+
+ if(!hasMetrics) {
+ if( instance->spacing == FT_CHARCELL || flags & FT_GET_DUMMY ){
+ memcpy((char*)&tgp->metrics,
+ (char*)instance->charcellMetrics,
+ sizeof(xCharInfo));
+ }
+ else if( flags & FT_FORCE_CONSTANT_SPACING ) {
+ memcpy((char*)&tgp->metrics,
+ (char*)instance->forceConstantMetrics,
+ sizeof(xCharInfo));
+ }
+ /* mono or prop. */
+ else{
+ int new_width;
+ double ratio;
+
+ sbitchk_incomplete_but_exist=0;
+ if( ! (instance->load_flags & FT_LOAD_NO_BITMAP) ) {
+ if( FT_Do_SBit_Metrics(face->face,instance->size,instance->strike_index,
+ idx,&sbit_metrics,&sbitchk_incomplete_but_exist)==0 ) {
+ bitmap_metrics = &sbit_metrics;
+ }
+ }
+ if( bitmap_metrics == NULL ) {
+ if ( sbitchk_incomplete_but_exist==0 && (instance->ttcap.flags & TTCAP_IS_VERY_LAZY) ) {
+ if( ft_get_very_lazy_bbox( idx, face->face, instance->size,
+ instance->ttcap.vl_slant,
+ &instance->transformation.matrix,
+ &bbox, &outline_hori_advance,
+ &outline_vert_advance ) == 0 ) {
+ goto bbox_ok; /* skip exact calculation */
+ }
+ }
+ ftrc = FT_Load_Glyph(instance->face->face, idx,
+ instance->load_flags);
+ if(ftrc != 0) return FTtoXReturnCode(ftrc);
+ metrics = &face->face->glyph->metrics;
+ if( face->face->glyph->format == FT_GLYPH_FORMAT_BITMAP ) {
+ bitmap_metrics = metrics;
+ }
+ }
+
+ if( bitmap_metrics ) {
+ FT_Pos factor;
+
+ leftSideBearing = bitmap_metrics->horiBearingX / 64;
+ rightSideBearing = (bitmap_metrics->width + bitmap_metrics->horiBearingX) / 64;
+ bbox_center_raw = (2.0 * bitmap_metrics->horiBearingX + bitmap_metrics->width)/2.0/64.0;
+ characterWidth = (int)floor(bitmap_metrics->horiAdvance
+ * instance->ttcap.scaleBBoxWidth / 64.0 + .5);
+ ascent = bitmap_metrics->horiBearingY / 64;
+ descent = (bitmap_metrics->height - bitmap_metrics->horiBearingY) / 64 ;
+ /* */
+ new_width = characterWidth;
+ if( instance->ttcap.flags & TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH )
+ new_width += instance->ttcap.doubleStrikeShift;
+ new_width += instance->ttcap.adjustBBoxWidthByPixel;
+ ratio = (double)new_width/characterWidth;
+ characterWidth = new_width;
+ /* adjustment by pixel unit */
+ if( instance->ttcap.flags & TTCAP_DOUBLE_STRIKE )
+ rightSideBearing += instance->ttcap.doubleStrikeShift;
+ rightSideBearing += instance->ttcap.adjustRightSideBearingByPixel;
+ leftSideBearing += instance->ttcap.adjustLeftSideBearingByPixel;
+ rightSideBearing += instance->ttcap.rsbShiftOfBitmapAutoItalic;
+ leftSideBearing += instance->ttcap.lsbShiftOfBitmapAutoItalic;
+ /* */
+ factor = bitmap_metrics->horiAdvance;
+ rawCharacterWidth = (unsigned short)(short)(floor(1000 * factor
+ * instance->ttcap.scaleBBoxWidth * ratio / 64.
+ / instance->pixel_size));
+ }
+ else {
+ /* Outline */
+#ifdef USE_GET_CBOX
+ /* Very fast?? */
+ FT_Outline_Get_CBox(&face->face->glyph->outline, &bbox);
+ ftrc=0; /* FT_Outline_Get_CBox returns nothing. */
+#else
+ /* Calculate exact metrics */
+ ftrc=FT_Outline_Get_BBox(&face->face->glyph->outline, &bbox);
+#endif
+ if( ftrc != 0 ) return FTtoXReturnCode(ftrc);
+ outline_hori_advance = metrics->horiAdvance;
+ outline_vert_advance = metrics->vertAdvance;
+ bbox_ok:
+ descent = CEIL64(-bbox.yMin - 32) / 64;
+ leftSideBearing = FLOOR64(bbox.xMin + 32) / 64;
+ ascent = FLOOR64(bbox.yMax + 32) / 64;
+ rightSideBearing = FLOOR64(bbox.xMax + 32) / 64;
+ bbox_center_raw = (double)(bbox.xMax + bbox.xMin)/2.0/64.;
+ if ( instance->pixel_width_unit_x != 0 )
+ characterWidth =
+ (int)floor( outline_hori_advance
+ * instance->ttcap.scaleBBoxWidth
+ * instance->pixel_width_unit_x / 64. + .5);
+ else {
+ characterWidth =
+ (int)floor( outline_vert_advance
+ * instance->ttcap.scaleBBoxHeight
+ * instance->pixel_width_unit_y / 64. + .5);
+ if(characterWidth <= 0)
+ characterWidth = instance->charcellMetrics->characterWidth;
+ }
+ /* */
+ new_width = characterWidth;
+ if( instance->ttcap.flags & TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH )
+ new_width += instance->ttcap.doubleStrikeShift;
+ new_width += instance->ttcap.adjustBBoxWidthByPixel;
+ ratio = (double)new_width/characterWidth;
+ characterWidth = new_width;
+ if ( instance->pixel_width_unit_x != 0 )
+ rawCharacterWidth =
+ (unsigned short)(short)(floor(1000 * outline_hori_advance
+ * instance->ttcap.scaleBBoxWidth * ratio
+ * instance->pixel_width_unit_x / 64.));
+ else {
+ rawCharacterWidth =
+ (unsigned short)(short)(floor(1000 * outline_vert_advance
+ * instance->ttcap.scaleBBoxHeight * ratio
+ * instance->pixel_width_unit_y / 64.));
+ if(rawCharacterWidth <= 0)
+ rawCharacterWidth = instance->charcellMetrics->attributes;
+ }
+ /* adjustment by pixel unit */
+ if( instance->ttcap.flags & TTCAP_DOUBLE_STRIKE )
+ rightSideBearing += instance->ttcap.doubleStrikeShift;
+ rightSideBearing += instance->ttcap.adjustRightSideBearingByPixel;
+ leftSideBearing += instance->ttcap.adjustLeftSideBearingByPixel;
+ }
+
+ /* Set the glyph metrics. */
+ tgp->metrics.attributes = (unsigned short)((short)rawCharacterWidth);
+ tgp->metrics.leftSideBearing = leftSideBearing;
+ tgp->metrics.rightSideBearing = rightSideBearing;
+ tgp->metrics.characterWidth = characterWidth;
+ tgp->metrics.ascent = ascent;
+ tgp->metrics.descent = descent;
+ /* Update the width to match the width of the font */
+ if( instance->spacing != FT_PROPORTIONAL )
+ tgp->metrics.characterWidth = instance->charcellMetrics->characterWidth;
+ if(instance->ttcap.flags & TTCAP_MONO_CENTER){
+ b_shift = (int)floor((instance->advance/2.0-bbox_center_raw) + .5);
+ tgp->metrics.leftSideBearing += b_shift;
+ tgp->metrics.rightSideBearing += b_shift;
+ }
+ }
+ }
+
+ if( flags & FT_GET_GLYPH_METRICS_ONLY ) return Successful;
+
+ /*
+ * CHECK THE NECESSITY OF BITMAP POSITION'S CORRECTION
+ */
+
+ correct=0;
+ if( instance->spacing == FT_CHARCELL ) correct=1;
+ else if( flags & FT_FORCE_CONSTANT_SPACING ) correct=1;
+ else{
+ int sbit_available=0;
+ sbitchk_incomplete_but_exist=0;
+ if( !(instance->load_flags & FT_LOAD_NO_BITMAP) ) {
+ if( FT_Do_SBit_Metrics(face->face,instance->size,
+ instance->strike_index,idx,NULL,
+ &sbitchk_incomplete_but_exist)==0 ) {
+ sbit_available=1;
+ }
+ }
+ if( sbit_available == 0 ) {
+ if ( sbitchk_incomplete_but_exist==0 && (instance->ttcap.flags & TTCAP_IS_VERY_LAZY) ) {
+ if( FT_IS_SFNT(face->face) ) correct=1;
+ }
+ }
+ }
+
+ /*
+ * RENDER AND ALLOCATE BUFFER
+ */
+
+ if( flags & FT_GET_DUMMY ) is_outline = -1;
+ else {
+ if( !metrics ) {
+ ftrc = FT_Load_Glyph(instance->face->face, idx,
+ instance->load_flags);
+ metrics = &face->face->glyph->metrics;
+
+ if(ftrc != 0) return FTtoXReturnCode(ftrc);
+ }
+
+ if( face->face->glyph->format != FT_GLYPH_FORMAT_BITMAP ) {
+ ftrc = FT_Render_Glyph(face->face->glyph,FT_RENDER_MODE_MONO);
+ if( ftrc != 0 ) return FTtoXReturnCode(ftrc);
+ is_outline = 1;
+ }
+ else{
+ is_outline=0;
+ }
+ }
+
+ /* Spacial case */
+ if( (instance->ttcap.flags & TTCAP_MONO_CENTER) && hasMetrics ) {
+ if( is_outline == 1 ){
+ if( correct ){
+ if( ft_get_very_lazy_bbox( idx, face->face, instance->size,
+ instance->ttcap.vl_slant,
+ &instance->transformation.matrix,
+ &bbox, &outline_hori_advance,
+ &outline_vert_advance ) != 0 ){
+ is_outline = -1; /* <- error */
+ }
+ }
+ else {
+#ifdef USE_GET_CBOX
+ FT_Outline_Get_CBox(&face->face->glyph->outline, &bbox);
+ ftrc=0;
+#else
+ ftrc=FT_Outline_Get_BBox(&face->face->glyph->outline, &bbox);
+#endif
+ if( ftrc != 0 ) return FTtoXReturnCode(ftrc);
+ }
+ bbox_center_raw = (double)(bbox.xMax + bbox.xMin)/2.0/64.;
+ }
+ else if( is_outline == 0 )
+ bbox_center_raw = (2.0 * metrics->horiBearingX + metrics->width)/2.0/64.0;
+ else
+ bbox_center_raw = 0;
+ b_shift = (int)floor((instance->advance/2.0-bbox_center_raw) + .5);
+ }
+
+ wd_actual = tgp->metrics.rightSideBearing - tgp->metrics.leftSideBearing;
+ ht_actual = tgp->metrics.ascent + tgp->metrics.descent;
+
+ /* The X convention is to consider a character with an empty
+ * bounding box as undefined. This convention is broken. */
+
+ if(wd_actual <= 0) wd = 1;
+ else wd=wd_actual;
+ if(ht_actual <= 0) ht = 1;
+ else ht=ht_actual;
+
+ bpr = (((wd + (instance->bmfmt.glyph<<3) - 1) >> 3) &
+ -instance->bmfmt.glyph);
+ raster = (char*)xalloc(ht * bpr);
+ if(raster == NULL)
+ return AllocError;
+ memset(raster, 0, ht * bpr);
+
+ tgp->bits = raster;
+
+ /* If FT_GET_DUMMY is set, we return white space. */
+ if ( is_outline == -1 ) return Successful;
+
+ if ( wd_actual <= 0 || ht_actual <= 0 ) return Successful;
+
+ /*
+ * CALCULATE OFFSET, dx AND dy.
+ */
+
+ dx = face->face->glyph->bitmap_left - tgp->metrics.leftSideBearing;
+ dy = tgp->metrics.ascent - face->face->glyph->bitmap_top;
+
+ if(instance->ttcap.flags & TTCAP_MONO_CENTER)
+ dx += b_shift;
+
+ /* To prevent chipped bitmap, we correct dx and dy if needed. */
+ if( correct && is_outline==1 ){
+ int lsb, rsb, asc, des;
+ int chip_left,chip_right,chip_top,chip_bot;
+#ifdef USE_GET_CBOX
+ FT_Outline_Get_CBox(&face->face->glyph->outline, &bbox);
+ ftrc=0;
+#else
+ ftrc=FT_Outline_Get_BBox(&face->face->glyph->outline, &bbox);
+#endif
+ if( ftrc != 0 ) return FTtoXReturnCode(ftrc);
+ des = CEIL64(-bbox.yMin - 32) / 64;
+ lsb = FLOOR64(bbox.xMin + 32) / 64;
+ asc = FLOOR64(bbox.yMax + 32) / 64;
+ rsb = FLOOR64(bbox.xMax + 32) / 64;
+ rightSideBearing = tgp->metrics.rightSideBearing;
+ leftSideBearing = tgp->metrics.leftSideBearing;
+ if( instance->ttcap.flags & TTCAP_DOUBLE_STRIKE )
+ rightSideBearing -= instance->ttcap.doubleStrikeShift;
+ /* special case */
+ if(instance->ttcap.flags & TTCAP_MONO_CENTER){
+ leftSideBearing -= b_shift;
+ rightSideBearing -= b_shift;
+ }
+ chip_left = lsb - leftSideBearing;
+ chip_right = rightSideBearing - rsb;
+ if( flags & FT_FORCE_CONSTANT_SPACING ){
+ if( instance->ttcap.force_c_adjust_lsb_by_pixel != 0 ||
+ instance->ttcap.force_c_adjust_rsb_by_pixel != 0 ){
+ chip_left=0;
+ chip_right=0;
+ }
+ }
+ else{
+ if( instance->ttcap.adjustRightSideBearingByPixel != 0 ||
+ instance->ttcap.adjustLeftSideBearingByPixel != 0 ){
+ chip_left=0;
+ chip_right=0;
+ }
+ }
+ chip_top = tgp->metrics.ascent - asc;
+ chip_bot = tgp->metrics.descent - des;
+ if( chip_left < 0 && 0 < chip_right ) dx++;
+ else if( chip_right < 0 && 0 < chip_left ) dx--;
+ if( chip_top < 0 && 0 < chip_bot ) dy++;
+ else if( chip_bot < 0 && 0 < chip_top ) dy--;
+ }
+
+ /*
+ * COPY RASTER
+ */
+
+ {
+ FT_Bitmap *bitmap;
+ int i, j;
+ unsigned char *current_raster;
+ unsigned char *current_buffer;
+ int mod_dx0,mod_dx1;
+ int div_dx;
+ bitmap = &face->face->glyph->bitmap;
+ if( 0 <= dx ){
+ div_dx = dx / 8;
+ mod_dx0 = dx % 8;
+ mod_dx1 = 8-mod_dx0;
+ }
+ else{
+ div_dx = dx / 8 -1;
+ mod_dx1 = -dx % 8;
+ mod_dx0 = 8-mod_dx1;
+ }
+ for( i = MAX(0, dy) ; i<ht ; i++ ){
+ int prev_jj,jj;
+ if( bitmap->rows <= i-dy ) break;
+ current_buffer=(unsigned char *)(bitmap->buffer+bitmap->pitch*(i-dy));
+ current_raster=(unsigned char *)(raster+i*bpr);
+ j = MAX(0,div_dx);
+ jj = j-div_dx;
+ prev_jj = jj-1;
+ if( j<bpr ){
+ if( 0 <= prev_jj && prev_jj < bitmap->pitch )
+ current_raster[j]|=current_buffer[prev_jj]<<mod_dx1;
+ if( 0 <= jj && jj < bitmap->pitch ){
+ current_raster[j]|=current_buffer[jj]>>mod_dx0;
+ j++; prev_jj++; jj++;
+ for( ; j<bpr ; j++,prev_jj++,jj++ ){
+ current_raster[j]|=current_buffer[prev_jj]<<mod_dx1;
+ if( bitmap->pitch <= jj ) break;
+ current_raster[j]|=current_buffer[jj]>>mod_dx0;
+ }
+ }
+ }
+ }
+ }
+
+ /* by TTCap */
+ if ( instance->ttcap.flags & TTCAP_DOUBLE_STRIKE ) {
+ int i;
+ for( i=0 ; i < instance->ttcap.doubleStrikeShift ; i++ )
+ ft_make_up_bold_bitmap( raster, bpr, ht, instance->ttcap.flags);
+ }
+ if ( is_outline == 0 &&
+ ( instance->ttcap.lsbShiftOfBitmapAutoItalic != 0 ||
+ instance->ttcap.rsbShiftOfBitmapAutoItalic != 0 ) ) {
+ ft_make_up_italic_bitmap( raster, bpr, ht,
+ - instance->ttcap.lsbShiftOfBitmapAutoItalic
+ + instance->ttcap.rsbShiftOfBitmapAutoItalic,
+ instance->charcellMetrics->ascent
+ + instance->charcellMetrics->descent,
+ instance->charcellMetrics->ascent
+ - tgp->metrics.ascent,
+ instance->ttcap.autoItalic);
+ }
+
+ if(instance->bmfmt.bit == LSBFirst) {
+ BitOrderInvert((unsigned char*)(tgp->bits), ht*bpr);
+ }
+
+ if(instance->bmfmt.byte != instance->bmfmt.bit) {
+ switch(instance->bmfmt.scan) {
+ case 1:
+ break;
+ case 2:
+ TwoByteSwap((unsigned char*)(tgp->bits), ht*bpr);
+ break;
+ case 4:
+ FourByteSwap((unsigned char*)(tgp->bits), ht*bpr);
+ break;
+ default:
+ ;
+ }
+ }
+
+ return Successful;
+}
+
+static void
+FreeTypeFreeFont(FTFontPtr font)
+{
+ FreeTypeFreeInstance(font->instance);
+ if(font->ranges)
+ xfree(font->ranges);
+ if(font->dummy_char.bits)
+ xfree(font->dummy_char.bits);
+ xfree(font);
+}
+
+/* Free a font. If freeProps is 0, don't free the properties. */
+
+static void
+FreeTypeFreeXFont(FontPtr pFont, int freeProps)
+{
+ FTFontPtr tf;
+
+ if(pFont) {
+ if((tf = (FTFontPtr)pFont->fontPrivate)) {
+ FreeTypeFreeFont(tf);
+ }
+ if(freeProps && pFont->info.nprops>0) {
+ xfree(pFont->info.isStringProp);
+ xfree(pFont->info.props);
+ }
+ DestroyFontRec(pFont);
+ }
+}
+
+
+/* Unload a font */
+
+static void
+FreeTypeUnloadXFont(FontPtr pFont)
+{
+ MUMBLE("Unloading\n");
+ FreeTypeFreeXFont(pFont, 1);
+}
+
+/* Add the font properties, including the Font name, the XLFD
+ properties, some strings from the font, and various typographical
+ data. We only provide data readily available in the tables in the
+ font for now, altough FIGURE_WIDTH would be a good idea as it is
+ used by Xaw. */
+
+static int
+FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
+ char *fontname, int rawAverageWidth, Bool font_properties)
+{
+ int i, j, maxprops;
+ char *sp, *ep, val[MAXFONTNAMELEN], *vp;
+ FTFacePtr face;
+ FTInstancePtr instance;
+ FTNormalisedTransformationPtr trans;
+ int upm;
+ TT_OS2 *os2;
+ TT_Postscript *post;
+ PS_FontInfoRec t1info_rec, *t1info;
+ int xlfdProps = 0;
+ int ftrc;
+
+ instance = font->instance;
+ face = instance->face;
+ trans = &instance->transformation;
+ upm = face->face->units_per_EM;
+ if(upm == 0) {
+ /* Work around FreeType bug */
+ upm = WORK_AROUND_UPM;
+ }
+
+ os2 = FT_Get_Sfnt_Table(face->face, ft_sfnt_os2);
+ post = FT_Get_Sfnt_Table(face->face, ft_sfnt_post);
+ ftrc = FT_Get_PS_Font_Info(face->face, &t1info_rec);
+ if(ftrc == 0)
+ t1info = &t1info_rec;
+ else
+ t1info = NULL;
+
+ if(t1info) {
+ os2 = NULL;
+ post = NULL;
+ }
+
+ info->nprops = 0; /* in case we abort */
+
+ strcpy(val, fontname);
+ if(FontParseXLFDName(val, vals, FONT_XLFD_REPLACE_VALUE)) {
+ xlfdProps = 1;
+ } else {
+ MUMBLE("Couldn't parse XLFD\n");
+ xlfdProps = 0;
+ }
+
+ maxprops=
+ 1 + /* NAME */
+ (xlfdProps ? 14 : 0) + /* from XLFD */
+ 5 +
+ ( !face->bitmap ? 3 : 0 ) + /* raw_av,raw_asc,raw_dec */
+ ( font_properties ? 2 : 0 ) + /* asc,dec */
+ ( (font_properties && os2) ? 6 : 0 ) +
+ ( (font_properties && (post || t1info)) ? 3 : 0 ) +
+ 2; /* type */
+
+ info->props = (FontPropPtr)xalloc(maxprops * sizeof(FontPropRec));
+ if(info->props == NULL)
+ return AllocError;
+
+ info->isStringProp = (char*)xalloc(maxprops);
+ if(info->isStringProp == NULL) {
+ xfree(info->props);
+ return AllocError;
+ }
+
+ memset((char *)info->isStringProp, 0, maxprops);
+
+ i = 0;
+
+ info->props[i].name = MakeAtom("FONT", 4, TRUE);
+ info->props[i].value = MakeAtom(val, strlen(val), TRUE);
+ info->isStringProp[i] = 1;
+ i++;
+
+ if(*val && *(sp = val + 1)) {
+ for (j = 0, sp = val + 1; j < 14; j++) {
+ if (j == 13)
+ /* Handle the case of the final field containing a subset
+ specification. */
+ for (ep = sp; *ep && *ep != '['; ep++);
+ else
+ for (ep = sp; *ep && *ep != '-'; ep++);
+
+ info->props[i].name =
+ MakeAtom(xlfd_props[j], strlen(xlfd_props[j]), TRUE);
+
+ switch(j) {
+ case 6: /* pixel size */
+ info->props[i].value =
+ (int)(fabs(vals->pixel_matrix[3]) + 0.5);
+ i++;
+ break;
+ case 7: /* point size */
+ info->props[i].value =
+ (int)(fabs(vals->point_matrix[3])*10.0 + 0.5);
+ i++;
+ break;
+ case 8: /* resolution x */
+ info->props[i].value = vals->x;
+ i++;
+ break;
+ case 9: /* resolution y */
+ info->props[i].value = vals->y;
+ i++;
+ break;
+ case 11: /* average width */
+ info->props[i].value = vals->width;
+ i++;
+ break;
+ default: /* a string */
+ info->props[i].value = MakeAtom(sp, ep - sp, TRUE);
+ info->isStringProp[i] = 1;
+ i++;
+ }
+ sp = ++ep;
+ }
+ }
+
+ info->props[i].name = MakeAtom("RAW_PIXEL_SIZE", 14, TRUE);
+ info->props[i].value = 1000;
+ i++;
+
+ info->props[i].name = MakeAtom("RAW_POINT_SIZE", 14, TRUE);
+ info->props[i].value = (long)(72270.0 / (double)vals->y + .5);
+ i++;
+
+ if(!face->bitmap) {
+ info->props[i].name = MakeAtom("RAW_AVERAGE_WIDTH", 17, TRUE);
+ info->props[i].value = rawAverageWidth;
+ i++;
+ }
+
+ if ( font_properties ) {
+ info->props[i].name = MakeAtom("FONT_ASCENT", 11, TRUE);
+ info->props[i].value = info->fontAscent;
+ i++;
+ }
+
+ if(!face->bitmap) {
+ info->props[i].name = MakeAtom("RAW_ASCENT", 10, TRUE);
+ info->props[i].value =
+ ((double)face->face->ascender/(double)upm*1000.0);
+ i++;
+ }
+
+ if ( font_properties ) {
+ info->props[i].name = MakeAtom("FONT_DESCENT", 12, TRUE);
+ info->props[i].value = info->fontDescent;
+ i++;
+ }
+
+ if(!face->bitmap) {
+ info->props[i].name = MakeAtom("RAW_DESCENT", 11, TRUE);
+ info->props[i].value =
+ -((double)face->face->descender/(double)upm*1000.0);
+ i++;
+ }
+
+ j = FTGetEnglishName(face->face, TT_NAME_ID_COPYRIGHT,
+ val, MAXFONTNAMELEN);
+ vp = val;
+ if (j < 0) {
+ if(t1info && t1info->notice) {
+ vp = t1info->notice;
+ j = strlen(vp);
+ }
+ }
+ if(j > 0) {
+ info->props[i].name = MakeAtom("COPYRIGHT", 9, TRUE);
+ info->props[i].value = MakeAtom(vp, j, TRUE);
+ info->isStringProp[i] = 1;
+ i++;
+ }
+
+ j = FTGetEnglishName(face->face, TT_NAME_ID_FULL_NAME,
+ val, MAXFONTNAMELEN);
+ vp = val;
+ if (j < 0) {
+ if(t1info && t1info->full_name) {
+ vp = t1info->full_name;
+ j = strlen(vp);
+ }
+ }
+ if(j > 0) {
+ info->props[i].name = MakeAtom("FACE_NAME", 9, TRUE);
+ info->props[i].value = MakeAtom(vp, j, TRUE);
+ info->isStringProp[i] = 1;
+ i++;
+ }
+
+ vp = (char *)FT_Get_Postscript_Name(face->face);
+ if (vp) {
+ j = strlen(vp);
+ } else {
+ j = -1;
+ }
+ if (j < 0) {
+ j = FTGetEnglishName(face->face, TT_NAME_ID_PS_NAME,
+ val, MAXFONTNAMELEN);
+ vp = val;
+ }
+ if (j < 0) {
+ if(t1info && t1info->full_name) {
+ vp = t1info->full_name;
+ j = strlen(vp);
+ }
+ }
+ if(j > 0) {
+ info->props[i].name = MakeAtom("_ADOBE_POSTSCRIPT_FONTNAME", 26, TRUE);
+ info->props[i].value = MakeAtom(vp, j, TRUE);
+ info->isStringProp[i] = 1;
+ i++;
+ }
+
+ /* These macros handle the case of a diagonal matrix. They convert
+ FUnits into pixels. */
+#define TRANSFORM_FUNITS_X(xval) \
+ ((int) \
+ floor( ((double)(xval)/(double)upm) * (double)vals->pixel_matrix[0] + 0.5 ) )
+
+#define TRANSFORM_FUNITS_Y(yval) \
+ ((int) \
+ floor( ((double)(yval)/(double)upm) * (double)vals->pixel_matrix[3] + 0.5 ) )
+
+ /* In what follows, we assume the matrix is diagonal. In the rare
+ case when it is not, the values will be somewhat wrong. */
+
+ if( font_properties && os2 ) {
+ info->props[i].name = MakeAtom("SUBSCRIPT_SIZE",14,TRUE);
+ info->props[i].value =
+ TRANSFORM_FUNITS_Y(os2->ySubscriptYSize);
+ i++;
+ info->props[i].name = MakeAtom("SUBSCRIPT_X",11,TRUE);
+ info->props[i].value =
+ TRANSFORM_FUNITS_X(os2->ySubscriptXOffset);
+ i++;
+ info->props[i].name = MakeAtom("SUBSCRIPT_Y",11,TRUE);
+ info->props[i].value =
+ TRANSFORM_FUNITS_Y(os2->ySubscriptYOffset);
+ i++;
+ info->props[i].name = MakeAtom("SUPERSCRIPT_SIZE",16,TRUE);
+ info->props[i].value =
+ TRANSFORM_FUNITS_Y(os2->ySuperscriptYSize);
+ i++;
+ info->props[i].name = MakeAtom("SUPERSCRIPT_X",13,TRUE);
+ info->props[i].value =
+ TRANSFORM_FUNITS_X(os2->ySuperscriptXOffset);
+ i++;
+ info->props[i].name = MakeAtom("SUPERSCRIPT_Y",13,TRUE);
+ info->props[i].value =
+ TRANSFORM_FUNITS_Y(os2->ySuperscriptYOffset);
+ i++;
+ }
+
+ if( font_properties && (post || t1info) ) {
+ int underlinePosition, underlineThickness;
+
+ /* Raw underlineposition counts upwards,
+ but UNDERLINE_POSITION counts downwards. */
+ if(post) {
+ underlinePosition = TRANSFORM_FUNITS_Y(-post->underlinePosition);
+ underlineThickness = TRANSFORM_FUNITS_Y(post->underlineThickness);
+ } else {
+ underlinePosition =
+ TRANSFORM_FUNITS_Y(-t1info->underline_position);
+ underlineThickness =
+ TRANSFORM_FUNITS_Y(t1info->underline_thickness);
+ }
+ if(underlineThickness <= 0)
+ underlineThickness = 1;
+
+ info->props[i].name = MakeAtom("UNDERLINE_THICKNESS",19,TRUE);
+ info->props[i].value = underlineThickness;
+ i++;
+
+ info->props[i].name = MakeAtom("UNDERLINE_POSITION",18,TRUE);
+
+ info->props[i].value = underlinePosition;
+
+ i++;
+
+ /* The italic angle is often unreliable for Type 1 fonts */
+ if(post && trans->matrix.xx == trans->matrix.yy) {
+ info->props[i].name = MakeAtom("ITALIC_ANGLE",12,TRUE);
+ info->props[i].value =
+ /* Convert from TT_Fixed to
+ 64th of a degree counterclockwise from 3 o'clock */
+ 90*64+(post->italicAngle >> 10);
+ i++;
+ }
+#undef TRANSFORM_FUNITS_X
+#undef TRANSFORM_FUNITS_Y
+ }
+
+ info->props[i].name = MakeAtom("FONT_TYPE", 9, TRUE);
+ vp = (char *)FT_Get_X11_Font_Format(face->face);
+ info->props[i].value = MakeAtom(vp, strlen(vp), TRUE);
+ info->isStringProp[i] = 1;
+ i++;
+
+ info->props[i].name = MakeAtom("RASTERIZER_NAME", 15, TRUE);
+ info->props[i].value = MakeAtom("FreeType", 10, TRUE);
+ info->isStringProp[i] = 1;
+ i++;
+
+ info->nprops = i;
+ return Successful;
+}
+
+static int
+ft_get_index(unsigned code, FTFontPtr font, unsigned *idx)
+{
+
+ /* As a special case, we pass 0 even when it is not in the ranges;
+ this will allow for the default glyph, which should exist in any
+ TrueType font. */
+
+ /* This is not required...
+ if(code > 0 && font->nranges) {
+ int i;
+ for(i = 0; i < font->nranges; i++)
+ if((code >=
+ font->ranges[i].min_char_low+
+ (font->ranges[i].min_char_high<<8)) &&
+ (code <=
+ font->ranges[i].max_char_low +
+ (font->ranges[i].max_char_high<<8)))
+ break;
+ if(i == font->nranges) {
+ *idx = font->zero_idx;
+ return -1;
+ }
+ }
+ */
+ if( font->info ) {
+ if( !( font->info->firstCol <= (code & 0x000ff) &&
+ (code & 0x000ff) <= font->info->lastCol &&
+ font->info->firstRow <= (code >> 8) &&
+ (code >> 8) <= font->info->lastRow ) ) {
+ *idx = font->zero_idx;
+ /* Error: The code has not been parsed in ft_compute_bounds()!
+ We should not return any metrics. */
+ return -1;
+ }
+ }
+
+ *idx = FTRemap(font->instance->face->face, &font->mapping, code);
+
+ return 0;
+}
+
+static int
+FreeTypeFontGetGlyph(unsigned code, int flags, CharInfoPtr *g, FTFontPtr font)
+{
+ unsigned idx = 0;
+ int xrc;
+
+#ifdef X_ACCEPTS_NO_SUCH_CHAR
+ if( ft_get_index(code,font,&idx) || idx == 0 || idx == font->zero_idx ) {
+ *g = NULL;
+ flags &= ~FT_FORCE_CONSTANT_SPACING;
+ /* if( font->instance->spacing != FT_CHARCELL ) */
+ return Successful;
+ }
+#else
+ if( ft_get_index(code,font,&idx) ) {
+ /* The code has not been parsed! */
+ *g = NULL;
+ flags &= ~FT_FORCE_CONSTANT_SPACING;
+ }
+#endif
+
+ xrc = FreeTypeInstanceGetGlyph(idx, flags, g, font->instance);
+ if( xrc == Successful && *g != NULL )
+ return Successful;
+ if( font->zero_idx != idx ) {
+ xrc = FreeTypeInstanceGetGlyph(font->zero_idx, flags, g, font->instance);
+ if( xrc == Successful && *g != NULL )
+ return Successful;
+ }
+ return FreeTypeInstanceGetGlyph(font->zero_idx, flags|FT_GET_DUMMY, g, font->instance);
+}
+
+static int
+FreeTypeFontGetGlyphMetrics(unsigned code, int flags, xCharInfo **metrics, FTFontPtr font)
+{
+ unsigned idx = 0;
+ int xrc;
+
+#ifdef X_ACCEPTS_NO_SUCH_CHAR
+ if ( ft_get_index(code,font,&idx) || idx == 0 || idx == font->zero_idx ) {
+ *metrics = NULL;
+ flags &= ~FT_FORCE_CONSTANT_SPACING;
+ /* if( font->instance->spacing != FT_CHARCELL ) */
+ return Successful;
+ }
+#else
+ if ( ft_get_index(code,font,&idx) || idx == 0 || idx == font->zero_idx ) {
+ /* The code has not been parsed! */
+ *metrics = NULL;
+ flags &= ~FT_FORCE_CONSTANT_SPACING;
+ }
+#endif
+
+ xrc = FreeTypeInstanceGetGlyphMetrics(idx, flags, metrics, font->instance);
+ if( xrc == Successful && *metrics != NULL )
+ return Successful;
+ if( font->zero_idx != idx ) {
+ xrc = FreeTypeInstanceGetGlyphMetrics(font->zero_idx, flags,
+ metrics, font->instance);
+ if( xrc == Successful && *metrics != NULL )
+ return Successful;
+ }
+ return FreeTypeInstanceGetGlyphMetrics(font->zero_idx, flags|FT_GET_DUMMY, metrics, font->instance);
+}
+
+/*
+ * restrict code range
+ *
+ * boolean for the numeric zone:
+ * results = results & (ranges[0] | ranges[1] | ... ranges[nranges-1])
+ */
+
+static void
+restrict_code_range(unsigned short *refFirstCol,
+ unsigned short *refFirstRow,
+ unsigned short *refLastCol,
+ unsigned short *refLastRow,
+ fsRange const *ranges, int nRanges)
+{
+ if (nRanges) {
+ int minCol = 256, minRow = 256, maxCol = -1, maxRow = -1;
+ fsRange const *r = ranges;
+ int i;
+
+ for (i=0; i<nRanges; i++) {
+ if (r->min_char_high != r->max_char_high) {
+ minCol = 0x00;
+ maxCol = 0xff;
+ } else {
+ if (minCol > r->min_char_low)
+ minCol = r->min_char_low;
+ if (maxCol < r->max_char_low)
+ maxCol = r->max_char_low;
+ }
+ if (minRow > r->min_char_high)
+ minRow = r->min_char_high;
+ if (maxRow < r->max_char_high)
+ maxRow = r->max_char_high;
+ r++;
+ }
+
+ if (minCol > *refLastCol)
+ *refFirstCol = *refLastCol;
+ else if (minCol > *refFirstCol)
+ *refFirstCol = minCol;
+
+ if (maxCol < *refFirstCol)
+ *refLastCol = *refFirstCol;
+ else if (maxCol < *refLastCol)
+ *refLastCol = maxCol;
+
+ if (minRow > *refLastRow) {
+ *refFirstRow = *refLastRow;
+ *refFirstCol = *refLastCol;
+ } else if (minRow > *refFirstRow)
+ *refFirstRow = minRow;
+
+ if (maxRow < *refFirstRow) {
+ *refLastRow = *refFirstRow;
+ *refLastCol = *refFirstCol;
+ } else if (maxRow < *refLastRow)
+ *refLastRow = maxRow;
+ }
+}
+
+
+static int
+restrict_code_range_by_str(int count,unsigned short *refFirstCol,
+ unsigned short *refFirstRow,
+ unsigned short *refLastCol,
+ unsigned short *refLastRow,
+ char const *str)
+{
+ int nRanges = 0;
+ int result = 0;
+ fsRange *ranges = NULL;
+ char const *p, *q;
+
+ p = q = str;
+ for (;;) {
+ int minpoint=0, maxpoint=65535;
+ long val;
+
+ /* skip comma and/or space */
+ while (',' == *p || isspace(*p))
+ p++;
+
+ /* begin point */
+ if ('-' != *p) {
+ val = strtol(p, (char **)&q, 0);
+ if (p == q)
+ /* end or illegal */
+ break;
+ if (val<0 || val>65535) {
+ /* out of zone */
+ break;
+ }
+ minpoint = val;
+ p=q;
+ }
+
+ /* skip space */
+ while (isspace(*p))
+ p++;
+
+ if (',' != *p && '\0' != *p) {
+ /* contiune */
+ if ('-' == *p)
+ /* hyphon */
+ p++;
+ else
+ /* end or illegal */
+ break;
+
+ /* skip space */
+ while (isspace(*p))
+ p++;
+
+ val = strtol(p, (char **)&q, 0);
+ if (p != q) {
+ if (val<0 || val>65535)
+ break;
+ maxpoint = val;
+ } else if (',' != *p && '\0' != *p)
+ /* end or illegal */
+ break;
+ p=q;
+ } else
+ /* comma - single code */
+ maxpoint = minpoint;
+
+ if ( count <= 0 && minpoint>maxpoint ) {
+ int tmp;
+ tmp = minpoint;
+ minpoint = maxpoint;
+ maxpoint = tmp;
+ }
+
+ /* add range */
+#if 0
+ fprintf(stderr, "zone: 0x%04X - 0x%04X\n", minpoint, maxpoint);
+ fflush(stderr);
+#endif
+ nRanges++;
+ ranges = (fsRange *)xrealloc(ranges, nRanges*sizeof(*ranges));
+ if (NULL == ranges)
+ break;
+ {
+ fsRange *r = ranges+nRanges-1;
+
+ r->min_char_low = minpoint & 0xff;
+ r->max_char_low = maxpoint & 0xff;
+ r->min_char_high = (minpoint>>8) & 0xff;
+ r->max_char_high = (maxpoint>>8) & 0xff;
+ }
+ }
+
+ if (ranges) {
+ if ( count <= 0 ) {
+ restrict_code_range(refFirstCol, refFirstRow, refLastCol, refLastRow,
+ ranges, nRanges);
+ }
+ else {
+ int i;
+ fsRange *r;
+ for ( i=0 ; i<nRanges ; i++ ) {
+ if ( count <= i ) break;
+ r = ranges+i;
+ refFirstCol[i] = r->min_char_low;
+ refLastCol[i] = r->max_char_low;
+ refFirstRow[i] = r->min_char_high;
+ refLastRow[i] = r->max_char_high;
+ }
+ result=i;
+ }
+ xfree(ranges);
+ }
+ return result;
+}
+
+/* *face_number and *spacing are initialized but *load_flags is NOT. */
+static int
+FreeTypeSetUpTTCap( char *fileName, FontScalablePtr vals,
+ char **dynStrRealFileName, char **dynStrFTFileName,
+ struct TTCapInfo *ret, int *face_number, FT_Int32 *load_flags,
+ int *spacing, Bool *font_properties, char **dynStrTTCapCodeRange )
+{
+ int result = Successful;
+ SDynPropRecValList listPropRecVal;
+ SPropRecValContainer contRecValue;
+ Bool hinting=True;
+ Bool isEmbeddedBitmap = True;
+ Bool alwaysEmbeddedBitmap = False;
+ int pixel = vals->pixel;
+
+ *font_properties=True;
+ *dynStrRealFileName=NULL;
+ *dynStrFTFileName=NULL;
+ *dynStrTTCapCodeRange=NULL;
+
+ if (SPropRecValList_new(&listPropRecVal)) {
+ return AllocError;
+ }
+
+ {
+ int len = strlen(fileName);
+ char *capHead = NULL;
+ {
+ /* font cap */
+ char *p1=NULL, *p2=NULL;
+
+ p1=strrchr(fileName, '/');
+ if ( p1 == NULL ) p1 = fileName;
+ else p1++;
+ if (NULL != (p2=strrchr(p1, ':'))) {
+ /* colon exist in the right side of slash. */
+ int dirLen = p1-fileName;
+ int baseLen = fileName+len - p2 -1;
+
+ *dynStrRealFileName = (char *)xalloc(dirLen+baseLen+1);
+ if( *dynStrRealFileName == NULL ) {
+ result = AllocError;
+ goto quit;
+ }
+ if ( 0 < dirLen )
+ memcpy(*dynStrRealFileName, fileName, dirLen);
+ strcpy(*dynStrRealFileName+dirLen, p2+1);
+ capHead = p1;
+ } else {
+ *dynStrRealFileName = xstrdup(fileName);
+ if( *dynStrRealFileName == NULL ) {
+ result = AllocError;
+ goto quit;
+ }
+ }
+ }
+
+ /* font cap */
+ if (capHead) {
+ if (SPropRecValList_add_by_font_cap(&listPropRecVal,
+ capHead)) {
+ result = BadFontPath;
+ goto quit;
+ }
+ }
+ }
+
+ *face_number=0;
+ *spacing=0;
+ ret->autoItalic=0.0;
+ ret->scaleWidth=1.0;
+ ret->scaleBBoxWidth = 1.0;
+ ret->scaleBBoxHeight = 1.0;
+ ret->doubleStrikeShift = 1;
+ ret->adjustBBoxWidthByPixel = 0;
+ ret->adjustLeftSideBearingByPixel = 0;
+ ret->adjustRightSideBearingByPixel = 0;
+ ret->flags = 0;
+ ret->scaleBitmap = 0.0;
+ ret->forceConstantSpacingBegin = -1;
+ ret->forceConstantSpacingEnd = -1;
+ ret->force_c_representative_metrics_char_code = -2;
+ ret->force_c_scale_b_box_width = 1.0;
+ ret->force_c_scale_b_box_height = 1.0;
+ ret->force_c_adjust_width_by_pixel = 0;
+ ret->force_c_adjust_lsb_by_pixel = 0;
+ ret->force_c_adjust_rsb_by_pixel = 0;
+ ret->force_c_scale_lsb = 0.0;
+ ret->force_c_scale_rsb = 1.0;
+ /* */
+ ret->vl_slant=0;
+ ret->lsbShiftOfBitmapAutoItalic=0;
+ ret->rsbShiftOfBitmapAutoItalic=0;
+ /* face number */
+ {
+ char *beginptr=NULL,*endptr;
+ if ( SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "FaceNumber")) {
+ int lv;
+ beginptr = SPropContainer_value_str(contRecValue);
+ lv=strtol(beginptr, &endptr, 10);
+ if ( *beginptr != '\0' && *endptr == '\0' ) {
+ if ( 0 < lv ) *face_number = lv;
+ }
+ }
+ if( beginptr && 0 < *face_number ) {
+ char *slash;
+ *dynStrFTFileName = /* add -> ':'+strlen0+':'+strlen1+'\0' */
+ (char *)xalloc(1+strlen(beginptr)+1+strlen(*dynStrRealFileName)+1);
+ if( *dynStrFTFileName == NULL ){
+ result = AllocError;
+ goto quit;
+ }
+ **dynStrFTFileName = '\0';
+ slash = strrchr(*dynStrRealFileName,'/');
+ if( slash ) {
+ char *p;
+ strcat(*dynStrFTFileName,*dynStrRealFileName);
+ p = strrchr(*dynStrFTFileName,'/');
+ p[1] = '\0';
+ strcat(*dynStrFTFileName,":");
+ strcat(*dynStrFTFileName,beginptr);
+ strcat(*dynStrFTFileName,":");
+ strcat(*dynStrFTFileName,slash+1);
+ }
+ else{
+ strcat(*dynStrFTFileName,":");
+ strcat(*dynStrFTFileName,beginptr);
+ strcat(*dynStrFTFileName,":");
+ strcat(*dynStrFTFileName,*dynStrRealFileName);
+ }
+ }
+ else{
+ *dynStrFTFileName = (char *)xalloc(strlen(*dynStrRealFileName)+1);
+ if( *dynStrFTFileName == NULL ){
+ result = AllocError;
+ goto quit;
+ }
+ **dynStrFTFileName = '\0';
+ strcat(*dynStrFTFileName,*dynStrRealFileName);
+ }
+ }
+ /*
+ fprintf(stderr,"[Filename:%s]\n",fileName);
+ fprintf(stderr,"[RealFilename:%s]\n",*dynStrRealFileName);
+ fprintf(stderr,"[FTFilename:%s]\n",*dynStrFTFileName);
+ */
+ /* slant control */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "AutoItalic"))
+ ret->autoItalic = SPropContainer_value_dbl(contRecValue);
+ /* hinting control */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "Hinting"))
+ hinting = SPropContainer_value_bool(contRecValue);
+ /* scaling */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "ScaleWidth")) {
+ ret->scaleWidth = SPropContainer_value_dbl(contRecValue);
+ if (ret->scaleWidth<=0.0) {
+ fprintf(stderr, "ScaleWitdh needs plus.\n");
+ result = BadFontName;
+ goto quit;
+ }
+ }
+ /* bbox adjustment */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "ScaleBBoxWidth")) {
+ /* Scaling to Bounding Box Width */
+ int lv;
+ char *endptr,*beginptr;
+ double v,scaleBBoxWidth=1.0,scaleBBoxHeight=1.0;
+ beginptr = SPropContainer_value_str(contRecValue);
+ do {
+ if ( strlen(beginptr) < 1 ) break;
+ v=strtod(beginptr, &endptr);
+ if ( endptr!=beginptr ) {
+ scaleBBoxWidth = v;
+ }
+ if ( *endptr != ';' && *endptr != ',' ) break;
+ if ( *endptr == ',' ) {
+ beginptr=endptr+1;
+ v=strtod(beginptr, &endptr);
+ if ( endptr!=beginptr ) {
+ scaleBBoxHeight = v;
+ }
+ }
+ if ( *endptr != ';' && *endptr != ',' ) break;
+ beginptr=endptr+1;
+ lv=strtol(beginptr, &endptr, 10);
+ if ( endptr!=beginptr ) {
+ ret->adjustBBoxWidthByPixel = lv;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ lv=strtol(beginptr, &endptr, 10);
+ if ( endptr!=beginptr ) {
+ ret->adjustLeftSideBearingByPixel = lv;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ lv=strtol(beginptr, &endptr, 10);
+ if ( endptr!=beginptr ) {
+ ret->adjustRightSideBearingByPixel = lv;
+ }
+ } while ( 0 );
+ if (scaleBBoxWidth<=0.0) {
+ fprintf(stderr, "ScaleBBoxWitdh needs plus.\n");
+ result = BadFontName;
+ goto quit;
+ }
+ if (scaleBBoxHeight<=0.0) {
+ fprintf(stderr, "ScaleBBoxHeight needs plus.\n");
+ result = BadFontName;
+ goto quit;
+ }
+ ret->scaleBBoxWidth = scaleBBoxWidth;
+ ret->scaleBBoxHeight = scaleBBoxHeight;
+ }
+ /* spacing */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "ForceSpacing")) {
+ char *strSpace = SPropContainer_value_str(contRecValue);
+ Bool err = False;
+ if (1 != strlen(strSpace))
+ err = True;
+ else
+ switch (strSpace[0]) {
+ case 'M':
+ ret->flags |= TTCAP_MONO_CENTER;
+ *spacing = 'm';
+ break;
+ case 'm':
+ case 'p':
+ case 'c':
+ *spacing = strSpace[0];
+ break;
+ default:
+ err = True;
+ }
+ if (err) {
+ result = BadFontName;
+ goto quit;
+ }
+ }
+ /* doube striking */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "DoubleStrike")) {
+ /* Set or Reset Auto Bold Flag */
+ char *strDoubleStrike = SPropContainer_value_str(contRecValue);
+ Bool err = False;
+ if ( 0 < strlen(strDoubleStrike) ) {
+ switch (strDoubleStrike[0]) {
+ case 'm':
+ case 'M':
+ case 'l':
+ case 'L':
+ ret->flags |= TTCAP_DOUBLE_STRIKE;
+ ret->flags |= TTCAP_DOUBLE_STRIKE_MKBOLD_EDGE_LEFT;
+ break;
+ case 'y':
+ case 'Y':
+ ret->flags |= TTCAP_DOUBLE_STRIKE;
+ break;
+ case 'n':
+ case 'N':
+ ret->flags &= ~TTCAP_DOUBLE_STRIKE;
+ ret->flags &= ~TTCAP_DOUBLE_STRIKE_MKBOLD_EDGE_LEFT;
+ ret->flags &= ~TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH;
+ break;
+ default:
+ err = True;
+ }
+ if ( err != True ) {
+ if ( strDoubleStrike[1] ) {
+ switch (strDoubleStrike[1]) {
+ case 'b':
+ case 'B':
+ case 'p':
+ case 'P':
+ case 'y':
+ case 'Y':
+ ret->flags |= TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH;
+ break;
+ default:
+ break;
+ }
+ }
+ do {
+ char *comma_ptr=strchr(strDoubleStrike,';');
+ if ( !comma_ptr ) comma_ptr=strchr(strDoubleStrike,',');
+ if ( !comma_ptr ) break;
+ if ( comma_ptr[1] ) {
+ char *endptr;
+ int mkboldMaxPixel;
+ mkboldMaxPixel=strtol(comma_ptr+1, &endptr, 10);
+ if ( endptr != comma_ptr+1 && mkboldMaxPixel <= pixel ) {
+ ret->flags &= ~TTCAP_DOUBLE_STRIKE_MKBOLD_EDGE_LEFT;
+ }
+ }
+ comma_ptr=strchr(comma_ptr+1,',');
+ if ( !comma_ptr ) break;
+ if ( comma_ptr[1] ) {
+ char *endptr;
+ int max_pixel;
+ max_pixel=strtol(comma_ptr+1, &endptr, 10);
+ if ( endptr != comma_ptr+1 && max_pixel <= pixel ) {
+ if( ret->flags & TTCAP_DOUBLE_STRIKE )
+ ret->doubleStrikeShift += pixel / max_pixel;
+ }
+ }
+ } while(0);
+ }
+ }
+ else
+ err = True;
+ if (err) {
+ result = BadFontName;
+ goto quit;
+ }
+ }
+ /* very lazy metrics */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "VeryLazyMetrics")){
+ Bool isVeryLazy = SPropContainer_value_bool(contRecValue);
+ ret->flags |= TTCAP_DISABLE_DEFAULT_VERY_LAZY;
+ if( isVeryLazy == True )
+ ret->flags |= TTCAP_IS_VERY_LAZY;
+ else
+ ret->flags &= ~TTCAP_IS_VERY_LAZY;
+ }
+ /* embedded bitmap */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "EmbeddedBitmap")) {
+ char *strEmbeddedBitmap = SPropContainer_value_str(contRecValue);
+ Bool err = False;
+ if ( 1 == strlen(strEmbeddedBitmap) ) {
+ switch (strEmbeddedBitmap[0]) {
+ case 'y':
+ case 'Y':
+ isEmbeddedBitmap = True;
+ alwaysEmbeddedBitmap = True;
+ break;
+ case 'u':
+ case 'U':
+ isEmbeddedBitmap = True;
+ alwaysEmbeddedBitmap = False;
+ break;
+ case 'n':
+ case 'N':
+ isEmbeddedBitmap = False;
+ break;
+ default:
+ err = True;
+ }
+ }
+ else
+ err = True;
+ if (err) {
+ result = BadFontName;
+ goto quit;
+ }
+ }
+ /* scale bitmap */
+ if((ret->flags & TTCAP_IS_VERY_LAZY) &&
+ SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "VeryLazyBitmapWidthScale")) {
+ /* Scaling to Bitmap Bounding Box Width */
+ double scaleBitmapWidth = SPropContainer_value_dbl(contRecValue);
+
+ fprintf(stderr, "Warning: `bs' option is not required in X-TT version 2.\n");
+#if 0
+ if (scaleBitmapWidth<=0.0) {
+ fprintf(stderr, "ScaleBitmapWitdh needs plus.\n");
+ result = BadFontName;
+ goto quit;
+ }
+#endif
+ ret->scaleBitmap = scaleBitmapWidth;
+ }
+ /* restriction of the code range */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "CodeRange")) {
+ *dynStrTTCapCodeRange = xstrdup(SPropContainer_value_str(contRecValue));
+ if( *dynStrTTCapCodeRange == NULL ) {
+ result = AllocError;
+ goto quit;
+ }
+ }
+ /* forceConstantSpacing{Begin,End} */
+ if ( 1 /* ft->spacing == 'p' */ ){
+ unsigned short first_col=0,last_col=0x00ff;
+ unsigned short first_row=0,last_row=0x00ff;
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "ForceConstantSpacingCodeRange")) {
+ if ( restrict_code_range_by_str(1,&first_col, &first_row,
+ &last_col, &last_row,
+ SPropContainer_value_str(contRecValue)) == 1 ) {
+ ret->forceConstantSpacingBegin = (int)( first_row<<8 | first_col );
+ ret->forceConstantSpacingEnd = (int)( last_row<<8 | last_col );
+ if ( ret->forceConstantSpacingBegin <= ret->forceConstantSpacingEnd )
+ ret->flags &= ~TTCAP_FORCE_C_OUTSIDE;
+ else ret->flags |= TTCAP_FORCE_C_OUTSIDE;
+ }
+ }
+ }
+ /* */
+ if ( 1 ){
+ unsigned short first_col=0, last_col=0x0ff;
+ unsigned short first_row=0, last_row=0x0ff;
+ if ( SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "ForceConstantSpacingMetrics")) {
+ char *strMetrics;
+ strMetrics = SPropContainer_value_str(contRecValue);
+ if ( strMetrics ) {
+ char *comma_ptr,*period_ptr,*semic_ptr;
+ semic_ptr=strchr(strMetrics,';');
+ comma_ptr=strchr(strMetrics,',');
+ period_ptr=strchr(strMetrics,'.');
+ if ( semic_ptr && comma_ptr )
+ if ( semic_ptr < comma_ptr ) comma_ptr=NULL;
+ if ( semic_ptr && period_ptr )
+ if ( semic_ptr < period_ptr ) period_ptr=NULL;
+ if ( !comma_ptr && !period_ptr && strMetrics != semic_ptr ) {
+ if ( restrict_code_range_by_str(1,&first_col, &first_row,
+ &last_col, &last_row,
+ SPropContainer_value_str(contRecValue)) == 1 ) {
+ ret->force_c_representative_metrics_char_code =
+ (int)( first_row<<8 | first_col );
+ }
+ }
+ else {
+ double v;
+ char *endptr,*beginptr=strMetrics;
+ do {
+ v=strtod(beginptr, &endptr);
+ if ( endptr!=beginptr ) {
+ ret->force_c_scale_b_box_width = v;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ v=strtod(beginptr, &endptr);
+ if ( endptr!=beginptr ) {
+ ret->force_c_scale_lsb = v;
+ ret->flags |= TTCAP_FORCE_C_LSB_FLAG;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ v=strtod(beginptr, &endptr);
+ if ( endptr!=beginptr ) {
+ ret->force_c_scale_rsb = v;
+ ret->flags |= TTCAP_FORCE_C_RSB_FLAG;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ v=strtod(beginptr, &endptr);
+ if ( endptr!=beginptr ) {
+ ret->force_c_scale_b_box_height = v;
+ }
+ } while (0);
+ }
+ if ( semic_ptr ) {
+ int lv;
+ char *endptr,*beginptr=semic_ptr+1;
+ do {
+ lv=strtol(beginptr, &endptr, 10);
+ if ( endptr!=beginptr ) {
+ ret->force_c_adjust_width_by_pixel=lv;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ lv=strtol(beginptr, &endptr, 10);
+ if ( endptr!=beginptr ) {
+ ret->force_c_adjust_lsb_by_pixel=lv;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ lv=strtol(beginptr, &endptr, 10);
+ if ( endptr!=beginptr ) {
+ ret->force_c_adjust_rsb_by_pixel=lv;
+ }
+ } while (0);
+ }
+ }
+ }
+ }
+
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "FontProperties")) {
+ /* Set or Reset the Flag of FontProperties */
+ *font_properties=SPropContainer_value_bool(contRecValue);
+ }
+
+ ret->force_c_scale_b_box_width *= ret->scaleBBoxWidth;
+ ret->force_c_scale_b_box_height *= ret->scaleBBoxHeight;
+
+ ret->force_c_scale_b_box_width *= ret->scaleWidth;
+ ret->scaleBBoxWidth *= ret->scaleWidth;
+
+ ret->force_c_adjust_rsb_by_pixel += ret->adjustRightSideBearingByPixel;
+ ret->force_c_adjust_lsb_by_pixel += ret->adjustLeftSideBearingByPixel;
+
+ /* scaleWidth, scaleBBoxWidth, force_c_scale_b_box_width, force_c_scale_b_box_width */
+
+ /* by TTCap */
+ if( hinting == False ) *load_flags |= FT_LOAD_NO_HINTING;
+ if( isEmbeddedBitmap == False ) *load_flags |= FT_LOAD_NO_BITMAP;
+ if( ret->autoItalic != 0 && alwaysEmbeddedBitmap == False )
+ *load_flags |= FT_LOAD_NO_BITMAP;
+
+ quit:
+ return result;
+}
+
+static int
+ft_get_trans_from_vals( FontScalablePtr vals, FTNormalisedTransformationPtr trans )
+{
+ /* Compute the transformation matrix. We use floating-point
+ arithmetic for simplicity */
+
+ trans->xres = vals->x;
+ trans->yres = vals->y;
+
+ /* This value cannot be 0. */
+ trans->scale = hypot(vals->point_matrix[2], vals->point_matrix[3]);
+ trans->nonIdentity = 0;
+
+ /* Try to round stuff. We want approximate zeros to be exact zeros,
+ and if the elements on the diagonal are approximately equal, we
+ want them equal. We do this to avoid breaking hinting. */
+ if(DIFFER(vals->point_matrix[0], vals->point_matrix[3])) {
+ trans->nonIdentity = 1;
+ trans->matrix.xx =
+ (int)((vals->point_matrix[0]*(double)TWO_SIXTEENTH)/trans->scale);
+ trans->matrix.yy =
+ (int)((vals->point_matrix[3]*(double)TWO_SIXTEENTH)/trans->scale);
+ } else {
+ trans->matrix.xx = trans->matrix.yy =
+ ((vals->point_matrix[0] + vals->point_matrix[3])/2*
+ (double)TWO_SIXTEENTH)/trans->scale;
+ }
+
+ if(DIFFER0(vals->point_matrix[1], trans->scale)) {
+ trans->matrix.yx =
+ (int)((vals->point_matrix[1]*(double)TWO_SIXTEENTH)/trans->scale);
+ trans->nonIdentity = 1;
+ } else
+ trans->matrix.yx = 0;
+
+ if(DIFFER0(vals->point_matrix[2], trans->scale)) {
+ trans->matrix.xy =
+ (int)((vals->point_matrix[2]*(double)TWO_SIXTEENTH)/trans->scale);
+ trans->nonIdentity = 1;
+ } else
+ trans->matrix.xy=0;
+ return 0;
+}
+
+
+static int
+is_fixed_width(FT_Face face)
+{
+ PS_FontInfoRec t1info_rec;
+ int ftrc;
+
+ if(FT_IS_FIXED_WIDTH(face)) {
+ return 1;
+ }
+
+ ftrc = FT_Get_PS_Font_Info(face, &t1info_rec);
+ if(ftrc == 0 && t1info_rec.is_fixed_pitch) {
+ return 1;
+ }
+
+ return 0;
+}
+
+static int
+FreeTypeLoadFont(FTFontPtr font, FontInfoPtr info, FTFacePtr face,
+ char *FTFileName, FontScalablePtr vals, FontEntryPtr entry,
+ FontBitmapFormatPtr bmfmt, FT_Int32 load_flags,
+ struct TTCapInfo *tmp_ttcap, char *dynStrTTCapCodeRange,
+ int ttcap_spacing )
+{
+ int xrc;
+ FTNormalisedTransformationRec trans;
+ int spacing, actual_spacing, zero_code;
+ long lastCode, firstCode;
+ TT_Postscript *post;
+
+ ft_get_trans_from_vals(vals,&trans);
+
+ /* Check for charcell in XLFD */
+ spacing = FT_PROPORTIONAL;
+ if(entry->name.ndashes == 14) {
+ char *p;
+ int dashes = 0;
+ for(p = entry->name.name;
+ p <= entry->name.name + entry->name.length - 2;
+ p++) {
+ if(*p == '-') {
+ dashes++;
+ if(dashes == 11) {
+ if(p[1]=='c' && p[2]=='-')
+ spacing=FT_CHARCELL;
+ else if(p[1]=='m' && p[2]=='-')
+ spacing=FT_MONOSPACED;
+ break;
+ }
+ }
+ }
+ }
+ /* by TTCap */
+ if( ttcap_spacing != 0 ) {
+ if( ttcap_spacing == 'c' ) spacing=FT_CHARCELL;
+ else if( ttcap_spacing == 'm' ) spacing=FT_MONOSPACED;
+ else spacing=FT_PROPORTIONAL;
+ }
+
+ actual_spacing = spacing;
+ if( spacing == FT_PROPORTIONAL ) {
+ if( is_fixed_width(face->face) )
+ actual_spacing = FT_MONOSPACED;
+ }
+
+ if(entry->name.ndashes == 14) {
+ xrc = FTPickMapping(entry->name.name, entry->name.length, FTFileName,
+ face->face, &font->mapping);
+ if (xrc != Successful)
+ return xrc;
+ } else {
+ xrc = FTPickMapping(0, 0, FTFileName,
+ face->face, &font->mapping);
+ if (xrc != Successful)
+ return xrc;
+ }
+
+ font->nranges = vals->nranges;
+ font->ranges = 0;
+ if(font->nranges) {
+ font->ranges = (fsRange*)xalloc(vals->nranges*sizeof(fsRange));
+ if(font->ranges == NULL)
+ return AllocError;
+ memcpy((char*)font->ranges, (char*)vals->ranges,
+ vals->nranges*sizeof(fsRange));
+ }
+
+ zero_code=-1;
+ if(info) {
+ firstCode = 0;
+ lastCode = 0xFFFFL;
+ if(!font->mapping.mapping ||
+ font->mapping.mapping->encoding->row_size == 0) {
+ /* linear indexing */
+ lastCode=MIN(lastCode,
+ font->mapping.mapping ?
+ font->mapping.mapping->encoding->size-1 :
+ 0xFF);
+ if(font->mapping.mapping && font->mapping.mapping->encoding->first)
+ firstCode = font->mapping.mapping->encoding->first;
+ info->firstRow = firstCode/0x100;
+ info->lastRow = lastCode/0x100;
+ info->firstCol =
+ (info->firstRow || info->lastRow) ? 0 : (firstCode & 0xFF);
+ info->lastCol = info->lastRow ? 0xFF : (lastCode & 0xFF);
+ if ( firstCode == 0 ) zero_code=0;
+ } else {
+ /* matrix indexing */
+ info->firstRow = font->mapping.mapping->encoding->first;
+ info->lastRow = MIN(font->mapping.mapping->encoding->size-1,
+ lastCode/0x100);
+ info->firstCol = font->mapping.mapping->encoding->first_col;
+ info->lastCol = MIN(font->mapping.mapping->encoding->row_size-1,
+ lastCode<0x100?lastCode:0xFF);
+ if( info->firstRow == 0 && info->firstCol == 0 ) zero_code=0;
+ }
+
+ /* firstCode and lastCode are not valid in case of a matrix
+ encoding */
+
+ if( dynStrTTCapCodeRange ) {
+ restrict_code_range_by_str(0,&info->firstCol, &info->firstRow,
+ &info->lastCol, &info->lastRow,
+ dynStrTTCapCodeRange);
+ }
+ restrict_code_range(&info->firstCol, &info->firstRow,
+ &info->lastCol, &info->lastRow,
+ font->ranges, font->nranges);
+ }
+ font->info = info;
+
+ /* zero code is frequently used. */
+ if ( zero_code < 0 ) {
+ /* The fontenc should have the information of DefaultCh.
+ But we do not have such a information.
+ So we cannot but set 0. */
+ font->zero_idx = 0;
+ }
+ else
+ font->zero_idx = FTRemap(face->face,
+ &font->mapping, zero_code);
+
+ post = FT_Get_Sfnt_Table(face->face, ft_sfnt_post);
+
+#ifdef DEFAULT_VERY_LAZY
+ if( !( tmp_ttcap->flags & TTCAP_DISABLE_DEFAULT_VERY_LAZY ) )
+ if( DEFAULT_VERY_LAZY <= 1 + info->lastRow - info->firstRow ) {
+ if( post ){
+ tmp_ttcap->flags |= TTCAP_IS_VERY_LAZY;
+ }
+ }
+#endif
+ /* We should always reset. */
+ tmp_ttcap->flags &= ~TTCAP_DISABLE_DEFAULT_VERY_LAZY;
+
+ if ( face->bitmap || actual_spacing == FT_CHARCELL )
+ tmp_ttcap->flags &= ~TTCAP_IS_VERY_LAZY;
+ /* "vl=y" is available when TrueType or OpenType only */
+ if ( !face->bitmap && !(FT_IS_SFNT( face->face )) )
+ tmp_ttcap->flags &= ~TTCAP_IS_VERY_LAZY;
+
+ if( post ) {
+ if( post->italicAngle != 0 )
+ tmp_ttcap->vl_slant = -sin( (post->italicAngle/1024./5760.)*1.57079632679489661923 );
+ /* fprintf(stderr,"angle=%g(%g)\n",tmp_ttcap->vl_slant,(post->italicAngle/1024./5760.)*90); */
+ }
+
+ xrc = FreeTypeOpenInstance(&font->instance, face,
+ FTFileName, &trans, actual_spacing, bmfmt,
+ tmp_ttcap, load_flags );
+ return xrc;
+}
+
+static void
+adjust_min_max(xCharInfo *minc, xCharInfo *maxc, xCharInfo *tmp)
+{
+#define MINMAX(field,ci) \
+ if (minc->field > (ci)->field) \
+ minc->field = (ci)->field; \
+ if (maxc->field < (ci)->field) \
+ maxc->field = (ci)->field;
+
+ MINMAX(ascent, tmp);
+ MINMAX(descent, tmp);
+ MINMAX(leftSideBearing, tmp);
+ MINMAX(rightSideBearing, tmp);
+ MINMAX(characterWidth, tmp);
+
+ if ((INT16)minc->attributes > (INT16)tmp->attributes)
+ minc->attributes = tmp->attributes;
+ if ((INT16)maxc->attributes < (INT16)tmp->attributes)
+ maxc->attributes = tmp->attributes;
+#undef MINMAX
+}
+
+static void
+ft_compute_bounds(FTFontPtr font, FontInfoPtr pinfo, FontScalablePtr vals )
+{
+ FTInstancePtr instance;
+ int row, col;
+ unsigned int c;
+ xCharInfo minchar, maxchar, *tmpchar = NULL;
+ int overlap, maxOverlap;
+ long swidth = 0;
+ long total_width = 0;
+ int num_cols, num_chars = 0;
+ int flags, skip_ok = 0;
+ int force_c_outside ;
+
+ instance = font->instance;
+ force_c_outside = instance->ttcap.flags & TTCAP_FORCE_C_OUTSIDE;
+
+ minchar.ascent = minchar.descent =
+ minchar.leftSideBearing = minchar.rightSideBearing =
+ minchar.characterWidth = minchar.attributes = 32767;
+ maxchar.ascent = maxchar.descent =
+ maxchar.leftSideBearing = maxchar.rightSideBearing =
+ maxchar.characterWidth = maxchar.attributes = -32767;
+ maxOverlap = -32767;
+
+ /* Parse all glyphs */
+ num_cols = 1 + pinfo->lastCol - pinfo->firstCol;
+ for (row = pinfo->firstRow; row <= pinfo->lastRow; row++) {
+ if ( skip_ok && tmpchar ) {
+ if ( !force_c_outside ) {
+ if ( instance->ttcap.forceConstantSpacingBegin < row<<8
+ && row<<8 < (instance->ttcap.forceConstantSpacingEnd & 0x0ff00) ) {
+ if (tmpchar->characterWidth) {
+ num_chars += num_cols;
+ swidth += ABS(tmpchar->characterWidth)*num_cols;
+ total_width += tmpchar->characterWidth*num_cols;
+ continue;
+ }
+ }
+ else skip_ok=0;
+ }
+ else { /* for GB18030 proportional */
+ if ( instance->ttcap.forceConstantSpacingBegin < row<<8
+ || row<<8 < (instance->ttcap.forceConstantSpacingEnd & 0x0ff00) ) {
+ if (tmpchar->characterWidth) {
+ num_chars += num_cols;
+ swidth += ABS(tmpchar->characterWidth)*num_cols;
+ total_width += tmpchar->characterWidth*num_cols;
+ continue;
+ }
+ }
+ else skip_ok=0;
+ }
+ }
+ for (col = pinfo->firstCol; col <= pinfo->lastCol; col++) {
+ c = row<<8|col;
+ flags=0;
+ if ( !force_c_outside ) {
+ if ( c <= instance->ttcap.forceConstantSpacingEnd
+ && instance->ttcap.forceConstantSpacingBegin <= c )
+ flags|=FT_FORCE_CONSTANT_SPACING;
+ }
+ else { /* for GB18030 proportional */
+ if ( c <= instance->ttcap.forceConstantSpacingEnd
+ || instance->ttcap.forceConstantSpacingBegin <= c )
+ flags|=FT_FORCE_CONSTANT_SPACING;
+ }
+#if 0
+ fprintf(stderr, "comp_bounds: %x ->", c);
+#endif
+ if ( skip_ok == 0 || flags == 0 ){
+ tmpchar=NULL;
+#if 0
+ fprintf(stderr, "%x\n", c);
+#endif
+ if( FreeTypeFontGetGlyphMetrics(c, flags, &tmpchar, font) != Successful )
+ continue;
+ }
+ if ( !tmpchar ) continue;
+ adjust_min_max(&minchar, &maxchar, tmpchar);
+ overlap = tmpchar->rightSideBearing - tmpchar->characterWidth;
+ if (maxOverlap < overlap)
+ maxOverlap = overlap;
+
+ if (!tmpchar->characterWidth)
+ continue;
+ num_chars++;
+ swidth += ABS(tmpchar->characterWidth);
+ total_width += tmpchar->characterWidth;
+
+ if ( flags & FT_FORCE_CONSTANT_SPACING ) skip_ok=1;
+ }
+ }
+
+#ifndef X_ACCEPTS_NO_SUCH_CHAR
+ /* Check code 0 */
+ if( FreeTypeInstanceGetGlyphMetrics(font->zero_idx, 0, &tmpchar, font->instance) != Successful || tmpchar == NULL)
+ if( FreeTypeInstanceGetGlyphMetrics(font->zero_idx, FT_GET_DUMMY, &tmpchar, font->instance) != Successful )
+ tmpchar = NULL;
+ if ( tmpchar ) {
+ adjust_min_max(&minchar, &maxchar, tmpchar);
+ overlap = tmpchar->rightSideBearing - tmpchar->characterWidth;
+ if (maxOverlap < overlap)
+ maxOverlap = overlap;
+ }
+#endif
+
+ /* AVERAGE_WIDTH ... 1/10 pixel unit */
+ if (num_chars > 0) {
+ swidth = (swidth * 10.0 + num_chars / 2.0) / num_chars;
+ if (total_width < 0)
+ swidth = -swidth;
+ vals->width = swidth;
+ } else
+ vals->width = 0;
+
+ /*
+ if (char_width.pixel) {
+ maxchar.characterWidth = char_width.pixel;
+ minchar.characterWidth = char_width.pixel;
+ }
+ */
+
+ pinfo->maxbounds = maxchar;
+ pinfo->minbounds = minchar;
+ pinfo->ink_maxbounds = maxchar;
+ pinfo->ink_minbounds = minchar;
+ pinfo->maxOverlap = maxOverlap;
+}
+
+static int
+compute_new_extents( FontScalablePtr vals, double scale, double lsb, double rsb, double desc, double asc,
+ int *lsb_result, int *rsb_result, int *desc_result, int *asc_result )
+{
+#define TRANSFORM_POINT(matrix, x, y, dest) \
+ ((dest)[0] = (matrix)[0] * (x) + (matrix)[2] * (y), \
+ (dest)[1] = (matrix)[1] * (x) + (matrix)[3] * (y))
+
+#define CHECK_EXTENT(lsb, rsb, desc, asc, data) \
+ ((lsb) > (data)[0] ? (lsb) = (data)[0] : 0 , \
+ (rsb) < (data)[0] ? (rsb) = (data)[0] : 0, \
+ (-desc) > (data)[1] ? (desc) = -(data)[1] : 0 , \
+ (asc) < (data)[1] ? (asc) = (data)[1] : 0)
+ double newlsb, newrsb, newdesc, newasc;
+ double point[2];
+
+ /* Compute new extents for this glyph */
+ TRANSFORM_POINT(vals->pixel_matrix, lsb, -desc, point);
+ newlsb = point[0];
+ newrsb = newlsb;
+ newdesc = -point[1];
+ newasc = -newdesc;
+ TRANSFORM_POINT(vals->pixel_matrix, lsb, asc, point);
+ CHECK_EXTENT(newlsb, newrsb, newdesc, newasc, point);
+ TRANSFORM_POINT(vals->pixel_matrix, rsb, -desc, point);
+ CHECK_EXTENT(newlsb, newrsb, newdesc, newasc, point);
+ TRANSFORM_POINT(vals->pixel_matrix, rsb, asc, point);
+ CHECK_EXTENT(newlsb, newrsb, newdesc, newasc, point);
+
+ /* ???: lsb = (int)floor(newlsb * scale); */
+ *lsb_result = (int)floor(newlsb * scale + 0.5);
+ *rsb_result = (int)floor(newrsb * scale + 0.5);
+ *desc_result = (int)ceil(newdesc * scale - 0.5);
+ *asc_result = (int)floor(newasc * scale + 0.5);
+
+ return 0;
+#undef CHECK_EXTENT
+#undef TRANSFORM_POINT
+}
+
+static int
+is_matrix_unit(FontScalablePtr vals)
+{
+ double base_size;
+ FT_Matrix m;
+
+ base_size = hypot(vals->point_matrix[2], vals->point_matrix[3]);
+
+ m.xx = vals->point_matrix[0] / base_size * 65536;
+ m.xy = vals->point_matrix[2] / base_size * 65536;
+ m.yx = vals->point_matrix[1] / base_size * 65536;
+ m.yy = vals->point_matrix[3] / base_size * 65536;
+
+ return (m.xx == 65536) && (m.yx == 0) &&
+ (m.xy == 0) && (m.yy == 65536);
+}
+
+/* Do all the real work for OpenFont or FontInfo */
+/* xf->info is only accessed through info, and xf might be null */
+
+static int
+FreeTypeLoadXFont(char *fileName,
+ FontScalablePtr vals, FontPtr xf, FontInfoPtr info,
+ FontBitmapFormatPtr bmfmt, FontEntryPtr entry)
+{
+ FTFontPtr font = NULL;
+ FTFacePtr face = NULL;
+ FTInstancePtr instance;
+ FT_Size_Metrics *smetrics;
+ int xrc=Successful;
+ int charcell;
+ long rawWidth = 0, rawAverageWidth = 0;
+ int upm, minLsb, maxRsb, ascent, descent, width, averageWidth;
+ double scale, base_width, base_height;
+ Bool orig_is_matrix_unit, font_properties;
+ int face_number, ttcap_spacing;
+ struct TTCapInfo tmp_ttcap;
+ struct TTCapInfo *ins_ttcap;
+ FT_Int32 load_flags = FT_LOAD_DEFAULT; /* orig: FT_LOAD_RENDER | FT_LOAD_MONOCHROME */
+ char *dynStrRealFileName = NULL; /* foo.ttc */
+ char *dynStrFTFileName = NULL; /* :1:foo.ttc */
+ char *dynStrTTCapCodeRange = NULL;
+
+ font = (FTFontPtr)xalloc(sizeof(FTFontRec));
+ if(font == NULL) {
+ xrc = AllocError;
+ goto quit;
+ }
+ memset(font, 0, sizeof(FTFontRec));
+
+ xrc = FreeTypeSetUpTTCap(fileName, vals,
+ &dynStrRealFileName, &dynStrFTFileName,
+ &tmp_ttcap, &face_number,
+ &load_flags, &ttcap_spacing,
+ &font_properties, &dynStrTTCapCodeRange);
+ if ( xrc != Successful ) {
+ goto quit;
+ }
+
+ xrc = FreeTypeOpenFace(&face, dynStrFTFileName, dynStrRealFileName, face_number);
+ if(xrc != Successful) {
+ goto quit;
+ }
+
+ if( is_matrix_unit(vals) )
+ orig_is_matrix_unit = True;
+ else {
+ orig_is_matrix_unit = False;
+ /* Turn off EmbeddedBitmap when original matrix is not diagonal. */
+ load_flags |= FT_LOAD_NO_BITMAP;
+ }
+
+ if( face->bitmap ) load_flags &= ~FT_LOAD_NO_BITMAP;
+
+ /* Slant control by TTCap */
+ if(!face->bitmap) {
+ vals->pixel_matrix[2] +=
+ vals->pixel_matrix[0] * tmp_ttcap.autoItalic;
+ vals->point_matrix[2] +=
+ vals->point_matrix[0] * tmp_ttcap.autoItalic;
+ vals->pixel_matrix[3] +=
+ vals->pixel_matrix[1] * tmp_ttcap.autoItalic;
+ vals->point_matrix[3] +=
+ vals->point_matrix[1] * tmp_ttcap.autoItalic;
+ }
+
+ base_width=hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]);
+ base_height=hypot(vals->pixel_matrix[2], vals->pixel_matrix[3]);
+ if(MAX(base_width, base_height) < 1.0 ) {
+ xrc = BadFontName;
+ goto quit;
+ }
+
+ xrc = FreeTypeLoadFont(font, info, face, dynStrFTFileName, vals, entry, bmfmt,
+ load_flags, &tmp_ttcap, dynStrTTCapCodeRange,
+ ttcap_spacing );
+ if(xrc != Successful) {
+ goto quit;
+ }
+
+ instance = font->instance;
+ smetrics = &instance->size->metrics;
+ ins_ttcap = &instance->ttcap;
+
+ upm = face->face->units_per_EM;
+ if(upm == 0) {
+ /* Work around FreeType bug */
+ upm = WORK_AROUND_UPM;
+ }
+ scale = 1.0 / upm;
+
+ charcell = (instance->spacing == FT_CHARCELL);
+
+ if( instance->charcellMetrics == NULL ) {
+
+ /* New instance */
+
+ long force_c_rawWidth = 0;
+ int force_c_lsb,force_c_rsb,force_c_width;
+ double unit_x=0,unit_y=0,advance;
+ CharInfoPtr tmpglyph;
+
+ /*
+ * CALCULATE HEADER'S METRICS
+ */
+
+ /* for OUTLINE fonts */
+ if(!face->bitmap) {
+ int new_width;
+ double ratio,force_c_ratio;
+ double width_x=0,width_y=0;
+ double force_c_width_x, force_c_rsb_x, force_c_lsb_x;
+ double tmp_rsb,tmp_lsb,tmp_asc,tmp_des;
+ double max_advance_height;
+ tmp_asc = face->face->bbox.yMax;
+ tmp_des = -(face->face->bbox.yMin);
+ if ( tmp_asc < face->face->ascender ) tmp_asc = face->face->ascender;
+ if ( tmp_des < -(face->face->descender) ) tmp_des = -(face->face->descender);
+ tmp_lsb = face->face->bbox.xMin;
+ tmp_rsb = face->face->bbox.xMax;
+ if ( tmp_rsb < face->face->max_advance_width ) tmp_rsb = face->face->max_advance_width;
+ /* apply scaleBBoxWidth */
+ /* we should not ...??? */
+ tmp_lsb *= ins_ttcap->scaleBBoxWidth;
+ tmp_rsb *= ins_ttcap->scaleBBoxWidth;
+ /* transform and rescale */
+ compute_new_extents( vals, scale, tmp_lsb, tmp_rsb, tmp_des, tmp_asc,
+ &minLsb, &maxRsb, &descent, &ascent );
+ /* */
+ /* Consider vertical layouts */
+ if( 0 < face->face->max_advance_height )
+ max_advance_height = face->face->max_advance_height;
+ else
+ max_advance_height = tmp_asc + tmp_des;
+ if( vals->pixel_matrix[1] == 0 ){
+ unit_x = fabs(vals->pixel_matrix[0]);
+ unit_y = 0;
+ width_x = face->face->max_advance_width * ins_ttcap->scaleBBoxWidth * unit_x;
+ }
+ else if( vals->pixel_matrix[3] == 0 ){
+ unit_y = fabs(vals->pixel_matrix[2]);
+ unit_x = 0;
+ width_x = max_advance_height * ins_ttcap->scaleBBoxHeight * unit_y;
+ }
+ else{
+ unit_x = fabs(vals->pixel_matrix[0] -
+ vals->pixel_matrix[1]*vals->pixel_matrix[2]/vals->pixel_matrix[3]);
+ unit_y = fabs(vals->pixel_matrix[2] -
+ vals->pixel_matrix[3]*vals->pixel_matrix[0]/vals->pixel_matrix[1]);
+ width_x = face->face->max_advance_width * ins_ttcap->scaleBBoxWidth * unit_x;
+ width_y = max_advance_height * ins_ttcap->scaleBBoxHeight * unit_y;
+ if( width_y < width_x ){
+ width_x = width_y;
+ unit_x = 0;
+ }
+ else{
+ unit_y = 0;
+ }
+ }
+ /* calculate correction ratio */
+ width = (int)floor( (advance = width_x * scale) + 0.5);
+ new_width = width;
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH )
+ new_width += ins_ttcap->doubleStrikeShift;
+ new_width += ins_ttcap->adjustBBoxWidthByPixel;
+ ratio = (double)new_width/width;
+ width = new_width;
+ /* force constant */
+ if( unit_x != 0 ) {
+ force_c_width_x = face->face->max_advance_width
+ * ins_ttcap->force_c_scale_b_box_width * unit_x;
+ force_c_lsb_x = face->face->max_advance_width
+ * ins_ttcap->force_c_scale_lsb * unit_x;
+ force_c_rsb_x = face->face->max_advance_width
+ * ins_ttcap->force_c_scale_rsb * unit_x;
+ }
+ else {
+ force_c_width_x = max_advance_height
+ * ins_ttcap->force_c_scale_b_box_height * unit_y;
+ force_c_lsb_x = max_advance_height
+ * ins_ttcap->force_c_scale_lsb * unit_y;
+ force_c_rsb_x = max_advance_height
+ * ins_ttcap->force_c_scale_rsb * unit_y;
+ }
+ /* calculate correction ratio */
+ force_c_width = (int)floor(force_c_width_x * scale + 0.5);
+ new_width = force_c_width;
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH )
+ force_c_width += ins_ttcap->doubleStrikeShift;
+ new_width += ins_ttcap->force_c_adjust_width_by_pixel;
+ force_c_ratio = (double)new_width/force_c_width;
+ force_c_width = new_width;
+ /* force_c_lsb, force_c_rsb */
+ if( ins_ttcap->flags & TTCAP_FORCE_C_LSB_FLAG )
+ force_c_lsb = (int)floor( force_c_lsb_x * scale + 0.5 );
+ else
+ force_c_lsb = minLsb;
+ if( ins_ttcap->flags & TTCAP_FORCE_C_RSB_FLAG )
+ force_c_rsb = (int)floor( force_c_rsb_x * scale + 0.5 );
+ else
+ force_c_rsb = maxRsb;
+ /* calculate shift of BitmapAutoItalic
+ (when diagonal matrix only) */
+ if( orig_is_matrix_unit == True ) {
+ if( ins_ttcap->autoItalic != 0 ) {
+ double ai;
+ int ai_lsb,ai_rsb,ai_total;
+ if( 0 < ins_ttcap->autoItalic ) ai=ins_ttcap->autoItalic;
+ else ai = -ins_ttcap->autoItalic;
+ ai_total = (int)( (ascent+descent) * ai + 0.5);
+ ai_rsb = (int)((double)ai_total * ascent / ( ascent + descent ) + 0.5 );
+ ai_lsb = -(ai_total - ai_rsb);
+ if( 0 < ins_ttcap->autoItalic ) {
+ ins_ttcap->lsbShiftOfBitmapAutoItalic = ai_lsb;
+ ins_ttcap->rsbShiftOfBitmapAutoItalic = ai_rsb;
+ }
+ else {
+ ins_ttcap->lsbShiftOfBitmapAutoItalic = -ai_rsb;
+ ins_ttcap->rsbShiftOfBitmapAutoItalic = -ai_lsb;
+ }
+ }
+ }
+ /* integer adjustment by TTCap */
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE )
+ maxRsb += ins_ttcap->doubleStrikeShift;
+ maxRsb += ins_ttcap->adjustRightSideBearingByPixel;
+ minLsb += ins_ttcap->adjustLeftSideBearingByPixel;
+ /* */
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE )
+ force_c_rsb += ins_ttcap->doubleStrikeShift;
+ force_c_rsb += ins_ttcap->force_c_adjust_rsb_by_pixel;
+ force_c_lsb += ins_ttcap->force_c_adjust_lsb_by_pixel;
+ /* apply to rawWidth */
+ averageWidth = (int)floor(10 * width_x * scale
+ * ratio + 0.5);
+ rawWidth = floor(width_x * scale
+ * ratio * 1000. / base_height + 0.5);
+ rawAverageWidth = floor(width_x * scale * ratio * 10.
+ * 1000. / base_height + 0.5);
+ force_c_rawWidth = floor(force_c_width_x * scale
+ * force_c_ratio * 1000. / base_height + 0.5);
+ /* */
+ }
+ /* for BITMAP fonts [if(face->bitmap)] */
+ else {
+ /* These values differ from actual when outline,
+ so we must use them ONLY FOR BITMAP. */
+ width = (int)floor(smetrics->max_advance * ins_ttcap->scaleBBoxWidth / 64.0 + .5);
+ descent = -smetrics->descender / 64;
+ ascent = smetrics->ascender / 64;
+ /* force constant */
+ force_c_width = (int)floor(smetrics->max_advance
+ * ins_ttcap->force_c_scale_b_box_width / 64.0 + .5);
+ /* Preserve average width for bitmap fonts */
+ if(vals->width != 0)
+ averageWidth = (int)floor(vals->width * ins_ttcap->scaleBBoxWidth +.5);
+ else
+ averageWidth = (int)floor(10.0 * smetrics->max_advance
+ * ins_ttcap->scaleBBoxWidth / 64.0 + .5);
+ rawWidth = 0;
+ rawAverageWidth = 0;
+ force_c_rawWidth = 0;
+ /* We don't consider vertical layouts */
+ advance = (int)floor(smetrics->max_advance / 64.0 +.5);
+ unit_x = vals->pixel_matrix[0];
+ unit_y = 0;
+ /* We can use 'width' only when bitmap.
+ This should not be set when outline. */
+ minLsb = 0;
+ maxRsb = width;
+ /* force constant */
+ if( ins_ttcap->flags & TTCAP_FORCE_C_LSB_FLAG )
+ force_c_lsb = (int)floor(smetrics->max_advance
+ * ins_ttcap->force_c_scale_lsb / 64.0 + .5);
+ else
+ force_c_lsb = minLsb;
+ if( ins_ttcap->flags & TTCAP_FORCE_C_RSB_FLAG )
+ force_c_rsb = (int)floor(smetrics->max_advance
+ * ins_ttcap->force_c_scale_rsb / 64.0 + .5);
+ else
+ force_c_rsb = maxRsb;
+ /* calculate shift of BitmapAutoItalic */
+ if( ins_ttcap->autoItalic != 0 ) {
+ double ai;
+ int ai_lsb,ai_rsb,ai_total;
+ if( 0 < ins_ttcap->autoItalic ) ai=ins_ttcap->autoItalic;
+ else ai = -ins_ttcap->autoItalic;
+ ai_total = (int)( (ascent+descent) * ai + 0.5);
+ ai_rsb = (int)((double)ai_total * ascent / ( ascent + descent ) + 0.5 );
+ ai_lsb = -(ai_total - ai_rsb);
+ if( 0 < ins_ttcap->autoItalic ) {
+ ins_ttcap->lsbShiftOfBitmapAutoItalic = ai_lsb;
+ ins_ttcap->rsbShiftOfBitmapAutoItalic = ai_rsb;
+ }
+ else {
+ ins_ttcap->lsbShiftOfBitmapAutoItalic = -ai_rsb;
+ ins_ttcap->rsbShiftOfBitmapAutoItalic = -ai_lsb;
+ }
+ }
+ /* integer adjustment by TTCap */
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH )
+ width += ins_ttcap->doubleStrikeShift;
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE )
+ maxRsb += ins_ttcap->doubleStrikeShift;
+ maxRsb += ins_ttcap->adjustRightSideBearingByPixel;
+ minLsb += ins_ttcap->adjustLeftSideBearingByPixel;
+ /* We have not carried out matrix calculation, so this is done. */
+ maxRsb += ins_ttcap->rsbShiftOfBitmapAutoItalic;
+ minLsb += ins_ttcap->lsbShiftOfBitmapAutoItalic;
+ /* force constant */
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE )
+ force_c_rsb += ins_ttcap->doubleStrikeShift;
+ force_c_rsb += ins_ttcap->force_c_adjust_rsb_by_pixel;
+ force_c_lsb += ins_ttcap->force_c_adjust_lsb_by_pixel;
+ force_c_rsb += ins_ttcap->rsbShiftOfBitmapAutoItalic;
+ force_c_lsb += ins_ttcap->lsbShiftOfBitmapAutoItalic;
+ }
+
+ /* SET CALCULATED VALUES TO INSTANCE */
+
+ /* Set actual height and cosine */
+ instance->pixel_size = base_height;
+ instance->advance = advance;
+ if ( unit_x != 0 ){
+ instance->pixel_width_unit_x = unit_x/base_height;
+ instance->pixel_width_unit_y = 0;
+ }
+ else{
+ instance->pixel_width_unit_x = 0;
+ instance->pixel_width_unit_y = unit_y/base_height;
+ }
+
+ /* header's metrics */
+ instance->charcellMetrics = (xCharInfo*)xalloc(sizeof(xCharInfo));
+ if(instance->charcellMetrics == NULL) {
+ xrc = AllocError;
+ goto quit;
+ }
+ instance->charcellMetrics->ascent = ascent;
+ instance->charcellMetrics->descent = descent;
+ instance->charcellMetrics->attributes = rawWidth;
+ instance->charcellMetrics->rightSideBearing = maxRsb;
+ instance->charcellMetrics->leftSideBearing = minLsb;
+ instance->charcellMetrics->characterWidth = width;
+ instance->averageWidth = averageWidth;
+ instance->rawAverageWidth = rawAverageWidth;
+
+ /* Check code 0 */
+ if( FreeTypeInstanceGetGlyph(font->zero_idx, 0, &tmpglyph, font->instance) != Successful
+ || tmpglyph == NULL)
+ if( FreeTypeInstanceGetGlyph(font->zero_idx, FT_GET_DUMMY, &tmpglyph, font->instance)
+ != Successful )
+ tmpglyph = NULL;
+ if ( !tmpglyph ) {
+ xrc = AllocError;
+ goto quit;
+ }
+
+ /* FORCE CONSTANT METRICS */
+ if( 0 <= ins_ttcap->forceConstantSpacingEnd ) {
+ xCharInfo *tmpchar = NULL;
+ int c = ins_ttcap->force_c_representative_metrics_char_code;
+ /* header's metrics */
+ if( instance->forceConstantMetrics == NULL ){
+ instance->forceConstantMetrics = (xCharInfo*)xalloc(sizeof(xCharInfo));
+ if(instance->forceConstantMetrics == NULL) {
+ xrc = AllocError;
+ goto quit;
+ }
+ }
+ /* Get Representative Metrics */
+ if ( 0 <= c ) {
+ if( FreeTypeFontGetGlyphMetrics(c, 0, &tmpchar, font) != Successful )
+ tmpchar = NULL;
+ }
+ if ( tmpchar && 0 < tmpchar->characterWidth ) {
+ instance->forceConstantMetrics->leftSideBearing = tmpchar->leftSideBearing;
+ instance->forceConstantMetrics->rightSideBearing = tmpchar->rightSideBearing;
+ instance->forceConstantMetrics->characterWidth = tmpchar->characterWidth;
+ instance->forceConstantMetrics->ascent = tmpchar->ascent;
+ instance->forceConstantMetrics->descent = tmpchar->descent;
+ instance->forceConstantMetrics->attributes = tmpchar->attributes;
+ }
+ else {
+ instance->forceConstantMetrics->leftSideBearing = force_c_lsb;
+ instance->forceConstantMetrics->rightSideBearing = force_c_rsb;
+ instance->forceConstantMetrics->characterWidth = force_c_width;
+ instance->forceConstantMetrics->ascent = ascent;
+ instance->forceConstantMetrics->descent = descent;
+ instance->forceConstantMetrics->attributes = force_c_rawWidth;
+ }
+ /* Check code 0 */
+ if( FreeTypeInstanceGetGlyph(font->zero_idx, FT_FORCE_CONSTANT_SPACING,
+ &tmpglyph, font->instance) != Successful
+ || tmpglyph == NULL)
+ if( FreeTypeInstanceGetGlyph(font->zero_idx, FT_FORCE_CONSTANT_SPACING | FT_GET_DUMMY,
+ &tmpglyph, font->instance)
+ != Successful )
+ tmpglyph = NULL;
+ if ( !tmpglyph ) {
+ xrc = AllocError;
+ goto quit;
+ }
+ }
+ }
+ else{
+
+ /*
+ * CACHED VALUES
+ */
+
+ width = instance->charcellMetrics->characterWidth;
+ ascent = instance->charcellMetrics->ascent;
+ descent = instance->charcellMetrics->descent;
+ rawWidth = instance->charcellMetrics->attributes;
+ maxRsb = instance->charcellMetrics->rightSideBearing;
+ minLsb = instance->charcellMetrics->leftSideBearing;
+ averageWidth = instance->averageWidth;
+ rawAverageWidth = instance->rawAverageWidth;
+
+ }
+
+ /*
+ * SET maxbounds, minbounds ...
+ */
+
+ if( !charcell ) { /* NOT CHARCELL */
+ if( info ){
+ /*
+ Calculate all glyphs' metrics.
+ maxbounds.ascent and maxbounds.descent are quite important values
+ for XAA. If ascent/descent of each glyph exceeds
+ maxbounds.ascent/maxbounds.descent, XAA causes SERVER CRASH.
+ Therefore, THIS MUST BE DONE.
+ */
+ ft_compute_bounds(font,info,vals);
+ }
+ }
+ else{ /* CHARCELL */
+
+ /*
+ * SET CALCULATED OR CACHED VARIABLES
+ */
+
+ vals->width = averageWidth;
+
+ if( info ){
+
+ info->maxbounds.leftSideBearing = minLsb;
+ info->maxbounds.rightSideBearing = maxRsb;
+ info->maxbounds.characterWidth = width;
+ info->maxbounds.ascent = ascent;
+ info->maxbounds.descent = descent;
+ info->maxbounds.attributes =
+ (unsigned short)(short)rawWidth;
+
+ info->minbounds = info->maxbounds;
+ }
+ }
+
+ /* set info */
+
+ if( info ){
+ /*
+ info->fontAscent = ascent;
+ info->fontDescent = descent;
+ */
+ info->fontAscent = info->maxbounds.ascent;
+ info->fontDescent = info->maxbounds.descent;
+ /* Glyph metrics are accurate */
+ info->inkMetrics=1;
+
+ memcpy((char *)&info->ink_maxbounds,
+ (char *)&info->maxbounds, sizeof(xCharInfo));
+ memcpy((char *)&info->ink_minbounds,
+ (char *)&info->minbounds, sizeof(xCharInfo));
+
+ /* XXX - hack */
+ info->defaultCh=0;
+
+ /* Set the pInfo flags */
+ /* Properties set by FontComputeInfoAccelerators:
+ pInfo->noOverlap;
+ pInfo->terminalFont;
+ pInfo->constantMetrics;
+ pInfo->constantWidth;
+ pInfo->inkInside;
+ */
+ /* from lib/font/util/fontaccel.c */
+ FontComputeInfoAccelerators(info);
+ }
+
+ if(xf)
+ xf->fontPrivate = (void*)font;
+
+ if(info) {
+ xrc = FreeTypeAddProperties(font, vals, info, entry->name.name,
+ rawAverageWidth, font_properties);
+ if (xrc != Successful) {
+ goto quit;
+ }
+ }
+
+ quit:
+ if ( dynStrTTCapCodeRange ) xfree(dynStrTTCapCodeRange);
+ if ( dynStrFTFileName ) xfree(dynStrFTFileName);
+ if ( dynStrRealFileName ) xfree(dynStrRealFileName);
+ if ( xrc != Successful ) {
+ if( font ){
+ if( face && font->instance == NULL ) FreeTypeFreeFace(face);
+ FreeTypeFreeFont(font);
+ }
+ }
+ return xrc;
+}
+
+/* Routines used by X11 to get info and glyphs from the font. */
+
+static int
+FreeTypeGetMetrics(FontPtr pFont, unsigned long count, unsigned char *chars,
+ FontEncoding charEncoding, unsigned long *metricCount,
+ xCharInfo **metrics)
+{
+ unsigned int code = 0;
+ int flags = 0;
+ FTFontPtr tf;
+ struct TTCapInfo *ttcap;
+ xCharInfo **mp, *m;
+
+ /* MUMBLE1("Get metrics for %ld characters\n", count);*/
+
+ tf = (FTFontPtr)pFont->fontPrivate;
+ ttcap = &tf->instance->ttcap;
+ mp = metrics;
+
+ while (count-- > 0) {
+ switch (charEncoding) {
+ case Linear8Bit:
+ case TwoD8Bit:
+ code = *chars++;
+ break;
+ case Linear16Bit:
+ case TwoD16Bit:
+ code = (*chars++ << 8);
+ code |= *chars++;
+ /* */
+ if ( !(ttcap->flags & TTCAP_FORCE_C_OUTSIDE) ) {
+ if ( (int)code <= ttcap->forceConstantSpacingEnd
+ && ttcap->forceConstantSpacingBegin <= (int)code )
+ flags|=FT_FORCE_CONSTANT_SPACING;
+ else flags=0;
+ }
+ else { /* for GB18030 proportional */
+ if ( (int)code <= ttcap->forceConstantSpacingEnd
+ || ttcap->forceConstantSpacingBegin <= (int)code )
+ flags|=FT_FORCE_CONSTANT_SPACING;
+ else flags=0;
+ }
+ break;
+ }
+
+ if(FreeTypeFontGetGlyphMetrics(code, flags, &m, tf) == Successful && m!=NULL) {
+ *mp++ = m;
+ }
+#ifdef X_ACCEPTS_NO_SUCH_CHAR
+ else *mp++ = &noSuchChar.metrics;
+#endif
+ }
+
+ *metricCount = mp - metrics;
+ return Successful;
+}
+
+static int
+FreeTypeGetGlyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
+ FontEncoding charEncoding, unsigned long *glyphCount,
+ CharInfoPtr *glyphs)
+{
+ unsigned int code = 0;
+ int flags = 0;
+ FTFontPtr tf;
+ CharInfoPtr *gp;
+ CharInfoPtr g;
+ struct TTCapInfo *ttcap;
+
+ tf = (FTFontPtr)pFont->fontPrivate;
+ ttcap = &tf->instance->ttcap;
+ gp = glyphs;
+
+ while (count-- > 0) {
+ switch (charEncoding) {
+ case Linear8Bit: case TwoD8Bit:
+ code = *chars++;
+ break;
+ case Linear16Bit: case TwoD16Bit:
+ code = *chars++ << 8;
+ code |= *chars++;
+ /* */
+ if ( !(ttcap->flags & TTCAP_FORCE_C_OUTSIDE) ) {
+ if ( (int)code <= ttcap->forceConstantSpacingEnd
+ && ttcap->forceConstantSpacingBegin <= (int)code )
+ flags|=FT_FORCE_CONSTANT_SPACING;
+ else flags=0;
+ }
+ else { /* for GB18030 proportional */
+ if ( (int)code <= ttcap->forceConstantSpacingEnd
+ || ttcap->forceConstantSpacingBegin <= (int)code )
+ flags|=FT_FORCE_CONSTANT_SPACING;
+ else flags=0;
+ }
+ break;
+ }
+
+ if(FreeTypeFontGetGlyph(code, flags, &g, tf) == Successful && g!=NULL) {
+ *gp++ = g;
+ }
+#ifdef X_ACCEPTS_NO_SUCH_CHAR
+ else {
+#ifdef XAA_ACCEPTS_NULL_BITS
+ *gp++ = &noSuchChar;
+#else
+ if ( tf->dummy_char.bits ) {
+ *gp++ = &tf->dummy_char;
+ }
+ else {
+ char *raster = NULL;
+ int wd_actual, ht_actual, wd, ht, bpr;
+ wd_actual = tf->info->maxbounds.rightSideBearing - tf->info->maxbounds.leftSideBearing;
+ ht_actual = tf->info->maxbounds.ascent + tf->info->maxbounds.descent;
+ if(wd_actual <= 0) wd = 1;
+ else wd=wd_actual;
+ if(ht_actual <= 0) ht = 1;
+ else ht=ht_actual;
+ bpr = (((wd + (tf->instance->bmfmt.glyph<<3) - 1) >> 3) &
+ -tf->instance->bmfmt.glyph);
+ raster = (char*)xalloc(ht * bpr);
+ if(raster) {
+ memset(raster, 0, ht * bpr);
+ tf->dummy_char.bits = raster;
+ *gp++ = &tf->dummy_char;
+ }
+ }
+#endif
+ }
+#endif
+ }
+
+ *glyphCount = gp - glyphs;
+ return Successful;
+}
+
+static int
+FreeTypeSetUpFont(FontPathElementPtr fpe, FontPtr xf, FontInfoPtr info,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ FontBitmapFormatPtr bmfmt)
+{
+ int xrc;
+ int image;
+
+ /* Get the default bitmap format information for this X installation.
+ Also update it for the client if running in the font server. */
+ FontDefaultFormat(&bmfmt->bit, &bmfmt->byte, &bmfmt->glyph, &bmfmt->scan);
+ if ((xrc = CheckFSFormat(format, fmask, &bmfmt->bit, &bmfmt->byte,
+ &bmfmt->scan, &bmfmt->glyph,
+ &image)) != Successful) {
+ MUMBLE1("Aborting after checking FS format: %d\n", xrc);
+ return xrc;
+ }
+
+ if(xf) {
+ xf->refcnt = 0;
+ xf->bit = bmfmt->bit;
+ xf->byte = bmfmt->byte;
+ xf->glyph = bmfmt->glyph;
+ xf->scan = bmfmt->scan;
+ xf->format = format;
+ xf->get_glyphs = FreeTypeGetGlyphs;
+ xf->get_metrics = FreeTypeGetMetrics;
+ xf->unload_font = FreeTypeUnloadXFont;
+ xf->unload_glyphs = 0;
+ xf->fpe = fpe;
+ xf->svrPrivate = 0;
+ xf->fontPrivate = 0; /* we'll set it later */
+ xf->fpePrivate = 0;
+ }
+
+ info->defaultCh = 0;
+ info->noOverlap = 0; /* not updated */
+ info->terminalFont = 0; /* not updated */
+ info->constantMetrics = 0; /* we'll set it later */
+ info->constantWidth = 0; /* we'll set it later */
+ info->inkInside = 1;
+ info->inkMetrics = 1;
+ info->allExist=0; /* not updated */
+ info->drawDirection = LeftToRight; /* we'll set it later */
+ info->cachable = 1; /* we don't do licensing */
+ info->anamorphic = 0; /* can hinting lead to anamorphic scaling? */
+ info->maxOverlap = 0; /* we'll set it later. */
+ info->pad = 0; /* ??? */
+ return Successful;
+}
+
+/* Functions exported by the backend */
+
+static int
+FreeTypeOpenScalable(FontPathElementPtr fpe, FontPtr *ppFont, int flags,
+ FontEntryPtr entry, char *fileName, FontScalablePtr vals,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font)
+{
+ int xrc;
+ FontPtr xf;
+ FontBitmapFormatRec bmfmt;
+
+ MUMBLE1("Open Scalable %s, XLFD=",fileName);
+#ifdef DEBUG_TRUETYPE
+ fwrite(entry->name.name, entry->name.length, 1, stdout);
+#endif
+ MUMBLE("\n");
+
+ xf = CreateFontRec();
+ if (xf == NULL)
+ return AllocError;
+
+ xrc = FreeTypeSetUpFont(fpe, xf, &xf->info, format, fmask, &bmfmt);
+ if(xrc != Successful) {
+ DestroyFontRec(xf);
+ return xrc;
+ }
+ xrc = FreeTypeLoadXFont(fileName, vals, xf, &xf->info, &bmfmt, entry);
+ if(xrc != Successful) {
+ MUMBLE1("Error during load: %d\n",xrc);
+ DestroyFontRec(xf);
+ return xrc;
+ }
+
+ *ppFont = xf;
+
+ return xrc;
+}
+
+/* Routine to get requested font info. */
+
+static int
+FreeTypeGetInfoScalable(FontPathElementPtr fpe, FontInfoPtr info,
+ FontEntryPtr entry, FontNamePtr fontName,
+ char *fileName, FontScalablePtr vals)
+{
+ int xrc;
+ FontBitmapFormatRec bmfmt;
+
+ MUMBLE("Get info, XLFD= ");
+#ifdef DEBUG_TRUETYPE
+ fwrite(entry->name.name, entry->name.length, 1, stdout);
+#endif
+ MUMBLE("\n");
+
+ xrc = FreeTypeSetUpFont(fpe, 0, info, 0, 0, &bmfmt);
+ if(xrc != Successful) {
+ return xrc;
+ }
+
+ bmfmt.glyph <<= 3;
+
+ xrc = FreeTypeLoadXFont(fileName, vals, 0, info, &bmfmt, entry);
+ if(xrc != Successful) {
+ MUMBLE1("Error during load: %d\n", xrc);
+ return xrc;
+ }
+
+ return Successful;
+}
+
+/* Renderer registration. */
+
+/* Set the capabilities of this renderer. */
+#define CAPABILITIES (CAP_CHARSUBSETTING | CAP_MATRIX)
+
+/* Set it up so file names with either upper or lower case can be
+ loaded. We don't support compressed fonts. */
+static FontRendererRec renderers[] = {
+ {".ttf", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".TTF", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".ttc", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".TTC", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".otf", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".OTF", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".otc", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".OTC", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".pfa", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".PFA", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".pfb", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".PFB", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+};
+static int num_renderers = sizeof(renderers) / sizeof(renderers[0]);
+
+static FontRendererRec alt_renderers[] = {
+ {".bdf", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".BDF", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".pcf", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".PCF", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+};
+
+static int num_alt_renderers =
+sizeof(alt_renderers) / sizeof(alt_renderers[0]);
+
+
+void
+FreeTypeRegisterFontFileFunctions(void)
+{
+ int i;
+
+ for (i = 0; i < num_renderers; i++)
+ FontFileRegisterRenderer(&renderers[i]);
+
+ for (i = 0; i < num_alt_renderers; i++)
+ FontFilePriorityRegisterRenderer(&alt_renderers[i], -10);
+}
diff --git a/nx-X11/lib/font/FreeType/ftfuncs.h b/nx-X11/lib/font/FreeType/ftfuncs.h
new file mode 100644
index 000000000..f115a8b77
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/ftfuncs.h
@@ -0,0 +1,189 @@
+/*
+Copyright (c) 1998-2002 by Juliusz Chroboczek
+Copyright (c) 2003 After X-TT Project, All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+/* $XFree86: xc/lib/font/FreeType/ftfuncs.h,v 1.17 2003/12/21 04:02:07 dawes Exp $ */
+
+/* Number of buckets in the hashtable holding faces */
+#define NUMFACEBUCKETS 32
+
+/* Glyphs are held in segments of this size */
+#define FONTSEGMENTSIZE 16
+
+/* A structure that holds bitmap order and padding info. */
+
+typedef struct {
+ int bit; /* bit order */
+ int byte; /* byte order */
+ int glyph; /* glyph pad size */
+ int scan; /* machine word size */
+} FontBitmapFormatRec, *FontBitmapFormatPtr;
+
+struct FTSize_s;
+
+/* At the lowest level, there is face; FTFaces are in one-to-one
+ correspondence with TrueType faces. Multiple instance may share
+ the same face. */
+
+typedef struct _FTFace {
+ char *filename;
+ FT_Face face;
+ int bitmap;
+ struct _FTInstance *instances;
+ struct _FTInstance *active_instance;
+ struct _FTFace *next; /* link to next face in bucket */
+} FTFaceRec, *FTFacePtr;
+
+/* A transformation matrix with resolution information */
+typedef struct _FTNormalisedTransformation {
+ double scale;
+ int nonIdentity; /* if 0, matrix is the identity */
+ FT_Matrix matrix;
+ int xres, yres;
+} FTNormalisedTransformationRec, *FTNormalisedTransformationPtr;
+
+#define FT_PROPORTIONAL 0
+#define FT_MONOSPACED 1
+#define FT_CHARCELL 2
+
+#define FT_AVAILABLE_UNKNOWN 0
+#define FT_AVAILABLE_NO 1
+#define FT_AVAILABLE_METRICS 2
+#define FT_AVAILABLE_RASTERISED 3
+
+#define FT_GET_GLYPH_BOTH 0x01
+#define FT_GET_GLYPH_METRICS_ONLY 0x02
+#define FT_GET_DUMMY 0x04
+#define FT_FORCE_CONSTANT_SPACING 0x08
+
+#define TTCAP_DOUBLE_STRIKE 0x0001
+#define TTCAP_DOUBLE_STRIKE_MKBOLD_EDGE_LEFT 0x0002
+#define TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH 0x0008
+#define TTCAP_IS_VERY_LAZY 0x0010
+#define TTCAP_DISABLE_DEFAULT_VERY_LAZY 0x0020
+#define TTCAP_FORCE_C_LSB_FLAG 0x0100
+#define TTCAP_FORCE_C_RSB_FLAG 0x0200
+#define TTCAP_FORCE_C_OUTSIDE 0x0400
+#define TTCAP_MONO_CENTER 0x0800
+
+/* TTCap */
+struct TTCapInfo {
+ long flags;
+ double autoItalic;
+ double scaleWidth;
+ double scaleBBoxWidth;
+ double scaleBBoxHeight;
+ int doubleStrikeShift;
+ int adjustBBoxWidthByPixel;
+ int adjustLeftSideBearingByPixel;
+ int adjustRightSideBearingByPixel;
+ double scaleBitmap;
+ int forceConstantSpacingBegin;
+ int forceConstantSpacingEnd;
+ /* We don't compare */
+ int force_c_adjust_width_by_pixel;
+ int force_c_adjust_lsb_by_pixel;
+ int force_c_adjust_rsb_by_pixel;
+ int force_c_representative_metrics_char_code;
+ double force_c_scale_b_box_width;
+ double force_c_scale_b_box_height;
+ double force_c_scale_lsb;
+ double force_c_scale_rsb;
+ double vl_slant;
+ int lsbShiftOfBitmapAutoItalic;
+ int rsbShiftOfBitmapAutoItalic;
+};
+
+/* An instance builds on a face by specifying the transformation
+ matrix. Multiple fonts may share the same instance. */
+
+/* This structure caches bitmap data */
+typedef struct _FTInstance {
+ FTFacePtr face; /* the associated face */
+ FT_Size size;
+ FTNormalisedTransformationRec transformation;
+ FT_Int32 load_flags;
+ FT_ULong strike_index;
+ int spacing; /* actual spacing */
+ double pixel_size; /* to calc attributes (actual height) */
+ double pixel_width_unit_x; /* to calc horiz. width (cosine) */
+ double pixel_width_unit_y; /* to calc vert. width (cosine) */
+ xCharInfo *charcellMetrics; /* the header's metrics */
+ int averageWidth; /* the header's metrics */
+ long rawAverageWidth; /* the header's metrics */
+ double advance; /* the header's metrics */
+ xCharInfo *forceConstantMetrics;
+ FontBitmapFormatRec bmfmt;
+ unsigned nglyphs;
+ CharInfoPtr *glyphs; /* glyphs and available are used in parallel */
+ int **available;
+ struct TTCapInfo ttcap;
+ int refcount;
+ struct _FTInstance *next; /* link to next instance */
+} FTInstanceRec, *FTInstancePtr;
+
+/* A font is an instance with coding information; fonts are in
+ one-to-one correspondence with X fonts */
+typedef struct _FTFont{
+ FTInstancePtr instance;
+ FTMappingRec mapping;
+ unsigned zero_idx;
+ FontInfoPtr info;
+ int nranges;
+ CharInfoRec dummy_char;
+ fsRange *ranges;
+} FTFontRec, *FTFontPtr;
+
+#ifndef NOT_IN_FTFUNCS
+
+/* Prototypes for some local functions */
+
+static int FreeTypeOpenFace(FTFacePtr *facep, char *FTFileName, char *realFileName, int faceNumber);
+static void FreeTypeFreeFace(FTFacePtr face);
+static int
+FreeTypeOpenInstance(FTInstancePtr *instancep, FTFacePtr face,
+ char *FTFileName, FTNormalisedTransformationPtr trans,
+ int spacing, FontBitmapFormatPtr bmfmt,
+ struct TTCapInfo *tmp_ttcap, FT_Int32 load_flags);
+static void FreeTypeFreeInstance(FTInstancePtr instance);
+static int
+FreeTypeInstanceGetGlyph(unsigned idx, int flags, CharInfoPtr *g, FTInstancePtr instance);
+static int
+FreeTypeInstanceGetGlyphMetrics(unsigned idx, int flags,
+ xCharInfo **metrics, FTInstancePtr instance );
+static int
+FreeTypeRasteriseGlyph(unsigned idx, int flags, CharInfoPtr tgp,
+ FTInstancePtr instance, int hasMetrics );
+static void FreeTypeFreeFont(FTFontPtr font);
+static void FreeTypeFreeXFont(FontPtr pFont, int freeProps);
+static void FreeTypeUnloadXFont(FontPtr pFont);
+static int
+FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
+ char *fontname, int rawAverageWidth, Bool font_properties);
+static int FreeTypeFontGetGlyph(unsigned code, int flags, CharInfoPtr *g, FTFontPtr font);
+static int
+FreeTypeLoadFont(FTFontPtr font, FontInfoPtr info, FTFacePtr face,
+ char *FTFileName, FontScalablePtr vals, FontEntryPtr entry,
+ FontBitmapFormatPtr bmfmt, FT_Int32 load_flags,
+ struct TTCapInfo *tmp_ttcap, char *dynStrTTCapCodeRange,
+ int ttcap_spacing );
+
+#endif /* NOT_IN_FTFUNCS */
diff --git a/nx-X11/lib/font/FreeType/ftsystem.c b/nx-X11/lib/font/FreeType/ftsystem.c
new file mode 100644
index 000000000..90c51c1bf
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/ftsystem.c
@@ -0,0 +1,332 @@
+/***************************************************************************/
+/* */
+/* ftsystem.c */
+/* */
+/* ANSI-specific FreeType low-level system interface (body). */
+/* */
+/* Copyright 1996-2001, 2002 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* Modified for XFree86. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+/* Modified for XFree86 */
+/* $XFree86$ */
+
+ /*************************************************************************/
+ /* */
+ /* This file contains the default interface used by FreeType to access */
+ /* low-level, i.e. memory management, i/o access as well as thread */
+ /* synchronisation. It can be replaced by user-specific routines if */
+ /* necessary. */
+ /* */
+ /*************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <ft2build.h>
+#include FT_CONFIG_CONFIG_H
+#include FT_INTERNAL_DEBUG_H
+#include FT_SYSTEM_H
+#include FT_ERRORS_H
+#include FT_TYPES_H
+
+#ifndef FONTMODULE
+#include <stdio.h>
+#include <stdlib.h>
+#else
+#include "Xmd.h"
+#define _XTYPEDEF_BOOL
+#include "Xdefs.h"
+#define DONT_DEFINE_WRAPPERS
+#include "xf86_ansic.h"
+#undef DONT_DEFINE_WRAPPERS
+#define malloc(x) xf86malloc(x)
+#define realloc(x, y) xf86realloc(x, y)
+#define free(x) xf86free(x)
+#define FILE XF86FILE
+#define fopen(x, y) xf86fopen(x, y)
+#define fclose(x) xf86fclose(x)
+#define fseek(x, y, z) xf86fseek(x, y, z)
+#define ftell(x) xf86ftell(x)
+#define SEEK_SET XF86_SEEK_SET
+#define SEEK_END XF86_SEEK_END
+#define fread(x, y, z, t) xf86fread(x, y, z, t)
+#endif
+
+
+ /*************************************************************************/
+ /* */
+ /* MEMORY MANAGEMENT INTERFACE */
+ /* */
+ /*************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* It is not necessary to do any error checking for the */
+ /* allocation-related functions. This will be done by the higher level */
+ /* routines like FT_Alloc() or FT_Realloc(). */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* ft_alloc */
+ /* */
+ /* <Description> */
+ /* The memory allocation function. */
+ /* */
+ /* <Input> */
+ /* memory :: A pointer to the memory object. */
+ /* */
+ /* size :: The requested size in bytes. */
+ /* */
+ /* <Return> */
+ /* The address of newly allocated block. */
+ /* */
+ FT_CALLBACK_DEF( void* )
+ ft_alloc( FT_Memory memory,
+ long size )
+ {
+ FT_UNUSED( memory );
+
+ return malloc( size );
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* ft_realloc */
+ /* */
+ /* <Description> */
+ /* The memory reallocation function. */
+ /* */
+ /* <Input> */
+ /* memory :: A pointer to the memory object. */
+ /* */
+ /* cur_size :: The current size of the allocated memory block. */
+ /* */
+ /* new_size :: The newly requested size in bytes. */
+ /* */
+ /* block :: The current address of the block in memory. */
+ /* */
+ /* <Return> */
+ /* The address of the reallocated memory block. */
+ /* */
+ FT_CALLBACK_DEF( void* )
+ ft_realloc( FT_Memory memory,
+ long cur_size,
+ long new_size,
+ void* block )
+ {
+ FT_UNUSED( memory );
+ FT_UNUSED( cur_size );
+
+ return realloc( block, new_size );
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* ft_free */
+ /* */
+ /* <Description> */
+ /* The memory release function. */
+ /* */
+ /* <Input> */
+ /* memory :: A pointer to the memory object. */
+ /* */
+ /* block :: The address of block in memory to be freed. */
+ /* */
+ FT_CALLBACK_DEF( void )
+ ft_free( FT_Memory memory,
+ void* block )
+ {
+ FT_UNUSED( memory );
+
+ free( block );
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* RESOURCE MANAGEMENT INTERFACE */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_io
+
+ /* We use the macro STREAM_FILE for convenience to extract the */
+ /* system-specific stream handle from a given FreeType stream object */
+#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer )
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* ft_ansi_stream_close */
+ /* */
+ /* <Description> */
+ /* The function to close a stream. */
+ /* */
+ /* <Input> */
+ /* stream :: A pointer to the stream object. */
+ /* */
+ FT_CALLBACK_DEF( void )
+ ft_ansi_stream_close( FT_Stream stream )
+ {
+ fclose( STREAM_FILE( stream ) );
+
+ stream->descriptor.pointer = NULL;
+ stream->size = 0;
+ stream->base = 0;
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* ft_ansi_stream_io */
+ /* */
+ /* <Description> */
+ /* The function to open a stream. */
+ /* */
+ /* <Input> */
+ /* stream :: A pointer to the stream object. */
+ /* */
+ /* offset :: The position in the data stream to start reading. */
+ /* */
+ /* buffer :: The address of buffer to store the read data. */
+ /* */
+ /* count :: The number of bytes to read from the stream. */
+ /* */
+ /* <Return> */
+ /* The number of bytes actually read. */
+ /* */
+ FT_CALLBACK_DEF( unsigned long )
+ ft_ansi_stream_io( FT_Stream stream,
+ unsigned long offset,
+ unsigned char* buffer,
+ unsigned long count )
+ {
+ FILE* file;
+
+
+ file = STREAM_FILE( stream );
+
+ fseek( file, offset, SEEK_SET );
+
+ return (unsigned long)fread( buffer, 1, count, file );
+ }
+
+
+ /* documentation is in ftobjs.h */
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Stream_Open( FT_Stream stream,
+ const char* filepathname )
+ {
+ FILE* file;
+
+
+ if ( !stream )
+ return FT_Err_Invalid_Stream_Handle;
+
+ file = fopen( filepathname, "rb" );
+ if ( !file )
+ {
+ FT_ERROR(( "FT_Stream_Open:" ));
+ FT_ERROR(( " could not open `%s'\n", filepathname ));
+
+ return FT_Err_Cannot_Open_Resource;
+ }
+
+ fseek( file, 0, SEEK_END );
+ stream->size = ftell( file );
+ fseek( file, 0, SEEK_SET );
+
+ stream->descriptor.pointer = file;
+ stream->pathname.pointer = (char*)filepathname;
+ stream->pos = 0;
+
+ stream->read = ft_ansi_stream_io;
+ stream->close = ft_ansi_stream_close;
+
+ FT_TRACE1(( "FT_Stream_Open:" ));
+ FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
+ filepathname, stream->size ));
+
+ return FT_Err_Ok;
+ }
+
+
+#ifdef FT_DEBUG_MEMORY
+
+ extern FT_Int
+ ft_mem_debug_init( FT_Memory memory );
+
+ extern void
+ ft_mem_debug_done( FT_Memory memory );
+
+#endif
+
+
+ /* documentation is in ftobjs.h */
+
+ FT_EXPORT_DEF( FT_Memory )
+ FT_New_Memory( void )
+ {
+ FT_Memory memory;
+
+
+ memory = (FT_Memory)malloc( sizeof ( *memory ) );
+ if ( memory )
+ {
+ memory->user = 0;
+ memory->alloc = ft_alloc;
+ memory->realloc = ft_realloc;
+ memory->free = ft_free;
+#ifdef FT_DEBUG_MEMORY
+ ft_mem_debug_init( memory );
+#endif
+ }
+
+ return memory;
+ }
+
+
+ /* documentation is in ftobjs.h */
+
+ FT_EXPORT_DEF( void )
+ FT_Done_Memory( FT_Memory memory )
+ {
+#ifdef FT_DEBUG_MEMORY
+ ft_mem_debug_done( memory );
+#endif
+#undef free
+ memory->free( memory, memory );
+ }
+
+
+/* END */
diff --git a/nx-X11/lib/font/FreeType/fttools.c b/nx-X11/lib/font/FreeType/fttools.c
new file mode 100644
index 000000000..9251838a9
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/fttools.c
@@ -0,0 +1,201 @@
+/*
+ Copyright (c) 1997 by Mark Leisher
+ Copyright (c) 1998-2002 by Juliusz Chroboczek
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ 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
+ AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+
+/* $XFree86: xc/lib/font/FreeType/fttools.c,v 1.6 2003/06/08 15:41:13 herrb Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#ifndef FONTMODULE
+#include <ctype.h>
+#include <string.h>
+#else
+#include "Xmd.h"
+#include "Xdefs.h"
+#include "xf86_ansic.h"
+#endif
+
+#include <X11/fonts/font.h>
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_SFNT_NAMES_H
+#include FT_TRUETYPE_IDS_H
+#include "ft.h"
+
+/* backward compatibility hack */
+#if (FREETYPE_VERSION < 2001008)
+# ifndef ft_isdigit
+# define ft_isdigit isdigit
+# endif
+#endif
+
+#ifndef LSBFirst
+#define LSBFirst 0
+#define MSBFirst 1
+#endif
+
+#define LOBYTE(s,byte) ((byte)==LSBFirst?*(char*)(s):*((char*)(s)+1))
+#define HIBYTE(s,byte) ((byte)==LSBFirst?*((char*)(s)+1):*(char*)(s))
+
+int FTtoXReturnCode(int rc)
+{
+ if(rc == 0x40)
+ return AllocError;
+ /* Anything else stops the font matching mechanism */
+ else return BadFontName;
+
+}
+
+/* Convert slen bytes from UCS-2 to ISO 8859-1. Byte specifies the
+ endianness of the string, max the maximum number of bytes written into
+ to. */
+static int
+FTu2a(int slen, FT_Byte *from, char *to, int byte, int max)
+{
+ int i, n;
+
+ n = 0;
+ for (i = 0; i < slen; i += 2) {
+ if(n >= max)
+ break;
+ if(HIBYTE(from+i, byte)!=0)
+ *to++='?';
+ else
+ *to++ = LOBYTE(from+i,byte);
+ n++;
+ }
+ *to = 0;
+ return n;
+}
+
+static int
+FTGetName(FT_Face face, int nid, int pid, int eid, FT_SfntName *name_return)
+{
+ FT_SfntName name;
+ int n, i;
+
+ n = FT_Get_Sfnt_Name_Count(face);
+ if(n <= 0)
+ return 0;
+
+ for(i = 0; i < n; i++) {
+ if(FT_Get_Sfnt_Name(face, i, &name))
+ continue;
+ if(name.name_id == nid &&
+ name.platform_id == pid &&
+ (eid < 0 || name.encoding_id == eid)) {
+ switch(name.platform_id) {
+ case TT_PLATFORM_APPLE_UNICODE:
+ case TT_PLATFORM_MACINTOSH:
+ if(name.language_id != TT_MAC_LANGID_ENGLISH)
+ continue;
+ break;
+ case TT_PLATFORM_MICROSOFT:
+ if(name.language_id != TT_MS_LANGID_ENGLISH_UNITED_STATES &&
+ name.language_id != TT_MS_LANGID_ENGLISH_UNITED_KINGDOM)
+ break;
+ continue;
+ break;
+ default:
+ break;
+ }
+ *name_return = name;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
+FTGetEnglishName(FT_Face face, int nid, char *name_return, int name_len)
+{
+ FT_SfntName name;
+ int len;
+
+ if(FTGetName(face, nid,
+ TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, &name) ||
+ FTGetName(face, nid,
+ TT_PLATFORM_APPLE_UNICODE, -1, &name))
+ return FTu2a(name.string_len, name.string, name_return,
+ MSBFirst, name_len);
+
+ /* Pretend that Apple Roman is ISO 8859-1. */
+ if(FTGetName(face, nid, TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, &name)) {
+ len = name.string_len;
+ if(len > name_len)
+ len = name_len;
+ memcpy(name_return, name.string, len);
+ return len;
+ }
+
+ /* Must be some font that can only be named in Polish or something. */
+ return -1;
+}
+
+int
+FTcheckForTTCName(char *fileName, char **realFileName, int *faceNumber)
+{
+ int length;
+ int fn;
+ int i, j;
+ char *start, *realName;
+
+ length = strlen(fileName);
+ if(length < 4)
+ return 0;
+
+ if(strcasecmp(fileName + (length-4), ".ttc") != 0 &&
+ strcasecmp(fileName + (length-4), ".otc") != 0)
+ return 0;
+
+ realName = xalloc(length + 1);
+ if(realName == NULL)
+ return 0;
+
+ strcpy(realName, fileName);
+ *realFileName=realName;
+ start = strchr(realName, ':');
+ if(start) {
+ fn=0;
+ i=1;
+ while(ft_isdigit(start[i])) {
+ fn *= 10;
+ fn += start[i]-'0';
+ i++;
+ }
+ if(start[i]==':') {
+ *faceNumber = fn;
+ i++;
+ j = 0;
+ while(start[i]) {
+ start[j++] = start[i++];
+ }
+ start[j] = '\0';
+ return 1;
+ }
+ }
+
+ *faceNumber = 0;
+ return 1;
+}
diff --git a/nx-X11/lib/font/FreeType/module/Imakefile b/nx-X11/lib/font/FreeType/module/Imakefile
new file mode 100644
index 000000000..855220b1e
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/module/Imakefile
@@ -0,0 +1,111 @@
+XCOMM $XFree86: xc/lib/font/FreeType/module/Imakefile,v 1.16 2003/11/05 16:58:35 tsi Exp $
+
+FT2INCDIR = $(TOP)/extras/freetype2/include
+FT2SOURCEDIR = $(TOP)/extras/freetype2/src
+
+/*#define BuildFreetypeDlModule NO*/
+
+#if !defined(BuildFreetypeDlModule)
+# define BuildFreetypeDlModule (HasFreetype2 && HasDlopen)
+#endif
+
+#if !BuildFreetypeDlModule
+EXTRADEFINES = Freetype2BuildDefines -DFONTMODULE
+# else
+# undef MakeDllModules
+# define MakeDllModules YES
+#endif
+
+
+
+DEFINES = $(EXTRADEFINES) -DXFREE86_FT2 $(INTERNALDEFINES)
+#define IHaveModules
+#include <Server.tmpl>
+
+
+#if BuildFreetypeDlModule
+
+FT2INCLUDES = $(FREETYPE2INCLUDES)
+EXTLIB = $(FREETYPE2LIB)
+
+# if !HasFreetype2
+LINKFT2LIB = -L$(BUILDLIBDIR)
+# endif
+#else
+
+FT2INCLUDES = -I$(FT2INCDIR) \
+ -I$(FT2SOURCEDIR)/base \
+ -I$(FT2SOURCEDIR)/gzip \
+ -I$(FT2SOURCEDIR)/raster \
+ -I$(FT2SOURCEDIR)/sfnt \
+ -I$(FT2SOURCEDIR)/truetype \
+ -I$(FT2SOURCEDIR)/cff \
+ -I$(FT2SOURCEDIR)/type1 \
+ -I$(FT2SOURCEDIR)/psaux \
+ -I$(FT2SOURCEDIR)/psnames \
+ -I$(FT2SOURCEDIR)/pshinter \
+ -I$(FT2SOURCEDIR)/autohint \
+ -I$(FT2SOURCEDIR)/bdf \
+ -I$(FT2SOURCEDIR)/pcf \
+ -I$(FT2SOURCEDIR)/lzw
+
+FT2SRCS = ftbase.c ftinit.c ftglyph.c ftbbox.c ftsystem.c fttype1.c ftxf86.c \
+ ftgzip.c raster.c sfnt.c truetype.c cff.c type1.c \
+ psaux.c psnames.c pshinter.c autohint.c ftlzw.c \
+ ftbdf.c bdf.c pcf.c
+FT2OBJS = ftbase.o ftinit.o ftglyph.o ftbbox.o ftsystem.o fttype1.o ftxf86.o \
+ ftgzip.o raster.o sfnt.o truetype.o cff.o type1.o \
+ psaux.o psnames.o pshinter.o autohint.o ftlzw.o \
+ ftbdf.o bdf.o pcf.o
+#endif
+
+INCLUDES = -I. -I.. -I$(FONTINCSRC) -I../../include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/include $(FT2INCLUDES) -I$(INCLUDESRC)
+
+SRCS = xttcap.c ftfuncs.c ftenc.c fttools.c $(FT2SRCS) ftmodule.c
+OBJS = xttcap.o ftfuncs.o ftenc.o fttools.o $(FT2OBJS) ftmodule.o
+
+LinkSourceFile(ftenc.c,..)
+LinkSourceFile(ftfuncs.c,..)
+LinkSourceFile(fttools.c,..)
+LinkSourceFile(xttcap.c,..)
+
+#if !BuildFreetypeDlModule
+LinkSourceFile(ftbase.c,$(FT2SOURCEDIR)/base)
+LinkSourceFile(ftinit.c,$(FT2SOURCEDIR)/base)
+LinkSourceFile(ftglyph.c,$(FT2SOURCEDIR)/base)
+LinkSourceFile(ftbbox.c,$(FT2SOURCEDIR)/base)
+LinkSourceFile(ftsystem.c,..)
+LinkSourceFile(ftutil.c,$(FT2SOURCEDIR)/base)
+LinkSourceFile(fttype1.c,$(FT2SOURCEDIR)/base)
+LinkSourceFile(ftxf86.c,$(FT2SOURCEDIR)/base)
+LinkSourceFile(ftgzip.c,$(FT2SOURCEDIR)/gzip)
+LinkSourceFile(raster.c,$(FT2SOURCEDIR)/raster)
+LinkSourceFile(sfnt.c,$(FT2SOURCEDIR)/sfnt)
+LinkSourceFile(truetype.c,$(FT2SOURCEDIR)/truetype)
+LinkSourceFile(cff.c,$(FT2SOURCEDIR)/cff)
+LinkSourceFile(type1.c,$(FT2SOURCEDIR)/type1)
+LinkSourceFile(psaux.c,$(FT2SOURCEDIR)/psaux)
+LinkSourceFile(psnames.c,$(FT2SOURCEDIR)/psnames)
+LinkSourceFile(pshinter.c,$(FT2SOURCEDIR)/pshinter)
+LinkSourceFile(autohint.c,$(FT2SOURCEDIR)/autohint)
+LinkSourceFile(ftbdf.c,$(FT2SOURCEDIR)/base)
+LinkSourceFile(bdf.c,$(FT2SOURCEDIR)/bdf)
+LinkSourceFile(pcf.c,$(FT2SOURCEDIR)/pcf)
+LinkSourceFile(ftlzw.c,$(FT2SOURCEDIR)/lzw)
+#endif
+
+ModuleObjectRule()
+
+#if !BuildFreetypeDlModule
+LibraryModuleTarget(freetype,$(OBJS))
+InstallLibraryModule(freetype,$(MODULEDIR),fonts)
+InstallDriverSDKLibraryModule(freetype,$(DRIVERSDKMODULEDIR),fonts)
+#else
+DepDynamicModuleTarget(Concat3(lib,freetype,.so), $(OBJS), $(LINKFT2LIB) $(OBJS) $(EXTLIB))
+InstallDynamicModule(Concat3(lib,freetype,.so),$(MODULEDIR),fonts)
+InstallDriverSDKDynamicModule(Concat3(lib,freetype,.so),$(DRIVERSDKMODULEDIR),fonts)
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/font/FreeType/module/ft2build.h b/nx-X11/lib/font/FreeType/module/ft2build.h
new file mode 100644
index 000000000..83b9d4802
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/module/ft2build.h
@@ -0,0 +1,45 @@
+/***************************************************************************/
+/* */
+/* ft2build.h */
+/* */
+/* FreeType 2 build and setup macros. */
+/* */
+/* Copyright 1996-2001 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* Modified for XFree86. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+/* $XFree86: xc/lib/font/FreeType/ft2build.h,v 1.3 2002/10/01 00:02:10 alanh Exp $ */
+
+/* $XdotOrg: xc/lib/font/FreeType/module/ft2build.h,v 1.3 2005/07/03 07:00:58 daniels Exp $ */
+ /*************************************************************************/
+ /* */
+ /* This file corresponds to the default "ft2build.h" file for */
+ /* FreeType 2. It uses the "freetype" include root. */
+ /* */
+ /* Note that specific platforms might use a different configuration. */
+ /* See builds/unix/ft2unix.h for an example. */
+ /* */
+ /*************************************************************************/
+
+#ifndef __FT2_BUILD_GENERIC_H__
+#define __FT2_BUILD_GENERIC_H__
+
+# if defined (FONTMODULE)
+# include "ftheader.h"
+# else
+#include <freetype/config/ftheader.h>
+# endif
+
+#endif /* __FT2_BUILD_GENERIC_H__ */
+
+
+/* END */
diff --git a/nx-X11/lib/font/FreeType/module/ftheader.h b/nx-X11/lib/font/FreeType/module/ftheader.h
new file mode 100644
index 000000000..ec1671c41
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/module/ftheader.h
@@ -0,0 +1,550 @@
+/***************************************************************************/
+/* */
+/* ftheader.h */
+/* */
+/* Build macros of the FreeType 2 library. */
+/* */
+/* Copyright 1996-2001, 2002 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+/* $XFree86: xc/lib/font/FreeType/ftheader.h,v 1.4 2003/05/29 03:05:08 dawes Exp $ */
+
+#ifndef __FT_HEADER_H__
+#define __FT_HEADER_H__
+
+ /*@***********************************************************************/
+ /* */
+ /* <Macro> */
+ /* FT_BEGIN_HEADER */
+ /* */
+ /* <Description> */
+ /* This macro is used in association with @FT_END_HEADER in header */
+ /* files to ensure that the declarations within are properly */
+ /* encapsulated in an `extern "C" { .. }' block when included from a */
+ /* C++ compiler. */
+ /* */
+#ifdef __cplusplus
+#define FT_BEGIN_HEADER extern "C" {
+#else
+#define FT_BEGIN_HEADER /* nothing */
+#endif
+
+
+ /*@***********************************************************************/
+ /* */
+ /* <Macro> */
+ /* FT_END_HEADER */
+ /* */
+ /* <Description> */
+ /* This macro is used in association with @FT_BEGIN_HEADER in header */
+ /* files to ensure that the declarations within are properly */
+ /* encapsulated in an `extern "C" { .. }' block when included from a */
+ /* C++ compiler. */
+ /* */
+#ifdef __cplusplus
+#define FT_END_HEADER }
+#else
+#define FT_END_HEADER /* nothing */
+#endif
+
+
+ /*************************************************************************/
+ /* */
+ /* Aliases for the FreeType 2 public and configuration files. */
+ /* */
+ /*************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* <Section> */
+ /* header_file_macros */
+ /* */
+ /* <Title> */
+ /* Header File Macros */
+ /* */
+ /* <Abstract> */
+ /* Macro definitions used to #include specific header files. */
+ /* */
+ /* <Description> */
+ /* The following macros are defined to the name of specific */
+ /* FreeType 2 header files. They can be used directly in #include */
+ /* statements as in: */
+ /* */
+ /* { */
+ /* #include FT_FREETYPE_H */
+ /* #include FT_MULTIPLE_MASTERS_H */
+ /* #include FT_GLYPH_H */
+ /* } */
+ /* */
+ /* There are several reasons why we are now using macros to name */
+ /* public header files. The first one is that such macros are not */
+ /* limited to the infamous 8.3 naming rule required by DOS (and */
+ /* `FT_MULTIPLE_MASTERS_H' is a lot more meaningful than `ftmm.h'). */
+ /* */
+ /* The second reason is that is allows for more flexibility in the */
+ /* way FreeType 2 is installed on a given system. */
+ /* */
+ /*************************************************************************/
+
+ /* configuration files */
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_CONFIG_CONFIG_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* FreeType 2 configuration data. */
+ /* */
+#ifndef FT_CONFIG_CONFIG_H
+#define FT_CONFIG_CONFIG_H <freetype/config/ftconfig.h>
+#endif
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_CONFIG_STANDARD_LIBRARY_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* FreeType 2 configuration data. */
+ /* */
+#ifndef FT_CONFIG_STANDARD_LIBRARY_H
+#define FT_CONFIG_STANDARD_LIBRARY_H <myftstdlib.h>
+#endif
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_CONFIG_OPTIONS_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* FreeType 2 project-specific configuration options. */
+ /* */
+#ifndef FT_CONFIG_OPTIONS_H
+#define FT_CONFIG_OPTIONS_H <ftoption.h>
+#endif
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_CONFIG_MODULES_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the list of FreeType 2 modules that are statically linked to new */
+ /* library instances in @FT_Init_FreeType. */
+ /* */
+#ifndef FT_CONFIG_MODULES_H
+#define FT_CONFIG_MODULES_H <ftmodule.h>
+#endif
+
+ /* public headers */
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_FREETYPE_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the base FreeType 2 API. */
+ /* */
+#define FT_FREETYPE_H <freetype/freetype.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_ERRORS_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the list of FreeType 2 error codes (and messages). */
+ /* */
+ /* It is included by @FT_FREETYPE_H. */
+ /* */
+#define FT_ERRORS_H <freetype/fterrors.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_MODULE_ERRORS_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the list of FreeType 2 module error offsets (and messages). */
+ /* */
+#define FT_MODULE_ERRORS_H <freetype/ftmoderr.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_SYSTEM_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the FreeType 2 interface to low-level operations (i.e. memory */
+ /* management and stream i/o). */
+ /* */
+ /* It is included by @FT_FREETYPE_H. */
+ /* */
+#define FT_SYSTEM_H <freetype/ftsystem.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_IMAGE_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* types definitions related to glyph images (i.e. bitmaps, outlines, */
+ /* scan-converter parameters). */
+ /* */
+ /* It is included by @FT_FREETYPE_H. */
+ /* */
+#define FT_IMAGE_H <freetype/ftimage.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_TYPES_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the basic data types defined by FreeType 2. */
+ /* */
+ /* It is included by @FT_FREETYPE_H. */
+ /* */
+#define FT_TYPES_H <fttypes.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_LIST_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the list management API of FreeType 2. */
+ /* */
+ /* (Most applications will never need to include this file.) */
+ /* */
+#define FT_LIST_H <freetype/ftlist.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_OUTLINE_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the scalable outline management API of FreeType 2. */
+ /* */
+#define FT_OUTLINE_H <freetype/ftoutln.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_SIZES_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the API used to manage multiple @FT_Size objects per face. */
+ /* */
+#define FT_SIZES_H <freetype/ftsizes.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_MODULE_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the module management API of FreeType 2. */
+ /* */
+#define FT_MODULE_H <freetype/ftmodapi.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_RENDER_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the renderer module management API of FreeType 2. */
+ /* */
+#define FT_RENDER_H <freetype/ftrender.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_TYPE1_TABLES_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the types and API specific to the Type 1 format. */
+ /* */
+#define FT_TYPE1_TABLES_H <freetype/t1tables.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_TRUETYPE_IDS_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the enumeration values used to identify name strings, languages, */
+ /* encodings, etc. This file really contains a _large_ set of */
+ /* constant macro definitions, taken from the TrueType and OpenType */
+ /* specifications. */
+ /* */
+#define FT_TRUETYPE_IDS_H <freetype/ttnameid.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_TRUETYPE_TABLES_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the types and API specific to the TrueType (as well as OpenType) */
+ /* format. */
+ /* */
+#define FT_TRUETYPE_TABLES_H <freetype/tttables.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_TRUETYPE_TAGS_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the definitions of TrueType 4-byte `tags' used to identify blocks */
+ /* in SFNT-based font formats (i.e. TrueType and OpenType). */
+ /* */
+#define FT_TRUETYPE_TAGS_H <freetype/tttags.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_BDF_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the definitions of an API to access BDF-specific strings from a */
+ /* face. */
+ /* */
+#define FT_BDF_H <freetype/ftbdf.h>
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_GZIP_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the definitions of an API to support for gzip-compressed files. */
+ /* */
+#define FT_GZIP_H <freetype/ftgzip.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_LZW_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the definitions of an API to support for LZW-compressed files. */
+ /* */
+#define FT_LZW_H <freetype/ftlzw.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_WINFONTS_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the definitions of an API to support Windows .FNT files */
+ /* */
+#define FT_WINFONTS_H <freetype/ftwinfnt.h>
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_GLYPH_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the API of the optional glyph management component. */
+ /* */
+#define FT_GLYPH_H <freetype/ftglyph.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_BBOX_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the API of the optional exact bounding box computation routines. */
+ /* */
+#define FT_BBOX_H <freetype/ftbbox.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_CACHE_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the API of the optional FreeType 2 cache sub-system. */
+ /* */
+#define FT_CACHE_H <freetype/ftcache.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_CACHE_IMAGE_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the `glyph image' API of the FreeType 2 cache sub-system. */
+ /* */
+ /* It is used to define a cache for @FT_Glyph elements. You can also */
+ /* see the API defined in @FT_CACHE_SMALL_BITMAPS_H if you only need */
+ /* to store small glyph bitmaps, as it will use less memory. */
+ /* */
+#define FT_CACHE_IMAGE_H <freetype/cache/ftcimage.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_CACHE_SMALL_BITMAPS_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the `small bitmaps' API of the FreeType 2 cache sub-system. */
+ /* */
+ /* It is used to define a cache for small glyph bitmaps in a */
+ /* relatively memory-efficient way. You can also use the API defined */
+ /* in @FT_CACHE_IMAGE_H if you want to cache arbitrary glyph images, */
+ /* including scalable outlines. */
+ /* */
+#define FT_CACHE_SMALL_BITMAPS_H <freetype/cache/ftcsbits.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_CACHE_CHARMAP_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the `charmap' API of the FreeType 2 cache sub-system. */
+ /* */
+#define FT_CACHE_CHARMAP_H <freetype/cache/ftccmap.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_MAC_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the Macintosh-specific FreeType 2 API. The latter is used to */
+ /* access fonts embedded in resource forks. */
+ /* */
+ /* This header file must be explicitly included by client */
+ /* applications compiled on the Mac (note that the base API still */
+ /* works though). */
+ /* */
+#define FT_MAC_H <freetype/ftmac.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_MULTIPLE_MASTERS_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the optional multiple-masters management API of FreeType 2. */
+ /* */
+#define FT_MULTIPLE_MASTERS_H <freetype/ftmm.h>
+
+
+ /*************************************************************************/
+ /* */
+ /* @macro: */
+ /* FT_SFNT_NAMES_H */
+ /* */
+ /* @description: */
+ /* A macro used in #include statements to name the file containing */
+ /* the optional FreeType 2 API used to access embedded `name' strings */
+ /* in SFNT-based font formats (i.e. TrueType and OpenType). */
+ /* */
+#define FT_SFNT_NAMES_H <freetype/ftsnames.h>
+
+ /* */
+
+#define FT_TRIGONOMETRY_H <freetype/fttrigon.h>
+#define FT_STROKER_H <freetype/ftstroke.h>
+#define FT_SYNTHESIS_H <freetype/ftsynth.h>
+#define FT_ERROR_DEFINITIONS_H <freetype/fterrdef.h>
+
+#define FT_CACHE_MANAGER_H <freetype/cache/ftcmanag.h>
+
+#define FT_CACHE_INTERNAL_LRU_H <freetype/cache/ftlru.h>
+#define FT_CACHE_INTERNAL_GLYPH_H <freetype/cache/ftcglyph.h>
+#define FT_CACHE_INTERNAL_CACHE_H <freetype/cache/ftccache.h>
+
+#define FT_XFREE86_H <freetype/ftxf86.h>
+
+#define FT_INCREMENTAL_H <freetype/ftincrem.h>
+
+#define FT_TRUETYPE_UNPATENTED_H <freetype/ttunpat.h>
+
+ /* now include internal headers definitions from <freetype/internal/...> */
+
+#define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h>
+#include FT_INTERNAL_INTERNAL_H
+
+
+#endif /* __FT2_BUILD_H__ */
+
+
+/* END */
diff --git a/nx-X11/lib/font/FreeType/module/ftmodule.c b/nx-X11/lib/font/FreeType/module/ftmodule.c
new file mode 100644
index 000000000..c2fe79089
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/module/ftmodule.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 1998-2002 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+/* $XFree86: xc/lib/font/FreeType/module/ftmodule.c,v 1.18 2003/11/02 04:30:57 dawes Exp $ */
+
+#include "misc.h"
+
+#include <X11/fonts/fontmod.h>
+#include "xf86Module.h"
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+static MODULESETUPPROTO(freetypeSetup);
+
+ /*
+ * This is the module data function that is accessed when loading
+ * libfreetype as a module.
+ */
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "freetype",
+ MODULEVENDORSTRING " & the After X-TT Project",
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 2, 1, 0,
+ ABI_CLASS_FONT, /* Font module */
+ ABI_FONT_VERSION,
+ MOD_CLASS_FONT,
+ {0,0,0,0} /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData freetypeModuleData = { &VersRec, freetypeSetup, NULL };
+
+extern void FreeTypeRegisterFontFileFunctions(void);
+
+FontModule freetypeModule = {
+ FreeTypeRegisterFontFileFunctions,
+ "FreeType",
+ NULL
+};
+
+static pointer
+freetypeSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ freetypeModule.module = module;
+ LoadFont(&freetypeModule);
+
+ /* Need a non-NULL return */
+ return (pointer)1;
+}
diff --git a/nx-X11/lib/font/FreeType/module/ftmodule.h b/nx-X11/lib/font/FreeType/module/ftmodule.h
new file mode 100644
index 000000000..443c97c29
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/module/ftmodule.h
@@ -0,0 +1,21 @@
+/* $XFree86: xc/lib/font/FreeType/ftmodule.h,v 1.5 2003/10/24 16:33:08 tsi Exp $ */
+
+FT_USE_MODULE(autohint_module_class)
+FT_USE_MODULE(cff_driver_class)
+/* FT_USE_MODULE(t1cid_driver_class) */
+FT_USE_MODULE(pcf_driver_class)
+FT_USE_MODULE(bdf_driver_class)
+FT_USE_MODULE(psaux_module_class)
+FT_USE_MODULE(psnames_module_class)
+FT_USE_MODULE(pshinter_module_class)
+FT_USE_MODULE(ft_raster1_renderer_class)
+FT_USE_MODULE(sfnt_module_class)
+/* FT_USE_MODULE(ft_smooth_renderer_class) */
+/* FT_USE_MODULE(ft_smooth_lcd_renderer_class) */
+/* FT_USE_MODULE(ft_smooth_lcdv_renderer_class) */
+FT_USE_MODULE(tt_driver_class)
+FT_USE_MODULE(t1_driver_class)
+/* FT_USE_MODULE(t42_driver_class) */
+/* FT_USE_MODULE(pfr_driver_class) */
+/* FT_USE_MODULE(winfnt_driver_class) */
+
diff --git a/nx-X11/lib/font/FreeType/module/ftoption.h b/nx-X11/lib/font/FreeType/module/ftoption.h
new file mode 100644
index 000000000..a527ec12d
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/module/ftoption.h
@@ -0,0 +1,567 @@
+/***************************************************************************/
+/* */
+/* ftoption.h */
+/* */
+/* User-selectable configuration macros (specification only). */
+/* */
+/* Copyright 1996-2001, 2002, 2003, 2004 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef __FTOPTION_H__
+#define __FTOPTION_H__
+
+
+#include <ft2build.h>
+
+
+FT_BEGIN_HEADER
+
+ /*************************************************************************/
+ /* */
+ /* USER-SELECTABLE CONFIGURATION MACROS */
+ /* */
+ /* This file contains the default configuration macro definitions for */
+ /* a standard build of the FreeType library. There are three ways to */
+ /* use this file to build project-specific versions of the library: */
+ /* */
+ /* - You can modify this file by hand, but this is not recommended in */
+ /* cases where you would like to build several versions of the */
+ /* library from a single source directory. */
+ /* */
+ /* - You can put a copy of this file in your build directory, more */
+ /* precisely in "$BUILD/freetype/config/ftoption.h", where "$BUILD" */
+ /* is the name of a directory that is included _before_ the FreeType */
+ /* include path during compilation. */
+ /* */
+ /* The default FreeType Makefiles and Jamfiles use the build */
+ /* directory "builds/<system>" by default, but you can easily change */
+ /* that for your own projects. */
+ /* */
+ /* - Copy the file <ft2build.h> to "$BUILD/ft2build.h" and modify it */
+ /* slightly to pre-define the macro FT_CONFIG_OPTIONS_H used to */
+ /* locate this file during the build. For example, */
+ /* */
+ /* #define FT_CONFIG_OPTIONS_H <myftoptions.h> */
+ /* #include <freetype/config/ftheader.h> */
+ /* */
+ /* will use "$BUILD/myftoptions.h" instead of this file for macro */
+ /* definitions. */
+ /* */
+ /* Note also that you can similarly pre-define the macro */
+ /* FT_CONFIG_MODULES_H used to locate the file listing of the modules */
+ /* that are statically linked to the library at compile time. By */
+ /* default, this file is <freetype/config/ftmodule.h>. */
+ /* */
+ /* We highly recommend using the third method whenever possible. */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** G E N E R A L F R E E T Y P E 2 C O N F I G U R A T I O N ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* Many compilers provide a non-ANSI 64-bit data type that can be used */
+ /* by FreeType to speed up some computations. However, this will create */
+ /* some problems when compiling the library in strict ANSI mode. */
+ /* */
+ /* For this reason, the use of 64-bit integers is normally disabled when */
+ /* the __STDC__ macro is defined. You can however disable this by */
+ /* defining the macro FT_CONFIG_OPTION_FORCE_INT64 here. */
+ /* */
+ /* For most compilers, this will only create compilation warnings when */
+ /* building the library. */
+ /* */
+ /* ObNote: The compiler-specific 64-bit integers are detected in the */
+ /* file "ftconfig.h" either statically or through the */
+ /* `configure' script on supported platforms. */
+ /* */
+#undef FT_CONFIG_OPTION_FORCE_INT64
+
+
+ /*************************************************************************/
+ /* */
+ /* LZW-compressed file support. */
+ /* */
+ /* FreeType now handles font files that have been compressed with the */
+ /* 'compress' program. This is mostly used to parse many of the PCF */
+ /* files that come with various X11 distributions. The implementation */
+ /* uses NetBSD's `zopen' to partially uncompress the file on the fly */
+ /* (see src/lzw/ftgzip.c). */
+ /* */
+ /* Define this macro if you want to enable this `feature'. */
+ /* */
+#define FT_CONFIG_OPTION_USE_LZW
+
+
+ /*************************************************************************/
+ /* */
+ /* Gzip-compressed file support. */
+ /* */
+ /* FreeType now handles font files that have been compressed with the */
+ /* 'gzip' program. This is mostly used to parse many of the PCF files */
+ /* that come with XFree86. The implementation uses `zlib' to */
+ /* partially uncompress the file on the fly (see src/gzip/ftgzip.c). */
+ /* */
+ /* Define this macro if you want to enable this `feature'. See also */
+ /* the macro FT_CONFIG_OPTION_SYSTEM_ZLIB below. */
+ /* */
+#define FT_CONFIG_OPTION_USE_ZLIB
+
+
+ /*************************************************************************/
+ /* */
+ /* ZLib library selection */
+ /* */
+ /* This macro is only used when FT_CONFIG_OPTION_USE_ZLIB is defined. */
+ /* It allows FreeType's `ftgzip' component to link to the system's */
+ /* installation of the ZLib library. This is useful on systems like */
+ /* Unix or VMS where it generally is already available. */
+ /* */
+ /* If you let it undefined, the component will use its own copy */
+ /* of the zlib sources instead. These have been modified to be */
+ /* included directly within the component and *not* export external */
+ /* function names. This allows you to link any program with FreeType */
+ /* _and_ ZLib without linking conflicts. */
+ /* */
+ /* Do not #undef this macro here since the build system might define */
+ /* it for certain configurations only. */
+ /* */
+/* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */
+
+
+ /*************************************************************************/
+ /* */
+ /* DLL export compilation */
+ /* */
+ /* When compiling FreeType as a DLL, some systems/compilers need a */
+ /* special keyword in front OR after the return type of function */
+ /* declarations. */
+ /* */
+ /* Two macros are used within the FreeType source code to define */
+ /* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */
+ /* */
+ /* FT_EXPORT( return_type ) */
+ /* */
+ /* is used in a function declaration, as in */
+ /* */
+ /* FT_EXPORT( FT_Error ) */
+ /* FT_Init_FreeType( FT_Library* alibrary ); */
+ /* */
+ /* */
+ /* FT_EXPORT_DEF( return_type ) */
+ /* */
+ /* is used in a function definition, as in */
+ /* */
+ /* FT_EXPORT_DEF( FT_Error ) */
+ /* FT_Init_FreeType( FT_Library* alibrary ) */
+ /* { */
+ /* ... some code ... */
+ /* return FT_Err_Ok; */
+ /* } */
+ /* */
+ /* You can provide your own implementation of FT_EXPORT and */
+ /* FT_EXPORT_DEF here if you want. If you leave them undefined, they */
+ /* will be later automatically defined as `extern return_type' to */
+ /* allow normal compilation. */
+ /* */
+ /* Do not #undef these macros here since the build system might define */
+ /* them for certain configurations only. */
+ /* */
+/* #define FT_EXPORT(x) extern x */
+/* #define FT_EXPORT_DEF(x) x */
+
+
+ /*************************************************************************/
+ /* */
+ /* Glyph Postscript Names handling */
+ /* */
+ /* By default, FreeType 2 is compiled with the `PSNames' module. This */
+ /* module is in charge of converting a glyph name string into a */
+ /* Unicode value, or return a Macintosh standard glyph name for the */
+ /* use with the TrueType `post' table. */
+ /* */
+ /* Undefine this macro if you do not want `PSNames' compiled in your */
+ /* build of FreeType. This has the following effects: */
+ /* */
+ /* - The TrueType driver will provide its own set of glyph names, */
+ /* if you build it to support postscript names in the TrueType */
+ /* `post' table. */
+ /* */
+ /* - The Type 1 driver will not be able to synthetize a Unicode */
+ /* charmap out of the glyphs found in the fonts. */
+ /* */
+ /* You would normally undefine this configuration macro when building */
+ /* a version of FreeType that doesn't contain a Type 1 or CFF driver. */
+ /* */
+#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES
+
+
+ /*************************************************************************/
+ /* */
+ /* Postscript Names to Unicode Values support */
+ /* */
+ /* By default, FreeType 2 is built with the `PSNames' module compiled */
+ /* in. Among other things, the module is used to convert a glyph name */
+ /* into a Unicode value. This is especially useful in order to */
+ /* synthetize on the fly a Unicode charmap from the CFF/Type 1 driver */
+ /* through a big table named the `Adobe Glyph List' (AGL). */
+ /* */
+ /* Undefine this macro if you do not want the Adobe Glyph List */
+ /* compiled in your `PSNames' module. The Type 1 driver will not be */
+ /* able to synthetize a Unicode charmap out of the glyphs found in the */
+ /* fonts. */
+ /* */
+#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
+
+
+ /*************************************************************************/
+ /* */
+ /* Support for Mac fonts */
+ /* */
+ /* Define this macro if you want support for outline fonts in Mac */
+ /* format (mac dfont, mac resource, macbinary containing a mac */
+ /* resource) on non-Mac platforms. */
+ /* */
+ /* Note that the `FOND' resource isn't checked. */
+ /* */
+#define FT_CONFIG_OPTION_MAC_FONTS
+
+
+ /*************************************************************************/
+ /* */
+ /* Guessing methods to access embedded resource forks */
+ /* */
+ /* Enable extra Mac fonts support on non-Mac platforms (e.g. */
+ /* GNU/Linux). */
+ /* */
+ /* Resource forks which include fonts data are stored sometimes in */
+ /* locations which users or developers don't expected. In some cases, */
+ /* resource forks start with some offset from the head of a file. In */
+ /* other cases, the actual resource fork is stored in file different */
+ /* from what the user specifies. If this option is activated, */
+ /* FreeType tries to guess whether such offsets or different file */
+ /* names must be used. */
+ /* */
+ /* Note that normal, direct access of resource forks is controlled via */
+ /* the FT_CONFIG_OPTION_MAC_FONTS option. */
+ /* */
+#ifdef FT_CONFIG_OPTION_MAC_FONTS
+#define FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
+#endif
+
+
+ /*************************************************************************/
+ /* */
+ /* Allow the use of FT_Incremental_Interface to load typefaces that */
+ /* contain no glyph data, but supply it via a callback function. */
+ /* This allows FreeType to be used with the PostScript language, using */
+ /* the GhostScript interpreter. */
+ /* */
+/* #define FT_CONFIG_OPTION_INCREMENTAL */
+
+
+ /*************************************************************************/
+ /* */
+ /* The size in bytes of the render pool used by the scan-line converter */
+ /* to do all of its work. */
+ /* */
+ /* This must be greater than 4KByte. */
+ /* */
+#define FT_RENDER_POOL_SIZE 16384L
+
+
+ /*************************************************************************/
+ /* */
+ /* FT_MAX_MODULES */
+ /* */
+ /* The maximum number of modules that can be registered in a single */
+ /* FreeType library object. 32 is the default. */
+ /* */
+#define FT_MAX_MODULES 32
+
+
+ /*************************************************************************/
+ /* */
+ /* Debug level */
+ /* */
+ /* FreeType can be compiled in debug or trace mode. In debug mode, */
+ /* errors are reported through the `ftdebug' component. In trace */
+ /* mode, additional messages are sent to the standard output during */
+ /* execution. */
+ /* */
+ /* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */
+ /* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */
+ /* */
+ /* Don't define any of these macros to compile in `release' mode! */
+ /* */
+ /* Do not #undef these macros here since the build system might define */
+ /* them for certain configurations only. */
+ /* */
+/* #define FT_DEBUG_LEVEL_ERROR */
+/* #define FT_DEBUG_LEVEL_TRACE */
+
+
+ /*************************************************************************/
+ /* */
+ /* Memory Debugging */
+ /* */
+ /* FreeType now comes with an integrated memory debugger that is */
+ /* capable of detecting simple errors like memory leaks or double */
+ /* deletes. To compile it within your build of the library, you */
+ /* should define FT_DEBUG_MEMORY here. */
+ /* */
+ /* Note that the memory debugger is only activated at runtime when */
+ /* when the _environment_ variable "FT2_DEBUG_MEMORY" is defined also! */
+ /* */
+ /* Do not #undef this macro here since the build system might define */
+ /* it for certain configurations only. */
+ /* */
+/* #define FT_DEBUG_MEMORY */
+
+
+ /*************************************************************************/
+ /* */
+ /* Module errors */
+ /* */
+ /* If this macro is set (which is _not_ the default), the higher byte */
+ /* of an error code gives the module in which the error has occurred, */
+ /* while the lower byte is the real error code. */
+ /* */
+ /* Setting this macro makes sense for debugging purposes only, since */
+ /* it would break source compatibility of certain programs that use */
+ /* FreeType 2. */
+ /* */
+ /* More details can be found in the files ftmoderr.h and fterrors.h. */
+ /* */
+#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
+
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** S F N T D R I V E R C O N F I G U R A T I O N ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* Define TT_CONFIG_OPTION_EMBEDDED_BITMAPS if you want to support */
+ /* embedded bitmaps in all formats using the SFNT module (namely */
+ /* TrueType & OpenType). */
+ /* */
+#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+
+
+ /*************************************************************************/
+ /* */
+ /* Define TT_CONFIG_OPTION_POSTSCRIPT_NAMES if you want to be able to */
+ /* load and enumerate the glyph Postscript names in a TrueType or */
+ /* OpenType file. */
+ /* */
+ /* Note that when you do not compile the `PSNames' module by undefining */
+ /* the above FT_CONFIG_OPTION_POSTSCRIPT_NAMES, the `sfnt' module will */
+ /* contain additional code used to read the PS Names table from a font. */
+ /* */
+ /* (By default, the module uses `PSNames' to extract glyph names.) */
+ /* */
+#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES
+
+
+ /*************************************************************************/
+ /* */
+ /* Define TT_CONFIG_OPTION_SFNT_NAMES if your applications need to */
+ /* access the internal name table in a SFNT-based format like TrueType */
+ /* or OpenType. The name table contains various strings used to */
+ /* describe the font, like family name, copyright, version, etc. It */
+ /* does not contain any glyph name though. */
+ /* */
+ /* Accessing SFNT names is done through the functions declared in */
+ /* `freetype/ftnames.h'. */
+ /* */
+#define TT_CONFIG_OPTION_SFNT_NAMES
+
+
+ /*************************************************************************/
+ /* */
+ /* TrueType CMap support */
+ /* */
+ /* Here you can fine-tune which TrueType CMap table format shall be */
+ /* supported. */
+#define TT_CONFIG_CMAP_FORMAT_0
+#define TT_CONFIG_CMAP_FORMAT_2
+#define TT_CONFIG_CMAP_FORMAT_4
+#define TT_CONFIG_CMAP_FORMAT_6
+#define TT_CONFIG_CMAP_FORMAT_8
+#define TT_CONFIG_CMAP_FORMAT_10
+#define TT_CONFIG_CMAP_FORMAT_12
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */
+ /* a bytecode interpreter in the TrueType driver. Note that there are */
+ /* important patent issues related to the use of the interpreter. */
+ /* */
+ /* By undefining this, you will only compile the code necessary to load */
+ /* TrueType glyphs without hinting. */
+ /* */
+ /* Do not #undef this macro here, since the build system might */
+ /* define it for certain configurations only. */
+ /* */
+/* #define TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
+
+
+ /*************************************************************************/
+ /* */
+ /* Define TT_CONFIG_OPTION_UNPATENTED_HINTING (in addition to */
+ /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER) to compile the unpatented */
+ /* work-around hinting system. Note that for the moment, the algorithm */
+ /* is only used when selected at runtime through the parameter tag */
+ /* FT_PARAM_TAG_UNPATENTED_HINTING; or when the debug hook */
+ /* FT_DEBUG_HOOK_UNPATENTED_HINTING is globally actived */
+ /* */
+#define TT_CONFIG_OPTION_UNPATENTED_HINTING
+
+
+ /*************************************************************************/
+ /* */
+ /* Define TT_CONFIG_OPTION_INTERPRETER_SWITCH to compile the TrueType */
+ /* bytecode interpreter with a huge switch statement, rather than a call */
+ /* table. This results in smaller and faster code for a number of */
+ /* architectures. */
+ /* */
+ /* Note however that on some compiler/processor combinations, undefining */
+ /* this macro will generate faster, though larger, code. */
+ /* */
+#define TT_CONFIG_OPTION_INTERPRETER_SWITCH
+
+
+ /*************************************************************************/
+ /* */
+ /* Define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED to compile the */
+ /* TrueType glyph loader to use Apple's definition of how to handle */
+ /* component offsets in composite glyphs. */
+ /* */
+ /* Apple and MS disagree on the default behavior of component offsets */
+ /* in composites. Apple says that they should be scaled by the scale */
+ /* factors in the transformation matrix (roughly, it's more complex) */
+ /* while MS says they should not. OpenType defines two bits in the */
+ /* composite flags array which can be used to disambiguate, but old */
+ /* fonts will not have them. */
+ /* */
+ /* http://partners.adobe.com/asn/developer/opentype/glyf.html */
+ /* http://fonts.apple.com/TTRefMan/RM06/Chap6glyf.html */
+ /* */
+#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** T Y P E 1 D R I V E R C O N F I G U R A T I O N ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* T1_MAX_DICT_DEPTH is the maximal depth of nest dictionaries and */
+ /* arrays in the Type 1 stream (see t1load.c). A minimum of 4 is */
+ /* required. */
+ /* */
+#define T1_MAX_DICT_DEPTH 5
+
+
+ /*************************************************************************/
+ /* */
+ /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */
+ /* calls during glyph loading. */
+ /* */
+#define T1_MAX_SUBRS_CALLS 16
+
+
+ /*************************************************************************/
+ /* */
+ /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */
+ /* minimum of 16 is required. */
+ /* */
+ /* The Chinese font MingTiEG-Medium (CNS 11643 character set) needs 256. */
+ /* */
+#define T1_MAX_CHARSTRINGS_OPERANDS 256
+
+
+ /*************************************************************************/
+ /* */
+ /* Define this configuration macro if you want to prevent the */
+ /* compilation of `t1afm', which is in charge of reading Type 1 AFM */
+ /* files into an existing face. Note that if set, the T1 driver will be */
+ /* unable to produce kerning distances. */
+ /* */
+#undef T1_CONFIG_OPTION_NO_AFM
+
+
+ /*************************************************************************/
+ /* */
+ /* Define this configuration macro if you want to prevent the */
+ /* compilation of the Multiple Masters font support in the Type 1 */
+ /* driver. */
+ /* */
+#undef T1_CONFIG_OPTION_NO_MM_SUPPORT
+
+ /* */
+
+/*
+ * The FT_CONFIG_OPTION_CHESTER_XXXX macros are used to toggle some recent
+ * improvements to the auto-hinter contributed by David Chester. They will
+ * most likely disappear completely in the next release. For now, you
+ * should always keep them defined.
+ *
+ */
+#define FT_CONFIG_OPTION_CHESTER_HINTS
+
+#ifdef FT_CONFIG_OPTION_CHESTER_HINTS
+
+#define FT_CONFIG_CHESTER_SMALL_F
+#define FT_CONFIG_CHESTER_ASCENDER
+#define FT_CONFIG_CHESTER_SERIF
+#define FT_CONFIG_CHESTER_STEM
+#define FT_CONFIG_CHESTER_BLUE_SCALE
+
+#endif /* FT_CONFIG_OPTION_CHESTER_HINTS */
+
+FT_END_HEADER
+
+
+#endif /* __FTOPTION_H__ */
+
+
+/* END */
diff --git a/nx-X11/lib/font/FreeType/module/ftstdlib.h b/nx-X11/lib/font/FreeType/module/ftstdlib.h
new file mode 100644
index 000000000..3d5b7fc76
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/module/ftstdlib.h
@@ -0,0 +1,113 @@
+/* ftstdlib.h -- modified for XFree86. */
+/* $XFree86: xc/lib/font/FreeType/ftstdlib.h,v 1.5 2003/02/22 06:00:36 dawes Exp $ */
+
+#ifndef __FTSTDLIB_H__
+#define __FTSTDLIB_H__
+
+#ifndef FONTMODULE
+
+#include <limits.h>
+
+#define FT_UINT_MAX UINT_MAX
+#define FT_ULONG_MAX ULONG_MAX
+
+#include <ctype.h>
+
+#define ft_isalnum isalnum
+#define ft_isupper isupper
+#define ft_islower islower
+#define ft_isdigit isdigit
+#define ft_isxdigit isxdigit
+
+
+#include <string.h>
+
+#define ft_strlen strlen
+#define ft_strcat strcat
+#define ft_strcmp strcmp
+#define ft_strncmp strncmp
+#define ft_memcpy memcpy
+#define ft_strcpy strcpy
+#define ft_strncpy strncpy
+#define ft_memset memset
+#define ft_memmove memmove
+#define ft_memcmp memcmp
+
+#include <stdio.h>
+
+#define ft_sprintf sprintf
+
+#include <stdlib.h>
+
+#define ft_qsort qsort
+#define ft_exit exit
+
+#define ft_atoi atoi
+
+#include <setjmp.h>
+
+#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */
+ /* jmp_buf is defined as a macro */
+ /* on certain platforms */
+
+#define ft_setjmp setjmp /* same thing here */
+#define ft_longjmp longjmp /* " */
+
+
+#else
+
+#include "Xmd.h"
+#define _XTYPEDEF_BOOL
+#include "Xdefs.h"
+#define DONT_DEFINE_WRAPPERS
+#define DEFINE_SETJMP_WRAPPERS
+#include "xf86_ansic.h"
+#undef DONT_DEFINE_WRAPPERS
+
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((xf86size_t)&((TYPE*)0)->MEMBER)
+#endif
+
+#define FT_UINT_MAX 4294967295U
+#ifdef LONG64
+#define FT_ULONG_MAX 18446744073709551615UL
+#else
+#define FT_ULONG_MAX 4294967295UL
+#endif
+
+#define ft_isalnum xf86isalnum
+#define ft_isupper xf86isupper
+#define ft_islower xf86islower
+#define ft_xdigit xf86isxdigit
+
+#define ft_strlen xf86strlen
+#define ft_strcmp xf86strcmp
+#define ft_strncmp xf86strncmp
+#define ft_memcpy xf86memcpy
+#define ft_strcpy xf86strcpy
+#define ft_strncpy xf86strncpy
+#define ft_memset xf86memset
+#define ft_memmove xf86memmove
+#define ft_memcmp xf86memcmp
+
+#define ft_sprintf xf86sprintf
+
+#define ft_qsort xf86qsort
+#define ft_exit xf86exit
+
+#define ft_atoi xf86atoi
+
+#define ft_jmp_buf jmp_buf
+#define ft_setjmp setjmp
+#define ft_longjmp longjmp
+
+#endif /* FONTMODULE */
+
+
+#include <stdarg.h>
+
+
+#endif /* __FTSTDLIB_H__ */
+
+
+/* END */
diff --git a/nx-X11/lib/font/FreeType/module/fttypes.h b/nx-X11/lib/font/FreeType/module/fttypes.h
new file mode 100644
index 000000000..82bb273e4
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/module/fttypes.h
@@ -0,0 +1,571 @@
+/***************************************************************************/
+/* */
+/* fttypes.h */
+/* */
+/* FreeType simple types definitions (specification only). */
+/* */
+/* Copyright 1996-2001 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* Modified for XFree86. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+/* $XFree86: xc/lib/font/FreeType/fttypes.h,v 1.4 2003/05/29 03:05:08 dawes Exp $ */
+
+#ifndef __FTTYPES_H__
+#define __FTTYPES_H__
+
+
+#include <ft2build.h>
+#include FT_CONFIG_CONFIG_H
+#include FT_SYSTEM_H
+#include FT_IMAGE_H
+
+#ifndef FONTMODULE
+#include <stddef.h>
+#else
+#include "Xmd.h"
+#define _XTYPEDEF_BOOL
+#include "Xdefs.h"
+#include "xf86_ansic.h"
+#ifndef size_t
+#define DONT_DEFINE_WRAPPERS
+#define size_t xf86size_t
+#undef DONT_DEFINE_WRAPPERS
+#endif
+#endif
+
+FT_BEGIN_HEADER
+
+
+ /*************************************************************************/
+ /* */
+ /* <Section> */
+ /* basic_types */
+ /* */
+ /* <Title> */
+ /* Basic Data Types */
+ /* */
+ /* <Abstract> */
+ /* The basic data types defined by the library. */
+ /* */
+ /* <Description> */
+ /* This section contains the basic data types defined by FreeType 2, */
+ /* ranging from simple scalar types to bitmap descriptors. More */
+ /* font-specific structures are defined in a different section. */
+ /* */
+ /* <Order> */
+ /* FT_Byte */
+ /* FT_Char */
+ /* FT_Int */
+ /* FT_UInt */
+ /* FT_Short */
+ /* FT_UShort */
+ /* FT_Long */
+ /* FT_ULong */
+ /* FT_Bool */
+ /* FT_Offset */
+ /* FT_PtrDist */
+ /* FT_String */
+ /* FT_Error */
+ /* FT_Fixed */
+ /* FT_Pointer */
+ /* FT_Pos */
+ /* FT_Vector */
+ /* FT_BBox */
+ /* FT_Matrix */
+ /* FT_FWord */
+ /* FT_UFWord */
+ /* FT_F2Dot14 */
+ /* FT_UnitVector */
+ /* FT_F26Dot6 */
+ /* */
+ /* */
+ /* FT_Generic */
+ /* FT_Generic_Finalizer */
+ /* */
+ /* FT_Bitmap */
+ /* FT_Pixel_Mode */
+ /* FT_Palette_Mode */
+ /* FT_Glyph_Format */
+ /* FT_IMAGE_TAG */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Bool */
+ /* */
+ /* <Description> */
+ /* A typedef of unsigned char, used for simple booleans. */
+ /* */
+ typedef unsigned char FT_Bool;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_FWord */
+ /* */
+ /* <Description> */
+ /* A signed 16-bit integer used to store a distance in original font */
+ /* units. */
+ /* */
+ typedef signed short FT_FWord; /* distance in FUnits */
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_UFWord */
+ /* */
+ /* <Description> */
+ /* An unsigned 16-bit integer used to store a distance in original */
+ /* font units. */
+ /* */
+ typedef unsigned short FT_UFWord; /* unsigned distance */
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Char */
+ /* */
+ /* <Description> */
+ /* A simple typedef for the _signed_ char type. */
+ /* */
+ typedef signed char FT_Char;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Byte */
+ /* */
+ /* <Description> */
+ /* A simple typedef for the _unsigned_ char type. */
+ /* */
+ typedef unsigned char FT_Byte;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_String */
+ /* */
+ /* <Description> */
+ /* A simple typedef for the char type, usually used for strings. */
+ /* */
+ typedef char FT_String;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Short */
+ /* */
+ /* <Description> */
+ /* A typedef for signed short. */
+ /* */
+ typedef signed short FT_Short;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_UShort */
+ /* */
+ /* <Description> */
+ /* A typedef for unsigned short. */
+ /* */
+ typedef unsigned short FT_UShort;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Int */
+ /* */
+ /* <Description> */
+ /* A typedef for the int type. */
+ /* */
+ typedef int FT_Int;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_UInt */
+ /* */
+ /* <Description> */
+ /* A typedef for the unsigned int type. */
+ /* */
+ typedef unsigned int FT_UInt;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Long */
+ /* */
+ /* <Description> */
+ /* A typedef for signed long. */
+ /* */
+ typedef signed long FT_Long;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_ULong */
+ /* */
+ /* <Description> */
+ /* A typedef for unsigned long. */
+ /* */
+ typedef unsigned long FT_ULong;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_F2Dot14 */
+ /* */
+ /* <Description> */
+ /* A signed 2.14 fixed float type used for unit vectors. */
+ /* */
+ typedef signed short FT_F2Dot14;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_F26Dot6 */
+ /* */
+ /* <Description> */
+ /* A signed 26.6 fixed float type used for vectorial pixel */
+ /* coordinates. */
+ /* */
+ typedef signed long FT_F26Dot6;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Fixed */
+ /* */
+ /* <Description> */
+ /* This type is used to store 16.16 fixed float values, like scales */
+ /* or matrix coefficients. */
+ /* */
+ typedef signed long FT_Fixed;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Error */
+ /* */
+ /* <Description> */
+ /* The FreeType error code type. A value of 0 is always interpreted */
+ /* as a successful operation. */
+ /* */
+ typedef int FT_Error;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Pointer */
+ /* */
+ /* <Description> */
+ /* A simple typedef for a typeless pointer. */
+ /* */
+ typedef void* FT_Pointer;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Offset */
+ /* */
+ /* <Description> */
+ /* This is equivalent to the ANSI C `size_t' type, i.e. the largest */
+ /* _unsigned_ integer type used to express a file size or position, */
+ /* or a memory block size. */
+ /* */
+ typedef size_t FT_Offset;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_PtrDist */
+ /* */
+ /* <Description> */
+ /* This is equivalent to the ANSI C `ptrdiff_t' type, i.e. the */
+ /* largest _signed_ integer type used to express the distance */
+ /* between two pointers. */
+ /* */
+ typedef size_t FT_PtrDist;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_UnitVector */
+ /* */
+ /* <Description> */
+ /* A simple structure used to store a 2D vector unit vector. Uses */
+ /* FT_F2Dot14 types. */
+ /* */
+ /* <Fields> */
+ /* x :: Horizontal coordinate. */
+ /* */
+ /* y :: Vertical coordinate. */
+ /* */
+ typedef struct FT_UnitVector_
+ {
+ FT_F2Dot14 x;
+ FT_F2Dot14 y;
+
+ } FT_UnitVector;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_Matrix */
+ /* */
+ /* <Description> */
+ /* A simple structure used to store a 2x2 matrix. Coefficients are */
+ /* in 16.16 fixed float format. The computation performed is: */
+ /* */
+ /* { */
+ /* x' = x*xx + y*xy */
+ /* y' = x*yx + y*yy */
+ /* } */
+ /* */
+ /* <Fields> */
+ /* xx :: Matrix coefficient. */
+ /* */
+ /* xy :: Matrix coefficient. */
+ /* */
+ /* yx :: Matrix coefficient. */
+ /* */
+ /* yy :: Matrix coefficient. */
+ /* */
+ typedef struct FT_Matrix_
+ {
+ FT_Fixed xx, xy;
+ FT_Fixed yx, yy;
+
+ } FT_Matrix;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_Data */
+ /* */
+ /* <Description> */
+ /* Read-only binary data represented as a pointer and a length. */
+ /* */
+ /* <Fields> */
+ /* pointer :: The data. */
+ /* */
+ /* length :: The length of the data in bytes. */
+ /* */
+ typedef struct FT_Data_
+ {
+ const FT_Byte* pointer;
+ FT_Int length;
+
+ } FT_Data;
+
+
+ /*************************************************************************/
+ /* */
+ /* <FuncType> */
+ /* FT_Generic_Finalizer */
+ /* */
+ /* <Description> */
+ /* Describes a function used to destroy the `client' data of any */
+ /* FreeType object. See the description of the FT_Generic type for */
+ /* details of usage. */
+ /* */
+ /* <Input> */
+ /* The address of the FreeType object which is under finalization. */
+ /* Its client data is accessed through its `generic' field. */
+ /* */
+ typedef void (*FT_Generic_Finalizer)(void* object);
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_Generic */
+ /* */
+ /* <Description> */
+ /* Client applications often need to associate their own data to a */
+ /* variety of FreeType core objects. For example, a text layout API */
+ /* might want to associate a glyph cache to a given size object. */
+ /* */
+ /* Most FreeType object contains a `generic' field, of type */
+ /* FT_Generic, which usage is left to client applications and font */
+ /* servers. */
+ /* */
+ /* It can be used to store a pointer to client-specific data, as well */
+ /* as the address of a `finalizer' function, which will be called by */
+ /* FreeType when the object is destroyed (for example, the previous */
+ /* client example would put the address of the glyph cache destructor */
+ /* in the `finalizer' field). */
+ /* */
+ /* <Fields> */
+ /* data :: A typeless pointer to any client-specified data. This */
+ /* field is completely ignored by the FreeType library. */
+ /* */
+ /* finalizer :: A pointer to a `generic finalizer' function, which */
+ /* will be called when the object is destroyed. If this */
+ /* field is set to NULL, no code will be called. */
+ /* */
+ typedef struct FT_Generic_
+ {
+ void* data;
+ FT_Generic_Finalizer finalizer;
+
+ } FT_Generic;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Macro> */
+ /* FT_MAKE_TAG */
+ /* */
+ /* <Description> */
+ /* This macro converts four letter tags which are used to label */
+ /* TrueType tables into an unsigned long to be used within FreeType. */
+ /* */
+ /* <Note> */
+ /* The produced values *must* be 32bit integers. Don't redefine this */
+ /* macro. */
+ /* */
+#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
+ ( ( (FT_ULong)_x1 << 24 ) | \
+ ( (FT_ULong)_x2 << 16 ) | \
+ ( (FT_ULong)_x3 << 8 ) | \
+ (FT_ULong)_x4 )
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* L I S T M A N A G E M E N T */
+ /* */
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Section> */
+ /* list_processing */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_ListNode */
+ /* */
+ /* <Description> */
+ /* Many elements and objects in FreeType are listed through a */
+ /* FT_List record (see FT_ListRec). As its name suggests, a */
+ /* FT_ListNode is a handle to a single list element. */
+ /* */
+ typedef struct FT_ListNodeRec_* FT_ListNode;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_List */
+ /* */
+ /* <Description> */
+ /* A handle to a list record (see FT_ListRec). */
+ /* */
+ typedef struct FT_ListRec_* FT_List;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_ListNodeRec */
+ /* */
+ /* <Description> */
+ /* A structure used to hold a single list element. */
+ /* */
+ /* <Fields> */
+ /* prev :: The previous element in the list. NULL if first. */
+ /* */
+ /* next :: The next element in the list. NULL if last. */
+ /* */
+ /* data :: A typeless pointer to the listed object. */
+ /* */
+ typedef struct FT_ListNodeRec_
+ {
+ FT_ListNode prev;
+ FT_ListNode next;
+ void* data;
+
+ } FT_ListNodeRec;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_ListRec */
+ /* */
+ /* <Description> */
+ /* A structure used to hold a simple doubly-linked list. These are */
+ /* used in many parts of FreeType. */
+ /* */
+ /* <Fields> */
+ /* head :: The head (first element) of doubly-linked list. */
+ /* */
+ /* tail :: The tail (last element) of doubly-linked list. */
+ /* */
+ typedef struct FT_ListRec_
+ {
+ FT_ListNode head;
+ FT_ListNode tail;
+
+ } FT_ListRec;
+
+
+ /* */
+
+#define FT_IS_EMPTY( list ) ( (list).head == 0 )
+
+ /* return base error code (without module-specific prefix) */
+#define FT_ERROR_BASE( x ) ( (x) & 0xFF )
+
+ /* return module error code */
+#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U )
+
+#define FT_BOOL( x ) ( (FT_Bool)( x ) )
+
+FT_END_HEADER
+
+#endif /* __FTTYPES_H__ */
+
+
+/* END */
diff --git a/nx-X11/lib/font/FreeType/module/myftstdlib.h b/nx-X11/lib/font/FreeType/module/myftstdlib.h
new file mode 100644
index 000000000..dc9f8658f
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/module/myftstdlib.h
@@ -0,0 +1,82 @@
+/* ftstdlib.h -- modified for XFree86. */
+/* $XFree86: xc/lib/font/FreeType/ftstdlib.h,v 1.5 2003/02/22 06:00:36 dawes Exp $ */
+#ifndef __MYFTSTDLIB_H__
+#define __MYFTSTDLIB_H__
+
+
+#ifndef FONTMODULE
+
+# include <ftstdlib.h>
+# ifndef ft_isdigit
+# define ft_isdigit isdigit
+# endif
+
+#else
+
+#ifndef __FTSTDLIB_H__
+#define __FTSTDLIB_H__
+/* we don't include limits.h */
+#define CHAR_BIT 8
+
+#include "Xmd.h"
+#define _XTYPEDEF_BOOL
+#include "Xdefs.h"
+#define DONT_DEFINE_WRAPPERS
+#define DEFINE_SETJMP_WRAPPERS
+#include "xf86_ansic.h"
+#undef DONT_DEFINE_WRAPPERS
+
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((xf86size_t)&((TYPE*)0)->MEMBER)
+#endif
+
+#define FT_UINT_MAX 4294967295U
+#ifdef LONG64
+#define FT_ULONG_MAX 18446744073709551615UL
+#else
+#define FT_ULONG_MAX 4294967295UL
+#endif
+
+#define ft_isalnum xf86isalnum
+#define ft_isupper xf86isupper
+#define ft_islower xf86islower
+#define ft_isxdigit xf86isxdigit
+/* works around a bug in freetype 2.1.8 */
+#ifndef isdigit
+#define isdigit xf86isdigit
+#endif
+#define ft_isdigit xf86isdigit
+
+#define ft_strlen xf86strlen
+#define ft_strcat xf86strcat
+#define ft_strrchr xf86strrchr
+#define ft_strcmp xf86strcmp
+#define ft_strncmp xf86strncmp
+#define ft_memcpy xf86memcpy
+#define ft_strcpy xf86strcpy
+#define ft_strncpy xf86strncpy
+#define ft_memset xf86memset
+#define ft_memmove xf86memmove
+#define ft_memcmp xf86memcmp
+
+#define ft_sprintf xf86sprintf
+
+#define ft_qsort xf86qsort
+#define ft_exit xf86exit
+
+#define ft_atoi xf86atoi
+
+#define ft_jmp_buf jmp_buf
+#define ft_setjmp setjmp
+#define ft_longjmp longjmp
+
+#endif /* __FTSTDLIB_H__ */
+#endif /* FONTMODULE */
+
+
+#include <stdarg.h>
+
+#endif /* __MYFTSTDLIB_H__ */
+
+
+/* END */
diff --git a/nx-X11/lib/font/FreeType/xttcap.c b/nx-X11/lib/font/FreeType/xttcap.c
new file mode 100644
index 000000000..2040c1612
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/xttcap.c
@@ -0,0 +1,809 @@
+/* ===EmacsMode: -*- Mode: C; tab-width:4; c-basic-offset: 4; -*- === */
+/* ===FileName: ===
+ Copyright (c) 1998 Takuya SHIOZAKI, All Rights reserved.
+ Copyright (c) 1998 X-TrueType Server Project, All rights reserved.
+ Copyright (c) 2003 After X-TT Project, All rights reserved.
+
+===Notice
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ Major Release ID: X-TrueType Server Version 1.4 [Charles's Wain Release 0]
+
+Notice===
+ */
+/* $XFree86: xc/lib/font/FreeType/xttcap.c,v 1.1 2003/10/19 18:53:50 dawes Exp $ */
+
+/*
+#include "xttversion.h"
+
+static char const * const releaseID =
+ _XTT_RELEASE_NAME;
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#ifndef FONTMODULE
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+#else
+#include "Xmd.h"
+#include "Xdefs.h"
+#include "xf86_ansic.h"
+#endif
+/*
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xfuncproto.h>
+#include "xf86Module.h"
+#include "xf86_ansic.h"
+*/
+
+#ifndef True
+#define True (-1)
+#endif /* True */
+#ifndef False
+#define False (0)
+#endif /* False */
+
+#include "xttcap.h"
+
+#if 0
+/*
+ Prototypes for obsoleted OS (e.g. SunOS4)
+ */
+
+#if (defined(sun) && !(defined(SVR4) || defined(__SVR4)))
+double strtod(char *str, char **ptr);
+double strtol(char *str, char **ptr, int base);
+#endif
+#endif
+
+
+/**************************************************************************
+ Private Data Types
+ */
+
+/* Property Record List */
+/* List Node */
+typedef struct TagSPropRecValListNodeP
+{
+ SPropRecValContainerEntityP containerE;
+ struct TagSPropRecValListNodeP *nextNode;
+} SPropRecValListNodeP;
+
+
+/**************************************************************************
+ Tables
+ */
+
+/* valid record field */
+static SPropertyRecord const validRecords[] =
+{
+ { "FontFile", eRecTypeString },
+ { "FaceNumber", eRecTypeString },
+ { "AutoItalic", eRecTypeDouble },
+ { "DoubleStrike", eRecTypeString },
+ { "FontProperties", eRecTypeBool },
+ { "ForceSpacing", eRecTypeString },
+ { "ScaleBBoxWidth", eRecTypeString },
+ { "ScaleWidth", eRecTypeDouble },
+ { "EncodingOptions", eRecTypeString },
+ { "Hinting", eRecTypeBool },
+ { "VeryLazyMetrics", eRecTypeBool },
+ { "CodeRange", eRecTypeString },
+ { "EmbeddedBitmap", eRecTypeString },
+ { "VeryLazyBitmapWidthScale", eRecTypeDouble },
+ { "ForceConstantSpacingCodeRange", eRecTypeString },
+ { "ForceConstantSpacingMetrics", eRecTypeString },
+ { "Dummy", eRecTypeVoid }
+};
+static int const
+numOfValidRecords = sizeof(validRecords)/sizeof(validRecords[0]);
+
+/* correspondence between record name and cap variable name */
+static struct {
+ char const * capVariable;
+ char const * recordName;
+} const correspondRelations[] = {
+ { "fn", "FaceNumber" },
+ { "ai", "AutoItalic" },
+ { "ds", "DoubleStrike" },
+ { "fp", "FontProperties" },
+ { "fs", "ForceSpacing" },
+ { "bw", "ScaleBBoxWidth" },
+ { "sw", "ScaleWidth" },
+ { "eo", "EncodingOptions" },
+ { "vl", "VeryLazyMetrics" },
+ { "bs", "VeryLazyBitmapWidthScale" },
+ { "cr", "CodeRange" },
+ { "eb", "EmbeddedBitmap" },
+ { "hi", "Hinting" },
+ { "fc", "ForceConstantSpacingCodeRange" },
+ { "fm", "ForceConstantSpacingMetrics" }
+};
+static int const
+numOfCorrespondRelations
+= sizeof(correspondRelations)/sizeof(correspondRelations[0]);
+
+/**************************************************************************
+ Functions
+ */
+
+#ifdef USE_TTP_FILE
+
+#ifndef LEN_LINEBUF
+#define LEN_LINEBUF 2048
+#endif /* !def LEN_LINEBUF */
+
+/* get one line */
+static Bool /* True == Error, False == Success */
+get_one_line(FILE *is, char *buf)
+{
+ Bool result = False;
+ int count = 0;
+ Bool flHead = True;
+ Bool flSpace = False;
+ Bool flInSingleQuote = False;
+ Bool flInDoubleQuote = False;
+ Bool flBackSlash = False;
+ Bool flFirstElement = True;
+
+ *buf = '\0';
+ for (;;) {
+ int c = fgetc(is);
+
+ if (ferror(is)) {
+ fprintf(stderr, "truetype font property file : read error.\n");
+ result = True;
+ break;
+ }
+
+ if (EOF == c) {
+ if (flInSingleQuote || flInDoubleQuote) {
+ fprintf(stderr,
+ "truetype font property file : unmatched quote.\n");
+ result = True;
+ }
+ break;
+ }
+ if (flInSingleQuote) {
+ if ('\'' == c) {
+ /* end of single quoted string */
+ flInSingleQuote = False;
+ c = -1; /* NOT extract to buffer. */
+ } else
+ /* others, extract all character to buffer unconditionally. */
+ ;
+ goto trans;
+ }
+ if (flBackSlash) {
+ /* escape --- when just before character is backslash,
+ next character is escaped. */
+ flBackSlash = False;
+ if ('n' == c)
+ /* newline */
+ c = '\n';
+ if ('\n' == c)
+ /* ignore newline */
+ c = -1;
+ else
+ /* others, extract all character to buffer unconditionally. */
+ ;
+ goto trans;
+ }
+ if ('\\' == c) {
+ /* set flag to escape next character. */
+ flBackSlash = True;
+ c = -1; /* NOT extract to buffer. */
+ goto trans;
+ }
+ if (flInDoubleQuote) {
+ if ('"' == c) {
+ /* end of double quoted string */
+ flInDoubleQuote = False;
+ c = -1; /* NOT extract to buffer. */
+ } else
+ /* others, extract all character to buffer unconditionally. */
+ ;
+ goto trans;
+ }
+ if ('#' == c) {
+ /* skip comment till end of line. */
+ while ('\n' != c) {
+ c = fgetc(is);
+ if (ferror(is)) {
+ fprintf(stderr,
+ "truetype font property file : read error.\n");
+ result = True;
+ break;
+ }
+ if (EOF == c) {
+ break;
+ }
+ }
+ break;
+ }
+ if ('\'' == c) {
+ /* into single quoted string */
+ flInSingleQuote = True;
+ c = -1; /* NOT extract to buffer. */
+ goto trans;
+ }
+ if ('"' == c) {
+ /* into double quoted string */
+ flInDoubleQuote = True;
+ c = -1; /* NOT extract to buffer. */
+ goto trans;
+ }
+ if ('\n' == c)
+ /* End of Line */
+ break;
+ if (isspace(c)) {
+ /* convine multiple spaces */
+ if (!flHead)
+ /* except space at the head of line */
+ flSpace = True;
+ continue;
+ }
+ trans:
+ /* set flHead to False, since current character is not white space
+ when reaches here. */
+ flHead = False;
+ do {
+ if (count>=LEN_LINEBUF-1) {
+ /* overflow */
+ fprintf(stderr,
+ "truetype font property file : too long line.\n");
+ result = True;
+ goto quit;
+ }
+ if (flSpace) {
+ /* just before characters is white space, but
+ current character is not WS. */
+ if (flFirstElement) {
+ /* this spaces is the first cell(?) of white spaces. */
+ flFirstElement = False;
+ /* separate record name and record value */
+ *buf = (char)0xff;
+ } else
+ *buf = ' ';
+ flSpace = False;
+ } else
+ if (-1 != c) {
+ *buf = c;
+ c = -1; /* invalidate */
+ } else
+ /* skip */
+ buf--;
+ buf++;
+ } while (-1 != c); /* when 'c' is not -1, it means
+ that 'c' contains an untreated character. */
+ }
+ *buf = '\0';
+
+ quit:
+ return result;
+}
+
+/* parse one line */
+static Bool /* True == Error, False == Success */
+parse_one_line(SDynPropRecValList *pThisList, FILE *is)
+{
+ Bool result = False;
+ char *buf = NULL;
+ char *recordHead, *valueHead = NULL;
+
+ if (NULL == (buf = xalloc(LEN_LINEBUF))) {
+ fprintf(stderr,
+ "truetype font property file : cannot allocate memory.\n");
+ result = True;
+ goto abort;
+ }
+ {
+ recordHead = buf;
+/* refRecordValue->refRecordType = NULL;*/
+ do {
+ if (get_one_line(is, buf)) {
+ result = True;
+ goto quit;
+ }
+ if (feof(is)) {
+ if ('\0' == *buf)
+ goto quit;
+ break;
+ }
+ } while ('\0' == *buf);
+
+ if (NULL != (valueHead = strchr(buf, 0xff))) {
+ *valueHead = '\0';
+ valueHead++;
+ } else
+ valueHead = buf+strlen(buf);
+#if 0
+ fprintf(stderr,
+ "truetype font property file : \n"
+ "recName:\"%s\"\nvalue:\"%s\"\n",
+ recordHead, valueHead);
+#endif
+ result = SPropRecValList_add_record(pThisList, recordHead, valueHead);
+ }
+ quit:
+ xfree(buf);
+ abort:
+ return result;
+}
+
+/* Read Property File */
+Bool /* True == Error, False == Success */
+SPropRecValList_read_prop_file(SDynPropRecValList *pThisList,
+ char const * const strFileName)
+{
+ Bool result = False;
+ FILE *is;
+
+#if 1
+ if (!strcmp(strFileName, "-"))
+ is = stdin;
+ else
+#endif
+ is = fopen(strFileName, "r");
+ if (NULL == is) {
+ fprintf(stderr, "truetype font property : cannot open file %s.\n",
+ strFileName);
+ result = True;
+ goto abort;
+ }
+ {
+ for (;;) {
+ if (False != (result = parse_one_line(pThisList, is)))
+ goto quit;
+ if (feof(is))
+ break;
+ }
+ }
+ quit:
+#if 1
+ if (strcmp(strFileName, "-"))
+#endif
+ fclose(is);
+ abort:
+ return result;
+}
+#endif /* USE_TTP_FILE */
+
+/* get property record type by record name */
+static Bool /* True == Found, False == Not Found */
+get_record_type_by_name(SPropertyRecord const ** const refRefRecord, /*result*/
+ char const *strName)
+{
+ Bool result = False;
+ int i;
+
+ *refRefRecord = NULL;
+ for (i=0; i<numOfValidRecords; i++) {
+ if (!mystrcasecmp(validRecords[i].strRecordName, strName)) {
+ result = True;
+ *refRefRecord = &validRecords[i];
+ break;
+ }
+ }
+
+ return result;
+}
+
+/* Constructor for Container Node */
+Bool /* True == Error, False == Success */
+SPropRecValList_new(SDynPropRecValList *pThisList)
+{
+ Bool result = False;
+
+ pThisList->headNode = NULL;
+
+ return result;
+}
+
+/* Destructor for Container List */
+Bool /* True == Error, False == Success */
+SPropRecValList_delete(SDynPropRecValList *pThisList)
+{
+ Bool result = False;
+ SPropRecValListNodeP *p, *np;
+
+ for (p=pThisList->headNode; NULL!=p; p=np) {
+ np = p->nextNode;
+ switch (p->containerE.refRecordType->recordType) {
+ case eRecTypeInteger:
+ break;
+ case eRecTypeDouble:
+ break;
+ case eRecTypeBool:
+ break;
+ case eRecTypeString:
+ if (SPropContainer_value_str(&p->containerE))
+ xfree((void*)SPropContainer_value_str(&p->containerE));
+ break;
+ case eRecTypeVoid:
+ break;
+ }
+ xfree(p);
+ }
+
+ pThisList->headNode = NULL;
+
+ return result;
+}
+
+#ifdef DUMP
+void
+SPropRecValList_dump(SRefPropRecValList *pThisList)
+{
+ SPropRecValListNodeP *p;
+ for (p=pThisList->headNode; NULL!=p; p=p->nextNode) {
+ switch (p->containerE.refRecordType->recordType) {
+ case eRecTypeInteger:
+ fprintf(stderr, "%s = %d\n",
+ p->containerE.refRecordType->strRecordName,
+ p->containerE.uValue.integerValue);
+ break;
+ case eRecTypeDouble:
+ fprintf(stderr, "%s = %f\n",
+ p->containerE.refRecordType->strRecordName,
+ p->containerE.uValue.doubleValue);
+ break;
+ case eRecTypeBool:
+ fprintf(stderr, "%s = %s\n",
+ p->containerE.refRecordType->strRecordName,
+ p->containerE.uValue.boolValue
+ ? "True":"False");
+ break;
+ case eRecTypeString:
+ fprintf(stderr, "%s = \"%s\"\n",
+ p->containerE.refRecordType->strRecordName,
+ p->containerE.uValue.dynStringValue);
+ break;
+ case eRecTypeVoid:
+ fprintf(stderr, "%s = void\n",
+ p->containerE.refRecordType->strRecordName);
+ break;
+ }
+ }
+}
+#endif
+
+/* Add Property Record Value */
+extern Bool /* True == Error, False == Success */
+SPropRecValList_add_record(SDynPropRecValList *pThisList,
+ char const * const recordName,
+ char const * const strValue)
+{
+ Bool result = False;
+ SPropRecValContainerEntityP tmpContainerE;
+
+ if (get_record_type_by_name(&tmpContainerE.refRecordType, recordName)) {
+ switch (tmpContainerE.refRecordType->recordType) {
+ case eRecTypeInteger:
+ {
+ int val;
+ char *endPtr;
+
+ val = strtol(strValue, &endPtr, 0);
+ if ('\0' != *endPtr) {
+ fprintf(stderr,
+ "truetype font property : "
+ "%s record needs integer value.\n",
+ recordName);
+ result = True;
+ goto quit;
+ }
+ SPropContainer_value_int(&tmpContainerE) = val;
+ }
+ break;
+ case eRecTypeDouble:
+ {
+ double val;
+ char *endPtr;
+
+ val = strtod(strValue, &endPtr);
+ if ('\0' != *endPtr) {
+ fprintf(stderr,
+ "truetype font property : "
+ "%s record needs floating point value.\n",
+ recordName);
+ result = True;
+ goto quit;
+ }
+ SPropContainer_value_dbl(&tmpContainerE) = val;
+ }
+ break;
+ case eRecTypeBool:
+ {
+ Bool val;
+
+ if (!mystrcasecmp(strValue, "yes"))
+ val = True;
+ else if (!mystrcasecmp(strValue, "y"))
+ val = True;
+ else if (!mystrcasecmp(strValue, "on"))
+ val = True;
+ else if (!mystrcasecmp(strValue, "true"))
+ val = True;
+ else if (!mystrcasecmp(strValue, "t"))
+ val = True;
+ else if (!mystrcasecmp(strValue, "ok"))
+ val = True;
+ else if (!mystrcasecmp(strValue, "no"))
+ val = False;
+ else if (!mystrcasecmp(strValue, "n"))
+ val = False;
+ else if (!mystrcasecmp(strValue, "off"))
+ val = False;
+ else if (!mystrcasecmp(strValue, "false"))
+ val = False;
+ else if (!mystrcasecmp(strValue, "f"))
+ val = False;
+ else if (!mystrcasecmp(strValue, "bad"))
+ val = False;
+ else {
+ fprintf(stderr,
+ "truetype font property : "
+ "%s record needs boolean value.\n",
+ recordName);
+ result = True;
+ goto quit;
+ }
+ SPropContainer_value_bool(&tmpContainerE) = val;
+ }
+ break;
+ case eRecTypeString:
+ {
+ char *p;
+
+ if (NULL == (p = (char *)xalloc(strlen(strValue)+1))) {
+ fprintf(stderr,
+ "truetype font property : "
+ "cannot allocate memory.\n");
+ result = True;
+ goto quit;
+ }
+ strcpy(p, strValue);
+ SPropContainer_value_str(&tmpContainerE) = p;
+ }
+ break;
+ case eRecTypeVoid:
+ if ('\0' != *strValue) {
+ fprintf(stderr,
+ "truetype font property : "
+ "%s record needs void.\n", recordName);
+ result = True;
+ }
+ break;
+ }
+ {
+ /* add to list */
+ SPropRecValListNodeP *newNode;
+
+ if (NULL == (newNode =
+ (SPropRecValListNodeP *)xalloc(sizeof(*newNode)))) {
+ fprintf(stderr,
+ "truetype font property : "
+ "cannot allocate memory.\n");
+ result = True;
+ goto quit;
+ }
+ newNode->nextNode = pThisList->headNode;
+ newNode->containerE = tmpContainerE;
+ tmpContainerE.refRecordType = NULL; /* invalidate --
+ disown value handle. */
+ pThisList->headNode = newNode;
+ }
+ } else {
+ /* invalid record name */
+ fprintf(stderr,
+ "truetype font : "
+ "invalid record name \"%s.\"\n", recordName);
+ result = True;
+ }
+
+ quit:
+ return result;
+}
+
+
+/* Search Property Record */
+Bool /* True == Hit, False == Miss */
+SPropRecValList_search_record(SRefPropRecValList *pThisList,
+ SPropRecValContainer *refRecValue,
+ char const * const recordName)
+{
+ Bool result = False;
+ SPropRecValListNodeP *p;
+
+ *refRecValue = NULL;
+ for (p=pThisList->headNode; NULL!=p; p=p->nextNode) {
+ if (!mystrcasecmp(p->containerE.refRecordType->strRecordName,
+ recordName)) {
+ *refRecValue = &p->containerE;
+ result = True;
+ break;
+ }
+ }
+
+ return result;
+}
+
+
+/* Parse TTCap */
+Bool /* True == Error, False == Success */
+SPropRecValList_add_by_font_cap(SDynPropRecValList *pThisList,
+ char const *strCapHead)
+{
+ Bool result = False;
+ /* SPropertyRecord const *refRecordType; */
+ char const *term;
+
+ if (NULL == (term = strrchr(strCapHead, ':')))
+ goto abort;
+
+ {
+ /* for xfsft compatible */
+ char const *p;
+ for (p=term-1; p>=strCapHead; p--) {
+ if ( ':'==*p ) {
+ /*
+ * :num:filename
+ * ^p ^term
+ */
+ if ( p!=term ) {
+ int len = term-p-1;
+ char *value;
+
+ len = term-p-1;
+ value=(char *)xalloc(len+1);
+ memcpy(value, p+1, len);
+ value[len]='\0';
+ SPropRecValList_add_record(pThisList,
+ "FaceNumber",
+ value);
+ xfree(value);
+ term=p;
+ }
+ break;
+ }
+ if ( !isdigit(*p) )
+ break;
+ }
+ }
+
+ while (strCapHead<term) {
+ int i;
+ char const *nextColon = strchr(strCapHead, ':');
+ if (0<nextColon-strCapHead) {
+ char *duplicated = (char *)xalloc((nextColon-strCapHead)+1);
+ {
+ char *value;
+
+ memcpy(duplicated, strCapHead, nextColon-strCapHead);
+ duplicated[nextColon-strCapHead] = '\0';
+ if (NULL != (value=strchr(duplicated, '='))) {
+ *value = '\0';
+ value++;
+ } else
+ value = &duplicated[nextColon-strCapHead];
+
+ for (i=0; i<numOfCorrespondRelations; i++) {
+ if (!mystrcasecmp(correspondRelations[i].capVariable,
+ duplicated)) {
+ if (SPropRecValList_add_record(pThisList,
+ correspondRelations[i]
+ .recordName,
+ value))
+ break;
+ goto next;
+ }
+ }
+ fprintf(stderr, "truetype font : Illegal Font Cap.\n");
+ result = True;
+ break;
+ next:
+ ;
+ }
+ xfree(duplicated);
+ }
+ strCapHead = nextColon+1;
+ }
+
+ /* quit: */
+ abort:
+ return result;
+}
+
+
+/**************************************************************************
+ Functions (xttmisc)
+ */
+
+/* compare strings, ignoring case */
+Bool /* False == equal, True == not equal */
+mystrcasecmp(char const *s1, char const *s2)
+{
+ Bool result = True;
+
+#if (defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ||\
+ defined(__bsdi__)) && !defined(FONTMODULE)
+ /* 4.4BSD has strcasecmp function. */
+ result = strcasecmp(s1, s2) != 0;
+#else
+ {
+ unsigned int len1 = strlen(s1);
+
+ if (len1 == strlen(s2)) {
+ int i;
+ for (i=0; i<len1; i++) {
+ if (toupper(*s1++) != toupper(*s2++))
+ goto quit;
+ }
+ result = False;
+ } else
+ /* len1 != len2 -> not equal*/
+ ;
+ }
+ quit:
+ ;
+#endif
+
+ return result;
+}
+
+
+/* strdup clone with using the allocator of X server */
+char *
+XttXstrdup(char const *str)
+{
+ char *result;
+
+ result = (char *)xalloc(strlen(str)+1);
+
+ if (result)
+ strcpy(result, str);
+
+ return result;
+}
+
+
+#if 0
+int main()
+{
+ SDynPropRecValList list;
+
+ SPropRecValList_new(&list);
+ SPropRecValList_read_prop_file(&list, "-");
+ SPropRecValList_dump(&list);
+ SPropRecValList_delete(&list);
+
+ return 0;
+}
+#endif
+
+/* end of file */
diff --git a/nx-X11/lib/font/FreeType/xttcap.h b/nx-X11/lib/font/FreeType/xttcap.h
new file mode 100644
index 000000000..33c224f90
--- /dev/null
+++ b/nx-X11/lib/font/FreeType/xttcap.h
@@ -0,0 +1,140 @@
+/* ===EmacsMode: -*- Mode: C; tab-width:4; c-basic-offset: 4; -*- === */
+/* ===FileName: ===
+ Copyright (c) 1998 Takuya SHIOZAKI, All Rights reserved.
+ Copyright (c) 1998 X-TrueType Server Project, All rights reserved.
+ Copyright (c) 2003 After X-TT Project, All rights reserved.
+
+===Notice
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ Major Release ID: X-TrueType Server Version 1.3 [Aoi MATSUBARA Release 3]
+
+Notice===
+ */
+/* $XFree86: xc/extras/X-TrueType/xttcap.h,v 1.2 2001/08/01 00:44:33 tsi Exp $ */
+
+#ifndef _XTTCAP_H_
+#define _XTTCAP_H_ (1)
+
+#include <X11/Xdefs.h>
+
+/*******************************************************************
+ Data Types
+ */
+
+/* Record Type */
+typedef enum
+{
+ eRecTypeInteger,
+ eRecTypeDouble,
+ eRecTypeBool,
+ eRecTypeString,
+ eRecTypeVoid=-1
+} ERecType;
+
+/* Record Name vs Record Type */
+typedef struct
+{
+ char const *strRecordName;
+ ERecType const recordType;
+} SPropertyRecord;
+
+/* Record Value Container */
+typedef struct
+{
+ SPropertyRecord const *refRecordType;
+ union {
+ int integerValue;
+ double doubleValue;
+ Bool boolValue;
+ char *dynStringValue;
+ } uValue;
+} SPropRecValContainerEntityP, *SPropRecValContainer;
+
+/* Record Value List */
+typedef struct TagSPropRecValListNodeP SPropRecValListNode;
+typedef struct
+{
+ SPropRecValListNode *headNode;
+} SDynPropRecValList;
+typedef SDynPropRecValList const SRefPropRecValList;
+
+
+/*******************************************************************
+ Functions
+ */
+
+/* Constructor for Rec Val List */
+extern Bool /* True == Error, False == Success */
+SPropRecValList_new(SDynPropRecValList *pThisList);
+/* Destructor for Rec Val List */
+extern Bool /* True == Error, False == Success */
+SPropRecValList_delete(SDynPropRecValList *pThisList);
+/* Read Property File */
+extern Bool /* True == Error, False == Success */
+SPropRecValList_read_prop_file(SDynPropRecValList *pThisList,
+ char const * const strFileName);
+/* Add Property Record Value */
+extern Bool /* True == Error, False == Success */
+SPropRecValList_add_record(SDynPropRecValList *pThisList,
+ char const * const recordName,
+ char const * const strValue);
+/* Search Property Record */
+extern Bool /* True == Hit, False == Miss */
+SPropRecValList_search_record(SRefPropRecValList *pThisList,
+ SPropRecValContainer *refContRecVal,
+ char const * const recordName);
+/* Add by Font Cap */
+extern Bool /* True == Error, False == Success */
+SPropRecValList_add_by_font_cap(SDynPropRecValList *pThisList,
+ char const *strCapHead);
+
+#ifdef DUMP
+void
+SPropRecValList_dump(SRefPropRecValList *refList);
+#endif
+
+#define SPropContainer_value_int(contRecVal)\
+ ((contRecVal)->uValue.integerValue)
+#define SPropContainer_value_dbl(contRecVal)\
+ ((contRecVal)->uValue.doubleValue)
+#define SPropContainer_value_bool(contRecVal)\
+ ((contRecVal)->uValue.boolValue)
+#define SPropContainer_value_str(contRecVal)\
+ ((contRecVal)->uValue.dynStringValue)
+
+/******************************************************
+ Prototypes (xttmisc)
+ */
+
+/* compare strings with ignoring case */
+ /* False == equal, True == not equal */
+Bool mystrcasecmp(char const *s1, char const *s2);
+
+/* strdup clone */
+char * XttXstrdup(char const *str);
+#undef xstrdup
+#define xstrdup(s) XttXstrdup((char const*)s)
+
+#endif /* !def _XTTCAP_H_ */
+
+/* end of file */
diff --git a/nx-X11/lib/font/Imakefile b/nx-X11/lib/font/Imakefile
new file mode 100644
index 000000000..02ddd8eaa
--- /dev/null
+++ b/nx-X11/lib/font/Imakefile
@@ -0,0 +1,178 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:24 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/font/Imakefile,v 3.37 2003/10/24 16:21:12 tsi Exp $
+
+#include <Server.tmpl>
+
+#define IHaveSubdirs
+
+#define DoNormalLib NormalLibFont
+#define DoSharedLib SharedLibFont
+#define DoExtraLib SharedLibFont
+#define DoDebugLib DebugLibFont
+#define DoProfileLib ProfileLibFont
+
+#if !BuildFontLib
+#define LibCreate NO
+#else
+#define LibCreate YES
+#endif
+
+#if BuildLibraries
+#define LibInstall YES
+#else
+#define LibInstall NO
+#endif
+
+#if BuildLibraries
+STUBDIRS = stubs
+#endif
+
+LIBNAME = Xfont
+SOREV = $(SOFONTREV)
+
+#ifndef SeparateSharedCompile
+#define SeparateSharedCompile YES
+#endif
+#if NormalLibFont && SharedLibFont && SeparateSharedCompile
+STATIC_OBJSDIR = unshared/
+#endif
+
+#ifdef SharedXfontReqs
+REQUIREDLIBS = SharedXfontReqs
+#endif
+
+#if BuildSpeedo
+ SPEEDODIRS = Speedo
+ SPEEDOSHAREDOBJS = Speedo/?*.o
+ SPEEDOSTATICOBJS = Speedo/$(STATIC_OBJSDIR)?*.o
+ SPEEDODEBUGOBJS = Speedo/debugger/?*.o
+ SPEEDOPROFILEOBJS = Speedo/profiled/?*.o
+ SPEEDODONES = Speedo/DONE
+#endif
+#if BuildType1 || BuildCID
+ TYPE1DIRS = Type1
+ TYPE1SHAREDOBJS = Type1/?*.o
+ TYPE1STATICOBJS = Type1/$(STATIC_OBJSDIR)?*.o
+ TYPE1DEBUGOBJS = Type1/debugger/?*.o
+ TYPE1PROFILEOBJS = Type1/profiled/?*.o
+ TYPE1DONES = Type1/DONE
+#endif
+#if BuildFreeType || BuildFreetype2Library
+ FREETYPEDIRS = FreeType
+ FREETYPESHAREDOBJS = FreeType/?*.o
+ FREETYPESTATICOBJS = FreeType/$(STATIC_OBJSDIR)?*.o
+ FREETYPEDEBUGOBJS = FreeType/debugger/?*.o
+FREETYPEPROFILEOBJS = FreeType/profiled/?*.o
+ FREETYPEDONES = FreeType/DONE
+#endif
+#if BuildBuiltinFonts
+ BUILTINDIRS = builtins
+ BUILTINSHAREDOBJS = builtins/?*.o
+ BUILTINSTATICOBJS = builtins/$(STATIC_OBJSDIR)?*.o
+ BUILTINDEBUGOBJS = builtins/debugger/?*.o
+ BUILTINPROFILEOBJS = builtins/profiled/?*.o
+ BUILTINDONES = builtins/DONE
+#endif
+#if BuildFontCache
+ FONTCACHEDIRS = fontcache
+FONTCACHESHAREDOBJS = fontcache/?*.o
+FONTCACHESTATICOBJS = fontcache/$(STATIC_OBJSDIR)?*.o
+ FONTCACHEDEBUGOBJS = fontcache/debugger/?*.o
+FONTCACHEPROFILEOBJS = fontcache/profiled/?*.o
+ FONTCACHEDONES = fontcache/DONE
+#endif
+
+ SUBDIRS = bitmap fontfile fc $(FONTCACHEDIRS) \
+ $(SPEEDODIRS) $(TYPE1DIRS) \
+ $(FREETYPEDIRS) $(BUILTINDIRS) \
+ util $(STUBDIRS) include
+ SHARED_OBJS = bitmap/?*.o fontfile/?*.o fc/?*.o $(FONTCACHESHAREDOBJS) \
+ $(SPEEDOSHAREDOBJS) $(TYPE1SHAREDOBJS) \
+ $(FREETYPESHAREDOBJS) \
+ $(BUILTINSHAREDOBJS) util/?*.o
+ STATIC_OBJS = bitmap/$(STATIC_OBJSDIR)?*.o fontfile/$(STATIC_OBJSDIR)?*.o \
+ fc/$(STATIC_OBJSDIR)?*.o $(FONTCACHESTATICOBJS) \
+ $(SPEEDOSTATICOBJS) $(TYPE1STATICOBJS) \
+ $(FREETYPESTATICOBJS) \
+ $(BUILTINSTATICOBJS) util/$(STATIC_OBJSDIR)?*.o
+ DEBUG_OBJS = bitmap/debugger/?*.o fontfile/debugger/?*.o fc/debugger/?*.o \
+ $(FONTCACHEDEBUGOBJS) \
+ $(SPEEDODEBUGOBJS) $(TYPE1DEBUGOBJS) \
+ $(FREETYPEDEBUGOBJS) \
+ $(BUILTINDEBUGOBJS) util/debugger/?*.o
+ PROFILE_OBJS = bitmap/profiled/?*.o fontfile/profiled/?*.o fc/profiled/?*.o \
+ $(FONTCACHEPROFILEOBJS) \
+ $(SPEEDOPROFILEOBJS) $(TYPE1PROFILEOBJS) \
+ $(FREETYPEPROFILEOBJS) \
+ $(BUILTINPROFILEOBJS) util/profiled/?*.o
+ DONES = bitmap/DONE fontfile/DONE fc/DONE $(FONTCACHEDONES) \
+ $(SPEEDODONES) $(TYPE1DONES) \
+ $(FREETYPEDONES) \
+ $(BUILTINDONES) util/DONE
+
+#if BuildServer && DoLoadableServer
+ BASEDIRS = fontfile fc util $(FONTCACHEDIRS)
+ BASELIBOBJS = fontfile/$(STATIC_OBJSDIR)?*.o fc/$(STATIC_OBJSDIR)?*.o \
+ util/$(STATIC_OBJSDIR)?*.o $(FONTCACHESTATICOBJS)
+ BASEOBJS = fontfile/module/ffcheck.o fontfile/module/register.o \
+ util/private.o
+ BASEDONES = fontfile/DONE fontfile/module/DONE fc/DONE util/DONE \
+ $(FONTCACHEDONES)
+#endif
+
+#if HasParallelMake
+MakeMutex($(SUBDIRS) $(DONES))
+#endif
+
+#if HasGnuMake || HasBsdMake
+$(DONES): $(SUBDIRS)
+#endif
+
+#include <Library.tmpl>
+
+#undef _LinkBuildLibrary
+#define _LinkBuildLibrary(lib) LinkBuildLibrary(lib)
+
+#if LibCreate
+#if NormalLibFont
+NormalDepLibraryTarget($(LIBNAME),$(SUBDIRS) $(DONES),$(STATIC_OBJS))
+#if LibInstall
+InstallLibrary($(LIBNAME),$(USRLIBDIR))
+#endif /* LibInstall */
+#endif /* NormalLibFont */
+
+#if SharedLibFont
+SharedDepLibraryTarget($(LIBNAME),$(SOREV),$(SUBDIRS) $(DONES),$(SHARED_OBJS),.,.)
+#if LibInstall
+InstallSharedLibrary($(LIBNAME),$(SOREV),$(SHLIBDIR))
+#endif /* LibInstall */
+#endif /* SharedLibFont */
+
+#if DebugLibFont
+DebuggedDepLibraryTarget($(LIBNAME),$(SUBDIRS) $(DONES),$(DEBUG_OBJS))
+#if LibInstall
+InstallLibrary($(LIBNAME)_d,$(USRLIBDIR))
+#endif /* LibInstall */
+#endif /* DebugLibFont */
+
+#if ProfileLibFont
+ProfiledDepLibraryTarget($(LIBNAME),$(SUBDIRS) $(DONES),$(PROFILE_OBJS))
+#if LibInstall
+InstallLibrary($(LIBNAME)_p,$(USRLIBDIR))
+#endif /* LibInstall */
+#endif /* ProfileLibFont */
+#endif /* LibCreate */
+
+#if BuildServer && DoLoadableServer
+NormalDepLibraryTarget(fontbase,$(BASEDIRS) $(BASEDONES),$(BASELIBOBJS))
+NormalDepRelocatableTarget(fontbase,$(BASEDIRS) $(BASEDONES),$(BASEOBJS))
+#endif
+
+
+ForceSubdirs($(SUBDIRS))
+
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/lib/font/Speedo/Imakefile b/nx-X11/lib/font/Speedo/Imakefile
new file mode 100644
index 000000000..e2d9dcdeb
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/Imakefile
@@ -0,0 +1,46 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:24 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/font/Speedo/Imakefile,v 1.10 2001/01/19 08:13:29 dawes Exp $
+
+#if BuildServer && DoLoadableServer
+#define IHaveSubdirs
+#define NoLibSubdirs
+#define PassCDebugFlags
+SUBDIRS = module
+#endif
+
+ INCLUDES = -I$(FONTINCSRC) -I../include -I$(SERVERSRC)/include
+ HEADERS =
+ SPEEDOSRCS = do_char.c do_trns.c out_bl2d.c out_blk.c \
+ out_scrn.c out_util.c reset.c set_spcs.c set_trns.c
+ SPEEDOOBJS = do_char.o do_trns.o out_bl2d.o out_blk.o \
+ out_scrn.o out_util.o reset.o set_spcs.o set_trns.o
+
+ SRCS = spfuncs.c spfile.c spinfo.c sperr.c spfont.c spglyph.c \
+ spencode.c bics-unicode.c \
+ $(SPEEDOSRCS)
+ OBJS = spfuncs.o spfile.o spinfo.o sperr.o spfont.o spglyph.o \
+ spencode.o bics-unicode.o \
+ $(SPEEDOOBJS)
+
+#if BuildFontLib
+#define DoNormalLib NormalLibFont
+#define DoSharedLib SharedLibFont
+#define DoDebugLib DebugLibFont
+#define DoProfileLib ProfileLibFont
+#include <Library.tmpl>
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+#endif
+
+#if BuildServer && DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/font/Speedo/adobe-iso.h b/nx-X11/lib/font/Speedo/adobe-iso.h
new file mode 100644
index 000000000..e1eeef1c5
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/adobe-iso.h
@@ -0,0 +1,200 @@
+/* $Xorg: adobe-iso.h,v 1.3 2000/08/17 19:46:24 cpqbld Exp $ */
+
+/*
+ * Latin 1 format from masterset format 11 (ps)
+ * 0 implies no valid mapping
+ */
+
+int adobe_map[] = {
+ 32, 32,
+ 33, 33,
+ 34, 34,
+ 35, 35,
+ 36, 36,
+ 37, 37,
+ 38, 38,
+ 39, 169,
+ 40, 40,
+ 41, 41,
+ 42, 42,
+ 43, 43,
+ 44, 44,
+ 45, 45,
+ 46, 46,
+ 47, 47,
+ 48, 48,
+ 49, 49,
+ 50, 50,
+ 51, 51,
+ 52, 52,
+ 53, 53,
+ 54, 54,
+ 55, 55,
+ 56, 56,
+ 57, 57,
+ 58, 58,
+ 59, 59,
+ 60, 60,
+ 61, 61,
+ 62, 62,
+ 63, 63,
+ 64, 64,
+ 65, 65,
+ 66, 66,
+ 67, 67,
+ 68, 68,
+ 69, 69,
+ 70, 70,
+ 71, 71,
+ 72, 72,
+ 73, 73,
+ 74, 74,
+ 75, 75,
+ 76, 76,
+ 77, 77,
+ 78, 78,
+ 79, 79,
+ 80, 80,
+ 81, 81,
+ 82, 82,
+ 83, 83,
+ 84, 84,
+ 85, 85,
+ 86, 86,
+ 87, 87,
+ 88, 88,
+ 89, 89,
+ 90, 90,
+ 91, 91,
+ 92, 92,
+ 93, 93,
+ 94, 195,
+ 95, 95,
+ 96, 193,
+ 97, 97,
+ 98, 98,
+ 99, 99,
+ 100, 100,
+ 101, 101,
+ 102, 102,
+ 103, 103,
+ 104, 104,
+ 105, 105,
+ 106, 106,
+ 107, 107,
+ 108, 108,
+ 109, 109,
+ 110, 110,
+ 111, 111,
+ 112, 112,
+ 113, 113,
+ 114, 114,
+ 115, 115,
+ 116, 116,
+ 117, 117,
+ 118, 118,
+ 119, 119,
+ 120, 120,
+ 121, 121,
+ 122, 122,
+ 123, 123,
+ 124, 124,
+ 125, 125,
+ 126, 196, /* lc tilde */
+ 127, 0, /* */
+ 161, 161, /* invert exclamation */
+ 162, 162, /* cent */
+ 163, 163, /* pound sterling */
+ 164, 168, /* intl currency */
+ 165, 165, /* yen */
+ 166, 320, /* split vert bar */
+ 167, 167, /* section mark */
+ 168, 200, /* dierisis */
+ 169, 0, /* superior copyright */
+ 170, 0, /* feminine ordinal */
+ 171, 171, /* dbl left guillemot */
+ 172, 314, /* math not */
+ 173, 0, /* hyphen ? */
+ 174, 0, /* superior registered */
+ 175, 0, /* overscore */
+ 176, 321, /* degree */
+ 177, 329, /* math +- */
+ 178, 333, /* superior 2 */
+ 179, 332, /* superior 3 */
+ 180, 194, /* lc acute */
+ 181, 324, /* greek lc mu */
+ 182, 182, /* Paragraph */
+ 183, 180, /* center dot */
+ 184, 203, /* cedilla lc */
+ 185, 328, /* superior 1 */
+ 186, 0, /* masculine ordinal(using superior o) */
+ 187, 187, /* right dbl guillemot */
+ 188, 327, /* 1/4 */
+ 189, 326, /* 1/2 */
+ 190, 331, /* 3/4 */
+ 191, 191, /* invert question */
+ 192, 259, /* A grave */
+ 193, 256, /* A acute */
+ 194, 257, /* A circumflex */
+ 195, 261, /* A tilde */
+ 196, 258, /* A dierisis */
+ 197, 260, /* A angstrom */
+ 198, 225, /* AE ligature */
+ 199, 262, /* C cedilla */
+ 200, 266, /* E grave */
+ 201, 263, /* E acute */
+ 202, 264, /* E circumflex */
+ 203, 265, /* E dierisis */
+ 204, 270, /* I grave */
+ 205, 267, /* I acute */
+ 206, 268, /* I circumflex */
+ 207, 269, /* I dierisis */
+ 208, 317, /* D bar */
+ 209, 271, /* N tilde */
+ 210, 275, /* O grave */
+ 211, 272, /* O acute */
+ 212, 273, /* O circumflex */
+ 213, 276, /* O tilde */
+ 214, 274, /* O dierisis */
+ 215, 325, /* math multiply */
+ 216, 233, /* O bar */
+ 217, 281, /* U grave */
+ 218, 278, /* U acute */
+ 219, 279, /* U circumflex */
+ 220, 280, /* U dierisis */
+ 221, 319, /* Y acute */
+ 222, 318, /* icelandic thorn lc */
+ 223, 251, /* German dbl s */
+ 224, 287, /* a grave */
+ 225, 284, /* a acute */
+ 226, 285, /* a circumflex */
+ 227, 289, /* a tilde */
+ 228, 286, /* a dierisis */
+ 229, 288, /* a angstrom */
+ 230, 241, /* ae ligature */
+ 231, 290, /* c cedilla */
+ 232, 294, /* e grave */
+ 233, 291, /* e acute */
+ 234, 292, /* e circumflex */
+ 235, 293, /* e dierisis */
+ 236, 298, /* i grave */
+ 237, 295, /* i acute */
+ 238, 296, /* i circumflex */
+ 239, 297, /* i dierisis */
+ 240, 323, /* icelandic eth lc */
+ 241, 299, /* n tilde */
+ 242, 303, /* o grave */
+ 243, 300, /* o acute */
+ 244, 301, /* o circumflex */
+ 245, 304, /* o tilde */
+ 246, 302, /* o dierisis */
+ 247, 322, /* math divide */
+ 248, 249, /* o bar */
+ 249, 309, /* u grave */
+ 250, 306, /* u acute */
+ 251, 307, /* u circumflex */
+ 252, 308, /* u dierisis */
+ 253, 334, /* y acute */
+ 254, 330, /* icelandic thorn uc */
+ 255, 310, /* y dierisis */
+};
diff --git a/nx-X11/lib/font/Speedo/bics-iso.h b/nx-X11/lib/font/Speedo/bics-iso.h
new file mode 100644
index 000000000..4964fa34e
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/bics-iso.h
@@ -0,0 +1,224 @@
+/* $Xorg: bics-iso.h,v 1.4 2001/02/09 02:04:00 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.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/bics-iso.h,v 1.6 2001/01/17 19:43:17 dawes Exp $ */
+
+int sp_bics_map[] = {
+ 32, 0,
+ 33, 1,
+ 34, 2,
+ 35, 3,
+ 36, 4,
+ 37, 5,
+ 38, 6,
+ 39, 264,
+ 40, 8,
+ 41, 9,
+ 42, 10,
+ 43, 11,
+ 44, 12,
+ 45, 13,
+ 46, 14,
+ 47, 15,
+ 48, 16,
+ 49, 17,
+ 50, 18,
+ 51, 19,
+ 52, 20,
+ 53, 21,
+ 54, 22,
+ 55, 23,
+ 56, 24,
+ 57, 25,
+ 58, 26,
+ 59, 27,
+ 60, 28,
+ 61, 29,
+ 62, 30,
+ 63, 31,
+ 64, 32,
+ 65, 33,
+ 66, 34,
+ 67, 35,
+ 68, 36,
+ 69, 37,
+ 70, 38,
+ 71, 39,
+ 72, 40,
+ 73, 41,
+ 74, 42,
+ 75, 43,
+ 76, 44,
+ 77, 45,
+ 78, 46,
+ 79, 47,
+ 80, 48,
+ 81, 49,
+ 82, 50,
+ 83, 51,
+ 84, 52,
+ 85, 53,
+ 86, 54,
+ 87, 55,
+ 88, 56,
+ 89, 57,
+ 90, 58,
+ 91, 59,
+ 92, 60,
+ 93, 61,
+ 94, 133,
+ 95, 63,
+ 96, 131,
+ 97, 65,
+ 98, 66,
+ 99, 67,
+ 100, 68,
+ 101, 69,
+ 102, 70,
+ 103, 71,
+ 104, 72,
+ 105, 73,
+ 106, 74,
+ 107, 75,
+ 108, 76,
+ 109, 77,
+ 110, 78,
+ 111, 79,
+ 112, 80,
+ 113, 81,
+ 114, 82,
+ 115, 83,
+ 116, 84,
+ 117, 85,
+ 118, 86,
+ 119, 87,
+ 120, 88,
+ 121, 89,
+ 122, 90,
+ 123, 91,
+ 124, 92,
+ 125, 93,
+ 126, 137,
+ 127, 358,
+ 161, 128,
+ 162, 98,
+ 163, 97,
+ 164, 278,
+ 165, 274,
+ 166, 277,
+ 167, 110,
+ 168, 135,
+ 169, 503,
+ 170, 538,
+ 171, 125,
+ 172, 309,
+ 173, 191,
+ 174, 504,
+ 175, 230,
+ 176, 339,
+ 177, 286,
+ 178, 160,
+ 179, 161,
+ 180, 129,
+ 181, 325,
+ 182, 279,
+ 183, 102,
+ 184, 141,
+ 185, 159,
+ 186, 544,
+ 187, 126,
+ 188, 151,
+ 189, 153,
+ 190, 155,
+ 191, 127,
+ 192, 259,
+ 193, 261,
+ 194, 257,
+ 195, 253,
+ 196, 255,
+ 197, 113,
+ 198, 114,
+ 199, 148,
+ 200, 249,
+ 201, 251,
+ 202, 247,
+ 203, 245,
+ 204, 239,
+ 205, 241,
+ 206, 237,
+ 207, 235,
+ 208, 169,
+ 209, 196,
+ 210, 202,
+ 211, 200,
+ 212, 204,
+ 213, 208,
+ 214, 206,
+ 215, 284,
+ 216, 115,
+ 217, 212,
+ 218, 210,
+ 219, 214,
+ 220, 216,
+ 221, 224,
+ 222, 271,
+ 223, 121,
+ 224, 260,
+ 225, 262,
+ 226, 258,
+ 227, 254,
+ 228, 256,
+ 229, 117,
+ 230, 118,
+ 231, 149,
+ 232, 250,
+ 233, 252,
+ 234, 248,
+ 235, 246,
+ 236, 240,
+ 237, 242,
+ 238, 238,
+ 239, 236,
+ 240, 273,
+ 241, 195,
+ 242, 201,
+ 243, 199,
+ 244, 203,
+ 245, 207,
+ 246, 205,
+ 247, 285,
+ 248, 119,
+ 249, 211,
+ 250, 209,
+ 251, 213,
+ 252, 215,
+ 253, 223,
+ 254, 272,
+ 255, 221,
+};
+
diff --git a/nx-X11/lib/font/Speedo/bics-unicode.c b/nx-X11/lib/font/Speedo/bics-unicode.c
new file mode 100644
index 000000000..735508268
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/bics-unicode.c
@@ -0,0 +1,138 @@
+/*
+Copyright (c) 1998 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+
+/* $XFree86$ */
+
+/* These data are very dodgy. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "bics-unicode.h"
+
+static short table_160[]=
+{0, 128, 98, 97, 278, 274, 277, 110, 135, 503, 538, 125, 309, 191, 504,
+ 230, 339, 286, 160, 161, 129, 325, 279, 102, 141, 159, 544, 126, 151,
+ 153, 155, 127, 259, 261, 257, 253, 255, 113, 114, 148, 249, 251, 247,
+ 245, 239, 241, 237, 235, 169, 196, 202, 200, 204, 208, 206, 284, 115,
+ 212, 210, 214, 216, 224, 271, 121, 260, 262, 258, 254, 256, 117, 118,
+ 149, 250, 252, 248, 246, 240, 242, 238, 236, 273, 195, 201, 199, 203,
+ 207, 205, 285, 119, 211, 209, 213, 215, 223, 272, 221, 477, 476, 374,
+ 373, 171, 177, 376, 375, -1, -1, -1, -1, 378, 377, 379, -1, 169, 173,
+ 383, 382, -1, -1, -1, -1, 172, 178, 243, 244, -1, -1, -1, -1, -1, -1,
+ 385, -1, -1, -1, -1, -1, 233, 234, 387, 386, -1, -1, 391, 390, 389,
+ 122, 276, 275, -1, -1, 393, 392, -1, 395, 394, 399, 398, -1, -1, -1,
+ -1, 170, 174, 194, 193, 402, 401, 198, 197, 263, -1, -1, -1, -1, -1,
+ -1, 404, 403, 116, 120, -1, -1, 408, 407, 406, 405, 410, 409, -1, -1,
+ 486, 485, 412, 411, 419, 418, 364, 363, -1, -1, 218, 217, 421, 420, -1,
+ -1, 220, 219, 423, 422, -1, 268, 425, 424, -1, -1, 222, 368, 367, 372,
+ 371, 370, 369};
+
+static short table_728[]={144, 181, 146, 731, 137, 183};
+
+static short table_915[]=
+{313, 314, -1, -1, -1, 315, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 316, -1, -1, 317, -1, -1, 318, -1, -1, -1, -1, -1, -1, -1, 319, 320,
+ -1, 321, 322, -1, 323, 324, -1, -1, -1, 325, -1, -1, -1, 326, -1, -1,
+ 327, 328, -1, 329};
+
+static short table_8211[]=
+{111, 112, -1, -1, -1, -1, -1, 106, -1, 103, 105, 107, 104, 108, 109,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 100, -1, -1,
+ -1, -1, -1, -1, -1, -1, 123, 124, -1, 265};
+
+static short table_8319[]=
+{543, 475, 466, 467, 468, 469, 470, 471, 472, 473, 474, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 491, -1, -1, -1, 266};
+
+static short table_8592[]={293, 295, 294, 292, 297, 296};
+
+static short table_8712[]=
+{298, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 492, -1, -1, -1, -1, -1,
+ -1, 302, -1, -1, -1, 303, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 299,
+ -1, -1, -1, -1, 428};
+
+
+static short table_8800[]={288, -1, -1, -1, 291, 290};
+
+static short table_9600[]=
+{304, -1, -1, -1, 305, -1, -1, -1, 308, -1, -1, -1, 306, -1, -1, -1,
+ 307, 357, 358, 359, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 335, 336, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 348, -1, -1, -1, 345, -1, -1, -1, -1, -1, 347, -1, -1, -1, 346,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 339, -1, -1, -1, 342, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 344};
+
+static short table_9784[]={360, -1, 361, 362, -1, -1, -1, -1, 350, -1, 349};
+
+static short table_9824[]=
+{354, -1, -1, 352, -1, 351, 353, -1, -1, -1, 330, 331};
+
+static short table_64256[]={282, 95, 96, 281};
+
+int
+unicode_to_bics(unsigned code)
+{
+ if(code<32) return -1;
+ else if(code<127) return code-32;
+ else if(code<160) return -1;
+ else if(code<383) return table_160[code-160];
+ else if(code==402) return 99;
+ else if(code==486) return 480;
+ else if(code==487) return 379;
+ else if(code==501) return 384;
+ else if(code==711) return 139;
+ else if(code<728) return -1;
+ else if(code<734) return table_728[code-728];
+ else if(code<915) return -1;
+ else if(code<967) return table_915[code-915];
+ else if(code<8211) return -1;
+ else if(code<8253) return table_8211[code-8211];
+ else if(code<8319) return -1;
+ else if(code<8360) return table_8319[code-8319];
+ else if(code<8592) return -1;
+ else if(code<8598) return table_8592[code-8592];
+ else if(code==8616) return 340;
+ else if(code<8712) return -1;
+ else if(code<8751) return table_8712[code-8712];
+ else if(code<8800) return -1;
+ else if(code<8806) return table_8800[code-8800];
+ else if(code==8976) return 310;
+ else if(code==8992) return 300;
+ else if(code==8993) return 301;
+ else if(code==9400) return 332;
+ else if(code==9415) return 333;
+ else if(code==9473) return 355;
+ else if(code==9475) return 356;
+ else if(code<9600) return -1;
+ else if(code<9690) return table_9600[code-9600];
+ else if(code==9711) return 343;
+ else if(code<9784) return -1;
+ else if(code<9795) return table_9784[code-9784];
+ else if(code<9824) return -1;
+ else if(code<9836) return table_9824[code-9824];
+ else if(code<64256) return -1;
+ else if(code<64261) return table_64256[code-64256];
+ else return -1;
+}
+
diff --git a/nx-X11/lib/font/Speedo/bics-unicode.h b/nx-X11/lib/font/Speedo/bics-unicode.h
new file mode 100644
index 000000000..90fa1885b
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/bics-unicode.h
@@ -0,0 +1,3 @@
+/* $XFree86$ */
+
+int unicode_to_bics(unsigned);
diff --git a/nx-X11/lib/font/Speedo/do_char.c b/nx-X11/lib/font/Speedo/do_char.c
new file mode 100644
index 000000000..410d6339a
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/do_char.c
@@ -0,0 +1,1016 @@
+/* $Xorg: do_char.c,v 1.3 2000/08/17 19:46:24 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/do_char.c,v 1.3 2001/01/17 19:43:17 dawes Exp $ */
+
+/***************************** D O - C H A R . C *****************************
+ * *
+ * This is the top level module for processing one simple or composite *
+ * character.
+ * *
+ ****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "spdo_prv.h" /* General definitions for Speedo */
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** STATIC FUNCTIONS *****/
+
+static boolean sp_make_simp_char(PROTO_DECL2 ufix8 FONTFAR *pointer,ufix8 format);
+static boolean sp_make_comp_char(PROTO_DECL2 ufix8 FONTFAR *pointer);
+static ufix8 FONTFAR *sp_get_char_org(PROTO_DECL2 ufix16 char_index,boolean top_level);
+static fix15 sp_get_posn_arg(PROTO_DECL2 ufix8 FONTFAR *STACKFAR *ppointer,ufix8 format);
+static fix15 sp_get_scale_arg(PROTO_DECL2 ufix8 FONTFAR *STACKFAR *ppointer,ufix8 format);
+
+
+FUNCTION ufix16 get_char_id(
+GDECL
+ufix16 char_index) /* Index to character in char directory */
+/*
+ * Returns character id for specified character index in currently
+ * selected font.
+ * Reports Error 10 and returns 0 if no font selected.
+ * Reports Error 12 and returns 0 if character data not available.
+ */
+{
+ufix8 FONTFAR *pointer; /* Pointer to character data */
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return (ufix16)0; /* Return zero character id */
+ }
+
+pointer = sp_get_char_org(char_index, TRUE); /* Get pointer to character data */
+if (pointer == NULL) /* Character data not available? */
+ {
+ report_error(12); /* Report character data not avail */
+ return (ufix16)0; /* Return zero character id */
+ }
+
+return 0xffff & NEXT_WORD(pointer); /* Return character id */
+}
+
+
+#if INCL_METRICS
+FUNCTION fix31 get_char_width(
+GDECL
+ufix16 char_index) /* Index to character in char directory */
+/*
+ * Returns character set width for specified character index in currently
+ * selected font in units of 1/65536 em.
+ * Reports Error 10 and returns 0 if no font selected.
+ * Reports Error 12 and returns 0 if character data not available.
+ */
+{
+ufix8 FONTFAR *pointer; /* Pointer to character data */
+fix31 set_width; /* Set width of character */
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return (fix31)0; /* Return zero character width */
+ }
+
+pointer = sp_get_char_org(char_index, TRUE); /* Get pointer to character data */
+if (pointer == NULL) /* Character data not available? */
+ {
+ report_error(12); /* Report character data not avail */
+ return (fix31)0; /* Return zero character width */
+ }
+
+pointer += 2; /* Skip over character id */
+set_width = (fix31)NEXT_WORD(pointer); /* Read set width and Convert units */
+set_width = ((set_width << 16) + (sp_globals.metric_resolution >> 1)) / sp_globals.metric_resolution;
+return set_width; /* Return in 1/65536 em units */
+}
+#endif
+
+#if INCL_METRICS
+FUNCTION fix15 get_track_kern(
+GDECL
+fix15 track, /* Track required (0 - 3) */
+fix15 point_size) /* Point size (units of whole points) */
+/*
+ * Returns inter-character spacing adjustment in units of 1/256
+ * points for the specified kerning track and point size.
+ * If the specified point size is larger than the maximum point
+ * size for the specified track, the adjustment for the maximum
+ * point size is used.
+ * If the specified point size is smaller than the minimum point
+ * size for the specified track, the adjustment for the minimum
+ * point size is used.
+ * If the specified point size is between the minimum point size
+ * and the maximum point size for the specified track, the
+ * adjustment is interpolated linearly between the minimum and
+ * maximum adjustments.
+ * Reports Error 10 and returns 0 if no font selected.
+ * Reports Error 13 and returns 0 if track kerning data not in font.
+ */
+{
+ufix8 FONTFAR *pointer; /* Pointer to character data */
+fix15 no_tracks; /* Number of kerning tracks in font */
+ufix8 format; /* Track kerning format byte */
+fix15 i; /* Track counter */
+fix15 min_pt_size = 0; /* Minimum point size for track */
+fix15 max_pt_size = 0; /* Maximum point size for track */
+fix15 min_adj = 0; /* Adjustment for min point size */
+fix15 max_adj = 0; /* Adjustment for max point size */
+fix31 delta_pt_size; /* Max point size - min point size */
+fix31 delta_adj; /* Min adjustment - max adjustment */
+fix15 adj = 0; /* Interpolated adjustment */
+
+if (track == 0) /* Track zero selected? */
+ {
+ return adj; /* Return zero track kerning adjustment */
+ }
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return adj; /* Return zero track kerning adjustment */
+ }
+
+no_tracks = sp_globals.kern.no_tracks; /* Number of kerning tracks */
+if (track > no_tracks) /* Required track not available? */
+ {
+ report_error(13); /* Report track kerning data not avail */
+ return adj; /* Return zero track kerning adjustment */
+ }
+
+pointer = sp_globals.kern.tkorg; /* Point to start of track kern data */
+for (i = 0; i < track; i++) /* Read until track required is read */
+ {
+ format = NEXT_BYTE(pointer); /* Read track kerning format byte */
+ min_pt_size = (format & BIT0)?
+ NEXT_WORD(pointer):
+ (fix15)NEXT_BYTE(pointer);
+ min_adj = (format & BIT1)?
+ NEXT_WORD(pointer):
+ (fix15)NEXT_BYTE(pointer);
+ max_pt_size = (format & BIT2)?
+ NEXT_WORD(pointer):
+ (fix15)NEXT_BYTE(pointer);
+ max_adj = (format & BIT3)?
+ NEXT_WORD(pointer):
+ (fix15)NEXT_BYTE(pointer);
+ }
+
+if (point_size <= min_pt_size) /* Smaller than minimum point size? */
+ {
+ return min_adj; /* Return minimum adjustment (1/256 points) */
+ }
+
+if (point_size >= max_pt_size) /* Larger than maximum point size? */
+ {
+ return max_adj; /* Return maximum adjustment (1/256 points) */
+ }
+
+delta_pt_size = (fix31)(max_pt_size - min_pt_size);
+delta_adj = (fix31)(min_adj - max_adj);
+adj = (fix15)(min_adj -
+ (((fix31)(point_size - min_pt_size) * delta_adj +
+ (delta_pt_size >> 1)) / delta_pt_size));
+return adj; /* Return interpolated adjustment (1/256 points) */
+}
+#endif
+
+#if INCL_METRICS
+FUNCTION fix31 get_pair_kern(
+GDECL
+ufix16 char_index1, /* Index to first character in char directory */
+ufix16 char_index2) /* Index to second character in char directory */
+/*
+ * Returns inter-character spacing adjustment in units of 1/65536 em
+ * for the specified pair of characters.
+ * Reports Error 10 and returns 0 if no font selected.
+ * Reports Error 14 and returns 0 if pair kerning data not in font.
+ */
+{
+ufix8 FONTFAR *origin; /* Pointer to first kerning pair record */
+ufix8 FONTFAR *pointer; /* Pointer to character data */
+ufix16 tmpufix16; /* Temporary workspace */
+fix15 no_pairs; /* Number of kerning pairs in font */
+ufix8 format; /* Track kerning format byte */
+boolean long_id; /* TRUE if 2-byte character ids */
+fix15 rec_size; /* Number of bytes in kern pair record */
+fix15 n; /* Number of remaining kern pairs */
+fix15 nn; /* Number of kern pairs in first partition */
+fix15 base; /* Index to first record in rem kern pairs */
+fix15 i; /* Index to kern pair being tested */
+fix31 adj = 0; /* Returned value of adjustment */
+fix15 adj_base = 0; /* Adjustment base for relative adjustments */
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return adj; /* Return zero pair kerning adjustment */
+ }
+
+no_pairs = sp_globals.kern.no_pairs; /* Number of kerning pairs */
+if (no_pairs == 0) /* Pair kerning data not available? */
+ {
+ report_error(14); /* Report pair kerning data not avail */
+ return adj; /* Return zero pair kerning adjustment */
+ }
+
+pointer = sp_globals.kern.pkorg; /* Point to start of pair kern data */
+format = NEXT_BYTE(pointer); /* Read pair kerning format byte */
+if (!(format & BIT0)) /* One-byte adjustment values? */
+ adj_base = NEXT_WORD(pointer); /* Read base adjustment */
+origin = pointer; /* First byte of kerning pair data */
+rec_size = format + 3; /* Compute kerning pair record size */
+long_id = format & BIT1; /* Set flag for 2-byte char index */
+
+n = no_pairs; /* Consider all kerning pairs */
+base = 0; /* Set base at first kern pair record */
+while (n != 0) /* While 1 or more kern pairs remain ... */
+ {
+ nn = n >> 1; /* Size of first partition */
+ i = base + nn; /* Index to record to be tested */
+ pointer = origin + (i * rec_size);
+ tmpufix16 = NEXT_CHNDX(pointer, long_id);
+ if (char_index1 < tmpufix16)
+ {
+ n = nn; /* Number remaining in first partition */
+ continue;
+ }
+ if (char_index1 > tmpufix16)
+ {
+ n -= nn + 1; /* Number remaining in second partition */
+ base = i + 1; /* Base index for second partition */
+ continue;
+ }
+ tmpufix16 = NEXT_CHNDX(pointer, long_id);
+ if (char_index2 < tmpufix16)
+ {
+ n = nn; /* Number remaining in first partition */
+ continue;
+ }
+ if (char_index2 > tmpufix16)
+ {
+ n -= nn + 1; /* Number remaining in second partition */
+ base = i + 1; /* Base index for second partition */
+ continue;
+ }
+ adj = (format & BIT0)?
+ (fix31)NEXT_WORD(pointer):
+ (fix31)(adj_base + (fix15)NEXT_BYTE(pointer));
+ adj = ((adj << 16) + (sp_globals.orus_per_em >> 1)) / sp_globals.orus_per_em; /* Convert units */
+ n = 0; /* No more to consider */
+ }
+return adj; /* Return pair kerning adjustment */
+}
+#endif
+
+
+#if INCL_METRICS
+#ifdef old
+FUNCTION boolean get_char_bbox(
+GDECL
+ufix16 char_index,
+bbox_t *bbox)
+{
+/*
+ * returns true if character exists, false if it doesn't
+ * provides transformed character bounding box in 1/65536 pixels
+ * in the provided bbox_t structure. Bounding box may be
+ * conservative in the event that the transformation is not
+ * normal or the character is compound.
+ */
+
+ufix8 FONTFAR *pointer;
+fix15 tmp;
+point_t Pmin, Pmax;
+
+#if REENTRANT_ALLOC
+plaid_t plaid;
+sp_globals.plaid = &plaid;
+#endif
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return FALSE; /* Error return */
+ }
+
+init_tcb(); /* Initialize transformation control block */
+
+pointer = sp_get_char_org(char_index, TRUE); /* Point to start of character data */
+if (pointer == NULL) /* Character data not available? */
+ {
+ report_error(12); /* Report character data not avail */
+ return FALSE; /* Error return */
+ }
+
+pointer += 2; /* Skip over character id */
+tmp = NEXT_WORD(pointer); /* Read set width */
+
+tmp = NEXT_BYTE(pointer);
+if (tmp & BIT1) /* Optional data in header? */
+ {
+ tmp = (ufix8)NEXT_BYTE(pointer); /* Read size of optional data */
+ pointer += tmp; /* Skip optional data */
+ }
+
+pointer = plaid_tcb(pointer, tmp); /* Process plaid data */
+pointer = read_bbox(pointer, &Pmin, &Pmax,(boolean)FALSE); /* Read bounding box */
+bbox->xmin = (fix31)Pmin.x << sp_globals.poshift;
+bbox->xmax = (fix31)Pmax.x << sp_globals.poshift;
+bbox->ymin = (fix31)Pmin.y << sp_globals.poshift;
+bbox->ymax = (fix31)Pmax.y << sp_globals.poshift;
+return TRUE;
+}
+
+#else /* new code, 4/25/91 */
+
+FUNCTION boolean get_char_bbox(
+GDECL
+ufix16 char_index,
+bbox_t *bbox)
+{
+/*
+ * returns true if character exists, false if it doesn't
+ * provides transformed character bounding box in 1/65536 pixels
+ * in the provided bbox_t structure. Bounding box may be
+ * conservative in the event that the transformation is not
+ * normal or the character is compound.
+ */
+
+ufix8 FONTFAR *pointer;
+fix15 tmp;
+fix15 format;
+ufix16 pix_adj;
+point_t Pmin, Pmax;
+
+#if REENTRANT_ALLOC
+plaid_t plaid;
+sp_globals.plaid = &plaid;
+#endif
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return FALSE; /* Error return */
+ }
+
+init_tcb(); /* Initialize transformation control block */
+
+pointer = sp_get_char_org(char_index, TRUE); /* Point to start of character data */
+if (pointer == NULL) /* Character data not available? */
+ {
+ report_error(12); /* Report character data not avail */
+ return FALSE; /* Error return */
+ }
+
+pointer += 2; /* Skip over character id */
+tmp = NEXT_WORD(pointer); /* Read set width */
+
+format = NEXT_BYTE(pointer);
+if (format & BIT1) /* Optional data in header? */
+ {
+ tmp = (ufix8)NEXT_BYTE(pointer); /* Read size of optional data */
+ pointer += tmp; /* Skip optional data */
+ }
+
+if (format & BIT0)
+ {
+ pix_adj = sp_globals.onepix << 1; /* Allow 2 pixel expansion ... */
+ }
+else
+ {
+ pix_adj = 0;
+ }
+
+pointer = plaid_tcb(pointer, format); /* Process plaid data */
+pointer = read_bbox(pointer, &Pmin, &Pmax,(boolean)FALSE); /* Read bounding box */
+
+Pmin.x -= pix_adj; /* ... of components of ... */
+Pmin.y -= pix_adj; /* ... compound ... */
+Pmax.x += pix_adj; /* ... character ... */
+Pmax.y += pix_adj; /* ... bounding box. */
+
+
+bbox->xmin = (fix31)Pmin.x << sp_globals.poshift;
+bbox->xmax = (fix31)Pmax.x << sp_globals.poshift;
+bbox->ymin = (fix31)Pmin.y << sp_globals.poshift;
+bbox->ymax = (fix31)Pmax.y << sp_globals.poshift;
+return TRUE;
+}
+#endif /* new code */
+
+#endif
+
+
+#if INCL_ISW
+FUNCTION boolean make_char_isw(
+GDECL
+ufix16 char_index,
+ufix32 imported_setwidth)
+{
+fix15 xmin; /* Minimum X ORU value in font */
+fix15 xmax; /* Maximum X ORU value in font */
+fix15 ymin; /* Minimum Y ORU value in font */
+fix15 ymax; /* Maximum Y ORU value in font */
+ufix16 return_value;
+
+sp_globals.import_setwidth_act = TRUE;
+/* convert imported width to orus */
+sp_globals.imported_width = (sp_globals.metric_resolution *
+ imported_setwidth) >> 16;
+return_value = do_make_char(char_index);
+
+if (sp_globals.isw_modified_constants)
+ {
+ /* reset fixed point constants */
+ xmin = read_word_u(sp_globals.font_org + FH_FXMIN);
+ ymin = read_word_u(sp_globals.font_org + FH_FYMIN);
+ ymax = read_word_u(sp_globals.font_org + FH_FYMAX);
+ sp_globals.constr.data_valid = FALSE;
+ xmax = read_word_u(sp_globals.font_org + FH_FXMAX);
+ if (!setup_consts(xmin,xmax,ymin,ymax))
+ {
+ report_error(3); /* Requested specs out of range */
+ return FALSE;
+ }
+ }
+return (return_value);
+}
+
+FUNCTION boolean make_char(
+GDECL
+ufix16 char_index) /* Index to character in char directory */
+{
+sp_globals.import_setwidth_act = FALSE;
+return (do_make_char(char_index));
+}
+
+FUNCTION static boolean do_make_char(GDECL ufix16 char_index)
+#else
+FUNCTION boolean make_char(GDECL ufix16 char_index)
+#endif
+/*
+ * Outputs specified character using the currently selected font and
+ * scaling and output specifications.
+ * Reports Error 10 and returns FALSE if no font specifications
+ * previously set.
+ * Reports Error 12 and returns FALSE if character data not available.
+ */
+{
+ufix8 FONTFAR *pointer; /* Pointer to character data */
+fix15 x_orus;
+fix15 tmpfix15;
+ufix8 format;
+
+#if INCL_ISW
+sp_globals.isw_modified_constants = FALSE;
+#endif
+
+#if REENTRANT_ALLOC
+
+plaid_t plaid;
+
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+intercepts_t intercepts;
+sp_globals.intercepts = &intercepts;
+#endif
+
+sp_globals.plaid = &plaid;
+#endif
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return FALSE; /* Error return */
+ }
+
+#if INCL_MULTIDEV
+#if INCL_OUTLINE
+if (sp_globals.output_mode == MODE_OUTLINE && !sp_globals.outline_device_set)
+ {
+ report_error(2);
+ return FALSE;
+ }
+else
+#endif
+ if (!sp_globals.bitmap_device_set)
+ {
+ report_error(2);
+ return FALSE;
+ }
+#endif
+
+
+init_tcb(); /* Initialize transformation control block */
+
+pointer = sp_get_char_org(char_index, TRUE); /* Point to start of character data */
+SHOW(pointer);
+if (pointer == NULL) /* Character data not available? */
+ {
+ report_error(12); /* Report character data not avail */
+ return FALSE; /* Error return */
+ }
+
+pointer += 2; /* Skip over character id */
+x_orus = NEXT_WORD(pointer); /* Read set width */
+#if INCL_SQUEEZING || INCL_ISW
+sp_globals.setwidth_orus = x_orus;
+#endif
+
+#if INCL_ISW
+if (sp_globals.import_setwidth_act)
+ x_orus = sp_globals.imported_width;
+#endif
+sp_globals.Psw.x = (fix15)((fix31)
+ (((fix31)x_orus * (sp_globals.specs.xxmult>>16) +
+ ( ((fix31)x_orus * (sp_globals.specs.xxmult&0xffffL) )>>16)
+ ) << sp_globals.pixshift) / sp_globals.metric_resolution);
+
+sp_globals.Psw.y = (fix15)(
+ (fix31)(
+ ((fix31)x_orus * (sp_globals.specs.yxmult>>16) +
+ ( ((fix31)x_orus * (sp_globals.specs.yxmult&0xffffL) )>>16)
+ ) << sp_globals.pixshift) / sp_globals.metric_resolution);
+
+format = NEXT_BYTE(pointer);
+if (format & BIT1) /* Optional data in header? */
+ {
+ tmpfix15 = (ufix8)NEXT_BYTE(pointer); /* Read size of optional data */
+ pointer += tmpfix15; /* Skip optional data */
+ }
+if (format & BIT0)
+ {
+ return sp_make_comp_char(pointer); /* Output compound character */
+ }
+else
+ {
+ return sp_make_simp_char(pointer, format); /* Output simple character */
+ }
+}
+
+FUNCTION static boolean sp_make_simp_char(
+GDECL
+ufix8 FONTFAR *pointer, /* Pointer to first byte of position argument */
+ufix8 format) /* Character format byte */
+/*
+ * Called by sp_make_char() to output a simple (non-compound) character.
+ * Returns TRUE on completion.
+ */
+{
+point_t Pmin, Pmax; /* Transformed corners of bounding box */
+#if INCL_SQUEEZING || INCL_ISW
+ufix8 FONTFAR *save_pointer;
+#endif
+#if INCL_ISW
+fix31 char_width;
+fix31 isw_scale;
+#endif
+
+#if INCL_SQUEEZING
+sp_globals.squeezing_compound = FALSE;
+if ((sp_globals.pspecs->flags & SQUEEZE_LEFT) ||
+ (sp_globals.pspecs->flags & SQUEEZE_RIGHT) ||
+ (sp_globals.pspecs->flags & SQUEEZE_TOP) ||
+ (sp_globals.pspecs->flags & SQUEEZE_BOTTOM) )
+ {
+ /* get the bounding box data before processing the character */
+ save_pointer = pointer;
+ preview_bounding_box (pointer, format);
+ pointer = save_pointer;
+ }
+#endif
+#if (INCL_ISW)
+if (sp_globals.import_setwidth_act)
+ {
+ save_pointer = pointer;
+ preview_bounding_box (pointer, format);
+ pointer = save_pointer;
+ /* make sure I'm not going to get fixed point overflow */
+ isw_scale = compute_isw_scale();
+ if (sp_globals.bbox_xmin_orus < 0)
+ char_width = SQUEEZE_MULT((sp_globals.bbox_xmax_orus - sp_globals.bbox_xmin_orus), isw_scale);
+ else
+ char_width = SQUEEZE_MULT(sp_globals.bbox_xmax_orus, isw_scale);
+ if (char_width >= sp_globals.isw_xmax)
+ if (!reset_xmax(char_width))
+ return FALSE;
+ }
+#endif
+pointer = plaid_tcb(pointer, format); /* Process plaid data */
+pointer = read_bbox(pointer, &Pmin, &Pmax, FALSE); /* Read bounding box */
+if (fn_begin_char(sp_globals.Psw, Pmin, Pmax)) /* Signal start of character output */
+ {
+ do
+ {
+ proc_outl_data(pointer); /* Process outline data */
+ }
+ while (!fn_end_char()); /* Repeat if not done */
+ }
+return TRUE;
+}
+
+FUNCTION static boolean sp_make_comp_char(
+GDECL
+ufix8 FONTFAR *pointer) /* Pointer to first byte of position argument */
+/*
+ * Called by sp_make_char() to output a compound character.
+ * Returns FALSE if data for any sub-character is not available.
+ * Returns TRUE if output completed with no error.
+ */
+{
+point_t Pmin, Pmax; /* Transformed corners of bounding box */
+point_t Pssw; /* Transformed escapement vector */
+ufix8 FONTFAR *pointer_sav; /* Saved pointer to compound character data */
+ufix8 FONTFAR *sub_pointer; /* Pointer to sub-character data */
+ufix8 format; /* Format of DOCH instruction */
+ufix16 sub_char_index; /* Index to sub-character in character directory */
+fix15 x_posn; /* X position of sub-character (outline res units) */
+fix15 y_posn; /* Y position of sub-character (outline res units) */
+fix15 x_scale; /* X scale factor of sub-character (scale units) */
+fix15 y_scale; /* Y scale factor of sub-character (scale units) */
+fix15 tmpfix15; /* Temporary workspace */
+fix15 x_orus; /* Set width in outline resolution units */
+fix15 pix_adj; /* Pixel adjustment to compound char bounding box */
+#if INCL_SQUEEZING
+fix31 x_factor, x_offset, top_scale, bottom_scale;
+boolean squeezed_x, squeezed_y;
+#endif
+#if INCL_SQUEEZING || INCL_ISW
+fix15 x_offset_pix;
+#endif
+#if INCL_ISW
+fix31 char_width;
+fix31 isw_scale;
+#endif
+
+
+#if INCL_SQUEEZING
+sp_globals.squeezing_compound = TRUE;
+#endif
+pointer = read_bbox(pointer, &Pmin, &Pmax, TRUE); /* Read bounding box data */
+pix_adj = sp_globals.onepix << 1; /* Allow 2 pixel expansion ... */
+Pmin.x -= pix_adj; /* ... of components of ... */
+Pmin.y -= pix_adj; /* ... compound ... */
+Pmax.x += pix_adj; /* ... character ... */
+Pmax.y += pix_adj; /* ... bounding box. */
+
+#if INCL_SQUEEZING
+/* scale the bounding box if necessary before calling begin_char */
+squeezed_x = calculate_x_scale(&x_factor, &x_offset, 0);
+squeezed_y = calculate_y_scale(&top_scale, &bottom_scale,0,0);
+
+if (squeezed_x)
+ { /* scale the x coordinates of the bbox */
+ x_offset_pix = (fix15)(((x_offset >> 16) * sp_globals.tcb0.xppo)
+ >> sp_globals.mpshift);
+ if ((x_offset_pix >0) && (x_offset_pix < sp_globals.onepix))
+ x_offset_pix = sp_globals.onepix;
+ Pmin.x = SQUEEZE_MULT (x_factor, Pmin.x) + x_offset_pix - pix_adj;
+ Pmax.x = SQUEEZE_MULT (x_factor, Pmax.x) + x_offset_pix + pix_adj;
+ }
+if (squeezed_y)
+ { /* scale the y coordinates of the bbox */
+ if ((Pmin.y) < 0)
+ Pmin.y = SQUEEZE_MULT (bottom_scale, Pmin.y) - pix_adj;
+ else
+ Pmin.y = SQUEEZE_MULT (top_scale, Pmin.y) - pix_adj;
+ if ((Pmax.y) < 0)
+ Pmax.y = SQUEEZE_MULT (bottom_scale, Pmax.y) + pix_adj;
+ else
+ Pmax.y = SQUEEZE_MULT (top_scale, Pmax.y) + pix_adj;
+ }
+#endif
+#if (INCL_ISW)
+if (sp_globals.import_setwidth_act)
+ {
+ /* make sure I'm not going to get fixed point overflow */
+ isw_scale = ((fix31)sp_globals.imported_width << 16)/
+ (fix31)sp_globals.setwidth_orus;
+ char_width = SQUEEZE_MULT((sp_globals.bbox_xmax_orus -
+ sp_globals.bbox_xmin_orus),
+isw_scale);
+ if (char_width >= sp_globals.isw_xmax)
+ if (!reset_xmax(char_width))
+ return FALSE;
+ }
+#endif
+
+if (fn_begin_char(sp_globals.Psw, Pmin, Pmax)) /* Signal start of character data */
+ {
+ pointer_sav = pointer;
+ do
+ {
+ pointer = pointer_sav; /* Point to next DOCH or END instruction */
+ while ((format = NEXT_BYTE(pointer))) /* DOCH instruction? */
+ {
+ init_tcb(); /* Initialize transformation control block */
+ x_posn = sp_get_posn_arg(&pointer, format);
+ y_posn = sp_get_posn_arg(&pointer, (ufix8)(format >> 2));
+ x_scale = sp_get_scale_arg(&pointer, (ufix8)(format & BIT4));
+ y_scale = sp_get_scale_arg(&pointer, (ufix8)(format & BIT5));
+ scale_tcb(&sp_globals.tcb, x_posn, y_posn, x_scale, y_scale); /* Scale for sub-char */
+ sub_char_index = (format & BIT6)? /* Read sub-char index */
+ 0xffff & NEXT_WORD(pointer):
+ 0xffff & NEXT_BYTE(pointer);
+ sub_pointer = sp_get_char_org(sub_char_index, FALSE); /* Point to start of sub-char */
+ if (sub_pointer == NULL) /* Character data not available? */
+ {
+ return FALSE; /* Abort character output */
+ }
+ sub_pointer += 2; /* Skip over character id */
+ x_orus = NEXT_WORD(sub_pointer); /* Read set_width of sub-character */
+
+ Pssw.x = (fix15)(
+ (fix31)(
+ ((fix31)x_orus * (sp_globals.specs.xxmult>>16) +
+ ( ((fix31)x_orus * (sp_globals.specs.xxmult&0xffffL) )>>16)
+ ) << sp_globals.pixshift) / sp_globals.metric_resolution);
+ Pssw.y = (fix15)(
+ (fix31)(
+ ((fix31)x_orus * (sp_globals.specs.yxmult>>16) +
+ ( ((fix31)x_orus * (sp_globals.specs.yxmult&0xffffL) )>>16)
+ ) << sp_globals.pixshift) / sp_globals.metric_resolution);
+
+ format = NEXT_BYTE(sub_pointer); /* Read sub-character format */
+ if (format & BIT1) /* Optional data in header? */
+ {
+ tmpfix15 = (ufix8)NEXT_BYTE(sub_pointer); /* Read size of optional data */
+ sub_pointer += tmpfix15; /* Skip optional data */
+ }
+ sub_pointer = plaid_tcb(sub_pointer, format); /* Process sub-character plaid data */
+ sub_pointer = read_bbox(sub_pointer, &Pmin, &Pmax, FALSE); /* Read bounding box */
+ fn_begin_sub_char(Pssw, Pmin, Pmax); /* Signal start of sub-character data */
+ proc_outl_data(sub_pointer); /* Process sub-character data */
+ fn_end_sub_char(); /* Signal end of sub-character data */
+ }
+ }
+ while (!fn_end_char()); /* Signal end of character; repeat if required */
+ }
+return TRUE;
+}
+
+#if INCL_LCD /* Dynamic load character data supported? */
+FUNCTION static ufix8 FONTFAR *sp_get_char_org(
+GDECL
+ufix16 char_index, /* Index of character to be accessed */
+boolean top_level) /* Not a compound character element */
+/*
+ * Called by sp_get_char_id(), sp_get_char_width(), sp_make_char() and
+ * sp_make_comp_char() to get a pointer to the start of the character data
+ * for the specified character index.
+ * Version for configuration supporting dynamic character data loading.
+ * Calls load_char_data() to load character data if not already loaded
+ * as part of the original font buffer.
+ * Returns NULL if character data not available
+ */
+{
+buff_t *pchar_data; /* Buffer descriptor requested */
+ufix8 FONTFAR *pointer; /* Pointer into character directory */
+ufix8 format; /* Character directory format byte */
+fix31 char_offset; /* Offset of char data from start of font file */
+fix31 next_char_offset; /* Offset of char data from start of font file */
+fix15 no_bytes; /* Number of bytes required for char data */
+
+if (top_level) /* Not element of compound char? */
+ {
+ if (char_index < sp_globals.first_char_idx) /* Before start of character set? */
+ return NULL;
+ char_index -= sp_globals.first_char_idx;
+ if (char_index >= sp_globals.no_chars_avail) /* Beyond end of character set? */
+ return NULL;
+ sp_globals.cb_offset = 0; /* Reset char buffer offset */
+ }
+
+pointer = sp_globals.pchar_dir;
+format = NEXT_BYTE(pointer); /* Read character directory format byte */
+pointer += char_index << 1; /* Point to indexed character entry */
+if (format) /* 3-byte entries in char directory? */
+ {
+ pointer += char_index; /* Adjust for 3-byte entries */
+ char_offset = read_long(pointer); /* Read file offset to char data */
+ next_char_offset = read_long(pointer + 3); /* Read offset to next char */
+ }
+else
+ {
+ char_offset = (fix31)(0xffff & NEXT_WORD(pointer)); /* Read file offset to char data */
+ next_char_offset = (fix31)(0xffff & NEXT_WORD(pointer)); /* Read offset to next char */
+ }
+
+no_bytes = next_char_offset - char_offset;
+if (no_bytes == 0) /* Character not in directory? */
+ return NULL;
+
+if (next_char_offset <= sp_globals.font_buff_size)/* Character data already in font buffer? */
+ return sp_globals.pfont->org + char_offset; /* Return pointer into font buffer */
+
+pchar_data = load_char_data(char_offset, no_bytes, sp_globals.cb_offset); /* Request char data load */
+if (pchar_data->no_bytes < no_bytes) /* Correct number of bytes loaded? */
+ return NULL;
+
+if (top_level) /* Not element of compound char? */
+ {
+ sp_globals.cb_offset = no_bytes;
+ }
+
+return pchar_data->org; /* Return pointer into character data buffer */
+}
+#endif
+
+#if INCL_LCD
+#else /* Dynamic load character data not supported? */
+FUNCTION static ufix8 FONTFAR *sp_get_char_org(
+GDECL
+ufix16 char_index, /* Index of character to be accessed */
+boolean top_level) /* Not a compound character element */
+/*
+ * Called by sp_get_char_id(), sp_get_char_width(), sp_make_char() and
+ * sp_make_comp_char() to get a pointer to the start of the character data
+ * for the specified character index.
+ * Version for configuration not supporting dynamic character data loading.
+ * Returns NULL if character data not available
+ */
+{
+ufix8 FONTFAR *pointer; /* Pointer into character directory */
+ufix8 format; /* Character directory format byte */
+fix31 char_offset; /* Offset of char data from start of font file */
+fix31 next_char_offset; /* Offset of char data from start of font file */
+fix15 no_bytes; /* Number of bytes required for char data */
+
+if (top_level) /* Not element of compound char? */
+ {
+ if (char_index < sp_globals.first_char_idx) /* Before start of character set? */
+ return NULL;
+ char_index -= sp_globals.first_char_idx;
+ if (char_index >= sp_globals.no_chars_avail) /* Beyond end of character set? */
+ return NULL;
+ }
+
+pointer = sp_globals.pchar_dir;
+format = NEXT_BYTE(pointer); /* Read character directory format byte */
+pointer += char_index << 1; /* Point to indexed character entry */
+if (format) /* 3-byte entries in char directory? */
+ {
+ pointer += char_index; /* Adjust for 3-byte entries */
+ char_offset = read_long(pointer); /* Read file offset to char data */
+ next_char_offset = read_long(pointer + 3); /* Read offset to next char */
+ }
+else
+ {
+ char_offset = (fix31)(0xffff & NEXT_WORD(pointer)); /* Read file offset to char data */
+ next_char_offset = (fix31)(0xffff & NEXT_WORD(pointer)); /* Read offset to next char */
+ }
+
+no_bytes = next_char_offset - char_offset;
+if (no_bytes == 0) /* Character not in directory? */
+ return NULL;
+
+return sp_globals.pfont->org + char_offset; /* Return pointer into font buffer */
+}
+#endif
+
+
+FUNCTION static fix15 sp_get_posn_arg(
+GDECL
+ufix8 FONTFAR * STACKFAR *ppointer, /* Pointer to first byte of position argument */
+ufix8 format) /* Format of DOCH arguments */
+/*
+ * Called by sp_make_comp_char() to read a position argument from the
+ * specified point in the font/char buffer.
+ * Updates pointer to byte following position argument.
+ * Returns value of position argument in outline resolution units
+ */
+{
+switch (format & 0x03)
+ {
+case 1:
+ return NEXT_WORD(*ppointer);
+
+case 2:
+ return (fix15)((fix7)NEXT_BYTE(*ppointer));
+
+default:
+ return (fix15)0;
+ }
+}
+
+FUNCTION static fix15 sp_get_scale_arg(
+GDECL
+ufix8 FONTFAR *STACKFAR *ppointer, /* Pointer to first byte of position argument */
+ufix8 format) /* Format of DOCH arguments */
+/*
+ * Called by sp_make_comp_char() to read a scale argument from the
+ * specified point in the font/char buffer.
+ * Updates pointer to byte following scale argument.
+ * Returns value of scale argument in scale units (normally 1/4096)
+ */
+{
+if (format)
+ return NEXT_WORD(*ppointer);
+else
+ return (fix15)ONE_SCALE;
+}
+#if INCL_ISW || INCL_SQUEEZING
+FUNCTION static void preview_bounding_box(
+GDECL
+ufix8 FONTFAR *pointer, /* Pointer to first byte of position argument */
+ufix8 format) /* Character format byte */
+{
+point_t Pmin, Pmax; /* Transformed corners of bounding box */
+
+ sp_globals.no_X_orus = (format & BIT2)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+ sp_globals.no_Y_orus = (format & BIT3)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+ pointer = read_oru_table(pointer);
+
+ /* Skip over control zone table */
+ pointer = skip_control_zone(pointer,format);
+
+ /* Skip over interpolation table */
+ pointer = skip_interpolation_table(pointer,format);
+ /* get_args has a pathological need for this value to be set */
+ sp_globals.Y_edge_org = sp_globals.no_X_orus;
+ pointer = read_bbox(pointer, &Pmin, &Pmax, TRUE); /* Read bounding bo
+x */
+
+}
+#endif
+#if INCL_ISW
+FUNCTION static boolean reset_xmax(
+GDECL
+fix31 xmax)
+
+{
+fix15 xmin; /* Minimum X ORU value in font */
+fix15 ymin; /* Minimum Y ORU value in font */
+fix15 ymax; /* Maximum Y ORU value in font */
+
+
+sp_globals.isw_modified_constants = TRUE;
+xmin = read_word_u(sp_globals.font_org + FH_FXMIN);
+ymin = read_word_u(sp_globals.font_org + FH_FYMIN);
+ymax = read_word_u(sp_globals.font_org + FH_FYMAX);
+
+if (!setup_consts(xmin,xmax,ymin,ymax))
+ {
+ report_error(3); /* Requested specs out of range */
+ return FALSE;
+ }
+sp_globals.constr.data_valid = FALSE;
+/* recompute setwidth */
+sp_globals.Psw.x = (fix15)((fix31)(
+ ((fix31)sp_globals.imported_width * (sp_globals.specs.xxmult>>16) +
+ ( ((fix31)sp_globals.imported_width *
+ (sp_globals.specs.xxmult&0xffffL) )>>16)
+ ) << sp_globals.pixshift) / sp_globals.metric_resolution);
+sp_globals.Psw.y = (fix15)(
+ (fix31)(
+ ((fix31)sp_globals.imported_width * (sp_globals.specs.yxmult>>16) +
+ ( ((fix31)sp_globals.imported_width * (sp_globals.specs.yxmult&0xffffL) )>>16)
+ ) << sp_globals.pixshift) / sp_globals.metric_resolution);
+
+return TRUE;
+}
+#endif
diff --git a/nx-X11/lib/font/Speedo/do_trns.c b/nx-X11/lib/font/Speedo/do_trns.c
new file mode 100644
index 000000000..2e0f1dbed
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/do_trns.c
@@ -0,0 +1,512 @@
+/* $Xorg: do_trns.c,v 1.3 2000/08/17 19:46:25 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/do_trns.c,v 1.3 2001/01/17 19:43:17 dawes Exp $ */
+
+/**************************** D O _ T R N S . C ******************************
+ * *
+ * This module is responsible for executing all intelligent transformation *
+ * for bounding box and outline data *
+ * *
+ ****************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "spdo_prv.h" /* General definitions for Speedo */
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** STATIC FUNCTIONS *****/
+
+static void sp_split_curve(PROTO_DECL2 point_t P1,point_t P2,point_t P3,fix15 depth);
+static ufix8 FONTFAR *sp_get_args(PROTO_DECL2 ufix8 FONTFAR *pointer,ufix8 format,point_t STACKFAR *pP);
+
+
+FUNCTION ufix8 FONTFAR *read_bbox(
+GDECL
+ufix8 FONTFAR *pointer, /* Pointer to next byte in char data */
+point_t STACKFAR *pPmin, /* Lower left corner of bounding box */
+point_t STACKFAR *pPmax, /* Upper right corner of bounding box */
+boolean set_flag) /* flag to indicate whether global oru bbox should be saved */
+/*
+ * Called by make_simp_char() and make_comp_char() to read the
+ * bounding box data from the font.
+ * Sets Pmin and Pmax to the bottom left and top right corners
+ * of the bounding box after transformation into device space.
+ * The units of Pmin and Pmax are sub-pixels.
+ * Updates *ppointer to point to the byte following the
+ * bounding box data.
+ */
+{
+ufix8 format1;
+ufix8 format = 0;
+fix15 i;
+point_t P;
+
+sp_globals.x_int = 0;
+sp_globals.y_int = sp_globals.Y_int_org;
+sp_globals.x_orus = sp_globals.y_orus = 0;
+format1 = NEXT_BYTE(pointer);
+pointer = sp_get_args(pointer, format1, pPmin);
+#if INCL_SQUEEZING || INCL_ISW
+if (set_flag)
+ {
+ sp_globals.bbox_xmin_orus = sp_globals.x_orus;
+ sp_globals.bbox_ymin_orus = sp_globals.y_orus;
+ }
+#endif
+*pPmax = *pPmin;
+for (i = 1; i < 4; i++)
+ {
+ switch(i)
+ {
+ case 1:
+ if (format1 & BIT6) /* Xmax requires X int zone 1? */
+ sp_globals.x_int++;
+ format = (format1 >> 4) | 0x0c;
+ break;
+
+ case 2:
+ if (format1 & BIT7) /* Ymax requires Y int zone 1? */
+ sp_globals.y_int++;
+ format = NEXT_BYTE(pointer);
+ break;
+
+ case 3:
+ sp_globals.x_int = 0;
+ format >>= 4;
+ break;
+
+ default:
+ break;
+ }
+
+ pointer = sp_get_args(pointer, format, &P);
+#if INCL_SQUEEZING || INCL_ISW
+ if (set_flag && (i==2))
+ {
+ sp_globals.bbox_xmax_orus = sp_globals.x_orus;
+ sp_globals.bbox_ymax_orus = sp_globals.y_orus;
+ }
+#endif
+ if ((i == 2) || (!sp_globals.normal))
+ {
+ if (P.x < pPmin->x)
+ pPmin->x = P.x;
+ if (P.y < pPmin->y)
+ pPmin->y = P.y;
+ if (P.x > pPmax->x)
+ pPmax->x = P.x;
+ if (P.y > pPmax->y)
+ pPmax->y = P.y;
+ }
+ }
+
+#if DEBUG
+printf("BBOX %6.1f(Xint 0), %6.1f(Yint 0), %6.1f(Xint %d), %6.1f(Yint %d)\n",
+ (real)pPmin->x / (real)sp_globals.onepix,
+ (real)pPmin->y / (real)sp_globals.onepix,
+ (real)pPmax->x / (real)sp_globals.onepix,
+ (format1 >> 6) & 0x01,
+ (real)pPmax->y / (real)sp_globals.onepix,
+ (format1 >> 7) & 0x01);
+
+#endif
+return pointer;
+}
+
+FUNCTION void proc_outl_data(
+GDECL
+ufix8 FONTFAR *pointer) /* Pointer to next byte in char data */
+/*
+ * Called by make_simp_char() and make_comp_char() to read the
+ * outline data from the font.
+ * The outline data is parsed, transformed into device coordinates
+ * and passed to an output module for further processing.
+ * Note that pointer is not updated to facilitate repeated
+ * processing of the outline data when banding mode is in effect.
+ */
+{
+ufix8 format1, format2;
+point_t P0, P1, P2, P3;
+fix15 depth;
+fix15 curve_count;
+
+sp_globals.x_int = 0;
+sp_globals.y_int = sp_globals.Y_int_org;
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+record_xint((fix15)sp_globals.x_int); /* Record xint data */
+record_yint((fix15)(sp_globals.y_int - sp_globals.Y_int_org)); /* Record yint data */
+#endif
+
+sp_globals.x_orus = sp_globals.y_orus = 0;
+curve_count = 0;
+while(TRUE)
+ {
+ format1 = NEXT_BYTE(pointer);
+ switch(format1 >> 4)
+ {
+ case 0: /* LINE */
+ pointer = sp_get_args(pointer, format1, &P1);
+#if DEBUG
+ printf("LINE %6.1f, %6.1f\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix);
+#endif
+ fn_line(P1);
+ sp_globals.P0 = P1;
+ continue;
+
+ case 1: /* Short XINT */
+ sp_globals.x_int = format1 & 0x0f;
+#if DEBUG
+ printf("XINT %d\n", sp_globals.x_int);
+#endif
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+record_xint((fix15)sp_globals.x_int); /* Record xint data */
+#endif
+ continue;
+
+ case 2: /* Short YINT */
+ sp_globals.y_int = sp_globals.Y_int_org + (format1 & 0x0f);
+#if DEBUG
+ printf("YINT %d\n", sp_globals.y_int - sp_globals.Y_int_org);
+#endif
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+record_yint((fix15)(sp_globals.y_int - sp_globals.Y_int_org)); /* Record yint data */
+#endif
+ continue;
+
+ case 3: /* Miscellaneous */
+ switch(format1 & 0x0f)
+ {
+ case 0: /* END */
+ if (curve_count)
+ {
+ fn_end_contour();
+ }
+ return;
+
+ case 1: /* Long XINT */
+ sp_globals.x_int = NEXT_BYTE(pointer);
+#if DEBUG
+ printf("XINT %d\n", sp_globals.x_int);
+#endif
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+record_xint((fix15)sp_globals.x_int); /* Record xint data */
+#endif
+ continue;
+
+ case 2: /* Long YINT */
+ sp_globals.y_int = sp_globals.Y_int_org + NEXT_BYTE(pointer);
+#if DEBUG
+ printf("YINT %d\n", sp_globals.y_int - sp_globals.Y_int_org);
+#endif
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+record_yint((fix15)(sp_globals.y_int - sp_globals.Y_int_org)); /* Record yint data */
+#endif
+ continue;
+
+ default: /* Not used */
+ continue;
+ }
+
+ case 4: /* MOVE Inside */
+ case 5: /* MOVE Outside */
+ if (curve_count++)
+ {
+ fn_end_contour();
+ }
+
+ pointer = sp_get_args(pointer, format1, &P0);
+ sp_globals.P0 = P0;
+#if DEBUG
+ printf("MOVE %6.1f, %6.1f\n",
+ (real)sp_globals.P0.x / (real)sp_globals.onepix, (real)sp_globals.P0.y / (real)sp_globals.onepix);
+#endif
+ fn_begin_contour(sp_globals.P0, (boolean)(format1 & BIT4));
+ continue;
+
+ case 6: /* Undefined */
+#if DEBUG
+ printf("*** Undefined instruction (Hex %4x)\n", format1);
+#endif
+ continue;
+
+ case 7: /* Undefined */
+#if DEBUG
+ printf("*** Undefined instruction (Hex %4x)\n", format1);
+#endif
+ continue;
+
+ default: /* CRVE */
+ format2 = NEXT_BYTE(pointer);
+ pointer = sp_get_args(pointer, format1, &P1);
+ pointer = sp_get_args(pointer, format2, &P2);
+ pointer = sp_get_args(pointer, (ufix8)(format2 >> 4), &P3);
+ depth = (format1 >> 4) & 0x07;
+#if DEBUG
+ printf("CRVE %6.1f, %6.1f, %6.1f, %6.1f, %6.1f, %6.1f, %d\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix,
+ (real)P2.x / (real)sp_globals.onepix, (real)P2.y / (real)sp_globals.onepix,
+ (real)P3.x / (real)sp_globals.onepix, (real)P3.y / (real)sp_globals.onepix,
+ depth);
+#endif
+ depth += sp_globals.depth_adj;
+ if (sp_globals.curves_out)
+ {
+ fn_curve(P1, P2, P3, depth);
+ sp_globals.P0 = P3;
+ continue;
+ }
+ if (depth <= 0)
+ {
+ fn_line(P3);
+ sp_globals.P0 = P3;
+ continue;
+ }
+ sp_split_curve(P1, P2, P3, depth);
+ continue;
+ }
+ }
+}
+
+FUNCTION static void sp_split_curve(
+GDECL
+point_t P1, /* First control point of Bezier curve */
+point_t P2, /* Second control point of Bezier curve */
+point_t P3, /* End point of Bezier curve */
+fix15 depth) /* Levels of recursive subdivision required */
+/*
+ * Called by proc_outl_data() to subdivide Bezier curves into an
+ * appropriate number of vectors, whenever curves are not enabled
+ * for output to the currently selected output module.
+ * sp_split_curve() calls itself recursively to the depth specified
+ * at which point it calls line() to deliver each vector resulting
+ * from the spliting process.
+ */
+{
+fix31 X0 = (fix31)sp_globals.P0.x;
+fix31 Y0 = (fix31)sp_globals.P0.y;
+fix31 X1 = (fix31)P1.x;
+fix31 Y1 = (fix31)P1.y;
+fix31 X2 = (fix31)P2.x;
+fix31 Y2 = (fix31)P2.y;
+fix31 X3 = (fix31)P3.x;
+fix31 Y3 = (fix31)P3.y;
+point_t Pmid;
+point_t Pctrl1;
+point_t Pctrl2;
+
+#if DEBUG
+printf("CRVE(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix,
+ (real)P2.x / (real)sp_globals.onepix, (real)P2.y / (real)sp_globals.onepix,
+ (real)P3.x / (real)sp_globals.onepix, (real)P3.y / (real)sp_globals.onepix);
+#endif
+
+
+Pmid.x = (X0 + (X1 + X2) * 3 + X3 + 4) >> 3;
+Pmid.y = (Y0 + (Y1 + Y2) * 3 + Y3 + 4) >> 3;
+if ((--depth) <= 0)
+ {
+ fn_line(Pmid);
+ sp_globals.P0 = Pmid;
+ fn_line(P3);
+ sp_globals.P0 = P3;
+ }
+else
+ {
+ Pctrl1.x = (X0 + X1 + 1) >> 1;
+ Pctrl1.y = (Y0 + Y1 + 1) >> 1;
+ Pctrl2.x = (X0 + (X1 << 1) + X2 + 2) >> 2;
+ Pctrl2.y = (Y0 + (Y1 << 1) + Y2 + 2) >> 2;
+ sp_split_curve(Pctrl1, Pctrl2, Pmid, depth);
+ Pctrl1.x = (X1 + (X2 << 1) + X3 + 2) >> 2;
+ Pctrl1.y = (Y1 + (Y2 << 1) + Y3 + 2) >> 2;
+ Pctrl2.x = (X2 + X3 + 1) >> 1;
+ Pctrl2.y = (Y2 + Y3 + 1) >> 1;
+ sp_split_curve(Pctrl1, Pctrl2, P3, depth);
+ }
+}
+
+FUNCTION static ufix8 FONTFAR *sp_get_args(
+GDECL
+ufix8 FONTFAR *pointer, /* Pointer to next byte in char data */
+ufix8 format, /* Format specifiaction of argument pair */
+point_t STACKFAR *pP) /* Resulting transformed point */
+/*
+ * Called by read_bbox() and proc_outl_data() to read an X Y argument
+ * pair from the font.
+ * The format is specified as follows:
+ * Bits 0-1: Type of X argument.
+ * Bits 2-3: Type of Y argument.
+ * where the 4 possible argument types are:
+ * Type 0: Controlled coordinate represented by one byte
+ * index into the X or Y controlled coordinate table.
+ * Type 1: Interpolated coordinate represented by a two-byte
+ * signed integer.
+ * Type 2: Interpolated coordinate represented by a one-byte
+ * signed increment/decrement relative to the
+ * proceding X or Y coordinate.
+ * Type 3: Repeat of preceding X or Y argument value and type.
+ * The units of P are sub-pixels.
+ * Updates *ppointer to point to the byte following the
+ * argument pair.
+ */
+{
+ufix8 edge;
+
+/* Read X argument */
+switch(format & 0x03)
+ {
+case 0: /* Index to controlled oru */
+ edge = NEXT_BYTE(pointer);
+ sp_globals.x_orus = sp_plaid.orus[edge];
+#if INCL_RULES
+ sp_globals.x_pix = sp_plaid.pix[edge];
+#endif
+ break;
+
+case 1: /* 2 byte interpolated oru value */
+ sp_globals.x_orus = NEXT_WORD(pointer);
+ goto L1;
+
+case 2: /* 1 byte signed oru increment */
+ sp_globals.x_orus += (fix15)((fix7)NEXT_BYTE(pointer));
+L1:
+#if INCL_RULES
+ sp_globals.x_pix = TRANS(sp_globals.x_orus, sp_plaid.mult[sp_globals.x_int], sp_plaid.offset[sp_globals.x_int], sp_globals.mpshift);
+#endif
+ break;
+
+default: /* No change in X value */
+ break;
+ }
+
+/* Read Y argument */
+switch((format >> 2) & 0x03)
+ {
+case 0: /* Index to controlled oru */
+ edge = sp_globals.Y_edge_org + NEXT_BYTE(pointer);
+ sp_globals.y_orus = sp_plaid.orus[edge];
+#if INCL_RULES
+ sp_globals.y_pix = sp_plaid.pix[edge];
+#endif
+ break;
+
+case 1: /* 2 byte interpolated oru value */
+ sp_globals.y_orus = NEXT_WORD(pointer);
+ goto L2;
+
+case 2: /* 1 byte signed oru increment */
+ sp_globals.y_orus += (fix15)((fix7)NEXT_BYTE(pointer));
+L2:
+#if INCL_RULES
+ sp_globals.y_pix = TRANS(sp_globals.y_orus, sp_plaid.mult[sp_globals.y_int], sp_plaid.offset[sp_globals.y_int], sp_globals.mpshift);
+#endif
+ break;
+
+default: /* No change in X value */
+ break;
+ }
+
+#if INCL_RULES
+switch(sp_globals.tcb.xmode)
+ {
+case 0: /* X mode 0 */
+ pP->x = sp_globals.x_pix;
+ break;
+
+case 1: /* X mode 1 */
+ pP->x = -sp_globals.x_pix;
+ break;
+
+case 2: /* X mode 2 */
+ pP->x = sp_globals.y_pix;
+ break;
+
+case 3: /* X mode 3 */
+ pP->x = -sp_globals.y_pix;
+ break;
+
+default: /* X mode 4 */
+#endif
+ pP->x = (MULT16(sp_globals.x_orus, sp_globals.tcb.xxmult) +
+ MULT16(sp_globals.y_orus, sp_globals.tcb.xymult) +
+ sp_globals.tcb.xoffset) >> sp_globals.mpshift;
+#if INCL_RULES
+ break;
+ }
+
+switch(sp_globals.tcb.ymode)
+ {
+case 0: /* Y mode 0 */
+ pP->y = sp_globals.y_pix;
+ break;
+
+case 1: /* Y mode 1 */
+ pP->y = -sp_globals.y_pix;
+ break;
+
+case 2: /* Y mode 2 */
+ pP->y = sp_globals.x_pix;
+ break;
+
+case 3: /* Y mode 3 */
+ pP->y = -sp_globals.x_pix;
+ break;
+
+default: /* Y mode 4 */
+#endif
+ pP->y = (MULT16(sp_globals.x_orus, sp_globals.tcb.yxmult) +
+ MULT16(sp_globals.y_orus, sp_globals.tcb.yymult) +
+ sp_globals.tcb.yoffset) >> sp_globals.mpshift;
+#if INCL_RULES
+ break;
+ }
+#endif
+
+return pointer;
+}
+
+
+
diff --git a/nx-X11/lib/font/Speedo/htest.c b/nx-X11/lib/font/Speedo/htest.c
new file mode 100644
index 000000000..235b76560
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/htest.c
@@ -0,0 +1,361 @@
+/* $Xorg: htest.c,v 1.3 2000/08/17 19:46:25 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+/****************************** H T E S T . C ********************************
+ * *
+ * SPEEDO FONT HEADER TEST MODULE *
+ * *
+ ****************************************************************************/
+
+
+#include "speedo.h" /* General definition for make_bmap */
+#include <stdio.h>
+
+#define DEBUG 0
+
+#if DEBUG
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+#define FONT_BUFFER_SIZE 1000
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+static char pathname[100]; /* Name of font file to be output */
+static ufix8 font_buffer[FONT_BUFFER_SIZE]; /* Font buffer */
+static FILE *fdescr; /* Speedo outline file descriptor */
+
+
+
+FUNCTION main(argc,argv)
+int argc;
+char *argv[];
+{
+int bytes_read; /* Number of bytes read from font file */
+ufix8 tmpufix8; /* Temporary workspace */
+fix15 tmpfix15; /* Temporary workspace */
+ufix16 tmpufix16; /* Temporary workspace */
+ufix32 tmpufix32; /* Temporary workspace */
+ufix8 *pvt_header_org; /* Origin of provate header data */
+
+ufix8 read_1b(); /* Read 1 byte field from font header */
+fix15 read_2b(); /* Read 2 byte field from font header */
+fix31 read_4b(); /* Read 4 byte field from font header */
+
+if (argc != 2)
+ {
+ fprintf(stderr,"Usage: htest {fontfile}\n\n");
+ exit (1);
+ }
+
+sprintf(pathname, argv[1]);
+
+/* Initialization */
+printf("\n SPEEDO FONT FILE HEADER DATA\n");
+printf(" -------------------------\n\n");
+/* Load Speedo outline file */
+fdescr = fopen (pathname, "rb");
+if (fdescr == NULL)
+ {
+ printf("****** Cannot open file %s\n", pathname);
+ return;
+ }
+
+bytes_read = fread(font_buffer, sizeof(ufix8), sizeof(font_buffer), fdescr);
+if (bytes_read == 0)
+ {
+ printf("****** Error on reading %s: %x\n", pathname, bytes_read);
+ fclose(fdescr);
+ return;
+ }
+
+printf("Format Identifier ...................... %.4s\n", font_buffer + FH_FMVER);
+
+tmpufix32 = (ufix32)read_4b(font_buffer + FH_FMVER + 4);
+printf("CR-LF-NULL-NULL data ............... %8.8lx %s\n", tmpufix32, (tmpufix32 != 0x0d0a0000)? "(incorrect)": " ");
+
+printf("Font Size .............................. %4ld\n", (ufix32)read_4b(font_buffer + FH_FNTSZ));
+
+printf("Minimum Font Buffer Size ............... %4ld\n", (ufix32)read_4b(font_buffer + FH_FBFSZ));
+
+printf("Minimum Character Buffer Size .......... %4d\n", (ufix16)read_2b(font_buffer + FH_CBFSZ));
+
+printf("Header Size ............................ %4d\n", (ufix16)read_2b(font_buffer + FH_HEDSZ));
+
+printf("Font ID ................................ %4.4d\n", (ufix16)read_2b(font_buffer + FH_FNTID));
+
+printf("Font Version Number .................... %4d\n", (ufix16)read_1b(font_buffer + FH_SFVNR));
+
+printf("Font Full Name:\n %.70s\n", font_buffer + FH_FNTNM);
+
+printf("Manufacturing Date ................ %10.10s\n", font_buffer + FH_MDATE);
+
+printf("Character Set Name:\n %s\n", font_buffer + FH_LAYNM);
+
+printf("Character Set ID: ...................... %.4s\n", font_buffer + FH_LAYNM + 66);
+
+printf("Copyright Notice:\n %.70s\n", font_buffer + FH_CPYRT);
+
+printf("Number of Char. Indexes in Char. Set ... %4d\n", (ufix16)read_2b(font_buffer + FH_NCHRL));
+
+printf("Total number of Char. Indexes in Font .. %4d\n", (ufix16)read_2b(font_buffer + FH_NCHRF));
+
+printf("Index of First Character ............... %4d\n", (ufix16)read_2b(font_buffer + FH_FCHRF));
+
+printf("Number of Kerning Tracks ............... %4d\n", (ufix16)read_2b(font_buffer + FH_NKTKS));
+
+printf("Number of Kerning Pairs ................ %4d\n", (ufix16)read_2b(font_buffer + FH_NKPRS));
+
+printf("Font Flags:\n");
+tmpufix8 = read_1b(font_buffer + FH_FLAGS);
+printf(" Extended font ...................... %s\n", (tmpufix8 & BIT0)? " Yes": " No");
+
+printf("Classification Flags:\n");
+tmpufix8 = read_1b(font_buffer + FH_CLFGS);
+printf(" Italic ............................. %s\n", (tmpufix8 & BIT0)? " Yes": " No");
+printf(" Monospace .......................... %s\n", (tmpufix8 & BIT1)? " Yes": " No");
+printf(" Serif .............................. %s\n", (tmpufix8 & BIT2)? " Yes": " No");
+printf(" Display ............................ %s\n", (tmpufix8 & BIT3)? " Yes": " No");
+
+tmpufix8 = read_1b(font_buffer + FH_FAMCL);
+printf("Family Classification .................. %4d ", tmpufix8);
+switch (tmpufix8)
+ {
+case 0:
+ printf("(Don't care)\n");
+ break;
+case 1:
+ printf("(Serif)\n");
+ break;
+case 2:
+ printf("(Sans serif)\n");
+ break;
+case 3:
+ printf("(Monospace)\n");
+ break;
+case 4:
+ printf("(Script or calligraphic)\n");
+ break;
+case 5:
+ printf("(Decorative)\n");
+ break;
+default:
+ printf("\n");
+ break;
+ }
+
+printf("Font Form Classification:\n");
+tmpufix8 = read_1b(font_buffer + FH_FRMCL);
+printf(" Width Type ......................... %4d ", (tmpufix8 & 0x0f));
+switch (tmpufix8 & 0x0f)
+ {
+case 4:
+ printf("(Condensed)\n");
+ break;
+case 6:
+ printf("(Semi-condensed)\n");
+ break;
+case 8:
+ printf("(Normal)\n");
+ break;
+case 10:
+ printf("(Semi-expanded)\n");
+ break;
+case 12:
+ printf("(Expanded)\n");
+ break;
+default:
+ printf("\n");
+ break;
+ }
+printf(" Weight ............................. %4d ", (tmpufix8 >> 4));
+switch (tmpufix8 >> 4)
+ {
+case 1:
+ printf("(Thin)\n");
+ break;
+case 2:
+ printf("(Ultralight)\n");
+ break;
+case 3:
+ printf("(Extra light)\n");
+ break;
+case 4:
+ printf("(Light)\n");
+ break;
+case 5:
+ printf("(Book)\n");
+ break;
+case 6:
+ printf("(Normal)\n");
+ break;
+case 7:
+ printf("(Medium)\n");
+ break;
+case 8:
+ printf("(Semibold)\n");
+ break;
+case 9:
+ printf("(Demibold)\n");
+ break;
+case 10:
+ printf("(Bold)\n");
+ break;
+case 11:
+ printf("(Extrabold)\n");
+ break;
+case 12:
+ printf("(Ultrabold)\n");
+ break;
+case 13:
+ printf("(Heavy)\n");
+ break;
+case 14:
+ printf("(Black)\n");
+ break;
+default:
+ printf("\n");
+ break;
+ }
+
+printf("Short Font Name ........................ %.16s\n", font_buffer + FH_SFNTN);
+
+printf("Short Face Name ........................ %.16s\n", font_buffer + FH_SFACN);
+
+printf("Font Form .............................. %.14s\n", font_buffer + FH_FNTFM);
+
+printf("Italic Angle ........................... %7.2f\n", ((real)read_2b(font_buffer + FH_ITANG) / 256.0));
+
+printf("ORUs per Em ............................ %4d\n", (ufix16)read_2b(font_buffer + FH_ORUPM));
+
+printf("Width of Word Space .................... %4d\n", (ufix16)read_2b(font_buffer + FH_WDWTH));
+
+printf("Width of Em Space ...................... %4d\n", (ufix16)read_2b(font_buffer + FH_EMWTH));
+
+printf("Width of En Space ...................... %4d\n", (ufix16)read_2b(font_buffer + FH_ENWTH));
+
+printf("Width of Thin Space .................... %4d\n", (ufix16)read_2b(font_buffer + FH_TNWTH));
+
+printf("Width of Figure Space .................. %4d\n", (ufix16)read_2b(font_buffer + FH_FGWTH));
+
+printf("Min X coordinate in font ............... %4d\n", (fix15)read_2b(font_buffer + FH_FXMIN));
+
+printf("Min Y coordinate in font ............... %4d\n", (fix15)read_2b(font_buffer + FH_FYMIN));
+
+printf("Max X coordinate in font ............... %4d\n", (fix15)read_2b(font_buffer + FH_FXMAX));
+
+printf("Max Y coordinate in font ............... %4d\n", (fix15)read_2b(font_buffer + FH_FYMAX));
+
+printf("Underline Position ..................... %4d\n", (fix15)read_2b(font_buffer + FH_ULPOS));
+
+printf("Underline Thickness .................... %4d\n", (fix15)read_2b(font_buffer + FH_ULTHK));
+
+printf("Small Caps Y position .................. %4d\n", (fix15)read_2b(font_buffer + FH_SMCTR));
+printf("Small Caps X scale ..................... %7.2f\n", ((real)read_2b(font_buffer + FH_SMCTR + 2) / 4096.0));
+printf("Small Caps Y scale ..................... %7.2f\n", ((real)(fix15)read_2b(font_buffer + FH_SMCTR + 4) / 4096.0));
+
+printf("Display Superiors Y position ........... %4d\n", (fix15)read_2b(font_buffer + FH_SMCTR));
+printf("Display Superiors X scale .............. %7.2f\n", ((real)read_2b(font_buffer + FH_SMCTR + 2) / 4096.0));
+printf("Display Superiors Y scale .............. %7.2f\n", ((real)read_2b(font_buffer + FH_SMCTR + 4) / 4096.0));
+
+printf("Footnote Superiors Y position .......... %4d\n", (fix15)read_2b(font_buffer + FH_FNSTR));
+printf("Footnote Superiors X scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_FNSTR + 2) / 4096.0));
+printf("Footnote Superiors Y scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_FNSTR + 4) / 4096.0));
+
+printf("Alpha Superiors Y position ............. %4d\n", (fix15)read_2b(font_buffer + FH_ALSTR));
+printf("Alpha Superiors X scale ................ %7.2f\n", ((real)read_2b(font_buffer + FH_ALSTR + 2) / 4096.0));
+printf("Alpha Superiors Y scale ................ %7.2f\n", ((real)read_2b(font_buffer + FH_ALSTR + 4) / 4096.0));
+
+printf("Chemical Inferiors Y position .......... %4d\n", (fix15)read_2b(font_buffer + FH_CMITR));
+printf("Chemical Inferiors X scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_CMITR + 2) / 4096.0));
+printf("Chemical Inferiors Y scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_CMITR + 4) / 4096.0));
+
+printf("Small Numerators Y position ............ %4d\n", (fix15)read_2b(font_buffer + FH_SNMTR));
+printf("Small Numerators X scale ............... %7.2f\n", ((real)read_2b(font_buffer + FH_SNMTR + 2) / 4096.0));
+printf("Small Numerators Y scale ............... %7.2f\n", ((real)read_2b(font_buffer + FH_SNMTR + 4) / 4096.0));
+
+printf("Small Denominators Y position .......... %4d\n", (fix15)read_2b(font_buffer + FH_SDNTR));
+printf("Small Denominators X scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_SDNTR + 2) / 4096.0));
+printf("Small Denominators Y scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_SDNTR + 4) / 4096.0));
+
+printf("Medium Numerators Y position ........... %4d\n", (fix15)read_2b(font_buffer + FH_MNMTR));
+printf("Medium Numerators X scale .............. %7.2f\n", ((real)read_2b(font_buffer + FH_MNMTR + 2) / 4096.0));
+printf("Medium Numerators Y scale .............. %7.2f\n", ((real)read_2b(font_buffer + FH_MNMTR + 4) / 4096.0));
+
+printf("Medium Denominators Y position ......... %4d\n", (fix15)read_2b(font_buffer + FH_MDNTR));
+printf("Medium Denominators X scale ............ %7.2f\n", ((real)read_2b(font_buffer + FH_MDNTR + 2) / 4096.0));
+printf("Medium Denominators Y scale ............ %7.2f\n", ((real)read_2b(font_buffer + FH_MDNTR + 4) / 4096.0));
+
+printf("Large Numerators Y position ............ %4d\n", (fix15)read_2b(font_buffer + FH_LNMTR));
+printf("Large Numerators X scale ............... %7.2f\n", ((real)read_2b(font_buffer + FH_LNMTR + 2) / 4096.0));
+printf("Large Numerators Y scale ............... %7.2f\n", ((real)read_2b(font_buffer + FH_LNMTR + 4) / 4096.0));
+
+printf("Large Denominators Y position .......... %4d\n", (fix15)read_2b(font_buffer + FH_LDNTR));
+printf("Large Denominators X scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_LDNTR + 2) / 4096.0));
+printf("Large Denominators Y scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_LDNTR + 4) / 4096.0));
+
+fclose(fdescr);
+}
+
+
+FUNCTION ufix8 read_1b(pointer)
+ufix8 *pointer;
+/*
+ * Reads 1-byte field from font buffer
+ */
+{
+return *pointer;
+}
+
+FUNCTION fix15 read_2b(pointer)
+ufix8 *pointer;
+/*
+ * Reads 2-byte field from font buffer
+ */
+{
+fix31 temp;
+
+temp = *pointer++;
+temp = (temp << 8) + *(pointer);
+return temp;
+}
+
+FUNCTION fix31 read_4b(pointer)
+ufix8 *pointer;
+/*
+ * Reads 4-byte field from font buffer
+ */
+{
+fix31 temp;
+
+temp = *pointer++;
+temp = (temp << 8) + *(pointer++);
+temp = (temp << 8) + *(pointer++);
+temp = (temp << 8) + *(pointer);
+return temp;
+}
+
diff --git a/nx-X11/lib/font/Speedo/iface.c b/nx-X11/lib/font/Speedo/iface.c
new file mode 100644
index 000000000..1dad5ae48
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/iface.c
@@ -0,0 +1,650 @@
+/* $Xorg: iface.c,v 1.3 2000/08/17 19:46:25 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/iface.c,v 1.2 1998/07/25 06:56:53 dawes Exp $ */
+
+/***************************** I F A C E . C *********************************
+ * *
+ * This module provides a layer to make Speedo function calls to and *
+ * from it compatible with Fontware 2.X function calls. *
+ * *
+ ****************************************************************************/
+
+#include "speedo.h" /* General definitions for Speedo */
+#ifndef FONTMODULE
+#include <math.h>
+#else
+#include "xf86_ansic.h"
+#endif
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+#define PI 3.1415926536 /* pi */
+#define PTPERINCH 72.2892 /* nbr points per inch, exactly! */
+
+#define BIT8 0x0100
+#define BIT9 0x0200
+#define BIT10 0x0400
+#define BIT11 0x0800
+#define BIT12 0x1000
+#define BIT13 0x2000
+#define BIT14 0x4000
+#define BIT15 0x8000
+
+#define READ 0
+
+typedef short bool16;
+typedef int bool;
+
+typedef
+struct
+ {
+ bool16 left;
+ bool16 right;
+ bool16 top;
+ bool16 bottom;
+ } lrtb;
+
+
+typedef
+struct
+ {
+ buff_t *pfont; /* Pointer to font data */
+ ufix16 mode; /* what mode is the font generator in */
+ real point_size_x; /* Point size in X dimension */
+ real point_size_y; /* Point size in Y dimension */
+ real res_hor; /* Horizontal resolution of output device */
+ real res_ver; /* Vertical resolution of output device */
+ real rot_angle; /* Rotation angle in degrees (clockwise) */
+ real obl_angle; /* Obliquing angle in degrees (clockwise) */
+ bool16 whitewrite; /* if T, generate bitmaps for whitewriters */
+ fix15 thresh; /* Scan conversion threshold *
+ * Thickens characters on each edge by *
+ * <thresh> sub-pixels */
+ bool16 import_widths; /* Use imported width table */
+ lrtb clip; /* Clip to standard character cell */
+ lrtb squeeze; /* Squeeze to standard character cell */
+ bool16 bogus_mode; /* if T, ignore plaid data */
+ } comp_char_desc; /* character attributes for scan conv */
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+ fw_reset(); /* Fontware 2.X reset call */
+ fw_set_specs(); /* Fontware 2.X set specs call */
+bool fw_make_char(); /* Fontware 2.X make character call */
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+void _open_bitmap();
+void _close_bitmap();
+void _set_bitmap_bits();
+void _open_outline();
+void _open_outline();
+void _start_new_char();
+void _start_curve();
+void _line_to();
+void _close_curve();
+void _close_outline();
+
+/***** STATIC VARIABLES *****/
+static specs_t *pspecs;
+static buff_t *pfont;
+static buff_t char_data;
+static fix15 set_width_x;
+static specs_t specsarg;
+
+/***** STATIC FUNCTIONS *****/
+static fix31 make_mult();
+
+
+FUNCTION fw_reset()
+{
+sp_reset();
+}
+
+FUNCTION fw_set_specs(pspecs)
+comp_char_desc *pspecs; /* Pointer to scan conversion parameters structure */
+
+/* Fontware 2.X character generator call to set font specifications
+ * compc -- pointer to structure containing scan conversion parameters.
+ * ->compf -- compressed font data structure
+ * ->point_size_x -- x pointsize
+ * ->point_size_y -- y pointsize
+ * ->res_hor -- horizontal pixels per inch
+ * ->res_ver -- vertical pixels per inch
+ * ->rot_angle -- rotation angle in degrees (clockwise)
+ * ->obl_angle -- obliquing angle in degrees (clockwise)
+ * ->whitewrite -- if true, generate bitmaps for whitewriters
+ * ->thresh -- scan-conversion threshold
+ * ->import_widths -- if true, use external width table
+ * ->clip.left -- clips min x at left of emsquare
+ * ->clip.right -- clips max x at right of emsquare
+ * ->clip.bottom -- clips min x at bottom of emsquare
+ * ->clip.top -- clips max x at top of emsquare
+ * ->squeeze.left -- squeezes min x at left of emsquare
+ * ->squeeze.right, .top, .bottom &c
+ * ->sw_fixed -- if TRUE, match pixel widths to scaled outline widths
+ * ->bogus_mode -- ignore plaid data if TRUE
+ */
+
+{
+fix15 irot;
+fix15 iobl;
+fix15 x_trans_type;
+fix15 y_trans_type;
+fix31 xx_mult;
+fix31 xy_mult;
+fix31 yx_mult;
+fix31 yy_mult;
+real sinrot, cosrot, tanobl;
+real x_distortion;
+real pixperem_h;
+real pixperem_v;
+real point_size_x;
+real point_size_y;
+real res_hor;
+real res_ver;
+fix15 mode;
+
+specsarg.pfont = pspecs->pfont;
+
+irot = floor(pspecs->rot_angle + 0.5);
+iobl = floor(pspecs->obl_angle + 0.5);
+if (iobl > 85)
+ iobl = 85;
+if (iobl < -85)
+ iobl = -85;
+if ((irot % 90) == 0)
+ {
+ x_trans_type = y_trans_type = irot / 90 & 0x0003;
+ if (iobl != 0)
+ {
+ if (x_trans_type & 0x01)
+ y_trans_type = 4;
+ else
+ x_trans_type = 4;
+ }
+ }
+else if (((irot + iobl) % 90) == 0)
+ {
+ x_trans_type = y_trans_type = (irot + iobl) / 90 & 0x0003;
+ if (iobl != 0)
+ {
+ if (x_trans_type & 0x01)
+ x_trans_type = 4;
+ else
+ y_trans_type = 4;
+ }
+ }
+else
+ {
+ x_trans_type = y_trans_type = 4;
+ }
+
+point_size_x = pspecs->point_size_x;
+point_size_y = pspecs->point_size_y;
+res_hor = pspecs->res_hor;
+res_ver = pspecs->res_ver;
+
+switch (x_trans_type)
+ {
+case 0:
+ xx_mult = make_mult(point_size_x, res_hor);
+ xy_mult = 0;
+ break;
+
+case 1:
+ xx_mult = 0;
+ xy_mult = make_mult(point_size_y, res_hor);
+ break;
+
+case 2:
+ xx_mult = -make_mult(point_size_x, res_hor);
+ xy_mult = 0;
+ break;
+
+case 3:
+ xx_mult = 0;
+ xy_mult = -make_mult(point_size_y, res_hor);
+ break;
+
+default:
+ sinrot = sin((real)irot * PI / 180.);
+ cosrot = cos((real)irot * PI / 180.);
+ tanobl = tan((real)iobl * PI / 180.);
+ x_distortion = point_size_x / point_size_y;
+ pixperem_h = point_size_y * res_hor / (real)PTPERINCH; /* this is NOT a bug */
+ xx_mult = floor(cosrot * x_distortion * pixperem_h * 65536.0 + 0.5);
+ xy_mult = floor((sinrot + cosrot * tanobl) * pixperem_h * 65536.0 + 0.5);
+ break;
+ }
+
+switch (y_trans_type)
+ {
+case 0:
+ yx_mult = 0;
+ yy_mult = make_mult(point_size_y, res_ver);
+ break;
+
+case 1:
+ yx_mult = -make_mult(point_size_x, res_hor);
+ yy_mult = 0;
+ break;
+
+case 2:
+ yx_mult = 0;
+ yy_mult = -make_mult(point_size_y, res_ver);
+ break;
+
+case 3:
+ yx_mult = make_mult(point_size_x, res_ver);
+ yy_mult = 0;
+ break;
+
+default:
+ sinrot = sin((real)irot * PI / 180.);
+ cosrot = cos((real)irot * PI / 180.);
+ tanobl = tan((real)iobl * PI / 180.);
+ x_distortion = point_size_x / point_size_y;
+ pixperem_v = point_size_y * res_ver / (real)PTPERINCH;
+ yx_mult = floor(-sinrot * x_distortion * pixperem_v * 65536.0 + 0.5);
+ yy_mult = floor((cosrot - sinrot * tanobl) * pixperem_v * 65536.0 + 0.5);
+ break;
+ }
+
+specsarg.xxmult = xx_mult;
+specsarg.xymult = xy_mult;
+specsarg.xoffset = 0;
+specsarg.yxmult = yx_mult;
+specsarg.yymult = yy_mult;
+specsarg.yoffset = 0;
+specsarg.out_info = 0;
+
+/* Select processing mode */
+switch (pspecs->mode)
+ {
+case 1:
+ if (pspecs->whitewrite) /* White-write requested? */
+ {
+ mode = 1;
+ }
+ else
+ {
+ mode = 0;
+ }
+ break;
+
+case 2:
+ mode = 2;
+ break;
+
+default:
+ mode = pspecs->mode;
+ break;
+ }
+
+if (pspecs->bogus_mode) /* Linear transformation requested? */
+ {
+ mode |= BIT4; /* Set linear tranformation flag */
+ }
+
+if (pspecs->import_widths) /* Imported widths requested? */
+ {
+ mode |= BIT6; /* Set imported width flag */
+ }
+
+if (pspecs->clip.left) /* Clip left requested? */
+ {
+ mode |= BIT8; /* Set clip left flag */
+ }
+
+if (pspecs->clip.right) /* Clip right requested? */
+ {
+ mode |= BIT9; /* Set clip right flag */
+ }
+
+if (pspecs->clip.top) /* Clip top requested? */
+ {
+ mode |= BIT10; /* Set clip top flag */
+ }
+
+if (pspecs->clip.bottom) /* Clip bottom requested? */
+ {
+ mode |= BIT11; /* Set clip bottom flag */
+ }
+
+if (pspecs->squeeze.left) /* Squeeze left requested? */
+ {
+ mode |= BIT12; /* Set squeeze left flag */
+ }
+
+if (pspecs->squeeze.right) /* Squeeze right requested? */
+ {
+ mode |= BIT13; /* Set squeeze right flag */
+ }
+
+if (pspecs->squeeze.top) /* Squeeze top requested? */
+ {
+ mode |= BIT14; /* Set squeeze top flag */
+ }
+
+if (pspecs->squeeze.bottom) /* Squeeze bottom requested? */
+ {
+ mode |= BIT15; /* Set squeeze bottom flag */
+ }
+
+specsarg.flags = mode;
+
+sp_set_specs(&specsarg);
+}
+
+FUNCTION static fix31 make_mult(point_size, resolution)
+real point_size;
+real resolution;
+{
+real ms_factor;
+
+return (fix31)floor((point_size * resolution * 65536.0) / (real)PTPERINCH + 0.5);
+}
+
+FUNCTION bool fw_make_char(char_index)
+ufix16 char_index;
+{
+return sp_make_char(char_index);
+}
+
+FUNCTION buff_t *sp_load_char_data(file_offset, no_bytes, cb_offset)
+fix31 file_offset;
+fix15 no_bytes;
+fix15 cb_offset;
+/*
+ * Called by Speedo character generator to request that character
+ * data be loaded from the font file.
+ * This is a dummy function that assumes that the entire font has
+ * been loaded.
+ */
+{
+#if DEBUG
+printf("load_char_data(%d, %d, %d)\n", file_offset, no_bytes, char_offset);
+#endif
+char_data.org = pfont->org + file_offset;
+char_data.no_bytes = no_bytes;
+return &char_data;
+}
+
+FUNCTION void sp_report_error(n)
+fix15 n; /* Error identification number */
+/*
+ * Called by Speedo character generator to report an error.
+ */
+{
+switch(n)
+ {
+case 1:
+ printf("Insufficient font data loaded\n");
+ break;
+
+case 3:
+ printf("Transformation matrix out of range\n");
+ break;
+
+case 4:
+ printf("Font format error\n");
+ break;
+
+case 5:
+ printf("Requested specs not compatible with output module\n");
+ break;
+
+case 7:
+ printf("Intelligent transformation requested but not supported\n");
+ break;
+
+case 8:
+ printf("Unsupported output mode requested\n");
+ break;
+
+case 9:
+ printf("Extended font loaded but only compact fonts supported\n");
+ break;
+
+case 10:
+ printf("Font specs not set prior to use of font\n");
+ break;
+
+case 12:
+ printf("Character data not available()\n");
+ break;
+
+case 13:
+ printf("Track kerning data not available()\n");
+ break;
+
+case 14:
+ printf("Pair kerning data not available()\n");
+ break;
+
+default:
+ printf("report_error(%d)\n", n);
+ break;
+ }
+}
+
+
+
+FUNCTION void sp_open_bitmap(sw_x, sw_y, xorg, yorg, xsize, ysize)
+fix31 sw_x; /* X component of escapement vector */
+fix31 sw_y; /* Y component of escapement vector */
+fix31 xorg; /* X origin */
+fix31 yorg; /* Y origin */
+fix15 xsize; /* width of bitmap */
+fix15 ysize; /* height of bitmap */
+/*
+ * Called by Speedo character generator to initialize a buffer prior
+ * to receiving bitmap data.
+ */
+{
+
+fix15 xmin,xmax,ymin,ymax;
+
+#if DEBUG
+printf("sp_open_bitmap:\n");
+printf(" X component of set width vector = %3.1f\n", (real)sw_x / 65536.0);
+printf(" Y component of set width vector = %3.1f\n", (real)sw_y / 65536.0);
+printf(" Bounding box is (%d, %d, %d, %d)\n", xmin, ymin, xmax, ymax);
+#endif
+
+xmin = xorg >> 16;
+ymin = yorg >> 16;
+xmax = xmin + xsize;
+ymax = ymin + ysize;
+
+set_width_x = ((sw_x >> 15) + 1) >> 1;
+open_bitmap(set_width_x, xmin, xmax, ymin, ymax);
+}
+
+FUNCTION void sp_set_bitmap_bits(y, x1, x2)
+fix15 y, x1, x2;
+/*
+ * Called by Speedo character generator to write one row of pixels
+ * into the generated bitmap character.
+ */
+{
+#if DEBUG
+printf("set_bitmap_bits(%d, %d, %d)\n", y, x1, x2);
+#endif
+
+set_bitmap_bits(y, x1, x2);
+}
+
+FUNCTION void sp_close_bitmap()
+/*
+ * Called by Speedo character generator to indicate all bitmap data
+ * has been generated.
+ */
+{
+#if DEBUG
+printf("close_bitmap()\n");
+#endif
+
+close_bitmap();
+}
+
+FUNCTION void sp_open_outline(sw_x, sw_y, xmin, xmax, ymin, ymax)
+fix31 sw_x; /* X component of escapement vector */
+fix31 sw_y; /* Y component of escapement vector */
+fix31 xmin; /* Minimum X value in outline */
+fix31 xmax; /* Maximum X value in outline */
+fix31 ymin; /* Minimum Y value in outline */
+fix31 ymax; /* Maximum Y value in outline */
+/*
+ * Called by Speedo character generator to initialize prior to
+ * outputting scaled outline data.
+ */
+{
+#if DEBUG
+printf("open_outline(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n",
+ (real)sw_x / 65536.0, (real)sw_y / 65536.0,
+ (real)xmin / 65536.0, (real)xmax / 65536.0, (real)ymin / 65536.0, (real)ymax / 65536.0);
+#endif
+
+set_width_x = ((sw_x >> 15) + 1) >> 1;
+open_outline(set_width_x);
+}
+
+FUNCTION void sp_start_new_char()
+/*
+ * Called by Speedo character generator to initialize prior to
+ * outputting scaled outline data for a sub-character in a compound
+ * character.
+ */
+{
+#if DEBUG
+printf("start_new_char()\n");
+#endif
+
+start_new_char();
+}
+
+FUNCTION void sp_start_contour(x, y, outside)
+fix31 x; /* X coordinate of start point in 1/65536 pixels */
+fix31 y; /* Y coordinate of start point in 1/65536 pixels */
+boolean outside; /* TRUE if curve encloses ink (Counter-clockwise) */
+/*
+ * Called by Speedo character generator at the start of each contour
+ * in the outline data of the character.
+ */
+{
+real realx, realy;
+
+realx = (real)x / 65536.0;
+realy = (real)y / 65536.0;
+
+#if DEBUG
+printf("start_curve(%3.1f, %3.1f, %s)\n",
+ realx, realy,
+ outside? "outside": "inside");
+#endif
+
+start_curve(realx, realy, outside);
+}
+
+FUNCTION void sp_curve_to(x1, y1, x2, y2, x3, y3)
+fix31 x1; /* X coordinate of first control point in 1/65536 pixels */
+fix31 y1; /* Y coordinate of first control point in 1/65536 pixels */
+fix31 x2; /* X coordinate of second control point in 1/65536 pixels */
+fix31 y2; /* Y coordinate of second control point in 1/65536 pixels */
+fix31 x3; /* X coordinate of curve end point in 1/65536 pixels */
+fix31 y3; /* Y coordinate of curve end point in 1/65536 pixels */
+/*
+ * Called by Speedo character generator once for each curve in the
+ * scaled outline data of the character. This function is only called if curve
+ * output is enabled in the set_specs() call.
+ */
+{
+#if DEBUG
+printf("curve_to(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n",
+ (real)x1 / 65536.0, (real)y1 / 65536.0,
+ (real)x2 / 65536.0, (real)y2 / 65536.0,
+ (real)x3 / 65536.0, (real)y3 / 65536.0);
+#endif
+}
+
+FUNCTION void sp_line_to(x, y)
+fix31 x; /* X coordinate of vector end point in 1/65536 pixels */
+fix31 y; /* Y coordinate of vector end point in 1/65536 pixels */
+/*
+ * Called by Speedo character generator onece for each vector in the
+ * scaled outline data for the character. This include curve data that has
+ * been sub-divided into vectors if curve output has not been enabled
+ * in the set_specs() call.
+ */
+{
+real realx, realy;
+
+realx = (real)x / 65536.0;
+realy = (real)y / 65536.0;
+
+#if DEBUG
+printf("line_to(%3.1f, %3.1f)\n",
+ realx, realy);
+#endif
+
+line_to(realx, realy);
+}
+
+FUNCTION void sp_close_contour()
+/*
+ * Called by Speedo character generator at the end of each contour
+ * in the outline data of the character.
+ */
+{
+#if DEBUG
+printf("close_curve()\n");
+#endif
+
+close_curve();
+}
+
+FUNCTION void sp_close_outline()
+/*
+ * Called by Speedo character generator at the end of output of the
+ * scaled outline of the character.
+ */
+{
+#if DEBUG
+printf("close_outline()\n");
+#endif
+
+close_outline(set_width_x);
+}
+
diff --git a/nx-X11/lib/font/Speedo/keys.h b/nx-X11/lib/font/Speedo/keys.h
new file mode 100644
index 000000000..dd9d0bff7
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/keys.h
@@ -0,0 +1,56 @@
+/* $Xorg: keys.h,v 1.3 2000/08/17 19:46:25 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+
+/***** DECRYPTION KEY CONSTANTS (PC Platform) *****/
+
+#define CUS0 432 /* Customer number */
+
+#define KEY0 0 /* Decryption key 0 */
+#define KEY1 72 /* Decryption key 1 */
+#define KEY2 123 /* Decryption key 2 */
+#define KEY3 1 /* Decryption key 3 */
+#define KEY4 222 /* Decryption key 4 */
+#define KEY5 194 /* Decryption key 5 */
+#define KEY6 113 /* Decryption key 6 */
+#define KEY7 119 /* Decryption key 7 */
+#define KEY8 52 /* Decryption key 8 */
+
+/***** DECRYPTION KEY CONSTANTS (Sample) *****/
+
+#define XSAMPLEFONTS
+
+#define XCUS0 0 /* Customer number */
+
+#define XKEY0 0 /* Decryption key 0 */
+#define XKEY1 0 /* Decryption key 1 */
+#define XKEY2 0 /* Decryption key 2 */
+#define XKEY3 0 /* Decryption key 3 */
+#define XKEY4 0 /* Decryption key 4 */
+#define XKEY5 0 /* Decryption key 5 */
+#define XKEY6 0 /* Decryption key 6 */
+#define XKEY7 0 /* Decryption key 7 */
+#define XKEY8 0 /* Decryption key 8 */
+
+
diff --git a/nx-X11/lib/font/Speedo/module/Imakefile b/nx-X11/lib/font/Speedo/module/Imakefile
new file mode 100644
index 000000000..e517707c5
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/module/Imakefile
@@ -0,0 +1,47 @@
+XCOMM $XFree86: xc/lib/font/Speedo/module/Imakefile,v 1.5 1999/08/14 10:49:18 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+ INCLUDES = -I$(FONTINCSRC) -I../../include -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I../
+ HEADERS =
+ DEFINES = -DFONTMODULE
+
+ SPEEDOSRCS = do_char.c do_trns.c out_bl2d.c out_blk.c speedomod.c \
+ out_scrn.c out_util.c reset.c set_spcs.c set_trns.c
+ SPEEDOOBJS = do_char.o do_trns.o out_bl2d.o out_blk.o speedomod.o \
+ out_scrn.o out_util.o reset.o set_spcs.o set_trns.o
+
+ SRCS = spfuncs.c spfile.c spinfo.c sperr.c spfont.c spglyph.c \
+ spencode.c bics-unicode.c \
+ $(SPEEDOSRCS)
+ OBJS = spfuncs.o spfile.o spinfo.o sperr.o spfont.o spglyph.o \
+ spencode.o bics-unicode.o \
+ $(SPEEDOOBJS)
+
+LinkSourceFile(bics-unicode.c,..)
+LinkSourceFile(do_char.c,..)
+LinkSourceFile(do_trns.c,..)
+LinkSourceFile(out_bl2d.c,..)
+LinkSourceFile(out_blk.c,..)
+LinkSourceFile(out_scrn.c,..)
+LinkSourceFile(out_util.c,..)
+LinkSourceFile(reset.c,..)
+LinkSourceFile(set_spcs.c,..)
+LinkSourceFile(set_trns.c,..)
+LinkSourceFile(spfuncs.c,..)
+LinkSourceFile(spfile.c,..)
+LinkSourceFile(spinfo.c,..)
+LinkSourceFile(sperr.c,..)
+LinkSourceFile(spfont.c,..)
+LinkSourceFile(spglyph.c,..)
+LinkSourceFile(spencode.c,..)
+
+ModuleObjectRule()
+LibraryModuleTarget(speedo,$(OBJS))
+InstallLibraryModule(speedo,$(MODULEDIR),fonts)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(speedo,$(DRIVERSDKMODULEDIR),fonts)
diff --git a/nx-X11/lib/font/Speedo/module/speedomod.c b/nx-X11/lib/font/Speedo/module/speedomod.c
new file mode 100644
index 000000000..94820fe44
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/module/speedomod.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+/* $XFree86: xc/lib/font/Speedo/module/speedomod.c,v 1.8 2001/09/04 13:49:16 dawes Exp $ */
+
+#include "misc.h"
+
+#include <X11/fonts/fontmod.h>
+#include "xf86Module.h"
+
+static MODULESETUPPROTO(speedoSetup);
+
+ /*
+ * This is the module data function that is accessed when loading
+ * libspeedo as a module.
+ */
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "speedo",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 1,
+ ABI_CLASS_FONT, /* A font module */
+ ABI_FONT_VERSION,
+ MOD_CLASS_FONT,
+ {0,0,0,0} /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData speedoModuleData = { &VersRec, speedoSetup, NULL };
+
+extern void SpeedoRegisterFontFileFunctions(void);
+
+FontModule speedoModule = {
+ SpeedoRegisterFontFileFunctions,
+ "Speedo",
+ NULL
+};
+
+static pointer
+speedoSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ speedoModule.module = module;
+ LoadFont(&speedoModule);
+
+ /* Need a non-NULL return */
+ return (pointer)1;
+}
diff --git a/nx-X11/lib/font/Speedo/nsample.c b/nx-X11/lib/font/Speedo/nsample.c
new file mode 100644
index 000000000..a90367f0a
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/nsample.c
@@ -0,0 +1,745 @@
+/* $Xorg: nsample.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+
+/*************************** N S A M P L E . C *******************************
+ * *
+ * SPEEDO CHARACTER GENERATOR TEST MODULE *
+ * *
+ * This is an illustration of what external resources are required to *
+ * load a Speedo outline and use the Speedo character generator to generate *
+ * bitmaps or scaled outlines according to the desired specification. * *
+ * *
+ * This program loads a Speedo outline, defines a set of character *
+ * generation specifications, generates bitmap (or outline) data for each *
+ * character in the font and prints them on the standard output. *
+ * *
+ * If the font buffer is too small to hold the entire font, the first *
+ * part of the font is loaded. Character data is then loaded dynamically *
+ * as required. *
+ * *
+ ****************************************************************************/
+
+#include <stdio.h>
+#if PROTOS_AVAIL
+#include <stddef.h>
+#include <malloc.h>
+#include <stdlib.h>
+void main(int argc,char *argv[]);
+#else
+void* malloc();
+#endif
+
+#include "speedo.h" /* General definition for make_bmap */
+#include "keys.h" /* Font decryption keys */
+
+#define DEBUG 0
+
+#if DEBUG
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+#define MAX_BITS 256 /* Max line length of generated bitmap */
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC FUNCTIONS *****/
+
+#if PROTOS_AVAIL
+fix31 read_4b(ufix8 FONTFAR *ptr);
+fix15 read_2b(ufix8 FONTFAR *ptr);
+#else
+fix31 read_4b();
+fix15 read_2b();
+#endif
+/***** STATIC VARIABLES *****/
+static char pathname[100]; /* Name of font file to be output */
+static ufix8 FONTFAR *font_buffer; /* Pointer to allocated Font buffer */
+static ufix8 FONTFAR *char_buffer; /* Pointer to allocate Character buffer */
+static buff_t font; /* Buffer descriptor for font data */
+#if INCL_LCD
+static buff_t char_data; /* Buffer descriptor for character data */
+#endif
+static FILE *fdescr; /* Speedo outline file descriptor */
+static ufix16 char_index; /* Index of character to be generated */
+static ufix16 char_id; /* Character ID */
+static ufix16 minchrsz; /* minimum character buffer size */
+
+static ufix8 key[] =
+ {
+ KEY0,
+ KEY1,
+ KEY2,
+ KEY3,
+ KEY4,
+ KEY5,
+ KEY6,
+ KEY7,
+ KEY8
+ }; /* Font decryption key */
+
+static fix15 raswid; /* raster width */
+static fix15 rashgt; /* raster height */
+static fix15 offhor; /* horizontal offset from left edge of emsquare */
+static fix15 offver; /* vertical offset from baseline */
+static fix15 set_width; /* character set width */
+static fix15 y_cur; /* Current y value being generated and printed */
+static char line_of_bits[2 * MAX_BITS + 1]; /* Buffer for row of generated bits */
+
+#if INCL_MULTIDEV
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+bitmap_t bfuncs = { sp_open_bitmap, sp_set_bitmap_bits, sp_close_bitmap };
+#endif
+#if INCL_OUTLINE
+outline_t ofuncs = { sp_open_outline, sp_start_new_char, sp_start_contour, sp_curve_to,
+ sp_line_to, sp_close_contour, sp_close_outline };
+#endif
+#endif
+
+
+ufix8 temp[16]; /* temp buffer for first 16 bytes of font */
+
+
+FUNCTION void main(argc,argv)
+int argc;
+char *argv[];
+{
+ufix16 bytes_read; /* Number of bytes read from font file */
+specs_t specs; /* Bundle of character generation specs */
+int first_char_index; /* Index of first character in font */
+int no_layout_chars; /* number of characters in layout */
+ufix32 i;
+ufix32 minbufsz; /* minimum font buffer size to allocate */
+ufix16 cust_no;
+ufix8 FONTFAR *byte_ptr;
+
+#if REENTRANT_ALLOC
+SPEEDO_GLOBALS* sp_global_ptr;
+#endif
+
+
+if (argc != 2)
+ {
+ fprintf(stderr,"Usage: nsample {fontfile}\n\n");
+ exit (1);
+ }
+
+sprintf(pathname, argv[1]);
+
+/* Load Speedo outline file */
+fdescr = fopen (pathname, "rb");
+if (fdescr == NULL)
+ {
+ printf("****** Cannot open file %s\n", pathname);
+ return;
+ }
+
+/* get minimum font buffer size - read first 16 bytes to get the minimum
+ size field from the header, then allocate buffer dynamically */
+
+bytes_read = fread(temp, sizeof(ufix8), 16, fdescr);
+
+if (bytes_read != 16)
+ {
+ printf("****** Error on reading %s: %x\n", pathname, bytes_read);
+ fclose(fdescr);
+ return;
+ }
+#if INCL_LCD
+minbufsz = (ufix32)read_4b(temp+FH_FBFSZ);
+#else
+minbufsz = (ufix32)read_4b(temp+FH_FNTSZ);
+if (minbufsz >= 0x10000)
+ {
+ printf("****** Cannot process fonts greater than 64K - use dynamic character loading configuration option\n");
+ fclose(fdescr);
+ return;
+ }
+#endif
+
+#if (defined(M_I86SM) || defined(M_I86MM))
+font_buffer = (ufix8 FONTFAR *)_fmalloc((ufix16)minbufsz);
+#else
+font_buffer = (ufix8 *)malloc((ufix16)minbufsz);
+#endif
+
+if (font_buffer == NULL)
+ {
+ printf("****** Unable to allocate memory for font buffer\n");
+ fclose(fdescr);
+ return;
+ }
+
+#if DEBUG
+printf("Loading font file %s\n", pathname);
+#endif
+
+fseek(fdescr, (ufix32)0, 0);
+#if (defined(M_I86SM) || (defined(M_I86MM)))
+byte_ptr = font_buffer;
+for (i=0; i< minbufsz; i++){
+ int ch;
+ ch = getc(fdescr);
+ if (ch == EOF)
+ {printf ("Premature EOF in reading font buffer, %ld bytes read\n",i);
+ exit(2);}
+ *byte_ptr=(ufix8)ch;
+ byte_ptr++;
+ }
+bytes_read = i;
+#else
+bytes_read = fread((ufix8 *)font_buffer, sizeof(ufix8), (ufix16)minbufsz, fdescr);
+if (bytes_read == 0)
+ {
+ printf("****** Error on reading %s: %x\n", pathname, bytes_read);
+ fclose(fdescr);
+ return;
+ }
+#endif
+
+#if INCL_LCD
+/* now allocate minimum character buffer */
+
+minchrsz = read_2b(font_buffer+FH_CBFSZ);
+#if (defined(M_I86SM) || (defined(M_I86MM)))
+char_buffer = (ufix8 FONTFAR *)_fmalloc(minchrsz);
+#else
+char_buffer = (ufix8*)malloc(minchrsz);
+#endif
+
+if (char_buffer == NULL)
+ {
+ printf("****** Unable to allocate memory for character buffer\n");
+ fclose(fdescr);
+ return;
+ }
+#endif
+
+#if DYNAMIC_ALLOC || REENTRANT_ALLOC
+ sp_global_ptr = (SPEEDO_GLOBALS *)malloc(sizeof(SPEEDO_GLOBALS));
+ memset(sp_global_ptr,(ufix8)0,sizeof(SPEEDO_GLOBALS));
+#endif
+
+
+/* Initialization */
+#if REENTRANT_ALLOC
+sp_reset(sp_global_ptr); /* Reset Speedo character generator */
+#else
+sp_reset(); /* Reset Speedo character generator */
+#endif
+
+font.org = font_buffer;
+font.no_bytes = bytes_read;
+
+#if REENTRANT_ALLOC
+if ((cust_no=sp_get_cust_no(sp_global_ptr,font)) != CUS0 && /* NOT STANDARD ENCRYPTION */
+#else
+if ((cust_no=sp_get_cust_no(font)) != CUS0 && /* NOT STANDARD ENCRYPTION */
+#endif
+ cust_no != 0)
+ {
+#if REENTRANT_ALLOC
+ printf("Unable to use fonts for customer number %d\n",
+ sp_get_cust_no(sp_global_ptr(font)));
+#else
+ printf("Unable to use fonts for customer number %d\n",
+ sp_get_cust_no(font));
+#endif
+ fclose(fdescr);
+ return;
+ }
+
+#if INCL_KEYS
+#if REENTRANT_ALLOC
+sp_set_key(sp_global_ptr,key); /* Set decryption key */
+#else
+sp_set_key(key); /* Set decryption key */
+#endif
+#endif
+
+#if INCL_MULTIDEV
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+#if REENTRANT_ALLOC
+sp_set_bitmap_device(sp_global_ptr,&bfuncs,sizeof(bfuncs)); /* Set decryption key */
+#else
+sp_set_bitmap_device(&bfuncs,sizeof(bfuncs)); /* Set decryption key */
+#endif
+#endif
+#if INCL_OUTLINE
+#if REENTRANT_ALLOC
+sp_set_outline_device(sp_global_ptr,&ofuncs,sizeof(ofuncs)); /* Set decryption key */
+#else
+sp_set_outline_device(&ofuncs,sizeof(ofuncs)); /* Set decryption key */
+#endif
+#endif
+#endif
+
+first_char_index = read_2b(font_buffer + FH_FCHRF);
+no_layout_chars = read_2b(font_buffer + FH_NCHRL);
+
+/* Set specifications for character to be generated */
+specs.pfont = &font; /* Pointer to Speedo outline structure */
+specs.xxmult = 25L << 16; /* Coeff of X to calculate X pixels */
+specs.xymult = 0L << 16; /* Coeff of Y to calculate X pixels */
+specs.xoffset = 0L << 16; /* Position of X origin */
+specs.yxmult = 0L << 16; /* Coeff of X to calculate Y pixels */
+specs.yymult = 25L << 16; /* Coeff of Y to calculate Y pixels */
+specs.yoffset = 0L << 16; /* Position of Y origin */
+specs.flags = 0; /* Mode flags */
+specs.out_info = NULL;
+
+
+#if REENTRANT_ALLOC
+if (!sp_set_specs(sp_global_ptr,&specs)) /* Set character generation specifications */
+#else
+if (!sp_set_specs(&specs)) /* Set character generation specifications */
+#endif
+ {
+ printf("****** Cannot set requested specs\n");
+ }
+else
+ {
+ for (i = 0; i < no_layout_chars; i++) /* For each character in font */
+ {
+ char_index = i + first_char_index;
+#if REENTRANT_ALLOC
+ char_id = sp_get_char_id(sp_global_ptr,char_index);
+#else
+ char_id = sp_get_char_id(char_index);
+#endif
+ if (char_id != 0)
+ {
+#if REENTRANT_ALLOC
+ if (!sp_make_char(sp_global_ptr,char_index))
+#else
+ if (!sp_make_char(char_index))
+#endif
+ {
+ printf("****** Cannot generate character %d\n", char_index);
+ }
+ }
+ }
+ }
+
+fclose(fdescr);
+}
+
+#if INCL_LCD
+#if REENTRANT_ALLOC
+FUNCTION buff_t *sp_load_char_data(sp_global_ptr, file_offset, no_bytes, cb_offset)
+SPEEDO_GLOBALS *sp_global_ptr;
+#else
+FUNCTION buff_t *sp_load_char_data(file_offset, no_bytes, cb_offset)
+#endif
+fix31 file_offset; /* Offset in bytes from the start of the font file */
+fix15 no_bytes; /* Number of bytes to be loaded */
+fix15 cb_offset; /* Offset in bytes from start of char buffer */
+/*
+ * Called by Speedo character generator to request that character
+ * data be loaded from the font file into a character data buffer.
+ * The character buffer offset is zero for all characters except elements
+ * of compound characters. If a single buffer is allocated for character
+ * data, cb_offset ensures that sub-character data is loaded after the
+ * top-level compound character.
+ * Returns a pointer to a buffer descriptor.
+ */
+{
+int bytes_read;
+
+#if DEBUG
+printf("\nCharacter data(%d, %d, %d) requested\n", file_offset, no_bytes, cb_offset);
+#endif
+if (fseek(fdescr, (long)file_offset, (int)0) != 0)
+ {
+ printf("****** Error in seeking character\n");
+ fclose(fdescr);
+ exit(1);
+ }
+
+if ((no_bytes + cb_offset) > minchrsz)
+ {
+ printf("****** Character buffer overflow\n");
+ fclose(fdescr);
+ exit(3);
+ }
+
+bytes_read = fread((char_buffer + cb_offset), sizeof(ufix8), no_bytes, fdescr);
+if (bytes_read != no_bytes)
+ {
+ printf("****** Error on reading character data\n");
+ fclose(fdescr);
+ exit(2);
+ }
+
+#if DEBUG
+printf("Character data loaded\n");
+#endif
+
+char_data.org = (ufix8 FONTFAR *)char_buffer + cb_offset;
+char_data.no_bytes = no_bytes;
+return &char_data;
+}
+#endif
+
+
+#if REENTRANT_ALLOC
+FUNCTION void sp_report_error(sp_global_ptr,n)
+SPEEDO_GLOBALS *sp_global_ptr;
+#else
+FUNCTION void sp_report_error(n)
+#endif
+fix15 n; /* Error identification number */
+/*
+ * Called by Speedo character generator to report an error.
+ *
+ * Since character data not available is one of those errors
+ * that happens many times, don't report it to user
+ */
+{
+
+switch(n)
+ {
+case 1:
+ printf("Insufficient font data loaded\n");
+ break;
+
+case 3:
+ printf("Transformation matrix out of range\n");
+ break;
+
+case 4:
+ printf("Font format error\n");
+ break;
+
+case 5:
+ printf("Requested specs not compatible with output module\n");
+ break;
+
+case 7:
+ printf("Intelligent transformation requested but not supported\n");
+ break;
+
+case 8:
+ printf("Unsupported output mode requested\n");
+ break;
+
+case 9:
+ printf("Extended font loaded but only compact fonts supported\n");
+ break;
+
+case 10:
+ printf("Font specs not set prior to use of font\n");
+ break;
+
+case 12:
+ break;
+
+case 13:
+ printf("Track kerning data not available()\n");
+ break;
+
+case 14:
+ printf("Pair kerning data not available()\n");
+ break;
+
+default:
+ printf("report_error(%d)\n", n);
+ break;
+ }
+}
+
+#if REENTRANT_ALLOC
+FUNCTION void sp_open_bitmap(sp_global_ptr, x_set_width, y_set_width, xorg, yorg, xsize, ysize)
+SPEEDO_GLOBALS *sp_global_ptr;
+#else
+FUNCTION void sp_open_bitmap(x_set_width, y_set_width, xorg, yorg, xsize, ysize)
+#endif
+fix31 x_set_width;
+fix31 y_set_width; /* Set width vector */
+fix31 xorg; /* Pixel boundary at left extent of bitmap character */
+fix31 yorg; /* Pixel boundary at right extent of bitmap character */
+fix15 xsize; /* Pixel boundary of bottom extent of bitmap character */
+fix15 ysize; /* Pixel boundary of top extent of bitmap character */
+/*
+ * Called by Speedo character generator to initialize a buffer prior
+ * to receiving bitmap data.
+ */
+{
+fix15 i;
+
+#if DEBUG
+printf("open_bitmap(%3.1f, %3.1f, %3.1f, %3.1f, %d, %d)\n",
+ (real)x_set_width / 65536.0, (real)y_set_width / 65536.0,
+ (real)xorg / 65536.0, (real)yorg / 65536.0, (int)xsize, (int)ysize);
+#endif
+raswid = xsize;
+rashgt = ysize;
+offhor = (fix15)(xorg >> 16);
+offver = (fix15)(yorg >> 16);
+
+if (raswid > MAX_BITS)
+ raswid = MAX_BITS;
+
+printf("\nCharacter index = %d, ID = %d\n", char_index, char_id);
+printf("set width = %3.1f, %3.1f\n", (real)x_set_width / 65536.0, (real)y_set_width / 65536.0);
+printf("X offset = %d\n", offhor);
+printf("Y offset = %d\n\n", offver);
+for (i = 0; i < raswid; i++)
+ {
+ line_of_bits[i << 1] = '.';
+ line_of_bits[(i << 1) + 1] = ' ';
+ }
+line_of_bits[raswid << 1] = '\0';
+y_cur = 0;
+}
+
+#if REENTRANT_ALLOC
+FUNCTION void sp_set_bitmap_bits (sp_global_ptr, y, xbit1, xbit2)
+SPEEDO_GLOBALS *sp_global_ptr;
+#else
+FUNCTION void sp_set_bitmap_bits (y, xbit1, xbit2)
+#endif
+ fix15 y; /* Scan line (0 = first row above baseline) */
+ fix15 xbit1; /* Pixel boundary where run starts */
+ fix15 xbit2; /* Pixel boundary where run ends */
+
+/*
+ * Called by Speedo character generator to write one row of pixels
+ * into the generated bitmap character.
+ */
+
+{
+fix15 i;
+
+#if DEBUG
+printf("set_bitmap_bits(%d, %d, %d)\n", (int)y, (int)xbit1, (int)xbit2);
+#endif
+/* Clip runs beyond end of buffer */
+if (xbit1 > MAX_BITS)
+ xbit1 = MAX_BITS;
+
+if (xbit2 > MAX_BITS)
+ xbit2 = MAX_BITS;
+
+/* Output backlog lines if any */
+while (y_cur != y)
+ {
+ printf(" %s\n", line_of_bits);
+ for (i = 0; i < raswid; i++)
+ {
+ line_of_bits[i << 1] = '.';
+ }
+ y_cur++;
+ }
+
+/* Add bits to current line */
+for (i = xbit1; i < xbit2; i++)
+ {
+ line_of_bits[i << 1] = 'X';
+ }
+}
+
+#if REENTRANT_ALLOC
+FUNCTION void sp_close_bitmap(sp_global_ptr)
+SPEEDO_GLOBALS *sp_global_ptr;
+#else
+FUNCTION void sp_close_bitmap()
+#endif
+/*
+ * Called by Speedo character generator to indicate all bitmap data
+ * has been generated.
+ */
+{
+#if DEBUG
+printf("close_bitmap()\n");
+#endif
+printf(" %s\n", line_of_bits);
+}
+
+#if INCL_OUTLINE
+#if REENTRANT_ALLOC
+FUNCTION void sp_open_outline(sp_global_ptr, x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+SPEEDO_GLOBALS *sp_global_ptr;
+#else
+FUNCTION void sp_open_outline(x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#endif
+fix31 x_set_width;
+fix31 y_set_width; /* Transformed escapement vector */
+fix31 xmin; /* Minimum X value in outline */
+fix31 xmax; /* Maximum X value in outline */
+fix31 ymin; /* Minimum Y value in outline */
+fix31 ymax; /* Maximum Y value in outline */
+/*
+ * Called by Speedo character generator to initialize prior to
+ * outputting scaled outline data.
+ */
+{
+printf("\nopen_outline(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n",
+ (real)x_set_width / 65536.0, (real)y_set_width / 65536.0,
+ (real)xmin / 65536.0, (real)xmax / 65536.0, (real)ymin / 65536.0, (real)ymax / 65536.0);
+}
+
+
+#if REENTRANT_ALLOC
+FUNCTION void sp_start_new_char(sp_global_ptr)
+SPEEDO_GLOBALS *sp_global_ptr;
+#else
+FUNCTION void sp_start_new_char()
+#endif
+/*
+ * Called by Speedo character generator to initialize prior to
+ * outputting scaled outline data for a sub-character in a compound
+ * character.
+ */
+{
+printf("start_new_char()\n");
+}
+
+#if REENTRANT_ALLOC
+FUNCTION void sp_start_contour(sp_global_ptr, x, y, outside)
+SPEEDO_GLOBALS *sp_global_ptr;
+#else
+FUNCTION void sp_start_contour(x, y, outside)
+#endif
+fix31 x; /* X coordinate of start point in 1/65536 pixels */
+fix31 y; /* Y coordinate of start point in 1/65536 pixels */
+boolean outside; /* TRUE if curve encloses ink (Counter-clockwise) */
+/*
+ * Called by Speedo character generator at the start of each contour
+ * in the outline data of the character.
+ */
+{
+printf("start_contour(%3.1f, %3.1f, %s)\n",
+ (real)x / 65536.0, (real)y / 65536.0,
+ outside? "outside": "inside");
+}
+
+#if REENTRANT_ALLOC
+FUNCTION void sp_curve_to(sp_global_ptr, x1, y1, x2, y2, x3, y3)
+SPEEDO_GLOBALS *sp_global_ptr;
+#else
+FUNCTION void sp_curve_to(x1, y1, x2, y2, x3, y3)
+#endif
+fix31 x1; /* X coordinate of first control point in 1/65536 pixels */
+fix31 y1; /* Y coordinate of first control point in 1/65536 pixels */
+fix31 x2; /* X coordinate of second control point in 1/65536 pixels */
+fix31 y2; /* Y coordinate of second control point in 1/65536 pixels */
+fix31 x3; /* X coordinate of curve end point in 1/65536 pixels */
+fix31 y3; /* Y coordinate of curve end point in 1/65536 pixels */
+/*
+ * Called by Speedo character generator onece for each curve in the
+ * scaled outline data of the character. This function is only called if curve
+ * output is enabled in the set_specs() call.
+ */
+{
+printf("curve_to(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n",
+ (real)x1 / 65536.0, (real)y1 / 65536.0,
+ (real)x2 / 65536.0, (real)y2 / 65536.0,
+ (real)x3 / 65536.0, (real)y3 / 65536.0);
+}
+
+#if REENTRANT_ALLOC
+FUNCTION void sp_line_to(sp_global_ptr, x, y)
+SPEEDO_GLOBALS *sp_global_ptr;
+#else
+FUNCTION void sp_line_to(x, y)
+#endif
+fix31 x; /* X coordinate of vector end point in 1/65536 pixels */
+fix31 y; /* Y coordinate of vector end point in 1/65536 pixels */
+/*
+ * Called by Speedo character generator onece for each vector in the
+ * scaled outline data for the character. This include curve data that has
+ * been sub-divided into vectors if curve output has not been enabled
+ * in the set_specs() call.
+ */
+{
+printf("line_to(%3.1f, %3.1f)\n",
+ (real)x / 65536.0, (real)y / 65536.0);
+}
+
+
+#if REENTRANT_ALLOC
+FUNCTION void sp_close_contour(sp_global_ptr)
+SPEEDO_GLOBALS *sp_global_ptr;
+#else
+FUNCTION void sp_close_contour()
+#endif
+/*
+ * Called by Speedo character generator at the end of each contour
+ * in the outline data of the character.
+ */
+{
+printf("close_contour()\n");
+}
+
+#if REENTRANT_ALLOC
+FUNCTION void sp_close_outline(sp_global_ptr)
+SPEEDO_GLOBALS *sp_global_ptr;
+#else
+FUNCTION void sp_close_outline()
+#endif
+/*
+ * Called by Speedo character generator at the end of output of the
+ * scaled outline of the character.
+ */
+{
+printf("close_outline()\n");
+}
+
+#endif
+
+FUNCTION fix15 read_2b(pointer)
+ufix8 FONTFAR *pointer;
+/*
+ * Reads 2-byte field from font buffer
+ */
+{
+fix15 temp;
+
+temp = *pointer++;
+temp = (temp << 8) + *(pointer);
+return temp;
+}
+
+
+ FUNCTION fix31 read_4b(pointer)
+ufix8 FONTFAR *pointer;
+/*
+ * Reads 4-byte field from font buffer
+ */
+{
+fix31 temp;
+
+temp = *pointer++;
+temp = (temp << 8) + *(pointer++);
+temp = (temp << 8) + *(pointer++);
+temp = (temp << 8) + *(pointer);
+return temp;
+}
+
+
diff --git a/nx-X11/lib/font/Speedo/out_bl2d.c b/nx-X11/lib/font/Speedo/out_bl2d.c
new file mode 100644
index 000000000..6c38cb30d
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/out_bl2d.c
@@ -0,0 +1,772 @@
+/* $Xorg: out_bl2d.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/out_bl2d.c,v 1.3 1999/02/07 11:47:14 dawes Exp $ */
+
+/*************************** O U T _ B L 2 D . C *****************************
+ * *
+ * This is an output module for screen writer using two dimensional scanning *
+ ****************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "spdo_prv.h" /* General definitions for speedo */
+
+#define CLOCKWISE 1
+#define DEBUG 0
+#define ABS(X) ( (X < 0) ? -X : X)
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** STATIC FUNCTIONS *****/
+
+#if INCL_2D
+static void sp_draw_vector_to_2d(PROTO_DECL2 fix15 x0,fix15 y0,fix15 x1,fix15 y1,band_t GLOBALFAR *band);
+static void sp_add_intercept_2d(PROTO_DECL2 fix15 y,fix15 x);
+static void sp_proc_intercepts_2d(PROTO_DECL1);
+#endif
+
+#if INCL_2D
+FUNCTION boolean init_2d(
+GDECL
+specs_t GLOBALFAR *specsarg)
+/*
+ * init_out_2d() is called by sp_set_specs() to initialize the output module.
+ * Returns TRUE if output module can accept requested specifications.
+ * Returns FALSE otherwise.
+ */
+{
+
+if (specsarg->flags & CURVES_OUT)
+ return FALSE; /* Curves out, clipping not supported */
+
+#if DEBUG
+printf("INIT_OUT__2d()\n");
+#endif
+return TRUE;
+}
+#endif
+
+#if INCL_2D
+FUNCTION boolean begin_char_2d(
+GDECL
+point_t Psw,
+point_t Pmin,
+point_t Pmax)
+/* Called once at the start of the character generation process
+ * Initializes intercept table, either calculates pixel maxima or
+ * decides that they need to be collected
+ */
+{
+#if DEBUG
+printf("BEGIN_CHAR__2d(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
+ (real)Psw.x / (real)sp_globals.onepix, (real)Psw.y / (real)sp_globals.onepix,
+ (real)Pmin.x / (real)sp_globals.onepix, (real)Pmin.y / (real)sp_globals.onepix,
+ (real)Pmax.x / (real)sp_globals.onepix, (real)Pmax.y / (real)sp_globals.onepix);
+#endif
+/* Convert PIX.FRAC to 16.16 form */
+sp_globals.x_scan_active = TRUE; /* Assume x-scanning from the start */
+
+init_char_out(Psw,Pmin,Pmax);
+return TRUE;
+}
+#endif
+
+
+#if INCL_2D
+FUNCTION void begin_contour_2d(
+GDECL
+point_t P1,
+boolean outside)
+/* Called at the start of each contour
+ */
+{
+
+#if DEBUG
+printf("BEGIN_CONTOUR__2d(%3.4f, %3.4f, %s)\n",
+ (real)P1.x / (real)sp_globals.onepix,
+ (real)P1.y / (real)sp_globals.onepix,
+ outside? "outside": "inside");
+#endif
+sp_globals.x0_spxl = P1.x;
+sp_globals.y0_spxl = P1.y;
+}
+#endif
+
+#if INCL_2D
+FUNCTION void line_2d(
+GDECL
+point_t P1)
+/*
+ * Called for each vector in the transformed character
+ * "draws" vector into intercept table
+ */
+{
+
+#if DEBUG
+printf("LINE_0(%3.4f, %3.4f)\n",
+ (real)P1.x / (real)sp_globals.onepix,
+ (real)P1.y / (real)sp_globals.onepix);
+#endif
+
+if (sp_globals.extents_running)
+ {
+ if (sp_globals.x0_spxl > sp_globals.bmap_xmax)
+ sp_globals.bmap_xmax = sp_globals.x0_spxl;
+ if (sp_globals.x0_spxl < sp_globals.bmap_xmin)
+ sp_globals.bmap_xmin = sp_globals.x0_spxl;
+ if (sp_globals.y0_spxl > sp_globals.bmap_ymax)
+ sp_globals.bmap_ymax = sp_globals.y0_spxl;
+ if (sp_globals.y0_spxl < sp_globals.bmap_ymin)
+ sp_globals.bmap_ymin = sp_globals.y0_spxl;
+ }
+
+if (!sp_globals.intercept_oflo)
+ {
+ sp_draw_vector_to_2d(sp_globals.x0_spxl,
+ sp_globals.y0_spxl,
+ P1.x,
+ P1.y,
+ &sp_globals.y_band); /* y-scan */
+
+ if (sp_globals.x_scan_active)
+ sp_draw_vector_to_2d(sp_globals.y0_spxl,
+ sp_globals.x0_spxl,
+ P1.y,
+ P1.x,
+ &sp_globals.x_band); /* x-scan if selected */
+ }
+
+sp_globals.x0_spxl = P1.x;
+sp_globals.y0_spxl = P1.y; /* update endpoint */
+}
+
+FUNCTION static void sp_draw_vector_to_2d(
+GDECL
+fix15 x0, /* X coordinate */
+fix15 y0, /* Y coordinate */
+fix15 x1,
+fix15 y1,
+band_t GLOBALFAR *band)
+{
+register fix15 how_many_y; /* # of intercepts at y = n + 1/2 */
+register fix15 yc; /* Current scan-line */
+ fix15 temp1; /* various uses */
+ fix15 temp2; /* various uses */
+register fix31 dx_dy; /* slope of line in 16.16 form */
+register fix31 xc; /* high-precision (16.16) x coordinate */
+ fix15 y_pxl;
+
+yc = (y0 + sp_globals.pixrnd) >> sp_globals.pixshift; /* current scan line = end of last line */
+y_pxl = (y1 + sp_globals.pixrnd) >> sp_globals.pixshift; /* calculate new end-scan line */
+
+if ((how_many_y = y_pxl - yc) == 0) return; /* Don't draw a null line */
+
+if (how_many_y < 0) yc--; /* Predecrment downward lines */
+
+if (yc > band->band_max) /* Is start point above band? */
+ {
+ if (y_pxl > band->band_max) return; /* line has to go down! */
+ how_many_y = y_pxl - (yc = band->band_max) - 1; /* Yes, limit it */
+ }
+
+if (yc < band->band_min) /* Is start point below band? */
+ {
+ if (y_pxl < band->band_min) return; /* line has to go up! */
+ how_many_y = y_pxl - (yc = band->band_min); /* Yes, limit it */
+ }
+
+xc = (fix31)(x0 + sp_globals.pixrnd) << 16; /* Original x coordinate with built in */
+ /* rounding. int.16 + pixshift form */
+
+if ( (temp1 = (x1 - x0)) == 0) /* check for vertical line */
+ {
+ dx_dy = 0L; /* Zero slope, leave xc alone */
+ goto skip_calc;
+ }
+
+/* calculate dx_dy at 16.16 fixed point */
+
+dx_dy = ( (fix31)temp1 << 16 )/(fix31)(y1 - y0);
+
+/* We have to check for a @#$%@# possible multiply overflow */
+/* by doing another @#$*& multiply. In assembly language, */
+/* the program could just check the OVerflow flag or whatever*/
+/* works on the particular processor. This C code is meant */
+/* to be processor independent. */
+
+temp1 = (yc << sp_globals.pixshift) - y0 + sp_globals.pixrnd;
+/* This sees if the sign bits start at bit 15 */
+/* if they do, no overflow has occurred */
+
+temp2 = (fix15)(MULT16(temp1,(fix15)(dx_dy >> 16)) >> 15);
+
+if ( (temp2 != (fix15)0xFFFF) &&
+ (temp2 != 0x0000) )
+ { /* Overflow. Pick point closest to yc + .5 */
+ if (ABS(temp1) < ABS((yc << sp_globals.pixshift) - y1 + sp_globals.pixrnd))
+ { /* use x1 instead of x0 */
+ xc = (fix31)(x1 + sp_globals.pixrnd) << (16 - sp_globals.pixshift);
+ }
+ goto skip_calc;
+ }
+/* calculate new xc at the center of the *current* scan line */
+/* due to banding, yc may be several lines away from y0 */
+/* xc += (yc + .5 - y0) * dx_dy */
+/* This multiply generates a subpixel delta. */
+/* So we leave it as an int.pixshift + 16 delta */
+
+xc += (fix31)temp1 * dx_dy;
+dx_dy <<= sp_globals.pixshift;
+skip_calc:
+
+yc -= band->band_array_offset; /* yc is now an offset relative to the band */
+
+if (how_many_y < 0)
+ { /* Vector down */
+ if ((how_many_y += yc + 1) < band->band_floor)
+ how_many_y = band->band_floor; /* can't go below floor */
+ while(yc >= how_many_y)
+ {
+ temp1 = (fix15)(xc >> 16);
+ sp_add_intercept_2d(yc--,temp1);
+ xc -= dx_dy;
+ }
+ }
+ else
+ { /* Vector up */
+ /* check to see that line doesn't extend beyond top of band */
+ if ((how_many_y += yc) > band->band_ceiling)
+ how_many_y = band->band_ceiling;
+ while(yc < how_many_y)
+ {
+ temp1 = (fix15)(xc >> 16);
+ sp_add_intercept_2d(yc++,temp1);
+ xc += dx_dy;
+ }
+ }
+}
+
+#endif
+
+#if INCL_2D
+FUNCTION boolean end_char_2d()
+/* Called when all character data has been output
+ * Return TRUE if output process is complete
+ * Return FALSE to repeat output of the transformed data beginning
+ * with the first contour
+ */
+{
+
+fix31 xorg;
+fix31 yorg;
+#if INCL_CLIPPING
+fix31 em_max, em_min, bmap_max, bmap_min;
+#endif
+
+#if DEBUG
+printf("END_CHAR__2d()\n");
+#endif
+
+if (sp_globals.first_pass)
+ {
+ if (sp_globals.bmap_xmax >= sp_globals.bmap_xmin)
+ {
+ sp_globals.xmin = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ sp_globals.xmax = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ }
+ else
+ {
+ sp_globals.xmin = sp_globals.xmax = 0;
+ }
+ if (sp_globals.bmap_ymax >= sp_globals.bmap_ymin)
+ {
+
+#if INCL_CLIPPING
+ switch(sp_globals.tcb0.xtype)
+ {
+ case 1: /* 180 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ sp_globals.clip_ymin = -1 * sp_globals.clip_ymin;
+ if (bmap_min < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ else
+ sp_globals.ymin = bmap_min;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max < sp_globals.clip_ymax)
+ sp_globals.ymax = bmap_max;
+ else
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ sp_globals.clip_xmax = -sp_globals.xmin;
+ sp_globals.clip_xmin = ((sp_globals.set_width.x+32768L) >> 16) -
+ sp_globals.xmin;
+ break;
+ case 2: /* 90 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_xmin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift;
+ sp_globals.clip_xmin = -1 * sp_globals.clip_xmin;
+ bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ if (bmap_min > sp_globals.clip_xmin)
+ sp_globals.clip_xmin = bmap_min;
+
+ /* normalize to x origin */
+ sp_globals.clip_xmin -= sp_globals.xmin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_xmax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max < sp_globals.clip_xmax)
+ sp_globals.xmax = bmap_max;
+ else
+ sp_globals.xmax = sp_globals.clip_xmax;
+ sp_globals.clip_ymax = 0;
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ /* normalize to x origin */
+ sp_globals.clip_xmax -= sp_globals.xmin;
+ }
+ break;
+ case 3: /* 270 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_xmin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift;
+ sp_globals.clip_xmin = -1 * sp_globals.clip_xmin;
+ bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+
+ /* let the minimum be the larger of these two values */
+ if (bmap_min > sp_globals.clip_xmin)
+ sp_globals.clip_xmin = bmap_min;
+
+ /* normalize the x value to new xorgin */
+ sp_globals.clip_xmin -= sp_globals.xmin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_xmax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+ /* let the max be the lesser of these two values */
+ if (bmap_max < sp_globals.clip_xmax)
+ {
+ sp_globals.xmax = bmap_max;
+ sp_globals.clip_xmax = bmap_max;
+ }
+ else
+ sp_globals.xmax = sp_globals.clip_xmax;
+
+ /* normalize the x value to new x origin */
+ sp_globals.clip_xmax -= sp_globals.xmin;
+ }
+ /* compute y clip values */
+ sp_globals.clip_ymax = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = 0;
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ break;
+ default: /* this is for zero degree rotation and arbitrary rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max > sp_globals.clip_ymax)
+ sp_globals.ymax = bmap_max;
+ else
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ sp_globals.clip_ymin = - sp_globals.clip_ymin;
+ bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ if (bmap_min < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ else
+ sp_globals.ymin = bmap_min;
+ }
+ sp_globals.clip_xmin = -sp_globals.xmin;
+ sp_globals.clip_xmax = ((sp_globals.set_width.x+32768L) >> 16) -
+ sp_globals.xmin;
+ break;
+ }
+if ( !(sp_globals.specs.flags & CLIP_TOP))
+#endif
+ sp_globals.ymax = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+#if INCL_CLIPPING
+if ( !(sp_globals.specs.flags & CLIP_BOTTOM))
+#endif
+ sp_globals.ymin = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ }
+ else
+ {
+ sp_globals.ymin = sp_globals.ymax = 0;
+ }
+
+ /* add in the rounded out part (from xform.) of the left edge */
+ if (sp_globals.tcb.xmode == 0) /* for X pix is function of X orus only add the round */
+ xorg = (((fix31)sp_globals.xmin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift));
+ else
+ if (sp_globals.tcb.xmode == 1) /* for X pix is function of -X orus only, subtr. round */
+ xorg = (((fix31)sp_globals.xmin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift)) ;
+ else
+ xorg = (fix31)sp_globals.xmin << 16; /* for other cases don't use round on x */
+
+ if (sp_globals.tcb.ymode == 2) /* for Y pix is function of X orus only, add round error */
+ yorg = (((fix31)sp_globals.ymin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift));
+ else
+ if (sp_globals.tcb.ymode == 3) /* for Y pix is function of -X orus only, sub round */
+ yorg = (((fix31)sp_globals.ymin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift));
+ else /* all other cases have no round error on yorg */
+ yorg = (fix31)sp_globals.ymin << 16;
+
+ open_bitmap(sp_globals.set_width.x, sp_globals.set_width.y, xorg, yorg,
+ sp_globals.xmax - sp_globals.xmin, sp_globals.ymax - sp_globals.ymin);
+ if (sp_globals.intercept_oflo)
+ {
+ sp_globals.y_band.band_min = sp_globals.ymin;
+ sp_globals.y_band.band_max = sp_globals.ymax;
+ sp_globals.x_scan_active = FALSE;
+ sp_globals.no_x_lists = 0;
+ init_intercepts_out();
+ sp_globals.first_pass = FALSE;
+ sp_globals.extents_running = FALSE;
+ return FALSE;
+ }
+ else
+ {
+ sp_proc_intercepts_2d();
+ close_bitmap();
+ return TRUE;
+ }
+ }
+else
+ {
+ if (sp_globals.intercept_oflo)
+ {
+ reduce_band_size_out();
+ init_intercepts_out();
+ return FALSE;
+ }
+ else
+ {
+ sp_proc_intercepts_2d();
+ if (next_band_out())
+ {
+ init_intercepts_out();
+ return FALSE;
+ }
+ close_bitmap();
+ return TRUE;
+ }
+ }
+}
+#endif
+
+#if INCL_2D
+FUNCTION static void sp_add_intercept_2d(
+GDECL
+fix15 y, /* Y coordinate in relative pixel units */
+ /* (0 is lowest sample in band) */
+fix15 x) /* X coordinate of intercept in subpixel units */
+
+/* Called by line() to add an intercept to the intercept list structure
+ */
+
+{
+register fix15 from; /* Insertion pointers for the linked list sort */
+register fix15 to;
+
+#if DEBUG
+/* Bounds checking IS done in debug mode */
+if ((y >= MAX_INTERCEPTS) || (y < 0))
+ {
+ printf("Intercept out of table!!!!! (%d)\n",y);
+ return;
+ }
+
+if (y >= sp_globals.no_y_lists)
+ {
+ printf(" Add x intercept(%2d, %f)\n",
+ y + sp_globals.x_band.band_min - sp_globals.no_y_lists,
+ (real)x/(real)sp_globals.onepix);
+ if (y > (sp_globals.no_x_lists + sp_globals.no_y_lists))
+ {
+ printf(" Intercept too big for band!!!!!\007\n");
+ return;
+ }
+ }
+ else
+ {
+ printf(" Add y intercept(%2d, %f)\n", y + sp_globals.y_band.band_min,(real)x/(real)sp_globals.onepix);
+ }
+
+if (y < 0) /* Y value below bottom of current band? */
+ {
+ printf(" Intecerpt less than 0!!!\007\n");
+ return;
+ }
+#endif
+
+/* Store new values */
+
+sp_intercepts.car[sp_globals.next_offset] = x;
+
+/* Find slot to insert new element (between from and to) */
+
+from = y; /* Start at list head */
+
+while( (to = sp_intercepts.cdr[from]) >= sp_globals.first_offset) /* Until to == end of list */
+ {
+ if (x <= sp_intercepts.car[to]) /* If next item is larger than or same as this one... */
+ goto insert_element; /* ... drop out and insert here */
+ from = to; /* move forward in list */
+ }
+
+insert_element: /* insert element "next_offset" between elements "from" */
+ /* and "to" */
+
+sp_intercepts.cdr[from] = sp_globals.next_offset;
+sp_intercepts.cdr[sp_globals.next_offset] = to;
+
+if (++sp_globals.next_offset >= MAX_INTERCEPTS) /* Intercept buffer full? */
+ {
+ sp_globals.intercept_oflo = TRUE;
+/* There may be a few more calls to "add_intercept" from the current line */
+/* To avoid problems, we set next_offset to a safe value. We don't care */
+/* if the intercept table gets trashed at this point */
+ sp_globals.next_offset = sp_globals.first_offset;
+ }
+}
+
+#endif
+
+#if INCL_2D
+FUNCTION static void sp_proc_intercepts_2d()
+/* Called by sp_make_char to output accumulated intercept lists
+ * Clips output to xmin, xmax, sp_globals.ymin, ymax boundaries
+ */
+{
+register fix15 i;
+register fix15 from, to; /* Start and end of run in pixel units
+ relative to left extent of character */
+register fix15 y;
+register fix15 scan_line;
+ fix15 local_bmap_xmin;
+ fix15 local_bmap_xmax;
+ fix15 first_y, last_y;
+ fix15 j,k;
+
+#if INCL_CLIPPING
+if ((sp_globals.specs.flags & CLIP_LEFT) != 0)
+ clipleft = TRUE;
+else
+ clipleft = FALSE;
+if ((sp_globals.specs.flags & CLIP_RIGHT) != 0)
+ clipright = TRUE;
+else
+ clipright = FALSE;
+if (clipleft || clipright)
+ {
+ xmax = sp_globals.clip_xmax << sp_globals.pixshift;
+ xmin = sp_globals.clip_xmin << sp_globals.pixshift;
+ }
+if (!clipright)
+ xmax = ((sp_globals.set_width.x+32768L) >> 16);
+#endif
+
+if (sp_globals.x_scan_active) /* If xscanning, we need to make sure we don't miss any important pixels */
+ {
+ first_y = sp_globals.x_band.band_floor; /* start of x lists */
+ last_y = sp_globals.x_band.band_ceiling; /* end of x lists */
+ for (y = first_y; y != last_y; y++) /* scan all xlists */
+ {
+ i = sp_intercepts.cdr[y]; /* Index head of intercept list */
+ while (i != 0) /* Link to next intercept if present */
+ {
+ from = sp_intercepts.car[i];
+ j = i;
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ if (i == 0) /* End of list? */
+ {
+#if DEBUG
+ printf("****** proc_intercepts: odd number of intercepts in x list\n");
+#endif
+ break;
+ }
+ to = sp_intercepts.car[i];
+ k = sp_intercepts.cdr[i];
+ if (((to >> sp_globals.pixshift) >= (from >> sp_globals.pixshift)) &&
+ ((to - from) < (sp_globals.onepix + 1)))
+ {
+ from = ((fix31)to + (fix31)from - (fix31)sp_globals.onepix) >> (sp_globals.pixshift + 1);
+ if (from > sp_globals.y_band.band_max)
+ from = sp_globals.y_band.band_max;
+ if ((from -= sp_globals.y_band.band_min) < 0)
+ from = 0;
+ to = ((y - sp_globals.x_band.band_floor + sp_globals.x_band.band_min)
+ << sp_globals.pixshift)
+ + sp_globals.pixrnd;
+ sp_intercepts.car[j] = to;
+ sp_intercepts.car[i] = to + sp_globals.onepix;
+ sp_intercepts.cdr[i] = sp_intercepts.cdr[from];
+ sp_intercepts.cdr[from] = j;
+ }
+ i = k;
+ }
+ }
+ }
+#if DEBUG
+printf("\nIntercept lists:\n");
+#endif
+
+if ((first_y = sp_globals.y_band.band_max) >= sp_globals.ymax)
+ first_y = sp_globals.ymax - 1; /* Clip to ymax boundary */
+
+if ((last_y = sp_globals.y_band.band_min) < sp_globals.ymin)
+ last_y = sp_globals.ymin; /* Clip to sp_globals.ymin boundary */
+
+last_y -= sp_globals.y_band.band_array_offset;
+
+local_bmap_xmin = sp_globals.xmin << sp_globals.pixshift;
+local_bmap_xmax = (sp_globals.xmax << sp_globals.pixshift) + sp_globals.pixrnd;
+
+#if DEBUG
+/* Print out all of the intercept info */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = y; /* Index head of intercept list */
+ while ((i = sp_intercepts.cdr[i]) != 0) /* Link to next intercept if present */
+ {
+ if ((from = sp_intercepts.car[i] - local_bmap_xmin) < 0)
+ from = 0; /* Clip to xmin boundary */
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ if (i == 0) /* End of list? */
+ {
+ printf("****** proc_intercepts: odd number of intercepts\n");
+ break;
+ }
+ if ((to = sp_intercepts.car[i]) > sp_globals.bmap_xmax)
+ to = sp_globals.bmap_xmax - local_bmap_xmin; /* Clip to xmax boundary */
+ else
+ to -= local_bmap_xmin;
+ printf(" Y = %2d (scanline %2d): %3.4f %3.4f:\n",
+ y + sp_globals.y_band.band_min,
+ scan_line,
+ (real)from / (real)sp_globals.onepix,
+ (real)to / (real)sp_globals.onepix);
+ }
+ }
+#endif
+
+/* Draw the image */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = y; /* Index head of intercept list */
+ while ((i = sp_intercepts.cdr[i]) != 0) /* Link to next intercept if present */
+ {
+ if ((from = sp_intercepts.car[i] - local_bmap_xmin) < 0)
+ from = 0; /* Clip to xmin boundary */
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+
+ if ((to = sp_intercepts.car[i]) > local_bmap_xmax)
+ to = sp_globals.bmap_xmax - local_bmap_xmin; /* Clip to xmax boundary */
+ else
+ to -= local_bmap_xmin;
+#if INCL_CLIPPING
+ if (clipleft)
+ {
+ if (to <= xmin)
+ continue;
+ if (from < xmin)
+ from = xmin;
+ }
+ if (clipright)
+ {
+ if (from >= xmax)
+ continue;
+ if (to > xmax)
+ to = xmax;
+ }
+#endif
+ if ( (to - from) <= sp_globals.onepix)
+ {
+ from = (to + from - sp_globals.onepix) >> (sp_globals.pixshift + 1);
+ set_bitmap_bits(scan_line, from, from + 1);
+ }
+ else
+ {
+ set_bitmap_bits(scan_line, from >> sp_globals.pixshift, to >> sp_globals.pixshift);
+ }
+ }
+ }
+}
+
+#endif
diff --git a/nx-X11/lib/font/Speedo/out_blk.c b/nx-X11/lib/font/Speedo/out_blk.c
new file mode 100644
index 000000000..a5b669b2a
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/out_blk.c
@@ -0,0 +1,706 @@
+/* $Xorg: out_blk.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/out_blk.c,v 1.2 1999/02/07 06:18:16 dawes Exp $ */
+
+
+/*************************** O U T _ B L K . C *********************************
+ * *
+ * This is an output module for black-writer mode. *
+ * *
+ *****************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "spdo_prv.h" /* General definitions for Speedo */
+
+#define DEBUG 0
+#define LOCAL static
+#define ABS(X) ( (X < 0) ? -X : X)
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** STATIC FUNCTIONS *****/
+
+#if INCL_BLACK
+static void sp_add_intercept_black(PROTO_DECL2 fix15 y, fix15 x);
+static void sp_proc_intercepts_black(PROTO_DECL1);
+#endif
+
+
+#if INCL_BLACK
+FUNCTION boolean init_black(
+GDECL
+specs_t GLOBALFAR *specsarg)
+/*
+ * init_out0() is called by sp_set_specs() to initialize the output module.
+ * Returns TRUE if output module can accept requested specifications.
+ * Returns FALSE otherwise.
+ */
+{
+#if DEBUG
+printf("INIT_BLK()\n");
+#endif
+if (specsarg->flags & CURVES_OUT)
+ return FALSE; /* Curves out not supported */
+return (TRUE);
+}
+#endif
+
+
+#if INCL_BLACK
+FUNCTION boolean begin_char_black(
+GDECL
+point_t Psw,
+point_t Pmin,
+point_t Pmax)
+/* Called once at the start of the character generation process
+ */
+{
+#if DEBUG
+printf("BEGIN_CHAR_BLACK(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
+ (real)Psw.x / (real)sp_globals.onepix, (real)Psw.y / (real)sp_globals.onepix,
+ (real)Pmin.x / (real)sp_globals.onepix, (real)Pmin.y / (real)sp_globals.onepix,
+ (real)Pmax.x / (real)sp_globals.onepix, (real)Pmax.y / (real)sp_globals.onepix);
+#endif
+init_char_out(Psw,Pmin,Pmax);
+return TRUE;
+}
+#endif
+
+
+#if INCL_BLACK
+FUNCTION void begin_contour_black(
+GDECL
+point_t P1,
+boolean outside)
+/* Called at the start of each contour
+ */
+{
+
+#if DEBUG
+printf("BEGIN_CONTOUR_BLACK(%3.1f, %3.1f, %s)\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix, outside? "outside": "inside");
+#endif
+sp_globals.x0_spxl = P1.x;
+sp_globals.y0_spxl = P1.y;
+sp_globals.y_pxl = (sp_globals.y0_spxl + sp_globals.pixrnd) >> sp_globals.pixshift;
+}
+#endif
+
+#if INCL_BLACK
+FUNCTION void line_black(
+GDECL
+point_t P1)
+/* Called for each vector in the transformed character
+ */
+{
+register fix15 how_many_y; /* # of intercepts at y = n + 1/2 */
+register fix15 yc, i; /* Current scan-line */
+ fix15 temp1; /* various uses */
+ fix15 temp2; /* various uses */
+register fix31 dx_dy; /* slope of line in 16.16 form */
+register fix31 xc; /* high-precision (16.16) x coordinate */
+ fix15 x0,y0,x1,y1; /* PIX.FRAC start and endpoints */
+
+x0 = sp_globals.x0_spxl; /* get start of line (== current point) */
+y0 = sp_globals.y0_spxl;
+sp_globals.x0_spxl = x1 = P1.x; /* end of line */
+sp_globals.y0_spxl = y1 = P1.y; /* (also update current point to end of line) */
+
+yc = sp_globals.y_pxl; /* current scan line = end of last line */
+sp_globals.y_pxl = (y1 + sp_globals.pixrnd) >> sp_globals.pixshift; /* calculate new end-scan sp_globals.line */
+
+
+#if DEBUG
+printf("LINE_BLACK(%3.4f, %3.4f)\n",
+ (real)P1.x/(real)sp_globals.onepix,
+ (real)P1.y/(real)sp_globals.onepix);
+#endif
+
+if (sp_globals.extents_running)
+ {
+ if (sp_globals.x0_spxl > sp_globals.bmap_xmax)
+ sp_globals.bmap_xmax = sp_globals.x0_spxl;
+ if (sp_globals.x0_spxl < sp_globals.bmap_xmin)
+ sp_globals.bmap_xmin = sp_globals.x0_spxl;
+ if (sp_globals.y0_spxl > sp_globals.bmap_ymax)
+ sp_globals.bmap_ymax = sp_globals.y0_spxl;
+ if (sp_globals.y0_spxl < sp_globals.bmap_ymin)
+ sp_globals.bmap_ymin = sp_globals.y0_spxl;
+ }
+
+if (sp_globals.intercept_oflo) return;
+
+if ((how_many_y = sp_globals.y_pxl - yc) == 0) return; /* Don't draw a null line */
+
+if (how_many_y < 0) yc--; /* Predecrment downward lines */
+
+if (yc > sp_globals.y_band.band_max) /* Is start point above band? */
+ {
+ if (sp_globals.y_pxl > sp_globals.y_band.band_max) return; /* line has to go down! */
+ how_many_y = sp_globals.y_pxl - (yc = sp_globals.y_band.band_max) - 1; /* Yes, limit it */
+ }
+
+if (yc < sp_globals.y_band.band_min) /* Is start point below band? */
+ {
+ if (sp_globals.y_pxl < sp_globals.y_band.band_min) return; /* line has to go up! */
+ how_many_y = sp_globals.y_pxl - (yc = sp_globals.y_band.band_min); /* Yes, limit it */
+ }
+
+xc = (fix31)(x0 + sp_globals.pixrnd) << (16 - sp_globals.pixshift); /* Original x coordinate with built in */
+ /* rounding. 16.16 form */
+
+
+if ( (temp1 = (x1 - x0)) == 0) /* check for vertical line */
+ {
+ yc -= sp_globals.y_band.band_min; /* yc is now an offset relative to the band */
+ temp1 = (fix15)(xc >> 16);
+ if (how_many_y < 0)
+ { /* Vector down */
+ if ((how_many_y += yc + 1) < 0) how_many_y = 0; /* can't go below 0 */
+ for (i = yc; i >= how_many_y; i--)
+ sp_add_intercept_black(i,temp1);
+ }
+ else
+ { /* Vector up */
+ /* check to see that line doesn't extend beyond top of band */
+ if ((how_many_y += yc) > sp_globals.no_y_lists) how_many_y = sp_globals.no_y_lists;
+ for (i = yc; i != how_many_y; i++)
+ sp_add_intercept_black(i,temp1);
+ }
+ return;
+ }
+
+/* calculate dx_dy at 16.16 fixed point */
+
+dx_dy = ( (fix31)temp1 << 16 )/(fix31)(y1 - y0);
+
+/* We have to check for a @#$%@# possible multiply overflow */
+/* by doing another @#$*& multiply. In assembly language, */
+/* the program could just check the OVerflow flag or whatever*/
+/* works on the particular processor. This C code is meant */
+/* to be processor independant. */
+
+temp1 = (yc << sp_globals.pixshift) - y0 + sp_globals.pixrnd;
+/* This sees if the sign bits start at bit 15 */
+/* if they do, no overflow has occurred */
+
+temp2 = (fix15)(MULT16(temp1,(fix15)(dx_dy >> 16)) >> 15);
+
+if ( (temp2 != (fix15)0xFFFF) &&
+ (temp2 != 0x0000) &&
+ /* Overflow. Pick point closest to yc + .5 */
+ (ABS(temp1) < ABS((yc << sp_globals.pixshift) - y1 + sp_globals.pixrnd)) )
+ { /* use x1 instead of x0 */
+ xc = (fix31)(x1 + sp_globals.pixrnd) << (16 - sp_globals.pixshift);
+ }
+else
+ {
+/* calculate new xc at the center of the *current* scan line */
+/* due to banding, yc may be several lines away from y0 */
+/* xc += (yc + .5 - y0) * dx_dy */
+/* This multiply generates a subpixel delta. */
+/* So we shift it to be a 16.16 delta */
+
+ xc += ((fix31)temp1 * dx_dy) >> sp_globals.pixshift;
+ }
+
+yc -= sp_globals.y_band.band_min; /* yc is now an offset relative to the band */
+
+if (how_many_y < 0)
+ { /* Vector down */
+ if (how_many_y == -1)
+ sp_add_intercept_black(yc, (fix15) (xc >> 16));
+ else
+ {
+ if ((how_many_y += yc + 1) < 0) how_many_y = 0; /* can't go below 0 */
+ for (i = yc; i >= how_many_y; i--)
+ {
+ temp1 = (fix15)(xc >> 16);
+ sp_add_intercept_black(i,temp1);
+ xc -= dx_dy;
+ }
+ }
+ }
+ else
+ { /* Vector up */
+ /* check to see that line doesn't extend beyond top of band */
+ if (how_many_y == 1)
+ sp_add_intercept_black(yc, (fix15) (xc >> 16));
+ else
+ {
+ if ((how_many_y += yc) > sp_globals.no_y_lists) how_many_y = sp_globals.no_y_lists;
+ for (i = yc; i != how_many_y; i++)
+ {
+ temp1 = (fix15)(xc >> 16);
+ sp_add_intercept_black(i,temp1);
+ xc += dx_dy;
+ }
+ }
+ }
+}
+#endif
+#if INCL_BLACK
+FUNCTION boolean end_char_black()
+GDECL
+/* Called when all character data has been output
+ * Return TRUE if output process is complete
+ * Return FALSE to repeat output of the transformed data beginning
+ * with the first contour
+ */
+{
+
+fix31 xorg;
+fix31 yorg;
+#if INCL_CLIPPING
+fix31 bmap_max, bmap_min;
+#endif
+
+#if DEBUG
+printf("END_CHAR_BLACK()\n");
+#endif
+
+if (sp_globals.first_pass)
+ {
+ if (sp_globals.bmap_xmax >= sp_globals.bmap_xmin)
+ {
+ sp_globals.xmin = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ sp_globals.xmax = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ }
+ else
+ {
+ sp_globals.xmin = sp_globals.xmax = 0;
+ }
+ if (sp_globals.bmap_ymax >= sp_globals.bmap_ymin)
+ {
+
+#if INCL_CLIPPING
+ switch(sp_globals.tcb0.xtype)
+ {
+ case 1: /* 180 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ sp_globals.clip_ymin = -1 * sp_globals.clip_ymin;
+ if (bmap_min < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ else
+ sp_globals.ymin = bmap_min;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max < sp_globals.clip_ymax)
+ sp_globals.ymax = bmap_max;
+ else
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ sp_globals.clip_xmax = -sp_globals.xmin;
+ sp_globals.clip_xmin = ((sp_globals.set_width.x+32768L) >> 16) -
+ sp_globals.xmin;
+ break;
+ case 2: /* 90 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_xmin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift;
+ sp_globals.clip_xmin = -1 * sp_globals.clip_xmin;
+ bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ if (bmap_min > sp_globals.clip_xmin)
+ sp_globals.clip_xmin = bmap_min;
+
+ /* normalize to x origin */
+ sp_globals.clip_xmin -= sp_globals.xmin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_xmax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max < sp_globals.clip_xmax)
+ sp_globals.xmax = bmap_max;
+ else
+ sp_globals.xmax = sp_globals.clip_xmax;
+ sp_globals.clip_ymax = 0;
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ /* normalize to x origin */
+ sp_globals.clip_xmax -= sp_globals.xmin;
+ }
+ break;
+ case 3: /* 270 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_xmin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift;
+ sp_globals.clip_xmin = -1 * sp_globals.clip_xmin;
+ bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+
+ /* let the minimum be the larger of these two values */
+ if (bmap_min > sp_globals.clip_xmin)
+ sp_globals.clip_xmin = bmap_min;
+
+ /* normalize the x value to new xorgin */
+ sp_globals.clip_xmin -= sp_globals.xmin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_xmax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+ /* let the max be the lesser of these two values */
+ if (bmap_max < sp_globals.clip_xmax)
+ {
+ sp_globals.xmax = bmap_max;
+ sp_globals.clip_xmax = bmap_max;
+ }
+ else
+ sp_globals.xmax = sp_globals.clip_xmax;
+
+ /* normalize the x value to new x origin */
+ sp_globals.clip_xmax -= sp_globals.xmin;
+ }
+ /* compute y clip values */
+ sp_globals.clip_ymax = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = 0;
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ break;
+ default: /* this is for zero degree rotation and arbitrary rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max > sp_globals.clip_ymax)
+ sp_globals.ymax = bmap_max;
+ else
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ sp_globals.clip_ymin = - sp_globals.clip_ymin;
+ bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ if (bmap_min < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ else
+ sp_globals.ymin = bmap_min;
+ }
+ sp_globals.clip_xmin = -sp_globals.xmin;
+ sp_globals.clip_xmax = ((sp_globals.set_width.x+32768L) >> 16) -
+ sp_globals.xmin;
+ break;
+ }
+if ( !(sp_globals.specs.flags & CLIP_TOP))
+#endif
+ sp_globals.ymax = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+#if INCL_CLIPPING
+if ( !(sp_globals.specs.flags & CLIP_BOTTOM))
+#endif
+
+ sp_globals.ymin = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ }
+ else
+ {
+ sp_globals.ymin = sp_globals.ymax = 0;
+ }
+
+ /* add in the rounded out part (from xform.) of the left edge */
+ if (sp_globals.tcb.xmode == 0) /* for X pix is function of X orus only add the round */
+ xorg = (((fix31)sp_globals.xmin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift));
+ else
+ if (sp_globals.tcb.xmode == 1) /* for X pix is function of -X orus only, subtr. round */
+ xorg = (((fix31)sp_globals.xmin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift)) ;
+ else
+ xorg = (fix31)sp_globals.xmin << 16; /* for other cases don't use round on x */
+
+ if (sp_globals.tcb.ymode == 2) /* for Y pix is function of X orus only, add round error */
+ yorg = (((fix31)sp_globals.ymin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift));
+ else
+ if (sp_globals.tcb.ymode == 3) /* for Y pix is function of -X orus only, sub round */
+ yorg = (((fix31)sp_globals.ymin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift));
+ else /* all other cases have no round error on yorg */
+ yorg = (fix31)sp_globals.ymin << 16;
+
+ open_bitmap(sp_globals.set_width.x, sp_globals.set_width.y, xorg, yorg,
+ sp_globals.xmax - sp_globals.xmin, sp_globals.ymax - sp_globals.ymin);
+ if (sp_globals.intercept_oflo)
+ {
+ sp_globals.y_band.band_min = sp_globals.ymin;
+ sp_globals.y_band.band_max = sp_globals.ymax;
+ init_intercepts_out();
+ sp_globals.first_pass = FALSE;
+ sp_globals.extents_running = FALSE;
+ return FALSE;
+ }
+ else
+ {
+ sp_proc_intercepts_black();
+ close_bitmap();
+ return TRUE;
+ }
+ }
+else
+ {
+ if (sp_globals.intercept_oflo)
+ {
+ reduce_band_size_out();
+ init_intercepts_out();
+ return FALSE;
+ }
+ else
+ {
+ sp_proc_intercepts_black();
+ if (next_band_out())
+ {
+ init_intercepts_out();
+ return FALSE;
+ }
+ close_bitmap();
+ return TRUE;
+ }
+ }
+}
+#endif
+
+#if INCL_BLACK
+FUNCTION LOCAL void sp_add_intercept_black(
+GDECL
+fix15 y, /* Y coordinate in relative pixel units */
+ /* (0 is lowest sample in band) */
+fix15 x) /* X coordinate of intercept in subpixel units */
+
+/* Called by line() to add an intercept to the intercept list structure
+ */
+
+{
+register fix15 from; /* Insertion pointers for the linked list sort */
+register fix15 to;
+
+#if DEBUG
+printf(" Add intercept(%2d, %d)\n", y + sp_globals.y_band.band_min,x);
+
+/* Bounds checking IS done in debug mode */
+if (y < 0) /* Y value below bottom of current band? */
+ {
+ printf(" Intecerpt less than 0!!!\007\n");
+ return;
+ }
+
+if (y > (sp_globals.no_y_lists - 1)) /* Y value above top of current band? */
+ {
+ printf(" Intercept too big for band!!!!!\007\n");
+ return;
+ }
+#endif
+
+/* Store new values */
+
+sp_intercepts.car[sp_globals.next_offset] = x;
+
+/* Find slot to insert new element (between from and to) */
+
+from = y; /* Start at list head */
+
+while( (to = sp_intercepts.cdr[from]) >= sp_globals.first_offset) /* Until to == end of list */
+ {
+ if (x <= sp_intercepts.car[to]) /* If next item is larger than or same as this one... */
+ goto insert_element; /* ... drop out and insert here */
+ from = to; /* move forward in list */
+ }
+
+insert_element: /* insert element "sp_globals.next_offset" between elements "from" */
+ /* and "to" */
+
+sp_intercepts.cdr[from] = sp_globals.next_offset;
+sp_intercepts.cdr[sp_globals.next_offset] = to;
+
+if (++sp_globals.next_offset >= MAX_INTERCEPTS) /* Intercept buffer full? */
+ {
+ sp_globals.intercept_oflo = TRUE;
+/* There may be a few more calls to "add_intercept" from the current line */
+/* To avoid problems, we set next_offset to a safe value. We don't care */
+/* if the intercept table gets trashed at this point */
+ sp_globals.next_offset = sp_globals.first_offset;
+ }
+}
+
+#endif
+
+#if INCL_BLACK
+FUNCTION LOCAL void sp_proc_intercepts_black()
+GDECL
+
+/* Called by sp_make_char to output accumulated intercept lists
+ * Clips output to sp_globals.xmin, sp_globals.xmax, sp_globals.ymin, sp_globals.ymax boundaries
+ */
+{
+register fix15 i;
+register fix15 from, to; /* Start and end of run in pixel units
+ relative to left extent of character */
+register fix15 y;
+register fix15 scan_line;
+ fix15 first_y, last_y;
+
+#if DEBUG
+printf("\nIntercept lists:\n");
+#endif
+
+#if INCL_CLIPPING
+if ((sp_globals.specs.flags & CLIP_LEFT) != 0)
+ clipleft = TRUE;
+else
+ clipleft = FALSE;
+if ((sp_globals.specs.flags & CLIP_RIGHT) != 0)
+ clipright = TRUE;
+else
+ clipright = FALSE;
+if (clipleft || clipright)
+ {
+ xmax = sp_globals.clip_xmax;
+ xmin = sp_globals.clip_xmin;
+ }
+if (!clipright)
+ xmax = ((sp_globals.set_width.x+32768L) >> 16);
+#endif
+
+if ((first_y = sp_globals.y_band.band_max) >= sp_globals.ymax)
+ first_y = sp_globals.ymax - 1; /* Clip to sp_globals.ymax boundary */
+
+if ((last_y = sp_globals.y_band.band_min) < sp_globals.ymin)
+ last_y = sp_globals.ymin; /* Clip to sp_globals.ymin boundary */
+
+last_y -= sp_globals.y_band.band_min;
+#if DEBUG
+/* Print out all of the intercept info */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = y; /* Index head of intercept list */
+ while ((i = sp_intercepts.cdr[i]) != 0) /* Link to next intercept if present */
+ {
+ if ((from = sp_intercepts.car[i] - sp_globals.xmin) < 0)
+ from = 0; /* Clip to sp_globals.xmin boundary */
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ if (i == 0) /* End of list? */
+ {
+ printf("****** proc_intercepts: odd number of intercepts\n");
+ break;
+ }
+ if ((to = sp_intercepts.car[i]) > sp_globals.xmax)
+ to = sp_globals.xmax - sp_globals.xmin; /* Clip to sp_globals.xmax boundary */
+ else
+ to -= sp_globals.xmin;
+ printf(" Y = %2d (scanline %2d): %d %d:\n",
+ y + sp_globals.y_band.band_min, scan_line, from, to);
+ }
+ }
+#endif
+
+/* Draw the image */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = y; /* Index head of intercept list */
+ while ((i = sp_intercepts.cdr[i]) != 0) /* Link to next intercept if present */
+ {
+ if ((from = sp_intercepts.car[i] - sp_globals.xmin) < 0)
+ from = 0; /* Clip to sp_globals.xmin boundary */
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+
+ if ((to = sp_intercepts.car[i]) > sp_globals.xmax)
+ to = sp_globals.xmax - sp_globals.xmin; /* Clip to sp_globals.xmax boundary */
+ else
+ to -= sp_globals.xmin;
+ if (from >= to)
+ {
+ if (from >= sp_globals.xmax - sp_globals.xmin)
+ {
+ --from ;
+ }
+ to = from+1;
+ }
+#if INCL_CLIPPING
+ if (clipleft)
+ {
+ if (to <= xmin)
+ continue;
+ if (from < xmin)
+ from = xmin;
+ }
+ if (clipright)
+ {
+ if (from >= xmax)
+ continue;
+ if (to > xmax)
+ to = xmax;
+ }
+#endif
+ set_bitmap_bits(scan_line, from, to);
+ }
+ }
+}
+
+#endif
+
+
+
+
diff --git a/nx-X11/lib/font/Speedo/out_outl.c b/nx-X11/lib/font/Speedo/out_outl.c
new file mode 100644
index 000000000..013901092
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/out_outl.c
@@ -0,0 +1,290 @@
+/* $Xorg: out_outl.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+
+/**************************** O U T _ 2 _ 1 . C ******************************
+ * *
+ * This is the standard output module for vector output mode. *
+ * *
+ ****************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "spdo_prv.h" /* General definitions for Speedo */
+
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+/* the following macro is used to limit points on the outline to the bounding box */
+
+#define RANGECHECK(value,min,max) (((value) >= (min) ? (value) : (min)) < (max) ? (value) : (max))
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** STATIC FUNCTIONS *****/
+
+
+#if INCL_OUTLINE
+FUNCTION boolean init_outline(specsarg)
+GDECL
+specs_t GLOBALFAR *specsarg;
+/*
+ * init_out2() is called by sp_set_specs() to initialize the output module.
+ * Returns TRUE if output module can accept requested specifications.
+ * Returns FALSE otherwise.
+ */
+{
+#if DEBUG
+printf("INIT_OUT_2()\n");
+#endif
+if (specsarg->flags & (CLIP_LEFT + CLIP_RIGHT + CLIP_TOP + CLIP_BOTTOM))
+ return FALSE; /* Clipping not supported */
+return (TRUE);
+}
+#endif
+
+#if INCL_OUTLINE
+FUNCTION boolean begin_char_outline(Psw, Pmin, Pmax)
+GDECL
+point_t Psw; /* End of escapement vector (sub-pixels) */
+point_t Pmin; /* Bottom left corner of bounding box */
+point_t Pmax; /* Top right corner of bounding box */
+/*
+ * If two or more output modules are included in the configuration, begin_char2()
+ * is called by begin_char() to signal the start of character output data.
+ * If only one output module is included in the configuration, begin_char() is
+ * called by make_simp_char() and make_comp_char().
+ */
+{
+fix31 set_width_x;
+fix31 set_width_y;
+fix31 xmin;
+fix31 xmax;
+fix31 ymin;
+fix31 ymax;
+
+#if DEBUG
+printf("BEGIN_CHAR_2(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
+ (real)Psw.x / (real)onepix, (real)Psw.y / (real)onepix,
+ (real)Pmin.x / (real)onepix, (real)Pmin.y / (real)onepix,
+ (real)Pmax.x / (real)onepix, (real)Pmax.y / (real)onepix);
+#endif
+sp_globals.poshift = 16 - sp_globals.pixshift;
+set_width_x = (fix31)Psw.x << sp_globals.poshift;
+set_width_y = (fix31)Psw.y << sp_globals.poshift;
+xmin = (fix31)Pmin.x << sp_globals.poshift;
+xmax = (fix31)Pmax.x << sp_globals.poshift;
+ymin = (fix31)Pmin.y << sp_globals.poshift;
+ymax = (fix31)Pmax.y << sp_globals.poshift;
+sp_globals.xmin = Pmin.x;
+sp_globals.xmax = Pmax.x;
+sp_globals.ymin = Pmin.y;
+sp_globals.ymax = Pmax.y;
+open_outline(set_width_x, set_width_y, xmin, xmax, ymin, ymax);
+return TRUE;
+}
+#endif
+
+#if INCL_OUTLINE
+FUNCTION void begin_sub_char_outline(Psw, Pmin, Pmax)
+GDECL
+point_t Psw; /* End of sub-char escapement vector */
+point_t Pmin; /* Bottom left corner of sub-char bounding box */
+point_t Pmax; /* Top right corner of sub-char bounding box */
+/*
+ * If two or more output modules are included in the configuration, begin_sub_char2()
+ * is called by begin_sub_char() to signal the start of sub-character output data.
+ * If only one output module is included in the configuration, begin_sub_char() is
+ * called by make_comp_char().
+ */
+{
+#if DEBUG
+printf("BEGIN_SUB_CHAR_2(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
+ (real)Psw.x / (real)onepix, (real)Psw.y / (real)onepix,
+ (real)Pmin.x / (real)onepix, (real)Pmin.y / (real)onepix,
+ (real)Pmax.x / (real)onepix, (real)Pmax.y / (real)onepix);
+#endif
+start_new_char();
+}
+#endif
+
+
+#if INCL_OUTLINE
+FUNCTION void begin_contour_outline(P1, outside)
+GDECL
+point_t P1; /* Start point of contour */
+boolean outside; /* TRUE if outside (counter-clockwise) contour */
+/*
+ * If two or more output modules are included in the configuration, begin_contour2()
+ * is called by begin_contour() to define the start point of a new contour
+ * and to indicate whether it is an outside (counter-clockwise) contour
+ * or an inside (clockwise) contour.
+ * If only one output module is included in the configuration, begin_sub_char() is
+ * called by proc_outl_data().
+ */
+{
+fix15 x,y;
+#if DEBUG
+printf("BEGIN_CONTOUR_2(%3.1f, %3.1f, %s)\n",
+ (real)P1.x / (real)onepix, (real)P1.y / (real)onepix, outside? "outside": "inside");
+#endif
+x = RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
+y = RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);
+
+start_contour((fix31)x << sp_globals.poshift, (fix31)y << sp_globals.poshift, outside);
+}
+#endif
+
+#if INCL_OUTLINE
+FUNCTION void curve_outline(P1, P2, P3,depth)
+GDECL
+point_t P1; /* First control point of Bezier curve */
+point_t P2; /* Second control point of Bezier curve */
+point_t P3; /* End point of Bezier curve */
+fix15 depth;
+/*
+ * If two or more output modules are included in the configuration, curve2()
+ * is called by curve() to output one curve segment.
+ * If only one output module is included in the configuration, curve() is
+ * called by proc_outl_data().
+ * This function is only called when curve output is enabled.
+ */
+{
+fix15 x1,y1,x2,y2,x3,y3;
+#if DEBUG
+printf("CURVE_2(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n",
+ (real)P1.x / (real)onepix, (real)P1.y / (real)onepix,
+ (real)P2.x / (real)onepix, (real)P2.y / (real)onepix,
+ (real)P3.x / (real)onepix, (real)P3.y / (real)onepix);
+#endif
+x1= RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
+y1= RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);
+
+x2= RANGECHECK(P2.x,sp_globals.xmin,sp_globals.xmax);
+y2= RANGECHECK(P2.y,sp_globals.ymin,sp_globals.ymax);
+
+x3= RANGECHECK(P3.x,sp_globals.xmin,sp_globals.xmax);
+y3= RANGECHECK(P3.y,sp_globals.ymin,sp_globals.ymax);
+
+curve_to((fix31)x1 << sp_globals.poshift, (fix31)y1 << sp_globals.poshift,
+ (fix31)x2<< sp_globals.poshift, (fix31)y2 << sp_globals.poshift,
+ (fix31)x3 << sp_globals.poshift, (fix31)y3 << sp_globals.poshift);
+}
+#endif
+
+#if INCL_OUTLINE
+FUNCTION void line_outline(P1)
+GDECL
+point_t P1; /* End point of vector */
+/*
+ * If two or more output modules are included in the configuration, line2()
+ * is called by line() to output one vector.
+ * If only one output module is included in the configuration, line() is
+ * called by proc_outl_data(). If curve output is enabled, line() is also
+ * called by split_curve().
+ */
+{
+fix15 x1,y1;
+#if DEBUG
+printf("LINE_2(%3.1f, %3.1f)\n", (real)P1.x / (real)onepix, (real)P1.y / (real)onepix);
+#endif
+x1= RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
+y1= RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);
+
+line_to((fix31)x1 << sp_globals.poshift, (fix31)y1 << sp_globals.poshift);
+}
+#endif
+
+#if INCL_OUTLINE
+FUNCTION void end_contour_outline()
+GDECL
+/*
+ * If two or more output modules are included in the configuration, end_contour2()
+ * is called by end_contour() to signal the end of a contour.
+ * If only one output module is included in the configuration, end_contour() is
+ * called by proc_outl_data().
+ */
+{
+#if DEBUG
+printf("END_CONTOUR_2()\n");
+#endif
+close_contour();
+}
+#endif
+
+
+#if INCL_OUTLINE
+FUNCTION void end_sub_char_outline()
+GDECL
+/*
+ * If two or more output modules are included in the configuration, end_sub_char2()
+ * is called by end_sub_char() to signal the end of sub-character data.
+ * If only one output module is included in the configuration, end_sub_char() is
+ * called by make_comp_char().
+ */
+{
+#if DEBUG
+printf("END_SUB_CHAR_2()\n");
+#endif
+}
+#endif
+
+
+#if INCL_OUTLINE
+FUNCTION boolean end_char_outline()
+GDECL
+/*
+ * If two or more output modules are included in the configuration, end_char2()
+ * is called by end_char() to signal the end of the character data.
+ * If only one output module is included in the configuration, end_char() is
+ * called by make_simp_char() and make_comp_char().
+ * Returns TRUE if output process is complete
+ * Returns FALSE to repeat output of the transformed data beginning
+ * with the first contour (of the first sub-char if compound).
+ */
+{
+#if DEBUG
+printf("END_CHAR_2()\n");
+#endif
+close_outline();
+return TRUE;
+}
+#endif
+
diff --git a/nx-X11/lib/font/Speedo/out_scrn.c b/nx-X11/lib/font/Speedo/out_scrn.c
new file mode 100644
index 000000000..0ea3b1976
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/out_scrn.c
@@ -0,0 +1,1090 @@
+/* $Xorg: out_scrn.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/out_scrn.c,v 1.4 1999/12/27 00:39:25 robin Exp $ */
+
+
+/*************************** O U T _ S C R N . C *****************************
+ * *
+ * This is an output module for screen-writer mode. *
+ * *
+ *****************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "spdo_prv.h" /* General definitions for Speedo */
+
+#define DEBUG 0
+#define LOCAL static
+#define ABS(X) ( (X < 0) ? -X : X)
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** STATIC FUNCTIONS *****/
+
+static void sp_add_intercept_screen(PROTO_DECL2 fix15 y,fix31 x);
+static void sp_proc_intercepts_screen(PROTO_DECL1);
+
+
+#if INCL_SCREEN
+FUNCTION boolean init_screen(
+GDECL
+specs_t FONTFAR *specsarg)
+/*
+ * init_out0() is called by sp_set_specs() to initialize the output module.
+ * Returns TRUE if output module can accept requested specifications.
+ * Returns FALSE otherwise.
+ */
+{
+#if DEBUG
+printf("INIT_SCREEN()\n");
+#endif
+return (TRUE);
+}
+#endif
+
+
+#if INCL_SCREEN
+FUNCTION boolean begin_char_screen(
+GDECL
+point_t Psw,
+point_t Pmin,
+point_t Pmax)
+/* Called once at the start of the character generation process
+ */
+{
+#if DEBUG
+printf("BEGIN_CHAR_SCREEN(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
+ (real)Psw.x / (real)sp_globals.onepix, (real)Psw.y / (real)sp_globals.onepix,
+ (real)Pmin.x / (real)sp_globals.onepix, (real)Pmin.y / (real)sp_globals.onepix,
+ (real)Pmax.x / (real)sp_globals.onepix, (real)Pmax.y / (real)sp_globals.onepix);
+#endif
+if (sp_globals.pixshift > 8)
+ sp_intercepts.fracpix = sp_globals.onepix << (8 - sp_globals.pixshift);
+else
+ sp_intercepts.fracpix = sp_globals.onepix >> (sp_globals.pixshift - 8);
+
+init_char_out(Psw,Pmin,Pmax);
+
+return TRUE;
+}
+#endif
+
+
+#if INCL_SCREEN
+FUNCTION void begin_contour_screen(
+GDECL
+point_t P1,
+boolean outside)
+/* Called at the start of each contour
+ */
+{
+
+#if DEBUG
+printf("BEGIN_CONTOUR_SCREEN(%3.1f, %3.1f, %s)\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix, outside? "outside": "inside");
+#endif
+sp_globals.x0_spxl = P1.x;
+sp_globals.y0_spxl = P1.y;
+sp_globals.y_pxl = (sp_globals.y0_spxl + sp_globals.pixrnd) >> sp_globals.pixshift;
+}
+#endif
+
+#if INCL_SCREEN
+FUNCTION void curve_screen(
+GDECL
+point_t P1, point_t P2, point_t P3,
+fix15 depth)
+{
+fix31 X0;
+fix31 Y0;
+fix31 X1;
+fix31 Y1;
+fix31 X2;
+fix31 Y2;
+fix31 X3;
+fix31 Y3;
+#if DEBUG
+printf("CURVE_SCREEN(%6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f)\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix,
+ (real)P2.x / (real)sp_globals.onepix, (real)P2.y / (real)sp_globals.onepix,
+ (real)P3.x / (real)sp_globals.onepix, (real)P3.y / (real)sp_globals.onepix);
+#endif
+
+
+if (sp_globals.extents_running) /* Accumulate actual character extents if required */
+ {
+ if (P3.x > sp_globals.bmap_xmax)
+ sp_globals.bmap_xmax = P3.x;
+ if (P3.x < sp_globals.bmap_xmin)
+ sp_globals.bmap_xmin = P3.x;
+ if (P3.y > sp_globals.bmap_ymax)
+ sp_globals.bmap_ymax = P3.y;
+ if (P3.y < sp_globals.bmap_ymin)
+ sp_globals.bmap_ymin = P3.y;
+ }
+
+X0 = ((fix31)sp_globals.x0_spxl << sp_globals.poshift) + (fix31)32768;
+Y0 = ((fix31)sp_globals.y0_spxl << sp_globals.poshift) + (fix31)32768;
+X1 = ((fix31)P1.x << sp_globals.poshift) + (fix31)32768;
+Y1 = ((fix31)P1.y << sp_globals.poshift) + (fix31)32768;
+X2 = ((fix31)P2.x << sp_globals.poshift) + (fix31)32768;
+Y2 = ((fix31)P2.y << sp_globals.poshift) + (fix31)32768;
+X3 = ((fix31)P3.x << sp_globals.poshift) + (fix31)32768;
+Y3 = ((fix31)P3.y << sp_globals.poshift) + (fix31)32768;
+
+if (((Y0 - Y3) * sp_globals.tcb.mirror) > 0)
+ {
+ sp_intercepts.leftedge = LEFT_INT;
+ }
+else
+ {
+ sp_intercepts.leftedge = 0;
+ }
+
+scan_curve_screen(X0,Y0,X1,Y1,X2,Y2,X3,Y3);
+sp_globals.x0_spxl = P3.x;
+sp_globals.y0_spxl = P3.y;
+sp_globals.y_pxl = (P3.y + sp_globals.pixrnd) >> sp_globals.pixshift; /* calculate new end-scan sp_globals.line */
+}
+
+FUNCTION void scan_curve_screen(
+GDECL
+fix31 X0, fix31 Y0, fix31 X1, fix31 Y1, fix31 X2, fix31 Y2, fix31 X3, fix31 Y3)
+/* Called for each curve in the transformed character if curves out enabled
+ */
+{
+fix31 Pmidx;
+fix31 Pmidy;
+fix31 Pctrl1x;
+fix31 Pctrl1y;
+fix31 Pctrl2x;
+fix31 Pctrl2y;
+
+#ifdef DBGCRV
+printf("SCAN_CURVE_SCREEN(%6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f)\n",
+ (real)(X0-32768) / 65536.0, (real)(Y0-32768) / 65536.0,
+ (real)(X1-32768) / 65536.0, (real)(Y1-32768) / 65536.0,
+ (real)(X2-32768) / 65536.0, (real)(Y2-32768) / 65536.0,
+ (real)(X3-32768) / 65536.0, (real)(Y3-32768) / 65536.0);
+#endif
+
+if (((Y3 >> 16)) == (Y0 >> 16) || (Y3+1) == Y0 || Y3 == (Y0+1))
+ {
+ return;
+ }
+if ((X3 >> 16) == (X0 >> 16))
+ {
+ vert_line_screen(X3,(fix15)(Y0>>16),(fix15)(Y3>>16));
+ return;
+ }
+Pmidx = (X0 + (X1 + X2) * 3 + X3 + 4 ) >> 3;
+Pmidy = (Y0 + (Y1 + Y2) * 3 + Y3 + 4 ) >> 3;
+
+Pctrl1x = (X0 + X1 + 1 ) >> 1;
+Pctrl1y = (Y0 + Y1 + 1) >> 1;
+Pctrl2x = (X0 + (X1 << 1) + X2 + 2 ) >> 2;
+Pctrl2y = (Y0 + (Y1 << 1) + Y2 + 2 ) >> 2;
+scan_curve_screen(X0,Y0, Pctrl1x, Pctrl1y, Pctrl2x,Pctrl2y, Pmidx,Pmidy);
+
+Pctrl1x = (X1 + (X2 << 1) + X3 + 2 ) >> 2;
+Pctrl1y = (Y1 + (Y2 << 1) + Y3 + 2 ) >> 2;
+Pctrl2x = (X2 + X3 + 1 ) >> 1;
+Pctrl2y = (Y2 + Y3 + 1 ) >> 1;
+scan_curve_screen(Pmidx,Pmidy, Pctrl1x,Pctrl1y, Pctrl2x,Pctrl2y, X3,Y3);
+}
+
+FUNCTION void vert_line_screen(
+GDECL
+fix31 x,
+fix15 y1, fix15 y2)
+{
+
+#ifdef DBGCRV
+printf("VERT_LINE_SCREEN(%6.4f, %6.4f, %6.4f)\n",
+ (real)(x - 32768) / 65536.0,
+ (real)(y1 - 32768) / 65536.0,
+ (real)(y2 - 32768) / 65536.0);
+#endif
+
+if (sp_globals.intercept_oflo)
+ return;
+
+if (y1 > y2) /* Line goes downwards ? */
+ {
+ if (y1 > (sp_globals.y_band.band_max + 1)) /* Start point above top of band? */
+ y1 = sp_globals.y_band.band_max + 1; /* Adjust start point to top of band */
+ if (y2 < sp_globals.y_band.band_min) /* End point below bottom of band? */
+ y2 = sp_globals.y_band.band_min; /* Adjust end point bottom of band */
+
+ y1 -= sp_globals.y_band.band_min; /* Translate start point to band origin */
+ y2 -= sp_globals.y_band.band_min; /* Translate end point to band origin */
+
+ while (y2 < y1) /* At least one intercept left? */
+ {
+ sp_add_intercept_screen(--y1, x); /* Add intercept */
+ }
+ }
+else if (y2 > y1) /* Line goes upwards ? */
+ {
+ if (y1 < sp_globals.y_band.band_min) /* Start point below bottom of band? */
+ y1 = sp_globals.y_band.band_min; /* Adjust start point to bottom of band */
+ if (y2 > (sp_globals.y_band.band_max + 1)) /* End point above top of band? */
+ y2 = sp_globals.y_band.band_max + 1; /* Adjust end point to top of band */
+
+ y1 -= sp_globals.y_band.band_min; /* Translate start point to band origin */
+ y2 -= sp_globals.y_band.band_min; /* Translate end point to band origin */
+
+ while (y1 < y2) /* At least one intercept left? */
+ {
+ sp_add_intercept_screen(y1++, x); /* Add intercept */
+ }
+ }
+
+
+}
+
+#endif
+
+
+#if INCL_SCREEN
+FUNCTION void line_screen(
+GDECL
+point_t P1)
+/* Called for each vector in the transformed character
+ */
+{
+register fix15 how_many_y; /* # of intercepts at y = n + 1/2 */
+register fix15 yc; /* Current scan-line */
+ fix15 temp1; /* various uses */
+ fix15 temp2; /* various uses */
+register fix31 dx_dy; /* slope of line in 16.16 form */
+register fix31 xc; /* high-precision (16.16) x coordinate */
+ fix15 x0,y0,x1,y1; /* PIX.FRAC start and endpoints */
+
+x0 = sp_globals.x0_spxl; /* get start of line (== current point) */
+y0 = sp_globals.y0_spxl;
+sp_globals.x0_spxl = x1 = P1.x; /* end of line */
+sp_globals.y0_spxl = y1 = P1.y; /* (also update current point to end of line) */
+
+yc = sp_globals.y_pxl; /* current scan line = end of last line */
+sp_globals.y_pxl = (y1 + sp_globals.pixrnd) >> sp_globals.pixshift; /* calculate new end-scan sp_globals.line */
+
+
+#if DEBUG
+printf("LINE_SCREEN(%3.4f, %3.4f)\n",
+ (real)P1.x/(real)sp_globals.onepix,
+ (real)P1.y/(real)sp_globals.onepix);
+#endif
+
+if (sp_globals.extents_running)
+ {
+ if (sp_globals.x0_spxl > sp_globals.bmap_xmax)
+ sp_globals.bmap_xmax = sp_globals.x0_spxl;
+ if (sp_globals.x0_spxl < sp_globals.bmap_xmin)
+ sp_globals.bmap_xmin = sp_globals.x0_spxl;
+ if (sp_globals.y0_spxl > sp_globals.bmap_ymax)
+ sp_globals.bmap_ymax = sp_globals.y0_spxl;
+ if (sp_globals.y0_spxl < sp_globals.bmap_ymin)
+ sp_globals.bmap_ymin = sp_globals.y0_spxl;
+ }
+
+if (sp_globals.intercept_oflo) return;
+
+if ((how_many_y = sp_globals.y_pxl - yc) == 0) return; /* Don't draw a null line */
+
+xc = (fix31)(x0 + sp_globals.pixrnd) << (16 - sp_globals.pixshift); /* Original x coordinate with built in */
+ /* rounding. 16.16 form */
+
+if (how_many_y < 0)
+ {
+ yc--; /* Predecrment downward lines */
+ }
+
+if ((how_many_y * sp_globals.tcb.mirror) < 0)
+ {
+ sp_intercepts.leftedge = LEFT_INT;
+ }
+else
+ {
+ sp_intercepts.leftedge = 0;
+ }
+
+if (yc > sp_globals.y_band.band_max) /* Is start point above band? */
+ {
+ if (sp_globals.y_pxl > sp_globals.y_band.band_max) return; /* line has to go down! */
+ how_many_y = sp_globals.y_pxl - (yc = sp_globals.y_band.band_max) - 1; /* Yes, limit it */
+ }
+
+if (yc < sp_globals.y_band.band_min) /* Is start point below band? */
+ {
+ if (sp_globals.y_pxl < sp_globals.y_band.band_min) return; /* line has to go up! */
+ how_many_y = sp_globals.y_pxl - (yc = sp_globals.y_band.band_min); /* Yes, limit it */
+ }
+
+if ( (temp1 = (x1 - x0)) == 0) /* check for vertical line */
+ {
+ dx_dy = 0L; /* Zero slope, leave xc alone */
+ goto skip_calc;
+ }
+
+/* calculate dx_dy at 16.16 fixed point */
+
+dx_dy = ( (fix31)temp1 << 16 )/(fix31)(y1 - y0);
+
+/* We have to check for a @#$%@# possible multiply overflow */
+/* by doing another @#$*& multiply. In assembly language, */
+/* the program could just check the OVerflow flag or whatever*/
+/* works on the particular processor. This C code is meant */
+/* to be processor independant. */
+
+temp1 = (yc << sp_globals.pixshift) - y0 + sp_globals.pixrnd;
+/* This sees if the sign bits start at bit 15 */
+/* if they do, no overflow has occurred */
+
+temp2 = (fix15)(MULT16(temp1,(fix15)(dx_dy >> 16)) >> 15);
+
+if ( (temp2 != (fix15)-1) &&
+ (temp2 != 0x0000) )
+ { /* Overflow. Pick point closest to yc + .5 */
+ if (ABS(temp1) < ABS((yc << sp_globals.pixshift) - y1 + sp_globals.pixrnd))
+ { /* use x1 instead of x0 */
+ xc = (fix31)(x1 + sp_globals.pixrnd) << (16 - sp_globals.pixshift);
+ }
+ goto skip_calc;
+ }
+/* calculate new xc at the center of the *current* scan line */
+/* due to banding, yc may be several lines away from y0 */
+/* xc += (yc + .5 - y0) * dx_dy */
+/* This multiply generates a subpixel delta. */
+/* So we shift it to be a 16.16 delta */
+
+xc += ((fix31)temp1 * dx_dy) >> sp_globals.pixshift;
+
+skip_calc:
+
+yc -= sp_globals.y_band.band_min; /* yc is now an offset relative to the band */
+
+if (how_many_y < 0)
+ { /* Vector down */
+ if ((how_many_y += yc + 1) < 0) how_many_y = 0; /* can't go below 0 */
+ while(yc >= how_many_y)
+ {
+ sp_add_intercept_screen(yc--,xc);
+ xc -= dx_dy;
+ }
+ }
+ else
+ { /* Vector up */
+ /* check to see that line doesn't extend beyond top of band */
+ if ((how_many_y += yc) > sp_globals.no_y_lists) how_many_y = sp_globals.no_y_lists;
+ while(yc != how_many_y)
+ {
+ sp_add_intercept_screen(yc++,xc);
+ xc += dx_dy;
+ }
+ }
+}
+#endif
+
+#if INCL_SCREEN
+FUNCTION void end_contour_screen()
+GDECL
+/* Called after the last vector in each contour
+ */
+{
+#if DEBUG
+printf("END_CONTOUR_SCREEN()\n");
+#endif
+sp_intercepts.inttype[sp_globals.next_offset-1] |= END_INT;
+}
+#endif
+
+
+
+#if INCL_SCREEN
+FUNCTION boolean end_char_screen()
+GDECL
+/* Called when all character data has been output
+ * Return TRUE if output process is complete
+ * Return FALSE to repeat output of the transformed data beginning
+ * with the first contour
+ */
+{
+
+fix31 xorg;
+fix31 yorg;
+
+#if INCL_CLIPPING
+fix31 em_max, em_min, bmap_max, bmap_min;
+#endif
+
+#if DEBUG
+printf("END_CHAR_SCREEN()\n");
+#endif
+
+if (sp_globals.first_pass)
+ {
+ if (sp_globals.bmap_xmax >= sp_globals.bmap_xmin)
+ {
+ sp_globals.xmin = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ sp_globals.xmax = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ }
+ else
+ {
+ sp_globals.xmin = sp_globals.xmax = 0;
+ }
+ if (sp_globals.bmap_ymax >= sp_globals.bmap_ymin)
+ {
+
+#if INCL_CLIPPING
+ switch(sp_globals.tcb0.xtype)
+ {
+ case 1: /* 180 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ sp_globals.clip_ymin = -1 * sp_globals.clip_ymin;
+ if (bmap_min < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ else
+ sp_globals.ymin = bmap_min;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max < sp_globals.clip_ymax)
+ sp_globals.ymax = bmap_max;
+ else
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ sp_globals.clip_xmax = -sp_globals.xmin;
+ sp_globals.clip_xmin = ((sp_globals.set_width.x+32768L) >> 16) -
+ sp_globals.xmin;
+ break;
+ case 2: /* 90 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_xmin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift;
+ sp_globals.clip_xmin = -1 * sp_globals.clip_xmin;
+ bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ if (bmap_min > sp_globals.clip_xmin)
+ sp_globals.clip_xmin = bmap_min;
+
+ /* normalize to x origin */
+ sp_globals.clip_xmin -= sp_globals.xmin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_xmax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max < sp_globals.clip_xmax)
+ sp_globals.xmax = bmap_max;
+ else
+ sp_globals.xmax = sp_globals.clip_xmax;
+ sp_globals.clip_ymax = 0;
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ /* normalize to x origin */
+ sp_globals.clip_xmax -= sp_globals.xmin;
+ }
+ break;
+ case 3: /* 270 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_xmin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift;
+ sp_globals.clip_xmin = -1 * sp_globals.clip_xmin;
+ bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+
+ /* let the minimum be the larger of these two values */
+ if (bmap_min > sp_globals.clip_xmin)
+ sp_globals.clip_xmin = bmap_min;
+
+ /* normalize the x value to new xorgin */
+ sp_globals.clip_xmin -= sp_globals.xmin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_xmax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+ /* let the max be the lesser of these two values */
+ if (bmap_max < sp_globals.clip_xmax)
+ {
+ sp_globals.xmax = bmap_max;
+ sp_globals.clip_xmax = bmap_max;
+ }
+ else
+ sp_globals.xmax = sp_globals.clip_xmax;
+
+ /* normalize the x value to new x origin */
+ sp_globals.clip_xmax -= sp_globals.xmin;
+ }
+ /* compute y clip values */
+ sp_globals.clip_ymax = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = 0;
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ break;
+ default: /* this is for zero degree rotation and arbitrary rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max > sp_globals.clip_ymax)
+ sp_globals.ymax = bmap_max;
+ else
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ sp_globals.clip_ymin = - sp_globals.clip_ymin;
+ bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ if (bmap_min < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ else
+ sp_globals.ymin = bmap_min;
+ }
+ sp_globals.clip_xmin = -sp_globals.xmin;
+ sp_globals.clip_xmax = ((sp_globals.set_width.x+32768L) >> 16) -
+ sp_globals.xmin;
+ break;
+ }
+if ( !(sp_globals.specs.flags & CLIP_TOP))
+#endif
+ sp_globals.ymax = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+#if INCL_CLIPPING
+if ( !(sp_globals.specs.flags & CLIP_BOTTOM))
+#endif
+
+ sp_globals.ymin = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ }
+ else
+ {
+ sp_globals.ymin = sp_globals.ymax = 0;
+ }
+
+ /* add in the rounded out part (from xform.) of the left edge */
+ if (sp_globals.tcb.xmode == 0) /* for X pix is function of X orus only add the round */
+ xorg = (((fix31)sp_globals.xmin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift));
+ else
+ if (sp_globals.tcb.xmode == 1) /* for X pix is function of -X orus only, subtr. round */
+ xorg = (((fix31)sp_globals.xmin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift)) ;
+ else
+ xorg = (fix31)sp_globals.xmin << 16; /* for other cases don't use round on x */
+
+ if (sp_globals.tcb.ymode == 2) /* for Y pix is function of X orus only, add round error */
+ yorg = (((fix31)sp_globals.ymin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift));
+ else
+ if (sp_globals.tcb.ymode == 3) /* for Y pix is function of -X orus only, sub round */
+ yorg = (((fix31)sp_globals.ymin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift));
+ else /* all other cases have no round error on yorg */
+ yorg = (fix31)sp_globals.ymin << 16;
+
+ open_bitmap(sp_globals.set_width.x, sp_globals.set_width.y, xorg, yorg,
+ sp_globals.xmax - sp_globals.xmin, sp_globals.ymax - sp_globals.ymin);
+ if (sp_globals.intercept_oflo)
+ {
+ sp_globals.y_band.band_min = sp_globals.ymin;
+ sp_globals.y_band.band_max = sp_globals.ymax;
+ init_intercepts_out();
+ sp_globals.first_pass = FALSE;
+ sp_globals.extents_running = FALSE;
+ return FALSE;
+ }
+ else
+ {
+ sp_proc_intercepts_screen();
+ close_bitmap();
+ return TRUE;
+ }
+ }
+else
+ {
+ if (sp_globals.intercept_oflo)
+ {
+ reduce_band_size_out();
+ init_intercepts_out();
+ return FALSE;
+ }
+ else
+ {
+ sp_proc_intercepts_screen();
+ if (next_band_out())
+ {
+ init_intercepts_out();
+ return FALSE;
+ }
+ close_bitmap();
+ return TRUE;
+ }
+ }
+}
+#endif
+
+#if INCL_SCREEN
+FUNCTION LOCAL void sp_add_intercept_screen(
+GDECL
+fix15 y, /* Y coordinate in relative pixel units */
+ /* (0 is lowest sample in band) */
+fix31 x) /* X coordinate of intercept in subpixel units */
+
+/* Called by line() to add an intercept to the intercept list structure
+ */
+
+{
+register fix15 from; /* Insertion pointers for the linked list sort */
+register fix15 to;
+register fix15 xloc;
+register fix15 xfrac;
+
+#if DEBUG
+printf(" Add intercept(%2d, %x)\n", y + sp_globals.y_band.band_min, x);
+
+/* Bounds checking IS done in debug mode */
+if (y < 0) /* Y value below bottom of current band? */
+ {
+ printf(" Intecerpt less than 0!!!\007\n");
+ return;
+ }
+
+if (y > (sp_globals.no_y_lists - 1)) /* Y value above top of current band? */
+ {
+ printf(" Intercept too big for band!!!!!\007\n");
+ return;
+ }
+#endif
+
+/* Store new values */
+
+sp_intercepts.car[sp_globals.next_offset] = xloc = (fix15)(x >> 16);
+sp_intercepts.inttype[sp_globals.next_offset] = sp_intercepts.leftedge | (xfrac = ((x >> 8) & FRACTION));
+
+/* Find slot to insert new element (between from and to) */
+
+from = y; /* Start at list head */
+
+while( (to = sp_intercepts.cdr[from]) != 0) /* Until to == end of list */
+ {
+ if (xloc < sp_intercepts.car[to]) /* If next item is larger than or same as this one... */
+ goto insert_element; /* ... drop out and insert here */
+ else if (xloc == sp_intercepts.car[to] && xfrac < (sp_intercepts.inttype[to] & FRACTION))
+ goto insert_element; /* ... drop out and insert here */
+ from = to; /* move forward in list */
+ }
+
+insert_element: /* insert element "sp_globals.next_offset" between elements "from" */
+ /* and "to" */
+
+sp_intercepts.cdr[from] = sp_globals.next_offset;
+sp_intercepts.cdr[sp_globals.next_offset] = to;
+
+if (++sp_globals.next_offset >= MAX_INTERCEPTS) /* Intercept buffer full? */
+ {
+ sp_globals.intercept_oflo = TRUE;
+/* There may be a few more calls to "add_intercept" from the current line */
+/* To avoid problems, we set next_offset to a safe value. We don't care */
+/* if the intercept table gets trashed at this point */
+ sp_globals.next_offset = sp_globals.first_offset;
+ }
+}
+
+#endif
+
+#if INCL_SCREEN
+FUNCTION LOCAL void sp_proc_intercepts_screen()
+GDECL
+
+/* Called by sp_make_char to output accumulated intercept lists
+ * Clips output to sp_globals.xmin, sp_globals.xmax, sp_globals.ymin, sp_globals.ymax boundaries
+ */
+{
+register fix15 i,j, jplus1, iminus1;
+fix15 k,nextk, previ;
+register fix15 from, to; /* Start and end of run in pixel units
+ relative to left extent of character */
+register fix15 y;
+register fix15 scan_line;
+ fix15 first_y, last_y;
+ fix15 xsave;
+
+
+fix15 diff;
+
+#if DEBUG
+printf("\nPROC_INTERCEPTS_SCREEN: Intercept lists before:\n");
+#endif
+
+#if INCL_CLIPPING
+if ((sp_globals.specs.flags & CLIP_LEFT) != 0)
+ clipleft = TRUE;
+else
+ clipleft = FALSE;
+if ((sp_globals.specs.flags & CLIP_RIGHT) != 0)
+ clipright = TRUE;
+else
+ clipright = FALSE;
+if (clipleft || clipright)
+ {
+ xmax = sp_globals.clip_xmax + sp_globals.xmin;
+ xmin = sp_globals.clip_xmin + sp_globals.xmin;
+ }
+if (!clipright)
+ xmax = ((sp_globals.set_width.x+32768L) >> 16);
+#endif
+
+if ((first_y = sp_globals.y_band.band_max) >= sp_globals.ymax)
+ first_y = sp_globals.ymax - 1; /* Clip to sp_globals.ymax boundary */
+
+if ((last_y = sp_globals.y_band.band_min) < sp_globals.ymin)
+ last_y = sp_globals.ymin; /* Clip to sp_globals.ymin boundary */
+
+last_y -= sp_globals.y_band.band_min;
+
+#if DEBUG
+/* Print out all of the intercept info */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = y; /* Index head of intercept list */
+ while ((i = sp_intercepts.cdr[i]) != 0) /* Link to next intercept if present */
+ {
+ if ((from = sp_intercepts.car[i] - sp_globals.xmin) < 0)
+ from = 0; /* Clip to sp_globals.xmin boundary */
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ if (i == 0) /* End of list? */
+ {
+ printf("****** proc_intercepts: odd number of intercepts\n");
+ break;
+ }
+ if ((to = sp_intercepts.car[i]) > sp_globals.xmax)
+ to = sp_globals.xmax - sp_globals.xmin; /* Clip to sp_globals.xmax boundary */
+ else
+ to -= sp_globals.xmin;
+ printf(" Y = %2d (scanline %2d): %d %d:\n",
+ y + sp_globals.y_band.band_min, scan_line, from, to);
+ }
+ }
+#endif
+
+/* CHECK INTERCEPT LIST FOR DROPOUT AND WINDING, FIX IF NECESSARY */
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--)
+ {
+ previ = y;
+ i = sp_intercepts.cdr[y]; /* Index head of intercept list */
+ while (i != 0) /* Link to next intercept if present */
+ {
+ j = i;
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ if (sp_intercepts.inttype[i] & LEFT_INT)
+ {
+ if (sp_intercepts.inttype[j] & LEFT_INT)
+ {
+ do { i = sp_intercepts.cdr[i]; } while (sp_intercepts.inttype[i] & LEFT_INT);
+ do { i = sp_intercepts.cdr[i]; } while (sp_intercepts.cdr[i] && !(sp_intercepts.inttype[sp_intercepts.cdr[i]] & LEFT_INT));
+ sp_intercepts.cdr[j] = i;
+ }
+ else
+ {
+ xsave = sp_intercepts.car[j];
+ sp_intercepts.car[j] = sp_intercepts.car[i];
+ sp_intercepts.car[i] = xsave;
+
+ xsave = sp_intercepts.inttype[j];
+ sp_intercepts.inttype[j] = sp_intercepts.inttype[i] & FRACTION;
+ sp_intercepts.inttype[i] = xsave | LEFT_INT;
+
+ sp_intercepts.cdr[previ] = i;
+ sp_intercepts.cdr[j] = sp_intercepts.cdr[i];
+ sp_intercepts.cdr[i] = j;
+ i = j;
+ j = sp_intercepts.cdr[previ];
+ }
+ }
+
+ if (sp_intercepts.car[j] < sp_globals.xmin)
+ sp_intercepts.car[j] = sp_globals.xmin; /* Clip to sp_globals.xmin boundary */
+
+ if (sp_intercepts.car[i] > sp_globals.xmax)
+ sp_intercepts.car[i] = sp_globals.xmax;
+
+ if (sp_intercepts.car[j] >= sp_intercepts.car[i])
+ {
+ if ((ufix16)(sp_intercepts.inttype[j] & FRACTION) + (ufix16)(sp_intercepts.inttype[i] & FRACTION) > sp_intercepts.fracpix)
+ ++sp_intercepts.car[i];
+ else
+ --sp_intercepts.car[j];
+ }
+ if (sp_globals.first_pass)
+ {
+ if (sp_intercepts.inttype[i-1] & END_INT)
+ {
+ for (iminus1 = i+1; !(sp_intercepts.inttype[iminus1] & END_INT); iminus1++)
+ ;
+ }
+ else
+ iminus1 = i-1;
+
+ if (sp_intercepts.inttype[j] & END_INT)
+ {
+ for (jplus1 = j-1; !(sp_intercepts.inttype[jplus1] & END_INT); jplus1--)
+ ;
+ jplus1++;
+ }
+ else
+ jplus1 = j+1;
+
+ if ((sp_intercepts.inttype[iminus1] & LEFT_INT))
+ {
+ if ( sp_intercepts.car[jplus1] > sp_intercepts.car[i])
+ {
+ diff = sp_intercepts.car[jplus1] - sp_intercepts.car[i];
+ sp_intercepts.car[i] += diff/2;
+ sp_intercepts.car[jplus1] -= diff/2;
+ if (diff & 1)
+ {
+ if ((ufix16)(sp_intercepts.inttype[i] & FRACTION) + (ufix16)(sp_intercepts.inttype[jplus1] & FRACTION) > sp_intercepts.fracpix)
+ sp_intercepts.car[i] ++;
+ else
+ sp_intercepts.car[jplus1]--;
+ }
+ }
+ }
+ else if (!(sp_intercepts.inttype[jplus1] & LEFT_INT))
+ {
+ if (sp_intercepts.car[iminus1] < sp_intercepts.car[j])
+ {
+ diff = sp_intercepts.car[j] - sp_intercepts.car[iminus1];
+ sp_intercepts.car[j] -= diff/2;
+ sp_intercepts.car[iminus1] += diff/2;
+ if (diff & 1)
+ {
+ if ((ufix16)(sp_intercepts.inttype[j] & FRACTION) +
+ (ufix16)(sp_intercepts.inttype[iminus1] & FRACTION) > sp_intercepts.fracpix)
+ sp_intercepts.car[iminus1]++;
+ else
+ sp_intercepts.car[j]--;
+ }
+ }
+ }
+ if (sp_globals.tcb.mirror == -1)
+ {
+ if (sp_intercepts.inttype[j-1] & END_INT)
+ {
+ for (jplus1 = j+1; !(sp_intercepts.inttype[jplus1] & END_INT); jplus1++)
+ ;
+ }
+ else
+ {
+ jplus1 = j-1;
+ }
+ }
+
+ if (!(sp_intercepts.inttype[jplus1] & LEFT_INT) &&
+ sp_intercepts.car[j] > sp_intercepts.car[jplus1])
+ {
+ k = sp_intercepts.cdr[y - 1];
+ while (k > 0)
+ {
+ nextk = sp_intercepts.cdr[k];
+ if (!(sp_intercepts.inttype[k] & LEFT_INT) &&
+ (sp_intercepts.inttype[nextk] & LEFT_INT) &&
+ sp_intercepts.car[nextk] > sp_intercepts.car[jplus1])
+ {
+ if ((diff=sp_intercepts.car[j] - sp_intercepts.car[k]) > 0)
+ {
+ if (diff <= (sp_intercepts.car[nextk] - sp_intercepts.car[jplus1]))
+ {
+ sp_intercepts.car[j] -= diff/2;
+ sp_intercepts.car[k] += diff/2;
+ if (diff & 1)
+ {
+ if ((ufix16)(sp_intercepts.inttype[j] & FRACTION) +
+ (ufix16)(sp_intercepts.inttype[k] & FRACTION) > sp_intercepts.fracpix)
+ sp_intercepts.car[j]--;
+ else
+ sp_intercepts.car[k]++;
+ }
+ }
+ else
+ {
+ diff = sp_intercepts.car[nextk] - sp_intercepts.car[jplus1];
+ sp_intercepts.car[nextk] -= diff/2;
+ sp_intercepts.car[jplus1] += diff/2;
+ if (diff & 1)
+ {
+ if ((ufix16)(sp_intercepts.inttype[jplus1] & FRACTION) +
+ (ufix16)(sp_intercepts.inttype[nextk] & FRACTION) > sp_intercepts.fracpix)
+ sp_intercepts.car[nextk]--;
+ else
+ sp_intercepts.car[jplus1]++;
+ }
+ }
+ }
+ break;
+ }
+ k = nextk;
+ }
+ }
+ if (j > 0 && sp_intercepts.car[j-1] > sp_intercepts.car[i] && !(sp_intercepts.inttype[j-1] & END_INT))
+ {
+ diff = sp_intercepts.car[j-1] - sp_intercepts.car[i];
+ sp_intercepts.car[i] += diff/2;
+ sp_intercepts.car[j-1] -= diff/2;
+ if (diff & 1)
+ {
+ if ((ufix16)(sp_intercepts.inttype[i] & FRACTION) + (ufix16)(sp_intercepts.inttype[j-1] & FRACTION) > sp_intercepts.fracpix)
+ sp_intercepts.car[i]++;
+ else
+ sp_intercepts.car[j-1]--;
+ }
+ }
+ if (sp_intercepts.car[i+1] < sp_intercepts.car[j] && !(sp_intercepts.inttype[i] & END_INT))
+ {
+ diff = sp_intercepts.car[j] - sp_intercepts.car[i+1];
+ sp_intercepts.car[j] -= diff/2;
+ sp_intercepts.car[i+1] += diff/2;
+ if (diff & 1)
+ {
+ if ((ufix16)(sp_intercepts.inttype[j] & FRACTION) + (ufix16)(sp_intercepts.inttype[i+1] & FRACTION) > sp_intercepts.fracpix)
+ sp_intercepts.car[i+1]++;
+ else
+ sp_intercepts.car[j]--;
+ }
+
+ }
+ previ = i;
+ }
+ i = sp_intercepts.cdr[i];
+ }
+ }
+
+#if DEBUG
+printf("\nPROC_INTERCEPTS_SCREEN: Intercept lists after:\n");
+/* Print out all of the intercept info */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = y; /* Index head of intercept list */
+ while ((i = sp_intercepts.cdr[i]) != 0) /* Link to next intercept if present */
+ {
+ if ((from = sp_intercepts.car[i] - sp_globals.xmin) < 0)
+ from = 0; /* Clip to sp_globals.xmin boundary */
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ if (i == 0) /* End of list? */
+ {
+ printf("****** proc_intercepts: odd number of intercepts\n");
+ break;
+ }
+ if ((to = sp_intercepts.car[i]) > sp_globals.xmax)
+ to = sp_globals.xmax - sp_globals.xmin; /* Clip to sp_globals.xmax boundary */
+ else
+ to -= sp_globals.xmin;
+ printf(" Y = %2d (scanline %2d): %d %d:\n",
+ y + sp_globals.y_band.band_min, scan_line, from, to);
+ }
+ }
+#endif
+
+/* INTERCEPTS ALL PATCHED, NOW DRAW THE IMAGE */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = sp_intercepts.cdr[y]; /* Index head of intercept list */
+ while (i != 0) /* Link to next intercept if present */
+ {
+ from = sp_intercepts.car[i];
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ to = sp_intercepts.car[i];
+#if INCL_CLIPPING
+ if (clipleft)
+ {
+ if (to <= xmin)
+ {
+ i = sp_intercepts.cdr[i];
+ continue;
+ }
+ if (from < xmin)
+ from = xmin;
+ }
+ if (clipright)
+ {
+ if (from >= xmax)
+ {
+ i = sp_intercepts.cdr[i];
+ continue;
+ }
+ if (to > xmax)
+ to = xmax;
+ }
+#endif
+ set_bitmap_bits(scan_line, from-sp_globals.xmin, to-sp_globals.xmin);
+ i = sp_intercepts.cdr[i];
+ }
+ }
+}
+
+#endif
diff --git a/nx-X11/lib/font/Speedo/out_util.c b/nx-X11/lib/font/Speedo/out_util.c
new file mode 100644
index 000000000..171241030
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/out_util.c
@@ -0,0 +1,341 @@
+/* $Xorg: out_util.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/out_util.c,v 1.2 1999/02/07 06:18:17 dawes Exp $ */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#define DEBUG 0
+
+/*************************** O U T _ U T I L . C *****************************
+ * *
+ * This is a utility module share by all bitmap output modules *
+ * *
+ *****************************************************************************/
+
+
+#include "spdo_prv.h" /* General definitions for Speedo */
+/* absolute value function */
+#define ABS(X) ( (X < 0) ? -X : X)
+#if INCL_BLACK || INCL_2D || INCL_SCREEN
+
+FUNCTION void init_char_out(
+GDECL
+point_t Psw, point_t Pmin, point_t Pmax)
+{
+sp_globals.set_width.x = (fix31)Psw.x << sp_globals.poshift;
+sp_globals.set_width.y = (fix31)Psw.y << sp_globals.poshift;
+set_first_band_out(Pmin, Pmax);
+init_intercepts_out();
+if (sp_globals.normal)
+ {
+ sp_globals.bmap_xmin = Pmin.x;
+ sp_globals.bmap_xmax = Pmax.x;
+ sp_globals.bmap_ymin = Pmin.y;
+ sp_globals.bmap_ymax = Pmax.y;
+ sp_globals.extents_running = FALSE;
+ }
+else
+ {
+ sp_globals.bmap_xmin = 32000;
+ sp_globals.bmap_xmax = -32000;
+ sp_globals.bmap_ymin = 32000;
+ sp_globals.bmap_ymax = -32000;
+ sp_globals.extents_running = TRUE;
+ }
+sp_globals.first_pass = TRUE;
+}
+
+FUNCTION void begin_sub_char_out(
+GDECL
+point_t Psw,
+point_t Pmin,
+point_t Pmax)
+/* Called at the start of each sub-character in a composite character
+ */
+{
+#if DEBUG
+printf("BEGIN_SUB_CHAR_out(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
+ (real)Psw.x / (real)sp_globals.onepix, (real)Psw.y / (real)sp_globals.onepix,
+ (real)Pmin.x / (real)sp_globals.onepix, (real)Pmin.y / (real)sp_globals.onepix,
+ (real)Pmax.x / (real)sp_globals.onepix, (real)Pmax.y / (real)sp_globals.onepix);
+#endif
+restart_intercepts_out();
+if (!sp_globals.extents_running)
+ {
+ sp_globals.bmap_xmin = 32000;
+ sp_globals.bmap_xmax = -32000;
+ sp_globals.bmap_ymin = 32000;
+ sp_globals.bmap_ymax = -32000;
+ sp_globals.extents_running = TRUE;
+ }
+}
+
+FUNCTION void curve_out(
+GDECL
+point_t P1, point_t P2, point_t P3,
+fix15 depth)
+/* Called for each curve in the transformed character if curves out enabled
+ */
+{
+#if DEBUG
+printf("CURVE_OUT(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix,
+ (real)P2.x / (real)sp_globals.onepix, (real)P2.y / (real)sp_globals.onepix,
+ (real)P3.x / (real)sp_globals.onepix, (real)P3.y / (real)sp_globals.onepix);
+#endif
+}
+
+
+
+FUNCTION void end_contour_out()
+GDECL
+/* Called after the last vector in each contour
+ */
+{
+#if DEBUG
+printf("END_CONTOUR_OUT()\n");
+#endif
+}
+
+
+FUNCTION void end_sub_char_out()
+GDECL
+/* Called after the last contour in each sub-character in a compound character
+ */
+{
+#if DEBUG
+printf("END_SUB_CHAR_OUT()\n");
+#endif
+}
+
+
+FUNCTION void init_intercepts_out()
+GDECL
+/* Called to initialize intercept storage data structure
+ */
+
+{
+fix15 i;
+fix15 no_lists;
+
+#if DEBUG
+printf(" Init intercepts (Y band from %d to %d)\n", sp_globals.y_band.band_min, sp_globals.y_band.band_max);
+if (sp_globals.x_scan_active)
+ printf(" (X band from %d to %d)\n", sp_globals.x_band.band_min, sp_globals.x_band.band_max);
+#endif
+
+sp_globals.intercept_oflo = FALSE;
+
+sp_globals.no_y_lists = sp_globals.y_band.band_max - sp_globals.y_band.band_min + 1;
+#if INCL_2D
+if (sp_globals.output_mode == MODE_2D)
+ {
+ sp_globals.no_x_lists = sp_globals.x_scan_active ?
+ sp_globals.x_band.band_max - sp_globals.x_band.band_min + 1 : 0;
+ no_lists = sp_globals.no_y_lists + sp_globals.no_x_lists;
+ }
+else
+#endif
+ no_lists = sp_globals.no_y_lists;
+
+#if INCL_2D
+sp_globals.y_band.band_floor = 0;
+sp_globals.y_band.band_ceiling = sp_globals.no_y_lists;
+#endif
+
+if (no_lists >= MAX_INTERCEPTS) /* Not enough room for list table? */
+ {
+ no_lists = sp_globals.no_y_lists = MAX_INTERCEPTS;
+ sp_globals.intercept_oflo = TRUE;
+ sp_globals.y_band.band_min = sp_globals.y_band.band_max - sp_globals.no_y_lists + 1;
+#if INCL_2D
+ sp_globals.y_band.band_array_offset = sp_globals.y_band.band_min;
+ sp_globals.y_band.band_ceiling = sp_globals.no_y_lists;
+ sp_globals.no_x_lists = 0;
+ sp_globals.x_scan_active = FALSE;
+#endif
+ }
+
+for (i = 0; i < no_lists; i++) /* For each active value... */
+ {
+#if INCL_SCREEN
+ if (sp_globals.output_mode == MODE_SCREEN)
+ sp_intercepts.inttype[i]=0;
+#endif
+ sp_intercepts.cdr[i] = 0; /* Mark each intercept list empty */
+ }
+
+sp_globals.first_offset = sp_globals.next_offset = no_lists;
+
+#if INCL_2D
+sp_globals.y_band.band_array_offset = sp_globals.y_band.band_min;
+sp_globals.x_band.band_array_offset = sp_globals.x_band.band_min - sp_globals.no_y_lists;
+sp_globals.x_band.band_floor = sp_globals.no_y_lists;
+sp_globals.x_band.band_ceiling = no_lists;
+#endif
+#if INCL_SCREEN
+sp_intercepts.inttype[sp_globals.no_y_lists-1] = END_INT;
+#endif
+
+}
+
+
+FUNCTION void restart_intercepts_out()
+GDECL
+
+/* Called by sp_make_char when a new sub character is started
+ * Freezes current sorted lists
+ */
+
+{
+
+#if DEBUG
+printf(" Restart intercepts:\n");
+#endif
+sp_globals.first_offset = sp_globals.next_offset;
+}
+
+
+
+FUNCTION void set_first_band_out(
+GDECL
+point_t Pmin,
+point_t Pmax)
+{
+
+sp_globals.ymin = Pmin.y;
+sp_globals.ymax = Pmax.y;
+
+sp_globals.ymin = (sp_globals.ymin - sp_globals.onepix + 1) >> sp_globals.pixshift;
+sp_globals.ymax = (sp_globals.ymax + sp_globals.onepix - 1) >> sp_globals.pixshift;
+
+#if INCL_CLIPPING
+ switch(sp_globals.tcb0.xtype)
+ {
+ case 1: /* 180 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ sp_globals.clip_ymin = -1* sp_globals.clip_ymin;
+ if (sp_globals.ymin < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ if (sp_globals.ymax > sp_globals.clip_ymax)
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ break;
+ case 2: /* 90 degree rotation */
+ sp_globals.clip_ymax = 0;
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ break;
+ case 3: /* 270 degree rotation */
+ sp_globals.clip_ymax = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = 0;
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ break;
+ default: /* this is for zero degree rotation and arbitrary rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ if (sp_globals.ymax > sp_globals.clip_ymax)
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ sp_globals.clip_ymin = - sp_globals.clip_ymin;
+ if (sp_globals.ymin < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ }
+ break;
+ }
+#endif
+sp_globals.y_band.band_min = sp_globals.ymin;
+sp_globals.y_band.band_max = sp_globals.ymax - 1;
+
+sp_globals.xmin = (Pmin.x + sp_globals.pixrnd) >> sp_globals.pixshift;
+sp_globals.xmax = (Pmax.x + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+
+#if INCL_2D
+sp_globals.x_band.band_min = sp_globals.xmin - 1; /* subtract one pixel of "safety margin" */
+sp_globals.x_band.band_max = sp_globals.xmax /* - 1 + 1 */; /* Add one pixel of "safety margin" */
+#endif
+}
+
+
+
+
+
+
+
+FUNCTION void reduce_band_size_out()
+GDECL
+{
+sp_globals.y_band.band_min = sp_globals.y_band.band_max - ((sp_globals.y_band.band_max - sp_globals.y_band.band_min) >> 1);
+#if INCL_2D
+sp_globals.y_band.band_array_offset = sp_globals.y_band.band_min;
+#endif
+}
+
+
+FUNCTION boolean next_band_out()
+GDECL
+{
+fix15 tmpfix15;
+
+if (sp_globals.y_band.band_min <= sp_globals.ymin)
+ return FALSE;
+tmpfix15 = sp_globals.y_band.band_max - sp_globals.y_band.band_min;
+sp_globals.y_band.band_max = sp_globals.y_band.band_min - 1;
+sp_globals.y_band.band_min = sp_globals.y_band.band_max - tmpfix15;
+if (sp_globals.y_band.band_min < sp_globals.ymin)
+ sp_globals.y_band.band_min = sp_globals.ymin;
+#if INCL_2D
+sp_globals.y_band.band_array_offset = sp_globals.y_band.band_min;
+#endif
+return TRUE;
+}
+#endif
+
diff --git a/nx-X11/lib/font/Speedo/reset.c b/nx-X11/lib/font/Speedo/reset.c
new file mode 100644
index 000000000..4cb9f7de0
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/reset.c
@@ -0,0 +1,131 @@
+/* $Xorg: reset.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/reset.c,v 1.2 1999/02/07 06:18:17 dawes Exp $ */
+
+
+
+/******************************* R E S E T . C *******************************
+ * *
+ * This module provides initialization functions. *
+ * *
+ ****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "spdo_prv.h" /* General definitions for Speedo */
+#include "keys.h" /* Font decryption keys */
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** STATIC FUNCTIONS *****/
+
+
+FUNCTION void reset()
+GDECL
+/*
+ * Called by the host software to intialize the Speedo mechanism
+ */
+{
+sp_globals.specs_valid = FALSE; /* Flag specs not valid */
+
+/* Reset decryption key */
+sp_globals.key32 = (KEY3 << 8) | KEY2;
+sp_globals.key4 = KEY4;
+sp_globals.key6 = KEY6;
+sp_globals.key7 = KEY7;
+sp_globals.key8 = KEY8;
+
+#if INCL_RULES
+sp_globals.constr.font_id_valid = FALSE;
+#endif
+
+#if INCL_MULTIDEV
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+sp_globals.bitmap_device_set = FALSE;
+#endif
+#if INCL_OUTLINE
+sp_globals.outline_device_set = FALSE;
+#endif
+#endif
+}
+
+#if INCL_KEYS
+FUNCTION void set_key(
+GDECL
+ufix8 key[]) /* Specified decryption key */
+/*
+ * Dynamically sets font decryption key.
+ */
+{
+sp_globals.key32 = ((ufix16)key[3] << 8) | key[2];
+sp_globals.key4 = key[4];
+sp_globals.key6 = key[6];
+sp_globals.key7 = key[7];
+sp_globals.key8 = key[8];
+}
+#endif
+
+
+
+FUNCTION ufix16 get_cust_no(
+GDECL
+buff_t font_buff)
+/*
+ returns customer number from font
+*/
+{
+ufix8 FONTFAR *hdr2_org;
+ufix16 private_off;
+
+private_off = read_word_u(font_buff.org + FH_HEDSZ);
+if (private_off + FH_CUSNR > font_buff.no_bytes)
+ {
+ report_error(1); /* Insufficient font data loaded */
+ return FALSE;
+ }
+
+hdr2_org = font_buff.org + private_off;
+
+return (read_word_u(hdr2_org + FH_CUSNR));
+}
+
+
diff --git a/nx-X11/lib/font/Speedo/set_spcs.c b/nx-X11/lib/font/Speedo/set_spcs.c
new file mode 100644
index 000000000..b69b13f34
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/set_spcs.c
@@ -0,0 +1,773 @@
+/* $Xorg: set_spcs.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/set_spcs.c,v 1.3 2001/01/17 19:43:17 dawes Exp $ */
+
+
+/*************************** S E T _ S P C S . C *****************************
+ * *
+ * This module implements all sp_set_specs() functionality. *
+ * *
+ ****************************************************************************/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#define SET_SPCS
+#include "spdo_prv.h" /* General definitions for Speedo */
+#include "keys.h"
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/****** EXTERNAL VARIABLES *****/
+
+/***** STATIC VARIABLES *****/
+
+
+/****** STATIC FUNCTIONS *****/
+
+static boolean sp_setup_consts(PROTO_DECL2 fix15 xmin, fix15 xmax,
+ fix15 ymin, fix15 ymax);
+static void sp_setup_tcb(PROTO_DECL2 tcb_t GLOBALFAR *ptcb);
+static fix15 sp_setup_mult(PROTO_DECL2 fix31 input_mult);
+static fix31 sp_setup_offset(PROTO_DECL2 fix31 input_offset);
+
+
+
+FUNCTION boolean set_specs(
+GDECL
+specs_t STACKFAR *specsarg) /* Bundle of conversion specifications */
+/*
+ * Called by host software to set character generation specifications
+ */
+{
+fix31 offcd; /* Offset to start of character directory */
+fix31 ofcns; /* Offset to start of constraint data */
+fix31 cd_size; /* Size of character directory */
+fix31 no_bytes_min; /* Min number of bytes in font buffer */
+ufix16 font_id; /* Font ID */
+ufix16 private_off; /* offset to private header */
+fix15 xmin; /* Minimum X ORU value in font */
+fix15 xmax; /* Maximum X ORU value in font */
+fix15 ymin; /* Minimum Y ORU value in font */
+fix15 ymax; /* Maximum Y ORU value in font */
+
+sp_globals.specs_valid = FALSE; /* Flag specs not valid */
+
+sp_globals.specs = *specsarg; /* copy specs structure into sp_globals */
+sp_globals.pspecs = &sp_globals.specs;
+sp_globals.font = *sp_globals.pspecs->pfont;
+sp_globals.pfont = &sp_globals.font;
+sp_globals.font_org = sp_globals.font.org;
+
+if (read_word_u(sp_globals.font_org + FH_FMVER + 4) != 0x0d0a)
+ {
+ report_error(4); /* Font format error */
+ return FALSE;
+ }
+if (read_word_u(sp_globals.font_org + FH_FMVER + 6) != 0x0000)
+ {
+ report_error(4); /* Font format error */
+ return FALSE;
+ }
+
+if (get_cust_no(*specsarg->pfont) == 0)
+ {
+ sp_globals.key32 = 0;
+ sp_globals.key4 = 0;
+ sp_globals.key6 = 0;
+ sp_globals.key7 = 0;
+ sp_globals.key8 = 0;
+ }
+else
+ {
+ sp_globals.key32 = (KEY3 << 8) | KEY2;
+ sp_globals.key4 = KEY4;
+ sp_globals.key6 = KEY6;
+ sp_globals.key7 = KEY7;
+ sp_globals.key8 = KEY8;
+ }
+
+
+sp_globals.no_chars_avail = read_word_u(sp_globals.font_org + FH_NCHRF);
+
+/* Read sp_globals.orus per em from font header */
+sp_globals.orus_per_em = read_word_u(sp_globals.font_org + FH_ORUPM);
+
+/* compute address of private header */
+private_off = read_word_u(sp_globals.font_org + FH_HEDSZ);
+sp_globals.hdr2_org = sp_globals.font_org + private_off;
+
+/* set metric resolution if specified, default to outline res otherwise */
+if (private_off > EXP_FH_METRES)
+ {
+ sp_globals.metric_resolution = read_word_u(sp_globals.font_org + EXP_FH_METRES);
+ }
+else
+ {
+ sp_globals.metric_resolution = sp_globals.orus_per_em;
+ }
+
+#if INCL_METRICS
+sp_globals.kern.tkorg = sp_globals.font_org + read_long(sp_globals.hdr2_org + FH_OFFTK);
+sp_globals.kern.pkorg = sp_globals.font_org + read_long(sp_globals.hdr2_org + FH_OFFPK);
+sp_globals.kern.no_tracks = read_word_u(sp_globals.font_org + FH_NKTKS);
+sp_globals.kern.no_pairs = read_word_u(sp_globals.font_org + FH_NKPRS);
+#endif
+
+offcd = read_long(sp_globals.hdr2_org + FH_OFFCD); /* Read offset to character directory */
+ofcns = read_long(sp_globals.hdr2_org + FH_OFCNS); /* Read offset to constraint data */
+cd_size = ofcns - offcd;
+if ((((sp_globals.no_chars_avail << 1) + 3) != cd_size) &&
+ (((sp_globals.no_chars_avail * 3) + 4) != cd_size))
+ {
+ report_error(4); /* Font format error */
+ return FALSE;
+ }
+
+#if INCL_LCD /* Dynamic character data load suppoorted? */
+#if INCL_METRICS
+no_bytes_min = read_long(sp_globals.hdr2_org + FH_OCHRD); /* Offset to character data */
+#else /* Dynamic character data load not supported? */
+no_bytes_min = read_long(sp_globals.hdr2_org + FH_OFFTK); /* Offset to track kerning data */
+#endif
+#else /* Dynamic character data load not supported? */
+no_bytes_min = read_long(sp_globals.hdr2_org + FH_NBYTE); /* Offset to EOF + 1 */
+#endif
+
+sp_globals.font_buff_size = sp_globals.pfont->no_bytes;
+if (sp_globals.font_buff_size < no_bytes_min) /* Minimum data not loaded? */
+ {
+ report_error(1); /* Insufficient font data loaded */
+ return FALSE;
+ }
+
+sp_globals.pchar_dir = sp_globals.font_org + offcd;
+sp_globals.first_char_idx = read_word_u(sp_globals.font_org + FH_FCHRF);
+
+/* Register font name with sp_globals.constraint mechanism */
+#if INCL_RULES
+font_id = read_word_u(sp_globals.font_org + FH_FNTID);
+if (!(sp_globals.constr.font_id_valid) || (sp_globals.constr.font_id != font_id))
+ {
+ sp_globals.constr.font_id = font_id;
+ sp_globals.constr.font_id_valid = TRUE;
+ sp_globals.constr.data_valid = FALSE;
+ }
+sp_globals.constr.org = sp_globals.font_org + ofcns;
+sp_globals.constr.active = ((sp_globals.pspecs->flags & CONSTR_OFF) == 0);
+#endif
+
+/* Set up sliding point constants */
+/* Set pixel shift to accomodate largest transformed pixel value */
+xmin = read_word_u(sp_globals.font_org + FH_FXMIN);
+xmax = read_word_u(sp_globals.font_org + FH_FXMAX);
+ymin = read_word_u(sp_globals.font_org + FH_FYMIN);
+ymax = read_word_u(sp_globals.font_org + FH_FYMAX);
+
+if (!sp_setup_consts(xmin,xmax,ymin,ymax))
+ {
+ report_error(3); /* Requested specs out of range */
+ return FALSE;
+ }
+#if INCL_ISW
+/* save the value of the max x oru that the fixed point constants are based on*/
+sp_globals.isw_xmax = xmax;
+#endif
+
+/* Setup transformation control block */
+sp_setup_tcb(&sp_globals.tcb0);
+
+
+/* Select output module */
+sp_globals.output_mode = sp_globals.pspecs->flags & 0x0007;
+
+#if INCL_USEROUT
+if (!init_userout(sp_globals.pspecs))
+#endif
+
+switch (sp_globals.output_mode)
+ {
+#if INCL_BLACK
+case MODE_BLACK: /* Output mode 0 (Black writer) */
+ sp_globals.init_out = sp_init_black;
+ sp_globals.begin_char = sp_begin_char_black;
+ sp_globals.begin_sub_char = sp_begin_sub_char_out;
+ sp_globals.begin_contour = sp_begin_contour_black;
+ sp_globals.curve = sp_curve_out;
+ sp_globals.line = sp_line_black;
+ sp_globals.end_contour = sp_end_contour_out;
+ sp_globals.end_sub_char = sp_end_sub_char_out;
+ sp_globals.end_char = sp_end_char_black;
+ break;
+#endif
+
+#if INCL_SCREEN
+case MODE_SCREEN: /* Output mode 1 (Screen writer) */
+ sp_globals.init_out = sp_init_screen;
+ sp_globals.begin_char = sp_begin_char_screen;
+ sp_globals.begin_sub_char = sp_begin_sub_char_out;
+ sp_globals.begin_contour = sp_begin_contour_screen;
+ sp_globals.curve = sp_curve_screen;
+ sp_globals.line = sp_line_screen;
+ sp_globals.end_contour = sp_end_contour_screen;
+ sp_globals.end_sub_char = sp_end_sub_char_out;
+ sp_globals.end_char = sp_end_char_screen;
+ break;
+#endif
+
+#if INCL_OUTLINE
+case MODE_OUTLINE: /* Output mode 2 (Vector) */
+ sp_globals.init_out = sp_init_outline;
+ sp_globals.begin_char = sp_begin_char_outline;
+ sp_globals.begin_sub_char = sp_begin_sub_char_outline;
+ sp_globals.begin_contour = sp_begin_contour_outline;
+ sp_globals.curve = sp_curve_outline;
+ sp_globals.line = sp_line_outline;
+ sp_globals.end_contour = sp_end_contour_outline;
+ sp_globals.end_sub_char = sp_end_sub_char_outline;
+ sp_globals.end_char = sp_end_char_outline;
+ break;
+#endif
+
+#if INCL_2D
+case MODE_2D: /* Output mode 3 */
+ sp_globals.init_out = sp_init_2d;
+ sp_globals.begin_char = sp_begin_char_2d;
+ sp_globals.begin_sub_char = sp_begin_sub_char_out;
+ sp_globals.begin_contour = sp_begin_contour_2d;
+ sp_globals.curve = sp_curve_out;
+ sp_globals.line = sp_line_2d;
+ sp_globals.end_contour = sp_end_contour_out;
+ sp_globals.end_sub_char = sp_end_sub_char_out;
+ sp_globals.end_char = sp_end_char_2d;
+ break;
+#endif
+
+default:
+ report_error(8); /* Unsupported mode requested */
+ return FALSE;
+ }
+
+ if (!fn_init_out(sp_globals.pspecs))
+ {
+ report_error(5);
+ return FALSE;
+ }
+
+
+sp_globals.curves_out = sp_globals.pspecs->flags & CURVES_OUT;
+
+if (sp_globals.pspecs->flags & BOGUS_MODE) /* Linear transformation requested? */
+ {
+ sp_globals.tcb0.xtype = sp_globals.tcb0.ytype = 4;
+ }
+else /* Intelligent transformation requested? */
+ {
+#if INCL_RULES
+#else
+ report_error(7); /* Rules requested; not supported */
+ return FALSE;
+#endif
+ }
+
+if ((sp_globals.pspecs->flags & SQUEEZE_LEFT) ||
+ (sp_globals.pspecs->flags & SQUEEZE_RIGHT) ||
+ (sp_globals.pspecs->flags & SQUEEZE_TOP) ||
+ (sp_globals.pspecs->flags & SQUEEZE_BOTTOM) )
+ {
+#if (INCL_SQUEEZING)
+#else
+ report_error(11);
+ return FALSE;
+#endif
+ }
+
+if ((sp_globals.pspecs->flags & CLIP_LEFT) ||
+ (sp_globals.pspecs->flags & CLIP_RIGHT) ||
+ (sp_globals.pspecs->flags & CLIP_TOP) ||
+ (sp_globals.pspecs->flags & CLIP_BOTTOM) )
+ {
+#if (INCL_CLIPPING)
+#else
+ report_error(11);
+ return FALSE;
+#endif
+ }
+
+sp_globals.specs_valid = TRUE;
+return TRUE;
+}
+
+
+
+#if INCL_MULTIDEV
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+FUNCTION boolean set_bitmap_device(
+GDECL
+bitmap_t *bfuncs,
+ufix16 size)
+{
+
+if (size != sizeof(sp_globals.bitmap_device))
+ return FALSE;
+
+sp_globals.bitmap_device = *bfuncs;
+sp_globals.bitmap_device_set = TRUE;
+}
+#endif
+
+#if INCL_OUTLINE
+FUNCTION boolean set_outline_device(
+GDECL
+outline_t *ofuncs,
+ufix16 size)
+{
+
+if (size != sizeof(sp_globals.outline_device))
+ return FALSE;
+
+sp_globals.outline_device = *ofuncs;
+sp_globals.outline_device_set = TRUE;
+}
+#endif
+#endif
+
+
+#ifdef old
+FUNCTION boolean sp_setup_consts(
+GDECL
+fix15 xmin, /* Minimum X ORU value in font */
+fix15 xmax, /* Maximum X ORU value in font */
+fix15 ymin, /* Minimum Y ORU value in font */
+fix15 ymax) /* Maximum Y ORU value in font */
+#else
+static FUNCTION boolean sp_setup_consts(
+GDECL
+fix15 xmin, /* Minimum X ORU value in font */
+fix15 xmax, /* Maximum X ORU value in font */
+fix15 ymin, /* Minimum Y ORU value in font */
+fix15 ymax) /* Maximum Y ORU value in font */
+#endif
+/*
+ * Sets the following constants used for fixed point arithmetic:
+ * sp_globals.multshift multipliers and products; range is 14 to 8
+ * sp_globals.pixshift pixels: range is 0 to 8
+ * sp_globals.mpshift shift from product to sub-pixels (sp_globals.multshift - sp_globals.pixshift)
+ * sp_globals.multrnd rounding for products
+ * sp_globals.pixrnd rounding for pixels
+ * sp_globals.mprnd rounding for sub-pixels
+ * sp_globals.onepix 1 pixel in shifted pixel units
+ * sp_globals.pixfix mask to eliminate fractional bits of shifted pixels
+ * sp_globals.depth_adj curve splitting depth adjustment
+ * Returns FALSE if specs are out of range
+ */
+{
+fix31 mult; /* Successive multiplier values */
+ufix32 num; /* Numerator of largest multiplier value */
+ufix32 numcopy; /* Copy of numerator */
+ufix32 denom; /* Denominator of largest multiplier value */
+ufix32 denomcopy; /* Copy of denominator */
+ufix32 pix_max; /* Maximum pixel rounding error */
+fix31 xmult; /* Coefficient of X oru value in transformation */
+fix31 ymult; /* Coefficient of Y oru value in transformation */
+fix31 offset; /* Constant in transformation */
+fix15 i; /* Loop counter */
+fix15 x, y; /* Successive corners of bounding box in ORUs */
+fix31 pixval; /* Successive pixel values multiplied by orus per em */
+fix15 xx = 0, yy = 0;/* Bounding box corner that produces max pixel value */
+
+/* Determine numerator and denominator of largest multiplier value */
+mult = sp_globals.pspecs->xxmult >> 16;
+if (mult < 0)
+ mult = -mult;
+num = mult;
+
+mult = sp_globals.pspecs->xymult >> 16;
+if (mult < 0)
+ mult = -mult;
+if (mult > num)
+ num = mult;
+
+mult = sp_globals.pspecs->yxmult >> 16;
+if (mult < 0)
+ mult = -mult;
+if (mult > num)
+ num = mult;
+
+mult = sp_globals.pspecs->yymult >> 16;
+if (mult < 0)
+ mult = -mult;
+if (mult > num)
+ num = mult;
+num++; /* Max absolute pixels per em (rounded up) */
+denom = (ufix32)sp_globals.orus_per_em;
+
+/* Set curve splitting depth adjustment to accomodate largest multiplier value */
+sp_globals.depth_adj = 0; /* 0 = 0.5 pel, 1 = 0.13 pel, 2 = 0.04 pel accuracy */
+denomcopy = denom;
+/* The following two occurances of a strange method of shifting twice by 1
+ are intentional and should not be changed to a single shift by 2.
+ It prevents MicroSoft C 5.1 from generating functions calls to do the shift.
+ Worse, using the REENTRANT_ALLOC option in conjunction with the /AC compiler
+ option, the function appears to be called incorrectly, causing depth_adj to always
+ be set to -7, causing very angular characters. */
+
+while ((num > denomcopy) && (sp_globals.depth_adj < 5)) /* > 1, 4, 16, ... pixels per oru? */
+ {
+ denomcopy <<= 1;
+ denomcopy <<= 1;
+ sp_globals.depth_adj++; /* Add 1, 2, 3, ... to depth adjustment */
+ }
+numcopy = num << 2;
+while ((numcopy <= denom) && (sp_globals.depth_adj > -4)) /* <= 1/4, 1/16, 1/64 pix per oru? */
+ {
+ numcopy <<= 1;
+ numcopy <<= 1;
+ sp_globals.depth_adj--; /* Subtract 1, 2, 3, ... from depth adjustment */
+ }
+SHOW(sp_globals.depth_adj);
+
+/* Set multiplier shift to accomodate largest multiplier value */
+sp_globals.multshift = 14;
+numcopy = num;
+while (numcopy >= denom) /* More than 1, 2, 4, ... pix per oru? */
+ {
+ numcopy >>= 1;
+ sp_globals.multshift--; /* sp_globals.multshift is 13, 12, 11, ... */
+ }
+
+sp_globals.multrnd = ((fix31)1 << sp_globals.multshift) >> 1;
+SHOW(sp_globals.multshift);
+
+
+pix_max = (ufix32)( 0xffff & read_word_u(sp_globals.hdr2_org + FH_PIXMX));
+
+num = 0;
+xmult = ((sp_globals.pspecs->xxmult >> 16) + 1) >> 1;
+ymult = ((sp_globals.pspecs->xymult >> 16) + 1) >> 1;
+offset = ((sp_globals.pspecs->xoffset >> 16) + 1) >> 1;
+for (i = 0; i < 8; i++)
+ {
+ if (i == 4)
+ {
+ xmult = ((sp_globals.pspecs->yxmult >> 16) + 1) >> 1;
+ ymult = ((sp_globals.pspecs->yymult >> 16) + 1) >> 1;
+ offset = ((sp_globals.pspecs->yoffset >> 16) + 1) >> 1;
+ }
+ x = (i & BIT1)? xmin: xmax;
+ y = (i & BIT0)? ymin: ymax;
+ pixval = (fix31)x * xmult + (fix31)y * ymult + offset * denom;
+ if (pixval < 0)
+ pixval = -pixval;
+ if (pixval > num)
+ {
+ num = pixval;
+ xx = x;
+ yy = y;
+ }
+ }
+if (xx < 0)
+ xx = -xx;
+if (yy < 0)
+ yy = -yy;
+num += xx + yy + ((pix_max + 2) * denom);
+ /* Allow (with 2:1 safety margin) for 1 pixel rounding errors in */
+ /* xmult, ymult and offset values, pix_max pixel expansion */
+ /* due to intelligent scaling, and */
+ /* 1 pixel rounding of overall character position */
+denom = denom << 14; /* Note num is in units of half pixels times orus per em */
+
+sp_globals.pixshift = -1;
+while ((num <= denom) && (sp_globals.pixshift < 8)) /* Max pixels <= 32768, 16384, 8192, ... pixels? */
+ {
+ num <<= 1;
+ sp_globals.pixshift++; /* sp_globals.pixshift = 0, 1, 2, ... */
+ }
+if (sp_globals.pixshift < 0)
+ return FALSE;
+
+SHOW(sp_globals.pixshift);
+sp_globals.poshift = 16 - sp_globals.pixshift;
+
+sp_globals.onepix = (fix15)1 << sp_globals.pixshift;
+sp_globals.pixrnd = sp_globals.onepix >> 1;
+sp_globals.pixfix = ~0 << sp_globals.pixshift;
+
+sp_globals.mpshift = sp_globals.multshift - sp_globals.pixshift;
+if (sp_globals.mpshift < 0)
+ return FALSE;
+sp_globals.mprnd = ((fix31)1 << sp_globals.mpshift) >> 1;
+
+return TRUE;
+}
+
+#ifdef old
+FUNCTION void sp_setup_tcb(
+GDECL
+tcb_t GLOBALFAR *ptcb) /* Pointer to transformation control bloxk */
+#else
+static FUNCTION void sp_setup_tcb(
+GDECL
+tcb_t GLOBALFAR *ptcb) /* Pointer to transformation control bloxk */
+#endif
+/*
+ * Convert transformation coeffs to internal form
+ */
+{
+
+ptcb->xxmult = sp_setup_mult(sp_globals.pspecs->xxmult);
+ptcb->xymult = sp_setup_mult(sp_globals.pspecs->xymult);
+ptcb->xoffset = sp_setup_offset(sp_globals.pspecs->xoffset);
+ptcb->yxmult = sp_setup_mult(sp_globals.pspecs->yxmult);
+ptcb->yymult = sp_setup_mult(sp_globals.pspecs->yymult);
+ptcb->yoffset = sp_setup_offset(sp_globals.pspecs->yoffset);
+
+SHOW(ptcb->xxmult);
+SHOW(ptcb->xymult);
+SHOW(ptcb->xoffset);
+SHOW(ptcb->yxmult);
+SHOW(ptcb->yymult);
+SHOW(ptcb->yoffset);
+
+type_tcb(ptcb); /* Classify transformation type */
+}
+
+FUNCTION static fix15 sp_setup_mult(
+GDECL
+fix31 input_mult) /* Multiplier in input format */
+/*
+ * Called by sp_setup_tcb() to convert multiplier in transformation
+ * matrix from external to internal form.
+ */
+{
+fix15 imshift; /* Right shift to internal format */
+fix31 imdenom; /* Divisor to internal format */
+fix31 imrnd; /* Rounding for division operation */
+
+imshift = 15 - sp_globals.multshift;
+imdenom = (fix31)sp_globals.orus_per_em << imshift;
+imrnd = imdenom >> 1;
+
+input_mult >>= 1;
+if (input_mult >= 0)
+ return (fix15)((input_mult + imrnd) / imdenom);
+else
+ return -(fix15)((-input_mult + imrnd) / imdenom);
+}
+
+FUNCTION static fix31 sp_setup_offset(
+GDECL
+fix31 input_offset) /* Multiplier in input format */
+/*
+ * Called by sp_setup_tcb() to convert offset in transformation
+ * matrix from external to internal form.
+ */
+{
+fix15 imshift; /* Right shift to internal format */
+fix31 imrnd; /* Rounding for right shift operation */
+
+imshift = 15 - sp_globals.multshift;
+imrnd = ((fix31)1 << imshift) >> 1;
+
+return (((input_offset >> 1) + imrnd) >> imshift) + sp_globals.mprnd;
+}
+
+FUNCTION void type_tcb(
+GDECL
+tcb_t GLOBALFAR *ptcb) /* Pointer to transformation control bloxk */
+{
+fix15 x_trans_type;
+fix15 y_trans_type;
+fix15 xx_mult;
+fix15 xy_mult;
+fix15 yx_mult;
+fix15 yy_mult;
+fix15 h_pos;
+fix15 v_pos;
+fix15 x_ppo;
+fix15 y_ppo;
+fix15 x_pos;
+fix15 y_pos;
+
+/* check for mirror image transformations */
+xx_mult = ptcb->xxmult;
+xy_mult = ptcb->xymult;
+yx_mult = ptcb->yxmult;
+yy_mult = ptcb->yymult;
+
+ptcb->mirror = ((((fix31)xx_mult*(fix31)yy_mult)-
+ ((fix31)xy_mult*(fix31)yx_mult)) < 0) ? -1 : 1;
+
+if (sp_globals.pspecs->flags & BOGUS_MODE) /* Linear transformation requested? */
+ {
+ ptcb->xtype = 4;
+ ptcb->ytype = 4;
+
+ ptcb->xppo = 0;
+ ptcb->yppo = 0;
+ ptcb->xpos = 0;
+ ptcb->ypos = 0;
+ }
+else /* Intelligent tranformation requested? */
+ {
+ h_pos = ((ptcb->xoffset >> sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+ v_pos = ((ptcb->yoffset >> sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+
+ x_trans_type = 4;
+ x_ppo = 0;
+ x_pos = 0;
+
+ y_trans_type = 4;
+ y_ppo = 0;
+ y_pos = 0;
+
+ if (xy_mult == 0)
+ {
+ if (xx_mult >= 0)
+ {
+ x_trans_type = 0; /* X pix is function of X orus only */
+ x_ppo = xx_mult;
+ x_pos = h_pos;
+ }
+ else
+ {
+ x_trans_type = 1; /* X pix is function of -X orus only */
+ x_ppo = -xx_mult;
+ x_pos = -h_pos;
+ }
+ }
+
+ else if (xx_mult == 0)
+ {
+ if (xy_mult >= 0)
+ {
+ x_trans_type = 2; /* X pix is function of Y orus only */
+ y_ppo = xy_mult;
+ y_pos = h_pos;
+ }
+ else
+ {
+ x_trans_type = 3; /* X pix is function of -Y orus only */
+ y_ppo = -xy_mult;
+ y_pos = -h_pos;
+ }
+ }
+
+ if (yx_mult == 0)
+ {
+ if (yy_mult >= 0)
+ {
+ y_trans_type = 0; /* Y pix is function of Y orus only */
+ y_ppo = yy_mult;
+ y_pos = v_pos;
+ }
+ else
+ {
+ y_trans_type = 1; /* Y pix is function of -Y orus only */
+ y_ppo = -yy_mult;
+ y_pos = -v_pos;
+ }
+ }
+ else if (yy_mult == 0)
+ {
+ if (yx_mult >= 0)
+ {
+ y_trans_type = 2; /* Y pix is function of X orus only */
+ x_ppo = yx_mult;
+ x_pos = v_pos;
+ }
+ else
+ {
+ y_trans_type = 3; /* Y pix is function of -X orus only */
+ x_ppo = -yx_mult;
+ x_pos = -v_pos;
+ }
+ }
+
+ ptcb->xtype = x_trans_type;
+ ptcb->ytype = y_trans_type;
+
+ ptcb->xppo = x_ppo;
+ ptcb->yppo = y_ppo;
+ ptcb->xpos = x_pos;
+ ptcb->ypos = y_pos;
+ }
+
+sp_globals.normal = (ptcb->xtype != 4) && (ptcb->ytype != 4);
+
+ptcb->xmode = 4;
+ptcb->ymode = 4;
+
+SHOW(ptcb->xtype);
+SHOW(ptcb->ytype);
+SHOW(ptcb->xppo);
+SHOW(ptcb->yppo);
+SHOW(ptcb->xpos);
+SHOW(ptcb->ypos);
+}
+
+FUNCTION fix31 read_long(
+GDECL
+ufix8 FONTFAR *pointer) /* Pointer to first byte of encrypted 3-byte integer */
+/*
+ * Reads a 3-byte encrypted integer from the byte string starting at
+ * the specified point.
+ * Returns the decrypted value read as a signed integer.
+ */
+{
+fix31 tmpfix31;
+
+tmpfix31 = (fix31)((*pointer++) ^ sp_globals.key4) << 8; /* Read middle byte */
+tmpfix31 += (fix31)(*pointer++) << 16; /* Read most significant byte */
+tmpfix31 += (fix31)((*pointer) ^ sp_globals.key6); /* Read least significant byte */
+return tmpfix31;
+}
+
+FUNCTION fix15 read_word_u(
+GDECL
+ufix8 FONTFAR *pointer) /* Pointer to first byte of unencrypted 2-byte integer */
+/*
+ * Reads a 2-byte unencrypted integer from the byte string starting at
+ * the specified point.
+ * Returns the decrypted value read as a signed integer.
+ */
+{
+fix15 tmpfix15;
+
+tmpfix15 = (fix15)(*pointer++) << 8; /* Read most significant byte */
+tmpfix15 += (fix15)(*pointer); /* Add least significant byte */
+return tmpfix15;
+}
+
+
diff --git a/nx-X11/lib/font/Speedo/set_trns.c b/nx-X11/lib/font/Speedo/set_trns.c
new file mode 100644
index 000000000..3b8f60378
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/set_trns.c
@@ -0,0 +1,1324 @@
+/* $Xorg: set_trns.c,v 1.3 2000/08/17 19:46:27 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/set_trns.c,v 1.5tsi Exp $ */
+
+
+
+/*************************** S E T _ T R N S . C *****************************
+ * *
+ * This module is called from do_char.c to set up the intelligent *
+ * transformation for one character (or sub-character of a composite *
+ * character.
+ * *
+ ****************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "spdo_prv.h" /* General definitions for Speedo */
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+/***** LOCAL MACROS *****/
+
+#define SQUEEZE_X_ORU(A,B,C) ((((fix31)A * (fix31)B) + C) >> 16)
+#define ABS(A) ((A < 0)? -A:A) /* absolute value */
+#define IMPORT_FACTOR \
+ shift = 16;\
+ while (*x_factor > (0x7fffffffL / (isw_scale >> (16 - shift))))\
+ shift--;\
+ *x_factor = (*x_factor * (isw_scale>>(16-shift))) >> shift;
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** STATIC FUNCTIONS *****/
+
+static void sp_constr_update(PROTO_DECL1);
+static ufix8 FONTFAR *sp_setup_pix_table(PROTO_DECL2 ufix8 FONTFAR *pointer,boolean short_form,fix15 no_X_ctrl_zones,fix15 no_Y_ctrl_zones);
+static ufix8 FONTFAR *sp_setup_int_table(PROTO_DECL2 ufix8 FONTFAR *pointer,fix15 no_X_int_zones,fix15 no_Y_int_zones);
+
+
+FUNCTION void init_tcb()
+GDECL
+/*
+ * Called by sp_make_char() and make_comp_char() to initialize the current
+ * transformation control block to the top level transformation.
+ */
+{
+sp_globals.tcb = sp_globals.tcb0;
+}
+
+FUNCTION void scale_tcb(
+GDECL
+tcb_t GLOBALFAR *ptcb, /* Transformation control block */
+fix15 x_pos, /* X position (outline res units) */
+fix15 y_pos, /* Y position (outline res units) */
+fix15 x_scale, /* X scale factor * ONE_SCALE */
+fix15 y_scale) /* Y scale factor * ONE_SCALE */
+/*
+ * Called by make_comp_char() to apply position and scale for each of the
+ * components of a compound character.
+ */
+{
+fix15 xx_mult = ptcb->xxmult;
+fix15 xy_mult = ptcb->xymult;
+fix31 x_offset = ptcb->xoffset;
+fix15 yx_mult = ptcb->yxmult;
+fix15 yy_mult = ptcb->yymult;
+fix31 y_offset = ptcb->yoffset;
+
+ptcb->xxmult = TRANS(xx_mult, x_scale, (fix31)SCALE_RND, SCALE_SHIFT);
+ptcb->xymult = TRANS(xy_mult, y_scale, (fix31)SCALE_RND, SCALE_SHIFT);
+ptcb->xoffset = MULT16(xx_mult, x_pos) + MULT16(xy_mult, y_pos) + x_offset;
+ptcb->yxmult = TRANS(yx_mult, x_scale, (fix31)SCALE_RND, SCALE_SHIFT);
+ptcb->yymult = TRANS(yy_mult, y_scale, (fix31)SCALE_RND, SCALE_SHIFT);
+ptcb->yoffset = MULT16(yx_mult, x_pos) + MULT16(yy_mult, y_pos) + y_offset;
+
+type_tcb(ptcb); /* Reclassify transformation types */
+}
+
+FUNCTION ufix8 FONTFAR *skip_interpolation_table(
+GDECL
+ufix8 FONTFAR *pointer, /* Pointer to next byte in char data */
+ufix8 format) /* Character format byte */
+{
+fix15 i,n;
+ufix8 intsize[9];
+
+intsize[0] = 1;
+intsize[1] = 2;
+intsize[2] = 3;
+intsize[3] = 1;
+intsize[4] = 2;
+intsize[5] = 1;
+intsize[6] = 2;
+intsize[7] = 0;
+intsize[8] = 0;
+
+n = ((format & BIT6)? (fix15)NEXT_BYTE(pointer): 0);
+n += ((format & BIT7)? (fix15)NEXT_BYTE(pointer): 0);
+for (i = 0; i < n; i++) /* For each entry in int table ... */
+ {
+ format = NEXT_BYTE(pointer); /* Read format byte */
+ if (format & BIT7) /* Short Start/End point spec? */
+ {
+ pointer++; /* Skip Start/End point byte */
+ }
+ else
+ {
+ pointer += intsize[format & 0x7]; /* Skip Start point spec */
+ pointer += intsize[(format >> 3) & 0x7]; /* Skip End point spec */
+ }
+ }
+return pointer;
+}
+FUNCTION ufix8 FONTFAR *skip_control_zone(
+GDECL
+ufix8 FONTFAR *pointer, /* Pointer to next byte in char data */
+ufix8 format) /* Character format byte */
+{
+fix15 i,n;
+ufix16 tmpufix16;
+
+n = sp_globals.no_X_orus + sp_globals.no_Y_orus - 2;
+for (i = 0; i < n; i++) /* For each entry in control table ... */
+ {
+ if (format & BIT4)
+ pointer++; /* Skip short form From/To fields */
+ else
+ pointer += 2; /* Skip FROM and TO fields */
+ /* skip constraints field */
+ NEXT_BYTES (pointer, tmpufix16);
+
+ }
+return pointer;
+}
+
+#if INCL_RULES
+#else
+FUNCTION ufix8 FONTFAR *plaid_tcb(
+GDECL
+ufix8 FONTFAR *pointer, /* Pointer to next byte in char data */
+ufix8 format) /* Character format byte */
+/*
+ * Called by make_simp_char() and make_comp_char() to set up the controlled
+ * coordinate table and skip all other intelligent scaling rules embedded
+ * in the character data.
+ * Updates pointer to first byte after plaid data.
+ * This is used only if intelligent scaling is not supported in the
+ * configuration definitions.
+ */
+{
+fix15 i, n;
+
+
+
+sp_globals.no_X_orus = (format & BIT2)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+sp_globals.no_Y_orus = (format & BIT3)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+pointer = read_oru_table(pointer); /* Updates no_X/Y/orus */
+sp_globals.Y_edge_org = sp_globals.no_X_orus;
+
+/* Skip over control zone table */
+pointer = skip_control_zone(pointer,format);
+
+/* Skip over interpolation table */
+pointer = skip_interpolation_table(pointer,format);
+return pointer;
+}
+#endif
+
+#if INCL_RULES
+FUNCTION ufix8 FONTFAR *plaid_tcb(
+GDECL
+ufix8 FONTFAR *pointer, /* Pointer to next byte in char data */
+ufix8 format) /* Character format byte */
+/*
+ * Called by make_simp_char() and make_comp_char() to set up the controlled
+ * coordinate table and process all intelligent scaling rules embedded
+ * in the character data.
+ * Updates pointer to first byte after plaid data.
+ * This is used only if intelligent scaling is enabled in the
+ * configuration definitions.
+ */
+{
+fix15 no_X_ctrl_zones;
+fix15 no_Y_ctrl_zones;
+fix15 no_X_int_zones;
+fix15 no_Y_int_zones;
+
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+begin_plaid_data();
+#endif
+
+sp_constr_update(); /* Update constraint table if required */
+
+sp_globals.no_X_orus = (format & BIT2)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+sp_globals.no_Y_orus = (format & BIT3)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+pointer = read_oru_table(pointer); /* Updates no_X/Y/orus to include zero values */
+sp_globals.Y_edge_org = sp_globals.no_X_orus;
+if (sp_globals.no_X_orus > 1) /* 2 or more controlled X coordinates? */
+ sp_globals.tcb.xmode = sp_globals.tcb.xtype; /* Enable intelligent scaling in X */
+
+if (sp_globals.no_Y_orus > 1) /* 2 or more controlled Y coordinates? */
+ sp_globals.tcb.ymode = sp_globals.tcb.ytype; /* Enable intelligent scaling in Y */
+
+no_X_ctrl_zones = sp_globals.no_X_orus - 1;
+no_Y_ctrl_zones = sp_globals.no_Y_orus - 1;
+pointer = sp_setup_pix_table(pointer, (boolean)(format & BIT4),
+ no_X_ctrl_zones, no_Y_ctrl_zones);
+
+no_X_int_zones = (format & BIT6)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+no_Y_int_zones = (format & BIT7)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+sp_globals.Y_int_org = no_X_int_zones;
+pointer = sp_setup_int_table(pointer, no_X_int_zones, no_Y_int_zones);
+
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+end_plaid_data();
+#endif
+
+return pointer;
+}
+#endif
+
+#if INCL_RULES
+FUNCTION static void sp_constr_update()
+GDECL
+/*
+ * Called by plaid_tcb() to update the constraint table for the current
+ * transformation.
+ * This is always carried out whenever a character is generated following
+ * a change of font or scale factor or after initialization.
+ */
+{
+fix31 ppo;
+fix15 xppo;
+fix15 yppo;
+ufix8 FONTFAR *pointer;
+fix15 no_X_constr;
+fix15 no_Y_constr;
+fix15 i, j, k, l, n;
+fix15 ppm;
+ufix8 format;
+ufix8 format1;
+fix15 limit;
+ufix16 constr_org;
+fix15 constr_nr;
+fix15 size;
+fix31 off;
+fix15 min;
+fix15 orus;
+fix15 pix;
+ufix16 tmpufix16; /* in extended mode, macro uses secnd term */
+
+if (sp_globals.constr.data_valid && /* Constr table already done and ... */
+ (sp_globals.tcb.xppo == sp_globals.constr.xppo) && /* ... X pix per oru unchanged and ... */
+ (sp_globals.tcb.yppo == sp_globals.constr.yppo)) /* ... Y pix per oru unchanged? */
+ {
+ return; /* No need to update constraint table */
+ }
+
+sp_globals.constr.xppo = xppo = sp_globals.tcb.xppo; /* Update X pixels per oru indicator */
+sp_globals.constr.yppo = yppo = sp_globals.tcb.yppo; /* Update Y pixels per oru indicator */
+sp_globals.constr.data_valid = TRUE; /* Mark constraint table valid */
+
+pointer = sp_globals.constr.org; /* Point to first byte of constraint data */
+no_X_constr = NEXT_BYTES(pointer, tmpufix16); /* Read nmbr of X constraints */
+no_Y_constr = NEXT_BYTES(pointer, tmpufix16); /* Read nmbr of Y constraints */
+
+i = 0;
+constr_org = 0;
+n = no_X_constr;
+ppo = xppo;
+for (j = 0; ; j++)
+ {
+ sp_globals.c_act[i] = FALSE; /* Flag constraint 0 not active */
+ sp_globals.c_pix[i++] = 0; /* Constraint 0 implies no minimum */
+ sp_globals.c_act[i] = FALSE; /* Flag constraint 1 not active */
+ sp_globals.c_pix[i++] = sp_globals.onepix; /* Constraint 1 implies min 1 pixel*/
+ ppm = (ppo * (fix31)sp_globals.orus_per_em) >> sp_globals.multshift;
+ for (k = 0; k < n; k++)
+ {
+ format = NEXT_BYTE(pointer); /* Read format byte */
+ limit = (fix15)NEXT_BYTE(pointer); /* Read limit field */
+ sp_globals.c_act[i] =
+ ((ppm < limit) || (limit == 255)) &&
+ sp_globals.constr.active;
+ if (sp_globals.c_act[i]) /* Constraint active? */
+ {
+ if ((format & BIT1) && /* Constraint specified and ... */
+ (constr_nr = constr_org +
+ ((format & BIT0)? /* Read unsigned constraint value */
+ NEXT_WORD(pointer):
+ (fix15)NEXT_BYTE(pointer)),
+ sp_globals.c_act[constr_nr])) /* ... and specified constraint active? */
+ {
+ pix = sp_globals.c_pix[constr_nr]; /* Use constrained pixel value */
+ format1 = format;
+ for (l = 2; l > 0; l--) /* Skip 2 arguments */
+ {
+ format1 >>= 2;
+ if ((size = format1 & 0x03))
+ pointer += size - 1;
+ }
+ }
+ else /* Constraint absent or inactive? */
+ {
+ orus = (format & BIT2)? /* Read unsigned oru value */
+ NEXT_WORD(pointer):
+ (fix15)NEXT_BYTE(pointer);
+
+ if (format & BIT5) /* Specified offset value? */
+ {
+ off = (fix31)((format & BIT4)? /* Read offset value */
+ NEXT_WORD(pointer):
+ (fix7)NEXT_BYTE(pointer));
+ off = (off << (sp_globals.multshift - 6)) + sp_globals.multrnd;
+ }
+ else /* Unspecified (zero) offset value? */
+ {
+ off = sp_globals.multrnd;
+ }
+
+ pix = (fix15)(((fix31)orus * ppo + off) / (1 << sp_globals.mpshift)) & sp_globals.pixfix;
+ }
+ }
+ else /* Constraint inactive? */
+ {
+ format1 = format;
+ for (l = 3; l > 0; l--) /* Skip over 3 arguments */
+ {
+ if ((size = format1 & 0x03))
+ pointer += size - 1;
+ format1 >>= 2;
+ }
+ pix = 0;
+ }
+
+ if (format & 0xc0) /* Specified minimum value? */
+ {
+ min = (format & BIT7)? /* Read unsigned minimum value */
+ (fix15)NEXT_BYTE(pointer) << sp_globals.pixshift:
+ sp_globals.onepix;
+ }
+ else /* Unspecified (zero) minimum value? */
+ {
+ min = 0;
+ }
+
+ sp_globals.c_pix[i] = (pix < min)? min: pix;
+ i++;
+ }
+ if (j) break; /* Finished if second time around loop */
+ constr_org = sp_globals.Y_constr_org = i;
+ n = no_Y_constr;
+ ppo = yppo;
+ }
+
+#if DEBUG
+printf("\nCONSTRAINT TABLE\n");
+n = no_X_constr + 2;
+for (i = 0; i < n; i++)
+ {
+ printf("%3d ", i);
+ if (sp_globals.c_act[i])
+ {
+ printf("T ");
+ }
+ else
+ {
+ printf("F ");
+ }
+ printf("%5.1f\n", ((real)sp_globals.c_pix[i] / (real)sp_globals.onepix));
+ }
+printf("--------------\n");
+n = no_Y_constr + 2;
+for (i = 0; i < n; i++)
+ {
+ j = i + sp_globals.Y_constr_org;
+ printf("%3d ", i);
+ if (sp_globals.c_act[j])
+ {
+ printf("T ");
+ }
+ else
+ {
+ printf("F ");
+ }
+ printf("%5.1f\n", ((real)sp_globals.c_pix[j] / (real)sp_globals.onepix));
+ }
+#endif
+
+}
+#endif
+
+FUNCTION ufix8 FONTFAR *read_oru_table(
+GDECL
+ufix8 FONTFAR *pointer) /* Pointer to first byte in controlled coord table */
+/*
+ * Called by plaid_tcb() to read the controlled coordinate table from the
+ * character data in the font.
+ * Updates the pointer to the byte following the controlled coordinate
+ * data.
+ */
+{
+fix15 i, j, k, n;
+boolean zero_not_in;
+boolean zero_added;
+fix15 oru;
+
+#if INCL_RULES
+fix15 pos;
+#endif
+
+i = 0;
+n = sp_globals.no_X_orus;
+#if INCL_RULES
+pos = sp_globals.tcb.xpos;
+#endif
+for (j = 0; ; j++)
+ {
+ zero_not_in = TRUE;
+ zero_added = FALSE;
+ for (k = 0; k < n; k++)
+ {
+ oru = NEXT_WORD(pointer);
+ if (zero_not_in && (oru >= 0)) /* First positive oru value? */
+ {
+#if INCL_RULES
+ sp_plaid.pix[i] = pos; /* Insert position in pix array */
+#endif
+ if (oru != 0) /* Zero oru value omitted? */
+ {
+ sp_plaid.orus[i++] = 0; /* Insert zero value in oru array */
+ zero_added = TRUE; /* Remember to increment size of array */
+ }
+ zero_not_in = FALSE; /* Inhibit further testing for zero ins */
+ }
+ sp_plaid.orus[i++] = oru; /* Add specified oru value to array */
+ }
+ if (zero_not_in) /* All specified oru values negative? */
+ {
+#if INCL_RULES
+ sp_plaid.pix[i] = pos; /* Insert position in pix array */
+#endif
+ sp_plaid.orus[i++] = 0; /* Add zero oru value */
+ zero_added = TRUE; /* Remember to increment size of array */
+ }
+ if (j) /* Both X and Y orus read? */
+ break;
+ if (zero_added)
+ sp_globals.no_X_orus++; /* Increment X array size */
+ n = sp_globals.no_Y_orus; /* Prepare to read Y oru values */
+#if INCL_RULES
+ pos = sp_globals.tcb.ypos;
+#endif
+ }
+if (zero_added) /* Zero Y oru value added to array? */
+ sp_globals.no_Y_orus++; /* Increment Y array size */
+
+#if DEBUG
+printf("\nX ORUS\n");
+n = sp_globals.no_X_orus;
+for (i = 0; i < n; i++)
+ {
+ printf("%2d %4d\n", i, sp_plaid.orus[i]);
+ }
+printf("\nY ORUS\n");
+n = sp_globals.no_Y_orus;
+for (i = 0; i < n; i++)
+ {
+ printf("%2d %4d\n", i, sp_plaid.orus[i + sp_globals.no_X_orus]);
+ }
+#endif
+
+return pointer; /* Update pointer */
+}
+#if INCL_SQUEEZING || INCL_ISW
+FUNCTION static void calculate_x_pix(
+GDECL
+ufix8 start_edge, ufix8 end_edge,
+ufix16 constr_nr,
+fix31 x_scale,
+fix31 x_offset,
+fix31 ppo,
+fix15 setwidth_pix)
+/*
+ * Called by sp_setup_pix_table() when X squeezing is necessary
+ * to insert the correct edge in the global pix array
+ */
+{
+fix15 zone_pix;
+fix15 start_oru, end_oru;
+
+/* compute scaled oru coordinates */
+start_oru= (fix15)(SQUEEZE_X_ORU(sp_plaid.orus[start_edge], x_scale, x_offset));
+end_oru = (fix15)(SQUEEZE_X_ORU(sp_plaid.orus[end_edge], x_scale, x_offset));
+
+if (!sp_globals.c_act[constr_nr]) /* constraint inactive */
+ {
+ /* calculate zone width */
+ zone_pix = (fix15)(((((fix31)end_oru - (fix31)start_oru) * ppo) /
+ (1<<sp_globals.mpshift)) + sp_globals.pixrnd) & sp_globals.pixfix;
+ /* check for overflow */
+ if (((end_oru-start_oru) > 0) && (zone_pix < 0))
+ zone_pix = 0x7ffff;
+ /* check for minimum */
+ if ((ABS(zone_pix)) >= sp_globals.c_pix[constr_nr])
+ goto Lx;
+ }
+/* use the zone size from the constr table - scale it */
+zone_pix = (fix15)(((SQUEEZE_MULT(x_scale,sp_globals.c_pix[constr_nr]))
+ + sp_globals.pixrnd) & sp_globals.pixfix);
+
+/* look for overflow */
+if ((sp_globals.c_pix[constr_nr] > 0) && (zone_pix < 0))
+ zone_pix = 0x7fff;
+
+if (start_edge > end_edge)
+ {
+ zone_pix = -zone_pix;
+ }
+Lx:
+/* assign pixel value to global pix array */
+sp_plaid.pix[end_edge]=sp_plaid.pix[start_edge] + zone_pix;
+
+/* check for overflow */
+if (((sp_plaid.pix[start_edge] >0) && (zone_pix >0)) &&
+ (sp_plaid.pix[end_edge] < 0))
+ sp_plaid.pix[end_edge] = 0x7fff; /* set it to the max */
+
+/* be sure to be in the setwidth !*/
+#if INCL_ISW
+if (!sp_globals.import_setwidth_act) /* only check left edge if not isw only */
+#endif
+if ((sp_globals.pspecs->flags & SQUEEZE_LEFT) && (sp_plaid.pix[end_edge] < 0))
+ sp_plaid.pix[end_edge] = 0;
+if ((sp_globals.pspecs->flags & SQUEEZE_RIGHT) &&
+ (sp_plaid.pix[end_edge] > setwidth_pix))
+ sp_plaid.pix[end_edge] = setwidth_pix;
+
+}
+#endif
+
+#if INCL_SQUEEZING
+FUNCTION static void calculate_y_pix(
+GDECL
+ufix8 start_edge, ufix8 end_edge,
+ufix16 constr_nr,
+fix31 top_scale, fix31 bottom_scale,
+fix31 ppo,
+fix15 em_top_pix, fix15 em_bot_pix)
+
+/*
+ * Called by sp_setup_pix_table() when Y squeezing is necessary
+ * to insert the correct edge in the global pix array
+ */
+{
+fix15 zone_pix;
+fix15 start_oru, end_oru;
+fix31 zone_width, above_base, below_base;
+
+/* check whether edge is above or below the baseline */
+/* and apply appropriate scale factor to get scaled oru coordinates */
+if (sp_plaid.orus[start_edge] < 0)
+ start_oru =(fix15)(SQUEEZE_MULT(sp_plaid.orus[start_edge], bottom_scale));
+else
+ start_oru =(fix15)(SQUEEZE_MULT(sp_plaid.orus[start_edge], top_scale));
+
+if (sp_plaid.orus[end_edge] < 0)
+ end_oru =(fix15)(SQUEEZE_MULT(sp_plaid.orus[end_edge], bottom_scale));
+else
+ end_oru =(fix15)(SQUEEZE_MULT(sp_plaid.orus[end_edge], top_scale));
+
+if (!sp_globals.c_act[constr_nr]) /* Constraint inactive? */
+ {
+ /* calculate zone width */
+ zone_pix = (fix15)(((((fix31)end_oru - (fix31)start_oru) * ppo)
+ >> sp_globals.mpshift)+ sp_globals.pixrnd) & sp_globals.pixfix;
+ /* check minimum */
+ if ((ABS(zone_pix)) >= sp_globals.c_pix[constr_nr])
+ goto Ly;
+ }
+
+/* Use zone size from constr table */
+if ((end_oru >= 0) && (start_oru >=0))
+ /* all above baseline */
+ zone_pix = (fix15)(SQUEEZE_MULT(top_scale, sp_globals.c_pix[constr_nr]));
+else if ((end_oru <= 0) && (start_oru <=0))
+ /* all below baseline */
+ zone_pix = (fix15)(SQUEEZE_MULT(bottom_scale, sp_globals.c_pix[constr_nr]));
+else
+ {
+ /* mixture */
+ if (start_oru > 0)
+ {
+ zone_width = start_oru - end_oru;
+ /* get % above baseline in 16.16 fixed point */
+ above_base = (((fix31)start_oru) << 16) /
+ ((fix31)zone_width) ;
+ /* get % below baseline in 16.16 fixed point */
+ below_base = (((fix31)-end_oru) << 16) /
+ ((fix31)zone_width) ;
+ }
+ else
+ {
+ zone_width = end_oru - start_oru;
+ /* get % above baseline in 16.16 fixed point */
+ above_base = (((fix31)-start_oru) << 16) /
+ ((fix31)zone_width) ;
+ /* get % below baseline in 16.16 fixed point */
+ below_base = (((fix31)end_oru) << 16) /
+ ((fix31)zone_width) ;
+ }
+ /* % above baseline * total zone * top_scale + */
+ /* % below baseline * total zone * bottom_scale */
+ zone_pix = ((((above_base * (fix31)sp_globals.c_pix[constr_nr]) >> 16) *
+ top_scale) +
+ (((below_base * (fix31)sp_globals.c_pix[constr_nr]) >> 16) *
+ bottom_scale)) >> 16;
+ }
+
+/* make this zone pix fall on a pixel boundary */
+zone_pix = (zone_pix + sp_globals.pixrnd) & sp_globals.pixfix;
+
+/* if minimum is in effect make the zone one pixel */
+if ((sp_globals.c_pix[constr_nr] != 0) && (zone_pix < sp_globals.onepix))
+ zone_pix = sp_globals.onepix;
+
+if (start_edge > end_edge)
+ {
+ zone_pix = -zone_pix; /* Use negatve zone size */
+ }
+Ly:
+/* assign global pix value */
+sp_plaid.pix[end_edge] = sp_plaid.pix[start_edge] + zone_pix; /* Insert end pixels */
+
+/* make sure it is in the EM !*/
+if ((sp_globals.pspecs->flags & SQUEEZE_TOP) &&
+ (sp_plaid.pix[end_edge] > em_top_pix))
+ sp_plaid.pix[end_edge] = em_top_pix;
+if ((sp_globals.pspecs->flags & SQUEEZE_BOTTOM) &&
+ (sp_plaid.pix[end_edge] < em_bot_pix))
+ sp_plaid.pix[end_edge] = em_bot_pix;
+}
+
+FUNCTION boolean calculate_x_scale(x_factor, x_offset, no_X_ctrl_zones)
+GDECL
+fix31 *x_factor,
+fix31 *x_offset,
+fix15 no_X_ctrl_zones) /* Number of X control zones */
+/*
+ * Called by sp_setup_pix_table() when squeezing is included
+ * to determine whether X scaling is necessary. If it is, the
+ * scale factor and offset are computed. This function returns
+ * a boolean value TRUE = X squeezind is necessary, FALSE = no
+ * X squeezing is necessary.
+ */
+{
+boolean squeeze_left, squeeze_right;
+boolean out_on_right, out_on_left;
+fix15 bbox_width,set_width;
+fix15 bbox_xmin, bbox_xmax;
+fix15 x_offset_pix;
+fix15 i;
+#if INCL_ISW
+fix31 isw_scale;
+fix15 shift;
+#endif
+
+
+/* set up some flags and common calculations */
+squeeze_left = (sp_globals.pspecs->flags & SQUEEZE_LEFT)? TRUE:FALSE;
+squeeze_right = (sp_globals.pspecs->flags & SQUEEZE_RIGHT)? TRUE:FALSE;
+bbox_xmin = sp_globals.bbox_xmin_orus;
+bbox_xmax = sp_globals.bbox_xmax_orus;
+set_width = sp_globals.setwidth_orus;
+
+if (bbox_xmax > set_width)
+ out_on_right = TRUE;
+else
+ out_on_right = FALSE;
+if (bbox_xmin < 0)
+ out_on_left = TRUE;
+else
+ out_on_left = FALSE;
+bbox_width =bbox_xmax - bbox_xmin;
+
+/*
+ * don't need X squeezing if:
+ * - X squeezing not enabled
+ * - bbox doesn't violate on left or right
+ * - left squeezing only is enabled and char isn't out on left
+ * - right squeezing only is enabled and char isn't out on right
+ */
+
+if ((!squeeze_left && !squeeze_right) ||
+ (!out_on_right && !out_on_left) ||
+ (squeeze_left && !squeeze_right && !out_on_left) ||
+ (squeeze_right && !squeeze_left && !out_on_right))
+ return FALSE;
+
+#if INCL_ISW
+if (sp_globals.import_setwidth_act)
+ {
+ /* if both isw and squeezing is going on - let the imported */
+ /* setwidth factor be factored in with the squeeze */
+ isw_scale = compute_isw_scale();
+ /*sp_globals.setwidth_orus = sp_globals.imported_width;*/
+ }
+else
+ isw_scale = 0x10000L; /* 1 in 16.16 notation */
+#endif
+
+/* squeezing on left and right ? */
+if (squeeze_left && squeeze_right)
+ {
+ /* calculate scale factor */
+ if (bbox_width < set_width)
+ *x_factor = 0x10000L; /* 1 in 16.16 notation */
+ else
+ *x_factor = ((fix31)set_width<<16)/(fix31)bbox_width;
+#if INCL_ISW
+ IMPORT_FACTOR
+#endif
+ /* calculate offset */
+ if (out_on_left) /* fall out on left ? */
+ *x_offset = -(fix31)*x_factor * (fix31)bbox_xmin;
+ /* fall out on right and I am shifting only ? */
+ else if (out_on_right && (*x_factor == 0x10000L))
+ *x_offset = -(fix31)*x_factor * (fix31)(bbox_xmax - set_width);
+ else
+ *x_offset = 0x0L; /* 0 in 16.16 notation */
+ }
+/* squeezing on left only and violates left */
+else if (squeeze_left)
+ {
+ if (bbox_width < set_width) /* will it fit if I shift it ? */
+ *x_factor = 0x10000L; /* 1 in 16.16 notation */
+ else if (out_on_right)
+ *x_factor = ((fix31)set_width<<16)/(fix31)bbox_width;
+ else
+ *x_factor = ((fix31)set_width<<16)/
+ (fix31)(bbox_width - (bbox_xmax-set_width));
+#if INCL_ISW
+ IMPORT_FACTOR
+#endif
+ *x_offset = (fix31)-*x_factor * (fix31)bbox_xmin;
+ }
+
+/* I must be squeezing on right, and violates right */
+else
+ {
+ if (bbox_width < set_width) /* will it fit if I shift it ? */
+ { /* just shift it left - it will fit in the bbox */
+ *x_factor = 0x10000L; /* 1 in 16.16 notation */
+#if INCL_ISW
+ IMPORT_FACTOR
+#endif
+ *x_offset = (fix31)-*x_factor * (fix31)bbox_xmin;
+ }
+ else if (out_on_left)
+ {
+ *x_factor = ((fix31)set_width<<16)/(fix31)bbox_width;
+#if INCL_ISW
+ IMPORT_FACTOR
+#endif
+ *x_offset = 0x0L; /* 0 in 16.16 notation */
+ }
+ else
+ {
+ *x_factor = ((fix31)set_width<<16)/(fix31)bbox_xmax;
+#if INCL_ISW
+ IMPORT_FACTOR
+#endif
+ *x_offset = 0x0L; /* 0 in 16.16 notation */
+ }
+ }
+
+x_offset_pix = (fix15)(((*x_offset >> 16) * sp_globals.tcb0.xppo)
+ / (1<<sp_globals.mpshift));
+
+if ((x_offset_pix >0) && (x_offset_pix < sp_globals.onepix))
+ x_offset_pix = sp_globals.onepix;
+
+/* look for the first non-negative oru value, scale and add the offset */
+/* to the corresponding pixel value - note that the pixel value */
+/* is set in read_oru_table. */
+
+/* look at all the X edges */
+for (i=0; i < (no_X_ctrl_zones+1); i++)
+ if (sp_plaid.orus[i] >= 0)
+ {
+ sp_plaid.pix[i] = (SQUEEZE_MULT(sp_plaid.pix[i], *x_factor)
+ +sp_globals.pixrnd + x_offset_pix) & sp_globals.pixfix;
+ break;
+ }
+
+return TRUE;
+}
+
+FUNCTION boolean calculate_y_scale(
+GDECL
+fix31 *top_scale, fix31 *bottom_scale,
+fix15 first_Y_zone,
+fix15 no_Y_ctrl_zones)
+/*
+ * Called by sp_setup_pix_table() when squeezing is included
+ * to determine whether Y scaling is necessary. If it is,
+ * two scale factors are computed, one for above the baseline,
+ * and one for below the basline.
+ * This function returns a boolean value TRUE = Y squeezind is necessary,
+ * FALSE = no Y squeezing is necessary.
+ */
+{
+boolean squeeze_top, squeeze_bottom;
+boolean out_on_top, out_on_bottom;
+fix15 bbox_top, bbox_bottom;
+fix15 bbox_height;
+fix15 i;
+
+/* set up some flags and common calculations */
+squeeze_top = (sp_globals.pspecs->flags & SQUEEZE_TOP)? TRUE:FALSE;
+squeeze_bottom = (sp_globals.pspecs->flags & SQUEEZE_BOTTOM)? TRUE:FALSE;
+bbox_top = sp_globals.bbox_ymax_orus;
+bbox_bottom = sp_globals.bbox_ymin_orus;
+bbox_height = bbox_top - bbox_bottom;
+
+if (bbox_top > EM_TOP)
+ out_on_top = TRUE;
+else
+ out_on_top = FALSE;
+
+if (bbox_bottom < EM_BOT)
+ out_on_bottom = TRUE;
+else
+ out_on_bottom = FALSE;
+
+/*
+ * don't need Y squeezing if:
+ * - Y squeezing not enabled
+ * - bbox doesn't violate on top or bottom
+ * - top squeezing only is enabled and char isn't out on top
+ * - bottom squeezing only is enabled and char isn't out on bottom
+ */
+if ((!squeeze_top && !squeeze_bottom) ||
+ (!out_on_top && !out_on_bottom) ||
+ (squeeze_top && !squeeze_bottom && !out_on_top) ||
+ (squeeze_bottom && !squeeze_top && !out_on_bottom))
+ return FALSE;
+
+if (squeeze_top && (bbox_top > EM_TOP))
+ *top_scale = ((fix31)EM_TOP << 16)/(fix31)(bbox_top);
+else
+ *top_scale = 0x10000L; /* 1 in 16.16 fixed point */
+
+if (squeeze_bottom && (bbox_bottom < EM_BOT))
+ *bottom_scale = ((fix31)-(EM_BOT) << 16)/(fix31)-bbox_bottom;
+else
+ *bottom_scale = 0x10000L;
+
+if (sp_globals.squeezing_compound)
+ {
+ for (i=first_Y_zone; i < (first_Y_zone + no_Y_ctrl_zones + 1); i++)
+ {
+ if (sp_plaid.orus[i] >= 0)
+ sp_plaid.pix[i] = (SQUEEZE_MULT(sp_plaid.pix[i], *top_scale)
+ +sp_globals.pixrnd) & sp_globals.pixfix;
+ else
+ sp_plaid.pix[i] = (SQUEEZE_MULT(sp_plaid.pix[i], *bottom_scale)
+ +sp_globals.pixrnd) & sp_globals.pixfix;
+ }
+ }
+return TRUE;
+}
+#endif
+
+#if INCL_RULES
+FUNCTION static ufix8 FONTFAR *sp_setup_pix_table(
+GDECL
+ufix8 FONTFAR *pointer, /* Pointer to first byte in control zone table */
+boolean short_form, /* TRUE if 1 byte from/to specification */
+fix15 no_X_ctrl_zones, /* Number of X control zones */
+fix15 no_Y_ctrl_zones) /* Number of Y control zones */
+/*
+ * Called by plaid_tcb() to read the control zone table from the
+ * character data in the font.
+ * Sets up a table of pixel values for all controlled coordinates.
+ * Updates the pointer to the byte following the control zone
+ * data.
+ */
+{
+fix15 i, j, n;
+fix31 ppo;
+#if INCL_SQUEEZING || INCL_ISW
+fix31 xppo0; /* top level pixels per oru */
+fix31 yppo0; /* top level pixels per oru */
+#endif
+ufix8 edge_org;
+ufix8 edge;
+ufix8 start_edge;
+ufix8 end_edge;
+ufix16 constr_org;
+fix15 constr_nr;
+fix15 zone_pix;
+fix31 whole_zone; /* non-transformed value of the first X zone */
+ufix16 tmpufix16; /* in extended mode, macro uses secnd term */
+#if INCL_SQUEEZING
+fix31 x_scale;
+fix31 y_top_scale, y_bottom_scale;
+fix31 x_offset;
+boolean squeezed_y;
+fix15 setwidth_pix, em_top_pix, em_bot_pix;
+#endif
+
+#if INCL_ISW
+boolean imported_width;
+fix31 isw_scale;
+fix15 isw_setwidth_pix;
+#endif
+
+#if INCL_ISW || INCL_SQUEEZING
+boolean squeezed_x;
+#endif
+
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+begin_ctrl_zones(no_X_ctrl_zones, no_Y_ctrl_zones);
+#endif
+
+
+edge_org = 0;
+constr_org = 0;
+sp_globals.rnd_xmin = 0; /* initialize the error for chars with no zone */
+n = no_X_ctrl_zones;
+ppo = sp_globals.tcb.xppo;
+#if INCL_SQUEEZING || INCL_ISW
+xppo0 = sp_globals.tcb0.xppo;
+yppo0 = sp_globals.tcb0.yppo;
+squeezed_x = FALSE;
+#endif
+
+#if INCL_SQUEEZING
+squeezed_x = calculate_x_scale (&x_scale, &x_offset, no_X_ctrl_zones);
+squeezed_y = calculate_y_scale(&y_top_scale,&y_bottom_scale,(n+1),
+ no_Y_ctrl_zones);
+#if INCL_ISW
+if (sp_globals.import_setwidth_act == TRUE)
+setwidth_pix = ((fix15)(((fix31)sp_globals.imported_width * xppo0) >>
+ sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+
+else
+#endif
+setwidth_pix = ((fix15)(((fix31)sp_globals.setwidth_orus * xppo0) >>
+ sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+/* check for overflow */
+if (setwidth_pix < 0)
+ setwidth_pix = 0x7fff; /* set to maximum */
+em_bot_pix = ((fix15)(((fix31)EM_BOT * yppo0) >>
+ sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+em_top_pix = ((fix15)(((fix31)EM_TOP * yppo0) >>
+ sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+#endif
+
+#if INCL_ISW
+/* convert to pixels */
+isw_setwidth_pix = ((fix15)(((fix31)sp_globals.imported_width * xppo0) >>
+ sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+/* check for overflow */
+if (isw_setwidth_pix < 0)
+ isw_setwidth_pix = 0x7fff; /* set to maximum */
+if (!squeezed_x && ((imported_width = sp_globals.import_setwidth_act) == TRUE))
+ {
+ isw_scale = compute_isw_scale();
+
+ /* look for the first non-negative oru value, scale and add the offset */
+ /* to the corresponding pixel value - note that the pixel value */
+ /* is set in read_oru_table. */
+
+ /* look at all the X edges */
+ for (i=0; i < (no_X_ctrl_zones+1); i++)
+ if (sp_plaid.orus[i] >= 0)
+ {
+ sp_plaid.pix[i] = (SQUEEZE_MULT(sp_plaid.pix[i], isw_scale)
+ +sp_globals.pixrnd) & sp_globals.pixfix;
+ break;
+ }
+
+ }
+#endif
+
+for (i = 0; ; i++) /* For X and Y control zones... */
+ {
+ for (j = 0; j < n; j++) /* For each zone in X or Y... */
+ {
+ if (short_form) /* 1 byte from/to specification? */
+ {
+ edge = NEXT_BYTE(pointer); /* Read packed from/to spec */
+ start_edge = edge_org + (edge & 0x0f); /* Extract start edge */
+ end_edge = edge_org + (edge >> 4); /* Extract end edge */
+ }
+ else /* 2 byte from/to specification? */
+ {
+ start_edge = edge_org + NEXT_BYTE(pointer); /* Read start edge */
+ end_edge = edge_org + NEXT_BYTE(pointer); /* read end edge */
+ }
+ constr_nr = constr_org +
+ NEXT_BYTES(pointer, tmpufix16); /* Read constraint number */
+#if INCL_SQUEEZING
+ if (i == 0 && squeezed_x)
+ calculate_x_pix(start_edge, end_edge, constr_nr,
+ x_scale, x_offset, ppo, setwidth_pix);
+ else if (i == 1 && squeezed_y)
+ calculate_y_pix(start_edge, end_edge,constr_nr,
+ y_top_scale, y_bottom_scale, ppo, em_top_pix, em_bot_pix);
+ else
+ {
+#endif
+#if INCL_ISW
+ if (i==0 && imported_width)
+ calculate_x_pix(start_edge, end_edge, constr_nr,
+ isw_scale, 0, ppo, isw_setwidth_pix);
+ else
+ {
+#endif
+ if (!sp_globals.c_act[constr_nr]) /* Constraint inactive? */
+ {
+ zone_pix = ((fix15)((((fix31)sp_plaid.orus[end_edge] -
+ (fix31)sp_plaid.orus[start_edge]) * ppo) /
+ (1<<sp_globals.mpshift)) + sp_globals.pixrnd) &
+ sp_globals.pixfix;
+ if ((ABS(zone_pix)) >= sp_globals.c_pix[constr_nr])
+ goto L1;
+ }
+ zone_pix = sp_globals.c_pix[constr_nr]; /* Use zone size from constr table */
+ if (start_edge > end_edge) /* sp_plaid.orus[start_edge] > sp_plaid.orus[end_edge]? */
+ {
+ zone_pix = -zone_pix; /* Use negatve zone size */
+ }
+ L1:
+ /* inter-character spacing fix */
+ if ((j == 0) && (i == 0)) /* if this is the 1st X zone, save rounding error */
+ { /* get the non-xformed - xformed zone, in right direction */
+ whole_zone = (((fix31)sp_plaid.orus[end_edge] -
+ (fix31)sp_plaid.orus[start_edge]) *
+ ppo) / (1<<sp_globals.mpshift);
+ sp_globals.rnd_xmin = whole_zone - zone_pix;
+ }
+ sp_plaid.pix[end_edge] = sp_plaid.pix[start_edge] + zone_pix; /* Insert end pixels */
+#if INCL_SQUEEZING
+ if (i == 0) /* in the x direction */
+ { /* brute force squeeze */
+ if ((sp_globals.pspecs->flags & SQUEEZE_LEFT) &&
+ (sp_plaid.pix[end_edge] < 0))
+ sp_plaid.pix[end_edge] = 0;
+ if ((sp_globals.pspecs->flags & SQUEEZE_RIGHT) &&
+ (sp_plaid.pix[end_edge] > setwidth_pix))
+ sp_plaid.pix[end_edge] = setwidth_pix;
+ }
+ if (i == 1) /* in the y direction */
+ { /* brute force squeeze */
+ if ((sp_globals.pspecs->flags & SQUEEZE_TOP) &&
+ (sp_plaid.pix[end_edge] > em_top_pix))
+ sp_plaid.pix[end_edge] = em_top_pix;
+ if ((sp_globals.pspecs->flags & SQUEEZE_BOTTOM) &&
+ (sp_plaid.pix[end_edge] < em_bot_pix))
+ sp_plaid.pix[end_edge] = em_bot_pix;
+ }
+#endif
+#if INCL_SQUEEZING
+ }
+#endif
+#if INCL_ISW
+ }
+#endif
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+ record_ctrl_zone(
+ (fix31)sp_plaid.pix[start_edge] << (16 - sp_globals.pixshift),
+ (fix31)sp_plaid.pix[end_edge] << (16 - sp_globals.pixshift),
+ (fix15)(constr_nr - constr_org));
+#endif
+ }
+ if (i) /* Y pixels done? */
+ break;
+ edge_org = sp_globals.Y_edge_org; /* Prepare to process Y ctrl zones */
+ constr_org = sp_globals.Y_constr_org;
+ n = no_Y_ctrl_zones;
+ ppo = sp_globals.tcb.yppo;
+ }
+
+#if DEBUG
+printf("\nX PIX TABLE\n");
+n = no_X_ctrl_zones + 1;
+for (i = 0; i < n; i++)
+ printf("%2d %6.1f\n", i, (real)sp_plaid.pix[i] / (real)sp_globals.onepix);
+printf("\nY PIX TABLE\n");
+n = no_Y_ctrl_zones + 1;
+for (i = 0; i < n; i++)
+ {
+ j = i + no_X_ctrl_zones + 1;
+ printf("%2d %6.1f\n", i, (real)sp_plaid.pix[j] / (real)sp_globals.onepix);
+ }
+#endif
+
+return pointer;
+}
+#endif
+
+
+#if INCL_RULES
+FUNCTION static ufix8 FONTFAR *sp_setup_int_table(
+GDECL
+ufix8 FONTFAR *pointer, /* Pointer to first byte in interpolation zone table */
+fix15 no_X_int_zones, /* Number of X interpolation zones */
+fix15 no_Y_int_zones) /* Number of X interpolation zones */
+/*
+ * Called by plaid_tcb() to read the interpolation zone table from the
+ * character data in the font.
+ * Sets up a table of interpolation coefficients with one entry for
+ * every X or Y interpolation zone.
+ * Updates the pointer to the byte following the interpolation zone
+ * data.
+ */
+{
+fix15 i, j, k, l, n;
+ufix8 format;
+ufix8 format_copy;
+ufix8 tmpufix8;
+fix15 start_orus = 0;
+ufix8 edge_org;
+ufix8 edge;
+ufix16 adj_factor;
+fix15 adj_orus;
+fix15 end_orus = 0;
+fix31 zone_orus;
+fix15 start_pix = 0;
+fix15 end_pix = 0;
+
+
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+begin_int_zones(no_X_int_zones, no_Y_int_zones);
+#endif
+
+i = 0;
+edge_org = 0;
+n = no_X_int_zones;
+for (j = 0; ; j++)
+ {
+ for (k = 0; k < n; k++)
+ {
+ format = NEXT_BYTE(pointer);
+ if (format & BIT7) /* Short start/end point spec? */
+ {
+ tmpufix8 = NEXT_BYTE(pointer);
+ edge = edge_org + (tmpufix8 & 0xf);
+ start_orus = sp_plaid.orus[edge];
+ start_pix = sp_plaid.pix[edge];
+ edge = edge_org + (tmpufix8 >> 4);
+ end_orus = sp_plaid.orus[edge];
+ end_pix = sp_plaid.pix[edge];
+ }
+ else /* Standard start and end point spec? */
+ {
+ format_copy = format;
+ for (l = 0; ; l++) /* Loop for start and end point */
+ {
+ switch (format_copy & 0x7) /* Decode start/end point format */
+ {
+
+ case 0: /* Index to control edge */
+ edge = edge_org + NEXT_BYTE(pointer);
+ end_orus = sp_plaid.orus[edge];
+ end_pix = sp_plaid.pix[edge];
+ break;
+
+ case 1: /* 1 byte fractional distance to next edge */
+ adj_factor = 0xffff & NEXT_BYTE(pointer) << 8;
+ goto L1;
+
+
+ case 2: /* 2 byte fractional distance to next edge */
+ adj_factor = 0xffff & NEXT_WORD(pointer);
+ L1: edge = edge_org + NEXT_BYTE(pointer);
+ end_orus = sp_plaid.orus[edge] +
+ ((((fix31)sp_plaid.orus[edge + 1] - (fix31)sp_plaid.orus[edge]) *
+ (ufix32)adj_factor + (fix31)32768) >> 16);
+ end_pix = sp_plaid.pix[edge] +
+ ((((fix31)sp_plaid.pix[edge + 1] - (fix31)sp_plaid.pix[edge]) *
+ (ufix32)adj_factor + (fix31)32768) >> 16);
+ break;
+
+ case 3: /* 1 byte delta orus before first edge */
+ adj_orus = -(fix15)NEXT_BYTE(pointer);
+ goto L2;
+
+ case 4: /* 2 byte delta orus before first edge */
+ adj_orus = -NEXT_WORD(pointer);
+ L2: edge = edge_org;
+ goto L4;
+
+ case 5: /* 1 byte delta orus after last edge */
+ adj_orus = (fix15)NEXT_BYTE(pointer);
+ goto L3;
+
+ case 6: /* 2 byte delta orus after last edge */
+ adj_orus = NEXT_WORD(pointer);
+ L3: edge = j? sp_globals.Y_edge_org + sp_globals.no_Y_orus - 1: sp_globals.no_X_orus - 1;
+ L4: end_orus = sp_plaid.orus[edge] + adj_orus;
+ end_pix = sp_plaid.pix[edge] +
+ (((fix31)adj_orus * (fix31)(j? sp_globals.tcb.yppo: sp_globals.tcb.xppo) +
+ sp_globals.mprnd) / (1<<sp_globals.mpshift));
+ break;
+
+ }
+
+ if (l) /* Second time round loop? */
+ break;
+ format_copy >>= 3; /* Adj format to decode end point format */
+ start_orus = end_orus; /* Save start point oru value */
+ start_pix = end_pix; /* Save start point pixel value */
+ }
+ }
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+ record_int_zone(
+ (fix31)start_pix << (16 - sp_globals.pixshift),
+ (fix31)end_pix << (16 - sp_globals.pixshift));
+#endif
+ zone_orus = (fix31)end_orus - (fix31)start_orus;
+ sp_plaid.mult[i] = ((((fix31)end_pix - (fix31)start_pix) << sp_globals.mpshift) +
+ (zone_orus / 2)) / zone_orus;
+ sp_plaid.offset[i] =
+ (((((fix31)start_pix + (fix31)end_pix) << sp_globals.mpshift) -
+ ((fix31)sp_plaid.mult[i] * ((fix31)start_orus + (fix31)end_orus))) / 2) +
+ sp_globals.mprnd;
+ i++;
+ }
+ if (j) /* Finished? */
+ break;
+ edge_org = sp_globals.Y_edge_org; /* Prepare to process Y ctrl zones */
+ n = no_Y_int_zones;
+ }
+
+#if DEBUG
+printf("\nX INT TABLE\n");
+n = no_X_int_zones;
+for (i = 0; i < n; i++)
+ {
+ printf("%2d %7.4f %7.4f\n", i,
+ (real)sp_plaid.mult[i] / (real)(1 << sp_globals.multshift),
+ (real)sp_plaid.offset[i] / (real)(1 << sp_globals.multshift));
+ }
+printf("\nY INT TABLE\n");
+n = no_Y_int_zones;
+for (i = 0; i < n; i++)
+ {
+ j = i + no_X_int_zones;
+ printf("%2d %7.4f %7.4f\n", i,
+ (real)sp_plaid.mult[j] / (real)(1 << sp_globals.multshift),
+ (real)sp_plaid.offset[j] / (real)(1 << sp_globals.multshift));
+ }
+#endif
+
+return pointer;
+}
+#endif
+#if INCL_ISW
+FUNCTION fix31 compute_isw_scale()
+GDECL
+{
+fix31 isw_scale;
+
+if (sp_globals.setwidth_orus == 0)
+ isw_scale = 0x00010000;
+else
+ isw_scale = ((fix31)sp_globals.imported_width << 16)/
+ (fix31)sp_globals.setwidth_orus;
+return isw_scale;
+}
+#endif
diff --git a/nx-X11/lib/font/Speedo/spdo_prv.h b/nx-X11/lib/font/Speedo/spdo_prv.h
new file mode 100644
index 000000000..162c0fddd
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/spdo_prv.h
@@ -0,0 +1,421 @@
+/* $Xorg: spdo_prv.h,v 1.3 2000/08/17 19:46:27 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/spdo_prv.h,v 1.4 1999/03/14 03:21:17 dawes Exp $ */
+
+
+
+/***************************** S P D O _ P R V . H *******************************/
+
+#include "speedo.h" /* include public definitions */
+
+/***** CONFIGURATION DEFINITIONS *****/
+
+
+/***** PRIVATE FONT HEADER OFFSET CONSTANTS *****/
+#define FH_ORUMX 0 /* U Max ORU value 2 bytes */
+#define FH_PIXMX 2 /* U Max Pixel value 2 bytes */
+#define FH_CUSNR 4 /* U Customer Number 2 bytes */
+#define FH_OFFCD 6 /* E Offset to Char Directory 3 bytes */
+#define FH_OFCNS 9 /* E Offset to Constraint Data 3 bytes */
+#define FH_OFFTK 12 /* E Offset to Track Kerning 3 bytes */
+#define FH_OFFPK 15 /* E Offset to Pair Kerning 3 bytes */
+#define FH_OCHRD 18 /* E Offset to Character Data 3 bytes */
+#define FH_NBYTE 21 /* E Number of Bytes in File 3 bytes */
+
+
+/***** MODE FLAGS CONSTANTS *****/
+#define CURVES_OUT 0X0008 /* Output module accepts curves */
+#define BOGUS_MODE 0X0010 /* Linear scaling mode */
+#define CONSTR_OFF 0X0020 /* Inhibit constraint table */
+#define IMPORT_WIDTHS 0X0040 /* Imported width mode */
+#define SQUEEZE_LEFT 0X0100 /* Squeeze left mode */
+#define SQUEEZE_RIGHT 0X0200 /* Squeeze right mode */
+#define SQUEEZE_TOP 0X0400 /* Squeeze top mode */
+#define SQUEEZE_BOTTOM 0X0800 /* Squeeze bottom mode */
+#define CLIP_LEFT 0X1000 /* Clip left mode */
+#define CLIP_RIGHT 0X2000 /* Clip right mode */
+#define CLIP_TOP 0X4000 /* Clip top mode */
+#define CLIP_BOTTOM 0X8000 /* Clip bottom mode */
+
+
+/***** MACRO DEFINITIONS *****/
+
+#define SQUEEZE_MULT(A,B) (((fix31)A * (fix31)B) / (1 << 16))
+
+#define NEXT_BYTE(A) (*(A)++)
+
+#define NEXT_WORD(A) \
+ ((fix15)(sp_globals.key32 ^ ((A) += 2, \
+ ((fix15)((A)[-1]) << 8) | (fix15)((A)[-2]) | \
+ ((A)[-1] & 0x80? ~0xFFFF : 0))))
+
+#if INCL_EXT /* Extended fonts supported? */
+
+#define NEXT_BYTES(A, B) \
+ (((B = (ufix16)(*(A)++) ^ sp_globals.key7) >= 248)? \
+ ((ufix16)(B & 0x07) << 8) + ((*(A)++) ^ sp_globals.key8) + 248: \
+ B)
+
+#else /* Compact fonts only supported? */
+
+#define NEXT_BYTES(A, B) ((*(A)++) ^ sp_globals.key7)
+
+#endif
+
+
+#define NEXT_BYTE_U(A) (*(A)++)
+
+#define NEXT_WORD_U(A, B) \
+ (fix15)(B = (*(A)++) << 8, (fix15)(*(A)++) + B)
+
+#define NEXT_CHNDX(A, B) \
+ ((B)? (ufix16)NEXT_WORD(A): (ufix16)NEXT_BYTE(A))
+
+/* Multiply (fix15)X by (fix15)Y to produce (fix31)product */
+#define MULT16(X, Y) \
+ ((fix31)X * (fix31)Y)
+
+/* Multiply (fix15)X by (fix15)MULT, add (fix31)OFFSET,
+ * shift right SHIFT bits to produce (fix15)result */
+#define TRANS(X, MULT, OFFSET, SHIFT) \
+ ((fix15)((((fix31)X * (fix31)MULT) + OFFSET) / (1 << SHIFT)))
+
+/******************************************************************************
+ *
+ * the following block of definitions redefines every function
+ * reference to be prefixed with an "sp_". In addition, if this
+ * is a reentrant version, the parameter sp_globals will be added
+ * as the first parameter.
+ *
+ *****************************************************************************/
+
+#if STATIC_ALLOC || DYNAMIC_ALLOC
+
+#define GDECL
+
+#define get_char_id(char_index) sp_get_char_id(char_index)
+#define get_char_width(char_index) sp_get_char_width(char_index)
+#define get_track_kern(track,point_size) sp_get_track_kern(track,point_size)
+#define get_pair_kern(char_index1,char_index2) sp_get_pair_kern(char_index1,char_index2)
+#define get_char_bbox(char_index,bbox) sp_get_char_bbox(char_index,bbox)
+#define make_char(char_index) sp_make_char(char_index)
+#if INCL_ISW
+#define compute_isw_scale() sp_compute_isw_scale()
+#define do_make_char(char_index) sp_do_make_char(char_index)
+#define make_char_isw(char_index,imported_width) sp_make_char_isw(char_index,imported_width)
+#define reset_xmax(xmax) sp_reset_xmax(xmax)
+#endif
+#if INCL_ISW || INCL_SQUEEZING
+#define preview_bounding_box(pointer,format) sp_preview_bounding_box(pointer,format)
+#endif
+#define make_simp_char(pointer,format) sp_make_simp_char(pointer,format)
+#define make_comp_char(pointer) sp_make_comp_char(pointer)
+#define get_char_org(char_index,top_level) sp_get_char_org(char_index,top_level)
+#define get_posn_arg(ppointer,format) sp_get_posn_arg(ppointer,format)
+#define get_scale_arg(ppointer,format) sp_get_scale_arg(ppointer,format)
+#define read_bbox(ppointer,pPmin,pPmax,set_flag) sp_read_bbox(ppointer,pPmin,pPmax,set_flag)
+#define proc_outl_data(pointer) sp_proc_outl_data(pointer)
+#define split_curve(P1,P2,P3,depth) sp_split_curve(P1,P2,P3,depth)
+#define get_args(ppointer,format,pP) sp_get_args(ppointer,format,pP)
+
+#define init_black(specsarg) sp_init_black(specsarg)
+#define begin_char_black(Psw,Pmin,Pmax) sp_begin_char_black(Psw,Pmin,Pmax)
+#define begin_contour_black(P1,outside) sp_begin_contour_black(P1,outside)
+#define line_black(P1) sp_line_black(P1)
+#define end_char_black() sp_end_char_black()
+#define add_intercept_black(y,x) sp_add_intercept_black(y,x)
+#define proc_intercepts_black() sp_proc_intercepts_black()
+
+#define init_screen(specsarg) sp_init_screen(specsarg)
+#define begin_char_screen(Psw,Pmin,Pmax) sp_begin_char_screen(Psw,Pmin,Pmax)
+#define begin_contour_screen(P1,outside) sp_begin_contour_screen(P1,outside)
+#define curve_screen(P1,P2,P3,depth) sp_curve_screen(P1,P2,P3,depth)
+#define scan_curve_screen(X0,Y0,X1,Y1,X2,Y2,X3,Y3) sp_scan_curve_screen(X0,Y0,X1,Y1,X2,Y2,X3,Y3)
+#define vert_line_screen(x,y1,y2) sp_vert_line_screen(x,y1,y2)
+#define line_screen(P1) sp_line_screen(P1)
+#define end_contour_screen() sp_end_contour_screen()
+#define end_char_screen() sp_end_char_screen()
+#define add_intercept_screen(y,x) sp_add_intercept_screen(y,x)
+#define proc_intercepts_screen() sp_proc_intercepts_screen()
+
+#define init_outline(specsarg) sp_init_outline(specsarg)
+#define begin_char_outline(Psw,Pmin,Pmax) sp_begin_char_outline(Psw,Pmin,Pmax)
+#define begin_sub_char_outline(Psw,Pmin,Pmax) sp_begin_sub_char_outline(Psw,Pmin,Pmax)
+#define begin_contour_outline(P1,outside) sp_begin_contour_outline(P1,outside)
+#define curve_outline(P1,P2,P3,depth) sp_curve_outline(P1,P2,P3,depth)
+#define line_outline(P1) sp_line_outline(P1)
+#define end_contour_outline() sp_end_contour_outline()
+#define end_sub_char_outline() sp_end_sub_char_outline()
+#define end_char_outline() sp_end_char_outline()
+
+#define init_2d(specsarg) sp_init_2d(specsarg)
+#define begin_char_2d(Psw, Pmin, Pmax) sp_begin_char_2d(Psw, Pmin, Pmax)
+#define begin_contour_2d(P1, outside) sp_begin_contour_2d(P1, outside)
+#define line_2d(P1) sp_line_2d(P1)
+#define end_char_2d() sp_end_char_2d()
+#define add_intercept_2d(y, x) sp_add_intercept_2d(y, x)
+#define proc_intercepts_2d() sp_proc_intercepts_2d()
+#define draw_vector_to_2d(x0, y0, x1, y1, band) sp_draw_vector_to_2d(x0, y0, x1, y1, band)
+
+#define init_char_out(Psw,Pmin,Pmax) sp_init_char_out(Psw,Pmin,Pmax)
+#define begin_sub_char_out(Psw,Pmin,Pmax) sp_begin_sub_char_out(Psw,Pmin,Pmax)
+#define curve_out(P1,P2,P3,depth) sp_curve_out(P1,P2,P3,depth)
+#define end_contour_out() sp_end_contour_out()
+#define end_sub_char_out() sp_end_sub_char_out()
+#define init_intercepts_out() sp_init_intercepts_out()
+#define restart_intercepts_out() sp_restart_intercepts_out()
+#define set_first_band_out(Pmin,Pmax) sp_set_first_band_out(Pmin,Pmax)
+#define reduce_band_size_out() sp_reduce_band_size_out()
+#define next_band_out() sp_next_band_out()
+
+#define init_userout(specsarg) sp_init_userout(specsarg)
+
+#define reset() sp_reset()
+#define set_key(key) sp_set_key(key)
+#define get_cust_no(font_buff) sp_get_cust_no(font_buff)
+#define set_specs(specsarg) sp_set_specs(specsarg)
+#define setup_consts(xmin,xmax,ymin,ymax) sp_setup_consts(xmin,xmax,ymin,ymax)
+#define setup_tcb(ptcb) sp_setup_tcb(ptcb)
+#define setup_mult(input_mult) sp_setup_mult(input_mult)
+#define setup_offset(input_offset) sp_setup_offset(input_offset)
+#define type_tcb(ptcb) sp_type_tcb(ptcb)
+#define read_long(pointer) sp_read_long(pointer)
+#define read_word_u(pointer) sp_read_word_u(pointer)
+#define init_tcb() sp_init_tcb()
+#define scale_tcb(ptcb,x_pos,y_pos,x_scale,y_scale) sp_scale_tcb(ptcb,x_pos,y_pos,x_scale,y_scale)
+#define plaid_tcb(ppointer,format) sp_plaid_tcb(ppointer,format)
+#define skip_orus(ppointer,short_form,no_ctrl_zones) sp_skip_orus(ppointer,short_form,no_ctrl_zones)
+#define skip_interpolation_table(ppointer,format) sp_skip_interpolation_table(ppointer,format)
+#define skip_control_zone(ppointer,format) sp_skip_control_zone(ppointer,format)
+#define constr_update() sp_constr_update()
+#define read_oru_table(ppointer) sp_read_oru_table(ppointer)
+#define calculate_x_pix(start_edge,end_edge,constr_nr,x_scale,x_offset,ppo,setwidth_pix) sp_calculate_x_pix(start_edge,end_edge,constr_nr,x_scale,x_offset,ppo,setwidth_pix)
+#define calculate_y_pix(start_edge,end_edge,constr_nr,top_scale,bottom_scale,ppo,emtop_pix,embot_pix) sp_calculate_y_pix(start_edge,end_edge,constr_nr,top_scale,bottom_scale,ppo,emtop_pix,embot_pix)
+#define calculate_x_scale(x_factor,x_offset,no_x_ctrl_zones) sp_calculate_x_scale(x_factor,x_offset,no_x_ctrl_zones)
+#define calculate_y_scale(top_scale,bottom_scale,first_y_zone,no_Y_ctrl_zones) sp_calculate_y_scale(top_scale,bottom_scale,first_y_zone,no_Y_ctrl_zones)
+#define setup_pix_table(ppointer,short_form,no_X_ctrl_zones,no_Y_ctrl_zones) sp_setup_pix_table(ppointer,short_form,no_X_ctrl_zones,no_Y_ctrl_zones)
+#define setup_int_table(ppointer,no_X_int_zones, no_Y_int_zones) sp_setup_int_table(ppointer,no_X_int_zones, no_Y_int_zones)
+
+#define fn_init_out(specsarg) (*sp_globals.init_out)(specsarg)
+#define fn_begin_char(Psw,Pmin,Pmax) (*sp_globals.begin_char)(Psw,Pmin,Pmax)
+#define fn_begin_sub_char(Psw,Pmin,Pmax) (*sp_globals.begin_sub_char)(Psw,Pmin,Pmax)
+#define fn_end_sub_char() (*sp_globals.end_sub_char)()
+#define fn_end_char() (*sp_globals.end_char)()
+#define fn_line(P1) (*sp_globals.line)(P1)
+#define fn_end_contour() (*sp_globals.end_contour)()
+#define fn_begin_contour(P0,fmt) (*sp_globals.begin_contour)(P0,fmt)
+#define fn_curve(P1,P2,P3,depth) (*sp_globals.curve)(P1,P2,P3,depth)
+
+#define load_char_data(offset, no_bytes, buff_off) sp_load_char_data(offset, no_bytes, buff_off)
+#define report_error(n) sp_report_error(n)
+
+#if INCL_MULTIDEV
+
+#define set_bitmap_device(bfuncs,size) sp_set_bitmap_device(bfuncs,size)
+#define set_outline_device(ofuncs,size) sp_set_outline_device(ofuncs,size)
+
+#define open_bitmap(x_set_width, y_set_width, xmin, xmax, ymin, ymax) (*sp_globals.bitmap_device.p_open_bitmap)(x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define set_bitmap_bits(y, xbit1, xbit2) (*sp_globals.bitmap_device.p_set_bits)(y, xbit1, xbit2)
+#define close_bitmap() (*sp_globals.bitmap_device.p_close_bitmap)()
+
+#define open_outline(x_set_width, y_set_width, xmin, xmax, ymin, ymax) (*sp_globals.outline_device.p_open_outline)(x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define start_new_char() (*sp_globals.outline_device.p_start_char)()
+#define start_contour(x,y,outside) (*sp_globals.outline_device.p_start_contour)(x,y,outside)
+#define curve_to(x1,y1,x2,y2,x3,y3) (*sp_globals.outline_device.p_curve)(x1,y1,x2,y2,x3,y3)
+#define line_to(x,y) (*sp_globals.outline_device.p_line)(x,y)
+#define close_contour() (*sp_globals.outline_device.p_close_contour)()
+#define close_outline() (*sp_globals.outline_device.p_close_outline)()
+
+#else
+
+#define open_bitmap(x_set_width, y_set_width, xmin, xmax, ymin, ymax) sp_open_bitmap(x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define set_bitmap_bits(y, xbit1, xbit2) sp_set_bitmap_bits(y, xbit1, xbit2)
+#define close_bitmap() sp_close_bitmap()
+
+#define open_outline(x_set_width, y_set_width, xmin, xmax, ymin, ymax) sp_open_outline(x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define start_new_char() sp_start_new_char()
+#define start_contour(x,y,outside) sp_start_contour(x,y,outside)
+#define curve_to(x1,y1,x2,y2,x3,y3) sp_curve_to(x1,y1,x2,y2,x3,y3)
+#define line_to(x,y) sp_line_to(x,y)
+#define close_contour() sp_close_contour()
+#define close_outline() sp_close_outline()
+
+#endif
+
+#else
+
+#define GDECL SPEEDO_GLOBALS* sp_global_ptr,
+
+#define get_char_id(char_index) sp_get_char_id(sp_global_ptr,char_index)
+#define get_char_width(char_index) sp_get_char_width(sp_global_ptr,char_index)
+#define get_track_kern(track,point_size) sp_get_track_kern(sp_global_ptr,track,point_size)
+#define get_pair_kern(char_index1,char_index2) sp_get_pair_kern(sp_global_ptr,char_index1,char_index2)
+#define get_char_bbox(char_index,bbox) sp_get_char_bbox(sp_global_ptr,char_index,bbox)
+#define make_char(char_index) sp_make_char(sp_global_ptr,char_index)
+#if INCL_ISW
+#define compute_isw_scale() sp_compute_isw_scale(sp_global_ptr)
+#define do_make_char(char_index) sp_do_make_char(sp_global_ptr,char_index)
+#define make_char_isw(char_index,imported_width) sp_make_char_isw(sp_global_ptr,char_index,imported_width)
+#define reset_xmax(xmax) sp_reset_xmax(sp_global_ptr,xmax)
+#endif
+#if INCL_ISW || INCL_SQUEEZING
+#define preview_bounding_box(pointer,format) sp_preview_bounding_box(sp_global_ptr,pointer,format)
+#endif
+#define make_simp_char(pointer,format) sp_make_simp_char(sp_global_ptr,pointer,format)
+#define make_comp_char(pointer) sp_make_comp_char(sp_global_ptr,pointer)
+#define get_char_org(char_index,top_level) sp_get_char_org(sp_global_ptr,char_index,top_level)
+#define get_posn_arg(ppointer,format) sp_get_posn_arg(sp_global_ptr,ppointer,format)
+#define get_scale_arg(ppointer,format) sp_get_scale_arg(sp_global_ptr,ppointer,format)
+#define read_bbox(ppointer,pPmin,pPmax,set_flag) sp_read_bbox(sp_global_ptr,ppointer,pPmin,pPmax,set_flag)
+#define proc_outl_data(pointer) sp_proc_outl_data(sp_global_ptr,pointer)
+#define split_curve(P1,P2,P3,depth) sp_split_curve(sp_global_ptr,P1,P2,P3,depth)
+#define get_args(ppointer,format,pP) sp_get_args(sp_global_ptr,ppointer,format,pP)
+
+#define init_black(specsarg) sp_init_black(sp_global_ptr,specsarg)
+#define begin_char_black(Psw,Pmin,Pmax) sp_begin_char_black(sp_global_ptr,Psw,Pmin,Pmax)
+#define begin_contour_black(P1,outside) sp_begin_contour_black(sp_global_ptr,P1,outside)
+#define line_black(P1) sp_line_black(sp_global_ptr,P1)
+#define end_char_black() sp_end_char_black(sp_global_ptr)
+#define add_intercept_black(y,x) sp_add_intercept_black(sp_global_ptr,y,x)
+#define proc_intercepts_black() sp_proc_intercepts_black(sp_global_ptr)
+
+#define init_screen(specsarg) sp_init_screen(sp_global_ptr,specsarg)
+#define begin_char_screen(Psw,Pmin,Pmax) sp_begin_char_screen(sp_global_ptr,Psw,Pmin,Pmax)
+#define begin_contour_screen(P1,outside) sp_begin_contour_screen(sp_global_ptr,P1,outside)
+#define curve_screen(P1,P2,P3,depth) sp_curve_screen(sp_global_ptr,P1,P2,P3,depth)
+#define scan_curve_screen(X0,Y0,X1,Y1,X2,Y2,X3,Y3) sp_scan_curve_screen(sp_global_ptr,X0,Y0,X1,Y1,X2,Y2,X3,Y3)
+#define vert_line_screen(x,y1,y2) sp_vert_line_screen(sp_global_ptr,x,y1,y2)
+#define line_screen(P1) sp_line_screen(sp_global_ptr,P1)
+#define end_char_screen() sp_end_char_screen(sp_global_ptr)
+#define end_contour_screen() sp_end_contour_screen(sp_global_ptr)
+#define add_intercept_screen(y,x) sp_add_intercept_screen(sp_global_ptr,y,x)
+#define proc_intercepts_screen() sp_proc_intercepts_screen(sp_global_ptr)
+
+#define init_outline(specsarg) sp_init_outline(sp_global_ptr,specsarg)
+#define begin_char_outline(Psw,Pmin,Pmax) sp_begin_char_outline(sp_global_ptr,Psw,Pmin,Pmax)
+#define begin_sub_char_outline(Psw,Pmin,Pmax) sp_begin_sub_char_outline(sp_global_ptr,Psw,Pmin,Pmax)
+#define begin_contour_outline(P1,outside) sp_begin_contour_outline(sp_global_ptr,P1,outside)
+#define curve_outline(P1,P2,P3,depth) sp_curve_outline(sp_global_ptr,P1,P2,P3,depth)
+#define line_outline(P1) sp_line_outline(sp_global_ptr,P1)
+#define end_contour_outline() sp_end_contour_outline(sp_global_ptr)
+#define end_sub_char_outline() sp_end_sub_char_outline(sp_global_ptr)
+#define end_char_outline() sp_end_char_outline(sp_global_ptr)
+
+#define init_2d(specsarg) sp_init_2d(sp_global_ptr,specsarg)
+#define begin_char_2d(Psw, Pmin, Pmax) sp_begin_char_2d(sp_global_ptr,Psw, Pmin, Pmax)
+#define begin_contour_2d(P1, outside) sp_begin_contour_2d(sp_global_ptr,P1, outside)
+#define line_2d(P1) sp_line_2d(sp_global_ptr,P1)
+#define end_char_2d() sp_end_char_2d(sp_global_ptr)
+#define add_intercept_2d(y, x) sp_add_intercept_2d(sp_global_ptr,y, x)
+#define proc_intercepts_2d() sp_proc_intercepts_2d(sp_global_ptr)
+#define draw_vector_to_2d(x0, y0, x1, y1, band) sp_draw_vector_to_2d(sp_global_ptr,x0, y0, x1, y1, band)
+
+#define init_char_out(Psw,Pmin,Pmax) sp_init_char_out(sp_global_ptr,Psw,Pmin,Pmax)
+#define begin_sub_char_out(Psw,Pmin,Pmax) sp_begin_sub_char_out(sp_global_ptr,Psw,Pmin,Pmax)
+#define curve_out(P1,P2,P3,depth) sp_curve_out(sp_global_ptr,P1,P2,P3,depth)
+#define end_contour_out() sp_end_contour_out(sp_global_ptr)
+#define end_sub_char_out() sp_end_sub_char_out(sp_global_ptr)
+#define init_intercepts_out() sp_init_intercepts_out(sp_global_ptr)
+#define restart_intercepts_out() sp_restart_intercepts_out(sp_global_ptr)
+#define set_first_band_out(Pmin,Pmax) sp_set_first_band_out(sp_global_ptr,Pmin,Pmax)
+#define reduce_band_size_out() sp_reduce_band_size_out(sp_global_ptr)
+#define next_band_out() sp_next_band_out(sp_global_ptr)
+
+#define init_userout(specsarg) sp_init_userout(sp_global_ptr,specsarg)
+
+#define reset() sp_reset(sp_global_ptr)
+#define set_key(key) sp_set_key(sp_global_ptr,key)
+#define get_cust_no(font_buff) sp_get_cust_no(sp_global_ptr,font_buff)
+#define set_specs(specsarg) sp_set_specs(sp_global_ptr,specsarg)
+#define setup_consts(xmin,xmax,ymin,ymax) sp_setup_consts(sp_global_ptr,xmin,xmax,ymin,ymax)
+#define setup_tcb(ptcb) sp_setup_tcb(sp_global_ptr,ptcb)
+#define setup_mult(input_mult) sp_setup_mult(sp_global_ptr,input_mult)
+#define setup_offset(input_offset) sp_setup_offset(sp_global_ptr,input_offset)
+#define type_tcb(ptcb) sp_type_tcb(sp_global_ptr,ptcb)
+#define read_long(pointer) sp_read_long(sp_global_ptr,pointer)
+#define read_word_u(pointer) sp_read_word_u(sp_global_ptr,pointer)
+#define init_tcb() sp_init_tcb(sp_global_ptr)
+#define scale_tcb(ptcb,x_pos,y_pos,x_scale,y_scale) sp_scale_tcb(sp_global_ptr,ptcb,x_pos,y_pos,x_scale,y_scale)
+#define plaid_tcb(ppointer,format) sp_plaid_tcb(sp_global_ptr,ppointer,format)
+#define skip_orus(ppointer,short_form,no_ctrl_zones) sp_skip_orus(sp_global_ptr,ppointer,short_form,no_ctrl_zones)
+#define skip_interpolation_table(ppointer,format) sp_skip_interpolation_table(sp_global_ptr,ppointer,format)
+#define skip_control_zone(ppointer,format) sp_skip_control_zone(sp_global_ptr,ppointer,format)
+#define constr_update() sp_constr_update(sp_global_ptr)
+#define read_oru_table(ppointer) sp_read_oru_table(sp_global_ptr,ppointer)
+#define calculate_x_pix(start_edge,end_edge,constr_nr,x_scale,x_offset,ppo,setwidth_pix) sp_calculate_x_pix(sp_global_ptr,start_edge,end_edge,constr_nr,x_scale,x_offset,ppo,setwidth_pix)
+#define calculate_y_pix(start_edge,end_edge,constr_nr,top_scale,bottom_scale,ppo,emtop_pix,embot_pix) sp_calculate_y_pix(sp_global_ptr,start_edge,end_edge,constr_nr,top_scale,bottom_scale,ppo,emtop_pix,embot_pix)
+#define calculate_x_scale(x_factor,x_offset,no_x_ctrl_zones) sp_calculate_x_scale(sp_global_ptr,x_factor,x_offset,no_x_ctrl_zones)
+#define calculate_y_scale(top_scale,bottom_scale,first_y_zone,no_Y_ctrl_zones) sp_calculate_y_scale(sp_global_ptr,top_scale,bottom_scale,first_y_zone,no_Y_ctrl_zones)
+#define setup_pix_table(ppointer,short_form,no_X_ctrl_zones,no_Y_ctrl_zones) sp_setup_pix_table(sp_global_ptr,ppointer,short_form,no_X_ctrl_zones,no_Y_ctrl_zones)
+#define setup_int_table(ppointer,no_X_int_zones, no_Y_int_zones) sp_setup_int_table(sp_global_ptr,ppointer,no_X_int_zones, no_Y_int_zones)
+
+#define fn_init_out(specsarg) (*sp_globals.init_out)(sp_global_ptr,specsarg)
+#define fn_begin_char(Psw,Pmin,Pmax) (*sp_globals.begin_char)(sp_global_ptr,Psw,Pmin,Pmax)
+#define fn_begin_sub_char(Psw,Pmin,Pmax) (*sp_globals.begin_sub_char)(sp_global_ptr,Psw,Pmin,Pmax)
+#define fn_end_sub_char() (*sp_globals.end_sub_char)(sp_global_ptr)
+#define fn_end_char() (*sp_globals.end_char)(sp_global_ptr)
+#define fn_line(P1) (*sp_globals.line)(sp_global_ptr,P1)
+#define fn_end_contour() (*sp_globals.end_contour)(sp_global_ptr)
+#define fn_begin_contour(P0,fmt) (*sp_globals.begin_contour)(sp_global_ptr,P0,fmt)
+#define fn_curve(P1,P2,P3,depth) (*sp_globals.curve)(sp_global_ptr,P1,P2,P3,depth)
+
+
+#define load_char_data(offset, no_bytes, buff_off) sp_load_char_data(sp_global_ptr, offset, no_bytes, buff_off)
+#define report_error(n) sp_report_error(sp_global_ptr, n)
+
+#if INCL_MULTIDEV
+
+#define set_bitmap_device(bfuncs,size) sp_set_bitmap_device(sp_global_ptr,bfuncs,size)
+#define set_outline_device(ofuncs,size) sp_set_outline_device(sp_global_ptr,ofuncs,size)
+
+#define open_bitmap(x_set_width, y_set_width, xmin, xmax, ymin, ymax)(*sp_globals.bitmap_device.p_open_bitmap)(sp_global_ptr,x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define set_bitmap_bits(y, xbit1, xbit2)(*sp_globals.bitmap_device.p_set_bits)(sp_global_ptr,y, xbit1, xbit2)
+#define close_bitmap()(*sp_globals.bitmap_device.p_close_bitmap)(sp_global_ptr)
+
+#define open_outline(x_set_width, y_set_width, xmin, xmax, ymin, ymax)(*sp_globals.outline_device.p_open_outline)(sp_global_ptr,x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define start_new_char()(*sp_globals.outline_device.p_start_char)(sp_global_ptr)
+#define start_contour(x,y,outside)(*sp_globals.outline_device.p_start_contour)(sp_global_ptr,x,y,outside)
+#define curve_to(x1,y1,x2,y2,x3,y3)(*sp_globals.outline_device.p_curve)(sp_global_ptr,x1,y1,x2,y2,x3,y3)
+#define line_to(x,y)(*sp_globals.outline_device.p_line)(sp_global_ptr,x,y)
+#define close_contour()(*sp_globals.outline_device.p_close_contour)(sp_global_ptr)
+#define close_outline()(*sp_globals.outline_device.p_close_outline)(sp_global_ptr)
+
+#else
+
+#define open_bitmap(x_set_width, y_set_width, xmin, xmax, ymin, ymax) sp_open_bitmap(sp_global_ptr, x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define set_bitmap_bits(y, xbit1, xbit2) sp_set_bitmap_bits(sp_global_ptr, y, xbit1, xbit2)
+#define close_bitmap() sp_close_bitmap(sp_global_ptr)
+
+#define open_outline(x_set_width, y_set_width, xmin, xmax, ymin, ymax) sp_open_outline(sp_global_ptr, x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define start_new_char() sp_start_new_char(sp_global_ptr )
+#define start_contour(x,y,outside) sp_start_contour(sp_global_ptr, x,y,outside)
+#define curve_to(x1,y1,x2,y2,x3,y3) sp_curve_to(sp_global_ptr, x1,y1,x2,y2,x3,y3)
+#define line_to(x,y) sp_line_to(sp_global_ptr, x,y)
+#define close_contour() sp_close_contour(sp_global_ptr)
+#define close_outline() sp_close_outline(sp_global_ptr)
+
+#endif
+#endif
+
+
diff --git a/nx-X11/lib/font/Speedo/speedo.h b/nx-X11/lib/font/Speedo/speedo.h
new file mode 100644
index 000000000..5eb516c1c
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/speedo.h
@@ -0,0 +1,890 @@
+/* $Xorg: speedo.h,v 1.3 2000/08/17 19:46:27 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/speedo.h,v 3.5 2001/01/17 19:43:18 dawes Exp $ */
+
+#ifndef _SPEEDO_H_
+#define _SPEEDO_H_
+
+#include <X11/Xmd.h>
+
+/***************************** S P E E D O . H *******************************
+ ****************************************************************************/
+
+/***** USER OPTIONS OVERRIDE DEFAULTS ******/
+#include "useropt.h"
+
+/***** CONFIGURATION DEFINITIONS *****/
+
+#ifndef INCL_CLIPPING
+#define INCL_CLIPPING 0 /* 0 indicates CLIPPING code is not compiled in*/
+#endif
+
+#ifndef INCL_SQUEEZING
+#define INCL_SQUEEZING 0 /* 0 indicates SQUEEZE code is not compiled in*/
+#endif
+
+#ifndef INCL_EXT
+#define INCL_EXT 1 /* 1 to include extended font support */
+#endif /* 0 to omit extended font support */
+
+#ifndef INCL_RULES
+#define INCL_RULES 1 /* 1 to include intelligent scaling support */
+#endif /* 0 to omit intelligent scaling support */
+
+#ifndef INCL_BLACK
+#define INCL_BLACK 1 /* 1 to include blackwriter output support */
+#endif /* 0 to omit output mode 0 support */
+
+#ifndef INCL_SCREEN
+#define INCL_SCREEN 0 /* 1 to include screen writeroutput support */
+#endif /* 0 to omit support */
+
+#ifndef INCL_OUTLINE
+#define INCL_OUTLINE 0 /* 1 to include outline output support */
+#endif /* 0 to omit output mode 2 support */
+
+#ifndef INCL_2D
+#define INCL_2D 0 /* 1 to include 2d blackwriter output support */
+#endif /* 0 to omit output mode 3 support */
+
+#ifndef INCL_USEROUT
+#define INCL_USEROUT 0 /* 1 to include user defined output module support */
+#endif /* 0 to omit user defined output module support */
+
+#ifndef INCL_LCD
+#define INCL_LCD 1 /* 1 to include load char data support*/
+#endif /* 0 to omit load char data support */
+#ifndef INCL_ISW
+#define INCL_ISW 0 /* 1 to include imported width support */
+#endif /* 0 to omit imported width support */
+
+#ifndef INCL_METRICS
+#define INCL_METRICS 1 /* 1 to include metrics support */
+#endif /* 0 to omit metrics support */
+
+#ifndef INCL_KEYS
+#define INCL_KEYS 0 /* 1 to include multi key support */
+#endif /* 0 to omit multi key support */
+
+#ifndef INCL_MULTIDEV
+#define INCL_MULTIDEV 0 /* 1 to include multiple output device support */
+#endif /* 0 to omit multi device support */
+
+#ifndef SHORT_LISTS
+#define SHORT_LISTS 1 /* 1 to allocate small intercept lists */
+#endif
+
+#ifndef INCL_PLAID_OUT
+#define INCL_PLAID_OUT 0 /* 1 to include plaid data monitoring */
+#endif /* 0 to omit plaid data monitoring */
+
+#ifndef FONTFAR /* if Intel mixed memory model implementation */
+#define FONTFAR /* pointer type modifier for font buffer */
+#endif
+
+#ifndef STACKFAR /* if Intel mixed memory model implementation */
+#define STACKFAR /* pointer type modifier for font buffer */
+#endif
+
+#ifndef GLOBALFAR
+#define GLOBALFAR
+#endif
+
+#define MODE_BLACK 0
+#define MODE_SCREEN MODE_BLACK + INCL_BLACK
+#define MODE_OUTLINE MODE_SCREEN + INCL_SCREEN
+#define MODE_2D MODE_OUTLINE + INCL_OUTLINE
+
+#ifdef DYNAMIC_ALLOC
+#if DYNAMIC_ALLOC
+#define STATIC_ALLOC 0
+#endif
+#endif
+
+#ifdef REENTRANT_ALLOC
+#if REENTRANT_ALLOC
+#define STATIC_ALLOC 0
+#endif
+#endif
+
+#ifndef STATIC_ALLOC
+#define STATIC_ALLOC 1
+#endif
+
+#ifndef DYNAMIC_ALLOC
+#define DYNAMIC_ALLOC 0
+#endif
+
+#ifndef REENTRANT_ALLOC
+#define REENTRANT_ALLOC 0
+#endif
+
+/***** TYPE DEFINITIONS *****/
+
+#ifndef STDEF
+#ifndef SPD_BMAP
+
+typedef INT8 fix7;
+
+typedef double real;
+
+typedef CARD8 ufix8;
+#ifndef VFONT
+typedef CARD8 boolean;
+#endif
+#endif
+
+typedef INT16 fix15;
+
+typedef CARD16 ufix16;
+
+typedef INT32 fix31;
+
+typedef CARD32 ufix32;
+#endif
+
+/***** GENERAL CONSTANTS *****/
+
+#ifndef FALSE
+#define FALSE 0
+#define TRUE 1
+#endif
+
+#ifndef NULL
+#include <stddef.h>
+#endif
+
+#define FUNCTION
+
+#define BIT0 0x01
+#define BIT1 0x02
+#define BIT2 0x04
+#define BIT3 0x08
+#define BIT4 0x10
+#define BIT5 0x20
+#define BIT6 0x40
+#define BIT7 0x80
+
+#if INCL_EXT /* Extended fonts supported? */
+
+#define MAX_CONSTR 750 /* Max constraints (incl 4 dummies) */
+#define MAX_CTRL_ZONES 256 /* Max number of controlled orus */
+#define MAX_INT_ZONES 256 /* Max number of interpolation zones */
+
+#else /* Compact fonts only supported */
+
+#define MAX_CONSTR 512 /* Max constraints (incl 4 dummies) */
+#define MAX_CTRL_ZONES 64 /* Max number of controlled orus */
+#define MAX_INT_ZONES 64 /* Max number of interpolation zones */
+
+#endif
+
+#define SCALE_SHIFT 12 /* Binary point positiion for scale values */
+#define SCALE_RND 2048 /* Rounding bit for scaling transformation */
+#define ONE_SCALE 4096 /* Unity scale value */
+
+#ifdef INCL_SCREEN /* constants used by Screenwriter module */
+#define LEFT_INT 1 /* left intercept */
+#define END_INT 2 /* last intercept */
+#define FRACTION 0xFC /* fractional portion of intercept type list */
+#endif
+
+#if INCL_SQUEEZING || INCL_CLIPPING /* constants used by SQUEEZEing code */
+#define EM_TOP 764
+#define EM_BOT -236
+#endif
+
+/***** STRUCTURE DEFINITIONS *****/
+#if REENTRANT_ALLOC
+#define PROTO_DECL1 struct speedo_global_data GLOBALFAR *sp_global_ptr
+#define PROTO_DECL2 PROTO_DECL1 ,
+#else
+#define PROTO_DECL1 void
+#define PROTO_DECL2
+#endif
+
+typedef
+struct buff_tag
+ {
+ ufix8 FONTFAR *org; /* Pointer to start of buffer */
+ ufix32 no_bytes; /* Size of buffer in bytes */
+ }
+buff_t; /* Buffer descriptor */
+
+typedef struct constr_tag
+ {
+ ufix8 FONTFAR *org; /* Pointer to first byte in constr data */
+ ufix16 font_id; /* Font id for calculated data */
+ fix15 xppo; /* X pixels per oru for calculated data */
+ fix15 yppo; /* Y pixels per oru for calculated data */
+ boolean font_id_valid; /* TRUE if font id valid */
+ boolean data_valid; /* TRUE if calculated data valid */
+ boolean active; /* TRUE if constraints enabled */
+ }
+constr_t; /* Constraint data state */
+
+typedef struct kern_tag
+ {
+ ufix8 FONTFAR *tkorg; /* First byte of track kerning data */
+ ufix8 FONTFAR *pkorg; /* First byte of pair kerning data */
+ fix15 no_tracks; /* Number of kerning tracks */
+ fix15 no_pairs; /* Number of kerning pairs */
+ }
+kern_t; /* Kerning control block */
+
+typedef struct specs_tag
+ {
+ buff_t STACKFAR *pfont; /* Pointer to font data */
+ fix31 xxmult; /* Coeff of X orus to compute X pix */
+ fix31 xymult; /* Coeff of Y orus to compute X pix */
+ fix31 xoffset; /* Constant to compute X pix */
+ fix31 yxmult; /* Coeff of X orus to compute Y pix */
+ fix31 yymult; /* Coeff of Y orus to compute Y pix */
+ fix31 yoffset; /* Constant to compute Y pix */
+ ufix32 flags; /* Mode flags: */
+ /* Bit 0 - 2: Output module selector: */
+ /* Bit 3: Send curves to output module*/
+ /* Bit 4: Use linear scaling if set */
+ /* Bit 5: Inhibit constraint table */
+ /* Bit 6: Import set width if set */
+ /* Bit 7: not used */
+ /* Bit 8: Squeeze left if set */
+ /* Bit 9: Squeeze right if set */
+ /* Bit 10: Squeeze top if set */
+ /* Bit 11: Squeeze bottom if set */
+ /* Bit 12: Clip left if set */
+ /* Bit 13: Clip right if set */
+ /* Bit 14: Clip top if set */
+ /* Bit 15: Clip bottom if set */
+ /* Bits 16-31 not used */
+ void *out_info; /* information for output module */
+ }
+specs_t; /* Specs structure for fw_set_specs */
+
+typedef struct tcb_tag
+ {
+ fix15 xxmult; /* Linear coeff of Xorus to compute Xpix */
+ fix15 xymult; /* Linear coeff of Yorus to compute Xpix */
+ fix31 xoffset; /* Linear constant to compute Xpix */
+ fix15 yxmult; /* Linear coeff of Xorus to compute Ypix */
+ fix15 yymult; /* Linear coeff of Yorus to compute Ypix */
+ fix31 yoffset; /* Linear constant to compute Ypix */
+ fix15 xppo; /* Pixels per oru in X dimension of char */
+ fix15 yppo; /* Pixels per oru in Y dimension of char */
+ fix15 xpos; /* Origin in X dimension of character */
+ fix15 ypos; /* Origin in Y dimension of character */
+ ufix16 xtype; /* Transformation type for X oru coords */
+ ufix16 ytype; /* Transformation type for Y oru coords */
+ ufix16 xmode; /* Transformation mode for X oru coords */
+ ufix16 ymode; /* Transformation mode for Y oru coords */
+ fix15 mirror; /* Transformation creates mirror image */
+ }
+tcb_t; /* Transformation control block */
+
+typedef struct point_tag
+ {
+ fix15 x; /* X coord of point (shifted pixels) */
+ fix15 y; /* Y coord of point (shifted pixels) */
+ }
+point_t; /* Point in device space */
+
+typedef struct band_tag
+ {
+ fix15 band_max;
+ fix15 band_min;
+ fix15 band_array_offset;
+ fix15 band_floor;
+ fix15 band_ceiling;
+ } band_t;
+
+typedef struct bbox_tag
+ {
+ fix31 xmin;
+ fix31 xmax;
+ fix31 ymin;
+ fix31 ymax;
+ } bbox_t;
+
+#if SHORT_LISTS
+#define MAX_INTERCEPTS 256 /* Max storage for intercepts */
+typedef ufix8 cdr_t; /* 8 bit links in intercept chains */
+#else
+#define MAX_INTERCEPTS 1000 /* Max storage for intercepts */
+typedef ufix16 cdr_t; /* 16 bit links in intercept chains */
+#endif
+
+#if REENTRANT_ALLOC
+
+typedef struct intercepts_tag
+ {
+ fix15 car[MAX_INTERCEPTS];
+ fix15 cdr[MAX_INTERCEPTS];
+#if INCL_SCREEN
+ ufix8 inttype[MAX_INTERCEPTS];
+ ufix8 leftedge;
+ ufix16 fracpix;
+#endif
+ } intercepts_t;
+
+typedef struct plaid_tag
+ {
+ fix15 orus[MAX_CTRL_ZONES]; /* Controlled coordinate table (orus) */
+#if INCL_RULES
+ fix15 pix[MAX_CTRL_ZONES]; /* Controlled coordinate table (sub-pixels) */
+ fix15 mult[MAX_INT_ZONES]; /* Interpolation multiplier table */
+ fix31 offset[MAX_INT_ZONES]; /* Interpolation offset table */
+#endif
+ } plaid_t;
+#endif
+
+#if INCL_MULTIDEV
+typedef struct bitmap_tag
+ {
+ void (*p_open_bitmap)(PROTO_DECL2 fix31 x_set_width, fix31 y_set_width, fix31 xorg, fix31 yorg, fix15 xsize,fix15 ysize);
+ void (*p_set_bits)(PROTO_DECL2 fix15 y, fix15 xbit1, fix15 xbit2);
+ void (*p_close_bitmap)(PROTO_DECL1);
+ } bitmap_t;
+
+typedef struct outline_tag
+ {
+ void (*p_open_outline)(PROTO_DECL2 fix31 x_set_width, fix31 y_set_width, fix31 xmin, fix31 xmax, fix31 ymin,fix31 ymax);
+ void (*p_start_char)(PROTO_DECL1);
+ void (*p_start_contour)(PROTO_DECL2 fix31 x,fix31 y,boolean outside);
+ void (*p_curve)(PROTO_DECL2 fix31 x1, fix31 y1, fix31 x2, fix31 y2, fix31 x3, fix31 y3);
+ void (*p_line)(PROTO_DECL2 fix31 x, fix31 y);
+ void (*p_close_contour)(PROTO_DECL1);
+ void (*p_close_outline)(PROTO_DECL1);
+ } outline_t;
+#endif
+
+/* ---------------------------------------------------*/
+/**** MAIN GLOBAL DATA STRUCTURE, SPEEDO_GLOBALS *****/
+
+typedef struct speedo_global_data
+ {
+/* do_char.c data definitions */
+#if INCL_METRICS /* Metrics functions supported? */
+ kern_t kern; /* Kerning control block */
+#endif /* endif incl_metrics */
+ point_t Psw; /* End of escapement vector (1/65536 pixel units) */
+
+#if INCL_LCD /* Dynamic load character data supported? */
+ fix15 cb_offset; /* Offset to sub-char data in char buffer */
+#endif /* endif incl_lcd */
+
+/* do_trns.c data definitions */
+ point_t P0; /* Current point (sub-pixels) */
+ fix15 x_orus; /* Current X argument (orus) */
+ fix15 y_orus; /* Current Y argument (orus) */
+ fix15 x_pix; /* Current X argument (sub-pixels) */
+ fix15 y_pix; /* Current Y argument (sub-pixels) */
+ ufix8 x_int; /* Current X interpolation zone */
+ ufix8 y_int; /* Current Y interpolation zone */
+
+#if INCL_MULTIDEV && INCL_OUTLINE
+ outline_t outline_device;
+ boolean outline_device_set;
+#endif
+
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+#if INCL_MULTIDEV
+ bitmap_t bitmap_device;
+ boolean bitmap_device_set;
+#endif
+ band_t y_band; /* Y current band(whole pixels) */
+
+ struct set_width_tag
+ {
+ fix31 x;
+ fix31 y;
+ } set_width; /* Character escapement vector */
+
+ boolean first_pass; /* TRUE during first pass thru outline data */
+ boolean extents_running; /* T if extent accumulation for each vector */
+ fix15 x0_spxl; /* X coord of current point (sub pixels) */
+ fix15 y0_spxl; /* Y coord of current point (sub pixels) */
+ fix15 y_pxl; /* Y coord of current point (whole pixels) */
+#if REENTRANT_ALLOC
+ intercepts_t STACKFAR *intercepts;
+#else /* else if not reentrant */
+ fix15 car[MAX_INTERCEPTS]; /* Data field of intercept storage */
+ cdr_t cdr[MAX_INTERCEPTS]; /* Link field of intercept storage */
+#if INCL_SCREEN
+ ufix8 inttype[MAX_INTERCEPTS];
+ ufix8 leftedge;
+ ufix16 fracpix;
+#endif /* endif incl_screen */
+#endif /* endif reentrant */
+ fix15 bmap_xmin; /* Min X value (sub-pixel units) */
+ fix15 bmap_xmax; /* Max X value (sub-pixel units) */
+ fix15 bmap_ymin; /* Min Y value (sub-pixel units) */
+ fix15 bmap_ymax; /* Max Y value (sub-pixel units) */
+ fix15 no_y_lists; /* Number of active intercept lists */
+ fix15 first_offset; /* Index of first active list cell */
+ fix15 next_offset; /* Index of next free list cell */
+ boolean intercept_oflo; /* TRUE if intercepts data lost */
+#endif /* endif incl_black, incl_screen, incl_2d */
+
+/* bounding box now used by all output modules, including outline */
+ fix15 xmin; /* Min X value in whole character */
+ fix15 xmax; /* Max X value in whole character */
+ fix15 ymin; /* Min Y value in whole character */
+ fix15 ymax; /* Max Y value in whole character */
+
+#if INCL_2D
+ fix15 no_x_lists; /* Number of active x intercept lists */
+ band_t x_band; /* X current band(whole pixels) */
+ boolean x_scan_active; /* X scan flag during scan conversion */
+#endif
+
+/* reset.c data definitions */
+ ufix16 key32; /* Decryption keys 3,2 combined */
+ ufix8 key4; /* Decryption key 4 */
+ ufix8 key6; /* Decryption key 6 */
+ ufix8 key7; /* Decryption key 7 */
+ ufix8 key8; /* Decryption key 8 */
+
+/* set_spcs.c data definitions */
+ buff_t font;
+ buff_t GLOBALFAR *pfont; /* Pointer to font buffer structure */
+ fix31 font_buff_size; /* Number of bytes loaded in font buffer */
+ ufix8 FONTFAR *pchar_dir; /* Pointer to character directory */
+ fix15 first_char_idx; /* Index to first character in font */
+ fix15 no_chars_avail; /* Total characters in font layout */
+ fix15 orus_per_em; /* Outline resolution */
+ fix15 metric_resolution; /* metric resolution for setwidths, kerning pairs
+ (defaults to orus_per_em) */
+ tcb_t tcb0; /* Top level transformation control block */
+
+ boolean specs_valid; /* TRUE if fw_set_specs() successful */
+
+ fix15 depth_adj; /* Curve splitting depth adjustment */
+ boolean curves_out; /* Allow curves to output module */
+ fix15 output_mode; /* Output module selector */
+ fix15 thresh; /* Scan conversion threshold (sub-pixels) */
+ boolean normal; /* TRUE if 0 obl and mult of 90 deg rot */
+
+ fix15 multshift; /* Fixed point shift for multipliers */
+ fix15 pixshift; /* Fixed point shift for sub-pixels */
+ fix15 poshift; /* Left shift from pixel to output format */
+ fix15 mpshift; /* Fixed point shift for mult to sub-pixels */
+ fix31 multrnd; /* 0.5 in multiplier units */
+ fix15 pixrnd; /* 0.5 in sub-pixel units */
+ fix31 mprnd; /* 0.5 sub-pixels in multiplier units */
+ fix15 pixfix; /* Mask to remove fractional pixels */
+ fix15 onepix; /* 1.0 pixels in sub-pixel units */
+
+ boolean (*init_out)(PROTO_DECL2 specs_t GLOBALFAR *specsarg);
+ boolean (*begin_char)(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
+ void (*begin_sub_char)(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
+ void (*begin_contour)(PROTO_DECL2 point_t P1,boolean outside);
+ void (*curve)(PROTO_DECL2 point_t P1, point_t P2, point_t P3, fix15 depth);
+ void (*line)(PROTO_DECL2 point_t P1);
+ void (*end_contour)(PROTO_DECL1);
+ void (*end_sub_char)(PROTO_DECL1);
+ boolean (*end_char)(PROTO_DECL1);
+ specs_t GLOBALFAR *pspecs; /* Pointer to specifications bundle */
+ specs_t specs; /* copy specs onto stack */
+ ufix8 FONTFAR *font_org; /* Pointer to start of font data */
+ ufix8 FONTFAR *hdr2_org; /* Pointer to start of private header data */
+
+/* set_trns.c data definitions */
+ tcb_t tcb; /* Current transformation control block */
+ ufix8 Y_edge_org; /* Index to first Y controlled coordinate */
+ ufix8 Y_int_org; /* Index to first Y interpolation zone */
+ fix31 rnd_xmin; /* rounded out value of xmin for int-char spac. fix */
+
+#if REENTRANT_ALLOC
+ plaid_t STACKFAR *plaid;
+#else /* if not reentrant */
+ fix15 orus[MAX_CTRL_ZONES]; /* Controlled coordinate table (orus) */
+#if INCL_RULES
+ fix15 pix[MAX_CTRL_ZONES]; /* Controlled coordinate table (sub-pixels) */
+ fix15 mult[MAX_INT_ZONES]; /* Interpolation multiplier table */
+ fix31 offset[MAX_INT_ZONES]; /* Interpolation offset table */
+#endif /* endif incl_rules */
+#endif /* endif not reentrant */
+
+ fix15 no_X_orus; /* Number of X controlled coordinates */
+ fix15 no_Y_orus; /* Number of Y controlled coordinates */
+ ufix16 Y_constr_org; /* Origin of constraint table in font data */
+
+#if INCL_RULES
+ constr_t constr; /* Constraint data state */
+ boolean c_act[MAX_CONSTR]; /* TRUE if constraint currently active */
+ fix15 c_pix[MAX_CONSTR]; /* Size of constrained zone if active */
+#endif
+#if INCL_ISW
+ boolean import_setwidth_act; /* boolean to indicate imported setwidth */
+ boolean isw_modified_constants;
+ ufix32 imported_width; /* value of imported setwidth */
+ fix15 isw_xmax; /* maximum oru value for constants*/
+#endif
+#if INCL_SQUEEZING || INCL_ISW
+ fix15 setwidth_orus; /* setwidth value in orus */
+ /* bounding box in orus for squeezing */
+ fix15 bbox_xmin_orus; /* X minimum in orus */
+ fix15 bbox_xmax_orus; /* X maximum in orus */
+ fix15 bbox_ymin_orus; /* Y minimum in orus */
+ fix15 bbox_ymax_orus; /* Y maximum in orus */
+#endif
+#ifdef INCL_SQUEEZING
+ boolean squeezing_compound; /* flag to indicate a compound character*/
+#endif
+#ifdef INCL_CLIPPING
+ fix31 clip_xmax;
+ fix31 clip_ymax;
+ fix31 clip_xmin;
+ fix31 clip_ymin;
+#endif
+ } SPEEDO_GLOBALS;
+
+/***********************************************************************************
+ *
+ * Speedo global data structure allocation
+ *
+ ***********************************************************************************/
+
+#ifdef SET_SPCS
+#define EXTERN
+#else
+#define EXTERN extern
+#endif
+#if STATIC_ALLOC
+EXTERN SPEEDO_GLOBALS GLOBALFAR sp_globals;
+#define sp_intercepts sp_globals
+#define sp_plaid sp_globals
+#else
+#if DYNAMIC_ALLOC
+EXTERN SPEEDO_GLOBALS GLOBALFAR *sp_global_ptr;
+#define sp_globals (*sp_global_ptr)
+#define sp_intercepts (*sp_global_ptr)
+#define sp_plaid (*sp_global_ptr)
+#else
+#if REENTRANT_ALLOC
+#define sp_globals (*sp_global_ptr)
+#define sp_intercepts (*(*sp_global_ptr).intercepts)
+#define sp_plaid (*(*sp_global_ptr).plaid)
+#endif
+#endif
+#endif
+#ifdef EXTERN
+#undef EXTERN
+#endif
+
+
+/***** PUBLIC FONT HEADER OFFSET CONSTANTS *****/
+#define FH_FMVER 0 /* U D4.0 CR LF NULL NULL 8 bytes */
+#define FH_FNTSZ 8 /* U Font size (bytes) 4 bytes */
+#define FH_FBFSZ 12 /* U Min font buffer size (bytes) 4 bytes */
+#define FH_CBFSZ 16 /* U Min char buffer size (bytes) 2 bytes */
+#define FH_HEDSZ 18 /* U Header size (bytes) 2 bytes */
+#define FH_FNTID 20 /* U Source Font ID 2 bytes */
+#define FH_SFVNR 22 /* U Source Font Version Number 2 bytes */
+#define FH_FNTNM 24 /* U Source Font Name 70 bytes */
+#define FH_MDATE 94 /* U Manufacturing Date 10 bytes */
+#define FH_LAYNM 104 /* U Layout Name 70 bytes */
+#define FH_CPYRT 174 /* U Copyright Notice 78 bytes */
+#define FH_NCHRL 252 /* U Number of Chars in Layout 2 bytes */
+#define FH_NCHRF 254 /* U Total Number of Chars in Font 2 bytes */
+#define FH_FCHRF 256 /* U Index of first char in Font 2 bytes */
+#define FH_NKTKS 258 /* U Number of kerning tracks in font 2 bytes */
+#define FH_NKPRS 260 /* U Number of kerning pairs in font 2 bytes */
+#define FH_FLAGS 262 /* U Font flags 1 byte: */
+ /* Bit 0: Extended font */
+ /* Bit 1: not used */
+ /* Bit 2: not used */
+ /* Bit 3: not used */
+ /* Bit 4: not used */
+ /* Bit 5: not used */
+ /* Bit 6: not used */
+ /* Bit 7: not used */
+#define FH_CLFGS 263 /* U Classification flags 1 byte: */
+ /* Bit 0: Italic */
+ /* Bit 1: Monospace */
+ /* Bit 2: Serif */
+ /* Bit 3: Display */
+ /* Bit 4: not used */
+ /* Bit 5: not used */
+ /* Bit 6: not used */
+ /* Bit 7: not used */
+#define FH_FAMCL 264 /* U Family Classification 1 byte: */
+ /* 0: Don't care */
+ /* 1: Serif */
+ /* 2: Sans serif */
+ /* 3: Monospace */
+ /* 4: Script or calligraphic */
+ /* 5: Decorative */
+ /* 6-255: not used */
+#define FH_FRMCL 265 /* U Font form Classification 1 byte: */
+ /* Bits 0-3 (width type): */
+ /* 0-3: not used */
+ /* 4: Condensed */
+ /* 5: not used */
+ /* 6: Semi-condensed */
+ /* 7: not used */
+ /* 8: Normal */
+ /* 9: not used */
+ /* 10: Semi-expanded */
+ /* 11: not used */
+ /* 12: Expanded */
+ /* 13-15: not used */
+ /* Bits 4-7 (Weight): */
+ /* 0: not used */
+ /* 1: Thin */
+ /* 2: Ultralight */
+ /* 3: Extralight */
+ /* 4: Light */
+ /* 5: Book */
+ /* 6: Normal */
+ /* 7: Medium */
+ /* 8: Semibold */
+ /* 9: Demibold */
+ /* 10: Bold */
+ /* 11: Extrabold */
+ /* 12: Ultrabold */
+ /* 13: Heavy */
+ /* 14: Black */
+ /* 15-16: not used */
+#define FH_SFNTN 266 /* U Short Font Name 32 bytes */
+#define FH_SFACN 298 /* U Short Face Name 16 bytes */
+#define FH_FNTFM 314 /* U Font form 14 bytes */
+#define FH_ITANG 328 /* U Italic angle 2 bytes (1/256th deg) */
+#define FH_ORUPM 330 /* U Number of ORUs per em 2 bytes */
+#define FH_WDWTH 332 /* U Width of Wordspace 2 bytes */
+#define FH_EMWTH 334 /* U Width of Emspace 2 bytes */
+#define FH_ENWTH 336 /* U Width of Enspace 2 bytes */
+#define FH_TNWTH 338 /* U Width of Thinspace 2 bytes */
+#define FH_FGWTH 340 /* U Width of Figspace 2 bytes */
+#define FH_FXMIN 342 /* U Font-wide min X value 2 bytes */
+#define FH_FYMIN 344 /* U Font-wide min Y value 2 bytes */
+#define FH_FXMAX 346 /* U Font-wide max X value 2 bytes */
+#define FH_FYMAX 348 /* U Font-wide max Y value 2 bytes */
+#define FH_ULPOS 350 /* U Underline position 2 bytes */
+#define FH_ULTHK 352 /* U Underline thickness 2 bytes */
+#define FH_SMCTR 354 /* U Small caps transformation 6 bytes */
+#define FH_DPSTR 360 /* U Display sups transformation 6 bytes */
+#define FH_FNSTR 366 /* U Footnote sups transformation 6 bytes */
+#define FH_ALSTR 372 /* U Alpha sups transformation 6 bytes */
+#define FH_CMITR 378 /* U Chemical infs transformation 6 bytes */
+#define FH_SNMTR 384 /* U Small nums transformation 6 bytes */
+#define FH_SDNTR 390 /* U Small denoms transformation 6 bytes */
+#define FH_MNMTR 396 /* U Medium nums transformation 6 bytes */
+#define FH_MDNTR 402 /* U Medium denoms transformation 6 bytes */
+#define FH_LNMTR 408 /* U Large nums transformation 6 bytes */
+#define FH_LDNTR 414 /* U Large denoms transformation 6 bytes */
+ /* Transformation data format: */
+ /* Y position 2 bytes */
+ /* X scale 2 bytes (1/4096ths) */
+ /* Y scale 2 bytes (1/4096ths) */
+#define SIZE_FW FH_LDNTR + 6 /* size of nominal font header */
+#define EXP_FH_METRES SIZE_FW /* offset to expansion field metric resolution (optional) */
+
+
+
+/***** MODE FLAGS CONSTANTS *****/
+#define CURVES_OUT 0X0008 /* Output module accepts curves */
+#define BOGUS_MODE 0X0010 /* Linear scaling mode */
+#define CONSTR_OFF 0X0020 /* Inhibit constraint table */
+#define IMPORT_WIDTHS 0X0040 /* Imported width mode */
+#define SQUEEZE_LEFT 0X0100 /* Squeeze left mode */
+#define SQUEEZE_RIGHT 0X0200 /* Squeeze right mode */
+#define SQUEEZE_TOP 0X0400 /* Squeeze top mode */
+#define SQUEEZE_BOTTOM 0X0800 /* Squeeze bottom mode */
+#define CLIP_LEFT 0X1000 /* Clip left mode */
+#define CLIP_RIGHT 0X2000 /* Clip right mode */
+#define CLIP_TOP 0X4000 /* Clip top mode */
+#define CLIP_BOTTOM 0X8000 /* Clip bottom mode */
+
+/***********************************************************************************
+ *
+ * Speedo function declarations - use prototypes if available
+ *
+ ***********************************************************************************/
+
+/* do_char.c functions */
+ufix16 sp_get_char_id(PROTO_DECL2 ufix16 char_index);
+boolean sp_make_char(PROTO_DECL2 ufix16 char_index);
+#if INCL_ISW
+fix31 sp_compute_isw_scale(PROTO_DECL2);
+static boolean sp_do_make_char(PROTO_DECL2 ufix16 char_index);
+boolean sp_make_char_isw(PROTO_DECL2 ufix16 char_index, ufix32 imported_width);
+static boolean sp_reset_xmax(PROTO_DECL2 fix31 xmax);
+#endif
+#if INCL_ISW || INCL_SQUEEZING
+static void sp_preview_bounding_box(PROTO_DECL2 ufix8 FONTFAR *pointer,ufix8 format);
+#endif
+
+#if INCL_METRICS /* Metrics functions supported? */
+fix31 sp_get_char_width(PROTO_DECL2 ufix16 char_index);
+fix15 sp_get_track_kern(PROTO_DECL2 fix15 track,fix15 point_size);
+fix31 sp_get_pair_kern(PROTO_DECL2 ufix16 char_index1,ufix16 char_index2);
+boolean sp_get_char_bbox(PROTO_DECL2 ufix16 char_index, bbox_t *bbox);
+#endif
+
+/* do_trns.c functions */
+ufix8 FONTFAR *sp_read_bbox(PROTO_DECL2 ufix8 FONTFAR *pointer,point_t STACKFAR *pPmin,point_t STACKFAR *pPmax,boolean set_flag);
+void sp_proc_outl_data(PROTO_DECL2 ufix8 FONTFAR *pointer);
+
+/* out_blk.c functions */
+#if INCL_BLACK
+boolean sp_init_black(PROTO_DECL2 specs_t GLOBALFAR *specsarg);
+boolean sp_begin_char_black(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
+void sp_begin_contour_black(PROTO_DECL2 point_t P1,boolean outside);
+void sp_line_black(PROTO_DECL2 point_t P1);
+boolean sp_end_char_black(PROTO_DECL1);
+#endif
+
+/* out_scrn.c functions */
+#if INCL_SCREEN
+boolean sp_init_screen(PROTO_DECL2 specs_t GLOBALFAR *specsarg);
+boolean sp_begin_char_screen(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
+void sp_begin_contour_screen(PROTO_DECL2 point_t P1,boolean outside);
+void sp_curve_screen(PROTO_DECL2 point_t P1,point_t P2,point_t P3, fix15 depth);
+void sp_scan_curve_screen(PROTO_DECL2 fix31 X0,fix31 Y0,fix31 X1,fix31 Y1,fix31 X2,fix31 Y2,fix31 X3,fix31 Y3);
+void sp_vert_line_screen(PROTO_DECL2 fix31 x, fix15 y1, fix15 y2);
+void sp_line_screen(PROTO_DECL2 point_t P1);
+void sp_end_contour_screen(PROTO_DECL1);
+boolean sp_end_char_screen(PROTO_DECL1);
+#endif
+
+/* out_outl.c functions */
+#if INCL_OUTLINE
+#if INCL_MULTIDEV
+boolean sp_set_outline_device(PROTO_DECL2 outline_t *ofuncs, ufix16 size);
+#endif
+
+
+boolean sp_init_outline(PROTO_DECL2 specs_t GLOBALFAR *specsarg);
+boolean sp_begin_char_outline(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
+void sp_begin_sub_char_outline(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
+void sp_begin_contour_outline(PROTO_DECL2 point_t P1,boolean outside);
+void sp_curve_outline(PROTO_DECL2 point_t P1,point_t P2,point_t P3, fix15 depth);
+void sp_line_outline(PROTO_DECL2 point_t P1);
+void sp_end_contour_outline(PROTO_DECL1);
+void sp_end_sub_char_outline(PROTO_DECL1);
+boolean sp_end_char_outline(PROTO_DECL1);
+#endif
+
+/* out_bl2d.c functions */
+#if INCL_2D
+boolean sp_init_2d(PROTO_DECL2 specs_t GLOBALFAR *specsarg);
+boolean sp_begin_char_2d(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
+void sp_begin_contour_2d(PROTO_DECL2 point_t P1,boolean outside);
+void sp_line_2d(PROTO_DECL2 point_t P1);
+boolean sp_end_char_2d(PROTO_DECL1);
+#endif
+
+/* out_util.c functions */
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+
+#if INCL_MULTIDEV
+boolean sp_set_bitmap_device(PROTO_DECL2 bitmap_t *bfuncs, ufix16 size);
+#endif
+
+void sp_init_char_out(PROTO_DECL2 point_t Psw, point_t Pmin, point_t Pmax);
+void sp_begin_sub_char_out(PROTO_DECL2 point_t Psw, point_t Pmin, point_t Pmax);
+void sp_curve_out(PROTO_DECL2 point_t P1, point_t P2, point_t P3, fix15 depth);
+void sp_end_contour_out(PROTO_DECL1);
+void sp_end_sub_char_out(PROTO_DECL1);
+void sp_init_intercepts_out(PROTO_DECL1);
+void sp_restart_intercepts_out(PROTO_DECL1);
+void sp_set_first_band_out(PROTO_DECL2 point_t Pmin, point_t Pmax);
+void sp_reduce_band_size_out(PROTO_DECL1);
+boolean sp_next_band_out(PROTO_DECL1);
+#endif
+
+#if INCL_USEROUT
+boolean sp_init_userout(specs_t *specsarg);
+#endif
+
+
+/* reset.c functions */
+void sp_reset(PROTO_DECL1);
+#if INCL_KEYS
+void sp_set_key(PROTO_DECL2 ufix8 key[]);
+#endif
+ufix16 sp_get_cust_no(PROTO_DECL2 buff_t font_buff);
+
+/* set_spcs.c functions */
+boolean sp_set_specs(PROTO_DECL2 specs_t STACKFAR *specsarg);
+void sp_type_tcb(PROTO_DECL2 tcb_t GLOBALFAR *ptcb);
+
+fix31 sp_read_long(PROTO_DECL2 ufix8 FONTFAR *pointer);
+fix15 sp_read_word_u(PROTO_DECL2 ufix8 FONTFAR *pointer);
+
+/* set_trns.c functions */
+void sp_init_tcb(PROTO_DECL1);
+void sp_scale_tcb(PROTO_DECL2 tcb_t GLOBALFAR *ptcb,fix15 x_pos,fix15 y_pos,fix15 x_scale,fix15 y_scale);
+ufix8 FONTFAR *sp_plaid_tcb(PROTO_DECL2 ufix8 FONTFAR *pointer,ufix8 format);
+ufix8 FONTFAR *sp_skip_interpolation_table(PROTO_DECL2 ufix8 FONTFAR *pointer, ufix8 format);
+ufix8 FONTFAR *sp_skip_control_zone(PROTO_DECL2 ufix8 FONTFAR *pointer, ufix8 format);
+
+ufix8 FONTFAR *sp_read_oru_table(PROTO_DECL2 ufix8 FONTFAR *pointer);
+#if INCL_SQUEEZING || INCL_ISW
+static void sp_calculate_x_pix(PROTO_DECL2 ufix8 start_edge,ufix8 end_edge,ufix16 constr_nr,fix31 x_scale,fix31 x_offset,fix31 ppo,fix15 setwidth_pix);
+#endif
+#if INCL_SQUEEZING
+static void sp_calculate_y_pix(PROTO_DECL2 ufix8 start_edge,ufix8 end_edge,ufix16 constr_nr,fix31 top_scale,fix31 bottom_scale,fix31 ppo,fix15 emtop_pix,fix15 embot_pix);
+boolean sp_calculate_x_scale(PROTO_DECL2 fix31 *x_factor,fix31 *x_offset,fix15 no_x_ctrl_zones);
+boolean sp_calculate_y_scale(PROTO_DECL2 fix31 *top_scale,fix31 *bottom_scale,fix15 first_y_zone, fix15 no_Y_ctrl_zones);
+#endif
+
+
+/* user defined functions */
+
+void sp_report_error(PROTO_DECL2 fix15 n);
+
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+void sp_open_bitmap(PROTO_DECL2 fix31 x_set_width, fix31 y_set_width, fix31 xorg, fix31 yorg, fix15 xsize,fix15 ysize);
+void sp_set_bitmap_bits(PROTO_DECL2 fix15 y, fix15 xbit1, fix15 xbit2);
+void sp_close_bitmap(PROTO_DECL1);
+#endif
+
+#if INCL_OUTLINE
+void sp_open_outline(PROTO_DECL2 fix31 x_set_width, fix31 y_set_width, fix31 xmin, fix31 xmax, fix31 ymin,fix31 ymax);
+void sp_start_new_char(PROTO_DECL1);
+void sp_start_contour(PROTO_DECL2 fix31 x,fix31 y,boolean outside);
+void sp_curve_to(PROTO_DECL2 fix31 x1, fix31 y1, fix31 x2, fix31 y2, fix31 x3, fix31 y3);
+void sp_line_to(PROTO_DECL2 fix31 x, fix31 y);
+void sp_close_contour(PROTO_DECL1);
+void sp_close_outline(PROTO_DECL1);
+#endif
+
+#if INCL_LCD /* Dynamic load character data supported? */
+buff_t *sp_load_char_data(PROTO_DECL2 fix31 file_offset,fix15 no_bytes,fix15 cb_offset); /* Load character data from font file */
+#endif
+
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+void sp_record_xint(PROTO_DECL2 fix15 int_num); /* Record xint data */
+void sp_record_yint(PROTO_DECL2 fix15 int_num); /* Record yint data */
+void sp_begin_plaid_data(PROTO_DECL1); /* Signal start of plaid data */
+void sp_begin_ctrl_zones(PROTO_DECL2 fix15, no_X_zones, fix15 no_Y_zones); /* Signal start of control zones */
+void sp_record_ctrl_zone(PROTO_DECL2 fix31 start, fix31 end, fix15 constr); /* Record control zone data */
+void sp_begin_int_zones(PROTO_DECL2 fix15 no_X_int_zones, fix15 no_Y_int_zones); /* Signal start of interpolation zones */
+void sp_record_int_zone(PROTO_DECL2 fix31 start, fix31 end); /* Record interpolation zone data */
+void sp_end_plaid_data(PROTO_DECL1); /* Signal end of plaid data */
+#endif
+
+#endif /* _SPEEDO_H_ */
diff --git a/nx-X11/lib/font/Speedo/spencode.c b/nx-X11/lib/font/Speedo/spencode.c
new file mode 100644
index 000000000..96a13504a
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/spencode.c
@@ -0,0 +1,67 @@
+/* $Xorg: spencode.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR 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, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/spencode.c,v 1.6 2001/01/17 19:43:18 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "spint.h"
+
+/* No longer needed with new encoding code */
+/* #include "bics-iso.h"
+
+int sp_bics_map_size = (sizeof(sp_bics_map) / (sizeof(int) * 2));*/
+
+#ifdef EXTRAFONTS
+#include "adobe-iso.h"
+
+int adobe_map_size = (sizeof(adobe_map) / (sizeof(int) * 2));
+
+#endif /* EXTRAFONTS */
diff --git a/nx-X11/lib/font/Speedo/sperr.c b/nx-X11/lib/font/Speedo/sperr.c
new file mode 100644
index 000000000..36ce51125
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/sperr.c
@@ -0,0 +1,127 @@
+/* $Xorg: sperr.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of M.I.T., Network Computing Devices,
+ * or Digital not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. M.I.T. Network Computing Devices, or Digital
+ * make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES, DIGITAL AND MIT DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES, DIGITAL OR MIT 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 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/sperr.c,v 1.6 2001/12/14 19:56:41 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "spint.h"
+
+#ifndef FONTMODULE
+#include <stdarg.h>
+#endif
+
+extern void ErrorF(const char* f, ...);
+
+void
+SpeedoErr(char *str, ...)
+{
+ va_list v;
+ int a1;
+
+ va_start(v, str);
+ ErrorF("Speedo: ");
+ a1 = va_arg(v, int);
+ ErrorF(str, a1);
+ va_end(v);
+}
+
+/*
+ * Called by Speedo character generator to report an error.
+ *
+ * Since character data not available is one of those errors
+ * that happens many times, don't report it to user
+ */
+void
+sp_report_error(fix15 n)
+{
+ switch (n) {
+ case 1:
+ SpeedoErr("Insufficient font data loaded\n");
+ break;
+ case 3:
+ SpeedoErr("Transformation matrix out of range\n");
+ break;
+ case 4:
+ SpeedoErr("Font format error\n");
+ break;
+ case 5:
+ SpeedoErr("Requested specs not compatible with output module\n");
+ break;
+ case 7:
+ SpeedoErr("Intelligent transformation requested but not supported\n");
+ break;
+ case 8:
+ SpeedoErr("Unsupported output mode requested\n");
+ break;
+ case 9:
+ SpeedoErr("Extended font loaded but only compact fonts supported\n");
+ break;
+ case 10:
+ SpeedoErr("Font specs not set prior to use of font\n");
+ break;
+ case 12:
+ break;
+ case 13:
+ SpeedoErr("Track kerning data not available()\n");
+ break;
+ case 14:
+ SpeedoErr("Pair kerning data not available()\n");
+ break;
+ default:
+ SpeedoErr("report_error(%d)\n", n);
+ break;
+ }
+}
diff --git a/nx-X11/lib/font/Speedo/spfile.c b/nx-X11/lib/font/Speedo/spfile.c
new file mode 100644
index 000000000..c58c0e471
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/spfile.c
@@ -0,0 +1,460 @@
+/* $Xorg: spfile.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL
+ * 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.
+ *
+ * Author: Dave Lemke, Network Computing Devices Inc
+ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/spfile.c,v 1.13 2001/08/13 21:46:47 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/fontenc.h>
+#ifndef FONTMODULE
+#include <stdio.h>
+#else
+#include "xf86_ansic.h"
+#endif
+
+#include "spint.h"
+#include "bics-unicode.h"
+
+SpeedoFontPtr sp_fp_cur = (SpeedoFontPtr) 0;
+
+#ifdef EXTRAFONTS
+#include "ncdkeys.h"
+#endif
+
+#include "keys.h"
+
+#ifdef EXTRAFONTS
+static ufix8 skey[] =
+{
+ SKEY0,
+ SKEY1,
+ SKEY2,
+ SKEY3,
+ SKEY4,
+ SKEY5,
+ SKEY6,
+ SKEY7,
+ SKEY8
+}; /* Sample Font decryption key */
+
+static ufix8 rkey[] =
+{
+ RKEY0,
+ RKEY1,
+ RKEY2,
+ RKEY3,
+ RKEY4,
+ RKEY5,
+ RKEY6,
+ RKEY7,
+ RKEY8
+}; /* Retail Font decryption key */
+
+#endif /* EXTRAFONTS */
+
+#ifdef XSAMPLEFONTS
+static ufix8 xkey[] =
+{
+ XKEY0,
+ XKEY1,
+ XKEY2,
+ XKEY3,
+ XKEY4,
+ XKEY5,
+ XKEY6,
+ XKEY7,
+ XKEY8
+}; /* Sample Font decryption key */
+#endif
+
+static ufix8 mkey[] =
+{
+ KEY0,
+ KEY1,
+ KEY2,
+ KEY3,
+ KEY4,
+ KEY5,
+ KEY6,
+ KEY7,
+ KEY8
+}; /* Font decryption key */
+
+
+static fix15
+read_2b(ufix8 *ptr)
+{
+ fix15 tmp;
+
+ tmp = *ptr++;
+ tmp = (tmp << 8) + *ptr;
+ return tmp;
+}
+
+static fix31
+read_4b(ufix8 *ptr)
+{
+ fix31 tmp;
+
+ tmp = *ptr++;
+ tmp = (tmp << 8) + *ptr++;
+ tmp = (tmp << 8) + *ptr++;
+ tmp = (tmp << 8) + *ptr;
+ return tmp;
+}
+
+/*
+ * loads the specified char's data
+ */
+buff_t *
+sp_load_char_data(fix31 file_offset, fix15 num, fix15 cb_offset)
+{
+ SpeedoMasterFontPtr master = sp_fp_cur->master;
+
+ if (fseek(master->fp, (long) file_offset, (int) 0)) {
+ SpeedoErr("can't seek to char\n");
+ }
+ if ((num + cb_offset) > master->mincharsize) {
+ SpeedoErr("char buf overflow\n");
+ }
+ if (fread((master->c_buffer + cb_offset), sizeof(ufix8), num,
+ master->fp) != num) {
+ SpeedoErr("can't get char data\n");
+ }
+ master->char_data.org = (ufix8 *) master->c_buffer + cb_offset;
+ master->char_data.no_bytes = num;
+
+ return &master->char_data;
+}
+
+struct speedo_encoding {
+ char *name;
+ int *enc;
+ int enc_size;
+};
+
+/* Takes care of caching encodings already referenced */
+static int
+find_encoding(const char *fontname, const char *filename,
+ int **enc, int *enc_size)
+{
+ static struct speedo_encoding *known_encodings=0;
+ static int number_known_encodings=0;
+ static int known_encodings_size=0;
+
+ char *encoding_name;
+ int iso8859_1;
+ FontMapPtr mapping;
+ int i, j, k, size;
+ struct speedo_encoding *temp;
+ int *new_enc;
+ char *new_name;
+
+ iso8859_1 = 0;
+
+ encoding_name = FontEncFromXLFD(fontname, strlen(fontname));
+ if(!encoding_name) {
+ encoding_name="iso8859-1";
+ iso8859_1=1;
+ }
+ /* We don't go through the font library if asked for Latin-1 */
+ iso8859_1 = iso8859_1 || !strcmp(encoding_name, "iso8859-1");
+
+ for(i=0; i<number_known_encodings; i++) {
+ if(!strcmp(encoding_name, known_encodings[i].name)) {
+ *enc=known_encodings[i].enc;
+ *enc_size=known_encodings[i].enc_size;
+ return Successful;
+ }
+ }
+
+ /* it hasn't been cached yet, need to compute it */
+
+ /* ensure we've got enough storage first */
+
+ if(known_encodings==0) {
+ if((known_encodings=
+ (struct speedo_encoding*)xalloc(2*sizeof(struct speedo_encoding)))
+ ==0)
+ return AllocError;
+ number_known_encodings=0;
+ known_encodings_size=2;
+ }
+
+ if(number_known_encodings >= known_encodings_size) {
+ if((temp=
+ (struct speedo_encoding*)xrealloc(known_encodings,
+ 2*sizeof(struct speedo_encoding)*
+ known_encodings_size))==0)
+ return AllocError;
+ known_encodings=temp;
+ known_encodings_size*=2;
+ }
+
+ mapping=0;
+ if(!iso8859_1) {
+ mapping = FontEncMapFind(encoding_name,
+ FONT_ENCODING_UNICODE, -1, -1,
+ filename);
+ }
+#define SPEEDO_RECODE(c) \
+ (mapping? \
+ unicode_to_bics(FontEncRecode(c, mapping)): \
+ unicode_to_bics(c))
+
+ if((new_name = (char*)xalloc(strlen(encoding_name)))==0)
+ return AllocError;
+ strcpy(new_name, encoding_name);
+
+ /* For now, we limit ourselves to 256 glyphs */
+ size=0;
+ for(i=0; i < (mapping?mapping->encoding->size:256) && i < 256; i++)
+ if(SPEEDO_RECODE(i)>=0)
+ size++;
+ new_enc = (int*)xalloc(2*size*sizeof(int));
+ if(!new_enc) {
+ xfree(new_name);
+ return AllocError;
+ }
+ for(i=j=0; i < (mapping?mapping->encoding->size:256) && i < 256; i++)
+ if((k = SPEEDO_RECODE(i))>=0) {
+ new_enc[2*j] = i;
+ new_enc[2*j+1] = k;
+ j++;
+ }
+ known_encodings[number_known_encodings].name = new_name;
+ known_encodings[number_known_encodings].enc = new_enc;
+ known_encodings[number_known_encodings].enc_size = size;
+ number_known_encodings++;
+
+ *enc = new_enc;
+ *enc_size = size;
+ return Successful;
+#undef SPEEDO_RECODE
+}
+
+int
+sp_open_master(const char *fontname, const char *filename,
+ SpeedoMasterFontPtr *master)
+{
+ SpeedoMasterFontPtr spmf;
+ ufix8 tmp[16];
+ ufix16 cust_no;
+ FILE *fp;
+ ufix32 minbufsize;
+ ufix16 mincharsize;
+ ufix8 *f_buffer;
+ ufix8 *c_buffer;
+ int ret;
+ ufix8 *key;
+
+ spmf = (SpeedoMasterFontPtr) xalloc(sizeof(SpeedoMasterFontRec));
+ if (!spmf)
+ return AllocError;
+ bzero(spmf, sizeof(SpeedoMasterFontRec));
+ spmf->entry = NULL;
+ spmf->f_buffer = NULL;
+ spmf->c_buffer = NULL;
+
+ /* open font */
+ spmf->fname = (char *) xalloc(strlen(filename) + 1);
+ if (!spmf->fname)
+ return AllocError;
+ fp = fopen(filename, "r");
+ if (!fp) {
+ ret = BadFontName;
+ goto cleanup;
+ }
+ strcpy(spmf->fname, filename);
+ spmf->fp = fp;
+ spmf->state |= MasterFileOpen;
+
+ if (fread(tmp, sizeof(ufix8), 16, fp) != 16) {
+ ret = BadFontName;
+ goto cleanup;
+ }
+ minbufsize = (ufix32) read_4b(tmp + FH_FBFSZ);
+ f_buffer = (ufix8 *) xalloc(minbufsize);
+ if (!f_buffer) {
+ ret = AllocError;
+ goto cleanup;
+ }
+ spmf->f_buffer = f_buffer;
+
+ fseek(fp, (ufix32) 0, 0);
+
+ /* read in the font */
+ if (fread(f_buffer, sizeof(ufix8), (ufix16) minbufsize, fp) != minbufsize) {
+ ret = BadFontName;
+ goto cleanup;
+ }
+ spmf->copyright = (char *) (f_buffer + FH_CPYRT);
+ spmf->mincharsize = mincharsize = read_2b(f_buffer + FH_CBFSZ);
+
+ c_buffer = (ufix8 *) xalloc(mincharsize);
+ if (!c_buffer) {
+ ret = AllocError;
+ goto cleanup;
+ }
+ spmf->c_buffer = c_buffer;
+
+ spmf->font.org = spmf->f_buffer;
+ spmf->font.no_bytes = minbufsize;
+
+ cust_no = sp_get_cust_no(spmf->font);
+
+ /* XXX add custom encryption stuff here */
+
+#ifdef EXTRAFONTS
+ if (cust_no == SCUS0) {
+ key = skey;
+ } else if (cust_no == RCUS0) {
+ key = rkey;
+ } else
+#endif
+
+#ifdef XSAMPLEFONTS
+ if (cust_no == XCUS0) {
+ key = xkey;
+ } else
+#endif
+
+ if (cust_no == CUS0) {
+ key = mkey;
+ } else {
+ SpeedoErr("Non - standard encryption for \"%s\"\n", filename);
+ ret = BadFontName;
+ goto cleanup;
+ }
+ spmf->key = key;
+ sp_set_key(key);
+
+ spmf->first_char_id = read_2b(f_buffer + FH_FCHRF);
+ spmf->num_chars = read_2b(f_buffer + FH_NCHRL);
+
+
+ spmf->enc = 0;
+ spmf->enc_size = 0;
+
+#ifdef EXTRAFONTS
+ { /* choose the proper encoding */
+ char *f;
+
+ f = strrchr(filename, '/');
+ if (f) {
+ f++;
+ if (strncmp(f, "bx113", 5) == 0) {
+ spmf->enc = adobe_map;
+ spmf->enc_size = adobe_map_size;
+ }
+ }
+ }
+#endif
+
+ if(!spmf->enc)
+ if((ret=find_encoding(fontname, filename, &spmf->enc, &spmf->enc_size))
+ !=Successful)
+ goto cleanup;
+
+ spmf->first_char_id = spmf->enc[0];
+ /* size of extents array */
+ spmf->max_id = spmf->enc[(spmf->enc_size - 1) * 2];
+ spmf->num_chars = spmf->enc_size;
+
+ *master = spmf;
+
+ return Successful;
+
+cleanup:
+ *master = (SpeedoMasterFontPtr) 0;
+ sp_close_master_font(spmf);
+ return ret;
+}
+
+void
+sp_close_master_font(SpeedoMasterFontPtr spmf)
+{
+ if (!spmf)
+ return;
+ if (spmf->state & MasterFileOpen)
+ fclose(spmf->fp);
+ if (spmf->entry)
+ spmf->entry->u.scalable.extra->private = NULL;
+ xfree(spmf->fname);
+ xfree(spmf->f_buffer);
+ xfree(spmf->c_buffer);
+ xfree(spmf);
+}
+
+void
+sp_close_master_file(SpeedoMasterFontPtr spmf)
+{
+ (void) fclose(spmf->fp);
+ spmf->state &= ~MasterFileOpen;
+}
+
+
+/*
+ * reset the encryption key, and make sure the file is opened
+ */
+void
+sp_reset_master(SpeedoMasterFontPtr spmf)
+{
+ sp_set_key(spmf->key);
+ if (!(spmf->state & MasterFileOpen)) {
+ spmf->fp = fopen(spmf->fname, "r");
+ /* XXX -- what to do if we can't open the file? */
+ spmf->state |= MasterFileOpen;
+ }
+ fseek(spmf->fp, 0, 0);
+}
diff --git a/nx-X11/lib/font/Speedo/spfont.c b/nx-X11/lib/font/Speedo/spfont.c
new file mode 100644
index 000000000..c209d5a51
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/spfont.c
@@ -0,0 +1,453 @@
+/* $Xorg: spfont.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR 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.
+ *
+ * Author: Dave Lemke, Network Computing Devices Inc
+ */
+/* $XFree86: xc/lib/font/Speedo/spfont.c,v 3.12tsi 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.
+
+*/
+
+/*
+ * Speedo font loading
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/FSproto.h>
+#include "spint.h"
+#include <X11/fonts/fontutil.h>
+#ifndef FONTMODULE
+#ifdef _XOPEN_SOURCE
+#include <math.h>
+#else
+#define _XOPEN_SOURCE /* to get prototype for hypot on some systems */
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+#else
+#include "servermd.h"
+#include "xf86_ansic.h"
+#endif
+
+#ifndef M_PI
+#define M_PI 3.14159
+#endif /* M_PI */
+#ifndef DEFAULT_BIT_ORDER
+
+#ifdef BITMAP_BIT_ORDER
+#define DEFAULT_BIT_ORDER BITMAP_BIT_ORDER
+#else
+#define DEFAULT_BIT_ORDER UNKNOWN_BIT_ORDER
+#endif
+
+#endif
+
+static void SpeedoCloseFont(FontPtr pfont);
+
+static int
+sp_get_glyphs(
+ FontPtr pFont,
+ unsigned long count,
+ register unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
+{
+ SpeedoFontPtr spf;
+ unsigned int firstCol;
+ register unsigned int numCols;
+ unsigned int firstRow;
+ unsigned int numRows;
+ CharInfoPtr *glyphsBase;
+ register unsigned int c;
+ register CharInfoPtr pci;
+ unsigned int r;
+ CharInfoPtr encoding;
+ CharInfoPtr pDefault;
+#ifdef notyet
+ int itemSize;
+#endif
+ int err = Successful;
+
+ spf = (SpeedoFontPtr) pFont->fontPrivate;
+ encoding = spf->encoding;
+ pDefault = spf->pDefault;
+ firstCol = pFont->info.firstCol;
+ numCols = pFont->info.lastCol - firstCol + 1;
+ glyphsBase = glyphs;
+
+
+ /* XXX - this should be much smarter */
+ /* make sure the glyphs are there */
+#ifdef notyet
+ if (charEncoding == Linear8Bit || charEncoding == TwoD8Bit)
+ itemSize = 1;
+ else
+ itemSize = 2;
+
+ if (!fsd->complete)
+ err = fs_load_glyphs(NULL, pFont, count, itemSize, chars);
+#endif
+
+ if (err != Successful)
+ return err;
+
+ switch (charEncoding) {
+
+ case Linear8Bit:
+ case TwoD8Bit:
+ if (pFont->info.firstRow > 0)
+ break;
+ if (pFont->info.allExist && pDefault) {
+ while (count--) {
+ c = (*chars++) - firstCol;
+ if (c < numCols)
+ *glyphs++ = &encoding[c];
+ else
+ *glyphs++ = pDefault;
+ }
+ } else {
+ while (count--) {
+ c = (*chars++) - firstCol;
+ if (c < numCols && (pci = &encoding[c])->bits)
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ }
+ break;
+ case Linear16Bit:
+ if (pFont->info.allExist && pDefault) {
+ while (count--) {
+ c = *chars++ << 8;
+ c = (c | *chars++) - firstCol;
+ if (c < numCols)
+ *glyphs++ = &encoding[c];
+ else
+ *glyphs++ = pDefault;
+ }
+ } else {
+ while (count--) {
+ c = *chars++ << 8;
+ c = (c | *chars++) - firstCol;
+ if (c < numCols && (pci = &encoding[c])->bits)
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ }
+ break;
+
+ case TwoD16Bit:
+ firstRow = pFont->info.firstRow;
+ numRows = pFont->info.lastRow - firstRow + 1;
+ while (count--) {
+ r = (*chars++) - firstRow;
+ c = (*chars++) - firstCol;
+ if (r < numRows && c < numCols &&
+ (pci = &encoding[r * numCols + c])->bits)
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ }
+ *glyphCount = glyphs - glyphsBase;
+ return Successful;
+}
+
+static CharInfoRec nonExistantChar;
+
+static int
+sp_get_metrics(
+ FontPtr pFont,
+ unsigned long count,
+ register unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ xCharInfo **glyphs) /* RETURN */
+{
+ int ret;
+ SpeedoFontPtr spf;
+ CharInfoPtr oldDefault;
+
+ spf = (SpeedoFontPtr) pFont->fontPrivate;
+ oldDefault = spf->pDefault;
+ spf->pDefault = &nonExistantChar;
+ ret = sp_get_glyphs(pFont, count, chars, charEncoding,
+ glyphCount, (CharInfoPtr *) glyphs);
+
+ spf->pDefault = oldDefault;
+ return ret;
+}
+
+int
+sp_open_font(
+ char *fontname,
+ char *filename,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ Mask flags,
+ SpeedoFontPtr *spfont)
+{
+ SpeedoFontPtr spf;
+ SpeedoMasterFontPtr spmf;
+ int ret;
+ specs_t specs;
+ int xx8, xy8, yx8, yy8;
+
+ /* find a master (create it if necessary) */
+ spmf = (SpeedoMasterFontPtr) entry->u.scalable.extra->private;
+ if (!spmf)
+ {
+ ret = sp_open_master(fontname, filename, &spmf);
+ if (ret != Successful)
+ return ret;
+ entry->u.scalable.extra->private = (pointer) spmf;
+ spmf->entry = entry;
+ }
+
+ spf = (SpeedoFontPtr) xalloc(sizeof(SpeedoFontRec));
+ if (!spf)
+ return AllocError;
+ bzero((char *) spf, sizeof(SpeedoFontRec));
+
+ *spfont = spf;
+
+ /* clobber everything -- this may be leaking, but other wise evil
+ * stuff is left behind -- succesive transformed fonts get mangled */
+ bzero((char *)&sp_globals, sizeof(sp_globals));
+
+ spf->master = spmf;
+ spf->entry = entry;
+ spmf->refcount++;
+ sp_reset_master(spmf);
+ /* now we've done enough that if we bail out we must call sp_close_font */
+
+ spf->vals = *vals;
+
+ /* set up specs */
+
+ specs.pfont = &spmf->font;
+
+ specs.xxmult = (int)(vals->pixel_matrix[0] * (double)(1L << 16));
+ specs.xymult = (int)(vals->pixel_matrix[2] * (double)(1L << 16));
+ specs.yxmult = (int)(vals->pixel_matrix[1] * (double)(1L << 16));
+ specs.yymult = (int)(vals->pixel_matrix[3] * (double)(1L << 16));
+
+ specs.xoffset = 0L << 16; /* XXX tweak? */
+ specs.yoffset = 0L << 16; /* XXX tweak? */
+
+ specs.flags = MODE_SCREEN;
+ specs.out_info = NULL;
+
+ /* When Speedo tries to generate a very small font bitmap, it
+ often crashes or goes into an infinite loop.
+ Don't know why this is so, but until we can fix it properly,
+ return BadFontName for anything smaller than 4 pixels.
+ */
+#define TINY_FACTOR (16 << 16)
+ xx8 = specs.xxmult >> 8;
+ xy8 = specs.xymult >> 8;
+ yx8 = specs.yxmult >> 8;
+ yy8 = specs.yymult >> 8;
+ if (xx8 * xx8 + xy8 * xy8 < TINY_FACTOR ||
+ yx8 * yx8 + yy8 * yy8 < TINY_FACTOR)
+ {
+ sp_close_font(spf);
+ return BadFontName;
+ }
+
+ /* clobber global state to avoid wrecking future transformed fonts */
+ bzero ((char *) &sp_globals, sizeof(sp_globals));
+
+ if (!sp_set_specs(&specs))
+ {
+ sp_close_font(spf);
+ return BadFontName;
+ }
+
+ spf->specs = specs;
+ spf->master = spmf;
+
+ *spfont = spf;
+ return Successful;
+}
+
+static int
+sp_load_font(
+ char *fontname,
+ char *filename,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr pfont,
+ Mask flags)
+{
+ SpeedoFontPtr spf;
+ SpeedoMasterFontPtr spmf;
+ int esize;
+ int ret;
+ long sWidth;
+
+ ret = sp_open_font(fontname, filename, entry, vals, format, fmask,
+ flags, &spf);
+
+ if (ret != Successful)
+ return ret;
+
+ spmf = spf->master;
+ sp_reset_master(spmf);
+ esize = sizeof(CharInfoRec) * (spmf->max_id - spmf->first_char_id + 1);
+
+ spf->encoding = (CharInfoPtr) xalloc(esize);
+ if (!spf->encoding) {
+ sp_close_font(spf);
+ return AllocError;
+ }
+ bzero((char *) spf->encoding, esize);
+
+ sp_fp_cur = spf;
+
+ sp_make_header(spf, &pfont->info);
+
+ sp_compute_bounds(spf, &pfont->info, SaveMetrics, &sWidth);
+
+ sp_compute_props(spf, fontname, &pfont->info, sWidth);
+
+ pfont->fontPrivate = (pointer) spf;
+
+/* XXX */
+ flags |= FontLoadBitmaps;
+
+ if (flags & FontLoadBitmaps) {
+ sp_fp_cur = spf;
+ ret = sp_build_all_bitmaps(pfont, format, fmask);
+ }
+ if (ret != Successful)
+ return ret;
+
+ /* compute remaining accelerators */
+ FontComputeInfoAccelerators(&pfont->info);
+
+ pfont->format = format;
+
+ pfont->get_metrics = sp_get_metrics;
+ pfont->get_glyphs = sp_get_glyphs;
+ pfont->unload_font = SpeedoCloseFont;
+ pfont->unload_glyphs = NULL;
+ pfont->refcnt = 0;
+
+ /* have to hold on to master for min/max id */
+ sp_close_master_file(spmf);
+
+ return ret;
+}
+
+int
+SpeedoFontLoad(
+ FontPtr *ppfont,
+ char *fontname,
+ char *filename,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ Mask flags)
+{
+ FontPtr pfont;
+ int ret;
+
+ /* Reject ridiculously small sizes that will blow up the math */
+ if (hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]) < 1.0 ||
+ hypot(vals->pixel_matrix[2], vals->pixel_matrix[3]) < 1.0)
+ return BadFontName;
+
+ if (!(pfont = CreateFontRec()))
+ return AllocError;
+
+ ret = sp_load_font(fontname, filename, entry, vals, format, fmask,
+ pfont, flags);
+
+ if (ret == Successful)
+ *ppfont = pfont;
+ else
+ DestroyFontRec (pfont);
+
+ return ret;
+}
+
+void
+sp_close_font(SpeedoFontPtr spf)
+{
+ SpeedoMasterFontPtr spmf;
+
+ spmf = spf->master;
+ --spmf->refcount;
+ if (spmf->refcount == 0)
+ sp_close_master_font (spmf);
+ xfree(spf->encoding);
+ xfree(spf->bitmaps);
+ xfree(spf);
+}
+
+static void
+SpeedoCloseFont(FontPtr pfont)
+{
+ SpeedoFontPtr spf;
+
+ spf = (SpeedoFontPtr) pfont->fontPrivate;
+ sp_close_font(spf);
+ xfree(pfont->info.isStringProp);
+ xfree(pfont->info.props);
+ DestroyFontRec(pfont);
+
+}
diff --git a/nx-X11/lib/font/Speedo/spfuncs.c b/nx-X11/lib/font/Speedo/spfuncs.c
new file mode 100644
index 000000000..da4d5c55e
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/spfuncs.c
@@ -0,0 +1,167 @@
+/* $Xorg: spfuncs.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR 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.
+ *
+ * Author: Dave Lemke, Network Computing Devices, Inc
+ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/spfuncs.c,v 1.7 2001/08/27 19:49:51 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifndef FONTMODULE
+#include <X11/Xos.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/fontutil.h>
+#include "spint.h"
+
+/* ARGSUSED */
+static int
+SpeedoOpenScalable (
+ FontPathElementPtr fpe,
+ FontPtr *pFont,
+ int flags,
+ FontEntryPtr entry,
+ char *fileName,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font) /* We don't do licensing */
+{
+ char fullName[MAXFONTNAMELEN];
+
+ strcpy (fullName, entry->name.name);
+ return SpeedoFontLoad (pFont, fullName, fileName, entry, vals,
+ format, fmask, flags);
+}
+
+/*
+ * XXX
+ *
+ * this does a lot more then i'd like, but it has to get the bitmaps
+ * in order to get accurate metrics (which it *must* have).
+ *
+ * a possible optimization is to avoid allocating the glyph memory
+ * and to simply save the values without doing the work.
+ */
+static int
+get_font_info(
+ FontInfoPtr pinfo,
+ char *fontname,
+ char *filename,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ SpeedoFontPtr *spfont)
+{
+ SpeedoFontPtr spf;
+ int err;
+ long sWidth;
+
+ err = sp_open_font(fontname, filename, entry, vals,
+ (fsBitmapFormat) 0, (fsBitmapFormatMask) 0, (unsigned long) 0,
+ &spf);
+
+ if (err != Successful)
+ return err;
+
+ sp_fp_cur = spf;
+ sp_reset_master(spf->master);
+
+ sp_make_header(spf, pinfo);
+
+ sp_compute_bounds(spf, pinfo, (unsigned long) 0, &sWidth);
+
+ sp_compute_props(spf, fontname, pinfo, sWidth);
+
+ /* compute remaining accelerators */
+ FontComputeInfoAccelerators (pinfo);
+
+ *spfont = spf;
+
+ return Successful;
+}
+
+/* ARGSUSED */
+static int
+SpeedoGetInfoScaleable(
+ FontPathElementPtr fpe,
+ FontInfoPtr pFontInfo,
+ FontEntryPtr entry,
+ FontNamePtr fontName,
+ char *fileName,
+ FontScalablePtr vals)
+{
+ SpeedoFontPtr spf = NULL;
+ char fullName[MAXFONTNAMELEN];
+ int err;
+
+ strcpy(fullName, entry->name.name);
+ FontParseXLFDName(fullName, vals, FONT_XLFD_REPLACE_VALUE);
+
+ err = get_font_info(pFontInfo, fullName, fileName, entry, vals, &spf);
+
+ if (spf)
+ sp_close_font(spf);
+
+ return err;
+}
+
+static FontRendererRec renderer = {
+ ".spd", 4, NULL, SpeedoOpenScalable,
+ NULL, SpeedoGetInfoScaleable, 0
+ , CAP_MATRIX | CAP_CHARSUBSETTING
+};
+
+void
+SpeedoRegisterFontFileFunctions()
+{
+ sp_make_standard_props();
+ sp_reset();
+ FontFileRegisterRenderer(&renderer);
+}
diff --git a/nx-X11/lib/font/Speedo/spglyph.c b/nx-X11/lib/font/Speedo/spglyph.c
new file mode 100644
index 000000000..3577f5567
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/spglyph.c
@@ -0,0 +1,399 @@
+/* $Xorg: spglyph.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR 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.
+ *
+ * Author: Dave Lemke, Network Computing Devices Inc
+ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/spglyph.c,v 1.6 2001/01/17 19:43:20 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/X.h> /* for bit order #defines */
+#include "spint.h"
+#include <X11/fonts/fontutil.h>
+
+#undef CLIP_BBOX_NOISE
+
+static CurrentFontValuesRec current_font_values;
+static CurrentFontValuesPtr cfv = &current_font_values;
+static int bit_order,
+ byte_order,
+ scan;
+
+unsigned long
+sp_compute_data_size(
+ FontPtr pfont,
+ int mappad,
+ int scanlinepad,
+ unsigned long start,
+ unsigned long end)
+{
+ unsigned long ch;
+ unsigned long size = 0;
+ int bpr;
+ SpeedoFontPtr spf = (SpeedoFontPtr) pfont->fontPrivate;
+ FontInfoPtr pinfo = &pfont->info;
+ int firstChar;
+
+ firstChar = spf->master->first_char_id;
+
+ /* allocate the space */
+ switch (mappad) {
+ int charsize;
+ CharInfoPtr ci;
+ xCharInfo *cim;
+
+ case BitmapFormatImageRectMin:
+ cfv->bpr = 0;
+ for (ch = start; ch <= end; ch++) {
+ ci = &spf->encoding[ch - firstChar];
+ if (!ci)
+ ci = spf->pDefault;
+ cim = &ci->metrics;
+ charsize = GLYPH_SIZE(ci, scanlinepad);
+ charsize *= cim->ascent + cim->descent;
+ size += charsize;
+ }
+ break;
+ case BitmapFormatImageRectMaxWidth:
+ bpr = GLWIDTHBYTESPADDED(FONT_MAX_WIDTH(pinfo), scanlinepad);
+ cfv->bpr = bpr;
+ for (ch = start; ch <= end; ch++) {
+ ci = &spf->encoding[ch - firstChar];
+ if (!ci)
+ ci = spf->pDefault;
+ cim = &ci->metrics;
+ charsize = bpr * (cim->ascent + cim->descent);
+ size += charsize;
+ }
+ break;
+ case BitmapFormatImageRectMax:
+ bpr = GLWIDTHBYTESPADDED(FONT_MAX_WIDTH(pinfo), scanlinepad);
+ cfv->bpr = bpr;
+ size = (end - start + 1) * bpr * FONT_MAX_HEIGHT(pinfo);
+ break;
+ default:
+ assert(0);
+ }
+
+ return size;
+}
+
+static void
+finish_line(SpeedoFontPtr spf)
+{
+ int bpr = cfv->bpr;
+ CharInfoPtr ci = &spf->encoding[cfv->char_id - spf->master->first_char_id];
+
+ if (bpr == 0) {
+ bpr = GLYPH_SIZE(ci, cfv->scanpad);
+ }
+ if (bpr) { /* char may not have any metrics... */
+ cfv->bp = (char *)cfv->bp + bpr;
+ }
+ assert(cfv->bp - sp_fp_cur->bitmaps <= sp_fp_cur->bitmap_size);
+}
+
+
+void
+sp_set_bitmap_bits(fix15 y, fix15 xbit1, fix15 xbit2)
+{
+ int nmiddle;
+ CARD8 startmask,
+ endmask;
+ CARD8 *dst;
+
+ if (xbit1 > cfv->bit_width) {
+
+#ifdef CLIP_BBOX_NOISE
+ SpeedoErr("Run wider than bitmap width -- truncated\n");
+#endif
+
+ xbit1 = cfv->bit_width;
+ }
+ if (xbit2 > cfv->bit_width) {
+
+#ifdef CLIP_BBOX_NOISE
+ SpeedoErr("Run wider than bitmap width -- truncated\n");
+#endif
+
+ xbit2 = cfv->bit_width;
+ }
+
+ if (xbit2 < xbit1) {
+ xbit2 = xbit1;
+ }
+
+ while (cfv->cur_y != y) {
+ finish_line(sp_fp_cur);
+ cfv->cur_y++;
+ }
+
+ cfv->last_y = y;
+ if (y >= cfv->bit_height) {
+
+#ifdef CLIP_BBOX_NOISE
+ SpeedoErr("Y larger than bitmap height -- truncated\n");
+#endif
+
+ cfv->trunc = 1;
+ return;
+ }
+ if (xbit1 < 0) /* XXX this is more than a little bit rude... */
+ xbit1 = 0;
+
+ nmiddle = (xbit1 >> 3);
+ dst = (CARD8 *)cfv->bp + nmiddle;
+ xbit2 -= (xbit1 & ~7);
+ nmiddle = (xbit2 >> 3);
+ xbit1 &= 7;
+ xbit2 &= 7;
+ if (bit_order == MSBFirst) {
+ startmask = ((CARD8) ~0) >> xbit1;
+ endmask = ~(((CARD8) ~0) >> xbit2);
+ } else {
+ startmask = ((CARD8) ~0) << xbit1;
+ endmask = ~(((CARD8) ~0) << xbit2);
+ }
+ if (nmiddle == 0)
+ *dst |= endmask & startmask;
+ else {
+ *dst++ |= startmask;
+ while (--nmiddle)
+ *dst++ = (CARD8)~0;
+ *dst |= endmask;
+ }
+}
+
+/* ARGSUSED */
+void
+sp_open_bitmap(fix31 x_set_width, fix31 y_set_width, fix31 xorg, fix31 yorg,
+ fix15 xsize, fix15 ysize)
+{
+ CharInfoPtr ci = &sp_fp_cur->encoding[cfv->char_id - sp_fp_cur->master->first_char_id];
+
+/*-
+ * this is set to provide better quality bitmaps. since the Speedo
+ * sp_get_bbox() function returns an approximate (but guarenteed to contain)
+ * set of metrics, some of the bitmaps can be place poorly inside and
+ * look bad.
+ *
+ * with this set, the actual bitmap values are used instead of the bboxes.
+ * it makes things look better, but causes two possible problems:
+ *
+ * 1 - the reported min & max bounds may not correspond to the extents
+ * reported
+ * 2 - if the extents are reported before the character is generated,
+ * a client could see them change. this currently never happens,
+ * but will when a desired enhancement (don't reneder till needed)
+ * is made.
+ */
+
+#define BBOX_FIXUP 1
+
+#ifdef BBOX_FIXUP
+ int off_horz;
+ int off_vert;
+
+ if (xorg < 0)
+ off_horz = (fix15) ((xorg - 32768L) / 65536);
+ else
+ off_horz = (fix15) ((xorg + 32768L) / 65536);
+ if (yorg < 0)
+ off_vert = (fix15) ((yorg - 32768L) / 65536);
+ else
+ off_vert = (fix15) ((yorg + 32768L) / 65536);
+ if (xsize != 0 || ysize != 0 || ci->metrics.characterWidth)
+ {
+ ci->metrics.leftSideBearing = off_horz;
+ ci->metrics.descent = -off_vert;
+ ci->metrics.rightSideBearing = xsize + off_horz;
+ ci->metrics.ascent = ysize + off_vert;
+ }
+ else
+ {
+ /* If setting the proper size would cause the character to appear to
+ be non-existent, fudge things by giving it a pixel to occupy. */
+ xsize = ysize = 1;
+ ci->metrics.leftSideBearing = ci->metrics.descent = 0;
+ ci->metrics.rightSideBearing = ci->metrics.ascent = 1;
+ }
+
+ cfv->bit_width = xsize;
+ cfv->bit_height = ysize;
+#else
+ cfv->bit_width = ci->metrics.rightSideBearing -
+ ci->metrics.leftSideBearing;
+ cfv->bit_height = ci->metrics.ascent + ci->metrics.descent;
+#endif
+
+ assert(cfv->bp - sp_fp_cur->bitmaps <= sp_fp_cur->bitmap_size);
+ ci->bits = (char *) cfv->bp;
+
+ cfv->cur_y = 0;
+}
+
+void
+sp_close_bitmap()
+{
+ CharInfoPtr ci = &sp_fp_cur->encoding[cfv->char_id - sp_fp_cur->master->first_char_id];
+ int bpr = cfv->bpr;
+
+ if (bpr == 0)
+ bpr = GLYPH_SIZE(ci, cfv->scanpad);
+ if (!cfv->trunc)
+ finish_line(sp_fp_cur);
+ cfv->trunc = 0;
+ cfv->last_y++;
+ while (cfv->last_y < cfv->bit_height) {
+ finish_line(sp_fp_cur);
+ cfv->last_y++;
+ }
+ if (byte_order != bit_order) {
+ switch (scan) {
+ case 1:
+ break;
+ case 2:
+ TwoByteSwap(cfv->bp, bpr * cfv->bit_height);
+ break;
+ case 4:
+ FourByteSwap(cfv->bp, bpr * cfv->bit_height);
+ break;
+ }
+ }
+}
+
+int
+sp_build_all_bitmaps(
+ FontPtr pfont,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask)
+{
+ int ret,
+ glyph = 1,
+ image = BitmapFormatImageRectMin;
+ unsigned long glyph_size;
+ SpeedoFontPtr spf = (SpeedoFontPtr) pfont->fontPrivate;
+ SpeedoMasterFontPtr spmf = spf->master;
+ pointer bitmaps;
+ int start,
+ end,
+ i;
+
+ scan = 1;
+ ret = CheckFSFormat(format, fmask,
+ &bit_order, &byte_order, &scan, &glyph, &image);
+
+ pfont->bit = bit_order;
+ pfont->byte = byte_order;
+ pfont->glyph = glyph;
+ pfont->scan = scan;
+ if (ret != Successful)
+ return BadFontFormat;
+
+ start = spmf->first_char_id;
+ end = spmf->max_id;
+ glyph_size = sp_compute_data_size(pfont, image, glyph, start, end);
+
+ /* XXX -- MONDO KLUDGE -- add some slop */
+ /*
+ * not sure why this is wanted, but it keeps the packer from going off the
+ * end and toasting us down the line
+ */
+ glyph_size += 20;
+
+#ifdef DEBUG
+ spf->bitmap_size = glyph_size;
+#endif
+
+ bitmaps = (pointer) xalloc(glyph_size);
+ if (!bitmaps)
+ return AllocError;
+ bzero((char *) bitmaps, glyph_size);
+
+ /* set up some state */
+ sp_fp_cur = spf;
+ spf->bitmaps = bitmaps;
+ cfv->format = format;
+ cfv->scanpad = glyph;
+ cfv->bp = bitmaps;
+
+ for (i = 0; i < spmf->num_chars; i++) {
+ int j;
+ cfv->char_index = spmf->enc[i * 2 + 1];
+ cfv->char_id = spmf->enc[i * 2];
+#ifdef DEBUG
+fprintf(stderr, "build_all_sp_bitmaps:i = %d, Char ID = %d\n", i, cfv->char_id);
+#endif
+ if (!cfv->char_id)
+ continue;
+
+ /*
+ * See if this character is in the list of ranges specified in the
+ * XLFD name
+ */
+ for (j = 0; j < spf->vals.nranges; j++)
+ if (cfv->char_id >= mincharno(spf->vals.ranges[j]) &&
+ cfv->char_id <= maxcharno(spf->vals.ranges[j]))
+ break;
+
+ /* If not, don't realize it. */
+ if (spf->vals.nranges && j == spf->vals.nranges)
+ continue;
+
+ if (!sp_make_char(cfv->char_index)) {
+
+#ifdef DEBUG /* can be very common with some encodings */
+ SpeedoErr("Can't make char %d\n", cfv->char_index);
+#endif
+ }
+ }
+
+ return Successful;
+}
diff --git a/nx-X11/lib/font/Speedo/spinfo.c b/nx-X11/lib/font/Speedo/spinfo.c
new file mode 100644
index 000000000..d7a1edd98
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/spinfo.c
@@ -0,0 +1,462 @@
+/* $Xorg: spinfo.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR 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.
+ *
+ * Author: Dave Lemke, Network Computing Devices, Inc
+ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/spinfo.c,v 1.12 2001/12/14 19:56:42 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/fontutil.h>
+#include "spint.h"
+#ifndef FONTMODULE
+#include <math.h>
+#else
+#include "xf86_ansic.h"
+#endif
+
+/* percentage of pointsize used to specify ascent & descent */
+#define STRETCH_FACTOR 120
+
+enum scaleType {
+ atom, truncate_atom, pixel_size, point_size, resolution_x,
+ resolution_y, average_width
+};
+
+typedef struct _fontProp {
+ char *name;
+ long atom;
+ enum scaleType type;
+} fontProp;
+
+static fontProp fontNamePropTable[] = {
+ { "FOUNDRY", 0, atom },
+ { "FAMILY_NAME", 0, atom },
+ { "WEIGHT_NAME", 0, atom },
+ { "SLANT", 0, atom },
+ { "SETWIDTH_NAME", 0, atom },
+ { "ADD_STYLE_NAME", 0, atom },
+ { "PIXEL_SIZE", 0, pixel_size },
+ { "POINT_SIZE", 0, point_size },
+ { "RESOLUTION_X", 0, resolution_x },
+ { "RESOLUTION_Y", 0, resolution_y },
+ { "SPACING", 0, atom },
+ { "AVERAGE_WIDTH", 0, average_width },
+ { "CHARSET_REGISTRY", 0, atom },
+ { "CHARSET_ENCODING", 0, truncate_atom }
+};
+
+/* Warning: following array is closely related to the sequence of
+ defines after it. */
+
+static fontProp extraProps[] = {
+ { "FONT", 0, },
+ { "COPYRIGHT", 0, },
+ { "RAW_PIXEL_SIZE", 0, },
+ { "RAW_POINT_SIZE", 0, },
+ { "RAW_ASCENT", 0, },
+ { "RAW_DESCENT", 0, },
+ { "RAW_AVERAGE_WIDTH", 0, },
+ { "FONT_TYPE", 0, },
+ { "RASTERIZER_NAME", 0, }
+};
+
+/* this is a bit kludgy */
+#define FONTPROP 0
+#define COPYRIGHTPROP 1
+#define RAWPIXELPROP 2
+#define RAWPOINTPROP 3
+#define RAWASCENTPROP 4
+#define RAWDESCENTPROP 5
+#define RAWWIDTHPROP 6
+#define FONT_TYPEPROP 7
+#define RASTERIZER_NAMEPROP 8
+
+#define NNAMEPROPS (sizeof(fontNamePropTable) / sizeof(fontProp))
+#define NEXTRAPROPS (sizeof(extraProps) / sizeof(fontProp))
+
+#define NPROPS (NNAMEPROPS + NEXTRAPROPS)
+
+void
+sp_make_standard_props()
+{
+ int i;
+ fontProp *t;
+
+ i = sizeof(fontNamePropTable) / sizeof(fontProp);
+ for (t = fontNamePropTable; i; i--, t++)
+ t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+ i = sizeof(extraProps) / sizeof(fontProp);
+ for (t = extraProps; i; i--, t++)
+ t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+}
+
+void
+sp_make_header(
+ SpeedoFontPtr spf,
+ FontInfoPtr pinfo)
+{
+ int pixel_size;
+ SpeedoMasterFontPtr spmf = spf->master;
+
+ pinfo->firstCol = spmf->first_char_id & 0xff;
+ pinfo->firstRow = spmf->first_char_id >> 8;
+ pinfo->lastCol = spmf->max_id & 0xff;
+ pinfo->lastRow = spmf->max_id >> 8;
+
+ /* XXX -- hackery here */
+ pinfo->defaultCh = 0;
+/* computed by FontComputeInfoAccelerators:
+ * noOverlap
+ * constantMetrics
+ * terminalFont
+ * constantWidth
+ * inkInside
+ */
+ pinfo->inkMetrics = 0;
+ pinfo->allExist = 0;
+ pinfo->drawDirection = LeftToRight;
+ pinfo->cachable = 1;
+ if (spf->specs.xxmult != spf->specs.yymult)
+ pinfo->anamorphic = TRUE;
+ else
+ pinfo->anamorphic = FALSE;
+/* computed by sp_compute_bounds:
+ * maxOverlap
+ * maxbounds
+ * minbounds
+ * ink_maxbounds
+ * ink_minbounds
+ */
+ pixel_size = spf->vals.pixel_matrix[3] * STRETCH_FACTOR / 100;
+ pinfo->fontAscent = pixel_size * 764 / 1000; /* 764 == EM_TOP */
+ pinfo->fontDescent = pixel_size - pinfo->fontAscent;
+}
+
+static void
+adjust_min_max(
+ xCharInfo *minc,
+ xCharInfo *maxc,
+ xCharInfo *tmp)
+{
+#define MINMAX(field,ci) \
+ if (minc->field > (ci)->field) \
+ minc->field = (ci)->field; \
+ if (maxc->field < (ci)->field) \
+ maxc->field = (ci)->field;
+
+ MINMAX(ascent, tmp);
+ MINMAX(descent, tmp);
+ MINMAX(leftSideBearing, tmp);
+ MINMAX(rightSideBearing, tmp);
+ MINMAX(characterWidth, tmp);
+
+ if ((INT16)minc->attributes > (INT16)tmp->attributes)
+ minc->attributes = tmp->attributes;
+ if ((INT16)maxc->attributes < (INT16)tmp->attributes)
+ maxc->attributes = tmp->attributes;
+
+#undef MINMAX
+}
+
+
+void
+sp_compute_bounds(
+ SpeedoFontPtr spf,
+ FontInfoPtr pinfo,
+ unsigned long flags,
+ long *sWidth)
+{
+ int i,
+ id,
+ index,
+ maxOverlap,
+ overlap,
+ total_width = 0;
+ xCharInfo minchar,
+ maxchar,
+ tmpchar;
+ bbox_t bbox;
+ fix31 width;
+ double pix_width;
+ SpeedoMasterFontPtr spmf = spf->master;
+ int firstChar;
+ int num_chars = 0;
+
+ firstChar = spmf->first_char_id;
+ minchar.ascent = minchar.descent =
+ minchar.leftSideBearing = minchar.rightSideBearing =
+ minchar.characterWidth = minchar.attributes = 32767;
+ maxchar.ascent = maxchar.descent =
+ maxchar.leftSideBearing = maxchar.rightSideBearing =
+ maxchar.characterWidth = maxchar.attributes = -32767;
+ maxOverlap = -32767;
+ *sWidth = 0;
+ for (i = 0; i < spmf->num_chars; i++) {
+ int j;
+ int char_id;
+
+ index = spmf->enc[i * 2 + 1];
+ char_id = spmf->enc[i * 2];
+ /*
+ * See if this character is in the list of ranges specified in the
+ * XLFD name
+ */
+ for (j = 0; j < spf->vals.nranges; j++)
+ if (char_id >= mincharno(spf->vals.ranges[j]) &&
+ char_id <= maxcharno(spf->vals.ranges[j]))
+ break;
+ if (spf->vals.nranges && j == spf->vals.nranges)
+ continue;
+ num_chars++;
+
+ if (!(flags & ComputeBoundsOnly)) {
+
+ width = sp_get_char_width(index);
+
+ /* convert to pixel coords */
+ pix_width = (int)width * (spf->specs.xxmult / 65536L) +
+ ((int) width * (spf->specs.xxmult % 65536L))
+ / 65536L;
+ pix_width /= 65536L;
+
+ (void) sp_get_char_bbox(index, &bbox);
+ bbox.ymax = (bbox.ymax + 32768L) >> 16;
+ bbox.ymin = (bbox.ymin + 32768L) >> 16;
+ bbox.xmin = (bbox.xmin + 32768L) >> 16;
+ bbox.xmax = (bbox.xmax + 32768L) >> 16;
+ tmpchar.ascent = bbox.ymax;
+ tmpchar.descent = -bbox.ymin;
+ tmpchar.characterWidth = (int)(pix_width + /* round */
+ (pix_width > 0 ? 0.5 : -0.5));
+ tmpchar.rightSideBearing = bbox.xmax;
+ tmpchar.leftSideBearing = bbox.xmin;
+
+ if (!tmpchar.characterWidth &&
+ tmpchar.ascent == -tmpchar.descent &&
+ tmpchar.rightSideBearing == tmpchar.leftSideBearing)
+ {
+ /* Character appears non-existent, probably as a result
+ of the transformation. Let's give it one pixel in
+ the universe so it's not mistaken for non-existent. */
+ tmpchar.leftSideBearing = tmpchar.descent = 0;
+ tmpchar.rightSideBearing = tmpchar.ascent = 1;
+ }
+
+ tmpchar.attributes = (int)((double)(int)width / 65.536 + .5);
+ }
+ else
+ tmpchar = spf->encoding[char_id - firstChar].metrics;
+
+ adjust_min_max(&minchar, &maxchar, &tmpchar);
+ overlap = tmpchar.rightSideBearing - tmpchar.characterWidth;
+ if (maxOverlap < overlap)
+ maxOverlap = overlap;
+
+ total_width += ((int)(INT16)tmpchar.attributes);
+ *sWidth += abs((int)(INT16)tmpchar.attributes);
+
+ if (flags & SaveMetrics) {
+ id = spmf->enc[i * 2] - firstChar;
+ assert(id <= spmf->max_id - firstChar);
+ spf->encoding[id].metrics = tmpchar;
+ }
+ }
+
+
+ if (num_chars > 0)
+ {
+ *sWidth = (int)(((double)*sWidth * 10.0 + (double)num_chars / 2.0) /
+ num_chars);
+ if (total_width < 0)
+ {
+ /* Predominant direction is R->L */
+ *sWidth = -*sWidth;
+ }
+ spf->vals.width = (int)((double)*sWidth * spf->vals.pixel_matrix[0] /
+ 1000.0 +
+ (spf->vals.pixel_matrix[0] > 0 ? .5 : -.5));
+ }
+ else
+ {
+ spf->vals.width = 0;
+ }
+ pinfo->maxbounds = maxchar;
+ pinfo->minbounds = minchar;
+ pinfo->ink_maxbounds = maxchar;
+ pinfo->ink_minbounds = minchar;
+ pinfo->maxOverlap = maxOverlap;
+}
+
+void
+sp_compute_props(
+ SpeedoFontPtr spf,
+ char *fontname,
+ FontInfoPtr pinfo,
+ long sWidth)
+{
+ FontPropPtr pp;
+ int i,
+ nprops;
+ fontProp *fpt;
+ char *is_str;
+ char *ptr1 = NULL,
+ *ptr2;
+ char *ptr3;
+ char tmpname[1024];
+ FontScalableRec tmpvals;
+
+ nprops = pinfo->nprops = NPROPS;
+ pinfo->isStringProp = (char *) xalloc(sizeof(char) * nprops);
+ pinfo->props = (FontPropPtr) xalloc(sizeof(FontPropRec) * nprops);
+ if (!pinfo->isStringProp || !pinfo->props) {
+ xfree(pinfo->isStringProp);
+ pinfo->isStringProp = (char *) 0;
+ xfree(pinfo->props);
+ pinfo->props = (FontPropPtr) 0;
+ pinfo->nprops = 0;
+ return;
+ }
+ bzero(pinfo->isStringProp, (sizeof(char) * nprops));
+
+ ptr2 = fontname;
+ for (i = NNAMEPROPS, pp = pinfo->props, fpt = fontNamePropTable,
+ is_str = pinfo->isStringProp;
+ i;
+ i--, pp++, fpt++, is_str++) {
+
+ if (*ptr2)
+ {
+ ptr1 = ptr2 + 1;
+ if (!(ptr2 = strchr(ptr1, '-'))) ptr2 = strchr(ptr1, '\0');
+ }
+
+ pp->name = fpt->atom;
+ switch (fpt->type) {
+ case atom:
+ *is_str = TRUE;
+ pp->value = MakeAtom(ptr1, ptr2 - ptr1, TRUE);
+ break;
+ case truncate_atom:
+ *is_str = TRUE;
+ for (ptr3 = ptr1; *ptr3; ptr3++)
+ if (*ptr3 == '[')
+ break;
+ pp->value = MakeAtom(ptr1, ptr3 - ptr1, TRUE);
+ break;
+ case pixel_size:
+ pp->value = (int)(spf->vals.pixel_matrix[3] +
+ (spf->vals.pixel_matrix[3] > 0 ? .5 : -.5));
+ break;
+ case point_size:
+ pp->value = (int)(spf->vals.point_matrix[3] * 10.0 +
+ (spf->vals.point_matrix[3] > 0 ? .5 : -.5));
+ break;
+ case resolution_x:
+ pp->value = spf->vals.x;
+ break;
+ case resolution_y:
+ pp->value = spf->vals.y;
+ break;
+ case average_width:
+ pp->value = spf->vals.width;
+ break;
+ }
+ }
+
+ for (i = 0, fpt = extraProps; i < NEXTRAPROPS; i++, is_str++, pp++, fpt++) {
+ pp->name = fpt->atom;
+ switch (i) {
+ case FONTPROP:
+ *is_str = TRUE;
+ strcpy(tmpname, fontname);
+ FontParseXLFDName(tmpname, &tmpvals, FONT_XLFD_REPLACE_ZERO);
+ FontParseXLFDName(tmpname, &spf->vals, FONT_XLFD_REPLACE_VALUE);
+ pp->value = MakeAtom(tmpname, strlen(tmpname), TRUE);
+ break;
+ case COPYRIGHTPROP:
+ *is_str = TRUE;
+ pp->value = MakeAtom(spf->master->copyright,
+ strlen(spf->master->copyright), TRUE);
+ break;
+ case FONT_TYPEPROP:
+ *is_str = TRUE;
+ pp->value = MakeAtom("Speedo", strlen("Speedo"), TRUE);
+ break;
+ case RASTERIZER_NAMEPROP:
+ *is_str = TRUE;
+ pp->value = MakeAtom("X Consortium Speedo Rasterizer",
+ strlen("X Consortium Speedo Rasterizer"),
+ TRUE);
+ break;
+ case RAWPIXELPROP:
+ *is_str = FALSE;
+ pp->value = 1000;
+ break;
+ case RAWPOINTPROP:
+ *is_str = FALSE;
+ pp->value = (long)(72270.0 / (double)spf->vals.y + .5);
+ break;
+ case RAWASCENTPROP:
+ *is_str = FALSE;
+ pp->value = STRETCH_FACTOR * 764 / 100;
+ break;
+ case RAWDESCENTPROP:
+ *is_str = FALSE;
+ pp->value = STRETCH_FACTOR * 236 / 100;
+ break;
+ case RAWWIDTHPROP:
+ *is_str = FALSE;
+ pp->value = sWidth;
+ break;
+ }
+ }
+}
diff --git a/nx-X11/lib/font/Speedo/spint.h b/nx-X11/lib/font/Speedo/spint.h
new file mode 100644
index 000000000..118ea8f42
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/spint.h
@@ -0,0 +1,180 @@
+/* $Xorg: spint.h,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR 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, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/Speedo/spint.h,v 1.9 2001/01/17 19:43:20 dawes Exp $ */
+
+#ifndef _SPINT_H_
+#define _SPINT_H_
+
+#include <X11/fonts/fntfilst.h>
+#ifndef XFree86LOADER
+#include <stdio.h>
+#else
+#include <xf86_ansic.h>
+#endif
+#include <X11/Xfuncproto.h>
+#include "speedo.h"
+
+#define SaveMetrics 0x1
+#define ComputeBoundsOnly 0x2
+
+#define GLWIDTHBYTESPADDED(bits,nbytes) \
+ ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
+ :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \
+ :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \
+ :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \
+ : 0)
+
+#define GLYPH_SIZE(ch, nbytes) \
+ GLWIDTHBYTESPADDED((ch)->metrics.rightSideBearing - \
+ (ch)->metrics.leftSideBearing, (nbytes))
+
+#define mincharno(p) ((p).min_char_low + ((p).min_char_high << 8))
+#define maxcharno(p) ((p).max_char_low + ((p).max_char_high << 8))
+
+#define MasterFileOpen 0x1
+
+typedef struct _sp_master {
+ FontEntryPtr entry; /* back pointer */
+ FILE *fp;
+ char *fname;
+ ufix8 *f_buffer;
+ ufix8 *c_buffer;
+ char *copyright;
+ ufix8 *key;
+ buff_t font;
+ buff_t char_data;
+ ufix16 mincharsize;
+ int first_char_id;
+ int num_chars;
+ int max_id;
+ int state; /* open, closed */
+ int refcount; /* number of instances */
+ int *enc;
+ int enc_size;
+} SpeedoMasterFontRec, *SpeedoMasterFontPtr;
+
+typedef struct _cur_font_stats {
+ fsBitmapFormat format;
+ /* current glyph info */
+ ufix16 char_index;
+ ufix16 char_id;
+
+ fix15 bit_width,
+ bit_height;
+ fix15 cur_y;
+ int bpr;
+
+ /*
+ * since Speedo returns extents that are not identical to what it feeds to
+ * the bitmap builder, and we want to be able to use the extents for
+ * preformance reasons, some of the bitmaps require padding out. the next
+ * two flags keep track of this.
+ */
+ fix15 last_y;
+ int trunc;
+
+ pointer bp;
+ int scanpad;
+} CurrentFontValuesRec, *CurrentFontValuesPtr;
+
+
+typedef struct _sp_font {
+ struct _sp_master *master;
+ specs_t specs;
+
+ FontEntryPtr entry;
+
+ FontScalableRec vals;
+
+ /* char & metric data */
+ CharInfoPtr encoding;
+ CharInfoPtr pDefault;
+ pointer bitmaps;
+
+#ifdef DEBUG
+ unsigned long bitmap_size;
+#endif
+
+} SpeedoFontRec, *SpeedoFontPtr;
+
+extern SpeedoFontPtr sp_fp_cur;
+
+extern int sp_open_font(char *, char *, FontEntryPtr, FontScalablePtr,
+ fsBitmapFormat, fsBitmapFormatMask, Mask,
+ SpeedoFontPtr *);
+extern int sp_open_master(const char *, const char *, SpeedoMasterFontPtr *);
+extern void sp_close_font(SpeedoFontPtr);
+extern void sp_close_master_font(SpeedoMasterFontPtr);
+extern void sp_close_master_file(SpeedoMasterFontPtr);
+extern void sp_reset_master(SpeedoMasterFontPtr);
+extern void SpeedoErr(char *fmt, ...);
+
+extern void sp_make_standard_props(void);
+extern void sp_make_header(SpeedoFontPtr, FontInfoPtr);
+extern void sp_compute_bounds(SpeedoFontPtr, FontInfoPtr, unsigned long, long *);
+extern void sp_compute_props(SpeedoFontPtr, char *, FontInfoPtr, long);
+extern int sp_build_all_bitmaps(FontPtr, fsBitmapFormat, fsBitmapFormatMask);
+extern unsigned long sp_compute_data_size(FontPtr, int, int, unsigned long,
+ unsigned long);
+
+extern int SpeedoFontLoad(FontPtr *, char *, char *, FontEntryPtr,
+ FontScalablePtr, fsBitmapFormat, fsBitmapFormatMask,
+ Mask);
+
+extern int sp_bics_map[];
+extern int sp_bics_map_size;
+
+#ifdef EXTRAFONTS
+extern int adobe_map[];
+extern int adobe_map_size;
+
+#endif
+
+#endif /* _SPINT_H_ */
diff --git a/nx-X11/lib/font/Speedo/sptobdf.c b/nx-X11/lib/font/Speedo/sptobdf.c
new file mode 100644
index 000000000..ca3caa515
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/sptobdf.c
@@ -0,0 +1,678 @@
+/* $Xorg: sptobdf.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing Devices and
+ * Digital not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Network Computing Devices and Digital make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR 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.
+ *
+ * Dave Lemke
+ */
+
+/*
+
+Copyright 1987, 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.
+
+*/
+
+/*
+ * Speedo outline to BFD format converter
+ */
+
+#include <stdio.h>
+#include "speedo.h"
+
+#ifdef EXTRAFONTS
+#include "ncdkeys.h"
+#else
+#include "keys.h"
+#endif
+
+#include "iso8859.h"
+
+#define MAX_BITS 1024
+
+#define BBOX_CLIP
+
+static char line_of_bits[MAX_BITS + 1];
+
+static FILE *fp;
+static ufix16 char_index,
+ char_id;
+static buff_t font;
+static buff_t char_data;
+static ufix8 *f_buffer,
+ *c_buffer;
+static ufix16 mincharsize;
+static fix15 cur_y;
+static fix15 bit_width,
+ bit_height;
+
+static ufix8 key[] =
+{
+ KEY0,
+ KEY1,
+ KEY2,
+ KEY3,
+ KEY4,
+ KEY5,
+ KEY6,
+ KEY7,
+ KEY8
+}; /* Font decryption key */
+
+
+static char *progname;
+static char *fontname = NULL;
+static char *fontfile = NULL;
+
+static int point_size = 120;
+static int x_res = 72;
+static int y_res = 72;
+static int quality = 0;
+static int iso_encoding = 1;
+
+static int num_props = 7;
+static int stretch = 120;
+
+static specs_t specs;
+
+static void dump_header();
+
+static void
+usage()
+{
+ fprintf(stderr, "Usage: %s [-xres x resolution] [-yres y resolution]\n\t[-ptsize pointsize] [-fn fontname] [-q quality (0-1)] fontfile\n", progname);
+ fprintf(stderr, "Where:\n");
+ fprintf(stderr, "-xres specifies the X resolution (72)\n");
+ fprintf(stderr, "-yres specifies the Y resolution (72)\n");
+ fprintf(stderr, "-pts specifies the pointsize in decipoints (120)\n");
+ fprintf(stderr, "-fn specifies the font name (full Bitstream name)\n");
+ fprintf(stderr, "-q specifies the font quality [0-1] (0)\n");
+ fprintf(stderr, "\n");
+ exit(0);
+}
+
+static fix15
+read_2b(ptr)
+ ufix8 *ptr;
+{
+ fix15 tmp;
+
+ tmp = *ptr++;
+ tmp = (tmp << 8) + *ptr;
+ return tmp;
+}
+
+static fix31
+read_4b(ptr)
+ ufix8 *ptr;
+{
+ fix31 tmp;
+
+ tmp = *ptr++;
+ tmp = (tmp << 8) + *ptr++;
+ tmp = (tmp << 8) + *ptr++;
+ tmp = (tmp << 8) + *ptr;
+ return tmp;
+}
+
+static void
+process_args(ac, av)
+ int ac;
+ char **av;
+{
+ int i;
+
+ for (i = 1; i < ac; i++) {
+ if (!strncmp(av[i], "-xr", 3)) {
+ if (av[i + 1]) {
+ x_res = atoi(av[++i]);
+ } else
+ usage();
+ } else if (!strncmp(av[i], "-yr", 3)) {
+ if (av[i + 1]) {
+ y_res = atoi(av[++i]);
+ } else
+ usage();
+ } else if (!strncmp(av[i], "-pt", 3)) {
+ if (av[i + 1]) {
+ point_size = atoi(av[++i]);
+ } else
+ usage();
+ } else if (!strncmp(av[i], "-fn", 3)) {
+ if (av[i + 1]) {
+ fontname = av[++i];
+ } else
+ usage();
+ } else if (!strncmp(av[i], "-q", 2)) {
+ if (av[i + 1]) {
+ quality = atoi(av[++i]);
+ } else
+ usage();
+ } else if (!strncmp(av[i], "-st", 3)) {
+ if (av[i + 1]) {
+ stretch = atoi(av[++i]);
+ } else
+ usage();
+ } else if (!strncmp(av[i], "-noni", 5)) {
+ iso_encoding = 0;
+ } else if (*av[i] == '-') {
+ usage();
+ } else
+ fontfile = av[i];
+ }
+ if (!fontfile)
+ usage();
+}
+
+void
+main(argc, argv)
+ int argc;
+ char **argv;
+{
+ ufix32 i;
+ ufix8 tmp[16];
+ ufix32 minbufsize;
+ ufix16 cust_no;
+ int first_char_index,
+ num_chars;
+
+ progname = argv[0];
+ process_args(argc, argv);
+ fp = fopen(fontfile, "r");
+ if (!fp) {
+ fprintf(stderr, "No such font file, \"%s\"\n", fontfile);
+ exit(-1);
+ }
+ if (fread(tmp, sizeof(ufix8), 16, fp) != 16) {
+ fprintf(stderr, "error reading \"%s\"\n", fontfile);
+ exit(-1);
+ }
+ minbufsize = (ufix32) read_4b(tmp + FH_FBFSZ);
+ f_buffer = (ufix8 *) malloc(minbufsize);
+ if (!f_buffer) {
+ fprintf(stderr, "can't get %x bytes of memory\n", minbufsize);
+ exit(-1);
+ }
+ fseek(fp, (ufix32) 0, 0);
+
+ if (fread(f_buffer, sizeof(ufix8), (ufix16) minbufsize, fp) != minbufsize) {
+ fprintf(stderr, "error reading file \"%s\"\n", fontfile);
+ exit(-1);
+ }
+ mincharsize = read_2b(f_buffer + FH_CBFSZ);
+
+ c_buffer = (ufix8 *) malloc(mincharsize);
+ if (!c_buffer) {
+ fprintf(stderr, "can't get %x bytes for char buffer\n", mincharsize);
+ exit(-1);
+ }
+ /* init */
+ sp_reset();
+
+ font.org = f_buffer;
+ font.no_bytes = minbufsize;
+
+ if ((cust_no = sp_get_cust_no(font)) != CUS0) {
+ fprintf(stderr, "Non-standard encryption for \"%s\"\n", fontfile);
+ exit(-1);
+ }
+ sp_set_key(key);
+
+ first_char_index = read_2b(f_buffer + FH_FCHRF);
+ num_chars = read_2b(f_buffer + FH_NCHRL);
+
+ /* set up specs */
+ /* Note that point size is in decipoints */
+ specs.pfont = &font;
+ /* XXX beware of overflow */
+ specs.xxmult = point_size * x_res / 720 * (1 << 16);
+ specs.xymult = 0L << 16;
+ specs.xoffset = 0L << 16;
+ specs.yxmult = 0L << 16;
+ specs.yymult = point_size * y_res / 720 * (1 << 16);
+ specs.yoffset = 0L << 16;
+ switch (quality) {
+ case 0:
+ specs.flags = 0;
+ break;
+ case 1:
+ specs.flags = MODE_SCREEN;
+ break;
+ case 2:
+ specs.flags = MODE_2D;
+ break;
+ default:
+ fprintf(stderr, "bogus quality value %d\n", quality);
+ break;
+ }
+ specs.out_info = NULL;
+
+ if (!fontname) {
+ fontname = (char *) (f_buffer + FH_FNTNM);
+ }
+ if (iso_encoding)
+ num_chars = num_iso_chars;
+ dump_header(num_chars);
+
+ if (!sp_set_specs(&specs)) {
+ fprintf(stderr, "can't set specs\n");
+ } else {
+ if (iso_encoding) {
+ for (i = 0; i < num_iso_chars * 2; i += 2) {
+ char_index = iso_map[i + 1];
+ char_id = iso_map[i];
+ if (!sp_make_char(char_index)) {
+ fprintf(stderr, "can't make char %x\n", char_index);
+ }
+ }
+ } else {
+ for (i = 0; i < num_chars; i++) {
+ char_index = i + first_char_index;
+ char_id = sp_get_char_id(char_index);
+ if (char_id) {
+ if (!sp_make_char(char_index)) {
+ fprintf(stderr, "can't make char %x\n", char_index);
+ }
+ }
+ }
+ }
+ }
+
+ (void) fclose(fp);
+
+ printf("ENDFONT\n");
+ exit(0);
+}
+
+static void
+dump_header(num_chars)
+ ufix32 num_chars;
+{
+ fix15 xmin,
+ ymin,
+ xmax,
+ ymax;
+ fix15 ascent,
+ descent;
+ fix15 pixel_size;
+
+ xmin = read_2b(f_buffer + FH_FXMIN);
+ ymin = read_2b(f_buffer + FH_FYMIN);
+ xmax = read_2b(f_buffer + FH_FXMAX);
+ ymax = read_2b(f_buffer + FH_FYMAX);
+ pixel_size = point_size * x_res / 720;
+
+ printf("STARTFONT 2.1\n");
+ printf("COMMENT\n");
+ printf("COMMENT Generated from Bitstream Speedo outlines via sptobdf\n");
+ printf("COMMENT\n");
+ printf("FONT %s\n", fontname);
+ printf("SIZE %d %d %d\n", pixel_size, x_res, y_res);
+ printf("FONTBOUNDINGBOX %d %d %d %d\n", xmin, ymin, xmax, ymax);
+ printf("STARTPROPERTIES %d\n", num_props);
+
+ printf("RESOLUTION_X %d\n", x_res);
+ printf("RESOLUTION_Y %d\n", y_res);
+ printf("POINT_SIZE %d\n", point_size);
+ printf("PIXEL_SIZE %d\n", pixel_size);
+ printf("COPYRIGHT \"%s\"\n", f_buffer + FH_CPYRT);
+
+ /* do some stretching here so that its isn't too tight */
+ pixel_size = pixel_size * stretch / 100;
+ ascent = pixel_size * 764 / 1000; /* 764 == EM_TOP */
+ descent = pixel_size - ascent;
+ printf("FONT_ASCENT %d\n", ascent);
+ printf("FONT_DESCENT %d\n", descent);
+
+ printf("ENDPROPERTIES\n");
+ printf("CHARS %d\n", num_chars);
+}
+
+buff_t *
+sp_load_char_data(file_offset, num, cb_offset)
+ fix31 file_offset;
+ fix15 num;
+ fix15 cb_offset;
+{
+ if (fseek(fp, (long) file_offset, (int) 0)) {
+ fprintf(stderr, "can't seek to char\n");
+ (void) fclose(fp);
+ exit(-1);
+ }
+ if ((num + cb_offset) > mincharsize) {
+ fprintf(stderr, "char buf overflow\n");
+ (void) fclose(fp);
+ exit(-2);
+ }
+ if (fread((c_buffer + cb_offset), sizeof(ufix8), num, fp) != num) {
+ fprintf(stderr, "can't get char data\n");
+ exit(-1);
+ }
+ char_data.org = (ufix8 *) c_buffer + cb_offset;
+ char_data.no_bytes = num;
+
+ return &char_data;
+}
+
+/*
+ * Called by Speedo character generator to report an error.
+ *
+ * Since character data not available is one of those errors
+ * that happens many times, don't report it to user
+ */
+void
+sp_report_error(n)
+ fix15 n;
+{
+ switch (n) {
+ case 1:
+ fprintf(stderr, "Insufficient font data loaded\n");
+ break;
+ case 3:
+ fprintf(stderr, "Transformation matrix out of range\n");
+ break;
+ case 4:
+ fprintf(stderr, "Font format error\n");
+ break;
+ case 5:
+ fprintf(stderr, "Requested specs not compatible with output module\n");
+ break;
+ case 7:
+ fprintf(stderr, "Intelligent transformation requested but not supported\n");
+ break;
+ case 8:
+ fprintf(stderr, "Unsupported output mode requested\n");
+ break;
+ case 9:
+ fprintf(stderr, "Extended font loaded but only compact fonts supported\n");
+ break;
+ case 10:
+ fprintf(stderr, "Font specs not set prior to use of font\n");
+ break;
+ case 12:
+ break;
+ case 13:
+ fprintf(stderr, "Track kerning data not available()\n");
+ break;
+ case 14:
+ fprintf(stderr, "Pair kerning data not available()\n");
+ break;
+ default:
+ fprintf(stderr, "report_error(%d)\n", n);
+ break;
+ }
+}
+
+void
+sp_open_bitmap(x_set_width, y_set_width, xorg, yorg, xsize, ysize)
+ fix31 x_set_width;
+ fix31 y_set_width;
+ fix31 xorg;
+ fix31 yorg;
+ fix15 xsize;
+ fix15 ysize;
+{
+ fix15 i;
+ fix15 off_horz;
+ fix15 off_vert;
+ fix31 width,
+ pix_width;
+ bbox_t bb;
+
+ bit_width = xsize;
+
+ bit_height = ysize;
+ off_horz = (fix15) ((xorg + 32768L) >> 16);
+ off_vert = (fix15) ((yorg + 32768L) >> 16);
+
+ if (bit_width > MAX_BITS) {
+
+#ifdef DEBUG
+ fprintf(stderr, "char wider than max bits -- truncated\n");
+#endif
+
+ bit_width = MAX_BITS;
+ }
+ width = sp_get_char_width(char_index);
+ pix_width = width * (specs.xxmult / 65536L) +
+ ((ufix32) width * ((ufix32) specs.xxmult & 0xffff)) / 65536L;
+ pix_width /= 65536L;
+
+ width = (pix_width * 7200L) / (point_size * y_res);
+
+ (void) sp_get_char_bbox(char_index, &bb);
+ bb.xmin >>= 16;
+ bb.ymin >>= 16;
+ bb.xmax >>= 16;
+ bb.ymax >>= 16;
+
+#ifdef DEBUG
+ if ((bb.xmax - bb.xmin) != bit_width)
+ fprintf(stderr, "bbox & width mismatch 0x%x (%d) (%d vs %d)\n",
+ char_index, char_id, (bb.xmax - bb.xmin), bit_width);
+ if ((bb.ymax - bb.ymin) != bit_height)
+ fprintf(stderr, "bbox & height mismatch 0x%x (%d) (%d vs %d)\n",
+ char_index, char_id, (bb.ymax - bb.ymin), bit_height);
+ if (bb.xmin != off_horz)
+ fprintf(stderr, "x min mismatch 0x%x (%d) (%d vs %d)\n",
+ char_index, char_id, bb.xmin, off_horz);
+ if (bb.ymin != off_vert)
+ fprintf(stderr, "y min mismatch 0x%x (%d) (%d vs %d)\n",
+ char_index, char_id, bb.ymin, off_vert);
+#endif
+
+#ifdef BBOX_CLIP
+ bit_width = bb.xmax - bb.xmin;
+ bit_height = bb.ymax - bb.ymin;
+ off_horz = bb.xmin;
+ off_vert = bb.ymin;
+#endif
+
+ /* XXX kludge to handle space */
+ if (bb.xmin == 0 && bb.ymin == 0 && bb.xmax == 0 && bb.ymax == 0 &&
+ width) {
+ bit_width = 1;
+ bit_height = 1;
+ }
+ printf("STARTCHAR %d\n", char_id);
+ printf("ENCODING %d\n", char_id);
+ printf("SWIDTH %d 0\n", width);
+ printf("DWIDTH %d 0\n", pix_width);
+ printf("BBX %d %d %d %d\n", bit_width, bit_height, off_horz, off_vert);
+ printf("BITMAP\n");
+
+ for (i = 0; i < bit_width; i++) {
+ line_of_bits[i] = '.';
+ }
+ line_of_bits[bit_width] = '\0';
+ cur_y = 0;
+}
+
+static void
+dump_line(line)
+ ufix8 *line;
+{
+ int bit;
+ unsigned byte;
+
+ byte = 0;
+ for (bit = 0; bit < bit_width; bit++) {
+ if (line[bit] == 'X')
+ byte |= (1 << (7 - (bit & 7)));
+ if ((bit & 7) == 7) {
+ printf("%02X", byte);
+ byte = 0;
+ }
+ }
+ if ((bit & 7) != 0)
+ printf("%02X", byte);
+ printf("\n");
+}
+
+#ifdef BBOX_CLIP
+static fix15 last_y;
+static int trunc = 0;
+
+#endif
+
+void
+sp_set_bitmap_bits(y, xbit1, xbit2)
+ fix15 y;
+ fix15 xbit1;
+ fix15 xbit2;
+{
+ fix15 i;
+
+ if (xbit1 > MAX_BITS) {
+
+#ifdef DEBUG
+ fprintf(stderr, "run wider than max bits -- truncated\n");
+#endif
+
+ xbit1 = MAX_BITS;
+ }
+ if (xbit2 > MAX_BITS) {
+
+#ifdef DEBUG
+ fprintf(stderr, "run wider than max bits -- truncated\n");
+#endif
+
+ xbit2 = MAX_BITS;
+ }
+ while (cur_y != y) {
+ dump_line(line_of_bits);
+ for (i = 0; i < bit_width; i++) {
+ line_of_bits[i] = '.';
+ }
+ cur_y++;
+ }
+
+#ifdef BBOX_CLIP
+ last_y = y;
+ if (y >= bit_height) {
+
+#ifdef DEBUG
+ fprintf(stderr,
+ "y value is larger than height 0x%x (%d) -- truncated\n",
+ char_index, char_id);
+#endif
+
+ trunc = 1;
+ return;
+ }
+#endif /* BBOX_CLIP */
+
+ for (i = xbit1; i < xbit2; i++) {
+ line_of_bits[i] = 'X';
+ }
+}
+
+void
+sp_close_bitmap()
+{
+
+#ifdef BBOX_CLIP
+ int i;
+
+ if (!trunc)
+ dump_line(line_of_bits);
+ trunc = 0;
+
+
+ last_y++;
+ while (last_y < bit_height) {
+
+#ifdef DEBUG
+ fprintf(stderr, "padding out height for 0x%x (%d)\n",
+ char_index, char_id);
+#endif
+
+ for (i = 0; i < bit_width; i++) {
+ line_of_bits[i] = '.';
+ }
+ dump_line(line_of_bits);
+ last_y++;
+ }
+
+#else
+ dump_line(line_of_bits);
+#endif
+
+ printf("ENDCHAR\n");
+}
+
+/* outline stubs */
+void
+sp_open_outline()
+{
+}
+
+void
+sp_start_new_char()
+{
+}
+
+void
+sp_start_contour()
+{
+}
+
+void
+sp_curve_to()
+{
+}
+
+void
+sp_line_to()
+{
+}
+
+void
+sp_close_contour()
+{
+}
+
+void
+sp_close_outline()
+{
+}
diff --git a/nx-X11/lib/font/Speedo/useropt.h b/nx-X11/lib/font/Speedo/useropt.h
new file mode 100644
index 000000000..e879aae96
--- /dev/null
+++ b/nx-X11/lib/font/Speedo/useropt.h
@@ -0,0 +1,41 @@
+/* $Xorg: useropt.h,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#define INCL_LCD 1
+#define STATIC_ALLOC 1
+
+#define INCL_BLACK 1
+#define INCL_SCREEN 1
+#define INCL_2D 1
+#define SHORT_LISTS 0
+
+#define INCL_RULES 1
+#define INCL_METRICS 1
+
+#define INCL_KEYS 1
diff --git a/nx-X11/lib/font/Type1/AFM.h b/nx-X11/lib/font/Type1/AFM.h
new file mode 100644
index 000000000..f2c997a3f
--- /dev/null
+++ b/nx-X11/lib/font/Type1/AFM.h
@@ -0,0 +1,62 @@
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#if XFONT_CID
+#ifndef AFM_H
+#define AFM_H
+
+/* Bounding box definition. Used for the Font BBox as well as the
+ * Character BBox.
+ */
+typedef struct
+{
+ int llx; /* lower left x-position */
+ int lly; /* lower left y-position */
+ int urx; /* upper right x-position */
+ int ury; /* upper right y-position */
+} BBox;
+
+/* Character Metric Information. This structure is used only if ALL
+ * character metric information is requested. If only the character
+ * widths is requested, then only an array of the character x-widths
+ * is returned.
+ *
+ * The key that each field is associated with is in comments. For an
+ * explanation about each key and its value please refer to the
+ * Character Metrics section of the AFM documentation (full title
+ * & version given above).
+ */
+typedef struct
+{
+ long code; /* CID code */
+ int wx; /* key: WX or W0X */
+ BBox charBBox; /* key: B */
+} Metrics;
+
+typedef struct
+{
+ int nChars; /* number of entries in char metrics array */
+ Metrics *metrics; /* ptr to char metrics array */
+} FontInfo;
+
+int CIDAFM(FILE *, FontInfo **);
+#endif /* AFM_H */
+#endif
diff --git a/nx-X11/lib/font/Type1/Imakefile b/nx-X11/lib/font/Type1/Imakefile
new file mode 100644
index 000000000..3b10c0399
--- /dev/null
+++ b/nx-X11/lib/font/Type1/Imakefile
@@ -0,0 +1,91 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:28 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/font/Type1/Imakefile,v 1.12 2002/02/13 21:32:48 dawes Exp $
+
+#if BuildServer && DoLoadableServer
+#define IHaveSubdirs
+#define NoLibSubdirs
+#define PassCDebugFlags
+SUBDIRS = module
+#endif
+
+INCLUDES = -I$(FONTINCSRC) -I../include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/include
+
+#if BuildCID
+CIDSRCS = cidchar.c afm.c
+CIDOBJS = cidchar.o afm.o
+#if HasUsableFileMmap
+MMAPDEFINES = -DUSE_MMAP
+#endif
+DEFINES = -DBUILDCID -DHAVE_CFM $(MMAPDEFINES)
+#endif
+
+SRCS = \
+ arith.c \
+ curves.c \
+ fontfcn.c \
+ hints.c \
+ lines.c \
+ objects.c \
+ paths.c \
+ regions.c \
+ scanfont.c \
+ spaces.c \
+ t1funcs.c \
+ t1info.c \
+ t1io.c \
+ t1malloc.c \
+ t1snap.c \
+ t1stub.c \
+ token.c \
+ type1.c \
+ util.c \
+ $(CIDSRCS) \
+ t1unicode.c
+
+
+OBJS = \
+ arith.o \
+ curves.o \
+ fontfcn.o \
+ hints.o \
+ lines.o \
+ objects.o \
+ paths.o \
+ regions.o \
+ scanfont.o \
+ spaces.o \
+ t1funcs.o \
+ t1info.o \
+ t1io.o \
+ t1malloc.o \
+ t1snap.o \
+ t1stub.o \
+ token.o \
+ type1.o \
+ util.o \
+ $(CIDOBJS) \
+ t1unicode.o
+
+#if BuildFontLib
+#define DoNormalLib NormalLibFont
+#define DoSharedLib SharedLibFont
+#define DoDebugLib DebugLibFont
+#define DoProfileLib ProfileLibFont
+#include <Library.tmpl>
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+#endif
+
+#if BuildServer && DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+DependTarget()
diff --git a/nx-X11/lib/font/Type1/afm.c b/nx-X11/lib/font/Type1/afm.c
new file mode 100644
index 000000000..9a6dafee7
--- /dev/null
+++ b/nx-X11/lib/font/Type1/afm.c
@@ -0,0 +1,200 @@
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/afm.c,v 1.2 1999/08/21 13:47:38 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#ifdef XFONT_CID
+#ifndef FONTMODULE
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+#else
+#include "Xmd.h" /* For INT32 declaration */
+#include "Xdefs.h" /* For Bool */
+#include "xf86_ansic.h"
+#endif
+#include <X11/fonts/fontmisc.h> /* for xalloc/xfree */
+#include "AFM.h"
+
+#define PBUF 256
+#define KBUF 20
+
+char *gettoken(FILE *);
+
+static char *afmbuf = NULL;
+
+char *gettoken(FILE *fd) {
+ char *bp;
+ int c, found;
+
+ bp = afmbuf;
+ found = 0;
+
+ while((c = getc(fd)) != EOF) {
+ if (found == 0 && (c == ' ' || c == '\t' || c == '\n' || c == '\r' ||
+ c == ';' || c == ',')) continue;
+ found = 1;
+ if (c != ' ' && c != '\t' && c != '\n' && c != '\r' && c != ';') {
+ *bp++ = c;
+ if (bp - afmbuf >= PBUF) {
+ bp = afmbuf;
+ break;
+ }
+ } else
+ break;
+ }
+
+ *bp = 0;
+ return(afmbuf);
+}
+
+int CIDAFM(FILE *fd, FontInfo **pfi) {
+ char *p = 0;
+ int i, j, k = 0, found = 0;
+ FontInfo *fi;
+
+ if (fd == NULL || pfi == NULL) return(1);
+
+ *pfi = NULL;
+
+ if ((afmbuf = (char *)xalloc(PBUF)) == NULL)
+ return(1);
+
+ while(1) {
+ if (!(p = gettoken(fd))) {
+ xfree(afmbuf);
+ return(1);
+ }
+
+ if (strncmp(p, "StartFontMetrics", 16) == 0) {
+ if (!(p = gettoken(fd))) {
+ xfree(afmbuf);
+ return(1);
+ }
+ if (strncmp(p, "4", 1) < 0) {
+ free(afmbuf);
+ return(1);
+ }
+ found = 1;
+ } else if (strncmp(p, "StartCharMetrics", 16) == 0) {
+ if (!found) {
+ xfree(afmbuf);
+ return(1);
+ }
+
+ if (!(p = gettoken(fd))) {
+ xfree(afmbuf);
+ return(1);
+ }
+
+ fi = (FontInfo *)xalloc(sizeof(FontInfo));
+
+ if (fi == NULL) {
+ xfree(afmbuf);
+ return(1);
+ }
+ bzero(fi, sizeof(FontInfo));
+
+ fi->nChars = atoi(p);
+
+ if (fi->nChars < 0 || fi->nChars > INT_MAX / sizeof(Metrics)) {
+ xfree(afmbuf);
+ xfree(fi);
+ return(1);
+ }
+ fi->metrics = (Metrics *)xalloc(fi->nChars *
+ sizeof(Metrics));
+ if (fi->metrics == NULL) {
+ xfree(afmbuf);
+ xfree(fi);
+ return(1);
+ }
+
+ j = 0;
+ for (i = 0; i < fi->nChars; i++) {
+ k = 0;
+ while(1) {
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ if (strncmp(p, "W0X", 3) == 0) {
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ fi->metrics[j].wx = atoi(p);
+ } else if (strncmp(p, "N", 1) == 0) {
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ fi->metrics[j].code = (long)atoi(p);
+ } else if (strncmp(p, "B", 1) == 0) {
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ fi->metrics[j].charBBox.llx = atoi(p);
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ fi->metrics[j].charBBox.lly = atoi(p);
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ fi->metrics[j].charBBox.urx = atoi(p);
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ fi->metrics[j].charBBox.ury = atoi(p);
+ j++;
+ break;
+ }
+ k++;
+ if (k >= KBUF) break;
+ }
+ if (k >= KBUF) break;
+ }
+ if (k >= KBUF || j != fi->nChars) {
+ xfree(fi->metrics);
+ xfree(fi);
+ xfree(afmbuf);
+ return(1);
+ } else {
+ *pfi = fi;
+ xfree(afmbuf);
+ return(0);
+ }
+ }
+ }
+
+ xfree(afmbuf);
+ return(1);
+}
+#endif
diff --git a/nx-X11/lib/font/Type1/arith.c b/nx-X11/lib/font/Type1/arith.c
new file mode 100644
index 000000000..961154335
--- /dev/null
+++ b/nx-X11/lib/font/Type1/arith.c
@@ -0,0 +1,486 @@
+/* $Xorg: arith.c,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/arith.c,v 1.6tsi Exp $ */
+
+ /* ARITH CWEB V0006 ******** */
+/*
+:h1.ARITH Module - Portable Module for Multiple Precision Fixed Point Arithmetic
+
+This module provides division and multiplication of 64-bit fixed point
+numbers. (To be more precise, the module works on numbers that take
+two 'longs' to store. That is almost always equivalent to saying 64-bit
+numbers.)
+
+Note: it is frequently easy and desirable to recode these functions in
+assembly language for the particular processor being used, because
+assembly language, unlike C, will have 64-bit multiply products and
+64-bit dividends. This module is offered as a portable version.
+
+&author. Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com) and Sten F. Andler
+
+
+:h3.Include Files
+
+The included files are:
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef FONTMODULE
+# include "os.h"
+#endif
+#include "objects.h"
+#include "spaces.h"
+#include "arith.h"
+
+
+/*
+:h3.
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+Reference for all algorithms: Donald E. Knuth, "The Art of Computer
+Programming, Volume 2, Semi-Numerical Algorithms," Addison-Wesley Co.,
+Massachusetts, 1969, pp. 229-279.
+
+Knuth talks about a 'digit' being an arbitrary sized unit and a number
+being a sequence of digits. We'll take a digit to be a 'short'.
+The following assumption must be valid for these algorithms to work:
+:ol.
+:li.A 'long' is two 'short's.
+:eol.
+The following code is INDEPENDENT of:
+:ol.
+:li.The actual size of a short.
+:li.Whether shorts and longs are stored most significant byte
+first or least significant byte first.
+:eol.
+
+SHORTSIZE is the number of bits in a short; LONGSIZE is the number of
+bits in a long; MAXSHORT is the maximum unsigned short:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+ASSEMBLE concatenates two shorts to form a long:
+*/
+#define ASSEMBLE(hi,lo) ((((unsigned long)hi)<<SHORTSIZE)+(lo))
+/*
+HIGHDIGIT extracts the most significant short from a long; LOWDIGIT
+extracts the least significant short from a long:
+*/
+#define HIGHDIGIT(u) ((u)>>SHORTSIZE)
+#define LOWDIGIT(u) ((u)&MAXSHORT)
+
+/*
+SIGNBITON tests the high order bit of a long 'w':
+*/
+#define SIGNBITON(w) (((long)w)<0)
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h2.Double Long Arithmetic
+
+:h3.DLmult() - Multiply Two Longs to Yield a Double Long
+
+The two multiplicands must be positive.
+*/
+
+void
+DLmult(doublelong *product, unsigned long u, unsigned long v)
+{
+#ifdef LONG64
+/* printf("DLmult(? ?, %lx, %lx)\n", u, v); */
+ *product = u*v;
+/* printf("DLmult returns %lx\n", *product); */
+#else
+ register unsigned long u1, u2; /* the digits of u */
+ register unsigned long v1, v2; /* the digits of v */
+ register unsigned int w1, w2, w3, w4; /* the digits of w */
+ register unsigned long t; /* temporary variable */
+/* printf("DLmult(? ?, %x, %x)\n", u, v); */
+ u1 = HIGHDIGIT(u);
+ u2 = LOWDIGIT(u);
+ v1 = HIGHDIGIT(v);
+ v2 = LOWDIGIT(v);
+
+ if (v2 == 0) w4 = w3 = w2 = 0;
+ else
+ {
+ t = u2 * v2;
+ w4 = LOWDIGIT(t);
+ t = u1 * v2 + HIGHDIGIT(t);
+ w3 = LOWDIGIT(t);
+ w2 = HIGHDIGIT(t);
+ }
+
+ if (v1 == 0) w1 = 0;
+ else
+ {
+ t = u2 * v1 + w3;
+ w3 = LOWDIGIT(t);
+ t = u1 * v1 + w2 + HIGHDIGIT(t);
+ w2 = LOWDIGIT(t);
+ w1 = HIGHDIGIT(t);
+ }
+
+ product->high = ASSEMBLE(w1, w2);
+ product->low = ASSEMBLE(w3, w4);
+#endif /* LONG64 else */
+}
+
+/*
+:h2.DLdiv() - Divide Two Longs by One Long, Yielding Two Longs
+
+Both the dividend and the divisor must be positive.
+*/
+
+void
+DLdiv(doublelong *quotient, /* also where dividend is, originally */
+ unsigned long divisor)
+{
+#ifdef LONG64
+/* printf("DLdiv(%lx %lx)\n", quotient, divisor); */
+ *quotient /= divisor;
+/* printf("DLdiv returns %lx\n", *quotient); */
+#else
+ register unsigned long u1u2 = quotient->high;
+ register unsigned long u3u4 = quotient->low;
+ register long u3; /* single digit of dividend */
+ register int v1,v2; /* divisor in registers */
+ register long t; /* signed copy of u1u2 */
+ register int qhat; /* guess at the quotient digit */
+ register unsigned long q3q4; /* low two digits of quotient */
+ register int shift; /* holds the shift value for normalizing */
+ register int j; /* loop variable */
+
+/* printf("DLdiv(%x %x, %x)\n", quotient->high, quotient->low, divisor); */
+ /*
+ * Knuth's algorithm works if the dividend is smaller than the
+ * divisor. We can get to that state quickly:
+ */
+ if (u1u2 >= divisor) {
+ quotient->high = u1u2 / divisor;
+ u1u2 %= divisor;
+ }
+ else
+ quotient->high = 0;
+
+ if (divisor <= MAXSHORT) {
+
+ /*
+ * This is the case where the divisor is contained in one
+ * 'short'. It is worthwhile making this fast:
+ */
+ u1u2 = ASSEMBLE(u1u2, HIGHDIGIT(u3u4));
+ q3q4 = u1u2 / divisor;
+ u1u2 %= divisor;
+ u1u2 = ASSEMBLE(u1u2, LOWDIGIT(u3u4));
+ quotient->low = ASSEMBLE(q3q4, u1u2 / divisor);
+ return;
+ }
+
+
+ /*
+ * At this point the divisor is a true 'long' so we must use
+ * Knuth's algorithm.
+ *
+ * Step D1: Normalize divisor and dividend (this makes our 'qhat'
+ * guesses more accurate):
+ */
+ for (shift=0; !SIGNBITON(divisor); shift++, divisor <<= 1) { ; }
+ shift--;
+ divisor >>= 1;
+
+ if ((u1u2 >> (LONGSIZE - shift)) != 0 && shift != 0)
+ Abort("DLdiv: dividend too large");
+ u1u2 = (u1u2 << shift) + ((shift == 0) ? 0 : u3u4 >> (LONGSIZE - shift));
+ u3u4 <<= shift;
+
+ /*
+ * Step D2: Begin Loop through digits, dividing u1,u2,u3 by v1,v2,
+ * then shifting U left by 1 digit:
+ */
+ v1 = HIGHDIGIT(divisor);
+ v2 = LOWDIGIT(divisor);
+ q3q4 = 0;
+ u3 = HIGHDIGIT(u3u4);
+
+ for (j=0; j < 2; j++) {
+
+ /*
+ * Step D3: make a guess (qhat) at the next quotient denominator:
+ */
+ qhat = (HIGHDIGIT(u1u2) == v1) ? MAXSHORT : u1u2 / v1;
+ /*
+ * At this point Knuth would have us further refine our
+ * guess, since we know qhat is too big if
+ *
+ * v2 * qhat > ASSEMBLE(u1u2 % v, u3)
+ *
+ * That would make sense if u1u2 % v was easy to find, as it
+ * would be in assembly language. I ignore this step, and
+ * repeat step D6 if qhat is too big.
+ */
+
+ /*
+ * Step D4: Multiply v1,v2 times qhat and subtract it from
+ * u1,u2,u3:
+ */
+ u3 -= qhat * v2;
+ /*
+ * The high digit of u3 now contains the "borrow" for the
+ * rest of the substraction from u1,u2.
+ * Sometimes we can lose the sign bit with the above.
+ * If so, we have to force the high digit negative:
+ */
+ t = HIGHDIGIT(u3);
+ if (t > 0)
+ t |= -1 << SHORTSIZE;
+ t += u1u2 - qhat * v1;
+/* printf("..>divide step qhat=%x t=%x u3=%x u1u2=%x v1=%x v2=%x\n",
+ qhat, t, u3, u1u2, v1, v2); */
+ while (t < 0) { /* Test is Step D5. */
+
+ /*
+ * D6: Oops, qhat was too big. Add back in v1,v2 and
+ * decrease qhat by 1:
+ */
+ u3 = LOWDIGIT(u3) + v2;
+ t += HIGHDIGIT(u3) + v1;
+ qhat--;
+/* printf("..>>qhat correction t=%x u3=%x qhat=%x\n", t, u3, qhat); */
+ }
+ /*
+ * Step D7: shift U left one digit and loop:
+ */
+ u1u2 = t;
+ if (HIGHDIGIT(u1u2) != 0)
+ Abort("divide algorithm error");
+ u1u2 = ASSEMBLE(u1u2, LOWDIGIT(u3));
+ u3 = LOWDIGIT(u3u4);
+ q3q4 = ASSEMBLE(q3q4, qhat);
+ }
+ quotient->low = q3q4;
+/* printf("DLdiv returns %x %x\n", quotient->high, quotient->low); */
+#endif /* !LONG64 */
+ return;
+}
+
+/*
+:h3.DLadd() - Add Two Double Longs
+
+In this case, the doublelongs may be signed. The algorithm takes the
+piecewise sum of the high and low longs, with the possibility that the
+high should be incremented if there is a carry out of the low. How to
+tell if there is a carry? Alex Harbury suggested that if the sum of
+the lows is less than the max of the lows, there must have been a
+carry. Conversely, if there was a carry, the sum of the lows must be
+less than the max of the lows. So, the test is "if and only if".
+*/
+
+void
+DLadd(doublelong *u, /* u = u + v */
+ doublelong *v)
+{
+#ifdef LONG64
+/* printf("DLadd(%lx %lx)\n", *u, *v); */
+ *u = *u + *v;
+/* printf("DLadd returns %lx\n", *u); */
+#else
+ register unsigned long lowmax = MAX(u->low, v->low);
+
+/* printf("DLadd(%x %x, %x %x)\n", u->high, u->low, v->high, v->low); */
+ u->high += v->high;
+ u->low += v->low;
+ if (lowmax > u->low)
+ u->high++;
+#endif
+}
+/*
+:h3.DLsub() - Subtract Two Double Longs
+
+Testing for a borrow is even easier. If the v.low is greater than
+u.low, there must be a borrow.
+*/
+
+void
+DLsub(doublelong *u, /* u = u - v */
+ doublelong *v)
+{
+#ifdef LONG64
+/* printf("DLsub(%lx %lx)\n", *u, *v); */
+ *u = *u - *v;
+/* printf("DLsub returns %lx\n", *u); */
+#else
+/* printf("DLsub(%x %x, %x %x)\n", u->high, u->low, v->high, v->low);*/
+ u->high -= v->high;
+ if (v->low > u->low)
+ u->high--;
+ u->low -= v->low;
+#endif
+}
+/*
+:h3.DLrightshift() - Macro to Shift Double Long Right by N
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h2.Fractional Pel Arithmetic
+*/
+/*
+:h3.FPmult() - Multiply Two Fractional Pel Values
+
+This funtion first calculates w = u * v to "doublelong" precision.
+It then shifts w right by FRACTBITS bits, and checks that no
+overflow will occur when the resulting value is passed back as
+a fractpel.
+*/
+
+fractpel
+FPmult(fractpel u, fractpel v)
+{
+ doublelong w;
+ register int negative = FALSE; /* sign flag */
+#ifdef LONG64
+ register fractpel ret;
+#endif
+
+ if ((u == 0) || (v == 0)) return (0);
+
+
+ if (u < 0) {u = -u; negative = TRUE;}
+ if (v < 0) {v = -v; negative = !negative;}
+
+ if (u == TOFRACTPEL(1)) return ((negative) ? -v : v);
+ if (v == TOFRACTPEL(1)) return ((negative) ? -u : u);
+
+ DLmult(&w, u, v);
+ DLrightshift(w, FRACTBITS);
+#ifndef LONG64
+ if (w.high != 0 || SIGNBITON(w.low)) {
+ w.low = TOFRACTPEL(MAXSHORT);
+ }
+
+ return ((negative) ? -w.low : w.low);
+#else
+ if (w & 0xffffffff80000000L ) {
+ ret = TOFRACTPEL(MAXSHORT);
+ }
+ else
+ ret = (fractpel)w;
+
+ return ((negative) ? -ret : ret);
+#endif
+}
+
+/*
+:h3.FPdiv() - Divide Two Fractional Pel Values
+
+These values may be signed. The function returns the quotient.
+*/
+
+fractpel
+FPdiv(fractpel dividend, fractpel divisor)
+{
+ doublelong w; /* result will be built here */
+ int negative = FALSE; /* flag for sign bit */
+#ifdef LONG64
+ register fractpel ret;
+#endif
+
+ if (dividend < 0) {
+ dividend = -dividend;
+ negative = TRUE;
+ }
+ if (divisor < 0) {
+ divisor = -divisor;
+ negative = !negative;
+ }
+#ifndef LONG64
+ w.low = dividend << FRACTBITS;
+ w.high = dividend >> (LONGSIZE - FRACTBITS);
+ DLdiv(&w, divisor);
+ if (w.high != 0 || SIGNBITON(w.low)) {
+ w.low = TOFRACTPEL(MAXSHORT);
+ }
+ return( (negative) ? -w.low : w.low);
+#else
+ w = ((long)dividend) << FRACTBITS;
+ DLdiv(&w, divisor);
+ if (w & 0xffffffff80000000L ) {
+ ret = TOFRACTPEL(MAXSHORT);
+ }
+ else
+ ret = (fractpel)w;
+ return( (negative) ? -ret : ret);
+#endif
+}
+
+/*
+:h3.FPstarslash() - Multiply then Divide
+
+Borrowing a chapter from the language Forth, it is useful to define
+an operator that first multiplies by one constant then divides by
+another, keeping the intermediate result in extended precision.
+*/
+
+fractpel
+FPstarslash(fractpel a, /* result = a * b / c */
+ fractpel b,
+ fractpel c)
+{
+ doublelong w; /* result will be built here */
+ int negative = FALSE;
+#ifdef LONG64
+ register fractpel ret;
+#endif
+
+ if (a < 0) { a = -a; negative = TRUE; }
+ if (b < 0) { b = -b; negative = !negative; }
+ if (c < 0) { c = -c; negative = !negative; }
+
+ DLmult(&w, a, b);
+ DLdiv(&w, c);
+#ifndef LONG64
+ if (w.high != 0 || SIGNBITON(w.low)) {
+ w.low = TOFRACTPEL(MAXSHORT);
+ }
+ return((negative) ? -w.low : w.low);
+#else
+ if (w & 0xffffffff80000000L ) {
+ ret = TOFRACTPEL(MAXSHORT);
+ }
+ else
+ ret = (fractpel)w;
+ return( (negative) ? -ret : ret);
+#endif
+}
diff --git a/nx-X11/lib/font/Type1/arith.h b/nx-X11/lib/font/Type1/arith.h
new file mode 100644
index 000000000..6c810b946
--- /dev/null
+++ b/nx-X11/lib/font/Type1/arith.h
@@ -0,0 +1,77 @@
+/* $Xorg: arith.h,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/arith.h,v 1.4 1999/08/21 13:47:39 dawes Exp $ */
+
+/*SHARED*/
+
+#include <X11/Xmd.h> /* LONG64 */
+
+/*END SHARED*/
+/*SHARED*/
+
+#undef SHORTSIZE
+#define SHORTSIZE (sizeof(short)*8)
+#undef LONGSIZE
+#define LONGSIZE (SHORTSIZE*2)
+#undef MAXSHORT
+#define MAXSHORT ((1<<SHORTSIZE)-1)
+
+/*END SHARED*/
+/*SHARED*/
+
+#ifdef LONG64
+typedef long doublelong;
+#else
+typedef struct {
+ long high;
+ unsigned long low;
+} doublelong;
+#endif /* LONG64 else */
+
+/*END SHARED*/
+/*SHARED*/
+
+#ifdef LONG64
+#define DLrightshift(dl,N) ((dl) >>= (N))
+#else
+#define DLrightshift(dl,N) { \
+ dl.low = (dl.low >> N) + (((unsigned long) dl.high) << (LONGSIZE - N)); \
+ dl.high >>= N; \
+}
+#endif
+
+extern void DLmult ( doublelong *product, unsigned long u, unsigned long v );
+extern void DLdiv ( doublelong *quotient, unsigned long divisor );
+extern void DLadd ( doublelong *u, doublelong *v );
+extern void DLsub ( doublelong *u, doublelong *v );
+extern fractpel FPmult ( fractpel u, fractpel v );
+extern fractpel FPdiv ( fractpel dividend, fractpel divisor );
+extern fractpel FPstarslash ( fractpel a, fractpel b, fractpel c );
+
+/*END SHARED*/
diff --git a/nx-X11/lib/font/Type1/blues.h b/nx-X11/lib/font/Type1/blues.h
new file mode 100644
index 000000000..88602f79e
--- /dev/null
+++ b/nx-X11/lib/font/Type1/blues.h
@@ -0,0 +1,95 @@
+/* $Xorg: blues.h,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ * Portions Copyright (c) 1990 Adobe Systems Incorporated.
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark or Adobe
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * IBM, LEXMARK, AND ADOBE PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY
+ * WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE
+ * ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING
+ * ANY DUTY TO SUPPORT OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY
+ * PORTION OF THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM,
+ * LEXMARK, OR ADOBE) ASSUMES THE ENTIRE COST OF ALL SERVICING, REPAIR AND
+ * CORRECTION. IN NO EVENT SHALL IBM, LEXMARK, OR ADOBE 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.
+ */
+/* $XFree86: xc/lib/font/Type1/blues.h,v 1.3 1999/08/22 08:58:49 dawes Exp $ */
+
+
+extern psobj *GetType1CharString ( psfont *fontP, unsigned char code );
+
+#define TOPLEFT 1
+#define BOTTOMRIGHT 2
+
+#define NUMBLUEVALUES 14
+#define NUMOTHERBLUES 10
+#define NUMFAMILYBLUES 14
+#define NUMFAMILYOTHERBLUES 10
+#define NUMSTEMSNAPH 12
+#define NUMSTEMSNAPV 12
+#define NUMSTDHW 1
+#define NUMSTDVW 1
+
+#define DEFAULTBOLDSTEMWIDTH 2.0
+
+#define MAXALIGNMENTZONES ((NUMBLUEVALUES+NUMOTHERBLUES)/2)
+#define DEFAULTBLUESCALE 0.039625
+#define DEFAULTBLUESHIFT 7
+#define DEFAULTBLUEFUZZ 1
+#define DEFAULTSTDHW 0
+#define DEFAULTSTDVW 0
+#define DEFAULTFORCEBOLD FALSE
+#define DEFAULTLANGUAGEGROUP 0
+#define DEFAULTRNDSTEMUP FALSE
+#define DEFAULTLENIV 4
+#define DEFAULTEXPANSIONFACTOR 0.06
+
+/* see Type 1 Font Format book for explanations of these values */
+/* Note that we're currently doing nothing for minfeature and password. */
+struct blues_struct {
+ struct blues_struct *next; /* ptr to next Blues structure in list */
+ int numBlueValues; /* # of BlueValues in following array */
+ int BlueValues[NUMBLUEVALUES];
+ int numOtherBlues; /* # of OtherBlues values in following array */
+ int OtherBlues[NUMOTHERBLUES];
+ int numFamilyBlues; /* # of FamilyBlues values in following array */
+ int FamilyBlues[NUMFAMILYBLUES];
+ int numFamilyOtherBlues; /* # of FamilyOtherBlues values in */
+ int FamilyOtherBlues[NUMFAMILYOTHERBLUES]; /* this array */
+ double BlueScale;
+ int BlueShift;
+ int BlueFuzz;
+ double StdHW;
+ double StdVW;
+ int numStemSnapH; /* # of StemSnapH values in following array */
+ double StemSnapH[NUMSTEMSNAPH];
+ int numStemSnapV; /* # of StemSnapV values in following array */
+ double StemSnapV[NUMSTEMSNAPV];
+ int ForceBold;
+ int LanguageGroup;
+ int RndStemUp;
+ int lenIV;
+ double ExpansionFactor;
+};
+
+/* the alignment zone structure -- somewhat similar to the stem structure */
+/* see Adobe Type1 Font Format book about the terms used in this structure */
+struct alignmentzone {
+ int topzone; /* TRUE if a topzone, FALSE if a bottom zone */
+ double bottomy, topy; /* interval of this alignment zone */
+};
diff --git a/nx-X11/lib/font/Type1/cidchar.c b/nx-X11/lib/font/Type1/cidchar.c
new file mode 100644
index 000000000..20d26650c
--- /dev/null
+++ b/nx-X11/lib/font/Type1/cidchar.c
@@ -0,0 +1,621 @@
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/cidchar.c,v 1.9tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#if XFONT_CID
+#ifndef FONTMODULE
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#ifdef USE_MMAP
+#include <sys/mman.h>
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)(-1))
+#endif
+#endif
+#else
+#include "Xmd.h" /* For INT32 declaration */
+#include "Xdefs.h" /* For Bool */
+#include "xf86_ansic.h"
+#endif
+#ifndef FONTMODULE
+#ifdef _XOPEN_SOURCE
+#include <math.h>
+#else
+#define _XOPEN_SOURCE
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+#endif
+#include <X11/fonts/fntfilst.h>
+#include "objects.h"
+#include "spaces.h"
+#include "range.h"
+#include "util.h"
+#include "fontfcn.h"
+#include "blues.h"
+#include "AFM.h"
+#include "t1intf.h"
+
+#define BSIZE 4096
+
+extern cidfont *CIDFontP;
+extern psfont *FDArrayP;
+extern psfont *FontP;
+
+static unsigned char sd[] = "StartData";
+
+CharInfoPtr
+CIDGetGlyphInfo(FontPtr pFont, unsigned int cidcode, CharInfoPtr pci, int *rc)
+{
+ CharInfoPtr cp = NULL;
+#ifdef USE_MMAP
+ int fd;
+ unsigned char *buf;
+ long total_len = 0;
+#else
+ FILE *fp;
+ unsigned char buf[BSIZE];
+ unsigned int count = 0;
+#endif
+ cidglyphs *cid;
+ unsigned char *p1 = NULL;
+#ifndef USE_MMAP
+ unsigned char *p2;
+#endif
+ register int i = 0, j;
+ long byteoffset;
+ int FDindex, FDBytes, GDBytes, SDBytes, SubrCount, CIDMapOffset, len;
+ psobj *arrayP;
+ psobj charstring;
+ long *subroffsets = NULL, cstringoffset, nextcstringoffset;
+ struct blues_struct *blues;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+#ifdef USE_MMAP
+ if (!cid->CIDdata) {
+ if (!(fd = open(cid->CIDFontName, O_RDONLY, 0))) {
+ *rc = BadFontName;
+ return(cp);
+ }
+ cid->CIDsize = lseek(fd, 0, SEEK_END);
+ cid->CIDdata = (unsigned char *)
+ mmap(0, (size_t)cid->CIDsize, PROT_READ, MAP_SHARED, fd, 0);
+ close(fd);
+ if (cid->CIDdata == (unsigned char *)MAP_FAILED) {
+ *rc = AllocError;
+ cid->CIDdata = NULL;
+ return (cp);
+ }
+ }
+#else
+ if (!(fp = fopen(cid->CIDFontName,"rb"))) {
+ *rc = BadFontName;
+ return(cp);
+ }
+#endif
+
+#ifdef USE_MMAP
+ if (cid->dataoffset == 0) {
+ if ((p1 = (unsigned char *)strstr((char *)cid->CIDdata, (char *)sd))
+ != NULL) {
+ cid->dataoffset = (p1 - cid->CIDdata) + strlen((char *)sd);
+ }
+ else {
+ *rc = BadFontFormat;
+ return(cp);
+ }
+ }
+#else /* USE_MMAP */
+ if (cid->dataoffset == 0) {
+ p2 = sd;
+
+ /* find "StartData" */
+ while (*p2) {
+ cid->dataoffset += count;
+ if ((count = fread(buf, 1, BSIZE, fp)) == 0)
+ break;
+ p1 = buf;
+ for (i=0; i < count && *p2; i++) {
+ if (*p1 == *p2)
+ p2++;
+ else {
+ p2 = sd;
+ if (*p1 == *p2)
+ p2++;
+ }
+ p1++;
+ }
+ }
+
+ /* if "StartData" not found, or end of file */
+ if (*p2 || count == 0) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+
+ if (i >= count) {
+ cid->dataoffset += count;
+ count = fread(buf, 1, BSIZE, fp);
+ p1 = buf;
+ } else {
+ cid->dataoffset += p1 - buf;
+ count = count - (p1 - buf);
+ }
+ } else {
+ if (fseek(fp, cid->dataoffset, SEEK_SET)) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+ if ((count = fread(buf, 1, BSIZE, fp)) == 0) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+ p1 = buf;
+ }
+
+ /* if "StartData" not found, or "Binary" data and the next character */
+ /* is not the space character (0x20) */
+
+ if (count == 0 || (CIDFontP->binarydata && (*p1 != ' '))) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+#endif /* USE_MMAP */
+
+ FDBytes = CIDFontP->CIDfontInfoP[CIDFDBYTES].value.data.integer;
+ GDBytes = CIDFontP->CIDfontInfoP[CIDGDBYTES].value.data.integer;
+ CIDMapOffset = CIDFontP->CIDfontInfoP[CIDMAPOFFSET].value.data.integer;
+ byteoffset = cid->dataoffset + 1 + CIDMapOffset +
+ cidcode * (FDBytes + GDBytes);
+#ifdef USE_MMAP
+ buf = &cid->CIDdata[byteoffset];
+#else
+ if (fseek(fp, byteoffset, SEEK_SET)) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+ if ((count = fread(buf, 1, BSIZE, fp)) < 2*(FDBytes + GDBytes)) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+#endif
+
+ /* if FDBytes is equal to 0, the CIDMap contains no FD indices, and the */
+ /* FD index of 0 is assumed. */
+ if (FDBytes == 0)
+ FDindex = 0;
+ else {
+ FDindex = 0;
+ for (i = 0; i < FDBytes; i++)
+ FDindex += (unsigned char)buf[i] << (8 * (FDBytes - 1 - i));
+ }
+
+ if (FDindex >= CIDFontP->CIDfontInfoP[CIDFDARRAY].value.len) {
+ *rc = BadFontFormat;
+#ifndef USE_MMAP
+ fclose(fp);
+#endif
+ return(cp);
+ }
+
+ cstringoffset = 0;
+ for (i = 0; i < GDBytes; i++)
+ cstringoffset += (unsigned char)buf[FDBytes + i] <<
+ (8 * (GDBytes - 1 - i));
+
+ nextcstringoffset = 0;
+ for (i = 0; i < GDBytes; i++)
+ nextcstringoffset += (unsigned char)buf[2*FDBytes + GDBytes + i] <<
+ (8 * (GDBytes - 1 - i));
+
+ len = nextcstringoffset - cstringoffset;
+
+ if (len <= 0) { /* empty interval, missing glyph */
+ *rc = BadFontFormat;
+#ifndef USE_MMAP
+ fclose(fp);
+#endif
+ return(cp);
+ }
+
+ FontP = &FDArrayP[FDindex];
+
+ charstring.type = OBJ_INTEGER;
+ charstring.len = len;
+
+#ifndef USE_MMAP
+ if (!(charstring.data.stringP = (unsigned char *)xalloc(len))) {
+ *rc = AllocError;
+ fclose(fp);
+ return(cp);
+ }
+#endif
+
+ byteoffset = cid->dataoffset + 1 + cstringoffset;
+
+#ifdef USE_MMAP
+ charstring.data.stringP = &cid->CIDdata[byteoffset];
+#else
+ if (fseek(fp, byteoffset, SEEK_SET)) {
+ *rc = BadFontFormat;
+ xfree(charstring.data.stringP);
+ fclose(fp);
+ return(cp);
+ }
+
+ if ((count = fread(charstring.data.stringP, 1, len, fp)) != len) {
+ *rc = BadFontFormat;
+ xfree(charstring.data.stringP);
+ fclose(fp);
+ return(cp);
+ }
+#endif
+
+ if (FontP->Subrs.data.arrayP == NULL) {
+ /* get subroutine data */
+ byteoffset = cid->dataoffset + 1 +
+ FDArrayP[FDindex].Private[CIDT1SUBMAPOFF].value.data.integer;
+
+ SDBytes = FDArrayP[FDindex].Private[CIDT1SDBYTES].value.data.integer;
+
+ SubrCount = FDArrayP[FDindex].Private[CIDT1SUBRCNT].value.data.integer;
+#ifdef USE_MMAP
+ buf = &cid->CIDdata[byteoffset];
+#else
+ if (fseek(fp, byteoffset, SEEK_SET)) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+
+ if ((count = fread(buf, 1, BSIZE, fp)) < SDBytes * (SubrCount + 1)) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+#endif
+
+ arrayP = (psobj *)vm_alloc(SubrCount*sizeof(psobj));
+ if (!arrayP) {
+ *rc = AllocError;
+#ifndef USE_MMAP
+ fclose(fp);
+#endif
+ return(cp);
+ }
+
+ if (!(subroffsets = (long *)xalloc((SubrCount + 1)*sizeof(long)))) {
+ *rc = AllocError;
+#ifndef USE_MMAP
+ fclose(fp);
+#endif
+ return(cp);
+ }
+
+ for (i = 0; i <= SubrCount; i++) {
+ subroffsets[i] = 0;
+ for (j = 0; j < SDBytes; j++)
+ subroffsets[i] += (unsigned char)buf[i * SDBytes + j] <<
+ (8 * (SDBytes - 1 - j));
+ }
+
+ byteoffset = cid->dataoffset + 1 + subroffsets[0];
+
+ /* get subroutine info */
+#ifndef USE_MMAP
+ if (fseek(fp, byteoffset, SEEK_SET)) {
+ *rc = BadFontFormat;
+ xfree(subroffsets);
+ fclose(fp);
+ return(cp);
+ }
+#else
+ total_len = byteoffset;
+#endif
+ for (i = 0; i < SubrCount; i++) {
+ len = subroffsets[i + 1] - subroffsets[i];
+#ifndef USE_MMAP
+ arrayP[i].data.valueP = vm_alloc(len);
+ if (!arrayP[i].data.valueP) {
+ *rc = AllocError;
+ xfree(subroffsets);
+ fclose(fp);
+ return(cp);
+ }
+#endif
+ arrayP[i].len = len;
+#ifdef USE_MMAP
+ arrayP[i].data.valueP = (char *)&cid->CIDdata[total_len];
+ total_len += len;
+#else
+ if ((count = fread(arrayP[i].data.valueP, 1, len, fp)) != len) {
+ *rc = BadFontFormat;
+ xfree(subroffsets);
+ fclose(fp);
+ return(cp);
+ }
+#endif
+ }
+
+ FontP->Subrs.len = SubrCount;
+ FontP->Subrs.data.arrayP = arrayP;
+ xfree(subroffsets);
+ }
+
+ if (FontP->BluesP == NULL) {
+ blues = (struct blues_struct *) vm_alloc(sizeof(struct blues_struct));
+ if (!blues) {
+ *rc = AllocError;
+#ifndef USE_MMAP
+ xfree(subroffsets);
+ fclose(fp);
+#endif
+ return(cp);
+ }
+ bzero(blues, sizeof(struct blues_struct));
+ blues->numBlueValues =
+ FDArrayP[FDindex].Private[CIDT1BLUEVALUES].value.len;
+ for (i = 0; i < blues->numBlueValues; i++)
+ blues->BlueValues[i] =
+ FDArrayP[FDindex].Private[CIDT1BLUEVALUES].value.data.arrayP[i].data.integer;
+ blues->numOtherBlues =
+ FDArrayP[FDindex].Private[CIDT1OTHERBLUES].value.len;
+ for (i = 0; i < blues->numOtherBlues; i++)
+ blues->OtherBlues[i] =
+ FDArrayP[FDindex].Private[CIDT1OTHERBLUES].value.data.arrayP[i].data.integer;
+ blues->numFamilyBlues =
+ FDArrayP[FDindex].Private[CIDT1FAMBLUES].value.len;
+ for (i = 0; i < blues->numFamilyBlues; i++)
+ blues->FamilyBlues[i] =
+ FDArrayP[FDindex].Private[CIDT1FAMBLUES].value.data.arrayP[i].data.integer;
+ blues->numFamilyOtherBlues =
+ FDArrayP[FDindex].Private[CIDT1FAMOTHERBLUES].value.len;
+ for (i = 0; i < blues->numFamilyOtherBlues; i++)
+ blues->FamilyOtherBlues[i] =
+ FDArrayP[FDindex].Private[CIDT1FAMOTHERBLUES].value.data.arrayP[i].data.integer;
+ blues->BlueScale = FDArrayP[FDindex].Private[CIDT1BLUESCALE].value.data.real;
+ blues->BlueShift = FDArrayP[FDindex].Private[CIDT1BLUESHIFT].value.data.integer;
+ blues->BlueFuzz = FDArrayP[FDindex].Private[CIDT1BLUEFUZZ].value.data.integer;
+ blues->StdHW = (double)FDArrayP[FDindex].Private[CIDT1STDHW].value.data.arrayP[0].data.integer;
+ blues->StdVW = (double)FDArrayP[FDindex].Private[CIDT1STDVW].value.data.arrayP[0].data.integer;
+
+ blues->numStemSnapH =
+ FDArrayP[FDindex].Private[CIDT1STEMSNAPH].value.len;
+ for (i = 0; i < blues->numStemSnapH; i++)
+ blues->StemSnapH[i] =
+ FDArrayP[FDindex].Private[CIDT1STEMSNAPH].value.data.arrayP[i].data.integer;
+ blues->numStemSnapV =
+ FDArrayP[FDindex].Private[CIDT1STEMSNAPV].value.len;
+ for (i = 0; i < blues->numStemSnapV; i++)
+ blues->StemSnapV[i] =
+ FDArrayP[FDindex].Private[CIDT1STEMSNAPV].value.data.arrayP[i].data.integer;
+ blues->ForceBold =
+ FDArrayP[FDindex].Private[CIDT1FORCEBOLD].value.data.boolean;
+
+ blues->LanguageGroup =
+ FDArrayP[FDindex].Private[CIDT1LANGGROUP].value.data.integer;
+
+ blues->RndStemUp =
+ FDArrayP[FDindex].Private[CIDT1RNDSTEMUP].value.data.boolean;
+
+ blues->lenIV =
+ FDArrayP[FDindex].Private[CIDT1LENIV].value.data.integer;
+
+ blues->ExpansionFactor =
+ FDArrayP[FDindex].Private[CIDT1EXPFACTOR].value.data.real;
+
+ FontP->BluesP = blues;
+ }
+
+ cp = CIDRenderGlyph(pFont, &charstring, &FontP->Subrs, FontP->BluesP, pci, rc);
+
+#ifndef USE_MMAP
+ xfree(charstring.data.stringP);
+
+ fclose(fp);
+#endif
+ return(cp);
+}
+
+static int
+node_compare(const void *node1, const void *node2)
+{
+ return (((Metrics *)node1)->code - ((Metrics *)node2)->code);
+}
+
+static CharInfoRec *
+CIDGetCharMetrics(FontPtr pFont, FontInfo *fi, unsigned int charcode, double sxmult)
+{
+ CharInfoPtr cp;
+ Metrics *p, node;
+ unsigned int cidcode;
+
+ cidcode = node.code = getCID(pFont, charcode);
+ if ((cidcode < fi->nChars) && (cidcode == fi->metrics[cidcode].code))
+ p = &fi->metrics[cidcode];
+ else
+ p = (Metrics *)bsearch(&node, fi->metrics, fi->nChars, sizeof(Metrics), node_compare);
+
+ if (!p)
+ p = &fi->metrics[0];
+
+ if (!(cp = (CharInfoRec *)Xalloc(sizeof(CharInfoRec))))
+ return NULL;
+ bzero(cp, sizeof(CharInfoRec));
+
+ /* indicate that character bitmap is not defined */
+ cp->bits = (char *)CID_BITMAP_UNDEFINED;
+
+
+ /* get metric data for this CID code from the CID AFM file */
+ cp->metrics.leftSideBearing =
+ floor(p->charBBox.llx / sxmult + 0.5);
+ cp->metrics.rightSideBearing =
+ floor(p->charBBox.urx / sxmult + 0.5);
+ cp->metrics.characterWidth = floor(p->wx / sxmult + 0.5);
+ cp->metrics.ascent = floor(p->charBBox.ury / sxmult + 0.5);
+ cp->metrics.descent = -floor(p->charBBox.lly / sxmult + 0.5);
+
+ cp->metrics.attributes = p->wx;
+
+ return cp;
+}
+
+int
+CIDGetAFM(FontPtr pFont, unsigned long count, unsigned char *chars, FontEncoding charEncoding, unsigned long *glyphCount, CharInfoPtr *glyphs, char *cidafmfile)
+{
+ FILE *fp;
+ FontInfo *fi = NULL;
+ cidglyphs *cid;
+ CharInfoPtr *glyphsBase;
+ register unsigned int c;
+
+ register CharInfoPtr pci;
+ CharInfoPtr pDefault;
+ unsigned int firstCol, code, char_row, char_col;
+ double sxmult;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ if (cid->AFMinfo == NULL) {
+ if (!(fp = fopen(cidafmfile, "rb")))
+ return(BadFontName);
+
+ if (CIDAFM(fp, &fi) != 0) {
+ fprintf(stderr,
+ "There is something wrong with Adobe Font Metric file %s.\n",
+ cidafmfile);
+ fclose(fp);
+ return(BadFontName);
+ }
+ fclose(fp);
+ cid->AFMinfo = fi;
+ }
+ fi = cid->AFMinfo;
+
+ firstCol = pFont->info.firstCol;
+ pDefault = cid->pDefault;
+ glyphsBase = glyphs;
+
+ /* multiplier for computation of raw values */
+ sxmult = hypot(cid->pixel_matrix[0], cid->pixel_matrix[1]);
+ if (sxmult > EPS) sxmult = 1000.0 / sxmult;
+ if (sxmult == 0.0) return(0);
+
+ switch (charEncoding) {
+
+#define EXIST(pci) \
+ ((pci)->metrics.attributes || \
+ (pci)->metrics.ascent != -(pci)->metrics.descent || \
+ (pci)->metrics.leftSideBearing != (pci)->metrics.rightSideBearing)
+
+ case Linear8Bit:
+ case TwoD8Bit:
+ if (pFont->info.firstRow > 0)
+ break;
+ while (count--) {
+ c = (*chars++);
+ if (c >= firstCol && c <= pFont->info.lastCol) {
+ code = c - firstCol;
+ if (!(pci = (CharInfoRec *)cid->glyphs[code]))
+ pci = CIDGetCharMetrics(pFont, fi, c, sxmult);
+ if (pci && EXIST(pci)) {
+ *glyphs++ = pci;
+ cid->glyphs[code] = pci;
+ }
+ } else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ case Linear16Bit:
+ while (count--) {
+ char_row = *chars++;
+ char_col = *chars++;
+ c = char_row << 8;
+ c = (c | char_col);
+ if (pFont->info.firstRow <= char_row && char_row <=
+ pFont->info.lastRow && pFont->info.firstCol <= char_col &&
+ char_col <= pFont->info.lastCol) {
+ code = pFont->info.lastCol - pFont->info.firstCol + 1;
+ char_row = char_row - pFont->info.firstRow;
+ char_col = char_col - pFont->info.firstCol;
+ code = char_row * code + char_col;
+ if (!(pci = (CharInfoRec *)cid->glyphs[code]))
+ pci = CIDGetCharMetrics(pFont, fi, c, sxmult);
+ if (pci && EXIST(pci)) {
+ *glyphs++ = pci;
+ cid->glyphs[code] = pci;
+ } else if (pDefault) {
+ *glyphs++ = pDefault;
+ cid->glyphs[code] = pDefault;
+ }
+ } else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+
+ case TwoD16Bit:
+ while (count--) {
+ char_row = (*chars++);
+ char_col = (*chars++);
+ c = char_row << 8;
+ c = (c | char_col);
+ if (pFont->info.firstRow <= char_row && char_row <=
+ pFont->info.lastRow && pFont->info.firstCol <= char_col &&
+ char_col <= pFont->info.lastCol) {
+ code = pFont->info.lastCol - pFont->info.firstCol + 1;
+ char_row = char_row - pFont->info.firstRow;
+ char_col = char_col - pFont->info.firstCol;
+ code = char_row * code + char_col;
+ if (!(pci = (CharInfoRec *)cid->glyphs[code]))
+ pci = CIDGetCharMetrics(pFont, fi, c, sxmult);
+ if (pci && EXIST(pci)) {
+ *glyphs++ = pci;
+ cid->glyphs[code] = pci;
+ } else if (pDefault) {
+ *glyphs++ = pDefault;
+ cid->glyphs[code] = pDefault;
+ }
+ } else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ }
+ *glyphCount = glyphs - glyphsBase;
+
+#undef EXIST
+
+ return Successful;
+
+}
+#endif
diff --git a/nx-X11/lib/font/Type1/cluts.h b/nx-X11/lib/font/Type1/cluts.h
new file mode 100644
index 000000000..67d930324
--- /dev/null
+++ b/nx-X11/lib/font/Type1/cluts.h
@@ -0,0 +1,35 @@
+/* $Xorg: cluts.h,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* STUB */
+
+#define KillCLUT(T)
+#define CopyCLUT(T) T
+#define UniqueCLUT(T)
+
diff --git a/nx-X11/lib/font/Type1/curves.c b/nx-X11/lib/font/Type1/curves.c
new file mode 100644
index 000000000..9d0c3f8cc
--- /dev/null
+++ b/nx-X11/lib/font/Type1/curves.c
@@ -0,0 +1,228 @@
+/* $Xorg: curves.c,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991 */
+/* All Rights Reserved */
+
+/* License to use, copy, modify, and distribute this software */
+/* and its documentation for any purpose and without fee is */
+/* hereby granted, provided that licensee provides a license to */
+/* IBM, Corp. to use, copy, modify, and distribute derivative */
+/* works and their documentation for any purpose and without */
+/* fee, 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 IBM not be used in advertising or publicity pertaining to */
+/* distribution of the software without specific, written prior */
+/* permission. */
+
+/* IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES */
+/* OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT */
+/* LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY, */
+/* FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF */
+/* THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND */
+/* PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT */
+/* OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF */
+/* THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES */
+/* THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN */
+/* NO EVENT SHALL IBM 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. */
+/* $XFree86: xc/lib/font/Type1/curves.c,v 1.7 2001/08/27 19:49:52 dawes Exp $ */
+
+/*
+:h1.CURVES Module - Stepping Beziers
+
+This module is responsible for "rasterizing"
+third order curves. That is, it changes the high level curve
+specification into a list of pels that that curve travels
+through.
+
+:h3.Include Files
+
+Include files needed:
+*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef FONTMODULE
+# include "os.h"
+#endif
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h"
+#include "curves.h"
+#include "lines.h"
+#include "arith.h"
+
+
+/*
+:h3.Functions Provided to Other Modules
+
+External entry points:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+Note that "stepping" and "flattening" are so similiar that they use the
+same routine. When the "region" parameter is NULL, that is a flag that
+we are flattening instead of stepping.
+*/
+/*
+:h2.Bezier Third Order Curves
+*/
+/*
+:h3.The "bezierinfo" Structure
+
+This structure is used to store information used when we subdivide
+Bezier curves.
+*/
+
+struct bezierinfo {
+ struct region *region; /* the region being built or NULL */
+ struct fractpoint last; /* not used yet; maybe could save some work */
+ struct fractpoint origin; /* the origin of the bezier */
+} ;
+
+/*
+ Checking for termination of the subdivision process:
+ This is the stupidest test in the world, just check if the coordinatewise
+ distance from an end control point to the next control point is less than
+ one half pel. If so, we must be done.
+ This returns 1 if the subdivision is terminated and 0 if you still need
+ to subdivide.
+*/
+
+static int
+BezierTerminationTest(fractpel xa, fractpel ya,
+ fractpel xb, fractpel yb,
+ fractpel xc, fractpel yc,
+ fractpel xd, fractpel yd)
+{
+ fractpel dmax;
+ dmax = ABS(xa - xb);
+ dmax = MAX(dmax,ABS(ya - yb));
+ dmax = MAX(dmax,ABS(xd - xc));
+ dmax = MAX(dmax,ABS(yd - yc));
+ if(dmax > FPHALF)
+ return(0); /* not done yet */
+ else
+ return(1); /* done */
+}
+
+/*
+:h3.StepBezierRecurse() - The Recursive Logic in StepBezier()
+
+The recursion involves dividing the control polygon into two smaller
+control polygons by finding the midpoints of the lines. This idea is
+described in any graphics text book and its simplicity is what caused
+Bezier to define his curves as he did. If the input region 'R' is NULL,
+the result is a path that is the 'flattened' curve; otherwise StepBezier
+returns nothing special.
+*/
+static struct segment *
+StepBezierRecurse(struct bezierinfo *I, /* Region under construction or NULL */
+ fractpel xA, fractpel yA, /* A control point */
+ fractpel xB, fractpel yB, /* B control point */
+ fractpel xC, fractpel yC, /* C control point */
+ fractpel xD, fractpel yD) /* D control point */
+{
+ if (BezierTerminationTest(xA,yA,xB,yB,xC,yC,xD,yD))
+ {
+ if (I->region == NULL)
+ return(PathSegment(LINETYPE, xD - xA, yD - yA));
+ else
+ StepLine(I->region, I->origin.x + xA, I->origin.y + yA,
+ I->origin.x + xD, I->origin.y + yD);
+ }
+ else
+ {
+ fractpel xAB,yAB;
+ fractpel xBC,yBC;
+ fractpel xCD,yCD;
+ fractpel xABC,yABC;
+ fractpel xBCD,yBCD;
+ fractpel xABCD,yABCD;
+
+ xAB = xA + xB; yAB = yA + yB;
+ xBC = xB + xC; yBC = yB + yC;
+ xCD = xC + xD; yCD = yC + yD;
+
+ xABC = xAB + xBC; yABC = yAB + yBC;
+ xBCD = xBC + xCD; yBCD = yBC + yCD;
+
+ xABCD = xABC + xBCD; yABCD = yABC + yBCD;
+
+ xAB >>= 1; yAB >>= 1;
+ xBC >>= 1; yBC >>= 1;
+ xCD >>= 1; yCD >>= 1;
+ xABC >>= 2; yABC >>= 2;
+ xBCD >>= 2; yBCD >>= 2;
+ xABCD >>= 3; yABCD >>= 3;
+
+ if (I->region == NULL)
+ {
+ return( Join(
+ StepBezierRecurse(I, xA, yA, xAB, yAB, xABC, yABC, xABCD, yABCD),
+ StepBezierRecurse(I, xABCD, yABCD, xBCD, yBCD, xCD, yCD, xD, yD)
+ )
+ );
+ }
+ else
+ {
+ StepBezierRecurse(I, xA, yA, xAB, yAB, xABC, yABC, xABCD, yABCD);
+ StepBezierRecurse(I, xABCD, yABCD, xBCD, yBCD, xCD, yCD, xD, yD);
+ }
+ }
+ return NULL;
+ /*NOTREACHED*/
+}
+
+/*
+:h3.TOOBIG() - Macro to Test if a Coordinate is Too Big to Bezier SubDivide Normally
+
+Intermediate values in the Bezier subdivision are 8 times bigger than
+the starting values. If this overflows, a 'long', we are in trouble:
+*/
+
+#undef BITS
+#define BITS (sizeof(long)*8)
+#define HIGHTEST(p) (((p)>>(BITS-4)) != 0) /* includes sign bit */
+#define TOOBIG(xy) ((xy < 0) ? HIGHTEST(-xy) : HIGHTEST(xy))
+
+/*
+:h3.StepBezier() - Produce Run Ends for a Bezier Curve
+
+This is the entry point called from outside the module.
+*/
+
+struct segment *
+StepBezier(struct region *R, /* Region under construction or NULL */
+ fractpel xA, fractpel yA, /* A control point */
+ fractpel xB, fractpel yB, /* B control point */
+ fractpel xC, fractpel yC, /* C control point */
+ fractpel xD, fractpel yD) /* D control point */
+{
+ struct bezierinfo Info;
+
+ Info.region = R;
+ Info.origin.x = xA;
+ Info.origin.y = yA;
+
+ xB -= xA;
+ xC -= xA;
+ xD -= xA;
+ yB -= yA;
+ yC -= yA;
+ yD -= yA;
+
+ if ( TOOBIG(xB) || TOOBIG(yB) || TOOBIG(xC) || TOOBIG(yC)
+ || TOOBIG(xD) || TOOBIG(yD) )
+ Abort("Beziers this big not yet supported");
+
+ return(StepBezierRecurse(&Info,
+ (fractpel) 0, (fractpel) 0, xB, yB, xC, yC, xD, yD));
+}
+
diff --git a/nx-X11/lib/font/Type1/curves.h b/nx-X11/lib/font/Type1/curves.h
new file mode 100644
index 000000000..ca54bad62
--- /dev/null
+++ b/nx-X11/lib/font/Type1/curves.h
@@ -0,0 +1,44 @@
+/* $Xorg: curves.h,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/curves.h,v 1.3 1999/08/22 08:58:50 dawes Exp $ */
+
+/*SHARED*/
+
+#define StepConic(R,xA,yA,xB,yB,xC,yC,r) t1_StepConic(R,xA,yA,xB,yB,xC,yC,r)
+#define StepBezier(R,xA,yA,xB,yB,xC,yC,xD,yD) t1_StepBezier(R,xA,yA,xB,yB,xC,yC,xD,yD)
+
+#define FlattenConic(xM,yM,xC,yC,r) t1_StepConic(NULL,(fractpel)0,(fractpel)0,xM,yM,xC,yC,r)
+#define FlattenBezier(xB,yB,xC,yC,xD,yD) t1_StepBezier(NULL,(fractpel)0,(fractpel)0,xB,yB,xC,yC,xD,yD)
+
+#if 0
+struct segment *t1_StepConic();
+#endif
+extern struct segment *t1_StepBezier ( struct region *R, fractpel xA, fractpel yA, fractpel xB, fractpel yB, fractpel xC, fractpel yC, fractpel xD, fractpel yD );
+
+/*END SHARED*/
diff --git a/nx-X11/lib/font/Type1/digit.h b/nx-X11/lib/font/Type1/digit.h
new file mode 100644
index 000000000..c69380954
--- /dev/null
+++ b/nx-X11/lib/font/Type1/digit.h
@@ -0,0 +1,64 @@
+/* $Xorg: digit.h,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* -------------------------------------- */
+/* --- MACHINE GENERATED, DO NOT EDIT --- */
+/* -------------------------------------- */
+
+#ifndef DIGIT
+#define DIGIT 1
+
+/*
+ * Digit Value Table --
+ *
+ * The entries in the Digit Value Table map character
+ * codes in the set {0-9,a-z,A-Z} to their numeric
+ * values as part of numbers of radix 2-36.
+ *
+ */
+unsigned char digit_value[256] = {
+0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,
+ 0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,
+ 0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+};
+
+#endif
diff --git a/nx-X11/lib/font/Type1/fontfcn.c b/nx-X11/lib/font/Type1/fontfcn.c
new file mode 100644
index 000000000..9b48b9834
--- /dev/null
+++ b/nx-X11/lib/font/Type1/fontfcn.c
@@ -0,0 +1,709 @@
+/* $Xorg: fontfcn.c,v 1.4 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* Author: Katherine A. Hitchcock IBM Almaden Research Laboratory */
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/fontfcn.c,v 1.10 2001/04/05 17:42:27 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#ifndef FONTMODULE
+#include <stdio.h>
+#include <string.h>
+#else
+#include "Xmd.h" /* For INT32 declaration */
+#include "Xdefs.h" /* For Bool */
+#include "xf86_ansic.h"
+#endif
+#include "t1imager.h"
+#include "util.h"
+#if XFONT_CID
+#include "range.h"
+#include <X11/Xdefs.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#include "fontfcn.h"
+
+extern struct segment *Type1Char ( char *env, XYspace S,
+ psobj *charstrP, psobj *subrsP,
+ psobj *osubrsP,
+ struct blues_struct *bluesP, int *modeP );
+
+#if XFONT_CID
+extern struct xobject *CIDChar ( char *env, XYspace S,
+ psobj *charstrP, psobj *subrsP,
+ psobj *osubrsP,
+ struct blues_struct *bluesP, int *modeP );
+static boolean initCIDFont( int cnt );
+#endif
+
+/***================================================================***/
+/* GLOBALS */
+/***================================================================***/
+char CurFontName[120];
+char *CurFontEnv;
+char *vm_base = NULL;
+psfont *FontP = NULL;
+psfont TheCurrentFont;
+#if XFONT_CID
+char CurCIDFontName[CID_PATH_MAX];
+char CurCMapName[CID_PATH_MAX];
+cidfont *CIDFontP = NULL;
+cmapres *CMapP = NULL;
+cidfont TheCurrentCIDFont;
+cmapres TheCurrentCMap;
+psfont *FDArrayP = NULL;
+int FDArrayIndex = 0;
+#endif
+
+/***================================================================***/
+/* SearchDict - look for name */
+/* - compare for match on len and string */
+/* return 0 - not found. */
+/* return n - nth element in dictionary. */
+/***================================================================***/
+int
+SearchDictName(psdict *dictP, psobj *keyP)
+{
+ int i,n;
+
+
+ n = dictP[0].key.len;
+ for (i=1;i<=n;i++) { /* scan the intire dictionary */
+ if (
+ (dictP[i].key.len == keyP->len )
+ &&
+ (strncmp(dictP[i].key.data.valueP,
+ keyP->data.valueP,
+ keyP->len) == 0
+ )
+ ) return(i);
+ }
+ return(0);
+}
+
+#if XFONT_CID
+static boolean
+initCIDFont(int cnt)
+{
+ if (!(vm_init(cnt))) return(FALSE);
+ vm_base = vm_next_byte();
+ strcpy(CurCIDFontName, ""); /* initialize to none */
+ strcpy(CurCMapName, ""); /* initialize to none */
+ /* cause a font data reset on the next Type 1 font */
+ strcpy(CurFontName, ""); /* initialize to none */
+ CIDFontP = &TheCurrentCIDFont;
+ CMapP = &TheCurrentCMap;
+ CIDFontP->vm_start = vm_next_byte();
+ CIDFontP->spacerangecnt = 0;
+ CIDFontP->notdefrangecnt = 0;
+ CIDFontP->cidrangecnt = 0;
+ CIDFontP->spacerangeP = NULL;
+ CIDFontP->notdefrangeP = NULL;
+ CIDFontP->cidrangeP = NULL;
+ CIDFontP->CIDFontFileName.len = 0;
+ CIDFontP->CIDFontFileName.data.valueP = CurCIDFontName;
+ CMapP->CMapFileName.len = 0;
+ CMapP->CMapFileName.data.valueP = CurCMapName;
+ CMapP->firstRow = 0xFFFF;
+ CMapP->firstCol = 0xFFFF;
+ CMapP->lastRow = 0;
+ CMapP->lastCol = 0;
+ return(TRUE);
+}
+
+/***================================================================***/
+boolean
+initCIDType1Font(void)
+{
+ strcpy(CurFontName, ""); /* initialize to none */
+ FontP = &FDArrayP[FDArrayIndex];
+ FontP->vm_start = vm_next_byte();
+ FontP->FontFileName.len = 0;
+ FontP->FontFileName.data.valueP = CurFontName;
+ FontP->Subrs.len = 0;
+ FontP->Subrs.data.stringP = NULL;
+ FontP->CharStringsP = NULL;
+ FontP->Private = NULL;
+ FontP->fontInfoP = NULL;
+ FontP->BluesP = NULL;
+ return(TRUE);
+}
+#endif
+
+boolean
+initFont(int cnt)
+{
+
+ if (!(vm_init(cnt))) return(FALSE);
+ vm_base = vm_next_byte();
+ if (!(Init_BuiltInEncoding())) return(FALSE);
+ strcpy(CurFontName, ""); /* iniitialize to none */
+#if XFONT_CID
+ /* cause a font data reset on the next CID-keyed font */
+ strcpy(CurCIDFontName, ""); /* initialize to none */
+#endif
+ FontP = &TheCurrentFont;
+ FontP->vm_start = vm_next_byte();
+ FontP->FontFileName.len = 0;
+ FontP->FontFileName.data.valueP = CurFontName;
+ return(TRUE);
+}
+/***================================================================***/
+#if XFONT_CID
+static void
+resetCIDFont(char *cidfontname, char *cmapfile)
+{
+
+ vm_next = CIDFontP->vm_start;
+ vm_free = vm_size - ( vm_next - vm_base);
+ CIDFontP->spacerangecnt = 0;
+ CIDFontP->notdefrangecnt = 0;
+ CIDFontP->cidrangecnt = 0;
+ CIDFontP->spacerangeP = NULL;
+ CIDFontP->notdefrangeP = NULL;
+ CIDFontP->cidrangeP = NULL;
+ CIDFontP->CIDfontInfoP = NULL;
+ /* This will load the font into the FontP */
+ strcpy(CurCIDFontName,cidfontname);
+ strcpy(CurCMapName,cmapfile);
+ CIDFontP->CIDFontFileName.len = strlen(CurCIDFontName);
+ CIDFontP->CIDFontFileName.data.valueP = CurCIDFontName;
+ CMapP->CMapFileName.len = strlen(CurCMapName);
+ CMapP->CMapFileName.data.valueP = CurCMapName;
+ CMapP->firstRow = 0xFFFF;
+ CMapP->firstCol = 0xFFFF;
+ CMapP->lastRow = 0;
+ CMapP->lastCol = 0;
+}
+
+static void
+resetCIDType1Font(void)
+{
+
+ vm_next = FontP->vm_start;
+ vm_free = vm_size - ( vm_next - vm_base);
+ FontP->Subrs.len = 0;
+ FontP->Subrs.data.stringP = NULL;
+ FontP->CharStringsP = NULL;
+ FontP->Private = NULL;
+ FontP->fontInfoP = NULL;
+ FontP->BluesP = NULL;
+ /* This will load the font into the FontP */
+ FontP->FontFileName.len = strlen(CurFontName);
+ FontP->FontFileName.data.valueP = CurFontName;
+}
+#endif
+
+static void
+resetFont(char *env)
+{
+
+ vm_next = FontP->vm_start;
+ vm_free = vm_size - ( vm_next - vm_base);
+ FontP->Subrs.len = 0;
+ FontP->Subrs.data.stringP = NULL;
+ FontP->CharStringsP = NULL;
+ FontP->Private = NULL;
+ FontP->fontInfoP = NULL;
+ FontP->BluesP = NULL;
+ /* This will load the font into the FontP */
+ strcpy(CurFontName,env);
+ FontP->FontFileName.len = strlen(CurFontName);
+ FontP->FontFileName.data.valueP = CurFontName;
+
+}
+
+#if XFONT_CID
+/***================================================================***/
+int
+readCIDFont(char *cidfontname, char *cmapfile)
+{
+ int rcode;
+
+ /* restore the virtual memory and eliminate old font */
+ resetCIDFont(cidfontname, cmapfile);
+ /* This will load the font into the FontP */
+ rcode = scan_cidfont(CIDFontP, CMapP);
+ if (rcode == SCAN_OUT_OF_MEMORY) {
+ /* free the memory and start again */
+ if (!(initCIDFont(vm_size * 2))) {
+ /* we are really out of memory */
+ return(SCAN_OUT_OF_MEMORY);
+ }
+ resetCIDFont(cidfontname, cmapfile);
+ rcode = scan_cidfont(CIDFontP, CMapP);
+ /* only double the memory twice, then report error */
+ if (rcode == SCAN_OUT_OF_MEMORY) {
+ /* free the memory and start again */
+ if (!(initCIDFont(vm_size * 2))) {
+ /* we are really out of memory */
+ return(SCAN_OUT_OF_MEMORY);
+ }
+ resetCIDFont(cidfontname, cmapfile);
+ rcode = scan_cidfont(CIDFontP, CMapP);
+ }
+ }
+ return(rcode);
+}
+
+int
+readCIDType1Font(void)
+{
+ int rcode;
+
+ resetCIDType1Font();
+
+ /* This will load the font into the FontP */
+ rcode = scan_cidtype1font(FontP);
+ return(rcode);
+}
+#endif
+
+int
+readFont(char *env)
+{
+ int rcode;
+
+ /* restore the virtual memory and eliminate old font */
+ resetFont(env);
+ /* This will load the font into the FontP */
+ rcode = scan_font(FontP);
+ if (rcode == SCAN_OUT_OF_MEMORY) {
+ /* free the memory and start again */
+#if XFONT_CID
+ /* xfree(vm_base); */
+#else
+ xfree(vm_base);
+#endif
+ if (!(initFont(vm_size * 2))) {
+ /* we are really out of memory */
+ return(SCAN_OUT_OF_MEMORY);
+ }
+ resetFont(env);
+ rcode = scan_font(FontP);
+#if XFONT_CID
+ /* only double the memory twice, then report error */
+ if (rcode == SCAN_OUT_OF_MEMORY) {
+ /* free the memory and start again */
+ /* xfree(vm_base) */
+ if (!(initFont(vm_size * 2))) {
+ /* we are really out of memory */
+ return(SCAN_OUT_OF_MEMORY);
+ }
+ resetFont(env);
+ rcode = scan_font(FontP);
+ }
+#else
+ /* only double the memory once, then report error */
+#endif
+ }
+ return(rcode);
+}
+/***================================================================***/
+struct xobject *
+fontfcnB(struct XYspace *S, unsigned char *code, int *lenP, int *mode)
+{
+ psobj *charnameP; /* points to psobj that is name of character*/
+ int N;
+ psdict *CharStringsDictP; /* dictionary with char strings */
+ psobj CodeName; /* used to store the translation of the name*/
+ psobj *SubrsArrayP;
+ psobj *theStringP;
+
+ struct xobject *charpath; /* the path for this character */
+
+ charnameP = &CodeName;
+ charnameP->len = *lenP;
+ charnameP->data.stringP = code;
+
+ CharStringsDictP = FontP->CharStringsP;
+
+ /* search the chars string for this charname as key */
+ N = SearchDictName(CharStringsDictP,charnameP);
+ if (N<=0) {
+ *mode = FF_PARSE_ERROR;
+ return(NULL);
+ }
+ /* ok, the nth item is the psobj that is the string for this char */
+ theStringP = &(CharStringsDictP[N].value);
+
+ /* get the dictionary pointers to the Subrs */
+
+ SubrsArrayP = &(FontP->Subrs);
+ /* scale the Adobe fonts to 1 unit high */
+ /* call the type 1 routine to rasterize the character */
+ charpath = (struct xobject *)Type1Char((char *)FontP,S,theStringP,
+ SubrsArrayP,NULL,
+ FontP->BluesP , mode);
+ /* if Type1Char reported an error, then return */
+ if ( *mode == FF_PARSE_ERROR) return(NULL);
+ /* fill with winding rule unless path was requested */
+ if (*mode != FF_PATH) {
+ charpath = (struct xobject *)Interior((struct segment *)charpath,
+ WINDINGRULE+CONTINUITY);
+ }
+ return(charpath);
+}
+
+#if XFONT_CID
+/***================================================================***/
+/* CIDfontfcnA(cidfontname, cmapfile, mode) */
+/* */
+/* 1) initialize the font - global indicates it has been done */
+/* 2) load the font */
+/***================================================================***/
+Bool
+CIDfontfcnA(char *cidfontname, char *cmapfile, int *mode)
+{
+ int rcode, cidinit;
+
+ cidinit = 0;
+ if (CIDFontP == NULL || strcmp(CurCIDFontName, "") == 0) {
+ InitImager();
+ if (!(initCIDFont(VM_SIZE))) {
+ /* we are really out of memory */
+ *mode = SCAN_OUT_OF_MEMORY;
+ return(FALSE);
+ }
+ cidinit = 1;
+ }
+
+ /* if the cidfontname is null, then use font already loaded */
+
+ /* if not the same font name */
+ if (cidinit || (cidfontname && strcmp(cidfontname,CurCIDFontName) != 0) ||
+ (cmapfile && strcmp(cmapfile,CurCMapName) != 0)) {
+ /* restore the virtual memory and eliminate old font, read new one */
+ rcode = readCIDFont(cidfontname, cmapfile);
+ if (rcode != 0 ) {
+ strcpy(CurCIDFontName, ""); /* no CIDFont loaded */
+ strcpy(CurCMapName, ""); /* no CMap loaded */
+ *mode = rcode;
+ return(FALSE);
+ }
+ }
+ return(TRUE);
+
+}
+
+/***================================================================***/
+/* CIDType1fontfcnA(mode) */
+/* */
+/* 1) initialize the font - global indicates it has been done */
+/* 2) load the font */
+/***================================================================***/
+Bool
+CIDType1fontfcnA(int *mode)
+{
+ int rcode;
+
+ if (!(initCIDType1Font())) {
+ /* we are really out of memory */
+ *mode = SCAN_OUT_OF_MEMORY;
+ return(FALSE);
+ }
+
+ if ((rcode = readCIDType1Font()) != 0) {
+ strcpy(CurFontName, ""); /* no font loaded */
+ *mode = rcode;
+ return(FALSE);
+ }
+ return(TRUE);
+
+}
+#endif
+
+/***================================================================***/
+/* fontfcnA(env, mode) */
+/* */
+/* env is a pointer to a string that contains the fontname. */
+/* */
+/* 1) initialize the font - global indicates it has been done */
+/* 2) load the font */
+/***================================================================***/
+Bool
+fontfcnA(char *env, int *mode)
+{
+ int rc;
+
+ /* Has the FontP initialized? If not, then */
+ /* Initialize */
+#if XFONT_CID
+ if (FontP == NULL || strcmp(CurFontName, "") == 0) {
+#else
+ if (FontP == NULL) {
+#endif
+ InitImager();
+ if (!(initFont(VM_SIZE))) {
+ /* we are really out of memory */
+ *mode = SCAN_OUT_OF_MEMORY;
+ return(FALSE);
+ }
+ }
+
+ /* if the env is null, then use font already loaded */
+
+ /* if the not same font name */
+ if ( (env) && (strcmp(env,CurFontName) != 0 ) ) {
+ /* restore the virtual memory and eliminate old font, read new one */
+ rc = readFont(env);
+ if (rc != 0 ) {
+ strcpy(CurFontName, ""); /* no font loaded */
+ *mode = rc;
+ return(FALSE);
+ }
+ }
+ return(TRUE);
+
+}
+
+#if XFONT_CID
+/***================================================================***/
+/* CIDQueryFontLib(cidfontname,cmapfile,infoName,infoValue,rcodeP) */
+/* */
+/* cidfontname is a pointer to a string that contains the fontname. */
+/* */
+/* 1) initialize the font - global indicates it has been done */
+/* 2) load the font */
+/* 3) use the font to call getInfo for that value. */
+/***================================================================***/
+
+void
+CIDQueryFontLib(char *cidfontname, char *cmapfile, char *infoName,
+ pointer infoValue, /* parameter returned here */
+ int *rcodeP)
+{
+ int rc,N,i,cidinit;
+ psdict *dictP;
+ psobj nameObj;
+ psobj *valueP;
+
+ /* Has the CIDFontP initialized? If not, then */
+ /* Initialize */
+ cidinit = 0;
+ if (CIDFontP == NULL || strcmp(CurCIDFontName, "") == 0) {
+ InitImager();
+ if (!(initCIDFont(VM_SIZE))) {
+ *rcodeP = 1;
+ return;
+ }
+ cidinit = 1;
+ }
+ /* if the file name is null, then use font already loaded */
+ /* if the not same font name, reset and load next font */
+ if (cidinit || (cidfontname && strcmp(cidfontname,CurCIDFontName) != 0) ||
+ (cmapfile && strcmp(cmapfile,CurCMapName) != 0)) {
+ /* restore the virtual memory and eliminate old font */
+ rc = readCIDFont(cidfontname, cmapfile);
+ if (rc != 0 ) {
+ strcpy(CurCIDFontName, ""); /* no font loaded */
+ strcpy(CurCMapName, ""); /* no font loaded */
+ *rcodeP = 1;
+ return;
+ }
+ }
+ dictP = CIDFontP->CIDfontInfoP;
+ objFormatName(&nameObj,strlen(infoName),infoName);
+ N = SearchDictName(dictP,&nameObj);
+ /* if found */
+ if ( N > 0 ) {
+ *rcodeP = 0;
+ switch (dictP[N].value.type) {
+ case OBJ_ARRAY:
+ valueP = dictP[N].value.data.arrayP;
+ /* Just double check valueP. H.J. */
+ if (valueP == NULL) break;
+ if (strcmp(infoName,"FontMatrix") == 0) {
+ /* 6 elments, return them as floats */
+ for (i=0;i<6;i++) {
+ if (valueP->type == OBJ_INTEGER )
+ ((float *)infoValue)[i] = valueP->data.integer;
+ else
+ ((float *)infoValue)[i] = valueP->data.real;
+ valueP++;
+ }
+ }
+ if (strcmp(infoName,"FontBBox") == 0) {
+ /* 4 elments for Bounding Box. all integers */
+ for (i=0;i<4;i++) {
+ ((int *)infoValue)[i] = valueP->data.integer;
+ valueP++;
+ }
+ break;
+ case OBJ_INTEGER:
+ case OBJ_BOOLEAN:
+ *((int *)infoValue) = dictP[N].value.data.integer;
+ break;
+ case OBJ_REAL:
+ *((float *)infoValue) = dictP[N].value.data.real;
+ break;
+ case OBJ_NAME:
+ case OBJ_STRING:
+ *((char **)infoValue) = dictP[N].value.data.valueP;
+ break;
+ default:
+ *rcodeP = 1;
+ break;
+ }
+ }
+ }
+ else *rcodeP = 1;
+}
+#endif
+
+/***================================================================***/
+/* QueryFontLib(env, infoName,infoValue,rcodeP) */
+/* */
+/* env is a pointer to a string that contains the fontname. */
+/* */
+/* 1) initialize the font - global indicates it has been done */
+/* 2) load the font */
+/* 3) use the font to call getInfo for that value. */
+/***================================================================***/
+
+void
+QueryFontLib(char *env, char *infoName,
+ pointer infoValue, /* parameter returned here */
+ int *rcodeP)
+{
+ int rc,N,i;
+ psdict *dictP;
+ psobj nameObj;
+ psobj *valueP;
+
+ /* Has the FontP initialized? If not, then */
+ /* Initialize */
+ if (FontP == NULL) {
+ InitImager();
+ if (!(initFont(VM_SIZE))) {
+ *rcodeP = 1;
+ return;
+ }
+ }
+ /* if the env is null, then use font already loaded */
+ /* if the not same font name, reset and load next font */
+ if ( (env) && (strcmp(env,CurFontName) != 0 ) ) {
+ /* restore the virtual memory and eliminate old font */
+ rc = readFont(env);
+ if (rc != 0 ) {
+ strcpy(CurFontName, ""); /* no font loaded */
+ *rcodeP = 1;
+ return;
+ }
+ }
+ dictP = FontP->fontInfoP;
+ objFormatName(&nameObj,strlen(infoName),infoName);
+ N = SearchDictName(dictP,&nameObj);
+ /* if found */
+ if ( N > 0 ) {
+ *rcodeP = 0;
+ switch (dictP[N].value.type) {
+ case OBJ_ARRAY:
+ valueP = dictP[N].value.data.arrayP;
+ /* Just double check valueP. H.J. */
+ if (valueP == NULL) break;
+ if (strcmp(infoName,"FontMatrix") == 0) {
+ /* 6 elments, return them as floats */
+ for (i=0;i<6;i++) {
+ if (valueP->type == OBJ_INTEGER )
+ ((float *)infoValue)[i] = valueP->data.integer;
+ else
+ ((float *)infoValue)[i] = valueP->data.real;
+ valueP++;
+ }
+ }
+ if (strcmp(infoName,"FontBBox") == 0) {
+ /* 4 elments for Bounding Box. all integers */
+ for (i=0;i<4;i++) {
+ ((int *)infoValue)[i] = valueP->data.integer;
+ valueP++;
+ }
+ break;
+ case OBJ_INTEGER:
+ case OBJ_BOOLEAN:
+ *((int *)infoValue) = dictP[N].value.data.integer;
+ break;
+ case OBJ_REAL:
+ *((float *)infoValue) = dictP[N].value.data.real;
+ break;
+ case OBJ_NAME:
+ case OBJ_STRING:
+ *((char **)infoValue) = dictP[N].value.data.valueP;
+ break;
+ default:
+ *rcodeP = 1;
+ break;
+ }
+ }
+ }
+ else *rcodeP = 1;
+}
+
+#if XFONT_CID
+struct xobject *
+CIDfontfcnC(struct XYspace *S, psobj *theStringP,
+ psobj *SubrsArrayP, struct blues_struct *BluesP,
+ int *lenP, int *mode)
+{
+ struct xobject *charpath; /* the path for this character */
+
+ charpath = (struct xobject *)CIDChar((char *)FontP,S,theStringP,
+ SubrsArrayP,NULL,BluesP,mode);
+ /* if Type1Char reported an error, then return */
+ if ( *mode == FF_PARSE_ERROR) return(NULL);
+ /* fill with winding rule unless path was requested */
+ if (*mode != FF_PATH) {
+ charpath = (struct xobject *)Interior((struct segment *)charpath,
+ WINDINGRULE+CONTINUITY);
+ }
+ return(charpath);
+}
+#endif
diff --git a/nx-X11/lib/font/Type1/fontfcn.h b/nx-X11/lib/font/Type1/fontfcn.h
new file mode 100644
index 000000000..1409eb9a9
--- /dev/null
+++ b/nx-X11/lib/font/Type1/fontfcn.h
@@ -0,0 +1,250 @@
+/* $Xorg: fontfcn.h,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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 (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/fontfcn.h,v 1.4 1999/08/22 08:58:50 dawes Exp $ */
+
+
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+/* modular config.h defines VERSION as libXfont version */
+#ifdef VERSION
+#undef VERSION
+#endif
+
+#if XFONT_CID
+/* Definition of a PostScript CIDFont resource */
+typedef struct cid_font {
+ char *vm_start;
+ int spacerangecnt;
+ int notdefrangecnt;
+ int cidrangecnt;
+ spacerange *spacerangeP;
+ cidrange *notdefrangeP;
+ cidrange *cidrangeP;
+ int binarydata; /* 1=binary data, 0=hex data */
+ long bytecnt;
+ psobj CIDFontFileName;
+ psdict *CIDfontInfoP;
+} cidfont;
+
+/* Definition of a PostScript CMap resource */
+typedef struct cmap_res {
+ unsigned short firstCol;
+ unsigned short lastCol;
+ unsigned short firstRow;
+ unsigned short lastRow;
+ psobj CMapFileName;
+ psdict *CMapInfoP;
+} cmapres;
+#endif
+
+/* Definition of a PostScript FONT */
+typedef struct ps_font {
+ char *vm_start;
+ psobj FontFileName;
+ psobj Subrs;
+ psdict *CharStringsP;
+ psdict *Private;
+ psdict *fontInfoP;
+struct blues_struct *BluesP;
+} psfont;
+/***================================================================***/
+/* Routines in scan_font */
+/***================================================================***/
+
+extern boolean Init_BuiltInEncoding ( void );
+#if XFONT_CID
+extern int scan_cidfont ( cidfont *CIDFontP, cmapres *CMapP );
+extern int scan_cidtype1font ( psfont *FontP );
+#endif
+extern int scan_font ( psfont *FontP );
+/***================================================================***/
+/* Return codes from scan_font */
+/***================================================================***/
+#define SCAN_OK 0
+#define SCAN_FILE_EOF -1
+#define SCAN_ERROR -2
+#define SCAN_OUT_OF_MEMORY -3
+#define SCAN_FILE_OPEN_ERROR -4
+#define SCAN_TRUE -5
+#define SCAN_FALSE -6
+#define SCAN_END -7
+
+#if XFONT_CID
+/***================================================================***/
+/* Name of CID FontInfo fields */
+/***================================================================***/
+#define CIDCOUNT 1
+#define CIDFONTNAME 2
+#define CIDFONTTYPE 3
+#define CIDVERSION 4
+#define CIDREGISTRY 5
+#define CIDORDERING 6
+#define CIDSUPPLEMENT 7
+#define CIDMAPOFFSET 8
+#define CIDFDARRAY 9
+#define CIDFDBYTES 10
+#define CIDFONTBBOX 11
+#define CIDFULLNAME 12
+#define CIDFAMILYNAME 13
+#define CIDWEIGHT 14
+#define CIDNOTICE 15
+#define CIDGDBYTES 16
+#define CIDUIDBASE 17
+#define CIDXUID 18
+
+/***================================================================***/
+/* Name of CMapInfo fields */
+/***================================================================***/
+#define CMAPREGISTRY 1
+#define CMAPORDERING 2
+#define CMAPSUPPLEMENT 3
+#define CMAPNAME 4
+#define CMAPVERSION 5
+#define CMAPTYPE 6
+#define CMAPWMODE 7
+#define CMAPCIDCOUNT 8
+#endif
+
+/***================================================================***/
+/* Name of FontInfo fields */
+/***================================================================***/
+
+#define FONTNAME 1
+#define PAINTTYPE 2
+#define FONTTYPENUM 3
+#define FONTMATRIX 4
+#define FONTBBOX 5
+#define UNIQUEID 6
+#define STROKEWIDTH 7
+#define VERSION 8
+#define NOTICE 9
+#define FULLNAME 10
+#define FAMILYNAME 11
+#define WEIGHT 12
+#define ITALICANGLE 13
+#define ISFIXEDPITCH 14
+#define UNDERLINEPOSITION 15
+#define UNDERLINETHICKNESS 16
+#define ENCODING 17
+/***================================================================***/
+/* Name of Private values */
+/***================================================================***/
+#define BLUEVALUES 1
+#define OTHERBLUES 2
+#define FAMILYBLUES 3
+#define FAMILYOTHERBLUES 4
+#define BLUESCALE 5
+#define BLUESHIFT 6
+#define BLUEFUZZ 7
+#define STDHW 8
+#define STDVW 9
+#define STEMSNAPH 10
+#define STEMSNAPV 11
+#define FORCEBOLD 12
+#define LANGUAGEGROUP 13
+#define LENIV 14
+#define RNDSTEMUP 15
+#define EXPANSIONFACTOR 16
+
+#if XFONT_CID
+/***================================================================***/
+/* Name of CID Type 1 Private values */
+/***================================================================***/
+#define CIDT1MINFEATURE 1
+#define CIDT1LENIV 2
+#define CIDT1LANGGROUP 3
+#define CIDT1BLUEVALUES 4
+#define CIDT1OTHERBLUES 5
+#define CIDT1BLUESCALE 6
+#define CIDT1BLUEFUZZ 7
+#define CIDT1BLUESHIFT 8
+#define CIDT1FAMBLUES 9
+#define CIDT1FAMOTHERBLUES 10
+#define CIDT1STDHW 11
+#define CIDT1STDVW 12
+#define CIDT1STEMSNAPH 13
+#define CIDT1STEMSNAPV 14
+#define CIDT1SUBMAPOFF 15
+#define CIDT1SDBYTES 16
+#define CIDT1SUBRCNT 17
+#define CIDT1FORCEBOLD 18
+#define CIDT1RNDSTEMUP 19
+#define CIDT1EXPFACTOR 20
+
+#define CID_BITMAP_UNDEFINED 0
+extern int SearchDictName ( psdict *dictP, psobj *keyP );
+#if XFONT_CID
+extern boolean initCIDType1Font ( void );
+#endif
+extern boolean initFont ( int cnt );
+#if XFONT_CID
+extern int readCIDFont ( char *cidfontname, char *cmapfile );
+extern int readCIDType1Font ( void );
+#endif
+extern int readFont ( char *env );
+extern struct xobject *fontfcnB ( struct XYspace *S, unsigned char *code,
+ int *lenP, int *mode );
+#if XFONT_CID
+extern Bool CIDfontfcnA ( char *cidfontname, char *cmapfile, int *mode );
+extern Bool CIDType1fontfcnA ( int *mode );
+#endif
+extern Bool fontfcnA ( char *env, int *mode );
+#if XFONT_CID
+extern void CIDQueryFontLib ( char *cidfontname, char *cmapfile,
+ char *infoName, pointer infoValue, int *rcodeP );
+#endif
+extern void QueryFontLib ( char *env, char *infoName, pointer infoValue,
+ int *rcodeP );
+#if XFONT_CID
+extern struct xobject *CIDfontfcnC ( struct XYspace *S, psobj *theStringP,
+ psobj *SubrsArrayP,
+ struct blues_struct *BluesP, int *lenP,
+ int *mode );
+#endif
+#endif
diff --git a/nx-X11/lib/font/Type1/fonts.h b/nx-X11/lib/font/Type1/fonts.h
new file mode 100644
index 000000000..7215e0f7a
--- /dev/null
+++ b/nx-X11/lib/font/Type1/fonts.h
@@ -0,0 +1,49 @@
+/* $Xorg: fonts.h,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+
+/* STUB */
+
+#define CopyFont(f) f
+#define UniqueFont(f) f
+#define KillFont(f)
+#define KillText(t)
+#define CopyText(t) t
+#define I_DumpText(t)
+#define CoerceText(t) t
+#define TextDelta(t,pt)
+#define XformText(p,s)
+#define GimeSpace() FALSE
+
+#define LibInit()
+#define InitFonts()
+#define InitFiles()
+#define TraceClose()
+
+#define FF_PARSE_ERROR -1
diff --git a/nx-X11/lib/font/Type1/hdigit.h b/nx-X11/lib/font/Type1/hdigit.h
new file mode 100644
index 000000000..fbaa9c1db
--- /dev/null
+++ b/nx-X11/lib/font/Type1/hdigit.h
@@ -0,0 +1,94 @@
+/* $Xorg: hdigit.h,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* -------------------------------------- */
+/* --- MACHINE GENERATED, DO NOT EDIT --- */
+/* -------------------------------------- */
+
+#ifndef HDIGIT
+#define HDIGIT 1
+
+/*
+ * Hex Digit Value Table --
+ *
+ * The entries in the Digit Value Table map character codes in the set
+ * {0-9,a-f,A-F} to their numeric values for readhexstring
+ * (00 10...F0 for the high hex digit and 00 01...0F for the low).
+ * The white-space and hex string termination characters are.
+ * mapped to codes > 0xf0 to enable usage by several modules.
+ * 2 tables are build HighHex and LowHex.
+ *
+ */
+
+/* Indicators for special characters in these tables */
+#define HERROR (0xfe)
+#define HWHITE_SPACE (0xfd)
+#define HRIGHT_ANGLE (0xfc)
+#define LAST_HDIGIT (0xf0)
+
+#define HighHexP (HighHex+1)
+unsigned char HighHex[257] = { 0xFF,
+ 0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFD,0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xFE,0xFE,0xFE,0xFE,0xFC,0xFE,
+ 0xFE,0xA0,0xB0,0xC0,0xD0,0xE0,0xF0,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xA0,0xB0,0xC0,0xD0,0xE0,0xF0,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE
+};
+#define LowHexP (LowHex+1)
+unsigned char LowHex[257] = { 0xFF,
+ 0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFD,0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0xFE,0xFE,0xFE,0xFE,0xFC,0xFE,
+ 0xFE,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE
+};
+
+#endif
diff --git a/nx-X11/lib/font/Type1/hints.c b/nx-X11/lib/font/Type1/hints.c
new file mode 100644
index 000000000..14deac229
--- /dev/null
+++ b/nx-X11/lib/font/Type1/hints.c
@@ -0,0 +1,890 @@
+/* $Xorg: hints.c,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/hints.c,v 1.7tsi Exp $ */
+
+ /* HINTS CWEB V0006 ******** */
+/*
+:h1.HINTS Module - Processing Rasterization Hints
+
+&author. Sten F. Andler; continuity by Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com) and Duaine
+W. Pryor, Jr.
+
+
+:h3.Include Files
+
+The included files are:
+*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef FONTMODULE
+# include "os.h"
+#endif
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h"
+#include "hints.h"
+
+/*
+:h3.Functions Provided to the TYPE1IMAGER User
+
+None.
+*/
+
+/*
+:h3.Functions Provided to Other Modules
+
+This module provides the following entry point to other modules:
+*/
+
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h3.Macros Provided to Other Modules
+
+None.
+*/
+
+/*
+:h2.InitHints() - Initialize hint data structure
+*/
+
+#define MAXLABEL 20
+static struct {
+ int inuse;
+ int computed;
+ struct fractpoint hint;
+} oldHint[MAXLABEL];
+
+#define ODD(x) (((int)(x)) & 01)
+#define FPFLOOR(fp) TOFRACTPEL((fp) >> FRACTBITS)
+#define FPROUND(fp) FPFLOOR((fp) + FPHALF)
+
+void
+InitHints(void)
+{
+ int i;
+
+ for (i = 0; i < MAXLABEL; i++)
+ {
+ oldHint[i].inuse = FALSE;
+ oldHint[i].computed = FALSE;
+ }
+}
+
+/*
+:h3.CloseHints(hintP) - Reverse hints that are still open
+*/
+
+void
+CloseHints(struct fractpoint *hintP)
+{
+ int i;
+
+ for (i = 0; i < MAXLABEL; i++)
+ {
+ if (oldHint[i].inuse)
+ {
+ hintP->x -= oldHint[i].hint.x;
+ hintP->y -= oldHint[i].hint.y;
+
+ oldHint[i].inuse = FALSE;
+ }
+ }
+}
+
+/*
+:h3.ComputeHint(hP, currX, currY, hintP) - Compute the value of a hint
+*/
+
+static void
+ComputeHint(struct hintsegment *hP,
+ fractpel currX, fractpel currY,
+ struct fractpoint *hintP)
+{
+ fractpel currRef, currWidth;
+ int idealWidth;
+ fractpel hintValue;
+ char orientation;
+
+/*
+By construction, width is never zero. Therefore we can use the
+width value to determine if the hint has been rotated by a
+multiple of 90 degrees.
+*/
+
+ if (hP->width.y == 0)
+ {
+ orientation = 'v'; /* vertical */
+ }
+ else if (hP->width.x == 0)
+ {
+ orientation = 'h'; /* horizontal */
+ }
+ else
+ {
+ hintP->x = hintP->y = 0;
+ return;
+ }
+
+ /* Compute currRef and currWidth with a unit of 1 pel */
+ if (orientation == 'v') /* vertical */
+ {
+ currRef = hP->ref.x + currX;
+ currWidth = ABS(hP->width.x);
+ }
+ else if (orientation == 'h') /* horizontal */
+ {
+ currRef = hP->ref.y + currY;
+ currWidth = ABS(hP->width.y);
+ }
+ else /* error */
+ {
+ Abort("ComputeHint: invalid orientation");
+ }
+
+ if ((hP->hinttype == 'b') /* Bar or stem */
+ || (hP->hinttype == 's')) /* Serif */
+ {
+ idealWidth = NEARESTPEL(currWidth);
+ if (idealWidth == 0) idealWidth = 1;
+ if (ODD(idealWidth)) /* Is ideal width odd? */
+ {
+ /* center "ref" over pel */
+ hintValue = FPFLOOR(currRef) + FPHALF - currRef;
+ }
+ else
+ {
+ /* align "ref" on pel boundary */
+ hintValue = FPROUND(currRef) - currRef;
+ }
+ }
+ else if (hP->hinttype == 'c') /* Curve extrema */
+ {
+ /* align "ref" on pel boundary */
+ hintValue = FPROUND(currRef) - currRef;
+ }
+ else /* error */
+ {
+ Abort("ComputeHint: invalid hinttype");
+ }
+
+ if (orientation == 'v') /* vertical */
+ {
+ hintP->x = hintValue;
+ hintP->y = 0;
+ }
+ else if (orientation == 'h') /* horizontal */
+ {
+ hintP->x = 0;
+ hintP->y = hintValue;
+ }
+ else /* error */
+ {
+ Abort("ComputeHint: invalid orientation");
+ }
+}
+
+/*
+:h3.ProcessHint(hP, currX, currY, hintP) - Process a rasterization hint
+*/
+
+void
+ProcessHint(struct hintsegment *hP,
+ fractpel currX, fractpel currY,
+ struct fractpoint *hintP)
+{
+ struct fractpoint thisHint;
+
+ if ((hP->adjusttype == 'm') /* Move */
+ || (hP->adjusttype == 'a')) /* Adjust */
+ {
+ /* Look up hint in oldHint table */
+ if ((hP->label >= 0) && (hP->label < MAXLABEL))
+ {
+ if (oldHint[hP->label].computed)
+ /* Use old hint value if already computed */
+ {
+ thisHint.x = oldHint[hP->label].hint.x;
+ thisHint.y = oldHint[hP->label].hint.y;
+ oldHint[hP->label].inuse = TRUE;
+ }
+ else
+ /* Compute new value for hint and store it for future use */
+ {
+ ComputeHint(hP, currX, currY, &thisHint);
+
+ oldHint[hP->label].hint.x = thisHint.x;
+ oldHint[hP->label].hint.y = thisHint.y;
+ oldHint[hP->label].inuse = TRUE;
+ oldHint[hP->label].computed = TRUE;
+ }
+ }
+ else /* error */
+ {
+ Abort("ProcessHint: invalid label");
+ }
+ }
+ else if (hP->adjusttype == 'r') /* Reverse */
+ {
+ /* Use the inverse of the existing hint value to reverse hint */
+ if ((hP->label >= 0) && (hP->label < MAXLABEL))
+ {
+ if (oldHint[hP->label].inuse)
+ {
+ thisHint.x = -oldHint[hP->label].hint.x;
+ thisHint.y = -oldHint[hP->label].hint.y;
+ oldHint[hP->label].inuse = FALSE;
+ }
+ else /* error */
+ {
+ Abort("ProcessHint: label is not in use");
+ }
+ }
+ else /* error */
+ {
+ Abort("ProcessHint: invalid label");
+ }
+
+ }
+ else /* error */
+ {
+ Abort("ProcessHint: invalid adjusttype");
+ }
+
+ hintP->x += thisHint.x;
+ hintP->y += thisHint.y;
+}
+
+/*
+:h2 id=subpath.Navigation Through Edge Lists
+
+For continuity checking purposes, we need to navigate through edge
+lists by the "subpath" chains and answer questions about edges. The
+subpath chain links together edges that were part of the same subpath
+(no intervening move segments) when the interior of the path was
+calculated. Here we use the term "edge" to mean every edge list
+that was created in between changes of direction.
+
+The subpath chains are singly-linked circular chains. For the convenience
+of building them, they direction of the list (from edge to edge) is the
+reverse of the order in which they were built. Within any single edge,
+the subpath chain goes from top-to-bottom. (There might be a violation
+of this because of the way the user started the first chain; see
+:hdref refid=fixsubp..).
+
+:h3.ISTOP() and ISBOTTOM() - Flag Bits for Edge Lists at the Top and
+Bottom of Their SubPaths
+*/
+
+#define ISTOP(flag) ((flag)&0x20)
+#define ISBOTTOM(flag) ((flag)&0x10)
+/*
+:h3.ISLEFT() - Flag Bit for Left Edges
+*/
+
+#define ISLEFT(flag) ((flag)&0x08)
+
+/*
+:h3.XofY() - Macro to Find X Value at Given Y
+
+This macro can only be used if it is known that the Y is within the
+given edgelist's ymin and ymax.
+*/
+
+#define XofY(edge, y) edge->xvalues[y - edge->ymin]
+
+/*
+:h3.findXofY() - Like XofY(), Except not Restricted
+
+If the Y is out of bounds of the given edgelist, this macro will
+call SearchXofY to search the edge's subpath chain for the correct
+Y range. If the Y value is off the edge, MINPEL is returned.
+*/
+#define findXofY(edge, y) ((y < edge->ymin || y >= edge->ymax) ? SearchXofY(edge, y) : XofY(edge, y))
+
+/*
+:h4.SearchXofY() - Routine Called by FindXofY() for Difficult Cases
+
+The concept of this routine is to follow the subpath chain to find the
+edge just below (i.e., next in chain) or just above (i.e., immediately
+before in chain. It is assumed that the Y value is no more than one
+off of the edge's range; XofY() could be replace by FindXofY() to
+call ourselves recursively if this were not true.
+*/
+
+static pel
+SearchXofY(register struct edgelist *edge, /* represents edge */
+ register pel y) /* 'y' value to find edge for */
+{
+ register struct edgelist *e; /* loop variable */
+
+ if (y < edge->ymin) {
+ if (ISTOP(edge->flag))
+ return(MINPEL);
+ for (e = edge->subpath; e->subpath != edge; e = e->subpath) { ; }
+ if (e->ymax == edge->ymin)
+ return(XofY(e, y));
+ }
+ else if (y >= edge->ymax) {
+ if (ISBOTTOM(edge->flag))
+ return(MINPEL);
+ e = edge->subpath;
+ if (e->ymin == edge->ymax)
+ return(XofY(e, y));
+ }
+ else
+ return(XofY(edge, y));
+
+ Abort("bad subpath chain");
+ /*NOTREACHED*/
+}
+/*
+:h3.ISBREAK() Macro - Tests if an Edge List is at a "Break"
+
+The subpath chains are organized top to bottom. When the bottom of
+a given edge is reached, the subpath chain points to the top of the
+next edge. We call this a "break" in the chain. The following macro
+is the simple test for the break condition:
+*/
+
+#define ISBREAK(top,bot) (top->ymax != bot->ymin)
+
+
+/*
+:h3.ImpliedHorizontalLine() - Tests for Horizontal Connectivity
+
+This function returns true if two edges are connected horizontally.
+They are connected horizontally if they are consecutive in the subpath,
+and either we are at the bottom and the first edge is going down or we
+are at the top and the first edge is going up.
+*/
+
+#define BLACKABOVE -1
+#define BLACKBELOW +1
+#define NONE 0
+
+static int
+ImpliedHorizontalLine(struct edgelist *e1, /* two edges to check */
+ struct edgelist *e2,
+ int y) /* y where they might be connected */
+{
+ register struct edgelist *e3,*e4;
+
+ if (ISDOWN(e1->flag) == ISDOWN(e2->flag))
+ return(NONE); /* can't be consecutive unless different directions */
+/*
+Now we check for consecutiveness: Can we get from 'e1' to 'e2' with
+only one intervening break? Can we get from 'e2' to 'e1' with only one
+intervening break? 'e3' will be as far as we can get after 'e1'; 'e4'
+will be has far as we can get after 'e2':
+*/
+ for (e3 = e1; !ISBREAK(e3, e3->subpath); e3 = e3->subpath) { ; }
+ for (e3 = e3->subpath; e3 != e2; e3 = e3->subpath)
+ if (ISBREAK(e3, e3->subpath))
+ break;
+
+ for (e4 = e2; !ISBREAK(e4, e4->subpath); e4 = e4->subpath) { ; }
+ for (e4 = e4->subpath; e4 != e1; e4 = e4->subpath)
+ if (ISBREAK(e4, e4->subpath))
+ break;
+/*
+If the edges are mutually consecutive, we must have horizontal lines
+both top and bottom:
+*/
+ if (e3 == e2 && e4 == e1)
+ return(TRUE);
+/*
+If the edges are not consecutive either way, no horizontal lines are
+possible:
+*/
+ if (e3 != e2 && e4 != e1)
+ return(NONE);
+/*
+Now let's swap 'e1' and 'e2' if necessary to enforce the rule that 'e2'
+follows 'e1'. Remember that subpath chains go in the opposite direction
+from the way the subpaths were built; this led to the simplest way
+do build them.
+*/
+ if (e4 != e1) {
+ e2 = e1;
+ e1 = e3; /* remember e3 == e2, this just swaps 'e1' and 'e2' */
+ }
+/*
+Now we have everything to return the answer:
+*/
+ if (ISTOP(e1->flag) && y == e1->ymin)
+ return(ISDOWN(e2->flag));
+ else if (ISBOTTOM(e1->flag) && y == e1->ymax)
+ return(!ISDOWN(e2->flag));
+ else
+ Abort("ImpliedHorizontalLine: why ask?");
+ /*NOTREACHED*/
+}
+
+/*
+:h3 id=fixsubp.FixSubPaths() - Must be Called to Organize Subpath Chains
+
+The region-building code in Interior(), in particular splitedge(),
+maintains the rule that sub-paths are linked top-to-bottom except
+at breaks. However, it is possible that there may be a "false break"
+because the user started the subpath in the middle of an edge (and
+went in the "wrong" direction from there, up instead of down). This
+routine finds and fixes false breaks.
+
+Also, this routine sets the ISTOP and ISBOTTOM flags in the edge lists.
+*/
+
+static void
+FixSubPaths(struct region *R) /* anchor of region */
+{
+ register struct edgelist *e; /* fast loop variable */
+ register struct edgelist *edge; /* current edge in region */
+ register struct edgelist *next; /* next in subpath after 'edge' */
+ register struct edgelist *break1; /* first break after 'next' */
+ register struct edgelist *break2 = NULL; /* last break before 'edge' */
+ register struct edgelist *prev; /* previous edge for fixing links */
+ int left = TRUE;
+
+ for (edge = R->anchor; edge != NULL; edge = edge->link) {
+
+ if (left)
+ edge->flag |= ISLEFT(ON);
+ left = !left;
+
+ next = edge->subpath;
+
+ if (!ISBREAK(edge, next))
+ continue;
+ if (edge->ymax < next->ymin)
+ Abort("disjoint subpath?");
+/*
+'edge' now contains an edgelist at the bottom of an edge, and 'next'
+contains the next subsequent edgelist in the subpath, which must be at
+the top. We refer to this a "break" in the subpath.
+*/
+ next->flag |= ISTOP(ON);
+ edge->flag |= ISBOTTOM(ON);
+
+ if (ISDOWN(edge->flag) != ISDOWN(next->flag))
+ continue;
+/*
+We are now in the unusual case; both edges are going in the same
+direction so this must be a "false break" due to the way that the user
+created the path. We'll have to fix it.
+*/
+ for (break1 = next; !ISBREAK(break1, break1->subpath); break1 = break1->subpath) { ; }
+
+ for (e = break1->subpath; e != edge; e = e->subpath)
+ if (ISBREAK(e, e->subpath))
+ break2 = e;
+/*
+Now we've set up 'break1' and 'break2'. I've found the following
+diagram invaluable. 'break1' is the first break after 'next'. 'break2'
+is the LAST break before 'edge'.
+&drawing.
+ next
+ +------+ +---->+------+
+ +--->| >-----+ | | >-----+
+ | | | | | | | |
+ | +-------------+ | +-------------+
+ | | |break1| | | | |
+ | +->| >-------+ +->| >-----+
+ | | | | | |
+ | | | +-------------+
+ | +------+ | | |
+ | +----------------+ | | |
+ | | +------+ | +->| >-----+
+ | +->| >-----+ | | | |
+ | | | | | +-------------+
+ | +-------------+ | | | |
+ | | |edge | | | |break2|
+ | +->| >-----+ | +->| >-----+
+ | | | | | | | |
+ | | | | | | | |
+ | | | | | | | |
+ | +------+ | | +------+ |
+ | | | |
+ +---------------+ +---------------+
+
+&edrawing.
+We want to fix this situation by having 'edge' point to where 'break1'
+now points, and having 'break1' point to where 'break2' now points.
+Finally, 'break2' should point to 'next'. Also, we observe that
+'break1' can't be a bottom, and is also not a top unless it is the same
+as 'next':
+*/
+ edge->subpath = break1->subpath;
+
+ break1->subpath = break2->subpath;
+ if (ISBREAK(break1, break1->subpath))
+ Abort("unable to fix subpath break?");
+
+ break2->subpath = next;
+
+ break1->flag &= ~ISBOTTOM(ON);
+ if (break1 != next)
+ break1->flag &= ~ISTOP(ON);
+ }
+/*
+This region might contain "ambiguous" edges; edges exactly equal to
+edge->link. Due to the random dynamics of where they get sorted into
+the list, they can yield false crossings, where the edges appear
+to cross. This confuses our continuity logic no end. Since we can
+swap them without changing the region, we do.
+*/
+ for (edge = R->anchor, prev = NULL; VALIDEDGE(edge); prev = edge, edge = prev->link) {
+
+ if (! ISAMBIGUOUS(edge->flag))
+ continue;
+
+ next = edge->subpath;
+
+ while (ISAMBIGUOUS(next->flag) && next != edge)
+ next = next->subpath;
+/*
+We've finally found a non-ambiguous edge; we make sure it is left/right
+compatible with 'edge':
+*/
+ if ( (ISLEFT(edge->flag) == ISLEFT(next->flag) && ISDOWN(edge->flag) == ISDOWN(next->flag) )
+ || (ISLEFT(edge->flag) != ISLEFT(next->flag) && ISDOWN(edge->flag) != ISDOWN(next->flag) ) )
+ continue;
+
+/*
+Incompatible, we will swap 'edge' and the following edge in the list.
+You may think that there must be a next edge in this swath. So did I.
+No! If there is a totally ambiguous inner loop, for example, we could
+get all the way to the outside without resolving ambiguity.
+*/
+ next = edge->link; /* note new meaning of 'next' */
+ if (next == NULL || edge->ymin != next->ymin)
+ continue;
+ if (prev == NULL)
+ R->anchor = next;
+ else
+ prev->link = next;
+ edge->link = next->link;
+ next->link = edge;
+ edge->flag ^= ISLEFT(ON);
+ edge->flag &= ~ISAMBIGUOUS(ON);
+ next->flag ^= ISLEFT(ON);
+ next->flag &= ~ISAMBIGUOUS(ON);
+ edge = next;
+ }
+}
+/*
+:h3.DumpSubPaths()
+
+A debug tool.
+*/
+
+static struct edgelist *before(struct edgelist *e); /* subroutine of DumpSubPaths */
+
+static void
+DumpSubPaths(struct edgelist *anchor)
+{
+
+ register struct edgelist *edge,*e,*e2;
+ pel y;
+
+ for (edge = anchor; VALIDEDGE(edge); edge = edge->link) {
+ if (ISPERMANENT(edge->flag))
+ continue;
+ for (e2 = edge; !ISPERMANENT(e2->flag);) {
+ if (ISDOWN(e2->flag)) {
+ for (e = e2;; e = e->subpath) {
+ for (y=e->ymin+1; y < e->ymax; y++)
+ e->flag |= ISPERMANENT(ON);
+ if (ISBREAK(e, e->subpath))
+ break;
+ }
+ }
+ else {
+ for (e = e2; !ISBREAK(e, e->subpath); e = e->subpath) { ; }
+ for (;; e=before(e)) {
+ for (y=e->ymax-2; y >= e->ymin; y--)
+ e->flag |= ISPERMANENT(ON);
+ if (e == e2)
+ break;
+ }
+ }
+ do {
+ e2 = before(e2);
+ } while (!ISBREAK(before(e2), e2));
+ }
+ }
+}
+
+static struct edgelist *
+before(struct edgelist *e)
+{
+ struct edgelist *r;
+ for (r = e->subpath; r->subpath != e; r = r->subpath) { ; }
+ return(r);
+}
+
+/*
+:h2.Fixing Region Continuity Problems
+
+Small regions may become disconnected when their connecting segments are
+less than a pel wide. This may be correct in some applications, but in
+many (especially small font characters), it is more pleasing to keep
+connectivity. ApplyContinuity() (invoked by +CONTINUITY on the
+Interior() fill rule) fixes connection breaks. The resulting region
+is geometrically less accurate, but may be more pleasing to the eye.
+*/
+/*
+Here are some macros which we will need:
+*/
+
+#define IsValidPel(j) (j!=MINPEL)
+
+/*
+:h3.writeXofY() - Stuffs an X Value Into an "edgelist"
+
+writeXofY writes an x value into an edge at position 'y'. It must
+update the edge's xmin and xmax. If there is a possibility that this
+new x might exceed the region's bounds, updating those are the
+responsibility of the caller.
+*/
+
+static void
+writeXofY(struct edgelist *e,/* relevant edgelist */
+ int y, /* y value */
+ int x) /* new x value */
+{
+ if (e->xmin > x) e->xmin = x;
+ if (e->xmax < x) e->xmax = x;
+ e->xvalues[y - e->ymin] = x;
+}
+
+/*-------------------------------------------------------------------------*/
+/* the following three macros tell us whether we are at a birth point, a */
+/* death point, or simply in the middle of the character */
+/*-------------------------------------------------------------------------*/
+#define WeAreAtTop(e,i) (ISTOP(e->flag) && e->ymin == i)
+#define WeAreAtBottom(e,i) (ISBOTTOM(e->flag) && e->ymax-1 == i)
+#define WeAreInMiddle(e,i) \
+ ((!ISTOP(e->flag) && !ISBOTTOM(e->flag))||(i < e->ymax-1 && i > e->ymin))
+/*
+The following macro tests if two "edgelist" structures are in the same
+swath:
+*/
+#define SAMESWATH(e1,e2) (e1->ymin == e2->ymin)
+
+/*
+:h3.CollapseWhiteRun() - Subroutine of ApplyContinuity()
+
+When we have a white run with an implied horizontal line above or
+below it, we better have black on the other side of this line. This
+function both tests to see if black is there, and adjusts the end
+points (collapses) the white run as necessary if it is not. The
+goal is to collapse the white run as little as possible.
+*/
+
+static void
+CollapseWhiteRun(struct edgelist *anchor, /* anchor of edge list */
+ pel yblack, /* y of (hopefully) black run above or below */
+ struct edgelist *left, /* edgelist at left of WHITE run */
+ struct edgelist *right, /* edgelist at right of WHITE run */
+ pel ywhite) /* y location of white run */
+{
+ struct edgelist *edge;
+ struct edgelist *swathstart = anchor;
+ register pel x;
+
+ if (XofY(left, ywhite) >= XofY(right, ywhite))
+ return;
+/*
+Find the swath with 'yblack'. If we don't find it, completely collapse
+the white run and return:
+*/
+ while (VALIDEDGE(swathstart)) {
+ if (yblack < swathstart->ymin) {
+ writeXofY(left, ywhite, XofY(right, ywhite));
+ return;
+ }
+ if (yblack < swathstart->ymax) break;
+ swathstart = swathstart->link->link;
+ }
+ if(!VALIDEDGE(swathstart)) {
+ writeXofY(left, ywhite, XofY(right, ywhite));
+ return;
+ }
+/*
+Now we are in the swath that contains 'y', the reference line above
+or below that we are trying to maintain continuity with. If black
+in this line begins in the middle of our white run, we must collapse
+the white run from the left to that point. If black ends in the
+middle of our white run, we must collapse the white run from the right
+to that point.
+*/
+ for (edge = swathstart; VALIDEDGE(edge); edge = edge->link) {
+
+ if (!SAMESWATH(swathstart,edge))
+ break;
+ if( XofY(edge, yblack) > XofY(left, ywhite)) {
+ if (ISLEFT(edge->flag)) {
+ x = XofY(edge, yblack);
+ if (XofY(right, ywhite) < x)
+ x = XofY(right, ywhite);
+ writeXofY(left, ywhite, x);
+ }
+ else {
+ x = XofY(edge, yblack);
+ while (edge->link != NULL && SAMESWATH(edge, edge->link)
+ && x >= XofY(edge->link, yblack) ) {
+ edge = edge->link->link;
+ x = XofY(edge, yblack);
+ }
+ if (x < XofY(right, ywhite))
+ writeXofY(right, ywhite, x);
+ return;
+ }
+ }
+ }
+ writeXofY(left, ywhite, XofY(right, ywhite));
+}
+
+/*
+:h3.ApplyContinuity() - Fix False Breaks in a Region
+
+This is the externally visible routine called from the REGIONS module
+when the +CONTINUITY flag is on the Interior() fill rule.
+*/
+
+void
+ApplyContinuity(struct region *R)
+{
+ struct edgelist *left;
+ struct edgelist *right;
+ struct edgelist *edge,*e2;
+ pel rightXabove,rightXbelow,leftXabove,leftXbelow;
+ pel leftX,rightX;
+ int i;
+ long newcenter,abovecenter,belowcenter;
+
+ FixSubPaths(R);
+ if (RegionDebug >= 3)
+ DumpSubPaths(R->anchor);
+ left = R->anchor;
+/* loop through and do all of the easy checking. ( no tops or bottoms) */
+ while(VALIDEDGE(left))
+ {
+ right = left->link;
+ for(i=left->ymin;i<left->ymax;++i)
+ {
+ leftX = findXofY(left,i);
+ rightX = findXofY(right,i);
+ leftXbelow = findXofY(left,i+1);
+ rightXbelow = findXofY(right,i+1);
+ if(rightX <= leftX)
+ {
+/* then, we have a break in a near vertical line */
+ leftXabove = findXofY(left,i-1);
+ rightXabove = findXofY(right,i-1);
+ if( IsValidPel(leftXabove) && IsValidPel(rightXabove) )
+ {
+ abovecenter = leftXabove + rightXabove;
+ }
+ else
+ {
+ abovecenter = leftX + rightX;
+ }
+ if( IsValidPel(leftXbelow) && IsValidPel(rightXbelow) )
+ {
+ belowcenter = leftXbelow + rightXbelow;
+ }
+ else
+ {
+ belowcenter = leftX + rightX;
+ }
+ newcenter = abovecenter + belowcenter;
+ if( newcenter > 4*leftX )
+ {
+ rightX = rightX + 1;
+ }
+ else if( newcenter < 4*leftX)
+ {
+ leftX = leftX - 1;
+ }
+ else
+ {
+ rightX = rightX + 1;
+ }
+ writeXofY(right,i,rightX);
+ writeXofY(left,i,leftX);
+ if(rightX > R->xmax) {R->xmax = rightX;}
+ if(leftX < R->xmin) {R->xmin = leftX;}
+ }
+ if( !WeAreAtBottom(left,i) && (leftXbelow>=rightX))
+ {
+/* then we have a break in a near horizontal line in the middle */
+ writeXofY(right,i,leftXbelow);
+ }
+ if( !WeAreAtBottom(right,i) && (leftX >=rightXbelow))
+ {
+/* then we have a break in a near horizontal line in the middle */
+ writeXofY(left,i,rightXbelow);
+ }
+ }
+ left = right->link;
+ }
+/*
+There may be "implied horizontal lines" between edges that have
+implications for continuity. This loop looks for white runs that
+have implied horizontal lines on the top or bottom, and calls
+CollapseWhiteRuns to check and fix any continuity problems from
+them.
+*/
+ for (edge = R->anchor; VALIDEDGE(edge); edge = edge->link) {
+ if ((!ISTOP(edge->flag) && !ISBOTTOM(edge->flag)) || ISLEFT(edge->flag))
+ continue; /* at some future date we may want left edge logic here too */
+ for (e2 = edge->link; VALIDEDGE(e2) && SAMESWATH(edge,e2); e2 = e2->link) {
+ if (ISTOP(e2->flag) && ISTOP(edge->flag)
+ && NONE != ImpliedHorizontalLine(edge,e2,edge->ymin)) {
+ if (ISLEFT(e2->flag))
+ CollapseWhiteRun(R->anchor, edge->ymin-1,
+ edge, e2, edge->ymin);
+ }
+ if (ISBOTTOM(e2->flag) && ISBOTTOM(edge->flag)
+ && NONE != ImpliedHorizontalLine(edge,e2, edge->ymax)) {
+ if (ISLEFT(e2->flag))
+ CollapseWhiteRun(R->anchor, edge->ymax,
+ edge, e2, edge->ymax-1);
+ }
+ }
+ }
+}
+
+
+
+
diff --git a/nx-X11/lib/font/Type1/hints.h b/nx-X11/lib/font/Type1/hints.h
new file mode 100644
index 000000000..8e2ae2ade
--- /dev/null
+++ b/nx-X11/lib/font/Type1/hints.h
@@ -0,0 +1,48 @@
+/* $Xorg: hints.h,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/hints.h,v 1.3 1999/08/22 08:58:51 dawes Exp $ */
+
+/*SHARED*/
+
+#define InitHints t1_InitHints
+extern void t1_InitHints ( void ); /* Initialize hint data structure */
+
+#define CloseHints(hintP) t1_CloseHints(hintP)
+/* Reverse hints that are still open */
+extern void t1_CloseHints ( struct fractpoint *hintP );
+
+#define ProcessHint(hP, currX, currY, hintP) t1_ProcessHint(hP, currX, currY, hintP)
+/* Process a rasterization hint */
+extern void t1_ProcessHint ( struct hintsegment *hP, fractpel currX, fractpel currY, struct fractpoint *hintP );
+
+#define ApplyContinuity(R) t1_ApplyContinuity(R)
+/* fix false connection breaks in a region */
+extern void t1_ApplyContinuity ( struct region *R );
+
+/*END SHARED*/
diff --git a/nx-X11/lib/font/Type1/lines.c b/nx-X11/lib/font/Type1/lines.c
new file mode 100644
index 000000000..835afc6ed
--- /dev/null
+++ b/nx-X11/lib/font/Type1/lines.c
@@ -0,0 +1,189 @@
+/* $Xorg: lines.c,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/lines.c,v 1.4tsi Exp $ */
+
+ /* LINES CWEB V0003 ******** */
+/*
+:h1.LINES Module - Rasterizing Lines
+
+&author. Duaine W. Pryor, Jr. and Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com)
+
+
+:h3.Include Files
+
+The included files are:
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h"
+#include "lines.h"
+
+/*
+:h3.Functions Provided to the TYPE1IMAGER User
+
+None.
+*/
+
+/*
+:h3.Functions Provided to Other Modules
+
+This module provides the following entry point to other modules:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h3.Macros Provided to Other Modules
+
+None.
+*/
+
+/*
+:h2.StepLine() - Produces Run Ends for a Line After Checks
+
+The main work is done by Bresenham(); here we just perform checks and
+get the line so that its Y direction is always increasing:
+*/
+
+void StepLine(R, x1, y1, x2, y2)
+ register struct region *R; /* region being built */
+ register fractpel x1,y1; /* starting point */
+ register fractpel x2,y2; /* ending point */
+{
+ register fractpel dy;
+
+ dy = y2 - y1;
+
+/*
+We execute the "GOING_TO" macro to call back the REGIONS module, if
+necessary (like if the Y direction of the edge has changed):
+*/
+ GOING_TO(R, x1, y1, x2, y2, dy);
+
+ if (dy == 0)
+ return;
+
+ if (dy < 0)
+ Bresenham(R->edge, x2, y2, x1, y1);
+ else
+ Bresenham(R->edge, x1, y1, x2, y2);
+ return;
+}
+/*
+:h3.Bresenham() - Actually Produces Run Ends
+
+This routine runs a Bresenham line-stepping
+algorithm. See, for example, Newman and Sproul, :hp1/Principles
+of Interactive Computer Graphics/, pp. 25-27.
+When we enter this, we
+are guaranteed that dy is positive.
+We'd like to work in 8 bit precision, so we'll define some macros and
+constants to let us do that:
+*/
+
+#define PREC 8 /* we'll keep fraction pels in 8 bit precision */
+/*
+RoundFP() rounds down by 'b' bits:
+*/
+#define RoundFP(xy,b) (((xy)+(1<<((b)-1)))>>(b))
+
+/*
+TruncFP() truncates down by 'b' bits:
+*/
+#define TruncFP(xy,b) ((xy)>>(b))
+
+
+void Bresenham(edgeP,x1,y1,x2,y2)
+ register pel *edgeP; /* pointer to top of list (y == 0) */
+ register fractpel x1,y1; /* starting point on line */
+ register fractpel x2,y2; /* ending point on the line (down) */
+{
+ register long dx,dy; /* change in x and y, in my own precision */
+ register long x,y; /* integer pel starting point */
+ register int count; /* integer pel delta y */
+ register long d; /* the Bresenham algorithm error term */
+
+ x1 = TruncFP(x1, FRACTBITS-PREC);
+ y1 = TruncFP(y1, FRACTBITS-PREC);
+ x2 = TruncFP(x2, FRACTBITS-PREC);
+ y2 = TruncFP(y2, FRACTBITS-PREC);
+
+ dx = x2 - x1;
+ dy = y2 - y1;
+/*
+Find the starting x and y integer pel coordinates:
+*/
+
+ x = RoundFP(x1,PREC);
+ y = RoundFP(y1,PREC);
+ edgeP += y;
+ count = RoundFP(y2,PREC) - y;
+/*------------------------------------------------------------------*/
+/* Force dx to be positive so that dfy will be negative */
+/* this means that vertical moves will decrease d */
+/*------------------------------------------------------------------*/
+ if (dx<0)
+ {
+ dx = -dx;
+#define P PREC
+ d=(dy*(x1-(x<<P)+(1<<(P-1)))-dx*((y<<P)-y1+(1<<(P-1))))>>P;
+#undef P
+ while(--count >= 0 )
+ {
+ while(d<0)
+ {
+ --x;
+ d += dy;
+ }
+ *(edgeP++) = x;
+ d -= dx;
+ }
+ }
+ else /* positive dx */
+ {
+#define P PREC
+ d = (dy*((x<<P)-x1+(1<<(P-1)))-dx*((y<<P)-y1+(1<<(P-1))))>>P;
+#undef P
+ while(--count >= 0 )
+ {
+ while(d<0)
+ {
+ ++x;
+ d += dy;
+ }
+ *(edgeP++) = x;
+ d -= dx;
+ }
+ }
+}
diff --git a/nx-X11/lib/font/Type1/lines.h b/nx-X11/lib/font/Type1/lines.h
new file mode 100644
index 000000000..f8ffd3a43
--- /dev/null
+++ b/nx-X11/lib/font/Type1/lines.h
@@ -0,0 +1,39 @@
+/* $Xorg: lines.h,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/lines.h,v 1.3 1999/08/22 08:58:52 dawes Exp $ */
+
+/*SHARED*/
+
+#define StepLine(R,x1,y1,x2,y2) t1_StepLine(R,x1,y1,x2,y2)
+#define Bresenham(e,x1,y1,x2,y2) t1_Bresenham(e,x1,y1,x2,y2)
+
+extern void t1_StepLine ( struct region *R, fractpel x1, fractpel y1, fractpel x2, fractpel y2 );
+extern void t1_Bresenham ( pel *edgeP, fractpel x1, fractpel y1, fractpel x2, fractpel y2 );
+
+/*END SHARED*/
diff --git a/nx-X11/lib/font/Type1/minimain.c b/nx-X11/lib/font/Type1/minimain.c
new file mode 100644
index 000000000..4aa826dc1
--- /dev/null
+++ b/nx-X11/lib/font/Type1/minimain.c
@@ -0,0 +1,48 @@
+/* $Xorg: minimain.c,v 1.4 2001/02/09 02:04:01 xorgcvs Exp $ */
+
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "ximager5.h"
+
+main()
+{
+ XYspace S;
+ path p;
+
+ InitImager();
+ S = Scale(IDENTITY, 300.0, -300.0);
+ p = Join(Line(Loc(S, 0.0, 1.0)), Line(Loc(S, 1.0, 0.0)));
+ Interior(ClosePath(p), EVENODDRULE);
+}
+
+void Trace()
+{
+}
+
+void *DEFAULTDEVICE;
diff --git a/nx-X11/lib/font/Type1/module/Imakefile b/nx-X11/lib/font/Type1/module/Imakefile
new file mode 100644
index 000000000..db8ab54f7
--- /dev/null
+++ b/nx-X11/lib/font/Type1/module/Imakefile
@@ -0,0 +1,99 @@
+XCOMM $XFree86: xc/lib/font/Type1/module/Imakefile,v 1.6 1999/08/14 10:49:18 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+INCLUDES = -I$(FONTINCSRC) -I../ -I../../include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/include
+
+#if BuildCID
+CIDSRCS = cidchar.c afm.c
+CIDOBJS = cidchar.o afm.o
+#if HasUsableFileMmap
+MMAPDEFINES = -DUSE_MMAP
+#endif
+CIDDEFINES = -DBUILDCID -DHAVE_CFM $(MMAPDEFINES)
+#endif
+
+DEFINES = -DFONTMODULE $(CIDDEFINES)
+
+SRCS = \
+ arith.c \
+ curves.c \
+ fontfcn.c \
+ hints.c \
+ lines.c \
+ objects.c \
+ paths.c \
+ regions.c \
+ scanfont.c \
+ spaces.c \
+ t1funcs.c \
+ t1info.c \
+ t1io.c \
+ t1malloc.c \
+ t1snap.c \
+ t1stub.c \
+ token.c \
+ type1.c \
+ util.c \
+ t1unicode.c \
+ $(CIDSRCS) \
+ type1mod.c
+
+OBJS = \
+ arith.o \
+ curves.o \
+ fontfcn.o \
+ hints.o \
+ lines.o \
+ objects.o \
+ paths.o \
+ regions.o \
+ scanfont.o \
+ spaces.o \
+ t1funcs.o \
+ t1info.o \
+ t1io.o \
+ t1malloc.o \
+ t1snap.o \
+ t1stub.o \
+ token.o \
+ type1.o \
+ util.o \
+ t1unicode.o \
+ $(CIDOBJS) \
+ type1mod.o
+
+LinkSourceFile(arith.c,..)
+LinkSourceFile(curves.c,..)
+LinkSourceFile(fontfcn.c,..)
+LinkSourceFile(hints.c,..)
+LinkSourceFile(lines.c,..)
+LinkSourceFile(objects.c,..)
+LinkSourceFile(paths.c,..)
+LinkSourceFile(regions.c,..)
+LinkSourceFile(scanfont.c,..)
+LinkSourceFile(spaces.c,..)
+LinkSourceFile(t1funcs.c,..)
+LinkSourceFile(t1info.c,..)
+LinkSourceFile(t1io.c,..)
+LinkSourceFile(t1malloc.c,..)
+LinkSourceFile(t1snap.c,..)
+LinkSourceFile(t1stub.c,..)
+LinkSourceFile(t1unicode.c,..)
+LinkSourceFile(token.c,..)
+LinkSourceFile(type1.c,..)
+LinkSourceFile(util.c,..)
+#if BuildCID
+LinkSourceFile(afm.c,..)
+LinkSourceFile(cidchar.c,..)
+#endif
+
+ModuleObjectRule()
+LibraryModuleTarget(type1,$(OBJS))
+InstallLibraryModule(type1,$(MODULEDIR),fonts)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(type1,$(DRIVERSDKMODULEDIR),fonts)
diff --git a/nx-X11/lib/font/Type1/module/type1mod.c b/nx-X11/lib/font/Type1/module/type1mod.c
new file mode 100644
index 000000000..e652591a2
--- /dev/null
+++ b/nx-X11/lib/font/Type1/module/type1mod.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+/* $XFree86: xc/lib/font/Type1/module/type1mod.c,v 1.10 2002/12/09 17:29:59 dawes Exp $ */
+
+#include "misc.h"
+
+#include <X11/fonts/fontmod.h>
+#include "xf86Module.h"
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+static MODULESETUPPROTO(type1Setup);
+
+ /*
+ * This is the module data function that is accessed when loading
+ * libtype1 as a module.
+ */
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "type1",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 2,
+ ABI_CLASS_FONT, /* Font module */
+ ABI_FONT_VERSION,
+ MOD_CLASS_FONT,
+ {0,0,0,0} /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData type1ModuleData = { &VersRec, type1Setup, NULL };
+
+extern void Type1RegisterFontFileFunctions(void);
+#ifdef BUILDCID
+extern void CIDRegisterFontFileFunctions(void);
+#endif
+
+FontModule type1Module = {
+ Type1RegisterFontFileFunctions,
+ "Type1",
+ NULL
+};
+
+#ifdef BUILDCID
+FontModule CIDModule = {
+ CIDRegisterFontFileFunctions,
+ "CID",
+ NULL
+};
+#endif
+
+static pointer
+type1Setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ type1Module.module = module;
+ LoadFont(&type1Module);
+#ifdef BUILDCID
+ CIDModule.module = module;
+ LoadFont(&CIDModule);
+#endif
+
+ /* Need a non-NULL return */
+ return (pointer)1;
+}
diff --git a/nx-X11/lib/font/Type1/objects.c b/nx-X11/lib/font/Type1/objects.c
new file mode 100644
index 000000000..c86587dba
--- /dev/null
+++ b/nx-X11/lib/font/Type1/objects.c
@@ -0,0 +1,1101 @@
+/* $Xorg: objects.c,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/objects.c,v 1.10tsi Exp $ */
+ /* OBJECTS CWEB V0025 ******** */
+/*
+:h1.OBJECTS Module - TYPE1IMAGER Objects Common Routines
+
+This module defines and implements the C structures that represent
+objects in the TYPE1IMAGER. All common routines for manipulating these
+objects are defined in this module. Specific routines for
+specific objects are defined in the modules that deal with that
+object type.
+
+
+&author. Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com)
+
+
+:h3.Include Files
+
+The included files are:
+*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#define GLOBALS 1 /* see :hdref refid=debugvar. */
+/*
+The following two includes are C standards; we include them because we
+use 'toupper' and the 'str'-type functions in this module. Potentially
+these may be defined as macros; if these ".h" files do not exist on your
+system it is a pretty safe bet that these are external entry points and
+you do do not need to include these header files.
+*/
+
+#ifndef FONTMODULE
+#include <string.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <stdio.h>
+#else
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "os.h"
+#include "xf86_ansic.h"
+#endif
+
+/*
+override incorrect system functions; for example you might define
+a macro for "strcpy" that diverts it to "my_strcpy".
+*/
+
+ /* moved these includes from above the */
+ /* was included first (it contains com- */
+ /* piler defines). dsr 081291 */
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h"
+#include "fonts.h"
+#include "pictures.h"
+#include "strokes.h"
+#include "cluts.h"
+
+
+static char *TypeFmt(int type);
+
+/*
+:h3.The "pointer" Macro - Define a Generic Pointer
+
+Sadly, many compilers will give a warning message when a pointer to
+one structure is assigned to a pointer to another. We've even seen
+some that give severe errors (when the wrong pointer type is used as
+an initializer or returned from a function). TYPE1IMAGER has routines
+like Dup and Allocate that are perfectly willing to duplicate or
+allocate any of a number of different types of structures. How to
+declare them in a truely portable way?
+
+Well, there is no single good answer that I've found. You can always
+beg the question and "cast" everything. I find this distracting and the
+resulting code ugly. On the other hand, we have found at least one
+compiler that will accept "void *" as a generic pointer that can
+assigned to any other pointer type without error or warning (apparently
+this is also the ANSI standard). So, we define "void *" to be a generic
+pointer. (You might have to change this for your compiler; the "ifndef"
+allows the change to be made on the command line if you want.)
+:i1/portability assumptions/
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Functions Provided to the TYPE1IMAGER User
+
+This module provides the following TYPE1IMAGER entry points:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+Note that entry points that are intended for use external to TYPE1IMAGER
+begin with the characters :q/xi/. Macros are used to make the names
+more mnemonic.
+*/
+
+/*
+:h3.Functions Provided to Other Modules
+
+This module provides the following functions for other modules:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+Note that entry points that intended for use within TYPE1IMAGER, but
+which must be global because they are used across module boundaries,
+begin with the characters :q/I_/. Macros are used to make the names
+more mnemonic.
+
+Entry points totally within a module use mnemonic names and are
+declared :hp2/static/. One of the compilers I used had a bug when
+static functions were passed as addresses. Thus, some functions
+which are logically "static" are not so declared.
+
+Note also the trick of declaring routines, like Consume(), with a
+variable number of arguments. To avoid the restrictions on variable
+numbers of arguments in the macro processor, we just replace the
+text 'Consume' with 'I_Consume'.
+*/
+/*
+:h3.Macros Provided to Other Modules
+
+This is the module where we define all the useful constants like
+TRUE, FALSE, and NULL, and simple expressions like MIN(), MAX(), and ABS().
+We might as well get to it right here:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+Notice that upper case is used for constant values and macro
+definitions. I generally follow that convention.
+
+Many more global macros are defined later in this module.
+*/
+/*
+:h2.Basic TYPE1IMAGER Object Structure
+
+All TYPE1IMAGER objects which are available to the user have a common
+header. This header is defined below:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+The following define is an attempt to centralize the definition of the
+common xobject data shared by structures that are derived from the
+generic xobject structure. For example, the structure font, defined in
+fonts.shr :
+&code.
+ struct font {
+ char type;
+ char flag;
+ int references;
+ ... other data types & structs ...
+ }
+&ecode.
+would now be defined as:
+&code.
+ struct font {
+ XOBJ_COMMON
+ ... other data types & structs ...
+ }
+&ecode.
+Thus we have a better-structured inheritance mechanism. 3-26-91 PNM
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Object Type Definitions
+
+These constants define the values which go in the 'type' field of
+an TYPE1IMAGER object structure:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Flag Byte Definitions
+
+Many programmers define flag bits as a mask (for example, 0x04), and
+test, set, and reset them as follows:
+
+&code.
+ if ((flag & PERMANENT) != 0)
+
+ flag |= PERMANENT;
+ flag &= &inv.PERMANENT;
+:exmp.
+
+I favor a style where the 'if' statement can ask a question:
+
+&code.
+ if (ISPERMANENT(flag))
+
+ flag |= ISPERMANENT(ON);
+ flag &= &inv.ISPERMANENT(ON);
+
+:exmp.
+This said, we now define two bit settings of the flag byte of the
+object. "ISPERMANENT" will be set by the user, when he calls
+Permanent(). "ISIMMORTAL" will be used for compiled-in objects
+that we don't want the user to ever destroy.
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+Flag bit definitions that apply to all objects are assigned
+starting with the least significant (0x01) bit. Flag bit definitions
+specific to a certain object type are assigned starting with the
+most significant (0x80) bit. We hope they never meet.
+*/
+/*
+:h3 id=preserve.PRESERVE() Macro
+
+Occasionally an TYPE1IMAGER operator is implemented by calling other
+TYPE1IMAGER operators. For example, Arc2() calls Conic(). When we
+call more than one operator as a subroutine, we have to be careful
+of temporary objects. A temporary object will be consumed by the
+subroutine operator and then is no longer available for the caller.
+This can be prevented simply by bumping a temporary object's reference
+count.
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h3.RefRoll() Macro to Detect References Count Rollover
+
+The following macro is designed to check for reference count rollover.
+A return value of TRUE means rollover has not occurred; a return value
+of FALSE means we cannot increment the reference count. Note also that
+those functions that use this macro must decrement the reference count
+afterwards. 3-26-91 PNM
+*/
+
+#define RefRoll(obj) (++(obj)->references > 0)
+
+/*
+:h2.TYPE1IMAGER Object Functions
+
+:h3.LONGCOPY() - Macro to Copy "long" Aligned Data
+
+Copying arbitrary bytes in C is a bit of a problem. "strcpy" can't be
+used, because 0 bytes are special-cased. Most environments have a
+routine "memcopy" or "bcopy" or "bytecopy" that copies memory containing
+zero bytes. Sadly, there is no standard on the name of such a routine,
+which makes it impossible to write truely portable code to use it.
+
+It turns out that TYPE1IMAGER, when it wants to copy data, frequently
+knows that both the source and destination are aligned on "long"
+boundaries. This allows us to copy by using "long *" pointers. This
+is usually very efficient on almost all processors. Frequently, it
+is more efficient than using general-purpose assembly language routines.
+So, we define a macro to do this in a portable way. "dest" and "source"
+must be long-aligned, and "bytes" must be a multiple of "sizeof(long)":
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Allocate() - Allocating a Memory Block
+
+Allocate returns a pointer to memory object that is a copy of
+the template passed (if any). In addition, extra bytes may be
+allocated contiguously with the object. (This may be useful for
+variable size objects such as edge lists. See :hdref refid=regions..)
+
+Allocate() always returns a non-immortal object, even if the template is
+immortal. Therefore a non-NULL template must have a "flag" byte.
+
+If the template is NULL, then 'size' bytes are cleared to all NULLs.
+
+If the template is non-NULL, a new object is allocated in memory.
+It therefore seems logical that its reference count field should be
+set to 1. So, a nun-NULL template must also have a "references" field.
+PNM 3-26-91
+*/
+
+struct xobject *
+t1_Allocate(int size, /* number of bytes to allocate & initialize */
+ pointer ptr, /* example structure to allocate */
+ int extra) /* any extra uninitialized bytes needed contiguously */
+{
+ register struct xobject *template = (struct xobject *)ptr;
+ register struct xobject *r;
+
+ /*
+ * round up 'size' and 'extra' to be an integer number of 'long's:
+ */
+ size = (size + sizeof(long) - 1) & -(int)sizeof(long);
+ extra = (extra + sizeof(long) - 1) & -(int)sizeof(long);
+ if (size + extra <= 0)
+ Abort("Non-positive allocate?");
+ r = (struct xobject *) xiMalloc(size + extra);
+
+ while (r == NULL) {
+ if (!GimeSpace()) {
+ Abort("We have REALLY run out of memory");
+ }
+ r = (struct xobject *) xiMalloc(size + extra);
+ }
+
+ /*
+ * copy the template into the new memory:
+ */
+ if (template != NULL) {
+ /* Added references count decrement if template is not permanent.
+ This is for the case where Allocate is called by a Dupxxxx
+ function, which was in turn called by Unique(). (PNM) */
+ if (!ISPERMANENT(template->flag))
+ --template->references;
+ LONGCOPY(r, template, size);
+ r->flag &= ~(ISPERMANENT(ON) | ISIMMORTAL(ON));
+ /* added reference field 3-2-6-91 PNM */
+ r->references = 1;
+ }
+ else {
+ register char **p1;
+
+ for (p1=(char **)r; size > 0; size -= sizeof(char *))
+ *p1++ = NULL;
+ }
+
+ return(r);
+}
+
+/*
+:h3.Free() - Frees an Allocated Object
+
+This routine makes a sanity check to make sure the "type" field of the
+standard object structure has not been cleared. If the object is
+not a standard structure, then the macro "NonObjectFree" is available
+that does not perform this check.
+
+In either case, the object must not be the NULL pointer. This preserves
+portability, as the C system xiFree() will not always accept NULL.
+*/
+
+void
+Free(pointer objPtr)
+{
+ struct xobject *obj = (struct xobject *)objPtr; /* structure to free */
+
+ if (obj->type == INVALIDTYPE)
+ Abort("Free of already freed object?");
+ obj->type = INVALIDTYPE;
+
+ xiFree((long *)obj);
+}
+
+/*
+:h3.Permanent() - Makes an Object Permanent
+
+Real simple--just set a flag. Every routine that consumes its objects
+(which is almost every user entry) must check this flag, and not consume
+the object if it is set.
+
+If a temporary object is made permanent, and there is more than one
+reference to it, we must first Copy() it, then set the ISPERMANENT
+flag. Note also that the reference count must be incremented when an
+object is changed from temporary to permanent (see the ISUNIQUE macro).
+
+Note that the purpose of this function is to convert an object into a
+permanent object:
+ If it was permanent to begin with, we do nothing;
+ If it was temporary and unique, we set the PERMANENT flag and increment
+the reference count;
+ If it was temporary and nonunique, we must make a unique Copy(), set
+the PERMANENT flag, and set the reference count to 2. We must also
+decrement the original object's reference count, because what we have
+done is to change one of the old temporary handles to a permanent one.
+3-26-91 PNM
+*/
+
+struct xobject *
+t1_Permanent(pointer objPtr)
+{
+ struct xobject *obj = (struct xobject *)objPtr; /* object to be made permanent */
+
+ if ( (obj != NULL) && ( !(ISPERMANENT(obj->flag)) ) )
+ {
+ /* there is a non-NULL, temporary object to be made permanent.
+ If there are multiple references to this object, first get
+ a new COPY().
+ Note also that we have to decrement the reference count if
+ we do a Copy() here, because we are consuming the temporary
+ argument passed, and returning a unique, permanent one.
+ */
+ if ( obj->references > 1)
+ {
+ obj = Copy(obj);
+ }
+ /* now set the permanent flag, and increment the reference
+ count, since a temporary object has now become permanent. */
+ obj->references++;
+ obj->flag |= ISPERMANENT(ON);
+ }
+ return(obj);
+}
+
+#ifdef notused
+/*
+:h3.Temporary() - Undoes the Effect of "Permanent()"
+
+This simply resets the "ISPERMANENT" flag.
+
+If a permanent object is made temporary, and there is more than one reference
+to it, we must first Copy() it, then reset the ISPERMANENT flag. However,
+if the permanent object has obly one reference, we need only decrement the
+reference count ( and reset the flag).
+
+Note that this function, in the case of a PERMANENT argument, basically
+converts the PERMANENT handle to a TEMPORARY one. Thus, in the case of
+a nonunique, permanent argument passed, we not only make a Copy(),
+we also decrement the reference count, to reflect the fact that we have
+lost a permanent handle and gained a temporary one.
+PNM 3-2-6-91
+*/
+
+struct xobject *
+xiTemporary(pointer objPtr)
+{
+ register struct xobject *obj
+ = (struct xobject *)objPtr; /* object to be made permanent */
+ if (obj != NULL) {
+ /* if it's already temporary, there's nothing to do. */
+ if ISPERMANENT(obj->flag)
+ {
+ /* if there are multiple references to this object, get a
+ Copy we can safely alter. Recall that the reference count
+ is incremented for permanent objects.
+ Recall further that Copy returns an object with the
+ same flag state and a reference count of 2 (for PERMANENT
+ objects).
+ Thus, regardless of whether or not we need to copy a
+ permanent object, we still decrement its reference
+ count and reset the flag.
+ */
+ if (obj->references != 2 || ISIMMORTAL(obj->flag))
+ {
+ /* not unique; consume handle, get a temporary Copy! */
+ obj = Copy(obj);
+ }
+ /* else decrement the reference count (since it's going from
+ permanent to temporary) and clear the flag. */
+ else {
+ obj->references--;
+ obj->flag &= ~ISPERMANENT(ON);
+ }
+ }
+ }
+ return(obj);
+}
+#endif /* notused */
+
+/*
+:h3.Dup() - Duplicate an Object
+
+Dup will increment the reference count of an object, only making a
+Copy() if needed.
+Note that Dup() retains the state of the permanent flag.
+3-26-91 PNM
+*/
+
+
+struct xobject *
+t1_Dup(pointer objPtr)
+{
+ register struct xobject *obj
+ = (struct xobject *)objPtr; /* object to be duplicated */
+ register char oldflag; /* copy of original object's flag byte */
+
+ if (obj == NULL)
+ return(NULL);
+ /* An immortal object must be Copy'ed, so that we get a mortal
+ copy of it, since we try not to destroy immortal objects. */
+ if (ISIMMORTAL(obj->flag))
+ return(Copy(obj));
+
+ /* if incrementing the reference count doesn't cause the count
+ to wrap, simply return the object with the count bumped. Note
+ that the RefRoll macro increments the count to perform the
+ rollover check, so we must decrement the count. */
+ if (RefRoll(obj))
+ return(obj);
+
+ /* that didn't work out, so put the count back and call Copy(). */
+ --obj->references;
+ oldflag = obj->flag;
+ obj = Copy(obj);
+ if (ISPERMANENT(oldflag))
+ obj = Permanent(obj);
+ return(obj);
+}
+
+/*
+:h3.Copy() - Make a New Copy of an Object
+
+This is the generic Copy() where the object type is unknown. There
+are specific Copyxxx functions for known object types.
+
+Copy will create a NEW temporary object, and WILL NOT simply bump the
+reference count.
+
+Sometimes duplicating an object is just as simple as Allocating with it
+as a template. But other objects are complicated linked lists. So, we
+let each module provide us a routine (or macro) that duplicates the
+objects it knows about.
+*/
+
+struct xobject *
+t1_Copy(pointer objPtr)
+{
+ register struct xobject *obj
+ = (struct xobject *)objPtr; /* object to be Copy'ed */
+ if (obj == NULL)
+ return(NULL);
+
+ if (ISPATHTYPE(obj->type))
+ obj = (struct xobject *) CopyPath((struct segment *)obj);
+ else
+ switch (obj->type) {
+ case SPACETYPE:
+ obj = (struct xobject *)
+ CopySpace((struct XYspace *)obj);
+ break;
+ case FONTTYPE:
+ obj = (struct xobject *) CopyFont(obj); break;
+ case REGIONTYPE:
+ obj = (struct xobject *)
+ CopyRegion((struct region *)obj);
+ break;
+ case PICTURETYPE:
+ obj = (struct xobject *) CopyPicture(obj); break;
+ case LINESTYLETYPE:
+ obj = (struct xobject *) CopyLineStyle(obj); break;
+ case STROKEPATHTYPE:
+ obj = (struct xobject *) CopyStrokePath(obj); break;
+ case CLUTTYPE:
+ obj = (struct xobject *) CopyCLUT(obj); break;
+ default:
+ return(ArgErr("Copy: invalid object", obj, NULL));
+ }
+
+ return(obj);
+}
+
+/*
+:h3.Destroy() - Destroys an Object
+
+This can get complicated. Just like with Copy(), we let the experts
+handle it.
+*/
+struct xobject *
+Destroy(pointer objPtr)
+{
+ register struct xobject *obj
+ = (struct xobject *)objPtr; /* object to be destroyed */
+ if (obj == NULL)
+ return(NULL);
+ if (ISIMMORTAL(obj->flag)) {
+ return(NULL);
+ }
+ if (ISPATHTYPE(obj->type))
+ KillPath((struct segment *)obj);
+ else {
+ switch (obj->type) {
+ case REGIONTYPE:
+ KillRegion((struct region *)obj);
+ break;
+ case SPACETYPE:
+ KillSpace(obj);
+ break;
+ case LINESTYLETYPE:
+ KillLineStyle(obj);
+ break;
+ case FONTTYPE:
+ KillFont(obj);
+ break;
+ case PICTURETYPE:
+ KillPicture(obj);
+ break;
+ case STROKEPATHTYPE:
+ KillStrokePath(obj);
+ break;
+ case CLUTTYPE:
+ KillCLUT(obj);
+ break;
+ default:
+ return(ArgErr("Destroy: invalid object", obj, NULL));
+ }
+ }
+ return(NULL);
+}
+/*
+:h2.Generally Useful Macros
+
+:h3.FOLLOWING() - Macro to Point to the Data Following a Structure
+
+There are several places in TYPE1IMAGER where we will allocate variable
+data that belongs to a structure immediately after that structure.
+This is a performance technique, because it reduces the number of
+trips we have to take through xiMalloc() and xiFree(). It turns out C has
+a very convenient way to point past a structure--if 'p' is a pointer
+to a structure, 'p+1' is a pointer to the data after it. This
+behavior of C is somewhat startling and somewhat hard to follow, if
+you are not used to it, so we define a macro to point to the data
+following a structure:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.TYPECHECK() - Verify the Type of an Argument
+
+This macro tests the type of an argument. If the test fails, it consumes
+any other arguments as necessary and causes the imbedding routine to
+return the value 'whenBAD'.
+
+Note that the consumeables list should be an argument list itself, for
+example (0) or (2,A,B). See :hdref refid=consume. below.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.ARGCHECK() - Perform an Arbitrary Check on an Argument
+
+This macro is a generalization of TYPECHECK to take an arbitrary
+predicate. If the error occurs (i.e., the predicate is true), the
+arbitrary message 'msg' is returned.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.TYPENULLCHECK() - Extension of TYPECHECK() for NULL arguments
+
+Many routines allow NULLs to be passed as arguments. 'whenBAD' will
+be returned in this case, too.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.MAKECONSUME() - Create a "Consume"-type Macro
+
+Consuming an object means destroying it if it is not permanent. This
+logic is so common to all the routines, that it is immortalized in this
+macro. For example, ConsumePath(p) can be simply defined as
+MAKECONSUME(p,KillPath(p)). In effect, this macro operates on a
+meta-level.
+:i1/consuming objects/
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h3.MAKEUNIQUE() - Create a "Unique"-type Macro
+
+Many routines are written to modify their arguments in place. Thus,
+they want to insure that they duplicate an object if it is permanent.
+This is called making an object "unique". For example, UniquePath(p)
+can be simply defined as MAKEUNIQUE(p,DupPath(p)).
+:i1/unique objects/
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+An object is unique (and directly alterable) if there is only one
+reference to it, and it is not permanent (in which case we increment
+the reference count, so we don't have to check the permanent bit).
+3-26-91 PNM
+
+Note the rules for making a unique object:
+&drawing.
+ IF (obj->references = 1) return(obj);
+ ELSE (references > 1)
+ IF (ISPERMANENT(obj->flag)) return(Dupxxx(obj));
+ ELSE (nonunique, temporary object!)
+ obj->references--; return(Dupxxx(obj));
+&edrawing.
+If we must make a Copy of a nonunique, temporary object, we decrement
+reference count of the original object!
+*/
+
+/*
+:h3.Unique() - Make a Unique Object
+
+Here is a generic 'Unique' function if the object type is not known.
+Why didn't we build it with the MAKEUNIQUE macro, you ask? Well, we
+used to, but there is at least one damn compiler in the world that
+raises errors if the types of an "(a) ? b : c" expression do not match.
+Also, when we changed Dup() to retain the permanent/temporary flag, we
+wanted to make sure "Unique" always returned a temporary object.
+
+Note that we cannot use Dup() to create a copy of the object in question,
+because Dup() may simply bump the reference count, and not return a
+unique copy to us. That is why we use t1_Copy().
+
+The purpose of this function is to make sure we have a copy of an object
+that we can safely alter:
+:ol.
+:li.If we have a unique, temporary object, we simply return the argument.
+:li.If we have a nonunique, temporary object, we have to make a new copy
+of it, and decrement the reference count of the original object, to reflect
+the fact that we traded temporary handles.
+:li.If we have a permanent object, we make a temporary copy of it, but
+we do not decrement the reference count of the original permanent object,
+because permanent objects, by definition, are persistent. 3-2-6-91 PNM
+:eol.
+*/
+
+struct xobject *
+t1_Unique(pointer objPtr)
+{
+ struct xobject *obj = (struct xobject *)objPtr;
+
+ /* if the original object is not already unique, make a unique
+ copy...Note also that if the object was not permanent, we must
+ consume the old handle! 3-26-91 PNM
+ NOTE : consumption of the old handle moved to Allocate. 4-18-91 */
+ if (!obj || obj->references == 1)
+ return(obj);
+
+ obj = Copy(obj);
+ /* and make sure we return a temporary object ! */
+ if (ISPERMANENT(obj->flag))
+ {
+ obj->flag &= ~ISPERMANENT(ON);
+ obj->references--;
+ }
+ return(obj);
+}
+
+
+/*
+:h2.Initialization, Error, and Debug Routines
+
+:h3 id=debugvar.Declarations for Debug Purposes
+
+We declare all the debug flags here. Some link editors make the not
+unreasonable restriction that only one module may declare and
+initialize global variables; all the rest must declare the variable
+'extern'. This is logical, but is somewhat awkward to implement with
+C include files. We solve the problem by temporarily making the name
+'extern' a null name if GLOBALS is defined. (GLOBALS is only defined
+in this OBJECTS module.) Since 'externs' can't be initialized, we
+have to handle that with #defines too.
+:i1/GLOBALS (&#define.)/
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+static char *ErrorMessage = NULL;
+
+/*
+:h3.Pragmatics() - Set/Reset Debug Flags
+
+We provide a controlled way for the TYPE1IMAGER user to set and reset
+our debugging and tracing:
+*/
+void
+Pragmatics(char *username, /* name of the flag */
+ int value) /* value to set it to */
+{
+ register char *p; /* temporary loop variable */
+#define NAMESIZE 40
+ char name[NAMESIZE]; /* buffer to store my copy of 'username' */
+
+ if (strlen(username) >= (unsigned)NAMESIZE)
+ Abort("Pragmatics name too large");
+ strcpy(name, username);
+ for (p = name; *p != '\0'; p++)
+ *p = toupper(*p);
+
+ if (!strcmp(name, "ALL"))
+ MustTraceCalls = InternalTrace = /* MustCrash = */
+ LineIOTrace = value;
+
+ else if (!strcmp(name, "LINEIOTRACE"))
+ LineIOTrace = value;
+
+ else if (!strcmp(name, "TRACECALLS"))
+ MustTraceCalls = value;
+
+ else if (!strcmp(name, "CHECKARGS"))
+ MustCheckArgs = value;
+
+ else if (!strcmp(name, "PROCESSHINTS"))
+ ProcessHints = value;
+
+ else if (!strcmp(name, "SAVEFONTPATHS"))
+ SaveFontPaths = value;
+
+ else if (!strcmp(name, "CRASTERCOMPRESSIONTYPE"))
+ CRASTERCompressionType = value;
+
+ else if (!strcmp(name, "CRASHONUSERERROR"))
+ MustCrash = value;
+
+ else if (!strcmp(name, "DEBUG"))
+ StrokeDebug = SpaceDebug = PathDebug = ConicDebug = LineDebug =
+ RegionDebug = MemoryDebug = FontDebug =
+ HintDebug = ImageDebug = OffPageDebug = value;
+
+ else if (!strcmp(name, "CONICDEBUG"))
+ ConicDebug = value;
+
+ else if (!strcmp(name, "LINEDEBUG"))
+ LineDebug = value;
+
+ else if (!strcmp(name, "REGIONDEBUG"))
+ RegionDebug = value;
+
+ else if (!strcmp(name, "PATHDEBUG"))
+ PathDebug = value;
+
+ else if (!strcmp(name, "SPACEDEBUG"))
+ SpaceDebug = value;
+
+ else if (!strcmp(name, "STROKEDEBUG"))
+ StrokeDebug = value;
+
+ else if (!strcmp(name, "MEMORYDEBUG"))
+ MemoryDebug = value;
+
+ else if (!strcmp(name, "FONTDEBUG"))
+ FontDebug = value;
+
+ else if (!strcmp(name, "HINTDEBUG"))
+ HintDebug = value;
+
+ else if (!strcmp(name, "IMAGEDEBUG"))
+ ImageDebug = value;
+
+ else if (!strcmp(name, "OFFPAGEDEBUG"))
+ OffPageDebug = value;
+
+#ifdef MC68000
+/*
+The following pragmatics flag turns on or off instruction histograming
+for performance analysis. It is only defined in the Delta card
+environment.
+*/
+ else if (!strcmp(name, "PROFILE")) {
+ if (value)
+ StartProfile();
+ else
+ StopProfile();
+ }
+#endif
+ else if (!strcmp(name, "FLUSHCACHE")) {
+#ifdef notdef
+ while (GimeSpace()) { ; }
+#endif
+ }
+
+ else if (!strcmp(name, "CACHEDCHARS"))
+ CachedChars = (value <= 0) ? 1 : value;
+
+ else if (!strcmp(name, "CACHEDFONTS"))
+ CachedFonts = (value <= 0) ? 1 : value;
+
+ else if (!strcmp(name, "CACHEBLIMIT"))
+ CacheBLimit = value;
+
+ else if (!strcmp(name, "CONTINUITY"))
+ Continuity = value;
+
+
+ else {
+ printf("Pragmatics flag = '%s'\n", name);
+ ArgErr("Pragmatics: flag not known", NULL, NULL);
+ }
+ return;
+}
+
+/*
+:h3.Consume() - Consume a List of Arguments
+
+This general purpose routine is provided in the case where the object
+type(s) to be consumed are unknown or not yet verified, and/or it is
+not known whether the object is permanent.
+
+If the type of the argument is known, it is faster to directly consume
+that type, for example, ConsumeRegion() or ConsumePath(). Furthermore,
+if it is already known that the object is temporary, it is faster to
+just kill it rather than consume it, for example, KillSpace().
+*/
+
+void
+Consume(int n, ...)
+{
+ struct xobject *obj;
+ va_list ap;
+
+ va_start(ap, n);
+
+ while (n-- > 0) {
+ obj = va_arg(ap, struct xobject *);
+ if (obj != NULL && !ISPERMANENT(obj->flag))
+ Destroy(obj);
+ }
+}
+
+/*
+:h3.TypeErr() - Handles "Invalid Object Type" Errors
+*/
+
+struct xobject *
+TypeErr(char *name, /* Name of routine (for error message) */
+ pointer objPtr, /* Object in error */
+ int expect, /* type expected */
+ pointer retPtr) /* object to return to caller */
+{
+ struct xobject *obj = (struct xobject *)objPtr;
+ struct xobject *ret = (struct xobject *)retPtr;
+ /*
+ * This buffer must be large enough to hold 'name' plus
+ * two of the largest strings that can be returned by TypeFmt.
+ * The largest value of 'name' is currently 9 ("ClosePath")
+ * and the longest strings in TypeFmt are 30 characters.
+ */
+ static char typemsg[115];
+
+ if (MustCrash)
+ LineIOTrace = TRUE;
+
+ sprintf(typemsg, "Wrong object type in %s. Expected %s; was %s.\n",
+ name, TypeFmt(expect), TypeFmt(obj->type));
+
+ if (MustCrash)
+ Abort("Terminating because of CrashOnUserError...");
+ else
+ ErrorMessage = typemsg;
+
+/* changed ISPERMANENT to ret->references > 1 3-26-91 PNM */
+ if (ret != NULL && (ret->references > 1))
+ ret = Dup(ret);
+ return(ret);
+}
+
+/*
+:h4.TypeFmt() - Returns Pointer to English Name of Object Type
+
+This is a subroutine of TypeErr().
+*/
+
+static char *
+TypeFmt(int type) /* type field */
+{
+ char *r;
+
+ if (ISPATHTYPE(type))
+ if (type == TEXTTYPE)
+ r = "path or region (from TextPath)";
+ else
+ r = "path";
+ else {
+ switch (type) {
+ case INVALIDTYPE:
+ r = "INVALID (previously consumed?)";
+ break;
+ case REGIONTYPE:
+ r = "region";
+ break;
+ case SPACETYPE:
+ r = "XYspace";
+ break;
+ case LINESTYLETYPE:
+ r = "linestyle";
+ break;
+ case FONTTYPE:
+ r = "font";
+ break;
+ case PICTURETYPE:
+ r = "picture";
+ break;
+ case STROKEPATHTYPE:
+ r = "path (from StrokePath)";
+ break;
+ default:
+ r = "UNKNOWN";
+ break;
+ }
+ }
+ return(r);
+}
+/*
+:h3.ArgErr() - Invalid Argument Passed to a Routine
+
+A common routine to report argument errors. It is usually called
+is returned to the caller in case MustCrash is FALSE and ArgErr
+returns to its caller.
+*/
+
+struct xobject *
+ArgErr(char *string, /* description of error */
+ pointer objPtr, /* object, if any, that was in error */
+ pointer retPtr) /* object returned to caller or NULL */
+{
+ struct xobject *ret = (struct xobject *)retPtr;
+
+ if (MustCrash)
+ LineIOTrace = TRUE;
+
+ if (MustCrash)
+ Abort("Terminating because of CrashOnUserError...");
+ else
+ ErrorMessage = string;
+ return(ret);
+}
+
+/*
+:h3.Abort() - Crash Due to Error
+
+Defined in objects.h to be FatalError(), the server's abort routine.
+*/
+
+/*
+:h3.REAL Miscellaneous Stuff
+
+:h4.ErrorMsg() - Return the User an Error Message
+*/
+
+char *
+ErrorMsg(void)
+{
+ register char *r;
+
+ r = ErrorMessage;
+ ErrorMessage = NULL;
+ return(r);
+}
+
+/*
+:h4.InitImager() - Initialize TYPE1IMAGER
+
+We check that a short is 16 bits and a long 32 bits; we have made
+those assumptions elsewhere in the code. (This is almost a C standard,
+anyway.) Note that TYPE1IMAGER makes no assumptions about the size of an
+'int'!
+:i1/portability assumptions/
+*/
+
+void
+InitImager(void)
+{
+
+/* Check to see if we have been using our own malloc. If so,*/
+/* Undef malloc so that we can get to the system call. */
+/* All other calls to malloc are defined to xiMalloc. */
+
+
+/* if (sizeof(short) != 2 || sizeof(INT32) != 4)
+ Abort("Fundamental TYPE1IMAGER assumptions invalid in this port");
+*/
+ InitSpaces();
+ InitFonts();
+ InitFiles();
+/*
+In some environments, constants and/or exception handling need to be
+*/
+ LibInit();
+}
+/*
+:h4.TermImager() - Terminate TYPE1IMAGER
+
+This only makes sense in a server environment; true TYPE1IMAGER needs do
+nothing.
+*/
+void
+TermImager(void)
+{
+ return;
+}
+#ifdef notused
+/*
+:h4.reportusage() - A Stub to Get a Clean Link with Portable PMP
+*/
+void
+reportusage(void)
+{
+ return;
+}
+#endif
diff --git a/nx-X11/lib/font/Type1/objects.h b/nx-X11/lib/font/Type1/objects.h
new file mode 100644
index 000000000..7552f98d9
--- /dev/null
+++ b/nx-X11/lib/font/Type1/objects.h
@@ -0,0 +1,354 @@
+/* $Xorg: objects.h,v 1.3 2000/08/17 19:46:31 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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 (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/objects.h,v 1.14tsi Exp $ */
+/*SHARED*/
+
+/*END SHARED*/
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#include <X11/Xdefs.h>
+#include <X11/Xfuncproto.h>
+#ifndef FONTMODULE
+#include <stdlib.h>
+#endif
+/*SHARED*/
+
+#define Permanent(obj) t1_Permanent(obj)
+#ifdef notused
+#define Temporary(obj) t1_Temporary(obj)
+#endif
+#define Destroy(obj) t1_Destroy(obj)
+#define Dup(obj) t1_Dup(obj)
+#define InitImager t1_InitImager
+#define TermImager t1_TermImager
+#define Pragmatics(f,v) t1_Pragmatics(f,v)
+#define ErrorMsg t1_ErrorMsg
+
+/* make an object permanent */
+extern struct xobject *t1_Permanent ( pointer obj );
+
+#ifdef notused
+/* make an object temporary */
+extern struct xobject *t1_Temporary( pointer obj );
+#endif
+
+/* destroy an object */
+extern struct xobject *t1_Destroy ( pointer obj );
+
+/* duplicate an object */
+extern struct xobject *t1_Dup ( pointer obj );
+
+
+extern void t1_InitImager ( void ); /* initialize TYPE1IMAGER */
+extern void t1_TermImager ( void ); /* terminate TYPE1IMAGER */
+/* set debug flags, etc. */
+extern void t1_Pragmatics ( char *username, int value );
+
+/* return last TYPE1IMAGER error message */
+extern char *t1_ErrorMsg ( void );
+
+/*END SHARED*/
+/*SHARED*/
+extern void xiFree ( long *addr );
+extern char *xiMalloc ( unsigned Size );
+extern void addmemory ( long *addr, long size );
+extern void delmemory ( void );
+
+#ifndef OS_H
+extern void FatalError(const char *f, ...)
+#if defined(__GNUC__) && \
+ ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ > 4)))
+__attribute((noreturn))
+#endif
+;
+
+extern void ErrorF(const char *f, ...);
+#endif
+
+#define Abort(line) FatalError(line)
+#define Allocate(n,t,s) t1_Allocate(n,t,s)
+#define Free(obj) t1_Free(obj)
+#define NonObjectFree(a) xiFree((long *)(a))
+#define Consume t1_Consume
+#define ArgErr(s,o,r) t1_ArgErr(s,o,r)
+#define TypeErr(n,o,e,r) t1_TypeErr(n,o,e,r)
+#define Copy(obj) t1_Copy(obj)
+#define Unique(obj) t1_Unique(obj)
+
+/* allocate memory */
+extern struct xobject *t1_Allocate( int size, pointer template,
+ int extra );
+
+/* free memory */
+extern void t1_Free ( pointer obj );
+
+/* make a unique temporary copy of an object */
+extern struct xobject *t1_Unique ( pointer obj );
+
+/* handle argument errors */
+extern struct xobject *t1_ArgErr ( char *string, pointer obj, pointer ret );
+
+/* handle 'bad type' argument errors */
+extern struct xobject *t1_TypeErr ( char *name, pointer obj,
+ int expect, pointer ret );
+
+/* consume a variable number of arguments */
+extern void t1_Consume ( int n, ... );
+
+/* make a new copy, not reference bump PNM */
+extern struct xobject *t1_Copy ( pointer obj );
+
+
+/*END SHARED*/
+/*SHARED*/
+
+#define ON (~0) /* all bits on */
+#ifndef FALSE
+#define FALSE 0 /* handy zero value */
+#endif
+#ifndef TRUE
+#define TRUE 1 /* handy non-zero value */
+#endif
+
+#ifndef NULL
+#include <stddef.h>
+/*
+The NULL pointer is system specific. (Most systems, however, use 0.)
+TYPE1IMAGER could have its own NULL, independent of the rest of the system,
+were it not for malloc(). The system call malloc() returns NULL when
+out of memory.
+:i1/portibility assumptions/
+*/
+#endif
+
+#ifndef MIN
+#define MIN(a,b) (((a)<(b)) ? a : b)
+#endif
+#ifndef MAX
+#define MAX(a,b) (((a)>(b)) ? a : b)
+#endif
+#ifndef ABS
+#define ABS(a) (((a)>=0)?(a):-(a))
+#endif
+
+/*END SHARED*/
+/*SHARED*/
+
+struct xobject {
+ char type; /* encoded type of object */
+ unsigned char flag; /* flag byte for temporary object characteristics*/
+ short references; /* count of pointers to this object
+ (plus 1 for permanent objects) PNM */
+} ;
+
+/*END SHARED*/
+/*SHARED*/
+
+#define XOBJ_COMMON char type; unsigned char flag; short references;
+
+/*END SHARED*/
+/*SHARED*/
+
+
+#define INVALIDTYPE 0
+#define FONTTYPE 1
+#define REGIONTYPE 3
+#define PICTURETYPE 4
+#define SPACETYPE 5
+#define LINESTYLETYPE 6
+#define EDGETYPE 7
+#define STROKEPATHTYPE 8
+#define CLUTTYPE 9
+
+#define ISPATHTYPE(type) ((type)&0x10) /* all path segments have this bit on */
+#define LINETYPE (0+ISPATHTYPE(ON))
+#define CONICTYPE (1+ISPATHTYPE(ON))
+#define BEZIERTYPE (2+ISPATHTYPE(ON))
+#define HINTTYPE (3+ISPATHTYPE(ON))
+
+#define MOVETYPE (5+ISPATHTYPE(ON))
+#define TEXTTYPE (6+ISPATHTYPE(ON))
+
+/*END SHARED*/
+/*SHARED*/
+
+#define ISPERMANENT(flag) ((flag)&0x01)
+#define ISIMMORTAL(flag) ((flag)&0x02)
+
+/*END SHARED*/
+/*SHARED*/
+
+#define PRESERVE(obj) if (!ISPERMANENT((obj)->flag)) \
+ (obj)->references++;
+
+/*END SHARED*/
+/*SHARED*/
+
+#define LONGCOPY(dest,source,bytes) { \
+ register long *p1 = (long *)dest; register long *p2 = (long *)source; \
+ register int count = (bytes) / sizeof(long); \
+ while (--count >= 0) *p1++ = *p2++; }
+
+
+/*END SHARED*/
+/*SHARED*/
+
+#define FOLLOWING(p) ((p)+1)
+
+/*END SHARED*/
+/*SHARED*/
+
+#define TYPECHECK(name, obj, expect, whenBAD, consumables, rettype) { \
+ if (obj->type != expect) { \
+ (Consume)consumables; \
+ return((rettype)TypeErr(name, obj, expect, whenBAD)); \
+ } \
+}
+
+/*END SHARED*/
+/*SHARED*/
+
+#define ARGCHECK(test,msg,obj,whenBAD,consumables,rettype) { \
+ if (test) { \
+ (Consume)consumables; \
+ return((rettype)ArgErr(msg, obj, whenBAD)); \
+ } \
+}
+
+/*END SHARED*/
+/*SHARED*/
+
+/* Changed use of Dup() below to Temporary(Copy()) because Dup() does not
+ necessarily return a Unique Copy anymore! 3-26-91 */
+#define TYPENULLCHECK(name, obj, expect, whenBAD, consumables,rettype) \
+ if (obj == NULL) { \
+ (Consume)consumables; \
+ if (whenBAD != NULL && ISPERMANENT(whenBAD->flag)) \
+ return((rettype)Temporary(Copy(whenBAD))); \
+ else return((rettype)whenBAD); \
+ } else { \
+ if (obj->type != expect) { \
+ (Consume)consumables; \
+ return((rettype)TypeErr(name, obj, expect, whenBAD)); \
+ } \
+ }
+/*END SHARED*/
+/*SHARED*/
+
+#define MAKECONSUME(obj,stmt) { if (!ISPERMANENT(obj->flag)) stmt; }
+
+/*END SHARED*/
+/*SHARED*/
+
+#define MAKEUNIQUE(obj,stmt) ( ( (obj)->references > 1 ) ? stmt : obj )
+
+/*END SHARED*/
+/*SHARED*/
+
+#ifdef GLOBALS
+
+#define extern
+#define INITIALIZED(value) = value
+
+#else
+
+#define INITIALIZED(value)
+
+#endif
+
+extern char MustCheckArgs INITIALIZED(TRUE);
+extern char MustTraceCalls INITIALIZED(FALSE);
+#if XFONT_CID
+extern char MustCrash INITIALIZED(FALSE);
+#else
+extern char MustCrash INITIALIZED(TRUE);
+#endif
+extern char InternalTrace INITIALIZED(TRUE);
+extern char LineIOTrace INITIALIZED(TRUE);
+
+extern char ProcessHints INITIALIZED(TRUE);
+
+extern char SaveFontPaths INITIALIZED(TRUE);
+
+extern short CRASTERCompressionType INITIALIZED(1);
+
+extern char ConicDebug INITIALIZED(0);
+extern char LineDebug INITIALIZED(0);
+extern char RegionDebug INITIALIZED(0);
+extern char PathDebug INITIALIZED(0);
+extern char FontDebug INITIALIZED(0);
+extern char SpaceDebug INITIALIZED(0);
+extern char StrokeDebug INITIALIZED(0);
+extern char MemoryDebug INITIALIZED(0);
+extern char HintDebug INITIALIZED(0);
+extern char ImageDebug INITIALIZED(0);
+extern char OffPageDebug INITIALIZED(0);
+
+extern short CachedChars INITIALIZED(0x7FFF);
+extern short CachedFonts INITIALIZED(0x7FFF);
+extern int CacheBLimit INITIALIZED(12500);
+extern char Continuity INITIALIZED(2);
+
+#ifdef extern
+#undef extern
+#endif
+
+/*
+We define other routines formatting parameters
+*/
+#define DumpArea(area) t1_DumpArea(area)
+#define DumpText(text) t1_DumpText(text)
+#define DumpPath(path) t1_DumpPath(path)
+#define DumpSpace(space) t1_DumpSpace(space)
+#define DumpEdges(e) t1_DumpEdges(e)
+#define FormatFP(s,p) t1_FormatFP(s,p)
+
+/* dump a textpath structure */
+extern void t1_DumpText(void);
+
+/*END SHARED*/
diff --git a/nx-X11/lib/font/Type1/paths.c b/nx-X11/lib/font/Type1/paths.c
new file mode 100644
index 000000000..1ab25ecef
--- /dev/null
+++ b/nx-X11/lib/font/Type1/paths.c
@@ -0,0 +1,1406 @@
+/* $Xorg: paths.c,v 1.3 2000/08/17 19:46:31 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/paths.c,v 1.7tsi Exp $ */
+
+ /* PATHS CWEB V0021 ******** */
+/*
+:h1 id=paths.PATHS Module - Path Operator Handler
+
+This is the module that is responsible for building and transforming
+path lists.
+
+&author. Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com)
+
+
+:h3.Include Files
+
+The included files are:
+*/
+
+ /* after the system includes (dsr) */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef FONTMODULE
+# include "os.h"
+#endif
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h" /* understands about Union */
+#include "fonts.h" /* understands about TEXTTYPEs */
+#include "pictures.h" /* understands about handles */
+#include "strokes.h" /* understands how to coerce stroke paths */
+#include "trig.h"
+
+
+/*
+:h3.Routines Available to the TYPE1IMAGER User
+
+The PATHS routines that are made available to the outside user are:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Functions Provided to Other Modules
+
+The path routines that are made available to other TYPE1IMAGER modules
+are defined here:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+NOTE: because of the casts put in the macros for Loc, ArcCA, Conic,
+RoundConic, PathSegment, and JoinSegment, we cannot use the macro names
+when the functions are actually defined. We have to use the unique
+names with their unique first two characters. Thus, if anyone in the
+future ever decided to change the first two characters, it would not be
+enough just to change the macro (as it would for most other functions).
+He would have to also change the function definition.
+*/
+/*
+:h3.Macros Provided to Other Modules
+
+The CONCAT macro is defined here and used in the STROKES module. See
+:hdref refid=pathmac..
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h2.Path Segment Structures
+
+A path is represented as a linked list of the following structure:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+When 'link' is NULL, we are at the last segment in the path (surprise!).
+
+'last' is only non-NULL on the first segment of a path,
+for all the other segments 'last' == NULL. We test for a non-NULL
+'last' (ISPATHANCHOR predicate) when we are given an alleged path
+to make sure the user is not trying to pull a fast one on us.
+
+A path may be a collection of disjoint paths. Every break in the
+disjoint path is represented by a MOVETYPE segment.
+
+Closed paths are discussed in :hdref refid=close..
+
+:h3.CopyPath() - Physically Duplicating a Path
+
+This simple function illustrates moving through the path linked list.
+Duplicating a segment just involves making a copy of it, except for
+text, which has some auxilliary things involved. We don't feel
+competent to duplicate text in this module, so we call someone who
+knows how (in the FONTS module).
+*/
+struct segment *
+CopyPath(struct segment *p0) /* path to duplicate */
+{
+ register struct segment *p,*n = NULL,*last = NULL,*anchor;
+
+ for (p = p0, anchor = NULL; p != NULL; p = p->link) {
+
+ ARGCHECK((!ISPATHTYPE(p->type) || (p != p0 && p->last != NULL)),
+ "CopyPath: invalid segment", p, NULL, (0), struct segment *);
+
+ if (p->type == TEXTTYPE)
+ n = (struct segment *) CopyText(p);
+ else
+ n = (struct segment *)Allocate(p->size, p, 0);
+ n->last = NULL;
+ if (anchor == NULL)
+ anchor = n;
+ else
+ last->link = n;
+ last = n;
+ }
+/*
+At this point we have a chain of newly allocated segments hanging off
+'anchor'. We need to make sure the first segment points to the last:
+*/
+ if (anchor != NULL) {
+ n->link = NULL;
+ anchor->last = n;
+ }
+
+ return(anchor);
+}
+/*
+:h3.KillPath() - Destroying a Path
+
+Destroying a path is simply a matter of freeing each segment in the
+linked list. Again, we let the experts handle text.
+*/
+void
+KillPath(struct segment *p) /* path to destroy */
+{
+ register struct segment *linkp; /* temp register holding next segment*/
+
+ /* return conditional based on reference count 3-26-91 PNM */
+ if ( (--(p->references) > 1) ||
+ ( (p->references == 1) && !ISPERMANENT(p->flag) ) )
+ return;
+
+ while (p != NULL) {
+ if (!ISPATHTYPE(p->type)) {
+ ArgErr("KillPath: bad segment", p, NULL);
+ return;
+ }
+ linkp = p->link;
+ if (p->type == TEXTTYPE)
+ KillText(p);
+ else
+ Free(p);
+ p = linkp;
+ }
+}
+
+/*
+:h2 id=location."location" Objects
+
+The TYPE1IMAGER user creates and destroys objects of type "location". These
+objects locate points for the primitive path operators. We play a trick
+here and store these objects in the same "segment" structure used for
+paths, with a type field == MOVETYPE.
+
+This allows the Line() operator, for example, to be very trivial:
+It merely stamps its input structure as a LINETYPE and returns it to the
+caller--assuming, of course, the input structure was not permanent (as
+it usually isn't).
+
+:h3.The "movesegment" Template Structure
+
+This template is used as a generic segment structure for Allocate:
+*/
+
+/* added reference field 1 to temporary template below 3-26-91 PNM */
+static struct segment movetemplate = { MOVETYPE, 0, 1, sizeof(struct segment), 0,
+ NULL, NULL, {0, 0} };
+/*
+:h3.Loc() - Create an "Invisible Line" Between (0,0) and a Point
+
+*/
+
+struct segment *
+t1_Loc(struct XYspace *S, /* coordinate space to interpret X,Y */
+ double x, double y) /* destination point */
+{
+ register struct segment *r;
+
+
+ r = (struct segment *)Allocate(sizeof(struct segment), &movetemplate, 0);
+ TYPECHECK("Loc", S, SPACETYPE, r, (0), struct segment *);
+
+ r->last = r;
+ r->context = S->context;
+ (*S->convert)(&r->dest, S, x, y);
+ ConsumeSpace(S);
+ return(r);
+}
+/*
+:h3.ILoc() - Loc() With Integer Arguments
+
+*/
+struct segment *
+ILoc(struct XYspace *S, /* coordinate space to interpret X,Y */
+ int x, int y) /* destination point */
+{
+ register struct segment *r;
+
+ r = (struct segment *)Allocate(sizeof(struct segment), &movetemplate, 0);
+ TYPECHECK("Loc", S, SPACETYPE, r, (0), struct segment *);
+
+ r->last = r;
+ r->context = S->context;
+ (*S->iconvert)(&r->dest, S, (long) x, (long) y);
+ ConsumeSpace(S);
+ return(r);
+}
+
+/*
+:h3.SubLoc() - Vector Subtraction of Two Locition Objects
+
+This user operator subtracts two location objects, yielding a new
+location object that is the result.
+
+The symmetrical function AddLoc() is totally redundent with Join(),
+so it is not provided.
+*/
+
+struct segment *
+SubLoc(struct segment *p1, struct segment *p2)
+{
+ ARGCHECK(!ISLOCATION(p1), "SubLoc: bad first arg", p1, NULL, (0), struct segment *);
+ ARGCHECK(!ISLOCATION(p2), "SubLoc: bad second arg", p2, NULL, (0), struct segment *);
+ p1 = UniquePath(p1);
+ p1->dest.x -= p2->dest.x;
+ p1->dest.y -= p2->dest.y;
+ ConsumePath(p2);
+ return(p1);
+}
+
+/*
+:h2.Straight Line Segments
+
+:h3.PathSegment() - Create a Generic Path Segment
+
+Many routines need a LINETYPE or MOVETYPE path segment, but do not
+want to go through the external user's interface, because, for example,
+they already know the "fractpel" destination of the segment and the
+conversion is unnecessary. PathSegment() is an internal routine
+provided to the rest of TYPE1IMAGER for handling these cases.
+*/
+
+struct segment *
+t1_PathSegment(int type, /* LINETYPE or MOVETYPE */
+ fractpel x, fractpel y) /* where to go to, if known */
+{
+ register struct segment *r; /* newly created segment */
+
+ r = (struct segment *)Allocate(sizeof(struct segment), &movetemplate, 0);
+ r->type = type;
+ r->last = r; /* last points to itself for singleton */
+ r->dest.x = x;
+ r->dest.y = y;
+ return(r);
+}
+/*
+:h3.Line() - Create a Line Segment Between (0,0) and a Point P
+
+This involves just creating and filling out a segment structure:
+*/
+struct segment *
+Line(struct segment *P) /* relevant coordinate space */
+{
+ ARGCHECK(!ISLOCATION(P), "Line: arg not a location", P, NULL, (0), struct segment *);
+
+ P = UniquePath(P);
+ P->type = LINETYPE;
+ return(P);
+}
+/*
+:h2.Curved Path Segments
+
+We need more points to describe curves. So, the structures for curved
+path segments are slightly different. The first part is identical;
+the curved structures are larger with the extra points on the end.
+
+:h3.Bezier Segment Structure
+
+We support third order Bezier curves. They are specified with four
+control points A, B, C, and D. The curve starts at A with slope AB
+and ends at D with slope CD. The curvature at the point A is inversely
+related to the length |AB|, and the curvature at the point D is
+inversely related to the length |CD|. Point A is always point (0,0).
+
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Bezier() - Generate a Bezier Segment
+
+This is just a simple matter of filling out a 'beziersegment' structure:
+*/
+
+struct beziersegment *
+Bezier(struct segment *B, /* second control point */
+ struct segment *C, /* third control point */
+ struct segment *D) /* fourth control point (ending point) */
+{
+/* added reference field of 1 to temporary template below 3-26-91 PNM */
+ static struct beziersegment template =
+ { BEZIERTYPE, 0, 1, sizeof(struct beziersegment), 0,
+ NULL, NULL, { 0, 0 }, { 0, 0 }, { 0, 0 } };
+
+ register struct beziersegment *r; /* output segment */
+
+ ARGCHECK(!ISLOCATION(B), "Bezier: bad B", B, NULL, (2,C,D), struct beziersegment *);
+ ARGCHECK(!ISLOCATION(C), "Bezier: bad C", C, NULL, (2,B,D), struct beziersegment *);
+ ARGCHECK(!ISLOCATION(D), "Bezier: bad D", D, NULL, (2,B,C), struct beziersegment *);
+
+ r = (struct beziersegment *)Allocate(sizeof(struct beziersegment), &template, 0);
+ r->last = (struct segment *) r;
+ r->dest.x = D->dest.x;
+ r->dest.y = D->dest.y;
+ r->B.x = B->dest.x;
+ r->B.y = B->dest.y;
+ r->C.x = C->dest.x;
+ r->C.y = C->dest.y;
+
+ ConsumePath(B);
+ ConsumePath(C);
+ ConsumePath(D);
+ return(r);
+}
+
+/*
+:h2.Font "Hint" Segments
+
+:h3.Hint() - A Font 'Hint' Segment
+
+This is temporary code while we experiment with hints.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+struct hintsegment *
+Hint(struct XYspace *S, float ref, float width,
+ char orientation, char hinttype, char adjusttype, char direction,
+ int label)
+{
+/* added reference field of 1 to hintsegment template below 3-26-91 PNM */
+ static struct hintsegment template = { HINTTYPE, 0, 1, sizeof(struct hintsegment), 0,
+ NULL, NULL, { 0, 0 }, { 0, 0 }, { 0, 0 },
+ ' ', ' ', ' ', ' ', 0};
+
+ register struct hintsegment *r;
+
+ r = (struct hintsegment *)Allocate(sizeof(struct hintsegment), &template, 0);
+
+ r->orientation = orientation;
+ if (width == 0.0) width = 1.0;
+
+ if (orientation == 'h') {
+ (*S->convert)(&r->ref, S, 0.0, ref);
+ (*S->convert)(&r->width, S, 0.0, width);
+ }
+ else if (orientation == 'v') {
+ (*S->convert)(&r->ref, S, ref, 0.0);
+ (*S->convert)(&r->width, S, width, 0.0);
+ }
+ else
+ return((struct hintsegment *)ArgErr("Hint: orient not 'h' or 'v'", NULL, NULL));
+ if (r->width.x < 0) r->width.x = - r->width.x;
+ if (r->width.y < 0) r->width.y = - r->width.y;
+ r->hinttype = hinttype;
+ r->adjusttype = adjusttype;
+ r->direction = direction;
+ r->label = label;
+ r->last = (struct segment *) r;
+ ConsumeSpace(S);
+ return(r);
+}
+
+/*
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+POP removes the first segment in a path 'p' and Frees it. 'p' is left
+pointing to the end of the path:
+*/
+#define POP(p) \
+ { register struct segment *linkp; \
+ linkp = p->link; \
+ if (linkp != NULL) \
+ linkp->last = p->last; \
+ Free(p); \
+ p = linkp; }
+/*
+INSERT inserts a single segment in the middle of a chain. 'b' is
+the segment before, 'p' the segment to be inserted, and 'a' the
+segment after.
+*/
+#define INSERT(b,p,a) b->link=p; p->link=a; p->last=NULL
+
+/*
+:h3.Join() - Join Two Objects Together
+
+If these are paths, this operator simply invokes the CONCAT macro.
+Why so much code then, you ask? Well we have to check for object
+types other than paths, and also check for certain path consistency
+rules.
+*/
+
+struct segment *
+Join(struct segment *p1, struct segment *p2)
+{
+/*
+We start with a whole bunch of very straightforward argument tests:
+*/
+ if (p2 != NULL) {
+ if (!ISPATHTYPE(p2->type)) {
+
+ if (p1 == NULL)
+ return((struct segment *)Unique(p2));
+
+ switch (p1->type) {
+
+ case REGIONTYPE:
+
+ case STROKEPATHTYPE:
+ p1 = CoercePath(p1);
+ break;
+
+ default:
+ return((struct segment *)BegHandle(p1, p2));
+ }
+ }
+
+ ARGCHECK((p2->last == NULL), "Join: right arg not anchor", p2, NULL, (1,p1), struct segment *);
+ p2 = UniquePath(p2);
+
+/*
+In certain circumstances, we don't have to duplicate a permanent
+location. (We would just end up destroying it anyway). These cases
+are when 'p2' begins with a move-type segment:
+*/
+ if (p2->type == TEXTTYPE || p2->type == MOVETYPE) {
+ if (p1 == NULL)
+ return(p2);
+ if (ISLOCATION(p1)) {
+ p2->dest.x += p1->dest.x;
+ p2->dest.y += p1->dest.y;
+ ConsumePath(p1);
+ return(p2);
+ }
+ }
+ }
+ else
+ return((struct segment *)Unique(p1));
+
+ if (p1 != NULL) {
+ if (!ISPATHTYPE(p1->type))
+
+ switch (p2->type) {
+
+ case REGIONTYPE:
+
+ case STROKEPATHTYPE:
+ p2 = CoercePath(p2);
+ break;
+
+ default:
+ return((struct segment *)EndHandle(p1, p2));
+ }
+
+ ARGCHECK((p1->last == NULL), "Join: left arg not anchor", p1, NULL, (1,p2), struct segment *);
+ p1 = UniquePath(p1);
+ }
+ else
+ return(p2);
+
+/*
+At this point all the checking is done. We have two temporary non-null
+path types in 'p1' and 'p2'. If p1 ends with a MOVE, and p2 begins with
+a MOVE, we collapse the two MOVEs into one. We enforce the rule that
+there may not be two MOVEs in a row:
+*/
+
+ if (p1->last->type == MOVETYPE && p2->type == MOVETYPE) {
+ p1->last->flag |= p2->flag;
+ p1->last->dest.x += p2->dest.x;
+ p1->last->dest.y += p2->dest.y;
+ POP(p2);
+ if (p2 == NULL)
+ return(p1);
+ }
+/*
+Now we check for another silly rule. If a path has any TEXTTYPEs,
+then it must have only TEXTTYPEs and MOVETYPEs, and furthermore,
+it must begin with a TEXTTYPE. This rule makes it easy to check
+for the special case of text. If necessary, we will coerce
+TEXTTYPEs into paths so we don't mix TEXTTYPEs with normal paths.
+*/
+ if (p1->type == TEXTTYPE) {
+ if (p2->type != TEXTTYPE && !ISLOCATION(p2))
+ p1 = CoerceText(p1);
+ }
+ else {
+ if (p2->type == TEXTTYPE) {
+ if (ISLOCATION(p1)) {
+ p2->dest.x += p1->dest.x;
+ p2->dest.y += p1->dest.y;
+ Free(p1);
+ return(p2);
+ }
+ else
+ p2 = CoerceText(p2);
+ }
+ }
+/*
+Thank God! Finally! It's hard to believe, but we are now able to
+actually do the join. This is just invoking the CONCAT macro:
+*/
+ CONCAT(p1, p2);
+
+ return(p1);
+}
+
+/*
+:h3.JoinSegment() - Create a Path Segment and Join It to a Known Path
+
+This internal function is quicker than a full-fledged join because
+it can do much less checking.
+*/
+
+struct segment *
+t1_JoinSegment(struct segment *before, /* path to join before new segment */
+ int type, /* type of new segment (MOVETYPE or LINETYPE) */
+ fractpel x, fractpel y, /* x,y of new segment */
+ struct segment *after) /* path to join after new segment */
+{
+ register struct segment *r; /* returned path built here */
+
+ r = PathSegment(type, x, y);
+ if (before != NULL) {
+ CONCAT(before, r);
+ r = before;
+ }
+ else
+ r->context = after->context;
+ if (after != NULL)
+ CONCAT(r, after);
+ return(r);
+}
+
+/*
+:h2.Other Path Functions
+
+*/
+
+
+struct segment *
+t1_ClosePath(struct segment *p0, /* path to close */
+ int lastonly) /* flag deciding to close all subpaths or... */
+{
+ register struct segment *p,*last = NULL,*start; /* used in looping through path */
+ register fractpel x,y; /* current position in path */
+ register fractpel firstx = 0,firsty = 0; /* start position of sub path */
+ register struct segment *lastnonhint = NULL; /* last non-hint segment in path */
+
+ if (p0 != NULL && p0->type == TEXTTYPE)
+ return(UniquePath(p0));
+ if (p0->type == STROKEPATHTYPE)
+ return((struct segment *)Unique(p0));
+ /*
+ * NOTE: a null closed path is different from a null open path
+ * and is denoted by a closed (0,0) move segment. We make
+ * sure this path begins and ends with a MOVETYPE:
+ */
+ if (p0 == NULL || p0->type != MOVETYPE)
+ p0 = JoinSegment(NULL, MOVETYPE, 0, 0, p0);
+ TYPECHECK("ClosePath", p0, MOVETYPE, NULL, (0), struct segment *);
+ if (p0->last->type != MOVETYPE)
+ p0 = JoinSegment(p0, MOVETYPE, 0, 0, NULL);
+
+ p0 = UniquePath(p0);
+
+/*
+We now begin a loop through the path,
+incrementing current 'x' and 'y'. We are searching
+for MOVETYPE segments (breaks in the path) that are not already closed.
+At each break, we insert a close segment.
+*/
+ for (p = p0, x = y = 0, start = NULL;
+ p != NULL;
+ x += p->dest.x, y += p->dest.y, last = p, p = p->link)
+ {
+
+ if (p->type == MOVETYPE) {
+ if (start != NULL && (lastonly?p->link==NULL:TRUE) &&
+ !(ISCLOSED(start->flag) && LASTCLOSED(last->flag))) {
+ register struct segment *r; /* newly created */
+
+ start->flag |= ISCLOSED(ON);
+ r = PathSegment(LINETYPE, firstx - x,
+ firsty - y);
+ INSERT(last, r, p);
+ r->flag |= LASTCLOSED(ON);
+ /*< adjust 'last' if possible for a 0,0 close >*/
+{
+
+#define CLOSEFUDGE 3 /* if we are this close, let's change last segment */
+
+ if (r->dest.x != 0 || r->dest.y != 0) {
+ if (r->dest.x <= CLOSEFUDGE && r->dest.x >= -CLOSEFUDGE
+ && r->dest.y <= CLOSEFUDGE && r->dest.y >= -CLOSEFUDGE) {
+ lastnonhint->dest.x += r->dest.x;
+ lastnonhint->dest.y += r->dest.y;
+ r->dest.x = r->dest.y = 0;
+ }
+ }
+}
+ if (p->link != NULL) {
+ p->dest.x += x - firstx;
+ p->dest.y += y - firsty;
+ x = firstx;
+ y = firsty;
+ }
+ }
+ start = p;
+ firstx = x + p->dest.x;
+ firsty = y + p->dest.y;
+ }
+ else if (p->type != HINTTYPE)
+ lastnonhint = p;
+ }
+ return(p0);
+}
+/*
+*/
+/*
+:h2.Reversing the Direction of a Path
+
+This turned out to be more difficult than I thought at first. The
+trickiness was due to the fact that closed paths must remain closed,
+etc.
+
+We need three subroutines:
+*/
+
+/* break a path at any point */
+static struct segment *SplitPath ( struct segment *anchor,
+ struct segment *before );
+/* breaks a path after first sub-path */
+static struct segment *DropSubPath ( struct segment *p0 );
+/* reverses a single sub-path */
+static struct segment *ReverseSubPath ( struct segment *p );
+
+/*
+:h3.Reverse() - User Operator to Reverse a Path
+
+This operator reverses the entire path.
+*/
+
+struct segment *
+Reverse(struct segment *p) /* full path to reverse */
+{
+ register struct segment *r; /* output path built here */
+ register struct segment *nextp; /* contains next sub-path */
+
+ if (p == NULL)
+ return(NULL);
+
+ ARGCHECK(!ISPATHANCHOR(p), "Reverse: invalid path", p, NULL, (0), struct segment *);
+
+ if (p->type == TEXTTYPE)
+ p = CoerceText(p);
+ p = UniquePath(p);
+
+ r = NULL;
+
+ do {
+ nextp = DropSubPath(p);
+ p = ReverseSubPath(p);
+ r = Join(p, r);
+ p = nextp;
+
+ } while (p != NULL);
+
+ return(r);
+}
+
+/*
+:h4.ReverseSubPath() - Subroutine to Reverse a Single Sub-Path
+*/
+
+static struct segment *
+ReverseSubPath(struct segment *p) /* input path */
+{
+ register struct segment *r; /* reversed path will be created here */
+ register struct segment *nextp; /* temporary variable used in loop */
+ register int wasclosed; /* flag, path was closed */
+
+ if (p == NULL)
+ return(NULL);
+
+ wasclosed = ISCLOSED(p->flag);
+ r = NULL;
+
+ do {
+/*
+First we reverse the direction of this segment and clean up its flags:
+*/
+ p->dest.x = - p->dest.x; p->dest.y = - p->dest.y;
+ p->flag &= ~(ISCLOSED(ON) | LASTCLOSED(ON));
+
+ switch (p->type) {
+
+ case LINETYPE:
+ case MOVETYPE:
+ break;
+
+ case CONICTYPE:
+ {
+/*
+The logic of this is that the new M point (stored relative to the new
+beginning) is (M - C). However, C ("dest") has already been reversed
+So, we add "dest" instead of subtracting it:
+*/
+ register struct conicsegment *cp = (struct conicsegment *) p;
+
+ cp->M.x += cp->dest.x; cp->M.y += cp->dest.y;
+ }
+ break;
+
+ case BEZIERTYPE:
+ {
+ register struct beziersegment *bp = (struct beziersegment *) p;
+
+ bp->B.x += bp->dest.x; bp->B.y += bp->dest.y;
+ bp->C.x += bp->dest.x; bp->C.y += bp->dest.y;
+ }
+ break;
+
+ case HINTTYPE:
+ {
+ register struct hintsegment *hp = (struct hintsegment *) p;
+
+ hp->ref.x = -hp->ref.x; hp->ref.y = -hp->ref.y;
+ }
+ break;
+
+ default:
+ Abort("Reverse: bad path segment");
+ }
+/*
+We need to reverse the order of segments too, so we break this segment
+off of the input path, and tack it on the front of the growing path
+in 'r':
+*/
+ nextp = p->link;
+ p->link = NULL;
+ p->last = p;
+ if (r != NULL)
+ CONCAT(p,r); /* leaves result in 'p'... not what we want */
+ r = p;
+ p = nextp; /* advance to next segment in input path */
+
+ } while (p != NULL);
+
+ if (wasclosed)
+ r = ClosePath(r);
+
+ return(r);
+}
+
+/*
+:h4.DropSubPath() - Drops the First Sub-Path Off a Path
+
+This subroutine returns the remaining sub-path(s). While doing so, it
+breaks the input path after the first sub-path so that a pointer to
+the original path now contains the first sub-path only.
+*/
+
+static struct segment *
+DropSubPath(struct segment *p0) /* original path */
+{
+ register struct segment *p; /* returned remainder here */
+
+ for (p = p0; p->link != NULL; p = p->link) {
+ if (p->link->type == MOVETYPE)
+ break;
+ }
+
+ return(SplitPath(p0, p));
+}
+
+static struct segment *
+SplitPath(struct segment *anchor, struct segment *before)
+{
+ register struct segment *r;
+
+ if (before == anchor->last)
+ return(NULL);
+
+ r = before->link;
+ r->last = anchor->last;
+ anchor->last = before;
+ before->link = NULL;
+
+ return(r);
+}
+
+static void
+UnClose(struct segment *p0)
+{
+ register struct segment *p;
+
+ for (p=p0; p->link->link != NULL; p=p->link) { ; }
+
+ if (!LASTCLOSED(p->link->flag))
+ Abort("UnClose: no LASTCLOSED");
+
+ Free(SplitPath(p0, p));
+ p0->flag &= ~ISCLOSED(ON);
+}
+
+/*
+:h3.ReverseSubPaths() - Reverse the Direction of Sub-paths Within a Path
+
+This user operator reverses the sub-paths in a path, but leaves the
+'move' segments unchanged. It builds on top of the subroutines
+already established.
+*/
+
+struct segment *
+ReverseSubPaths(struct segment *p) /* input path */
+{
+ register struct segment *r; /* reversed path will be created here */
+ register struct segment *nextp; /* temporary variable used in loop */
+ int wasclosed; /* flag; subpath was closed */
+ register struct segment *nomove; /* the part of sub-path without move segment */
+ struct fractpoint delta;
+
+ if (p == NULL)
+ return(NULL);
+
+ ARGCHECK(!ISPATHANCHOR(p), "ReverseSubPaths: invalid path", p, NULL, (0), struct segment *);
+
+ if (p->type == TEXTTYPE)
+ p = CoerceText(p);
+ if (p->type != MOVETYPE)
+ p = JoinSegment(NULL, MOVETYPE, 0, 0, p);
+
+ p = UniquePath(p);
+
+ r = NULL;
+
+ for (; p != NULL;) {
+ nextp = DropSubPath(p);
+ wasclosed = ISCLOSED(p->flag);
+ if (wasclosed)
+ UnClose(p);
+
+ nomove = SplitPath(p, p);
+ r = Join(r, p);
+
+ PathDelta(nomove, &delta);
+
+ nomove = ReverseSubPath(nomove);
+ p->dest.x += delta.x;
+ p->dest.y += delta.y;
+ if (nextp != NULL) {
+ nextp->dest.x += delta.x;
+ nextp->dest.y += delta.y;
+ }
+ if (wasclosed) {
+ nomove = ClosePath(nomove);
+ nextp->dest.x -= delta.x;
+ nextp->dest.y -= delta.y;
+ }
+ r = Join(r, nomove);
+ p = nextp;
+
+ }
+
+ return(r);
+}
+
+/*
+:h2.Transforming and Putting Handles on Paths
+
+:h3.PathTransform() - Transform a Path
+
+Transforming a path involves transforming all the points. In order
+that closed paths do not become "unclosed" when their relative
+positions are slightly changed due to loss of arithmetic precision,
+all point transformations are in absolute coordinates.
+
+(It might be better to reset the "absolute" coordinates every time a
+move segment is encountered. This would mean that we could accumulate
+error from subpath to subpath, but we would be less likely to make
+the "big error" where our fixed point arithmetic "wraps". However, I
+think I'll keep it this way until something happens to convince me
+otherwise.)
+
+The transform is described as a "space", that way we can use our
+old friend the "iconvert" function, which should be very efficient.
+*/
+
+struct segment *
+PathTransform(struct segment *p0, /* path to transform */
+ struct XYspace *S) /* pseudo space to transform in */
+{
+ register struct segment *p; /* to loop through path with */
+ register fractpel newx,newy; /* current transformed position in path */
+ register fractpel oldx,oldy; /* current untransformed position in path */
+ register fractpel savex,savey; /* save path delta x,y */
+
+ p0 = UniquePath(p0);
+
+ newx = newy = oldx = oldy = 0;
+
+ for (p=p0; p != NULL; p=p->link) {
+
+ savex = p->dest.x; savey = p->dest.y;
+
+ (*S->iconvert)(&p->dest, S, p->dest.x + oldx, p->dest.y + oldy);
+ p->dest.x -= newx;
+ p->dest.y -= newy;
+
+ switch (p->type) {
+
+ case LINETYPE:
+ case MOVETYPE:
+ break;
+
+ case CONICTYPE:
+ {
+ register struct conicsegment *cp = (struct conicsegment *) p;
+
+ (*S->iconvert)(&cp->M, S, cp->M.x + oldx, cp->M.y + oldy);
+ cp->M.x -= newx;
+ cp->M.y -= newy;
+ /*
+ * Note roundness doesn't change... linear transform
+ */
+ break;
+ }
+
+
+ case BEZIERTYPE:
+ {
+ register struct beziersegment *bp = (struct beziersegment *) p;
+
+ (*S->iconvert)(&bp->B, S, bp->B.x + oldx, bp->B.y + oldy);
+ bp->B.x -= newx;
+ bp->B.y -= newy;
+ (*S->iconvert)(&bp->C, S, bp->C.x + oldx, bp->C.y + oldy);
+ bp->C.x -= newx;
+ bp->C.y -= newy;
+ break;
+ }
+
+ case HINTTYPE:
+ {
+ register struct hintsegment *hp = (struct hintsegment *) p;
+
+ (*S->iconvert)(&hp->ref, S, hp->ref.x + oldx, hp->ref.y + oldy);
+ hp->ref.x -= newx;
+ hp->ref.y -= newy;
+ (*S->iconvert)(&hp->width, S, hp->width.x, hp->width.y);
+ /* Note: width is not relative to origin */
+ break;
+ }
+
+ case TEXTTYPE:
+ {
+ XformText(p,S);
+ break;
+ }
+
+ default:
+ Abort("PathTransform: invalid segment");
+ }
+ oldx += savex;
+ oldy += savey;
+ newx += p->dest.x;
+ newy += p->dest.y;
+ }
+ return(p0);
+}
+
+/*
+:h3.PathDelta() - Return a Path's Ending Point
+*/
+
+void
+PathDelta(struct segment *p, /* input path */
+ struct fractpoint *pt) /* pointer to x,y to set */
+{
+ struct fractpoint mypoint; /* I pass this to TextDelta */
+ register fractpel x,y; /* working variables for path current point */
+
+ for (x=y=0; p != NULL; p=p->link) {
+ x += p->dest.x;
+ y += p->dest.y;
+ if (p->type == TEXTTYPE) {
+ TextDelta(p, &mypoint);
+ x += mypoint.x;
+ y += mypoint.y;
+ }
+ }
+
+ pt->x = x;
+ pt->y = y;
+}
+
+/*
+:h3.BoundingBox() - Produce a Bounding Box Path
+
+This function is called by image code, when we know the size of the
+image in pels, and need to get a bounding box path that surrounds it.
+The starting/ending handle is in the lower right hand corner.
+*/
+struct segment *
+BoundingBox(pel h, pel w) /* size of box */
+{
+ register struct segment *path;
+
+ path = PathSegment(LINETYPE, -TOFRACTPEL(w), 0);
+ path = JoinSegment(NULL, LINETYPE, 0, -TOFRACTPEL(h), path);
+ path = JoinSegment(NULL, LINETYPE, TOFRACTPEL(w), 0, path);
+ path = ClosePath(path);
+
+ return(path);
+}
+
+/*
+:h2.Querying Locations and Paths
+
+:h3.QueryLoc() - Return the X,Y of a Locition
+*/
+
+void
+QueryLoc(struct segment *P, /* location to query, not consumed */
+ struct XYspace *S, /* XY space to return coordinates in */
+ double *xP, double *yP) /* coordinates returned here */
+{
+ if (!ISLOCATION(P)) {
+ ArgErr("QueryLoc: first arg not a location", P, NULL);
+ return;
+ }
+ if (S->type != SPACETYPE) {
+ ArgErr("QueryLoc: second arg not a space", S, NULL);
+ return;
+ }
+ UnConvert(S, &P->dest, xP, yP);
+}
+/*
+:h3.QueryPath() - Find Out the Type of Segment at the Head of a Path
+
+This is a very simple routine that looks at the first segment of a
+path and tells the caller what it is, as well as returning the control
+point(s) of the path segment. Different path segments have different
+number of control points. If the caller knows that the segment is
+a move segment, for example, he only needs to pass pointers to return
+one control point.
+*/
+
+void
+QueryPath(struct segment *path, /* path to check */
+ int *typeP, /* return the type of path here */
+ struct segment **Bp, /* return location of first point */
+ struct segment **Cp, /* return location of second point */
+ struct segment **Dp, /* return location of third point */
+ double *fP) /* return Conic sharpness */
+{
+ register int coerced = FALSE; /* did I coerce a text path? */
+
+ if (path == NULL) {
+ *typeP = -1;
+ return;
+ }
+ if (!ISPATHANCHOR(path)) {
+ ArgErr("QueryPath: arg not a valid path", path, NULL);
+ }
+ if (path->type == TEXTTYPE) {
+ path = CoerceText(path);
+ coerced = TRUE;
+ }
+
+ switch (path->type) {
+
+ case MOVETYPE:
+ *typeP = 0;
+ *Bp = PathSegment(MOVETYPE, path->dest.x, path->dest.y);
+ break;
+
+ case LINETYPE:
+ *typeP = (LASTCLOSED(path->flag)) ? 4 : 1;
+ *Bp = PathSegment(MOVETYPE, path->dest.x, path->dest.y);
+ break;
+
+ case CONICTYPE:
+ {
+ register struct conicsegment *cp = (struct conicsegment *) path;
+
+ *typeP = 2;
+ *Bp = PathSegment(MOVETYPE, cp->M.x, cp->M.y);
+ *Cp = PathSegment(MOVETYPE, cp->dest.x, cp->dest.y);
+ *fP = cp->roundness;
+ }
+ break;
+
+ case BEZIERTYPE:
+ {
+ register struct beziersegment *bp = (struct beziersegment *) path;
+
+ *typeP = 3;
+ *Bp = PathSegment(MOVETYPE, bp->B.x, bp->B.y);
+ *Cp = PathSegment(MOVETYPE, bp->C.x, bp->C.y);
+ *Dp = PathSegment(MOVETYPE, bp->dest.x, bp->dest.y);
+ }
+ break;
+
+ case HINTTYPE:
+ *typeP = 5;
+ break;
+
+ default:
+ Abort("QueryPath: unknown segment");
+ }
+ if (coerced)
+ KillPath(path);
+}
+/*
+:h3.QueryBounds() - Return the Bounding Box of a Path
+
+Returns the bounding box by setting the user's variables.
+*/
+
+void
+QueryBounds(struct segment *p0, /* object to check for bound */
+ struct XYspace *S, /* coordinate space of returned values */
+ double *xminP, /* lower left hand corner (set by routine) */
+ double *yminP,
+ double *xmaxP, /* upper right hand corner (set by routine) */
+ double *ymaxP)
+{
+ register struct segment *path; /* loop variable for path segments */
+ register fractpel lastx,lasty; /* loop variables: previous endingpoint */
+ register fractpel x,y; /* loop variables: current ending point */
+ struct fractpoint min; /* registers to keep lower left hand corner */
+ struct fractpoint max; /* registers to keep upper right hand corner */
+ int coerced = FALSE; /* we have coerced the path from another object */
+ double x1,y1,x2,y2,x3,y3,x4,y4; /* corners of rectangle in space X */
+
+ if (S->type != SPACETYPE) {
+ ArgErr("QueryBounds: bad XYspace", S, NULL);
+ return;
+ }
+
+ min.x = min.y = max.x = max.y = 0;
+ if (p0 != NULL) {
+ if (!ISPATHANCHOR(p0)) {
+ switch(p0->type) {
+ case STROKEPATHTYPE:
+ /* replaced DupStrokePath() with Dup() 3-26-91 PNM */
+ p0 = (struct segment *) DoStroke(Dup(p0));
+ /* no break here, we have a region in p0 */
+ case REGIONTYPE:
+ p0 = RegionBounds((struct region *)p0);
+ break;
+
+ case PICTURETYPE:
+ p0 = PictureBounds(p0);
+ break;
+
+ default:
+ ArgErr("QueryBounds: bad object", p0, NULL);
+ return;
+ }
+ coerced = TRUE;
+ }
+ if (p0->type == TEXTTYPE) {
+ /* replaced CopyPath() with Dup() 3-26-91 PNM */
+ p0 = (struct segment *)CoerceText(Dup(p0)); /* there are faster ways */
+ coerced = TRUE;
+ }
+ if (p0->type == MOVETYPE) {
+ min.x = max.x = p0->dest.x;
+ min.y = max.y = p0->dest.y;
+ }
+ }
+ lastx = lasty = 0;
+
+ for (path = p0; path != NULL; path = path->link) {
+
+ x = lastx + path->dest.x;
+ y = lasty + path->dest.y;
+
+ switch (path->type) {
+
+ case LINETYPE:
+ break;
+
+ case CONICTYPE:
+ {
+ register struct conicsegment *cp = (struct conicsegment *) path;
+ register fractpel Mx = lastx + cp->M.x;
+ register fractpel My = lasty + cp->M.y;
+ register fractpel deltax = 0.5 * cp->roundness * cp->dest.x;
+ register fractpel deltay = 0.5 * cp->roundness * cp->dest.y;
+ register fractpel Px = Mx - deltax;
+ register fractpel Py = My - deltay;
+ register fractpel Qx = Mx + deltax;
+ register fractpel Qy = My + deltay;
+
+
+ if (Mx < min.x) min.x = Mx;
+ else if (Mx > max.x) max.x = Mx;
+ if (My < min.y) min.y = My;
+ else if (My > max.y) max.y = My;
+
+ if (Px < min.x) min.x = Px;
+ else if (Px > max.x) max.x = Px;
+ if (Py < min.y) min.y = Py;
+ else if (Py > max.y) max.y = Py;
+
+ if (Qx < min.x) min.x = Qx;
+ else if (Qx > max.x) max.x = Qx;
+ if (Qy < min.y) min.y = Qy;
+ else if (Qy > max.y) max.y = Qy;
+ }
+ break;
+
+
+ case MOVETYPE:
+ /*
+ * We can't risk adding trailing Moves to the
+ * bounding box:
+ */
+ if (path->link == NULL)
+ goto done; /* God forgive me */
+ break;
+
+ case BEZIERTYPE:
+ {
+ register struct beziersegment *bp = (struct beziersegment *) path;
+ register fractpel Bx = lastx + bp->B.x;
+ register fractpel By = lasty + bp->B.y;
+ register fractpel Cx = lastx + bp->C.x;
+ register fractpel Cy = lasty + bp->C.y;
+
+ if (Bx < min.x) min.x = Bx;
+ else if (Bx > max.x) max.x = Bx;
+ if (By < min.y) min.y = By;
+ else if (By > max.y) max.y = By;
+
+ if (Cx < min.x) min.x = Cx;
+ else if (Cx > max.x) max.x = Cx;
+ if (Cy < min.y) min.y = Cy;
+ else if (Cy > max.y) max.y = Cy;
+ }
+ break;
+
+ case HINTTYPE:
+ break;
+ default:
+ Abort("QueryBounds: unknown type");
+ }
+
+ if (x < min.x) min.x = x;
+ else if (x > max.x) max.x = x;
+ if (y < min.y) min.y = y;
+ else if (y > max.y) max.y = y;
+
+ lastx = x; lasty = y;
+ }
+done:
+ UnConvert(S, &min, &x1, &y1);
+ UnConvert(S, &max, &x4, &y4);
+ x = min.x; min.x = max.x; max.x = x;
+ UnConvert(S, &min, &x2, &y2);
+ UnConvert(S, &max, &x3, &y3);
+
+ *xminP = *xmaxP = x1;
+ if (x2 < *xminP) *xminP = x2;
+ else if (x2 > *xmaxP) *xmaxP = x2;
+ if (x3 < *xminP) *xminP = x3;
+ else if (x3 > *xmaxP) *xmaxP = x3;
+ if (x4 < *xminP) *xminP = x4;
+ else if (x4 > *xmaxP) *xmaxP = x4;
+
+ *yminP = *ymaxP = y1;
+ if (y2 < *yminP) *yminP = y2;
+ else if (y2 > *ymaxP) *ymaxP = y2;
+ if (y3 < *yminP) *yminP = y3;
+ else if (y3 > *ymaxP) *ymaxP = y3;
+ if (y4 < *yminP) *yminP = y4;
+ else if (y4 > *ymaxP) *ymaxP = y4;
+
+ if (coerced)
+ Destroy(p0);
+}
+/*
+:h3.BoxPath()
+*/
+struct segment *
+BoxPath(struct XYspace *S, int h, int w)
+{
+ struct segment *path;
+
+ path = Join( Line(ILoc(S, w, 0)), Line(ILoc(S, 0, h)) );
+ path = JoinSegment(path, LINETYPE, -path->dest.x, -path->dest.y, NULL);
+ return(ClosePath(path));
+}
+
+/*
+:h3.DropSegment() - Drop the First Segment in a Path
+
+This routine takes the path and returns a new path that is one segment
+shorter. It can be used in conjunction with QueryPath(), for example,
+to ask about an entire path.
+*/
+
+struct segment *
+DropSegment(struct segment *path)
+{
+ if (path != NULL && path->type == STROKEPATHTYPE)
+ path = CoercePath(path);
+ ARGCHECK((path == NULL || !ISPATHANCHOR(path)),
+ "DropSegment: arg not a non-null path", path, path, (0), struct segment *);
+ if (path->type == TEXTTYPE)
+ path = CoerceText(path);
+ path = UniquePath(path);
+
+ POP(path);
+ return(path);
+}
+/*
+:h3.HeadSegment() - Return the First Segment in a Path
+
+This routine takes the path and returns a new path consists of the
+first segment only.
+*/
+
+struct segment *
+HeadSegment(struct segment *path) /* input path */
+{
+ if (path == NULL)
+ return(NULL);
+ if (path->type == STROKEPATHTYPE)
+ path = CoercePath(path);
+ ARGCHECK(!ISPATHANCHOR(path), "HeadSegment: arg not a path", path, path, (0), struct segment *);
+ if (path->type == TEXTTYPE)
+ path = CoerceText(path);
+ path = UniquePath(path);
+
+ if (path->link != NULL)
+ KillPath(path->link);
+ path->link = NULL;
+ path->last = path;
+ return(path);
+}
+
+/*
+:h2.Path Debug Routines
+
+:h3.DumpPath() - Display a Path on the Trace File
+*/
+
+void
+DumpPath(struct segment *p)
+{
+}
diff --git a/nx-X11/lib/font/Type1/paths.h b/nx-X11/lib/font/Type1/paths.h
new file mode 100644
index 000000000..b61275b9c
--- /dev/null
+++ b/nx-X11/lib/font/Type1/paths.h
@@ -0,0 +1,239 @@
+/* $Xorg: paths.h,v 1.3 2000/08/17 19:46:31 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/paths.h,v 1.3 1999/08/22 08:58:53 dawes Exp $ */
+
+/*SHARED*/
+
+#define Loc(S,x,y) t1_Loc(S,(double)x,(double)y)
+#define ILoc(S,x,y) t1_ILoc(S,x,y)
+#define Line(P) t1_Line(P)
+#define Join(p1,p2) t1_Join(p1,p2)
+#define ClosePath(p) t1_ClosePath(p,0)
+#define CloseLastSubPath(p) t1_ClosePath(p,1)
+#define Conic(B,C,s) t1_Conic(B,C,(double)s)
+#define RoundConic(M,C,r) t1_RoundConic(M,C,(double)r)
+#define ArcP3(S,P2,P3) t1_ArcP3(S,P2,P3)
+#define ArcCA(S,C,d) t1_ArcCA(S,C,(double)d)
+#define Bezier(B,C,D) t1_Bezier(B,C,D)
+#define Hint(S,r,w,o,h,a,d,l) t1_Hint(S,r,w,o,h,a,d,l)
+#define Reverse(p) t1_Reverse(p)
+#define ReverseSubPaths(p) t1_ReverseSubPaths(p)
+#define AddLoc(p1,p2) t1_Join(p1,p2)
+#define SubLoc(p1,p2) t1_SubLoc(p1,p2)
+#define DropSegment(p) t1_DropSegment(p)
+#define HeadSegment(p) t1_HeadSegment(p)
+#define QueryLoc(P,S,x,y) t1_QueryLoc(P,S,x,y)
+#define QueryPath(p,t,B,C,D,r) t1_QueryPath(p,t,B,C,D,r)
+#define QueryBounds(p,S,x1,y1,x2,y2) t1_QueryBounds(p,S,x1,y1,x2,y2)
+
+
+/* create a location object (or "move" segment) */
+extern struct segment *t1_Loc ( struct XYspace *S, double x, double y );
+/* integer argument version of same */
+extern struct segment *t1_ILoc ( struct XYspace *S, int x, int y );
+/* straight line path segment */
+extern struct segment *t1_Line ( struct segment *P );
+/* join two paths or regions together */
+extern struct segment *t1_Join ( struct segment *p1, struct segment *p2 );
+/* close a path or path set */
+extern struct segment *t1_ClosePath ( struct segment *p0, int lastonly );
+#if 0
+struct conicsegment *t1_Conic(); /* conic curve path segment */
+
+struct conicsegment *t1_RoundConic(); /* ditto, specified another way */
+struct conicsegment *t1_ArcP3(); /* circular path segment with three points */
+struct conicsegment *t1_ArcCA(); /* ditto, with center point and angle */
+#endif
+/* Bezier third order curve path segment */
+extern struct beziersegment *t1_Bezier ( struct segment *B, struct segment *C,
+ struct segment *D );
+/* produce a font 'hint' path segment */
+extern struct hintsegment *t1_Hint ( struct XYspace *S, float ref, float width,
+ char orientation, char hinttype,
+ char adjusttype, char direction,
+ int label );
+/* reverse the complete order of paths */
+extern struct segment *t1_Reverse ( struct segment *p );
+/* reverse only sub-paths; moves unchanged */
+extern struct segment *t1_ReverseSubPaths ( struct segment *p );
+/* subtract two location objects */
+extern struct segment *t1_SubLoc ( struct segment *p1, struct segment *p2 );
+/* Drop the first segment in a path */
+extern struct segment *t1_DropSegment ( struct segment *path );
+/* return the first segment in a path */
+extern struct segment *t1_HeadSegment ( struct segment *path );
+/* Query location; return its (x,y) */
+extern void t1_QueryLoc ( struct segment *P, struct XYspace *S, double *xP,
+ double *yP );
+/* Query segment at head of a path */
+extern void t1_QueryPath ( struct segment *path, int *typeP,
+ struct segment **Bp, struct segment **Cp,
+ struct segment **Dp, double *fP );
+/* Query the bounding box of a path */
+extern void t1_QueryBounds ( struct segment *p0, struct XYspace *S,
+ double *xminP, double *yminP,
+ double *xmaxP, double *ymaxP );
+
+/*END SHARED*/
+/*SHARED*/
+
+#define CopyPath(p) t1_CopyPath(p)
+#define KillPath(p) t1_KillPath(p)
+#define PathTransform(p,m) t1_PathXform(p,m)
+#define PathDelta(p,pt) t1_PathDelta(p,pt)
+#define BoundingBox(h,w) t1_BoundingBox(h,w)
+#define PathSegment(t,x,y) t1_PathSegment(t,(fractpel)x,(fractpel)y)
+#define JoinSegment(b,t,x,y,a) t1_JoinSegment(b,t,(fractpel)x,(fractpel)y,a)
+#define Hypoteneuse(dx,dy) t1_Hypoteneuse(dx,dy)
+#define BoxPath(S,h,w) t1_BoxPath(S,h,w)
+
+/* duplicate a path */
+extern struct segment *t1_CopyPath ( struct segment *p0 );
+/* destroy a path */
+extern void t1_KillPath ( struct segment *p );
+/* transform a path arbitrarily */
+extern struct segment *t1_PathXform ( struct segment *p0, struct XYspace *S );
+/* calculate the ending point of a path */
+extern void t1_PathDelta ( struct segment *p, struct fractpoint *pt );
+/* */
+extern struct segment *t1_BoundingBox ( pel h, pel w );
+/* produce a MOVE or LINE segment */
+extern struct segment *t1_PathSegment ( int type, fractpel x, fractpel y );
+/* join a MOVE or LINE segment to a path */
+extern struct segment *t1_JoinSegment ( struct segment *before, int type, fractpel x, fractpel y, struct segment *after );
+#if 0
+double t1_Hypoteneuse(); /* returns the length of a line */
+#endif
+/* returns a rectangular path */
+extern struct segment *t1_BoxPath ( struct XYspace *S, int h, int w );
+
+/*END SHARED*/
+/*SHARED*/
+
+#define ConsumePath(p) MAKECONSUME(p,KillPath(p))
+#define UniquePath(p) MAKEUNIQUE(p,CopyPath(p))
+
+/*END SHARED*/
+/*SHARED*/
+
+struct segment {
+ XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
+ unsigned char size; /* size of the structure */
+ unsigned char context; /* index to device context */
+ struct segment *link; /* pointer to next structure in linked list */
+ struct segment *last; /* pointer to last structure in list */
+ struct fractpoint dest; /* relative ending location of path segment */
+} ;
+
+#define ISCLOSED(flag) ((flag)&0x80) /* subpath is closed */
+#define LASTCLOSED(flag) ((flag)&0x40) /* last segment in closed subpath */
+
+/*
+NOTE: The ISCLOSED flag is set on the MOVETYPE segment before the
+subpath proper; the LASTCLOSED flag is set on the last segment (LINETYPE)
+in the subpath
+
+We define the ISPATHANCHOR predicate to test that a path handle
+passed by the user is valid:
+*/
+
+#define ISPATHANCHOR(p) (ISPATHTYPE(p->type)&&p->last!=NULL)
+
+/*
+For performance reasons, a user's "location" object is identical to
+a path whose only segment is a move segment. We define a predicate
+to test for this case. See also :hdref refid=location..
+*/
+
+#define ISLOCATION(p) ((p)->type == MOVETYPE && (p)->link == NULL)
+
+/*END SHARED*/
+/*SHARED*/
+
+struct conicsegment {
+ XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
+ /* type = CONICTYPE */
+ unsigned char size; /* as with any 'segment' type */
+ unsigned char context; /* as with any 'segment' type */
+ struct segment *link; /* as with any 'segment' type */
+ struct segment *last; /* as with any 'segment' type */
+ struct fractpoint dest; /* Ending point (C point) */
+ struct fractpoint M; /* "midpoint" of conic explained above */
+ float roundness; /* explained above */
+} ;
+/*END SHARED*/
+/*SHARED*/
+
+struct beziersegment {
+ XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
+ /* type = BEZIERTYPE */
+ unsigned char size; /* as with any 'segment' type */
+ unsigned char context; /* as with any 'segment' type */
+ struct segment *link; /* as with any 'segment' type */
+ struct segment *last; /* as with any 'segment' type */
+ struct fractpoint dest; /* ending point (D) */
+ struct fractpoint B; /* control point B */
+ struct fractpoint C; /* control point C */
+} ;
+
+/*END SHARED*/
+/*SHARED*/
+
+struct hintsegment {
+ XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
+ /* type = HINTTYPE */
+ unsigned char size; /* size of the structure */
+ unsigned char context; /* device context */
+ struct segment *link; /* pointer to next structure in linked list */
+ struct segment *last; /* pointer to last structure in list */
+ struct fractpoint dest; /* ALWAYS 0,0 */
+ struct fractpoint ref;
+ struct fractpoint width;
+ char orientation;
+ char hinttype;
+ char adjusttype;
+ char direction;
+ int label;
+} ;
+
+/*END SHARED*/
+/*SHARED*/
+
+/*
+CONCAT links the 'p2' path chain on the end of the 'p1' chain. (This macro
+is also used by the STROKES module.)
+*/
+#define CONCAT(p1, p2) { \
+ p1->last->link = p2; /* link p2 on end of p1 */ \
+ p1->last = p2->last; /* last of new is last of p2 */ \
+ p2->last = NULL; } /* only first segment has non-NULL "last" */
+
+/*END SHARED*/
+/* dump a path list */
+extern void t1_DumpPath ( struct segment *p );
diff --git a/nx-X11/lib/font/Type1/pictures.h b/nx-X11/lib/font/Type1/pictures.h
new file mode 100644
index 000000000..0abc715ce
--- /dev/null
+++ b/nx-X11/lib/font/Type1/pictures.h
@@ -0,0 +1,50 @@
+/* $Xorg: pictures.h,v 1.3 2000/08/17 19:46:31 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* $XFree86: xc/lib/font/Type1/pictures.h,v 1.3 1999/08/22 08:58:53 dawes Exp $ */
+
+/* STUB */
+
+#define CopyPicture(p) p
+#define UniquePicture(p) p
+#define KillPicture(p)
+#define BegHandle(o,m) o
+#define EndHandle(o,m) o
+#define PictureBounds(P) P
+
+struct picture {
+ struct fractpoint origin;
+ struct fractpoint ending;
+};
+
+#define Phantom(o) t1_Phantom(o)
+#define Snap(o) t1_Snap(o)
+
+extern struct segment *t1_Phantom ( struct segment *p );
+extern struct segment *t1_Snap ( struct segment *p );
diff --git a/nx-X11/lib/font/Type1/range.h b/nx-X11/lib/font/Type1/range.h
new file mode 100644
index 000000000..496f000da
--- /dev/null
+++ b/nx-X11/lib/font/Type1/range.h
@@ -0,0 +1,48 @@
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#if XFONT_CID
+#define CID_NAME_MAX 255 /* max # of characters in a file name */
+#define CID_PATH_MAX 1024 /* max # of characters in a path name */
+
+typedef struct spacerange_code {
+ unsigned int srcCodeLo;
+ unsigned int srcCodeHi;
+} spacerangecode;
+
+typedef struct space_range {
+ struct space_range *next;
+ int rangecnt;
+ struct spacerange_code *spacecode;
+} spacerange;
+
+typedef struct cidrange_code {
+ unsigned int srcCodeLo;
+ unsigned int srcCodeHi;
+ unsigned int dstCIDLo;
+} cidrangecode;
+
+typedef struct cid_range {
+ struct cid_range *next;
+ int rangecnt;
+ struct cidrange_code *range;
+} cidrange;
+#endif
diff --git a/nx-X11/lib/font/Type1/regions.c b/nx-X11/lib/font/Type1/regions.c
new file mode 100644
index 000000000..f8875dafb
--- /dev/null
+++ b/nx-X11/lib/font/Type1/regions.c
@@ -0,0 +1,1651 @@
+/* $Xorg: regions.c,v 1.3 2000/08/17 19:46:31 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/regions.c,v 3.8tsi Exp $ */
+ /* REGIONS CWEB V0023 LOTS */
+/*
+:h1 id=regions.REGIONS Module - Regions Operator Handler
+
+This module is responsible for creating and manipulating regions.
+
+&author. Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com)
+
+
+:h3.Include Files
+
+The included files are:
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef FONTMODULE
+# include "os.h"
+#endif
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h"
+#include "curves.h"
+#include "lines.h"
+#include "pictures.h"
+#include "fonts.h"
+#include "hints.h"
+#include "strokes.h" /* to pick up 'DoStroke' */
+
+
+static void newfilledge ( struct region *R, fractpel xmin, fractpel xmax,
+ fractpel ymin, fractpel ymax, int isdown );
+static struct edgelist *splitedge ( struct edgelist *list, pel y );
+static void vertjoin ( struct edgelist *top, struct edgelist *bottom );
+static int touches ( int h, pel *left, pel *right );
+static int crosses ( int h, pel *left, pel *right );
+static void edgemin ( int h, pel *e1, pel *e2 );
+static void edgemax ( int h, pel *e1, pel *e2 );
+static struct edgelist *NewEdge ( pel xmin, pel xmax, pel ymin, pel ymax,
+ pel *xvalues, int isdown );
+static struct edgelist *swathxsort ( struct edgelist *before0,
+ struct edgelist *edge );
+/*
+:h3.Functions Provided to the TYPE1IMAGER User
+
+This module provides the following TYPE1IMAGER entry points:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Functions Provided to Other Modules
+
+This module provides the following entry points to other modules:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Macros Provided to Other Modules
+
+:h4.GOING_TO() - Macro Predicate Needed for Changing Direction, Etc.
+
+The actual generation of run end lists (edge boundaries) is left
+to the low level rasterizing modules, LINES and CURVES. There
+are some global region-type
+questions that occur when doing a low-level
+rasterization:
+:ol.
+:li.Did we just change direction in Y and therefore need to start
+a new edge?
+:li.Did we run out of allocated edge space?
+:li.Do the minimum or maximum X values for the current edge need
+updating?
+:eol.
+In general the REGIONS is not smart enough to answer those questions
+itself. (For example, determining if and when a curve changes direction
+may need detailed curve knowledge.) Yet, this must be done efficiently.
+We provide a macro "GOING_TO" where the invoker tells us where it is
+heading for (x2,y2), plus where it is now (x1,y1), plus the current
+region under construction, and the macro answers the questions above.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h2.Data Structures Used to Represent Regions
+
+:h3.The "region" Structure
+
+The region structure is an anchor for a linked list of "edgelist"
+structures (see :hdref refid=edgelist..). It also summarizes the
+information in the edgelist structures (for example, the bounding
+box of the region). And, it contains scratch areas used during
+the creation of a region.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+The ISOPTIMIZED flag tells us if we've put a permanent region in
+'optimal' form.
+*/
+#define ISOPTIMIZED(flag) ((flag)&0x10)
+
+/*
+The ISRECTANGULAR flag tells us if a region is a rectangle. We don't
+always notice rectangles--if this flag is set, the region definitely
+is a rectangle, but some rectangular regions will not have the flag
+set. The flag is used to optimize some paths.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h4."TT_INFINITY" - A Constant Region Structure of Infinite Extent
+
+Infinity is the complement of a null area:
+Note - removed the refcount = 1 init, replaced with references = 2 3-26-91 PNM
+*/
+static struct region _infinity = { REGIONTYPE,
+ ISCOMPLEMENT(ON)+ISINFINITE(ON)+ISPERMANENT(ON)+ISIMMORTAL(ON), 2,
+ {0, 0}, {0, 0},
+ 0, 0, 0, 0,
+ NULL, NULL,
+ 0, 0, 0, 0, 0, NULL, NULL,
+ NULL, 0, NULL, NULL };
+struct region *TT_INFINITY = &_infinity;
+
+/*
+:h4."EmptyRegion" - A Region Structure with Zero Area
+
+This structure is used to initialize the region to be built in
+Interior():
+Note - replaced refcount = 1 init with references = 2 3-26-91 PNM
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+struct region EmptyRegion = { REGIONTYPE,
+ ISPERMANENT(ON)+ISIMMORTAL(ON), 2,
+ {0, 0}, {0, 0},
+ MAXPEL, MAXPEL, MINPEL, MINPEL,
+ NULL, NULL,
+ 0, 0, 0, 0, 0, NULL, NULL,
+ NULL, 0, NULL, NULL };
+
+/*
+:h3 id=edgelist.The "edgelist" Structure
+
+Regions are represented by a linked list of 'edgelist' structures.
+When a region is complete, the structures are paired, one for the
+left and one for the right edge. While a region is being built,
+this rule may be violated temporarily.
+
+An 'edgelist' structure contains the X values for a given span
+of Y values. The (X,Y) pairs define an edge. We use the crack
+and edge coordinate system, so that integer values of X and Y
+go between pels. The edge is defined between the minimum Y and
+maximum Y.
+
+The linked list is kept sorted from top to bottom, that is, in
+increasing y. Also, if 'e1' is an edgelist structure and 'e2' is the
+next one in the list, they must have exactly the same ymin,ymax values
+or be totally disjoint. These two requirements mean that if e2's ymin
+is less than e1's ymax, it must be exactly equal to e1's ymin. A
+sublist of structures with identical ymin and ymax values is called a
+'swath'.
+
+In addition, edgelist structures are separately linked together based
+on what subpath originally created them; each subpath is kept as a
+separate circular linked list. This information is ignored unless
+continuity checking is invoked. See :hdref refid=subpath. for a
+complete description of this.
+*/
+
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+The "edgelist" structure follows the convention of TYPE1IMAGER user
+objects, having a type field and a flag field as the first two
+elements. However, the user never sees "edgelist" structures
+directly; he is given handles to "region" structures only.
+
+By having a type field, we can use the "copy" feature of Allocate()
+to duplicate edge lists quickly.
+
+We also define two flag bits for this structure. The ISDOWN bit is set
+if the edge is going in the direction of increasing Y. The ISAMBIGUOUS
+bit is set if the edge is identical to its neighbor (edge->link); such
+edges may be "left" when they should be "right", or vice versa,
+unnecessarily confusing the continuity checking logic. The FixSubPaths()
+routine in HINTS will swap ambiguous edges if that avoids crossing edges;
+see :hdref refid=fixsubp..
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h3.KillRegion() - Destroys a Region
+
+KillRegion nominally just decrements the reference count to that region.
+If the reference count becomes 0, all memory associated with it is
+freed. We just follow the linked list, freeing as we go, then kill any
+associated (thresholded) picture.
+Note - added conditional return based on references 3-26-91 PNM
+*/
+
+void
+KillRegion(struct region *area) /* area to free */
+{
+ register struct edgelist *p; /* loop variable */
+ register struct edgelist *next; /* loop variable */
+
+ if (area->references < 0)
+ Abort("KillRegion: negative reference count");
+ if ( (--(area->references) > 1) ||
+ ( (area->references == 1) && !ISPERMANENT(area->flag) ) )
+ return;
+
+ for (p=area->anchor; p != NULL; p=next) {
+ next = p->link;
+ Free(p);
+ }
+ if (area->thresholded != NULL)
+ KillPicture(area->thresholded);
+ Free(area);
+}
+/*
+:h3.CopyRegion() - Makes a Copy of a Region
+*/
+struct region *
+CopyRegion(struct region *area) /* region to duplicate */
+{
+ register struct region *r; /* output region built here */
+ register struct edgelist *last = NULL; /* loop variable */
+ register struct edgelist *p,*newp; /* loop variables */
+
+ r = (struct region *)Allocate(sizeof(struct region), area, 0);
+ r->anchor = NULL;
+
+ for (p=area->anchor; VALIDEDGE(p); p=p->link) {
+
+ newp = NewEdge(p->xmin, p->xmax, p->ymin, p->ymax, p->xvalues, ISDOWN(p->flag));
+ if (r->anchor == NULL)
+ r->anchor = last = newp;
+ else
+ last->link = newp;
+
+ last = newp;
+ }
+ if (area->thresholded != NULL)
+ /* replaced DupPicture with Dup() 3-26-91 PNM */
+ r->thresholded = (struct picture *)Dup(area->thresholded);
+ return(r);
+}
+/*
+:h4.NewEdge() - Allocates and Returns a New "edgelist" Structure
+
+We allocate space for the X values contiguously with the 'edgelist'
+structure that locates them. That way, we only have to free the
+edgelist structure to free all memory associated with it. Damn
+clever, huh?
+*/
+
+static struct edgelist *
+NewEdge(pel xmin, pel xmax, /* X extent of edge */
+ pel ymin, pel ymax, /* Y extent of edge */
+ pel *xvalues, /* list of X values for entire edge */
+ int isdown) /* flag: TRUE means edge progresses downward */
+{
+ static struct edgelist template = {
+ EDGETYPE, 0, 1, NULL, NULL,
+ 0, 0, 0, 0, NULL };
+
+ register struct edgelist *r; /* returned structure */
+ register int iy; /* ymin adjusted for 'long' alignment purposes */
+
+ if (ymin >= ymax)
+ Abort("newedge: height not positive");
+/*
+We are going to copy the xvalues into a newly allocated area. It
+helps performance if the values are all "long" aligned. We can test
+if the xvalues are long aligned by ANDing the address with the
+(sizeof(long) - 1)--if non zero, the xvalues are not aligned well. We
+set 'iy' to the ymin value that would give us good alignment:
+*/
+ iy = ymin - (((unsigned long)xvalues) & (sizeof(long)-1)) / sizeof(pel);
+
+ r = (struct edgelist *)Allocate(sizeof(struct edgelist), &template,
+ (ymax - iy) * sizeof(pel));
+
+ if (isdown) r->flag = ISDOWN(ON);
+ r->xmin = xmin;
+ r->xmax = xmax;
+ r->ymin = ymin;
+ r->ymax = ymax;
+
+ r->xvalues = (pel *) FOLLOWING(r);
+ if (ymin != iy) {
+ r->xvalues += ymin - iy;
+ xvalues -= ymin - iy;
+ }
+
+/*
+We must round up (ymax - iy) so we get the ceiling of the number of
+longs. The destination must be able to hold these extra bytes because
+Allocate() makes everything it allocates be in multiples of longs.
+*/
+ LONGCOPY(&r[1], xvalues, (ymax - iy) * sizeof(pel) + sizeof(long) - 1);
+
+ return(r);
+}
+
+/*
+:h3 id=discard.discard() - Discard All Edges Between Two Edges
+
+At first glance it would seem that we could discard an edgelist
+structure merely by unlinking it from the list and freeing it. You are
+wrong, region-breath! For performance, the X values associated with an
+edge are allocated contiguously with it. So, we free the X values when
+we free a structure. However, once an edge has been split, we are no
+longer sure which control block actually is part of the memory block
+that contains the edges. Rather than trying to decide, we play it safe
+and never free part of a region.
+
+So, to mark a 'edgelist' structure as discarded, we move it to the end
+of the list and set ymin=ymax.
+*/
+
+static void
+discard(struct edgelist *left, /* all edges between here exclusive */
+ struct edgelist *right) /* should be discarded */
+{
+ register struct edgelist *beg,*end,*p;
+
+ beg = left->link;
+ if (beg == right)
+ return;
+
+ for (p = beg; p != right; p = p->link) {
+ if (p->link == NULL && right != NULL)
+ Abort("discard(): ran off end");
+ p->ymin = p->ymax = 32767;
+ end = p;
+ }
+ /*
+ * now put the chain beg/end at the end of right, if it is not
+ * already there:
+ */
+ if (right != NULL) {
+ left->link = right;
+ while (right->link != NULL)
+ right = right->link;
+ right->link = beg;
+ }
+ end->link = NULL;
+}
+
+/*
+:h4.Unwind() - Discards Edges That Fail the Winding Rule Test
+
+The winding rule says that upward going edges should be paired with
+downward going edges only, and vice versa. So, if two upward edges
+or two downward edges are nominally left/right pairs, Unwind() should
+discard the second one. Everything should balance; we should discard
+an even number of edges; of course, we abort if we don't.
+*/
+static void
+Unwind(struct edgelist *area) /* input area modified in place */
+{
+ register struct edgelist *last = NULL,*next; /* struct before and after current one */
+ register int y; /* ymin of current swath */
+ register int count,newcount; /* winding count registers */
+
+ while (VALIDEDGE(area)) {
+
+ count = 0;
+ y = area->ymin;
+
+ do {
+ next = area->link;
+
+ if (ISDOWN(area->flag))
+ newcount = count + 1;
+ else
+ newcount = count - 1;
+
+ if (count == 0 || newcount == 0)
+ last = area;
+ else
+ discard(last, next);
+
+ count = newcount;
+ area = next;
+
+ } while (area != NULL && area->ymin == y);
+
+ if (count != 0)
+ Abort("Unwind: uneven edges");
+ }
+}
+/*
+:h2.Building Regions
+
+:h3.Interior() - Iterate Through a Path, Building a Region
+
+This routine is the workhorse driver routine that iterates through a
+path, calling the appropriate stepping routines to actually produce the
+run end "edgelist" structures.
+
+:ol.
+:li."Interior" calls StepLine or StepConic or StepBezier as appropriate
+to produce run ends.
+:li.Occasionally these routines will notice a change in Y direction
+and will call ChangeDirection (through the GOING_TO macro); this is
+a call back to the REGIONS module.
+:li.ChangeDirection will call whatever function is in the region
+structure; for Interior, this function is 'newfilledge'.
+:li.Newfilledge will call NewEdge to create a new edgelist structure,
+then, call SortSwath to sort it onto the linked list being built at
+the region "anchor".
+:eol.
+
+By making the function called by ChangeDirection be a parameter of the
+region, we allow the same ChangeDirection logic to be used by stroking.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+struct region *
+Interior(struct segment *p, /* take interior of this path */
+ int fillrule) /* rule to follow if path crosses itself */
+{
+ register fractpel x,y; /* keeps ending point of path segment */
+ fractpel lastx,lasty; /* previous x,y from path segment before */
+ register struct region *R; /* region I will build */
+ register struct segment *nextP; /* next segment of path */
+ struct fractpoint hint; /* accumulated hint value */
+ char tempflag; /* flag; is path temporary? */
+ char Cflag; /* flag; should we apply continuity? */
+
+ if (p == NULL)
+ return(NULL);
+/*
+Establish the 'Cflag' continuity flag based on user's fill rule and
+our own 'Continuity' pragmatic (0: never do continuity, 1: do what
+user asked, >1: do it regardless).
+*/
+ if (fillrule > 0) {
+ Cflag = Continuity > 0;
+ fillrule -= CONTINUITY;
+ }
+ else
+ Cflag = Continuity > 1;
+
+ ARGCHECK((fillrule != WINDINGRULE && fillrule != EVENODDRULE),
+ "Interior: bad fill rule", NULL, NULL, (1,p), struct region *);
+
+ if (p->type == TEXTTYPE)
+/* if (fillrule != EVENODDRULE)
+ else */
+ return((struct region *)UniquePath(p));
+ if (p->type == STROKEPATHTYPE) {
+ if (fillrule == WINDINGRULE)
+ return((struct region *)DoStroke(p));
+ else
+ p = CoercePath(p);
+ }
+
+ R = (struct region *)Allocate(sizeof(struct region), &EmptyRegion, 0);
+
+ ARGCHECK(!ISPATHANCHOR(p), "Interior: bad path", p, R, (0), struct region *);
+ ARGCHECK((p->type != MOVETYPE), "Interior: path not closed", p, R, (0), struct region *);
+
+
+/* changed definition from !ISPERMANENT to references <= 1 3-26-91 PNM */
+ tempflag = (p->references <= 1); /* only first segment in path is so marked */
+ if (!ISPERMANENT(p->flag)) p->references -= 1;
+
+ R->newedgefcn = newfilledge;
+/*
+Believe it or not, "R" is now completely initialized. We are counting
+on the copy of template to get other fields the way we want them,
+namely
+:ol.
+:li.anchor = NULL
+:li.xmin, ymin, xmax, ymax, to minimum and maximum values respectively.
+:eol.
+Anchor = NULL is very
+important to ChangeDirection.
+See :hdref refid=CD..
+
+To minimize problems of "wrapping" in our pel arithmetic, we keep an
+origin of the region which is the first move. Hopefully, that keeps
+numbers within plus or minus 32K pels.
+*/
+ R->origin.x = 0/*TOFRACTPEL(NEARESTPEL(p->dest.x))*/;
+ R->origin.y = 0/*TOFRACTPEL(NEARESTPEL(p->dest.y))*/;
+ lastx = - R->origin.x;
+ lasty = - R->origin.y;
+/*
+ChangeDirection initializes other important fields in R, such as
+lastdy, edge, edgeYstop, edgexmin, and edgexmax. The first segment
+is a MOVETYPE, so it will be called first.
+*/
+/*
+The hints data structure must be initialized once for each path.
+*/
+
+ if (ProcessHints)
+ InitHints(); /* initialize hint data structure */
+
+ while (p != NULL) {
+
+ x = lastx + p->dest.x;
+ y = lasty + p->dest.y;
+
+ nextP = p->link;
+
+/*
+Here we start the hints processing by initializing the hint value to
+zero. If ProcessHints is FALSE, the value will remain zero.
+Otherwise, hint accumulates the computed hint values.
+*/
+
+ hint.x = hint.y = 0;
+
+/*
+If we are processing hints, and this is a MOVE segment (other than
+the first on the path), we need to close (reverse) any open hints.
+*/
+
+ if (ProcessHints)
+ if ((p->type == MOVETYPE) && (p->last == NULL)) {
+ CloseHints(&hint);
+ }
+
+/*
+Next we run through all the hint segments (if any) attached to this
+segment. If ProcessHints is TRUE, we will accumulate computed hint
+values. In either case, nextP will be advanced to the first non-HINT
+segment (or NULL), and each hint segment will be freed if necessary.
+*/
+
+ while ((nextP != NULL) && (nextP->type == HINTTYPE)) {
+ if (ProcessHints)
+ ProcessHint((struct hintsegment *)nextP,
+ x + hint.x, y + hint.y, &hint);
+
+ {
+ register struct segment *saveP = nextP;
+
+ nextP = nextP->link;
+ if (tempflag)
+ Free(saveP);
+ }
+ }
+
+/*
+We now apply the full hint value to the ending point of the path segment.
+*/
+
+ x += hint.x;
+ y += hint.y;
+
+ switch(p->type) {
+
+ case LINETYPE:
+ StepLine(R, lastx, lasty, x, y);
+ break;
+
+ case CONICTYPE:
+ {
+
+/*
+For a conic curve, we apply half the hint value to the conic midpoint.
+*/
+
+ }
+ break;
+
+ case BEZIERTYPE:
+ {
+ register struct beziersegment *bp = (struct beziersegment *) p;
+
+/*
+For a Bezier curve, we apply the full hint value to the Bezier C point.
+*/
+
+ StepBezier(R, lastx, lasty,
+ lastx + bp->B.x, lasty + bp->B.y,
+ lastx + bp->C.x + hint.x,
+ lasty + bp->C.y + hint.y,
+ x, y);
+ }
+ break;
+
+ case MOVETYPE:
+/*
+At this point we have encountered a MOVE segment. This breaks the
+path, making it disjoint.
+*/
+ if (p->last == NULL) /* i.e., not first in path */
+ ChangeDirection(CD_LAST, R, lastx, lasty, (fractpel) 0);
+
+ ChangeDirection(CD_FIRST, R, x, y, (fractpel) 0);
+/*
+We'll just double check for closure here. We forgive an appended
+MOVETYPE at the end of the path, if it isn't closed:
+*/
+ if (!ISCLOSED(p->flag) && p->link != NULL)
+ return((struct region *)ArgErr("Fill: sub-path not closed", p, NULL));
+ break;
+
+ default:
+ Abort("Interior: path type error");
+ }
+/*
+We're done with this segment. Advance to the next path segment in
+the list, freeing this one if necessary:
+*/
+ lastx = x; lasty = y;
+
+ if (tempflag)
+ Free(p);
+ p = nextP;
+ }
+ ChangeDirection(CD_LAST, R, lastx, lasty, (fractpel) 0);
+ R->ending.x = lastx;
+ R->ending.y = lasty;
+/*
+Finally, clean up the region's based on the user's 'fillrule' request:
+*/
+ if (Cflag)
+ ApplyContinuity(R);
+ if (fillrule == WINDINGRULE)
+ Unwind(R->anchor);
+ return(R);
+}
+/*
+:h3."workedge" Array
+
+This is a statically allocated array where edges are built
+before being copied into more permanent storage by NewEdge().
+*/
+
+#ifndef MAXEDGE
+#define MAXEDGE 1000
+#endif
+
+static pel workedge[MAXEDGE];
+static pel *currentworkarea = workedge;
+static pel currentsize = MAXEDGE;
+
+/*
+:h3 id=cd.ChangeDirection() - Called When Y Direction Changes
+
+The rasterizing routines call this entry point when they detect
+a change in Y. We then build the current edge and sort it into
+emerging edgelist at 'anchor' by calling whatever "newedgefcn"
+is appropriate.
+*/
+
+void
+ChangeDirection(int type, /* CD_FIRST, CD_CONTINUE, or CD_LAST */
+ struct region *R, /* region in which we are changing direction */
+ fractpel x, fractpel y, /* current beginning x,y */
+ fractpel dy) /* direction and magnitude of change in y */
+{
+ register fractpel ymin,ymax; /* minimum and maximum Y since last call */
+ register pel iy; /* nearest integer pel to 'y' */
+ register pel idy; /* nearest integer pel to 'dy' */
+ register int ydiff; /* allowed Y difference in 'currentworkarea' */
+
+ if (type != CD_FIRST) {
+
+ if (R->lastdy > 0) {
+ ymin = R->firsty;
+ ymax = y;
+ }
+ else {
+ ymin = y;
+ ymax = R->firsty;
+ }
+
+ if (ymax < ymin)
+ Abort("negative sized edge?");
+
+
+ (*R->newedgefcn)(R, R->edgexmin, R->edgexmax, ymin, ymax,
+ R->lastdy > 0);
+
+ }
+
+ R->firsty = y;
+ R->firstx = x;
+ R->lastdy = dy;
+
+ iy = NEARESTPEL(y);
+ idy = NEARESTPEL(dy);
+ if (currentworkarea != workedge && idy < MAXEDGE && idy > -MAXEDGE) {
+ NonObjectFree(currentworkarea);
+ currentworkarea = workedge;
+ currentsize = MAXEDGE;
+ }
+ ydiff = currentsize - 1;
+ if (dy > 0) {
+ R->edge = &currentworkarea[-iy];
+ R->edgeYstop = TOFRACTPEL(ydiff + iy) + FPHALF;
+ }
+ else {
+ R->edge = &currentworkarea[ydiff - iy];
+ R->edgeYstop = TOFRACTPEL(iy - ydiff) - FPHALF;
+ }
+ R->edgexmax = R->edgexmin = x;
+/*
+If this is the end of a subpath, we complete the subpath circular
+chain:
+*/
+ if (type == CD_LAST && R->lastedge != NULL) {
+ register struct edgelist *e = R->firstedge;
+
+ while (e->subpath != NULL)
+ e = e->subpath;
+ e->subpath = R->lastedge;
+ R->lastedge = R->firstedge = NULL;
+ }
+}
+/*
+:h3 id=newfill.newfilledge() - Called When We Have a New Edge While Filling
+
+This is the prototypical "newedge" function passed to "Rasterize" and
+stored in "newedgefcn" in the region being built.
+
+If the edge is non-null, we sort it onto the list of edges we are
+building at "anchor".
+
+This function also has to keep the bounding box of the region
+up to date.
+*/
+
+static void
+newfilledge(struct region *R, /* region being built */
+ fractpel xmin, fractpel xmax, /* X range of this edge */
+ fractpel ymin, fractpel ymax, /* Y range of this edge */
+ int isdown) /* flag: TRUE means edge goes down, else up */
+{
+
+ register pel pelxmin,pelymin,pelxmax,pelymax; /* pel versions of bounds */
+ register struct edgelist *edge; /* newly created edge */
+
+ pelymin = NEARESTPEL(ymin);
+ pelymax = NEARESTPEL(ymax);
+ if (pelymin == pelymax)
+ return;
+
+ pelxmin = NEARESTPEL(xmin);
+ pelxmax = NEARESTPEL(xmax);
+
+ if (pelxmin < R->xmin) R->xmin = pelxmin;
+ if (pelxmax > R->xmax) R->xmax = pelxmax;
+ if (pelymin < R->ymin) R->ymin = pelymin;
+ if (pelymax > R->ymax) R->ymax = pelymax;
+
+ edge = NewEdge(pelxmin, pelxmax, pelymin, pelymax, &R->edge[pelymin], isdown);
+ edge->subpath = R->lastedge;
+ R->lastedge = edge;
+ if (R->firstedge == NULL)
+ R->firstedge = edge;
+
+ R->anchor = SortSwath(R->anchor, edge, swathxsort);
+
+}
+
+/*
+:h2.Sorting Edges
+
+:h3.SortSwath() - Vertically Sort an Edge into a Region
+
+This routine sorts an edge or a pair of edges into a growing region,
+so that the region maintains its top-to-bottom, left-to-right form.
+The rules for sorting horizontally may vary depending on what you
+are doing, but the rules for vertical sorting are always the same.
+This routine is passed an argument that is a function that will
+perform the horizontal sort on demand (for example, swathxsort() or
+SwathUnion()).
+
+This is a recursive routine. A new edge (or edge pair) may overlap
+the list I am building in strange and wonderful ways. Edges may
+cross. When this happens, my strategy is to split the incoming edge
+(or the growing list) in two at that point, execute the actual sort on
+the top part of the split, and recursively call myself to figure out
+exactly where the bottom part belongs.
+*/
+
+#define TOP(e) ((e)->ymin) /* the top of an edge (for readability */
+#define BOTTOM(e) ((e)->ymax) /* the bottom of an edge (for readability */
+
+struct edgelist *
+SortSwath(struct edgelist *anchor, /* list being built */
+ struct edgelist *edge, /* incoming edge or pair of edges */
+ SwathFunc swathfcn) /* horizontal sorter */
+{
+ register struct edgelist *before,*after;
+ struct edgelist base;
+
+ if (anchor == NULL)
+ return(edge);
+
+ before = &base;
+ before->ymin = before->ymax = MINPEL;
+ before->link = after = anchor;
+
+/*
+If the incoming edge is above the current list, we connect the current
+list to the bottom of the incoming edge. One slight complication is
+if the incoming edge overlaps into the current list. Then, we
+first split the incoming edge in two at the point of overlap and recursively
+call ourselves to sort the bottom of the split into the current list:
+*/
+ if (TOP(edge) < TOP(after)) {
+ if (BOTTOM(edge) > TOP(after)) {
+
+ after = SortSwath(after, splitedge(edge, TOP(after)), swathfcn);
+ }
+ vertjoin(edge, after);
+ return(edge);
+ }
+/*
+At this point the top of edge is not higher than the top of the list,
+which we keep in 'after'. We move the 'after' point down the list,
+until the top of the edge occurs in the swath beginning with 'after'.
+
+If the bottom of 'after' is below the bottom of the edge, we have to
+split the 'after' swath into two parts, at the bottom of the edge.
+If the bottom of 'after' is above the bottom of the swath,
+*/
+
+ while (VALIDEDGE(after)) {
+
+ if (TOP(after) == TOP(edge)) {
+ if (BOTTOM(after) > BOTTOM(edge))
+ vertjoin(after, splitedge(after, BOTTOM(edge)));
+ else if (BOTTOM(after) < BOTTOM(edge)) {
+ after = SortSwath(after,
+ splitedge(edge, BOTTOM(after)), swathfcn);
+ }
+ break;
+ }
+ else if (TOP(after) > TOP(edge)) {
+ if (BOTTOM(edge) > TOP(after)) {
+ after = SortSwath(after,
+ splitedge(edge, TOP(after)), swathfcn);
+ }
+ break;
+ }
+ else if (BOTTOM(after) > TOP(edge))
+ vertjoin(after, splitedge(after, TOP(edge)));
+
+ before = after;
+ after = after->link;
+ }
+
+/*
+At this point 'edge' exactly corresponds in height to the current
+swath pointed to by 'after'.
+*/
+ if (after != NULL && TOP(after) == TOP(edge)) {
+ before = (*swathfcn)(before, edge);
+ after = before->link;
+ }
+/*
+At this point 'after' contains all the edges after 'edge', and 'before'
+contains all the edges before. Whew! A simple matter now of adding
+'edge' to the linked list in its rightful place:
+*/
+ before->link = edge;
+ if (RegionDebug > 1) {
+ while (edge->link != NULL) {
+ edge = edge->link;
+ }
+ }
+ else
+ for (; edge->link != NULL; edge = edge->link) { ; }
+
+ edge->link = after;
+ return(base.link);
+}
+
+/*
+:h3.splitedge() - Split an Edge or Swath in Two at a Given Y Value
+
+This function returns the edge or swath beginning at the Y value, and
+is guaranteed not to change the address of the old swath while splitting
+it.
+*/
+
+static struct edgelist *
+splitedge(struct edgelist *list, /* area to split */
+ pel y) /* Y value to split list at */
+{
+ register struct edgelist *new; /* anchor for newly built list */
+ register struct edgelist *last = NULL; /* end of newly built list */
+ register struct edgelist *r; /* temp pointer to new structure */
+ register struct edgelist *lastlist; /* temp pointer to last 'list' value */
+
+ lastlist = new = NULL;
+
+ while (list != NULL) {
+ if (y < list->ymin)
+ break;
+ if (y >= list->ymax)
+ Abort("splitedge: above top of list");
+ if (y == list->ymin)
+ Abort("splitedge: would be null");
+
+ r = (struct edgelist *)Allocate(sizeof(struct edgelist), list, 0);
+/*
+At this point 'r' points to a copy of the single structure at 'list'.
+We will make 'r' be the new split 'edgelist'--the lower half.
+We don't bother to correct 'xmin' and 'xmax', we'll take the
+the pessimistic answer that results from using the old values.
+*/
+ r->ymin = y;
+ r->xvalues = list->xvalues + (y - list->ymin);
+/*
+Note that we do not need to allocate new memory for the X values,
+they can remain with the old "edgelist" structure. We do have to
+update that old structure so it is not as high:
+*/
+ list->ymax = y;
+/*
+Insert 'r' in the subpath chain:
+*/
+ r->subpath = list->subpath;
+ list->subpath = r;
+/*
+Now attach 'r' to the list we are building at 'new', and advance
+'list' to point to the next element in the old list:
+*/
+ if (new == NULL)
+ new = r;
+ else
+ last->link = r;
+ last = r;
+ lastlist = list;
+ list = list->link;
+ }
+/*
+At this point we have a new list built at 'new'. We break the old
+list at 'lastlist', and add the broken off part to the end of 'new'.
+Then, we return the caller a pointer to 'new':
+*/
+ if (new == NULL)
+ Abort("null splitedge");
+ lastlist->link = NULL;
+ last->link = list;
+ return(new);
+}
+
+/*
+:h3.vertjoin() - Join Two Disjoint Edge Lists Vertically
+
+The two edges must be disjoint vertically.
+*/
+static void vertjoin(top, bottom)
+ register struct edgelist *top; /* uppermost region */
+ register struct edgelist *bottom; /* bottommost region */
+{
+ if (BOTTOM(top) > TOP(bottom))
+ Abort("vertjoin not disjoint");
+
+ for (; top->link != NULL; top=top->link) { ; }
+
+ top->link = bottom;
+ return;
+}
+
+/*
+:h3.swathxsort() - Sorting by X Values
+
+We need to sort 'edge' into its rightful
+place in the swath by X value, taking care that we do not accidentally
+advance to the next swath while searching for the correct X value. Like
+all swath functions, this function returns a pointer to the edge
+BEFORE the given edge in the sort.
+*/
+
+static struct edgelist *
+swathxsort(struct edgelist *before0, /* edge before this swath */
+ struct edgelist *edge) /* input edge */
+{
+ register struct edgelist *before;
+ register struct edgelist *after;
+ register pel y = 0;
+
+ before = before0;
+ after = before->link;
+
+ while (after != NULL && TOP(after) == TOP(edge)) {
+
+ register pel *x1,*x2;
+
+ y = TOP(edge);
+ x1 = after->xvalues;
+ x2 = edge->xvalues;
+
+ while (y < BOTTOM(edge) && *x1 == *x2) {
+ x1++; x2++; y++;
+ }
+ if (y >= BOTTOM(edge)) {
+ edge->flag |= ISAMBIGUOUS(ON);
+ after->flag |= ISAMBIGUOUS(ON);
+ break;
+ }
+
+ if (*x1 >= *x2)
+ break;
+
+ before = after;
+ after = after->link;
+ }
+
+/*
+At this point, 'edge' is between 'before' and 'after'. If 'edge' didn't
+cross either of those other edges, we would be done. We check for
+crossing. If it does cross, we split the problem up by calling SortSwath
+recursively with the part of the edge that is below the crossing point:
+*/
+{
+ register int h0,h; /* height of edge--number of scans */
+
+ h0 = h = BOTTOM(edge) - y;
+ y -= TOP(edge);
+
+ if (h0 <= 0) {
+ return(before);
+ }
+
+ if (TOP(before) == TOP(edge))
+ h -= crosses(h, &before->xvalues[y], &edge->xvalues[y]);
+ if (after != NULL && TOP(after) == TOP(edge))
+ h -= crosses(h, &edge->xvalues[y], &after->xvalues[y]);
+
+ if (h < h0) {
+ SortSwath(before0->link,
+ splitedge(edge, TOP(edge) + y + h),
+ swathxsort);
+
+ }
+}
+
+ return(before);
+}
+/*
+:h3.SwathUnion() - Union Two Edges by X Value
+
+We have a left and right edge that must be unioned into a growing
+swath. If they are totally disjoint, they are just added in. The
+fun comes in they overlap the existing edges. Then some edges
+will disappear.
+*/
+
+struct edgelist *
+SwathUnion(struct edgelist *before0, /* edge before the swath */
+ struct edgelist *edge) /* list of two edges to be unioned */
+{
+ register int h; /* saves height of edge */
+ register struct edgelist *rightedge; /* saves right edge of 'edge' */
+ register struct edgelist *before,*after; /* edge before and after */
+ int h0; /* saves initial height */
+
+ h0 = h = edge->ymax - edge->ymin;
+ if (h <= 0)
+ Abort("SwathUnion: 0 height swath?");
+
+ before = before0;
+ after = before->link;
+
+ while (after != NULL && TOP(after) == TOP(edge)) {
+ register struct edgelist *right;
+
+ right = after->link;
+ if (right->xvalues[0] >= edge->xvalues[0])
+ break;
+ before = right;
+ after = before->link;
+ }
+/*
+This is the picture at this point. 'L' indicates a left hand edge,
+'R' indicates the right hand edge.
+'<--->' indicates the degree of uncertainty as to its placement
+relative to other edges:
+:xmp atomic.
+ before after
+ R <---L----> R L R L R
+ <---L---> <------R-------------------------->
+ edge
+:exmp.
+In case the left of 'edge' touches 'before', we need to reduce
+the height by that amount.
+*/
+ if (TOP(before) == TOP(edge))
+ h -= touches(h, before->xvalues, edge->xvalues);
+
+ rightedge = edge->link;
+
+ if (after == NULL || TOP(after) != TOP(edge) ||
+ after->xvalues[0] > rightedge->xvalues[0]) {
+/*
+On this side of the the above 'if', the new edge is disjoint from the
+existing edges in the swath. This is the picture:
+:xmp atomic.
+ before after
+ R L R L R L R
+ L R
+ edge
+:exmp.
+We will verify it remains disjoint for the entire height. If the
+situation changes somewhere down the edge, we split the edge at that
+point and recursively call ourselves (through 'SortSwath') to figure
+out the new situation:
+*/
+ if (after != NULL && TOP(after) == TOP(edge))
+ h -= touches(h, rightedge->xvalues, after->xvalues);
+ if (h < h0)
+ SortSwath(before0->link, splitedge(edge, edge->ymin + h), t1_SwathUnion);
+ /* go to "return" this edge pair; it is totally disjoint */
+ }
+ else {
+/*
+At this point, at the 'else', we know that the
+new edge overlaps one or more pairs in the existing swath. Here is
+a picture of our knowledge and uncertainties:
+:xmp atomic.
+ before after
+ R L R L R L R
+ <---L---> <---R------------------->
+ edge
+:exmp.
+We need to move 'after' along until it is to the right of the
+right of 'edge'. ('After' should always point to a left edge of a pair:)
+*/
+ register struct edgelist *left; /* variable to keep left edge in */
+
+ do {
+ left = after;
+ after = (after->link)->link;
+
+ } while (after != NULL && TOP(after) == TOP(edge)
+ && after->xvalues[0] <= rightedge->xvalues[0]);
+/*
+At this point this is the picture:
+:xmp atomic.
+ before left after
+ R L R L R L R
+ <---L---> <---R--->
+ edge
+:exmp.
+We need to verify that the situation stays like this all the way
+down the edge. Again, if the
+situation changes somewhere down the edge, we split the edge at that
+point and recursively call ourselves (through 'SortSwath') to figure
+out the new situation:
+*/
+
+ h -= crosses(h, left->xvalues, rightedge->xvalues);
+ h -= crosses(h, edge->xvalues, ((before->link)->link)->xvalues);
+
+ if (after != NULL && TOP(after) == TOP(edge))
+
+ h -= touches(h, rightedge->xvalues, after->xvalues);
+
+/*
+OK, if we touched either of our neighbors we need to split at that point
+and recursively sort the split edge onto the list. One tricky part
+is that when we recursively sort, 'after' will change if it was not
+in our current swath:
+*/
+ if (h < h0) {
+ SortSwath(before0->link,
+ splitedge(edge, edge->ymin + h),
+ t1_SwathUnion);
+
+ if (after == NULL || TOP(after) != TOP(edge))
+ for (after = before0->link;
+ TOP(after) == TOP(edge);
+ after = after->link) { ; }
+ }
+/*
+Now we need to augment 'edge' by the left and right of the overlapped
+swath, and to discard all edges between before and after, because they
+were overlapped and have been combined with the new incoming 'edge':
+*/
+ edge->xmin = MIN(edge->xmin, (before->link)->xmin);
+ edge->xmax = MIN(edge->xmax, (before->link)->xmax);
+ edgemin(h, edge->xvalues, (before->link)->xvalues);
+ rightedge->xmin = MAX(rightedge->xmin, (left->link)->xmin);
+ rightedge->xmax = MAX(rightedge->xmax, (left->link)->xmax);
+ edgemax(h, rightedge->xvalues, (left->link)->xvalues);
+ discard(before, after);
+ }
+ return(before);
+}
+#ifdef notused
+/*
+:h3.swathrightmost() - Simply Sorts New Edge to Rightmost of Swath
+
+Like all swath functions, this function returns a pointer to the edge
+BEFORE the given edge in the sort.
+*/
+
+static struct edgelist *
+swathrightmost(struct edgelist *before, /* edge before this swath */
+ struct edgelist *edge) /* input edge */
+{
+ register struct edgelist *after;
+
+ after = before->link;
+
+ while (after != NULL && TOP(after) == TOP(edge)) {
+ before = after;
+ after = after->link;
+ }
+
+ return(before);
+
+}
+#endif
+/*
+:h3.touches() - Returns the Remaining Height When Two Edges Touch
+
+So, it will return 0 if they never touch. Allows incredibly(?) mnemonic
+if (touches(...)) construct.
+*/
+
+static int
+touches(int h, pel *left, pel *right)
+{
+ for (; h > 0; h--)
+ if (*left++ >= *right++)
+ break;
+ return(h);
+}
+/*
+:h3.crosses() - Returns the Remaining Height When Two Edges Cross
+
+So, it will return 0 if they never cross.
+*/
+
+static int
+crosses(int h, pel *left, pel *right)
+{
+ for (; h > 0; h--)
+ if (*left++ > *right++)
+ break;
+ return(h);
+}
+/*
+:h3.cedgemin() - Stores the Mininum of an Edge and an X Value
+*/
+
+static void
+cedgemin(int h, pel *e1, pel x)
+{
+ for (; --h >= 0; e1++)
+ if (*e1 > x)
+ *e1 = x;
+}
+/*
+:h3.cedgemax() - Stores the Maximum of an Edge and an X Value
+*/
+
+static void
+cedgemax(int h, pel *e1, pel x)
+{
+ for (; --h >= 0; e1++)
+ if (*e1 < x)
+ *e1 = x;
+}
+/*
+:h3.edgemin() - Stores the Mininum of Two Edges in First Edge
+*/
+
+static void
+edgemin(int h, pel *e1, pel *e2)
+{
+ for (; --h >= 0; e1++,e2++)
+ if (*e1 > *e2)
+ *e1 = *e2;
+}
+/*
+:h3.edgemax() - Stores the Maximum of Two Edges in First Edge
+*/
+
+static void
+edgemax(int h, pel *e1, pel *e2)
+{
+ for (; --h >= 0; e1++,e2++)
+ if (*e1 < *e2)
+ *e1 = *e2;
+}
+
+/*
+:h2.Changing the Representation of Regions
+
+For convenience and/or performance, we sometimes like to change the way
+regions are represented. This does not change the object itself, just
+the representation, so these transformations can be made on a permanent
+region.
+
+*/
+
+void
+MoveEdges(struct region *R, /* region to modify */
+ fractpel dx, fractpel dy) /* delta X and Y to move edge list by */
+{
+ register struct edgelist *edge; /* for looping through edges */
+
+ R->origin.x += dx;
+ R->origin.y += dy;
+ R->ending.x += dx;
+ R->ending.y += dy;
+ if (R->thresholded != NULL) {
+ R->thresholded->origin.x -= dx;
+ R->thresholded->origin.y -= dy;
+ }
+/*
+From now on we will deal with dx and dy as integer pel values:
+*/
+ dx = NEARESTPEL(dx);
+ dy = NEARESTPEL(dy);
+ if (dx == 0 && dy == 0)
+ return;
+
+ R->xmin += dx;
+ R->xmax += dx;
+ R->ymin += dy;
+ R->ymax += dy;
+
+ for (edge = R->anchor; VALIDEDGE(edge); edge = edge->link) {
+ edge->ymin += dy;
+ edge->ymax += dy;
+ if (dx != 0) {
+ register int h; /* loop index; height of edge */
+ register pel *Xp; /* loop pointer to X values */
+
+ edge->xmin += dx;
+ edge->xmax += dx;
+ for (Xp = edge->xvalues, h = edge->ymax - edge->ymin;
+ --h >= 0; )
+ *Xp++ += dx;
+ }
+ }
+}
+
+/*
+:h3.UnJumble() - Sort a Region Top to Bottom
+
+It is an open question whether it pays in general to do this.
+*/
+
+void
+UnJumble(struct region *region) /* region to sort */
+{
+ register struct edgelist *anchor; /* new lists built here */
+ register struct edgelist *edge; /* edge pointer for loop */
+ register struct edgelist *next; /* ditto */
+
+ anchor = NULL;
+
+ for (edge=region->anchor; VALIDEDGE(edge); edge=next) {
+ if (edge->link == NULL)
+ Abort("UnJumble: unpaired edge?");
+ next = edge->link->link;
+ edge->link->link = NULL;
+ anchor = SortSwath(anchor, edge, t1_SwathUnion);
+ }
+
+ if (edge != NULL)
+ vertjoin(anchor, edge);
+
+ region->anchor = anchor;
+ region->flag &= ~ISJUMBLED(ON);
+}
+
+/*
+*/
+#ifdef notused
+static void
+OptimizeRegion(struct region *R) /* region to optimize */
+{
+ register pel *xP; /* pel pointer for inner loop */
+ register int x; /* holds X value */
+ register int xmin,xmax; /* holds X range */
+ register int h; /* loop counter */
+ register struct edgelist *e; /* edgelist pointer for loop */
+
+ R->flag |= ISRECTANGULAR(ON);
+
+ for (e = R->anchor; VALIDEDGE(e); e=e->link) {
+ xmin = MAXPEL;
+ xmax = MINPEL;
+ for (h = e->ymax - e->ymin, xP = e->xvalues; --h >= 0;) {
+ x = *xP++;
+ if (x < xmin) xmin = x;
+ if (x > xmax) xmax = x;
+ }
+ if (xmin != xmax || (xmin != R->xmin && xmax != R->xmax))
+ R->flag &= ~ISRECTANGULAR(ON);
+ if (xmin < e->xmin || xmax > e->xmax)
+ Abort("Tighten: existing edge bound was bad");
+ if (xmin < R->xmin || xmax > R->xmax)
+ Abort("Tighten: existing region bound was bad");
+ e->xmin = xmin;
+ e->xmax = xmax;
+ }
+ R->flag |= ISOPTIMIZED(ON);
+}
+#endif
+
+/*
+:h2.Miscelaneous Routines
+
+:h3.MoreWorkArea() - Allocate New Space for "edge"
+
+Our strategy is to temporarily allocate an array to hold this
+unexpectedly large edge. ChangeDirection frees this array any time
+it gets a shorter 'dy'.
+*/
+
+/*ARGSUSED*/
+void
+MoreWorkArea(struct region *R, /* region we are generating */
+ fractpel x1, fractpel y1, /* starting point of line */
+ fractpel x2, fractpel y2) /* ending point of line */
+{
+ register int idy; /* integer dy of line */
+
+ idy = NEARESTPEL(y1) - NEARESTPEL(y2);
+ if (idy < 0) idy = - idy;
+
+ /*
+ * we must add one to the delta for the number of run ends we
+ * need to store:
+ */
+ if (++idy > currentsize) {
+ if (currentworkarea != workedge)
+ NonObjectFree(currentworkarea);
+ currentworkarea = (pel *)Allocate(0, NULL, idy * sizeof(pel));
+ currentsize = idy;
+ }
+ ChangeDirection(CD_CONTINUE, R, x1, y1, y2 - y1);
+}
+
+/*
+:h3.BoxClip() - Clip a Region to a Rectangle
+
+BoxClip also duplicates the region if it is permanent. Note the
+clipping box is specified in REGION coordinates, that is, in
+coordinates relative to the region (0,0) point
+*/
+
+struct region *
+BoxClip(struct region *R, /* region to clip */
+ pel xmin, pel ymin, /* upper left hand corner of rectangle */
+ pel xmax, pel ymax) /* lower right hand corner */
+{
+ struct edgelist anchor; /* pretend edgelist to facilitate discards */
+ register struct edgelist *e,*laste;
+
+ R = UniqueRegion(R);
+
+ if (xmin > R->xmin) {
+ R->xmin = xmin;
+ }
+ if (xmax < R->xmax) {
+ R->xmax = xmax;
+ }
+
+ if (ymin > R->ymin) {
+ R->ymin = ymin;
+ }
+ if (ymax < R->ymax) {
+ R->ymax = ymax;
+ }
+
+
+ laste = &anchor;
+ anchor.link = R->anchor;
+
+ for (e = R->anchor; VALIDEDGE(e); e = e->link) {
+ if (TOP(e) < ymin) {
+ e->xvalues += ymin - e->ymin;
+ e->ymin = ymin;
+ }
+ if (BOTTOM(e) > ymax)
+ e->ymax = ymax;
+ if (TOP(e) >= BOTTOM(e)) {
+ discard(laste, e->link->link);
+ e = laste;
+ continue;
+ }
+ if (e->xmin < xmin) {
+ cedgemax(BOTTOM(e) - TOP(e), e->xvalues, xmin);
+ e->xmin = xmin;
+ e->xmax = MAX(e->xmax, xmin);
+ }
+ if (e->xmax > xmax) {
+ cedgemin(BOTTOM(e) - TOP(e), e->xvalues, xmax);
+ e->xmin = MIN(e->xmin, xmax);
+ e->xmax = xmax;
+ }
+ laste = e;
+ }
+
+ R->anchor = anchor.link;
+
+ return(R);
+}
+
+#ifdef notdef
+/*
+:h3.CoerceRegion() - Force a TextPath Structure to Become a Region
+
+We also save the newly created region in the textpath structure, if the
+structure was permanent. Then we don't have to do this again. Why not
+save it all the time? Well, we certainly could, but I suspect it
+wouldn't pay. We would have to make this region permanent (because we
+couldn't have it be consumed) and this would probably require
+unnecessary CopyRegions in most cases.
+*/
+
+struct region *
+CoerceRegion(struct textpath *tp) /* input TEXTTYPE */
+{
+ struct segment *path; /* temporary character path */
+ struct region *R; /* returned region */
+
+
+ R = Interior(path, EVENODDRULE);
+ return(R);
+}
+#endif
+
+/*
+:h3.RegionBounds() - Returns Bounding Box of a Region
+*/
+
+struct segment *
+RegionBounds(struct region *R)
+{
+ register struct segment *path; /* returned path */
+
+ path = BoxPath(IDENTITY, R->ymax - R->ymin, R->xmax - R->xmin);
+ path = Join(PathSegment(MOVETYPE, R->origin.x + TOFRACTPEL(R->xmin),
+ R->origin.y + TOFRACTPEL(R->ymin) ),
+ path);
+ return(path);
+}
+
+/*
+:h2.Formatting/Dump Routines for Debug
+
+:h3.DumpArea() - Display a Region
+*/
+void
+DumpArea(struct region *area)
+{
+ DumpEdges(area->anchor);
+}
+
+#define INSWATH(p, y0, y1) (p != NULL && p->ymin == y0 && p->ymax == y1)
+/*
+:h3.DumpEdges() - Display Run End Lists (Edge Lists)
+*/
+
+/*
+:h3.edgecheck() - For Debug, Verify that an Edge Obeys the Rules
+*/
+
+/*ARGSUSED*/
+static void
+edgecheck(struct edgelist *edge, int oldmin, int oldmax)
+{
+ if (edge->type != EDGETYPE)
+ Abort("EDGE ERROR: non EDGETYPE in list");
+/*
+The following check is not valid if the region is jumbled so I took it
+out:
+*/
+/* if (edge->ymin < oldmax && edge->ymin != oldmin)
+ Abort("EDGE ERROR: overlapping swaths"); */
+}
+
+void
+DumpEdges(struct edgelist *edges)
+{
+ register struct edgelist *p,*p2;
+ register pel ymin = MINPEL;
+ register pel ymax = MINPEL;
+
+ if (edges == NULL) {
+ return;
+ }
+ if (RegionDebug <= 1) {
+ for (p=edges; p != NULL; p = p->link) {
+ edgecheck(p, ymin, ymax);
+ ymin = p->ymin; ymax = p->ymax;
+ }
+ }
+ else {
+
+ for (p2=edges; p2 != NULL; ) {
+
+ edgecheck(p2, ymin, ymax);
+ ymin = p2->ymin;
+ ymax = p2->ymax;
+
+ while (INSWATH(p2, ymin, ymax))
+ p2 = p2->link;
+ }
+ }
+}
diff --git a/nx-X11/lib/font/Type1/regions.h b/nx-X11/lib/font/Type1/regions.h
new file mode 100644
index 000000000..96ad1a53a
--- /dev/null
+++ b/nx-X11/lib/font/Type1/regions.h
@@ -0,0 +1,250 @@
+/* $Xorg: regions.h,v 1.3 2000/08/17 19:46:32 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/regions.h,v 1.7 2001/01/17 19:43:23 dawes Exp $ */
+/*SHARED*/
+
+#define Interior(p,rule) t1_Interior(p,rule)
+#define Union(a1,a2) t1_Union(a1,a2)
+#define Intersect(a1,a2) t1_Intersect(a1,a2)
+#define Complement(area) t1_Complement(area)
+#define Overlap(a1,a2) t1_OverLap(a1,a2)
+
+
+/* returns the interior of a closed path */
+extern struct region *t1_Interior ( struct segment *p, int fillrule );
+#if 0
+struct region *t1_Union(); /* set union of paths or regions */
+struct region *t1_Intersect(); /* set intersection of regions */
+struct region *t1_Complement(); /* complement of a region */
+int t1_Overlap(); /* returns a Boolean; TRUE if regions overlap */
+#endif
+
+#define TT_INFINITY t1_Infinity
+
+/*END SHARED*/
+/*SHARED*/
+
+#define ChangeDirection(type,R,x,y,dy) t1_ChangeDirection(type,R,x,y,dy)
+
+/* called when we change direction in Y */
+extern void t1_ChangeDirection ( int type, struct region *R, fractpel x,
+ fractpel y, fractpel dy );
+#define CD_FIRST -1 /* enumeration of ChangeDirection type */
+#define CD_CONTINUE 0 /* enumeration of ChangeDirection type */
+#define CD_LAST 1 /* enumeration of ChangeDirection type */
+
+#define MoreWorkArea(R,x1,y1,x2,y2) t1_MoreWorkArea(R,x1,y1,x2,y2)
+#define KillRegion(area) t1_KillRegion(area)
+#define CopyRegion(area) t1_CopyRegion(area)
+#define BoxClip(R,xmin,ymin,xmax,ymax) t1_BoxClip(R,xmin,ymin,xmax,ymax)
+#define SortSwath(a,p,f) t1_SortSwath(a,p,f)
+#define SwathUnion(b,e) t1_SwathUnion(b,e)
+#define RegionBounds(r) t1_RegionBounds(r)
+#define CoerceRegion(p) t1_CoerceRegion(p)
+#define MoveEdges(R,dx,dy) t1_MoveEdges(R,dx,dy)
+#define UnJumble(R) t1_UnJumble(R)
+
+typedef struct edgelist *(*SwathFunc)(struct edgelist *, struct edgelist *);
+
+/* get longer edge list for stepping */
+extern void t1_MoreWorkArea ( struct region *R, fractpel x1, fractpel y1,
+ fractpel x2, fractpel y2 );
+/* duplicate a region */
+extern struct region *t1_CopyRegion ( struct region *area );
+/* destroy a region */
+extern void t1_KillRegion ( struct region *area );
+/* clip a region to a rectangle */
+extern struct region *t1_BoxClip ( struct region *R, pel xmin, pel ymin,
+ pel xmax, pel ymax );
+/* sort edges onto growing edge list */
+extern struct edgelist *t1_SortSwath ( struct edgelist *anchor,
+ struct edgelist *edge,
+ SwathFunc swathfcn );
+/* 'union' two edges into a swath */
+extern struct edgelist *t1_SwathUnion ( struct edgelist *before0,
+ struct edgelist *edge );
+/* returns bounding box of a region */
+extern struct segment *t1_RegionBounds ( struct region *R );
+#ifdef notdef
+/* force text to become a true region */
+struct region *t1_CoerceRegion(struct textpath *tp);
+#endif
+/* moves the edge values in a region */
+extern void t1_MoveEdges ( struct region *R, fractpel dx, fractpel dy );
+/* sort the edges and reset the jumbled flag */
+extern void t1_UnJumble ( struct region *region );
+
+
+/*END SHARED*/
+/*SHARED*/
+
+#define GOING_TO(R, x1, y1, x2, y2, dy) { \
+ if (dy < 0) { \
+ if (R->lastdy >= 0) \
+ ChangeDirection(CD_CONTINUE, R, x1, y1, dy); \
+ if (y2 < R->edgeYstop) \
+ MoreWorkArea(R, x1, y1, x2, y2); \
+ } \
+ else if (dy > 0) { \
+ if (R->lastdy <= 0) \
+ ChangeDirection(CD_CONTINUE, R, x1, y1, dy); \
+ if (y2 > R->edgeYstop) \
+ MoreWorkArea(R, x1, y1, x2, y2); \
+ } \
+ else /* dy == 0 */ ChangeDirection(CD_CONTINUE, R, x1, y1, dy); \
+ if (x2 < R->edgexmin) R->edgexmin = x2; \
+ else if (x2 > R->edgexmax) R->edgexmax = x2; \
+}
+
+#ifndef FONTMODULE
+#ifndef __sxg__
+#include <limits.h>
+#endif
+#endif
+#ifdef SHRT_MIN
+#define MINPEL SHRT_MIN
+#else
+#define MINPEL ((pel)(-1<<(8*sizeof(pel)-1))) /* smallest value fitting in a pel */
+#endif
+#ifdef SHRT_MAX
+#define MAXPEL SHRT_MAX
+#else
+#define MAXPEL ((pel)((1<<(8*sizeof(pel)-1))-1))/* largest value fitting in a pel */
+#endif
+
+/*
+The "Unique"-type macro is different (unique?) for regions, because some
+regions structures are shared among several objects, and might have
+to be made unique for that reason (i.e., references > 1).
+*/
+
+#define ConsumeRegion(R) MAKECONSUME(R,KillRegion(R))
+#define UniqueRegion(R) MAKEUNIQUE(R,CopyRegion(R))
+
+
+/*END SHARED*/
+/*SHARED*/
+
+typedef void (*NewEdgeFunc)(struct region *,
+ fractpel, fractpel, fractpel, fractpel, int);
+
+struct region {
+ XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
+ /* type = REGIONTYPE */
+ struct fractpoint origin; /* beginning handle: X,Y origin of region */
+ struct fractpoint ending; /* ending handle: X,Y change after painting region */
+ pel xmin,ymin; /* minimum X,Y of region */
+ pel xmax,ymax; /* mat1_mum X,Y of region */
+ struct edgelist *anchor; /* list of edges that bound the region */
+ struct picture *thresholded; /* region defined by thresholded picture*/
+/*
+Note that the ending handle and the bounding box values are stored
+relative to 'origin'.
+
+The above elements describe a region. The following elements are
+scratchpad areas used while the region is being built:
+*/
+ fractpel lastdy; /* direction of last segment */
+ fractpel firstx,firsty; /* starting point of current edge */
+ fractpel edgexmin,edgexmax; /* x extent of current edge */
+ struct edgelist *lastedge,*firstedge; /* last and first edges in subpath */
+ pel *edge; /* pointer to array of X values for edge */
+ fractpel edgeYstop; /* Y value where 'edges' array ends */
+ NewEdgeFunc newedgefcn; /* function to use when building a new edge */
+ struct strokeinfo *strokeinfo; /* scratchpad info during stroking only */
+} ;
+/*
+The ISCOMPLEMENT flag indicates the region is reversed--it is the
+"outside" of the nominal region.
+*/
+#define ISCOMPLEMENT(flag) ((flag)&0x80)
+/*
+The ISJUMBLED flag indicates the region is not sorted top-to-bottom.
+*/
+#define ISJUMBLED(flag) ((flag)&0x40)
+/*
+The ISINFINITE flag allows a quick check for an INFINITE region, which
+is frequently intersected.
+*/
+#define ISINFINITE(flag) ((flag)&0x20)
+
+/*END SHARED*/
+/*SHARED*/
+
+#define ISRECTANGULAR(flag) ((flag)&0x08)
+
+/*END SHARED*/
+/*SHARED*/
+
+#define EmptyRegion t1_EmptyRegion
+
+/*END SHARED*/
+/*SHARED*/
+
+struct edgelist {
+ XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
+ /* type = EDGETYPE */
+ struct edgelist *link; /* pointer to next in linked list */
+ struct edgelist *subpath; /* informational link for "same subpath" */
+ pel xmin,xmax; /* range of edge in X */
+ pel ymin,ymax; /* range of edge in Y */
+ pel *xvalues; /* pointer to ymax-ymin X values */
+} ;
+/*
+The end of the list is marked by either "link" being NULL, or by
+ymin == ymax. See :hdref refid=discard.. We define the VALIDEDGE
+predicate to test for the opposite of these conditions:
+*/
+
+#define VALIDEDGE(p) ((p)!=NULL&&(p)->ymin<(p)->ymax)
+
+/*END SHARED*/
+/*SHARED*/
+
+#define ISDOWN(f) ((f)&0x80)
+
+#define ISAMBIGUOUS(f) ((f)&0x40)
+
+/*END SHARED*/
+/*SHARED*/
+
+/*
+Interior() rule enumerations:
+*/
+#define WINDINGRULE -2
+#define EVENODDRULE -3
+
+#define CONTINUITY 0x80 /* can be added to above rules; e.g. WINDINGRULE+CONTINUITY */
+
+/*END SHARED*/
+
+/* dump a region structure */
+extern void t1_DumpArea ( struct region *area );
+/* dump a region's edge list */
+extern void t1_DumpEdges ( struct edgelist *edges );
diff --git a/nx-X11/lib/font/Type1/scanfont.c b/nx-X11/lib/font/Type1/scanfont.c
new file mode 100644
index 000000000..8db497959
--- /dev/null
+++ b/nx-X11/lib/font/Type1/scanfont.c
@@ -0,0 +1,2370 @@
+/* $XdotOrg: xc/lib/font/Type1/scanfont.c,v 1.5 2005/07/09 23:30:06 keithp Exp $ */
+/* $Xorg: scanfont.c,v 1.3 2000/08/17 19:46:32 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* Author: Katherine A. Hitchcock IBM Almaden Research Laboratory */
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/scanfont.c,v 1.16 2003/05/27 22:26:46 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#ifndef FONTMODULE
+#include <string.h>
+#include <limits.h>
+#else
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "xf86_ansic.h"
+#endif
+#include "t1stdio.h"
+#include "util.h"
+#include "token.h"
+#if XFONT_CID
+#include "range.h"
+#endif
+#include "objects.h"
+#include "spaces.h"
+#include "fontfcn.h"
+#include "blues.h"
+
+#if XFONT_CID
+#define CID_BUFSIZE 80
+
+extern psfont *FDArrayP;
+static spacerange *spacerangeP;
+static cidrange *notdefrangeP;
+static cidrange *cidrangeP;
+extern int FDArrayIndex;
+static boolean CIDWantFontInfo;
+static psobj inputFile1;
+#endif
+
+static int rc;
+static boolean InPrivateDict;
+static boolean WantFontInfo;
+static boolean TwoSubrs;
+static psobj inputFile;
+static psobj filterFile;
+static psobj *inputP;
+
+
+/**********************************************************************/
+/* Init_BuiltInEncoding() */
+/* */
+/* Initializes the StandardEncoding and ISOLatin1Encoding vector. */
+/* */
+/**********************************************************************/
+typedef struct /* Builtin Standard Encoding */
+{
+ int index;
+ char *name;
+} EncodingTable;
+
+static EncodingTable StdEnc[] = {
+ { 040 , "space" },
+ { 041 , "exclam" },
+ { 042 , "quotedbl" },
+ { 043 , "numbersign" },
+ { 044 , "dollar" },
+ { 045 , "percent" },
+ { 046 , "ampersand" },
+ { 047 , "quoteright" },
+ { 050 , "parenleft" },
+ { 051 , "parenright" },
+ { 052 , "asterisk" },
+ { 053 , "plus" },
+ { 054 , "comma" },
+ { 055 , "hyphen" },
+ { 056 , "period" },
+ { 057 , "slash" },
+ { 060 , "zero" },
+ { 061 , "one" },
+ { 062 , "two" },
+ { 063 , "three" },
+ { 064 , "four" },
+ { 065 , "five" },
+ { 066 , "six" },
+ { 067 , "seven" },
+ { 070 , "eight" },
+ { 071 , "nine" },
+ { 072 , "colon" },
+ { 073 , "semicolon" },
+ { 074 , "less" },
+ { 075 , "equal" },
+ { 076 , "greater" },
+ { 077 , "question" },
+ { 0100 , "at" },
+ { 0101 , "A" },
+ { 0102 , "B" },
+ { 0103 , "C" },
+ { 0104 , "D" },
+ { 0105 , "E" },
+ { 0106 , "F" },
+ { 0107 , "G" },
+ { 0110 , "H" },
+ { 0111 , "I" },
+ { 0112 , "J" },
+ { 0113 , "K" },
+ { 0114 , "L" },
+ { 0115 , "M" },
+ { 0116 , "N" },
+ { 0117 , "O" },
+ { 0120 , "P" },
+ { 0121 , "Q" },
+ { 0122 , "R" },
+ { 0123 , "S" },
+ { 0124 , "T" },
+ { 0125 , "U" },
+ { 0126 , "V" },
+ { 0127 , "W" },
+ { 0130 , "X" },
+ { 0131 , "Y" },
+ { 0132 , "Z" },
+ { 0133 , "bracketleft" },
+ { 0134 , "backslash" },
+ { 0135 , "bracketright" },
+ { 0136 , "asciicircum" },
+ { 0137 , "underscore" },
+ { 0140 , "quoteleft" },
+ { 0141 , "a" },
+ { 0142 , "b" },
+ { 0143 , "c" },
+ { 0144 , "d" },
+ { 0145 , "e" },
+ { 0146 , "f" },
+ { 0147 , "g" },
+ { 0150 , "h" },
+ { 0151 , "i" },
+ { 0152 , "j" },
+ { 0153 , "k" },
+ { 0154 , "l" },
+ { 0155 , "m" },
+ { 0156 , "n" },
+ { 0157 , "o" },
+ { 0160 , "p" },
+ { 0161 , "q" },
+ { 0162 , "r" },
+ { 0163 , "s" },
+ { 0164 , "t" },
+ { 0165 , "u" },
+ { 0166 , "v" },
+ { 0167 , "w" },
+ { 0170 , "x" },
+ { 0171 , "y" },
+ { 0172 , "z" },
+ { 0173 , "braceleft" },
+ { 0174 , "bar" },
+ { 0175 , "braceright" },
+ { 0176 , "asciitilde" },
+ { 0241 , "exclamdown" },
+ { 0242 , "cent" },
+ { 0243 , "sterling" },
+ { 0244 , "fraction" },
+ { 0245 , "yen" },
+ { 0246 , "florin" },
+ { 0247 , "section" },
+ { 0250 , "currency" },
+ { 0251 , "quotesingle" },
+ { 0252 , "quotedblleft" },
+ { 0253 , "guillemotleft" },
+ { 0254 , "guilsinglleft" },
+ { 0255 , "guilsinglright" },
+ { 0256 , "fi" },
+ { 0257 , "fl" },
+ { 0261 , "endash" },
+ { 0262 , "dagger" },
+ { 0263 , "daggerdbl" },
+ { 0264 , "periodcentered" },
+ { 0266 , "paragraph" },
+ { 0267 , "bullet" },
+ { 0270 , "quotesinglbase" },
+ { 0271 , "quotedblbase" },
+ { 0272 , "quotedblright" },
+ { 0273 , "guillemotright" },
+ { 0274 , "ellipsis" },
+ { 0275 , "perthousand" },
+ { 0277 , "questiondown" },
+ { 0301 , "grave" },
+ { 0302 , "acute" },
+ { 0303 , "circumflex" },
+ { 0304 , "tilde" },
+ { 0305 , "macron" },
+ { 0306 , "breve" },
+ { 0307 , "dotaccent" },
+ { 0310 , "dieresis" },
+ { 0312 , "ring" },
+ { 0313 , "cedilla" },
+ { 0315 , "hungarumlaut" },
+ { 0316 , "ogonek" },
+ { 0317 , "caron" },
+ { 0320 , "emdash" },
+ { 0341 , "AE" },
+ { 0343 , "ordfeminine" },
+ { 0350 , "Lslash" },
+ { 0351 , "Oslash" },
+ { 0352 , "OE" },
+ { 0353 , "ordmasculine" },
+ { 0361 , "ae" },
+ { 0365 , "dotlessi" },
+ { 0370 , "lslash" },
+ { 0371 , "oslash" },
+ { 0372 , "oe" },
+ { 0373 , "germandbls" },
+ { 0, 0 }
+};
+
+static EncodingTable ISO8859Enc[] = {
+ { 32, "space" },
+ { 33, "exclam" },
+ { 34, "quotedbl" },
+ { 35, "numbersign" },
+ { 36, "dollar" },
+ { 37, "percent" },
+ { 38, "ampersand" },
+ { 39, "quoteright" },
+ { 40, "parenleft" },
+ { 41, "parenright" },
+ { 42, "asterisk" },
+ { 43, "plus" },
+ { 44, "comma" },
+ { 45, "minus" },
+ { 46, "period" },
+ { 47, "slash" },
+ { 48, "zero" },
+ { 49, "one" },
+ { 50, "two" },
+ { 51, "three" },
+ { 52, "four" },
+ { 53, "five" },
+ { 54, "six" },
+ { 55, "seven" },
+ { 56, "eight" },
+ { 57, "nine" },
+ { 58, "colon" },
+ { 59, "semicolon" },
+ { 60, "less" },
+ { 61, "equal" },
+ { 62, "greater" },
+ { 63, "question" },
+ { 64, "at" },
+ { 65, "A" },
+ { 66, "B" },
+ { 67, "C" },
+ { 68, "D" },
+ { 69, "E" },
+ { 70, "F" },
+ { 71, "G" },
+ { 72, "H" },
+ { 73, "I" },
+ { 74, "J" },
+ { 75, "K" },
+ { 76, "L" },
+ { 77, "M" },
+ { 78, "N" },
+ { 79, "O" },
+ { 80, "P" },
+ { 81, "Q" },
+ { 82, "R" },
+ { 83, "S" },
+ { 84, "T" },
+ { 85, "U" },
+ { 86, "V" },
+ { 87, "W" },
+ { 88, "X" },
+ { 89, "Y" },
+ { 90, "Z" },
+ { 91, "bracketleft" },
+ { 92, "backslash" },
+ { 93, "bracketright" },
+ { 94, "asciicircum" },
+ { 95, "underscore" },
+ { 96, "quoteleft" },
+ { 97, "a" },
+ { 98, "b" },
+ { 99, "c" },
+ { 100, "d" },
+ { 101, "e" },
+ { 102, "f" },
+ { 103, "g" },
+ { 104, "h" },
+ { 105, "i" },
+ { 106, "j" },
+ { 107, "k" },
+ { 108, "l" },
+ { 109, "m" },
+ { 110, "n" },
+ { 111, "o" },
+ { 112, "p" },
+ { 113, "q" },
+ { 114, "r" },
+ { 115, "s" },
+ { 116, "t" },
+ { 117, "u" },
+ { 118, "v" },
+ { 119, "w" },
+ { 120, "x" },
+ { 121, "y" },
+ { 122, "z" },
+ { 123, "braceleft" },
+ { 124, "bar" },
+ { 125, "braceright" },
+ { 126, "asciitilde" },
+ { 160, "space" },
+ { 161, "exclamdown" },
+ { 162, "cent" },
+ { 163, "sterling" },
+ { 164, "currency" },
+ { 165, "yen" },
+ { 166, "brokenbar" },
+ { 167, "section" },
+ { 168, "dieresis" },
+ { 169, "copyright" },
+ { 170, "ordfeminine" },
+ { 171, "guillemotleft" },
+ { 172, "logicalnot" },
+ { 173, "hyphen" },
+ { 174, "registered" },
+ { 175, "macron" },
+ { 176, "degree" },
+ { 177, "plusminus" },
+ { 178, "twosuperior" },
+ { 179, "threesuperior" },
+ { 180, "acute" },
+ { 181, "mu" },
+ { 182, "paragraph" },
+ { 183, "periodcentered" },
+ { 184, "cedilla" },
+ { 185, "onesuperior" },
+ { 186, "ordmasculine" },
+ { 187, "guillemotright" },
+ { 188, "onequarter" },
+ { 189, "onehalf" },
+ { 190, "threequarters" },
+ { 191, "questiondown" },
+ { 192, "Agrave" },
+ { 193, "Aacute" },
+ { 194, "Acircumflex" },
+ { 195, "Atilde" },
+ { 196, "Adieresis" },
+ { 197, "Aring" },
+ { 198, "AE" },
+ { 199, "Ccedilla" },
+ { 200, "Egrave" },
+ { 201, "Eacute" },
+ { 202, "Ecircumflex" },
+ { 203, "Edieresis" },
+ { 204, "Igrave" },
+ { 205, "Iacute" },
+ { 206, "Icircumflex" },
+ { 207, "Idieresis" },
+ { 208, "Eth" },
+ { 209, "Ntilde" },
+ { 210, "Ograve" },
+ { 211, "Oacute" },
+ { 212, "Ocircumflex" },
+ { 213, "Otilde" },
+ { 214, "Odieresis" },
+ { 215, "multiply" },
+ { 216, "Oslash" },
+ { 217, "Ugrave" },
+ { 218, "Uacute" },
+ { 219, "Ucircumflex" },
+ { 220, "Udieresis" },
+ { 221, "Yacute" },
+ { 222, "Thorn" },
+ { 223, "germandbls" },
+ { 224, "agrave" },
+ { 225, "aacute" },
+ { 226, "acircumflex" },
+ { 227, "atilde" },
+ { 228, "adieresis" },
+ { 229, "aring" },
+ { 230, "ae" },
+ { 231, "ccedilla" },
+ { 232, "egrave" },
+ { 233, "eacute" },
+ { 234, "ecircumflex" },
+ { 235, "edieresis" },
+ { 236, "igrave" },
+ { 237, "iacute" },
+ { 238, "icircumflex" },
+ { 239, "idieresis" },
+ { 240, "eth" },
+ { 241, "ntilde" },
+ { 242, "ograve" },
+ { 243, "oacute" },
+ { 244, "ocircumflex" },
+ { 245, "otilde" },
+ { 246, "odieresis" },
+ { 247, "divide" },
+ { 248, "oslash" },
+ { 249, "ugrave" },
+ { 250, "uacute" },
+ { 251, "ucircumflex" },
+ { 252, "udieresis" },
+ { 253, "yacute" },
+ { 254, "thorn" },
+ { 255, "ydieresis" },
+ { 0, 0 }
+};
+
+static psobj *StdEncArrayP = NULL;
+psobj *ISOLatin1EncArrayP = NULL;
+
+static psobj *
+MakeEncodingArrayP(EncodingTable *encodingTable)
+{
+ int i;
+ psobj *encodingArrayP;
+
+ encodingArrayP = (psobj *)vm_alloc(256*(sizeof(psobj)));
+ if (!encodingArrayP)
+ return NULL;
+
+ /* initialize everything to .notdef */
+ for (i=0; i<256;i++)
+ objFormatName(&(encodingArrayP[i]),7, ".notdef");
+
+ for (i=0; encodingTable[i].name; i++)
+ {
+ objFormatName(&(encodingArrayP[encodingTable[i].index]),
+ strlen(encodingTable[i].name),
+ encodingTable[i].name);
+ }
+
+ return(encodingArrayP);
+}
+
+boolean
+Init_BuiltInEncoding(void)
+{
+ StdEncArrayP = MakeEncodingArrayP(StdEnc);
+ ISOLatin1EncArrayP = MakeEncodingArrayP(ISO8859Enc);
+ return (StdEncArrayP && ISOLatin1EncArrayP);
+}
+
+/********************************************************************/
+/***================================================================***/
+static int
+getNextValue(int valueType)
+{
+ scan_token(inputP);
+ if (tokenType != valueType) {
+ return(SCAN_ERROR);
+ }
+ return(SCAN_OK);
+
+}
+/***================================================================***/
+/* This routine will set the global rc if there is an error */
+/***================================================================***/
+static int
+getInt(void)
+{
+ scan_token(inputP);
+ if (tokenType != TOKEN_INTEGER) {
+ rc = SCAN_ERROR;
+ return(0);
+ }
+ else {
+ return( tokenValue.integer);
+ }
+
+}
+/***================================================================***/
+/*
+ * See Sec 10.3 of ``Adobe Type 1 Font Format'' v1.1,
+ * for parsing Encoding.
+ */
+static int
+getEncoding(psobj *arrayP)
+{
+ scan_token(inputP);
+ if ((tokenType == TOKEN_NAME && (tokenLength==16 || tokenLength==17)))
+ {
+ if((tokenLength==16) && (!strncmp(tokenStartP,"StandardEncoding",16)))
+ arrayP->data.valueP = (char *) StdEncArrayP;
+ else
+ arrayP->data.valueP = (char *) ISOLatin1EncArrayP;
+ arrayP->len = 256;
+ return(SCAN_OK);
+ }
+ else if ( (tokenType == TOKEN_LEFT_BRACE) ||
+ (tokenType == TOKEN_LEFT_BRACKET) )
+ {
+ /* Array of literal names */
+
+ psobj *objP;
+ int i;
+
+ objP = (psobj *)vm_alloc(256*(sizeof(psobj)));
+ if (!(objP)) return(SCAN_OUT_OF_MEMORY);
+
+ arrayP->data.valueP = (char *) objP;
+ arrayP->len = 256;
+
+ for (i=0; i<256; i++, objP++)
+ {
+ scan_token(inputP);
+
+ if (tokenType != TOKEN_LITERAL_NAME)
+ return(SCAN_ERROR);
+
+ if (!(vm_alloc(tokenLength)) ) return(SCAN_OUT_OF_MEMORY);
+ objFormatName(objP,tokenLength,tokenStartP);
+ }
+
+ scan_token(inputP);
+ if ( (tokenType == TOKEN_RIGHT_BRACE) ||
+ (tokenType == TOKEN_RIGHT_BRACKET) )
+ return(SCAN_OK);
+ }
+ else
+ {
+ /* Must be sequences of ``dup <index> <charactername> put" */
+
+ psobj *objP;
+ int i;
+
+ objP = (psobj *)vm_alloc(256*(sizeof(psobj)));
+ if (!(objP)) return(SCAN_OUT_OF_MEMORY);
+
+ arrayP->data.valueP = (char *) objP;
+ arrayP->len = 256;
+
+ for (i=0; i<256; i++)
+ objFormatName(objP + i, 7, ".notdef");
+
+ while (TRUE)
+ {
+ scan_token(inputP);
+
+ switch (tokenType)
+ {
+ case TOKEN_NAME:
+ if (tokenLength == 3)
+ {
+ if (strncmp(tokenStartP,"dup",3) == 0)
+ {
+ /* get <index> */
+ scan_token(inputP);
+ if (tokenType != TOKEN_INTEGER ||
+ tokenValue.integer < 0 ||
+ tokenValue.integer > 255)
+ return (SCAN_ERROR);
+ i = tokenValue.integer;
+
+ /* get <characer_name> */
+ scan_token(inputP);
+ if (tokenType != TOKEN_LITERAL_NAME)
+ return(SCAN_ERROR);
+
+ if (!(vm_alloc(tokenLength)) )
+ return(SCAN_OUT_OF_MEMORY);
+ objFormatName(objP + i,tokenLength,tokenStartP);
+
+ /* get "put" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME)
+ return(SCAN_ERROR);
+ }
+ else if (strncmp(tokenStartP,"def",3) == 0)
+ return (SCAN_OK);
+ }
+ break;
+ case TOKEN_EOF:
+ case TOKEN_NONE:
+ case TOKEN_INVALID:
+ return (SCAN_ERROR);
+ }
+ }
+ }
+
+ return (SCAN_ERROR);
+}
+/***================================================================***/
+#if XFONT_CID
+static int
+getFDArray(psobj *arrayP)
+{
+ int rc;
+
+ /* get the number of items in the FDArray */
+ scan_token(inputP);
+ if (tokenType == TOKEN_INTEGER) {
+ /* an FD array must contain at least one element */
+ if (tokenValue.integer <= 0)
+ return(SCAN_ERROR);
+ arrayP->len = tokenValue.integer;
+ } else
+ return(SCAN_ERROR);
+
+ /* get the token "array" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || strncmp(tokenStartP, "array", 5) != 0)
+ return(SCAN_ERROR);
+
+ /* format the array in memory, save pointer to the beginning */
+ arrayP->data.valueP = tokenStartP;
+
+ /* allocate FDArray */
+ /* No integer overflow since arrayP->len is unsigned short */
+ FDArrayP = (psfont *)vm_alloc(arrayP->len*(sizeof(psfont)));
+ if (!(FDArrayP)) return(SCAN_OUT_OF_MEMORY);
+
+ /* get a specified number of font dictionaries */
+ for (FDArrayIndex = 0; FDArrayIndex < arrayP->len; FDArrayIndex++) {
+ /* get "dup" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || strncmp(tokenStartP, "dup", 3) != 0)
+ return(SCAN_ERROR);
+ /* get an integer digit */
+ scan_token(inputP);
+ if (tokenType != TOKEN_INTEGER)
+ return(SCAN_ERROR);
+
+ /* read a CID version of a Type 1 font */
+ if (!CIDType1fontfcnA(&rc))
+ return(rc);
+
+ /* get "put" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || strncmp(tokenStartP, "put", 3) != 0)
+ return(SCAN_ERROR);
+ }
+ return(SCAN_OK);
+}
+#endif
+
+static int
+getArray(psobj *arrayP)
+{
+ int N; /* count the items in the array */
+ psobj *objP;
+
+ /* That is totally a kludge. If some stupid font file has
+ * /foo/foo # ftp://ftp.cdrom.com/pub/os2/fonts/future.zip
+ * we will treat it as /foo.
+ * H.J. */
+ char tmp [1024];
+
+ strncpy (tmp, tokenStartP, sizeof (tmp));
+ tmp [sizeof (tmp) - 1] = '\0';
+
+restart:
+ scan_token(inputP);
+ switch (tokenType)
+ {
+ case TOKEN_LEFT_BRACE:
+ case TOKEN_LEFT_BRACKET:
+ break;
+
+ case TOKEN_LITERAL_NAME:
+ tokenStartP[tokenLength] = '\0';
+ if (strcmp (tokenStartP, tmp) == 0)
+ {
+ /* Ok, We see /foo/foo. Let's restart. */
+ goto restart;
+ }
+
+ default:
+ return(SCAN_ERROR);
+ }
+ /* format the array in memory, save pointer to the beginning */
+ arrayP->data.valueP = tokenStartP;
+ /* loop, picking up next object, until right BRACE or BRACKET */
+ N = 0;
+ do {
+ scan_token(inputP);
+ if ( (tokenType == TOKEN_RIGHT_BRACE) ||
+ (tokenType == TOKEN_RIGHT_BRACKET) ) {
+ /* save then number of items in the array */
+ arrayP->len = N;
+ return(SCAN_OK);
+ }
+ /* allocate the space for the object */
+ objP = (psobj *)vm_alloc(sizeof(psobj));
+ if (!(objP)) return(SCAN_OUT_OF_MEMORY);
+
+ /* array is an array of numbers, (real or integer) */
+ if (tokenType == TOKEN_REAL) {
+ objFormatReal(objP, tokenValue.real);
+ }
+ else
+ if (tokenType == TOKEN_INTEGER) {
+ objFormatInteger(objP, tokenValue.integer);
+ }
+ else return(SCAN_ERROR);
+ N++;
+ } while ( 1>0 );
+ /* NOTREACHED*/
+}
+/***================================================================***/
+static int
+getName(char *nameP)
+{
+ do {
+ scan_token(inputP);
+ if (tokenType <= TOKEN_NONE) {
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ return(SCAN_ERROR);
+ }
+ } while ((tokenType != TOKEN_NAME) ||
+ (0 != strncmp(tokenStartP,nameP,strlen(nameP))) );
+ /* found */
+ return(SCAN_OK);
+}
+/***================================================================***/
+static int
+getNbytes(int N)
+{
+ int I;
+
+
+ tokenStartP = vm_next_byte();
+ tokenMaxP = tokenStartP + MIN(vm_free_bytes(), MAX_STRING_LEN);
+ if (N > vm_free_bytes()) {
+ return(SCAN_OUT_OF_MEMORY);
+ }
+ I = T1Read(tokenStartP,1,N,inputP->data.fileP);
+ if ( I != N ) return(SCAN_FILE_EOF);
+ return(SCAN_OK);
+}
+
+/***================================================================***/
+/* getLiteralName(nameObjP) */
+/* scan for next literal. */
+/* if we encounter the name 'end' then terminate and say ok. */
+/* It means that the CharStrings does not have as many characters */
+/* as the dictionary said it would and that is ok. */
+/***================================================================***/
+static int
+getLiteralName(psobj *nameObjP)
+{
+ do {
+ scan_token(inputP);
+ if (tokenType <= TOKEN_NONE) {
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ return(SCAN_ERROR);
+ }
+ if (tokenType == TOKEN_NAME) {
+ if (0 == strncmp(tokenStartP,"end",3) ) {
+ return(SCAN_END);
+ }
+ }
+ } while (tokenType != TOKEN_LITERAL_NAME) ;
+ nameObjP->len = tokenLength;
+ /* allocate all the names in the CharStrings Structure */
+ if (!(vm_alloc(tokenLength)) ) return(SCAN_OUT_OF_MEMORY);
+ nameObjP->data.valueP = tokenStartP;
+ /* found */
+ return(SCAN_OK);
+}
+
+/***================================================================***/
+/*
+ * BuildSubrs routine
+ */
+/***================================================================***/
+
+static int
+BuildSubrs(psfont *FontP)
+{
+ int N; /* number of values in Subrs */
+ int I; /* index into Subrs */
+ int i; /* loop thru Subrs */
+ int J; /* length of Subrs entry */
+ psobj *arrayP;
+
+ /* next token should be a positive int */
+ /* note: rc is set by getInt. */
+ N = getInt();
+ if (rc) return(rc);
+ if (N < 0 ) return(SCAN_ERROR);
+ /* if we already have a Subrs, then skip the second one */
+ /* The second one is for hiresolution devices. */
+ if (FontP->Subrs.data.arrayP != NULL) {
+ TwoSubrs = TRUE;
+ /* process all the Subrs, but do not update anything */
+ /* can not just skip them because of the binary data */
+ for (i=0;i<N;i++) {
+ /* look for dup */
+ rc = getName("dup");
+ if (rc) return(rc);
+ /* get 2 integers */
+ I = getInt();
+ if (rc) return(rc);
+ J = getInt();
+ if (rc) return(rc);
+ if ( (I < 0) || (J < 0 ) ) return (SCAN_ERROR);
+ /* get the next token, it should be RD or -|, either is ok */
+ rc = getNextValue(TOKEN_NAME);
+ if ( rc != SCAN_OK ) return(rc);
+ rc = getNbytes(J);
+ if (rc) return(rc);
+ }
+ return(SCAN_OK);
+ }
+ if (N > INT_MAX / sizeof(psobj))
+ return (SCAN_ERROR);
+ arrayP = (psobj *)vm_alloc(N*sizeof(psobj));
+ if (!(arrayP) ) return(SCAN_OUT_OF_MEMORY);
+ FontP->Subrs.len = N;
+ FontP->Subrs.data.arrayP = arrayP;
+ /* get N values for Subrs */
+ for (i=0;i<N;i++) {
+ /* look for dup */
+ rc = getName("dup");
+ if (rc) return(rc);
+ /* get 2 integers */
+ I = getInt();
+ if (rc) return(rc);
+ J = getInt();
+ if (rc) return(rc);
+ if ( (I < 0) || (J < 0 ) ) return (SCAN_ERROR);
+ arrayP[I].len = J;
+ /* get the next token, it should be RD or -|, either is ok */
+ rc = getNextValue(TOKEN_NAME);
+ if ( rc != SCAN_OK ) return(rc);
+ rc = getNbytes(J);
+ if (rc == SCAN_OK) {
+ arrayP[I].data.valueP = tokenStartP;
+ if ( !(vm_alloc(J)) ) return(SCAN_OUT_OF_MEMORY);
+ }
+ else return(rc);
+ }
+ return(SCAN_OK);
+
+}
+/***================================================================***/
+/***================================================================***/
+/*
+ * BuildCharStrings routine
+ */
+/***================================================================***/
+
+static int
+BuildCharStrings(psfont *FontP)
+{
+ int N; /* number of values in CharStrings */
+ int i; /* loop thru Subrs */
+ int J; /* length of Subrs entry */
+ psdict *dictP;
+
+ /* next token should be a positive int */
+ N = getInt();
+ if (rc) {
+ /* check if file had TwoSubrs, hi resolution stuff is in file*/
+ if (TwoSubrs) {
+ do {
+ scan_token(inputP);
+ if (tokenType <= TOKEN_NONE) {
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ return(SCAN_ERROR);
+ }
+ } while (tokenType != TOKEN_INTEGER);
+ N = tokenValue.integer;
+ }
+ else return(rc); /* if next token was not an Int */
+ }
+ if (N<=0 || N > INT_MAX / sizeof(psdict)) return(SCAN_ERROR);
+ /* save number of entries in the dictionary */
+
+ dictP = (psdict *)vm_alloc((N+1)*sizeof(psdict));
+ if (!(dictP)) return(SCAN_OUT_OF_MEMORY);
+ FontP->CharStringsP = dictP;
+ dictP[0].key.len = N;
+ /* get N values for CharStrings */
+ for (i=1;i<=N;i++) {
+ /* look for next literal name */
+ rc = getLiteralName(&(dictP[i].key));
+ if (rc) return(rc);
+ /* get 1 integer */
+ J = getInt();
+ if (rc) return(rc); /* if next token was not an Int */
+ if (J<0) return (SCAN_ERROR);
+ dictP[i].value.len = J;
+ /* get the next token, it should be RD or -|, either is ok */
+ rc = getNextValue(TOKEN_NAME);
+ if ( rc != SCAN_OK ) return(rc);
+ rc = getNbytes(J);
+ if (rc == SCAN_OK) {
+ dictP[i].value.data.valueP = tokenStartP;
+ if ( !(vm_alloc(J)) ) return(SCAN_OUT_OF_MEMORY);
+ }
+ else return(rc);
+ }
+ return(SCAN_OK);
+
+}
+/***================================================================***/
+#if XFONT_CID
+/***================================================================***/
+/*
+ * BuildCIDFontInfo Dictionary
+ */
+/***================================================================***/
+static int
+BuildCIDFontInfo(cidfont *CIDfontP)
+{
+ psdict *dictP;
+
+ /* allocate the private dictionary (max number of entries + 1) */
+ dictP = (psdict *)vm_alloc(20*sizeof(psdict));
+ if (!(dictP)) return(SCAN_OUT_OF_MEMORY);
+
+ CIDfontP->CIDfontInfoP = dictP;
+ CIDfontP->CIDfontInfoP[0].key.len = 18; /* number of actual entries */
+ objFormatName(&(dictP[CIDCOUNT].key),8,"CIDCount");
+ objFormatInteger(&(dictP[CIDCOUNT].value),-1);
+ objFormatName(&(dictP[CIDFONTNAME].key),11,"CIDFontName");
+ objFormatName(&(dictP[CIDFONTNAME].value),0,NULL);
+ objFormatName(&(dictP[CIDFONTTYPE].key),11,"CIDFontType");
+ objFormatInteger(&(dictP[CIDFONTTYPE].value),-1);
+ objFormatName(&(dictP[CIDVERSION].key),14,"CIDFontVersion");
+ objFormatInteger(&(dictP[CIDVERSION].value),-1);
+ objFormatName(&(dictP[CIDREGISTRY].key),8,"Registry");
+ objFormatString(&(dictP[CIDREGISTRY].value),0,NULL);
+ objFormatName(&(dictP[CIDORDERING].key),8,"Ordering");
+ objFormatString(&(dictP[CIDORDERING].value),0,NULL);
+ objFormatName(&(dictP[CIDSUPPLEMENT].key),10,"Supplement");
+ objFormatInteger(&(dictP[CIDSUPPLEMENT].value),-1);
+ objFormatName(&(dictP[CIDMAPOFFSET].key),12,"CIDMapOffset");
+ objFormatInteger(&(dictP[CIDMAPOFFSET].value),-1);
+ objFormatName(&(dictP[CIDFDARRAY].key),7,"FDArray");
+ objFormatArray(&(dictP[CIDFDARRAY].value),0,NULL);
+ objFormatName(&(dictP[CIDFDBYTES].key),7,"FDBytes");
+ objFormatInteger(&(dictP[CIDFDBYTES].value),-1);
+ objFormatName(&(dictP[CIDFONTBBOX].key),8,"FontBBox");
+ objFormatArray(&(dictP[CIDFONTBBOX].value),0,NULL);
+ objFormatName(&(dictP[CIDFULLNAME].key),8,"FullName");
+ objFormatString(&(dictP[CIDFULLNAME].value),0,NULL);
+ objFormatName(&(dictP[CIDFAMILYNAME].key),10,"FamilyName");
+ objFormatString(&(dictP[CIDFAMILYNAME].value),0,NULL);
+ objFormatName(&(dictP[CIDWEIGHT].key),6,"Weight");
+ objFormatString(&(dictP[CIDWEIGHT].value),0,NULL);
+ objFormatName(&(dictP[CIDNOTICE].key),6,"Notice");
+ objFormatString(&(dictP[CIDNOTICE].value),0,NULL);
+ objFormatName(&(dictP[CIDGDBYTES].key),7,"GDBytes");
+ objFormatInteger(&(dictP[CIDGDBYTES].value),-1);
+ objFormatName(&(dictP[CIDUIDBASE].key),7,"UIDBase");
+ objFormatInteger(&(dictP[CIDUIDBASE].value),0);
+ objFormatName(&(dictP[CIDXUID].key),4,"XUID");
+ objFormatInteger(&(dictP[CIDXUID].value),0);
+ return(SCAN_OK);
+}
+/***================================================================***/
+/*
+ * BuildCMapInfo Dictionary
+ */
+/***================================================================***/
+static int
+BuildCMapInfo(cmapres *CMapP)
+{
+ psdict *dictP;
+
+ /* allocate the private dictionary (max number of entries + 1) */
+ dictP = (psdict *)vm_alloc(20*sizeof(psdict));
+ if (!(dictP)) return(SCAN_OUT_OF_MEMORY);
+
+ CMapP->CMapInfoP = dictP;
+ CMapP->CMapInfoP[0].key.len = 8; /* number of actual entries */
+ objFormatName(&(dictP[CMAPREGISTRY].key),8,"Registry");
+ objFormatString(&(dictP[CMAPREGISTRY].value),0,NULL);
+ objFormatName(&(dictP[CMAPORDERING].key),8,"Ordering");
+ objFormatString(&(dictP[CMAPORDERING].value),0,NULL);
+ objFormatName(&(dictP[CMAPSUPPLEMENT].key),10,"Supplement");
+ objFormatInteger(&(dictP[CMAPSUPPLEMENT].value),-1);
+ objFormatName(&(dictP[CMAPNAME].key),8,"CMapName");
+ objFormatString(&(dictP[CMAPNAME].value),0,NULL);
+ objFormatName(&(dictP[CMAPVERSION].key),11,"CMapVersion");
+ objFormatInteger(&(dictP[CMAPVERSION].value),-1);
+ objFormatName(&(dictP[CMAPTYPE].key),8,"CMapType");
+ objFormatInteger(&(dictP[CMAPTYPE].value),-1);
+ objFormatName(&(dictP[CMAPWMODE].key),5,"WMode");
+ objFormatInteger(&(dictP[CMAPWMODE].value),-1);
+ objFormatName(&(dictP[CMAPCIDCOUNT].key),8,"CIDCount");
+ objFormatInteger(&(dictP[CMAPCIDCOUNT].value),-1);
+ return(SCAN_OK);
+}
+#endif
+
+/***================================================================***/
+/*
+ * BuildFontInfo Dictionary
+ */
+/***================================================================***/
+static int
+BuildFontInfo(psfont *fontP)
+{
+ psdict *dictP;
+
+ /* allocate the private dictionary */
+ dictP = (psdict *)vm_alloc(20*sizeof(psdict));
+ if (!(dictP)) return(SCAN_OUT_OF_MEMORY);
+
+ fontP->fontInfoP = dictP;
+ fontP->fontInfoP[0].key.len = 17; /* number of actual entries */
+ objFormatName(&(dictP[FONTNAME].key),8,"FontName");
+ objFormatName(&(dictP[FONTNAME].value),0,NULL);
+ objFormatName(&(dictP[PAINTTYPE].key),9,"PaintType");
+ objFormatInteger(&(dictP[PAINTTYPE].value),0);
+ objFormatName(&(dictP[FONTTYPENUM].key),8,"FontType");
+ objFormatInteger(&(dictP[FONTTYPENUM].value),0);
+ objFormatName(&(dictP[FONTMATRIX].key),10,"FontMatrix");
+ objFormatArray(&(dictP[FONTMATRIX].value),0,NULL);
+ objFormatName(&(dictP[FONTBBOX].key),8,"FontBBox");
+ objFormatArray(&(dictP[FONTBBOX].value),0,NULL);
+ objFormatName(&(dictP[ENCODING].key),8,"Encoding");
+ objFormatEncoding(&(dictP[ENCODING].value),0,NULL);
+ objFormatName(&(dictP[UNIQUEID].key),8,"UniqueID");
+ objFormatInteger(&(dictP[UNIQUEID].value),0);
+ objFormatName(&(dictP[STROKEWIDTH].key),11,"StrokeWidth");
+ objFormatReal(&(dictP[STROKEWIDTH].value),0.0);
+ objFormatName(&(dictP[VERSION].key),7,"version");
+ objFormatString(&(dictP[VERSION].value),0,NULL);
+ objFormatName(&(dictP[NOTICE].key),6,"Notice");
+ objFormatString(&(dictP[NOTICE].value),0,NULL);
+ objFormatName(&(dictP[FULLNAME].key),8,"FullName");
+ objFormatString(&(dictP[FULLNAME].value),0,NULL);
+ objFormatName(&(dictP[FAMILYNAME].key),10,"FamilyName");
+ objFormatString(&(dictP[FAMILYNAME].value),0,NULL);
+ objFormatName(&(dictP[WEIGHT].key),6,"Weight");
+ objFormatString(&(dictP[WEIGHT].value),0,NULL);
+ objFormatName(&(dictP[ITALICANGLE].key),11,"ItalicAngle");
+ objFormatReal(&(dictP[ITALICANGLE].value),0.0);
+ objFormatName(&(dictP[ISFIXEDPITCH].key),12,"isFixedPitch");
+ objFormatBoolean(&(dictP[ISFIXEDPITCH].value),FALSE);
+ objFormatName(&(dictP[UNDERLINEPOSITION].key),17,"UnderlinePosition");
+ objFormatReal(&(dictP[UNDERLINEPOSITION].value),0.0);
+ objFormatName(&(dictP[UNDERLINETHICKNESS].key),18,"UnderlineThickness");
+ objFormatReal(&(dictP[UNDERLINETHICKNESS].value),0.0);
+ return(SCAN_OK);
+}
+#if XFONT_CID
+/***================================================================***/
+/*
+ * BuildCIDType1Private Dictionary
+ */
+/***================================================================***/
+static int
+BuildCIDType1Private(psfont *fontP)
+{
+ psdict *Private;
+
+ /* allocate the private dictionary */
+ Private = (psdict *)vm_alloc(21*sizeof(psdict));
+
+ if (!(Private)) return(SCAN_OUT_OF_MEMORY);
+
+ fontP->Private = Private;
+ fontP->Private[0].key.len = 20; /* number of actual entries */
+
+ objFormatName(&(Private[CIDT1MINFEATURE].key),10,"MinFeature");
+ objFormatArray(&(Private[CIDT1MINFEATURE].value),0,NULL);
+ objFormatName(&(Private[CIDT1LENIV].key),5,"lenIV");
+ objFormatInteger(&(Private[CIDT1LENIV].value),DEFAULTLENIV);
+ objFormatName(&(Private[CIDT1LANGGROUP].key),13,"LanguageGroup");
+ objFormatInteger(&(Private[CIDT1LANGGROUP].value),DEFAULTLANGUAGEGROUP);
+ objFormatName(&(Private[CIDT1BLUEVALUES].key),10,"BlueValues");
+ objFormatArray(&(Private[CIDT1BLUEVALUES].value),0,NULL);
+ objFormatName(&(Private[CIDT1OTHERBLUES].key),10,"OtherBlues");
+ objFormatArray(&(Private[CIDT1OTHERBLUES].value),0,NULL);
+ objFormatName(&(Private[CIDT1BLUESCALE].key),9,"BlueScale");
+ objFormatReal(&(Private[CIDT1BLUESCALE].value),DEFAULTBLUESCALE);
+ objFormatName(&(Private[CIDT1BLUEFUZZ].key),8,"BlueFuzz");
+ objFormatInteger(&(Private[CIDT1BLUEFUZZ].value),DEFAULTBLUEFUZZ);
+ objFormatName(&(Private[CIDT1BLUESHIFT].key),9,"BlueShift");
+ objFormatInteger(&(Private[CIDT1BLUESHIFT].value),DEFAULTBLUESHIFT);
+ objFormatName(&(Private[CIDT1FAMBLUES].key),11,"FamilyBlues");
+ objFormatArray(&(Private[CIDT1FAMBLUES].value),0,NULL);
+ objFormatName(&(Private[CIDT1FAMOTHERBLUES].key),16,"FamilyOtherBlues");
+ objFormatArray(&(Private[CIDT1FAMOTHERBLUES].value),0,NULL);
+ objFormatName(&(Private[CIDT1STDHW].key),5,"StdHW");
+ objFormatArray(&(Private[CIDT1STDHW].value),0,NULL);
+ objFormatName(&(Private[CIDT1STDVW].key),5,"StdVW");
+ objFormatArray(&(Private[CIDT1STDVW].value),0,NULL);
+ objFormatName(&(Private[CIDT1STEMSNAPH].key),9,"StemSnapH");
+ objFormatArray(&(Private[CIDT1STEMSNAPH].value),0,NULL);
+ objFormatName(&(Private[CIDT1STEMSNAPV].key),9,"StemSnapV");
+ objFormatArray(&(Private[CIDT1STEMSNAPV].value),0,NULL);
+ /* skip password */
+ objFormatName(&(Private[CIDT1SUBMAPOFF].key),13,"SubrMapOffset");
+ objFormatInteger(&(Private[CIDT1SUBMAPOFF].value),0);
+ objFormatName(&(Private[CIDT1SDBYTES].key),7,"SDBytes");
+ objFormatInteger(&(Private[CIDT1SDBYTES].value),0);
+ objFormatName(&(Private[CIDT1SUBRCNT].key),9,"SubrCount");
+ objFormatInteger(&(Private[CIDT1SUBRCNT].value),0);
+ objFormatName(&(Private[CIDT1FORCEBOLD].key),9,"ForceBold");
+ objFormatBoolean(&(Private[CIDT1FORCEBOLD].value),DEFAULTFORCEBOLD);
+ objFormatName(&(Private[CIDT1RNDSTEMUP].key),9,"RndStemUp");
+ objFormatBoolean(&(Private[CIDT1RNDSTEMUP].value),DEFAULTRNDSTEMUP);
+ objFormatName(&(Private[CIDT1EXPFACTOR].key),15,"ExpansionFactor");
+ objFormatReal(&(Private[CIDT1EXPFACTOR].value),
+ DEFAULTEXPANSIONFACTOR);
+ return(SCAN_OK);
+}
+#endif
+/***================================================================***/
+/*
+ * BuildPrivate Dictionary
+ */
+/***================================================================***/
+static int
+BuildPrivate(psfont *fontP)
+{
+ psdict *Private;
+
+ /* allocate the private dictionary */
+ Private = (psdict *)vm_alloc(20*sizeof(psdict));
+
+ if (!(Private)) return(SCAN_OUT_OF_MEMORY);
+
+ fontP->Private = Private;
+ fontP->Private[0].key.len = 16; /* number of actual entries */
+
+ objFormatName(&(Private[BLUEVALUES].key),10,"BlueValues");
+ objFormatArray(&(Private[BLUEVALUES].value),0,NULL);
+ objFormatName(&(Private[OTHERBLUES].key),10,"OtherBlues");
+ objFormatArray(&(Private[OTHERBLUES].value),0,NULL);
+ objFormatName(&(Private[FAMILYBLUES].key),11,"FamilyBlues");
+ objFormatArray(&(Private[FAMILYBLUES].value),0,NULL);
+ objFormatName(&(Private[FAMILYOTHERBLUES].key),16,"FamilyOtherBlues");
+ objFormatArray(&(Private[FAMILYOTHERBLUES].value),0,NULL);
+ objFormatName(&(Private[BLUESCALE].key),9,"BlueScale");
+ objFormatReal(&(Private[BLUESCALE].value),DEFAULTBLUESCALE);
+ objFormatName(&(Private[BLUESHIFT].key),9,"BlueShift");
+ objFormatInteger(&(Private[BLUESHIFT].value),DEFAULTBLUESHIFT);
+ objFormatName(&(Private[BLUEFUZZ].key),8,"BlueFuzz");
+ objFormatInteger(&(Private[BLUEFUZZ].value),DEFAULTBLUEFUZZ);
+ objFormatName(&(Private[STDHW].key),5,"StdHW");
+ objFormatArray(&(Private[STDHW].value),0,NULL);
+ objFormatName(&(Private[STDVW].key),5,"StdVW");
+ objFormatArray(&(Private[STDVW].value),0,NULL);
+ objFormatName(&(Private[STEMSNAPH].key),9,"StemSnapH");
+ objFormatArray(&(Private[STEMSNAPH].value),0,NULL);
+ objFormatName(&(Private[STEMSNAPV].key),9,"StemSnapV");
+ objFormatArray(&(Private[STEMSNAPV].value),0,NULL);
+ objFormatName(&(Private[FORCEBOLD].key),9,"ForceBold");
+ objFormatBoolean(&(Private[FORCEBOLD].value),DEFAULTFORCEBOLD);
+ objFormatName(&(Private[LANGUAGEGROUP].key),13,"LanguageGroup");
+ objFormatInteger(&(Private[LANGUAGEGROUP].value),DEFAULTLANGUAGEGROUP);
+ objFormatName(&(Private[LENIV].key),5,"lenIV");
+ objFormatInteger(&(Private[LENIV].value),DEFAULTLENIV);
+ objFormatName(&(Private[RNDSTEMUP].key),9,"RndStemUp");
+ objFormatBoolean(&(Private[RNDSTEMUP].value),DEFAULTRNDSTEMUP);
+ objFormatName(&(Private[EXPANSIONFACTOR].key),9,"ExpansionFactor");
+ objFormatReal(&(Private[EXPANSIONFACTOR].value),
+ DEFAULTEXPANSIONFACTOR);
+ return(SCAN_OK);
+}
+/***================================================================***/
+/**********************************************************************/
+/* GetType1Blues(fontP) */
+/* */
+/* Routine to support font-level hints. */
+/* */
+/* Gets all the Blues information from the Private dictionary */
+/* for the font. */
+/* */
+/* */
+/**********************************************************************/
+static int
+GetType1Blues(psfont *fontP)
+{
+ psdict *PrivateDictP; /* the Private dict relating to hints */
+ struct blues_struct *blues; /* ptr for the blues struct we will allocate */
+ int i;
+ psobj *HintEntryP;
+
+
+
+ /* get the Private dictionary pointer */
+ PrivateDictP = fontP->Private;
+
+ /* allocate the memory for the blues structure */
+ blues = (struct blues_struct *) vm_alloc(sizeof(struct blues_struct));
+
+ if (!blues) return(SCAN_OUT_OF_MEMORY);
+
+ /* Make fontP's blues ptr point to this newly allocated structure. */
+ fontP->BluesP = blues;
+
+ /* fill in the BlueValues array */
+ HintEntryP = &(PrivateDictP[BLUEVALUES].value);
+ /* check to see if the entry exists and if it's an array */
+ if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
+ blues->numBlueValues = 0;
+ else {
+ /* get the number of values in the array */
+ if (HintEntryP->len > NUMBLUEVALUES) {
+ blues->numBlueValues = NUMBLUEVALUES;
+ } else
+ blues->numBlueValues = HintEntryP->len;
+ for (i = 0; i<= blues->numBlueValues-1; ++i) {
+ if (objPIsInteger(&HintEntryP->data.arrayP[i]))
+ blues->BlueValues[i] =
+ HintEntryP->data.arrayP[i].data.integer;
+ else if (objPIsReal(&HintEntryP->data.arrayP[i]))
+ blues->BlueValues[i] =
+ HintEntryP->data.arrayP[i].data.real;
+ else
+ blues->BlueValues[i] = 0;
+ }
+ }
+
+ /* fill in the OtherBlues array */
+ HintEntryP = &(PrivateDictP[OTHERBLUES].value);
+ /* check to see if the entry exists and if it's an array */
+ if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
+ blues->numOtherBlues = 0;
+ else {
+ /* get the number of values in the array */
+ if (HintEntryP->len > NUMOTHERBLUES) {
+ blues->numOtherBlues = NUMOTHERBLUES;
+ } else
+ blues->numOtherBlues = HintEntryP->len;
+ for (i = 0; i<= blues->numOtherBlues-1; ++i) {
+ if (objPIsInteger(&HintEntryP->data.arrayP[i]))
+ blues->OtherBlues[i] =
+ HintEntryP->data.arrayP[i].data.integer;
+ else if (objPIsReal(&HintEntryP->data.arrayP[i]))
+ blues->OtherBlues[i] =
+ HintEntryP->data.arrayP[i].data.real;
+ else
+ blues->OtherBlues[i] = 0;
+ }
+ }
+
+ /* fill in the FamilyBlues array */
+ HintEntryP = &(PrivateDictP[FAMILYBLUES].value);
+ /* check to see if the entry exists and if it's an array */
+ if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
+ blues->numFamilyBlues = 0;
+ else {
+ /* get the number of values in the array */
+ if (HintEntryP->len > NUMFAMILYBLUES) {
+ blues->numFamilyBlues = NUMFAMILYBLUES;
+ } else
+ blues->numFamilyBlues = HintEntryP->len;
+ for (i = 0; i<= blues->numFamilyBlues-1; ++i) {
+ if (objPIsInteger(&HintEntryP->data.arrayP[i]))
+ blues->FamilyBlues[i] =
+ HintEntryP->data.arrayP[i].data.integer;
+ else if (objPIsReal(&HintEntryP->data.arrayP[i]))
+ blues->FamilyBlues[i] =
+ HintEntryP->data.arrayP[i].data.real;
+ else
+ blues->FamilyBlues[i] = 0;
+ }
+ }
+
+ /* fill in the FamilyOtherBlues array */
+ HintEntryP = &(PrivateDictP[FAMILYOTHERBLUES].value);
+ /* check to see if the entry exists and if it's an array */
+ if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
+ blues->numFamilyOtherBlues = 0;
+ else {
+ /* get the number of values in the array */
+ if (HintEntryP->len > NUMFAMILYOTHERBLUES) {
+ blues->numFamilyOtherBlues = NUMFAMILYOTHERBLUES;
+ } else
+ blues->numFamilyOtherBlues = HintEntryP->len;
+ for (i = 0; i<= blues->numFamilyOtherBlues-1; ++i) {
+ if (objPIsInteger(&HintEntryP->data.arrayP[i]))
+ blues->FamilyOtherBlues[i] =
+ HintEntryP->data.arrayP[i].data.integer;
+ else if (objPIsReal(&HintEntryP->data.arrayP[i]))
+ blues->FamilyOtherBlues[i] =
+ HintEntryP->data.arrayP[i].data.real;
+ else
+ blues->FamilyOtherBlues[i] = 0;
+ }
+ }
+
+ /* fill in the StemSnapH array */
+ HintEntryP = &(PrivateDictP[STEMSNAPH].value);
+ /* check to see if the entry exists and if it's an array */
+ if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
+ blues->numStemSnapH = 0;
+ else {
+ /* get the number of values in the array */
+ if (HintEntryP->len > NUMSTEMSNAPH) {
+ blues->numStemSnapH = NUMSTEMSNAPH;
+ } else
+ blues->numStemSnapH = HintEntryP->len;
+ for (i = 0; i<= blues->numStemSnapH-1; ++i) {
+ if (objPIsInteger(&HintEntryP->data.arrayP[i]))
+ blues->StemSnapH[i] =
+ HintEntryP->data.arrayP[i].data.integer;
+ else if (objPIsReal(&HintEntryP->data.arrayP[i]))
+ blues->StemSnapH[i] =
+ HintEntryP->data.arrayP[i].data.real;
+ else
+ blues->StemSnapH[i] = 0;
+ }
+ }
+
+ /* fill in the StemSnapV array */
+ HintEntryP = &(PrivateDictP[STEMSNAPV].value);
+ /* check to see if the entry exists and if it's an array */
+ if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
+ blues->numStemSnapV = 0;
+ else {
+ /* get the number of values in the array */
+ if (HintEntryP->len > NUMSTEMSNAPV) {
+ blues->numStemSnapV = NUMSTEMSNAPV;
+ } else
+ blues->numStemSnapV = HintEntryP->len;
+ for (i = 0; i<= blues->numStemSnapV-1; ++i) {
+ if (objPIsInteger(&HintEntryP->data.arrayP[i]))
+ blues->StemSnapV[i] =
+ HintEntryP->data.arrayP[i].data.integer;
+ else if (objPIsReal(&HintEntryP->data.arrayP[i]))
+ blues->StemSnapV[i] =
+ HintEntryP->data.arrayP[i].data.real;
+ else
+ blues->StemSnapV[i] = 0;
+ }
+ }
+
+ /* fill in the StdVW array */
+ HintEntryP = &(PrivateDictP[STDVW].value);
+ /* check to see if the entry exists and if it's an array */
+ if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
+ /* a value of zero signifies no entry */
+ blues->StdVW = 0;
+ else {
+ if (HintEntryP->len > NUMSTDVW) {
+ }
+ if (objPIsInteger(&HintEntryP->data.arrayP[0]))
+ blues->StdVW = HintEntryP->data.arrayP[0].data.integer;
+ else if (objPIsReal(&HintEntryP->data.arrayP[0]))
+ blues->StdVW = HintEntryP->data.arrayP[0].data.real;
+ else
+ blues->StdVW = 0;
+ }
+
+ /* fill in the StdHW array */
+ HintEntryP = &(PrivateDictP[STDHW].value);
+ /* check to see if the entry exists and if it's an array */
+ if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
+ /* a value of zero signifies no entry */
+ blues->StdHW = 0;
+ else {
+ if (HintEntryP->len > NUMSTDHW) {
+ }
+ if (objPIsInteger(&HintEntryP->data.arrayP[0]))
+ blues->StdHW = HintEntryP->data.arrayP[0].data.integer;
+ else if (objPIsReal(&HintEntryP->data.arrayP[0]))
+ blues->StdHW = HintEntryP->data.arrayP[0].data.real;
+ else
+ blues->StdHW = 0;
+ }
+
+
+ /* get the ptr to the BlueScale entry */
+ HintEntryP = &(PrivateDictP[BLUESCALE].value);
+ /* put the BlueScale in the blues structure */
+ if (objPIsInteger(HintEntryP)) /* Must be integer! */
+ blues->BlueScale = HintEntryP->data.integer;
+ else if (objPIsReal(HintEntryP)) /* Error? */
+ blues->BlueScale = HintEntryP->data.real;
+ else
+ blues->BlueScale = DEFAULTBLUESCALE;
+
+ /* get the ptr to the BlueShift entry */
+ HintEntryP = &(PrivateDictP[BLUESHIFT].value);
+ if (objPIsInteger(HintEntryP)) /* Must be integer! */
+ blues->BlueShift = HintEntryP->data.integer;
+ else if (objPIsReal(HintEntryP)) /* Error? */
+ blues->BlueShift = HintEntryP->data.real;
+ else
+ blues->BlueShift = DEFAULTBLUESHIFT;
+
+ /* get the ptr to the BlueFuzz entry */
+ HintEntryP = &(PrivateDictP[BLUEFUZZ].value);
+ if (objPIsInteger(HintEntryP)) /* Must be integer! */
+ blues->BlueFuzz = HintEntryP->data.integer;
+ else if (objPIsReal(HintEntryP)) /* Error? */
+ blues->BlueFuzz = HintEntryP->data.real;
+ else
+ blues->BlueFuzz = DEFAULTBLUEFUZZ;
+
+ /* get the ptr to the ForceBold entry */
+ HintEntryP = &(PrivateDictP[FORCEBOLD].value);
+ if (objPIsBoolean(HintEntryP)) /* Must be integer! */
+ blues->ForceBold = HintEntryP->data.boolean;
+ else
+ blues->ForceBold = DEFAULTFORCEBOLD;
+
+ /* get the ptr to the LanguageGroup entry */
+ HintEntryP = &(PrivateDictP[LANGUAGEGROUP].value);
+ if (objPIsInteger(HintEntryP)) /* Must be integer! */
+ blues->LanguageGroup = HintEntryP->data.integer;
+ else
+ blues->LanguageGroup = DEFAULTLANGUAGEGROUP;
+
+ /* get the ptr to the RndStemUp entry */
+ HintEntryP = &(PrivateDictP[RNDSTEMUP].value);
+ if (objPIsBoolean(HintEntryP)) /* Must be integer! */
+ blues->RndStemUp = HintEntryP->data.boolean;
+ else
+ blues->RndStemUp = DEFAULTRNDSTEMUP;
+
+ /* get the ptr to the lenIV entry */
+ HintEntryP = &(PrivateDictP[LENIV].value);
+ if (objPIsInteger(HintEntryP)) /* Must be integer! */
+ blues->lenIV = HintEntryP->data.integer;
+ else
+ blues->lenIV = DEFAULTLENIV;
+
+ /* get the ptr to the ExpansionFactor entry */
+ HintEntryP = &(PrivateDictP[EXPANSIONFACTOR].value);
+ if (objPIsInteger(HintEntryP))
+ blues->ExpansionFactor = HintEntryP->data.integer;
+ else if (objPIsReal(HintEntryP))
+ blues->ExpansionFactor = HintEntryP->data.real;
+ else
+ blues->ExpansionFactor = DEFAULTEXPANSIONFACTOR;
+ return(SCAN_OK);
+}
+/**********************************************************************/
+/* GetType1CharString(fontP,code) */
+/* */
+/* Look up code in the standard encoding vector and return */
+/* the charstring associated with the character name. */
+/* */
+/* fontP is the psfont structure. */
+/* */
+/* Returns a psobj (string) */
+/**********************************************************************/
+psobj *
+GetType1CharString(psfont *fontP, unsigned char code)
+{
+ int N; /* the 'Nth' entry in the CharStrings */
+ psobj *charnameP; /* points to psobj that is name of character*/
+
+ psdict *CharStringsDictP; /* dictionary with char strings */
+ psobj *theStringP; /* the definition for the code */
+
+
+
+ if (StdEncArrayP == NULL) {
+ return(NULL);
+ }
+ /* use the code to index into the standard encoding vector */
+ charnameP = &(StdEncArrayP[code]);
+
+ /* test if the encoding array points to a name */
+ if (!(objPIsName(charnameP)) ) {
+ return(NULL);
+ }
+
+ /* Now that we have the character name out of the standardencoding */
+ /* get the character definition out of the current font */
+ CharStringsDictP = fontP->CharStringsP;
+
+ /* search the chars string for this charname as key */
+ N = SearchDictName(CharStringsDictP,charnameP);
+ if (N<=0) {
+ return(NULL);
+ }
+ /* OK, the nth item is the psobj that is the string for this char */
+ theStringP = &(CharStringsDictP[N].value);
+
+ return(theStringP);
+}
+
+/***================================================================***/
+/*
+ * FindDictValue
+ */
+/***================================================================***/
+
+static int
+FindDictValue(psdict *dictP)
+{
+ psobj LitName;
+ int N;
+ int V;
+
+ /* we have just scanned a token and it is a literal name */
+ /* need to check if that name is in Private dictionary */
+ objFormatName(&LitName,tokenLength,tokenStartP);
+ /* is it in the dictP */
+ N = SearchDictName(dictP,&LitName);
+ /* if found */
+ if ( N > 0 ) {
+ /* what type */
+ switch (dictP[N].value.type) {
+ case OBJ_ENCODING:
+ V = getEncoding(&(dictP[N].value));
+ if ( V != SCAN_OK ) return(V);
+ break;
+ case OBJ_ARRAY:
+#if XFONT_CID
+ if (0 == strncmp(tokenStartP,"FDArray",7))
+ V = getFDArray(&(dictP[N].value));
+ else
+ V = getArray(&(dictP[N].value));
+#else
+ V = getArray(&(dictP[N].value));
+#endif
+ if ( V != SCAN_OK ) return(V);
+ break;
+ case OBJ_INTEGER:
+ /* next value in integer */
+ dictP[N].value.data.integer = getInt();
+ if (rc) return(rc); /* if next token was not an Int */
+ break;
+ case OBJ_REAL:
+ /* next value must be real or int, store as a real */
+ scan_token(inputP);
+ if (tokenType == TOKEN_REAL) {
+ dictP[N].value.data.real = tokenValue.real;
+ }
+ else
+ if (tokenType == TOKEN_INTEGER) {
+ dictP[N].value.data.real = tokenValue.integer;
+ }
+ else return(SCAN_ERROR);
+ break;
+ case OBJ_NAME:
+ V = getNextValue(TOKEN_LITERAL_NAME);
+ if ( V != SCAN_OK ) return(V);
+ if (!(vm_alloc(tokenLength)) ) return(SCAN_OUT_OF_MEMORY);
+ objFormatName(&(dictP[N].value),tokenLength,tokenStartP);
+ break;
+ case OBJ_STRING:
+ V = getNextValue(TOKEN_STRING);
+ if ( V != SCAN_OK ) return(V);
+ if (!(vm_alloc(tokenLength)) ) return(SCAN_OUT_OF_MEMORY);
+ objFormatString(&(dictP[N].value),tokenLength,tokenStartP);
+ break;
+ case OBJ_BOOLEAN:
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME) {
+ return(SCAN_ERROR);
+ }
+ if (0 == strncmp(tokenStartP,"true",4) ) {
+ dictP[N].value.data.boolean =TRUE;
+ }
+ else
+ if (0 == strncmp(tokenStartP,"false",5) ) {
+ dictP[N].value.data.boolean =FALSE;
+ }
+ else return(SCAN_ERROR);
+ break;
+
+ default:
+ return(SCAN_ERROR);
+ }
+ }
+ /* Name is not in dictionary. That is ok. */
+ return(SCAN_OK);
+
+}
+/***================================================================***/
+
+#if XFONT_CID
+/*
+ * -------------------------------------------------------------------
+ * Scan the next token and convert it into an object
+ * Result is placed on the Operand Stack as next object
+ * -------------------------------------------------------------------
+ */
+int
+scan_cidfont(cidfont *CIDFontP, cmapres *CMapP)
+{
+ char filename[CID_PATH_MAX];
+ char cmapfile[CID_PATH_MAX];
+ char buf[CID_BUFSIZE];
+ char filetype[3];
+ FILE *fileP;
+ FILE *fileP1;
+ char *nameP;
+ int namelen;
+ int i, j;
+ int cread, rangecnt;
+ unsigned int char_row, char_col;
+
+ filetype[0] = 'r';
+ filetype[1] = 'b';
+ filetype[2] = '\0';
+
+ /* copy the filename and remove leading or trailing blanks */
+ /* point to name and search for leading blanks */
+ nameP= CIDFontP->CIDFontFileName.data.nameP;
+ namelen = CIDFontP->CIDFontFileName.len;
+ while (nameP[0] == ' ') {
+ nameP++;
+ namelen--;
+ }
+ /* now remove any trailing blanks */
+ while ((namelen>0) && ( nameP[namelen-1] == ' ')) {
+ namelen--;
+ }
+ strncpy(filename,nameP,namelen);
+ filename[namelen] = '\0';
+ /* file name is now constructed */
+ inputFile.data.fileP = NULL;
+ filterFile.data.fileP = NULL;
+
+ /* check whether a CIDFont file */
+ if ((fileP = fopen(filename,filetype))) {
+ cread = fread(buf, 1, CID_BUFSIZE, fileP);
+ fclose(fileP);
+ if (cread > 17) {
+ if (strncmp(buf, "%!", 2) ||
+ strstr(buf, "Resource-CIDFont") == NULL)
+ return(SCAN_FILE_OPEN_ERROR);
+ } else
+ return(SCAN_FILE_OPEN_ERROR);
+ } else
+ return(SCAN_FILE_OPEN_ERROR);
+
+ /* copy the CMap file name and remove leading or trailing blanks */
+ /* point to name and search for leading blanks */
+ nameP = CMapP->CMapFileName.data.nameP;
+ namelen = CMapP->CMapFileName.len;
+ while (nameP[0] == ' ') {
+ nameP++;
+ namelen--;
+ }
+ /* now remove any trailing blanks */
+ while ((namelen>0) && ( nameP[namelen-1] == ' ')) {
+ namelen--;
+ }
+ strncpy(cmapfile,nameP,namelen);
+ cmapfile[namelen] = '\0';
+ /* CMap file name is now constructed */
+ inputFile1.data.fileP = NULL;
+
+ /* check whether a CMap file */
+ if ((fileP1 = fopen(cmapfile,filetype))) {
+ cread = fread(buf, 1, CID_BUFSIZE, fileP1);
+ fclose(fileP1);
+ if (cread > 17) {
+ if (strncmp(buf, "%!", 2) ||
+ strstr(buf, "Resource-CMap") == NULL)
+ return(SCAN_FILE_OPEN_ERROR);
+ } else
+ return(SCAN_FILE_OPEN_ERROR);
+ } else
+ return(SCAN_FILE_OPEN_ERROR);
+
+ /* read the specified CMap file */
+ inputP = &inputFile1;
+
+ if (!(fileP1 = fopen(cmapfile,filetype)))
+ return(SCAN_FILE_OPEN_ERROR);
+
+ objFormatFile(inputP,fileP1);
+
+ if ((rc = BuildCMapInfo(CMapP)) != 0)
+ return(rc);
+
+ /* Assume everything will be OK */
+ rc = 0;
+ rangecnt = 0;
+
+ do {
+ /* Scan the next token */
+ scan_token(inputP);
+ if (tokenType == TOKEN_INTEGER)
+ rangecnt = tokenValue.integer;
+
+ if (rangecnt < 0 || rangecnt > INT_MAX / sizeof(spacerangecode)) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ /* ==> tokenLength, tokenTooLong, tokenType, and */
+ /* tokenValue are now set */
+
+ switch (tokenType) {
+ case TOKEN_EOF:
+ case TOKEN_NONE:
+ case TOKEN_INVALID:
+ /* in this case we are done */
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ rc = SCAN_ERROR;
+ break;
+ case TOKEN_LITERAL_NAME:
+ /* Look up the name */
+ tokenStartP[tokenLength] = '\0';
+
+ rc = FindDictValue(CMapP->CMapInfoP);
+ /* we are not going to report errors except out of memory */
+ if (rc != SCAN_OUT_OF_MEMORY)
+ rc = SCAN_OK;
+ break;
+ case TOKEN_NAME:
+ if (0 == strncmp(tokenStartP,"begincodespacerange",19)) {
+ CIDFontP->spacerangecnt++;
+ spacerangeP = (spacerange *)vm_alloc(sizeof(spacerange));
+ if (!spacerangeP) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ spacerangeP->next = NULL;
+ spacerangeP->rangecnt = rangecnt;
+ spacerangeP->spacecode =
+ (spacerangecode *)vm_alloc(rangecnt*sizeof(spacerangecode));
+ if (!spacerangeP->spacecode) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ for (i = 0; i < rangecnt; i++) {
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ spacerangeP->spacecode[i].srcCodeLo = 0;
+ for (j = 0; j < tokenLength; j++)
+ spacerangeP->spacecode[i].srcCodeLo +=
+ (unsigned char)tokenStartP[j] << (8 * (tokenLength - 1 - j));
+
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ spacerangeP->spacecode[i].srcCodeHi = 0;
+ for (j = 0; j < tokenLength; j++)
+ spacerangeP->spacecode[i].srcCodeHi +=
+ (unsigned char)tokenStartP[j] << (8 * (tokenLength - 1 - j));
+ }
+
+ if (CIDFontP->spacerangeP) {
+ if (CIDFontP->spacerangeP->next == NULL)
+ CIDFontP->spacerangeP->next = spacerangeP;
+ else {
+ spacerangeP->next = CIDFontP->spacerangeP->next;
+ CIDFontP->spacerangeP->next = spacerangeP;
+ }
+ } else
+ CIDFontP->spacerangeP = spacerangeP;
+
+ /* read "endcodespacerange" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || (tokenType == TOKEN_NAME &&
+ (strncmp(tokenStartP,"endcodespacerange",17) != 0))) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ }
+ if (0 == strncmp(tokenStartP,"begincidrange",13)) {
+ CIDFontP->cidrangecnt++;
+ cidrangeP = (cidrange *)vm_alloc(sizeof(cidrange));
+ if (!cidrangeP) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ cidrangeP->next = NULL;
+ cidrangeP->rangecnt = rangecnt;
+ cidrangeP->range =
+ (cidrangecode *)vm_alloc(rangecnt*sizeof(cidrangecode));
+ if (!cidrangeP->range) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ for (i = 0; i < rangecnt; i++) {
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ cidrangeP->range[i].srcCodeLo = 0;
+ for (j = 0; j < tokenLength; j++)
+ cidrangeP->range[i].srcCodeLo +=
+ (unsigned char)tokenStartP[j] << (8 * (tokenLength - 1 - j));
+ char_row = (cidrangeP->range[i].srcCodeLo >> 8) & 0xff;
+ char_col = cidrangeP->range[i].srcCodeLo & 0xff;
+ if (char_row < CMapP->firstRow)
+ CMapP->firstRow = char_row;
+ if (char_row > CMapP->lastRow)
+ CMapP->lastRow = char_row;
+ if (char_col < CMapP->firstCol)
+ CMapP->firstCol = char_col;
+ if (char_col > CMapP->lastCol)
+ CMapP->lastCol = char_col;
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ cidrangeP->range[i].srcCodeHi = 0;
+ for (j = 0; j < tokenLength; j++)
+ cidrangeP->range[i].srcCodeHi +=
+ (unsigned char)tokenStartP[j] << (8 * (tokenLength - 1 - j));
+ char_row = (cidrangeP->range[i].srcCodeHi >> 8) & 0xff;
+ char_col = cidrangeP->range[i].srcCodeHi & 0xff;
+ if (char_row < CMapP->firstRow)
+ CMapP->firstRow = char_row;
+ if (char_row > CMapP->lastRow)
+ CMapP->lastRow = char_row;
+ if (char_col < CMapP->firstCol)
+ CMapP->firstCol = char_col;
+ if (char_col > CMapP->lastCol)
+ CMapP->lastCol = char_col;
+ scan_token(inputP);
+ if (tokenType != TOKEN_INTEGER) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ cidrangeP->range[i].dstCIDLo = tokenValue.integer;
+ }
+
+ if (CIDFontP->cidrangeP) {
+ if (CIDFontP->cidrangeP->next == NULL)
+ CIDFontP->cidrangeP->next = cidrangeP;
+ else {
+ cidrangeP->next = CIDFontP->cidrangeP->next;
+ CIDFontP->cidrangeP->next = cidrangeP;
+ }
+ } else
+ CIDFontP->cidrangeP = cidrangeP;
+
+ /* read "endcidrange" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || (tokenType == TOKEN_NAME &&
+ (strncmp(tokenStartP,"endcidrange",11) != 0))) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ }
+
+ if (0 == strncmp(tokenStartP,"beginnotdefrange",16)) {
+ CIDFontP->notdefrangecnt++;
+ notdefrangeP = (cidrange *)vm_alloc(sizeof(cidrange));
+ if (!notdefrangeP) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ notdefrangeP->next = 0;
+ notdefrangeP->rangecnt = rangecnt;
+ notdefrangeP->range =
+ (cidrangecode *)vm_alloc(rangecnt*sizeof(cidrangecode));
+ if (!notdefrangeP->range) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ for (i = 0; i < rangecnt; i++) {
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ notdefrangeP->range[i].srcCodeLo = 0;
+ for (j = 0; j < tokenLength; j++)
+ notdefrangeP->range[i].srcCodeLo = (int)(tokenStartP[j] <<
+ (8 * (tokenLength - 1 - j)));
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ notdefrangeP->range[i].srcCodeHi = 0;
+ for (j = 0; j < tokenLength; j++)
+ notdefrangeP->range[i].srcCodeHi = (int)(tokenStartP[j] <<
+ (8 * (tokenLength - 1 - j)));
+ scan_token(inputP);
+ if (tokenType != TOKEN_INTEGER) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ notdefrangeP->range[i].dstCIDLo = tokenValue.integer;
+ }
+ if (CIDFontP->notdefrangeP) {
+ if (CIDFontP->notdefrangeP->next == NULL)
+ CIDFontP->notdefrangeP->next = notdefrangeP;
+ else {
+ notdefrangeP->next = CIDFontP->notdefrangeP->next;
+ CIDFontP->notdefrangeP->next = notdefrangeP;
+ }
+ } else
+ CIDFontP->notdefrangeP = notdefrangeP;
+
+ /* read "endnotdefrange" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || (tokenType == TOKEN_NAME &&
+ (strncmp(tokenStartP,"endnotdefrange",14) != 0))) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ }
+
+ if (0 == strncmp(tokenStartP,"endcmap",7)) {
+ if (CMapP->CMapInfoP[CMAPREGISTRY].value.data.valueP == NULL ||
+ CMapP->CMapInfoP[CMAPORDERING].value.data.valueP == NULL ||
+ CMapP->CMapInfoP[CMAPSUPPLEMENT].value.data.integer == -1) {
+ rc = SCAN_ERROR;
+ break;
+ } else {
+ rc = SCAN_FILE_EOF;
+ break;
+ }
+ }
+ break;
+ }
+ }
+ while (rc == 0);
+ fclose(inputP->data.fileP);
+ if (tokenTooLong)
+ rc = SCAN_OUT_OF_MEMORY;
+ if (rc == SCAN_OUT_OF_MEMORY) return(rc);
+
+ /* open the specified CIDFont file */
+ if (!(fileP = fopen(filename,filetype)))
+ return(SCAN_FILE_OPEN_ERROR);
+
+ inputP = &inputFile;
+ objFormatFile(inputP,fileP);
+ CIDWantFontInfo = TRUE;
+ TwoSubrs = FALSE;
+ rc = BuildCIDFontInfo(CIDFontP);
+ if (rc != 0) return(rc);
+
+ /* Assume everything will be OK */
+ rc = 0;
+
+ /* Loop until complete font is read */
+ do {
+ /* Scan the next token */
+ scan_token(inputP);
+
+ /* ==> tokenLength, tokenTooLong, tokenType, and tokenValue are */
+ /* now set */
+
+ switch (tokenType) {
+ case TOKEN_EOF:
+ case TOKEN_NONE:
+ case TOKEN_INVALID:
+ /* in this case we are done */
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ rc = SCAN_ERROR;
+ break;
+ case TOKEN_LITERAL_NAME:
+ /* Look up the name */
+ tokenStartP[tokenLength] = '\0';
+
+ if (CIDWantFontInfo) {
+ rc = FindDictValue(CIDFontP->CIDfontInfoP);
+ /* we are not going to report errors except out of memory */
+ if (rc != SCAN_OUT_OF_MEMORY)
+ rc = SCAN_OK;
+ break;
+ }
+ break;
+ case TOKEN_STRING:
+ tokenStartP[tokenLength] = '\0';
+ if (0 == strncmp(tokenStartP,"Binary",6)) {
+ CIDFontP->binarydata = 1;
+ scan_token(inputP);
+ if (tokenType == TOKEN_INTEGER)
+ CIDFontP->bytecnt = tokenValue.integer;
+ else {
+ rc = SCAN_ERROR;
+ break;
+ }
+ } else if (0 == strncmp(tokenStartP,"Hex",3)) {
+ /* not yet supported */
+ rc = SCAN_ERROR;
+ break;
+#if 0
+ /* uncomment when the hex format is supported */
+ CIDFontP->binarydata = 0;
+ scan_token(inputP);
+ if (tokenType == TOKEN_INTEGER)
+ CIDFontP->bytecnt = tokenValue.integer;
+ else {
+ rc = SCAN_ERROR;
+ break;
+ }
+#endif
+ }
+ break;
+ case TOKEN_NAME:
+ /* end of PostScript and beginning of data */
+ if (0 == strncmp(tokenStartP,"StartData",9)) {
+ /* every CIDFont must have an FDArray */
+ /* check whether other required dictionary entries were found */
+ if (CIDFontP->CIDfontInfoP[CIDFDARRAY].value.data.arrayP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDFONTNAME].value.data.nameP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDFONTTYPE].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDVERSION].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDREGISTRY].value.data.valueP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDORDERING].value.data.valueP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDSUPPLEMENT].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDMAPOFFSET].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDFDBYTES].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDGDBYTES].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDCOUNT].value.data.integer == -1) {
+ rc = SCAN_ERROR;
+ break;
+ } else {
+ /* do Registry and Ordering entries match? */
+ if (strcmp(CIDFontP->CIDfontInfoP[CIDREGISTRY].value.data.valueP,
+ CMapP->CMapInfoP[CMAPREGISTRY].value.data.valueP) != 0 ||
+ strcmp(CIDFontP->CIDfontInfoP[CIDORDERING].value.data.valueP,
+ CMapP->CMapInfoP[CMAPORDERING].value.data.valueP) != 0) {
+ rc = SCAN_ERROR;
+ break;
+ } else {
+ fclose(inputP->data.fileP);
+ return(SCAN_OK);
+ }
+ }
+ }
+ break;
+ }
+
+ }
+ while (rc ==0);
+ fclose(inputP->data.fileP);
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ return(rc);
+}
+
+/*
+ * -------------------------------------------------------------------
+ * Scan the next token and convert it into an object
+ * Result is placed on the Operand Stack as next object
+ * -------------------------------------------------------------------
+ */
+int
+scan_cidtype1font(psfont *FontP)
+{
+ int i;
+ int begincnt = 0; /* counter for the number of unpaired begin operators */
+ int currentfilefound = 0;
+
+ WantFontInfo = TRUE;
+ InPrivateDict = FALSE;
+ TwoSubrs = FALSE;
+ rc = BuildFontInfo(FontP);
+ if (rc != 0) return(rc);
+
+ /* Assume everything will be OK */
+ rc = 0;
+ filterFile.data.fileP = NULL;
+
+ /* Loop until complete font is read */
+ do {
+ /* Scan the next token */
+ scan_token(inputP);
+
+ /* ==> tokenLength, tokenTooLong, tokenType, and tokenValue are */
+ /* now set */
+
+ switch (tokenType) {
+ case TOKEN_EOF:
+ case TOKEN_NONE:
+ case TOKEN_INVALID:
+ /* in this case we are done */
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ rc = SCAN_ERROR;
+ break;
+ case TOKEN_LITERAL_NAME:
+ /* Look up the name */
+ tokenStartP[tokenLength] = '\0';
+ if (InPrivateDict ) {
+ rc = FindDictValue(FontP->Private);
+ /* we are not going to report errors */
+ /* Sometimes the font file may test a value such as */
+ /* testing to see if the font is alreadly loaded with */
+ /* same UniqueID. We would faile on /UniqueID get */
+ /* because we are expecting a int to follow UniqueID*/
+ /* If the correct object type does not follow a Name*/
+ /* then we will skip over it without reporting error except */
+ /* out of memory */
+ if (rc != SCAN_OUT_OF_MEMORY)
+ rc = SCAN_OK;
+ break;
+ } /* end of reading Private dictionary */
+ else
+ if (0 == strncmp(tokenStartP,"Private",7) ) {
+ InPrivateDict = TRUE;
+ rc = BuildCIDType1Private(FontP);
+ break;
+ }
+ else
+ if (WantFontInfo) {
+ rc = FindDictValue(FontP->fontInfoP);
+ /* we are not going to report errors except out of memory */
+ if (rc != SCAN_OUT_OF_MEMORY)
+ rc = SCAN_OK;
+ break;
+ }
+ break;
+ case TOKEN_NAME:
+ if (0 == strncmp(tokenStartP,"currentfile",11)) {
+ currentfilefound = 1;
+ break;
+ } else if (0 == strncmp(tokenStartP,"eexec",5)) {
+ if (currentfilefound == 1) {
+ currentfilefound = 0;
+ filterFile.data.fileP = CIDeexec(inputP->data.fileP);
+ if (filterFile.data.fileP == NULL) {
+ fclose(inputFile.data.fileP);
+ return(SCAN_FILE_OPEN_ERROR);
+ }
+ inputP = &filterFile;
+ } else {
+ rc = SCAN_ERROR;
+ break;
+ }
+ } else if (0 == strncmp(tokenStartP,"begin",5)) {
+ begincnt++;
+ currentfilefound = 0;
+ } else if (0 == strncmp(tokenStartP,"end",3)) {
+ currentfilefound = 0;
+ begincnt--;
+ if (begincnt == 0) {
+ if (filterFile.data.fileP != NULL) {
+ scan_token(inputP); /* get 'currentfile' */
+ scan_token(inputP); /* get 'closefile' */
+ inputP = &inputFile;
+ resetDecrypt();
+ inputP->data.fileP->b_cnt =
+ F_BUFSIZ - (inputP->data.fileP->b_ptr -
+ inputP->data.fileP->b_base);
+ if (inputP->data.fileP->b_cnt > 0) {
+ for (i = 0; i < inputP->data.fileP->b_cnt; i++)
+ if (*(inputP->data.fileP->b_ptr + i) == '%')
+ break;
+ if (i < inputP->data.fileP->b_cnt) {
+ inputP->data.fileP->b_cnt -= i;
+ inputP->data.fileP->b_ptr += i;
+ } else
+ inputP->data.fileP->b_cnt = 0;
+ }
+ }
+ rc = SCAN_OK;
+ return(rc);
+ }
+ if (begincnt < 0) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ }
+ break;
+ }
+
+ }
+ while (rc == 0);
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ return(rc);
+}
+#endif
+
+/*
+ * -------------------------------------------------------------------
+ * Scan the next token and convert it into an object
+ * Result is placed on the Operand Stack as next object
+ * -------------------------------------------------------------------
+ */
+int
+scan_font(psfont *FontP)
+{
+
+
+ char filename[128];
+ char filetype[3];
+ FILE *fileP;
+ char *nameP;
+ int namelen;
+ int V;
+ int i;
+ boolean starthex80;
+
+ starthex80 = FALSE;
+ filetype[0] = 'r';
+ filetype[1] = 'b';
+ filetype[2] = '\0';
+ /* copy the filename and remove leading or trailing blanks */
+ /* point to name and search for leading blanks */
+ nameP= FontP->FontFileName.data.nameP;
+ namelen = FontP->FontFileName.len;
+ while (nameP[0] == ' ') {
+ nameP++;
+ namelen--;
+ }
+ /* now remove any trailing blanks */
+ while ((namelen>0) && ( nameP[namelen-1] == ' ')) {
+ namelen--;
+ }
+ strncpy(filename,nameP,namelen);
+ filename[namelen] = '\0';
+ /* file name is now constructed */
+ inputFile.data.fileP = NULL;
+ filterFile.data.fileP = NULL;
+
+ inputP = &inputFile;
+ if ((fileP = T1Open(filename,filetype))) {
+ /* get the first byte of file */
+ V = _XT1getc(fileP);
+ /* if file starts with x'80' then skip next 5 bytes */
+ if ( V == 0X80 ) {
+ for (i=0;i<5;i++) V = _XT1getc(fileP);
+ starthex80 = TRUE;
+ }
+ else T1Ungetc(V,fileP);
+ objFormatFile(inputP,fileP);
+ }
+ else {
+ return(SCAN_FILE_OPEN_ERROR);
+ };
+
+ WantFontInfo = TRUE;
+ InPrivateDict = FALSE;
+ TwoSubrs = FALSE;
+ rc = BuildFontInfo(FontP);
+ if (rc != 0) return(rc);
+
+ /* Assume everything will be OK */
+ rc = 0;
+
+ /* Loop until complete font is read */
+ do {
+ /* Scan the next token */
+ scan_token(inputP);
+
+ /* ==> tokenLength, tokenTooLong, tokenType, and tokenValue are */
+ /* now set */
+
+ switch (tokenType) {
+ case TOKEN_EOF:
+ case TOKEN_NONE:
+ case TOKEN_INVALID:
+ /* in this case we are done */
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ rc = SCAN_ERROR;
+ break;
+ case TOKEN_LITERAL_NAME:
+ /* Look up the name */
+ tokenStartP[tokenLength] = '\0';
+ if (InPrivateDict ) {
+ if (0== strncmp(tokenStartP,"Subrs",5) ) {
+ rc = BuildSubrs(FontP);
+ break;
+ }
+ if (0== strncmp(tokenStartP,"CharStrings",11) ) {
+ rc = BuildCharStrings(FontP);
+ if ( (rc == SCAN_OK) ||(rc == SCAN_END) ) {
+ T1Close(inputP->data.fileP);
+ /* Build the Blues Structure */
+ rc = GetType1Blues(FontP);
+ /* whatever the return code, return it */
+ /* all the work is done. This is the normal exit.*/
+ return(rc);
+ }
+ break;
+ }
+ rc = FindDictValue(FontP->Private);
+ /* we are not going to report errors */
+ /* Sometimes the font file may test a value such as */
+ /* testing to see if the font is alreadly loaded with */
+ /* same UniqueID. We would faile on /UniqueID get */
+ /* because we are expecting a int to follow UniqueID*/
+ /* If the correct object type does not follow a Name*/
+ /* then we will skip over it without reporting error except */
+ /* when out of memory */
+ if (rc != SCAN_OUT_OF_MEMORY)
+ rc = SCAN_OK;
+ break;
+ } /* end of reading Private dictionary */
+ else
+ if (0== strncmp(tokenStartP,"Private",7) ) {
+ InPrivateDict = TRUE;
+ rc = BuildPrivate(FontP);
+ break;
+ }
+ else
+ if (WantFontInfo) {
+ rc = FindDictValue(FontP->fontInfoP);
+ /* we are not going to report errors except out of memory */
+ if (rc != SCAN_OUT_OF_MEMORY)
+ rc = SCAN_OK;
+ break;
+ }
+ break;
+ case TOKEN_NAME:
+ if (0 == strncmp(tokenStartP,"eexec",5) ) {
+ /* if file started with x'80', check next 5 bytes */
+ if (starthex80) {
+ V = _XT1getc(fileP);
+ if ( V == 0X80 ) {
+ for (i=0;i<5;i++) V = _XT1getc(fileP);
+ }
+ else T1Ungetc(V,fileP);
+ }
+ filterFile.data.fileP = T1eexec(inputP->data.fileP);
+ if (filterFile.data.fileP == NULL) {
+ T1Close(inputFile.data.fileP);
+ return(SCAN_FILE_OPEN_ERROR);
+ }
+ inputP = &filterFile;
+
+ WantFontInfo = FALSE;
+ }
+ break;
+ }
+
+ }
+ while (rc ==0);
+ T1Close(inputP->data.fileP);
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ return(rc);
+}
+
diff --git a/nx-X11/lib/font/Type1/spaces.c b/nx-X11/lib/font/Type1/spaces.c
new file mode 100644
index 000000000..55cc96f67
--- /dev/null
+++ b/nx-X11/lib/font/Type1/spaces.c
@@ -0,0 +1,998 @@
+/* $Xorg: spaces.c,v 1.4 2000/08/17 19:46:32 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/spaces.c,v 3.10tsi Exp $ */
+ /* SPACES CWEB V0021 ******** */
+/*
+:h1 id=spaces.SPACES Module - Handles Coordinate Spaces
+
+This module is responsible for handling the TYPE1IMAGER "XYspace" object.
+
+&author. Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com)
+
+
+:h3.Include Files
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef FONTMODULE
+#include "Xdefs.h" /* Bool declaration ??? */
+#include "Xmd.h" /* INT32 declaration ??? */
+#include "os.h"
+#include "xf86_ansic.h"
+#else
+#include "X11/Xos.h"
+#include <stdio.h>
+#endif
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "pictures.h"
+#include "fonts.h"
+#include "arith.h"
+#include "trig.h"
+
+static void FindFfcn ( double cx, double cy,
+ convertFunc *fcnP );
+static void FindIfcn ( double cx, double cy,
+ fractpel *icxP, fractpel *icyP,
+ iconvertFunc *fcnP );
+
+/*
+:h3.Entry Points Provided to the TYPE1IMAGER User
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h3.Entry Points Provided to Other Modules
+*/
+
+/*
+In addition, other modules call the SPACES module through function
+vectors in the "XYspace" structure. The entry points accessed that
+way are "FConvert()", "IConvert()", and "ForceFloat()".
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Macros and Typedefs Provided to Other Modules
+
+:h4.Duplicating and Killing Spaces
+
+Destroying XYspaces is so simple we can do it with a
+macro:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+On the other hand, duplicating XYspaces is slightly more difficult
+because of the need to keep a unique ID in the space, see
+:hdref refid=dupspace..
+
+:h4.Fixed Point Pel Representation
+
+We represent pel positions with fixed point numbers. This does NOT
+mean integer, but truly means fixed point, with a certain number
+of binary digits (FRACTBITS) representing the fractional part of the
+pel.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h2.Data Structures for Coordinate Spaces and Points
+*/
+/*
+:h3 id=matrix.Matrices
+
+TYPE1IMAGER uses 2x2 transformation matrices. We'll use C notation for
+such a matrix (M[2][2]), the first index being rows, the second columns.
+*/
+
+/*
+:h3.The "doublematrix" Structure
+
+We frequently find it desirable to store both a matrix and its
+inverse. We store these in a "doublematrix" structure.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h3.The "XYspace" Structure
+
+The XYspace structure represents the XYspace object.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+#define RESERVED 10 /* 'n' IDs are reserved for invalid & immortal spaces */
+/*
+*/
+#define NEXTID ((SpaceID < RESERVED) ? (SpaceID = RESERVED) : ++SpaceID)
+
+static unsigned int SpaceID = 1;
+
+struct XYspace *
+CopySpace(struct XYspace *S)
+{
+ S = (struct XYspace *)Allocate(sizeof(struct XYspace), S, 0);
+ S->ID = NEXTID;
+ return(S);
+}
+/*
+:h3.The "fractpoint" Structure
+
+A fractional point is just a "fractpel" x and y:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h3.Lazy Evaluation of Matrix Inverses
+
+Calculating the inverse of a matrix is somewhat involved, and we usually
+do not need them. So, we flag whether or not the space has the inverse
+already calculated:
+*/
+
+#define HASINVERSE(flag) ((flag)&0x80)
+
+/*
+The following macro forces a space to have an inverse:
+*/
+
+#define CoerceInverse(S) if (!HASINVERSE((S)->flag)) { \
+ MatrixInvert((S)->tofract.normal, (S)->tofract.inverse); (S)->flag |= HASINVERSE(ON); }
+/*
+:h3.IDENTITY Space
+
+IDENTITY space is (logically) the space corresponding to the identity
+transformation matrix. However, since all our transformation matrices
+have a common FRACTFLOAT scale factor to convert to 'fractpel's, that
+is actually what we store in 'tofract' matrix of IDENTITY:
+*/
+
+static struct XYspace identity = { SPACETYPE, ISPERMANENT(ON) + ISIMMORTAL(ON)
+ + HASINVERSE(ON), 2, /* added 3-26-91 PNM */
+ NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ INVALIDID + 1, 0,
+ {{{FRACTFLOAT, 0.0}, {0.0, FRACTFLOAT}},
+ {{1.0/FRACTFLOAT, 0.0}, {0.0, 1.0/FRACTFLOAT}}},
+ {{0, 0}, {0, 0}}};
+struct XYspace *IDENTITY = &identity;
+
+/*
+*/
+#define MAXCONTEXTS 16
+
+static struct doublematrix contexts[MAXCONTEXTS];
+
+#ifdef notdef
+
+static int nextcontext = 1;
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h3.FindDeviceContext() - Find the Context Given a Device
+
+This routine, given a device, returns the index of the device's
+transformation matrix in the context array. If it cannot find it,
+it will allocate a new array entry and fill it out.
+*/
+
+static int
+FindDeviceContext(pointer device) /* device token */
+{
+ double M[2][2]; /* temporary matrix */
+ float Xres,Yres; /* device resolution */
+ int orient = -1; /* device orientation */
+ int rc = -1; /* return code for QueryDeviceState */
+
+ if (rc != 0) /* we only bother with this check once */
+ Abort("Context: QueryDeviceState didn't work");
+
+ M[0][0] = M[1][0] = M[0][1] = M[1][1] = 0.0;
+
+ switch (orient) {
+ case 0:
+ M[0][0] = Xres; M[1][1] = -Yres;
+ break;
+ case 1:
+ M[1][0] = Yres; M[0][1] = Xres;
+ break;
+ case 2:
+ M[0][0] = -Xres; M[1][1] = Yres;
+ break;
+ case 3:
+ M[1][0] = -Yres; M[0][1] = -Xres;
+ break;
+ default:
+ Abort("QueryDeviceState returned invalid orientation");
+ }
+ return(FindContext(M));
+}
+
+/*
+:h3.FindContext() - Find the Context Given a Matrix
+
+This routine, given a matrix, returns the index of that matrix matrix in
+the context array. If it cannot find it, it will allocate a new array
+entry and fill it out.
+*/
+
+int
+FindContext(double M[2][2]) /* array to search for */
+{
+ register int i; /* loop variable for search */
+ for (i=0; i < nextcontext; i++)
+ if (M[0][0] == contexts[i].normal[0][0] && M[1][0] == contexts[i].normal[1][0]
+ && M[0][1] == contexts[i].normal[0][1] && M[1][1] == contexts[i].normal[1][1])
+ break;
+
+ if (i >= nextcontext) {
+ if (i >= MAXCONTEXTS)
+ Abort("Context: out of them");
+ LONGCOPY(contexts[i].normal, M, sizeof(contexts[i].normal));
+ MatrixInvert(M, contexts[i].inverse);
+ nextcontext++;
+ }
+
+ return(i);
+}
+
+/*
+:h3.Context() - Create a Coordinate Space for a Device
+
+This user operator is implemented by first finding the device context
+array index, then transforming IDENTITY space to create an appropriate
+cooridnate space.
+*/
+
+struct XYspace *
+Context(pointer device, /* device token */
+ double units) /* multiples of one inch */
+{
+ double M[2][2]; /* device transformation matrix */
+ register int n; /* will hold device context number */
+ register struct XYspace *S; /* XYspace constructed */
+
+ ARGCHECK((device == NULL), "Context of NULLDEVICE not allowed",
+ NULL, IDENTITY, (0), struct XYspace *);
+ ARGCHECK((units == 0.0), "Context: bad units", NULL, IDENTITY, (0), struct XYspace *);
+
+ n = FindDeviceContext(device);
+
+ LONGCOPY(M, contexts[n].normal, sizeof(M));
+
+ M[0][0] *= units;
+ M[0][1] *= units;
+ M[1][0] *= units;
+ M[1][1] *= units;
+
+ S = (struct XYspace *)Xform(IDENTITY, M);
+
+ S->context = n;
+ return(S);
+}
+#endif
+
+/*
+:h3.ConsiderContext() - Adjust a Matrix to Take Out Device Transform
+
+Remember, we have :f/x times U times D/ and :f/M/ and and we want :f/x
+times U times M times D/. An easy way to do this is to calculate
+:f/D sup <-1> times M times D/, because:
+:formula.
+x times U times D times D sup <-1> times M times D = x times U times M times D
+:formula.
+So this subroutine, given an :f/M/and an object, finds the :f/D/ for that
+object and modifies :f/M/ so it is :f/D sup <-1> times M times D/.
+*/
+
+static void
+ConsiderContext(struct xobject *obj, /* object to be transformed */
+ double M[2][2]) /* matrix (may be changed) */
+{
+ register int context = 0; /* index in contexts array */
+
+ if (obj == NULL) return;
+
+ if (ISPATHTYPE(obj->type)) {
+ struct segment *path = (struct segment *) obj;
+
+ context = path->context;
+ }
+ else if (obj->type == SPACETYPE) {
+ struct XYspace *S = (struct XYspace *) obj;
+
+ context = S->context;
+ }
+ else if (obj->type == PICTURETYPE) {
+
+ }
+ else
+ context = NULLCONTEXT;
+
+ if (context != NULLCONTEXT) {
+ MatrixMultiply(contexts[context].inverse, M, M);
+ MatrixMultiply(M, contexts[context].normal, M);
+ }
+}
+
+/*
+:h2.Conversion from User's X,Y to "fractpel" X,Y
+
+When the user is building paths (lines, moves, curves, etc.) he passes
+the control points (x,y) for the paths together with an XYspace. We
+must convert from the user's (x,y) to our internal representation
+which is in pels (fractpels, actually). This involves transforming
+the user's (x,y) under the coordinate space transformation. It is
+important that we do this quickly. So, we store pointers to different
+conversion functions right in the XYspace structure. This allows us
+to have simpler special case functions for the more commonly
+encountered types of transformations.
+
+:h3.Convert(), IConvert(), and ForceFloat() - Called Through "XYspace" Structure
+
+These are functions that fit in the "convert" and "iconvert" function
+pointers in the XYspace structure. They call the "xconvert", "yconvert",
+"ixconvert", and "iyconvert" as appropriate to actually do the work.
+These secondary routines come in many flavors to handle different
+special cases as quickly as possible.
+*/
+
+static void
+FXYConvert(struct fractpoint *pt, /* point to set */
+ struct XYspace *S, /* relevant coordinate space */
+ double x, double y) /* user's coordinates of point */
+{
+ pt->x = (*S->xconvert)(S->tofract.normal[0][0], S->tofract.normal[1][0], x, y);
+ pt->y = (*S->yconvert)(S->tofract.normal[0][1], S->tofract.normal[1][1], x, y);
+}
+
+static void
+IXYConvert(struct fractpoint *pt, /* point to set */
+ struct XYspace *S, /* relevant coordinate space */
+ long x, long y) /* user's coordinates of point */
+{
+ pt->x = (*S->ixconvert)(S->itofract[0][0], S->itofract[1][0], x, y);
+ pt->y = (*S->iyconvert)(S->itofract[0][1], S->itofract[1][1], x, y);
+}
+
+/*
+ForceFloat is a substitute for IConvert(), when we just do not have
+enough significant digits in the coefficients to get high enough
+precision in the answer with fixed point arithmetic. So, we force the
+integers to floats, and do the arithmetic all with floats:
+*/
+
+static void
+ForceFloat(struct fractpoint *pt, /* point to set */
+ struct XYspace *S, /* relevant coordinate space */
+ long x, long y) /* user's coordinates of point */
+{
+ (*S->convert)(pt, S, (double) x, (double) y);
+}
+
+/*
+:h3.FXYboth(), FXonly(), FYonly() - Floating Point Conversion
+
+These are the routines we use when the user has given us floating
+point numbers for x and y. FXYboth() is the general purpose routine;
+FXonly() and FYonly() are special cases when one of the coefficients
+is 0.0.
+*/
+
+static fractpel
+FXYboth(double cx, double cy, /* x and y coefficients */
+ double x, double y) /* user x,y */
+{
+ register double r; /* temporary float */
+
+ r = x * cx + y * cy;
+ return((fractpel) r);
+}
+
+/*ARGSUSED*/
+static fractpel
+FXonly(double cx, double cy, /* x and y coefficients */
+ double x, double y) /* user x,y */
+{
+ register double r; /* temporary float */
+
+ r = x * cx;
+ return((fractpel) r);
+}
+
+/*ARGSUSED*/
+static fractpel
+FYonly(double cx, double cy, /* x and y coefficients */
+ double x, double y) /* user x,y */
+{
+ register double r; /* temporary float */
+
+ r = y * cy;
+ return((fractpel) r);
+}
+
+/*
+:h3.IXYboth(), IXonly(), IYonly() - Simple Integer Conversion
+
+These are the routines we use when the user has given us integers for
+x and y, and the coefficients have enough significant digits to
+provide precise answers with only "long" (32 bit?) multiplication.
+IXYboth() is the general purpose routine; IXonly() and IYonly() are
+special cases when one of the coefficients is 0.
+*/
+
+static fractpel
+IXYboth(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
+{
+ return(x * cx + y * cy);
+}
+
+/*ARGSUSED*/
+static fractpel
+IXonly(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
+{
+ return(x * cx);
+}
+
+/*ARGSUSED*/
+static fractpel
+IYonly(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
+{
+ return(y * cy);
+}
+
+
+/*
+:h3.FPXYboth(), FPXonly(), FPYonly() - More Involved Integer Conversion
+
+These are the routines we use when the user has given us integers for
+x and y, but the coefficients do not have enough significant digits to
+provide precise answers with only "long" (32 bit?) multiplication.
+We have increased the number of significant bits in the coefficients
+by FRACTBITS; therefore we must use "double long" (64 bit?)
+multiplication by calling FPmult(). FPXYboth() is the general purpose
+routine; FPXonly() and FPYonly() are special cases when one of the
+coefficients is 0.
+
+Note that it is perfectly possible for us to calculate X with the
+"FP" method and Y with the "I" method, or vice versa. It all depends
+on how the functions in the XYspace structure are filled out.
+*/
+
+static fractpel
+FPXYboth(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
+{
+ return( FPmult(x, cx) + FPmult(y, cy) );
+}
+
+/*ARGSUSED*/
+static fractpel
+FPXonly(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
+{
+ return( FPmult(x, cx) );
+}
+
+/*ARGSUSED*/
+static fractpel
+FPYonly(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
+{
+ return( FPmult(y, cy) );
+}
+
+
+
+/*
+:h3.FillOutFcns() - Determine the Appropriate Functions to Use for Conversion
+
+This function fills out the "convert" and "iconvert" function pointers
+in an XYspace structure, and also fills the "helper"
+functions that actually do the work.
+*/
+
+static void
+FillOutFcns(struct XYspace *S) /* functions will be set in this structure */
+{
+ S->convert = FXYConvert;
+ S->iconvert = IXYConvert;
+
+ FindFfcn(S->tofract.normal[0][0], S->tofract.normal[1][0], &S->xconvert);
+ FindFfcn(S->tofract.normal[0][1], S->tofract.normal[1][1], &S->yconvert);
+ FindIfcn(S->tofract.normal[0][0], S->tofract.normal[1][0],
+ &S->itofract[0][0], &S->itofract[1][0], &S->ixconvert);
+ FindIfcn(S->tofract.normal[0][1], S->tofract.normal[1][1],
+ &S->itofract[0][1], &S->itofract[1][1], &S->iyconvert);
+
+ if (S->ixconvert == NULL || S->iyconvert == NULL)
+ S->iconvert = ForceFloat;
+}
+
+/*
+:h4.FindFfcn() - Subroutine of FillOutFcns() to Fill Out Floating Functions
+
+This function tests for the special case of one of the coefficients
+being zero:
+*/
+
+static void
+FindFfcn(double cx, double cy, /* x and y coefficients */
+ convertFunc *fcnP) /* pointer to function to set */
+{
+ if (cx == 0.0)
+ *fcnP = FYonly;
+ else if (cy == 0.0)
+ *fcnP = FXonly;
+ else
+ *fcnP = FXYboth;
+}
+
+/*
+:h4.FindIfcn() - Subroutine of FillOutFcns() to Fill Out Integer Functions
+
+There are two types of integer functions, the 'I' type and the 'FP' type.
+We use the I type functions when we are satisfied with simple integer
+arithmetic. We used the FP functions when we feel we need higher
+precision (but still fixed point) arithmetic. If all else fails,
+we store a NULL indicating that this we should do the conversion in
+floating point.
+*/
+
+static void
+FindIfcn(double cx, double cy, /* x and y coefficients */
+ fractpel *icxP, fractpel *icyP, /* fixed point coefficients to set */
+ iconvertFunc *fcnP) /* pointer to function to set */
+{
+ register fractpel imax; /* maximum of cx and cy */
+
+ *icxP = cx;
+ *icyP = cy;
+
+ if (cx != (float) (*icxP) || cy != (float) (*icyP)) {
+/*
+At this point we know our integer approximations of the coefficients
+are not exact. However, we will still use them if the maximum
+coefficient will not fit in a 'fractpel'. Of course, we have little
+choice at that point, but we haven't lost that much precision by
+staying with integer arithmetic. We have enough significant digits
+so that
+any error we introduce is less than one part in 2:sup/16/.
+*/
+
+ imax = MAX(ABS(*icxP), ABS(*icyP));
+ if (imax < (fractpel) (1<<(FRACTBITS-1)) ) {
+/*
+At this point we know our integer approximations just do not have
+enough significant digits for accuracy. We will add FRACTBITS
+significant digits to the coefficients (by multiplying them by
+1<<FRACTBITS) and go to the "FP" form of the functions. First, we
+check to see if we have ANY significant digits at all (that is, if
+imax == 0). If we don't, we suspect that adding FRACTBITS digits
+won't help, so we punt the whole thing.
+*/
+ if (imax == 0) {
+ *fcnP = NULL;
+ return;
+ }
+ cx *= FRACTFLOAT;
+ cy *= FRACTFLOAT;
+ *icxP = cx;
+ *icyP = cy;
+ *fcnP = FPXYboth;
+ }
+ else
+ *fcnP = IXYboth;
+ }
+ else
+ *fcnP = IXYboth;
+/*
+Now we check for special cases where one coefficient is zero (after
+integer conversion):
+*/
+ if (*icxP == 0)
+ *fcnP = (*fcnP == FPXYboth) ? FPYonly : IYonly;
+ else if (*icyP == 0)
+ *fcnP = (*fcnP == FPXYboth) ? FPXonly : IXonly;
+}
+/*
+:h3.UnConvert() - Find User Coordinates From FractPoints
+
+The interesting thing with this routine is that we avoid calculating
+the matrix inverse of the device transformation until we really need
+it, which is to say, until this routine is called for the first time
+with a given coordinate space.
+
+We also only calculate it only once. If the inverted matrix is valid,
+we don't calculate it; if not, we do. We never expect matrices with
+zero determinants, so by convention, we mark the matrix is invalid by
+marking both X terms zero.
+*/
+
+void
+UnConvert(struct XYspace *S, /* relevant coordinate space */
+ struct fractpoint *pt, /* device coordinates */
+ double *xp, double *yp) /* where to store resulting x,y */
+{
+ double x,y;
+
+ CoerceInverse(S);
+ x = pt->x;
+ y = pt->y;
+ *xp = S->tofract.inverse[0][0] * x + S->tofract.inverse[1][0] * y;
+ *yp = S->tofract.inverse[0][1] * x + S->tofract.inverse[1][1] * y;
+}
+
+/*
+:h2.Transformations
+*/
+/*
+:h3 id=xform.Xform() - Transform Object in X and Y
+
+TYPE1IMAGER wants transformations of objects like paths to be identical
+to transformations of spaces. For example, if you scale a line(1,1)
+by 10 it should yield the same result as generating the line(1,1) in
+a coordinate space that has been scaled by 10.
+
+We handle fonts by storing the accumulated transform, for example, SR
+(accumulating on the right). Then when we map the font through space TD,
+for example, we multiply the accumulated font transform on the left by
+the space transform on the right, yielding SRTD in this case. We will
+get the same result if we did S, then R, then T on the space and mapping
+an unmodified font through that space.
+*/
+
+struct xobject *
+t1_Xform(struct xobject *obj, /* object to transform */
+ double M[2][2]) /* transformation matrix */
+{
+ if (obj == NULL)
+ return(NULL);
+
+ if (obj->type == FONTTYPE) {
+ register struct font *F = (struct font *) obj;
+
+ F = UniqueFont(F);
+ return((struct xobject*)F);
+ }
+ if (obj->type == PICTURETYPE) {
+/*
+In the case of a picture, we choose both to update the picture's
+transformation matrix and keep the handles up to date.
+*/
+ register struct picture *P = (struct picture *) obj;
+ register struct segment *handles; /* temporary path to transform handles */
+
+ P = UniquePicture(P);
+ handles = PathSegment(LINETYPE, P->origin.x, P->origin.y);
+ handles = Join(handles,
+ PathSegment(LINETYPE, P->ending.x, P->ending.y) );
+ handles = (struct segment *)Xform((struct xobject *) handles, M);
+ P->origin = handles->dest;
+ P->ending = handles->link->dest;
+ KillPath(handles);
+ return((struct xobject *)P);
+ }
+
+ if (ISPATHTYPE(obj->type)) {
+ struct XYspace pseudo; /* local temporary space */
+ PseudoSpace(&pseudo, M);
+ return((struct xobject *) PathTransform((struct segment *)obj,
+ &pseudo));
+ }
+
+
+ if (obj->type == SPACETYPE) {
+ register struct XYspace *S = (struct XYspace *) obj;
+
+/* replaced ISPERMANENT(S->flag) with S->references > 1 3-26-91 PNM */
+ if (S->references > 1)
+ S = CopySpace(S);
+ else
+ S->ID = NEXTID;
+
+ MatrixMultiply(S->tofract.normal, M, S->tofract.normal);
+ /*
+ * mark inverted matrix invalid:
+ */
+ S->flag &= ~HASINVERSE(ON);
+
+ FillOutFcns(S);
+ return((struct xobject *) S);
+ }
+
+ return(ArgErr("Untransformable object", obj, obj));
+}
+
+/*
+:h3.Transform() - Transform an Object
+
+This is the external user's entry point.
+*/
+struct xobject *
+t1_Transform(struct xobject *obj,
+ double cxx, double cyx, /* 2x2 transform matrix elements */
+ double cxy, double cyy) /* in row order */
+{
+ double M[2][2];
+
+ M[0][0] = cxx;
+ M[0][1] = cyx;
+ M[1][0] = cxy;
+ M[1][1] = cyy;
+ ConsiderContext(obj, M);
+ return(Xform(obj, M));
+}
+/*
+:h3.Scale() - Special Case of Transform()
+
+This is a user operator.
+*/
+
+struct xobject *
+t1_Scale(struct xobject *obj, /* object to scale */
+ double sx, double sy) /* scale factors in x and y */
+{
+ double M[2][2];
+
+ M[0][0] = sx;
+ M[1][1] = sy;
+ M[1][0] = M[0][1] = 0.0;
+ ConsiderContext(obj, M);
+ return(Xform(obj, M));
+}
+
+/*
+:h3 id=rotate.Rotate() - Special Case of Transform()
+
+We special-case different settings of 'degrees' for performance
+and accuracy within the DegreeSin() and DegreeCos() routines themselves.
+*/
+
+#ifdef notdef
+struct xobject *
+xiRotate(struct xobject *obj, /* object to be transformed */
+ double degrees) /* degrees of COUNTER-clockwise rotation */
+{
+ double M[2][2];
+
+ M[0][0] = M[1][1] = DegreeCos(degrees);
+ M[1][0] = - (M[0][1] = DegreeSin(degrees));
+ ConsiderContext(obj, M);
+ return(Xform(obj, M));
+}
+#endif
+
+/*
+:h3.PseudoSpace() - Build a Coordinate Space from a Matrix
+
+Since we have built all this optimized code that, given an (x,y) and
+a coordinate space, yield transformed (x,y), it seems a shame not to
+use the same logic when we need to multiply an (x,y) by an arbitrary
+matrix that is not (initially) part of a coordinate space. This
+subroutine takes the arbitrary matrix and builds a coordinate
+space, with all its nifty function pointers.
+*/
+
+void
+PseudoSpace(struct XYspace *S, /* coordinate space structure to fill out */
+ double M[2][2]) /* matrix that will become 'tofract.normal' */
+{
+ S->type = SPACETYPE;
+ S->flag = ISPERMANENT(ON) + ISIMMORTAL(ON);
+ S->references = 2; /* 3-26-91 added PNM */
+ S->tofract.normal[0][0] = M[0][0];
+ S->tofract.normal[1][0] = M[1][0];
+ S->tofract.normal[0][1] = M[0][1];
+ S->tofract.normal[1][1] = M[1][1];
+
+ FillOutFcns(S);
+}
+
+/*
+:h2 id=matrixa.Matrix Arithmetic
+
+Following the convention in Newman and Sproull, :hp1/Interactive
+Computer Graphics/,
+matrices are organized:
+:xmp.
+ | cxx cyx |
+ | cxy cyy |
+:exmp.
+A point is horizontal, for example:
+:xmp.
+ [ x y ]
+:exmp.
+This means that:
+:formula/x prime = cxx times x + cxy times y/
+:formula/y prime = cyx times x + cyy times y/
+I've seen the other convention, where transform matrices are
+transposed, equally often in the literature.
+*/
+
+/*
+:h3.MatrixMultiply() - Implements Multiplication of Two Matrices
+
+Implements matrix multiplication, A * B = C.
+
+To remind myself, matrix multiplication goes rows of A times columns
+of B.
+The output matrix may be the same as one of the input matrices.
+*/
+void
+MatrixMultiply(double A[2][2], double B[2][2], /* input matrices */
+ double C[2][2]) /* output matrix */
+{
+ register double txx,txy,tyx,tyy;
+
+ txx = A[0][0] * B[0][0] + A[0][1] * B[1][0];
+ txy = A[1][0] * B[0][0] + A[1][1] * B[1][0];
+ tyx = A[0][0] * B[0][1] + A[0][1] * B[1][1];
+ tyy = A[1][0] * B[0][1] + A[1][1] * B[1][1];
+
+ C[0][0] = txx;
+ C[1][0] = txy;
+ C[0][1] = tyx;
+ C[1][1] = tyy;
+}
+/*
+:h3.MatrixInvert() - Invert a Matrix
+
+My reference for matrix inversion was :hp1/Elementary Linear Algebra/
+by Paul C. Shields, Worth Publishers, Inc., 1968.
+*/
+void
+MatrixInvert(double M[2][2], /* input matrix */
+ double Mprime[2][2]) /* output inverted matrix */
+{
+ register double D; /* determinant of matrix M */
+ register double txx,txy,tyx,tyy;
+
+ txx = M[0][0];
+ txy = M[1][0];
+ tyx = M[0][1];
+ tyy = M[1][1];
+
+ D = M[1][1] * M[0][0] - M[1][0] * M[0][1];
+ if (D == 0.0)
+ Abort("MatrixInvert: can't");
+
+ Mprime[0][0] = tyy / D;
+ Mprime[1][0] = -txy / D;
+ Mprime[0][1] = -tyx / D;
+ Mprime[1][1] = txx / D;
+}
+/*
+:h2.Initialization, Queries, and Debug
+*/
+/*
+:h3.InitSpaces() - Initialize Constant Spaces
+
+For compatibility, we initialize a coordinate space called USER which
+maps 72nds of an inch to pels on the default device.
+*/
+
+struct XYspace *USER = &identity;
+
+void
+InitSpaces(void)
+{
+ IDENTITY->type = SPACETYPE;
+ FillOutFcns(IDENTITY);
+
+ contexts[NULLCONTEXT].normal[1][0]
+ = contexts[NULLCONTEXT].normal[0][1]
+ = contexts[NULLCONTEXT].inverse[1][0]
+ = contexts[NULLCONTEXT].inverse[0][1] = 0.0;
+ contexts[NULLCONTEXT].normal[0][0]
+ = contexts[NULLCONTEXT].normal[1][1]
+ = contexts[NULLCONTEXT].inverse[0][0]
+ = contexts[NULLCONTEXT].inverse[1][1] = 1.0;
+
+ USER->flag |= ISIMMORTAL(ON);
+ CoerceInverse(USER);
+}
+/*
+:h3.QuerySpace() - Returns the Transformation Matrix of a Space
+
+Since the tofract matrix of an XYspace includes the scale factor
+necessary to produce fractpel results (i.e., FRACTFLOAT), this
+must be taken out before we return the matrix to the user. Fortunately,
+this is simple: just multiply by the inverse of IDENTITY!
+*/
+
+void
+QuerySpace(struct XYspace *S, /* space asked about */
+ double *cxxP, double *cyxP, /* where to put answer */
+ double *cxyP, double *cyyP)
+{
+ double M[2][2]; /* temp matrix to build user's answer */
+
+ if (S->type != SPACETYPE) {
+ ArgErr("QuerySpace: not a space", S, NULL);
+ return;
+ }
+ MatrixMultiply(S->tofract.normal, IDENTITY->tofract.inverse, M);
+ *cxxP = M[0][0];
+ *cxyP = M[1][0];
+ *cyxP = M[0][1];
+ *cyyP = M[1][1];
+}
+
+/*
+:h3.FormatFP() - Format a Fixed Point Pel
+
+We format the pel as "dddd.XXXX", where XX's are hexidecimal digits,
+and the dd's are decimal digits. This might be a little confusing
+mixing hexidecimal and decimal like that, but it is convenient
+to use for debug.
+
+We make sure we have N (FRACTBITS/4) digits past the decimal point.
+*/
+#define FRACTMASK ((1<<FRACTBITS)-1) /* mask for fractional part */
+
+void
+FormatFP(char *string, /* output string */
+ fractpel fpel) /* fractional pel input */
+{
+ char temp[8];
+ register char *s;
+ register char *sign;
+
+ if (fpel < 0) {
+ sign = "-";
+ fpel = -fpel;
+ }
+ else
+ sign = "";
+
+ sprintf(temp, "000%lx", fpel & FRACTMASK);
+ s = temp + strlen(temp) - (FRACTBITS/4);
+
+ sprintf(string, "%s%d.%sx", sign, (int)(fpel >> FRACTBITS), s);
+}
+
+/*
+:h3.DumpSpace() - Display a Coordinate Space
+*/
+/*ARGSUSED*/
+void
+DumpSpace(struct XYspace *S)
+{
+}
diff --git a/nx-X11/lib/font/Type1/spaces.h b/nx-X11/lib/font/Type1/spaces.h
new file mode 100644
index 000000000..ef78f2f47
--- /dev/null
+++ b/nx-X11/lib/font/Type1/spaces.h
@@ -0,0 +1,172 @@
+/* $Xorg: spaces.h,v 1.3 2000/08/17 19:46:32 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/spaces.h,v 3.3 1999/08/22 08:58:53 dawes Exp $ */
+
+/*SHARED*/
+
+#define USER t1_User
+#define IDENTITY t1_Identity
+
+#define Context(d,u) t1_Context(d,u)
+#define Transform(o,f1,f2,f3,f4) t1_Transform(o,f1,f2,f3,f4)
+#define Rotate(o,d) t1_Rotate(o,d)
+#define Scale(o,sx,sy) t1_Scale(o,sx,sy)
+#define QuerySpace(S,f1,f2,f3,f4) t1_QuerySpace(S,f1,f2,f3,f4)
+#define Warp(s1,o,s2) t1_Warp(s1,o,s2)
+
+/* IDENTITY space */
+extern struct XYspace *IDENTITY;
+
+/* creates a coordinate space for a device */
+extern struct XYspace *Context(pointer device, double units);
+/* transform an object */
+extern struct xobject *t1_Transform ( struct xobject *obj, double cxx,
+ double cyx, double cxy, double cyy );
+#if 0
+struct xobject *t1_Rotate(); /* rotate an object */
+#endif
+/* scale an object */
+extern struct xobject *t1_Scale ( struct xobject *obj, double sx, double sy );
+#if 0
+struct xobject *t1_Warp(); /* transform like delta of two spaces */
+#endif
+/* returns coordinate space matrix */
+extern void t1_QuerySpace ( struct XYspace *S, double *cxxP, double *cyxP,
+ double *cxyP, double *cyyP );
+
+/*END SHARED*/
+/*SHARED*/
+
+/* #define KillSpace(s) Free(s)
+Note - redefined KillSpace() to check references !
+3-26-91 PNM */
+
+#define KillSpace(s) if ( (--(s->references) == 0) ||\
+ ( (s->references == 1) && ISPERMANENT(s->flag) ) )\
+ Free(s)
+
+#define ConsumeSpace(s) MAKECONSUME(s,KillSpace(s))
+#define UniqueSpace(s) MAKEUNIQUE(s,CopySpace(s))
+
+/*END SHARED*/
+/*SHARED*/
+
+typedef short pel; /* integer pel locations */
+typedef long fractpel; /* fractional pel locations */
+
+#define FRACTBITS 16 /* number of fractional bits in 'fractpel' */
+/*
+We define the following macros to convert from 'fractpel' to 'pel' and
+vice versa:
+*/
+#define TOFRACTPEL(p) (((fractpel)p)<<FRACTBITS)
+#define FPHALF (1<<(FRACTBITS-1))
+#define NEARESTPEL(fp) (((fp)+FPHALF)>>FRACTBITS)
+#define FRACTFLOAT (double)(1L<<FRACTBITS)
+
+/*END SHARED*/
+/*SHARED*/
+
+struct doublematrix {
+ double normal[2][2];
+ double inverse[2][2];
+} ;
+
+/*END SHARED*/
+/*SHARED*/
+
+struct fractpoint {
+ fractpel x,y;
+} ;
+
+/*SHARED*/
+
+typedef fractpel (*convertFunc)(double, double, double, double);
+typedef fractpel (*iconvertFunc)(fractpel, fractpel, long, long);
+
+struct XYspace {
+ XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
+ /* type = SPACETYPE */
+ void (*convert)(struct fractpoint *, struct XYspace *, double, double); /* calculate "fractpoint" X,Y from float X,Y */
+ void (*iconvert)(struct fractpoint *, struct XYspace *, long, long); /* calculate "fractpoint" X,Y from int X,Y */
+ convertFunc xconvert; /* subroutine of convert */
+ convertFunc yconvert; /* subroutine of convert */
+ iconvertFunc ixconvert; /* subroutine of iconvert */
+ iconvertFunc iyconvert; /* subroutine of iconvert */
+ int ID; /* unique identifier (used in font caching) */
+ unsigned char context; /* device context of coordinate space */
+ struct doublematrix tofract; /* xform to get to fractional pels */
+ fractpel itofract[2][2]; /* integer version of "tofract.normal" */
+} ;
+
+#define INVALIDID 0 /* no valid space will have this ID */
+
+/*END SHARED*/
+/*END SHARED*/
+/*SHARED*/
+
+#define DeviceResolution t1_DeviceResolution
+#define InitSpaces t1_InitSpaces
+#define CopySpace(s) t1_CopySpace(s)
+#define Xform(o,M) t1_Xform(o,M)
+#define UnConvert(S,pt,xp,yp) t1_UnConvert(S,pt,xp,yp)
+#define MatrixMultiply(A,B,C) t1_MMultiply(A,B,C)
+#define MatrixInvert(A,B) t1_MInvert(A,B)
+#define PseudoSpace(S,M) t1_PseudoSpace(S,M)
+#define FindContext(M) t1_FindContext(M)
+
+/* initialize pre-defined coordinate spaces */
+extern void t1_InitSpaces ( void );
+/* duplicate a coordinate space */
+extern struct XYspace *t1_CopySpace ( struct XYspace *S );
+/* transform object by matrix */
+extern struct xobject *t1_Xform ( struct xobject *obj, double M[2][2] );
+/* return user coordinates from device coordinates */
+extern void t1_UnConvert ( struct XYspace *S, struct fractpoint *pt,
+ double *xp, double *yp );
+/* multiply two matrices */
+extern void t1_MMultiply ( double A[2][2], double B[2][2], double C[2][2] );
+/* invert a matrix */
+extern void t1_MInvert ( double M[2][2], double Mprime[2][2] );
+/* force a coordinate space from a matrix */
+extern void t1_PseudoSpace ( struct XYspace *S, double M[2][2] );
+/* return the "context" represented by a matrix */
+int t1_FindContext(double M[2][2]);
+
+/*END SHARED*/
+/*SHARED*/
+
+#define NULLCONTEXT 0
+
+/*END SHARED*/
+
+/* dump a coordinate space structure */
+extern void t1_DumpSpace ( struct XYspace *S );
+/* dump a format a "fractpel" coordinate */
+extern void t1_FormatFP ( char *string, fractpel fpel );
diff --git a/nx-X11/lib/font/Type1/strokes.h b/nx-X11/lib/font/Type1/strokes.h
new file mode 100644
index 000000000..c374e16db
--- /dev/null
+++ b/nx-X11/lib/font/Type1/strokes.h
@@ -0,0 +1,38 @@
+/* $Xorg: strokes.h,v 1.3 2000/08/17 19:46:32 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/*STUB*/
+
+#define CopyLineStyle(s) s
+#define CopyStrokePath(p) p
+#define KillStrokePath(p)
+#define KillLineStyle(s)
+#define CoercePath(sp) sp
+#define DoStroke(sp) sp
+
diff --git a/nx-X11/lib/font/Type1/t1funcs.c b/nx-X11/lib/font/Type1/t1funcs.c
new file mode 100644
index 000000000..9de819a0d
--- /dev/null
+++ b/nx-X11/lib/font/Type1/t1funcs.c
@@ -0,0 +1,1668 @@
+/* $Xorg: t1funcs.c,v 1.5 2001/02/09 02:04:01 xorgcvs Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License, subject to the license given below, 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software
+ * without specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ *
+ * Author: Jeffrey B. Lotspiech, IBM Almaden Research Center
+ * Modeled on spfuncs.c by Dave Lemke, Network Computing Devices, Inc
+ * which contains the following copyright and permission notices:
+ *
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing Devices
+ * or Digital not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Network Computing Devices or Digital make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR 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 (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/t1funcs.c,v 3.33 2003/07/19 13:16:40 tsi Exp $ */
+
+/*
+
+Copyright 1987, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#ifndef FONTMODULE
+#include <string.h>
+#if XFONT_CID
+#include <stdlib.h>
+#include <sys/types.h>
+#include <dirent.h>
+#endif
+#ifdef _XOPEN_SOURCE
+#include <math.h>
+#else
+#define _XOPEN_SOURCE /* to get prototype for hypot on some systems */
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+#include "X11/Xfuncs.h"
+#ifdef USE_MMAP
+#include <sys/types.h>
+#include <sys/mman.h>
+#endif
+#else
+#include "Xmd.h"
+#include "Xdefs.h"
+#endif
+
+#ifdef FONTMODULE
+#include "os.h"
+#include "xf86_ansic.h"
+#endif
+
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/fontutil.h>
+#include <X11/fonts/FSproto.h>
+#include <X11/fonts/fontenc.h>
+#include "t1unicode.h"
+
+#if XFONT_CID
+#include "range.h"
+#endif
+
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h"
+#include "t1stdio.h"
+#include "util.h"
+#include "fontfcn.h"
+#include "t1intf.h"
+
+
+static int Type1GetGlyphs ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, CharInfoPtr *glyphs );
+
+#if XFONT_CID
+#define CMapDir "/CMap/"
+#define CFMDir "/CFM/"
+#define CIDFontDir "/CIDFont/"
+#endif
+
+static int Type1GetMetrics ( FontPtr pFont, unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount,
+ xCharInfo **glyphs );
+
+
+#define minchar(p) ((p).min_char_low + ((p).min_char_high << 8))
+#define maxchar(p) ((p).max_char_low + ((p).max_char_high << 8))
+
+static void fillrun ( char *p, pel x0, pel x1, int bit );
+
+extern psfont *FontP;
+extern psobj *ISOLatin1EncArrayP;
+
+#if XFONT_CID
+extern char CurCIDFontName[];
+extern char CurCMapName[];
+
+static CharInfoPtr CIDGetGlyph ( FontPtr pFont, unsigned int charcode,
+ CharInfoPtr pci );
+
+extern cidfont *CIDFontP;
+extern cmapres *CMapP;
+#endif
+
+static void fill ( char *dest, int h, int w, struct region *area, int byte,
+ int bit, int wordsize );
+
+#if XFONT_CID
+int
+CIDOpenScalable (FontPathElementPtr fpe,
+ FontPtr *ppFont,
+ int flags,
+ FontEntryPtr entry,
+ char *fileName,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font) /* We don't do licensing */
+{
+ FontPtr pFont;
+ int bit,
+ byte,
+ glyph,
+ scan,
+ image;
+ long *pool; /* memory pool for ximager objects */
+ int size; /* for memory size calculations */
+ struct XYspace *S; /* coordinate space for character */
+ register int i;
+ int nchars, len, rc;
+ cidglyphs *cid;
+ char *p;
+ double t1 = .001, t2 = 0.0, t3 = 0.0, t4 = .001;
+ double sxmult;
+ char CIDFontName[CID_NAME_MAX];
+ char CMapName[CID_NAME_MAX];
+ char cidfontname[CID_PATH_MAX];
+ char cmapname[CID_PATH_MAX];
+ char *path;
+ char cidfontpath[CID_PATH_MAX];
+ char cmappath[CID_PATH_MAX];
+#if defined(HAVE_CFM) || defined(CID_ALL_CHARS)
+ char cfmdir[CID_PATH_MAX];
+ char cfmfilename[CID_NAME_MAX];
+#endif
+#if defined(CID_ALL_CHARS)
+ char *cf;
+#else
+ long sAscent, sDescent;
+#endif
+
+ /* check the font name */
+ len = strlen(fileName);
+ if (len <= 0 || len > CID_NAME_MAX - 1)
+ return BadFontName;
+
+#if defined(HAVE_CFM) || defined(CID_ALL_CHARS)
+ strcpy(cfmdir, fileName);
+ p = strrchr(cfmdir, '/');
+ if (p) *p = '\0';
+#endif
+
+ path = fileName;
+ if (!(fileName = strrchr(fileName, '/')))
+ return BadFontName;
+
+ len = fileName - path;
+ strncpy(cidfontpath, path, len);
+ cidfontpath[len] = '\0';
+ strcpy(cmappath, cidfontpath);
+ strcat(cmappath, CMapDir);
+#ifdef HAVE_CFM
+ strcpy(cfmdir, cidfontpath);
+ strcat(cfmdir, CFMDir);
+#endif
+ strcat(cidfontpath, CIDFontDir);
+
+ fileName++;
+
+ /* extract the CIDFontName and CMapName from the font name */
+ /* check for <CIDFontName>--<CMapName> */
+ if ((p = strstr(fileName, "--"))) {
+ if (p == fileName)
+ return BadFontName;
+ else {
+ strcpy(CIDFontName, fileName);
+ CIDFontName[p - fileName] = '\0';
+ p += 2;
+ i = 0;
+ while (*p && *p != '.')
+ CMapName[i++] = *p++;
+ CMapName[i] = '\0';
+ if ((len = strlen(CMapName)) <= 0)
+ return BadFontName;
+ }
+ } else
+ return BadFontName;
+
+ /* The CMap files whose names end with -V are not yet supported */
+ len = strlen(CMapName);
+ if ((len >= 2 && CMapName[len - 2] == '-' && CMapName[len - 1] == 'V') ||
+ (len == 1 && CMapName[len - 1] == 'V'))
+ return BadFontName;
+
+ /* Reject ridiculously small font sizes that will blow up the math */
+ if (hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]) < 1.0 ||
+ hypot(vals->pixel_matrix[2], vals->pixel_matrix[3]) < 1.0)
+ return BadFontName;
+
+#ifdef CID_ALL_CHARS
+ if ((cf = getenv("CFMDIR")) == NULL)
+ strcat(cfmdir, CFMDir);
+ else {
+ strcpy(cfmdir, cf);
+ strcat(cfmdir, "/");
+ }
+#endif
+
+#if defined(HAVE_CFM) || defined(CID_ALL_CHARS)
+ strcpy(cfmfilename, cfmdir);
+ strcat(cfmfilename, CIDFontName);
+ strcat(cfmfilename, "--");
+ strcat(cfmfilename, CMapName);
+ strcat(cfmfilename, ".cfm");
+#endif
+
+ /* create a full-path name for a CIDFont file */
+ if (strlen(cidfontpath) + strlen(CIDFontName) + 2 >
+ CID_PATH_MAX)
+ return BadFontName;
+ strcpy(cidfontname, cidfontpath);
+ strcat(cidfontname, CIDFontName);
+
+ /* create a full-path name for a CMap file */
+ if (strlen(cmappath) + strlen(CMapName) + 2 > CID_PATH_MAX)
+ return BadFontName;
+ strcpy(cmapname, cmappath);
+ strcat(cmapname, CMapName);
+
+ /* set up default values */
+ FontDefaultFormat(&bit, &byte, &glyph, &scan);
+ /* get any changes made from above */
+ rc = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);
+ if (rc != Successful)
+ return rc;
+
+#define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
+
+ if (!(pFont = CreateFontRec()))
+ return AllocError;
+
+ cid = (cidglyphs *)xalloc(sizeof(cidglyphs));
+ if (cid == NULL) {
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+ bzero(cid, sizeof(cidglyphs));
+
+ /* heuristic for "maximum" size of pool we'll need: */
+ size = 200000 + 600 *
+ (int)hypot(vals->pixel_matrix[2], vals->pixel_matrix[3])
+ * sizeof(short);
+ if (size < 0 || NULL == (pool = (long *) xalloc(size))) {
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+
+ addmemory(pool, size);
+
+ /* load font if not already loaded */
+ if (!CIDfontfcnA(cidfontname, cmapname, &rc)) {
+ FontP = NULL;
+ delmemory();
+ xfree(pool);
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return Type1ReturnCodeToXReturnCode(rc);
+ }
+
+ FontP = NULL;
+
+ S = (struct XYspace *) t1_Transform((struct xobject *)IDENTITY,
+ t1, t2, t3, t4);
+
+ S = (struct XYspace *) Permanent(t1_Transform((struct xobject *)S,
+ vals->pixel_matrix[0],
+ -vals->pixel_matrix[1],
+ vals->pixel_matrix[2],
+ -vals->pixel_matrix[3]));
+
+ /* multiplier for computation of raw values */
+ sxmult = hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]);
+ if (sxmult > EPS) sxmult = 1000.0 / sxmult;
+
+ pFont->info.firstRow = CMapP->firstRow;
+ pFont->info.firstCol = CMapP->firstCol;
+ pFont->info.lastRow = CMapP->lastRow;
+ pFont->info.lastCol = CMapP->lastCol;
+
+ nchars = (pFont->info.lastRow - pFont->info.firstRow + 1) *
+ (pFont->info.lastCol - pFont->info.firstCol + 1);
+
+ delmemory();
+ xfree(pool);
+
+ if (pFont->info.firstCol > pFont->info.lastCol)
+ {
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return BadFontName;
+ }
+
+ cid->glyphs = (CharInfoRec **)xalloc(nchars*sizeof(CharInfoRec *));
+ if (cid->glyphs == NULL) {
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+ bzero(cid->glyphs, nchars*sizeof(CharInfoRec *));
+
+ pFont->info.defaultCh = 0;
+ pFont->format = format;
+
+ pFont->bit = bit;
+ pFont->byte = byte;
+ pFont->glyph = glyph;
+ pFont->scan = scan;
+
+ pFont->get_metrics = CIDGetMetrics;
+ pFont->get_glyphs = CIDGetGlyphs;
+ pFont->unload_font = CIDCloseFont;
+ pFont->unload_glyphs = NULL;
+ pFont->refcnt = 0;
+
+ len = strlen(cidfontname);
+ cid->CIDFontName = (char *)xalloc(len + 1);
+ if (cid->CIDFontName == NULL) {
+ xfree(cid->glyphs);
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+ strcpy(cid->CIDFontName, cidfontname);
+
+ len = strlen(cmapname);
+ cid->CMapName = (char *)xalloc(len + 1);
+ if (cid->CMapName == NULL) {
+ xfree(cid->CIDFontName);
+ xfree(cid->glyphs);
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+ strcpy(cid->CMapName, cmapname);
+
+ cid->pixel_matrix[0] = vals->pixel_matrix[0];
+ cid->pixel_matrix[1] = vals->pixel_matrix[1];
+ cid->pixel_matrix[2] = vals->pixel_matrix[2];
+ cid->pixel_matrix[3] = vals->pixel_matrix[3];
+
+ pFont->fontPrivate = (unsigned char *)cid;
+
+ pFont->info.fontAscent =
+ (CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[3].data.integer *
+ vals->pixel_matrix[3] +
+ (CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[3].data.integer >
+ 0 ? 500 : -500)) / 1000;
+
+ pFont->info.fontDescent =
+ -(int)((double)CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[1].data.integer
+ * vals->pixel_matrix[3] +
+ (CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[1].data.integer >
+ 0 ? 500 : -500)) / 1000;
+
+ /* Adobe does not put isFixedPitch entries in CID-keyed fonts. */
+ /* CID-keyed are not constant-width fonts. */
+ pFont->info.constantWidth = 0;
+
+#ifndef CID_ALL_CHARS
+ sAscent = CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[3].data.integer;
+ sDescent = -CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[1].data.integer;
+#endif
+
+ if (strncmp(entry->name.name, "-bogus", 6)) {
+#ifdef CID_ALL_CHARS
+ ComputeBoundsAllChars(pFont, cfmfilename, sxmult);
+#else
+#ifdef HAVE_CFM
+ CIDFillFontInfo(pFont, vals, cidfontname, entry->name.name, cmapname,
+ cfmfilename, sAscent, sDescent, sxmult);
+#else
+ CIDFillFontInfo(pFont, vals, cidfontname, entry->name.name, cmapname,
+ sAscent, sDescent, sxmult);
+#endif /* HAVE_CFM */
+#endif /* CID_ALL_CHARS */
+ }
+
+ *ppFont = pFont;
+
+ return Successful;
+}
+#endif
+
+/*ARGSUSED*/
+int
+Type1OpenScalable (FontPathElementPtr fpe,
+ FontPtr *ppFont,
+ int flags,
+ FontEntryPtr entry,
+ char *fileName,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font) /* We don't do licensing */
+{
+ FontPtr pFont;
+ int bit,
+ byte,
+ glyph,
+ scan,
+ image;
+ int pad,wordsize; /* scan & image in bits */
+ long *pool; /* memory pool for ximager objects */
+ int size; /* for memory size calculations */
+ struct XYspace *S; /* coordinate space for character */
+ struct region *area;
+ CharInfoRec *glyphs;
+ int len, rc, count = 0, i = 0;
+ struct type1font *type1;
+ char *p;
+ FontMapPtr mapping = NULL;
+ int no_mapping;
+ psobj *fontmatrix;
+ long x0, total_width = 0, total_raw_width = 0;
+ double x1, y1, t1 = .001, t2 = 0.0, t3 = 0.0, t4 = .001;
+ double sxmult;
+
+ /* Reject ridiculously small font sizes that will blow up the math */
+ if (hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]) < 1.0 ||
+ hypot(vals->pixel_matrix[2], vals->pixel_matrix[3]) < 1.0)
+ return BadFontName;
+
+ /* set up default values */
+ FontDefaultFormat(&bit, &byte, &glyph, &scan);
+ /* get any changes made from above */
+ rc = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);
+ if (rc != Successful)
+ return rc;
+
+ pad = glyph * 8;
+ wordsize = scan * 8;
+
+#define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
+
+ pFont = CreateFontRec();
+ if (pFont == NULL)
+ return AllocError;
+
+ type1 = (struct type1font *)xalloc(sizeof(struct type1font));
+ if (type1 == NULL) {
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+ bzero(type1, sizeof(struct type1font));
+
+ /* heuristic for "maximum" size of pool we'll need: */
+#if XFONT_CID
+ size = 400000 + 600 *
+#else
+ size = 200000 + 600 *
+#endif
+ (int)hypot(vals->pixel_matrix[2], vals->pixel_matrix[3])
+ * sizeof(short);
+ if (size < 0 || NULL == (pool = (long *) xalloc(size))) {
+ xfree(type1);
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+
+ addmemory(pool, size);
+
+
+ glyphs = type1->glyphs;
+
+ /* load font if not already loaded */
+ if (!fontfcnA(fileName, &rc)) {
+ delmemory();
+ xfree(type1);
+ DestroyFontRec(pFont);
+ xfree(pool);
+ return Type1ReturnCodeToXReturnCode(rc);
+ }
+
+ fontmatrix = &FontP->fontInfoP[FONTMATRIX].value;
+ if (objPIsArray(fontmatrix) && fontmatrix->len == 6)
+ {
+#define assign(n,d,f) if (objPIsInteger(fontmatrix->data.arrayP + n)) \
+ d = fontmatrix->data.arrayP[n].data.integer; \
+ else if (objPIsReal(fontmatrix->data.arrayP + n)) \
+ d = fontmatrix->data.arrayP[n].data.real; \
+ else d = f;
+
+ assign(0, t1, .001);
+ assign(1, t2, 0.0);
+ assign(2, t3, 0.0);
+ assign(3, t4, .001);
+ }
+
+ S = (struct XYspace *) t1_Transform((struct xobject *)IDENTITY,
+ t1, t2, t3, t4);
+
+ S = (struct XYspace *) Permanent(t1_Transform((struct xobject *)S,
+ vals->pixel_matrix[0],
+ -vals->pixel_matrix[1],
+ vals->pixel_matrix[2],
+ -vals->pixel_matrix[3]));
+
+
+ /* multiplier for computation of raw values */
+ sxmult = hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]);
+ if (sxmult > EPS) sxmult = 1000.0 / sxmult;
+
+ no_mapping=0;
+ p = FontEncFromXLFD(entry->name.name, entry->name.length);
+
+ if(p==0) { /* XLFD does not specify an encoding */
+ mapping=0;
+ no_mapping=2; /* ISO 8859-1 */
+ }
+
+ if(!strcmp(p, "adobe-fontspecific")) {
+ mapping=0;
+ no_mapping=1; /* font's native encoding vector */
+ }
+
+ pFont->info.firstCol = 255;
+ pFont->info.lastCol = 0;
+
+ if(!no_mapping) {
+ mapping = FontEncMapFind(p,
+ FONT_ENCODING_POSTSCRIPT, -1, -1,
+ fileName);
+ if(!mapping)
+ mapping = FontEncMapFind(p,
+ FONT_ENCODING_UNICODE, -1, -1,
+ fileName);
+ if(!mapping)
+ goto NoEncoding;
+ else
+ no_mapping=0;
+ }
+
+ for (i=0; i < 256; i++) {
+ long h,w;
+ long paddedW;
+ int j;
+ char *codename;
+
+ if(no_mapping == 1) {
+ codename = FontP->fontInfoP[ENCODING].
+ value.data.arrayP[i].data.valueP;
+ len = FontP->fontInfoP[ENCODING].
+ value.data.arrayP[i].len;
+ } else if(no_mapping) {
+ codename = unicodetoPSname(i);
+ len = codename ? strlen(codename) : 0;
+ } else {
+ if(mapping->type == FONT_ENCODING_UNICODE) {
+ codename = unicodetoPSname(FontEncRecode(i, mapping));
+ } else
+ codename = FontEncName(i, mapping);
+ len=codename?strlen(codename):0;
+ }
+
+ /* Avoid multiply rasterising the undefined glyph */
+ if(len==7 && !strncmp(codename, ".notdef", 7)) {
+ len=0;
+ codename=0;
+ }
+
+ /* But do rasterise it at least once */
+ if(len==0) {
+ if(i==0) {
+ codename=".notdef";
+ len=7;
+ } else
+ continue;
+ }
+
+ /* See if this character is in the list of ranges specified
+ in the XLFD name */
+ if(i!=0) {
+ for (j = 0; j < vals->nranges; j++)
+ if (i >= minchar(vals->ranges[j]) &&
+ i <= maxchar(vals->ranges[j]))
+ break;
+
+ /* If not, don't realize it. */
+ if (vals->nranges && j == vals->nranges)
+ continue;
+ }
+
+ rc = 0;
+ area = (struct region *)fontfcnB(S, (unsigned char *)codename,
+ &len, &rc);
+ if (rc < 0) {
+ rc = Type1ReturnCodeToXReturnCode(rc);
+ break;
+ }
+ else if (rc > 0)
+ continue;
+
+ if (area == NULL)
+ continue;
+
+ if (pFont->info.firstCol > i)
+ pFont->info.firstCol = i;
+ if (pFont->info.lastCol < i)
+ pFont->info.lastCol = i;
+
+ h = area->ymax - area->ymin;
+ w = area->xmax - area->xmin;
+ paddedW = PAD(w, pad);
+
+ if (h > 0 && w > 0) {
+ size = h * paddedW / 8;
+ glyphs[i].bits = (char *)xalloc(size);
+ if (glyphs[i].bits == NULL) {
+ rc = AllocError;
+ break;
+ }
+ }
+ else {
+ size = 0;
+ h = w = 0;
+ area->xmin = area->xmax = 0;
+ area->ymax = area->ymax = 0;
+ }
+
+ glyphs[i].metrics.leftSideBearing = area->xmin;
+ x1 = (double)(x0 = area->ending.x - area->origin.x);
+ y1 = (double)(area->ending.y - area->origin.y);
+ glyphs[i].metrics.characterWidth =
+ (x0 + (x0 > 0 ? FPHALF : -FPHALF)) / (1 << FRACTBITS);
+ if (!glyphs[i].metrics.characterWidth && size == 0)
+ {
+ /* Zero size and zero extents: presumably caused by
+ the choice of transformation. Let's create a
+ small bitmap so we're not mistaken for an undefined
+ character. */
+ h = w = 1;
+ size = paddedW = PAD(w, pad);
+ glyphs[i].bits = (char *)xalloc(size);
+ if (glyphs[i].bits == NULL) {
+ rc = AllocError;
+ break;
+ }
+ }
+ glyphs[i].metrics.attributes =
+ NEARESTPEL((long)(hypot(x1, y1) * sxmult));
+ total_width += glyphs[i].metrics.attributes;
+ total_raw_width += abs((int)(INT16)glyphs[i].metrics.attributes);
+ count++;
+ glyphs[i].metrics.rightSideBearing = w + area->xmin;
+ glyphs[i].metrics.descent = area->ymax - NEARESTPEL(area->origin.y);
+ glyphs[i].metrics.ascent = h - glyphs[i].metrics.descent;
+
+
+ bzero(glyphs[i].bits, size);
+ if (h > 0 && w > 0) {
+ fill(glyphs[i].bits, h, paddedW, area, byte, bit, wordsize );
+ }
+
+ Destroy(area);
+ }
+ NoEncoding:
+
+ delmemory();
+ xfree(pool);
+
+ if (pFont->info.firstCol > pFont->info.lastCol)
+ {
+ xfree(type1);
+ DestroyFontRec(pFont);
+ return BadFontName;
+ }
+
+ if (i != 256) {
+ for (i--; i >= 0; i--)
+ if (glyphs[i].bits != NULL)
+ xfree(glyphs[i].bits);
+ xfree(type1);
+ DestroyFontRec(pFont);
+ return rc;
+ }
+ type1->pDefault = NULL;
+
+ pFont->format = format;
+
+ pFont->bit = bit;
+ pFont->byte = byte;
+ pFont->glyph = glyph;
+ pFont->scan = scan;
+
+ pFont->info.firstRow = 0;
+ pFont->info.lastRow = 0;
+
+ pFont->get_metrics = Type1GetMetrics;
+ pFont->get_glyphs = Type1GetGlyphs;
+ pFont->unload_font = Type1CloseFont;
+ pFont->unload_glyphs = NULL;
+ pFont->refcnt = 0;
+
+ pFont->fontPrivate = (unsigned char *) type1;
+
+ if (count)
+ {
+ total_raw_width = (total_raw_width * 10 + count / 2) / count;
+ if (total_width < 0)
+ {
+ /* Predominant direction is R->L */
+ total_raw_width = -total_raw_width;
+ }
+ vals->width = (int)((double)total_raw_width *
+ vals->pixel_matrix[0] / 1000.0 +
+ (vals->pixel_matrix[0] > 0 ? .5 : -.5));
+ }
+
+ T1FillFontInfo(pFont, vals, fileName, entry->name.name, total_raw_width);
+
+ *ppFont = pFont;
+ return Successful;
+}
+
+#if XFONT_CID
+unsigned int
+getCID(FontPtr pFont, unsigned int charcode)
+{
+ unsigned int cidcode = 0;
+ Bool charvalid = FALSE;
+ cidglyphs *cid;
+ int i, j;
+ unsigned int char_row, char_col, rangelo_row, rangelo_col, k;
+ unsigned int rangehi_row, rangehi_col;
+ spacerange *spacerangeP;
+ cidrange *notdefrangeP, *cidrangeP;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ if (cid == NULL)
+ return cidcode;
+
+ char_row = (charcode >> 8) & 0xff;
+ char_col = charcode & 0xff;
+
+ spacerangeP = CIDFontP->spacerangeP;
+ for (i = 0; i < CIDFontP->spacerangecnt; i++) {
+ for (j = 0; j < spacerangeP->rangecnt; j++) {
+ rangelo_row =
+ (spacerangeP->spacecode[j].srcCodeLo >> 8) & 0xff;
+ rangelo_col = spacerangeP->spacecode[j].srcCodeLo & 0xff;
+ rangehi_row =
+ (spacerangeP->spacecode[j].srcCodeHi >> 8) & 0xff;
+ rangehi_col = spacerangeP->spacecode[j].srcCodeHi & 0xff;
+ if (char_row >= rangelo_row && char_row <= rangehi_row &&
+ char_col >= rangelo_col && char_col <= rangehi_col) {
+ charvalid = TRUE;
+ break;
+ }
+ }
+ if (charvalid) break;
+ spacerangeP = spacerangeP->next;
+ }
+
+ if (charvalid) {
+ charvalid = FALSE;
+ cidrangeP = CIDFontP->cidrangeP;
+ for (i = 0; i < CIDFontP->cidrangecnt; i++) {
+ for (j = 0; j < cidrangeP->rangecnt; j++) {
+ rangelo_row =
+ (cidrangeP->range[j].srcCodeLo >> 8) & 0xff;
+ rangelo_col = cidrangeP->range[j].srcCodeLo & 0xff;
+ rangehi_row =
+ (cidrangeP->range[j].srcCodeHi >> 8) & 0xff;
+ rangehi_col = cidrangeP->range[j].srcCodeHi & 0xff;
+ if (char_row >= rangelo_row && char_row <= rangehi_row &&
+ char_col >= rangelo_col && char_col <= rangehi_col) {
+ charvalid = TRUE;
+ for (k = cidrangeP->range[j].srcCodeLo;
+ k <= cidrangeP->range[j].srcCodeHi; k++) {
+ if (k == charcode)
+ cidcode = cidrangeP->range[j].dstCIDLo + k -
+ cidrangeP->range[j].srcCodeLo;
+ }
+ break;
+ }
+ }
+ if (charvalid) break;
+ cidrangeP = cidrangeP->next;
+ }
+ }
+
+ if (charvalid) {
+ charvalid = FALSE;
+ notdefrangeP = CIDFontP->notdefrangeP;
+ for (i = 0; i < CIDFontP->notdefrangecnt; i++) {
+ for (j = 0; j < notdefrangeP->rangecnt; j++) {
+ rangelo_row =
+ (notdefrangeP->range[j].srcCodeLo >> 8) & 0xff;
+ rangelo_col = notdefrangeP->range[j].srcCodeLo & 0xff;
+ rangehi_row =
+ (notdefrangeP->range[j].srcCodeHi >> 8) & 0xff;
+ rangehi_col = notdefrangeP->range[j].srcCodeHi & 0xff;
+ if (char_row >= rangelo_row && char_row <= rangehi_row &&
+ char_col >= rangelo_col && char_col <= rangehi_col) {
+ charvalid = TRUE;
+ for (k = notdefrangeP->range[j].srcCodeLo;
+ k <= notdefrangeP->range[j].srcCodeHi; k++) {
+ if (k == charcode)
+ /* the whole range is mapped to a single CID code */
+ cidcode = notdefrangeP->range[j].dstCIDLo;
+ }
+ break;
+ }
+ }
+ if (charvalid) break;
+ notdefrangeP = notdefrangeP->next;
+ }
+ }
+
+ /* If you specify a CMap that has more CIDs than a specified CIDFont, */
+ /* the program could go beyond the number of entries in CIDMap. Make */
+ /* sure that that does not happen. */
+ if (cidcode < CIDFontP->CIDfontInfoP[CIDCOUNT].value.data.integer)
+ return cidcode;
+ else
+ return 0;
+}
+
+static CharInfoPtr
+CIDGetGlyph(FontPtr pFont, unsigned int charcode, CharInfoPtr pci)
+{
+ int rc;
+ CharInfoPtr cp = NULL;
+ unsigned int cidcode;
+
+ /* character code -> CID */
+ cidcode = getCID(pFont, charcode);
+
+ cp = CIDGetGlyphInfo(pFont, cidcode, pci, &rc);
+
+ if (rc != Successful && cidcode) {
+ cidcode = 0;
+ cp = CIDGetGlyphInfo(pFont, cidcode, pci, &rc);
+ }
+
+ return cp;
+}
+
+int
+CIDGetGlyphs(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
+{
+ unsigned int code, char_row, char_col;
+ CharInfoPtr *glyphsBase;
+ register unsigned int c;
+ CharInfoPtr pci;
+ CharInfoPtr pDefault;
+ cidglyphs *cid;
+ register int firstCol;
+ int rc = 0;
+ int cid_valid = 0;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ FontP = NULL;
+
+ firstCol = pFont->info.firstCol;
+ pDefault = cid->pDefault;
+ glyphsBase = glyphs;
+
+ switch (charEncoding) {
+
+#define EXIST(pci) \
+ ((pci)->metrics.attributes || \
+ (pci)->metrics.ascent != -(pci)->metrics.descent || \
+ (pci)->metrics.leftSideBearing != (pci)->metrics.rightSideBearing)
+
+ case Linear8Bit:
+ case TwoD8Bit:
+ if (pFont->info.firstRow > 0)
+ break;
+ while (count--) {
+ c = (*chars++);
+ if (c >= firstCol && c <= pFont->info.lastCol) {
+ code = c - firstCol;
+ if (!(pci = (CharInfoRec *)cid->glyphs[code]) ||
+ ((long)pci->bits == CID_BITMAP_UNDEFINED)) {
+ /* load font if not already loaded */
+ if(!cid_valid) {
+ if(!CIDfontfcnA(cid->CIDFontName, cid->CMapName, &rc)) { FontP = NULL;
+ return Type1ReturnCodeToXReturnCode(rc);
+ }
+ cid_valid = 1;
+ }
+ pci = CIDGetGlyph(pFont, c, pci);
+ }
+ if (pci && EXIST(pci)) {
+ *glyphs++ = pci;
+ cid->glyphs[code] = pci;
+ } else if (pDefault) {
+ *glyphs++ = pDefault;
+ cid->glyphs[code] = pDefault;
+ }
+ } else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ case Linear16Bit:
+ while (count--) {
+ char_row = *chars++;
+ char_col = *chars++;
+ c = char_row << 8;
+ c = (c | char_col);
+ if (pFont->info.firstRow <= char_row && char_row <=
+ pFont->info.lastRow && pFont->info.firstCol <= char_col &&
+ char_col <= pFont->info.lastCol) {
+ code = pFont->info.lastCol - pFont->info.firstCol + 1;
+ char_row = char_row - pFont->info.firstRow;
+ char_col = char_col - pFont->info.firstCol;
+ code = char_row * code + char_col;
+ if (!(pci = (CharInfoRec *)cid->glyphs[code]) ||
+ ((long)pci->bits == CID_BITMAP_UNDEFINED)) {
+ /* load font if not already loaded */
+ if(!cid_valid) {
+ if(!CIDfontfcnA(cid->CIDFontName, cid->CMapName, &rc)) { FontP = NULL;
+ return Type1ReturnCodeToXReturnCode(rc);
+ }
+ cid_valid = 1;
+ }
+ pci = CIDGetGlyph(pFont, c, pci);
+ }
+ if (pci && EXIST(pci)) {
+ *glyphs++ = pci;
+ cid->glyphs[code] = pci;
+ } else if (pDefault) {
+ *glyphs++ = pDefault;
+ cid->glyphs[code] = pDefault;
+ }
+ } else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+
+ case TwoD16Bit:
+ while (count--) {
+ char_row = (*chars++);
+ char_col = (*chars++);
+ c = char_row << 8;
+ c = (c | char_col);
+ if (pFont->info.firstRow <= char_row && char_row <=
+ pFont->info.lastRow && pFont->info.firstCol <= char_col &&
+ char_col <= pFont->info.lastCol) {
+ code = pFont->info.lastCol - pFont->info.firstCol + 1;
+ char_row = char_row - pFont->info.firstRow;
+ char_col = char_col - pFont->info.firstCol;
+ code = char_row * code + char_col;
+ if (!(pci = (CharInfoRec *)cid->glyphs[code]) ||
+ ((long)pci->bits == CID_BITMAP_UNDEFINED)) {
+ /* load font if not already loaded */
+ if(!cid_valid) {
+ if(!CIDfontfcnA(cid->CIDFontName, cid->CMapName, &rc)) { FontP = NULL;
+ return Type1ReturnCodeToXReturnCode(rc);
+ }
+ cid_valid = 1;
+ }
+ pci = CIDGetGlyph(pFont, c, pci);
+ }
+ if (pci && EXIST(pci)) {
+ *glyphs++ = pci;
+ cid->glyphs[code] = pci;
+ } else if (pDefault) {
+ *glyphs++ = pDefault;
+ cid->glyphs[code] = pDefault;
+ }
+ } else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ }
+ *glyphCount = glyphs - glyphsBase;
+ return Successful;
+
+#undef EXIST
+}
+#endif
+
+static int
+Type1GetGlyphs(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
+{
+ unsigned int firstRow;
+ unsigned int numRows;
+ CharInfoPtr *glyphsBase;
+ register unsigned int c;
+ register CharInfoPtr pci;
+ unsigned int r;
+ CharInfoPtr pDefault;
+ register struct type1font *type1Font;
+ register int firstCol;
+
+ type1Font = (struct type1font *) pFont->fontPrivate;
+ firstCol = pFont->info.firstCol;
+ pDefault = type1Font->pDefault;
+ glyphsBase = glyphs;
+
+ switch (charEncoding) {
+
+#define EXIST(pci) \
+ ((pci)->metrics.attributes || \
+ (pci)->metrics.ascent != -(pci)->metrics.descent || \
+ (pci)->metrics.leftSideBearing != (pci)->metrics.rightSideBearing)
+
+ case Linear8Bit:
+ case TwoD8Bit:
+ if (pFont->info.firstRow > 0)
+ break;
+ while (count--) {
+ c = (*chars++);
+ if (c >= firstCol &&
+ (pci = &type1Font->glyphs[c]) &&
+ EXIST(pci))
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ case Linear16Bit:
+ while (count--) {
+ c = *chars++ << 8;
+ c = (c | *chars++);
+ if (c < 256 && c >= firstCol &&
+ (pci = &type1Font->glyphs[c]) &&
+ EXIST(pci))
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+
+ case TwoD16Bit:
+ firstRow = pFont->info.firstRow;
+ numRows = pFont->info.lastRow - firstRow + 1;
+ while (count--) {
+ r = (*chars++) - firstRow;
+ c = (*chars++);
+ if (r < numRows && c < 256 && c >= firstCol &&
+ (pci = &type1Font->glyphs[(r << 8) + c]) &&
+ EXIST(pci))
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ }
+ *glyphCount = glyphs - glyphsBase;
+ return Successful;
+
+#undef EXIST
+}
+
+#if XFONT_CID
+static CharInfoRec nonExistantChar;
+
+int
+CIDGetMetrics(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ xCharInfo **glyphs) /* RETURN */
+{
+ int ret;
+ cidglyphs *cid;
+ CharInfoPtr oldDefault;
+ char cidafmname[CID_PATH_MAX];
+ char CIDFontName[CID_NAME_MAX];
+ char *ptr;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ strcpy(cidafmname, cid->CIDFontName);
+ if (!(ptr = strrchr(cidafmname, '/')))
+ return BadFontName;
+
+ *ptr = '\0';
+
+ strcpy(CIDFontName, ptr + 1);
+
+ if (!(ptr = strrchr(cidafmname, '/')))
+ return BadFontName;
+
+ *ptr = '\0';
+
+ strcat(cidafmname, "/AFM/");
+ strcat(cidafmname, CIDFontName);
+
+ strcat(cidafmname, ".afm");
+
+ oldDefault = cid->pDefault;
+ cid->pDefault = &nonExistantChar;
+
+ ret = CIDGetAFM(pFont, count, chars, charEncoding, glyphCount, (CharInfoPtr
+*)glyphs, cidafmname);
+ if (ret != Successful)
+ ret = CIDGetGlyphs(pFont, count, chars, charEncoding, glyphCount,
+ (CharInfoPtr *)glyphs);
+
+ *ptr = 0;
+ cid->pDefault = oldDefault;
+ return ret;
+}
+#endif
+
+static int
+Type1GetMetrics(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ xCharInfo **glyphs) /* RETURN */
+{
+ static CharInfoRec nonExistantChar;
+
+ int ret;
+ struct type1font *type1Font;
+ CharInfoPtr oldDefault;
+
+ type1Font = (struct type1font *) pFont->fontPrivate;
+ oldDefault = type1Font->pDefault;
+ type1Font->pDefault = &nonExistantChar;
+ ret = Type1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, (CharInfoPtr *) glyphs);
+ type1Font->pDefault = oldDefault;
+ return ret;
+}
+
+#if XFONT_CID
+void
+CIDCloseFont(FontPtr pFont)
+{
+ register int i;
+ cidglyphs *cid;
+ int nchars;
+
+ if (pFont) {
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ if (cid) {
+
+ if (cid->CIDFontName && !strcmp(cid->CIDFontName, CurCIDFontName)
+ && cid->CMapName && !strcmp(cid->CMapName, CurCMapName)){
+ strcpy(CurCIDFontName, ""); /* initialize to none */
+ strcpy(CurCMapName, ""); /* initialize to none */
+ }
+
+ if (cid->CIDFontName)
+ xfree(cid->CIDFontName);
+
+ if (cid->CMapName)
+ xfree(cid->CMapName);
+
+ nchars = (pFont->info.lastRow - pFont->info.firstRow + 1) *
+ (pFont->info.lastCol - pFont->info.firstCol + 1);
+
+ for (i = 0; i < nchars; i++) {
+ if (cid->glyphs[i] && (cid->glyphs[i] != &nonExistantChar)) {
+ if (cid->glyphs[i]->bits)
+ xfree(cid->glyphs[i]->bits);
+ xfree(cid->glyphs[i]);
+ }
+ }
+
+ if (cid->glyphs)
+ xfree(cid->glyphs);
+
+ if (cid->AFMinfo)
+ xfree(cid->AFMinfo);
+#ifdef USE_MMAP
+ if (cid->CIDdata)
+ munmap(cid->CIDdata, cid->CIDsize);
+#endif
+ xfree(cid);
+ }
+
+ if (pFont->info.props)
+ xfree(pFont->info.props);
+
+ if (pFont->info.isStringProp)
+ xfree(pFont->info.isStringProp);
+
+ DestroyFontRec(pFont);
+ }
+}
+#endif
+
+void
+Type1CloseFont(FontPtr pFont)
+{
+ register int i;
+ struct type1font *type1;
+
+ type1 = (struct type1font *) pFont->fontPrivate;
+ for (i=0; i < 256; i++)
+ if (type1->glyphs[i].bits != NULL)
+ xfree(type1->glyphs[i].bits);
+ xfree(type1);
+
+ if (pFont->info.props)
+ xfree(pFont->info.props);
+
+ if (pFont->info.isStringProp)
+ xfree(pFont->info.isStringProp);
+
+ DestroyFontRec(pFont);
+}
+
+static void
+fill(char *dest, /* destination bitmap */
+ int h, int w, /* dimensions of 'dest', w padded */
+ struct region *area, /* region to write to 'dest' */
+ int byte, int bit, /* flags; LSBFirst or MSBFirst */
+ int wordsize) /* number of bits per word for LSB/MSB purposes */
+{
+ register struct edgelist *edge; /* for looping through edges */
+ register char *p; /* current scan line in 'dest' */
+ register int y; /* for looping through scans */
+ register int wbytes = w / 8; /* number of bytes in width */
+ register pel *leftP,*rightP; /* pointers to X values, left and right */
+ int xmin = area->xmin; /* upper left X */
+ int ymin = area->ymin; /* upper left Y */
+
+ for (edge = area->anchor; VALIDEDGE(edge); edge = edge->link->link) {
+
+ p = dest + (edge->ymin - ymin) * wbytes;
+ leftP = edge->xvalues;
+ rightP = edge->link->xvalues;
+
+ for (y = edge->ymin; y < edge->ymax; y++) {
+ fillrun(p, *leftP++ - xmin, *rightP++ - xmin, bit);
+ p += wbytes;
+ }
+ }
+/*
+Now, as an afterthought, we'll go reorganize if odd byte order requires
+it:
+*/
+ if (byte == LSBFirst && wordsize != 8) {
+ register int i;
+
+ switch (wordsize) {
+ case 16:
+ {
+ register unsigned short data,*p;
+
+ p = (unsigned short *) dest;
+
+ for (i = h * w /16; --i >= 0;) {
+ data = *p;
+ *p++ = (data << 8) + (data >> 8);
+ }
+ break;
+ }
+ case 64:
+ case 32:
+ {
+ register unsigned long data,*p;
+
+ p = (unsigned long *) dest;
+
+ for (i = h * w / 32; --i >= 0;) {
+ data = *p;
+ *p++ = (data << 24) + (data >> 24)
+ + (0xFF00 & (data >> 8))
+ + (0xFF0000 & (data << 8));
+ }
+ if (wordsize == 64) {
+
+ p = (unsigned long *) dest;
+
+ for (i = h * w / 64; --i >= 0;) {
+ data = *p++;
+ p[-1] = p[0];
+ *p++ = data;
+ }
+ }
+ break;
+ }
+ default:
+ Abort("xiFill: unknown format");
+ }
+ }
+
+}
+
+#define ALLONES 0xFF
+
+static void
+fillrun(char *p, /* address of this scan line */
+ pel x0, pel x1, /* left and right X */
+ int bit) /* format: LSBFirst or MSBFirst */
+{
+ register int startmask,endmask; /* bits to set in first and last char*/
+ register int middle; /* number of chars between start and end + 1 */
+
+ if (x1 <= x0)
+ return;
+ middle = x1/8 - x0/8;
+ p += x0/8;
+ x0 &= 7; x1 &= 7;
+ if (bit == LSBFirst) {
+ startmask = ALLONES << x0;
+ endmask = ~(ALLONES << x1);
+ }
+ else {
+ startmask = ALLONES >> x0;
+ endmask = ~(ALLONES >> x1);
+ }
+ if (middle == 0)
+ *p++ |= startmask & endmask;
+ else {
+ *p++ |= startmask;
+ while (--middle > 0)
+ *p++ = (char)ALLONES;
+ *p |= endmask;
+ }
+}
+
+#define CAPABILITIES (CAP_MATRIX | CAP_CHARSUBSETTING)
+
+#if XFONT_CID
+FontRendererRec CIDRendererInfo[] = {
+ { ".cid", 4, NULL, CIDOpenScalable,
+ NULL, CIDGetInfoScalable, 0, CAPABILITIES }
+};
+#endif
+
+#if XFONT_CID
+FontRendererRec Type1RendererInfo[] = {
+#else
+static FontRendererRec renderers[] = {
+#endif
+ { ".pfa", 4, NULL, Type1OpenScalable,
+ NULL, Type1GetInfoScalable, 0, CAPABILITIES },
+ { ".pfb", 4, NULL, Type1OpenScalable,
+ NULL, Type1GetInfoScalable, 0, CAPABILITIES }
+};
+
+#if XFONT_CID
+void
+CIDRegisterFontFileFunctions(void)
+{
+ int i;
+
+ Type1InitStdProps();
+ for (i=0; i < sizeof(CIDRendererInfo) / sizeof(FontRendererRec); i++)
+ FontFileRegisterRenderer(&CIDRendererInfo[i]);
+}
+#endif
+
+void
+Type1RegisterFontFileFunctions(void)
+{
+ int i;
+
+#if XFONT_CID
+ Type1InitStdProps();
+ for (i=0; i < sizeof(Type1RendererInfo) / sizeof(FontRendererRec); i++)
+ FontFilePriorityRegisterRenderer(&Type1RendererInfo[i], -10);
+#else
+ T1InitStdProps();
+ for (i=0; i < sizeof(renderers) / sizeof(FontRendererRec); i++)
+ FontFilePriorityRegisterRenderer(&renderers[i], -10);
+#endif
+}
+
+int
+Type1ReturnCodeToXReturnCode(int rc)
+{
+ switch(rc) {
+ case SCAN_OK:
+ return Successful;
+ case SCAN_FILE_EOF:
+ /* fall through to BadFontFormat */
+ case SCAN_ERROR:
+ return BadFontFormat;
+ case SCAN_OUT_OF_MEMORY:
+ return AllocError;
+ case SCAN_FILE_OPEN_ERROR:
+ return BadFontName;
+ case SCAN_TRUE:
+ case SCAN_FALSE:
+ case SCAN_END:
+ /* fall through */
+ default:
+ /* this should not happen */
+#if XFONT_CID
+ ErrorF("Font return code cannot be converted to X return code: %d\n", rc);
+#else
+ ErrorF("Type1 return code not convertable to X return code: %d\n", rc);
+#endif
+ return rc;
+ }
+}
+
+#if XFONT_CID
+CharInfoPtr
+CIDRenderGlyph(FontPtr pFont, psobj *charstringP, psobj *subarrayP,
+ struct blues_struct *bluesP, CharInfoPtr pci, int *mode)
+{
+ int bit,
+ byte,
+ glyph,
+ scan,
+ image;
+ int pad,wordsize; /* scan & image in bits */
+ long *pool; /* memory pool for ximager objects */
+ int size; /* for memory size calculations */
+ struct XYspace *S; /* coordinate space for character */
+ struct region *area;
+ CharInfoRec *glyphs;
+ int len, rc;
+ long x0;
+ double x1, y1, t1 = .001, t2 = 0.0, t3 = 0.0, t4 = .001;
+ double sxmult;
+ long h,w;
+ long paddedW;
+ cidglyphs *cid;
+ fsBitmapFormat format = 0;
+ fsBitmapFormatMask fmask = 0;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ /* set up default values */
+ FontDefaultFormat(&bit, &byte, &glyph, &scan);
+ /* get any changes made from above */
+ rc = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);
+ if (rc != Successful) {
+ *mode = rc;
+ return(NULL);
+ }
+
+ pad = glyph * 8;
+ wordsize = scan * 8;
+
+#define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
+
+ /* heuristic for "maximum" size of pool we'll need: */
+ size = 200000 + 600 *
+ (int)hypot(cid->pixel_matrix[2], cid->pixel_matrix[3])
+ * sizeof(short);
+ if (size < 0 || NULL == (pool = (long *) xalloc(size))) {
+ *mode = AllocError;
+ return(NULL);
+ }
+
+ addmemory(pool, size);
+
+ if (pci && (long)pci->bits == CID_BITMAP_UNDEFINED)
+ glyphs = pci;
+ else {
+ if (!(glyphs = (CharInfoRec *)xalloc(sizeof(CharInfoRec)))) {
+ delmemory();
+ xfree(pool);
+ *mode = AllocError;
+ return(NULL);
+ }
+ bzero(glyphs, sizeof(CharInfoRec));
+ }
+
+ S = (struct XYspace *) t1_Transform((struct xobject *)IDENTITY,
+ t1, t2, t3, t4);
+
+ S = (struct XYspace *) Permanent(t1_Transform((struct xobject *)S,
+ cid->pixel_matrix[0],
+ -cid->pixel_matrix[1],
+ cid->pixel_matrix[2],
+ -cid->pixel_matrix[3]));
+
+ /* multiplier for computation of raw values */
+ sxmult = hypot(cid->pixel_matrix[0], cid->pixel_matrix[1]);
+ if (sxmult > EPS) sxmult = 1000.0 / sxmult;
+
+ rc = 0;
+ area = (struct region *)CIDfontfcnC(S, charstringP, subarrayP, bluesP,
+ &len, &rc);
+ if (rc < 0 || area == NULL) {
+ delmemory();
+ xfree(pool);
+ if (pci != glyphs) xfree(glyphs);
+ *mode = Type1ReturnCodeToXReturnCode(rc);
+ return(NULL);
+ }
+
+ h = area->ymax - area->ymin;
+ w = area->xmax - area->xmin;
+ paddedW = PAD(w, pad);
+
+ if (h > 0 && w > 0) {
+ size = h * paddedW / 8;
+ glyphs[0].bits = (char *)xalloc(size);
+ if (glyphs[0].bits == NULL) {
+ Destroy(area);
+ delmemory();
+ xfree(pool);
+ if (pci != glyphs) xfree(glyphs);
+ *mode = AllocError;
+ return(NULL);
+ }
+ bzero(glyphs[0].bits, size);
+ }
+ else {
+ size = 0;
+ h = w = 0;
+ area->xmin = area->xmax = 0;
+ area->ymax = area->ymax = 0;
+ glyphs[0].bits = NULL;
+ }
+
+ glyphs[0].metrics.leftSideBearing = area->xmin;
+ x1 = (double)(x0 = area->ending.x - area->origin.x);
+ y1 = (double)(area->ending.y - area->origin.y);
+ glyphs[0].metrics.characterWidth =
+ (x0 + (x0 > 0 ? FPHALF : -FPHALF)) / (1 << FRACTBITS);
+ if (!glyphs[0].metrics.characterWidth && size == 0)
+ {
+ /* Zero size and zero extents: presumably caused by
+ the choice of transformation. Let's create a
+ small bitmap so we're not mistaken for an undefined
+ character. */
+ h = w = 1;
+ size = paddedW = PAD(w, pad);
+ glyphs[0].bits = (char *)xalloc(size);
+ if (glyphs[0].bits == NULL) {
+ Destroy(area);
+ delmemory();
+ xfree(pool);
+ if (pci != glyphs) xfree(glyphs);
+ *mode = AllocError;
+ return(NULL);
+ }
+ bzero(glyphs[0].bits, size);
+ }
+ glyphs[0].metrics.attributes =
+ NEARESTPEL((long)(hypot(x1, y1) * sxmult));
+ glyphs[0].metrics.rightSideBearing = w + area->xmin;
+ glyphs[0].metrics.descent = area->ymax - NEARESTPEL(area->origin.y);
+ glyphs[0].metrics.ascent = h - glyphs[0].metrics.descent;
+
+ if (h > 0 && w > 0)
+ fill(glyphs[0].bits, h, paddedW, area, byte, bit, wordsize);
+ Destroy(area);
+ delmemory();
+ xfree(pool);
+ *mode = Successful;
+ return(glyphs);
+}
+#endif
diff --git a/nx-X11/lib/font/Type1/t1hdigit.h b/nx-X11/lib/font/Type1/t1hdigit.h
new file mode 100644
index 000000000..e05f0de5d
--- /dev/null
+++ b/nx-X11/lib/font/Type1/t1hdigit.h
@@ -0,0 +1,40 @@
+/* $Xorg: t1hdigit.h,v 1.3 2000/08/17 19:46:33 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* Indicators for special characters in the p_hdigit.h tables */
+#define HERROR (0xfe)
+#define HWHITE_SPACE (0xfd)
+#define HRIGHT_ANGLE (0xfc)
+#define LAST_HDIGIT (0xf0)
+
+/* Declarations for the tables */
+#define HighHexP (HighHex+1)
+extern unsigned char HighHex[];
+#define LowHexP (LowHex+1)
+extern unsigned char LowHex[];
diff --git a/nx-X11/lib/font/Type1/t1imager.h b/nx-X11/lib/font/Type1/t1imager.h
new file mode 100644
index 000000000..9730f9a47
--- /dev/null
+++ b/nx-X11/lib/font/Type1/t1imager.h
@@ -0,0 +1,84 @@
+/* $Xorg: t1imager.h,v 1.3 2000/08/17 19:46:33 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* $XFree86: xc/lib/font/Type1/t1imager.h,v 1.4 2001/01/17 19:43:23 dawes Exp $ */
+
+
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h"
+
+typedef struct xobject *xobject;
+typedef struct segment *path;
+typedef struct region *region;
+typedef struct XYspace *XYspace;
+
+
+#ifndef NULL
+#include <stddef.h>
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+
+#define WINDINGRULE -2
+#define EVENODDRULE -3
+
+#define CONTINUITY 0x80 /* can be added to above rules; e.g. WINDINGRULE+CONTINUITY */
+
+
+/*
+Generic null object definition:
+*/
+#define NULLOBJECT ((xobject)NULL)
+
+/*
+Null path definition:
+*/
+#define NULLPATH NULLOBJECT
+
+/*
+Full page and null region definition:
+*/
+#define INFINITY t1_Infinity
+#ifndef NOEXTERNS
+extern region *INFINITY;
+#endif
+#define NULLREGION NULLOBJECT
+
+#define FF_PARSE_ERROR 5
+#define FF_PATH 1
+
diff --git a/nx-X11/lib/font/Type1/t1info.c b/nx-X11/lib/font/Type1/t1info.c
new file mode 100644
index 000000000..322572ee2
--- /dev/null
+++ b/nx-X11/lib/font/Type1/t1info.c
@@ -0,0 +1,1096 @@
+/* $Xorg: t1info.c,v 1.4 2001/02/09 02:04:01 xorgcvs Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License, subject to the license given below, 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software
+ * without specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ *
+ * Author: Carol H. Thompson IBM Almaden Research Center
+ * Modeled on spinfo.c by Dave Lemke, Network Computing Devices, Inc
+ * which contains the following copyright and permission notices:
+ *
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Network Computing
+ * Devices and Digital make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR 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, 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 (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/t1info.c,v 1.18tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/fontutil.h>
+#ifndef FONTMODULE
+#include <stdio.h>
+#ifndef BUILDCID
+#include <math.h>
+#endif
+#else
+#include "xf86_ansic.h"
+#endif
+#include <X11/fonts/FSproto.h>
+
+#if XFONT_CID
+#ifndef FONTMODULE
+#ifdef _XOPEN_SOURCE
+#include <math.h>
+#else
+#define _XOPEN_SOURCE
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+#endif
+#include "objects.h"
+#include "spaces.h"
+#include "range.h"
+#endif
+
+#if XFONT_CID
+#include "util.h"
+#include "fontfcn.h"
+
+#if defined(HAVE_CFM) || defined(CID_ALL_CHARS)
+#ifndef DEFAULT_CFM_DIR
+#define DEFAULT_CFM_DIR "./"
+#endif
+char cfmDefaultDir[] = DEFAULT_CFM_DIR;
+#define CFMMAGIC 0x91239123
+#endif
+#endif
+#include "t1intf.h"
+
+#define DECIPOINTSPERINCH 722.7
+#define DEFAULTRES 75
+#define DEFAULTPOINTSIZE 120
+
+enum scaleType {
+ atom, truncate_atom, pixel_size, point_size, resolution_x,
+ resolution_y, average_width
+};
+
+#if XFONT_CID
+extern cidfont *CIDFontP;
+static int stdpropsinit = 0;
+
+typedef struct cfm_rec {
+ xCharInfo maxbounds;
+ xCharInfo minbounds;
+ xCharInfo ink_maxbounds;
+ xCharInfo ink_minbounds;
+ INT32 totalrw;
+ INT16 maxo;
+ INT16 alle;
+} cfmrec;
+#endif
+
+typedef struct _fontProp {
+ char *name;
+ long atom;
+ enum scaleType type;
+} fontProp;
+
+static fontProp fontNamePropTable[] = { /* Example: */
+ { "FOUNDRY", 0, atom }, /* adobe */
+ { "FAMILY_NAME", 0, atom }, /* times roman */
+ { "WEIGHT_NAME", 0, atom }, /* bold */
+ { "SLANT", 0, atom }, /* i */
+ { "SETWIDTH_NAME", 0, atom }, /* normal */
+ { "ADD_STYLE_NAME", 0, atom }, /* */
+ { "PIXEL_SIZE", 0, pixel_size }, /* 18 */
+ { "POINT_SIZE", 0, point_size }, /* 180 */
+ { "RESOLUTION_X", 0, resolution_x }, /* 72 */
+ { "RESOLUTION_Y", 0, resolution_y }, /* 72 */
+ { "SPACING", 0, atom }, /* p */
+ { "AVERAGE_WIDTH", 0, average_width }, /* 0 */
+ { "CHARSET_REGISTRY", 0, atom }, /* ISO8859 */
+ { "CHARSET_ENCODING", 0, truncate_atom } /* 1 */
+};
+
+/* NOTICE: Following array is closely related to the sequence of defines
+ following it. */
+static fontProp extraProps[] = {
+ { "FONT", 0, },
+ { "COPYRIGHT", 0, },
+ { "RAW_PIXEL_SIZE", 0, },
+ { "RAW_POINT_SIZE", 0, },
+ { "RAW_ASCENT", 0, },
+ { "RAW_DESCENT", 0, },
+ { "RAW_AVERAGE_WIDTH", 0, },
+ { "FACE_NAME", 0, },
+ { "FONT_TYPE", 0, },
+ { "RASTERIZER_NAME", 0, }
+};
+
+/* this is a bit kludgy */
+#define FONTPROP 0
+#define COPYRIGHTPROP 1
+#define RAWPIXELPROP 2
+#define RAWPOINTPROP 3
+#define RAWASCENTPROP 4
+#define RAWDESCENTPROP 5
+#define RAWWIDTHPROP 6
+#define FACE_NAMEPROP 7
+#define FONT_TYPEPROP 8
+#define RASTERIZER_NAMEPROP 9
+
+#define NNAMEPROPS (sizeof(fontNamePropTable) / sizeof(fontProp))
+#define NEXTRAPROPS (sizeof(extraProps) / sizeof(fontProp))
+
+#define NPROPS (NNAMEPROPS + NEXTRAPROPS)
+
+/*ARGSUSED*/
+static void
+FillHeader(FontInfoPtr pInfo, FontScalablePtr Vals)
+{
+ /* OpenScalable in T1FUNCS sets the following:
+ pInfo->firstCol,
+ pInfo->firstRow,
+ pInfo->lastCol, and
+ pInfo->lastRow. */
+ /* the following are ununsed
+ pInfo->pad. */
+
+ /* Items we should handle better someday +++ */
+ pInfo->defaultCh = 0;
+ pInfo->drawDirection = LeftToRight;
+ if (Vals->point_matrix[0] == Vals->point_matrix[3])
+ pInfo->anamorphic = 0;
+ else
+ pInfo->anamorphic = 1;
+ pInfo->inkMetrics = 0; /* no ink metrics here */
+ pInfo->cachable = 1; /* no licensing (yet) */
+}
+
+static void
+adjust_min_max(xCharInfo *minc, xCharInfo *maxc, xCharInfo *tmp)
+{
+#define MINMAX(field,ci) \
+ if (minc->field > (ci)->field) \
+ minc->field = (ci)->field; \
+ if (maxc->field < (ci)->field) \
+ maxc->field = (ci)->field;
+
+ MINMAX(ascent, tmp);
+ MINMAX(descent, tmp);
+ MINMAX(leftSideBearing, tmp);
+ MINMAX(rightSideBearing, tmp);
+ MINMAX(characterWidth, tmp);
+
+ /* Do MINMAX for attributes field. Since that field is CARD16,
+ we'll cast to a signed integer */
+ if ((INT16)minc->attributes > (INT16)tmp->attributes)
+ minc->attributes = tmp->attributes;
+ if ((INT16)maxc->attributes < (INT16)tmp->attributes)
+ maxc->attributes = tmp->attributes;
+
+#undef MINMAX
+}
+
+static void
+ComputeBounds(FontInfoPtr pInfo, CharInfoPtr pChars, FontScalablePtr Vals)
+{
+ int i;
+ xCharInfo minchar, maxchar;
+ int numchars = 0;
+ int totchars;
+ int overlap;
+ int maxlap;
+
+ minchar.ascent = minchar.descent =
+ minchar.leftSideBearing = minchar.rightSideBearing =
+ minchar.characterWidth = minchar.attributes = 32767;
+ maxchar.ascent = maxchar.descent =
+ maxchar.leftSideBearing = maxchar.rightSideBearing =
+ maxchar.characterWidth = maxchar.attributes = -32767;
+
+ maxlap = -32767;
+ totchars = pInfo->lastCol - pInfo->firstCol + 1;
+ pChars += pInfo->firstCol;
+ pInfo->allExist = 1;
+ for (i = 0; i < totchars; i++,pChars++) {
+ xCharInfo *pmetrics = &pChars->metrics;
+
+ if (pmetrics->attributes ||
+ pmetrics->ascent != -pmetrics->descent ||
+ pmetrics->leftSideBearing != pmetrics->rightSideBearing) {
+ numchars++;
+ adjust_min_max(&minchar, &maxchar, pmetrics);
+ overlap = pmetrics->rightSideBearing - pmetrics->characterWidth;
+ if (overlap > maxlap) maxlap = overlap;
+ }
+ else pInfo->allExist = 0;
+ }
+
+ /* If we're monospaced, round the average width field to the
+ nearest pixel */
+ if (minchar.characterWidth == maxchar.characterWidth)
+ Vals->width = minchar.characterWidth * 10;
+
+ pInfo->maxbounds = maxchar;
+ pInfo->minbounds = minchar;
+ pInfo->ink_maxbounds = maxchar;
+ pInfo->ink_minbounds = minchar;
+ pInfo->maxOverlap = maxlap + -(minchar.leftSideBearing);
+
+ /* Set the pInfo flags */
+ /* Properties set by FontComputeInfoAccelerators:
+ pInfo->noOverlap;
+ pInfo->terminalFont;
+ pInfo->constantMetrics;
+ pInfo->constantWidth;
+ pInfo->inkInside;
+
+ */
+ FontComputeInfoAccelerators (pInfo);
+}
+
+#if XFONT_CID
+#ifdef CID_ALL_CHARS
+void
+ComputeBoundsAllChars(FontPtr pFont, char *cfmfilename, double sxmult)
+{
+ FILE *cfm;
+ CARD32 magic;
+ int count = 0;
+ int maxlap, overlap, i, j, k, ret;
+ xCharInfo minchar, maxchar;
+ cidrange *cidrangeP;
+ unsigned char ccode[2];
+ unsigned long ccount;
+ xCharInfo *pmetrics;
+ long total_raw_width = 0, total_width = 0;
+ char cfmd[CID_PATH_MAX];
+ cfmrec *cfmp;
+ char *p;
+
+ if (!(cfm = fopen(cfmfilename, "w"))) {
+ fprintf(stderr,
+ "Unable to open the file %s. You are probably not logged in as root.\n",
+ cfmfilename);
+ p = strrchr(cfmfilename, '/');
+ if (p == NULL) exit(1);
+ strcpy(cfmd, cfmDefaultDir);
+ strcat(cfmd, p + 1);
+ if (!(cfm = fopen(cfmd, "w"))) {
+ fprintf(stderr,
+ "Switching to current directory. Unable to open the file %s.\n",
+ cfmd);
+ exit(1);
+ }
+ }
+
+ if ((cfmp = (cfmrec *)xalloc(sizeof(cfmrec))) == NULL) {
+ fprintf(stderr, "Unable to allocate memory.");
+ exit(1);
+ }
+ bzero(cfmp, sizeof(cfmrec));
+
+ minchar.ascent = minchar.descent =
+ minchar.leftSideBearing = minchar.rightSideBearing =
+ minchar.characterWidth = minchar.attributes = 32767;
+ maxchar.ascent = maxchar.descent =
+ maxchar.leftSideBearing = maxchar.rightSideBearing =
+ maxchar.characterWidth = maxchar.attributes = -32767;
+
+ maxlap = -32767;
+ cfmp->alle = 1;
+ cidrangeP = CIDFontP->cidrangeP;
+
+ /* go through all character codes specified in a given CMap */
+ for (i = 0; i < CIDFontP->cidrangecnt; i++) {
+ for (j = 0; j < cidrangeP->rangecnt; j++) {
+ for (k = cidrangeP->range[j].srcCodeLo;
+ k <= cidrangeP->range[j].srcCodeHi; k++) {
+ ccode[0] = (k >> 8) & 0xff;
+ ccode[1] = k & 0xff;
+ ret = CIDGetMetrics(pFont, 1, ccode, Linear16Bit, &ccount, &pmetrics);
+ if (ret != Successful || (ret == Successful && pmetrics == NULL))
+ continue;
+ total_width += pmetrics->attributes;
+ total_raw_width += abs((int)(INT16)pmetrics->attributes);
+ if (pmetrics->attributes ||
+ pmetrics->ascent != -pmetrics->descent ||
+ pmetrics->leftSideBearing != pmetrics->rightSideBearing) {
+ count++;
+ adjust_min_max(&minchar, &maxchar, pmetrics);
+ overlap = pmetrics->rightSideBearing - pmetrics->characterWidth;
+ if (overlap > maxlap) maxlap = overlap;
+ }
+ else cfmp->alle = 0;
+ }
+ }
+ }
+
+ if (count)
+ {
+ total_raw_width = (total_raw_width * 10 + count / 2) / count;
+ if (total_width < 0)
+ {
+ /* Predominant direction is R->L */
+ total_raw_width = -total_raw_width;
+ }
+ }
+
+ cfmp->totalrw = (INT32)total_raw_width;
+
+ cfmp->maxbounds.leftSideBearing =
+ floor((double)maxchar.leftSideBearing * sxmult + 0.5);
+ cfmp->maxbounds.rightSideBearing =
+ floor((double)maxchar.rightSideBearing * sxmult + 0.5);
+ cfmp->maxbounds.characterWidth =
+ floor((double)maxchar.characterWidth * sxmult + 0.5);
+ cfmp->maxbounds.ascent =
+ floor((double)maxchar.ascent * sxmult + 0.5);
+ cfmp->maxbounds.descent =
+ floor((double)maxchar.descent * sxmult);
+ cfmp->maxbounds.attributes = maxchar.attributes;
+
+ cfmp->minbounds.leftSideBearing =
+ floor((double)minchar.leftSideBearing * sxmult + 0.5);
+ cfmp->minbounds.rightSideBearing =
+ floor((double)minchar.rightSideBearing * sxmult + 0.5);
+ cfmp->minbounds.characterWidth =
+ floor((double)minchar.characterWidth * sxmult + 0.5);
+ cfmp->minbounds.ascent =
+ floor((double)minchar.ascent * sxmult + 0.5);
+ cfmp->minbounds.descent =
+ floor((double)minchar.descent * sxmult + 0.5);
+ cfmp->minbounds.attributes = minchar.attributes;
+
+ cfmp->ink_maxbounds.leftSideBearing =
+ floor((double)maxchar.leftSideBearing * sxmult + 0.5);
+ cfmp->ink_maxbounds.rightSideBearing =
+ floor((double)maxchar.rightSideBearing * sxmult + 0.5);
+ cfmp->ink_maxbounds.characterWidth =
+ floor((double)maxchar.characterWidth * sxmult + 0.5);
+ cfmp->ink_maxbounds.ascent =
+ floor((double)maxchar.ascent * sxmult + 0.5);
+ cfmp->ink_maxbounds.descent =
+ floor((double)maxchar.descent * sxmult + 0.5);
+ cfmp->ink_maxbounds.attributes = maxchar.attributes;
+
+ cfmp->ink_minbounds.leftSideBearing =
+ floor((double)minchar.leftSideBearing * sxmult + 0.5);
+ cfmp->ink_minbounds.rightSideBearing =
+ floor((double)minchar.rightSideBearing * sxmult + 0.5);
+ cfmp->ink_minbounds.characterWidth =
+ floor((double)minchar.characterWidth * sxmult + 0.5);
+ cfmp->ink_minbounds.ascent =
+ floor((double)minchar.ascent * sxmult + 0.5);
+ cfmp->ink_minbounds.descent =
+ floor((double)minchar.descent * sxmult + 0.5);
+ cfmp->ink_minbounds.attributes = minchar.attributes;
+
+ cfmp->maxo = (INT32)(maxlap + -(minchar.leftSideBearing));
+
+ magic = CFMMAGIC;
+ fwrite(&magic, sizeof(CARD32), 1, cfm);
+ fwrite(cfmp, sizeof(cfmrec), 1, cfm);
+ xfree(cfmp);
+ fclose(cfm);
+}
+#else
+static long
+ComputeBoundsAll(FontPtr pFont)
+{
+ int count = 0;
+ int maxlap, overlap, i, j, k, ret;
+ xCharInfo minchar, maxchar;
+ cidrange *cidrangeP;
+ unsigned char ccode[2];
+ unsigned long ccount;
+ xCharInfo *pmetrics;
+ CharInfoRec *cinfo[1];
+ long total_raw_width = 0, total_width = 0;
+ FontInfoPtr pInfo = &(pFont->info);
+
+ minchar.ascent = minchar.descent =
+ minchar.leftSideBearing = minchar.rightSideBearing =
+ minchar.characterWidth = minchar.attributes = 32767;
+ maxchar.ascent = maxchar.descent =
+ maxchar.leftSideBearing = maxchar.rightSideBearing =
+ maxchar.characterWidth = maxchar.attributes = -32767;
+
+ maxlap = -32767;
+ pInfo->allExist = 1;
+ cidrangeP = CIDFontP->cidrangeP;
+
+ /* go through all character codes specified in a given CMap */
+ for (i = 0; i < CIDFontP->cidrangecnt; i++) {
+ for (j = 0; j < cidrangeP->rangecnt; j++) {
+ for (k = cidrangeP->range[j].srcCodeLo;
+ k <= cidrangeP->range[j].srcCodeHi; k++) {
+ ccode[0] = (k >> 8) & 0xff;
+ ccode[1] = k & 0xff;
+ ret = CIDGetMetrics(pFont, 1, ccode, Linear16Bit, &ccount, (xCharInfo **)cinfo);
+ if (ret != Successful || cinfo == NULL)
+ continue;
+ pmetrics = &cinfo[0]->metrics;
+ total_width += pmetrics->attributes;
+ total_raw_width += abs((int)(INT16)pmetrics->attributes);
+ if (pmetrics->attributes ||
+ pmetrics->ascent != -pmetrics->descent ||
+ pmetrics->leftSideBearing != pmetrics->rightSideBearing) {
+ count++;
+ adjust_min_max(&minchar, &maxchar, pmetrics);
+ overlap = pmetrics->rightSideBearing - pmetrics->characterWidth;
+ if (overlap > maxlap) maxlap = overlap;
+ }
+ else pInfo->allExist = 0;
+ }
+ }
+ }
+
+ if (count)
+ {
+ total_raw_width = (total_raw_width * 10 + count / 2) / count;
+ if (total_width < 0)
+ {
+ /* Predominant direction is R->L */
+ total_raw_width = -total_raw_width;
+ }
+ }
+
+ pInfo->maxbounds.leftSideBearing = maxchar.leftSideBearing;
+ pInfo->maxbounds.rightSideBearing = maxchar.rightSideBearing;
+ pInfo->maxbounds.characterWidth = maxchar.characterWidth;
+ pInfo->maxbounds.ascent = maxchar.ascent;
+ pInfo->maxbounds.descent = maxchar.descent;
+ pInfo->maxbounds.attributes = maxchar.attributes;
+
+ pInfo->minbounds.leftSideBearing = minchar.leftSideBearing;
+ pInfo->minbounds.rightSideBearing = minchar.rightSideBearing;
+ pInfo->minbounds.characterWidth = minchar.characterWidth;
+ pInfo->minbounds.ascent = minchar.ascent;
+ pInfo->minbounds.descent = minchar.descent;
+ pInfo->minbounds.attributes = minchar.attributes;
+
+ pInfo->ink_maxbounds.leftSideBearing = maxchar.leftSideBearing;
+ pInfo->ink_maxbounds.rightSideBearing = maxchar.rightSideBearing;
+ pInfo->ink_maxbounds.characterWidth = maxchar.characterWidth;
+ pInfo->ink_maxbounds.ascent = maxchar.ascent;
+ pInfo->ink_maxbounds.descent = maxchar.descent;
+ pInfo->ink_maxbounds.attributes = maxchar.attributes;
+
+ pInfo->ink_minbounds.leftSideBearing = minchar.leftSideBearing;
+ pInfo->ink_minbounds.rightSideBearing = minchar.rightSideBearing;
+ pInfo->ink_minbounds.characterWidth = minchar.characterWidth;
+ pInfo->ink_minbounds.ascent = minchar.ascent;
+ pInfo->ink_minbounds.descent = minchar.descent;
+ pInfo->ink_minbounds.attributes = minchar.attributes;
+
+ pInfo->maxOverlap = maxlap + -(minchar.leftSideBearing);
+
+ return total_raw_width;
+}
+#endif
+#endif
+
+static void
+ComputeProps(FontInfoPtr pInfo, FontScalablePtr Vals, char *Filename,
+ long *sAscent, long *sDescent)
+{
+ int infoint;
+ int infoBBox[4];
+ int rc;
+
+ QueryFontLib(Filename, "isFixedPitch", &infoint, &rc);
+ if (!rc) {
+ pInfo->constantWidth = infoint;
+ }
+ QueryFontLib((char *)0, "FontBBox", infoBBox, &rc);
+ if (!rc) {
+ pInfo->fontAscent =
+ (int)((double)infoBBox[3] * Vals->pixel_matrix[3] +
+ (infoBBox[3] > 0 ? 500 : -500)) / 1000;
+ pInfo->fontDescent =
+ -(int)((double)infoBBox[1] * Vals->pixel_matrix[3] +
+ (infoBBox[1] > 0 ? 500 : -500)) / 1000;
+ *sAscent = infoBBox[3];
+ *sDescent = -infoBBox[1];
+ }
+}
+
+#if XFONT_CID
+#ifndef CID_ALL_CHARS
+static void
+CIDComputeStdProps(FontInfoPtr pInfo, FontScalablePtr Vals,
+ char *Filename, char *Cmapname, char *Fontname,
+ long sAscent, long sDescent, long sWidth)
+{
+ FontPropPtr pp;
+ int i,
+ nprops;
+ fontProp *fpt;
+ char *is_str;
+ char *ptr1 = NULL,
+ *ptr2;
+ char *ptr3;
+ char *infostrP;
+ int rc;
+ char scaledName[CID_PATH_MAX];
+
+ strcpy (scaledName, Fontname);
+ /* Fill in our copy of the fontname from the Vals structure */
+ FontParseXLFDName (scaledName, Vals, FONT_XLFD_REPLACE_VALUE);
+
+ /* This form of the properties is used by the X-client; the X-server
+ doesn't care what they are. */
+ nprops = pInfo->nprops = NPROPS;
+ pInfo->isStringProp = (char *) xalloc(sizeof(char) * nprops);
+ pInfo->props = (FontPropPtr) xalloc(sizeof(FontPropRec) * nprops);
+ if (!pInfo->isStringProp || !pInfo->props) {
+ xfree(pInfo->isStringProp);
+ pInfo->isStringProp = (char *) 0;
+ xfree(pInfo->props);
+ pInfo->props = (FontPropPtr) 0;
+ pInfo->nprops = 0;
+ return;
+ }
+ bzero(pInfo->isStringProp, (sizeof(char) * nprops));
+
+ ptr2 = scaledName;
+ for (i = NNAMEPROPS, pp = pInfo->props, fpt = fontNamePropTable, is_str = pInfo->isStringProp;
+ i;
+ i--, pp++, fpt++, is_str++) {
+
+ if (*ptr2)
+ {
+ ptr1 = ptr2 + 1;
+ if (!(ptr2 = strchr(ptr1, '-'))) ptr2 = strchr(ptr1, '\0');
+ }
+
+ pp->name = fpt->atom;
+ switch (fpt->type) {
+ case atom: /* Just copy info from scaledName */
+ *is_str = TRUE;
+ pp->value = MakeAtom(ptr1, ptr2 - ptr1, TRUE);
+ break;
+ case truncate_atom:
+ *is_str = TRUE;
+ for (ptr3 = ptr1; *ptr3; ptr3++)
+ if (*ptr3 == '[')
+ break;
+ pp->value = MakeAtom(ptr1, ptr3 - ptr1, TRUE);
+ break;
+ case pixel_size:
+ pp->value = (int)(fabs(Vals->pixel_matrix[3]) + .5);
+ break;
+ case point_size:
+ pp->value = (int)(fabs(Vals->point_matrix[3]) * 10.0 + .5);
+ break;
+ case resolution_x:
+ pp->value = Vals->x;
+ break;
+ case resolution_y:
+ pp->value = Vals->y;
+ break;
+ case average_width:
+ pp->value = Vals->width;
+ break;
+ }
+ }
+
+ for (i = 0, fpt = extraProps;
+ i < NEXTRAPROPS;
+ i++, is_str++, pp++, fpt++) {
+ pp->name = fpt->atom;
+ switch (i) {
+ case FONTPROP:
+ *is_str = TRUE;
+ pp->value = MakeAtom(scaledName, strlen(scaledName), TRUE);
+ break;
+ case COPYRIGHTPROP:
+ *is_str = TRUE;
+ CIDQueryFontLib(Filename, Cmapname, "Notice", &infostrP, &rc);
+ if (rc || !infostrP) {
+ infostrP = "Copyright Notice not available";
+ }
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case FACE_NAMEPROP:
+ *is_str = TRUE;
+ CIDQueryFontLib(Filename, Cmapname, "CIDFontName", &infostrP, &rc);
+ if (rc || !infostrP) {
+ infostrP = "(unknown)";
+ }
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case FONT_TYPEPROP:
+ *is_str = TRUE;
+ infostrP = "CIDFont";
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case RASTERIZER_NAMEPROP:
+ *is_str = TRUE;
+ infostrP = "X Consortium Type 1 Rasterizer";
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case RAWPIXELPROP:
+ *is_str = FALSE;
+ pp->value = 1000;
+ break;
+ case RAWPOINTPROP:
+ *is_str = FALSE;
+ pp->value = (long)(72270.0 / (double)Vals->y + .5);
+ break;
+ case RAWASCENTPROP:
+ *is_str = FALSE;
+ pp->value = sAscent;
+ break;
+ case RAWDESCENTPROP:
+ *is_str = FALSE;
+ pp->value = sDescent;
+ break;
+ case RAWWIDTHPROP:
+ *is_str = FALSE;
+ pp->value = sWidth;
+ break;
+ }
+ }
+}
+#endif
+#endif
+
+static void
+ComputeStdProps(FontInfoPtr pInfo, FontScalablePtr Vals,
+ char *Filename, char *Fontname,
+ long sAscent, long sDescent, long sWidth)
+{
+ FontPropPtr pp;
+ int i,
+ nprops;
+ fontProp *fpt;
+ char *is_str;
+ char *ptr1 = NULL,
+ *ptr2;
+ char *ptr3;
+ char *infostrP;
+ int rc;
+ char scaledName[MAXFONTNAMELEN];
+
+ strcpy (scaledName, Fontname);
+ /* Fill in our copy of the fontname from the Vals structure */
+ FontParseXLFDName (scaledName, Vals, FONT_XLFD_REPLACE_VALUE);
+
+ /* This form of the properties is used by the X-client; the X-server
+ doesn't care what they are. */
+ nprops = pInfo->nprops = NPROPS;
+ pInfo->isStringProp = (char *) xalloc(sizeof(char) * nprops);
+ pInfo->props = (FontPropPtr) xalloc(sizeof(FontPropRec) * nprops);
+ if (!pInfo->isStringProp || !pInfo->props) {
+ xfree(pInfo->isStringProp);
+ pInfo->isStringProp = (char *) 0;
+ xfree(pInfo->props);
+ pInfo->props = (FontPropPtr) 0;
+ return;
+ }
+ bzero(pInfo->isStringProp, (sizeof(char) * nprops));
+
+ ptr2 = scaledName;
+ for (i = NNAMEPROPS, pp = pInfo->props, fpt = fontNamePropTable, is_str = pInfo->isStringProp;
+ i;
+ i--, pp++, fpt++, is_str++) {
+
+ if (*ptr2)
+ {
+ ptr1 = ptr2 + 1;
+ if (!(ptr2 = strchr(ptr1, '-'))) ptr2 = strchr(ptr1, '\0');
+ }
+
+ pp->name = fpt->atom;
+ switch (fpt->type) {
+ case atom: /* Just copy info from scaledName */
+ *is_str = TRUE;
+ pp->value = MakeAtom(ptr1, ptr2 - ptr1, TRUE);
+ break;
+ case truncate_atom:
+ *is_str = TRUE;
+ for (ptr3 = ptr1; *ptr3; ptr3++)
+ if (*ptr3 == '[')
+ break;
+ pp->value = MakeAtom(ptr1, ptr3 - ptr1, TRUE);
+ break;
+ case pixel_size:
+ pp->value = (int)(fabs(Vals->pixel_matrix[3]) + .5);
+ break;
+ case point_size:
+ pp->value = (int)(fabs(Vals->point_matrix[3]) * 10.0 + .5);
+ break;
+ case resolution_x:
+ pp->value = Vals->x;
+ break;
+ case resolution_y:
+ pp->value = Vals->y;
+ break;
+ case average_width:
+ pp->value = Vals->width;
+ break;
+ }
+ }
+
+ for (i = 0, fpt = extraProps;
+ i < NEXTRAPROPS;
+ i++, is_str++, pp++, fpt++) {
+ pp->name = fpt->atom;
+ switch (i) {
+ case FONTPROP:
+ *is_str = TRUE;
+ pp->value = MakeAtom(scaledName, strlen(scaledName), TRUE);
+ break;
+ case COPYRIGHTPROP:
+ *is_str = TRUE;
+ QueryFontLib(Filename, "Notice", &infostrP, &rc);
+ if (rc || !infostrP) {
+ infostrP = "Copyright Notice not available";
+ }
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case FACE_NAMEPROP:
+ *is_str = TRUE;
+ QueryFontLib(Filename, "FontName", &infostrP, &rc);
+ if (rc || !infostrP) {
+ infostrP = "(unknown)";
+ }
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case FONT_TYPEPROP:
+ *is_str = TRUE;
+ infostrP = "Type 1";
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case RASTERIZER_NAMEPROP:
+ *is_str = TRUE;
+ infostrP = "X Consortium Type 1 Rasterizer";
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case RAWPIXELPROP:
+ *is_str = FALSE;
+ pp->value = 1000;
+ break;
+ case RAWPOINTPROP:
+ *is_str = FALSE;
+ pp->value = (long)(72270.0 / (double)Vals->y + .5);
+ break;
+ case RAWASCENTPROP:
+ *is_str = FALSE;
+ pp->value = sAscent;
+ break;
+ case RAWDESCENTPROP:
+ *is_str = FALSE;
+ pp->value = sDescent;
+ break;
+ case RAWWIDTHPROP:
+ *is_str = FALSE;
+ pp->value = sWidth;
+ break;
+ }
+ }
+}
+
+#if XFONT_CID
+/*ARGSUSED*/
+int
+CIDGetInfoScalable(FontPathElementPtr fpe,
+ FontInfoPtr pInfo,
+ FontEntryPtr entry,
+ FontNamePtr fontName,
+ char *fileName,
+ FontScalablePtr Vals)
+{
+ FontPtr pfont;
+ int flags = 0;
+ long format = 0; /* It doesn't matter what format for just info */
+ long fmask = 0;
+ int ret;
+
+ ret = CIDOpenScalable(fpe, &pfont, flags, entry, fileName, Vals,
+ format, fmask, NULL);
+ if (ret != Successful)
+ return ret;
+ *pInfo = pfont->info;
+
+ /* XXX - Set pointers in pfont->info to NULL so they are not freed. */
+ pfont->info.props = NULL;
+ pfont->info.isStringProp = NULL;
+
+ CIDCloseFont(pfont);
+ return Successful;
+}
+#endif
+
+/*ARGSUSED*/
+int
+Type1GetInfoScalable(FontPathElementPtr fpe,
+ FontInfoPtr pInfo,
+ FontEntryPtr entry,
+ FontNamePtr fontName,
+ char *fileName,
+ FontScalablePtr Vals)
+{
+ FontPtr pfont;
+ int flags = 0;
+ long format = 0; /* It doesn't matter what format for just info */
+ long fmask = 0;
+ int ret;
+
+ ret = Type1OpenScalable(fpe, &pfont, flags, entry, fileName, Vals,
+ format, fmask , NULL);
+ if (ret != Successful)
+ return ret;
+ *pInfo = pfont->info;
+
+ /* XXX - Set pointers in pfont->info to NULL so they are not freed. */
+ pfont->info.props = NULL;
+ pfont->info.isStringProp = NULL;
+
+ Type1CloseFont(pfont);
+ return Successful;
+}
+
+#if XFONT_CID
+#ifndef CID_ALL_CHARS
+void
+CIDFillFontInfo(FontPtr pFont, FontScalablePtr Vals,
+ char *Filename, char *Fontname, char *Cmapname,
+#ifdef HAVE_CFM
+ char *cfmfilename,
+#endif
+ long sAscent, long sDescent, double sxmult)
+{
+#ifdef HAVE_CFM
+ FILE *cfm;
+ cfmrec *cfmp;
+ int gotcfm = 0;
+ CARD32 magic;
+#endif
+ long sWidth = 0;
+ FontInfoPtr pInfo = &pFont->info;
+
+ FillHeader(pInfo, Vals);
+
+#ifdef HAVE_CFM
+ if ((cfm = fopen(cfmfilename,"r"))) {
+ fread(&magic,sizeof(CARD32),1,cfm);
+ if(magic == CFMMAGIC) {
+ if ((cfmp = (cfmrec *)xalloc(sizeof(cfmrec))) != NULL) {
+ fread(cfmp,sizeof(cfmrec),1,cfm);
+ sWidth = (long)cfmp->totalrw;
+ pInfo->allExist = cfmp->alle;
+ if (sxmult != 0) {
+ pInfo->maxbounds.leftSideBearing =
+ floor((double)cfmp->maxbounds.leftSideBearing /
+ sxmult + 0.5);
+ pInfo->maxbounds.rightSideBearing =
+ floor((double)cfmp->maxbounds.rightSideBearing /
+ sxmult + 0.5);
+ pInfo->maxbounds.characterWidth =
+ floor((double)cfmp->maxbounds.characterWidth /
+ sxmult + 0.5);
+ pInfo->maxbounds.ascent =
+ floor((double)cfmp->maxbounds.ascent /
+ sxmult + 0.5);
+ pInfo->maxbounds.descent =
+ floor((double)cfmp->maxbounds.descent /
+ sxmult + 0.5);
+ pInfo->maxbounds.attributes =
+ cfmp->maxbounds.attributes;
+
+ pInfo->minbounds.leftSideBearing =
+ cfmp->minbounds.leftSideBearing / sxmult;
+ pInfo->minbounds.rightSideBearing =
+ cfmp->minbounds.rightSideBearing / sxmult;
+ pInfo->minbounds.characterWidth =
+ cfmp->minbounds.characterWidth / sxmult;
+ pInfo->minbounds.ascent =
+ cfmp->minbounds.ascent / sxmult;
+ pInfo->minbounds.descent =
+ cfmp->minbounds.descent / sxmult;
+ pInfo->minbounds.attributes = cfmp->minbounds.attributes;
+
+ pInfo->ink_maxbounds.leftSideBearing =
+ cfmp->ink_maxbounds.leftSideBearing / sxmult;
+ pInfo->ink_maxbounds.rightSideBearing =
+ cfmp->ink_maxbounds.rightSideBearing / sxmult;
+ pInfo->ink_maxbounds.characterWidth =
+ cfmp->ink_maxbounds.characterWidth / sxmult;
+ pInfo->ink_maxbounds.ascent =
+ cfmp->ink_maxbounds.ascent / sxmult;
+ pInfo->ink_maxbounds.descent =
+ cfmp->ink_maxbounds.descent / sxmult;
+ pInfo->ink_maxbounds.attributes =
+ cfmp->ink_maxbounds.attributes;
+
+ pInfo->ink_minbounds.leftSideBearing =
+ cfmp->ink_minbounds.leftSideBearing / sxmult;
+ pInfo->ink_minbounds.rightSideBearing =
+ cfmp->ink_minbounds.rightSideBearing / sxmult;
+ pInfo->ink_minbounds.characterWidth =
+ cfmp->ink_minbounds.characterWidth / sxmult;
+ pInfo->ink_minbounds.ascent =
+ cfmp->ink_minbounds.ascent / sxmult;
+ pInfo->ink_minbounds.descent =
+ cfmp->ink_minbounds.descent / sxmult;
+ pInfo->ink_minbounds.attributes =
+ cfmp->ink_minbounds.attributes;
+ pInfo->ink_minbounds.attributes =
+ cfmp->ink_minbounds.attributes;
+
+ pInfo->maxOverlap = (short)cfmp->maxo;
+
+ gotcfm = 1;
+ }
+ xfree(cfmp);
+ }
+ }
+ fclose(cfm);
+ }
+
+ if (!gotcfm)
+#endif
+ sWidth = ComputeBoundsAll(pFont);
+
+ FontComputeInfoAccelerators(pInfo);
+
+ CIDComputeStdProps(pInfo, Vals, Filename, Cmapname, Fontname, sAscent,
+ sDescent, sWidth);
+}
+#endif /* CID_ALL_CHARS */
+#endif /* BUILDCID */
+
+void
+T1FillFontInfo(FontPtr pFont, FontScalablePtr Vals,
+ char *Filename, char *Fontname, long sWidth)
+{
+ FontInfoPtr pInfo = &pFont->info;
+ struct type1font *p = (struct type1font *)pFont->fontPrivate;
+ long sAscent, sDescent; /* Scalable 1000-pixel values */
+
+ FillHeader(pInfo, Vals);
+
+ ComputeBounds(pInfo, p->glyphs, Vals);
+
+ ComputeProps(pInfo, Vals, Filename, &sAscent, &sDescent);
+ ComputeStdProps(pInfo, Vals, Filename, Fontname, sAscent, sDescent, sWidth);
+}
+
+/* Called once, at renderer registration time */
+void
+#if XFONT_CID
+Type1InitStdProps(void)
+#else
+T1InitStdProps(void)
+#endif
+{
+ int i;
+ fontProp *t;
+
+#if XFONT_CID
+ if (!stdpropsinit) {
+ stdpropsinit = 1;
+ i = sizeof(fontNamePropTable) / sizeof(fontProp);
+ for (t = fontNamePropTable; i; i--, t++)
+ t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+ i = sizeof(extraProps) / sizeof(fontProp);
+ for (t = extraProps; i; i--, t++)
+ t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+ }
+#else
+ i = sizeof(fontNamePropTable) / sizeof(fontProp);
+ for (t = fontNamePropTable; i; i--, t++)
+ t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+ i = sizeof(extraProps) / sizeof(fontProp);
+ for (t = extraProps; i; i--, t++)
+ t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+#endif
+}
diff --git a/nx-X11/lib/font/Type1/t1intf.h b/nx-X11/lib/font/Type1/t1intf.h
new file mode 100644
index 000000000..831acc55d
--- /dev/null
+++ b/nx-X11/lib/font/Type1/t1intf.h
@@ -0,0 +1,143 @@
+/* $Xorg: t1intf.h,v 1.3 2000/08/17 19:46:33 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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 (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/t1intf.h,v 1.6 2001/01/17 19:43:23 dawes Exp $ */
+
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#if XFONT_CID
+#include "AFM.h"
+#endif
+
+struct type1font {
+ CharInfoPtr pDefault;
+ CharInfoRec glyphs[256];
+};
+
+#if XFONT_CID
+typedef struct cid_glyphs {
+ char *CIDFontName;
+ char *CMapName;
+ long dataoffset;
+ double pixel_matrix[4];
+ CharInfoPtr pDefault;
+ CharInfoRec **glyphs;
+ FontInfo *AFMinfo;
+#ifdef USE_MMAP
+ unsigned char *CIDdata;
+ long CIDsize;
+#endif
+} cidglyphs;
+#endif
+
+/*
+ * Function prototypes
+ */
+/* t1funcs.c */
+#if XFONT_CID
+extern int CIDOpenScalable ( FontPathElementPtr fpe, FontPtr *ppFont,
+ int flags, FontEntryPtr entry, char *fileName,
+ FontScalablePtr vals, fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font );
+#endif
+extern int Type1OpenScalable ( FontPathElementPtr fpe, FontPtr *ppFont,
+ int flags, FontEntryPtr entry, char *fileName,
+ FontScalablePtr vals, fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font );
+#if XFONT_CID
+extern unsigned int getCID ( FontPtr pFont, unsigned int charcode );
+extern int CIDGetGlyphs ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, CharInfoPtr *glyphs );
+extern int CIDGetMetrics ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, xCharInfo **glyphs );
+extern void CIDCloseFont ( FontPtr pFont );
+#endif
+extern void Type1CloseFont ( FontPtr pFont );
+extern int Type1ReturnCodeToXReturnCode ( int rc );
+#if XFONT_CID
+extern CharInfoPtr CIDRenderGlyph ( FontPtr pFont, psobj *charstringP,
+ psobj *subarrayP,
+ struct blues_struct *bluesP,
+ CharInfoPtr pci, int *mode );
+#endif
+
+/* t1info.c */
+#ifdef CID_ALL_CHARS
+extern void ComputeBoundsAllChars ( FontPtr pFont, char *cfmfilename, double sxmult );
+#endif
+#if XFONT_CID
+extern int CIDGetInfoScalable ( FontPathElementPtr fpe, FontInfoPtr pInfo,
+ FontEntryPtr entry, FontNamePtr fontName,
+ char *fileName, FontScalablePtr Vals );
+#endif
+extern int Type1GetInfoScalable ( FontPathElementPtr fpe, FontInfoPtr pInfo,
+ FontEntryPtr entry, FontNamePtr fontName,
+ char *fileName, FontScalablePtr Vals );
+#if XFONT_CID
+extern void CIDFillFontInfo ( FontPtr pFont, FontScalablePtr Vals,
+ char *Filename, char *Fontname, char *Cmapname,
+#ifdef HAVE_CFM
+ char *cfmfilename,
+#endif
+ long sAscent, long sDescent, double sxmult );
+#endif
+extern void T1FillFontInfo ( FontPtr pFont, FontScalablePtr Vals,
+ char *Filename, char *Fontname, long sWidth );
+extern void Type1InitStdProps ( void );
+
+/* cidchar.c */
+extern CharInfoPtr CIDGetGlyphInfo ( FontPtr pFont, unsigned int cidcode,
+ CharInfoPtr pci, int *rc );
+extern int CIDGetAFM ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, CharInfoPtr *glyphs,
+ char *cidafmfile );
diff --git a/nx-X11/lib/font/Type1/t1io.c b/nx-X11/lib/font/Type1/t1io.c
new file mode 100644
index 000000000..42b8bb6be
--- /dev/null
+++ b/nx-X11/lib/font/Type1/t1io.c
@@ -0,0 +1,388 @@
+/* $Xorg: t1io.c,v 1.3 2000/08/17 19:46:33 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ * Author: Carol H. Thompson IBM Almaden Research Center
+ */
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/t1io.c,v 3.8 2001/01/17 19:43:23 dawes Exp $ */
+/*******************************************************************
+* I/O package for Type 1 font reading
+********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#ifndef STATIC
+#define STATIC static
+#endif
+
+#ifndef FONTMODULE
+#include <fcntl.h>
+#include <unistd.h>
+#else
+#include "Xdefs.h"
+#include "Xmd.h" /* INT32 declaration */
+#include "xf86_ansic.h"
+#endif
+#include "t1stdio.h"
+#include "t1hdigit.h"
+#ifdef WIN32
+#include <X11/Xw32defs.h>
+#endif
+#include <X11/Xdefs.h>
+
+/* Constants and variables used in the decryption */
+#define c1 ((unsigned short)52845)
+#define c2 ((unsigned short)22719)
+static unsigned short r;
+static int asc, Decrypt;
+static int extrach;
+static int haveextrach;
+
+/* Our single FILE structure and buffer for this package */
+STATIC F_FILE TheFile;
+STATIC unsigned char TheBuffer[F_BUFSIZ];
+
+/* Our routines */
+static int T1Decrypt ( unsigned char *p, int len );
+static int T1Fill ( F_FILE *f );
+
+#if XFONT_CID
+void
+resetDecrypt(void)
+{
+ Decrypt = 0;
+}
+#endif
+
+/* -------------------------------------------------------------- */
+/*ARGSUSED*/
+F_FILE *
+T1Open(char *fn, /* Pointer to filename */
+ char *mode) /* Pointer to open mode string */
+{
+ F_FILE *of = &TheFile;
+ int oflags = O_RDONLY; /* We know we are only reading */
+
+ Decrypt = 0;
+
+#ifdef O_BINARY /* VMS or DOS */
+ oflags |= O_BINARY;
+#endif
+ of->fd = open(fn, oflags, 0);
+ if (of->fd < 0)
+ return NULL;
+
+ /* Initialize the buffer information of our file descriptor */
+ of->b_base = TheBuffer;
+ of->b_size = F_BUFSIZ;
+ of->b_ptr = NULL;
+ of->b_cnt = 0;
+ of->flags = 0;
+ of->error = 0;
+ haveextrach = 0;
+ return &TheFile;
+} /* end Open */
+
+/* -------------------------------------------------------------- */
+int /* Read one character */
+T1Getc(F_FILE *f) /* Stream descriptor */
+{
+ if (f->b_base == NULL) return EOF; /* already closed */
+
+ if (f->flags & UNGOTTENC) { /* there is an ungotten c */
+ f->flags &= ~UNGOTTENC;
+ return (int) f->ungotc;
+ }
+
+ if (f->b_cnt == 0) /* Buffer needs to be (re)filled */
+ f->b_cnt = T1Fill(f);
+ if (f->b_cnt > 0) return (f->b_cnt--, (int) *(f->b_ptr++));
+ else {
+ f->flags |= FIOEOF;
+ return EOF;
+ }
+} /* end Getc */
+
+/* -------------------------------------------------------------- */
+int /* Put back one character */
+T1Ungetc(int c,
+ F_FILE *f) /* Stream descriptor */
+{
+ if (c != EOF) {
+ f->ungotc = c;
+ f->flags |= UNGOTTENC; /* set flag */
+ f->flags &= ~FIOEOF; /* reset EOF */
+ }
+ return c;
+} /* end Ungetc */
+
+/* -------------------------------------------------------------- */
+int /* Read n items into caller's buffer */
+T1Read(char *buffP, /* Buffer to be filled */
+ int size, /* Size of each item */
+ int n, /* Number of items to read */
+ F_FILE *f) /* Stream descriptor */
+{
+ int bytelen, cnt, i;
+ F_char *p = (F_char *)buffP;
+ int icnt; /* Number of characters to read */
+
+ if (f->b_base == NULL) return 0; /* closed */
+ icnt = (size!=1)?n*size:n; /* Number of bytes we want */
+
+ if (f->flags & UNGOTTENC) { /* there is an ungotten c */
+ f->flags &= ~UNGOTTENC;
+ *(p++) = f->ungotc;
+ icnt--; bytelen = 1;
+ }
+ else bytelen = 0;
+
+ while (icnt > 0) {
+ /* First use any bytes we have buffered in the stream buffer */
+ if ((cnt=f->b_cnt) > 0) {
+ if (cnt > icnt) cnt = icnt;
+ for (i=0; i<cnt; i++) *(p++) = *(f->b_ptr++);
+ f->b_cnt -= cnt;
+ icnt -= cnt;
+ bytelen += cnt;
+ }
+
+ if ((icnt == 0) || (f->flags & FIOEOF)) break;
+
+ f->b_cnt = T1Fill(f);
+ }
+ return ((size!=1)?bytelen/size:bytelen);
+} /* end Read */
+
+/* -------------------------------------------------------------- */
+int /* Close the file */
+T1Close(F_FILE *f) /* Stream descriptor */
+{
+ if (f->b_base == NULL) return 0; /* already closed */
+ f->b_base = NULL; /* no valid stream */
+ return close(f->fd);
+} /* end Close */
+
+
+/* -------------------------------------------------------------- */
+F_FILE * /* Initialization */
+T1eexec(F_FILE *f) /* Stream descriptor */
+{
+ int i, c;
+ int H;
+ unsigned char *p;
+ unsigned char randomP[8];
+
+ r = 55665; /* initial key */
+ asc = 1; /* indicate ASCII form */
+
+ /* Consume the 4 random bytes, determining if we are also to
+ ASCIIDecodeHex as we process our input. (See pages 63-64
+ of the Adobe Type 1 Font Format book.) */
+
+ /* Skip over any initial white space chars */
+ while (HighHexP[c=_XT1getc(f)] == HWHITE_SPACE) ;
+
+ /* If ASCII, the next 7 chars are guaranteed consecutive */
+ randomP[0] = c; /* store first non white space char */
+ T1Read((pointer)(randomP+1), 1, 3, f); /* read 3 more, for a total of 4 */
+ /* store first four chars */
+ for (i=0,p=randomP; i<4; i++) { /* Check 4 valid ASCIIEncode chars */
+ if (HighHexP[*p++] > LAST_HDIGIT) { /* non-ASCII byte */
+ asc = 0;
+ break;
+ }
+ }
+ if (asc) { /* ASCII form, convert first eight bytes to binary */
+ T1Read((pointer)(randomP+4), 1, 4, f); /* Need four more */
+ for (i=0,p=randomP; i<4; i++) { /* Convert */
+ H = HighHexP[*p++];
+ randomP[i] = H | LowHexP[*p++];
+ }
+ }
+
+ /* Adjust our key */
+ for (i=0,p=randomP; i<4; i++) {
+ r = (*p++ + r) * c1 + c2;
+ }
+
+ /* Decrypt the remaining buffered bytes */
+ f->b_cnt = T1Decrypt(f->b_ptr, f->b_cnt);
+ Decrypt = 1;
+ return (T1Feof(f))?NULL:f;
+} /* end eexec */
+
+#if XFONT_CID
+F_FILE * /* Initialization */
+CIDeexec(F_FILE *f) /* Stream descriptor */
+{
+ int i, c;
+ int H;
+ unsigned char *p;
+ unsigned char randomP[8];
+
+ r = 55665; /* initial key */
+ asc = 1; /* indicate ASCII form */
+
+ /* Consume the 4 random bytes, determining if we are also to
+ ASCIIDecodeHex as we process our input. (See pages 63-64
+ of the Adobe Type 1 Font Format book.) */
+
+ /* Skip over any initial white space chars */
+ while (HighHexP[c=_XT1getc(f)] == HWHITE_SPACE) ;
+
+ /* If ASCII, the next 7 chars are guaranteed consecutive */
+ randomP[0] = c; /* store first non white space char */
+ T1Read((pointer)(randomP+1), 1, 3, f); /* read 3 more, for a total of 4 */
+ /* store first four chars */
+ for (i=0,p=randomP; i<4; i++) { /* Check 4 valid ASCIIEncode chars */
+ if (HighHexP[*p++] > LAST_HDIGIT) { /* non-ASCII byte */
+ asc = 0;
+ break;
+ }
+ }
+ if (asc) { /* ASCII form, convert first eight bytes to binary */
+ T1Read((pointer)(randomP+4), 1, 4, f); /* Need four more */
+ for (i=0,p=randomP; i<4; i++) { /* Convert */
+ H = HighHexP[*p++];
+ randomP[i] = H | LowHexP[*p++];
+ }
+ }
+
+ /* Adjust our key */
+ for (i=0,p=randomP; i<4; i++) {
+ r = (*p++ + r) * c1 + c2;
+ }
+
+ /* Decrypt up to, but not including, the first '%' sign */
+ if (f->b_cnt > 0) {
+ for (i = 0; i < f->b_cnt; i++)
+ if (*(f->b_ptr + i) == '%')
+ break;
+
+ if (i < f->b_cnt) {
+ if (i == 0)
+ f->b_cnt = 0;
+ else
+ f->b_cnt = T1Decrypt(f->b_ptr, i);
+ } else
+ f->b_cnt = T1Decrypt(f->b_ptr, f->b_cnt);
+ }
+ Decrypt = 1;
+ return (T1Feof(f))?NULL:f;
+} /* end eexec */
+#endif
+
+/* -------------------------------------------------------------- */
+STATIC int
+T1Decrypt(unsigned char *p, int len)
+{
+ int n;
+ int H = 0, L;
+ unsigned char *inp = p;
+ unsigned char *tblP;
+
+ if (asc) {
+ if (haveextrach) {
+ H = extrach;
+ tblP = LowHexP;
+ }
+ else tblP = HighHexP;
+ for (n=0; len>0; len--) {
+ L = tblP[*inp++];
+ if (L == HWHITE_SPACE) continue;
+ if (L > LAST_HDIGIT) break;
+ if (tblP == HighHexP) { /* Got first hexit value */
+ H = L;
+ tblP = LowHexP;
+ } else { /* Got second hexit value; compute value and store it */
+ n++;
+ tblP = HighHexP;
+ H |= L;
+ /* H is an int, 0 <= H <= 255, so all of this will work */
+ *p++ = H ^ (r >> 8);
+ r = (H + r) * c1 + c2;
+ }
+ }
+ if (tblP != HighHexP) { /* We had an odd number of hexits */
+ extrach = H;
+ haveextrach = 1;
+ } else haveextrach = 0;
+ return n;
+ } else {
+ for (n = len; n>0; n--) {
+ H = *inp++;
+ *p++ = H ^ (r >> 8);
+ r = (H + r) * c1 + c2;
+ }
+ return len;
+ }
+} /* end Decrypt */
+
+/* -------------------------------------------------------------- */
+STATIC int /* Refill stream buffer */
+T1Fill(F_FILE *f) /* Stream descriptor */
+{
+ int rc;
+
+ rc = read(f->fd, f->b_base, F_BUFSIZ);
+ /* propagate any error or eof to current file */
+ if (rc <= 0) {
+ if (rc == 0) /* means EOF */
+ f->flags |= FIOEOF;
+ else {
+ f->error = (short)-rc;
+ f->flags |= FIOERROR;
+ rc = 0;
+ }
+ }
+ f->b_ptr = f->b_base;
+ if (Decrypt) rc = T1Decrypt(f->b_base, rc);
+ return rc;
+} /* end Fill */
diff --git a/nx-X11/lib/font/Type1/t1malloc.c b/nx-X11/lib/font/Type1/t1malloc.c
new file mode 100644
index 000000000..20d4212cd
--- /dev/null
+++ b/nx-X11/lib/font/Type1/t1malloc.c
@@ -0,0 +1,759 @@
+/* $Xorg: t1malloc.c,v 1.3 2000/08/17 19:46:34 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK 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.
+ */
+/* $XFree86: xc/lib/font/Type1/t1malloc.c,v 1.11 2002/02/18 20:51:57 herrb Exp $ */
+ /* MALLOC CWEB V0004 LOTS */
+/*
+:h1.MALLOC - Fast Memory Allocation
+
+This module is meant to provide portable C-style memory allocation
+routines (malloc/free).
+
+&author. Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com)
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifndef FONTMODULE
+#include <stdio.h>
+#else
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "os.h"
+#include "xf86_ansic.h"
+#endif
+#include "objects.h" /* get #define for Abort() */
+
+
+/*
+:h3.Define NULL
+
+In the beginning, C compilers made no assumptions about NULL. It was
+even theoretically possible that NULL would not be 0. ANSI has tied
+this down a bit. The following definition seems to be the most
+popular (in terms of reducing compiler complaints), however, if your
+compiler is unhappy about it, you can redefine it on the command line:
+*/
+#ifndef NULL
+#include <stddef.h>
+#endif
+/*
+Of course, NULL is important because xiMalloc() is defined to return
+NULL when out of memory.
+
+:h2.Data Structures Used to Manage Free Memory
+
+:h3.The "freeblock" Structure
+
+The list of available memory blocks is a doubly-linked list. Each
+block begins with the following structure:
+*/
+
+struct freeblock {
+ long size; /* number of 'longs' in block,
+ including this header */
+ struct freeblock *fore; /* forward in doubly-linked list */
+ struct freeblock *back; /* backward in doubly-linked list */
+} ;
+/*
+In addition, each free block has a TRAILER that is simply the 'size'
+repeated. Thus 'size' is found at the beginning of the block and at the
+end of the block (size-1 longs away). 'size' includes both the header
+and the trailer.
+
+When a block is allocated, its 'size' is turned negative (both at the
+beginning and at the end). Thus, checking whether two blocks may be
+combined is very simple. We merely examine both neighboring blocks'
+size to see if they are positive (and hence available for combination).
+
+The memory address returned to the user is therefore one "long" below the
+size, and one extra "long" is added to the end of the block (beyond what
+the user requested) to store the trailing size.
+
+:h3."firstfree" and "lastfree", the Anchors to the Free List
+
+"firstfree" points to the first available free block; "lastfree" points
+to the end of the chain of available blocks. These are linked together
+by initialization code; see :hdref refid=addmem..
+*/
+
+static struct freeblock firstfree = { 0L, NULL, NULL };
+static struct freeblock lastfree = { 0L, NULL, NULL };
+
+/*
+:h3."firstcombined" and "uncombined", Keeping Track of Uncombined Blocks
+
+This module is designed to make the combining of adjacent free memory
+blocks be very fast. Nonetheless, combining blocks is naturally the
+most expensive part of any memory system. In an X system,
+it is worthwhile to defer the combination for a while, because
+frequently we will end up asking for a block of exactly the same
+size that we recently returned and we can save ourselves some work.
+
+"MAXUNCOMBINED" is the maximum number of uncombined blocks that we will
+allow at any time:
+*/
+
+#define MAXUNCOMBINED 3
+
+/*
+"firstcombined" is a pointer into the free list. The uncombined blocks
+are always at the front of the list. "firstcombined" points to the
+first block that has been combined.
+*/
+static struct freeblock *firstcombined = &lastfree;
+static short uncombined = 0; /* current number of uncombined blocks */
+
+/*
+Uncombined blocks have a negative 'size'; in this they are like
+allocated blocks.
+
+We store a distinctive hex pattern in 'size' when we combine a block
+to help us debug:
+*/
+#define COMBINED 0xBADBAD
+
+/*
+:h3.DEBUGWORDS - Extra Memory Saved With Each Block for Debug
+
+We add 'DEBUGWORDS' words to each allocated block to put interesting
+debug information:
+*/
+#ifndef DEBUGWORDS
+#define DEBUGWORDS 0
+#endif
+
+/*
+:h3.MINEXCESS - Amount of "Excess" We Would be Willing to Ignore
+
+When we search the free list to find memory for a user request, we
+frequently find an area that is bigger than what the user has asked for.
+Normally we put the remaining words (the excess) back on the free list.
+However, if the area is just slightly bigger than what the user needs,
+it is counter-productive to do this, as the small amount recovered tends
+to hurt by increasing memory fragmentation rather than help by providing
+more available memory. "MINEXCESS" is the number of words that must be
+recovered before we would bother to put the excess back on the free
+list. If there is not enough excess, we just give the user more than he
+asked for.
+*/
+
+#define MINEXCESS (7 + DEBUGWORDS)
+
+/*
+:h3.Some Flags for Debug
+*/
+
+long AvailableWords = 0; /* number of words available in memory */
+char mallocdebug = 0; /* a flag that enables some chatty printf's */
+
+/*
+:h3.Prototypes of static functions
+*/
+
+static void combine ( void );
+static void freeuncombinable ( long *addr, long size );
+static void unhook ( struct freeblock *p );
+static void dumpchain ( void );
+#ifdef notused
+static void reportarea ( long *area );
+#endif
+
+/*
+:h3.whocalledme() - Debug for Memory Leaks
+
+This routine is 68000-specific; it copies the value of the application's
+curOper variable (which is often a pointer to a character string), and
+the first part of the stack at the time malloc was called into the
+DEBUGWORDS area reserved with each block.
+We use it to see who is malloc-ing memory without free-ing it.
+*/
+
+#if DEBUGWORDS
+
+static void
+whocalledme(long *addr, /* address of memory block */
+ long *stack) /* address of malloc's parameter on stack */
+{
+ register long size; /* size of memory block */
+ register int i; /* loop index */
+ extern char *curOper; /* ptr to last operator (kept by appl.) */
+
+ stack--;
+ size = - *addr;
+
+ addr += size - 1 - DEBUGWORDS;
+ *addr++ = (long) curOper;
+ for (i=0; i < DEBUGWORDS-1; i++)
+ *addr++ = *stack++;
+}
+#else
+
+#define whocalledme(addr, stack)
+
+#endif
+/*
+:h2.xiFree() - User-Callable "Return Memory" Routine
+
+The actual beginning of the block is one 'long' before the address we
+gave to the user. The block begins and ends with '-size' in words.
+*/
+
+void
+xiFree(long *addr) /* user's memory to be returned */
+{
+ register long size; /* amount of memory in this block */
+ register struct freeblock *p; /* identical to 'addr' */
+
+ if (addr == NULL) { /* common "mistake", so allow it (CHT) */
+ printf("\nxiFree(NULL)?\n");
+ return;
+ }
+
+ size = *--addr;
+/*
+Make sure this address looks OK; 'size' must be less than zero (meaning
+the block is allocated) and should be repeated at the end of the block.
+*/
+ if (size >= 0)
+ Abort("free: bad size");
+ if (addr[-1 - size] != size)
+ Abort("free: mismatched size");
+/*
+Now make this a 'freeblock' structure and tack it on the FRONT of the
+free list (where uncombined blocks go):
+*/
+ AvailableWords -= size; /* actually INCREASES AvailableWords */
+ p = (struct freeblock *) addr;
+ p->back = &firstfree;
+ (p->fore = firstfree.fore)->back = p;
+ firstfree.fore = p;
+/*
+If we have too many uncombined blocks, call combine() to combine one.
+*/
+ if (++uncombined > MAXUNCOMBINED) {
+ combine();
+ if (mallocdebug) {
+ printf("xiFree(%p) with combine, ", (void *)addr);
+ dumpchain();
+ }
+ }
+ else {
+ if (mallocdebug) {
+ printf("xiFree(%p), ", (void *)addr);
+ dumpchain();
+ }
+ }
+
+ return;
+}
+
+/*
+:h3.combine() - Subroutine of xiFree() to Combine Blocks
+
+This routine tries to combine the block just before 'firstcombined'.
+In any event, that block will be moved to the end of the list (after
+'firstcombined').
+*/
+
+static void
+combine(void)
+{
+ register struct freeblock *p; /* block we will try to combine */
+ register long *addr; /* identical to 'p' for 'long' access */
+ register long size; /* size of this block */
+ register long size2; /* size of potential combinee */
+
+ p = firstcombined->back;
+ if (p == &firstfree)
+ Abort("why are we combining?");
+
+ addr = (long *) p;
+ size = - p->size;
+ if (--uncombined < 0)
+ Abort("too many combine()s");
+
+ if (addr[-1] < 0 && addr[size] < 0) {
+/*
+We special case the situation where no combining can be done. Then, we
+just mark the chain "combined" (i.e., positive size), move the
+'firstcombined' pointer back in the chain, and return.
+*/
+ addr[0] = addr[size - 1] = size;
+ firstcombined = (struct freeblock *) addr;
+ return;
+ }
+/*
+Otherwise, we unhook this pointer from the chain:
+*/
+ unhook(p);
+/*
+First we attempt to combine this with the block immediately above:
+*/
+ size2 = addr[-1];
+ if (size2 > 0) { /* i.e., block above is free */
+ *addr = COMBINED; /* might help debug */
+ addr -= size2;
+ if (addr[0] != size2)
+ Abort("bad block above");
+ unhook((struct freeblock *)addr);
+ size += size2;
+ }
+/*
+At this point 'addr' and 'size' may be the original block, or it may be
+the newly combined block. Now we attempt to combine it with the block
+below:
+*/
+ p = (struct freeblock *) (addr + size);
+ size2 = p->size;
+
+ if (size2 > 0) { /* i.e., block below is free */
+ p->size = COMBINED;
+ if (size2 != ((long *) p)[size2 - 1])
+ Abort("bad block below");
+ unhook(p);
+ size += size2;
+ }
+/*
+Finally we take the newly combined block and put it on the end of the
+chain by calling the "freeuncombinable" subroutine:
+*/
+ freeuncombinable(addr, size);
+}
+
+/*
+:h3.freeuncombinable() - Free a Block That Need Not be Combined
+
+This block is "uncombinable" either because we have already combined
+it with its eligible neighbors, or perhaps because we know it has
+no neighbors.
+*/
+
+static void
+freeuncombinable(long *addr, /* address of the block to be freed */
+ long size) /* size of block in words */
+{
+ register struct freeblock *p; /* a convenient synonym for 'addr' */
+
+/*
+Mark block allocated and combined by setting its 'size' positive:
+*/
+ addr[size - 1] = addr[0] = size;
+/*
+Now tack the block on the end of the doubly-linked free list:
+*/
+ p = (struct freeblock *) addr;
+ p->fore = &lastfree;
+ (p->back = lastfree.back)->fore = p;
+ lastfree.back = p;
+/*
+If we have previously had no combined blocks, we must update
+'firstcombined' to point to this block:
+*/
+ if (firstcombined->fore == NULL)
+ firstcombined = p;
+}
+
+/*
+:h3.unhook() - Unhook a Block from the Doubly-linked List
+
+The only tricky thing here is to make sure that 'firstcombined' is
+updated if this block happened to be the old 'firstcombined'. (We
+would never be unhooking 'firstfree' or 'lastfree', so we do not
+have to worry about the end cases.)
+*/
+
+static void
+unhook(struct freeblock *p) /* block to unhook */
+{
+ p->back->fore = p->fore;
+ p->fore->back = p->back;
+
+ if (firstcombined == p)
+ firstcombined = p->fore;
+}
+/*
+:h2.xiMalloc() - Main User Entry Point for Getting Memory
+
+We have two slightly different versions of xiMalloc(). In the case
+where we have TYPE1IMAGER and a font cache, we are prepared, when nominally
+out of memory, to loop calling TYPE1IMAGER's GimeSpace() to release font
+cache.
+*/
+
+/* The following code put in by MDC on 11/10/90 */
+
+#ifdef TYPE1IMAGER
+
+static char *malloc_local(unsigned size);
+
+char *
+xiMalloc(unsigned size)
+{
+ char *memaddr;
+
+ while ( (memaddr = malloc_local(size)) == NULL ) {
+ /* Ask TYPE1IMAGER to give us some of its cache back */
+ if ( I_GimeSpace() == 0 ) break; /* We are really, really, out of memory */
+ }
+
+ return(memaddr);
+}
+#endif
+
+/*
+Now begins the real workhorse xiMalloc() (called 'malloc_local' if
+we are taking advantage of TYPE1IMAGER). Its argument is an unsigned;
+at least that lets users with 16-bit integers get a 64K chunk of
+memory, and it is also compatible with the definition of a "size_t"
+in most systems.
+*/
+#ifdef TYPE1IMAGER
+static char *
+malloc_local(unsigned Size) /* number of bytes the user requested */
+#else
+char *
+xiMalloc(unsigned Size)
+#endif
+{
+ register long size = (long)Size; /* a working register for size */
+ register struct freeblock *p; /* tentative block to be returned */
+ register long excess; /* words in excess of user request */
+ register long *area; /* a convenient synonym for 'p' */
+
+/*
+First, we increase 'size' to allow for the two size fields we will
+save with the block, plus any information for debug purposes.
+Then we ensure that the block will be large enough to hold our
+'freeblock' information. Finally we convert it to be in words
+(longs), not bytes, increased to span an integral number of double
+words, so that all memory blocks dispensed with be properly aligned.
+*/
+ size += 2*sizeof(long) + DEBUGWORDS*sizeof(long);
+ if (size < sizeof(struct freeblock) + sizeof(long))
+ size = sizeof(struct freeblock) + sizeof(long);
+ size = ((unsigned) (size + sizeof(double) - 1) / sizeof(double)) * (sizeof(double)/sizeof(long));
+
+/*
+For speed, we will try first to give the user back a very recently
+returned block--one that is on the front of the chain before
+'firstcombined'. These blocks still have negative sizes, and need
+only to be "unhook"ed:
+*/
+ size = -size;
+ for (p=firstfree.fore; p != firstcombined; p=p->fore) {
+ if (p->size == size) {
+ unhook(p);
+ uncombined--;
+ if (mallocdebug) {
+ printf("fast xiMalloc(%ld) = %p, ", size,
+ (void *)p);
+ dumpchain();
+ }
+ AvailableWords += size; /* decreases AvailableWords */
+ whocalledme(p, &Size);
+ return((char *)&p->fore);
+ }
+ }
+/*
+Well, if we get here, there are no uncombined blocks matching the user's
+request. So, we search the rest of the chain for a block that is big
+enough. ('size' becomes positive again):
+*/
+ size = -size;
+ for (;; p = p->fore) {
+/*
+If we hit the end of the chain (p->size == 0), we are probably out of
+memory. However, we should first try to combine any memory that has
+not yet been combined before we give that pessimistic answer. If
+we succeed in combining, we can call ourselves recursively to try to
+allocate the requested amount:
+*/
+ if (p->size == 0) {
+ if (uncombined <= 0)
+ return(NULL);
+ while (firstfree.fore != firstcombined)
+ combine();
+ return(xiMalloc(sizeof(long) * (size - 2 - DEBUGWORDS)));
+ }
+/*
+Otherwise, we keep searching until we find a big enough block:
+*/
+ if (p->size >= size)
+ break;
+ }
+/*
+At this point, 'p' contains a block at least as big as what the user
+requested, so we take it off the free chain. If it is excessively big,
+we return the excess to the free chain:
+*/
+ unhook(p);
+ excess = p->size - size;
+ area = (long *) p;
+
+ if (excess > MINEXCESS)
+ freeuncombinable(area + size, excess);
+ else
+ size = p->size;
+
+ AvailableWords -= size;
+/*
+Mark first and last word of block with the negative of the size, to
+flag that this block is allocated:
+*/
+ area[size - 1] = area[0] = - size;
+
+ if (mallocdebug) {
+ printf("slow xiMalloc(%ld) @ %p, ", size, (void *)area);
+ dumpchain();
+ }
+ whocalledme(area, &Size);
+/*
+The address we return to the user is one 'long' BELOW the address of
+the block. This protects our 'size' field, so we can tell the size
+of the block when he returns it to us with xiFree(). Also, he better not
+touch the 'size' field at the end of the block either. (That would be
+nasty of him, as he would be touching memory outside of the bytes he
+requested).
+*/
+ return((char *) (area + 1));
+}
+
+/*
+:h2 id=addmem.addmemory() - Initialize Free Memory
+
+This routine should be called at initialization to initialize the
+free chain. There is no standard way to do this in C.
+We want the memory dispensed by malloc to be aligned on a double word
+boundary (because some machines either require alignment, or are
+more efficient if accesses are aligned). Since the total size of
+any block created by malloc is an integral number of double words,
+all we have to do to ensure alignment is to adjust each large block
+added to the free chain to start on an odd long-word boundary.
+(Malloc's size field will occupy the odd long and the user's memory
+will then begin on an even boundary.) Since we fill in additional
+size fields at the beginning and end of each of the large freeblocks,
+we need only adjust the address passed to addmemory to a double word
+boundary.
+*/
+
+#define MAXAREAS 10 /* there can be this many calls to addmemory() */
+
+static long *freearea[MAXAREAS] = { NULL }; /* so we can report later */
+
+void
+addmemory(long *addr, /* beginning of free area */
+ long size) /* number of bytes of free area */
+{
+ register int i; /* loop index variable */
+ register long *aaddr; /* aligned beginning of free area */
+
+#if DEBUGWORDS
+ printf("malloc has DEBUGWORDS=%d\n", DEBUGWORDS);
+#endif
+/*
+First link together firstfree and lastfree if necessary:
+*/
+ if (firstfree.fore == NULL) {
+ firstfree.fore = &lastfree;
+ lastfree.back = &firstfree;
+ }
+/*
+We'll record where the area was that was given to us for later reports:
+*/
+ for (i=0; i < MAXAREAS; i++)
+ if (freearea[i] == NULL) break;
+ if (i >= MAXAREAS)
+ Abort("too many addmemory()s");
+ aaddr = (long *) ( ((long) addr + sizeof(double) - 1) & - (long)sizeof(double) );
+ size -= (char *) aaddr - (char *) addr;
+ freearea[i] = aaddr;
+/*
+Convert 'size' to number of longs, and store '-size' guards at the
+beginning and end of this area so we will not accidentally recombine the
+first or last block:
+*/
+ size /= sizeof(long);
+
+ AvailableWords += size - 2;
+
+ aaddr[size - 1] = aaddr[0] = -size;
+/*
+Finally, call 'freeuncombinable' to put the remaining memory on the
+free list:
+*/
+ freeuncombinable(aaddr + 1, size - 2);
+}
+
+/*
+:h3.delmemory() - Delete Memory Pool
+*/
+void
+delmemory(void)
+{
+ register int i;
+
+ AvailableWords = 0;
+ firstfree.fore = &lastfree;
+ lastfree.back = &firstfree;
+ firstcombined = &lastfree;
+ uncombined = 0;
+ for (i=0; i<MAXAREAS; i++)
+ freearea[i] = NULL;
+}
+
+/*
+:h2.Debug Routines
+
+:h3.dumpchain() - Print the Chain of Free Blocks
+*/
+
+static void
+dumpchain(void)
+{
+ register struct freeblock *p; /* current free block */
+ register long size; /* size of block */
+ register struct freeblock *back; /* block before 'p' */
+ register int i; /* temp variable for counting */
+
+ printf("DUMPING FAST FREE LIST:\n");
+ back = &firstfree;
+ for (p = firstfree.fore, i=uncombined; p != firstcombined;
+ p = p->fore) {
+ if (--i < 0)
+ Abort("too many uncombined areas");
+ size = p->size;
+ printf(". . . area @ %p, size = %ld\n", (void *)p, -size);
+ if (size >= 0 || size != ((int *) p)[-1 - size])
+ Abort("dumpchain: bad size");
+ if (p->back != back)
+ Abort("dumpchain: bad back");
+ back = p;
+ }
+ printf("DUMPING COMBINED FREE LIST:\n");
+ for (; p != &lastfree; p = p->fore) {
+ size = p->size;
+ printf(". . . area @ %p, size = %ld\n", (void *)p, size);
+ if (size <= 0 || size != ((int *) p)[size - 1])
+ Abort("dumpchain: bad size");
+ if (p->back != back)
+ Abort("dumpchain: bad back");
+ back = p;
+ }
+ if (back != lastfree.back)
+ Abort("dumpchain: bad lastfree");
+}
+
+#ifdef notused
+/*
+:h3.reportarea() - Display a Contiguous Set of Memory Blocks
+*/
+
+static void
+reportarea(long *area) /* start of blocks (from addmemory) */
+{
+ register long size; /* size of current block */
+ register long wholesize; /* size of original area */
+ register struct freeblock *p; /* pointer to block */
+
+ if (area == NULL)
+ return;
+ wholesize = - *area++;
+ wholesize -= 2;
+
+ while (wholesize > 0) {
+ size = *area;
+ if (size < 0) {
+ register int i,j;
+
+ size = -size;
+ printf("Allocated %5ld bytes at %p, first words=%08lx %08lx\n",
+ size * sizeof(long), area + 1, area[1], area[2]);
+#if DEBUGWORDS
+ printf(" ...Last operator: %s\n",
+ (char *)area[size-DEBUGWORDS-1]);
+#endif
+ for (i = size - DEBUGWORDS; i < size - 2; i += 8) {
+ printf(" ...");
+ for (j=0; j<8; j++)
+ printf(" %08lx", area[i+j]);
+ printf("\n");
+ }
+
+ }
+ else {
+ printf("Free %ld bytes at %p\n", size * sizeof(long),
+ area);
+ if (size == 0)
+ Abort("zero sized memory block");
+
+ for (p = firstfree.fore; p != NULL; p = p->fore)
+ if ((long *) p == area) break;
+ if ((long *) p != area)
+ Abort("not found on forward chain");
+
+ for (p = lastfree.back; p != NULL; p = p->back)
+ if ((long *) p == area) break;
+ if ((long *) p != area)
+ Abort("not found on backward chain");
+ }
+ if (area[0] != area[size - 1])
+ Abort("unmatched check sizes");
+ area += size;
+ wholesize -= size;
+ }
+}
+
+/*
+:h3.MemReport() - Display All of Memory
+*/
+
+void
+MemReport(void)
+{
+ register int i;
+
+ dumpchain();
+
+ for (i=0; i<MAXAREAS; i++)
+ reportarea(freearea[i]);
+}
+
+/*
+:h3.MemBytesAvail - Display Number of Bytes Now Available
+*/
+
+void
+MemBytesAvail(void)
+{
+ printf("There are now %ld bytes available\n", AvailableWords *
+ sizeof(long) );
+}
+#endif
diff --git a/nx-X11/lib/font/Type1/t1snap.c b/nx-X11/lib/font/Type1/t1snap.c
new file mode 100644
index 000000000..5618b581b
--- /dev/null
+++ b/nx-X11/lib/font/Type1/t1snap.c
@@ -0,0 +1,85 @@
+/* $Xorg: t1snap.c,v 1.3 2000/08/17 19:46:34 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* $XFree86: xc/lib/font/Type1/t1snap.c,v 1.3 1999/08/22 08:58:54 dawes Exp $ */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "pictures.h"
+
+/*
+:h2.Handle Functions
+
+:h3.Phantom() - Returns a Move Segment Equivalent to Handles
+
+This is a user operator. Its new name is QueryHandle.
+*/
+
+struct segment *
+t1_Phantom(struct segment *p) /* object to take the Phantom of */
+{
+ struct fractpoint pt; /* handle size will built here */
+
+ if (p == NULL)
+ pt.x = pt.y = 0;
+ else
+ PathDelta(p, &pt);
+
+ return(PathSegment(MOVETYPE, pt.x, pt.y));
+}
+
+/*
+:h3.Snap() - Force Ending Handle of Object to Origin
+
+This is a user operator.
+*/
+
+struct segment *
+t1_Snap(struct segment *p) /* path to snap */
+{
+ struct fractpoint pt; /* for finding length of path */
+
+ if (p == NULL)
+ return(NULL);
+ p = UniquePath(p);
+
+ PathDelta(p, &pt);
+ if (p->last->type == MOVETYPE) {
+ p->last->dest.x -= pt.x;
+ p->last->dest.y -= pt.y;
+ }
+ else
+ p = JoinSegment(p, MOVETYPE, -pt.x, -pt.y, NULL);
+ return(p);
+}
diff --git a/nx-X11/lib/font/Type1/t1stdio.h b/nx-X11/lib/font/Type1/t1stdio.h
new file mode 100644
index 000000000..2ed083253
--- /dev/null
+++ b/nx-X11/lib/font/Type1/t1stdio.h
@@ -0,0 +1,101 @@
+/* $Xorg: t1stdio.h,v 1.3 2000/08/17 19:46:34 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* $XFree86: xc/lib/font/Type1/t1stdio.h,v 1.9 2001/01/17 19:43:24 dawes Exp $ */
+/* T1IO FILE structure and related stuff */
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#ifdef XFree86LOADER
+#undef FILE
+#endif
+#define FILE F_FILE
+typedef unsigned char F_char;
+
+typedef struct F_FILE {
+ F_char *b_base; /* Pointer to beginning of buffer */
+ long b_size; /* Size of the buffer */
+ F_char *b_ptr; /* Pointer to next char in buffer */
+ long b_cnt; /* Number of chars remaining in buffer */
+ F_char flags; /* other flags; != 0 means getc must call fgetc */
+ F_char ungotc; /* Place for ungotten char; flag set if present */
+ short error; /* error status */
+ int fd; /* underlying file descriptor */
+} F_FILE;
+
+
+/* defines for flags */
+#define UNGOTTENC (0x01)
+#define FIOEOF (0x80)
+#define FIOERROR (0x40)
+
+#ifndef NULL
+#include <stddef.h>
+#endif
+
+#define EOF (-1) /* end of file */
+#define F_BUFSIZ (512)
+
+#define _XT1getc(f) \
+ ( \
+ ( ((f)->b_cnt > 0) && ((f)->flags == 0) ) ? \
+ ( (f)->b_cnt--, (unsigned int)*( (f)->b_ptr++ ) ) : \
+ T1Getc(f) \
+ )
+
+#define T1Feof(f) (((f)->flags & FIOEOF) && ((f)->b_cnt==0))
+
+#if XFONT_CID
+extern F_FILE *CIDeexec ( FILE *f );
+#endif
+
+extern FILE *T1Open ( char *fn, char *mode );
+extern int T1Getc ( FILE *f );
+extern int T1Ungetc ( int c, FILE *f );
+extern int T1Read ( char *buffP, int size, int n, FILE *f );
+extern int T1Close ( FILE *f );
+extern FILE *T1eexec ( FILE *f );
+extern void resetDecrypt ( void );
+
+#undef fclose
+#undef fopen
+#undef ungetc
+#undef fgetc
+#undef fread
+#undef feof
+#undef ferror
+#define fclose(f) T1Close(f)
+#define fopen(name,mode) T1Open(name,mode)
+#define ungetc(c,f) T1Ungetc(c,f)
+#define fgetc(f) T1Getc(f)
+
+#define fread(bufP,size,n,f) T1Read(bufP,size,n,f)
+#define feof(f) (((f)->flags & FIOEOF) && ((f)->b_cnt==0))
+#define ferror(f) (((f)->flags & FIOERROR)?(f)->error:0)
diff --git a/nx-X11/lib/font/Type1/t1stub.c b/nx-X11/lib/font/Type1/t1stub.c
new file mode 100644
index 000000000..2fb1d797f
--- /dev/null
+++ b/nx-X11/lib/font/Type1/t1stub.c
@@ -0,0 +1,56 @@
+/* $Xorg: t1stub.c,v 1.3 2000/08/17 19:46:34 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* $XFree86: xc/lib/font/Type1/t1stub.c,v 1.8 2001/01/17 19:43:24 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef FONTMODULE
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "os.h"
+#include "xf86_ansic.h"
+#else
+#include <stdio.h>
+#endif
+#include "objects.h" /* get #define for Abort() */
+
+static void
+xiStub(void)
+{
+ printf("xiStub called\n");
+ Abort("xiStub called");
+}
+
+void
+t1_DumpText(void)
+{
+ xiStub();
+}
diff --git a/nx-X11/lib/font/Type1/t1test.c b/nx-X11/lib/font/Type1/t1test.c
new file mode 100644
index 000000000..1da74168f
--- /dev/null
+++ b/nx-X11/lib/font/Type1/t1test.c
@@ -0,0 +1,246 @@
+/* $Xorg: t1test.c,v 1.3 2000/08/17 19:46:34 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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/fonts/fntfilst.h>
+#include <X11/fonts/FSproto.h>
+
+#define DECIPOINTSPERINCH 722.7
+#define DEFAULTRES 75
+#define DEFAULTPOINTSIZE 120
+
+FontScalableRec vals;
+FontEntryRec entry;
+
+int main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ int h;
+ char temp[80];
+ char file[80];
+ char glyphcode[1];
+ FontPtr fontptr;
+ CharInfoRec *glyphs[1];
+ int count;
+ int code;
+ int rc = -1;
+
+ T1FillVals(&vals);
+ Type1RegisterFontFileFunctions();
+ entry.name.name = "-adobe-utopia-medium-r-normal--0-0-0-0-p-0-iso8859-1";
+
+ for (;;) {
+ printf("T1TEST: ");
+ gets(temp);
+ glyphcode[0] = '\0';
+
+ switch(temp[0]) {
+
+ case 'c':
+ if (1 != sscanf(&temp[2], "%c", glyphcode))
+ printf("glyph code?\n");
+ break;
+
+ case 'x':
+ if (1 != sscanf(&temp[2], "%x", &code))
+ printf("glyph code?\n");
+ else
+ glyphcode[0] = code;
+ break;
+
+ case 'd':
+ if (1 != sscanf(&temp[2], "%d", &code))
+ printf("glyph code?\n");
+ else
+ glyphcode[0] = code;
+ break;
+
+ case 'h':
+ if (1 != sscanf(&temp[2], "%d", &h))
+ printf("height?\n");
+ vals.pixel = h;
+ rc = Type1OpenScalable(NULL, &fontptr, 0, &entry, file, &vals, 0, 0);
+ break;
+
+ case 'f':
+ if (1 != sscanf(&temp[2], "%s", file))
+ printf("file name?\n");
+ rc = Type1OpenScalable(NULL, &fontptr, 0, &entry, file, &vals, 0, 0);
+ break;
+
+ case 't':
+ if (1 != sscanf(&temp[2], "%s", file))
+ printf("file name?\n");
+ vals.pixel = 8;
+ rc = Type1OpenScalable(NULL, &fontptr, 0, &entry, file, &vals, 0, 0);
+ if (rc != Successful) break;
+ vals.pixel = 20;
+ rc = Type1OpenScalable(NULL, &fontptr, 0, &entry, file, &vals, 0, 0);
+ if (rc != Successful) break;
+ vals.pixel = 50;
+ rc = Type1OpenScalable(NULL, &fontptr, 0, &entry, file, &vals, 0, 0);
+ glyphcode[0] = 'A';
+ printf("From font '%s':\n", file);
+ break;
+
+ case 'q':
+ return 0;
+
+ default:
+ printf("unknown command '%c', must one of 'qfchdxt'\n", temp[0]);
+
+ }
+ if (rc == Successful) {
+ if (glyphcode[0] != '\0') {
+ (*fontptr->get_glyphs)(fontptr, 1, glyphcode, 0, &count, glyphs);
+ if (count > 0)
+ Display(glyphs[0]);
+ else
+ printf("Code %x not valid in this font\n", glyphcode[0]);
+ }
+ }
+ else
+ printf("Bad font (rc = %d, file='%s')\n", rc, file);
+ }
+}
+
+static void Display(glyph)
+ CharInfoRec *glyph;
+{
+ int h,w;
+ unsigned char *p;
+ int data;
+ int i;
+
+ p = glyph->bits;
+
+ printf("Metrics: left=%d, right=%d, w=%d, above=%d, below=%d\n",
+ glyph->metrics.leftSideBearing,
+ glyph->metrics.rightSideBearing,
+ glyph->metrics.characterWidth,
+ glyph->metrics.ascent,
+ glyph->metrics.descent);
+
+ for (h=glyph->metrics.ascent + glyph->metrics.descent; --h >= 0;) {
+ w = glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing;
+ while (w > 0) {
+ data = *p++;
+ for (i=0; i<8; i++) {
+ if (--w < 0)
+ break;
+ if (data & 0x80)
+ printf("X");
+ else
+ printf(".");
+ data <<= 1;
+ }
+ }
+ printf("\n");
+ }
+}
+
+T1FillVals(vals)
+ FontScalablePtr vals;
+{
+ FontResolutionPtr res;
+ int x_res = DEFAULTRES;
+ int y_res = DEFAULTRES;
+ int pointsize = DEFAULTPOINTSIZE; /* decipoints */
+ int num_res;
+
+ /* Must have x, y, and pixel */
+ if (!vals->x || !vals->y || !vals->pixel) {
+ res = GetClientResolutions(&num_res);
+ if (num_res) {
+ if (res->x_resolution)
+ x_res = res->x_resolution;
+ if (res->y_resolution)
+ y_res = res->y_resolution;
+ if (res->point_size)
+ pointsize = res->point_size;
+ }
+ if (!vals->x)
+ vals->x = x_res;
+ if (!vals->y)
+ vals->y = y_res;
+ if (!vals->point) {
+ if (!vals->pixel) vals->point = pointsize;
+ else vals->point = (vals->pixel * DECIPOINTSPERINCH) / vals->y;
+ }
+ if (!vals->pixel)
+ vals->pixel = (vals->point * vals->y) / DECIPOINTSPERINCH;
+ /* Make sure above arithmetic is normally in range and will
+ round properly. +++ */
+ }
+}
+
+int CheckFSFormat(format, fmask, bit, byte, scan, glyph, image)
+ int format,fmask,*bit,*byte,*scan,*glyph,*image;
+{
+ *bit = *byte = 1;
+ *glyph = *scan = *image = 1;
+ return Successful;
+
+}
+
+char *MakeAtom(p)
+ char *p;
+{
+ return p;
+}
+
+
+FontResolutionPtr GetClientResolutions(resP)
+ int *resP;
+{
+ *resP = 0;
+};
+
+char *Xalloc(size)
+ int size;
+{
+ extern char *malloc();
+ return(malloc(size));
+}
+
+void Xfree()
+{
+ free();
+}
+
+FontDefaultFormat() { ; }
+
+FontFileRegisterRenderer() { ; }
+
+GenericGetBitmaps() { ; }
+GenericGetExtents() { ; }
+
+FontParseXLFDName() { ; }
+FontComputeInfoAccelerators() { ; }
diff --git a/nx-X11/lib/font/Type1/t1unicode.c b/nx-X11/lib/font/Type1/t1unicode.c
new file mode 100644
index 000000000..136cc4441
--- /dev/null
+++ b/nx-X11/lib/font/Type1/t1unicode.c
@@ -0,0 +1,251 @@
+/*
+Copyright (c) 1998 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "t1unicode.h"
+
+static char* table_32[] =
+{ "space", "exclam", "quotedbl", "numbersign", "dollar", "percent",
+ "ampersand", "quotesingle", "parenleft", "parenright", "asterisk",
+ "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two",
+ "three", "four", "five", "six", "seven", "eight", "nine", "colon",
+ "semicolon", "less", "equal", "greater", "question", "at", "A", "B",
+ "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
+ "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft",
+ "backslash", "bracketright", "asciicircum", "underscore", "grave",
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
+ "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
+ "braceleft", "bar", "braceright", "asciitilde", 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, "space", "exclamdown", "cent", "sterling", "currency", "yen",
+ "brokenbar", "section", "dieresis", "copyright", "ordfeminine",
+ "guillemotleft", "logicalnot", "hyphen", "registered", "macron",
+ "degree", "plusminus", "twosuperior", "threesuperior", "acute", "mu",
+ "paragraph", "periodcentered", "cedilla", "onesuperior",
+ "ordmasculine", "guillemotright", "onequarter", "onehalf",
+ "threequarters", "questiondown", "Agrave", "Aacute", "Acircumflex",
+ "Atilde", "Adieresis", "Aring", "AE", "Ccedilla", "Egrave", "Eacute",
+ "Ecircumflex", "Edieresis", "Igrave", "Iacute", "Icircumflex",
+ "Idieresis", "Eth", "Ntilde", "Ograve", "Oacute", "Ocircumflex",
+ "Otilde", "Odieresis", "multiply", "Oslash", "Ugrave", "Uacute",
+ "Ucircumflex", "Udieresis", "Yacute", "Thorn", "germandbls", "agrave",
+ "aacute", "acircumflex", "atilde", "adieresis", "aring", "ae",
+ "ccedilla", "egrave", "eacute", "ecircumflex", "edieresis", "igrave",
+ "iacute", "icircumflex", "idieresis", "eth", "ntilde", "ograve",
+ "oacute", "ocircumflex", "otilde", "odieresis", "divide", "oslash",
+ "ugrave", "uacute", "ucircumflex", "udieresis", "yacute", "thorn",
+ "ydieresis", "Amacron", "amacron", "Abreve", "abreve", "Aogonek",
+ "aogonek", "Cacute", "cacute", "Ccircumflex", "ccircumflex",
+ "Cdotaccent", "cdotaccent", "Ccaron", "ccaron", "Dcaron", "dcaron",
+ "Dcroat", "dcroat", "Emacron", "emacron", "Ebreve", "ebreve",
+ "Edotaccent", "edotaccent", "Eogonek", "eogonek", "Ecaron", "ecaron",
+ "Gcircumflex", "gcircumflex", "Gbreve", "gbreve", "Gdotaccent",
+ "gdotaccent", "Gcommaaccent", "gcommaaccent", "Hcircumflex",
+ "hcircumflex", "Hbar", "hbar", "Itilde", "itilde", "Imacron",
+ "imacron", "Ibreve", "ibreve", "Iogonek", "iogonek", "Idotaccent",
+ "dotlessi", "IJ", "ij", "Jcircumflex", "jcircumflex", "Kcommaaccent",
+ "kcommaaccent", "kgreenlandic", "Lacute", "lacute", "Lcommaaccent",
+ "lcommaaccent", "Lcaron", "lcaron", "Ldot", "ldot", "Lslash",
+ "lslash", "Nacute", "nacute", "Ncommaaccent", "ncommaaccent",
+ "Ncaron", "ncaron", "napostrophe", "Eng", "eng", "Omacron", "omacron",
+ "Obreve", "obreve", "Ohungarumlaut", "ohungarumlaut", "OE", "oe",
+ "Racute", "racute", "Rcommaaccent", "rcommaaccent", "Rcaron",
+ "rcaron", "Sacute", "sacute", "Scircumflex", "scircumflex",
+ "Scommaaccent", "scommaaccent", "Scaron", "scaron", "Tcommaaccent",
+ "tcommaaccent", "Tcaron", "tcaron", "Tbar", "tbar", "Utilde",
+ "utilde", "Umacron", "umacron", "Ubreve", "ubreve", "Uring", "uring",
+ "Uhungarumlaut", "uhungarumlaut", "Uogonek", "uogonek", "Wcircumflex",
+ "wcircumflex", "Ycircumflex", "ycircumflex", "Ydieresis", "Zacute",
+ "zacute", "Zdotaccent", "zdotaccent", "Zcaron", "zcaron", "longs", 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "florin", 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Ohorn", "ohorn", 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, "Uhorn", "uhorn", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Gcaron",
+ "gcaron", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "Aringacute", "aringacute", "AEacute", "aeacute", "Oslashacute",
+ "oslashacute", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57929", "afii64937", 0, 0, 0, 0, 0, 0,
+ 0, 0, "circumflex", "caron", 0, "macron", 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, "breve", "dotaccent", "ring", "ogonek", "tilde",
+ "hungarumlaut", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "gravecomb",
+ "acutecomb", 0, "tildecomb", 0, 0, 0, 0, 0, "hookabovecomb", 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "dotbelowcomb", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "tonos", "dieresistonos", "Alphatonos",
+ "anoteleia", "Epsilontonos", "Etatonos", "Iotatonos", 0,
+ "Omicrontonos", 0, "Upsilontonos", "Omegatonos", "iotadieresistonos",
+ "Alpha", "Beta", "Gamma", "Delta", "Epsilon", "Zeta", "Eta", "Theta",
+ "Iota", "Kappa", "Lambda", "Mu", "Nu", "Xi", "Omicron", "Pi", "Rho",
+ 0, "Sigma", "Tau", "Upsilon", "Phi", "Chi", "Psi", "Omega",
+ "Iotadieresis", "Upsilondieresis", "alphatonos", "epsilontonos",
+ "etatonos", "iotatonos", "upsilondieresistonos", "alpha", "beta",
+ "gamma", "delta", "epsilon", "zeta", "eta", "theta", "iota", "kappa",
+ "lambda", "mu", "nu", "xi", "omicron", "pi", "rho", "sigma1", "sigma",
+ "tau", "upsilon", "phi", "chi", "psi", "omega", "iotadieresis",
+ "upsilondieresis", "omicrontonos", "upsilontonos", "omegatonos", 0, 0,
+ "theta1", "Upsilon1", 0, 0, "phi1", "omega1", 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii10023", "afii10051",
+ "afii10052", "afii10053", "afii10054", "afii10055", "afii10056",
+ "afii10057", "afii10058", "afii10059", "afii10060", "afii10061", 0,
+ "afii10062", "afii10145", "afii10017", "afii10018", "afii10019",
+ "afii10020", "afii10021", "afii10022", "afii10024", "afii10025",
+ "afii10026", "afii10027", "afii10028", "afii10029", "afii10030",
+ "afii10031", "afii10032", "afii10033", "afii10034", "afii10035",
+ "afii10036", "afii10037", "afii10038", "afii10039", "afii10040",
+ "afii10041", "afii10042", "afii10043", "afii10044", "afii10045",
+ "afii10046", "afii10047", "afii10048", "afii10049", "afii10065",
+ "afii10066", "afii10067", "afii10068", "afii10069", "afii10070",
+ "afii10072", "afii10073", "afii10074", "afii10075", "afii10076",
+ "afii10077", "afii10078", "afii10079", "afii10080", "afii10081",
+ "afii10082", "afii10083", "afii10084", "afii10085", "afii10086",
+ "afii10087", "afii10088", "afii10089", "afii10090", "afii10091",
+ "afii10092", "afii10093", "afii10094", "afii10095", "afii10096",
+ "afii10097", 0, "afii10071", "afii10099", "afii10100", "afii10101",
+ "afii10102", "afii10103", "afii10104", "afii10105", "afii10106",
+ "afii10107", "afii10108", "afii10109", 0, "afii10110", "afii10193", 0,
+ 0, "afii10146", "afii10194", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "afii10147", "afii10195", "afii10148", "afii10196", 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "afii10050", "afii10098", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii10846", 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "afii57799", "afii57801", "afii57800", "afii57802", "afii57793",
+ "afii57794", "afii57795", "afii57798", "afii57797", "afii57806", 0,
+ "afii57796", "afii57807", "afii57839", "afii57645", "afii57841",
+ "afii57842", "afii57804", "afii57803", "afii57658", 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, "afii57664", "afii57665", "afii57666", "afii57667",
+ "afii57668", "afii57669", "afii57670", "afii57671", "afii57672",
+ "afii57673", "afii57674", "afii57675", "afii57676", "afii57677",
+ "afii57678", "afii57679", "afii57680", "afii57681", "afii57682",
+ "afii57683", "afii57684", "afii57685", "afii57686", "afii57687",
+ "afii57688", "afii57689", "afii57690", 0, 0, 0, 0, 0, "afii57716",
+ "afii57717", "afii57718", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57388", 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, "afii57403", 0, 0, 0, "afii57407", 0, "afii57409",
+ "afii57410", "afii57411", "afii57412", "afii57413", "afii57414",
+ "afii57415", "afii57416", "afii57417", "afii57418", "afii57419",
+ "afii57420", "afii57421", "afii57422", "afii57423", "afii57424",
+ "afii57425", "afii57426", "afii57427", "afii57428", "afii57429",
+ "afii57430", "afii57431", "afii57432", "afii57433", "afii57434", 0, 0,
+ 0, 0, 0, "afii57440", "afii57441", "afii57442", "afii57443",
+ "afii57444", "afii57445", "afii57446", "afii57470", "afii57448",
+ "afii57449", "afii57450", "afii57451", "afii57452", "afii57453",
+ "afii57454", "afii57455", "afii57456", "afii57457", "afii57458", 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57392", "afii57393",
+ "afii57394", "afii57395", "afii57396", "afii57397", "afii57398",
+ "afii57399", "afii57400", "afii57401", "afii57381", 0, 0, "afii63167",
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57511", 0, 0, 0, 0, "afii57506",
+ 0, 0, 0, 0, 0, 0, 0, "afii57507", 0, "afii57512", 0, 0, 0, 0, 0, 0, 0,
+ 0, "afii57513", 0, 0, 0, 0, 0, 0, "afii57508", 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, "afii57505", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57509", 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, "afii57514", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57519", 0, 0, "afii57534", 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+static char* table_2000[] = /* general punctuation, s*scripts, currency */
+{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii61664", "afii301", "afii299",
+ "afii300", 0, 0, "figuredash", "endash", "emdash", "afii00208", 0,
+ "underscoredbl", "quoteleft", "quoteright", "quotesinglbase",
+ "quotereversed", "quotedblleft", "quotedblright", "quotedblbase", 0,
+ "dagger", "daggerdbl", "bullet", 0, "onedotenleader",
+ "twodotenleader", "ellipsis", 0, 0, 0, 0, 0, "afii61573", "afii61574",
+ "afii61575", 0, "perthousand", 0, "minute", "second", 0, 0, 0, 0, 0,
+ "guilsinglleft", "guilsinglright", 0, "exclamdbl", 0, 0, 0, 0, 0, 0,
+ 0, "fraction", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, "zerosuperior", 0, 0, 0, "foursuperior", "fivesuperior",
+ "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", 0, 0,
+ 0, "parenleftsuperior", "parenrightsuperior", "nsuperior",
+ "zeroinferior", "oneinferior", "twoinferior", "threeinferior",
+ "fourinferior", "fiveinferior", "sixinferior", "seveninferior",
+ "eightinferior", "nineinferior", 0, 0, 0, "parenleftinferior",
+ "parenrightinferior", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, "colonmonetary", 0, "franc", "lira", 0, 0, "peseta", 0, 0,
+ "afii57636", "dong", "Euro", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+static char* table_2500[]= /* line and box drawing */
+{ "SF100000", 0, "SF110000", 0, 0, 0, 0, 0, 0, 0, 0, 0, "SF010000", 0,
+ 0, 0, "SF030000", 0, 0, 0, "SF020000", 0, 0, 0, "SF040000", 0, 0, 0,
+ "SF080000", 0, 0, 0, 0, 0, 0, 0, "SF090000", 0, 0, 0, 0, 0, 0, 0,
+ "SF060000", 0, 0, 0, 0, 0, 0, 0, "SF070000", 0, 0, 0, 0, 0, 0, 0,
+ "SF050000", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "SF430000", "SF240000", "SF510000", "SF520000", "SF390000",
+ "SF220000", "SF210000", "SF250000", "SF500000", "SF490000",
+ "SF380000", "SF280000", "SF270000", "SF260000", "SF360000",
+ "SF370000", "SF420000", "SF190000", "SF200000", "SF230000",
+ "SF470000", "SF480000", "SF410000", "SF450000", "SF460000",
+ "SF400000", "SF540000", "SF530000", "SF440000", 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "upblock", 0, 0, 0, "dnblock", 0,
+ 0, 0, "block", 0, 0, 0, "lfblock", 0, 0, 0, "rtblock", "ltshade",
+ "shade", "dkshade", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+static char* table_FB00[] = /* alphabetic presentation forms */
+{ "ff", "fi", "fl", "ffi", "ffl", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57705", 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, "afii57694", "afii57695", 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "afii57723", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, "afii57700", 0, 0, 0, 0 };
+
+char*
+unicodetoPSname(unsigned short code)
+{
+ if(code<32) return 0;
+ else if(code<0x6FF) return table_32[code-32];
+ else if(code<0x2000) return 0;
+ else if(code<0x20D0) return table_2000[code-0x2000];
+ else if(code==0x2116) return "afii61352"; /* numero sign, for Koi */
+ else if(code==0x2122) return "trademark";
+ else if(code<0x2500) return 0;
+ else if(code<0x25A0) return table_2500[code-0x2500];
+ else if(code<0xFB00) return 0;
+ else if(code<0xFB50) return table_FB00[code-0xFB00];
+ else return 0;
+}
diff --git a/nx-X11/lib/font/Type1/t1unicode.h b/nx-X11/lib/font/Type1/t1unicode.h
new file mode 100644
index 000000000..bad0274a0
--- /dev/null
+++ b/nx-X11/lib/font/Type1/t1unicode.h
@@ -0,0 +1,25 @@
+/*
+Copyright (c) 1998 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+
+/* $XFree86$ */
+
+char *unicodetoPSname(unsigned short code);
diff --git a/nx-X11/lib/font/Type1/token.c b/nx-X11/lib/font/Type1/token.c
new file mode 100644
index 000000000..71a968b30
--- /dev/null
+++ b/nx-X11/lib/font/Type1/token.c
@@ -0,0 +1,1208 @@
+/* $Xorg: token.c,v 1.4 2000/08/17 19:46:34 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* $XFree86: xc/lib/font/Type1/token.c,v 1.5tsi Exp $ */
+/* Authors: Sig Nin & Carol Thompson IBM Almaden Research Laboratory */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "t1stdio.h"
+#include "util.h"
+#include "digit.h"
+#include "token.h"
+#include "tokst.h"
+#include "hdigit.h"
+
+/*
+ * -------------------------------------------------------------------
+ * Globals
+ * -------------------------------------------------------------------
+ */
+
+/* These variables are set by the caller */
+char *tokenStartP; /* Pointer to token buffer in VM */
+char *tokenMaxP; /* Pointer to last byte in buffer + 1 */
+
+/* These variables are set by TOKEN */
+int tokenLength; /* Characters in token */
+boolean tokenTooLong; /* Token too long for buffer */
+int tokenType; /* Type of token identified */
+psvalue tokenValue; /* Token value */
+
+/*
+ * -------------------------------------------------------------------
+ * Private variables
+ * -------------------------------------------------------------------
+ */
+
+static FILE *inputFileP; /* Current input file */
+
+
+/* Token */
+static char *tokenCharP; /* Pointer to next character in token */
+
+/*
+ * -------------------------------------------------------------------
+ * Private routines for manipulating numbers
+ * -------------------------------------------------------------------
+ */
+
+#define Exp10(e) \
+((e) == 0\
+ ? (double)(1.0)\
+ : (-64 <= (e) && (e) <= 63\
+ ? Exp10T[(e)+64]\
+ : P10(e)\
+ )\
+)
+
+static double Exp10T[128] = {
+ 1e-64, 1e-63, 1e-62, 1e-61, 1e-60, 1e-59, 1e-58, 1e-57,
+ 1e-56, 1e-55, 1e-54, 1e-53, 1e-52, 1e-51, 1e-50, 1e-49,
+ 1e-48, 1e-47, 1e-46, 1e-45, 1e-44, 1e-43, 1e-42, 1e-41,
+ 1e-40, 1e-39, 1e-38, 1e-37, 1e-36, 1e-35, 1e-34, 1e-33,
+ 1e-32, 1e-31, 1e-30, 1e-29, 1e-28, 1e-27, 1e-26, 1e-25,
+ 1e-24, 1e-23, 1e-22, 1e-21, 1e-20, 1e-19, 1e-18, 1e-17,
+ 1e-16, 1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10, 1e-9,
+ 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1,
+ 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7,
+ 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
+ 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 1e23,
+ 1e24, 1e25, 1e26, 1e27, 1e28, 1e29, 1e30, 1e31,
+ 1e32, 1e33, 1e34, 1e35, 1e36, 1e37, 1e38, 1e39,
+ 1e40, 1e41, 1e42, 1e43, 1e44, 1e45, 1e46, 1e47,
+ 1e48, 1e49, 1e50, 1e51, 1e52, 1e53, 1e54, 1e55,
+ 1e56, 1e57, 1e58, 1e59, 1e60, 1e61, 1e62, 1e63
+};
+
+static double
+P10(long exponent)
+{
+ double value, power;
+
+ if (exponent < 0) {
+ power = 0.1;
+ value = (exponent & 1 ? power : 1.0);
+ exponent++;
+ exponent = -(exponent >> 1); /* portable C for -(exponent/2) */
+ }
+ else {
+ power = 10.0;
+ value = (exponent & 1 ? power : 1.0);
+ exponent = exponent >> 1;
+ }
+
+ while(exponent > 0) {
+ power *= power;
+ if (exponent & 1)
+ value *= power;
+ exponent >>= 1;
+ }
+
+ return(value);
+}
+
+/*
+ * -------------------------------------------------------------------
+ * Private routines and macros for manipulating the input
+ * -------------------------------------------------------------------
+ */
+
+/* Get next character from the input --
+ *
+ */
+#define next_ch() (_XT1getc(inputFileP))
+
+/* Push a character back into the input --
+ *
+ * Ungetc of EOF will fail, but that's ok: the next getc will
+ * return EOF.
+ *
+ * NOTE: These macros are presently written to return the character
+ * pushed, or EOF if none was pushed. However, they are not
+ * required to return anything in particular, and callers should
+ * not rely on the returned value.
+ */
+#define back_ch(ch) (T1Ungetc(ch, inputFileP))
+
+/* Push a character back into the input if it was not white space.
+ * If it is a carriage return (\r) then check next char for
+ * linefeed and consume them both, otherwise put next char back.
+ *
+ */
+#define back_ch_not_white(ch) \
+(\
+isWHITE_SPACE(ch)\
+ ? ((ch == '\r')\
+ ? (((ch = next_ch()) == '\n')\
+ ? EOF\
+ : back_ch(ch)\
+ )\
+ : EOF\
+ )\
+ : back_ch(ch)\
+)
+
+/*
+ * -------------------------------------------------------------------
+ * Private routines and macros for manipulating the token buffer
+ * -------------------------------------------------------------------
+ */
+
+/* Add a character to the token
+ * ---- use ONLY when you KNOW that this character will
+ * be stored within the token buffer.
+ */
+#define save_unsafe_ch(ch) (*tokenCharP++ = ch)
+
+/* Add a character to the token, if not too long to fit */
+#define save_ch(ch) \
+((tokenCharP < tokenMaxP)\
+ ? save_unsafe_ch(ch)\
+ : (tokenTooLong = TRUE)\
+)
+
+#define save_ch_no_inc(ch) \
+if (tokenCharP < tokenMaxP) *tokenCharP = ch
+
+/*
+ * -------------------------------------------------------------------
+ * Action Routines
+ *
+ * These routines all
+ * -- take int ch as a parameter
+ * -- return int ch if no token was recognized, DONE otherwise
+ * -- leave the next character in the input, if returning DONE
+ * -------------------------------------------------------------------
+ */
+
+#define DONE (256)
+
+/* Get the next input character */
+static int
+next_char(int ch)
+{
+ return(next_ch());
+}
+
+/* Add character to token */
+static int
+add_char(int ch)
+{
+ save_ch(ch);
+ return(next_ch());
+}
+
+
+/* -------------------------------------------------------------------
+ * Skip white space and comments
+ */
+
+/* Skip white space */
+static int
+skip_space(int ch)
+{
+ do {
+ ch = next_ch();
+ } while(isWHITE_SPACE(ch));
+ return(ch);
+}
+
+/* Skip comments */
+static int
+skip_comment(int ch)
+{
+ do {
+ ch = next_ch();
+ } while(isCOMMENT(ch));
+ return(ch);
+}
+
+/* -------------------------------------------------------------------
+ * Collect value elements for a number
+ */
+
+/* decimal integer or real number mantissa */
+static int m_sign;
+static long m_value;
+static long m_scale;
+
+/* real number exponent */
+static int e_sign;
+static long e_value;
+
+/* radix number */
+static long r_base;
+static long r_value;
+static long r_scale;
+
+static int
+add_sign(int ch)
+{
+ m_sign = ch;
+ save_unsafe_ch(ch);
+ return(next_ch());
+}
+
+static int
+add_1st_digits(int ch)
+{
+ m_sign = '+';
+ return(add_digits(ch));
+}
+
+static int
+add_digits(int ch)
+{
+ long value, p_value, scale;
+ int digit;
+
+ /* On entry, expect m_sign to be set to '+' or '-';
+ * ch is a decimal digit.
+ * Expect at most one character saved at this point,
+ * a sign. This routine will save up to 10 more
+ * characters without checking the buffer boundary.
+ */
+
+ value = ch - '0';
+ save_unsafe_ch(ch);
+ ch = next_ch();
+
+ while(isDECIMAL_DIGIT(ch) && value < (MAX_INTEGER/10)) {
+ value = (value << 3) + (value << 1) + (ch - '0');
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ }
+
+ /* Quick exit for small integers --
+ * |x| <= 10*((MAX_INTEGER/10)-1)+9
+ * |x| <= 2,147,483,639 for 32 bit integers
+ */
+ if (isNUMBER_ENDER(ch)) {
+ back_ch_not_white(ch);
+ tokenValue.integer = (m_sign == '-' ? -value : value);
+ tokenType = TOKEN_INTEGER;
+ return(DONE);
+ }
+
+ /* Handle additional digits. Beyond the boundary case,
+ * 10*(MAX_INTEGER/10) <= |number| <= MAX_INTEGER
+ * just count the digits: the number is too large to
+ * represent as an integer and will be returned as a real.
+ * The mantissa of a real holds fewer bits than an integer.
+ */
+ p_value = value;
+ value = (m_sign == '-' ? -value : value);
+ scale = 0;
+
+ if (isDECIMAL_DIGIT(ch)) {
+
+ /* Handle the boundary case */
+ if (p_value == (MAX_INTEGER/10)) {
+ digit = ch - '0';
+
+ /* Must handle positive and negative values separately */
+ /* for 2's complement arithmetic */
+ if (value > 0) {
+ if (digit <= MAX_INTEGER%10)
+ value = (value << 3) + (value << 1) + digit;
+ else
+ ++scale; /* Too big, just count it */
+ }
+ else {
+ /* Use positive % operands for portability */
+ if (digit <= -(MIN_INTEGER+10)%10)
+ value = (value << 3) + (value << 1) - digit;
+ else
+ ++scale; /* Too big, just count it */
+ }
+ }
+ else
+ ++scale; /* Not boundary case, just count digit */
+
+ save_unsafe_ch(ch);
+ ch = next_ch();
+
+ /* Continue scanning digits, but can't store them */
+ while(isDECIMAL_DIGIT(ch)) {
+ ++scale;
+ save_ch(ch);
+ ch = next_ch();
+ }
+ }
+
+ /* Continue from here scanning radix integer or real */
+ m_value = value;
+ m_scale = scale;
+
+ /* Initialize for possible real */
+ e_sign = '+';
+ e_value = 0;
+
+ return(ch);
+}
+
+static int
+add_1st_decpt(int ch)
+{
+ m_sign = '+';
+ return(add_decpt(ch));
+}
+
+static int
+add_decpt(int ch)
+{
+ /* On entry, expect m_sign to be set to '+' or '-' */
+ m_value = 0;
+ m_scale = 0;
+ save_unsafe_ch(ch);
+ return(next_ch());
+}
+
+static int
+add_fraction(int ch)
+{
+ long value, scale;
+ int digit;
+
+ /* On entry, expect m_value and m_scale to be initialized,
+ * and m_sign to be set to '+' or '-'. Expect m_value and m_sign
+ * to be consistent (this is not checked).
+ */
+ value = m_value;
+ scale = m_scale;
+
+ /* Scan leading zeroes */
+ if (value == 0) {
+ while(ch == '0') {
+ --scale;
+ save_ch(ch);
+ ch = next_ch();
+ }
+
+ /* Scan first significant digit */
+ if (isDECIMAL_DIGIT(ch)) {
+ --scale;
+ value = ch - '0';
+ value = (m_sign == '-' ? -value : value);
+ save_ch(ch);
+ ch = next_ch();
+ }
+ else
+ /* no significant digits -- number is zero */
+ scale = 0;
+ }
+ /* value != 0 || value == 0 && !isDECIMAL_DIGIT(ch) */
+
+ /* Scan additional significant digits */
+ if (isDECIMAL_DIGIT(ch)) {
+ if (value > 0) {
+ while(isDECIMAL_DIGIT(ch) && value < (MAX_INTEGER/10)) {
+ --scale;
+ value = (value << 3) + (value << 1) + (ch - '0');
+ save_ch(ch);
+ ch = next_ch();
+ }
+ /* Check boundary case */
+ if (isDECIMAL_DIGIT(ch) && value == (MAX_INTEGER/10)) {
+ digit = ch - '0';
+ if (digit <= MAX_INTEGER%10) {
+ --scale;
+ value = (value << 3) + (value << 1) + digit;
+ save_ch(ch);
+ ch = next_ch();
+ }
+ }
+ }
+ else {
+ /* value < 0 */
+ while(isDECIMAL_DIGIT(ch) && value > -(-(MIN_INTEGER+10)/10+1)) {
+ /* Use positive / operands for portability */
+ --scale;
+ value = (value << 3) + (value << 1) - (ch - '0');
+ save_ch(ch);
+ ch = next_ch();
+ }
+ /* Check boundary case */
+ if (isDECIMAL_DIGIT(ch)
+ && value == -(-(MIN_INTEGER+10)/10+1)) {
+ digit = ch - '0';
+ if (digit <= -(MIN_INTEGER+10)%10) {
+ /* Use positive % operands for portability */
+ --scale;
+ value = (value << 3) + (value << 1) - digit;
+ save_ch(ch);
+ ch = next_ch();
+ }
+ }
+ }
+
+ /* Additional digits can be discarded */
+ while(isDECIMAL_DIGIT(ch)) {
+ save_ch(ch);
+ ch = next_ch();
+ }
+ }
+
+ /* Store results */
+ m_value = value;
+ m_scale = scale;
+
+ /* Initialize for possible real */
+ e_sign = '+';
+ e_value = 0;
+
+ return(ch);
+}
+
+static int
+add_e_sign(int ch)
+{
+ e_sign = ch;
+ save_ch(ch);
+ return(next_ch());
+}
+
+static int
+add_exponent(int ch)
+{
+ long value, p_value;
+ long scale = 0;
+ int digit;
+
+ /* On entry, expect e_sign to be set to '+' or '-' */
+
+ value = ch - '0';
+ save_ch(ch);
+ ch = next_ch();
+
+ while(isDECIMAL_DIGIT(ch) && value < (MAX_INTEGER/10)) {
+ value = (value << 3) + (value << 1) + (ch - '0');
+ save_ch(ch);
+ ch = next_ch();
+ }
+
+ p_value = value;
+ value = (e_sign == '-' ? -value : value);
+
+ /* Handle additional digits. Beyond the boundary case,
+ * 10*(MAX_INTEGER/10) <= |number| <= MAX_INTEGER
+ * just count the digits: the number is too large to
+ * represent as an integer.
+ */
+ if (isDECIMAL_DIGIT(ch)) {
+
+ /* Examine boundary case */
+ if (p_value == (MAX_INTEGER/10)) {
+ digit = ch - '0';
+
+ /* Must handle positive and negative values separately */
+ /* for 2's complement arithmetic */
+ if (value > 0) {
+ if (digit <= MAX_INTEGER%10)
+ value = (value << 3) + (value << 1) + digit;
+ else
+ ++scale; /* Too big, just count it */
+ }
+ else {
+ /* Use positive % operands for portability */
+ if (digit <= -(MIN_INTEGER+10)%10)
+ value = (value << 3) + (value << 1) - digit;
+ else
+ ++scale; /* Too big, just count it */
+ }
+ }
+ else
+ ++scale; /* Not boundary case, just count digit */
+
+ save_ch(ch);
+ ch = next_ch();
+
+ /* Continue scanning digits, but can't store any more */
+ while(isDECIMAL_DIGIT(ch)) {
+ ++scale;
+ save_ch(ch);
+ ch = next_ch();
+ }
+ }
+
+ /* Store results */
+ e_value = value;
+
+ return(ch);
+}
+
+static int
+add_radix(int ch)
+{
+ if (2 <= m_value && m_value <= 36 && m_scale == 0) {
+ r_base = m_value;
+ save_ch(ch);
+ return(next_ch());
+ }
+ else {
+ /* Radix invalid, complete a name token */
+ return(AAH_NAME(ch));
+ }
+}
+
+static int
+add_r_digits(int ch)
+{
+ unsigned long value;
+ long radix, scale;
+ int digit;
+
+ /* NOTE: The syntax of a radix number allows only for
+ * values of zero or more. The value will be stored as
+ * a 32 bit integer, which PostScript then interprets
+ * as signed. This means, for example, that the numbers:
+ *
+ * 8#37777777777
+ * 10#4294967295
+ * 16#FFFFFFFF
+ * 36#1Z141Z3
+ *
+ * are all interpreted as -1. This routine implements this
+ * idea explicitly: it accumulates the number's value
+ * as unsigned, then casts it to signed when done.
+ */
+
+ /* Expect r_base to be initialized */
+ radix = r_base;
+ value = 0;
+ scale = 0;
+
+ /* Scan leading zeroes */
+ while(ch == '0') {
+ save_ch(ch);
+ ch = next_ch();
+ }
+
+ /* Handle first non-zero digit */
+ if ((digit=digit_value[ch]) < radix) {
+ value = digit;
+ save_ch(ch);
+ ch = next_ch();
+
+ /* Add digits until boundary case reached */
+ while((digit=digit_value[ch]) < radix
+ && value < (MAX_ULONG / radix)) {
+ value = value * radix + digit;
+ save_ch(ch);
+ ch = next_ch();
+ };
+
+ /* Scan remaining digits */
+ if ((digit=digit_value[ch]) < radix) {
+
+ /* Examine boundary case ---
+ * radix*(MAX_ULONG/radix) <= number <= MAX_ULONG
+ */
+ if (value == (MAX_ULONG/radix) && digit <= MAX_ULONG%radix)
+ value = value * radix + digit;
+ else
+ ++scale;
+
+ /* Continue scanning digits, but can't store them */
+ save_ch(ch);
+ ch = next_ch();
+ while(digit_value[ch] < radix) {
+ ++scale;
+ save_ch(ch);
+ ch = next_ch();
+ }
+ }
+ }
+
+ /* Store result */
+ r_value = (long) value; /* result is signed */
+ r_scale = scale;
+
+ return(ch);
+}
+
+/* -------------------------------------------------------------------
+ * Complete a number; set token type and done flag.
+ * Put current input character back, if it is not white space.
+ */
+
+/* Done: Radix Number */
+static int
+RADIX_NUMBER(int ch)
+{
+ back_ch_not_white(ch);
+ if (r_scale == 0) {
+ tokenValue.integer = r_value;
+ tokenType = TOKEN_INTEGER;
+ }
+ else {
+ tokenType = TOKEN_NAME;
+ }
+ return(DONE);
+}
+
+/* Done: Integer */
+static int
+INTEGER(int ch)
+{
+ back_ch_not_white(ch);
+ if (m_scale == 0) {
+ tokenValue.integer = m_value;
+ tokenType = TOKEN_INTEGER;
+ }
+ else {
+ tokenValue.real = (double)(m_value) * Exp10(m_scale);
+ tokenType = TOKEN_REAL;
+ }
+ return(DONE);
+}
+
+/* Done: Real */
+static int
+REAL(int ch)
+{
+ double temp;
+
+ back_ch_not_white(ch);
+
+ /* HAZARD: exponent overflow of intermediate result
+ * (e.g., in 370 floating point); this should not be a problem
+ * with IEEE floating point. Reduce exponent overflow hazard by
+ * combining m_scale and e_value first, if they have different signs,
+ * or multiplying m_value and one of the other factors, if both
+ * m_scale and e_value are negative.
+ */
+ if ((m_scale >= 0 && e_value <= 0)
+ || (m_scale <= 0 && e_value >= 0)) {
+ tokenValue.real = (double)(m_value) * Exp10(m_scale + e_value);
+ }
+ else {
+ temp = (double)(m_value) * Exp10(m_scale);
+ tokenValue.real = temp * Exp10(e_value);
+ }
+
+ tokenType = TOKEN_REAL;
+ return(DONE);
+}
+
+
+/* -------------------------------------------------------------------
+ * Assemble a hex string; set token type and done flag.
+ */
+
+/* Done: Hex String */
+static int
+HEX_STRING(int ch)
+{
+ int value;
+
+ while(TRUE) {
+
+ /* Process odd digit */
+ ch = next_ch();
+ if (!isHEX_DIGIT(ch)) {
+
+ /* Skip white space */
+ while(isWHITE_SPACE(ch))
+ ch = next_ch();
+
+ /* Check for terminator */
+ if (!isHEX_DIGIT(ch)) {
+ break;
+ }
+ }
+ value = digit_value[ch] << 4;
+
+ /* Process even digit */
+ ch = next_ch();
+ if (!isHEX_DIGIT(ch)) {
+
+ /* Skip white space */
+ while(isWHITE_SPACE(ch))
+ ch = next_ch();
+
+ /* Check for terminator */
+ if (!isHEX_DIGIT(ch)) {
+ save_ch(value);
+ break;
+ }
+ }
+ save_ch(value + digit_value[ch]);
+ }
+
+ /* Classify result, based on why loop ended */
+ if (ch == '>')
+ tokenType = TOKEN_HEX_STRING;
+ else {
+ /* save the invalid character for error reporting */
+ save_ch(ch);
+ tokenType = TOKEN_INVALID;
+ }
+
+ return(DONE);
+}
+
+/* -------------------------------------------------------------------
+ * Assemble a string; set token type and done flag
+ */
+
+/* Save a backslash-coded character in a string --
+ *
+ * Store the proper character for special cases
+ * "\b", "\f", "\n", "\r", and "\t".
+ *
+ * Decode and store octal-coded character, up to
+ * three octal digits, "\o", "\oo", and "\ooo".
+ *
+ * The sequence "\<newline>" is a line continuation,
+ * so consume both without storing anything.
+ *
+ * The sequence "\<EOF>" is an error; exit without
+ * storing anything and let the caller handle it.
+ *
+ * For other characters, including the sequences
+ * "\\", "\(", and "\)", simply store the second
+ * character.
+ */
+static void
+save_digraph(int ch)
+{
+ int value;
+
+ switch (ch) {
+
+ case 'b': /* backspace */
+ ch = '\b';
+ break;
+
+ case 'f': /* formfeed */
+ ch = '\f';
+ break;
+
+ case 'n': /* newline */
+ ch = '\n';
+ break;
+
+ case 'r': /* carriage return */
+ ch = '\r';
+ break;
+
+ case 't': /* horizontal tab */
+ ch = '\t';
+ break;
+
+ case '\n': /* line continuation -- consume it */
+ return;
+
+ case '\r': /* carriage return -- consume it */
+ ch = next_ch(); /* look at next character, is it \n? */
+ if (ch == '\n') return;
+ back_ch(ch); /* if not a line feed, then return it */
+ return;
+
+ case EOF: /* end of file -- forget it */
+ return;
+
+ default:
+ /* scan up to three octal digits to get value */
+ if (isOCTAL_DIGIT(ch)) {
+ value = digit_value[ch];
+ ch = next_ch();
+ if (isOCTAL_DIGIT(ch)) {
+ value = (value << 3) + digit_value[ch];
+ ch = next_ch();
+ if (isOCTAL_DIGIT(ch))
+ value = (value << 3) + digit_value[ch];
+ else
+ back_ch(ch);
+ }
+ else
+ back_ch(ch);
+ ch = value;
+ }
+ }
+
+ /* Found a character to save */
+ save_ch(ch);
+}
+
+/* Done: String */
+static int
+STRING(int ch)
+{
+ int nest_level = 1;
+
+ tokenType = TOKEN_STRING;
+
+ do {
+
+ ch = next_ch();
+ while(!isSTRING_SPECIAL(ch)) {
+ save_ch(ch);
+ ch = next_ch();
+ };
+
+ switch (ch) {
+
+ case '(':
+ ++nest_level;
+ save_ch(ch);
+ break;
+
+ case ')':
+ if (--nest_level > 0)
+ save_ch(ch);
+ break;
+
+ case '\\':
+ save_digraph(next_ch());
+ break;
+
+ case '\r':
+ /* All carriage returns (\r) are turned into linefeeds (\n)*/
+ ch = next_ch(); /* get the next one, is it \n? */
+ if (ch != '\n') { /* if not, then put it back. */
+ back_ch(ch);
+ }
+ save_ch('\n'); /* in either case, save a linefeed */
+ break;
+
+
+ case EOF:
+ tokenType = TOKEN_INVALID; /* Unterminated string */
+ nest_level = 0;
+ break;
+ }
+
+ } while(nest_level > 0);
+
+ /* If there's room, add a 0-byte termination without increasing string
+ length. This fixes certain dependencies on 0-terminated strings */
+ save_ch_no_inc(0);
+
+ return(DONE);
+}
+
+
+/* -------------------------------------------------------------------
+ * Assemble a name; set token type and done flag.
+ * Put current input character back, if it is not white space.
+ */
+
+/* Done: Name
+ * (Safe version used to complete name tokens that
+ * start out looking like something else).
+ */
+
+static int
+AAH_NAME(int ch)
+{
+ do {
+ save_ch(ch);
+ ch = next_ch();
+ } while(isNAME(ch));
+
+ back_ch_not_white(ch);
+ tokenType = TOKEN_NAME;
+ return(DONE);
+}
+
+/* Done: Name */
+static int
+NAME(int ch)
+{
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ while(isNAME(ch)) {
+ save_ch(ch);
+ ch = next_ch();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ back_ch_not_white(ch);
+ tokenType = TOKEN_NAME;
+ return(DONE);
+}
+
+/* Done: Literal Name */
+static int
+LITERAL_NAME(int ch)
+{
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ while(isNAME(ch)) {
+ save_ch(ch);
+ ch = next_ch();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ back_ch_not_white(ch);
+ tokenType = TOKEN_LITERAL_NAME;
+ return(DONE);
+}
+
+/* Done: immediate Name */
+static int
+IMMED_NAME(int ch)
+{
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ if (isNAME(ch)) {
+ save_unsafe_ch(ch);
+ ch = next_ch();
+ while(isNAME(ch)) {
+ save_ch(ch);
+ ch = next_ch();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ back_ch_not_white(ch);
+ tokenType = TOKEN_IMMED_NAME;
+ return(DONE);
+}
+
+/* Done: Name found while looking for something else */
+static int
+OOPS_NAME(int ch)
+{
+ back_ch_not_white(ch);
+ tokenType = TOKEN_NAME;
+ return(DONE);
+}
+
+
+/* -------------------------------------------------------------------
+ * Complete a miscellaneous token; set token type and done flag.
+ */
+
+/* Done: Unmatched Right Angle-Bracket */
+static int
+RIGHT_ANGLE(int ch)
+{
+ tokenType = TOKEN_RIGHT_ANGLE;
+ return(DONE);
+}
+
+/* Done: Unmatched Right Parenthesis */
+static int
+RIGHT_PAREN(int ch)
+{
+ tokenType = TOKEN_RIGHT_PAREN;
+ return(DONE);
+}
+
+/* Done: Left Brace */
+static int
+LEFT_BRACE(int ch)
+{
+ tokenType = TOKEN_LEFT_BRACE;
+ return(DONE);
+}
+
+/* Done: Right Brace */
+static int
+RIGHT_BRACE(int ch)
+{
+ tokenType = TOKEN_RIGHT_BRACE;
+ return(DONE);
+}
+
+/* Done: Left Bracket */
+static int
+LEFT_BRACKET(int ch)
+{
+ save_unsafe_ch(ch);
+ tokenType = TOKEN_LEFT_BRACKET;
+ return(DONE);
+}
+
+/* Done: Right Bracket */
+static int
+RIGHT_BRACKET(int ch)
+{
+ save_unsafe_ch(ch);
+ tokenType = TOKEN_RIGHT_BRACKET;
+ return(DONE);
+}
+
+/* Done: Break */
+static int
+BREAK_SIGNAL(int ch)
+{
+ tokenType = TOKEN_BREAK;
+ return(DONE);
+}
+
+/* Done: No Token Found */
+static int
+NO_TOKEN(int ch)
+{
+ tokenType = TOKEN_EOF;
+ return(DONE);
+}
+
+
+/*
+ * -------------------------------------------------------------------
+ * scan_token -- scan one token from the input. It uses a simple
+ * finite state machine to recognize token classes.
+ *
+ * The input is from a file.
+ *
+ * On entry --
+ *
+ * inputP -> input PostScript object, a file.
+ * tokenStartP -> buffer in VM for accumulating the token.
+ * tokenMaxP -> last character in the token buffer
+ *
+ * On exit --
+ *
+ * tokenLength = number of characters in the token
+ * tokenTooLong = TRUE if the token did not fit in the buffer
+ * tokenType = code for the type of token parsed.
+ * tokenValue = converted value of a numeric token.
+ *
+ *
+ * -------------------------------------------------------------------
+ */
+void
+scan_token(psobj *inputP)
+{
+ int ch;
+ unsigned char *stateP = s0;
+ unsigned char entry;
+ int (*actionP)(int);
+
+ /* Define input source */
+ inputFileP = inputP->data.fileP;
+ if (inputFileP == NULL) {
+ tokenType = TOKEN_EOF;
+ return;
+ }
+
+ /* Ensure enough space for most cases
+ * (so we don't have to keep checking)
+ * The length needs to cover the maximum number
+ * of save_unsafe_ch() calls that might be executed.
+ * That number is 11 (a sign and 10 decimal digits, e.g.,
+ * when scanning -2147483648), but use MAX_NAME_LEN
+ * in case someone changes that without checking.
+ */
+ tokenStartP = vm_next_byte();
+ tokenMaxP = tokenStartP + MIN(vm_free_bytes(), MAX_STRING_LEN);
+
+ if ((tokenMaxP-tokenStartP) < (MAX_NAME_LEN)) {
+ tokenLength = 0;
+ tokenTooLong = TRUE;
+ tokenType = TOKEN_NONE;
+ tokenValue.integer = 0;
+ return;
+ }
+
+ /* Reset token */
+ tokenCharP = tokenStartP;
+ tokenTooLong = FALSE;
+
+ /* Scan one token */
+ ch = next_ch();
+ do {
+ entry = stateP[ch];
+ stateP = classActionTable[entry].nextStateP;
+ actionP = classActionTable[entry].actionRoutineP;
+ ch = (*actionP)(ch);
+ } while(ch != DONE);
+
+
+ /* Return results */
+ tokenLength = tokenCharP - tokenStartP;
+}
diff --git a/nx-X11/lib/font/Type1/token.h b/nx-X11/lib/font/Type1/token.h
new file mode 100644
index 000000000..663982889
--- /dev/null
+++ b/nx-X11/lib/font/Type1/token.h
@@ -0,0 +1,79 @@
+/* $Xorg: token.h,v 1.3 2000/08/17 19:46:34 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* $XFree86: xc/lib/font/Type1/token.h,v 1.3 1999/08/22 08:58:54 dawes Exp $ */
+
+#ifndef TOKEN_H
+#define TOKEN_H
+
+/* Special characters */
+#define CONTROL_C (3)
+
+/* Token type codes */
+#define TOKEN_INVALID (-3)
+#define TOKEN_BREAK (-2)
+#define TOKEN_EOF (-1)
+#define TOKEN_NONE (0)
+#define TOKEN_LEFT_PAREN (1)
+#define TOKEN_RIGHT_PAREN (2)
+#define TOKEN_LEFT_ANGLE (3)
+#define TOKEN_RIGHT_ANGLE (4)
+#define TOKEN_LEFT_BRACE (5)
+#define TOKEN_RIGHT_BRACE (6)
+#define TOKEN_LEFT_BRACKET (7)
+#define TOKEN_RIGHT_BRACKET (8)
+#define TOKEN_NAME (9)
+#define TOKEN_LITERAL_NAME (10)
+#define TOKEN_INTEGER (11)
+#define TOKEN_REAL (12)
+#define TOKEN_RADIX_NUMBER (13)
+#define TOKEN_HEX_STRING (14)
+#define TOKEN_STRING (15)
+#define TOKEN_IMMED_NAME (16)
+
+/* Token routines */
+extern void scan_token( psobj *inputP );
+
+/*
+ * -------------------------------------------------------------------------
+ * Globals shared -- (everyone else KEEP YOUR MITTS OFF THEM!)
+ * -------------------------------------------------------------------------
+ */
+
+/* These variables are set by the caller */
+extern char *tokenStartP; /* Pointer to token buffer in VM */
+extern char *tokenMaxP; /* Pointer to end of VM we may use + 1 */
+
+/* These variables are set by P_TOKEN */
+extern int tokenLength; /* Characters in token */
+extern boolean tokenTooLong; /* Token too long for space available */
+extern int tokenType; /* Type of token identified */
+extern psvalue tokenValue; /* Token value */
+
+#endif /* TOKEN_H */
diff --git a/nx-X11/lib/font/Type1/tokst.h b/nx-X11/lib/font/Type1/tokst.h
new file mode 100644
index 000000000..02166afde
--- /dev/null
+++ b/nx-X11/lib/font/Type1/tokst.h
@@ -0,0 +1,510 @@
+/* $Xorg: tokst.h,v 1.3 2000/08/17 19:46:34 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/* $XFree86: xc/lib/font/Type1/tokst.h,v 1.3 1999/08/22 08:58:54 dawes Exp $ */
+
+/* -------------------------------------- */
+/* --- MACHINE GENERATED, DO NOT EDIT --- */
+/* -------------------------------------- */
+
+#ifndef TOKST
+#define TOKST 1
+
+/*
+ * State Index Tables --
+ *
+ * These tables map the input character to the
+ * proper entry in the Class Action Table.
+ * There is one table for each state.
+ *
+ */
+#define s0 (si0+2)
+static unsigned char si0[258] = { 0x10,0x11,
+ 0x02,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x02,0x02,0x0F,0x0F,0x02,0x0F,0x0F,
+ 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
+ 0x02,0x0F,0x0F,0x0F,0x0F,0x03,0x0F,0x0F,0x05,0x0B,0x0F,0x0D,0x0F,0x0D,0x0E,0x04,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x0F,0x0F,0x08,0x0F,0x0C,0x0F,
+ 0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x0F,0x0A,0x0F,0x0F,
+ 0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x0F,0x09,0x0F,0x0F,
+ 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
+ 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
+ 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
+ 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
+ 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
+ 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
+ 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
+ 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F
+};
+
+#define s1 (si1+2)
+static unsigned char si1[258] = { 0x14,0x15,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x12,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13
+};
+
+#define s2 (si2+2)
+static unsigned char si2[258] = { 0x1B,0x1C,
+ 0x16,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x16,0x16,0x1A,0x1A,0x16,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x16,0x1A,0x1A,0x1A,0x1A,0x17,0x1A,0x1A,0x17,0x17,0x1A,0x1A,0x1A,0x1A,0x19,0x17,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1A,0x1A,0x17,0x1A,0x17,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x17,0x1A,0x17,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x17,0x1A,0x17,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A
+};
+
+#define s3 (si3+2)
+static unsigned char si3[258] = { 0x23,0x24,
+ 0x1D,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x1D,0x1D,0x22,0x22,0x1D,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x1D,0x22,0x22,0x20,0x22,0x1E,0x22,0x22,0x1E,0x1E,0x22,0x22,0x22,0x22,0x1F,0x1E,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x1E,0x22,0x1E,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x21,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x1E,0x22,0x1E,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x21,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x1E,0x22,0x1E,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22
+};
+
+#define s4 (si4+2)
+static unsigned char si4[258] = { 0x29,0x2A,
+ 0x25,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x25,0x25,0x28,0x28,0x25,0x28,0x28,
+ 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,
+ 0x25,0x28,0x28,0x28,0x28,0x26,0x28,0x28,0x26,0x26,0x28,0x28,0x28,0x28,0x28,0x26,
+ 0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x28,0x28,0x26,0x28,0x26,0x28,
+ 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,
+ 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x26,0x28,0x26,0x28,0x28,
+ 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,
+ 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x26,0x28,0x26,0x28,0x28,
+ 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,
+ 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,
+ 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,
+ 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,
+ 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,
+ 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,
+ 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,
+ 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28
+};
+
+#define s5 (si5+2)
+static unsigned char si5[258] = { 0x30,0x31,
+ 0x2B,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2B,0x2B,0x2F,0x2F,0x2B,0x2F,0x2F,
+ 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
+ 0x2B,0x2F,0x2F,0x2F,0x2F,0x2C,0x2F,0x2F,0x2C,0x2C,0x2F,0x2F,0x2F,0x2F,0x2F,0x2C,
+ 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2F,0x2F,0x2C,0x2F,0x2C,0x2F,
+ 0x2F,0x2F,0x2F,0x2F,0x2F,0x2D,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
+ 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2C,0x2F,0x2C,0x2F,0x2F,
+ 0x2F,0x2F,0x2F,0x2F,0x2F,0x2D,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
+ 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2C,0x2F,0x2C,0x2F,0x2F,
+ 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
+ 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
+ 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
+ 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
+ 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
+ 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
+ 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
+ 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F
+};
+
+#define s6 (si6+2)
+static unsigned char si6[258] = { 0x36,0x37,
+ 0x32,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x32,0x32,0x35,0x35,0x32,0x35,0x35,
+ 0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,
+ 0x32,0x35,0x35,0x35,0x35,0x33,0x35,0x35,0x33,0x33,0x35,0x35,0x35,0x35,0x35,0x33,
+ 0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x33,0x35,0x33,0x35,
+ 0x35,0x35,0x35,0x35,0x35,0x34,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,
+ 0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x33,0x35,0x33,0x35,0x35,
+ 0x35,0x35,0x35,0x35,0x35,0x34,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,
+ 0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x33,0x35,0x33,0x35,0x35,
+ 0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,
+ 0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,
+ 0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,
+ 0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,
+ 0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,
+ 0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,
+ 0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,
+ 0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35
+};
+
+#define s7 (si7+2)
+static unsigned char si7[258] = { 0x3D,0x3E,
+ 0x38,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x38,0x38,0x3C,0x3C,0x38,0x3C,0x3C,
+ 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,
+ 0x38,0x3C,0x3C,0x3C,0x3C,0x39,0x3C,0x3C,0x39,0x39,0x3C,0x3A,0x3C,0x3A,0x3C,0x39,
+ 0x3B,0x3B,0x3B,0x3B,0x3B,0x3B,0x3B,0x3B,0x3B,0x3B,0x3C,0x3C,0x39,0x3C,0x39,0x3C,
+ 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,
+ 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x39,0x3C,0x39,0x3C,0x3C,
+ 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,
+ 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x39,0x3C,0x39,0x3C,0x3C,
+ 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,
+ 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,
+ 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,
+ 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,
+ 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,
+ 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,
+ 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,
+ 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C
+};
+
+#define s8 (si8+2)
+static unsigned char si8[258] = { 0x43,0x44,
+ 0x3F,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3F,0x3F,0x42,0x42,0x3F,0x42,0x42,
+ 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
+ 0x3F,0x42,0x42,0x42,0x42,0x40,0x42,0x42,0x40,0x40,0x42,0x42,0x42,0x42,0x42,0x40,
+ 0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x42,0x42,0x40,0x42,0x40,0x42,
+ 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
+ 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x40,0x42,0x40,0x42,0x42,
+ 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
+ 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x40,0x42,0x40,0x42,0x42,
+ 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
+ 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
+ 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
+ 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
+ 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
+ 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
+ 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
+ 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42
+};
+
+#define s9 (si9+2)
+static unsigned char si9[258] = { 0x48,0x49,
+ 0x45,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x45,0x45,0x47,0x47,0x45,0x47,0x47,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,
+ 0x45,0x47,0x47,0x47,0x47,0x46,0x47,0x47,0x46,0x46,0x47,0x47,0x47,0x47,0x47,0x46,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x46,0x47,0x46,0x47,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x46,0x47,0x46,0x47,0x47,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x46,0x47,0x46,0x47,0x47,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,
+ 0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47,0x47
+};
+
+#define s10 (si10+2)
+static unsigned char si10[258] = { 0x4E,0x4F,
+ 0x4A,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4A,0x4A,0x4D,0x4D,0x4A,0x4D,0x4D,
+ 0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,
+ 0x4A,0x4D,0x4D,0x4D,0x4D,0x4B,0x4D,0x4D,0x4B,0x4B,0x4D,0x4D,0x4D,0x4D,0x4D,0x4B,
+ 0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4D,0x4D,0x4B,0x4D,0x4B,0x4D,
+ 0x4D,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,
+ 0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4B,0x4D,0x4B,0x4D,0x4D,
+ 0x4D,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,
+ 0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4B,0x4D,0x4B,0x4D,0x4D,
+ 0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,
+ 0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,
+ 0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,
+ 0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,
+ 0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,
+ 0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,
+ 0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,
+ 0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D
+};
+
+#define s11 (si11+2)
+static unsigned char si11[258] = { 0x53,0x54,
+ 0x50,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x50,0x50,0x52,0x52,0x50,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,
+ 0x50,0x52,0x52,0x52,0x52,0x51,0x52,0x52,0x51,0x51,0x52,0x52,0x52,0x52,0x52,0x51,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x51,0x52,0x51,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x51,0x52,0x51,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x51,0x52,0x51,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52
+};
+
+/*
+ * Class Action Table --
+ *
+ * The entries in the Class Action Table indicate the
+ * action routine to be called, and the next state to
+ * enter, for each relevant character class in each.
+ * state. There are several entries for each state.
+ *
+ */
+static int AAH_NAME ( int ch );
+static int BREAK_SIGNAL ( int ch );
+static int HEX_STRING ( int ch );
+static int IMMED_NAME ( int ch );
+static int INTEGER ( int ch );
+static int LEFT_BRACE ( int ch );
+static int LEFT_BRACKET ( int ch );
+static int LITERAL_NAME ( int ch );
+static int NAME ( int ch );
+static int NO_TOKEN ( int ch );
+static int OOPS_NAME ( int ch );
+static int RADIX_NUMBER ( int ch );
+static int REAL ( int ch );
+static int RIGHT_ANGLE ( int ch );
+static int RIGHT_BRACE ( int ch );
+static int RIGHT_BRACKET ( int ch );
+static int RIGHT_PAREN ( int ch );
+static int STRING ( int ch );
+static int add_1st_decpt ( int ch );
+static int add_1st_digits ( int ch );
+static int add_char ( int ch );
+static int add_decpt ( int ch );
+static int add_digits ( int ch );
+static int add_exponent ( int ch );
+static int add_e_sign ( int ch );
+static int add_fraction ( int ch );
+static int add_radix ( int ch );
+static int add_r_digits ( int ch );
+static int add_sign ( int ch );
+static int next_char ( int ch );
+static int skip_comment ( int ch );
+static int skip_space ( int ch );
+
+static struct cat {
+ int (*actionRoutineP)(int);
+ unsigned char *nextStateP;
+} classActionTable[] = {
+
+ /* s0: Classify initial character */
+ /* 00 ALPHA */ {NAME, s0}, /* executable name */
+ /* 01 DIGIT */ {add_1st_digits, s3}, /* number? */
+ /* 02 WHITE_SPACE */ {skip_space, s0}, /* skip white space */
+ /* 03 PERCENT */ {skip_comment, s0}, /* comment? */
+ /* 04 SLASH */ {next_char, s1}, /* literal or imm name */
+ /* 05 LEFT_PAREN */ {STRING, s0}, /* string */
+ /* 06 LEFT_BRACE */ {LEFT_BRACE, s0}, /* begin procedure body */
+ /* 07 LEFT_BRACKET */ {LEFT_BRACKET, s0}, /* begin array */
+ /* 08 LEFT_ANGLE */ {HEX_STRING, s0}, /* hex string? */
+ /* 09 RIGHT_BRACE */ {RIGHT_BRACE, s0}, /* end procedure body */
+ /* 0A RIGHT_BRACKET */ {RIGHT_BRACKET, s0}, /* end array */
+ /* 0B RIGHT_PAREN */ {RIGHT_PAREN, s0}, /* unmatched right paren */
+ /* 0C RIGHT_ANGLE */ {RIGHT_ANGLE, s0}, /* unmatched right angle */
+ /* 0D SIGN */ {add_sign, s2}, /* signed number? */
+ /* 0E DECIMAL_POINT */ {add_1st_decpt, s4}, /* real number? */
+ /* 0F ANY */ {NAME, s0}, /* executable name */
+ /* 10 BREAK */ {BREAK_SIGNAL, s0}, /* break signalled */
+ /* 11 EOF */ {NO_TOKEN, s0}, /* no token found */
+
+ /* s1: Further classify a '/' */
+ /* 12 SLASH */ {IMMED_NAME, s0}, /* immediate name */
+ /* 13 ANY */ {LITERAL_NAME, s0}, /* literal name */
+ /* 14 BREAK */ {BREAK_SIGNAL, s0}, /* break signalled */
+ /* 15 EOF */ {OOPS_NAME, s0}, /* isolated sign */
+
+ /* s2: sign */
+ /* 16 WHITE_SPACE */ {OOPS_NAME, s0}, /* isolated sign */
+ /* 17 SPECIAL */ {OOPS_NAME, s0}, /* isolated sign */
+ /* 18 DIGIT */ {add_digits, s3}, /* number? */
+ /* 19 DECIMAL_POINT */ {add_decpt, s4}, /* real number? */
+ /* 1A ANY */ {NAME, s0}, /* executable name */
+ /* 1B BREAK */ {BREAK_SIGNAL, s0}, /* break signalled */
+ /* 1C EOF */ {OOPS_NAME, s0}, /* isolated sign */
+
+ /* s3: sign? digit+ */
+ /* 1D WHITE_SPACE */ {INTEGER, s0}, /* n-digit integer */
+ /* 1E SPECIAL */ {INTEGER, s0}, /* n-digit integer */
+ /* 1F DECIMAL_POINT */ {add_char, s5}, /* real number? */
+ /* 20 POUND */ {add_radix, s10}, /* radix number? */
+ /* 21 eE */ {add_char, s7}, /* real with exponent? */
+ /* 22 ANY */ {AAH_NAME, s0}, /* executable name */
+ /* 23 BREAK */ {BREAK_SIGNAL, s0}, /* break signalled */
+ /* 24 EOF */ {INTEGER, s0}, /* n-digit integer */
+
+ /* s4: sign? . */
+ /* 25 WHITE_SPACE */ {OOPS_NAME, s0}, /* isolated +. or -. */
+ /* 26 SPECIAL */ {OOPS_NAME, s0}, /* isolated +. or -. */
+ /* 27 DIGIT */ {add_fraction, s6}, /* number? */
+ /* 28 ANY */ {NAME, s0}, /* executable name */
+ /* 29 BREAK */ {BREAK_SIGNAL, s0}, /* break signalled */
+ /* 2A EOF */ {OOPS_NAME, s0}, /* isolated +. or -. */
+
+ /* s5: sign? digit+ . */
+ /* 2B WHITE_SPACE */ {REAL, s0}, /* real with fraction */
+ /* 2C SPECIAL */ {REAL, s0}, /* real with fraction */
+ /* 2D eE */ {add_char, s7}, /* real with exponent? */
+ /* 2E DIGIT */ {add_fraction, s6}, /* number? */
+ /* 2F ANY */ {AAH_NAME, s0}, /* executable name */
+ /* 30 BREAK */ {BREAK_SIGNAL, s0}, /* break signalled */
+ /* 31 EOF */ {REAL, s0}, /* real with fraction */
+
+ /* s6: sign? (digit+ . digit+) | (. digit+) */
+ /* 32 WHITE_SPACE */ {REAL, s0}, /* real with fraction */
+ /* 33 SPECIAL */ {REAL, s0}, /* real with fraction */
+ /* 34 eE */ {add_char, s7}, /* real with exponent? */
+ /* 35 ANY */ {AAH_NAME, s0}, /* executable name */
+ /* 36 BREAK */ {BREAK_SIGNAL, s0}, /* break signalled */
+ /* 37 EOF */ {REAL, s0}, /* real with fraction */
+
+ /* s7: sign? ((digit+ (. digit*)?) | (. digit+)) Ee */
+ /* 38 WHITE_SPACE */ {OOPS_NAME, s0}, /* invalid real number */
+ /* 39 SPECIAL */ {OOPS_NAME, s0}, /* invalid real number */
+ /* 3A SIGN */ {add_e_sign, s8}, /* real w signed exponent? */
+ /* 3B DIGIT */ {add_exponent, s9}, /* real w exponent ? */
+ /* 3C ANY */ {AAH_NAME, s0}, /* executable name */
+ /* 3D BREAK */ {BREAK_SIGNAL, s0}, /* break signalled */
+ /* 3E EOF */ {OOPS_NAME, s0}, /* invalid real number */
+
+ /* s8: sign? (digit+ (. digit*)? | (digit* . digit+) Ee sign */
+ /* 3F WHITE_SPACE */ {OOPS_NAME, s0}, /* invalid real number */
+ /* 40 SPECIAL */ {OOPS_NAME, s0}, /* invalid real number */
+ /* 41 DIGIT */ {add_exponent, s9}, /* real w exponent? */
+ /* 42 ANY */ {AAH_NAME, s0}, /* executable name */
+ /* 43 BREAK */ {BREAK_SIGNAL, s0}, /* break signalled */
+ /* 44 EOF */ {OOPS_NAME, s0}, /* invalid real number */
+
+ /* s9: sign? (digit+ (. digit*)? | (digit* . digit+) Ee sign? digit+ */
+ /* 45 WHITE_SPACE */ {REAL, s0}, /* real w exponent */
+ /* 46 SPECIAL */ {REAL, s0}, /* real w exponent */
+ /* 47 ANY */ {AAH_NAME, s0}, /* executable name */
+ /* 48 BREAK */ {BREAK_SIGNAL, s0}, /* break signalled */
+ /* 49 EOF */ {REAL, s0}, /* real w exponent */
+
+ /* s10: digit+ # */
+ /* 4A WHITE_SPACE */ {OOPS_NAME, s0}, /* invalid radix number */
+ /* 4B SPECIAL */ {OOPS_NAME, s0}, /* invalid radix number */
+ /* 4C R_DIGIT */ {add_r_digits, s11}, /* radix number? */
+ /* 4D ANY */ {AAH_NAME, s0}, /* executable name */
+ /* 4E BREAK */ {BREAK_SIGNAL, s0}, /* break signalled */
+ /* 4F EOF */ {OOPS_NAME, s0}, /* invalid radix number */
+
+ /* s11: digit+ # r_digit+ */
+ /* 50 WHITE_SPACE */ {RADIX_NUMBER, s0}, /* radix number */
+ /* 51 SPECIAL */ {RADIX_NUMBER, s0}, /* radix number */
+ /* 52 ANY */ {AAH_NAME, s0}, /* executable name */
+ /* 53 BREAK */ {BREAK_SIGNAL, s0}, /* break signalled */
+ /* 54 EOF */ {RADIX_NUMBER, s0} /* radix number */
+};
+
+/*
+ * Character Classification Tables --
+ *
+ * The entries in the Character Classification Tables
+ * map character codes to character classes. The
+ * tables contains one entry per code. The bits in
+ * each entry indicate which classes the character
+ * code belongs to.
+ *
+ * The macros 'isInCLASS(ch)' generate code to test
+ * whether 'ch' is a character in 'CLASS'.
+ *
+ */
+/* Membership macros for classes defined in table 1 ... */
+#define isRADIX_DIGIT(c) ((isInP1[c] & 0x80) != 0)
+#define isHEX_DIGIT(c) ((isInP1[c] & 0x40) != 0)
+#define isDECIMAL_DIGIT(c) ((isInP1[c] & 0x10) != 0)
+#define isOCTAL_DIGIT(c) ((isInP1[c] & 0x20) != 0)
+
+/* Membership macros for classes defined in table 2 ... */
+#define isWHITE_SPACE(c) ((isInP2[c] & 0x80) != 0)
+#define isCOMMENT(c) ((isInP2[c] & 0x40) != 0)
+#define isNAME(c) ((isInP2[c] & 0x20) != 0)
+#define isSTRING_SPECIAL(c) ((isInP2[c] & 0x10) != 0)
+#define isNUMBER_ENDER(c) ((isInP2[c] & 0x08) != 0)
+
+#define isInP1 (isInT1+2)
+static unsigned char isInT1[258] = { 0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xD0,0xD0,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
+ 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
+ 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+
+#define isInP2 (isInT2+2)
+static unsigned char isInT2[258] = { 0x18,0x18,
+ 0xC8,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xC8,0x88,0x60,0x60,0x98,0x60,0x60,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
+ 0xC8,0x60,0x60,0x60,0x60,0x48,0x60,0x60,0x58,0x58,0x60,0x60,0x60,0x60,0x60,0x48,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x48,0x60,0x48,0x60,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x48,0x70,0x48,0x60,0x60,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x48,0x60,0x48,0x60,0x60,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
+ 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60
+};
+
+#endif
diff --git a/nx-X11/lib/font/Type1/trig.h b/nx-X11/lib/font/Type1/trig.h
new file mode 100644
index 000000000..d569ed067
--- /dev/null
+++ b/nx-X11/lib/font/Type1/trig.h
@@ -0,0 +1,41 @@
+/* $Xorg: trig.h,v 1.3 2000/08/17 19:46:34 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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.
+ */
+/*SHARED*/
+
+/* $XFree86: xc/lib/font/Type1/trig.h,v 1.2 1998/07/25 06:57:00 dawes Exp $ */
+
+#undef DegreeCos
+#undef DegreeSin
+#undef sqrt
+
+#define DegreeCos(d) xiStub()
+#define DegreeSin(d) xiStub()
+#define sqrt(d) xiStub()
+
diff --git a/nx-X11/lib/font/Type1/type1.c b/nx-X11/lib/font/Type1/type1.c
new file mode 100644
index 000000000..b3fa4965a
--- /dev/null
+++ b/nx-X11/lib/font/Type1/type1.c
@@ -0,0 +1,1892 @@
+/* $Xorg: type1.c,v 1.4 2000/08/17 19:46:34 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ * Portions Copyright (c) 1990 Adobe Systems Incorporated.
+ * All Rights Reserved
+ *
+ * License 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 IBM or Lexmark or Adobe
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * IBM, LEXMARK, AND ADOBE PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY
+ * WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE
+ * ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING
+ * ANY DUTY TO SUPPORT OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY
+ * PORTION OF THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM,
+ * LEXMARK, OR ADOBE) ASSUMES THE ENTIRE COST OF ALL SERVICING, REPAIR AND
+ * CORRECTION. IN NO EVENT SHALL IBM, LEXMARK, OR ADOBE 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 (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/type1.c,v 1.9tsi Exp $ */
+
+/*********************************************************************/
+/* */
+/* Type 1 module - Converting fonts in Adobe Type 1 Font Format */
+/* to scaled and hinted paths for rasterization. */
+/* Files: type1.c, type1.h, and blues.h. */
+/* */
+/* Authors: Sten F. Andler, IBM Almaden Research Center */
+/* (Type 1 interpreter, stem & flex hints) */
+/* */
+/* Patrick A. Casey, Lexmark International, Inc. */
+/* (Font level hints & stem hints) */
+/* */
+/*********************************************************************/
+
+/******************/
+/* Include Files: */
+/******************/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#ifndef FONTMODULE
+#include <stdio.h> /* a system-dependent include, usually */
+#include <math.h>
+#else
+#include "Xdefs.h"
+#include "Xmd.h"
+#include "xf86_ansic.h"
+#endif
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "fonts.h" /* understands about TEXTTYPEs */
+#include "pictures.h" /* understands about handles */
+#include "range.h"
+
+typedef struct xobject xobject;
+#include "util.h" /* PostScript objects */
+#include "fontfcn.h"
+#include "blues.h" /* Blues structure for font-level hints */
+
+/**********************************/
+/* Type1 Constants and Structures */
+/**********************************/
+#define MAXSTACK 24 /* Adobe Type1 limit */
+#define MAXCALLSTACK 10 /* Adobe Type1 limit */
+#define MAXPSFAKESTACK 32 /* Max depth of fake PostScript stack (local) */
+#define MAXSTRLEN 512 /* Max length of a Type 1 string (local) */
+#define MAXLABEL 256 /* Maximum number of new hints */
+#if XFONT_CID
+#define MAXSTEMS 500 /* Maximum number of VSTEM and HSTEM hints */
+#else
+#define MAXSTEMS 128 /* Maximum number of VSTEM and HSTEM hints */
+#endif
+#define EPS 0.001 /* Small number for comparisons */
+
+/************************************/
+/* Adobe Type 1 CharString commands */
+/************************************/
+#define HSTEM 1
+#define VSTEM 3
+#define VMOVETO 4
+#define RLINETO 5
+#define HLINETO 6
+#define VLINETO 7
+#define RRCURVETO 8
+#define CLOSEPATH 9
+#define CALLSUBR 10
+#define RETURN 11
+#define ESCAPE 12
+#define HSBW 13
+#define ENDCHAR 14
+#define RMOVETO 21
+#define HMOVETO 22
+#define VHCURVETO 30
+#define HVCURVETO 31
+
+/*******************************************/
+/* Adobe Type 1 CharString Escape commands */
+/*******************************************/
+#define DOTSECTION 0
+#define VSTEM3 1
+#define HSTEM3 2
+#define SEAC 6
+#define SBW 7
+#define DIV 12
+#define CALLOTHERSUBR 16
+#define POP 17
+#define SETCURRENTPOINT 33
+
+/*****************/
+/* Useful macros */
+/*****************/
+
+#define FABS(x) fabs(x)
+
+#define CEIL(x) ceil(x)
+
+#define FLOOR(x) floor(x)
+
+#define ROUND(x) FLOOR((x) + 0.5)
+
+#define ODD(x) (((int)(x)) & 01)
+
+#define Error {errflag = TRUE; return;}
+#define ErrorRet(ret) {errflag = TRUE; return (ret);}
+
+/********************/
+/* global variables */
+/********************/
+struct stem { /* representation of a STEM hint */
+ int vertical; /* TRUE if vertical, FALSE otherwise */
+ double x, dx; /* interval of vertical stem */
+ double y, dy; /* interval of horizontal stem */
+ struct segment *lbhint, *lbrevhint; /* left or bottom hint adjustment */
+ struct segment *rthint, *rtrevhint; /* right or top hint adjustment */
+};
+
+struct xobject *Type1Char(char *env, struct XYspace *S,
+ psobj *charstrP, psobj *subrsP, psobj *osubrsP,
+ struct blues_struct *bluesP, int *modeP);
+#if XFONT_CID
+struct xobject *CIDChar(char *env, struct XYspace *S,
+ psobj *charstrP, psobj *subrsP, psobj *osubrsP,
+ struct blues_struct *bluesP, int *modeP);
+#endif
+
+static double escapementX, escapementY;
+static double sidebearingX, sidebearingY;
+static double accentoffsetX, accentoffsetY;
+
+static struct segment *path;
+static int errflag;
+
+/*************************************************/
+/* Global variables to hold Type1Char parameters */
+/*************************************************/
+static char *Environment;
+static struct XYspace *CharSpace;
+static psobj *CharStringP, *SubrsP;
+
+/************************/
+/* Forward declarations */
+/************************/
+static struct segment *Applyhint ( struct segment *p, int stemnumber,
+ int half );
+static struct segment *Applyrevhint ( struct segment *p, int stemnumber,
+ int half );
+static void CallOtherSubr ( int othersubrno );
+static void CallSubr ( int subrno );
+static struct segment *CenterStem ( double edge1, double edge2 );
+static void ClearCallStack ( void );
+static void ClearPSFakeStack ( void );
+static void ClearStack ( void );
+static void ComputeAlignmentZones ( void );
+static void ComputeStem ( int stemno );
+static void Decode ( int Code );
+static unsigned char Decrypt ( unsigned char cipher );
+static double Div ( double num1, double num2 );
+static void DoClosePath ( void );
+static void DoCommand ( int Code );
+static int DoRead ( int *CodeP );
+static void DotSection ( void );
+static void EndChar ( void );
+static void Escape ( int Code );
+static struct segment *FindStems ( double x, double y, double dx, double dy );
+static void FinitStems ( void );
+static void FlxProc ( double c1x2, double c1y2, double c3x0, double c3y0,
+ double c3x1, double c3y1, double c3x2, double c3y2,
+ double c4x0, double c4y0, double c4x1, double c4y1,
+ double c4x2, double c4y2, double epY, double epX,
+ int idmin );
+static void FlxProc1 ( void );
+static void FlxProc2 ( void );
+static void HintReplace ( void );
+static void HStem ( double y, double dy );
+static void InitStems ( void );
+static void PopCall ( psobj **CurrStrPP, int *CurrIndexP,
+ unsigned short *CurrKeyP );
+static double PSFakePop ( void );
+static void PSFakePush ( double Num );
+static void Push ( double Num );
+static void PushCall ( psobj *CurrStrP, int CurrIndex,
+ unsigned short CurrKey );
+static void Return ( void );
+static void RLineTo ( double dx, double dy );
+static void RMoveTo ( double dx, double dy );
+static void RRCurveTo ( double dx1, double dy1, double dx2, double dy2,
+ double dx3, double dy3 );
+static void Sbw ( double sbx, double sby, double wx, double wy );
+static void Seac ( double asb, double adx, double ady, unsigned char bchar,
+ unsigned char achar );
+static void SetCurrentPoint ( double x, double y );
+static void StartDecrypt ( void );
+static void VStem ( double x, double dx );
+
+/*****************************************/
+/* statics for Flex procedures (FlxProc) */
+/*****************************************/
+static struct segment *FlxOldPath; /* save path before Flex feature */
+
+/******************************************************/
+/* statics for Font level hints (Blues) (see blues.h) */
+/******************************************************/
+static struct blues_struct *blues; /* the blues structure */
+static struct alignmentzone alignmentzones[MAXALIGNMENTZONES];
+static int numalignmentzones; /* total number of alignment zones */
+
+/****************************************************************/
+/* Subroutines for the Font level hints (Alignment zones, etc.) */
+/****************************************************************/
+
+/******************************************/
+/* Fill in the alignment zone structures. */
+/******************************************/
+static void
+ComputeAlignmentZones(void)
+{
+ int i;
+ double dummy, bluezonepixels, familyzonepixels;
+ struct segment *p;
+
+ numalignmentzones = 0; /* initialize total # of zones */
+
+ /* do the BlueValues zones */
+ for (i = 0; i < blues->numBlueValues; i +=2, ++numalignmentzones) {
+ /* the 0th & 1st numbers in BlueValues are for a bottom zone */
+ /* the rest are topzones */
+ if (i == 0) /* bottom zone */
+ alignmentzones[numalignmentzones].topzone = FALSE;
+ else /* top zone */
+ alignmentzones[numalignmentzones].topzone = TRUE;
+ if (i < blues->numFamilyBlues) { /* we must consider FamilyBlues */
+ p = ILoc(CharSpace,0,blues->BlueValues[i] - blues->BlueValues[i+1]);
+ QueryLoc(p, IDENTITY, &dummy, &bluezonepixels);
+ Destroy(p);
+ p = ILoc(CharSpace,0,blues->FamilyBlues[i]-blues->FamilyBlues[i+1]);
+ QueryLoc(p, IDENTITY, &dummy, &familyzonepixels);
+ Destroy(p);
+ /* is the difference in size of the zones less than 1 pixel? */
+ if (FABS(bluezonepixels - familyzonepixels) < 1.0) {
+ /* use the Family zones */
+ alignmentzones[numalignmentzones].bottomy =
+ blues->FamilyBlues[i];
+ alignmentzones[numalignmentzones].topy =
+ blues->FamilyBlues[i+1];
+ continue;
+ }
+ }
+ /* use this font's Blue zones */
+ alignmentzones[numalignmentzones].bottomy = blues->BlueValues[i];
+ alignmentzones[numalignmentzones].topy = blues->BlueValues[i+1];
+ }
+
+ /* do the OtherBlues zones */
+ for (i = 0; i < blues->numOtherBlues; i +=2, ++numalignmentzones) {
+ /* all of the OtherBlues zones are bottom zones */
+ alignmentzones[numalignmentzones].topzone = FALSE;
+ if (i < blues->numFamilyOtherBlues) {/* consider FamilyOtherBlues */
+ p = ILoc(CharSpace,0,blues->OtherBlues[i] - blues->OtherBlues[i+1]);
+ QueryLoc(p, IDENTITY, &dummy, &bluezonepixels);
+ Destroy(p);
+ p = ILoc(CharSpace,0,blues->FamilyOtherBlues[i] -
+ blues->FamilyOtherBlues[i+1]);
+ QueryLoc(p, IDENTITY, &dummy, &familyzonepixels);
+ Destroy(p);
+ /* is the difference in size of the zones less than 1 pixel? */
+ if (FABS(bluezonepixels - familyzonepixels) < 1.0) {
+ /* use the Family zones */
+ alignmentzones[numalignmentzones].bottomy =
+ blues->FamilyOtherBlues[i];
+ alignmentzones[numalignmentzones].topy =
+ blues->FamilyOtherBlues[i+1];
+ continue;
+ }
+ }
+ /* use this font's Blue zones (as opposed to the Family Blues */
+ alignmentzones[numalignmentzones].bottomy = blues->OtherBlues[i];
+ alignmentzones[numalignmentzones].topy = blues->OtherBlues[i+1];
+ }
+}
+
+/**********************************************************************/
+/* Subroutines and statics for handling of the VSTEM and HSTEM hints. */
+/**********************************************************************/
+static int InDotSection; /* DotSection flag */
+static struct stem stems[MAXSTEMS]; /* All STEM hints */
+static int numstems; /* Number of STEM hints */
+static int currstartstem; /* The current starting stem. */
+static int oldvert, oldhor; /* Remember hint in effect */
+static int oldhorhalf, oldverthalf; /* Remember which half of the stem */
+static double wsoffsetX, wsoffsetY; /* White space offset - for VSTEM3,HSTEM3 */
+static int wsset; /* Flag for whether we've set wsoffsetX,Y */
+
+static void
+InitStems(void) /* Initialize the STEM hint data structures */
+{
+ InDotSection = FALSE;
+ currstartstem = numstems = 0;
+ oldvert = oldhor = -1;
+}
+
+static void
+FinitStems(void) /* Terminate the STEM hint data structures */
+{
+ int i;
+
+ for (i = 0; i < numstems; i++) {
+ Destroy(stems[i].lbhint);
+ Destroy(stems[i].lbrevhint);
+ Destroy(stems[i].rthint);
+ Destroy(stems[i].rtrevhint);
+ }
+}
+
+/*******************************************************************/
+/* Compute the dislocation that a stemhint should cause for points */
+/* inside the stem. */
+/*******************************************************************/
+static void
+ComputeStem(int stemno)
+{
+ int verticalondevice, idealwidth;
+ double stemstart, stemwidth;
+ struct segment *p;
+ int i;
+ double stembottom, stemtop, flatposition;
+ double Xpixels, Ypixels;
+ double unitpixels, onepixel;
+ int suppressovershoot, enforceovershoot;
+ double stemshift, flatpospixels, overshoot;
+ double widthdiff; /* Number of character space units to adjust width */
+ double lbhintvalue, rthintvalue;
+ double cxx, cyx, cxy, cyy; /* Transformation matrix */
+ int rotated; /* TRUE if character is on the side, FALSE if upright */
+
+ /************************************************/
+ /* DETERMINE ORIENTATION OF CHARACTER ON DEVICE */
+ /************************************************/
+
+ QuerySpace(CharSpace, &cxx, &cyx, &cxy, &cyy); /* Transformation matrix */
+
+ if (FABS(cxx) < 0.00001 || FABS(cyy) < 0.00001)
+ rotated = TRUE; /* Char is on side (90 or 270 degrees), possibly oblique. */
+ else if (FABS(cyx) < 0.00001 || FABS(cxy) < 0.00001)
+ rotated = FALSE; /* Char is upright (0 or 180 degrees), possibly oblique. */
+ else {
+ stems[stemno].lbhint = NULL; /* Char is at non-axial angle, ignore hints. */
+ stems[stemno].lbrevhint = NULL;
+ stems[stemno].rthint = NULL;
+ stems[stemno].rtrevhint = NULL;
+ return;
+ }
+
+ /* Determine orientation of stem */
+
+ if (stems[stemno].vertical) {
+ verticalondevice = !rotated;
+ stemstart = stems[stemno].x;
+ stemwidth = stems[stemno].dx;
+ } else {
+ verticalondevice = rotated;
+ stemstart = stems[stemno].y;
+ stemwidth = stems[stemno].dy;
+ }
+
+ /* Determine how many pixels (non-negative) correspond to 1 character space
+ unit (unitpixels), and how many character space units (non-negative)
+ correspond to one pixel (onepixel). */
+
+ if (stems[stemno].vertical)
+ p = ILoc(CharSpace, 1, 0);
+ else
+ p = ILoc(CharSpace, 0, 1);
+ QueryLoc(p, IDENTITY, &Xpixels, &Ypixels);
+ Destroy(p);
+ if (verticalondevice)
+ unitpixels = FABS(Xpixels);
+ else
+ unitpixels = FABS(Ypixels);
+
+ onepixel = 1.0 / unitpixels;
+
+ /**********************/
+ /* ADJUST STEM WIDTHS */
+ /**********************/
+
+ widthdiff = 0.0;
+
+ /* Find standard stem with smallest width difference from this stem */
+ if (stems[stemno].vertical) { /* vertical stem */
+ if (blues->StdVW != 0) /* there is an entry for StdVW */
+ widthdiff = blues->StdVW - stemwidth;
+ for (i = 0; i < blues->numStemSnapV; ++i) { /* now look at StemSnapV */
+ if (blues->StemSnapV[i] - stemwidth < widthdiff)
+ /* this standard width is the best match so far for this stem */
+ widthdiff = blues->StemSnapV[i] - stemwidth;
+ }
+ } else { /* horizontal stem */
+ if (blues->StdHW != 0) /* there is an entry for StdHW */
+ widthdiff = blues->StdHW - stemwidth;
+ for (i = 0; i < blues->numStemSnapH; ++i) { /* now look at StemSnapH */
+ if (blues->StemSnapH[i] - stemwidth < widthdiff)
+ /* this standard width is the best match so far for this stem */
+ widthdiff = blues->StemSnapH[i] - stemwidth;
+ }
+ }
+
+ /* Only expand or contract stems if they differ by less than 1 pixel from
+ the closest standard width, otherwise make the width difference = 0. */
+ if (FABS(widthdiff) > onepixel)
+ widthdiff = 0.0;
+
+ /* Expand or contract stem to the nearest integral number of pixels. */
+ idealwidth = ROUND((stemwidth + widthdiff) * unitpixels);
+ /* Ensure that all stems are at least one pixel wide. */
+ if (idealwidth == 0)
+ idealwidth = 1;
+ /* Apply ForceBold to vertical stems. */
+ if (blues->ForceBold && stems[stemno].vertical)
+ /* Force this vertical stem to be at least DEFAULTBOLDSTEMWIDTH wide. */
+ if (idealwidth < DEFAULTBOLDSTEMWIDTH)
+ idealwidth = DEFAULTBOLDSTEMWIDTH;
+ /* Now compute the number of character space units necessary */
+ widthdiff = idealwidth * onepixel - stemwidth;
+
+ /*********************************************************************/
+ /* ALIGNMENT ZONES AND OVERSHOOT SUPPRESSION - HORIZONTAL STEMS ONLY */
+ /*********************************************************************/
+
+ stemshift = 0.0;
+
+ if (!stems[stemno].vertical) {
+
+ /* Get bottom and top boundaries of the stem. */
+ stembottom = stemstart;
+ stemtop = stemstart + stemwidth;
+
+ /* Find out if this stem intersects an alignment zone (the BlueFuzz */
+ /* entry in the Private dictionary specifies the number of character */
+ /* units to extend (in both directions) the effect of an alignment */
+ /* zone on a horizontal stem. The default value of BlueFuzz is 1. */
+ for (i = 0; i < numalignmentzones; ++i) {
+ if (alignmentzones[i].topzone) {
+ if (stemtop >= alignmentzones[i].bottomy &&
+ stemtop <= alignmentzones[i].topy + blues->BlueFuzz) {
+ break; /* We found a top-zone */
+ }
+ } else {
+ if (stembottom <= alignmentzones[i].topy &&
+ stembottom >= alignmentzones[i].bottomy - blues->BlueFuzz) {
+ break; /* We found a bottom-zone */
+ }
+ }
+ }
+
+ if (i < numalignmentzones) { /* We found an intersecting zone (number i). */
+ suppressovershoot = FALSE;
+ enforceovershoot = FALSE;
+
+ /* When 1 character space unit is rendered smaller than BlueScale
+ device units (pixels), we must SUPPRESS overshoots. Otherwise,
+ if the top (or bottom) of this stem is more than BlueShift character
+ space units away from the flat position, we must ENFORCE overshoot. */
+
+ if (unitpixels < blues->BlueScale)
+ suppressovershoot = TRUE;
+ else
+ if (alignmentzones[i].topzone) {
+ if (stemtop >= alignmentzones[i].bottomy + blues->BlueShift)
+ enforceovershoot = TRUE;
+ } else
+ if (stembottom <= alignmentzones[i].topy - blues->BlueShift)
+ enforceovershoot = TRUE;
+
+ /*************************************************/
+ /* ALIGN THE FLAT POSITION OF THE ALIGNMENT ZONE */
+ /*************************************************/
+
+ /* Compute the position of the alignment zone's flat position in
+ device space and the amount of shift needed to align it on a
+ pixel boundary. Move all stems this amount. */
+
+ if (alignmentzones[i].topzone)
+ flatposition = alignmentzones[i].bottomy;
+ else
+ flatposition = alignmentzones[i].topy;
+
+ /* Find the flat position in pixels */
+ flatpospixels = flatposition * unitpixels;
+
+ /* Find the stem shift necessary to align the flat
+ position on a pixel boundary, and use this shift for all stems */
+ stemshift = (ROUND(flatpospixels) - flatpospixels) * onepixel;
+
+ /************************************************/
+ /* HANDLE OVERSHOOT ENFORCEMENT AND SUPPRESSION */
+ /************************************************/
+
+ /* Compute overshoot amount (non-negative) */
+ if (alignmentzones[i].topzone)
+ overshoot = stemtop - flatposition;
+ else
+ overshoot = flatposition - stembottom;
+
+ if (overshoot > 0.0) {
+ /* ENFORCE overshoot by shifting the entire stem (if necessary) so that
+ it falls at least one pixel beyond the flat position. */
+
+ if (enforceovershoot)
+ if (overshoot < onepixel) {
+ if (alignmentzones[i].topzone)
+ stemshift += onepixel - overshoot;
+ else
+ stemshift -= onepixel - overshoot;
+ }
+ /* SUPPRESS overshoot by aligning the stem to the alignment zone's
+ flat position. */
+
+ if (suppressovershoot) {
+ if (alignmentzones[i].topzone)
+ stemshift -= overshoot;
+ else
+ stemshift += overshoot;
+ }
+ }
+
+ /************************************************************/
+ /* COMPUTE HINT VALUES FOR EACH SIDE OF THE HORIZONTAL STEM */
+ /************************************************************/
+
+ /* If the stem was aligned by a topzone, we expand or contract the stem
+ only at the bottom - since the stem top was aligned by the zone.
+ If the stem was aligned by a bottomzone, we expand or contract the stem
+ only at the top - since the stem bottom was aligned by the zone. */
+ if (alignmentzones[i].topzone) {
+ lbhintvalue = stemshift - widthdiff; /* bottom */
+ rthintvalue = stemshift; /* top */
+ } else {
+ lbhintvalue = stemshift; /* bottom */
+ rthintvalue = stemshift + widthdiff; /* top */
+ }
+
+ stems[stemno].lbhint = (struct segment *)Permanent(Loc(CharSpace, 0.0, lbhintvalue));
+ stems[stemno].lbrevhint = (struct segment *)Permanent(Loc(CharSpace, 0.0, -lbhintvalue));
+ stems[stemno].rthint = (struct segment *)Permanent(Loc(CharSpace, 0.0, rthintvalue));
+ stems[stemno].rtrevhint = (struct segment *)Permanent(Loc(CharSpace, 0.0, -rthintvalue));
+
+ return;
+
+ } /* endif (i < numalignmentzones) */
+
+ /* We didn't find any alignment zones intersecting this stem, so
+ proceed with normal stem alignment below. */
+
+ } /* endif (!stems[stemno].vertical) */
+
+ /* Align stem with pixel boundaries on device */
+ stemstart = stemstart - widthdiff / 2;
+ stemshift = ROUND(stemstart * unitpixels) * onepixel - stemstart;
+
+ /* Adjust the boundaries of the stem */
+ lbhintvalue = stemshift - widthdiff / 2; /* left or bottom */
+ rthintvalue = stemshift + widthdiff / 2; /* right or top */
+
+ if (stems[stemno].vertical) {
+ stems[stemno].lbhint = (struct segment *)Permanent(Loc(CharSpace, lbhintvalue, 0.0));
+ stems[stemno].lbrevhint = (struct segment *)Permanent(Loc(CharSpace, -lbhintvalue, 0.0));
+ stems[stemno].rthint = (struct segment *)Permanent(Loc(CharSpace, rthintvalue, 0.0));
+ stems[stemno].rtrevhint = (struct segment *)Permanent(Loc(CharSpace, -rthintvalue, 0.0));
+ } else {
+ stems[stemno].lbhint = (struct segment *)Permanent(Loc(CharSpace, 0.0, lbhintvalue));
+ stems[stemno].lbrevhint = (struct segment *)Permanent(Loc(CharSpace, 0.0, -lbhintvalue));
+ stems[stemno].rthint = (struct segment *)Permanent(Loc(CharSpace, 0.0, rthintvalue));
+ stems[stemno].rtrevhint = (struct segment *)Permanent(Loc(CharSpace, 0.0, -rthintvalue));
+ }
+}
+
+#define LEFT 1
+#define RIGHT 2
+#define BOTTOM 3
+#define TOP 4
+
+/*********************************************************************/
+/* Adjust a point using the given stem hint. Use the left/bottom */
+/* hint value or the right/top hint value depending on where the */
+/* point lies in the stem. */
+/*********************************************************************/
+static struct segment *
+Applyhint(struct segment *p, int stemnumber, int half)
+{
+ if (half == LEFT || half == BOTTOM)
+ return Join(p, stems[stemnumber].lbhint); /* left or bottom hint */
+ else
+ return Join(p, stems[stemnumber].rthint); /* right or top hint */
+}
+
+/*********************************************************************/
+/* Adjust a point using the given reverse hint. Use the left/bottom */
+/* hint value or the right/top hint value depending on where the */
+/* point lies in the stem. */
+/*********************************************************************/
+static struct segment *
+Applyrevhint(struct segment *p, int stemnumber, int half)
+{
+ if (half == LEFT || half == BOTTOM)
+ return Join(p, stems[stemnumber].lbrevhint); /* left or bottom hint */
+ else
+ return Join(p, stems[stemnumber].rtrevhint); /* right or top hint */
+}
+
+/***********************************************************************/
+/* Find the vertical and horizontal stems that the current point */
+/* (x, y) may be involved in. At most one horizontal and one vertical */
+/* stem can apply to a single point, since there are no overlaps */
+/* allowed. */
+/* The actual hintvalue is returned as a location. */
+/* Hints are ignored inside a DotSection. */
+/***********************************************************************/
+static struct segment *
+FindStems(double x, double y, double dx, double dy)
+{
+ int i;
+ int newvert, newhor;
+ struct segment *p;
+ int newhorhalf, newverthalf;
+
+ if (InDotSection) return(NULL);
+
+ newvert = newhor = -1;
+ newhorhalf = newverthalf = -1;
+
+ for (i = currstartstem; i < numstems; i++) {
+ if (stems[i].vertical) { /* VSTEM hint */
+ if ((x >= stems[i].x - EPS) &&
+ (x <= stems[i].x+stems[i].dx + EPS)) {
+ newvert = i;
+ if (dy != 0.0) {
+ if (dy < 0) newverthalf = LEFT;
+ else newverthalf = RIGHT;
+ } else {
+ if (x < stems[i].x+stems[i].dx / 2) newverthalf = LEFT;
+ else newverthalf = RIGHT;
+ }
+ }
+ } else { /* HSTEM hint */
+ if ((y >= stems[i].y - EPS) &&
+ (y <= stems[i].y+stems[i].dy + EPS)) {
+ newhor = i;
+ if (dx != 0.0) {
+ if (dx < 0) newhorhalf = TOP;
+ else newhorhalf = BOTTOM;
+ } else {
+ if (y < stems[i].y+stems[i].dy / 2) newhorhalf = BOTTOM;
+ else newhorhalf = TOP;
+ }
+ }
+ }
+ }
+
+ p = NULL;
+
+ if (newvert == -1 && oldvert == -1) ; /* Outside of any hints */
+ else if (newvert == oldvert &&
+ newverthalf == oldverthalf); /* No hint change */
+ else if (oldvert == -1) { /* New vertical hint in effect */
+ p = Applyhint(p, newvert, newverthalf);
+ } else if (newvert == -1) { /* Old vertical hint no longer in effect */
+ p = Applyrevhint(p, oldvert, oldverthalf);
+ } else { /* New vertical hint in effect, old hint no longer in effect */
+ p = Applyrevhint(p, oldvert, oldverthalf);
+ p = Applyhint(p, newvert, newverthalf);
+ }
+
+ if (newhor == -1 && oldhor == -1) ; /* Outside of any hints */
+ else if (newhor == oldhor &&
+ newhorhalf == oldhorhalf) ; /* No hint change */
+ else if (oldhor == -1) { /* New horizontal hint in effect */
+ p = Applyhint(p, newhor, newhorhalf);
+ } else if (newhor == -1) { /* Old horizontal hint no longer in effect */
+ p = Applyrevhint(p, oldhor, oldhorhalf);
+ }
+ else { /* New horizontal hint in effect, old hint no longer in effect */
+ p = Applyrevhint(p, oldhor, oldhorhalf);
+ p = Applyhint(p, newhor, newhorhalf);
+ }
+
+ oldvert = newvert; oldverthalf = newverthalf;
+ oldhor = newhor; oldhorhalf = newhorhalf;
+
+ return p;
+}
+
+/******************************************************/
+/* Subroutines and statics for the Type1Char routines */
+/******************************************************/
+
+static int strindex; /* index into PostScript string being interpreted */
+static double currx, curry; /* accumulated x and y values for hints */
+
+struct callstackentry {
+ psobj *currstrP; /* current CharStringP */
+ int currindex; /* current strindex */
+ unsigned short currkey; /* current decryption key */
+ };
+
+static double Stack[MAXSTACK];
+static int Top;
+static struct callstackentry CallStack[MAXCALLSTACK];
+static int CallTop;
+static double PSFakeStack[MAXPSFAKESTACK];
+static int PSFakeTop;
+
+static void
+ClearStack(void)
+{
+ Top = -1;
+}
+
+static void
+Push(double Num)
+{
+ if (++Top < MAXSTACK) Stack[Top] = Num;
+ else Error;
+}
+
+static void
+ClearCallStack(void)
+{
+ CallTop = -1;
+}
+
+static void
+PushCall(psobj *CurrStrP, int CurrIndex, unsigned short CurrKey)
+{
+ if (++CallTop < MAXCALLSTACK) {
+ CallStack[CallTop].currstrP = CurrStrP; /* save CharString pointer */
+ CallStack[CallTop].currindex = CurrIndex; /* save CharString index */
+ CallStack[CallTop].currkey = CurrKey; /* save decryption key */
+ }
+ else Error;
+}
+
+static void
+PopCall(psobj **CurrStrPP, int *CurrIndexP, unsigned short *CurrKeyP)
+{
+ if (CallTop >= 0) {
+ *CurrStrPP = CallStack[CallTop].currstrP; /* restore CharString pointer */
+ *CurrIndexP = CallStack[CallTop].currindex; /* restore CharString index */
+ *CurrKeyP = CallStack[CallTop--].currkey; /* restore decryption key */
+ }
+ else Error;
+}
+
+static void
+ClearPSFakeStack(void)
+{
+ PSFakeTop = -1;
+}
+
+/* PSFakePush: Pushes a number onto the fake PostScript stack */
+static void
+PSFakePush(double Num)
+{
+ if (++PSFakeTop < MAXPSFAKESTACK) PSFakeStack[PSFakeTop] = Num;
+ else Error;
+}
+
+/* PSFakePop: Removes a number from the top of the fake PostScript stack */
+static double
+PSFakePop (void)
+{
+ if (PSFakeTop >= 0) return(PSFakeStack[PSFakeTop--]);
+ else ErrorRet(0.0);
+ /*NOTREACHED*/
+}
+
+/***********************************************************************/
+/* Center a stem on the pixel grid -- used by HStem3 and VStem3 */
+/***********************************************************************/
+static struct segment *
+CenterStem(double edge1, double edge2)
+{
+ int idealwidth, verticalondevice;
+ double leftx, lefty, rightx, righty, center, width;
+ double widthx, widthy;
+ double shift, shiftx, shifty;
+ double Xpixels, Ypixels;
+ struct segment *p;
+
+ p = Loc(CharSpace, edge1, 0.0);
+ QueryLoc(p, IDENTITY, &leftx, &lefty);
+
+ p = Join(p, Loc(CharSpace, edge2, 0.0));
+ QueryLoc(p, IDENTITY, &rightx, &righty);
+ Destroy(p);
+
+ widthx = FABS(rightx - leftx);
+ widthy = FABS(righty - lefty);
+
+ if (widthy <= EPS) { /* verticalondevice hint */
+ verticalondevice = TRUE;
+ center = (rightx + leftx) / 2.0;
+ width = widthx;
+ }
+ else if (widthx <= EPS) { /* horizontal hint */
+ verticalondevice = FALSE;
+ center = (righty + lefty) / 2.0;
+ width = widthy;
+ }
+ else { /* neither horizontal nor verticalondevice and not oblique */
+ return (NULL);
+ }
+
+ idealwidth = ROUND(width);
+ if (idealwidth == 0) idealwidth = 1;
+ if (ODD(idealwidth)) { /* is ideal width odd? */
+ /* center stem over pixel */
+ shift = FLOOR(center) + 0.5 - center;
+ }
+ else {
+ /* align stem on pixel boundary */
+ shift = ROUND(center) - center;
+ }
+
+ if (verticalondevice) {
+ shiftx = shift;
+ shifty = 0.0;
+ } else {
+ shifty = shift;
+ shiftx = 0.0;
+ }
+
+ p = Loc(IDENTITY, shiftx, shifty);
+ QueryLoc(p, CharSpace, &Xpixels, &Ypixels);
+ wsoffsetX = Xpixels; wsoffsetY = Ypixels;
+ currx += wsoffsetX; curry += wsoffsetY;
+
+ return (p);
+}
+
+/*-----------------------------------------------------------------------
+ Decrypt - From Adobe Type 1 book page 63, with some modifications
+-----------------------------------------------------------------------*/
+#define KEY 4330 /* Initial key (seed) for CharStrings decryption */
+#define C1 52845 /* Multiplier for pseudo-random number generator */
+#define C2 22719 /* Constant for pseudo-random number generator */
+
+static unsigned short r; /* Pseudo-random sequence of keys */
+
+static unsigned char
+Decrypt(unsigned char cipher)
+{
+ unsigned char plain;
+
+ plain = cipher ^ (r >> 8);
+ r = (cipher + r) * C1 + C2;
+ return plain;
+}
+
+/* Get the next byte from the codestring being interpreted */
+static int
+DoRead(int *CodeP)
+{
+ if (strindex >= CharStringP->len) return(FALSE); /* end of string */
+ *CodeP = Decrypt((unsigned char) CharStringP->data.stringP[strindex++]);
+ return(TRUE);
+}
+
+/* Strip blues->lenIV bytes from CharString and update encryption key */
+/* (the lenIV entry in the Private dictionary specifies the number of */
+/* random bytes at the beginning of each CharString; default is 4) */
+static void
+StartDecrypt(void)
+{
+ int Code;
+
+ r = KEY; /* Initial key (seed) for CharStrings decryption */
+ for (strindex = 0; strindex < blues->lenIV;)
+ if (!DoRead(&Code)) /* Read a byte and update decryption key */
+ Error;
+}
+
+static void
+Decode(int Code)
+{
+ int Code1, Code2, Code3, Code4;
+
+ if (Code <= 31) /* Code is [0,31] */
+ DoCommand(Code);
+ else if (Code <= 246) /* Code is [32,246] */
+ Push((double)(Code - 139));
+ else if (Code <= 250) { /* Code is [247,250] */
+ if (!DoRead(&Code2)) goto ended;
+ Push((double)(((Code - 247) << 8) + Code2 + 108));
+ }
+ else if (Code <= 254) { /* Code is [251,254] */
+ if (!DoRead(&Code2)) goto ended;
+ Push((double)( -((Code - 251) << 8) - Code2 - 108));
+ }
+ else { /* Code is 255 */
+ if (!DoRead(&Code1)) goto ended;
+ if (!DoRead(&Code2)) goto ended;
+ if (!DoRead(&Code3)) goto ended;
+ if (!DoRead(&Code4)) goto ended;
+ Push((double)((((((Code1<<8) + Code2)<<8) + Code3)<<8) + Code4));
+ }
+ return;
+
+ended: Error;
+}
+
+/* Interpret a command code */
+static void
+DoCommand(int Code)
+{
+ switch(Code) {
+ case HSTEM: /* |- y dy HSTEM |- */
+ /* Vertical range of a horizontal stem zone */
+ if (Top < 1) Error;
+ HStem(Stack[0], Stack[1]);
+ ClearStack();
+ break;
+ case VSTEM: /* |- x dx VSTEM |- */
+ /* Horizontal range of a vertical stem zone */
+ if (Top < 1) Error;
+ VStem(Stack[0], Stack[1]);
+ ClearStack();
+ break;
+ case VMOVETO: /* |- dy VMOVETO |- */
+ /* Vertical MOVETO, equivalent to 0 dy RMOVETO */
+ if (Top < 0) Error;
+ RMoveTo(0.0, Stack[0]);
+ ClearStack();
+ break;
+ case RLINETO: /* |- dx dy RLINETO |- */
+ /* Like RLINETO in PostScript */
+ if (Top < 1) Error;
+ RLineTo(Stack[0], Stack[1]);
+ ClearStack();
+ break;
+ case HLINETO: /* |- dx HLINETO |- */
+ /* Horizontal LINETO, equivalent to dx 0 RLINETO */
+ if (Top < 0) Error;
+ RLineTo(Stack[0], 0.0);
+ ClearStack();
+ break;
+ case VLINETO: /* |- dy VLINETO |- */
+ /* Vertical LINETO, equivalent to 0 dy RLINETO */
+ if (Top < 0) Error;
+ RLineTo(0.0, Stack[0]);
+ ClearStack();
+ break;
+ case RRCURVETO:
+ /* |- dx1 dy1 dx2 dy2 dx3 dy3 RRCURVETO |- */
+ /* Relative RCURVETO, equivalent to dx1 dy1 */
+ /* (dx1+dx2) (dy1+dy2) (dx1+dx2+dx3) */
+ /* (dy1+dy2+dy3) RCURVETO in PostScript */
+ if (Top < 5) Error;
+ RRCurveTo(Stack[0], Stack[1], Stack[2], Stack[3],
+ Stack[4], Stack[5]);
+ ClearStack();
+ break;
+ case CLOSEPATH: /* - CLOSEPATH |- */
+ /* Closes a subpath without repositioning the */
+ /* current point */
+ DoClosePath();
+ ClearStack();
+ break;
+ case CALLSUBR: /* subr# CALLSUBR - */
+ /* Calls a CharString subroutine with index */
+ /* subr# from the Subrs array */
+ if (Top < 0) Error;
+ CallSubr((int)Stack[Top--]);
+ break;
+ case RETURN: /* - RETURN - */
+ /* Returns from a Subrs array CharString */
+ /* subroutine called with CALLSUBR */
+ Return();
+ break;
+ case ESCAPE: /* ESCAPE to two-byte command code */
+ if (!DoRead(&Code)) Error;
+ Escape(Code);
+ break;
+ case HSBW: /* |- sbx wx HSBW |- */
+ /* Set the left sidebearing point to (sbx,0), */
+ /* set the character width vector to (wx,0). */
+ /* Equivalent to sbx 0 wx 0 SBW. Space */
+ /* character should have sbx = 0 */
+ if (Top < 1) Error;
+ Sbw(Stack[0], 0.0, Stack[1], 0.0);
+ ClearStack();
+ break;
+ case ENDCHAR: /* - ENDCHAR |- */
+ /* Finishes a CharString outline */
+ EndChar();
+ ClearStack();
+ break;
+ case RMOVETO: /* |- dx dy RMOVETO |- */
+ /* Behaves like RMOVETO in PostScript */
+ if (Top < 1) Error;
+ RMoveTo(Stack[0], Stack[1]);
+ ClearStack();
+ break;
+ case HMOVETO: /* |- dx HMOVETO |- */
+ /* Horizontal MOVETO. Equivalent to dx 0 RMOVETO */
+ if (Top < 0) Error;
+ RMoveTo(Stack[0], 0.0);
+ ClearStack();
+ break;
+ case VHCURVETO: /* |- dy1 dx2 dy2 dx3 VHCURVETO |- */
+ /* Vertical-Horizontal CURVETO, equivalent to */
+ /* 0 dy1 dx2 dy2 dx3 0 RRCURVETO */
+ if (Top < 3) Error;
+ RRCurveTo(0.0, Stack[0], Stack[1], Stack[2],
+ Stack[3], 0.0);
+ ClearStack();
+ break;
+ case HVCURVETO: /* |- dx1 dx2 dy2 dy3 HVCURVETO |- */
+ /* Horizontal-Vertical CURVETO, equivalent to */
+ /* dx1 0 dx2 dy2 0 dy3 RRCURVETO */
+ if (Top < 3) Error;
+ RRCurveTo(Stack[0], 0.0, Stack[1], Stack[2], 0.0, Stack[3]);
+ ClearStack();
+ break;
+ default: /* Unassigned command code */
+ ClearStack();
+ Error;
+ }
+}
+
+static void
+Escape(int Code)
+{
+ int i, Num;
+ struct segment *p;
+
+ switch(Code) {
+ case DOTSECTION: /* - DOTSECTION |- */
+ /* Brackets an outline section for the dots in */
+ /* letters such as "i", "j", and "!". */
+ DotSection();
+ ClearStack();
+ break;
+ case VSTEM3: /* |- x0 dx0 x1 dx1 x2 dx2 VSTEM3 |- */
+ /* Declares the horizontal ranges of three */
+ /* vertical stem zones between x0 and x0+dx0, */
+ /* x1 and x1+dx1, and x2 and x2+dx2. */
+ if (Top < 5) Error;
+ if (!wsset && ProcessHints) {
+ /* Shift the whole character so that the middle stem is centered. */
+ p = CenterStem(Stack[2] + sidebearingX, Stack[3]);
+ path = Join(path, p);
+ wsset = 1;
+ }
+
+ VStem(Stack[0], Stack[1]);
+ VStem(Stack[2], Stack[3]);
+ VStem(Stack[4], Stack[5]);
+ ClearStack();
+ break;
+ case HSTEM3: /* |- y0 dy0 y1 dy1 y2 dy2 HSTEM3 |- */
+ /* Declares the vertical ranges of three hori- */
+ /* zontal stem zones between y0 and y0+dy0, */
+ /* y1 and y1+dy1, and y2 and y2+dy2. */
+ if (Top < 5) Error;
+ HStem(Stack[0], Stack[1]);
+ HStem(Stack[2], Stack[3]);
+ HStem(Stack[4], Stack[5]);
+ ClearStack();
+ break;
+ case SEAC: /* |- asb adx ady bchar achar SEAC |- */
+ /* Standard Encoding Accented Character. */
+ if (Top < 4) Error;
+ Seac(Stack[0], Stack[1], Stack[2],
+ (unsigned char) Stack[3],
+ (unsigned char) Stack[4]);
+ ClearStack();
+ break;
+ case SBW: /* |- sbx sby wx wy SBW |- */
+ /* Set the left sidebearing point to (sbx,sby), */
+ /* set the character width vector to (wx,wy). */
+ if (Top < 3) Error;
+ Sbw(Stack[0], Stack[1], Stack[2], Stack[3]);
+ ClearStack();
+ break;
+ case DIV: /* num1 num2 DIV quotient */
+ /* Behaves like DIV in the PostScript language */
+ if (Top < 1) Error;
+ Stack[Top-1] = Div(Stack[Top-1], Stack[Top]);
+ Top--;
+ break;
+ case CALLOTHERSUBR:
+ /* arg1 ... argn n othersubr# CALLOTHERSUBR - */
+ /* Make calls on the PostScript interpreter */
+ if (Top < 1) Error;
+ Num = Stack[Top-1];
+ if (Top < Num+1) Error;
+ for (i = 0; i < Num; i++) PSFakePush(Stack[Top - i - 2]);
+ Top -= Num + 2;
+#if XFONT_CID
+ if ((int)Stack[Top + Num + 2] > 3)
+ ClearPSFakeStack();
+ else
+ CallOtherSubr((int)Stack[Top + Num + 2]);
+#else
+ CallOtherSubr((int)Stack[Top + Num + 2]);
+#endif
+ break;
+ case POP: /* - POP number */
+ /* Removes a number from the top of the */
+ /* PostScript interpreter stack and pushes it */
+ /* onto the Type 1 BuildChar operand stack */
+ Push(PSFakePop());
+ break;
+ case SETCURRENTPOINT: /* |- x y SETCURRENTPOINT |- */
+ /* Sets the current point to (x,y) in absolute */
+ /* character space coordinates without per- */
+ /* forming a CharString MOVETO command */
+ if (Top < 1) Error;
+ SetCurrentPoint(Stack[0], Stack[1]);
+ ClearStack();
+ break;
+ default: /* Unassigned escape code command */
+ ClearStack();
+ Error;
+ }
+}
+
+/* |- y dy HSTEM |- */
+/* Declares the vertical range of a horizontal stem zone */
+/* between coordinates y and y + dy */
+/* y is relative to the left sidebearing point */
+static void
+HStem(double y, double dy)
+{
+ if (ProcessHints) {
+ if (numstems >= MAXSTEMS) Error;
+ if (dy < 0.0) {y += dy; dy = -dy;}
+ stems[numstems].vertical = FALSE;
+ stems[numstems].x = 0.0;
+ stems[numstems].y = sidebearingY + y + wsoffsetY;
+ stems[numstems].dx = 0.0;
+ stems[numstems].dy = dy;
+ ComputeStem(numstems);
+ numstems++;
+ }
+}
+
+/* |- x dx VSTEM |- */
+/* Declares the horizontal range of a vertical stem zone */
+/* between coordinates x and x + dx */
+/* x is relative to the left sidebearing point */
+
+static void
+VStem(double x, double dx)
+{
+ if (ProcessHints) {
+ if (numstems >= MAXSTEMS) Error;
+ if (dx < 0.0) {x += dx; dx = -dx;}
+ stems[numstems].vertical = TRUE;
+ stems[numstems].x = sidebearingX + x + wsoffsetX;
+ stems[numstems].y = 0.0;
+ stems[numstems].dx = dx;
+ stems[numstems].dy = 0.0;
+ ComputeStem(numstems);
+ numstems++;
+ }
+}
+
+/* |- dx dy RLINETO |- */
+/* Behaves like RLINETO in PostScript */
+static void
+RLineTo(double dx, double dy)
+{
+ struct segment *B;
+
+ B = Loc(CharSpace, dx, dy);
+
+ if (ProcessHints) {
+ currx += dx;
+ curry += dy;
+ /* B = Join(B, FindStems(currx, curry)); */
+ B = Join(B, FindStems(currx, curry, dx, dy));
+ }
+
+ path = Join(path, Line(B));
+}
+
+/* |- dx1 dy1 dx2 dy2 dx3 dy3 RRCURVETO |- */
+/* Relative RCURVETO, equivalent to dx1 dy1 */
+/* (dx1+dx2) (dy1+dy2) (dx1+dx2+dx3) */
+/* (dy1+dy2+dy3) RCURVETO in PostScript */
+static void
+RRCurveTo(double dx1, double dy1, double dx2, double dy2,
+ double dx3, double dy3)
+{
+ struct segment *B, *C, *D;
+
+ B = Loc(CharSpace, dx1, dy1);
+ C = Loc(CharSpace, dx2, dy2);
+ D = Loc(CharSpace, dx3, dy3);
+
+ if (ProcessHints) {
+ /* For a Bezier curve, we apply the full hint value to
+ the Bezier C point (and thereby D point). */
+ currx += dx1 + dx2 + dx3;
+ curry += dy1 + dy2 + dy3;
+ /* C = Join(C, FindStems(currx, curry)); */
+ C = Join(C, FindStems(currx, curry, dx3, dy3));
+ }
+
+ /* Since XIMAGER is not completely relative, */
+ /* we need to add up the delta values */
+
+ C = Join(C, (struct segment *)Dup(B));
+ D = Join(D, (struct segment *)Dup(C));
+
+ path = Join(path, (struct segment *)Bezier(B, C, D));
+}
+
+/* - CLOSEPATH |- */
+/* Closes a subpath WITHOUT repositioning the */
+/* current point */
+static void
+DoClosePath(void)
+{
+ struct segment *CurrentPoint;
+
+ CurrentPoint = Phantom(path);
+ path = ClosePath(path);
+ path = Join(Snap(path), CurrentPoint);
+}
+
+/* subr# CALLSUBR - */
+/* Calls a CharString subroutine with index */
+/* subr# from the Subrs array */
+static void
+CallSubr(int subrno)
+{
+ if ((subrno < 0) || (subrno >= SubrsP->len))
+ Error;
+ PushCall(CharStringP, strindex, r);
+ CharStringP = &SubrsP->data.arrayP[subrno];
+ StartDecrypt();
+}
+
+/* - RETURN - */
+/* Returns from a Subrs array CharString */
+/* subroutine called with CALLSUBR */
+static void
+Return(void)
+{
+ PopCall(&CharStringP, &strindex, &r);
+}
+
+/* - ENDCHAR |- */
+/* Finishes a CharString outline */
+/* Executes SETCHACHEDEVICE using a bounding box */
+/* it computes directly from the character outline */
+/* and using the width information acquired from a previous */
+/* HSBW or SBW. It then calls a special version of FILL */
+/* or STROKE depending on the value of PaintType in the */
+/* font dictionary */
+static void
+EndChar(void)
+{
+ /* There is no need to compute and set bounding box for
+ the cache, since XIMAGER does that on the fly. */
+
+ /* Perform a Closepath just in case the command was left out */
+ path = ClosePath(path);
+
+ /* Set character width */
+ path = Join(Snap(path), Loc(CharSpace, escapementX, escapementY));
+
+}
+
+/* |- dx dy RMOVETO |- */
+/* Behaves like RMOVETO in PostScript */
+static void
+RMoveTo(double dx, double dy)
+{
+ struct segment *B;
+
+ B = Loc(CharSpace, dx, dy);
+
+ if (ProcessHints) {
+ currx += dx;
+ curry += dy;
+ /* B = Join(B, FindStems(currx, curry)); */
+ B = Join(B, FindStems(currx, curry, 0.0, 0.0));
+ }
+
+ path = Join(path, B);
+}
+
+/* - DOTSECTION |- */
+/* Brackets an outline section for the dots in */
+/* letters such as "i", "j", and "!". */
+static void
+DotSection(void)
+{
+ InDotSection = !InDotSection;
+}
+
+/* |- asb adx ady bchar achar SEAC |- */
+/* Standard Encoding Accented Character. */
+static void
+Seac(double asb, double adx, double ady,
+ unsigned char bchar, unsigned char achar)
+{
+ int Code;
+ struct segment *mypath;
+
+ /* Move adx - asb, ady over and up from base char's sbpoint. */
+ /* (We use adx - asb to counteract the accents sb shift.) */
+ /* The variables accentoffsetX/Y modify sidebearingX/Y in Sbw(). */
+ /* Note that these incorporate the base character's sidebearing shift by */
+ /* using the current sidebearingX, Y values. */
+ accentoffsetX = sidebearingX + adx - asb;
+ accentoffsetY = sidebearingY + ady;
+
+ /* Set path = NULL to avoid complaints from Sbw(). */
+ path = NULL;
+
+ /* Go find the CharString for the accent's code via an upcall */
+ CharStringP = GetType1CharString((psfont *)Environment, achar);
+ StartDecrypt();
+
+ ClearStack();
+ ClearPSFakeStack();
+ ClearCallStack();
+
+ for (;;) {
+ if (!DoRead(&Code)) break;
+ Decode(Code);
+ if (errflag) return;
+ }
+ /* Copy snapped path to mypath and set path to NULL as above. */
+ mypath = Snap(path);
+ path = NULL;
+
+ /* We must reset these to null now. */
+ accentoffsetX = accentoffsetY = 0;
+
+ /* go find the CharString for the base char's code via an upcall */
+ CharStringP = GetType1CharString((psfont *)Environment, bchar);
+ StartDecrypt();
+
+ ClearStack();
+ ClearPSFakeStack();
+ ClearCallStack();
+
+ FinitStems();
+ InitStems();
+
+ for (;;) {
+ if (!DoRead(&Code)) break;
+ Decode(Code);
+ if (errflag) return;
+ }
+ path = Join(mypath, path);
+}
+
+
+/* |- sbx sby wx wy SBW |- */
+/* Set the left sidebearing point to (sbx,sby), */
+/* set the character width vector to (wx,wy). */
+static void
+Sbw(double sbx, double sby, double wx, double wy)
+{
+ escapementX = wx; /* Character width vector */
+ escapementY = wy;
+
+ /* Sidebearing values are sbx, sby args, plus accent offset from Seac(). */
+ sidebearingX = sbx + accentoffsetX;
+ sidebearingY = sby + accentoffsetY;
+
+ path = Join(path, Loc(CharSpace, sidebearingX, sidebearingY));
+ if (ProcessHints) {currx = sidebearingX; curry = sidebearingY;}
+}
+
+ /* num1 num2 DIV quotient */
+/* Behaves like DIV in the PostScript language */
+static double
+Div(double num1, double num2)
+{
+ return(num1 / num2);
+}
+
+/*
+ The following four subroutines (FlxProc, FlxProc1, FlxProc2, and
+ HintReplace) are C versions of the OtherSubrs Programs, which were
+ were published in the Adobe Type 1 Font Format book.
+
+ The Flex outline fragment is described by
+ c1: (x0, y0) = c3: (x0, yshrink(y0)) or (xshrink(x0), y0)
+ " (x1, y1) = " (x1, yshrink(y1)) or (xshrink(x1), y1)
+ " (x2, y2) - reference point
+ c2: (x0, y0) = c4: (x0, yshrink(y0)) or (xshrink(x0), y0)
+ " (x1, y1) = " (x1, yshrink(y1)) or (xshrink(x1), y1)
+ " (x2, y2) = " (x2, y2), rightmost endpoint
+ c3: (x0, y0) - control point, 1st Bezier curve
+ " (x1, y1) - control point, -"-
+ " (x2, y2) - end point, -"-
+ c4: (x0, y0) - control point, 2nd Bezier curve
+ " (x1, y1) - control point, -"-
+ " (x2, y2) - end point, -"-
+ ep: (epY, epX) - final endpoint (should be same as c4: (x2, y2))
+ idmin - minimum Flex height (1/100 pixel) at which to render curves
+*/
+
+#define dtransform(dxusr,dyusr,dxdev,dydev) { \
+ register struct segment *point = Loc(CharSpace, dxusr, dyusr); \
+ QueryLoc(point, IDENTITY, dxdev, dydev); \
+ Destroy(point); \
+}
+
+#define itransform(xdev,ydev,xusr,yusr) { \
+ register struct segment *point = Loc(IDENTITY, xdev, ydev); \
+ QueryLoc(point, CharSpace, xusr, yusr); \
+ Destroy(point); \
+}
+
+#define transform(xusr,yusr,xdev,ydev) dtransform(xusr,yusr,xdev,ydev)
+
+#define PaintType (0)
+
+#define lineto(x,y) { \
+ struct segment *CurrentPoint; \
+ double CurrentX, CurrentY; \
+ CurrentPoint = Phantom(path); \
+ QueryLoc(CurrentPoint, CharSpace, &CurrentX, &CurrentY); \
+ Destroy(CurrentPoint); \
+ RLineTo(x - CurrentX, y - CurrentY); \
+}
+
+#define curveto(x0,y0,x1,y1,x2,y2) { \
+ struct segment *CurrentPoint; \
+ double CurrentX, CurrentY; \
+ CurrentPoint = Phantom(path); \
+ QueryLoc(CurrentPoint, CharSpace, &CurrentX, &CurrentY); \
+ Destroy(CurrentPoint); \
+ RRCurveTo(x0 - CurrentX, y0 - CurrentY, x1 - x0, y1 - y0, x2 - x1, y2 - y1); \
+}
+
+#define xshrink(x) ((x - c4x2) * shrink +c4x2)
+#define yshrink(y) ((y - c4y2) * shrink +c4y2)
+
+#define PickCoords(flag) \
+ if (flag) { /* Pick "shrunk" coordinates */ \
+ x0 = c1x0; y0 = c1y0; \
+ x1 = c1x1; y1 = c1y1; \
+ x2 = c1x2; y2 = c1y2; \
+ x3 = c2x0; y3 = c2y0; \
+ x4 = c2x1; y4 = c2y1; \
+ x5 = c2x2; y5 = c2y2; \
+ } else { /* Pick original coordinates */ \
+ x0 = c3x0; y0 = c3y0; \
+ x1 = c3x1; y1 = c3y1; \
+ x2 = c3x2; y2 = c3y2; \
+ x3 = c4x0; y3 = c4y0; \
+ x4 = c4x1; y4 = c4y1; \
+ x5 = c4x2; y5 = c4y2; \
+ }
+
+/* FlxProc() = OtherSubrs[0]; Main part of Flex */
+/* Calling sequence: 'idmin epX epY 3 0 callothersubr' */
+/* Computes Flex values, and renders the Flex path, */
+/* and returns (leaves) ending coordinates on stack */
+static void
+FlxProc(double c1x2, double c1y2, double c3x0, double c3y0,
+ double c3x1, double c3y1, double c3x2, double c3y2,
+ double c4x0, double c4y0, double c4x1, double c4y1,
+ double c4x2, double c4y2, double epY, double epX, int idmin)
+{
+ double dmin;
+ double c1x0, c1y0, c1x1, c1y1;
+ double c2x0, c2y0, c2x1, c2y1, c2x2, c2y2;
+ char yflag;
+ double x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5;
+ double cxx, cyx, cxy, cyy; /* Transformation matrix */
+ int flipXY;
+ double x, y;
+ double erosion = 1; /* Device parameter */
+ /* Erosion may have different value specified in 'internaldict' */
+ double shrink;
+ double dX, dY;
+ char erode;
+ double eShift;
+ double cx, cy;
+ double ex, ey;
+
+ c1x0 = c1y0 = c1x1 = c1y1 = c2x0 = c2y0 = c2x1 = c2y1 = c2x2 = c2y2 = 0.0;
+
+ Destroy(path);
+ path = FlxOldPath; /* Restore previous path (stored in FlxProc1) */
+
+ if (ProcessHints) {
+ dmin = ABS(idmin) / 100.0; /* Minimum Flex height in pixels */
+
+ c2x2 = c4x2; c2y2 = c4y2; /* Point c2 = c4 */
+
+ yflag = FABS(c1y2 - c3y2) > FABS(c1x2 - c3x2); /* Flex horizontal? */
+
+ QuerySpace(CharSpace, &cxx, &cyx, &cxy, &cyy); /* Transformation matrix */
+
+ if (FABS(cxx) < 0.00001 || FABS(cyy) < 0.00001)
+ flipXY = -1; /* Char on side */
+ else if (FABS(cyx) < 0.00001 || FABS(cxy) < 0.00001)
+ flipXY = 1; /* Char upright */
+ else
+ flipXY = 0; /* Char at angle */
+
+ if (yflag) { /* Flex horizontal */
+ if (flipXY == 0 || c3y2 == c4y2) { /* Char at angle or Flex height = 0 */
+ PickCoords(FALSE); /* Pick original control points */
+ } else {
+ shrink = FABS((c1y2 - c4y2) / (c3y2 - c4y2)); /* Slope */
+
+ c1x0 = c3x0; c1y0 = yshrink(c3y0);
+ c1x1 = c3x1; c1y1 = yshrink(c3y1);
+ c2x0 = c4x0; c2y0 = yshrink(c4y0);
+ c2x1 = c4x1; c2y1 = yshrink(c4y1);
+
+ dtransform(0.0, ROUND(c3y2-c1y2), &x, &y); /* Flex height in pixels */
+ dY = FABS((flipXY == 1) ? y : x);
+ PickCoords(dY < dmin); /* If Flex small, pick 'shrunk' control points */
+
+ if (FABS(y2 - c1y2) > 0.001) { /* Flex 'non-zero'? */
+ transform(c1x2, c1y2, &x, &y);
+
+ if (flipXY == 1) {
+ cx = x; cy = y;
+ } else {
+ cx = y; cy = x;
+ }
+
+ dtransform(0.0, ROUND(y2-c1y2), &x, &y);
+ dY = (flipXY == 1) ? y : x;
+ if (ROUND(dY) != 0)
+ dY = ROUND(dY);
+ else
+ dY = (dY < 0) ? -1 : 1;
+
+ erode = PaintType != 2 && erosion >= 0.5;
+ if (erode)
+ cy -= 0.5;
+ ey = cy + dY;
+ ey = CEIL(ey) - ey;
+ ey = ey + FLOOR(cy + dY);
+ if (erode)
+ ey += 0.5;
+
+ if (flipXY == 1) {
+ itransform(cx, ey, &x, &y);
+ } else {
+ itransform(ey, cx, &x, &y);
+ }
+
+ eShift = y - y2;
+ y1 += eShift;
+ y2 += eShift;
+ y3 += eShift;
+ }
+ }
+ } else { /* Flex vertical */
+ if (flipXY == 0 || c3x2 == c4x2) { /* Char at angle or Flex height = 0 */
+ PickCoords(FALSE); /* Pick original control points */
+ } else {
+ shrink = FABS((c1x2 - c4x2) / (c3x2 - c4x2)); /* Slope */
+
+ c1x0 = xshrink(c3x0); c1y0 = c3y0;
+ c1x1 = xshrink(c3x1); c1y1 = c3y1;
+ c2x0 = xshrink(c4x0); c2y0 = c4y0;
+ c2x1 = xshrink(c4x1); c2y1 = c4y1;
+
+ dtransform(ROUND(c3x2 - c1x2), 0.0, &x, &y); /* Flex height in pixels */
+ dX = FABS((flipXY == -1) ? y : x);
+ PickCoords(dX < dmin); /* If Flex small, pick 'shrunk' control points */
+
+ if (FABS(x2 - c1x2) > 0.001) {
+ transform(c1x2, c1y2, &x, &y);
+ if (flipXY == -1) {
+ cx = y; cy = x;
+ } else {
+ cx = x; cy = y;
+ }
+
+ dtransform(ROUND(x2-c1x2), 0.0, &x, &y);
+ dX = (flipXY == -1) ? y : x;
+ if (ROUND(dX) != 0)
+ dX = ROUND(dX);
+ else
+ dX = (dX < 0) ? -1 : 1;
+
+ erode = PaintType != 2 && erosion >= 0.5;
+ if (erode)
+ cx -= 0.5;
+ ex = cx + dX;
+ ex = CEIL(ex) - ex;
+ ex = ex + FLOOR(cx + dX);
+ if (erode)
+ ex += 0.5;
+
+ if (flipXY == -1) {
+ itransform(cy, ex, &x, &y);
+ } else {
+ itransform(ex, cy, &x, &y);
+ }
+
+ eShift = x - x2;
+ x1 += eShift;
+ x2 += eShift;
+ x3 += eShift;
+ }
+ }
+ }
+
+ if (x2 == x5 || y2 == y5) {
+ lineto(x5, y5);
+ } else {
+ curveto(x0, y0, x1, y1, x2, y2);
+ curveto(x3, y3, x4, y4, x5, y5);
+ }
+ } else { /* ProcessHints is off */
+ PickCoords(FALSE); /* Pick original control points */
+ curveto(x0, y0, x1, y1, x2, y2);
+ curveto(x3, y3, x4, y4, x5, y5);
+ }
+
+ PSFakePush(epY);
+ PSFakePush(epX);
+}
+
+/* FlxProc1() = OtherSubrs[1]; Part of Flex */
+/* Calling sequence: '0 1 callothersubr' */
+/* Saves and clears path, then restores currentpoint */
+static void
+FlxProc1(void)
+{
+ struct segment *CurrentPoint;
+
+ CurrentPoint = Phantom(path);
+
+ FlxOldPath = path;
+ path = CurrentPoint;
+}
+
+/* FlxProc2() = OtherSubrs[2]; Part of Flex */
+/* Calling sequence: '0 2 callothersubr' */
+/* Returns currentpoint on stack */
+static void
+FlxProc2(void)
+{
+ struct segment *CurrentPoint;
+ double CurrentX, CurrentY;
+
+ CurrentPoint = Phantom(path);
+ QueryLoc(CurrentPoint, CharSpace, &CurrentX, &CurrentY);
+ Destroy(CurrentPoint);
+
+ /* Push CurrentPoint on fake PostScript stack */
+ PSFakePush(CurrentX);
+ PSFakePush(CurrentY);
+}
+
+/* HintReplace() = OtherSubrs[3]; Hint Replacement */
+/* Calling sequence: 'subr# 1 3 callothersubr pop callsubr' */
+/* Reinitializes stem hint structure */
+static void
+HintReplace(void)
+{
+ /* Effectively retire the current stems, but keep them around for */
+ /* revhint use in case we are in a stem when we replace hints. */
+ currstartstem = numstems;
+
+ /* 'subr#' is left on PostScript stack (for 'pop callsubr') */
+}
+
+/* arg1 ... argn n othersubr# CALLOTHERSUBR - */
+/* Make calls on the PostScript interpreter (or call equivalent C code) */
+/* NOTE: The n arguments have been pushed on the fake PostScript stack */
+static void
+CallOtherSubr(int othersubrno)
+{
+ switch(othersubrno) {
+ case 0: /* OtherSubrs[0]; Main part of Flex */
+ if (PSFakeTop < 16) Error;
+ ClearPSFakeStack();
+ FlxProc(
+ PSFakeStack[0], PSFakeStack[1], PSFakeStack[2], PSFakeStack[3],
+ PSFakeStack[4], PSFakeStack[5], PSFakeStack[6], PSFakeStack[7],
+ PSFakeStack[8], PSFakeStack[9], PSFakeStack[10], PSFakeStack[11],
+ PSFakeStack[12], PSFakeStack[13], PSFakeStack[14], PSFakeStack[15],
+ (int) PSFakeStack[16]
+ );
+ break;
+ case 1: /* OtherSubrs[1]; Part of Flex */
+ FlxProc1();
+ break;
+ case 2: /* OtherSubrs[2]; Part of Flex */
+ FlxProc2();
+ break;
+ case 3: /* OtherSubrs[3]; Hint Replacement */
+ HintReplace();
+ break;
+ default: { /* call OtherSubrs[4] or higher if PostScript is present */
+ }
+ }
+}
+
+/* |- x y SETCURRENTPOINT |- */
+/* Sets the current point to (x,y) in absolute */
+/* character space coordinates without per- */
+/* forming a CharString MOVETO command */
+static void
+SetCurrentPoint(double x, double y)
+{
+ currx = x;
+ curry = y;
+}
+
+/* The Type1Char routine for use by PostScript. */
+/************************************************/
+struct xobject *
+Type1Char(char *env, struct XYspace *S, psobj *charstrP, psobj *subrsP,
+ psobj *osubrsP,
+ struct blues_struct *bluesP, /* FontID's ptr to the blues struct */
+ int *modeP)
+{
+ int Code;
+
+ path = NULL;
+ errflag = FALSE;
+
+ /* Make parameters available to all Type1 routines */
+ Environment = env;
+ CharSpace = S; /* used when creating path elements */
+ CharStringP = charstrP;
+ SubrsP = subrsP;
+
+ blues = bluesP;
+
+ /* compute the alignment zones */
+ ComputeAlignmentZones();
+
+ StartDecrypt();
+
+ ClearStack();
+ ClearPSFakeStack();
+ ClearCallStack();
+
+ InitStems();
+
+ currx = curry = 0;
+ escapementX = escapementY = 0;
+ sidebearingX = sidebearingY = 0;
+ accentoffsetX = accentoffsetY = 0;
+ wsoffsetX = wsoffsetY = 0; /* No shift to preserve whitspace. */
+ wsset = 0; /* wsoffsetX,Y haven't been set yet. */
+
+ for (;;) {
+ if (!DoRead(&Code)) break;
+ Decode(Code);
+ if (errflag) break;
+ }
+
+ FinitStems();
+
+
+ /* Clean up if an error has occurred */
+ if (errflag) {
+ if (path != NULL) {
+ Destroy(path); /* Reclaim storage */
+ path = NULL; /* Indicate that character could not be built */
+ }
+ }
+
+ return((struct xobject *) path);
+}
+
+#if XFONT_CID
+struct xobject *
+CIDChar(char *env, struct XYspace *S,
+ psobj *charstrP, psobj *subrsP, psobj *osubrsP,
+ struct blues_struct *bluesP, /* FontID's ptr to the blues struct */
+ int *modeP)
+{
+ int Code;
+
+ path = NULL;
+ errflag = FALSE;
+
+ /* Make parameters available to all CID routines */
+ Environment = env;
+ CharSpace = S; /* used when creating path elements */
+ CharStringP = charstrP;
+ SubrsP = subrsP;
+
+ blues = bluesP;
+
+ /* compute the alignment zones */
+ ComputeAlignmentZones();
+
+ StartDecrypt();
+
+ ClearStack();
+ ClearPSFakeStack();
+ ClearCallStack();
+
+ InitStems();
+
+ currx = curry = 0;
+ escapementX = escapementY = 0;
+ sidebearingX = sidebearingY = 0;
+ accentoffsetX = accentoffsetY = 0;
+ wsoffsetX = wsoffsetY = 0; /* No shift to preserve whitspace. */
+ wsset = 0; /* wsoffsetX,Y haven't been set yet. */
+
+ for (;;) {
+ if (!DoRead(&Code)) break;
+ Decode(Code);
+ if (errflag) break;
+ }
+
+ FinitStems();
+
+ /* Clean up if an error has occurred */
+ if (errflag) {
+ if (path != NULL) {
+ Destroy(path); /* Reclaim storage */
+ path = NULL; /* Indicate that character could not be built */
+ }
+ }
+
+ return((struct xobject *) path);
+}
+#endif
diff --git a/nx-X11/lib/font/Type1/util.c b/nx-X11/lib/font/Type1/util.c
new file mode 100644
index 000000000..7c5a81dee
--- /dev/null
+++ b/nx-X11/lib/font/Type1/util.c
@@ -0,0 +1,222 @@
+/* $Xorg: util.c,v 1.3 2000/08/17 19:46:34 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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 (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/util.c,v 1.5 1999/08/21 13:47:53 dawes Exp $ */
+/* Author: Katherine A. Hitchcock IBM Almaden Research Laboratory */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#ifndef FONTMODULE
+#include <stdio.h>
+#else
+#include "Xdefs.h"
+#include "Xmd.h"
+#include "xf86_ansic.h"
+#endif
+#include "util.h"
+#include <X11/fonts/fontmisc.h> /* for xalloc/xfree */
+
+static char *vm_base = NULL; /* Start of virtual memory area */
+ char *vm_next = NULL; /* Pointer to first free byte */
+ long vm_free = 0; /* Count of free bytes */
+ long vm_size = 0; /* Total size of memory */
+
+/*
+ * Initialize memory.
+ */
+boolean
+vm_init(int cnt)
+{
+#if XFONT_CID
+ if (vm_base == NULL || (vm_base != NULL && vm_size != cnt)) {
+ if (vm_base != NULL) xfree(vm_base);
+ vm_next = vm_base = (char *)xalloc (cnt);
+ } else
+ vm_next = vm_base;
+#else
+ vm_next = vm_base = (char *)xalloc (cnt);
+#endif
+
+ if (vm_base != NULL) {
+ vm_free = cnt;
+ vm_size = cnt;
+ return(TRUE);
+ }
+ else
+ return(FALSE);
+
+}
+
+char *
+vm_alloc(int bytes)
+{
+ char *answer;
+
+ /* Round to next word multiple */
+ bytes = (bytes + 7) & ~7;
+
+ /* Allocate the space, if it is available */
+ if (bytes > 0 && bytes <= vm_free) {
+ answer = vm_next;
+ vm_free -= bytes;
+ vm_next += bytes;
+ }
+ else
+ answer = NULL;
+
+ return(answer);
+}
+
+/*
+ * Format an Integer object
+ */
+void
+objFormatInteger(psobj *objP, int value)
+{
+ if (objP != NULL) {
+ objP->type = OBJ_INTEGER;
+ objP->len = 0;
+ objP->data.integer = value;
+ }
+}
+
+/*
+ * Format a Real object
+ */
+void
+objFormatReal(psobj *objP, float value)
+{
+ if (objP != NULL) {
+ objP->type = OBJ_REAL;
+ objP->len = 0;
+ objP->data.real = value;
+ }
+}
+
+/*
+ * Format a Boolean object
+ */
+void
+objFormatBoolean(psobj *objP, boolean value)
+{
+ if (objP != NULL) {
+ objP->type = OBJ_BOOLEAN;
+ objP->len = 0;
+ objP->data.boolean = value;
+ }
+}
+
+/*
+ * Format an Encoding object
+ */
+void
+objFormatEncoding(psobj *objP, int length, psobj *valueP)
+{
+ if (objP != NULL) {
+ objP->type = OBJ_ENCODING;
+ objP->len = length;
+ objP->data.arrayP = valueP;
+ }
+}
+
+/*
+ * Format an Array object
+ */
+void
+objFormatArray(psobj *objP, int length, psobj *valueP)
+{
+ if (objP != NULL) {
+ objP->type = OBJ_ARRAY;
+ objP->len = length;
+ objP->data.arrayP = valueP;
+ }
+}
+
+
+/*
+ * Format a String object
+ */
+void
+objFormatString(psobj *objP, int length, char *valueP)
+{
+ if (objP != NULL) {
+ objP->type = OBJ_STRING;
+ objP->len = length;
+ objP->data.valueP = valueP;
+ }
+}
+
+/*
+ * Format a Name object
+ */
+void
+objFormatName(psobj *objP, int length, char *valueP)
+{
+ if (objP != NULL) {
+ objP->type = OBJ_NAME;
+ objP->len = length;
+ objP->data.nameP = valueP;
+ }
+}
+
+/*
+ * Format a File object
+ */
+void
+objFormatFile(psobj *objP, FILE *valueP)
+{
+ if (objP != NULL) {
+ objP->type = OBJ_FILE;
+ objP->len = 0;
+ objP->data.fileP = valueP;
+ }
+}
+
diff --git a/nx-X11/lib/font/Type1/util.h b/nx-X11/lib/font/Type1/util.h
new file mode 100644
index 000000000..a1a8b3e6b
--- /dev/null
+++ b/nx-X11/lib/font/Type1/util.h
@@ -0,0 +1,217 @@
+/* $Xorg: util.h,v 1.3 2000/08/17 19:46:34 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License 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 IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM 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 (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/util.h,v 1.4 1999/08/22 08:58:55 dawes Exp $ */
+
+#ifndef UTIL_H
+#define UTIL_H
+
+#ifdef BUILDCID
+#define XFONT_CID 1
+#endif
+
+#ifndef boolean
+typedef int boolean;
+#endif
+
+#ifndef TRUE
+#define TRUE (1)
+#endif
+
+#ifndef FALSE
+#define FALSE (0)
+#endif
+
+/***================================================================***/
+/* Portable definitions for 2's complement machines.
+ * NOTE: These really should be based on PostScript types,
+ * for example, sizeof(ps_integer), or sizeof(ps_unsigned)
+ */
+#define MAX_ULONG (~(unsigned long)(0))
+/* This code is portable, assuming K&R C and 2's complement arithmetic */
+#define MAX_INTEGER \
+ ((long)((((unsigned long) 1)<<(sizeof(unsigned long)*8-1))-1))
+#define MIN_INTEGER ((-MAX_INTEGER)-1)
+
+#define MAX_ARRAY_CNT (65535)
+#define MAX_DICT_CNT (65535)
+#define MAX_STRING_LEN (65535)
+#define MAX_NAME_LEN (128)
+
+/* this is the size of memory allocated for reading fonts */
+
+#if XFONT_CID
+#define VM_SIZE (100*1024)
+#else
+#define VM_SIZE (50*1024)
+#endif
+/***================================================================***/
+
+#ifndef MIN
+#define MIN(a,b) (((a)<(b)) ? a : b )
+#endif
+
+/***================================================================***/
+/* Routines for managing virtual memory */
+/***================================================================***/
+
+extern boolean vm_init ( int cnt );
+extern long vm_free;
+extern long vm_size;
+extern char *vm_next;
+extern char *vm_alloc ( int bytes );
+
+/***================================================================***/
+/* Macros for managing virtual memory */
+/***================================================================***/
+#define vm_next_byte() (vm_next)
+#define vm_free_bytes() (vm_free)
+#define vm_avail(B) (B <= vm_free)
+
+
+
+/***================================================================***/
+/* Types of PostScript objects */
+/***================================================================***/
+#define OBJ_INTEGER (0)
+#define OBJ_REAL (1)
+#define OBJ_BOOLEAN (2)
+#define OBJ_ARRAY (3)
+#define OBJ_STRING (4)
+#define OBJ_NAME (5)
+#define OBJ_FILE (6)
+#define OBJ_ENCODING (7)
+
+/***================================================================***/
+/* Value of PostScript objects */
+/***================================================================***/
+typedef union ps_value {
+ char *valueP; /* value pointer for unspecified type */
+ int value; /* value for unspecified type */
+ int integer; /* when type is OBJ_INTEGER */
+ float real; /* when type is OBJ_REAL */
+ int boolean; /* when type is OBJ_BOOLEAN */
+ struct ps_obj *arrayP; /* when type is OBJ_ARRAY */
+ unsigned char *stringP; /* when type is OBJ_STRING */
+ char *nameP; /* when type is OBJ_NAME */
+ FILE *fileP; /* when type is OBJ_FILE */
+} psvalue;
+
+/***================================================================***/
+/* Definition of a PostScript object */
+/***================================================================***/
+typedef struct ps_obj {
+ char type;
+ char unused;
+ unsigned short len;
+ union ps_value data;
+} psobj;
+
+/***================================================================***/
+/* Definition of a PostScript Dictionary Entry */
+/***================================================================***/
+typedef struct ps_dict {
+ psobj key;
+ psobj value;
+} psdict;
+
+/***================================================================***/
+/* Macros for testing type of PostScript objects */
+/***================================================================***/
+#define objIsInteger(o) ((o).type == OBJ_INTEGER)
+#define objIsReal(o) ((o).type == OBJ_REAL)
+#define objIsBoolean(o) ((o).type == OBJ_BOOLEAN)
+#define objIsArray(o) ((o).type == OBJ_ARRAY)
+#define objIsString(o) ((o).type == OBJ_STRING)
+#define objIsName(o) ((o).type == OBJ_NAME)
+#define objIsFile(o) ((o).type == OBJ_FILE)
+
+/***================================================================***/
+/* Macros for setting type of PostScript objects */
+/***================================================================***/
+#define objSetInteger(o) ((o).type = OBJ_INTEGER)
+#define objSetReal(o) ((o).type = OBJ_REAL)
+#define objSetBoolean(o) ((o).type = OBJ_BOOLEAN)
+#define objSetArray(o) ((o).type = OBJ_ARRAY)
+#define objSetString(o) ((o).type = OBJ_STRING)
+#define objSetName(o) ((o).type = OBJ_NAME)
+#define objSetFile(o) ((o).type = OBJ_FILE)
+
+/***================================================================***/
+/* Macros for testing type of PostScript objects (pointer access) */
+/***================================================================***/
+#define objPIsInteger(o) ((o)->type == OBJ_INTEGER)
+#define objPIsReal(o) ((o)->type == OBJ_REAL)
+#define objPIsBoolean(o) ((o)->type == OBJ_BOOLEAN)
+#define objPIsArray(o) ((o)->type == OBJ_ARRAY)
+#define objPIsString(o) ((o)->type == OBJ_STRING)
+#define objPIsName(o) ((o)->type == OBJ_NAME)
+#define objPIsFile(o) ((o)->type == OBJ_FILE)
+
+/***================================================================***/
+/* Macros for setting type of PostScript objects (pointer access) */
+/***================================================================***/
+#define objPSetInteger(o) ((o)->type = OBJ_INTEGER)
+#define objPSetReal(o) ((o)->type = OBJ_REAL)
+#define objPSetBoolean(o) ((o)->type = OBJ_BOOLEAN)
+#define objPSetArray(o) ((o)->type = OBJ_ARRAY)
+#define objPSetString(o) ((o)->type = OBJ_STRING)
+#define objPSetName(o) ((o)->type = OBJ_NAME)
+#define objPSetFile(o) ((o)->type = OBJ_FILE)
+
+/***================================================================***/
+/* Prototypes of object formatting functions */
+/***================================================================***/
+extern void objFormatInteger ( psobj *objP, int value );
+extern void objFormatReal ( psobj *objP, float value );
+extern void objFormatBoolean ( psobj *objP, boolean value );
+extern void objFormatEncoding ( psobj *objP, int length, psobj *valueP );
+extern void objFormatArray ( psobj *objP, int length, psobj *valueP );
+extern void objFormatString ( psobj *objP, int length, char *valueP );
+extern void objFormatName ( psobj *objP, int length, char *valueP );
+extern void objFormatFile ( psobj *objP, FILE *valueP );
+
+#endif
diff --git a/nx-X11/lib/font/bitmap/Imakefile b/nx-X11/lib/font/bitmap/Imakefile
new file mode 100644
index 000000000..9acbe7796
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/Imakefile
@@ -0,0 +1,71 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:34 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/font/bitmap/Imakefile,v 1.11 2001/04/03 17:51:59 paulo Exp $
+
+#if BuildServer && DoLoadableServer
+#define IHaveSubdirs
+#define NoLibSubdirs
+#define PassCDebugFlags
+SUBDIRS = module
+#endif
+
+BDFSRCS=bdfread.c bdfutils.c
+BDFOBJS=bdfread.o bdfutils.o
+#ifndef KDriveXServer
+BDFDEFS=-DBDFFORMAT
+
+SNFSRCS=snfread.c
+SNFOBJS=snfread.o
+SNFDEFS=-DSNFFORMAT
+#endif
+
+PCFSRCS=pcfread.c pcfwrite.c
+PCFOBJS=pcfread.o pcfwrite.o
+PCFDEFS=-DPCFFORMAT
+
+
+ INCLUDES = -I$(FONTINCSRC) -I../include
+ HEADERS = bdfint.h pcf.h
+#ifdef FontFormatDefines
+ FORMAT_DEFS = FontFormatDefines
+#endif
+#if GzipFontCompression
+ GZIP_DEFS = -DX_GZIP_FONT_COMPRESSION
+#endif
+ DEFINES = $(BDFDEFS) $(PCFDEFS) $(SNFDEFS)
+
+ SRCS = $(BDFSRCS) bitmap.c bitmaputil.c bitscale.c \
+ bitmapfunc.c $(PCFSRCS) $(SNFSRCS) \
+ fontink.c
+
+ OBJS = $(BDFOBJS) bitmap.o bitmaputil.o bitscale.o \
+ bitmapfunc.o $(PCFOBJS) $(SNFOBJS) \
+ fontink.o
+
+#if BuildFontLib
+#define DoNormalLib NormalLibFont
+#define DoSharedLib SharedLibFont
+#define DoDebugLib DebugLibFont
+#define DoProfileLib ProfileLibFont
+#include <Library.tmpl>
+LibraryObjectRule()
+
+SpecialCLibObjectRule(bitmapfunc,$(ICONFIGFILES),$(GZIP_DEFS))
+SpecialCLibObjectRule(bitscale,$(ICONFIGFILES),$(GZIP_DEFS))
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+#endif
+
+#if BuildServer && DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+BuildIncludes($(HEADERS),X11/fonts,../..)
+InstallMultipleFlags($(HEADERS),$(INCDIR)/X11/fonts,$(INSTINCFLAGS))
+
+DependTarget()
diff --git a/nx-X11/lib/font/bitmap/bdfint.h b/nx-X11/lib/font/bitmap/bdfint.h
new file mode 100644
index 000000000..d41c4a556
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/bdfint.h
@@ -0,0 +1,90 @@
+/* $Xorg: bdfint.h,v 1.4 2001/02/09 02:04:01 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.
+
+*/
+/* $XFree86: xc/lib/font/bitmap/bdfint.h,v 1.4 2001/01/17 19:43:26 dawes Exp $ */
+
+#ifndef BDFINT_H
+#define BDFINT_H
+
+#define bdfIsPrefix(buf,str) (!strncmp((char *)buf,str,strlen(str)))
+#define bdfStrEqual(s1,s2) (!strcmp(s1,s2))
+
+#define BDF_GENPROPS 6
+#define NullProperty ((FontPropPtr)0)
+
+/*
+ * This structure holds some properties we need to generate if they aren't
+ * specified in the BDF file and some other values read from the file
+ * that we'll need to calculate them. We need to keep track of whether
+ * or not we've read them.
+ */
+typedef struct BDFSTAT {
+ int linenum;
+ char *fileName;
+ char fontName[MAXFONTNAMELEN];
+ float pointSize;
+ int resolution_x;
+ int resolution_y;
+ int digitCount;
+ int digitWidths;
+ int exHeight;
+
+ FontPropPtr fontProp;
+ FontPropPtr pointSizeProp;
+ FontPropPtr resolutionXProp;
+ FontPropPtr resolutionYProp;
+ FontPropPtr resolutionProp;
+ FontPropPtr xHeightProp;
+ FontPropPtr weightProp;
+ FontPropPtr quadWidthProp;
+ BOOL haveFontAscent;
+ BOOL haveFontDescent;
+ BOOL haveDefaultCh;
+} bdfFileState;
+
+extern void bdfError ( char * message, ... );
+extern void bdfWarning ( char *message, ... );
+extern unsigned char * bdfGetLine ( FontFilePtr file, unsigned char *buf,
+ int len );
+extern Atom bdfForceMakeAtom ( char *str, int *size );
+extern Atom bdfGetPropertyValue ( char *s );
+extern int bdfIsInteger ( char *str );
+extern unsigned char bdfHexByte ( unsigned char *s );
+extern Bool bdfSpecialProperty ( FontPtr pFont, FontPropPtr prop,
+ char isString, bdfFileState *bdfState );
+extern int bdfReadFont( FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan );
+extern int bdfReadFontInfo( FontInfoPtr pFontInfo, FontFilePtr file );
+
+extern void FontCharInkMetrics ( FontPtr pFont, CharInfoPtr pCI,
+ xCharInfo *pInk );
+extern void FontCharReshape ( FontPtr pFont, CharInfoPtr pSrc,
+ CharInfoPtr pDst );
+
+#endif /* BDFINT_H */
diff --git a/nx-X11/lib/font/bitmap/bdfread.c b/nx-X11/lib/font/bitmap/bdfread.c
new file mode 100644
index 000000000..a6f0c1e7e
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/bdfread.c
@@ -0,0 +1,967 @@
+/* $Xorg: bdfread.c,v 1.5 2001/02/09 02:04:01 xorgcvs Exp $ */
+
+/************************************************************************
+Copyright 1989 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.
+
+************************************************************************/
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/bitmap/bdfread.c,v 1.12tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifndef FONTMODULE
+#include <ctype.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/fontutil.h>
+/* use bitmap structure */
+#include <X11/fonts/bitmap.h>
+#include <X11/fonts/bdfint.h>
+
+#if HAVE_STDINT_H
+#include <stdint.h>
+#elif !defined(INT32_MAX)
+#define INT32_MAX 0x7fffffff
+#endif
+
+#define INDICES 256
+#define MAXENCODING 0xFFFF
+#define BDFLINELEN 1024
+
+static Bool bdfPadToTerminal(FontPtr pFont);
+extern int bdfFileLineNum;
+
+/***====================================================================***/
+
+static Bool
+bdfReadBitmap(CharInfoPtr pCI, FontFilePtr file, int bit, int byte,
+ int glyph, int scan, CARD32 *sizes)
+{
+ int widthBits,
+ widthBytes,
+ widthHexChars;
+ int height,
+ row;
+ int i,
+ inLineLen,
+ nextByte;
+ unsigned char *pInBits,
+ *picture,
+ *line = NULL;
+ unsigned char lineBuf[BDFLINELEN];
+
+ widthBits = GLYPHWIDTHPIXELS(pCI);
+ height = GLYPHHEIGHTPIXELS(pCI);
+
+ widthBytes = BYTES_PER_ROW(widthBits, glyph);
+ if (widthBytes * height > 0) {
+ picture = (unsigned char *) xalloc(widthBytes * height);
+ if (!picture) {
+ bdfError("Couldn't allocate picture (%d*%d)\n", widthBytes, height);
+ goto BAILOUT;
+ }
+ } else
+ picture = NULL;
+ pCI->bits = (char *) picture;
+
+ if (sizes) {
+ for (i = 0; i < GLYPHPADOPTIONS; i++)
+ sizes[i] += BYTES_PER_ROW(widthBits, (1 << i)) * height;
+ }
+ nextByte = 0;
+ widthHexChars = BYTES_PER_ROW(widthBits, 1);
+
+/* 5/31/89 (ef) -- hack, hack, hack. what *am* I supposed to do with */
+/* 0 width characters? */
+
+ for (row = 0; row < height; row++) {
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if (!line)
+ break;
+
+ if (widthBits == 0) {
+ if ((!line) || (bdfIsPrefix(line, "ENDCHAR")))
+ break;
+ else
+ continue;
+ }
+ pInBits = line;
+ inLineLen = strlen((char *) pInBits);
+
+ if (inLineLen & 1) {
+ bdfError("odd number of characters in hex encoding\n");
+ line[inLineLen++] = '0';
+ line[inLineLen] = '\0';
+ }
+ inLineLen >>= 1;
+ i = inLineLen;
+ if (i > widthHexChars)
+ i = widthHexChars;
+ for (; i > 0; i--, pInBits += 2)
+ picture[nextByte++] = bdfHexByte(pInBits);
+
+ /* pad if line is too short */
+ if (inLineLen < widthHexChars) {
+ for (i = widthHexChars - inLineLen; i > 0; i--)
+ picture[nextByte++] = 0;
+ } else {
+ unsigned char mask;
+
+ mask = 0xff << (8 - (widthBits & 0x7));
+ if (mask && picture[nextByte - 1] & ~mask) {
+ picture[nextByte - 1] &= mask;
+ }
+ }
+
+ if (widthBytes > widthHexChars) {
+ i = widthBytes - widthHexChars;
+ while (i-- > 0)
+ picture[nextByte++] = 0;
+ }
+ }
+
+ if ((line && (!bdfIsPrefix(line, "ENDCHAR"))) || (height == 0))
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+
+ if ((!line) || (!bdfIsPrefix(line, "ENDCHAR"))) {
+ bdfError("missing 'ENDCHAR'\n");
+ goto BAILOUT;
+ }
+ if (nextByte != height * widthBytes) {
+ bdfError("bytes != rows * bytes_per_row (%d != %d * %d)\n",
+ nextByte, height, widthBytes);
+ goto BAILOUT;
+ }
+ if (picture != NULL) {
+ if (bit == LSBFirst)
+ BitOrderInvert(picture, nextByte);
+ if (bit != byte) {
+ if (scan == 2)
+ TwoByteSwap(picture, nextByte);
+ else if (scan == 4)
+ FourByteSwap(picture, nextByte);
+ }
+ }
+ return (TRUE);
+BAILOUT:
+ if (picture)
+ xfree(picture);
+ pCI->bits = NULL;
+ return (FALSE);
+}
+
+/***====================================================================***/
+
+static Bool
+bdfSkipBitmap(FontFilePtr file, int height)
+{
+ unsigned char *line;
+ int i = 0;
+ unsigned char lineBuf[BDFLINELEN];
+
+ do {
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ i++;
+ } while (line && !bdfIsPrefix(line, "ENDCHAR") && i <= height);
+
+ if (i > 1 && line && !bdfIsPrefix(line, "ENDCHAR")) {
+ bdfError("Error in bitmap, missing 'ENDCHAR'\n");
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+/***====================================================================***/
+
+static void
+bdfFreeFontBits(FontPtr pFont)
+{
+ BitmapFontPtr bitmapFont;
+ BitmapExtraPtr bitmapExtra;
+ int i, nencoding;
+
+ bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
+ bitmapExtra = (BitmapExtraPtr) bitmapFont->bitmapExtra;
+ xfree(bitmapFont->ink_metrics);
+ if(bitmapFont->encoding) {
+ nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
+ (pFont->info.lastRow - pFont->info.firstRow + 1);
+ for(i=0; i<NUM_SEGMENTS(nencoding); i++)
+ xfree(bitmapFont->encoding[i]);
+ }
+ xfree(bitmapFont->encoding);
+ for (i = 0; i < bitmapFont->num_chars; i++)
+ xfree(bitmapFont->metrics[i].bits);
+ xfree(bitmapFont->metrics);
+ if (bitmapExtra)
+ {
+ xfree (bitmapExtra->glyphNames);
+ xfree (bitmapExtra->sWidths);
+ xfree (bitmapExtra);
+ }
+ xfree(pFont->info.props);
+ xfree(bitmapFont);
+}
+
+
+static Bool
+bdfReadCharacters(FontFilePtr file, FontPtr pFont, bdfFileState *pState,
+ int bit, int byte, int glyph, int scan)
+{
+ unsigned char *line;
+ register CharInfoPtr ci;
+ int i,
+ ndx,
+ nchars,
+ nignored;
+ unsigned int char_row, char_col;
+ int numEncodedGlyphs = 0;
+ CharInfoPtr *bdfEncoding[256];
+ BitmapFontPtr bitmapFont;
+ BitmapExtraPtr bitmapExtra;
+ CARD32 *bitmapsSizes;
+ unsigned char lineBuf[BDFLINELEN];
+ int nencoding;
+
+ bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
+ bitmapExtra = (BitmapExtraPtr) bitmapFont->bitmapExtra;
+
+ if (bitmapExtra) {
+ bitmapsSizes = bitmapExtra->bitmapsSizes;
+ for (i = 0; i < GLYPHPADOPTIONS; i++)
+ bitmapsSizes[i] = 0;
+ } else
+ bitmapsSizes = NULL;
+
+ bzero(bdfEncoding, sizeof(bdfEncoding));
+ bitmapFont->metrics = NULL;
+ ndx = 0;
+
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+
+ if ((!line) || (sscanf((char *) line, "CHARS %d", &nchars) != 1)) {
+ bdfError("bad 'CHARS' in bdf file\n");
+ return (FALSE);
+ }
+ if (nchars < 1) {
+ bdfError("invalid number of CHARS in BDF file\n");
+ return (FALSE);
+ }
+ if (nchars > INT32_MAX / sizeof(CharInfoRec)) {
+ bdfError("Couldn't allocate pCI (%d*%d)\n", nchars,
+ sizeof(CharInfoRec));
+ goto BAILOUT;
+ }
+ ci = (CharInfoPtr) xalloc(nchars * sizeof(CharInfoRec));
+ if (!ci) {
+ bdfError("Couldn't allocate pCI (%d*%d)\n", nchars,
+ sizeof(CharInfoRec));
+ goto BAILOUT;
+ }
+ bzero((char *)ci, nchars * sizeof(CharInfoRec));
+ bitmapFont->metrics = ci;
+
+ if (bitmapExtra) {
+ bitmapExtra->glyphNames = (Atom *) xalloc(nchars * sizeof(Atom));
+ if (!bitmapExtra->glyphNames) {
+ bdfError("Couldn't allocate glyphNames (%d*%d)\n",
+ nchars, sizeof(Atom));
+ goto BAILOUT;
+ }
+ }
+ if (bitmapExtra) {
+ bitmapExtra->sWidths = (int *) xalloc(nchars * sizeof(int));
+ if (!bitmapExtra->sWidths) {
+ bdfError("Couldn't allocate sWidth (%d *%d)\n",
+ nchars, sizeof(int));
+ return FALSE;
+ }
+ }
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ pFont->info.firstRow = 256;
+ pFont->info.lastRow = 0;
+ pFont->info.firstCol = 256;
+ pFont->info.lastCol = 0;
+ nignored = 0;
+ for (ndx = 0; (ndx < nchars) && (line) && (bdfIsPrefix(line, "STARTCHAR"));) {
+ int t;
+ int wx; /* x component of width */
+ int wy; /* y component of width */
+ int bw; /* bounding-box width */
+ int bh; /* bounding-box height */
+ int bl; /* bounding-box left */
+ int bb; /* bounding-box bottom */
+ int enc,
+ enc2; /* encoding */
+ unsigned char *p; /* temp pointer into line */
+ char charName[100];
+ int ignore;
+
+ if (sscanf((char *) line, "STARTCHAR %s", charName) != 1) {
+ bdfError("bad character name in BDF file\n");
+ goto BAILOUT; /* bottom of function, free and return error */
+ }
+ if (bitmapExtra)
+ bitmapExtra->glyphNames[ndx] = bdfForceMakeAtom(charName, NULL);
+
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if (!line || (t = sscanf((char *) line, "ENCODING %d %d", &enc, &enc2)) < 1) {
+ bdfError("bad 'ENCODING' in BDF file\n");
+ goto BAILOUT;
+ }
+ if (enc < -1 || (t == 2 && enc2 < -1)) {
+ bdfError("bad ENCODING value");
+ goto BAILOUT;
+ }
+ if (t == 2 && enc == -1)
+ enc = enc2;
+ ignore = 0;
+ if (enc == -1) {
+ if (!bitmapExtra) {
+ nignored++;
+ ignore = 1;
+ }
+ } else if (enc > MAXENCODING) {
+ bdfError("char '%s' has encoding too large (%d)\n",
+ charName, enc);
+ } else {
+ char_row = (enc >> 8) & 0xFF;
+ char_col = enc & 0xFF;
+ if (char_row < pFont->info.firstRow)
+ pFont->info.firstRow = char_row;
+ if (char_row > pFont->info.lastRow)
+ pFont->info.lastRow = char_row;
+ if (char_col < pFont->info.firstCol)
+ pFont->info.firstCol = char_col;
+ if (char_col > pFont->info.lastCol)
+ pFont->info.lastCol = char_col;
+ if (bdfEncoding[char_row] == (CharInfoPtr *) NULL) {
+ bdfEncoding[char_row] =
+ (CharInfoPtr *) xalloc(256 * sizeof(CharInfoPtr));
+ if (!bdfEncoding[char_row]) {
+ bdfError("Couldn't allocate row %d of encoding (%d*%d)\n",
+ char_row, INDICES, sizeof(CharInfoPtr));
+ goto BAILOUT;
+ }
+ for (i = 0; i < 256; i++)
+ bdfEncoding[char_row][i] = (CharInfoPtr) NULL;
+ }
+ if (bdfEncoding[char_row] != NULL) {
+ bdfEncoding[char_row][char_col] = ci;
+ numEncodedGlyphs++;
+ }
+ }
+
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if ((!line) || (sscanf((char *) line, "SWIDTH %d %d", &wx, &wy) != 2)) {
+ bdfError("bad 'SWIDTH'\n");
+ goto BAILOUT;
+ }
+ if (wy != 0) {
+ bdfError("SWIDTH y value must be zero\n");
+ goto BAILOUT;
+ }
+ if (bitmapExtra)
+ bitmapExtra->sWidths[ndx] = wx;
+
+/* 5/31/89 (ef) -- we should be able to ditch the character and recover */
+/* from all of these. */
+
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if ((!line) || (sscanf((char *) line, "DWIDTH %d %d", &wx, &wy) != 2)) {
+ bdfError("bad 'DWIDTH'\n");
+ goto BAILOUT;
+ }
+ if (wy != 0) {
+ bdfError("DWIDTH y value must be zero\n");
+ goto BAILOUT;
+ }
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if ((!line) || (sscanf((char *) line, "BBX %d %d %d %d", &bw, &bh, &bl, &bb) != 4)) {
+ bdfError("bad 'BBX'\n");
+ goto BAILOUT;
+ }
+ if ((bh < 0) || (bw < 0)) {
+ bdfError("character '%s' has a negative sized bitmap, %dx%d\n",
+ charName, bw, bh);
+ goto BAILOUT;
+ }
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if ((line) && (bdfIsPrefix(line, "ATTRIBUTES"))) {
+ for (p = line + strlen("ATTRIBUTES ");
+ (*p == ' ') || (*p == '\t');
+ p++)
+ /* empty for loop */ ;
+ ci->metrics.attributes = (bdfHexByte(p) << 8) + bdfHexByte(p + 2);
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ } else
+ ci->metrics.attributes = 0;
+
+ if (!line || !bdfIsPrefix(line, "BITMAP")) {
+ bdfError("missing 'BITMAP'\n");
+ goto BAILOUT;
+ }
+ /* collect data for generated properties */
+ if ((strlen(charName) == 1)) {
+ if ((charName[0] >= '0') && (charName[0] <= '9')) {
+ pState->digitWidths += wx;
+ pState->digitCount++;
+ } else if (charName[0] == 'x') {
+ pState->exHeight = (bh + bb) <= 0 ? bh : bh + bb;
+ }
+ }
+ if (!ignore) {
+ ci->metrics.leftSideBearing = bl;
+ ci->metrics.rightSideBearing = bl + bw;
+ ci->metrics.ascent = bh + bb;
+ ci->metrics.descent = -bb;
+ ci->metrics.characterWidth = wx;
+ ci->bits = NULL;
+ bdfReadBitmap(ci, file, bit, byte, glyph, scan, bitmapsSizes);
+ ci++;
+ ndx++;
+ } else
+ bdfSkipBitmap(file, bh);
+
+ line = bdfGetLine(file, lineBuf, BDFLINELEN); /* get STARTCHAR or
+ * ENDFONT */
+ }
+
+ if (ndx + nignored != nchars) {
+ bdfError("%d too few characters\n", nchars - (ndx + nignored));
+ goto BAILOUT;
+ }
+ nchars = ndx;
+ bitmapFont->num_chars = nchars;
+ if ((line) && (bdfIsPrefix(line, "STARTCHAR"))) {
+ bdfError("more characters than specified\n");
+ goto BAILOUT;
+ }
+ if ((!line) || (!bdfIsPrefix(line, "ENDFONT"))) {
+ bdfError("missing 'ENDFONT'\n");
+ goto BAILOUT;
+ }
+ if (numEncodedGlyphs == 0)
+ bdfWarning("No characters with valid encodings\n");
+
+ nencoding = (pFont->info.lastRow - pFont->info.firstRow + 1) *
+ (pFont->info.lastCol - pFont->info.firstCol + 1);
+ bitmapFont->encoding =
+ (CharInfoPtr **) xcalloc(NUM_SEGMENTS(nencoding),
+ sizeof(CharInfoPtr*));
+ if (!bitmapFont->encoding) {
+ bdfError("Couldn't allocate ppCI (%d,%d)\n",
+ NUM_SEGMENTS(nencoding),
+ sizeof(CharInfoPtr*));
+ goto BAILOUT;
+ }
+ pFont->info.allExist = TRUE;
+ i = 0;
+ for (char_row = pFont->info.firstRow;
+ char_row <= pFont->info.lastRow;
+ char_row++) {
+ if (bdfEncoding[char_row] == (CharInfoPtr *) NULL) {
+ pFont->info.allExist = FALSE;
+ i += pFont->info.lastCol - pFont->info.firstCol + 1;
+ } else {
+ for (char_col = pFont->info.firstCol;
+ char_col <= pFont->info.lastCol;
+ char_col++) {
+ if (!bdfEncoding[char_row][char_col])
+ pFont->info.allExist = FALSE;
+ else {
+ if (!bitmapFont->encoding[SEGMENT_MAJOR(i)]) {
+ bitmapFont->encoding[SEGMENT_MAJOR(i)]=
+ (CharInfoPtr*)xcalloc(BITMAP_FONT_SEGMENT_SIZE,
+ sizeof(CharInfoPtr));
+ if (!bitmapFont->encoding[SEGMENT_MAJOR(i)])
+ goto BAILOUT;
+ }
+ ACCESSENCODINGL(bitmapFont->encoding,i) =
+ bdfEncoding[char_row][char_col];
+ }
+ i++;
+ }
+ }
+ }
+ for (i = 0; i < 256; i++)
+ if (bdfEncoding[i])
+ xfree(bdfEncoding[i]);
+ return (TRUE);
+BAILOUT:
+ for (i = 0; i < 256; i++)
+ if (bdfEncoding[i])
+ xfree(bdfEncoding[i]);
+ /* bdfFreeFontBits will clean up the rest */
+ return (FALSE);
+}
+
+/***====================================================================***/
+
+static Bool
+bdfReadHeader(FontFilePtr file, bdfFileState *pState)
+{
+ unsigned char *line;
+ char namebuf[BDFLINELEN];
+ unsigned char lineBuf[BDFLINELEN];
+
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if (!line || sscanf((char *) line, "STARTFONT %s", namebuf) != 1 ||
+ !bdfStrEqual(namebuf, "2.1")) {
+ bdfError("bad 'STARTFONT'\n");
+ return (FALSE);
+ }
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if (!line || sscanf((char *) line, "FONT %[^\n]", pState->fontName) != 1) {
+ bdfError("bad 'FONT'\n");
+ return (FALSE);
+ }
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if (!line || !bdfIsPrefix(line, "SIZE")) {
+ bdfError("missing 'SIZE'\n");
+ return (FALSE);
+ }
+ if (sscanf((char *) line, "SIZE %f%d%d", &pState->pointSize,
+ &pState->resolution_x, &pState->resolution_y) != 3) {
+ bdfError("bad 'SIZE'\n");
+ return (FALSE);
+ }
+ if (pState->pointSize < 1 ||
+ pState->resolution_x < 1 || pState->resolution_y < 1) {
+ bdfError("SIZE values must be > 0\n");
+ return (FALSE);
+ }
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if (!line || !bdfIsPrefix(line, "FONTBOUNDINGBOX")) {
+ bdfError("missing 'FONTBOUNDINGBOX'\n");
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+/***====================================================================***/
+
+static Bool
+bdfReadProperties(FontFilePtr file, FontPtr pFont, bdfFileState *pState)
+{
+ int nProps, props_left,
+ nextProp;
+ char *stringProps;
+ FontPropPtr props;
+ char namebuf[BDFLINELEN],
+ secondbuf[BDFLINELEN],
+ thirdbuf[BDFLINELEN];
+ unsigned char *line;
+ unsigned char lineBuf[BDFLINELEN];
+ BitmapFontPtr bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
+
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if (!line || !bdfIsPrefix(line, "STARTPROPERTIES")) {
+ bdfError("missing 'STARTPROPERTIES'\n");
+ return (FALSE);
+ }
+ if (sscanf((char *) line, "STARTPROPERTIES %d", &nProps) != 1) {
+ bdfError("bad 'STARTPROPERTIES'\n");
+ return (FALSE);
+ }
+ pFont->info.isStringProp = NULL;
+ pFont->info.props = NULL;
+ pFont->info.nprops = 0;
+
+ stringProps = (char *) xalloc((nProps + BDF_GENPROPS) * sizeof(char));
+ pFont->info.isStringProp = stringProps;
+ if (stringProps == NULL) {
+ bdfError("Couldn't allocate stringProps (%d*%d)\n",
+ (nProps + BDF_GENPROPS), sizeof(Bool));
+ goto BAILOUT;
+ }
+ pFont->info.props = props = (FontPropPtr) xalloc((nProps + BDF_GENPROPS) *
+ sizeof(FontPropRec));
+ if (props == NULL) {
+ bdfError("Couldn't allocate props (%d*%d)\n", nProps + BDF_GENPROPS,
+ sizeof(FontPropRec));
+ goto BAILOUT;
+ }
+ bzero((char *)props, (nProps + BDF_GENPROPS) * sizeof(FontPropRec));
+
+ nextProp = 0;
+ props_left = nProps;
+ while (props_left-- > 0) {
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if (line == NULL || bdfIsPrefix(line, "ENDPROPERTIES")) {
+ bdfError("\"STARTPROPERTIES %d\" followed by only %d properties\n",
+ nProps, nProps - props_left - 1);
+ goto BAILOUT;
+ }
+ while (*line && isspace(*line))
+ line++;
+
+ switch (sscanf((char *) line, "%s%s%s", namebuf, secondbuf, thirdbuf)) {
+ default:
+ bdfError("missing '%s' parameter value\n", namebuf);
+ goto BAILOUT;
+
+ case 2:
+ /*
+ * Possibilites include: valid quoted string with no white space
+ * valid integer value invalid value
+ */
+ if (secondbuf[0] == '"') {
+ stringProps[nextProp] = TRUE;
+ props[nextProp].value =
+ bdfGetPropertyValue((char *)line + strlen(namebuf) + 1);
+ if (!props[nextProp].value)
+ goto BAILOUT;
+ break;
+ } else if (bdfIsInteger(secondbuf)) {
+ stringProps[nextProp] = FALSE;
+ props[nextProp].value = atoi(secondbuf);
+ break;
+ } else {
+ bdfError("invalid '%s' parameter value\n", namebuf);
+ goto BAILOUT;
+ }
+
+ case 3:
+ /*
+ * Possibilites include: valid quoted string with some white space
+ * invalid value (reject even if second string is integer)
+ */
+ if (secondbuf[0] == '"') {
+ stringProps[nextProp] = TRUE;
+ props[nextProp].value =
+ bdfGetPropertyValue((char *)line + strlen(namebuf) + 1);
+ if (!props[nextProp].value)
+ goto BAILOUT;
+ break;
+ } else {
+ bdfError("invalid '%s' parameter value\n", namebuf);
+ goto BAILOUT;
+ }
+ }
+ props[nextProp].name = bdfForceMakeAtom(namebuf, NULL);
+ if (props[nextProp].name == None) {
+ bdfError("Empty property name.\n");
+ goto BAILOUT;
+ }
+ if (!bdfSpecialProperty(pFont, &props[nextProp],
+ stringProps[nextProp], pState))
+ nextProp++;
+ }
+
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if (!line || !bdfIsPrefix(line, "ENDPROPERTIES")) {
+ bdfError("missing 'ENDPROPERTIES'\n");
+ goto BAILOUT;
+ }
+ if (!pState->haveFontAscent || !pState->haveFontDescent) {
+ bdfError("missing 'FONT_ASCENT' or 'FONT_DESCENT' properties\n");
+ goto BAILOUT;
+ }
+ if (bitmapFont->bitmapExtra) {
+ bitmapFont->bitmapExtra->info.fontAscent = pFont->info.fontAscent;
+ bitmapFont->bitmapExtra->info.fontDescent = pFont->info.fontDescent;
+ }
+ if (!pState->pointSizeProp) {
+ props[nextProp].name = bdfForceMakeAtom("POINT_SIZE", NULL);
+ props[nextProp].value = (INT32) (pState->pointSize * 10.0);
+ stringProps[nextProp] = FALSE;
+ pState->pointSizeProp = &props[nextProp];
+ nextProp++;
+ }
+ if (!pState->fontProp) {
+ props[nextProp].name = bdfForceMakeAtom("FONT", NULL);
+ props[nextProp].value = (INT32) bdfForceMakeAtom(pState->fontName, NULL);
+ stringProps[nextProp] = TRUE;
+ pState->fontProp = &props[nextProp];
+ nextProp++;
+ }
+ if (!pState->weightProp) {
+ props[nextProp].name = bdfForceMakeAtom("WEIGHT", NULL);
+ props[nextProp].value = -1; /* computed later */
+ stringProps[nextProp] = FALSE;
+ pState->weightProp = &props[nextProp];
+ nextProp++;
+ }
+ if (!pState->resolutionProp &&
+ pState->resolution_x == pState->resolution_y) {
+ props[nextProp].name = bdfForceMakeAtom("RESOLUTION", NULL);
+ props[nextProp].value = (INT32) ((pState->resolution_x * 100.0) / 72.27);
+ stringProps[nextProp] = FALSE;
+ pState->resolutionProp = &props[nextProp];
+ nextProp++;
+ }
+ if (!pState->resolutionXProp) {
+ props[nextProp].name = bdfForceMakeAtom("RESOLUTION_X", NULL);
+ props[nextProp].value = (INT32) pState->resolution_x;
+ stringProps[nextProp] = FALSE;
+ pState->resolutionProp = &props[nextProp];
+ nextProp++;
+ }
+ if (!pState->resolutionYProp) {
+ props[nextProp].name = bdfForceMakeAtom("RESOLUTION_Y", NULL);
+ props[nextProp].value = (INT32) pState->resolution_y;
+ stringProps[nextProp] = FALSE;
+ pState->resolutionProp = &props[nextProp];
+ nextProp++;
+ }
+ if (!pState->xHeightProp) {
+ props[nextProp].name = bdfForceMakeAtom("X_HEIGHT", NULL);
+ props[nextProp].value = -1; /* computed later */
+ stringProps[nextProp] = FALSE;
+ pState->xHeightProp = &props[nextProp];
+ nextProp++;
+ }
+ if (!pState->quadWidthProp) {
+ props[nextProp].name = bdfForceMakeAtom("QUAD_WIDTH", NULL);
+ props[nextProp].value = -1; /* computed later */
+ stringProps[nextProp] = FALSE;
+ pState->quadWidthProp = &props[nextProp];
+ nextProp++;
+ }
+ pFont->info.nprops = nextProp;
+ return (TRUE);
+BAILOUT:
+ if (pFont->info.isStringProp) {
+ xfree(pFont->info.isStringProp);
+ pFont->info.isStringProp = NULL;
+ }
+ if (pFont->info.props) {
+ xfree(pFont->info.props);
+ pFont->info.props = NULL;
+ }
+ while (line && bdfIsPrefix(line, "ENDPROPERTIES"))
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ return (FALSE);
+}
+
+/***====================================================================***/
+
+static void
+bdfUnloadFont(FontPtr pFont)
+{
+ bdfFreeFontBits (pFont);
+ DestroyFontRec(pFont);
+}
+
+int
+bdfReadFont(FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan)
+{
+ bdfFileState state;
+ xCharInfo *min,
+ *max;
+ BitmapFontPtr bitmapFont;
+
+ pFont->fontPrivate = 0;
+
+ bzero(&state, sizeof(bdfFileState));
+ bdfFileLineNum = 0;
+
+ if (!bdfReadHeader(file, &state))
+ goto BAILOUT;
+
+ bitmapFont = (BitmapFontPtr) xalloc(sizeof(BitmapFontRec));
+ if (!bitmapFont) {
+ bdfError("Couldn't allocate bitmapFontRec (%d)\n", sizeof(BitmapFontRec));
+ goto BAILOUT;
+ }
+ bzero((char *)bitmapFont, sizeof(BitmapFontRec));
+
+ pFont->fontPrivate = (pointer) bitmapFont;
+ bitmapFont->metrics = 0;
+ bitmapFont->ink_metrics = 0;
+ bitmapFont->bitmaps = 0;
+ bitmapFont->encoding = 0;
+ bitmapFont->pDefault = NULL;
+
+ bitmapFont->bitmapExtra = (BitmapExtraPtr) xalloc(sizeof(BitmapExtraRec));
+ if (!bitmapFont->bitmapExtra) {
+ bdfError("Couldn't allocate bitmapExtra (%d)\n", sizeof(BitmapExtraRec));
+ goto BAILOUT;
+ }
+ bzero((char *)bitmapFont->bitmapExtra, sizeof(BitmapExtraRec));
+
+ bitmapFont->bitmapExtra->glyphNames = 0;
+ bitmapFont->bitmapExtra->sWidths = 0;
+
+ if (!bdfReadProperties(file, pFont, &state))
+ goto BAILOUT;
+
+ if (!bdfReadCharacters(file, pFont, &state, bit, byte, glyph, scan))
+ goto BAILOUT;
+
+ if (state.haveDefaultCh) {
+ unsigned int r, c, cols;
+
+ r = pFont->info.defaultCh >> 8;
+ c = pFont->info.defaultCh & 0xFF;
+ if (pFont->info.firstRow <= r && r <= pFont->info.lastRow &&
+ pFont->info.firstCol <= c && c <= pFont->info.lastCol) {
+ cols = pFont->info.lastCol - pFont->info.firstCol + 1;
+ r = r - pFont->info.firstRow;
+ c = c - pFont->info.firstCol;
+ bitmapFont->pDefault = ACCESSENCODING(bitmapFont->encoding,
+ r * cols + c);
+ }
+ }
+ pFont->bit = bit;
+ pFont->byte = byte;
+ pFont->glyph = glyph;
+ pFont->scan = scan;
+ pFont->info.anamorphic = FALSE;
+ pFont->info.cachable = TRUE;
+ bitmapComputeFontBounds(pFont);
+ if (FontCouldBeTerminal(&pFont->info)) {
+ bdfPadToTerminal(pFont);
+ bitmapComputeFontBounds(pFont);
+ }
+ FontComputeInfoAccelerators(&pFont->info);
+ if (bitmapFont->bitmapExtra)
+ FontComputeInfoAccelerators(&bitmapFont->bitmapExtra->info);
+ if (pFont->info.constantMetrics) {
+ if (!bitmapAddInkMetrics(pFont)) {
+ bdfError("Failed to add bitmap ink metrics\n");
+ goto BAILOUT;
+ }
+ }
+ if (bitmapFont->bitmapExtra)
+ bitmapFont->bitmapExtra->info.inkMetrics = pFont->info.inkMetrics;
+
+ bitmapComputeFontInkBounds(pFont);
+/* ComputeFontAccelerators (pFont); */
+
+ /* generate properties */
+ min = &pFont->info.ink_minbounds;
+ max = &pFont->info.ink_maxbounds;
+ if (state.xHeightProp && (state.xHeightProp->value == -1))
+ state.xHeightProp->value = state.exHeight ?
+ state.exHeight : min->ascent;
+
+ if (state.quadWidthProp && (state.quadWidthProp->value == -1))
+ state.quadWidthProp->value = state.digitCount ?
+ (INT32) (state.digitWidths / state.digitCount) :
+ (min->characterWidth + max->characterWidth) / 2;
+
+ if (state.weightProp && (state.weightProp->value == -1))
+ state.weightProp->value = bitmapComputeWeight(pFont);
+
+ pFont->get_glyphs = bitmapGetGlyphs;
+ pFont->get_metrics = bitmapGetMetrics;
+ pFont->unload_font = bdfUnloadFont;
+ pFont->unload_glyphs = NULL;
+ return Successful;
+BAILOUT:
+ if (pFont->fontPrivate)
+ bdfFreeFontBits (pFont);
+ return AllocError;
+}
+
+int
+bdfReadFontInfo(FontInfoPtr pFontInfo, FontFilePtr file)
+{
+ FontRec font;
+ int ret;
+
+ bzero(&font, sizeof (FontRec));
+
+ ret = bdfReadFont(&font, file, MSBFirst, LSBFirst, 1, 1);
+ if (ret == Successful) {
+ *pFontInfo = font.info;
+ font.info.props = 0;
+ font.info.isStringProp = 0;
+ font.info.nprops = 0;
+ bdfFreeFontBits (&font);
+ }
+ return ret;
+}
+
+static Bool
+bdfPadToTerminal(FontPtr pFont)
+{
+ BitmapFontPtr bitmapFont;
+ BitmapExtraPtr bitmapExtra;
+ int i;
+ int new_size;
+ CharInfoRec new;
+ int w,
+ h;
+
+ bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
+
+ bzero(&new, sizeof(CharInfoRec));
+ new.metrics.ascent = pFont->info.fontAscent;
+ new.metrics.descent = pFont->info.fontDescent;
+ new.metrics.leftSideBearing = 0;
+ new.metrics.rightSideBearing = pFont->info.minbounds.characterWidth;
+ new.metrics.characterWidth = new.metrics.rightSideBearing;
+ new_size = BYTES_FOR_GLYPH(&new, pFont->glyph);
+
+ for (i = 0; i < bitmapFont->num_chars; i++) {
+ new.bits = (char *) xalloc(new_size);
+ if (!new.bits) {
+ bdfError("Couldn't allocate bits (%d)\n", new_size);
+ return FALSE;
+ }
+ FontCharReshape(pFont, &bitmapFont->metrics[i], &new);
+ new.metrics.attributes = bitmapFont->metrics[i].metrics.attributes;
+ xfree(bitmapFont->metrics[i].bits);
+ bitmapFont->metrics[i] = new;
+ }
+ bitmapExtra = bitmapFont->bitmapExtra;
+ if (bitmapExtra) {
+ w = GLYPHWIDTHPIXELS(&new);
+ h = GLYPHHEIGHTPIXELS(&new);
+ for (i = 0; i < GLYPHPADOPTIONS; i++)
+ bitmapExtra->bitmapsSizes[i] = bitmapFont->num_chars *
+ (BYTES_PER_ROW(w, 1 << i) * h);
+ }
+ return TRUE;
+}
diff --git a/nx-X11/lib/font/bitmap/bdfutils.c b/nx-X11/lib/font/bitmap/bdfutils.c
new file mode 100644
index 000000000..a0c5ae949
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/bdfutils.c
@@ -0,0 +1,340 @@
+/* $Xorg: bdfutils.c,v 1.5 2001/02/09 02:04:02 xorgcvs Exp $ */
+/************************************************************************
+Copyright 1989 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.
+
+************************************************************************/
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/bitmap/bdfutils.c,v 1.10 2001/12/14 19:56:45 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifndef FONTMODULE
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+#endif
+
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/fontstruct.h>
+/* use bitmap structure */
+#include <X11/fonts/bitmap.h>
+#include <X11/fonts/bdfint.h>
+
+int bdfFileLineNum;
+
+/***====================================================================***/
+
+void
+bdfError(char* message, ...)
+{
+ va_list args;
+
+ va_start (args, message);
+ fprintf(stderr, "BDF Error on line %d: ", bdfFileLineNum);
+ vfprintf(stderr, message, args);
+ va_end (args);
+}
+
+/***====================================================================***/
+
+void
+bdfWarning(char *message, ...)
+{
+ va_list args;
+
+ va_start (args, message);
+ fprintf(stderr, "BDF Warning on line %d: ", bdfFileLineNum);
+ vfprintf(stderr, message, args);
+ va_end (args);
+}
+
+/*
+ * read the next (non-comment) line and keep a count for error messages.
+ * Returns buf, or NULL if EOF.
+ */
+
+unsigned char *
+bdfGetLine(FontFilePtr file, unsigned char *buf, int len)
+{
+ int c;
+ unsigned char *b;
+
+ for (;;) {
+ b = buf;
+ while ((c = FontFileGetc(file)) != FontFileEOF) {
+ if (c == '\r')
+ continue;
+ if (c == '\n') {
+ bdfFileLineNum++;
+ break;
+ }
+ if (b - buf >= (len - 1))
+ break;
+ *b++ = c;
+ }
+ *b = '\0';
+ if (c == FontFileEOF)
+ return NULL;
+ if (b != buf && !bdfIsPrefix(buf, "COMMENT"))
+ break;
+ }
+ return buf;
+}
+
+/***====================================================================***/
+
+Atom
+bdfForceMakeAtom(char *str, int *size)
+{
+ register int len = strlen(str);
+ Atom the_atom;
+
+ if (size != NULL)
+ *size += len + 1;
+ the_atom = MakeAtom(str, len, TRUE);
+ if (the_atom == None)
+ bdfError("Atom allocation failed\n");
+ return the_atom;
+}
+
+/***====================================================================***/
+
+/*
+ * Handle quoted strings.
+ */
+
+Atom
+bdfGetPropertyValue(char *s)
+{
+ register char *p,
+ *pp;
+ char *orig_s = s;
+ Atom atom;
+
+ /* strip leading white space */
+ while (*s && (*s == ' ' || *s == '\t'))
+ s++;
+ if (*s == 0) {
+ return bdfForceMakeAtom(s, NULL);
+ }
+ if (*s != '"') {
+ pp = s;
+ /* no white space in value */
+ for (pp = s; *pp; pp++)
+ if (*pp == ' ' || *pp == '\t' || *pp == '\015' || *pp == '\n') {
+ *pp = 0;
+ break;
+ }
+ return bdfForceMakeAtom(s, NULL);
+ }
+ /* quoted string: strip outer quotes and undouble inner quotes */
+ s++;
+ pp = p = (char *) xalloc((unsigned) strlen(s) + 1);
+ if (pp == NULL) {
+ bdfError("Couldn't allocate property value string (%d)\n", strlen(s) + 1);
+ return None;
+ }
+ while (*s) {
+ if (*s == '"') {
+ if (*(s + 1) != '"') {
+ *p++ = 0;
+ atom = bdfForceMakeAtom(pp, NULL);
+ xfree(pp);
+ return atom;
+ } else {
+ s++;
+ }
+ }
+ *p++ = *s++;
+ }
+ xfree (pp);
+ bdfError("unterminated quoted string property: %s\n", (pointer) orig_s);
+ return None;
+}
+
+/***====================================================================***/
+
+/*
+ * return TRUE if string is a valid integer
+ */
+int
+bdfIsInteger(char *str)
+{
+ char c;
+
+ c = *str++;
+ if (!(isdigit(c) || c == '-' || c == '+'))
+ return (FALSE);
+
+ while ((c = *str++))
+ if (!isdigit(c))
+ return (FALSE);
+
+ return (TRUE);
+}
+
+/***====================================================================***/
+
+/*
+ * make a byte from the first two hex characters in glyph picture
+ */
+
+unsigned char
+bdfHexByte(unsigned char *s)
+{
+ unsigned char b = 0;
+ register char c;
+ int i;
+
+ for (i = 2; i; i--) {
+ c = *s++;
+ if ((c >= '0') && (c <= '9'))
+ b = (b << 4) + (c - '0');
+ else if ((c >= 'A') && (c <= 'F'))
+ b = (b << 4) + 10 + (c - 'A');
+ else if ((c >= 'a') && (c <= 'f'))
+ b = (b << 4) + 10 + (c - 'a');
+ else
+ bdfError("bad hex char '%c'", c);
+ }
+ return b;
+}
+
+/***====================================================================***/
+
+/*
+ * check for known special property values
+ */
+
+static char *SpecialAtoms[] = {
+ "FONT_ASCENT",
+#define BDF_FONT_ASCENT 0
+ "FONT_DESCENT",
+#define BDF_FONT_DESCENT 1
+ "DEFAULT_CHAR",
+#define BDF_DEFAULT_CHAR 2
+ "POINT_SIZE",
+#define BDF_POINT_SIZE 3
+ "RESOLUTION",
+#define BDF_RESOLUTION 4
+ "X_HEIGHT",
+#define BDF_X_HEIGHT 5
+ "WEIGHT",
+#define BDF_WEIGHT 6
+ "QUAD_WIDTH",
+#define BDF_QUAD_WIDTH 7
+ "FONT",
+#define BDF_FONT 8
+ "RESOLUTION_X",
+#define BDF_RESOLUTION_X 9
+ "RESOLUTION_Y",
+#define BDF_RESOLUTION_Y 10
+ 0,
+};
+
+Bool
+bdfSpecialProperty(FontPtr pFont, FontPropPtr prop,
+ char isString, bdfFileState *bdfState)
+{
+ char **special;
+ char *name;
+
+ name = NameForAtom(prop->name);
+ for (special = SpecialAtoms; *special; special++)
+ if (!strcmp(name, *special))
+ break;
+
+ switch (special - SpecialAtoms) {
+ case BDF_FONT_ASCENT:
+ if (!isString) {
+ pFont->info.fontAscent = prop->value;
+ bdfState->haveFontAscent = TRUE;
+ }
+ return TRUE;
+ case BDF_FONT_DESCENT:
+ if (!isString) {
+ pFont->info.fontDescent = prop->value;
+ bdfState->haveFontDescent = TRUE;
+ }
+ return TRUE;
+ case BDF_DEFAULT_CHAR:
+ if (!isString) {
+ pFont->info.defaultCh = prop->value;
+ bdfState->haveDefaultCh = TRUE;
+ }
+ return TRUE;
+ case BDF_POINT_SIZE:
+ bdfState->pointSizeProp = prop;
+ return FALSE;
+ case BDF_RESOLUTION:
+ bdfState->resolutionProp = prop;
+ return FALSE;
+ case BDF_X_HEIGHT:
+ bdfState->xHeightProp = prop;
+ return FALSE;
+ case BDF_WEIGHT:
+ bdfState->weightProp = prop;
+ return FALSE;
+ case BDF_QUAD_WIDTH:
+ bdfState->quadWidthProp = prop;
+ return FALSE;
+ case BDF_FONT:
+ bdfState->fontProp = prop;
+ return FALSE;
+ case BDF_RESOLUTION_X:
+ bdfState->resolutionXProp = prop;
+ return FALSE;
+ case BDF_RESOLUTION_Y:
+ bdfState->resolutionYProp = prop;
+ return FALSE;
+ default:
+ return FALSE;
+ }
+}
diff --git a/nx-X11/lib/font/bitmap/bitmap.c b/nx-X11/lib/font/bitmap/bitmap.c
new file mode 100644
index 000000000..d238f4d30
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/bitmap.c
@@ -0,0 +1,160 @@
+/* $Xorg: bitmap.c,v 1.4 2001/02/09 02:04:02 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/bitmap/bitmap.c,v 1.6 2001/01/17 19:43:27 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/bitmap.h>
+
+int
+bitmapGetGlyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
+{
+ BitmapFontPtr bitmapFont;
+ unsigned int firstCol;
+ register unsigned int numCols;
+ unsigned int firstRow;
+ unsigned int numRows;
+ CharInfoPtr *glyphsBase;
+ register unsigned int c;
+ register CharInfoPtr pci;
+ unsigned int r;
+ CharInfoPtr **encoding;
+ CharInfoPtr pDefault;
+
+ bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
+ encoding = bitmapFont->encoding;
+ pDefault = bitmapFont->pDefault;
+ firstCol = pFont->info.firstCol;
+ numCols = pFont->info.lastCol - firstCol + 1;
+ glyphsBase = glyphs;
+ switch (charEncoding) {
+
+ case Linear8Bit:
+ case TwoD8Bit:
+ if (pFont->info.firstRow > 0)
+ break;
+ if (pFont->info.allExist && pDefault) {
+ while (count--) {
+ c = (*chars++) - firstCol;
+ if (c < numCols)
+ *glyphs++ = ACCESSENCODING(encoding,c);
+ else
+ *glyphs++ = pDefault;
+ }
+ } else {
+ while (count--) {
+ c = (*chars++) - firstCol;
+ if (c < numCols && (pci = ACCESSENCODING(encoding,c)))
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ }
+ break;
+ case Linear16Bit:
+ if (pFont->info.allExist && pDefault) {
+ while (count--) {
+ c = *chars++ << 8;
+ c = (c | *chars++) - firstCol;
+ if (c < numCols)
+ *glyphs++ = ACCESSENCODING(encoding,c);
+ else
+ *glyphs++ = pDefault;
+ }
+ } else {
+ while (count--) {
+ c = *chars++ << 8;
+ c = (c | *chars++) - firstCol;
+ if (c < numCols && (pci = ACCESSENCODING(encoding,c)))
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ }
+ break;
+
+ case TwoD16Bit:
+ firstRow = pFont->info.firstRow;
+ numRows = pFont->info.lastRow - firstRow + 1;
+ while (count--) {
+ r = (*chars++) - firstRow;
+ c = (*chars++) - firstCol;
+ if (r < numRows && c < numCols &&
+ (pci = ACCESSENCODING(encoding, r * numCols + c)))
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ }
+ *glyphCount = glyphs - glyphsBase;
+ return Successful;
+}
+
+static CharInfoRec nonExistantChar;
+
+int
+bitmapGetMetrics(FontPtr pFont, unsigned long count, unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ xCharInfo **glyphs) /* RETURN */
+{
+ int ret;
+ xCharInfo *ink_metrics;
+ CharInfoPtr metrics;
+ BitmapFontPtr bitmapFont;
+ CharInfoPtr oldDefault;
+ int i;
+
+ bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
+ oldDefault = bitmapFont->pDefault;
+ bitmapFont->pDefault = &nonExistantChar;
+ ret = bitmapGetGlyphs(pFont, count, chars, charEncoding, glyphCount, (CharInfoPtr *) glyphs);
+ if (ret == Successful) {
+ if (bitmapFont->ink_metrics) {
+ metrics = bitmapFont->metrics;
+ ink_metrics = bitmapFont->ink_metrics;
+ for (i = 0; i < *glyphCount; i++) {
+ if (glyphs[i] != (xCharInfo *) & nonExistantChar)
+ glyphs[i] = ink_metrics + (((CharInfoPtr) glyphs[i]) - metrics);
+ }
+ }
+ }
+ bitmapFont->pDefault = oldDefault;
+ return ret;
+}
diff --git a/nx-X11/lib/font/bitmap/bitmapfunc.c b/nx-X11/lib/font/bitmap/bitmapfunc.c
new file mode 100644
index 000000000..e6187e5ee
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/bitmapfunc.c
@@ -0,0 +1,240 @@
+/* $Xorg: bitmapfunc.c,v 1.5 2001/02/09 02:04:02 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+
+/* $XFree86: xc/lib/font/bitmap/bitmapfunc.c,v 3.17 2002/09/19 13:21:58 tsi Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/*
+ * Translate monolithic #defines to modular definitions
+ */
+
+#ifdef PCFFORMAT
+#define XFONT_PCFFORMAT 1
+#endif
+
+#ifdef SNFFORMAT
+#define XFONT_SNFFORMAT 1
+#endif
+
+#ifdef BDFFORMAT
+#define XFONT_BDFFORMAT 1
+#endif
+
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/bitmap.h>
+#include <X11/fonts/fontutil.h>
+#include <X11/fonts/bdfint.h>
+#include <X11/fonts/pcf.h>
+#include "snfstr.h"
+
+typedef struct _BitmapFileFunctions {
+ int (*ReadFont) (FontPtr /* pFont */, FontFilePtr /* file */,
+ int /* bit */, int /* byte */,
+ int /* glyph */, int /* scan */);
+ int (*ReadInfo) ( FontInfoPtr /* pFontInfo */,
+ FontFilePtr /* file */ );
+} BitmapFileFunctionsRec, *BitmapFileFunctionsPtr;
+
+
+/*
+ * the readers[] and renderers[] arrays must be in the same order,
+ * and also in the same order as scale[] and find_scale[] in bitscale.c
+ *
+ */
+static BitmapFileFunctionsRec readers[] = {
+#if XFONT_PCFFORMAT
+ { pcfReadFont, pcfReadFontInfo} ,
+ { pcfReadFont, pcfReadFontInfo} ,
+#ifdef X_GZIP_FONT_COMPRESSION
+ { pcfReadFont, pcfReadFontInfo} ,
+#endif
+#endif
+#if XFONT_SNFFORMAT
+ { snfReadFont, snfReadFontInfo},
+ { snfReadFont, snfReadFontInfo},
+#ifdef X_GZIP_FONT_COMPRESSION
+ { snfReadFont, snfReadFontInfo} ,
+#endif
+#endif
+#if XFONT_BDFFORMAT
+ { bdfReadFont, bdfReadFontInfo} ,
+ { bdfReadFont, bdfReadFontInfo} ,
+#ifdef X_GZIP_FONT_COMPRESSION
+ { bdfReadFont, bdfReadFontInfo} ,
+#endif
+#endif
+#if XFONT_PCFFORMAT
+ { pmfReadFont, pcfReadFontInfo} ,
+#endif
+};
+
+
+#define CAPABILITIES (CAP_MATRIX | CAP_CHARSUBSETTING)
+
+static FontRendererRec renderers[] = {
+#if XFONT_PCFFORMAT
+ { ".pcf", 4, BitmapOpenBitmap, BitmapOpenScalable,
+ BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
+ CAPABILITIES },
+ { ".pcf.Z", 6, BitmapOpenBitmap, BitmapOpenScalable,
+ BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
+ CAPABILITIES },
+#ifdef X_GZIP_FONT_COMPRESSION
+ { ".pcf.gz", 7,
+ BitmapOpenBitmap, BitmapOpenScalable,
+ BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
+ CAPABILITIES },
+#endif
+#endif
+#if XFONT_SNFFORMAT
+ { ".snf", 4, BitmapOpenBitmap, BitmapOpenScalable,
+ BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
+ CAPABILITIES },
+ { ".snf.Z", 6, BitmapOpenBitmap, BitmapOpenScalable,
+ BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
+ CAPABILITIES },
+#ifdef X_GZIP_FONT_COMPRESSION
+ { ".snf.gz", 7, BitmapOpenBitmap, BitmapOpenScalable,
+ BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
+ CAPABILITIES },
+#endif
+#endif
+#if XFONT_BDFFORMAT
+ { ".bdf", 4, BitmapOpenBitmap, BitmapOpenScalable,
+ BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
+ CAPABILITIES },
+ { ".bdf.Z", 6, BitmapOpenBitmap, BitmapOpenScalable,
+ BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
+ CAPABILITIES },
+#ifdef X_GZIP_FONT_COMPRESSION
+ { ".bdf.gz", 7, BitmapOpenBitmap, BitmapOpenScalable,
+ BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
+ CAPABILITIES },
+#endif
+#endif
+#if XFONT_PCFFORMAT
+ { ".pmf", 4, BitmapOpenBitmap, BitmapOpenScalable,
+ BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
+ CAPABILITIES }
+#endif
+};
+
+int
+BitmapOpenBitmap (FontPathElementPtr fpe, FontPtr *ppFont, int flags,
+ FontEntryPtr entry, char *fileName,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font) /* We don't do licensing */
+{
+ FontFilePtr file;
+ FontPtr pFont;
+ int i;
+ int ret;
+ int bit,
+ byte,
+ glyph,
+ scan,
+ image;
+
+ i = BitmapGetRenderIndex(entry->u.bitmap.renderer);
+ file = FontFileOpen (fileName);
+ if (!file)
+ return BadFontName;
+ if (!(pFont = CreateFontRec())) {
+ fprintf(stderr, "Error: Couldn't allocate pFont (%ld)\n",
+ (unsigned long)sizeof(FontRec));
+ FontFileClose (file);
+ return AllocError;
+ }
+ /* set up default values */
+ FontDefaultFormat(&bit, &byte, &glyph, &scan);
+ /* get any changes made from above */
+ ret = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);
+
+ /* Fill in font record. Data format filled in by reader. */
+ pFont->refcnt = 0;
+
+ ret = (*readers[i].ReadFont) (pFont, file, bit, byte, glyph, scan);
+
+ FontFileClose (file);
+ if (ret != Successful) {
+ xfree(pFont);
+ } else {
+ *ppFont = pFont;
+ }
+ return ret;
+}
+
+int
+BitmapGetInfoBitmap (FontPathElementPtr fpe, FontInfoPtr pFontInfo,
+ FontEntryPtr entry, char *fileName)
+{
+ FontFilePtr file;
+ int i;
+ int ret;
+ FontRendererPtr renderer;
+
+ renderer = FontFileMatchRenderer (fileName);
+ if (!renderer)
+ return BadFontName;
+ i = BitmapGetRenderIndex(renderer);
+ file = FontFileOpen (fileName);
+ if (!file)
+ return BadFontName;
+ ret = (*readers[i].ReadInfo) (pFontInfo, file);
+ FontFileClose (file);
+ return ret;
+}
+
+#define numRenderers (sizeof renderers / sizeof renderers[0])
+
+void
+BitmapRegisterFontFileFunctions (void)
+{
+ int i;
+
+ for (i = 0; i < numRenderers; i++)
+ FontFileRegisterRenderer (&renderers[i]);
+}
+
+/*
+ * compute offset into renderers array - used to find the font reader,
+ * the font info reader, and the bitmap scaling routine. All users
+ * of this routine must be kept in step with the renderer array.
+ */
+int
+BitmapGetRenderIndex(FontRendererPtr renderer)
+{
+ return renderer - renderers;
+}
diff --git a/nx-X11/lib/font/bitmap/bitmaputil.c b/nx-X11/lib/font/bitmap/bitmaputil.c
new file mode 100644
index 000000000..3487f7f92
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/bitmaputil.c
@@ -0,0 +1,232 @@
+/* $Xorg: bitmaputil.c,v 1.5 2001/02/09 02:04:02 xorgcvs Exp $ */
+
+/*
+
+Copyright 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.
+
+*/
+/* $XFree86: xc/lib/font/bitmap/bitmaputil.c,v 1.10 2002/09/24 20:52:48 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/bitmap.h>
+#include <X11/fonts/bdfint.h>
+
+#ifndef MAXSHORT
+#define MAXSHORT 32767
+#endif
+
+#ifndef MINSHORT
+#define MINSHORT -32768
+#endif
+
+static xCharInfo initMinMetrics = {
+MAXSHORT, MAXSHORT, MAXSHORT, MAXSHORT, MAXSHORT, 0xFFFF};
+static xCharInfo initMaxMetrics = {
+MINSHORT, MINSHORT, MINSHORT, MINSHORT, MINSHORT, 0x0000};
+
+#define MINMAX(field,ci) \
+ if (minbounds->field > (ci)->field) \
+ minbounds->field = (ci)->field; \
+ if (maxbounds->field < (ci)->field) \
+ maxbounds->field = (ci)->field;
+
+#define COMPUTE_MINMAX(ci) \
+ if ((ci)->ascent || (ci)->descent || \
+ (ci)->leftSideBearing || (ci)->rightSideBearing || \
+ (ci)->characterWidth) \
+ { \
+ MINMAX(ascent, (ci)); \
+ MINMAX(descent, (ci)); \
+ MINMAX(leftSideBearing, (ci)); \
+ MINMAX(rightSideBearing, (ci)); \
+ MINMAX(characterWidth, (ci)); \
+ }
+
+void
+bitmapComputeFontBounds(FontPtr pFont)
+{
+ BitmapFontPtr bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
+ int nchars;
+ int r,
+ c;
+ CharInfoPtr ci;
+ int maxOverlap;
+ int overlap;
+ xCharInfo *minbounds,
+ *maxbounds;
+ int i;
+ int numneg = 0, numpos = 0;
+
+ if (bitmapFont->bitmapExtra) {
+ minbounds = &bitmapFont->bitmapExtra->info.minbounds;
+ maxbounds = &bitmapFont->bitmapExtra->info.maxbounds;
+ } else {
+ minbounds = &pFont->info.minbounds;
+ maxbounds = &pFont->info.maxbounds;
+ }
+ *minbounds = initMinMetrics;
+ *maxbounds = initMaxMetrics;
+ maxOverlap = MINSHORT;
+ nchars = bitmapFont->num_chars;
+ for (i = 0, ci = bitmapFont->metrics; i < nchars; i++, ci++) {
+ COMPUTE_MINMAX(&ci->metrics);
+ if (ci->metrics.characterWidth < 0)
+ numneg++;
+ else
+ numpos++;
+ minbounds->attributes &= ci->metrics.attributes;
+ maxbounds->attributes |= ci->metrics.attributes;
+ overlap = ci->metrics.rightSideBearing - ci->metrics.characterWidth;
+ if (maxOverlap < overlap)
+ maxOverlap = overlap;
+ }
+ if (bitmapFont->bitmapExtra) {
+ if (numneg > numpos)
+ bitmapFont->bitmapExtra->info.drawDirection = RightToLeft;
+ else
+ bitmapFont->bitmapExtra->info.drawDirection = LeftToRight;
+ bitmapFont->bitmapExtra->info.maxOverlap = maxOverlap;
+ minbounds = &pFont->info.minbounds;
+ maxbounds = &pFont->info.maxbounds;
+ *minbounds = initMinMetrics;
+ *maxbounds = initMaxMetrics;
+ i = 0;
+ maxOverlap = MINSHORT;
+ for (r = pFont->info.firstRow; r <= pFont->info.lastRow; r++) {
+ for (c = pFont->info.firstCol; c <= pFont->info.lastCol; c++) {
+ ci = ACCESSENCODING(bitmapFont->encoding, i);
+ if (ci) {
+ COMPUTE_MINMAX(&ci->metrics);
+ if (ci->metrics.characterWidth < 0)
+ numneg++;
+ else
+ numpos++;
+ minbounds->attributes &= ci->metrics.attributes;
+ maxbounds->attributes |= ci->metrics.attributes;
+ overlap = ci->metrics.rightSideBearing -
+ ci->metrics.characterWidth;
+ if (maxOverlap < overlap)
+ maxOverlap = overlap;
+ }
+ i++;
+ }
+ }
+ }
+ if (numneg > numpos)
+ pFont->info.drawDirection = RightToLeft;
+ else
+ pFont->info.drawDirection = LeftToRight;
+ pFont->info.maxOverlap = maxOverlap;
+}
+
+void
+bitmapComputeFontInkBounds(FontPtr pFont)
+{
+ BitmapFontPtr bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
+ int nchars;
+ int r,
+ c;
+ CharInfoPtr cit;
+ xCharInfo *ci;
+ int offset;
+ xCharInfo *minbounds,
+ *maxbounds;
+ int i;
+
+ if (!bitmapFont->ink_metrics) {
+ if (bitmapFont->bitmapExtra) {
+ bitmapFont->bitmapExtra->info.ink_minbounds = bitmapFont->bitmapExtra->info.minbounds;
+ bitmapFont->bitmapExtra->info.ink_maxbounds = bitmapFont->bitmapExtra->info.maxbounds;
+ }
+ pFont->info.ink_minbounds = pFont->info.minbounds;
+ pFont->info.ink_maxbounds = pFont->info.maxbounds;
+ } else {
+ if (bitmapFont->bitmapExtra) {
+ minbounds = &bitmapFont->bitmapExtra->info.ink_minbounds;
+ maxbounds = &bitmapFont->bitmapExtra->info.ink_maxbounds;
+ } else {
+ minbounds = &pFont->info.ink_minbounds;
+ maxbounds = &pFont->info.ink_maxbounds;
+ }
+ *minbounds = initMinMetrics;
+ *maxbounds = initMaxMetrics;
+ nchars = bitmapFont->num_chars;
+ for (i = 0, ci = bitmapFont->ink_metrics; i < nchars; i++, ci++) {
+ COMPUTE_MINMAX(ci);
+ minbounds->attributes &= ci->attributes;
+ maxbounds->attributes |= ci->attributes;
+ }
+ if (bitmapFont->bitmapExtra) {
+ minbounds = &pFont->info.ink_minbounds;
+ maxbounds = &pFont->info.ink_maxbounds;
+ *minbounds = initMinMetrics;
+ *maxbounds = initMaxMetrics;
+ i=0;
+ for (r = pFont->info.firstRow; r <= pFont->info.lastRow; r++) {
+ for (c = pFont->info.firstCol; c <= pFont->info.lastCol; c++) {
+ cit = ACCESSENCODING(bitmapFont->encoding, i);
+ if (cit) {
+ offset = cit - bitmapFont->metrics;
+ ci = &bitmapFont->ink_metrics[offset];
+ COMPUTE_MINMAX(ci);
+ minbounds->attributes &= ci->attributes;
+ maxbounds->attributes |= ci->attributes;
+ }
+ i++;
+ }
+ }
+ }
+ }
+}
+
+Bool
+bitmapAddInkMetrics(FontPtr pFont)
+{
+ BitmapFontPtr bitmapFont;
+ int i;
+
+ bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
+ bitmapFont->ink_metrics = (xCharInfo *) xalloc(bitmapFont->num_chars * sizeof(xCharInfo));
+ if (!bitmapFont->ink_metrics) {
+ fprintf(stderr, "Error: Couldn't allocate ink_metrics (%d*%ld)\n",
+ bitmapFont->num_chars, (unsigned long)sizeof(xCharInfo));
+ return FALSE;
+ }
+ for (i = 0; i < bitmapFont->num_chars; i++)
+ FontCharInkMetrics(pFont, &bitmapFont->metrics[i], &bitmapFont->ink_metrics[i]);
+ pFont->info.inkMetrics = TRUE;
+ return TRUE;
+}
+
+/* ARGSUSED */
+int
+bitmapComputeWeight(FontPtr pFont)
+{
+ return 10;
+}
diff --git a/nx-X11/lib/font/bitmap/bitscale.c b/nx-X11/lib/font/bitmap/bitscale.c
new file mode 100644
index 000000000..8f7247eaf
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/bitscale.c
@@ -0,0 +1,1978 @@
+/* $Xorg: bitscale.c,v 1.5 2001/02/09 02:04:02 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/bitmap/bitscale.c,v 3.29tsi Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/*
+ * Translate monolithic #defines to modular definitions
+ */
+
+#ifdef PCFFORMAT
+#define XFONT_PCFFORMAT 1
+#endif
+
+#ifdef SNFFORMAT
+#define XFONT_SNFFORMAT 1
+#endif
+
+#ifdef BDFFORMAT
+#define XFONT_BDFFORMAT 1
+#endif
+
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/bitmap.h>
+#include <X11/fonts/fontutil.h>
+#ifndef FONTMODULE
+#ifdef _XOPEN_SOURCE
+#include <math.h>
+#else
+#define _XOPEN_SOURCE /* to get prototype for hypot on some systems */
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+#endif
+
+#ifndef MAX
+#define MAX(a,b) (((a)>(b)) ? a : b)
+#endif
+
+/* Should get this from elsewhere */
+extern unsigned long serverGeneration;
+
+static void bitmapUnloadScalable (FontPtr pFont);
+static void ScaleBitmap ( FontPtr pFont, CharInfoPtr opci,
+ CharInfoPtr pci, double *inv_xform,
+ double widthMult, double heightMult );
+static FontPtr BitmapScaleBitmaps(FontPtr pf, FontPtr opf,
+ double widthMult, double heightMult,
+ FontScalablePtr vals);
+static FontPtr PrinterScaleBitmaps(FontPtr pf, FontPtr opf,
+ double widthMult, double heightMult,
+ FontScalablePtr vals);
+
+enum scaleType {
+ atom, truncate_atom, pixel_size, point_size, resolution_x,
+ resolution_y, average_width, scaledX, scaledY, unscaled, fontname,
+ raw_ascent, raw_descent, raw_pixelsize, raw_pointsize,
+ raw_average_width, uncomputed
+};
+
+typedef struct _fontProp {
+ char *name;
+ Atom atom;
+ enum scaleType type;
+} fontProp;
+
+typedef FontPtr (*ScaleFunc) ( FontPtr /* pf */,
+ FontPtr /* opf */,
+ double /* widthMult */,
+ double /* heightMult */,
+ FontScalablePtr /* vals */);
+
+/* These next two arrays must be kept in step with the renderer array */
+ScaleFunc scale[] =
+{
+#if XFONT_PCFFORMAT
+ BitmapScaleBitmaps,
+ BitmapScaleBitmaps,
+#ifdef X_GZIP_FONT_COMPRESSION
+ BitmapScaleBitmaps,
+#endif
+#endif
+#if XFONT_SNFFORMAT
+ BitmapScaleBitmaps,
+ BitmapScaleBitmaps,
+#ifdef X_GZIP_FONT_COMPRESSION
+ BitmapScaleBitmaps,
+#endif
+#endif
+#if XFONT_BDFFORMAT
+ BitmapScaleBitmaps,
+ BitmapScaleBitmaps,
+#ifdef X_GZIP_FONT_COMPRESSION
+ BitmapScaleBitmaps,
+#endif
+#endif
+#if XFONT_PCFFORMAT
+ PrinterScaleBitmaps,
+#endif
+};
+
+static FontEntryPtr FindBestToScale ( FontPathElementPtr fpe,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ FontScalablePtr best,
+ double *dxp, double *dyp,
+ double *sdxp, double *sdyp,
+ FontPathElementPtr *fpep );
+static FontEntryPtr FindPmfToScale ( FontPathElementPtr fpe,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ FontScalablePtr best,
+ double *dxp, double *dyp,
+ double *sdxp, double *sdyp,
+ FontPathElementPtr *fpep );
+
+typedef FontEntryPtr (*FindToScale) (FontPathElementPtr fpe,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ FontScalablePtr best,
+ double *dxp, double *dyp,
+ double *sdxp, double *sdyp,
+ FontPathElementPtr *fpep);
+FindToScale find_scale[] =
+{
+#if XFONT_PCFFORMAT
+ FindBestToScale,
+ FindBestToScale,
+#ifdef X_GZIP_FONT_COMPRESSION
+ FindBestToScale,
+#endif
+#endif
+#if XFONT_SNFFORMAT
+ FindBestToScale,
+ FindBestToScale,
+#ifdef X_GZIP_FONT_COMPRESSION
+ FindBestToScale,
+#endif
+#endif
+#if XFONT_BDFFORMAT
+ FindBestToScale,
+ FindBestToScale,
+#ifdef X_GZIP_FONT_COMPRESSION
+ FindBestToScale,
+#endif
+#endif
+#if XFONT_PCFFORMAT
+ FindPmfToScale,
+#endif
+};
+
+static unsigned long bitscaleGeneration = 0; /* initialization flag */
+
+static fontProp fontNamePropTable[] = {
+ { "FOUNDRY", 0, atom },
+ { "FAMILY_NAME", 0, atom },
+ { "WEIGHT_NAME", 0, atom },
+ { "SLANT", 0, atom },
+ { "SETWIDTH_NAME", 0, atom },
+ { "ADD_STYLE_NAME", 0, atom },
+ { "PIXEL_SIZE", 0, pixel_size },
+ { "POINT_SIZE", 0, point_size },
+ { "RESOLUTION_X", 0, resolution_x },
+ { "RESOLUTION_Y", 0, resolution_y },
+ { "SPACING", 0, atom },
+ { "AVERAGE_WIDTH", 0, average_width },
+ { "CHARSET_REGISTRY", 0, atom },
+ { "CHARSET_ENCODING", 0, truncate_atom },
+ { "FONT", 0, fontname },
+ { "RAW_ASCENT", 0, raw_ascent },
+ { "RAW_DESCENT", 0, raw_descent },
+ { "RAW_PIXEL_SIZE", 0, raw_pixelsize },
+ { "RAW_POINT_SIZE", 0, raw_pointsize },
+ { "RAW_AVERAGE_WIDTH", 0, raw_average_width }
+};
+
+#define TRANSFORM_POINT(matrix, x, y, dest) \
+ ((dest)[0] = (matrix)[0] * (x) + (matrix)[2] * (y), \
+ (dest)[1] = (matrix)[1] * (x) + (matrix)[3] * (y))
+
+#define CHECK_EXTENT(lsb, rsb, desc, asc, data) \
+ ((lsb) > (data)[0] ? (lsb) = (data)[0] : 0 , \
+ (rsb) < (data)[0] ? (rsb) = (data)[0] : 0, \
+ (-desc) > (data)[1] ? (desc) = -(data)[1] : 0 , \
+ (asc) < (data)[1] ? (asc) = (data)[1] : 0)
+
+#define NPROPS (sizeof(fontNamePropTable) / sizeof(fontProp))
+
+/* Warning: order of the next two tables is critically interdependent.
+ Location of "unscaled" properties at the end of fontPropTable[]
+ is important. */
+
+static fontProp fontPropTable[] = {
+ { "MIN_SPACE", 0, scaledX },
+ { "NORM_SPACE", 0, scaledX },
+ { "MAX_SPACE", 0, scaledX },
+ { "END_SPACE", 0, scaledX },
+ { "AVG_CAPITAL_WIDTH", 0, scaledX },
+ { "AVG_LOWERCASE_WIDTH", 0, scaledX },
+ { "QUAD_WIDTH", 0, scaledX },
+ { "FIGURE_WIDTH", 0, scaledX },
+ { "SUPERSCRIPT_X", 0, scaledX },
+ { "SUPERSCRIPT_Y", 0, scaledY },
+ { "SUBSCRIPT_X", 0, scaledX },
+ { "SUBSCRIPT_Y", 0, scaledY },
+ { "SUPERSCRIPT_SIZE", 0, scaledY },
+ { "SUBSCRIPT_SIZE", 0, scaledY },
+ { "SMALL_CAP_SIZE", 0, scaledY },
+ { "UNDERLINE_POSITION", 0, scaledY },
+ { "UNDERLINE_THICKNESS", 0, scaledY },
+ { "STRIKEOUT_ASCENT", 0, scaledY },
+ { "STRIKEOUT_DESCENT", 0, scaledY },
+ { "CAP_HEIGHT", 0, scaledY },
+ { "X_HEIGHT", 0, scaledY },
+ { "ITALIC_ANGLE", 0, unscaled },
+ { "RELATIVE_SETWIDTH", 0, unscaled },
+ { "RELATIVE_WEIGHT", 0, unscaled },
+ { "WEIGHT", 0, unscaled },
+ { "DESTINATION", 0, unscaled },
+ { "PCL_FONT_NAME", 0, unscaled },
+ { "_ADOBE_POSTSCRIPT_FONTNAME", 0, unscaled }
+};
+
+/* sleazy way to shut up the compiler */
+#define zerohack (enum scaleType)0
+
+static fontProp rawFontPropTable[] = {
+ { "RAW_MIN_SPACE", 0, },
+ { "RAW_NORM_SPACE", 0, },
+ { "RAW_MAX_SPACE", 0, },
+ { "RAW_END_SPACE", 0, },
+ { "RAW_AVG_CAPITAL_WIDTH", 0, },
+ { "RAW_AVG_LOWERCASE_WIDTH", 0, },
+ { "RAW_QUAD_WIDTH", 0, },
+ { "RAW_FIGURE_WIDTH", 0, },
+ { "RAW_SUPERSCRIPT_X", 0, },
+ { "RAW_SUPERSCRIPT_Y", 0, },
+ { "RAW_SUBSCRIPT_X", 0, },
+ { "RAW_SUBSCRIPT_Y", 0, },
+ { "RAW_SUPERSCRIPT_SIZE", 0, },
+ { "RAW_SUBSCRIPT_SIZE", 0, },
+ { "RAW_SMALL_CAP_SIZE", 0, },
+ { "RAW_UNDERLINE_POSITION", 0, },
+ { "RAW_UNDERLINE_THICKNESS", 0, },
+ { "RAW_STRIKEOUT_ASCENT", 0, },
+ { "RAW_STRIKEOUT_DESCENT", 0, },
+ { "RAW_CAP_HEIGHT", 0, },
+ { "RAW_X_HEIGHT", 0, }
+};
+
+static void
+initFontPropTable(void)
+{
+ int i;
+ fontProp *t;
+
+ i = sizeof(fontNamePropTable) / sizeof(fontProp);
+ for (t = fontNamePropTable; i; i--, t++)
+ t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+
+ i = sizeof(fontPropTable) / sizeof(fontProp);
+ for (t = fontPropTable; i; i--, t++)
+ t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+
+ i = sizeof(rawFontPropTable) / sizeof(fontProp);
+ for (t = rawFontPropTable; i; i--, t++)
+ t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+}
+
+#if 0
+static FontEntryPtr
+GetScalableEntry (FontPathElementPtr fpe, FontNamePtr name)
+{
+ FontDirectoryPtr dir;
+
+ dir = (FontDirectoryPtr) fpe->private;
+ return FontFileFindNameInDir (&dir->scalable, name);
+}
+#endif
+
+static double
+get_matrix_horizontal_component(double *matrix)
+{
+ return hypot(matrix[0], matrix[1]);
+}
+
+static double
+get_matrix_vertical_component(double *matrix)
+{
+ return hypot(matrix[2], matrix[3]);
+}
+
+
+static Bool
+ComputeScaleFactors(FontScalablePtr from, FontScalablePtr to,
+ double *dx, double *dy, double *sdx, double *sdy,
+ double *rescale_x)
+{
+ double srcpixelset, destpixelset, srcpixel, destpixel;
+
+ srcpixelset = get_matrix_horizontal_component(from->pixel_matrix);
+ destpixelset = get_matrix_horizontal_component(to->pixel_matrix);
+ srcpixel = get_matrix_vertical_component(from->pixel_matrix);
+ destpixel = get_matrix_vertical_component(to->pixel_matrix);
+
+ if (srcpixelset >= EPS)
+ {
+ *dx = destpixelset / srcpixelset;
+ *sdx = 1000.0 / srcpixelset;
+ }
+ else
+ *sdx = *dx = 0;
+
+ *rescale_x = 1.0;
+
+ /* If client specified a width, it overrides setsize; in this
+ context, we interpret width as applying to the font before any
+ rotation, even though that's not what is ultimately returned in
+ the width field. */
+ if (from->width > 0 && to->width > 0 && fabs(*dx) > EPS)
+ {
+ double rescale = (double)to->width / (double)from->width;
+
+ /* If the client specified a transformation matrix, the rescaling
+ for width does *not* override the setsize. Instead, just check
+ for consistency between the setsize from the matrix and the
+ setsize that would result from rescaling according to the width.
+ This assumes (perhaps naively) that the width is correctly
+ reported in the name. As an interesting side effect, this test
+ may result in choosing a different source bitmap (one that
+ scales consistently between the setsize *and* the width) than it
+ would choose if a width were not specified. Sort of a hidden
+ multiple-master functionality. */
+ if ((to->values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
+ (to->values_supplied & POINTSIZE_MASK) == POINTSIZE_ARRAY)
+ {
+ /* Reject if resulting width difference is >= 1 pixel */
+ if (fabs(rescale * from->width - *dx * from->width) >= 10)
+ return FALSE;
+ }
+ else
+ {
+ *rescale_x = rescale/(*dx);
+ *dx = rescale;
+ }
+ }
+
+ if (srcpixel >= EPS)
+ {
+ *dy = destpixel / srcpixel;
+ *sdy = 1000.0 / srcpixel;
+ }
+ else
+ *sdy = *dy = 0;
+
+ return TRUE;
+}
+
+/* favor enlargement over reduction because of aliasing resulting
+ from reduction */
+#define SCORE(m,s) \
+if (m >= 1.0) { \
+ if (m == 1.0) \
+ score += (16 * s); \
+ else if (m == 2.0) \
+ score += (4 * s); \
+ else \
+ score += (int)(((double)(3 * s)) / m); \
+} else { \
+ score += (int)(((double)(2 * s)) * m); \
+}
+
+/* don't need to favor enlargement when looking for bitmap that can
+ be used unscalable */
+#define SCORE2(m,s) \
+if (m >= 1.0) \
+ score += (int)(((double)(8 * s)) / m); \
+else \
+ score += (int)(((double)(8 * s)) * m);
+
+static FontEntryPtr
+FindBestToScale(FontPathElementPtr fpe, FontEntryPtr entry,
+ FontScalablePtr vals, FontScalablePtr best,
+ double *dxp, double *dyp,
+ double *sdxp, double *sdyp,
+ FontPathElementPtr *fpep)
+{
+ FontScalableRec temp;
+ int source, i;
+ int best_score, best_unscaled_score,
+ score;
+ double dx = 0.0, sdx = 0.0, dx_amount = 0.0,
+ dy = 0.0, sdy = 0.0, dy_amount = 0.0,
+ best_dx = 0.0, best_sdx = 0.0, best_dx_amount = 0.0,
+ best_dy = 0.0, best_sdy = 0.0, best_dy_amount = 0.0,
+ best_unscaled_sdx = 0.0, best_unscaled_sdy = 0.0,
+ rescale_x = 0.0, best_rescale_x = 0.0,
+ best_unscaled_rescale_x = 0.0;
+ FontEntryPtr zero;
+ FontNameRec zeroName;
+ char zeroChars[MAXFONTNAMELEN];
+ FontDirectoryPtr dir;
+ FontScaledPtr scaled;
+ FontScalableExtraPtr extra;
+ FontScaledPtr best_scaled, best_unscaled;
+ FontPathElementPtr best_fpe = NULL, best_unscaled_fpe = NULL;
+ FontEntryPtr bitmap = NULL;
+ FontEntryPtr result;
+ int aliascount = 20;
+ FontPathElementPtr bitmap_fpe = NULL;
+ FontNameRec xlfdName;
+
+ /* find the best match */
+ rescale_x = 1.0;
+ best_scaled = 0;
+ best_score = 0;
+ best_unscaled = 0;
+ best_unscaled_score = -1;
+ best_dx_amount = best_dy_amount = HUGE_VAL;
+ memcpy (zeroChars, entry->name.name, entry->name.length);
+ zeroChars[entry->name.length] = '\0';
+ zeroName.name = zeroChars;
+ FontParseXLFDName (zeroChars, &temp, FONT_XLFD_REPLACE_ZERO);
+ zeroName.length = strlen (zeroChars);
+ zeroName.ndashes = entry->name.ndashes;
+ xlfdName.name = vals->xlfdName;
+ xlfdName.length = strlen(xlfdName.name);
+ xlfdName.ndashes = FontFileCountDashes(xlfdName.name, xlfdName.length);
+ restart_bestscale_loop: ;
+ /*
+ * Look through all the registered bitmap sources for
+ * the same zero name as ours; entries along that one
+ * can be scaled as desired.
+ */
+ for (source = 0; source < FontFileBitmapSources.count; source++)
+ {
+ /* There might already be a bitmap that satisfies the request
+ but didn't have a zero name that was found by the scalable
+ font matching logic. Keep track if there is. */
+ if (bitmap == NULL && vals->xlfdName != NULL)
+ {
+ bitmap_fpe = FontFileBitmapSources.fpe[source];
+ dir = (FontDirectoryPtr) bitmap_fpe->private;
+ bitmap = FontFileFindNameInDir (&dir->nonScalable, &xlfdName);
+ if (bitmap && bitmap->type != FONT_ENTRY_BITMAP)
+ {
+ if (bitmap->type == FONT_ENTRY_ALIAS && aliascount > 0)
+ {
+ aliascount--;
+ xlfdName.name = bitmap->u.alias.resolved;
+ xlfdName.length = strlen(xlfdName.name);
+ xlfdName.ndashes = FontFileCountDashes(xlfdName.name,
+ xlfdName.length);
+ bitmap = NULL;
+ goto restart_bestscale_loop;
+ }
+ else
+ bitmap = NULL;
+ }
+ }
+
+ if (FontFileBitmapSources.fpe[source] == fpe)
+ zero = entry;
+ else
+ {
+ dir = (FontDirectoryPtr) FontFileBitmapSources.fpe[source]->private;
+ zero = FontFileFindNameInDir (&dir->scalable, &zeroName);
+ if (!zero)
+ continue;
+ }
+ extra = zero->u.scalable.extra;
+ for (i = 0; i < extra->numScaled; i++)
+ {
+ scaled = &extra->scaled[i];
+ if (!scaled->bitmap)
+ continue;
+ if (!ComputeScaleFactors(&scaled->vals, vals, &dx, &dy, &sdx, &sdy,
+ &rescale_x))
+ continue;
+ score = 0;
+ dx_amount = dx;
+ dy_amount = dy;
+ SCORE(dy_amount, 10);
+ SCORE(dx_amount, 1);
+ if ((score > best_score) ||
+ ((score == best_score) &&
+ ((dy_amount < best_dy_amount) ||
+ ((dy_amount == best_dy_amount) &&
+ (dx_amount < best_dx_amount)))))
+ {
+ best_fpe = FontFileBitmapSources.fpe[source];
+ best_scaled = scaled;
+ best_score = score;
+ best_dx = dx;
+ best_dy = dy;
+ best_sdx = sdx;
+ best_sdy = sdy;
+ best_dx_amount = dx_amount;
+ best_dy_amount = dy_amount;
+ best_rescale_x = rescale_x;
+ }
+ /* Is this font a candidate for use without ugly rescaling? */
+ if (fabs(dx) > EPS && fabs(dy) > EPS &&
+ fabs(vals->pixel_matrix[0] * rescale_x -
+ scaled->vals.pixel_matrix[0]) < 1 &&
+ fabs(vals->pixel_matrix[1] * rescale_x -
+ scaled->vals.pixel_matrix[1]) < EPS &&
+ fabs(vals->pixel_matrix[2] -
+ scaled->vals.pixel_matrix[2]) < EPS &&
+ fabs(vals->pixel_matrix[3] -
+ scaled->vals.pixel_matrix[3]) < 1)
+ {
+ /* Yes. The pixel sizes are close on the diagonal and
+ extremely close off the diagonal. */
+ score = 0;
+ SCORE2(vals->pixel_matrix[3] /
+ scaled->vals.pixel_matrix[3], 10);
+ SCORE2(vals->pixel_matrix[0] * rescale_x /
+ scaled->vals.pixel_matrix[0], 1);
+ if (score > best_unscaled_score)
+ {
+ best_unscaled_fpe = FontFileBitmapSources.fpe[source];
+ best_unscaled = scaled;
+ best_unscaled_sdx = sdx / dx;
+ best_unscaled_sdy = sdy / dy;
+ best_unscaled_score = score;
+ best_unscaled_rescale_x = rescale_x;
+ }
+ }
+ }
+ }
+ if (best_unscaled)
+ {
+ *best = best_unscaled->vals;
+ *fpep = best_unscaled_fpe;
+ *dxp = 1.0;
+ *dyp = 1.0;
+ *sdxp = best_unscaled_sdx;
+ *sdyp = best_unscaled_sdy;
+ rescale_x = best_unscaled_rescale_x;
+ result = best_unscaled->bitmap;
+ }
+ else if (best_scaled)
+ {
+ *best = best_scaled->vals;
+ *fpep = best_fpe;
+ *dxp = best_dx;
+ *dyp = best_dy;
+ *sdxp = best_sdx;
+ *sdyp = best_sdy;
+ rescale_x = best_rescale_x;
+ result = best_scaled->bitmap;
+ }
+ else
+ result = NULL;
+
+ if (bitmap != NULL && (result == NULL || *dxp != 1.0 || *dyp != 1.0))
+ {
+ *fpep = bitmap_fpe;
+ FontParseXLFDName (bitmap->name.name, best, FONT_XLFD_REPLACE_NONE);
+ if (ComputeScaleFactors(best, best, dxp, dyp, sdxp, sdyp, &rescale_x))
+ result = bitmap;
+ else
+ result = NULL;
+ }
+
+ if (result && rescale_x != 1.0)
+ {
+ /* We have rescaled horizontally due to an XLFD width field. Change
+ the matrix appropriately */
+ vals->pixel_matrix[0] *= rescale_x;
+ vals->pixel_matrix[1] *= rescale_x;
+#ifdef NOTDEF
+ /* This would force the pointsize and pixelsize fields in the
+ FONT property to display as matrices to more accurately
+ report the font being supplied. It might also break existing
+ applications that expect a single number in that field. */
+ vals->values_supplied =
+ vals->values_supplied & ~(PIXELSIZE_MASK | POINTSIZE_MASK) |
+ PIXELSIZE_ARRAY;
+#else /* NOTDEF */
+ vals->values_supplied = vals->values_supplied & ~POINTSIZE_MASK;
+#endif /* NOTDEF */
+ /* Recompute and reround the FontScalablePtr values after
+ rescaling for the new width. */
+ FontFileCompleteXLFD(vals, vals);
+ }
+
+ return result;
+}
+
+static FontEntryPtr
+FindPmfToScale(FontPathElementPtr fpe, FontEntryPtr entry,
+ FontScalablePtr vals, FontScalablePtr best,
+ double *dxp, double *dyp,
+ double *sdxp, double *sdyp,
+ FontPathElementPtr *fpep)
+{
+ FontEntryPtr result = NULL;
+ FontScaledPtr scaled;
+ FontScalableExtraPtr extra;
+ int i;
+
+ extra = entry->u.scalable.extra;
+ for (i = 0; i < extra->numScaled; i++)
+ {
+ double rescale_x;
+
+ scaled = &extra->scaled[i];
+ if (!scaled->bitmap)
+ continue;
+ if (!ComputeScaleFactors(&scaled->vals, vals, dxp, dyp, sdxp, sdyp,
+ &rescale_x))
+ continue;
+ *best = scaled->vals;
+ *fpep = fpe;
+ result = scaled->bitmap;
+ if (rescale_x != 1.0)
+ {
+ /* We have rescaled horizontally due to an XLFD width field. Change
+ the matrix appropriately */
+ vals->pixel_matrix[0] *= rescale_x;
+ vals->pixel_matrix[1] *= rescale_x;
+#ifdef NOTDEF
+ /* This would force the pointsize and pixelsize fields in the
+ FONT property to display as matrices to more accurately
+ report the font being supplied. It might also break existing
+ applications that expect a single number in that field. */
+ vals->values_supplied =
+ vals->values_supplied & ~(PIXELSIZE_MASK | POINTSIZE_MASK) |
+ PIXELSIZE_ARRAY;
+#else /* NOTDEF */
+ vals->values_supplied = vals->values_supplied & ~POINTSIZE_MASK;
+#endif /* NOTDEF */
+ /* Recompute and reround the FontScalablePtr values after
+ rescaling for the new width. */
+ FontFileCompleteXLFD(vals, vals);
+ }
+ break;
+ }
+ return result;
+}
+
+static long
+doround(double x)
+{
+ return (x >= 0) ? (long)(x + .5) : (long)(x - .5);
+}
+
+static int
+computeProps(FontPropPtr pf, char *wasStringProp,
+ FontPropPtr npf, char *isStringProp,
+ unsigned int nprops, double xfactor, double yfactor,
+ double sXfactor, double sYfactor)
+{
+ int n;
+ int count;
+ fontProp *t;
+ double rawfactor = 0.0;
+
+ for (count = 0; nprops > 0; nprops--, pf++, wasStringProp++) {
+ n = sizeof(fontPropTable) / sizeof(fontProp);
+ for (t = fontPropTable; n && (t->atom != pf->name); n--, t++);
+ if (!n)
+ continue;
+
+ switch (t->type) {
+ case scaledX:
+ npf->value = doround(xfactor * (double)pf->value);
+ rawfactor = sXfactor;
+ break;
+ case scaledY:
+ npf->value = doround(yfactor * (double)pf->value);
+ rawfactor = sYfactor;
+ break;
+ case unscaled:
+ npf->value = pf->value;
+ npf->name = pf->name;
+ npf++;
+ count++;
+ *isStringProp++ = *wasStringProp;
+ break;
+ default:
+ break;
+ }
+ if (t->type != unscaled)
+ {
+ npf->name = pf->name;
+ npf++;
+ count++;
+ npf->value = doround(rawfactor * (double)pf->value);
+ npf->name = rawFontPropTable[t - fontPropTable].atom;
+ npf++;
+ count++;
+ *isStringProp++ = *wasStringProp;
+ *isStringProp++ = *wasStringProp;
+ }
+ }
+ return count;
+}
+
+
+static int
+ComputeScaledProperties(FontInfoPtr sourceFontInfo, /* the font to be scaled */
+ char *name, /* name of resulting font */
+ FontScalablePtr vals,
+ double dx, double dy, /* scale factors in x and y */
+ double sdx, double sdy, /* directions */
+ long sWidth, /* 1000-pixel average width */
+ FontPropPtr *pProps, /* returns properties;
+ preallocated */
+ char **pIsStringProp) /* return booleans;
+ preallocated */
+{
+ int n;
+ char *ptr1 = NULL, *ptr2 = NULL;
+ char *ptr3;
+ FontPropPtr fp;
+ fontProp *fpt;
+ char *isStringProp;
+ int nProps;
+
+ if (bitscaleGeneration != serverGeneration) {
+ initFontPropTable();
+ bitscaleGeneration = serverGeneration;
+ }
+ nProps = NPROPS + 1 + sizeof(fontPropTable) / sizeof(fontProp) +
+ sizeof(rawFontPropTable) / sizeof(fontProp);
+ fp = (FontPropPtr) xalloc(sizeof(FontPropRec) * nProps);
+ *pProps = fp;
+ if (!fp) {
+ fprintf(stderr, "Error: Couldn't allocate font properties (%ld*%d)\n",
+ (unsigned long)sizeof(FontPropRec), nProps);
+ return 1;
+ }
+ isStringProp = (char *) xalloc (nProps);
+ *pIsStringProp = isStringProp;
+ if (!isStringProp)
+ {
+ fprintf(stderr, "Error: Couldn't allocate isStringProp (%d)\n", nProps);
+ xfree (fp);
+ return 1;
+ }
+ ptr2 = name;
+ for (fpt = fontNamePropTable, n = NPROPS;
+ n;
+ fp++, fpt++, n--, isStringProp++)
+ {
+
+ if (*ptr2)
+ {
+ ptr1 = ptr2 + 1;
+ if (!(ptr2 = strchr(ptr1, '-'))) ptr2 = strchr(ptr1, '\0');
+ }
+
+ *isStringProp = 0;
+ switch (fpt->type) {
+ case atom:
+ fp->value = MakeAtom(ptr1, ptr2 - ptr1, TRUE);
+ *isStringProp = 1;
+ break;
+ case truncate_atom:
+ for (ptr3 = ptr1; *ptr3; ptr3++)
+ if (*ptr3 == '[')
+ break;
+ if (!*ptr3) ptr3 = ptr2;
+ fp->value = MakeAtom(ptr1, ptr3 - ptr1, TRUE);
+ *isStringProp = 1;
+ break;
+ case pixel_size:
+ fp->value = doround(vals->pixel_matrix[3]);
+ break;
+ case point_size:
+ fp->value = doround(vals->point_matrix[3] * 10.0);
+ break;
+ case resolution_x:
+ fp->value = vals->x;
+ break;
+ case resolution_y:
+ fp->value = vals->y;
+ break;
+ case average_width:
+ fp->value = vals->width;
+ break;
+ case fontname:
+ fp->value = MakeAtom(name, strlen(name), TRUE);
+ *isStringProp = 1;
+ break;
+ case raw_ascent:
+ fp->value = sourceFontInfo->fontAscent * sdy;
+ break;
+ case raw_descent:
+ fp->value = sourceFontInfo->fontDescent * sdy;
+ break;
+ case raw_pointsize:
+ fp->value = (long)(72270.0 / (double)vals->y + .5);
+ break;
+ case raw_pixelsize:
+ fp->value = 1000;
+ break;
+ case raw_average_width:
+ fp->value = sWidth;
+ break;
+ default:
+ break;
+ }
+ fp->name = fpt->atom;
+ }
+ n = NPROPS;
+ n += computeProps(sourceFontInfo->props, sourceFontInfo->isStringProp,
+ fp, isStringProp, sourceFontInfo->nprops, dx, dy,
+ sdx, sdy);
+ return n;
+}
+
+
+static int
+compute_xform_matrix(FontScalablePtr vals, double dx, double dy,
+ double *xform, double *inv_xform,
+ double *xmult, double *ymult)
+{
+ double det;
+ double pixel = get_matrix_vertical_component(vals->pixel_matrix);
+ double pixelset = get_matrix_horizontal_component(vals->pixel_matrix);
+
+ if (pixel < EPS || pixelset < EPS) return 0;
+
+ /* Initialize the transformation matrix to the scaling factors */
+ xform[0] = dx / pixelset;
+ xform[1] = xform[2] = 0.0;
+ xform[3] = dy / pixel;
+
+/* Inline matrix multiply -- somewhat ugly to minimize register usage */
+#define MULTIPLY_XFORM(a,b,c,d) \
+{ \
+ register double aa = (a), bb = (b), cc = (c), dd = (d); \
+ register double temp; \
+ temp = aa * xform[0] + cc * xform[1]; \
+ aa = aa * xform[2] + cc * xform[3]; \
+ xform[1] = bb * xform[0] + dd * xform[1]; \
+ xform[3] = bb * xform[2] + dd * xform[3]; \
+ xform[0] = temp; \
+ xform[2] = aa; \
+}
+
+ /* Rescale the transformation matrix for size of source font */
+ MULTIPLY_XFORM(vals->pixel_matrix[0],
+ vals->pixel_matrix[1],
+ vals->pixel_matrix[2],
+ vals->pixel_matrix[3]);
+
+ *xmult = xform[0];
+ *ymult = xform[3];
+
+
+ if (inv_xform == NULL) return 1;
+
+ /* Compute the determinant for use in inverting the matrix. */
+ det = xform[0] * xform[3] - xform[1] * xform[2];
+
+ /* If the determinant is tiny or zero, give up */
+ if (fabs(det) < EPS) return 0;
+
+ /* Compute the inverse */
+ inv_xform[0] = xform[3] / det;
+ inv_xform[1] = -xform[1] / det;
+ inv_xform[2] = -xform[2] / det;
+ inv_xform[3] = xform[0] / det;
+
+ return 1;
+}
+
+/*
+ * ScaleFont
+ * returns a pointer to the new scaled font, or NULL (due to AllocError).
+ */
+static FontPtr
+ScaleFont(FontPtr opf, /* originating font */
+ double widthMult, /* glyphs width scale factor */
+ double heightMult, /* glyphs height scale factor */
+ double sWidthMult, /* scalable glyphs width scale factor */
+ double sHeightMult, /* scalable glyphs height scale factor */
+ FontScalablePtr vals,
+ double *newWidthMult, /* return: X component of glyphs width
+ scale factor */
+ double *newHeightMult, /* return: Y component of glyphs height
+ scale factor */
+ long *sWidth) /* return: average 1000-pixel width */
+{
+ FontPtr pf;
+ FontInfoPtr pfi,
+ opfi;
+ BitmapFontPtr bitmapFont,
+ obitmapFont;
+ CharInfoPtr pci,
+ opci;
+ int nchars = 0; /* how many characters in the font */
+ int i;
+ int firstCol, lastCol, firstRow, lastRow;
+ double xform[4], inv_xform[4];
+ double xmult, ymult;
+ int totalwidth = 0, totalchars = 0;
+#define OLDINDEX(i) (((i)/(lastCol - firstCol + 1) + \
+ firstRow - opf->info.firstRow) * \
+ (opf->info.lastCol - opf->info.firstCol + 1) + \
+ (i)%(lastCol - firstCol + 1) + \
+ firstCol - opf->info.firstCol)
+
+ *sWidth = 0;
+
+ opfi = &opf->info;
+ obitmapFont = (BitmapFontPtr) opf->fontPrivate;
+
+ bitmapFont = 0;
+ if (!(pf = CreateFontRec())) {
+ fprintf(stderr, "Error: Couldn't allocate FontRec (%ld)\n",
+ (unsigned long)sizeof(FontRec));
+ goto bail;
+ }
+ pf->refcnt = 0;
+ pf->bit = opf->bit;
+ pf->byte = opf->byte;
+ pf->glyph = opf->glyph;
+ pf->scan = opf->scan;
+
+ pf->get_glyphs = bitmapGetGlyphs;
+ pf->get_metrics = bitmapGetMetrics;
+ pf->unload_font = bitmapUnloadScalable;
+ pf->unload_glyphs = NULL;
+
+ pfi = &pf->info;
+ *pfi = *opfi;
+ /* If charset subsetting specified in vals, determine what our range
+ needs to be for the output font */
+ if (vals->nranges)
+ {
+ int i;
+
+ pfi->allExist = 0;
+ firstCol = 255;
+ lastCol = 0;
+ firstRow = 255;
+ lastRow = 0;
+
+ for (i = 0; i < vals->nranges; i++)
+ {
+ if (vals->ranges[i].min_char_high != vals->ranges[i].max_char_high)
+ {
+ firstCol = opfi->firstCol;
+ lastCol = opfi->lastCol;
+ }
+ if (firstCol > vals->ranges[i].min_char_low)
+ firstCol = vals->ranges[i].min_char_low;
+ if (lastCol < vals->ranges[i].max_char_low)
+ lastCol = vals->ranges[i].max_char_low;
+ if (firstRow > vals->ranges[i].min_char_high)
+ firstRow = vals->ranges[i].min_char_high;
+ if (lastRow < vals->ranges[i].max_char_high)
+ lastRow = vals->ranges[i].max_char_high;
+ }
+
+ if (firstCol > lastCol || firstRow > lastRow)
+ goto bail;
+
+ if (firstCol < opfi->firstCol)
+ firstCol = opfi->firstCol;
+ if (lastCol > opfi->lastCol)
+ lastCol = opfi->lastCol;
+ if (firstRow < opfi->firstRow)
+ firstRow = opfi->firstRow;
+ if (lastRow > opfi->lastRow)
+ lastRow = opfi->lastRow;
+ }
+ else
+ {
+ firstCol = opfi->firstCol;
+ lastCol = opfi->lastCol;
+ firstRow = opfi->firstRow;
+ lastRow = opfi->lastRow;
+ }
+
+ bitmapFont = (BitmapFontPtr) xalloc(sizeof(BitmapFontRec));
+ if (!bitmapFont) {
+ fprintf(stderr, "Error: Couldn't allocate bitmapFont (%ld)\n",
+ (unsigned long)sizeof(BitmapFontRec));
+ goto bail;
+ }
+ nchars = (lastRow - firstRow + 1) * (lastCol - firstCol + 1);
+ pfi->firstRow = firstRow;
+ pfi->lastRow = lastRow;
+ pfi->firstCol = firstCol;
+ pfi->lastCol = lastCol;
+ pf->fontPrivate = (pointer) bitmapFont;
+ bitmapFont->version_num = obitmapFont->version_num;
+ bitmapFont->num_chars = nchars;
+ bitmapFont->num_tables = obitmapFont->num_tables;
+ bitmapFont->metrics = 0;
+ bitmapFont->ink_metrics = 0;
+ bitmapFont->bitmaps = 0;
+ bitmapFont->encoding = 0;
+ bitmapFont->bitmapExtra = 0;
+ bitmapFont->pDefault = 0;
+ bitmapFont->metrics = (CharInfoPtr) xalloc(nchars * sizeof(CharInfoRec));
+ if (!bitmapFont->metrics) {
+ fprintf(stderr, "Error: Couldn't allocate metrics (%d*%ld)\n",
+ nchars, (unsigned long)sizeof(CharInfoRec));
+ goto bail;
+ }
+ bitmapFont->encoding =
+ (CharInfoPtr **) xcalloc(NUM_SEGMENTS(nchars),
+ sizeof(CharInfoPtr*));
+ if (!bitmapFont->encoding) {
+ fprintf(stderr, "Error: Couldn't allocate encoding (%d*%ld)\n",
+ nchars, (unsigned long)sizeof(CharInfoPtr));
+ goto bail;
+ }
+
+#undef MAXSHORT
+#define MAXSHORT 32767
+#undef MINSHORT
+#define MINSHORT -32768
+
+ pfi->anamorphic = FALSE;
+ if (heightMult != widthMult)
+ pfi->anamorphic = TRUE;
+ pfi->cachable = TRUE;
+
+ if (!compute_xform_matrix(vals, widthMult, heightMult, xform,
+ inv_xform, &xmult, &ymult))
+ goto bail;
+
+ pfi->fontAscent = opfi->fontAscent * ymult;
+ pfi->fontDescent = opfi->fontDescent * ymult;
+
+ pfi->minbounds.leftSideBearing = MAXSHORT;
+ pfi->minbounds.rightSideBearing = MAXSHORT;
+ pfi->minbounds.ascent = MAXSHORT;
+ pfi->minbounds.descent = MAXSHORT;
+ pfi->minbounds.characterWidth = MAXSHORT;
+ pfi->minbounds.attributes = MAXSHORT;
+
+ pfi->maxbounds.leftSideBearing = MINSHORT;
+ pfi->maxbounds.rightSideBearing = MINSHORT;
+ pfi->maxbounds.ascent = MINSHORT;
+ pfi->maxbounds.descent = MINSHORT;
+ pfi->maxbounds.characterWidth = MINSHORT;
+ pfi->maxbounds.attributes = MINSHORT;
+
+ /* Compute the transformation and inverse transformation matrices.
+ Can fail if the determinant is zero. */
+
+ pci = bitmapFont->metrics;
+ for (i = 0; i < nchars; i++)
+ {
+ if ((opci = ACCESSENCODING(obitmapFont->encoding,OLDINDEX(i))))
+ {
+ double newlsb, newrsb, newdesc, newasc, point[2];
+
+#define minchar(p) ((p).min_char_low + ((p).min_char_high << 8))
+#define maxchar(p) ((p).max_char_low + ((p).max_char_high << 8))
+
+ if (vals->nranges)
+ {
+ int row = i / (lastCol - firstCol + 1) + firstRow;
+ int col = i % (lastCol - firstCol + 1) + firstCol;
+ int ch = (row << 8) + col;
+ int j;
+ for (j = 0; j < vals->nranges; j++)
+ if (ch >= minchar(vals->ranges[j]) &&
+ ch <= maxchar(vals->ranges[j]))
+ break;
+ if (j == vals->nranges)
+ {
+ continue;
+ }
+ }
+
+ if (opci->metrics.leftSideBearing == 0 &&
+ opci->metrics.rightSideBearing == 0 &&
+ opci->metrics.ascent == 0 &&
+ opci->metrics.descent == 0 &&
+ opci->metrics.characterWidth == 0)
+ {
+ continue;
+ }
+
+ if(!bitmapFont->encoding[SEGMENT_MAJOR(i)]) {
+ bitmapFont->encoding[SEGMENT_MAJOR(i)]=
+ (CharInfoPtr*)xcalloc(BITMAP_FONT_SEGMENT_SIZE,
+ sizeof(CharInfoPtr));
+ if(!bitmapFont->encoding[SEGMENT_MAJOR(i)])
+ goto bail;
+ }
+ ACCESSENCODINGL(bitmapFont->encoding, i) = pci;
+
+ /* Compute new extents for this glyph */
+ TRANSFORM_POINT(xform,
+ opci->metrics.leftSideBearing,
+ -opci->metrics.descent,
+ point);
+ newlsb = point[0];
+ newrsb = newlsb;
+ newdesc = -point[1];
+ newasc = -newdesc;
+ TRANSFORM_POINT(xform,
+ opci->metrics.leftSideBearing,
+ opci->metrics.ascent,
+ point);
+ CHECK_EXTENT(newlsb, newrsb, newdesc, newasc, point);
+ TRANSFORM_POINT(xform,
+ opci->metrics.rightSideBearing,
+ -opci->metrics.descent,
+ point);
+ CHECK_EXTENT(newlsb, newrsb, newdesc, newasc, point);
+ TRANSFORM_POINT(xform,
+ opci->metrics.rightSideBearing,
+ opci->metrics.ascent,
+ point);
+ CHECK_EXTENT(newlsb, newrsb, newdesc, newasc, point);
+
+ pci->metrics.leftSideBearing = (int)floor(newlsb);
+ pci->metrics.rightSideBearing = (int)floor(newrsb + .5);
+ pci->metrics.descent = (int)ceil(newdesc);
+ pci->metrics.ascent = (int)floor(newasc + .5);
+ /* Accumulate total width of characters before transformation,
+ to ascertain predominant direction of font. */
+ totalwidth += opci->metrics.characterWidth;
+ pci->metrics.characterWidth =
+ doround((double)opci->metrics.characterWidth * xmult);
+ pci->metrics.attributes =
+ doround((double)opci->metrics.characterWidth * sWidthMult);
+ if (!pci->metrics.characterWidth)
+ {
+ /* Since transformation may shrink width, height, and
+ escapement to zero, make sure existing characters
+ are not mistaken for undefined characters. */
+
+ if (pci->metrics.rightSideBearing ==
+ pci->metrics.leftSideBearing)
+ pci->metrics.rightSideBearing++;
+ if (pci->metrics.ascent == -pci->metrics.descent)
+ pci->metrics.ascent++;
+ }
+
+ pci++;
+ }
+ }
+
+
+ /*
+ * For each character, set the per-character metrics, scale the glyph, and
+ * check per-font minbounds and maxbounds character information.
+ */
+
+ pci = bitmapFont->metrics;
+ for (i = 0; i < nchars; i++)
+ {
+ if ((pci = ACCESSENCODING(bitmapFont->encoding,i)) &&
+ (opci = ACCESSENCODING(obitmapFont->encoding,OLDINDEX(i))))
+ {
+ totalchars++;
+ *sWidth += abs((int)(INT16)pci->metrics.attributes);
+#define MINMAX(field) \
+ if (pfi->minbounds.field > pci->metrics.field) \
+ pfi->minbounds.field = pci->metrics.field; \
+ if (pfi->maxbounds.field < pci->metrics.field) \
+ pfi->maxbounds.field = pci->metrics.field
+
+ MINMAX(leftSideBearing);
+ MINMAX(rightSideBearing);
+ MINMAX(ascent);
+ MINMAX(descent);
+ MINMAX(characterWidth);
+
+ /* Hack: Cast attributes into a signed quantity. Tread lightly
+ for now and don't go changing the global Xproto.h file */
+ if ((INT16)pfi->minbounds.attributes >
+ (INT16)pci->metrics.attributes)
+ pfi->minbounds.attributes = pci->metrics.attributes;
+ if ((INT16)pfi->maxbounds.attributes <
+ (INT16)pci->metrics.attributes)
+ pfi->maxbounds.attributes = pci->metrics.attributes;
+#undef MINMAX
+ }
+ }
+ pfi->ink_minbounds = pfi->minbounds;
+ pfi->ink_maxbounds = pfi->maxbounds;
+ if (totalchars)
+ {
+ *sWidth = (*sWidth * 10 + totalchars / 2) / totalchars;
+ if (totalwidth < 0)
+ {
+ /* Dominant direction is R->L */
+ *sWidth = -*sWidth;
+ }
+
+ if (pfi->minbounds.characterWidth == pfi->maxbounds.characterWidth)
+ vals->width = pfi->minbounds.characterWidth * 10;
+ else
+ vals->width = doround((double)*sWidth * vals->pixel_matrix[0] /
+ 1000.0);
+ }
+ else
+ {
+ vals->width = 0;
+ *sWidth = 0;
+ }
+ FontComputeInfoAccelerators (pfi);
+
+ if (pfi->defaultCh != (unsigned short) NO_SUCH_CHAR) {
+ unsigned int r,
+ c,
+ cols;
+
+ r = pfi->defaultCh >> 8;
+ c = pfi->defaultCh & 0xFF;
+ if (pfi->firstRow <= r && r <= pfi->lastRow &&
+ pfi->firstCol <= c && c <= pfi->lastCol) {
+ cols = pfi->lastCol - pfi->firstCol + 1;
+ r = r - pfi->firstRow;
+ c = c - pfi->firstCol;
+ bitmapFont->pDefault =
+ ACCESSENCODING(bitmapFont->encoding, r * cols + c);
+ }
+ }
+
+ *newWidthMult = xmult;
+ *newHeightMult = ymult;
+ return pf;
+bail:
+ if (pf)
+ xfree(pf);
+ if (bitmapFont) {
+ xfree(bitmapFont->metrics);
+ xfree(bitmapFont->ink_metrics);
+ xfree(bitmapFont->bitmaps);
+ if(bitmapFont->encoding)
+ for(i=0; i<NUM_SEGMENTS(nchars); i++)
+ xfree(bitmapFont->encoding[i]);
+ xfree(bitmapFont->encoding);
+ }
+ return NULL;
+}
+
+static void
+ScaleBitmap(FontPtr pFont, CharInfoPtr opci, CharInfoPtr pci,
+ double *inv_xform, double widthMult, double heightMult)
+{
+ register char *bitmap, /* The bits */
+ *newBitmap;
+ register int bpr, /* Padding information */
+ newBpr;
+ int width, /* Extents information */
+ height,
+ newWidth,
+ newHeight;
+ register int row, /* Loop variables */
+ col;
+ INT32 deltaX, /* Increments for resampling loop */
+ deltaY;
+ INT32 xValue, /* Subscripts for resampling loop */
+ yValue;
+ double point[2];
+ unsigned char *char_grayscale = 0;
+ INT32 *diffusion_workspace = NULL, *thisrow = NULL,
+ *nextrow = NULL, pixmult = 0;
+ int box_x = 0, box_y = 0;
+
+ static unsigned char masklsb[] =
+ { 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 };
+ static unsigned char maskmsb[] =
+ { 0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1 };
+ unsigned char *mask = (pFont->bit == LSBFirst ? masklsb : maskmsb);
+
+
+ bitmap = opci->bits;
+ newBitmap = pci->bits;
+ width = GLYPHWIDTHPIXELS(opci);
+ height = GLYPHHEIGHTPIXELS(opci);
+ newWidth = GLYPHWIDTHPIXELS(pci);
+ newHeight = GLYPHHEIGHTPIXELS(pci);
+ if (!newWidth || !newHeight || !width || !height)
+ return;
+
+ bpr = BYTES_PER_ROW(width, pFont->glyph);
+ newBpr = BYTES_PER_ROW(newWidth, pFont->glyph);
+
+ if (widthMult > 0.0 && heightMult > 0.0 &&
+ (widthMult < 1.0 || heightMult < 1.0))
+ {
+ /* We are reducing in one or both dimensions. In an attempt to
+ reduce aliasing, we'll antialias by passing the original
+ glyph through a low-pass box filter (which results in a
+ grayscale image), then use error diffusion to create bitonal
+ output in the resampling loop. */
+
+ /* First compute the sizes of the box filter */
+ widthMult = ceil(1.0 / widthMult);
+ heightMult = ceil(1.0 / heightMult);
+ box_x = width / 2;
+ box_y = height / 2;
+ if (widthMult < (double)box_x) box_x = (int)widthMult;
+ if (heightMult < (double)box_y) box_y = (int)heightMult;
+ /* The pixmult value (below) is used to darken the image before
+ we perform error diffusion: a necessary concession to the
+ fact that it's very difficult to generate readable halftoned
+ glyphs. The degree of darkening is proportional to the size
+ of the blurring filter, hence inversely proportional to the
+ darkness of the lightest gray that results from antialiasing.
+ The result is that characters that exercise this logic (those
+ generated by reducing from a larger source font) tend to err
+ on the side of being too bold instead of being too light to
+ be readable. */
+ pixmult = box_x * box_y * 192;
+
+ if (box_x > 1 || box_y > 1)
+ {
+ /* Looks like we need to anti-alias. Create a workspace to
+ contain the grayscale character plus an additional row and
+ column for scratch */
+ char_grayscale =
+ (unsigned char *)xalloc((width + 1) * (height + 1));
+ if (char_grayscale)
+ {
+ diffusion_workspace =
+ (INT32 *)xalloc((newWidth + 2) * 2 * sizeof(int));
+ if (!diffusion_workspace)
+ {
+ fprintf(stderr, "Warning: Couldn't allocate diffusion"
+ " workspace (%ld)\n",
+ (newWidth + 2) * 2 * (unsigned long)sizeof(int));
+ xfree(char_grayscale);
+ char_grayscale = (unsigned char *)0;
+ }
+ /* Initialize our error diffusion workspace for later use */
+ bzero((char *)diffusion_workspace + sizeof(INT32),
+ (newWidth + 3) * sizeof(int));
+ thisrow = diffusion_workspace + 1;
+ nextrow = diffusion_workspace + newWidth + 3;
+ } else {
+ fprintf(stderr, "Warning: Couldn't allocate character grayscale (%d)\n", (width + 1) * (height + 1));
+ }
+ }
+ }
+
+ if (char_grayscale)
+ {
+ /* We will be doing antialiasing. First copy the bitmap into
+ our buffer, mapping input range [0,1] to output range
+ [0,255]. */
+ register unsigned char *srcptr, *dstptr;
+ srcptr = (unsigned char *)bitmap;
+ dstptr = char_grayscale;
+ for (row = 0; row < height; row++)
+ {
+ for (col = 0; col < width; col++)
+ *dstptr++ = (srcptr[col >> 3] & mask[col & 0x7]) ? 255 : 0;
+ srcptr += bpr; /* On to next row of source */
+ dstptr++; /* Skip scratch column in dest */
+ }
+ if (box_x > 1)
+ {
+ /* Our box filter has a width > 1... let's filter the rows */
+
+ int right_width = box_x / 2;
+ int left_width = box_x - right_width - 1;
+
+ for (row = 0; row < height; row++)
+ {
+ int sum = 0;
+ int left_size = 0, right_size = 0;
+
+ srcptr = char_grayscale + (width + 1) * row;
+ dstptr = char_grayscale + (width + 1) * height; /* scratch */
+
+ /* We've computed the shape of our full box filter. Now
+ compute the right-hand part of the moving sum */
+ for (right_size = 0; right_size < right_width; right_size++)
+ sum += srcptr[right_size];
+
+ /* Now start moving the sum, growing the box filter, and
+ dropping averages into our scratch buffer */
+ for (left_size = 0; left_size < left_width; left_size++)
+ {
+ sum += srcptr[right_width];
+ *dstptr++ = sum / (left_size + right_width + 1);
+ srcptr++;
+ }
+
+ /* The box filter has reached full width... continue
+ computation of moving average until the right side
+ hits the wall. */
+ for (col = left_size; col + right_size < width; col++)
+ {
+ sum += srcptr[right_width];
+ *dstptr++ = sum / box_x;
+ sum -= srcptr[-left_width];
+ srcptr++;
+ }
+
+ /* Collapse the right side of the box filter */
+ for (; right_size > 0; right_size--)
+ {
+ *dstptr++ = sum / (left_width + right_size);
+ sum -= srcptr[-left_width];
+ srcptr++;
+ }
+
+ /* Done with the row... copy dest back over source */
+ memmove(char_grayscale + (width + 1) * row,
+ char_grayscale + (width + 1) * height,
+ width);
+ }
+ }
+ if (box_y > 1)
+ {
+ /* Our box filter has a height > 1... let's filter the columns */
+
+ int bottom_height = box_y / 2;
+ int top_height = box_y - bottom_height - 1;
+
+ for (col = 0; col < width; col++)
+ {
+ int sum = 0;
+ int top_size = 0, bottom_size = 0;
+
+ srcptr = char_grayscale + col;
+ dstptr = char_grayscale + width; /* scratch */
+
+ /* We've computed the shape of our full box filter. Now
+ compute the bottom part of the moving sum */
+ for (bottom_size = 0;
+ bottom_size < bottom_height;
+ bottom_size++)
+ sum += srcptr[bottom_size * (width + 1)];
+
+ /* Now start moving the sum, growing the box filter, and
+ dropping averages into our scratch buffer */
+ for (top_size = 0; top_size < top_height; top_size++)
+ {
+ sum += srcptr[bottom_height * (width + 1)];
+ *dstptr = sum / (top_size + bottom_height + 1);
+ dstptr += width + 1;
+ srcptr += width + 1;
+ }
+
+ /* The box filter has reached full height... continue
+ computation of moving average until the bottom
+ hits the wall. */
+ for (row = top_size; row + bottom_size < height; row++)
+ {
+ sum += srcptr[bottom_height * (width + 1)];
+ *dstptr = sum / box_y;
+ dstptr += width + 1;
+ sum -= srcptr[-top_height * (width + 1)];
+ srcptr += width + 1;
+ }
+
+ /* Collapse the bottom of the box filter */
+ for (; bottom_size > 0; bottom_size--)
+ {
+ *dstptr = sum / (top_height + bottom_size);
+ dstptr += width + 1;
+ sum -= srcptr[-top_height * (width + 1)];
+ srcptr += width + 1;
+ }
+
+ /* Done with the column... copy dest back over source */
+
+ dstptr = char_grayscale + col;
+ srcptr = char_grayscale + width; /* scratch */
+ for (row = 0; row < height; row++)
+ {
+ *dstptr = *srcptr;
+ dstptr += width + 1;
+ srcptr += width + 1;
+ }
+ }
+ }
+
+ /* Increase the grayvalue to increase ink a bit */
+ srcptr = char_grayscale;
+ for (row = 0; row < height; row++)
+ {
+ for (col = 0; col < width; col++)
+ {
+ register int pixvalue = (int)*srcptr * pixmult / 256;
+ if (pixvalue > 255) pixvalue = 255;
+ *srcptr = pixvalue;
+ srcptr++;
+ }
+ srcptr++;
+ }
+ }
+
+ /* Compute the increment values for the resampling loop */
+ TRANSFORM_POINT(inv_xform, 1, 0, point);
+ deltaX = (INT32)(point[0] * 65536.0);
+ deltaY = (INT32)(-point[1] * 65536.0);
+
+ /* Resampling loop: resamples original glyph for generation of new
+ glyph in transformed coordinate system. */
+
+ for (row = 0; row < newHeight; row++)
+ {
+ /* Compute inverse transformation for start of this row */
+ TRANSFORM_POINT(inv_xform,
+ (double)(pci->metrics.leftSideBearing) + .5,
+ (double)(pci->metrics.ascent - row) - .5,
+ point);
+
+ /* Adjust for coordinate system to get resampling point */
+ point[0] -= opci->metrics.leftSideBearing;
+ point[1] = opci->metrics.ascent - point[1];
+
+ /* Convert to integer coordinates */
+ xValue = (INT32)(point[0] * 65536.0);
+ yValue = (INT32)(point[1] * 65536.0);
+
+ if (char_grayscale)
+ {
+ INT32 *temp;
+ for (col = 0; col < newWidth; col++)
+ {
+ register int x = xValue >> 16, y = yValue >> 16;
+ int pixvalue, error;
+
+ pixvalue = ((x >= 0 && x < width && y >= 0 && y < height) ?
+ char_grayscale[x + y * (width + 1)] : 0) +
+ thisrow[col] / 16;
+ if (pixvalue > 255) pixvalue = 255;
+ else if (pixvalue < 0) pixvalue = 0;
+
+ /* Choose the bit value and set resulting error value */
+ if (pixvalue >= 128)
+ {
+ newBitmap[(col >> 3) + row * newBpr] |= mask[col & 0x7];
+ error = pixvalue - 255;
+ }
+ else
+ error = -pixvalue;
+
+ /* Diffuse the error */
+ thisrow[col + 1] += error * 7;
+ nextrow[col - 1] += error * 3;
+ nextrow[col] += error * 5;
+ nextrow[col + 1] = error;
+
+ xValue += deltaX;
+ yValue += deltaY;
+ }
+
+ /* Add in error values that fell off either end */
+ nextrow[0] += nextrow[-1];
+ nextrow[newWidth - 2] += thisrow[newWidth];
+ nextrow[newWidth - 1] += nextrow[newWidth];
+ nextrow[newWidth] = 0;
+
+ temp = nextrow;
+ nextrow = thisrow;
+ thisrow = temp;
+ nextrow[-1] = nextrow[0] = 0;
+ }
+ else
+ {
+ for (col = 0; col < newWidth; col++)
+ {
+ register int x = xValue >> 16, y = yValue >> 16;
+
+ if (x >= 0 && x < width && y >= 0 && y < height)
+ {
+ /* Use point-sampling for rescaling. */
+
+ if (bitmap[(x >> 3) + y * bpr] & mask[x & 0x7])
+ newBitmap[(col >> 3) + row * newBpr] |= mask[col & 0x7];
+ }
+
+ xValue += deltaX;
+ yValue += deltaY;
+ }
+ }
+ }
+
+
+ if (char_grayscale)
+ {
+ xfree(char_grayscale);
+ xfree(diffusion_workspace);
+ }
+}
+
+static FontPtr
+BitmapScaleBitmaps(FontPtr pf, /* scaled font */
+ FontPtr opf, /* originating font */
+ double widthMult, /* glyphs width scale factor */
+ double heightMult, /* glyphs height scale factor */
+ FontScalablePtr vals)
+{
+ register int i;
+ int nchars = 0;
+ char *glyphBytes;
+ BitmapFontPtr bitmapFont,
+ obitmapFont;
+ CharInfoPtr pci,
+ opci;
+ FontInfoPtr pfi;
+ int glyph;
+ unsigned bytestoalloc = 0;
+ int firstCol, lastCol, firstRow, lastRow;
+
+ double xform[4], inv_xform[4];
+ double xmult, ymult;
+
+ bitmapFont = (BitmapFontPtr) pf->fontPrivate;
+ obitmapFont = (BitmapFontPtr) opf->fontPrivate;
+
+ if (!compute_xform_matrix(vals, widthMult, heightMult, xform,
+ inv_xform, &xmult, &ymult))
+ goto bail;
+
+ pfi = &pf->info;
+ firstCol = pfi->firstCol;
+ lastCol = pfi->lastCol;
+ firstRow = pfi->firstRow;
+ lastRow = pfi->lastRow;
+
+ nchars = (lastRow - firstRow + 1) * (lastCol - firstCol + 1);
+ glyph = pf->glyph;
+ for (i = 0; i < nchars; i++)
+ {
+ if ((pci = ACCESSENCODING(bitmapFont->encoding, i)))
+ bytestoalloc += BYTES_FOR_GLYPH(pci, glyph);
+ }
+
+ /* Do we add the font malloc stuff for VALUE ADDED ? */
+ /* Will need to remember to free in the Unload routine */
+
+
+ bitmapFont->bitmaps = (char *) xalloc(bytestoalloc);
+ if (!bitmapFont->bitmaps) {
+ fprintf(stderr, "Error: Couldn't allocate bitmaps (%d)\n", bytestoalloc);
+ goto bail;
+ }
+ bzero(bitmapFont->bitmaps, bytestoalloc);
+
+ glyphBytes = bitmapFont->bitmaps;
+ for (i = 0; i < nchars; i++)
+ {
+ if ((pci = ACCESSENCODING(bitmapFont->encoding, i)) &&
+ (opci = ACCESSENCODING(obitmapFont->encoding, OLDINDEX(i))))
+ {
+ pci->bits = glyphBytes;
+ ScaleBitmap (pf, opci, pci, inv_xform,
+ widthMult, heightMult);
+ glyphBytes += BYTES_FOR_GLYPH(pci, glyph);
+ }
+ }
+ return pf;
+
+bail:
+ if (pf)
+ xfree(pf);
+ if (bitmapFont) {
+ xfree(bitmapFont->metrics);
+ xfree(bitmapFont->ink_metrics);
+ xfree(bitmapFont->bitmaps);
+ if(bitmapFont->encoding)
+ for(i=0; i<NUM_SEGMENTS(nchars); i++)
+ xfree(bitmapFont->encoding[i]);
+ xfree(bitmapFont->encoding);
+ }
+ return NULL;
+}
+
+static FontPtr
+PrinterScaleBitmaps(FontPtr pf, /* scaled font */
+ FontPtr opf, /* originating font */
+ double widthMult, /* glyphs width scale factor */
+ double heightMult, /* glyphs height scale factor */
+ FontScalablePtr vals)
+{
+ register int i;
+ int nchars = 0;
+ char *glyphBytes;
+ BitmapFontPtr bitmapFont,
+ obitmapFont;
+ CharInfoPtr pci;
+ FontInfoPtr pfi;
+ int glyph;
+ unsigned bytestoalloc = 0;
+ int firstCol, lastCol, firstRow, lastRow;
+
+ double xform[4], inv_xform[4];
+ double xmult, ymult;
+
+ bitmapFont = (BitmapFontPtr) pf->fontPrivate;
+ obitmapFont = (BitmapFontPtr) opf->fontPrivate;
+
+ if (!compute_xform_matrix(vals, widthMult, heightMult, xform,
+ inv_xform, &xmult, &ymult))
+ goto bail;
+
+ pfi = &pf->info;
+ firstCol = pfi->firstCol;
+ lastCol = pfi->lastCol;
+ firstRow = pfi->firstRow;
+ lastRow = pfi->lastRow;
+
+ nchars = (lastRow - firstRow + 1) * (lastCol - firstCol + 1);
+ glyph = pf->glyph;
+ for (i = 0; i < nchars; i++)
+ {
+ if ((pci = ACCESSENCODING(bitmapFont->encoding, i)))
+ bytestoalloc = MAX(bytestoalloc,BYTES_FOR_GLYPH(pci, glyph));
+ }
+
+ /* Do we add the font malloc stuff for VALUE ADDED ? */
+ /* Will need to remember to free in the Unload routine */
+
+
+ bitmapFont->bitmaps = (char *) xalloc(bytestoalloc);
+ if (!bitmapFont->bitmaps) {
+ fprintf(stderr, "Error: Couldn't allocate bitmaps (%d)\n", bytestoalloc);
+ goto bail;
+ }
+ bzero(bitmapFont->bitmaps, bytestoalloc);
+
+ glyphBytes = bitmapFont->bitmaps;
+ for (i = 0; i < nchars; i++)
+ {
+ if ((pci = ACCESSENCODING(bitmapFont->encoding, i)) &&
+ (ACCESSENCODING(obitmapFont->encoding, OLDINDEX(i))))
+ {
+ pci->bits = glyphBytes;
+ }
+ }
+ return pf;
+
+bail:
+ if (pf)
+ xfree(pf);
+ if (bitmapFont) {
+ xfree(bitmapFont->metrics);
+ xfree(bitmapFont->ink_metrics);
+ xfree(bitmapFont->bitmaps);
+ if(bitmapFont->encoding)
+ for(i=0; i<NUM_SEGMENTS(nchars); i++)
+ xfree(bitmapFont->encoding[i]);
+ xfree(bitmapFont->encoding);
+ }
+ return NULL;
+}
+
+#ifdef NOTDEF
+/*
+ * exported interfaces
+ */
+
+FontFileLoadName(FontFileDirPtr *dirs, int ndirs, char *name, FontPtr *pfont,
+ fsBitmapFormat format, fsBitmapFormatMask fmask)
+{
+ FontFileNamePtr fname;
+ char full_name[1024];
+ int ret = BadFontName;
+ int i;
+
+ i = 0;
+ while (i < ndirs) {
+ if (fname = FontFileFindNameInDir(dirs[i], name)) {
+ if (!fname->alias) {
+ if (!fname->font) {
+ strcpy(full_name, dirs[i]->dir);
+ strcat(full_name, fname->file);
+ ret = FontFileLoad(pfont, full_name, format, fmask);
+ if (ret == Successful) {
+ fname->font = *pfont;
+ (*pfont)->fpePrivate = (pointer) fname;
+ }
+ return ret;
+ }
+ *pfont = fname->font;
+ return Successful;
+ }
+ name = fname->file;
+ i = 0;
+ } else
+ i++;
+ }
+ return BadFontName;
+}
+#endif
+
+/* ARGSUSED */
+int
+BitmapOpenScalable (FontPathElementPtr fpe,
+ FontPtr *pFont,
+ int flags,
+ FontEntryPtr entry,
+ char *fileName, /* unused */
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font) /* We don't do licensing */
+{
+ FontScalableRec best;
+ FontPtr font = NullFont;
+ double dx, sdx,
+ dy, sdy,
+ savedX, savedY;
+ FontPropPtr props;
+ char *isStringProp;
+ int propCount;
+ int status;
+ long sWidth;
+
+ FontEntryPtr scaleFrom;
+ FontPathElementPtr scaleFPE;
+ FontPtr sourceFont;
+ char fontName[MAXFONTNAMELEN];
+
+ /* Can't deal with mix-endian fonts yet */
+
+#ifdef NOTDEF /* XXX need better test */
+ if ((format & BitmapFormatByteOrderMask) !=
+ (format & BitmapFormatBitOrderMask))
+ return NullFontFileName;
+#endif
+
+ /* Reject outrageously small font sizes to keep the math from
+ blowing up. */
+ if (get_matrix_vertical_component(vals->pixel_matrix) < 1.0 ||
+ get_matrix_horizontal_component(vals->pixel_matrix) < 1.0)
+ return BadFontName;
+
+ scaleFrom = (*find_scale[BitmapGetRenderIndex(entry->u.bitmap.renderer)])
+ (fpe, entry, vals, &best, &dx, &dy, &sdx, &sdy, &scaleFPE);
+
+ if (!scaleFrom)
+ return BadFontName;
+
+ status = FontFileOpenBitmap(scaleFPE, &sourceFont, LoadAll, scaleFrom,
+ format, fmask);
+
+ if (status != Successful)
+ return BadFontName;
+
+ if (!vals->width)
+ vals->width = best.width * dx;
+
+ /* Compute the scaled font */
+
+ savedX = dx;
+ savedY = dy;
+ font = ScaleFont(sourceFont, dx, dy, sdx, sdy, vals, &dx, &dy, &sWidth);
+ if (font)
+ font = (*scale[ BitmapGetRenderIndex(entry->u.bitmap.renderer) ])
+ (font, sourceFont, savedX, savedY, vals);
+
+ if (!font)
+ {
+ if (!sourceFont->refcnt)
+ FontFileCloseFont((FontPathElementPtr) 0, sourceFont);
+ return AllocError;
+ }
+
+ /* Prepare font properties for the new font */
+
+ strcpy (fontName, scaleFrom->name.name);
+ FontParseXLFDName (fontName, vals, FONT_XLFD_REPLACE_VALUE);
+
+ propCount = ComputeScaledProperties(&sourceFont->info, fontName, vals,
+ dx, dy, sdx, sdy, sWidth, &props,
+ &isStringProp);
+
+ if (!sourceFont->refcnt)
+ FontFileCloseFont((FontPathElementPtr) 0, sourceFont);
+
+ if (propCount && (!props || !isStringProp))
+ {
+ font->info.nprops = 0;
+ font->info.props = (FontPropPtr)0;
+ font->info.isStringProp = (char *)0;
+ bitmapUnloadScalable(font);
+ return AllocError;
+ }
+
+ font->info.props = props;
+ font->info.nprops = propCount;
+ font->info.isStringProp = isStringProp;
+
+ *pFont = font;
+ return Successful;
+}
+
+int
+BitmapGetInfoScalable (FontPathElementPtr fpe,
+ FontInfoPtr pFontInfo,
+ FontEntryPtr entry,
+ FontNamePtr fontName,
+ char *fileName,
+ FontScalablePtr vals)
+{
+ FontPtr pfont;
+ int flags = 0;
+ long format = 0; /* It doesn't matter what format for just info */
+ long fmask = 0;
+ int ret;
+
+ ret = BitmapOpenScalable(fpe, &pfont, flags, entry, fileName, vals,
+ format, fmask, NULL);
+ if (ret != Successful)
+ return ret;
+ *pFontInfo = pfont->info;
+
+ pfont->info.nprops = 0;
+ pfont->info.props = NULL;
+ pfont->info.isStringProp = NULL;
+
+ (*pfont->unload_font)(pfont);
+ return Successful;
+}
+
+static void
+bitmapUnloadScalable (FontPtr pFont)
+{
+ BitmapFontPtr bitmapFont;
+ FontInfoPtr pfi;
+ int i, nencoding;
+
+ bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
+ pfi = &pFont->info;
+ xfree (pfi->props);
+ xfree (pfi->isStringProp);
+ if(bitmapFont->encoding) {
+ nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
+ (pFont->info.lastRow - pFont->info.firstRow + 1);
+ for(i=0; i<NUM_SEGMENTS(nencoding); i++)
+ xfree(bitmapFont->encoding[i]);
+ }
+ xfree (bitmapFont->encoding);
+ xfree (bitmapFont->bitmaps);
+ xfree (bitmapFont->ink_metrics);
+ xfree (bitmapFont->metrics);
+ xfree (pFont->fontPrivate);
+ DestroyFontRec (pFont);
+}
diff --git a/nx-X11/lib/font/bitmap/fontink.c b/nx-X11/lib/font/bitmap/fontink.c
new file mode 100644
index 000000000..a9606f039
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/fontink.c
@@ -0,0 +1,219 @@
+/* $Xorg: fontink.c,v 1.4 2001/02/09 02:04:02 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.
+
+*/
+/* $XFree86: xc/lib/font/bitmap/fontink.c,v 1.6 2001/01/17 19:43:27 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/bitmap.h>
+#include <X11/fonts/bdfint.h>
+
+static unsigned char ink_mask_msb[8] = {
+ 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01,
+};
+
+static unsigned char ink_mask_lsb[8] = {
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
+};
+
+void
+FontCharInkMetrics(FontPtr pFont, CharInfoPtr pCI, xCharInfo *pInk)
+{
+ int leftBearing,
+ ascent,
+ descent;
+ register int vpos,
+ hpos,
+ bpos = 0;
+ int bitmapByteWidth,
+ bitmapByteWidthPadded;
+ int bitmapBitWidth;
+ int span;
+ register unsigned char *p;
+ unsigned char *ink_mask = 0;
+ register int bmax;
+ register unsigned char charbits;
+
+ if (pFont->bit == MSBFirst)
+ ink_mask = ink_mask_msb;
+ else if (pFont->bit == LSBFirst)
+ ink_mask = ink_mask_lsb;
+ pInk->characterWidth = pCI->metrics.characterWidth;
+ pInk->attributes = pCI->metrics.attributes;
+
+ leftBearing = pCI->metrics.leftSideBearing;
+ ascent = pCI->metrics.ascent;
+ descent = pCI->metrics.descent;
+ bitmapBitWidth = GLYPHWIDTHPIXELS(pCI);
+ bitmapByteWidth = GLYPHWIDTHBYTES(pCI);
+ bitmapByteWidthPadded = BYTES_PER_ROW(bitmapBitWidth, pFont->glyph);
+ span = bitmapByteWidthPadded - bitmapByteWidth;
+
+ p = (unsigned char *) pCI->bits;
+ for (vpos = descent + ascent; --vpos >= 0;) {
+ for (hpos = bitmapByteWidth; --hpos >= 0;) {
+ if (*p++ != 0)
+ goto found_ascent;
+ }
+ p += span;
+ }
+ /*
+ * special case -- font with no bits gets all zeros
+ */
+ pInk->leftSideBearing = leftBearing;
+ pInk->rightSideBearing = leftBearing;
+ pInk->ascent = 0;
+ pInk->descent = 0;
+ return;
+found_ascent:
+ pInk->ascent = vpos - descent + 1;
+
+ p = ((unsigned char *) pCI->bits) + bitmapByteWidthPadded *
+ (descent + ascent - 1) + bitmapByteWidth;
+
+ for (vpos = descent + ascent; --vpos >= 0;) {
+ for (hpos = bitmapByteWidth; --hpos >= 0;) {
+ if (*--p != 0)
+ goto found_descent;
+ }
+ p -= span;
+ }
+found_descent:
+ pInk->descent = vpos - ascent + 1;
+
+ bmax = 8;
+ for (hpos = 0; hpos < bitmapByteWidth; hpos++) {
+ charbits = 0;
+ p = (unsigned char *) pCI->bits + hpos;
+ for (vpos = descent + ascent; --vpos >= 0; p += bitmapByteWidthPadded)
+ charbits |= *p;
+ if (charbits) {
+ if (hpos == bitmapByteWidth - 1)
+ bmax = bitmapBitWidth - (hpos << 3);
+ p = ink_mask;
+ for (bpos = bmax; --bpos >= 0;) {
+ if (charbits & *p++)
+ goto found_left;
+ }
+ }
+ }
+found_left:
+ pInk->leftSideBearing = leftBearing + (hpos << 3) + bmax - bpos - 1;
+
+ bmax = bitmapBitWidth - ((bitmapByteWidth - 1) << 3);
+ for (hpos = bitmapByteWidth; --hpos >= 0;) {
+ charbits = 0;
+ p = (unsigned char *) pCI->bits + hpos;
+ for (vpos = descent + ascent; --vpos >= 0; p += bitmapByteWidthPadded)
+ charbits |= *p;
+ if (charbits) {
+ p = ink_mask + bmax;
+ for (bpos = bmax; --bpos >= 0;) {
+ if (charbits & *--p)
+ goto found_right;
+ }
+ }
+ bmax = 8;
+ }
+found_right:
+ pInk->rightSideBearing = leftBearing + (hpos << 3) + bpos + 1;
+}
+
+#define ISBITONMSB(x, line) ((line)[(x)/8] & (1 << (7-((x)%8))))
+#define SETBITMSB(x, line) ((line)[(x)/8] |= (1 << (7-((x)%8))))
+#define ISBITONLSB(x, line) ((line)[(x)/8] & (1 << ((x)%8)))
+#define SETBITLSB(x, line) ((line)[(x)/8] |= (1 << ((x)%8)))
+
+#define Min(a,b) ((a)<(b)?(a):(b))
+#define Max(a,b) ((a)>(b)?(a):(b))
+
+void
+FontCharReshape(FontPtr pFont, CharInfoPtr pSrc, CharInfoPtr pDst)
+{
+ int x,
+ y;
+ unsigned char *in_line,
+ *out_line;
+ unsigned char *oldglyph,
+ *newglyph;
+ int inwidth;
+ int outwidth,
+ outheight;
+ int out_bytes,
+ in_bytes;
+ int y_min,
+ y_max,
+ x_min,
+ x_max;
+
+ newglyph = (unsigned char *) pDst->bits;
+ outwidth = pDst->metrics.rightSideBearing - pDst->metrics.leftSideBearing;
+ outheight = pDst->metrics.descent + pDst->metrics.ascent;
+ out_bytes = BYTES_PER_ROW(outwidth, pFont->glyph);
+
+ oldglyph = (unsigned char *) pSrc->bits;
+ inwidth = pSrc->metrics.rightSideBearing - pSrc->metrics.leftSideBearing;
+ in_bytes = BYTES_PER_ROW(inwidth, pFont->glyph);
+
+ bzero(newglyph, out_bytes * outheight);
+ in_line = oldglyph;
+ out_line = newglyph;
+ y_min = Max(-pSrc->metrics.ascent, -pDst->metrics.ascent);
+ y_max = Min(pSrc->metrics.descent, pDst->metrics.descent);
+ x_min = Max(pSrc->metrics.leftSideBearing, pDst->metrics.leftSideBearing);
+ x_max = Min(pSrc->metrics.rightSideBearing, pDst->metrics.rightSideBearing);
+ in_line += (y_min + pSrc->metrics.ascent) * in_bytes;
+ out_line += (y_min + pDst->metrics.ascent) * out_bytes;
+ if (pFont->bit == MSBFirst) {
+ for (y = y_min; y < y_max; y++) {
+ for (x = x_min; x < x_max; x++) {
+ if (ISBITONMSB(x - pSrc->metrics.leftSideBearing, in_line))
+ SETBITMSB(x - pDst->metrics.leftSideBearing, out_line);
+ }
+ in_line += in_bytes;
+ out_line += out_bytes;
+ }
+ } else {
+ for (y = y_min; y < y_max; y++) {
+ for (x = x_min; x < x_max; x++) {
+ if (ISBITONLSB(x - pSrc->metrics.leftSideBearing, in_line))
+ SETBITLSB(x - pDst->metrics.leftSideBearing, out_line);
+ }
+ in_line += in_bytes;
+ out_line += out_bytes;
+ }
+ }
+}
diff --git a/nx-X11/lib/font/bitmap/module/Imakefile b/nx-X11/lib/font/bitmap/module/Imakefile
new file mode 100644
index 000000000..29a49c644
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/module/Imakefile
@@ -0,0 +1,45 @@
+XCOMM $XFree86: xc/lib/font/bitmap/module/Imakefile,v 1.5 1999/12/03 19:17:18 eich Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+ INCLUDES = -I$(FONTINCSRC) -I../../include -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I../
+ HEADERS =
+ DEFINES = -DFONTMODULE -DBDFFORMAT -DSNFFORMAT -DPCFFORMAT
+
+#ifdef FontFormatDefines
+ FORMAT_DEFS = FontFormatDefines
+#endif
+#if GzipFontCompression
+ GZIP_DEFS = -DX_GZIP_FONT_COMPRESSION
+#endif
+
+ SRCS = bdfread.c bdfutils.c bitmap.c bitmaputil.c bitscale.c \
+ bitmapfunc.c pcfread.c pcfwrite.c snfread.c \
+ fontink.c bitmapmod.c
+
+ OBJS = bdfread.o bdfutils.o bitmap.o bitmaputil.o bitscale.o \
+ bitmapfunc.o pcfread.o pcfwrite.o snfread.o \
+ fontink.o bitmapmod.o
+
+SpecialCObjectRule(bitmapfunc,$(ICONFIGFILES),$(GZIP_DEFS))
+
+LinkSourceFile(bdfread.c,..)
+LinkSourceFile(bdfutils.c,..)
+LinkSourceFile(bitmap.c,..)
+LinkSourceFile(bitmaputil.c,..)
+LinkSourceFile(bitscale.c,..)
+LinkSourceFile(bitmapfunc.c,..)
+LinkSourceFile(pcfread.c,..)
+LinkSourceFile(pcfwrite.c,..)
+LinkSourceFile(snfread.c,..)
+LinkSourceFile(fontink.c,..)
+
+ModuleObjectRule()
+LibraryModuleTarget(bitmap,$(OBJS))
+InstallLibraryModule(bitmap,$(MODULEDIR),fonts)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(bitmap,$(DRIVERSDKMODULEDIR),fonts)
diff --git a/nx-X11/lib/font/bitmap/module/bitmapmod.c b/nx-X11/lib/font/bitmap/module/bitmapmod.c
new file mode 100644
index 000000000..0ae9ff7ad
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/module/bitmapmod.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * XFREE86 PROJECT 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 XFree86 Project 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
+ * XFree86 Project.
+ */
+/* $XFree86: xc/lib/font/bitmap/module/bitmapmod.c,v 1.7 1999/01/26 05:53:47 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/Xdefs.h>
+
+#include <X11/fonts/fontmod.h>
+#include "xf86Module.h"
+
+static MODULESETUPPROTO(bitmapSetup);
+
+ /*
+ * This is the module data function that is accessed when loading
+ * libbitmap as a module.
+ */
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "bitmap",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_FONT, /* Font module */
+ ABI_FONT_VERSION,
+ MOD_CLASS_FONT,
+ {0,0,0,0} /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData bitmapModuleData = { &VersRec, bitmapSetup, NULL };
+
+extern void BitmapRegisterFontFileFunctions(void);
+
+FontModule bitmapModule = {
+ BitmapRegisterFontFileFunctions,
+ "Bitmap",
+ NULL
+};
+
+static pointer
+bitmapSetup(pointer mod, pointer opts, int *errmaj, int *errmin)
+{
+ bitmapModule.module = mod;
+ LoadFont(&bitmapModule);
+
+ /* Need a non-NULL return */
+ return (pointer)1;
+}
diff --git a/nx-X11/lib/font/bitmap/pcf.h b/nx-X11/lib/font/bitmap/pcf.h
new file mode 100644
index 000000000..33b0ceff1
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/pcf.h
@@ -0,0 +1,100 @@
+/* $Xorg: pcf.h,v 1.4 2001/02/09 02:04:02 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/bitmap/pcf.h,v 1.4 2001/12/14 19:56:47 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifndef _PCF_H_
+#define _PCF_H_
+
+/*
+ * Information used to read/write PCF fonts
+ */
+
+typedef struct _PCFTable {
+ CARD32 type;
+ CARD32 format;
+ CARD32 size;
+ CARD32 offset;
+} PCFTableRec, *PCFTablePtr;
+
+#define PCF_FILE_VERSION (('p'<<24)|('c'<<16)|('f'<<8)|1)
+#define PCF_FORMAT_MASK 0xffffff00
+
+#define PCF_DEFAULT_FORMAT 0x00000000
+#define PCF_INKBOUNDS 0x00000200
+#define PCF_ACCEL_W_INKBOUNDS 0x00000100
+#define PCF_COMPRESSED_METRICS 0x00000100
+
+#define PCF_FORMAT_MATCH(a,b) (((a)&PCF_FORMAT_MASK) == ((b)&PCF_FORMAT_MASK))
+
+#define PCF_GLYPH_PAD_MASK (3<<0)
+#define PCF_BYTE_MASK (1<<2)
+#define PCF_BIT_MASK (1<<3)
+#define PCF_SCAN_UNIT_MASK (3<<4)
+
+#define PCF_BYTE_ORDER(f) (((f) & PCF_BYTE_MASK)?MSBFirst:LSBFirst)
+#define PCF_BIT_ORDER(f) (((f) & PCF_BIT_MASK)?MSBFirst:LSBFirst)
+#define PCF_GLYPH_PAD_INDEX(f) ((f) & PCF_GLYPH_PAD_MASK)
+#define PCF_GLYPH_PAD(f) (1<<PCF_GLYPH_PAD_INDEX(f))
+#define PCF_SCAN_UNIT_INDEX(f) (((f) & PCF_SCAN_UNIT_MASK) >> 4)
+#define PCF_SCAN_UNIT(f) (1<<PCF_SCAN_UNIT_INDEX(f))
+#define PCF_FORMAT_BITS(f) ((f) & (PCF_GLYPH_PAD_MASK|PCF_BYTE_MASK|PCF_BIT_MASK|PCF_SCAN_UNIT_MASK))
+
+#define PCF_SIZE_TO_INDEX(s) ((s) == 4 ? 2 : (s) == 2 ? 1 : 0)
+#define PCF_INDEX_TO_SIZE(b) (1<<b)
+
+#define PCF_FORMAT(bit,byte,glyph,scan) (\
+ (PCF_SIZE_TO_INDEX(scan) << 4) | \
+ (((bit) == MSBFirst ? 1 : 0) << 3) | \
+ (((byte) == MSBFirst ? 1 : 0) << 2) | \
+ (PCF_SIZE_TO_INDEX(glyph) << 0))
+
+#define PCF_PROPERTIES (1<<0)
+#define PCF_ACCELERATORS (1<<1)
+#define PCF_METRICS (1<<2)
+#define PCF_BITMAPS (1<<3)
+#define PCF_INK_METRICS (1<<4)
+#define PCF_BDF_ENCODINGS (1<<5)
+#define PCF_SWIDTHS (1<<6)
+#define PCF_GLYPH_NAMES (1<<7)
+#define PCF_BDF_ACCELERATORS (1<<8)
+
+extern int pcfReadFont ( FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan );
+extern int pcfReadFontInfo ( FontInfoPtr pFontInfo, FontFilePtr file );
+extern int pmfReadFont ( FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan );
+extern int pcfWriteFont ( FontPtr pFont, FontFilePtr file );
+extern void pcfError ( const char *, ... );
+
+#endif /* _PCF_H_ */
diff --git a/nx-X11/lib/font/bitmap/pcfread.c b/nx-X11/lib/font/bitmap/pcfread.c
new file mode 100644
index 000000000..75916dae8
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/pcfread.c
@@ -0,0 +1,997 @@
+/* $Xorg: pcfread.c,v 1.5 2001/02/09 02:04:02 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.
+
+*/
+/* $XFree86: xc/lib/font/bitmap/pcfread.c,v 1.21 2003/11/17 22:20:22 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/bitmap.h>
+#include <X11/fonts/pcf.h>
+
+#ifndef MAX
+#define MAX(a,b) (((a)>(b)) ? a : b)
+#endif
+
+#include <stdarg.h>
+
+void
+pcfError(const char* message, ...)
+{
+ va_list args;
+
+ va_start(args, message);
+
+ fprintf(stderr, "PCF Error: ");
+ vfprintf(stderr, message, args);
+ va_end(args);
+}
+
+/* Read PCF font files */
+
+static void pcfUnloadFont ( FontPtr pFont );
+static int position;
+
+
+#define IS_EOF(file) ((file)->eof == BUFFILEEOF)
+
+#define FONT_FILE_GETC_ERR(f) (tmp = FontFileGetc(f), BAIL_ON_EOF)
+
+static int
+pcfGetLSB32(FontFilePtr file)
+{
+ int c;
+
+ c = FontFileGetc(file);
+ c |= FontFileGetc(file) << 8;
+ c |= FontFileGetc(file) << 16;
+ c |= FontFileGetc(file) << 24;
+ position += 4;
+ return c;
+}
+
+static int
+pcfGetINT32(FontFilePtr file, CARD32 format)
+{
+ int c;
+
+ if (PCF_BYTE_ORDER(format) == MSBFirst) {
+ c = FontFileGetc(file) << 24;
+ c |= FontFileGetc(file) << 16;
+ c |= FontFileGetc(file) << 8;
+ c |= FontFileGetc(file);
+ } else {
+ c = FontFileGetc(file);
+ c |= FontFileGetc(file) << 8;
+ c |= FontFileGetc(file) << 16;
+ c |= FontFileGetc(file) << 24;
+ }
+ position += 4;
+ return c;
+}
+
+static int
+pcfGetINT16(FontFilePtr file, CARD32 format)
+{
+ int c;
+
+ if (PCF_BYTE_ORDER(format) == MSBFirst) {
+ c = FontFileGetc(file) << 8;
+ c |= FontFileGetc(file);
+ } else {
+ c = FontFileGetc(file);
+ c |= FontFileGetc(file) << 8;
+ }
+ position += 2;
+ return c;
+}
+
+#define pcfGetINT8(file, format) (position++, FontFileGetc(file))
+
+static PCFTablePtr
+pcfReadTOC(FontFilePtr file, int *countp)
+{
+ CARD32 version;
+ PCFTablePtr tables;
+ int count;
+ int i;
+
+ position = 0;
+ version = pcfGetLSB32(file);
+ if (version != PCF_FILE_VERSION)
+ return (PCFTablePtr) NULL;
+ count = pcfGetLSB32(file);
+ if (IS_EOF(file)) return (PCFTablePtr) NULL;
+ tables = (PCFTablePtr) xalloc(count * sizeof(PCFTableRec));
+ if (!tables) {
+ pcfError("pcfReadTOC(): Couldn't allocate tables (%d*%d)\n", count, sizeof(PCFTableRec));
+ return (PCFTablePtr) NULL;
+ }
+ for (i = 0; i < count; i++) {
+ tables[i].type = pcfGetLSB32(file);
+ tables[i].format = pcfGetLSB32(file);
+ tables[i].size = pcfGetLSB32(file);
+ tables[i].offset = pcfGetLSB32(file);
+ if (IS_EOF(file)) goto Bail;
+ }
+
+ *countp = count;
+ return tables;
+
+ Bail:
+ xfree(tables);
+ return (PCFTablePtr) NULL;
+}
+
+/*
+ * PCF supports two formats for metrics, both the regular
+ * jumbo size, and 'lite' metrics, which are useful
+ * for most fonts which have even vaguely reasonable
+ * metrics
+ */
+
+static Bool
+pcfGetMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
+{
+ metric->leftSideBearing = pcfGetINT16(file, format);
+ metric->rightSideBearing = pcfGetINT16(file, format);
+ metric->characterWidth = pcfGetINT16(file, format);
+ metric->ascent = pcfGetINT16(file, format);
+ metric->descent = pcfGetINT16(file, format);
+ metric->attributes = pcfGetINT16(file, format);
+ if (IS_EOF(file)) return FALSE;
+
+ return TRUE;
+}
+
+static Bool
+pcfGetCompressedMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
+{
+ metric->leftSideBearing = pcfGetINT8(file, format) - 0x80;
+ metric->rightSideBearing = pcfGetINT8(file, format) - 0x80;
+ metric->characterWidth = pcfGetINT8(file, format) - 0x80;
+ metric->ascent = pcfGetINT8(file, format) - 0x80;
+ metric->descent = pcfGetINT8(file, format) - 0x80;
+ metric->attributes = 0;
+ if (IS_EOF(file)) return FALSE;
+
+ return TRUE;
+}
+
+/*
+ * Position the file to the begining of the specified table
+ * in the font file
+ */
+static Bool
+pcfSeekToType(FontFilePtr file, PCFTablePtr tables, int ntables,
+ CARD32 type, CARD32 *formatp, CARD32 *sizep)
+{
+ int i;
+
+ for (i = 0; i < ntables; i++)
+ if (tables[i].type == type) {
+ if (position > tables[i].offset)
+ return FALSE;
+ if (!FontFileSkip(file, tables[i].offset - position))
+ return FALSE;
+ position = tables[i].offset;
+ *sizep = tables[i].size;
+ *formatp = tables[i].format;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static Bool
+pcfHasType (PCFTablePtr tables, int ntables, CARD32 type)
+{
+ int i;
+
+ for (i = 0; i < ntables; i++)
+ if (tables[i].type == type)
+ return TRUE;
+ return FALSE;
+}
+
+/*
+ * pcfGetProperties
+ *
+ * Reads the font properties from the font file, filling in the FontInfo rec
+ * supplied. Used by by both ReadFont and ReadFontInfo routines.
+ */
+
+static Bool
+pcfGetProperties(FontInfoPtr pFontInfo, FontFilePtr file,
+ PCFTablePtr tables, int ntables)
+{
+ FontPropPtr props = 0;
+ int nprops;
+ char *isStringProp = 0;
+ CARD32 format;
+ int i;
+ CARD32 size;
+ int string_size;
+ char *strings;
+
+ /* font properties */
+
+ if (!pcfSeekToType(file, tables, ntables, PCF_PROPERTIES, &format, &size))
+ goto Bail;
+ format = pcfGetLSB32(file);
+ if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
+ goto Bail;
+ nprops = pcfGetINT32(file, format);
+ if (IS_EOF(file)) goto Bail;
+ props = (FontPropPtr) xalloc(nprops * sizeof(FontPropRec));
+ if (!props) {
+ pcfError("pcfGetProperties(): Couldn't allocate props (%d*%d)\n", nprops, sizeof(FontPropRec));
+ goto Bail;
+ }
+ isStringProp = (char *) xalloc(nprops * sizeof(char));
+ if (!isStringProp) {
+ pcfError("pcfGetProperties(): Couldn't allocate isStringProp (%d*%d)\n", nprops, sizeof(char));
+ goto Bail;
+ }
+ for (i = 0; i < nprops; i++) {
+ props[i].name = pcfGetINT32(file, format);
+ isStringProp[i] = pcfGetINT8(file, format);
+ props[i].value = pcfGetINT32(file, format);
+ if (IS_EOF(file)) goto Bail;
+ }
+ /* pad the property array */
+ /*
+ * clever here - nprops is the same as the number of odd-units read, as
+ * only isStringProp are odd length
+ */
+ if (nprops & 3)
+ {
+ i = 4 - (nprops & 3);
+ (void)FontFileSkip(file, i);
+ position += i;
+ }
+ if (IS_EOF(file)) goto Bail;
+ string_size = pcfGetINT32(file, format);
+ if (IS_EOF(file)) goto Bail;
+ strings = (char *) xalloc(string_size);
+ if (!strings) {
+ pcfError("pcfGetProperties(): Couldn't allocate strings (%d)\n", string_size);
+ goto Bail;
+ }
+ FontFileRead(file, strings, string_size);
+ if (IS_EOF(file)) goto Bail;
+ position += string_size;
+ for (i = 0; i < nprops; i++) {
+ props[i].name = MakeAtom(strings + props[i].name,
+ strlen(strings + props[i].name), TRUE);
+ if (isStringProp[i]) {
+ props[i].value = MakeAtom(strings + props[i].value,
+ strlen(strings + props[i].value), TRUE);
+ }
+ }
+ xfree(strings);
+ pFontInfo->isStringProp = isStringProp;
+ pFontInfo->props = props;
+ pFontInfo->nprops = nprops;
+ return TRUE;
+Bail:
+ xfree(isStringProp);
+ xfree(props);
+ return FALSE;
+}
+
+
+/*
+ * pcfReadAccel
+ *
+ * Fill in the accelerator information from the font file; used
+ * to read both BDF_ACCELERATORS and old style ACCELERATORS
+ */
+
+static Bool
+pcfGetAccel(FontInfoPtr pFontInfo, FontFilePtr file,
+ PCFTablePtr tables, int ntables, CARD32 type)
+{
+ CARD32 format;
+ CARD32 size;
+
+ if (!pcfSeekToType(file, tables, ntables, type, &format, &size) ||
+ IS_EOF(file))
+ goto Bail;
+ format = pcfGetLSB32(file);
+ if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT) &&
+ !PCF_FORMAT_MATCH(format, PCF_ACCEL_W_INKBOUNDS))
+ {
+ goto Bail;
+ }
+ pFontInfo->noOverlap = pcfGetINT8(file, format);
+ pFontInfo->constantMetrics = pcfGetINT8(file, format);
+ pFontInfo->terminalFont = pcfGetINT8(file, format);
+ pFontInfo->constantWidth = pcfGetINT8(file, format);
+ pFontInfo->inkInside = pcfGetINT8(file, format);
+ pFontInfo->inkMetrics = pcfGetINT8(file, format);
+ pFontInfo->drawDirection = pcfGetINT8(file, format);
+ pFontInfo->anamorphic = FALSE;
+ pFontInfo->cachable = TRUE;
+ /* natural alignment */ pcfGetINT8(file, format);
+ pFontInfo->fontAscent = pcfGetINT32(file, format);
+ pFontInfo->fontDescent = pcfGetINT32(file, format);
+ pFontInfo->maxOverlap = pcfGetINT32(file, format);
+ if (IS_EOF(file)) goto Bail;
+ if (!pcfGetMetric(file, format, &pFontInfo->minbounds))
+ goto Bail;
+ if (!pcfGetMetric(file, format, &pFontInfo->maxbounds))
+ goto Bail;
+ if (PCF_FORMAT_MATCH(format, PCF_ACCEL_W_INKBOUNDS)) {
+ if (!pcfGetMetric(file, format, &pFontInfo->ink_minbounds))
+ goto Bail;
+ if (!pcfGetMetric(file, format, &pFontInfo->ink_maxbounds))
+ goto Bail;
+ } else {
+ pFontInfo->ink_minbounds = pFontInfo->minbounds;
+ pFontInfo->ink_maxbounds = pFontInfo->maxbounds;
+ }
+ return TRUE;
+Bail:
+ return FALSE;
+}
+
+int
+pcfReadFont(FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan)
+{
+ CARD32 format;
+ CARD32 size;
+ BitmapFontPtr bitmapFont = 0;
+ int i;
+ PCFTablePtr tables = 0;
+ int ntables;
+ int nmetrics;
+ int nbitmaps;
+ int sizebitmaps;
+ int nink_metrics;
+ CharInfoPtr metrics = 0;
+ xCharInfo *ink_metrics = 0;
+ char *bitmaps = 0;
+ CharInfoPtr **encoding = 0;
+ int nencoding = 0;
+ int encodingOffset;
+ CARD32 bitmapSizes[GLYPHPADOPTIONS];
+ CARD32 *offsets = 0;
+ Bool hasBDFAccelerators;
+
+ pFont->info.nprops = 0;
+ pFont->info.props = 0;
+ if (!(tables = pcfReadTOC(file, &ntables)))
+ goto Bail;
+
+ /* properties */
+
+ if (!pcfGetProperties(&pFont->info, file, tables, ntables))
+ goto Bail;
+
+ /* Use the old accelerators if no BDF accelerators are in the file */
+
+ hasBDFAccelerators = pcfHasType (tables, ntables, PCF_BDF_ACCELERATORS);
+ if (!hasBDFAccelerators)
+ if (!pcfGetAccel (&pFont->info, file, tables, ntables, PCF_ACCELERATORS))
+ goto Bail;
+
+ /* metrics */
+
+ if (!pcfSeekToType(file, tables, ntables, PCF_METRICS, &format, &size)) {
+ goto Bail;
+ }
+ format = pcfGetLSB32(file);
+ if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT) &&
+ !PCF_FORMAT_MATCH(format, PCF_COMPRESSED_METRICS)) {
+ goto Bail;
+ }
+ if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
+ nmetrics = pcfGetINT32(file, format);
+ else
+ nmetrics = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
+ metrics = (CharInfoPtr) xalloc(nmetrics * sizeof(CharInfoRec));
+ if (!metrics) {
+ pcfError("pcfReadFont(): Couldn't allocate metrics (%d*%d)\n", nmetrics, sizeof(CharInfoRec));
+ goto Bail;
+ }
+ for (i = 0; i < nmetrics; i++)
+ if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
+ if (!pcfGetMetric(file, format, &(metrics + i)->metrics))
+ goto Bail;
+ } else {
+ if (!pcfGetCompressedMetric(file, format, &(metrics + i)->metrics))
+ goto Bail;
+ }
+
+ /* bitmaps */
+
+ if (!pcfSeekToType(file, tables, ntables, PCF_BITMAPS, &format, &size))
+ goto Bail;
+ format = pcfGetLSB32(file);
+ if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
+ goto Bail;
+
+ nbitmaps = pcfGetINT32(file, format);
+ if (nbitmaps != nmetrics || IS_EOF(file))
+ goto Bail;
+
+ offsets = (CARD32 *) xalloc(nbitmaps * sizeof(CARD32));
+ if (!offsets) {
+ pcfError("pcfReadFont(): Couldn't allocate offsets (%d*%d)\n", nbitmaps, sizeof(CARD32));
+ goto Bail;
+ }
+ for (i = 0; i < nbitmaps; i++) {
+ offsets[i] = pcfGetINT32(file, format);
+ if (IS_EOF(file)) goto Bail;
+ }
+
+ for (i = 0; i < GLYPHPADOPTIONS; i++) {
+ bitmapSizes[i] = pcfGetINT32(file, format);
+ if (IS_EOF(file)) goto Bail;
+ }
+
+ sizebitmaps = bitmapSizes[PCF_GLYPH_PAD_INDEX(format)];
+ /* guard against completely empty font */
+ bitmaps = xalloc(sizebitmaps ? sizebitmaps : 1);
+ if (!bitmaps) {
+ pcfError("pcfReadFont(): Couldn't allocate bitmaps (%d)\n", sizebitmaps ? sizebitmaps : 1);
+ goto Bail;
+ }
+ FontFileRead(file, bitmaps, sizebitmaps);
+ if (IS_EOF(file)) goto Bail;
+ position += sizebitmaps;
+
+ if (PCF_BIT_ORDER(format) != bit)
+ BitOrderInvert((unsigned char *)bitmaps, sizebitmaps);
+ if ((PCF_BYTE_ORDER(format) == PCF_BIT_ORDER(format)) != (bit == byte)) {
+ switch (bit == byte ? PCF_SCAN_UNIT(format) : scan) {
+ case 1:
+ break;
+ case 2:
+ TwoByteSwap((unsigned char *)bitmaps, sizebitmaps);
+ break;
+ case 4:
+ FourByteSwap((unsigned char *)bitmaps, sizebitmaps);
+ break;
+ }
+ }
+ if (PCF_GLYPH_PAD(format) != glyph) {
+ char *padbitmaps;
+ int sizepadbitmaps;
+ int old,
+ new;
+ xCharInfo *metric;
+
+ sizepadbitmaps = bitmapSizes[PCF_SIZE_TO_INDEX(glyph)];
+ padbitmaps = (char *) xalloc(sizepadbitmaps);
+ if (!padbitmaps) {
+ pcfError("pcfReadFont(): Couldn't allocate padbitmaps (%d)\n", sizepadbitmaps);
+ goto Bail;
+ }
+ new = 0;
+ for (i = 0; i < nbitmaps; i++) {
+ old = offsets[i];
+ metric = &metrics[i].metrics;
+ offsets[i] = new;
+ new += RepadBitmap(bitmaps + old, padbitmaps + new,
+ PCF_GLYPH_PAD(format), glyph,
+ metric->rightSideBearing - metric->leftSideBearing,
+ metric->ascent + metric->descent);
+ }
+ xfree(bitmaps);
+ bitmaps = padbitmaps;
+ }
+ for (i = 0; i < nbitmaps; i++)
+ metrics[i].bits = bitmaps + offsets[i];
+
+ xfree(offsets);
+ offsets = NULL;
+
+ /* ink metrics ? */
+
+ ink_metrics = NULL;
+ if (pcfSeekToType(file, tables, ntables, PCF_INK_METRICS, &format, &size)) {
+ format = pcfGetLSB32(file);
+ if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT) &&
+ !PCF_FORMAT_MATCH(format, PCF_COMPRESSED_METRICS)) {
+ goto Bail;
+ }
+ if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
+ nink_metrics = pcfGetINT32(file, format);
+ else
+ nink_metrics = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
+ if (nink_metrics != nmetrics)
+ goto Bail;
+ ink_metrics = (xCharInfo *) xalloc(nink_metrics * sizeof(xCharInfo));
+ if (!ink_metrics) {
+ pcfError("pcfReadFont(): Couldn't allocate ink_metrics (%d*%d)\n", nink_metrics, sizeof(xCharInfo));
+ goto Bail;
+ }
+ for (i = 0; i < nink_metrics; i++)
+ if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
+ if (!pcfGetMetric(file, format, ink_metrics + i))
+ goto Bail;
+ } else {
+ if (!pcfGetCompressedMetric(file, format, ink_metrics + i))
+ goto Bail;
+ }
+ }
+
+ /* encoding */
+
+ if (!pcfSeekToType(file, tables, ntables, PCF_BDF_ENCODINGS, &format, &size))
+ goto Bail;
+ format = pcfGetLSB32(file);
+ if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
+ goto Bail;
+
+ pFont->info.firstCol = pcfGetINT16(file, format);
+ pFont->info.lastCol = pcfGetINT16(file, format);
+ pFont->info.firstRow = pcfGetINT16(file, format);
+ pFont->info.lastRow = pcfGetINT16(file, format);
+ pFont->info.defaultCh = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
+ if (pFont->info.firstCol > pFont->info.lastCol ||
+ pFont->info.firstRow > pFont->info.lastRow ||
+ pFont->info.lastCol-pFont->info.firstCol > 255) goto Bail;
+
+ nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
+ (pFont->info.lastRow - pFont->info.firstRow + 1);
+
+ encoding = (CharInfoPtr **) xcalloc(NUM_SEGMENTS(nencoding),
+ sizeof(CharInfoPtr*));
+ if (!encoding) {
+ pcfError("pcfReadFont(): Couldn't allocate encoding (%d*%d)\n", nencoding, sizeof(CharInfoPtr));
+ goto Bail;
+ }
+
+ pFont->info.allExist = TRUE;
+ for (i = 0; i < nencoding; i++) {
+ encodingOffset = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
+ if (encodingOffset == 0xFFFF) {
+ pFont->info.allExist = FALSE;
+ } else {
+ if(!encoding[SEGMENT_MAJOR(i)]) {
+ encoding[SEGMENT_MAJOR(i)]=
+ (CharInfoPtr*)xcalloc(BITMAP_FONT_SEGMENT_SIZE,
+ sizeof(CharInfoPtr));
+ if(!encoding[SEGMENT_MAJOR(i)])
+ goto Bail;
+ }
+ ACCESSENCODINGL(encoding, i) = metrics + encodingOffset;
+ }
+ }
+
+ /* BDF style accelerators (i.e. bounds based on encoded glyphs) */
+
+ if (hasBDFAccelerators)
+ if (!pcfGetAccel (&pFont->info, file, tables, ntables, PCF_BDF_ACCELERATORS))
+ goto Bail;
+
+ bitmapFont = (BitmapFontPtr) xalloc(sizeof *bitmapFont);
+ if (!bitmapFont) {
+ pcfError("pcfReadFont(): Couldn't allocate bitmapFont (%d)\n", sizeof *bitmapFont);
+ goto Bail;
+ }
+
+ bitmapFont->version_num = PCF_FILE_VERSION;
+ bitmapFont->num_chars = nmetrics;
+ bitmapFont->num_tables = ntables;
+ bitmapFont->metrics = metrics;
+ bitmapFont->ink_metrics = ink_metrics;
+ bitmapFont->bitmaps = bitmaps;
+ bitmapFont->encoding = encoding;
+ bitmapFont->pDefault = (CharInfoPtr) 0;
+ if (pFont->info.defaultCh != (unsigned short) NO_SUCH_CHAR) {
+ unsigned int r,
+ c,
+ cols;
+
+ r = pFont->info.defaultCh >> 8;
+ c = pFont->info.defaultCh & 0xFF;
+ if (pFont->info.firstRow <= r && r <= pFont->info.lastRow &&
+ pFont->info.firstCol <= c && c <= pFont->info.lastCol) {
+ cols = pFont->info.lastCol - pFont->info.firstCol + 1;
+ r = r - pFont->info.firstRow;
+ c = c - pFont->info.firstCol;
+ bitmapFont->pDefault = ACCESSENCODING(encoding, r * cols + c);
+ }
+ }
+ bitmapFont->bitmapExtra = (BitmapExtraPtr) 0;
+ pFont->fontPrivate = (pointer) bitmapFont;
+ pFont->get_glyphs = bitmapGetGlyphs;
+ pFont->get_metrics = bitmapGetMetrics;
+ pFont->unload_font = pcfUnloadFont;
+ pFont->unload_glyphs = NULL;
+ pFont->bit = bit;
+ pFont->byte = byte;
+ pFont->glyph = glyph;
+ pFont->scan = scan;
+ xfree(tables);
+ return Successful;
+Bail:
+ xfree(ink_metrics);
+ if(encoding) {
+ for(i=0; i<NUM_SEGMENTS(nencoding); i++)
+ xfree(encoding[i]);
+ }
+ xfree(encoding);
+ xfree(bitmaps);
+ xfree(metrics);
+ xfree(pFont->info.props);
+ pFont->info.nprops = 0;
+ pFont->info.props = 0;
+ xfree (pFont->info.isStringProp);
+ xfree(bitmapFont);
+ xfree(tables);
+ xfree(offsets);
+ return AllocError;
+}
+
+int
+pcfReadFontInfo(FontInfoPtr pFontInfo, FontFilePtr file)
+{
+ PCFTablePtr tables;
+ int ntables;
+ CARD32 format;
+ CARD32 size;
+ int nencoding;
+ Bool hasBDFAccelerators;
+
+ pFontInfo->isStringProp = NULL;
+ pFontInfo->props = NULL;
+ pFontInfo->nprops = 0;
+
+ if (!(tables = pcfReadTOC(file, &ntables)))
+ goto Bail;
+
+ /* properties */
+
+ if (!pcfGetProperties(pFontInfo, file, tables, ntables))
+ goto Bail;
+
+ /* Use the old accelerators if no BDF accelerators are in the file */
+
+ hasBDFAccelerators = pcfHasType (tables, ntables, PCF_BDF_ACCELERATORS);
+ if (!hasBDFAccelerators)
+ if (!pcfGetAccel (pFontInfo, file, tables, ntables, PCF_ACCELERATORS))
+ goto Bail;
+
+ /* encoding */
+
+ if (!pcfSeekToType(file, tables, ntables, PCF_BDF_ENCODINGS, &format, &size))
+ goto Bail;
+ format = pcfGetLSB32(file);
+ if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
+ goto Bail;
+
+ pFontInfo->firstCol = pcfGetINT16(file, format);
+ pFontInfo->lastCol = pcfGetINT16(file, format);
+ pFontInfo->firstRow = pcfGetINT16(file, format);
+ pFontInfo->lastRow = pcfGetINT16(file, format);
+ pFontInfo->defaultCh = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
+ if (pFontInfo->firstCol > pFontInfo->lastCol ||
+ pFontInfo->firstRow > pFontInfo->lastRow ||
+ pFontInfo->lastCol-pFontInfo->firstCol > 255) goto Bail;
+
+ nencoding = (pFontInfo->lastCol - pFontInfo->firstCol + 1) *
+ (pFontInfo->lastRow - pFontInfo->firstRow + 1);
+
+ pFontInfo->allExist = TRUE;
+ while (nencoding--) {
+ if (pcfGetINT16(file, format) == 0xFFFF)
+ pFontInfo->allExist = FALSE;
+ if (IS_EOF(file)) goto Bail;
+ }
+ if (IS_EOF(file)) goto Bail;
+
+ /* BDF style accelerators (i.e. bounds based on encoded glyphs) */
+
+ if (hasBDFAccelerators)
+ if (!pcfGetAccel (pFontInfo, file, tables, ntables, PCF_BDF_ACCELERATORS))
+ goto Bail;
+
+ xfree(tables);
+ return Successful;
+Bail:
+ pFontInfo->nprops = 0;
+ xfree (pFontInfo->props);
+ xfree (pFontInfo->isStringProp);
+ xfree(tables);
+ return AllocError;
+}
+
+static void
+pcfUnloadFont(FontPtr pFont)
+{
+ BitmapFontPtr bitmapFont;
+ int i,nencoding;
+
+ bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
+ xfree(bitmapFont->ink_metrics);
+ if(bitmapFont->encoding) {
+ nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
+ (pFont->info.lastRow - pFont->info.firstRow + 1);
+ for(i=0; i<NUM_SEGMENTS(nencoding); i++)
+ xfree(bitmapFont->encoding[i]);
+ }
+ xfree(bitmapFont->encoding);
+ xfree(bitmapFont->bitmaps);
+ xfree(bitmapFont->metrics);
+ xfree(pFont->info.isStringProp);
+ xfree(pFont->info.props);
+ xfree(bitmapFont);
+ DestroyFontRec(pFont);
+}
+
+int
+pmfReadFont(FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan)
+{
+ CARD32 format;
+ CARD32 size;
+ BitmapFontPtr bitmapFont = 0;
+ int i;
+ PCFTablePtr tables = 0;
+ int ntables;
+ int nmetrics;
+ int sizebitmaps;
+ int nink_metrics;
+ CharInfoPtr metrics = 0;
+ xCharInfo *ink_metrics = 0;
+ char *bitmaps = 0;
+ CharInfoPtr **encoding = 0;
+ int nencoding = 0;
+ int encodingOffset;
+ Bool hasBDFAccelerators;
+ CharInfoPtr pci;
+
+ pFont->info.nprops = 0;
+ pFont->info.props = 0;
+
+ if (!(tables = pcfReadTOC(file, &ntables)))
+ goto Bail;
+
+ /* properties */
+
+ if (!pcfGetProperties(&pFont->info, file, tables, ntables))
+ goto Bail;
+
+ /* Use the old accelerators if no BDF accelerators are in the file */
+
+ hasBDFAccelerators = pcfHasType (tables, ntables, PCF_BDF_ACCELERATORS);
+ if (!hasBDFAccelerators)
+ if (!pcfGetAccel (&pFont->info, file, tables, ntables, PCF_ACCELERATORS))
+ goto Bail;
+
+ /* metrics */
+
+ if (!pcfSeekToType(file, tables, ntables, PCF_METRICS, &format, &size)) {
+ goto Bail;
+ }
+ format = pcfGetLSB32(file);
+ if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT) &&
+ !PCF_FORMAT_MATCH(format, PCF_COMPRESSED_METRICS)) {
+ goto Bail;
+ }
+ if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
+ nmetrics = pcfGetINT32(file, format);
+ else
+ nmetrics = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
+ metrics = (CharInfoPtr) xalloc(nmetrics * sizeof(CharInfoRec));
+ if (!metrics) {
+ pcfError("pmfReadFont(): Couldn't allocate metrics (%d*%d)\n", nmetrics, sizeof(CharInfoRec));
+ goto Bail;
+ }
+ for (i = 0; i < nmetrics; i++)
+ if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
+ if (!pcfGetMetric(file, format, &(metrics + i)->metrics))
+ goto Bail;
+ } else {
+ if (!pcfGetCompressedMetric(file, format, &(metrics + i)->metrics))
+ goto Bail;
+ }
+
+ /* Set the bitmaps to all point to the same zero filled array
+ * that is the size of the largest bitmap.
+ */
+
+ pci = metrics;
+ sizebitmaps = 0;
+ for (i = 0; i < nmetrics; i++)
+ {
+ sizebitmaps = MAX(sizebitmaps,BYTES_FOR_GLYPH(pci, glyph));
+ pci++;
+ }
+
+#ifdef FONTMODULE
+ sizebitmaps = 1024; /* Default - we xalloc the size anyway */
+#else
+ sizebitmaps = BUFSIZ;
+#endif
+ /* guard against completely empty font */
+ bitmaps = (char *) xalloc(sizebitmaps);
+ if (!bitmaps) {
+ pcfError("pmfReadFont(): Couldn't allocate bitmaps (%d)\n", sizebitmaps);
+ goto Bail;
+ }
+
+ memset(bitmaps,0,sizebitmaps);
+ for (i = 0; i < nmetrics; i++)
+ metrics[i].bits = bitmaps;
+
+ /* ink metrics ? */
+
+ ink_metrics = NULL;
+ if (pcfSeekToType(file, tables, ntables, PCF_INK_METRICS, &format, &size)) {
+ format = pcfGetLSB32(file);
+ if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT) &&
+ !PCF_FORMAT_MATCH(format, PCF_COMPRESSED_METRICS)) {
+ goto Bail;
+ }
+ if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
+ nink_metrics = pcfGetINT32(file, format);
+ else
+ nink_metrics = pcfGetINT16(file, format);
+ if (nink_metrics != nmetrics)
+ goto Bail;
+ if (IS_EOF(file)) goto Bail;
+ ink_metrics = (xCharInfo *) xalloc(nink_metrics * sizeof(xCharInfo));
+ if (!ink_metrics) {
+ pcfError("pmfReadFont(): Couldn't allocate ink_metrics (%d*%d)\n", nink_metrics, sizeof(xCharInfo));
+ goto Bail;
+ }
+ for (i = 0; i < nink_metrics; i++)
+ if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
+ if (!pcfGetMetric(file, format, ink_metrics + i))
+ goto Bail;
+ } else {
+ if (!pcfGetCompressedMetric(file, format, ink_metrics + i))
+ goto Bail;
+ }
+ }
+
+ /* encoding */
+
+ if (!pcfSeekToType(file, tables, ntables, PCF_BDF_ENCODINGS, &format, &size))
+ goto Bail;
+ format = pcfGetLSB32(file);
+ if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
+ goto Bail;
+
+ pFont->info.firstCol = pcfGetINT16(file, format);
+ pFont->info.lastCol = pcfGetINT16(file, format);
+ pFont->info.firstRow = pcfGetINT16(file, format);
+ pFont->info.lastRow = pcfGetINT16(file, format);
+ pFont->info.defaultCh = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
+
+ nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
+ (pFont->info.lastRow - pFont->info.firstRow + 1);
+
+ encoding = (CharInfoPtr **) xcalloc(NUM_SEGMENTS(nencoding),
+ sizeof(CharInfoPtr*));
+ if (!encoding) {
+ pcfError("pmfReadFont(): Couldn't allocate encoding (%d*%d)\n", nencoding, sizeof(CharInfoPtr));
+ goto Bail;
+ }
+ pFont->info.allExist = TRUE;
+ for (i = 0; i < nencoding; i++) {
+ encodingOffset = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
+ if (encodingOffset == 0xFFFF) {
+ pFont->info.allExist = FALSE;
+ } else {
+ if(!encoding[SEGMENT_MAJOR(i)]) {
+ encoding[SEGMENT_MAJOR(i)]=
+ (CharInfoPtr*)xcalloc(BITMAP_FONT_SEGMENT_SIZE,
+ sizeof(CharInfoPtr));
+ if(!encoding[SEGMENT_MAJOR(i)])
+ goto Bail;
+ }
+ ACCESSENCODINGL(encoding, i) = metrics + encodingOffset;
+ }
+ }
+ if (IS_EOF(file)) goto Bail;
+
+ /* BDF style accelerators (i.e. bounds based on encoded glyphs) */
+
+ if (hasBDFAccelerators)
+ if (!pcfGetAccel (&pFont->info, file, tables, ntables, PCF_BDF_ACCELERATORS))
+ goto Bail;
+
+ bitmapFont = (BitmapFontPtr) xalloc(sizeof *bitmapFont);
+ if (!bitmapFont) {
+ pcfError("pmfReadFont(): Couldn't allocate bitmapFont (%d)\n", sizeof *bitmapFont);
+ goto Bail;
+ }
+
+ bitmapFont->version_num = PCF_FILE_VERSION;
+ bitmapFont->num_chars = nmetrics;
+ bitmapFont->num_tables = ntables;
+ bitmapFont->metrics = metrics;
+ bitmapFont->ink_metrics = ink_metrics;
+ bitmapFont->bitmaps = bitmaps;
+ bitmapFont->encoding = encoding;
+ bitmapFont->pDefault = (CharInfoPtr) 0;
+ if (pFont->info.defaultCh != (unsigned short) NO_SUCH_CHAR) {
+ unsigned int r,
+ c,
+ cols;
+
+ r = pFont->info.defaultCh >> 8;
+ c = pFont->info.defaultCh & 0xFF;
+ if (pFont->info.firstRow <= r && r <= pFont->info.lastRow &&
+ pFont->info.firstCol <= c && c <= pFont->info.lastCol) {
+ cols = pFont->info.lastCol - pFont->info.firstCol + 1;
+ r = r - pFont->info.firstRow;
+ c = c - pFont->info.firstCol;
+ bitmapFont->pDefault = ACCESSENCODING(encoding, r * cols + c);
+ }
+ }
+ bitmapFont->bitmapExtra = (BitmapExtraPtr) 0;
+ pFont->fontPrivate = (pointer) bitmapFont;
+ pFont->get_glyphs = bitmapGetGlyphs;
+ pFont->get_metrics = bitmapGetMetrics;
+ pFont->unload_font = pcfUnloadFont;
+ pFont->unload_glyphs = NULL;
+ pFont->bit = bit;
+ pFont->byte = byte;
+ pFont->glyph = glyph;
+ pFont->scan = scan;
+ xfree(tables);
+ return Successful;
+Bail:
+ xfree(ink_metrics);
+ if(encoding) {
+ for(i=0; i<NUM_SEGMENTS(nencoding); i++)
+ xfree(encoding[i]);
+ }
+ xfree(encoding);
+ xfree(bitmaps);
+ xfree(metrics);
+ xfree(pFont->info.props);
+ pFont->info.nprops = 0;
+ pFont->info.props = 0;
+ xfree (pFont->info.isStringProp);
+ xfree(bitmapFont);
+ xfree(tables);
+ return AllocError;
+}
diff --git a/nx-X11/lib/font/bitmap/pcfwrite.c b/nx-X11/lib/font/bitmap/pcfwrite.c
new file mode 100644
index 000000000..8d5e9425f
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/pcfwrite.c
@@ -0,0 +1,468 @@
+/* $Xorg: pcfwrite.c,v 1.5 2001/02/09 02:04:02 xorgcvs Exp $ */
+/*
+
+Copyright 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.
+
+*/
+/* $XFree86: xc/lib/font/bitmap/pcfwrite.c,v 1.11 2003/11/17 22:20:22 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/bitmap.h>
+#include <X11/fonts/pcf.h>
+
+/* Write PCF font files */
+
+static CARD32 current_position;
+
+static int
+pcfWrite(FontFilePtr file, char *b, int c)
+{
+ current_position += c;
+ return FontFileWrite(file, b, c);
+}
+
+static int
+pcfPutLSB32(FontFilePtr file, int c)
+{
+ current_position += 4;
+ (void) FontFilePutc(c, file);
+ (void) FontFilePutc(c >> 8, file);
+ (void) FontFilePutc(c >> 16, file);
+ return FontFilePutc(c >> 24, file);
+}
+
+static int
+pcfPutINT32(FontFilePtr file, CARD32 format, int c)
+{
+ current_position += 4;
+ if (PCF_BYTE_ORDER(format) == MSBFirst) {
+ (void) FontFilePutc(c >> 24, file);
+ (void) FontFilePutc(c >> 16, file);
+ (void) FontFilePutc(c >> 8, file);
+ return FontFilePutc(c, file);
+ } else {
+ (void) FontFilePutc(c, file);
+ (void) FontFilePutc(c >> 8, file);
+ (void) FontFilePutc(c >> 16, file);
+ return FontFilePutc(c >> 24, file);
+ }
+}
+
+static int
+pcfPutINT16(FontFilePtr file, CARD32 format, int c)
+{
+ current_position += 2;
+ if (PCF_BYTE_ORDER(format) == MSBFirst) {
+ (void) FontFilePutc(c >> 8, file);
+ return FontFilePutc(c, file);
+ } else {
+ (void) FontFilePutc(c, file);
+ return FontFilePutc(c >> 8, file);
+ }
+}
+
+/*ARGSUSED*/
+static int
+pcfPutINT8(FontFilePtr file, CARD32 format, int c)
+{
+ current_position += 1;
+ return FontFilePutc(c, file);
+}
+
+static void
+pcfWriteTOC(FontFilePtr file, PCFTablePtr table, int count)
+{
+ CARD32 version;
+ int i;
+
+ version = PCF_FILE_VERSION;
+ pcfPutLSB32(file, version);
+ pcfPutLSB32(file, count);
+ for (i = 0; i < count; i++) {
+ pcfPutLSB32(file, table->type);
+ pcfPutLSB32(file, table->format);
+ pcfPutLSB32(file, table->size);
+ pcfPutLSB32(file, table->offset);
+ table++;
+ }
+}
+
+static void
+pcfPutCompressedMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
+{
+ pcfPutINT8(file, format, metric->leftSideBearing + 0x80);
+ pcfPutINT8(file, format, metric->rightSideBearing + 0x80);
+ pcfPutINT8(file, format, metric->characterWidth + 0x80);
+ pcfPutINT8(file, format, metric->ascent + 0x80);
+ pcfPutINT8(file, format, metric->descent + 0x80);
+}
+
+static void
+pcfPutMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
+{
+ pcfPutINT16(file, format, metric->leftSideBearing);
+ pcfPutINT16(file, format, metric->rightSideBearing);
+ pcfPutINT16(file, format, metric->characterWidth);
+ pcfPutINT16(file, format, metric->ascent);
+ pcfPutINT16(file, format, metric->descent);
+ pcfPutINT16(file, format, metric->attributes);
+}
+
+static void
+pcfPutBitmap(FontFilePtr file, CARD32 format, CharInfoPtr pCI)
+{
+ int count;
+ unsigned char *bits;
+
+ count = BYTES_FOR_GLYPH(pCI, PCF_GLYPH_PAD(format));
+ bits = (unsigned char *) pCI->bits;
+ current_position += count;
+ while (count--)
+ FontFilePutc(*bits++, file);
+}
+
+static void
+pcfPutAccel(FontFilePtr file, CARD32 format, FontInfoPtr pFontInfo)
+{
+ pcfPutINT8(file, format, pFontInfo->noOverlap);
+ pcfPutINT8(file, format, pFontInfo->constantMetrics);
+ pcfPutINT8(file, format, pFontInfo->terminalFont);
+ pcfPutINT8(file, format, pFontInfo->constantWidth);
+ pcfPutINT8(file, format, pFontInfo->inkInside);
+ pcfPutINT8(file, format, pFontInfo->inkMetrics);
+ pcfPutINT8(file, format, pFontInfo->drawDirection);
+ pcfPutINT8(file, format, 0);
+ pcfPutINT32(file, format, pFontInfo->fontAscent);
+ pcfPutINT32(file, format, pFontInfo->fontDescent);
+ pcfPutINT32(file, format, pFontInfo->maxOverlap);
+ pcfPutMetric(file, format, &pFontInfo->minbounds);
+ pcfPutMetric(file, format, &pFontInfo->maxbounds);
+ if (PCF_FORMAT_MATCH(format, PCF_ACCEL_W_INKBOUNDS)) {
+ pcfPutMetric(file, format, &pFontInfo->ink_minbounds);
+ pcfPutMetric(file, format, &pFontInfo->ink_maxbounds);
+ }
+}
+
+#define S32 4
+#define S16 2
+#define S8 1
+
+#define Pad(s) (RoundUp(s) - (s))
+#define RoundUp(s) (((s) + 3) & ~3)
+
+#define Compressable(i) (-128 <= (i) && (i) <= 127)
+
+#define CanCompressMetric(m) (Compressable((m)->leftSideBearing) && \
+ Compressable((m)->rightSideBearing) && \
+ Compressable((m)->characterWidth) && \
+ Compressable((m)->ascent) && \
+ Compressable((m)->descent) && \
+ (m)->attributes == 0)
+
+#define CanCompressMetrics(min,max) (CanCompressMetric(min) && CanCompressMetric(max))
+
+static char *
+pcfNameForAtom(Atom a)
+{
+ return NameForAtom(a);
+}
+
+int
+pcfWriteFont(FontPtr pFont, FontFilePtr file)
+{
+ PCFTableRec tables[32],
+ *table;
+ CARD32 mask,
+ bit;
+ int ntables;
+ int size;
+ CARD32 format;
+ int i;
+ int cur_table;
+ int prop_string_size;
+ int glyph_string_size;
+ xCharInfo *minbounds,
+ *maxbounds;
+ xCharInfo *ink_minbounds,
+ *ink_maxbounds;
+ BitmapFontPtr bitmapFont;
+ int nencodings = 0;
+ int header_size;
+ FontPropPtr offsetProps;
+ int prop_pad = 0;
+ char *atom_name;
+ int glyph;
+ CARD32 offset;
+
+ bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
+ if (bitmapFont->bitmapExtra) {
+ minbounds = &bitmapFont->bitmapExtra->info.minbounds;
+ maxbounds = &bitmapFont->bitmapExtra->info.maxbounds;
+ ink_minbounds = &bitmapFont->bitmapExtra->info.ink_minbounds;
+ ink_maxbounds = &bitmapFont->bitmapExtra->info.ink_maxbounds;
+ } else {
+ minbounds = &pFont->info.minbounds;
+ maxbounds = &pFont->info.maxbounds;
+ ink_minbounds = &pFont->info.ink_minbounds;
+ ink_maxbounds = &pFont->info.ink_maxbounds;
+ }
+ offsetProps = (FontPropPtr) xalloc(pFont->info.nprops * sizeof(FontPropRec));
+ if (!offsetProps) {
+ pcfError("pcfWriteFont(): Couldn't allocate offsetProps (%d*%d)", pFont->info.nprops, sizeof(FontPropRec));
+ return AllocError;
+ }
+ prop_string_size = 0;
+ for (i = 0; i < pFont->info.nprops; i++) {
+ offsetProps[i].name = prop_string_size;
+ prop_string_size += strlen(pcfNameForAtom(pFont->info.props[i].name)) + 1;
+ if (pFont->info.isStringProp[i]) {
+ offsetProps[i].value = prop_string_size;
+ prop_string_size += strlen(pcfNameForAtom(pFont->info.props[i].value)) + 1;
+ } else
+ offsetProps[i].value = pFont->info.props[i].value;
+ }
+ format = PCF_FORMAT(pFont->bit, pFont->byte, pFont->glyph, pFont->scan);
+ mask = 0xFFFFFFF;
+ ntables = 0;
+ table = tables;
+ while (mask) {
+ bit = lowbit(mask);
+ mask &= ~bit;
+ table->type = bit;
+ switch (bit) {
+ case PCF_PROPERTIES:
+ table->format = PCF_DEFAULT_FORMAT | format;
+ size = S32 + S32 + (S32 + S8 + S32) * pFont->info.nprops;
+ prop_pad = Pad(size);
+ table->size = RoundUp(size) + S32 +
+ RoundUp(prop_string_size);
+ table++;
+ break;
+ case PCF_ACCELERATORS:
+ if (bitmapFont->bitmapExtra->info.inkMetrics)
+ table->format = PCF_ACCEL_W_INKBOUNDS | format;
+ else
+ table->format = PCF_DEFAULT_FORMAT | format;
+ table->size = 100;
+ table++;
+ break;
+ case PCF_METRICS:
+ if (CanCompressMetrics(minbounds, maxbounds)) {
+ table->format = PCF_COMPRESSED_METRICS | format;
+ size = S32 + S16 + bitmapFont->num_chars * (5 * S8);
+ table->size = RoundUp(size);
+ } else {
+ table->format = PCF_DEFAULT_FORMAT | format;
+ table->size = S32 + S32 + bitmapFont->num_chars * (6 * S16);
+ }
+ table++;
+ break;
+ case PCF_BITMAPS:
+ table->format = PCF_DEFAULT_FORMAT | format;
+ size = S32 + S32 + bitmapFont->num_chars * S32 +
+ GLYPHPADOPTIONS * S32 +
+ bitmapFont->bitmapExtra->bitmapsSizes[PCF_GLYPH_PAD_INDEX(format)];
+ table->size = RoundUp(size);
+ table++;
+ break;
+ case PCF_INK_METRICS:
+ if (bitmapFont->ink_metrics) {
+ if (CanCompressMetrics(ink_minbounds, ink_maxbounds)) {
+ table->format = PCF_COMPRESSED_METRICS | format;
+ size = S32 + S16 + bitmapFont->num_chars * (5 * S8);
+ table->size = RoundUp(size);
+ } else {
+ table->format = PCF_DEFAULT_FORMAT | format;
+ table->size = S32 + S32 + bitmapFont->num_chars * (6 * S16);
+ }
+ table++;
+ }
+ break;
+ case PCF_BDF_ENCODINGS:
+ table->format = PCF_DEFAULT_FORMAT | format;
+ nencodings = (pFont->info.lastRow - pFont->info.firstRow + 1) *
+ (pFont->info.lastCol - pFont->info.firstCol + 1);
+ size = S32 + 5 * S16 + nencodings * S16;
+ table->size = RoundUp(size);
+ table++;
+ break;
+ case PCF_SWIDTHS:
+ table->format = PCF_DEFAULT_FORMAT | format;
+ table->size = S32 + S32 + bitmapFont->num_chars * S32;
+ table++;
+ break;
+ case PCF_GLYPH_NAMES:
+ table->format = PCF_DEFAULT_FORMAT | format;
+ glyph_string_size = 0;
+ for (i = 0; i < bitmapFont->num_chars; i++)
+ glyph_string_size += strlen(pcfNameForAtom(bitmapFont->bitmapExtra->glyphNames[i])) + 1;
+ table->size = S32 + S32 + bitmapFont->num_chars * S32 +
+ S32 + RoundUp(glyph_string_size);
+ table++;
+ break;
+ case PCF_BDF_ACCELERATORS:
+ if (pFont->info.inkMetrics)
+ table->format = PCF_ACCEL_W_INKBOUNDS | format;
+ else
+ table->format = PCF_DEFAULT_FORMAT | format;
+ table->size = 100;
+ table++;
+ break;
+ }
+ }
+ ntables = table - tables;
+ offset = 0;
+ header_size = S32 + S32 + ntables * (4 * S32);
+ offset = header_size;
+ for (cur_table = 0, table = tables;
+ cur_table < ntables;
+ cur_table++, table++) {
+ table->offset = offset;
+ offset += table->size;
+ }
+ current_position = 0;
+ pcfWriteTOC(file, tables, ntables);
+ for (cur_table = 0, table = tables;
+ cur_table < ntables;
+ cur_table++, table++) {
+ if (current_position > table->offset) {
+ printf("can't go backwards... %d > %d\n",
+ (int)current_position, (int)table->offset);
+ xfree(offsetProps);
+ return BadFontName;
+ }
+ while (current_position < table->offset)
+ pcfPutINT8(file, format, '\0');
+ pcfPutLSB32(file, table->format);
+ switch (table->type) {
+ case PCF_PROPERTIES:
+ pcfPutINT32(file, format, pFont->info.nprops);
+ for (i = 0; i < pFont->info.nprops; i++) {
+ pcfPutINT32(file, format, offsetProps[i].name);
+ pcfPutINT8(file, format, pFont->info.isStringProp[i]);
+ pcfPutINT32(file, format, offsetProps[i].value);
+ }
+ for (i = 0; i < prop_pad; i++)
+ pcfPutINT8(file, format, 0);
+ pcfPutINT32(file, format, prop_string_size);
+ for (i = 0; i < pFont->info.nprops; i++) {
+ atom_name = pcfNameForAtom(pFont->info.props[i].name);
+ pcfWrite(file, atom_name, strlen(atom_name) + 1);
+ if (pFont->info.isStringProp[i]) {
+ atom_name = pcfNameForAtom(pFont->info.props[i].value);
+ pcfWrite(file, atom_name, strlen(atom_name) + 1);
+ }
+ }
+ break;
+ case PCF_ACCELERATORS:
+ pcfPutAccel(file, table->format, &bitmapFont->bitmapExtra->info);
+ break;
+ case PCF_METRICS:
+ if (PCF_FORMAT_MATCH(table->format, PCF_COMPRESSED_METRICS)) {
+ pcfPutINT16(file, format, bitmapFont->num_chars);
+ for (i = 0; i < bitmapFont->num_chars; i++)
+ pcfPutCompressedMetric(file, format, &bitmapFont->metrics[i].metrics);
+ } else {
+ pcfPutINT32(file, format, bitmapFont->num_chars);
+ for (i = 0; i < bitmapFont->num_chars; i++)
+ pcfPutMetric(file, format, &bitmapFont->metrics[i].metrics);
+ }
+ break;
+ case PCF_BITMAPS:
+ pcfPutINT32(file, format, bitmapFont->num_chars);
+ glyph = PCF_GLYPH_PAD(format);
+ offset = 0;
+ for (i = 0; i < bitmapFont->num_chars; i++) {
+ pcfPutINT32(file, format, offset);
+ offset += BYTES_FOR_GLYPH(&bitmapFont->metrics[i], glyph);
+ }
+ for (i = 0; i < GLYPHPADOPTIONS; i++) {
+ pcfPutINT32(file, format,
+ bitmapFont->bitmapExtra->bitmapsSizes[i]);
+ }
+ for (i = 0; i < bitmapFont->num_chars; i++)
+ pcfPutBitmap(file, format, &bitmapFont->metrics[i]);
+ break;
+ case PCF_INK_METRICS:
+ if (PCF_FORMAT_MATCH(table->format, PCF_COMPRESSED_METRICS)) {
+ pcfPutINT16(file, format, bitmapFont->num_chars);
+ for (i = 0; i < bitmapFont->num_chars; i++)
+ pcfPutCompressedMetric(file, format, &bitmapFont->ink_metrics[i]);
+ } else {
+ pcfPutINT32(file, format, bitmapFont->num_chars);
+ for (i = 0; i < bitmapFont->num_chars; i++)
+ pcfPutMetric(file, format, &bitmapFont->ink_metrics[i]);
+ }
+ break;
+ case PCF_BDF_ENCODINGS:
+ pcfPutINT16(file, format, pFont->info.firstCol);
+ pcfPutINT16(file, format, pFont->info.lastCol);
+ pcfPutINT16(file, format, pFont->info.firstRow);
+ pcfPutINT16(file, format, pFont->info.lastRow);
+ pcfPutINT16(file, format, pFont->info.defaultCh);
+ for (i = 0; i < nencodings; i++) {
+ if (ACCESSENCODING(bitmapFont->encoding,i))
+ pcfPutINT16(file, format,
+ ACCESSENCODING(bitmapFont->encoding, i) -
+ bitmapFont->metrics);
+ else
+ pcfPutINT16(file, format, 0xFFFF);
+ }
+ break;
+ case PCF_SWIDTHS:
+ pcfPutINT32(file, format, bitmapFont->num_chars);
+ for (i = 0; i < bitmapFont->num_chars; i++)
+ pcfPutINT32(file, format, bitmapFont->bitmapExtra->sWidths[i]);
+ break;
+ case PCF_GLYPH_NAMES:
+ pcfPutINT32(file, format, bitmapFont->num_chars);
+ offset = 0;
+ for (i = 0; i < bitmapFont->num_chars; i++) {
+ pcfPutINT32(file, format, offset);
+ offset += strlen(pcfNameForAtom(bitmapFont->bitmapExtra->glyphNames[i])) + 1;
+ }
+ pcfPutINT32(file, format, offset);
+ for (i = 0; i < bitmapFont->num_chars; i++) {
+ atom_name = pcfNameForAtom(bitmapFont->bitmapExtra->glyphNames[i]);
+ pcfWrite(file, atom_name, strlen(atom_name) + 1);
+ }
+ break;
+ case PCF_BDF_ACCELERATORS:
+ pcfPutAccel(file, table->format, &pFont->info);
+ break;
+ }
+ }
+
+ xfree(offsetProps);
+ return Successful;
+}
diff --git a/nx-X11/lib/font/bitmap/snfread.c b/nx-X11/lib/font/bitmap/snfread.c
new file mode 100644
index 000000000..01b6bf382
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/snfread.c
@@ -0,0 +1,514 @@
+/* $Xorg: snfread.c,v 1.5 2001/02/09 02:04:02 xorgcvs Exp $ */
+/************************************************************************
+Copyright 1989 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.
+
+************************************************************************/
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/bitmap/snfread.c,v 1.12 2003/11/17 22:20:22 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifndef FONTMODULE
+#include <ctype.h>
+#endif
+
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/bitmap.h>
+#include "snfstr.h"
+
+#include <stdarg.h>
+
+void
+snfError(const char* message, ...)
+{
+ va_list args;
+
+ va_start(args, message);
+
+ fprintf(stderr, "SNF Error: ");
+ vfprintf(stderr, message, args);
+ va_end(args);
+}
+
+static void snfUnloadFont(FontPtr pFont);
+
+static int
+snfReadCharInfo(FontFilePtr file, CharInfoPtr charInfo, char *base)
+{
+ snfCharInfoRec snfCharInfo;
+
+#define Width(m) ((m).rightSideBearing - (m).leftSideBearing)
+#define Height(m) ((m).ascent + (m).descent)
+
+ if (FontFileRead(file, (char *) &snfCharInfo, sizeof snfCharInfo) !=
+ sizeof(snfCharInfo)) {
+ return BadFontName;
+ }
+ charInfo->metrics = snfCharInfo.metrics;
+ if (snfCharInfo.exists)
+ charInfo->bits = base + snfCharInfo.byteOffset;
+ else
+ charInfo->bits = 0;
+ return Successful;
+}
+
+static int
+snfReadxCharInfo(FontFilePtr file, xCharInfo *charInfo)
+{
+ snfCharInfoRec snfCharInfo;
+
+ if (FontFileRead(file, (char *) &snfCharInfo, sizeof snfCharInfo) !=
+ sizeof(snfCharInfo)) {
+ return BadFontName;
+ }
+ *charInfo = snfCharInfo.metrics;
+ return Successful;
+}
+
+static void
+snfCopyInfo(snfFontInfoPtr snfInfo, FontInfoPtr pFontInfo)
+{
+ pFontInfo->firstCol = snfInfo->firstCol;
+ pFontInfo->lastCol = snfInfo->lastCol;
+ pFontInfo->firstRow = snfInfo->firstRow;
+ pFontInfo->lastRow = snfInfo->lastRow;
+ pFontInfo->defaultCh = snfInfo->chDefault;
+ pFontInfo->noOverlap = snfInfo->noOverlap;
+ pFontInfo->terminalFont = snfInfo->terminalFont;
+ pFontInfo->constantMetrics = snfInfo->constantMetrics;
+ pFontInfo->constantWidth = snfInfo->constantWidth;
+ pFontInfo->inkInside = snfInfo->inkInside;
+ pFontInfo->inkMetrics = snfInfo->inkMetrics;
+ pFontInfo->allExist = snfInfo->allExist;
+ pFontInfo->drawDirection = snfInfo->drawDirection;
+ pFontInfo->anamorphic = FALSE;
+ pFontInfo->cachable = TRUE;
+ pFontInfo->maxOverlap = 0;
+ pFontInfo->minbounds = snfInfo->minbounds.metrics;
+ pFontInfo->maxbounds = snfInfo->maxbounds.metrics;
+ pFontInfo->fontAscent = snfInfo->fontAscent;
+ pFontInfo->fontDescent = snfInfo->fontDescent;
+ pFontInfo->nprops = snfInfo->nProps;
+}
+
+static int
+snfReadProps(snfFontInfoPtr snfInfo, FontInfoPtr pFontInfo, FontFilePtr file)
+{
+ char *strings;
+ FontPropPtr pfp;
+ snfFontPropPtr psnfp;
+ char *propspace;
+ int bytestoalloc;
+ int i;
+
+ bytestoalloc = snfInfo->nProps * sizeof(snfFontPropRec) +
+ BYTESOFSTRINGINFO(snfInfo);
+ propspace = (char *) xalloc(bytestoalloc);
+ if (!propspace) {
+ snfError("snfReadProps(): Couldn't allocate propspace (%d)\n", bytestoalloc);
+ return AllocError;
+ }
+
+ if (FontFileRead(file, propspace, bytestoalloc) != bytestoalloc) {
+ xfree(propspace);
+ return BadFontName;
+ }
+ psnfp = (snfFontPropPtr) propspace;
+
+ strings = propspace + BYTESOFPROPINFO(snfInfo);
+
+ for (i = 0, pfp = pFontInfo->props; i < snfInfo->nProps; i++, pfp++, psnfp++) {
+ pfp->name = MakeAtom(&strings[psnfp->name],
+ (unsigned) strlen(&strings[psnfp->name]), 1);
+ pFontInfo->isStringProp[i] = psnfp->indirect;
+ if (psnfp->indirect)
+ pfp->value = (INT32) MakeAtom(&strings[psnfp->value],
+ (unsigned) strlen(&strings[psnfp->value]), 1);
+ else
+ pfp->value = psnfp->value;
+ }
+
+ xfree(propspace);
+ return Successful;
+}
+
+static int
+snfReadHeader(snfFontInfoPtr snfInfo, FontFilePtr file)
+{
+ if (FontFileRead(file, (char *) snfInfo, sizeof *snfInfo) != sizeof *snfInfo)
+ return BadFontName;
+
+ if (snfInfo->version1 != FONT_FILE_VERSION ||
+ snfInfo->version2 != FONT_FILE_VERSION)
+ return BadFontName;
+ return Successful;
+}
+
+static int snf_set;
+static int snf_bit, snf_byte, snf_glyph, snf_scan;
+
+void
+SnfSetFormat (int bit, int byte, int glyph, int scan)
+{
+ snf_bit = bit;
+ snf_byte = byte;
+ snf_glyph = glyph;
+ snf_scan = scan;
+ snf_set = 1;
+}
+
+static void
+SnfGetFormat (int *bit, int *byte, int *glyph, int *scan)
+{
+ if (!snf_set)
+ FontDefaultFormat (&snf_bit, &snf_byte, &snf_glyph, &snf_scan);
+ *bit = snf_bit;
+ *byte = snf_byte;
+ *glyph = snf_glyph;
+ *scan = snf_scan;
+}
+
+int
+snfReadFont(FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan)
+{
+ snfFontInfoRec fi;
+ unsigned bytestoalloc;
+ int i, j;
+ char *fontspace;
+ BitmapFontPtr bitmapFont;
+ int num_chars;
+ int bitmapsSize;
+ int ret;
+ int metrics_off;
+ int encoding_off;
+ int props_off;
+ int isStringProp_off;
+ int ink_off;
+ char *bitmaps;
+ int def_bit, def_byte, def_glyph, def_scan;
+
+ ret = snfReadHeader(&fi, file);
+ if (ret != Successful)
+ return ret;
+
+ SnfGetFormat (&def_bit, &def_byte, &def_glyph, &def_scan);
+
+ /*
+ * we'll allocate one chunk of memory and split it among the various parts
+ * of the font:
+ *
+ * BitmapFontRec CharInfoRec's Glyphs Encoding DIX Properties Ink CharInfoRec's
+ *
+ * If the glyphpad is not the same as the font file, then the glyphs
+ * are allocated separately, to be later realloc'ed when we know
+ * how big to make them.
+ */
+
+ bitmapsSize = BYTESOFGLYPHINFO(&fi);
+ num_chars = n2dChars(&fi);
+ bytestoalloc = sizeof(BitmapFontRec); /* bitmapFont */
+ metrics_off = bytestoalloc;
+ bytestoalloc += num_chars * sizeof(CharInfoRec); /* metrics */
+ encoding_off = bytestoalloc;
+ bytestoalloc += NUM_SEGMENTS(num_chars) * sizeof(CharInfoPtr**);
+ /* encoding */
+ props_off = bytestoalloc;
+ bytestoalloc += fi.nProps * sizeof(FontPropRec); /* props */
+ isStringProp_off = bytestoalloc;
+ bytestoalloc += fi.nProps * sizeof(char); /* isStringProp */
+ bytestoalloc = (bytestoalloc + 3) & ~3;
+ ink_off = bytestoalloc;
+ if (fi.inkMetrics)
+ bytestoalloc += num_chars * sizeof(xCharInfo); /* ink_metrics */
+
+ fontspace = (char *) xalloc(bytestoalloc);
+ if (!fontspace) {
+ snfError("snfReadFont(): Couldn't allocate fontspace (%d)\n", bytestoalloc);
+ return AllocError;
+ }
+ bitmaps = (char *) xalloc (bitmapsSize);
+ if (!bitmaps)
+ {
+ snfError("snfReadFont(): Couldn't allocate bitmaps (%d)\n", bitmapsSize);
+ xfree (fontspace);
+ return AllocError;
+ }
+ /*
+ * now fix up pointers
+ */
+
+ bitmapFont = (BitmapFontPtr) fontspace;
+ bitmapFont->num_chars = num_chars;
+ bitmapFont->metrics = (CharInfoPtr) (fontspace + metrics_off);
+ bitmapFont->encoding = (CharInfoPtr **) (fontspace + encoding_off);
+ bitmapFont->bitmaps = bitmaps;
+ bitmapFont->pDefault = NULL;
+ bitmapFont->bitmapExtra = NULL;
+ pFont->info.props = (FontPropPtr) (fontspace + props_off);
+ pFont->info.isStringProp = (char *) (fontspace + isStringProp_off);
+ if (fi.inkMetrics)
+ bitmapFont->ink_metrics = (xCharInfo *) (fontspace + ink_off);
+ else
+ bitmapFont->ink_metrics = 0;
+
+ /*
+ * read the CharInfo
+ */
+
+ ret = Successful;
+ memset(bitmapFont->encoding, 0,
+ NUM_SEGMENTS(num_chars)*sizeof(CharInfoPtr*));
+ for (i = 0; ret == Successful && i < num_chars; i++) {
+ ret = snfReadCharInfo(file, &bitmapFont->metrics[i], bitmaps);
+ if (bitmapFont->metrics[i].bits) {
+ if (!bitmapFont->encoding[SEGMENT_MAJOR(i)]) {
+ bitmapFont->encoding[SEGMENT_MAJOR(i)]=
+ (CharInfoPtr*)xcalloc(BITMAP_FONT_SEGMENT_SIZE,
+ sizeof(CharInfoPtr));
+ if (!bitmapFont->encoding[SEGMENT_MAJOR(i)]) {
+ ret = AllocError;
+ break;
+ }
+ }
+ ACCESSENCODINGL(bitmapFont->encoding,i) = &bitmapFont->metrics[i];
+ }
+ }
+
+ if (ret != Successful) {
+ xfree(bitmaps);
+ if(bitmapFont->encoding) {
+ for(j=0; j<SEGMENT_MAJOR(i); j++)
+ xfree(bitmapFont->encoding[i]);
+ }
+ xfree(fontspace);
+ return ret;
+ }
+ /*
+ * read the glyphs
+ */
+
+ if (FontFileRead(file, bitmaps, bitmapsSize) != bitmapsSize) {
+ xfree(bitmaps);
+ xfree(fontspace);
+ return BadFontName;
+ }
+
+ if (def_bit != bit)
+ BitOrderInvert((unsigned char *)bitmaps, bitmapsSize);
+ if ((def_byte == def_bit) != (bit == byte)) {
+ switch (bit == byte ? def_scan : scan) {
+ case 1:
+ break;
+ case 2:
+ TwoByteSwap((unsigned char *)bitmaps, bitmapsSize);
+ break;
+ case 4:
+ FourByteSwap((unsigned char *)bitmaps, bitmapsSize);
+ break;
+ }
+ }
+ if (def_glyph != glyph) {
+ char *padbitmaps;
+ int sizepadbitmaps;
+ int sizechar;
+ CharInfoPtr metric;
+
+ sizepadbitmaps = 0;
+ metric = bitmapFont->metrics;
+ for (i = 0; i < num_chars; i++)
+ {
+ if (metric->bits)
+ sizepadbitmaps += BYTES_FOR_GLYPH(metric,glyph);
+ metric++;
+ }
+ padbitmaps = (char *) xalloc(sizepadbitmaps);
+ if (!padbitmaps) {
+ snfError("snfReadFont(): Couldn't allocate padbitmaps (%d)\n", sizepadbitmaps);
+ xfree (bitmaps);
+ xfree (fontspace);
+ return AllocError;
+ }
+ metric = bitmapFont->metrics;
+ bitmapFont->bitmaps = padbitmaps;
+ for (i = 0; i < num_chars; i++) {
+ sizechar = RepadBitmap(metric->bits, padbitmaps,
+ def_glyph, glyph,
+ metric->metrics.rightSideBearing -
+ metric->metrics.leftSideBearing,
+ metric->metrics.ascent + metric->metrics.descent);
+ metric->bits = padbitmaps;
+ padbitmaps += sizechar;
+ metric++;
+ }
+ xfree(bitmaps);
+ }
+
+ /* now read and atom'ize properties */
+
+ ret = snfReadProps(&fi, &pFont->info, file);
+ if (ret != Successful) {
+ xfree(fontspace);
+ return ret;
+ }
+ snfCopyInfo(&fi, &pFont->info);
+
+ /* finally, read the ink metrics if the exist */
+
+ if (fi.inkMetrics) {
+ ret = Successful;
+ ret = snfReadxCharInfo(file, &pFont->info.ink_minbounds);
+ ret = snfReadxCharInfo(file, &pFont->info.ink_maxbounds);
+ for (i = 0; ret == Successful && i < num_chars; i++)
+ ret = snfReadxCharInfo(file, &bitmapFont->ink_metrics[i]);
+ if (ret != Successful) {
+ xfree(fontspace);
+ return ret;
+ }
+ } else {
+ pFont->info.ink_minbounds = pFont->info.minbounds;
+ pFont->info.ink_maxbounds = pFont->info.maxbounds;
+ }
+
+ if (pFont->info.defaultCh != (unsigned short) NO_SUCH_CHAR) {
+ unsigned int r,
+ c,
+ cols;
+
+ r = pFont->info.defaultCh >> 8;
+ c = pFont->info.defaultCh & 0xFF;
+ if (pFont->info.firstRow <= r && r <= pFont->info.lastRow &&
+ pFont->info.firstCol <= c && c <= pFont->info.lastCol) {
+ cols = pFont->info.lastCol - pFont->info.firstCol + 1;
+ r = r - pFont->info.firstRow;
+ c = c - pFont->info.firstCol;
+ bitmapFont->pDefault = &bitmapFont->metrics[r * cols + c];
+ }
+ }
+ bitmapFont->bitmapExtra = (BitmapExtraPtr) 0;
+ pFont->fontPrivate = (pointer) bitmapFont;
+ pFont->get_glyphs = bitmapGetGlyphs;
+ pFont->get_metrics = bitmapGetMetrics;
+ pFont->unload_font = snfUnloadFont;
+ pFont->unload_glyphs = NULL;
+ pFont->bit = bit;
+ pFont->byte = byte;
+ pFont->glyph = glyph;
+ pFont->scan = scan;
+ return Successful;
+}
+
+int
+snfReadFontInfo(FontInfoPtr pFontInfo, FontFilePtr file)
+{
+ int ret;
+ snfFontInfoRec fi;
+ int bytestoskip;
+ int num_chars;
+
+ ret = snfReadHeader(&fi, file);
+ if (ret != Successful)
+ return ret;
+ snfCopyInfo(&fi, pFontInfo);
+
+ pFontInfo->props = (FontPropPtr) xalloc(fi.nProps * sizeof(FontPropRec));
+ if (!pFontInfo->props) {
+ snfError("snfReadFontInfo(): Couldn't allocate props (%d*%d)\n", fi.nProps, sizeof(FontPropRec));
+ return AllocError;
+ }
+ pFontInfo->isStringProp = (char *) xalloc(fi.nProps * sizeof(char));
+ if (!pFontInfo->isStringProp) {
+ snfError("snfReadFontInfo(): Couldn't allocate isStringProp (%d*%d)\n", fi.nProps, sizeof(char));
+ xfree(pFontInfo->props);
+ return AllocError;
+ }
+ num_chars = n2dChars(&fi);
+ bytestoskip = num_chars * sizeof(snfCharInfoRec); /* charinfos */
+ bytestoskip += BYTESOFGLYPHINFO(&fi);
+ (void)FontFileSkip(file, bytestoskip);
+
+ ret = snfReadProps(&fi, pFontInfo, file);
+ if (ret != Successful) {
+ xfree(pFontInfo->props);
+ xfree(pFontInfo->isStringProp);
+ return ret;
+ }
+ if (fi.inkMetrics) {
+ ret = snfReadxCharInfo(file, &pFontInfo->ink_minbounds);
+ if (ret != Successful) {
+ xfree(pFontInfo->props);
+ xfree(pFontInfo->isStringProp);
+ return ret;
+ }
+ ret = snfReadxCharInfo(file, &pFontInfo->ink_maxbounds);
+ if (ret != Successful) {
+ xfree(pFontInfo->props);
+ xfree(pFontInfo->isStringProp);
+ return ret;
+ }
+ } else {
+ pFontInfo->ink_minbounds = pFontInfo->minbounds;
+ pFontInfo->ink_maxbounds = pFontInfo->maxbounds;
+ }
+ return Successful;
+
+}
+
+static void
+snfUnloadFont(FontPtr pFont)
+{
+ BitmapFontPtr bitmapFont;
+
+ bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
+ xfree (bitmapFont->bitmaps);
+ xfree (bitmapFont);
+ DestroyFontRec (pFont);
+}
+
diff --git a/nx-X11/lib/font/bitmap/snfstr.h b/nx-X11/lib/font/bitmap/snfstr.h
new file mode 100644
index 000000000..8158089bf
--- /dev/null
+++ b/nx-X11/lib/font/bitmap/snfstr.h
@@ -0,0 +1,185 @@
+/* $Xorg: snfstr.h,v 1.4 2001/02/09 02:04:02 xorgcvs Exp $ */
+/***********************************************************
+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.
+
+******************************************************************/
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/bitmap/snfstr.h,v 1.5 2001/12/14 19:56:47 dawes Exp $ */
+
+#ifndef SNFSTR_H
+#define SNFSTR_H 1
+
+#include <X11/fonts/fntfilio.h>
+
+/*-
+ * This file describes the Server Natural Font format.
+ * SNF fonts are both CPU-dependent and frame buffer bit order dependent.
+ * This file is used by:
+ * 1) the server, to hold font information read out of font files.
+ * 2) font converters
+ *
+ * Each font file contains the following
+ * data structures, with no padding in-between.
+ *
+ * 1) The XFONTINFO structure
+ * hand-padded to a two-short boundary.
+ * maxbounds.byteoffset is the total number of bytes in the
+ * glpyh array
+ * maxbounds.bitOffset is thetotal width of the unpadded font
+ *
+ * 2) The XCHARINFO array
+ * indexed directly with character codes, both on disk
+ * and in memory.
+ *
+ * 3) Character glyphs
+ * padded in the server-natural way, and
+ * ordered in the device-natural way.
+ * End of glyphs padded to 32-bit boundary.
+ *
+ * 4) nProps font properties
+ *
+ * 5) a sequence of null-terminated strings, for font properties
+ */
+
+#define FONT_FILE_VERSION 4
+
+typedef struct _snfFontProp {
+ CARD32 name; /* offset of string */
+ INT32 value; /* number or offset of string */
+ Bool indirect; /* value is a string offset */
+} snfFontPropRec;
+
+/*
+ * the following macro definitions describe a font file image in memory
+ */
+#define ADDRCharInfoRec( pfi) \
+ ((snfCharInfoRec *) &(pfi)[1])
+
+#define ADDRCHARGLYPHS( pfi) \
+ (((char *) &(pfi)[1]) + BYTESOFCHARINFO(pfi))
+
+/*
+ * pad out glyphs to a CARD32 boundary
+ */
+#define ADDRXFONTPROPS( pfi) \
+ ((snfFontPropRec *) ((char *)ADDRCHARGLYPHS( pfi) + BYTESOFGLYPHINFO(pfi)))
+
+#define ADDRSTRINGTAB( pfi) \
+ ((char *)ADDRXFONTPROPS( pfi) + BYTESOFPROPINFO(pfi))
+
+#define n2dChars(pfi) (((pfi)->lastRow - (pfi)->firstRow + 1) * \
+ ((pfi)->lastCol - (pfi)->firstCol + 1))
+#define BYTESOFFONTINFO(pfi) (sizeof(snfFontInfoRec))
+#define BYTESOFCHARINFO(pfi) (sizeof(snfCharInfoRec) * n2dChars(pfi))
+#define BYTESOFPROPINFO(pfi) (sizeof(snfFontPropRec) * (pfi)->nProps)
+#define BYTESOFSTRINGINFO(pfi) ((pfi)->lenStrings)
+#define BYTESOFGLYPHINFO(pfi) (((pfi)->maxbounds.byteOffset+3) & ~0x3)
+#define BYTESOFINKINFO(pfi) (sizeof(snfCharInfoRec) * n2dChars(pfi))
+
+typedef struct _snfFontProp *snfFontPropPtr;
+typedef struct _snfCharInfo *snfCharInfoPtr;
+typedef struct _snfFontInfo *snfFontInfoPtr;
+
+typedef struct _snfCharInfo {
+ xCharInfo metrics; /* info preformatted for Queries */
+ unsigned byteOffset:24; /* byte offset of the raster from pGlyphs */
+ unsigned exists:1; /* true iff glyph exists for this char */
+ unsigned pad:7; /* must be zero for now */
+} snfCharInfoRec;
+
+typedef struct _snfFontInfo {
+ unsigned int version1; /* version stamp */
+ unsigned int allExist;
+ unsigned int drawDirection;
+ unsigned int noOverlap; /* true if:
+ * max(rightSideBearing-characterWidth) <=
+ * minbounds->metrics.leftSideBearing */
+ unsigned int constantMetrics;
+ unsigned int terminalFont; /* Should be deprecated! true if: constant
+ * metrics && leftSideBearing == 0 &&
+ * rightSideBearing == characterWidth &&
+ * ascent == fontAscent && descent ==
+ * fontDescent */
+ unsigned int linear:1; /* true if firstRow == lastRow */
+ unsigned int constantWidth:1; /* true if
+ * minbounds->metrics.characterWidth
+ * ==
+ * maxbounds->metrics.characterWidth */
+ unsigned int inkInside:1; /* true if for all defined glyphs:
+ * leftSideBearing >= 0 && rightSideBearing <=
+ * characterWidth && -fontDescent <= ascent <=
+ * fontAscent && -fontAscent <= descent <=
+ * fontDescent */
+ unsigned int inkMetrics:1; /* ink metrics != bitmap metrics */
+ /* used with terminalFont */
+ /* see font's pInk{CI,Min,Max} */
+ unsigned int padding:28;
+ unsigned int firstCol;
+ unsigned int lastCol;
+ unsigned int firstRow;
+ unsigned int lastRow;
+ unsigned int nProps;
+ unsigned int lenStrings; /* length in bytes of string table */
+ unsigned int chDefault; /* default character */
+ int fontDescent; /* minimum for quality typography */
+ int fontAscent; /* minimum for quality typography */
+ snfCharInfoRec minbounds; /* MIN of glyph metrics over all chars */
+ snfCharInfoRec maxbounds; /* MAX of glyph metrics over all chars */
+ unsigned int pixDepth; /* intensity bits per pixel */
+ unsigned int glyphSets; /* number of sets of glyphs, for sub-pixel
+ * positioning */
+ unsigned int version2; /* version stamp double-check */
+} snfFontInfoRec;
+
+extern void SnfSetFormat ( int bit, int byte, int glyph, int scan );
+extern int snfReadFont ( FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan );
+extern int snfReadFontInfo ( FontInfoPtr pFontInfo, FontFilePtr file );
+extern void snfError( const char* message, ... );
+
+#endif /* SNFSTR_H */
diff --git a/nx-X11/lib/font/builtins/Imakefile b/nx-X11/lib/font/builtins/Imakefile
new file mode 100644
index 000000000..f70434865
--- /dev/null
+++ b/nx-X11/lib/font/builtins/Imakefile
@@ -0,0 +1,17 @@
+XCOMM $XFree86: xc/lib/font/builtins/Imakefile,v 1.2 1999/11/19 14:59:08 hohndel Exp $
+XCOMM
+XCOMM
+XCOMM $XConsortium: Imakefile /main/14 1996/11/03 19:58:41 kaleb $
+#include <Server.tmpl>
+
+ INCLUDES = -I$(FONTINCSRC) -I../include -I$(SERVERSRC)/include
+ HEADERS =
+
+ SRCS = dir.c file.c fonts.c fpe.c render.c
+ OBJS = dir.o file.o fonts.o fpe.o render.o
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/font/builtins/buildfont b/nx-X11/lib/font/builtins/buildfont
new file mode 100644
index 000000000..aa4602ff8
--- /dev/null
+++ b/nx-X11/lib/font/builtins/buildfont
@@ -0,0 +1,14 @@
+#!/bin/sh
+#
+# Convert a bdf file into C-code suitable for inclusion in
+# builtin fonts
+#
+FONT=$1
+NAME=$2
+echo 'static const char file_'$NAME'[] = {'
+bdftopcf -p1 -u1 $1 |
+ compress -b 12 |
+ od -b -v -w8 |
+ sed 's/^[0-9]*\( *\)/\1\1\1\1/' |
+ sed 's/\([0-9][0-9]*\)/'"'"'\\\1'"'"',/g'
+echo '};'
diff --git a/nx-X11/lib/font/builtins/builtin.h b/nx-X11/lib/font/builtins/builtin.h
new file mode 100644
index 000000000..ea98407eb
--- /dev/null
+++ b/nx-X11/lib/font/builtins/builtin.h
@@ -0,0 +1,60 @@
+/*
+ * Id: builtin.h,v 1.2 1999/11/02 06:16:47 keithp Exp $
+ *
+ * Copyright 1999 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+/* $XFree86: xc/lib/font/builtins/builtin.h,v 1.3 1999/12/30 02:29:49 robin Exp $ */
+
+#include <X11/Xdefs.h>
+#include <X11/fonts/font.h>
+#include <X11/fonts/fontxlfd.h>
+#include <X11/fonts/fntfil.h>
+#include <X11/fonts/fntfilio.h>
+#include <X11/fonts/fntfilst.h>
+
+typedef struct _BuiltinFile {
+ const char *name;
+ int len;
+ const char *bits;
+} BuiltinFileRec, *BuiltinFilePtr;
+
+typedef struct _BuiltinDir {
+ char *file_name;
+ char *font_name;
+} BuiltinDirRec, *BuiltinDirPtr;
+
+typedef struct _BuiltinAlias {
+ char *alias_name;
+ char *font_name;
+} BuiltinAliasRec, *BuiltinAliasPtr;
+
+extern const BuiltinFileRec builtin_files[];
+extern const int builtin_files_count;
+
+extern const BuiltinDirRec builtin_dir[];
+extern const int builtin_dir_count;
+
+extern const BuiltinAliasRec builtin_alias[];
+extern const int builtin_alias_count;
+
+extern FontFilePtr BuiltinFileOpen ();
+extern int BuiltinFileClose ();
diff --git a/nx-X11/lib/font/builtins/dir.c b/nx-X11/lib/font/builtins/dir.c
new file mode 100644
index 000000000..fb2f82c41
--- /dev/null
+++ b/nx-X11/lib/font/builtins/dir.c
@@ -0,0 +1,64 @@
+/*
+ * Id: dir.c,v 1.2 1999/11/02 06:16:47 keithp Exp $
+ *
+ * Copyright 1999 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+/* $XFree86: xc/lib/font/builtins/dir.c,v 1.3 1999/12/30 02:29:49 robin Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "builtin.h"
+
+int
+BuiltinReadDirectory (directory, pdir)
+ char *directory;
+ FontDirectoryPtr *pdir;
+{
+ FontDirectoryPtr dir;
+ int i;
+
+ dir = FontFileMakeDir ("", builtin_dir_count);
+ for (i = 0; i < builtin_dir_count; i++)
+ {
+ if (!FontFileAddFontFile (dir,
+ (char *) builtin_dir[i].font_name,
+ (char *) builtin_dir[i].file_name))
+ {
+ FontFileFreeDir (dir);
+ return BadFontPath;
+ }
+ }
+ for (i = 0; i < builtin_alias_count; i++)
+ {
+ if (!FontFileAddFontAlias (dir,
+ (char *) builtin_alias[i].alias_name,
+ (char *) builtin_alias[i].font_name))
+ {
+ FontFileFreeDir (dir);
+ return BadFontPath;
+ }
+ }
+ FontFileSortDir (dir);
+ *pdir = dir;
+ return Successful;
+}
diff --git a/nx-X11/lib/font/builtins/file.c b/nx-X11/lib/font/builtins/file.c
new file mode 100644
index 000000000..024c35343
--- /dev/null
+++ b/nx-X11/lib/font/builtins/file.c
@@ -0,0 +1,139 @@
+/*
+ * Id: file.c,v 1.2 1999/11/02 06:16:47 keithp Exp $
+ *
+ * Copyright 1999 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+/* $XFree86: xc/lib/font/builtins/file.c,v 1.3 1999/12/30 02:29:49 robin Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "builtin.h"
+
+typedef struct _BuiltinIO {
+ int offset;
+ BuiltinFilePtr file;
+} BuiltinIORec, *BuiltinIOPtr;
+
+static int
+BuiltinFill (f)
+ BufFilePtr f;
+{
+ int left, len;
+ BuiltinIOPtr io = ((BuiltinIOPtr) f->private);
+
+ left = io->file->len - io->offset;
+ if (left <= 0)
+ {
+ f->left = 0;
+ return BUFFILEEOF;
+ }
+ len = BUFFILESIZE;
+ if (len > left)
+ len = left;
+ bcopy (io->file->bits + io->offset, f->buffer, len);
+ io->offset += len;
+ f->left = len - 1;
+ f->bufp = f->buffer + 1;
+ return f->buffer[0];
+}
+
+static int
+BuiltinSkip (f, count)
+ BufFilePtr f;
+ int count;
+{
+ BuiltinIOPtr io = ((BuiltinIOPtr) f->private);
+ int curoff;
+ int fileoff;
+ int todo;
+ int left;
+
+ curoff = f->bufp - f->buffer;
+ fileoff = curoff + f->left;
+ if (curoff + count <= fileoff) {
+ f->bufp += count;
+ f->left -= count;
+ } else {
+ todo = count - (fileoff - curoff);
+ io->offset += todo;
+ if (io->offset > io->file->len)
+ io->offset = io->file->len;
+ if (io->offset < 0)
+ io->offset = 0;
+ f->left = 0;
+ }
+ return count;
+}
+
+static int
+BuiltinClose (f, doClose)
+ BufFilePtr f;
+{
+ BuiltinIOPtr io = ((BuiltinIOPtr) f->private);
+
+ xfree (io);
+ return 1;
+}
+
+
+FontFilePtr
+BuiltinFileOpen (name)
+ char *name;
+{
+ int i;
+ BuiltinIOPtr io;
+ BufFilePtr raw, cooked;
+
+ if (*name == '/') name++;
+ for (i = 0; i < builtin_files_count; i++)
+ if (!strcmp (name, builtin_files[i].name))
+ break;
+ if (i == builtin_files_count)
+ return NULL;
+ io = (BuiltinIOPtr) xalloc (sizeof (BuiltinIORec));
+ if (!io)
+ return NULL;
+ io->offset = 0;
+ io->file = (void *) &builtin_files[i];
+ raw = BufFileCreate ((char *) io, BuiltinFill, 0, BuiltinSkip, BuiltinClose);
+ if (!raw)
+ {
+ xfree (io);
+ return NULL;
+ }
+ if (cooked = BufFilePushCompressed (raw))
+ raw = cooked;
+ else
+ {
+ raw->left += raw->bufp - raw->buffer;
+ raw->bufp = raw->buffer;
+ }
+ return (FontFilePtr) raw;
+}
+
+int
+BuiltinFileClose (f)
+ FontFilePtr f;
+{
+ return BufFileClose ((BufFilePtr) f, TRUE);
+}
diff --git a/nx-X11/lib/font/builtins/fonts.c b/nx-X11/lib/font/builtins/fonts.c
new file mode 100644
index 000000000..30c762f7f
--- /dev/null
+++ b/nx-X11/lib/font/builtins/fonts.c
@@ -0,0 +1,2438 @@
+/*
+ * Id: fonts.c,v 1.2 1999/11/02 06:16:47 keithp Exp $
+ *
+ * Copyright 1999 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+/* $XFree86: xc/lib/font/builtins/fonts.c,v 1.3 1999/12/30 02:29:49 robin Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "builtin.h"
+
+static const char file_6x13[] = {
+ '\037', '\235', '\214', '\001', '\314', '\214', '\201', '\223',
+ '\000', '\200', '\301', '\000', '\006', '\023', '\032', '\244',
+ '\042', '\300', '\040', '\246', '\204', '\015', '\023', '\042',
+ '\004', '\100', '\046', '\041', '\273', '\210', '\004', '\024',
+ '\116', '\104', '\223', '\021', '\000', '\224', '\001', '\006',
+ '\021', '\050', '\114', '\210', '\317', '\201', '\101', '\134',
+ '\007', '\014', '\102', '\320', '\150', '\220', '\243', '\101',
+ '\130', '\026', '\014', '\202', '\030', '\251', '\062', '\042',
+ '\206', '\015', '\006', '\201', '\320', '\004', '\200', '\010',
+ '\044', '\000', '\024', '\035', '\014', '\002', '\332', '\211',
+ '\104', '\044', '\000', '\130', '\063', '\017', '\112', '\064',
+ '\130', '\321', '\040', '\076', '\024', '\064', '\053', '\354',
+ '\014', '\040', '\041', '\341', '\004', '\211', '\070', '\145',
+ '\112', '\144', '\221', '\120', '\206', '\104', '\037', '\011',
+ '\213', '\110', '\134', '\222', '\260', '\211', '\304', '\055',
+ '\011', '\323', '\110', '\304', '\223', '\060', '\217', '\302',
+ '\006', '\011', '\011', '\051', '\144', '\153', '\360', '\221',
+ '\102', '\262', '\006', '\071', '\335', '\115', '\230', '\112',
+ '\142', '\254', '\204', '\263', '\024', '\362', '\110', '\030',
+ '\114', '\242', '\264', '\204', '\332', '\044', '\256', '\113',
+ '\330', '\116', '\342', '\275', '\204', '\035', '\046', '\006',
+ '\020', '\061', '\121', '\314', '\104', '\000', '\012', '\322',
+ '\136', '\136', '\223', '\220', '\316', '\345', '\005', '\011',
+ '\373', '\134', '\066', '\100', '\023', '\321', '\104', '\043',
+ '\117', '\234', '\120', '\161', '\022', '\244', '\111', '\221',
+ '\057', '\122', '\212', '\034', '\111', '\062', '\205', '\212',
+ '\224', '\054', '\006', '\121', '\127', '\161', '\102', '\344',
+ '\066', '\200', '\046', '\151', '\346', '\214', '\001', '\140',
+ '\244', '\165', '\022', '\046', '\131', '\276', '\260', '\166',
+ '\115', '\074', '\015', '\236', '\062', '\025', '\257', '\024',
+ '\111', '\162', '\004', '\011', '\025', '\345', '\255', '\305',
+ '\066', '\201', '\236', '\246', '\116', '\033', '\000', '\123',
+ '\230', '\004', '\121', '\015', '\100', '\012', '\370', '\042',
+ '\124', '\256', '\044', '\041', '\102', '\005', '\011', '\166',
+ '\346', '\123', '\312', '\264', '\111', '\063', '\344', '\215',
+ '\033', '\062', '\145', '\334', '\314', '\201', '\016', '\040',
+ '\010', '\021', '\042', '\137', '\324', '\226', '\005', '\023',
+ '\257', '\055', '\047', '\226', '\107', '\111', '\140', '\121',
+ '\004', '\023', '\001', '\046', '\241', '\205', '\130', '\120',
+ '\074', '\221', '\204', '\152', '\015', '\076', '\130', '\136',
+ '\021', '\123', '\074', '\301', '\104', '\025', '\124', '\044',
+ '\221', '\332', '\027', '\130', '\134', '\230', '\341', '\206',
+ '\035', '\176', '\210', '\333', '\024', '\120', '\004', '\061',
+ '\304', '\204', '\107', '\000', '\060', '\104', '\177', '\126',
+ '\024', '\041', '\105', '\020', '\107', '\274', '\246', '\036',
+ '\173', '\110', '\270', '\210', '\104', '\020', '\122', '\114',
+ '\201', '\036', '\154', '\262', '\321', '\146', '\033', '\156',
+ '\264', '\075', '\201', '\003', '\016', '\065', '\344', '\240',
+ '\043', '\217', '\076', '\136', '\127', '\204', '\023', '\103',
+ '\074', '\101', '\004', '\213', '\000', '\304', '\340', '\342',
+ '\023', '\120', '\144', '\041', '\005', '\165', '\326', '\171',
+ '\124', '\207', '\030', '\154', '\244', '\061', '\006', '\010',
+ '\144', '\274', '\321', '\106', '\030', '\151', '\270', '\001',
+ '\202', '\031', '\366', '\321', '\341', '\002', '\010', '\040',
+ '\114', '\201', '\106', '\030', '\162', '\224', '\001', '\102',
+ '\030', '\367', '\201', '\220', '\237', '\032', '\157', '\344',
+ '\341', '\002', '\161', '\251', '\121', '\001', '\100', '\013',
+ '\300', '\011', '\327', '\202', '\021', '\316', '\101', '\107',
+ '\050', '\167', '\336', '\265', '\040', '\105', '\013', '\361',
+ '\315', '\127', '\337', '\175', '\371', '\355', '\107', '\106',
+ '\013', '\055', '\304', '\060', '\103', '\246', '\062', '\300',
+ '\320', '\302', '\015', '\065', '\174', '\032', '\352', '\020',
+ '\055', '\330', '\340', '\151', '\221', '\107', '\046', '\231',
+ '\051', '\000', '\322', '\161', '\051', '\150', '\154', '\043',
+ '\162', '\350', '\241', '\023', '\000', '\140', '\361', '\005',
+ '\022', '\323', '\125', '\047', '\150', '\024', '\125', '\370',
+ '\367', '\305', '\215', '\355', '\051', '\005', '\100', '\000',
+ '\304', '\026', '\153', '\020', '\150', '\006', '\105', '\264',
+ '\023', '\151', '\244', '\201', '\246', '\254', '\101', '\314',
+ '\002', '\340', '\354', '\262', '\044', '\375', '\223', '\054',
+ '\000', '\321', '\116', '\273', '\323', '\266', '\334', '\116',
+ '\145', '\020', '\070', '\000', '\000', '\142', '\210', '\041',
+ '\213', '\010', '\042', '\056', '\271', '\346', '\216', '\133',
+ '\356', '\271', '\353', '\252', '\233', '\056', '\272', '\354',
+ '\276', '\333', '\056', '\274', '\356', '\306', '\153', '\157',
+ '\275', '\370', '\322', '\253', '\357', '\274', '\374', '\312',
+ '\353', '\357', '\275', '\373', '\376', '\233', '\157', '\277',
+ '\000', '\023', '\074', '\260', '\300', '\001', '\027', '\214',
+ '\260', '\301', '\011', '\037', '\254', '\360', '\303', '\016',
+ '\107', '\334', '\360', '\304', '\014', '\127', '\274', '\360',
+ '\305', '\020', '\123', '\214', '\261', '\304', '\026', '\147',
+ '\334', '\061', '\307', '\033', '\153', '\354', '\161', '\310',
+ '\037', '\213', '\014', '\362', '\310', '\050', '\237', '\254',
+ '\262', '\311', '\054', '\227', '\354', '\062', '\311', '\060',
+ '\247', '\334', '\162', '\314', '\053', '\277', '\054', '\263',
+ '\315', '\065', '\323', '\074', '\363', '\315', '\072', '\343',
+ '\274', '\163', '\316', '\074', '\007', '\015', '\364', '\320',
+ '\077', '\027', '\355', '\363', '\321', '\376', '\322', '\004',
+ '\056', '\115', '\160', '\031', '\244', '\101', '\102', '\047',
+ '\044', '\104', '\103', '\102', '\101', '\044', '\104', '\253',
+ '\101', '\150', '\265', '\224', '\120', '\035', '\011', '\011',
+ '\222', '\220', '\135', '\171', '\361', '\225', '\220', '\055',
+ '\011', '\015', '\223', '\020', '\064', '\011', '\165', '\223',
+ '\220', '\072', '\011', '\075', '\146', '\020', '\001', '\023',
+ '\105', '\060', '\221', '\007', '\023', '\255', '\060', '\021',
+ '\016', '\023', '\025', '\061', '\221', '\024', '\023', '\175',
+ '\061', '\021', '\033', '\023', '\345', '\061', '\221', '\041',
+ '\023', '\115', '\062', '\021', '\050', '\023', '\265', '\062',
+ '\221', '\056', '\023', '\035', '\063', '\021', '\065', '\023',
+ '\205', '\063', '\221', '\073', '\023', '\355', '\063', '\021',
+ '\002', '\021', '\125', '\020', '\221', '\010', '\021', '\275',
+ '\020', '\021', '\017', '\021', '\045', '\021', '\221', '\025',
+ '\021', '\215', '\021', '\021', '\034', '\021', '\365', '\021',
+ '\221', '\042', '\021', '\135', '\022', '\021', '\051', '\021',
+ '\305', '\022', '\221', '\057', '\021', '\055', '\023', '\021',
+ '\066', '\021', '\225', '\023', '\221', '\074', '\021', '\375',
+ '\023', '\021', '\003', '\076', '\145', '\340', '\223', '\011',
+ '\076', '\315', '\340', '\023', '\020', '\076', '\065', '\341',
+ '\223', '\026', '\076', '\235', '\341', '\023', '\035', '\076',
+ '\005', '\342', '\223', '\043', '\076', '\155', '\342', '\023',
+ '\052', '\076', '\325', '\342', '\223', '\060', '\076', '\075',
+ '\343', '\023', '\067', '\076', '\245', '\343', '\223', '\075',
+ '\076', '\015', '\320', '\021', '\004', '\035', '\165', '\320',
+ '\221', '\012', '\035', '\335', '\320', '\021', '\021', '\035',
+ '\105', '\321', '\221', '\027', '\035', '\255', '\321', '\021',
+ '\036', '\035', '\025', '\322', '\221', '\044', '\035', '\175',
+ '\322', '\021', '\053', '\035', '\311', '\105', '\107', '\214',
+ '\321', '\221', '\151', '\164', '\004', '\034', '\035', '\151',
+ '\107', '\107', '\364', '\321', '\221', '\003', '\024', '\300',
+ '\040', '\024', '\170', '\040', '\000', '\102', '\040', '\101',
+ '\027', '\110', '\160', '\007', '\022', '\104', '\202', '\004',
+ '\253', '\040', '\101', '\061', '\110', '\360', '\015', '\022',
+ '\344', '\203', '\004', '\023', '\041', '\101', '\113', '\110',
+ '\160', '\024', '\022', '\204', '\205', '\004', '\173', '\041',
+ '\101', '\145', '\110', '\360', '\032', '\022', '\044', '\207',
+ '\004', '\343', '\041', '\101', '\177', '\110', '\160', '\001',
+ '\244', '\001', '\000', '\006', '\162', '\130', '\202', '\034',
+ '\312', '\040', '\207', '\077', '\310', '\041', '\023', '\162',
+ '\230', '\205', '\034', '\232', '\041', '\207', '\163', '\310',
+ '\041', '\040', '\162', '\330', '\210', '\034', '\152', '\042',
+ '\207', '\247', '\310', '\041', '\055', '\162', '\030', '\214',
+ '\034', '\072', '\043', '\207', '\333', '\310', '\041', '\072',
+ '\162', '\130', '\217', '\034', '\012', '\040', '\045', '\000',
+ '\170', '\000', '\030', '\071', '\000', '\306', '\024', '\200',
+ '\321', '\006', '\140', '\034', '\002', '\030', '\241', '\000',
+ '\306', '\056', '\200', '\121', '\015', '\140', '\274', '\003',
+ '\030', '\011', '\001', '\306', '\110', '\200', '\321', '\023',
+ '\140', '\134', '\005', '\030', '\121', '\142', '\220', '\142',
+ '\200', '\121', '\032', '\140', '\374', '\006', '\030', '\331',
+ '\001', '\306', '\174', '\200', '\321', '\000', '\106', '\231',
+ '\200', '\121', '\100', '\140', '\224', '\026', '\030', '\105',
+ '\007', '\106', '\071', '\202', '\121', '\250', '\140', '\224',
+ '\060', '\030', '\305', '\015', '\106', '\331', '\203', '\121',
+ '\020', '\141', '\224', '\112', '\030', '\105', '\024', '\106',
+ '\171', '\205', '\121', '\170', '\141', '\224', '\144', '\030',
+ '\305', '\032', '\106', '\031', '\207', '\121', '\340', '\141',
+ '\224', '\176', '\030', '\105', '\001', '\005', '\001', '\300',
+ '\005', '\142', '\111', '\202', '\130', '\306', '\040', '\226',
+ '\076', '\210', '\345', '\022', '\142', '\211', '\205', '\130',
+ '\226', '\041', '\226', '\162', '\210', '\345', '\037', '\142',
+ '\311', '\210', '\130', '\146', '\042', '\226', '\246', '\210',
+ '\345', '\054', '\142', '\011', '\214', '\130', '\066', '\043',
+ '\226', '\332', '\210', '\345', '\071', '\142', '\111', '\217',
+ '\130', '\006', '\040', '\063', '\000', '\160', '\000', '\066',
+ '\067', '\200', '\115', '\024', '\140', '\263', '\006', '\330',
+ '\024', '\002', '\066', '\237', '\200', '\115', '\056', '\140',
+ '\063', '\015', '\330', '\264', '\003', '\066', '\007', '\201',
+ '\115', '\110', '\140', '\263', '\023', '\330', '\124', '\005',
+ '\066', '\157', '\201', '\115', '\142', '\140', '\063', '\032',
+ '\330', '\364', '\006', '\066', '\327', '\201', '\115', '\174',
+ '\140', '\263', '\000', '\310', '\222', '\000', '\262', '\076',
+ '\200', '\054', '\026', '\040', '\053', '\007', '\310', '\062',
+ '\002', '\262', '\246', '\200', '\054', '\060', '\040', '\013',
+ '\030', '\061', '\011', '\127', '\013', '\022', '\222', '\065',
+ '\000', '\170', '\340', '\242', '\030', '\315', '\250', '\007',
+ '\150', '\102', '\000', '\007', '\174', '\300', '\001', '\035',
+ '\061', '\210', '\012', '\052', '\060', '\322', '\222', '\222',
+ '\364', '\244', '\012', '\051', '\100', '\001', '\034', '\130',
+ '\000', '\220', '\022', '\040', '\244', '\000', '\070', '\100',
+ '\000', '\006', '\020', '\200', '\007', '\010', '\300', '\000',
+ '\002', '\170', '\226', '\003', '\210', '\345', '\000', '\007',
+ '\110', '\100', '\233', '\125', '\221', '\010', '\261', '\016',
+ '\340', '\200', '\233', '\346', '\024', '\132', '\011', '\110',
+ '\100', '\016', '\271', '\365', '\322', '\017', '\274', '\024',
+ '\000', '\037', '\240', '\111', '\004', '\046', '\120', '\201',
+ '\014', '\104', '\040', '\247', '\002', '\330', '\150', '\102',
+ '\042', '\020', '\001', '\005', '\144', '\304', '\251', '\057',
+ '\015', '\253', '\130', '\301', '\330', '\255', '\003', '\210',
+ '\025', '\246', '\011', '\341', '\301', '\131', '\327', '\112',
+ '\200', '\301', '\050', '\204', '\255', '\077', '\070', '\153',
+ '\102', '\176', '\320', '\055', '\205', '\320', '\265', '\256',
+ '\006', '\271', '\053', '\136', '\365', '\132', '\127', '\272',
+ '\262', '\125', '\255', '\154', '\035', '\153', '\140', '\305',
+ '\312', '\327', '\155', '\305', '\165', '\260', '\201', '\115',
+ '\010', '\004', '\020', '\100', '\000', '\001', '\020', '\000',
+ '\001', '\020', '\210', '\252', '\106', '\034', '\313', '\130',
+ '\001', '\004', '\100', '\262', '\043', '\371', '\200', '\002',
+ '\066', '\013', '\313', '\235', '\104', '\226', '\000', '\037',
+ '\270', '\214', '\101', '\030', '\040', '\201', '\234', '\036',
+ '\040', '\247', '\022', '\150', '\332', '\266', '\320', '\212',
+ '\327', '\267', '\255', '\025', '\000', '\060', '\345', '\154',
+ '\135', '\067', '\253', '\131', '\315', '\142', '\063', '\041',
+ '\004', '\360', '\200', '\112', '\035', '\100', '\001', '\012',
+ '\074', '\000', '\246', '\022', '\250', '\200', '\002', '\052',
+ '\253', '\200', '\012', '\304', '\062', '\131', '\052', '\025',
+ '\100', '\001', '\062', '\220', '\200', '\210', '\046', '\204',
+ '\001', '\215', '\355', '\026', '\143', '\033', '\233', '\323',
+ '\227', '\032', '\045', '\131', '\326', '\105', '\300', '\164',
+ '\237', '\005', '\333', '\012', '\174', '\364', '\003', '\025',
+ '\140', '\055', '\154', '\101', '\373', '\124', '\274', '\102',
+ '\227', '\273', '\006', '\301', '\054', '\136', '\073', '\032',
+ '\122', '\010', '\054', '\266', '\262', '\226', '\025', '\055',
+ '\001', '\024', '\300', '\325', '\372', '\172', '\365', '\255',
+ '\006', '\050', '\300', '\131', '\325', '\353', '\000', '\256',
+ '\056', '\266', '\261', '\227', '\125', '\310', '\007', '\376',
+ '\353', '\000', '\367', '\106', '\300', '\044', '\011', '\321',
+ '\056', '\003', '\066', '\233', '\200', '\017', '\150', '\127',
+ '\300', '\304', '\152', '\300', '\004', '\014', '\214', '\140',
+ '\203', '\364', '\227', '\130', '\017', '\250', '\157', '\205',
+ '\241', '\372', '\336', '\227', '\142', '\125', '\041', '\375',
+ '\345', '\152', '\210', '\017', '\014', '\342', '\372', '\172',
+ '\200', '\302', '\034', '\005', '\351', '\333', '\124', '\374',
+ '\126', '\026', '\237', '\127', '\261', '\225', '\015', '\000',
+ '\145', '\127', '\102', '\023', '\311', '\252', '\367', '\040',
+ '\063', '\216', '\161', '\211', '\043', '\360', '\337', '\214',
+ '\300', '\064', '\304', '\031', '\250', '\100', '\005', '\032',
+ '\020', '\000', '\255', '\276', '\215', '\276', '\134', '\375',
+ '\100', '\175', '\025', '\362', '\000', '\011', '\070', '\331',
+ '\247', '\116', '\176', '\100', '\211', '\213', '\105', '\054',
+ '\022', '\047', '\244', '\311', '\116', '\316', '\262', '\004',
+ '\244', '\234', '\220', '\320', '\142', '\270', '\130', '\352',
+ '\365', '\162', '\115', '\251', '\074', '\145', '\142', '\131',
+ '\325', '\312', '\006', '\251', '\157', '\004', '\224', '\274',
+ '\344', '\204', '\270', '\364', '\254', '\033', '\346', '\200',
+ '\166', '\347', '\214', '\000', '\245', '\052', '\204', '\253',
+ '\011', '\050', '\300', '\000', '\012', '\220', '\000', '\256',
+ '\152', '\204', '\312', '\140', '\276', '\163', '\004', '\066',
+ '\040', '\144', '\065', '\337', '\171', '\002', '\124', '\255',
+ '\352', '\231', '\167', '\254', '\146', '\064', '\207', '\261',
+ '\276', '\017', '\040', '\263', '\233', '\033', '\035', '\201',
+ '\012', '\024', '\370', '\312', '\220', '\346', '\263', '\237',
+ '\047', '\315', '\123', '\024', '\167', '\071', '\261', '\133',
+ '\245', '\264', '\243', '\325', '\314', '\331', '\362', '\246',
+ '\271', '\276', '\102', '\256', '\300', '\006', '\042', '\040',
+ '\350', '\315', '\316', '\027', '\311', '\255', '\366', '\252',
+ '\130', '\005', '\334', '\341', '\234', '\006', '\330', '\315',
+ '\130', '\315', '\365', '\206', '\211', '\125', '\135', '\355',
+ '\272', '\027', '\304', '\164', '\236', '\363', '\206', '\347',
+ '\313', '\352', '\326', '\146', '\366', '\271', '\220', '\155',
+ '\155', '\201', '\075', '\300', '\125', '\043', '\017', '\013',
+ '\303', '\152', '\346', '\362', '\110', '\056', '\034', '\000',
+ '\107', '\273', '\027', '\002', '\314', '\066', '\361', '\116',
+ '\372', '\033', '\132', '\107', '\223', '\066', '\247', '\066',
+ '\375', '\060', '\115', '\106', '\174', '\142', '\053', '\027',
+ '\113', '\302', '\206', '\176', '\053', '\266', '\304', '\272',
+ '\141', '\000', '\210', '\204', '\001', '\164', '\116', '\152',
+ '\016', '\213', '\225', '\347', '\075', '\367', '\131', '\041',
+ '\006', '\140', '\153', '\273', '\217', '\225', '\352', '\012',
+ '\024', '\173', '\044', '\350', '\156', '\363', '\264', '\325',
+ '\274', '\357', '\107', '\163', '\065', '\322', '\304', '\032',
+ '\111', '\266', '\043', '\160', '\342', '\137', '\277', '\145',
+ '\002', '\222', '\036', '\070', '\042', '\035', '\015', '\000',
+ '\160', '\143', '\125', '\002', '\014', '\330', '\211', '\232',
+ '\063', '\340', '\134', '\101', '\167', '\365', '\276', '\122',
+ '\255', '\264', '\220', '\157', '\173', '\147', '\131', '\323',
+ '\127', '\343', '\134', '\345', '\070', '\004', '\050', '\356',
+ '\140', '\000', '\253', '\027', '\003', '\141', '\065', '\337',
+ '\113', '\061', '\360', '\126', '\120', '\033', '\104', '\346',
+ '\004', '\200', '\371', '\113', '\175', '\142', '\220', '\340',
+ '\036', '\327', '\330', '\100', '\127', '\067', '\133', '\133',
+ '\134', '\001', '\225', '\132', '\032', '\255', '\337', '\376',
+ '\042', '\152', '\125', '\273', '\125', '\155', '\052', '\240',
+ '\277', '\043', '\341', '\052', '\155', '\311', '\013', '\323',
+ '\131', '\317', '\172', '\264', '\245', '\045', '\055', '\306',
+ '\041', '\200', '\161', '\205', '\144', '\205', '\133', '\375',
+ '\125', '\365', '\004', '\010', '\115', '\361', '\145', '\063',
+ '\034', '\252', '\333', '\242', '\200', '\002', '\124', '\252',
+ '\000', '\012', '\160', '\153', '\300', '\064', '\336', '\326',
+ '\215', '\055', '\034', '\201', '\013', '\154', '\140', '\003',
+ '\166', '\147', '\271', '\171', '\235', '\234', '\161', '\246',
+ '\122', '\035', '\355', '\020', '\321', '\357', '\027', '\267',
+ '\245', '\134', '\307', '\362', '\174', '\044', '\214', '\005',
+ '\372', '\306', '\057', '\160', '\031', '\017', '\134', '\340',
+ '\361', '\027', '\260', '\100', '\157', '\335', '\276', '\223',
+ '\276', '\003', '\075', '\361', '\002', '\030', '\200', '\151',
+ '\271', '\245', '\365', '\214', '\073', '\173', '\044', '\005',
+ '\150', '\273', '\332', '\045', '\230', '\054', '\315', '\177',
+ '\021', '\002', '\030', '\240', '\000', '\007', '\342', '\236',
+ '\171', '\323', '\042', '\200', '\002', '\213', '\345', '\100',
+ '\340', '\035', '\133', '\000', '\011', '\244', '\176', '\365',
+ '\102', '\007', '\260', '\210', '\161', '\053', '\022', '\142',
+ '\257', '\171', '\323', '\356', '\366', '\061', '\222', '\331',
+ '\374', '\334', '\252', '\370', '\236', '\370', '\020', '\314',
+ '\314', '\361', '\201', '\277', '\131', '\330', '\016', '\037',
+ '\370', '\363', '\175', '\351', '\363', '\377', '\015', '\000',
+ '\015', '\250', '\264', '\000', '\015', '\140', '\151', '\120',
+ '\070', '\115', '\345', '\003', '\107', '\367', '\261', '\120',
+ '\375', '\362', '\255', '\203', '\037', '\376', '\061', '\217',
+ '\337', '\000', '\005', '\361', '\062', '\302', '\061', '\333',
+ '\174', '\365', '\023', '\013', '\263', '\340', '\007', '\153',
+ '\130', '\061', '\233', '\170', '\371', '\067', '\265', '\370',
+ '\120', '\335', '\157', '\102', '\332', '\257', '\377', '\053',
+ '\147', '\371', '\002', '\131', '\046', '\155', '\152', '\007',
+ '\000', '\134', '\105', '\125', '\213', '\366', '\066', '\042',
+ '\061', '\142', '\273', '\027', '\022', '\031', '\241', '\200',
+ '\150', '\106', '\132', '\331', '\324', '\150', '\025', '\066',
+ '\200', '\016', '\130', '\141', '\315', '\127', '\201', '\032',
+ '\347', '\125', '\047', '\247', '\130', '\016', '\220', '\001',
+ '\101', '\046', '\144', '\210', '\266', '\123', '\010', '\110',
+ '\200', '\022', '\230', '\140', '\031', '\101', '\151', '\025',
+ '\006', '\201', '\050', '\270', '\177', '\231', '\261', '\202',
+ '\014', '\110', '\202', '\262', '\146', '\152', '\303', '\222',
+ '\141', '\007', '\147', '\054', '\073', '\106', '\203', '\023',
+ '\100', '\144', '\043', '\230', '\115', '\330', '\026', '\001',
+ '\034', '\147', '\202', '\026', '\326', '\203', '\077', '\210',
+ '\165', '\101', '\310', '\154', '\103', '\010', '\000', '\003',
+ '\310', '\203', '\106', '\350', '\134', '\315', '\247', '\204',
+ '\076', '\350', '\134', '\244', '\225', '\161', '\146', '\167',
+ '\204', '\040', '\106', '\001', '\016', '\120', '\000', '\302',
+ '\265', '\155', '\162', '\123', '\155', '\040', '\325', '\020',
+ '\340', '\027', '\201', '\335', '\126', '\141', '\211', '\007',
+ '\206', '\134', '\210', '\177', '\144', '\210', '\146', '\115',
+ '\310', '\155', '\145', '\270', '\203', '\371', '\066', '\177',
+ '\100', '\270', '\156', '\156', '\110', '\204', '\160', '\170',
+ '\177', '\006', '\321', '\204', '\155', '\110', '\207', '\230',
+ '\101', '\000', '\210', '\244', '\200', '\023', '\210', '\115',
+ '\001', '\007', '\175', '\106', '\301', '\207', '\157', '\050',
+ '\210', '\162', '\110', '\210', '\110', '\210', '\115', '\206',
+ '\230', '\206', '\004', '\067', '\022', '\117', '\025', '\125',
+ '\062', '\310', '\201', '\037', '\070', '\001', '\042', '\010',
+ '\133', '\106', '\321', '\150', '\106', '\066', '\206', '\226',
+ '\150', '\206', '\231', '\130', '\207', '\330', '\264', '\211',
+ '\344', '\107', '\202', '\117', '\270', '\162', '\025', '\026',
+ '\141', '\023', '\120', '\200', '\104', '\206', '\020', '\115',
+ '\130', '\137', '\052', '\107', '\142', '\023', '\001', '\056',
+ '\201', '\120', '\010', '\206', '\240', '\010', '\201', '\000',
+ '\010', '\260', '\150', '\010', '\177', '\160', '\056', '\212',
+ '\140', '\056', '\204', '\140', '\010', '\207', '\240', '\213',
+ '\274', '\150', '\056', '\260', '\330', '\213', '\200', '\260',
+ '\213', '\302', '\270', '\213', '\211', '\260', '\007', '\264',
+ '\310', '\213', '\200', '\220', '\214', '\302', '\030', '\214',
+ '\346', '\062', '\010', '\344', '\322', '\007', '\200', '\000',
+ '\215', '\204', '\040', '\010', '\202', '\060', '\056', '\325',
+ '\170', '\215', '\321', '\010', '\060', '\210', '\220', '\007',
+ '\347', '\142', '\010', '\310', '\210', '\215', '\322', '\070',
+ '\056', '\202', '\160', '\213', '\343', '\002', '\010', '\201',
+ '\240', '\215', '\353', '\002', '\215', '\374', '\062', '\216',
+ '\206', '\220', '\215', '\354', '\010', '\214', '\206', '\200',
+ '\010', '\313', '\010', '\213', '\364', '\230', '\214', '\206',
+ '\120', '\217', '\343', '\162', '\213', '\260', '\230', '\010',
+ '\200', '\040', '\010', '\320', '\070', '\010', '\176', '\260',
+ '\214', '\371', '\370', '\217', '\320', '\350', '\217', '\201',
+ '\140', '\214', '\172', '\220', '\214', '\210', '\300', '\217',
+ '\206', '\340', '\217', '\311', '\010', '\221', '\375', '\370',
+ '\007', '\011', '\371', '\220', '\172', '\120', '\221', '\010',
+ '\151', '\214', '\372', '\330', '\220', '\314', '\350', '\007',
+ '\025', '\051', '\010', '\263', '\010', '\213', '\205', '\300',
+ '\007', '\037', '\031', '\222', '\017', '\251', '\217', '\022',
+ '\171', '\222', '\021', '\211', '\222', '\054', '\271', '\222',
+ '\056', '\331', '\217', '\055', '\011', '\223', '\025', '\171',
+ '\010', '\201', '\060', '\223', '\046', '\231', '\222', '\206',
+ '\060', '\220', '\060', '\371', '\222', '\052', '\271', '\223',
+ '\076', '\331', '\223', '\100', '\231', '\222', '\102', '\311',
+ '\222', '\030', '\031', '\223', '\101', '\151', '\224', '\103',
+ '\311', '\223', '\211', '\160', '\223', '\110', '\331', '\224',
+ '\112', '\331', '\224', '\105', '\271', '\222', '\121', '\331',
+ '\217', '\013', '\011', '\213', '\350', '\050', '\010', '\124',
+ '\211', '\217', '\106', '\131', '\220', '\077', '\311', '\225',
+ '\100', '\151', '\010', '\362', '\230', '\221', '\363', '\270',
+ '\214', '\273', '\210', '\010', '\141', '\211', '\216', '\032',
+ '\251', '\225', '\152', '\131', '\213', '\372', '\010', '\226',
+ '\370', '\050', '\217', '\136', '\351', '\225', '\367', '\310',
+ '\226', '\153', '\171', '\216', '\165', '\351', '\226', '\164',
+ '\011', '\223', '\000', '\171', '\224', '\021', '\271', '\220',
+ '\342', '\262', '\214', '\004', '\271', '\214', '\173', '\051',
+ '\224', '\016', '\231', '\222', '\207', '\120', '\230', '\006',
+ '\171', '\222', '\257', '\030', '\213', '\050', '\211', '\007',
+ '\311', '\250', '\010', '\205', '\251', '\223', '\274', '\350',
+ '\220', '\205', '\040', '\231', '\043', '\371', '\230', '\205',
+ '\211', '\007', '\213', '\171', '\214', '\014', '\171', '\213',
+ '\320', '\250', '\010', '\310', '\370', '\231', '\173', '\040',
+ '\010', '\273', '\250', '\010', '\216', '\131', '\213', '\114',
+ '\111', '\232', '\206', '\060', '\222', '\252', '\371', '\217',
+ '\323', '\030', '\213', '\173', '\260', '\231', '\322', '\030',
+ '\214', '\016', '\251', '\010', '\372', '\150', '\233', '\217',
+ '\151', '\224', '\270', '\011', '\213', '\273', '\311', '\230',
+ '\271', '\371', '\233', '\274', '\211', '\224', '\362', '\330',
+ '\233', '\304', '\171', '\233', '\306', '\011', '\234', '\276',
+ '\031', '\234', '\074', '\131', '\234', '\310', '\311', '\234',
+ '\312', '\131', '\213', '\265', '\151', '\222', '\316', '\231',
+ '\234', '\324', '\331', '\233', '\051', '\211', '\010', '\322',
+ '\171', '\234', '\317', '\131', '\235', '\332', '\151', '\227',
+ '\265', '\070', '\234', '\335', '\071', '\235', '\342', '\031',
+ '\236', '\344', '\331', '\234', '\345', '\151', '\217', '\016',
+ '\111', '\223', '\346', '\271', '\236', '\274', '\051', '\217',
+ '\146', '\371', '\230', '\136', '\263', '\023', '\326', '\262',
+ '\055', '\010', '\321', '\020', '\040', '\221', '\021', '\017',
+ '\104', '\032', '\051', '\041', '\022', '\005', '\221', '\031',
+ '\240', '\221', '\161', '\160', '\141', '\022', '\122', '\266',
+ '\022', '\254', '\126', '\025', '\127', '\341', '\166', '\122',
+ '\021', '\023', '\027', '\240', '\103', '\000', '\220', '\001',
+ '\325', '\007', '\000', '\070', '\041', '\173', '\101', '\261',
+ '\121', '\121', '\065', '\023', '\041', '\000', '\000', '\042',
+ '\000', '\000', '\043', '\000', '\000', '\044', '\000', '\000',
+ '\045', '\000', '\000', '\046', '\000', '\000', '\121', '\003',
+ '\025', '\051', '\000', '\000', '\052', '\000', '\000', '\053',
+ '\000', '\000', '\134', '\061', '\121', '\177', '\362', '\002',
+ '\000', '\000', '\003', '\125', '\002', '\000', '\136', '\061',
+ '\003', '\000', '\060', '\065', '\065', '\000', '\000', '\066',
+ '\000', '\000', '\067', '\000', '\000', '\070', '\000', '\000',
+ '\112', '\242', '\003', '\000', '\260', '\003', '\000', '\060',
+ '\030', '\075', '\000', '\000', '\140', '\101', '\127', '\072',
+ '\121', '\065', '\102', '\340', '\042', '\000', '\100', '\004',
+ '\000', '\040', '\026', '\106', '\000', '\000', '\055', '\222',
+ '\043', '\111', '\000', '\000', '\112', '\000', '\000', '\144',
+ '\301', '\004', '\277', '\001', '\000', '\264', '\362', '\004',
+ '\036', '\001', '\000', '\121', '\120', '\036', '\340', '\001',
+ '\000', '\202', '\122', '\005', '\000', '\140', '\005', '\254',
+ '\122', '\053', '\000', '\200', '\033', '\132', '\000', '\000',
+ '\150', '\301', '\005', '\000', '\320', '\005', '\000', '\340',
+ '\005', '\000', '\360', '\005', '\000', '\000', '\006', '\000',
+ '\020', '\006', '\000', '\040', '\006', '\000', '\060', '\034',
+ '\025', '\121', '\006', '\000', '\140', '\006', '\000', '\160',
+ '\006', '\000', '\200', '\006', '\000', '\240', '\026', '\152',
+ '\000', '\000', '\234', '\301', '\006', '\000', '\360', '\035',
+ '\156', '\000', '\000', '\157', '\000', '\000', '\160', '\000',
+ '\000', '\161', '\000', '\000', '\162', '\000', '\000', '\163',
+ '\000', '\000', '\164', '\000', '\000', '\134', '\143', '\007',
+ '\000', '\160', '\007', '\000', '\300', '\026', '\156', '\241',
+ '\007', '\000', '\260', '\007', '\000', '\300', '\007', '\000',
+ '\320', '\007', '\000', '\340', '\007', '\000', '\360', '\007',
+ '\000', '\360', '\017', '\260', '\032', '\253', '\262', '\072',
+ '\253', '\264', '\132', '\253', '\266', '\172', '\253', '\270',
+ '\172', '\253', '\103', '\021', '\010', '\000', '\340', '\065',
+ '\203', '\000', '\000', '\162', '\121', '\010', '\000', '\140',
+ '\010', '\000', '\160', '\010', '\074', '\001', '\000', '\211',
+ '\000', '\000', '\212', '\000', '\000', '\213', '\000', '\000',
+ '\214', '\000', '\000', '\215', '\000', '\000', '\216', '\000',
+ '\000', '\166', '\001', '\011', '\000', '\020', '\011', '\000',
+ '\040', '\011', '\000', '\060', '\011', '\000', '\100', '\011',
+ '\000', '\120', '\011', '\000', '\140', '\011', '\000', '\160',
+ '\011', '\000', '\360', '\020', '\231', '\000', '\000', '\232',
+ '\000', '\000', '\233', '\000', '\000', '\172', '\321', '\011',
+ '\000', '\340', '\011', '\000', '\360', '\011', '\000', '\000',
+ '\012', '\000', '\020', '\012', '\000', '\040', '\012', '\000',
+ '\060', '\012', '\000', '\100', '\012', '\000', '\120', '\012',
+ '\000', '\140', '\012', '\000', '\160', '\012', '\000', '\200',
+ '\012', '\000', '\320', '\027', '\252', '\000', '\000', '\253',
+ '\000', '\000', '\254', '\000', '\000', '\255', '\000', '\000',
+ '\256', '\000', '\000', '\257', '\160', '\024', '\000', '\360',
+ '\027', '\262', '\000', '\000', '\201', '\101', '\013', '\000',
+ '\120', '\013', '\000', '\100', '\066', '\267', '\000', '\000',
+ '\270', '\000', '\000', '\271', '\000', '\000', '\272', '\000',
+ '\000', '\273', '\000', '\000', '\274', '\000', '\000', '\275',
+ '\000', '\000', '\276', '\000', '\000', '\277', '\000', '\000',
+ '\300', '\000', '\000', '\205', '\041', '\014', '\000', '\140',
+ '\066', '\304', '\000', '\000', '\305', '\000', '\000', '\306',
+ '\000', '\000', '\307', '\000', '\000', '\310', '\000', '\000',
+ '\311', '\000', '\000', '\312', '\000', '\000', '\313', '\000',
+ '\000', '\314', '\000', '\000', '\315', '\000', '\000', '\316',
+ '\000', '\000', '\317', '\000', '\000', '\150', '\023', '\015',
+ '\000', '\160', '\030', '\323', '\000', '\000', '\324', '\000',
+ '\000', '\325', '\000', '\000', '\326', '\000', '\000', '\327',
+ '\000', '\000', '\330', '\000', '\000', '\331', '\000', '\000',
+ '\211', '\261', '\015', '\000', '\300', '\015', '\000', '\240',
+ '\066', '\336', '\000', '\000', '\337', '\260', '\023', '\113',
+ '\143', '\264', '\023', '\321', '\014', '\153', '\333', '\266',
+ '\006', '\301', '\266', '\157', '\353', '\266', '\152', '\033',
+ '\267', '\164', '\073', '\267', '\166', '\013', '\267', '\167',
+ '\053', '\267', '\170', '\273', '\267', '\172', '\333', '\267',
+ '\165', '\313', '\267', '\177', '\353', '\267', '\171', '\033',
+ '\270', '\204', '\073', '\270', '\206', '\013', '\270', '\207',
+ '\053', '\270', '\210', '\273', '\270', '\212', '\333', '\270',
+ '\205', '\313', '\270', '\217', '\353', '\270', '\211', '\033',
+ '\271', '\224', '\073', '\271', '\226', '\013', '\271', '\227',
+ '\053', '\271', '\230', '\273', '\271', '\232', '\333', '\271',
+ '\225', '\313', '\271', '\237', '\353', '\271', '\231', '\033',
+ '\272', '\244', '\073', '\272', '\246', '\013', '\272', '\247',
+ '\053', '\272', '\250', '\273', '\272', '\252', '\333', '\272',
+ '\245', '\313', '\272', '\257', '\353', '\272', '\251', '\033',
+ '\273', '\264', '\073', '\273', '\266', '\213', '\272', '\012',
+ '\221', '\266', '\012', '\161', '\134', '\101', '\005', '\241',
+ '\011', '\321', '\241', '\006', '\061', '\121', '\006', '\221',
+ '\243', '\171', '\225', '\020', '\071', '\142', '\020', '\141',
+ '\152', '\020', '\155', '\152', '\020', '\303', '\141', '\020',
+ '\214', '\152', '\020', '\134', '\143', '\020', '\254', '\152',
+ '\020', '\306', '\152', '\020', '\326', '\152', '\020', '\347',
+ '\152', '\020', '\370', '\152', '\020', '\011', '\153', '\020',
+ '\030', '\153', '\020', '\051', '\153', '\020', '\071', '\153',
+ '\020', '\113', '\153', '\020', '\133', '\153', '\020', '\341',
+ '\260', '\066', '\011', '\061', '\017', '\011', '\301', '\017',
+ '\011', '\121', '\000', '\023', '\061', '\211', '\214', '\047',
+ '\023', '\023', '\141', '\002', '\023', '\321', '\002', '\023',
+ '\141', '\003', '\023', '\021', '\004', '\023', '\201', '\004',
+ '\023', '\001', '\005', '\023', '\241', '\005', '\023', '\121',
+ '\006', '\023', '\361', '\006', '\023', '\241', '\007', '\023',
+ '\061', '\010', '\023', '\141', '\032', '\006', '\341', '\010',
+ '\023', '\121', '\011', '\023', '\301', '\011', '\023', '\041',
+ '\012', '\023', '\161', '\012', '\023', '\261', '\012', '\023',
+ '\361', '\012', '\023', '\121', '\013', '\213', '\063', '\021',
+ '\277', '\060', '\021', '\303', '\060', '\021', '\311', '\060',
+ '\021', '\317', '\360', '\070', '\023', '\241', '\015', '\023',
+ '\101', '\016', '\023', '\221', '\016', '\023', '\361', '\016',
+ '\023', '\161', '\017', '\227', '\021', '\021', '\232', '\147',
+ '\020', '\005', '\020', '\021', '\247', '\145', '\020', '\011',
+ '\020', '\021', '\013', '\020', '\021', '\015', '\020', '\021',
+ '\066', '\225', '\146', '\021', '\061', '\001', '\231', '\023',
+ '\021', '\027', '\020', '\021', '\031', '\020', '\021', '\033',
+ '\020', '\021', '\035', '\020', '\021', '\037', '\020', '\021',
+ '\041', '\020', '\021', '\043', '\020', '\021', '\045', '\020',
+ '\021', '\047', '\020', '\021', '\051', '\020', '\021', '\053',
+ '\020', '\021', '\055', '\320', '\071', '\021', '\021', '\003',
+ '\021', '\061', '\003', '\021', '\121', '\003', '\021', '\161',
+ '\003', '\021', '\041', '\004', '\021', '\301', '\004', '\021',
+ '\221', '\005', '\021', '\121', '\006', '\247', '\023', '\021',
+ '\172', '\020', '\021', '\174', '\020', '\021', '\176', '\020',
+ '\021', '\200', '\020', '\021', '\202', '\020', '\021', '\204',
+ '\020', '\021', '\206', '\020', '\021', '\210', '\260', '\072',
+ '\021', '\301', '\010', '\021', '\341', '\010', '\021', '\001',
+ '\011', '\021', '\041', '\011', '\021', '\101', '\011', '\021',
+ '\141', '\011', '\021', '\201', '\011', '\021', '\241', '\011',
+ '\021', '\301', '\011', '\021', '\341', '\011', '\021', '\001',
+ '\012', '\021', '\041', '\012', '\257', '\023', '\021', '\246',
+ '\020', '\021', '\250', '\020', '\021', '\252', '\020', '\021',
+ '\254', '\020', '\021', '\256', '\020', '\021', '\270', '\020',
+ '\021', '\274', '\020', '\021', '\307', '\020', '\021', '\322',
+ '\020', '\021', '\333', '\020', '\021', '\340', '\220', '\073',
+ '\021', '\241', '\016', '\021', '\361', '\016', '\021', '\101',
+ '\017', '\021', '\221', '\017', '\021', '\341', '\017', '\062',
+ '\354', '\023', '\010', '\340', '\023', '\015', '\340', '\023',
+ '\022', '\340', '\023', '\027', '\340', '\023', '\034', '\340',
+ '\023', '\041', '\060', '\074', '\076', '\261', '\002', '\076',
+ '\001', '\003', '\076', '\121', '\003', '\076', '\241', '\003',
+ '\076', '\361', '\003', '\076', '\101', '\004', '\076', '\221',
+ '\004', '\076', '\341', '\004', '\076', '\061', '\005', '\076',
+ '\201', '\005', '\076', '\321', '\005', '\076', '\041', '\006',
+ '\315', '\343', '\023', '\154', '\340', '\023', '\161', '\340',
+ '\023', '\166', '\340', '\023', '\173', '\340', '\023', '\200',
+ '\340', '\023', '\205', '\340', '\023', '\212', '\340', '\023',
+ '\217', '\340', '\023', '\224', '\340', '\023', '\231', '\340',
+ '\023', '\236', '\340', '\023', '\243', '\160', '\075', '\076',
+ '\321', '\012', '\076', '\041', '\013', '\076', '\161', '\013',
+ '\076', '\301', '\013', '\076', '\021', '\014', '\076', '\141',
+ '\014', '\076', '\261', '\014', '\076', '\001', '\015', '\076',
+ '\121', '\015', '\076', '\241', '\015', '\076', '\361', '\015',
+ '\076', '\101', '\016', '\341', '\343', '\023', '\356', '\340',
+ '\023', '\363', '\340', '\023', '\370', '\340', '\023', '\375',
+ '\340', '\023', '\216', '\145', '\020', '\146', '\065', '\132',
+ '\035', '\021', '\001', '\035', '\141', '\001', '\035', '\261',
+ '\001', '\035', '\001', '\002', '\035', '\121', '\002', '\353',
+ '\323', '\021', '\057', '\320', '\021', '\064', '\320', '\021',
+ '\071', '\320', '\021', '\076', '\320', '\021', '\103', '\320',
+ '\021', '\110', '\320', '\021', '\115', '\320', '\021', '\122',
+ '\320', '\021', '\127', '\320', '\021', '\134', '\320', '\021',
+ '\141', '\320', '\021', '\146', '\120', '\077', '\035', '\001',
+ '\007', '\035', '\121', '\007', '\035', '\241', '\007', '\035',
+ '\361', '\007', '\035', '\101', '\010', '\035', '\221', '\010',
+ '\035', '\341', '\010', '\035', '\061', '\011', '\035', '\201',
+ '\011', '\035', '\321', '\011', '\035', '\041', '\012', '\035',
+ '\161', '\012', '\377', '\323', '\021', '\261', '\320', '\021',
+ '\266', '\320', '\021', '\273', '\340', '\323', '\302', '\221',
+ '\006', '\151', '\000', '\003', '\146', '\235', '\247', '\143',
+ '\135', '\326', '\060', '\140', '\045', '\141', '\220', '\326',
+ '\146', '\355', '\025', '\155', '\075', '\006', '\144', '\155',
+ '\326', '\064', '\032', '\327', '\163', '\015', '\003', '\123',
+ '\143', '\327', '\152', '\175', '\243', '\172', '\155', '\326',
+ '\071', '\332', '\327', '\060', '\260', '\243', '\175', '\035',
+ '\003', '\060', '\072', '\330', '\154', '\355', '\326', '\061',
+ '\000', '\327', '\210', '\135', '\327', '\210', '\235', '\327',
+ '\210', '\315', '\327', '\210', '\375', '\327', '\210', '\055',
+ '\330', '\156', '\335', '\051', '\150', '\055', '\327', '\145',
+ '\055', '\003', '\207', '\215', '\331', '\060', '\040', '\003',
+ '\212', '\315', '\331', '\062', '\300', '\330', '\240', '\355',
+ '\330', '\240', '\015', '\331', '\240', '\055', '\331', '\240',
+ '\115', '\331', '\234', '\075', '\003', '\205', '\355', '\326',
+ '\063', '\260', '\331', '\163', '\075', '\003', '\237', '\035',
+ '\333', '\242', '\035', '\333', '\244', '\035', '\333', '\246',
+ '\035', '\333', '\250', '\035', '\333', '\073', '\072', '\007',
+ '\160', '\020', '\006', '\143', '\000', '\250', '\145', '\200',
+ '\007', '\143', '\300', '\006', '\141', '\360', '\035', '\161',
+ '\120', '\007', '\157', '\100', '\007', '\320', '\001', '\046',
+ '\000', '\340', '\006', '\336', '\041', '\006', '\145', '\040',
+ '\007', '\163', '\220', '\006', '\147', '\360', '\250', '\145',
+ '\302', '\006', '\306', '\175', '\251', '\160', '\060', '\335',
+ '\301', '\355', '\006', '\233', '\172', '\334', '\335', '\115',
+ '\335', '\170', '\122', '\021', '\311', '\275', '\334', '\323',
+ '\155', '\335', '\150', '\260', '\251', '\277', '\135', '\047',
+ '\156', '\300', '\006', '\145', '\140', '\006', '\354', '\115',
+ '\047', '\371', '\041', '\007', '\352', '\035', '\336', '\163',
+ '\300', '\334', '\366', '\075', '\007', '\234', '\001', '\007',
+ '\154', '\120', '\007', '\231', '\072', '\006', '\146', '\162',
+ '\046', '\205', '\232', '\007', '\160', '\200', '\006', '\371',
+ '\041', '\251', '\351', '\375', '\006', '\025', '\061', '\007',
+ '\306', '\075', '\007', '\206', '\252', '\007', '\323', '\035',
+ '\251', '\366', '\001', '\250', '\164', '\160', '\007', '\221',
+ '\112', '\007', '\150', '\120', '\047', '\200', '\312', '\046',
+ '\165', '\160', '\251', '\146', '\220', '\006', '\166', '\000',
+ '\250', '\325', '\315', '\026', '\373', '\061', '\342', '\217',
+ '\132', '\006', '\367', '\375', '\334', '\151', '\002', '\250',
+ '\002', '\316', '\006', '\366', '\201', '\251', '\362', '\041',
+ '\046', '\157', '\000', '\343', '\217', '\012', '\337', '\163',
+ '\220', '\251', '\145', '\220', '\334', '\141', '\300', '\250',
+ '\147', '\120', '\047', '\141', '\240', '\337', '\224', '\132',
+ '\007', '\145', '\220', '\337', '\151', '\020', '\343', '\101',
+ '\336', '\037', '\000', '\260', '\244', '\057', '\342', '\244',
+ '\120', '\052', '\245', '\000', '\100', '\245', '\126', '\212',
+ '\245', '\000', '\240', '\245', '\146', '\321', '\245', '\137',
+ '\032', '\246', '\346', '\061', '\005', '\144', '\012', '\000',
+ '\146', '\212', '\246', '\127', '\240', '\246', '\154', '\272',
+ '\247', '\162', '\020', '\006', '\153', '\120', '\006', '\164',
+ '\000', '\337', '\362', '\275', '\247', '\300', '\275', '\006',
+ '\016', '\336', '\326', '\206', '\052', '\006', '\145', '\076',
+ '\006', '\147', '\116', '\007', '\366', '\175', '\006', '\353',
+ '\175', '\331', '\144', '\055', '\327', '\162', '\060', '\006',
+ '\336', '\301', '\251', '\224', '\102', '\335', '\002', '\136',
+ '\047', '\103', '\216', '\336', '\152', '\036', '\336', '\173',
+ '\332', '\247', '\024', '\001', '\000', '\035', '\076', '\250',
+ '\205', '\172', '\250', '\000', '\220', '\250', '\213', '\332',
+ '\250', '\317', '\015', '\251', '\222', '\112', '\251', '\226',
+ '\212', '\251', '\232', '\312', '\251', '\000', '\340', '\251',
+ '\240', '\052', '\252', '\000', '\100', '\252', '\162', '\016',
+ '\334', '\145', '\160', '\350', '\154', '\176', '\251', '\243',
+ '\036', '\334', '\167', '\236', '\347', '\172', '\115', '\007',
+ '\151', '\300', '\006', '\370', '\241', '\347', '\151', '\020',
+ '\003', '\067', '\260', '\243', '\146', '\035', '\006', '\060',
+ '\172', '\353', '\126', '\162', '\353', '\136', '\161', '\353',
+ '\064', '\172', '\353', '\123', '\163', '\353', '\067', '\172',
+ '\353', '\071', '\172', '\353', '\266', '\016', '\003', '\141',
+ '\320', '\243', '\267', '\256', '\044', '\267', '\256', '\247',
+ '\267', '\316', '\247', '\267', '\076', '\034', '\267', '\136',
+ '\021', '\267', '\016', '\250', '\267', '\056', '\250', '\146',
+ '\055', '\006', '\271', '\016', '\003', '\142', '\260', '\353',
+ '\334', '\336', '\353', '\334', '\376', '\353', '\334', '\036',
+ '\354', '\334', '\076', '\354', '\334', '\136', '\354', '\334',
+ '\176', '\354', '\142', '\240', '\354', '\334', '\316', '\354',
+ '\334', '\356', '\354', '\334', '\016', '\355', '\334', '\056',
+ '\355', '\334', '\116', '\355', '\334', '\156', '\355', '\334',
+ '\216', '\355', '\060', '\060', '\006', '\333', '\076', '\006',
+ '\336', '\076', '\006', '\340', '\076', '\006', '\342', '\076',
+ '\006', '\344', '\076', '\006', '\346', '\076', '\006', '\350',
+ '\076', '\006', '\307', '\076', '\006', '\354', '\076', '\006',
+ '\356', '\076', '\006', '\360', '\076', '\006', '\362', '\076',
+ '\006', '\364', '\076', '\006', '\366', '\036', '\334', '\057',
+ '\272', '\357', '\372', '\116', '\006', '\333', '\116', '\006',
+ '\336', '\116', '\006', '\340', '\116', '\006', '\342', '\116',
+ '\006', '\344', '\116', '\006', '\346', '\116', '\006', '\350',
+ '\116', '\006', '\307', '\116', '\006', '\354', '\116', '\006',
+ '\356', '\116', '\006', '\360', '\116', '\006', '\362', '\116',
+ '\006', '\364', '\116', '\006', '\366', '\036', '\353', '\146',
+ '\115', '\006', '\372', '\136', '\006', '\333', '\136', '\006',
+ '\336', '\136', '\006', '\340', '\136', '\006', '\342', '\136',
+ '\006', '\344', '\136', '\006', '\346', '\136', '\006', '\350',
+ '\136', '\006', '\307', '\136', '\006', '\354', '\136', '\006',
+ '\356', '\136', '\006', '\360', '\136', '\006', '\362', '\136',
+ '\006', '\364', '\316', '\037', '\146', '\135', '\006', '\370',
+ '\036', '\337', '\031', '\157', '\006', '\333', '\156', '\006',
+ '\336', '\156', '\006', '\340', '\156', '\006', '\342', '\156',
+ '\006', '\344', '\156', '\006', '\346', '\156', '\006', '\350',
+ '\156', '\006', '\307', '\156', '\006', '\354', '\156', '\006',
+ '\356', '\156', '\006', '\360', '\156', '\006', '\362', '\056',
+ '\020', '\133', '\157', '\357', '\146', '\200', '\357', '\146',
+ '\040', '\250', '\302', '\002', '\150', '\023', '\201', '\054',
+ '\025', '\307', '\055', '\331', '\362', '\367', '\370', '\206',
+ '\055', '\322', '\042', '\370', '\043', '\261', '\124', '\370',
+ '\060', '\237', '\015', '\021', '\370', '\312', '\002',
+
+};
+
+static const char file_cursor[] = {
+ '\037', '\235', '\214', '\001', '\314', '\214', '\201', '\203',
+ '\000', '\200', '\301', '\000', '\006', '\023', '\032', '\044',
+ '\227', '\020', '\121', '\102', '\001', '\012', '\023', '\222',
+ '\111', '\310', '\006', '\041', '\000', '\002', '\012', '\055',
+ '\042', '\030', '\140', '\020', '\232', '\306', '\210', '\006',
+ '\151', '\114', '\060', '\210', '\015', '\043', '\000', '\020',
+ '\040', '\001', '\020', '\261', '\310', '\000', '\203', '\101',
+ '\040', '\051', '\341', '\100', '\004', '\000', '\045', '\203',
+ '\101', '\100', '\051', '\321', '\045', '\060', '\010', '\154',
+ '\103', '\102', '\213', '\012', '\047', '\032', '\104', '\125',
+ '\002', '\344', '\116', '\220', '\001', '\024', '\044', '\124',
+ '\241', '\320', '\206', '\305', '\032', '\077', '\165', '\044',
+ '\014', '\242', '\120', '\251', '\101', '\044', '\012', '\327',
+ '\044', '\234', '\242', '\320', '\111', '\102', '\060', '\135',
+ '\023', '\266', '\121', '\370', '\257', '\354', '\077', '\073',
+ '\012', '\033', '\200', '\014', '\224', '\160', '\310', '\023',
+ '\050', '\131', '\244', '\044', '\071', '\202', '\204', '\012',
+ '\000', '\052', '\150', '\312', '\314', '\051', '\003', '\102',
+ '\304', '\031', '\066', '\171', '\340', '\240', '\231', '\043',
+ '\002', '\104', '\030', '\071', '\174', '\353', '\270', '\051',
+ '\343', '\146', '\114', '\235', '\066', '\142', '\312', '\040',
+ '\236', '\010', '\345', '\111', '\022', '\047', '\124', '\276',
+ '\114', '\111', '\242', '\245', '\010', '\000', '\043', '\117',
+ '\060', '\003', '\160', '\054', '\147', '\316', '\033', '\071',
+ '\000', '\256', '\024', '\231', '\133', '\027', '\200', '\224',
+ '\042', '\123', '\236', '\060', '\251', '\102', '\045', '\111',
+ '\150', '\327', '\260', '\145', '\323', '\266', '\355', '\344',
+ '\013', '\026', '\334', '\261', '\147', '\327', '\016', '\375',
+ '\045', '\013', '\000', '\054', '\137', '\220', '\254', '\246',
+ '\153', '\067', '\112', '\225', '\040', '\104', '\276', '\134',
+ '\111', '\102', '\204', '\012', '\326', '\224', '\330', '\041',
+ '\044', '\214', '\220', '\320', '\354', '\277', '\170', '\377',
+ '\014', '\052', '\055', '\233', '\021', '\200', '\166', '\356',
+ '\017', '\314', '\143', '\137', '\317', '\276', '\275', '\173',
+ '\244', '\006', '\065', '\001', '\320', '\203', '\050', '\222',
+ '\041', '\104', '\171', '\022', '\105', '\072', '\224', '\150',
+ '\116', '\240', '\110', '\200', '\070', '\042', '\207', '\040',
+ '\221', '\004', '\362', '\110', '\037', '\205', '\104', '\222',
+ '\110', '\040', '\174', '\030', '\022', '\211', '\042', '\202',
+ '\040', '\250', '\040', '\203', '\016', '\102', '\070', '\140',
+ '\044', '\203', '\024', '\162', '\041', '\041', '\205', '\350',
+ '\161', '\210', '\175', '\370', '\325', '\307', '\137', '\200',
+ '\221', '\064', '\022', '\310', '\037', '\217', '\104', '\342',
+ '\210', '\040', '\376', '\225', '\030', '\310', '\205', '\053',
+ '\172', '\350', '\142', '\036', '\365', '\255', '\230', '\307',
+ '\207', '\013', '\342', '\121', '\037', '\204', '\170', '\174',
+ '\210', '\010', '\042', '\072', '\106', '\362', '\143', '\203',
+ '\000', '\072', '\262', '\307', '\207', '\006', '\336', '\270',
+ '\337', '\041', '\101', '\376', '\110', '\037', '\206', '\215',
+ '\350', '\241', '\337', '\040', '\215', '\320', '\250', '\340',
+ '\041', '\371', '\135', '\231', '\345', '\041', '\370', '\351',
+ '\307', '\337', '\226', '\135', '\356', '\027', '\046', '\227',
+ '\133', '\046', '\142', '\045', '\231', '\136', '\046', '\262',
+ '\107', '\202', '\205', '\164', '\350', '\240', '\041', '\206',
+ '\350', '\341', '\140', '\041', '\130', '\176', '\170', '\337',
+ '\232', '\113', '\312', '\051', '\044', '\042', '\162', '\374',
+ '\007', '\310', '\043', '\175', '\002', '\010', '\111', '\240',
+ '\177', '\022', '\372', '\210', '\236', '\164', '\052', '\171',
+ '\337', '\223', '\367', '\225', '\251', '\344', '\041', '\114',
+ '\326', '\367', '\343', '\205', '\202', '\064', '\162', '\041',
+ '\225', '\176', '\070', '\042', '\150', '\246', '\202', '\322',
+ '\341', '\047', '\044', '\236', '\012', '\372', '\147', '\221',
+ '\200', '\100', '\122', '\340', '\241', '\372', '\041', '\022',
+ '\147', '\252', '\206', '\064', '\011', '\244', '\244', '\370',
+ '\331', '\371', '\352', '\176', '\211', '\000', '\122', '\137',
+ '\200', '\177', '\350', '\147', '\040', '\211', '\206', '\034',
+ '\202', '\242', '\230', '\200', '\050', '\262', '\344', '\037',
+ '\213', '\354', '\351', '\152', '\217', '\173', '\006', '\073',
+ '\041', '\261', '\017', '\012', '\162', '\307', '\177', '\013',
+ '\332', '\101', '\240', '\205', '\004', '\026', '\262', '\310',
+ '\205', '\326', '\036', '\353', '\043', '\042', '\174', '\024',
+ '\033', '\110', '\043', '\174', '\060', '\162', '\252', '\035',
+ '\377', '\075', '\022', '\110', '\035', '\004', '\232', '\153',
+ '\045', '\043', '\204', '\144', '\311', '\056', '\221', '\155',
+ '\036', '\151', '\237', '\041', '\174', '\044', '\310', '\345',
+ '\036', '\016', '\376', '\230', '\207', '\237', '\216', '\340',
+ '\101', '\240', '\201', '\055', '\366', '\172', '\041', '\227',
+ '\317', '\056', '\051', '\255', '\261', '\260', '\042', '\353',
+ '\144', '\175', '\215', '\246', '\251', '\347', '\037', '\375',
+ '\336', '\012', '\111', '\037', '\204', '\104', '\362', '\010',
+ '\040', '\365', '\132', '\034', '\210', '\225', '\203', '\264',
+ '\133', '\037', '\207', '\201', '\230', '\332', '\161', '\251',
+ '\221', '\160', '\030', '\007', '\040', '\030', '\022', '\022',
+ '\307', '\177', '\034', '\122', '\034', '\311', '\037', '\220',
+ '\144', '\134', '\252', '\313', '\134', '\146', '\314', '\245',
+ '\035', '\011', '\226', '\132', '\107', '\316', '\220', '\074',
+ '\032', '\351', '\236', '\172', '\010', '\313', '\137', '\320',
+ '\264', '\336', '\101', '\240', '\040', '\216', '\034', '\214',
+ '\364', '\231', '\146', '\246', '\151', '\145', '\257', '\133',
+ '\036', '\342', '\041', '\044', '\120', '\043', '\002', '\011',
+ '\227', '\044', '\342', '\232', '\342', '\256', '\232', '\152',
+ '\175', '\152', '\213', '\001', '\136', '\150', '\240', '\214',
+ '\001', '\132', '\231', '\344', '\207', '\301', '\006', '\031',
+ '\310', '\042', '\056', '\227', '\052', '\063', '\044', '\312',
+ '\006', '\313', '\354', '\332', '\112', '\012', '\302', '\110',
+ '\220', '\110', '\027', '\034', '\354', '\301', '\153', '\257',
+ '\174', '\245', '\337', '\211', '\034', '\102', '\261', '\042',
+ '\220', '\326', '\253', '\310', '\217', '\012', '\311', '\007',
+ '\022', '\007', '\011', '\361', '\220', '\320', '\157', '\006',
+ '\341', '\221', '\220', '\040', '\011', '\051', '\016', '\000',
+ '\051', '\011', '\361', '\222', '\020', '\063', '\011', '\171',
+ '\223', '\220', '\076', '\011', '\151', '\140', '\221', '\123',
+ '\006', '\131', '\141', '\221', '\034', '\026', '\111', '\142',
+ '\221', '\053', '\026', '\071', '\143', '\221', '\070', '\026',
+ '\351', '\143', '\221', '\006', '\063', '\351', '\060', '\223',
+ '\025', '\063', '\331', '\061', '\223', '\044', '\063', '\311',
+ '\062', '\223', '\064', '\063', '\311', '\063', '\223', '\004',
+ '\034', '\001', '\040', '\103', '\361', '\120', '\024', '\017',
+ '\107', '\361', '\216', '\024', '\317', '\112', '\361', '\312',
+ '\024', '\257', '\116', '\361', '\010', '\230', '\204', '\202',
+ '\111', '\074', '\230', '\104', '\205', '\111', '\154', '\230',
+ '\204', '\210', '\111', '\244', '\230', '\104', '\214', '\111',
+ '\342', '\230', '\044', '\100', '\001', '\006', '\201', '\200',
+ '\076', '\000', '\076', '\254', '\157', '\305', '\372', '\162',
+ '\254', '\357', '\310', '\372', '\256', '\254', '\257', '\314',
+ '\372', '\352', '\254', '\217', '\200', '\001', '\006', '\241',
+ '\300', '\077', '\000', '\110', '\370', '\037', '\032', '\376',
+ '\207', '\210', '\377', '\241', '\342', '\177', '\304', '\370',
+ '\037', '\071', '\376', '\007', '\200', '\003', '\030', '\204',
+ '\003', '\016', '\004', '\000', '\017', '\042', '\310', '\205',
+ '\010', '\342', '\041', '\202', '\230', '\210', '\240', '\051',
+ '\042', '\150', '\214', '\010', '\202', '\043', '\202', '\376',
+ '\210', '\240', '\006', '\012', '\002', '\000', '\035', '\220',
+ '\120', '\013', '\044', '\324', '\003', '\011', '\035', '\101',
+ '\102', '\123', '\220', '\120', '\027', '\044', '\224', '\006',
+ '\011', '\345', '\101', '\102', '\011', '\034', '\105', '\006',
+ '\107', '\221', '\302', '\121', '\334', '\160', '\024', '\107',
+ '\034', '\305', '\025', '\107', '\161', '\306', '\121', '\334',
+ '\161', '\024', '\007', '\130', '\105', '\004', '\126', '\321',
+ '\201', '\125', '\260', '\140', '\025', '\074', '\130', '\305',
+ '\020', '\126', '\061', '\205', '\125', '\200', '\141', '\025',
+ '\157', '\130', '\105', '\037', '\126', '\321', '\300', '\002',
+ '\014', '\242', '\203', '\055', '\002', '\100', '\013', '\136',
+ '\264', '\203', '\027', '\055', '\341', '\105', '\130', '\170',
+ '\021', '\032', '\136', '\374', '\206', '\027', '\377', '\341',
+ '\305', '\006', '\060', '\300', '\040', '\037', '\170', '\043',
+ '\000', '\132', '\040', '\307', '\037', '\310', '\261', '\011',
+ '\162', '\374', '\202', '\034', '\335', '\040', '\107', '\107',
+ '\310', '\261', '\023', '\162', '\334', '\205', '\034', '\267',
+ '\041', '\307', '\175', '\310', '\361', '\002', '\152', '\001',
+ '\300', '\015', '\022', '\171', '\205', '\104', '\336', '\041',
+ '\221', '\227', '\110', '\344', '\055', '\022', '\171', '\215',
+ '\104', '\336', '\043', '\221', '\021', '\160', '\200', '\101',
+ '\132', '\240', '\111', '\000', '\034', '\241', '\223', '\145',
+ '\350', '\144', '\040', '\072', '\031', '\212', '\116', '\366',
+ '\242', '\223', '\335', '\350', '\144', '\076', '\072', '\231',
+ '\201', '\364', '\000', '\240', '\006', '\256', '\254', '\202',
+ '\053', '\323', '\340', '\312', '\100', '\270', '\062', '\022',
+ '\256', '\214', '\205', '\053', '\213', '\341', '\312', '\156',
+ '\270', '\062', '\037', '\256', '\314', '\200', '\166', '\346',
+ '\070', '\314', '\042', '\014', '\263', '\014', '\303', '\054',
+ '\304', '\060', '\047', '\061', '\314', '\131', '\014', '\323',
+ '\005', '\334', '\001', '\000', '\027', '\104', '\140', '\020',
+ '\134', '\020', '\301', '\040', '\007', '\300', '\301', '\003',
+ '\170', '\360', '\001', '\037', '\370', '\340', '\003', '\374',
+ '\170', '\000', '\076', '\016', '\000', '\217', '\001', '\224',
+ '\163', '\234', '\341', '\374', '\146', '\067', '\267', '\231',
+ '\315', '\007', '\300', '\343', '\003', '\370', '\370', '\001',
+ '\077', '\376', '\340', '\017', '\177', '\374', '\201', '\037',
+ '\077', '\300', '\307', '\007', '\340', '\341', '\116', '\161',
+ '\202', '\363', '\007', '\366', '\244', '\247', '\074', '\341',
+ '\351', '\116', '\000', '\300', '\100', '\202', '\000', '\370',
+ '\000', '\060', '\366', '\371', '\200', '\160', '\002', '\343',
+ '\000', '\037', '\134', '\036', '\016', '\006', '\300', '\201',
+ '\000', '\070', '\040', '\000', '\016', '\234', '\011', '\070',
+ '\000', '\200', '\017', '\000', '\370', '\003', '\020', '\177',
+ '\000', '\307', '\037', '\342', '\211', '\117', '\176', '\174',
+ '\000', '\034', '\014', '\305', '\307', '\003', '\370', '\160',
+ '\000', '\037', '\034', '\340', '\003', '\002', '\320', '\044',
+ '\106', '\302', '\363', '\017', '\014', '\330', '\024', '\003',
+ '\132', '\340', '\001', '\006', '\376', '\061', '\000', '\236',
+ '\372', '\264', '\247', '\003', '\220', '\234', '\344', '\374',
+ '\021', '\000', '\242', '\022', '\225', '\037', '\000', '\220',
+ '\034', '\006', '\170', '\240', '\205', '\233', '\356', '\024',
+ '\000', '\377', '\070', '\350', '\120', '\213', '\112', '\125',
+ '\241', '\102', '\025', '\250', '\077', '\345', '\051', '\116',
+ '\300', '\061', '\200', '\010', '\030', '\200', '\074', '\056',
+ '\301', '\210', '\000', '\170', '\272', '\321', '\162', '\346',
+ '\343', '\000', '\336', '\061', '\313', '\007', '\376', '\201',
+ '\326', '\001', '\034', '\201', '\003', '\104', '\040', '\100',
+ '\134', '\343', '\372', '\217', '\017', '\024', '\201', '\002',
+ '\167', '\315', '\053', '\005', '\352', '\072', '\127', '\271',
+ '\022', '\340', '\255', '\337', '\350', '\103', '\140', '\003',
+ '\313', '\215', '\016', '\374', '\343', '\017', '\207', '\075',
+ '\354', '\140', '\373', '\220', '\130', '\304', '\376', '\241',
+ '\260', '\213', '\015', '\054', '\107', '\070', '\062', '\002',
+ '\004', '\214', '\200', '\000', '\043', '\020', '\300', '\010',
+ '\002', '\060', '\212', '\321', '\000', '\140', '\034', '\017',
+ '\230', '\054', '\000', '\070', '\362', '\217', '\037', '\224',
+ '\066', '\075', '\351', '\171', '\007', '\014', '\336', '\201',
+ '\203', '\167', '\160', '\340', '\035', '\016', '\170', '\307',
+ '\001', '\336', '\061', '\200', '\167', '\374', '\300', '\266',
+ '\266', '\115', '\117', '\132', '\315', '\142', '\120', '\203',
+ '\022', '\040', '\006', '\010', '\210', '\001', '\004', '\142',
+ '\000', '\202', '\030', '\000', '\041', '\006', '\200', '\210',
+ '\001', '\077', '\142', '\320', '\333', '\203', '\302', '\240',
+ '\264', '\245', '\005', '\000', '\074', '\244', '\313', '\200',
+ '\173', '\160', '\340', '\036', '\070', '\270', '\007', '\034',
+ '\356', '\001', '\216', '\173', '\000', '\343', '\036', '\374',
+ '\000', '\257', '\170', '\245', '\273', '\333', '\262', '\300',
+ '\344', '\274', '\000', '\100', '\057', '\114', '\342', '\212',
+ '\004', '\001', '\100', '\041', '\000', '\033', '\205', '\211',
+ '\101', '\352', '\132', '\127', '\140', '\004', '\300', '\276',
+ '\370', '\275', '\257', '\176', '\231', '\221', '\201', '\302',
+ '\252', '\024', '\036', '\020', '\035', '\200', '\175', '\033',
+ '\333', '\130', '\140', '\000', '\300', '\300', '\010', '\076',
+ '\260', '\202', '\023', '\014', '\335', '\037', '\000', '\103',
+ '\300', '\020', '\176', '\260', '\204', '\043', '\334', '\323',
+ '\362', '\036', '\026', '\041', '\375', '\370', '\103', '\001',
+ '\200', '\120', '\217', '\057', '\124', '\000', '\012', '\325',
+ '\270', '\002', '\155', '\252', '\120', '\205', '\152', '\124',
+ '\241', '\002', '\124', '\250', '\307', '\025', '\012', '\000',
+ '\205', '\176', '\174', '\041', '\000', '\100', '\110', '\254',
+ '\205', '\147', '\114', '\143', '\357', '\070', '\067', '\251',
+ '\070', '\106', '\052', '\122', '\215', '\032', '\200', '\031',
+ '\014', '\040', '\006', '\002', '\270', '\361', '\215', '\247',
+ '\073', '\135', '\174', '\004', '\300', '\310', '\374', '\030',
+ '\100', '\222', '\103', '\030', '\302', '\177', '\074', '\300',
+ '\311', '\116', '\276', '\207', '\003', '\210', '\054', '\335',
+ '\052', '\203', '\343', '\310', '\007', '\010', '\247', '\007',
+ '\074', '\340', '\000', '\010', '\342', '\040', '\233', '\140',
+ '\306', '\101', '\227', '\267', '\034', '\316', '\161', '\136',
+ '\371', '\203', '\372', '\304', '\247', '\075', '\355', '\071',
+ '\120', '\175', '\272', '\031', '\236', '\362', '\134', '\363',
+ '\075', '\363', '\171', '\322', '\054', '\077', '\300', '\034',
+ '\031', '\230', '\300', '\014', '\222', '\101', '\202', '\074',
+ '\220', '\040', '\002', '\042', '\030', '\107', '\014', '\374',
+ '\361', '\001', '\145', '\120', '\300', '\320', '\206', '\126',
+ '\107', '\005', '\226', '\101', '\203', '\155', '\066', '\230',
+ '\320', '\367', '\310', '\301', '\066', '\356', '\320', '\216',
+ '\066', '\364', '\343', '\015', '\371', '\060', '\303', '\074',
+ '\346', '\120', '\332', '\165', '\324', '\300', '\323', '\236',
+ '\336', '\307', '\015', '\326', '\121', '\207', '\147', '\360',
+ '\241', '\261', '\052', '\045', '\000', '\004', '\014', '\000',
+ '\006', '\005', '\140', '\101', '\036', '\107', '\030', '\000',
+ '\020', '\144', '\055', '\000', '\040', '\324', '\132', '\023',
+ '\130', '\260', '\102', '\025', '\256', '\121', '\205', '\055',
+ '\144', '\241', '\326', '\265', '\306', '\247', '\112', '\115',
+ '\352', '\217', '\177', '\024', '\333', '\302', '\305', '\076',
+ '\166', '\171', '\213', '\215', '\117', '\040', '\300', '\370',
+ '\331', '\316', '\216', '\166', '\000', '\020', '\153', '\020',
+ '\304', '\112', '\373', '\332', '\317', '\346', '\252', '\266',
+ '\007', '\260', '\155', '\032', '\157', '\373', '\333', '\334',
+ '\036', '\200', '\020', '\102', '\120', '\204', '\050', '\050',
+ '\041', '\005', '\124', '\250', '\000', '\032', '\026', '\000',
+ '\205', '\002', '\374', '\302', '\037', '\316', '\176', '\167',
+ '\273', '\327', '\235', '\356', '\163', '\227', '\173', '\334',
+ '\146', '\230', '\101', '\033', '\266', '\261', '\207', '\067',
+ '\330', '\341', '\006', '\154', '\330', '\300', '\027', '\372',
+ '\001', '\120', '\234', '\000', '\164', '\340', '\001', '\377',
+ '\167', '\277', '\367', '\235', '\157', '\234', '\070', '\034',
+ '\000', '\017', '\177', '\070', '\142', '\043', '\016', '\361',
+ '\212', '\077', '\074', '\277', '\030', '\327', '\357', '\156',
+ '\063', '\316', '\361', '\147', '\203', '\141', '\000', '\355',
+ '\106', '\102', '\002', '\210', '\020', '\201', '\161', '\377',
+ '\341', '\017', '\325', '\376', '\303', '\270', '\111', '\056',
+ '\362', '\166', '\177', '\334', '\331', '\134', '\005', '\260',
+ '\112', '\013', '\353', '\214', '\034', '\034', '\043', '\016',
+ '\145', '\101', '\154', '\131', '\156', '\136', '\163', '\377',
+ '\272', '\063', '\300', '\366', '\235', '\052', '\121', '\263',
+ '\012', '\124', '\036', '\113', '\316', '\310', '\114', '\106',
+ '\353', '\223', '\227', '\016', '\345', '\245', '\047', '\335',
+ '\310', '\116', '\016', '\000', '\002', '\244', '\116', '\165',
+ '\004', '\204', '\301', '\352', '\123', '\317', '\172', '\325',
+ '\241', '\154', '\332', '\256', '\207', '\371', '\034', '\071',
+ '\000', '\273', '\330', '\163', '\020', '\346', '\006', '\227',
+ '\126', '\252', '\000', '\100', '\252', '\055', '\172', '\074',
+ '\000', '\041', '\367', '\326', '\307', '\153', '\107', '\252',
+ '\344', '\016', '\132', '\344', '\000', '\054', '\131', '\351',
+ '\115', '\247', '\162', '\323', '\235', '\034', '\302', '\044',
+ '\033', '\171', '\272', '\351', '\355', '\255', '\343', '\024',
+ '\312', '\320', '\160', '\002', '\342', '\000', '\100', '\070',
+ '\000', '\010', '\006', '\000', '\201', '\001', '\114', '\235',
+ '\000', '\001', '\200', '\210', '\105', '\300', '\042', '\071',
+ '\077', '\000', '\342', '\007', '\050', '\325', '\247', '\077',
+ '\036', '\260', '\371', '\017', '\002', '\030', '\027', '\003',
+ '\340', '\304', '\000', '\034', '\021', '\200', '\103', '\004',
+ '\200', '\043', '\026', '\201', '\311', '\101', '\007', '\277',
+ '\120', '\000', '\150', '\262', '\001', '\200', '\040', '\000',
+ '\020', '\010', '\200', '\022', '\355', '\024', '\104', '\254',
+ '\000', '\230', '\074', '\216', '\175', '\160', '\171', '\224',
+ '\242', '\024', '\020', '\017', '\000', '\306', '\003', '\300',
+ '\141', '\000', '\231', '\340', '\000', '\000', '\214', '\323',
+ '\244', '\003', '\111', '\373', '\200', '\110', '\040', '\040',
+ '\023', '\011', '\150', '\300', '\002', '\016', '\340', '\200',
+ '\253', '\137', '\235', '\372', '\322', '\207', '\276', '\363',
+ '\271', '\136', '\332', '\171', '\314', '\100', '\324', '\077',
+ '\370', '\301', '\067', '\174', '\360', '\216', '\036', '\224',
+ '\177', '\374', '\341', '\027', '\265', '\367', '\033', '\034',
+ '\217', '\001', '\354', '\343', '\245', '\014', '\110', '\000',
+ '\002', '\154', '\362', '\003', '\220', '\324', '\337', '\004',
+ '\004', '\040', '\001', '\003', '\174', '\200', '\217', '\033',
+ '\300', '\143', '\004', '\343', '\160', '\000', '\367', '\360',
+ '\144', '\153', '\025', '\176', '\070', '\020', '\125', '\064',
+ '\065', '\137', '\120', '\305', '\000', '\376', '\300', '\001',
+ '\374', '\300', '\017', '\377', '\200', '\017', '\377', '\000',
+ '\017', '\357', '\000', '\016', '\307', '\140', '\140', '\127',
+ '\126', '\116', '\006', '\106', '\014', '\010', '\140', '\014',
+ '\073', '\325', '\165', '\036', '\310', '\201', '\006', '\126',
+ '\116', '\127', '\206', '\140', '\002', '\006', '\121', '\344',
+ '\364', '\000', '\350', '\160', '\001', '\334', '\260', '\003',
+ '\026', '\326', '\202', '\053', '\310', '\117', '\037', '\064',
+ '\141', '\000', '\340', '\001', '\256', '\027', '\000', '\314',
+ '\220', '\017', '\015', '\340', '\144', '\177', '\300', '\000',
+ '\166', '\144', '\000', '\214', '\043', '\116', '\007', '\240',
+ '\035', '\104', '\250', '\036', '\222', '\003', '\000', '\365',
+ '\367', '\003', '\025', '\346', '\035', '\135', '\147', '\166',
+ '\000', '\105', '\120', '\307', '\167', '\174', '\072', '\226',
+ '\166', '\000', '\060', '\165', '\023', '\040', '\000', '\053',
+ '\066', '\001', '\004', '\060', '\015', '\005', '\360', '\001',
+ '\074', '\340', '\200', '\020', '\100', '\016', '\141', '\010',
+ '\011', '\364', '\000', '\011', '\344', '\000', '\011', '\004',
+ '\200', '\010', '\010', '\100', '\010', '\020', '\300', '\007',
+ '\340', '\004', '\000', '\373', '\020', '\000', '\367', '\320',
+ '\123', '\002', '\050', '\200', '\246', '\245', '\163', '\341',
+ '\005', '\017', '\367', '\000', '\017', '\023', '\270', '\207',
+ '\347', '\060', '\154', '\037', '\340', '\206', '\000', '\340',
+ '\022', '\036', '\160', '\170', '\017', '\226', '\201', '\003',
+ '\060', '\116', '\372', '\100', '\207', '\375', '\100', '\116',
+ '\346', '\024', '\000', '\051', '\000', '\000', '\043', '\000',
+ '\000', '\026', '\000', '\000', '\162', '\304', '\070', '\012',
+ '\065', '\174', '\216', '\070', '\116', '\233', '\267', '\167',
+ '\117', '\326', '\126', '\377', '\060', '\155', '\110', '\130',
+ '\203', '\036', '\025', '\000', '\221', '\347', '\007', '\004',
+ '\200', '\000', '\010', '\100', '\020', '\252', '\010', '\007',
+ '\024', '\200', '\000', '\042', '\000', '\003', '\101', '\000',
+ '\014', '\040', '\000', '\004', '\022', '\000', '\010', '\005',
+ '\201', '\076', '\002', '\060', '\164', '\164', '\310', '\167',
+ '\360', '\004', '\116', '\160', '\066', '\117', '\022', '\010',
+ '\017', '\041', '\345', '\140', '\037', '\000', '\174', '\015',
+ '\004', '\000', '\002', '\340', '\206', '\306', '\020', '\003',
+ '\203', '\000', '\006', '\320', '\006', '\155', '\003', '\000',
+ '\006', '\006', '\000', '\003', '\055', '\201', '\001', '\014',
+ '\000', '\003', '\254', '\046', '\140', '\001', '\340', '\206',
+ '\376', '\360', '\003', '\067', '\367', '\214', '\323', '\070',
+ '\215', '\103', '\020', '\006', '\207', '\000', '\007', '\016',
+ '\200', '\003', '\034', '\300', '\001', '\142', '\006', '\140',
+ '\134', '\065', '\140', '\377', '\260', '\012', '\252', '\120',
+ '\142', '\362', '\130', '\000', '\150', '\004', '\012', '\366',
+ '\270', '\000', '\370', '\170', '\217', '\371', '\010', '\012',
+ '\364', '\070', '\217', '\325', '\120', '\143', '\002', '\131',
+ '\143', '\204', '\026', '\116', '\371', '\160', '\002', '\336',
+ '\007', '\166', '\317', '\300', '\003', '\015', '\266', '\220',
+ '\140', '\347', '\175', '\007', '\031', '\116', '\005', '\011',
+ '\120', '\364', '\244', '\163', '\003', '\231', '\126', '\162',
+ '\206', '\117', '\247', '\167', '\000', '\017', '\360', '\001',
+ '\077', '\200', '\130', '\037', '\260', '\001', '\061', '\000',
+ '\003', '\140', '\360', '\161', '\311', '\230', '\036', '\037',
+ '\060', '\212', '\050', '\107', '\123', '\001', '\360', '\123',
+ '\050', '\167', '\017', '\000', '\060', '\017', '\000', '\160',
+ '\146', '\367', '\065', '\132', '\066', '\071', '\010', '\000',
+ '\060', '\004', '\222', '\010', '\000', '\043', '\261', '\017',
+ '\077', '\060', '\022', '\223', '\250', '\223', '\070', '\051',
+ '\132', '\250', '\005', '\000', '\241', '\365', '\010', '\003',
+ '\360', '\014', '\001', '\360', '\016', '\120', '\225', '\126',
+ '\114', '\251', '\224', '\110', '\031', '\132', '\105', '\051',
+ '\132', '\124', '\151', '\223', '\077', '\125', '\225', '\125',
+ '\131', '\224', '\132', '\151', '\224', '\120', '\305', '\164',
+ '\113', '\267', '\225', '\133', '\171', '\137', '\376', '\360',
+ '\156', '\277', '\040', '\002', '\242', '\040', '\012', '\252',
+ '\200', '\226', '\152', '\251', '\012', '\146', '\071', '\226',
+ '\156', '\111', '\226', '\157', '\051', '\226', '\167', '\110',
+ '\140', '\216', '\105', '\227', '\166', '\131', '\227', '\002',
+ '\205', '\225', '\066', '\131', '\225', '\077', '\005', '\226',
+ '\134', '\271', '\225', '\236', '\350', '\144', '\173', '\071',
+ '\230', '\130', '\371', '\123', '\177', '\171', '\230', '\140',
+ '\031', '\230', '\301', '\027', '\000', '\170', '\360', '\000',
+ '\316', '\306', '\026', '\302', '\020', '\016', '\044', '\040',
+ '\015', '\270', '\340', '\000', '\240', '\040', '\000', '\040',
+ '\120', '\153', '\001', '\220', '\231', '\150', '\050', '\162',
+ '\050', '\240', '\000', '\036', '\300', '\115', '\374', '\200',
+ '\116', '\015', '\365', '\001', '\303', '\020', '\004', '\347',
+ '\060', '\016', '\314', '\366', '\015', '\052', '\365', '\101',
+ '\061', '\167', '\000', '\200', '\350', '\007', '\341', '\367',
+ '\215', '\104', '\005', '\014', '\157', '\151', '\226', '\052',
+ '\240', '\012', '\271', '\271', '\233', '\154', '\051', '\012',
+ '\157', '\371', '\233', '\144', '\051', '\227', '\167', '\071',
+ '\234', '\170', '\111', '\227', '\337', '\270', '\121', '\007',
+ '\005', '\026', '\006', '\106', '\150', '\233', '\331', '\014',
+ '\154', '\340', '\234', '\316', '\031', '\000', '\320', '\110',
+ '\215', '\070', '\200', '\001', '\006', '\220', '\201', '\214',
+ '\151', '\145', '\036', '\125', '\200', '\002', '\311', '\017',
+ '\357', '\060', '\116', '\044', '\150', '\121', '\000', '\300',
+ '\035', '\314', '\045', '\005', '\000', '\340', '\005', '\000',
+ '\100', '\010', '\000', '\340', '\020', '\123', '\007', '\001',
+ '\001', '\000', '\003', '\230', '\131', '\153', '\004', '\160',
+ '\170', '\311', '\310', '\077', '\004', '\120', '\177', '\053',
+ '\351', '\121', '\151', '\147', '\167', '\107', '\146', '\116',
+ '\346', '\204', '\202', '\340', '\020', '\174', '\307', '\230',
+ '\222', '\051', '\151', '\203', '\034', '\200', '\210', '\343',
+ '\304', '\014', '\014', '\240', '\240', '\340', '\311', '\155',
+ '\001', '\020', '\016', '\041', '\020', '\016', '\141', '\040',
+ '\014', '\020', '\300', '\001', '\016', '\160', '\145', '\370',
+ '\160', '\004', '\053', '\265', '\231', '\347', '\144', '\147',
+ '\204', '\126', '\220', '\102', '\030', '\017', '\203', '\020',
+ '\017', '\343', '\060', '\017', '\363', '\360', '\016', '\071',
+ '\260', '\145', '\127', '\346', '\017', '\307', '\120', '\026',
+ '\053', '\345', '\166', '\007', '\365', '\123', '\060', '\132',
+ '\145', '\124', '\066', '\135', '\212', '\131', '\243', '\125',
+ '\306', '\007', '\372', '\171', '\014', '\001', '\060', '\010',
+ '\245', '\027', '\000', '\306', '\000', '\137', '\070', '\166',
+ '\174', '\050', '\000', '\000', '\105', '\352', '\016', '\000',
+ '\300', '\006', '\000', '\160', '\174', '\332', '\321', '\121',
+ '\374', '\120', '\124', '\164', '\370', '\010', '\007', '\360',
+ '\011', '\007', '\340', '\015', '\131', '\226', '\210', '\107',
+ '\306', '\121', '\373', '\351', '\017', '\112', '\226', '\245',
+ '\160', '\000', '\161', '\300', '\000', '\016', '\360', '\200',
+ '\017', '\374', '\120', '\154', '\370', '\200', '\015', '\214',
+ '\300', '\000', '\006', '\300', '\077', '\003', '\000', '\010',
+ '\020', '\026', '\163', '\211', '\250', '\144', '\003', '\300',
+ '\245', '\077', '\205', '\017', '\003', '\300', '\013', '\003',
+ '\300', '\003', '\003', '\140', '\203', '\066', '\050', '\107',
+ '\316', '\005', '\004', '\060', '\000', '\010', '\007', '\305',
+ '\134', '\062', '\360', '\017', '\067', '\140', '\074', '\000',
+ '\200', '\134', '\060', '\000', '\250', '\315', '\105', '\243',
+ '\300', '\000', '\017', '\300', '\020', '\017', '\200', '\040',
+ '\223', '\367', '\260', '\133', '\000', '\160', '\017', '\223',
+ '\032', '\251', '\217', '\112', '\243', '\204', '\111', '\230',
+ '\206', '\251', '\227', '\104', '\211', '\230', '\177', '\251',
+ '\230', '\242', '\252', '\225', '\142', '\111', '\226', '\146',
+ '\231', '\226', '\252', '\252', '\226', '\155', '\011', '\227',
+ '\256', '\072', '\226', '\302', '\131', '\234', '\262', '\112',
+ '\234', '\215', '\365', '\215', '\245', '\025', '\000', '\042',
+ '\200', '\253', '\270', '\372', '\017', '\043', '\000', '\150',
+ '\276', '\052', '\002', '\200', '\026', '\017', '\077', '\020',
+ '\001', '\040', '\100', '\254', '\304', '\012', '\135', '\151',
+ '\165', '\000', '\356', '\360', '\017', '\357', '\300', '\254',
+ '\314', '\172', '\007', '\356', '\000', '\255', '\225', '\072',
+ '\255', '\377', '\160', '\007', '\340', '\260', '\133', '\017',
+ '\007', '\012', '\001', '\240', '\255', '\260', '\020', '\000',
+ '\260', '\060', '\000', '\240', '\007', '\172', '\274', '\160',
+ '\000', '\343', '\352', '\013', '\007', '\340', '\013', '\035',
+ '\271', '\174', '\015', '\144', '\210', '\301', '\067', '\174',
+ '\303', '\267', '\117', '\360', '\032', '\117', '\044', '\045',
+ '\117', '\306', '\126', '\026', '\037', '\020', '\102', '\024',
+ '\220', '\257', '\372', '\272', '\257', '\024', '\360', '\007',
+ '\076', '\300', '\001', '\010', '\240', '\243', '\002', '\013',
+ '\000', '\003', '\133', '\260', '\004', '\173', '\260', '\241',
+ '\030', '\212', '\376', '\160', '\260', '\114', '\132', '\205',
+ '\010', '\320', '\022', '\337', '\370', '\000', '\170', '\360',
+ '\215', '\055', '\241', '\212', '\330', '\270', '\216', '\266',
+ '\212', '\227', '\337', '\270', '\216', '\330', '\130', '\020',
+ '\157', '\144', '\117', '\351', '\141', '\117', '\157', '\124',
+ '\020', '\007', '\045', '\205', '\365', '\132', '\026', '\314',
+ '\366', '\017', '\307', '\167', '\120', '\125', '\070', '\210',
+ '\321', '\205', '\007', '\321', '\345', '\022', '\036', '\213',
+ '\174', '\320', '\145', '\221', '\210', '\125', '\177', '\214',
+ '\303', '\000', '\010', '\300', '\001', '\076', '\360', '\007',
+ '\374', '\372', '\263', '\332', '\161', '\174', '\072', '\272',
+ '\260', '\011', '\333', '\215', '\007', '\153', '\260', '\110',
+ '\173', '\260', '\073', '\333', '\263', '\077', '\333', '\257',
+ '\377', '\212', '\000', '\102', '\253', '\237', '\105', '\233',
+ '\264', '\072', '\132', '\264', '\013', '\253', '\243', '\307',
+ '\167', '\021', '\256', '\227', '\120', '\200', '\260', '\007',
+ '\240', '\260', '\007', '\220', '\260', '\007', '\210', '\040',
+ '\266', '\144', '\073', '\266', '\214', '\260', '\007', '\106',
+ '\362', '\013', '\173', '\200', '\001', '\334', '\321', '\247',
+ '\310', '\307', '\076', '\000', '\260', '\222', '\140', '\360',
+ '\017', '\160', '\360', '\017', '\060', '\173', '\267', '\166',
+ '\373', '\017', '\247', '\346', '\007', '\211', '\345', '\007',
+ '\177', '\000', '\003', '\176', '\040', '\101', '\341', '\201',
+ '\020', '\204', '\013', '\000', '\355', '\027', '\001', '\002',
+ '\360', '\253', '\020', '\040', '\002', '\377', '\007', '\000',
+ '\044', '\140', '\244', '\006', '\005', '\014', '\246', '\205',
+ '\125', '\003', '\340', '\100', '\003', '\170', '\271', '\357',
+ '\000', '\255', '\322', '\372', '\016', '\024', '\310', '\207',
+ '\034', '\005', '\014', '\377', '\000', '\272', '\240', '\233',
+ '\212', '\325', '\123', '\075', '\020', '\040', '\000', '\247',
+ '\033', '\016', '\341', '\200', '\147', '\343', '\064', '\116',
+ '\170', '\246', '\272', '\247', '\173', '\272', '\245', '\113',
+ '\000', '\251', '\150', '\000', '\330', '\250', '\263', '\004',
+ '\140', '\235', '\042', '\152', '\242', '\366', '\260', '\003',
+ '\341', '\304', '\017', '\007', '\140', '\017', '\037', '\140',
+ '\242', '\042', '\212', '\001', '\002', '\140', '\235', '\014',
+ '\240', '\246', '\056', '\141', '\000', '\070', '\301', '\002',
+ '\006', '\340', '\011', '\224', '\150', '\000', '\365', '\027',
+ '\002', '\000', '\160', '\002', '\000', '\120', '\024', '\326',
+ '\213', '\275', '\325', '\013', '\000', '\324', '\113', '\275',
+ '\365', '\147', '\211', '\030', '\320', '\000', '\174', '\040',
+ '\276', '\015', '\340', '\007', '\073', '\010', '\125', '\350',
+ '\233', '\200', '\352', '\233', '\276', '\350', '\213', '\023',
+ '\330', '\226', '\231', '\360', '\053', '\000', '\234', '\300',
+ '\001', '\323', '\270', '\216', '\235', '\231', '\000', '\044',
+ '\040', '\001', '\371', '\332', '\022', '\252', '\206', '\023',
+ '\371', '\365', '\161', '\037', '\247', '\215', '\070', '\340',
+ '\001', '\237', '\300', '\007', '\334', '\026', '\210', '\363',
+ '\313', '\137', '\371', '\146', '\003', '\066', '\020', '\232',
+ '\351', '\150', '\137', '\000', '\046', '\146', '\055', '\121',
+ '\215', '\317', '\130', '\216', '\317', '\130', '\215', '\055',
+ '\321', '\216', '\007', '\140', '\137', '\257', '\251', '\122',
+ '\074', '\300', '\145', '\070', '\160', '\216', '\303', '\020',
+ '\016', '\143', '\060', '\016', '\043', '\174', '\216', '\351',
+ '\370', '\301', '\255', '\051', '\153', '\201', '\247', '\136',
+ '\201', '\127', '\127', '\056', '\354', '\302', '\035', '\227',
+ '\137', '\164', '\071', '\303', '\372', '\305', '\021', '\351',
+ '\341', '\003', '\372', '\231', '\144', '\145', '\246', '\245',
+ '\060', '\360', '\236', '\230', '\111', '\173', '\005', '\241',
+ '\035', '\040', '\340', '\100', '\051', '\211', '\162', '\106',
+ '\225', '\145', '\362', '\224', '\117', '\371', '\364', '\237',
+ '\360', '\160', '\241', '\007', '\212', '\003', '\340', '\360',
+ '\245', '\033', '\005', '\272', '\135', '\127', '\225', '\240',
+ '\065', '\006', '\000', '\320', '\131', '\233', '\225', '\131',
+ '\227', '\125', '\131', '\242', '\145', '\141', '\251', '\165',
+ '\133', '\144', '\114', '\133', '\262', '\005', '\133', '\256',
+ '\305', '\132', '\252', '\125', '\224', '\015', '\326', '\250',
+ '\060', '\260', '\134', '\311', '\165', '\134', '\305', '\065',
+ '\134', '\301', '\365', '\133', '\315', '\145', '\141', '\322',
+ '\025', '\136', '\172', '\354', '\135', '\334', '\245', '\135',
+ '\330', '\145', '\135', '\367', '\120', '\135', '\064', '\112',
+ '\137', '\051', '\031', '\170', '\033', '\365', '\136', '\355',
+ '\025', '\127', '\061', '\334', '\302', '\120', '\045', '\253',
+ '\034', '\374', '\237', '\063', '\327', '\001', '\374', '\145',
+ '\303', '\003', '\326', '\165', '\011', '\166', '\311', '\013',
+ '\246', '\140', '\026', '\066', '\141', '\234', '\114', '\141',
+ '\017', '\126', '\020', '\074', '\373', '\007', '\167', '\340',
+ '\257', '\000', '\333', '\005', '\153', '\220', '\004', '\101',
+ '\220', '\312', '\121', '\170', '\260', '\104', '\333', '\222',
+ '\256', '\174', '\265', '\000', '\240', '\013', '\120', '\345',
+ '\312', '\241', '\170', '\015', '\001', '\140', '\313', '\074',
+ '\172', '\225', '\235', '\252', '\227', '\212', '\351', '\227',
+ '\176', '\371', '\075', '\040', '\240', '\000', '\311', '\040',
+ '\003', '\362', '\220', '\000', '\114', '\140', '\000', '\103',
+ '\200', '\001', '\213', '\174', '\136', '\317', '\206', '\023',
+ '\350', '\140', '\007', '\373', '\360', '\015', '\004', '\167',
+ '\154', '\246', '\365', '\017', '\317', '\220', '\007', '\063',
+ '\274', '\301', '\332', '\374', '\120', '\156', '\372', '\251',
+ '\273', '\354', '\251', '\136', '\051', '\230', '\276', '\214',
+ '\230', '\255', '\013', '\233', '\166', '\146', '\010', '\030',
+ '\060', '\010', '\060', '\020', '\010', '\340', '\020', '\014',
+ '\341', '\340', '\316', '\041', '\000', '\016', '\023', '\240',
+ '\215', '\030', '\120', '\146', '\346', '\114', '\232', '\277',
+ '\313', '\171', '\334', '\051', '\220', '\117', '\230', '\317',
+ '\341', '\164', '\007', '\000', '\253', '\212', '\002', '\075',
+ '\320', '\034', '\160', '\007', '\357', '\100', '\313', '\106',
+ '\273', '\312', '\012', '\275', '\244', '\014', '\035', '\265',
+ '\105', '\173', '\320', '\051', '\221', '\011', '\021', '\001',
+ '\004', '\216', '\160', '\020', '\312', '\150', '\223', '\030',
+ '\201', '\076', '\374', '\343', '\100', '\005', '\261', '\023',
+ '\112', '\261', '\105', '\157', '\244', '\026', '\232', '\224',
+ '\036', '\347', '\001', '\000', '\022', '\300', '\223', '\000',
+ '\100', '\001', '\000', '\120', '\001', '\224', '\010', '\000',
+ '\027', '\060', '\210', '\000', '\140', '\023', '\032', '\000',
+ '\000', '\076', '\301', '\070', '\035', '\100', '\212', '\051',
+ '\211', '\022', '\324', '\113', '\115', '\223', '\370', '\270',
+ '\105', '\141', '\002', '\333', '\133', '\244', '\221', '\310',
+ '\024', '\053', '\000', '\000', '\054', '\060', '\107', '\000',
+ '\340', '\002', '\000', '\360', '\002', '\275', '\105', '\250',
+ '\000', '\060', '\003', '\000', '\100', '\003', '\257', '\004',
+ '\000', '\066', '\240', '\110', '\014', '\235', '\003', '\045',
+ '\004', '\000', '\073', '\200', '\120', '\075', '\000', '\267',
+ '\365', '\007', '\023', '\124', '\041', '\004', '\071', '\251',
+ '\022', '\000', '\340', '\031', '\106', '\340', '\111', '\000',
+ '\004', '\000', '\111', '\000', '\000', '\112', '\000', '\000',
+ '\113', '\000', '\000', '\114', '\000', '\000', '\115', '\000',
+ '\000', '\136', '\361', '\004', '\064', '\001', '\000', '\121',
+ '\340', '\032', '\000', '\300', '\025', '\166', '\121', '\005',
+ '\000', '\140', '\005', '\251', '\161', '\034', '\000', '\140',
+ '\034', '\132', '\000', '\000', '\133', '\040', '\115', '\000',
+ '\320', '\005', '\347', '\011', '\000', '\137', '\000', '\000',
+ '\140', '\021', '\006', '\000', '\040', '\006', '\236', '\065',
+ '\021', '\145', '\000', '\000', '\146', '\000', '\000', '\147',
+ '\000', '\000', '\150', '\000', '\000', '\151', '\000', '\000',
+ '\152', '\000', '\000', '\132', '\241', '\244', '\143', '\341',
+ '\006', '\000', '\360', '\006', '\000', '\360', '\245', '\161',
+ '\000', '\000', '\250', '\061', '\007', '\000', '\100', '\007',
+ '\000', '\120', '\007', '\000', '\200', '\026', '\167', '\200',
+ '\143', '\171', '\060', '\037', '\000', '\260', '\007', '\007',
+ '\333', '\007', '\000', '\020', '\270', '\050', '\207', '\023',
+ '\154', '\101', '\071', '\070', '\251', '\236', '\205', '\000',
+ '\000', '\206', '\000', '\000', '\207', '\260', '\236', '\000',
+ '\220', '\010', '\000', '\240', '\010', '\000', '\260', '\010',
+ '\000', '\300', '\010', '\000', '\320', '\010', '\000', '\120',
+ '\321', '\217', '\000', '\000', '\220', '\000', '\000', '\221',
+ '\000', '\000', '\222', '\000', '\000', '\223', '\000', '\000',
+ '\224', '\000', '\000', '\225', '\000', '\000', '\226', '\000',
+ '\000', '\227', '\000', '\000', '\230', '\000', '\000', '\022',
+ '\015', '\022', '\226', '\103', '\002', '\063', '\301', '\336',
+ '\006', '\341', '\336', '\216', '\333', '\336', '\362', '\375',
+ '\336', '\363', '\035', '\337', '\364', '\175', '\337', '\366',
+ '\235', '\337', '\360', '\275', '\337', '\365', '\315', '\337',
+ '\370', '\355', '\337', '\372', '\335', '\337', '\002', '\376',
+ '\337', '\003', '\036', '\340', '\004', '\176', '\340', '\006',
+ '\236', '\340', '\000', '\276', '\340', '\005', '\316', '\340',
+ '\010', '\356', '\340', '\012', '\336', '\340', '\022', '\376',
+ '\340', '\023', '\036', '\341', '\024', '\176', '\341', '\026',
+ '\236', '\341', '\020', '\276', '\341', '\025', '\316', '\341',
+ '\030', '\356', '\341', '\032', '\336', '\341', '\042', '\376',
+ '\341', '\043', '\236', '\340', '\004', '\060', '\023', '\047',
+ '\116', '\342', '\052', '\036', '\342', '\053', '\016', '\342',
+ '\102', '\140', '\021', '\057', '\256', '\336', '\051', '\161',
+ '\024', '\056', '\235', '\020', '\067', '\335', '\077', '\011',
+ '\201', '\325', '\006', '\141', '\327', '\006', '\201', '\236',
+ '\006', '\201', '\032', '\006', '\061', '\333', '\006', '\301',
+ '\026', '\006', '\301', '\334', '\006', '\161', '\336', '\006',
+ '\261', '\012', '\011', '\061', '\014', '\011', '\161', '\015',
+ '\011', '\001', '\170', '\124', '\150', '\020', '\015', '\140',
+ '\021', '\030', '\140', '\021', '\050', '\140', '\021', '\063',
+ '\140', '\021', '\103', '\140', '\021', '\116', '\140', '\021',
+ '\136', '\140', '\021', '\145', '\140', '\021', '\161', '\140',
+ '\021', '\167', '\140', '\021', '\202', '\140', '\021', '\215',
+ '\140', '\021', '\235', '\140', '\021', '\243', '\260', '\072',
+ '\026', '\301', '\013', '\026', '\241', '\224', '\006', '\221',
+ '\015', '\026', '\201', '\016', '\026', '\141', '\017', '\026',
+ '\221', '\000', '\063', '\321', '\000', '\063', '\141', '\001',
+ '\063', '\321', '\001', '\063', '\221', '\002', '\063', '\141',
+ '\003', '\063', '\321', '\136', '\006', '\101', '\005', '\063',
+ '\121', '\006', '\063', '\021', '\007', '\063', '\041', '\010',
+ '\063', '\321', '\010', '\063', '\321', '\011', '\063', '\141',
+ '\012', '\063', '\101', '\013', '\063', '\241', '\013', '\063',
+ '\121', '\014', '\063', '\321', '\014', '\063', '\241', '\015',
+ '\032', '\065', '\023', '\353', '\060', '\023', '\361', '\060',
+ '\023', '\374', '\060', '\023', '\002', '\120', '\074', '\015',
+ '\120', '\074', '\023', '\120', '\074', '\036', '\120', '\074',
+ '\043', '\120', '\074', '\055', '\120', '\074', '\023', '\165',
+ '\025', '\305', '\023', '\005', '\305', '\363', '\005', '\305',
+ '\223', '\006', '\305', '\203', '\007', '\305', '\023', '\010',
+ '\305', '\203', '\224', '\361', '\121', '\074', '\252', '\120',
+ '\074', '\263', '\120', '\074', '\301', '\000', '\075', '\305',
+ '\203', '\015', '\305', '\303', '\015', '\305', '\123', '\016',
+ '\305', '\043', '\017', '\305', '\103', '\273', '\342', '\141',
+ '\022', '\025', '\140', '\022', '\034', '\140', '\075', '\046',
+ '\361', '\002', '\046', '\261', '\003', '\046', '\061', '\173',
+ '\006', '\241', '\004', '\046', '\221', '\005', '\046', '\321',
+ '\006', '\046', '\161', '\007', '\046', '\141', '\010', '\046',
+ '\021', '\011', '\046', '\021', '\012', '\046', '\261', '\012',
+ '\046', '\241', '\013', '\046', '\141', '\014', '\046', '\161',
+ '\015', '\046', '\001', '\016', '\046', '\341', '\016', '\046',
+ '\161', '\017', '\046', '\121', '\000', '\353', '\063', '\001',
+ '\353', '\143', '\002', '\353', '\203', '\003', '\353', '\363',
+ '\004', '\353', '\323', '\005', '\353', '\003', '\007', '\353',
+ '\243', '\141', '\006', '\061', '\011', '\353', '\363', '\011',
+ '\353', '\003', '\013', '\353', '\043', '\014', '\353', '\223',
+ '\015', '\353', '\023', '\016', '\353', '\343', '\016', '\353',
+ '\123', '\017', '\353', '\023', '\000', '\377', '\263', '\077',
+ '\006', '\101', '\001', '\377', '\323', '\001', '\377', '\263',
+ '\002', '\377', '\243', '\215', '\134', '\364', '\077', '\101',
+ '\360', '\077', '\115', '\360', '\077', '\124', '\360', '\077',
+ '\324', '\150', '\020', '\157', '\360', '\077', '\203', '\360',
+ '\077', '\223', '\140', '\100', '\377', '\223', '\013', '\377',
+ '\363', '\014', '\377', '\203', '\015', '\377', '\143', '\016',
+ '\377', '\343', '\016', '\377', '\263', '\017', '\014', '\024',
+ '\101', '\012', '\020', '\101', '\023', '\020', '\101', '\041',
+ '\020', '\101', '\052', '\020', '\101', '\137', '\146', '\020',
+ '\101', '\020', '\101', '\117', '\020', '\101', '\125', '\020',
+ '\101', '\140', '\020', '\101', '\146', '\020', '\101', '\161',
+ '\020', '\101', '\310', '\101', '\032', '\246', '\201', '\032',
+ '\133', '\137', '\007', '\245', '\161', '\032', '\137', '\320',
+ '\006', '\141', '\060', '\007', '\132', '\161', '\030', '\162',
+ '\360', '\006', '\263', '\215', '\366', '\152', '\077', '\366',
+ '\145', '\257', '\025', '\142', '\120', '\366', '\145', '\100',
+ '\006', '\137', '\300', '\366', '\167', '\360', '\005', '\144',
+ '\240', '\366', '\244', '\035', '\367', '\173', '\101', '\367',
+ '\166', '\217', '\367', '\172', '\357', '\366', '\146', '\037',
+ '\331', '\162', '\357', '\367', '\162', '\220', '\366', '\167',
+ '\137', '\007', '\137', '\312', '\367', '\163', '\137', '\367',
+ '\207', '\337', '\366', '\212', '\057', '\370', '\160', '\377',
+ '\006', '\141', '\340', '\332', '\142', '\100', '\371', '\164',
+ '\040', '\371', '\221', '\375', '\006', '\147', '\360', '\006',
+ '\163', '\220', '\006', '\164', '\120', '\333', '\227', '\337',
+ '\371', '\237', '\037', '\372', '\232', '\177', '\371', '\164',
+ '\100', '\007', '\157', '\320', '\006', '\137', '\300', '\006',
+ '\145', '\140', '\006', '\231', '\077', '\006', '\247', '\261',
+ '\030', '\250', '\201', '\372', '\252', '\317', '\372', '\256',
+ '\017', '\373', '\137', '\040', '\373', '\162', '\100', '\373',
+ '\247', '\377', '\006', '\251', '\277', '\372', '\137', '\040',
+ '\007', '\151', '\160', '\006', '\150', '\020', '\373', '\263',
+ '\057', '\031', '\233', '\037', '\374', '\254', '\117', '\374',
+ '\306', '\217', '\374', '\275', '\057', '\031', '\277', '\317',
+ '\374', '\137', '\360', '\371', '\144', '\120', '\331', '\266',
+ '\057', '\374', '\326', '\137', '\006', '\323', '\177', '\373',
+ '\137', '\100', '\007', '\145', '\200', '\375', '\300', '\357',
+ '\375', '\340', '\317', '\375', '\144', '\077', '\370', '\227',
+ '\217', '\007', '\325', '\017', '\007', '\151', '\040', '\007',
+ '\141', '\240', '\244', '\351', '\277', '\376', '\355', '\377',
+ '\376', '\232', '\077', '\006', '\214', '\001', '\376', '\162',
+ '\360', '\005', '\160', '\100', '\007', '\250', '\141', '\377',
+ '\156', '\200', '\377', '\372', '\317', '\377', '\365', '\337',
+ '\376', '\143', '\340', '\372', '\243', '\321', '\376', '\143',
+ '\340', '\372', '\365', '\317', '\006', '\157', '\060', '\006',
+ '\132', '\061', '\006', '\154', '\360', '\006', '\143', '\260',
+ '\006', '\365', '\377', '\006', '\146', '\140', '\006', '\341',
+ '\077', '\366', '\165', '\220', '\331', '\262', '\157', '\006',
+ '\146', '\020', '\376', '\143', '\137', '\007', '\147', '\120',
+ '\377', '\151', '\077', '\007', '\254', '\075', '\006', '\151',
+ '\077', '\007', '\163', '\120', '\377', '\151', '\077', '\007',
+ '\163', '\060', '\374', '\145', '\140', '\007', '\222', '\261',
+ '\027', '\243', '\221', '\366', '\163', '\060', '\007', '\303',
+ '\137', '\006', '\166', '\040', '\031', '\173', '\121', '\377',
+ '\151', '\077', '\007', '\163', '\200', '\006', '\141', '\320',
+ '\376', '\243', '\221', '\366', '\163', '\060', '\007', '\150',
+ '\020', '\006', '\355', '\257', '\371', '\144', '\220', '\006',
+ '\141', '\320', '\006', '\157', '\340', '\006', '\164', '\077',
+ '\006', '\151', '\077', '\007', '\254', '\115', '\006', '\151',
+ '\020', '\006', '\155', '\360', '\006', '\156', '\100', '\367',
+ '\143', '\220', '\366', '\163', '\060', '\007', '\232', '\237',
+ '\367', '\256', '\235', '\367', '\231', '\177', '\376', '\132',
+ '\221', '\367', '\164', '\220', '\376', '\000', '\220', '\367',
+ '\164', '\020', '\377', '\347', '\257', '\025', '\171', '\137',
+ '\007', '\142', '\340', '\372', '\216', '\217', '\370', '\000',
+ '\220', '\367', '\165', '\040', '\006', '\256', '\357', '\370',
+ '\210', '\257', '\371', '\144', '\340', '\376', '\272', '\317',
+ '\006', '\207', '\161', '\006', '\225', '\115', '\006', '\356',
+ '\257', '\373', '\154', '\160', '\030', '\147', '\140', '\376',
+ '\157', '\017', '\000', '\144', '\340', '\376', '\272', '\077',
+ '\007', '\144', '\317', '\006', '\112', '\112', '\006', '\356',
+ '\257', '\373', '\163', '\100', '\366', '\154', '\300', '\006',
+ '\232', '\117', '\006', '\356', '\017', '\007', '\215', '\237',
+ '\376', '\000', '\100', '\006', '\356', '\017', '\007', '\215',
+ '\037', '\377', '\347', '\257', '\025', '\145', '\200', '\007',
+ '\143', '\200', '\006', '\141', '\340', '\006', '\147', '\120',
+ '\331', '\145', '\200', '\007', '\143', '\200', '\006', '\141',
+ '\340', '\006', '\147', '\140', '\376', '\157', '\157', '\331',
+ '\256', '\017', '\366', '\226', '\355', '\372', '\140', '\257',
+ '\371', '\235', '\057', '\006', '\142', '\340', '\372', '\250',
+ '\321', '\371', '\142', '\040', '\006', '\256', '\237', '\377',
+ '\347', '\257', '\025', '\147', '\360', '\030', '\142', '\120',
+ '\333', '\147', '\360', '\030', '\142', '\220', '\007', '\232',
+ '\217', '\006', '\141', '\340', '\006', '\144', '\300', '\134',
+ '\150', '\020', '\006', '\156', '\100', '\006', '\061', '\240',
+ '\371', '\150', '\020', '\006', '\156', '\100', '\006', '\062',
+ '\240', '\331', '\141', '\340', '\006', '\144', '\040', '\003',
+ '\232', '\237', '\027', '\207', '\341', '\332', '\171', '\161',
+ '\030', '\231', '\177', '\376', '\132', '\221', '\006', '\262',
+ '\117', '\332', '\151', '\040', '\373', '\156', '\240', '\371',
+ '\355', '\377', '\006', '\156', '\260', '\373', '\151', '\077',
+ '\007', '\254', '\335', '\376', '\157', '\340', '\006', '\273',
+ '\237', '\366', '\163', '\060', '\007', '\232', '\237', '\373',
+ '\231', '\277', '\377', '\250', '\221', '\373', '\231', '\277',
+ '\377', '\371', '\177', '\376', '\241', '\375', '\372', '\231',
+ '\277', '\375', '\111', '\372', '\372', '\231', '\277', '\375',
+ '\232', '\237', '\373', '\231', '\137', '\376', '\111', '\372',
+ '\372', '\231', '\137', '\376', '\232', '\237', '\373', '\164',
+ '\040', '\006', '\165', '\020', '\374', '\244', '\235', '\373',
+ '\164', '\040', '\006', '\165', '\020', '\374', '\156', '\240',
+ '\371', '\154', '\300', '\006', '\165', '\357', '\006', '\177',
+ '\121', '\331', '\154', '\300', '\006', '\165', '\357', '\006',
+ '\177', '\141', '\376', '\157', '\237', '\244', '\371', '\037',
+ '\006', '\156', '\360', '\027', '\225', '\315', '\006', '\371',
+ '\037', '\006', '\156', '\360', '\027', '\346', '\377', '\366',
+ '\000', '\100', '\366', '\244', '\115', '\366', '\156', '\240',
+ '\371', '\155', '\220', '\006', '\144', '\100', '\006', '\256',
+ '\057', '\006', '\165', '\020', '\374', '\244', '\335', '\006',
+ '\151', '\100', '\006', '\144', '\340', '\372', '\142', '\120',
+ '\007', '\301', '\357', '\006', '\232', '\337', '\006', '\157',
+ '\120', '\007', '\173', '\001', '\000', '\155', '\360', '\006',
+ '\165', '\260', '\027', '\232', '\017', '\007', '\214', '\061',
+ '\006', '\151', '\240', '\244', '\160', '\300', '\030', '\143',
+ '\220', '\006', '\154', '\240', '\371', '\354', '\357', '\376',
+ '\340', '\177', '\332', '\363', '\017', '\376', '\232', '\017',
+ '\007', '\154', '\120', '\007', '\254', '\015', '\007', '\154',
+ '\120', '\007', '\163', '\240', '\371', '\161', '\120', '\007',
+ '\172', '\101', '\007', '\151', '\360', '\006', '\156', '\340',
+ '\370', '\210', '\017', '\000', '\161', '\120', '\007', '\172',
+ '\101', '\007', '\151', '\360', '\006', '\156', '\340', '\370',
+ '\210', '\257', '\371', '\316', '\177', '\374', '\372', '\317',
+ '\377', '\252', '\135', '\374', '\307', '\257', '\377', '\374',
+ '\257', '\371', '\316', '\177', '\374', '\325', '\237', '\006',
+ '\327', '\257', '\332', '\305', '\177', '\374', '\325', '\237',
+ '\006', '\327', '\257', '\371', '\316', '\177', '\374', '\337',
+ '\037', '\376', '\252', '\135', '\374', '\307', '\377', '\375',
+ '\341', '\257', '\371', '\316', '\177', '\374', '\142', '\120',
+ '\007', '\301', '\117', '\332', '\316', '\177', '\374', '\142',
+ '\120', '\007', '\301', '\357', '\006', '\232', '\057', '\007',
+ '\164', '\300', '\006', '\255', '\317', '\371', '\246', '\055',
+ '\007', '\164', '\300', '\006', '\255', '\317', '\371', '\157',
+ '\240', '\371', '\163', '\020', '\006', '\151', '\300', '\006',
+ '\227', '\137', '\371', '\000', '\060', '\007', '\141', '\220',
+ '\006', '\154', '\160', '\371', '\225', '\257', '\371', '\163',
+ '\040', '\006', '\200', '\177', '\007', '\156', '\340', '\370',
+ '\210', '\017', '\000', '\163', '\040', '\006', '\200', '\177',
+ '\007', '\156', '\340', '\370', '\210', '\257', '\371', '\163',
+ '\040', '\006', '\137', '\200', '\006', '\200', '\137', '\007',
+ '\142', '\340', '\372', '\216', '\217', '\370', '\000', '\060',
+ '\007', '\142', '\360', '\005', '\150', '\000', '\370', '\165',
+ '\040', '\006', '\256', '\357', '\370', '\210', '\257', '\371',
+ '\163', '\040', '\006', '\255', '\377', '\372', '\231', '\157',
+ '\367', '\000', '\060', '\007', '\142', '\320', '\372', '\257',
+ '\237', '\371', '\177', '\177', '\376', '\132', '\061', '\007',
+ '\142', '\060', '\374', '\305', '\177', '\374', '\216', '\217',
+ '\370', '\000', '\060', '\007', '\142', '\060', '\374', '\305',
+ '\177', '\374', '\216', '\217', '\370', '\232', '\077', '\007',
+ '\142', '\360', '\005', '\221', '\157', '\367', '\000', '\060',
+ '\007', '\142', '\360', '\005', '\221', '\377', '\367', '\347',
+ '\257', '\025', '\163', '\040', '\006', '\137', '\140', '\007',
+ '\200', '\137', '\007', '\142', '\340', '\372', '\216', '\217',
+ '\370', '\000', '\060', '\007', '\142', '\360', '\005', '\166',
+ '\000', '\370', '\165', '\040', '\006', '\256', '\357', '\370',
+ '\210', '\257', '\371', '\163', '\200', '\006', '\165', '\220',
+ '\372', '\256', '\017', '\000', '\163', '\200', '\006', '\165',
+ '\220', '\372', '\256', '\257', '\371', '\237', '\257', '\007',
+ '\151', '\340', '\006', '\231', '\375', '\371', '\172', '\220',
+ '\006', '\156', '\160', '\006', '\232', '\077', '\007', '\354',
+ '\177', '\375', '\253', '\315', '\376', '\327', '\237', '\377',
+ '\347', '\257', '\025', '\163', '\000', '\007', '\356', '\237',
+ '\007', '\143', '\020', '\006', '\244', '\075', '\007', '\160',
+ '\340', '\376', '\171', '\060', '\006', '\141', '\340', '\006',
+ '\232', '\077', '\007', '\164', '\160', '\030', '\000', '\060',
+ '\007', '\164', '\160', '\030', '\232', '\117', '\007', '\207',
+ '\161', '\006', '\145', '\340', '\332', '\164', '\160', '\030',
+ '\147', '\120', '\006', '\231', '\177', '\376', '\132', '\101',
+ '\007', '\143', '\220', '\366', '\163', '\300', '\332', '\164',
+ '\060', '\006', '\151', '\077', '\007', '\163', '\240', '\371',
+ '\252', '\017', '\007', '\255', '\377', '\372', '\231', '\157',
+ '\367', '\255', '\375', '\006', '\160', '\320', '\372', '\257',
+ '\237', '\371', '\177', '\177', '\376', '\132', '\241', '\372',
+ '\160', '\320', '\372', '\257', '\017', '\375', '\264', '\337',
+ '\332', '\157', '\000', '\007', '\255', '\377', '\372', '\320',
+ '\357', '\373', '\347', '\257', '\025', '\252', '\017', '\007',
+ '\303', '\137', '\374', '\307', '\277', '\373', '\311', '\217',
+ '\032', '\252', '\017', '\007', '\303', '\137', '\374', '\307',
+ '\277', '\373', '\311', '\237', '\377', '\347', '\257', '\025',
+ '\252', '\017', '\007', '\325', '\237', '\006', '\327', '\337',
+ '\332', '\157', '\000', '\007', '\325', '\237', '\006', '\327',
+ '\257', '\371', '\252', '\017', '\007', '\337', '\037', '\376',
+ '\255', '\375', '\006', '\160', '\360', '\375', '\341', '\257',
+ '\371', '\374', '\137', '\006', '\132', '\301', '\377', '\145',
+ '\260', '\006', '\232', '\137', '\007', '\154', '\120', '\367',
+ '\156', '\360', '\027', '\225', '\135', '\007', '\154', '\120',
+ '\367', '\156', '\360', '\027', '\346', '\377', '\366', '\257',
+ '\015', '\031', '\210', '\301', '\006', '\154', '\000', '\331',
+ '\217', '\041', '\006', '\210', '\301', '\006', '\154', '\020',
+ '\006', '\232', '\017', '\366', '\165', '\357', '\006', '\177',
+ '\121', '\331', '\140', '\137', '\367', '\156', '\360', '\027',
+ '\346', '\377', '\366', '\000', '\160', '\007', '\225', '\077',
+ '\006', '\233', '\175', '\007', '\225', '\077', '\006', '\150',
+ '\240', '\371', '\170', '\200', '\377', '\143', '\201', '\007',
+ '\370', '\317', '\372', '\347', '\257', '\025', '\357', '\141',
+ '\020', '\303', '\064', '\236', '\335', '\141', '\026', '\340',
+ '\041', '\036', '\115', '\131', '\036', '\045', '\115', '\322',
+ '\011', '\001',
+
+};
+
+static const char file_5x7[] = {
+ '\037', '\235', '\214', '\001', '\314', '\214', '\201', '\203',
+ '\000', '\200', '\301', '\000', '\006', '\023', '\032', '\244',
+ '\043', '\300', '\040', '\242', '\204', '\015', '\025', '\032',
+ '\044', '\223', '\220', '\137', '\104', '\002', '\012', '\021',
+ '\002', '\100', '\203', '\021', '\000', '\230', '\001', '\006',
+ '\013', '\112', '\004', '\200', '\053', '\201', '\101', '\144',
+ '\007', '\014', '\202', '\030', '\011', '\000', '\102', '\104',
+ '\100', '\021', '\014', '\002', '\141', '\211', '\010', '\044',
+ '\000', '\110', '\023', '\014', '\002', '\142', '\111', '\316',
+ '\200', '\101', '\014', '\027', '\022', '\152', '\124', '\110',
+ '\321', '\040', '\277', '\016', '\043', '\203', '\216', '\014',
+ '\040', '\041', '\141', '\316', '\203', '\033', '\022', '\256',
+ '\074', '\310', '\042', '\241', '\014', '\241', '\076', '\022',
+ '\026', '\021', '\272', '\044', '\141', '\023', '\241', '\133',
+ '\022', '\212', '\021', '\032', '\047', '\241', '\034', '\205',
+ '\051', '\015', '\366', '\121', '\150', '\044', '\341', '\303',
+ '\204', '\135', '\015', '\126', '\122', '\030', '\027', '\200',
+ '\050', '\241', '\252', '\022', '\262', '\122', '\170', '\325',
+ '\240', '\056', '\241', '\313', '\022', '\116', '\023', '\112',
+ '\056', '\241', '\071', '\226', '\000', '\362', '\145', '\114',
+ '\130', '\100', '\143', '\200', '\007', '\032', '\147', '\070',
+ '\306', '\241', '\361', '\315', '\120', '\005', '\011', '\355',
+ '\014', '\075', '\223', '\060', '\320', '\120', '\237', '\006',
+ '\025', '\015', '\055', '\240', '\260', '\222', '\106', '\043',
+ '\117', '\234', '\120', '\161', '\022', '\244', '\111', '\221',
+ '\057', '\122', '\212', '\034', '\111', '\062', '\205', '\212',
+ '\224', '\054', '\006', '\121', '\127', '\161', '\102', '\344',
+ '\066', '\200', '\046', '\151', '\346', '\214', '\001', '\140',
+ '\244', '\165', '\022', '\046', '\131', '\276', '\260', '\166',
+ '\115', '\074', '\015', '\236', '\062', '\024', '\257', '\024',
+ '\111', '\162', '\004', '\011', '\025', '\345', '\255', '\267',
+ '\066', '\201', '\236', '\246', '\116', '\033', '\000', '\123',
+ '\230', '\004', '\121', '\015', '\100', '\012', '\370', '\042',
+ '\124', '\256', '\044', '\041', '\102', '\005', '\011', '\166',
+ '\346', '\116', '\336', '\310', '\151', '\023', '\206', '\015',
+ '\200', '\040', '\104', '\210', '\174', '\251', '\235', '\205',
+ '\311', '\353', '\345', '\133', '\001', '\000', '\105', '\022',
+ '\130', '\024', '\301', '\304', '\176', '\111', '\150', '\261',
+ '\025', '\024', '\117', '\044', '\241', '\032', '\202', '\012',
+ '\226', '\127', '\304', '\024', '\117', '\060', '\121', '\005',
+ '\025', '\111', '\244', '\366', '\005', '\026', '\022', '\122',
+ '\150', '\041', '\206', '\032', '\342', '\066', '\005', '\024',
+ '\101', '\014', '\341', '\340', '\021', '\000', '\014', '\161',
+ '\237', '\025', '\105', '\110', '\021', '\304', '\021', '\257',
+ '\251', '\307', '\036', '\022', '\051', '\042', '\021', '\204',
+ '\024', '\123', '\240', '\007', '\233', '\154', '\264', '\331',
+ '\206', '\033', '\155', '\117', '\340', '\200', '\103', '\015',
+ '\071', '\324', '\170', '\143', '\216', '\327', '\025', '\341',
+ '\304', '\020', '\117', '\020', '\161', '\042', '\000', '\061',
+ '\000', '\260', '\033', '\021', '\055', '\062', '\341', '\340',
+ '\153', '\014', '\116', '\221', '\004', '\210', '\116', '\000',
+ '\100', '\145', '\155', '\016', '\006', '\301', '\145', '\212',
+ '\117', '\100', '\221', '\205', '\024', '\324', '\131', '\227',
+ '\342', '\033', '\160', '\344', '\041', '\107', '\032', '\147',
+ '\240', '\101', '\007', '\010', '\061', '\344', '\220', '\103',
+ '\014', '\054', '\320', '\151', '\047', '\016', '\040', '\120',
+ '\201', '\106', '\031', '\040', '\074', '\001', '\107', '\031',
+ '\156', '\200', '\160', '\204', '\034', '\157', '\324', '\001',
+ '\007', '\161', '\251', '\121', '\001', '\100', '\013', '\300',
+ '\011', '\327', '\202', '\021', '\316', '\101', '\007', '\051',
+ '\167', '\336', '\265', '\040', '\105', '\013', '\361', '\315',
+ '\127', '\137', '\013', '\055', '\334', '\020', '\052', '\014',
+ '\241', '\326', '\120', '\152', '\013', '\103', '\264', '\120',
+ '\003', '\251', '\100', '\012', '\111', '\144', '\013', '\121',
+ '\112', '\227', '\246', '\243', '\261', '\171', '\170', '\141',
+ '\206', '\135', '\142', '\361', '\005', '\022', '\323', '\125',
+ '\347', '\150', '\024', '\125', '\340', '\367', '\205', '\214',
+ '\355', '\041', '\046', '\224', '\102', '\240', '\001', '\060',
+ '\324', '\120', '\006', '\221', '\106', '\232', '\117', '\314',
+ '\002', '\340', '\323', '\263', '\312', '\032', '\153', '\355',
+ '\265', '\330', '\146', '\133', '\055', '\000', '\340', '\000',
+ '\000', '\110', '\041', '\205', '\030', '\022', '\310', '\267',
+ '\341', '\216', '\013', '\256', '\270', '\344', '\242', '\173',
+ '\256', '\271', '\345', '\246', '\313', '\256', '\272', '\355',
+ '\256', '\353', '\356', '\274', '\362', '\326', '\033', '\357',
+ '\275', '\350', '\032', '\202', '\357', '\273', '\374', '\322',
+ '\333', '\256', '\276', '\360', '\006', '\334', '\257', '\275',
+ '\002', '\373', '\133', '\060', '\301', '\003', '\357', '\153',
+ '\160', '\302', '\007', '\053', '\214', '\360', '\302', '\020',
+ '\077', '\054', '\261', '\303', '\024', '\067', '\154', '\061',
+ '\303', '\030', '\107', '\134', '\161', '\306', '\023', '\137',
+ '\254', '\261', '\307', '\035', '\163', '\274', '\361', '\307',
+ '\042', '\203', '\074', '\162', '\310', '\044', '\247', '\374',
+ '\060', '\300', '\045', '\267', '\234', '\062', '\313', '\052',
+ '\237', '\054', '\263', '\311', '\064', '\273', '\214', '\362',
+ '\315', '\063', '\333', '\234', '\163', '\314', '\065', '\363',
+ '\254', '\163', '\317', '\070', '\003', '\275', '\163', '\320',
+ '\077', '\027', '\355', '\363', '\321', '\104', '\043', '\075',
+ '\164', '\271', '\043', '\165', '\073', '\122', '\132', '\000',
+ '\070', '\220', '\120', '\005', '\011', '\161', '\220', '\320',
+ '\010', '\011', '\251', '\220', '\120', '\224', '\006', '\341',
+ '\220', '\320', '\017', '\011', '\265', '\145', '\320', '\127',
+ '\006', '\071', '\152', '\120', '\130', '\006', '\215', '\145',
+ '\120', '\032', '\011', '\055', '\152', '\320', '\035', '\011',
+ '\371', '\221', '\120', '\041', '\011', '\061', '\222', '\320',
+ '\044', '\011', '\151', '\222', '\120', '\050', '\011', '\241',
+ '\222', '\320', '\053', '\011', '\331', '\222', '\120', '\057',
+ '\011', '\021', '\223', '\120', '\140', '\006', '\111', '\223',
+ '\120', '\066', '\011', '\071', '\015', '\300', '\071', '\011',
+ '\271', '\223', '\120', '\075', '\025', '\045', '\064', '\200',
+ '\106', '\012', '\150', '\024', '\201', '\106', '\030', '\150',
+ '\364', '\201', '\106', '\046', '\150', '\324', '\202', '\106',
+ '\064', '\150', '\264', '\203', '\106', '\102', '\150', '\224',
+ '\204', '\106', '\120', '\150', '\164', '\205', '\106', '\136',
+ '\150', '\124', '\206', '\106', '\154', '\150', '\064', '\207',
+ '\106', '\172', '\150', '\344', '\231', '\103', '\032', '\075',
+ '\242', '\221', '\045', '\032', '\165', '\242', '\021', '\051',
+ '\032', '\255', '\242', '\221', '\054', '\032', '\345', '\242',
+ '\021', '\060', '\032', '\035', '\243', '\221', '\063', '\032',
+ '\125', '\243', '\021', '\067', '\032', '\215', '\243', '\221',
+ '\072', '\032', '\305', '\243', '\021', '\076', '\032', '\375',
+ '\243', '\221', '\001', '\021', '\065', '\020', '\021', '\005',
+ '\021', '\155', '\020', '\221', '\010', '\021', '\245', '\020',
+ '\021', '\014', '\021', '\335', '\020', '\221', '\017', '\021',
+ '\025', '\021', '\021', '\023', '\021', '\115', '\021', '\221',
+ '\026', '\021', '\205', '\021', '\021', '\032', '\021', '\275',
+ '\021', '\221', '\035', '\021', '\351', '\103', '\104', '\010',
+ '\021', '\221', '\105', '\104', '\104', '\022', '\021', '\311',
+ '\104', '\104', '\100', '\021', '\221', '\123', '\104', '\304',
+ '\025', '\021', '\251', '\105', '\104', '\170', '\021', '\221',
+ '\141', '\104', '\104', '\031', '\021', '\211', '\106', '\104',
+ '\260', '\021', '\221', '\157', '\104', '\304', '\034', '\021',
+ '\151', '\107', '\104', '\350', '\021', '\221', '\175', '\104',
+ '\104', '\000', '\066', '\111', '\200', '\115', '\040', '\140',
+ '\223', '\013', '\330', '\304', '\003', '\066', '\051', '\201',
+ '\115', '\130', '\140', '\223', '\031', '\330', '\104', '\007',
+ '\066', '\011', '\202', '\115', '\220', '\140', '\223', '\047',
+ '\330', '\304', '\012', '\066', '\351', '\202', '\115', '\310',
+ '\140', '\223', '\065', '\330', '\104', '\016', '\066', '\311',
+ '\203', '\115', '\000', '\141', '\223', '\103', '\330', '\304',
+ '\021', '\066', '\251', '\204', '\115', '\070', '\141', '\223',
+ '\121', '\330', '\104', '\025', '\066', '\211', '\205', '\115',
+ '\160', '\141', '\223', '\137', '\330', '\304', '\030', '\066',
+ '\151', '\206', '\115', '\250', '\141', '\223', '\155', '\330',
+ '\104', '\034', '\066', '\111', '\207', '\115', '\340', '\141',
+ '\223', '\173', '\330', '\304', '\037', '\066', '\051', '\100',
+ '\107', '\030', '\320', '\221', '\011', '\164', '\104', '\003',
+ '\035', '\011', '\101', '\107', '\120', '\320', '\221', '\027',
+ '\164', '\304', '\006', '\035', '\351', '\101', '\107', '\210',
+ '\320', '\221', '\045', '\164', '\104', '\012', '\035', '\311',
+ '\102', '\107', '\300', '\320', '\221', '\063', '\164', '\304',
+ '\015', '\035', '\251', '\103', '\107', '\370', '\320', '\221',
+ '\101', '\164', '\104', '\021', '\035', '\211', '\104', '\107',
+ '\060', '\321', '\221', '\117', '\164', '\304', '\024', '\035',
+ '\151', '\105', '\107', '\150', '\321', '\221', '\135', '\164',
+ '\104', '\030', '\035', '\111', '\106', '\107', '\240', '\321',
+ '\221', '\153', '\164', '\304', '\033', '\035', '\051', '\107',
+ '\107', '\330', '\321', '\221', '\171', '\164', '\104', '\037',
+ '\035', '\011', '\000', '\151', '\000', '\200', '\200', '\135',
+ '\076', '\140', '\227', '\026', '\330', '\145', '\007', '\166',
+ '\111', '\202', '\135', '\256', '\140', '\227', '\062', '\330',
+ '\145', '\016', '\166', '\011', '\204', '\135', '\036', '\141',
+ '\227', '\116', '\330', '\145', '\025', '\166', '\311', '\205',
+ '\135', '\216', '\141', '\227', '\152', '\330', '\145', '\034',
+ '\166', '\211', '\207', '\135', '\376', '\141', '\227', '\206',
+ '\330', '\145', '\043', '\166', '\111', '\211', '\135', '\156',
+ '\142', '\227', '\242', '\330', '\145', '\052', '\166', '\011',
+ '\213', '\135', '\336', '\142', '\227', '\276', '\330', '\145',
+ '\061', '\166', '\311', '\214', '\135', '\116', '\143', '\227',
+ '\332', '\330', '\145', '\070', '\166', '\211', '\216', '\135',
+ '\276', '\143', '\227', '\366', '\330', '\145', '\077', '\166',
+ '\111', '\000', '\320', '\054', '\000', '\064', '\022', '\000',
+ '\115', '\006', '\100', '\003', '\002', '\320', '\000', '\201',
+ '\001', '\072', '\301', '\300', '\326', '\014', '\362', '\200',
+ '\212', '\132', '\324', '\040', '\004', '\160', '\300', '\007',
+ '\034', '\200', '\021', '\005', '\024', '\300', '\243', '\036',
+ '\005', '\100', '\001', '\016', '\120', '\200', '\002', '\160',
+ '\224', '\000', '\227', '\033', '\100', '\003', '\010', '\100',
+ '\307', '\224', '\032', '\100', '\001', '\057', '\015', '\100',
+ '\000', '\006', '\100', '\107', '\072', '\022', '\100', '\001',
+ '\035', '\301', '\050', '\107', '\243', '\146', '\220', '\004',
+ '\054', '\240', '\001', '\011', '\040', '\000', '\113', '\113',
+ '\132', '\000', '\001', '\234', '\124', '\250', '\004', '\200',
+ '\132', '\102', '\016', '\200', '\324', '\252', '\041', '\025',
+ '\251', '\126', '\303', '\250', '\120', '\077', '\320', '\324',
+ '\017', '\260', '\304', '\252', '\043', '\301', '\252', '\104',
+ '\264', '\252', '\020', '\253', '\102', '\365', '\251', '\102',
+ '\145', '\052', '\130', '\271', '\152', '\020', '\252', '\202',
+ '\365', '\251', '\010', '\040', '\200', '\000', '\010', '\200',
+ '\000', '\251', '\255', '\065', '\255', '\106', '\115', '\210',
+ '\003', '\024', '\100', '\327', '\220', '\160', '\324', '\001',
+ '\021', '\141', '\200', '\000', '\016', '\040', '\200', '\006',
+ '\050', '\044', '\247', '\054', '\171', '\052', '\000', '\072',
+ '\132', '\127', '\205', '\050', '\340', '\003', '\207', '\305',
+ '\114', '\324', '\114', '\112', '\001', '\251', '\005', '\040',
+ '\250', '\002', '\110', '\200', '\110', '\004', '\120', '\324',
+ '\217', '\112', '\113', '\000', '\314', '\122', '\253', '\000',
+ '\066', '\213', '\221', '\265', '\042', '\065', '\042', '\105',
+ '\345', '\053', '\101', '\011', '\140', '\126', '\211', '\200',
+ '\157', '\050', '\017', '\140', '\211', '\001', '\100', '\003',
+ '\127', '\215', '\120', '\226', '\250', '\015', '\101', '\341',
+ '\146', '\367', '\052', '\055', '\311', '\252', '\065', '\265',
+ '\017', '\100', '\200', '\001', '\020', '\220', '\000', '\237',
+ '\024', '\264', '\000', '\017', '\020', '\052', '\000', '\040',
+ '\163', '\000', '\336', '\372', '\304', '\000', '\001', '\070',
+ '\100', '\002', '\172', '\073', '\334', '\264', '\152', '\266',
+ '\266', '\006', '\130', '\356', '\161', '\227', '\353', '\000',
+ '\335', '\032', '\144', '\265', '\322', '\002', '\015', '\166',
+ '\117', '\073', '\130', '\314', '\256', '\065', '\041', '\270',
+ '\025', '\312', '\132', '\061', '\013', '\000', '\312', '\252',
+ '\265', '\274', '\265', '\155', '\100', '\003', '\002', '\060',
+ '\335', '\004', '\074', '\140', '\271', '\000', '\120', '\256',
+ '\162', '\023', '\220', '\222', '\350', '\312', '\224', '\271',
+ '\363', '\135', '\156', '\112', '\210', '\053', '\123', '\334',
+ '\046', '\127', '\246', '\010', '\261', '\057', '\120', '\245',
+ '\266', '\334', '\367', '\302', '\227', '\257', '\263', '\115',
+ '\011', '\002', '\026', '\154', '\134', '\000', '\044', '\240',
+ '\000', '\003', '\030', '\100', '\001', '\114', '\002', '\340',
+ '\376', '\072', '\270', '\242', '\313', '\065', '\211', '\117',
+ '\177', '\012', '\324', '\332', '\146', '\330', '\047', '\363',
+ '\075', '\200', '\114', '\075', '\354', '\323', '\335', '\206',
+ '\170', '\302', '\265', '\135', '\053', '\176', '\147', '\273',
+ '\131', '\007', '\147', '\230', '\271', '\057', '\306', '\156',
+ '\206', '\061', '\354', '\342', '\325', '\302', '\027', '\266',
+ '\055', '\316', '\255', '\132', '\037', '\023', '\337', '\012',
+ '\247', '\045', '\000', '\157', '\065', '\210', '\130', '\303',
+ '\132', '\336', '\135', '\042', '\046', '\265', '\003', '\370',
+ '\256', '\104', '\034', '\220', '\200', '\006', '\140', '\106',
+ '\246', '\041', '\116', '\010', '\162', '\331', '\313', '\313',
+ '\266', '\122', '\127', '\312', '\015', '\030', '\200', '\157',
+ '\025', '\260', '\327', '\026', '\033', '\204', '\311', '\310',
+ '\165', '\000', '\224', '\063', '\214', '\336', '\044', '\323',
+ '\026', '\043', '\110', '\055', '\252', '\114', '\041', '\214',
+ '\142', '\063', '\157', '\026', '\152', '\300', '\205', '\257',
+ '\220', '\311', '\174', '\135', '\351', '\056', '\125', '\277',
+ '\032', '\141', '\162', '\002', '\252', '\073', '\347', '\021',
+ '\177', '\231', '\246', '\051', '\171', '\363', '\146', '\041',
+ '\332', '\323', '\053', '\067', '\253', '\244', '\021', '\161',
+ '\161', '\105', '\023', '\322', '\333', '\350', '\062', '\072',
+ '\001', '\070', '\215', '\110', '\160', '\005', '\220', '\132',
+ '\265', '\232', '\271', '\263', '\054', '\156', '\010', '\220',
+ '\301', '\107', '\336', '\220', '\152', '\353', '\257', '\203',
+ '\155', '\352', '\140', '\035', '\120', '\322', '\235', '\352',
+ '\225', '\257', '\176', '\005', '\100', '\004', '\346', '\352',
+ '\200', '\230', '\040', '\032', '\301', '\122', '\015', '\065',
+ '\000', '\364', '\372', '\122', '\006', '\350', '\126', '\261',
+ '\012', '\151', '\165', '\005', '\046', '\120', '\201', '\125',
+ '\033', '\240', '\000', '\311', '\112', '\210', '\004', '\022',
+ '\320', '\024', '\360', '\212', '\104', '\041', '\251', '\375',
+ '\162', '\004', '\056', '\060', '\201', '\011', '\254', '\072',
+ '\331', '\177', '\305', '\351', '\137', '\111', '\073', '\125',
+ '\151', '\251', '\065', '\131', '\253', '\055', '\150', '\102',
+ '\316', '\073', '\222', '\014', '\213', '\330', '\001', '\013',
+ '\130', '\000', '\135', '\025', '\213', '\135', '\304', '\250',
+ '\265', '\240', '\031', '\205', '\110', '\121', '\273', '\075',
+ '\354', '\203', '\334', '\227', '\001', '\325', '\005', '\160',
+ '\003', '\322', '\312', '\200', '\010', '\013', '\140', '\001',
+ '\360', '\106', '\100', '\154', '\165', '\331', '\220', '\350',
+ '\272', '\027', '\276', '\376', '\066', '\260', '\207', '\005',
+ '\036', '\160', '\200', '\027', '\330', '\340', '\377', '\066',
+ '\011', '\251', '\033', '\100', '\122', '\277', '\332', '\367',
+ '\261', '\340', '\343', '\057', '\217', '\045', '\356', '\137',
+ '\021', '\117', '\374', '\277', '\074', '\106', '\360', '\233',
+ '\343', '\313', '\342', '\224', '\150', '\234', '\266', '\037',
+ '\367', '\270', '\002', '\304', '\255', '\200', '\224', '\000',
+ '\225', '\303', '\046', '\361', '\267', '\235', '\125', '\316',
+ '\134', '\226', '\267', '\167', '\345', '\061', '\146', '\264',
+ '\215', '\243', '\246', '\336', '\160', '\247', '\344', '\305',
+ '\060', '\216', '\071', '\316', '\175', '\262', '\163', '\221',
+ '\042', '\272', '\305', '\311', '\245', '\357', '\210', '\243',
+ '\253', '\334', '\005', '\064', '\146', '\255', '\114', '\166',
+ '\162', '\167', '\223', '\216', '\231', '\233', '\062', '\035',
+ '\000', '\036', '\175', '\072', '\146', '\236', '\276', '\332',
+ '\247', '\177', '\271', '\001', '\046', '\225', '\262', '\114',
+ '\071', '\135', '\320', '\054', '\373', '\126', '\000', '\006',
+ '\360', '\172', '\221', '\303', '\256', '\145', '\221', '\112',
+ '\113', '\354', '\100', '\066', '\163', '\240', '\147', '\272',
+ '\161', '\312', '\252', '\335', '\354', '\157', '\027', '\000',
+ '\003', '\374', '\355', '\023', '\217', '\346', '\267', '\274',
+ '\005', '\265', '\363', '\265', '\127', '\356', '\341', '\272',
+ '\003', '\333', '\316', '\317', '\262', '\263', '\264', '\206',
+ '\073', '\370', '\253', '\057', '\040', '\320', '\004', '\310',
+ '\260', '\324', '\324', '\252', '\370', '\301', '\067', '\036',
+ '\063', '\215', '\147', '\074', '\244', '\317', '\033', '\164',
+ '\241', '\103', '\176', '\362', '\211', '\116', '\310', '\077',
+ '\214', '\205', '\220', '\206', '\200', '\004', '\043', '\324',
+ '\122', '\260', '\203', '\241', '\016', '\200', '\005', '\314',
+ '\032', '\000', '\176', '\225', '\132', '\152', '\041', '\240',
+ '\152', '\000', '\064', '\045', '\047', '\024', '\000', '\000',
+ '\325', '\054', '\000', '\200', '\240', '\110', '\064', '\003',
+ '\000', '\320', '\000', '\000', '\242', '\142', '\065', '\244',
+ '\170', '\000', '\000', '\126', '\135', '\111', '\010', '\000',
+ '\040', '\002', '\000', '\140', '\215', '\004', '\000', '\050',
+ '\001', '\000', '\114', '\000', '\200', '\023', '\000', '\000',
+ '\005', '\000', '\110', '\001', '\000', '\264', '\266', '\002',
+ '\000', '\124', '\245', '\005', '\000', '\160', '\001', '\000',
+ '\136', '\000', '\000', '\030', '\100', '\011', '\000', '\127',
+ '\231', '\001', '\000', '\150', '\000', '\200', '\032', '\000',
+ '\300', '\006', '\000', '\270', '\001', '\000', '\274', '\126',
+ '\044', '\035', '\000', '\140', '\007', '\000', '\340', '\001',
+ '\000', '\172', '\000', '\200', '\254', '\200', '\155', '\046',
+ '\101', '\000', '\200', '\020', '\122', '\344', '\045', '\000',
+ '\154', '\245', '\055', '\050', '\102', '\043', '\111', '\000',
+ '\000', '\112', '\000', '\000', '\135', '\301', '\004', '\277',
+ '\001', '\000', '\135', '\362', '\004', '\002', '\002', '\000',
+ '\121', '\120', '\036', '\340', '\001', '\000', '\216', '\122',
+ '\005', '\000', '\140', '\005', '\000', '\160', '\005', '\000',
+ '\300', '\041', '\270', '\241', '\005', '\000', '\020', '\026',
+ '\134', '\000', '\000', '\135', '\000', '\000', '\136', '\000',
+ '\000', '\137', '\340', '\021', '\000', '\020', '\006', '\000',
+ '\060', '\026', '\303', '\101', '\021', '\145', '\000', '\000',
+ '\146', '\000', '\000', '\234', '\201', '\006', '\000', '\300',
+ '\066', '\152', '\000', '\000', '\153', '\000', '\000', '\366',
+ '\361', '\035', '\156', '\000', '\000', '\157', '\000', '\000',
+ '\213', '\122', '\026', '\147', '\061', '\007', '\000', '\100',
+ '\007', '\000', '\120', '\007', '\000', '\140', '\007', '\000',
+ '\000', '\067', '\170', '\000', '\000', '\171', '\000', '\000',
+ '\172', '\000', '\000', '\173', '\000', '\000', '\174', '\000',
+ '\000', '\153', '\041', '\067', '\177', '\000', '\000', '\377',
+ '\220', '\205', '\132', '\270', '\205', '\134', '\330', '\205',
+ '\136', '\370', '\205', '\140', '\030', '\206', '\140', '\270',
+ '\023', '\201', '\000', '\000', '\202', '\000', '\000', '\203',
+ '\000', '\000', '\204', '\000', '\000', '\164', '\143', '\010',
+ '\000', '\160', '\010', '\000', '\360', '\020', '\211', '\000',
+ '\000', '\212', '\000', '\000', '\213', '\000', '\000', '\166',
+ '\323', '\010', '\000', '\340', '\010', '\000', '\360', '\010',
+ '\067', '\001', '\000', '\221', '\000', '\000', '\222', '\000',
+ '\000', '\170', '\103', '\011', '\000', '\060', '\027', '\226',
+ '\000', '\000', '\227', '\000', '\000', '\230', '\000', '\000',
+ '\231', '\000', '\000', '\172', '\263', '\011', '\000', '\300',
+ '\011', '\000', '\320', '\011', '\000', '\340', '\011', '\000',
+ '\360', '\011', '\000', '\000', '\012', '\000', '\300', '\067',
+ '\167', '\061', '\012', '\000', '\100', '\012', '\000', '\120',
+ '\012', '\000', '\140', '\012', '\000', '\160', '\012', '\000',
+ '\340', '\067', '\251', '\000', '\000', '\171', '\261', '\012',
+ '\000', '\260', '\027', '\255', '\000', '\000', '\256', '\000',
+ '\000', '\200', '\003', '\013', '\000', '\020', '\013', '\000',
+ '\040', '\013', '\000', '\060', '\013', '\000', '\100', '\013',
+ '\000', '\120', '\013', '\000', '\040', '\070', '\267', '\100',
+ '\022', '\000', '\220', '\013', '\000', '\360', '\027', '\273',
+ '\000', '\000', '\274', '\000', '\000', '\204', '\343', '\013',
+ '\000', '\360', '\013', '\000', '\000', '\014', '\000', '\020',
+ '\014', '\000', '\040', '\014', '\000', '\060', '\014', '\000',
+ '\140', '\070', '\305', '\000', '\000', '\306', '\000', '\000',
+ '\307', '\000', '\000', '\310', '\000', '\000', '\311', '\000',
+ '\000', '\312', '\000', '\000', '\201', '\301', '\014', '\000',
+ '\320', '\014', '\000', '\340', '\014', '\000', '\360', '\014',
+ '\000', '\000', '\015', '\000', '\020', '\015', '\000', '\240',
+ '\070', '\203', '\101', '\015', '\000', '\120', '\015', '\000',
+ '\140', '\015', '\000', '\160', '\015', '\000', '\200', '\015',
+ '\000', '\300', '\070', '\332', '\000', '\000', '\333', '\000',
+ '\000', '\334', '\000', '\000', '\335', '\000', '\000', '\336',
+ '\000', '\000', '\337', '\300', '\022', '\216', '\003', '\101',
+ '\006', '\341', '\220', '\262', '\370', '\100', '\022', '\371',
+ '\220', '\023', '\031', '\221', '\024', '\171', '\221', '\026',
+ '\231', '\221', '\020', '\271', '\221', '\025', '\311', '\221',
+ '\030', '\351', '\221', '\032', '\331', '\221', '\042', '\371',
+ '\221', '\043', '\031', '\222', '\044', '\171', '\222', '\046',
+ '\231', '\222', '\040', '\271', '\222', '\045', '\311', '\222',
+ '\050', '\351', '\222', '\052', '\331', '\222', '\062', '\371',
+ '\222', '\063', '\031', '\223', '\064', '\171', '\223', '\066',
+ '\231', '\223', '\060', '\271', '\223', '\065', '\311', '\223',
+ '\070', '\351', '\223', '\072', '\331', '\223', '\102', '\371',
+ '\223', '\103', '\031', '\224', '\104', '\171', '\224', '\106',
+ '\231', '\224', '\100', '\271', '\224', '\105', '\311', '\224',
+ '\110', '\351', '\224', '\112', '\331', '\224', '\122', '\371',
+ '\224', '\123', '\031', '\225', '\124', '\171', '\225', '\126',
+ '\231', '\225', '\012', '\341', '\070', '\012', '\141', '\144',
+ '\270', '\006', '\155', '\261', '\147', '\020', '\270', '\147',
+ '\020', '\277', '\147', '\020', '\130', '\143', '\020', '\320',
+ '\147', '\020', '\330', '\147', '\020', '\175', '\221', '\176',
+ '\011', '\041', '\177', '\006', '\221', '\177', '\271', '\001',
+ '\027', '\011', '\001', '\005', '\011', '\101', '\201', '\006',
+ '\301', '\201', '\006', '\121', '\202', '\023', '\221', '\020',
+ '\154', '\143', '\020', '\073', '\150', '\020', '\102', '\150',
+ '\020', '\113', '\250', '\026', '\011', '\161', '\206', '\006',
+ '\001', '\207', '\006', '\141', '\067', '\006', '\021', '\210',
+ '\006', '\221', '\210', '\006', '\041', '\211', '\006', '\301',
+ '\211', '\006', '\101', '\212', '\006', '\201', '\212', '\006',
+ '\261', '\212', '\006', '\341', '\212', '\006', '\021', '\213',
+ '\006', '\001', '\070', '\006', '\201', '\213', '\006', '\301',
+ '\213', '\006', '\001', '\214', '\006', '\061', '\214', '\006',
+ '\141', '\214', '\006', '\221', '\214', '\006', '\101', '\070',
+ '\006', '\001', '\215', '\006', '\101', '\215', '\006', '\201',
+ '\215', '\006', '\261', '\215', '\006', '\361', '\215', '\006',
+ '\061', '\216', '\006', '\201', '\070', '\351', '\230', '\020',
+ '\356', '\150', '\020', '\362', '\150', '\020', '\203', '\141',
+ '\020', '\370', '\150', '\020', '\374', '\150', '\020', '\214',
+ '\143', '\020', '\003', '\151', '\020', '\007', '\151', '\020',
+ '\013', '\151', '\020', '\341', '\220', '\020', '\343', '\220',
+ '\020', '\345', '\220', '\020', '\220', '\143', '\020', '\351',
+ '\220', '\020', '\353', '\220', '\020', '\355', '\220', '\020',
+ '\357', '\220', '\020', '\361', '\220', '\020', '\363', '\060',
+ '\071', '\011', '\161', '\017', '\011', '\241', '\030', '\006',
+ '\261', '\017', '\011', '\321', '\017', '\232', '\047', '\024',
+ '\032', '\161', '\071', '\315', '\242', '\021', '\042', '\326',
+ '\123', '\032', '\261', '\000', '\032', '\261', '\136', '\024',
+ '\245', '\071', '\032', '\061', '\001', '\032', '\121', '\001',
+ '\032', '\161', '\001', '\032', '\221', '\001', '\032', '\261',
+ '\001', '\032', '\321', '\001', '\236', '\243', '\021', '\041',
+ '\240', '\021', '\043', '\240', '\021', '\045', '\240', '\021',
+ '\047', '\240', '\021', '\051', '\240', '\021', '\053', '\040',
+ '\072', '\032', '\361', '\002', '\032', '\021', '\003', '\221',
+ '\241', '\021', '\065', '\240', '\021', '\067', '\240', '\021',
+ '\071', '\140', '\072', '\032', '\321', '\003', '\032', '\361',
+ '\003', '\032', '\021', '\004', '\032', '\061', '\004', '\032',
+ '\121', '\004', '\032', '\161', '\004', '\252', '\243', '\021',
+ '\113', '\240', '\021', '\115', '\240', '\021', '\117', '\240',
+ '\021', '\121', '\240', '\021', '\123', '\240', '\021', '\125',
+ '\340', '\072', '\032', '\221', '\005', '\032', '\261', '\005',
+ '\032', '\321', '\005', '\032', '\361', '\005', '\032', '\021',
+ '\006', '\032', '\161', '\006', '\264', '\243', '\021', '\161',
+ '\240', '\021', '\232', '\141', '\020', '\173', '\240', '\021',
+ '\200', '\240', '\021', '\205', '\240', '\021', '\242', '\141',
+ '\020', '\276', '\143', '\020', '\224', '\240', '\021', '\231',
+ '\240', '\021', '\236', '\240', '\021', '\243', '\240', '\021',
+ '\250', '\240', '\021', '\255', '\160', '\074', '\032', '\161',
+ '\013', '\032', '\301', '\013', '\032', '\021', '\014', '\032',
+ '\141', '\014', '\032', '\261', '\014', '\032', '\001', '\015',
+ '\321', '\243', '\021', '\332', '\240', '\021', '\337', '\240',
+ '\021', '\344', '\240', '\021', '\351', '\240', '\021', '\356',
+ '\240', '\021', '\363', '\260', '\075', '\032', '\321', '\017',
+ '\256', '\025', '\021', '\174', '\365', '\145', '\021', '\061',
+ '\001', '\021', '\201', '\001', '\021', '\321', '\001', '\347',
+ '\023', '\021', '\047', '\020', '\021', '\054', '\020', '\021',
+ '\061', '\020', '\021', '\070', '\020', '\021', '\075', '\020',
+ '\021', '\102', '\020', '\021', '\107', '\060', '\077', '\021',
+ '\021', '\005', '\021', '\141', '\005', '\021', '\261', '\005',
+ '\021', '\001', '\006', '\021', '\121', '\006', '\021', '\301',
+ '\006', '\021', '\021', '\007', '\377', '\023', '\021', '\173',
+ '\360', '\022', '\021', '\121', '\010', '\021', '\241', '\010',
+ '\021', '\021', '\011', '\021', '\141', '\011', '\021', '\261',
+ '\011', '\013', '\024', '\021', '\245', '\020', '\021', '\252',
+ '\020', '\021', '\257', '\020', '\021', '\267', '\060', '\101',
+ '\021', '\021', '\014', '\021', '\141', '\014', '\021', '\261',
+ '\014', '\021', '\001', '\015', '\021', '\121', '\015', '\021',
+ '\241', '\015', '\021', '\041', '\016', '\021', '\161', '\016',
+ '\021', '\301', '\016', '\021', '\021', '\017', '\021', '\141',
+ '\017', '\045', '\224', '\150', '\161', '\144', '\023', '\012',
+ '\140', '\023', '\017', '\140', '\023', '\024', '\140', '\023',
+ '\031', '\360', '\102', '\066', '\061', '\002', '\066', '\201',
+ '\002', '\066', '\321', '\002', '\066', '\041', '\003', '\066',
+ '\161', '\003', '\066', '\301', '\003', '\071', '\144', '\023',
+ '\106', '\140', '\023', '\113', '\140', '\023', '\120', '\140',
+ '\023', '\125', '\140', '\023', '\103', '\000', '\003', '\370',
+ '\232', '\042', '\370', '\032', '\045', '\367', '\012', '\003',
+ '\127', '\321', '\257', '\342', '\327', '\257', '\344', '\327',
+ '\257', '\346', '\327', '\257', '\350', '\327', '\257', '\352',
+ '\167', '\257', '\061', '\340', '\175', '\012', '\313', '\257',
+ '\060', '\020', '\003', '\377', '\372', '\260', '\001', '\373',
+ '\260', '\003', '\373', '\260', '\005', '\373', '\260', '\007',
+ '\373', '\260', '\011', '\353', '\257', '\014', '\353', '\257',
+ '\016', '\053', '\003', '\021', '\053', '\003', '\023', '\053',
+ '\003', '\025', '\053', '\003', '\027', '\053', '\003', '\031',
+ '\053', '\003', '\033', '\073', '\003', '\035', '\073', '\003',
+ '\016', '\073', '\003', '\021', '\073', '\003', '\023', '\073',
+ '\003', '\025', '\073', '\003', '\027', '\073', '\003', '\031',
+ '\073', '\003', '\033', '\113', '\003', '\336', '\067', '\174',
+ '\305', '\167', '\174', '\311', '\267', '\174', '\315', '\367',
+ '\174', '\321', '\067', '\175', '\000', '\120', '\175', '\327',
+ '\227', '\175', '\333', '\327', '\175', '\337', '\027', '\176',
+ '\343', '\127', '\176', '\347', '\347', '\226', '\354', '\007',
+ '\000', '\356', '\007', '\177', '\362', '\107', '\177', '\366',
+ '\007', '\000', '\370', '\247', '\177', '\374', '\107', '\004',
+ '\376', '\107', '\034', '\000', '\020', '\200', '\000', '\060',
+ '\200', '\005', '\170', '\200', '\011', '\270', '\200', '\015',
+ '\370', '\200', '\346', '\061', '\005', '\022', '\050', '\045',
+ '\025', '\170', '\201', '\031', '\010', '\000', '\033', '\330',
+ '\201', '\000', '\360', '\201', '\041', '\070', '\202', '\045',
+ '\010', '\006', '\047', '\230', '\202', '\000', '\260', '\202',
+ '\000', '\320', '\202', '\057', '\030', '\203', '\063', '\010',
+ '\000', '\065', '\170', '\203', '\071', '\010', '\000', '\073',
+ '\330', '\203', '\077', '\010', '\000', '\101', '\070', '\204',
+ '\105', '\170', '\204', '\111', '\010', '\000', '\113', '\330',
+ '\204', '\117', '\030', '\205', '\123', '\130', '\205', '\372',
+ '\307', '\006', '\141', '\340', '\006', '\067', '\070', '\004',
+ '\061', '\140', '\003', '\014', '\373', '\271', '\374', '\372',
+ '\271', '\377', '\372', '\271', '\001', '\373', '\271', '\003',
+ '\373', '\271', '\005', '\373', '\271', '\007', '\373', '\271',
+ '\011', '\373', '\271', '\136', '\343', '\271', '\066', '\120',
+ '\044', '\236', '\173', '\003', '\241', '\173', '\003', '\243',
+ '\173', '\003', '\245', '\173', '\003', '\247', '\173', '\003',
+ '\251', '\173', '\003', '\253', '\173', '\003', '\255', '\173',
+ '\003', '\257', '\173', '\003', '\261', '\033', '\003', '\067',
+ '\100', '\273', '\061', '\200', '\003', '\241', '\213', '\003',
+ '\243', '\213', '\003', '\245', '\213', '\003', '\247', '\213',
+ '\003', '\251', '\073', '\044', '\051', '\262', '\274', '\255',
+ '\213', '\003', '\257', '\053', '\044', '\327', '\213', '\003',
+ '\312', '\233', '\003', '\241', '\173', '\047', '\367', '\161',
+ '\006', '\162', '\020', '\006', '\166', '\320', '\202', '\236',
+ '\233', '\003', '\247', '\233', '\003', '\251', '\233', '\003',
+ '\253', '\233', '\003', '\255', '\233', '\003', '\257', '\233',
+ '\003', '\307', '\153', '\047', '\376', '\107', '\276', '\346',
+ '\213', '\276', '\062', '\360', '\260', '\051', '\262', '\277',
+ '\377', '\272', '\277', '\001', '\273', '\277', '\003', '\273',
+ '\277', '\005', '\273', '\277', '\007', '\273', '\277', '\011',
+ '\273', '\277', '\261', '\273', '\277', '\105', '\362', '\004',
+ '\370', '\173', '\276', '\375', '\033', '\003', '\374', '\052',
+ '\003', '\020', '\033', '\301', '\001', '\034', '\003', '\003',
+ '\034', '\003', '\005', '\374', '\271', '\122', '\362', '\300',
+ '\372', '\273', '\274', '\021', '\114', '\273', '\040', '\313',
+ '\260', '\040', '\073', '\301', '\040', '\333', '\277', '\042',
+ '\173', '\202', '\055', '\340', '\301', '\050', '\134', '\300',
+ '\050', '\213', '\302', '\011', '\054', '\003', '\013', '\054',
+ '\003', '\042', '\314', '\262', '\375', '\353', '\262', '\177',
+ '\273', '\302', '\345', '\013', '\301', '\103', '\040', '\262',
+ '\001', '\114', '\263', '\067', '\134', '\300', '\070', '\173',
+ '\303', '\011', '\074', '\003', '\013', '\074', '\003', '\042',
+ '\314', '\263', '\375', '\113', '\003', '\023', '\114', '\003',
+ '\377', '\113', '\003', '\001', '\114', '\003', '\003', '\114',
+ '\003', '\005', '\114', '\003', '\007', '\114', '\003', '\011',
+ '\114', '\003', '\013', '\114', '\003', '\042', '\274', '\052',
+ '\375', '\133', '\003', '\023', '\134', '\003', '\377', '\133',
+ '\003', '\001', '\134', '\003', '\003', '\134', '\003', '\346',
+ '\147', '\055', '\314', '\222', '\054', '\313', '\042', '\021',
+ '\316', '\062', '\170', '\321', '\062', '\055', '\160', '\234',
+ '\020',
+
+};
+
+static const char file_5x8[] = {
+ '\037', '\235', '\214', '\001', '\314', '\214', '\201', '\223',
+ '\000', '\200', '\301', '\000', '\006', '\023', '\032', '\144',
+ '\042', '\300', '\040', '\246', '\204', '\015', '\023', '\042',
+ '\004', '\100', '\046', '\041', '\271', '\210', '\004', '\024',
+ '\116', '\104', '\024', '\021', '\311', '\000', '\203', '\010',
+ '\024', '\046', '\304', '\140', '\300', '\040', '\264', '\002',
+ '\006', '\041', '\150', '\064', '\310', '\321', '\040', '\272',
+ '\005', '\006', '\101', '\210', '\114', '\071', '\021', '\216',
+ '\003', '\203', '\100', '\146', '\002', '\100', '\020', '\021',
+ '\320', '\003', '\203', '\200', '\164', '\322', '\371', '\010',
+ '\000', '\121', '\004', '\211', '\110', '\051', '\046', '\344',
+ '\107', '\141', '\146', '\005', '\235', '\001', '\044', '\044',
+ '\234', '\040', '\161', '\103', '\102', '\231', '\007', '\131',
+ '\044', '\224', '\041', '\321', '\107', '\302', '\042', '\022',
+ '\227', '\044', '\154', '\042', '\161', '\113', '\102', '\061',
+ '\022', '\343', '\044', '\224', '\243', '\060', '\244', '\301',
+ '\076', '\012', '\241', '\044', '\104', '\244', '\120', '\254',
+ '\301', '\112', '\165', '\023', '\212', '\222', '\250', '\052',
+ '\041', '\053', '\205', '\134', '\015', '\352', '\222', '\270',
+ '\054', '\341', '\065', '\211', '\350', '\022', '\262', '\223',
+ '\150', '\157', '\344', '\304', '\000', '\035', '\046', '\152',
+ '\231', '\010', '\100', '\101', '\302', '\060', '\224', '\317',
+ '\044', '\144', '\103', '\371', '\100', '\302', '\072', '\224',
+ '\121', '\212', '\004', '\064', '\321', '\310', '\023', '\047',
+ '\124', '\234', '\004', '\151', '\122', '\344', '\213', '\224',
+ '\042', '\107', '\222', '\114', '\241', '\042', '\045', '\213',
+ '\101', '\323', '\125', '\234', '\020', '\251', '\015', '\240',
+ '\111', '\232', '\071', '\143', '\000', '\030', '\131', '\235',
+ '\204', '\111', '\226', '\057', '\252', '\131', '\013', '\117',
+ '\203', '\247', '\114', '\305', '\053', '\105', '\222', '\034',
+ '\101', '\102', '\005', '\371', '\152', '\260', '\115', '\234',
+ '\247', '\251', '\323', '\006', '\300', '\024', '\046', '\101',
+ '\120', '\003', '\220', '\342', '\275', '\010', '\225', '\053',
+ '\111', '\210', '\120', '\101', '\142', '\135', '\271', '\223',
+ '\067', '\162', '\332', '\204', '\141', '\003', '\040', '\010',
+ '\021', '\042', '\137', '\146', '\147', '\141', '\322', '\072',
+ '\071', '\130', '\000', '\120', '\044', '\201', '\105', '\021',
+ '\114', '\344', '\227', '\204', '\026', '\140', '\101', '\361',
+ '\104', '\022', '\250', '\031', '\210', '\340', '\170', '\105',
+ '\114', '\361', '\004', '\023', '\125', '\120', '\221', '\304',
+ '\151', '\137', '\140', '\001', '\241', '\204', '\024', '\132',
+ '\210', '\241', '\155', '\123', '\100', '\021', '\304', '\020',
+ '\014', '\036', '\001', '\300', '\020', '\365', '\131', '\121',
+ '\204', '\024', '\101', '\034', '\321', '\032', '\172', '\352',
+ '\041', '\161', '\042', '\022', '\101', '\110', '\061', '\205',
+ '\171', '\256', '\301', '\046', '\033', '\155', '\266', '\311',
+ '\366', '\204', '\015', '\064', '\330', '\340', '\102', '\014',
+ '\071', '\344', '\020', '\303', '\214', '\065', '\336', '\130',
+ '\135', '\021', '\116', '\014', '\361', '\004', '\021', '\045',
+ '\002', '\220', '\204', '\024', '\126', '\234', '\370', '\004',
+ '\024', '\131', '\110', '\041', '\035', '\165', '\047', '\276',
+ '\001', '\107', '\036', '\162', '\244', '\161', '\006', '\032',
+ '\164', '\200', '\100', '\044', '\016', '\071', '\200', '\040',
+ '\106', '\036', '\040', '\014', '\361', '\306', '\031', '\156',
+ '\244', '\101', '\107', '\032', '\157', '\270', '\321', '\046',
+ '\174', '\160', '\270', '\040', '\334', '\151', '\124', '\000',
+ '\320', '\202', '\157', '\300', '\265', '\140', '\004', '\163',
+ '\316', '\375', '\251', '\035', '\167', '\055', '\110', '\321',
+ '\302', '\173', '\361', '\315', '\327', '\102', '\013', '\070',
+ '\100', '\012', '\103', '\013', '\067', '\324', '\100', '\251',
+ '\245', '\103', '\264', '\120', '\303', '\244', '\076', '\002',
+ '\051', '\044', '\221', '\106', '\266', '\060', '\145', '\225',
+ '\320', '\155', '\331', '\347', '\153', '\034', '\126', '\170',
+ '\241', '\023', '\000', '\140', '\361', '\005', '\022', '\321',
+ '\115', '\327', '\147', '\024', '\125', '\330', '\367', '\005',
+ '\214', '\353', '\035', '\164', '\120', '\000', '\274', '\362',
+ '\152', '\220', '\147', '\272', '\352', '\004', '\000', '\112',
+ '\050', '\171', '\106', '\231', '\101', '\304', '\002', '\140',
+ '\254', '\116', '\242', '\001', '\260', '\317', '\077', '\006',
+ '\065', '\224', '\354', '\262', '\302', '\126', '\153', '\355',
+ '\112', '\000', '\004', '\005', '\110', '\041', '\205', '\034',
+ '\022', '\310', '\266', '\335', '\176', '\313', '\255', '\267',
+ '\340', '\222', '\073', '\256', '\270', '\341', '\226', '\213',
+ '\256', '\271', '\351', '\236', '\253', '\356', '\273', '\356',
+ '\306', '\333', '\356', '\274', '\354', '\326', '\273', '\356',
+ '\275', '\360', '\322', '\213', '\257', '\274', '\366', '\346',
+ '\333', '\057', '\277', '\373', '\352', '\353', '\157', '\300',
+ '\377', '\012', '\014', '\360', '\300', '\010', '\037', '\254',
+ '\260', '\301', '\014', '\027', '\354', '\060', '\301', '\020',
+ '\047', '\334', '\160', '\304', '\013', '\077', '\054', '\261',
+ '\305', '\025', '\123', '\074', '\361', '\305', '\032', '\143',
+ '\274', '\161', '\306', '\034', '\207', '\014', '\362', '\310',
+ '\037', '\227', '\354', '\261', '\275', '\063', '\005', '\065',
+ '\223', '\133', '\000', '\250', '\144', '\020', '\006', '\127',
+ '\045', '\204', '\102', '\102', '\060', '\044', '\204', '\103',
+ '\102', '\071', '\031', '\044', '\243', '\101', '\162', '\031',
+ '\244', '\241', '\101', '\140', '\044', '\204', '\106', '\102',
+ '\160', '\044', '\204', '\107', '\102', '\052', '\027', '\225',
+ '\020', '\044', '\011', '\075', '\144', '\020', '\050', '\011',
+ '\241', '\222', '\020', '\054', '\011', '\341', '\222', '\020',
+ '\060', '\011', '\041', '\223', '\020', '\064', '\011', '\141',
+ '\223', '\020', '\070', '\011', '\045', '\146', '\020', '\074',
+ '\011', '\341', '\203', '\055', '\002', '\023', '\101', '\060',
+ '\021', '\006', '\023', '\201', '\060', '\021', '\012', '\023',
+ '\301', '\060', '\021', '\016', '\023', '\001', '\061', '\021',
+ '\022', '\023', '\101', '\061', '\021', '\026', '\023', '\201',
+ '\061', '\021', '\032', '\065', '\115', '\204', '\307', '\104',
+ '\244', '\261', '\064', '\021', '\044', '\023', '\141', '\062',
+ '\021', '\050', '\023', '\241', '\062', '\021', '\054', '\023',
+ '\341', '\062', '\021', '\060', '\023', '\041', '\063', '\021',
+ '\064', '\023', '\141', '\063', '\021', '\070', '\023', '\241',
+ '\063', '\021', '\074', '\023', '\341', '\103', '\131', '\104',
+ '\074', '\245', '\024', '\021', '\006', '\021', '\201', '\020',
+ '\021', '\012', '\021', '\301', '\020', '\021', '\016', '\021',
+ '\001', '\321', '\121', '\104', '\120', '\104', '\204', '\105',
+ '\104', '\140', '\104', '\204', '\106', '\104', '\160', '\104',
+ '\204', '\107', '\117', '\021', '\265', '\004', '\000', '\044',
+ '\021', '\141', '\022', '\021', '\050', '\021', '\241', '\022',
+ '\021', '\054', '\021', '\341', '\022', '\021', '\060', '\021',
+ '\041', '\023', '\021', '\064', '\021', '\141', '\023', '\021',
+ '\070', '\021', '\241', '\023', '\021', '\074', '\021', '\341',
+ '\023', '\021', '\000', '\104', '\041', '\100', '\024', '\004',
+ '\104', '\141', '\100', '\024', '\010', '\104', '\241', '\100',
+ '\024', '\014', '\104', '\341', '\100', '\024', '\020', '\104',
+ '\171', '\304', '\063', '\121', '\130', '\020', '\005', '\006',
+ '\121', '\150', '\020', '\005', '\007', '\121', '\170', '\020',
+ '\005', '\010', '\121', '\210', '\040', '\012', '\044', '\210',
+ '\202', '\011', '\242', '\200', '\202', '\050', '\250', '\040',
+ '\012', '\054', '\210', '\202', '\013', '\242', '\000', '\203',
+ '\050', '\310', '\040', '\012', '\064', '\210', '\202', '\015',
+ '\242', '\200', '\203', '\050', '\350', '\040', '\012', '\074',
+ '\210', '\202', '\017', '\242', '\000', '\040', '\043', '\040',
+ '\111', '\210', '\313', '\000', '\200', '\225', '\152', '\021',
+ '\300', '\001', '\037', '\160', '\000', '\010', '\001', '\100',
+ '\001', '\005', '\264', '\360', '\205', '\012', '\120', '\200',
+ '\003', '\142', '\310', '\001', '\004', '\040', '\340', '\000',
+ '\001', '\030', '\100', '\007', '\012', '\300', '\000', '\002',
+ '\020', '\300', '\000', '\001', '\050', '\011', '\003', '\050',
+ '\060', '\304', '\136', '\035', '\200', '\003', '\004', '\350',
+ '\341', '\007', '\025', '\260', '\102', '\203', '\234', '\060',
+ '\043', '\067', '\001', '\100', '\002', '\026', '\320', '\200',
+ '\004', '\370', '\220', '\000', '\034', '\050', '\200', '\026',
+ '\005', '\120', '\103', '\033', '\136', '\021', '\130', '\042',
+ '\071', '\300', '\025', '\127', '\210', '\304', '\061', '\372',
+ '\220', '\003', '\012', '\271', '\342', '\007', '\306', '\010',
+ '\200', '\017', '\010', '\313', '\215', '\072', '\201', '\343',
+ '\114', '\344', '\050', '\022', '\070', '\136', '\261', '\214',
+ '\146', '\024', '\243', '\031', '\011', '\100', '\307', '\204',
+ '\254', '\161', '\217', '\146', '\334', '\011', '\001', '\004',
+ '\100', '\000', '\004', '\104', '\221', '\220', '\010', '\030',
+ '\144', '\024', '\077', '\020', '\303', '\030', '\046', '\004',
+ '\001', '\153', '\374', '\300', '\367', '\030', '\040', '\201',
+ '\003', '\010', '\100', '\002', '\015', '\110', '\343', '\265',
+ '\234', '\170', '\305', '\017', '\032', '\244', '\221', '\012',
+ '\211', '\041', '\043', '\031', '\151', '\231', '\023', '\026',
+ '\300', '\001', '\024', '\120', '\141', '\264', '\230', '\250',
+ '\000', '\267', '\020', '\040', '\206', '\257', '\164', '\241',
+ '\101', '\172', '\370', '\075', '\220', '\134', '\221', '\145',
+ '\204', '\364', '\341', '\367', '\044', '\300', '\000', '\017',
+ '\120', '\062', '\041', '\076', '\374', '\343', '\114', '\150',
+ '\051', '\022', '\017', '\350', '\344', '\211', '\051', '\201',
+ '\100', '\042', '\005', '\200', '\221', '\106', '\062', '\321',
+ '\211', '\006', '\270', '\142', '\024', '\051', '\011', '\001',
+ '\006', '\010', '\300', '\230', '\000', '\240', '\044', '\002',
+ '\040', '\300', '\113', '\220', '\060', '\100', '\001', '\036',
+ '\260', '\241', '\101', '\074', '\040', '\000', '\007', '\160',
+ '\223', '\001', '\263', '\024', '\200', '\002', '\054', '\320',
+ '\115', '\000', '\170', '\100', '\231', '\211', '\004', '\041',
+ '\045', '\051', '\331', '\116', '\112', '\152', '\200', '\002',
+ '\325', '\234', '\045', '\072', '\031', '\200', '\116', '\175',
+ '\146', '\163', '\220', '\266', '\144', '\146', '\041', '\023',
+ '\162', '\223', '\050', '\106', '\253', '\220', '\313', '\164',
+ '\142', '\053', '\063', '\222', '\021', '\112', '\146', '\240',
+ '\002', '\025', '\110', '\200', '\000', '\366', '\051', '\001',
+ '\011', '\170', '\240', '\242', '\006', '\161', '\200', '\004',
+ '\064', '\272', '\321', '\131', '\112', '\200', '\231', '\355',
+ '\344', '\150', '\105', '\243', '\110', '\116', '\007', '\060',
+ '\023', '\233', '\045', '\145', '\146', '\104', '\050', '\051',
+ '\000', '\015', '\264', '\263', '\242', '\027', '\305', '\050',
+ '\000', '\124', '\050', '\115', '\203', '\160', '\000', '\002',
+ '\070', '\175', '\251', '\002', '\014', '\020', '\103', '\251',
+ '\000', '\100', '\245', '\314', '\214', '\242', '\105', '\143',
+ '\352', '\123', '\011', '\130', '\300', '\003', '\032', '\160',
+ '\251', '\107', '\053', '\032', '\322', '\221', '\062', '\163',
+ '\251', '\026', '\320', '\000', '\003', '\124', '\302', '\121',
+ '\007', '\050', '\065', '\233', '\022', '\050', '\144', '\073',
+ '\377', '\330', '\111', '\000', '\060', '\265', '\242', '\375',
+ '\374', '\052', '\077', '\015', '\302', '\124', '\017', '\134',
+ '\224', '\254', '\274', '\244', '\247', '\101', '\042', '\020',
+ '\001', '\046', '\372', '\160', '\234', '\312', '\034', '\044',
+ '\066', '\115', '\252', '\322', '\103', '\042', '\022', '\247',
+ '\031', '\265', '\241', '\015', '\243', '\030', '\313', '\153',
+ '\031', '\323', '\000', '\204', '\324', '\011', '\005', '\222',
+ '\332', '\224', '\237', '\226', '\163', '\244', '\012', '\261',
+ '\346', '\104', '\223', '\071', '\330', '\173', '\046', '\226',
+ '\234', '\375', '\104', '\000', '\005', '\236', '\330', '\104',
+ '\112', '\336', '\024', '\235', '\101', '\145', '\252', '\023',
+ '\001', '\020', '\315', '\023', '\206', '\120', '\257', '\317',
+ '\004', '\051', '\107', '\015', '\322', '\131', '\037', '\032',
+ '\264', '\062', '\020', '\075', '\012', '\101', '\065', '\233',
+ '\020', '\172', '\366', '\063', '\243', '\033', '\175', '\252',
+ '\115', '\045', '\160', '\323', '\021', '\256', '\123', '\266',
+ '\031', '\065', '\200', '\041', '\071', '\251', '\102', '\012',
+ '\260', '\314', '\253', '\025', '\105', '\143', '\102', '\032',
+ '\331', '\304', '\010', '\100', '\364', '\264', '\151', '\365',
+ '\051', '\132', '\071', '\320', '\116', '\167', '\046', '\322',
+ '\230', '\030', '\050', '\244', '\156', '\011', '\000', '\263',
+ '\017', '\006', '\162', '\272', '\321', '\105', '\100', '\111',
+ '\130', '\150', '\231', '\115', '\002', '\200', '\160', '\331',
+ '\332', '\026', '\040', '\306', '\313', '\055', '\103', '\374',
+ '\041', '\020', '\345', '\015', '\004', '\172', '\115', '\246',
+ '\136', '\102', '\024', '\302', '\020', '\175', '\010', '\204',
+ '\173', '\315', '\213', '\260', '\101', '\164', '\253', '\017',
+ '\200', '\260', '\057', '\041', '\002', '\041', '\010', '\156',
+ '\355', '\267', '\277', '\367', '\315', '\227', '\041', '\366',
+ '\000', '\256', '\102', '\360', '\001', '\134', '\204', '\300',
+ '\057', '\267', '\006', '\341', '\007', '\160', '\011', '\342',
+ '\017', '\000', '\046', '\227', '\175', '\353', '\245', '\340',
+ '\102', '\374', '\167', '\302', '\355', '\175', '\057', '\040',
+ '\344', '\253', '\141', '\160', '\321', '\267', '\274', '\177',
+ '\360', '\060', '\040', '\004', '\241', '\137', '\374', '\212',
+ '\167', '\304', '\366', '\065', '\304', '\206', '\347', '\133',
+ '\341', '\103', '\220', '\267', '\133', '\053', '\176', '\357',
+ '\171', '\307', '\025', '\143', '\370', '\012', '\142', '\276',
+ '\347', '\115', '\361', '\214', '\145', '\354', '\341', '\363',
+ '\272', '\167', '\020', '\033', '\136', '\260', '\037', '\070',
+ '\014', '\344', '\365', '\252', '\230', '\303', '\107', '\236',
+ '\157', '\220', '\065', '\154', '\344', '\045', '\037', '\271',
+ '\274', '\116', '\216', '\162', '\223', '\233', '\174', '\143',
+ '\031', '\043', '\271', '\306', '\061', '\056', '\304', '\220',
+ '\225', '\174', '\145', '\165', '\115', '\031', '\312', '\137',
+ '\146', '\062', '\230', '\307', '\054', '\146', '\046', '\163',
+ '\231', '\314', '\111', '\056', '\363', '\223', '\325', '\054',
+ '\345', '\364', '\206', '\131', '\305', '\042', '\176', '\163',
+ '\233', '\073', '\214', '\146', '\054', '\117', '\231', '\313',
+ '\054', '\136', '\357', '\206', '\003', '\221', '\342', '\370',
+ '\372', '\127', '\312', '\356', '\045', '\304', '\234', '\005',
+ '\035', '\346', '\375', '\336', '\331', '\314', '\357', '\125',
+ '\057', '\230', '\225', '\214', '\340', '\045', '\023', '\372',
+ '\317', '\353', '\065', '\264', '\177', '\025', '\155', '\341',
+ '\030', '\077', '\272', '\314', '\204', '\016', '\364', '\213',
+ '\057', '\315', '\151', '\112', '\137', '\332', '\305', '\044',
+ '\056', '\263', '\213', '\215', '\174', '\340', '\023', '\013',
+ '\353', '\017', '\325', '\102', '\110', '\103', '\076', '\222',
+ '\021', '\224', '\224', '\304', '\063', '\041', '\051', '\210',
+ '\145', '\140', '\202', '\316', '\114', '\336', '\344', '\047',
+ '\052', '\071', '\212', '\124', '\250', '\322', '\224', '\247',
+ '\130', '\000', '\000', '\027', '\000', '\000', '\314', '\062',
+ '\000', '\000', '\015', '\000', '\300', '\052', '\150', '\354',
+ '\200', '\073', '\333', '\110', '\102', '\000', '\204', '\000',
+ '\000', '\042', '\000', '\300', '\010', '\000', '\100', '\002',
+ '\000', '\224', '\000', '\000', '\046', '\000', '\300', '\011',
+ '\000', '\060', '\263', '\024', '\000', '\100', '\005', '\000',
+ '\130', '\001', '\000', '\264', '\322', '\002', '\000', '\350',
+ '\351', '\005', '\000', '\250', '\331', '\221', '\270', '\062',
+ '\003', '\000', '\320', '\000', '\000', '\065', '\000', '\200',
+ '\015', '\000', '\160', '\003', '\000', '\334', '\054', '\007',
+ '\000', '\320', '\001', '\000', '\166', '\000', '\000', '\036',
+ '\000', '\240', '\007', '\000', '\360', '\312', '\017', '\000',
+ '\220', '\223', '\040', '\000', '\100', '\010', '\047', '\002',
+ '\000', '\021', '\000', '\000', '\026', '\043', '\000', '\300',
+ '\104', '\062', '\112', '\002', '\000', '\224', '\000', '\000',
+ '\261', '\060', '\241', '\067', '\000', '\140', '\325', '\023',
+ '\000', '\004', '\200', '\050', '\214', '\307', '\073', '\000',
+ '\350', '\123', '\025', '\000', '\100', '\252', '\126', '\001',
+ '\300', '\066', '\132', '\000', '\200', '\131', '\270', '\000',
+ '\200', '\056', '\000', '\300', '\013', '\000', '\370', '\002',
+ '\000', '\202', '\026', '\006', '\000', '\240', '\045', '\070',
+ '\025', '\051', '\003', '\000', '\314', '\000', '\000', '\315',
+ '\014', '\055', '\015', '\000', '\120', '\003', '\000', '\326',
+ '\000', '\000', '\372', '\164', '\307', '\015', '\000', '\170',
+ '\003', '\000', '\212', '\246', '\026', '\266', '\314', '\001',
+ '\000', '\164', '\000', '\100', '\035', '\000', '\140', '\007',
+ '\000', '\334', '\001', '\000', '\107', '\313', '\003', '\000',
+ '\364', '\000', '\200', '\075', '\000', '\200', '\017', '\000',
+ '\200', '\213', '\037', '\000', '\200', '\352', '\224', '\045',
+ '\345', '\273', '\147', '\247', '\214', '\332', '\323', '\316',
+ '\366', '\140', '\241', '\335', '\355', '\153', '\207', '\173',
+ '\333', '\337', '\116', '\367', '\270', '\327', '\175', '\356',
+ '\166', '\317', '\073', '\336', '\367', '\056', '\367', '\276',
+ '\337', '\335', '\357', '\172', '\007', '\074', '\337', '\377',
+ '\116', '\370', '\300', '\027', '\176', '\360', '\206', '\117',
+ '\074', '\342', '\027', '\057', '\370', '\306', '\037', '\336',
+ '\361', '\212', '\207', '\074', '\343', '\037', '\117', '\371',
+ '\310', '\127', '\176', '\362', '\206', '\127', '\110', '\322',
+ '\024', '\322', '\254', '\356', '\002', '\340', '\047', '\006',
+ '\051', '\054', '\000', '\210', '\075', '\316', '\204', '\114',
+ '\333', '\040', '\063', '\063', '\110', '\271', '\015', '\022',
+ '\030', '\172', '\047', '\304', '\337', '\006', '\061', '\370',
+ '\155', '\022', '\142', '\027', '\216', '\033', '\144', '\344',
+ '\006', '\111', '\271', '\101', '\144', '\156', '\220', '\212',
+ '\030', '\004', '\350', '\006', '\101', '\272', '\101', '\236',
+ '\156', '\220', '\243', '\275', '\045', '\041', '\202', '\110',
+ '\310', '\041', '\022', '\302', '\210', '\204', '\104', '\042',
+ '\041', '\226', '\110', '\310', '\046', '\022', '\002', '\065',
+ '\203', '\224', '\042', '\041', '\247', '\110', '\110', '\052',
+ '\022', '\262', '\212', '\204', '\264', '\042', '\041', '\257',
+ '\110', '\110', '\054', '\022', '\062', '\213', '\204', '\324',
+ '\042', '\041', '\267', '\110', '\110', '\056', '\022', '\262',
+ '\213', '\204', '\364', '\042', '\041', '\277', '\110', '\110',
+ '\060', '\022', '\062', '\214', '\204', '\024', '\043', '\041',
+ '\307', '\110', '\110', '\062', '\022', '\122', '\030', '\203',
+ '\064', '\043', '\041', '\317', '\220', '\020', '\321', '\220',
+ '\020', '\323', '\220', '\020', '\325', '\140', '\030', '\011',
+ '\221', '\015', '\011', '\261', '\015', '\011', '\321', '\015',
+ '\011', '\361', '\015', '\011', '\021', '\016', '\011', '\061',
+ '\016', '\011', '\121', '\016', '\011', '\161', '\016', '\011',
+ '\221', '\016', '\011', '\261', '\016', '\011', '\321', '\016',
+ '\011', '\361', '\016', '\011', '\021', '\017', '\011', '\061',
+ '\017', '\011', '\121', '\017', '\011', '\161', '\017', '\011',
+ '\221', '\017', '\011', '\261', '\017', '\011', '\321', '\017',
+ '\011', '\001', '\055', '\273', '\142', '\020', '\003', '\060',
+ '\021', '\005', '\060', '\021', '\070', '\144', '\020', '\011',
+ '\060', '\021', '\013', '\060', '\021', '\015', '\060', '\021',
+ '\017', '\060', '\021', '\021', '\060', '\021', '\023', '\060',
+ '\021', '\025', '\060', '\021', '\027', '\060', '\021', '\031',
+ '\060', '\021', '\033', '\060', '\021', '\221', '\141', '\020',
+ '\037', '\060', '\021', '\041', '\060', '\021', '\043', '\060',
+ '\021', '\045', '\060', '\021', '\047', '\060', '\021', '\051',
+ '\060', '\021', '\053', '\060', '\021', '\055', '\060', '\021',
+ '\057', '\060', '\021', '\061', '\060', '\021', '\063', '\060',
+ '\021', '\065', '\060', '\021', '\067', '\060', '\021', '\071',
+ '\060', '\021', '\073', '\060', '\021', '\075', '\060', '\021',
+ '\077', '\060', '\021', '\101', '\060', '\021', '\103', '\060',
+ '\021', '\105', '\060', '\021', '\107', '\060', '\021', '\111',
+ '\060', '\021', '\113', '\060', '\021', '\115', '\060', '\021',
+ '\117', '\060', '\021', '\121', '\060', '\021', '\123', '\060',
+ '\021', '\125', '\060', '\021', '\127', '\060', '\021', '\131',
+ '\060', '\021', '\133', '\060', '\021', '\135', '\060', '\021',
+ '\137', '\060', '\021', '\230', '\141', '\020', '\146', '\040',
+ '\207', '\060', '\120', '\211', '\047', '\122', '\211', '\107',
+ '\062', '\004', '\225', '\310', '\025', '\232', '\010', '\003',
+ '\355', '\326', '\211', '\357', '\326', '\211', '\361', '\326',
+ '\211', '\363', '\326', '\211', '\365', '\246', '\211', '\061',
+ '\120', '\063', '\250', '\230', '\211', '\060', '\020', '\003',
+ '\234', '\330', '\212', '\237', '\330', '\212', '\241', '\330',
+ '\212', '\243', '\330', '\212', '\245', '\330', '\212', '\247',
+ '\010', '\003', '\062', '\240', '\212', '\272', '\310', '\212',
+ '\062', '\360', '\212', '\062', '\020', '\213', '\062', '\060',
+ '\213', '\062', '\120', '\213', '\062', '\160', '\213', '\062',
+ '\220', '\213', '\063', '\300', '\213', '\063', '\300', '\212',
+ '\063', '\360', '\212', '\063', '\020', '\213', '\063', '\060',
+ '\213', '\063', '\120', '\213', '\063', '\160', '\213', '\063',
+ '\220', '\213', '\064', '\120', '\063', '\317', '\026', '\155',
+ '\323', '\126', '\155', '\327', '\226', '\155', '\333', '\326',
+ '\155', '\337', '\026', '\156', '\343', '\346', '\047', '\346',
+ '\006', '\000', '\350', '\246', '\156', '\000', '\300', '\156',
+ '\356', '\006', '\157', '\362', '\346', '\172', '\367', '\226',
+ '\157', '\373', '\326', '\157', '\377', '\026', '\160', '\000',
+ '\060', '\160', '\005', '\167', '\160', '\011', '\267', '\160',
+ '\015', '\367', '\160', '\000', '\020', '\161', '\023', '\127',
+ '\161', '\000', '\160', '\161', '\144', '\241', '\161', '\034',
+ '\347', '\161', '\344', '\061', '\005', '\041', '\007', '\000',
+ '\043', '\127', '\162', '\032', '\202', '\162', '\052', '\007',
+ '\000', '\054', '\347', '\162', '\060', '\047', '\163', '\064',
+ '\147', '\163', '\000', '\200', '\163', '\000', '\240', '\163',
+ '\074', '\347', '\163', '\000', '\000', '\164', '\102', '\107',
+ '\164', '\106', '\007', '\000', '\110', '\247', '\164', '\114',
+ '\007', '\000', '\116', '\007', '\165', '\122', '\107', '\165',
+ '\126', '\207', '\165', '\000', '\240', '\165', '\134', '\347',
+ '\165', '\140', '\047', '\166', '\047', '\022', '\003', '\067',
+ '\120', '\157', '\111', '\321', '\053', '\275', '\362', '\053',
+ '\147', '\067', '\023', '\323', '\102', '\167', '\310', '\062',
+ '\054', '\312', '\042', '\224', '\011', '\321', '\054', '\317',
+ '\022', '\055', '\104', '\131', '\054', '\164', '\007',
+
+};
+
+static char name_6x13[] = "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1";
+static char name_cursor[] = "cursor";
+static char name_5x7[] = "-misc-fixed-medium-r-normal--7-70-75-75-c-50-iso8859-1";
+static char name_5x8[] = "-misc-fixed-medium-r-normal--8-80-75-75-c-50-iso646.1991-irv";
+
+const BuiltinFileRec builtin_files[] = {
+"6x13.builtin", sizeof file_6x13, file_6x13,
+"cursor.builtin", sizeof file_cursor, file_cursor,
+"5x7.builtin", sizeof file_5x7, file_5x7,
+"5x8.builtin", sizeof file_5x8, file_5x8,
+};
+
+const int builtin_files_count = sizeof (builtin_files) / sizeof (builtin_files[0]);
+
+const BuiltinDirRec builtin_dir[] = {
+"6x13.builtin", name_6x13,
+"cursor.builtin", name_cursor,
+"5x7.builtin", name_5x7,
+"5x8.builtin", name_5x8,
+};
+
+const int builtin_dir_count = sizeof (builtin_dir) / sizeof (builtin_dir[0]);
+
+static char alias_fixed[] = "fixed";
+static char alias_6x13[] = "6x13";
+static char alias_6x13_100[] = "-misc-fixed-medium-r-semicondensed--13-100-100-100-c-60-iso8859-1";
+static char alias_5x7[] = "5x7";
+static char alias_5x7_100[] = "-misc-fixed-medium-r-normal--7-50-100-100-c-50-iso8859-1";
+static char alias_5x8[] = "5x8";
+static char alias_5x8_75[] = "-misc-fixed-medium-r-normal--8-80-75-75-c-50-iso8859-1";
+static char alias_5x8_100[] = "-misc-fixed-medium-r-normal--8-60-100-100-c-50-iso8859-1";
+
+const BuiltinAliasRec builtin_alias[] = {
+alias_fixed, name_6x13,
+alias_6x13, name_6x13,
+alias_6x13_100, name_6x13,
+alias_5x7, name_5x7,
+alias_5x7_100, name_5x7,
+alias_5x8, name_5x8,
+alias_5x8_75, name_5x8,
+alias_5x8_100, name_5x8,
+};
+
+const int builtin_alias_count = sizeof (builtin_alias) / sizeof (builtin_alias[0]);
diff --git a/nx-X11/lib/font/builtins/fpe.c b/nx-X11/lib/font/builtins/fpe.c
new file mode 100644
index 000000000..7f78fabbd
--- /dev/null
+++ b/nx-X11/lib/font/builtins/fpe.c
@@ -0,0 +1,98 @@
+/* $XdotOrg: xc/lib/font/builtins/fpe.c,v 1.5 2005/07/30 18:56:32 alanc Exp $ */
+/*
+ * Id: fpe.c,v 1.2 1999/11/02 06:16:48 keithp Exp $
+ *
+ * Copyright 1999 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+/* $XFree86: xc/lib/font/builtins/fpe.c,v 1.3 1999/12/30 02:29:51 robin Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+
+static int font_file_type;
+
+const char builtin_fonts[] = "built-ins";
+
+int
+BuiltinNameCheck (name)
+ char *name;
+{
+ return (strcmp (name, builtin_fonts) == 0);
+}
+
+int
+BuiltinInitFPE (fpe)
+ FontPathElementPtr fpe;
+{
+ int status;
+ FontDirectoryPtr dir;
+
+ status = BuiltinReadDirectory (fpe->name, &dir);
+
+ if (status == Successful)
+ fpe->private = (pointer) dir;
+ return status;
+}
+
+/* ARGSUSED */
+int
+BuiltinResetFPE (fpe)
+ FontPathElementPtr fpe;
+{
+ FontDirectoryPtr dir;
+
+ dir = (FontDirectoryPtr) fpe->private;
+ /* builtins can't change! */
+ return Successful;
+}
+
+int
+BuiltinFreeFPE (fpe)
+ FontPathElementPtr fpe;
+{
+ FontFileFreeDir ((FontDirectoryPtr) fpe->private);
+ return Successful;
+}
+
+void
+BuiltinRegisterFpeFunctions(void)
+{
+ BuiltinRegisterFontFileFunctions ();
+
+ font_file_type = RegisterFPEFunctions(BuiltinNameCheck,
+ BuiltinInitFPE,
+ BuiltinFreeFPE,
+ BuiltinResetFPE,
+ FontFileOpenFont,
+ FontFileCloseFont,
+ FontFileListFonts,
+ FontFileStartListFontsWithInfo,
+ FontFileListNextFontWithInfo,
+ (WakeupFpeFunc) 0,
+ (ClientDiedFunc) 0,
+ (LoadGlyphsFunc) 0,
+ (StartLaFunc) 0,
+ (NextLaFunc) 0,
+ (SetPathFunc) 0);
+}
diff --git a/nx-X11/lib/font/builtins/render.c b/nx-X11/lib/font/builtins/render.c
new file mode 100644
index 000000000..520d873f4
--- /dev/null
+++ b/nx-X11/lib/font/builtins/render.c
@@ -0,0 +1,114 @@
+/* $XdotOrg: xc/lib/font/builtins/render.c,v 1.5 2005/07/30 18:56:32 alanc Exp $ */
+/*
+ * Id: render.c,v 1.2 1999/11/02 06:16:48 keithp Exp $
+ *
+ * Copyright 1999 SuSE, Inc.
+ *
+ * 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 of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+/* $XFree86: xc/lib/font/builtins/render.c,v 1.3 1999/12/30 02:29:51 robin Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#include "builtin.h"
+
+BuiltinOpenBitmap (fpe, ppFont, flags, entry, fileName, format, fmask)
+ FontPathElementPtr fpe;
+ FontPtr *ppFont;
+ int flags;
+ FontEntryPtr entry;
+ char *fileName;
+ fsBitmapFormat format;
+ fsBitmapFormatMask fmask;
+{
+ FontFilePtr file;
+ FontPtr pFont;
+ int i;
+ int ret;
+ int bit,
+ byte,
+ glyph,
+ scan,
+ image;
+
+ file = BuiltinFileOpen (fileName);
+ if (!file)
+ return BadFontName;
+ pFont = (FontPtr) xalloc(sizeof(FontRec));
+ if (!pFont) {
+ BuiltinFileClose (file);
+ return AllocError;
+ }
+ /* set up default values */
+ FontDefaultFormat(&bit, &byte, &glyph, &scan);
+ /* get any changes made from above */
+ ret = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);
+
+ /* Fill in font record. Data format filled in by reader. */
+ pFont->refcnt = 0;
+ pFont->maxPrivate = -1;
+ pFont->devPrivates = (pointer *) 0;
+
+ ret = pcfReadFont (pFont, file, bit, byte, glyph, scan);
+
+ BuiltinFileClose (file);
+ if (ret != Successful)
+ xfree(pFont);
+ else
+ *ppFont = pFont;
+ return ret;
+}
+
+BuiltinGetInfoBitmap (fpe, pFontInfo, entry, fileName)
+ FontPathElementPtr fpe;
+ FontInfoPtr pFontInfo;
+ FontEntryPtr entry;
+ char *fileName;
+{
+ FontFilePtr file;
+ int i;
+ int ret;
+ FontRendererPtr renderer;
+
+ file = BuiltinFileOpen (fileName);
+ if (!file)
+ return BadFontName;
+ ret = pcfReadFontInfo (pFontInfo, file);
+ BuiltinFileClose (file);
+ return ret;
+}
+
+static FontRendererRec renderers[] = {
+ ".builtin", 8,
+ BuiltinOpenBitmap, 0, BuiltinGetInfoBitmap, 0, 0
+};
+
+#define numRenderers (sizeof renderers / sizeof renderers[0])
+
+void
+BuiltinRegisterFontFileFunctions(void)
+{
+ int i;
+ for (i = 0; i < numRenderers; i++)
+ FontFileRegisterRenderer ((FontRendererRec *) &renderers[i]);
+}
+
diff --git a/nx-X11/lib/font/fc/Imakefile b/nx-X11/lib/font/fc/Imakefile
new file mode 100644
index 000000000..d51151348
--- /dev/null
+++ b/nx-X11/lib/font/fc/Imakefile
@@ -0,0 +1,31 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:36 cpqbld Exp $
+XCOMM
+XCOMM Make file for font handling routines
+XCOMM
+XCOMM $XFree86: xc/lib/font/fc/Imakefile,v 1.4 1999/12/13 02:52:50 robin Exp $
+#include <Server.tmpl>
+
+ INCLUDES = -I$(FONTINCSRC) -I../include $(TRANS_INCLUDES)
+ HEADERS =
+ SRCS = fsconvert.c fserve.c fsio.c transport.c
+ OBJS = fsconvert.o fserve.o fsio.o transport.o
+ CONN_DEFINES = $(CONNECTION_FLAGS) -DFONT_t -DTRANS_CLIENT -DTRANS_SERVER -DTRANS_REOPEN
+#if HasBSD44Sockets
+ SOCK_DEFINES = -DBSD44SOCKETS
+#endif
+ DEFINES = $(SIGNAL_DEFINES) $(CONN_DEFINES) $(SOCK_DEFINES)
+
+
+#define DoNormalLib NormalLibFont
+#define DoSharedLib SharedLibFont
+#define DoDebugLib DebugLibFont
+#define DoProfileLib ProfileLibFont
+#include <Library.tmpl>
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+LinkSourceFile(transport.c,$(TRANSCOMMSRC))
+
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/font/fc/fsconvert.c b/nx-X11/lib/font/fc/fsconvert.c
new file mode 100644
index 000000000..9ff54f58f
--- /dev/null
+++ b/nx-X11/lib/font/fc/fsconvert.c
@@ -0,0 +1,760 @@
+/* $Xorg: fsconvert.c,v 1.3 2000/08/17 19:46:36 cpqbld Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices
+ *
+ * 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 of Network Computing Devices not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. Network Computing Devices
+ * makes no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL NETWORK COMPUTING DEVICES 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.
+ *
+ * Author: Dave Lemke, Network Computing Devices, Inc
+ */
+/* $XFree86: xc/lib/font/fc/fsconvert.c,v 1.14 2003/08/30 18:06:29 dawes Exp $ */
+/*
+ * FS data conversion
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/X.h>
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/Xpoll.h>
+#include <X11/fonts/FS.h>
+#include <X11/fonts/FSproto.h>
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+#include "fservestr.h"
+#include <X11/fonts/fontutil.h>
+#include "fslibos.h"
+
+extern char _fs_glyph_undefined;
+extern char _fs_glyph_requested;
+extern char _fs_glyph_zero_length;
+
+
+/*
+ * converts data from font server form to X server form
+ */
+
+void
+_fs_convert_char_info(fsXCharInfo *src, xCharInfo *dst)
+{
+ dst->ascent = src->ascent;
+ dst->descent = src->descent;
+ dst->leftSideBearing = src->left;
+ dst->rightSideBearing = src->right;
+ dst->characterWidth = src->width;
+ dst->attributes = src->attributes;
+}
+
+void
+_fs_init_fontinfo(FSFpePtr conn, FontInfoPtr pfi)
+{
+ if (conn->fsMajorVersion == 1) {
+ unsigned short n;
+ n = pfi->firstCol;
+ pfi->firstCol = pfi->firstRow;
+ pfi->firstRow = n;
+ n = pfi->lastCol;
+ pfi->lastCol = pfi->lastRow;
+ pfi->lastRow = n;
+ pfi->defaultCh = ((pfi->defaultCh >> 8) & 0xff)
+ + ((pfi->defaultCh & 0xff) << 8);
+ }
+
+ if (FontCouldBeTerminal (pfi))
+ {
+ pfi->terminalFont = TRUE;
+ pfi->minbounds.ascent = pfi->fontAscent;
+ pfi->minbounds.descent = pfi->fontDescent;
+ pfi->minbounds.leftSideBearing = 0;
+ pfi->minbounds.rightSideBearing = pfi->minbounds.characterWidth;
+ pfi->maxbounds = pfi->minbounds;
+ }
+
+ FontComputeInfoAccelerators (pfi);
+}
+
+int
+_fs_convert_props(fsPropInfo *pi, fsPropOffset *po, pointer pd,
+ FontInfoPtr pfi)
+{
+ FontPropPtr dprop;
+ int i,
+ nprops;
+ char *is_str;
+ fsPropOffset local_off;
+ char *off_adr;
+ char *pdc = pd;
+
+/* stolen from server/include/resource.h */
+#define BAD_RESOURCE 0xe0000000
+
+ nprops = pfi->nprops = pi->num_offsets;
+
+ if (nprops < 0
+ || nprops > SIZE_MAX/(sizeof(FontPropRec) + sizeof(char)))
+ return -1;
+
+ dprop = (FontPropPtr) xalloc(sizeof(FontPropRec) * nprops +
+ sizeof (char) * nprops);
+ if (!dprop)
+ return -1;
+
+ is_str = (char *) (dprop + nprops);
+ pfi->props = dprop;
+ pfi->isStringProp = is_str;
+
+ off_adr = (char *)po;
+ for (i = 0; i < nprops; i++, dprop++, is_str++)
+ {
+ memcpy(&local_off, off_adr, SIZEOF(fsPropOffset));
+ dprop->name = MakeAtom(&pdc[local_off.name.position],
+ local_off.name.length, 1);
+ if (local_off.type != PropTypeString) {
+ *is_str = FALSE;
+ dprop->value = local_off.value.position;
+ } else {
+ *is_str = TRUE;
+ dprop->value = (INT32) MakeAtom(&pdc[local_off.value.position],
+ local_off.value.length, 1);
+ if (dprop->value == BAD_RESOURCE)
+ {
+ xfree (pfi->props);
+ pfi->nprops = 0;
+ pfi->props = 0;
+ pfi->isStringProp = 0;
+ return -1;
+ }
+ }
+ off_adr += SIZEOF(fsPropOffset);
+ }
+
+ return nprops;
+}
+
+void
+_fs_free_props (FontInfoPtr pfi)
+{
+ if (pfi->props)
+ {
+ xfree (pfi->props);
+ pfi->nprops = 0;
+ pfi->props = 0;
+ }
+}
+
+int
+_fs_convert_lfwi_reply(FSFpePtr conn, FontInfoPtr pfi,
+ fsListFontsWithXInfoReply *fsrep,
+ fsPropInfo *pi, fsPropOffset *po, pointer pd)
+{
+ fsUnpack_XFontInfoHeader(fsrep, pfi);
+ _fs_init_fontinfo(conn, pfi);
+
+ if (_fs_convert_props(pi, po, pd, pfi) == -1)
+ return AllocError;
+
+ return Successful;
+}
+
+
+#define ENCODING_UNDEFINED(enc) \
+ ((enc)->bits == &_fs_glyph_undefined ? \
+ TRUE : \
+ (access_done = access_done && (enc)->bits != &_fs_glyph_requested, \
+ FALSE))
+
+#define GLYPH_UNDEFINED(loc) ENCODING_UNDEFINED(encoding + (loc))
+
+/*
+ * figures out what glyphs to request
+ *
+ * Includes logic to attempt to reduce number of round trips to the font
+ * server: when a glyph is requested, fs_build_range() requests a
+ * 16-glyph range of glyphs that contains the requested glyph. This is
+ * predicated on the belief that using a glyph increases the chances
+ * that nearby glyphs will be used: a good assumption for phonetic
+ * alphabets, but a questionable one for ideographic/pictographic ones.
+ */
+/* ARGSUSED */
+int
+fs_build_range(FontPtr pfont, Bool range_flag, unsigned int count,
+ int item_size, unsigned char *data, int *nranges,
+ fsRange **ranges)
+{
+ FSFontDataPtr fsd = (FSFontDataPtr) (pfont->fpePrivate);
+ FSFontPtr fsfont = (FSFontPtr) (pfont->fontPrivate);
+ register CharInfoPtr encoding = fsfont->encoding;
+ FontInfoPtr pfi = &(pfont->info);
+ fsRange range;
+ int access_done = TRUE;
+ int err;
+ register unsigned long firstrow, lastrow, firstcol, lastcol;
+ register unsigned long row;
+ register unsigned long col;
+ register unsigned long loc;
+
+ if (!fsd->glyphs_to_get)
+ return AccessDone;
+
+ firstrow = pfi->firstRow;
+ lastrow = pfi->lastRow;
+ firstcol = pfi->firstCol;
+ lastcol = pfi->lastCol;
+
+ /* Make sure we have default char */
+ if (fsfont->pDefault && ENCODING_UNDEFINED(fsfont->pDefault))
+ {
+ loc = fsfont->pDefault - encoding;
+ row = loc / (lastcol - firstcol + 1) + firstrow;
+ col = loc % (lastcol - firstcol + 1) + firstcol;
+
+ range.min_char_low = range.max_char_low = col;
+ range.min_char_high = range.max_char_high = row;
+
+ if ((err = add_range(&range, nranges, ranges, FALSE)) !=
+ Successful) return err;
+ encoding[loc].bits = &_fs_glyph_requested;
+ access_done = FALSE;
+ }
+
+ if (!range_flag && item_size == 1)
+ {
+ if (firstrow != 0) return AccessDone;
+ while (count--)
+ {
+ col = *data++;
+ if (col >= firstcol && col <= lastcol &&
+ GLYPH_UNDEFINED(col - firstcol))
+ {
+ int col1, col2;
+ col1 = col & 0xf0;
+ col2 = col1 + 15;
+ if (col1 < firstcol) col1 = firstcol;
+ if (col2 > lastcol) col2 = lastcol;
+ /* Collect a 16-glyph neighborhood containing the requested
+ glyph... should in most cases reduce the number of round
+ trips to the font server. */
+ for (col = col1; col <= col2; col++)
+ {
+ if (!GLYPH_UNDEFINED(col - firstcol)) continue;
+ range.min_char_low = range.max_char_low = col;
+ range.min_char_high = range.max_char_high = 0;
+ if ((err = add_range(&range, nranges, ranges, FALSE)) !=
+ Successful) return err;
+ encoding[col - firstcol].bits = &_fs_glyph_requested;
+ access_done = FALSE;
+ }
+ }
+ }
+ }
+ else
+ {
+ fsRange fullrange[1];
+
+ if (range_flag && count == 0)
+ {
+ count = 2;
+ data = (unsigned char *)fullrange;
+ fullrange[0].min_char_high = firstrow;
+ fullrange[0].min_char_low = firstcol;
+ fullrange[0].max_char_high = lastrow;
+ fullrange[0].max_char_low = lastcol;
+ }
+
+ while (count--)
+ {
+ int row1, col1, row2, col2;
+ row1 = row2 = *data++;
+ col1 = col2 = *data++;
+ if (range_flag)
+ {
+ if (count)
+ {
+ row2 = *data++;
+ col2 = *data++;
+ count--;
+ }
+ else
+ {
+ row2 = lastrow;
+ col2 = lastcol;
+ }
+ if (row1 < firstrow) row1 = firstrow;
+ if (row2 > lastrow) row2 = lastrow;
+ if (col1 < firstcol) col1 = firstcol;
+ if (col2 > lastcol) col2 = lastcol;
+ }
+ else
+ {
+ if (row1 < firstrow || row1 > lastrow ||
+ col1 < firstcol || col1 > lastcol)
+ continue;
+ }
+ for (row = row1; row <= row2; row++)
+ {
+ expand_glyph_range: ;
+ loc = (row - firstrow) * (lastcol + 1 - firstcol) +
+ (col1 - firstcol);
+ for (col = col1; col <= col2; col++, loc++)
+ {
+ if (GLYPH_UNDEFINED(loc))
+ {
+ if (row1 == row2 &&
+ (((col1 & 0xf) && col1 > firstcol) ||
+ (col2 & 0xf) != 0xf) && (col2 < lastcol))
+ {
+ /* If we're loading from a single row, expand
+ range of glyphs loaded to a multiple of
+ a 16-glyph range -- attempt to reduce number
+ of round trips to the font server. */
+ col1 &= 0xf0;
+ col2 = (col2 & 0xf0) + 15;
+ if (col1 < firstcol) col1 = firstcol;
+ if (col2 > lastcol) col2 = lastcol;
+ goto expand_glyph_range;
+ }
+ range.min_char_low = range.max_char_low = col;
+ range.min_char_high = range.max_char_high = row;
+ if ((err = add_range(&range, nranges, ranges, FALSE)) !=
+ Successful) return err;
+ encoding[loc].bits = &_fs_glyph_requested;
+ access_done = FALSE;
+ }
+ }
+ }
+ }
+ }
+
+ return access_done ?
+ AccessDone :
+ Successful;
+}
+
+#undef GLYPH_UNDEFINED
+#undef ENCODING_UNDEFINED
+
+
+/* _fs_clean_aborted_loadglyphs(): Undoes the changes to the encoding array
+ performed by fs_build_range(); for use if the associated LoadGlyphs
+ requests needs to be cancelled. */
+
+void
+_fs_clean_aborted_loadglyphs(FontPtr pfont, int num_expected_ranges,
+ fsRange *expected_ranges)
+{
+ register FSFontPtr fsfont;
+ register int i;
+
+ fsfont = (FSFontPtr) pfont->fontPrivate;
+ if (fsfont->encoding)
+ {
+ fsRange full_range[1];
+ if (!num_expected_ranges)
+ {
+ full_range[0].min_char_low = pfont->info.firstCol;
+ full_range[0].min_char_high = pfont->info.firstRow;
+ full_range[0].max_char_low = pfont->info.lastCol;
+ full_range[0].max_char_high = pfont->info.lastRow;
+ num_expected_ranges = 1;
+ expected_ranges = full_range;
+ }
+
+ for (i = 0; i < num_expected_ranges; i++)
+ {
+ int row, col;
+ for (row = expected_ranges[i].min_char_high;
+ row <= expected_ranges[i].max_char_high;
+ row++)
+ {
+ register CharInfoPtr encoding = fsfont->encoding +
+ ((row - pfont->info.firstRow) *
+ (pfont->info.lastCol -
+ pfont->info.firstCol + 1) +
+ expected_ranges[i].min_char_low -
+ pfont->info.firstCol);
+ for (col = expected_ranges[i].min_char_low;
+ col <= expected_ranges[i].max_char_low;
+ encoding++, col++)
+ {
+ if (encoding->bits == &_fs_glyph_requested)
+ encoding->bits = &_fs_glyph_undefined;
+ }
+ }
+ }
+ }
+}
+
+
+/*
+ * figures out what extents to request
+ * this is where lots of extra
+ * smarts wants to live
+ */
+/* ARGSUSED */
+int
+_fs_check_extents(FontPtr pfont, Mask flags, int nranges, fsRange *range,
+ FSBlockDataPtr blockrec)
+{
+/* XXX -- either fill in the requested info if we have it somewhere
+ * and return AccessDone, or else return Successful
+ */
+ return Successful;
+}
+
+/*
+ * figures out what glyphs to request
+ * this is where lots of extra
+ * smarts wants to live
+ */
+/* ARGSUSED */
+int
+_fs_check_bitmaps(FontPtr pfont, fsBitmapFormat format,
+ Mask flags, int nranges, fsRange *range,
+ FSBlockDataPtr blockrec)
+{
+/* XXX -- either fill in the requested info if we have it somewhere
+ * and return AccessDone, or else return Successful
+ */
+ return Successful;
+}
+
+int
+_fs_get_glyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
+{
+ FSFontPtr fsdata;
+ unsigned int firstCol;
+ register unsigned int numCols;
+ unsigned int firstRow;
+ unsigned int numRows;
+ CharInfoPtr *glyphsBase;
+ register unsigned int c;
+ register CharInfoPtr pci;
+ unsigned int r;
+ CharInfoPtr encoding;
+ CharInfoPtr pDefault;
+ FSFontDataPtr fsd = (FSFontDataPtr) pFont->fpePrivate;
+ int err = Successful;
+
+ fsdata = (FSFontPtr) pFont->fontPrivate;
+ encoding = fsdata->encoding;
+ pDefault = fsdata->pDefault;
+ firstCol = pFont->info.firstCol;
+ numCols = pFont->info.lastCol - firstCol + 1;
+ glyphsBase = glyphs;
+
+ /* In this age of glyph caching, any glyphs gotten through this
+ procedure should already be loaded. If they are not, we are
+ dealing with someone (perhaps a ddx driver optimizing a font)
+ that doesn't understand the finer points of glyph caching. The
+ CHECK_ENCODING macro checks for this condition... if found, it
+ calls fs_load_all_glyphs(), which corrects it. Since the caller
+ of this code will not know how to handle a return value of
+ Suspended, the fs_load_all_glyphs() procedure will block and
+ freeze the server until the load operation is done. Moral: the
+ glyphCachingMode flag really must indicate the capabilities of
+ the ddx drivers. */
+
+#define CHECK_ENCODING(cnum) \
+ ( pci = encoding + (cnum), \
+ fsd->glyphs_to_get ? \
+ ( pci->bits == &_fs_glyph_undefined || pci->bits == &_fs_glyph_requested ? \
+ ((err = fs_load_all_glyphs(pFont)), pci) : \
+ pci ) : \
+ pci )
+
+ switch (charEncoding) {
+
+ case Linear8Bit:
+ case TwoD8Bit:
+ if (pFont->info.firstRow > 0)
+ break;
+ if (pFont->info.allExist && pDefault) {
+ while (err == Successful && count--) {
+ c = (*chars++) - firstCol;
+ if (c < numCols)
+ *glyphs++ = CHECK_ENCODING(c);
+ else
+ *glyphs++ = pDefault;
+ }
+ } else {
+ while (err == Successful && count--) {
+ c = (*chars++) - firstCol;
+ if (c < numCols && CHECK_ENCODING(c)->bits)
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ }
+ break;
+ case Linear16Bit:
+ if (pFont->info.allExist && pDefault) {
+ while (err == Successful && count--) {
+ c = *chars++ << 8;
+ c = (c | *chars++) - firstCol;
+ if (c < numCols)
+ *glyphs++ = CHECK_ENCODING(c);
+ else
+ *glyphs++ = pDefault;
+ }
+ } else {
+ while (err == Successful && count--) {
+ c = *chars++ << 8;
+ c = (c | *chars++) - firstCol;
+ if (c < numCols && CHECK_ENCODING(c)->bits)
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ }
+ break;
+
+ case TwoD16Bit:
+ firstRow = pFont->info.firstRow;
+ numRows = pFont->info.lastRow - firstRow + 1;
+ while (err == Successful && count--) {
+ r = (*chars++) - firstRow;
+ c = (*chars++) - firstCol;
+ if (r < numRows && c < numCols &&
+ CHECK_ENCODING(r * numCols + c)->bits)
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ }
+ *glyphCount = glyphs - glyphsBase;
+ return err;
+}
+
+
+static int
+_fs_get_metrics(FontPtr pFont, unsigned long count, unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ xCharInfo **glyphs) /* RETURN */
+{
+ FSFontPtr fsdata;
+ unsigned int firstCol;
+ register unsigned int numCols;
+ unsigned int firstRow;
+ unsigned int numRows;
+ xCharInfo **glyphsBase;
+ register unsigned int c;
+ unsigned int r;
+ CharInfoPtr encoding;
+ CharInfoPtr pDefault;
+
+ fsdata = (FSFontPtr) pFont->fontPrivate;
+ encoding = fsdata->inkMetrics;
+ pDefault = fsdata->pDefault;
+ /* convert default bitmap metric to default ink metric */
+ if (pDefault)
+ pDefault = encoding + (pDefault - fsdata->encoding);
+ firstCol = pFont->info.firstCol;
+ numCols = pFont->info.lastCol - firstCol + 1;
+ glyphsBase = glyphs;
+
+
+ /* XXX - this should be much smarter */
+ /* make sure the glyphs are there */
+ switch (charEncoding) {
+
+ case Linear8Bit:
+ case TwoD8Bit:
+ if (pFont->info.firstRow > 0)
+ break;
+ if (pFont->info.allExist && pDefault) {
+ while (count--) {
+ c = (*chars++) - firstCol;
+ if (c < numCols)
+ *glyphs++ = (xCharInfo *)&encoding[c];
+ else
+ *glyphs++ = (xCharInfo *)pDefault;
+ }
+ } else {
+ while (count--) {
+ c = (*chars++) - firstCol;
+ if (c < numCols)
+ *glyphs++ = (xCharInfo *)(encoding + c);
+ else if (pDefault)
+ *glyphs++ = (xCharInfo *)pDefault;
+ }
+ }
+ break;
+ case Linear16Bit:
+ if (pFont->info.allExist && pDefault) {
+ while (count--) {
+ c = *chars++ << 8;
+ c = (c | *chars++) - firstCol;
+ if (c < numCols)
+ *glyphs++ = (xCharInfo *)(encoding + c);
+ else
+ *glyphs++ = (xCharInfo *)pDefault;
+ }
+ } else {
+ while (count--) {
+ c = *chars++ << 8;
+ c = (c | *chars++) - firstCol;
+ if (c < numCols)
+ *glyphs++ = (xCharInfo *)(encoding + c);
+ else if (pDefault)
+ *glyphs++ = (xCharInfo *)pDefault;
+ }
+ }
+ break;
+
+ case TwoD16Bit:
+ firstRow = pFont->info.firstRow;
+ numRows = pFont->info.lastRow - firstRow + 1;
+ while (count--) {
+ r = (*chars++) - firstRow;
+ c = (*chars++) - firstCol;
+ if (r < numRows && c < numCols)
+ *glyphs++ = (xCharInfo *)(encoding + (r * numCols + c));
+ else if (pDefault)
+ *glyphs++ = (xCharInfo *)pDefault;
+ }
+ break;
+ }
+ *glyphCount = glyphs - glyphsBase;
+ return Successful;
+}
+
+
+void
+_fs_unload_font(FontPtr pfont)
+{
+ FSFontPtr fsdata = (FSFontPtr) pfont->fontPrivate;
+ FSFontDataPtr fsd = (FSFontDataPtr) pfont->fpePrivate;
+ CharInfoPtr encoding = fsdata->encoding;
+ FSGlyphPtr glyphs;
+
+ /*
+ * fsdata points at FSFontRec, FSFontDataRec and name
+ */
+ if (encoding)
+ xfree(encoding);
+
+ while ((glyphs = fsdata->glyphs))
+ {
+ fsdata->glyphs = glyphs->next;
+ xfree (glyphs);
+ }
+
+ /* XXX we may get called after the resource DB has been cleaned out */
+ if (find_old_font(fsd->fontid))
+ DeleteFontClientID (fsd->fontid);
+
+ _fs_free_props (&pfont->info);
+
+ xfree(fsdata);
+
+ DestroyFontRec(pfont);
+}
+
+FontPtr
+fs_create_font (FontPathElementPtr fpe,
+ char *name,
+ int namelen,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask)
+{
+ FontPtr pfont;
+ FSFontPtr fsfont;
+ FSFontDataPtr fsd;
+ int bit, byte, scan, glyph;
+
+ pfont = CreateFontRec ();
+ if (!pfont)
+ return 0;
+ fsfont = (FSFontPtr) xalloc (sizeof (FSFontRec) +
+ sizeof (FSFontDataRec) +
+ namelen + 1);
+ if (!fsfont)
+ {
+ DestroyFontRec (pfont);
+ return 0;
+ }
+ fsd = (FSFontDataPtr) (fsfont + 1);
+ bzero((char *) fsfont, sizeof(FSFontRec));
+ bzero((char *) fsd, sizeof(FSFontDataRec));
+
+ pfont->fpe = fpe;
+ pfont->fontPrivate = (pointer) fsfont;
+ pfont->fpePrivate = (pointer) fsd;
+
+ /* These font components will be needed in packGlyphs */
+ CheckFSFormat(format, BitmapFormatMaskBit |
+ BitmapFormatMaskByte |
+ BitmapFormatMaskScanLineUnit |
+ BitmapFormatMaskScanLinePad,
+ &bit,
+ &byte,
+ &scan,
+ &glyph,
+ NULL);
+ pfont->format = format;
+ pfont->bit = bit;
+ pfont->byte = byte;
+ pfont->scan = scan;
+ pfont->glyph = glyph;
+
+ pfont->info.nprops = 0;
+ pfont->info.props = 0;
+ pfont->info.isStringProp = 0;
+
+ /* set font function pointers */
+ pfont->get_glyphs = _fs_get_glyphs;
+ pfont->get_metrics = _fs_get_metrics;
+ pfont->unload_font = _fs_unload_font;
+ pfont->unload_glyphs = NULL;
+
+ /* set the FPE private information */
+ fsd->format = format;
+ fsd->fmask = fmask;
+ fsd->name = (char *) (fsd + 1);
+ memcpy (fsd->name, name, namelen);
+ fsd->name[namelen] = '\0';
+ fsd->fontid = GetNewFontClientID ();
+
+ /* save the ID */
+ if (!StoreFontClientFont(pfont, fsd->fontid))
+ {
+ xfree (fsfont);
+ DestroyFontRec (pfont);
+ return 0;
+ }
+
+ return pfont;
+}
+
+pointer
+fs_alloc_glyphs (FontPtr pFont, int size)
+{
+ FSGlyphPtr glyphs;
+ FSFontPtr fsfont = (FSFontPtr) pFont->fontPrivate;
+
+ glyphs = xalloc (sizeof (FSGlyphRec) + size);
+ glyphs->next = fsfont->glyphs;
+ fsfont->glyphs = glyphs;
+ return (pointer) (glyphs + 1);
+}
diff --git a/nx-X11/lib/font/fc/fserve.c b/nx-X11/lib/font/fc/fserve.c
new file mode 100644
index 000000000..bac0b8ee6
--- /dev/null
+++ b/nx-X11/lib/font/fc/fserve.c
@@ -0,0 +1,3262 @@
+/* $XdotOrg: xc/lib/font/fc/fserve.c,v 1.8 2005/07/09 06:36:12 keithp Exp $ */
+/* $Xorg: fserve.c,v 1.4 2001/02/09 02:04:02 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.
+
+*/
+/* $XFree86: xc/lib/font/fc/fserve.c,v 3.26tsi Exp $ */
+
+/*
+ * Copyright 1990 Network Computing Devices
+ *
+ * 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 names of Network Computing Devices, or Digital
+ * not be used in advertising or publicity pertaining to distribution
+ * of the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES, AND DIGITAL AND DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES,
+ * OR 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.
+ *
+ * Author: Dave Lemke, Network Computing Devices, Inc
+ */
+/*
+ * font server specific font access
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef WIN32
+#define _WILLWINSOCK_
+#endif
+#define FONT_t
+#define TRANS_CLIENT
+#include "X11/Xtrans/Xtrans.h"
+#include "X11/Xpoll.h"
+#include <X11/fonts/FS.h>
+#include <X11/fonts/FSproto.h>
+#include <X11/X.h>
+#include <X11/Xos.h>
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+#include "fservestr.h"
+#include <X11/fonts/fontutil.h>
+#include <errno.h>
+
+#include <time.h>
+#define Time_t time_t
+
+#ifdef NCD
+#include <ncd/nvram.h>
+#endif
+
+#include <stddef.h>
+
+#ifndef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+#define TimeCmp(a,c,b) ((int) ((a) - (b)) c 0)
+
+#define NONZEROMETRICS(pci) ((pci)->leftSideBearing || \
+ (pci)->rightSideBearing || \
+ (pci)->ascent || \
+ (pci)->descent || \
+ (pci)->characterWidth)
+
+extern void ErrorF(const char *f, ...);
+
+static int fs_read_glyphs ( FontPathElementPtr fpe, FSBlockDataPtr blockrec );
+static int fs_read_list ( FontPathElementPtr fpe, FSBlockDataPtr blockrec );
+static int fs_read_list_info ( FontPathElementPtr fpe,
+ FSBlockDataPtr blockrec );
+
+extern fd_set _fs_fd_mask;
+
+static void fs_block_handler ( pointer data, OSTimePtr wt,
+ pointer LastSelectMask );
+static int fs_wakeup ( FontPathElementPtr fpe, unsigned long *mask );
+
+/*
+ * List of all FPEs
+ */
+static FSFpePtr fs_fpes;
+/*
+ * Union of all FPE blockStates
+ */
+static CARD32 fs_blockState;
+
+static int _fs_restart_connection ( FSFpePtr conn );
+static void fs_send_query_bitmaps ( FontPathElementPtr fpe,
+ FSBlockDataPtr blockrec );
+static int fs_send_close_font ( FontPathElementPtr fpe, Font id );
+static void fs_client_died ( pointer client, FontPathElementPtr fpe );
+static void _fs_client_access ( FSFpePtr conn, pointer client, Bool sync );
+static void _fs_client_resolution ( FSFpePtr conn );
+static fsGenericReply *fs_get_reply (FSFpePtr conn, int *error);
+static int fs_await_reply (FSFpePtr conn);
+static void _fs_do_blocked (FSFpePtr conn);
+static void fs_cleanup_bfont (FSBlockedFontPtr bfont);
+
+char _fs_glyph_undefined;
+char _fs_glyph_requested;
+char _fs_glyph_zero_length;
+
+static int generationCount;
+
+int FontServerRequestTimeout = 30 * 1000;
+
+static void
+_fs_close_server (FSFpePtr conn);
+
+static FSFpePtr
+_fs_init_conn (char *servername);
+
+static int
+_fs_wait_connect (FSFpePtr conn);
+
+static int
+_fs_send_init_packets (FSFpePtr conn);
+
+static void
+_fs_check_reconnect (FSFpePtr conn);
+
+static void
+_fs_start_reconnect (FSFpePtr conn);
+
+static void
+_fs_free_conn (FSFpePtr conn);
+
+static int
+fs_free_fpe(FontPathElementPtr fpe);
+
+/*
+ * Font server access
+ *
+ * the basic idea for the non-blocking access is to have the function
+ * called multiple times until the actual data is returned, instead
+ * of ClientBlocked.
+ *
+ * the first call to the function will cause the request to be sent to
+ * the font server, and a block record to be stored in the fpe's list
+ * of outstanding requests. the FS block handler also sticks the
+ * proper set of fd's into the select mask. when data is ready to be
+ * read in, the FS wakup handler will be hit. this will read the
+ * data off the wire into the proper block record, and then signal the
+ * client that caused the block so that it can restart. it will then
+ * call the access function again, which will realize that the data has
+ * arrived and return it.
+ */
+
+
+#ifdef DEBUG
+static void
+_fs_add_req_log(FSFpePtr conn, int opcode)
+{
+ conn->current_seq++;
+ fprintf (stderr, "\t\tRequest: %5d Opcode: %2d\n",
+ conn->current_seq, opcode);
+ conn->reqbuffer[conn->reqindex].opcode = opcode;
+ conn->reqbuffer[conn->reqindex].sequence = conn->current_seq;
+ conn->reqindex++;
+ if (conn->reqindex == REQUEST_LOG_SIZE)
+ conn->reqindex = 0;
+}
+
+static void
+_fs_add_rep_log (FSFpePtr conn, fsGenericReply *rep)
+{
+ int i;
+
+ for (i = 0; i < REQUEST_LOG_SIZE; i++)
+ if (conn->reqbuffer[i].sequence == rep->sequenceNumber)
+ break;
+ if (i == REQUEST_LOG_SIZE)
+ fprintf (stderr, "\t\t\t\t\tReply: %5d Opcode: unknown\n",
+ rep->sequenceNumber);
+ else
+ fprintf (stderr, "\t\t\t\t\tReply: %5d Opcode: %d\n",
+ rep->sequenceNumber,
+ conn->reqbuffer[i].opcode);
+}
+#else
+#define _fs_add_req_log(conn,op) ((conn)->current_seq++)
+#define _fs_add_rep_log(conn,rep)
+#endif
+
+static Bool
+fs_name_check(char *name)
+{
+#ifdef __UNIXOS2__
+ /* OS/2 uses D:/usr/X11R6/.... as fontfile pathnames, so check that
+ * there is not only a protocol/ prefix, but also that the first chars
+ * are not a drive letter
+ */
+ if (name && isalpha(*name) && name[1] == ':')
+ return FALSE;
+#endif
+ /* Just make sure there is a protocol/ prefix */
+ return (name && *name != '/' && strchr(name, '/'));
+}
+
+static void
+_fs_client_resolution(FSFpePtr conn)
+{
+ fsSetResolutionReq srreq;
+ int num_res;
+ FontResolutionPtr res;
+
+ res = GetClientResolutions(&num_res);
+
+ if (num_res) {
+ srreq.reqType = FS_SetResolution;
+ srreq.num_resolutions = num_res;
+ srreq.length = (SIZEOF(fsSetResolutionReq) +
+ (num_res * SIZEOF(fsResolution)) + 3) >> 2;
+
+ _fs_add_req_log(conn, FS_SetResolution);
+ if (_fs_write(conn, (char *) &srreq, SIZEOF(fsSetResolutionReq)) != -1)
+ (void)_fs_write_pad(conn, (char *) res,
+ (num_res * SIZEOF(fsResolution)));
+ }
+}
+
+/*
+ * close font server and remove any state associated with
+ * this connection - this includes any client records.
+ */
+
+static void
+fs_close_conn(FSFpePtr conn)
+{
+ FSClientPtr client, nclient;
+
+ _fs_close_server (conn);
+
+ for (client = conn->clients; client; client = nclient)
+ {
+ nclient = client->next;
+ xfree (client);
+ }
+ conn->clients = NULL;
+}
+
+/*
+ * the wakeup handlers have to be set when the FPE is open, and not
+ * removed until it is freed, in order to handle unexpected data, like
+ * events
+ */
+/* ARGSUSED */
+static int
+fs_init_fpe(FontPathElementPtr fpe)
+{
+ FSFpePtr conn;
+ char *name;
+ int err;
+ int ret;
+
+ /* open font server */
+ /* create FS specific fpe info */
+ name = fpe->name;
+
+ /* hack for old style names */
+ if (*name == ':')
+ name++; /* skip ':' */
+
+ conn = _fs_init_conn (name);
+ if (!conn)
+ err = AllocError;
+ else
+ {
+ err = init_fs_handlers (fpe, fs_block_handler);
+ if (err != Successful)
+ {
+ _fs_free_conn (conn);
+ err = AllocError;
+ }
+ else
+ {
+ fpe->private = conn;
+ conn->next = fs_fpes;
+ fs_fpes = conn;
+ ret = _fs_wait_connect (conn);
+ if (ret != FSIO_READY)
+ {
+ fs_free_fpe (fpe);
+ err = BadFontPath;
+ }
+ else
+ err = Successful;
+ }
+ }
+
+ if (err == Successful)
+ {
+#ifdef NCD
+ if (configData.ExtendedFontDiags)
+ printf("Connected to font server \"%s\"\n", name);
+#endif
+#ifdef DEBUG
+ fprintf (stderr, "connected to FS \"%s\"\n", name);
+#endif
+ }
+ else
+ {
+#ifdef DEBUG
+ fprintf(stderr, "failed to connect to FS \"%s\" %d\n", name, err);
+#endif
+#ifdef NCD
+ if (configData.ExtendedFontDiags)
+ printf("Failed to connect to font server \"%s\"\n", name);
+#endif
+ ;
+ }
+ return err;
+}
+
+static int
+fs_reset_fpe(FontPathElementPtr fpe)
+{
+ (void) _fs_send_init_packets((FSFpePtr) fpe->private);
+ return Successful;
+}
+
+/*
+ * this shouldn't be called till all refs to the FPE are gone
+ */
+
+static int
+fs_free_fpe(FontPathElementPtr fpe)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private, *prev;
+
+ /* unhook from chain of all font servers */
+ for (prev = &fs_fpes; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == conn)
+ {
+ *prev = conn->next;
+ break;
+ }
+ }
+ _fs_unmark_block (conn, conn->blockState);
+ fs_close_conn(conn);
+ remove_fs_handlers(fpe, fs_block_handler, fs_fpes == 0);
+ _fs_free_conn (conn);
+ fpe->private = (pointer) 0;
+
+#ifdef NCD
+ if (configData.ExtendedFontDiags)
+ printf("Disconnected from font server \"%s\"\n", fpe->name);
+#endif
+#ifdef DEBUG
+ fprintf (stderr, "disconnect from FS \"%s\"\n", fpe->name);
+#endif
+
+ return Successful;
+}
+
+static FSBlockDataPtr
+fs_new_block_rec(FontPathElementPtr fpe, pointer client, int type)
+{
+ FSBlockDataPtr blockrec,
+ *prev;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ int size;
+
+ switch (type) {
+ case FS_OPEN_FONT:
+ size = sizeof(FSBlockedFontRec);
+ break;
+ case FS_LOAD_GLYPHS:
+ size = sizeof(FSBlockedGlyphRec);
+ break;
+ case FS_LIST_FONTS:
+ size = sizeof(FSBlockedListRec);
+ break;
+ case FS_LIST_WITH_INFO:
+ size = sizeof(FSBlockedListInfoRec);
+ break;
+ default:
+ size = 0;
+ break;
+ }
+ blockrec = (FSBlockDataPtr) xalloc(sizeof(FSBlockDataRec) + size);
+ if (!blockrec)
+ return (FSBlockDataPtr) 0;
+ blockrec->data = (pointer) (blockrec + 1);
+ blockrec->client = client;
+ blockrec->sequenceNumber = -1;
+ blockrec->errcode = StillWorking;
+ blockrec->type = type;
+ blockrec->depending = 0;
+ blockrec->next = (FSBlockDataPtr) 0;
+
+ /* stick it on the end of the list (since its expected last) */
+ for (prev = &conn->blockedRequests; *prev; prev = &(*prev)->next)
+ ;
+ *prev = blockrec;
+
+ return blockrec;
+}
+
+static void
+_fs_set_pending_reply (FSFpePtr conn)
+{
+ FSBlockDataPtr blockrec;
+
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ if (blockrec->errcode == StillWorking)
+ break;
+ if (blockrec)
+ {
+ conn->blockedReplyTime = GetTimeInMillis () + FontServerRequestTimeout;
+ _fs_mark_block (conn, FS_PENDING_REPLY);
+ }
+ else
+ _fs_unmark_block (conn, FS_PENDING_REPLY);
+}
+
+static void
+_fs_remove_block_rec(FSFpePtr conn, FSBlockDataPtr blockrec)
+{
+ FSBlockDataPtr *prev;
+
+ for (prev = &conn->blockedRequests; *prev; prev = &(*prev)->next)
+ if (*prev == blockrec)
+ {
+ *prev = blockrec->next;
+ break;
+ }
+ if (blockrec->type == FS_LOAD_GLYPHS)
+ {
+ FSBlockedGlyphPtr bglyph = (FSBlockedGlyphPtr)blockrec->data;
+ if (bglyph->num_expected_ranges)
+ xfree(bglyph->expected_ranges);
+ }
+ xfree(blockrec);
+ _fs_set_pending_reply (conn);
+}
+
+static void
+_fs_signal_clients_depending(FSClientsDependingPtr *clients_depending)
+{
+ FSClientsDependingPtr p;
+
+ while ((p = *clients_depending))
+ {
+ *clients_depending = p->next;
+ ClientSignal(p->client);
+ xfree(p);
+ }
+}
+
+static int
+_fs_add_clients_depending(FSClientsDependingPtr *clients_depending, pointer client)
+{
+ FSClientsDependingPtr new, cd;
+
+ for (; (cd = *clients_depending);
+ clients_depending = &(*clients_depending)->next)
+ {
+ if (cd->client == client)
+ return Suspended;
+ }
+
+ new = (FSClientsDependingPtr)xalloc (sizeof (FSClientsDependingRec));
+ if (!new)
+ return BadAlloc;
+
+ new->client = client;
+ new->next = 0;
+ *clients_depending = new;
+ return Suspended;
+}
+
+/*
+ * When a request is aborted due to a font server failure,
+ * signal any depending clients to restart their dependant
+ * requests
+ */
+static void
+_fs_clean_aborted_blockrec(FSFpePtr conn, FSBlockDataPtr blockrec)
+{
+ switch(blockrec->type) {
+ case FS_OPEN_FONT: {
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr)blockrec->data;
+
+ fs_cleanup_bfont (bfont);
+ _fs_signal_clients_depending(&bfont->clients_depending);
+ break;
+ }
+ case FS_LOAD_GLYPHS: {
+ FSBlockedGlyphPtr bglyph = (FSBlockedGlyphPtr)blockrec->data;
+
+ _fs_clean_aborted_loadglyphs(bglyph->pfont,
+ bglyph->num_expected_ranges,
+ bglyph->expected_ranges);
+ _fs_signal_clients_depending(&bglyph->clients_depending);
+ break;
+ }
+ case FS_LIST_FONTS:
+ break;
+ case FS_LIST_WITH_INFO: {
+ FSBlockedListInfoPtr binfo;
+ binfo = (FSBlockedListInfoPtr) blockrec->data;
+ if (binfo->status == FS_LFWI_REPLY)
+ FD_SET(conn->fs_fd, &_fs_fd_mask);
+ _fs_free_props (&binfo->info);
+ }
+ default:
+ break;
+ }
+}
+
+static void
+fs_abort_blockrec(FSFpePtr conn, FSBlockDataPtr blockrec)
+{
+ _fs_clean_aborted_blockrec (conn, blockrec);
+ _fs_remove_block_rec (conn, blockrec);
+}
+
+/*
+ * Tell the font server we've failed to complete an open and
+ * then unload the partially created font
+ */
+static void
+fs_cleanup_bfont (FSBlockedFontPtr bfont)
+{
+ FSFontDataRec *fsd;
+
+ if (bfont->pfont)
+ {
+ fsd = (FSFontDataRec *) bfont->pfont->fpePrivate;
+
+ /* make sure the FS knows we choked on it */
+ fs_send_close_font(bfont->pfont->fpe, bfont->fontid);
+
+ /*
+ * Either unload the font if it's being opened for
+ * the first time, or smash the generation field to
+ * mark this font as an orphan
+ */
+ if (!(bfont->flags & FontReopen))
+ {
+ if (bfont->freeFont)
+ (*bfont->pfont->unload_font) (bfont->pfont);
+#ifdef DEBUG
+ else
+ fprintf (stderr, "Not freeing other font in cleanup_bfont\n");
+#endif
+ bfont->pfont = 0;
+ }
+ else
+ fsd->generation = -1;
+ }
+}
+
+/*
+ * Check to see if a complete reply is waiting
+ */
+static fsGenericReply *
+fs_get_reply (FSFpePtr conn, int *error)
+{
+ char *buf;
+ fsGenericReply *rep;
+ int ret;
+
+ /* block if the connection is down or paused in lfwi */
+ if (conn->fs_fd == -1 || !FD_ISSET (conn->fs_fd, &_fs_fd_mask))
+ {
+ *error = FSIO_BLOCK;
+ return 0;
+ }
+
+ ret = _fs_start_read (conn, sizeof (fsGenericReply), &buf);
+ if (ret != FSIO_READY)
+ {
+ *error = FSIO_BLOCK;
+ return 0;
+ }
+
+ rep = (fsGenericReply *) buf;
+
+ ret = _fs_start_read (conn, rep->length << 2, &buf);
+ if (ret != FSIO_READY)
+ {
+ *error = FSIO_BLOCK;
+ return 0;
+ }
+
+ *error = FSIO_READY;
+
+ return (fsGenericReply *) buf;
+}
+
+static Bool
+fs_reply_ready (FSFpePtr conn)
+{
+ fsGenericReply *rep;
+
+ if (conn->fs_fd == -1 || !FD_ISSET (conn->fs_fd, &_fs_fd_mask))
+ return FALSE;
+ if (fs_data_read (conn) < sizeof (fsGenericReply))
+ return FALSE;
+ rep = (fsGenericReply *) (conn->inBuf.buf + conn->inBuf.remove);
+ if (fs_data_read (conn) < rep->length << 2)
+ return FALSE;
+ return TRUE;
+}
+
+static void
+_fs_pending_reply (FSFpePtr conn)
+{
+ if (!(conn->blockState & FS_PENDING_REPLY))
+ {
+ _fs_mark_block (conn, FS_PENDING_REPLY);
+ conn->blockedReplyTime = GetTimeInMillis () + FontServerRequestTimeout;
+ }
+}
+
+static void
+_fs_prepare_for_reply (FSFpePtr conn)
+{
+ _fs_pending_reply (conn);
+ _fs_flush (conn);
+}
+
+/*
+ * Block (for a while) awaiting a complete reply
+ */
+static int
+fs_await_reply (FSFpePtr conn)
+{
+ int ret;
+
+ if (conn->blockState & FS_COMPLETE_REPLY)
+ return FSIO_READY;
+
+ while (!fs_get_reply (conn, &ret))
+ {
+ if (ret != FSIO_BLOCK)
+ return ret;
+ if (_fs_wait_for_readable (conn, FontServerRequestTimeout) != FSIO_READY)
+ {
+ _fs_connection_died (conn);
+ return FSIO_ERROR;
+ }
+ }
+ return FSIO_READY;
+}
+
+/*
+ * Process the reply to an OpenBitmapFont request
+ */
+static int
+fs_read_open_font(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
+ fsOpenBitmapFontReply *rep;
+ FSBlockDataPtr blockOrig;
+ FSBlockedFontPtr origBfont;
+ int ret;
+
+ rep = (fsOpenBitmapFontReply *) fs_get_reply (conn, &ret);
+ if (!rep || rep->type == FS_Error)
+ {
+ if (ret == FSIO_BLOCK)
+ return StillWorking;
+ if (rep)
+ _fs_done_read (conn, rep->length << 2);
+ fs_cleanup_bfont (bfont);
+ return BadFontName;
+ }
+
+ /* If we're not reopening a font and FS detected a duplicate font
+ open request, replace our reference to the new font with a
+ reference to an existing font (possibly one not finished
+ opening). If this is a reopen, keep the new font reference...
+ it's got the metrics and extents we read when the font was opened
+ before. This also gives us the freedom to easily close the font
+ if we we decide (in fs_read_query_info()) that we don't like what
+ we got. */
+
+ if (rep->otherid && !(bfont->flags & FontReopen))
+ {
+ fs_cleanup_bfont (bfont);
+
+ /* Find old font if we're completely done getting it from server. */
+ bfont->pfont = find_old_font(rep->otherid);
+ bfont->freeFont = FALSE;
+ bfont->fontid = rep->otherid;
+ bfont->state = FS_DONE_REPLY;
+ /*
+ * look for a blocked request to open the same font
+ */
+ for (blockOrig = conn->blockedRequests;
+ blockOrig;
+ blockOrig = blockOrig->next)
+ {
+ if (blockOrig != blockrec && blockOrig->type == FS_OPEN_FONT)
+ {
+ origBfont = (FSBlockedFontPtr) blockOrig->data;
+ if (origBfont->fontid == rep->otherid)
+ {
+ blockrec->depending = blockOrig->depending;
+ blockOrig->depending = blockrec;
+ bfont->state = FS_DEPENDING;
+ bfont->pfont = origBfont->pfont;
+ break;
+ }
+ }
+ }
+ if (bfont->pfont == NULL)
+ {
+ /* XXX - something nasty happened */
+ ret = BadFontName;
+ }
+ else
+ ret = AccessDone;
+ }
+ else
+ {
+ bfont->pfont->info.cachable = rep->cachable != 0;
+ bfont->state = FS_INFO_REPLY;
+ /*
+ * Reset the blockrec for the next reply
+ */
+ blockrec->sequenceNumber = bfont->queryInfoSequence;
+ conn->blockedReplyTime = GetTimeInMillis () + FontServerRequestTimeout;
+ ret = StillWorking;
+ }
+ _fs_done_read (conn, rep->length << 2);
+ return ret;
+}
+
+static Bool
+fs_fonts_match (FontInfoPtr pInfo1, FontInfoPtr pInfo2)
+{
+ int i;
+
+ if (pInfo1->firstCol != pInfo2->firstCol ||
+ pInfo1->lastCol != pInfo2->lastCol ||
+ pInfo1->firstRow != pInfo2->firstRow ||
+ pInfo1->lastRow != pInfo2->lastRow ||
+ pInfo1->defaultCh != pInfo2->defaultCh ||
+ pInfo1->noOverlap != pInfo2->noOverlap ||
+ pInfo1->terminalFont != pInfo2->terminalFont ||
+ pInfo1->constantMetrics != pInfo2->constantMetrics ||
+ pInfo1->constantWidth != pInfo2->constantWidth ||
+ pInfo1->inkInside != pInfo2->inkInside ||
+ pInfo1->inkMetrics != pInfo2->inkMetrics ||
+ pInfo1->allExist != pInfo2->allExist ||
+ pInfo1->drawDirection != pInfo2->drawDirection ||
+ pInfo1->cachable != pInfo2->cachable ||
+ pInfo1->anamorphic != pInfo2->anamorphic ||
+ pInfo1->maxOverlap != pInfo2->maxOverlap ||
+ pInfo1->fontAscent != pInfo2->fontAscent ||
+ pInfo1->fontDescent != pInfo2->fontDescent ||
+ pInfo1->nprops != pInfo2->nprops)
+ return FALSE;
+
+#define MATCH(xci1, xci2) \
+ (((xci1).leftSideBearing == (xci2).leftSideBearing) && \
+ ((xci1).rightSideBearing == (xci2).rightSideBearing) && \
+ ((xci1).characterWidth == (xci2).characterWidth) && \
+ ((xci1).ascent == (xci2).ascent) && \
+ ((xci1).descent == (xci2).descent) && \
+ ((xci1).attributes == (xci2).attributes))
+
+ if (!MATCH(pInfo1->maxbounds, pInfo2->maxbounds) ||
+ !MATCH(pInfo1->minbounds, pInfo2->minbounds) ||
+ !MATCH(pInfo1->ink_maxbounds, pInfo2->ink_maxbounds) ||
+ !MATCH(pInfo1->ink_minbounds, pInfo2->ink_minbounds))
+ return FALSE;
+
+#undef MATCH
+
+ for (i = 0; i < pInfo1->nprops; i++)
+ if (pInfo1->isStringProp[i] !=
+ pInfo2->isStringProp[i] ||
+ pInfo1->props[i].name !=
+ pInfo2->props[i].name ||
+ pInfo1->props[i].value !=
+ pInfo2->props[i].value)
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static int
+fs_read_query_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
+{
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ fsQueryXInfoReply *rep;
+ char *buf;
+ fsPropInfo *pi;
+ fsPropOffset *po;
+ pointer pd;
+ FontInfoPtr pInfo;
+ FontInfoRec tempInfo;
+ int err;
+ int ret;
+
+ rep = (fsQueryXInfoReply *) fs_get_reply (conn, &ret);
+ if (!rep || rep->type == FS_Error)
+ {
+ if (ret == FSIO_BLOCK)
+ return StillWorking;
+ if (rep)
+ _fs_done_read (conn, rep->length << 2);
+ fs_cleanup_bfont (bfont);
+ return BadFontName;
+ }
+
+ /* If this is a reopen, accumulate the query info into a dummy
+ font and compare to our original data. */
+ if (bfont->flags & FontReopen)
+ pInfo = &tempInfo;
+ else
+ pInfo = &bfont->pfont->info;
+
+ buf = (char *) rep;
+ buf += SIZEOF(fsQueryXInfoReply);
+
+ /* move the data over */
+ fsUnpack_XFontInfoHeader(rep, pInfo);
+
+ /* compute accelerators */
+ _fs_init_fontinfo(conn, pInfo);
+
+ /* Compute offsets into the reply */
+ pi = (fsPropInfo *) buf;
+ buf += SIZEOF (fsPropInfo);
+
+ po = (fsPropOffset *) buf;
+ buf += pi->num_offsets * SIZEOF(fsPropOffset);
+
+ pd = (pointer) buf;
+ buf += pi->data_len;
+
+ /* convert the properties and step over the reply */
+ ret = _fs_convert_props(pi, po, pd, pInfo);
+ _fs_done_read (conn, rep->length << 2);
+
+ if (ret == -1)
+ {
+ fs_cleanup_bfont (bfont);
+ return AllocError;
+ }
+
+ if (bfont->flags & FontReopen)
+ {
+ /* We're reopening a font that we lost because of a downed
+ connection. In the interest of avoiding corruption from
+ opening a different font than the old one (we already have
+ its metrics, extents, and probably some of its glyphs),
+ verify that the metrics and properties all match. */
+
+ if (fs_fonts_match (pInfo, &bfont->pfont->info))
+ {
+ err = Successful;
+ bfont->state = FS_DONE_REPLY;
+ }
+ else
+ {
+ fs_cleanup_bfont (bfont);
+ err = BadFontName;
+ }
+ _fs_free_props (pInfo);
+
+ return err;
+ }
+
+ /*
+ * Ask for terminal format fonts if possible
+ */
+ if (bfont->pfont->info.terminalFont)
+ bfont->format = ((bfont->format & ~ (BitmapFormatImageRectMask)) |
+ BitmapFormatImageRectMax);
+
+ /*
+ * Figure out if the whole font should get loaded right now.
+ */
+ if (glyphCachingMode == CACHING_OFF ||
+ (glyphCachingMode == CACHE_16_BIT_GLYPHS
+ && !bfont->pfont->info.lastRow))
+ {
+ bfont->flags |= FontLoadAll;
+ }
+
+ /*
+ * Ready to send the query bitmaps; the terminal font bit has
+ * been computed and glyphCaching has been considered
+ */
+ if (bfont->flags & FontLoadBitmaps)
+ {
+ fs_send_query_bitmaps (fpe, blockrec);
+ _fs_flush (conn);
+ }
+
+ bfont->state = FS_EXTENT_REPLY;
+
+ /*
+ * Reset the blockrec for the next reply
+ */
+ blockrec->sequenceNumber = bfont->queryExtentsSequence;
+ conn->blockedReplyTime = GetTimeInMillis () + FontServerRequestTimeout;
+
+ return StillWorking;
+}
+
+static int
+fs_read_extent_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
+ FSFontDataPtr fsd = (FSFontDataPtr) bfont->pfont->fpePrivate;
+ FSFontPtr fsfont = (FSFontPtr) bfont->pfont->fontPrivate;
+ fsQueryXExtents16Reply *rep;
+ char *buf;
+ int i;
+ int numExtents;
+ int numInfos;
+ int ret;
+ Bool haveInk = FALSE; /* need separate ink metrics? */
+ CharInfoPtr ci, pCI;
+ char *fsci;
+ fsXCharInfo fscilocal;
+ FontInfoRec *fi = &bfont->pfont->info;
+
+ rep = (fsQueryXExtents16Reply *) fs_get_reply (conn, &ret);
+ if (!rep || rep->type == FS_Error)
+ {
+ if (ret == FSIO_BLOCK)
+ return StillWorking;
+ if (rep)
+ _fs_done_read (conn, rep->length << 2);
+ fs_cleanup_bfont (bfont);
+ return BadFontName;
+ }
+
+ /* move the data over */
+ /* need separate inkMetrics for fixed font server protocol version */
+ numExtents = rep->num_extents;
+ numInfos = numExtents;
+ if (bfont->pfont->info.terminalFont && conn->fsMajorVersion > 1)
+ {
+ numInfos *= 2;
+ haveInk = TRUE;
+ }
+ ci = pCI = (CharInfoPtr) xalloc(sizeof(CharInfoRec) * numInfos);
+
+ if (!pCI)
+ {
+ _fs_done_read (conn, rep->length << 2);
+ fs_cleanup_bfont(bfont);
+ return AllocError;
+ }
+ fsfont->encoding = pCI;
+ if (haveInk)
+ fsfont->inkMetrics = pCI + numExtents;
+ else
+ fsfont->inkMetrics = pCI;
+
+ buf = (char *) rep;
+ buf += SIZEOF (fsQueryXExtents16Reply);
+ fsci = buf;
+
+ fsd->glyphs_to_get = 0;
+ ci = fsfont->inkMetrics;
+ for (i = 0; i < numExtents; i++)
+ {
+ memcpy(&fscilocal, fsci, SIZEOF(fsXCharInfo)); /* align it */
+ _fs_convert_char_info(&fscilocal, &ci->metrics);
+ /* Bounds check. */
+ if (ci->metrics.ascent > fi->maxbounds.ascent)
+ {
+ ErrorF("fserve: warning: %s %s ascent (%d) > maxascent (%d)\n",
+ fpe->name, fsd->name,
+ ci->metrics.ascent, fi->maxbounds.ascent);
+ ci->metrics.ascent = fi->maxbounds.ascent;
+ }
+ if (ci->metrics.descent > fi->maxbounds.descent)
+ {
+ ErrorF("fserve: warning: %s %s descent (%d) > maxdescent (%d)\n",
+ fpe->name, fsd->name,
+ ci->metrics.descent, fi->maxbounds.descent);
+ ci->metrics.descent = fi->maxbounds.descent;
+ }
+ fsci = fsci + SIZEOF(fsXCharInfo);
+ /* Initialize the bits field for later glyph-caching use */
+ if (NONZEROMETRICS(&ci->metrics))
+ {
+ if (!haveInk &&
+ (ci->metrics.leftSideBearing == ci->metrics.rightSideBearing ||
+ ci->metrics.ascent == -ci->metrics.descent))
+ pCI[i].bits = &_fs_glyph_zero_length;
+ else
+ {
+ pCI[i].bits = &_fs_glyph_undefined;
+ fsd->glyphs_to_get++;
+ }
+ }
+ else
+ pCI[i].bits = (char *)0;
+ ci++;
+ }
+
+ /* Done with reply */
+ _fs_done_read (conn, rep->length << 2);
+
+ /* build bitmap metrics, ImageRectMax style */
+ if (haveInk)
+ {
+ CharInfoPtr ii;
+
+ ci = fsfont->encoding;
+ ii = fsfont->inkMetrics;
+ for (i = 0; i < numExtents; i++, ci++, ii++)
+ {
+ if (NONZEROMETRICS(&ii->metrics))
+ {
+ ci->metrics.leftSideBearing = FONT_MIN_LEFT(fi);
+ ci->metrics.rightSideBearing = FONT_MAX_RIGHT(fi);
+ ci->metrics.ascent = FONT_MAX_ASCENT(fi);
+ ci->metrics.descent = FONT_MAX_DESCENT(fi);
+ ci->metrics.characterWidth = FONT_MAX_WIDTH(fi);
+ ci->metrics.attributes = ii->metrics.attributes;
+ }
+ else
+ {
+ ci->metrics = ii->metrics;
+ }
+ /* Bounds check. */
+ if (ci->metrics.ascent > fi->maxbounds.ascent)
+ {
+ ErrorF("fserve: warning: %s %s ascent (%d) "
+ "> maxascent (%d)\n",
+ fpe->name, fsd->name,
+ ci->metrics.ascent, fi->maxbounds.ascent);
+ ci->metrics.ascent = fi->maxbounds.ascent;
+ }
+ if (ci->metrics.descent > fi->maxbounds.descent)
+ {
+ ErrorF("fserve: warning: %s %s descent (%d) "
+ "> maxdescent (%d)\n",
+ fpe->name, fsd->name,
+ ci->metrics.descent, fi->maxbounds.descent);
+ ci->metrics.descent = fi->maxbounds.descent;
+ }
+ }
+ }
+ {
+ unsigned int r, c, numCols, firstCol;
+
+ firstCol = bfont->pfont->info.firstCol;
+ numCols = bfont->pfont->info.lastCol - firstCol + 1;
+ c = bfont->pfont->info.defaultCh;
+ fsfont->pDefault = 0;
+ if (bfont->pfont->info.lastRow)
+ {
+ r = c >> 8;
+ r -= bfont->pfont->info.firstRow;
+ c &= 0xff;
+ c -= firstCol;
+ if (r < bfont->pfont->info.lastRow-bfont->pfont->info.firstRow+1 &&
+ c < numCols)
+ fsfont->pDefault = &pCI[r * numCols + c];
+ }
+ else
+ {
+ c -= firstCol;
+ if (c < numCols)
+ fsfont->pDefault = &pCI[c];
+ }
+ }
+ bfont->state = FS_GLYPHS_REPLY;
+
+ if (bfont->flags & FontLoadBitmaps)
+ {
+ /*
+ * Reset the blockrec for the next reply
+ */
+ blockrec->sequenceNumber = bfont->queryBitmapsSequence;
+ conn->blockedReplyTime = GetTimeInMillis () + FontServerRequestTimeout;
+ return StillWorking;
+ }
+ return Successful;
+}
+
+#ifdef DEBUG
+static char *fs_open_states[] = {
+ "OPEN_REPLY ",
+ "INFO_REPLY ",
+ "EXTENT_REPLY",
+ "GLYPHS_REPLY",
+ "DONE_REPLY ",
+ "DEPENDING ",
+};
+#endif
+
+static int
+fs_do_open_font(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
+{
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
+ int err;
+
+#ifdef DEBUG
+ fprintf (stderr, "fs_do_open_font state %s %s\n",
+ fs_open_states[bfont->state],
+ ((FSFontDataPtr) (bfont->pfont->fpePrivate))->name);
+#endif
+ err = BadFontName;
+ switch (bfont->state) {
+ case FS_OPEN_REPLY:
+ err = fs_read_open_font(fpe, blockrec);
+ if (err != StillWorking) { /* already loaded, or error */
+ /* if font's already loaded, massage error code */
+ switch (bfont->state) {
+ case FS_DONE_REPLY:
+ err = Successful;
+ break;
+ case FS_DEPENDING:
+ err = StillWorking;
+ break;
+ }
+ }
+ break;
+ case FS_INFO_REPLY:
+ err = fs_read_query_info(fpe, blockrec);
+ break;
+ case FS_EXTENT_REPLY:
+ err = fs_read_extent_info(fpe, blockrec);
+ break;
+ case FS_GLYPHS_REPLY:
+ if (bfont->flags & FontLoadBitmaps)
+ err = fs_read_glyphs(fpe, blockrec);
+ break;
+ case FS_DEPENDING: /* can't happen */
+ default:
+ break;
+ }
+#ifdef DEBUG
+ fprintf (stderr, "fs_do_open_font err %d\n", err);
+#endif
+ if (err != StillWorking)
+ {
+ bfont->state = FS_DONE_REPLY; /* for _fs_load_glyphs() */
+ while ((blockrec = blockrec->depending))
+ {
+ bfont = (FSBlockedFontPtr) blockrec->data;
+ bfont->state = FS_DONE_REPLY; /* for _fs_load_glyphs() */
+ }
+ }
+ return err;
+}
+
+void
+_fs_mark_block (FSFpePtr conn, CARD32 mask)
+{
+ conn->blockState |= mask;
+ fs_blockState |= mask;
+}
+
+void
+_fs_unmark_block (FSFpePtr conn, CARD32 mask)
+{
+ FSFpePtr c;
+
+ if (conn->blockState & mask)
+ {
+ conn->blockState &= ~mask;
+ fs_blockState = 0;
+ for (c = fs_fpes; c; c = c->next)
+ fs_blockState |= c->blockState;
+ }
+}
+
+/* ARGSUSED */
+static void
+fs_block_handler(pointer data, OSTimePtr wt, pointer LastSelectMask)
+{
+ static struct timeval block_timeout;
+ CARD32 now, earliest, wakeup;
+ int soonest;
+ FSFpePtr conn;
+
+ XFD_ORSET((fd_set *)LastSelectMask, (fd_set *)LastSelectMask,
+ &_fs_fd_mask);
+ /*
+ * Flush all pending output
+ */
+ if (fs_blockState & FS_PENDING_WRITE)
+ for (conn = fs_fpes; conn; conn = conn->next)
+ if (conn->blockState & FS_PENDING_WRITE)
+ _fs_flush (conn);
+ /*
+ * Check for any fpe with a complete reply, set sleep time to zero
+ */
+ if (fs_blockState & FS_COMPLETE_REPLY)
+ {
+ block_timeout.tv_sec = 0;
+ block_timeout.tv_usec = 0;
+ if (*wt == NULL)
+ *wt = &block_timeout;
+ else
+ **wt = block_timeout;
+ }
+ /*
+ * Walk through fpe list computing sleep time
+ */
+ else if (fs_blockState & (FS_BROKEN_WRITE|
+ FS_BROKEN_CONNECTION|
+ FS_PENDING_REPLY|
+ FS_RECONNECTING))
+ {
+ now = GetTimeInMillis ();
+ earliest = now + 10000000;
+ for (conn = fs_fpes; conn; conn = conn->next)
+ {
+ if (conn->blockState & FS_RECONNECTING)
+ {
+ wakeup = conn->blockedConnectTime;
+ if (TimeCmp (wakeup, <, earliest))
+ earliest = wakeup;
+ }
+ if (conn->blockState & FS_BROKEN_CONNECTION)
+ {
+ wakeup = conn->brokenConnectionTime;
+ if (TimeCmp (wakeup, <, earliest))
+ earliest = wakeup;
+ }
+ if (conn->blockState & FS_BROKEN_WRITE)
+ {
+ wakeup = conn->brokenWriteTime;
+ if (TimeCmp (wakeup, <, earliest))
+ earliest = wakeup;
+ }
+ if (conn->blockState & FS_PENDING_REPLY)
+ {
+ wakeup = conn->blockedReplyTime;
+ if (TimeCmp (wakeup, <, earliest))
+ earliest = wakeup;
+ }
+ }
+ soonest = earliest - now;
+ if (soonest < 0)
+ soonest = 0;
+ block_timeout.tv_sec = soonest / 1000;
+ block_timeout.tv_usec = (soonest % 1000) * 1000;
+ if (*wt == NULL)
+ *wt = &block_timeout;
+ else if (soonest < (*wt)->tv_sec * 1000 + (*wt)->tv_usec / 1000)
+ **wt = block_timeout;
+ }
+}
+
+static void
+fs_handle_unexpected(FSFpePtr conn, fsGenericReply *rep)
+{
+ if (rep->type == FS_Event && rep->data1 == KeepAlive)
+ {
+ fsNoopReq req;
+
+ /* ping it back */
+ req.reqType = FS_Noop;
+ req.length = SIZEOF(fsNoopReq) >> 2;
+ _fs_add_req_log(conn, FS_Noop);
+ _fs_write(conn, (char *) &req, SIZEOF(fsNoopReq));
+ }
+ /* this should suck up unexpected replies and events */
+ _fs_done_read (conn, rep->length << 2);
+}
+
+static void
+fs_read_reply (FontPathElementPtr fpe, pointer client)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec;
+ int ret;
+ int err;
+ fsGenericReply *rep;
+
+ if ((rep = fs_get_reply (conn, &ret)))
+ {
+ _fs_add_rep_log (conn, rep);
+ for (blockrec = conn->blockedRequests;
+ blockrec;
+ blockrec = blockrec->next)
+ {
+ if (blockrec->sequenceNumber == rep->sequenceNumber)
+ break;
+ }
+ err = Successful;
+ if (!blockrec)
+ {
+ fs_handle_unexpected(conn, rep);
+ }
+ else
+ {
+ /*
+ * go read it, and if we're done,
+ * wake up the appropriate client
+ */
+ switch (blockrec->type) {
+ case FS_OPEN_FONT:
+ blockrec->errcode = fs_do_open_font(fpe, blockrec);
+ break;
+ case FS_LOAD_GLYPHS:
+ blockrec->errcode = fs_read_glyphs(fpe, blockrec);
+ break;
+ case FS_LIST_FONTS:
+ blockrec->errcode = fs_read_list(fpe, blockrec);
+ break;
+ case FS_LIST_WITH_INFO:
+ blockrec->errcode = fs_read_list_info(fpe, blockrec);
+ break;
+ default:
+ break;
+ }
+ err = blockrec->errcode;
+ if (err != StillWorking)
+ {
+ while (blockrec)
+ {
+ blockrec->errcode = err;
+ if (client != blockrec->client)
+ ClientSignal(blockrec->client);
+ blockrec = blockrec->depending;
+ }
+ _fs_unmark_block (conn, FS_PENDING_REPLY);
+ }
+ }
+ if (fs_reply_ready (conn))
+ _fs_mark_block (conn, FS_COMPLETE_REPLY);
+ else
+ _fs_unmark_block (conn, FS_COMPLETE_REPLY);
+ }
+}
+
+static int
+fs_wakeup(FontPathElementPtr fpe, unsigned long *mask)
+{
+ fd_set *LastSelectMask = (fd_set *) mask;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+
+ /*
+ * Don't continue if the fd is -1 (which will be true when the
+ * font server terminates
+ */
+ if ((conn->blockState & FS_RECONNECTING))
+ _fs_check_reconnect (conn);
+ else if ((conn->blockState & FS_COMPLETE_REPLY) ||
+ (conn->fs_fd != -1 && FD_ISSET(conn->fs_fd, LastSelectMask)))
+ fs_read_reply (fpe, 0);
+ if (conn->blockState & (FS_PENDING_REPLY|FS_BROKEN_CONNECTION|FS_BROKEN_WRITE))
+ _fs_do_blocked (conn);
+#ifdef DEBUG
+ {
+ FSBlockDataPtr blockrec;
+ FSBlockedFontPtr bfont;
+ FSBlockedListPtr blist;
+ static CARD32 lastState;
+ static FSBlockDataPtr lastBlock;
+
+ if (conn->blockState || conn->blockedRequests || lastState || lastBlock)
+ {
+ fprintf (stderr, " Block State 0x%x\n", (int) conn->blockState);
+ lastState = conn->blockState;
+ lastBlock = conn->blockedRequests;
+ }
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ {
+ switch (blockrec->type) {
+ case FS_OPEN_FONT:
+ bfont = (FSBlockedFontPtr) blockrec->data;
+ fprintf (stderr, " Blocked font errcode %d sequence %d state %s %s\n",
+ blockrec->errcode,
+ blockrec->sequenceNumber,
+ fs_open_states[bfont->state],
+ bfont->pfont ?
+ ((FSFontDataPtr) (bfont->pfont->fpePrivate))->name :
+ "<freed>");
+ break;
+ case FS_LIST_FONTS:
+ blist = (FSBlockedListPtr) blockrec->data;
+ fprintf (stderr, " Blocked list errcode %d sequence %d\n",
+ blockrec->errcode, blockrec->sequenceNumber);
+ break;
+ default:
+ fprintf (stderr, " Blocked type %d errcode %d sequence %d\n",
+ blockrec->type,
+ blockrec->errcode,
+ blockrec->sequenceNumber);
+ break;
+ }
+ }
+ }
+#endif
+ return FALSE;
+}
+
+/*
+ * Notice a dead connection and prepare for reconnect
+ */
+
+void
+_fs_connection_died(FSFpePtr conn)
+{
+ if (conn->blockState & FS_BROKEN_CONNECTION)
+ return;
+ fs_close_conn(conn);
+ conn->brokenConnectionTime = GetTimeInMillis ();
+ _fs_mark_block (conn, FS_BROKEN_CONNECTION);
+ _fs_unmark_block (conn, FS_BROKEN_WRITE|FS_PENDING_WRITE|FS_RECONNECTING);
+}
+
+/*
+ * Signal clients that the connection has come back up
+ */
+static int
+_fs_restart_connection(FSFpePtr conn)
+{
+ FSBlockDataPtr block;
+
+ _fs_unmark_block (conn, FS_GIVE_UP);
+ while ((block = (FSBlockDataPtr) conn->blockedRequests))
+ {
+ if (block->errcode == StillWorking)
+ {
+ ClientSignal(block->client);
+ fs_abort_blockrec(conn, block);
+ }
+ }
+ return TRUE;
+}
+
+/*
+ * Declare this font server connection useless
+ */
+static void
+_fs_giveup (FSFpePtr conn)
+{
+ FSBlockDataPtr block;
+
+ if (conn->blockState & FS_GIVE_UP)
+ return;
+#ifdef DEBUG
+ fprintf (stderr, "give up on FS \"%s\"\n", conn->servername);
+#endif
+ _fs_mark_block (conn, FS_GIVE_UP);
+ while ((block = (FSBlockDataPtr) conn->blockedRequests))
+ {
+ if (block->errcode == StillWorking)
+ {
+ ClientSignal (block->client);
+ fs_abort_blockrec (conn, block);
+ }
+ }
+ if (conn->fs_fd >= 0)
+ _fs_connection_died (conn);
+}
+
+static void
+_fs_do_blocked (FSFpePtr conn)
+{
+ CARD32 now;
+
+ now = GetTimeInMillis ();
+ if ((conn->blockState & FS_PENDING_REPLY) &&
+ TimeCmp (conn->blockedReplyTime, <=, now))
+ {
+ _fs_giveup (conn);
+ }
+ else
+ {
+ if (conn->blockState & FS_BROKEN_CONNECTION)
+ {
+ /* Try to reconnect broken connections */
+ if (TimeCmp (conn->brokenConnectionTime, <=, now))
+ _fs_start_reconnect (conn);
+ }
+ else if (conn->blockState & FS_BROKEN_WRITE)
+ {
+ /* Try to flush blocked connections */
+ if (TimeCmp (conn->brokenWriteTime, <=, now))
+ _fs_flush (conn);
+ }
+ }
+}
+
+/*
+ * sends the actual request out
+ */
+/* ARGSUSED */
+static int
+fs_send_open_font(pointer client, FontPathElementPtr fpe, Mask flags,
+ char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *ppfont)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FontPtr font;
+ FSBlockDataPtr blockrec = NULL;
+ FSBlockedFontPtr bfont;
+ FSFontDataPtr fsd;
+ fsOpenBitmapFontReq openreq;
+ fsQueryXInfoReq inforeq;
+ fsQueryXExtents16Req extreq;
+ int err;
+ unsigned char buf[1024];
+
+ if (conn->blockState & FS_GIVE_UP)
+ return BadFontName;
+
+ if (namelen <= 0 || namelen > sizeof (buf) - 1)
+ return BadFontName;
+
+ /*
+ * Get the font structure put together, either by reusing
+ * the existing one or creating a new one
+ */
+ if (flags & FontReopen)
+ {
+ Atom nameatom, fn = None;
+ int i;
+
+ font = *ppfont;
+ fsd = (FSFontDataPtr)font->fpePrivate;
+ /* This is an attempt to reopen a font. Did the font have a
+ NAME property? */
+ if ((nameatom = MakeAtom("FONT", 4, 0)) != None)
+ {
+ for (i = 0; i < font->info.nprops; i++)
+ if (font->info.props[i].name == nameatom &&
+ font->info.isStringProp[i])
+ {
+ fn = font->info.props[i].value;
+ break;
+ }
+ }
+ if (fn == None || !(name = NameForAtom(fn)))
+ {
+ name = fsd->name;
+ namelen = fsd->namelen;
+ }
+ else
+ namelen = strlen(name);
+ }
+ else
+ {
+ font = fs_create_font (fpe, name, namelen, format, fmask);
+ if (!font)
+ return AllocError;
+
+ fsd = (FSFontDataPtr)font->fpePrivate;
+ }
+
+ /* make a new block record, and add it to the end of the list */
+ blockrec = fs_new_block_rec(font->fpe, client, FS_OPEN_FONT);
+ if (!blockrec)
+ {
+ if (!(flags & FontReopen))
+ (*font->unload_font) (font);
+ return AllocError;
+ }
+
+ /*
+ * Must check this before generating any protocol, otherwise we'll
+ * mess up a reconnect in progress
+ */
+ if (conn->blockState & (FS_BROKEN_CONNECTION | FS_RECONNECTING))
+ {
+ _fs_pending_reply (conn);
+ return Suspended;
+ }
+
+ fsd->generation = conn->generation;
+
+ bfont = (FSBlockedFontPtr) blockrec->data;
+ bfont->fontid = fsd->fontid;
+ bfont->pfont = font;
+ bfont->state = FS_OPEN_REPLY;
+ bfont->flags = flags;
+ bfont->format = fsd->format;
+ bfont->clients_depending = (FSClientsDependingPtr)0;
+ bfont->freeFont = (flags & FontReopen) == 0;
+
+ _fs_client_access (conn, client, (flags & FontOpenSync) != 0);
+ _fs_client_resolution(conn);
+
+ /* do an FS_OpenFont, FS_QueryXInfo and FS_QueryXExtents */
+ buf[0] = (unsigned char) namelen;
+ memcpy(&buf[1], name, namelen);
+ openreq.reqType = FS_OpenBitmapFont;
+ openreq.fid = fsd->fontid;
+ openreq.format_hint = fsd->format;
+ openreq.format_mask = fsd->fmask;
+ openreq.length = (SIZEOF(fsOpenBitmapFontReq) + namelen + 4) >> 2;
+
+ _fs_add_req_log(conn, FS_OpenBitmapFont);
+ _fs_write(conn, (char *) &openreq, SIZEOF(fsOpenBitmapFontReq));
+ _fs_write_pad(conn, (char *) buf, namelen + 1);
+
+ blockrec->sequenceNumber = conn->current_seq;
+
+ inforeq.reqType = FS_QueryXInfo;
+ inforeq.id = fsd->fontid;
+ inforeq.length = SIZEOF(fsQueryXInfoReq) >> 2;
+
+ bfont->queryInfoSequence = conn->current_seq + 1;
+
+ _fs_add_req_log(conn, FS_QueryXInfo);
+ _fs_write(conn, (char *) &inforeq, SIZEOF(fsQueryXInfoReq));
+
+ if (!(bfont->flags & FontReopen))
+ {
+ extreq.reqType = FS_QueryXExtents16;
+ extreq.range = fsTrue;
+ extreq.fid = fsd->fontid;
+ extreq.num_ranges = 0;
+ extreq.length = SIZEOF(fsQueryXExtents16Req) >> 2;
+
+ bfont->queryExtentsSequence = conn->current_seq + 1;
+
+ _fs_add_req_log(conn, FS_QueryXExtents16);
+ _fs_write(conn, (char *) &extreq, SIZEOF(fsQueryXExtents16Req));
+ }
+
+#ifdef NCD
+ if (configData.ExtendedFontDiags)
+ {
+ memcpy(buf, name, MIN(256, namelen));
+ buf[MIN(256, namelen)] = '\0';
+ printf("Requesting font \"%s\" from font server \"%s\"\n",
+ buf, font->fpe->name);
+ }
+#endif
+ _fs_prepare_for_reply (conn);
+
+ err = blockrec->errcode;
+ if (bfont->flags & FontOpenSync)
+ {
+ while (blockrec->errcode == StillWorking)
+ {
+ if (fs_await_reply (conn) != FSIO_READY)
+ {
+ blockrec->errcode = BadFontName;
+ break;
+ }
+ fs_read_reply (font->fpe, client);
+ }
+ err = blockrec->errcode;
+ if (err == Successful)
+ *ppfont = bfont->pfont;
+ else
+ fs_cleanup_bfont (bfont);
+ bfont->freeFont = FALSE;
+ _fs_remove_block_rec (conn, blockrec);
+ }
+ return err == StillWorking ? Suspended : err;
+}
+
+static void
+fs_send_query_bitmaps(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
+ fsQueryXBitmaps16Req bitreq;
+
+ /* send the request */
+ bitreq.reqType = FS_QueryXBitmaps16;
+ bitreq.fid = bfont->fontid;
+ bitreq.format = bfont->format;
+ bitreq.range = TRUE;
+ bitreq.length = SIZEOF(fsQueryXBitmaps16Req) >> 2;
+ bitreq.num_ranges = 0;
+
+ bfont->queryBitmapsSequence = conn->current_seq + 1;
+
+ _fs_add_req_log(conn, FS_QueryXBitmaps16);
+ _fs_write(conn, (char *) &bitreq, SIZEOF(fsQueryXBitmaps16Req));
+}
+
+/* ARGSUSED */
+static int
+fs_open_font(pointer client, FontPathElementPtr fpe, Mask flags,
+ char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *ppfont,
+ char **alias, FontPtr non_cachable_font)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec;
+ FSBlockedFontPtr bfont;
+ int err;
+
+ /* libfont interface expects ImageRectMin glyphs */
+ format = (format & ~BitmapFormatImageRectMask) | BitmapFormatImageRectMin;
+
+ *alias = (char *) 0;
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ {
+ if (blockrec->type == FS_OPEN_FONT && blockrec->client == client)
+ {
+ err = blockrec->errcode;
+ if (err == StillWorking)
+ return Suspended;
+
+ bfont = (FSBlockedFontPtr) blockrec->data;
+ if (err == Successful)
+ *ppfont = bfont->pfont;
+ else
+ fs_cleanup_bfont (bfont);
+ _fs_remove_block_rec (conn, blockrec);
+ return err;
+ }
+ }
+ return fs_send_open_font(client, fpe, flags, name, namelen, format, fmask,
+ id, ppfont);
+}
+
+/* ARGSUSED */
+static int
+fs_send_close_font(FontPathElementPtr fpe, Font id)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ fsCloseReq req;
+
+ if (conn->blockState & FS_GIVE_UP)
+ return Successful;
+ /* tell the font server to close the font */
+ req.reqType = FS_CloseFont;
+ req.length = SIZEOF(fsCloseReq) >> 2;
+ req.id = id;
+ _fs_add_req_log(conn, FS_CloseFont);
+ _fs_write(conn, (char *) &req, SIZEOF(fsCloseReq));
+
+ return Successful;
+}
+
+/* ARGSUSED */
+static void
+fs_close_font(FontPathElementPtr fpe, FontPtr pfont)
+{
+ FSFontDataPtr fsd = (FSFontDataPtr) pfont->fpePrivate;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+
+ if (conn->generation == fsd->generation)
+ fs_send_close_font(fpe, fsd->fontid);
+
+#ifdef DEBUG
+ {
+ FSBlockDataPtr blockrec;
+ FSBlockedFontPtr bfont;
+
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ {
+ if (blockrec->type == FS_OPEN_FONT)
+ {
+ bfont = (FSBlockedFontPtr) blockrec->data;
+ if (bfont->pfont == pfont)
+ fprintf (stderr, "closing font which hasn't been opened\n");
+ }
+ }
+ }
+#endif
+ (*pfont->unload_font) (pfont);
+}
+
+static int
+fs_read_glyphs(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
+{
+ FSBlockedGlyphPtr bglyph = (FSBlockedGlyphPtr) blockrec->data;
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FontPtr pfont = bglyph->pfont;
+ /* works for either blocked font
+ or glyph rec... pfont is at
+ the very beginning of both
+ blockrec->data structures */
+ FSFontDataPtr fsd = (FSFontDataPtr) (pfont->fpePrivate);
+ FSFontPtr fsdata = (FSFontPtr) pfont->fontPrivate;
+ FontInfoPtr pfi = &pfont->info;
+ fsQueryXBitmaps16Reply *rep;
+ char *buf;
+ fsOffset32 *ppbits;
+ fsOffset32 local_off;
+ char *off_adr;
+ pointer pbitmaps;
+ char *bits, *allbits;
+#ifdef DEBUG
+ char *origallbits;
+#endif
+ int i,
+ err;
+ int nranges = 0;
+ int ret;
+ fsRange *nextrange = 0;
+ unsigned long minchar, maxchar;
+
+ rep = (fsQueryXBitmaps16Reply *) fs_get_reply (conn, &ret);
+ if (!rep || rep->type == FS_Error)
+ {
+ if (ret == FSIO_BLOCK)
+ return StillWorking;
+ if (rep)
+ _fs_done_read (conn, rep->length << 2);
+ err = AllocError;
+ goto bail;
+ }
+
+ buf = (char *) rep;
+ buf += SIZEOF (fsQueryXBitmaps16Reply);
+
+ ppbits = (fsOffset32 *) buf;
+ buf += SIZEOF (fsOffset32) * (rep->num_chars);
+
+ pbitmaps = (pointer ) buf;
+
+ if (blockrec->type == FS_LOAD_GLYPHS)
+ {
+ nranges = bglyph->num_expected_ranges;
+ nextrange = bglyph->expected_ranges;
+ }
+
+ /* place the incoming glyphs */
+ if (nranges)
+ {
+ /* We're operating under the assumption that the ranges
+ requested in the LoadGlyphs call were all legal for this
+ font, and that individual ranges do not cover multiple
+ rows... fs_build_range() is designed to ensure this. */
+ minchar = (nextrange->min_char_high - pfi->firstRow) *
+ (pfi->lastCol - pfi->firstCol + 1) +
+ nextrange->min_char_low - pfi->firstCol;
+ maxchar = (nextrange->max_char_high - pfi->firstRow) *
+ (pfi->lastCol - pfi->firstCol + 1) +
+ nextrange->max_char_low - pfi->firstCol;
+ nextrange++;
+ }
+ else
+ {
+ minchar = 0;
+ maxchar = rep->num_chars;
+ }
+
+ off_adr = (char *)ppbits;
+
+ allbits = fs_alloc_glyphs (pfont, rep->nbytes);
+
+ if (!allbits)
+ {
+ err = AllocError;
+ goto bail;
+ }
+
+#ifdef DEBUG
+ origallbits = allbits;
+ fprintf (stderr, "Reading %d glyphs in %d bytes for %s\n",
+ (int) rep->num_chars, (int) rep->nbytes, fsd->name);
+#endif
+
+ for (i = 0; i < rep->num_chars; i++)
+ {
+ memcpy(&local_off, off_adr, SIZEOF(fsOffset32)); /* align it */
+ if (blockrec->type == FS_OPEN_FONT ||
+ fsdata->encoding[minchar].bits == &_fs_glyph_requested)
+ {
+ /*
+ * Broken X font server returns bits for missing characters
+ * when font is padded
+ */
+ if (NONZEROMETRICS(&fsdata->encoding[minchar].metrics))
+ {
+ if (local_off.length)
+ {
+ bits = allbits;
+ allbits += local_off.length;
+ memcpy(bits, (char *)pbitmaps + local_off.position,
+ local_off.length);
+ }
+ else
+ bits = &_fs_glyph_zero_length;
+ }
+ else
+ bits = 0;
+ if (fsdata->encoding[minchar].bits == &_fs_glyph_requested)
+ fsd->glyphs_to_get--;
+ fsdata->encoding[minchar].bits = bits;
+ }
+ if (minchar++ == maxchar)
+ {
+ if (!--nranges) break;
+ minchar = (nextrange->min_char_high - pfi->firstRow) *
+ (pfi->lastCol - pfi->firstCol + 1) +
+ nextrange->min_char_low - pfi->firstCol;
+ maxchar = (nextrange->max_char_high - pfi->firstRow) *
+ (pfi->lastCol - pfi->firstCol + 1) +
+ nextrange->max_char_low - pfi->firstCol;
+ nextrange++;
+ }
+ off_adr += SIZEOF(fsOffset32);
+ }
+#ifdef DEBUG
+ fprintf (stderr, "Used %d bytes instead of %d\n",
+ (int) (allbits - origallbits), (int) rep->nbytes);
+#endif
+
+ if (blockrec->type == FS_OPEN_FONT)
+ {
+ fsd->glyphs_to_get = 0;
+ bfont->state = FS_DONE_REPLY;
+ }
+ err = Successful;
+
+bail:
+ _fs_done_read (conn, rep->length << 2);
+ return err;
+}
+
+static int
+fs_send_load_glyphs(pointer client, FontPtr pfont,
+ int nranges, fsRange *ranges)
+{
+ FontPathElementPtr fpe = pfont->fpe;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockedGlyphPtr blockedglyph;
+ fsQueryXBitmaps16Req req;
+ FSBlockDataPtr blockrec;
+
+ if (conn->blockState & FS_GIVE_UP)
+ return BadCharRange;
+
+ /* make a new block record, and add it to the end of the list */
+ blockrec = fs_new_block_rec(fpe, client, FS_LOAD_GLYPHS);
+ if (!blockrec)
+ return AllocError;
+ blockedglyph = (FSBlockedGlyphPtr) blockrec->data;
+ blockedglyph->pfont = pfont;
+ blockedglyph->num_expected_ranges = nranges;
+ /* Assumption: it's our job to free ranges */
+ blockedglyph->expected_ranges = ranges;
+ blockedglyph->clients_depending = (FSClientsDependingPtr)0;
+
+ if (conn->blockState & (FS_BROKEN_CONNECTION|FS_RECONNECTING))
+ {
+ _fs_pending_reply (conn);
+ return Suspended;
+ }
+
+ /* send the request */
+ req.reqType = FS_QueryXBitmaps16;
+ req.fid = ((FSFontDataPtr) pfont->fpePrivate)->fontid;
+ req.format = pfont->format;
+ if (pfont->info.terminalFont)
+ req.format = (req.format & ~(BitmapFormatImageRectMask)) |
+ BitmapFormatImageRectMax;
+ req.range = TRUE;
+ /* each range takes up 4 bytes */
+ req.length = (SIZEOF(fsQueryXBitmaps16Req) >> 2) + nranges;
+ req.num_ranges = nranges * 2; /* protocol wants count of fsChar2bs */
+ _fs_add_req_log(conn, FS_QueryXBitmaps16);
+ _fs_write(conn, (char *) &req, SIZEOF(fsQueryXBitmaps16Req));
+
+ blockrec->sequenceNumber = conn->current_seq;
+
+ /* Send ranges to the server... pack into a char array by hand
+ to avoid structure-packing portability problems and to
+ handle swapping for version1 protocol */
+ if (nranges)
+ {
+#define RANGE_BUFFER_SIZE 64
+#define RANGE_BUFFER_SIZE_MASK 63
+ int i;
+ char range_buffer[RANGE_BUFFER_SIZE * 4];
+ char *range_buffer_p;
+
+ range_buffer_p = range_buffer;
+ for (i = 0; i < nranges;)
+ {
+ if (conn->fsMajorVersion > 1)
+ {
+ *range_buffer_p++ = ranges[i].min_char_high;
+ *range_buffer_p++ = ranges[i].min_char_low;
+ *range_buffer_p++ = ranges[i].max_char_high;
+ *range_buffer_p++ = ranges[i].max_char_low;
+ }
+ else
+ {
+ *range_buffer_p++ = ranges[i].min_char_low;
+ *range_buffer_p++ = ranges[i].min_char_high;
+ *range_buffer_p++ = ranges[i].max_char_low;
+ *range_buffer_p++ = ranges[i].max_char_high;
+ }
+
+ if (!(++i & RANGE_BUFFER_SIZE_MASK))
+ {
+ _fs_write(conn, range_buffer, RANGE_BUFFER_SIZE * 4);
+ range_buffer_p = range_buffer;
+ }
+ }
+ if (i &= RANGE_BUFFER_SIZE_MASK)
+ _fs_write(conn, range_buffer, i * 4);
+ }
+
+ _fs_prepare_for_reply (conn);
+ return Suspended;
+}
+
+
+extern pointer serverClient; /* This could be any number that
+ doesn't conflict with existing
+ client values. */
+
+int
+fs_load_all_glyphs(FontPtr pfont)
+{
+ int err;
+ FSFpePtr conn = (FSFpePtr) pfont->fpe->private;
+
+ /*
+ * The purpose of this procedure is to load all glyphs in the event
+ * that we're dealing with someone who doesn't understand the finer
+ * points of glyph caching... it is called from _fs_get_glyphs() if
+ * the latter is called to get glyphs that have not yet been loaded.
+ * We assume that the caller will not know how to handle a return
+ * value of Suspended (usually the case for a GetGlyphs() caller),
+ * so this procedure hangs around, freezing the server, for the
+ * request to complete. This is an unpleasant kluge called to
+ * perform an unpleasant job that, we hope, will never be required.
+ */
+
+ while ((err = _fs_load_glyphs(serverClient, pfont, TRUE, 0, 0, NULL)) ==
+ Suspended)
+ {
+ if (fs_await_reply (conn) != FSIO_READY)
+ {
+ /* Get rid of blockrec */
+ fs_client_died(serverClient, pfont->fpe);
+ err = BadCharRange;
+ break;
+ }
+ fs_read_reply (pfont->fpe, serverClient);
+ }
+ return err;
+}
+
+
+int
+_fs_load_glyphs(pointer client, FontPtr pfont, Bool range_flag,
+ unsigned int nchars, int item_size, unsigned char *data)
+{
+ FSFpePtr conn = (FSFpePtr) pfont->fpe->private;
+ int nranges = 0;
+ fsRange *ranges = NULL;
+ int res;
+ FSBlockDataPtr blockrec;
+ FSBlockedGlyphPtr blockedglyph;
+ FSClientsDependingPtr *clients_depending = NULL;
+ int err;
+
+ /* see if the result is already there */
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ {
+ if (blockrec->type == FS_LOAD_GLYPHS)
+ {
+ blockedglyph = (FSBlockedGlyphPtr) blockrec->data;
+ if (blockedglyph->pfont == pfont)
+ {
+ /* Look for this request */
+ if (blockrec->client == client)
+ {
+ err = blockrec->errcode;
+ if (err == StillWorking)
+ return Suspended;
+ _fs_signal_clients_depending(&blockedglyph->clients_depending);
+ _fs_remove_block_rec(conn, blockrec);
+ return err;
+ }
+ /* We've found an existing LoadGlyphs blockrec for this
+ font but for another client. Rather than build a
+ blockrec for it now (which entails some complex
+ maintenance), we'll add it to a queue of clients to
+ be signalled when the existing LoadGlyphs is
+ completed. */
+ clients_depending = &blockedglyph->clients_depending;
+ break;
+ }
+ }
+ else if (blockrec->type == FS_OPEN_FONT)
+ {
+ FSBlockedFontPtr bfont;
+ bfont = (FSBlockedFontPtr) blockrec->data;
+ if (bfont->pfont == pfont)
+ {
+ /*
+ * An OpenFont is pending for this font, this must
+ * be from a reopen attempt, so finish the open
+ * attempt and retry the LoadGlyphs
+ */
+ if (blockrec->client == client)
+ {
+ err = blockrec->errcode;
+ if (err == StillWorking)
+ return Suspended;
+
+ _fs_signal_clients_depending(&bfont->clients_depending);
+ _fs_remove_block_rec(conn, blockrec);
+ if (err != Successful)
+ return err;
+ break;
+ }
+ /* We've found an existing OpenFont blockrec for this
+ font but for another client. Rather than build a
+ blockrec for it now (which entails some complex
+ maintenance), we'll add it to a queue of clients to
+ be signalled when the existing OpenFont is
+ completed. */
+ if (blockrec->errcode == StillWorking)
+ {
+ clients_depending = &bfont->clients_depending;
+ break;
+ }
+ }
+ }
+ }
+
+ /*
+ * see if the desired glyphs already exist, and return Successful if they
+ * do, otherwise build up character range/character string
+ */
+ res = fs_build_range(pfont, range_flag, nchars, item_size, data,
+ &nranges, &ranges);
+
+ switch (res)
+ {
+ case AccessDone:
+ return Successful;
+
+ case Successful:
+ break;
+
+ default:
+ return res;
+ }
+
+ /*
+ * If clients_depending is not null, this request must wait for
+ * some prior request(s) to complete.
+ */
+ if (clients_depending)
+ {
+ /* Since we're not ready to send the load_glyphs request yet,
+ clean up the damage (if any) caused by the fs_build_range()
+ call. */
+ if (nranges)
+ {
+ _fs_clean_aborted_loadglyphs(pfont, nranges, ranges);
+ xfree(ranges);
+ }
+ return _fs_add_clients_depending(clients_depending, client);
+ }
+
+ /*
+ * If fsd->generation != conn->generation, the font has been closed
+ * due to a lost connection. We will reopen it, which will result
+ * in one of three things happening:
+ * 1) The open will succeed and obtain the same font. Life
+ * is wonderful.
+ * 2) The open will fail. There is code above to recognize this
+ * and flunk the LoadGlyphs request. The client might not be
+ * thrilled.
+ * 3) Worst case: the open will succeed but the font we open will
+ * be different. The fs_read_query_info() procedure attempts
+ * to detect this by comparing the existing metrics and
+ * properties against those of the reopened font... if they
+ * don't match, we flunk the reopen, which eventually results
+ * in flunking the LoadGlyphs request. We could go a step
+ * further and compare the extents, but this should be
+ * sufficient.
+ */
+ if (((FSFontDataPtr)pfont->fpePrivate)->generation != conn->generation)
+ {
+ /* Since we're not ready to send the load_glyphs request yet,
+ clean up the damage caused by the fs_build_range() call. */
+ _fs_clean_aborted_loadglyphs(pfont, nranges, ranges);
+ xfree(ranges);
+
+ /* Now try to reopen the font. */
+ return fs_send_open_font(client, pfont->fpe,
+ (Mask)FontReopen, (char *)0, 0,
+ (fsBitmapFormat)0, (fsBitmapFormatMask)0,
+ (XID)0, &pfont);
+ }
+
+ return fs_send_load_glyphs(client, pfont, nranges, ranges);
+}
+
+static int
+fs_read_list(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockedListPtr blist = (FSBlockedListPtr) blockrec->data;
+ fsListFontsReply *rep;
+ char *data;
+ int length,
+ i,
+ ret;
+ int err;
+
+ rep = (fsListFontsReply *) fs_get_reply (conn, &ret);
+ if (!rep || rep->type == FS_Error)
+ {
+ if (ret == FSIO_BLOCK)
+ return StillWorking;
+ if (rep)
+ _fs_done_read (conn, rep->length << 2);
+ return AllocError;
+ }
+ data = (char *) rep + SIZEOF (fsListFontsReply);
+
+ err = Successful;
+ /* copy data into FontPathRecord */
+ for (i = 0; i < rep->nFonts; i++)
+ {
+ length = *(unsigned char *)data++;
+ err = AddFontNamesName(blist->names, data, length);
+ if (err != Successful)
+ break;
+ data += length;
+ }
+ _fs_done_read (conn, rep->length << 2);
+ return err;
+}
+
+static int
+fs_send_list_fonts(pointer client, FontPathElementPtr fpe, char *pattern,
+ int patlen, int maxnames, FontNamesPtr newnames)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec;
+ FSBlockedListPtr blockedlist;
+ fsListFontsReq req;
+
+ if (conn->blockState & FS_GIVE_UP)
+ return BadFontName;
+
+ /* make a new block record, and add it to the end of the list */
+ blockrec = fs_new_block_rec(fpe, client, FS_LIST_FONTS);
+ if (!blockrec)
+ return AllocError;
+ blockedlist = (FSBlockedListPtr) blockrec->data;
+ blockedlist->names = newnames;
+
+ if (conn->blockState & (FS_BROKEN_CONNECTION | FS_RECONNECTING))
+ {
+ _fs_pending_reply (conn);
+ return Suspended;
+ }
+
+ _fs_client_access (conn, client, FALSE);
+ _fs_client_resolution(conn);
+
+ /* send the request */
+ req.reqType = FS_ListFonts;
+ req.maxNames = maxnames;
+ req.nbytes = patlen;
+ req.length = (SIZEOF(fsListFontsReq) + patlen + 3) >> 2;
+ _fs_add_req_log(conn, FS_ListFonts);
+ _fs_write(conn, (char *) &req, SIZEOF(fsListFontsReq));
+ _fs_write_pad(conn, (char *) pattern, patlen);
+
+ blockrec->sequenceNumber = conn->current_seq;
+
+#ifdef NCD
+ if (configData.ExtendedFontDiags) {
+ char buf[256];
+
+ memcpy(buf, pattern, MIN(256, patlen));
+ buf[MIN(256, patlen)] = '\0';
+ printf("Listing fonts on pattern \"%s\" from font server \"%s\"\n",
+ buf, fpe->name);
+ }
+#endif
+
+ _fs_prepare_for_reply (conn);
+ return Suspended;
+}
+
+static int
+fs_list_fonts(pointer client, FontPathElementPtr fpe,
+ char *pattern, int patlen, int maxnames, FontNamesPtr newnames)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec;
+ int err;
+
+ /* see if the result is already there */
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ {
+ if (blockrec->type == FS_LIST_FONTS && blockrec->client == client)
+ {
+ err = blockrec->errcode;
+ if (err == StillWorking)
+ return Suspended;
+ _fs_remove_block_rec(conn, blockrec);
+ return err;
+ }
+ }
+
+ /* didn't find waiting record, so send a new one */
+ return fs_send_list_fonts(client, fpe, pattern, patlen, maxnames, newnames);
+}
+
+/*
+ * Read a single list info reply and restart for the next reply
+ */
+static int
+fs_read_list_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
+{
+ FSBlockedListInfoPtr binfo = (FSBlockedListInfoPtr) blockrec->data;
+ fsListFontsWithXInfoReply *rep;
+ char *buf;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ fsPropInfo *pi;
+ fsPropOffset *po;
+ pointer pd;
+ int ret;
+ int err;
+
+ /* clean up anything from the last trip */
+ _fs_free_props (&binfo->info);
+
+ rep = (fsListFontsWithXInfoReply *) fs_get_reply (conn, &ret);
+ if (rep == 0)
+ {
+ if (ret == FSIO_BLOCK)
+ return StillWorking;
+ binfo->status = FS_LFWI_FINISHED;
+ err = AllocError;
+ goto done;
+ }
+ /*
+ * Normal termination -- the list ends with a name of length 0
+ */
+ if (rep->nameLength == 0)
+ {
+#ifdef DEBUG
+ fprintf (stderr, "fs_read_list_info done\n");
+#endif
+ binfo->status = FS_LFWI_FINISHED;
+ err = BadFontName;
+ goto done;
+ }
+
+ buf = (char *) rep + SIZEOF (fsListFontsWithXInfoReply);
+
+ /*
+ * The original FS implementation didn't match
+ * the spec, version 1 was respecified to match the FS.
+ * Version 2 matches the original intent
+ */
+ if (conn->fsMajorVersion <= 1)
+ {
+ memcpy (binfo->name, buf, rep->nameLength);
+ buf += _fs_pad_length (rep->nameLength);
+ }
+ pi = (fsPropInfo *) buf;
+ buf += SIZEOF (fsPropInfo);
+ po = (fsPropOffset *) buf;
+ buf += pi->num_offsets * SIZEOF (fsPropOffset);
+ pd = (pointer) buf;
+ buf += pi->data_len;
+ if (conn->fsMajorVersion > 1)
+ {
+ memcpy (binfo->name, buf, rep->nameLength);
+ buf += _fs_pad_length (rep->nameLength);
+ }
+
+#ifdef DEBUG
+ binfo->name[rep->nameLength] = '\0';
+ fprintf (stderr, "fs_read_list_info %s\n", binfo->name);
+#endif
+ err = _fs_convert_lfwi_reply(conn, &binfo->info, rep, pi, po, pd);
+ if (err != Successful)
+ {
+ binfo->status = FS_LFWI_FINISHED;
+ goto done;
+ }
+ binfo->namelen = rep->nameLength;
+ binfo->remaining = rep->nReplies;
+
+ binfo->status = FS_LFWI_REPLY;
+
+ /* disable this font server until we've processed this response */
+ _fs_unmark_block (conn, FS_COMPLETE_REPLY);
+ FD_CLR(conn->fs_fd, &_fs_fd_mask);
+done:
+ _fs_done_read (conn, rep->length << 2);
+ return err;
+}
+
+/* ARGSUSED */
+static int
+fs_start_list_with_info(pointer client, FontPathElementPtr fpe,
+ char *pattern, int len, int maxnames, pointer *pdata)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec;
+ FSBlockedListInfoPtr binfo;
+ fsListFontsWithXInfoReq req;
+
+ if (conn->blockState & FS_GIVE_UP)
+ return BadFontName;
+
+ /* make a new block record, and add it to the end of the list */
+ blockrec = fs_new_block_rec(fpe, client, FS_LIST_WITH_INFO);
+ if (!blockrec)
+ return AllocError;
+
+ binfo = (FSBlockedListInfoPtr) blockrec->data;
+ bzero((char *) binfo, sizeof(FSBlockedListInfoRec));
+ binfo->status = FS_LFWI_WAITING;
+
+ if (conn->blockState & (FS_BROKEN_CONNECTION | FS_RECONNECTING))
+ {
+ _fs_pending_reply (conn);
+ return Suspended;
+ }
+
+ _fs_client_access (conn, client, FALSE);
+ _fs_client_resolution(conn);
+
+ /* send the request */
+ req.reqType = FS_ListFontsWithXInfo;
+ req.maxNames = maxnames;
+ req.nbytes = len;
+ req.length = (SIZEOF(fsListFontsWithXInfoReq) + len + 3) >> 2;
+ _fs_add_req_log(conn, FS_ListFontsWithXInfo);
+ (void) _fs_write(conn, (char *) &req, SIZEOF(fsListFontsWithXInfoReq));
+ (void) _fs_write_pad(conn, pattern, len);
+
+ blockrec->sequenceNumber = conn->current_seq;
+
+#ifdef NCD
+ if (configData.ExtendedFontDiags) {
+ char buf[256];
+
+ memcpy(buf, pattern, MIN(256, len));
+ buf[MIN(256, len)] = '\0';
+ printf("Listing fonts with info on pattern \"%s\" from font server \"%s\"\n",
+ buf, fpe->name);
+ }
+#endif
+
+ _fs_prepare_for_reply (conn);
+ return Successful;
+}
+
+/* ARGSUSED */
+static int
+fs_next_list_with_info(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo, int *numFonts,
+ pointer private)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec;
+ FSBlockedListInfoPtr binfo;
+ int err;
+
+ /* see if the result is already there */
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ if (blockrec->type == FS_LIST_WITH_INFO && blockrec->client == client)
+ break;
+
+ if (!blockrec)
+ {
+ /* The only good reason for not finding a blockrec would be if
+ disconnect/reconnect to the font server wiped it out and the
+ code that called us didn't do the right thing to create
+ another one. Under those circumstances, we need to return an
+ error to prevent that code from attempting to interpret the
+ information we don't return. */
+ return BadFontName;
+ }
+
+ binfo = (FSBlockedListInfoPtr) blockrec->data;
+
+ if (binfo->status == FS_LFWI_WAITING)
+ return Suspended;
+
+ *namep = binfo->name;
+ *namelenp = binfo->namelen;
+ *pFontInfo = &binfo->info;
+ *numFonts = binfo->remaining;
+
+ /* Restart reply processing from this font server */
+ FD_SET(conn->fs_fd, &_fs_fd_mask);
+ if (fs_reply_ready (conn))
+ _fs_mark_block (conn, FS_COMPLETE_REPLY);
+
+ err = blockrec->errcode;
+ switch (binfo->status) {
+ case FS_LFWI_FINISHED:
+ _fs_remove_block_rec(conn, blockrec);
+ break;
+ case FS_LFWI_REPLY:
+ binfo->status = FS_LFWI_WAITING;
+ blockrec->errcode = StillWorking;
+ conn->blockedReplyTime = GetTimeInMillis () + FontServerRequestTimeout;
+ _fs_mark_block (conn, FS_PENDING_REPLY);
+ break;
+ }
+
+ return err;
+}
+
+/*
+ * Called when client exits
+ */
+
+static void
+fs_client_died(pointer client, FontPathElementPtr fpe)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec,
+ depending;
+ FSClientPtr *prev, cur;
+ fsFreeACReq freeac;
+
+ for (prev = &conn->clients; (cur = *prev); prev = &cur->next)
+ {
+ if (cur->client == client) {
+ freeac.reqType = FS_FreeAC;
+ freeac.id = cur->acid;
+ freeac.length = sizeof (fsFreeACReq) >> 2;
+ _fs_add_req_log(conn, FS_FreeAC);
+ _fs_write (conn, (char *) &freeac, sizeof (fsFreeACReq));
+ *prev = cur->next;
+ xfree (cur);
+ break;
+ }
+ }
+ /* find a pending requests */
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ if (blockrec->client == client)
+ break;
+
+ if (!blockrec)
+ return;
+
+ /* replace the client pointers in this block rec with the chained one */
+ if ((depending = blockrec->depending))
+ {
+ blockrec->client = depending->client;
+ blockrec->depending = depending->depending;
+ blockrec = depending;
+ }
+ fs_abort_blockrec(conn, blockrec);
+}
+
+static void
+_fs_client_access (FSFpePtr conn, pointer client, Bool sync)
+{
+ FSClientPtr *prev, cur;
+ fsCreateACReq crac;
+ fsSetAuthorizationReq setac;
+ char *authorizations;
+ int authlen;
+ Bool new_cur = FALSE;
+
+#ifdef DEBUG
+ if (conn->blockState & (FS_RECONNECTING|FS_BROKEN_CONNECTION))
+ {
+ fprintf (stderr, "Sending requests without a connection\n");
+ }
+#endif
+ for (prev = &conn->clients; (cur = *prev); prev = &cur->next)
+ {
+ if (cur->client == client)
+ {
+ if (prev != &conn->clients)
+ {
+ *prev = cur->next;
+ cur->next = conn->clients;
+ conn->clients = cur;
+ }
+ break;
+ }
+ }
+ if (!cur)
+ {
+ cur = (FSClientPtr) xalloc (sizeof (FSClientRec));
+ if (!cur)
+ return;
+ cur->client = client;
+ cur->next = conn->clients;
+ conn->clients = cur;
+ cur->acid = GetNewFontClientID ();
+ new_cur = TRUE;
+ }
+ if (new_cur || cur->auth_generation != client_auth_generation(client))
+ {
+ if (!new_cur)
+ {
+ fsFreeACReq freeac;
+ freeac.reqType = FS_FreeAC;
+ freeac.id = cur->acid;
+ freeac.length = sizeof (fsFreeACReq) >> 2;
+ _fs_add_req_log(conn, FS_FreeAC);
+ _fs_write (conn, (char *) &freeac, sizeof (fsFreeACReq));
+ }
+ crac.reqType = FS_CreateAC;
+ crac.num_auths = set_font_authorizations(&authorizations, &authlen,
+ client);
+ authlen = crac.num_auths ? (authlen + 3) & ~0x3 : 0;
+ crac.length = (sizeof (fsCreateACReq) + authlen) >> 2;
+ crac.acid = cur->acid;
+ _fs_add_req_log(conn, FS_CreateAC);
+ _fs_write(conn, (char *) &crac, sizeof (fsCreateACReq));
+ _fs_write(conn, authorizations, authlen);
+ /* ignore reply; we don't even care about it */
+ conn->curacid = 0;
+ cur->auth_generation = client_auth_generation(client);
+ }
+ if (conn->curacid != cur->acid)
+ {
+ setac.reqType = FS_SetAuthorization;
+ setac.length = sizeof (fsSetAuthorizationReq) >> 2;
+ setac.id = cur->acid;
+ _fs_add_req_log(conn, FS_SetAuthorization);
+ _fs_write(conn, (char *) &setac, sizeof (fsSetAuthorizationReq));
+ conn->curacid = cur->acid;
+ }
+}
+
+/*
+ * Poll a pending connect
+ */
+
+static int
+_fs_check_connect (FSFpePtr conn)
+{
+ int ret;
+
+ ret = _fs_poll_connect (conn->trans_conn, 0);
+ switch (ret) {
+ case FSIO_READY:
+ conn->fs_fd = _FontTransGetConnectionNumber (conn->trans_conn);
+ FD_SET (conn->fs_fd, &_fs_fd_mask);
+ break;
+ case FSIO_BLOCK:
+ break;
+ }
+ return ret;
+}
+
+/*
+ * Return an FSIO status while waiting for the completed connection
+ * reply to arrive
+ */
+
+static fsConnSetup *
+_fs_get_conn_setup (FSFpePtr conn, int *error, int *setup_len)
+{
+ int ret;
+ char *data;
+ int headlen;
+ int len;
+ fsConnSetup *setup;
+ fsConnSetupAccept *accept;
+
+ ret = _fs_start_read (conn, SIZEOF (fsConnSetup), &data);
+ if (ret != FSIO_READY)
+ {
+ *error = ret;
+ return 0;
+ }
+
+ setup = (fsConnSetup *) data;
+ if (setup->major_version > FS_PROTOCOL)
+ {
+ *error = FSIO_ERROR;
+ return 0;
+ }
+
+ headlen = (SIZEOF (fsConnSetup) +
+ (setup->alternate_len << 2) +
+ (setup->auth_len << 2));
+ /* On anything but Success, no extra data is sent */
+ if (setup->status != AuthSuccess)
+ {
+ len = headlen;
+ }
+ else
+ {
+ ret = _fs_start_read (conn, headlen + SIZEOF (fsConnSetupAccept), &data);
+ if (ret != FSIO_READY)
+ {
+ *error = ret;
+ return 0;
+ }
+ setup = (fsConnSetup *) data;
+ accept = (fsConnSetupAccept *) (data + headlen);
+ len = headlen + (accept->length << 2);
+ }
+ ret = _fs_start_read (conn, len, &data);
+ if (ret != FSIO_READY)
+ {
+ *error = ret;
+ return 0;
+ }
+ *setup_len = len;
+ return (fsConnSetup *) data;
+}
+
+static int
+_fs_send_conn_client_prefix (FSFpePtr conn)
+{
+ fsConnClientPrefix req;
+ int endian;
+ int ret;
+
+ /* send setup prefix */
+ endian = 1;
+ if (*(char *) &endian)
+ req.byteOrder = 'l';
+ else
+ req.byteOrder = 'B';
+
+ req.major_version = FS_PROTOCOL;
+ req.minor_version = FS_PROTOCOL_MINOR;
+
+/* XXX add some auth info here */
+ req.num_auths = 0;
+ req.auth_len = 0;
+ ret = _fs_write (conn, (char *) &req, SIZEOF (fsConnClientPrefix));
+ if (ret != FSIO_READY)
+ return FSIO_ERROR;
+ conn->blockedConnectTime = GetTimeInMillis () + FontServerRequestTimeout;
+ return ret;
+}
+
+static int
+_fs_recv_conn_setup (FSFpePtr conn)
+{
+ int ret;
+ fsConnSetup *setup;
+ FSFpeAltPtr alts;
+ int i, alt_len;
+ int setup_len;
+ char *alt_save, *alt_names;
+
+ setup = _fs_get_conn_setup (conn, &ret, &setup_len);
+ if (!setup)
+ return ret;
+ conn->current_seq = 0;
+ conn->fsMajorVersion = setup->major_version;
+ /*
+ * Create an alternate list from the initial server, but
+ * don't chain looking for alternates.
+ */
+ if (conn->alternate == 0)
+ {
+ /*
+ * free any existing alternates list, allowing the list to
+ * be updated
+ */
+ if (conn->alts)
+ {
+ xfree (conn->alts);
+ conn->alts = 0;
+ conn->numAlts = 0;
+ }
+ if (setup->num_alternates)
+ {
+ alts = (FSFpeAltPtr) xalloc (setup->num_alternates *
+ sizeof (FSFpeAltRec) +
+ (setup->alternate_len << 2));
+ if (alts)
+ {
+ alt_names = (char *) (setup + 1);
+ alt_save = (char *) (alts + setup->num_alternates);
+ for (i = 0; i < setup->num_alternates; i++)
+ {
+ alts[i].subset = alt_names[0];
+ alt_len = alt_names[1];
+ alts[i].name = alt_save;
+ memcpy (alt_save, alt_names + 2, alt_len);
+ alt_save[alt_len] = '\0';
+ alt_save += alt_len + 1;
+ alt_names += _fs_pad_length (alt_len + 2);
+ }
+ conn->numAlts = setup->num_alternates;
+ conn->alts = alts;
+ }
+ }
+ }
+ _fs_done_read (conn, setup_len);
+ if (setup->status != AuthSuccess)
+ return FSIO_ERROR;
+ return FSIO_READY;
+}
+
+static int
+_fs_open_server (FSFpePtr conn)
+{
+ int ret;
+ char *servername;
+
+ if (conn->alternate == 0)
+ servername = conn->servername;
+ else
+ servername = conn->alts[conn->alternate-1].name;
+ conn->trans_conn = _fs_connect (servername, &ret);
+ conn->blockedConnectTime = GetTimeInMillis () + FS_RECONNECT_WAIT;
+ return ret;
+}
+
+static char *
+_fs_catalog_name (char *servername)
+{
+ char *sp;
+
+ sp = strchr (servername, '/');
+ if (!sp)
+ return 0;
+ return strrchr (sp + 1, '/');
+}
+
+static int
+_fs_send_init_packets (FSFpePtr conn)
+{
+ fsSetResolutionReq srreq;
+ fsSetCataloguesReq screq;
+ int num_cats,
+ clen;
+ char *catalogues;
+ char *cat;
+ char len;
+ char *end;
+ int num_res;
+ FontResolutionPtr res;
+
+#define CATALOGUE_SEP '+'
+
+ res = GetClientResolutions(&num_res);
+ if (num_res)
+ {
+ srreq.reqType = FS_SetResolution;
+ srreq.num_resolutions = num_res;
+ srreq.length = (SIZEOF(fsSetResolutionReq) +
+ (num_res * SIZEOF(fsResolution)) + 3) >> 2;
+
+ _fs_add_req_log(conn, FS_SetResolution);
+ if (_fs_write(conn, (char *) &srreq, SIZEOF(fsSetResolutionReq)) != FSIO_READY)
+ return FSIO_ERROR;
+ if (_fs_write_pad(conn, (char *) res, (num_res * SIZEOF(fsResolution))) != FSIO_READY)
+ return FSIO_ERROR;
+ }
+
+ catalogues = 0;
+ if (conn->alternate != 0)
+ catalogues = _fs_catalog_name (conn->alts[conn->alternate-1].name);
+ if (!catalogues)
+ catalogues = _fs_catalog_name (conn->servername);
+
+ if (!catalogues)
+ {
+ conn->has_catalogues = FALSE;
+ return FSIO_READY;
+ }
+ conn->has_catalogues = TRUE;
+
+ /* turn cats into counted list */
+ catalogues++;
+
+ cat = catalogues;
+ num_cats = 0;
+ clen = 0;
+ while (*cat)
+ {
+ num_cats++;
+ end = strchr(cat, CATALOGUE_SEP);
+ if (!end)
+ end = cat + strlen (cat);
+ clen += (end - cat) + 1; /* length byte + string */
+ cat = end;
+ }
+
+ screq.reqType = FS_SetCatalogues;
+ screq.num_catalogues = num_cats;
+ screq.length = (SIZEOF(fsSetCataloguesReq) + clen + 3) >> 2;
+
+ _fs_add_req_log(conn, FS_SetCatalogues);
+ if (_fs_write(conn, (char *) &screq, SIZEOF(fsSetCataloguesReq)) != FSIO_READY)
+ return FSIO_ERROR;
+
+ while (*cat)
+ {
+ num_cats++;
+ end = strchr(cat, CATALOGUE_SEP);
+ if (!end)
+ end = cat + strlen (cat);
+ len = end - cat;
+ if (_fs_write (conn, &len, 1) != FSIO_READY)
+ return FSIO_ERROR;
+ if (_fs_write (conn, cat, (int) len) != FSIO_READY)
+ return FSIO_ERROR;
+ cat = end;
+ }
+
+ if (_fs_write (conn, "....", _fs_pad_length (clen) - clen) != FSIO_READY)
+ return FSIO_ERROR;
+
+ return FSIO_READY;
+}
+
+static int
+_fs_send_cat_sync (FSFpePtr conn)
+{
+ fsListCataloguesReq lcreq;
+
+ /*
+ * now sync up with the font server, to see if an error was generated
+ * by a bogus catalogue
+ */
+ lcreq.reqType = FS_ListCatalogues;
+ lcreq.length = (SIZEOF(fsListCataloguesReq)) >> 2;
+ lcreq.maxNames = 0;
+ lcreq.nbytes = 0;
+ _fs_add_req_log(conn, FS_SetCatalogues);
+ if (_fs_write(conn, (char *) &lcreq, SIZEOF(fsListCataloguesReq)) != FSIO_READY)
+ return FSIO_ERROR;
+ conn->blockedConnectTime = GetTimeInMillis () + FontServerRequestTimeout;
+ return FSIO_READY;
+}
+
+static int
+_fs_recv_cat_sync (FSFpePtr conn)
+{
+ fsGenericReply *reply;
+ fsError *error;
+ int err;
+ int ret;
+
+ reply = fs_get_reply (conn, &err);
+ if (!reply)
+ return err;
+
+ ret = FSIO_READY;
+ if (reply->type == FS_Error)
+ {
+ error = (fsError *) reply;
+ if (error->major_opcode == FS_SetCatalogues)
+ ret = FSIO_ERROR;
+ }
+ _fs_done_read (conn, reply->length << 2);
+ return ret;
+}
+
+static void
+_fs_close_server (FSFpePtr conn)
+{
+ _fs_unmark_block (conn, FS_PENDING_WRITE|FS_BROKEN_WRITE|FS_COMPLETE_REPLY|FS_BROKEN_CONNECTION);
+ if (conn->trans_conn)
+ {
+ _FontTransClose (conn->trans_conn);
+ conn->trans_conn = 0;
+ _fs_io_reinit (conn);
+ }
+ if (conn->fs_fd >= 0)
+ {
+ FD_CLR (conn->fs_fd, &_fs_fd_mask);
+ conn->fs_fd = -1;
+ }
+ conn->fs_conn_state = FS_CONN_UNCONNECTED;
+}
+
+static int
+_fs_do_setup_connection (FSFpePtr conn)
+{
+ int ret;
+
+ do
+ {
+#ifdef DEBUG
+ fprintf (stderr, "fs_do_setup_connection state %d\n", conn->fs_conn_state);
+#endif
+ switch (conn->fs_conn_state) {
+ case FS_CONN_UNCONNECTED:
+ ret = _fs_open_server (conn);
+ if (ret == FSIO_BLOCK)
+ conn->fs_conn_state = FS_CONN_CONNECTING;
+ break;
+ case FS_CONN_CONNECTING:
+ ret = _fs_check_connect (conn);
+ break;
+ case FS_CONN_CONNECTED:
+ ret = _fs_send_conn_client_prefix (conn);
+ break;
+ case FS_CONN_SENT_PREFIX:
+ ret = _fs_recv_conn_setup (conn);
+ break;
+ case FS_CONN_RECV_INIT:
+ ret = _fs_send_init_packets (conn);
+ if (conn->has_catalogues)
+ ret = _fs_send_cat_sync (conn);
+ break;
+ case FS_CONN_SENT_CAT:
+ if (conn->has_catalogues)
+ ret = _fs_recv_cat_sync (conn);
+ else
+ ret = FSIO_READY;
+ break;
+ default:
+ ret = FSIO_READY;
+ break;
+ }
+ switch (ret) {
+ case FSIO_READY:
+ if (conn->fs_conn_state < FS_CONN_RUNNING)
+ conn->fs_conn_state++;
+ break;
+ case FSIO_BLOCK:
+ if (TimeCmp (GetTimeInMillis (), <, conn->blockedConnectTime))
+ break;
+ ret = FSIO_ERROR;
+ /* fall through... */
+ case FSIO_ERROR:
+ _fs_close_server (conn);
+ /*
+ * Try the next alternate
+ */
+ if (conn->alternate < conn->numAlts)
+ {
+ conn->alternate++;
+ ret = FSIO_READY;
+ }
+ else
+ conn->alternate = 0;
+ break;
+ }
+ } while (conn->fs_conn_state != FS_CONN_RUNNING && ret == FSIO_READY);
+ if (ret == FSIO_READY)
+ conn->generation = ++generationCount;
+ return ret;
+}
+
+static int
+_fs_wait_connect (FSFpePtr conn)
+{
+ int ret;
+
+ for (;;)
+ {
+ ret = _fs_do_setup_connection (conn);
+ if (ret != FSIO_BLOCK)
+ break;
+ if (conn->fs_conn_state <= FS_CONN_CONNECTING)
+ ret = _fs_poll_connect (conn->trans_conn, 1000);
+ else
+ ret = _fs_wait_for_readable (conn, 1000);
+ if (ret == FSIO_ERROR)
+ break;
+ }
+ return ret;
+}
+
+/*
+ * Poll a connection in the process of reconnecting
+ */
+static void
+_fs_check_reconnect (FSFpePtr conn)
+{
+ int ret;
+
+ ret = _fs_do_setup_connection (conn);
+ switch (ret) {
+ case FSIO_READY:
+ _fs_unmark_block (conn, FS_RECONNECTING|FS_GIVE_UP);
+ _fs_restart_connection (conn);
+ break;
+ case FSIO_BLOCK:
+ break;
+ case FSIO_ERROR:
+ conn->brokenConnectionTime = GetTimeInMillis () + FS_RECONNECT_POLL;
+ break;
+ }
+}
+
+/*
+ * Start the reconnection process
+ */
+static void
+_fs_start_reconnect (FSFpePtr conn)
+{
+ if (conn->blockState & FS_RECONNECTING)
+ return;
+ conn->alternate = 0;
+ _fs_mark_block (conn, FS_RECONNECTING);
+ _fs_unmark_block (conn, FS_BROKEN_CONNECTION);
+ _fs_check_reconnect (conn);
+}
+
+
+static FSFpePtr
+_fs_init_conn (char *servername)
+{
+ FSFpePtr conn;
+
+ conn = xalloc (sizeof (FSFpeRec) + strlen (servername) + 1);
+ if (!conn)
+ return 0;
+ memset (conn, '\0', sizeof (FSFpeRec));
+ if (!_fs_io_init (conn))
+ {
+ xfree (conn);
+ return 0;
+ }
+ conn->servername = (char *) (conn + 1);
+ conn->fs_conn_state = FS_CONN_UNCONNECTED;
+ conn->fs_fd = -1;
+ strcpy (conn->servername, servername);
+ return conn;
+}
+
+static void
+_fs_free_conn (FSFpePtr conn)
+{
+ _fs_close_server (conn);
+ _fs_io_fini (conn);
+ if (conn->alts)
+ xfree (conn->alts);
+ xfree (conn);
+}
+
+/*
+ * called at server init time
+ */
+
+void
+fs_register_fpe_functions(void)
+{
+ RegisterFPEFunctions(fs_name_check,
+ fs_init_fpe,
+ fs_free_fpe,
+ fs_reset_fpe,
+ fs_open_font,
+ fs_close_font,
+ fs_list_fonts,
+ fs_start_list_with_info,
+ fs_next_list_with_info,
+ fs_wakeup,
+ fs_client_died,
+ _fs_load_glyphs,
+ NULL,
+ NULL,
+ NULL);
+}
+
+static int
+check_fs_open_font(pointer client, FontPathElementPtr fpe, Mask flags,
+ char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *ppfont,
+ char **alias, FontPtr non_cachable_font)
+{
+ if (XpClientIsBitmapClient(client))
+ return (fs_open_font(client, fpe, flags, name, namelen, format,
+ fmask, id, ppfont, alias, non_cachable_font) );
+ return BadFontName;
+}
+
+static int
+check_fs_list_fonts(pointer client, FontPathElementPtr fpe,
+ char *pattern, int patlen, int maxnames,
+ FontNamesPtr newnames)
+{
+ if (XpClientIsBitmapClient(client))
+ return (fs_list_fonts(client, fpe, pattern, patlen, maxnames,
+ newnames));
+ return BadFontName;
+}
+
+static int
+check_fs_start_list_with_info(pointer client, FontPathElementPtr fpe,
+ char *pattern, int len, int maxnames,
+ pointer *pdata)
+{
+ if (XpClientIsBitmapClient(client))
+ return (fs_start_list_with_info(client, fpe, pattern, len, maxnames,
+ pdata));
+ return BadFontName;
+}
+
+static int
+check_fs_next_list_with_info(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo, int *numFonts,
+ pointer private)
+{
+ if (XpClientIsBitmapClient(client))
+ return (fs_next_list_with_info(client, fpe, namep, namelenp, pFontInfo,
+ numFonts,private));
+ return BadFontName;
+}
+
+void
+check_fs_register_fpe_functions(void)
+{
+ RegisterFPEFunctions(fs_name_check,
+ fs_init_fpe,
+ fs_free_fpe,
+ fs_reset_fpe,
+ check_fs_open_font,
+ fs_close_font,
+ check_fs_list_fonts,
+ check_fs_start_list_with_info,
+ check_fs_next_list_with_info,
+ fs_wakeup,
+ fs_client_died,
+ _fs_load_glyphs,
+ NULL,
+ NULL,
+ NULL);
+}
diff --git a/nx-X11/lib/font/fc/fserve.h b/nx-X11/lib/font/fc/fserve.h
new file mode 100644
index 000000000..3254f40fa
--- /dev/null
+++ b/nx-X11/lib/font/fc/fserve.h
@@ -0,0 +1,96 @@
+/* $Xorg: fserve.h,v 1.3 2000/08/17 19:46:36 cpqbld Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices
+ *
+ * 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 of Network Computing Devices not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Network Computing
+ * Devices makes no representations about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL NETWORK COMPUTING DEVICES 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.
+ *
+ * Author: Dave Lemke, Network Computing Devices, Inc
+ *
+ */
+/* $XFree86: xc/lib/font/fc/fserve.h,v 1.4 2001/01/17 19:43:29 dawes Exp $ */
+
+#ifndef _FSERVE_H_
+#define _FSERVE_H_
+/*
+ * font server data structures
+ */
+
+/* types of block records */
+#define FS_OPEN_FONT 1
+#define FS_LOAD_GLYPHS 2
+#define FS_LIST_FONTS 3
+#define FS_LIST_WITH_INFO 4
+
+/* states of OpenFont */
+#define FS_OPEN_REPLY 0
+#define FS_INFO_REPLY 1
+#define FS_EXTENT_REPLY 2
+#define FS_GLYPHS_REPLY 3
+#define FS_DONE_REPLY 4
+#define FS_DEPENDING 5
+
+/* status of ListFontsWithInfo */
+#define FS_LFWI_WAITING 0
+#define FS_LFWI_REPLY 1
+#define FS_LFWI_FINISHED 2
+
+/* states of connection */
+#define FS_CONN_CLOSED 0
+#define FS_CONN_CONNECTING 1
+#define FS_CONN_READ_HEADER 2
+#define FS_CONN_READ_DATA 3
+
+#define AccessDone 0x400
+
+typedef struct _fs_font_data *FSFontDataPtr;
+typedef struct _fs_blocked_font *FSBlockedFontPtr;
+typedef struct _fs_blocked_glyphs *FSBlockedGlyphPtr;
+typedef struct _fs_blocked_list *FSBlockedListPtr;
+typedef struct _fs_blocked_list_info *FSBlockedListInfoPtr;
+typedef struct _fs_block_data *FSBlockDataPtr;
+typedef struct _fs_font_table *FSFontTablePtr;
+typedef struct _fs_fpe_data *FSFpePtr;
+
+typedef struct _fs_blocked_bitmaps *FSBlockedBitmapPtr;
+typedef struct _fs_blocked_extents *FSBlockedExtentPtr;
+
+extern void _fs_convert_char_info ( fsXCharInfo *src, xCharInfo *dst );
+extern void _fs_free_props (FontInfoPtr pfi);
+extern FontPtr fs_create_font (FontPathElementPtr fpe,
+ char *name,
+ int namelen,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask);
+
+extern int fs_load_all_glyphs ( FontPtr pfont );
+extern int _fs_load_glyphs ( pointer client, FontPtr pfont, Bool range_flag,
+ unsigned int nchars, int item_size,
+ unsigned char *data );
+
+/*
+ * These should be declared elsewhere, but I'm concerned that moving them
+ * would cause problems building other pieces
+ */
+extern FontPtr find_old_font (Font id);
+extern int set_font_authorizations (char **a, int *len, pointer client);
+extern long GetTimeInMillis (void);
+
+
+#endif /* _FSERVE_H_ */
diff --git a/nx-X11/lib/font/fc/fservestr.h b/nx-X11/lib/font/fc/fservestr.h
new file mode 100644
index 000000000..0e4166642
--- /dev/null
+++ b/nx-X11/lib/font/fc/fservestr.h
@@ -0,0 +1,211 @@
+/* $Xorg: fservestr.h,v 1.3 2000/08/17 19:46:36 cpqbld Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices
+ *
+ * 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 of Network Computing Devices not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Network Computing
+ * Devices makes no representations about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL NETWORK COMPUTING DEVICES 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.
+ *
+ * Author: Dave Lemke, Network Computing Devices, Inc
+ */
+/* $XFree86: xc/lib/font/fc/fservestr.h,v 3.3 2001/01/17 19:43:29 dawes Exp $ */
+
+#ifndef _FSERVESTR_H_
+#define _FSERVESTR_H_
+
+#include "fserve.h"
+#include "fsio.h"
+
+/*
+ * font server data structures
+ */
+/*
+ * font server private storage
+ */
+
+typedef struct _fs_glyph {
+ struct _fs_glyph *next;
+} FSGlyphRec, *FSGlyphPtr;
+
+typedef struct _fs_font {
+ CharInfoPtr pDefault;
+ CharInfoPtr encoding;
+ CharInfoPtr inkMetrics;
+ FSGlyphPtr glyphs;
+} FSFontRec, *FSFontPtr;
+
+/* FS special data for the font */
+typedef struct _fs_font_data {
+ long fontid;
+ int generation; /* FS generation when opened */
+ unsigned long glyphs_to_get; /* # glyphs remaining to be gotten */
+
+ /* Following data needed in case font needs to be reopened. */
+ int namelen;
+ char *name;
+ fsBitmapFormat format;
+ fsBitmapFormatMask fmask;
+} FSFontDataRec;
+
+typedef struct fs_clients_depending {
+ pointer client;
+ struct fs_clients_depending *next;
+} FSClientsDependingRec, *FSClientsDependingPtr;
+
+/* OpenFont specific data for blocked request */
+typedef struct _fs_blocked_font {
+ FontPtr pfont; /* must be first for fs_read_glyphs */
+ long fontid;
+ int state; /* how many of the replies have landed */
+ int flags;
+ Bool freeFont; /* free this font on failure */
+ CARD16 queryInfoSequence;
+ CARD16 queryExtentsSequence;
+ CARD16 queryBitmapsSequence;
+ fsBitmapFormat format;
+ FSClientsDependingPtr clients_depending;
+} FSBlockedFontRec;
+
+/* LoadGlyphs data for blocked request */
+typedef struct _fs_blocked_glyphs {
+ FontPtr pfont; /* must be first for fs_read_glyphs */
+ int num_expected_ranges;
+ fsRange *expected_ranges;
+ FSClientsDependingPtr clients_depending;
+} FSBlockedGlyphRec;
+
+/* LoadExtents data for blocked request */
+typedef struct _fs_blocked_extents {
+ FontPtr pfont;
+ fsRange *expected_ranges;
+ int nranges;
+ unsigned long nextents;
+ fsXCharInfo *extents;
+} FSBlockedExtentRec;
+
+/* LoadBitmaps data for blocked request */
+typedef struct _fs_blocked_bitmaps {
+ FontPtr pfont;
+ fsRange *expected_ranges;
+ int nranges;
+ unsigned long size;
+ unsigned long nglyphs;
+ fsOffset32 *offsets;
+ pointer gdata;
+} FSBlockedBitmapRec;
+
+/* state for blocked ListFonts */
+typedef struct _fs_blocked_list {
+ FontNamesPtr names;
+} FSBlockedListRec;
+
+/* state for blocked ListFontsWithInfo */
+typedef struct _fs_blocked_list_info {
+ int status;
+ int namelen;
+ FontInfoRec info;
+ char name[256];
+ int remaining;
+} FSBlockedListInfoRec;
+
+/* state for blocked request */
+typedef struct _fs_block_data {
+ int type; /* Open Font, LoadGlyphs, ListFonts,
+ * ListWithInfo */
+ pointer client; /* who wants it */
+ CARD16 sequenceNumber; /* expected */
+ pointer data; /* type specific data */
+ int errcode; /* Suspended, et al. */
+ struct _fs_block_data *depending; /* clients depending on this one */
+ struct _fs_block_data *next;
+} FSBlockDataRec;
+
+/* state for reconnected to dead font server */
+typedef struct _fs_reconnect {
+ int i;
+} FSReconnectRec, *FSReconnectPtr;
+
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define fsCat(x,y) x##_##y
+#else
+#define fsCat(x,y) x/**/_/**/y
+#endif
+
+
+/* copy XCharInfo parts of a protocol reply into a xCharInfo */
+
+#define fsUnpack_XCharInfo(packet, structure) \
+ (structure)->leftSideBearing = fsCat(packet,left); \
+ (structure)->rightSideBearing = fsCat(packet,right); \
+ (structure)->characterWidth = fsCat(packet,width); \
+ (structure)->ascent = fsCat(packet,ascent); \
+ (structure)->descent = fsCat(packet,descent); \
+ (structure)->attributes = fsCat(packet,attributes)
+
+
+/* copy XFontInfoHeader parts of a protocol reply into a FontInfoRec */
+
+#define fsUnpack_XFontInfoHeader(packet, structure) \
+ (structure)->allExist = ((packet)->font_header_flags & FontInfoAllCharsExist) != 0; \
+ (structure)->drawDirection = \
+ ((packet)->font_header_draw_direction == LeftToRightDrawDirection) ? \
+ LeftToRight : RightToLeft; \
+ (structure)->inkInside = ((packet)->font_header_flags & FontInfoInkInside) != 0; \
+ \
+ (structure)->firstRow = (packet)->font_hdr_char_range_min_char_high; \
+ (structure)->firstCol = (packet)->font_hdr_char_range_min_char_low; \
+ (structure)->lastRow = (packet)->font_hdr_char_range_max_char_high; \
+ (structure)->lastCol = (packet)->font_hdr_char_range_max_char_low; \
+ (structure)->defaultCh = (packet)->font_header_default_char_low \
+ + ((packet)->font_header_default_char_high << 8); \
+ \
+ (structure)->fontDescent = (packet)->font_header_font_descent; \
+ (structure)->fontAscent = (packet)->font_header_font_ascent; \
+ \
+ fsUnpack_XCharInfo((packet)->font_header_min_bounds, &(structure)->minbounds); \
+ fsUnpack_XCharInfo((packet)->font_header_min_bounds, &(structure)->ink_minbounds); \
+ fsUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->maxbounds); \
+ fsUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->ink_maxbounds)
+
+extern void _fs_init_fontinfo ( FSFpePtr conn, FontInfoPtr pfi );
+extern int _fs_convert_props ( fsPropInfo *pi, fsPropOffset *po, pointer pd,
+ FontInfoPtr pfi );
+extern int _fs_convert_lfwi_reply ( FSFpePtr conn, FontInfoPtr pfi,
+ fsListFontsWithXInfoReply *fsrep,
+ fsPropInfo *pi, fsPropOffset *po,
+ pointer pd );
+extern int fs_build_range ( FontPtr pfont, Bool range_flag,
+ unsigned int count, int item_size,
+ unsigned char *data, int *nranges,
+ fsRange **ranges );
+extern void _fs_clean_aborted_loadglyphs ( FontPtr pfont,
+ int num_expected_ranges,
+ fsRange *expected_ranges );
+extern int _fs_check_extents ( FontPtr pfont, Mask flags, int nranges,
+ fsRange *range, FSBlockDataPtr blockrec );
+extern int _fs_check_bitmaps ( FontPtr pfont, fsBitmapFormat format,
+ Mask flags, int nranges, fsRange *range,
+ FSBlockDataPtr blockrec );
+extern int _fs_get_glyphs ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, CharInfoPtr *glyphs );
+extern void _fs_unload_font ( FontPtr pfont );
+extern void _fs_init_font ( FontPtr pfont );
+extern pointer fs_alloc_glyphs (FontPtr pFont, int size);
+#endif /* _FSERVESTR_H_ */
diff --git a/nx-X11/lib/font/fc/fsio.c b/nx-X11/lib/font/fc/fsio.c
new file mode 100644
index 000000000..fbfb9dfed
--- /dev/null
+++ b/nx-X11/lib/font/fc/fsio.c
@@ -0,0 +1,516 @@
+/* $Xorg: fsio.c,v 1.3 2000/08/17 19:46:36 cpqbld Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices
+ *
+ * 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 of Network Computing Devices not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Network Computing
+ * Devices makes no representations about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL NETWORK COMPUTING DEVICES 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.
+ *
+ * Author: Dave Lemke, Network Computing Devices, Inc
+ */
+/* $XFree86: xc/lib/font/fc/fsio.c,v 3.16tsi Exp $ */
+/*
+ * font server i/o routines
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef WIN32
+#define _WILLWINSOCK_
+#include "X11/Xwindows.h"
+#endif
+
+#define FONT_t
+#define TRANS_CLIENT
+#include "X11/Xtrans/Xtrans.h"
+#include "X11/Xpoll.h"
+#include <X11/fonts/FS.h>
+#include <X11/fonts/FSproto.h>
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+#include "fservestr.h"
+
+#include <stdio.h>
+#include <signal.h>
+#include <sys/types.h>
+#if !defined(WIN32)
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
+#endif
+#include <errno.h>
+#ifdef WIN32
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#undef EINTR
+#define EINTR WSAEINTR
+#endif
+
+#ifdef __UNIXOS2__
+#define select(n,r,w,x,t) os2PseudoSelect(n,r,w,x,t)
+#endif
+
+
+static int padlength[4] = {0, 3, 2, 1};
+fd_set _fs_fd_mask;
+
+static int
+_fs_resize (FSBufPtr buf, long size);
+
+static void
+_fs_downsize (FSBufPtr buf, long size);
+
+int
+_fs_poll_connect (XtransConnInfo trans_conn, int timeout)
+{
+ fd_set w_mask;
+ struct timeval tv;
+ int fs_fd = _FontTransGetConnectionNumber (trans_conn);
+ int ret;
+
+ do
+ {
+ tv.tv_usec = 0;
+ tv.tv_sec = timeout;
+ FD_ZERO (&w_mask);
+ FD_SET (fs_fd, &w_mask);
+ ret = Select (fs_fd + 1, NULL, &w_mask, NULL, &tv);
+ } while (ret < 0 && ECHECK(EINTR));
+ if (ret == 0)
+ return FSIO_BLOCK;
+ if (ret < 0)
+ return FSIO_ERROR;
+ return FSIO_READY;
+}
+
+XtransConnInfo
+_fs_connect(char *servername, int *err)
+{
+ XtransConnInfo trans_conn; /* transport connection object */
+ int ret;
+ int i = 0;
+ int retries = 5;
+
+ /*
+ * Open the network connection.
+ */
+ if( (trans_conn=_FontTransOpenCOTSClient(servername)) == NULL )
+ {
+ *err = FSIO_ERROR;
+ return 0;
+ }
+
+ /*
+ * Set the connection non-blocking since we use select() to block.
+ */
+
+ _FontTransSetOption(trans_conn, TRANS_NONBLOCKING, 1);
+
+ do {
+ if (i == TRANS_TRY_CONNECT_AGAIN)
+ sleep(1);
+ i = _FontTransConnect(trans_conn,servername);
+ } while ((i == TRANS_TRY_CONNECT_AGAIN) && (retries-- > 0));
+
+ if (i < 0)
+ {
+ if (i == TRANS_IN_PROGRESS)
+ ret = FSIO_BLOCK;
+ else
+ ret = FSIO_ERROR;
+ }
+ else
+ ret = FSIO_READY;
+
+ if (ret == FSIO_ERROR)
+ {
+ _FontTransClose(trans_conn);
+ trans_conn = 0;
+ }
+
+ *err = ret;
+ return trans_conn;
+}
+
+int
+_fs_fill (FSFpePtr conn)
+{
+ long avail;
+ long bytes_read;
+ Bool waited = FALSE;
+
+ if (_fs_flush (conn) < 0)
+ return FSIO_ERROR;
+ /*
+ * Don't go overboard here; stop reading when we've
+ * got enough to satisfy the pending request
+ */
+ while ((conn->inNeed - (conn->inBuf.insert - conn->inBuf.remove)) > 0)
+ {
+ avail = conn->inBuf.size - conn->inBuf.insert;
+ /*
+ * For SVR4 with a unix-domain connection, ETEST() after selecting
+ * readable means the server has died. To do this here, we look for
+ * two consecutive reads returning ETEST().
+ */
+ ESET (0);
+ bytes_read =_FontTransRead(conn->trans_conn,
+ conn->inBuf.buf + conn->inBuf.insert,
+ avail);
+ if (bytes_read > 0) {
+ conn->inBuf.insert += bytes_read;
+ waited = FALSE;
+ }
+ else
+ {
+ if (bytes_read == 0 || ETEST ())
+ {
+ if (!waited)
+ {
+ waited = TRUE;
+ if (_fs_wait_for_readable (conn, 0) == FSIO_BLOCK)
+ return FSIO_BLOCK;
+ continue;
+ }
+ }
+ _fs_connection_died (conn);
+ return FSIO_ERROR;
+ }
+ }
+ return FSIO_READY;
+}
+
+/*
+ * Make space and return whether data have already arrived
+ */
+
+int
+_fs_start_read (FSFpePtr conn, long size, char **buf)
+{
+ int ret;
+
+ conn->inNeed = size;
+ if (fs_inqueued(conn) < size)
+ {
+ if (_fs_resize (&conn->inBuf, size) != FSIO_READY)
+ {
+ _fs_connection_died (conn);
+ return FSIO_ERROR;
+ }
+ ret = _fs_fill (conn);
+ if (ret == FSIO_ERROR)
+ return ret;
+ if (ret == FSIO_BLOCK || fs_inqueued(conn) < size)
+ return FSIO_BLOCK;
+ }
+ if (buf)
+ *buf = conn->inBuf.buf + conn->inBuf.remove;
+ return FSIO_READY;
+}
+
+void
+_fs_done_read (FSFpePtr conn, long size)
+{
+ if (conn->inBuf.insert - conn->inBuf.remove < size)
+ {
+#ifdef DEBUG
+ fprintf (stderr, "_fs_done_read skipping to many bytes\n");
+#endif
+ return;
+ }
+ conn->inBuf.remove += size;
+ conn->inNeed -= size;
+ _fs_downsize (&conn->inBuf, FS_BUF_MAX);
+}
+
+long
+_fs_pad_length (long len)
+{
+ return len + padlength[len&3];
+}
+
+int
+_fs_flush (FSFpePtr conn)
+{
+ long bytes_written;
+ long remain;
+
+ /* XXX - hack. The right fix is to remember that the font server
+ has gone away when we first discovered it. */
+ if (conn->fs_fd < 0)
+ return FSIO_ERROR;
+
+ while ((remain = conn->outBuf.insert - conn->outBuf.remove) > 0)
+ {
+ bytes_written = _FontTransWrite(conn->trans_conn,
+ conn->outBuf.buf + conn->outBuf.remove,
+ (int) remain);
+ if (bytes_written > 0)
+ {
+ conn->outBuf.remove += bytes_written;
+ }
+ else
+ {
+ if (bytes_written == 0 || ETEST ())
+ {
+ conn->brokenWriteTime = GetTimeInMillis () + FS_FLUSH_POLL;
+ _fs_mark_block (conn, FS_BROKEN_WRITE);
+ break;
+ }
+ if (!ECHECK (EINTR))
+ {
+ _fs_connection_died (conn);
+ return FSIO_ERROR;
+ }
+ }
+ }
+ if (conn->outBuf.remove == conn->outBuf.insert)
+ {
+ _fs_unmark_block (conn, FS_BROKEN_WRITE|FS_PENDING_WRITE);
+ if (conn->outBuf.size > FS_BUF_INC)
+ conn->outBuf.buf = xrealloc (conn->outBuf.buf, FS_BUF_INC);
+ conn->outBuf.remove = conn->outBuf.insert = 0;
+ }
+ return FSIO_READY;
+}
+
+static int
+_fs_resize (FSBufPtr buf, long size)
+{
+ char *new;
+ long new_size;
+
+ if (buf->remove)
+ {
+ if (buf->remove != buf->insert)
+ {
+ memmove (buf->buf,
+ buf->buf + buf->remove,
+ buf->insert - buf->remove);
+ }
+ buf->insert -= buf->remove;
+ buf->remove = 0;
+ }
+ if (buf->size - buf->remove < size)
+ {
+ new_size = ((buf->remove + size + FS_BUF_INC) / FS_BUF_INC) * FS_BUF_INC;
+ new = xrealloc (buf->buf, new_size);
+ if (!new)
+ return FSIO_ERROR;
+ buf->buf = new;
+ buf->size = new_size;
+ }
+ return FSIO_READY;
+}
+
+static void
+_fs_downsize (FSBufPtr buf, long size)
+{
+ if (buf->insert == buf->remove)
+ {
+ buf->insert = buf->remove = 0;
+ if (buf->size > size)
+ {
+ buf->buf = xrealloc (buf->buf, size);
+ buf->size = size;
+ }
+ }
+}
+
+void
+_fs_io_reinit (FSFpePtr conn)
+{
+ conn->outBuf.insert = conn->outBuf.remove = 0;
+ _fs_downsize (&conn->outBuf, FS_BUF_INC);
+ conn->inBuf.insert = conn->inBuf.remove = 0;
+ _fs_downsize (&conn->inBuf, FS_BUF_MAX);
+}
+
+Bool
+_fs_io_init (FSFpePtr conn)
+{
+ conn->outBuf.insert = conn->outBuf.remove = 0;
+ conn->outBuf.buf = xalloc (FS_BUF_INC);
+ if (!conn->outBuf.buf)
+ return FALSE;
+ conn->outBuf.size = FS_BUF_INC;
+
+ conn->inBuf.insert = conn->inBuf.remove = 0;
+ conn->inBuf.buf = xalloc (FS_BUF_INC);
+ if (!conn->inBuf.buf)
+ {
+ xfree (conn->outBuf.buf);
+ conn->outBuf.buf = 0;
+ return FALSE;
+ }
+ conn->inBuf.size = FS_BUF_INC;
+
+ return TRUE;
+}
+
+void
+_fs_io_fini (FSFpePtr conn)
+{
+ if (conn->outBuf.buf)
+ xfree (conn->outBuf.buf);
+ if (conn->inBuf.buf)
+ xfree (conn->inBuf.buf);
+}
+
+static int
+_fs_do_write(FSFpePtr conn, char *data, long len, long size)
+{
+ if (size == 0) {
+#ifdef DEBUG
+ fprintf(stderr, "tried to write 0 bytes \n");
+#endif
+ return FSIO_READY;
+ }
+
+ if (conn->fs_fd == -1)
+ return FSIO_ERROR;
+
+ while (conn->outBuf.insert + size > conn->outBuf.size)
+ {
+ if (_fs_flush (conn) < 0)
+ return FSIO_ERROR;
+ if (_fs_resize (&conn->outBuf, size) < 0)
+ {
+ _fs_connection_died (conn);
+ return FSIO_ERROR;
+ }
+ }
+ memcpy (conn->outBuf.buf + conn->outBuf.insert, data, len);
+ conn->outBuf.insert += size;
+ _fs_mark_block (conn, FS_PENDING_WRITE);
+ return FSIO_READY;
+}
+
+/*
+ * Write the indicated bytes
+ */
+int
+_fs_write (FSFpePtr conn, char *data, long len)
+{
+ return _fs_do_write (conn, data, len, len);
+}
+
+/*
+ * Write the indicated bytes adding any appropriate pad
+ */
+int
+_fs_write_pad(FSFpePtr conn, char *data, long len)
+{
+ return _fs_do_write (conn, data, len, len + padlength[len & 3]);
+}
+
+/*
+ * returns the amount of data waiting to be read
+ */
+int
+_fs_data_ready(FSFpePtr conn)
+{
+ BytesReadable_t readable;
+
+ if (_FontTransBytesReadable(conn->trans_conn, &readable) < 0)
+ return -1;
+ return readable;
+}
+
+int
+_fs_wait_for_readable(FSFpePtr conn, int ms)
+{
+ fd_set r_mask;
+ fd_set e_mask;
+ int result;
+ struct timeval tv;
+
+ for (;;) {
+ if (conn->fs_fd < 0)
+ return FSIO_ERROR;
+ FD_ZERO(&r_mask);
+ FD_ZERO(&e_mask);
+ tv.tv_sec = ms / 1000;
+ tv.tv_usec = (ms % 1000) * 1000;
+ FD_SET(conn->fs_fd, &r_mask);
+ FD_SET(conn->fs_fd, &e_mask);
+ result = Select(conn->fs_fd + 1, &r_mask, NULL, &e_mask, &tv);
+ if (result < 0)
+ {
+ if (ECHECK(EINTR) || ECHECK(EAGAIN))
+ continue;
+ else
+ return FSIO_ERROR;
+ }
+ if (result == 0)
+ return FSIO_BLOCK;
+ if (FD_ISSET(conn->fs_fd, &r_mask))
+ return FSIO_READY;
+ return FSIO_ERROR;
+ }
+}
+
+int
+_fs_set_bit(fd_set *mask, int fd)
+{
+ FD_SET(fd, mask);
+ return fd;
+}
+
+int
+_fs_is_bit_set(fd_set *mask, int fd)
+{
+ return FD_ISSET(fd, mask);
+}
+
+void
+_fs_bit_clear(fd_set *mask, int fd)
+{
+ FD_CLR(fd, mask);
+}
+
+int
+_fs_any_bit_set(fd_set *mask)
+{
+ return XFD_ANYSET(mask);
+}
+
+void
+_fs_or_bits(fd_set *dst, fd_set *m1, fd_set *m2)
+{
+#ifdef WIN32
+ int i;
+ if (dst != m1) {
+ for (i = m1->fd_count; --i >= 0; ) {
+ if (!FD_ISSET(m1->fd_array[i], dst))
+ FD_SET(m1->fd_array[i], dst);
+ }
+ }
+ if (dst != m2) {
+ for (i = m2->fd_count; --i >= 0; ) {
+ if (!FD_ISSET(m2->fd_array[i], dst))
+ FD_SET(m2->fd_array[i], dst);
+ }
+ }
+#else
+ XFD_ORSET(dst, m1, m2);
+#endif
+}
diff --git a/nx-X11/lib/font/fc/fsio.h b/nx-X11/lib/font/fc/fsio.h
new file mode 100644
index 000000000..224143601
--- /dev/null
+++ b/nx-X11/lib/font/fc/fsio.h
@@ -0,0 +1,187 @@
+/* $Xorg: fsio.h,v 1.3 2000/08/17 19:46:36 cpqbld Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices
+ *
+ * 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 of Network Computing Devices not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Network Computing
+ * Devices makes no representations about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL NETWORK COMPUTING DEVICES 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.
+ *
+ * Author: Dave Lemke, Network Computing Devices, Inc
+ */
+/* $XFree86: xc/lib/font/fc/fsio.h,v 1.5 1999/12/30 02:39:06 robin Exp $ */
+
+#ifndef _FSIO_H_
+#define _FSIO_H_
+
+#undef DEBUG
+#define REQUEST_LOG_SIZE 100
+
+typedef struct _fs_fpe_alternate {
+ char *name;
+ Bool subset;
+} FSFpeAltRec, *FSFpeAltPtr;
+
+
+/* Per client access contexts */
+typedef struct _fs_client_data {
+ pointer client;
+ struct _fs_client_data *next;
+ XID acid;
+ int auth_generation;
+} FSClientRec, *FSClientPtr;
+
+#define FS_RECONNECT_POLL 1000
+#define FS_RECONNECT_WAIT 5000
+#define FS_GIVEUP_WAIT 20000
+#define FS_REQUEST_TIMEOUT 20000
+#define FS_OPEN_TIMEOUT 30000
+#define FS_REOPEN_TIMEOUT 10000
+#define FS_FLUSH_POLL 1000
+
+typedef struct _fs_buf {
+ char *buf; /* data */
+ long size; /* sizeof data */
+ long insert; /* where to insert new data */
+ long remove; /* where to remove old data */
+} FSBufRec, *FSBufPtr;
+
+#define FS_BUF_INC 1024
+#define FS_BUF_MAX 32768
+
+#define FS_PENDING_WRITE 0x01 /* some write data is queued */
+#define FS_BROKEN_WRITE 0x02 /* writes are broken */
+#define FS_BROKEN_CONNECTION 0x04 /* connection is broken */
+#define FS_PENDING_REPLY 0x08 /* waiting for a reply */
+#define FS_GIVE_UP 0x10 /* font server declared useless */
+#define FS_COMPLETE_REPLY 0x20 /* complete reply ready */
+#define FS_RECONNECTING 0x40
+
+#define FS_CONN_UNCONNECTED 0
+#define FS_CONN_CONNECTING 1
+#define FS_CONN_CONNECTED 2
+#define FS_CONN_SENT_PREFIX 3
+#define FS_CONN_RECV_INIT 4
+#define FS_CONN_SENT_CAT 5
+#define FS_CONN_RUNNING 6
+
+/* FS specific font FontPathElement data */
+typedef struct _fs_fpe_data {
+ FSFpePtr next; /* list of all active fs fpes */
+ int fs_fd; /* < 0 when not running */
+ int fs_conn_state; /* connection state */
+ int current_seq;
+ char *servername;
+ Bool has_catalogues;
+
+ int generation;
+ int numAlts;
+ int alternate; /* which alternate is in use +1 */
+ int fsMajorVersion; /* font server major version number */
+ FSFpeAltPtr alts;
+
+ FSClientPtr clients;
+ XID curacid;
+#ifdef DEBUG
+ int reqindex;
+ struct {
+ int opcode;
+ int sequence;
+ } reqbuffer[REQUEST_LOG_SIZE];
+#endif
+ FSBufRec outBuf; /* request queue */
+ FSBufRec inBuf; /* reply queue */
+ long inNeed; /* amount needed for reply */
+
+ CARD32 blockState;
+ CARD32 blockedReplyTime; /* time to abort blocked read */
+ CARD32 brokenWriteTime; /* time to retry broken write */
+ CARD32 blockedConnectTime; /* time to abort blocked connect */
+ CARD32 brokenConnectionTime; /* time to retry broken connection */
+
+ FSBlockDataPtr blockedRequests;
+
+ struct _XtransConnInfo *trans_conn; /* transport connection object */
+} FSFpeRec;
+
+#define fs_outspace(conn) ((conn)->outBuf.size - (conn)->outBuf.insert)
+#define fs_outqueued(conn) ((conn)->outBuf.insert - (conn)->outBuf.remove)
+#define fs_inqueued(conn) ((conn)->inBuf.insert - (conn)->inBuf.remove)
+#define fs_needsflush(conn) (fs_outqueued(conn) != 0)
+#define fs_needsfill(conn) (fs_inqueued(conn) < (conn)->inNeed)
+#define fs_needsconnect(conn) ((conn)->fs_fd < 0)
+#define fs_data_read(conn) ((conn)->inBuf.insert - (conn)->inBuf.remove)
+
+#define FSIO_READY 1
+#define FSIO_BLOCK 0
+#define FSIO_ERROR -1
+
+extern Bool _fs_reopen_server ( FSFpePtr conn );
+extern int _fs_write ( FSFpePtr conn, char *data, long size );
+extern int _fs_write_pad ( FSFpePtr conn, char *data, long len );
+extern int _fs_data_ready ( FSFpePtr conn );
+extern int _fs_wait_for_readable ( FSFpePtr conn, int ms );
+extern int _fs_set_bit ( fd_set * mask, int fd );
+extern int _fs_is_bit_set ( fd_set * mask, int fd );
+extern void _fs_bit_clear ( fd_set * mask, int fd );
+extern int _fs_any_bit_set ( fd_set * mask );
+extern void _fs_or_bits ( fd_set * dst, fd_set * m1, fd_set * m2 );
+extern long _fs_pad_length (long len);
+
+extern void _fs_connection_died ( FSFpePtr conn );
+
+extern int _fs_fill (FSFpePtr conn);
+extern int _fs_flush (FSFpePtr conn);
+extern void _fs_mark_block (FSFpePtr conn, CARD32 mask);
+extern void _fs_unmark_block (FSFpePtr conn, CARD32 mask);
+extern void _fs_done_read (FSFpePtr conn, long size);
+extern void _fs_io_reinit (FSFpePtr conn);
+extern int _fs_start_read (FSFpePtr conn, long size, char **buf);
+extern Bool _fs_io_init (FSFpePtr conn);
+extern void _fs_io_fini (FSFpePtr conn);
+extern int _fs_poll_connect (XtransConnInfo trans_conn, int timeout);
+extern XtransConnInfo _fs_connect(char *servername, int *ret);
+
+/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ */
+#ifdef WIN32
+#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK)
+#else
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define ETEST() (errno == EAGAIN)
+#else
+#define ETEST() (errno == EWOULDBLOCK)
+#endif
+#endif
+#endif
+#ifdef WIN32
+#define ECHECK(err) (WSAGetLastError() == err)
+#define ESET(val) WSASetLastError(val)
+#else
+#ifdef ISC
+#define ECHECK(err) ((errno == err) || ETEST())
+#else
+#define ECHECK(err) (errno == err)
+#endif
+#define ESET(val) errno = val
+#endif
+
+#endif /* _FSIO_H_ */
diff --git a/nx-X11/lib/font/fc/fsio.h.NX.reference b/nx-X11/lib/font/fc/fsio.h.NX.reference
new file mode 100644
index 000000000..f79a17b90
--- /dev/null
+++ b/nx-X11/lib/font/fc/fsio.h.NX.reference
@@ -0,0 +1,191 @@
+/* $Xorg: fsio.h,v 1.3 2000/08/17 19:46:36 cpqbld Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices
+ *
+ * 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 of Network Computing Devices not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Network Computing
+ * Devices makes no representations about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL NETWORK COMPUTING DEVICES 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.
+ *
+ * Author: Dave Lemke, Network Computing Devices, Inc
+ */
+/* $XFree86: xc/lib/font/fc/fsio.h,v 1.6 2001/01/17 19:43:29 dawes Exp $ */
+
+#ifndef _FSIO_H_
+#define _FSIO_H_
+
+#undef DEBUG
+#define REQUEST_LOG_SIZE 100
+
+typedef struct _fs_fpe_alternate {
+ char *name;
+ Bool subset;
+} FSFpeAltRec, *FSFpeAltPtr;
+
+
+/* Per client access contexts */
+typedef struct _fs_client_data {
+ pointer client;
+ struct _fs_client_data *next;
+ XID acid;
+ int auth_generation;
+} FSClientRec, *FSClientPtr;
+
+#define FS_RECONNECT_POLL 1000
+#ifdef __CYGWIN__
+#define FS_RECONNECT_WAIT 800
+#else
+#define FS_RECONNECT_WAIT 5000
+#endif
+#define FS_GIVEUP_WAIT 20000
+#define FS_REQUEST_TIMEOUT 20000
+#define FS_OPEN_TIMEOUT 30000
+#define FS_REOPEN_TIMEOUT 10000
+#define FS_FLUSH_POLL 1000
+
+typedef struct _fs_buf {
+ char *buf; /* data */
+ long size; /* sizeof data */
+ long insert; /* where to insert new data */
+ long remove; /* where to remove old data */
+} FSBufRec, *FSBufPtr;
+
+#define FS_BUF_INC 1024
+#define FS_BUF_MAX 32768
+
+#define FS_PENDING_WRITE 0x01 /* some write data is queued */
+#define FS_BROKEN_WRITE 0x02 /* writes are broken */
+#define FS_BROKEN_CONNECTION 0x04 /* connection is broken */
+#define FS_PENDING_REPLY 0x08 /* waiting for a reply */
+#define FS_GIVE_UP 0x10 /* font server declared useless */
+#define FS_COMPLETE_REPLY 0x20 /* complete reply ready */
+#define FS_RECONNECTING 0x40
+
+#define FS_CONN_UNCONNECTED 0
+#define FS_CONN_CONNECTING 1
+#define FS_CONN_CONNECTED 2
+#define FS_CONN_SENT_PREFIX 3
+#define FS_CONN_RECV_INIT 4
+#define FS_CONN_SENT_CAT 5
+#define FS_CONN_RUNNING 6
+
+/* FS specific font FontPathElement data */
+typedef struct _fs_fpe_data {
+ FSFpePtr next; /* list of all active fs fpes */
+ int fs_fd; /* < 0 when not running */
+ int fs_conn_state; /* connection state */
+ int current_seq;
+ char *servername;
+ Bool has_catalogues;
+
+ int generation;
+ int numAlts;
+ int alternate; /* which alternate is in use +1 */
+ int fsMajorVersion; /* font server major version number */
+ FSFpeAltPtr alts;
+
+ FSClientPtr clients;
+ XID curacid;
+#ifdef DEBUG
+ int reqindex;
+ struct {
+ int opcode;
+ int sequence;
+ } reqbuffer[REQUEST_LOG_SIZE];
+#endif
+ FSBufRec outBuf; /* request queue */
+ FSBufRec inBuf; /* reply queue */
+ long inNeed; /* amount needed for reply */
+
+ CARD32 blockState;
+ CARD32 blockedReplyTime; /* time to abort blocked read */
+ CARD32 brokenWriteTime; /* time to retry broken write */
+ CARD32 blockedConnectTime; /* time to abort blocked connect */
+ CARD32 brokenConnectionTime; /* time to retry broken connection */
+
+ FSBlockDataPtr blockedRequests;
+
+ struct _XtransConnInfo *trans_conn; /* transport connection object */
+} FSFpeRec;
+
+#define fs_outspace(conn) ((conn)->outBuf.size - (conn)->outBuf.insert)
+#define fs_outqueued(conn) ((conn)->outBuf.insert - (conn)->outBuf.remove)
+#define fs_inqueued(conn) ((conn)->inBuf.insert - (conn)->inBuf.remove)
+#define fs_needsflush(conn) (fs_outqueued(conn) != 0)
+#define fs_needsfill(conn) (fs_inqueued(conn) < (conn)->inNeed)
+#define fs_needsconnect(conn) ((conn)->fs_fd < 0)
+#define fs_data_read(conn) ((conn)->inBuf.insert - (conn)->inBuf.remove)
+
+#define FSIO_READY 1
+#define FSIO_BLOCK 0
+#define FSIO_ERROR -1
+
+extern Bool _fs_reopen_server ( FSFpePtr conn );
+extern int _fs_write ( FSFpePtr conn, char *data, long size );
+extern int _fs_write_pad ( FSFpePtr conn, char *data, long len );
+extern int _fs_data_ready ( FSFpePtr conn );
+extern int _fs_wait_for_readable ( FSFpePtr conn, int ms );
+extern int _fs_set_bit ( fd_set * mask, int fd );
+extern int _fs_is_bit_set ( fd_set * mask, int fd );
+extern void _fs_bit_clear ( fd_set * mask, int fd );
+extern int _fs_any_bit_set ( fd_set * mask );
+extern void _fs_or_bits ( fd_set * dst, fd_set * m1, fd_set * m2 );
+extern long _fs_pad_length (long len);
+
+extern void _fs_connection_died ( FSFpePtr conn );
+
+extern int _fs_fill (FSFpePtr conn);
+extern int _fs_flush (FSFpePtr conn);
+extern void _fs_mark_block (FSFpePtr conn, CARD32 mask);
+extern void _fs_unmark_block (FSFpePtr conn, CARD32 mask);
+extern void _fs_done_read (FSFpePtr conn, long size);
+extern void _fs_io_reinit (FSFpePtr conn);
+extern int _fs_start_read (FSFpePtr conn, long size, char **buf);
+extern Bool _fs_io_init (FSFpePtr conn);
+extern void _fs_io_fini (FSFpePtr conn);
+extern int _fs_poll_connect (XtransConnInfo trans_conn, int timeout);
+extern XtransConnInfo _fs_connect(char *servername, int *ret);
+
+/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ */
+#ifdef WIN32
+#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK)
+#else
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define ETEST() (errno == EAGAIN)
+#else
+#define ETEST() (errno == EWOULDBLOCK)
+#endif
+#endif
+#endif
+#ifdef WIN32
+#define ECHECK(err) (WSAGetLastError() == err)
+#define ESET(val) WSASetLastError(val)
+#else
+#ifdef ISC
+#define ECHECK(err) ((errno == err) || ETEST())
+#else
+#define ECHECK(err) (errno == err)
+#endif
+#define ESET(val) errno = val
+#endif
+
+#endif /* _FSIO_H_ */
diff --git a/nx-X11/lib/font/fc/fsio.h.XF86.reference b/nx-X11/lib/font/fc/fsio.h.XF86.reference
new file mode 100644
index 000000000..974ef4a91
--- /dev/null
+++ b/nx-X11/lib/font/fc/fsio.h.XF86.reference
@@ -0,0 +1,187 @@
+/* $Xorg: fsio.h,v 1.3 2000/08/17 19:46:36 cpqbld Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices
+ *
+ * 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 of Network Computing Devices not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Network Computing
+ * Devices makes no representations about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL NETWORK COMPUTING DEVICES 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.
+ *
+ * Author: Dave Lemke, Network Computing Devices, Inc
+ */
+/* $XFree86: xc/lib/font/fc/fsio.h,v 1.6 2001/01/17 19:43:29 dawes Exp $ */
+
+#ifndef _FSIO_H_
+#define _FSIO_H_
+
+#undef DEBUG
+#define REQUEST_LOG_SIZE 100
+
+typedef struct _fs_fpe_alternate {
+ char *name;
+ Bool subset;
+} FSFpeAltRec, *FSFpeAltPtr;
+
+
+/* Per client access contexts */
+typedef struct _fs_client_data {
+ pointer client;
+ struct _fs_client_data *next;
+ XID acid;
+ int auth_generation;
+} FSClientRec, *FSClientPtr;
+
+#define FS_RECONNECT_POLL 1000
+#define FS_RECONNECT_WAIT 5000
+#define FS_GIVEUP_WAIT 20000
+#define FS_REQUEST_TIMEOUT 20000
+#define FS_OPEN_TIMEOUT 30000
+#define FS_REOPEN_TIMEOUT 10000
+#define FS_FLUSH_POLL 1000
+
+typedef struct _fs_buf {
+ char *buf; /* data */
+ long size; /* sizeof data */
+ long insert; /* where to insert new data */
+ long remove; /* where to remove old data */
+} FSBufRec, *FSBufPtr;
+
+#define FS_BUF_INC 1024
+#define FS_BUF_MAX 32768
+
+#define FS_PENDING_WRITE 0x01 /* some write data is queued */
+#define FS_BROKEN_WRITE 0x02 /* writes are broken */
+#define FS_BROKEN_CONNECTION 0x04 /* connection is broken */
+#define FS_PENDING_REPLY 0x08 /* waiting for a reply */
+#define FS_GIVE_UP 0x10 /* font server declared useless */
+#define FS_COMPLETE_REPLY 0x20 /* complete reply ready */
+#define FS_RECONNECTING 0x40
+
+#define FS_CONN_UNCONNECTED 0
+#define FS_CONN_CONNECTING 1
+#define FS_CONN_CONNECTED 2
+#define FS_CONN_SENT_PREFIX 3
+#define FS_CONN_RECV_INIT 4
+#define FS_CONN_SENT_CAT 5
+#define FS_CONN_RUNNING 6
+
+/* FS specific font FontPathElement data */
+typedef struct _fs_fpe_data {
+ FSFpePtr next; /* list of all active fs fpes */
+ int fs_fd; /* < 0 when not running */
+ int fs_conn_state; /* connection state */
+ int current_seq;
+ char *servername;
+ Bool has_catalogues;
+
+ int generation;
+ int numAlts;
+ int alternate; /* which alternate is in use +1 */
+ int fsMajorVersion; /* font server major version number */
+ FSFpeAltPtr alts;
+
+ FSClientPtr clients;
+ XID curacid;
+#ifdef DEBUG
+ int reqindex;
+ struct {
+ int opcode;
+ int sequence;
+ } reqbuffer[REQUEST_LOG_SIZE];
+#endif
+ FSBufRec outBuf; /* request queue */
+ FSBufRec inBuf; /* reply queue */
+ long inNeed; /* amount needed for reply */
+
+ CARD32 blockState;
+ CARD32 blockedReplyTime; /* time to abort blocked read */
+ CARD32 brokenWriteTime; /* time to retry broken write */
+ CARD32 blockedConnectTime; /* time to abort blocked connect */
+ CARD32 brokenConnectionTime; /* time to retry broken connection */
+
+ FSBlockDataPtr blockedRequests;
+
+ struct _XtransConnInfo *trans_conn; /* transport connection object */
+} FSFpeRec;
+
+#define fs_outspace(conn) ((conn)->outBuf.size - (conn)->outBuf.insert)
+#define fs_outqueued(conn) ((conn)->outBuf.insert - (conn)->outBuf.remove)
+#define fs_inqueued(conn) ((conn)->inBuf.insert - (conn)->inBuf.remove)
+#define fs_needsflush(conn) (fs_outqueued(conn) != 0)
+#define fs_needsfill(conn) (fs_inqueued(conn) < (conn)->inNeed)
+#define fs_needsconnect(conn) ((conn)->fs_fd < 0)
+#define fs_data_read(conn) ((conn)->inBuf.insert - (conn)->inBuf.remove)
+
+#define FSIO_READY 1
+#define FSIO_BLOCK 0
+#define FSIO_ERROR -1
+
+extern Bool _fs_reopen_server ( FSFpePtr conn );
+extern int _fs_write ( FSFpePtr conn, char *data, long size );
+extern int _fs_write_pad ( FSFpePtr conn, char *data, long len );
+extern int _fs_data_ready ( FSFpePtr conn );
+extern int _fs_wait_for_readable ( FSFpePtr conn, int ms );
+extern int _fs_set_bit ( fd_set * mask, int fd );
+extern int _fs_is_bit_set ( fd_set * mask, int fd );
+extern void _fs_bit_clear ( fd_set * mask, int fd );
+extern int _fs_any_bit_set ( fd_set * mask );
+extern void _fs_or_bits ( fd_set * dst, fd_set * m1, fd_set * m2 );
+extern long _fs_pad_length (long len);
+
+extern void _fs_connection_died ( FSFpePtr conn );
+
+extern int _fs_fill (FSFpePtr conn);
+extern int _fs_flush (FSFpePtr conn);
+extern void _fs_mark_block (FSFpePtr conn, CARD32 mask);
+extern void _fs_unmark_block (FSFpePtr conn, CARD32 mask);
+extern void _fs_done_read (FSFpePtr conn, long size);
+extern void _fs_io_reinit (FSFpePtr conn);
+extern int _fs_start_read (FSFpePtr conn, long size, char **buf);
+extern Bool _fs_io_init (FSFpePtr conn);
+extern void _fs_io_fini (FSFpePtr conn);
+extern int _fs_poll_connect (XtransConnInfo trans_conn, int timeout);
+extern XtransConnInfo _fs_connect(char *servername, int *ret);
+
+/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ */
+#ifdef WIN32
+#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK)
+#else
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define ETEST() (errno == EAGAIN)
+#else
+#define ETEST() (errno == EWOULDBLOCK)
+#endif
+#endif
+#endif
+#ifdef WIN32
+#define ECHECK(err) (WSAGetLastError() == err)
+#define ESET(val) WSASetLastError(val)
+#else
+#ifdef ISC
+#define ECHECK(err) ((errno == err) || ETEST())
+#else
+#define ECHECK(err) (errno == err)
+#endif
+#define ESET(val) errno = val
+#endif
+
+#endif /* _FSIO_H_ */
diff --git a/nx-X11/lib/font/fc/fslibos.h b/nx-X11/lib/font/fc/fslibos.h
new file mode 100644
index 000000000..acc1f16dc
--- /dev/null
+++ b/nx-X11/lib/font/fc/fslibos.h
@@ -0,0 +1,220 @@
+/* $Xorg: fslibos.h,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+/*
+ * Copyright 1990 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment Corporation
+ */
+
+/*
+
+Copyright 1987, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fc/fslibos.h,v 3.8 2003/08/29 18:01:14 herrb Exp $ */
+
+/*
+ * FSlib networking & os include file
+ */
+
+#include <X11/Xtrans/Xtrans.h>
+
+#ifndef WIN32
+
+/*
+ * makedepend screws up on #undef OPEN_MAX, so we define a new symbol
+ */
+
+#ifndef FONT_OPEN_MAX
+
+#ifndef X_NOT_POSIX
+# ifdef _POSIX_SOURCE
+# include <limits.h>
+# else
+# define _POSIX_SOURCE
+# include <limits.h>
+# undef _POSIX_SOURCE
+# endif
+#endif
+#ifndef SIZE_MAX
+# ifdef ULONG_MAX
+# define SIZE_MAX ULONG_MAX
+# else
+# define SIZE_MAX UINT_MAX
+# endif
+#endif
+#ifndef OPEN_MAX
+#if defined(SVR4) || defined(__UNIXOS2__)
+#define OPEN_MAX 256
+#else
+#include <sys/param.h>
+#ifndef OPEN_MAX
+#ifdef __OSF1__
+#define OPEN_MAX 256
+#else
+#ifdef NOFILE
+#define OPEN_MAX NOFILE
+#else
+#define OPEN_MAX NOFILES_MAX
+#endif
+#endif
+#endif
+#endif
+#endif
+
+#if OPEN_MAX > 256
+#define FONT_OPEN_MAX 256
+#else
+#define FONT_OPEN_MAX OPEN_MAX
+#endif
+
+#endif /* FONT_OPEN_MAX */
+
+#ifdef WORD64
+#define NMSKBITS 64
+#else
+#define NMSKBITS 32
+#endif
+
+#define MSKCNT ((FONT_OPEN_MAX + NMSKBITS - 1) / NMSKBITS)
+
+typedef unsigned long FdSet[MSKCNT];
+typedef FdSet FdSetPtr;
+
+#if (MSKCNT==1)
+#define BITMASK(i) (1 << (i))
+#define MASKIDX(i) 0
+#endif
+
+#if (MSKCNT>1)
+#define BITMASK(i) (1 << ((i) & (NMSKBITS - 1)))
+#define MASKIDX(i) ((i) / NMSKBITS)
+#endif
+
+#define MASKWORD(buf, i) buf[MASKIDX(i)]
+#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
+#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
+#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
+
+#if (MSKCNT==1)
+#define COPYBITS(src, dst) dst[0] = src[0]
+#define CLEARBITS(buf) buf[0] = 0
+#define MASKANDSETBITS(dst, b1, b2) dst[0] = (b1[0] & b2[0])
+#define ORBITS(dst, b1, b2) dst[0] = (b1[0] | b2[0])
+#define UNSETBITS(dst, b1) (dst[0] &= ~b1[0])
+#define ANYSET(src) (src[0])
+#endif
+
+#if (MSKCNT==2)
+#define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; }
+#define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; }
+#define MASKANDSETBITS(dst, b1, b2) {\
+ dst[0] = (b1[0] & b2[0]);\
+ dst[1] = (b1[1] & b2[1]); }
+#define ORBITS(dst, b1, b2) {\
+ dst[0] = (b1[0] | b2[0]);\
+ dst[1] = (b1[1] | b2[1]); }
+#define UNSETBITS(dst, b1) {\
+ dst[0] &= ~b1[0]; \
+ dst[1] &= ~b1[1]; }
+#define ANYSET(src) (src[0] || src[1])
+#endif
+
+#if (MSKCNT==3)
+#define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; \
+ dst[2] = src[2]; }
+#define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; buf[2] = 0; }
+#define MASKANDSETBITS(dst, b1, b2) {\
+ dst[0] = (b1[0] & b2[0]);\
+ dst[1] = (b1[1] & b2[1]);\
+ dst[2] = (b1[2] & b2[2]); }
+#define ORBITS(dst, b1, b2) {\
+ dst[0] = (b1[0] | b2[0]);\
+ dst[1] = (b1[1] | b2[1]);\
+ dst[2] = (b1[2] | b2[2]); }
+#define UNSETBITS(dst, b1) {\
+ dst[0] &= ~b1[0]; \
+ dst[1] &= ~b1[1]; \
+ dst[2] &= ~b1[2]; }
+#define ANYSET(src) (src[0] || src[1] || src[2])
+#endif
+
+#if (MSKCNT==4)
+#define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; \
+ dst[2] = src[2]; dst[3] = src[3]
+#define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0
+#define MASKANDSETBITS(dst, b1, b2) \
+ dst[0] = (b1[0] & b2[0]);\
+ dst[1] = (b1[1] & b2[1]);\
+ dst[2] = (b1[2] & b2[2]);\
+ dst[3] = (b1[3] & b2[3])
+#define ORBITS(dst, b1, b2) \
+ dst[0] = (b1[0] | b2[0]);\
+ dst[1] = (b1[1] | b2[1]);\
+ dst[2] = (b1[2] | b2[2]);\
+ dst[3] = (b1[3] | b2[3])
+#define UNSETBITS(dst, b1) \
+ dst[0] &= ~b1[0]; \
+ dst[1] &= ~b1[1]; \
+ dst[2] &= ~b1[2]; \
+ dst[3] &= ~b1[3]
+#define ANYSET(src) (src[0] || src[1] || src[2] || src[3])
+#endif
+
+#if (MSKCNT>4)
+#define COPYBITS(src, dst) memmove((caddr_t) dst, (caddr_t) src,\
+ MSKCNT*sizeof(long))
+#define CLEARBITS(buf) bzero((caddr_t) buf, MSKCNT*sizeof(long))
+#define MASKANDSETBITS(dst, b1, b2) \
+ { int cri; \
+ for (cri=MSKCNT; --cri>=0; ) \
+ dst[cri] = (b1[cri] & b2[cri]); }
+#define ORBITS(dst, b1, b2) \
+ { int cri; \
+ for (cri=MSKCNT; --cri>=0; ) \
+ dst[cri] = (b1[cri] | b2[cri]); }
+#define UNSETBITS(dst, b1) \
+ { int cri; \
+ for (cri=MSKCNT; --cri>=0; ) \
+ dst[cri] &= ~b1[cri]; }
+#if (MSKCNT==8)
+#define ANYSET(src) (src[0] || src[1] || src[2] || src[3] || \
+ src[4] || src[5] || src[6] || src[7])
+#endif
+#endif
+
+#else /* not WIN32 */
+
+#include <X11/Xwinsock.h>
+#include <X11/Xw32defs.h>
+
+typedef fd_set FdSet;
+typedef FdSet *FdSetPtr;
+
+#define CLEARBITS(set) FD_ZERO(&set)
+#define BITSET(set,s) FD_SET(s,&set)
+#define BITCLEAR(set,s) FD_CLR(s,&set)
+#define GETBIT(set,s) FD_ISSET(s,&set)
+#define ANYSET(set) set->fd_count
+
+#endif
diff --git a/nx-X11/lib/font/fontcache/Imakefile b/nx-X11/lib/font/fontcache/Imakefile
new file mode 100644
index 000000000..1c8526d6c
--- /dev/null
+++ b/nx-X11/lib/font/fontcache/Imakefile
@@ -0,0 +1,29 @@
+XCOMM Id: Imakefile,v 1.2 1999/01/31 13:02:46 akiyama Exp $
+
+
+
+XCOMM $XFree86$
+
+#include <Server.tmpl>
+
+#if BuildFontCache
+FONTCACHE_DEFINES = FontCacheExtensionDefines
+#endif
+ INCLUDES = -I. -I$(FONTINCSRC) -I../include
+ HEADERS =
+ SRCS = fontcache.c
+ OBJS = fontcache.o
+
+#define DoNormalLib NormalLibFont
+#define DoSharedLib SharedLibFont
+#define DoDebugLib DebugLibFont
+#define DoProfileLib ProfileLibFont
+#include <Library.tmpl>
+LibraryObjectRule()
+
+SpecialCLibObjectRule(fontcache,$(ICONFIGFILES),$(FONTCACHE_DEFINES))
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/lib/font/fontcache/fcqueue.h b/nx-X11/lib/font/fontcache/fcqueue.h
new file mode 100644
index 000000000..58ba6dfa1
--- /dev/null
+++ b/nx-X11/lib/font/fontcache/fcqueue.h
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)queue.h 8.5 (Berkeley) 8/20/94
+ * $_Id_: queue.h,v 1.10.2.4 1998/05/12 16:35:25 bde Exp $
+ *
+ * ----------------------------------------------------------------------
+ *
+ * Note:
+ * This header file derived from FreeBSD-2.2.7
+ * /usr/include/sys/queue.h, modified for X-TrueType Server by
+ * Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
+ *
+ * Id: fcqueue.h,v 1.1 1999/01/06 13:36:42 akiyama Exp $
+ */
+
+#ifndef _FCQUEUE_H_
+#define _FCQUEUE_H_
+
+/*
+ * Tail queue definitions.
+ */
+#define TAILQ_HEAD(name, type) \
+struct name { \
+ struct type *tqh_first; /* first element */ \
+ struct type **tqh_last; /* addr of last next element */ \
+}
+
+#define TAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).tqh_first }
+
+#define TAILQ_ENTRY(type) \
+struct { \
+ struct type *tqe_next; /* next element */ \
+ struct type **tqe_prev; /* address of previous next element */ \
+}
+
+/*
+ * Tail queue functions.
+ */
+#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
+
+#define TAILQ_FOREACH(var, head, field) \
+ for (var = TAILQ_FIRST(head); var; var = TAILQ_NEXT(var, field))
+
+#define TAILQ_FIRST(head) ((head)->tqh_first)
+
+#define TAILQ_LAST(head, headname) \
+ (*(((struct headname *)((head)->tqh_last))->tqh_last))
+
+#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
+
+#define TAILQ_PREV(elm, headname, field) \
+ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+#define TAILQ_INIT(head) do { \
+ (head)->tqh_first = NULL; \
+ (head)->tqh_last = &(head)->tqh_first; \
+} while (0)
+
+#define TAILQ_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
+ (head)->tqh_first->field.tqe_prev = \
+ &(elm)->field.tqe_next; \
+ else \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+ (head)->tqh_first = (elm); \
+ (elm)->field.tqe_prev = &(head)->tqh_first; \
+} while (0)
+
+#define TAILQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.tqe_next = NULL; \
+ (elm)->field.tqe_prev = (head)->tqh_last; \
+ *(head)->tqh_last = (elm); \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+} while (0)
+
+#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+ (elm)->field.tqe_next->field.tqe_prev = \
+ &(elm)->field.tqe_next; \
+ else \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+ (listelm)->field.tqe_next = (elm); \
+ (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
+} while (0)
+
+#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
+ (elm)->field.tqe_next = (listelm); \
+ *(listelm)->field.tqe_prev = (elm); \
+ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
+} while (0)
+
+#define TAILQ_REMOVE(head, elm, field) do { \
+ if (((elm)->field.tqe_next) != NULL) \
+ (elm)->field.tqe_next->field.tqe_prev = \
+ (elm)->field.tqe_prev; \
+ else \
+ (head)->tqh_last = (elm)->field.tqe_prev; \
+ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
+} while (0)
+
+#endif /* _FCQUEUE_H_ */
diff --git a/nx-X11/lib/font/fontcache/fontcache.c b/nx-X11/lib/font/fontcache/fontcache.c
new file mode 100644
index 000000000..40cfd63c2
--- /dev/null
+++ b/nx-X11/lib/font/fontcache/fontcache.c
@@ -0,0 +1,1022 @@
+/*-
+ * Copyright (c) 1998-1999 Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
+ * All rights reserved.
+ * Copyright (c) 1998-1999 X-TrueType Server Project, All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Id: fontcache.c,v 1.19 1999/01/31 13:06:00 akiyama Exp $
+ */
+/* $XFree86: xc/lib/font/fontcache/fontcache.c,v 1.4 2001/04/05 17:42:28 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "fontcache.h"
+
+#define LOW_MARK 0
+#define HI_MARK 1
+
+#define PURGE_ENTRY 1
+#define PURGE_BITMAP 2
+
+typedef struct {
+ long hiMark; /* Cache hi water mark */
+ long lowMark; /* Cache low water mark */
+ long allocated; /* Cache allocated size */
+ long used; /* Cache used size */
+} FontCacheSize_t;
+
+static int CacheInitialized = 0;
+
+static TAILQ_HEAD(FcInUseQueue, cache_entry) InUseQueueHead, *InUseQueue;
+static TAILQ_HEAD(FcFreeQueue, cache_entry) FreeQueueHead, *FreeQueue;
+static FCBCB FreeBitmapHead, *FreeBitmap;
+
+static long CacheHiMark;
+static long CacheLowMark;
+static int CacheBalance;
+static FontCacheSize_t HashSize;
+static FontCacheSize_t AllocSize;
+static int NeedPurgeCache;
+static FontCacheStatistics CacheStatistics;
+
+static void fc_assign_cache(void);
+static int fc_assign_entry(void);
+static void fc_flush_cache(void);
+static int fc_get_bitmap_area(FontCacheEntryPtr, int);
+static void fc_free_bitmap_area(FontCacheBitmapPtr);
+static int fc_check_size(int);
+static void fc_purge_cache(void);
+static void fc_purge_bitmap(void);
+static void fc_flush_cache_bitmap(void);
+static void fc_flush_cache_inuse(void);
+static void fc_flush_cache_free(void);
+static void fc_purge_cache_entry(void);
+static void fc_purge_cache_entry_pool(void);
+static void fc_purge_bitmap_pool(void);
+
+
+/*
+ * FontCacheInitialize()
+ *
+ * Initialize cache work area.
+ */
+
+int
+FontCacheInitialize()
+{
+#ifdef FONTCACHE
+ int i;
+
+ if (!CacheInitialized) {
+ /*
+ * first time initialization
+ */
+#if defined(HASH_DEBUG) || defined(DEBUG)
+ fprintf(stderr, "FontCacheInitialize: initializing cache\n");
+#endif
+ InUseQueue = &InUseQueueHead;
+ TAILQ_INIT(InUseQueue);
+
+ FreeQueue = &FreeQueueHead;
+ TAILQ_INIT(FreeQueue);
+
+ FreeBitmap = &FreeBitmapHead;
+ FreeBitmap->index = 0;
+ for (i = 0; i < FC_MEM_HASH_SIZE; i++) {
+ TAILQ_INIT(&FreeBitmap->head[i]);
+ }
+
+ CacheHiMark = FC_DEFAULT_CACHE_SIZE * 1024; /* temporary */
+ CacheLowMark = (CacheHiMark / 4) * 3;
+ CacheBalance = FC_CACHE_BALANCE;
+
+ NeedPurgeCache = 0;
+
+ HashSize.allocated = HashSize.used = 0;
+ AllocSize.allocated = AllocSize.used = 0;
+ fc_assign_cache();
+ fc_assign_entry();
+#if defined(DEBUG)
+ fprintf(stderr, "FontCacheInitialize: hi=%ld, lo=%ld, bal=%d\n",
+ CacheHiMark, CacheLowMark, CacheBalance);
+#endif
+
+ CacheInitialized = 1;
+ } else {
+ /*
+ * second time or later case.
+ * flush and reassign cache.
+ */
+#if defined(HASH_DEBUG) || defined(DEBUG)
+ fprintf(stderr, "FontCacheInitialize: initializing cache, again\n");
+#endif
+ }
+
+ memset(&CacheStatistics, 0, sizeof (CacheStatistics));
+#endif /* FONTCACHE */
+
+ return 0; /* make lint happy */
+}
+
+/*
+ * FontCacheChangeSettings()
+ *
+ * Change cache size and reinitialize work areas.
+ *
+ * Returns 0, if memory allocation failed. Otherwise 1.
+ */
+
+int
+FontCacheChangeSettings(FontCacheSettingsPtr cs)
+{
+ int result;
+
+ if (!CacheInitialized) {
+ FontCacheInitialize();
+ if (!CacheInitialized)
+ return 0;
+ }
+
+#if defined(HASH_DEBUG) || defined(DEBUG)
+fprintf(stderr,
+ "FontCahceChangeSettings: hi-mark=%ld, low-mark=%ld, balance=%ld\n",
+ cs->himark, cs->lowmark, cs->balance);
+#endif
+
+ fc_flush_cache();
+
+ CacheHiMark = cs->himark;
+ CacheLowMark = cs->lowmark;
+ CacheBalance = cs->balance;
+
+ fc_assign_cache();
+ result = fc_assign_entry();
+
+ return result;
+}
+
+/*
+ * FontCacheGetSettings()
+ *
+ * Get current cache control parameters.
+ */
+
+void
+FontCacheGetSettings(FontCacheSettingsPtr cs)
+{
+ if (!CacheInitialized) {
+ FontCacheInitialize();
+ if (!CacheInitialized)
+ return;
+ }
+
+ cs->himark = CacheHiMark;
+ cs->lowmark = CacheLowMark;
+ cs->balance = CacheBalance;
+}
+
+/*
+ * FontCacheGetStatistics()
+ *
+ * Get current cache statistics.
+ */
+
+void
+FontCacheGetStatistics(FontCacheStatisticsPtr cs)
+{
+ if (!CacheInitialized) {
+ FontCacheInitialize();
+ if (!CacheInitialized)
+ return;
+ }
+
+ CacheStatistics.purge_stat = NeedPurgeCache;
+ CacheStatistics.balance = CacheBalance;
+ CacheStatistics.f.usage = HashSize.used;
+ CacheStatistics.v.usage = AllocSize.used;
+
+ memcpy(cs, &CacheStatistics, sizeof (CacheStatistics));
+}
+
+/*
+ * FontCacheOpenCache()
+ *
+ * Allocate font cache control block and initialize it.
+ *
+ * Returns pointer to font cache control block. Or returns NULL when
+ * detected illegal parameter or memory allocation failed.
+ */
+
+FCCBPtr
+FontCacheOpenCache(void *arg)
+{
+ int linesize;
+ FCCBPtr this;
+ int size = 0, mask = 0;
+ int i;
+
+ static int sizes[] = { 16, 32, 64, 128, 0 };
+
+ if (!CacheInitialized) {
+ FontCacheInitialize();
+ if (!CacheInitialized)
+ return NULL;
+ }
+
+ linesize = (long)arg;
+#if defined(HASH_DEBUG) || defined(DEBUG)
+fprintf(stderr, "FontCacheOpenCache: line size=%d\n", linesize);
+#endif
+
+ for (i = 0; sizes[i] != 0; i++) {
+ if (sizes[i] == linesize) {
+ size = linesize;
+ mask = linesize - 1;
+ break;
+ }
+ }
+ if (sizes[i] == 0) {
+ return NULL;
+ }
+
+ this = (FCCBPtr) malloc(sizeof (FCCB));
+ if (this != NULL) {
+ memset(this, 0, sizeof (FCCB));
+ this->head = (FontCacheHeadPtr) malloc(sizeof (FontCacheHead) * size);
+ if (this->head == NULL) {
+ free(this);
+ this = NULL;
+ } else {
+ this->size = size;
+ this->mask = mask;
+ for (i = 0; i < size; i++) {
+ TAILQ_INIT(&this->head[i]);
+ }
+ }
+ }
+
+ return this;
+}
+
+/*
+ * FontCacheCloseCache()
+ *
+ * Release font cache control block and all it's related entries.
+ */
+
+void
+FontCacheCloseCache(FCCBPtr this)
+{
+ FontCacheEntryPtr entry, next;
+ int i;
+ int size;
+
+ if (!CacheInitialized) {
+ return;
+ }
+
+ size = this->size;
+ for (i = 0; i < size; i++) {
+ entry = TAILQ_FIRST(&this->head[i]);
+ while (entry != NULL) {
+ /* remove entry from in-use queue, here */
+ TAILQ_REMOVE(InUseQueue, entry, c_lru);
+
+ /* remove entry from the hash */
+ if (entry->bitmapsize > FC_SMALL_BITMAP_SIZE
+ && entry->charInfo.bits != NULL) {
+ fc_free_bitmap_area(entry->bmp);
+ }
+ entry->charInfo.bits = NULL;
+ entry->bitmapsize = 0;
+
+ next = TAILQ_NEXT(entry, c_hash);
+ TAILQ_INSERT_HEAD(FreeQueue, entry, c_lru);
+ HashSize.used -= sizeof (FontCacheEntry);
+ entry = next;
+ }
+ }
+
+ free(this->head);
+ free(this);
+}
+
+/*
+ * FontCacheGetEntry()
+ *
+ * Allocate font cache entry and initialize it.
+ */
+
+FontCacheEntryPtr
+FontCacheGetEntry()
+{
+ FontCacheEntryPtr entry;
+ FontCacheEntryPtr p;
+ long size;
+
+ /* scan in-use queue and purge if required */
+ fc_purge_cache();
+
+ /* allocate hash entry */
+ if (TAILQ_EMPTY(FreeQueue)) {
+ size = sizeof (FontCacheEntry);
+ p = (FontCacheEntryPtr) malloc(size);
+ if (p != NULL) {
+ TAILQ_INSERT_HEAD(FreeQueue, p, c_lru);
+ HashSize.allocated += size;
+#if defined(HASH_DEBUG) || defined(DEBUG)
+fprintf(stderr, "FontCachegetEntry: allocated new entry\n");
+#endif
+ }
+ }
+
+ if (!TAILQ_EMPTY(FreeQueue)) {
+ entry = TAILQ_FIRST(FreeQueue);
+ TAILQ_REMOVE(FreeQueue, entry, c_lru);
+ memset(entry, 0, sizeof (FontCacheEntry));
+ } else {
+ entry = NULL;
+ }
+
+ return entry;
+}
+
+/*
+ * FontCacheGetBitmap()
+ *
+ * Allocate font glyph bitmap area.
+ *
+ * Note:
+ * Allocated area should be cleared.
+ */
+
+int
+FontCacheGetBitmap(FontCacheEntryPtr entry, int size)
+{
+ int oldsize;
+ int result;
+
+ /* XXX */
+ if ((AllocSize.used > AllocSize.hiMark - size) &&
+ (size > FC_SMALL_BITMAP_SIZE)) {
+ fc_purge_bitmap();
+ }
+
+ if (size < 0) /* wrong size */
+ return 0;
+
+ result = 0;
+ oldsize = entry->bitmapsize;
+ if (size <= FC_SMALL_BITMAP_SIZE) {
+ /* use coresponding bitmap area */
+ if (oldsize > FC_SMALL_BITMAP_SIZE) {
+ /* We don't need allocated area anymore */
+ fc_free_bitmap_area(entry->bmp);
+ }
+ entry->bitmapsize = size;
+ if (size > 0) {
+ entry->charInfo.bits = entry->bitmap;
+ memset(entry->charInfo.bits, 0, size);
+ } else
+ entry->charInfo.bits = NULL;
+
+ result = 1;
+ } else {
+ /* need extra bitmap area */
+ if (entry->charInfo.bits == NULL) {
+ /* no any extra bitmap area */
+ if (fc_get_bitmap_area(entry, size)) {
+ entry->bitmapsize = size;
+ memset(entry->charInfo.bits, 0, size);
+ if (fc_check_size(HI_MARK)) {
+ fc_purge_cache();
+ }
+ result = 1;
+ }
+ } else {
+ /* we already have extra bitmap area */
+ if (oldsize == size) {
+ /* same size, reuse it */
+ memset(entry->charInfo.bits, 0, size);
+ result = 1;
+ } else {
+ /* different size */
+ fc_free_bitmap_area(entry->bmp);
+ if (fc_get_bitmap_area(entry, size)) {
+ entry->bitmapsize = size;
+ memset(entry->charInfo.bits, 0, size);
+ if (fc_check_size(HI_MARK)) {
+ fc_purge_cache();
+ }
+ result = 1;
+ }
+ }
+ }
+ }
+
+ return result;
+}
+
+/*
+ * FontCacheSearchEntry()
+ *
+ * Search an entry matched with the key from the hash.
+ */
+
+int
+FontCacheSearchEntry(FCCBPtr this, int key, FontCacheEntryPtr *value)
+{
+ FontCacheHeadPtr head;
+ FontCacheEntryPtr entry;
+ int index;
+
+ index = key & this->mask;
+ head = &this->head[index];
+
+ TAILQ_FOREACH(entry, head, c_hash) {
+ if (entry->key == key) {
+ /* found, change position */
+ CacheStatistics.f.hits++;
+
+ TAILQ_REMOVE(InUseQueue, entry, c_lru);
+ TAILQ_INSERT_HEAD(InUseQueue, entry, c_lru);
+
+ TAILQ_REMOVE(head, entry, c_hash);
+ TAILQ_INSERT_HEAD(head, entry, c_hash);
+
+ /* purge least recentrly used cache entirs */
+ fc_purge_cache();
+
+ *value = entry;
+ return 1;
+ }
+ }
+
+ /* purge least recentrly used cache entirs */
+ fc_purge_cache();
+
+ /* not found */
+ CacheStatistics.f.misshits++;
+ *value = NULL;
+ return 0;
+}
+
+/*
+ * FontCacheInsertEntry()
+ *
+ * Insert an entry into the cache pool.
+ */
+
+int
+FontCacheInsertEntry(FCCBPtr this, int key, FontCacheEntryPtr entry)
+{
+ FontCacheHeadPtr head;
+ int index;
+
+ index = key & this->mask;
+ head = &this->head[index];
+
+ entry->key = key;
+ entry->c_head = head;
+ TAILQ_INSERT_HEAD(head, entry, c_hash);
+
+ /* insert entry into in-use queue */
+ TAILQ_INSERT_HEAD(InUseQueue, entry, c_lru);
+
+ /* adjust cache in-use size */
+ HashSize.used += sizeof (FontCacheEntry);
+ if (fc_check_size(HI_MARK)) {
+ fc_purge_cache();
+ }
+
+ return 1;
+}
+
+/*
+ * fc_assign_cache()
+ *
+ * Assign cache size considered with cache balance rate.
+ */
+
+static void
+fc_assign_cache()
+{
+ HashSize.hiMark = (CacheHiMark * CacheBalance) / 100;
+ HashSize.lowMark = (CacheLowMark * CacheBalance) / 100;
+
+ AllocSize.hiMark = (CacheHiMark * (100 - CacheBalance)) / 100;
+ AllocSize.lowMark = (CacheLowMark * (100 - CacheBalance)) / 100;
+}
+
+/*
+ * fc_assign_entry()
+ *
+ * Assign cache entry into free queue.
+ *
+ * Returns 0, when memory allocation failed. Otherwise 1.
+ */
+
+static int
+fc_assign_entry()
+{
+ FontCacheEntryPtr entry;
+ long used;
+ int result = 1;
+
+ used = 0;
+ while ((used + sizeof (FontCacheEntry)) < HashSize.hiMark) {
+ entry = (FontCacheEntryPtr) malloc(sizeof (FontCacheEntry));
+ if (entry == NULL) {
+ fprintf(stderr, "fc_assign_entry: can't allocate memory.\n");
+ result = 0;
+ break;
+ }
+ TAILQ_INSERT_HEAD(FreeQueue, entry, c_lru);
+ used += sizeof (FontCacheEntry);
+ HashSize.allocated += sizeof (FontCacheEntry);
+ }
+
+ return result;
+}
+
+/*
+ * fc_get_bitmap_area()
+ *
+ * Search allocated memory area from free bitmap hash pool. If there
+ * is no entry, then allocate new bitmap area.
+ *
+ * Returns 0, when memory allocation failed, otherwise 1. And some
+ * sort of cache entry structure members were updated.
+ */
+
+static int
+fc_get_bitmap_area(FontCacheEntryPtr this, int size)
+{
+ FontCacheBitmapHeadPtr head;
+ FontCacheBitmapPtr bitmap;
+ int index;
+ int result = 0;
+
+ index = size & FC_MEM_HASH_MASK;
+ head = &FreeBitmap->head[index];
+ TAILQ_FOREACH(bitmap, head, b_hash) {
+ if (bitmap->key == size) {
+ TAILQ_REMOVE(head, bitmap, b_hash);
+ this->bmp = bitmap;
+ this->charInfo.bits = (char *) (bitmap + 1);
+ bitmap->b_entry = this;
+ result = 1;
+ CacheStatistics.v.hits++;
+ AllocSize.used += (size + sizeof (FontCacheBitmap));
+#if defined(HASH_DEBUG) || defined(DEBUG)
+fprintf(stderr, "fc_get_bitmap_area: bitmap entry found in pool\n");
+#endif
+ break;
+ }
+ }
+
+ if (result == 0) {
+ CacheStatistics.v.misshits++;
+ bitmap = (FontCacheBitmapPtr) malloc(size + sizeof (FontCacheBitmap));
+ if (bitmap != NULL) {
+ bitmap->b_entry = this;
+ bitmap->size = size + sizeof (FontCacheBitmap);
+ bitmap->key = size;
+ this->bmp = bitmap;
+ this->charInfo.bits = (char *) (bitmap + 1);
+ AllocSize.allocated += (size + sizeof (FontCacheBitmap));
+ AllocSize.used += (size + sizeof (FontCacheBitmap));
+ result = 1;
+#if defined(HASH_DEBUG) || defined(DEBUG)
+fprintf(stderr, "fc_get_bitmap_area: bitmap entry allocated\n");
+#endif
+ } else {
+ this->bmp = NULL;
+ this->charInfo.bits = NULL;
+ }
+ }
+
+ return result;
+}
+
+/*
+ * fc_free_bitmap_area()
+ *
+ * Release allocated bitmap area into free hash pool.
+ */
+
+static void
+fc_free_bitmap_area(FontCacheBitmapPtr this)
+{
+ FontCacheBitmapHeadPtr head;
+ FontCacheEntryPtr entry;
+ int index;
+
+#if defined(HASH_DEBUG) || defined(DEBUG)
+fprintf(stderr, "fc_free_bitmap_area: bitmap entry returns into pool\n");
+#endif
+
+ index = this->key & FC_MEM_HASH_MASK;
+ head = &FreeBitmap->head[index];
+ TAILQ_INSERT_HEAD(head, this, b_hash);
+
+ AllocSize.used -= this->size;
+
+ entry = this->b_entry;
+ entry->bmp = NULL;
+ entry->bitmapsize = 0;
+}
+
+/*
+ * fc_flush_cache_bitmap()
+ *
+ * Flush all allocated bitmap area from the free hash pool.
+ */
+
+static void
+fc_flush_cache_bitmap()
+{
+ FontCacheBitmapHeadPtr head;
+ FontCacheBitmapPtr bitmap;
+ int i;
+
+ for (i = 0; i < FC_MEM_HASH_SIZE; i++) {
+ head = &FreeBitmap->head[i];
+ while (!TAILQ_EMPTY(head)) {
+ bitmap = TAILQ_FIRST(head);
+ TAILQ_REMOVE(head, bitmap, b_hash);
+
+ AllocSize.allocated -= bitmap->size;
+ free(bitmap);
+ }
+ }
+}
+
+/*
+ * fc_flush_cache_inuse()
+ *
+ * Release all in-use cache entries.
+ */
+
+static void
+fc_flush_cache_inuse()
+{
+ FontCacheEntryPtr entry;
+ FontCacheHeadPtr head;
+
+ while (!TAILQ_EMPTY(InUseQueue)) {
+ /* remove this entry from in-use queue */
+ entry = TAILQ_FIRST(InUseQueue);
+ TAILQ_REMOVE(InUseQueue, entry, c_lru);
+
+ /* remove this entry from hash */
+ head = entry->c_head;
+ TAILQ_REMOVE(head, entry, c_hash);
+
+ /* release bitmap area */
+ if (entry->bitmapsize > FC_SMALL_BITMAP_SIZE
+ && entry->charInfo.bits != NULL) {
+ fc_free_bitmap_area(entry->bmp);
+ }
+ entry->charInfo.bits = NULL;
+ entry->bitmapsize = 0;
+
+ /* release font-specific private area */
+ if ( entry->vfuncs && entry->vfuncs->f_private_dispose )
+ (*entry->vfuncs->f_private_dispose)(entry->f_private);
+ entry->f_private = NULL;
+ entry->vfuncs = NULL;
+
+ /* add this entry to free queue */
+ TAILQ_INSERT_HEAD(FreeQueue, entry, c_lru);
+
+ /* adjust size */
+ HashSize.used -= sizeof (FontCacheEntry);
+ }
+}
+
+/*
+ * fc_flush_cache_free()
+ *
+ * Flush all free cache entries from the free cache queue.
+ */
+
+static void
+fc_flush_cache_free()
+{
+ FontCacheEntryPtr entry;
+
+ /* release entire entries of the free queue */
+ while (!TAILQ_EMPTY(FreeQueue)) {
+ entry = TAILQ_FIRST(FreeQueue);
+ TAILQ_REMOVE(FreeQueue, entry, c_lru);
+ free(entry);
+ HashSize.allocated -= sizeof (FontCacheEntry);
+ }
+}
+
+/*
+ * fc_flush_cache()
+ *
+ * Flush all cache entries and allocated bitmap area from the pool.
+ */
+
+static void
+fc_flush_cache()
+{
+ fc_flush_cache_inuse();
+ fc_flush_cache_bitmap();
+ fc_flush_cache_free();
+
+ memset(&CacheStatistics, 0, sizeof (CacheStatistics));
+}
+
+/*
+ * fc_check_size()
+ *
+ * Check cache size, then return it's result.
+ */
+
+static int
+fc_check_size(int mark)
+{
+ int result = 0;
+
+ if (mark == LOW_MARK) {
+ if (HashSize.used > HashSize.lowMark) {
+ result |= PURGE_ENTRY;
+ }
+ if (AllocSize.used > AllocSize.lowMark) {
+ result |= PURGE_BITMAP;
+ }
+ } else {
+ if (HashSize.used > HashSize.hiMark) {
+ result |= PURGE_ENTRY;
+ }
+ if (AllocSize.used > AllocSize.hiMark) {
+ result |= PURGE_BITMAP;
+ }
+ }
+
+ return result;
+}
+
+/*
+ * fc_purge_cache_entry()
+ *
+ * Purge least recently used cache entry.
+ */
+
+static void
+fc_purge_cache_entry()
+{
+ FontCacheHeadPtr head;
+ FontCacheEntryPtr entry;
+ int i;
+
+ for (i = 0; i < FC_PURGE_PER_SCAN; i++) {
+ /* get least recently used entry */
+ entry = TAILQ_LAST(InUseQueue, FcInUseQueue);
+
+#if defined(HASH_DEBUG) || defined(DEBUG)
+fprintf(stderr, "fc_purge_cache_entry: purged: %p, %d\n",
+ entry, entry->key);
+#endif
+
+ /* remove this entry from in-use queue */
+ TAILQ_REMOVE(InUseQueue, entry, c_lru);
+
+ /* remove this entry from the hash */
+ head = entry->c_head;
+ TAILQ_REMOVE(head, entry, c_hash);
+
+ /* release bitmap area */
+ if (entry->bitmapsize > FC_SMALL_BITMAP_SIZE
+ && entry->charInfo.bits != NULL) {
+ fc_free_bitmap_area(entry->bmp);
+ CacheStatistics.v.purged++;
+ }
+ entry->charInfo.bits = NULL;
+ entry->bitmapsize = 0;
+
+ /* release font-specific private area */
+ if ( entry->vfuncs && entry->vfuncs->f_private_dispose )
+ (*entry->vfuncs->f_private_dispose)(entry->f_private);
+ entry->f_private = NULL;
+ entry->vfuncs = NULL;
+
+ /* add this entry to free queue */
+ TAILQ_INSERT_HEAD(FreeQueue, entry, c_lru);
+
+ HashSize.used -= sizeof (FontCacheEntry);
+ CacheStatistics.f.purged++;
+ }
+}
+
+/*
+ * fc_purge_cache_entry_pool()
+ *
+ * Purge free cache entries, to adjust cache size.
+ */
+
+static void
+fc_purge_cache_entry_pool()
+{
+ FontCacheEntryPtr entry;
+
+ while (!TAILQ_EMPTY(FreeQueue)) {
+ entry = TAILQ_LAST(FreeQueue, FcFreeQueue);
+ TAILQ_REMOVE(FreeQueue, entry, c_lru);
+#if defined(HASH_DEBUG) || defined(DEBUG)
+fprintf(stderr, "fc_purge_cache_entry_pool: purged from free queue: %p\n",
+ entry);
+#endif
+ HashSize.allocated -= sizeof (FontCacheEntry);
+ free(entry);
+ if (HashSize.allocated <= HashSize.hiMark) {
+ break;
+ }
+ }
+}
+
+/*
+ * fc_purge_bitmap()
+ *
+ * Purge least recently used allocated bitmap area.
+ */
+
+static void
+fc_purge_bitmap()
+{
+ FontCacheEntryPtr entry, first;
+ int purged = 0;
+
+ /* release used entry, if required */
+ first = TAILQ_FIRST(InUseQueue);
+ if (first != NULL) {
+ entry = TAILQ_LAST(InUseQueue, FcInUseQueue);
+ while (purged < FC_PURGE_PER_SCAN) {
+ if (entry->bmp != NULL) {
+#if defined(HASH_DEBUG) || defined(DEBUG)
+fprintf(stderr, "fc_purge_bitmap: purged from live queue: %p, %d(%d)\n",
+ entry->bmp, entry->bmp->key, entry->bmp->size);
+#endif
+ fc_free_bitmap_area(entry->bmp);
+ entry->charInfo.bits = NULL;
+ CacheStatistics.v.purged++;
+ purged++;
+ }
+ if (entry == first) {
+ break;
+ }
+ entry = TAILQ_PREV(entry, FcInUseQueue, c_lru);
+ }
+ }
+}
+
+/*
+ * fc_purge_bitmap_pool()
+ *
+ * Purge free bitmap area from pool, to adjust cache size.
+ */
+
+static void
+fc_purge_bitmap_pool()
+{
+ int this, stop, quit;
+ FontCacheBitmapHeadPtr head;
+ FontCacheBitmapPtr bitmap;
+
+ /* release free bitmap entry */
+ this = FreeBitmap->index;
+ stop = this;
+ quit = 0;
+
+ do {
+ head = &FreeBitmap->head[this];
+ while (!TAILQ_EMPTY(head)) {
+ bitmap = TAILQ_LAST(head, fcmem_head);
+ TAILQ_REMOVE(head, bitmap, b_hash);
+#if defined(HASH_DEBUG) || defined(DEBUG)
+fprintf(stderr, "fc_purge_bitmap_pool: purged from pool: %p, %d(%d)\n",
+ bitmap, bitmap->key, bitmap->size);
+#endif
+ AllocSize.allocated -= bitmap->size;
+ free(bitmap);
+ if (AllocSize.allocated <= AllocSize.hiMark) {
+ quit = 1;
+ break;
+ }
+ }
+ this++;
+ this &= FC_MEM_HASH_MASK;
+ } while (this != stop && quit == 0);
+
+ FreeBitmap->index++;
+ FreeBitmap->index &= FC_MEM_HASH_MASK;
+}
+
+/*
+ * fc_purge_cache()
+ *
+ * Purge font cache, if required.
+ */
+
+static void
+fc_purge_cache()
+{
+ int strategy;
+
+ if (NeedPurgeCache) {
+ strategy = fc_check_size(LOW_MARK);
+ switch (strategy) {
+ case PURGE_ENTRY :
+ CacheStatistics.purge_runs++;
+ fc_purge_cache_entry();
+ break;
+ case PURGE_BITMAP :
+ CacheStatistics.purge_runs++;
+ fc_purge_bitmap();
+ break;
+ case (PURGE_ENTRY | PURGE_BITMAP) :
+ CacheStatistics.purge_runs++;
+ fc_purge_cache_entry();
+ fc_purge_bitmap();
+ break;
+ default :
+ NeedPurgeCache = 0;
+ break;
+ }
+ } else {
+ strategy = fc_check_size(HI_MARK);
+ switch (strategy) {
+ case PURGE_ENTRY :
+ if ((CacheBalance + FC_BALANCE_DIFFS) <= FC_BALANCE_HI) {
+ CacheBalance += FC_BALANCE_DIFFS;
+#if defined(HASH_DEBUG) || defined(DEBUG)
+fprintf(stderr, "fc_purge_cache: cache balance changed to %d\n", CacheBalance);
+#endif
+ fc_assign_cache();
+ fc_purge_bitmap_pool();
+ } else {
+ CacheStatistics.purge_runs++;
+ NeedPurgeCache = 1;
+ while (fc_check_size(HI_MARK) & PURGE_ENTRY) {
+ fc_purge_cache_entry();
+ }
+ }
+ break;
+ case PURGE_BITMAP :
+ if ((CacheBalance - FC_BALANCE_DIFFS) >= FC_BALANCE_LOW) {
+ CacheBalance -= FC_BALANCE_DIFFS;
+#if defined(HASH_DEBUG) || defined(DEBUG)
+fprintf(stderr, "fc_purge_cache: cache balance changed to %d\n", CacheBalance);
+#endif
+ fc_assign_cache();
+ fc_purge_cache_entry_pool();
+ } else {
+ CacheStatistics.purge_runs++;
+ NeedPurgeCache = 1;
+ while (fc_check_size(HI_MARK) & PURGE_BITMAP) {
+ fc_purge_bitmap();
+ }
+ }
+ break;
+ case (PURGE_ENTRY | PURGE_BITMAP) :
+ CacheStatistics.purge_runs++;
+ NeedPurgeCache = 1;
+ while (fc_check_size(HI_MARK)) {
+ fc_purge_cache_entry();
+ fc_purge_bitmap();
+ }
+ break;
+ default :
+ break;
+ }
+ }
+}
diff --git a/nx-X11/lib/font/fontcache/fontcache.h b/nx-X11/lib/font/fontcache/fontcache.h
new file mode 100644
index 000000000..c95de25eb
--- /dev/null
+++ b/nx-X11/lib/font/fontcache/fontcache.h
@@ -0,0 +1,121 @@
+/*-
+ * Copyright (c) 1998-1999 Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
+ * All rights reserved.
+ * Copyright (c) 1998-1999 X-TrueType Server Project, All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Id: fontcache.h,v 1.12 1999/01/09 06:24:30 akiyama Exp $
+ */
+/* $XFree86: xc/lib/font/fontcache/fontcache.h,v 1.6 2002/11/08 00:46:27 alanh Exp $ */
+
+#ifndef _FONTCACHE_H_
+#define _FONTCACHE_H_
+
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+#include "fcqueue.h"
+#define _FONTCACHE_SERVER_
+#include <X11/extensions/fontcacheP.h>
+
+/* constant declarations */
+
+#ifndef FC_DEFAULT_CACHE_SIZE
+#define FC_DEFAULT_CACHE_SIZE 5120 /* in KB */
+#endif
+
+#define FC_CACHE_BALANCE 70 /* in percentage */
+#define FC_BALANCE_LOW 10 /* in percentage */
+#define FC_BALANCE_HI 90 /* in percentage */
+#define FC_BALANCE_DIFFS 5 /* in percentage */
+
+#define FC_SMALL_BITMAP_SIZE 128
+
+#define FC_MEM_HASH_SIZE 256
+#define FC_MEM_HASH_MASK (FC_MEM_HASH_SIZE - 1)
+
+#define FC_PURGE_PER_SCAN 2
+
+/* data type declarations */
+
+struct cache_entry;
+struct fcbitmap;
+
+TAILQ_HEAD(fchash_head, cache_entry);
+TAILQ_HEAD(fcmem_head, fcbitmap);
+
+struct fcbitmap {
+ TAILQ_ENTRY(fcbitmap) b_hash;
+ struct cache_entry *b_entry;
+ int size;
+ int key;
+};
+
+struct fc_entry_vfuncs {
+ void (*f_private_dispose)(void *f_private);
+};
+
+struct cache_entry {
+ TAILQ_ENTRY(cache_entry) c_hash; /* Hash chain. */
+ TAILQ_ENTRY(cache_entry) c_lru; /* Font cache LRU list chain. */
+ struct fchash_head *c_head; /* Pointer to head. */
+ int key; /* hash key */
+ CharInfoRec charInfo; /* CharInfo record */
+ struct fcbitmap *bmp;
+ void *f_private; /* Font-specific private data */
+ struct fc_entry_vfuncs *vfuncs; /* virtual function table */
+ int bitmapsize; /* Bitmap size */
+ char bitmap[FC_SMALL_BITMAP_SIZE]; /* Small bitmap data area */
+};
+
+struct fchash {
+ int size;
+ int mask;
+ struct fchash_head *head;
+};
+
+struct fcmemhash {
+ int index;
+ struct fcmem_head head[FC_MEM_HASH_SIZE];
+};
+
+typedef struct fcbitmap FontCacheBitmap, *FontCacheBitmapPtr;
+typedef struct cache_entry FontCacheEntry, *FontCacheEntryPtr;
+typedef struct fchash_head FontCacheHead, *FontCacheHeadPtr;
+typedef struct fcmem_head FontCacheBitmapHead, *FontCacheBitmapHeadPtr;
+typedef struct fchash FCCB, *FCCBPtr;
+typedef struct fcmemhash FCBCB, *FCBCBPtr;
+
+/* Function prototypes */
+
+int FontCacheInitialize(void);
+FCCBPtr FontCacheOpenCache(void * /* arg */);
+void FontCacheCloseCache(FCCBPtr /* this */);
+FontCacheEntryPtr FontCacheGetEntry(void);
+int FontCacheSearchEntry(FCCBPtr /* this */, int /* key */,
+ FontCacheEntryPtr * /* value */);
+int FontCacheInsertEntry(FCCBPtr /* this */, int /* key */,
+ FontCacheEntryPtr /* entry */);
+int FontCacheGetBitmap(FontCacheEntryPtr /* entry */,
+ int /* size */);
+
+#endif /* _FONTCACHE_H_ */
diff --git a/nx-X11/lib/font/fontfile/Imakefile b/nx-X11/lib/font/fontfile/Imakefile
new file mode 100644
index 000000000..fa075a951
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/Imakefile
@@ -0,0 +1,81 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:36 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/font/fontfile/Imakefile,v 3.20 2001/11/03 23:03:00 dawes Exp $
+
+#include <Server.tmpl>
+
+#if BuildServer && DoLoadableServer
+#define IHaveSubdirs
+#define NoLibSubdirs
+SUBDIRS = module
+#endif
+
+ INCLUDES = -I$(FONTINCSRC) -I../include -I$(SERVERSRC)/include \
+ -I$(INCLUDESRC)
+ HEADERS =
+#ifdef FontFormatDefines
+FORMAT_DEFS = FontFormatDefines
+#endif
+
+#if BuildSpeedo
+SPEEDO_DEFINES = -DBUILD_SPEEDO
+#endif
+#if BuildType1
+TYPE1_DEFINES = -DBUILD_TYPE1
+#endif
+#if BuildCID
+CID_DEFINES = -DBUILD_CID
+#endif
+#if BuildFreeType
+FREETYPE_DEFINES = -DBUILD_FREETYPE
+#endif
+
+#if FontencCompatibility
+ COMPAT_SRC = fontencc.c
+ COMPAT_OBJ = fontencc.o
+#endif
+
+#if GzipFontCompression
+ GUNZIP_SRC = gunzip.c
+ GUNZIP_OBJ = gunzip.o
+ GZIP_DEFS = -DX_GZIP_FONT_COMPRESSION
+#endif
+
+FONTENCDEFS = -DFONT_ENCODINGS_DIRECTORY=\"$(ENCODINGSDIR)/encodings.dir\"
+
+ DEFINES = StrcasecmpDefines \
+ $(SPEEDO_DEFINES) $(TYPE1_DEFINES) $(CID_DEFINES) \
+ $(FREETYPE_DEFINES) $(FONTENCDEFS) \
+ $(GZIP_DEFS)
+
+ SRCS = dirfile.c fontdir.c fontfile.c fileio.c fontscale.c \
+ defaults.c bitsource.c register.c renderers.c bufio.c \
+ decompress.c filewr.c printerfont.c ffcheck.c \
+ fontenc.c encparse.c $(COMPAT_SRC) $(GUNZIP_SRC)
+ OBJS = dirfile.o fontdir.o fontfile.o fileio.o fontscale.o \
+ defaults.o bitsource.o register.o renderers.o bufio.o \
+ decompress.o filewr.o printerfont.o ffcheck.o \
+ fontenc.o encparse.o $(COMPAT_OBJ) $(GUNZIP_OBJ)
+
+#define DoNormalLib NormalLibFont
+#define DoSharedLib SharedLibFont
+#define DoDebugLib DebugLibFont
+#define DoProfileLib ProfileLibFont
+#include <Library.tmpl>
+LibraryObjectRule()
+
+SpecialCLibObjectRule(fileio,$(ICONFIGFILES),$(GZIP_DEFS))
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+#if BuildServer && DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/lib/font/fontfile/bitsource.c b/nx-X11/lib/font/fontfile/bitsource.c
new file mode 100644
index 000000000..ae27de8fe
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/bitsource.c
@@ -0,0 +1,174 @@
+/* $Xorg: bitsource.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/bitsource.c,v 1.3 2001/01/17 19:43:29 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+
+BitmapSourcesRec FontFileBitmapSources;
+
+Bool
+FontFileRegisterBitmapSource (FontPathElementPtr fpe)
+{
+ FontPathElementPtr *new;
+ int i;
+ int newsize;
+
+ for (i = 0; i < FontFileBitmapSources.count; i++)
+ if (FontFileBitmapSources.fpe[i] == fpe)
+ return TRUE;
+ if (FontFileBitmapSources.count == FontFileBitmapSources.size)
+ {
+ newsize = FontFileBitmapSources.size + 4;
+ new = (FontPathElementPtr *) xrealloc (FontFileBitmapSources.fpe, newsize * sizeof *new);
+ if (!new)
+ return FALSE;
+ FontFileBitmapSources.size = newsize;
+ FontFileBitmapSources.fpe = new;
+ }
+ FontFileBitmapSources.fpe[FontFileBitmapSources.count++] = fpe;
+ return TRUE;
+}
+
+void
+FontFileUnregisterBitmapSource (FontPathElementPtr fpe)
+{
+ int i;
+
+ for (i = 0; i < FontFileBitmapSources.count; i++)
+ if (FontFileBitmapSources.fpe[i] == fpe)
+ {
+ FontFileBitmapSources.count--;
+ if (FontFileBitmapSources.count == 0)
+ {
+ FontFileBitmapSources.size = 0;
+ xfree (FontFileBitmapSources.fpe);
+ FontFileBitmapSources.fpe = 0;
+ }
+ else
+ {
+ for (; i < FontFileBitmapSources.count; i++)
+ FontFileBitmapSources.fpe[i] = FontFileBitmapSources.fpe[i+1];
+ }
+ break;
+ }
+}
+
+/*
+ * Our set_path_hook: unregister all bitmap sources.
+ * This is necessary because already open fonts will keep their FPEs
+ * allocated, but they may not be on the new font path.
+ * The bitmap sources in the new path will be registered by the init_func.
+ */
+void
+FontFileEmptyBitmapSource(void)
+{
+ if (FontFileBitmapSources.count == 0)
+ return;
+
+ FontFileBitmapSources.count = 0;
+ FontFileBitmapSources.size = 0;
+ xfree (FontFileBitmapSources.fpe);
+ FontFileBitmapSources.fpe = 0;
+}
+
+int
+FontFileMatchBitmapSource (FontPathElementPtr fpe,
+ FontPtr *pFont,
+ int flags,
+ FontEntryPtr entry,
+ FontNamePtr zeroPat,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ Bool noSpecificSize)
+{
+ int source;
+ FontEntryPtr zero;
+ FontBitmapEntryPtr bitmap;
+ int ret;
+ FontDirectoryPtr dir;
+ FontScaledPtr scaled;
+
+ /*
+ * Look through all the registered bitmap sources for
+ * the same zero name as ours; entries along that one
+ * can be scaled as desired.
+ */
+ ret = BadFontName;
+ for (source = 0; source < FontFileBitmapSources.count; source++)
+ {
+ if (FontFileBitmapSources.fpe[source] == fpe)
+ continue;
+ dir = (FontDirectoryPtr) FontFileBitmapSources.fpe[source]->private;
+ zero = FontFileFindNameInDir (&dir->scalable, zeroPat);
+ if (!zero)
+ continue;
+ scaled = FontFileFindScaledInstance (zero, vals, noSpecificSize);
+ if (scaled)
+ {
+ if (scaled->pFont)
+ {
+ *pFont = scaled->pFont;
+ (*pFont)->fpe = FontFileBitmapSources.fpe[source];
+ ret = Successful;
+ }
+ else if (scaled->bitmap)
+ {
+ entry = scaled->bitmap;
+ bitmap = &entry->u.bitmap;
+ if (bitmap->pFont)
+ {
+ *pFont = bitmap->pFont;
+ (*pFont)->fpe = FontFileBitmapSources.fpe[source];
+ ret = Successful;
+ }
+ else
+ {
+ ret = FontFileOpenBitmap (
+ FontFileBitmapSources.fpe[source],
+ pFont, flags, entry, format, fmask);
+ if (ret == Successful && *pFont)
+ (*pFont)->fpe = FontFileBitmapSources.fpe[source];
+ }
+ }
+ else /* "cannot" happen */
+ {
+ ret = BadFontName;
+ }
+ break;
+ }
+ }
+ return ret;
+}
diff --git a/nx-X11/lib/font/fontfile/bufio.c b/nx-X11/lib/font/fontfile/bufio.c
new file mode 100644
index 000000000..43c6a13a7
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/bufio.c
@@ -0,0 +1,212 @@
+/* $Xorg: bufio.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/bufio.c,v 3.9 2001/12/14 19:56:50 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/bufio.h>
+#include <errno.h>
+
+BufFilePtr
+BufFileCreate (char *private,
+ int (*input)(BufFilePtr),
+ int (*output)(int, BufFilePtr),
+ int (*skip)(BufFilePtr, int),
+ int (*close)(BufFilePtr, int))
+{
+ BufFilePtr f;
+
+ f = (BufFilePtr) xalloc (sizeof *f);
+ if (!f)
+ return 0;
+ f->private = private;
+ f->bufp = f->buffer;
+ f->left = 0;
+ f->input = input;
+ f->output = output;
+ f->skip = skip;
+ f->eof = 0;
+ f->close = close;
+ return f;
+}
+
+#define FileDes(f) ((int)(long) (f)->private)
+
+static int
+BufFileRawFill (BufFilePtr f)
+{
+ int left;
+
+ left = read (FileDes(f), (char *)f->buffer, BUFFILESIZE);
+ if (left <= 0) {
+ f->left = 0;
+ return BUFFILEEOF;
+ }
+ f->left = left - 1;
+ f->bufp = f->buffer + 1;
+ return f->buffer[0];
+}
+
+static int
+BufFileRawSkip (BufFilePtr f, int count)
+{
+ int curoff;
+ int fileoff;
+ int todo;
+
+ curoff = f->bufp - f->buffer;
+ fileoff = curoff + f->left;
+ if (curoff + count <= fileoff) {
+ f->bufp += count;
+ f->left -= count;
+ } else {
+ todo = count - (fileoff - curoff);
+ if (lseek (FileDes(f), todo, 1) == -1) {
+ if (errno != ESPIPE)
+ return BUFFILEEOF;
+ while (todo) {
+ curoff = BUFFILESIZE;
+ if (curoff > todo)
+ curoff = todo;
+ fileoff = read (FileDes(f), (char *)f->buffer, curoff);
+ if (fileoff <= 0)
+ return BUFFILEEOF;
+ todo -= fileoff;
+ }
+ }
+ f->left = 0;
+ }
+ return count;
+}
+
+static int
+BufFileRawClose (BufFilePtr f, int doClose)
+{
+ if (doClose)
+ close (FileDes (f));
+ return 1;
+}
+
+BufFilePtr
+BufFileOpenRead (int fd)
+{
+#if defined(__UNIXOS2__) || defined (WIN32)
+ /* hv: I'd bet WIN32 has the same effect here */
+ setmode(fd,O_BINARY);
+#endif
+ return BufFileCreate ((char *)(long) fd, BufFileRawFill, 0, BufFileRawSkip, BufFileRawClose);
+}
+
+static int
+BufFileRawFlush (int c, BufFilePtr f)
+{
+ int cnt;
+
+ if (c != BUFFILEEOF)
+ *f->bufp++ = c;
+ cnt = f->bufp - f->buffer;
+ f->bufp = f->buffer;
+ f->left = BUFFILESIZE;
+ if (write (FileDes(f), (char *)f->buffer, cnt) != cnt)
+ return BUFFILEEOF;
+ return c;
+}
+
+BufFilePtr
+BufFileOpenWrite (int fd)
+{
+ BufFilePtr f;
+
+#if defined(__UNIXOS2__) || defined(WIN32)
+ /* hv: I'd bet WIN32 has the same effect here */
+ setmode(fd,O_BINARY);
+#endif
+ f = BufFileCreate ((char *)(long) fd, 0, BufFileRawFlush, 0, BufFileFlush);
+ f->bufp = f->buffer;
+ f->left = BUFFILESIZE;
+ return f;
+}
+
+int
+BufFileRead (BufFilePtr f, char *b, int n)
+{
+ int c, cnt;
+ cnt = n;
+ while (cnt--) {
+ c = BufFileGet (f);
+ if (c == BUFFILEEOF)
+ break;
+ *b++ = c;
+ }
+ return n - cnt - 1;
+}
+
+int
+BufFileWrite (BufFilePtr f, char *b, int n)
+{
+ int cnt;
+ cnt = n;
+ while (cnt--) {
+ if (BufFilePut (*b++, f) == BUFFILEEOF)
+ return BUFFILEEOF;
+ }
+ return n;
+}
+
+int
+BufFileFlush (BufFilePtr f, int doClose)
+{
+ if (f->bufp != f->buffer)
+ return (*f->output) (BUFFILEEOF, f);
+ return 0;
+}
+
+int
+BufFileClose (BufFilePtr f, int doClose)
+{
+ int ret;
+ ret = (*f->close) (f, doClose);
+ xfree (f);
+ return ret;
+}
+
+void
+BufFileFree (BufFilePtr f)
+{
+ xfree (f);
+}
diff --git a/nx-X11/lib/font/fontfile/decompress.c b/nx-X11/lib/font/fontfile/decompress.c
new file mode 100644
index 000000000..a4c546871
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/decompress.c
@@ -0,0 +1,410 @@
+/* $Xorg: decompress.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+/*
+ * Copyright 1985, 1986 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * James A. Woods, derived from original work by Spencer Thomas
+ * and Joseph Orost.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/decompress.c,v 1.4 2001/01/17 19:43:29 dawes Exp $ */
+/*
+ * decompress - cat a compressed file
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/bufio.h>
+
+#define BITS 16
+
+/*
+ * a code_int must be able to hold 2**BITS values of type int, and also -1
+ */
+#if BITS > 15
+typedef long int code_int;
+#else
+typedef int code_int;
+#endif
+
+typedef long int count_int;
+
+#ifdef NO_UCHAR
+ typedef char char_type;
+#else
+ typedef unsigned char char_type;
+#endif /* UCHAR */
+
+static char_type magic_header[] = { "\037\235" }; /* 1F 9D */
+
+/* Defines for third byte of header */
+#define BIT_MASK 0x1f
+#define BLOCK_MASK 0x80
+/* Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is
+ a fourth header byte (for expansion).
+*/
+
+#define INIT_BITS 9 /* initial number of bits/code */
+
+#ifdef COMPATIBLE /* But wrong! */
+# define MAXCODE(n_bits) (1 << (n_bits) - 1)
+#else
+# define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
+#endif /* COMPATIBLE */
+
+/*
+ * the next two codes should not be changed lightly, as they must not
+ * lie within the contiguous general code space.
+ */
+#define FIRST 257 /* first free entry */
+#define CLEAR 256 /* table clear output code */
+
+#define STACK_SIZE 8192
+
+typedef struct _compressedFILE {
+ BufFilePtr file;
+
+ char_type *stackp;
+ code_int oldcode;
+ char_type finchar;
+
+ int block_compress;
+ int maxbits;
+ code_int maxcode, maxmaxcode;
+
+ code_int free_ent;
+ int clear_flg;
+ int n_bits;
+
+ /* bit buffer */
+ int offset, size;
+ char_type buf[BITS];
+
+ char_type de_stack[STACK_SIZE];
+ char_type *tab_suffix;
+ unsigned short *tab_prefix;
+} CompressedFile;
+
+
+static int hsize_table[] = {
+ 5003, /* 12 bits - 80% occupancy */
+ 9001, /* 13 bits - 91% occupancy */
+ 18013, /* 14 bits - 91% occupancy */
+ 35023, /* 15 bits - 94% occupancy */
+ 69001 /* 16 bits - 95% occupancy */
+};
+
+static int BufCompressedClose ( BufFilePtr f, int doClose );
+static int BufCompressedFill ( BufFilePtr f );
+static code_int getcode ( CompressedFile *file );
+static int BufCompressedSkip ( BufFilePtr f, int bytes );
+
+BufFilePtr
+BufFilePushCompressed (BufFilePtr f)
+{
+ int code;
+ int maxbits;
+ int hsize;
+ CompressedFile *file;
+ int extra;
+
+ if ((BufFileGet(f) != (magic_header[0] & 0xFF)) ||
+ (BufFileGet(f) != (magic_header[1] & 0xFF)))
+ {
+ return 0;
+ }
+ code = BufFileGet (f);
+ if (code == BUFFILEEOF) return 0;
+
+ maxbits = code & BIT_MASK;
+ if (maxbits > BITS || maxbits < 12)
+ return 0;
+ hsize = hsize_table[maxbits - 12];
+ extra = (1 << maxbits) * sizeof (char_type) +
+ hsize * sizeof (unsigned short);
+ file = (CompressedFile *) xalloc (sizeof (CompressedFile) + extra);
+ if (!file)
+ return 0;
+ file->file = f;
+ file->maxbits = maxbits;
+ file->block_compress = code & BLOCK_MASK;
+ file->maxmaxcode = 1 << file->maxbits;
+ file->tab_suffix = (char_type *) &file[1];
+ file->tab_prefix = (unsigned short *) (file->tab_suffix + file->maxmaxcode);
+ /*
+ * As above, initialize the first 256 entries in the table.
+ */
+ file->maxcode = MAXCODE(file->n_bits = INIT_BITS);
+ for ( code = 255; code >= 0; code-- ) {
+ file->tab_prefix[code] = 0;
+ file->tab_suffix[code] = (char_type) code;
+ }
+ file->free_ent = ((file->block_compress) ? FIRST : 256 );
+ file->clear_flg = 0;
+ file->offset = 0;
+ file->size = 0;
+ file->stackp = file->de_stack;
+ bzero(file->buf, BITS);
+ file->finchar = file->oldcode = getcode (file);
+ if (file->oldcode != -1)
+ *file->stackp++ = file->finchar;
+ return BufFileCreate ((char *) file,
+ BufCompressedFill,
+ 0,
+ BufCompressedSkip,
+ BufCompressedClose);
+}
+
+static int
+BufCompressedClose (BufFilePtr f, int doClose)
+{
+ CompressedFile *file;
+ BufFilePtr raw;
+
+ file = (CompressedFile *) f->private;
+ raw = file->file;
+ xfree (file);
+ BufFileClose (raw, doClose);
+ return 1;
+}
+
+static int
+BufCompressedFill (BufFilePtr f)
+{
+ CompressedFile *file;
+ register char_type *stackp, *de_stack;
+ register char_type finchar;
+ register code_int code, oldcode, incode;
+ BufChar *buf, *bufend;
+
+ file = (CompressedFile *) f->private;
+
+ buf = f->buffer;
+ bufend = buf + BUFFILESIZE;
+ stackp = file->stackp;
+ de_stack = file->de_stack;
+ finchar = file->finchar;
+ oldcode = file->oldcode;
+ while (buf < bufend) {
+ while (stackp > de_stack && buf < bufend)
+ *buf++ = *--stackp;
+
+ if (buf == bufend)
+ break;
+
+ if (oldcode == -1)
+ break;
+
+ code = getcode (file);
+ if (code == -1)
+ break;
+
+ if ( (code == CLEAR) && file->block_compress ) {
+ for ( code = 255; code >= 0; code-- )
+ file->tab_prefix[code] = 0;
+ file->clear_flg = 1;
+ file->free_ent = FIRST - 1;
+ if ( (code = getcode (file)) == -1 ) /* O, untimely death! */
+ break;
+ }
+ incode = code;
+ /*
+ * Special case for KwKwK string.
+ */
+ if ( code >= file->free_ent ) {
+ *stackp++ = finchar;
+ code = oldcode;
+ }
+
+ /*
+ * Generate output characters in reverse order
+ */
+ while ( code >= 256 )
+ {
+ *stackp++ = file->tab_suffix[code];
+ code = file->tab_prefix[code];
+ }
+ finchar = file->tab_suffix[code];
+ *stackp++ = finchar;
+
+ /*
+ * Generate the new entry.
+ */
+ if ( (code=file->free_ent) < file->maxmaxcode ) {
+ file->tab_prefix[code] = (unsigned short)oldcode;
+ file->tab_suffix[code] = finchar;
+ file->free_ent = code+1;
+ }
+ /*
+ * Remember previous code.
+ */
+ oldcode = incode;
+ }
+ file->oldcode = oldcode;
+ file->stackp = stackp;
+ file->finchar = finchar;
+ if (buf == f->buffer) {
+ f->left = 0;
+ return BUFFILEEOF;
+ }
+ f->bufp = f->buffer + 1;
+ f->left = (buf - f->buffer) - 1;
+ return f->buffer[0];
+}
+
+/*****************************************************************
+ * TAG( getcode )
+ *
+ * Read one code from the standard input. If BUFFILEEOF, return -1.
+ * Inputs:
+ * stdin
+ * Outputs:
+ * code or -1 is returned.
+ */
+
+static char_type rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
+
+static code_int
+getcode(CompressedFile *file)
+{
+ register code_int code;
+ register int r_off, bits;
+ register char_type *bp = file->buf;
+ register BufFilePtr raw;
+
+ if ( file->clear_flg > 0 || file->offset >= file->size ||
+ file->free_ent > file->maxcode )
+ {
+ /*
+ * If the next entry will be too big for the current code
+ * size, then we must increase the size. This implies reading
+ * a new buffer full, too.
+ */
+ if ( file->free_ent > file->maxcode ) {
+ file->n_bits++;
+ if ( file->n_bits == file->maxbits )
+ file->maxcode = file->maxmaxcode; /* won't get any bigger now */
+ else
+ file->maxcode = MAXCODE(file->n_bits);
+ }
+ if ( file->clear_flg > 0) {
+ file->maxcode = MAXCODE (file->n_bits = INIT_BITS);
+ file->clear_flg = 0;
+ }
+ bits = file->n_bits;
+ raw = file->file;
+ while (bits > 0 && (code = BufFileGet (raw)) != BUFFILEEOF)
+ {
+ *bp++ = code;
+ --bits;
+ }
+ bp = file->buf;
+ if (bits == file->n_bits)
+ return -1; /* end of file */
+ file->size = file->n_bits - bits;
+ file->offset = 0;
+ /* Round size down to integral number of codes */
+ file->size = (file->size << 3) - (file->n_bits - 1);
+ }
+ r_off = file->offset;
+ bits = file->n_bits;
+ /*
+ * Get to the first byte.
+ */
+ bp += (r_off >> 3);
+ r_off &= 7;
+ /* Get first part (low order bits) */
+#ifdef NO_UCHAR
+ code = ((*bp++ >> r_off) & rmask[8 - r_off]) & 0xff;
+#else
+ code = (*bp++ >> r_off);
+#endif /* NO_UCHAR */
+ bits -= (8 - r_off);
+ r_off = 8 - r_off; /* now, offset into code word */
+ /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
+ if ( bits >= 8 ) {
+#ifdef NO_UCHAR
+ code |= (*bp++ & 0xff) << r_off;
+#else
+ code |= *bp++ << r_off;
+#endif /* NO_UCHAR */
+ r_off += 8;
+ bits -= 8;
+ }
+ /* high order bits. */
+ code |= (*bp & rmask[bits]) << r_off;
+ file->offset += file->n_bits;
+
+ return code;
+}
+
+static int
+BufCompressedSkip (BufFilePtr f, int bytes)
+{
+ int c;
+ while (bytes--)
+ {
+ c = BufFileGet(f);
+ if (c == BUFFILEEOF)
+ return BUFFILEEOF;
+ }
+ return 0;
+}
+
+#ifdef TEST
+int
+main (int argc, char *argv[])
+{
+ BufFilePtr inputraw, input, output;
+ int c;
+
+ inputraw = BufFileOpenRead (0);
+ input = BufFilePushCompressed (inputraw);
+ output = BufFileOpenWrite (1);
+ while ((c = BufFileGet (input)) != BUFFILEEOF)
+ BufFilePut (c, output);
+ BufFileClose (input, FALSE);
+ BufFileClose (output, FALSE);
+ return 0;
+}
+#endif
diff --git a/nx-X11/lib/font/fontfile/defaults.c b/nx-X11/lib/font/fontfile/defaults.c
new file mode 100644
index 000000000..7f20cab67
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/defaults.c
@@ -0,0 +1,77 @@
+/* $Xorg: defaults.c,v 1.4 2001/02/09 02:04:03 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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/defaults.c,v 1.7 2001/01/17 19:43:29 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/X.h>
+#include <X11/Xproto.h>
+
+#ifndef DEFAULT_BIT_ORDER
+#ifdef BITMAP_BIT_ORDER
+#define DEFAULT_BIT_ORDER BITMAP_BIT_ORDER
+#else
+#define DEFAULT_BIT_ORDER MSBFirst
+#endif
+#endif
+
+#ifndef DEFAULT_BYTE_ORDER
+#ifdef IMAGE_BYTE_ORDER
+#define DEFAULT_BYTE_ORDER IMAGE_BYTE_ORDER
+#else
+#define DEFAULT_BYTE_ORDER MSBFirst
+#endif
+#endif
+
+#ifndef DEFAULT_GLYPH_PAD
+#ifdef GLYPHPADBYTES
+#define DEFAULT_GLYPH_PAD GLYPHPADBYTES
+#else
+#define DEFAULT_GLYPH_PAD 4
+#endif
+#endif
+
+#ifndef DEFAULT_SCAN_UNIT
+#define DEFAULT_SCAN_UNIT 1
+#endif
+
+#include <X11/fonts/fntfilst.h>
+
+void
+FontDefaultFormat (int *bit, int *byte, int *glyph, int *scan)
+{
+ *bit = DEFAULT_BIT_ORDER;
+ *byte = DEFAULT_BYTE_ORDER;
+ *glyph = DEFAULT_GLYPH_PAD;
+ *scan = DEFAULT_SCAN_UNIT;
+}
diff --git a/nx-X11/lib/font/fontfile/dirfile.c b/nx-X11/lib/font/fontfile/dirfile.c
new file mode 100644
index 000000000..f390391bc
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/dirfile.c
@@ -0,0 +1,491 @@
+/* $Xorg: dirfile.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/dirfile.c,v 3.17 2004/02/08 01:52:27 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/*
+ * dirfile.c
+ *
+ * Read fonts.dir and fonts.alias files
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+static Bool AddFileNameAliases ( FontDirectoryPtr dir );
+static int ReadFontAlias ( char *directory, Bool isFile,
+ FontDirectoryPtr *pdir );
+static int lexAlias ( FILE *file, char **lexToken );
+static int lexc ( FILE *file );
+
+int
+FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
+{
+ char file_name[MAXFONTFILENAMELEN];
+ char font_name[MAXFONTNAMELEN];
+ char dir_file[MAXFONTFILENAMELEN];
+ char dir_path[MAXFONTFILENAMELEN];
+ char *ptr;
+ FILE *file;
+ int count,
+ i,
+ status;
+ struct stat statb;
+ static char format[24] = "";
+
+ FontDirectoryPtr dir = NullFontDirectory;
+
+ if (strlen(directory) + 1 + sizeof(FontDirFile) > sizeof(dir_file))
+ return BadFontPath;
+
+ /* Check for font directory attributes */
+#if !defined(__UNIXOS2__) && !defined(WIN32)
+ if ((ptr = strchr(directory, ':'))) {
+#else
+ /* OS/2 and WIN32 path might start with a drive letter, don't clip this */
+ if ((ptr = strchr(directory+2, ':'))) {
+#endif
+ strncpy(dir_path, directory, ptr - directory);
+ dir_path[ptr - directory] = '\0';
+ } else {
+ strcpy(dir_path, directory);
+ }
+ strcpy(dir_file, dir_path);
+ if (dir_file[strlen(dir_file) - 1] != '/')
+ strcat(dir_file, "/");
+ strcat(dir_file, FontDirFile);
+ file = fopen(dir_file, "rt");
+ if (file) {
+ Bool found_font = FALSE;
+
+#ifndef WIN32
+ if (fstat (fileno(file), &statb) == -1)
+#else
+ if (stat (dir_file, &statb) == -1)
+#endif
+ {
+ fclose(file);
+ return BadFontPath;
+ }
+ count = fscanf(file, "%d\n", &i);
+ if ((count == EOF) || (count != 1)) {
+ fclose(file);
+ return BadFontPath;
+ }
+ dir = FontFileMakeDir(directory, i);
+ if (dir == NULL) {
+ fclose(file);
+ return BadFontPath;
+ }
+ dir->dir_mtime = statb.st_mtime;
+ if (format[0] == '\0')
+ sprintf(format, "%%%ds %%%d[^\n]\n",
+ MAXFONTFILENAMELEN-1, MAXFONTNAMELEN-1);
+
+ while ((count = fscanf(file, format, file_name, font_name)) != EOF) {
+#if defined(__UNIXOS2__) || defined(WIN32)
+ /* strip any existing trailing CR */
+ for (i=0; i<strlen(font_name); i++) {
+ if (font_name[i]=='\r') font_name[i] = '\0';
+ }
+#endif
+ if (count != 2) {
+ FontFileFreeDir (dir);
+ fclose(file);
+ return BadFontPath;
+ }
+ if (FontFileAddFontFile (dir, font_name, file_name))
+ found_font = TRUE;
+ }
+ if (!found_font) {
+ FontFileFreeDir (dir);
+ fclose(file);
+ return BadFontPath;
+ }
+ fclose(file);
+
+ } else if (errno != ENOENT) {
+ return BadFontPath;
+ }
+ status = ReadFontAlias(dir_path, FALSE, &dir);
+ if (status != Successful) {
+ if (dir)
+ FontFileFreeDir (dir);
+ return status;
+ }
+ if (!dir)
+ return BadFontPath;
+
+ FontFileSortDir(dir);
+
+ *pdir = dir;
+ return Successful;
+}
+
+Bool
+FontFileDirectoryChanged(FontDirectoryPtr dir)
+{
+ char dir_file[MAXFONTFILENAMELEN];
+ struct stat statb;
+
+ if (strlen(dir->directory) + sizeof(FontDirFile) > sizeof(dir_file))
+ return FALSE;
+
+ strcpy (dir_file, dir->directory);
+ strcat (dir_file, FontDirFile);
+ if (stat (dir_file, &statb) == -1)
+ {
+ if (errno != ENOENT || dir->dir_mtime != 0)
+ return TRUE;
+ return FALSE; /* doesn't exist and never did: no change */
+ }
+ if (dir->dir_mtime != statb.st_mtime)
+ return TRUE;
+ strcpy (dir_file, dir->directory);
+ strcat (dir_file, FontAliasFile);
+ if (stat (dir_file, &statb) == -1)
+ {
+ if (errno != ENOENT || dir->alias_mtime != 0)
+ return TRUE;
+ return FALSE; /* doesn't exist and never did: no change */
+ }
+ if (dir->alias_mtime != statb.st_mtime)
+ return TRUE;
+ return FALSE;
+}
+
+/*
+ * Make each of the file names an automatic alias for each of the files.
+ */
+
+static Bool
+AddFileNameAliases(FontDirectoryPtr dir)
+{
+ int i;
+ char copy[MAXFONTFILENAMELEN];
+ char *fileName;
+ FontTablePtr table;
+ FontRendererPtr renderer;
+ int len;
+ FontNameRec name;
+
+ table = &dir->nonScalable;
+ for (i = 0; i < table->used; i++) {
+ if (table->entries[i].type != FONT_ENTRY_BITMAP)
+ continue;
+ fileName = table->entries[i].u.bitmap.fileName;
+ renderer = FontFileMatchRenderer (fileName);
+ if (!renderer)
+ continue;
+
+ len = strlen (fileName) - renderer->fileSuffixLen;
+ if (len >= sizeof(copy))
+ continue;
+ CopyISOLatin1Lowered (copy, fileName, len);
+ copy[len] = '\0';
+ name.name = copy;
+ name.length = len;
+ name.ndashes = FontFileCountDashes (copy, len);
+
+ if (!FontFileFindNameInDir(table, &name)) {
+ if (!FontFileAddFontAlias (dir, copy, table->entries[i].name.name))
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/*
+ * parse the font.alias file. Format is:
+ *
+ * alias font-name
+ *
+ * To imbed white-space in an alias name, enclose it like "font name"
+ * in double quotes. \ escapes and character, so
+ * "font name \"With Double Quotes\" \\ and \\ back-slashes"
+ * works just fine.
+ *
+ * A line beginning with a ! denotes a newline-terminated comment.
+ */
+
+/*
+ * token types
+ */
+
+#define NAME 0
+#define NEWLINE 1
+#define DONE 2
+#define EALLOC 3
+
+static int
+ReadFontAlias(char *directory, Bool isFile, FontDirectoryPtr *pdir)
+{
+ char alias[MAXFONTNAMELEN];
+ char font_name[MAXFONTNAMELEN];
+ char alias_file[MAXFONTFILENAMELEN];
+ FILE *file;
+ FontDirectoryPtr dir;
+ int token;
+ char *lexToken;
+ int status = Successful;
+ struct stat statb;
+
+ if (strlen(directory) >= sizeof(alias_file))
+ return BadFontPath;
+ dir = *pdir;
+ strcpy(alias_file, directory);
+ if (!isFile) {
+ if (strlen(directory) + 1 + sizeof(FontAliasFile) > sizeof(alias_file))
+ return BadFontPath;
+ if (directory[strlen(directory) - 1] != '/')
+ strcat(alias_file, "/");
+ strcat(alias_file, FontAliasFile);
+ }
+ file = fopen(alias_file, "rt");
+ if (!file)
+ return ((errno == ENOENT) ? Successful : BadFontPath);
+ if (!dir)
+ *pdir = dir = FontFileMakeDir(directory, 10);
+ if (!dir)
+ {
+ fclose (file);
+ return AllocError;
+ }
+#ifndef WIN32
+ if (fstat (fileno (file), &statb) == -1)
+#else
+ if (stat (alias_file, &statb) == -1)
+#endif
+ {
+ fclose (file);
+ return BadFontPath;
+ }
+ dir->alias_mtime = statb.st_mtime;
+ while (status == Successful) {
+ token = lexAlias(file, &lexToken);
+ switch (token) {
+ case NEWLINE:
+ break;
+ case DONE:
+ fclose(file);
+ return Successful;
+ case EALLOC:
+ status = AllocError;
+ break;
+ case NAME:
+ if (strlen(lexToken) >= sizeof(alias)) {
+ status = BadFontPath;
+ break;
+ }
+ strcpy(alias, lexToken);
+ token = lexAlias(file, &lexToken);
+ switch (token) {
+ case NEWLINE:
+ if (strcmp(alias, "FILE_NAMES_ALIASES"))
+ status = BadFontPath;
+ else if (!AddFileNameAliases(dir))
+ status = AllocError;
+ break;
+ case DONE:
+ status = BadFontPath;
+ break;
+ case EALLOC:
+ status = AllocError;
+ break;
+ case NAME:
+ if (strlen(lexToken) >= sizeof(font_name)) {
+ status = BadFontPath;
+ break;
+ }
+ CopyISOLatin1Lowered(alias, alias, strlen(alias));
+ CopyISOLatin1Lowered(font_name, lexToken, strlen(lexToken));
+ if (!FontFileAddFontAlias (dir, alias, font_name))
+ status = AllocError;
+ break;
+ }
+ }
+ }
+ fclose(file);
+ return status;
+}
+
+#define QUOTE 0
+#define WHITE 1
+#define NORMAL 2
+#define END 3
+#define NL 4
+#define BANG 5
+
+static int charClass;
+
+static int
+lexAlias(FILE *file, char **lexToken)
+{
+ int c;
+ char *t;
+ enum state {
+ Begin, Normal, Quoted, Comment
+ } state;
+ int count;
+
+ static char *tokenBuf = (char *) NULL;
+ static int tokenSize = 0;
+
+ t = tokenBuf;
+ count = 0;
+ state = Begin;
+ for (;;) {
+ if (count == tokenSize) {
+ int nsize;
+ char *nbuf;
+
+ nsize = tokenSize ? (tokenSize << 1) : 64;
+ nbuf = (char *) xrealloc(tokenBuf, nsize);
+ if (!nbuf)
+ return EALLOC;
+ tokenBuf = nbuf;
+ tokenSize = nsize;
+ t = tokenBuf + count;
+ }
+ c = lexc(file);
+ switch (charClass) {
+ case QUOTE:
+ switch (state) {
+ case Begin:
+ case Normal:
+ state = Quoted;
+ break;
+ case Quoted:
+ state = Normal;
+ break;
+ case Comment:
+ break;
+ }
+ break;
+ case WHITE:
+ switch (state) {
+ case Begin:
+ case Comment:
+ continue;
+ case Normal:
+ *t = '\0';
+ *lexToken = tokenBuf;
+ return NAME;
+ case Quoted:
+ break;
+ }
+ /* fall through */
+ case NORMAL:
+ switch (state) {
+ case Begin:
+ state = Normal;
+ break;
+ case Comment:
+ continue;
+ default:
+ break;
+ }
+ *t++ = c;
+ ++count;
+ break;
+ case END:
+ case NL:
+ switch (state) {
+ case Begin:
+ case Comment:
+ *lexToken = (char *) NULL;
+ return charClass == END ? DONE : NEWLINE;
+ default:
+ *t = '\0';
+ *lexToken = tokenBuf;
+ ungetc(c, file);
+ return NAME;
+ }
+ break;
+ case BANG:
+ switch (state) {
+ case Begin:
+ state = Comment;
+ break;
+ case Comment:
+ break;
+ default:
+ *t++ = c;
+ ++count;
+ }
+ break;
+ }
+ }
+}
+
+static int
+lexc(FILE *file)
+{
+ int c;
+
+ c = getc(file);
+ switch (c) {
+ case EOF:
+ charClass = END;
+ break;
+ case '\\':
+ c = getc(file);
+ if (c == EOF)
+ charClass = END;
+ else
+ charClass = NORMAL;
+ break;
+ case '"':
+ charClass = QUOTE;
+ break;
+ case ' ':
+ case '\t':
+ charClass = WHITE;
+ break;
+ case '\r':
+ case '\n':
+ charClass = NL;
+ break;
+ case '!':
+ charClass = BANG;
+ break;
+ default:
+ charClass = NORMAL;
+ break;
+ }
+ return c;
+}
diff --git a/nx-X11/lib/font/fontfile/encparse.c b/nx-X11/lib/font/fontfile/encparse.c
new file mode 100644
index 000000000..6262aff07
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/encparse.c
@@ -0,0 +1,966 @@
+/*
+Copyright (c) 1998-2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+
+/* $XFree86: xc/lib/font/fontfile/encparse.c,v 1.20tsi Exp $ */
+
+/* Parser for encoding files */
+
+/* This code assumes that we are using ASCII. We don't use the ctype
+ functions, as they depend on the current locale. On the other
+ hand, we do use strcasecmp, but only on strings that we've checked
+ to be pure ASCII. Bloody ``Code Set Independence''. */
+
+#include <string.h>
+#include <stdio.h>
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#include <strings.h>
+#endif
+
+#ifndef FONTENC_NO_LIBFONT
+
+#include <X11/fonts/fntfilio.h>
+#include <X11/fonts/fntfilst.h>
+
+#else
+
+#include <stdlib.h>
+#define xalloc(n) malloc(n)
+#define xrealloc(p, n) realloc(p, n)
+#define xfree(p) free(p)
+
+#include "zlib.h"
+typedef gzFile FontFilePtr;
+#define FontFileGetc(f) gzgetc(f)
+#define FontFileOpen(filename) gzopen(filename, "rb")
+#define FontFileClose(f) gzclose(f)
+
+#define MAXFONTFILENAMELEN 1024
+#define MAXFONTNAMELEN 1024
+
+#endif
+
+#include <X11/fonts/fontenc.h>
+#include "fontencI.h"
+
+#define MAXALIASES 20
+
+#define EOF_TOKEN -1
+#define ERROR_TOKEN -2
+#define EOL_TOKEN 0
+#define NUMBER_TOKEN 1
+#define KEYWORD_TOKEN 2
+
+#define EOF_LINE -1
+#define ERROR_LINE -2
+#define STARTENCODING_LINE 1
+#define STARTMAPPING_LINE 2
+#define ENDMAPPING_LINE 3
+#define CODE_LINE 4
+#define CODE_RANGE_LINE 5
+#define CODE_UNDEFINE_LINE 6
+#define NAME_LINE 7
+#define SIZE_LINE 8
+#define ALIAS_LINE 9
+#define FIRSTINDEX_LINE 10
+
+/* Return from lexer */
+#define MAXKEYWORDLEN 100
+
+static long number_value;
+static char keyword_value[MAXKEYWORDLEN+1];
+
+static long value1, value2, value3;
+
+/* Lexer code */
+
+/* Skip to the beginning of new line */
+static void
+skipEndOfLine(FontFilePtr f, int c)
+{
+ if(c == 0)
+ c = FontFileGetc(f);
+
+ for(;;)
+ if(c <= 0 || c == '\n')
+ return;
+ else
+ c = FontFileGetc(f);
+}
+
+/* Get a number; we're at the first digit. */
+static unsigned
+getnum(FontFilePtr f, int c, int *cp)
+{
+ unsigned n = 0;
+ int base = 10;
+
+ /* look for `0' or `0x' prefix */
+ if(c == '0') {
+ c = FontFileGetc(f);
+ base = 8;
+ if(c == 'x' || c == 'X') {
+ base = 16;
+ c = FontFileGetc(f);
+ }
+ }
+
+ /* accumulate digits */
+ for(;;) {
+ if ('0' <= c && c <= '9') {
+ n *= base; n += c - '0';
+ } else if('a' <= c && c <= 'f') {
+ n *= base; n += c - 'a' + 10;
+ } else if('A' <=c && c <= 'F') {
+ n *= base; n += c - 'A' + 10;
+ } else
+ break;
+ c = FontFileGetc(f);
+ }
+
+ *cp = c; return n;
+}
+
+/* Skip to beginning of new line; return 1 if only whitespace was found. */
+static int
+endOfLine(FontFilePtr f, int c)
+{
+ if(c == 0)
+ c = FontFileGetc(f);
+
+ for(;;) {
+ if(c <= 0 || c == '\n')
+ return 1;
+ else if(c == '#') {
+ skipEndOfLine(f,c);
+ return 1;
+ }
+ else if(c == ' ' || c == '\t') {
+ skipEndOfLine(f,c);
+ return 0;
+ }
+ c = FontFileGetc(f);
+ }
+}
+
+/* Get a token; we're at first char */
+static int
+gettoken(FontFilePtr f, int c, int *cp)
+{
+ char *p;
+
+ if(c <= 0)
+ c = FontFileGetc(f);
+
+ if(c <= 0) {
+ return EOF_TOKEN;
+ }
+
+ while(c == ' ' || c == '\t')
+ c = FontFileGetc(f);
+
+ if(c=='\n') {
+ return EOL_TOKEN;
+ } else if(c == '#') {
+ skipEndOfLine(f,c);
+ return EOL_TOKEN;
+ } else if(c >= '0' && c <= '9') {
+ number_value = getnum(f,c,cp);
+ return NUMBER_TOKEN;
+ } else if((c >= 'A' && c <= 'Z') ||
+ (c >= 'a' && c <= 'z') ||
+ c == '/' || c == '_' || c == '-' || c == '.') {
+ p = keyword_value;
+ *p++ = c;
+ while(p-keyword_value < MAXKEYWORDLEN) {
+ c = FontFileGetc(f);
+ if(c <= ' ' || c > '~' || c == '#')
+ break;
+ *p++ = c;
+ }
+ *cp = c;
+ *p = '\0';
+ return KEYWORD_TOKEN;
+ } else {
+ *cp = c;
+ return ERROR_TOKEN;
+ }
+}
+
+/* Parse a line.
+ * Always skips to the beginning of a new line, even if an error occurs */
+static int
+getnextline(FontFilePtr f)
+{
+ int c, token;
+ c = FontFileGetc(f);
+ if(c <= 0)
+ return EOF_LINE;
+
+ again:
+ token=gettoken(f,c,&c);
+
+ switch(token) {
+ case EOF_TOKEN:
+ return EOF_LINE;
+ case EOL_TOKEN:
+ /* empty line */
+ c = FontFileGetc(f);
+ goto again;
+ case NUMBER_TOKEN:
+ value1 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value2 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value3 = number_value;
+ return CODE_RANGE_LINE;
+ case EOL_TOKEN:
+ return CODE_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ case KEYWORD_TOKEN:
+ if(!endOfLine(f,c))
+ return ERROR_LINE;
+ else
+ return NAME_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ case KEYWORD_TOKEN:
+ if(!strcasecmp(keyword_value, "STARTENCODING")) {
+ token = gettoken(f,c,&c);
+ if(token == KEYWORD_TOKEN) {
+ if(endOfLine(f,c))
+ return STARTENCODING_LINE;
+ else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "ALIAS")) {
+ token = gettoken(f,c,&c);
+ if(token == KEYWORD_TOKEN) {
+ if(endOfLine(f,c))
+ return ALIAS_LINE;
+ else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "SIZE")) {
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value1 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value2 = number_value;
+ return SIZE_LINE;
+ case EOL_TOKEN:
+ value2=0;
+ return SIZE_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "FIRSTINDEX")) {
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value1 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value2 = number_value;
+ return FIRSTINDEX_LINE;
+ case EOL_TOKEN:
+ value2 = 0;
+ return FIRSTINDEX_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "STARTMAPPING")) {
+ keyword_value[0] = 0;
+ value1 = 0; value1 = 0;
+ /* first a keyword */
+ token = gettoken(f,c,&c);
+ if(token != KEYWORD_TOKEN) {
+ skipEndOfLine(f, c);
+ return ERROR_LINE;
+ }
+
+ /* optional first integer */
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value1 = number_value;
+ } else if(token == EOL_TOKEN) {
+ return STARTMAPPING_LINE;
+ } else {
+ skipEndOfLine(f, c);
+ return ERROR_LINE;
+ }
+
+ /* optional second integer */
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value2 = number_value;
+ } else if(token == EOL_TOKEN) {
+ return STARTMAPPING_LINE;
+ } else {
+ skipEndOfLine(f, c);
+ return ERROR_LINE;
+ }
+
+ if(!endOfLine(f,c))
+ return ERROR_LINE;
+ else {
+ return STARTMAPPING_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "UNDEFINE")) {
+ /* first integer */
+ token = gettoken(f,c,&c);
+ if(token != NUMBER_TOKEN) {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ value1 = number_value;
+ /* optional second integer */
+ token = gettoken(f,c,&c);
+ if(token == EOL_TOKEN) {
+ value2 = value1;
+ return CODE_UNDEFINE_LINE;
+ } else if(token == NUMBER_TOKEN) {
+ value2 = number_value;
+ if(endOfLine(f,c)) {
+ return CODE_UNDEFINE_LINE;
+ } else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "ENDENCODING")) {
+ if(endOfLine(f,c))
+ return EOF_LINE;
+ else
+ return ERROR_LINE;
+ } else if(!strcasecmp(keyword_value, "ENDMAPPING")) {
+ if(endOfLine(f,c))
+ return ENDMAPPING_LINE;
+ else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ default:
+ return ERROR_LINE;
+ }
+}
+
+static void
+install_mapping(FontEncPtr encoding, FontMapPtr mapping)
+{
+ FontMapPtr m;
+
+ if(encoding->mappings == NULL)
+ encoding->mappings = mapping;
+ else {
+ m = encoding->mappings;
+ while(m->next != NULL)
+ m = m->next;
+ m->next = mapping;
+ }
+ mapping->next = NULL;
+ mapping->encoding = encoding;
+}
+
+static int
+setCode(unsigned from, unsigned to, unsigned row_size,
+ unsigned *first, unsigned *last,
+ unsigned *encsize, unsigned short **enc)
+{
+ unsigned index, i;
+ unsigned short *newenc;
+
+ if(from>0xFFFF)
+ return 0; /* success */
+
+ if(row_size==0)
+ index=from;
+ else {
+ if((value1 & 0xFF) >= row_size)
+ return 0; /* ignore out of range mappings */
+ index = (from>>8) * row_size + (from&0xFF);
+ }
+
+ /* Optimize away useless identity mappings. This is only expected
+ to be useful with linear encodings. */
+ if(index == to && (index < *first || index > *last))
+ return 0;
+ if(*encsize == 0) {
+ *encsize = (index < 256) ? 256 : 0x10000;
+ *enc = (unsigned short*)xalloc((*encsize) * sizeof(unsigned short));
+ if(*enc == NULL) {
+ *encsize = 0;
+ return 1;
+ }
+ } else if(*encsize <= index) {
+ *encsize = 0x10000;
+ if((newenc = (unsigned short*)xrealloc(enc, *encsize))==NULL)
+ return 1;
+ *enc = newenc;
+ }
+ if(*first > *last) {
+ *first = *last = index;
+ }
+ if(index < *first) {
+ for(i = index; i < *first; i++)
+ (*enc)[i] = i;
+ *first = index;
+ }
+ if(index > *last) {
+ for(i = *last + 1; i <= index; i++)
+ (*enc)[i] = i;
+ *last = index;
+ }
+ (*enc)[index] = to;
+ return 0;
+}
+
+/* Parser. If headerOnly is true, we're only interested in the
+ data contained in the encoding file's header. */
+
+/* As font encodings are currently never freed, the allocations done
+ by this function are mostly its private business. Note, however,
+ that FontEncIdentify needs to free the header fields -- so if you
+ change this function, you may need to change FontEncIdentify. */
+
+/* I want a garbage collector. */
+
+static FontEncPtr
+parseEncodingFile(FontFilePtr f, int headerOnly)
+{
+ int line;
+
+ unsigned short *enc=NULL;
+ char **nam = NULL, **newnam;
+ unsigned i, first = 0xFFFF, last=0, encsize=0, namsize=0;
+ FontEncPtr encoding = NULL;
+ FontMapPtr mapping = NULL;
+ FontEncSimpleMapPtr sm;
+ FontEncSimpleNamePtr sn;
+ char *aliases[MAXALIASES];
+ int numaliases=0;
+
+#if 0
+ /* GCC complains about unused labels. Please fix GCC rather than
+ obfuscating my code. */
+ no_encoding:
+#endif
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE:
+ goto error;
+ case STARTENCODING_LINE:
+ encoding = (FontEncPtr)xalloc(sizeof(FontEncRec));
+ if(encoding == NULL)
+ goto error;
+ encoding->name = (char*)xalloc(strlen(keyword_value)+1);
+ if(encoding->name == NULL)
+ goto error;
+ strcpy(encoding->name, keyword_value);
+ encoding->size = 256;
+ encoding->row_size = 0;
+ encoding->mappings = NULL;
+ encoding->next = NULL;
+ encoding->first = encoding->first_col=0;
+ goto no_mapping;
+ default:
+ goto error;
+ }
+
+ no_mapping:
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE: goto done;
+ case ALIAS_LINE:
+ if(numaliases < MAXALIASES) {
+ aliases[numaliases] = (char*)xalloc(strlen(keyword_value)+1);
+ if(aliases[numaliases] == NULL)
+ goto error;
+ strcpy(aliases[numaliases], keyword_value);
+ numaliases++;
+ }
+ goto no_mapping;
+ case SIZE_LINE:
+ encoding->size = value1;
+ encoding->row_size = value2;
+ goto no_mapping;
+ case FIRSTINDEX_LINE:
+ encoding->first = value1;
+ encoding->first_col = value2;
+ goto no_mapping;
+ case STARTMAPPING_LINE:
+ if(headerOnly)
+ goto done;
+ if(!strcasecmp(keyword_value, "unicode")) {
+ mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
+ if(mapping == NULL)
+ goto error;
+ mapping->type = FONT_ENCODING_UNICODE;
+ mapping->pid = 0;
+ mapping->eid = 0;
+ mapping->recode = 0;
+ mapping->name = 0;
+ mapping->client_data = 0;
+ mapping->next = 0;
+ goto mapping;
+ } else if(!strcasecmp(keyword_value, "cmap")) {
+ mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
+ if(mapping == NULL)
+ goto error;
+ mapping->type = FONT_ENCODING_TRUETYPE;
+ mapping->pid = value1;
+ mapping->eid = value2;
+ mapping->recode = 0;
+ mapping->name = 0;
+ mapping->client_data = 0;
+ mapping->next = 0;
+ goto mapping;
+ } else if(!strcasecmp(keyword_value, "postscript")) {
+ mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
+ if(mapping == NULL)
+ goto error;
+ mapping->type = FONT_ENCODING_POSTSCRIPT;
+ mapping->pid = 0;
+ mapping->eid = 0;
+ mapping->recode = 0;
+ mapping->name = 0;
+ mapping->client_data = 0;
+ mapping->next = 0;
+ goto string_mapping;
+ } else { /* unknown mapping type -- ignore */
+ goto skipmapping;
+ }
+ /* NOTREACHED */
+ goto error;
+ default: goto no_mapping; /* ignore unknown lines */
+ }
+
+ skipmapping:
+ line = getnextline(f);
+ switch(line) {
+ case ENDMAPPING_LINE:
+ goto no_mapping;
+ case EOF_LINE:
+ goto error;
+ default:
+ goto skipmapping;
+ }
+
+ mapping:
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE: goto error;
+ case ENDMAPPING_LINE:
+ mapping->recode = FontEncSimpleRecode;
+ mapping->name = FontEncUndefinedName;
+ mapping->client_data = sm =
+ (FontEncSimpleMapPtr)xalloc(sizeof(FontEncSimpleMapRec));
+ if(sm == NULL)
+ goto error;
+ sm->row_size = encoding->row_size;
+ if(first <= last) {
+ sm->first = first;
+ sm->len=last-first+1;
+ sm->map =
+ (unsigned short*)xalloc(sm->len * sizeof(unsigned short));
+ if(sm->map == NULL) {
+ xfree(sm);
+ mapping->client_data = sm = NULL;
+ goto error;
+ }
+ } else {
+ sm->first = 0;
+ sm->len = 0;
+ sm->map = 0;
+ }
+ for(i=0; i < sm->len; i++)
+ sm -> map[i] = enc[first+i];
+ install_mapping(encoding, mapping);
+ mapping = 0;
+ first = 0xFFFF; last=0;
+ goto no_mapping;
+
+ case CODE_LINE:
+ if(setCode(value1, value2, encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ goto mapping;
+
+ case CODE_RANGE_LINE:
+ if(value1 > 0x10000)
+ value1 = 0x10000;
+ if(value2 > 0x10000)
+ value2 = 0x10000;
+ if(value2 < value1)
+ goto mapping;
+ /* Do the last value first to avoid having to realloc() */
+ if(setCode(value2, value3+(value2-value1), encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ for(i=value1; i<value2; i++) {
+ if(setCode(i, value3+(i-value1), encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ }
+ goto mapping;
+
+ case CODE_UNDEFINE_LINE:
+ if(value1 > 0x10000)
+ value1 = 0x10000;
+ if(value2 > 0x10000)
+ value2 = 0x10000;
+ if(value2 < value1)
+ goto mapping;
+ /* Do the last value first to avoid having to realloc() */
+ if(setCode(value2, 0, encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ for(i = value1; i < value2; i++) {
+ if(setCode(i, 0, encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ }
+ goto mapping;
+
+ default: goto mapping; /* ignore unknown lines */
+ }
+
+ string_mapping:
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE: goto error;
+ case ENDMAPPING_LINE:
+ mapping->recode = FontEncUndefinedRecode;
+ mapping->name = FontEncSimpleName;
+ mapping->client_data = sn =
+ (FontEncSimpleNamePtr)xalloc(sizeof(FontEncSimpleNameRec));
+ if(sn == NULL)
+ goto error;
+ if(first > last) {
+ xfree(sn);
+ mapping->client_data = sn = NULL;
+ goto error;
+ }
+ sn->first = first;
+ sn->len = last - first + 1;
+ sn->map = (char**)xalloc(sn->len*sizeof(char*));
+ if(sn->map == NULL) {
+ xfree(sn);
+ mapping->client_data = sn = NULL;
+ goto error;
+ }
+ for(i = 0; i < sn->len; i++)
+ sn->map[i] = nam[first+i];
+ install_mapping(encoding,mapping);
+ mapping = 0;
+ first = 0xFFFF; last=0;
+ goto no_mapping;
+ case NAME_LINE:
+ if(value1 >= 0x10000) goto string_mapping;
+ if(namsize == 0) {
+ namsize = (value1) < 256 ? 256 : 0x10000;
+ nam = (char**)xalloc(namsize * sizeof(char*));
+ if(nam == NULL) {
+ namsize=0;
+ goto error;
+ }
+ } else if(namsize <= value1) {
+ namsize = 0x10000;
+ if((newnam = (char**)xrealloc(nam, namsize)) == NULL)
+ goto error;
+ nam = newnam;
+ }
+ if(first > last) {
+ first = last = value1;
+ }
+ if(value1 < first) {
+ for(i = value1; i < first; i++)
+ nam[i] = NULL;
+ first = value1;
+ }
+ if(value1 > last) {
+ for(i=last+1; i <= value1; i++)
+ nam[i]=NULL;
+ last = value1;
+ }
+ nam[value1] = (char*)xalloc(strlen(keyword_value)+1);
+ if(nam[value1] == NULL) {
+ goto error;
+ }
+ strcpy(nam[value1], keyword_value);
+ goto string_mapping;
+
+ default: goto string_mapping; /* ignore unknown lines */
+ }
+
+ done:
+ if(encsize) xfree(enc); encsize=0; enc = NULL;
+ if(namsize) xfree(nam); namsize=0; nam = NULL; /* don't free entries! */
+
+ encoding->aliases=NULL;
+ if(numaliases) {
+ encoding->aliases = (char**)xalloc((numaliases+1)*sizeof(char*));
+ if(encoding->aliases == NULL)
+ goto error;
+ for(i=0; i<numaliases; i++)
+ encoding->aliases[i] = aliases[i];
+ encoding->aliases[numaliases]=NULL;
+ }
+
+ return encoding;
+
+error:
+ if(encsize) xfree(enc); encsize=0;
+ if(namsize) {
+ for(i = first; i <= last; i++)
+ if(nam[i])
+ xfree(nam[i]);
+ xfree(nam);
+ namsize = 0;
+ }
+ if(mapping) {
+ if(mapping->client_data) xfree(mapping->client_data);
+ xfree(mapping);
+ }
+ if(encoding) {
+ if(encoding->name) xfree(encoding->name);
+ for(mapping = encoding->mappings; mapping; mapping = mapping->next) {
+ if(mapping->client_data) xfree(mapping->client_data);
+ xfree(mapping);
+ }
+ xfree(encoding);
+ }
+ for(i = 0; i < numaliases; i++)
+ xfree(aliases[i]);
+ /* We don't need to free sn and sm as they handled locally in the body.*/
+ return 0;
+}
+
+char*
+FontEncDirectory()
+{
+ static char* dir = NULL;
+
+ if(dir == NULL) {
+ char *c = getenv("FONT_ENCODINGS_DIRECTORY");
+ if(c) {
+ dir = malloc(strlen(c) + 1);
+ if(!dir)
+ return NULL;
+ strcpy(dir, c);
+ } else {
+ dir = FONT_ENCODINGS_DIRECTORY;
+ }
+ }
+ return dir;
+}
+
+static void
+parseFontFileName(const char *fontFileName, char *buf, char *dir)
+{
+ const char *p;
+ char *q, *lastslash;
+
+ for(p = fontFileName, q = dir, lastslash = NULL; *p; p++, q++) {
+ *q = *p;
+ if(*p == '/')
+ lastslash = q+1;
+ }
+
+ if(!lastslash)
+ lastslash = dir;
+
+ *lastslash = '\0';
+
+ if(buf && strlen(dir) + 14 < MAXFONTFILENAMELEN) {
+ strcpy(buf, dir);
+ strcat(buf, "encodings.dir");
+ }
+}
+
+static FontEncPtr
+FontEncReallyReallyLoad(const char *charset,
+ const char *dirname, const char *dir)
+{
+ FontFilePtr f;
+ FILE *file;
+ FontEncPtr encoding;
+ char file_name[MAXFONTFILENAMELEN], encoding_name[MAXFONTNAMELEN],
+ buf[MAXFONTFILENAMELEN];
+ int count, n;
+ static char format[24] = "";
+
+ /* As we don't really expect to open encodings that often, we don't
+ take the trouble of caching encodings directories. */
+
+ if((file = fopen(dirname, "r")) == NULL) {
+ return NULL;
+ }
+
+ count = fscanf(file, "%d\n", &n);
+ if(count == EOF || count != 1) {
+ fclose(file);
+ return NULL;
+ }
+
+ encoding = NULL;
+ if (!format[0]) {
+ sprintf(format, "%%%ds %%%d[^\n]\n", (int)sizeof(encoding_name) - 1,
+ (int)sizeof(file_name) - 1);
+ }
+ for(;;) {
+ count = fscanf(file, format, encoding_name, file_name);
+ if(count == EOF)
+ break;
+ if(count != 2)
+ break;
+
+ if(!strcasecmp(encoding_name, charset)) {
+ /* Found it */
+ if(file_name[0] != '/') {
+ if(strlen(dir) + strlen(file_name) >= MAXFONTFILENAMELEN) {
+ fclose(file);
+ return NULL;
+ }
+ strcpy(buf, dir);
+ strcat(buf, file_name);
+ } else {
+ strcpy(buf , file_name);
+ }
+
+ f = FontFileOpen(buf);
+ if(f == NULL) {
+ fclose(file);
+ return NULL;
+ }
+ encoding = parseEncodingFile(f, 0);
+ FontFileClose(f);
+ break;
+ }
+ }
+
+ fclose(file);
+
+ return encoding;
+}
+
+/* Parser ntrypoint -- used by FontEncLoad */
+FontEncPtr
+FontEncReallyLoad(const char *charset, const char *fontFileName)
+{
+ FontEncPtr encoding;
+ char dir[MAXFONTFILENAMELEN], dirname[MAXFONTFILENAMELEN];
+ char *d;
+
+ if(fontFileName) {
+ parseFontFileName(fontFileName, dirname, dir);
+ encoding = FontEncReallyReallyLoad(charset, dirname, dir);
+ if(encoding)
+ return(encoding);
+ }
+
+ d = FontEncDirectory();
+ if(d) {
+ parseFontFileName(d, NULL, dir);
+ encoding = FontEncReallyReallyLoad(charset, d, dir);
+ return encoding;
+ }
+
+ return NULL;
+}
+
+/* Return a NULL-terminated array of encoding names. Note that this
+ * function has incestuous knowledge of the allocations done by
+ * parseEncodingFile. */
+
+char **
+FontEncIdentify(const char *fileName)
+{
+ FontFilePtr f;
+ FontEncPtr encoding;
+ char **names, **name, **alias;
+ int numaliases;
+
+ if((f = FontFileOpen(fileName))==NULL) {
+ return NULL;
+ }
+ encoding = parseEncodingFile(f, 1);
+ FontFileClose(f);
+
+ if(!encoding)
+ return NULL;
+
+ numaliases = 0;
+ if(encoding->aliases)
+ for(alias = encoding->aliases; *alias; alias++)
+ numaliases++;
+
+ names = (char**)xalloc((numaliases+2)*sizeof(char*));
+ if(names == NULL) {
+ if(encoding->aliases)
+ xfree(encoding->aliases);
+ xfree(encoding);
+ return NULL;
+ }
+
+ name = names;
+ *(name++) = encoding->name;
+ if(numaliases > 0)
+ for(alias = encoding->aliases; *alias; alias++, name++)
+ *name = *alias;
+
+ *name = 0;
+ xfree(encoding->aliases);
+ xfree(encoding);
+
+ return names;
+}
diff --git a/nx-X11/lib/font/fontfile/encparse.c.NX.original b/nx-X11/lib/font/fontfile/encparse.c.NX.original
new file mode 100644
index 000000000..6262aff07
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/encparse.c.NX.original
@@ -0,0 +1,966 @@
+/*
+Copyright (c) 1998-2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+
+/* $XFree86: xc/lib/font/fontfile/encparse.c,v 1.20tsi Exp $ */
+
+/* Parser for encoding files */
+
+/* This code assumes that we are using ASCII. We don't use the ctype
+ functions, as they depend on the current locale. On the other
+ hand, we do use strcasecmp, but only on strings that we've checked
+ to be pure ASCII. Bloody ``Code Set Independence''. */
+
+#include <string.h>
+#include <stdio.h>
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#include <strings.h>
+#endif
+
+#ifndef FONTENC_NO_LIBFONT
+
+#include <X11/fonts/fntfilio.h>
+#include <X11/fonts/fntfilst.h>
+
+#else
+
+#include <stdlib.h>
+#define xalloc(n) malloc(n)
+#define xrealloc(p, n) realloc(p, n)
+#define xfree(p) free(p)
+
+#include "zlib.h"
+typedef gzFile FontFilePtr;
+#define FontFileGetc(f) gzgetc(f)
+#define FontFileOpen(filename) gzopen(filename, "rb")
+#define FontFileClose(f) gzclose(f)
+
+#define MAXFONTFILENAMELEN 1024
+#define MAXFONTNAMELEN 1024
+
+#endif
+
+#include <X11/fonts/fontenc.h>
+#include "fontencI.h"
+
+#define MAXALIASES 20
+
+#define EOF_TOKEN -1
+#define ERROR_TOKEN -2
+#define EOL_TOKEN 0
+#define NUMBER_TOKEN 1
+#define KEYWORD_TOKEN 2
+
+#define EOF_LINE -1
+#define ERROR_LINE -2
+#define STARTENCODING_LINE 1
+#define STARTMAPPING_LINE 2
+#define ENDMAPPING_LINE 3
+#define CODE_LINE 4
+#define CODE_RANGE_LINE 5
+#define CODE_UNDEFINE_LINE 6
+#define NAME_LINE 7
+#define SIZE_LINE 8
+#define ALIAS_LINE 9
+#define FIRSTINDEX_LINE 10
+
+/* Return from lexer */
+#define MAXKEYWORDLEN 100
+
+static long number_value;
+static char keyword_value[MAXKEYWORDLEN+1];
+
+static long value1, value2, value3;
+
+/* Lexer code */
+
+/* Skip to the beginning of new line */
+static void
+skipEndOfLine(FontFilePtr f, int c)
+{
+ if(c == 0)
+ c = FontFileGetc(f);
+
+ for(;;)
+ if(c <= 0 || c == '\n')
+ return;
+ else
+ c = FontFileGetc(f);
+}
+
+/* Get a number; we're at the first digit. */
+static unsigned
+getnum(FontFilePtr f, int c, int *cp)
+{
+ unsigned n = 0;
+ int base = 10;
+
+ /* look for `0' or `0x' prefix */
+ if(c == '0') {
+ c = FontFileGetc(f);
+ base = 8;
+ if(c == 'x' || c == 'X') {
+ base = 16;
+ c = FontFileGetc(f);
+ }
+ }
+
+ /* accumulate digits */
+ for(;;) {
+ if ('0' <= c && c <= '9') {
+ n *= base; n += c - '0';
+ } else if('a' <= c && c <= 'f') {
+ n *= base; n += c - 'a' + 10;
+ } else if('A' <=c && c <= 'F') {
+ n *= base; n += c - 'A' + 10;
+ } else
+ break;
+ c = FontFileGetc(f);
+ }
+
+ *cp = c; return n;
+}
+
+/* Skip to beginning of new line; return 1 if only whitespace was found. */
+static int
+endOfLine(FontFilePtr f, int c)
+{
+ if(c == 0)
+ c = FontFileGetc(f);
+
+ for(;;) {
+ if(c <= 0 || c == '\n')
+ return 1;
+ else if(c == '#') {
+ skipEndOfLine(f,c);
+ return 1;
+ }
+ else if(c == ' ' || c == '\t') {
+ skipEndOfLine(f,c);
+ return 0;
+ }
+ c = FontFileGetc(f);
+ }
+}
+
+/* Get a token; we're at first char */
+static int
+gettoken(FontFilePtr f, int c, int *cp)
+{
+ char *p;
+
+ if(c <= 0)
+ c = FontFileGetc(f);
+
+ if(c <= 0) {
+ return EOF_TOKEN;
+ }
+
+ while(c == ' ' || c == '\t')
+ c = FontFileGetc(f);
+
+ if(c=='\n') {
+ return EOL_TOKEN;
+ } else if(c == '#') {
+ skipEndOfLine(f,c);
+ return EOL_TOKEN;
+ } else if(c >= '0' && c <= '9') {
+ number_value = getnum(f,c,cp);
+ return NUMBER_TOKEN;
+ } else if((c >= 'A' && c <= 'Z') ||
+ (c >= 'a' && c <= 'z') ||
+ c == '/' || c == '_' || c == '-' || c == '.') {
+ p = keyword_value;
+ *p++ = c;
+ while(p-keyword_value < MAXKEYWORDLEN) {
+ c = FontFileGetc(f);
+ if(c <= ' ' || c > '~' || c == '#')
+ break;
+ *p++ = c;
+ }
+ *cp = c;
+ *p = '\0';
+ return KEYWORD_TOKEN;
+ } else {
+ *cp = c;
+ return ERROR_TOKEN;
+ }
+}
+
+/* Parse a line.
+ * Always skips to the beginning of a new line, even if an error occurs */
+static int
+getnextline(FontFilePtr f)
+{
+ int c, token;
+ c = FontFileGetc(f);
+ if(c <= 0)
+ return EOF_LINE;
+
+ again:
+ token=gettoken(f,c,&c);
+
+ switch(token) {
+ case EOF_TOKEN:
+ return EOF_LINE;
+ case EOL_TOKEN:
+ /* empty line */
+ c = FontFileGetc(f);
+ goto again;
+ case NUMBER_TOKEN:
+ value1 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value2 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value3 = number_value;
+ return CODE_RANGE_LINE;
+ case EOL_TOKEN:
+ return CODE_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ case KEYWORD_TOKEN:
+ if(!endOfLine(f,c))
+ return ERROR_LINE;
+ else
+ return NAME_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ case KEYWORD_TOKEN:
+ if(!strcasecmp(keyword_value, "STARTENCODING")) {
+ token = gettoken(f,c,&c);
+ if(token == KEYWORD_TOKEN) {
+ if(endOfLine(f,c))
+ return STARTENCODING_LINE;
+ else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "ALIAS")) {
+ token = gettoken(f,c,&c);
+ if(token == KEYWORD_TOKEN) {
+ if(endOfLine(f,c))
+ return ALIAS_LINE;
+ else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "SIZE")) {
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value1 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value2 = number_value;
+ return SIZE_LINE;
+ case EOL_TOKEN:
+ value2=0;
+ return SIZE_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "FIRSTINDEX")) {
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value1 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value2 = number_value;
+ return FIRSTINDEX_LINE;
+ case EOL_TOKEN:
+ value2 = 0;
+ return FIRSTINDEX_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "STARTMAPPING")) {
+ keyword_value[0] = 0;
+ value1 = 0; value1 = 0;
+ /* first a keyword */
+ token = gettoken(f,c,&c);
+ if(token != KEYWORD_TOKEN) {
+ skipEndOfLine(f, c);
+ return ERROR_LINE;
+ }
+
+ /* optional first integer */
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value1 = number_value;
+ } else if(token == EOL_TOKEN) {
+ return STARTMAPPING_LINE;
+ } else {
+ skipEndOfLine(f, c);
+ return ERROR_LINE;
+ }
+
+ /* optional second integer */
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value2 = number_value;
+ } else if(token == EOL_TOKEN) {
+ return STARTMAPPING_LINE;
+ } else {
+ skipEndOfLine(f, c);
+ return ERROR_LINE;
+ }
+
+ if(!endOfLine(f,c))
+ return ERROR_LINE;
+ else {
+ return STARTMAPPING_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "UNDEFINE")) {
+ /* first integer */
+ token = gettoken(f,c,&c);
+ if(token != NUMBER_TOKEN) {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ value1 = number_value;
+ /* optional second integer */
+ token = gettoken(f,c,&c);
+ if(token == EOL_TOKEN) {
+ value2 = value1;
+ return CODE_UNDEFINE_LINE;
+ } else if(token == NUMBER_TOKEN) {
+ value2 = number_value;
+ if(endOfLine(f,c)) {
+ return CODE_UNDEFINE_LINE;
+ } else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "ENDENCODING")) {
+ if(endOfLine(f,c))
+ return EOF_LINE;
+ else
+ return ERROR_LINE;
+ } else if(!strcasecmp(keyword_value, "ENDMAPPING")) {
+ if(endOfLine(f,c))
+ return ENDMAPPING_LINE;
+ else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ default:
+ return ERROR_LINE;
+ }
+}
+
+static void
+install_mapping(FontEncPtr encoding, FontMapPtr mapping)
+{
+ FontMapPtr m;
+
+ if(encoding->mappings == NULL)
+ encoding->mappings = mapping;
+ else {
+ m = encoding->mappings;
+ while(m->next != NULL)
+ m = m->next;
+ m->next = mapping;
+ }
+ mapping->next = NULL;
+ mapping->encoding = encoding;
+}
+
+static int
+setCode(unsigned from, unsigned to, unsigned row_size,
+ unsigned *first, unsigned *last,
+ unsigned *encsize, unsigned short **enc)
+{
+ unsigned index, i;
+ unsigned short *newenc;
+
+ if(from>0xFFFF)
+ return 0; /* success */
+
+ if(row_size==0)
+ index=from;
+ else {
+ if((value1 & 0xFF) >= row_size)
+ return 0; /* ignore out of range mappings */
+ index = (from>>8) * row_size + (from&0xFF);
+ }
+
+ /* Optimize away useless identity mappings. This is only expected
+ to be useful with linear encodings. */
+ if(index == to && (index < *first || index > *last))
+ return 0;
+ if(*encsize == 0) {
+ *encsize = (index < 256) ? 256 : 0x10000;
+ *enc = (unsigned short*)xalloc((*encsize) * sizeof(unsigned short));
+ if(*enc == NULL) {
+ *encsize = 0;
+ return 1;
+ }
+ } else if(*encsize <= index) {
+ *encsize = 0x10000;
+ if((newenc = (unsigned short*)xrealloc(enc, *encsize))==NULL)
+ return 1;
+ *enc = newenc;
+ }
+ if(*first > *last) {
+ *first = *last = index;
+ }
+ if(index < *first) {
+ for(i = index; i < *first; i++)
+ (*enc)[i] = i;
+ *first = index;
+ }
+ if(index > *last) {
+ for(i = *last + 1; i <= index; i++)
+ (*enc)[i] = i;
+ *last = index;
+ }
+ (*enc)[index] = to;
+ return 0;
+}
+
+/* Parser. If headerOnly is true, we're only interested in the
+ data contained in the encoding file's header. */
+
+/* As font encodings are currently never freed, the allocations done
+ by this function are mostly its private business. Note, however,
+ that FontEncIdentify needs to free the header fields -- so if you
+ change this function, you may need to change FontEncIdentify. */
+
+/* I want a garbage collector. */
+
+static FontEncPtr
+parseEncodingFile(FontFilePtr f, int headerOnly)
+{
+ int line;
+
+ unsigned short *enc=NULL;
+ char **nam = NULL, **newnam;
+ unsigned i, first = 0xFFFF, last=0, encsize=0, namsize=0;
+ FontEncPtr encoding = NULL;
+ FontMapPtr mapping = NULL;
+ FontEncSimpleMapPtr sm;
+ FontEncSimpleNamePtr sn;
+ char *aliases[MAXALIASES];
+ int numaliases=0;
+
+#if 0
+ /* GCC complains about unused labels. Please fix GCC rather than
+ obfuscating my code. */
+ no_encoding:
+#endif
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE:
+ goto error;
+ case STARTENCODING_LINE:
+ encoding = (FontEncPtr)xalloc(sizeof(FontEncRec));
+ if(encoding == NULL)
+ goto error;
+ encoding->name = (char*)xalloc(strlen(keyword_value)+1);
+ if(encoding->name == NULL)
+ goto error;
+ strcpy(encoding->name, keyword_value);
+ encoding->size = 256;
+ encoding->row_size = 0;
+ encoding->mappings = NULL;
+ encoding->next = NULL;
+ encoding->first = encoding->first_col=0;
+ goto no_mapping;
+ default:
+ goto error;
+ }
+
+ no_mapping:
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE: goto done;
+ case ALIAS_LINE:
+ if(numaliases < MAXALIASES) {
+ aliases[numaliases] = (char*)xalloc(strlen(keyword_value)+1);
+ if(aliases[numaliases] == NULL)
+ goto error;
+ strcpy(aliases[numaliases], keyword_value);
+ numaliases++;
+ }
+ goto no_mapping;
+ case SIZE_LINE:
+ encoding->size = value1;
+ encoding->row_size = value2;
+ goto no_mapping;
+ case FIRSTINDEX_LINE:
+ encoding->first = value1;
+ encoding->first_col = value2;
+ goto no_mapping;
+ case STARTMAPPING_LINE:
+ if(headerOnly)
+ goto done;
+ if(!strcasecmp(keyword_value, "unicode")) {
+ mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
+ if(mapping == NULL)
+ goto error;
+ mapping->type = FONT_ENCODING_UNICODE;
+ mapping->pid = 0;
+ mapping->eid = 0;
+ mapping->recode = 0;
+ mapping->name = 0;
+ mapping->client_data = 0;
+ mapping->next = 0;
+ goto mapping;
+ } else if(!strcasecmp(keyword_value, "cmap")) {
+ mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
+ if(mapping == NULL)
+ goto error;
+ mapping->type = FONT_ENCODING_TRUETYPE;
+ mapping->pid = value1;
+ mapping->eid = value2;
+ mapping->recode = 0;
+ mapping->name = 0;
+ mapping->client_data = 0;
+ mapping->next = 0;
+ goto mapping;
+ } else if(!strcasecmp(keyword_value, "postscript")) {
+ mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
+ if(mapping == NULL)
+ goto error;
+ mapping->type = FONT_ENCODING_POSTSCRIPT;
+ mapping->pid = 0;
+ mapping->eid = 0;
+ mapping->recode = 0;
+ mapping->name = 0;
+ mapping->client_data = 0;
+ mapping->next = 0;
+ goto string_mapping;
+ } else { /* unknown mapping type -- ignore */
+ goto skipmapping;
+ }
+ /* NOTREACHED */
+ goto error;
+ default: goto no_mapping; /* ignore unknown lines */
+ }
+
+ skipmapping:
+ line = getnextline(f);
+ switch(line) {
+ case ENDMAPPING_LINE:
+ goto no_mapping;
+ case EOF_LINE:
+ goto error;
+ default:
+ goto skipmapping;
+ }
+
+ mapping:
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE: goto error;
+ case ENDMAPPING_LINE:
+ mapping->recode = FontEncSimpleRecode;
+ mapping->name = FontEncUndefinedName;
+ mapping->client_data = sm =
+ (FontEncSimpleMapPtr)xalloc(sizeof(FontEncSimpleMapRec));
+ if(sm == NULL)
+ goto error;
+ sm->row_size = encoding->row_size;
+ if(first <= last) {
+ sm->first = first;
+ sm->len=last-first+1;
+ sm->map =
+ (unsigned short*)xalloc(sm->len * sizeof(unsigned short));
+ if(sm->map == NULL) {
+ xfree(sm);
+ mapping->client_data = sm = NULL;
+ goto error;
+ }
+ } else {
+ sm->first = 0;
+ sm->len = 0;
+ sm->map = 0;
+ }
+ for(i=0; i < sm->len; i++)
+ sm -> map[i] = enc[first+i];
+ install_mapping(encoding, mapping);
+ mapping = 0;
+ first = 0xFFFF; last=0;
+ goto no_mapping;
+
+ case CODE_LINE:
+ if(setCode(value1, value2, encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ goto mapping;
+
+ case CODE_RANGE_LINE:
+ if(value1 > 0x10000)
+ value1 = 0x10000;
+ if(value2 > 0x10000)
+ value2 = 0x10000;
+ if(value2 < value1)
+ goto mapping;
+ /* Do the last value first to avoid having to realloc() */
+ if(setCode(value2, value3+(value2-value1), encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ for(i=value1; i<value2; i++) {
+ if(setCode(i, value3+(i-value1), encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ }
+ goto mapping;
+
+ case CODE_UNDEFINE_LINE:
+ if(value1 > 0x10000)
+ value1 = 0x10000;
+ if(value2 > 0x10000)
+ value2 = 0x10000;
+ if(value2 < value1)
+ goto mapping;
+ /* Do the last value first to avoid having to realloc() */
+ if(setCode(value2, 0, encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ for(i = value1; i < value2; i++) {
+ if(setCode(i, 0, encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ }
+ goto mapping;
+
+ default: goto mapping; /* ignore unknown lines */
+ }
+
+ string_mapping:
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE: goto error;
+ case ENDMAPPING_LINE:
+ mapping->recode = FontEncUndefinedRecode;
+ mapping->name = FontEncSimpleName;
+ mapping->client_data = sn =
+ (FontEncSimpleNamePtr)xalloc(sizeof(FontEncSimpleNameRec));
+ if(sn == NULL)
+ goto error;
+ if(first > last) {
+ xfree(sn);
+ mapping->client_data = sn = NULL;
+ goto error;
+ }
+ sn->first = first;
+ sn->len = last - first + 1;
+ sn->map = (char**)xalloc(sn->len*sizeof(char*));
+ if(sn->map == NULL) {
+ xfree(sn);
+ mapping->client_data = sn = NULL;
+ goto error;
+ }
+ for(i = 0; i < sn->len; i++)
+ sn->map[i] = nam[first+i];
+ install_mapping(encoding,mapping);
+ mapping = 0;
+ first = 0xFFFF; last=0;
+ goto no_mapping;
+ case NAME_LINE:
+ if(value1 >= 0x10000) goto string_mapping;
+ if(namsize == 0) {
+ namsize = (value1) < 256 ? 256 : 0x10000;
+ nam = (char**)xalloc(namsize * sizeof(char*));
+ if(nam == NULL) {
+ namsize=0;
+ goto error;
+ }
+ } else if(namsize <= value1) {
+ namsize = 0x10000;
+ if((newnam = (char**)xrealloc(nam, namsize)) == NULL)
+ goto error;
+ nam = newnam;
+ }
+ if(first > last) {
+ first = last = value1;
+ }
+ if(value1 < first) {
+ for(i = value1; i < first; i++)
+ nam[i] = NULL;
+ first = value1;
+ }
+ if(value1 > last) {
+ for(i=last+1; i <= value1; i++)
+ nam[i]=NULL;
+ last = value1;
+ }
+ nam[value1] = (char*)xalloc(strlen(keyword_value)+1);
+ if(nam[value1] == NULL) {
+ goto error;
+ }
+ strcpy(nam[value1], keyword_value);
+ goto string_mapping;
+
+ default: goto string_mapping; /* ignore unknown lines */
+ }
+
+ done:
+ if(encsize) xfree(enc); encsize=0; enc = NULL;
+ if(namsize) xfree(nam); namsize=0; nam = NULL; /* don't free entries! */
+
+ encoding->aliases=NULL;
+ if(numaliases) {
+ encoding->aliases = (char**)xalloc((numaliases+1)*sizeof(char*));
+ if(encoding->aliases == NULL)
+ goto error;
+ for(i=0; i<numaliases; i++)
+ encoding->aliases[i] = aliases[i];
+ encoding->aliases[numaliases]=NULL;
+ }
+
+ return encoding;
+
+error:
+ if(encsize) xfree(enc); encsize=0;
+ if(namsize) {
+ for(i = first; i <= last; i++)
+ if(nam[i])
+ xfree(nam[i]);
+ xfree(nam);
+ namsize = 0;
+ }
+ if(mapping) {
+ if(mapping->client_data) xfree(mapping->client_data);
+ xfree(mapping);
+ }
+ if(encoding) {
+ if(encoding->name) xfree(encoding->name);
+ for(mapping = encoding->mappings; mapping; mapping = mapping->next) {
+ if(mapping->client_data) xfree(mapping->client_data);
+ xfree(mapping);
+ }
+ xfree(encoding);
+ }
+ for(i = 0; i < numaliases; i++)
+ xfree(aliases[i]);
+ /* We don't need to free sn and sm as they handled locally in the body.*/
+ return 0;
+}
+
+char*
+FontEncDirectory()
+{
+ static char* dir = NULL;
+
+ if(dir == NULL) {
+ char *c = getenv("FONT_ENCODINGS_DIRECTORY");
+ if(c) {
+ dir = malloc(strlen(c) + 1);
+ if(!dir)
+ return NULL;
+ strcpy(dir, c);
+ } else {
+ dir = FONT_ENCODINGS_DIRECTORY;
+ }
+ }
+ return dir;
+}
+
+static void
+parseFontFileName(const char *fontFileName, char *buf, char *dir)
+{
+ const char *p;
+ char *q, *lastslash;
+
+ for(p = fontFileName, q = dir, lastslash = NULL; *p; p++, q++) {
+ *q = *p;
+ if(*p == '/')
+ lastslash = q+1;
+ }
+
+ if(!lastslash)
+ lastslash = dir;
+
+ *lastslash = '\0';
+
+ if(buf && strlen(dir) + 14 < MAXFONTFILENAMELEN) {
+ strcpy(buf, dir);
+ strcat(buf, "encodings.dir");
+ }
+}
+
+static FontEncPtr
+FontEncReallyReallyLoad(const char *charset,
+ const char *dirname, const char *dir)
+{
+ FontFilePtr f;
+ FILE *file;
+ FontEncPtr encoding;
+ char file_name[MAXFONTFILENAMELEN], encoding_name[MAXFONTNAMELEN],
+ buf[MAXFONTFILENAMELEN];
+ int count, n;
+ static char format[24] = "";
+
+ /* As we don't really expect to open encodings that often, we don't
+ take the trouble of caching encodings directories. */
+
+ if((file = fopen(dirname, "r")) == NULL) {
+ return NULL;
+ }
+
+ count = fscanf(file, "%d\n", &n);
+ if(count == EOF || count != 1) {
+ fclose(file);
+ return NULL;
+ }
+
+ encoding = NULL;
+ if (!format[0]) {
+ sprintf(format, "%%%ds %%%d[^\n]\n", (int)sizeof(encoding_name) - 1,
+ (int)sizeof(file_name) - 1);
+ }
+ for(;;) {
+ count = fscanf(file, format, encoding_name, file_name);
+ if(count == EOF)
+ break;
+ if(count != 2)
+ break;
+
+ if(!strcasecmp(encoding_name, charset)) {
+ /* Found it */
+ if(file_name[0] != '/') {
+ if(strlen(dir) + strlen(file_name) >= MAXFONTFILENAMELEN) {
+ fclose(file);
+ return NULL;
+ }
+ strcpy(buf, dir);
+ strcat(buf, file_name);
+ } else {
+ strcpy(buf , file_name);
+ }
+
+ f = FontFileOpen(buf);
+ if(f == NULL) {
+ fclose(file);
+ return NULL;
+ }
+ encoding = parseEncodingFile(f, 0);
+ FontFileClose(f);
+ break;
+ }
+ }
+
+ fclose(file);
+
+ return encoding;
+}
+
+/* Parser ntrypoint -- used by FontEncLoad */
+FontEncPtr
+FontEncReallyLoad(const char *charset, const char *fontFileName)
+{
+ FontEncPtr encoding;
+ char dir[MAXFONTFILENAMELEN], dirname[MAXFONTFILENAMELEN];
+ char *d;
+
+ if(fontFileName) {
+ parseFontFileName(fontFileName, dirname, dir);
+ encoding = FontEncReallyReallyLoad(charset, dirname, dir);
+ if(encoding)
+ return(encoding);
+ }
+
+ d = FontEncDirectory();
+ if(d) {
+ parseFontFileName(d, NULL, dir);
+ encoding = FontEncReallyReallyLoad(charset, d, dir);
+ return encoding;
+ }
+
+ return NULL;
+}
+
+/* Return a NULL-terminated array of encoding names. Note that this
+ * function has incestuous knowledge of the allocations done by
+ * parseEncodingFile. */
+
+char **
+FontEncIdentify(const char *fileName)
+{
+ FontFilePtr f;
+ FontEncPtr encoding;
+ char **names, **name, **alias;
+ int numaliases;
+
+ if((f = FontFileOpen(fileName))==NULL) {
+ return NULL;
+ }
+ encoding = parseEncodingFile(f, 1);
+ FontFileClose(f);
+
+ if(!encoding)
+ return NULL;
+
+ numaliases = 0;
+ if(encoding->aliases)
+ for(alias = encoding->aliases; *alias; alias++)
+ numaliases++;
+
+ names = (char**)xalloc((numaliases+2)*sizeof(char*));
+ if(names == NULL) {
+ if(encoding->aliases)
+ xfree(encoding->aliases);
+ xfree(encoding);
+ return NULL;
+ }
+
+ name = names;
+ *(name++) = encoding->name;
+ if(numaliases > 0)
+ for(alias = encoding->aliases; *alias; alias++, name++)
+ *name = *alias;
+
+ *name = 0;
+ xfree(encoding->aliases);
+ xfree(encoding);
+
+ return names;
+}
diff --git a/nx-X11/lib/font/fontfile/encparse.c.X.original b/nx-X11/lib/font/fontfile/encparse.c.X.original
new file mode 100644
index 000000000..285f5a17d
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/encparse.c.X.original
@@ -0,0 +1,963 @@
+/*
+Copyright (c) 1998-2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+
+/* $XFree86: xc/lib/font/fontfile/encparse.c,v 1.20tsi Exp $ */
+
+/* Parser for encoding files */
+
+/* This code assumes that we are using ASCII. We don't use the ctype
+ functions, as they depend on the current locale. On the other
+ hand, we do use strcasecmp, but only on strings that we've checked
+ to be pure ASCII. Bloody ``Code Set Independence''. */
+
+#include <string.h>
+#include <stdio.h>
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#include <strings.h>
+#endif
+
+#ifndef FONTENC_NO_LIBFONT
+
+#include <X11/fonts/fntfilio.h>
+#include <X11/fonts/fntfilst.h>
+
+#else
+
+#include <stdlib.h>
+#define xalloc(n) malloc(n)
+#define xrealloc(p, n) realloc(p, n)
+#define xfree(p) free(p)
+
+#include "zlib.h"
+typedef gzFile FontFilePtr;
+#define FontFileGetc(f) gzgetc(f)
+#define FontFileOpen(filename) gzopen(filename, "rb")
+#define FontFileClose(f) gzclose(f)
+
+#define MAXFONTFILENAMELEN 1024
+#define MAXFONTNAMELEN 1024
+
+#endif
+
+#include <X11/fonts/fontenc.h>
+#include "fontencI.h"
+
+#define MAXALIASES 20
+
+#define EOF_TOKEN -1
+#define ERROR_TOKEN -2
+#define EOL_TOKEN 0
+#define NUMBER_TOKEN 1
+#define KEYWORD_TOKEN 2
+
+#define EOF_LINE -1
+#define ERROR_LINE -2
+#define STARTENCODING_LINE 1
+#define STARTMAPPING_LINE 2
+#define ENDMAPPING_LINE 3
+#define CODE_LINE 4
+#define CODE_RANGE_LINE 5
+#define CODE_UNDEFINE_LINE 6
+#define NAME_LINE 7
+#define SIZE_LINE 8
+#define ALIAS_LINE 9
+#define FIRSTINDEX_LINE 10
+
+/* Return from lexer */
+#define MAXKEYWORDLEN 100
+
+static long number_value;
+static char keyword_value[MAXKEYWORDLEN+1];
+
+static long value1, value2, value3;
+
+/* Lexer code */
+
+/* Skip to the beginning of new line */
+static void
+skipEndOfLine(FontFilePtr f, int c)
+{
+ if(c == 0)
+ c = FontFileGetc(f);
+
+ for(;;)
+ if(c <= 0 || c == '\n')
+ return;
+ else
+ c = FontFileGetc(f);
+}
+
+/* Get a number; we're at the first digit. */
+static unsigned
+getnum(FontFilePtr f, int c, int *cp)
+{
+ unsigned n = 0;
+ int base = 10;
+
+ /* look for `0' or `0x' prefix */
+ if(c == '0') {
+ c = FontFileGetc(f);
+ base = 8;
+ if(c == 'x' || c == 'X') {
+ base = 16;
+ c = FontFileGetc(f);
+ }
+ }
+
+ /* accumulate digits */
+ for(;;) {
+ if ('0' <= c && c <= '9') {
+ n *= base; n += c - '0';
+ } else if('a' <= c && c <= 'f') {
+ n *= base; n += c - 'a' + 10;
+ } else if('A' <=c && c <= 'F') {
+ n *= base; n += c - 'A' + 10;
+ } else
+ break;
+ c = FontFileGetc(f);
+ }
+
+ *cp = c; return n;
+}
+
+/* Skip to beginning of new line; return 1 if only whitespace was found. */
+static int
+endOfLine(FontFilePtr f, int c)
+{
+ if(c == 0)
+ c = FontFileGetc(f);
+
+ for(;;) {
+ if(c <= 0 || c == '\n')
+ return 1;
+ else if(c == '#') {
+ skipEndOfLine(f,c);
+ return 1;
+ }
+ else if(c == ' ' || c == '\t') {
+ skipEndOfLine(f,c);
+ return 0;
+ }
+ c = FontFileGetc(f);
+ }
+}
+
+/* Get a token; we're at first char */
+static int
+gettoken(FontFilePtr f, int c, int *cp)
+{
+ char *p;
+
+ if(c <= 0)
+ c = FontFileGetc(f);
+
+ if(c <= 0) {
+ return EOF_TOKEN;
+ }
+
+ while(c == ' ' || c == '\t')
+ c = FontFileGetc(f);
+
+ if(c=='\n') {
+ return EOL_TOKEN;
+ } else if(c == '#') {
+ skipEndOfLine(f,c);
+ return EOL_TOKEN;
+ } else if(c >= '0' && c <= '9') {
+ number_value = getnum(f,c,cp);
+ return NUMBER_TOKEN;
+ } else if((c >= 'A' && c <= 'Z') ||
+ (c >= 'a' && c <= 'z') ||
+ c == '/' || c == '_' || c == '-' || c == '.') {
+ p = keyword_value;
+ *p++ = c;
+ while(p-keyword_value < MAXKEYWORDLEN) {
+ c = FontFileGetc(f);
+ if(c <= ' ' || c > '~' || c == '#')
+ break;
+ *p++ = c;
+ }
+ *cp = c;
+ *p = '\0';
+ return KEYWORD_TOKEN;
+ } else {
+ *cp = c;
+ return ERROR_TOKEN;
+ }
+}
+
+/* Parse a line.
+ * Always skips to the beginning of a new line, even if an error occurs */
+static int
+getnextline(FontFilePtr f)
+{
+ int c, token;
+ c = FontFileGetc(f);
+ if(c <= 0)
+ return EOF_LINE;
+
+ again:
+ token=gettoken(f,c,&c);
+
+ switch(token) {
+ case EOF_TOKEN:
+ return EOF_LINE;
+ case EOL_TOKEN:
+ /* empty line */
+ c = FontFileGetc(f);
+ goto again;
+ case NUMBER_TOKEN:
+ value1 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value2 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value3 = number_value;
+ return CODE_RANGE_LINE;
+ case EOL_TOKEN:
+ return CODE_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ case KEYWORD_TOKEN:
+ if(!endOfLine(f,c))
+ return ERROR_LINE;
+ else
+ return NAME_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ case KEYWORD_TOKEN:
+ if(!strcasecmp(keyword_value, "STARTENCODING")) {
+ token = gettoken(f,c,&c);
+ if(token == KEYWORD_TOKEN) {
+ if(endOfLine(f,c))
+ return STARTENCODING_LINE;
+ else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "ALIAS")) {
+ token = gettoken(f,c,&c);
+ if(token == KEYWORD_TOKEN) {
+ if(endOfLine(f,c))
+ return ALIAS_LINE;
+ else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "SIZE")) {
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value1 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value2 = number_value;
+ return SIZE_LINE;
+ case EOL_TOKEN:
+ value2=0;
+ return SIZE_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "FIRSTINDEX")) {
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value1 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value2 = number_value;
+ return FIRSTINDEX_LINE;
+ case EOL_TOKEN:
+ value2 = 0;
+ return FIRSTINDEX_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "STARTMAPPING")) {
+ keyword_value[0] = 0;
+ value1 = 0; value1 = 0;
+ /* first a keyword */
+ token = gettoken(f,c,&c);
+ if(token != KEYWORD_TOKEN) {
+ skipEndOfLine(f, c);
+ return ERROR_LINE;
+ }
+
+ /* optional first integer */
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value1 = number_value;
+ } else if(token == EOL_TOKEN) {
+ return STARTMAPPING_LINE;
+ } else {
+ skipEndOfLine(f, c);
+ return ERROR_LINE;
+ }
+
+ /* optional second integer */
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value2 = number_value;
+ } else if(token == EOL_TOKEN) {
+ return STARTMAPPING_LINE;
+ } else {
+ skipEndOfLine(f, c);
+ return ERROR_LINE;
+ }
+
+ if(!endOfLine(f,c))
+ return ERROR_LINE;
+ else {
+ return STARTMAPPING_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "UNDEFINE")) {
+ /* first integer */
+ token = gettoken(f,c,&c);
+ if(token != NUMBER_TOKEN) {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ value1 = number_value;
+ /* optional second integer */
+ token = gettoken(f,c,&c);
+ if(token == EOL_TOKEN) {
+ value2 = value1;
+ return CODE_UNDEFINE_LINE;
+ } else if(token == NUMBER_TOKEN) {
+ value2 = number_value;
+ if(endOfLine(f,c)) {
+ return CODE_UNDEFINE_LINE;
+ } else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "ENDENCODING")) {
+ if(endOfLine(f,c))
+ return EOF_LINE;
+ else
+ return ERROR_LINE;
+ } else if(!strcasecmp(keyword_value, "ENDMAPPING")) {
+ if(endOfLine(f,c))
+ return ENDMAPPING_LINE;
+ else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ default:
+ return ERROR_LINE;
+ }
+}
+
+static void
+install_mapping(FontEncPtr encoding, FontMapPtr mapping)
+{
+ FontMapPtr m;
+
+ if(encoding->mappings == NULL)
+ encoding->mappings = mapping;
+ else {
+ m = encoding->mappings;
+ while(m->next != NULL)
+ m = m->next;
+ m->next = mapping;
+ }
+ mapping->next = NULL;
+ mapping->encoding = encoding;
+}
+
+static int
+setCode(unsigned from, unsigned to, unsigned row_size,
+ unsigned *first, unsigned *last,
+ unsigned *encsize, unsigned short **enc)
+{
+ unsigned index, i;
+ unsigned short *newenc;
+
+ if(from>0xFFFF)
+ return 0; /* success */
+
+ if(row_size==0)
+ index=from;
+ else {
+ if((value1 & 0xFF) >= row_size)
+ return 0; /* ignore out of range mappings */
+ index = (from>>8) * row_size + (from&0xFF);
+ }
+
+ /* Optimize away useless identity mappings. This is only expected
+ to be useful with linear encodings. */
+ if(index == to && (index < *first || index > *last))
+ return 0;
+ if(*encsize == 0) {
+ *encsize = (index < 256) ? 256 : 0x10000;
+ *enc = (unsigned short*)xalloc((*encsize) * sizeof(unsigned short));
+ if(*enc == NULL) {
+ *encsize = 0;
+ return 1;
+ }
+ } else if(*encsize <= index) {
+ *encsize = 0x10000;
+ if((newenc = (unsigned short*)xrealloc(enc, *encsize))==NULL)
+ return 1;
+ *enc = newenc;
+ }
+ if(*first > *last) {
+ *first = *last = index;
+ }
+ if(index < *first) {
+ for(i = index; i < *first; i++)
+ (*enc)[i] = i;
+ *first = index;
+ }
+ if(index > *last) {
+ for(i = *last + 1; i <= index; i++)
+ (*enc)[i] = i;
+ *last = index;
+ }
+ (*enc)[index] = to;
+ return 0;
+}
+
+/* Parser. If headerOnly is true, we're only interested in the
+ data contained in the encoding file's header. */
+
+/* As font encodings are currently never freed, the allocations done
+ by this function are mostly its private business. Note, however,
+ that FontEncIdentify needs to free the header fields -- so if you
+ change this function, you may need to change FontEncIdentify. */
+
+/* I want a garbage collector. */
+
+static FontEncPtr
+parseEncodingFile(FontFilePtr f, int headerOnly)
+{
+ int line;
+
+ unsigned short *enc=NULL;
+ char **nam = NULL, **newnam;
+ unsigned i, first = 0xFFFF, last=0, encsize=0, namsize=0;
+ FontEncPtr encoding = NULL;
+ FontMapPtr mapping = NULL;
+ FontEncSimpleMapPtr sm;
+ FontEncSimpleNamePtr sn;
+ char *aliases[MAXALIASES];
+ int numaliases=0;
+
+#if 0
+ /* GCC complains about unused labels. Please fix GCC rather than
+ obfuscating my code. */
+ no_encoding:
+#endif
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE:
+ goto error;
+ case STARTENCODING_LINE:
+ encoding = (FontEncPtr)xalloc(sizeof(FontEncRec));
+ if(encoding == NULL)
+ goto error;
+ encoding->name = (char*)xalloc(strlen(keyword_value)+1);
+ if(encoding->name == NULL)
+ goto error;
+ strcpy(encoding->name, keyword_value);
+ encoding->size = 256;
+ encoding->row_size = 0;
+ encoding->mappings = NULL;
+ encoding->next = NULL;
+ encoding->first = encoding->first_col=0;
+ goto no_mapping;
+ default:
+ goto error;
+ }
+
+ no_mapping:
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE: goto done;
+ case ALIAS_LINE:
+ if(numaliases < MAXALIASES) {
+ aliases[numaliases] = (char*)xalloc(strlen(keyword_value)+1);
+ if(aliases[numaliases] == NULL)
+ goto error;
+ strcpy(aliases[numaliases], keyword_value);
+ numaliases++;
+ }
+ goto no_mapping;
+ case SIZE_LINE:
+ encoding->size = value1;
+ encoding->row_size = value2;
+ goto no_mapping;
+ case FIRSTINDEX_LINE:
+ encoding->first = value1;
+ encoding->first_col = value2;
+ goto no_mapping;
+ case STARTMAPPING_LINE:
+ if(headerOnly)
+ goto done;
+ if(!strcasecmp(keyword_value, "unicode")) {
+ mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
+ if(mapping == NULL)
+ goto error;
+ mapping->type = FONT_ENCODING_UNICODE;
+ mapping->pid = 0;
+ mapping->eid = 0;
+ mapping->recode = 0;
+ mapping->name = 0;
+ mapping->client_data = 0;
+ mapping->next = 0;
+ goto mapping;
+ } else if(!strcasecmp(keyword_value, "cmap")) {
+ mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
+ if(mapping == NULL)
+ goto error;
+ mapping->type = FONT_ENCODING_TRUETYPE;
+ mapping->pid = value1;
+ mapping->eid = value2;
+ mapping->recode = 0;
+ mapping->name = 0;
+ mapping->client_data = 0;
+ mapping->next = 0;
+ goto mapping;
+ } else if(!strcasecmp(keyword_value, "postscript")) {
+ mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
+ if(mapping == NULL)
+ goto error;
+ mapping->type = FONT_ENCODING_POSTSCRIPT;
+ mapping->pid = 0;
+ mapping->eid = 0;
+ mapping->recode = 0;
+ mapping->name = 0;
+ mapping->client_data = 0;
+ mapping->next = 0;
+ goto string_mapping;
+ } else { /* unknown mapping type -- ignore */
+ goto skipmapping;
+ }
+ /* NOTREACHED */
+ goto error;
+ default: goto no_mapping; /* ignore unknown lines */
+ }
+
+ skipmapping:
+ line = getnextline(f);
+ switch(line) {
+ case ENDMAPPING_LINE:
+ goto no_mapping;
+ case EOF_LINE:
+ goto error;
+ default:
+ goto skipmapping;
+ }
+
+ mapping:
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE: goto error;
+ case ENDMAPPING_LINE:
+ mapping->recode = FontEncSimpleRecode;
+ mapping->name = FontEncUndefinedName;
+ mapping->client_data = sm =
+ (FontEncSimpleMapPtr)xalloc(sizeof(FontEncSimpleMapRec));
+ if(sm == NULL)
+ goto error;
+ sm->row_size = encoding->row_size;
+ if(first <= last) {
+ sm->first = first;
+ sm->len=last-first+1;
+ sm->map =
+ (unsigned short*)xalloc(sm->len * sizeof(unsigned short));
+ if(sm->map == NULL) {
+ xfree(sm);
+ mapping->client_data = sm = NULL;
+ goto error;
+ }
+ } else {
+ sm->first = 0;
+ sm->len = 0;
+ sm->map = 0;
+ }
+ for(i=0; i < sm->len; i++)
+ sm -> map[i] = enc[first+i];
+ install_mapping(encoding, mapping);
+ mapping = 0;
+ first = 0xFFFF; last=0;
+ goto no_mapping;
+
+ case CODE_LINE:
+ if(setCode(value1, value2, encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ goto mapping;
+
+ case CODE_RANGE_LINE:
+ if(value1 > 0x10000)
+ value1 = 0x10000;
+ if(value2 > 0x10000)
+ value2 = 0x10000;
+ if(value2 < value1)
+ goto mapping;
+ /* Do the last value first to avoid having to realloc() */
+ if(setCode(value2, value3+(value2-value1), encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ for(i=value1; i<value2; i++) {
+ if(setCode(i, value3+(i-value1), encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ }
+ goto mapping;
+
+ case CODE_UNDEFINE_LINE:
+ if(value1 > 0x10000)
+ value1 = 0x10000;
+ if(value2 > 0x10000)
+ value2 = 0x10000;
+ if(value2 < value1)
+ goto mapping;
+ /* Do the last value first to avoid having to realloc() */
+ if(setCode(value2, 0, encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ for(i = value1; i < value2; i++) {
+ if(setCode(i, 0, encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ }
+ goto mapping;
+
+ default: goto mapping; /* ignore unknown lines */
+ }
+
+ string_mapping:
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE: goto error;
+ case ENDMAPPING_LINE:
+ mapping->recode = FontEncUndefinedRecode;
+ mapping->name = FontEncSimpleName;
+ mapping->client_data = sn =
+ (FontEncSimpleNamePtr)xalloc(sizeof(FontEncSimpleNameRec));
+ if(sn == NULL)
+ goto error;
+ if(first > last) {
+ xfree(sn);
+ mapping->client_data = sn = NULL;
+ goto error;
+ }
+ sn->first = first;
+ sn->len = last - first + 1;
+ sn->map = (char**)xalloc(sn->len*sizeof(char*));
+ if(sn->map == NULL) {
+ xfree(sn);
+ mapping->client_data = sn = NULL;
+ goto error;
+ }
+ for(i = 0; i < sn->len; i++)
+ sn->map[i] = nam[first+i];
+ install_mapping(encoding,mapping);
+ mapping = 0;
+ first = 0xFFFF; last=0;
+ goto no_mapping;
+ case NAME_LINE:
+ if(value1 >= 0x10000) goto string_mapping;
+ if(namsize == 0) {
+ namsize = (value1) < 256 ? 256 : 0x10000;
+ nam = (char**)xalloc(namsize * sizeof(char*));
+ if(nam == NULL) {
+ namsize=0;
+ goto error;
+ }
+ } else if(namsize <= value1) {
+ namsize = 0x10000;
+ if((newnam = (char**)xrealloc(nam, namsize)) == NULL)
+ goto error;
+ nam = newnam;
+ }
+ if(first > last) {
+ first = last = value1;
+ }
+ if(value1 < first) {
+ for(i = value1; i < first; i++)
+ nam[i] = NULL;
+ first = value1;
+ }
+ if(value1 > last) {
+ for(i=last+1; i <= value1; i++)
+ nam[i]=NULL;
+ last = value1;
+ }
+ nam[value1] = (char*)xalloc(strlen(keyword_value)+1);
+ if(nam[value1] == NULL) {
+ goto error;
+ }
+ strcpy(nam[value1], keyword_value);
+ goto string_mapping;
+
+ default: goto string_mapping; /* ignore unknown lines */
+ }
+
+ done:
+ if(encsize) xfree(enc); encsize=0; enc = NULL;
+ if(namsize) xfree(nam); namsize=0; nam = NULL; /* don't free entries! */
+
+ encoding->aliases=NULL;
+ if(numaliases) {
+ encoding->aliases = (char**)xalloc((numaliases+1)*sizeof(char*));
+ if(encoding->aliases == NULL)
+ goto error;
+ for(i=0; i<numaliases; i++)
+ encoding->aliases[i] = aliases[i];
+ encoding->aliases[numaliases]=NULL;
+ }
+
+ return encoding;
+
+error:
+ if(encsize) xfree(enc); encsize=0;
+ if(namsize) {
+ for(i = first; i <= last; i++)
+ if(nam[i])
+ xfree(nam[i]);
+ xfree(nam);
+ namsize = 0;
+ }
+ if(mapping) {
+ if(mapping->client_data) xfree(mapping->client_data);
+ xfree(mapping);
+ }
+ if(encoding) {
+ if(encoding->name) xfree(encoding->name);
+ for(mapping = encoding->mappings; mapping; mapping = mapping->next) {
+ if(mapping->client_data) xfree(mapping->client_data);
+ xfree(mapping);
+ }
+ xfree(encoding);
+ }
+ for(i = 0; i < numaliases; i++)
+ xfree(aliases[i]);
+ /* We don't need to free sn and sm as they handled locally in the body.*/
+ return 0;
+}
+
+char*
+FontEncDirectory()
+{
+ static char* dir = NULL;
+
+ if(dir == NULL) {
+ char *c = getenv("FONT_ENCODINGS_DIRECTORY");
+ if(c) {
+ dir = malloc(strlen(c) + 1);
+ if(!dir)
+ return NULL;
+ strcpy(dir, c);
+ } else {
+ dir = FONT_ENCODINGS_DIRECTORY;
+ }
+ }
+ return dir;
+}
+
+static void
+parseFontFileName(const char *fontFileName, char *buf, char *dir)
+{
+ const char *p;
+ char *q, *lastslash;
+
+ for(p = fontFileName, q = dir, lastslash = NULL; *p; p++, q++) {
+ *q = *p;
+ if(*p == '/')
+ lastslash = q+1;
+ }
+
+ if(!lastslash)
+ lastslash = dir;
+
+ *lastslash = '\0';
+
+ if(buf && strlen(dir) + 14 < MAXFONTFILENAMELEN) {
+ strcpy(buf, dir);
+ strcat(buf, "encodings.dir");
+ }
+}
+
+static FontEncPtr
+FontEncReallyReallyLoad(const char *charset,
+ const char *dirname, const char *dir)
+{
+ FontFilePtr f;
+ FILE *file;
+ FontEncPtr encoding;
+ char file_name[MAXFONTFILENAMELEN], encoding_name[MAXFONTNAMELEN],
+ buf[MAXFONTFILENAMELEN];
+ int count, n;
+ static char format[24] = "";
+
+ /* As we don't really expect to open encodings that often, we don't
+ take the trouble of caching encodings directories. */
+
+ if((file = fopen(dirname, "r")) == NULL) {
+ return NULL;
+ }
+
+ count = fscanf(file, "%d\n", &n);
+ if(count == EOF || count != 1) {
+ fclose(file);
+ return NULL;
+ }
+
+ encoding = NULL;
+ if (!format[0]) {
+ sprintf(format, "%%%ds %%%d[^\n]\n", (int)sizeof(encoding_name) - 1,
+ (int)sizeof(file_name) - 1);
+ }
+ for(;;) {
+ count = fscanf(file, format, encoding_name, file_name);
+ if(count == EOF)
+ break;
+ if(count != 2)
+ break;
+
+ if(!strcasecmp(encoding_name, charset)) {
+ /* Found it */
+ if(file_name[0] != '/') {
+ if(strlen(dir) + strlen(file_name) >= MAXFONTFILENAMELEN)
+ return NULL;
+ strcpy(buf, dir);
+ strcat(buf, file_name);
+ } else {
+ strcpy(buf , file_name);
+ }
+
+ f = FontFileOpen(buf);
+ if(f == NULL) {
+ return NULL;
+ }
+ encoding = parseEncodingFile(f, 0);
+ FontFileClose(f);
+ break;
+ }
+ }
+
+ fclose(file);
+
+ return encoding;
+}
+
+/* Parser ntrypoint -- used by FontEncLoad */
+FontEncPtr
+FontEncReallyLoad(const char *charset, const char *fontFileName)
+{
+ FontEncPtr encoding;
+ char dir[MAXFONTFILENAMELEN], dirname[MAXFONTFILENAMELEN];
+ char *d;
+
+ if(fontFileName) {
+ parseFontFileName(fontFileName, dirname, dir);
+ encoding = FontEncReallyReallyLoad(charset, dirname, dir);
+ if(encoding)
+ return(encoding);
+ }
+
+ d = FontEncDirectory();
+ if(d) {
+ parseFontFileName(d, NULL, dir);
+ encoding = FontEncReallyReallyLoad(charset, d, dir);
+ return encoding;
+ }
+
+ return NULL;
+}
+
+/* Return a NULL-terminated array of encoding names. Note that this
+ * function has incestuous knowledge of the allocations done by
+ * parseEncodingFile. */
+
+char **
+FontEncIdentify(const char *fileName)
+{
+ FontFilePtr f;
+ FontEncPtr encoding;
+ char **names, **name, **alias;
+ int numaliases;
+
+ if((f = FontFileOpen(fileName))==NULL) {
+ return NULL;
+ }
+ encoding = parseEncodingFile(f, 1);
+ FontFileClose(f);
+
+ if(!encoding)
+ return NULL;
+
+ numaliases = 0;
+ if(encoding->aliases)
+ for(alias = encoding->aliases; *alias; alias++)
+ numaliases++;
+
+ names = (char**)xalloc((numaliases+2)*sizeof(char*));
+ if(names == NULL) {
+ if(encoding->aliases)
+ xfree(encoding->aliases);
+ xfree(encoding);
+ return NULL;
+ }
+
+ name = names;
+ *(name++) = encoding->name;
+ if(numaliases > 0)
+ for(alias = encoding->aliases; *alias; alias++, name++)
+ *name = *alias;
+
+ *name = 0;
+ xfree(encoding->aliases);
+ xfree(encoding);
+
+ return names;
+}
diff --git a/nx-X11/lib/font/fontfile/ffcheck.c b/nx-X11/lib/font/fontfile/ffcheck.c
new file mode 100644
index 000000000..9a70a17f9
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/ffcheck.c
@@ -0,0 +1,173 @@
+/* $Xorg: ffcheck.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/ffcheck.c,v 1.15tsi Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $NCDXorg: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/bitmap.h>
+#ifdef LOADABLEFONTS
+#include <X11/fonts/fontmod.h>
+#endif
+
+/*
+ * Map FPE functions to renderer functions
+ */
+
+
+/* Here we must check the client to see if it has a context attached to
+ * it that allows us to access the printer fonts
+ */
+
+static int
+FontFileCheckOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
+ char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *pFont, char **aliasName,
+ FontPtr non_cachable_font)
+{
+ if (XpClientIsBitmapClient(client))
+ return (FontFileOpenFont (client, fpe, flags, name, namelen, format,
+ fmask, id, pFont, aliasName, non_cachable_font));
+ return BadFontName;
+}
+
+static int
+FontFileCheckListFonts (pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max, FontNamesPtr names)
+{
+ if (XpClientIsBitmapClient(client))
+ return FontFileListFonts (client, fpe, pat, len, max, names);
+ return BadFontName;
+}
+
+static int
+FontFileCheckStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ if (XpClientIsBitmapClient(client))
+ return FontFileStartListFontsWithInfo(client, fpe, pat, len,
+ max, privatep);
+ return BadFontName;
+}
+
+static int
+FontFileCheckListNextFontWithInfo(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo,
+ int *numFonts, pointer private)
+{
+ if (XpClientIsBitmapClient(client))
+ return FontFileListNextFontWithInfo(client, fpe, namep, namelenp,
+ pFontInfo, numFonts, private);
+ return BadFontName;
+}
+
+static int
+FontFileCheckStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ if (XpClientIsBitmapClient(client))
+ return FontFileStartListFontsAndAliases(client, fpe, pat, len,
+ max, privatep);
+ return BadFontName;
+}
+
+static int
+FontFileCheckListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ char **resolvedp, int *resolvedlenp,
+ pointer private)
+{
+ if (XpClientIsBitmapClient(client))
+ return FontFileListNextFontOrAlias(client, fpe, namep, namelenp,
+ resolvedp, resolvedlenp, private);
+ return BadFontName;
+}
+
+void
+FontFileCheckRegisterFpeFunctions (void)
+{
+#ifndef LOADABLEFONTS
+ BitmapRegisterFontFileFunctions ();
+
+
+#ifndef CRAY
+#ifdef BUILD_SPEEDO
+ SpeedoRegisterFontFileFunctions ();
+#endif
+#ifdef BUILD_TYPE1
+ Type1RegisterFontFileFunctions();
+#endif
+#endif
+#ifdef BUILD_CID
+ CIDRegisterFontFileFunctions();
+#endif
+#ifdef BUILD_FREETYPE
+ FreeTypeRegisterFontFileFunctions();
+#endif
+
+
+#else
+
+ {
+ int i;
+
+ if (FontModuleList) {
+ for (i = 0; FontModuleList[i].name; i++) {
+ if (FontModuleList[i].initFunc)
+ FontModuleList[i].initFunc();
+ }
+ }
+ }
+#endif
+
+ RegisterFPEFunctions(FontFileNameCheck,
+ FontFileInitFPE,
+ FontFileFreeFPE,
+ FontFileResetFPE,
+ FontFileCheckOpenFont,
+ FontFileCloseFont,
+ FontFileCheckListFonts,
+ FontFileCheckStartListFontsWithInfo,
+ FontFileCheckListNextFontWithInfo,
+ NULL,
+ NULL,
+ NULL,
+ FontFileCheckStartListFontsAndAliases,
+ FontFileCheckListNextFontOrAlias,
+ FontFileEmptyBitmapSource);
+}
diff --git a/nx-X11/lib/font/fontfile/fileio.c b/nx-X11/lib/font/fontfile/fileio.c
new file mode 100644
index 000000000..a3f94640b
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/fileio.c
@@ -0,0 +1,90 @@
+/* $Xorg: fileio.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/fileio.c,v 3.9 2001/12/14 19:56:51 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilio.h>
+#include <X11/Xos.h>
+#ifndef O_BINARY
+#define O_BINARY O_RDONLY
+#endif
+
+FontFilePtr
+FontFileOpen (const char *name)
+{
+ int fd;
+ int len;
+ BufFilePtr raw, cooked;
+
+ fd = open (name, O_BINARY);
+ if (fd < 0)
+ return 0;
+ raw = BufFileOpenRead (fd);
+ if (!raw)
+ {
+ close (fd);
+ return 0;
+ }
+ len = strlen (name);
+#ifndef __UNIXOS2__
+ if (len > 2 && !strcmp (name + len - 2, ".Z")) {
+#else
+ if (len > 2 && (!strcmp (name + len - 4, ".pcz") ||
+ !strcmp (name + len - 2, ".Z"))) {
+#endif
+ cooked = BufFilePushCompressed (raw);
+ if (!cooked) {
+ BufFileClose (raw, TRUE);
+ return 0;
+ }
+ raw = cooked;
+#ifdef X_GZIP_FONT_COMPRESSION
+ } else if (len > 3 && !strcmp (name + len - 3, ".gz")) {
+ cooked = BufFilePushZIP (raw);
+ if (!cooked) {
+ BufFileClose (raw, TRUE);
+ return 0;
+ }
+ raw = cooked;
+#endif
+ }
+ return (FontFilePtr) raw;
+}
+
+int
+FontFileClose (FontFilePtr f)
+{
+ return BufFileClose ((BufFilePtr) f, TRUE);
+}
+
diff --git a/nx-X11/lib/font/fontfile/filewr.c b/nx-X11/lib/font/fontfile/filewr.c
new file mode 100644
index 000000000..d076f166a
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/filewr.c
@@ -0,0 +1,65 @@
+/* $Xorg: filewr.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/filewr.c,v 3.6 2001/12/14 19:56:51 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilio.h>
+#include <X11/Xos.h>
+
+FontFilePtr
+FontFileOpenWrite (const char *name)
+{
+ int fd;
+
+#if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)
+ fd = open (name, O_CREAT|O_TRUNC|O_RDWR|O_BINARY, 0666);
+#else
+ fd = creat (name, 0666);
+#endif
+ if (fd < 0)
+ return 0;
+ return (FontFilePtr) BufFileOpenWrite (fd);
+}
+
+FontFilePtr
+FontFileOpenWriteFd (int fd)
+{
+ return (FontFilePtr) BufFileOpenWrite (fd);
+}
+
+FontFilePtr
+FontFileOpenFd (int fd)
+{
+ return (FontFilePtr) BufFileOpenRead (fd);
+}
diff --git a/nx-X11/lib/font/fontfile/fontdir.c b/nx-X11/lib/font/fontfile/fontdir.c
new file mode 100644
index 000000000..8f75d8bde
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/fontdir.c
@@ -0,0 +1,827 @@
+/* $XdotOrg: xc/lib/font/fontfile/fontdir.c,v 1.6 2005/11/14 20:40:42 ajax Exp $ */
+/* $Xorg: fontdir.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/fontdir.c,v 3.22 2003/07/07 16:40:11 eich Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#include <X11/keysym.h>
+
+#if HAVE_STDINT_H
+#include <stdint.h>
+#elif !defined(INT32_MAX)
+#define INT32_MAX 0x7fffffff
+#endif
+
+Bool
+FontFileInitTable (FontTablePtr table, int size)
+{
+ if (size < 0 || (size > INT32_MAX/sizeof(FontEntryRec)))
+ return FALSE;
+ if (size)
+ {
+ table->entries = (FontEntryPtr) xalloc(sizeof(FontEntryRec) * size);
+ if (!table->entries)
+ return FALSE;
+ }
+ else
+ table->entries = 0;
+ table->used = 0;
+ table->size = size;
+ table->sorted = FALSE;
+ return TRUE;
+}
+
+void
+FontFileFreeEntry (FontEntryPtr entry)
+{
+ FontScalableExtraPtr extra;
+ int i;
+
+ if (entry->name.name)
+ xfree(entry->name.name);
+ entry->name.name = NULL;
+
+ switch (entry->type)
+ {
+ case FONT_ENTRY_SCALABLE:
+ xfree (entry->u.scalable.fileName);
+ extra = entry->u.scalable.extra;
+ for (i = 0; i < extra->numScaled; i++)
+ if (extra->scaled[i].vals.ranges)
+ xfree (extra->scaled[i].vals.ranges);
+ xfree (extra->scaled);
+ xfree (extra);
+ break;
+ case FONT_ENTRY_BITMAP:
+ xfree (entry->u.bitmap.fileName);
+ entry->u.bitmap.fileName = NULL;
+ break;
+ case FONT_ENTRY_ALIAS:
+ xfree (entry->u.alias.resolved);
+ entry->u.alias.resolved = NULL;
+ break;
+#ifdef NOTYET
+ case FONT_ENTRY_BC:
+ break;
+#endif
+ }
+}
+
+void
+FontFileFreeTable (FontTablePtr table)
+{
+ int i;
+
+ for (i = 0; i < table->used; i++)
+ FontFileFreeEntry (&table->entries[i]);
+ xfree (table->entries);
+}
+
+FontDirectoryPtr
+FontFileMakeDir(char *dirName, int size)
+{
+ FontDirectoryPtr dir;
+ int dirlen;
+ int needslash = 0;
+ char *attrib;
+ int attriblen;
+
+#if !defined(__UNIXOS2__) && !defined(WIN32)
+ attrib = strchr(dirName, ':');
+#else
+ /* OS/2 uses the colon in the drive letter descriptor, skip this */
+ attrib = strchr(dirName+2, ':');
+#endif
+ if (attrib) {
+ dirlen = attrib - dirName;
+ attriblen = strlen(attrib);
+ } else {
+ dirlen = strlen(dirName);
+ attriblen = 0;
+ }
+ if (dirName[dirlen - 1] != '/')
+#ifdef NCD
+ if (dirlen) /* leave out slash for builtins */
+#endif
+ needslash = 1;
+ dir = (FontDirectoryPtr) xalloc(sizeof *dir + dirlen + needslash + 1 +
+ (attriblen ? attriblen + 1 : 0));
+ if (!dir)
+ return (FontDirectoryPtr)0;
+ if (!FontFileInitTable (&dir->scalable, 0))
+ {
+ xfree (dir);
+ return (FontDirectoryPtr)0;
+ }
+ if (!FontFileInitTable (&dir->nonScalable, size))
+ {
+ FontFileFreeTable (&dir->scalable);
+ xfree (dir);
+ return (FontDirectoryPtr)0;
+ }
+ dir->directory = (char *) (dir + 1);
+ dir->dir_mtime = 0;
+ dir->alias_mtime = 0;
+ if (attriblen)
+ dir->attributes = dir->directory + dirlen + needslash + 1;
+ else
+ dir->attributes = NULL;
+ strncpy(dir->directory, dirName, dirlen);
+ dir->directory[dirlen] = '\0';
+ if (dir->attributes)
+ strcpy(dir->attributes, attrib);
+ if (needslash)
+ strcat(dir->directory, "/");
+ return dir;
+}
+
+void
+FontFileFreeDir (FontDirectoryPtr dir)
+{
+ FontFileFreeTable (&dir->scalable);
+ FontFileFreeTable (&dir->nonScalable);
+ xfree(dir);
+}
+
+FontEntryPtr
+FontFileAddEntry(FontTablePtr table, FontEntryPtr prototype)
+{
+ FontEntryPtr entry;
+ int newsize;
+
+ /* can't add entries to a sorted table, pointers get broken! */
+ if (table->sorted)
+ return (FontEntryPtr) 0; /* "cannot" happen */
+ if (table->used == table->size) {
+ newsize = table->size + 100;
+ entry = (FontEntryPtr) xrealloc(table->entries,
+ newsize * sizeof(FontEntryRec));
+ if (!entry)
+ return (FontEntryPtr)0;
+ table->size = newsize;
+ table->entries = entry;
+ }
+ entry = &table->entries[table->used];
+ *entry = *prototype;
+ entry->name.name = (char *) xalloc(prototype->name.length + 1);
+ if (!entry->name.name)
+ return (FontEntryPtr)0;
+ memcpy (entry->name.name, prototype->name.name, prototype->name.length);
+ entry->name.name[entry->name.length] = '\0';
+ table->used++;
+ return entry;
+}
+
+/*
+ * Compare two strings just like strcmp, but preserve decimal integer
+ * sorting order, i.e. "2" < "10" or "iso8859-2" < "iso8859-10" <
+ * "iso10646-1". Strings are sorted as if sequences of digits were
+ * prefixed by a length indicator (i.e., does not ignore leading zeroes).
+ *
+ * Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
+ */
+#define Xisdigit(c) ('\060' <= (c) && (c) <= '\071')
+
+static int strcmpn(const char *s1, const char *s2)
+{
+ int digits, predigits = 0;
+ const char *ss1, *ss2;
+
+ while (1) {
+ if (*s1 == 0 && *s2 == 0)
+ return 0;
+ digits = Xisdigit(*s1) && Xisdigit(*s2);
+ if (digits && !predigits) {
+ ss1 = s1;
+ ss2 = s2;
+ while (Xisdigit(*ss1) && Xisdigit(*ss2))
+ ss1++, ss2++;
+ if (!Xisdigit(*ss1) && Xisdigit(*ss2))
+ return -1;
+ if (Xisdigit(*ss1) && !Xisdigit(*ss2))
+ return 1;
+ }
+ if ((unsigned char)*s1 < (unsigned char)*s2)
+ return -1;
+ if ((unsigned char)*s1 > (unsigned char)*s2)
+ return 1;
+ predigits = digits;
+ s1++, s2++;
+ }
+}
+
+
+static int
+FontFileNameCompare(const void* a, const void* b)
+{
+ FontEntryPtr a_name = (FontEntryPtr) a,
+ b_name = (FontEntryPtr) b;
+
+ return strcmpn(a_name->name.name, b_name->name.name);
+}
+
+void
+FontFileSortTable (FontTablePtr table)
+{
+ if (!table->sorted) {
+ qsort((char *) table->entries, table->used, sizeof(FontEntryRec),
+ FontFileNameCompare);
+ table->sorted = TRUE;
+ }
+}
+
+void
+FontFileSortDir(FontDirectoryPtr dir)
+{
+ FontFileSortTable (&dir->scalable);
+ FontFileSortTable (&dir->nonScalable);
+ /* now that the table is fixed in size, swizzle the pointers */
+ FontFileSwitchStringsToBitmapPointers (dir);
+}
+
+/*
+ Given a Font Table, SetupWildMatch() sets up various pointers and state
+ information so the table can be searched for name(s) that match a given
+ fontname pattern -- which may contain wildcards. Under certain
+ circumstances, SetupWildMatch() will find the one table entry that
+ matches the pattern. If those circumstances do not pertain,
+ SetupWildMatch() returns a range within the the table that should be
+ searched for matching name(s). With the information established by
+ SetupWildMatch(), including state information in "private", the
+ PatternMatch() procedure is then used to test names in the range for a
+ match.
+*/
+
+#define isWild(c) ((c) == XK_asterisk || (c) == XK_question)
+#define isDigit(c) (XK_0 <= (c) && (c) <= XK_9)
+
+static int
+SetupWildMatch(FontTablePtr table, FontNamePtr pat,
+ int *leftp, int *rightp, int *privatep)
+{
+ int nDashes;
+ char c;
+ char *t;
+ char *firstWild;
+ char *firstDigit;
+ int first;
+ int center,
+ left,
+ right;
+ int result;
+ char *name;
+
+ name = pat->name;
+ nDashes = pat->ndashes;
+ firstWild = 0;
+ firstDigit = 0;
+ t = name;
+ while ((c = *t++)) {
+ if (isWild(c)) {
+ if (!firstWild)
+ firstWild = t - 1;
+ }
+ if (isDigit(c)) {
+ if (!firstDigit)
+ firstDigit = t - 1;
+ }
+ }
+ left = 0;
+ right = table->used;
+ if (firstWild)
+ *privatep = nDashes;
+ else
+ *privatep = -1;
+ if (!table->sorted) {
+ *leftp = left;
+ *rightp = right;
+ return -1;
+ } else if (firstWild) {
+ if (firstDigit && firstDigit < firstWild)
+ first = firstDigit - name;
+ else
+ first = firstWild - name;
+ while (left < right) {
+ center = (left + right) / 2;
+ result = strncmp(name, table->entries[center].name.name, first);
+ if (result == 0)
+ break;
+ if (result < 0)
+ right = center;
+ else
+ left = center + 1;
+ }
+ *leftp = left;
+ *rightp = right;
+ return -1;
+ } else {
+ while (left < right) {
+ center = (left + right) / 2;
+ result = strcmpn(name, table->entries[center].name.name);
+ if (result == 0)
+ return center;
+ if (result < 0)
+ right = center;
+ else
+ left = center + 1;
+ }
+ *leftp = 1;
+ *rightp = 0;
+ return -1;
+ }
+}
+
+static int
+PatternMatch(char *pat, int patdashes, char *string, int stringdashes)
+{
+ char c,
+ t;
+
+ if (stringdashes < patdashes)
+ return 0;
+ for (;;) {
+ switch (c = *pat++) {
+ case '*':
+ if (!(c = *pat++))
+ return 1;
+ if (c == XK_minus) {
+ patdashes--;
+ for (;;) {
+ while ((t = *string++) != XK_minus)
+ if (!t)
+ return 0;
+ stringdashes--;
+ if (PatternMatch(pat, patdashes, string, stringdashes))
+ return 1;
+ if (stringdashes == patdashes)
+ return 0;
+ }
+ } else {
+ for (;;) {
+ while ((t = *string++) != c) {
+ if (!t)
+ return 0;
+ if (t == XK_minus) {
+ if (stringdashes-- < patdashes)
+ return 0;
+ }
+ }
+ if (PatternMatch(pat, patdashes, string, stringdashes))
+ return 1;
+ }
+ }
+ case '?':
+ if (*string++ == XK_minus)
+ stringdashes--;
+ break;
+ case '\0':
+ return (*string == '\0');
+ case XK_minus:
+ if (*string++ == XK_minus) {
+ patdashes--;
+ stringdashes--;
+ break;
+ }
+ return 0;
+ default:
+ if (c == *string++)
+ break;
+ return 0;
+ }
+ }
+}
+
+int
+FontFileCountDashes (char *name, int namelen)
+{
+ int ndashes = 0;
+
+ while (namelen--)
+ if (*name++ == '\055') /* avoid non ascii systems */
+ ++ndashes;
+ return ndashes;
+}
+
+char *
+FontFileSaveString (char *s)
+{
+ char *n;
+
+ n = (char *) xalloc (strlen (s) + 1);
+ if (!n)
+ return 0;
+ strcpy (n, s);
+ return n;
+}
+
+FontEntryPtr
+FontFileFindNameInScalableDir(FontTablePtr table, FontNamePtr pat,
+ FontScalablePtr vals)
+{
+ int i,
+ start,
+ stop,
+ res,
+ private;
+ FontNamePtr name;
+
+ if ((i = SetupWildMatch(table, pat, &start, &stop, &private)) >= 0)
+ return &table->entries[i];
+ for (i = start; i < stop; i++) {
+ name = &table->entries[i].name;
+ res = PatternMatch(pat->name, private, name->name, name->ndashes);
+ if (res > 0)
+ {
+ /* Check to see if enhancements requested are available */
+ if (vals)
+ {
+ int vs = vals->values_supplied;
+ int cap;
+
+ if (table->entries[i].type == FONT_ENTRY_SCALABLE)
+ cap = table->entries[i].u.scalable.renderer->capabilities;
+ else if (table->entries[i].type == FONT_ENTRY_ALIAS)
+ cap = ~0; /* Calling code will have to see if true */
+ else
+ cap = 0;
+ if ((((vs & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
+ (vs & POINTSIZE_MASK) == POINTSIZE_ARRAY) &&
+ !(cap & CAP_MATRIX)) ||
+ ((vs & CHARSUBSET_SPECIFIED) &&
+ !(cap & CAP_CHARSUBSETTING)))
+ continue;
+ }
+ return &table->entries[i];
+ }
+ if (res < 0)
+ break;
+ }
+ return (FontEntryPtr)0;
+}
+
+FontEntryPtr
+FontFileFindNameInDir(FontTablePtr table, FontNamePtr pat)
+{
+ return FontFileFindNameInScalableDir(table, pat, (FontScalablePtr)0);
+}
+
+int
+FontFileFindNamesInScalableDir(FontTablePtr table, FontNamePtr pat, int max,
+ FontNamesPtr names, FontScalablePtr vals,
+ int alias_behavior, int *newmax)
+{
+ int i,
+ start,
+ stop,
+ res,
+ private;
+ int ret = Successful;
+ FontEntryPtr fname;
+ FontNamePtr name;
+
+ if (max <= 0)
+ return Successful;
+ if ((i = SetupWildMatch(table, pat, &start, &stop, &private)) >= 0) {
+ if (alias_behavior == NORMAL_ALIAS_BEHAVIOR ||
+ table->entries[i].type != FONT_ENTRY_ALIAS)
+ {
+ name = &table->entries[i].name;
+ if (newmax) *newmax = max - 1;
+ return AddFontNamesName(names, name->name, name->length);
+ }
+ start = i;
+ stop = i + 1;
+ }
+ for (i = start, fname = &table->entries[start]; i < stop; i++, fname++) {
+ res = PatternMatch(pat->name, private, fname->name.name, fname->name.ndashes);
+ if (res > 0) {
+ if (vals)
+ {
+ int vs = vals->values_supplied;
+ int cap;
+
+ if (fname->type == FONT_ENTRY_SCALABLE)
+ cap = fname->u.scalable.renderer->capabilities;
+ else if (fname->type == FONT_ENTRY_ALIAS)
+ cap = ~0; /* Calling code will have to see if true */
+ else
+ cap = 0;
+ if ((((vs & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
+ (vs & POINTSIZE_MASK) == POINTSIZE_ARRAY) &&
+ !(cap & CAP_MATRIX)) ||
+ ((vs & CHARSUBSET_SPECIFIED) &&
+ !(cap & CAP_CHARSUBSETTING)))
+ continue;
+ }
+
+ if ((alias_behavior & IGNORE_SCALABLE_ALIASES) &&
+ fname->type == FONT_ENTRY_ALIAS)
+ {
+ FontScalableRec tmpvals;
+ if (FontParseXLFDName (fname->name.name, &tmpvals,
+ FONT_XLFD_REPLACE_NONE) &&
+ !(tmpvals.values_supplied & SIZE_SPECIFY_MASK))
+ continue;
+ }
+
+ ret = AddFontNamesName(names, fname->name.name, fname->name.length);
+ if (ret != Successful)
+ goto bail;
+
+ /* If alias_behavior is LIST_ALIASES_AND_TARGET_NAMES, mark
+ this entry as an alias by negating its length and follow
+ it by the resolved name */
+ if ((alias_behavior & LIST_ALIASES_AND_TARGET_NAMES) &&
+ fname->type == FONT_ENTRY_ALIAS)
+ {
+ names->length[names->nnames - 1] =
+ -names->length[names->nnames - 1];
+ ret = AddFontNamesName(names, fname->u.alias.resolved,
+ strlen(fname->u.alias.resolved));
+ if (ret != Successful)
+ goto bail;
+ }
+
+ if (--max <= 0)
+ break;
+ } else if (res < 0)
+ break;
+ }
+ bail: ;
+ if (newmax) *newmax = max;
+ return ret;
+}
+
+int
+FontFileFindNamesInDir(FontTablePtr table, FontNamePtr pat,
+ int max, FontNamesPtr names)
+{
+ return FontFileFindNamesInScalableDir(table, pat, max, names,
+ (FontScalablePtr)0,
+ NORMAL_ALIAS_BEHAVIOR, (int *)0);
+}
+
+Bool
+FontFileMatchName(char *name, int length, FontNamePtr pat)
+{
+ /* Perform a fontfile-type name match on a single name */
+ FontTableRec table;
+ FontEntryRec entries[1];
+
+ /* Dummy up a table */
+ table.used = 1;
+ table.size = 1;
+ table.sorted = TRUE;
+ table.entries = entries;
+ entries[0].name.name = name;
+ entries[0].name.length = length;
+ entries[0].name.ndashes = FontFileCountDashes(name, length);
+
+ return FontFileFindNameInDir(&table, pat) != (FontEntryPtr)0;
+}
+
+/*
+ * Add a font file to a directory. This handles bitmap and
+ * scalable names both
+ */
+
+Bool
+FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
+{
+ FontEntryRec entry;
+ FontScalableRec vals, zeroVals;
+ FontRendererPtr renderer;
+ FontEntryPtr existing;
+ FontScalableExtraPtr extra;
+ FontEntryPtr bitmap = 0, scalable;
+ Bool isscale;
+ Bool scalable_xlfd;
+
+ renderer = FontFileMatchRenderer (fileName);
+ if (!renderer)
+ return FALSE;
+ entry.name.length = strlen (fontName);
+ if (entry.name.length > MAXFONTNAMELEN)
+ entry.name.length = MAXFONTNAMELEN;
+ entry.name.name = fontName;
+ CopyISOLatin1Lowered (entry.name.name, fontName, entry.name.length);
+ entry.name.ndashes = FontFileCountDashes (entry.name.name, entry.name.length);
+ entry.name.name[entry.name.length] = '\0';
+ /*
+ * Add a bitmap name if the incoming name isn't an XLFD name, or
+ * if it isn't a scalable name (i.e. non-zero scalable fields)
+ *
+ * If name of bitmapped font contains XLFD enhancements, do not add
+ * a scalable version of the name... this can lead to confusion and
+ * ambiguity between the font name and the field enhancements.
+ */
+ isscale = entry.name.ndashes == 14 &&
+ FontParseXLFDName(entry.name.name,
+ &vals, FONT_XLFD_REPLACE_NONE) &&
+ (vals.values_supplied & PIXELSIZE_MASK) != PIXELSIZE_ARRAY &&
+ (vals.values_supplied & POINTSIZE_MASK) != POINTSIZE_ARRAY &&
+ !(vals.values_supplied & ENHANCEMENT_SPECIFY_MASK);
+#define UNSCALED_ATTRIB "unscaled"
+ scalable_xlfd = (isscale &&
+ (((vals.values_supplied & PIXELSIZE_MASK) == 0) ||
+ ((vals.values_supplied & POINTSIZE_MASK) == 0)));
+ /*
+ * For scalable fonts without a scalable XFLD, check if the "unscaled"
+ * attribute is present.
+ */
+ if (isscale && !scalable_xlfd &&
+ dir->attributes && dir->attributes[0] == ':') {
+ char *ptr1 = dir->attributes + 1;
+ char *ptr2;
+ int length;
+ int uslength = strlen(UNSCALED_ATTRIB);
+
+ do {
+ ptr2 = strchr(ptr1, ':');
+ if (ptr2)
+ length = ptr2 - ptr1;
+ else
+ length = dir->attributes + strlen(dir->attributes) - ptr1;
+ if (length == uslength && !strncmp(ptr1, UNSCALED_ATTRIB, uslength))
+ isscale = FALSE;
+ if (ptr2)
+ ptr1 = ptr2 + 1;
+ } while (ptr2);
+ }
+ if (!isscale || (vals.values_supplied & SIZE_SPECIFY_MASK))
+ {
+ /*
+ * If the renderer doesn't support OpenBitmap, FontFileOpenFont
+ * will still do the right thing.
+ */
+ entry.type = FONT_ENTRY_BITMAP;
+ entry.u.bitmap.renderer = renderer;
+ entry.u.bitmap.pFont = NullFont;
+ if (!(entry.u.bitmap.fileName = FontFileSaveString (fileName)))
+ return FALSE;
+ if (!(bitmap = FontFileAddEntry (&dir->nonScalable, &entry)))
+ {
+ xfree (entry.u.bitmap.fileName);
+ return FALSE;
+ }
+ }
+ /*
+ * Parse out scalable fields from XLFD names - a scalable name
+ * just gets inserted, a scaled name has more things to do.
+ */
+ if (isscale)
+ {
+ if (vals.values_supplied & SIZE_SPECIFY_MASK)
+ {
+ bzero((char *)&zeroVals, sizeof(zeroVals));
+ zeroVals.x = vals.x;
+ zeroVals.y = vals.y;
+ zeroVals.values_supplied = PIXELSIZE_SCALAR | POINTSIZE_SCALAR;
+ FontParseXLFDName (entry.name.name, &zeroVals,
+ FONT_XLFD_REPLACE_VALUE);
+ entry.name.length = strlen (entry.name.name);
+ existing = FontFileFindNameInDir (&dir->scalable, &entry.name);
+ if (existing)
+ {
+ if ((vals.values_supplied & POINTSIZE_MASK) ==
+ POINTSIZE_SCALAR &&
+ (int)(vals.point_matrix[3] * 10) == GetDefaultPointSize())
+ {
+ existing->u.scalable.extra->defaults = vals;
+
+ xfree (existing->u.scalable.fileName);
+ if (!(existing->u.scalable.fileName = FontFileSaveString (fileName)))
+ return FALSE;
+ }
+ if(bitmap)
+ {
+ FontFileCompleteXLFD(&vals, &vals);
+ FontFileAddScaledInstance (existing, &vals, NullFont,
+ bitmap->name.name);
+ return TRUE;
+ }
+ }
+ }
+ if (!(entry.u.scalable.fileName = FontFileSaveString (fileName)))
+ return FALSE;
+ extra = (FontScalableExtraPtr) xalloc (sizeof (FontScalableExtraRec));
+ if (!extra)
+ {
+ xfree (entry.u.scalable.fileName);
+ return FALSE;
+ }
+ bzero((char *)&extra->defaults, sizeof(extra->defaults));
+ if ((vals.values_supplied & POINTSIZE_MASK) == POINTSIZE_SCALAR &&
+ (int)(vals.point_matrix[3] * 10) == GetDefaultPointSize())
+ extra->defaults = vals;
+ else
+ {
+ FontResolutionPtr resolution;
+ int num;
+
+ extra->defaults.point_matrix[0] =
+ extra->defaults.point_matrix[3] =
+ (double)GetDefaultPointSize() / 10.0;
+ extra->defaults.point_matrix[1] =
+ extra->defaults.point_matrix[2] = 0.0;
+ extra->defaults.values_supplied =
+ POINTSIZE_SCALAR | PIXELSIZE_UNDEFINED;
+ extra->defaults.width = -1;
+ if (vals.x <= 0 || vals.y <= 0)
+ {
+ resolution = GetClientResolutions (&num);
+ if (resolution && num > 0)
+ {
+ extra->defaults.x = resolution->x_resolution;
+ extra->defaults.y = resolution->y_resolution;
+ }
+ else
+ {
+ extra->defaults.x = 75;
+ extra->defaults.y = 75;
+ }
+ }
+ else
+ {
+ extra->defaults.x = vals.x;
+ extra->defaults.y = vals.y;
+ }
+ FontFileCompleteXLFD (&extra->defaults, &extra->defaults);
+ }
+ extra->numScaled = 0;
+ extra->sizeScaled = 0;
+ extra->scaled = 0;
+ extra->private = 0;
+ entry.type = FONT_ENTRY_SCALABLE;
+ entry.u.scalable.renderer = renderer;
+ entry.u.scalable.extra = extra;
+ if (!(scalable = FontFileAddEntry (&dir->scalable, &entry)))
+ {
+ xfree (extra);
+ xfree (entry.u.scalable.fileName);
+ return FALSE;
+ }
+ if (vals.values_supplied & SIZE_SPECIFY_MASK)
+ {
+ if(bitmap)
+ {
+ FontFileCompleteXLFD(&vals, &vals);
+ FontFileAddScaledInstance (scalable, &vals, NullFont,
+ bitmap->name.name);
+ }
+ }
+ }
+ return TRUE;
+}
+
+Bool
+FontFileAddFontAlias (FontDirectoryPtr dir, char *aliasName, char *fontName)
+{
+ FontEntryRec entry;
+
+ entry.name.length = strlen (aliasName);
+ CopyISOLatin1Lowered (aliasName, aliasName, entry.name.length);
+ entry.name.name = aliasName;
+ entry.name.ndashes = FontFileCountDashes (entry.name.name, entry.name.length);
+ entry.type = FONT_ENTRY_ALIAS;
+ if (!(entry.u.alias.resolved = FontFileSaveString (fontName)))
+ return FALSE;
+ if (!FontFileAddEntry (&dir->nonScalable, &entry))
+ {
+ xfree (entry.u.alias.resolved);
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/nx-X11/lib/font/fontfile/fontenc.c b/nx-X11/lib/font/fontfile/fontenc.c
new file mode 100644
index 000000000..e96cdde26
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/fontenc.c
@@ -0,0 +1,952 @@
+/*
+Copyright (c) 1998-2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+
+/* $XdotOrg: xc/lib/font/fontfile/fontenc.c,v 1.5 2005/11/08 06:33:26 jkj Exp $ */
+/* $XFree86: xc/lib/font/fontfile/fontenc.c,v 1.15 2003/02/20 03:25:19 dawes Exp $ */
+
+/* Backend-independent encoding code */
+
+#include <string.h>
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#include <strings.h>
+#endif
+
+#ifndef FONTENC_NO_LIBFONT
+
+#include <X11/fonts/fontmisc.h> /* defines xalloc and friends */
+#include <X11/fonts/fntfilst.h>
+
+#else
+
+#include <stdlib.h>
+#define xalloc(n) malloc(n)
+#define xrealloc(p, n) realloc(p, n)
+#define xfree(p) free(p)
+#define FALSE 0
+#define TRUE 1
+#define MAXFONTNAMELEN 1024
+#define MAXFONTFILENAMELEN 1024
+
+#endif /* FONTENC_NO_FONTFILE */
+
+#include <X11/fonts/fontenc.h>
+#include "fontencI.h"
+
+/* Functions local to this file */
+
+static FontEncPtr FontEncLoad(const char*, const char*);
+
+/* Early versions of this code only knew about hardwired encodings,
+ hence the following data. Now that the code knows how to load an
+ encoding from a file, most of these tables could go away. */
+
+/* At any rate, no new hardcoded encodings will be added. */
+
+static FontMapRec iso10646[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+/* Notice that the Apple encodings do not have all the characters in
+ the corresponding ISO 8859, and therefore the table has some holes.
+ There's not much more we can do with fonts without a Unicode cmap
+ unless we are willing to combine cmaps (which we are not). */
+
+static unsigned short
+iso8859_1_apple_roman[]=
+{ 0xCA, 0xC1, 0xA2, 0xA3, 0xDB, 0xB4, 0x00, 0xA4,
+ 0xAC, 0xA9, 0xBB, 0xC7, 0xC2, 0x00, 0xA8, 0xF8,
+ 0xA1, 0xB1, 0x00, 0x00, 0xAB, 0xB5, 0xA6, 0xE1,
+ 0xFC, 0x00, 0xBC, 0xC8, 0x00, 0x00, 0x00, 0xC0,
+ 0xCB, 0xE7, 0xE5, 0xCC, 0x80, 0x81, 0xAE, 0x82,
+ 0xE9, 0x83, 0xE6, 0xE8, 0xED, 0xEA, 0xEB, 0xEC,
+ 0x00, 0x84, 0xF1, 0xEE, 0xEF, 0xCD, 0x85, 0x00,
+ 0xAF, 0xF4, 0xF2, 0xF3, 0x86, 0x00, 0x00, 0xA7,
+ 0x88, 0x87, 0x89, 0x8B, 0x8A, 0x8C, 0xBE, 0x8D,
+ 0x8F, 0x8E, 0x90, 0x91, 0x93, 0x92, 0x94, 0x95,
+ 0x00, 0x96, 0x98, 0x97, 0x99, 0x9B, 0x9A, 0xD6,
+ 0xBF, 0x9D, 0x9C, 0x9E, 0x9F, 0x00, 0x00, 0xD8 };
+
+/* Cannot use simple_recode because need to eliminate 0x80<=code<0xA0 */
+static unsigned
+iso8859_1_to_apple_roman(unsigned isocode, void *client_data)
+{
+ if(isocode<=0x80)
+ return isocode;
+ else if(isocode>=0xA0)
+ return iso8859_1_apple_roman[isocode-0xA0];
+ else
+ return 0;
+}
+
+static FontMapRec iso8859_1[]=
+{
+ {FONT_ENCODING_TRUETYPE,2,2,0,0,0,0}, /* ISO 8859-1 */
+ {FONT_ENCODING_UNICODE,0,0,0,0,0,0}, /* ISO 8859-1 coincides with Unicode*/
+ {FONT_ENCODING_TRUETYPE,1,0,iso8859_1_to_apple_roman,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+static unsigned short iso8859_2_tophalf[]=
+{ 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7,
+ 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B,
+ 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7,
+ 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C,
+ 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
+ 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
+ 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
+ 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
+ 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
+ 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
+ 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
+ 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9 };
+
+static FontEncSimpleMapRec iso8859_2_to_unicode_map=
+{0x60, 0, 0xA0, iso8859_2_tophalf };
+
+static unsigned short iso8859_2_apple_centeuro[]=
+{ 0xCA, 0x84, 0x00, 0xFC, 0x00, 0xBB, 0xE5, 0xA4,
+ 0xAC, 0xE1, 0x00, 0xE8, 0x8F, 0x00, 0xEB, 0xFB,
+ 0xA1, 0x88, 0x00, 0xB8, 0x00, 0xBC, 0xE6, 0xFF,
+ 0x00, 0xE4, 0x00, 0xE9, 0x90, 0x00, 0xEC, 0xFD,
+ 0xD9, 0xE7, 0x00, 0x00, 0x80, 0xBD, 0x8C, 0x00,
+ 0x89, 0x83, 0xA2, 0x00, 0x9D, 0xEA, 0x00, 0x91,
+ 0x00, 0xC1, 0xC5, 0xEE, 0xEF, 0xCC, 0x85, 0x00,
+ 0xDB, 0xF1, 0xF2, 0xF4, 0x86, 0xF8, 0x00, 0xA7,
+ 0xDA, 0x87, 0x00, 0x00, 0x8A, 0xBE, 0x8D, 0x00,
+ 0x8B, 0x8E, 0xAB, 0x00, 0x9E, 0x92, 0x00, 0x93,
+ 0x00, 0xC4, 0xCB, 0x97, 0x99, 0xCE, 0x9A, 0xD6,
+ 0xDE, 0xF3, 0x9C, 0xF5, 0x9F, 0xF9, 0x00, 0x00 };
+
+static unsigned
+iso8859_2_to_apple_centeuro(unsigned isocode, void *client_data)
+{
+ if(isocode<=0x80)
+ return isocode;
+ else if(isocode>=0xA0)
+ return iso8859_2_apple_centeuro[isocode-0xA0];
+ else
+ return 0;
+}
+
+
+static FontMapRec iso8859_2[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,
+ FontEncSimpleRecode,0,&iso8859_2_to_unicode_map,0},
+ {FONT_ENCODING_TRUETYPE,1,29,iso8859_2_to_apple_centeuro,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+static unsigned short iso8859_3_tophalf[]=
+{ 0x00A0, 0x0126, 0x02D8, 0x00A3, 0x00A4, 0x0000, 0x0124, 0x00A7,
+ 0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, 0x0000, 0x017B,
+ 0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7,
+ 0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, 0x0000, 0x017C,
+ 0x00C0, 0x00C1, 0x00C2, 0x0000, 0x00C4, 0x010A, 0x0108, 0x00C7,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+ 0x0000, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x0120, 0x00D6, 0x00D7,
+ 0x011C, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x016C, 0x015C, 0x00DF,
+ 0x00E0, 0x00E1, 0x00E2, 0x0000, 0x00E4, 0x010B, 0x0109, 0x00E7,
+ 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+ 0x0000, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7,
+ 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9};
+
+static FontEncSimpleMapRec iso8859_3_to_unicode_map=
+{ 0x60, 0, 0xA0, iso8859_3_tophalf };
+
+static FontMapRec iso8859_3[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,
+ FontEncSimpleRecode,0,&iso8859_3_to_unicode_map,0},
+ {0,0,0,0,0,0,0}
+};
+
+
+static unsigned short iso8859_4_tophalf[]=
+{ 0x00A0, 0x0104, 0x0138, 0x0156, 0x00A4, 0x0128, 0x013B, 0x00A7,
+ 0x00A8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00AD, 0x017D, 0x00AF,
+ 0x00B0, 0x0105, 0x02DB, 0x0157, 0x00B4, 0x0129, 0x013C, 0x02C7,
+ 0x00B8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014A, 0x017E, 0x014B,
+ 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E,
+ 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x012A,
+ 0x0110, 0x0145, 0x014C, 0x0136, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+ 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x0168, 0x016A, 0x00DF,
+ 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F,
+ 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x012B,
+ 0x0111, 0x0146, 0x014D, 0x0137, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
+ 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x0169, 0x016B, 0x02D9,
+};
+
+static FontEncSimpleMapRec iso8859_4_to_unicode_map=
+{ 0x60, 0, 0xA0, iso8859_4_tophalf };
+
+static FontMapRec iso8859_4[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,0,
+ &iso8859_4_to_unicode_map,0},
+ {0,0,0,0,0,0,0}
+};
+
+static unsigned short iso8859_5_tophalf[]=
+{ 0x00A0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00AD, 0x040E, 0x040F,
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+ 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
+ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+ 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+ 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
+ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+ 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
+ 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00A7, 0x045E, 0x045F};
+
+static FontEncSimpleMapRec iso8859_5_to_unicode_map=
+{ 0x60, 0, 0xA0, iso8859_5_tophalf };
+
+static unsigned short
+iso8859_5_apple_cyrillic[]=
+{ 0xCA, 0xDD, 0xAB, 0xAE, 0xB8, 0xC1, 0xA7, 0xBA,
+ 0xB7, 0xBC, 0xBE, 0xCB, 0xCD, 0x00, 0xD8, 0xDA,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
+ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+ 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
+ 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
+ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
+ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
+ 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xDF,
+ 0xDC, 0xDE, 0xAC, 0xAF, 0xB9, 0xCF, 0xB4, 0xBB,
+ 0xC0, 0xBD, 0xBF, 0xCC, 0xCE, 0xA4, 0xD9, 0xDB };
+
+static unsigned
+iso8859_5_to_apple_cyrillic(unsigned isocode, void *client_data)
+{
+ if(isocode<=0x80)
+ return isocode;
+ else if(isocode>=0xA0)
+ return iso8859_5_apple_cyrillic[isocode-0x80];
+ else return 0;
+}
+
+static FontMapRec iso8859_5[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,0,
+ &iso8859_5_to_unicode_map,0},
+ {FONT_ENCODING_TRUETYPE,1,7,iso8859_5_to_apple_cyrillic,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+/* ISO 8859-6 seems useless for serving fonts (not enough presentation
+ * forms). What do Arabic-speakers use? */
+
+static unsigned
+iso8859_6_to_unicode(unsigned isocode, void *client_data)
+{
+ if(isocode<=0xA0 || isocode==0xA4 || isocode==0xAD)
+ return isocode;
+ else if(isocode==0xAC || isocode==0xBB ||
+ (isocode>=0xBF && isocode<=0xDA) ||
+ (isocode>=0xE0 && isocode<=0xEF) ||
+ (isocode>=0xF0 && isocode<=0xF2))
+ return isocode-0xA0+0x0600;
+ else
+ return 0;
+}
+
+static FontMapRec iso8859_6[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,iso8859_6_to_unicode,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+static unsigned
+iso8859_7_to_unicode(unsigned isocode, void *client_data)
+{
+ if(isocode<=0xA0 ||
+ (isocode>=0xA3 && isocode<=0xAD) ||
+ (isocode>=0xB0 && isocode<=0xB3) ||
+ isocode==0xB7 || isocode==0xBB || isocode==0xBD)
+ return isocode;
+ else if(isocode==0xA1)
+ return 0x02BD;
+ else if(isocode==0xA2)
+ return 0x02BC;
+ else if(isocode==0xAF)
+ return 0x2015;
+ else if(isocode>=0xB4)
+ return isocode-0xA0+0x0370;
+ else
+ return 0;
+}
+
+static FontMapRec iso8859_7[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,iso8859_7_to_unicode,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+static unsigned
+iso8859_8_to_unicode(unsigned isocode, void *client_data)
+{
+ if(isocode==0xA1)
+ return 0;
+ else if(isocode<0xBF)
+ return isocode;
+ else if(isocode==0xDF)
+ return 0x2017;
+ else if(isocode>=0xE0 && isocode<=0xFA)
+ return isocode+0x04F0;
+ else
+ return 0;
+}
+
+static FontMapRec iso8859_8[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,iso8859_8_to_unicode,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+static unsigned
+iso8859_9_to_unicode(unsigned isocode, void *client_data)
+{
+ switch(isocode) {
+ case 0xD0: return 0x011E;
+ case 0xDD: return 0x0130;
+ case 0xDE: return 0x015E;
+ case 0xF0: return 0x011F;
+ case 0xFD: return 0x0131;
+ case 0xFE: return 0x015F;
+ default: return isocode;
+ }
+}
+
+static FontMapRec iso8859_9[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,iso8859_9_to_unicode,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+static unsigned short iso8859_10_tophalf[]=
+{ 0x00A0, 0x0104, 0x0112, 0x0122, 0x012A, 0x0128, 0x0136, 0x00A7,
+ 0x013B, 0x0110, 0x0160, 0x0166, 0x017D, 0x00AD, 0x016A, 0x014A,
+ 0x00B0, 0x0105, 0x0113, 0x0123, 0x012B, 0x0129, 0x0137, 0x00B7,
+ 0x013C, 0x0111, 0x0161, 0x0167, 0x017E, 0x2014, 0x016B, 0x014B,
+ 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E,
+ 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x00CF,
+ 0x00D0, 0x0145, 0x014C, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x0168,
+ 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
+ 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F,
+ 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x00EF,
+ 0x00F0, 0x0146, 0x014D, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x0169,
+ 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x0138};
+
+static FontEncSimpleMapRec iso8859_10_to_unicode_map=
+{ 0x60, 0, 0xA0, iso8859_10_tophalf };
+
+static FontMapRec iso8859_10[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,0,
+ &iso8859_10_to_unicode_map,0},
+ {0,0,0,0,0,0,0}
+};
+
+static unsigned
+iso8859_15_to_unicode(unsigned isocode, void *client_data)
+{
+ switch(isocode) {
+ case 0xA4: return 0x20AC;
+ case 0xA6: return 0x0160;
+ case 0xA8: return 0x0161;
+ case 0xB4: return 0x017D;
+ case 0xB8: return 0x017E;
+ case 0xBC: return 0x0152;
+ case 0xBD: return 0x0153;
+ case 0xBE: return 0x0178;
+ default: return isocode;
+ }
+}
+
+static FontMapRec iso8859_15[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,iso8859_15_to_unicode,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+static unsigned short koi8_r_tophalf[]=
+{ 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
+ 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
+ 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2022, 0x221A, 0x2248,
+ 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7,
+ 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556,
+ 0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E,
+ 0x255F, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565,
+ 0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x00A9,
+ 0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
+ 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E,
+ 0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
+ 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A,
+ 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
+ 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E,
+ 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
+ 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A};
+
+static FontEncSimpleMapRec koi8_r_to_unicode_map=
+{ 0x80, 0, 0x80, koi8_r_tophalf };
+
+
+static FontMapRec koi8_r[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,0,
+ &koi8_r_to_unicode_map,0},
+ {0,0,0,0,0,0,0}
+};
+
+static unsigned
+koi8_ru_to_unicode(unsigned koicode, void *client_data)
+{
+ switch(koicode) {
+ case 0x93: return 0x201C;
+ case 0x96: return 0x201D;
+ case 0x97: return 0x2014;
+ case 0x98: return 0x2116;
+ case 0x99: return 0x2122;
+ case 0x9B: return 0x00BB;
+ case 0x9C: return 0x00AE;
+ case 0x9D: return 0x00AB;
+ case 0x9F: return 0x00A4;
+ case 0xA4: return 0x0454;
+ case 0xA6: return 0x0456;
+ case 0xA7: return 0x0457;
+ case 0xAD: return 0x0491;
+ case 0xAE: return 0x045E;
+ case 0xB4: return 0x0404;
+ case 0xB6: return 0x0406;
+ case 0xB7: return 0x0407;
+ case 0xBD: return 0x0490;
+ case 0xBE: return 0x040E;
+ default: return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
+ }
+}
+
+static FontMapRec koi8_ru[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,koi8_ru_to_unicode,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+/* koi8-e, ISO-IR-111 or ECMA-Cyrillic */
+
+static unsigned short koi8_e_A0_BF[]=
+{ 0x00A0, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00AD, 0x045E, 0x045F,
+ 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00A4, 0x040E, 0x040F };
+
+static unsigned
+koi8_e_to_unicode(unsigned koicode, void *client_data)
+{
+ if(koicode<0xA0)
+ return koicode;
+ else if(koicode<0xC0)
+ return koi8_e_A0_BF[koicode-0xA0];
+ else
+ return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
+}
+
+static FontMapRec koi8_e[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,koi8_e_to_unicode,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+/* Koi8 unified */
+
+static unsigned short koi8_uni_80_BF[]=
+{ 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
+ 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
+ 0x2591, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ 0x00A9, 0x2122, 0x00A0, 0x00BB, 0x00AE, 0x00AB, 0x00B7, 0x00A4,
+ 0x00A0, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x0491, 0x045E, 0x045F,
+ 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x0490, 0x040E, 0x040F };
+
+static unsigned
+koi8_uni_to_unicode(unsigned koicode, void *client_data)
+{
+ if(koicode<0x80)
+ return koicode;
+ else if(koicode<0xC0)
+ return koi8_uni_80_BF[koicode-0x80];
+ else
+ return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
+}
+
+static FontMapRec koi8_uni[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,koi8_uni_to_unicode,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+/* Ukrainian variant of Koi8-R; see RFC 2319 */
+
+static unsigned
+koi8_u_to_unicode(unsigned koicode, void *client_data)
+{
+ switch(koicode) {
+ case 0xA4: return 0x0454;
+ case 0xA6: return 0x0456;
+ case 0xA7: return 0x0457;
+ case 0xAD: return 0x0491;
+ case 0xB4: return 0x0404;
+ case 0xB6: return 0x0406;
+ case 0xB7: return 0x0407;
+ case 0xBD: return 0x0490;
+ default: return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
+ }
+}
+
+static FontMapRec koi8_u[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,koi8_u_to_unicode,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+/* Microsoft Symbol, which is only meaningful for TrueType fonts, is
+ treated specially in ftenc.c, where we add usFirstCharIndex-0x20 to
+ the glyph index before applying the cmap. Lovely design. */
+
+static FontMapRec microsoft_symbol[]=
+{{FONT_ENCODING_TRUETYPE,3,0,0,0,0,0},
+ /* You never know */
+ {FONT_ENCODING_TRUETYPE,3,1,0,0,0,0},
+ {0,0,0,0,0,0,0}};
+
+static FontMapRec apple_roman[]=
+{{FONT_ENCODING_TRUETYPE,1,0,0,0,0,0}, {0,0,0,0,0,0,0}};
+
+/* The data for recodings */
+
+/* For compatibility with X11R6.4. Losers. */
+static char *iso8859_15_aliases[2]={"fcd8859-15",0};
+
+static FontEncRec initial_encodings[]=
+{
+ {"iso10646-1",0,256*256,0,iso10646,0,0,0}, /* Unicode */
+ {"iso8859-1",0,256,0,iso8859_1,0,0,0}, /* Latin 1 (West European) */
+ {"iso8859-2",0,256,0,iso8859_2,0,0,0}, /* Latin 2 (East European) */
+ {"iso8859-3",0,256,0,iso8859_3,0,0,0}, /* Latin 3 (South European) */
+ {"iso8859-4",0,256,0,iso8859_4,0,0,0}, /* Latin 4 (North European) */
+ {"iso8859-5",0,256,0,iso8859_5,0,0,0}, /* Cyrillic */
+ {"iso8859-6",0,256,0,iso8859_6,0,0,0}, /* Arabic */
+ {"iso8859-7",0,256,0,iso8859_7,0,0,0}, /* Greek */
+ {"iso8859-8",0,256,0,iso8859_8,0,0,0}, /* Hebrew */
+ {"iso8859-9",0,256,0,iso8859_9,0,0,0}, /* Latin 5 (Turkish) */
+ {"iso8859-10",0,256,0,iso8859_10,0,0,0}, /* Latin 6 (Nordic) */
+ {"iso8859-15",iso8859_15_aliases,256,0,iso8859_15,0,0,0}, /* Latin 9 */
+ {"koi8-r",0,256,0,koi8_r,0,0,0}, /* Russian */
+ {"koi8-ru",0,256,0,koi8_ru,0,0,0}, /* Ukrainian */
+ {"koi8-uni",0,256,0,koi8_uni,0,0,0}, /* Russian/Ukrainian/Bielorussian */
+ {"koi8-e",0,256,0,koi8_e,0,0,0}, /* ``European'' */
+ {"koi8-u",0,256,0,koi8_u,0,0,0}, /* Ukrainian too */
+ {"microsoft-symbol",0,256,0,microsoft_symbol,0,0,0},
+ {"apple-roman",0,256,0,apple_roman,0,0,0},
+ {0,0,0,0,0,0,0}
+};
+
+static FontEncPtr font_encodings=NULL;
+
+static void
+define_initial_encoding_info(void)
+{
+ FontEncPtr encoding;
+ FontMapPtr mapping;
+
+ font_encodings = initial_encodings;
+ for(encoding = font_encodings; ; encoding++) {
+ encoding->next = encoding + 1;
+ for(mapping = encoding->mappings; ; mapping++) {
+ mapping->next = mapping+1;
+ mapping->encoding = encoding;
+ if(mapping->next->type == 0) {
+ mapping->next = NULL;
+ break;
+ }
+ }
+ if(!encoding->next->name) {
+ encoding->next = NULL;
+ break;
+ }
+ }
+}
+
+
+char*
+FontEncFromXLFD(const char *name, int length)
+{
+ const char *p;
+ char *q;
+ static char charset[MAXFONTNAMELEN];
+ int len;
+
+ if(length > MAXFONTNAMELEN - 1)
+ return 0;
+
+ if(name == NULL)
+ p = NULL;
+ else {
+ p = name + length - 1;
+ while(p > name && *p != '-')
+ p--;
+ p--;
+ while(p >= name && *p != '-')
+ p--;
+ if(p <= name)
+ p = 0;
+ }
+
+ /* now p either is null or points at the '-' before the charset registry */
+
+ if(p == 0)
+ return 0;
+
+ len = length - (p - name) - 1;
+ memcpy(charset, p+1, len);
+ charset[len] = 0;
+
+ /* check for a subset specification */
+ if((q = strchr(charset, (int)'[')))
+ *q = 0;
+
+ return charset;
+}
+
+unsigned
+FontEncRecode(unsigned code, FontMapPtr mapping)
+{
+ FontEncPtr encoding = mapping->encoding;
+ if(encoding && mapping->recode) {
+ if(encoding->row_size == 0) {
+ /* linear encoding */
+ if(code < encoding->first || code>=encoding->size)
+ return 0;
+ } else {
+ /* matrix encoding */
+ int row = code/0x100, col = code&0xFF;
+ if(row < encoding->first || row >= encoding->size ||
+ col < encoding->first_col || col >= encoding->row_size)
+ return 0;
+ }
+ return (*mapping->recode)(code, mapping->client_data);
+ } else
+ return code;
+}
+
+char*
+FontEncName(unsigned code, FontMapPtr mapping)
+{
+ FontEncPtr encoding = mapping->encoding;
+ if(encoding && mapping->name) {
+ if((encoding->row_size == 0 && code >= encoding->size) ||
+ (encoding->row_size != 0 &&
+ (code/0x100 >= encoding->size ||
+ (code&0xFF) >= encoding->row_size)))
+ return 0;
+ return (*mapping->name)(code, mapping->client_data);
+ } else
+ return 0;
+}
+
+FontEncPtr
+FontEncFind(const char *encoding_name, const char *filename)
+{
+ FontEncPtr encoding;
+ char **alias;
+
+ if(font_encodings == NULL) define_initial_encoding_info();
+
+ for(encoding = font_encodings; encoding; encoding = encoding->next) {
+ if(!strcasecmp(encoding->name, encoding_name))
+ return encoding;
+ if(encoding->aliases)
+ for(alias=encoding->aliases; *alias; alias++)
+ if(!strcasecmp(*alias, encoding_name))
+ return encoding;
+ }
+
+ /* Unknown charset, try to load a definition file */
+ return FontEncLoad(encoding_name, filename);
+}
+
+FontMapPtr
+FontMapFind(FontEncPtr encoding, int type, int pid, int eid)
+{
+ FontMapPtr mapping;
+ if(encoding == NULL)
+ return NULL;
+
+ for(mapping = encoding->mappings; mapping; mapping = mapping->next) {
+ if(mapping->type != type)
+ continue;
+ if(pid > 0 && mapping->pid != pid)
+ continue;
+ if(eid > 0 && mapping->eid != eid)
+ continue;
+ return mapping;
+ }
+ return NULL;
+}
+
+FontMapPtr
+FontEncMapFind(const char *encoding_name, int type, int pid, int eid,
+ const char *filename)
+{
+ FontEncPtr encoding;
+ FontMapPtr mapping;
+
+ encoding = FontEncFind(encoding_name, filename);
+ if(encoding == NULL)
+ return NULL;
+ mapping = FontMapFind(encoding, type, pid, eid);
+ return mapping;
+}
+
+static FontEncPtr
+FontEncLoad(const char *encoding_name, const char *filename)
+{
+ FontEncPtr encoding;
+
+ encoding = FontEncReallyLoad(encoding_name, filename);
+ if (encoding == NULL) {
+ return 0;
+ } else {
+ char **alias;
+ int found = 0;
+
+ /* Check whether the name is already known for this encoding */
+ if(strcasecmp(encoding->name, encoding_name) == 0) {
+ found = 1;
+ } else {
+ if(encoding->aliases) {
+ for(alias=encoding->aliases; *alias; alias++)
+ if(!strcasecmp(*alias, encoding_name)) {
+ found = 1;
+ break;
+ }
+ }
+ }
+
+ if(!found) {
+ /* Add a new alias. This works because we know that this
+ particular encoding has been allocated dynamically */
+ char **new_aliases;
+ char *new_name;
+ int numaliases = 0;
+
+ new_name = xalloc(strlen(encoding_name) + 1);
+ if(new_name == NULL)
+ return NULL;
+ strcpy(new_name, encoding_name);
+ if(encoding->aliases) {
+ for(alias = encoding->aliases; *alias; alias++)
+ numaliases++;
+ }
+ new_aliases = (char**)xalloc((numaliases+2)*sizeof(char*));
+ if(new_aliases == NULL) {
+ xfree(new_name);
+ return NULL;
+ }
+ if(encoding->aliases) {
+ memcpy(new_aliases, encoding->aliases, numaliases*sizeof(char*));
+ xfree(encoding->aliases);
+ }
+ new_aliases[numaliases] = new_name;
+ new_aliases[numaliases+1] = NULL;
+ encoding->aliases = new_aliases;
+ }
+
+ /* register the new encoding */
+ encoding->next=font_encodings;
+ font_encodings=encoding;
+
+ return encoding;
+ }
+}
+
+unsigned
+FontEncSimpleRecode(unsigned code, void *client_data)
+{
+ FontEncSimpleMapPtr map;
+ unsigned index;
+
+ map = client_data;
+
+ if(code > 0xFFFF || (map->row_size && (code&0xFF) >= map->row_size))
+ return 0;
+
+ if(map->row_size)
+ index = (code&0xFF)+(code>>8)*map->row_size;
+ else
+ index = code;
+
+ if(map->map && index>=map->first && index<map->first+map->len)
+ return map->map[index-map->first];
+ else
+ return code;
+}
+
+char *
+FontEncSimpleName(unsigned code, void *client_data)
+{
+ FontEncSimpleNamePtr map;
+
+ map = client_data;
+ if(map && code >= map->first && code<map->first+map->len)
+ return map->map[code-map->first];
+ else
+ return NULL;
+}
+
+unsigned
+FontEncUndefinedRecode(unsigned code, void *client_data)
+{
+ return code;
+}
+
+char *
+FontEncUndefinedName(unsigned code, void *client_data)
+{
+ return NULL;
+}
+
+#define FONTENC_SEGMENT_SIZE 256
+#define FONTENC_SEGMENTS 256
+#define FONTENC_INVERSE_CODES (FONTENC_SEGMENT_SIZE * FONTENC_SEGMENTS)
+
+static unsigned int
+reverse_reverse(unsigned i, void* data)
+{
+ int s, j;
+ unsigned **map = (unsigned**)data;
+
+ if(i >= FONTENC_INVERSE_CODES)
+ return 0;
+
+ if(map == NULL)
+ return 0;
+
+ s = i / FONTENC_SEGMENT_SIZE;
+ j = i % FONTENC_SEGMENT_SIZE;
+
+ if(map[s] == NULL)
+ return 0;
+ else
+ return map[s][j];
+}
+
+static int
+tree_set(unsigned int **map, unsigned int i, unsigned int j)
+{
+ int s, c;
+
+ if(i >= FONTENC_INVERSE_CODES)
+ return FALSE;
+
+ s = i / FONTENC_SEGMENT_SIZE;
+ c = i % FONTENC_SEGMENT_SIZE;
+
+ if(map[s] == NULL) {
+ map[s] = calloc(FONTENC_SEGMENT_SIZE, sizeof(int));
+ if(map[s] == NULL)
+ return FALSE;
+ }
+
+ map[s][c] = j;
+ return TRUE;
+}
+
+FontMapReversePtr
+FontMapReverse(FontMapPtr mapping)
+{
+ FontEncPtr encoding = mapping->encoding;
+ FontMapReversePtr reverse = NULL;
+ unsigned int **map = NULL;
+ int i, j, k;
+
+ if(encoding == NULL) goto bail;
+
+ map = calloc(FONTENC_SEGMENTS, sizeof(int*));
+ if(map == NULL) goto bail;
+
+ if(encoding->row_size == 0) {
+ for(i = encoding->first; i < encoding->size; i++) {
+ k = FontEncRecode(i, mapping);
+ if(k != 0)
+ if(!tree_set(map, k, i))
+ goto bail;
+ }
+ } else {
+ for(i = encoding->first; i < encoding->size; i++) {
+ for(j = encoding->first_col; j < encoding->row_size; j++) {
+ k = FontEncRecode(i*256 + j, mapping);
+ if(k != 0)
+ if(!tree_set(map, k, i*256+j))
+ goto bail;
+ }
+ }
+ }
+
+ reverse = malloc(sizeof(FontMapReverseRec));
+ if(!reverse) goto bail;
+
+ reverse->reverse = reverse_reverse;
+ reverse->data = map;
+ return reverse;
+
+ bail:
+ if(map)
+ xfree(map);
+ if(reverse)
+ xfree(reverse);
+ return NULL;
+}
+
+void
+FontMapReverseFree(FontMapReversePtr delendum)
+{
+ unsigned int **map = (unsigned int**)delendum;
+ int i;
+
+ if(map == NULL)
+ return;
+
+ for(i = 0; i < FONTENC_SEGMENTS; i++)
+ if(map[i] != NULL)
+ xfree(map[i]);
+
+ xfree(map);
+ return;
+}
diff --git a/nx-X11/lib/font/fontfile/fontencI.h b/nx-X11/lib/font/fontfile/fontencI.h
new file mode 100644
index 000000000..bd35a1fbb
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/fontencI.h
@@ -0,0 +1,46 @@
+/*
+Copyright (c) 1998-2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+
+/* $XFree86: xc/lib/font/fontfile/fontencI.h,v 1.3 1999/04/25 10:01:43 dawes Exp $ */
+
+/* Private types and functions for the encoding code. */
+/* Used by the files `fontenc.h' and `encparse.h' */
+
+typedef struct _FontEncSimpleMap {
+ unsigned len; /* might be 0x10000 */
+ unsigned short row_size;
+ unsigned short first;
+ unsigned short *map;
+} FontEncSimpleMapRec, *FontEncSimpleMapPtr;
+
+typedef struct _FontEncSimpleName {
+ unsigned len;
+ unsigned short first;
+ char **map;
+} FontEncSimpleNameRec, *FontEncSimpleNamePtr;
+
+unsigned FontEncSimpleRecode(unsigned, void*);
+unsigned FontEncUndefinedRecode(unsigned, void*);
+char *FontEncSimpleName(unsigned, void*);
+char *FontEncUndefinedName(unsigned, void*);
+
+FontEncPtr FontEncReallyLoad(const char*, const char*);
diff --git a/nx-X11/lib/font/fontfile/fontencc.c b/nx-X11/lib/font/fontfile/fontencc.c
new file mode 100644
index 000000000..b54079acf
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/fontencc.c
@@ -0,0 +1,77 @@
+/*
+Copyright (c) 1998-2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+/* $XFree86: xc/lib/font/fontfile/fontencc.c,v 1.1 2001/08/13 21:46:47 dawes Exp $ */
+
+/* Binary compatibility code. */
+
+/* This file includes code to make modules compiled for earlier
+ versions of the fontenc interfaces link with this one. It does
+ *not* provide source compatibility, as many of the data structures
+ now have different names. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontenc.h>
+#include <X11/fonts/fontencc.h>
+
+extern void ErrorF(const char *f, ...);
+
+char *
+font_encoding_from_xlfd(const char * name, int length)
+{
+ return FontEncFromXLFD(name, length);
+}
+
+FontEncPtr
+font_encoding_find(const char *encoding_name, const char *filename)
+{
+ return FontEncFind(encoding_name, filename);
+}
+
+unsigned
+font_encoding_recode(unsigned code,
+ FontEncPtr encoding, FontMapPtr mapping)
+{
+ if(encoding != mapping->encoding) {
+ ErrorF("Inconsistent mapping/encoding\n");
+ return 0;
+ }
+ return FontEncRecode(code, mapping);
+}
+
+char *
+font_encoding_name(unsigned code,
+ FontEncPtr encoding, FontMapPtr mapping)
+{
+ if(encoding != mapping->encoding) {
+ ErrorF("Inconsistent mapping/encoding\n");
+ return 0;
+ }
+ return FontEncName(code, mapping);
+}
+
+char **
+identifyEncodingFile(const char *filename)
+{
+ return FontEncIdentify(filename);
+}
diff --git a/nx-X11/lib/font/fontfile/fontfile.c b/nx-X11/lib/font/fontfile/fontfile.c
new file mode 100644
index 000000000..2356c0595
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/fontfile.c
@@ -0,0 +1,1147 @@
+/* $XdotOrg: xc/lib/font/fontfile/fontfile.c,v 1.5 2005/07/09 06:36:13 keithp Exp $ */
+/* $Xorg: fontfile.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/fontfile.c,v 3.21 2003/12/02 19:50:40 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $NCDXorg: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#ifdef WIN32
+#include <ctype.h>
+#endif
+
+/*
+ * Map FPE functions to renderer functions
+ */
+
+static int FontFileOpenBitmapNCF (FontPathElementPtr fpe, FontPtr *pFont,
+ int flags, FontEntryPtr entry,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font);
+
+int
+FontFileNameCheck (char *name)
+{
+#ifndef NCD
+#if defined(__UNIXOS2__) || defined(WIN32)
+ /* OS/2 uses D:/... as a path name for fonts, so accept this as a valid
+ * path if it starts with a letter and a colon. Same applies for WIN32
+ */
+ if (isalpha(*name) && name[1]==':')
+ return TRUE;
+#endif
+ return *name == '/';
+#else
+ return ((strcmp(name, "built-ins") == 0) || (*name == '/'));
+#endif
+}
+
+int
+FontFileInitFPE (FontPathElementPtr fpe)
+{
+ int status;
+ FontDirectoryPtr dir;
+
+ status = FontFileReadDirectory (fpe->name, &dir);
+ if (status == Successful)
+ {
+ if (dir->nonScalable.used > 0)
+ if (!FontFileRegisterBitmapSource (fpe))
+ {
+ FontFileFreeFPE (fpe);
+ return AllocError;
+ }
+ fpe->private = (pointer) dir;
+ }
+ return status;
+}
+
+/* ARGSUSED */
+int
+FontFileResetFPE (FontPathElementPtr fpe)
+{
+ FontDirectoryPtr dir;
+
+ dir = (FontDirectoryPtr) fpe->private;
+ /*
+ * The reset must fail for bitmap fonts because they get cleared when
+ * the path is set.
+ */
+ if (FontFileDirectoryChanged (dir))
+ {
+ /* can't do it, so tell the caller to close and re-open */
+ return FPEResetFailed;
+ }
+ else
+ {
+ if (dir->nonScalable.used > 0)
+ if (!FontFileRegisterBitmapSource (fpe))
+ {
+ return FPEResetFailed;
+ }
+ return Successful;
+ }
+}
+
+int
+FontFileFreeFPE (FontPathElementPtr fpe)
+{
+ FontFileUnregisterBitmapSource (fpe);
+ FontFileFreeDir ((FontDirectoryPtr) fpe->private);
+ return Successful;
+}
+
+static int
+transfer_values_to_alias(char *entryname, int entrynamelength,
+ char *resolvedname,
+ char **aliasName, FontScalablePtr vals)
+{
+ static char aliasname[MAXFONTNAMELEN];
+ int nameok = 1, len;
+ char lowerName[MAXFONTNAMELEN];
+
+ *aliasName = resolvedname;
+ if ((len = strlen(*aliasName)) <= MAXFONTNAMELEN &&
+ (entrynamelength < MAXFONTNAMELEN) &&
+ FontFileCountDashes (*aliasName, len) == 14)
+ {
+ FontScalableRec tmpVals;
+ FontScalableRec tmpVals2;
+
+ tmpVals2 = *vals;
+
+ /* If we're aliasing a scalable name, transfer values
+ from the name into the destination alias, multiplying
+ by matrices that appear in the alias. */
+
+ CopyISOLatin1Lowered (lowerName, entryname,
+ entrynamelength);
+ lowerName[entrynamelength] = '\0';
+
+ if (FontParseXLFDName(lowerName, &tmpVals,
+ FONT_XLFD_REPLACE_NONE) &&
+ !tmpVals.values_supplied &&
+ FontParseXLFDName(*aliasName, &tmpVals,
+ FONT_XLFD_REPLACE_NONE))
+ {
+ double *matrix = 0, tempmatrix[4];
+
+ /* Use a matrix iff exactly one is defined */
+ if ((tmpVals.values_supplied & PIXELSIZE_MASK) ==
+ PIXELSIZE_ARRAY &&
+ !(tmpVals.values_supplied & POINTSIZE_MASK))
+ matrix = tmpVals.pixel_matrix;
+ else if ((tmpVals.values_supplied & POINTSIZE_MASK) ==
+ POINTSIZE_ARRAY &&
+ !(tmpVals.values_supplied & PIXELSIZE_MASK))
+ matrix = tmpVals.point_matrix;
+
+ /* If matrix given in the alias, compute new point
+ and/or pixel matrices */
+ if (matrix)
+ {
+ /* Complete the XLFD name to avoid potential
+ gotchas */
+ if (FontFileCompleteXLFD(&tmpVals2, &tmpVals2))
+ {
+ tempmatrix[0] =
+ matrix[0] * tmpVals2.point_matrix[0] +
+ matrix[1] * tmpVals2.point_matrix[2];
+ tempmatrix[1] =
+ matrix[0] * tmpVals2.point_matrix[1] +
+ matrix[1] * tmpVals2.point_matrix[3];
+ tempmatrix[2] =
+ matrix[2] * tmpVals2.point_matrix[0] +
+ matrix[3] * tmpVals2.point_matrix[2];
+ tempmatrix[3] =
+ matrix[2] * tmpVals2.point_matrix[1] +
+ matrix[3] * tmpVals2.point_matrix[3];
+ tmpVals2.point_matrix[0] = tempmatrix[0];
+ tmpVals2.point_matrix[1] = tempmatrix[1];
+ tmpVals2.point_matrix[2] = tempmatrix[2];
+ tmpVals2.point_matrix[3] = tempmatrix[3];
+
+ tempmatrix[0] =
+ matrix[0] * tmpVals2.pixel_matrix[0] +
+ matrix[1] * tmpVals2.pixel_matrix[2];
+ tempmatrix[1] =
+ matrix[0] * tmpVals2.pixel_matrix[1] +
+ matrix[1] * tmpVals2.pixel_matrix[3];
+ tempmatrix[2] =
+ matrix[2] * tmpVals2.pixel_matrix[0] +
+ matrix[3] * tmpVals2.pixel_matrix[2];
+ tempmatrix[3] =
+ matrix[2] * tmpVals2.pixel_matrix[1] +
+ matrix[3] * tmpVals2.pixel_matrix[3];
+ tmpVals2.pixel_matrix[0] = tempmatrix[0];
+ tmpVals2.pixel_matrix[1] = tempmatrix[1];
+ tmpVals2.pixel_matrix[2] = tempmatrix[2];
+ tmpVals2.pixel_matrix[3] = tempmatrix[3];
+
+ tmpVals2.values_supplied =
+ (tmpVals2.values_supplied &
+ ~(PIXELSIZE_MASK | POINTSIZE_MASK)) |
+ PIXELSIZE_ARRAY | POINTSIZE_ARRAY;
+ }
+ else
+ nameok = 0;
+ }
+
+ CopyISOLatin1Lowered (aliasname, *aliasName, len + 1);
+ if (nameok && FontParseXLFDName(aliasname, &tmpVals2,
+ FONT_XLFD_REPLACE_VALUE))
+ /* Return a version of the aliasname that has
+ had the vals stuffed into it. To avoid
+ memory leak, this alias name lives in a
+ static buffer. The caller needs to be done
+ with this buffer before this procedure is
+ called again to avoid reentrancy problems. */
+ *aliasName = aliasname;
+ }
+ }
+ return nameok;
+}
+
+/* ARGSUSED */
+int
+FontFileOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
+ char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *pFont, char **aliasName,
+ FontPtr non_cachable_font)
+{
+ FontDirectoryPtr dir;
+ char lowerName[MAXFONTNAMELEN];
+ char fileName[MAXFONTFILENAMELEN*2 + 1];
+ FontNameRec tmpName;
+ FontEntryPtr entry;
+ FontScalableRec vals;
+ FontScalableEntryPtr scalable;
+ FontScaledPtr scaled;
+ FontBitmapEntryPtr bitmap;
+ int ret;
+ Bool noSpecificSize;
+ int nranges;
+ fsRange *ranges;
+
+ if (namelen >= MAXFONTNAMELEN)
+ return AllocError;
+ dir = (FontDirectoryPtr) fpe->private;
+
+ /* Match non-scalable pattern */
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ ranges = FontParseRanges(lowerName, &nranges);
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
+ if (!FontParseXLFDName(lowerName, &vals, FONT_XLFD_REPLACE_NONE))
+ bzero(&vals, sizeof(vals));
+ if (!(entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName)) &&
+ tmpName.ndashes == 14 &&
+ FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO))
+ {
+ tmpName.length = strlen(lowerName);
+ entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName);
+ }
+
+ if (entry)
+ {
+ switch (entry->type) {
+ case FONT_ENTRY_BITMAP:
+ bitmap = &entry->u.bitmap;
+ if (bitmap->pFont)
+ {
+ *pFont = bitmap->pFont;
+ (*pFont)->fpe = fpe;
+ ret = Successful;
+ }
+ else
+ {
+ ret = FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format,
+ fmask, non_cachable_font);
+ if (ret == Successful && *pFont)
+ (*pFont)->fpe = fpe;
+ }
+ break;
+ case FONT_ENTRY_ALIAS:
+ vals.nranges = nranges;
+ vals.ranges = ranges;
+ transfer_values_to_alias(entry->name.name, entry->name.length,
+ entry->u.alias.resolved, aliasName, &vals);
+ ret = FontNameAlias;
+ break;
+#ifdef NOTYET
+ case FONT_ENTRY_BC:
+ bc = &entry->u.bc;
+ entry = bc->entry;
+ ret = (*scalable->renderer->OpenScalable)
+ (fpe, pFont, flags, entry, &bc->vals, format, fmask,
+ non_cachable_font);
+ if (ret == Successful && *pFont)
+ (*pFont)->fpe = fpe;
+ break;
+#endif
+ default:
+ ret = BadFontName;
+ }
+ }
+ else
+ {
+ ret = BadFontName;
+ }
+
+ if (ret != BadFontName)
+ {
+ if (ranges) xfree(ranges);
+ return ret;
+ }
+
+ /* Match XLFD patterns */
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
+ if (!FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO) ||
+ !(tmpName.length = strlen (lowerName),
+ entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName,
+ &vals))) {
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
+ entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, &vals);
+ if (entry)
+ {
+ strcpy(lowerName, entry->name.name);
+ tmpName.name = lowerName;
+ tmpName.length = entry->name.length;
+ tmpName.ndashes = entry->name.ndashes;
+ }
+ }
+ if (entry)
+ {
+ noSpecificSize = FALSE; /* TRUE breaks XLFD enhancements */
+ if (entry->type == FONT_ENTRY_SCALABLE &&
+ FontFileCompleteXLFD (&vals, &entry->u.scalable.extra->defaults))
+ {
+ scalable = &entry->u.scalable;
+ if ((vals.values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
+ (vals.values_supplied & POINTSIZE_MASK) == POINTSIZE_ARRAY ||
+ (vals.values_supplied &
+ ~SIZE_SPECIFY_MASK & ~CHARSUBSET_SPECIFIED))
+ scaled = 0;
+ else
+ scaled = FontFileFindScaledInstance (entry, &vals,
+ noSpecificSize);
+ /*
+ * A scaled instance can occur one of two ways:
+ *
+ * Either the font has been scaled to this
+ * size already, in which case scaled->pFont
+ * will point at that font.
+ *
+ * Or a bitmap instance in this size exists,
+ * which is handled as if we got a pattern
+ * matching the bitmap font name.
+ */
+ if (scaled)
+ {
+ if (scaled->pFont)
+ {
+ *pFont = scaled->pFont;
+ (*pFont)->fpe = fpe;
+ ret = Successful;
+ }
+ else if (scaled->bitmap)
+ {
+ entry = scaled->bitmap;
+ bitmap = &entry->u.bitmap;
+ if (bitmap->pFont)
+ {
+ *pFont = bitmap->pFont;
+ (*pFont)->fpe = fpe;
+ ret = Successful;
+ }
+ else
+ {
+ ret = FontFileOpenBitmapNCF (fpe, pFont, flags, entry,
+ format, fmask,
+ non_cachable_font);
+ if (ret == Successful && *pFont)
+ (*pFont)->fpe = fpe;
+ }
+ }
+ else /* "cannot" happen */
+ {
+ ret = BadFontName;
+ }
+ }
+ else
+ {
+ ret = FontFileMatchBitmapSource (fpe, pFont, flags, entry, &tmpName, &vals, format, fmask, noSpecificSize);
+ if (ret != Successful)
+ {
+ char origName[MAXFONTNAMELEN];
+
+ CopyISOLatin1Lowered (origName, name, namelen);
+ origName[namelen] = '\0';
+
+ /* Pass the original XLFD name in the vals
+ structure; the rasterizer is free to examine it
+ for hidden meanings. This information will not
+ be saved in the scaled-instances table. */
+
+ vals.xlfdName = origName;
+ vals.ranges = ranges;
+ vals.nranges = nranges;
+
+ if (strlen(dir->directory) + strlen(scalable->fileName) >=
+ sizeof(fileName)) {
+ ret = BadFontName;
+ } else {
+ strcpy (fileName, dir->directory);
+ strcat (fileName, scalable->fileName);
+ ret = (*scalable->renderer->OpenScalable) (fpe, pFont,
+ flags, entry, fileName, &vals, format, fmask,
+ non_cachable_font);
+ }
+
+ /* In case rasterizer does something bad because of
+ charset subsetting... */
+ if (ret == Successful &&
+ ((*pFont)->info.firstCol > (*pFont)->info.lastCol ||
+ (*pFont)->info.firstRow > (*pFont)->info.lastRow))
+ {
+ (*(*pFont)->unload_font)(*pFont);
+ ret = BadFontName;
+ }
+ /* Save the instance */
+ if (ret == Successful)
+ {
+ if (FontFileAddScaledInstance (entry, &vals,
+ *pFont, (char *) 0))
+ ranges = 0;
+ else
+ (*pFont)->fpePrivate = (pointer) 0;
+ (*pFont)->fpe = fpe;
+ }
+ }
+ }
+ }
+ }
+ else
+ ret = BadFontName;
+
+ if (ranges)
+ xfree(ranges);
+ return ret;
+}
+
+/* ARGSUSED */
+void
+FontFileCloseFont (FontPathElementPtr fpe, FontPtr pFont)
+{
+ FontEntryPtr entry;
+
+ if ((entry = (FontEntryPtr) pFont->fpePrivate)) {
+ switch (entry->type) {
+ case FONT_ENTRY_SCALABLE:
+ FontFileRemoveScaledInstance (entry, pFont);
+ break;
+ case FONT_ENTRY_BITMAP:
+ entry->u.bitmap.pFont = 0;
+ break;
+ default:
+ /* "cannot" happen */
+ break;
+ }
+ pFont->fpePrivate = 0;
+ }
+ (*pFont->unload_font) (pFont);
+}
+
+static int
+FontFileOpenBitmapNCF (FontPathElementPtr fpe, FontPtr *pFont,
+ int flags, FontEntryPtr entry,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font)
+{
+ FontBitmapEntryPtr bitmap;
+ char fileName[MAXFONTFILENAMELEN*2+1];
+ int ret;
+ FontDirectoryPtr dir;
+
+ dir = (FontDirectoryPtr) fpe->private;
+ bitmap = &entry->u.bitmap;
+ if(!bitmap || !bitmap->renderer->OpenBitmap)
+ return BadFontName;
+ if (strlen(dir->directory) + strlen(bitmap->fileName) >= sizeof(fileName))
+ return BadFontName;
+ strcpy (fileName, dir->directory);
+ strcat (fileName, bitmap->fileName);
+ ret = (*bitmap->renderer->OpenBitmap)
+ (fpe, pFont, flags, entry, fileName, format, fmask,
+ non_cachable_font);
+ if (ret == Successful)
+ {
+ bitmap->pFont = *pFont;
+ (*pFont)->fpePrivate = (pointer) entry;
+ }
+ return ret;
+}
+
+int
+FontFileOpenBitmap (FontPathElementPtr fpe, FontPtr *pFont,
+ int flags, FontEntryPtr entry,
+ fsBitmapFormat format, fsBitmapFormatMask fmask)
+{
+ return FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format, fmask,
+ (FontPtr)0);
+}
+
+static int
+FontFileGetInfoBitmap (FontPathElementPtr fpe, FontInfoPtr pFontInfo,
+ FontEntryPtr entry)
+{
+ FontBitmapEntryPtr bitmap;
+ char fileName[MAXFONTFILENAMELEN*2+1];
+ int ret;
+ FontDirectoryPtr dir;
+
+ dir = (FontDirectoryPtr) fpe->private;
+ bitmap = &entry->u.bitmap;
+ if (!bitmap || !bitmap->renderer->GetInfoBitmap)
+ return BadFontName;
+ if (strlen(dir->directory) + strlen(bitmap->fileName) >= sizeof(fileName))
+ return BadFontName;
+ strcpy (fileName, dir->directory);
+ strcat (fileName, bitmap->fileName);
+ ret = (*bitmap->renderer->GetInfoBitmap) (fpe, pFontInfo, entry, fileName);
+ return ret;
+}
+
+static void
+_FontFileAddScalableNames(FontNamesPtr names, FontNamesPtr scaleNames,
+ FontNamePtr nameptr, char *zeroChars,
+ FontScalablePtr vals, fsRange *ranges,
+ int nranges, int *max)
+{
+ int i;
+ FontScalableRec zeroVals, tmpVals;
+ for (i = 0; i < scaleNames->nnames; i++)
+ {
+ char nameChars[MAXFONTNAMELEN];
+ if (!*max)
+ return;
+ FontParseXLFDName (scaleNames->names[i], &zeroVals,
+ FONT_XLFD_REPLACE_NONE);
+ tmpVals = *vals;
+ if (FontFileCompleteXLFD (&tmpVals, &zeroVals))
+ {
+ --*max;
+
+ strcpy (nameChars, scaleNames->names[i]);
+ if ((vals->values_supplied & PIXELSIZE_MASK) ||
+ !(vals->values_supplied & PIXELSIZE_WILDCARD) ||
+ vals->y == 0)
+ {
+ tmpVals.values_supplied =
+ (tmpVals.values_supplied & ~PIXELSIZE_MASK) |
+ (vals->values_supplied & PIXELSIZE_MASK);
+ tmpVals.pixel_matrix[0] = vals->pixel_matrix[0];
+ tmpVals.pixel_matrix[1] = vals->pixel_matrix[1];
+ tmpVals.pixel_matrix[2] = vals->pixel_matrix[2];
+ tmpVals.pixel_matrix[3] = vals->pixel_matrix[3];
+ }
+ if ((vals->values_supplied & POINTSIZE_MASK) ||
+ !(vals->values_supplied & POINTSIZE_WILDCARD) ||
+ vals->y == 0)
+ {
+ tmpVals.values_supplied =
+ (tmpVals.values_supplied & ~POINTSIZE_MASK) |
+ (vals->values_supplied & POINTSIZE_MASK);
+ tmpVals.point_matrix[0] = vals->point_matrix[0];
+ tmpVals.point_matrix[1] = vals->point_matrix[1];
+ tmpVals.point_matrix[2] = vals->point_matrix[2];
+ tmpVals.point_matrix[3] = vals->point_matrix[3];
+ }
+ if (vals->width <= 0)
+ tmpVals.width = 0;
+ if (vals->x == 0)
+ tmpVals.x = 0;
+ if (vals->y == 0)
+ tmpVals.y = 0;
+ tmpVals.ranges = ranges;
+ tmpVals.nranges = nranges;
+ FontParseXLFDName (nameChars, &tmpVals,
+ FONT_XLFD_REPLACE_VALUE);
+ /* If we're marking aliases with negative lengths, we
+ need to concoct a valid target name to follow it.
+ Otherwise we're done. */
+ if (scaleNames->length[i] >= 0)
+ {
+ (void) AddFontNamesName (names, nameChars,
+ strlen (nameChars));
+ /* If our original pattern matches the name from
+ the table and that name doesn't duplicate what
+ we just added, add the name from the table */
+ if (strcmp(nameChars, scaleNames->names[i]) &&
+ FontFileMatchName(scaleNames->names[i],
+ scaleNames->length[i],
+ nameptr) &&
+ *max)
+ {
+ --*max;
+ (void) AddFontNamesName (names, scaleNames->names[i],
+ scaleNames->length[i]);
+ }
+ }
+ else
+ {
+ char *aliasName;
+ vals->ranges = ranges;
+ vals->nranges = nranges;
+ if (transfer_values_to_alias(zeroChars,
+ strlen(zeroChars),
+ scaleNames->names[++i],
+ &aliasName, vals))
+ {
+ (void) AddFontNamesName (names, nameChars,
+ strlen (nameChars));
+ names->length[names->nnames - 1] =
+ -names->length[names->nnames - 1];
+ (void) AddFontNamesName (names, aliasName,
+ strlen (aliasName));
+ /* If our original pattern matches the name from
+ the table and that name doesn't duplicate what
+ we just added, add the name from the table */
+ if (strcmp(nameChars, scaleNames->names[i - 1]) &&
+ FontFileMatchName(scaleNames->names[i - 1],
+ -scaleNames->length[i - 1],
+ nameptr) &&
+ *max)
+ {
+ --*max;
+ (void) AddFontNamesName (names,
+ scaleNames->names[i - 1],
+ -scaleNames->length[i - 1]);
+ names->length[names->nnames - 1] =
+ -names->length[names->nnames - 1];
+ (void) AddFontNamesName (names, aliasName,
+ strlen (aliasName));
+ }
+ }
+ }
+ }
+ }
+}
+
+/* ARGSUSED */
+static int
+_FontFileListFonts (pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max, FontNamesPtr names,
+ int mark_aliases)
+{
+ FontDirectoryPtr dir;
+ char lowerChars[MAXFONTNAMELEN], zeroChars[MAXFONTNAMELEN];
+ FontNameRec lowerName;
+ FontNameRec zeroName;
+ FontNamesPtr scaleNames;
+ FontScalableRec vals;
+ fsRange *ranges;
+ int nranges;
+ int result = BadFontName;
+
+ if (len >= MAXFONTNAMELEN)
+ return AllocError;
+ dir = (FontDirectoryPtr) fpe->private;
+ CopyISOLatin1Lowered (lowerChars, pat, len);
+ lowerChars[len] = '\0';
+ lowerName.name = lowerChars;
+ lowerName.length = len;
+ lowerName.ndashes = FontFileCountDashes (lowerChars, len);
+
+ /* Match XLFD patterns */
+
+ strcpy (zeroChars, lowerChars);
+ if (lowerName.ndashes == 14 &&
+ FontParseXLFDName (zeroChars, &vals, FONT_XLFD_REPLACE_ZERO))
+ {
+ ranges = FontParseRanges(lowerChars, &nranges);
+ result = FontFileFindNamesInScalableDir (&dir->nonScalable,
+ &lowerName, max, names,
+ (FontScalablePtr)0,
+ (mark_aliases ?
+ LIST_ALIASES_AND_TARGET_NAMES :
+ NORMAL_ALIAS_BEHAVIOR) |
+ IGNORE_SCALABLE_ALIASES,
+ &max);
+ zeroName.name = zeroChars;
+ zeroName.length = strlen (zeroChars);
+ zeroName.ndashes = lowerName.ndashes;
+
+ /* Look for scalable names and aliases, adding scaled instances of
+ them to the output */
+
+ /* Scalable names... */
+ scaleNames = MakeFontNamesRecord (0);
+ if (!scaleNames)
+ {
+ if (ranges) xfree(ranges);
+ return AllocError;
+ }
+ FontFileFindNamesInScalableDir (&dir->scalable, &zeroName, max,
+ scaleNames, &vals,
+ mark_aliases ?
+ LIST_ALIASES_AND_TARGET_NAMES :
+ NORMAL_ALIAS_BEHAVIOR, (int *)0);
+ _FontFileAddScalableNames(names, scaleNames, &lowerName,
+ zeroChars, &vals, ranges, nranges,
+ &max);
+ FreeFontNames (scaleNames);
+
+ /* Scalable aliases... */
+ scaleNames = MakeFontNamesRecord (0);
+ if (!scaleNames)
+ {
+ if (ranges) xfree(ranges);
+ return AllocError;
+ }
+ FontFileFindNamesInScalableDir (&dir->nonScalable, &zeroName,
+ max, scaleNames, &vals,
+ mark_aliases ?
+ LIST_ALIASES_AND_TARGET_NAMES :
+ NORMAL_ALIAS_BEHAVIOR, (int *)0);
+ _FontFileAddScalableNames(names, scaleNames, &lowerName,
+ zeroChars, &vals, ranges, nranges,
+ &max);
+ FreeFontNames (scaleNames);
+
+ if (ranges) xfree(ranges);
+ }
+ else
+ {
+ result = FontFileFindNamesInScalableDir (&dir->nonScalable,
+ &lowerName, max, names,
+ (FontScalablePtr)0,
+ mark_aliases ?
+ LIST_ALIASES_AND_TARGET_NAMES :
+ NORMAL_ALIAS_BEHAVIOR,
+ &max);
+ if (result == Successful)
+ result = FontFileFindNamesInScalableDir (&dir->scalable,
+ &lowerName, max, names,
+ (FontScalablePtr)0,
+ mark_aliases ?
+ LIST_ALIASES_AND_TARGET_NAMES :
+ NORMAL_ALIAS_BEHAVIOR, (int *)0);
+ }
+ return result;
+}
+
+typedef struct _LFWIData {
+ FontNamesPtr names;
+ int current;
+} LFWIDataRec, *LFWIDataPtr;
+
+int
+FontFileListFonts (pointer client, FontPathElementPtr fpe, char *pat,
+ int len, int max, FontNamesPtr names)
+{
+ return _FontFileListFonts (client, fpe, pat, len, max, names, 0);
+}
+
+int
+FontFileStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ LFWIDataPtr data;
+ int ret;
+
+ data = (LFWIDataPtr) xalloc (sizeof *data);
+ if (!data)
+ return AllocError;
+ data->names = MakeFontNamesRecord (0);
+ if (!data->names)
+ {
+ xfree (data);
+ return AllocError;
+ }
+ ret = FontFileListFonts (client, fpe, pat, len, max, data->names);
+ if (ret != Successful)
+ {
+ FreeFontNames (data->names);
+ xfree (data);
+ return ret;
+ }
+ data->current = 0;
+ *privatep = (pointer) data;
+ return Successful;
+}
+
+/* ARGSUSED */
+static int
+FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo)
+{
+ FontDirectoryPtr dir;
+ char lowerName[MAXFONTNAMELEN];
+ char fileName[MAXFONTFILENAMELEN*2 + 1];
+ FontNameRec tmpName;
+ FontEntryPtr entry;
+ FontScalableRec vals;
+ FontScalableEntryPtr scalable;
+ FontScaledPtr scaled;
+ FontBitmapEntryPtr bitmap;
+ int ret;
+ Bool noSpecificSize;
+ int nranges;
+ fsRange *ranges;
+
+ char *name = *namep;
+ int namelen = *namelenp;
+
+ if (namelen >= MAXFONTNAMELEN)
+ return AllocError;
+ dir = (FontDirectoryPtr) fpe->private;
+
+ /* Match non-scalable pattern */
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ ranges = FontParseRanges(lowerName, &nranges);
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
+ if (!FontParseXLFDName(lowerName, &vals, FONT_XLFD_REPLACE_NONE))
+ bzero(&vals, sizeof(vals));
+ if (!(entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName)) &&
+ tmpName.ndashes == 14 &&
+ FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO))
+ {
+ tmpName.length = strlen(lowerName);
+ entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName);
+ }
+
+ if (entry)
+ {
+ switch (entry->type) {
+ case FONT_ENTRY_BITMAP:
+ bitmap = &entry->u.bitmap;
+ if (bitmap->pFont)
+ {
+ *pFontInfo = &bitmap->pFont->info;
+ ret = Successful;
+ }
+ else
+ {
+ ret = FontFileGetInfoBitmap (fpe, *pFontInfo, entry);
+ }
+ break;
+ case FONT_ENTRY_ALIAS:
+ vals.nranges = nranges;
+ vals.ranges = ranges;
+ transfer_values_to_alias(entry->name.name, entry->name.length,
+ entry->u.alias.resolved, namep, &vals);
+ *namelenp = strlen (*namep);
+ ret = FontNameAlias;
+ break;
+#ifdef NOTYET
+ case FONT_ENTRY_BC:
+ /* no LFWI for this yet */
+ bc = &entry->u.bc;
+ entry = bc->entry;
+ /* Make a new scaled instance */
+ if (strlen(dir->directory) + strlen(scalable->fileName) >=
+ sizeof(fileName)) {
+ ret = BadFontName;
+ } else {
+ strcpy (fileName, dir->directory);
+ strcat (fileName, scalable->fileName);
+ ret = (*scalable->renderer->GetInfoScalable)
+ (fpe, *pFontInfo, entry, tmpName, fileName, &bc->vals);
+ }
+ break;
+#endif
+ default:
+ ret = BadFontName;
+ }
+ }
+ else
+ {
+ ret = BadFontName;
+ }
+
+ if (ret != BadFontName)
+ {
+ if (ranges) xfree(ranges);
+ return ret;
+ }
+
+ /* Match XLFD patterns */
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
+ if (!FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO) ||
+ !(tmpName.length = strlen (lowerName),
+ entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName,
+ &vals))) {
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
+ entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, &vals);
+ if (entry)
+ {
+ strcpy(lowerName, entry->name.name);
+ tmpName.name = lowerName;
+ tmpName.length = entry->name.length;
+ tmpName.ndashes = entry->name.ndashes;
+ }
+ }
+
+ if (entry)
+ {
+ noSpecificSize = FALSE; /* TRUE breaks XLFD enhancements */
+ if (entry && entry->type == FONT_ENTRY_SCALABLE &&
+ FontFileCompleteXLFD (&vals, &entry->u.scalable.extra->defaults))
+ {
+ scalable = &entry->u.scalable;
+ scaled = FontFileFindScaledInstance (entry, &vals, noSpecificSize);
+ /*
+ * A scaled instance can occur one of two ways:
+ *
+ * Either the font has been scaled to this
+ * size already, in which case scaled->pFont
+ * will point at that font.
+ *
+ * Or a bitmap instance in this size exists,
+ * which is handled as if we got a pattern
+ * matching the bitmap font name.
+ */
+ if (scaled)
+ {
+ if (scaled->pFont)
+ {
+ *pFontInfo = &scaled->pFont->info;
+ ret = Successful;
+ }
+ else if (scaled->bitmap)
+ {
+ entry = scaled->bitmap;
+ bitmap = &entry->u.bitmap;
+ if (bitmap->pFont)
+ {
+ *pFontInfo = &bitmap->pFont->info;
+ ret = Successful;
+ }
+ else
+ {
+ ret = FontFileGetInfoBitmap (fpe, *pFontInfo, entry);
+ }
+ }
+ else /* "cannot" happen */
+ {
+ ret = BadFontName;
+ }
+ }
+ else
+ {
+#ifdef NOTDEF
+ /* no special case yet */
+ ret = FontFileMatchBitmapSource (fpe, pFont, flags, entry, &vals, format, fmask, noSpecificSize);
+ if (ret != Successful)
+#endif
+ {
+ char origName[MAXFONTNAMELEN];
+
+ CopyISOLatin1Lowered (origName, name, namelen);
+ origName[namelen] = '\0';
+ vals.xlfdName = origName;
+ vals.ranges = ranges;
+ vals.nranges = nranges;
+
+ /* Make a new scaled instance */
+ if (strlen(dir->directory) + strlen(scalable->fileName) >=
+ sizeof(fileName)) {
+ ret = BadFontName;
+ } else {
+ strcpy (fileName, dir->directory);
+ strcat (fileName, scalable->fileName);
+ ret = (*scalable->renderer->GetInfoScalable)
+ (fpe, *pFontInfo, entry, &tmpName, fileName, &vals);
+ }
+ if (ranges) xfree(ranges);
+ }
+ }
+ if (ret == Successful) return ret;
+ }
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ tmpName.length = namelen;
+ }
+ else
+ ret = BadFontName;
+
+ if (ranges)
+ xfree(ranges);
+ return ret;
+}
+
+int
+FontFileListNextFontWithInfo(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo,
+ int *numFonts, pointer private)
+{
+ LFWIDataPtr data = (LFWIDataPtr) private;
+ int ret;
+ char *name;
+ int namelen;
+
+ if (data->current == data->names->nnames)
+ {
+ FreeFontNames (data->names);
+ xfree (data);
+ return BadFontName;
+ }
+ name = data->names->names[data->current];
+ namelen = data->names->length[data->current];
+ ret = FontFileListOneFontWithInfo (client, fpe, &name, &namelen, pFontInfo);
+ if (ret == BadFontName)
+ ret = AllocError;
+ *namep = name;
+ *namelenp = namelen;
+ ++data->current;
+ *numFonts = data->names->nnames - data->current;
+ return ret;
+}
+
+int
+FontFileStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ LFWIDataPtr data;
+ int ret;
+
+ data = (LFWIDataPtr) xalloc (sizeof *data);
+ if (!data)
+ return AllocError;
+ data->names = MakeFontNamesRecord (0);
+ if (!data->names)
+ {
+ xfree (data);
+ return AllocError;
+ }
+ ret = _FontFileListFonts (client, fpe, pat, len, max, data->names, 1);
+ if (ret != Successful)
+ {
+ FreeFontNames (data->names);
+ xfree (data);
+ return ret;
+ }
+ data->current = 0;
+ *privatep = (pointer) data;
+ return Successful;
+}
+
+int
+FontFileListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp, char **resolvedp,
+ int *resolvedlenp, pointer private)
+{
+ LFWIDataPtr data = (LFWIDataPtr) private;
+ int ret;
+ char *name;
+ int namelen;
+
+ if (data->current == data->names->nnames)
+ {
+ FreeFontNames (data->names);
+ xfree (data);
+ return BadFontName;
+ }
+ name = data->names->names[data->current];
+ namelen = data->names->length[data->current];
+
+ /* If this is a real font name... */
+ if (namelen >= 0)
+ {
+ *namep = name;
+ *namelenp = namelen;
+ ret = Successful;
+ }
+ /* Else if an alias */
+ else
+ {
+ /* Tell the caller that this is an alias... let him resolve it to
+ see if it's valid */
+ *namep = name;
+ *namelenp = -namelen;
+ *resolvedp = data->names->names[++data->current];
+ *resolvedlenp = data->names->length[data->current];
+ ret = FontNameAlias;
+ }
+
+ ++data->current;
+ return ret;
+}
+
+void
+FontFileRegisterLocalFpeFunctions (void)
+{
+ RegisterFPEFunctions(FontFileNameCheck,
+ FontFileInitFPE,
+ FontFileFreeFPE,
+ FontFileResetFPE,
+ FontFileOpenFont,
+ FontFileCloseFont,
+ FontFileListFonts,
+ FontFileStartListFontsWithInfo,
+ FontFileListNextFontWithInfo,
+ NULL,
+ NULL,
+ NULL,
+ FontFileStartListFontsAndAliases,
+ FontFileListNextFontOrAlias,
+ FontFileEmptyBitmapSource);
+}
diff --git a/nx-X11/lib/font/fontfile/fontscale.c b/nx-X11/lib/font/fontfile/fontscale.c
new file mode 100644
index 000000000..8e9de513d
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/fontscale.c
@@ -0,0 +1,447 @@
+/* $Xorg: fontscale.c,v 1.5 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/fontscale.c,v 3.9 2001/08/27 19:49:54 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#ifdef _XOPEN_SOURCE
+#include <math.h>
+#else
+#define _XOPEN_SOURCE /* to get prototype for hypot on some systems */
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+
+Bool
+FontFileAddScaledInstance (FontEntryPtr entry, FontScalablePtr vals,
+ FontPtr pFont, char *bitmapName)
+{
+ FontScalableEntryPtr scalable;
+ FontScalableExtraPtr extra;
+ FontScaledPtr new;
+ int newsize;
+
+ scalable = &entry->u.scalable;
+ extra = scalable->extra;
+ if (extra->numScaled == extra->sizeScaled)
+ {
+ newsize = extra->sizeScaled + 4;
+ new = (FontScaledPtr) xrealloc (extra->scaled,
+ newsize * sizeof (FontScaledRec));
+ if (!new)
+ return FALSE;
+ extra->sizeScaled = newsize;
+ extra->scaled = new;
+ }
+ new = &extra->scaled[extra->numScaled++];
+ new->vals = *vals;
+ new->pFont = pFont;
+ new->bitmap = (FontEntryPtr) bitmapName;
+ if (pFont)
+ pFont->fpePrivate = (pointer) entry;
+ return TRUE;
+}
+
+/* Must call this after the directory is sorted */
+
+void
+FontFileSwitchStringsToBitmapPointers (FontDirectoryPtr dir)
+{
+ int s;
+ int b;
+ int i;
+ FontEntryPtr scalable;
+ FontEntryPtr nonScalable;
+ FontScaledPtr scaled;
+ FontScalableExtraPtr extra;
+
+ scalable = dir->scalable.entries;
+ nonScalable = dir->nonScalable.entries;
+ for (s = 0; s < dir->scalable.used; s++)
+ {
+ extra = scalable[s].u.scalable.extra;
+ scaled = extra->scaled;
+ for (i = 0; i < extra->numScaled; i++)
+ for (b = 0; b < dir->nonScalable.used; b++)
+ if (nonScalable[b].name.name == (char *) scaled[i].bitmap)
+ scaled[i].bitmap = &nonScalable[b];
+ }
+}
+
+void
+FontFileRemoveScaledInstance (FontEntryPtr entry, FontPtr pFont)
+{
+ FontScalableEntryPtr scalable;
+ FontScalableExtraPtr extra;
+ int i;
+
+ scalable = &entry->u.scalable;
+ extra = scalable->extra;
+ for (i = 0; i < extra->numScaled; i++)
+ {
+ if (extra->scaled[i].pFont == pFont)
+ {
+ if (extra->scaled[i].vals.ranges)
+ xfree (extra->scaled[i].vals.ranges);
+ extra->numScaled--;
+ for (; i < extra->numScaled; i++)
+ extra->scaled[i] = extra->scaled[i+1];
+ }
+ }
+}
+
+Bool
+FontFileCompleteXLFD (FontScalablePtr vals, FontScalablePtr def)
+{
+ FontResolutionPtr res;
+ int num_res;
+ double sx, sy, temp_matrix[4];
+ double pixel_setsize_adjustment = 1.0;
+ /*
+ * If two of the three vertical scale values are specified, compute the
+ * third. If all three are specified, make sure they are consistent
+ * (within a pixel)
+ *
+ * One purpose of this procedure is to complete XLFD names in a
+ * repeatable manner. That is, if the user partially specifies
+ * a name (say, pixelsize but not pointsize), the results generated
+ * here result in a fully specified name that will result in the
+ * same font.
+ */
+
+ res = GetClientResolutions(&num_res);
+
+ if (!(vals->values_supplied & PIXELSIZE_MASK) ||
+ !(vals->values_supplied & POINTSIZE_MASK))
+ {
+ /* If resolution(s) unspecified and cannot be computed from
+ pixelsize and pointsize, get appropriate defaults. */
+
+ if (num_res)
+ {
+ if (vals->x <= 0)
+ vals->x = res->x_resolution;
+ if (vals->y <= 0)
+ vals->y = res->y_resolution;
+ }
+
+ if (vals->x <= 0)
+ vals->x = def->x;
+ if (vals->y <= 0)
+ vals->y = def->y;
+ }
+ else
+ {
+ /* If needed, compute resolution values from the pixel and
+ pointsize information we were given. This problem is
+ overdetermined (four equations, two unknowns), but we don't
+ check for inconsistencies here. If they exist, they will
+ show up in later tests for the point and pixel sizes. */
+
+ if (vals->y <= 0)
+ {
+ double x = hypot(vals->pixel_matrix[1], vals->pixel_matrix[3]);
+ double y = hypot(vals->point_matrix[1], vals->point_matrix[3]);
+ if (y < EPS) return FALSE;
+ vals->y = (int)(x * 72.27 / y + .5);
+ }
+ if (vals->x <= 0)
+ {
+ /* If the pixelsize was given as an array, or as a scalar that
+ has been normalized for the pixel shape, we have enough
+ information to compute a separate horizontal resolution */
+
+ if ((vals->values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
+ (vals->values_supplied & PIXELSIZE_MASK) ==
+ PIXELSIZE_SCALAR_NORMALIZED)
+ {
+ double x = hypot(vals->pixel_matrix[0], vals->pixel_matrix[2]);
+ double y = hypot(vals->point_matrix[0], vals->point_matrix[2]);
+ if (y < EPS) return FALSE;
+ vals->x = (int)(x * 72.27 / y + .5);
+ }
+ else
+ {
+ /* Not enough information in the pixelsize array. Just
+ assume the pixels are square. */
+ vals->x = vals->y;
+ }
+ }
+ }
+
+ if (vals->x <= 0 || vals->y <= 0) return FALSE;
+
+ /* If neither pixelsize nor pointsize is defined, take the pointsize
+ from the defaults structure we've been passed. */
+ if (!(vals->values_supplied & PIXELSIZE_MASK) &&
+ !(vals->values_supplied & POINTSIZE_MASK))
+ {
+ if (num_res)
+ {
+ vals->point_matrix[0] =
+ vals->point_matrix[3] = (double)res->point_size / 10.0;
+ vals->point_matrix[1] =
+ vals->point_matrix[2] = 0;
+ vals->values_supplied = (vals->values_supplied & ~POINTSIZE_MASK) |
+ POINTSIZE_SCALAR;
+ }
+ else if (def->values_supplied & POINTSIZE_MASK)
+ {
+ vals->point_matrix[0] = def->point_matrix[0];
+ vals->point_matrix[1] = def->point_matrix[1];
+ vals->point_matrix[2] = def->point_matrix[2];
+ vals->point_matrix[3] = def->point_matrix[3];
+ vals->values_supplied = (vals->values_supplied & ~POINTSIZE_MASK) |
+ (def->values_supplied & POINTSIZE_MASK);
+ }
+ else return FALSE;
+ }
+
+ /* At this point, at least two of the three vertical scale values
+ should be specified. Our job now is to compute the missing ones
+ and check for agreement between overspecified values */
+
+ /* If pixelsize was specified by a scalar, we need to fix the matrix
+ now that we know the resolutions. */
+ if ((vals->values_supplied & PIXELSIZE_MASK) == PIXELSIZE_SCALAR)
+ {
+ /* pixel_setsize_adjustment used below to modify permissible
+ error in pixel/pointsize matching, since multiplying a
+ number rounded to integer changes the amount of the error
+ caused by the rounding */
+
+ pixel_setsize_adjustment = (double)vals->x / (double)vals->y;
+ vals->pixel_matrix[0] *= pixel_setsize_adjustment;
+ vals->values_supplied = (vals->values_supplied & ~PIXELSIZE_MASK) |
+ PIXELSIZE_SCALAR_NORMALIZED;
+ }
+
+ sx = (double)vals->x / 72.27;
+ sy = (double)vals->y / 72.27;
+
+ /* If a pointsize was specified, make sure pixelsize is consistent
+ to within 1 pixel, then replace pixelsize with a consistent
+ floating-point value. */
+
+ if (vals->values_supplied & POINTSIZE_MASK)
+ {
+ recompute_pixelsize: ;
+ temp_matrix[0] = vals->point_matrix[0] * sx;
+ temp_matrix[1] = vals->point_matrix[1] * sy;
+ temp_matrix[2] = vals->point_matrix[2] * sx;
+ temp_matrix[3] = vals->point_matrix[3] * sy;
+ if (vals->values_supplied & PIXELSIZE_MASK)
+ {
+ if (fabs(vals->pixel_matrix[0] - temp_matrix[0]) >
+ pixel_setsize_adjustment ||
+ fabs(vals->pixel_matrix[1] - temp_matrix[1]) > 1 ||
+ fabs(vals->pixel_matrix[2] - temp_matrix[2]) > 1 ||
+ fabs(vals->pixel_matrix[3] - temp_matrix[3]) > 1)
+ return FALSE;
+ }
+ if ((vals->values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY &&
+ (vals->values_supplied & POINTSIZE_MASK) == POINTSIZE_SCALAR)
+ {
+ /* In the special case that pixelsize came as an array and
+ pointsize as a scalar, recompute the pointsize matrix
+ from the pixelsize matrix. */
+ goto recompute_pointsize;
+ }
+
+ /* Refresh pixel matrix with precise values computed from
+ pointsize and resolution. */
+ vals->pixel_matrix[0] = temp_matrix[0];
+ vals->pixel_matrix[1] = temp_matrix[1];
+ vals->pixel_matrix[2] = temp_matrix[2];
+ vals->pixel_matrix[3] = temp_matrix[3];
+
+ /* Set values_supplied for pixel to match that for point */
+ vals->values_supplied =
+ (vals->values_supplied & ~PIXELSIZE_MASK) |
+ (((vals->values_supplied & POINTSIZE_MASK) == POINTSIZE_ARRAY) ?
+ PIXELSIZE_ARRAY : PIXELSIZE_SCALAR_NORMALIZED);
+ }
+ else
+ {
+ /* Pointsize unspecified... compute from pixel size and
+ resolutions */
+ recompute_pointsize: ;
+ if (fabs(sx) < EPS || fabs(sy) < EPS) return FALSE;
+ vals->point_matrix[0] = vals->pixel_matrix[0] / sx;
+ vals->point_matrix[1] = vals->pixel_matrix[1] / sy;
+ vals->point_matrix[2] = vals->pixel_matrix[2] / sx;
+ vals->point_matrix[3] = vals->pixel_matrix[3] / sy;
+
+ /* Set values_supplied for pixel to match that for point */
+ vals->values_supplied =
+ (vals->values_supplied & ~POINTSIZE_MASK) |
+ (((vals->values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY) ?
+ POINTSIZE_ARRAY : POINTSIZE_SCALAR);
+
+ /* If we computed scalar pointsize from scalar pixelsize, round
+ pointsize to decipoints and recompute pixelsize so we end up
+ with a repeatable name */
+ if ((vals->values_supplied & POINTSIZE_MASK) == POINTSIZE_SCALAR)
+ {
+ /* Off-diagonal elements should be zero since no matrix was
+ specified. */
+ vals->point_matrix[0] =
+ (double)(int)(vals->point_matrix[0] * 10.0 + .5) / 10.0;
+ vals->point_matrix[3] =
+ (double)(int)(vals->point_matrix[3] * 10.0 + .5) / 10.0;
+ goto recompute_pixelsize;
+ }
+ }
+
+ /* We've succeeded. Round everything to a few decimal places
+ for repeatability. */
+
+ vals->pixel_matrix[0] = xlfd_round_double(vals->pixel_matrix[0]);
+ vals->pixel_matrix[1] = xlfd_round_double(vals->pixel_matrix[1]);
+ vals->pixel_matrix[2] = xlfd_round_double(vals->pixel_matrix[2]);
+ vals->pixel_matrix[3] = xlfd_round_double(vals->pixel_matrix[3]);
+ vals->point_matrix[0] = xlfd_round_double(vals->point_matrix[0]);
+ vals->point_matrix[1] = xlfd_round_double(vals->point_matrix[1]);
+ vals->point_matrix[2] = xlfd_round_double(vals->point_matrix[2]);
+ vals->point_matrix[3] = xlfd_round_double(vals->point_matrix[3]);
+
+ /* Fill in the deprecated fields for the benefit of rasterizers
+ that do not handle the matrices. */
+ vals->point = vals->point_matrix[3] * 10;
+ vals->pixel = vals->pixel_matrix[3];
+
+ return TRUE;
+}
+
+static Bool
+MatchScalable (FontScalablePtr a, FontScalablePtr b)
+{
+ int i;
+
+ /* Some asymmetry here: we assume that the first argument (a) is
+ the table entry and the second (b) the item we're trying to match
+ (the key). We'll consider the fonts matched if the relevant
+ metrics match *and* if a) the table entry doesn't have charset
+ subsetting or b) the table entry has identical charset subsetting
+ to that in the key. We could add logic to check if the table
+ entry has a superset of the charset required by the key, but
+ we'll resist the urge for now. */
+
+#define EQUAL(a,b) ((a)[0] == (b)[0] && \
+ (a)[1] == (b)[1] && \
+ (a)[2] == (b)[2] && \
+ (a)[3] == (b)[3])
+
+ if (!(a->x == b->x &&
+ a->y == b->y &&
+ (a->width == b->width || a->width == 0 || b->width == 0 || b->width == -1) &&
+ (!(b->values_supplied & PIXELSIZE_MASK) ||
+ ((a->values_supplied & PIXELSIZE_MASK) ==
+ (b->values_supplied & PIXELSIZE_MASK) &&
+ EQUAL(a->pixel_matrix, b->pixel_matrix))) &&
+ (!(b->values_supplied & POINTSIZE_MASK) ||
+ ((a->values_supplied & POINTSIZE_MASK) ==
+ (b->values_supplied & POINTSIZE_MASK) &&
+ EQUAL(a->point_matrix, b->point_matrix))) &&
+ (a->nranges == 0 || a->nranges == b->nranges)))
+ return FALSE;
+
+ for (i = 0; i < a->nranges; i++)
+ if (a->ranges[i].min_char_low != b->ranges[i].min_char_low ||
+ a->ranges[i].min_char_high != b->ranges[i].min_char_high ||
+ a->ranges[i].max_char_low != b->ranges[i].max_char_low ||
+ a->ranges[i].max_char_high != b->ranges[i].max_char_high)
+ return FALSE;
+
+ return TRUE;
+}
+
+FontScaledPtr
+FontFileFindScaledInstance (FontEntryPtr entry, FontScalablePtr vals,
+ int noSpecificSize)
+{
+ FontScalableEntryPtr scalable;
+ FontScalableExtraPtr extra;
+ FontScalablePtr mvals;
+ int dist, i;
+ int mini;
+ double mindist;
+ register double temp, sum=0.0;
+
+#define NORMDIFF(a, b) ( \
+ temp = (a)[0] - (b)[0], \
+ sum = temp * temp, \
+ temp = (a)[1] - (b)[1], \
+ sum += temp * temp, \
+ temp = (a)[2] - (b)[2], \
+ sum += temp * temp, \
+ temp = (a)[3] - (b)[3], \
+ sum + temp * temp )
+
+ scalable = &entry->u.scalable;
+ extra = scalable->extra;
+ if (noSpecificSize && extra->numScaled)
+ {
+ mini = 0;
+ mindist = NORMDIFF(extra->scaled[0].vals.point_matrix,
+ vals->point_matrix);
+ for (i = 1; i < extra->numScaled; i++)
+ {
+ if (extra->scaled[i].pFont &&
+ !extra->scaled[i].pFont->info.cachable) continue;
+ mvals = &extra->scaled[i].vals;
+ dist = NORMDIFF(mvals->point_matrix, vals->point_matrix);
+ if (dist < mindist)
+ {
+ mindist = dist;
+ mini = i;
+ }
+ }
+ if (extra->scaled[mini].pFont &&
+ !extra->scaled[mini].pFont->info.cachable) return 0;
+ return &extra->scaled[mini];
+ }
+ else
+ {
+ /* See if we've scaled to this value yet */
+ for (i = 0; i < extra->numScaled; i++)
+ {
+ if (extra->scaled[i].pFont &&
+ !extra->scaled[i].pFont->info.cachable) continue;
+ if (MatchScalable (&extra->scaled[i].vals, vals))
+ return &extra->scaled[i];
+ }
+ }
+ return 0;
+}
diff --git a/nx-X11/lib/font/fontfile/gunzip.c b/nx-X11/lib/font/fontfile/gunzip.c
new file mode 100644
index 000000000..8c9c317aa
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/gunzip.c
@@ -0,0 +1,227 @@
+/* $Xorg: gunzip.c,v 1.3 2000/08/17 19:46:37 cpqbld Exp $ */
+/* lib/font/fontfile/gunzip.c
+ written by Mark Eichin <eichin@kitten.gen.ma.us> September 1996.
+ intended for inclusion in X11 public releases. */
+/* $XFree86: xc/lib/font/fontfile/gunzip.c,v 1.4 2000/09/19 12:46:08 eich Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/bufio.h>
+#include <zlib.h>
+
+typedef struct _xzip_buf {
+ z_stream z;
+ int zstat;
+ BufChar b[BUFFILESIZE];
+ BufChar b_in[BUFFILESIZE];
+ BufFilePtr f;
+} xzip_buf;
+
+static int BufZipFileClose ( BufFilePtr f, int flag );
+static int BufZipFileFill ( BufFilePtr f );
+static int BufZipFileSkip ( BufFilePtr f, int c );
+static int BufCheckZipHeader ( BufFilePtr f );
+
+BufFilePtr
+BufFilePushZIP (BufFilePtr f)
+{
+ xzip_buf *x;
+
+ x = (xzip_buf *) xalloc (sizeof (xzip_buf));
+ if (!x) return 0;
+ /* these are just for raw calloc/free */
+ x->z.zalloc = Z_NULL;
+ x->z.zfree = Z_NULL;
+ x->z.opaque = Z_NULL;
+ x->f = f;
+
+ /* force inflateInit to allocate it's own history buffer */
+ x->z.next_in = Z_NULL;
+ x->z.next_out = Z_NULL;
+ x->z.avail_in = x->z.avail_out = 0;
+
+ /* using negative windowBits sets "nowrap" mode, which turns off
+ zlib header checking [undocumented, for gzip compatibility only?] */
+ x->zstat = inflateInit2(&(x->z), -MAX_WBITS);
+ if (x->zstat != Z_OK) {
+ xfree(x);
+ return 0;
+ }
+
+ /* now that the history buffer is allocated, we provide the data buffer */
+ x->z.next_out = x->b;
+ x->z.avail_out = BUFFILESIZE;
+ x->z.next_out = x->b_in;
+ x->z.avail_in = 0;
+
+ if (BufCheckZipHeader(x->f)) {
+ xfree(x);
+ return 0;
+ }
+
+ return BufFileCreate((char *)x,
+ BufZipFileFill,
+ 0,
+ BufZipFileSkip,
+ BufZipFileClose);
+}
+
+static int
+BufZipFileClose(BufFilePtr f, int flag)
+{
+ xzip_buf *x = (xzip_buf *)f->private;
+ inflateEnd (&(x->z));
+ BufFileClose (x->f, flag);
+ xfree (x);
+ return 1;
+}
+
+/* here's the real work.
+ -- we need to put stuff in f.buffer, update f.left and f.bufp,
+ then return the first byte (or BUFFILEEOF).
+ -- to do this, we need to get stuff into avail_in, and next_in,
+ and call inflate appropriately.
+ -- we may also need to add CRC maintenance - if inflate tells us
+ Z_STREAM_END, we then have 4bytes CRC and 4bytes length...
+ gzio.c:gzread shows most of the mechanism.
+ */
+static int
+BufZipFileFill (BufFilePtr f)
+{
+ xzip_buf *x = (xzip_buf *)f->private;
+
+ /* we only get called when left == 0... */
+ /* but just in case, deal */
+ if (f->left >= 0) {
+ f->left--;
+ return *(f->bufp++);
+ }
+ /* did we run out last time? */
+ switch (x->zstat) {
+ case Z_OK:
+ break;
+ case Z_STREAM_END:
+ case Z_DATA_ERROR:
+ case Z_ERRNO:
+ f->left = 0;
+ return BUFFILEEOF;
+ default:
+ return BUFFILEEOF;
+ }
+ /* now we work to consume what we can */
+ /* let zlib know what we can handle */
+ x->z.next_out = x->b;
+ x->z.avail_out = BUFFILESIZE;
+
+ /* and try to consume all of it */
+ while (x->z.avail_out > 0) {
+ /* if we don't have anything to work from... */
+ if (x->z.avail_in == 0) {
+ /* ... fill the z buf from underlying file */
+ int i, c;
+ for (i = 0; i < sizeof(x->b_in); i++) {
+ c = BufFileGet(x->f);
+ if (c == BUFFILEEOF) break;
+ x->b_in[i] = c;
+ }
+ x->z.avail_in += i;
+ x->z.next_in = x->b_in;
+ }
+ /* so now we have some output space and some input data */
+ x->zstat = inflate(&(x->z), Z_NO_FLUSH);
+ /* the inflation output happens in the f buffer directly... */
+ if (x->zstat == Z_STREAM_END) {
+ /* deal with EOF, crc */
+ break;
+ }
+ if (x->zstat != Z_OK) {
+ break;
+ }
+ }
+ f->bufp = x->b;
+ f->left = BUFFILESIZE - x->z.avail_out;
+
+ if (f->left >= 0) {
+ f->left--;
+ return *(f->bufp++);
+ } else {
+ return BUFFILEEOF;
+ }
+}
+
+/* there should be a BufCommonSkip... */
+static int
+BufZipFileSkip (BufFilePtr f, int c)
+{
+ /* BufFileRawSkip returns the count unchanged.
+ BufCompressedSkip returns 0.
+ That means it probably never gets called... */
+ int retval = c;
+ while(c--) {
+ int get = BufFileGet(f);
+ if (get == BUFFILEEOF) return get;
+ }
+ return retval;
+}
+
+/* now we need to duplicate check_header */
+/* contents:
+ 0x1f, 0x8b -- magic number
+ 1 byte -- method (Z_DEFLATED)
+ 1 byte -- flags (mask with RESERVED -> fail)
+ 4 byte -- time (discard)
+ 1 byte -- xflags (discard)
+ 1 byte -- "os" code (discard)
+ [if flags & EXTRA_FIELD:
+ 2 bytes -- LSBfirst length n
+ n bytes -- extra data (discard)]
+ [if flags & ORIG_NAME:
+ n bytes -- null terminated name (discard)]
+ [if flags & COMMENT:
+ n bytes -- null terminated comment (discard)]
+ [if flags & HEAD_CRC:
+ 2 bytes -- crc of headers? (discard)]
+ */
+
+/* gzip flag byte -- from gzio.c */
+#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
+#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
+#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
+#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
+#define COMMENT 0x10 /* bit 4 set: file comment present */
+#define RESERVED 0xE0 /* bits 5..7: reserved */
+
+#define GET(f) do {c = BufFileGet(f); if (c == BUFFILEEOF) return c;} while(0)
+static int
+BufCheckZipHeader(BufFilePtr f)
+{
+ int c, flags;
+ GET(f); if (c != 0x1f) return 1; /* magic 1 */
+ GET(f); if (c != 0x8b) return 2; /* magic 2 */
+ GET(f); if (c != Z_DEFLATED) return 3; /* method */
+ GET(f); if (c & RESERVED) return 4; /* reserved flags */
+ flags = c;
+ GET(f); GET(f); GET(f); GET(f); /* time */
+ GET(f); /* xflags */
+ GET(f); /* os code */
+ if (flags & EXTRA_FIELD) {
+ int len;
+ GET(f); len = c;
+ GET(f); len += (c<<8);
+ while (len-- >= 0) {
+ GET(f);
+ }
+ }
+ if (flags & ORIG_NAME) {
+ do { GET(f); } while (c != 0);
+ }
+ if (flags & COMMENT) {
+ do { GET(f); } while (c != 0);
+ }
+ if (flags & HEAD_CRC) {
+ GET(f); GET(f); /* header crc */
+ }
+ return 0;
+}
diff --git a/nx-X11/lib/font/fontfile/module/Imakefile b/nx-X11/lib/font/fontfile/module/Imakefile
new file mode 100644
index 000000000..0eebe085e
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/module/Imakefile
@@ -0,0 +1,21 @@
+XCOMM $XFree86: xc/lib/font/fontfile/module/Imakefile,v 1.3 1999/06/13 13:47:35 dawes Exp $
+#include <Server.tmpl>
+
+ INCLUDES = -I$(FONTINCSRC) -I../../include -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC)
+
+ DEFINES = -DLOADABLEFONTS
+
+ SRCS = ffcheck.c register.c
+ OBJS = ffcheck.o register.o
+
+SubdirLibraryRule($(OBJS))
+
+NormalLibraryObjectRule()
+NormalLintTarget($(SRCS))
+
+LinkSourceFile(ffcheck.c,..)
+LinkSourceFile(register.c,..)
+
+DependTarget()
+
diff --git a/nx-X11/lib/font/fontfile/printerfont.c b/nx-X11/lib/font/fontfile/printerfont.c
new file mode 100644
index 000000000..0b6c19c62
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/printerfont.c
@@ -0,0 +1,178 @@
+/* $Xorg: printerfont.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/printerfont.c,v 1.5tsi Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $NCDXorg: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+
+/*
+ * Map FPE functions to renderer functions
+ */
+
+#define PRINTERPATHPREFIX "PRINTER:"
+
+/* STUB
+int XpClientIsPrintClient(client,fpe)
+pointer client;
+FontPathElementPtr fpe;
+{ return 1; }
+ */
+
+static int
+PrinterFontNameCheck (char *name)
+{
+ if (strncmp(name,PRINTERPATHPREFIX,strlen(PRINTERPATHPREFIX)) != 0)
+ return 0;
+ name += strlen(PRINTERPATHPREFIX);
+#ifndef NCD
+ return *name == '/';
+#else
+ return ((strcmp(name, "built-ins") == 0) || (*name == '/'));
+#endif
+}
+
+static int
+PrinterFontInitFPE (FontPathElementPtr fpe)
+{
+ int status;
+ FontDirectoryPtr dir;
+ char * name;
+
+ name = fpe->name + strlen(PRINTERPATHPREFIX);
+ status = FontFileReadDirectory (name, &dir);
+ if (status == Successful)
+ {
+ if (dir->nonScalable.used > 0)
+ if (!FontFileRegisterBitmapSource (fpe))
+ {
+ FontFileFreeFPE (fpe);
+ return AllocError;
+ }
+ fpe->private = (pointer) dir;
+ }
+ return status;
+}
+
+/* Here we must check the client to see if it has a context attached to
+ * it that allows us to access the printer fonts
+ */
+
+static int
+PrinterFontOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
+ char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *pFont, char **aliasName,
+ FontPtr non_cachable_font)
+{
+ if (XpClientIsPrintClient(client,fpe))
+ return (FontFileOpenFont (client, fpe, flags, name, namelen, format,
+ fmask, id, pFont, aliasName, non_cachable_font));
+ return BadFontName;
+}
+
+static int
+PrinterFontListFonts (pointer client, FontPathElementPtr fpe, char *pat,
+ int len, int max, FontNamesPtr names)
+{
+ if (XpClientIsPrintClient(client,fpe))
+ return FontFileListFonts (client, fpe, pat, len, max, names);
+ return BadFontName;
+}
+
+static int
+PrinterFontStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ if (XpClientIsPrintClient(client,fpe))
+ return FontFileStartListFontsWithInfo(client, fpe, pat, len,
+ max, privatep);
+ return BadFontName;
+}
+
+static int
+PrinterFontListNextFontWithInfo(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo,
+ int *numFonts, pointer private)
+{
+ if (XpClientIsPrintClient(client,fpe))
+ return FontFileListNextFontWithInfo(client, fpe, namep, namelenp,
+ pFontInfo, numFonts, private);
+ return BadFontName;
+}
+
+static int
+PrinterFontStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ if (XpClientIsPrintClient(client,fpe))
+ return FontFileStartListFontsAndAliases(client, fpe, pat, len,
+ max, privatep);
+ return BadFontName;
+}
+
+static int
+PrinterFontListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ char **resolvedp, int *resolvedlenp,
+ pointer private)
+{
+ if (XpClientIsPrintClient(client,fpe))
+ return FontFileListNextFontOrAlias(client, fpe, namep, namelenp,
+ resolvedp, resolvedlenp, private);
+ return BadFontName;
+}
+
+void
+PrinterFontRegisterFpeFunctions (void)
+{
+ RegisterFPEFunctions(PrinterFontNameCheck,
+ PrinterFontInitFPE,
+ FontFileFreeFPE,
+ FontFileResetFPE,
+ PrinterFontOpenFont,
+ FontFileCloseFont,
+ PrinterFontListFonts,
+ PrinterFontStartListFontsWithInfo,
+ PrinterFontListNextFontWithInfo,
+ NULL,
+ NULL,
+ NULL,
+ PrinterFontStartListFontsAndAliases,
+ PrinterFontListNextFontOrAlias,
+ FontFileEmptyBitmapSource);
+}
diff --git a/nx-X11/lib/font/fontfile/register.c b/nx-X11/lib/font/fontfile/register.c
new file mode 100644
index 000000000..cb74c7cab
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/register.c
@@ -0,0 +1,109 @@
+/* $Xorg: register.c,v 1.4 2001/02/09 02:04:03 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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/register.c,v 1.14 2001/01/17 19:43:30 dawes Exp $ */
+
+/*
+ * This is in a separate source file so that small programs
+ * such as mkfontdir that want to use the fontfile utilities don't
+ * end up dragging in code from all the renderers, which is not small.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#else
+#define XFONT_BITMAP 1
+#endif
+
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/bitmap.h>
+
+#ifdef LOADABLEFONTS
+#include <X11/fonts/fontmod.h>
+#endif
+
+/*
+ * Translate monolithic build symbols to modular build symbols.
+ * I chose to make the modular symbols 'canonical' because they
+ * are prefixed with XFONT_, neatly avoiding name collisions
+ * with other packages.
+ */
+
+#ifndef CRAY
+# ifdef BUILD_SPEEDO
+# define XFONT_SPEEDO 1
+# endif
+# ifdef BUILD_TYPE1
+# define XFONT_TYPE1 1
+# endif
+#endif
+
+#ifdef BUILD_CID
+# define XFONT_CID 1
+#endif
+#ifdef BUILD_FREETYPE
+# define XFONT_FREETYPE 1
+#endif
+
+void
+FontFileRegisterFpeFunctions(void)
+{
+#ifndef LOADABLEFONTS
+
+#ifdef XFONT_BITMAP
+ BitmapRegisterFontFileFunctions ();
+#endif
+#ifdef XFONT_SPEEDO
+ SpeedoRegisterFontFileFunctions ();
+#endif
+#ifdef XFONT_TYPE1
+ Type1RegisterFontFileFunctions();
+#endif
+#ifdef XFONT_CID
+ CIDRegisterFontFileFunctions();
+#endif
+#ifdef XFONT_FREETYPE
+ FreeTypeRegisterFontFileFunctions();
+#endif
+
+#else
+ {
+ int i;
+
+ if (FontModuleList) {
+ for (i = 0; FontModuleList[i].name; i++) {
+ if (FontModuleList[i].initFunc)
+ FontModuleList[i].initFunc();
+ }
+ }
+ }
+#endif
+
+ FontFileRegisterLocalFpeFunctions ();
+}
+
diff --git a/nx-X11/lib/font/fontfile/renderers.c b/nx-X11/lib/font/fontfile/renderers.c
new file mode 100644
index 000000000..f110ba817
--- /dev/null
+++ b/nx-X11/lib/font/fontfile/renderers.c
@@ -0,0 +1,117 @@
+/* $Xorg: renderers.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/renderers.c,v 1.7 2002/12/09 17:30:00 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+extern void ErrorF(const char *f, ...);
+
+static FontRenderersRec renderers;
+
+/*
+ * XXX Maybe should allow unregistering renders. For now, just clear the
+ * list at each new generation.
+ */
+extern unsigned long serverGeneration;
+static unsigned long rendererGeneration = 0;
+
+Bool
+FontFileRegisterRenderer (FontRendererPtr renderer)
+{
+ return FontFilePriorityRegisterRenderer(renderer, 0);
+}
+
+Bool
+FontFilePriorityRegisterRenderer (FontRendererPtr renderer, int priority)
+{
+ int i;
+ struct _FontRenderersElement *new;
+
+ if (rendererGeneration != serverGeneration) {
+ rendererGeneration = serverGeneration;
+ renderers.number = 0;
+ if (renderers.renderers)
+ xfree(renderers.renderers);
+ renderers.renderers = NULL;
+ }
+
+ for (i = 0; i < renderers.number; i++) {
+ if (!strcmp (renderers.renderers[i].renderer->fileSuffix,
+ renderer->fileSuffix)) {
+ if(renderers.renderers[i].priority >= priority) {
+ if(renderers.renderers[i].priority == priority) {
+ if (rendererGeneration == 1)
+ ErrorF("Warning: font renderer for \"%s\" "
+ "already registered at priority %d\n",
+ renderer->fileSuffix, priority);
+ }
+ return TRUE;
+ } else {
+ break;
+ }
+ }
+ }
+
+ if(i >= renderers.number) {
+ new = xrealloc (renderers.renderers, sizeof(*new) * (i + 1));
+ if (!new)
+ return FALSE;
+ renderers.renderers = new;
+ renderers.number = i + 1;
+ }
+ renderer->number = i;
+ renderers.renderers[i].renderer = renderer;
+ renderers.renderers[i].priority = priority;
+ return TRUE;
+}
+
+FontRendererPtr
+FontFileMatchRenderer (char *fileName)
+{
+ int i;
+ int fileLen;
+ FontRendererPtr r;
+
+ fileLen = strlen (fileName);
+ for (i = 0; i < renderers.number; i++)
+ {
+ r = renderers.renderers[i].renderer;
+ if (fileLen >= r->fileSuffixLen &&
+ !strcmp (fileName + fileLen - r->fileSuffixLen, r->fileSuffix))
+ {
+ return r;
+ }
+ }
+ return 0;
+}
diff --git a/nx-X11/lib/font/include/Imakefile b/nx-X11/lib/font/include/Imakefile
new file mode 100644
index 000000000..91c84e6ec
--- /dev/null
+++ b/nx-X11/lib/font/include/Imakefile
@@ -0,0 +1,11 @@
+XCOMM $Xorg$
+ HEADERS = bitmap.h bufio.h fntfil.h fntfilio.h fntfilst.h fontenc.h \
+ fontencc.h fontmisc.h fontmod.h fontshow.h fontutil.h \
+ fontxlfd.h
+all::
+
+BuildIncludes($(HEADERS),X11/fonts,../..)
+
+#if BuildLibraries
+InstallMultipleFlags($(HEADERS),$(INCDIR)/X11/fonts,$(INSTINCFLAGS))
+#endif
diff --git a/nx-X11/lib/font/include/bitmap.h b/nx-X11/lib/font/include/bitmap.h
new file mode 100644
index 000000000..e60fda8eb
--- /dev/null
+++ b/nx-X11/lib/font/include/bitmap.h
@@ -0,0 +1,116 @@
+/* $Xorg: bitmap.h,v 1.4 2001/02/09 02:04:04 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.
+
+*/
+/* $XFree86: xc/lib/font/include/bitmap.h,v 1.9 2001/01/17 19:43:31 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifndef _BITMAP_H_
+#define _BITMAP_H_
+
+#include <X11/fonts/fntfilio.h>
+#ifndef FONTMODULE
+#include <stdio.h> /* just for NULL */
+#else
+#include "xf86_ansic.h"
+#endif
+
+/*
+ * Internal format used to store bitmap fonts
+ */
+
+/* number of encoding entries in one segment */
+#define BITMAP_FONT_SEGMENT_SIZE 128
+
+typedef struct _BitmapExtra {
+ Atom *glyphNames;
+ int *sWidths;
+ CARD32 bitmapsSizes[GLYPHPADOPTIONS];
+ FontInfoRec info;
+} BitmapExtraRec, *BitmapExtraPtr;
+
+typedef struct _BitmapFont {
+ unsigned version_num;
+ int num_chars;
+ int num_tables;
+ CharInfoPtr metrics; /* font metrics, including glyph pointers */
+ xCharInfo *ink_metrics; /* ink metrics */
+ char *bitmaps; /* base of bitmaps, useful only to free */
+ CharInfoPtr **encoding; /* array of arrays of char info pointers */
+ CharInfoPtr pDefault; /* default character */
+ BitmapExtraPtr bitmapExtra; /* stuff not used by X server */
+} BitmapFontRec, *BitmapFontPtr;
+
+#define ACCESSENCODING(enc,i) \
+(enc[(i)/BITMAP_FONT_SEGMENT_SIZE]?\
+(enc[(i)/BITMAP_FONT_SEGMENT_SIZE][(i)%BITMAP_FONT_SEGMENT_SIZE]):\
+0)
+#define ACCESSENCODINGL(enc,i) \
+(enc[(i)/BITMAP_FONT_SEGMENT_SIZE][(i)%BITMAP_FONT_SEGMENT_SIZE])
+
+#define SEGMENT_MAJOR(n) ((n)/BITMAP_FONT_SEGMENT_SIZE)
+#define SEGMENT_MINOR(n) ((n)%BITMAP_FONT_SEGMENT_SIZE)
+#define NUM_SEGMENTS(n) \
+ (((n)+BITMAP_FONT_SEGMENT_SIZE-1)/BITMAP_FONT_SEGMENT_SIZE)
+
+extern int bitmapGetGlyphs ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, CharInfoPtr *glyphs );
+extern int bitmapGetMetrics ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, xCharInfo **glyphs );
+
+extern void bitmapComputeFontBounds ( FontPtr pFont );
+extern void bitmapComputeFontInkBounds ( FontPtr pFont );
+extern Bool bitmapAddInkMetrics ( FontPtr pFont );
+extern int bitmapComputeWeight ( FontPtr pFont );
+
+extern int BitmapOpenBitmap ( FontPathElementPtr fpe, FontPtr *ppFont,
+ int flags, FontEntryPtr entry, char *fileName,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font );
+extern int BitmapGetInfoBitmap ( FontPathElementPtr fpe,
+ FontInfoPtr pFontInfo, FontEntryPtr entry,
+ char *fileName );
+extern void BitmapRegisterFontFileFunctions ( void );
+extern int BitmapGetRenderIndex ( FontRendererPtr renderer );
+
+extern int BitmapOpenScalable ( FontPathElementPtr fpe, FontPtr *pFont,
+ int flags, FontEntryPtr entry, char *fileName,
+ FontScalablePtr vals, fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font );
+extern int BitmapGetInfoScalable ( FontPathElementPtr fpe,
+ FontInfoPtr pFontInfo, FontEntryPtr entry,
+ FontNamePtr fontName, char *fileName,
+ FontScalablePtr vals );
+
+#endif /* _BITMAP_H_ */
diff --git a/nx-X11/lib/font/include/bufio.h b/nx-X11/lib/font/include/bufio.h
new file mode 100644
index 000000000..da90064a2
--- /dev/null
+++ b/nx-X11/lib/font/include/bufio.h
@@ -0,0 +1,92 @@
+/* $Xorg: bufio.h,v 1.4 2001/02/09 02:04:04 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.
+
+*/
+/* $XFree86: xc/lib/font/include/bufio.h,v 1.6 2001/07/31 16:44:55 alanh Exp $ */
+
+#ifndef ___BUFIO_H___
+#define ___BUFIO_H___ 1
+
+#include <X11/Xfuncproto.h>
+
+#ifdef TEST
+
+#define xalloc(s) malloc(s)
+#define xfree(s) free(s)
+
+#endif
+
+#define BUFFILESIZE 8192
+#define BUFFILEEOF -1
+
+typedef unsigned char BufChar;
+typedef struct _buffile *BufFilePtr;
+
+typedef struct _buffile {
+ BufChar *bufp;
+ int left;
+ int eof;
+ BufChar buffer[BUFFILESIZE];
+ int (*input)( BufFilePtr /* f */);
+ int (*output)( int /* c */, BufFilePtr /* f */);
+ int (*skip)( BufFilePtr /* f */, int /* count */);
+ int (*close)( BufFilePtr /* f */, int /* doClose */);
+ char *private;
+} BufFileRec;
+
+extern BufFilePtr BufFileCreate (
+ char*,
+ int (*)(BufFilePtr),
+ int (*)(int, BufFilePtr),
+ int (*)(BufFilePtr, int),
+ int (*)(BufFilePtr, int));
+extern BufFilePtr BufFileOpenRead ( int );
+extern BufFilePtr BufFileOpenWrite ( int );
+extern BufFilePtr BufFilePushCompressed ( BufFilePtr );
+#ifdef X_GZIP_FONT_COMPRESSION
+extern BufFilePtr BufFilePushZIP ( BufFilePtr );
+#endif
+extern int BufFileClose ( BufFilePtr, int );
+extern int BufFileFlush ( BufFilePtr, int );
+extern int BufFileRead ( BufFilePtr, char*, int );
+extern int BufFileWrite ( BufFilePtr, char*, int );
+extern void BufFileFree ( BufFilePtr );
+
+#define BufFileGet(f) ((f)->left-- ? *(f)->bufp++ : ((f)->eof = (*(f)->input) (f)))
+#define BufFilePut(c,f) (--(f)->left ? *(f)->bufp++ = ((unsigned char)(c)) : (*(f)->output) ((unsigned char)(c),f))
+#define BufFileSkip(f,c) ((f)->eof = (*(f)->skip) (f, c))
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#endif /* ___BUFIO_H___ */
+
diff --git a/nx-X11/lib/font/include/fntfil.h b/nx-X11/lib/font/include/fntfil.h
new file mode 100644
index 000000000..81d2cbc3d
--- /dev/null
+++ b/nx-X11/lib/font/include/fntfil.h
@@ -0,0 +1,178 @@
+/* $Xorg: fntfil.h,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/include/fntfil.h,v 1.9 2001/12/14 19:56:54 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifndef _FONTFILE_H_
+#define _FONTFILE_H_
+
+#include <X11/fonts/fontxlfd.h>
+
+typedef struct _FontEntry *FontEntryPtr;
+typedef struct _FontTable *FontTablePtr;
+typedef struct _FontName *FontNamePtr;
+typedef struct _FontScaled *FontScaledPtr;
+typedef struct _FontScalableExtra *FontScalableExtraPtr;
+typedef struct _FontScalableEntry *FontScalableEntryPtr;
+typedef struct _FontScaleAliasEntry *FontScaleAliasEntryPtr;
+typedef struct _FontBitmapEntry *FontBitmapEntryPtr;
+typedef struct _FontAliasEntry *FontAliasEntryPtr;
+typedef struct _FontBCEntry *FontBCEntryPtr;
+typedef struct _FontDirectory *FontDirectoryPtr;
+typedef struct _FontRenderer *FontRendererPtr;
+
+#define NullFontEntry ((FontEntryPtr) 0)
+#define NullFontTable ((FontTablePtr) 0)
+#define NullFontName ((FontNamePtr) 0)
+#define NullFontScaled ((FontScaled) 0)
+#define NullFontScalableExtra ((FontScalableExtra) 0)
+#define NullFontscalableEntry ((FontScalableEntry) 0)
+#define NullFontScaleAliasEntry ((FontScaleAliasEntry) 0)
+#define NullFontBitmapEntry ((FontBitmapEntry) 0)
+#define NullFontAliasEntry ((FontAliasEntry) 0)
+#define NullFontBCEntry ((FontBCEntry) 0)
+#define NullFontDirectory ((FontDirectoryPtr) 0)
+#define NullFontRenderer ((FontRendererPtr) 0)
+
+#define FONT_ENTRY_SCALABLE 0
+#define FONT_ENTRY_SCALE_ALIAS 1
+#define FONT_ENTRY_BITMAP 2
+#define FONT_ENTRY_ALIAS 3
+#define FONT_ENTRY_BC 4
+
+#define MAXFONTNAMELEN 1024
+#define MAXFONTFILENAMELEN 1024
+
+#define FontDirFile "fonts.dir"
+#define FontAliasFile "fonts.alias"
+#define FontScalableFile "fonts.scale"
+
+extern int FontFileNameCheck ( char *name );
+extern int FontFileInitFPE ( FontPathElementPtr fpe );
+extern int FontFileResetFPE ( FontPathElementPtr fpe );
+extern int FontFileFreeFPE ( FontPathElementPtr fpe );
+extern int FontFileOpenFont ( pointer client, FontPathElementPtr fpe,
+ Mask flags, char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *pFont, char **aliasName,
+ FontPtr non_cachable_font );
+extern void FontFileCloseFont ( FontPathElementPtr fpe, FontPtr pFont );
+extern int FontFileOpenBitmap ( FontPathElementPtr fpe, FontPtr *pFont,
+ int flags, FontEntryPtr entry,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask );
+extern int FontFileListFonts ( pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ FontNamesPtr names );
+extern int FontFileStartListFontsWithInfo ( pointer client,
+ FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep );
+extern int FontFileListNextFontWithInfo ( pointer client,
+ FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo,
+ int *numFonts, pointer private );
+extern int FontFileStartListFontsAndAliases ( pointer client,
+ FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep );
+extern int FontFileListNextFontOrAlias ( pointer client,
+ FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ char **resolvedp, int *resolvedlenp,
+ pointer private );
+extern void FontFileRegisterLocalFpeFunctions ( void );
+
+
+extern FontEntryPtr FontFileAddEntry ( FontTablePtr table,
+ FontEntryPtr prototype );
+extern Bool FontFileAddFontAlias ( FontDirectoryPtr dir, char *aliasName,
+ char *fontName );
+extern Bool FontFileAddFontFile ( FontDirectoryPtr dir, char *fontName,
+ char *fileName );
+extern int FontFileCountDashes ( char *name, int namelen );
+extern FontEntryPtr FontFileFindNameInDir ( FontTablePtr table,
+ FontNamePtr pat );
+extern FontEntryPtr FontFileFindNameInScalableDir ( FontTablePtr table,
+ FontNamePtr pat,
+ FontScalablePtr vals );
+extern int FontFileFindNamesInDir ( FontTablePtr table, FontNamePtr pat,
+ int max, FontNamesPtr names );
+extern int FontFileFindNamesInScalableDir ( FontTablePtr table,
+ FontNamePtr pat, int max,
+ FontNamesPtr names,
+ FontScalablePtr vals,
+ int alias_behavior, int *newmax );
+
+extern void FontFileFreeDir ( FontDirectoryPtr dir );
+extern void FontFileFreeEntry ( FontEntryPtr entry );
+extern void FontFileFreeTable ( FontTablePtr table );
+extern Bool FontFileInitTable ( FontTablePtr table, int size );
+extern FontDirectoryPtr FontFileMakeDir ( char *dirName, int size );
+extern Bool FontFileMatchName ( char *name, int length, FontNamePtr pat );
+extern char * FontFileSaveString ( char *s );
+extern void FontFileSortDir ( FontDirectoryPtr dir );
+extern void FontFileSortTable ( FontTablePtr table );
+
+extern void FontDefaultFormat ( int *bit, int *byte, int *glyph, int *scan );
+
+extern Bool FontFileRegisterRenderer ( FontRendererPtr renderer );
+extern Bool FontFilePriorityRegisterRenderer ( FontRendererPtr renderer,
+ int priority );
+extern FontRendererPtr FontFileMatchRenderer ( char *fileName );
+
+extern Bool FontFileAddScaledInstance ( FontEntryPtr entry,
+ FontScalablePtr vals, FontPtr pFont,
+ char *bitmapName );
+extern void FontFileSwitchStringsToBitmapPointers ( FontDirectoryPtr dir );
+extern void FontFileRemoveScaledInstance ( FontEntryPtr entry, FontPtr pFont );
+extern Bool FontFileCompleteXLFD ( FontScalablePtr vals, FontScalablePtr def );
+extern FontScaledPtr FontFileFindScaledInstance ( FontEntryPtr entry,
+ FontScalablePtr vals,
+ int noSpecificSize );
+
+extern Bool FontFileRegisterBitmapSource ( FontPathElementPtr fpe );
+extern void FontFileUnregisterBitmapSource ( FontPathElementPtr fpe );
+extern void FontFileEmptyBitmapSource ( void );
+extern int FontFileMatchBitmapSource ( FontPathElementPtr fpe,
+ FontPtr *pFont, int flags,
+ FontEntryPtr entry,
+ FontNamePtr zeroPat,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ Bool noSpecificSize );
+
+extern int FontFileReadDirectory ( char *directory, FontDirectoryPtr *pdir );
+extern Bool FontFileDirectoryChanged ( FontDirectoryPtr dir );
+
+#endif /* _FONTFILE_H_ */
diff --git a/nx-X11/lib/font/include/fntfilio.h b/nx-X11/lib/font/include/fntfilio.h
new file mode 100644
index 000000000..f8e24f390
--- /dev/null
+++ b/nx-X11/lib/font/include/fntfilio.h
@@ -0,0 +1,56 @@
+/* $Xorg: fntfilio.h,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/include/fntfilio.h,v 1.6 2001/10/31 22:50:26 tsi Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifndef _FNTFILIO_H_
+#define _FNTFILIO_H_
+
+#include <X11/fonts/bufio.h>
+
+typedef BufFilePtr FontFilePtr;
+
+#define FontFileGetc(f) BufFileGet(f)
+#define FontFilePutc(c,f) BufFilePut(c,f)
+#define FontFileRead(f,b,n) BufFileRead(f,b,n)
+#define FontFileWrite(f,b,n) BufFileWrite(f,b,n)
+#define FontFileSkip(f,n) (BufFileSkip (f, n) != BUFFILEEOF)
+#define FontFileSeek(f,n) (BufFileSeek (f,n,0) != BUFFILEEOF)
+
+#define FontFileEOF BUFFILEEOF
+
+extern FontFilePtr FontFileOpen ( const char *name );
+extern int FontFileClose ( FontFilePtr f );
+extern FontFilePtr FontFileOpenWrite ( const char *name );
+extern FontFilePtr FontFileOpenWriteFd ( int fd );
+extern FontFilePtr FontFileOpenFd ( int fd );
+
+#endif /* _FNTFILIO_H_ */
diff --git a/nx-X11/lib/font/include/fntfilst.h b/nx-X11/lib/font/include/fntfilst.h
new file mode 100644
index 000000000..1a71eae7a
--- /dev/null
+++ b/nx-X11/lib/font/include/fntfilst.h
@@ -0,0 +1,198 @@
+/* $Xorg: fntfilst.h,v 1.5 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/include/fntfilst.h,v 3.8 2002/12/09 17:30:00 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifndef _FONTFILEST_H_
+#define _FONTFILEST_H_
+
+#ifndef FONTMODULE
+#include <X11/Xos.h>
+#endif
+#ifndef XP_PSTEXT
+#include <X11/fonts/fontmisc.h>
+#endif
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/fontxlfd.h>
+#include <X11/fonts/fntfil.h>
+
+typedef struct _FontName {
+ char *name;
+ short length;
+ short ndashes;
+} FontNameRec;
+
+typedef struct _FontScaled {
+ FontScalableRec vals;
+ FontEntryPtr bitmap;
+ FontPtr pFont;
+} FontScaledRec;
+
+typedef struct _FontScalableExtra {
+ FontScalableRec defaults;
+ int numScaled;
+ int sizeScaled;
+ FontScaledPtr scaled;
+ pointer private;
+} FontScalableExtraRec;
+
+typedef struct _FontScalableEntry {
+ FontRendererPtr renderer;
+ char *fileName;
+ FontScalableExtraPtr extra;
+} FontScalableEntryRec;
+
+/*
+ * This "can't" work yet - the returned alias string must be permanent,
+ * but this layer would need to generate the appropriate name from the
+ * resolved scalable + the XLFD values passed in. XXX
+ */
+
+typedef struct _FontScaleAliasEntry {
+ char *resolved;
+} FontScaleAliasEntryRec;
+
+typedef struct _FontBitmapEntry {
+ FontRendererPtr renderer;
+ char *fileName;
+ FontPtr pFont;
+} FontBitmapEntryRec;
+
+typedef struct _FontAliasEntry {
+ char *resolved;
+} FontAliasEntryRec;
+
+typedef struct _FontBCEntry {
+ FontScalableRec vals;
+ FontEntryPtr entry;
+} FontBCEntryRec;
+
+typedef struct _FontEntry {
+ FontNameRec name;
+ int type;
+ union _FontEntryParts {
+ FontScalableEntryRec scalable;
+ FontBitmapEntryRec bitmap;
+ FontAliasEntryRec alias;
+ FontBCEntryRec bc;
+ } u;
+} FontEntryRec;
+
+typedef struct _FontTable {
+ int used;
+ int size;
+ FontEntryPtr entries;
+ Bool sorted;
+} FontTableRec;
+
+typedef struct _FontDirectory {
+ char *directory;
+ unsigned long dir_mtime;
+ unsigned long alias_mtime;
+ FontTableRec scalable;
+ FontTableRec nonScalable;
+ char *attributes;
+} FontDirectoryRec;
+
+/* Capability bits: for definition of capabilities bitmap in the
+ FontRendererRec to indicate support of XLFD enhancements */
+
+#define CAP_MATRIX 0x1
+#define CAP_CHARSUBSETTING 0x2
+
+typedef struct _FontRenderer {
+ char *fileSuffix;
+ int fileSuffixLen;
+ int (*OpenBitmap)(FontPathElementPtr /* fpe */,
+ FontPtr * /* pFont */,
+ int /* flags */,
+ FontEntryPtr /* entry */,
+ char * /* fileName */,
+ fsBitmapFormat /* format */,
+ fsBitmapFormatMask /* mask */,
+ FontPtr /* non_cachable_font */);
+ int (*OpenScalable)(FontPathElementPtr /* fpe */,
+ FontPtr * /* pFont */,
+ int /* flags */,
+ FontEntryPtr /* entry */,
+ char * /* fileName */,
+ FontScalablePtr /* vals */,
+ fsBitmapFormat /* format */,
+ fsBitmapFormatMask /* fmask */,
+ FontPtr /* non_cachable_font */);
+ int (*GetInfoBitmap)(FontPathElementPtr /* fpe */,
+ FontInfoPtr /* pFontInfo */,
+ FontEntryPtr /* entry */,
+ char * /*fileName */);
+ int (*GetInfoScalable)(FontPathElementPtr /* fpe */,
+ FontInfoPtr /* pFontInfo */,
+ FontEntryPtr /* entry */,
+ FontNamePtr /* fontName */,
+ char * /* fileName */,
+ FontScalablePtr /* vals */);
+ int number;
+ int capabilities; /* Bitmap components defined above */
+} FontRendererRec;
+
+typedef struct _FontRenders {
+ int number;
+ struct _FontRenderersElement {
+ /* In order to preserve backward compatibility, the
+ priority field is made invisible to renderers */
+ FontRendererPtr renderer;
+ int priority;
+ } *renderers;
+} FontRenderersRec, *FontRenderersPtr;
+
+typedef struct _BitmapInstance {
+ FontScalableRec vals;
+ FontBitmapEntryPtr bitmap;
+} BitmapInstanceRec, *BitmapInstancePtr;
+
+typedef struct _BitmapScalablePrivate {
+ int numInstances;
+ BitmapInstancePtr instances;
+} BitmapScalablePrivateRec, *BitmapScalablePrivatePtr;
+
+typedef struct _BitmapSources {
+ FontPathElementPtr *fpe;
+ int size;
+ int count;
+} BitmapSourcesRec, *BitmapSourcesPtr;
+
+extern BitmapSourcesRec FontFileBitmapSources;
+
+/* Defines for FontFileFindNamesInScalableDir() behavior */
+#define NORMAL_ALIAS_BEHAVIOR 0
+#define LIST_ALIASES_AND_TARGET_NAMES (1<<0)
+#define IGNORE_SCALABLE_ALIASES (1<<1)
+
+#endif /* _FONTFILEST_H_ */
diff --git a/nx-X11/lib/font/include/fontenc.h b/nx-X11/lib/font/include/fontenc.h
new file mode 100644
index 000000000..09472cfc5
--- /dev/null
+++ b/nx-X11/lib/font/include/fontenc.h
@@ -0,0 +1,124 @@
+/*
+Copyright (c) 1998-2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+
+/* $XFree86: xc/lib/font/include/fontenc.h,v 1.7 2000/11/14 16:54:45 dawes Exp $ */
+
+/* Header for backend-independent encoding code */
+
+/* An encoding is identified with a name. An encoding contains some
+ global encoding data, such as its size, and a set of mappings.
+ Mappings are identified by their type and two integers, known as
+ pid and eid, the interpretation of which is type dependent. */
+
+#ifndef _FONTENC_H
+#define _FONTENC_H
+
+/* Encoding types. For future extensions, clients should be prepared
+ to ignore unknown encoding types. */
+
+/* 0 is treated specially. */
+
+#define FONT_ENCODING_UNICODE 1
+#define FONT_ENCODING_TRUETYPE 2
+#define FONT_ENCODING_POSTSCRIPT 3
+
+/* This structure represents a mapping, either from numeric codes from
+ numeric codes, or from numeric codes to strings. */
+
+/* It is expected that only one of `recode' and `name' will actually
+ be present. However, having both fields simplifies the interface
+ somewhat. */
+
+typedef struct _FontMap {
+ int type; /* the type of the mapping */
+ int pid, eid; /* the identification of the mapping */
+ unsigned (*recode)(unsigned, void*); /* mapping function */
+ char *(*name)(unsigned, void*); /* function returning glyph names */
+ void *client_data; /* second parameter of the two above */
+ struct _FontMap *next; /* link to next element in list */
+ /* The following was added for version 0.3 of the font interface. */
+ /* It should be kept at the end to preserve binary compatibility. */
+ struct _FontEnc *encoding;
+} FontMapRec, *FontMapPtr;
+
+/* This is the structure that holds all the info for one encoding. It
+ consists of a charset name, its size, and a linked list of mappings
+ like above. */
+
+typedef struct _FontEnc {
+ char *name; /* the name of the encoding */
+ char **aliases; /* its aliases, null terminated */
+ int size; /* its size, either in bytes or rows */
+ int row_size; /* the size of a row, or 0 if bytes */
+ FontMapPtr mappings; /* linked list of mappings */
+ struct _FontEnc *next; /* link to next element */
+ /* the following two were added in version 0.2 of the font interface */
+ /* they should be kept at the end to preserve binary compatibility */
+ int first; /* first byte or row */
+ int first_col; /* first column in each row */
+} FontEncRec, *FontEncPtr;
+
+typedef struct _FontMapReverse {
+ unsigned int (*reverse)(unsigned, void*);
+ void *data;
+} FontMapReverseRec, *FontMapReversePtr;
+
+
+/* Function prototypes */
+
+/* extract an encoding name from an XLFD name. Returns a pointer to a
+ *static* buffer, or NULL */
+char *FontEncFromXLFD(const char*, int);
+
+/* find the encoding data for a given encoding name; second parameter
+ is the filename of the font for which the encoding is needed.
+ Returns NULL on failure. */
+FontEncPtr FontEncFind(const char*, const char*);
+
+/* Find a given mapping for an encoding. This is only a convenience
+ function, as clients are allowed to scavenge the data structures
+ themselves (as the TrueType backend does). */
+
+FontMapPtr FontMapFind(FontEncPtr, int, int, int);
+
+/* Do both in a single step */
+FontMapPtr FontEncMapFind(const char *, int, int, int, const char *);
+
+/* Recode a code. Always succeeds. */
+unsigned FontEncRecode(unsigned, FontMapPtr);
+
+/* Return a name for a code. Returns a string or NULL. */
+char *FontEncName(unsigned, FontMapPtr);
+
+/* Return a pointer to the name of the system encodings directory. */
+/* This string is static and should not be modified. */
+char* FontEncDirectory(void);
+
+/* Identify an encoding file. If fileName doesn't exist, or is not an
+ encoding file, return NULL, otherwise returns a NULL-terminated
+ array of strings. */
+char **FontEncIdentify(const char *fileName);
+
+FontMapReversePtr FontMapReverse(FontMapPtr);
+
+void FontMapReverseFree(FontMapReversePtr);
+#endif
diff --git a/nx-X11/lib/font/include/fontencc.h b/nx-X11/lib/font/include/fontencc.h
new file mode 100644
index 000000000..51e0e1440
--- /dev/null
+++ b/nx-X11/lib/font/include/fontencc.h
@@ -0,0 +1,36 @@
+/*
+Copyright (c) 1998-2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+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
+AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+/* $XFree86$ */
+
+/* Binary compatibility entry points. */
+
+/* This file includes code to make modules compiled for earlier
+ versions of the fontenc interfaces link with this one. It does
+ *not* provide source compatibility, as many of the data structures
+ now have different names. */
+
+extern char *font_encoding_from_xlfd(const char*, int);
+extern unsigned font_encoding_recode(unsigned, FontEncPtr, FontMapPtr);
+extern FontEncPtr font_encoding_find(const char*, const char*);
+extern char *font_encoding_name(unsigned, FontEncPtr, FontMapPtr);
+extern char **identifyEncodingFile(const char *fileName);
+
diff --git a/nx-X11/lib/font/include/fontmisc.h b/nx-X11/lib/font/include/fontmisc.h
new file mode 100644
index 000000000..b7e359068
--- /dev/null
+++ b/nx-X11/lib/font/include/fontmisc.h
@@ -0,0 +1,133 @@
+/* $Xorg: fontmisc.h,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/include/fontmisc.h,v 3.16 2001/12/14 19:56:54 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifndef _FONTMISC_H_
+#define _FONTMISC_H_
+
+#ifndef FONTMODULE
+#include <X11/Xfuncs.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#ifndef X_NOT_POSIX
+#include <unistd.h>
+#else
+extern int close();
+#endif
+
+#endif /* FONTMODULE */
+
+#include "X11/Xdefs.h"
+
+
+#ifndef LSBFirst
+#define LSBFirst 0
+#define MSBFirst 1
+#endif
+
+#ifndef None
+#define None 0l
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+extern Atom MakeAtom ( char *string, unsigned len, int makeit );
+extern int ValidAtom ( Atom atom );
+extern char *NameForAtom (Atom atom);
+
+#ifndef _HAVE_XALLOC_DECLS
+#define _HAVE_XALLOC_DECLS
+extern pointer Xalloc(unsigned long);
+extern pointer Xrealloc(pointer, unsigned long);
+extern void Xfree(pointer);
+extern pointer Xcalloc(unsigned long);
+#endif
+extern int f_strcasecmp(const char *s1, const char *s2);
+
+#ifndef xalloc
+#define xalloc(n) Xalloc ((unsigned) n)
+#define xfree(p) Xfree ((pointer) p)
+#define xrealloc(p,n) Xrealloc ((pointer)p,n)
+#define xcalloc(n,s) Xcalloc((unsigned) n * (unsigned) s)
+#endif
+#define lowbit(x) ((x) & (~(x) + 1))
+
+#undef assert
+#define assert(x) ((void)0)
+
+#ifndef strcasecmp
+#if defined(NEED_STRCASECMP) && !defined(FONTMODULE)
+#define strcasecmp(s1,s2) f_strcasecmp(s1,s2)
+#endif
+#endif
+
+extern void
+BitOrderInvert(
+ register unsigned char *,
+ register int
+);
+
+extern void
+TwoByteSwap(
+ register unsigned char *,
+ register int
+);
+
+extern void
+FourByteSwap(
+ register unsigned char *,
+ register int
+);
+
+extern int
+RepadBitmap (
+ char*,
+ char*,
+ unsigned,
+ unsigned,
+ int,
+ int
+);
+
+extern void CopyISOLatin1Lowered(
+ char * /*dest*/,
+ char * /*source*/,
+ int /*length*/
+);
+
+extern void register_fpe_functions(void);
+
+#endif /* _FONTMISC_H_ */
diff --git a/nx-X11/lib/font/include/fontmod.h b/nx-X11/lib/font/include/fontmod.h
new file mode 100644
index 000000000..42d277fd4
--- /dev/null
+++ b/nx-X11/lib/font/include/fontmod.h
@@ -0,0 +1,16 @@
+/* $XFree86: xc/lib/font/include/fontmod.h,v 1.2 1998/07/25 06:57:09 dawes Exp $ */
+
+#ifndef _FONTMOD_H_
+#define _FONTMOD_H_
+
+typedef void (*InitFont)(void);
+
+typedef struct {
+ InitFont initFunc;
+ char * name;
+ pointer module;
+} FontModule;
+
+extern FontModule *FontModuleList;
+
+#endif /* _FONTMOD_H_ */
diff --git a/nx-X11/lib/font/include/fontshow.h b/nx-X11/lib/font/include/fontshow.h
new file mode 100644
index 000000000..5bb48fe18
--- /dev/null
+++ b/nx-X11/lib/font/include/fontshow.h
@@ -0,0 +1,37 @@
+/* $Xorg: fontshow.h,v 1.4 2001/02/09 02:04:04 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.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#define FONT_SHOW_INFO (1<<0)
+#define FONT_SHOW_PROPS (1<<1)
+#define FONT_SHOW_METRICS (1<<2)
+#define FONT_SHOW_GLYPHS (1<<3)
+#define FONT_SHOW_ALL (FONT_SHOW_INFO|FONT_SHOW_PROPS|FONT_SHOW_GLYPHS)
diff --git a/nx-X11/lib/font/include/fontutil.h b/nx-X11/lib/font/include/fontutil.h
new file mode 100644
index 000000000..9a73eaa47
--- /dev/null
+++ b/nx-X11/lib/font/include/fontutil.h
@@ -0,0 +1,26 @@
+/* $XFree86: xc/lib/font/include/fontutil.h,v 1.1 1999/03/14 11:17:49 dawes Exp $ */
+
+#ifndef _FONTUTIL_H_
+#define _FONTUTIL_H_
+
+#include <X11/fonts/FSproto.h>
+
+extern int FontCouldBeTerminal(FontInfoPtr);
+extern int CheckFSFormat(fsBitmapFormat, fsBitmapFormatMask, int *, int *,
+ int *, int *, int *);
+extern void FontComputeInfoAccelerators(FontInfoPtr);
+
+extern void GetGlyphs ( FontPtr font, unsigned long count,
+ unsigned char *chars, FontEncoding fontEncoding,
+ unsigned long *glyphcount, CharInfoPtr *glyphs );
+extern void QueryGlyphExtents ( FontPtr pFont, CharInfoPtr *charinfo,
+ unsigned long count, ExtentInfoRec *info );
+extern Bool QueryTextExtents ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, ExtentInfoRec *info );
+extern Bool ParseGlyphCachingMode ( char *str );
+extern void InitGlyphCaching ( void );
+extern void SetGlyphCachingMode ( int newmode );
+extern int add_range ( fsRange *newrange, int *nranges, fsRange **range,
+ Bool charset_subset );
+
+#endif /* _FONTUTIL_H_ */
diff --git a/nx-X11/lib/font/include/fontxlfd.h b/nx-X11/lib/font/include/fontxlfd.h
new file mode 100644
index 000000000..e87b93143
--- /dev/null
+++ b/nx-X11/lib/font/include/fontxlfd.h
@@ -0,0 +1,100 @@
+/* $Xorg: fontxlfd.h,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+Copyright 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.
+
+*/
+/* $XFree86: xc/lib/font/include/fontxlfd.h,v 1.5 2001/01/17 19:43:32 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifndef _FONTXLFD_H_
+#define _FONTXLFD_H_
+
+#include <X11/fonts/FSproto.h>
+
+/* Constants for values_supplied bitmap */
+
+#define SIZE_SPECIFY_MASK 0xf
+
+#define PIXELSIZE_MASK 0x3
+#define PIXELSIZE_UNDEFINED 0
+#define PIXELSIZE_SCALAR 0x1
+#define PIXELSIZE_ARRAY 0x2
+#define PIXELSIZE_SCALAR_NORMALIZED 0x3 /* Adjusted for resolution */
+
+#define POINTSIZE_MASK 0xc
+#define POINTSIZE_UNDEFINED 0
+#define POINTSIZE_SCALAR 0x4
+#define POINTSIZE_ARRAY 0x8
+
+#define PIXELSIZE_WILDCARD 0x10
+#define POINTSIZE_WILDCARD 0x20
+
+#define ENHANCEMENT_SPECIFY_MASK 0x40
+
+#define CHARSUBSET_SPECIFIED 0x40
+
+#define EPS 1.0e-20
+#define XLFD_NDIGITS 3 /* Round numbers in pixel and
+ point arrays to this many
+ digits for repeatability */
+
+typedef struct _FontScalable {
+ int values_supplied; /* Bitmap identifying what advanced
+ capabilities or enhancements
+ were specified in the font name */
+ double pixel_matrix[4];
+ double point_matrix[4];
+
+ /* Pixel and point fields are deprecated in favor of the
+ transformation matrices. They are provided and filled in for the
+ benefit of rasterizers that do not handle the matrices. */
+
+ int pixel,
+ point;
+
+ int x,
+ y,
+ width;
+ char *xlfdName;
+ int nranges;
+ fsRange *ranges;
+} FontScalableRec, *FontScalablePtr;
+
+
+extern double xlfd_round_double ( double x );
+extern Bool FontParseXLFDName ( char *fname, FontScalablePtr vals, int subst );
+extern fsRange *FontParseRanges ( char *name, int *nranges );
+
+#define FONT_XLFD_REPLACE_NONE 0
+#define FONT_XLFD_REPLACE_STAR 1
+#define FONT_XLFD_REPLACE_ZERO 2
+#define FONT_XLFD_REPLACE_VALUE 3
+
+#endif /* _FONTXLFD_H_ */
diff --git a/nx-X11/lib/font/stubs/Imakefile b/nx-X11/lib/font/stubs/Imakefile
new file mode 100644
index 000000000..555bbf614
--- /dev/null
+++ b/nx-X11/lib/font/stubs/Imakefile
@@ -0,0 +1,25 @@
+XCOMM $XFree86: xc/lib/font/stubs/Imakefile,v 1.3 1999/12/15 01:14:35 robin Exp $
+
+#include <Server.tmpl>
+
+INCLUDES = -I$(FONTINCSRC) -I../include -I$(XINCLUDESRC)
+SRCS = cauthgen.c csignal.c delfntcid.c errorf.c fatalerror.c \
+ findoldfnt.c getcres.c getdefptsize.c getnewfntcid.c gettime.c \
+ initfshdl.c regfpefunc.c rmfshdl.c servclient.c setfntauth.c \
+ stfntcfnt.c xpstubs.c
+OBJS = cauthgen.o csignal.o delfntcid.o errorf.o fatalerror.o \
+ findoldfnt.o getcres.o getdefptsize.o getnewfntcid.o gettime.o \
+ initfshdl.o regfpefunc.o rmfshdl.o servclient.o setfntauth.o \
+ stfntcfnt.o xpstubs.o
+
+#undef _LinkBuildLibrary
+#define _LinkBuildLibrary(lib) LinkBuildLibrary(lib)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(fntstubs,$(OBJS))
+LintLibraryTarget(fntstubs,$(SRCS))
+InstallLibrary(fntstubs,$(USRLIBDIR))
+NormalLintTarget($(SRCS))
+DependTarget()
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/cauthgen.c b/nx-X11/lib/font/stubs/cauthgen.c
new file mode 100644
index 000000000..dec438d08
--- /dev/null
+++ b/nx-X11/lib/font/stubs/cauthgen.c
@@ -0,0 +1,14 @@
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+int
+client_auth_generation(ClientPtr client)
+{
+ return 0;
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/csignal.c b/nx-X11/lib/font/stubs/csignal.c
new file mode 100644
index 000000000..c957eb837
--- /dev/null
+++ b/nx-X11/lib/font/stubs/csignal.c
@@ -0,0 +1,14 @@
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+Bool
+ClientSignal(ClientPtr client)
+{
+ return True;
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/delfntcid.c b/nx-X11/lib/font/stubs/delfntcid.c
new file mode 100644
index 000000000..af5c0a881
--- /dev/null
+++ b/nx-X11/lib/font/stubs/delfntcid.c
@@ -0,0 +1,13 @@
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+void
+DeleteFontClientID(Font id)
+{
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/errorf.c b/nx-X11/lib/font/stubs/errorf.c
new file mode 100644
index 000000000..52c6042a6
--- /dev/null
+++ b/nx-X11/lib/font/stubs/errorf.c
@@ -0,0 +1,13 @@
+/* $XFree86: xc/lib/font/stubs/errorf.c,v 1.1 1999/01/11 05:13:19 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+void
+ErrorF(const char *f, ...)
+{
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/fatalerror.c b/nx-X11/lib/font/stubs/fatalerror.c
new file mode 100644
index 000000000..7dff1704d
--- /dev/null
+++ b/nx-X11/lib/font/stubs/fatalerror.c
@@ -0,0 +1,13 @@
+/* $XFree86: xc/lib/font/stubs/fatalerror.c,v 1.1 1999/01/11 05:13:19 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+void
+FatalError(const char *f, ...)
+{
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/findoldfnt.c b/nx-X11/lib/font/stubs/findoldfnt.c
new file mode 100644
index 000000000..218ecd479
--- /dev/null
+++ b/nx-X11/lib/font/stubs/findoldfnt.c
@@ -0,0 +1,14 @@
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+FontPtr
+find_old_font(FSID id)
+{
+ return (FontPtr)NULL;
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/getcres.c b/nx-X11/lib/font/stubs/getcres.c
new file mode 100644
index 000000000..da0de9174
--- /dev/null
+++ b/nx-X11/lib/font/stubs/getcres.c
@@ -0,0 +1,14 @@
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+FontResolutionPtr
+GetClientResolutions(int *num)
+{
+ return (FontResolutionPtr) 0;
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/getdefptsize.c b/nx-X11/lib/font/stubs/getdefptsize.c
new file mode 100644
index 000000000..10a46c86e
--- /dev/null
+++ b/nx-X11/lib/font/stubs/getdefptsize.c
@@ -0,0 +1,14 @@
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+int
+GetDefaultPointSize(void)
+{
+ return 0;
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/getnewfntcid.c b/nx-X11/lib/font/stubs/getnewfntcid.c
new file mode 100644
index 000000000..5a1e9270a
--- /dev/null
+++ b/nx-X11/lib/font/stubs/getnewfntcid.c
@@ -0,0 +1,14 @@
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+Font
+GetNewFontClientID(void)
+{
+ return (Font)0;
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/gettime.c b/nx-X11/lib/font/stubs/gettime.c
new file mode 100644
index 000000000..60a4e3951
--- /dev/null
+++ b/nx-X11/lib/font/stubs/gettime.c
@@ -0,0 +1,14 @@
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+unsigned long
+GetTimeInMillis (void)
+{
+ return 0;
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/initfshdl.c b/nx-X11/lib/font/stubs/initfshdl.c
new file mode 100644
index 000000000..15a337a29
--- /dev/null
+++ b/nx-X11/lib/font/stubs/initfshdl.c
@@ -0,0 +1,15 @@
+/* $XFree86: xc/lib/font/stubs/initfshdl.c,v 1.1 1999/01/11 05:13:20 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+int
+init_fs_handlers(FontPathElementPtr fpe,
+ BlockHandlerProcPtr block_handler)
+{
+ return Successful;
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/regfpefunc.c b/nx-X11/lib/font/stubs/regfpefunc.c
new file mode 100644
index 000000000..d6fcf3be3
--- /dev/null
+++ b/nx-X11/lib/font/stubs/regfpefunc.c
@@ -0,0 +1,28 @@
+/* $XFree86: xc/lib/font/stubs/regfpefunc.c,v 1.1 1999/01/11 05:13:20 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+int
+RegisterFPEFunctions(NameCheckFunc name_func,
+ InitFpeFunc init_func,
+ FreeFpeFunc free_func,
+ ResetFpeFunc reset_func,
+ OpenFontFunc open_func,
+ CloseFontFunc close_func,
+ ListFontsFunc list_func,
+ StartLfwiFunc start_lfwi_func,
+ NextLfwiFunc next_lfwi_func,
+ WakeupFpeFunc wakeup_func,
+ ClientDiedFunc client_died,
+ LoadGlyphsFunc load_glyphs,
+ StartLaFunc start_list_alias_func,
+ NextLaFunc next_list_alias_func,
+ SetPathFunc set_path_func)
+{
+ return 0;
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/rmfshdl.c b/nx-X11/lib/font/stubs/rmfshdl.c
new file mode 100644
index 000000000..ae0ab7863
--- /dev/null
+++ b/nx-X11/lib/font/stubs/rmfshdl.c
@@ -0,0 +1,15 @@
+/* $XFree86: xc/lib/font/stubs/rmfshdl.c,v 1.1 1999/01/11 05:13:21 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+void
+remove_fs_handlers(FontPathElementPtr fpe,
+ BlockHandlerProcPtr blockHandler,
+ Bool all)
+{
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/servclient.c b/nx-X11/lib/font/stubs/servclient.c
new file mode 100644
index 000000000..25c853f87
--- /dev/null
+++ b/nx-X11/lib/font/stubs/servclient.c
@@ -0,0 +1,3 @@
+/* $XFree86$ */
+
+void *serverClient = 0;
diff --git a/nx-X11/lib/font/stubs/setfntauth.c b/nx-X11/lib/font/stubs/setfntauth.c
new file mode 100644
index 000000000..843f155e5
--- /dev/null
+++ b/nx-X11/lib/font/stubs/setfntauth.c
@@ -0,0 +1,14 @@
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+int
+set_font_authorizations(char **authorizations, int *authlen, ClientPtr client)
+{
+ return 0;
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/stfntcfnt.c b/nx-X11/lib/font/stubs/stfntcfnt.c
new file mode 100644
index 000000000..c062677f6
--- /dev/null
+++ b/nx-X11/lib/font/stubs/stfntcfnt.c
@@ -0,0 +1,14 @@
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+int
+StoreFontClientFont(FontPtr pfont, Font id)
+{
+ return 0;
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/stubs.h b/nx-X11/lib/font/stubs/stubs.h
new file mode 100644
index 000000000..d687a77e3
--- /dev/null
+++ b/nx-X11/lib/font/stubs/stubs.h
@@ -0,0 +1,27 @@
+/* $XFree86: xc/lib/font/stubs/stubs.h,v 1.3 1999/12/15 01:14:36 robin Exp $ */
+
+/* This directory includes dummy entry for bdftopcf and mkfontdir */
+
+#include <stdio.h>
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/font.h>
+
+
+#ifndef True
+#define True (-1)
+#endif
+#ifndef False
+#define False (0)
+#endif
+
+extern FontPtr find_old_font ( FSID id );
+extern int set_font_authorizations ( char **authorizations,
+ int *authlen,
+ ClientPtr client );
+
+extern unsigned long GetTimeInMillis (void);
+
+extern void ErrorF(const char *format, ...);
+extern void FatalError(const char *format, ...);
+
+/* end of file */
diff --git a/nx-X11/lib/font/stubs/xpstubs.c b/nx-X11/lib/font/stubs/xpstubs.c
new file mode 100644
index 000000000..444915367
--- /dev/null
+++ b/nx-X11/lib/font/stubs/xpstubs.c
@@ -0,0 +1,24 @@
+/* $XFree86$ */
+
+/*
+ stub for XpClient* functions.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "stubs.h"
+
+Bool
+XpClientIsBitmapClient(ClientPtr client)
+{
+ return True;
+}
+
+Bool
+XpClientIsPrintClient(ClientPtr client, FontPathElementPtr fpe)
+{
+ return False;
+}
+
+/* end of file */
diff --git a/nx-X11/lib/font/util/Imakefile b/nx-X11/lib/font/util/Imakefile
new file mode 100644
index 000000000..6c318ba7f
--- /dev/null
+++ b/nx-X11/lib/font/util/Imakefile
@@ -0,0 +1,43 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:39 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/font/util/Imakefile,v 1.6 2000/12/07 16:40:30 dawes Exp $
+
+#include <Server.tmpl>
+
+ INCLUDES = -I$(FONTINCSRC) -I../include
+ HEADERS =
+#ifdef FontFormatDefines
+ FORMAT_DEFS = FontFormatDefines
+#endif
+
+#if defined(SunArchitecture) && (OSMajorVersion == 5) && (OSMinorVersion <= 6)
+ /* Work around a problem with __ctype being a "relocation against
+ allocatable but non-writable section" on Solaris 2.6. Hopefully
+ it doesn't break anything. */
+ SYS_DEFINES = -D__XPG4_CHAR_CLASS__
+#endif
+
+
+ DEFINES = StrcasecmpDefines $(SYS_DEFINES) $(INTERNALDEFINES)
+
+ SRCS = utilbitmap.c fontnames.c fontutil.c fontxlfd.c format.c \
+ fontaccel.c atom.c miscutil.c private.c patcache.c
+
+ OBJS = utilbitmap.o fontnames.o fontutil.o fontxlfd.o format.o \
+ fontaccel.o atom.o miscutil.o private.o patcache.o
+
+#define DoNormalLib NormalLibFont
+#define DoSharedLib SharedLibFont
+#define DoDebugLib DebugLibFont
+#define DoProfileLib ProfileLibFont
+#include <Library.tmpl>
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
diff --git a/nx-X11/lib/font/util/atom.c b/nx-X11/lib/font/util/atom.c
new file mode 100644
index 000000000..942ea0d46
--- /dev/null
+++ b/nx-X11/lib/font/util/atom.c
@@ -0,0 +1,233 @@
+/* $Xorg: atom.c,v 1.5 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+Copyright 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.
+
+*/
+/* $XFree86: xc/lib/font/util/atom.c,v 1.9 2002/09/19 13:22:00 tsi Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* lame atom replacement routines for font applications */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+
+typedef struct _AtomList {
+ char *name;
+ int len;
+ int hash;
+ Atom atom;
+} AtomListRec, *AtomListPtr;
+
+static AtomListPtr *hashTable;
+
+static int hashSize, hashUsed;
+static int hashMask;
+static int rehash;
+
+static AtomListPtr *reverseMap;
+static int reverseMapSize;
+static Atom lastAtom;
+
+static int
+Hash(char *string, int len)
+{
+ int h;
+
+ h = 0;
+ while (len--)
+ h = (h << 3) ^ *string++;
+ if (h < 0)
+ return -h;
+ return h;
+}
+
+static int
+ResizeHashTable (void)
+{
+ int newHashSize;
+ int newHashMask;
+ AtomListPtr *newHashTable;
+ int i;
+ int h;
+ int newRehash;
+ int r;
+
+ if (hashSize == 0)
+ newHashSize = 1024;
+ else
+ newHashSize = hashSize * 2;
+ newHashTable = (AtomListPtr *) xalloc (newHashSize * sizeof (AtomListPtr));
+ if (!newHashTable) {
+ fprintf(stderr, "ResizeHashTable(): Error: Couldn't allocate"
+ " newHashTable (%ld)\n",
+ newHashSize * (unsigned long)sizeof (AtomListPtr));
+ return FALSE;
+ }
+ bzero ((char *) newHashTable, newHashSize * sizeof (AtomListPtr));
+ newHashMask = newHashSize - 1;
+ newRehash = (newHashMask - 2);
+ for (i = 0; i < hashSize; i++)
+ {
+ if (hashTable[i])
+ {
+ h = (hashTable[i]->hash) & newHashMask;
+ if (newHashTable[h])
+ {
+ r = hashTable[i]->hash % newRehash | 1;
+ do {
+ h += r;
+ if (h >= newHashSize)
+ h -= newHashSize;
+ } while (newHashTable[h]);
+ }
+ newHashTable[h] = hashTable[i];
+ }
+ }
+ xfree (hashTable);
+ hashTable = newHashTable;
+ hashSize = newHashSize;
+ hashMask = newHashMask;
+ rehash = newRehash;
+ return TRUE;
+}
+
+static int
+ResizeReverseMap (void)
+{
+ int ret = TRUE;
+ if (reverseMapSize == 0)
+ reverseMapSize = 1000;
+ else
+ reverseMapSize *= 2;
+ reverseMap = (AtomListPtr *) xrealloc (reverseMap, reverseMapSize * sizeof (AtomListPtr));
+ if (!reverseMap) {
+ fprintf(stderr, "ResizeReverseMap(): Error: Couldn't reallocate"
+ " reverseMap (%ld)\n",
+ reverseMapSize * (unsigned long)sizeof(AtomListPtr));
+ ret = FALSE;
+ }
+ return ret;
+}
+
+static int
+NameEqual (const char *a, const char *b, int l)
+{
+ while (l--)
+ if (*a++ != *b++)
+ return FALSE;
+ return TRUE;
+}
+
+Atom
+MakeAtom(char *string, unsigned len, int makeit)
+{
+ AtomListPtr a;
+ int hash;
+ int h = 0;
+ int r;
+
+ hash = Hash (string, len);
+ if (hashTable)
+ {
+ h = hash & hashMask;
+ if (hashTable[h])
+ {
+ if (hashTable[h]->hash == hash && hashTable[h]->len == len &&
+ NameEqual (hashTable[h]->name, string, len))
+ {
+ return hashTable[h]->atom;
+ }
+ r = (hash % rehash) | 1;
+ for (;;)
+ {
+ h += r;
+ if (h >= hashSize)
+ h -= hashSize;
+ if (!hashTable[h])
+ break;
+ if (hashTable[h]->hash == hash && hashTable[h]->len == len &&
+ NameEqual (hashTable[h]->name, string, len))
+ {
+ return hashTable[h]->atom;
+ }
+ }
+ }
+ }
+ if (!makeit)
+ return None;
+ a = (AtomListPtr) xalloc (sizeof (AtomListRec) + len + 1);
+ if (a == NULL) {
+ fprintf(stderr, "MakeAtom(): Error: Couldn't allocate AtomListRec"
+ " (%ld)\n", (unsigned long)sizeof (AtomListRec) + len + 1);
+ return None;
+ }
+ a->name = (char *) (a + 1);
+ a->len = len;
+ strncpy (a->name, string, len);
+ a->name[len] = '\0';
+ a->atom = ++lastAtom;
+ a->hash = hash;
+ if (hashUsed >= hashSize / 2)
+ {
+ ResizeHashTable ();
+ h = hash & hashMask;
+ if (hashTable[h])
+ {
+ r = (hash % rehash) | 1;
+ do {
+ h += r;
+ if (h >= hashSize)
+ h -= hashSize;
+ } while (hashTable[h]);
+ }
+ }
+ hashTable[h] = a;
+ hashUsed++;
+ if (reverseMapSize <= a->atom) {
+ if (!ResizeReverseMap())
+ return None;
+ }
+ reverseMap[a->atom] = a;
+ return a->atom;
+}
+
+int
+ValidAtom(Atom atom)
+{
+ return (atom != None) && (atom <= lastAtom);
+}
+
+char *
+NameForAtom(Atom atom)
+{
+ if (atom != None && atom <= lastAtom)
+ return reverseMap[atom]->name;
+ return NULL;
+}
diff --git a/nx-X11/lib/font/util/fontaccel.c b/nx-X11/lib/font/util/fontaccel.c
new file mode 100644
index 000000000..c37f69a39
--- /dev/null
+++ b/nx-X11/lib/font/util/fontaccel.c
@@ -0,0 +1,107 @@
+/* $Xorg: fontaccel.c,v 1.4 2001/02/09 02:04:04 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.
+
+*/
+/* $XFree86: xc/lib/font/util/fontaccel.c,v 1.6 2001/01/17 19:43:33 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/fontutil.h>
+
+void
+FontComputeInfoAccelerators(FontInfoPtr pFontInfo)
+{
+ pFontInfo->noOverlap = FALSE;
+ if (pFontInfo->maxOverlap <= pFontInfo->minbounds.leftSideBearing)
+ pFontInfo->noOverlap = TRUE;
+
+ if ((pFontInfo->minbounds.ascent == pFontInfo->maxbounds.ascent) &&
+ (pFontInfo->minbounds.descent == pFontInfo->maxbounds.descent) &&
+ (pFontInfo->minbounds.leftSideBearing ==
+ pFontInfo->maxbounds.leftSideBearing) &&
+ (pFontInfo->minbounds.rightSideBearing ==
+ pFontInfo->maxbounds.rightSideBearing) &&
+ (pFontInfo->minbounds.characterWidth ==
+ pFontInfo->maxbounds.characterWidth) &&
+ (pFontInfo->minbounds.attributes == pFontInfo->maxbounds.attributes)) {
+ pFontInfo->constantMetrics = TRUE;
+ if ((pFontInfo->maxbounds.leftSideBearing == 0) &&
+ (pFontInfo->maxbounds.rightSideBearing ==
+ pFontInfo->maxbounds.characterWidth) &&
+ (pFontInfo->maxbounds.ascent == pFontInfo->fontAscent) &&
+ (pFontInfo->maxbounds.descent == pFontInfo->fontDescent))
+ pFontInfo->terminalFont = TRUE;
+ else
+ pFontInfo->terminalFont = FALSE;
+ } else {
+ pFontInfo->constantMetrics = FALSE;
+ pFontInfo->terminalFont = FALSE;
+ }
+ if (pFontInfo->minbounds.characterWidth == pFontInfo->maxbounds.characterWidth)
+ pFontInfo->constantWidth = TRUE;
+ else
+ pFontInfo->constantWidth = FALSE;
+
+ if ((pFontInfo->minbounds.leftSideBearing >= 0) &&
+ (pFontInfo->maxOverlap <= 0) &&
+ (pFontInfo->minbounds.ascent >= -pFontInfo->fontDescent) &&
+ (pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) &&
+ (-pFontInfo->minbounds.descent <= pFontInfo->fontAscent) &&
+ (pFontInfo->maxbounds.descent <= pFontInfo->fontDescent))
+ pFontInfo->inkInside = TRUE;
+ else
+ pFontInfo->inkInside = FALSE;
+}
+
+int
+FontCouldBeTerminal(FontInfoPtr pFontInfo)
+{
+ if ((pFontInfo->minbounds.leftSideBearing >= 0) &&
+ (pFontInfo->maxbounds.rightSideBearing <= pFontInfo->maxbounds.characterWidth) &&
+ (pFontInfo->minbounds.characterWidth == pFontInfo->maxbounds.characterWidth) &&
+ (pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) &&
+ (pFontInfo->maxbounds.descent <= pFontInfo->fontDescent) &&
+ (pFontInfo->maxbounds.leftSideBearing != 0 ||
+ pFontInfo->minbounds.rightSideBearing != pFontInfo->minbounds.characterWidth ||
+ pFontInfo->minbounds.ascent != pFontInfo->fontAscent ||
+ pFontInfo->minbounds.descent != pFontInfo->fontDescent)) {
+ /* blow off font with nothing but a SPACE */
+ if (pFontInfo->maxbounds.ascent == 0 &&
+ pFontInfo->maxbounds.descent == 0)
+ return FALSE;
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/nx-X11/lib/font/util/fontnames.c b/nx-X11/lib/font/util/fontnames.c
new file mode 100644
index 000000000..2d3a51752
--- /dev/null
+++ b/nx-X11/lib/font/util/fontnames.c
@@ -0,0 +1,123 @@
+/* $Xorg: fontnames.c,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/util/fontnames.c,v 1.4 2001/01/17 19:43:33 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ *
+ * @(#)fontnames.c 3.1 91/04/10
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+
+void
+FreeFontNames(FontNamesPtr pFN)
+{
+ int i;
+
+ if (!pFN)
+ return;
+ for (i = 0; i < pFN->nnames; i++) {
+ xfree(pFN->names[i]);
+ }
+ xfree(pFN->names);
+ xfree(pFN->length);
+ xfree(pFN);
+}
+
+FontNamesPtr
+MakeFontNamesRecord(unsigned int size)
+{
+ FontNamesPtr pFN;
+
+ pFN = (FontNamesPtr) xalloc(sizeof(FontNamesRec));
+ if (pFN) {
+ pFN->nnames = 0;
+ pFN->size = size;
+ if (size)
+ {
+ pFN->length = (int *) xalloc(size * sizeof(int));
+ pFN->names = (char **) xalloc(size * sizeof(char *));
+ if (!pFN->length || !pFN->names) {
+ xfree(pFN->length);
+ xfree(pFN->names);
+ xfree(pFN);
+ pFN = (FontNamesPtr) 0;
+ }
+ }
+ else
+ {
+ pFN->length = 0;
+ pFN->names = 0;
+ }
+ }
+ return pFN;
+}
+
+int
+AddFontNamesName(FontNamesPtr names, char *name, int length)
+{
+ int index = names->nnames;
+ char *nelt;
+
+ nelt = (char *) xalloc(length + 1);
+ if (!nelt)
+ return AllocError;
+ if (index >= names->size) {
+ int size = names->size << 1;
+ int *nlength;
+ char **nnames;
+
+ if (size == 0)
+ size = 8;
+ nlength = (int *) xrealloc(names->length, size * sizeof(int));
+ nnames = (char **) xrealloc(names->names, size * sizeof(char *));
+ if (nlength && nnames) {
+ names->size = size;
+ names->length = nlength;
+ names->names = nnames;
+ } else {
+ xfree(nelt);
+ xfree(nlength);
+ xfree(nnames);
+ return AllocError;
+ }
+ }
+ names->length[index] = length;
+ names->names[index] = nelt;
+ strncpy(nelt, name, length);
+ nelt[length] = '\0';
+ names->nnames++;
+ return Successful;
+}
diff --git a/nx-X11/lib/font/util/fontutil.c b/nx-X11/lib/font/util/fontutil.c
new file mode 100644
index 000000000..05fe5c2f2
--- /dev/null
+++ b/nx-X11/lib/font/util/fontutil.c
@@ -0,0 +1,443 @@
+/* $Xorg: fontutil.c,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/util/fontutil.c,v 3.6 2001/10/28 03:32:46 tsi Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/FSproto.h>
+#include <X11/fonts/fontutil.h>
+
+/* Define global here... doesn't hurt the servers, and avoids
+ unresolved references in font clients. */
+
+static int defaultGlyphCachingMode = DEFAULT_GLYPH_CACHING_MODE;
+int glyphCachingMode = DEFAULT_GLYPH_CACHING_MODE;
+
+void
+GetGlyphs(FontPtr font,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding fontEncoding,
+ unsigned long *glyphcount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
+{
+ (*font->get_glyphs) (font, count, chars, fontEncoding, glyphcount, glyphs);
+}
+
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#define MAX(a,b) ((a)>(b)?(a):(b))
+
+void
+QueryGlyphExtents(FontPtr pFont,
+ CharInfoPtr *charinfo,
+ unsigned long count,
+ ExtentInfoRec *info)
+{
+ register unsigned long i;
+ xCharInfo *pCI;
+
+ info->drawDirection = pFont->info.drawDirection;
+
+ info->fontAscent = pFont->info.fontAscent;
+ info->fontDescent = pFont->info.fontDescent;
+
+ if (count != 0) {
+
+ pCI = &((*charinfo)->metrics); charinfo++;
+ /* ignore nonexisting characters when calculating text extents */
+ if ( !((pCI->characterWidth == 0)
+ && (pCI->rightSideBearing == 0)
+ && (pCI->leftSideBearing == 0)
+ && (pCI->ascent == 0)
+ && (pCI->descent == 0)) ) {
+ info->overallAscent = pCI->ascent;
+ info->overallDescent = pCI->descent;
+ info->overallLeft = pCI->leftSideBearing;
+ info->overallRight = pCI->rightSideBearing;
+ info->overallWidth = pCI->characterWidth;
+ }
+
+ if (pFont->info.constantMetrics && pFont->info.noOverlap) {
+ info->overallWidth *= count;
+ info->overallRight += (info->overallWidth -
+ pCI->characterWidth);
+ } else {
+ for (i = 1; i < count; i++) {
+ pCI = &((*charinfo)->metrics); charinfo++;
+ /* ignore nonexisting characters when calculating extents */
+ if ( !((pCI->characterWidth == 0)
+ && (pCI->rightSideBearing == 0)
+ && (pCI->leftSideBearing == 0)
+ && (pCI->ascent == 0)
+ && (pCI->descent == 0)) ) {
+ info->overallAscent = MAX(
+ info->overallAscent,
+ pCI->ascent);
+ info->overallDescent = MAX(
+ info->overallDescent,
+ pCI->descent);
+ info->overallLeft = MIN(
+ info->overallLeft,
+ info->overallWidth + pCI->leftSideBearing);
+ info->overallRight = MAX(
+ info->overallRight,
+ info->overallWidth + pCI->rightSideBearing);
+ /*
+ * yes, this order is correct; overallWidth IS incremented
+ * last
+ */
+ info->overallWidth += pCI->characterWidth;
+ }
+ }
+ }
+ } else {
+ info->overallAscent = 0;
+ info->overallDescent = 0;
+ info->overallWidth = 0;
+ info->overallLeft = 0;
+ info->overallRight = 0;
+ }
+}
+
+Bool
+QueryTextExtents(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ ExtentInfoRec *info)
+{
+ xCharInfo **charinfo;
+ unsigned long n;
+ FontEncoding encoding;
+ int cm;
+ int i;
+ unsigned long t;
+ xCharInfo *defaultChar = 0;
+ unsigned char defc[2];
+ int firstReal;
+
+ charinfo = (xCharInfo **) xalloc(count * sizeof(xCharInfo *));
+ if (!charinfo)
+ return FALSE;
+ encoding = TwoD16Bit;
+ if (pFont->info.lastRow == 0)
+ encoding = Linear16Bit;
+ (*pFont->get_metrics) (pFont, count, chars, encoding, &n, charinfo);
+
+ /* Do default character substitution as get_metrics doesn't */
+
+#define IsNonExistentChar(ci) (!(ci) || \
+ ((ci)->ascent == 0 && \
+ (ci)->descent == 0 && \
+ (ci)->leftSideBearing == 0 && \
+ (ci)->rightSideBearing == 0 && \
+ (ci)->characterWidth == 0))
+
+ firstReal = n;
+ defc[0] = pFont->info.defaultCh >> 8;
+ defc[1] = pFont->info.defaultCh;
+ (*pFont->get_metrics) (pFont, 1, defc, encoding, &t, &defaultChar);
+ if ((IsNonExistentChar (defaultChar)))
+ defaultChar = 0;
+ for (i = 0; i < n; i++)
+ {
+ if ((IsNonExistentChar (charinfo[i])))
+ {
+ if (!defaultChar)
+ continue;
+ charinfo[i] = defaultChar;
+ }
+ if (firstReal == n)
+ firstReal = i;
+ }
+ cm = pFont->info.constantMetrics;
+ pFont->info.constantMetrics = FALSE;
+ QueryGlyphExtents(pFont, (CharInfoPtr*) charinfo + firstReal,
+ n - firstReal, info);
+ pFont->info.constantMetrics = cm;
+ xfree(charinfo);
+ return TRUE;
+}
+
+Bool
+ParseGlyphCachingMode(char *str)
+{
+ if (!strcmp(str, "none")) defaultGlyphCachingMode = CACHING_OFF;
+ else if (!strcmp(str, "all")) defaultGlyphCachingMode = CACHE_ALL_GLYPHS;
+ else if (!strcmp(str, "16")) defaultGlyphCachingMode = CACHE_16_BIT_GLYPHS;
+ else return FALSE;
+ return TRUE;
+}
+
+void
+InitGlyphCaching(void)
+{
+ /* Set glyphCachingMode to the mode the server hopes to
+ support. DDX drivers that do not support the requested level
+ of glyph caching can call SetGlyphCachingMode to lower the
+ level of support.
+ */
+
+ glyphCachingMode = defaultGlyphCachingMode;
+}
+
+/* ddxen can call SetGlyphCachingMode to inform us of what level of glyph
+ * caching they can support.
+ */
+void
+SetGlyphCachingMode(int newmode)
+{
+ if ( (glyphCachingMode > newmode) && (newmode >= 0) )
+ glyphCachingMode = newmode;
+}
+
+#define range_alloc_granularity 16
+#define mincharp(p) ((p)->min_char_low + ((p)->min_char_high << 8))
+#define maxcharp(p) ((p)->max_char_low + ((p)->max_char_high << 8))
+
+/* add_range(): Add range to a list of ranges, with coalescence */
+int
+add_range(fsRange *newrange,
+ int *nranges,
+ fsRange **range,
+ Bool charset_subset)
+{
+ int first, last, middle;
+ unsigned long keymin, keymax;
+ unsigned long ptrmin = 0, ptrmax = 0;
+ fsRange *ptr = NULL, *ptr1, *ptr2, *endptr;
+
+ /* There are two different ways to treat ranges:
+
+ 1) Charset subsetting (support of the HP XLFD enhancements), in
+ which a range of 0x1234,0x3456 means all numbers between
+ 0x1234 and 0x3456, and in which min and max might be swapped.
+
+ 2) Row/column ranges, in which a range of 0x1234,0x3456 means the
+ ranges 0x1234-0x1256, 0x1334-0x1356, ... , 0x3434-0x3456.
+ This is for support of glyph caching.
+
+ The choice of treatment is selected with the "charset_subset"
+ flag */
+
+ /* If newrange covers multiple rows; break up the rows */
+ if (!charset_subset && newrange->min_char_high != newrange->max_char_high)
+ {
+ int i, err = 0;
+ fsRange temprange;
+ for (i = newrange->min_char_high;
+ i <= newrange->max_char_high;
+ i++)
+ {
+ temprange.min_char_low = newrange->min_char_low;
+ temprange.max_char_low = newrange->max_char_low;
+ temprange.min_char_high = temprange.max_char_high = i;
+ err = add_range(&temprange, nranges, range, charset_subset);
+ if (err != Successful) break;
+ }
+ return err;
+ }
+
+ keymin = mincharp(newrange);
+ keymax = maxcharp(newrange);
+
+ if (charset_subset && keymin > keymax)
+ {
+ unsigned long temp = keymin;
+ keymin = keymax;
+ keymax = temp;
+ }
+
+ /* add_range() maintains a sorted list; this makes possible coalescence
+ and binary searches */
+
+ /* Binary search for a range with which the new range can merge */
+
+ first = middle = 0;
+ last = *nranges - 1;
+ while (last >= first)
+ {
+ middle = (first + last) / 2;
+ ptr = (*range) + middle;
+ ptrmin = mincharp(ptr);
+ ptrmax = maxcharp(ptr);
+
+ if (ptrmin > 0 && keymax < ptrmin - 1) last = middle - 1;
+ else if (keymin > ptrmax + 1) first = middle + 1;
+ else if (!charset_subset)
+ {
+ /* We might have a range with which to merge... IF the
+ result doesn't cross rows */
+ if (newrange->min_char_high != ptr->min_char_high)
+ last = first - 1; /* Force adding a new range */
+ break;
+ }
+ else break; /* We have at least one range with which we can merge */
+ }
+
+ if (last < first)
+ {
+ /* Search failed; we need to add a new range to the list. */
+
+ /* Grow the list if necessary */
+ if (*nranges == 0 || *range == (fsRange *)0)
+ {
+ *range = (fsRange *)xalloc(range_alloc_granularity *
+ SIZEOF(fsRange));
+ *nranges = 0;
+ }
+ else if (!(*nranges % range_alloc_granularity))
+ {
+ *range = (fsRange *)xrealloc((char *)*range,
+ (*nranges + range_alloc_granularity) *
+ SIZEOF(fsRange));
+ }
+
+ /* If alloc failed, just return a null list */
+ if (*range == (fsRange *)0)
+ {
+ *nranges = 0;
+ return AllocError;
+ }
+
+ /* Should new entry go *at* or *after* ptr? */
+ ptr = (*range) + middle;
+ if (middle < *nranges && keymin > ptrmin) ptr++; /* after */
+
+ /* Open up a space for our new range */
+ memmove((char *)(ptr + 1),
+ (char *)ptr,
+ (char *)(*range + *nranges) - (char *)ptr);
+
+ /* Insert the new range */
+ ptr->min_char_low = keymin & 0xff;
+ ptr->min_char_high = keymin >> 8;
+ ptr->max_char_low = keymax & 0xff;
+ ptr->max_char_high = keymax >> 8;
+
+ /* Update range count */
+ (*nranges)++;
+
+ /* Done */
+ return Successful;
+ }
+
+ /* Join our new range to that pointed to by "ptr" */
+ if (keymin < ptrmin)
+ {
+ ptr->min_char_low = keymin & 0xff;
+ ptr->min_char_high = keymin >> 8;
+ }
+ if (keymax > ptrmax)
+ {
+ ptr->max_char_low = keymax & 0xff;
+ ptr->max_char_high = keymax >> 8;
+ }
+
+ ptrmin = mincharp(ptr);
+ ptrmax = maxcharp(ptr);
+
+ endptr = *range + *nranges;
+
+ for (ptr1 = ptr; ptr1 >= *range; ptr1--)
+ {
+ if (ptrmin <= maxcharp(ptr1) + 1)
+ {
+ if (!charset_subset && ptr->min_char_high != ptr1->min_char_high)
+ break;
+ if (ptrmin >= mincharp(ptr1))
+ ptrmin = mincharp(ptr1);
+ }
+ else break;
+ }
+ for (ptr2 = ptr; ptr2 < endptr; ptr2++)
+ {
+ if ((ptr2->min_char_low == 0 && ptr2->min_char_high == 0) ||
+ ptrmax >= mincharp(ptr2) - 1)
+ {
+ if (!charset_subset && ptr->min_char_high != ptr2->min_char_high)
+ break;
+ if (ptrmax <= maxcharp(ptr2))
+ ptrmax = maxcharp(ptr2);
+ }
+ else break;
+ }
+
+ /* We need to coalesce ranges between ptr1 and ptr2 exclusive */
+ ptr1++;
+ ptr2--;
+ if (ptr1 != ptr2)
+ {
+ memmove(ptr1, ptr2, (char *)endptr - (char *)ptr2);
+ *nranges -= (ptr2 - ptr1);
+ }
+
+ /* Write the new range into the range list */
+ ptr1->min_char_low = ptrmin & 0xff;
+ ptr1->min_char_high = ptrmin >> 8;
+ ptr1->max_char_low = ptrmax & 0xff;
+ ptr1->max_char_high = ptrmax >> 8;
+
+ return Successful;
+}
+
+/* It is difficult to find a good place for this. */
+#ifdef NEED_STRCASECMP
+int
+f_strcasecmp(const char *s1, const char *s2)
+{
+ char c1, c2;
+
+ if (*s1 == 0)
+ if (*s2 == 0)
+ return 0;
+ else
+ return 1;
+
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ while (c1 == c2) {
+ if (c1 == '\0')
+ return 0;
+ s1++;
+ s2++;
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ }
+ return c1 - c2;
+}
+#endif
+
diff --git a/nx-X11/lib/font/util/fontxlfd.c b/nx-X11/lib/font/util/fontxlfd.c
new file mode 100644
index 000000000..7adf74f4c
--- /dev/null
+++ b/nx-X11/lib/font/util/fontxlfd.c
@@ -0,0 +1,637 @@
+/* $Xorg: fontxlfd.c,v 1.4 2001/02/09 02:04:04 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.
+
+*/
+/* $XFree86: xc/lib/font/util/fontxlfd.c,v 3.16tsi Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/fontxlfd.h>
+#include <X11/fonts/fontutil.h>
+#include <X11/Xos.h>
+#include <math.h>
+#include <stdlib.h>
+#if defined(sony) && !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV)
+#define NO_LOCALE
+#endif
+#ifndef NO_LOCALE
+#include <locale.h>
+#endif
+#include <ctype.h>
+#include <stdio.h> /* for sprintf() */
+
+static char *
+GetInt(char *ptr, int *val)
+{
+ if (*ptr == '*') {
+ *val = -1;
+ ptr++;
+ } else
+ for (*val = 0; *ptr >= '0' && *ptr <= '9';)
+ *val = *val * 10 + *ptr++ - '0';
+ if (*ptr == '-')
+ return ptr;
+ return (char *) 0;
+}
+
+#define minchar(p) ((p).min_char_low + ((p).min_char_high << 8))
+#define maxchar(p) ((p).max_char_low + ((p).max_char_high << 8))
+
+
+#ifndef NO_LOCALE
+static struct lconv *locale = 0;
+#endif
+static char *radix = ".", *plus = "+", *minus = "-";
+
+static char *
+readreal(char *ptr, double *result)
+{
+ char buffer[80], *p1, *p2;
+
+#ifndef NO_LOCALE
+ /* Figure out what symbols apply in this locale */
+
+ if (!locale)
+ {
+ locale = localeconv();
+ if (locale->decimal_point && *locale->decimal_point)
+ radix = locale->decimal_point;
+ if (locale->positive_sign && *locale->positive_sign)
+ plus = locale->positive_sign;
+ if (locale->negative_sign && *locale->negative_sign)
+ minus = locale->negative_sign;
+ }
+#endif
+ /* Copy the first 80 chars of ptr into our local buffer, changing
+ symbols as needed. */
+ for (p1 = ptr, p2 = buffer;
+ *p1 && (p2 - buffer) < sizeof(buffer) - 1;
+ p1++, p2++)
+ {
+ switch(*p1)
+ {
+ case '~': *p2 = *minus; break;
+ case '+': *p2 = *plus; break;
+ case '.': *p2 = *radix; break;
+ default: *p2 = *p1;
+ }
+ }
+ *p2 = 0;
+
+ /* Now we have something that strtod() can interpret... do it. */
+ *result = strtod(buffer, &p1);
+ /* Return NULL if failure, pointer past number if success */
+ return (p1 == buffer) ? (char *)0 : (ptr + (p1 - buffer));
+}
+
+static char *
+xlfd_double_to_text(double value, char *buffer, int space_required)
+{
+ char formatbuf[40];
+ register char *p1;
+ int ndigits, exponent;
+
+#ifndef NO_LOCALE
+ if (!locale)
+ {
+ locale = localeconv();
+ if (locale->decimal_point && *locale->decimal_point)
+ radix = locale->decimal_point;
+ if (locale->positive_sign && *locale->positive_sign)
+ plus = locale->positive_sign;
+ if (locale->negative_sign && *locale->negative_sign)
+ minus = locale->negative_sign;
+ }
+#endif
+ /* Compute a format to use to render the number */
+ sprintf(formatbuf, "%%.%dle", XLFD_NDIGITS);
+
+ if (space_required)
+ *buffer++ = ' ';
+
+ /* Render the number using printf's idea of formatting */
+ sprintf(buffer, formatbuf, value);
+
+ /* Find and read the exponent value */
+ for (p1 = buffer + strlen(buffer);
+ *p1-- != 'e' && p1[1] != 'E';);
+ exponent = atoi(p1 + 2);
+ if (value == 0.0) exponent = 0;
+
+ /* Figure out how many digits are significant */
+ while (p1 >= buffer && (!isdigit(*p1) || *p1 == '0')) p1--;
+ ndigits = 0;
+ while (p1 >= buffer) if (isdigit(*p1--)) ndigits++;
+
+ /* Figure out notation to use */
+ if (exponent >= XLFD_NDIGITS || ndigits - exponent > XLFD_NDIGITS + 1)
+ {
+ /* Scientific */
+ sprintf(formatbuf, "%%.%dle", ndigits - 1);
+ sprintf(buffer, formatbuf, value);
+ }
+ else
+ {
+ /* Fixed */
+ ndigits -= exponent + 1;
+ if (ndigits < 0) ndigits = 0;
+ sprintf(formatbuf, "%%.%dlf", ndigits);
+ sprintf(buffer, formatbuf, value);
+ if (exponent < 0)
+ {
+ p1 = buffer;
+ while (*p1 && *p1 != '0') p1++;
+ while (*p1++) p1[-1] = *p1;
+ }
+ }
+
+ /* Last step, convert the locale-specific sign and radix characters
+ to our own. */
+ for (p1 = buffer; *p1; p1++)
+ {
+ if (*p1 == *minus) *p1 = '~';
+ else if (*p1 == *plus) *p1 = '+';
+ else if (*p1 == *radix) *p1 = '.';
+ }
+
+ return buffer - space_required;
+}
+
+double
+xlfd_round_double(double x)
+{
+ /* Utility for XLFD users to round numbers to XLFD_NDIGITS
+ significant digits. How do you round to n significant digits on
+ a binary machine? */
+
+#if defined(i386) || defined(__i386__) || \
+ defined(ia64) || defined(__ia64__) || \
+ defined(__alpha__) || defined(__alpha) || \
+ defined(__hppa__) || \
+ defined(__amd64__) || defined(__amd64) || \
+ defined(sgi)
+#if !defined(__UNIXOS2__)
+#include <float.h>
+
+/* if we have IEEE 754 fp, we can round to binary digits... */
+
+#if (FLT_RADIX == 2) && (DBL_DIG == 15) && (DBL_MANT_DIG == 53)
+
+#ifndef M_LN2
+#define M_LN2 0.69314718055994530942
+#endif
+#ifndef M_LN10
+#define M_LN10 2.30258509299404568402
+#endif
+
+/* convert # of decimal digits to # of binary digits */
+#define XLFD_NDIGITS_2 ((int)(XLFD_NDIGITS * M_LN10 / M_LN2 + 0.5))
+
+ union conv_d {
+ double d;
+ unsigned char b[8];
+ } d;
+ int i,j,k,d_exp;
+
+ if (x == 0)
+ return x;
+
+ /* do minor sanity check for IEEE 754 fp and correct byte order */
+ d.d = 1.0;
+ if (sizeof(double) == 8 && d.b[7] == 0x3f && d.b[6] == 0xf0) {
+
+ /*
+ * this code will round IEEE 754 double to XLFD_NDIGITS_2 binary digits
+ */
+
+ d.d = x;
+ d_exp = (d.b[7] << 4) | (d.b[6] >> 4);
+
+ i = (DBL_MANT_DIG-XLFD_NDIGITS_2) >> 3;
+ j = 1 << ((DBL_MANT_DIG-XLFD_NDIGITS_2) & 0x07);
+ for (; i<7; i++) {
+ k = d.b[i] + j;
+ d.b[i] = k;
+ if (k & 0x100) j = 1;
+ else break;
+ }
+ if ((i==7) && ((d.b[6] & 0xf0) != ((d_exp<<4) & 0xf0))) {
+ /* mantissa overflow: increment exponent */
+ d_exp = (d_exp & 0x800 ) | ((d_exp & 0x7ff) + 1);
+ d.b[7] = d_exp >> 4;
+ d.b[6] = (d.b[6] & 0x0f) | (d_exp << 4);
+ }
+
+ i = (DBL_MANT_DIG-XLFD_NDIGITS_2) >> 3;
+ j = 1 << ((DBL_MANT_DIG-XLFD_NDIGITS_2) & 0x07);
+ d.b[i] &= ~(j-1);
+ for (;--i>=0;) d.b[i] = 0;
+
+ return d.d;
+ }
+ else
+#endif
+#endif /* !__UNIXOS2__ */
+#endif /* i386 || __i386__ */
+ {
+ /*
+ * If not IEEE 754: Let printf() do it for you.
+ */
+
+ char formatbuf[40], buffer[40];
+
+ sprintf(formatbuf, "%%.%dlg", XLFD_NDIGITS);
+ sprintf(buffer, formatbuf, x);
+ return atof(buffer);
+ }
+}
+
+static char *
+GetMatrix(char *ptr, FontScalablePtr vals, int which)
+{
+ double *matrix;
+
+ if (which == PIXELSIZE_MASK)
+ matrix = vals->pixel_matrix;
+ else if (which == POINTSIZE_MASK)
+ matrix = vals->point_matrix;
+ else return (char *)0;
+
+ while (isspace(*ptr)) ptr++;
+ if (*ptr == '[')
+ {
+ /* This is a matrix containing real numbers. It would be nice
+ to use strtod() or sscanf() to read the numbers, but those
+ don't handle '~' for minus and we cannot force them to use a
+ "." for the radix. We'll have to do the hard work ourselves
+ (in readreal()). */
+
+ if ((ptr = readreal(++ptr, matrix + 0)) &&
+ (ptr = readreal(ptr, matrix + 1)) &&
+ (ptr = readreal(ptr, matrix + 2)) &&
+ (ptr = readreal(ptr, matrix + 3)))
+ {
+ while (isspace(*ptr)) ptr++;
+ if (*ptr != ']')
+ ptr = (char *)0;
+ else
+ {
+ ptr++;
+ while (isspace(*ptr)) ptr++;
+ if (*ptr == '-')
+ {
+ if (which == POINTSIZE_MASK)
+ vals->values_supplied |= POINTSIZE_ARRAY;
+ else
+ vals->values_supplied |= PIXELSIZE_ARRAY;
+ }
+ else ptr = (char *)0;
+ }
+ }
+ }
+ else
+ {
+ int value;
+ if ((ptr = GetInt(ptr, &value)))
+ {
+ vals->values_supplied &= ~which;
+ if (value > 0)
+ {
+ matrix[3] = (double)value;
+ if (which == POINTSIZE_MASK)
+ {
+ matrix[3] /= 10.0;
+ vals->values_supplied |= POINTSIZE_SCALAR;
+ }
+ else
+ vals->values_supplied |= PIXELSIZE_SCALAR;
+ /* If we're concocting the pixelsize array from a scalar,
+ we will need to normalize element 0 for the pixel shape.
+ This is done in FontFileCompleteXLFD(). */
+ matrix[0] = matrix[3];
+ matrix[1] = matrix[2] = 0.0;
+ }
+ else if (value < 0)
+ {
+ if (which == POINTSIZE_MASK)
+ vals->values_supplied |= POINTSIZE_WILDCARD;
+ else
+ vals->values_supplied |= PIXELSIZE_WILDCARD;
+ }
+ }
+ }
+ return ptr;
+}
+
+
+static void
+append_ranges(char *fname, int nranges, fsRange *ranges)
+{
+ if (nranges)
+ {
+ int i;
+
+ strcat(fname, "[");
+ for (i = 0; i < nranges && strlen(fname) < 1010; i++)
+ {
+ if (i) strcat(fname, " ");
+ sprintf(fname + strlen(fname), "%d",
+ minchar(ranges[i]));
+ if (ranges[i].min_char_low ==
+ ranges[i].max_char_low &&
+ ranges[i].min_char_high ==
+ ranges[i].max_char_high) continue;
+ sprintf(fname + strlen(fname), "_%d",
+ maxchar(ranges[i]));
+ }
+ strcat(fname, "]");
+ }
+}
+
+Bool
+FontParseXLFDName(char *fname, FontScalablePtr vals, int subst)
+{
+ register char *ptr;
+ register char *ptr1,
+ *ptr2,
+ *ptr3,
+ *ptr4;
+ register char *ptr5;
+ FontScalableRec tmpvals;
+ char replaceChar = '0';
+ char tmpBuf[1024];
+ int spacingLen;
+ int l;
+ char *p;
+
+ bzero(&tmpvals, sizeof(tmpvals));
+ if (subst != FONT_XLFD_REPLACE_VALUE)
+ *vals = tmpvals;
+
+ if (!(*(ptr = fname) == '-' || (*ptr++ == '*' && *ptr == '-')) || /* fndry */
+ !(ptr = strchr(ptr + 1, '-')) || /* family_name */
+ !(ptr1 = ptr = strchr(ptr + 1, '-')) || /* weight_name */
+ !(ptr = strchr(ptr + 1, '-')) || /* slant */
+ !(ptr = strchr(ptr + 1, '-')) || /* setwidth_name */
+ !(ptr = strchr(ptr + 1, '-')) || /* add_style_name */
+ !(ptr = strchr(ptr + 1, '-')) || /* pixel_size */
+ !(ptr = GetMatrix(ptr + 1, &tmpvals, PIXELSIZE_MASK)) ||
+ !(ptr2 = ptr = GetMatrix(ptr + 1, &tmpvals, POINTSIZE_MASK)) ||
+ !(ptr = GetInt(ptr + 1, &tmpvals.x)) || /* resolution_x */
+ !(ptr3 = ptr = GetInt(ptr + 1, &tmpvals.y)) || /* resolution_y */
+ !(ptr4 = ptr = strchr(ptr + 1, '-')) || /* spacing */
+ !(ptr5 = ptr = GetInt(ptr + 1, &tmpvals.width)) || /* average_width */
+ !(ptr = strchr(ptr + 1, '-')) || /* charset_registry */
+ strchr(ptr + 1, '-'))/* charset_encoding */
+ return FALSE;
+
+ /* Lop off HP charset subsetting enhancement. Interpreting this
+ field requires allocating some space in which to return the
+ results. So, to prevent memory leaks, this procedure will simply
+ lop off and ignore charset subsetting, and initialize the
+ relevant vals fields to zero. It's up to the caller to make its
+ own call to FontParseRanges() if it's interested in the charset
+ subsetting. */
+
+ if (subst != FONT_XLFD_REPLACE_NONE &&
+ (p = strchr(strrchr(fname, '-'), '[')))
+ {
+ tmpvals.values_supplied |= CHARSUBSET_SPECIFIED;
+ *p = '\0';
+ }
+
+ /* Fill in deprecated fields for the benefit of rasterizers that care
+ about them. */
+ tmpvals.pixel = (tmpvals.pixel_matrix[3] >= 0) ?
+ (int)(tmpvals.pixel_matrix[3] + .5) :
+ (int)(tmpvals.pixel_matrix[3] - .5);
+ tmpvals.point = (tmpvals.point_matrix[3] >= 0) ?
+ (int)(tmpvals.point_matrix[3] * 10 + .5) :
+ (int)(tmpvals.point_matrix[3] * 10 - .5);
+
+ spacingLen = ptr4 - ptr3 + 1;
+
+ switch (subst) {
+ case FONT_XLFD_REPLACE_NONE:
+ *vals = tmpvals;
+ break;
+ case FONT_XLFD_REPLACE_STAR:
+ replaceChar = '*';
+ case FONT_XLFD_REPLACE_ZERO:
+ strcpy(tmpBuf, ptr2);
+ ptr5 = tmpBuf + (ptr5 - ptr2);
+ ptr3 = tmpBuf + (ptr3 - ptr2);
+ ptr2 = tmpBuf;
+ ptr = ptr1 + 1;
+
+ ptr = strchr(ptr, '-') + 1; /* skip weight */
+ ptr = strchr(ptr, '-') + 1; /* skip slant */
+ ptr = strchr(ptr, '-') + 1; /* skip setwidth_name */
+ ptr = strchr(ptr, '-') + 1; /* skip add_style_name */
+
+ if ((ptr - fname) + spacingLen + strlen(ptr5) + 10 >= (unsigned)1024)
+ return FALSE;
+ *ptr++ = replaceChar;
+ *ptr++ = '-';
+ *ptr++ = replaceChar;
+ *ptr++ = '-';
+ *ptr++ = '*';
+ *ptr++ = '-';
+ *ptr++ = '*';
+ if (spacingLen > 2)
+ {
+ memmove(ptr, ptr3, spacingLen);
+ ptr += spacingLen;
+ }
+ else
+ {
+ *ptr++ = '-';
+ *ptr++ = '*';
+ *ptr++ = '-';
+ }
+ *ptr++ = replaceChar;
+ strcpy(ptr, ptr5);
+ *vals = tmpvals;
+ break;
+ case FONT_XLFD_REPLACE_VALUE:
+ if (vals->values_supplied & PIXELSIZE_MASK)
+ {
+ tmpvals.values_supplied =
+ (tmpvals.values_supplied & ~PIXELSIZE_MASK) |
+ (vals->values_supplied & PIXELSIZE_MASK);
+ tmpvals.pixel_matrix[0] = vals->pixel_matrix[0];
+ tmpvals.pixel_matrix[1] = vals->pixel_matrix[1];
+ tmpvals.pixel_matrix[2] = vals->pixel_matrix[2];
+ tmpvals.pixel_matrix[3] = vals->pixel_matrix[3];
+ }
+ if (vals->values_supplied & POINTSIZE_MASK)
+ {
+ tmpvals.values_supplied =
+ (tmpvals.values_supplied & ~POINTSIZE_MASK) |
+ (vals->values_supplied & POINTSIZE_MASK);
+ tmpvals.point_matrix[0] = vals->point_matrix[0];
+ tmpvals.point_matrix[1] = vals->point_matrix[1];
+ tmpvals.point_matrix[2] = vals->point_matrix[2];
+ tmpvals.point_matrix[3] = vals->point_matrix[3];
+ }
+ if (vals->x >= 0)
+ tmpvals.x = vals->x;
+ if (vals->y >= 0)
+ tmpvals.y = vals->y;
+ if (vals->width >= 0)
+ tmpvals.width = vals->width;
+ else if (vals->width < -1) /* overload: -1 means wildcard */
+ tmpvals.width = -vals->width;
+
+
+ p = ptr1 + 1; /* weight field */
+ l = strchr(p, '-') - p;
+ sprintf(tmpBuf, "%*.*s", l, l, p);
+
+ p += l + 1; /* slant field */
+ l = strchr(p, '-') - p;
+ sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p);
+
+ p += l + 1; /* setwidth_name */
+ l = strchr(p, '-') - p;
+ sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p);
+
+ p += l + 1; /* add_style_name field */
+ l = strchr(p, '-') - p;
+ sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p);
+
+ strcat(tmpBuf, "-");
+ if ((tmpvals.values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY)
+ {
+ char buffer[80];
+ strcat(tmpBuf, "[");
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[0],
+ buffer, 0));
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[1],
+ buffer, 1));
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[2],
+ buffer, 1));
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[3],
+ buffer, 1));
+ strcat(tmpBuf, "]");
+ }
+ else
+ {
+ sprintf(tmpBuf + strlen(tmpBuf), "%d",
+ (int)(tmpvals.pixel_matrix[3] + .5));
+ }
+ strcat(tmpBuf, "-");
+ if ((tmpvals.values_supplied & POINTSIZE_MASK) == POINTSIZE_ARRAY)
+ {
+ char buffer[80];
+ strcat(tmpBuf, "[");
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[0],
+ buffer, 0));
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[1],
+ buffer, 1));
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[2],
+ buffer, 1));
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[3],
+ buffer, 1));
+ strcat(tmpBuf, "]");
+ }
+ else
+ {
+ sprintf(tmpBuf + strlen(tmpBuf), "%d",
+ (int)(tmpvals.point_matrix[3] * 10.0 + .5));
+ }
+ sprintf(tmpBuf + strlen(tmpBuf), "-%d-%d%*.*s%d%s",
+ tmpvals.x, tmpvals.y,
+ spacingLen, spacingLen, ptr3, tmpvals.width, ptr5);
+ strcpy(ptr1 + 1, tmpBuf);
+ if ((vals->values_supplied & CHARSUBSET_SPECIFIED) && !vals->nranges)
+ strcat(fname, "[]");
+ else
+ append_ranges(fname, vals->nranges, vals->ranges);
+ break;
+ }
+ return TRUE;
+}
+
+fsRange *FontParseRanges(char *name, int *nranges)
+{
+ int n;
+ unsigned long l;
+ char *p1, *p2;
+ fsRange *result = (fsRange *)0;
+
+ name = strchr(name, '-');
+ for (n = 1; name && n < 14; n++)
+ name = strchr(name + 1, '-');
+
+ *nranges = 0;
+ if (!name || !(p1 = strchr(name, '['))) return (fsRange *)0;
+ p1++;
+
+ while (*p1 && *p1 != ']')
+ {
+ fsRange thisrange;
+
+ l = strtol(p1, &p2, 0);
+ if (p2 == p1 || l > 0xffff) break;
+ thisrange.max_char_low = thisrange.min_char_low = l & 0xff;
+ thisrange.max_char_high = thisrange.min_char_high = l >> 8;
+
+ p1 = p2;
+ if (*p1 == ']' || *p1 == ' ')
+ {
+ while (*p1 == ' ') p1++;
+ if (add_range(&thisrange, nranges, &result, TRUE) != Successful)
+ break;
+ }
+ else if (*p1 == '_')
+ {
+ l = strtol(++p1, &p2, 0);
+ if (p2 == p1 || l > 0xffff) break;
+ thisrange.max_char_low = l & 0xff;
+ thisrange.max_char_high = l >> 8;
+ p1 = p2;
+ if (*p1 == ']' || *p1 == ' ')
+ {
+ while (*p1 == ' ') p1++;
+ if (add_range(&thisrange, nranges, &result, TRUE) != Successful)
+ break;
+ }
+ }
+ else break;
+ }
+
+ return result;
+}
diff --git a/nx-X11/lib/font/util/format.c b/nx-X11/lib/font/util/format.c
new file mode 100644
index 000000000..6700721f9
--- /dev/null
+++ b/nx-X11/lib/font/util/format.c
@@ -0,0 +1,126 @@
+/* $Xorg: format.c,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment 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 names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Network Computing
+ * Devices and Digital make no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR 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, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/util/format.c,v 1.4 2001/01/17 19:43:33 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/FSproto.h>
+#include <X11/fonts/font.h>
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/fontutil.h>
+
+int
+CheckFSFormat(fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ int *bit_order,
+ int *byte_order,
+ int *scan,
+ int *glyph,
+ int *image)
+{
+ /* convert format to what the low levels want */
+ if (fmask & BitmapFormatMaskBit) {
+ *bit_order = format & BitmapFormatBitOrderMask;
+ *bit_order = (*bit_order == BitmapFormatBitOrderMSB)
+ ? MSBFirst : LSBFirst;
+ }
+ if (fmask & BitmapFormatMaskByte) {
+ *byte_order = format & BitmapFormatByteOrderMask;
+ *byte_order = (*byte_order == BitmapFormatByteOrderMSB)
+ ? MSBFirst : LSBFirst;
+ }
+ if (fmask & BitmapFormatMaskScanLineUnit) {
+ *scan = format & BitmapFormatScanlineUnitMask;
+ /* convert byte paddings into byte counts */
+ switch (*scan) {
+ case BitmapFormatScanlineUnit8:
+ *scan = 1;
+ break;
+ case BitmapFormatScanlineUnit16:
+ *scan = 2;
+ break;
+ case BitmapFormatScanlineUnit32:
+ *scan = 4;
+ break;
+ default:
+ return BadFontFormat;
+ }
+ }
+ if (fmask & BitmapFormatMaskScanLinePad) {
+ *glyph = format & BitmapFormatScanlinePadMask;
+ /* convert byte paddings into byte counts */
+ switch (*glyph) {
+ case BitmapFormatScanlinePad8:
+ *glyph = 1;
+ break;
+ case BitmapFormatScanlinePad16:
+ *glyph = 2;
+ break;
+ case BitmapFormatScanlinePad32:
+ *glyph = 4;
+ break;
+ default:
+ return BadFontFormat;
+ }
+ }
+ if (fmask & BitmapFormatMaskImageRectangle) {
+ *image = format & BitmapFormatImageRectMask;
+
+ if (*image != BitmapFormatImageRectMin &&
+ *image != BitmapFormatImageRectMaxWidth &&
+ *image != BitmapFormatImageRectMax)
+ return BadFontFormat;
+ }
+ return Successful;
+}
diff --git a/nx-X11/lib/font/util/miscutil.c b/nx-X11/lib/font/util/miscutil.c
new file mode 100644
index 000000000..03b4d061d
--- /dev/null
+++ b/nx-X11/lib/font/util/miscutil.c
@@ -0,0 +1,99 @@
+/* $Xorg: miscutil.c,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/util/miscutil.c,v 1.7 2001/07/25 15:04:57 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xosdefs.h>
+#include <stdlib.h>
+#include <X11/fonts/fontmisc.h>
+
+#define XK_LATIN1
+#include <X11/keysymdef.h>
+/* #include <X11/Xmu/CharSet.h> */
+
+/* make sure everything initializes themselves at least once */
+
+long serverGeneration = 1;
+
+void *
+Xalloc (unsigned long m)
+{
+ return malloc (m);
+}
+
+void *
+Xrealloc (void *n, unsigned long m)
+{
+ if (!n)
+ return malloc (m);
+ else
+ return realloc (n, m);
+}
+
+void
+Xfree (void *n)
+{
+ if (n)
+ free (n);
+}
+
+void *
+Xcalloc (unsigned long n)
+{
+ return calloc (n, 1);
+}
+
+void
+CopyISOLatin1Lowered (char *dst, char *src, int len)
+{
+ register unsigned char *dest, *source;
+
+ for (dest = (unsigned char *)dst, source = (unsigned char *)src;
+ *source && len > 0;
+ source++, dest++, len--)
+ {
+ if ((*source >= XK_A) && (*source <= XK_Z))
+ *dest = *source + (XK_a - XK_A);
+ else if ((*source >= XK_Agrave) && (*source <= XK_Odiaeresis))
+ *dest = *source + (XK_agrave - XK_Agrave);
+ else if ((*source >= XK_Ooblique) && (*source <= XK_Thorn))
+ *dest = *source + (XK_oslash - XK_Ooblique);
+ else
+ *dest = *source;
+ }
+ *dest = '\0';
+}
+
+void
+register_fpe_functions ()
+{
+}
diff --git a/nx-X11/lib/font/util/patcache.c b/nx-X11/lib/font/util/patcache.c
new file mode 100644
index 000000000..0351b1ac2
--- /dev/null
+++ b/nx-X11/lib/font/util/patcache.c
@@ -0,0 +1,221 @@
+/* $Xorg: patcache.c,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/util/patcache.c,v 3.4 2001/01/17 19:43:33 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+
+/*
+ * Static sized hash table for looking up font name patterns
+ *
+ * LRU entries, reusing old entries
+ */
+
+#define NBUCKETS 16
+#define NENTRIES 64
+
+#define UNSET (NENTRIES+1)
+
+typedef unsigned char EntryPtr;
+
+typedef struct _FontPatternCacheEntry {
+ struct _FontPatternCacheEntry *next, **prev;
+ short patlen;
+ char *pattern;
+ int hash;
+ FontPtr pFont; /* associated font */
+} FontPatternCacheEntryRec, *FontPatternCacheEntryPtr;
+
+typedef struct _FontPatternCache {
+ FontPatternCacheEntryPtr buckets[NBUCKETS];
+ FontPatternCacheEntryRec entries[NENTRIES];
+ FontPatternCacheEntryPtr free;
+} FontPatternCacheRec;
+
+/* Empty cache (for rehash) */
+void
+EmptyFontPatternCache (FontPatternCachePtr cache)
+{
+ int i;
+
+ for (i = 0; i < NBUCKETS; i++)
+ cache->buckets[i] = 0;
+ for (i = 0; i < NENTRIES; i++)
+ {
+ cache->entries[i].next = &cache->entries[i+1];
+ cache->entries[i].prev = 0;
+ cache->entries[i].pFont = 0;
+ xfree (cache->entries[i].pattern);
+ cache->entries[i].pattern = 0;
+ cache->entries[i].patlen = 0;
+ }
+ cache->free = &cache->entries[0];
+ cache->entries[NENTRIES - 1].next = 0;
+}
+
+/* Create and initialize cache */
+FontPatternCachePtr
+MakeFontPatternCache (void)
+{
+ FontPatternCachePtr cache;
+ int i;
+ cache = (FontPatternCachePtr) xalloc (sizeof *cache);
+ if (!cache)
+ return 0;
+ for (i = 0; i < NENTRIES; i++) {
+ cache->entries[i].patlen = 0;
+ cache->entries[i].pattern = 0;
+ cache->entries[i].pFont = 0;
+ }
+ EmptyFontPatternCache (cache);
+ return cache;
+}
+
+/* toss cache */
+void
+FreeFontPatternCache (FontPatternCachePtr cache)
+{
+ int i;
+
+ for (i = 0; i < NENTRIES; i++)
+ xfree (cache->entries[i].pattern);
+ xfree (cache);
+}
+
+/* compute id for string */
+static int
+Hash (const char *string, int len)
+{
+ int hash;
+
+ hash = 0;
+ while (len--)
+ hash = (hash << 1) ^ *string++;
+ if (hash < 0)
+ hash = -hash;
+ return hash;
+}
+
+/* add entry */
+void
+CacheFontPattern (FontPatternCachePtr cache,
+ char *pattern,
+ int patlen,
+ FontPtr pFont)
+{
+ FontPatternCacheEntryPtr e;
+ char *newpat;
+ int i;
+
+ newpat = (char *) xalloc (patlen);
+ if (!newpat)
+ return;
+ if (cache->free)
+ {
+ e = cache->free;
+ cache->free = e->next;
+ }
+ else
+ {
+ i = rand ();
+ if (i < 0)
+ i = -i;
+ i %= NENTRIES;
+ e = &cache->entries[i];
+ if (e->next)
+ e->next->prev = e->prev;
+ *e->prev = e->next;
+ xfree (e->pattern);
+ }
+ /* set pattern */
+ memcpy (newpat, pattern, patlen);
+ e->pattern = newpat;
+ e->patlen = patlen;
+ /* link to new hash chain */
+ e->hash = Hash (pattern, patlen);
+ i = e->hash % NBUCKETS;
+ e->next = cache->buckets[i];
+ if (e->next)
+ e->next->prev = &(e->next);
+ cache->buckets[i] = e;
+ e->prev = &(cache->buckets[i]);
+ e->pFont = pFont;
+}
+
+/* find matching entry */
+FontPtr
+FindCachedFontPattern (FontPatternCachePtr cache,
+ char *pattern,
+ int patlen)
+{
+ int hash;
+ int i;
+ FontPatternCacheEntryPtr e;
+
+ hash = Hash (pattern, patlen);
+ i = hash % NBUCKETS;
+ for (e = cache->buckets[i]; e; e = e->next)
+ {
+ if (e->patlen == patlen && e->hash == hash &&
+ !memcmp (e->pattern, pattern, patlen))
+ {
+ return e->pFont;
+ }
+ }
+ return 0;
+}
+
+void
+RemoveCachedFontPattern (FontPatternCachePtr cache,
+ FontPtr pFont)
+{
+ FontPatternCacheEntryPtr e;
+ int i;
+
+ for (i = 0; i < NENTRIES; i++)
+ {
+ if ((e = &cache->entries[i])->pFont == pFont)
+ {
+ e->pFont = 0;
+ if (e->next)
+ e->next->prev = e->prev;
+ *e->prev = e->next;
+ e->next = cache->free;
+ cache->free = e;
+ xfree (e->pattern);
+ e->pattern = 0;
+ }
+ }
+}
diff --git a/nx-X11/lib/font/util/private.c b/nx-X11/lib/font/util/private.c
new file mode 100644
index 000000000..85e90e57b
--- /dev/null
+++ b/nx-X11/lib/font/util/private.c
@@ -0,0 +1,107 @@
+/* $Xorg: private.c,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/font/util/private.c,v 1.8tsi Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+
+static int _FontPrivateAllocateIndex = 0;
+
+int
+AllocateFontPrivateIndex (void)
+{
+ return _FontPrivateAllocateIndex++;
+}
+
+FontPtr
+CreateFontRec (void)
+{
+ FontPtr pFont;
+ int size;
+
+ size = sizeof(FontRec) + (sizeof(pointer) * _FontPrivateAllocateIndex);
+
+ pFont = (FontPtr)xalloc(size);
+
+ if(pFont) {
+ bzero((char*)pFont, size);
+ pFont->maxPrivate = _FontPrivateAllocateIndex - 1;
+ if(_FontPrivateAllocateIndex)
+ pFont->devPrivates = (pointer)(&pFont[1]);
+ }
+
+ return pFont;
+}
+
+void
+DestroyFontRec (FontPtr pFont)
+{
+ if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1]))
+ xfree(pFont->devPrivates);
+ xfree(pFont);
+}
+
+void
+ResetFontPrivateIndex (void)
+{
+ _FontPrivateAllocateIndex = 0;
+}
+
+Bool
+_FontSetNewPrivate (FontPtr pFont, int n, pointer ptr)
+{
+ pointer *new;
+
+ if (n > pFont->maxPrivate) {
+ if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1])) {
+ new = (pointer *) xrealloc (pFont->devPrivates, (n + 1) * sizeof (pointer));
+ if (!new)
+ return FALSE;
+ } else {
+ new = (pointer *) xalloc ((n + 1) * sizeof (pointer));
+ if (!new)
+ return FALSE;
+ if (pFont->devPrivates)
+ memcpy (new, pFont->devPrivates, (pFont->maxPrivate + 1) * sizeof (pointer));
+ }
+ pFont->devPrivates = new;
+ /* zero out new, uninitialized privates */
+ while(++pFont->maxPrivate < n)
+ pFont->devPrivates[pFont->maxPrivate] = (pointer)0;
+ }
+ pFont->devPrivates[n] = ptr;
+ return TRUE;
+}
+
diff --git a/nx-X11/lib/font/util/utilbitmap.c b/nx-X11/lib/font/util/utilbitmap.c
new file mode 100644
index 000000000..a817a4ec6
--- /dev/null
+++ b/nx-X11/lib/font/util/utilbitmap.c
@@ -0,0 +1,188 @@
+/* $Xorg: utilbitmap.c,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+Copyright 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.
+
+*/
+/* $XFree86: xc/lib/font/util/utilbitmap.c,v 1.4 2001/01/17 19:43:34 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+
+/* Utility functions for reformating font bitmaps */
+
+static unsigned char _reverse_byte[0x100] = {
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
+};
+
+/*
+ * Invert bit order within each BYTE of an array.
+ */
+void
+BitOrderInvert(unsigned char *buf, int nbytes)
+{
+ unsigned char *rev = _reverse_byte;
+
+ for (; --nbytes >= 0; buf++)
+ *buf = rev[*buf];
+}
+
+/*
+ * Invert byte order within each 16-bits of an array.
+ */
+void
+TwoByteSwap(unsigned char *buf, int nbytes)
+{
+ unsigned char c;
+
+ for (; nbytes > 0; nbytes -= 2, buf += 2)
+ {
+ c = buf[0];
+ buf[0] = buf[1];
+ buf[1] = c;
+ }
+}
+
+/*
+ * Invert byte order within each 32-bits of an array.
+ */
+void
+FourByteSwap(unsigned char *buf, int nbytes)
+{
+ unsigned char c;
+
+ for (; nbytes > 0; nbytes -= 4, buf += 4)
+ {
+ c = buf[0];
+ buf[0] = buf[3];
+ buf[3] = c;
+ c = buf[1];
+ buf[1] = buf[2];
+ buf[2] = c;
+ }
+}
+
+/*
+ * Repad a bitmap
+ */
+
+int
+RepadBitmap (char *pSrc, char *pDst,
+ unsigned int srcPad, unsigned int dstPad,
+ int width, int height)
+{
+ int srcWidthBytes,dstWidthBytes;
+ int row,col;
+ char *pTmpSrc,*pTmpDst;
+
+ switch (srcPad) {
+ case 1:
+ srcWidthBytes = (width+7)>>3;
+ break;
+ case 2:
+ srcWidthBytes = ((width+15)>>4)<<1;
+ break;
+ case 4:
+ srcWidthBytes = ((width+31)>>5)<<2;
+ break;
+ case 8:
+ srcWidthBytes = ((width+63)>>6)<<3;
+ break;
+ default:
+ return 0;
+ }
+ switch (dstPad) {
+ case 1:
+ dstWidthBytes = (width+7)>>3;
+ break;
+ case 2:
+ dstWidthBytes = ((width+15)>>4)<<1;
+ break;
+ case 4:
+ dstWidthBytes = ((width+31)>>5)<<2;
+ break;
+ case 8:
+ dstWidthBytes = ((width+63)>>6)<<3;
+ break;
+ default:
+ return 0;
+ }
+
+ width = srcWidthBytes;
+ if (width > dstWidthBytes)
+ width = dstWidthBytes;
+ pTmpSrc= pSrc;
+ pTmpDst= pDst;
+ for (row = 0; row < height; row++)
+ {
+ for (col = 0; col < width; col++)
+ *pTmpDst++ = *pTmpSrc++;
+ while (col < dstWidthBytes)
+ {
+ *pTmpDst++ = '\0';
+ col++;
+ }
+ pTmpSrc += srcWidthBytes - width;
+ }
+ return dstWidthBytes * height;
+}
+
+
diff --git a/nx-X11/lib/fontconfig/Imakefile b/nx-X11/lib/fontconfig/Imakefile
new file mode 100644
index 000000000..938bc3e71
--- /dev/null
+++ b/nx-X11/lib/fontconfig/Imakefile
@@ -0,0 +1,464 @@
+XCOMM $XdotOrg: xc/lib/fontconfig/Imakefile,v 1.6 2005/11/08 06:33:26 jkj Exp $
+XCOMM $XFree86: xc/lib/fontconfig/Imakefile,v 1.17 2003/11/19 20:57:37 dawes Exp $
+
+#define DoNormalLib NormalLibFontconfig
+#define DoSharedLib SharedLibFontconfig
+#define DoExtraLib SharedLibFontconfig
+#define DoDebugLib DebugLibFontconfig
+#define DoProfileLib ProfileLibFontconfig
+#define HasSharedData YES
+#define LibName fontconfig
+#define SoRev SOFONTCONFIGREV
+#define LibInstall InstallFontconfigLibrary
+#define LibHeaders InstallFontconfigLibrary
+
+#define IncSubdir fontconfig
+
+HEADERS=fcfreetype.h fcprivate.h fontconfig.h
+
+BuildIncludes($(HEADERS),IncSubdir,..)
+#if InstallFontconfigLibrary
+InstallMultipleFlags($(HEADERS),$(INCDIR)/IncSubdir,$(INSTINCFLAGS))
+#endif
+
+#include <Threads.tmpl>
+
+XCOMM Assume FreeType is at least version 2.1.8 or later
+FREETYPE_DEFINES=-DHAVE_FT_GET_BDF_PROPERTY -DHAVE_FT_GET_NEXT_CHAR \
+ -DHAVE_FT_GET_PS_FONT_INFO -DHAVE_FT_GET_X11_FONT_FORMAT \
+ -DHAVE_FT_HAS_PS_GLYPH_NAMES
+
+FONTCONFIGSRC=$(TOP)/extras/fontconfig
+
+INCLUDES= $(EXPATINCLUDES) $(FREETYPE2INCLUDES) -I$(FONTCONFIGSRC)/src \
+ -I$(FONTCONFIGSRC) -I$(XBUILDINCDIR)
+
+#if HasMkstemp
+MKSTEMP_DEFINES=-DHAVE_MKSTEMP
+#endif
+
+#if !defined(Win32Architecture) && !defined(OS2Architecture)
+LINK_DEFINES=-DHAVE_LINK
+GETUID_DEFINES=-DHAVE_GETUID -DHAVE_GETEUID
+#endif
+
+DEFINES=-DFC_DEFAULT_FONTS='"$(FC_DEFAULT_FONTS)"' -DHAVE_EXPAT -DXFREE86_FT2 \
+ -DFONTCONFIG_PATH='"$(FONTCONFIGFONTSCONFDIR)"' \
+ $(MKSTEMP_DEFINES) $(FREETYPE_DEFINES) $(LINK_DEFINES) $(GETUID_DEFINES)
+
+REQUIREDLIBS=$(LDPRELIBS) $(FREETYPE2LIB) $(EXPATLIB)
+
+SRCS=fcatomic.c fcblanks.c fccache.c fccfg.c fccharset.c fcdbg.c \
+ fcdefault.c fcdir.c fcfreetype.c fcfs.c fcinit.c fclang.c fclist.c \
+ fcmatch.c fcmatrix.c fcname.c fcpat.c fcstr.c fcxml.c
+
+OBJS=fcatomic.o fcblanks.o fccache.o fccfg.o fccharset.o fcdbg.o \
+ fcdefault.o fcdir.o fcfreetype.o fcfs.o fcinit.o fclang.o fclist.o \
+ fcmatch.o fcmatrix.o fcname.o fcpat.o fcstr.o fcxml.o
+
+#include <Library.tmpl>
+
+#if DoSharedLib && SharedDataSeparation
+SpecialCObjectRule(sharedlib,NullParameter,$(SHLIBDEF))
+#endif
+
+DependTarget()
+
+FONTCONFIG_VERSION=2.2.2
+
+#ifndef FontconfigFontsConfDir
+#if NothingOutsideProjectRoot
+#define FontconfigFontsConfDir $(PROJECTROOT)/etc/fonts
+#else
+#define FontconfigFontsConfDir /etc/fonts
+#endif
+#endif
+
+FONTCONFIGFONTSCONFDIR=FontconfigFontsConfDir
+
+#ifdef DarwinArchitecture
+MACFONTDIRS = ~/Library/Fonts /Library/Fonts /Network/Library/Fonts \
+ /System/Library/Fonts
+#endif
+
+#if NothingOutsideProjectRoot
+FONTDIRS=$(FONTDIR)
+#else
+DEFAULTFONTDIRS=/usr/share/fonts
+FONTDIRS=$(FONTDIR) $(MACFONTDIRS)
+#endif
+
+RPATH_CFLAG = HardCodeLibdirFlag
+
+SUBSTVARS=prefix=$(PROJECTROOT) \
+ exec_prefix=$(BINDIR) \
+ libdir=$(USRLIBDIR) \
+ hardcode_libdir_flag_spec=$(RPATH_CFLAG) \
+ includedir=$(INCROOT) \
+ VERSION=$(FONTCONFIG_VERSION)
+
+CONFIG_SUBST_PROG=sh ./config-subst
+
+#if !(HasGnuMake)
+#if (defined(SunArchitecture) && defined(SVR4Architecture)) || \
+ defined(SCOArchitecture) || defined(USLArchitecture) || \
+ defined(UnixWareArchitecture)
+ XCOMM Required for the config-subst rules to work with Solaris make
+ SHELL=/bin/ksh
+#endif
+#endif
+
+#if InstallFontconfigLibrary
+# ifndef InstallNamedTargetBackup
+# define InstallNamedTargetBackup(step,srcname,flags,dest,dstname) @@\
+step:: srcname @@\
+ MakeDir($(DESTDIR)dest) @@\
+ MoveToBakFile($(DESTDIR)dest/dstname) @@\
+ $(INSTALL) $(INSTALLFLAGS) flags srcname $(DESTDIR)dest/dstname
+# endif /* InstallNamedTargetBackup */
+
+# ifndef InstallNonExecFileBackup
+# define InstallNonExecFileBackup(file,dest) @@\
+InstallNamedTargetBackup(install,file,$(INSTDATFLAGS),dest,file)
+# endif /* InstallNonExecFileBackup */
+
+InstallNonExecFileBackup(fonts.conf,$(FONTCONFIGFONTSCONFDIR))
+InstallNonExecFile(fonts.dtd,$(FONTCONFIGFONTSCONFDIR))
+#endif
+
+all:: fonts.conf
+
+fonts.conf: fonts.conf.in
+ RemoveFile($@)
+ DEFAULTFONTDIR=FC_DEFAULT_FONTS=$(DEFAULTFONTDIRS); \
+ FONTDIR=FC_FONTPATH=`for i in $(FONTDIRS); \
+ do echo -n '<dir>'$$i'</dir> '; done;`; \
+ FONTDIRDATE=FC_FONTDATE=`date;`;\
+ $(CONFIG_SUBST_PROG) "$$DEFAULTFONTDIR" "$$FONTDIR" "$$FONTDIRDATE" \
+ < fonts.conf.in > $@;
+
+clean::
+ RemoveFile(fonts.conf)
+
+#if SharedLibFontconfig
+# if defined(Win32Architecture) || defined(OS2Architecture)
+all:: fontconfig-def.cpp
+
+fontconfig-def.cpp: fontconfig.def.in
+ RemoveFile($@)
+ MAJ=`expr "$(SOFONTCONFIGREV)" : "\([^\.]*\)\..*"`; \
+ MIN=`expr "$(SOFONTCONFIGREV)" : "[^\.]*\.\([^\.]*\)\.*.*"` || true;\
+ TEEN=`expr "$(SOFONTCONFIGREV)" : "[^\.]*\.[^\.]*\.*\(.*\)"` || true;\
+ CUR=LT_CURRENT=`expr $$MAJ + $$MIN`;\
+ REV=LT_REVISION=$$TEEN;\
+ $(CONFIG_SUBST_PROG) $$CUR $$REV < fontconfig.def.in > $@
+
+clean::
+ RemoveFile(fontconfig-def.cpp)
+# endif
+#endif
+
+all:: fontconfig.pc
+
+fontconfig.pc: fontconfig.pc.in
+ RemoveFile($@)
+ $(CONFIG_SUBST_PROG) $(SUBSTVARS) < fontconfig.pc.in > $@
+
+#if InstallFontconfigLibrary
+InstallNonExecFile(fontconfig.pc,$(USRLIBDIR)/pkgconfig)
+#endif
+
+clean::
+ RemoveFile(fontconfig.pc)
+
+/* config stuff */
+LinkSourceFile(fontconfig.pc.in,$(FONTCONFIGSRC))
+LinkSourceFile(fonts.conf.in,$(FONTCONFIGSRC))
+LinkSourceFile(fonts.dtd,$(FONTCONFIGSRC))
+
+/* Source */
+LinkSourceFile(fcatomic.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fcblanks.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fccache.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fccfg.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fccharset.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fcdbg.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fcdefault.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fcdir.c,$(FONTCONFIGSRC)/src)
+/* LinkSourceFile(fcfreetype.c,$(FONTCONFIGSRC)/src) - use custom copy for now */
+LinkSourceFile(fcfs.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fcinit.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fclang.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fclist.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fcmatch.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fcmatrix.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fcname.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fcpat.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fcstr.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fcxml.c,$(FONTCONFIGSRC)/src)
+LinkSourceFile(fontconfig.def.in,$(FONTCONFIGSRC)/src)
+
+/* Public headers */
+LinkSourceFile(fcfreetype.h,$(FONTCONFIGSRC)/fontconfig)
+LinkSourceFile(fcprivate.h,$(FONTCONFIGSRC)/fontconfig)
+LinkSourceFile(fontconfig.h,$(FONTCONFIGSRC)/fontconfig)
+
+/* Man pages */
+LinkFile(FcAtomicCreate.man,$(FONTCONFIGSRC)/doc/FcAtomicCreate.3)
+InstallGenManPage(FcAtomicCreate,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcAtomicDeleteNew.man,$(FONTCONFIGSRC)/doc/FcAtomicDeleteNew.3)
+InstallGenManPage(FcAtomicDeleteNew,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcAtomicDestroy.man,$(FONTCONFIGSRC)/doc/FcAtomicDestroy.3)
+InstallGenManPage(FcAtomicDestroy,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcAtomicLock.man,$(FONTCONFIGSRC)/doc/FcAtomicLock.3)
+InstallGenManPage(FcAtomicLock,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcAtomicNewFile.man,$(FONTCONFIGSRC)/doc/FcAtomicNewFile.3)
+InstallGenManPage(FcAtomicNewFile,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcAtomicOrigFile.man,$(FONTCONFIGSRC)/doc/FcAtomicOrigFile.3)
+InstallGenManPage(FcAtomicOrigFile,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcAtomicReplaceOrig.man,$(FONTCONFIGSRC)/doc/FcAtomicReplaceOrig.3)
+InstallGenManPage(FcAtomicReplaceOrig,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcAtomicUnlock.man,$(FONTCONFIGSRC)/doc/FcAtomicUnlock.3)
+InstallGenManPage(FcAtomicUnlock,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcBlanksAdd.man,$(FONTCONFIGSRC)/doc/FcBlanksAdd.3)
+InstallGenManPage(FcBlanksAdd,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcBlanksCreate.man,$(FONTCONFIGSRC)/doc/FcBlanksCreate.3)
+InstallGenManPage(FcBlanksCreate,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcBlanksDestroy.man,$(FONTCONFIGSRC)/doc/FcBlanksDestroy.3)
+InstallGenManPage(FcBlanksDestroy,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcBlanksIsMember.man,$(FONTCONFIGSRC)/doc/FcBlanksIsMember.3)
+InstallGenManPage(FcBlanksIsMember,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetAddChar.man,$(FONTCONFIGSRC)/doc/FcCharSetAddChar.3)
+InstallGenManPage(FcCharSetAddChar,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetCopy.man,$(FONTCONFIGSRC)/doc/FcCharSetCopy.3)
+InstallGenManPage(FcCharSetCopy,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetCount.man,$(FONTCONFIGSRC)/doc/FcCharSetCount.3)
+InstallGenManPage(FcCharSetCount,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetCreate.man,$(FONTCONFIGSRC)/doc/FcCharSetCreate.3)
+InstallGenManPage(FcCharSetCreate,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetDestroy.man,$(FONTCONFIGSRC)/doc/FcCharSetDestroy.3)
+InstallGenManPage(FcCharSetDestroy,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetEqual.man,$(FONTCONFIGSRC)/doc/FcCharSetEqual.3)
+InstallGenManPage(FcCharSetEqual,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetFirstPage.man,$(FONTCONFIGSRC)/doc/FcCharSetFirstPage.3)
+InstallGenManPage(FcCharSetFirstPage,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetHasChar.man,$(FONTCONFIGSRC)/doc/FcCharSetHasChar.3)
+InstallGenManPage(FcCharSetHasChar,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetIntersect.man,$(FONTCONFIGSRC)/doc/FcCharSetIntersect.3)
+InstallGenManPage(FcCharSetIntersect,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetIntersectCount.man,$(FONTCONFIGSRC)/doc/FcCharSetIntersectCount.3)
+InstallGenManPage(FcCharSetIntersectCount,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetIsSubset.man,$(FONTCONFIGSRC)/doc/FcCharSetIsSubset.3)
+InstallGenManPage(FcCharSetIsSubset,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetNextPage.man,$(FONTCONFIGSRC)/doc/FcCharSetNextPage.3)
+InstallGenManPage(FcCharSetNextPage,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetSubtract.man,$(FONTCONFIGSRC)/doc/FcCharSetSubtract.3)
+InstallGenManPage(FcCharSetSubtract,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetSubtractCount.man,$(FONTCONFIGSRC)/doc/FcCharSetSubtractCount.3)
+InstallGenManPage(FcCharSetSubtractCount,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcCharSetUnion.man,$(FONTCONFIGSRC)/doc/FcCharSetUnion.3)
+InstallGenManPage(FcCharSetUnion,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigAppFontAddDir.man,$(FONTCONFIGSRC)/doc/FcConfigAppFontAddDir.3)
+InstallGenManPage(FcConfigAppFontAddDir,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigAppFontAddFile.man,$(FONTCONFIGSRC)/doc/FcConfigAppFontAddFile.3)
+InstallGenManPage(FcConfigAppFontAddFile,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigAppFontClear.man,$(FONTCONFIGSRC)/doc/FcConfigAppFontClear.3)
+InstallGenManPage(FcConfigAppFontClear,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigBuildFonts.man,$(FONTCONFIGSRC)/doc/FcConfigBuildFonts.3)
+InstallGenManPage(FcConfigBuildFonts,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigCreate.man,$(FONTCONFIGSRC)/doc/FcConfigCreate.3)
+InstallGenManPage(FcConfigCreate,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigDestroy.man,$(FONTCONFIGSRC)/doc/FcConfigDestroy.3)
+InstallGenManPage(FcConfigDestroy,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigFilename.man,$(FONTCONFIGSRC)/doc/FcConfigFilename.3)
+InstallGenManPage(FcConfigFilename,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigGetBlanks.man,$(FONTCONFIGSRC)/doc/FcConfigGetBlanks.3)
+InstallGenManPage(FcConfigGetBlanks,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigGetCache.man,$(FONTCONFIGSRC)/doc/FcConfigGetCache.3)
+InstallGenManPage(FcConfigGetCache,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigGetConfigDirs.man,$(FONTCONFIGSRC)/doc/FcConfigGetConfigDirs.3)
+InstallGenManPage(FcConfigGetConfigDirs,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigGetConfigFiles.man,$(FONTCONFIGSRC)/doc/FcConfigGetConfigFiles.3)
+InstallGenManPage(FcConfigGetConfigFiles,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigGetCurrent.man,$(FONTCONFIGSRC)/doc/FcConfigGetCurrent.3)
+InstallGenManPage(FcConfigGetCurrent,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigGetFontDirs.man,$(FONTCONFIGSRC)/doc/FcConfigGetFontDirs.3)
+InstallGenManPage(FcConfigGetFontDirs,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigGetFonts.man,$(FONTCONFIGSRC)/doc/FcConfigGetFonts.3)
+InstallGenManPage(FcConfigGetFonts,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigGetRescanInverval.man,$(FONTCONFIGSRC)/doc/FcConfigGetRescanInverval.3)
+InstallGenManPage(FcConfigGetRescanInverval,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigParseAndLoad.man,$(FONTCONFIGSRC)/doc/FcConfigParseAndLoad.3)
+InstallGenManPage(FcConfigParseAndLoad,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigSetCurrent.man,$(FONTCONFIGSRC)/doc/FcConfigSetCurrent.3)
+InstallGenManPage(FcConfigSetCurrent,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigSetRescanInverval.man,$(FONTCONFIGSRC)/doc/FcConfigSetRescanInverval.3)
+InstallGenManPage(FcConfigSetRescanInverval,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigSubstitute.man,$(FONTCONFIGSRC)/doc/FcConfigSubstitute.3)
+InstallGenManPage(FcConfigSubstitute,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigSubstituteWithPat.man,$(FONTCONFIGSRC)/doc/FcConfigSubstituteWithPat.3)
+InstallGenManPage(FcConfigSubstituteWithPat,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcConfigUptoDate.man,$(FONTCONFIGSRC)/doc/FcConfigUptoDate.3)
+InstallGenManPage(FcConfigUptoDate,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcDefaultSubstitute.man,$(FONTCONFIGSRC)/doc/FcDefaultSubstitute.3)
+InstallGenManPage(FcDefaultSubstitute,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcDirCacheValid.man,$(FONTCONFIGSRC)/doc/FcDirCacheValid.3)
+InstallGenManPage(FcDirCacheValid,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcDirSave.man,$(FONTCONFIGSRC)/doc/FcDirSave.3)
+InstallGenManPage(FcDirSave,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcDirScan.man,$(FONTCONFIGSRC)/doc/FcDirScan.3)
+InstallGenManPage(FcDirScan,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcFileScan.man,$(FONTCONFIGSRC)/doc/FcFileScan.3)
+InstallGenManPage(FcFileScan,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcFini.man,$(FONTCONFIGSRC)/doc/FcFini.3)
+InstallGenManPage(FcFini,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcFontList.man,$(FONTCONFIGSRC)/doc/FcFontList.3)
+InstallGenManPage(FcFontList,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcFontMatch.man,$(FONTCONFIGSRC)/doc/FcFontMatch.3)
+InstallGenManPage(FcFontMatch,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcFontRenderPrepare.man,$(FONTCONFIGSRC)/doc/FcFontRenderPrepare.3)
+InstallGenManPage(FcFontRenderPrepare,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcFontSetAdd.man,$(FONTCONFIGSRC)/doc/FcFontSetAdd.3)
+InstallGenManPage(FcFontSetAdd,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcFontSetCreate.man,$(FONTCONFIGSRC)/doc/FcFontSetCreate.3)
+InstallGenManPage(FcFontSetCreate,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcFontSetDestroy.man,$(FONTCONFIGSRC)/doc/FcFontSetDestroy.3)
+InstallGenManPage(FcFontSetDestroy,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcFontSort.man,$(FONTCONFIGSRC)/doc/FcFontSort.3)
+InstallGenManPage(FcFontSort,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcFreeTypeCharIndex.man,$(FONTCONFIGSRC)/doc/FcFreeTypeCharIndex.3)
+InstallGenManPage(FcFreeTypeCharIndex,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcFreeTypeCharSet.man,$(FONTCONFIGSRC)/doc/FcFreeTypeCharSet.3)
+InstallGenManPage(FcFreeTypeCharSet,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcFreeTypeQuery.man,$(FONTCONFIGSRC)/doc/FcFreeTypeQuery.3)
+InstallGenManPage(FcFreeTypeQuery,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcGetVersion.man,$(FONTCONFIGSRC)/doc/FcGetVersion.3)
+InstallGenManPage(FcGetVersion,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcInit.man,$(FONTCONFIGSRC)/doc/FcInit.3)
+InstallGenManPage(FcInit,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcInitBringUptoDate.man,$(FONTCONFIGSRC)/doc/FcInitBringUptoDate.3)
+InstallGenManPage(FcInitBringUptoDate,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcInitLoadConfig.man,$(FONTCONFIGSRC)/doc/FcInitLoadConfig.3)
+InstallGenManPage(FcInitLoadConfig,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcInitLoadConfigAndFonts.man,$(FONTCONFIGSRC)/doc/FcInitLoadConfigAndFonts.3)
+InstallGenManPage(FcInitLoadConfigAndFonts,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcInitReinitialize.man,$(FONTCONFIGSRC)/doc/FcInitReinitialize.3)
+InstallGenManPage(FcInitReinitialize,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcMatrixCopy.man,$(FONTCONFIGSRC)/doc/FcMatrixCopy.3)
+InstallGenManPage(FcMatrixCopy,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcMatrixEqual.man,$(FONTCONFIGSRC)/doc/FcMatrixEqual.3)
+InstallGenManPage(FcMatrixEqual,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcMatrixInit.man,$(FONTCONFIGSRC)/doc/FcMatrixInit.3)
+InstallGenManPage(FcMatrixInit,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcMatrixMultiply.man,$(FONTCONFIGSRC)/doc/FcMatrixMultiply.3)
+InstallGenManPage(FcMatrixMultiply,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcMatrixRotate.man,$(FONTCONFIGSRC)/doc/FcMatrixRotate.3)
+InstallGenManPage(FcMatrixRotate,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcMatrixScale.man,$(FONTCONFIGSRC)/doc/FcMatrixScale.3)
+InstallGenManPage(FcMatrixScale,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcMatrixShear.man,$(FONTCONFIGSRC)/doc/FcMatrixShear.3)
+InstallGenManPage(FcMatrixShear,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcNameConstant.man,$(FONTCONFIGSRC)/doc/FcNameConstant.3)
+InstallGenManPage(FcNameConstant,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcNameGetConstant.man,$(FONTCONFIGSRC)/doc/FcNameGetConstant.3)
+InstallGenManPage(FcNameGetConstant,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcNameGetObjectType.man,$(FONTCONFIGSRC)/doc/FcNameGetObjectType.3)
+InstallGenManPage(FcNameGetObjectType,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcNameParse.man,$(FONTCONFIGSRC)/doc/FcNameParse.3)
+InstallGenManPage(FcNameParse,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcNameRegisterConstants.man,$(FONTCONFIGSRC)/doc/FcNameRegisterConstants.3)
+InstallGenManPage(FcNameRegisterConstants,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcNameRegisterObjectTypes.man,$(FONTCONFIGSRC)/doc/FcNameRegisterObjectTypes.3)
+InstallGenManPage(FcNameRegisterObjectTypes,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcNameUnparse.man,$(FONTCONFIGSRC)/doc/FcNameUnparse.3)
+InstallGenManPage(FcNameUnparse,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcNameUnregisterConstants.man,$(FONTCONFIGSRC)/doc/FcNameUnregisterConstants.3)
+InstallGenManPage(FcNameUnregisterConstants,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcNameUnregisterObjectTypes.man,$(FONTCONFIGSRC)/doc/FcNameUnregisterObjectTypes.3)
+InstallGenManPage(FcNameUnregisterObjectTypes,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcObjectSetAdd.man,$(FONTCONFIGSRC)/doc/FcObjectSetAdd.3)
+InstallGenManPage(FcObjectSetAdd,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcObjectSetBuild.man,$(FONTCONFIGSRC)/doc/FcObjectSetBuild.3)
+InstallGenManPage(FcObjectSetBuild,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcObjectSetCreate.man,$(FONTCONFIGSRC)/doc/FcObjectSetCreate.3)
+InstallGenManPage(FcObjectSetCreate,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcObjectSetDestroy.man,$(FONTCONFIGSRC)/doc/FcObjectSetDestroy.3)
+InstallGenManPage(FcObjectSetDestroy,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternAdd-Type.man,$(FONTCONFIGSRC)/doc/FcPatternAdd-Type.3)
+InstallGenManPage(FcPatternAdd-Type,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternAdd.man,$(FONTCONFIGSRC)/doc/FcPatternAdd.3)
+InstallGenManPage(FcPatternAdd,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternAddWeak.man,$(FONTCONFIGSRC)/doc/FcPatternAddWeak.3)
+InstallGenManPage(FcPatternAddWeak,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternBuild.man,$(FONTCONFIGSRC)/doc/FcPatternBuild.3)
+InstallGenManPage(FcPatternBuild,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternCreate.man,$(FONTCONFIGSRC)/doc/FcPatternCreate.3)
+InstallGenManPage(FcPatternCreate,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternDel.man,$(FONTCONFIGSRC)/doc/FcPatternDel.3)
+InstallGenManPage(FcPatternDel,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternDestroy.man,$(FONTCONFIGSRC)/doc/FcPatternDestroy.3)
+InstallGenManPage(FcPatternDestroy,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternEqual.man,$(FONTCONFIGSRC)/doc/FcPatternEqual.3)
+InstallGenManPage(FcPatternEqual,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternEqualSubset.man,$(FONTCONFIGSRC)/doc/FcPatternEqualSubset.3)
+InstallGenManPage(FcPatternEqualSubset,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternGet-Type.man,$(FONTCONFIGSRC)/doc/FcPatternGet-Type.3)
+InstallGenManPage(FcPatternGet-Type,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternGet.man,$(FONTCONFIGSRC)/doc/FcPatternGet.3)
+InstallGenManPage(FcPatternGet,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternHash.man,$(FONTCONFIGSRC)/doc/FcPatternHash.3)
+InstallGenManPage(FcPatternHash,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternPrint.man,$(FONTCONFIGSRC)/doc/FcPatternPrint.3)
+InstallGenManPage(FcPatternPrint,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcPatternRemove.man,$(FONTCONFIGSRC)/doc/FcPatternRemove.3)
+InstallGenManPage(FcPatternRemove,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrBasename.man,$(FONTCONFIGSRC)/doc/FcStrBasename.3)
+InstallGenManPage(FcStrBasename,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrCmpIgnoreCase.man,$(FONTCONFIGSRC)/doc/FcStrCmpIgnoreCase.3)
+InstallGenManPage(FcStrCmpIgnoreCase,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrCopy.man,$(FONTCONFIGSRC)/doc/FcStrCopy.3)
+InstallGenManPage(FcStrCopy,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrCopyFilename.man,$(FONTCONFIGSRC)/doc/FcStrCopyFilename.3)
+InstallGenManPage(FcStrCopyFilename,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrDirname.man,$(FONTCONFIGSRC)/doc/FcStrDirname.3)
+InstallGenManPage(FcStrDirname,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrDowncase.man,$(FONTCONFIGSRC)/doc/FcStrDowncase.3)
+InstallGenManPage(FcStrDowncase,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrListCreate.man,$(FONTCONFIGSRC)/doc/FcStrListCreate.3)
+InstallGenManPage(FcStrListCreate,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrListDone.man,$(FONTCONFIGSRC)/doc/FcStrListDone.3)
+InstallGenManPage(FcStrListDone,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrListNext.man,$(FONTCONFIGSRC)/doc/FcStrListNext.3)
+InstallGenManPage(FcStrListNext,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrSetAdd.man,$(FONTCONFIGSRC)/doc/FcStrSetAdd.3)
+InstallGenManPage(FcStrSetAdd,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrSetAddFilename.man,$(FONTCONFIGSRC)/doc/FcStrSetAddFilename.3)
+InstallGenManPage(FcStrSetAddFilename,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrSetCreate.man,$(FONTCONFIGSRC)/doc/FcStrSetCreate.3)
+InstallGenManPage(FcStrSetCreate,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrSetDel.man,$(FONTCONFIGSRC)/doc/FcStrSetDel.3)
+InstallGenManPage(FcStrSetDel,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrSetDestroy.man,$(FONTCONFIGSRC)/doc/FcStrSetDestroy.3)
+InstallGenManPage(FcStrSetDestroy,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrSetMember.man,$(FONTCONFIGSRC)/doc/FcStrSetMember.3)
+InstallGenManPage(FcStrSetMember,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrStr.man,$(FONTCONFIGSRC)/doc/FcStrStr.3)
+InstallGenManPage(FcStrStr,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcStrStrIgnoreCase.man,$(FONTCONFIGSRC)/doc/FcStrStrIgnoreCase.3)
+InstallGenManPage(FcStrStrIgnoreCase,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcUcs4ToUtf8.man,$(FONTCONFIGSRC)/doc/FcUcs4ToUtf8.3)
+InstallGenManPage(FcUcs4ToUtf8,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcUtf16Len.man,$(FONTCONFIGSRC)/doc/FcUtf16Len.3)
+InstallGenManPage(FcUtf16Len,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcUtf16ToUcs4.man,$(FONTCONFIGSRC)/doc/FcUtf16ToUcs4.3)
+InstallGenManPage(FcUtf16ToUcs4,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcUtf8Len.man,$(FONTCONFIGSRC)/doc/FcUtf8Len.3)
+InstallGenManPage(FcUtf8Len,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcUtf8ToUcs4.man,$(FONTCONFIGSRC)/doc/FcUtf8ToUcs4.3)
+InstallGenManPage(FcUtf8ToUcs4,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcValueDestroy.man,$(FONTCONFIGSRC)/doc/FcValueDestroy.3)
+InstallGenManPage(FcValueDestroy,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(FcValueSave.man,$(FONTCONFIGSRC)/doc/FcValueSave.3)
+InstallGenManPage(FcValueSave,${LIBMANDIR},${LIBMANSUFFIX})
+LinkFile(fonts-conf.man,$(FONTCONFIGSRC)/doc/fonts-conf.5)
+InstallGenManPage(fonts-conf,${FILEMANDIR},${FILEMANSUFFIX})
diff --git a/nx-X11/lib/fontconfig/config-subst b/nx-X11/lib/fontconfig/config-subst
new file mode 100644
index 000000000..5907e0328
--- /dev/null
+++ b/nx-X11/lib/fontconfig/config-subst
@@ -0,0 +1,10 @@
+#!/bin/sh
+script=config-subst.$$
+trap "rm $script" 0
+rm -f $script
+for i in ${1+"$@"}; do
+ var="`echo "$i" | sed 's/=.*$//'`"
+ val="`echo "$i" | sed 's/^[^=]*=//'`"
+ echo "s;@$var@;$val;" >> $script
+done
+sed -f $script
diff --git a/nx-X11/lib/fontconfig/fcfreetype.c b/nx-X11/lib/fontconfig/fcfreetype.c
new file mode 100644
index 000000000..2627f9753
--- /dev/null
+++ b/nx-X11/lib/fontconfig/fcfreetype.c
@@ -0,0 +1,2847 @@
+/*
+ * $RCSId: xc/lib/fontconfig/src/fcfreetype.c,v 1.11 2002/08/31 22:17:32 keithp Exp $
+ *
+ * Copyright © 2001 Keith Packard
+ *
+ * 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 of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 © 2002-2003 by Juliusz Chroboczek
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ 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
+ AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "fcint.h"
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_INTERNAL_OBJECTS_H
+#include FT_TRUETYPE_TABLES_H
+#include FT_SFNT_NAMES_H
+#include FT_TRUETYPE_IDS_H
+#include FT_TYPE1_TABLES_H
+#include FT_INTERNAL_STREAM_H
+#include FT_INTERNAL_SFNT_H
+#include FT_INTERNAL_TRUETYPE_TYPES_H
+#if HAVE_FT_GET_X11_FONT_FORMAT
+#include FT_XFREE86_H
+#endif
+
+#if HAVE_FT_GET_BDF_PROPERTY
+#include FT_BDF_H
+#include FT_MODULE_H
+#define HAS_BDF_PROPERTY(f) ((f) && (f)->driver && \
+ (f)->driver->root.clazz->get_interface)
+#define MY_Get_BDF_Property(f,n,p) (HAS_BDF_PROPERTY(f) ? \
+ FT_Get_BDF_Property(f,n,p) : \
+ FT_Err_Invalid_Argument)
+#endif
+
+#if !HAVE_FT_GET_BDF_PROPERTY
+#warning "No FT_Get_BDF_Property: Please install freetype 2.1.4 or later"
+#endif
+
+#if !HAVE_FT_GET_PS_FONT_INFO
+#warning "No FT_Get_PS_Font_Info: Please install freetype 2.1.1 or later"
+#endif
+
+/*
+ * Keep Han languages separated by eliminating languages
+ * that the codePageRange bits says aren't supported
+ */
+
+static const struct {
+ int bit;
+ const FcChar8 *lang;
+} FcCodePageRange[] = {
+ { 17, (const FcChar8 *) "ja" },
+ { 18, (const FcChar8 *) "zh-cn" },
+ { 19, (const FcChar8 *) "ko" },
+ { 20, (const FcChar8 *) "zh-tw" },
+};
+
+#define NUM_CODE_PAGE_RANGE (sizeof FcCodePageRange / sizeof FcCodePageRange[0])
+
+FcBool
+FcFreeTypeIsExclusiveLang (const FcChar8 *lang)
+{
+ int i;
+
+ for (i = 0; i < NUM_CODE_PAGE_RANGE; i++)
+ {
+ if (FcLangCompare (lang, FcCodePageRange[i].lang) != FcLangDifferentLang)
+ return FcTrue;
+ }
+ return FcFalse;
+}
+
+typedef struct {
+ FT_UShort platform_id;
+ FT_UShort encoding_id;
+ char *fromcode;
+} FcFtEncoding;
+
+#define TT_ENCODING_DONT_CARE 0xffff
+#define FC_ENCODING_MAC_ROMAN "MACINTOSH"
+
+static const FcFtEncoding fcFtEncoding[] = {
+ { TT_PLATFORM_APPLE_UNICODE, TT_ENCODING_DONT_CARE, "UCS-2BE" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, "MACINTOSH" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_ID_JAPANESE, "SJIS" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, "UTF-16BE" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, "SJIS-WIN" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_GB2312, "GB3212" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, "BIG-5" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, "Wansung" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, "Johab" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_ID_UCS_4, "UCS4" },
+ { TT_PLATFORM_ISO, TT_ISO_ID_7BIT_ASCII, "ASCII" },
+ { TT_PLATFORM_ISO, TT_ISO_ID_10646, "UCS-2BE" },
+ { TT_PLATFORM_ISO, TT_ISO_ID_8859_1, "ISO-8859-1" },
+};
+
+#define NUM_FC_FT_ENCODING (sizeof (fcFtEncoding) / sizeof (fcFtEncoding[0]))
+
+typedef struct {
+ FT_UShort platform_id;
+ FT_UShort language_id;
+ char *lang;
+} FcFtLanguage;
+
+#define TT_LANGUAGE_DONT_CARE 0xffff
+
+static const FcFtLanguage fcFtLanguage[] = {
+ { TT_PLATFORM_APPLE_UNICODE, TT_LANGUAGE_DONT_CARE, 0 },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_ENGLISH, "en" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_FRENCH, "fr" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_GERMAN, "de" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_ITALIAN, "it" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_DUTCH, "nl" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SWEDISH, "sv" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SPANISH, "es" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_DANISH, "da" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_PORTUGUESE, "pt" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_NORWEGIAN, "no" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_HEBREW, "he" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_JAPANESE, "ja" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_ARABIC, "ar" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_FINNISH, "fi" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_GREEK, "el" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_ICELANDIC, "is" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_MALTESE, "mt" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_TURKISH, "tr" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_CROATIAN, "hr" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_CHINESE_TRADITIONAL, "zh-tw" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_URDU, "ur" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_HINDI, "hi" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_THAI, "th" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_KOREAN, "ko" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_LITHUANIAN, "lt" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_POLISH, "pl" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_HUNGARIAN, "hu" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_ESTONIAN, "et" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_LETTISH, "lv" },
+/* { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SAAMISK, ??? */
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_FAEROESE, "fo" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_FARSI, "fa" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_RUSSIAN, "ru" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_CHINESE_SIMPLIFIED, "zh-cn" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_FLEMISH, "nl" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_IRISH, "ga" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_ALBANIAN, "sq" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_ROMANIAN, "ro" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_CZECH, "cs" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SLOVAK, "sk" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SLOVENIAN, "sl" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_YIDDISH, "yi" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SERBIAN, "sr" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_MACEDONIAN, "mk" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_BULGARIAN, "bg" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_UKRAINIAN, "uk" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_BYELORUSSIAN, "be" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_UZBEK, "uz" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_KAZAKH, "kk" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_AZERBAIJANI, "az" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_AZERBAIJANI_CYRILLIC_SCRIPT, "az" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT, "ar" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_ARMENIAN, "hy" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_GEORGIAN, "ka" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_MOLDAVIAN, "mo" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_KIRGHIZ, "ky" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_TAJIKI, "tg" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_TURKMEN, "tk" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_MONGOLIAN, "mo" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT,"mo" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT, "mo" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_PASHTO, "ps" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_KURDISH, "ku" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_KASHMIRI, "ks" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SINDHI, "sd" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_TIBETAN, "bo" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_NEPALI, "ne" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SANSKRIT, "sa" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_MARATHI, "mr" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_BENGALI, "bn" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_ASSAMESE, "as" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_GUJARATI, "gu" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_PUNJABI, "pa" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_ORIYA, "or" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_MALAYALAM, "ml" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_KANNADA, "kn" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_TAMIL, "ta" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_TELUGU, "te" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SINHALESE, "si" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_BURMESE, "my" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_KHMER, "km" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_LAO, "lo" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_VIETNAMESE, "vi" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_INDONESIAN, "id" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_TAGALOG, "tl" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_MALAY_ROMAN_SCRIPT, "ms" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_MALAY_ARABIC_SCRIPT, "ms" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_AMHARIC, "am" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_TIGRINYA, "ti" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_GALLA, "om" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SOMALI, "so" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SWAHILI, "sw" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_RUANDA, "rw" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_RUNDI, "rn" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_CHEWA, "ny" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_MALAGASY, "mg" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_ESPERANTO, "eo" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_WELSH, "cy" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_BASQUE, "eu" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_CATALAN, "ca" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_LATIN, "la" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_QUECHUA, "qu" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_GUARANI, "gn" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_AYMARA, "ay" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_TATAR, "tt" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_UIGHUR, "ug" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_DZONGKHA, "dz" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_JAVANESE, "jw" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SUNDANESE, "su" },
+
+#if 0 /* these seem to be errors that have been dropped */
+
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SCOTTISH_GAELIC },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_IRISH_GAELIC },
+
+#endif
+
+ /* The following codes are new as of 2000-03-10 */
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_GALICIAN, "gl" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_AFRIKAANS, "af" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_BRETON, "br" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_INUKTITUT, "iu" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_SCOTTISH_GAELIC, "gd" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_MANX_GAELIC, "gv" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_IRISH_GAELIC, "ga" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_TONGAN, "to" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_GREEK_POLYTONIC, "el" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_GREELANDIC, "ik" },
+ { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT,"az" },
+
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_SAUDI_ARABIA, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_IRAQ, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_EGYPT, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_LIBYA, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_ALGERIA, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_MOROCCO, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_TUNISIA, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_OMAN, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_YEMEN, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_SYRIA, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_JORDAN, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_LEBANON, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_KUWAIT, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_UAE, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_BAHRAIN, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_QATAR, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_BULGARIAN_BULGARIA, "bg" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_CATALAN_SPAIN, "ca" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_CHINESE_TAIWAN, "zh-tw" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_CHINESE_PRC, "zh-cn" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_CHINESE_HONG_KONG, "zh-hk" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_CHINESE_SINGAPORE, "zh-sg" },
+
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_CHINESE_MACAU, "zh-mo" },
+
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_CZECH_CZECH_REPUBLIC, "cs" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_DANISH_DENMARK, "da" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_GERMAN_GERMANY, "de" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_GERMAN_SWITZERLAND, "de" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_GERMAN_AUSTRIA, "de" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_GERMAN_LUXEMBOURG, "de" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_GERMAN_LIECHTENSTEI, "de" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_GREEK_GREECE, "el" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_UNITED_STATES, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_UNITED_KINGDOM, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_AUSTRALIA, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_CANADA, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_NEW_ZEALAND, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_IRELAND, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_SOUTH_AFRICA, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_JAMAICA, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_CARIBBEAN, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_BELIZE, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_TRINIDAD, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_ZIMBABWE, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_PHILIPPINES, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT,"es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_MEXICO, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT,"es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_GUATEMALA, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_COSTA_RICA, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_PANAMA, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC,"es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_VENEZUELA, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_COLOMBIA, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_PERU, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_ARGENTINA, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_ECUADOR, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_CHILE, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_URUGUAY, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_PARAGUAY, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_BOLIVIA, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_EL_SALVADOR, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_HONDURAS, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_NICARAGUA, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_PUERTO_RICO, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FINNISH_FINLAND, "fi" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_FRANCE, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_BELGIUM, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_CANADA, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_SWITZERLAND, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_LUXEMBOURG, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_MONACO, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_HEBREW_ISRAEL, "he" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_HUNGARIAN_HUNGARY, "hu" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ICELANDIC_ICELAND, "is" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ITALIAN_ITALY, "it" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ITALIAN_SWITZERLAND, "it" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_JAPANESE_JAPAN, "ja" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA,"ko" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_KOREAN_JOHAB_KOREA, "ko" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_DUTCH_NETHERLANDS, "nl" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_DUTCH_BELGIUM, "nl" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL, "no" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK, "nn" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_POLISH_POLAND, "pl" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_PORTUGUESE_BRAZIL, "pt" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_PORTUGUESE_PORTUGAL, "pt" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND,"rm" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ROMANIAN_ROMANIA, "ro" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_MOLDAVIAN_MOLDAVIA, "mo" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_RUSSIAN_RUSSIA, "ru" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_RUSSIAN_MOLDAVIA, "ru" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_CROATIAN_CROATIA, "hr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SERBIAN_SERBIA_LATIN, "sr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC, "sr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SLOVAK_SLOVAKIA, "sk" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ALBANIAN_ALBANIA, "sq" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SWEDISH_SWEDEN, "sv" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SWEDISH_FINLAND, "sv" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_THAI_THAILAND, "th" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TURKISH_TURKEY, "tr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_URDU_PAKISTAN, "ur" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_INDONESIAN_INDONESIA, "id" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_UKRAINIAN_UKRAINE, "uk" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_BELARUSIAN_BELARUS, "be" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SLOVENE_SLOVENIA, "sl" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ESTONIAN_ESTONIA, "et" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_LATVIAN_LATVIA, "lv" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_LITHUANIAN_LITHUANIA, "lt" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA,"lt" },
+
+#ifdef TT_MS_LANGID_MAORI_NEW_ZELAND
+ /* this seems to be an error that have been dropped */
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_MAORI_NEW_ZEALAND, "mi" },
+#endif
+
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FARSI_IRAN, "fa" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_VIETNAMESE_VIET_NAM, "vi" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARMENIAN_ARMENIA, "hy" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN, "az" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC, "az" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_BASQUE_SPAIN, "eu" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SORBIAN_GERMANY, "wen" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_MACEDONIAN_MACEDONIA, "mk" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SUTU_SOUTH_AFRICA, "st" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TSONGA_SOUTH_AFRICA, "ts" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TSWANA_SOUTH_AFRICA, "tn" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_VENDA_SOUTH_AFRICA, "ven" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_XHOSA_SOUTH_AFRICA, "xh" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ZULU_SOUTH_AFRICA, "zu" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA, "af" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_GEORGIAN_GEORGIA, "ka" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS, "fo" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_HINDI_INDIA, "hi" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_MALTESE_MALTA, "mt" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SAAMI_LAPONIA, "se" },
+
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM,"gd" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_IRISH_GAELIC_IRELAND, "ga" },
+
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_MALAY_MALAYSIA, "ms" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM, "ms" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_KAZAK_KAZAKSTAN, "kk" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SWAHILI_KENYA, "sw" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN, "uz" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC, "uz" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TATAR_TATARSTAN, "tt" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_BENGALI_INDIA, "bn" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_PUNJABI_INDIA, "pa" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_GUJARATI_INDIA, "gu" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ORIYA_INDIA, "or" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TAMIL_INDIA, "ta" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TELUGU_INDIA, "te" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_KANNADA_INDIA, "kn" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_MALAYALAM_INDIA, "ml" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ASSAMESE_INDIA, "as" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_MARATHI_INDIA, "mr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SANSKRIT_INDIA, "sa" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_KONKANI_INDIA, "kok" },
+
+ /* new as of 2001-01-01 */
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ARABIC_GENERAL, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_CHINESE_GENERAL, "zh" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_GENERAL, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_WEST_INDIES, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_REUNION, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_CONGO, "fr" },
+
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_SENEGAL, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_CAMEROON, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_COTE_D_IVOIRE, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_MALI, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA,"bs" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_URDU_INDIA, "ur" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TAJIK_TAJIKISTAN, "tg" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_YIDDISH_GERMANY, "yi" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN, "ky" },
+
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TURKMEN_TURKMENISTAN, "tk" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_MONGOLIAN_MONGOLIA, "mn" },
+
+ /* the following seems to be inconsistent;
+ here is the current "official" way: */
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TIBETAN_BHUTAN, "bo" },
+ /* and here is what is used by Passport SDK */
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TIBETAN_CHINA, "bo" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_DZONGHKA_BHUTAN, "dz" },
+ /* end of inconsistency */
+
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_WELSH_WALES, "cy" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_KHMER_CAMBODIA, "km" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_LAO_LAOS, "lo" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_BURMESE_MYANMAR, "my" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_GALICIAN_SPAIN, "gl" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_MANIPURI_INDIA, "mni" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SINDHI_INDIA, "sd" },
+ /* the following one is only encountered in Microsoft RTF specification */
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_KASHMIRI_PAKISTAN, "ks" },
+ /* the following one is not in the Passport list, looks like an omission */
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_KASHMIRI_INDIA, "ks" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_NEPALI_NEPAL, "ne" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_NEPALI_INDIA, "ne" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRISIAN_NETHERLANDS, "fy" },
+
+ /* new as of 2001-03-01 (from Office Xp) */
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_HONG_KONG, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_INDIA, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_MALAYSIA, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_ENGLISH_SINGAPORE, "en" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SYRIAC_SYRIA, "syr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SINHALESE_SRI_LANKA, "si" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_CHEROKEE_UNITED_STATES, "chr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_INUKTITUT_CANADA, "iu" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_AMHARIC_ETHIOPIA, "am" },
+#if 0
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TAMAZIGHT_MOROCCO },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN },
+#endif
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_PASHTO_AFGHANISTAN, "ps" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FILIPINO_PHILIPPINES, "phi" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_DHIVEHI_MALDIVES, "div" },
+
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_OROMO_ETHIOPIA, "om" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TIGRIGNA_ETHIOPIA, "ti" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_TIGRIGNA_ERYTHREA, "ti" },
+
+ /* New additions from Windows Xp/Passport SDK 2001-11-10. */
+
+ /* don't ask what this one means... It is commented out currently. */
+#if 0
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_GREEK_GREECE2 },
+#endif
+
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_UNITED_STATES, "es" },
+ /* The following two IDs blatantly violate MS specs by using a */
+ /* sublanguage >,. */
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SPANISH_LATIN_AMERICA, "es" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_NORTH_AFRICA, "fr" },
+
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_MOROCCO, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FRENCH_HAITI, "fr" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_BENGALI_BANGLADESH, "bn" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN, "ar" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN,"mn" },
+#if 0
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_EDO_NIGERIA },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_FULFULDE_NIGERIA },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_IBIBIO_NIGERIA },
+#endif
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_HAUSA_NIGERIA, "ha" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_YORUBA_NIGERIA, "yo" },
+ /* language codes from, to, are (still) unknown. */
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_IGBO_NIGERIA, "ibo" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_KANURI_NIGERIA, "kau" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_GUARANI_PARAGUAY, "gn" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_HAWAIIAN_UNITED_STATES, "haw" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_LATIN, "la" },
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_SOMALI_SOMALIA, "so" },
+#if 0
+ /* Note: Yi does not have a (proper) ISO 639-2 code, since it is mostly */
+ /* not written (but OTOH the peculiar writing system is worth */
+ /* studying). */
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_YI_CHINA },
+#endif
+ { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES,"pap" },
+};
+
+#define NUM_FC_FT_LANGUAGE (sizeof (fcFtLanguage) / sizeof (fcFtLanguage[0]))
+
+typedef struct {
+ FT_UShort language_id;
+ char *fromcode;
+} FcMacRomanFake;
+
+static const FcMacRomanFake fcMacRomanFake[] = {
+ { TT_MS_LANGID_JAPANESE_JAPAN, "SJIS-WIN" },
+ { TT_MS_LANGID_ENGLISH_UNITED_STATES, "ASCII" },
+};
+
+static FcChar8 *
+FcFontCapabilities(FT_Face face);
+
+#define NUM_FC_MAC_ROMAN_FAKE (sizeof (fcMacRomanFake) / sizeof (fcMacRomanFake[0]))
+
+#if HAVE_ICONV && HAVE_ICONV_H
+#define USE_ICONV 1
+#include <iconv.h>
+#endif
+
+static FcChar8 *
+FcSfntNameTranscode (FT_SfntName *sname)
+{
+ int i;
+ char *fromcode;
+#if USE_ICONV
+ iconv_t cd;
+#endif
+ FcChar8 *utf8;
+
+ for (i = 0; i < NUM_FC_FT_ENCODING; i++)
+ if (fcFtEncoding[i].platform_id == sname->platform_id &&
+ (fcFtEncoding[i].encoding_id == TT_ENCODING_DONT_CARE ||
+ fcFtEncoding[i].encoding_id == sname->encoding_id))
+ break;
+ if (i == NUM_FC_FT_ENCODING)
+ return 0;
+ fromcode = fcFtEncoding[i].fromcode;
+
+ /*
+ * "real" Mac language IDs are all less than 150.
+ * Names using one of the MS language IDs are assumed
+ * to use an associated encoding (Yes, this is a kludge)
+ */
+ if (!strcmp (fromcode, FC_ENCODING_MAC_ROMAN) &&
+ sname->language_id >= 0x100)
+ {
+ int f;
+
+ fromcode = 0;
+ for (f = 0; f < NUM_FC_MAC_ROMAN_FAKE; f++)
+ if (fcMacRomanFake[f].language_id == sname->language_id)
+ {
+ fromcode = fcMacRomanFake[f].fromcode;
+ break;
+ }
+ if (!fromcode)
+ return 0;
+ }
+ if (!strcmp (fromcode, "UCS-2BE") || !strcmp (fromcode, "UTF-16BE"))
+ {
+ FcChar8 *src = sname->string;
+ int src_len = sname->string_len;
+ int len;
+ int wchar;
+ int ilen, olen;
+ FcChar8 *u8;
+ FcChar32 ucs4;
+
+ /*
+ * Convert Utf16 to Utf8
+ */
+
+ if (!FcUtf16Len (src, FcEndianBig, src_len, &len, &wchar))
+ return 0;
+
+ /*
+ * Allocate plenty of space. Freed below
+ */
+ utf8 = malloc (len * FC_UTF8_MAX_LEN + 1);
+ if (!utf8)
+ return 0;
+
+ u8 = utf8;
+
+ while ((ilen = FcUtf16ToUcs4 (src, FcEndianBig, &ucs4, src_len)) > 0)
+ {
+ src_len -= ilen;
+ src += ilen;
+ olen = FcUcs4ToUtf8 (ucs4, u8);
+ u8 += olen;
+ }
+ *u8 = '\0';
+ goto done;
+ }
+ if (!strcmp (fromcode, "ASCII") || !strcmp (fromcode, "ISO-8859-1"))
+ {
+ FcChar8 *src = sname->string;
+ int src_len = sname->string_len;
+ int olen;
+ FcChar8 *u8;
+ FcChar32 ucs4;
+
+ /*
+ * Convert Latin1 to Utf8. Freed below
+ */
+ utf8 = malloc (src_len * 2 + 1);
+ if (!utf8)
+ return 0;
+
+ u8 = utf8;
+ while (src_len > 0)
+ {
+ ucs4 = *src++;
+ src_len--;
+ olen = FcUcs4ToUtf8 (ucs4, u8);
+ u8 += olen;
+ }
+ *u8 = '\0';
+ goto done;
+ }
+ if (!strcmp (fromcode, FC_ENCODING_MAC_ROMAN))
+ {
+ FcChar8 *u8;
+ const FcCharMap *map = FcFreeTypeGetPrivateMap (ft_encoding_apple_roman);
+ FcChar8 *src = (FcChar8 *) sname->string;
+ int src_len = sname->string_len;
+
+ /*
+ * Convert AppleRoman to Utf8
+ */
+ if (!map)
+ return 0;
+
+ utf8 = malloc (sname->string_len * 3 + 1);
+ if (!utf8)
+ return 0;
+
+ u8 = utf8;
+ while (src_len > 0)
+ {
+ FcChar32 ucs4 = FcFreeTypePrivateToUcs4 (*src++, map);
+ int olen = FcUcs4ToUtf8 (ucs4, u8);
+ src_len--;
+ u8 += olen;
+ }
+ *u8 = '\0';
+ goto done;
+ }
+#if USE_ICONV
+ cd = iconv_open ("UTF-8", fromcode);
+ if (cd && cd != (iconv_t) (-1))
+ {
+ size_t in_bytes_left = sname->string_len;
+ size_t out_bytes_left = sname->string_len * FC_UTF8_MAX_LEN;
+ char *inbuf, *outbuf;
+
+ utf8 = malloc (out_bytes_left + 1);
+ if (!utf8)
+ {
+ iconv_close (cd);
+ return 0;
+ }
+
+ outbuf = (char *) utf8;
+ inbuf = (char *) sname->string;
+
+ while (in_bytes_left)
+ {
+ size_t did = iconv (cd,
+ &inbuf, &in_bytes_left,
+ &outbuf, &out_bytes_left);
+ if (did == (size_t) (-1))
+ {
+ iconv_close (cd);
+ free (utf8);
+ return 0;
+ }
+ }
+ iconv_close (cd);
+ *outbuf = '\0';
+ goto done;
+ }
+#endif
+ return 0;
+done:
+ if (FcStrCmpIgnoreBlanksAndCase (utf8, "") == 0)
+ {
+ free (utf8);
+ return 0;
+ }
+ return utf8;
+}
+
+static FcChar8 *
+FcSfntNameLanguage (FT_SfntName *sname)
+{
+ int i;
+ for (i = 0; i < NUM_FC_FT_LANGUAGE; i++)
+ if (fcFtLanguage[i].platform_id == sname->platform_id &&
+ (fcFtLanguage[i].language_id == TT_LANGUAGE_DONT_CARE ||
+ fcFtLanguage[i].language_id == sname->language_id))
+ return fcFtLanguage[i].lang;
+ return 0;
+}
+
+/* Order is significant. For example, some B&H fonts are hinted by
+ URW++, and both strings appear in the notice. */
+
+static const struct {
+ const FT_String *notice;
+ const FcChar8 *foundry;
+} FcNoticeFoundries[] = {
+ { (const FT_String *) "Bigelow", (const FcChar8 *) "b&h" },
+ { (const FT_String *) "Adobe", (const FcChar8 *) "adobe" },
+ { (const FT_String *) "Bitstream", (const FcChar8 *) "bitstream" },
+ { (const FT_String *) "Monotype", (const FcChar8 *) "monotype" },
+ { (const FT_String *) "Linotype", (const FcChar8 *) "linotype" },
+ { (const FT_String *) "LINOTYPE-HELL",
+ (const FcChar8 *) "linotype" },
+ { (const FT_String *) "IBM", (const FcChar8 *) "ibm" },
+ { (const FT_String *) "URW", (const FcChar8 *) "urw" },
+ { (const FT_String *) "International Typeface Corporation",
+ (const FcChar8 *) "itc" },
+ { (const FT_String *) "Tiro Typeworks",
+ (const FcChar8 *) "tiro" },
+ { (const FT_String *) "XFree86", (const FcChar8 *) "xfree86" },
+ { (const FT_String *) "Microsoft", (const FcChar8 *) "microsoft" },
+ { (const FT_String *) "Omega", (const FcChar8 *) "omega" },
+ { (const FT_String *) "Font21", (const FcChar8 *) "hwan" },
+ { (const FT_String *) "HanYang System",
+ (const FcChar8 *) "hanyang" }
+};
+
+#define NUM_NOTICE_FOUNDRIES (sizeof (FcNoticeFoundries) / sizeof (FcNoticeFoundries[0]))
+
+static const FcChar8 *
+FcNoticeFoundry(const FT_String *notice)
+{
+ int i;
+
+ if (notice)
+ for(i = 0; i < NUM_NOTICE_FOUNDRIES; i++)
+ if (strstr ((const char *) notice, (const char *) FcNoticeFoundries[i].notice))
+ return FcNoticeFoundries[i].foundry;
+ return 0;
+}
+
+static FcBool
+FcVendorMatch(const FT_Char vendor[4], const FT_Char *vendor_string)
+{
+ /* vendor is not necessarily NUL-terminated. */
+ int i, len;
+
+ len = strlen(vendor_string);
+ if (memcmp(vendor, vendor_string, len) != 0)
+ return FcFalse;
+ for (i = len; i < 4; i++)
+ if (vendor[i] != ' ' && vendor[i] != '\0')
+ return FcFalse;
+ return FcTrue;
+}
+
+/* This table is partly taken from ttmkfdir by Joerg Pommnitz. */
+
+/* It should not contain useless entries (such as UNKN) nor duplicate
+ entries for padding both with spaces and NULs. */
+
+static const struct {
+ const FT_Char *vendor;
+ const FcChar8 *foundry;
+} FcVendorFoundries[] = {
+ { (const FT_Char *) "ADBE", (const FcChar8 *) "adobe"},
+ { (const FT_Char *) "AGFA", (const FcChar8 *) "agfa"},
+ { (const FT_Char *) "ALTS", (const FcChar8 *) "altsys"},
+ { (const FT_Char *) "APPL", (const FcChar8 *) "apple"},
+ { (const FT_Char *) "ARPH", (const FcChar8 *) "arphic"},
+ { (const FT_Char *) "ATEC", (const FcChar8 *) "alltype"},
+ { (const FT_Char *) "B&H", (const FcChar8 *) "b&h"},
+ { (const FT_Char *) "BITS", (const FcChar8 *) "bitstream"},
+ { (const FT_Char *) "CANO", (const FcChar8 *) "cannon"},
+ { (const FT_Char *) "DYNA", (const FcChar8 *) "dynalab"},
+ { (const FT_Char *) "EPSN", (const FcChar8 *) "epson"},
+ { (const FT_Char *) "FJ", (const FcChar8 *) "fujitsu"},
+ { (const FT_Char *) "IBM", (const FcChar8 *) "ibm"},
+ { (const FT_Char *) "ITC", (const FcChar8 *) "itc"},
+ { (const FT_Char *) "IMPR", (const FcChar8 *) "impress"},
+ { (const FT_Char *) "LARA", (const FcChar8 *) "larabiefonts"},
+ { (const FT_Char *) "LEAF", (const FcChar8 *) "interleaf"},
+ { (const FT_Char *) "LETR", (const FcChar8 *) "letraset"},
+ { (const FT_Char *) "LINO", (const FcChar8 *) "linotype"},
+ { (const FT_Char *) "MACR", (const FcChar8 *) "macromedia"},
+ { (const FT_Char *) "MONO", (const FcChar8 *) "monotype"},
+ { (const FT_Char *) "MS", (const FcChar8 *) "microsoft"},
+ { (const FT_Char *) "MT", (const FcChar8 *) "monotype"},
+ { (const FT_Char *) "NEC", (const FcChar8 *) "nec"},
+ { (const FT_Char *) "PARA", (const FcChar8 *) "paratype"},
+ { (const FT_Char *) "QMSI", (const FcChar8 *) "qms"},
+ { (const FT_Char *) "RICO", (const FcChar8 *) "ricoh"},
+ { (const FT_Char *) "URW", (const FcChar8 *) "urw"},
+ { (const FT_Char *) "Y&Y", (const FcChar8 *) "y&y"}
+};
+
+#define NUM_VENDOR_FOUNDRIES (sizeof (FcVendorFoundries) / sizeof (FcVendorFoundries[0]))
+
+static const FcChar8 *
+FcVendorFoundry(const FT_Char vendor[4])
+{
+ int i;
+
+ if (vendor)
+ for(i = 0; i < NUM_VENDOR_FOUNDRIES; i++)
+ if (FcVendorMatch (vendor, FcVendorFoundries[i].vendor))
+ return FcVendorFoundries[i].foundry;
+ return 0;
+}
+
+typedef struct _FcStringConst {
+ const FcChar8 *name;
+ int value;
+} FcStringConst;
+
+static int
+FcStringIsConst (const FcChar8 *string,
+ const FcStringConst *c,
+ int nc)
+{
+ int i;
+
+ for (i = 0; i < nc; i++)
+ if (FcStrCmpIgnoreBlanksAndCase (string, c[i].name) == 0)
+ return c[i].value;
+ return -1;
+}
+
+static int
+FcStringContainsConst (const FcChar8 *string,
+ const FcStringConst *c,
+ int nc)
+{
+ int i;
+
+ for (i = 0; i < nc; i++)
+ if (FcStrContainsIgnoreBlanksAndCase (string, c[i].name))
+ return c[i].value;
+ return -1;
+}
+
+static const FcStringConst weightConsts[] = {
+ { "thin", FC_WEIGHT_THIN },
+ { "extralight", FC_WEIGHT_EXTRALIGHT },
+ { "ultralight", FC_WEIGHT_ULTRALIGHT },
+ { "light", FC_WEIGHT_LIGHT },
+ { "book", FC_WEIGHT_BOOK },
+ { "regular", FC_WEIGHT_REGULAR },
+ { "normal", FC_WEIGHT_NORMAL },
+ { "medium", FC_WEIGHT_MEDIUM },
+ { "demibold", FC_WEIGHT_DEMIBOLD },
+ { "demi", FC_WEIGHT_DEMIBOLD },
+ { "semibold", FC_WEIGHT_SEMIBOLD },
+ { "bold", FC_WEIGHT_BOLD },
+ { "extrabold", FC_WEIGHT_EXTRABOLD },
+ { "ultrabold", FC_WEIGHT_ULTRABOLD },
+ { "black", FC_WEIGHT_BLACK },
+ { "heavy", FC_WEIGHT_HEAVY },
+};
+
+#define NUM_WEIGHT_CONSTS (sizeof (weightConsts) / sizeof (weightConsts[0]))
+
+#define FcIsWeight(s) FcStringIsConst(s,weightConsts,NUM_WEIGHT_CONSTS)
+#define FcContainsWeight(s) FcStringContainsConst (s,weightConsts,NUM_WEIGHT_CONSTS)
+
+static const FcStringConst widthConsts[] = {
+ { "ultracondensed", FC_WIDTH_ULTRACONDENSED },
+ { "extracondensed", FC_WIDTH_EXTRACONDENSED },
+ { "semicondensed", FC_WIDTH_SEMICONDENSED },
+ { "condensed", FC_WIDTH_CONDENSED }, /* must be after *condensed */
+ { "normal", FC_WIDTH_NORMAL },
+ { "semiexpanded", FC_WIDTH_SEMIEXPANDED },
+ { "extraexpanded", FC_WIDTH_EXTRAEXPANDED },
+ { "ultraexpanded", FC_WIDTH_ULTRAEXPANDED },
+ { "expanded", FC_WIDTH_EXPANDED }, /* must be after *expanded */
+};
+
+#define NUM_WIDTH_CONSTS (sizeof (widthConsts) / sizeof (widthConsts[0]))
+
+#define FcIsWidth(s) FcStringIsConst(s,widthConsts,NUM_WIDTH_CONSTS)
+#define FcContainsWidth(s) FcStringContainsConst (s,widthConsts,NUM_WIDTH_CONSTS)
+
+static const FcStringConst slantConsts[] = {
+ { "italic", FC_SLANT_ITALIC },
+ { "oblique", FC_SLANT_OBLIQUE },
+};
+
+#define NUM_SLANT_CONSTS (sizeof (slantConsts) / sizeof (slantConsts[0]))
+
+#define FcIsSlant(s) FcStringIsConst(s,slantConsts,NUM_SLANT_CONSTS)
+#define FcContainsSlant(s) FcStringContainsConst (s,slantConsts,NUM_SLANT_CONSTS)
+
+static double
+FcGetPixelSize (FT_Face face, int i)
+{
+#if HAVE_FT_GET_BDF_PROPERTY
+ if (face->num_fixed_sizes == 1)
+ {
+ BDF_PropertyRec prop;
+ int rc;
+
+ rc = MY_Get_BDF_Property (face, "PIXEL_SIZE", &prop);
+ if (rc == 0 && prop.type == BDF_PROPERTY_TYPE_INTEGER)
+ return (double) prop.u.integer;
+ }
+#endif
+#if HAVE_FT_BITMAP_SIZE_Y_PPEM
+ return (double) face->available_sizes[i].y_ppem / 64.0;
+#else
+ return (double) face->available_sizes[i].height;
+#endif
+}
+
+static FcBool
+FcStringInPatternElement (FcPattern *pat, char *elt, FcChar8 *string)
+{
+ int e;
+ FcChar8 *old;
+ for (e = 0; FcPatternGetString (pat, elt, e, &old) == FcResultMatch; e++)
+ if (!FcStrCmpIgnoreBlanksAndCase (old, string))
+ {
+ return FcTrue;
+ break;
+ }
+ return FcFalse;
+}
+
+FcPattern *
+FcFreeTypeQuery (const FcChar8 *file,
+ int id,
+ FcBlanks *blanks,
+ int *count)
+{
+ FT_Face face;
+ FcPattern *pat;
+ int slant = -1;
+ int weight = -1;
+ int width = -1;
+ int i;
+ FcCharSet *cs;
+ FcLangSet *ls;
+ FT_Library ftLibrary;
+#if 0
+ FcChar8 *family = 0;
+#endif
+ FcChar8 *complex;
+ const FcChar8 *foundry = 0;
+ int spacing;
+ TT_OS2 *os2;
+#if HAVE_FT_GET_PS_FONT_INFO
+ PS_FontInfoRec psfontinfo;
+#endif
+#if HAVE_FT_GET_BDF_PROPERTY
+ BDF_PropertyRec prop;
+#endif
+ TT_Header *head;
+ const FcChar8 *exclusiveLang = 0;
+ FT_SfntName sname;
+ FT_UInt snamei, snamec;
+
+ int nfamily = 0;
+ int nfamily_lang = 0;
+ int nstyle = 0;
+ int nstyle_lang = 0;
+ int nfullname = 0;
+ int nfullname_lang = 0;
+
+ FcChar8 *style = 0;
+ int st;
+
+ if (FT_Init_FreeType (&ftLibrary))
+ return 0;
+
+ if (FT_New_Face (ftLibrary, (char *) file, id, &face))
+ goto bail;
+
+ *count = face->num_faces;
+
+ pat = FcPatternCreate ();
+ if (!pat)
+ goto bail0;
+
+ if (!FcPatternAddBool (pat, FC_OUTLINE,
+ (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
+ goto bail1;
+
+ if (!FcPatternAddBool (pat, FC_SCALABLE,
+ (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
+ goto bail1;
+
+
+ /*
+ * Get the OS/2 table
+ */
+ os2 = (TT_OS2 *) FT_Get_Sfnt_Table (face, ft_sfnt_os2);
+
+ /*
+ * Look first in the OS/2 table for the foundry, if
+ * not found here, the various notices will be searched for
+ * that information, either from the sfnt name tables or
+ * the Postscript FontInfo dictionary. Finally, the
+ * BDF properties will queried.
+ */
+
+ if (os2 && os2->version >= 0x0001 && os2->version != 0xffff)
+ foundry = FcVendorFoundry(os2->achVendID);
+
+ if (FcDebug () & FC_DBG_SCANV)
+ printf ("\n");
+ /*
+ * Grub through the name table looking for family
+ * and style names. FreeType makes quite a hash
+ * of them
+ */
+ snamec = FT_Get_Sfnt_Name_Count (face);
+ for (snamei = 0; snamei < snamec; snamei++)
+ {
+ FcChar8 *utf8;
+ FcChar8 *lang;
+ char *elt = 0, *eltlang = 0;
+ int *np = 0, *nlangp = 0;
+
+ if (FT_Get_Sfnt_Name (face, snamei, &sname) != 0)
+ continue;
+
+ utf8 = FcSfntNameTranscode (&sname);
+ lang = FcSfntNameLanguage (&sname);
+
+ if (!utf8)
+ continue;
+
+ switch (sname.name_id) {
+ case TT_NAME_ID_FONT_FAMILY:
+#if 0
+ case TT_NAME_ID_PS_NAME:
+ case TT_NAME_ID_UNIQUE_ID:
+#endif
+ if (FcDebug () & FC_DBG_SCANV)
+ printf ("found family (n %2d p %d e %d l 0x%04x) %s\n",
+ sname.name_id, sname.platform_id,
+ sname.encoding_id, sname.language_id,
+ utf8);
+
+ elt = FC_FAMILY;
+ eltlang = FC_FAMILYLANG;
+ np = &nfamily;
+ nlangp = &nfamily_lang;
+ break;
+ case TT_NAME_ID_FULL_NAME:
+ case TT_NAME_ID_MAC_FULL_NAME:
+ if (FcDebug () & FC_DBG_SCANV)
+ printf ("found full (n %2d p %d e %d l 0x%04x) %s\n",
+ sname.name_id, sname.platform_id,
+ sname.encoding_id, sname.language_id,
+ utf8);
+
+ elt = FC_FULLNAME;
+ eltlang = FC_FULLNAMELANG;
+ np = &nfullname;
+ nlangp = &nfullname_lang;
+ break;
+ case TT_NAME_ID_FONT_SUBFAMILY:
+ if (FcDebug () & FC_DBG_SCANV)
+ printf ("found style (n %2d p %d e %d l 0x%04x) %s\n",
+ sname.name_id, sname.platform_id,
+ sname.encoding_id, sname.language_id,
+ utf8);
+
+ elt = FC_STYLE;
+ eltlang = FC_STYLELANG;
+ np = &nstyle;
+ nlangp = &nstyle_lang;
+ break;
+ case TT_NAME_ID_TRADEMARK:
+ case TT_NAME_ID_MANUFACTURER:
+ /* If the foundry wasn't found in the OS/2 table, look here */
+ if(!foundry)
+ foundry = FcNoticeFoundry((FT_String *) utf8);
+ break;
+ }
+ if (elt)
+ {
+ if (FcStringInPatternElement (pat, elt, utf8))
+ {
+ free (utf8);
+ continue;
+ }
+
+ /* add new element */
+ if (!FcPatternAddString (pat, elt, utf8))
+ {
+ free (utf8);
+ goto bail1;
+ }
+ free (utf8);
+ if (lang)
+ {
+ /* pad lang list with 'xx' to line up with elt */
+ while (*nlangp < *np)
+ {
+ if (!FcPatternAddString (pat, eltlang, "xx"))
+ goto bail1;
+ ++*nlangp;
+ }
+ if (!FcPatternAddString (pat, eltlang, lang))
+ goto bail1;
+ ++*nlangp;
+ }
+ ++*np;
+ }
+ else
+ free (utf8);
+ }
+
+ if (!nfamily && face->family_name &&
+ FcStrCmpIgnoreBlanksAndCase (face->family_name, "") != 0)
+ {
+ if (FcDebug () & FC_DBG_SCANV)
+ printf ("using FreeType family \"%s\"\n", face->family_name);
+ if (!FcPatternAddString (pat, FC_FAMILY, face->family_name))
+ goto bail1;
+ ++nfamily;
+ }
+
+ if (!nstyle && face->style_name &&
+ FcStrCmpIgnoreBlanksAndCase (face->style_name, "") != 0)
+ {
+ if (FcDebug () & FC_DBG_SCANV)
+ printf ("using FreeType style \"%s\"\n", face->style_name);
+ if (!FcPatternAddString (pat, FC_STYLE, face->style_name))
+ goto bail1;
+ ++nstyle;
+ }
+
+ if (!nfamily)
+ {
+ FcChar8 *start, *end;
+ FcChar8 *family;
+
+ start = (FcChar8 *) strrchr ((char *) file, '/');
+ if (start)
+ start++;
+ else
+ start = (FcChar8 *) file;
+ end = (FcChar8 *) strrchr ((char *) start, '.');
+ if (!end)
+ end = start + strlen ((char *) start);
+ /* freed below */
+ family = malloc (end - start + 1);
+ strncpy ((char *) family, (char *) start, end - start);
+ family[end - start] = '\0';
+ if (FcDebug () & FC_DBG_SCANV)
+ printf ("using filename for family %s\n", family);
+ if (!FcPatternAddString (pat, FC_FAMILY, family))
+ {
+ free (family);
+ goto bail1;
+ }
+ free (family);
+ ++nfamily;
+ }
+
+ /*
+ * Walk through FC_FULLNAME entries eliding those in FC_FAMILY
+ * or which are simply a FC_FAMILY and FC_STYLE glued together
+ */
+ {
+ int fn, fa, st;
+ FcChar8 *full;
+ FcChar8 *fam;
+ FcChar8 *style;
+
+ for (fn = 0; FcPatternGetString (pat, FC_FULLNAME, fn, &full) == FcResultMatch; fn++)
+ {
+ FcBool remove = FcFalse;
+ /*
+ * Check each family
+ */
+ for (fa = 0; !remove &&
+ FcPatternGetString (pat, FC_FAMILY,
+ fa, &fam) == FcResultMatch;
+ fa++)
+ {
+ /*
+ * for exact match
+ */
+ if (!FcStrCmpIgnoreBlanksAndCase (full, fam))
+ {
+ remove = FcTrue;
+ break;
+ }
+ /*
+ * If the family is in the full name, check the
+ * combination of this family with every style
+ */
+ if (!FcStrContainsIgnoreBlanksAndCase (full, fam))
+ continue;
+ for (st = 0; !remove &&
+ FcPatternGetString (pat, FC_STYLE,
+ st, &style) == FcResultMatch;
+ st++)
+ {
+ FcChar8 *both = FcStrPlus (fam, style);
+
+ if (both)
+ {
+ if (FcStrCmpIgnoreBlanksAndCase (full, both) == 0)
+ remove = FcTrue;
+ free (both);
+ }
+ }
+ }
+ if (remove)
+ {
+ FcPatternRemove (pat, FC_FULLNAME, fn);
+ FcPatternRemove (pat, FC_FULLNAMELANG, fn);
+ fn--;
+ nfullname--;
+ nfullname_lang--;
+ }
+ }
+ if (FcDebug () & FC_DBG_SCANV)
+ for (fn = 0; FcPatternGetString (pat, FC_FULLNAME, fn, &full) == FcResultMatch; fn++)
+ printf ("Saving unique fullname %s\n", full);
+ }
+
+ if (!FcPatternAddString (pat, FC_FILE, file))
+ goto bail1;
+
+ if (!FcPatternAddInteger (pat, FC_INDEX, id))
+ goto bail1;
+
+#if 0
+ /*
+ * don't even try this -- CJK 'monospace' fonts are really
+ * dual width, and most other fonts don't bother to set
+ * the attribute. Sigh.
+ */
+ if ((face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) != 0)
+ if (!FcPatternAddInteger (pat, FC_SPACING, FC_MONO))
+ goto bail1;
+#endif
+
+ /*
+ * Find the font revision (if available)
+ */
+ head = (TT_Header *) FT_Get_Sfnt_Table (face, ft_sfnt_head);
+ if (head)
+ {
+ if (!FcPatternAddInteger (pat, FC_FONTVERSION, head->Font_Revision))
+ goto bail1;
+ }
+ else
+ {
+ if (!FcPatternAddInteger (pat, FC_FONTVERSION, 0))
+ goto bail1;
+ }
+
+ if (os2 && os2->version >= 0x0001 && os2->version != 0xffff)
+ {
+ for (i = 0; i < NUM_CODE_PAGE_RANGE; i++)
+ {
+ FT_ULong bits;
+ int bit;
+ if (FcCodePageRange[i].bit < 32)
+ {
+ bits = os2->ulCodePageRange1;
+ bit = FcCodePageRange[i].bit;
+ }
+ else
+ {
+ bits = os2->ulCodePageRange2;
+ bit = FcCodePageRange[i].bit - 32;
+ }
+ if (bits & (1 << bit))
+ {
+ /*
+ * If the font advertises support for multiple
+ * "exclusive" languages, then include support
+ * for any language found to have coverage
+ */
+ if (exclusiveLang)
+ {
+ exclusiveLang = 0;
+ break;
+ }
+ exclusiveLang = FcCodePageRange[i].lang;
+ }
+ }
+ }
+
+ if (os2 && os2->version != 0xffff)
+ {
+ if (os2->usWeightClass == 0)
+ ;
+ else if (os2->usWeightClass < 150)
+ weight = FC_WEIGHT_THIN;
+ else if (os2->usWeightClass < 250)
+ weight = FC_WEIGHT_EXTRALIGHT;
+ else if (os2->usWeightClass < 350)
+ weight = FC_WEIGHT_LIGHT;
+ else if (os2->usWeightClass < 450)
+ weight = FC_WEIGHT_REGULAR;
+ else if (os2->usWeightClass < 550)
+ weight = FC_WEIGHT_MEDIUM;
+ else if (os2->usWeightClass < 650)
+ weight = FC_WEIGHT_SEMIBOLD;
+ else if (os2->usWeightClass < 750)
+ weight = FC_WEIGHT_BOLD;
+ else if (os2->usWeightClass < 850)
+ weight = FC_WEIGHT_EXTRABOLD;
+ else if (os2->usWeightClass < 950)
+ weight = FC_WEIGHT_BLACK;
+
+ switch (os2->usWidthClass) {
+ case 1: width = FC_WIDTH_ULTRACONDENSED; break;
+ case 2: width = FC_WIDTH_EXTRACONDENSED; break;
+ case 3: width = FC_WIDTH_CONDENSED; break;
+ case 4: width = FC_WIDTH_SEMICONDENSED; break;
+ case 5: width = FC_WIDTH_NORMAL; break;
+ case 6: width = FC_WIDTH_SEMIEXPANDED; break;
+ case 7: width = FC_WIDTH_EXPANDED; break;
+ case 8: width = FC_WIDTH_EXTRAEXPANDED; break;
+ case 9: width = FC_WIDTH_ULTRAEXPANDED; break;
+ }
+ }
+ if (os2 && (complex = FcFontCapabilities(face)))
+ {
+ if (!FcPatternAddString (pat, FC_CAPABILITY, complex))
+ {
+ free (complex);
+ goto bail1;
+ }
+ free (complex);
+ }
+
+ /*
+ * Type 1: Check for FontInfo dictionary information
+ * Code from g2@magestudios.net (Gerard Escalante)
+ */
+
+#if HAVE_FT_GET_PS_FONT_INFO
+ if (FT_Get_PS_Font_Info(face, &psfontinfo) == 0)
+ {
+ if (weight == -1 && psfontinfo.weight)
+ {
+ weight = FcIsWeight (psfontinfo.weight);
+ if (FcDebug() & FC_DBG_SCANV)
+ printf ("\tType1 weight %s maps to %d\n",
+ psfontinfo.weight, weight);
+ }
+
+#if 0
+ /*
+ * Don't bother with italic_angle; FreeType already extracts that
+ * information for us and sticks it into style_flags
+ */
+ if (psfontinfo.italic_angle)
+ slant = FC_SLANT_ITALIC;
+ else
+ slant = FC_SLANT_ROMAN;
+#endif
+
+ if(!foundry)
+ foundry = FcNoticeFoundry(psfontinfo.notice);
+ }
+#endif /* HAVE_FT_GET_PS_FONT_INFO */
+
+#if HAVE_FT_GET_BDF_PROPERTY
+ /*
+ * Finally, look for a FOUNDRY BDF property if no other
+ * mechanism has managed to locate a foundry
+ */
+
+ if (!foundry)
+ {
+ int rc;
+ BDF_PropertyRec prop;
+ rc = MY_Get_BDF_Property(face, "FOUNDRY", &prop);
+ if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM)
+ foundry = prop.u.atom;
+ }
+
+ if (width == -1)
+ {
+ if (MY_Get_BDF_Property(face, "RELATIVE_SETWIDTH", &prop) == 0 &&
+ (prop.type == BDF_PROPERTY_TYPE_INTEGER ||
+ prop.type == BDF_PROPERTY_TYPE_CARDINAL))
+ {
+ FT_Int32 value;
+
+ if (prop.type == BDF_PROPERTY_TYPE_INTEGER)
+ value = prop.u.integer;
+ else
+ value = (FT_Int32) prop.u.cardinal;
+ switch ((value + 5) / 10) {
+ case 1: width = FC_WIDTH_ULTRACONDENSED; break;
+ case 2: width = FC_WIDTH_EXTRACONDENSED; break;
+ case 3: width = FC_WIDTH_CONDENSED; break;
+ case 4: width = FC_WIDTH_SEMICONDENSED; break;
+ case 5: width = FC_WIDTH_NORMAL; break;
+ case 6: width = FC_WIDTH_SEMIEXPANDED; break;
+ case 7: width = FC_WIDTH_EXPANDED; break;
+ case 8: width = FC_WIDTH_EXTRAEXPANDED; break;
+ case 9: width = FC_WIDTH_ULTRAEXPANDED; break;
+ }
+ }
+ if (width == -1 &&
+ MY_Get_BDF_Property (face, "SETWIDTH_NAME", &prop) == 0 &&
+ prop.type == BDF_PROPERTY_TYPE_ATOM)
+ {
+ width = FcIsWidth (prop.u.atom);
+ if (FcDebug () & FC_DBG_SCANV)
+ printf ("\tsetwidth %s maps to %d\n", prop.u.atom, width);
+ }
+ }
+#endif
+
+ /*
+ * Look for weight, width and slant names in the style value
+ */
+ for (st = 0; FcPatternGetString (pat, FC_STYLE, st, &style) == FcResultMatch; st++)
+ {
+ if (weight == -1)
+ {
+ weight = FcContainsWeight (style);
+ if (FcDebug() & FC_DBG_SCANV)
+ printf ("\tStyle %s maps to weight %d\n", style, weight);
+ }
+ if (width == -1)
+ {
+ width = FcContainsWidth (style);
+ if (FcDebug() & FC_DBG_SCANV)
+ printf ("\tStyle %s maps to width %d\n", style, width);
+ }
+ if (slant == -1)
+ {
+ slant = FcContainsSlant (style);
+ if (FcDebug() & FC_DBG_SCANV)
+ printf ("\tStyle %s maps to slant %d\n", style, slant);
+ }
+ }
+ /*
+ * Pull default values from the FreeType flags if more
+ * specific values not found above
+ */
+ if (slant == -1)
+ {
+ slant = FC_SLANT_ROMAN;
+ if (face->style_flags & FT_STYLE_FLAG_ITALIC)
+ slant = FC_SLANT_ITALIC;
+ }
+
+ if (weight == -1)
+ {
+ weight = FC_WEIGHT_MEDIUM;
+ if (face->style_flags & FT_STYLE_FLAG_BOLD)
+ weight = FC_WEIGHT_BOLD;
+ }
+
+ if (width == -1)
+ width = FC_WIDTH_NORMAL;
+
+ if (foundry == 0)
+ foundry = "unknown";
+
+ if (!FcPatternAddInteger (pat, FC_SLANT, slant))
+ goto bail1;
+
+ if (!FcPatternAddInteger (pat, FC_WEIGHT, weight))
+ goto bail1;
+
+ if (!FcPatternAddInteger (pat, FC_WIDTH, width))
+ goto bail1;
+
+ if (!FcPatternAddString (pat, FC_FOUNDRY, foundry))
+ goto bail1;
+
+ /*
+ * Compute the unicode coverage for the font
+ */
+ cs = FcFreeTypeCharSetAndSpacing (face, blanks, &spacing);
+ if (!cs)
+ goto bail1;
+
+#if HAVE_FT_GET_BDF_PROPERTY
+ /* For PCF fonts, override the computed spacing with the one from
+ the property */
+ if(MY_Get_BDF_Property(face, "SPACING", &prop) == 0 &&
+ prop.type == BDF_PROPERTY_TYPE_ATOM) {
+ if(!strcmp(prop.u.atom, "c") || !strcmp(prop.u.atom, "C"))
+ spacing = FC_CHARCELL;
+ else if(!strcmp(prop.u.atom, "m") || !strcmp(prop.u.atom, "M"))
+ spacing = FC_MONO;
+ else if(!strcmp(prop.u.atom, "p") || !strcmp(prop.u.atom, "P"))
+ spacing = FC_PROPORTIONAL;
+ }
+#endif
+
+ /*
+ * Skip over PCF fonts that have no encoded characters; they're
+ * usually just Unicode fonts transcoded to some legacy encoding
+ */
+ if (FcCharSetCount (cs) == 0)
+ {
+ if (!strcmp(FT_MODULE_CLASS(&face->driver->root)->module_name, "pcf"))
+ goto bail2;
+ }
+
+ if (!FcPatternAddCharSet (pat, FC_CHARSET, cs))
+ goto bail2;
+
+ ls = FcFreeTypeLangSet (cs, exclusiveLang);
+ if (!ls)
+ goto bail2;
+
+ if (!FcPatternAddLangSet (pat, FC_LANG, ls))
+ {
+ FcLangSetDestroy (ls);
+ goto bail2;
+ }
+
+ FcLangSetDestroy (ls);
+
+ if (spacing != FC_PROPORTIONAL)
+ if (!FcPatternAddInteger (pat, FC_SPACING, spacing))
+ goto bail2;
+
+ if (!(face->face_flags & FT_FACE_FLAG_SCALABLE))
+ {
+ for (i = 0; i < face->num_fixed_sizes; i++)
+ if (!FcPatternAddDouble (pat, FC_PIXEL_SIZE,
+ FcGetPixelSize (face, i)))
+ goto bail1;
+ if (!FcPatternAddBool (pat, FC_ANTIALIAS, FcFalse))
+ goto bail1;
+#if HAVE_FT_GET_BDF_PROPERTY
+ if(face->num_fixed_sizes == 1) {
+ int rc;
+ int value;
+ BDF_PropertyRec prop;
+
+ rc = MY_Get_BDF_Property(face, "POINT_SIZE", &prop);
+ if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_INTEGER)
+ value = prop.u.integer;
+ else if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_CARDINAL)
+ value = prop.u.cardinal;
+ else
+ goto nevermind;
+ if(!FcPatternAddDouble(pat, FC_SIZE, value / 10.0))
+ goto nevermind;
+
+ rc = MY_Get_BDF_Property(face, "RESOLUTION_Y", &prop);
+ if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_INTEGER)
+ value = prop.u.integer;
+ else if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_CARDINAL)
+ value = prop.u.cardinal;
+ else
+ goto nevermind;
+ if(!FcPatternAddDouble(pat, FC_DPI, (double)value))
+ goto nevermind;
+
+ }
+ nevermind:
+ ;
+#endif
+ }
+#if HAVE_FT_GET_X11_FONT_FORMAT
+ /*
+ * Use the (not well documented or supported) X-specific function
+ * from FreeType to figure out the font format
+ */
+ {
+ const char *font_format = FT_Get_X11_Font_Format (face);
+ if (font_format)
+ FcPatternAddString (pat, FC_FONTFORMAT, font_format);
+ }
+#endif
+
+ /*
+ * Drop our reference to the charset
+ */
+ FcCharSetDestroy (cs);
+
+ /*
+ * Deallocate family/style values
+ */
+
+ FT_Done_Face (face);
+ FT_Done_FreeType (ftLibrary);
+ return pat;
+
+bail2:
+ FcCharSetDestroy (cs);
+bail1:
+ FcPatternDestroy (pat);
+bail0:
+ FT_Done_Face (face);
+bail:
+ FT_Done_FreeType (ftLibrary);
+ return 0;
+}
+
+
+/*
+ * For our purposes, this approximation is sufficient
+ */
+#if !HAVE_FT_GET_NEXT_CHAR
+#define FT_Get_Next_Char(face, ucs4, gi) ((ucs4) >= 0xffffff ? \
+ (*(gi) = 0), 0 : \
+ (*(gi) = 1), (ucs4) + 1)
+#warning "No FT_Get_Next_Char: Please install freetype version 2.1.0 or newer"
+#endif
+
+typedef struct _FcCharEnt {
+ FcChar16 bmp;
+ unsigned char encode;
+} FcCharEnt;
+
+struct _FcCharMap {
+ const FcCharEnt *ent;
+ int nent;
+};
+
+typedef struct _FcFontDecode {
+ FT_Encoding encoding;
+ const FcCharMap *map;
+ FcChar32 max;
+} FcFontDecode;
+
+static const FcCharEnt AppleRomanEnt[] = {
+ { 0x0020, 0x20 }, /* SPACE */
+ { 0x0021, 0x21 }, /* EXCLAMATION MARK */
+ { 0x0022, 0x22 }, /* QUOTATION MARK */
+ { 0x0023, 0x23 }, /* NUMBER SIGN */
+ { 0x0024, 0x24 }, /* DOLLAR SIGN */
+ { 0x0025, 0x25 }, /* PERCENT SIGN */
+ { 0x0026, 0x26 }, /* AMPERSAND */
+ { 0x0027, 0x27 }, /* APOSTROPHE */
+ { 0x0028, 0x28 }, /* LEFT PARENTHESIS */
+ { 0x0029, 0x29 }, /* RIGHT PARENTHESIS */
+ { 0x002A, 0x2A }, /* ASTERISK */
+ { 0x002B, 0x2B }, /* PLUS SIGN */
+ { 0x002C, 0x2C }, /* COMMA */
+ { 0x002D, 0x2D }, /* HYPHEN-MINUS */
+ { 0x002E, 0x2E }, /* FULL STOP */
+ { 0x002F, 0x2F }, /* SOLIDUS */
+ { 0x0030, 0x30 }, /* DIGIT ZERO */
+ { 0x0031, 0x31 }, /* DIGIT ONE */
+ { 0x0032, 0x32 }, /* DIGIT TWO */
+ { 0x0033, 0x33 }, /* DIGIT THREE */
+ { 0x0034, 0x34 }, /* DIGIT FOUR */
+ { 0x0035, 0x35 }, /* DIGIT FIVE */
+ { 0x0036, 0x36 }, /* DIGIT SIX */
+ { 0x0037, 0x37 }, /* DIGIT SEVEN */
+ { 0x0038, 0x38 }, /* DIGIT EIGHT */
+ { 0x0039, 0x39 }, /* DIGIT NINE */
+ { 0x003A, 0x3A }, /* COLON */
+ { 0x003B, 0x3B }, /* SEMICOLON */
+ { 0x003C, 0x3C }, /* LESS-THAN SIGN */
+ { 0x003D, 0x3D }, /* EQUALS SIGN */
+ { 0x003E, 0x3E }, /* GREATER-THAN SIGN */
+ { 0x003F, 0x3F }, /* QUESTION MARK */
+ { 0x0040, 0x40 }, /* COMMERCIAL AT */
+ { 0x0041, 0x41 }, /* LATIN CAPITAL LETTER A */
+ { 0x0042, 0x42 }, /* LATIN CAPITAL LETTER B */
+ { 0x0043, 0x43 }, /* LATIN CAPITAL LETTER C */
+ { 0x0044, 0x44 }, /* LATIN CAPITAL LETTER D */
+ { 0x0045, 0x45 }, /* LATIN CAPITAL LETTER E */
+ { 0x0046, 0x46 }, /* LATIN CAPITAL LETTER F */
+ { 0x0047, 0x47 }, /* LATIN CAPITAL LETTER G */
+ { 0x0048, 0x48 }, /* LATIN CAPITAL LETTER H */
+ { 0x0049, 0x49 }, /* LATIN CAPITAL LETTER I */
+ { 0x004A, 0x4A }, /* LATIN CAPITAL LETTER J */
+ { 0x004B, 0x4B }, /* LATIN CAPITAL LETTER K */
+ { 0x004C, 0x4C }, /* LATIN CAPITAL LETTER L */
+ { 0x004D, 0x4D }, /* LATIN CAPITAL LETTER M */
+ { 0x004E, 0x4E }, /* LATIN CAPITAL LETTER N */
+ { 0x004F, 0x4F }, /* LATIN CAPITAL LETTER O */
+ { 0x0050, 0x50 }, /* LATIN CAPITAL LETTER P */
+ { 0x0051, 0x51 }, /* LATIN CAPITAL LETTER Q */
+ { 0x0052, 0x52 }, /* LATIN CAPITAL LETTER R */
+ { 0x0053, 0x53 }, /* LATIN CAPITAL LETTER S */
+ { 0x0054, 0x54 }, /* LATIN CAPITAL LETTER T */
+ { 0x0055, 0x55 }, /* LATIN CAPITAL LETTER U */
+ { 0x0056, 0x56 }, /* LATIN CAPITAL LETTER V */
+ { 0x0057, 0x57 }, /* LATIN CAPITAL LETTER W */
+ { 0x0058, 0x58 }, /* LATIN CAPITAL LETTER X */
+ { 0x0059, 0x59 }, /* LATIN CAPITAL LETTER Y */
+ { 0x005A, 0x5A }, /* LATIN CAPITAL LETTER Z */
+ { 0x005B, 0x5B }, /* LEFT SQUARE BRACKET */
+ { 0x005C, 0x5C }, /* REVERSE SOLIDUS */
+ { 0x005D, 0x5D }, /* RIGHT SQUARE BRACKET */
+ { 0x005E, 0x5E }, /* CIRCUMFLEX ACCENT */
+ { 0x005F, 0x5F }, /* LOW LINE */
+ { 0x0060, 0x60 }, /* GRAVE ACCENT */
+ { 0x0061, 0x61 }, /* LATIN SMALL LETTER A */
+ { 0x0062, 0x62 }, /* LATIN SMALL LETTER B */
+ { 0x0063, 0x63 }, /* LATIN SMALL LETTER C */
+ { 0x0064, 0x64 }, /* LATIN SMALL LETTER D */
+ { 0x0065, 0x65 }, /* LATIN SMALL LETTER E */
+ { 0x0066, 0x66 }, /* LATIN SMALL LETTER F */
+ { 0x0067, 0x67 }, /* LATIN SMALL LETTER G */
+ { 0x0068, 0x68 }, /* LATIN SMALL LETTER H */
+ { 0x0069, 0x69 }, /* LATIN SMALL LETTER I */
+ { 0x006A, 0x6A }, /* LATIN SMALL LETTER J */
+ { 0x006B, 0x6B }, /* LATIN SMALL LETTER K */
+ { 0x006C, 0x6C }, /* LATIN SMALL LETTER L */
+ { 0x006D, 0x6D }, /* LATIN SMALL LETTER M */
+ { 0x006E, 0x6E }, /* LATIN SMALL LETTER N */
+ { 0x006F, 0x6F }, /* LATIN SMALL LETTER O */
+ { 0x0070, 0x70 }, /* LATIN SMALL LETTER P */
+ { 0x0071, 0x71 }, /* LATIN SMALL LETTER Q */
+ { 0x0072, 0x72 }, /* LATIN SMALL LETTER R */
+ { 0x0073, 0x73 }, /* LATIN SMALL LETTER S */
+ { 0x0074, 0x74 }, /* LATIN SMALL LETTER T */
+ { 0x0075, 0x75 }, /* LATIN SMALL LETTER U */
+ { 0x0076, 0x76 }, /* LATIN SMALL LETTER V */
+ { 0x0077, 0x77 }, /* LATIN SMALL LETTER W */
+ { 0x0078, 0x78 }, /* LATIN SMALL LETTER X */
+ { 0x0079, 0x79 }, /* LATIN SMALL LETTER Y */
+ { 0x007A, 0x7A }, /* LATIN SMALL LETTER Z */
+ { 0x007B, 0x7B }, /* LEFT CURLY BRACKET */
+ { 0x007C, 0x7C }, /* VERTICAL LINE */
+ { 0x007D, 0x7D }, /* RIGHT CURLY BRACKET */
+ { 0x007E, 0x7E }, /* TILDE */
+ { 0x00A0, 0xCA }, /* NO-BREAK SPACE */
+ { 0x00A1, 0xC1 }, /* INVERTED EXCLAMATION MARK */
+ { 0x00A2, 0xA2 }, /* CENT SIGN */
+ { 0x00A3, 0xA3 }, /* POUND SIGN */
+ { 0x00A5, 0xB4 }, /* YEN SIGN */
+ { 0x00A7, 0xA4 }, /* SECTION SIGN */
+ { 0x00A8, 0xAC }, /* DIAERESIS */
+ { 0x00A9, 0xA9 }, /* COPYRIGHT SIGN */
+ { 0x00AA, 0xBB }, /* FEMININE ORDINAL INDICATOR */
+ { 0x00AB, 0xC7 }, /* LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */
+ { 0x00AC, 0xC2 }, /* NOT SIGN */
+ { 0x00AE, 0xA8 }, /* REGISTERED SIGN */
+ { 0x00AF, 0xF8 }, /* MACRON */
+ { 0x00B0, 0xA1 }, /* DEGREE SIGN */
+ { 0x00B1, 0xB1 }, /* PLUS-MINUS SIGN */
+ { 0x00B4, 0xAB }, /* ACUTE ACCENT */
+ { 0x00B5, 0xB5 }, /* MICRO SIGN */
+ { 0x00B6, 0xA6 }, /* PILCROW SIGN */
+ { 0x00B7, 0xE1 }, /* MIDDLE DOT */
+ { 0x00B8, 0xFC }, /* CEDILLA */
+ { 0x00BA, 0xBC }, /* MASCULINE ORDINAL INDICATOR */
+ { 0x00BB, 0xC8 }, /* RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */
+ { 0x00BF, 0xC0 }, /* INVERTED QUESTION MARK */
+ { 0x00C0, 0xCB }, /* LATIN CAPITAL LETTER A WITH GRAVE */
+ { 0x00C1, 0xE7 }, /* LATIN CAPITAL LETTER A WITH ACUTE */
+ { 0x00C2, 0xE5 }, /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */
+ { 0x00C3, 0xCC }, /* LATIN CAPITAL LETTER A WITH TILDE */
+ { 0x00C4, 0x80 }, /* LATIN CAPITAL LETTER A WITH DIAERESIS */
+ { 0x00C5, 0x81 }, /* LATIN CAPITAL LETTER A WITH RING ABOVE */
+ { 0x00C6, 0xAE }, /* LATIN CAPITAL LETTER AE */
+ { 0x00C7, 0x82 }, /* LATIN CAPITAL LETTER C WITH CEDILLA */
+ { 0x00C8, 0xE9 }, /* LATIN CAPITAL LETTER E WITH GRAVE */
+ { 0x00C9, 0x83 }, /* LATIN CAPITAL LETTER E WITH ACUTE */
+ { 0x00CA, 0xE6 }, /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */
+ { 0x00CB, 0xE8 }, /* LATIN CAPITAL LETTER E WITH DIAERESIS */
+ { 0x00CC, 0xED }, /* LATIN CAPITAL LETTER I WITH GRAVE */
+ { 0x00CD, 0xEA }, /* LATIN CAPITAL LETTER I WITH ACUTE */
+ { 0x00CE, 0xEB }, /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */
+ { 0x00CF, 0xEC }, /* LATIN CAPITAL LETTER I WITH DIAERESIS */
+ { 0x00D1, 0x84 }, /* LATIN CAPITAL LETTER N WITH TILDE */
+ { 0x00D2, 0xF1 }, /* LATIN CAPITAL LETTER O WITH GRAVE */
+ { 0x00D3, 0xEE }, /* LATIN CAPITAL LETTER O WITH ACUTE */
+ { 0x00D4, 0xEF }, /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */
+ { 0x00D5, 0xCD }, /* LATIN CAPITAL LETTER O WITH TILDE */
+ { 0x00D6, 0x85 }, /* LATIN CAPITAL LETTER O WITH DIAERESIS */
+ { 0x00D8, 0xAF }, /* LATIN CAPITAL LETTER O WITH STROKE */
+ { 0x00D9, 0xF4 }, /* LATIN CAPITAL LETTER U WITH GRAVE */
+ { 0x00DA, 0xF2 }, /* LATIN CAPITAL LETTER U WITH ACUTE */
+ { 0x00DB, 0xF3 }, /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */
+ { 0x00DC, 0x86 }, /* LATIN CAPITAL LETTER U WITH DIAERESIS */
+ { 0x00DF, 0xA7 }, /* LATIN SMALL LETTER SHARP S */
+ { 0x00E0, 0x88 }, /* LATIN SMALL LETTER A WITH GRAVE */
+ { 0x00E1, 0x87 }, /* LATIN SMALL LETTER A WITH ACUTE */
+ { 0x00E2, 0x89 }, /* LATIN SMALL LETTER A WITH CIRCUMFLEX */
+ { 0x00E3, 0x8B }, /* LATIN SMALL LETTER A WITH TILDE */
+ { 0x00E4, 0x8A }, /* LATIN SMALL LETTER A WITH DIAERESIS */
+ { 0x00E5, 0x8C }, /* LATIN SMALL LETTER A WITH RING ABOVE */
+ { 0x00E6, 0xBE }, /* LATIN SMALL LETTER AE */
+ { 0x00E7, 0x8D }, /* LATIN SMALL LETTER C WITH CEDILLA */
+ { 0x00E8, 0x8F }, /* LATIN SMALL LETTER E WITH GRAVE */
+ { 0x00E9, 0x8E }, /* LATIN SMALL LETTER E WITH ACUTE */
+ { 0x00EA, 0x90 }, /* LATIN SMALL LETTER E WITH CIRCUMFLEX */
+ { 0x00EB, 0x91 }, /* LATIN SMALL LETTER E WITH DIAERESIS */
+ { 0x00EC, 0x93 }, /* LATIN SMALL LETTER I WITH GRAVE */
+ { 0x00ED, 0x92 }, /* LATIN SMALL LETTER I WITH ACUTE */
+ { 0x00EE, 0x94 }, /* LATIN SMALL LETTER I WITH CIRCUMFLEX */
+ { 0x00EF, 0x95 }, /* LATIN SMALL LETTER I WITH DIAERESIS */
+ { 0x00F1, 0x96 }, /* LATIN SMALL LETTER N WITH TILDE */
+ { 0x00F2, 0x98 }, /* LATIN SMALL LETTER O WITH GRAVE */
+ { 0x00F3, 0x97 }, /* LATIN SMALL LETTER O WITH ACUTE */
+ { 0x00F4, 0x99 }, /* LATIN SMALL LETTER O WITH CIRCUMFLEX */
+ { 0x00F5, 0x9B }, /* LATIN SMALL LETTER O WITH TILDE */
+ { 0x00F6, 0x9A }, /* LATIN SMALL LETTER O WITH DIAERESIS */
+ { 0x00F7, 0xD6 }, /* DIVISION SIGN */
+ { 0x00F8, 0xBF }, /* LATIN SMALL LETTER O WITH STROKE */
+ { 0x00F9, 0x9D }, /* LATIN SMALL LETTER U WITH GRAVE */
+ { 0x00FA, 0x9C }, /* LATIN SMALL LETTER U WITH ACUTE */
+ { 0x00FB, 0x9E }, /* LATIN SMALL LETTER U WITH CIRCUMFLEX */
+ { 0x00FC, 0x9F }, /* LATIN SMALL LETTER U WITH DIAERESIS */
+ { 0x00FF, 0xD8 }, /* LATIN SMALL LETTER Y WITH DIAERESIS */
+ { 0x0131, 0xF5 }, /* LATIN SMALL LETTER DOTLESS I */
+ { 0x0152, 0xCE }, /* LATIN CAPITAL LIGATURE OE */
+ { 0x0153, 0xCF }, /* LATIN SMALL LIGATURE OE */
+ { 0x0178, 0xD9 }, /* LATIN CAPITAL LETTER Y WITH DIAERESIS */
+ { 0x0192, 0xC4 }, /* LATIN SMALL LETTER F WITH HOOK */
+ { 0x02C6, 0xF6 }, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
+ { 0x02C7, 0xFF }, /* CARON */
+ { 0x02D8, 0xF9 }, /* BREVE */
+ { 0x02D9, 0xFA }, /* DOT ABOVE */
+ { 0x02DA, 0xFB }, /* RING ABOVE */
+ { 0x02DB, 0xFE }, /* OGONEK */
+ { 0x02DC, 0xF7 }, /* SMALL TILDE */
+ { 0x02DD, 0xFD }, /* DOUBLE ACUTE ACCENT */
+ { 0x03A9, 0xBD }, /* GREEK CAPITAL LETTER OMEGA */
+ { 0x03C0, 0xB9 }, /* GREEK SMALL LETTER PI */
+ { 0x2013, 0xD0 }, /* EN DASH */
+ { 0x2014, 0xD1 }, /* EM DASH */
+ { 0x2018, 0xD4 }, /* LEFT SINGLE QUOTATION MARK */
+ { 0x2019, 0xD5 }, /* RIGHT SINGLE QUOTATION MARK */
+ { 0x201A, 0xE2 }, /* SINGLE LOW-9 QUOTATION MARK */
+ { 0x201C, 0xD2 }, /* LEFT DOUBLE QUOTATION MARK */
+ { 0x201D, 0xD3 }, /* RIGHT DOUBLE QUOTATION MARK */
+ { 0x201E, 0xE3 }, /* DOUBLE LOW-9 QUOTATION MARK */
+ { 0x2020, 0xA0 }, /* DAGGER */
+ { 0x2021, 0xE0 }, /* DOUBLE DAGGER */
+ { 0x2022, 0xA5 }, /* BULLET */
+ { 0x2026, 0xC9 }, /* HORIZONTAL ELLIPSIS */
+ { 0x2030, 0xE4 }, /* PER MILLE SIGN */
+ { 0x2039, 0xDC }, /* SINGLE LEFT-POINTING ANGLE QUOTATION MARK */
+ { 0x203A, 0xDD }, /* SINGLE RIGHT-POINTING ANGLE QUOTATION MARK */
+ { 0x2044, 0xDA }, /* FRACTION SLASH */
+ { 0x20AC, 0xDB }, /* EURO SIGN */
+ { 0x2122, 0xAA }, /* TRADE MARK SIGN */
+ { 0x2202, 0xB6 }, /* PARTIAL DIFFERENTIAL */
+ { 0x2206, 0xC6 }, /* INCREMENT */
+ { 0x220F, 0xB8 }, /* N-ARY PRODUCT */
+ { 0x2211, 0xB7 }, /* N-ARY SUMMATION */
+ { 0x221A, 0xC3 }, /* SQUARE ROOT */
+ { 0x221E, 0xB0 }, /* INFINITY */
+ { 0x222B, 0xBA }, /* INTEGRAL */
+ { 0x2248, 0xC5 }, /* ALMOST EQUAL TO */
+ { 0x2260, 0xAD }, /* NOT EQUAL TO */
+ { 0x2264, 0xB2 }, /* LESS-THAN OR EQUAL TO */
+ { 0x2265, 0xB3 }, /* GREATER-THAN OR EQUAL TO */
+ { 0x25CA, 0xD7 }, /* LOZENGE */
+ { 0xF8FF, 0xF0 }, /* Apple logo */
+ { 0xFB01, 0xDE }, /* LATIN SMALL LIGATURE FI */
+ { 0xFB02, 0xDF }, /* LATIN SMALL LIGATURE FL */
+};
+
+static const FcCharMap AppleRoman = {
+ AppleRomanEnt,
+ sizeof (AppleRomanEnt) / sizeof (AppleRomanEnt[0])
+};
+
+static const FcCharEnt AdobeSymbolEnt[] = {
+ { 0x0020, 0x20 }, /* SPACE # space */
+ { 0x0021, 0x21 }, /* EXCLAMATION MARK # exclam */
+ { 0x0023, 0x23 }, /* NUMBER SIGN # numbersign */
+ { 0x0025, 0x25 }, /* PERCENT SIGN # percent */
+ { 0x0026, 0x26 }, /* AMPERSAND # ampersand */
+ { 0x0028, 0x28 }, /* LEFT PARENTHESIS # parenleft */
+ { 0x0029, 0x29 }, /* RIGHT PARENTHESIS # parenright */
+ { 0x002B, 0x2B }, /* PLUS SIGN # plus */
+ { 0x002C, 0x2C }, /* COMMA # comma */
+ { 0x002E, 0x2E }, /* FULL STOP # period */
+ { 0x002F, 0x2F }, /* SOLIDUS # slash */
+ { 0x0030, 0x30 }, /* DIGIT ZERO # zero */
+ { 0x0031, 0x31 }, /* DIGIT ONE # one */
+ { 0x0032, 0x32 }, /* DIGIT TWO # two */
+ { 0x0033, 0x33 }, /* DIGIT THREE # three */
+ { 0x0034, 0x34 }, /* DIGIT FOUR # four */
+ { 0x0035, 0x35 }, /* DIGIT FIVE # five */
+ { 0x0036, 0x36 }, /* DIGIT SIX # six */
+ { 0x0037, 0x37 }, /* DIGIT SEVEN # seven */
+ { 0x0038, 0x38 }, /* DIGIT EIGHT # eight */
+ { 0x0039, 0x39 }, /* DIGIT NINE # nine */
+ { 0x003A, 0x3A }, /* COLON # colon */
+ { 0x003B, 0x3B }, /* SEMICOLON # semicolon */
+ { 0x003C, 0x3C }, /* LESS-THAN SIGN # less */
+ { 0x003D, 0x3D }, /* EQUALS SIGN # equal */
+ { 0x003E, 0x3E }, /* GREATER-THAN SIGN # greater */
+ { 0x003F, 0x3F }, /* QUESTION MARK # question */
+ { 0x005B, 0x5B }, /* LEFT SQUARE BRACKET # bracketleft */
+ { 0x005D, 0x5D }, /* RIGHT SQUARE BRACKET # bracketright */
+ { 0x005F, 0x5F }, /* LOW LINE # underscore */
+ { 0x007B, 0x7B }, /* LEFT CURLY BRACKET # braceleft */
+ { 0x007C, 0x7C }, /* VERTICAL LINE # bar */
+ { 0x007D, 0x7D }, /* RIGHT CURLY BRACKET # braceright */
+ { 0x00A0, 0x20 }, /* NO-BREAK SPACE # space */
+ { 0x00AC, 0xD8 }, /* NOT SIGN # logicalnot */
+ { 0x00B0, 0xB0 }, /* DEGREE SIGN # degree */
+ { 0x00B1, 0xB1 }, /* PLUS-MINUS SIGN # plusminus */
+ { 0x00B5, 0x6D }, /* MICRO SIGN # mu */
+ { 0x00D7, 0xB4 }, /* MULTIPLICATION SIGN # multiply */
+ { 0x00F7, 0xB8 }, /* DIVISION SIGN # divide */
+ { 0x0192, 0xA6 }, /* LATIN SMALL LETTER F WITH HOOK # florin */
+ { 0x0391, 0x41 }, /* GREEK CAPITAL LETTER ALPHA # Alpha */
+ { 0x0392, 0x42 }, /* GREEK CAPITAL LETTER BETA # Beta */
+ { 0x0393, 0x47 }, /* GREEK CAPITAL LETTER GAMMA # Gamma */
+ { 0x0394, 0x44 }, /* GREEK CAPITAL LETTER DELTA # Delta */
+ { 0x0395, 0x45 }, /* GREEK CAPITAL LETTER EPSILON # Epsilon */
+ { 0x0396, 0x5A }, /* GREEK CAPITAL LETTER ZETA # Zeta */
+ { 0x0397, 0x48 }, /* GREEK CAPITAL LETTER ETA # Eta */
+ { 0x0398, 0x51 }, /* GREEK CAPITAL LETTER THETA # Theta */
+ { 0x0399, 0x49 }, /* GREEK CAPITAL LETTER IOTA # Iota */
+ { 0x039A, 0x4B }, /* GREEK CAPITAL LETTER KAPPA # Kappa */
+ { 0x039B, 0x4C }, /* GREEK CAPITAL LETTER LAMDA # Lambda */
+ { 0x039C, 0x4D }, /* GREEK CAPITAL LETTER MU # Mu */
+ { 0x039D, 0x4E }, /* GREEK CAPITAL LETTER NU # Nu */
+ { 0x039E, 0x58 }, /* GREEK CAPITAL LETTER XI # Xi */
+ { 0x039F, 0x4F }, /* GREEK CAPITAL LETTER OMICRON # Omicron */
+ { 0x03A0, 0x50 }, /* GREEK CAPITAL LETTER PI # Pi */
+ { 0x03A1, 0x52 }, /* GREEK CAPITAL LETTER RHO # Rho */
+ { 0x03A3, 0x53 }, /* GREEK CAPITAL LETTER SIGMA # Sigma */
+ { 0x03A4, 0x54 }, /* GREEK CAPITAL LETTER TAU # Tau */
+ { 0x03A5, 0x55 }, /* GREEK CAPITAL LETTER UPSILON # Upsilon */
+ { 0x03A6, 0x46 }, /* GREEK CAPITAL LETTER PHI # Phi */
+ { 0x03A7, 0x43 }, /* GREEK CAPITAL LETTER CHI # Chi */
+ { 0x03A8, 0x59 }, /* GREEK CAPITAL LETTER PSI # Psi */
+ { 0x03A9, 0x57 }, /* GREEK CAPITAL LETTER OMEGA # Omega */
+ { 0x03B1, 0x61 }, /* GREEK SMALL LETTER ALPHA # alpha */
+ { 0x03B2, 0x62 }, /* GREEK SMALL LETTER BETA # beta */
+ { 0x03B3, 0x67 }, /* GREEK SMALL LETTER GAMMA # gamma */
+ { 0x03B4, 0x64 }, /* GREEK SMALL LETTER DELTA # delta */
+ { 0x03B5, 0x65 }, /* GREEK SMALL LETTER EPSILON # epsilon */
+ { 0x03B6, 0x7A }, /* GREEK SMALL LETTER ZETA # zeta */
+ { 0x03B7, 0x68 }, /* GREEK SMALL LETTER ETA # eta */
+ { 0x03B8, 0x71 }, /* GREEK SMALL LETTER THETA # theta */
+ { 0x03B9, 0x69 }, /* GREEK SMALL LETTER IOTA # iota */
+ { 0x03BA, 0x6B }, /* GREEK SMALL LETTER KAPPA # kappa */
+ { 0x03BB, 0x6C }, /* GREEK SMALL LETTER LAMDA # lambda */
+ { 0x03BC, 0x6D }, /* GREEK SMALL LETTER MU # mu */
+ { 0x03BD, 0x6E }, /* GREEK SMALL LETTER NU # nu */
+ { 0x03BE, 0x78 }, /* GREEK SMALL LETTER XI # xi */
+ { 0x03BF, 0x6F }, /* GREEK SMALL LETTER OMICRON # omicron */
+ { 0x03C0, 0x70 }, /* GREEK SMALL LETTER PI # pi */
+ { 0x03C1, 0x72 }, /* GREEK SMALL LETTER RHO # rho */
+ { 0x03C2, 0x56 }, /* GREEK SMALL LETTER FINAL SIGMA # sigma1 */
+ { 0x03C3, 0x73 }, /* GREEK SMALL LETTER SIGMA # sigma */
+ { 0x03C4, 0x74 }, /* GREEK SMALL LETTER TAU # tau */
+ { 0x03C5, 0x75 }, /* GREEK SMALL LETTER UPSILON # upsilon */
+ { 0x03C6, 0x66 }, /* GREEK SMALL LETTER PHI # phi */
+ { 0x03C7, 0x63 }, /* GREEK SMALL LETTER CHI # chi */
+ { 0x03C8, 0x79 }, /* GREEK SMALL LETTER PSI # psi */
+ { 0x03C9, 0x77 }, /* GREEK SMALL LETTER OMEGA # omega */
+ { 0x03D1, 0x4A }, /* GREEK THETA SYMBOL # theta1 */
+ { 0x03D2, 0xA1 }, /* GREEK UPSILON WITH HOOK SYMBOL # Upsilon1 */
+ { 0x03D5, 0x6A }, /* GREEK PHI SYMBOL # phi1 */
+ { 0x03D6, 0x76 }, /* GREEK PI SYMBOL # omega1 */
+ { 0x2022, 0xB7 }, /* BULLET # bullet */
+ { 0x2026, 0xBC }, /* HORIZONTAL ELLIPSIS # ellipsis */
+ { 0x2032, 0xA2 }, /* PRIME # minute */
+ { 0x2033, 0xB2 }, /* DOUBLE PRIME # second */
+ { 0x2044, 0xA4 }, /* FRACTION SLASH # fraction */
+ { 0x20AC, 0xA0 }, /* EURO SIGN # Euro */
+ { 0x2111, 0xC1 }, /* BLACK-LETTER CAPITAL I # Ifraktur */
+ { 0x2118, 0xC3 }, /* SCRIPT CAPITAL P # weierstrass */
+ { 0x211C, 0xC2 }, /* BLACK-LETTER CAPITAL R # Rfraktur */
+ { 0x2126, 0x57 }, /* OHM SIGN # Omega */
+ { 0x2135, 0xC0 }, /* ALEF SYMBOL # aleph */
+ { 0x2190, 0xAC }, /* LEFTWARDS ARROW # arrowleft */
+ { 0x2191, 0xAD }, /* UPWARDS ARROW # arrowup */
+ { 0x2192, 0xAE }, /* RIGHTWARDS ARROW # arrowright */
+ { 0x2193, 0xAF }, /* DOWNWARDS ARROW # arrowdown */
+ { 0x2194, 0xAB }, /* LEFT RIGHT ARROW # arrowboth */
+ { 0x21B5, 0xBF }, /* DOWNWARDS ARROW WITH CORNER LEFTWARDS # carriagereturn */
+ { 0x21D0, 0xDC }, /* LEFTWARDS DOUBLE ARROW # arrowdblleft */
+ { 0x21D1, 0xDD }, /* UPWARDS DOUBLE ARROW # arrowdblup */
+ { 0x21D2, 0xDE }, /* RIGHTWARDS DOUBLE ARROW # arrowdblright */
+ { 0x21D3, 0xDF }, /* DOWNWARDS DOUBLE ARROW # arrowdbldown */
+ { 0x21D4, 0xDB }, /* LEFT RIGHT DOUBLE ARROW # arrowdblboth */
+ { 0x2200, 0x22 }, /* FOR ALL # universal */
+ { 0x2202, 0xB6 }, /* PARTIAL DIFFERENTIAL # partialdiff */
+ { 0x2203, 0x24 }, /* THERE EXISTS # existential */
+ { 0x2205, 0xC6 }, /* EMPTY SET # emptyset */
+ { 0x2206, 0x44 }, /* INCREMENT # Delta */
+ { 0x2207, 0xD1 }, /* NABLA # gradient */
+ { 0x2208, 0xCE }, /* ELEMENT OF # element */
+ { 0x2209, 0xCF }, /* NOT AN ELEMENT OF # notelement */
+ { 0x220B, 0x27 }, /* CONTAINS AS MEMBER # suchthat */
+ { 0x220F, 0xD5 }, /* N-ARY PRODUCT # product */
+ { 0x2211, 0xE5 }, /* N-ARY SUMMATION # summation */
+ { 0x2212, 0x2D }, /* MINUS SIGN # minus */
+ { 0x2215, 0xA4 }, /* DIVISION SLASH # fraction */
+ { 0x2217, 0x2A }, /* ASTERISK OPERATOR # asteriskmath */
+ { 0x221A, 0xD6 }, /* SQUARE ROOT # radical */
+ { 0x221D, 0xB5 }, /* PROPORTIONAL TO # proportional */
+ { 0x221E, 0xA5 }, /* INFINITY # infinity */
+ { 0x2220, 0xD0 }, /* ANGLE # angle */
+ { 0x2227, 0xD9 }, /* LOGICAL AND # logicaland */
+ { 0x2228, 0xDA }, /* LOGICAL OR # logicalor */
+ { 0x2229, 0xC7 }, /* INTERSECTION # intersection */
+ { 0x222A, 0xC8 }, /* UNION # union */
+ { 0x222B, 0xF2 }, /* INTEGRAL # integral */
+ { 0x2234, 0x5C }, /* THEREFORE # therefore */
+ { 0x223C, 0x7E }, /* TILDE OPERATOR # similar */
+ { 0x2245, 0x40 }, /* APPROXIMATELY EQUAL TO # congruent */
+ { 0x2248, 0xBB }, /* ALMOST EQUAL TO # approxequal */
+ { 0x2260, 0xB9 }, /* NOT EQUAL TO # notequal */
+ { 0x2261, 0xBA }, /* IDENTICAL TO # equivalence */
+ { 0x2264, 0xA3 }, /* LESS-THAN OR EQUAL TO # lessequal */
+ { 0x2265, 0xB3 }, /* GREATER-THAN OR EQUAL TO # greaterequal */
+ { 0x2282, 0xCC }, /* SUBSET OF # propersubset */
+ { 0x2283, 0xC9 }, /* SUPERSET OF # propersuperset */
+ { 0x2284, 0xCB }, /* NOT A SUBSET OF # notsubset */
+ { 0x2286, 0xCD }, /* SUBSET OF OR EQUAL TO # reflexsubset */
+ { 0x2287, 0xCA }, /* SUPERSET OF OR EQUAL TO # reflexsuperset */
+ { 0x2295, 0xC5 }, /* CIRCLED PLUS # circleplus */
+ { 0x2297, 0xC4 }, /* CIRCLED TIMES # circlemultiply */
+ { 0x22A5, 0x5E }, /* UP TACK # perpendicular */
+ { 0x22C5, 0xD7 }, /* DOT OPERATOR # dotmath */
+ { 0x2320, 0xF3 }, /* TOP HALF INTEGRAL # integraltp */
+ { 0x2321, 0xF5 }, /* BOTTOM HALF INTEGRAL # integralbt */
+ { 0x2329, 0xE1 }, /* LEFT-POINTING ANGLE BRACKET # angleleft */
+ { 0x232A, 0xF1 }, /* RIGHT-POINTING ANGLE BRACKET # angleright */
+ { 0x25CA, 0xE0 }, /* LOZENGE # lozenge */
+ { 0x2660, 0xAA }, /* BLACK SPADE SUIT # spade */
+ { 0x2663, 0xA7 }, /* BLACK CLUB SUIT # club */
+ { 0x2665, 0xA9 }, /* BLACK HEART SUIT # heart */
+ { 0x2666, 0xA8 }, /* BLACK DIAMOND SUIT # diamond */
+ { 0xF6D9, 0xD3 }, /* COPYRIGHT SIGN SERIF # copyrightserif (CUS) */
+ { 0xF6DA, 0xD2 }, /* REGISTERED SIGN SERIF # registerserif (CUS) */
+ { 0xF6DB, 0xD4 }, /* TRADE MARK SIGN SERIF # trademarkserif (CUS) */
+ { 0xF8E5, 0x60 }, /* RADICAL EXTENDER # radicalex (CUS) */
+ { 0xF8E6, 0xBD }, /* VERTICAL ARROW EXTENDER # arrowvertex (CUS) */
+ { 0xF8E7, 0xBE }, /* HORIZONTAL ARROW EXTENDER # arrowhorizex (CUS) */
+ { 0xF8E8, 0xE2 }, /* REGISTERED SIGN SANS SERIF # registersans (CUS) */
+ { 0xF8E9, 0xE3 }, /* COPYRIGHT SIGN SANS SERIF # copyrightsans (CUS) */
+ { 0xF8EA, 0xE4 }, /* TRADE MARK SIGN SANS SERIF # trademarksans (CUS) */
+ { 0xF8EB, 0xE6 }, /* LEFT PAREN TOP # parenlefttp (CUS) */
+ { 0xF8EC, 0xE7 }, /* LEFT PAREN EXTENDER # parenleftex (CUS) */
+ { 0xF8ED, 0xE8 }, /* LEFT PAREN BOTTOM # parenleftbt (CUS) */
+ { 0xF8EE, 0xE9 }, /* LEFT SQUARE BRACKET TOP # bracketlefttp (CUS) */
+ { 0xF8EF, 0xEA }, /* LEFT SQUARE BRACKET EXTENDER # bracketleftex (CUS) */
+ { 0xF8F0, 0xEB }, /* LEFT SQUARE BRACKET BOTTOM # bracketleftbt (CUS) */
+ { 0xF8F1, 0xEC }, /* LEFT CURLY BRACKET TOP # bracelefttp (CUS) */
+ { 0xF8F2, 0xED }, /* LEFT CURLY BRACKET MID # braceleftmid (CUS) */
+ { 0xF8F3, 0xEE }, /* LEFT CURLY BRACKET BOTTOM # braceleftbt (CUS) */
+ { 0xF8F4, 0xEF }, /* CURLY BRACKET EXTENDER # braceex (CUS) */
+ { 0xF8F5, 0xF4 }, /* INTEGRAL EXTENDER # integralex (CUS) */
+ { 0xF8F6, 0xF6 }, /* RIGHT PAREN TOP # parenrighttp (CUS) */
+ { 0xF8F7, 0xF7 }, /* RIGHT PAREN EXTENDER # parenrightex (CUS) */
+ { 0xF8F8, 0xF8 }, /* RIGHT PAREN BOTTOM # parenrightbt (CUS) */
+ { 0xF8F9, 0xF9 }, /* RIGHT SQUARE BRACKET TOP # bracketrighttp (CUS) */
+ { 0xF8FA, 0xFA }, /* RIGHT SQUARE BRACKET EXTENDER # bracketrightex (CUS) */
+ { 0xF8FB, 0xFB }, /* RIGHT SQUARE BRACKET BOTTOM # bracketrightbt (CUS) */
+ { 0xF8FC, 0xFC }, /* RIGHT CURLY BRACKET TOP # bracerighttp (CUS) */
+ { 0xF8FD, 0xFD }, /* RIGHT CURLY BRACKET MID # bracerightmid (CUS) */
+ { 0xF8FE, 0xFE }, /* RIGHT CURLY BRACKET BOTTOM # bracerightbt (CUS) */
+};
+
+static const FcCharMap AdobeSymbol = {
+ AdobeSymbolEnt,
+ sizeof (AdobeSymbolEnt) / sizeof (AdobeSymbolEnt[0]),
+};
+
+static const FcFontDecode fcFontDecoders[] = {
+ { ft_encoding_unicode, 0, (1 << 21) - 1 },
+ { ft_encoding_symbol, &AdobeSymbol, (1 << 16) - 1 },
+ { ft_encoding_apple_roman, &AppleRoman, (1 << 16) - 1 },
+};
+
+#define NUM_DECODE (sizeof (fcFontDecoders) / sizeof (fcFontDecoders[0]))
+
+static const FcChar32 prefer_unicode[] = {
+ 0x20ac, /* EURO SIGN */
+};
+
+#define NUM_PREFER_UNICODE (sizeof (prefer_unicode) / sizeof (prefer_unicode[0]))
+
+FcChar32
+FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map)
+{
+ int low, high, mid;
+ FcChar16 bmp;
+
+ low = 0;
+ high = map->nent - 1;
+ if (ucs4 < map->ent[low].bmp || map->ent[high].bmp < ucs4)
+ return ~0;
+ while (low <= high)
+ {
+ mid = (high + low) >> 1;
+ bmp = map->ent[mid].bmp;
+ if (ucs4 == bmp)
+ return (FT_ULong) map->ent[mid].encode;
+ if (ucs4 < bmp)
+ high = mid - 1;
+ else
+ low = mid + 1;
+ }
+ return ~0;
+}
+
+FcChar32
+FcFreeTypePrivateToUcs4 (FcChar32 private, const FcCharMap *map)
+{
+ int i;
+
+ for (i = 0; i < map->nent; i++)
+ if (map->ent[i].encode == private)
+ return (FcChar32) map->ent[i].bmp;
+ return ~0;
+}
+
+const FcCharMap *
+FcFreeTypeGetPrivateMap (FT_Encoding encoding)
+{
+ int i;
+
+ for (i = 0; i < NUM_DECODE; i++)
+ if (fcFontDecoders[i].encoding == encoding)
+ return fcFontDecoders[i].map;
+ return 0;
+}
+
+#include "fc-glyphname/fcglyphname.h"
+
+static FcChar32
+FcHashGlyphName (const FcChar8 *name)
+{
+ FcChar32 h = 0;
+ FcChar8 c;
+
+ while ((c = *name++))
+ {
+ h = ((h << 1) | (h >> 31)) ^ c;
+ }
+ return h;
+}
+
+#if HAVE_FT_HAS_PS_GLYPH_NAMES
+/*
+ * Use Type1 glyph names for fonts which have reliable names
+ * and which export an Adobe Custom mapping
+ */
+static FcBool
+FcFreeTypeUseNames (FT_Face face)
+{
+ FT_Int map;
+
+ if (!FT_Has_PS_Glyph_Names (face))
+ return FcFalse;
+ for (map = 0; map < face->num_charmaps; map++)
+ if (face->charmaps[map]->encoding == ft_encoding_adobe_custom)
+ return FcTrue;
+ return FcFalse;
+}
+
+static FcChar8 *
+FcUcs4ToGlyphName (FcChar32 ucs4)
+{
+ int i = (int) (ucs4 % FC_GLYPHNAME_HASH);
+ int r = 0;
+ FcGlyphName *gn;
+
+ while ((gn = ucs_to_name[i]))
+ {
+ if (gn->ucs == ucs4)
+ return gn->name;
+ if (!r)
+ {
+ r = (int) (ucs4 % FC_GLYPHNAME_REHASH);
+ if (!r)
+ r = 1;
+ }
+ i += r;
+ if (i >= FC_GLYPHNAME_HASH)
+ i -= FC_GLYPHNAME_HASH;
+ }
+ return 0;
+}
+
+static FcChar32
+FcGlyphNameToUcs4 (FcChar8 *name)
+{
+ FcChar32 h = FcHashGlyphName (name);
+ int i = (int) (h % FC_GLYPHNAME_HASH);
+ int r = 0;
+ FcGlyphName *gn;
+
+ while ((gn = name_to_ucs[i]))
+ {
+ if (!strcmp ((char *) name, (char *) gn->name))
+ return gn->ucs;
+ if (!r)
+ {
+ r = (int) (h % FC_GLYPHNAME_REHASH);
+ if (!r)
+ r = 1;
+ }
+ i += r;
+ if (i >= FC_GLYPHNAME_HASH)
+ i -= FC_GLYPHNAME_HASH;
+ }
+ return 0xffff;
+}
+
+/*
+ * Search through a font for a glyph by name. This is
+ * currently a linear search as there doesn't appear to be
+ * any defined order within the font
+ */
+static FT_UInt
+FcFreeTypeGlyphNameIndex (FT_Face face, FcChar8 *name)
+{
+ FT_UInt gindex;
+ FcChar8 name_buf[FC_GLYPHNAME_MAXLEN + 2];
+
+ for (gindex = 0; gindex < face->num_glyphs; gindex++)
+ {
+ if (FT_Get_Glyph_Name (face, gindex, name_buf, FC_GLYPHNAME_MAXLEN+1) == 0)
+ if (!strcmp ((char *) name, (char *) name_buf))
+ return gindex;
+ }
+ return 0;
+}
+#endif
+
+/*
+ * Map a UCS4 glyph to a glyph index. Use all available encoding
+ * tables to try and find one that works. This information is expected
+ * to be cached by higher levels, so performance isn't critical
+ */
+
+FT_UInt
+FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4)
+{
+ int initial, offset, decode;
+ FT_UInt glyphindex;
+ FcChar32 charcode;
+ int p;
+
+ initial = 0;
+ /*
+ * Find the current encoding
+ */
+ if (face->charmap)
+ {
+ for (; initial < NUM_DECODE; initial++)
+ if (fcFontDecoders[initial].encoding == face->charmap->encoding)
+ break;
+ if (initial == NUM_DECODE)
+ initial = 0;
+ }
+ for (p = 0; p < NUM_PREFER_UNICODE; p++)
+ if (ucs4 == prefer_unicode[p])
+ {
+ initial = 0;
+ break;
+ }
+ /*
+ * Check each encoding for the glyph, starting with the current one
+ */
+ for (offset = 0; offset < NUM_DECODE; offset++)
+ {
+ decode = (initial + offset) % NUM_DECODE;
+ if (!face->charmap || face->charmap->encoding != fcFontDecoders[decode].encoding)
+ if (FT_Select_Charmap (face, fcFontDecoders[decode].encoding) != 0)
+ continue;
+ if (fcFontDecoders[decode].map)
+ {
+ charcode = FcFreeTypeUcs4ToPrivate (ucs4, fcFontDecoders[decode].map);
+ if (charcode == ~0)
+ continue;
+ }
+ else
+ charcode = ucs4;
+ glyphindex = FT_Get_Char_Index (face, (FT_ULong) charcode);
+ if (glyphindex)
+ return glyphindex;
+ }
+#if HAVE_FT_HAS_PS_GLYPH_NAMES
+ /*
+ * Check postscript name table if present
+ */
+ if (FcFreeTypeUseNames (face))
+ {
+ FcChar8 *name = FcUcs4ToGlyphName (ucs4);
+ if (name)
+ {
+ glyphindex = FcFreeTypeGlyphNameIndex (face, name);
+ if (glyphindex)
+ return glyphindex;
+ }
+ }
+#endif
+ return 0;
+}
+
+static FcBool
+FcFreeTypeCheckGlyph (FT_Face face, FcChar32 ucs4,
+ FT_UInt glyph, FcBlanks *blanks,
+ FT_Pos *advance)
+{
+ FT_Int load_flags = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH | FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
+ FT_GlyphSlot slot;
+
+ /*
+ * When using scalable fonts, only report those glyphs
+ * which can be scaled; otherwise those fonts will
+ * only be available at some sizes, and never when
+ * transformed. Avoid this by simply reporting bitmap-only
+ * glyphs as missing
+ */
+ if (face->face_flags & FT_FACE_FLAG_SCALABLE)
+ load_flags |= FT_LOAD_NO_BITMAP;
+
+ if (FT_Load_Glyph (face, glyph, load_flags))
+ return FcFalse;
+
+ slot = face->glyph;
+ if (!glyph)
+ return FcFalse;
+
+ *advance = slot->metrics.horiAdvance;
+
+ switch (slot->format) {
+ case ft_glyph_format_bitmap:
+ /*
+ * Bitmaps are assumed to be reasonable; if
+ * this proves to be a rash assumption, this
+ * code can be easily modified
+ */
+ return FcTrue;
+ case ft_glyph_format_outline:
+ /*
+ * Glyphs with contours are always OK
+ */
+ if (slot->outline.n_contours != 0)
+ return FcTrue;
+ /*
+ * Glyphs with no contours are only OK if
+ * they're members of the Blanks set specified
+ * in the configuration. If blanks isn't set,
+ * then allow any glyph to be blank
+ */
+ if (!blanks || FcBlanksIsMember (blanks, ucs4))
+ return FcTrue;
+ /* fall through ... */
+ default:
+ break;
+ }
+ return FcFalse;
+}
+
+#define FC_MIN(a,b) ((a) < (b) ? (a) : (b))
+#define FC_MAX(a,b) ((a) > (b) ? (a) : (b))
+#define FC_ABS(a) ((a) < 0 ? -(a) : (a))
+#define APPROXIMATELY_EQUAL(x,y) (FC_ABS ((x) - (y)) <= FC_MAX (FC_ABS (x), FC_ABS (y)) / 33)
+
+FcCharSet *
+FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
+{
+ FcChar32 page, off, max, ucs4;
+#ifdef CHECK
+ FcChar32 font_max = 0;
+#endif
+ FcCharSet *fcs;
+ FcCharLeaf *leaf;
+ const FcCharMap *map;
+ int o;
+ int i;
+ FT_UInt glyph;
+ FT_Pos advance, advance_one = 0, advance_two = 0;
+ FcBool has_advance = FcFalse, fixed_advance = FcTrue, dual_advance = FcFalse;
+
+ fcs = FcCharSetCreate ();
+ if (!fcs)
+ goto bail0;
+
+#ifdef CHECK
+ printf ("Family %s style %s\n", face->family_name, face->style_name);
+#endif
+ for (o = 0; o < NUM_DECODE; o++)
+ {
+ if (FT_Select_Charmap (face, fcFontDecoders[o].encoding) != 0)
+ continue;
+ map = fcFontDecoders[o].map;
+ if (map)
+ {
+ /*
+ * Non-Unicode tables are easy; there's a list of all possible
+ * characters
+ */
+ for (i = 0; i < map->nent; i++)
+ {
+ ucs4 = map->ent[i].bmp;
+ glyph = FT_Get_Char_Index (face, map->ent[i].encode);
+ if (glyph &&
+ FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance))
+ {
+ if (!has_advance)
+ {
+ has_advance = FcTrue;
+ advance_one = advance;
+ }
+ else if (!APPROXIMATELY_EQUAL (advance, advance_one))
+ {
+ if (fixed_advance)
+ {
+ dual_advance = FcTrue;
+ fixed_advance = FcFalse;
+ advance_two = advance;
+ }
+ else if (!APPROXIMATELY_EQUAL (advance, advance_two))
+ dual_advance = FcFalse;
+ }
+
+ leaf = FcCharSetFindLeafCreate (fcs, ucs4);
+ if (!leaf)
+ goto bail1;
+ leaf->map[(ucs4 & 0xff) >> 5] |= (1 << (ucs4 & 0x1f));
+#ifdef CHECK
+ if (ucs4 > font_max)
+ font_max = ucs4;
+#endif
+ }
+ }
+ }
+ else
+ {
+ FT_UInt gindex;
+
+ max = fcFontDecoders[o].max;
+ /*
+ * Find the first encoded character in the font
+ */
+ if (FT_Get_Char_Index (face, 0))
+ {
+ ucs4 = 0;
+ gindex = 1;
+ }
+ else
+ {
+ ucs4 = FT_Get_Next_Char (face, 0, &gindex);
+ if (!ucs4)
+ gindex = 0;
+ }
+
+ while (gindex)
+ {
+ page = ucs4 >> 8;
+ leaf = 0;
+ while ((ucs4 >> 8) == page)
+ {
+ glyph = FT_Get_Char_Index (face, ucs4);
+ if (glyph && FcFreeTypeCheckGlyph (face, ucs4,
+ glyph, blanks, &advance))
+ {
+ if (!has_advance)
+ {
+ has_advance = FcTrue;
+ advance_one = advance;
+ }
+ else if (!APPROXIMATELY_EQUAL (advance, advance_one))
+ {
+ if (fixed_advance)
+ {
+ dual_advance = FcTrue;
+ fixed_advance = FcFalse;
+ advance_two = advance;
+ }
+ else if (!APPROXIMATELY_EQUAL (advance, advance_two))
+ dual_advance = FcFalse;
+ }
+
+ if (!leaf)
+ {
+ leaf = FcCharSetFindLeafCreate (fcs, ucs4);
+ if (!leaf)
+ goto bail1;
+ }
+ off = ucs4 & 0xff;
+ leaf->map[off >> 5] |= (1 << (off & 0x1f));
+#ifdef CHECK
+ if (ucs4 > font_max)
+ font_max = ucs4;
+#endif
+ }
+ ucs4++;
+ }
+ ucs4 = FT_Get_Next_Char (face, ucs4 - 1, &gindex);
+ if (!ucs4)
+ gindex = 0;
+ }
+#ifdef CHECK
+ for (ucs4 = 0; ucs4 < 0x10000; ucs4++)
+ {
+ FcBool FT_Has, FC_Has;
+
+ FT_Has = FT_Get_Char_Index (face, ucs4) != 0;
+ FC_Has = FcCharSetHasChar (fcs, ucs4);
+ if (FT_Has != FC_Has)
+ {
+ printf ("0x%08x FT says %d FC says %d\n", ucs4, FT_Has, FC_Has);
+ }
+ }
+#endif
+ }
+ }
+#if HAVE_FT_HAS_PS_GLYPH_NAMES
+ /*
+ * Add mapping from PS glyph names if available
+ */
+ if (FcFreeTypeUseNames (face))
+ {
+ FcChar8 name_buf[FC_GLYPHNAME_MAXLEN + 2];
+
+ for (glyph = 0; glyph < face->num_glyphs; glyph++)
+ {
+ if (FT_Get_Glyph_Name (face, glyph, name_buf, FC_GLYPHNAME_MAXLEN+1) == 0)
+ {
+ ucs4 = FcGlyphNameToUcs4 (name_buf);
+ if (ucs4 != 0xffff &&
+ FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance))
+ {
+ if (!has_advance)
+ {
+ has_advance = FcTrue;
+ advance_one = advance;
+ }
+ else if (!APPROXIMATELY_EQUAL (advance, advance_one))
+ {
+ if (fixed_advance)
+ {
+ dual_advance = FcTrue;
+ fixed_advance = FcFalse;
+ advance_two = advance;
+ }
+ else if (!APPROXIMATELY_EQUAL (advance, advance_two))
+ dual_advance = FcFalse;
+ }
+ leaf = FcCharSetFindLeafCreate (fcs, ucs4);
+ if (!leaf)
+ goto bail1;
+ leaf->map[(ucs4 & 0xff) >> 5] |= (1 << (ucs4 & 0x1f));
+#ifdef CHECK
+ if (ucs4 > font_max)
+ font_max = ucs4;
+#endif
+ }
+ }
+ }
+ }
+#endif
+#ifdef CHECK
+ printf ("%d glyphs %d encoded\n", (int) face->num_glyphs, FcCharSetCount (fcs));
+ for (ucs4 = 0; ucs4 <= font_max; ucs4++)
+ {
+ FcBool has_char = (glyph = FcFreeTypeCharIndex (face, ucs4)) != 0;
+ FcBool has_bit = FcCharSetHasChar (fcs, ucs4);
+
+ if (has_char && !has_bit)
+ {
+ if (!FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance))
+ printf ("Bitmap missing broken char 0x%x\n", ucs4);
+ else
+ printf ("Bitmap missing char 0x%x\n", ucs4);
+ }
+ else if (!has_char && has_bit)
+ printf ("Bitmap extra char 0x%x\n", ucs4);
+ }
+#endif
+ if (fixed_advance)
+ *spacing = FC_MONO;
+ else if (dual_advance && APPROXIMATELY_EQUAL (2 * FC_MIN (advance_one, advance_two), FC_MAX (advance_one, advance_two)))
+ *spacing = FC_DUAL;
+ else
+ *spacing = FC_PROPORTIONAL;
+ return fcs;
+bail1:
+ FcCharSetDestroy (fcs);
+bail0:
+ return 0;
+}
+
+FcCharSet *
+FcFreeTypeCharSet (FT_Face face, FcBlanks *blanks)
+{
+ int spacing;
+
+ return FcFreeTypeCharSetAndSpacing (face, blanks, &spacing);
+}
+
+
+#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' )
+#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' )
+#define TTAG_SILF FT_MAKE_TAG( 'S', 'i', 'l', 'f')
+#define TT_Err_Ok FT_Err_Ok
+#define TT_Err_Invalid_Face_Handle FT_Err_Invalid_Face_Handle
+#define TTO_Err_Empty_Script 0x1005
+#define TTO_Err_Invalid_SubTable 0x1001
+
+#define OTLAYOUT_HEAD "otlayout:"
+#define OTLAYOUT_HEAD_LEN 9
+#define OTLAYOUT_ID_LEN 4
+/* space + head + id */
+#define OTLAYOUT_LEN (1 + OTLAYOUT_HEAD_LEN + OTLAYOUT_ID_LEN)
+
+/*
+ * This is a bit generous; the registry has only lower case and space
+ * except for 'DFLT'.
+ */
+#define FcIsSpace(x) (040 == (x))
+#define FcIsValidScript(x) (FcIsLower(x) || FcIsUpper (x) || FcIsSpace(x))
+
+static void
+addtag(FcChar8 *complex, FT_ULong tag)
+{
+ FcChar8 tagstring[OTLAYOUT_ID_LEN + 1];
+
+ tagstring[0] = (FcChar8)(tag >> 24),
+ tagstring[1] = (FcChar8)(tag >> 16),
+ tagstring[2] = (FcChar8)(tag >> 8),
+ tagstring[3] = (FcChar8)(tag);
+ tagstring[4] = '\0';
+
+ /* skip tags which aren't alphabetic, under the assumption that
+ * they're probably broken
+ */
+ if (!FcIsValidScript(tagstring[0]) ||
+ !FcIsValidScript(tagstring[1]) ||
+ !FcIsValidScript(tagstring[2]) ||
+ !FcIsValidScript(tagstring[3]))
+ return;
+
+ if (*complex != '\0')
+ strcat (complex, " ");
+ strcat (complex, "otlayout:");
+ strcat (complex, tagstring);
+}
+
+static int
+compareulong (const void *a, const void *b)
+{
+ const FT_ULong *ua = (const FT_ULong *) a;
+ const FT_ULong *ub = (const FT_ULong *) b;
+ return *ua - *ub;
+}
+
+
+static FT_Error
+GetScriptTags(FT_Face face, FT_ULong tabletag, FT_ULong **stags, FT_UShort *script_count)
+{
+ FT_ULong cur_offset, new_offset, base_offset;
+ TT_Face tt_face = (TT_Face)face;
+ FT_Stream stream = face->stream;
+ FT_Error error;
+ FT_UShort n, p;
+ FT_Memory memory = stream->memory;
+
+ if ( !stream )
+ return TT_Err_Invalid_Face_Handle;
+
+ if (( error = tt_face->goto_table( tt_face, tabletag, stream, 0 ) ))
+ return error;
+
+ base_offset = FT_STREAM_POS();
+
+ /* skip version */
+
+ if ( FT_STREAM_SEEK( base_offset + 4L ) || FT_FRAME_ENTER( 2L ) )
+ return error;
+
+ new_offset = FT_GET_USHORT() + base_offset;
+
+ FT_FRAME_EXIT();
+
+ cur_offset = FT_STREAM_POS();
+
+ if ( FT_STREAM_SEEK( new_offset ) != TT_Err_Ok )
+ return error;
+
+ base_offset = FT_STREAM_POS();
+
+ if ( FT_FRAME_ENTER( 2L ) )
+ return error;
+
+ *script_count = FT_GET_USHORT();
+
+ FT_FRAME_EXIT();
+
+ if ( FT_SET_ERROR (FT_MEM_ALLOC_ARRAY( *stags, *script_count, FT_ULong )) )
+ return error;
+
+ p = 0;
+ for ( n = 0; n < *script_count; n++ )
+ {
+ if ( FT_FRAME_ENTER( 6L ) )
+ goto Fail;
+
+ (*stags)[p] = FT_GET_ULONG();
+ new_offset = FT_GET_USHORT() + base_offset;
+
+ FT_FRAME_EXIT();
+
+ cur_offset = FT_STREAM_POS();
+
+ if ( FT_STREAM_SEEK( new_offset ) )
+ goto Fail;
+
+ if ( error == TT_Err_Ok )
+ p++;
+ else if ( error != TTO_Err_Empty_Script )
+ goto Fail;
+
+ (void)FT_STREAM_SEEK( cur_offset );
+ }
+
+ if (!p)
+ {
+ error = TTO_Err_Invalid_SubTable;
+ goto Fail;
+ }
+
+ /* sort the tag list before returning it */
+ qsort(*stags, *script_count, sizeof(FT_ULong), compareulong);
+
+ return TT_Err_Ok;
+
+Fail:
+ *script_count = 0;
+ FT_FREE( *stags );
+ return error;
+}
+
+static FcChar8 *
+FcFontCapabilities(FT_Face face)
+{
+ FcBool issilgraphitefont = 0;
+ FT_Error err;
+ FT_ULong len = 0;
+ FT_ULong *gsubtags=NULL, *gpostags=NULL;
+ FT_UShort gsub_count=0, gpos_count=0;
+ FT_ULong maxsize;
+ FT_Memory memory = face->stream->memory;
+ FcChar8 *complex = NULL;
+ int indx1 = 0, indx2 = 0;
+
+ err = FT_Load_Sfnt_Table(face, TTAG_SILF, 0, 0, &len);
+ issilgraphitefont = ( err == FT_Err_Ok);
+
+ if (GetScriptTags(face, TTAG_GPOS, &gpostags, &gpos_count) != FT_Err_Ok)
+ gpos_count = 0;
+ if (GetScriptTags(face, TTAG_GSUB, &gsubtags, &gsub_count) != FT_Err_Ok)
+ gsub_count = 0;
+
+ if (!issilgraphitefont && !gsub_count && !gpos_count)
+ goto bail;
+
+ maxsize = (((FT_ULong) gpos_count + (FT_ULong) gsub_count) * OTLAYOUT_LEN +
+ (issilgraphitefont ? 13 : 0));
+ complex = malloc (sizeof (FcChar8) * maxsize);
+ if (!complex)
+ goto bail;
+
+ complex[0] = '\0';
+ if (issilgraphitefont)
+ strcpy(complex, "ttable:Silf ");
+
+ while ((indx1 < gsub_count) || (indx2 < gpos_count)) {
+ if (indx1 == gsub_count) {
+ addtag(complex, gpostags[indx2]);
+ indx2++;
+ } else if ((indx2 == gpos_count) || (gsubtags[indx1] < gpostags[indx2])) {
+ addtag(complex, gsubtags[indx1]);
+ indx1++;
+ } else if (gsubtags[indx1] == gpostags[indx2]) {
+ addtag(complex, gsubtags[indx1]);
+ indx1++;
+ indx2++;
+ } else {
+ addtag(complex, gpostags[indx2]);
+ indx2++;
+ }
+ }
+ if (FcDebug () & FC_DBG_SCANV)
+ printf("complex features in this font: %s\n", complex);
+bail:
+ FT_FREE(gsubtags);
+ FT_FREE(gpostags);
+ return complex;
+}
diff --git a/nx-X11/lib/fontenc/Imakefile b/nx-X11/lib/fontenc/Imakefile
new file mode 100644
index 000000000..2bdb0564a
--- /dev/null
+++ b/nx-X11/lib/fontenc/Imakefile
@@ -0,0 +1,36 @@
+XCOMM $XFree86: xc/lib/fontenc/Imakefile,v 1.8 2003/11/17 15:30:11 tsi Exp $
+
+ INCLUDES = -I$(FONTINCSRC) -I$(FONTLIBSRC)/include -I$(FONTLIBSRC)/fontfile \
+ -I$(INCLUDESRC)
+
+FONTENCDEFS = -DFONTENC_NO_LIBFONT \
+ -DFONT_ENCODINGS_DIRECTORY=\"$(FONTDIR)/encodings/encodings.dir\"
+
+ DEFINES = StrcasecmpDefines $(FONTENCDEFS)
+
+ SRCS = fontenc.c encparse.c
+ OBJS = fontenc.o encparse.o
+
+ HEADERS = fontenc.h
+
+#define DoNormalLib NormalLibFontEnc
+#define DoSharedLib SharedLibFontEnc
+#define DoDebugLib DebugLibFontEnc
+#define DoProfileLib ProfileLibFontEnc
+#define LibName fontenc
+#define SoRev SOFONTENCREV
+#define IncSubdir X11
+#define IncSubSubdir fonts
+
+#ifdef SharedFontencReqs
+ REQUIREDLIBS = SharedFontencReqs
+#endif
+
+#include <Library.tmpl>
+
+LinkSourceFile(fontenc.c,$(FONTLIBSRC)/fontfile)
+LinkSourceFile(encparse.c,$(FONTLIBSRC)/fontfile)
+LinkSourceFile(fontenc.h,$(FONTLIBSRC)/include)
+
+DependTarget()
+
diff --git a/nx-X11/lib/fontenc/fontenc-def.cpp b/nx-X11/lib/fontenc/fontenc-def.cpp
new file mode 100644
index 000000000..31743abb2
--- /dev/null
+++ b/nx-X11/lib/fontenc/fontenc-def.cpp
@@ -0,0 +1,19 @@
+/* $XFree86$ */
+LIBRARY fontenc
+VERSION LIBRARY_VERSION
+EXPORTS
+ FontEncDirectory
+ FontEncIdentify
+ FontEncReallyLoad
+ FontEncFind
+ FontEncFromXLFD
+ FontEncMapFind
+ FontEncName
+ FontEncRecode
+ FontEncSimpleName
+ FontEncSimpleRecode
+ FontEncUndefinedName
+ FontEncUndefinedRecode
+ FontMapFind
+ FontMapReverse
+ FontMapReverseFree
diff --git a/nx-X11/lib/freetype2/Imakefile b/nx-X11/lib/freetype2/Imakefile
new file mode 100644
index 000000000..eed70ad23
--- /dev/null
+++ b/nx-X11/lib/freetype2/Imakefile
@@ -0,0 +1,263 @@
+XCOMM $XdotOrg: xc/lib/freetype2/Imakefile,v 1.4 2004/05/05 17:24:41 eich Exp $
+XCOMM $XFree86: xc/lib/freetype2/Imakefile,v 1.19 2003/11/21 02:33:22 dawes Exp $
+
+#define IHaveSubdirs
+#define PassCDebugFlags
+#define NoLibSubdirs
+
+#define DoNormalLib NormalLibFreetype2
+#define DoSharedLib SharedLibFreetype2
+#define DoExtraLib SharedLibFreetype2
+#define DoDebugLib DebugLibFreetype2
+#define DoProfileLib ProfileLibFreetype2
+#define HasSharedData YES
+#define LibName freetype
+#define SoRev SOFREETYPE2REV
+#ifdef SharedLibtoolFreetype2Rev
+#define SharedLibtoolRev SharedLibtoolFreetype2Rev
+#endif
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+FREETYPETOP = $(TOP)/extras/freetype2
+FREETYPESRC = $(FREETYPETOP)/src
+
+
+#ifdef DarwinArchitecture
+# if DarwinQuartzSupport
+DARWINDEFINES = -DTARGET_API_MAC_CARBON=TRUE
+REQUIREDLIBS = -framework CoreServices -framework ApplicationServices
+# else
+DARWINDEFINES = -DDARWIN_NO_CARBON
+# endif
+#endif
+
+DEFINES = $(DARWINDEFINES) Freetype2BuildDefines -DXFREE86_FT2
+
+INCLUDES = -I -I.\
+ -I$(FREETYPESRC)\
+ -I$(FREETYPESRC)/base\
+ -I$(FREETYPESRC)/autofit \
+ -I$(FREETYPESRC)/autohint\
+ -I$(FREETYPESRC)/bdf\
+ -I$(FREETYPESRC)/cff\
+ -I$(FREETYPESRC)/cid\
+ -I$(FREETYPESRC)/gzip\
+ -I$(FREETYPESRC)/lzw \
+ -I$(FREETYPESRC)/pcf\
+ -I$(FREETYPESRC)/pfr\
+ -I$(FREETYPESRC)/psaux\
+ -I$(FREETYPESRC)/pshinter\
+ -I$(FREETYPESRC)/psnames\
+ -I$(FREETYPESRC)/raster\
+ -I$(FREETYPESRC)/sfnt\
+ -I$(FREETYPESRC)/smooth\
+ -I$(FREETYPESRC)/truetype\
+ -I$(FREETYPESRC)/type1\
+ -I$(FREETYPESRC)/type42\
+ -I$(FREETYPESRC)/winfonts\
+ $(FREETYPE2INCLUDES)\
+ -I$(XBUILDINCDIR)
+
+SUBDIRS=freetype
+
+HEADERS=ft2build.h
+
+SRCS_BASE = ftapi.c \
+ ftbase.c \
+ ftbbox.c \
+ ftbdf.c \
+ ftdebug.c \
+ ftglyph.c \
+ ftinit.c \
+ ftmm.c \
+ ftpfr.c \
+ ftstroke.c \
+ ftsynth.c \
+ ftsystem.c \
+ fttype1.c \
+ ftwinfnt.c \
+ ftxf86.c
+
+OBJS_BASE = ftapi.o \
+ ftbase.o \
+ ftbbox.o \
+ ftbdf.o \
+ ftdebug.o \
+ ftglyph.o \
+ ftinit.o \
+ ftmm.o \
+ ftpfr.o \
+ ftstroke.o \
+ ftsynth.o \
+ ftsystem.o \
+ fttype1.o \
+ ftwinfnt.o \
+ ftxf86.o
+
+SRCS_AUTOFIT = autofit.c
+OBJS_AUTOFIT = autofit.o
+
+SRCS_AUTOHINT = autohint.c
+OBJS_AUTOHINT = autohint.o
+
+SRCS_BDF = bdf.c
+OBJS_BDF = bdf.o
+
+SRCS_CFF = cff.c
+OBJS_CFF = cff.o
+
+SRCS_CID = type1cid.c
+OBJS_CID = type1cid.o
+
+SRCS_GZIP = ftgzip.c
+OBJS_GZIP = ftgzip.o
+
+SRCS_LZW = ftlzw.c
+OBJS_LZW = ftlzw.o
+
+SRCS_PCF = pcf.c
+OBJS_PCF = pcf.o
+
+SRCS_PFR = pfr.c
+OBJS_PFR = pfr.o
+
+SRCS_PSAUX = psaux.c
+OBJS_PSAUX = psaux.o
+
+SRCS_PSHINTER = pshinter.c
+OBJS_PSHINTER = pshinter.o
+
+SRCS_PSNAMES = psnames.c
+OBJS_PSNAMES = psnames.o
+
+SRCS_RASTER = raster.c
+OBJS_RASTER = raster.o
+
+SRCS_SFNT = sfnt.c
+OBJS_SFNT = sfnt.o
+
+SRCS_SMOOTH = smooth.c
+OBJS_SMOOTH = smooth.o
+
+SRCS_TRUETYPE = truetype.c
+OBJS_TRUETYPE = truetype.o
+
+SRCS_TYPE1 = type1.c
+OBJS_TYPE1 = type1.o
+
+SRCS_TYPE42 = type42.c
+OBJS_TYPE42 = type42.o
+
+SRCS_WINFONTS = winfnt.c
+OBJS_WINFONTS = winfnt.o
+
+SRCS = $(SRCS_BASE)\
+ $(SRCS_AUTOFIT) \
+ $(SRCS_AUTOHINT)\
+ $(SRCS_BDF)\
+ $(SRCS_CFF)\
+ $(SRCS_CID)\
+ $(SRCS_GZIP)\
+ $(SRCS_LZW)\
+ $(SRCS_PCF)\
+ $(SRCS_PFR)\
+ $(SRCS_PSAUX)\
+ $(SRCS_PSHINTER)\
+ $(SRCS_PSNAMES)\
+ $(SRCS_RASTER)\
+ $(SRCS_SFNT)\
+ $(SRCS_SMOOTH)\
+ $(SRCS_TRUETYPE)\
+ $(SRCS_TYPE1)\
+ $(SRCS_TYPE42)\
+ $(SRCS_WINFONTS)
+
+OBJS = $(OBJS_BASE)\
+ $(OBJS_AUTOFIT) \
+ $(OBJS_AUTOHINT)\
+ $(OBJS_BDF)\
+ $(OBJS_CFF)\
+ $(OBJS_CID)\
+ $(OBJS_GZIP)\
+ $(OBJS_LZW)\
+ $(OBJS_PCF)\
+ $(OBJS_PFR)\
+ $(OBJS_PSAUX)\
+ $(OBJS_PSHINTER)\
+ $(OBJS_PSNAMES)\
+ $(OBJS_RASTER)\
+ $(OBJS_SFNT)\
+ $(OBJS_SMOOTH)\
+ $(OBJS_TRUETYPE)\
+ $(OBJS_TYPE1)\
+ $(OBJS_TYPE42)\
+ $(OBJS_WINFONTS)
+
+
+#include <Library.tmpl>
+
+#if DoSharedLib && SharedDataSeparation
+SpecialCObjectRule(sharedlib,NullParameter,$(SHLIBDEF))
+#endif
+
+#if 0
+MANSUFFIX = $(LIBMANSUFFIX)
+InstallManPage(Freetype,$(LIBMANDIR))
+#endif
+
+BuildIncludes($(HEADERS),.,.)
+InstallMultipleFlags($(HEADERS),$(INCDIR),$(INSTINCFLAGS))
+
+/* There might be an ft2build.h file in the wrong place. If so, remove it. */
+install::
+ @if [ -f $(DESTDIR)$(INCDIR)/freetype2/ft2build.h ]; then \
+ (set -x; $(RM) -f $(DESTDIR)$(INCDIR)/freetype2/ft2build.h) \
+ fi
+
+LinkFile(ft2build.h,$(FREETYPETOP)/builds/unix/ft2unix.h)
+
+LinkSourceFile(ftapi.c,$(FREETYPESRC)/base)
+LinkSourceFile(ftbase.c,$(FREETYPESRC)/base)
+LinkSourceFile(ftbdf.c,$(FREETYPESRC)/base)
+LinkSourceFile(ftbbox.c,$(FREETYPESRC)/base)
+LinkSourceFile(ftdebug.c,$(FREETYPESRC)/base)
+LinkSourceFile(ftglyph.c,$(FREETYPESRC)/base)
+LinkSourceFile(ftinit.c,$(FREETYPESRC)/base)
+LinkSourceFile(ftmm.c,$(FREETYPESRC)/base)
+LinkSourceFile(ftpfr.c,$(FREETYPESRC)/base)
+LinkSourceFile(ftstroke.c,$(FREETYPESRC)/base)
+LinkSourceFile(ftsynth.c,$(FREETYPESRC)/base)
+LinkSourceFile(ftsystem.c,$(FREETYPESRC)/base)
+LinkSourceFile(fttype1.c,$(FREETYPESRC)/base)
+LinkSourceFile(ftwinfnt.c,$(FREETYPESRC)/base)
+LinkSourceFile(ftxf86.c,$(FREETYPESRC)/base)
+
+#if defined(DarwinArchitecture) && DarwinQuartzSupport
+LinkSourceFile(ftmac.c,$(FREETYPESRC)/base)
+#endif
+
+LinkSourceFile(autofit.c,$(FREETYPESRC)/autofit)
+LinkSourceFile(autohint.c,$(FREETYPESRC)/autohint)
+LinkSourceFile(bdf.c,$(FREETYPESRC)/bdf)
+LinkSourceFile(cff.c,$(FREETYPESRC)/cff)
+LinkSourceFile(ftgzip.c,$(FREETYPESRC)/gzip)
+LinkSourceFile(ftlzw.c,$(FREETYPESRC)/lzw)
+LinkSourceFile(type1cid.c,$(FREETYPESRC)/cid)
+LinkSourceFile(pcf.c,$(FREETYPESRC)/pcf)
+LinkSourceFile(pfr.c,$(FREETYPESRC)/pfr)
+LinkSourceFile(psaux.c,$(FREETYPESRC)/psaux)
+LinkSourceFile(pshinter.c,$(FREETYPESRC)/pshinter)
+LinkSourceFile(psnames.c,$(FREETYPESRC)/psnames)
+LinkSourceFile(raster.c,$(FREETYPESRC)/raster)
+LinkSourceFile(sfnt.c,$(FREETYPESRC)/sfnt)
+LinkSourceFile(smooth.c,$(FREETYPESRC)/smooth)
+LinkSourceFile(truetype.c,$(FREETYPESRC)/truetype)
+LinkSourceFile(type1.c,$(FREETYPESRC)/type1)
+LinkSourceFile(type42.c,$(FREETYPESRC)/type42)
+LinkSourceFile(winfnt.c,$(FREETYPESRC)/winfonts)
+
+DependTarget()
+
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/lib/freetype2/freetype-def.cpp b/nx-X11/lib/freetype2/freetype-def.cpp
new file mode 100644
index 000000000..bfb1613ec
--- /dev/null
+++ b/nx-X11/lib/freetype2/freetype-def.cpp
@@ -0,0 +1,211 @@
+LIBRARY libfreetype
+VERSION LIBRARY_VERSION
+
+EXPORTS
+ah_arctan
+autohint_module_class
+;autohinter_interface
+cff_driver_class
+;FT_Access_Frame
+#ifndef __UNIXOS2__
+FT_Add64
+#endif
+FT_Add_Module
+FT_Alloc
+FT_Attach_File
+FT_Attach_Stream
+#ifndef __UNIXOS2__
+FT_Create_Extensions
+FT_Destroy_Extensions
+FT_Div64by32
+#endif
+FT_DivFix
+#ifndef __UNIXOS2__
+FT_Done_Extensions
+#endif
+FT_Done_Face
+FT_Done_GlyphSlot
+FT_Done_Library
+FT_Done_Size
+#ifndef __UNIXOS2__
+FT_Done_Stream
+FT_Extract_Frame
+FT_Forget_Frame
+#endif
+FT_Free
+#ifndef __UNIXOS2__
+FT_Get_Char
+#endif
+FT_Get_Char_Index
+#ifndef __UNIXOS2__
+FT_Get_Extension
+#endif
+FT_Get_Glyph_Name
+FT_Get_Kerning
+#ifndef __UNIXOS2__
+FT_Get_Long
+FT_Get_LongLE
+#endif
+FT_Get_Module
+FT_Get_Module_Interface
+#ifndef __UNIXOS2__
+FT_Get_Offset
+#endif
+FT_Get_Renderer
+FT_Get_Sfnt_Name
+FT_Get_Sfnt_Name_Count
+FT_Get_Sfnt_Table
+#ifndef __UNIXOS2__
+FT_Get_Short
+FT_Get_ShortLE
+#endif
+FT_GlyphLoader_Add
+#ifndef __UNIXOS2__
+FT_GlyphLoader_Check_Points
+FT_GlyphLoader_Check_Subglyphs
+FT_GlyphLoader_Copy_Points
+FT_GlyphLoader_Create_Extra
+#endif
+FT_GlyphLoader_Done
+FT_GlyphLoader_New
+FT_GlyphLoader_Prepare
+FT_GlyphLoader_Reset
+FT_GlyphLoader_Rewind
+#ifndef __UNIXOS2__
+FT_Init_Extensions
+#endif
+FT_List_Add
+FT_List_Finalize
+FT_List_Find
+FT_List_Insert
+FT_List_Iterate
+FT_List_Remove
+FT_List_Up
+FT_Load_Char
+FT_Load_Glyph
+FT_Lookup_Renderer
+FT_MulDiv
+FT_MulFix
+#ifndef __UNIXOS2__
+FT_MulTo64
+#endif
+FT_New_Face
+FT_New_GlyphSlot
+FT_New_Library
+FT_New_Memory_Face
+#ifndef __UNIXOS2__
+FT_New_Memory_Stream
+#endif
+FT_New_Size
+FT_Open_Face
+FT_Outline_Copy
+FT_Outline_Decompose
+FT_Outline_Done
+FT_Outline_Done_Internal
+FT_Outline_Get_Bitmap
+FT_Outline_Get_CBox
+FT_Outline_New
+FT_Outline_New_Internal
+FT_Outline_Render
+FT_Outline_Reverse
+FT_Outline_Transform
+FT_Outline_Translate
+#ifndef __UNIXOS2__
+FT_Read_Char
+FT_Read_Fields
+FT_Read_Long
+FT_Read_LongLE
+FT_Read_Offset
+FT_Read_Short
+FT_Read_ShortLE
+FT_Read_Stream
+FT_Read_Stream_At
+#endif
+FT_Realloc
+#ifndef __UNIXOS2__
+FT_Register_Extension
+FT_Release_Frame
+#endif
+FT_Remove_Module
+FT_Render_Glyph
+FT_Render_Glyph_Internal
+#ifndef __UNIXOS2__
+FT_Seek_Stream
+#endif
+FT_Select_Charmap
+FT_Set_Char_Size
+FT_Set_Charmap
+FT_Set_Debug_Hook
+FT_Set_Pixel_Sizes
+FT_Set_Renderer
+FT_Set_Transform
+#ifndef __UNIXOS2__
+FT_Skip_Stream
+FT_Sqrt64
+#endif
+FT_SqrtFixed
+FT_Stream_Pos
+FT_Vector_Transform
+FT_Outline_Get_BBox
+FT_Done_Glyph
+FT_Get_Glyph
+FT_Glyph_Copy
+FT_Glyph_Get_CBox
+FT_Glyph_To_Bitmap
+FT_Glyph_Transform
+FT_Matrix_Invert
+FT_Matrix_Multiply
+ft_bitmap_glyph_class
+ft_outline_glyph_class
+FT_Add_Default_Modules
+FT_Done_FreeType
+FT_Init_FreeType
+FT_Get_Multi_Master
+FT_Set_MM_Blend_Coordinates
+FT_Set_MM_Design_Coordinates
+FT_Done_Memory
+FT_New_Memory
+#ifndef __UNIXOS2__
+FT_New_Stream
+_cygwin_dll_entry@12
+_cygwin_noncygwin_dll_entry@12
+dll_main@12
+#endif
+ps_table_funcs
+psaux_module_class
+t1_builder_funcs
+t1_decoder_funcs
+#ifndef __UNIXOS2__
+t1_parser_funcs
+#endif
+psnames_module_class
+ft_raster1_renderer_class
+ft_raster5_renderer_class
+ft_standard_raster
+sbit_metrics_fields
+sfnt_module_class
+ft_grays_raster
+ft_smooth_renderer_class
+#ifndef __UNIXOS2__
+TT_New_Context
+TT_RunIns
+tt_default_graphics_state
+#endif
+tt_driver_class
+t1_driver_class
+t1cid_driver_class
+winfnt_driver_class
+#ifdef __UNIXOS2__
+FT_Get_First_Char
+FT_Get_Next_Char
+FT_Get_PS_Font_Info
+FT_Has_PS_Glyph_Names
+FT_Get_Name_Index
+FT_Get_BDF_Property
+FT_Activate_Size
+FT_Get_X11_Font_Format
+FT_Get_BDF_Charset_ID
+FT_Get_Postscript_Name
+#endif
+
+/* $XFree86: xc/lib/freetype2/freetype-def.cpp,v 1.6 2003/11/06 03:25:41 dawes Exp $ */
diff --git a/nx-X11/lib/freetype2/freetype/Imakefile b/nx-X11/lib/freetype2/freetype/Imakefile
new file mode 100644
index 000000000..246603fda
--- /dev/null
+++ b/nx-X11/lib/freetype2/freetype/Imakefile
@@ -0,0 +1,90 @@
+XCOMM $XFree86: xc/lib/freetype2/freetype/Imakefile,v 1.9 2003/05/29 03:05:09 dawes Exp $
+
+#define IHaveSubdirs
+#define PassCDebugFlags
+
+SUBDIRS=config cache internal
+
+FREETYPETOP = $(TOP)/extras/freetype2
+FREETYPESRC = $(FREETYPETOP)/src
+FREETYPEINC = $(FREETYPETOP)/include/freetype
+
+HEADERS= \
+ freetype.h \
+ ftbbox.h \
+ ftbdf.h \
+ ftcache.h \
+ ftchapters.h \
+ fterrdef.h \
+ fterrors.h \
+ ftglyph.h \
+ ftgzip.h \
+ ftimage.h \
+ ftincrem.h \
+ ftlist.h \
+ ftmac.h \
+ ftmm.h \
+ ftmoderr.h \
+ ftmodapi.h \
+ ftoutln.h \
+ ftpfr.h \
+ ftrender.h \
+ ftsizes.h \
+ ftsnames.h \
+ ftstroke.h \
+ ftsynth.h \
+ ftsysio.h \
+ ftsysmem.h \
+ ftsystem.h \
+ fttrigon.h \
+ fttypes.h \
+ ftwinfnt.h \
+ ftxf86.h \
+ t1tables.h \
+ ftlzw.h \
+ ttnameid.h \
+ tttables.h \
+ tttags.h \
+ ttunpat.h
+
+BuildIncludes($(HEADERS),freetype2/freetype,../..)
+InstallMultipleFlags($(HEADERS),$(INCDIR)/freetype2/freetype,$(INSTINCFLAGS))
+
+LinkSourceFile(freetype.h,$(FREETYPEINC))
+LinkSourceFile(ftbbox.h,$(FREETYPEINC))
+LinkSourceFile(ftbdf.h,$(FREETYPEINC))
+LinkSourceFile(ftcache.h,$(FREETYPEINC))
+LinkSourceFile(ftchapters.h,$(FREETYPEINC))
+LinkSourceFile(fterrdef.h,$(FREETYPEINC))
+LinkSourceFile(fterrors.h,$(FREETYPEINC))
+LinkSourceFile(ftglyph.h,$(FREETYPEINC))
+LinkSourceFile(ftgzip.h,$(FREETYPEINC))
+LinkSourceFile(ftimage.h,$(FREETYPEINC))
+LinkSourceFile(ftincrem.h,$(FREETYPEINC))
+LinkSourceFile(ftlist.h,$(FREETYPEINC))
+LinkSourceFile(ftmac.h,$(FREETYPEINC))
+LinkSourceFile(ftmm.h,$(FREETYPEINC))
+LinkSourceFile(ftmoderr.h,$(FREETYPEINC))
+LinkSourceFile(ftmodapi.h,$(FREETYPEINC))
+LinkSourceFile(ftoutln.h,$(FREETYPEINC))
+LinkSourceFile(ftpfr.h,$(FREETYPEINC))
+LinkSourceFile(ftrender.h,$(FREETYPEINC))
+LinkSourceFile(ftsizes.h,$(FREETYPEINC))
+LinkSourceFile(ftsnames.h,$(FREETYPEINC))
+LinkSourceFile(ftstroke.h,$(FREETYPEINC))
+LinkSourceFile(ftsynth.h,$(FREETYPEINC))
+LinkSourceFile(ftsysio.h,$(FREETYPEINC))
+LinkSourceFile(ftsysmem.h,$(FREETYPEINC))
+LinkSourceFile(ftsystem.h,$(FREETYPEINC))
+LinkSourceFile(fttrigon.h,$(FREETYPEINC))
+LinkSourceFile(fttypes.h,$(FREETYPEINC))
+LinkSourceFile(ftwinfnt.h,$(FREETYPEINC))
+LinkSourceFile(ftxf86.h,$(FREETYPEINC))
+LinkSourceFile(t1tables.h,$(FREETYPEINC))
+LinkSourceFile(ftlzw.h,$(FREETYPEINC))
+LinkSourceFile(ttnameid.h,$(FREETYPEINC))
+LinkSourceFile(tttables.h,$(FREETYPEINC))
+LinkSourceFile(tttags.h,$(FREETYPEINC))
+LinkSourceFile(ttunpat.h,$(FREETYPEINC))
+
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/lib/freetype2/freetype/cache/Imakefile b/nx-X11/lib/freetype2/freetype/cache/Imakefile
new file mode 100644
index 000000000..18ae1fed9
--- /dev/null
+++ b/nx-X11/lib/freetype2/freetype/cache/Imakefile
@@ -0,0 +1,25 @@
+XCOMM $XFree86: xc/lib/freetype2/freetype/cache/Imakefile,v 1.1 2001/02/08 00:55:41 keithp Exp $
+
+FREETYPETOP = $(TOP)/extras/freetype2
+FREETYPESRC = $(FREETYPETOP)/src
+FREETYPEINC = $(FREETYPETOP)/include/freetype
+
+HEADERS= \
+ ftccache.h \
+ ftccmap.h \
+ ftcglyph.h \
+ ftcimage.h \
+ ftcmanag.h \
+ ftcsbits.h \
+ ftcmru.h
+
+BuildIncludes($(HEADERS),freetype2/freetype/cache,../../..)
+InstallMultipleFlags($(HEADERS),$(INCDIR)/freetype2/freetype/cache,$(INSTINCFLAGS))
+
+LinkSourceFile(ftccache.h,$(FREETYPEINC)/cache)
+LinkSourceFile(ftccmap.h,$(FREETYPEINC)/cache)
+LinkSourceFile(ftcglyph.h,$(FREETYPEINC)/cache)
+LinkSourceFile(ftcimage.h,$(FREETYPEINC)/cache)
+LinkSourceFile(ftcmanag.h,$(FREETYPEINC)/cache)
+LinkSourceFile(ftcsbits.h,$(FREETYPEINC)/cache)
+LinkSourceFile(ftcmru.h,$(FREETYPEINC)/cache)
diff --git a/nx-X11/lib/freetype2/freetype/config/Imakefile b/nx-X11/lib/freetype2/freetype/config/Imakefile
new file mode 100644
index 000000000..c23911208
--- /dev/null
+++ b/nx-X11/lib/freetype2/freetype/config/Imakefile
@@ -0,0 +1,52 @@
+XCOMM $XdotOrg: xc/lib/freetype2/freetype/config/Imakefile,v 1.4 2005/10/10 01:25:40 alanc Exp $
+XCOMM $XFree86: xc/lib/freetype2/freetype/config/Imakefile,v 1.12 2003/10/24 16:21:17 tsi Exp $
+
+FREETYPETOP = $(TOP)/extras/freetype2
+FREETYPESRC = $(FREETYPETOP)/src
+FREETYPEINC = $(FREETYPETOP)/include/freetype
+
+HEADERS= \
+ ftconfig.h \
+ ftheader.h \
+ ftmodule.h \
+ ftoption.h \
+ ftstdlib.h
+
+BuildIncludes($(HEADERS),freetype2/freetype/config,../../..)
+InstallMultipleFlags($(HEADERS),$(INCDIR)/freetype2/freetype/config,$(INSTINCFLAGS))
+
+LinkSourceFile(ftconfig.h,$(FREETYPEINC)/config)
+LinkSourceFile(ftheader.h,$(FREETYPEINC)/config)
+LinkSourceFile(ftmodule.h,$(FREETYPEINC)/config)
+LinkSourceFile(ftoption.h,$(FREETYPEINC)/config)
+LinkSourceFile(ftstdlib.h,$(FREETYPEINC)/config)
+
+XCOMM Build and install a configure-compatible freetype-config
+
+LinkSourceFile(freetype-config.in,$(FREETYPETOP)/builds/unix)
+LinkSourceFile(freetype2.in,$(FREETYPETOP)/builds/unix)
+
+FREETYPE_VERSION=Freetype2Version
+
+RPATH_CFLAG = HardCodeLibdirFlag
+
+CONFIG_SUBST = \
+ sed -e s%@prefix@%$(PROJECTROOT)% -e s%@exec_prefix@%$(PROJECTROOT)% \
+ -e s%@libdir@%$(USRLIBDIR)%g -e s%@includedir@%$(INCDIR)% \
+ -e s%@ft_version@%$(FREETYPE_VERSION)% -e s%@LIBZ@%% \
+ -e s%@hardcode_libdir_flag_spec@%$(RPATH_CFLAG)% -e s%@wl@%%
+
+freetype-config: freetype-config.in
+ $(CONFIG_SUBST) < freetype-config.in > $@
+
+freetype2.pc: freetype2.in
+ $(CONFIG_SUBST) < freetype2.in > $@
+
+includes:: freetype-config freetype2.pc
+
+InstallNamedProg(freetype-config,freetype-config,$(BINDIR))
+InstallNonExecFile(freetype2.pc,$(USRLIBDIR)/pkgconfig)
+
+clean::
+ RemoveFile(freetype-config)
+ RemoveFile(freetype2.pc)
diff --git a/nx-X11/lib/freetype2/freetype/internal/Imakefile b/nx-X11/lib/freetype2/freetype/internal/Imakefile
new file mode 100644
index 000000000..2ec88abe9
--- /dev/null
+++ b/nx-X11/lib/freetype2/freetype/internal/Imakefile
@@ -0,0 +1,52 @@
+XCOMM $XdotOrg: xc/lib/freetype2/freetype/internal/Imakefile,v 1.3 2004/04/28 10:39:09 gisburn Exp $
+
+#define IHaveSubdirs
+#define PassCDebugFlags
+
+SUBDIRS=services
+
+FREETYPETOP = $(TOP)/extras/freetype2
+FREETYPESRC = $(FREETYPETOP)/src
+FREETYPEINC = $(FREETYPETOP)/include/freetype
+
+HEADERS= \
+ autohint.h \
+ ftcalc.h \
+ ftdebug.h \
+ ftdriver.h \
+ ftgloadr.h \
+ ftmemory.h \
+ ftobjs.h \
+ ftrfork.h \
+ ftserv.h \
+ ftstream.h \
+ fttrace.h \
+ internal.h \
+ pcftypes.h \
+ psaux.h \
+ pshints.h \
+ sfnt.h \
+ t1types.h \
+ tttypes.h
+
+BuildIncludes($(HEADERS),freetype2/freetype/internal,../../..)
+InstallMultipleFlags($(HEADERS),$(INCDIR)/freetype2/freetype/internal,$(INSTINCFLAGS))
+
+LinkSourceFile(autohint.h,$(FREETYPEINC)/internal)
+LinkSourceFile(ftcalc.h,$(FREETYPEINC)/internal)
+LinkSourceFile(ftdebug.h,$(FREETYPEINC)/internal)
+LinkSourceFile(ftdriver.h,$(FREETYPEINC)/internal)
+LinkSourceFile(ftgloadr.h,$(FREETYPEINC)/internal)
+LinkSourceFile(ftmemory.h,$(FREETYPEINC)/internal)
+LinkSourceFile(ftobjs.h,$(FREETYPEINC)/internal)
+LinkSourceFile(ftrfork.h,$(FREETYPEINC)/internal)
+LinkSourceFile(ftstream.h,$(FREETYPEINC)/internal)
+LinkSourceFile(ftserv.h,$(FREETYPEINC)/internal)
+LinkSourceFile(fttrace.h,$(FREETYPEINC)/internal)
+LinkSourceFile(internal.h,$(FREETYPEINC)/internal)
+LinkSourceFile(pcftypes.h,$(FREETYPEINC)/internal)
+LinkSourceFile(psaux.h,$(FREETYPEINC)/internal)
+LinkSourceFile(pshints.h,$(FREETYPEINC)/internal)
+LinkSourceFile(sfnt.h,$(FREETYPEINC)/internal)
+LinkSourceFile(t1types.h,$(FREETYPEINC)/internal)
+LinkSourceFile(tttypes.h,$(FREETYPEINC)/internal)
diff --git a/nx-X11/lib/freetype2/freetype/internal/services/Imakefile b/nx-X11/lib/freetype2/freetype/internal/services/Imakefile
new file mode 100644
index 000000000..31e18cff8
--- /dev/null
+++ b/nx-X11/lib/freetype2/freetype/internal/services/Imakefile
@@ -0,0 +1,31 @@
+FREETYPETOP = $(TOP)/extras/freetype2
+FREETYPESRC = $(FREETYPETOP)/src
+FREETYPEINC = $(FREETYPETOP)/include/freetype
+
+HEADERS= \
+ svbdf.h \
+ svmm.h \
+ svpostnm.h \
+ svpsinfo.h \
+ svwinfnt.h \
+ svgldict.h \
+ svpfr.h \
+ svpscmap.h \
+ svsfnt.h \
+ svttcmap.h \
+ svxf86nm.h
+
+BuildIncludes($(HEADERS),freetype2/freetype/internal/services,../../../..)
+InstallMultipleFlags($(HEADERS),$(INCDIR)/freetype2/freetype/internal/services,$(INSTINCFLAGS))
+
+LinkSourceFile(svbdf.h,$(FREETYPEINC)/internal/services)
+LinkSourceFile(svmm.h,$(FREETYPEINC)/internal/services)
+LinkSourceFile(svpostnm.h,$(FREETYPEINC)/internal/services)
+LinkSourceFile(svpsinfo.h,$(FREETYPEINC)/internal/services)
+LinkSourceFile(svwinfnt.h,$(FREETYPEINC)/internal/services)
+LinkSourceFile(svgldict.h,$(FREETYPEINC)/internal/services)
+LinkSourceFile(svpfr.h,$(FREETYPEINC)/internal/services)
+LinkSourceFile(svpscmap.h,$(FREETYPEINC)/internal/services)
+LinkSourceFile(svsfnt.h,$(FREETYPEINC)/internal/services)
+LinkSourceFile(svttcmap.h,$(FREETYPEINC)/internal/services)
+LinkSourceFile(svxf86nm.h,$(FREETYPEINC)/internal/services)
diff --git a/nx-X11/lib/lbxutil/Imakefile b/nx-X11/lib/lbxutil/Imakefile
new file mode 100644
index 000000000..d4f74e787
--- /dev/null
+++ b/nx-X11/lib/lbxutil/Imakefile
@@ -0,0 +1,31 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:40 cpqbld Exp $
+
+
+
+
+
+XCOMM $XFree86: xc/lib/lbxutil/Imakefile,v 1.7 1999/04/17 09:08:13 dawes Exp $
+
+#include <Server.tmpl>
+
+#define IHaveSubdirs
+
+SUBDIRS = lbx_zlib delta image
+
+OBJS = lbx_zlib/?*.o delta/?*.o image/?*.o
+
+DONES = lbx_zlib/DONE delta/DONE image/DONE
+
+lbx_zlib/DONE: lbx_zlib
+delta/DONE: delta
+image/DONE: image
+
+#undef _LinkBuildLibrary
+#define _LinkBuildLibrary(lib) LinkBuildLibrary(lib)
+
+NormalDepLibraryTarget(lbxutil,$(SUBDIRS) $(DONES),$(OBJS))
+
+ForceSubdirs($(SUBDIRS))
+
+DependSubdirs($(SUBDIRS))
+
diff --git a/nx-X11/lib/lbxutil/delta/Imakefile b/nx-X11/lib/lbxutil/delta/Imakefile
new file mode 100644
index 000000000..cb94c8906
--- /dev/null
+++ b/nx-X11/lib/lbxutil/delta/Imakefile
@@ -0,0 +1,17 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:40 cpqbld Exp $
+
+#define IncSubdir X11
+#include <Library.tmpl>
+
+SRCS = lbxdelta.c
+
+OBJS = lbxdelta.o
+
+INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/include -I../../../include/extensions
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
diff --git a/nx-X11/lib/lbxutil/delta/lbxdelta.c b/nx-X11/lib/lbxutil/delta/lbxdelta.c
new file mode 100644
index 000000000..5925a6a1b
--- /dev/null
+++ b/nx-X11/lib/lbxutil/delta/lbxdelta.c
@@ -0,0 +1,255 @@
+/*
+ * $NCDXorg: @(#)lbxdelta.c,v 1.2 1994/01/22 02:23:40 dct Exp $
+ * $Xorg: lbxdelta.c,v 1.5 2000/08/17 19:46:40 cpqbld Exp $
+ * $XdotOrg: xc/lib/lbxutil/delta/lbxdelta.c,v 1.7 2005/07/30 21:07:25 alanc Exp $
+ *
+ * Copyright 1993 Network Computing Devices
+ *
+ * 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 of NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * 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.
+ *
+ * Author: Dale Tonogai, Network Computing Devices
+ */
+/* $XFree86: xc/lib/lbxutil/delta/lbxdelta.c,v 1.7 2001/07/25 15:04:57 dawes Exp $ */
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+#include <X11/extensions/lbxdeltastr.h>
+
+#include <stddef.h>
+#include <string.h>
+
+#ifdef LBXREQSTATS
+#include "../lbx_zlib/reqstats.h"
+extern int LbxWhoAmI;
+extern struct ReqStats CoreRequestStats[128];
+extern struct ReqStats LbxRequestStats[LbxNumberReqs];
+
+#define LBX_CODE 136 /* XXX - this should not be hardcoded - on todo list */
+#endif
+
+/* Copied from xc/programs/Xserver/include/xorg/os.h */
+#ifndef _HAVE_XALLOC_DECLS
+#define _HAVE_XALLOC_DECLS
+#include <X11/Xdefs.h>
+
+extern pointer Xalloc(unsigned long /*amount*/);
+extern pointer Xcalloc(unsigned long /*amount*/);
+extern pointer Xrealloc(pointer /*ptr*/, unsigned long /*amount*/);
+extern void Xfree(pointer /*ptr*/);
+#endif
+
+/*
+ * Allocate data structures needed for doing Delta compaction
+ */
+int
+LBXInitDeltaCache(LBXDeltasPtr pcache,
+ int nDeltas,
+ int maxDeltasize)
+{
+ int i;
+ unsigned char *mem;
+
+ if ((pcache->nDeltas = nDeltas)) {
+ pcache->maxDeltasize = maxDeltasize;
+ if ((pcache->deltas = (LBXDeltaElemPtr)
+ Xalloc(pcache->nDeltas * sizeof(LBXDeltaElemRec) +
+ pcache->nDeltas * pcache->maxDeltasize)) == NULL) {
+ return -1;
+ }
+
+ mem = (unsigned char *) (pcache->deltas + pcache->nDeltas);
+ for (i = 0; i < pcache->nDeltas; i++) {
+ pcache->deltas[i].buf = mem;
+ mem += pcache->maxDeltasize;
+ }
+ }
+ else
+ pcache->maxDeltasize = 0;
+
+ pcache->nextDelta = 0;
+ pcache->activeDeltas = 0;
+ return 0;
+}
+
+/*
+ * Free data structures used for doing Delta compaction
+ */
+void
+LBXFreeDeltaCache(LBXDeltasPtr pcache)
+{
+ if (pcache->nDeltas && pcache->deltas)
+ Xfree(pcache->deltas);
+}
+
+static int
+BytesDiff(unsigned char *ptr1, unsigned char *ptr2,
+ int n,
+ int maxn)
+{
+ int result = 0;
+
+ while (n--)
+ if (*(ptr1++) != *(ptr2++))
+ if (++result >= maxn)
+ break;
+ return (result);
+}
+
+/*
+ * Find the message in the outgoing delta cache with the least number of
+ * differing bytes and return the number of differences. If all
+ * messages have greater than maxdiff differences, return -1.
+ */
+int
+LBXDeltaMinDiffs(LBXDeltasPtr pcache,
+ unsigned char *inmsg,
+ int inmsglen,
+ int maxdiff,
+ int *pindex)
+{
+ int i, j, k = 0, l = maxdiff + 1;
+ int m;
+ LBXDeltaElemPtr dm;
+
+ for (m = pcache->nextDelta-1, dm = &pcache->deltas[m], i = 0;
+ i < pcache->activeDeltas;
+ i++, m--, dm--
+ ) {
+ if (m < 0) {
+ m = pcache->nDeltas - 1;
+ dm = &pcache->deltas[m];
+ }
+ if (dm->length == inmsglen) {
+ j = BytesDiff(inmsg, dm->buf, inmsglen, l);
+ if (j < l) {
+ k = m;
+ l = j;
+ }
+ }
+ }
+
+ if (l > maxdiff)
+ return -1;
+ else {
+ *pindex = k;
+ return l;
+ }
+}
+
+/*
+ * Delta compact a given message
+ */
+void
+LBXEncodeDelta(LBXDeltasPtr pcache,
+ unsigned char *inmsg,
+ int ndiff,
+ int index,
+ unsigned char *buf)
+{
+ int i, off, diff;
+ xLbxDiffItem *deltas = (xLbxDiffItem *)buf;
+
+ for (off = i = 0; i < ndiff; off++) {
+ if ((diff = inmsg[off] - pcache->deltas[index].buf[off])) {
+ deltas[i].offset = off;
+ deltas[i++].diff = diff;
+ }
+ }
+}
+
+/*
+ * Uncompact a message
+ */
+int
+LBXDecodeDelta(LBXDeltasPtr pcache,
+ xLbxDiffItem *deltas,
+ int ndiff,
+ int index,
+ unsigned char **buf)
+{
+ int i;
+ int newindex = pcache->nextDelta;
+ int len = pcache->deltas[index].length;
+ unsigned char *p = pcache->deltas[newindex].buf;
+#ifdef LBXREQSTATS
+ xReq *req;
+#endif
+
+ pcache->nextDelta = (pcache->nextDelta + 1) % pcache->nDeltas;
+ if (index != newindex) {
+ memcpy(p, pcache->deltas[index].buf, len);
+ pcache->deltas[newindex].length = len;
+ }
+ for (i = 0; i < ndiff; i++)
+ p[deltas[i].offset] += deltas[i].diff;
+ *buf = p;
+
+#ifdef LBXREQSTATS
+ req = (xReq *) p;
+
+ if (LbxWhoAmI == 1) /* server */
+ {
+ struct ReqStats *reqStat = NULL;
+
+ if (req->reqType == LBX_CODE)
+ reqStat = &LbxRequestStats[req->data];
+ else if (req->reqType < 128)
+ reqStat = &CoreRequestStats[req->reqType];
+
+ if (reqStat)
+ {
+ reqStat->delta_count++;
+ reqStat->pre_delta_bytes += (req->length << 2);
+ reqStat->post_delta_bytes +=
+ (((sz_xLbxDeltaReq + sz_xLbxDiffItem * ndiff + 3) >> 2) << 2);
+ }
+ }
+#endif
+
+ return len;
+}
+
+/*
+ * Add a message to the outgoing delta cache
+ */
+void
+LBXAddDeltaOut(LBXDeltasPtr pcache,
+ unsigned char *inmsg,
+ int inmsglen)
+{
+ memcpy(pcache->deltas[pcache->nextDelta].buf, inmsg, inmsglen);
+ pcache->deltas[pcache->nextDelta].length = inmsglen;
+ pcache->nextDelta = (pcache->nextDelta + 1) % pcache->nDeltas;
+ if (pcache->activeDeltas < pcache->nDeltas)
+ pcache->activeDeltas++;
+}
+
+/*
+ * Add a message to the incoming delta cache
+ */
+void
+LBXAddDeltaIn(LBXDeltasPtr pcache,
+ unsigned char *inmsg,
+ int inmsglen)
+{
+ memcpy(pcache->deltas[pcache->nextDelta].buf, inmsg, inmsglen);
+ pcache->deltas[pcache->nextDelta].length = inmsglen;
+ pcache->nextDelta = (pcache->nextDelta + 1) % pcache->nDeltas;
+}
diff --git a/nx-X11/lib/lbxutil/image/Imakefile b/nx-X11/lib/lbxutil/image/Imakefile
new file mode 100644
index 000000000..fa7421615
--- /dev/null
+++ b/nx-X11/lib/lbxutil/image/Imakefile
@@ -0,0 +1,45 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:40 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/lbxutil/image/Imakefile,v 1.3 2001/01/17 19:43:35 dawes Exp $
+
+#define IncSubdir X11
+#include <Library.tmpl>
+
+SRCS = dfaxg42d.c dpackbits.c efaxg42d.c epackbits.c misc.c
+
+OBJS = dfaxg42d.o dpackbits.o efaxg42d.o epackbits.o misc.o
+
+INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/include -I../../../include/extensions
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+NormalLintTarget($(SRCS))
+
+MKG3STATES = ./mkg3states
+
+#if CrossCompiling
+HOST_CFLAGS=$(TOP_INCLUDES) $(INCLUDES) $(BOOTSTRAPCFLAGS) \
+ $(CROSSCOMPILEDEFINES) $(CROSSCOMPILEBOOTSTRAPDEFINES)
+#else
+HOST_CFLAGS=$(CFLAGS)
+#endif
+
+g3states.h : mkg3states.c
+ RemoveFiles($@ HostProgramTargetName(mkg3states))
+ -HostLinkRule(HostProgramTargetName(mkg3states), $(HOST_CFLAGS),mkg3states.c,$(LDLIBS))
+ RunProgram(MKG3STATES,> g3_states_h)
+ $(MV) g3_states_h $@
+ RemoveFiles(HostProgramTargetName(mkg3states) g3_states_h)
+
+includes:: g3states.h
+
+depend:: g3states.h
+
+clean::
+ RemoveFiles(g3_states_h g3states.h HostProgramTargetName(mkg3states))
+
+DependTarget()
+
diff --git a/nx-X11/lib/lbxutil/image/dfaxg42d.c b/nx-X11/lib/lbxutil/image/dfaxg42d.c
new file mode 100644
index 000000000..609992d62
--- /dev/null
+++ b/nx-X11/lib/lbxutil/image/dfaxg42d.c
@@ -0,0 +1,420 @@
+/* $Xorg: dfaxg42d.c,v 1.3 2000/08/17 19:46:40 cpqbld Exp $ */
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler
+ * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/lib/lbxutil/image/dfaxg42d.c,v 1.5 2001/01/17 19:43:35 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/Xfuncproto.h>
+#include <X11/Xfuncs.h>
+#include <stdlib.h>
+#include "g3states.h"
+#include "lbxfax.h"
+#include <X11/extensions/lbximage.h>
+
+/*
+ * -------------------------------------------------------------------------
+ * FAX G42D decoding for 1 bit images
+ * -------------------------------------------------------------------------
+ */
+
+static short sp_data, sp_bit;
+
+
+/*
+ * Fetch a byte from the input stream
+ */
+
+static unsigned char
+fetchByte (unsigned char **inbuf)
+
+{
+ unsigned char byte = **inbuf;
+ (*inbuf)++;
+ return (byte);
+}
+
+
+/*
+ * Decode a run of white.
+ */
+
+static int
+decode_white_run (unsigned char **inbuf)
+
+{
+ short state = sp_bit;
+ short action;
+ int runlen = 0;
+
+ for (;;)
+ {
+ if (sp_bit == 0)
+ {
+ nextbyte:
+ sp_data = fetchByte (inbuf);
+ }
+
+ action = TIFFFax1DAction[state][sp_data];
+ state = TIFFFax1DNextState[state][sp_data];
+ if (action == ACT_INCOMP)
+ goto nextbyte;
+ if (action == ACT_INVALID)
+ return (G3CODE_INVALID);
+ if (action == ACT_EOL)
+ return (G3CODE_EOL);
+ sp_bit = state;
+ action = RUNLENGTH(action - ACT_WRUNT);
+ runlen += action;
+ if (action < 64)
+ return (runlen);
+ }
+}
+
+
+/*
+ * Decode a run of black.
+ */
+
+static int
+decode_black_run (unsigned char **inbuf)
+
+{
+ short state = sp_bit + 8;
+ short action;
+ int runlen = 0;
+
+ for (;;)
+ {
+ if (sp_bit == 0)
+ {
+ nextbyte:
+ sp_data = fetchByte (inbuf);
+ }
+
+ action = TIFFFax1DAction[state][sp_data];
+ state = TIFFFax1DNextState[state][sp_data];
+ if (action == ACT_INCOMP)
+ goto nextbyte;
+ if (action == ACT_INVALID)
+ return (G3CODE_INVALID);
+ if (action == ACT_EOL)
+ return (G3CODE_EOL);
+ sp_bit = state;
+ action = RUNLENGTH(action - ACT_BRUNT);
+ runlen += action;
+ if (action < 64)
+ return (runlen);
+ state += 8;
+ }
+}
+
+
+/*
+ * Return the next uncompressed mode code word.
+ */
+
+static int
+decode_uncomp_code (unsigned char **inbuf)
+
+{
+ short code;
+
+ do {
+ if (sp_bit == 0 || sp_bit > 7)
+ sp_data = fetchByte (inbuf);
+
+ code = TIFFFaxUncompAction[sp_bit][sp_data];
+ sp_bit = TIFFFaxUncompNextState[sp_bit][sp_data];
+ } while (code == ACT_INCOMP);
+
+ return (code);
+}
+
+
+/*
+ * Fill a span with ones.
+ */
+
+static void
+fillspan (char *cp,
+ int x, int count)
+
+{
+ static unsigned char masks[] =
+ { 0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
+
+ if (count <= 0)
+ return;
+
+ cp += x>>3;
+
+ if (x &= 7)
+ {
+ /* align to byte boundary */
+
+ if (count < 8 - x) {
+ *cp++ |= masks[count] >> x;
+ return;
+ }
+
+ *cp++ |= 0xff >> x;
+ count -= 8 - x;
+ }
+
+ while (count >= 8)
+ {
+ *cp++ = (char)0xff;
+ count -= 8;
+ }
+
+ *cp |= masks[count];
+}
+
+
+/*
+ * Return the next bit in the input stream. This is
+ * used to extract 2D tag values and the color tag
+ * at the end of a terminating uncompressed data code.
+ */
+
+static int
+nextbit (unsigned char **inbuf)
+
+{
+ static unsigned char bitMask[8] =
+ { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
+ int bit;
+
+ if (sp_bit == 0)
+ sp_data = fetchByte (inbuf);
+
+ bit = sp_data & bitMask[sp_bit];
+
+ if (++(sp_bit) > 7)
+ sp_bit = 0;
+
+ return (bit);
+}
+
+
+static int
+DecodeFaxG42D (unsigned char **inbuf,
+ unsigned char *refline,
+ int pixels_per_line,
+ unsigned char *outbuf)
+
+{
+ int a0 = -1;
+ int b1, b2;
+ int run1, run2; /* for horizontal mode */
+ short mode;
+ short color = 1;
+
+ do {
+ if (sp_bit == 0 || sp_bit > 7)
+ sp_data = fetchByte (inbuf);
+
+ mode = TIFFFax2DMode[sp_bit][sp_data];
+ sp_bit = TIFFFax2DNextState[sp_bit][sp_data];
+
+ switch (mode)
+ {
+ case MODE_NULL:
+ break;
+
+ case MODE_PASS:
+ b2 = LbxImageFindDiff (refline, a0, pixels_per_line, !color);
+ b1 = LbxImageFindDiff (refline, b2, pixels_per_line, color);
+ b2 = LbxImageFindDiff (refline, b1, pixels_per_line, !color);
+
+ if (color)
+ {
+ if (a0 < 0)
+ a0 = 0;
+ fillspan ((char *) outbuf, a0, b2 - a0);
+ }
+
+ a0 = b2;
+ break;
+
+ case MODE_HORIZ:
+ if (color == 1)
+ {
+ run1 = decode_white_run (inbuf);
+ run2 = decode_black_run (inbuf);
+ }
+ else
+ {
+ run1 = decode_black_run (inbuf);
+ run2 = decode_white_run (inbuf);
+ }
+
+ /*
+ * Do the appropriate fill. Note that we exit this logic with
+ * the same color that we enter with since we do 2 fills. This
+ * explains the somewhat obscure logic below.
+ */
+
+ if (a0 < 0)
+ a0 = 0;
+ if (a0 + run1 > pixels_per_line)
+ run1 = pixels_per_line - a0;
+ if (color)
+ fillspan ((char *) outbuf, a0, run1);
+ a0 += run1;
+ if (a0 + run2 > pixels_per_line)
+ run2 = pixels_per_line - a0;
+ if (!color)
+ fillspan ((char *) outbuf, a0, run2);
+ a0 += run2;
+ break;
+
+ case MODE_VERT_V0:
+ case MODE_VERT_VR1:
+ case MODE_VERT_VR2:
+ case MODE_VERT_VR3:
+ case MODE_VERT_VL1:
+ case MODE_VERT_VL2:
+ case MODE_VERT_VL3:
+ b2 = LbxImageFindDiff (refline, a0, pixels_per_line, !color);
+ b1 = LbxImageFindDiff (refline, b2, pixels_per_line, color);
+ b1 += mode - MODE_VERT_V0;
+
+ if (color)
+ {
+ if (a0 < 0)
+ a0 = 0;
+ fillspan ((char *) outbuf, a0, b1 - a0);
+ }
+
+ color = !color;
+ a0 = b1;
+ break;
+
+ case MODE_UNCOMP:
+ /*
+ * Uncompressed mode: select from the special set of code words.
+ */
+
+ if (a0 < 0)
+ a0 = 0;
+ do
+ {
+ mode = decode_uncomp_code (inbuf);
+ switch (mode)
+ {
+ case UNCOMP_RUN1:
+ case UNCOMP_RUN2:
+ case UNCOMP_RUN3:
+ case UNCOMP_RUN4:
+ case UNCOMP_RUN5:
+ run1 = mode - UNCOMP_RUN0;
+ fillspan ((char *) outbuf, a0+run1-1, 1);
+ a0 += run1;
+ break;
+
+ case UNCOMP_RUN6:
+ a0 += 5;
+ break;
+
+ case UNCOMP_TRUN0:
+ case UNCOMP_TRUN1:
+ case UNCOMP_TRUN2:
+ case UNCOMP_TRUN3:
+ case UNCOMP_TRUN4:
+
+ run1 = mode - UNCOMP_TRUN0;
+ a0 += run1;
+ color = nextbit (inbuf) ? 0 : 1;
+ break;
+
+ case UNCOMP_INVALID:
+ goto bad;
+
+ case UNCOMP_EOF:
+ return (0);
+ }
+ } while (mode < UNCOMP_EXIT);
+ break;
+
+ case MODE_ERROR_1:
+ /* fall thru... */
+ case MODE_ERROR:
+ goto bad;
+
+ default:
+ return (0);
+ }
+
+ } while (a0 < pixels_per_line);
+
+bad:
+ return (a0 >= pixels_per_line);
+}
+
+
+int
+LbxImageDecodeFaxG42D (unsigned char *inbuf,
+ unsigned char *outbuf,
+ int image_bytes,
+ int pixels_per_line,
+ int padded_bytes_per_scanline,
+ int reverse_bits)
+
+{
+ int bytes_per_scanline = ROUNDUP8 (pixels_per_line);
+ unsigned char *refline, *refptr;
+ unsigned char *outbuf_start = outbuf;
+ int bytes_left = image_bytes;
+ int i;
+
+ refline = (unsigned char *) malloc (bytes_per_scanline + 1);
+ refptr = refline + 1;
+
+ for (i = 0; i < bytes_per_scanline + 1; i++)
+ refline[i] = 0xff;
+
+ bzero (outbuf, image_bytes);
+
+ sp_bit = 0;
+ sp_data = 0;
+
+ while (bytes_left > 0)
+ {
+ if (!DecodeFaxG42D (&inbuf, refptr, pixels_per_line, outbuf))
+ return (0);
+
+ memcpy (refptr, outbuf, bytes_per_scanline);
+
+ outbuf += padded_bytes_per_scanline;
+ bytes_left -= padded_bytes_per_scanline;
+ }
+
+ free ((char *) refline);
+
+ if (reverse_bits)
+ LbxReverseBits (outbuf_start, image_bytes);
+
+ return (outbuf - outbuf_start);
+}
diff --git a/nx-X11/lib/lbxutil/image/dpackbits.c b/nx-X11/lib/lbxutil/image/dpackbits.c
new file mode 100644
index 000000000..f0f2058d0
--- /dev/null
+++ b/nx-X11/lib/lbxutil/image/dpackbits.c
@@ -0,0 +1,100 @@
+/* $Xorg: dpackbits.c,v 1.4 2000/08/17 19:46:40 cpqbld Exp $ */
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler
+ * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/lib/lbxutil/image/dpackbits.c,v 1.3 2000/05/18 23:46:16 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/Xfuncproto.h>
+#include <X11/extensions/lbximage.h>
+
+/*
+ * -------------------------------------------------------------------------
+ * PackBits decoding for 8 bit color images
+ * -------------------------------------------------------------------------
+ */
+
+static void
+DecodePackBits (char **inbuf,
+ int numPixels,
+ char *outbuf)
+
+{
+ register char *inptr = *inbuf;
+ register int n, b;
+
+ while (numPixels > 0)
+ {
+ n = (int) *inptr++;
+
+ /* Watch out for compilers that don't sign extend chars... */
+
+ if (n >= 128)
+ n -= 256;
+
+ if (n < 0)
+ {
+ /* replicate next byte -n+1 times */
+
+ if (n == -128) /* nop */
+ continue;
+
+ n = -n + 1;
+ numPixels -= n;
+ for (b = *inptr++; n-- > 0;)
+ *outbuf++ = b;
+ }
+ else
+ {
+ /* copy next n+1 bytes literally */
+
+ memcpy (outbuf, inptr, ++n);
+ outbuf += n; numPixels -= n;
+ inptr += n;
+ }
+ }
+
+ *inbuf = inptr;
+}
+
+
+int
+LbxImageDecodePackBits (char *inbuf,
+ char *outbuf,
+ int num_scan_lines,
+ int scan_line_size)
+
+{
+ char *outbuf_start = outbuf;
+ int padded_scan_line_size = (scan_line_size % 4) ?
+ scan_line_size + (4 - scan_line_size % 4) : scan_line_size;
+
+ while (num_scan_lines > 0)
+ {
+ DecodePackBits (&inbuf, scan_line_size, outbuf);
+ outbuf += padded_scan_line_size;
+ num_scan_lines--;
+ }
+
+ return (outbuf - outbuf_start);
+}
diff --git a/nx-X11/lib/lbxutil/image/efaxg42d.c b/nx-X11/lib/lbxutil/image/efaxg42d.c
new file mode 100644
index 000000000..a89b5e0d2
--- /dev/null
+++ b/nx-X11/lib/lbxutil/image/efaxg42d.c
@@ -0,0 +1,328 @@
+/* $Xorg: efaxg42d.c,v 1.3 2000/08/17 19:46:41 cpqbld Exp $ */
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler
+ * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/lib/lbxutil/image/efaxg42d.c,v 1.4 2001/01/17 19:43:35 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/Xfuncproto.h>
+#include <stdlib.h>
+#include "lbxfax.h"
+#include <X11/extensions/lbximage.h>
+#include "lbxbwcodes.h"
+
+/*
+ * -------------------------------------------------------------------------
+ * FAX G42D encoding for 1 bit images
+ * -------------------------------------------------------------------------
+ */
+
+static short sp_data, sp_bit;
+
+static tableentry horizcode =
+ { 3, 0x1 }; /* 001 */
+
+static tableentry passcode =
+ { 4, 0x1 }; /* 0001 */
+
+static tableentry vcodes[7] = {
+ { 7, 0x03 }, /* 0000 011 */
+ { 6, 0x03 }, /* 0000 11 */
+ { 3, 0x03 }, /* 011 */
+ { 1, 0x1 }, /* 1 */
+ { 3, 0x2 }, /* 010 */
+ { 6, 0x02 }, /* 0000 10 */
+ { 7, 0x02 } /* 0000 010 */
+};
+
+typedef struct {
+ unsigned char *bufStart;
+ unsigned char *bufPtr;
+ int bufSize;
+ int bytesLeft;
+} Buffer;
+
+
+
+/*
+ * Flush bits to output buffer.
+ */
+
+static int
+flushbits (Buffer *outbuf)
+
+{
+ if (outbuf->bytesLeft > 0)
+ {
+ *(outbuf->bufPtr++) = sp_data;
+ outbuf->bytesLeft--;
+
+ sp_data = 0;
+ sp_bit = 8;
+
+ return (1);
+ }
+ else
+ return (0);
+}
+
+
+/*
+ * Write a variable-length bit-value to the output stream. Values are
+ * assumed to be at most 16 bits.
+ */
+
+static int
+putbits (unsigned int bits,
+ unsigned int length,
+ Buffer *outbuf)
+
+{
+ static int mask[9] =
+ {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
+
+ while (length > sp_bit)
+ {
+ sp_data |= bits >> (length - sp_bit);
+ length -= sp_bit;
+ if (!flushbits (outbuf))
+ return (0);
+ }
+
+ sp_data |= (bits & mask[length]) << (sp_bit - length);
+ sp_bit -= length;
+
+ if (sp_bit == 0)
+ {
+ if (!flushbits (outbuf))
+ return (0);
+ }
+
+ return (1);
+}
+
+
+/*
+ * Write a code to the output stream.
+ */
+
+static int
+putcode (tableentry *te,
+ Buffer *outbuf)
+
+{
+ return (putbits (te->code, te->length, outbuf));
+}
+
+
+/*
+ * Write the sequence of codes that describes the specified span of
+ * zero's or one's. The appropriate table that holds the make-up and
+ * terminating codes is supplied.
+ */
+
+static int
+putspan (int span,
+ tableentry *tab,
+ Buffer *outbuf)
+
+{
+ while (span >= 2624)
+ {
+ tableentry *te = &tab[63 + (2560 >> 6)];
+ if (!putcode (te, outbuf))
+ return (0);
+ span -= te->runlen;
+ }
+
+ if (span >= 64)
+ {
+ tableentry *te = &tab[63 + (span >> 6)];
+ if (!putcode (te, outbuf))
+ return (0);
+ span -= te->runlen;
+ }
+
+ if (!putcode (&tab[span], outbuf))
+ return (0);
+
+ return (1);
+}
+
+
+
+#define PIXEL(buf,ix) ((((buf)[(ix)>>3]) >> (7-((ix)&7))) & 1)
+
+static int
+EncodeFaxG42D (unsigned char *inbuf,
+ unsigned char *refline,
+ int bits,
+ Buffer *outbuf)
+
+{
+ short white = 1;
+ int a0 = 0;
+ int a1 = (PIXEL (inbuf, 0) != white ?
+ 0 : LbxImageFindDiff (inbuf, 0, bits, white));
+ int b1 = (PIXEL (refline, 0) != white ?
+ 0 : LbxImageFindDiff (refline, 0, bits, white));
+ int a2, b2;
+
+ for (;;)
+ {
+ b2 = LbxImageFindDiff (refline, b1, bits, PIXEL (refline, b1));
+ if (b2 >= a1)
+ {
+ int d = b1 - a1;
+ if (!(-3 <= d && d <= 3))
+ {
+ /* horizontal mode */
+
+ a2 = LbxImageFindDiff (inbuf, a1, bits, PIXEL (inbuf, a1));
+ if (!putcode (&horizcode, outbuf))
+ return (0);
+
+ if (a0 + a1 == 0 || PIXEL (inbuf, a0) == white)
+ {
+ if (!putspan(a1 - a0, TIFFFaxWhiteCodes, outbuf))
+ return (0);
+ if (!putspan(a2 - a1, TIFFFaxBlackCodes, outbuf))
+ return (0);
+ }
+ else
+ {
+ if (!putspan (a1 - a0, TIFFFaxBlackCodes, outbuf))
+ return (0);
+ if (!putspan (a2 - a1, TIFFFaxWhiteCodes, outbuf))
+ return (0);
+ }
+
+ a0 = a2;
+ }
+ else
+ {
+ /* vertical mode */
+
+ if (!putcode (&vcodes[d+3], outbuf))
+ return (0);
+ a0 = a1;
+ }
+ }
+ else
+ {
+ /* pass mode */
+
+ if (!putcode (&passcode, outbuf))
+ return (0);
+ a0 = b2;
+ }
+
+ if (a0 >= bits)
+ break;
+
+ a1 = LbxImageFindDiff (inbuf, a0, bits, PIXEL (inbuf, a0));
+ b1 = LbxImageFindDiff (refline, a0, bits, !PIXEL (inbuf, a0));
+ b1 = LbxImageFindDiff (refline, b1, bits, PIXEL (inbuf, a0));
+ }
+
+ return (1);
+}
+
+
+int
+LbxImageEncodeFaxG42D (unsigned char *inbuf,
+ unsigned char *outbuf,
+ int outbufSize,
+ int image_bytes,
+ int pixels_per_line,
+ int padded_bytes_per_scanline,
+ int reverse_bits,
+ int *bytesCompressed)
+
+{
+ int bytes_per_scanline = ROUNDUP8 (pixels_per_line);
+ unsigned char *refline, *refptr;
+ unsigned char *save_inbuf = inbuf;
+ int bytes_left = image_bytes;
+ Buffer OutBuf;
+ int status, i;
+
+ OutBuf.bufStart = OutBuf.bufPtr = outbuf;
+ OutBuf.bufSize = OutBuf.bytesLeft = outbufSize;
+
+ if (!(refline = (unsigned char *) malloc (bytes_per_scanline + 1)))
+ return (LBX_IMAGE_COMPRESS_BAD_MALLOC);
+
+ refptr = refline + 1;
+
+ for (i = 0; i < bytes_per_scanline + 1; i++)
+ refline[i] = 0xff;
+
+ if (reverse_bits)
+ LbxReverseBits (inbuf, image_bytes);
+
+ sp_bit = 8;
+ sp_data = 0;
+
+ while (bytes_left > 0)
+ {
+ if (!(status = EncodeFaxG42D (inbuf, refptr,
+ pixels_per_line, &OutBuf)))
+ {
+ goto bad;
+ }
+
+ memcpy (refptr, inbuf, bytes_per_scanline);
+
+ inbuf += padded_bytes_per_scanline;
+ bytes_left -= padded_bytes_per_scanline;
+ }
+
+ status = putbits (EOL, 12, &OutBuf);
+ if (status)
+ status = putbits (EOL, 12, &OutBuf);
+ if (status && sp_bit != 8)
+ {
+ status = flushbits (&OutBuf);
+ }
+
+ bad:
+
+ free ((char *) refline);
+
+ /* put the bits back the way they were */
+ if (reverse_bits)
+ LbxReverseBits (save_inbuf, image_bytes);
+
+ if (status)
+ {
+ *bytesCompressed = OutBuf.bufPtr - OutBuf.bufStart;
+
+ if (OutBuf.bytesLeft > 0)
+ return (LBX_IMAGE_COMPRESS_SUCCESS);
+ else
+ return (LBX_IMAGE_COMPRESS_NOT_WORTH_IT);
+ }
+ else
+ return (LBX_IMAGE_COMPRESS_NOT_WORTH_IT);
+}
diff --git a/nx-X11/lib/lbxutil/image/epackbits.c b/nx-X11/lib/lbxutil/image/epackbits.c
new file mode 100644
index 000000000..816fee57a
--- /dev/null
+++ b/nx-X11/lib/lbxutil/image/epackbits.c
@@ -0,0 +1,202 @@
+/* $Xorg: epackbits.c,v 1.4 2000/08/17 19:46:41 cpqbld Exp $ */
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler
+ * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <X11/Xfuncproto.h>
+#include <X11/extensions/lbximage.h>
+
+/*
+ * -------------------------------------------------------------------------
+ * PackBits encoding for 8 bit color images
+ * -------------------------------------------------------------------------
+ */
+
+#define PutByte(byte,bufptr,bytesLeft) \
+{ \
+ if (*bytesLeft < 1) {\
+ *outbuf = outptr; \
+ return (0); \
+ } \
+ *bufptr++ = byte; \
+ (*bytesLeft)--; \
+}
+
+
+static int
+EncodePackBits (char *inbuf,
+ int numPixels,
+ char **outbuf,
+ int *bytesLeft)
+
+{
+ register int pixelsLeft = numPixels;
+ register char *outptr = *outbuf;
+ register char *lastliteral;
+ register int n, b;
+ enum { BASE, LITERAL, RUN, LITERAL_RUN } state;
+
+ state = BASE;
+ lastliteral = 0;
+
+ while (pixelsLeft > 0)
+ {
+ /*
+ * Find the longest string of identical bytes.
+ */
+
+ b = *inbuf++, pixelsLeft--, n = 1;
+ for (; pixelsLeft > 0 && b == *inbuf; pixelsLeft--, inbuf++)
+ n++;
+
+ again:
+
+ switch (state)
+ {
+ case BASE: /* initial state, set run/literal */
+ if (n > 1)
+ {
+ state = RUN;
+
+ if (n > 128)
+ {
+ PutByte (-127, outptr, bytesLeft);
+ PutByte (b, outptr, bytesLeft);
+ n -= 128;
+ goto again;
+ }
+
+ PutByte (-(n-1), outptr, bytesLeft);
+ PutByte (b, outptr, bytesLeft);
+ }
+ else
+ {
+ lastliteral = outptr;
+ PutByte (0, outptr, bytesLeft);
+ PutByte (b, outptr, bytesLeft);
+ state = LITERAL;
+ }
+
+ break;
+
+ case LITERAL: /* last object was literal string */
+ if (n > 1)
+ {
+ state = LITERAL_RUN;
+
+ if (n > 128)
+ {
+ PutByte (-127, outptr, bytesLeft);
+ PutByte (b, outptr, bytesLeft);
+ n -= 128;
+ goto again;
+ }
+
+ PutByte (-(n-1), outptr, bytesLeft); /* encode run */
+ PutByte (b, outptr, bytesLeft);
+ }
+ else
+ { /* extend literal */
+ if (++(*lastliteral) == 127)
+ state = BASE;
+ PutByte (b, outptr, bytesLeft);
+ }
+
+ break;
+
+ case RUN: /* last object was run */
+ if (n > 1)
+ {
+ if (n > 128)
+ {
+ PutByte (-127, outptr, bytesLeft);
+ PutByte (b, outptr, bytesLeft);
+ n -= 128;
+ goto again;
+ }
+ PutByte (-(n-1), outptr, bytesLeft);
+ PutByte (b, outptr, bytesLeft);
+ }
+ else
+ {
+ lastliteral = outptr;
+ PutByte (0, outptr, bytesLeft);
+ PutByte (b, outptr, bytesLeft);
+ state = LITERAL;
+ }
+
+ break;
+
+ case LITERAL_RUN: /* literal followed by a run */
+ /*
+ * Check to see if previous run should
+ * be converted to a literal, in which
+ * case we convert literal-run-literal
+ * to a single literal.
+ */
+
+ if (n == 1 && outptr[-2] == (char)-1 && *lastliteral < 126)
+ {
+ state = (((*lastliteral) += 2) == 127 ? BASE : LITERAL);
+ outptr[-2] = outptr[-1]; /* replicate */
+ }
+ else
+ state = RUN;
+ goto again;
+ }
+ }
+
+ *outbuf = outptr;
+
+ return (1);
+}
+
+
+int
+LbxImageEncodePackBits (char *inbuf,
+ char *outbuf,
+ int outbufSize,
+ int format,
+ int depth,
+ int num_scan_lines,
+ int scan_line_size,
+ int *bytesCompressed)
+
+{
+ char *outbuf_start = outbuf;
+ int padded_scan_line_size = (scan_line_size % 4) ?
+ scan_line_size + (4 - scan_line_size % 4) : scan_line_size;
+ int bytesLeft = outbufSize;
+
+ while (num_scan_lines > 0)
+ {
+ if (!EncodePackBits (inbuf, scan_line_size, &outbuf, &bytesLeft))
+ return (LBX_IMAGE_COMPRESS_NOT_WORTH_IT);
+
+ inbuf += padded_scan_line_size;
+ num_scan_lines--;
+ }
+
+ *bytesCompressed = outbuf - outbuf_start;
+ return (LBX_IMAGE_COMPRESS_SUCCESS);
+}
diff --git a/nx-X11/lib/lbxutil/image/lbxbwcodes.h b/nx-X11/lib/lbxutil/image/lbxbwcodes.h
new file mode 100644
index 000000000..e26e2864c
--- /dev/null
+++ b/nx-X11/lib/lbxutil/image/lbxbwcodes.h
@@ -0,0 +1,269 @@
+/* $Xorg: lbxbwcodes.h,v 1.3 2000/08/17 19:46:41 cpqbld Exp $ */
+
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler
+ * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+/* $XFree86$ */
+
+/*
+ * Note that these tables are ordered such that the
+ * index into the table is known to be either the
+ * run length, or (run length / 64) + a fixed offset.
+ *
+ * NB: The G3CODE_INVALID entries are only used
+ * during state generation (see mkg3states.c).
+ */
+
+#ifdef __DARWIN__
+#ifndef TIFFaxWhiteCodes
+#define TIFFFaxWhiteCodes Darwin_X_TIFFFaxWhiteCodes
+#endif
+#endif
+tableentry TIFFFaxWhiteCodes[] = {
+ { 8, 0x35, 0 }, /* 0011 0101 */
+ { 6, 0x7, 1 }, /* 0001 11 */
+ { 4, 0x7, 2 }, /* 0111 */
+ { 4, 0x8, 3 }, /* 1000 */
+ { 4, 0xB, 4 }, /* 1011 */
+ { 4, 0xC, 5 }, /* 1100 */
+ { 4, 0xE, 6 }, /* 1110 */
+ { 4, 0xF, 7 }, /* 1111 */
+ { 5, 0x13, 8 }, /* 1001 1 */
+ { 5, 0x14, 9 }, /* 1010 0 */
+ { 5, 0x7, 10 }, /* 0011 1 */
+ { 5, 0x8, 11 }, /* 0100 0 */
+ { 6, 0x8, 12 }, /* 0010 00 */
+ { 6, 0x3, 13 }, /* 0000 11 */
+ { 6, 0x34, 14 }, /* 1101 00 */
+ { 6, 0x35, 15 }, /* 1101 01 */
+ { 6, 0x2A, 16 }, /* 1010 10 */
+ { 6, 0x2B, 17 }, /* 1010 11 */
+ { 7, 0x27, 18 }, /* 0100 111 */
+ { 7, 0xC, 19 }, /* 0001 100 */
+ { 7, 0x8, 20 }, /* 0001 000 */
+ { 7, 0x17, 21 }, /* 0010 111 */
+ { 7, 0x3, 22 }, /* 0000 011 */
+ { 7, 0x4, 23 }, /* 0000 100 */
+ { 7, 0x28, 24 }, /* 0101 000 */
+ { 7, 0x2B, 25 }, /* 0101 011 */
+ { 7, 0x13, 26 }, /* 0010 011 */
+ { 7, 0x24, 27 }, /* 0100 100 */
+ { 7, 0x18, 28 }, /* 0011 000 */
+ { 8, 0x2, 29 }, /* 0000 0010 */
+ { 8, 0x3, 30 }, /* 0000 0011 */
+ { 8, 0x1A, 31 }, /* 0001 1010 */
+ { 8, 0x1B, 32 }, /* 0001 1011 */
+ { 8, 0x12, 33 }, /* 0001 0010 */
+ { 8, 0x13, 34 }, /* 0001 0011 */
+ { 8, 0x14, 35 }, /* 0001 0100 */
+ { 8, 0x15, 36 }, /* 0001 0101 */
+ { 8, 0x16, 37 }, /* 0001 0110 */
+ { 8, 0x17, 38 }, /* 0001 0111 */
+ { 8, 0x28, 39 }, /* 0010 1000 */
+ { 8, 0x29, 40 }, /* 0010 1001 */
+ { 8, 0x2A, 41 }, /* 0010 1010 */
+ { 8, 0x2B, 42 }, /* 0010 1011 */
+ { 8, 0x2C, 43 }, /* 0010 1100 */
+ { 8, 0x2D, 44 }, /* 0010 1101 */
+ { 8, 0x4, 45 }, /* 0000 0100 */
+ { 8, 0x5, 46 }, /* 0000 0101 */
+ { 8, 0xA, 47 }, /* 0000 1010 */
+ { 8, 0xB, 48 }, /* 0000 1011 */
+ { 8, 0x52, 49 }, /* 0101 0010 */
+ { 8, 0x53, 50 }, /* 0101 0011 */
+ { 8, 0x54, 51 }, /* 0101 0100 */
+ { 8, 0x55, 52 }, /* 0101 0101 */
+ { 8, 0x24, 53 }, /* 0010 0100 */
+ { 8, 0x25, 54 }, /* 0010 0101 */
+ { 8, 0x58, 55 }, /* 0101 1000 */
+ { 8, 0x59, 56 }, /* 0101 1001 */
+ { 8, 0x5A, 57 }, /* 0101 1010 */
+ { 8, 0x5B, 58 }, /* 0101 1011 */
+ { 8, 0x4A, 59 }, /* 0100 1010 */
+ { 8, 0x4B, 60 }, /* 0100 1011 */
+ { 8, 0x32, 61 }, /* 0011 0010 */
+ { 8, 0x33, 62 }, /* 0011 0011 */
+ { 8, 0x34, 63 }, /* 0011 0100 */
+ { 5, 0x1B, 64 }, /* 1101 1 */
+ { 5, 0x12, 128 }, /* 1001 0 */
+ { 6, 0x17, 192 }, /* 0101 11 */
+ { 7, 0x37, 256 }, /* 0110 111 */
+ { 8, 0x36, 320 }, /* 0011 0110 */
+ { 8, 0x37, 384 }, /* 0011 0111 */
+ { 8, 0x64, 448 }, /* 0110 0100 */
+ { 8, 0x65, 512 }, /* 0110 0101 */
+ { 8, 0x68, 576 }, /* 0110 1000 */
+ { 8, 0x67, 640 }, /* 0110 0111 */
+ { 9, 0xCC, 704 }, /* 0110 0110 0 */
+ { 9, 0xCD, 768 }, /* 0110 0110 1 */
+ { 9, 0xD2, 832 }, /* 0110 1001 0 */
+ { 9, 0xD3, 896 }, /* 0110 1001 1 */
+ { 9, 0xD4, 960 }, /* 0110 1010 0 */
+ { 9, 0xD5, 1024 }, /* 0110 1010 1 */
+ { 9, 0xD6, 1088 }, /* 0110 1011 0 */
+ { 9, 0xD7, 1152 }, /* 0110 1011 1 */
+ { 9, 0xD8, 1216 }, /* 0110 1100 0 */
+ { 9, 0xD9, 1280 }, /* 0110 1100 1 */
+ { 9, 0xDA, 1344 }, /* 0110 1101 0 */
+ { 9, 0xDB, 1408 }, /* 0110 1101 1 */
+ { 9, 0x98, 1472 }, /* 0100 1100 0 */
+ { 9, 0x99, 1536 }, /* 0100 1100 1 */
+ { 9, 0x9A, 1600 }, /* 0100 1101 0 */
+ { 6, 0x18, 1664 }, /* 0110 00 */
+ { 9, 0x9B, 1728 }, /* 0100 1101 1 */
+ { 11, 0x8, 1792 }, /* 0000 0001 000 */
+ { 11, 0xC, 1856 }, /* 0000 0001 100 */
+ { 11, 0xD, 1920 }, /* 0000 0001 101 */
+ { 12, 0x12, 1984 }, /* 0000 0001 0010 */
+ { 12, 0x13, 2048 }, /* 0000 0001 0011 */
+ { 12, 0x14, 2112 }, /* 0000 0001 0100 */
+ { 12, 0x15, 2176 }, /* 0000 0001 0101 */
+ { 12, 0x16, 2240 }, /* 0000 0001 0110 */
+ { 12, 0x17, 2304 }, /* 0000 0001 0111 */
+ { 12, 0x1C, 2368 }, /* 0000 0001 1100 */
+ { 12, 0x1D, 2432 }, /* 0000 0001 1101 */
+ { 12, 0x1E, 2496 }, /* 0000 0001 1110 */
+ { 12, 0x1F, 2560 }, /* 0000 0001 1111 */
+ { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */
+ { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */
+ { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */
+ { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */
+ { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */
+};
+
+#ifdef __DARWIN__
+#ifndef TIFFaxBlackCodes
+#define TIFFFaxBlackCodes Darwin_X_TIFFFaxBlackCodes
+#endif
+#endif
+tableentry TIFFFaxBlackCodes[] = {
+ { 10, 0x37, 0 }, /* 0000 1101 11 */
+ { 3, 0x2, 1 }, /* 010 */
+ { 2, 0x3, 2 }, /* 11 */
+ { 2, 0x2, 3 }, /* 10 */
+ { 3, 0x3, 4 }, /* 011 */
+ { 4, 0x3, 5 }, /* 0011 */
+ { 4, 0x2, 6 }, /* 0010 */
+ { 5, 0x3, 7 }, /* 0001 1 */
+ { 6, 0x5, 8 }, /* 0001 01 */
+ { 6, 0x4, 9 }, /* 0001 00 */
+ { 7, 0x4, 10 }, /* 0000 100 */
+ { 7, 0x5, 11 }, /* 0000 101 */
+ { 7, 0x7, 12 }, /* 0000 111 */
+ { 8, 0x4, 13 }, /* 0000 0100 */
+ { 8, 0x7, 14 }, /* 0000 0111 */
+ { 9, 0x18, 15 }, /* 0000 1100 0 */
+ { 10, 0x17, 16 }, /* 0000 0101 11 */
+ { 10, 0x18, 17 }, /* 0000 0110 00 */
+ { 10, 0x8, 18 }, /* 0000 0010 00 */
+ { 11, 0x67, 19 }, /* 0000 1100 111 */
+ { 11, 0x68, 20 }, /* 0000 1101 000 */
+ { 11, 0x6C, 21 }, /* 0000 1101 100 */
+ { 11, 0x37, 22 }, /* 0000 0110 111 */
+ { 11, 0x28, 23 }, /* 0000 0101 000 */
+ { 11, 0x17, 24 }, /* 0000 0010 111 */
+ { 11, 0x18, 25 }, /* 0000 0011 000 */
+ { 12, 0xCA, 26 }, /* 0000 1100 1010 */
+ { 12, 0xCB, 27 }, /* 0000 1100 1011 */
+ { 12, 0xCC, 28 }, /* 0000 1100 1100 */
+ { 12, 0xCD, 29 }, /* 0000 1100 1101 */
+ { 12, 0x68, 30 }, /* 0000 0110 1000 */
+ { 12, 0x69, 31 }, /* 0000 0110 1001 */
+ { 12, 0x6A, 32 }, /* 0000 0110 1010 */
+ { 12, 0x6B, 33 }, /* 0000 0110 1011 */
+ { 12, 0xD2, 34 }, /* 0000 1101 0010 */
+ { 12, 0xD3, 35 }, /* 0000 1101 0011 */
+ { 12, 0xD4, 36 }, /* 0000 1101 0100 */
+ { 12, 0xD5, 37 }, /* 0000 1101 0101 */
+ { 12, 0xD6, 38 }, /* 0000 1101 0110 */
+ { 12, 0xD7, 39 }, /* 0000 1101 0111 */
+ { 12, 0x6C, 40 }, /* 0000 0110 1100 */
+ { 12, 0x6D, 41 }, /* 0000 0110 1101 */
+ { 12, 0xDA, 42 }, /* 0000 1101 1010 */
+ { 12, 0xDB, 43 }, /* 0000 1101 1011 */
+ { 12, 0x54, 44 }, /* 0000 0101 0100 */
+ { 12, 0x55, 45 }, /* 0000 0101 0101 */
+ { 12, 0x56, 46 }, /* 0000 0101 0110 */
+ { 12, 0x57, 47 }, /* 0000 0101 0111 */
+ { 12, 0x64, 48 }, /* 0000 0110 0100 */
+ { 12, 0x65, 49 }, /* 0000 0110 0101 */
+ { 12, 0x52, 50 }, /* 0000 0101 0010 */
+ { 12, 0x53, 51 }, /* 0000 0101 0011 */
+ { 12, 0x24, 52 }, /* 0000 0010 0100 */
+ { 12, 0x37, 53 }, /* 0000 0011 0111 */
+ { 12, 0x38, 54 }, /* 0000 0011 1000 */
+ { 12, 0x27, 55 }, /* 0000 0010 0111 */
+ { 12, 0x28, 56 }, /* 0000 0010 1000 */
+ { 12, 0x58, 57 }, /* 0000 0101 1000 */
+ { 12, 0x59, 58 }, /* 0000 0101 1001 */
+ { 12, 0x2B, 59 }, /* 0000 0010 1011 */
+ { 12, 0x2C, 60 }, /* 0000 0010 1100 */
+ { 12, 0x5A, 61 }, /* 0000 0101 1010 */
+ { 12, 0x66, 62 }, /* 0000 0110 0110 */
+ { 12, 0x67, 63 }, /* 0000 0110 0111 */
+ { 10, 0xF, 64 }, /* 0000 0011 11 */
+ { 12, 0xC8, 128 }, /* 0000 1100 1000 */
+ { 12, 0xC9, 192 }, /* 0000 1100 1001 */
+ { 12, 0x5B, 256 }, /* 0000 0101 1011 */
+ { 12, 0x33, 320 }, /* 0000 0011 0011 */
+ { 12, 0x34, 384 }, /* 0000 0011 0100 */
+ { 12, 0x35, 448 }, /* 0000 0011 0101 */
+ { 13, 0x6C, 512 }, /* 0000 0011 0110 0 */
+ { 13, 0x6D, 576 }, /* 0000 0011 0110 1 */
+ { 13, 0x4A, 640 }, /* 0000 0010 0101 0 */
+ { 13, 0x4B, 704 }, /* 0000 0010 0101 1 */
+ { 13, 0x4C, 768 }, /* 0000 0010 0110 0 */
+ { 13, 0x4D, 832 }, /* 0000 0010 0110 1 */
+ { 13, 0x72, 896 }, /* 0000 0011 1001 0 */
+ { 13, 0x73, 960 }, /* 0000 0011 1001 1 */
+ { 13, 0x74, 1024 }, /* 0000 0011 1010 0 */
+ { 13, 0x75, 1088 }, /* 0000 0011 1010 1 */
+ { 13, 0x76, 1152 }, /* 0000 0011 1011 0 */
+ { 13, 0x77, 1216 }, /* 0000 0011 1011 1 */
+ { 13, 0x52, 1280 }, /* 0000 0010 1001 0 */
+ { 13, 0x53, 1344 }, /* 0000 0010 1001 1 */
+ { 13, 0x54, 1408 }, /* 0000 0010 1010 0 */
+ { 13, 0x55, 1472 }, /* 0000 0010 1010 1 */
+ { 13, 0x5A, 1536 }, /* 0000 0010 1101 0 */
+ { 13, 0x5B, 1600 }, /* 0000 0010 1101 1 */
+ { 13, 0x64, 1664 }, /* 0000 0011 0010 0 */
+ { 13, 0x65, 1728 }, /* 0000 0011 0010 1 */
+ { 11, 0x8, 1792 }, /* 0000 0001 000 */
+ { 11, 0xC, 1856 }, /* 0000 0001 100 */
+ { 11, 0xD, 1920 }, /* 0000 0001 101 */
+ { 12, 0x12, 1984 }, /* 0000 0001 0010 */
+ { 12, 0x13, 2048 }, /* 0000 0001 0011 */
+ { 12, 0x14, 2112 }, /* 0000 0001 0100 */
+ { 12, 0x15, 2176 }, /* 0000 0001 0101 */
+ { 12, 0x16, 2240 }, /* 0000 0001 0110 */
+ { 12, 0x17, 2304 }, /* 0000 0001 0111 */
+ { 12, 0x1C, 2368 }, /* 0000 0001 1100 */
+ { 12, 0x1D, 2432 }, /* 0000 0001 1101 */
+ { 12, 0x1E, 2496 }, /* 0000 0001 1110 */
+ { 12, 0x1F, 2560 }, /* 0000 0001 1111 */
+ { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */
+ { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */
+ { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */
+ { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */
+ { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */
+};
diff --git a/nx-X11/lib/lbxutil/image/lbxfax.h b/nx-X11/lib/lbxutil/image/lbxfax.h
new file mode 100644
index 000000000..beac228b7
--- /dev/null
+++ b/nx-X11/lib/lbxutil/image/lbxfax.h
@@ -0,0 +1,60 @@
+/* $Xorg: lbxfax.h,v 1.3 2000/08/17 19:46:41 cpqbld Exp $ */
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler
+ * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+/* $XFree86$ */
+
+/*
+ * This header file contains various constants and tables needed
+ * for FAX G42D compression.
+ */
+
+typedef struct tableentry {
+ unsigned short length; /* bit length of g3 code */
+ unsigned short code; /* g3 code */
+ short runlen; /* run length in bits */
+} tableentry;
+
+#define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */
+
+/* status values returned instead of a run length */
+
+#define G3CODE_INVALID -1
+#define G3CODE_INCOMP -2
+#define G3CODE_EOL -3
+#define G3CODE_EOF -4
+
+#define ROUNDUP8(x) ((x + 7) >> 3)
+
+#ifdef __DARWIN__
+#ifndef TIFFaxWhiteCodes
+#define TIFFFaxWhiteCodes Darwin_X_TIFFFaxWhiteCodes
+#define TIFFFaxBlackCodes Darwin_X_TIFFFaxBlackCodes
+#endif
+#endif
+extern tableentry TIFFFaxWhiteCodes[];
+extern tableentry TIFFFaxBlackCodes[];
+
+/* misc.c */
+extern int LbxImageFindDiff ( unsigned char *cp, int bs, int be, int color );
+extern void LbxReverseBits ( unsigned char *cp, int n );
diff --git a/nx-X11/lib/lbxutil/image/misc.c b/nx-X11/lib/lbxutil/image/misc.c
new file mode 100644
index 000000000..fd228624e
--- /dev/null
+++ b/nx-X11/lib/lbxutil/image/misc.c
@@ -0,0 +1,213 @@
+/* $Xorg: misc.c,v 1.3 2000/08/17 19:46:41 cpqbld Exp $ */
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler
+ * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+/*
+ * This module contains utilities for image compression used
+ * by the LBX server and proxy.
+ */
+
+#include "lbxfax.h"
+
+static unsigned char zeroruns[256] = {
+ 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, /* 0x00 - 0x0f */
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x10 - 0x1f */
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x20 - 0x2f */
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x30 - 0x3f */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 - 0x4f */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x50 - 0x5f */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60 - 0x6f */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x70 - 0x7f */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8f */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9f */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 - 0xaf */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 - 0xbf */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 - 0xcf */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 - 0xdf */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 - 0xef */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xf0 - 0xff */
+};
+
+static unsigned char oneruns[256] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 - 0x0f */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 - 0x1f */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 - 0x2f */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30 - 0x3f */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 - 0x4f */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 - 0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x6f */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x7f */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 - 0x8f */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x90 - 0x9f */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xa0 - 0xaf */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xb0 - 0xbf */
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xc0 - 0xcf */
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xd0 - 0xdf */
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xe0 - 0xef */
+ 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, /* 0xf0 - 0xff */
+};
+
+
+static unsigned char BitRevTable[256] = {
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
+};
+
+
+/*
+ * Find a span of ones or zeros using the supplied table. The byte-aligned
+ * start of the bit string is supplied along with the start+end bit indices.
+ * The table gives the number of consecutive ones or zeros starting from the
+ * msb and is indexed by byte value.
+ */
+
+static int
+findspan (unsigned char **bpp,
+ int bs, int be,
+ unsigned char *tab)
+
+{
+ unsigned char *bp = *bpp;
+ int bits = be - bs;
+ int n, span;
+
+ /*
+ * Check partial byte on lhs.
+ */
+
+ if (bits > 0 && (n = (bs & 7)))
+ {
+ span = tab[(*bp << n) & 0xff];
+
+ if (span > 8 - n) /* table value too generous */
+ span = 8 - n;
+ if (span > bits) /* constrain span to bit range */
+ span = bits;
+ if (n+span < 8) /* doesn't extend to edge of byte */
+ goto done;
+
+ bits -= span;
+ bp++;
+ }
+ else
+ span = 0;
+
+ /*
+ * Scan full bytes for all 1's or all 0's.
+ */
+
+ while (bits >= 8)
+ {
+ n = tab[*bp];
+ span += n;
+ bits -= n;
+ if (n < 8) /* end of run */
+ goto done;
+ bp++;
+ }
+
+ /*
+ * Check partial byte on rhs.
+ */
+
+ if (bits > 0)
+ {
+ n = tab[*bp];
+ span += (n > bits ? bits : n);
+ }
+
+done:
+
+ *bpp = bp;
+ return (span);
+}
+
+/*
+ * Return the offset of the next bit in the range [bs..be] that is different
+ * from the specified color. The end, be, is returned if no such bit exists.
+ */
+
+int
+LbxImageFindDiff (unsigned char *cp,
+ int bs, int be, int color)
+
+{
+ cp += bs >> 3; /* adjust byte offset */
+ return (bs + findspan (&cp, bs, be, color ? oneruns : zeroruns));
+}
+
+
+
+
+void
+LbxReverseBits (unsigned char *cp,
+ int n)
+
+{
+ for (; n > 8; n -= 8)
+ {
+ cp[0] = BitRevTable[cp[0]];
+ cp[1] = BitRevTable[cp[1]];
+ cp[2] = BitRevTable[cp[2]];
+ cp[3] = BitRevTable[cp[3]];
+ cp[4] = BitRevTable[cp[4]];
+ cp[5] = BitRevTable[cp[5]];
+ cp[6] = BitRevTable[cp[6]];
+ cp[7] = BitRevTable[cp[7]];
+ cp += 8;
+ }
+
+ while (n-- > 0)
+ *cp = BitRevTable[*cp], cp++;
+}
diff --git a/nx-X11/lib/lbxutil/image/mkg3states.c b/nx-X11/lib/lbxutil/image/mkg3states.c
new file mode 100644
index 000000000..0e8fe3613
--- /dev/null
+++ b/nx-X11/lib/lbxutil/image/mkg3states.c
@@ -0,0 +1,761 @@
+/* $Xorg: mkg3states.c,v 1.3 2000/08/17 19:46:41 cpqbld Exp $ */
+/*
+ * Copyright (c) 1991, 1992 Sam Leffler
+ * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/lib/lbxutil/image/mkg3states.c,v 1.3 1999/02/01 11:55:49 dawes Exp $ */
+
+/*
+ * Program to construct Group 3 & Group 4 decoding tables.
+ *
+ * This code is derived from code by Michael P. Marking. In
+ * particular, the algorithms to generate the null_mode and
+ * horiz_mode state tables are his. See the comments below
+ * for more information.
+ *
+ * BEGIN (from the original source)
+ LEGAL
+ * Copyright 1989, 1990 Michael P. Marking, Post Office Box 8039,
+ * Scottsdale, Arizona 85252-8039. All rights reserved.
+ *
+ * License is granted by the copyright holder to distribute and use this
+ * code without payment of royalties or the necessity of notification as
+ * long as this notice (all the text under "LEGAL") is included.
+ *
+ * This program is offered without any warranty of any kind. It includes
+ * no warranty of merchantability or fitness for any purpose. Testing and
+ * suitability for any use are the sole responsibility of the user.
+ *
+ INFORMATION
+ * Although there is no support offered with this program, the author will
+ * endeavor to correct errors. Updates will also be made available from
+ * time to time.
+ *
+ * Contact: Michael P. Marking, Post Office Box 8039, Scottsdale, Arizona
+ * 85252-8039 USA. Replies are not guaranteed to be swift. Beginning
+ * July 1990, e-mail may be sent to uunet!ipel!marking.
+ *
+ * Also beginning in July 1990, this code will be archived at the
+ * ipel!phoenix BBS in file g3g4.zoo. The 24-hour telephone number
+ * for 300/1200/2400 is (602)274-0462. When logging in, specify user
+ * "public", system "bbs", and password "public".
+ *
+ * This code is also available from the C Users Group in volume 317.
+ *
+ * END (from the original source)
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+#define WHITE 0
+#define BLACK 1
+
+/*
+ * G3 2D and G4 decoding modes. Note that
+ * the vertical modes are ordered so that
+ * (mode - MODE_VERT_V0) gives the vertical
+ * adjustment for the b1 parameter.
+ */
+#define MODE_NULL 0
+#define MODE_PASS 1
+#define MODE_HORIZ 2
+#define MODE_VERT_VL3 3
+#define MODE_VERT_VL2 4
+#define MODE_VERT_VL1 5
+#define MODE_VERT_V0 6
+#define MODE_VERT_VR1 7
+#define MODE_VERT_VR2 8
+#define MODE_VERT_VR3 9
+#define MODE_UNCOMP 10
+#define MODE_ERROR 11
+#define MODE_ERROR_1 12
+
+unsigned long append_0 ( unsigned long prefix );
+unsigned long append_1 ( unsigned long prefix );
+
+unsigned long append_0 (unsigned long prefix)
+{
+ return (prefix + (1L<<16));
+}
+
+unsigned long append_1 (unsigned long prefix)
+{
+ static unsigned short prefix_bit[16] = {
+ 0x8000, 0x4000, 0x2000, 0x1000,
+ 0x0800, 0x0400, 0x0200, 0x0100,
+ 0x0080, 0x0040, 0x0020, 0x0010,
+ 0x0008, 0x0004, 0x0002, 0x0001
+ };
+ unsigned char len = (prefix >> 16) & 0xf;
+ return (append_0(prefix) + prefix_bit[len]);
+}
+
+#define G3CODES
+#include "lbxfax.h"
+#include "lbxbwcodes.h"
+
+short search_table ( unsigned long prefix, tableentry *tab, int n );
+short white_run_length ( unsigned long prefix );
+short black_run_length ( unsigned long prefix );
+short horiz_mode_code_black ( short runlen );
+short horiz_mode_code_white ( short runlen );
+void write_define ( FILE *fd, char *name, int value, char *comment );
+void write_preamble ( FILE *fd );
+void extern_table ( FILE *fd, char *name );
+void write_tables ( FILE *fd );
+short find_null_mode_prefix ( long prefix );
+short find_horiz_mode_prefix ( long prefix, int color );
+short find_uncomp_mode_prefix ( long prefix );
+short null_mode_type ( long prefix );
+short uncomp_mode_type ( long prefix );
+void build_null_mode_tables ( void );
+void build_horiz_mode_tables ( void );
+void build_uncomp_mode_tables ( void );
+
+short search_table (unsigned long prefix, tableentry *tab, int n)
+{
+ unsigned short len = (prefix >> 16) & 0xf;
+ unsigned short code = (prefix & 0xffff) >> (16 - len);
+
+ while (n-- > 0) {
+ if (tab->length == len && tab->code == code)
+ return ((short) tab->runlen);
+ tab++;
+ }
+ return (G3CODE_INCOMP);
+}
+
+#define NCODES(a) (sizeof (a) / sizeof (a[0]))
+short white_run_length (unsigned long prefix)
+{
+ return (search_table(prefix, TIFFFaxWhiteCodes, NCODES(TIFFFaxWhiteCodes)));
+}
+
+short black_run_length (unsigned long prefix)
+{
+ return (search_table(prefix, TIFFFaxBlackCodes, NCODES(TIFFFaxBlackCodes)));
+}
+#undef NCODES
+
+#define MAX_NULLPREFIX 200 /* max # of null-mode prefixes */
+typedef unsigned char NullModeTable[MAX_NULLPREFIX][256];
+#define MAX_HORIZPREFIX 250 /* max # of incomplete 1-D prefixes */
+typedef unsigned char HorizModeTable[MAX_HORIZPREFIX][256];
+
+ /* the bit string corresponding to this row of the decoding table */
+long null_mode_prefix[MAX_NULLPREFIX];
+NullModeTable null_mode; /* MODE_*, indexed by bit and byte */
+NullModeTable null_mode_next_state; /* next row of decoding tables to use */
+ /* number of prefixes or rows in the G4 decoding tables */
+short null_mode_prefix_count = 0;
+
+void write_null_mode_table ( FILE *fd, NullModeTable table, char *name );
+void write_horiz_mode_table ( FILE *fd, HorizModeTable table, char *name );
+
+/*
+ * 2D uncompressed mode codes. Note
+ * that two groups of codes are arranged
+ * so that the decoder can caluclate the
+ * length of the run by subtracting the
+ * code from a known base value.
+ */
+#define UNCOMP_INCOMP 0
+/* runs of [0]*1 */
+#define UNCOMP_RUN0 1
+#define UNCOMP_RUN1 2
+#define UNCOMP_RUN2 3
+#define UNCOMP_RUN3 4
+#define UNCOMP_RUN4 5
+#define UNCOMP_RUN5 6
+#define UNCOMP_RUN6 7
+/* runs of [0]* w/ terminating color */
+#define UNCOMP_TRUN0 8
+#define UNCOMP_TRUN1 9
+#define UNCOMP_TRUN2 10
+#define UNCOMP_TRUN3 11
+#define UNCOMP_TRUN4 12
+/* special code for unexpected EOF */
+#define UNCOMP_EOF 13
+/* invalid code encountered */
+#define UNCOMP_INVALID 14
+
+long uncomp_mode_prefix[MAX_NULLPREFIX];
+NullModeTable uncomp_mode;
+NullModeTable uncomp_mode_next_state;
+short uncomp_mode_prefix_count = 0;
+
+/*
+ * Decoding action values for horiz_mode.
+ */
+#define ACT_INCOMP 0 /* incompletely decoded code */
+#define ACT_INVALID 1 /* invalide code */
+#define ACT_WRUNT 2 /* terminating white run code */
+#define ACT_WRUN 65 /* non-terminating white run code */
+#define ACT_BRUNT 106 /* terminating black run code */
+#define ACT_BRUN 169 /* non-terminating black run code */
+#define ACT_EOL 210 /* end-of-line code */
+HorizModeTable horiz_mode;
+
+short horiz_mode_code_black (short runlen)
+{
+ return (runlen < 64 ? runlen + ACT_BRUNT : (runlen / 64) + ACT_BRUN);
+}
+
+short horiz_mode_code_white (short runlen)
+{
+ return (runlen < 64 ? runlen + ACT_WRUNT : (runlen / 64) + ACT_WRUN);
+}
+
+/*
+ * If the corresponding horiz_mode entry is ACT_INCOMP
+ * this entry is a row number for decoding the next byte;
+ * otherwise, it is the bit number with which to continue
+ * decoding the next codeword.
+ */
+HorizModeTable horiz_mode_next_state;
+ /* prefixes corresponding to the rows of the decoding table */
+long horiz_mode_prefix[MAX_HORIZPREFIX];
+ /* color of next run, BLACK or WHITE */
+char horiz_mode_color[MAX_HORIZPREFIX];
+short horiz_mode_prefix_count = 0;
+
+static unsigned char bit_mask[8] =
+ { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
+
+
+int verbose = FALSE;
+char *storage_class = "";
+
+int
+main (int argc, char *argv[])
+{
+ while (argc > 1 && argv[1][0] == '-') {
+ if (strcmp(argv[1], "-v") == 0) {
+ verbose = TRUE;
+ argc--, argv++;
+ } else if (strcmp(argv[1], "-c") == 0) {
+ storage_class = "const ";
+ argc--, argv++;
+ }
+ }
+ build_null_mode_tables(); /* null mode decoding tables */
+ if (verbose) {
+ fprintf(stderr, "%d null mode prefixes defined\n",
+ (int) null_mode_prefix_count);
+ fprintf(stderr, "building uncompressed mode scripts...\n");
+ }
+ build_uncomp_mode_tables(); /* uncompressed mode decoding tables */
+ if (verbose) {
+ fprintf(stderr, "%d uncompressed mode prefixes defined\n",
+ (int) uncomp_mode_prefix_count);
+ fprintf(stderr, "building 1D scripts...\n");
+ }
+ build_horiz_mode_tables(); /* 1D decoding tables */
+ if (verbose)
+ fprintf(stderr, "%d incomplete prefixes defined\n",
+ (int) horiz_mode_prefix_count);
+ write_tables(stdout);
+ exit(0);
+}
+
+void write_null_mode_table (fd, table, name)
+FILE *fd;
+NullModeTable table;
+char *name;
+{
+ int i, j;
+ char* outersep;
+ char* sep;
+
+ fprintf(fd, "%sunsigned char\t%s[%d][256] = {", storage_class,
+ name, (int) null_mode_prefix_count);
+ outersep = "";
+ for (i = 0; i < null_mode_prefix_count; i++) {
+ fprintf(fd, "%s\n/* prefix %d */ {\n", outersep, i);
+ sep = " ";
+ for (j = 0; j < 256; j++) {
+ fprintf(fd, "%s%2d", sep, (int) table[i][j]);
+ if (((j+1) % 16) == 0) {
+ fprintf(fd, ", /* %3d-%3d */\n", j-15, j);
+ sep = " ";
+ } else
+ sep = ",";
+ }
+ fprintf(fd, "}");
+ outersep = ",";
+ }
+ fprintf(fd, "\n};\n");
+}
+
+void
+write_horiz_mode_table (FILE *fd, HorizModeTable table, char *name)
+{
+ int i, j;
+ char* outersep;
+ char* sep;
+
+ fprintf(fd, "%s unsigned char\t%s[%d][256] = {", storage_class,
+ name, (int) horiz_mode_prefix_count);
+ outersep = "";
+ for (i = 0; i < horiz_mode_prefix_count; i++) {
+ fprintf(fd, "%s\n/* prefix %d */ {\n", outersep, i);
+ sep = " ";
+ for (j = 0; j < 256; j++) {
+ fprintf(fd, "%s%3d", sep, (int) table[i][j]);
+ if (((j+1) % 14) == 0) {
+ fprintf(fd, ", /* %3d-%3d */\n", j-13, j);
+ sep = " ";
+ } else
+ sep = ",";
+ }
+ fprintf(fd, "\n}");
+ outersep = ",";
+ }
+ fprintf(fd, "\n};\n");
+}
+
+void
+write_define(FILE *fd, char *name, int value, char *comment)
+{
+ fprintf(fd, "#define\t%s\t%d", name, value);
+ if (comment)
+ fprintf(fd, "\t/* %s */", comment);
+ fprintf(fd, "\n");
+}
+
+void
+write_preamble(FILE *fd)
+{
+ fprintf(fd, "%s\n",
+"/* DO NOT EDIT THIS FILE, IT WAS AUTOMATICALLY CREATED BY mkg3state */");
+ write_define(fd, "ACT_INCOMP", ACT_INCOMP, "incompletely decoded code");
+ write_define(fd, "ACT_INVALID", ACT_INVALID, "invalide code");
+ write_define(fd, "ACT_WRUNT", ACT_WRUNT, "terminating white run code");
+ write_define(fd, "ACT_WRUN", ACT_WRUN, "non-terminating white run code");
+ write_define(fd, "ACT_BRUNT", ACT_BRUNT, "terminating black run code");
+ write_define(fd, "ACT_BRUN", ACT_BRUN, "non-terminating black run code");
+ write_define(fd, "ACT_EOL", ACT_EOL, "end-of-line code");
+ fprintf(fd, "\n");
+ fprintf(fd, "/* modes that the decoder can be in */\n");
+ write_define(fd, "MODE_NULL", MODE_NULL, NULL);
+ write_define(fd, "MODE_PASS", MODE_PASS, NULL);
+ write_define(fd, "MODE_HORIZ", MODE_HORIZ, NULL);
+ write_define(fd, "MODE_VERT_V0", MODE_VERT_V0, NULL);
+ write_define(fd, "MODE_VERT_VR1", MODE_VERT_VR1, NULL);
+ write_define(fd, "MODE_VERT_VR2", MODE_VERT_VR2, NULL);
+ write_define(fd, "MODE_VERT_VR3", MODE_VERT_VR3, NULL);
+ write_define(fd, "MODE_VERT_VL1", MODE_VERT_VL1, NULL);
+ write_define(fd, "MODE_VERT_VL2", MODE_VERT_VL2, NULL);
+ write_define(fd, "MODE_VERT_VL3", MODE_VERT_VL3, NULL);
+ write_define(fd, "MODE_UNCOMP", MODE_UNCOMP, NULL);
+ write_define(fd, "MODE_ERROR", MODE_ERROR, NULL);
+ write_define(fd, "MODE_ERROR_1", MODE_ERROR_1, NULL);
+ fprintf(fd, "\n");
+ fprintf(fd, "#define\tRUNLENGTH(ix) (TIFFFaxWhiteCodes[ix].runlen)\n");
+ fprintf(fd, "\n");
+ write_define(fd, "UNCOMP_INCOMP", UNCOMP_INCOMP, NULL);
+ fprintf(fd, "/* runs of [0]*1 */\n");
+ write_define(fd, "UNCOMP_RUN0", UNCOMP_RUN0, NULL);
+ write_define(fd, "UNCOMP_RUN1", UNCOMP_RUN1, NULL);
+ write_define(fd, "UNCOMP_RUN2", UNCOMP_RUN2, NULL);
+ write_define(fd, "UNCOMP_RUN3", UNCOMP_RUN3, NULL);
+ write_define(fd, "UNCOMP_RUN4", UNCOMP_RUN4, NULL);
+ write_define(fd, "UNCOMP_RUN5", UNCOMP_RUN5, NULL);
+ write_define(fd, "UNCOMP_RUN6", UNCOMP_RUN6, NULL);
+ fprintf(fd, "/* runs of [0]* w/ terminating color */\n");
+ write_define(fd, "UNCOMP_TRUN0", UNCOMP_TRUN0, NULL);
+ write_define(fd, "UNCOMP_TRUN1", UNCOMP_TRUN1, NULL);
+ write_define(fd, "UNCOMP_TRUN2", UNCOMP_TRUN2, NULL);
+ write_define(fd, "UNCOMP_TRUN3", UNCOMP_TRUN3, NULL);
+ write_define(fd, "UNCOMP_TRUN4", UNCOMP_TRUN4, NULL);
+ fprintf(fd, "/* special code for unexpected EOF */\n");
+ write_define(fd, "UNCOMP_EOF", UNCOMP_EOF, NULL);
+ fprintf(fd, "/* invalid code encountered */\n");
+ write_define(fd, "UNCOMP_INVALID", UNCOMP_INVALID, NULL);
+ fprintf(fd, "/* codes >= terminate uncompress mode */\n");
+ fprintf(fd, "#define\tUNCOMP_EXIT UNCOMP_TRUN0\n");
+ fprintf(fd, "\n");
+}
+
+void
+extern_table(FILE *fd, char *name)
+{
+ fprintf(fd, "extern\t%sunsigned char %s[][256];\n", storage_class, name);
+}
+
+void
+write_tables(FILE *fd)
+{
+ write_preamble(fd);
+ write_null_mode_table(fd, null_mode, "TIFFFax2DMode");
+ write_null_mode_table(fd, null_mode_next_state, "TIFFFax2DNextState");
+ write_null_mode_table(fd, uncomp_mode, "TIFFFaxUncompAction");
+ write_null_mode_table(fd, uncomp_mode_next_state, "TIFFFaxUncompNextState");
+ write_horiz_mode_table(fd, horiz_mode, "TIFFFax1DAction");
+ write_horiz_mode_table(fd, horiz_mode_next_state, "TIFFFax1DNextState");
+}
+
+short
+find_null_mode_prefix (long prefix)
+{
+ short j1;
+
+ if (prefix == 0L)
+ return (0);
+ for (j1 = 8; j1 < null_mode_prefix_count; j1++)
+ if (prefix == null_mode_prefix[j1])
+ return (j1);
+ if (null_mode_prefix_count == MAX_NULLPREFIX) {
+ fprintf(stderr, "ERROR: null mode prefix table overflow\n");
+ exit(1);
+ }
+ if (verbose)
+ fprintf(stderr, "adding null mode prefix[%d] 0x%lx\n",
+ (int) null_mode_prefix_count, prefix);
+ null_mode_prefix[null_mode_prefix_count++] = prefix;
+ return (null_mode_prefix_count-1);
+}
+
+short
+find_horiz_mode_prefix (long prefix, int color)
+{
+ short j1;
+
+ for (j1 = 0; j1 < horiz_mode_prefix_count; j1++)
+ if (prefix == horiz_mode_prefix[j1] && horiz_mode_color[j1] == color)
+ return (j1);
+ /*
+ * It wasn't found, so add it to the tables, but first, is there room?
+ */
+ if (horiz_mode_prefix_count == MAX_HORIZPREFIX) {
+ fprintf(stderr, "ERROR: 1D prefix table overflow\n");
+ exit(1);
+ }
+ /* OK, there's room... */
+ if (verbose)
+ fprintf(stderr, "\nhoriz mode prefix %d, color %c = 0x%lx ",
+ (int) horiz_mode_prefix_count, "WB"[color], prefix);
+ horiz_mode_prefix[horiz_mode_prefix_count] = prefix;
+ horiz_mode_color[horiz_mode_prefix_count] = color;
+ horiz_mode_prefix_count++;
+ return (horiz_mode_prefix_count - 1);
+}
+
+short
+find_uncomp_mode_prefix (long prefix)
+{
+ short j1;
+
+ if (prefix == 0L)
+ return (0);
+ for (j1 = 8; j1 < uncomp_mode_prefix_count; j1++)
+ if (prefix == uncomp_mode_prefix[j1])
+ return (j1);
+ if (uncomp_mode_prefix_count == MAX_NULLPREFIX) {
+ fprintf(stderr, "ERROR: uncomp mode prefix table overflow\n");
+ exit(1);
+ }
+ if (verbose)
+ fprintf(stderr, "adding uncomp mode prefix[%d] 0x%lx\n",
+ (int) uncomp_mode_prefix_count, prefix);
+ uncomp_mode_prefix[uncomp_mode_prefix_count++] = prefix;
+ return (uncomp_mode_prefix_count-1);
+}
+
+short
+null_mode_type (long prefix)
+{
+ switch (prefix) {
+ case 0x18000L: return (MODE_VERT_V0); /* 1 */
+ case 0x36000L: return (MODE_VERT_VR1); /* 011 */
+ case 0x34000L: return (MODE_VERT_VL1); /* 010 */
+ case 0x32000L: return (MODE_HORIZ); /* 001 */
+ case 0x41000L: return (MODE_PASS); /* 0001 */
+ case 0x60C00L: return (MODE_VERT_VR2); /* 0000 11 */
+ case 0x60800L: return (MODE_VERT_VL2); /* 0000 10 */
+ case 0x70600L: return (MODE_VERT_VR3); /* 0000 011 */
+ case 0x70400L: return (MODE_VERT_VL3); /* 0000 010 */
+ case 0x80200L: return (MODE_ERROR); /* 0000 0010 */
+ case 0x90300L: return (MODE_ERROR); /* 0000 0011 0 */
+ case 0xA0380L: return (MODE_ERROR); /* 0000 0011 10 */
+ case 0xA03C0L: return (MODE_UNCOMP); /* 0000 0011 11 */
+ /*
+ * Under the assumption that there are no
+ * errors in the file, then this bit string
+ * can only be the beginning of an EOL code.
+ */
+ case 0x70000L: return (MODE_ERROR_1); /* 0000 000 */
+ }
+ return (-1);
+}
+
+short
+uncomp_mode_type (long prefix)
+{
+ short code;
+ short len;
+ switch (prefix) {
+ case 0x18000L: return (UNCOMP_RUN1); /* 1 */
+ case 0x24000L: return (UNCOMP_RUN2); /* 01 */
+ case 0x32000L: return (UNCOMP_RUN3); /* 001 */
+ case 0x41000L: return (UNCOMP_RUN4); /* 0001 */
+ case 0x50800L: return (UNCOMP_RUN5); /* 0000 1 */
+ case 0x60400L: return (UNCOMP_RUN6); /* 0000 01 */
+ case 0x70200L: return (UNCOMP_TRUN0); /* 0000 001 */
+ case 0x80100L: return (UNCOMP_TRUN1); /* 0000 0001 */
+ case 0x90080L: return (UNCOMP_TRUN2); /* 0000 0000 1 */
+ case 0xA0040L: return (UNCOMP_TRUN3); /* 0000 0000 01 */
+ case 0xB0020L: return (UNCOMP_TRUN4); /* 0000 0000 001 */
+ }
+ code = prefix & 0xffffL;
+ len = (prefix >> 16) & 0xf;
+ return ((code || len > 10) ? UNCOMP_INVALID : -1);
+}
+
+#define BASESTATE(b) ((unsigned char) ((b) & 0x7))
+
+void
+build_null_mode_tables(void)
+{
+ short prefix;
+
+ /*
+ * Note: the first eight entries correspond to
+ * a null prefix and starting bit numbers 0-7.
+ */
+ null_mode_prefix_count = 8;
+ for (prefix = 0; prefix < null_mode_prefix_count; prefix++) {
+ short byte;
+ for (byte = 0; byte < 256; byte++) {
+ short firstbit;
+ short bit;
+ long curprefix;
+ char found_code = FALSE;
+
+ if (prefix < 8) {
+ curprefix = 0L;
+ firstbit = prefix;
+ } else {
+ curprefix = null_mode_prefix[prefix];
+ firstbit = 0;
+ }
+ for (bit = firstbit; bit < 8 && !found_code; bit++) {
+ short mode;
+
+ if (bit_mask[bit] & byte)
+ curprefix = append_1(curprefix);
+ else
+ curprefix = append_0(curprefix);
+ switch (mode = null_mode_type(curprefix)) {
+ case MODE_PASS:
+ case MODE_HORIZ:
+ case MODE_VERT_V0:
+ case MODE_VERT_VR1:
+ case MODE_VERT_VR2:
+ case MODE_VERT_VR3:
+ case MODE_VERT_VL1:
+ case MODE_VERT_VL2:
+ case MODE_VERT_VL3:
+ case MODE_UNCOMP:
+ case MODE_ERROR:
+ case MODE_ERROR_1:
+ /*
+ * NOTE: if the bit number is 8, then the table
+ * entry will be zero, which indicates a new byte
+ * is to be fetched during the decoding process
+ */
+ found_code = TRUE;
+ null_mode[prefix][byte] = (unsigned char) mode;
+ null_mode_next_state[prefix][byte] = BASESTATE(bit+1);
+ break;
+ }
+ }
+ if (!found_code) {
+ null_mode_next_state[prefix][byte] = (unsigned char)
+ find_null_mode_prefix(curprefix);
+ /*
+ * This indicates to the decoder that
+ * no valid code has yet been identified.
+ */
+ null_mode[prefix][byte] = MODE_NULL;
+ }
+ }
+ }
+}
+
+void
+build_horiz_mode_tables(void)
+{
+ unsigned short byte;
+ short prefix;
+
+ /*
+ * The first 8 are for white,
+ * the second 8 are for black,
+ * beginning with bits 0-7.
+ */
+ horiz_mode_prefix_count = 16;
+ for (prefix = 0; prefix < horiz_mode_prefix_count; prefix++)
+ for (byte = 0; byte < 256; byte++) {
+ short bits_digested = 0;
+ short bit;
+ short firstbit;
+ char color;
+ unsigned long curprefix;
+
+ if (prefix < 8) {
+ color = WHITE;
+ curprefix = 0L;
+ firstbit = prefix;
+ } else if (prefix < 16) {
+ color = BLACK;
+ curprefix = 0L;
+ firstbit = prefix - 8;
+ } else {
+ color = horiz_mode_color[prefix];
+ curprefix = horiz_mode_prefix[prefix];
+ firstbit = 0;
+ }
+ for (bit = firstbit; bit < 8 && !bits_digested; bit++) {
+ if (bit_mask[bit] & byte)
+ curprefix = append_1(curprefix);
+ else
+ curprefix = append_0(curprefix);
+ /*
+ * The following conversion allows for arbitrary strings of
+ * zeroes to precede the end-of-line code 0000 0000 0001.
+ * It assumes no errors in the data, and is based on
+ * the assumption that the code replaced (12 consecutive
+ * zeroes) can only be "legally" encountered before the
+ * end-of-line code. This assumption is valid only for
+ * a Group 3 image; the combination will never occur
+ * in horizontal mode in a proper Group 4 image.
+ */
+ if (curprefix == 0xC0000L)
+ curprefix = 0xB0000L;
+ if (color == WHITE) {
+ short runlength = white_run_length(curprefix);
+
+ if (runlength == G3CODE_INVALID) {
+ horiz_mode[prefix][byte] = (unsigned char) ACT_INVALID;
+ horiz_mode_next_state[prefix][byte] = (unsigned char) bit;
+ bits_digested = bit + 1;
+ } else if (runlength == G3CODE_EOL) { /* Group 3 only */
+ horiz_mode[prefix][byte] = (unsigned char) ACT_EOL;
+ horiz_mode_next_state[prefix][byte] = BASESTATE(bit+1);
+ bits_digested = bit + 1;
+ } else if (runlength != G3CODE_INCOMP) {
+ horiz_mode[prefix][byte] = (unsigned char)
+ horiz_mode_code_white(runlength);
+ horiz_mode_next_state[prefix][byte] = BASESTATE(bit+1);
+ bits_digested = bit + 1;
+ }
+ } else { /* color == BLACK */
+ short runlength = black_run_length(curprefix);
+
+ if (runlength == G3CODE_INVALID) {
+ horiz_mode[prefix][byte] = (unsigned char) ACT_INVALID;
+ horiz_mode_next_state[prefix][byte] = (unsigned char) (bit+8);
+ bits_digested = bit + 1;
+ } else if (runlength == G3CODE_EOL) { /* Group 3 only */
+ horiz_mode[prefix][byte] = (unsigned char) ACT_EOL;
+ horiz_mode_next_state[prefix][byte] = BASESTATE(bit+1);
+ bits_digested = bit + 1;
+ } else if (runlength != G3CODE_INCOMP) {
+ horiz_mode[prefix][byte] = (unsigned char)
+ horiz_mode_code_black(runlength);
+ horiz_mode_next_state[prefix][byte] = BASESTATE(bit+1);
+ bits_digested = bit + 1;
+ }
+ }
+ }
+ if (!bits_digested) { /* no codewords after examining byte */
+ horiz_mode[prefix][byte] = (unsigned char) ACT_INCOMP;
+ horiz_mode_next_state[prefix][byte] = (unsigned char)
+ find_horiz_mode_prefix(curprefix, color);
+ }
+ }
+}
+
+void
+build_uncomp_mode_tables(void)
+{
+ short prefix;
+
+ /*
+ * Note: the first eight entries correspond to
+ * a null prefix and starting bit numbers 0-7.
+ */
+ uncomp_mode_prefix_count = 8;
+ for (prefix = 0; prefix < uncomp_mode_prefix_count; prefix++) {
+ short byte;
+ for (byte = 0; byte < 256; byte++) {
+ short firstbit;
+ short bit;
+ long curprefix;
+ char found_code = FALSE;
+
+ if (prefix < 8) {
+ curprefix = 0L;
+ firstbit = prefix;
+ } else {
+ curprefix = uncomp_mode_prefix[prefix];
+ firstbit = 0;
+ }
+ for (bit = firstbit; bit < 8 && !found_code; bit++) {
+ short mode;
+
+ if (bit_mask[bit] & byte)
+ curprefix = append_1(curprefix);
+ else
+ curprefix = append_0(curprefix);
+ mode = uncomp_mode_type(curprefix);
+ if (mode != -1) {
+ /*
+ * NOTE: if the bit number is 8, then the table
+ * entry will be zero, which indicates a new byte
+ * is to be fetched during the decoding process
+ */
+ found_code = TRUE;
+ uncomp_mode[prefix][byte] = (unsigned char) mode;
+ uncomp_mode_next_state[prefix][byte] = BASESTATE(bit+1);
+ break;
+ }
+ }
+ if (!found_code) {
+ uncomp_mode_next_state[prefix][byte] = (unsigned char)
+ find_uncomp_mode_prefix(curprefix);
+ /*
+ * This indicates to the decoder that
+ * no valid code has yet been identified.
+ */
+ uncomp_mode[prefix][byte] = UNCOMP_INCOMP;
+ }
+ }
+ }
+}
diff --git a/nx-X11/lib/lbxutil/lbx_zlib/Imakefile b/nx-X11/lib/lbxutil/lbx_zlib/Imakefile
new file mode 100644
index 000000000..ddcecc6fd
--- /dev/null
+++ b/nx-X11/lib/lbxutil/lbx_zlib/Imakefile
@@ -0,0 +1,22 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:41 cpqbld Exp $
+XCOMM $XdotOrg: xc/lib/lbxutil/lbx_zlib/Imakefile,v 1.3 2004/10/10 17:13:11 herrb Exp $
+
+#include <Library.tmpl>
+
+SRCS = lbx_zlib.c lbx_zlib_io.c reqstats.c
+
+OBJS = lbx_zlib.o lbx_zlib_io.o reqstats.o
+
+#if !HasZlib
+ZLIB_INCLUDES= -I../../zlib
+#endif
+
+INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/include \
+ -I../../../include/extensions $(ZLIB_INCLUDES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
diff --git a/nx-X11/lib/lbxutil/lbx_zlib/lbx_zlib.c b/nx-X11/lib/lbxutil/lbx_zlib/lbx_zlib.c
new file mode 100644
index 000000000..e7105a0c7
--- /dev/null
+++ b/nx-X11/lib/lbxutil/lbx_zlib/lbx_zlib.c
@@ -0,0 +1,543 @@
+/* $Xorg: lbx_zlib.c,v 1.6 2001/02/09 02:04:05 xorgcvs Exp $ */
+
+/*
+
+Copyright 1995, 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 1988, 1989, 1990, 1994 Network Computing Devices, Inc.
+ *
+ * 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 Network Computing Devices, Inc. not be
+ * used in advertising or publicity pertaining to distribution of this
+ * software without specific, written prior permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
+ * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
+ * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
+ * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
+ * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
+ * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/lib/lbxutil/lbx_zlib/lbx_zlib.c,v 1.9 2001/08/27 19:01:07 dawes Exp $ */
+
+#ifdef WIN32
+#define _WILLWINSOCK_
+#endif
+#define _BSD_SOURCE
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#if !defined(WIN32) && !defined(Lynx)
+#include <sys/param.h>
+#endif
+#include <X11/extensions/lbxbufstr.h>
+#include "lbx_zlib.h"
+#include <X11/extensions/lbxzlib.h>
+
+unsigned long stream_out_compressed;
+unsigned long stream_out_uncompressed;
+unsigned long stream_out_plain;
+unsigned long stream_in_compressed;
+unsigned long stream_in_uncompressed;
+unsigned long stream_in_plain;
+#ifdef LBXREQSTATS
+unsigned long stream_in_packet_header_bytes = 0;
+extern int LbxWhoAmI;
+#endif
+
+struct ZlibInfo {
+ struct compress_private compress_state;
+ struct compress_private decompress_state;
+ int fd;
+ int compress_off;
+ ZlibBuffer inbuf;
+ ZlibBuffer outbuf;
+ unsigned char header[ZLIB_PACKET_HDRLEN];
+ struct iovec iovbuf[2];
+};
+
+static int
+init_compress(struct compress_private *priv,/* local pointer to private data */
+ int level) /* compression level */
+{
+ priv->cp_outputcount = 0;
+
+ priv->cp_in_count = 0; /* length of input */
+ priv->cp_bytes_out = 0; /* length of compressed output */
+ priv->cp_inputbuf = priv->cp_inputbufend = NULL;
+ priv->cp_packet = NULL;
+
+ priv->stream.zalloc = (alloc_func) 0;
+ priv->stream.zfree = (free_func) 0;
+ priv->stream.next_in = NULL;
+ priv->stream.next_out = NULL;
+ priv->stream.avail_in = priv->stream.avail_out = 0;
+
+ priv->z_err = deflateInit (&(priv->stream), level);
+
+ return (priv->compress_inited = (priv->z_err == Z_OK) ? 1 : 0);
+}
+
+static int
+init_decompress(struct compress_private *priv)/* local pointer to private data */
+{
+ priv->cp_outputcount = 0;
+
+ priv->cp_in_count = 0; /* length of input */
+ priv->cp_bytes_out = 0; /* length of compressed output */
+ priv->cp_inputbuf = priv->cp_inputbufend = NULL;
+ priv->cp_packet = NULL;
+
+ priv->stream.zalloc = (alloc_func) 0;
+ priv->stream.zfree = (free_func) 0;
+ priv->stream.next_in = NULL;
+ priv->stream.next_out = NULL;
+ priv->stream.avail_in = priv->stream.avail_out = 0;
+
+ priv->need_flush_decompress = 0;
+
+ priv->z_err = inflateInit (&(priv->stream));
+
+#ifdef LBXREQSTATS
+ priv->req_length = -1;
+ priv->req_compbytes_read = 0;
+ priv->req_uncompbytes_read = 0;
+ priv->x_header_bytes_read = 0;
+#endif
+
+ return (priv->decompress_inited = (priv->z_err == Z_OK) ? 1 : 0);
+}
+
+
+static void
+do_compress (struct compress_private *priv,
+ int flush)
+
+{
+ priv->stream.next_in = priv->cp_inputbuf;
+ priv->stream.avail_in = priv->cp_inputbufend - priv->cp_inputbuf;
+
+ priv->stream.next_out = priv->cp_outputbuf;
+ priv->stream.avail_out = priv->cp_outputbufend - priv->cp_outputbuf;
+
+ priv->z_err = deflate (&(priv->stream), flush);
+
+ priv->cp_inputbuf = priv->stream.next_in;
+ priv->cp_outputbuf = priv->stream.next_out;
+}
+
+
+static void
+do_decompress (struct compress_private *priv)
+
+{
+ priv->stream.next_in = priv->cp_inputbuf;
+ priv->stream.avail_in = priv->cp_inputbufend - priv->cp_inputbuf;
+
+ priv->stream.next_out = priv->cp_outputbuf;
+ priv->stream.avail_out = priv->cp_outputbufend - priv->cp_outputbuf;
+
+ priv->z_err = inflate (&(priv->stream), Z_PARTIAL_FLUSH);
+
+ priv->need_flush_decompress = (priv->stream.avail_out == 0);
+
+ priv->cp_inputbuf = priv->stream.next_in;
+ priv->cp_outputbuf = priv->stream.next_out;
+}
+
+static int
+GetNewPacket(struct ZlibInfo *comp)
+{
+ register struct compress_private *priv = &comp->decompress_state;
+ int len;
+ int result;
+
+ if (priv->cp_packet) {
+ /* Free up previous packet in input buffer */
+ FreeInput(&comp->inbuf, priv->cp_inputbufend - priv->cp_packet);
+ priv->cp_packet = NULL;
+ }
+
+ if ((result = GetInputPtr(comp->fd,
+ &comp->inbuf,
+ ZLIB_PACKET_HDRLEN,
+ &priv->cp_packet)) <= 0)
+ return result;
+ len = ZLIB_GET_DATALEN(priv->cp_packet);
+ if ((result = GetInputPtr(comp->fd,
+ &comp->inbuf,
+ len + ZLIB_PACKET_HDRLEN,
+ &priv->cp_packet)) <= 0) {
+ priv->cp_packet = NULL;
+ return result;
+ }
+
+ return len;
+}
+
+static int
+NewPacketAvail(struct ZlibInfo *comp)
+{
+ register struct compress_private *priv = &comp->decompress_state;
+ char *pkt;
+ int len;
+
+ if (priv->cp_packet) {
+ /* Free up previous packet in input buffer */
+ FreeInput(&comp->inbuf, priv->cp_inputbufend - priv->cp_packet);
+ priv->cp_packet = NULL;
+ }
+
+ if ((pkt = BYTES_AVAIL(&comp->inbuf, ZLIB_PACKET_HDRLEN))) {
+ len = ZLIB_GET_DATALEN(pkt);
+ if (BYTES_AVAIL(&comp->inbuf, len + ZLIB_PACKET_HDRLEN))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static int
+PlainWrite(struct ZlibInfo *comp,
+ unsigned char *buffer,
+ int buflen)
+{
+ int retval;
+ int lenleft = buflen;
+
+ if ((retval = ZlibFlush(comp->fd)) == 0) {
+ register struct iovec *iov = comp->iovbuf;
+ while (lenleft) {
+ int outlen, written;
+ if ((outlen = iov[1].iov_len)) {
+ iov[1].iov_base = (caddr_t) buffer;
+ }
+ else {
+ outlen = MIN(lenleft, ZLIB_MAX_DATALEN);
+ ZLIB_PUT_PKTHDR(comp->header, outlen, FALSE);
+ iov[0].iov_base = (caddr_t) comp->header;
+ iov[0].iov_len = ZLIB_PACKET_HDRLEN;
+ iov[1].iov_base = (caddr_t) buffer;
+ iov[1].iov_len = outlen;
+ stream_out_uncompressed += ZLIB_PACKET_HDRLEN;
+ }
+ if ((retval = FlushIovBuf(comp->fd, iov)) < 0)
+ break;
+ written = outlen - retval;
+ lenleft -= written;
+ buffer += written;
+ stream_out_plain += written;
+ stream_out_uncompressed += written;
+ if (retval)
+ break;
+ }
+ if (lenleft == buflen)
+ return retval;
+ else
+ return buflen - lenleft;
+ }
+
+ else if (retval > 0) {
+ retval = -1;
+ errno = EWOULDBLOCK;
+ }
+
+ return retval;
+}
+
+#define MAX_FDS 256
+
+static struct ZlibInfo *per_fd[MAX_FDS];
+
+/*
+ * Initialize ZLIB compressor
+ */
+void *
+ZlibInit(int fd,
+ int level) /* compression level */
+{
+ struct ZlibInfo *comp;
+ int ret1, ret2;
+
+ if ((comp = (struct ZlibInfo *)Xalloc(sizeof(struct ZlibInfo))) == NULL)
+ return NULL;
+
+ ret1 = InitZlibBuffer(&comp->inbuf, INBUFFER_SIZE);
+ ret2 = InitZlibBuffer(&comp->outbuf, OUTBUFFER_SIZE);
+ if (ret1 < 0 || ret2 < 0) {
+ ZlibFree(comp);
+ return NULL;
+ }
+ comp->compress_off = FALSE;
+ comp->iovbuf[1].iov_len = 0;
+ comp->fd = fd;
+
+ if (!init_compress(&comp->compress_state, level) ||
+ !init_decompress(&comp->decompress_state)) {
+ ZlibFree(comp);
+ return NULL;
+ }
+
+ per_fd[fd] = comp;
+
+#ifdef LBXREQSTATS
+ InitLbxReqStats ();
+#endif
+
+ return (void *)comp;
+}
+
+void
+ZlibFree(struct ZlibInfo *comp)
+{
+ if (!comp)
+ return;
+ per_fd[comp->fd] = 0;
+ FreeZlibBuffer(&comp->inbuf);
+ FreeZlibBuffer(&comp->outbuf);
+
+ if (comp->compress_state.compress_inited)
+ deflateEnd (&(comp->compress_state.stream));
+ else if (comp->decompress_state.decompress_inited)
+ inflateEnd (&(comp->compress_state.stream));
+
+ Xfree(comp);
+}
+
+int
+ZlibFlush(int fd)
+{
+ struct ZlibInfo *comp = per_fd[fd];
+ struct compress_private *priv = &comp->compress_state;
+
+ if (priv->cp_in_count) {
+ int len;
+ do_compress (priv, Z_PARTIAL_FLUSH);
+ len = priv->cp_outputbuf - (priv->cp_packet + ZLIB_PACKET_HDRLEN);
+ ZLIB_PUT_PKTHDR(priv->cp_packet, len, TRUE);
+ stream_out_compressed += (len + ZLIB_PACKET_HDRLEN);
+
+ CommitOutBuf(&comp->outbuf, len + ZLIB_PACKET_HDRLEN);
+ priv->cp_in_count = 0;
+ }
+
+ return FlushOutBuf(comp->fd, &comp->outbuf);
+}
+
+int
+ZlibStuffInput(int fd,
+ unsigned char *buffer,
+ int buflen)
+{
+ struct ZlibInfo *comp = per_fd[fd];
+
+ if (StuffInput (&comp->inbuf, buffer, buflen) != buflen)
+ return 0;
+ return 1;
+}
+
+void
+ZlibCompressOn(int fd)
+{
+ per_fd[fd]->compress_off = FALSE;
+}
+
+void
+ZlibCompressOff(int fd)
+{
+ per_fd[fd]->compress_off = TRUE;
+}
+
+int
+ZlibWriteV(int fd,
+ struct iovec *iov,
+ int iovcnt)
+{
+ int i;
+ int total = 0;
+ int this_time;
+
+ for (i = 0; i < iovcnt; i++)
+ {
+ this_time = ZlibWrite(fd, (unsigned char *)iov[i].iov_base,
+ iov[i].iov_len);
+ if (this_time > 0)
+ total += this_time;
+ if (this_time != iov[i].iov_len)
+ {
+ if (total)
+ return total;
+ return this_time;
+ }
+ }
+ return total;
+}
+
+int
+ZlibWrite(int fd,
+ unsigned char *buffer,
+ int buflen)
+{
+ struct ZlibInfo *comp = per_fd[fd];
+ struct compress_private *priv = &comp->compress_state;
+ int len;
+ int lenleft = buflen;
+ unsigned char *p = buffer;
+
+ if (comp->compress_off) {
+ return PlainWrite(comp, buffer, buflen);
+ }
+
+ while (lenleft) {
+ if (priv->cp_in_count == 0) {
+ priv->cp_packet = (unsigned char *) ReserveOutBuf(&comp->outbuf,
+ ZLIB_PACKET_HDRLEN + ZLIB_MAX_OUTLEN);
+ if (!priv->cp_packet) {
+ errno = EWOULDBLOCK;
+ return -1;
+ }
+ priv->cp_outputbuf = priv->cp_packet + ZLIB_PACKET_HDRLEN;
+ priv->cp_outputbufend = priv->cp_outputbuf + ZLIB_MAX_OUTLEN;
+ }
+
+ len = MIN(ZLIB_MAX_PLAIN - priv->cp_in_count, lenleft);
+ stream_out_plain += len;
+
+ priv->cp_inputbuf = p;
+ priv->cp_inputbufend = p + len;
+ do_compress(priv, Z_NO_FLUSH);
+
+ p += len;
+ lenleft -= len;
+ if ((priv->cp_in_count += len) == ZLIB_MAX_PLAIN) {
+ if (ZlibFlush(fd) < 0) {
+ if (lenleft == buflen)
+ return -1;
+ return buflen - lenleft;
+ }
+ }
+ }
+
+ return buflen;
+}
+
+int
+ZlibRead(int fd,
+ unsigned char *buffer,
+ int buflen)
+{
+ struct ZlibInfo *comp = per_fd[fd];
+ struct compress_private *priv = &comp->decompress_state;
+ unsigned char *p = buffer;
+ int lenleft = buflen;
+ int len;
+ int retval = -1;
+
+ /*
+ * First check if there is any data Zlib decompressed already but
+ * didn't have output buffer space to store it in.
+ */
+
+ if (priv->need_flush_decompress)
+ {
+ priv->cp_outputbuf = p;
+ priv->cp_outputbufend = p + lenleft;
+
+ do_decompress (priv);
+
+ lenleft -= (priv->cp_outputbuf - p);
+ p = priv->cp_outputbuf;
+ }
+
+
+ /*
+ * Need to decompress some more data
+ */
+
+ priv->cp_outputbuf = p;
+ priv->cp_outputbufend = p + lenleft;
+ while (priv->cp_outputbuf != priv->cp_outputbufend) {
+ if (priv->cp_inputbuf == priv->cp_inputbufend) {
+ if ((retval = GetNewPacket(comp)) <= 0)
+ break;
+ priv->cp_inputbuf = priv->cp_packet + ZLIB_PACKET_HDRLEN;
+ priv->cp_inputbufend = priv->cp_inputbuf + retval;
+ if (ZLIB_COMPRESSED(priv->cp_packet))
+ stream_in_compressed += (retval + ZLIB_PACKET_HDRLEN);
+ else
+ stream_in_uncompressed += (retval + ZLIB_PACKET_HDRLEN);
+#ifdef LBXREQSTATS
+ stream_in_packet_header_bytes += ZLIB_PACKET_HDRLEN;
+#endif
+ }
+
+ if (ZLIB_COMPRESSED(priv->cp_packet))
+#ifdef LBXREQSTATS
+ if (LbxWhoAmI == 1) /* only support request stats for now */
+ do_decompress_with_stats(priv);
+ else
+#endif
+ do_decompress(priv);
+
+ else {
+ len = MIN(priv->cp_inputbufend - priv->cp_inputbuf,
+ priv->cp_outputbufend - priv->cp_outputbuf);
+ memmove(priv->cp_outputbuf, priv->cp_inputbuf, len);
+ priv->cp_inputbuf += len;
+ priv->cp_outputbuf += len;
+ }
+ }
+
+ if ((len = priv->cp_outputbuf - buffer) == 0)
+ return retval;
+ else {
+ stream_in_plain += len;
+ return len;
+ }
+}
+
+int
+ZlibInputAvail(int fd)
+{
+ struct ZlibInfo *comp = per_fd[fd];
+ struct compress_private *priv = &comp->decompress_state;
+
+ return (
+ priv->need_flush_decompress ||
+ priv->cp_inputbuf != priv->cp_inputbufend ||
+ NewPacketAvail(comp) > 0);
+}
diff --git a/nx-X11/lib/lbxutil/lbx_zlib/lbx_zlib.h b/nx-X11/lib/lbxutil/lbx_zlib/lbx_zlib.h
new file mode 100644
index 000000000..68b94f807
--- /dev/null
+++ b/nx-X11/lib/lbxutil/lbx_zlib/lbx_zlib.h
@@ -0,0 +1,136 @@
+/* $Xorg: lbx_zlib.h,v 1.4 2001/02/09 02:04:05 xorgcvs Exp $ */
+
+/*
+
+Copyright 1996 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 1988, 1989, 1990, 1994 Network Computing Devices, Inc.
+ *
+ * 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 Network Computing Devices, Inc. not be
+ * used in advertising or publicity pertaining to distribution of this
+ * software without specific, written prior permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
+ * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
+ * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
+ * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
+ * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
+ * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/lib/lbxutil/lbx_zlib/lbx_zlib.h,v 1.9 2001/08/27 19:01:07 dawes Exp $ */
+
+#include "zlib.h"
+#include <X11/Xfuncproto.h>
+
+struct compress_private {
+ z_stream stream;
+ char compress_inited;
+ char decompress_inited;
+ int z_err; /* error code for last stream operation */
+ unsigned char *cp_inputbuf;
+ unsigned char *cp_inputbufend;
+ unsigned char *cp_outputbuf;
+ unsigned char *cp_outputbufend;
+ unsigned char *cp_packet;
+ int cp_outputcount;
+ long int cp_in_count; /* length of input */
+ long int cp_bytes_out; /* length of compressed output */
+ int need_flush_decompress;
+#ifdef LBXREQSTATS
+ int x_req_code;
+ int lbx_req_code;
+ int x_header_bytes_read;
+ char x_header_buf[4];
+ int req_length;
+ int req_compbytes_read;
+ int req_uncompbytes_read;
+#endif
+};
+
+#ifndef MIN
+#define MIN(_a, _b) ( ((_a) < (_b)) ? (_a) : (_b))
+#endif
+
+
+/*
+ * The following is taken from the xtrans code, it would be nice to share it
+ */
+#if defined(WIN32) || (defined(USG) && !defined(CRAY) && !defined(umips) && !defined(MOTOROLA) && !defined(uniosu) && !defined(__sxg__))
+
+struct iovec {
+ caddr_t iov_base;
+ int iov_len;
+};
+
+#else
+#ifndef Lynx
+#include <sys/uio.h>
+#else
+#include <uio.h>
+#endif
+#endif
+
+#ifdef WIN32
+#define BOOL wBOOL
+#undef Status
+#define Status wStatus
+#include <winsock.h>
+#undef Status
+#define Status int
+#undef BOOL
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#endif
+
+
+/* lbx_zlib_io.c */
+extern int GetInputPtr ( int fd, ZlibBufferPtr inbuf, int reqlen,
+ unsigned char **ppkt );
+extern int StuffInput ( ZlibBufferPtr inbuf, unsigned char *pkt, int reqlen );
+extern void FreeInput ( ZlibBufferPtr inbuf, int len );
+extern void CommitOutBuf ( ZlibBufferPtr outbuf, int outlen );
+extern int FlushOutBuf ( int fd, ZlibBufferPtr outbuf );
+extern int FlushIovBuf ( int fd, struct iovec *iovbuf );
+
+/* Copied from xc/programs/Xserver/include/xorg/os.h */
+#ifndef _HAVE_XALLOC_DECLS
+#define _HAVE_XALLOC_DECLS
+#include <X11/Xdefs.h>
+
+extern pointer Xalloc(unsigned long /*amount*/);
+extern pointer Xcalloc(unsigned long /*amount*/);
+extern pointer Xrealloc(pointer /*ptr*/, unsigned long /*amount*/);
+extern void Xfree(pointer /*ptr*/);
+#endif
diff --git a/nx-X11/lib/lbxutil/lbx_zlib/lbx_zlib_io.c b/nx-X11/lib/lbxutil/lbx_zlib/lbx_zlib_io.c
new file mode 100644
index 000000000..12b29a310
--- /dev/null
+++ b/nx-X11/lib/lbxutil/lbx_zlib/lbx_zlib_io.c
@@ -0,0 +1,275 @@
+/* $Xorg: lbx_zlib_io.c,v 1.3 2000/08/17 19:46:41 cpqbld Exp $ */
+
+/*
+ * Copyright 1993 Network Computing Devices
+ *
+ * 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 of NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * 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.
+ *
+ * Author: Dale Tonogai, Network Computing Devices
+ */
+/* $XFree86: xc/lib/lbxutil/lbx_zlib/lbx_zlib_io.c,v 1.11 2001/01/17 19:43:36 dawes Exp $ */
+
+#ifdef WIN32
+#define _WILLWINSOCK_
+#endif
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+#include <errno.h>
+#if !defined(WIN32) && !defined(Lynx)
+#include <sys/param.h>
+#endif
+#include <X11/extensions/lbxbufstr.h>
+#include "lbx_zlib.h"
+
+#include <stddef.h>
+
+
+/*
+ * The following is taken from the xtrans code, almost as is,
+ * it would be nice to share it...
+ */
+#if defined(WIN32) || defined(__sxg__)
+static int
+writev(int fildes, const struct iovec *iov, int iovcnt)
+{
+ int i, len, total;
+ char *base;
+
+ ESET(0);
+ for (i = 0, total = 0; i < iovcnt; i++, iov++) {
+ len = iov->iov_len;
+ base = iov->iov_base;
+ while (len > 0) {
+ register int nbytes;
+ nbytes = write(fildes, base, len);
+ if (nbytes < 0 && total == 0) return -1;
+ if (nbytes <= 0) return total;
+ ESET(0);
+ len -= nbytes;
+ total += nbytes;
+ base += nbytes;
+ }
+ }
+ return total;
+}
+#endif
+
+int
+InitZlibBuffer(b, size)
+ ZlibBufferPtr b;
+ int size;
+{
+ if ((b->bufbase = (char *)Xalloc(size)) == NULL)
+ return -1;
+ b->bufend = b->bufbase + size;
+ b->bufptr = b->bufbase;
+ b->bufcnt = 0;
+ return 0;
+}
+
+void
+FreeZlibBuffer(b)
+ ZlibBufferPtr b;
+{
+ if (b->bufbase) {
+ Xfree(b->bufbase);
+ b->bufbase = NULL;
+ }
+}
+
+/*
+ * Returns:
+ * 1 if desired amount of data available in input buffer
+ * 0 if eof
+ * -1 if error
+ */
+int
+GetInputPtr(fd, inbuf, reqlen, ppkt)
+ int fd;
+ ZlibBufferPtr inbuf;
+ int reqlen;
+ unsigned char **ppkt;
+{
+ int readbytes;
+ int gotbytes;
+
+ if (inbuf->bufcnt == 0)
+ inbuf->bufptr = inbuf->bufbase;
+
+ if (reqlen <= inbuf->bufcnt) {
+ *ppkt = (unsigned char *)inbuf->bufptr;
+ return 1;
+ }
+
+ if (reqlen > inbuf->bufend - inbuf->bufptr) {
+ memmove(inbuf->bufbase, inbuf->bufptr, inbuf->bufcnt);
+ inbuf->bufptr = inbuf->bufbase;
+ }
+ readbytes = (inbuf->bufend - inbuf->bufptr) - inbuf->bufcnt;
+ gotbytes = read(fd, inbuf->bufptr + inbuf->bufcnt, readbytes);
+ if (gotbytes > 0) {
+ if (reqlen <= (inbuf->bufcnt += gotbytes)) {
+ *ppkt = (unsigned char *)inbuf->bufptr;
+ return 1;
+ }
+ }
+ else
+ return gotbytes;
+
+ errno = EWOULDBLOCK;
+ return -1;
+}
+
+/*
+ * When ZLIB is started, we may well have read some data off of the
+ * wire somewhere. This sticks those bytes ahead of anything we might
+ * read in the future
+ */
+
+int
+StuffInput(inbuf, pkt, reqlen)
+ ZlibBufferPtr inbuf;
+ unsigned char *pkt;
+ int reqlen;
+{
+ int readbytes;
+ char *last;
+
+ last = inbuf->bufptr + inbuf->bufcnt;
+ if (reqlen > inbuf->bufend - last)
+ {
+ memmove(inbuf->bufbase, inbuf->bufptr, inbuf->bufcnt);
+ inbuf->bufptr = inbuf->bufbase;
+ last = inbuf->bufptr + inbuf->bufcnt;
+ }
+ readbytes = MIN(reqlen, inbuf->bufend - last);
+ memmove(last, pkt, readbytes);
+ inbuf->bufcnt += readbytes;
+ return readbytes;
+}
+
+void
+FreeInput(inbuf, len)
+ ZlibBufferPtr inbuf;
+ int len;
+{
+ inbuf->bufptr += len;
+ if ((inbuf->bufcnt -= len) == 0)
+ inbuf->bufptr = inbuf->bufbase;
+}
+
+/*
+ * Reserve outlen bytes in the output buffer.
+ */
+char *
+ReserveOutBuf(outbuf, outlen)
+ ZlibBufferPtr outbuf;
+ int outlen;
+{
+ int left;
+
+ left = (outbuf->bufend - outbuf->bufptr) - outbuf->bufcnt;
+ if (left < outlen)
+ return NULL;
+ else
+ return outbuf->bufptr + outbuf->bufcnt;
+}
+
+/*
+ * Commit previously reserved space as real output
+ */
+void
+CommitOutBuf(outbuf, outlen)
+ ZlibBufferPtr outbuf;
+ int outlen;
+{
+ outbuf->bufcnt += outlen;
+}
+
+/*
+ * Write out as much as possible from the output buffer.
+ * Returns: >= 0 - amount left in buffer
+ * < 0 - write error
+ */
+int
+FlushOutBuf(fd, outbuf)
+ int fd;
+ ZlibBufferPtr outbuf;
+{
+ int bytes;
+
+ if (outbuf->bufcnt == 0)
+ return 0;
+ bytes = write(fd, outbuf->bufptr, outbuf->bufcnt);
+ if (bytes > 0) {
+ outbuf->bufptr += bytes;
+ if ((outbuf->bufcnt -= bytes) == 0)
+ outbuf->bufptr = outbuf->bufbase;
+ return outbuf->bufcnt;
+ }
+ else if (bytes == 0) {
+ errno = EWOULDBLOCK;
+ bytes = -1;
+ }
+ return bytes;
+}
+
+/*
+ * Write out as much as possible from the iovec array (no more than
+ * two entries allowed).
+ * Returns: >= 0 - amount left in iovec[1]
+ * < 0 - write error
+ */
+int
+FlushIovBuf(fd, iovbuf)
+ int fd;
+ struct iovec *iovbuf;
+{
+ int bytes;
+ int niov = 2;
+ struct iovec *iov = iovbuf;
+
+ if (iov[0].iov_len == 0) {
+ ++iov;
+ --niov;
+ }
+ bytes = writev(fd, iov, niov);
+ if (bytes > 0) {
+ int i;
+ int len;
+ for (i = 0; i < niov; i++) {
+ len = MIN(bytes, iov[i].iov_len);
+ iov[i].iov_len -= len;
+ /*
+ * An explicit cast is necessary because silly SGI changed
+ * iov_base from a caddr_t to a void* in IRIX 6.x, and strictly
+ * speaking ANSI/ISO C doesn't allow the use of a cast in an
+ * lvalue, i.e. such as: '((char*)(iov[i].iov_base)) += len;'
+ */
+ iov[i].iov_base = ((char*)(iov[i].iov_base)) + len;
+ if ((bytes -= len) == 0)
+ break;
+ }
+ return iovbuf[1].iov_len;
+ }
+ else if (bytes == 0) {
+ errno = EWOULDBLOCK;
+ bytes = -1;
+ }
+ return bytes;
+}
diff --git a/nx-X11/lib/lbxutil/lbx_zlib/reqstats.c b/nx-X11/lib/lbxutil/lbx_zlib/reqstats.c
new file mode 100644
index 000000000..50545b8f6
--- /dev/null
+++ b/nx-X11/lib/lbxutil/lbx_zlib/reqstats.c
@@ -0,0 +1,503 @@
+/* $Xorg: reqstats.c,v 1.4 2001/02/09 02:04:05 xorgcvs Exp $ */
+
+/*
+
+Copyright 1996 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/lbxutil/lbx_zlib/reqstats.c,v 1.5 2001/08/27 19:01:07 dawes Exp $ */
+
+#include "reqstats.h"
+
+#ifdef LBXREQSTATS
+
+#include <X11/Xfuncs.h>
+#include <X11/Xproto.h>
+#define _XLBX_SERVER_
+#include "XLbx.h"
+#include "lbx_zlib.h"
+#include <signal.h>
+#include <stdio.h>
+
+#define LBX_CODE 136 /* XXX - this should not be hardcoded - on todo list */
+
+extern unsigned long stream_in_compressed;
+extern unsigned long stream_in_plain;
+extern unsigned long stream_in_packet_header_bytes;
+extern unsigned long stream_in_uncompressed_bytes;
+
+unsigned long check_sum_in_compressed;
+unsigned long check_sum_in_plain;
+int unknown_extension_bytes = 0;
+
+struct ReqStats CoreRequestStats[128];
+struct ReqStats LbxRequestStats[LbxNumberReqs];
+
+static void LbxPrintReqStats (int);
+
+char *X_ReqNames[128] = {
+ 0, /* 0 */
+ "CreateWindow", /* 1 */
+ "ChangeWindowAttributes", /* 2 */
+ "GetWindowAttributes", /* 3 */
+ "DestroyWindow", /* 4 */
+ "DestroySubwindows", /* 5 */
+ "ChangeSaveSet", /* 6 */
+ "ReparentWindow", /* 7 */
+ "MapWindow", /* 8 */
+ "MapSubwindows", /* 9 */
+ "UnmapWindow", /* 10 */
+ "UnmapSubwindows", /* 11 */
+ "ConfigureWindow", /* 12 */
+ "CirculateWindow", /* 13 */
+ "GetGeometry", /* 14 */
+ "QueryTree", /* 15 */
+ "InternAtom", /* 16 */
+ "GetAtomName", /* 17 */
+ "ChangeProperty", /* 18 */
+ "DeleteProperty", /* 19 */
+ "GetProperty", /* 20 */
+ "ListProperties", /* 21 */
+ "SetSelectionOwner", /* 22 */
+ "GetSelectionOwner", /* 23 */
+ "ConvertSelection", /* 24 */
+ "SendEvent", /* 25 */
+ "GrabPointer", /* 26 */
+ "UngrabPointer", /* 27 */
+ "GrabButton", /* 28 */
+ "UngrabButton", /* 29 */
+ "ChangeActivePointerGrab", /* 30 */
+ "GrabKeyboard", /* 31 */
+ "UngrabKeyboard", /* 32 */
+ "GrabKey", /* 33 */
+ "UngrabKey", /* 34 */
+ "AllowEvents", /* 35 */
+ "GrabServer", /* 36 */
+ "UngrabServer", /* 37 */
+ "QueryPointer", /* 38 */
+ "GetMotionEvents", /* 39 */
+ "TranslateCoords", /* 40 */
+ "WarpPointer", /* 41 */
+ "SetInputFocus", /* 42 */
+ "GetInputFocus", /* 43 */
+ "QueryKeymap", /* 44 */
+ "OpenFont", /* 45 */
+ "CloseFont", /* 46 */
+ "QueryFont", /* 47 */
+ "QueryTextExtents", /* 48 */
+ "ListFonts", /* 49 */
+ "ListFontsWithInfo", /* 50 */
+ "SetFontPath", /* 51 */
+ "GetFontPath", /* 52 */
+ "CreatePixmap", /* 53 */
+ "FreePixmap", /* 54 */
+ "CreateGC", /* 55 */
+ "ChangeGC", /* 56 */
+ "CopyGC", /* 57 */
+ "SetDashes", /* 58 */
+ "SetClipRectangles", /* 59 */
+ "FreeGC", /* 60 */
+ "ClearArea", /* 61 */
+ "CopyArea", /* 62 */
+ "CopyPlane", /* 63 */
+ "PolyPoint", /* 64 */
+ "PolyLine", /* 65 */
+ "PolySegment", /* 66 */
+ "PolyRectangle", /* 67 */
+ "PolyArc", /* 68 */
+ "FillPoly", /* 69 */
+ "PolyFillRectangle", /* 70 */
+ "PolyFillArc", /* 71 */
+ "PutImage", /* 72 */
+ "GetImage", /* 73 */
+ "PolyText8", /* 74 */
+ "PolyText16", /* 75 */
+ "ImageText8", /* 76 */
+ "ImageText16", /* 77 */
+ "CreateColormap", /* 78 */
+ "FreeColormap", /* 79 */
+ "CopyColormapAndFree", /* 80 */
+ "InstallColormap", /* 81 */
+ "UninstallColormap", /* 82 */
+ "ListInstalledColormaps", /* 83 */
+ "AllocColor", /* 84 */
+ "AllocNamedColor", /* 85 */
+ "AllocColorCells", /* 86 */
+ "AllocColorPlanes", /* 87 */
+ "FreeColors", /* 88 */
+ "StoreColors", /* 89 */
+ "StoreNamedColor", /* 90 */
+ "QueryColors", /* 91 */
+ "LookupColor", /* 92 */
+ "CreateCursor", /* 93 */
+ "CreateGlyphCursor", /* 94 */
+ "FreeCursor", /* 95 */
+ "RecolorCursor", /* 96 */
+ "QueryBestSize", /* 97 */
+ "QueryExtension", /* 98 */
+ "ListExtensions", /* 99 */
+ "ChangeKeyboardMapping", /* 100 */
+ "GetKeyboardMapping", /* 101 */
+ "ChangeKeyboardControl", /* 102 */
+ "GetKeyboardControl", /* 103 */
+ "Bell", /* 104 */
+ "ChangePointerControl", /* 105 */
+ "GetPointerControl", /* 106 */
+ "SetScreenSaver", /* 107 */
+ "GetScreenSaver", /* 108 */
+ "ChangeHosts", /* 109 */
+ "ListHosts", /* 110 */
+ "SetAccessControl", /* 111 */
+ "SetCloseDownMode", /* 112 */
+ "KillClient", /* 113 */
+ "RotateProperties", /* 114 */
+ "ForceScreenSaver", /* 115 */
+ "SetPointerMapping", /* 116 */
+ "GetPointerMapping", /* 117 */
+ "SetModifierMapping", /* 118 */
+ "GetModifierMapping", /* 119 */
+ 0, /* 120 */
+ 0, /* 121 */
+ 0, /* 122 */
+ 0, /* 123 */
+ 0, /* 124 */
+ 0, /* 125 */
+ 0, /* 126 */
+ "NoOperation" /* 127 */
+};
+
+
+char *LBX_ReqNames[LbxNumberReqs] = {
+
+ "LbxQueryVersion", /* 0 */
+ "LbxStartProxy", /* 1 */
+ "LbxStopProxy", /* 2 */
+ "LbxSwitch", /* 3 */
+ "LbxNewClient", /* 4 */
+ "LbxCloseClient", /* 5 */
+ "LbxModifySequence", /* 6 */
+ "LbxAllowMotion", /* 7 */
+ "LbxIncrementPixel", /* 8 */
+ "LbxDelta", /* 9 */
+ "LbxGetModifierMapping", /* 10 */
+ "LbxQueryTag", /* 11 */
+ "LbxInvalidateTag", /* 12 */
+ "LbxPolyPoint", /* 13 */
+ "LbxPolyLine", /* 14 */
+ "LbxPolySegment", /* 15 */
+ "LbxPolyRectangle", /* 16 */
+ "LbxPolyArc", /* 17 */
+ "LbxFillPoly", /* 18 */
+ "LbxPolyFillRectangle", /* 19 */
+ "LbxPolyFillArc", /* 20 */
+ "LbxGetKeyboardMapping", /* 21 */
+ "LbxQueryFont", /* 22 */
+ "LbxChangeProperty", /* 23 */
+ "LbxGetProperty", /* 24 */
+ "LbxTagData", /* 25 */
+ "LbxCopyArea", /* 26 */
+ "LbxCopyPlane", /* 27 */
+ "LbxPolyText8", /* 28 */
+ "LbxPolyText16", /* 29 */
+ "LbxImageText8", /* 30 */
+ "LbxImageText16", /* 31 */
+ "LbxQueryExtension", /* 32 */
+ "LbxPutImage", /* 33 */
+ "LbxGetImage", /* 34 */
+ "LbxBeginLargeRequest", /* 35 */
+ "LbxLargeRequestData", /* 36 */
+ "LbxEndLargeRequest" /* 37 */
+};
+
+
+
+void
+InitLbxReqStats (void)
+
+{
+ bzero (CoreRequestStats, 128 * sizeof (struct ReqStats));
+ bzero (LbxRequestStats, LbxNumberReqs * sizeof (struct ReqStats));
+
+ signal (SIGUSR1, LbxPrintReqStats);
+}
+
+
+static void
+PrintStatsTable (struct ReqStats *table,
+ int count,
+ char **reqNames)
+
+{
+ int i;
+
+ fprintf (stderr, "U = uncompressed bytes\n");
+ fprintf (stderr, "C = compressed bytes\n");
+ fprintf (stderr, "%%C = percent compression\n");
+ fprintf (stderr, "%%T = percent of total bytes in stream\n");
+ fprintf (stderr, "\n");
+ fprintf (stderr, "%-25s\tCount\tU\tC\t%%C\t\t%%T\n", "Request");
+ fprintf (stderr, "-------------------------------------------------------------------------------\n");
+
+ for (i = 0; i < count; i++)
+ {
+ float compRatio, percentTot;
+
+ if (table[i].uncomp_bytes == 0)
+ compRatio = 0.0;
+ else
+ compRatio = 100.0 * (1.0 - ((float) table[i].comp_bytes /
+ (float) table[i].uncomp_bytes));
+
+ if (stream_in_compressed - stream_in_packet_header_bytes == 0)
+ percentTot = 0.0;
+ else
+ percentTot = 100.0 * (float) table[i].comp_bytes /
+ (float) (stream_in_compressed -
+ stream_in_packet_header_bytes);
+
+ if (reqNames[i])
+ fprintf (stderr, "%-25s\t%d\t%d\t%d\t%.3f\t\t%.3f\n",
+ reqNames[i],
+ table[i].count,
+ table[i].uncomp_bytes,
+ table[i].comp_bytes,
+ compRatio,
+ percentTot);
+
+ check_sum_in_plain += table[i].uncomp_bytes;
+ check_sum_in_compressed += table[i].comp_bytes;
+ }
+}
+
+static void
+PrintDeltaStats (struct ReqStats *table,
+ int count,
+ char **reqNames)
+
+{
+ int i;
+
+ for (i = 0; i < count; i++)
+ {
+ if (table[i].delta_count && reqNames[i])
+ fprintf (stderr, "%-25s\t%d\t%d\t%d\n",
+ reqNames[i],
+ table[i].delta_count,
+ table[i].pre_delta_bytes,
+ table[i].post_delta_bytes);
+ }
+}
+
+
+static void
+LbxPrintReqStats (int dummy)
+
+{
+ unsigned long total;
+
+ check_sum_in_plain = 0;
+ check_sum_in_compressed = 0;
+
+ fprintf (stderr, "\n\n");
+ fprintf (stderr, "Core X requests\n\n");
+ PrintStatsTable (CoreRequestStats, 128, X_ReqNames);
+
+ fprintf (stderr, "\n\n");
+ fprintf (stderr, "LBX requests\n\n");
+ PrintStatsTable (LbxRequestStats, LbxNumberReqs, LBX_ReqNames);
+
+ fprintf (stderr, "\n\n\n");
+
+ fprintf (stderr, "The following requests were delta compressed:\n");
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Pre = pre delta bytes\n");
+ fprintf (stderr, "Post = post delta bytes\n");
+ fprintf (stderr, "\n");
+ fprintf (stderr, "%-25s\tCount\tPre\tPost\n", "Request");
+ fprintf (stderr, "-------------------------------------------------------------------------------\n");
+ PrintDeltaStats (CoreRequestStats, 128, X_ReqNames);
+ PrintDeltaStats (LbxRequestStats, LbxNumberReqs, LBX_ReqNames);
+
+ fprintf (stderr, "\n\n\n");
+
+ fprintf (stderr, "overall stream compression = %f %%\n",
+ (check_sum_in_plain == 0) ? 0.0 :
+ (100.0 * (1.0 - ((float) check_sum_in_compressed /
+ (float) check_sum_in_plain))));
+
+ fprintf (stderr, "\n\n\n");
+
+ total = check_sum_in_plain + unknown_extension_bytes +
+ stream_in_uncompressed_bytes;
+
+ if (total == stream_in_plain)
+ fprintf (stderr, "Internal checksum succeeded!!!\n");
+ else
+ {
+ fprintf (stderr, "Internal checksum failed!!!\n");
+ fprintf (stderr, "actual checksum = %d\n", stream_in_plain);
+ fprintf (stderr, "computed checksum = %d\n", total);
+ }
+
+ fprintf (stderr, "\n\n");
+}
+
+
+void
+do_decompress_with_stats (struct compress_private *priv)
+
+{
+ int incount = priv->cp_inputbufend - priv->cp_inputbuf;
+
+ priv->stream.next_in = priv->cp_inputbuf;
+ priv->stream.next_out = priv->cp_outputbuf;
+ priv->stream.avail_out = priv->cp_outputbufend - priv->cp_outputbuf;
+
+ while (incount > 0)
+ {
+ char *save_out = (char *) priv->stream.next_out;
+ int outcount, outconsumed;
+
+ priv->stream.avail_in = 1;
+ priv->z_err = inflate (&(priv->stream), Z_NO_FLUSH);
+
+ priv->need_flush_decompress = (priv->stream.avail_out == 0 );
+
+ priv->req_compbytes_read++;
+
+ outcount = (char *) priv->stream.next_out - save_out;
+
+ priv->req_uncompbytes_read += outcount;
+
+ while (outcount > 0)
+ {
+ if (priv->req_length == -1 && priv->x_header_bytes_read < 4)
+ {
+ int have = MIN (outcount, (4 - priv->x_header_bytes_read));
+ memcpy (priv->x_header_buf + priv->x_header_bytes_read,
+ save_out, have);
+ priv->x_header_bytes_read += have;
+
+ if (priv->x_header_bytes_read < 4 && ((outcount - have) == 0))
+ break;
+ }
+
+ if (priv->req_length == -1 && priv->x_header_bytes_read == 4)
+ {
+ xReq *req = (xReq *) priv->x_header_buf;
+
+ priv->req_length = req->length << 2;
+ priv->x_req_code = req->reqType;
+
+ if (priv->x_req_code == LBX_CODE)
+ priv->lbx_req_code = req->data;
+ }
+
+ if (priv->req_length != -1)
+ {
+ if (priv->req_uncompbytes_read < priv->req_length)
+ break;
+ else
+ {
+ if (priv->x_req_code == LBX_CODE)
+ {
+ struct ReqStats *reqStat =
+ &LbxRequestStats[priv->lbx_req_code];
+
+ reqStat->count++;
+ reqStat->comp_bytes += priv->req_compbytes_read;
+ reqStat->uncomp_bytes += priv->req_length;
+
+#ifdef LBXREQLOG
+ fprintf (stderr,
+ "LBX opcode = %d, real len = %d, comp len = %d\n",
+ priv->lbx_req_code, priv->req_length,
+ priv->req_compbytes_read);
+#endif
+ }
+ else if (priv->x_req_code < 128)
+ {
+ struct ReqStats *reqStat =
+ &CoreRequestStats[priv->x_req_code];
+
+ reqStat->count++;
+ reqStat->comp_bytes += priv->req_compbytes_read;
+ reqStat->uncomp_bytes += priv->req_length;
+
+#ifdef LBXREQLOG
+ fprintf (stderr,
+ "X opcode = %d, real len = %d, comp len = %d\n",
+ priv->x_req_code, priv->req_length,
+ priv->req_compbytes_read);
+#endif
+ }
+ else
+ {
+#ifdef LBXREQLOG
+ fprintf (stderr,
+ "Unknown opcode = %d, real len = %d, comp len = %d\n",
+ priv->x_req_code, priv->req_length,
+ priv->req_compbytes_read);
+#endif
+ unknown_extension_bytes += priv->req_length;
+ }
+
+ priv->req_uncompbytes_read -= priv->req_length;
+
+ if (priv->req_uncompbytes_read > 0)
+ {
+ priv->req_compbytes_read = 1;
+ save_out += (outcount - priv->req_uncompbytes_read);
+ outcount = priv->req_uncompbytes_read;
+ }
+ else
+ {
+ priv->req_compbytes_read = 0;
+ outcount = 0;
+ }
+
+ priv->req_length = -1;
+ priv->x_header_bytes_read = 0;
+ }
+ }
+ }
+
+ incount--;
+
+ if (priv->stream.avail_out == 0)
+ break;
+ }
+
+ priv->cp_inputbuf = priv->stream.next_in;
+ priv->cp_outputbuf = priv->stream.next_out;
+}
+
+#else
+
+void
+InitLbxReqStats()
+{}
+
+#endif /* LBXREQSTATS */
diff --git a/nx-X11/lib/lbxutil/lbx_zlib/reqstats.h b/nx-X11/lib/lbxutil/lbx_zlib/reqstats.h
new file mode 100644
index 000000000..eab64e94e
--- /dev/null
+++ b/nx-X11/lib/lbxutil/lbx_zlib/reqstats.h
@@ -0,0 +1,43 @@
+/* $Xorg: reqstats.h,v 1.4 2001/02/09 02:04:05 xorgcvs Exp $ */
+
+/*
+
+Copyright 1996 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/lbxutil/lbx_zlib/reqstats.h,v 1.2 2001/08/27 19:01:07 dawes Exp $ */
+
+#ifdef LBXREQSTATS
+struct ReqStats {
+ int count;
+ unsigned long comp_bytes;
+ unsigned long uncomp_bytes;
+ int delta_count;
+ unsigned long pre_delta_bytes;
+ unsigned long post_delta_bytes;
+};
+#endif
+
+extern void InitLbxReqStats(void);
diff --git a/nx-X11/lib/misc/snprintf.c b/nx-X11/lib/misc/snprintf.c
new file mode 100644
index 000000000..6e9e2816f
--- /dev/null
+++ b/nx-X11/lib/misc/snprintf.c
@@ -0,0 +1,714 @@
+/*
+ * This version of snprintf() and vsnprintf() is based on Sprint from
+ * SIO by Panagiotis Tsirigotis, as included with xidentd-2.2.1.
+ *
+ * The modifications were made by The XFree86 Project, Inc and are
+ * Copyright 1999 by The XFree86 Project, Inc. These modifications
+ * consist of removing the support for writing to file streams,
+ * renaming some functions, ansification, and making some adjustments
+ * to achieve the semantics for snprintf and vsnprintf() as described
+ * in the relevant man page for FreeBSD 2.2.8.
+ *
+ *
+ * The original version carries the following notice:
+ *
+ * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
+ *
+ * The author (Panagiotis Tsirigotis) grants permission to use, copy,
+ * and distribute this software and its documentation for any purpose
+ * and without fee, provided that a) the above copyright notice extant in
+ * files in this distribution is not removed from files included in any
+ * redistribution, and b) this file is also included in any redistribution.
+ *
+ * Modifications to this software may be distributed, either by distributing
+ * the modified software or by distributing patches to the original software,
+ * under the following additional terms:
+ *
+ * 1. The version number will be modified as follows:
+ * a. The first 3 components of the version number
+ * (i.e. <number>.<number>.<number>) will remain unchanged.
+ * b. A new component will be appended to the version number to indicate
+ * the modification level. The form of this component is up to the
+ * author of the modifications.
+ *
+ * 2. The author of the modifications will include his/her name by appending
+ * it along with the new version number to this file and will be
+ * responsible for any wrong behavior of the modified software.
+ *
+ * The author makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without any express
+ * or implied warranty.
+ *
+ * Changes and modifications for:
+ *
+ * xinetd Version 2.1.4-bsdi
+ * xinetd Version 2.1.4-freebsd
+ * xinetd Version 2.1.4-linux
+ *
+ * are
+ *
+ * (c) Copyright 1995 by Charles Murcko
+ * All Rights Reserved
+ */
+
+/* $XFree86$ */
+
+
+/*
+ * Assumption: systems that don't have snprintf and vsnprintf do have
+ * ecvt, fcvt and gcvt.
+ */
+
+/* From: Id: sprint.c,v 1.5 1995/09/10 18:35:09 chuck Exp */
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <sys/types.h>
+
+#ifndef SCOPE
+#define SCOPE /**/
+#endif
+
+#ifndef WIDE_INT
+#define WIDE_INT long
+#endif
+
+typedef WIDE_INT wide_int;
+typedef unsigned WIDE_INT u_wide_int;
+typedef int bool_int;
+
+#ifndef FALSE
+#define FALSE 0
+#define TRUE 1
+#endif
+
+#define NUL '\0'
+
+#define S_NULL "(null)"
+#define S_NULL_LEN 6
+
+#define FLOAT_DIGITS 6
+#define EXPONENT_LENGTH 10
+
+typedef enum { NO = 0, YES = 1 } boolean_e ;
+
+/*
+ * NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions
+ *
+ * XXX: this is a magic number; do not decrease it
+ */
+#define NUM_BUF_SIZE 512
+
+/*
+ * The INS_CHAR macro inserts a character in the buffer.
+ * It uses the char pointers sp and bep:
+ * sp points to the next available character in the buffer
+ * bep points to the end-of-buffer
+ * While using this macro, note that the nextb pointer is NOT updated.
+ *
+ * Excess characters are discarded if the string overflows.
+ *
+ * NOTE: Evaluation of the c argument should not have any side-effects
+ */
+#define INS_CHAR( c, sp, bep, cc ) \
+ { \
+ if ( sp != NULL && sp < bep ) \
+ *sp++ = c ; \
+ cc++ ; \
+ }
+
+#define NUM( c ) ( c - '0' )
+
+#define STR_TO_DEC( str, num ) \
+ num = NUM( *str++ ) ; \
+ while ( isdigit( *str ) ) { \
+ num *= 10 ; \
+ num += NUM( *str++ ) ; \
+ }
+
+/*
+ * This macro does zero padding so that the precision
+ * requirement is satisfied. The padding is done by
+ * adding '0's to the left of the string that is going
+ * to be printed.
+ */
+#define FIX_PRECISION( adjust, precision, s, s_len ) \
+ if ( adjust ) \
+ while ( s_len < precision ) { \
+ *--s = '0' ; \
+ s_len++ ; \
+ }
+
+/*
+ * Macro that does padding. The padding is done by printing
+ * the character ch.
+ */
+#define PAD( width, len, ch ) \
+ do { \
+ INS_CHAR( ch, sp, bep, cc ) ; \
+ width-- ; \
+ } while ( width > len )
+
+/*
+ * Prefix the character ch to the string str
+ * Increase length
+ * Set the has_prefix flag
+ */
+#define PREFIX( str, length, ch ) \
+ *--str = ch ; length++ ; has_prefix = YES
+
+static char *conv_10(wide_int num, bool_int is_unsigned,
+ bool_int * is_negative, char *buf_end, int *len);
+SCOPE int vsnprintf(char *str, size_t size, const char *fmt, va_list ap);
+
+/*
+ * snprintf is based on SIO's Sprint.
+ *
+ * Sprint is the equivalent of printf for SIO.
+ * It returns the # of chars written
+ * Assumptions:
+ * - all floating point arguments are passed as doubles
+ */
+SCOPE int
+snprintf(char *str, size_t size, const char *fmt, ...)
+{
+ int cc;
+ va_list ap;
+
+ va_start(ap, fmt);
+ cc = vsnprintf(str, size, fmt, ap);
+ va_end(ap);
+ return cc;
+}
+
+/*
+ * Convert a floating point number to a string formats 'f', 'e' or 'E'.
+ * The result is placed in buf, and len denotes the length of the string
+ * The sign is returned in the is_negative argument (and is not placed
+ * in buf). Always add decimal point if add_dp is YES.
+ */
+static char *
+conv_fp(char format, double num, boolean_e add_dp, int precision,
+ bool_int *is_negative, char buf[], int *len)
+{
+ char *s = buf;
+ char *p;
+ int decimal_point;
+
+ if (format == 'f')
+ p = fcvt(num, precision, &decimal_point, is_negative);
+ else /* either e or E format */
+ p = ecvt(num, precision + 1, &decimal_point, is_negative);
+
+ /*
+ * Check for Infinity and NaN
+ */
+ if (isalpha(*p)) {
+ *len = strlen(strcpy(buf, p));
+ *is_negative = FALSE;
+ return (buf);
+ }
+ if (format == 'f')
+ if (decimal_point <= 0) {
+ *s++ = '0';
+ if (precision > 0) {
+ *s++ = '.';
+ while (decimal_point++ < 0)
+ *s++ = '0';
+ } else if (add_dp)
+ *s++ = '.';
+ } else {
+ while (decimal_point-- > 0)
+ *s++ = *p++;
+ if (precision > 0 || add_dp)
+ *s++ = '.';
+ } else {
+ *s++ = *p++;
+ if (precision > 0 || add_dp)
+ *s++ = '.';
+ }
+
+ /*
+ * copy the rest of p, the NUL is NOT copied
+ */
+ while (*p)
+ *s++ = *p++;
+
+ if (format != 'f') {
+ char temp[EXPONENT_LENGTH]; /* for exponent conversion */
+ int t_len;
+ bool_int exponent_is_negative;
+
+ *s++ = format; /* either e or E */
+ decimal_point--;
+ if (decimal_point != 0) {
+ p = conv_10((wide_int) decimal_point, FALSE, &exponent_is_negative,
+ &temp[EXPONENT_LENGTH], &t_len);
+ *s++ = exponent_is_negative ? '-' : '+';
+
+ /*
+ * Make sure the exponent has at least 2 digits
+ */
+ if (t_len == 1)
+ *s++ = '0';
+ while (t_len--)
+ *s++ = *p++;
+ } else {
+ *s++ = '+';
+ *s++ = '0';
+ *s++ = '0';
+ }
+ }
+ *len = s - buf;
+ return (buf);
+}
+
+/*
+ * Convert num to a base X number where X is a power of 2. nbits determines X.
+ * For example, if nbits is 3, we do base 8 conversion
+ * Return value:
+ * a pointer to a string containing the number
+ *
+ * The caller provides a buffer for the string: that is the buf_end argument
+ * which is a pointer to the END of the buffer + 1 (i.e. if the buffer
+ * is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
+ */
+static char *
+conv_p2(u_wide_int num, int nbits, char format, char *buf_end, int *len)
+{
+ int mask = (1 << nbits) - 1;
+ char *p = buf_end;
+ static char low_digits[] = "0123456789abcdef";
+ static char upper_digits[] = "0123456789ABCDEF";
+ char *digits = (format == 'X') ? upper_digits : low_digits;
+
+ do {
+ *--p = digits[num & mask];
+ num >>= nbits;
+ }
+ while (num);
+
+ *len = buf_end - p;
+ return (p);
+}
+
+/*
+ * Convert num to its decimal format.
+ * Return value:
+ * - a pointer to a string containing the number (no sign)
+ * - len contains the length of the string
+ * - is_negative is set to TRUE or FALSE depending on the sign
+ * of the number (always set to FALSE if is_unsigned is TRUE)
+ *
+ * The caller provides a buffer for the string: that is the buf_end argument
+ * which is a pointer to the END of the buffer + 1 (i.e. if the buffer
+ * is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
+ */
+static char *
+conv_10(wide_int num, bool_int is_unsigned, bool_int *is_negative,
+ char *buf_end, int *len)
+{
+ char *p = buf_end;
+ u_wide_int magnitude;
+
+ if (is_unsigned) {
+ magnitude = (u_wide_int) num;
+ *is_negative = FALSE;
+ } else {
+ *is_negative = (num < 0);
+
+ /*
+ * On a 2's complement machine, negating the most negative integer
+ * results in a number that cannot be represented as a signed integer.
+ * Here is what we do to obtain the number's magnitude:
+ * a. add 1 to the number
+ * b. negate it (becomes positive)
+ * c. convert it to unsigned
+ * d. add 1
+ */
+ if (*is_negative) {
+ wide_int t = num + 1;
+
+ magnitude = ((u_wide_int) - t) + 1;
+ } else
+ magnitude = (u_wide_int) num;
+ }
+
+ /*
+ * We use a do-while loop so that we write at least 1 digit
+ */
+ do {
+ register u_wide_int new_magnitude = magnitude / 10;
+
+ *--p = magnitude - new_magnitude * 10 + '0';
+ magnitude = new_magnitude;
+ }
+ while (magnitude);
+
+ *len = buf_end - p;
+ return (p);
+}
+
+/*
+ * Do format conversion.
+ */
+SCOPE int
+#if (defined(__UNIXWARE__) || defined(__OPENSERVER)) && !defined(__GNUC__)
+vsnprintf(char *str, size_t size, const char *fmt, _VA_LIST ap)
+#else
+vsnprintf(char *str, size_t size, const char *fmt, va_list ap)
+#endif
+{
+ char *sp;
+ char *bep;
+ int cc = 0;
+ int i;
+
+ char *s;
+ char *q;
+ int s_len;
+
+ int min_width;
+ int precision;
+ enum {
+ LEFT, RIGHT
+ } adjust;
+ char pad_char;
+ char prefix_char;
+
+ double fp_num;
+ wide_int i_num;
+ u_wide_int ui_num;
+
+ char num_buf[NUM_BUF_SIZE];
+ char char_buf[2]; /* for printing %% and %<unknown> */
+
+ /*
+ * Flag variables
+ */
+ boolean_e is_long;
+ boolean_e alternate_form;
+ boolean_e print_sign;
+ boolean_e print_blank;
+ boolean_e adjust_precision;
+ boolean_e adjust_width;
+ bool_int is_negative;
+
+ if (size == 0 && str != NULL)
+ return 0;
+
+ sp = str;
+ bep = str + size - 1;
+
+ while (*fmt) {
+ if (*fmt != '%') {
+ INS_CHAR(*fmt, sp, bep, cc);
+ } else {
+ /*
+ * Default variable settings
+ */
+ adjust = RIGHT;
+ alternate_form = print_sign = print_blank = NO;
+ pad_char = ' ';
+ prefix_char = NUL;
+
+ fmt++;
+
+ /*
+ * Try to avoid checking for flags, width or precision
+ */
+ if (isascii(*fmt) && !islower(*fmt)) {
+ /*
+ * Recognize flags: -, #, BLANK, +
+ */
+ for (;; fmt++) {
+ if (*fmt == '-')
+ adjust = LEFT;
+ else if (*fmt == '+')
+ print_sign = YES;
+ else if (*fmt == '#')
+ alternate_form = YES;
+ else if (*fmt == ' ')
+ print_blank = YES;
+ else if (*fmt == '0')
+ pad_char = '0';
+ else
+ break;
+ }
+
+ /*
+ * Check if a width was specified
+ */
+ if (isdigit(*fmt)) {
+ STR_TO_DEC(fmt, min_width);
+ adjust_width = YES;
+ } else if (*fmt == '*') {
+ min_width = va_arg(ap, int);
+
+ fmt++;
+ adjust_width = YES;
+ if (min_width < 0) {
+ adjust = LEFT;
+ min_width = -min_width;
+ }
+ } else
+ adjust_width = NO;
+
+ /*
+ * Check if a precision was specified
+ *
+ * XXX: an unreasonable amount of precision may be specified
+ * resulting in overflow of num_buf. Currently we
+ * ignore this possibility.
+ */
+ if (*fmt == '.') {
+ adjust_precision = YES;
+ fmt++;
+ if (isdigit(*fmt)) {
+ STR_TO_DEC(fmt, precision);
+ } else if (*fmt == '*') {
+ precision = va_arg(ap, int);
+
+ fmt++;
+ if (precision < 0)
+ precision = 0;
+ } else
+ precision = 0;
+ } else
+ adjust_precision = NO;
+ } else
+ adjust_precision = adjust_width = NO;
+
+ /*
+ * Modifier check
+ */
+ if (*fmt == 'l') {
+ is_long = YES;
+ fmt++;
+ } else
+ is_long = NO;
+
+ /*
+ * Argument extraction and printing.
+ * First we determine the argument type.
+ * Then, we convert the argument to a string.
+ * On exit from the switch, s points to the string that
+ * must be printed, s_len has the length of the string
+ * The precision requirements, if any, are reflected in s_len.
+ *
+ * NOTE: pad_char may be set to '0' because of the 0 flag.
+ * It is reset to ' ' by non-numeric formats
+ */
+ switch (*fmt) {
+ case 'd':
+ case 'i':
+ case 'u':
+ if (is_long)
+ i_num = va_arg(ap, wide_int);
+ else
+ i_num = (wide_int) va_arg(ap, int);
+
+ s = conv_10(i_num, (*fmt) == 'u', &is_negative,
+ &num_buf[NUM_BUF_SIZE], &s_len);
+ FIX_PRECISION(adjust_precision, precision, s, s_len);
+
+ if (*fmt != 'u') {
+ if (is_negative)
+ prefix_char = '-';
+ else if (print_sign)
+ prefix_char = '+';
+ else if (print_blank)
+ prefix_char = ' ';
+ }
+ break;
+
+ case 'o':
+ if (is_long)
+ ui_num = va_arg(ap, u_wide_int);
+ else
+ ui_num = (u_wide_int) va_arg(ap, unsigned int);
+
+ s = conv_p2(ui_num, 3, *fmt,
+ &num_buf[NUM_BUF_SIZE], &s_len);
+ FIX_PRECISION(adjust_precision, precision, s, s_len);
+ if (alternate_form && *s != '0') {
+ *--s = '0';
+ s_len++;
+ }
+ break;
+
+ case 'x':
+ case 'X':
+ if (is_long)
+ ui_num = (u_wide_int) va_arg(ap, u_wide_int);
+ else
+ ui_num = (u_wide_int) va_arg(ap, unsigned int);
+
+ s = conv_p2(ui_num, 4, *fmt,
+ &num_buf[NUM_BUF_SIZE], &s_len);
+ FIX_PRECISION(adjust_precision, precision, s, s_len);
+ if (alternate_form && i_num != 0) {
+ *--s = *fmt; /* 'x' or 'X' */
+ *--s = '0';
+ s_len += 2;
+ }
+ break;
+
+ case 's':
+ s = va_arg(ap, char *);
+
+ if (s != NULL) {
+ s_len = strlen(s);
+ if (adjust_precision && precision < s_len)
+ s_len = precision;
+ } else {
+ s = S_NULL;
+ s_len = S_NULL_LEN;
+ }
+ pad_char = ' ';
+ break;
+
+ case 'f':
+ case 'e':
+ case 'E':
+ fp_num = va_arg(ap, double);
+
+ s = conv_fp(*fmt, fp_num, alternate_form,
+ (adjust_precision == NO) ? FLOAT_DIGITS : precision,
+ &is_negative, &num_buf[1], &s_len);
+ if (is_negative)
+ prefix_char = '-';
+ else if (print_sign)
+ prefix_char = '+';
+ else if (print_blank)
+ prefix_char = ' ';
+ break;
+
+ case 'g':
+ case 'G':
+ if (adjust_precision == NO)
+ precision = FLOAT_DIGITS;
+ else if (precision == 0)
+ precision = 1;
+ /*
+ * We use &num_buf[ 1 ], so that we have room for the sign
+ */
+ s = gcvt(va_arg(ap, double), precision, &num_buf[1]);
+
+ if (*s == '-')
+ prefix_char = *s++;
+ else if (print_sign)
+ prefix_char = '+';
+ else if (print_blank)
+ prefix_char = ' ';
+
+ s_len = strlen(s);
+
+ if (alternate_form && (q = strchr(s, '.')) == NULL)
+ s[s_len++] = '.';
+ if (*fmt == 'G' && (q = strchr(s, 'e')) != NULL)
+ *q = 'E';
+ break;
+
+ case 'c':
+ char_buf[0] = (char)(va_arg(ap, int));
+
+ s = &char_buf[0];
+ s_len = 1;
+ pad_char = ' ';
+ break;
+
+ case '%':
+ char_buf[0] = '%';
+ s = &char_buf[0];
+ s_len = 1;
+ pad_char = ' ';
+ break;
+
+ case 'n':
+ *(va_arg(ap, int *)) = cc;
+
+ break;
+
+ /*
+ * If the pointer size is equal to the size of an unsigned
+ * integer we convert the pointer to a hex number, otherwise
+ * we print "%p" to indicate that we don't handle "%p".
+ */
+ case 'p':
+ ui_num = (u_wide_int) va_arg(ap, void *);
+
+ if (sizeof(void *) <= sizeof(u_wide_int))
+ s = conv_p2(ui_num, 4, 'x',
+ &num_buf[NUM_BUF_SIZE], &s_len);
+
+ else {
+ s = "%p";
+ s_len = 2;
+ }
+ pad_char = ' ';
+ break;
+
+ case NUL:
+ /*
+ * The last character of the format string was %.
+ * We ignore it.
+ */
+ continue;
+
+ /*
+ * The default case is for unrecognized %'s.
+ * We print %<char> to help the user identify what
+ * option is not understood.
+ * This is also useful in case the user wants to pass
+ * the output of __sio_converter to another function
+ * that understands some other %<char> (like syslog).
+ * Note that we can't point s inside fmt because the
+ * unknown <char> could be preceded by width etc.
+ */
+ default:
+ char_buf[0] = '%';
+ char_buf[1] = *fmt;
+ s = char_buf;
+ s_len = 2;
+ pad_char = ' ';
+ break;
+ }
+
+ if (prefix_char != NUL) {
+ *--s = prefix_char;
+ s_len++;
+ }
+ if (adjust_width && adjust == RIGHT && min_width > s_len) {
+ if (pad_char == '0' && prefix_char != NUL) {
+ INS_CHAR(*s, sp, bep, cc)
+ s++;
+ s_len--;
+ min_width--;
+ }
+ PAD(min_width, s_len, pad_char);
+ }
+ /*
+ * Print the string s.
+ */
+ for (i = s_len; i != 0; i--) {
+ INS_CHAR(*s, sp, bep, cc);
+ s++;
+ }
+
+ if (adjust_width && adjust == LEFT && min_width > s_len)
+ PAD(min_width, s_len, pad_char);
+ }
+ fmt++;
+ }
+ if (str != NULL) {
+ if (cc < size)
+ str[cc] = NUL;
+ else
+ str[size - 1] = NUL;
+ }
+ return cc;
+}
+
diff --git a/nx-X11/lib/misc/snprintf.h b/nx-X11/lib/misc/snprintf.h
new file mode 100644
index 000000000..481e67679
--- /dev/null
+++ b/nx-X11/lib/misc/snprintf.h
@@ -0,0 +1,35 @@
+/* $XFree86: xc/lib/misc/snprintf.h,v 3.1 1996/08/26 14:42:33 dawes Exp $ */
+
+#ifndef SNPRINTF_H
+#define SNPRINTF_H
+
+#ifdef HAS_SNPRINTF
+#ifdef LIBXT
+#define _XtSnprintf snprintf
+#define _XtVsnprintf vsnprintf
+#endif
+#ifdef LIBX11
+#define _XSnprintf snprintf
+#define _XVsnprintf vsnprintf
+#endif
+#else /* !HAS_SNPRINTF */
+
+#ifdef LIBXT
+#define snprintf _XtSnprintf
+#define vsnprintf _XtVsnprintf
+#endif
+#ifdef LIBX11
+#define snprintf _XSnprintf
+#define vsnprintf _XVsnprintf
+#endif
+
+extern int snprintf (char *str, size_t count, const char *fmt, ...);
+#if (defined(__UNIXWARE__) || defined(__OPENSERVER)) && !defined(__GNUC__)
+extern int vsnprintf (char *str, size_t count, const char *fmt, _VA_LIST arg);
+#else
+extern int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
+#endif
+
+#endif /* HAS_SNPRINTF */
+
+#endif /* SNPRINTF_H */
diff --git a/nx-X11/lib/misc/strlcat.c b/nx-X11/lib/misc/strlcat.c
new file mode 100644
index 000000000..28e2338f9
--- /dev/null
+++ b/nx-X11/lib/misc/strlcat.c
@@ -0,0 +1,61 @@
+/* $OpenBSD: strlcat.c,v 1.10 2003/04/12 21:56:39 millert Exp $ */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
+ * FOR ANY SPECIAL, DIRECT, 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.
+ */
+/* $XFree86$ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left). At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(char *dst, const char *src, size_t siz)
+{
+ register char *d = dst;
+ register const char *s = src;
+ register size_t n = siz;
+ size_t dlen;
+
+ /* Find the end of dst and adjust bytes left but don't go past end */
+ while (n-- != 0 && *d != '\0')
+ d++;
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return(dlen + strlen(s));
+ while (*s != '\0') {
+ if (n != 1) {
+ *d++ = *s;
+ n--;
+ }
+ s++;
+ }
+ *d = '\0';
+
+ return(dlen + (s - src)); /* count does not include NUL */
+}
diff --git a/nx-X11/lib/misc/strlcpy.c b/nx-X11/lib/misc/strlcpy.c
new file mode 100644
index 000000000..42442cc30
--- /dev/null
+++ b/nx-X11/lib/misc/strlcpy.c
@@ -0,0 +1,56 @@
+/* $OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp $ */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
+ * FOR ANY SPECIAL, DIRECT, 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.
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+ register char *d = dst;
+ register const char *s = src;
+ register size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0 && --n != 0) {
+ do {
+ if ((*d++ = *s++) == 0)
+ break;
+ } while (--n != 0);
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return(s - src - 1); /* count does not include NUL */
+}
diff --git a/nx-X11/lib/oldX/Imakefile b/nx-X11/lib/oldX/Imakefile
new file mode 100644
index 000000000..ae80d268e
--- /dev/null
+++ b/nx-X11/lib/oldX/Imakefile
@@ -0,0 +1,45 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:42 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/oldX/Imakefile,v 1.2 1998/12/20 11:57:19 dawes Exp $
+
+#define DoNormalLib NormalOldX
+#define DoSharedLib SharedOldX
+#define DoExtraLib SharedOldX
+#define DoDebugLib DebugOldX
+#define DoProfileLib ProfileOldX
+#define LibName oldX
+#define SoRev SOOLDXREV
+#define IncSubdir X11
+
+#ifdef SharedOldXReqs
+REQUIREDLIBS = SharedOldXReqs
+#endif
+
+#if Malloc0ReturnsNull
+ DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+ INCLUDES = -I$(XINCLUDESRC) -I$(XLIBSRC)
+ SRCS = \
+ XDraw.c \
+ XCrAssoc.c \
+ XDelAssoc.c \
+ XDestAssoc.c \
+ XLookAssoc.c \
+ XMakeAssoc.c
+ HEADERS = X10.h
+ LINTLIBS =
+
+ OBJS = \
+ XDraw.o \
+ XCrAssoc.o \
+ XDelAssoc.o \
+ XDestAssoc.o \
+ XLookAssoc.o \
+ XMakeAssoc.o
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/oldX/X10.h b/nx-X11/lib/oldX/X10.h
new file mode 100644
index 000000000..afdb80d6b
--- /dev/null
+++ b/nx-X11/lib/oldX/X10.h
@@ -0,0 +1,89 @@
+/* $Xorg: X10.h,v 1.4 2001/02/09 02:04:05 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.
+ *
+ * The X Window System is a Trademark of The Open Group.
+ *
+ */
+
+
+/*
+ * X10.h - Header definition and support file for the C subroutine
+ * interface library for V10 support routines.
+ */
+#ifndef _X10_H_
+#define _X10_H_
+
+/* Used in XDraw and XDrawFilled */
+
+typedef struct {
+ short x, y;
+ unsigned short flags;
+} Vertex;
+
+/* The meanings of the flag bits. If the bit is 1 the predicate is true */
+
+#define VertexRelative 0x0001 /* else absolute */
+#define VertexDontDraw 0x0002 /* else draw */
+#define VertexCurved 0x0004 /* else straight */
+#define VertexStartClosed 0x0008 /* else not */
+#define VertexEndClosed 0x0010 /* else not */
+/*#define VertexDrawLastPoint 0x0020 */ /* else don't */
+
+/*
+The VertexDrawLastPoint option has not been implemented in XDraw and
+XDrawFilled so it shouldn't be defined.
+*/
+
+/*
+ * XAssoc - Associations used in the XAssocTable data structure. The
+ * associations are used as circular queue entries in the association table
+ * which is contains an array of circular queues (buckets).
+ */
+typedef struct _XAssoc {
+ struct _XAssoc *next; /* Next object in this bucket. */
+ struct _XAssoc *prev; /* Previous obejct in this bucket. */
+ Display *display; /* Display which ownes the id. */
+ XID x_id; /* X Window System id. */
+ char *data; /* Pointer to untyped memory. */
+} XAssoc;
+
+/*
+ * XAssocTable - X Window System id to data structure pointer association
+ * table. An XAssocTable is a hash table whose buckets are circular
+ * queues of XAssoc's. The XAssocTable is constructed from an array of
+ * XAssoc's which are the circular queue headers (bucket headers).
+ * An XAssocTable consists an XAssoc pointer that points to the first
+ * bucket in the bucket array and an integer that indicates the number
+ * of buckets in the array.
+ */
+typedef struct {
+ XAssoc *buckets; /* Pointer to first bucket in bucket array.*/
+ int size; /* Table size (number of buckets). */
+} XAssocTable;
+
+XAssocTable *XCreateAssocTable();
+char *XLookUpAssoc();
+
+#endif /* _X10_H_ */
diff --git a/nx-X11/lib/oldX/XCrAssoc.c b/nx-X11/lib/oldX/XCrAssoc.c
new file mode 100644
index 000000000..d36e95293
--- /dev/null
+++ b/nx-X11/lib/oldX/XCrAssoc.c
@@ -0,0 +1,75 @@
+/* $Xorg: XCrAssoc.c,v 1.4 2001/02/09 02:04:05 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "X11/Xlibint.h"
+#include "X10.h"
+
+/*
+ * XCreateAssocTable - Create an XAssocTable. The size argument should be
+ * a power of two for efficiency reasons. Some size suggestions: use 32
+ * buckets per 100 objects; a reasonable maximum number of object per
+ * buckets is 8. If there is an error creating the XAssocTable, a NULL
+ * pointer is returned.
+ */
+XAssocTable *XCreateAssocTable(size)
+ register int size; /* Desired size of the table. */
+{
+ register XAssocTable *table; /* XAssocTable to be initialized. */
+ register XAssoc *buckets; /* Pointer to the first bucket in */
+ /* the bucket array. */
+
+ /* XMalloc the XAssocTable. */
+ if ((table = (XAssocTable *)Xmalloc(sizeof(XAssocTable))) == NULL) {
+ /* XMalloc call failed! */
+ errno = ENOMEM;
+ return(NULL);
+ }
+
+ /* XMalloc the buckets (actually just their headers). */
+ buckets = (XAssoc *)Xcalloc((unsigned)size, (unsigned)sizeof(XAssoc));
+ if (buckets == NULL) {
+ /* XCalloc call failed! */
+ errno = ENOMEM;
+ return(NULL);
+ }
+
+ /* Insert table data into the XAssocTable structure. */
+ table->buckets = buckets;
+ table->size = size;
+
+ while (--size >= 0) {
+ /* Initialize each bucket. */
+ buckets->prev = buckets;
+ buckets->next = buckets;
+ buckets++;
+ }
+
+ return(table);
+}
diff --git a/nx-X11/lib/oldX/XDelAssoc.c b/nx-X11/lib/oldX/XDelAssoc.c
new file mode 100644
index 000000000..e7c4b75a8
--- /dev/null
+++ b/nx-X11/lib/oldX/XDelAssoc.c
@@ -0,0 +1,82 @@
+/* $Xorg: XDelAssoc.c,v 1.4 2001/02/09 02:04:05 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.
+
+*/
+/* $XFree86: xc/lib/oldX/XDelAssoc.c,v 1.3 2001/01/17 19:43:37 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "X11/Xlibint.h"
+#include "X10.h"
+
+/*
+ * XDeleteAssoc - Delete an association in an XAssocTable keyed on
+ * an XId. An association may be removed only once. Redundant
+ * deletes are meaningless (but cause no problems).
+ */
+int
+XDeleteAssoc(dpy, table, x_id)
+ register Display *dpy;
+ register XAssocTable *table;
+ register XID x_id;
+{
+ int hash;
+ register XAssoc *bucket;
+ register XAssoc *Entry;
+
+ /* Hash the XId to get the bucket number. */
+ hash = x_id & (table->size - 1);
+ /* Look up the bucket to get the entries in that bucket. */
+ bucket = &table->buckets[hash];
+ /* Get the first entry in the bucket. */
+ Entry = bucket->next;
+
+ /* Scan through the entries in the bucket for the right XId. */
+ for (; Entry != bucket; Entry = Entry->next) {
+ if (Entry->x_id == x_id) {
+ /* We have the right XId. */
+ if (Entry->display == dpy) {
+ /* We have the right display. */
+ /* We have the right entry! */
+ /* Remove it from the queue and */
+ /* free the entry. */
+ Entry->prev->next = Entry->next;
+ Entry->next->prev = Entry->prev;
+ Xfree((char *)Entry);
+ return 0;
+ }
+ /* Oops, identical XId's on different displays! */
+ continue;
+ }
+ if (Entry->x_id > x_id) {
+ /* We have gone past where it should be. */
+ /* It is apparently not in the table. */
+ return 0;
+ }
+ }
+ /* It is apparently not in the table. */
+ return 0;
+}
diff --git a/nx-X11/lib/oldX/XDestAssoc.c b/nx-X11/lib/oldX/XDestAssoc.c
new file mode 100644
index 000000000..672ac2304
--- /dev/null
+++ b/nx-X11/lib/oldX/XDestAssoc.c
@@ -0,0 +1,67 @@
+/* $Xorg: XDestAssoc.c,v 1.4 2001/02/09 02:04:05 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.
+
+*/
+/* $XFree86: xc/lib/oldX/XDestAssoc.c,v 1.3 2001/01/17 19:43:38 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "X11/Xlibint.h"
+#include "X10.h"
+
+/*
+ * XDestroyAssocTable - Destroy (free the memory associated with)
+ * an XAssocTable.
+ */
+int
+XDestroyAssocTable(table)
+ register XAssocTable *table;
+{
+ register int i;
+ register XAssoc *bucket;
+ register XAssoc *Entry, *entry_next;
+
+ /* Free the buckets. */
+ for (i = 0; i < table->size; i++) {
+ bucket = &table->buckets[i];
+ for (
+ Entry = bucket->next;
+ Entry != bucket;
+ Entry = entry_next
+ ) {
+ entry_next = Entry->next;
+ Xfree((char *)Entry);
+ }
+ }
+
+ /* Free the bucket array. */
+ Xfree((char *)table->buckets);
+
+ /* Free the table. */
+ Xfree((char *)table);
+ return 0;
+}
+
diff --git a/nx-X11/lib/oldX/XDraw.c b/nx-X11/lib/oldX/XDraw.c
new file mode 100644
index 000000000..3eeff3e00
--- /dev/null
+++ b/nx-X11/lib/oldX/XDraw.c
@@ -0,0 +1,710 @@
+/* $Xorg: XDraw.c,v 1.4 2001/02/09 02:04:05 xorgcvs Exp $ */
+
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/oldX/XDraw.c,v 1.4 2001/07/25 15:04:57 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "X11/Xlibint.h"
+#include "X11/Xlib.h"
+#include "X10.h"
+
+#define OK_RETURN 1
+#define ERR_RETURN 0
+#include <stddef.h>
+
+/*
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+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.
+
+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.
+
+*/
+
+/*
+ *
+ * Vertices_converter: This internal routine takes a list of Vertices and
+ * returns another list of Vertices such that the
+ * following is true:
+ *
+ * (1) No Vertex has the VertexRelative flag on
+ * (2) No Vertex has the VertexCurved flag on
+ * (3) The first Vertex has the VertexDontDraw flag on
+ * (4) The path that the return Vertex list specifies should
+ * be drawn on the screen is very close to the path that the
+ * Vertex list passed to vertices_converter specified should be
+ * drawn. The difference is due solely to the approximation
+ * of curved segments in the original Vertex list by many
+ * small straight line segments that approximate the curve.
+ *
+ * Notes:
+ *
+ * (1) The first Vertex must have the VertexRelative flag
+ * turned off. (This is not checked, just assumed)
+ * (2) VertexDontDraw is automatically turned on for the first
+ * Vertex because drawing to the first Vertex makes no sense.
+ * (3) This routine is used only by XDraw & XDrawFilled.
+ * (4) A 0 is returned iff no error occurs.
+ * (5) The passed Vertex list not changed in any way.
+ *
+ * Implementation:
+ *
+ * A routine from the qvss device dependent code library from the
+ * X version 10 sources written by DEC was used, abet slightly
+ * modified as it provided 99% of the desired functionality.
+ *
+ */
+
+/*****************************************************************************/
+/* */
+/* WRITTEN BY DARYL F. HAZEL 8509.06 */
+/* */
+/* Modification history: */
+/* */
+/* Carver 8510.23 Fixed first time allocation of the coord buffer */
+/* to allocate max(200, pathcount) amount insted of just */
+/* 200. Potential Xserver crash problem. */
+/* */
+/* Carver 8510.21 Replaced old module by module worked on by Ram Rao and */
+/* Bob Scheifler to get better performace. */
+/* */
+/* Carver 8510.03 Changed the curve line converter to return the coord */
+/* path if a successor point does not exist for curve gen. */
+/* */
+/* Carver 8510.03 Fixed memory loss problem. A coord path is only */
+/* allocated if the current path will not fit in it and */
+/* before the new coord path is allocated the old one is */
+/* freed. */
+/* */
+/* Carver 8509.24 Fixed pointer/integer mismatch {*ppathaddr_new = ...} */
+/* */
+/* Corkum 8509.18 Modify code to intergrate into the draw curve command */
+/* */
+/* Modified by Mark Lillibridge 5/20/87 to make into */
+/* X11 Xlib XDraw() support. */
+/****************************************************************************/
+
+/*
+ * Definitions:
+ *
+ */
+
+typedef short WORD;
+typedef short *WORD_POINTER;
+
+/*
+ * Lookup tables, buffers used in the conversion:
+ *
+ */
+
+
+/*
+ * modified path list storage information:
+ */
+static Vertex *pathaddr_new = NULL; /*pointer to current modified path list*/
+static int pathlist_bytes = 0; /* size of modified path list in bytes */
+static int pathlist_segs = 0;/* size of modified path list in segments */
+static Vertex *pathaddr_coords = NULL; /*ptr to path list with coordinates */
+static int path_coord_list_bytes = 0; /* size of path list (w/coords) buff */
+static int path_coord_list_segs = 0; /* size of path list (w/coords) buff */
+
+/*
+ * THE TABLE OF PSEUDO FLOATING-POINT NUMBERS WHICH MAKE UP THE
+ * MULTIPLICATIVE COEFFICIENTS FOR THE CUBIC SPLINE ALGORITHM.
+ */
+static unsigned short bntable[] = {
+ 0xfc18, 0x7f97, 0x0476, 0xffde,
+ 0xf8be, 0x7e5d, 0x0972, 0xff76,
+ 0xf5f4, 0x7c56, 0x0eec, 0xfecc,
+ 0xf3ba, 0x7988, 0x14da, 0xfde6,
+ 0xf20b, 0x75fe, 0x1b2f, 0xfcca,
+ 0xf0e2, 0x71c1, 0x21dd, 0xfb81,
+ 0xf038, 0x6ce1, 0x28d3, 0xfa16,
+ 0xf001, 0x676d, 0x3000, 0xf894,
+ 0xf034, 0x6176, 0x3750, 0xf709,
+ 0xf0c3, 0x5b0f, 0x3eae, 0xf583,
+ 0xf1a1, 0x544b, 0x4605, 0xf410,
+ 0xf2c0, 0x4d41, 0x4d41, 0xf2c0,
+ 0xf410, 0x4605, 0x544b, 0xf1a1,
+ 0xf583, 0x3eae, 0x5b0f, 0xf0c3,
+ 0xf709, 0x3750, 0x6176, 0xf034,
+ 0xf894, 0x3000, 0x676d, 0xf001,
+ 0xfa16, 0x28d3, 0x6ce1, 0xf038,
+ 0xfb81, 0x21dd, 0x71c1, 0xf0e2,
+ 0xfcca, 0x1b2f, 0x75fe, 0xf20b,
+ 0xfde6, 0x14da, 0x7988, 0xf3ba,
+ 0xfecc, 0x0eec, 0x7c56, 0xf5f4,
+ 0xff76, 0x0972, 0x7e5d, 0xf8be,
+ 0xffde, 0x0476, 0x7f97, 0xfc18
+ };
+
+/*
+ * this is the table which determines how many straight-line segments to draw
+ * for a given curved segment.
+ */
+static short segtable[] = { 10, 3, 56, /* pl <= 10, 3 segments */
+ 32, 4, 40, /* pl <= 32, 4 segments */
+ 80, 6, 24, /* pl <= 80, 6 segments */
+ 96, 8, 16, /* pl <= 96, 8 segments */
+ 192, 12, 8, /* pl <= 192, 12 segments */
+ 32767, 24, 00 /* pl <= 32767, 24 segments */
+ };
+
+/*
+ *
+ * The Real routine:
+ *
+ */
+
+static int vertices_converter(pathaddr, pathcount, ppathaddr_new, newpathcnt)
+ Vertex *pathaddr; /* address of original path list */
+ int pathcount; /* number of points in original path list */
+ Vertex **ppathaddr_new; /* ptr to addr of new path list */
+ int *newpathcnt; /* ptr to new number of pts in path list */
+{
+ int p0x, p0y; /* coordinates of curve's predecessor point */
+ int p1x, p1y; /* coordinates of curve's starting point */
+ int p2x, p2y; /* coordinates of curve's ending point */
+ int p3x, p3y; /* coordinates of curve's successor point */
+ int flag; /* flag word of current end-point in p.list */
+ int successor_x = 0; /* X coordinate of curve's successor point */
+ int successor_y = 0; /* Y coordinate of curve's successor point */
+ int little_endian; /* stupid bntable is little-endian */
+ WORD increment; /* bntable-ptr-increment value */
+ WORD diffx, diffy; /* absolute values of x, y end-point diffs */
+ WORD lmajoraxis; /* "length" of seg projected onto major axis */
+ union /* accumulator variables for computing end-points... */
+ { /* ...using the bntable. */
+ struct
+ {
+ WORD low;
+ WORD high;
+ } sword;
+ int lword;
+ } xxe, yye;
+ register Vertex *pnewpath;/* pointer for traversing modified path list */
+ int newpathcount; /* number of end-points in modified path list*/
+ register Vertex *pflag; /* pointer used for looking for fig's last pt*/
+ int i; /* general-purpose loop variable */
+ int ecf_flag_set; /* flag indicating existence of set ECF flag */
+ int count;
+ int curve_flag; /* 0 = no curves in path; 1 = curves in path */
+
+ /*
+ * The following is necessary because of the pseudo-floating point
+ * calculations done down below.
+ */
+ i = 1;
+ if (*(char *) &i)
+ little_endian = 1;
+ else
+ little_endian = 0;
+
+ {
+ register Vertex *poldpath;/* pointer for traversing original path list */
+ register Vertex *p_coord_path; /* ptr to path list with coordinates */
+
+ /* Init the return path count to 0 in case of error */
+ *newpathcnt = 0;
+ newpathcount = 0;
+
+ /* Use path buffers from last time */
+ pnewpath = pathaddr_new;
+ p_coord_path = pathaddr_coords;
+
+ /*
+ * if size of coordinate path list buffer is not at least large enough to
+ * accommodate the specified path list, allocate enough memory to do so
+ */
+ if (path_coord_list_segs == 0) /* first time through*/
+ {
+ path_coord_list_segs = max (200, pathcount);
+ path_coord_list_bytes = path_coord_list_segs * sizeof(Vertex);
+ if ((pathaddr_coords = (Vertex *)Xmalloc(path_coord_list_bytes)) != 0)
+ p_coord_path = pathaddr_coords;
+ else
+ return(ERR_RETURN);
+ }
+ else /* all but first time through */
+ {
+ /* If coord buffer is large enough for this path then reuse it, other
+ wise free the old one and get a new one (Carver) 8510.03 */
+ if (path_coord_list_segs < pathcount)
+ {
+ Xfree( pathaddr_coords);
+ path_coord_list_segs = pathcount;
+ path_coord_list_bytes = path_coord_list_segs * sizeof(Vertex);
+ if ((pathaddr_coords =(Vertex *)Xmalloc(path_coord_list_bytes)) !=0)
+ p_coord_path = pathaddr_coords;
+ else
+ return(ERR_RETURN);
+ };
+ }
+
+ /*
+ * Copy given Vertex list (pathaddr) to coordinate buffer converting
+ * relative coordinates to absolute coordinates.
+ *
+ * Sets curve_flag iff at least one Vertex has the VertexCurved flag set.
+ *
+ */
+
+ poldpath = pathaddr;
+ curve_flag = 0;
+
+ *p_coord_path = *poldpath++; /* First Vertex is a special case */
+ p_coord_path->flags = (p_coord_path->flags | VertexDontDraw)
+ & ~VertexRelative;
+ if ((p_coord_path++)->flags & VertexCurved)
+ curve_flag = 1;
+ for (i = pathcount - 1; i > 0; i--)
+ {
+ if (poldpath->flags & VertexRelative)
+ { /* compute coordinates using last pt */
+ p_coord_path->x = poldpath->x + p_coord_path[-1].x;
+ p_coord_path->y = poldpath->y + p_coord_path[-1].y;
+ p_coord_path->flags = poldpath->flags & ~VertexRelative;
+ }
+ else *p_coord_path = *poldpath;
+ p_coord_path++;
+ if ((poldpath++)->flags & VertexCurved)
+ curve_flag = 1;
+ }
+ } /* End of scope for poldaddr, p_coord_path */
+
+ /*
+ * if it has been determined that there are no curved segment end points in
+ * the specified path list, return the path list containing the coordinates
+ * to the calling routine.
+ */
+ if (!curve_flag)
+ {
+ *newpathcnt = pathcount;
+ *ppathaddr_new = pathaddr_coords;
+ return(OK_RETURN);
+ }
+
+ /*
+ * if size of modified path list buffer is not at least large enough to
+ * accommodate the specified path list allocate enough memory to do so
+ */
+ pathaddr = pathaddr_coords;
+ if (pathlist_segs < pathcount)
+ {
+ if (pathlist_segs == 0) /* Fix storage leak -- MDL 5/20/87 */
+ Xfree( pathaddr_new );
+ pathlist_segs = pathcount;
+ pathlist_bytes = pathcount * sizeof(Vertex);
+ if ((pathaddr_new = (Vertex *)Xmalloc(pathlist_bytes)) != 0)
+ pnewpath = pathaddr_new;
+ else
+ return(ERR_RETURN);
+ }
+
+ /*
+ * initialize the beginning and ending coordinates of the first segment
+ */
+ p1x = 0;
+ p1y = 0;
+ p2x = 0;
+ p2y = 0;
+
+ {
+ register WORD *pbntable; /* table of multiplicative coeffics.*/
+ register WORD *psegtable; /* table used to detrmn num.sub-segs*/
+ register WORD m; /* num segments into which curve is divided */
+
+ /*
+ * MAIN LOOP OF THE PATH_LIST_CONVERTER ROUTINE
+ */
+ for ( count=pathcount ; count > 0; count--)
+ {
+ p0x = p1x; /* save previous values of path-list coordinate pairs*/
+ p0y = p1y;
+ p1x = p2x;
+ p1y = p2y;
+
+ /*
+ * read next end-point's coordinates from the path list
+ */
+ p2x = pathaddr->x;
+ p2y = pathaddr->y;
+ flag = (pathaddr++)->flags;
+
+ /*
+ * CURVED-segment considerations
+ */
+ if (flag & VertexCurved)
+ {
+ /*
+ * determine which point to use as the successor point: the next
+ * point in the list (if there is one), or a previously-saved point
+ * (when drawing closed figures)
+ */
+ if (flag & VertexEndClosed) /* last segment of closed fig*/
+ {
+ p3x = successor_x;
+ p3y = successor_y;
+ }
+ else /* stand-alone curved segment*/
+ {
+ if (count <= 1) /* no points to use as successor pt */
+ {
+
+ /* in this case draw the coord path */
+ *newpathcnt = pathcount;
+ *ppathaddr_new = pathaddr_coords;
+ return(OK_RETURN);
+ }
+ else
+ {
+ /*
+ * read next end-point's coordinates from the path list...
+ */
+ p3x = pathaddr->x;
+ p3y = pathaddr->y;
+
+ if (flag & VertexStartClosed)
+ { /* first segment of closed figure */
+ /*
+ * save P3 as successor pt for closed-fig-ending curve
+ */
+ successor_x = p3x;
+ successor_y = p3y;
+
+ /*
+ * Traverse the original path list looking for ECF flag
+ * After finding it, back pointer up to previous point
+ * and save the information for use as curve's pred. pt
+ */
+ ecf_flag_set = 0;
+ pflag = pathaddr;
+ for (i = count; i > 0; i--)
+ {
+ if (pflag->flags & VertexEndClosed)
+ {
+ pflag--;
+ p1x = pflag->x;
+ p1y = pflag->y;
+ ecf_flag_set = 1;
+ break;
+ }
+ pflag++;
+ }
+ if (!ecf_flag_set)
+ return(ERR_RETURN);
+ } /* end code pertaining to starting figure*/
+ } /* end code pertaining to successor points */
+ } /* end code pertaining to stand-alone curved segs*/
+
+ if ((flag & VertexDontDraw) == 0)
+ {
+ /*
+ * determine the "length" of the segment along the major axis
+ */
+ if ((diffx = p2x - p1x) < 0)
+ diffx = ~diffx + 1;
+ if ((diffy = p2y - p1y) < 0)
+ diffy = ~diffy + 1;
+ lmajoraxis = (diffx >= diffy) ? diffx : diffy;
+ if (lmajoraxis == 0) /* for vector to have length of... */
+ lmajoraxis = 1; /* ...at least one */
+
+ /*
+ * compute M, the number of sub-segments into which a curved
+ * segment is divided
+ */
+ psegtable = segtable;
+ while (lmajoraxis > *psegtable++)/* search for appropriate..*/
+ psegtable += 2; /* ...table entry */
+ m = *psegtable++; /* read number of segments */
+ increment = *psegtable >> 1;
+
+ /*
+ * determine if there is enough room remaining in the modified
+ * path-list buffer to hold ALL of the curve's sub-segment in-
+ * formation; if not, double the buffer size (if possible).
+ */
+ while ((newpathcount + m) > pathlist_segs)
+ {
+ pathlist_segs *= 2;
+ pathlist_bytes *= 2;
+ if ((pathaddr_new = (Vertex *)Xrealloc(pathaddr_new,
+ pathlist_bytes)) != 0)
+ pnewpath = pathaddr_new + newpathcount;
+ else
+ return(ERR_RETURN);
+ }
+
+ /*
+ * generate end-points of sub-segs into which curve is divided
+ */
+ pbntable = (WORD *) bntable; /* initialize the pointer to the Bn table*/
+ for ( ; m > 1; m--)
+ {
+ pbntable += increment;
+ xxe.lword = *pbntable * p0x;
+ yye.lword = *pbntable++ * p0y;
+ xxe.lword += *pbntable * p1x;
+ yye.lword += *pbntable++ * p1y;
+ xxe.lword += *pbntable * p2x;
+ yye.lword += *pbntable++ * p2y;
+ xxe.lword += *pbntable * p3x;
+ yye.lword += *pbntable++ * p3y;
+ xxe.lword = xxe.lword << 1; /* double values... */
+ yye.lword = yye.lword << 1; /* ...bn accts for it*/
+ xxe.lword += 0x8000; /* round off the accum value */
+ yye.lword += 0x8000;
+ if (little_endian) {
+ pnewpath->x = xxe.sword.high;/* the X coordinate */
+ pnewpath->y = yye.sword.high;/* the Y coordinate */
+ } else {
+ pnewpath->x = xxe.sword.low;/* the X coordinate */
+ pnewpath->y = yye.sword.low;/* the Y coordinate */
+ }
+ (pnewpath++)->flags = 0; /* the flag word */
+ newpathcount++;/* increment segment end-point countr*/
+ } /* end sub-segment end-point compute loop*/
+ } /* end DRAW-segment considerations code */
+ } /* end CURVED-segment considerations code */
+
+ /*
+ * put end-point from original path list into modified list
+ */
+ pnewpath->x = p2x;
+ pnewpath->y = p2y;
+ (pnewpath++)->flags = flag & ~VertexCurved;
+ newpathcount++;
+
+ /*
+ * determine whether or not the modified path list is full, and if so,
+ * double its size
+ */
+ if (newpathcount == pathlist_segs)
+ {
+ pathlist_bytes *= 2;
+ pathlist_segs *= 2;
+ if ((pathaddr_new = (Vertex *)Xrealloc(pathaddr_new,
+ pathlist_bytes)) != 0)
+ pnewpath = pathaddr_new + newpathcount;
+ else
+ return(ERR_RETURN);
+ }
+ } /* END of PATH_LIST_CONVERTER's main loop */
+
+ /*
+ * return the address of the modified path list and the number of segment
+ * end-points it contains
+ */
+ *newpathcnt = newpathcount;
+ *ppathaddr_new = pathaddr_new;
+ }
+
+ return(OK_RETURN);
+}
+
+/* Written by Mark Lillibridge */
+
+static XPoint *XDraw_points = NULL; /* Buffer to hold list of points for */
+static int point_count = 0; /* use in calling XDrawLines */
+
+Status XDraw (dpy, d, gc, vlist, vcount)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ Vertex *vlist;
+ int vcount;
+{
+ Vertex *newvlist;
+ int newvcount;
+ XPoint *p;
+ int pcount;
+
+ /* If less than 2 vertices, we don't have to do anything (no lines) */
+ if (vcount<2)
+ return(OK_RETURN);
+
+ /* Convert curved lines to straight lines & change relative references to */
+ /* absolute references. */
+ if (!vertices_converter( vlist, vcount, &newvlist, &newvcount))
+ return(ERR_RETURN);
+
+ /* Insure we have enough buffer space */
+ if (point_count < newvcount) {
+ if (point_count != 0)
+ Xfree( XDraw_points );
+ if (!(XDraw_points = (XPoint *) Xmalloc( newvcount * sizeof(XPoint) )))
+ return(ERR_RETURN);
+ point_count = newvcount;
+ }
+
+ /*
+ * Draw the lines defined by newvlist using seperate XDrawLines calls
+ * to insure that all the lines that should be joined are and that closed
+ * figures are joined correctly.
+ */
+ while (newvcount>0) {
+ p = XDraw_points; /* Put points in buffer */
+ pcount = 0;
+ p->x = newvlist->x; /* Copy first point */
+ (p++)->y = (newvlist++)->y;
+ newvcount--; pcount++;
+
+ /*
+ * Copy more points until out of points or need to stop XDrawLine
+ * because either we don't want to join to the next point
+ * (VertexDontDraw) or we want to stop after the next point so that
+ * a closed figure will be joined correctly. (We have to stop before
+ * a VertexStartClosed because the vertex marked VertexStartClosed
+ * must be the first vertex in its XDrawLines call to get joining
+ * to work correctly.
+ */
+ while (newvcount > 0 && !(newvlist->flags & (VertexDontDraw |
+ VertexStartClosed |
+ VertexEndClosed))) {
+ p->x = newvlist->x;
+ (p++)->y = (newvlist++)->y;
+ newvcount--; pcount++;
+ }
+
+ /*
+ * If stopped only because of need to start a new XDrawLines, copy
+ * next point but don't advance pointer so two XdrawLines act like one.
+ */
+ if ( newvcount > 0 && !(newvlist->flags & VertexDontDraw) ) {
+ p->x = newvlist->x;
+ (p++)->y = newvlist->y;
+ pcount++;
+ }
+
+ /* Do the XDrawLines if there are any lines to draw */
+ if (pcount>1)
+ XDrawLines(dpy, d, gc, XDraw_points, pcount, CoordModeOrigin);
+ }
+
+ return(OK_RETURN);
+}
+
+Status XDrawFilled (dpy, d, gc, vlist, vcount)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ Vertex *vlist;
+ int vcount;
+{
+ Vertex *newvlist;
+ int newvcount;
+ XPoint *p;
+ int pcount;
+
+ /* If less than 2 vertices, we don't have to do anything (no lines) */
+ if (vcount<2)
+ return(OK_RETURN);
+
+ /* Convert curved lines to straight lines & change relative references to */
+ /* absolute references. */
+ if (!vertices_converter( vlist, vcount, &newvlist, &newvcount))
+ return(ERR_RETURN);
+
+ /* Insure we have enough buffer space */
+ if (point_count < newvcount) {
+ if (point_count != 0)
+ Xfree( XDraw_points );
+ if (!(XDraw_points = (XPoint *) Xmalloc( newvcount * sizeof(XPoint) )))
+ return(ERR_RETURN);
+ point_count = newvcount;
+ }
+
+ /*
+ * Draw the lines defined by newvlist using seperate XDrawLines calls
+ * to insure that all the lines that should be joined are and that closed
+ * figures are joined correctly.
+ */
+ while (newvcount>0) {
+ p = XDraw_points; /* Put points in buffer */
+ pcount = 0;
+ p->x = newvlist->x; /* Copy first point */
+ (p++)->y = (newvlist++)->y;
+ newvcount--; pcount++;
+
+ /*
+ * Copy more points until out of points or need to stop XDrawLine
+ * because either we don't want to join to the next point
+ * (VertexDontDraw) or we want to stop after the next point so that
+ * a closed figure will be joined correctly. (We have to stop before
+ * a VertexStartClosed because the vertex marked VertexStartClosed
+ * must be the first vertex in its XDrawLines call to get joining
+ * to work correctly.
+ */
+ while (newvcount > 0 && !(newvlist->flags & (VertexStartClosed |
+ VertexEndClosed))) {
+ p->x = newvlist->x;
+ (p++)->y = (newvlist++)->y;
+ newvcount--; pcount++;
+ }
+
+ /*
+ * If stopped only because of need to start a new XDrawLines, copy
+ * next point but don't advance pointer so two XdrawLines act like one.
+ */
+ if ( newvcount > 0 ) {
+ p->x = newvlist->x;
+ (p++)->y = newvlist->y;
+ pcount++;
+ }
+
+ /* Do the XDrawLines if there are any lines to draw */
+ if (pcount>1) {
+ XFillPolygon(dpy, d, gc, XDraw_points, pcount, Complex,
+ CoordModeOrigin);
+ }
+ }
+
+ return(OK_RETURN);
+}
diff --git a/nx-X11/lib/oldX/XLookAssoc.c b/nx-X11/lib/oldX/XLookAssoc.c
new file mode 100644
index 000000000..fe150c919
--- /dev/null
+++ b/nx-X11/lib/oldX/XLookAssoc.c
@@ -0,0 +1,78 @@
+/* $Xorg: XLookAssoc.c,v 1.4 2001/02/09 02:04:05 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "X11/Xlibint.h"
+#include "X10.h"
+
+/*
+ * XLookUpAssoc - Retrieve the data stored in an XAssocTable by its XId.
+ * If an appropriately matching XId can be found in the table the routine will
+ * return apointer to the data associated with it. If the XId can not be found
+ * in the table the routine will return a NULL pointer. All XId's are relative
+ * to the currently active Display.
+ */
+XPointer XLookUpAssoc(dpy, table, x_id)
+ register Display *dpy;
+ register XAssocTable *table; /* XAssocTable to search in. */
+ register XID x_id; /* XId to search for. */
+{
+ int hash;
+ register XAssoc *bucket;
+ register XAssoc *Entry;
+
+ /* Hash the XId to get the bucket number. */
+ hash = x_id & (table->size - 1);
+ /* Look up the bucket to get the entries in that bucket. */
+ bucket = &table->buckets[hash];
+ /* Get the first entry in the bucket. */
+ Entry = bucket->next;
+
+ /* Scan through the entries in the bucket for the right XId. */
+ for (; Entry != bucket; Entry = Entry->next) {
+ if (Entry->x_id == x_id) {
+ /* We have the right XId. */
+ if (Entry->display == dpy) {
+ /* We have the right display. */
+ /* We have the right entry! */
+ return(Entry->data);
+ }
+ /* Oops, identical XId's on different displays! */
+ continue;
+ }
+ if (Entry->x_id > x_id) {
+ /* We have gone past where it should be. */
+ /* It is apparently not in the table. */
+ return(NULL);
+ }
+ }
+ /* It is apparently not in the table. */
+ return(NULL);
+}
+
diff --git a/nx-X11/lib/oldX/XMakeAssoc.c b/nx-X11/lib/oldX/XMakeAssoc.c
new file mode 100644
index 000000000..40b3562f6
--- /dev/null
+++ b/nx-X11/lib/oldX/XMakeAssoc.c
@@ -0,0 +1,113 @@
+/* $Xorg: XMakeAssoc.c,v 1.4 2001/02/09 02:04:05 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.
+
+*/
+/* $XFree86: xc/lib/oldX/XMakeAssoc.c,v 1.3 2001/01/17 19:43:38 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "X11/Xlibint.h"
+#include "X10.h"
+
+/*
+ * XMakeAssoc - Insert data into an XAssocTable keyed on an XId.
+ * Data is inserted into the table only once. Redundant inserts are
+ * meaningless (but cause no problems). The queue in each association
+ * bucket is sorted (lowest XId to highest XId).
+ */
+int
+XMakeAssoc(dpy, table, x_id, data)
+ register Display *dpy;
+ register XAssocTable *table;
+ register XID x_id;
+ register XPointer data;
+{
+ int hash;
+ register XAssoc *bucket;
+ register XAssoc *Entry;
+ register XAssoc *new_entry;
+
+ /* Hash the XId to get the bucket number. */
+ hash = x_id & (table->size - 1);
+ /* Look up the bucket to get the entries in that bucket. */
+ bucket = &table->buckets[hash];
+ /* Get the first entry in the bucket. */
+ Entry = bucket->next;
+
+ /* If (Entry != bucket), the bucket is empty so make */
+ /* the new entry the first entry in the bucket. */
+ /* if (Entry == bucket), the we have to search the */
+ /* bucket. */
+ if (Entry != bucket) {
+ /* The bucket isn't empty, begin searching. */
+ /* If we leave the for loop then we have either passed */
+ /* where the entry should be or hit the end of the bucket. */
+ /* In either case we should then insert the new entry */
+ /* before the current value of "Entry". */
+ for (; Entry != bucket; Entry = Entry->next) {
+ if (Entry->x_id == x_id) {
+ /* Entry has the same XId... */
+ if (Entry->display == dpy) {
+ /* Entry has the same Display... */
+ /* Therefore there is already an */
+ /* entry with this XId and Display, */
+ /* reset its data value and return. */
+ Entry->data = data;
+ return 0;
+ }
+ /* We found an association with the right */
+ /* id but the wrong display! */
+ continue;
+ }
+ /* If the current entry's XId is greater than the */
+ /* XId of the entry to be inserted then we have */
+ /* passed the location where the new XId should */
+ /* be inserted. */
+ if (Entry->x_id > x_id) break;
+ }
+ }
+
+ /* If we are here then the new entry should be inserted just */
+ /* before the current value of "Entry". */
+ /* Create a new XAssoc and load it with new provided data. */
+ new_entry = (XAssoc *)Xmalloc(sizeof(XAssoc));
+ if (new_entry == NULL) {
+ /* Malloc failed! */
+ errno = ENOMEM;
+ _XIOError(dpy);
+ }
+ new_entry->display = dpy;
+ new_entry->x_id = x_id;
+ new_entry->data = data;
+
+ /* Insert the new entry. */
+ new_entry->prev = Entry->prev;
+ new_entry->next = Entry;
+ Entry->prev->next = new_entry;
+ Entry->prev = new_entry;
+ return 0;
+}
+
diff --git a/nx-X11/lib/oldX/oldX-def.cpp b/nx-X11/lib/oldX/oldX-def.cpp
new file mode 100644
index 000000000..a975984e4
--- /dev/null
+++ b/nx-X11/lib/oldX/oldX-def.cpp
@@ -0,0 +1,11 @@
+LIBRARY OLDX
+VERSION LIBRARY_VERSION
+EXPORTS
+ XDraw
+ XDrawFilled
+ XCreateAssocTable
+ XDeleteAssoc
+ XDestroyAssocTable
+ XLookUpAssoc
+ XMakeAssoc
+/* $Xorg: oldX-def.cpp,v 1.3 2000/08/17 19:46:42 cpqbld Exp $ */
diff --git a/nx-X11/lib/psres/Imakefile b/nx-X11/lib/psres/Imakefile
new file mode 100644
index 000000000..158cd116e
--- /dev/null
+++ b/nx-X11/lib/psres/Imakefile
@@ -0,0 +1,34 @@
+XCOMM $XFree86: xc/lib/psres/Imakefile,v 1.3 2000/02/15 01:44:57 dawes Exp $
+
+#define DoNormalLib NormalLibPSRes
+#define DoSharedLib SharedLibPSRes
+#define DoExtraLib SharedLibPSRes
+#define DoDebugLib DebugLibPSRes
+#define DoProfileLib ProfileLibPSRes
+#define LibName psres
+#define SoRev SOPSRESREV
+#define LibHeaders NO
+
+#ifdef SharedPSResReqs
+REQUIREDLIBS = SharedPSResReqs
+#endif
+
+ PSWRAP = $(TOP)/config/pswrap/pswrap
+
+
+#if Malloc0ReturnsNull
+ ALLOC_DEFS = -DMALLOC_0_RETURNS_NULL
+#else
+ ALLOC_DEFS =
+#endif
+
+ DEFINES = -DXENVIRONMENT $(ALLOC_DEFS)
+
+SRCS = PSres.c
+
+OBJS = PSres.o
+
+#include <Library.tmpl>
+
+DependTarget()
+
diff --git a/nx-X11/lib/psres/PSres.c b/nx-X11/lib/psres/PSres.c
new file mode 100644
index 000000000..b7fd4acba
--- /dev/null
+++ b/nx-X11/lib/psres/PSres.c
@@ -0,0 +1,1661 @@
+/*
+ * PSres.c
+ *
+ * (c) Copyright 1991-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86: xc/lib/psres/PSres.c,v 1.4tsi Exp $ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef XENVIRONMENT
+#include <X11/Xos.h>
+#else
+#include <string.h>
+#include <sys/types.h>
+#endif
+
+#define USE_POSIX
+
+#ifdef NeXT
+#undef USE_POSIX
+#endif /* NeXT */
+
+#ifdef USE_POSIX
+#include <dirent.h>
+#else
+#include <sys/dir.h>
+#endif
+
+#include <sys/stat.h>
+#include <DPS/PSres.h>
+
+#ifndef PSRES_NAME
+#define PSRES_NAME "PSres.upr"
+#endif /* PSRES_NAME */
+
+#ifndef PSRES_EXT
+#define PSRES_EXT ".upr"
+#endif /* PSRES_EXT */
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif /* SEEK_SET */
+
+/* MT is the right pointer type to pass to memcpy, MST the size type */
+#define MT void *
+#define MST size_t
+
+#define MAXLEN 256
+typedef int (*ReadContentsFunction)();
+
+char *PSResFontOutline = "FontOutline",
+ *PSResFontPrebuilt = "FontPrebuilt",
+ *PSResFontAFM = "FontAFM",
+ *PSResFontBDF = "FontBDF",
+ *PSResFontFamily = "FontFamily",
+ *PSResFontBDFSizes = "FontBDFSizes",
+ *PSResForm = "Form",
+ *PSResPattern = "Pattern",
+ *PSResEncoding = "Encoding",
+ *PSResProcSet = "ProcSet";
+
+typedef struct _ResourceNameStruct {
+ char *name;
+ char *file;
+} ResourceNameStruct, *ResourceName;
+
+typedef struct _ResourceTypeStruct {
+ char *type;
+ long fileOffset; /* -1 means not really in the file */
+ ResourceName names;
+ int nameCount;
+ int filled; /* Whether has all names or just already found names */
+ char *nameBuffer;
+ char **oldNameBuffers;
+ int oldNameCount;
+} ResourceTypeStruct, *ResourceType;
+
+typedef struct _ResourceDirectoryStruct {
+ char *directory;
+ ResourceType types;
+ int typeCount;
+ char *typeNameBuffer;
+ char *filePrefix;
+ long endOfHeader;
+ int exclusive;
+ struct _ResourceDirectoryStruct *next;
+} ResourceDirectoryStruct, *ResourceDirectory;
+
+typedef struct {
+ char *type;
+ char *name;
+} TypeName;
+
+typedef struct {
+ PSResourceEnumerator func;
+ char *type;
+ char *name;
+ char *private;
+ int done;
+} EnumeratorStruct;
+
+static ResourceDirectory resDir = NULL, lastResDir;
+static char *savedPathOverride = NULL, *savedDefaultPath = NULL;
+static PSResourceSavePolicy currentPolicy = PSSaveByType;
+static char **currentResourceTypes = NULL;
+static char *resourceTypeBuffer = NULL;
+static time_t lastModifiedTime;
+static char nullStr = '\0';
+
+/* Wrappers */
+
+static char *mymalloc(size)
+ int size;
+{
+ char *ret;
+
+#ifdef XENVIRONMENT
+#ifdef MALLOC_0_RETURNS_NULL
+ if (size < 1) size = 1;
+#endif
+#else
+ if (size < 1) size = 1; /* Better safe than sorry */
+#endif
+
+ ret = (char *) malloc((unsigned) size);
+ if (ret != NULL) return ret;
+ (void) fprintf(stderr, "malloc failed\n");
+ exit(1);
+ return NULL;
+}
+
+PSResMallocProc PSResMalloc = mymalloc;
+#define MALLOC (*PSResMalloc)
+
+static char *myrealloc(ptr, size)
+ char *ptr;
+ int size;
+{
+ char *ret;
+
+#ifdef XENVIRONMENT
+#ifdef MALLOC_0_RETURNS_NULL
+ if (size < 1) size = 1;
+#endif
+#else
+ if (size < 1) size = 1; /* Better safe than sorry */
+#endif
+
+ if (ptr == NULL) return MALLOC(size);
+#ifdef NO_VOID_STAR
+ ret = (char *) realloc(ptr, (unsigned) size);
+#else
+ ret = (char *) realloc((void *) ptr, (unsigned) size);
+#endif
+ if (ret != NULL) return ret;
+ (void) fprintf(stderr, "realloc failed\n");
+ exit(1);
+ return NULL;
+}
+
+PSResReallocProc PSResRealloc = myrealloc;
+#define REALLOC (*PSResRealloc)
+
+static void myfree(ptr)
+ char *ptr;
+{
+#ifdef NO_VOID_STAR
+ if (ptr != NULL) free(ptr);
+#else
+ if (ptr != NULL) free((void *) ptr);
+#endif
+}
+
+PSResFreeProc PSResFree = myfree;
+#define FREE (*PSResFree)
+
+#define NewString(str) ((char *) strcpy(MALLOC((int) (strlen(str)+1)),(str)))
+
+static void FileWarningHandler(file, extraInfo)
+ char *file;
+ char *extraInfo;
+{
+ fprintf(stderr,
+ "Syntax error found in PostScript resource file %s:\n %s\n",
+ file, extraInfo);
+}
+
+PSResFileWarningHandlerProc PSResFileWarningHandler = FileWarningHandler;
+
+/* Just like fgets, but strips trailing newline, eliminates trailing comments,
+ skips trailing white space, skips blank lines, and chops lines longer
+ than size */
+
+static char *myfgets(buf, size, f)
+ char *buf;
+ register int size;
+ FILE *f;
+{
+ register int ch;
+ register int count = 0;
+
+#define STRIP_BLANKS \
+ while (--count >= 0 && (buf[count] == ' ' || buf[count] == '\t')) \
+ buf[count] = '\0';
+#define RETURN_BUF \
+ if (buf[0] != '\0') return buf; \
+ else return myfgets(buf, size, f);
+
+ if (size == 0) return buf;
+ size--;
+
+ while (count < size) {
+ ch = getc(f);
+ if (ch == EOF) {
+ buf[count] = '\0';
+ STRIP_BLANKS;
+ return NULL;
+ }
+ if (ch == '\n') {
+ buf[count] = '\0';
+ STRIP_BLANKS;
+ RETURN_BUF;
+ }
+ if (ch == '%') { /* Comment */
+ if (count == 0 || buf[count-1] != '\\') {
+ buf[count] = '\0';
+ do {
+ ch = getc(f);
+ } while (ch != EOF && ch != '\n');
+ STRIP_BLANKS;
+ if (ch == EOF) return NULL;
+ else RETURN_BUF;
+ }
+ }
+
+ buf[count] = ch;
+ count++;
+ }
+
+ /* Overflow, flush */
+ buf[count] = '\0';
+ do {
+ ch = getc(f);
+ } while (ch != EOF && ch != '\n');
+ STRIP_BLANKS;
+ if (ch == EOF) return NULL;
+ else RETURN_BUF;
+#undef RETURN_BUF
+#undef STRIP_BLANKS
+}
+
+static int Dequote(buf, dontDequote)
+ char *buf;
+ char dontDequote;
+{
+ char *dst = buf, *src = buf;
+
+ while (*src != '\0') {
+ if (*src == '\\') {
+ src++;
+ if (*src == '\0') {
+ *dst = '\0';
+ return 1;
+ } else if (*src == dontDequote) *dst++ = '\\';
+ }
+ *dst++ = *src++;
+ }
+ *dst = '\0';
+ return 0;
+}
+
+/* Sep returns the first unquoted position of the break character. The
+ dontDequote character only applies after the break character. If the
+ separator character is doubled, doubleSep is set to 1 and only one
+ of the separators is installed */
+
+static int DequoteAndBreak(buf, sep, bchar, dontDequote, doubleSep)
+ char *buf;
+ char **sep;
+ char bchar;
+ char dontDequote;
+ int *doubleSep;
+{
+ char *dst = buf, *src = buf;
+
+ *doubleSep = 0;
+ *sep = NULL;
+
+ while (*src != '\0') {
+ if (*src == '\\') {
+ src++;
+ if (*src == '\0') {
+ *dst = '\0';
+ return 1;
+ } else if (*src == dontDequote && *sep != NULL) *dst++ = '\\';
+ } else if (*sep == NULL && *src == bchar) {
+ *sep = dst;
+ if (*(src+1) == bchar) {
+ src++;
+ *doubleSep = 1;
+ }
+ }
+ *dst++ = *src++;
+ }
+ *dst = '\0';
+ return 0;
+}
+
+static float ParseVersion(f, excl)
+ FILE *f;
+ int *excl;
+{
+ char inBuf[MAXLEN];
+ float version = 0.0;
+ int count;
+
+ if (myfgets(inBuf, MAXLEN, f) == NULL) return 0.0;
+
+ /* Compare against magic value */
+
+ count = sscanf(inBuf, "PS-Resources-Exclusive-%f", &version);
+ if (count == 1) {
+ *excl = 1;
+ return version;
+ }
+ count = sscanf(inBuf, "PS-Resources-%f", &version);
+ if (count == 1) {
+ *excl = 0;
+ return version;
+ }
+ return 0.0;
+}
+
+static int ParseResourceTypes(f, dir)
+ FILE *f;
+ ResourceDirectory dir;
+{
+ char inBuf[MAXLEN];
+ char typebuf[MAXLEN];
+ char *types = typebuf;
+ int buflen = MAXLEN, typelen = 0, len;
+ int count, i;
+ int continued = 0, precontinued = 0;
+
+ typebuf[0] = '\0';
+ count = 0;
+
+ while (1) {
+ if (myfgets(inBuf, MAXLEN, f) == NULL) {
+ if (types != typebuf) FREE((char *) types);
+ return 1;
+ }
+ if (strcmp(inBuf, ".") == 0) break;
+ precontinued = continued;
+ continued = Dequote(inBuf, '\0');
+
+ len = strlen(inBuf);
+ if (typelen + len + 1 > buflen) {
+ if (types == typebuf) {
+ types = (char *) MALLOC(2*MAXLEN);
+ (void) memcpy((MT) types, (MT) typebuf, (MST) typelen);
+ } else types = REALLOC(types, buflen+MAXLEN);
+ buflen += MAXLEN;
+ }
+
+ if (precontinued) typelen--; /* Write over previous \0 */
+ else count++;
+ (void) strncpy(&types[typelen], inBuf, len+1);
+ typelen += len+1;
+ }
+
+ dir->typeCount = count;
+ if (count == 0) dir->types = NULL;
+ else {
+ dir->types = (ResourceType)
+ MALLOC((int) (count * sizeof(ResourceTypeStruct)));
+ dir->typeNameBuffer = (char *) MALLOC(typelen);
+ (void) memcpy((MT) dir->typeNameBuffer, (MT) types, (MST) typelen);
+ }
+
+ len = 0;
+ for (i = 0; i < count; i++) {
+ dir->types[i].type = &(dir->typeNameBuffer[len]);
+ dir->types[i].fileOffset = 0;
+ dir->types[i].names = NULL;
+ dir->types[i].nameBuffer = NULL;
+ dir->types[i].filled = 0;
+ dir->types[i].oldNameBuffers = NULL;
+ dir->types[i].oldNameCount = 0;
+ dir->types[i].nameCount = 0;
+ len += strlen(dir->types[i].type) + 1;
+ }
+
+ if (types != typebuf) FREE((char *) types);
+ return 0;
+}
+
+static int ParseFilePrefix(f, dir, dirName)
+ FILE *f;
+ ResourceDirectory dir;
+ char *dirName;
+{
+ char inBuf[MAXLEN];
+ int continued;
+ int len;
+ long savePos;
+ char *prefix;
+
+ dir->filePrefix = NULL;
+
+ savePos = ftell(f);
+ if (myfgets(inBuf, MAXLEN, f) == NULL) return 1;
+
+ if (inBuf[0] != '/') {
+ if (fseek(f, savePos, SEEK_SET) == -1) return 1;
+ len = strlen(dirName);
+ dir->filePrefix = strcpy((char *) MALLOC(len+2), dirName);
+ dir->filePrefix[len] = '/';
+ dir->filePrefix[len+1] = '\0';
+ return 0;
+ }
+
+ continued = Dequote(inBuf, '\0');
+ prefix = inBuf+1;
+ len = strlen(prefix);
+ dir->filePrefix = (char *) strcpy((char *) MALLOC(len+2), prefix);
+ if (!continued) {
+ dir->filePrefix[len] = '/';
+ dir->filePrefix[len+1] = '\0';
+ return 0;
+ }
+
+ while (1) {
+ if (myfgets(inBuf, MAXLEN, f) == NULL) return 1;
+ continued = Dequote(inBuf, '\0');
+ len += strlen(inBuf);
+ dir->filePrefix = (char *) REALLOC(dir->filePrefix, len+2);
+ (void) strcat(dir->filePrefix, inBuf);
+ if (!continued) {
+ dir->filePrefix[len] = '/';
+ dir->filePrefix[len+1] = '\0';
+ return 0;
+ }
+ }
+}
+
+static ResourceDirectory ParseHeader(f, dirName, fileName)
+ FILE *f;
+ char *dirName, *fileName;
+{
+ ResourceDirectory dir;
+ float version;
+ int exclusive;
+
+ rewind(f);
+
+ version = ParseVersion(f, &exclusive);
+ if (version < 1.0) return NULL;
+
+ dir = (ResourceDirectory) MALLOC(sizeof(ResourceDirectoryStruct));
+ dir->directory = (char *) NewString(fileName);
+ dir->exclusive = exclusive;
+ dir->next = NULL;
+
+ if (ParseResourceTypes(f, dir)) {
+ FREE((char *) dir->directory);
+ FREE((char *) dir);
+ return NULL;
+ }
+
+ if (ParseFilePrefix(f, dir, dirName)) dir->endOfHeader = 0;
+ else dir->endOfHeader = ftell(f);
+
+ return dir;
+}
+
+/* Store away old name buffer so pointers to it do not become invalid */
+
+static void CacheOldNames(type)
+ ResourceType type;
+{
+ type->oldNameCount++;
+ type->oldNameBuffers = (char **) REALLOC((char *) type->oldNameBuffers,
+ type->oldNameCount);
+ type->oldNameBuffers[type->oldNameCount-1] = type->nameBuffer;
+ type->nameBuffer = NULL;
+}
+
+/* Verify that the name matches the name in the file */
+
+static int VerifyName(f, name)
+ FILE *f;
+ char *name;
+{
+ char inBuf[MAXLEN];
+ int continued = 0;
+ int len;
+ int start = 0;
+
+ while (1) {
+ if (myfgets(inBuf, MAXLEN, f) == NULL) return 1;
+ continued = Dequote(inBuf, '\0');
+ if (continued) {
+ len = strlen(inBuf);
+ if (strncmp(inBuf, &name[start], len) != 0) return 1;
+ start += len;
+ } else {
+ if (strcmp(inBuf, &name[start]) != 0) return 1;
+ else break;
+ }
+ }
+ return 0;
+}
+
+static int LookupResourceInList(type, name)
+ ResourceType type;
+ char *name;
+{
+ int i;
+
+ for (i = 0; i < type->nameCount; i++) {
+ if (strcmp(name, type->names[i].name) == 0) return 1;
+ }
+ return 0;
+}
+
+static int CheckInsertPrefix(type)
+ char *type;
+{
+ /* Insert the prefix unless one of these special values */
+
+ if (strcmp(type, PSResFontFamily) == 0 ||
+ strcmp(type, PSResFontBDFSizes) == 0 ||
+ strcmp(type, "FontAxes") == 0 ||
+ strcmp(type, "FontBlendMap") == 0 ||
+ strcmp(type, "FontBlendPositions") == 0 ||
+ strcmp(type, "mkpsresPrivate") == 0) return 0;
+ return 1;
+}
+
+/* Returns a line, including continuations. Memory must be copied before
+ calling this again. */
+
+static int linebuflen = 0;
+static char *inputline = NULL;
+
+static char *ReadFullLine(f)
+ FILE *f;
+{
+ char readbuf[MAXLEN];
+ int start = 0;
+ int len;
+
+ while (1) {
+ if (myfgets(readbuf, MAXLEN, f) == NULL) return NULL;
+ len = strlen(readbuf);
+ if (start + len + 1 > linebuflen) {
+ linebuflen += MAXLEN + 1;
+ inputline = REALLOC(inputline, linebuflen);
+ }
+ strncpy(inputline+start, readbuf, len+1);
+
+ if (inputline[start+len-1] != '\\') break;
+
+ start = start+len-1;
+ }
+ return inputline;
+}
+
+static void FreeLineBuf()
+{
+ if (inputline != NULL) FREE(inputline);
+ inputline = NULL;
+ linebuflen = 0;
+}
+
+/* Assumes being correctly positioned in the file */
+
+static int ReadResourceSection(f, dir, type, name)
+ FILE *f;
+ ResourceDirectory dir;
+ ResourceType type;
+ char *name; /* If NULL, enumerate */
+{
+#define GROW 1000
+ char *linein;
+ int start;
+ int len;
+ char namebuf[GROW];
+ char *names = namebuf;
+ int buflen = GROW, namelen = 0;
+ int i, count = 0;
+ char *sep;
+ int prefixLen;
+ int insertPrefix;
+ char dontDequote;
+ int doubleEquals;
+ int addingPrefix;
+ int newsize;
+
+ if (type->nameBuffer != NULL) CacheOldNames(type);
+
+ insertPrefix = CheckInsertPrefix(type->type);
+ if (insertPrefix) {
+ prefixLen = strlen(dir->filePrefix);
+ dontDequote = '\0';
+ } else {
+ prefixLen = 0;
+ dontDequote = ',';
+ }
+
+ while (1) {
+ start = namelen;
+
+ linein = ReadFullLine(f);
+ if (linein == NULL) {
+ if (names != namebuf) FREE((char *) names);
+ FreeLineBuf();
+ return 1;
+ }
+ if (strcmp(linein, ".") == 0) break;
+
+ sep = NULL;
+ (void) DequoteAndBreak(linein, &sep, '=', dontDequote, &doubleEquals);
+
+ /* If no separator, a bogus line */
+ if (sep == NULL) continue;
+
+ /* Next line is UNIX specific! */
+ addingPrefix = *(sep+1) != '/' && insertPrefix && !doubleEquals;
+
+ len = strlen(linein) + 1 + (addingPrefix ? prefixLen : 0);
+
+ if (namelen + len >= buflen) {
+ newsize = buflen + GROW;
+ if (namelen + len > newsize) newsize = namelen + len;
+
+ if (names == namebuf) {
+ names = (char *) MALLOC(newsize);
+ (void) memcpy((MT) names, (MT) namebuf, (MST) namelen);
+ } else names = REALLOC(names, newsize);
+ buflen = newsize;
+ }
+
+ *sep = '\0';
+ len = strlen(linein);
+ (void) strncpy(&names[namelen], linein, len+1);
+ namelen += len+1;
+
+ if (addingPrefix) {
+ (void) strncpy(&names[namelen], dir->filePrefix, prefixLen);
+ namelen += prefixLen;
+ }
+
+ len = strlen(sep+1);
+ (void) strncpy(&names[namelen], sep+1, len+1);
+ namelen += len+1;
+
+ if (name != NULL && strcmp(names, name) != 0) namelen = start;
+ else count++;
+ }
+
+ type->nameCount = count;
+ if (count == 0) type->names = NULL;
+ else {
+ type->names = (ResourceName)
+ MALLOC((int) (count * sizeof(ResourceNameStruct)));
+ type->nameBuffer = (char *) MALLOC(namelen);
+ (void) memcpy((MT) type->nameBuffer, (MT) names, (MST) namelen);
+ }
+
+ len = 0;
+ for (i = 0; i < count; i++) {
+ type->names[i].name = &(type->nameBuffer[len]);
+ len += strlen(type->names[i].name) + 1;
+ type->names[i].file = &(type->nameBuffer[len]);
+ len += strlen(type->names[i].file) + 1;
+ }
+
+ if (names != namebuf) FREE((char *) names);
+ if (name == NULL) type->filled = 1;
+ FreeLineBuf();
+ return 0;
+
+#undef GROW
+}
+
+/* Assumes being correctly positioned in the file */
+
+static int SkipResourceSection(f, dir, type, checkName)
+ FILE *f;
+ ResourceDirectory dir;
+ ResourceType type;
+ int checkName;
+{
+ char inBuf[MAXLEN];
+ int i;
+
+ /* If next type has offset, just go there */
+
+ for (i = 0; i < dir->typeCount && dir->types + i != type; i++) {}
+
+ if (dir->types + i == type) {
+ for (i++; i < dir->typeCount; i++) {
+ if (dir->types[i].fileOffset == -1) continue;
+ if (dir->types[i].fileOffset > 0) {
+ if (fseek(f, dir->types[i].fileOffset, SEEK_SET) != -1) {
+ return 0;
+ } else break;
+ }
+ }
+ }
+
+ if (checkName && VerifyName(f, type->type) != 0) return 1;
+
+ while (1) {
+ if (myfgets(inBuf, MAXLEN, f) == NULL) return 1;
+ if (strcmp(inBuf, ".") == 0) return 0;
+ }
+}
+
+/* Assumes being correctly positioned in the file */
+
+static int ParseResourceSection(f, dir, type, name, checkName)
+ FILE *f;
+ ResourceDirectory dir;
+ ResourceType type;
+ char *name; /* If NULL, enumerate */
+ int checkName;
+{
+ if (checkName && VerifyName(f, type->type) != 0) return 1;
+
+ if (type->filled || (name != NULL && LookupResourceInList(type, name))) {
+ return SkipResourceSection(f, dir, type, 0);
+ }
+
+ return ReadResourceSection(f, dir, type, name);
+}
+
+void FreePSResourceStorage(everything)
+ int everything;
+{
+ ResourceDirectory d;
+ ResourceType t;
+ int i, j;
+
+ if (resDir == NULL) return;
+
+ for (d = resDir; d != NULL; d = d->next) {
+ for (i = 0; i < d->typeCount; i++) {
+ t = d->types + i;
+ FREE(t->nameBuffer);
+ FREE((char *) t->names);
+ t->nameCount = 0;
+ for (j = 0; j < t->oldNameCount; j++) FREE(t->oldNameBuffers[j]);
+ if (t->oldNameBuffers != NULL) FREE((char *) t->oldNameBuffers);
+ t->oldNameCount = 0;
+ t->nameCount = 0;
+ t->filled = 0;
+ }
+ }
+
+ if (!everything) return;
+
+ while (resDir != NULL) {
+ d = resDir->next;
+ FREE(resDir->directory);
+ FREE((char *) resDir->types);
+ FREE(resDir->typeNameBuffer);
+ FREE(resDir->filePrefix);
+ FREE((char *) resDir);
+ resDir = d;
+ }
+ lastResDir = NULL;
+ FREE(savedPathOverride);
+ savedPathOverride = NULL;
+ FREE(savedDefaultPath);
+ savedDefaultPath = NULL;
+}
+
+static ResourceDirectory ReadAndStoreFile(dir, name, len, readFunc, data)
+ char *dir, *name;
+ int len;
+ ReadContentsFunction readFunc;
+ char *data;
+{
+ ResourceDirectory rd = NULL;
+ FILE *f;
+ char nameBuf[MAXLEN];
+ char *fullName = nameBuf;
+ int fullLen;
+
+ fullLen = len + strlen(name) + 1;
+ if (fullLen >= MAXLEN) fullName = MALLOC(fullLen+1);
+ (void) strcpy(fullName, dir);
+ fullName[len] = '/';
+ (void) strcpy(fullName+len+1, name);
+
+ f = fopen(fullName, "r");
+ if (f != NULL) {
+ rd = ParseHeader(f, dir, fullName);
+
+ if (rd != NULL) {
+ if (resDir == NULL) resDir = rd;
+ else lastResDir->next = rd;
+ lastResDir = rd;
+ if (readFunc != NULL) (*readFunc) (f, rd, data);
+ } else (*PSResFileWarningHandler)(fullName, "Malformed header");
+ (void) fclose(f);
+ }
+ if (fullName != nameBuf) FREE(fullName);
+ return rd;
+}
+
+static time_t ReadFilesInDirectory(dirName, readFunc, data)
+ char *dirName;
+ ReadContentsFunction readFunc;
+ char *data;
+{
+ DIR *dir;
+#ifdef USE_POSIX
+ struct dirent *d;
+#else
+ struct direct *d;
+#endif
+ ResourceDirectory rd;
+ int len = strlen(dirName);
+ static int extensionLen = 0;
+ struct stat buf;
+ int namelen;
+
+ if (extensionLen == 0) extensionLen = strlen(PSRES_EXT);
+ if (stat(dirName, &buf) != 0) buf.st_mtime = 0;
+
+ rd = ReadAndStoreFile(dirName, PSRES_NAME, len, readFunc, data);
+
+ if (rd != 0 && rd->exclusive) return buf.st_mtime;
+
+ dir = opendir(dirName);
+ if (dir == NULL) return buf.st_mtime;
+
+ while ((d = readdir(dir)) != NULL) {
+ namelen = strlen(d->d_name);
+ if (namelen < extensionLen) continue;
+
+ if (strcmp(d->d_name + (namelen - extensionLen), PSRES_EXT) == 0
+ && strcmp(d->d_name, PSRES_NAME) != 0) {
+ (void) ReadAndStoreFile(dirName, d->d_name, len, readFunc, data);
+ }
+ }
+ (void) closedir(dir);
+ return buf.st_mtime;
+}
+
+/* Returns nonzero if current paths different from saved ones */
+
+static int SetUpSavedPaths(pathOverride, defaultPath)
+ char *pathOverride;
+ char *defaultPath;
+{
+ if (pathOverride == NULL) pathOverride = &nullStr;
+ if (defaultPath == NULL) defaultPath = &nullStr;
+
+ if (savedPathOverride == NULL ||
+ strcmp(pathOverride, savedPathOverride) != 0 ||
+ strcmp(defaultPath, savedDefaultPath) != 0) {
+
+ FreePSResourceStorage(1);
+
+ savedPathOverride = NewString(pathOverride);
+ savedDefaultPath = NewString(defaultPath);
+
+ return 1;
+ }
+ return 0;
+}
+
+/* Like SetUpSavedPaths, but never affects saved state */
+
+static int CheckSavedPaths(pathOverride, defaultPath)
+ char *pathOverride;
+ char *defaultPath;
+{
+ if (pathOverride == NULL) pathOverride = &nullStr;
+ if (defaultPath == NULL) defaultPath = &nullStr;
+
+ if (savedPathOverride == NULL ||
+ strcmp(pathOverride, savedPathOverride) != 0 ||
+ strcmp(defaultPath, savedDefaultPath) != 0) return 1;
+ else return 0;
+}
+
+static time_t ReadFilesInPath(string, readFunc, data)
+ char *string;
+ ReadContentsFunction readFunc;
+ char *data;
+{
+ char *pathChar;
+ char pathBuf[MAXLEN];
+ char *path;
+ register char *dir;
+ int len;
+ register char ch;
+ time_t newTime, latestTime = 0;
+
+ pathChar = string;
+
+ if (*pathChar == ':') pathChar++;
+
+ len = strlen(pathChar);
+ if (len < MAXLEN) path = pathBuf;
+ else path = MALLOC(len+1);
+
+ do {
+ dir = path;
+ do {
+ while (*pathChar == '\\') {
+ pathChar++;
+ if (*pathChar != '\0') *dir++ = *pathChar++;
+ }
+
+ *dir++ = ch = *pathChar++;
+ } while (ch != '\0' && ch != ':');
+ if (ch == ':') *(dir-1) = '\0';
+
+ if (*path == '\0') {
+ if (ch == ':' && string != savedDefaultPath) {
+ newTime = ReadFilesInPath(savedDefaultPath, readFunc, data);
+ if (newTime > latestTime) latestTime = newTime;
+ }
+ } else {
+ newTime = ReadFilesInDirectory(path, readFunc, data);
+ if (newTime > latestTime) latestTime = newTime;
+ }
+ } while (ch == ':');
+ if (path != pathBuf) FREE(path);
+ return latestTime;
+}
+
+static time_t MaxTimeInPath(string)
+ char *string;
+{
+ char *pathChar;
+ char pathBuf[MAXLEN];
+ char *path;
+ register char *dir;
+ int len;
+ register char ch;
+ time_t latestTime = 0;
+ struct stat buf;
+
+ pathChar = string;
+
+ if (*pathChar == ':') pathChar++;
+
+ len = strlen(pathChar);
+ if (len < MAXLEN) path = pathBuf;
+ else path = MALLOC(len+1);
+
+ do {
+ dir = path;
+ do {
+ while (*pathChar == '\\') {
+ pathChar++;
+ if (*pathChar != '\0') *dir++ = *pathChar++;
+ }
+
+ *dir++ = ch = *pathChar++;
+ } while (ch != '\0' && ch != ':');
+ if (ch == ':') *(dir-1) = '\0';
+
+ if (*path == '\0') {
+ if (ch == ':' && string != savedDefaultPath) {
+ buf.st_mtime = MaxTimeInPath(savedDefaultPath);
+ if (buf.st_mtime > latestTime) latestTime = buf.st_mtime;
+ }
+ } else {
+ if (stat(path, &buf) != 0) buf.st_mtime = 0;
+ if (buf.st_mtime > latestTime) latestTime = buf.st_mtime;
+ }
+ } while (ch == ':');
+ if (path != pathBuf) FREE(path);
+ return latestTime;
+}
+
+static char *GetPath()
+{
+ static char defaultEnvironmentPath[] = "::";
+ static char *environmentPath = NULL;
+
+ if (savedPathOverride != NULL && *savedPathOverride != '\0') {
+ return savedPathOverride;
+ }
+
+ if (environmentPath == NULL) {
+ environmentPath = getenv("PSRESOURCEPATH");
+ if (environmentPath == NULL) environmentPath = defaultEnvironmentPath;
+ }
+
+ return environmentPath;
+}
+
+void SetPSResourcePolicy(policy, willList, resourceTypes)
+ PSResourceSavePolicy policy;
+ int willList;
+ char **resourceTypes;
+{
+ currentPolicy = policy;
+
+ if (currentResourceTypes != NULL) FREE((char *) currentResourceTypes);
+ if (resourceTypeBuffer != NULL) FREE((char *) resourceTypeBuffer);
+
+ if (resourceTypes == NULL) {
+ currentResourceTypes = NULL;
+ resourceTypeBuffer = NULL;
+ } else {
+ int i = 0, len = 0;
+ char **cp = resourceTypes;
+
+ while (*cp != NULL) {
+ i++;
+ len += strlen(*cp) + 1;
+ cp++;
+ }
+
+ currentResourceTypes =
+ (char **) MALLOC((int) ((i+1) * sizeof(char *)));
+ resourceTypeBuffer = MALLOC(len);
+
+ len = 0;
+ i = 0;
+ cp = resourceTypes;
+
+ while (*cp != NULL) {
+ (void) strcpy(resourceTypeBuffer+len, *cp);
+ currentResourceTypes[i++] = resourceTypeBuffer + len;
+ len += strlen(*cp) + 1;
+ cp++;
+ }
+ currentResourceTypes[i] = NULL;
+ }
+}
+
+int InSavedList(type)
+ char *type;
+{
+ char **cp = currentResourceTypes;;
+
+ if (cp == NULL) return 0;
+
+ while (*cp != NULL) {
+ if (strcmp(*cp++, type) == 0) return 1;
+ }
+ return 0;
+}
+
+/* ARGSUSED */
+static int ReadEverything(f, rd, data)
+ FILE *f;
+ ResourceDirectory rd;
+ char *data;
+{
+ int i;
+ ResourceType t;
+ long pos;
+
+ /* We're at the start of the resource section; read all of them */
+
+ for (i = 0; i < rd->typeCount; i++) {
+ t = &rd->types[i];
+
+ if (t->fileOffset == -1) continue; /* Not really there */
+
+ if (t->fileOffset != 0 && fseek(f, t->fileOffset, SEEK_SET) != -1) {
+ if (!t->filled) {
+ if (ParseResourceSection(f, rd, t, (char *) NULL, 1)) {
+ char buf[256];
+ sprintf(buf, "Trouble parsing resource type %s", t->type);
+ PSResFileWarningHandler(rd->directory, buf);
+ return 1;
+ }
+ } else {
+ if (SkipResourceSection(f, rd, t, 1)) {
+ char buf[256];
+ sprintf(buf, "Trouble parsing resource type %s", t->type);
+ PSResFileWarningHandler(rd->directory, buf);
+ return 1;
+ }
+ }
+ continue;
+ }
+
+ pos = ftell(f);
+ if (VerifyName(f, t->type) == 0) {
+ t->fileOffset = pos;
+ if (ParseResourceSection(f, rd, t, (char *) NULL, 0)) {
+ char buf[256];
+ sprintf(buf, "Trouble parsing resource type %s", t->type);
+ PSResFileWarningHandler(rd->directory, buf);
+ return 1;
+ }
+ } else {
+ /* No resources of this type; try the next type */
+ t->fileOffset = -1;
+ if (fseek(f, pos, SEEK_SET)) {
+ PSResFileWarningHandler(rd->directory,
+ "File changed during execution");
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+static int ReadType(f, rd, type)
+ FILE *f;
+ ResourceDirectory rd;
+ char *type;
+{
+ int i;
+ ResourceType t;
+ long pos;
+
+ /* We're at the start of the resource section; read the sections that
+ are in the cached type list or are the passed in type */
+
+ for (i = 0; i < rd->typeCount; i++) {
+ t = &rd->types[i];
+
+ if (t->fileOffset == -1) continue; /* Not really there */
+ if (t->fileOffset != 0 && fseek(f, t->fileOffset, SEEK_SET) != -1) {
+ if (!t->filled &&
+ (strcmp(t->type, type) == 0 || InSavedList(t->type))) {
+ if (ParseResourceSection(f, rd, t, (char *) NULL, 1)) {
+ char buf[256];
+ sprintf(buf, "Trouble parsing resource type %s", t->type);
+ PSResFileWarningHandler(rd->directory, buf);
+ return 1;
+ }
+ } else if (SkipResourceSection(f, rd, t, 1)) {
+ char buf[256];
+ sprintf(buf, "Trouble parsing resource type %s", t->type);
+ PSResFileWarningHandler(rd->directory, buf);
+ return 1;
+ }
+ continue;
+ }
+
+ pos = ftell(f);
+ if (VerifyName(f, t->type) == 0) {
+ t->fileOffset = pos;
+ if (strcmp(t->type, type) == 0 || InSavedList(t->type)) {
+ if (ParseResourceSection(f, rd, t, (char *) NULL, 0)){
+ char buf[256];
+ sprintf(buf, "Trouble parsing resource type %s", t->type);
+ PSResFileWarningHandler(rd->directory, buf);
+ return 1;
+ }
+ } else if (SkipResourceSection(f, rd, t, 0)) {
+ char buf[256];
+ sprintf(buf, "Trouble parsing resource type %s", t->type);
+ PSResFileWarningHandler(rd->directory, buf);
+ return 1;
+ }
+ } else {
+ /* No resources of this type; try the next type */
+ t->fileOffset = -1;
+ if (fseek(f, pos, SEEK_SET) == -1) {
+ PSResFileWarningHandler(rd->directory,
+ "File changed during execution");
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+static int ReadName(f, rd, data)
+ FILE *f;
+ ResourceDirectory rd;
+ char *data;
+{
+ TypeName *tn = (TypeName *) data;
+ int i;
+ ResourceType t;
+ long pos;
+
+ /* We're at the start of the resource section; read the name in the
+ section for the passed in type */
+
+ for (i = 0; i < rd->typeCount; i++) {
+ t = &rd->types[i];
+
+ if (t->fileOffset == -1) continue; /* Not really there */
+ if (t->fileOffset != 0 && fseek(f, t->fileOffset, SEEK_SET)) {
+ if (strcmp(t->type, tn->type) == 0) {
+ if (ParseResourceSection(f, rd, t, tn->name, 1)) {
+ char buf[256];
+ sprintf(buf, "Trouble parsing resource type %s", t->type);
+ PSResFileWarningHandler(rd->directory, buf);
+ return 1;
+ }
+ } else if (SkipResourceSection(f, rd, t, 1)) {
+ char buf[256];
+ sprintf(buf, "Trouble parsing resource type %s", t->type);
+ PSResFileWarningHandler(rd->directory, buf);
+ return 1;
+ }
+ continue;
+ }
+
+ pos = ftell(f);
+ if (VerifyName(f, t->type) == 0) {
+ t->fileOffset = pos;
+ if (fseek(f, pos, SEEK_SET) == -1) {
+ PSResFileWarningHandler(rd->directory,
+ "File changed during execution");
+ return 1;
+ }
+ if (strcmp(t->type, tn->type) == 0) {
+ if (ParseResourceSection(f, rd, t, tn->name, 0)) {
+ char buf[256];
+ sprintf(buf, "Trouble parsing resource type %s", t->type);
+ PSResFileWarningHandler(rd->directory, buf);
+ return 1;
+ }
+ } else if (SkipResourceSection(f, rd, t, 0)) {
+ char buf[256];
+ sprintf(buf, "Trouble parsing resource type %s", t->type);
+ PSResFileWarningHandler(rd->directory, buf);
+ return 1;
+ }
+ } else {
+ /* No resources of this type; try the next type */
+ t->fileOffset = -1;
+ if (fseek(f, pos, SEEK_SET) == -1) {
+ PSResFileWarningHandler(rd->directory,
+ "File changed during execution");
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+static void ReadHeadersAndData(resourceType, resourceName)
+ char *resourceType;
+ char *resourceName;
+{
+ TypeName t;
+
+ switch (currentPolicy) {
+ case PSSaveEverything:
+ lastModifiedTime =
+ ReadFilesInPath(GetPath(), ReadEverything, (char *) NULL);
+ break;
+ case PSSaveByType:
+ lastModifiedTime =
+ ReadFilesInPath(GetPath(), ReadType, resourceType);
+ break;
+ case PSSaveReturnValues:
+ t.type = resourceType;
+ t.name = resourceName;
+ lastModifiedTime =
+ ReadFilesInPath(GetPath(), ReadName, (char *) &t);
+ break;
+ }
+}
+
+static void UpdateData(resourceType, resourceName)
+ char *resourceType;
+ char *resourceName;
+{
+ ResourceDirectory rd;
+ ResourceType rt;
+ int i;
+ FILE *f;
+ TypeName tn;
+
+ /* Make two passes; the first figures out if we're going to have to read
+ the file to service this request. If we are, open the file and read
+ in sections in the saved list (from SetPSResourcePolicy). If not
+ just saving return values, make sure we read in everything
+ in the section. */
+
+ for (rd = resDir; rd != NULL; rd = rd->next) {
+ f = NULL;
+ for (i = 0; i < rd->typeCount; i++) {
+ rt = rd->types + i;
+ if (rt->filled) continue;
+ if (strcmp(rt->type, resourceType) != 0) continue;
+
+ if (resourceName != NULL &&
+ LookupResourceInList(rt, resourceName)) continue;
+
+ f = fopen(rd->directory, "r");
+ break;
+ }
+ if (f == NULL) continue;
+
+ /* Nuts, have to read the file */
+
+ if (fseek(f, rd->endOfHeader, SEEK_SET) != -1) {
+ switch (currentPolicy) {
+ case PSSaveEverything:
+ (void) ReadEverything(f, rd, (char *) NULL);
+ break;
+ case PSSaveByType:
+ (void) ReadType(f, rd, resourceType);
+ break;
+ case PSSaveReturnValues:
+ tn.type = resourceType;
+ tn.name = resourceName;
+ (void) ReadName(f, rd, (char *) &tn);
+ break;
+ }
+ } else (*PSResFileWarningHandler)(rd->directory,
+ "File changed during execution");
+ (void) fclose(f);
+ }
+}
+
+static int FindData(resourceType, resourceName,
+ resourceNamesReturn, resourceFilesReturn)
+ char *resourceType;
+ char *resourceName;
+ char ***resourceNamesReturn;
+ char ***resourceFilesReturn;
+{
+ ResourceDirectory rd;
+ ResourceType rt;
+ int i, j, k;
+ int nameCount = 0;
+ char **names, **files;
+
+ /* Make two passes; first count, then set and return */
+
+ for (rd = resDir; rd != NULL; rd = rd->next) {
+ for (i = 0; i < rd->typeCount; i++) {
+ rt = rd->types + i;
+ if (strcmp(rt->type, resourceType) != 0) continue;
+ if (resourceName == NULL) nameCount += rt->nameCount;
+ else {
+ for (j = 0; j < rt->nameCount; j++) {
+ if (strcmp(rt->names[j].name, resourceName) == 0) {
+ nameCount++;
+ }
+ }
+ }
+ }
+ }
+
+ if (nameCount == 0) return 0;
+
+ names = (char **) MALLOC((int) (nameCount * sizeof(char *)));
+ files = (char **) MALLOC((int) (nameCount * sizeof(char *)));
+ k = 0;
+
+ for (rd = resDir; rd != NULL; rd = rd->next) {
+ for (i = 0; i < rd->typeCount; i++) {
+ rt = rd->types + i;
+ if (strcmp(rt->type, resourceType) != 0) continue;
+ for (j = 0; j < rt->nameCount; j++) {
+ if (resourceName == NULL ||
+ strcmp(rt->names[j].name, resourceName) == 0) {
+ names[k] = rt->names[j].name;
+ files[k++] = rt->names[j].file;
+ }
+ }
+ }
+ }
+
+ *resourceNamesReturn = names;
+ *resourceFilesReturn = files;
+ return nameCount;
+}
+
+extern int ListPSResourceFiles(psResourcePathOverride, defaultPath,
+ resourceType, resourceName,
+ resourceNamesReturn, resourceFilesReturn)
+ char *psResourcePathOverride;
+ char *defaultPath;
+ char *resourceType;
+ char *resourceName;
+ char ***resourceNamesReturn;
+ char ***resourceFilesReturn;
+{
+ if (SetUpSavedPaths(psResourcePathOverride, defaultPath)) {
+ ReadHeadersAndData(resourceType, resourceName);
+ } else UpdateData(resourceType, resourceName);
+ return FindData(resourceType, resourceName,
+ resourceNamesReturn, resourceFilesReturn);
+}
+
+int ListPSResourceTypes(pathOverride, defaultPath, typesReturn)
+ char *pathOverride;
+ char *defaultPath;
+ char ***typesReturn;
+{
+#define GROW 5
+#define START 15
+ int typeCount = 0, i, j, typeBufSize = 0;
+ ResourceDirectory d;
+ register char **types = NULL;
+ int sig;
+ int *sigs = NULL;
+ char *ch;
+
+ if (SetUpSavedPaths(pathOverride, defaultPath)) {
+ if (currentPolicy != PSSaveEverything) {
+ lastModifiedTime =
+ ReadFilesInPath(GetPath(), (ReadContentsFunction) NULL,
+ (char *) NULL);
+ } else lastModifiedTime =
+ ReadFilesInPath(GetPath(), ReadEverything, (char *) NULL);
+ }
+
+ for (d = resDir; d != NULL; d = d->next) {
+ for (i = 0; i < d->typeCount; i++) {
+ for (sig = 0, ch = d->types[i].type; *ch != '\0'; sig += *ch++) {}
+ for (j = 0; j < typeCount; j++) {
+ if (sig == sigs[j] &&
+ strcmp(types[j], d->types[i].type) == 0) break;
+ }
+ if (j >= typeCount) { /* Have to add */
+ if (typeCount >= typeBufSize) {
+ if (typeCount == 0) typeBufSize = START;
+ else typeBufSize += GROW;
+ types = (char **) REALLOC((char *) types,
+ typeBufSize * sizeof(char *));
+ sigs = (int *) REALLOC((char *) sigs,
+ typeBufSize * sizeof(int));
+ }
+ types[typeCount] = d->types[i].type;
+ sigs[typeCount++] = sig;
+ }
+ }
+ }
+
+ FREE((char *) sigs);
+ *typesReturn = types;
+ return typeCount;
+#undef START
+#undef GROW
+}
+
+/* Assumes being correctly positioned in the file */
+
+static int EnumerateResourceSection(f, dir, type, s, checkName)
+ FILE *f;
+ ResourceDirectory dir;
+ ResourceType type;
+ EnumeratorStruct *s;
+ int checkName;
+{
+#define GROW 1000
+ char *linein;
+ int len;
+ char namebuf[GROW];
+ char *names = namebuf;
+ int buflen = GROW, namelen = 0;
+ char *sep;
+ int prefixLen;
+ int insertPrefix;
+ char *file;
+ char dontDequote;
+ int doubleEquals;
+ int addingPrefix;
+
+ if (checkName && VerifyName(f, type->type) != 0) return 1;
+
+ insertPrefix = CheckInsertPrefix(type->type);
+ if (insertPrefix) {
+ prefixLen = strlen(dir->filePrefix);
+ dontDequote = '\0';
+ } else {
+ prefixLen = 0;
+ dontDequote = ',';
+ }
+
+ while (1) {
+ linein = ReadFullLine(f);
+ if (linein == NULL) {
+ if (names != namebuf) FREE((char *) names);
+ FreeLineBuf();
+ return 1;
+ }
+
+ if (strcmp(linein, ".") == 0) {
+ if (names != namebuf) FREE((char *) names);
+ FreeLineBuf();
+ return 0;
+ }
+
+ sep = NULL;
+ (void) DequoteAndBreak(linein, &sep, '=', dontDequote, &doubleEquals);
+
+ /* If no separator, a bogus line */
+ if (sep == NULL) continue;
+
+ /* Next line is UNIX specific! */
+ addingPrefix = *(sep+1) != '/' && insertPrefix && !doubleEquals;
+
+ len = strlen(linein) + (addingPrefix ? 0 : prefixLen) + 1;
+ if (len > buflen) {
+ if (names != namebuf) FREE((char *) names);
+ names = (char *) MALLOC(len);
+ }
+
+ *sep = '\0';
+ len = strlen(linein);
+ (void) strncpy(names, linein, len+1);
+
+ namelen = len+1;
+ file = &names[namelen];
+
+ if (addingPrefix) {
+ (void) strncpy(&names[namelen], dir->filePrefix, prefixLen);
+ namelen += prefixLen;
+ }
+
+ len = strlen(sep+1);
+ (void) strncpy(&names[namelen], sep+1, len+1);
+
+ if (s->name == NULL || strcmp(names, s->name) == 0) {
+ s->done = (*s->func) (s->type, names, file, s->private);
+ if (s->done) {
+ if (names != namebuf) FREE((char *) names);
+ FreeLineBuf();
+ return 0;
+ }
+ }
+ }
+#undef GROW
+}
+
+static int Enumerate(f, rd, data)
+ FILE *f;
+ ResourceDirectory rd;
+ char *data;
+{
+ EnumeratorStruct *s = (EnumeratorStruct *) data;
+ int i;
+ ResourceType t;
+ long pos;
+
+ if (s->done) return 0;
+
+ for (i = 0; i < rd->typeCount; i++) {
+ t = &rd->types[i];
+
+ if (t->fileOffset == -1) continue; /* Not really there */
+ if (t->fileOffset != 0 && fseek(f, t->fileOffset, SEEK_SET) != -1) {
+ if (strcmp(t->type, s->type) == 0) {
+ if (EnumerateResourceSection(f, rd, t, s, 1)) {
+ char buf[256];
+ sprintf(buf, "Trouble parsing resource type %s", t->type);
+ PSResFileWarningHandler(rd->directory, buf);
+ return 1;
+ }
+ if (s->done) return 0;;
+ } else if (SkipResourceSection(f, rd, t, 1)) {
+ char buf[256];
+ sprintf(buf, "Trouble parsing resource type %s", t->type);
+ PSResFileWarningHandler(rd->directory, buf);
+ return 1;
+ }
+ continue;
+ }
+
+ pos = ftell(f);
+ if (VerifyName(f, t->type) == 0) {
+ t->fileOffset = pos;
+ if (strcmp(t->type, s->type) == 0) {
+ if (EnumerateResourceSection(f, rd, t, s, 0)) return 1;
+ if (s->done) return 0;
+ } else if (SkipResourceSection(f, rd, t, 0)) return 1;
+ } else {
+ /* No resources of this type; try the next type */
+ t->fileOffset = -1;
+ if (fseek(f, pos, SEEK_SET) == -1) return 1;
+ }
+ }
+ return 0;
+}
+
+void EnumeratePSResourceFiles(pathOverride, defaultPath, resourceType,
+ resourceName, enumerator, private)
+ char *pathOverride;
+ char *defaultPath;
+ char *resourceType;
+ char *resourceName;
+ PSResourceEnumerator enumerator;
+ char *private;
+{
+ ResourceDirectory d;
+ FILE *f;
+ EnumeratorStruct s;
+
+ s.func = enumerator;
+ s.type = resourceType;
+ s.name = resourceName;
+ s.private = private;
+ s.done = 0;
+
+ if (SetUpSavedPaths(pathOverride, defaultPath)) {
+ lastModifiedTime =
+ ReadFilesInPath(GetPath(), Enumerate, (char *) &s);
+ return;
+ }
+
+ for (d = resDir; d != NULL && !s.done; d = d->next) {
+ f = fopen(d->directory, "r");
+ if (f == NULL) continue;
+ if (fseek(f, d->endOfHeader, SEEK_SET) != -1) {
+ (void) Enumerate(f, d, (char *) &s);
+ }
+ (void) fclose(f);
+ }
+}
+
+int CheckPSResourceTime(pathOverride, defaultPath)
+ char *pathOverride;
+ char *defaultPath;
+{
+ if (CheckSavedPaths(pathOverride, defaultPath)) return 1;
+ return MaxTimeInPath(GetPath()) > lastModifiedTime;
+}
diff --git a/nx-X11/lib/psres/psres-def.cpp b/nx-X11/lib/psres/psres-def.cpp
new file mode 100644
index 000000000..2107d1eab
--- /dev/null
+++ b/nx-X11/lib/psres/psres-def.cpp
@@ -0,0 +1,11 @@
+LIBRARY psres
+VERSION LIBRARY_VERSION
+EXPORTS
+;TCheckPSResourceTime
+EnumeratePSResourceFiles
+InSavedList
+ListPSResourceFiles
+ListPSResourceTypes
+SetPSResourcePolicy
+
+/* $XFree86$ */
diff --git a/nx-X11/lib/regex/Imakefile b/nx-X11/lib/regex/Imakefile
new file mode 100644
index 000000000..434e8f645
--- /dev/null
+++ b/nx-X11/lib/regex/Imakefile
@@ -0,0 +1,53 @@
+XCOMM $XFree86$
+
+#define DoNormalLib YES
+#define DoSharedLib NO
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#define HasSharedData NO
+#define LibName regex
+#define LibHeaders NO
+#define LibInstall NO
+#define LibInstallBuild YES
+
+SRCS = regcomp.c regerror.c regexec.c regfree.c engine.c
+OBJS = regcomp.o regerror.o regexec.o regfree.o
+IHEADERS = regcomp.ih regerror.ih regexec.ih regfree.ih engine.ih regex.h
+HEADERS = regex.h
+
+DEFINES = -DPOSIX_MISTAKE
+
+REGEXSOURCEDIR = $(TOP)/extras/regex
+
+INCLUDES = -I. -I$(REGEXSOURCEDIR)
+
+#include <Library.tmpl>
+
+LinkSourceFile(regcomp.c,$(REGEXSOURCEDIR))
+LinkSourceFile(regerror.c,$(REGEXSOURCEDIR))
+LinkSourceFile(regexec.c,$(REGEXSOURCEDIR))
+LinkSourceFile(regfree.c,$(REGEXSOURCEDIR))
+LinkSourceFile(engine.c,$(REGEXSOURCEDIR))
+
+.SUFFIXES: .ih .h
+.c.ih:
+ RemoveFile($@)
+ $(SHELL) $(REGEXSOURCEDIR)/mkh -p $< >$@
+
+REGEXHSRC = $(REGEXSOURCEDIR)/regex2.h $(SRCS)
+regex.h: $(REGEXHSRC)
+ RemoveFile(regex.h)
+ $(SHELL) $(REGEXSOURCEDIR)/mkh -i _REGEX_H_ $(REGEXHSRC) > regex.h
+
+$(OBJS): $(IHEADERS)
+
+includes:: $(IHEADERS)
+
+clean::
+ RemoveFiles($(IHEADERS))
+
+BuildIncludesTop($(HEADERS))
+
+DependTarget()
+
diff --git a/nx-X11/lib/windows/Imakefile b/nx-X11/lib/windows/Imakefile
new file mode 100644
index 000000000..84e456ba6
--- /dev/null
+++ b/nx-X11/lib/windows/Imakefile
@@ -0,0 +1,34 @@
+#define DoNormalLib NormalLibWindowsWM
+#define DoSharedLib SharedLibWindowsWM
+#define DoDebugLib DebugLibWindowsWM
+#define DoProfileLib ProfileLibWindowsWM
+#define LibName WindowsWM
+#define SoRev SOWINDOWSWMREV
+#define IncSubdir X11
+#define IncSubSubdir extensions
+
+#include <Threads.tmpl>
+
+#ifdef SharedWindowsWMReqs
+REQUIREDLIBS = SharedWindowsWMReqs
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+ DEFINES = $(ALLOC_DEFINES)
+ INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC)
+ SRCS = windowswm.c
+ OBJS = windowswm.o
+ LINTLIBS = $(LINTXLIB)
+
+HEADERS = windowswm.h windowswmstr.h
+
+#include <Library.tmpl>
+
+MANSUFFIX = $(LIBMANSUFFIX)
+
+InstallManPage(WindowsWM,$(LIBMANDIR))
+
+DependTarget()
diff --git a/nx-X11/lib/windows/WindowsWM-def.cpp b/nx-X11/lib/windows/WindowsWM-def.cpp
new file mode 100755
index 000000000..e6a9e57a0
--- /dev/null
+++ b/nx-X11/lib/windows/WindowsWM-def.cpp
@@ -0,0 +1,13 @@
+LIBRARY windows
+VERSION LIBRARY_VERSION
+EXPORTS
+XWindowsWMQueryExtension
+XWindowsWMQueryVersion
+XWindowsWMDisableUpdate
+XWindowsWMReenableUpdate
+XWindowsWMSelectInput
+XWindowsWMSetFrontProcess
+XWindowsWMFrameGetRect
+XWindowsWMFrameHitTest
+XWindowsWMFrameDraw
+XWindowsWMFrameSetTitle
diff --git a/nx-X11/lib/windows/WindowsWM.man b/nx-X11/lib/windows/WindowsWM.man
new file mode 100644
index 000000000..7ca9e3c8f
--- /dev/null
+++ b/nx-X11/lib/windows/WindowsWM.man
@@ -0,0 +1,340 @@
+.\"
+.\" $XFree86: xc/lib/apple/AppleWM.man,v 1.2 2003/09/16 00:36:08 torrey Exp $
+.\"
+.\" Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+.\" Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining a
+.\" copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sub license, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice (including the
+.\" next paragraph) 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 NON-INFRINGEMENT.
+.\" IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+.\"
+.de TQ
+.br
+.ns
+.TP \\$1
+..
+.TH APPLEWM 3 "Version 1.0" "XFree86"
+
+.SH NAME
+ AppleWM \- Apple rootless window management extension.
+.SH SYNTAX
+\&#include <X11/extensions/applewm.h>
+.nf
+.sp
+Bool XAppleWMQueryExtension \^(\^Display *\fIdpy\fP,
+ int *\fIevent_basep\fP, int *\fIerror_basep\fP\^);
+.sp
+Status XAppleWMQueryVersion \^(\^Display *\fIdpy\fP,
+ int *\fImajor_versionp\fP, int *\fIminor_versionp\fP\^);
+.sp
+Bool XAppleWMDisableUpdate \^(\^Display *\fIdpy\fP, int \fIscreen\fP\^);
+.sp
+Bool XAppleWMReenableUpdate \^(\^Display *\fIdpy\fP, int \fIscreen\fP\^);
+.sp
+Bool XAppleWMSelectInput \^(\^Display *\fIdpy\fP, unsigned long \fImask\fP\^);
+.sp
+Bool XAppleWMSetWindowMenu \^(\^Display *\fIdpy\fP, int \fInitems\fP,
+ const char **\fIitems\fP\^);
+.sp
+Bool XAppleWMSetWindowMenuWithShortcuts \^(\^Display *\fIdpy\fP,
+ int \fInitems\fP, const char **\fIitems\fP,
+ const char *\fIshortcuts\fP\^);
+.sp
+Bool XAppleWMSetWindowMenuCheck \^(\^Display *\fIdpy\fP, int \fIindex\fP\^);
+.sp
+Bool XAppleWMSetFrontProcess \^(\^Display *\fIdpy\fP\^);
+.sp
+Bool XAppleWMSetWindowLevel \^(\^Display *\fIdpy\fP, Window \fIwindow\fP,
+ int \fIlevel\fP\^);
+.sp
+Bool XAppleWMSetCanQuit \^(\^Display *\fIdpy\fP, Bool \fIstate\fP\^);
+.sp
+Bool XAppleWMFrameGetRect \^(\^Display *\fIdpy\fP,
+ unsigned int \fIframe_class\fP,
+ unsigned int \fIframe_rect\fP,
+ short \fIinner_x\fP, short \fIinner_y\fP,
+ short \fIinner_w\fP, short \fIinner_h\fP,
+ short \fIouter_x\fP, short \fIouter_y\fP,
+ short \fIouter_w\fP, short \fIouter_h\fP,
+ short *\fIret_x\fP, short *\fIret_y\fP,
+ short *\fIret_w\fP, short *\fIret_h\fP\^);
+.sp
+unsigned int XAppleWMFrameHitTest \^(\^Display *\fIdpy\fP,
+ unsigned int \fIframe_class\fP,
+ short \fIpoint_x\fP, short \fIpoint_y\fP,
+ short \fIinner_x\fP, short \fIinner_y\fP,
+ short \fIinner_w\fP, short \fIinner_h\fP,
+ short \fIouter_x\fP, short \fIouter_y\fP,
+ short \fIouter_w\fP, short \fIouter_h\fP\^);
+.sp
+Bool XAppleWMFrameDraw \^(\^Display *\fIdpy\fP, int \fIscreen\fP,
+ Window \fIwindow\fP,
+ unsigned int \fIframe_class\fP,
+ unsigned int \fIframe_attr\fP,
+ short \fIinner_x\fP, short \fIinner_y\fP,
+ short \fIinner_w\fP, short \fIinner_h\fP,
+ short \fIouter_x\fP, short \fIouter_y\fP,
+ short \fIouter_w\fP, short \fIouter_h\fP,
+ unsigned int \fItitle_length\fP,
+ const unsigned char *\fItitle_bytes\fP);
+.fi
+.SH ARGUMENTS
+.IP \fIdpy\fP 1i
+Specifies the connection to the X server.
+.IP \fIscreen\fP 1i
+Specifies which screen.
+.IP \fImask\fP 1i
+Mask of event types the client is interested in.
+.IP \fIwindow\fP 1i
+Specifies which window.
+.IP \fIlevel\fP 1i
+Specifies the window level.
+.IP \fIframe_class\fP 1i
+Specifies the class of window frame decoration.
+.IP \fIframe_rect\fP 1i
+Specifies which rectangle to return from the window frame decoration.
+.IP \fIframe_attr\fP 1i
+A mask specifying the attributes of the window frame decoration.
+.IP \fIinner_x\fP,\fIinner_y\fP,\fIinner_w\fP,\fIinner_h\fP 1i
+Rectangle of the window content inside the window frame decoration.
+.IP \fIouter_x\fP,\fIouter_y\fP,\fIouter_w\fP,\fIouter_h\fP 1i
+Rectangle of the outer border of the window frame decoration.
+.IP \fIpoint_x\fP,\fIpoint_y\fP 1i
+Specifies the coordinates of the mouse up event.
+
+.SH DATATYPES
+
+.PP
+.B Events
+.nf
+typedef struct {
+ int type; \/* of event *\/
+ unsigned long serial; \/* # of last request processed by server *\/
+ Bool send_event; \/* true if came from a SendEvent request *\/
+ Display *display; \/* Display the event was read from *\/
+ Window window; \/* window of event *\/
+ Time time; \/* server timestamp when event happened *\/
+ int kind; \/* subtype of event *\/
+ int arg;
+} XAppleWMNotifyEvent;
+.fi
+.B XAppleWMNotifyEvent
+is sent to a client who has requested notification of AppleWM events with
+\fBXAppleWMSelectInput\fP.
+
+.PP
+Event types:
+.nf
+\&#define AppleWMControllerNotify 0
+\&#define AppleWMActivationNotify 1
+\&#define AppleWMPasteboardNotify 2
+.fi
+.PP
+Event masks:
+.nf
+\&#define AppleWMControllerNotifyMask (1L << 0)
+\&#define AppleWMActivationNotifyMask (1L << 1)
+\&#define AppleWMPasteboardNotifyMask (1L << 2)
+.fi
+.PP
+Kinds of ControllerNotify events:
+.nf
+\&#define AppleWMMinimizeWindow 0
+\&#define AppleWMZoomWindow 1
+\&#define AppleWMCloseWindow 2
+\&#define AppleWMBringAllToFront 3
+\&#define AppleWMHideWindow 4
+\&#define AppleWMHideAll 5
+\&#define AppleWMShowAll 6
+\&#define AppleWMWindowMenuItem 9
+\&#define AppleWMWindowMenuNotify 10
+\&#define AppleWMNextWindow 11
+\&#define AppleWMPreviousWindow 12
+.fi
+.PP
+Kinds of ActivationNotify events:
+.nf
+\&#define AppleWMIsActive 0
+\&#define AppleWMIsInactive 1
+.fi
+.PP
+Kinds of PasteboardNotify events:
+.nf
+\&#define AppleWMCopyToPasteboard 0
+.sp
+.fi
+.PP
+.B Window Parameters
+.PP
+Window level ids for \fBXAppleWMSetWindowLevel\fP:
+.nf
+\&#define AppleWMWindowLevelNormal 0
+\&#define AppleWMWindowLevelFloating 1
+\&#define AppleWMWindowLevelTornOff 2
+\&#define AppleWMWindowLevelDock 3
+\&#define AppleWMWindowLevelDesktop 4
+\&#define AppleWMNumWindowLevels 5
+.fi
+.PP
+Values for \fIframe_rect\fP argument to \fBXAppleWMFrameGetRect\fP:
+.nf
+\&#define AppleWMFrameRectTitleBar 1
+\&#define AppleWMFrameRectTracking 2
+\&#define AppleWMFrameRectGrowBox 3
+.fi
+.PP
+Window frame classes:
+.nf
+\&#define AppleWMFrameClassDocument 1 << 0
+\&#define AppleWMFrameClassDialog 1 << 1
+\&#define AppleWMFrameClassModalDialog 1 << 2
+\&#define AppleWMFrameClassSystemModalDialog 1 << 3
+\&#define AppleWMFrameClassUtility 1 << 4
+\&#define AppleWMFrameClassToolbar 1 << 5
+\&#define AppleWMFrameClassMenu 1 << 6
+\&#define AppleWMFrameClassSplash 1 << 7
+\&#define AppleWMFrameClassBorderless 1 << 8
+.fi
+.PP
+Window frame attributes:
+.nf
+\&#define AppleWMFrameActive 0x0001
+\&#define AppleWMFrameUrgent 0x0002
+\&#define AppleWMFrameTitle 0x0004
+\&#define AppleWMFramePrelight 0x0008
+\&#define AppleWMFrameShaded 0x0010
+\&#define AppleWMFrameCloseBox 0x0100
+\&#define AppleWMFrameCollapseBox 0x0200
+\&#define AppleWMFrameZoomBox 0x0400
+\&#define AppleWMFrameAnyBox 0x0700
+\&#define AppleWMFrameCloseBoxClicked 0x0800
+\&#define AppleWMFrameCollapseBoxClicked 0x1000
+\&#define AppleWMFrameZoomBoxClicked 0x2000
+\&#define AppleWMFrameAnyBoxClicked 0x3800
+\&#define AppleWMFrameGrowBox 0x4000
+.fi
+
+.SH DESCRIPTION
+.B AppleWM
+is a simple library designed to interface with the Apple-WM extension.
+This extension allows X window managers to better interact with
+the Mac OS X Aqua user interface when running X11 in a rootless mode.
+.PP
+A more complete description will be forthcoming eventually.
+
+.SH FUNCTIONS
+.B XAppleWMDisableUpdate
+causes any updates to the windows on the screen to be queued until updates
+are reenabled with \fBXAppleWMReenableUpdate\fP. This is useful to avoid
+intermediate redraws to the screen if a number of changes are going to be
+made at once. Updates should only be disabled temporarily while drawing
+to a window. These calls may be nested and each call to
+\fBXAppleWMDisableUpdate\fP must be paired with a subsequent call to
+\fBXAppleWMReenableUpdate\fP. Updating is not reenabled until the last
+unnested call to \fBXAppleWMReenableUpdate\fP. Disabling updates applies
+to window content; however, it is implementation dependent whether window
+size and position changes are disabled as well.
+.PP
+.B XAppleWMSelectInput
+is used to request that a client receive notification of the
+.B AppleWM
+events listed above. The event mask specifies the event types the client is
+interested in receiving. Passing an event mask of 0 stops notification of
+events.
+.PP
+.B XAppleWMSetWindowMenu
+and
+.B XAppleWMSetWindowMenuWithShortcuts
+set the list of windows displayed in the X server's "Window" menu in the
+Aqua menu bar. Other items may be listed in this menu by the X server, but
+a part of this menu is set aside for use by the Apple-WM extension. This
+is intended to be used to set a list of important top-level X11 windows.
+.PP
+One item of the X server's "Window" menu can have a checkmark beside it to
+indicate it is the active or front most window.
+.B XAppleWMSetWindowMenuCheck
+can be used to set the item number to put a checkmark beside.
+.PP
+.B XAppleWMSetFrontProcess
+directs the X server to make itself the front most application among all
+the other Mac OS X applications. This causes X11 windows to move above
+other applications' windows and for the X server to start receiving
+keyboard and mouse events.
+.PP
+Windows can be placed into different Aqua window levels with
+\fBXAppleWMSetWindowLevel\fP. The stacking of window levels takes precedence
+over the stacking of windows within a level. Thus the bottom window in a level
+will obscure even the top most window of a lower window level. By default all
+windows are placed in the lowest window level, AppleWMWindowLevelNormal. When
+a window is moved to a new level, it is ordered in front of all of its peers
+at the new level. \fINote, X11 does not have the concept of window levels and
+this function does not change the X11 window order. The result of trying to
+reorder an X11 window above another window of higher level is undefined.
+This should probably be changed.\fP
+.PP
+By default, the X server will ask for confirmation whenever the user requests
+that it quit from the Aqua UI.
+.B XAppleWMSetCanQuit
+can be used to change this behavior. If a \fIstate\fP of TRUE is passed, the
+X server will quit without confirmation when requested. If FALSE is passed,
+the default behavior is used.
+.PP
+.B XAppleWMFrameDraw
+can be used to decorate a top-level window with the standard Aqua window
+frame and widgets. The \fIframe_class\fP controls the overall look of the
+window frame and \fIframe_attr\fP specifies the details of how the various
+UI elements should be drawn. The dimensions of the X11 window content are
+passed as the \fIinner_*\fP rectangle and the dimensions of the Aqua window
+frame are passed as the \fIouter_*\fP rectangle.
+.B XAppleWMFrameGetRect
+is used to calculate the size of the outer rectangle from the size of the
+window content, which is being reparented.
+.PP
+.B XAppleWMFrameGetRect
+returns a rectangle that encloses an element of the window frame decoration.
+The \fIframe_rect\fP argument specifies the element of interest. The
+\fIinner_*\fP and \fIouter_*\fP rectangles (as described above) specify the
+window geometry. If AppleWMFrameRectTitleBar is passed for \fIframe_rect\fP,
+the \fIinner_*\fP parameters are ignored. The returned rectangle has the
+dimensions of the \fIouter_*\fP rectangle except that its height is equal
+to the constant title bar height for the specified \fIframe_class\fP. The
+proper outer rectangle for a given window content size is the union of inner
+rectangle and the title bar rectangle. The AppleWMFrameRectTracking and
+AppleWMFrameRectGrowBox rectangles are primarily intended to be used by the
+window manager to determine the correct placement for child windows to
+receive events. The tracking rectangle is the area of the window containing
+the close, collapse and zoom boxes. Typically when the cursor is over this
+area, the window manager will highlight the close, collapse, and zoom
+buttons to conform to the standard Aqua interface.
+.PP
+If a mouse up or down event is received in the tracking rectangle,
+.B XAppleWMFrameHitTest
+is used to determine which button was clicked.
+.B XAppleWMFrameHitTest
+returns AppleWMFrameCloseBox, AppleWMFrameCollapseBox, or AppleWMFrameZoomBox
+to indicate which button was clicked. If no button was clicked, 0 will be
+returned.
+.PP
+Other functions include: \fBXAppleWMQueryExtension\fP, which returns the event
+and error base codes and \fBXAppleWMQueryVersion\fP, which returns the current
+version of the extension. (This information is cached by the library.)
+
+.SH RESTRICTIONS
+.B AppleWM
+is only intended to be used on Mac OS X when running a rootless X server.
diff --git a/nx-X11/lib/windows/windowswm.c b/nx-X11/lib/windows/windowswm.c
new file mode 100755
index 000000000..5d2a285ff
--- /dev/null
+++ b/nx-X11/lib/windows/windowswm.c
@@ -0,0 +1,386 @@
+/*
+ * WindowsWM extension is based on AppleWM extension
+ * Authors: Kensuke Matsuzaki
+ */
+/**************************************************************************
+
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/extensions/windowswmstr.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <stdio.h>
+
+static XExtensionInfo _windowswm_info_data;
+static XExtensionInfo *windowswm_info = &_windowswm_info_data;
+static char *windowswm_extension_name = WINDOWSWMNAME;
+
+#define WindowsWMCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, windowswm_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display (Display *dpy, XExtCodes *extCodes);
+static Bool wire_to_event ();
+static Status event_to_wire ();
+
+static /* const */ XExtensionHooks windowswm_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, windowswm_info,
+ windowswm_extension_name,
+ &windowswm_extension_hooks,
+ WindowsWMNumberEvents, NULL);
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, windowswm_info);
+
+static Bool
+wire_to_event (Display *dpy, XEvent *re, xEvent *event)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XWindowsWMNotifyEvent *se;
+ xWindowsWMNotifyEvent *sevent;
+
+ WindowsWMCheckExtension (dpy, info, False);
+
+ switch ((event->u.u.type & 0x7f) - info->codes->first_event)
+ {
+ case WindowsWMControllerNotify:
+ case WindowsWMActivationNotify:
+ se = (XWindowsWMNotifyEvent *) re;
+ sevent = (xWindowsWMNotifyEvent *) event;
+ se->type = sevent->type & 0x7f;
+ se->serial = _XSetLastRequestRead(dpy,(xGenericReply *) event);
+ se->send_event = (sevent->type & 0x80) != 0;
+ se->display = dpy;
+ se->window = sevent->window;
+ se->time = sevent->time;
+ se->kind = sevent->kind;
+ se->arg = sevent->arg;
+ se->x = sevent->x;
+ se->y = sevent->y;
+ se->w = sevent->w;
+ se->h = sevent->h;
+ return True;
+ }
+ return False;
+}
+
+static Status
+event_to_wire (Display *dpy, XEvent *re, xEvent *event)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XWindowsWMNotifyEvent *se;
+ xWindowsWMNotifyEvent *sevent;
+
+ WindowsWMCheckExtension (dpy, info, False);
+
+ switch ((re->type & 0x7f) - info->codes->first_event)
+ {
+ case WindowsWMControllerNotify:
+ case WindowsWMActivationNotify:
+ se = (XWindowsWMNotifyEvent *) re;
+ sevent = (xWindowsWMNotifyEvent *) event;
+ sevent->type = se->type | (se->send_event ? 0x80 : 0);
+ sevent->sequenceNumber = se->serial & 0xffff;
+ sevent->window = se->window;
+ sevent->kind = se->kind;
+ sevent->arg = se->arg;
+ sevent->time = se->time;
+ sevent->x = se->x;
+ sevent->y = se->y;
+ sevent->w = se->w;
+ sevent->h = se->h;
+ return 1;
+ }
+ return 0;
+}
+
+/*****************************************************************************
+ * *
+ * public Windows-WM Extension routines *
+ * *
+ *****************************************************************************/
+
+#if 0
+#include <stdio.h>
+#define TRACE(msg) fprintf(stderr, "WindowsWM%s\n", msg);
+#else
+#define TRACE(msg)
+#endif
+
+
+Bool
+XWindowsWMQueryExtension (Display *dpy,
+ int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ TRACE("QueryExtension...");
+ if (XextHasExtension(info))
+ {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ TRACE("QueryExtension... return True");
+ return True;
+ }
+ else
+ {
+ TRACE("QueryExtension... return False");
+ return False;
+ }
+}
+
+Bool
+XWindowsWMQueryVersion (Display* dpy, int* majorVersion,
+ int* minorVersion, int* patchVersion)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xWindowsWMQueryVersionReply rep;
+ xWindowsWMQueryVersionReq *req;
+
+ TRACE("QueryVersion...");
+ WindowsWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(WindowsWMQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_WindowsWMQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return False");
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ *patchVersion = rep.patchVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return True");
+ return True;
+}
+
+Bool
+XWindowsWMDisableUpdate (Display* dpy, int screen)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xWindowsWMDisableUpdateReq *req;
+
+ TRACE("DisableUpdate...");
+ WindowsWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(WindowsWMDisableUpdate, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_WindowsWMDisableUpdate;
+ req->screen = screen;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("DisableUpdate... return True");
+ return True;
+}
+
+Bool
+XWindowsWMReenableUpdate (Display* dpy, int screen)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xWindowsWMReenableUpdateReq *req;
+
+ TRACE("ReenableUpdate...");
+ WindowsWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(WindowsWMReenableUpdate, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_WindowsWMReenableUpdate;
+ req->screen = screen;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("ReenableUpdate... return True");
+ return True;
+}
+
+Bool
+XWindowsWMSelectInput (Display* dpy, unsigned long mask)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xWindowsWMSelectInputReq *req;
+
+ TRACE("SelectInput...");
+ WindowsWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(WindowsWMSelectInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_WindowsWMSelectInput;
+ req->mask = mask;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("SetlectInput... return True");
+ return True;
+}
+
+
+Bool
+XWindowsWMSetFrontProcess (Display* dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xWindowsWMSetFrontProcessReq *req;
+
+ TRACE("SetFrontProcess...");
+ WindowsWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(WindowsWMSetFrontProcess, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_WindowsWMSetFrontProcess;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("SetFrontProcess... return True");
+ return True;
+}
+
+Bool
+XWindowsWMFrameGetRect (Display* dpy, unsigned int frame_style,
+ unsigned int frame_style_ex, unsigned int frame_rect,
+ short ix, short iy, short iw, short ih,
+ short *rx, short *ry, short *rw, short *rh)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xWindowsWMFrameGetRectReply rep;
+ xWindowsWMFrameGetRectReq *req;
+
+ TRACE("FrameGetRect...");
+ WindowsWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(WindowsWMFrameGetRect, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_WindowsWMFrameGetRect;
+ req->frame_style = frame_style;
+ req->frame_style_ex = frame_style_ex;
+ req->frame_rect = frame_rect;
+ req->ix = ix;
+ req->iy = iy;
+ req->iw = iw;
+ req->ih = ih;
+ rep.x = rep.y = rep.w = rep.h = 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("FrameGetRect... return False");
+ return False;
+ }
+ *rx = rep.x; *ry = rep.y;
+ *rw = rep.w; *rh = rep.h;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("FrameGetRect... return True");
+ return True;
+}
+
+Bool
+XWindowsWMFrameDraw (Display* dpy, int screen, Window window,
+ unsigned int frame_style, unsigned int frame_style_ex,
+ short ix, short iy, short iw, short ih)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xWindowsWMFrameDrawReq *req;
+
+ TRACE("FrameDraw...");
+ WindowsWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(WindowsWMFrameDraw, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_WindowsWMFrameDraw;
+ req->screen = screen;
+ req->window = window;
+ req->frame_style = frame_style;
+ req->frame_style_ex = frame_style_ex;
+ req->ix = ix;
+ req->iy = iy;
+ req->iw = iw;
+ req->ih = ih;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("FrameDraw... return True");
+ return True;
+}
+
+Bool
+XWindowsWMFrameSetTitle (Display* dpy, int screen, Window window,
+ unsigned int title_length, const char *title_bytes)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xWindowsWMFrameSetTitleReq *req;
+
+ TRACE("FrameSetTitle...");
+ WindowsWMCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(WindowsWMFrameSetTitle, req);
+ req->reqType = info->codes->major_opcode;
+ req->wmReqType = X_WindowsWMFrameSetTitle;
+ req->screen = screen;
+ req->window = window;
+ req->title_length = title_length;
+
+ req->length += (title_length + 3)>>2;
+ Data (dpy, title_bytes, title_length);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("FrameSetTitle... return True");
+ return True;
+}
diff --git a/nx-X11/lib/windows/windowswm.h b/nx-X11/lib/windows/windowswm.h
new file mode 100755
index 000000000..2c3379f6e
--- /dev/null
+++ b/nx-X11/lib/windows/windowswm.h
@@ -0,0 +1,195 @@
+/*
+ * WindowsWM extension is based on AppleWM extension
+ * Authors: Kensuke Matsuzaki
+ */
+/**************************************************************************
+
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+#ifndef _WINDOWSWM_H_
+#define _WINDOWSWM_H_
+
+#include <X11/Xfuncproto.h>
+
+#define X_WindowsWMQueryVersion 0
+#define X_WindowsWMFrameGetRect 1
+#define X_WindowsWMFrameDraw 2
+#define X_WindowsWMFrameSetTitle 3
+#define X_WindowsWMDisableUpdate 4
+#define X_WindowsWMReenableUpdate 5
+#define X_WindowsWMSelectInput 6
+#define X_WindowsWMSetFrontProcess 7
+
+/* Events */
+#define WindowsWMControllerNotify 0
+#define WindowsWMActivationNotify 1
+#define WindowsWMNumberEvents 2
+
+#define WindowsWMControllerNotifyMask (1L << 0)
+#define WindowsWMActivationNotifyMask (1L << 1)
+
+/* "Kinds" of ControllerNotify events */
+#define WindowsWMMinimizeWindow 0
+#define WindowsWMMaximizeWindow 1
+#define WindowsWMRestoreWindow 2
+#define WindowsWMCloseWindow 3
+#define WindowsWMBringAllToFront 4
+#define WindowsWMHideWindow 5
+#define WindowsWMMoveWindow 6
+#define WindowsWMResizeWindow 7
+#define WindowsWMActivateWindow 8
+
+/* "Kinds" of ActivationNotify events */
+#define WindowsWMIsActive 0
+#define WindowsWMIsInactive 1
+
+/* Errors */
+#define WindowsWMClientNotLocal 0
+#define WindowsWMOperationNotSupported 1
+#define WindowsWMNumberErrors (WindowsWMOperationNotSupported + 1)
+
+/* Possible value for frame_rect argument to XWindowsWMFrameGetRect() */
+#define WindowsWMFrameRectTitleBar 1
+#define WindowsWMFrameRectTracking 2
+#define WindowsWMFrameRectGrowBox 3
+
+/* Window frame styles */
+#define WindowsWMFrameStyleBorder 0x800000
+#define WindowsWMFrameStyleCaption 0xc00000
+#define WindowsWMFrameStyleChild 0x40000000
+#define WindowsWMFrameStyleChildWindow 0x40000000
+#define WindowsWMFrameStyleClipChildren 0x2000000
+#define WindowsWMFrameStyleClipSiblings 0x4000000
+#define WindowsWMFrameStyleDisabled 0x8000000
+#define WindowsWMFrameStyleDlgFrame 0x400000
+#define WindowsWMFrameStyleGroup 0x20000
+#define WindowsWMFrameStyleHScroll 0x100000
+#define WindowsWMFrameStyleIconic 0x20000000
+#define WindowsWMFrameStyleMaximize 0x1000000
+#define WindowsWMFrameStyleMaximizeBox 0x10000
+#define WindowsWMFrameStyleMinimize 0x20000000
+#define WindowsWMFrameStyleMinimizeBox 0x20000
+#define WindowsWMFrameStyleOverlapped 0
+#define WindowsWMFrameStyleOverlappedWindow 0xcf0000
+#define WindowsWMFrameStylePopup 0x80000000
+#define WindowsWMFrameStylePopupWindow 0x80880000
+#define WindowsWMFrameStyleSizeBox 0x40000
+#define WindowsWMFrameStyleSysMenu 0x80000
+#define WindowsWMFrameStyleTabStop 0x10000
+#define WindowsWMFrameStyleThickFrame 0x40000
+#define WindowsWMFrameStyleTiled 0
+#define WindowsWMFrameStyleTiledWindow 0xcf0000
+#define WindowsWMFrameStyleVisible 0x10000000
+#define WindowsWMFrameStyleVScroll 0x200000
+
+/* Window frame Ex-styles */
+#define WindowsWMFrameStyleExAcceptFiles 16
+#define WindowsWMFrameStyleExAppWindow 0x40000
+#define WindowsWMFrameStyleExClientEdge 512
+#define WindowsWMFrameStyleExComposited 0x2000000
+#define WindowsWMFrameStyleExContextHelp 0x400
+#define WindowsWMFrameStyleExControlParent 0x10000
+#define WindowsWMFrameStyleExDlgModalFrame 1
+#define WindowsWMFrameStyleExLayered 0x80000
+#define WindowsWMFrameStyleExLayoutRtl 0x400000
+#define WindowsWMFrameStyleExLeft 0
+#define WindowsWMFrameStyleExLeftScrollBar 0x4000
+#define WindowsWMFrameStyleExLtrReading 0
+#define WindowsWMFrameStyleExMDIChild 64
+#define WindowsWMFrameStyleExNoActivate 0x8000000
+#define WindowsWMFrameStyleExNoInheritLayout 0x100000
+#define WindowsWMFrameStyleExNoParentNotify 4
+#define WindowsWMFrameStyleExOverlappedWindow 0x300
+#define WindowsWMFrameStyleExPaletteWindow 0x188
+#define WindowsWMFrameStyleExRight 0x1000
+#define WindowsWMFrameStyleExRightScrollBar 0
+#define WindowsWMFrameStyleExRtlReading 0x2000
+#define WindowsWMFrameStyleExStaticEdge 0x20000
+#define WindowsWMFrameStyleExToolWindow 128
+#define WindowsWMFrameStyleExTopMost 8
+#define WindowsWMFrameStyleExTransparent 32
+#define WindowsWMFrameStyleExWindowEdge 256
+
+#define WINDOWSWM_RAISE_ON_CLICK "_WINDOWSWM_RAISE_ON_CLICK"
+#define WINDOWSWM_MOUSE_ACTIVATE "_WINDOWSWM_MOUSE_ACTIVATE"
+#define WINDOWSWM_CLIENT_WINDOW "_WINDOWSWM_CLIENT_WINDOW"
+#define WINDOWSWM_NATIVE_HWND "_WINDOWSWM_NATIVE_HWND"
+
+#ifndef _WINDOWSWM_SERVER_
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came frome a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* window of event */
+ Time time; /* server timestamp when event happened */
+ int kind; /* subtype of event */
+ int arg;
+ int x;
+ int y;
+ int w;
+ int h;
+} XWindowsWMNotifyEvent;
+
+_XFUNCPROTOBEGIN
+
+Bool XWindowsWMQueryExtension (Display *dpy, int *event_base, int *error_base);
+
+Bool XWindowsWMQueryVersion (Display *dpy, int *majorVersion,
+ int *minorVersion, int *patchVersion);
+
+Bool XWindowsWMDisableUpdate (Display *dpy, int screen);
+
+Bool XWindowsWMReenableUpdate (Display *dpy, int screen);
+
+Bool XWindowsWMSelectInput (Display *dpy, unsigned long mask);
+
+Bool XWindowsWMSetFrontProcess (Display *dpy);
+
+Bool XWindowsWMFrameGetRect (Display *dpy,
+ unsigned int frame_style,
+ unsigned int frame_style_ex,
+ unsigned int frame_rect,
+ short inner_x, short inner_y,
+ short inner_w, short inner_h,
+ short *ret_x, short *ret_y,
+ short *ret_w, short *ret_h);
+
+Bool XWindowsWMFrameDraw (Display *dpy, int screen, Window window,
+ unsigned int frame_style,
+ unsigned int frame_style_ex,
+ short inner_x, short inner_y,
+ short inner_w, short inner_h);
+
+Bool XWindowsWMFrameSetTitle (Display *dpy, int screen, Window window,
+ unsigned int title_length,
+ const char * title_bytes);
+
+_XFUNCPROTOEND
+
+#endif /* _WINDOWSWM_SERVER_ */
+#endif /* _WINDOWSWM_H_ */
diff --git a/nx-X11/lib/windows/windowswmstr.h b/nx-X11/lib/windows/windowswmstr.h
new file mode 100755
index 000000000..37ceb535a
--- /dev/null
+++ b/nx-X11/lib/windows/windowswmstr.h
@@ -0,0 +1,169 @@
+/*
+ * WindowsWM extension is based on AppleWM extension
+ * Authors: Kensuke Matsuzaki
+ */
+/**************************************************************************
+
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+#ifndef _WINDOWSWMSTR_H_
+#define _WINDOWSWMSTR_H_
+
+#include <X11/extensions/windowswm.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#define WINDOWSWMNAME "Windows-WM"
+
+#define WINDOWS_WM_MAJOR_VERSION 1 /* current version numbers */
+#define WINDOWS_WM_MINOR_VERSION 0
+#define WINDOWS_WM_PATCH_VERSION 0
+
+typedef struct _WindowsWMQueryVersion {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMQueryVersion */
+ CARD16 length B16;
+} xWindowsWMQueryVersionReq;
+#define sz_xWindowsWMQueryVersionReq 4
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD16 majorVersion B16; /* major version of WM protocol */
+ CARD16 minorVersion B16; /* minor version of WM protocol */
+ CARD32 patchVersion B32; /* patch version of WM protocol */
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xWindowsWMQueryVersionReply;
+#define sz_xWindowsWMQueryVersionReply 32
+
+typedef struct _WindowsWMDisableUpdate {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMDisableUpdate */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xWindowsWMDisableUpdateReq;
+#define sz_xWindowsWMDisableUpdateReq 8
+
+typedef struct _WindowsWMReenableUpdate {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMReenableUpdate */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xWindowsWMReenableUpdateReq;
+#define sz_xWindowsWMReenableUpdateReq 8
+
+typedef struct _WindowsWMSelectInput {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMSelectInput */
+ CARD16 length B16;
+ CARD32 mask B32;
+} xWindowsWMSelectInputReq;
+#define sz_xWindowsWMSelectInputReq 8
+
+typedef struct _WindowsWMNotify {
+ BYTE type; /* always eventBase + event type */
+ BYTE kind;
+ CARD16 sequenceNumber B16;
+ Window window B32;
+ Time time B32; /* time of change */
+ CARD16 pad1 B16;
+ CARD32 arg B32;
+ INT16 x B16;
+ INT16 y B16;
+ CARD16 w B16;
+ CARD16 h B16;
+} xWindowsWMNotifyEvent;
+#define sz_xWindowsWMNotifyEvent 28
+
+typedef struct _WindowsWMSetFrontProcess {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMSetFrontProcess */
+ CARD16 length B16;
+} xWindowsWMSetFrontProcessReq;
+#define sz_xWindowsWMSetFrontProcessReq 4
+
+typedef struct _WindowsWMFrameGetRect {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMFrameGetRect */
+ CARD16 length B16;
+ CARD32 frame_style B32;
+ CARD32 frame_style_ex B32;
+ CARD16 frame_rect B16;
+ INT16 ix B16;
+ INT16 iy B16;
+ CARD16 iw B16;
+ CARD16 ih B16;
+ CARD16 pad1 B16;
+} xWindowsWMFrameGetRectReq;
+#define sz_xWindowsWMFrameGetRectReq 24
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ INT16 x B16;
+ INT16 y B16;
+ CARD16 w B16;
+ CARD16 h B16;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xWindowsWMFrameGetRectReply;
+#define sz_xWindowsWMFrameGetRectReply 32
+
+typedef struct _WindowsWMFrameDraw {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMFrameDraw */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 window B32;
+ CARD32 frame_style B32;
+ CARD32 frame_style_ex B32;
+ INT16 ix B16;
+ INT16 iy B16;
+ CARD16 iw B16;
+ CARD16 ih B16;
+} xWindowsWMFrameDrawReq;
+#define sz_xWindowsWMFrameDrawReq 28
+
+typedef struct _WindowsWMFrameSetTitle {
+ CARD8 reqType; /* always WMReqCode */
+ CARD8 wmReqType; /* always X_WMFrameSetTitle */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 window B32;
+ CARD32 title_length B32;
+} xWindowsWMFrameSetTitleReq;
+#define sz_xWindowsWMFrameSetTitleReq 16
+
+#endif /* _WINDOWSWMSTR_H_ */
diff --git a/nx-X11/lib/xkbfile/Imakefile b/nx-X11/lib/xkbfile/Imakefile
new file mode 100644
index 000000000..7b751c903
--- /dev/null
+++ b/nx-X11/lib/xkbfile/Imakefile
@@ -0,0 +1,43 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:42 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/xkbfile/Imakefile,v 3.5 2003/10/15 21:23:38 herrb Exp $
+
+#define DoNormalLib NormalLibxkbfile
+#define DoSharedLib SharedLibxkbfile
+#define DoExtraLib SharedLibxkbfile
+#define DoDebugLib DebugLibxkbfile
+#define DoProfileLib ProfileLibxkbfile
+#define HasSharedData NO
+#define LibName xkbfile
+#define SoRev SOXKBFILEREV
+#define IncSubdir X11
+#define IncSubSubdir extensions
+
+#ifdef SharedxkbfileReqs
+REQUIREDLIBS = SharedxkbfileReqs
+#endif
+
+#if !BuildXKBfilelib
+#define LibBuild NO
+#endif
+
+ SRCS = xkbtext.c xkbdraw.c xkbmisc.c xkbatom.c xkberrs.c \
+ cout.c xkbout.c xkmout.c \
+ xkmread.c srvmisc.c \
+ xkbconfig.c xkbbells.c maprules.c
+ OBJS = xkbtext.o xkbdraw.o xkbmisc.o xkbatom.o xkberrs.o \
+ cout.o xkbout.o xkmout.o \
+ xkmread.o srvmisc.o \
+ xkbconfig.o xkbbells.o maprules.o
+ HEADERS = XKBfile.h XKM.h XKMformat.h XKBrules.h \
+ XKBconfig.h XKBbells.h
+ INCLUDES = -I. -I$(EXTINCSRC)
+
+ROOT_DEFINES = -DDFLT_XKB_CONFIG_ROOT=\"$(LIBDIR)/xkb\"
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/xkbfile/XKBbells.h b/nx-X11/lib/xkbfile/XKBbells.h
new file mode 100644
index 000000000..16a9275ea
--- /dev/null
+++ b/nx-X11/lib/xkbfile/XKBbells.h
@@ -0,0 +1,143 @@
+#ifndef _XKBBELLS_H_
+#define _XKBBELLS_H_ 1
+
+/* $Xorg: XKBbells.h,v 1.3 2000/08/17 19:46:42 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86$ */
+
+#define XkbBN_Info "Info"
+#define XkbBN_Warning "Warning"
+#define XkbBN_MinorError "MinorError"
+#define XkbBN_MajorError "MajorError"
+#define XkbBN_BadValue "BadValue"
+#define XkbBN_InvalidLocation "InvalidLocation"
+#define XkbBN_Question "Question"
+#define XkbBN_Start "Start"
+#define XkbBN_End "End"
+#define XkbBN_Success "Success"
+#define XkbBN_Failure "Failure"
+#define XkbBN_Wait "Wait"
+#define XkbBN_Proceed "Proceed"
+#define XkbBN_Ignore "Ignore"
+#define XkbBN_Iconify "Iconify"
+#define XkbBN_Deiconify "Deconify"
+#define XkbBN_Open "Open"
+#define XkbBN_Close "Close"
+#define XkbBN_TerminalBell "TerminalBell"
+#define XkbBN_MarginBell "MarginBell"
+#define XkbBN_CursorStuck "CursorStuck"
+#define XkbBN_NewMail "NewMail"
+#define XkbBN_LaunchApp "LaunchApp"
+#define XkbBN_AppDeath "AppDeath"
+#define XkbBN_ImAlive "ImAlive"
+#define XkbBN_ClockChimeHour "ClockChimeHour"
+#define XkbBN_ClockChimeHalf "ClockChimeHalf"
+#define XkbBN_ClockChimeQuarter "ClockChimeQuarter"
+#define XkbBN_RepeatingLastBell "RepeatingLastBell"
+#define XkbBN_ComposeFail "ComposeFail"
+#define XkbBN_AX_FeatureOn "AX_FeatureOn"
+#define XkbBN_AX_FeatureOff "AX_FeatureOff"
+#define XkbBN_AX_FeatureChange "AX_FeatureChange"
+#define XkbBN_AX_IndicatorOn "AX_IndicatorOn"
+#define XkbBN_AX_IndicatorOff "AX_IndicatorOff"
+#define XkbBN_AX_IndicatorChange "AX_IndicatorChange"
+#define XkbBN_AX_SlowKeysWarning "AX_SlowKeysWarning"
+#define XkbBN_AX_SlowKeyPress "AX_SlowKeyPress"
+#define XkbBN_AX_SlowKeyAccept "AX_SlowKeyAccept"
+#define XkbBN_AX_SlowKeyReject "AX_SlowKeyReject"
+#define XkbBN_AX_SlowKeyRelease "AX_SlowKeyRelease"
+#define XkbBN_AX_BounceKeyReject "AX_BounceKeyReject"
+#define XkbBN_AX_StickyLatch "AX_StickyLatch"
+#define XkbBN_AX_StickyLock "AX_StickyLock"
+#define XkbBN_AX_StickyUnlock "AX_StickyUnlock"
+
+#define XkbBI_Info 0
+#define XkbBI_Warning 1
+#define XkbBI_MinorError 2
+#define XkbBI_MajorError 3
+#define XkbBI_BadValue 4
+#define XkbBI_InvalidLocation 5
+#define XkbBI_Question 6
+#define XkbBI_Start 7
+#define XkbBI_End 8
+#define XkbBI_Success 9
+#define XkbBI_Failure 10
+#define XkbBI_Wait 11
+#define XkbBI_Proceed 12
+#define XkbBI_Ignore 13
+#define XkbBI_Iconify 14
+#define XkbBI_Deiconify 15
+#define XkbBI_Open 16
+#define XkbBI_Close 17
+#define XkbBI_TerminalBell 18
+#define XkbBI_MarginBell 19
+#define XkbBI_CursorStuck 20
+#define XkbBI_NewMail 21
+#define XkbBI_LaunchApp 22
+#define XkbBI_AppDeath 23
+#define XkbBI_ImAlive 24
+#define XkbBI_ClockChimeHour 25
+#define XkbBI_ClockChimeHalf 26
+#define XkbBI_ClockChimeQuarter 27
+#define XkbBI_RepeatingLastBell 28
+#define XkbBI_ComposeFail 29
+#define XkbBI_AX_FeatureOn 30
+#define XkbBI_AX_FeatureOff 31
+#define XkbBI_AX_FeatureChange 32
+#define XkbBI_AX_IndicatorOn 33
+#define XkbBI_AX_IndicatorOff 34
+#define XkbBI_AX_IndicatorChange 35
+#define XkbBI_AX_SlowKeysWarning 36
+#define XkbBI_AX_SlowKeyPress 37
+#define XkbBI_AX_SlowKeyAccept 38
+#define XkbBI_AX_SlowKeyReject 39
+#define XkbBI_AX_SlowKeyRelease 40
+#define XkbBI_AX_BounceKeyReject 41
+#define XkbBI_AX_StickyLatch 42
+#define XkbBI_AX_StickyLock 43
+#define XkbBI_AX_StickyUnlock 44
+#define XkbBI_NumBells 45
+
+_XFUNCPROTOBEGIN
+
+extern Bool XkbStdBell(
+ Display * /* dpy */,
+ Window /* win */,
+ int /* percent */,
+ int /* bellDef */
+);
+
+extern Bool XkbStdBellEvent(
+ Display * /* dpy */,
+ Window /* win */,
+ int /* percent */,
+ int /* bellDef */
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XKBBELLS_H_ */
diff --git a/nx-X11/lib/xkbfile/XKBconfig.h b/nx-X11/lib/xkbfile/XKBconfig.h
new file mode 100644
index 000000000..fbc6a600e
--- /dev/null
+++ b/nx-X11/lib/xkbfile/XKBconfig.h
@@ -0,0 +1,280 @@
+#ifndef _XKBCONFIG_H_
+#define _XKBCONFIG_H_ 1
+
+/* $Xorg: XKBconfig.h,v 1.3 2000/08/17 19:46:42 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbfile/XKBconfig.h,v 3.5 2001/01/17 19:43:39 dawes Exp $ */
+
+
+typedef struct _XkbConfigRtrn *XkbConfigRtrnPtr;
+typedef struct _XkbConfigField *XkbConfigFieldPtr;
+typedef struct _XkbConfigFields *XkbConfigFieldsPtr;
+
+typedef Bool (*XkbConfigParseFunc)(
+ FILE * /* file */,
+ XkbConfigFieldsPtr /* fields */,
+ XkbConfigFieldPtr /* field */,
+ XkbDescPtr /* xkb */,
+ XkbConfigRtrnPtr /* rtrn */
+);
+
+#define XkbCF_Check 0
+#define XkbCF_Apply 1
+#define XkbCF_CleanUp 2
+#define XkbCF_Destroy 3
+
+typedef Bool (*XkbConfigFinishFunc)(
+ XkbConfigFieldsPtr /* fields */,
+ XkbDescPtr /* xkb */,
+ XkbConfigRtrnPtr /* rtrn */,
+ int /* what */
+);
+
+typedef struct _XkbConfigRtrnPriv {
+ int cfg_id;
+ XPointer priv;
+ struct _XkbConfigRtrnPriv * next;
+} XkbConfigRtrnPrivRec,*XkbConfigRtrnPrivPtr;
+
+typedef struct _XkbConfigModInfo {
+ Bool replace;
+ unsigned char mods;
+ unsigned char mods_clear;
+ unsigned short vmods;
+ unsigned short vmods_clear;
+} XkbConfigModInfoRec,*XkbConfigModInfoPtr;
+
+typedef struct _XkbConfigUnboundMod {
+ unsigned char what;
+ unsigned char mods;
+ unsigned short vmods;
+ short merge;
+ char * name;
+} XkbConfigUnboundModRec,*XkbConfigUnboundModPtr;
+
+#define XkbCF_MergeSet 0
+#define XkbCF_MergeAdd 1
+#define XkbCF_MergeRemove 2
+
+#define XkbCF_InitialMods (1L<<0)
+#define XkbCF_InternalMods (1L<<1)
+#define XkbCF_IgnoreLockMods (1L<<2)
+#define XkbCF_InitialCtrls (1L<<3)
+#define XkbCF_AccessXTimeout (1L<<4)
+#define XkbCF_AccessXTimeoutCtrlsOn (1L<<5)
+#define XkbCF_AccessXTimeoutCtrlsOff (1L<<6)
+#define XkbCF_AccessXTimeoutOptsOn (1L<<7)
+#define XkbCF_AccessXTimeoutOptsOff (1L<<8)
+#define XkbCF_GroupsWrap (1L<<9)
+#define XkbCF_InitialOpts (1L<<10)
+
+typedef struct _XkbConfigRtrn {
+ unsigned defined;
+ int error;
+ int line;
+
+ int click_volume;
+ int bell_volume;
+ int bell_pitch;
+ int bell_duration;
+ int repeat_delay;
+ int repeat_interval;
+
+ char * rules_file;
+ char * model;
+ char * layout;
+ char * variant;
+ char * options;
+
+ char * keymap;
+ char * keycodes;
+ char * geometry;
+ char * phys_symbols;
+ char * symbols;
+ char * types;
+ char * compat;
+
+ Bool replace_initial_ctrls;
+ unsigned long initial_ctrls;
+ unsigned long initial_ctrls_clear;
+
+ Bool replace_initial_opts;
+ unsigned short initial_opts;
+ unsigned short initial_opts_clear;
+
+ XkbConfigModInfoRec initial_mods;
+ XkbConfigModInfoRec internal_mods;
+ XkbConfigModInfoRec ignore_lock_mods;
+
+ short num_unbound_mods;
+ short sz_unbound_mods;
+ XkbConfigUnboundModPtr unbound_mods;
+
+ int groups_wrap;
+ int slow_keys_delay;
+ int debounce_delay;
+ int mk_delay;
+ int mk_interval;
+ int mk_time_to_max;
+ int mk_max_speed;
+ int mk_curve;
+ int ax_timeout;
+
+ Bool replace_axt_ctrls_on;
+ Bool replace_axt_ctrls_off;
+ unsigned long axt_ctrls_on;
+ unsigned long axt_ctrls_off;
+ unsigned long axt_ctrls_ignore;
+
+ Bool replace_axt_opts_off;
+ Bool replace_axt_opts_on;
+ unsigned short axt_opts_off;
+ unsigned short axt_opts_on;
+ unsigned short axt_opts_ignore;
+ XkbConfigRtrnPrivPtr priv;
+} XkbConfigRtrnRec;
+
+typedef struct _XkbConfigField {
+ char * field;
+ unsigned char field_id;
+} XkbConfigFieldRec;
+
+typedef struct _XkbConfigFields {
+ unsigned short cfg_id;
+ unsigned short num_fields;
+ XkbConfigFieldPtr fields;
+ XkbConfigParseFunc parser;
+ XkbConfigFinishFunc finish;
+ XPointer priv;
+ struct _XkbConfigFields *next;
+} XkbConfigFieldsRec;
+
+#define XkbCF_EOF -1
+#define XkbCF_Unknown 0
+#define XkbCF_EOL 1
+#define XkbCF_Semi 2
+#define XkbCF_Equals 3
+#define XkbCF_PlusEquals 4
+#define XkbCF_MinusEquals 5
+#define XkbCF_Plus 6
+#define XkbCF_Minus 7
+#define XkbCF_String 10
+#define XkbCF_Ident 11
+#define XkbCF_Integer 12
+
+#define XkbCF_UnterminatedString 100
+#define XkbCF_BadAlloc 101
+#define XkbCF_MissingIdent 102
+#define XkbCF_MissingEquals 103
+#define XkbCF_ExpectedEOS 104
+#define XkbCF_ExpectedBoolean 105
+#define XkbCF_ExpectedInteger 106
+#define XkbCF_ExpectedString 107
+#define XkbCF_ExpectedModifier 108
+#define XkbCF_ExpectedControl 109
+#define XkbCF_ExpectedAXOption 110
+#define XkbCF_ExpectedOperator 111
+#define XkbCF_ExpectedOORGroupBehavior 112
+
+typedef union {
+ int ival;
+ char * str;
+} XkbCFScanResultRec,*XkbCFScanResultPtr;
+
+extern XkbConfigFieldsPtr XkbCFDflts;
+
+_XFUNCPROTOBEGIN
+
+extern int XkbCFScan(
+ FILE * /* file */,
+ XkbCFScanResultPtr /* val_rtrn */,
+ XkbConfigRtrnPtr /* rtrn */
+);
+
+extern XkbConfigFieldsPtr XkbCFDup(
+ XkbConfigFieldsPtr /* fields */
+);
+
+extern XkbConfigFieldsPtr XkbCFFree(
+ XkbConfigFieldsPtr /* fields */,
+ Bool /* all */
+);
+
+extern XkbConfigUnboundModPtr XkbCFAddModByName(
+ XkbConfigRtrnPtr /* rtrn */,
+ int /* what */,
+ char * /* name */,
+ Bool /* merge */,
+ XkbConfigUnboundModPtr /* last */
+);
+
+extern Bool XkbCFBindMods(
+ XkbConfigRtrnPtr /* rtrn */,
+ XkbDescPtr /* xkb */
+);
+
+extern Bool XkbCFApplyMods(
+ XkbConfigRtrnPtr /* rtrn */,
+ int /* what */,
+ XkbConfigModInfoPtr /* info */
+);
+
+extern Bool XkbCFApplyRtrnValues(
+ XkbConfigRtrnPtr /* rtrn */,
+ XkbConfigFieldsPtr /* fields */,
+ XkbDescPtr /* xkb */
+);
+
+extern XkbConfigRtrnPrivPtr XkbCFAddPrivate(
+ XkbConfigRtrnPtr /* rtrn */,
+ XkbConfigFieldsPtr /* fields */,
+ XPointer /* ptr */
+);
+
+extern void XkbCFFreeRtrn(
+ XkbConfigRtrnPtr /* rtrn */,
+ XkbConfigFieldsPtr /* fields */,
+ XkbDescPtr /* xkb */
+);
+
+extern Bool XkbCFParse(
+ FILE * /* file */,
+ XkbConfigFieldsPtr /* fields */,
+ XkbDescPtr /* xkb */,
+ XkbConfigRtrnPtr /* rtrn */
+);
+
+extern void XkbCFReportError(
+ FILE * /* file */,
+ char * /* name */,
+ int /* error */,
+ int /* line */
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XKBCONFIG_H_ */
diff --git a/nx-X11/lib/xkbfile/XKBfile.h b/nx-X11/lib/xkbfile/XKBfile.h
new file mode 100644
index 000000000..bbd7e6fcd
--- /dev/null
+++ b/nx-X11/lib/xkbfile/XKBfile.h
@@ -0,0 +1,494 @@
+/* $XFree86: xc/lib/xkbfile/XKBfile.h,v 3.6 2003/10/24 16:33:09 tsi Exp $ */
+
+#ifndef _XKBFILE_H_
+#define _XKBFILE_H_ 1
+
+/* $Xorg: XKBfile.h,v 1.3 2000/08/17 19:46:43 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+
+/***====================================================================***/
+
+#define XkbXKMFile 0
+#define XkbCFile 1
+#define XkbXKBFile 2
+#define XkbMessage 3
+
+#define XkbMapDefined (1<<0)
+#define XkbStateDefined (1<<1)
+
+typedef struct _XkbFileInfo {
+ unsigned type;
+ unsigned defined;
+ XkbDescPtr xkb;
+} XkbFileInfo,*XkbFileInfoPtr;
+
+typedef void (*XkbFileAddOnFunc)(
+ FILE * /* file */,
+ XkbFileInfo * /* result */,
+ Bool /* topLevel */,
+ Bool /* showImplicit */,
+ int /* fileSection */,
+ void * /* priv */
+);
+
+/***====================================================================***/
+
+#define _XkbSuccess 0
+#define _XkbErrMissingNames 1
+#define _XkbErrMissingTypes 2
+#define _XkbErrMissingReqTypes 3
+#define _XkbErrMissingSymbols 4
+#define _XkbErrMissingVMods 5
+#define _XkbErrMissingIndicators 6
+#define _XkbErrMissingCompatMap 7
+#define _XkbErrMissingSymInterps 8
+#define _XkbErrMissingGeometry 9
+#define _XkbErrIllegalDoodad 10
+#define _XkbErrIllegalTOCType 11
+#define _XkbErrIllegalContents 12
+#define _XkbErrEmptyFile 13
+#define _XkbErrFileNotFound 14
+#define _XkbErrFileCannotOpen 15
+#define _XkbErrBadValue 16
+#define _XkbErrBadMatch 17
+#define _XkbErrBadTypeName 18
+#define _XkbErrBadTypeWidth 19
+#define _XkbErrBadFileType 20
+#define _XkbErrBadFileVersion 21
+#define _XkbErrBadFileFormat 22
+#define _XkbErrBadAlloc 23
+#define _XkbErrBadLength 24
+#define _XkbErrXReqFailure 25
+#define _XkbErrBadImplementation 26
+
+extern char * _XkbErrMessages[];
+extern unsigned _XkbErrCode;
+extern char * _XkbErrLocation;
+extern unsigned _XkbErrData;
+
+/***====================================================================***/
+
+_XFUNCPROTOBEGIN
+
+extern char * XkbIndentText(
+ unsigned /* size */
+);
+
+extern char * XkbAtomText(
+ Display * /* dpy */,
+ Atom /* atm */,
+ unsigned /* format */
+);
+
+extern char * XkbKeysymText(
+ KeySym /* sym */,
+ unsigned /* format */
+);
+
+extern char * XkbStringText(
+ char * /* str */,
+ unsigned /* format */
+);
+
+extern char * XkbKeyNameText(
+ char * /* name */,
+ unsigned /* format */
+);
+
+extern char *
+XkbModIndexText(
+ unsigned /* ndx */,
+ unsigned /* format */
+);
+
+extern char *
+XkbModMaskText(
+ unsigned /* mask */,
+ unsigned /* format */
+);
+
+extern char * XkbVModIndexText(
+ Display * /* dpy */,
+ XkbDescPtr /* xkb */,
+ unsigned /* ndx */,
+ unsigned /* format */
+);
+
+extern char * XkbVModMaskText(
+ Display * /* dpy */,
+ XkbDescPtr /* xkb */,
+ unsigned /* modMask */,
+ unsigned /* mask */,
+ unsigned /* format */
+);
+
+extern char * XkbConfigText(
+ unsigned /* config */,
+ unsigned /* format */
+);
+
+extern char * XkbSIMatchText(
+ unsigned /* type */,
+ unsigned /* format */
+);
+
+extern char * XkbIMWhichStateMaskText(
+ unsigned /* use_which */,
+ unsigned /* format */
+);
+
+extern char * XkbAccessXDetailText(
+ unsigned /* state */,
+ unsigned /* format */
+);
+
+extern char * XkbNKNDetailMaskText(
+ unsigned /* detail */,
+ unsigned /* format */
+);
+
+extern char * XkbControlsMaskText(
+ unsigned /* ctrls */,
+ unsigned /* format */
+);
+
+extern char * XkbGeomFPText(
+ int /* val */,
+ unsigned /* format */
+);
+
+extern char * XkbDoodadTypeText(
+ unsigned /* type */,
+ unsigned /* format */
+);
+
+extern char * XkbActionTypeText(
+ unsigned /* type */,
+ unsigned /* format */
+);
+
+extern char * XkbActionText(
+ Display * /* dpy */,
+ XkbDescPtr /* xkb */,
+ XkbAction * /* action */,
+ unsigned /* format */
+);
+
+extern char * XkbBehaviorText(
+ XkbDescPtr /* xkb */,
+ XkbBehavior * /* behavior */,
+ unsigned /* format */
+);
+
+/***====================================================================***/
+
+#define _XkbKSLower (1<<0)
+#define _XkbKSUpper (1<<1)
+
+#define XkbKSIsLower(k) (_XkbKSCheckCase(k)&_XkbKSLower)
+#define XkbKSIsUpper(k) (_XkbKSCheckCase(k)&_XkbKSUpper)
+#define XkbKSIsKeypad(k) (((k)>=XK_KP_Space)&&((k)<=XK_KP_Equal))
+#define XkbKSIsDeadKey(k) \
+ (((k)>=XK_dead_grave)&&((k)<=XK_dead_semivoiced_sound))
+
+extern unsigned _XkbKSCheckCase(
+ KeySym /* sym */
+);
+
+extern int XkbFindKeycodeByName(
+ XkbDescPtr /* xkb */,
+ char * /* name */,
+ Bool /* use_aliases */
+);
+
+extern Bool XkbLookupGroupAndLevel(
+ XkbDescPtr /* xkb */,
+ int /* key */,
+ int * /* mods_inout */,
+ int * /* grp_inout */,
+ int * /* lvl_rtrn */
+);
+
+/***====================================================================***/
+
+#ifndef XKB_IN_SERVER
+
+extern Bool XkbLookupCanonicalRGBColor(
+ char * /* def */,
+ XColor * /* color */
+);
+
+#endif
+
+/***====================================================================***/
+
+extern char * XkbAtomGetString(
+ Display * /* dpy */,
+ Atom /* atm */
+);
+
+extern Atom XkbInternAtom(
+ Display * /* dpy */,
+ char * /* name */,
+ Bool /* onlyIfExists */
+);
+
+extern Status XkbChangeKbdDisplay(
+ Display * /* newDpy */,
+ XkbFileInfo * /* result */
+);
+
+extern Atom XkbChangeAtomDisplay(
+ Display * /* oldDpy */,
+ Display * /* newDpy */,
+ Atom /* atm */
+);
+
+extern void XkbInitAtoms(
+ Display * /* dpy */
+);
+
+/***====================================================================***/
+
+#ifdef _XKBGEOM_H_
+
+#define XkbDW_Unknown 0
+#define XkbDW_Doodad 1
+#define XkbDW_Section 2
+typedef struct _XkbDrawable {
+ int type;
+ int priority;
+ union {
+ XkbDoodadPtr doodad;
+ XkbSectionPtr section;
+ } u;
+ struct _XkbDrawable * next;
+} XkbDrawableRec,*XkbDrawablePtr;
+
+extern XkbDrawablePtr
+XkbGetOrderedDrawables(
+ XkbGeometryPtr /* geom */,
+ XkbSectionPtr /* section */
+);
+
+extern void
+XkbFreeOrderedDrawables(
+ XkbDrawablePtr /* draw */
+);
+
+#endif
+
+/***====================================================================***/
+
+extern unsigned XkbConvertGetByNameComponents(
+ Bool /* toXkm */,
+ unsigned /* orig */
+);
+
+extern unsigned XkbConvertXkbComponents(
+ Bool /* toXkm */,
+ unsigned /* orig */
+);
+
+extern Bool XkbDetermineFileType(
+ XkbFileInfo * /* xkb */,
+ int /* format */,
+ int * /* opts_missing */
+);
+
+extern Bool XkbNameMatchesPattern(
+ char * /* name */,
+ char * /* pattern */
+);
+
+/***====================================================================***/
+
+extern Bool XkbWriteXKBKeycodes(
+ FILE * /* file */,
+ XkbFileInfo * /* result */,
+ Bool /* topLevel */,
+ Bool /* showImplicit */,
+ XkbFileAddOnFunc /* addOn */,
+ void * /* priv */
+);
+
+extern Bool XkbWriteXKBKeyTypes(
+ FILE * /* file */,
+ XkbFileInfo * /* result */,
+ Bool /* topLevel */,
+ Bool /* showImplicit */,
+ XkbFileAddOnFunc /* addOn */,
+ void * /* priv */
+);
+
+extern Bool XkbWriteXKBCompatMap(
+ FILE * /* file */,
+ XkbFileInfo * /* result */,
+ Bool /* topLevel */,
+ Bool /* showImplicit */,
+ XkbFileAddOnFunc /* addOn */,
+ void * /* priv */
+);
+
+extern Bool XkbWriteXKBSymbols(
+ FILE * /* file */,
+ XkbFileInfo * /* result */,
+ Bool /* topLevel */,
+ Bool /* showImplicit */,
+ XkbFileAddOnFunc /* addOn */,
+ void * /* priv */
+);
+
+extern Bool XkbWriteXKBGeometry(
+ FILE * /* file */,
+ XkbFileInfo * /* result */,
+ Bool /* topLevel */,
+ Bool /* showImplicit */,
+ XkbFileAddOnFunc /* addOn */,
+ void * /* priv */
+);
+
+extern Bool XkbWriteXKBSemantics(
+ FILE * /* file */,
+ XkbFileInfo * /* result */,
+ Bool /* topLevel */,
+ Bool /* showImplicit */,
+ XkbFileAddOnFunc /* addOn */,
+ void * /* priv */
+);
+
+extern Bool XkbWriteXKBLayout(
+ FILE * /* file */,
+ XkbFileInfo * /* result */,
+ Bool /* topLevel */,
+ Bool /* showImplicit */,
+ XkbFileAddOnFunc /* addOn */,
+ void * /* priv */
+);
+
+extern Bool XkbWriteXKBKeymap(
+ FILE * /* file */,
+ XkbFileInfo * /* result */,
+ Bool /* topLevel */,
+ Bool /* showImplicit */,
+ XkbFileAddOnFunc /* addOn */,
+ void * /* priv */
+);
+
+extern Bool XkbWriteXKBFile(
+ FILE * /* file */,
+ XkbFileInfo * /* result */,
+ Bool /* showImplicit */,
+ XkbFileAddOnFunc /* addOn */,
+ void * /* priv */
+);
+
+extern Bool XkbWriteCFile(
+ FILE * /* file */,
+ char * /* name */,
+ XkbFileInfo * /* info */
+);
+
+extern Bool XkbWriteXKMFile(
+ FILE * /* file */,
+ XkbFileInfo * /* result */
+);
+
+extern Bool XkbWriteToServer(
+ XkbFileInfo * /* result */
+);
+
+extern void XkbEnsureSafeMapName(
+ char * /* name */
+);
+
+extern Bool XkbWriteXKBKeymapForNames(
+ FILE * /* file */,
+ XkbComponentNamesPtr /* names */,
+ Display * /* dpy */,
+ XkbDescPtr /* xkb */,
+ unsigned /* want */,
+ unsigned /* need */
+);
+
+extern Status XkbMergeFile(
+ XkbDescPtr /* xkb */,
+ XkbFileInfo /* finfo */
+);
+
+/***====================================================================***/
+
+extern Bool XkmProbe(
+ FILE * /* file */
+);
+
+extern unsigned XkbReadFromServer(
+ Display * /* dpy */,
+ unsigned /* need */,
+ unsigned /* want */,
+ XkbFileInfo * /* result */
+);
+
+extern unsigned XkmReadFile(
+ FILE * /* file */,
+ unsigned /* need */,
+ unsigned /* want */,
+ XkbFileInfo * /* result */
+);
+
+#ifdef _XKMFORMAT_H_
+
+extern Bool XkmReadTOC(
+ FILE * /* file */,
+ xkmFileInfo * /* file_info */,
+ int /* max_toc */,
+ xkmSectionInfo * /* toc */
+);
+
+extern xkmSectionInfo *XkmFindTOCEntry(
+ xkmFileInfo * /* finfo */,
+ xkmSectionInfo * /* toc */,
+ unsigned /* type */
+);
+
+extern Bool XkmReadFileSection(
+ FILE * /* file */,
+ xkmSectionInfo * /* toc */,
+ XkbFileInfo * /* result */,
+ unsigned * /* loaded_rtrn */
+);
+
+extern char * XkmReadFileSectionName(
+ FILE * /* file */,
+ xkmSectionInfo * /* toc */
+);
+
+#endif /* _XKMFORMAT_H */
+
+_XFUNCPROTOEND
+
+#endif /* _XKBFILE_H_ */
diff --git a/nx-X11/lib/xkbfile/XKBfileInt.h b/nx-X11/lib/xkbfile/XKBfileInt.h
new file mode 100644
index 000000000..f11c46a1c
--- /dev/null
+++ b/nx-X11/lib/xkbfile/XKBfileInt.h
@@ -0,0 +1,79 @@
+#ifndef _XKBFILEINT_H_
+#define _XKBFILEINT_H_ 1
+
+/* $Xorg: XKBfileInt.h,v 1.3 2000/08/17 19:46:43 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86$ */
+
+#include "XKBfile.h"
+
+#ifdef DEBUG
+#define _XkbLibError(c,l,d) \
+ { fprintf(stderr,"xkbfile: %s in %s\n",_XkbErrMessages[c],(l)); \
+ _XkbErrCode= (c); _XkbErrLocation= (l); _XkbErrData= (d); }
+#else
+#define _XkbLibError(c,l,d) \
+ { _XkbErrCode= (c); _XkbErrLocation= (l); _XkbErrData= (d); }
+#endif
+
+#ifndef XKB_IN_SERVER
+
+#define _XkbAlloc(s) malloc((s))
+#define _XkbCalloc(n,s) calloc((n),(s))
+#define _XkbRealloc(o,s) realloc((o),(s))
+#define _XkbTypedAlloc(t) ((t *)malloc(sizeof(t)))
+#define _XkbTypedCalloc(n,t) ((t *)calloc((n),sizeof(t)))
+#define _XkbTypedRealloc(o,n,t) \
+ ((o)?(t *)realloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
+#define _XkbClearElems(a,f,l,t) bzero(&(a)[f],((l)-(f)+1)*sizeof(t))
+#define _XkbFree(p) free(p)
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+#endif
+
+_XFUNCPROTOBEGIN
+
+extern char * _XkbDupString(
+ char * /* old_str */
+);
+
+extern int _XkbStrCaseCmp(
+ char * /* str1 */,
+ char * /* str2 */
+);
+#define _XkbStrCaseEqual(s1,s2) (_XkbStrCaseCmp(s1,s2)==0)
+
+_XFUNCPROTOEND
+
+#endif /* _XKBFILEINT_H_ */
diff --git a/nx-X11/lib/xkbfile/XKBrules.h b/nx-X11/lib/xkbfile/XKBrules.h
new file mode 100644
index 000000000..0d77ca323
--- /dev/null
+++ b/nx-X11/lib/xkbfile/XKBrules.h
@@ -0,0 +1,201 @@
+#ifndef _XKBRULES_H_
+#define _XKBRULES_H_ 1
+
+/* $Xorg: XKBrules.h,v 1.3 2000/08/17 19:46:43 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1996 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbfile/XKBrules.h,v 3.5 2002/11/26 01:43:25 dawes Exp $ */
+
+/***====================================================================***/
+
+typedef struct _XkbRF_VarDefs {
+ char * model;
+ char * layout;
+ char * variant;
+ char * options;
+ unsigned short sz_extra;
+ unsigned short num_extra;
+ char * extra_names;
+ char ** extra_values;
+} XkbRF_VarDefsRec,*XkbRF_VarDefsPtr;
+
+typedef struct _XkbRF_VarDesc {
+ char * name;
+ char * desc;
+} XkbRF_VarDescRec, *XkbRF_VarDescPtr;
+
+typedef struct _XkbRF_DescribeVars {
+ int sz_desc;
+ int num_desc;
+ XkbRF_VarDescPtr desc;
+} XkbRF_DescribeVarsRec,*XkbRF_DescribeVarsPtr;
+
+typedef struct _XkbRF_Rule {
+ int number;
+ int layout_num;
+ int variant_num;
+ char * model;
+ char * layout;
+ char * variant;
+ char * option;
+ /* yields */
+ char * keycodes;
+ char * symbols;
+ char * types;
+ char * compat;
+ char * geometry;
+ char * keymap;
+ unsigned flags;
+} XkbRF_RuleRec,*XkbRF_RulePtr;
+
+typedef struct _XkbRF_Group {
+ int number;
+ char * name;
+ char * words;
+} XkbRF_GroupRec, *XkbRF_GroupPtr;
+
+#define XkbRF_PendingMatch (1L<<1)
+#define XkbRF_Option (1L<<2)
+#define XkbRF_Append (1L<<3)
+#define XkbRF_Normal (1L<<4)
+#define XkbRF_Invalid (1L<<5)
+
+typedef struct _XkbRF_Rules {
+ XkbRF_DescribeVarsRec models;
+ XkbRF_DescribeVarsRec layouts;
+ XkbRF_DescribeVarsRec variants;
+ XkbRF_DescribeVarsRec options;
+ unsigned short sz_extra;
+ unsigned short num_extra;
+ char ** extra_names;
+ XkbRF_DescribeVarsPtr extra;
+
+ unsigned short sz_rules;
+ unsigned short num_rules;
+ XkbRF_RulePtr rules;
+ unsigned short sz_groups;
+ unsigned short num_groups;
+ XkbRF_GroupPtr groups;
+} XkbRF_RulesRec, *XkbRF_RulesPtr;
+
+/***====================================================================***/
+
+_XFUNCPROTOBEGIN
+
+extern Bool XkbRF_GetComponents(
+ XkbRF_RulesPtr /* rules */,
+ XkbRF_VarDefsPtr /* var_defs */,
+ XkbComponentNamesPtr /* names */
+);
+
+extern XkbRF_RulePtr XkbRF_AddRule(
+ XkbRF_RulesPtr /* rules */
+);
+
+extern XkbRF_GroupPtr XkbRF_AddGroup(XkbRF_RulesPtr rules);
+
+extern Bool XkbRF_LoadRules(
+ FILE * /* file */,
+ XkbRF_RulesPtr /* rules */
+);
+
+extern Bool XkbRF_LoadRulesByName(
+ char * /* base */,
+ char * /* locale */,
+ XkbRF_RulesPtr /* rules */
+);
+
+/***====================================================================***/
+
+extern XkbRF_VarDescPtr XkbRF_AddVarDesc(
+ XkbRF_DescribeVarsPtr /* vars */
+);
+
+extern XkbRF_VarDescPtr XkbRF_AddVarDescCopy(
+ XkbRF_DescribeVarsPtr /* vars */,
+ XkbRF_VarDescPtr /* copy_from */
+);
+
+extern XkbRF_DescribeVarsPtr XkbRF_AddVarToDescribe(
+ XkbRF_RulesPtr /* rules */,
+ char * /* name */
+);
+
+extern Bool XkbRF_LoadDescriptions(
+ FILE * /* file */,
+ XkbRF_RulesPtr /* rules */
+);
+
+extern Bool XkbRF_LoadDescriptionsByName(
+ char * /* base */,
+ char * /* locale */,
+ XkbRF_RulesPtr /* rules */
+);
+
+extern XkbRF_RulesPtr XkbRF_Load(
+ char * /* base */,
+ char * /* locale */,
+ Bool /* wantDesc */,
+ Bool /* wantRules */
+);
+
+extern XkbRF_RulesPtr XkbRF_Create(
+ int /* sz_rules */,
+ int /* sz_extra */
+);
+
+/***====================================================================***/
+
+extern void XkbRF_Free(
+ XkbRF_RulesPtr /* rules */,
+ Bool /* freeRules */
+);
+
+
+/***====================================================================***/
+
+#define _XKB_RF_NAMES_PROP_ATOM "_XKB_RULES_NAMES"
+#define _XKB_RF_NAMES_PROP_MAXLEN 1024
+
+#ifndef XKB_IN_SERVER
+
+extern Bool XkbRF_GetNamesProp(
+ Display * /* dpy */,
+ char ** /* rules_file_rtrn */,
+ XkbRF_VarDefsPtr /* var_defs_rtrn */
+);
+
+extern Bool XkbRF_SetNamesProp(
+ Display * /* dpy */,
+ char * /* rules_file */,
+ XkbRF_VarDefsPtr /* var_defs */
+);
+
+#endif
+
+_XFUNCPROTOEND
+
+#endif /* _XKBRULES_H_ */
diff --git a/nx-X11/lib/xkbfile/XKM.h b/nx-X11/lib/xkbfile/XKM.h
new file mode 100644
index 000000000..c6c9f5195
--- /dev/null
+++ b/nx-X11/lib/xkbfile/XKM.h
@@ -0,0 +1,70 @@
+/* $Xorg: XKM.h,v 1.3 2000/08/17 19:46:43 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+#ifndef XKM_H
+#define XKM_H 1
+
+#define XkmFileVersion 15
+
+#define XkmIllegalFile -1
+#define XkmSemanticsFile 20
+#define XkmLayoutFile 21
+#define XkmKeymapFile 22
+#define XkmGeometryFile 23
+
+#define XkmTypesIndex 0
+#define XkmCompatMapIndex 1
+#define XkmSymbolsIndex 2
+#define XkmIndicatorsIndex 3
+#define XkmKeyNamesIndex 4
+#define XkmGeometryIndex 5
+#define XkmVirtualModsIndex 6
+#define XkmLastIndex XkmVirtualModsIndex
+
+#define XkmTypesMask (1<<0)
+#define XkmCompatMapMask (1<<1)
+#define XkmSymbolsMask (1<<2)
+#define XkmIndicatorsMask (1<<3)
+#define XkmKeyNamesMask (1<<4)
+#define XkmGeometryMask (1<<5)
+#define XkmVirtualModsMask (1<<6)
+#define XkmLegalIndexMask (0x7f)
+#define XkmAllIndicesMask (0x7f)
+
+#define XkmSemanticsRequired (XkmCompatMapMask)
+#define XkmSemanticsOptional (XkmTypesMask|XkmVirtualModsMask|XkmIndicatorsMask)
+#define XkmSemanticsLegal (XkmSemanticsRequired|XkmSemanticsOptional)
+#define XkmLayoutRequired (XkmKeyNamesMask|XkmSymbolsMask|XkmTypesMask)
+#define XkmLayoutOptional (XkmVirtualModsMask|XkmGeometryMask)
+#define XkmLayoutLegal (XkmLayoutRequired|XkmLayoutOptional)
+#define XkmKeymapRequired (XkmSemanticsRequired|XkmLayoutRequired)
+#define XkmKeymapOptional ((XkmSemanticsOptional|XkmLayoutOptional)&(~XkmKeymapRequired))
+#define XkmKeymapLegal (XkmKeymapRequired|XkmKeymapOptional)
+
+#define XkmLegalSection(m) (((m)&(~XkmKeymapLegal))==0)
+#define XkmSingleSection(m) (XkmLegalSection(m)&&(((m)&(~(m)+1))==(m)))
+
+#endif /* XKM_H */
diff --git a/nx-X11/lib/xkbfile/XKMformat.h b/nx-X11/lib/xkbfile/XKMformat.h
new file mode 100644
index 000000000..154da5694
--- /dev/null
+++ b/nx-X11/lib/xkbfile/XKMformat.h
@@ -0,0 +1,301 @@
+/* $Xorg: XKMformat.h,v 1.3 2000/08/17 19:46:43 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86$ */
+
+#ifndef _XKMFORMAT_H_
+#define _XKMFORMAT_H_ 1
+
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBproto.h>
+#include <X11/extensions/XKM.h>
+
+typedef struct _xkmFileInfo {
+ CARD8 type;
+ CARD8 min_kc;
+ CARD8 max_kc;
+ CARD8 num_toc;
+ CARD16 present B16;
+ CARD16 pad B16;
+} xkmFileInfo;
+#define sz_xkmFileInfo 8
+
+typedef struct _xkmSectionInfo {
+ CARD16 type B16;
+ CARD16 format B16;
+ CARD16 size B16;
+ CARD16 offset B16;
+} xkmSectionInfo;
+#define sz_xkmSectionInfo 8
+
+typedef struct _xkmKeyTypeDesc {
+ CARD8 realMods;
+ CARD8 numLevels;
+ CARD16 virtualMods B16;
+ CARD8 nMapEntries;
+ CARD8 nLevelNames;
+ CARD8 preserve;
+ CARD8 pad;
+} xkmKeyTypeDesc;
+#define sz_xkmKeyTypeDesc 8
+
+typedef struct _xkmKTMapEntryDesc {
+ CARD8 level;
+ CARD8 realMods;
+ CARD16 virtualMods B16;
+} xkmKTMapEntryDesc;
+#define sz_xkmKTMapEntryDesc 4
+
+typedef struct _xkmModsDesc {
+ CARD8 realMods;
+ CARD8 pad;
+ CARD16 virtualMods B16;
+} xkmModsDesc;
+#define sz_xkmModsDesc 4
+
+typedef struct _xkmVModMapDesc {
+ CARD8 key;
+ CARD8 pad;
+ CARD16 vmods B16;
+} xkmVModMapDesc;
+#define sz_xkmVModMapDesc 4
+
+typedef struct _xkmSymInterpretDesc {
+ CARD32 sym B32;
+ CARD8 mods;
+ CARD8 match;
+ CARD8 virtualMod;
+ CARD8 flags;
+ CARD8 actionType;
+ CARD8 actionData[7];
+} xkmSymInterpretDesc;
+#define sz_xkmSymInterpretDesc 16
+
+typedef struct _xkmBehaviorDesc {
+ CARD8 type;
+ CARD8 data;
+ CARD16 pad B16;
+} xkmBehaviorDesc;
+#define sz_xkmBehaviorDesc 4
+
+typedef struct _xkmActionDesc {
+ CARD8 type;
+ CARD8 data[7];
+} xkmActionDesc;
+#define sz_xkmActionDesc 8
+
+#define XkmKeyHasTypes (0x0f)
+#define XkmKeyHasGroup1Type (1<<0)
+#define XkmKeyHasGroup2Type (1<<1)
+#define XkmKeyHasGroup3Type (1<<2)
+#define XkmKeyHasGroup4Type (1<<3)
+#define XkmKeyHasActions (1<<4)
+#define XkmKeyHasBehavior (1<<5)
+#define XkmRepeatingKey (1<<6)
+#define XkmNonRepeatingKey (1<<7)
+
+typedef struct _xkmKeySymMapDesc {
+ CARD8 width;
+ CARD8 num_groups;
+ CARD8 modifier_map;
+ CARD8 flags;
+} xkmKeySymMapDesc;
+#define sz_xkmKeySymMapDesc 4
+
+typedef struct _xkmIndicatorMapDesc {
+ CARD8 indicator;
+ CARD8 flags;
+ CARD8 which_mods;
+ CARD8 real_mods;
+ CARD16 vmods B16;
+ CARD8 which_groups;
+ CARD8 groups;
+ CARD32 ctrls B32;
+} xkmIndicatorMapDesc;
+#define sz_xkmIndicatorMapDesc 12
+
+typedef struct _xkmGeometryDesc {
+ CARD16 width_mm B16;
+ CARD16 height_mm B16;
+ CARD8 base_color_ndx;
+ CARD8 label_color_ndx;
+ CARD16 num_properties B16;
+ CARD16 num_colors B16;
+ CARD16 num_shapes B16;
+ CARD16 num_sections B16;
+ CARD16 num_doodads B16;
+ CARD16 num_key_aliases B16;
+ CARD16 pad1 B16;
+} xkmGeometryDesc;
+#define sz_xkmGeometryDesc 20
+
+typedef struct _xkmPointDesc {
+ INT16 x B16;
+ INT16 y B16;
+} xkmPointDesc;
+#define sz_xkmPointDesc 4
+
+typedef struct _xkmOutlineDesc {
+ CARD8 num_points;
+ CARD8 corner_radius;
+ CARD16 pad B16;
+} xkmOutlineDesc;
+#define sz_xkmOutlineDesc 4
+
+typedef struct _xkmShapeDesc {
+ CARD8 num_outlines;
+ CARD8 primary_ndx;
+ CARD8 approx_ndx;
+ CARD8 pad;
+} xkmShapeDesc;
+#define sz_xkmShapeDesc 4
+
+typedef struct _xkmSectionDesc {
+ INT16 top B16;
+ INT16 left B16;
+ CARD16 width B16;
+ CARD16 height B16;
+ INT16 angle B16;
+ CARD8 priority;
+ CARD8 num_rows;
+ CARD8 num_doodads;
+ CARD8 num_overlays;
+ CARD16 pad2 B16;
+} xkmSectionDesc;
+#define sz_xkmSectionDesc 16
+
+typedef struct _xkmRowDesc {
+ INT16 top B16;
+ INT16 left B16;
+ CARD8 num_keys;
+ BOOL vertical;
+ CARD16 pad B16;
+} xkmRowDesc;
+#define sz_xkmRowDesc 8
+
+typedef struct _xkmKeyDesc {
+ CARD8 name[XkbKeyNameLength];
+ INT16 gap B16;
+ CARD8 shape_ndx;
+ CARD8 color_ndx;
+} xkmKeyDesc;
+#define sz_xkmKeyDesc 8
+
+typedef struct _xkmOverlayDesc {
+ CARD8 num_rows;
+ CARD8 pad1;
+ CARD16 pad2 B16;
+} xkmOverlayDesc;
+#define sz_xkmOverlayDesc 4
+
+typedef struct _xkmOverlayRowDesc {
+ CARD8 row_under;
+ CARD8 num_keys;
+ CARD16 pad B16;
+} xkmOverlayRowDesc;
+#define sz_xkmOverlayRowDesc 4
+
+typedef struct _xkmOverlayKeyDesc {
+ char over[XkbKeyNameLength];
+ char under[XkbKeyNameLength];
+} xkmOverlayKeyDesc;
+#define sz_xkmOverlayKeyDesc 8
+
+typedef struct _xkmShapeDoodadDesc {
+ CARD8 type;
+ CARD8 priority;
+ INT16 top B16;
+ INT16 left B16;
+ INT16 angle B16;
+ CARD8 color_ndx;
+ CARD8 shape_ndx;
+ CARD16 pad B16;
+ CARD32 pad1 B32;
+} xkmShapeDoodadDesc;
+#define sz_xkmShapeDoodadDesc 16
+
+typedef struct _xkmTextDoodadDesc {
+ CARD8 type;
+ CARD8 priority;
+ INT16 top B16;
+ INT16 left B16;
+ INT16 angle B16;
+ CARD16 width B16;
+ CARD16 height B16;
+ CARD8 color_ndx;
+ CARD8 pad1;
+ CARD16 pad2 B16;
+} xkmTextDoodadDesc;
+#define sz_xkmTextDoodadDesc 16
+
+typedef struct _xkmIndicatorDoodadDesc {
+ CARD8 type;
+ CARD8 priority;
+ INT16 top B16;
+ INT16 left B16;
+ CARD8 shape_ndx;
+ CARD8 on_color_ndx;
+ CARD8 off_color_ndx;
+ CARD8 pad1;
+ CARD16 pad2 B16;
+ CARD32 pad3 B32;
+} xkmIndicatorDoodadDesc;
+#define sz_xkmIndicatorDoodadDesc 16
+
+typedef struct _xkmLogoDoodadDesc {
+ CARD8 type;
+ CARD8 priority;
+ INT16 top B16;
+ INT16 left B16;
+ INT16 angle B16;
+ CARD8 color_ndx;
+ CARD8 shape_ndx;
+ CARD16 pad B16;
+ CARD32 pad1 B32;
+} xkmLogoDoodadDesc;
+#define sz_xkmLogoDoodadDesc 16
+
+typedef struct _xkmAnyDoodadDesc {
+ CARD8 type;
+ CARD8 priority;
+ INT16 top B16;
+ INT16 left B16;
+ CARD16 pad1 B16;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+} xkmAnyDoodadDesc;
+#define sz_xkmAnyDoodadDesc 16
+
+typedef union _xkmDoodadDesc {
+ xkmAnyDoodadDesc any;
+ xkmShapeDoodadDesc shape;
+ xkmTextDoodadDesc text;
+ xkmIndicatorDoodadDesc indicator;
+ xkmLogoDoodadDesc logo;
+} xkmDoodadDesc;
+#define sz_xkmDoodadDesc 16
+
+#endif /* _XKMFORMAT_H_ */
diff --git a/nx-X11/lib/xkbfile/cout.c b/nx-X11/lib/xkbfile/cout.c
new file mode 100644
index 000000000..161bd0f89
--- /dev/null
+++ b/nx-X11/lib/xkbfile/cout.c
@@ -0,0 +1,1036 @@
+/* $Xorg: cout.c,v 1.3 2000/08/17 19:46:43 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+ /* $XFree86: xc/lib/xkbfile/cout.c,v 3.8 2003/02/03 20:12:00 paulo Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKBgeom.h>
+
+#include "XKMformat.h"
+#include "XKBfileInt.h"
+
+#define lowbit(x) ((x) & (-(x)))
+
+static Bool
+WriteCHdrVMods(FILE *file,Display *dpy,XkbDescPtr xkb)
+{
+register int i,nOut;
+
+ if ((!xkb)||(!xkb->names)||(!xkb->names->vmods))
+ return False;
+ for (i=nOut=0;i<XkbNumVirtualMods;i++) {
+ if (xkb->names->vmods[i]!=None) {
+ fprintf(file,"%s#define vmod_%s %d\n",(nOut<1?"\n":""),
+ XkbAtomText(dpy,xkb->names->vmods[i],XkbCFile),
+ i);
+ nOut++;
+ }
+ }
+ for (i=nOut=0;i<XkbNumVirtualMods;i++) {
+ if (xkb->names->vmods[i]!=None) {
+ fprintf(file,"%s#define vmod_%sMask (1<<%d)\n",
+ (nOut<1?"\n":""),
+ XkbAtomText(dpy,xkb->names->vmods[i],XkbCFile)
+ ,i);
+ nOut++;
+ }
+ }
+ if (nOut>0)
+ fprintf(file,"\n");
+ return True;
+}
+
+static Bool
+WriteCHdrKeycodes(FILE *file,XkbDescPtr xkb)
+{
+Atom kcName;
+register unsigned i;
+char buf[8];
+
+ if ((!xkb)||(!xkb->names)||(!xkb->names->keys)) {
+ _XkbLibError(_XkbErrMissingNames,"WriteCHdrKeycodes",0);
+ return False;
+ }
+ kcName= xkb->names->keycodes;
+ buf[4]= '\0';
+ if (xkb->names->keycodes!=None)
+ fprintf(file,"/* keycodes name is \"%s\" */\n",
+ XkbAtomText(xkb->dpy,kcName,XkbMessage));
+ fprintf(file,"static XkbKeyNameRec keyNames[NUM_KEYS]= {\n");
+ for (i=0;i<=xkb->max_key_code;i++) {
+ sprintf(buf,"\"%s\"",XkbKeyNameText(xkb->names->keys[i].name,XkbCFile));
+ if (i!=xkb->max_key_code) {
+ fprintf(file," { %6s },",buf);
+ if ((i&3)==3)
+ fprintf(file,"\n");
+ }
+ else {
+ fprintf(file," { %6s }\n",buf);
+ }
+ }
+ fprintf(file,"};\n");
+ return True;
+}
+
+static void
+WriteTypePreserve( FILE * file,
+ Display * dpy,
+ char * prefix,
+ XkbDescPtr xkb,
+ XkbKeyTypePtr type)
+{
+register unsigned i;
+XkbModsPtr pre;
+
+ fprintf(file,"static XkbModsRec preserve_%s[%d]= {\n",prefix,
+ type->map_count);
+ for (i=0,pre=type->preserve;i<type->map_count;i++,pre++) {
+ if (i!=0)
+ fprintf(file,",\n");
+ fprintf(file," { %15s, ",XkbModMaskText(pre->mask,XkbCFile));
+ fprintf(file,"%15s, ",XkbModMaskText(pre->real_mods,XkbCFile));
+ fprintf(file,"%15s }",XkbVModMaskText(dpy,xkb,0,pre->vmods,XkbCFile));
+ }
+ fprintf(file,"\n};\n");
+ return;
+}
+
+static void
+WriteTypeInitFunc(FILE *file,Display *dpy,XkbDescPtr xkb)
+{
+register unsigned i,n;
+XkbKeyTypePtr type;
+Atom * names;
+char prefix[32];
+
+ fprintf(file,"\n\nstatic void\n");
+ fprintf(file,"initTypeNames(DPYTYPE dpy)\n");
+ fprintf(file,"{\n");
+ for (i=0,type=xkb->map->types;i<xkb->map->num_types;i++,type++) {
+ strcpy(prefix,XkbAtomText(dpy,type->name,XkbCFile));
+ if (type->name!=None)
+ fprintf(file," dflt_types[%d].name= GET_ATOM(dpy,\"%s\");\n",i,
+ XkbAtomText(dpy,type->name,XkbCFile));
+ names= type->level_names;
+ if (names!=NULL) {
+ char *tmp;
+ for (n=0;n<type->num_levels;n++) {
+ if (names[n]==None)
+ continue;
+ tmp= XkbAtomText(dpy,names[n],XkbCFile);
+ if (tmp==NULL)
+ continue;
+ fprintf(file," lnames_%s[%d]= ",prefix,n);
+ fprintf(file,"GET_ATOM(dpy,\"%s\");\n",tmp);
+ }
+ }
+ }
+ fprintf(file,"}\n");
+ return;
+}
+
+static Bool
+WriteCHdrKeyTypes(FILE *file,Display *dpy,XkbDescPtr xkb)
+{
+register unsigned i,n;
+XkbClientMapPtr map;
+XkbKeyTypePtr type;
+char prefix[32];
+
+ if ((!xkb)||(!xkb->map)||(!xkb->map->types)) {
+ _XkbLibError(_XkbErrMissingTypes,"WriteCHdrKeyTypes",0);
+ return False;
+ }
+ if (xkb->map->num_types<XkbNumRequiredTypes) {
+ _XkbLibError(_XkbErrMissingReqTypes,"WriteCHdrKeyTypes",0);
+ return 0;
+ }
+ map= xkb->map;
+ if ((xkb->names!=NULL)&&(xkb->names->types!=None)) {
+ fprintf(file,"/* types name is \"%s\" */\n",
+ XkbAtomText(dpy,xkb->names->types,XkbCFile));
+ }
+ for (i=0,type=map->types;i<map->num_types;i++,type++) {
+ strcpy(prefix,XkbAtomText(dpy,type->name,XkbCFile));
+
+ if (type->map_count>0) {
+ XkbKTMapEntryPtr entry;
+ entry= type->map;
+ fprintf(file,"static XkbKTMapEntryRec map_%s[%d]= {\n",prefix,
+ type->map_count);
+ for (n=0;n<(unsigned)type->map_count;n++,entry++) {
+ if (n!=0)
+ fprintf(file,",\n");
+ fprintf(file," { %d, %6d, { %15s, %15s, %15s } }",
+ entry->active,
+ entry->level,
+ XkbModMaskText(entry->mods.mask,XkbCFile),
+ XkbModMaskText(entry->mods.real_mods,XkbCFile),
+ XkbVModMaskText(dpy,xkb,0,entry->mods.vmods,XkbCFile));
+ }
+ fprintf(file,"\n};\n");
+
+ if (type->preserve)
+ WriteTypePreserve(file,dpy,prefix,xkb,type);
+ }
+ if (type->level_names!=NULL) {
+ fprintf(file,"static Atom lnames_%s[%d];\n",prefix,
+ type->num_levels);
+ }
+ fprintf(file,"\n");
+ }
+ fprintf(file,"static XkbKeyTypeRec dflt_types[]= {\n");
+ for (i=0,type=map->types;i<(unsigned)map->num_types;i++,type++) {
+ strcpy(prefix,XkbAtomText(dpy,type->name,XkbCFile));
+ if (i!=0) fprintf(file,",\n");
+ fprintf(file," {\n { %15s, %15s, %15s },\n",
+ XkbModMaskText(type->mods.mask,XkbCFile),
+ XkbModMaskText(type->mods.real_mods,XkbCFile),
+ XkbVModMaskText(dpy,xkb,0,type->mods.vmods,XkbCFile));
+ fprintf(file," %d,\n",type->num_levels);
+ fprintf(file," %d,",type->map_count);
+ if (type->map_count>0)
+ fprintf(file," map_%s,",prefix);
+ else fprintf(file," NULL,");
+ if (type->preserve)
+ fprintf(file," preserve_%s,\n",prefix);
+ else fprintf(file," NULL,\n");
+ if (type->level_names!=NULL)
+ fprintf(file," None, lnames_%s\n }",prefix);
+ else fprintf(file," None, NULL\n }");
+ }
+ fprintf(file,"\n};\n");
+ fprintf(file,"#define num_dflt_types (sizeof(dflt_types)/sizeof(XkbKeyTypeRec))\n");
+ WriteTypeInitFunc(file,dpy,xkb);
+ return True;
+}
+
+static Bool
+WriteCHdrCompatMap(FILE *file,Display *dpy,XkbDescPtr xkb)
+{
+register unsigned i;
+XkbCompatMapPtr compat;
+XkbSymInterpretPtr interp;
+
+ if ((!xkb)||(!xkb->compat)||(!xkb->compat->sym_interpret)) {
+ _XkbLibError(_XkbErrMissingSymInterps,"WriteCHdrInterp",0);
+ return False;
+ }
+ compat= xkb->compat;
+ if ((xkb->names!=NULL)&&(xkb->names->compat!=None)) {
+ fprintf(file,"/* compat name is \"%s\" */\n",
+ XkbAtomText(dpy,xkb->names->compat,XkbCFile));
+ }
+ fprintf(file,"static XkbSymInterpretRec dfltSI[%d]= {\n",
+ compat->num_si);
+ interp= compat->sym_interpret;
+ for (i=0;i<compat->num_si;i++,interp++) {
+ XkbAction *act;
+ act= (XkbAction *)&interp->act;
+ if (i!=0) fprintf(file,",\n");
+ fprintf(file," { %s, ",XkbKeysymText(interp->sym,XkbCFile));
+ fprintf(file,"0x%04x,\n",interp->flags);
+ fprintf(file," %s, ",XkbSIMatchText(interp->match,XkbCFile));
+ fprintf(file,"%s,\n",XkbModMaskText(interp->mods,XkbCFile));
+ fprintf(file," %d,\n",interp->virtual_mod);
+ fprintf(file," %s }",XkbActionText(dpy,xkb,act,XkbCFile));
+ }
+ fprintf(file,"\n};\n");
+ fprintf(file,
+ "#define num_dfltSI (sizeof(dfltSI)/sizeof(XkbSymInterpretRec))\n");
+ fprintf(file,"\nstatic XkbCompatMapRec compatMap= {\n");
+ fprintf(file," dfltSI,\n");
+ fprintf(file," { /* group compatibility */\n ");
+ for (i=0;i<XkbNumKbdGroups;i++) {
+ XkbModsPtr gc;
+ gc= &xkb->compat->groups[i];
+ fprintf(file,"%s{ %12s, %12s, %12s }",
+ ((i==0)?"":",\n "),
+ XkbModMaskText(gc->mask,XkbCFile),
+ XkbModMaskText(gc->real_mods,XkbCFile),
+ XkbVModMaskText(xkb->dpy,xkb,0,gc->vmods,XkbCFile));
+ }
+ fprintf(file,"\n },\n");
+ fprintf(file," num_dfltSI, num_dfltSI\n");
+ fprintf(file,"};\n\n");
+ return True;
+}
+
+static Bool
+WriteCHdrSymbols(FILE *file,XkbDescPtr xkb)
+{
+register unsigned i;
+
+ if ((!xkb)||(!xkb->map)||(!xkb->map->syms)||(!xkb->map->key_sym_map)) {
+ _XkbLibError(_XkbErrMissingSymbols,"WriteCHdrSymbols",0);
+ return False;
+ }
+ fprintf(file,"#define NUM_SYMBOLS %d\n",xkb->map->num_syms);
+ if (xkb->map->num_syms>0) {
+ register KeySym *sym;
+ sym= xkb->map->syms;
+ fprintf(file,"static KeySym symCache[NUM_SYMBOLS]= {\n");
+ for (i=0;i<xkb->map->num_syms;i++,sym++) {
+ if (i==0) fprintf(file," ");
+ else if (i%4==0) fprintf(file,",\n ");
+ else fprintf(file,", ");
+ fprintf(file,"%15s",XkbKeysymText(*sym,XkbCFile));
+ }
+ fprintf(file,"\n};\n");
+ }
+ if (xkb->max_key_code>0) {
+ register XkbSymMapPtr map;
+ map= xkb->map->key_sym_map;
+ fprintf(file,"static XkbSymMapRec symMap[NUM_KEYS]= {\n");
+ for (i=0;i<=xkb->max_key_code;i++,map++) {
+ if (i==0) fprintf(file," ");
+ else if ((i&3)==0) fprintf(file,",\n ");
+ else fprintf(file,", ");
+ fprintf(file, "{ %2d, 0x%x, %3d }",
+ map->kt_index[0], map->group_info, map->offset);
+ }
+ fprintf(file,"\n};\n");
+ }
+ return True;
+}
+
+static Bool
+WriteCHdrClientMap(FILE *file,Display *dpy,XkbDescPtr xkb)
+{
+ if ((!xkb)||(!xkb->map)||(!xkb->map->syms)||(!xkb->map->key_sym_map)) {
+ _XkbLibError(_XkbErrMissingSymbols,"WriteCHdrClientMap",0);
+ return False;
+ }
+ if (!WriteCHdrKeyTypes(file,dpy,xkb))
+ return False;
+ if (!WriteCHdrSymbols(file,xkb))
+ return False;
+ fprintf(file,"static XkbClientMapRec clientMap= {\n");
+ fprintf(file," NUM_TYPES, NUM_TYPES, types, \n");
+ fprintf(file," NUM_SYMBOLS, NUM_SYMBOLS, symCache, symMap\n");
+ fprintf(file,"};\n\n");
+ return True;
+}
+
+static Bool
+WriteCHdrServerMap(FILE *file,Display *dpy,XkbDescPtr xkb)
+{
+register unsigned i;
+
+ if ((!xkb)||(!xkb->map)||(!xkb->map->syms)||(!xkb->map->key_sym_map)) {
+ _XkbLibError(_XkbErrMissingSymbols,"WriteCHdrServerMap",0);
+ return False;
+ }
+ if (xkb->server->num_acts>0) {
+ register XkbAnyAction *act;
+ act= (XkbAnyAction *)xkb->server->acts;
+ fprintf(file,"#define NUM_ACTIONS %d\n",xkb->server->num_acts);
+ fprintf(file,"static XkbAnyAction actionCache[NUM_ACTIONS]= {\n");
+ for (i=0;i<xkb->server->num_acts;i++,act++) {
+ if (i==0) fprintf(file," ");
+ else fprintf(file,",\n ");
+ fprintf(file,"%s",XkbActionText(dpy,xkb,(XkbAction *)act,XkbCFile));
+ }
+ fprintf(file,"\n};\n");
+ }
+ fprintf(file,"static unsigned short keyActions[NUM_KEYS]= {\n");
+ for (i=0;i<=xkb->max_key_code;i++) {
+ if (i==0) fprintf(file," ");
+ else if ((i&0xf)==0) fprintf(file,",\n ");
+ else fprintf(file,", ");
+ fprintf(file,"%2d",xkb->server->key_acts[i]);
+ }
+ fprintf(file,"\n};\n");
+ fprintf(file,"static XkbBehavior behaviors[NUM_KEYS]= {\n");
+ for (i=0;i<=xkb->max_key_code;i++) {
+ if (i==0) fprintf(file," ");
+ else if ((i&0x3)==0) fprintf(file,",\n ");
+ else fprintf(file,", ");
+ if (xkb->server->behaviors) {
+ fprintf(file,"%s",
+ XkbBehaviorText(xkb,&xkb->server->behaviors[i],XkbCFile));
+ }
+ else fprintf(file,"{ 0, 0 }");
+ }
+ fprintf(file,"\n};\n");
+ fprintf(file,"static unsigned char explicit_parts[NUM_KEYS]= {\n");
+ for (i=0;i<=xkb->max_key_code;i++) {
+ if (i==0) fprintf(file," ");
+ else if ((i&0x7)==0) fprintf(file,",\n ");
+ else fprintf(file,", ");
+ if ((xkb->server->explicit==NULL)||(xkb->server->explicit[i]==0))
+ fprintf(file," 0");
+ else fprintf(file,"0x%02x",xkb->server->explicit[i]);
+ }
+ fprintf(file,"\n};\n");
+ fprintf(file,"static unsigned short vmodmap[NUM_KEYS]= {\n");
+ for (i=0;i<xkb->max_key_code;i++) {
+ if (i==0) fprintf(file," ");
+ else if ((i&0x7)==0) fprintf(file,",\n ");
+ else fprintf(file,", ");
+ if ((xkb->server->vmodmap==NULL)||(xkb->server->vmodmap[i]==0))
+ fprintf(file," 0");
+ else fprintf(file,"0x%04x",xkb->server->vmodmap[i]);
+ }
+ fprintf(file,"};\n");
+ fprintf(file,"static XkbServerMapRec serverMap= {\n");
+ fprintf(file," %d, %d, (XkbAction *)actionCache,\n",
+ xkb->server->num_acts,xkb->server->num_acts);
+ fprintf(file," behaviors, keyActions, explicit_parts,\n");
+ for (i=0;i<XkbNumVirtualMods;i++) {
+ if (i==0) fprintf(file," { ");
+ else if (i==8) fprintf(file,",\n ");
+ else fprintf(file,", ");
+ fprintf(file,"%3d",xkb->server->vmods[i]);
+ }
+ fprintf(file," },\n");
+ fprintf(file," vmodmap\n");
+ fprintf(file,"};\n\n");
+ return True;
+}
+
+static Bool
+WriteCHdrIndicators(FILE *file,Display *dpy,XkbDescPtr xkb)
+{
+register int i,nNames;
+XkbIndicatorMapPtr imap;
+
+ if (xkb->indicators==NULL)
+ return True;
+ fprintf(file, "static XkbIndicatorRec indicators= {\n");
+ fprintf(file, " 0x%lx,\n {\n",
+ (long)xkb->indicators->phys_indicators);
+ for (imap=xkb->indicators->maps,i=nNames=0;i<XkbNumIndicators;i++,imap++) {
+ fprintf(file,"%s { 0x%02x, %s, 0x%02x, %s, { %s, ",
+ (i!=0?",\n":""),
+ imap->flags,
+ XkbIMWhichStateMaskText(imap->which_groups,XkbCFile),
+ imap->groups,
+ XkbIMWhichStateMaskText(imap->which_mods,XkbCFile),
+ XkbModMaskText(imap->mods.mask,XkbCFile));
+ fprintf(file," %s, %s }, %s }",
+ XkbModMaskText(imap->mods.real_mods,XkbCFile),
+ XkbVModMaskText(dpy,xkb,0,imap->mods.vmods,XkbCFile),
+ XkbControlsMaskText(imap->ctrls,XkbCFile));
+ if (xkb->names && (xkb->names->indicators[i]!=None))
+ nNames++;
+ }
+ fprintf(file,"\n }\n};\n");
+ if (nNames>0) {
+ fprintf(file,"static void\n");
+ fprintf(file,"initIndicatorNames(DPYTYPE dpy,XkbDescPtr xkb)\n");
+ fprintf(file,"{\n");
+ for (i=0;i<XkbNumIndicators;i++) {
+ Atom name;
+ if (xkb->names->indicators[i]==None)
+ continue;
+ name= xkb->names->indicators[i];
+ fprintf(file," xkb->names->indicators[%2d]= ",i);
+ fprintf(file,"GET_ATOM(dpy,\"%s\");\n",
+ XkbAtomText(dpy,name,XkbCFile));
+ }
+ fprintf(file,"}\n");
+ }
+ return True;
+}
+
+static Bool
+WriteCHdrGeomProps(FILE *file,XkbDescPtr xkb,XkbGeometryPtr geom)
+{
+ if (geom->num_properties>0) {
+ register int i;
+ fprintf(file,"\nstatic XkbPropertyRec g_props[%d]= {\n",
+ geom->num_properties);
+ for (i=0;i<geom->num_properties;i++) {
+ fprintf(file,"%s { \"%s\", \"%s\" }",(i==0?"":",\n"),
+ XkbStringText(geom->properties[i].name,XkbCFile),
+ XkbStringText(geom->properties[i].value,XkbCFile));
+ }
+ fprintf(file,"\n};\n");
+ }
+ return True;
+}
+
+static Bool
+WriteCHdrGeomColors(FILE *file,XkbDescPtr xkb,XkbGeometryPtr geom)
+{
+ if (geom->num_colors>0) {
+ register int i;
+ fprintf(file,"\nstatic XkbColorRec g_colors[%d]= {\n",geom->num_colors);
+ for (i=0;i<geom->num_colors;i++) {
+ fprintf(file,"%s { %3d, \"%s\" }",(i==0?"":",\n"),
+ geom->colors[i].pixel,
+ XkbStringText(geom->colors[i].spec,XkbCFile));
+ }
+ fprintf(file,"\n};\n");
+ }
+ return True;
+}
+
+static Bool
+WriteCHdrGeomOutlines(FILE *file,int nOL,XkbOutlinePtr ol,int shapeNdx)
+{
+register int o,p;
+
+
+ for (o=0;o<nOL;o++) {
+ fprintf(file,"\nstatic XkbPointRec pts_sh%02do%02d[]= {\n",shapeNdx,o);
+ for (p=0;p<ol[o].num_points;p++) {
+ if (p==0) fprintf(file," ");
+ else if ((p&0x3)==0) fprintf(file,",\n ");
+ else fprintf(file,", ");
+ fprintf(file,"{ %4d, %4d }",
+ ol[o].points[p].x,ol[o].points[p].y);
+ }
+ fprintf(file,"\n};");
+ }
+ fprintf(file,"\n\nstatic XkbOutlineRec ol_sh%02d[]= {\n",shapeNdx);
+ for (o=0;o<nOL;o++) {
+ fprintf(file,"%s { %d, %d, %d, pts_sh%02do%02d }",
+ (o==0?"":",\n"),
+ ol[o].num_points,ol[o].num_points,
+ ol[o].corner_radius,shapeNdx,o);
+ }
+ fprintf(file,"\n};\n");
+ return True;
+}
+
+static Bool
+WriteCHdrGeomShapes(FILE *file,XkbDescPtr xkb,XkbGeometryPtr geom)
+{
+register int s;
+register XkbShapePtr shape;
+
+ for (s=0,shape=geom->shapes;s<geom->num_shapes;s++,shape++) {
+ WriteCHdrGeomOutlines(file,shape->num_outlines,shape->outlines,s);
+ }
+ fprintf(file,"\n\nstatic XkbShapeRec g_shapes[%d]= {\n",geom->num_shapes);
+ for (s=0,shape=geom->shapes;s<geom->num_shapes;s++,shape++) {
+ fprintf(file,"%s { None, %3d, %3d, ol_sh%02d, ",
+ (s==0?"":",\n"),shape->num_outlines,
+ shape->num_outlines,s);
+ if (shape->approx) {
+ fprintf(file,"&ol_sh%02d[%2d], ",s,
+ XkbOutlineIndex(shape,shape->approx));
+ }
+ else fprintf(file," NULL, ");
+ if (shape->primary) {
+ fprintf(file,"&ol_sh%02d[%2d],\n",s,
+ XkbOutlineIndex(shape,shape->primary));
+ }
+ else fprintf(file," NULL,\n");
+ fprintf(file," { %4d, %4d, %4d, %4d } }",
+ shape->bounds.x1,shape->bounds.y1,
+ shape->bounds.x2,shape->bounds.y2);
+ }
+ fprintf(file,"\n};\n");
+ return True;
+}
+
+static Bool
+WriteCHdrGeomDoodads( FILE * file,
+ XkbDescPtr xkb,
+ XkbGeometryPtr geom,
+ XkbSectionPtr section,
+ int section_num)
+{
+int nd,d;
+XkbDoodadPtr doodad;
+Display * dpy;
+
+ dpy= xkb->dpy;
+ if (section==NULL) {
+ if (geom->num_doodads>0) {
+ fprintf(file,"static XkbDoodadRec g_doodads[%d];\n",
+ geom->num_doodads);
+ }
+ fprintf(file,"static void\n");
+ fprintf(file,"_InitGeomDoodads(DPYTYPE dpy,XkbGeometryPtr geom)\n");
+ fprintf(file,"{\n");
+ fprintf(file,"register XkbDoodadPtr doodads;\n\n");
+ fprintf(file," doodads= geom->doodads;\n");
+ nd= geom->num_doodads;
+ doodad= geom->doodads;
+ }
+ else {
+ if (section->num_doodads>0) {
+ fprintf(file,"static XkbDoodadRec doodads_s%02d[%d];\n",
+ section_num,section->num_doodads);
+ }
+ fprintf(file,"static void\n");
+ fprintf(file,"_InitS%02dDoodads(",section_num);
+ fprintf(file," DPYTYPE dpy,\n");
+ fprintf(file," XkbGeometryPtr geom,\n");
+ fprintf(file," XkbSectionPtr section)\n");
+ fprintf(file,"{\n");
+ fprintf(file,"register XkbDoodadPtr doodads;\n\n");
+ fprintf(file," doodads= section->doodads;\n");
+ nd= geom->num_doodads;
+ doodad= geom->doodads;
+ }
+ for (d=0;d<nd;d++,doodad++) {
+ if (d!=0) fprintf(file,"\n");
+ fprintf(file," doodads[%d].any.name= GET_ATOM(dpy,\"%s\");\n",d,
+ XkbAtomText(dpy,doodad->any.name,XkbCFile));
+ fprintf(file," doodads[%d].any.type= %s;\n",d,
+ XkbDoodadTypeText(doodad->any.type,XkbCFile));
+ fprintf(file," doodads[%d].any.priority= %d;\n",d,
+ doodad->any.priority);
+ fprintf(file," doodads[%d].any.top= %d;\n",d,doodad->any.top);
+ fprintf(file," doodads[%d].any.left= %d;\n",d,doodad->any.left);
+ fprintf(file," doodads[%d].any.angle= %d;\n",d,doodad->any.angle);
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ fprintf(file," doodads[%d].shape.color_ndx= %d;\n",d,
+ doodad->shape.color_ndx);
+ fprintf(file," doodads[%d].shape.shape_ndx= %d;\n",d,
+ doodad->shape.shape_ndx);
+ break;
+ case XkbTextDoodad:
+ fprintf(file," doodads[%d].text.width= %d;\n",d,
+ doodad->text.width);
+ fprintf(file," doodads[%d].text.height= %d;\n",d,
+ doodad->text.height);
+ fprintf(file," doodads[%d].text.color_ndx= %d;\n",d,
+ doodad->text.color_ndx);
+ fprintf(file," doodads[%d].text.text= \"%s\";\n",d,
+ XkbStringText(doodad->text.text,XkbCFile));
+ fprintf(file," doodads[%d].text.font= \"%s\";\n",d,
+ XkbStringText(doodad->text.font,XkbCFile));
+ break;
+ case XkbIndicatorDoodad:
+ fprintf(file," doodads[%d].indicator.shape_ndx= %d;\n",d,
+ doodad->indicator.shape_ndx);
+ fprintf(file," doodads[%d].indicator.on_color_ndx= %d;\n",d,
+ doodad->indicator.on_color_ndx);
+ fprintf(file," doodads[%d].indicator.off_color_ndx= %d;\n",d,
+ doodad->indicator.off_color_ndx);
+ break;
+ case XkbLogoDoodad:
+ fprintf(file," doodads[%d].logo.color_ndx= %d;\n",d,
+ doodad->logo.color_ndx);
+ fprintf(file," doodads[%d].logo.shape_ndx= %d;\n",d,
+ doodad->logo.shape_ndx);
+ fprintf(file," doodads[%d].logo.logo_name= \"%s\";\n",d,
+ XkbStringText(doodad->logo.logo_name,XkbCFile));
+ break;
+ }
+ }
+ fprintf(file,"}\n");
+ return True;
+}
+
+static Bool
+WriteCHdrGeomOverlays( FILE * file,
+ XkbDescPtr xkb,
+ XkbSectionPtr section,
+ int section_num)
+{
+register int o,r,k;
+XkbOverlayPtr ol;
+XkbOverlayRowPtr row;
+XkbOverlayKeyPtr key;
+
+ if (section->num_overlays<1)
+ return True;
+ for (o=0,ol=section->overlays;o<section->num_overlays;o++,ol++) {
+ for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
+ fprintf(file,"static XkbOverlayKeyRec olkeys_s%02dr%02d[%d]= {\n",
+ section_num,r,row->num_keys);
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ fprintf(file,"%s { {\"%s\"}, {\"%s\"} }",
+ (k==0?"":",\n"),
+ XkbKeyNameText(key->over.name,XkbCFile),
+ XkbKeyNameText(key->under.name,XkbCFile));
+ }
+ fprintf(file,"\n};\n");
+ }
+ fprintf(file,"static XkbOverlayRowRec olrows_s%02d[%d]= {\n",
+ section_num,section->num_rows);
+ for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
+ fprintf(file,"%s { %4d, %4d, %4d, olkeys_s%02dr%02d }",
+ (r==0?"":",\n"),
+ row->row_under,row->num_keys,row->num_keys,
+ section_num,r);
+ }
+ fprintf(file,"\n};\n");
+ }
+ fprintf(file,"static XkbOverlayRec overlays_s%02d[%d]= {\n",section_num,
+ section->num_overlays);
+ for (o=0,ol=section->overlays;o<section->num_overlays;o++,ol++) {
+ fprintf(file,"%s {\n",(o==0?"":",\n"));
+ fprintf(file," None, /* name */\n");
+ fprintf(file," NULL, /* section_under */\n");
+ fprintf(file," %4d, /* num_rows */\n",ol->num_rows);
+ fprintf(file," %4d, /* sz_rows */\n",ol->num_rows);
+ fprintf(file," olrows_s%02d,\n",section_num);
+ fprintf(file," NULL /* bounds */\n");
+ fprintf(file," }");
+ }
+ fprintf(file,"\n};\n");
+ fprintf(file,"static void\n");
+ fprintf(file,"_InitS%02dOverlay(",section_num);
+ fprintf(file," DPYTYPE dpy,\n");
+ fprintf(file," XkbGeometryPtr geom,\n");
+ fprintf(file," XkbSectionPtr section)\n");
+ fprintf(file,"{\n");
+ fprintf(file,"XkbOverlayPtr ol;\n\n");
+ fprintf(file," ol= section->overlays;\n");
+ for (o=0,ol=section->overlays;o<section->num_overlays;o++,ol++) {
+ fprintf(file," ol[%2d].name= GET_ATOM(dpy,\"%s\");\n",o,
+ XkbAtomText(xkb->dpy,ol->name,XkbCFile));
+ fprintf(file," ol[%2d].section_under= section;\n",o);
+ }
+ fprintf(file,"}\n");
+ return True;
+}
+
+static Bool
+WriteCHdrGeomRows( FILE * file,
+ XkbDescPtr xkb,
+ XkbSectionPtr section,
+ int section_num)
+{
+register int k,r;
+register XkbRowPtr row;
+register XkbKeyPtr key;
+
+ for (r=0,row=section->rows;r<section->num_rows;r++,row++) {
+ fprintf(file,"static XkbKeyRec keys_s%02dr%02d[]= {\n",section_num,r);
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ fprintf(file,"%s { { \"%s\" }, %4d, %4d, %4d }",
+ (k==0?"":",\n"),
+ XkbKeyNameText(key->name.name,XkbCFile),
+ key->gap,key->shape_ndx,key->color_ndx);
+ }
+ fprintf(file,"\n};\n");
+ }
+ fprintf(file,"static XkbRowRec rows_s%02d[]= {\n",section_num);
+ for (r=0,row=section->rows;r<section->num_rows;r++,row++) {
+ fprintf(file,"%s { %4d, %4d, %2d, %2d, %1d, keys_s%02dr%02d, ",
+ (r==0?"":",\n"),
+ row->top,row->left,row->num_keys,row->num_keys,
+ (row->vertical!=0),
+ section_num,r);
+ fprintf(file," { %4d, %4d, %4d, %4d } }",
+ row->bounds.x1,row->bounds.y1,
+ row->bounds.x2,row->bounds.y2);
+ }
+ fprintf(file,"\n};\n");
+ return True;
+}
+
+static Bool
+WriteCHdrGeomSections(FILE *file,XkbDescPtr xkb,XkbGeometryPtr geom)
+{
+register int s;
+register XkbSectionPtr section;
+
+ for (s=0,section=geom->sections;s<geom->num_sections;s++,section++) {
+ WriteCHdrGeomRows(file,xkb,section,s);
+#ifdef NOTYET
+ if (section->num_doodads>0)
+ WriteCHdrGeomDoodads(file,xkb,geom,section,s);
+#endif
+ if (section->num_overlays>0)
+ WriteCHdrGeomOverlays(file,xkb,section,s);
+ }
+ fprintf(file,"\nstatic XkbSectionRec g_sections[%d]= {\n",
+ geom->num_sections);
+ for (s=0,section=geom->sections;s<geom->num_sections;s++,section++) {
+ if (s!=0) fprintf(file,",\n");
+ fprintf(file," {\n None, /* name */\n");
+ fprintf(file," %4d, /* priority */\n",section->priority);
+ fprintf(file," %4d, /* top */\n",section->top);
+ fprintf(file," %4d, /* left */\n",section->left);
+ fprintf(file," %4d, /* width */\n",section->width);
+ fprintf(file," %4d, /* height */\n",section->height);
+ fprintf(file," %4d, /* angle */\n",section->angle);
+ fprintf(file," %4d, /* num_rows */\n",section->num_rows);
+ fprintf(file," %4d, /* num_doodads */\n",section->num_doodads);
+ fprintf(file," %4d, /* num_overlays */\n",section->num_overlays);
+ fprintf(file," %4d, /* sz_rows */\n",section->num_rows);
+ fprintf(file," %4d, /* sz_doodads */\n",section->num_doodads);
+ fprintf(file," %4d, /* sz_overlays */\n",section->num_overlays);
+ if (section->num_rows>0)
+ fprintf(file," rows_s%02d,\n",s);
+ else fprintf(file," NULL, /* rows */\n");
+ if (section->num_doodads>0)
+ fprintf(file," doodads_s%02d,\n",s);
+ else fprintf(file," NULL, /* doodads */\n");
+ fprintf(file," { %4d, %4d, %4d, %4d }, /* bounds */\n",
+ section->bounds.x1,section->bounds.y1,
+ section->bounds.x2,section->bounds.y2);
+ if (section->num_overlays>0)
+ fprintf(file," overlays_s%02d\n",s);
+ else fprintf(file," NULL /* overlays */\n");
+ fprintf(file," }");
+ }
+ fprintf(file,"\n};\n");
+ fprintf(file,"\nstatic Bool\n");
+ fprintf(file,"_InitSections(DPYTYPE dpy,XkbGeometryPtr geom)\n");
+ fprintf(file,"{\nXkbSectionPtr sections;\n\n");
+ fprintf(file," sections= geom->sections;\n");
+ for (s=0,section=geom->sections;s<geom->num_sections;s++,section++) {
+ if (section->num_doodads>0) {
+ fprintf(file," _InitS%02dDoodads(dpy,geom,&sections[%d]);\n",
+ s,s);
+ }
+ if (section->num_overlays>0) {
+ fprintf(file," _InitS%02dOverlays(dpy,geom,&sections[%d]);\n",
+ s,s);
+ }
+ }
+ fprintf(file,"}\n");
+ return True;
+}
+
+static Bool
+WriteCHdrGeomAliases(FILE *file,XkbDescPtr xkb,XkbGeometryPtr geom)
+{
+ if (geom->num_key_aliases>0) {
+ register int i;
+ fprintf(file,"\nstatic XkbKeyAliasRec g_aliases[%d]= {\n",
+ geom->num_key_aliases);
+ for (i=0;i<geom->num_key_aliases;i++) {
+ fprintf(file,"%s { \"%s\", \"%s\" }",(i==0?"":",\n"),
+ XkbKeyNameText(geom->key_aliases[i].real,XkbCFile),
+ XkbKeyNameText(geom->key_aliases[i].alias,XkbCFile));
+ }
+ fprintf(file,"\n};\n");
+ }
+ return True;
+}
+
+static Bool
+WriteCHdrGeometry(FILE *file,XkbDescPtr xkb)
+{
+XkbGeometryPtr geom;
+register int i;
+
+ if ((!xkb)||(!xkb->geom)) {
+ _XkbLibError(_XkbErrMissingGeometry,"WriteCHdrGeometry",0);
+ return False;
+ }
+ geom= xkb->geom;
+ WriteCHdrGeomProps(file,xkb,geom);
+ WriteCHdrGeomColors(file,xkb,geom);
+ WriteCHdrGeomShapes(file,xkb,geom);
+ WriteCHdrGeomSections(file,xkb,geom);
+ WriteCHdrGeomDoodads(file,xkb,geom,NULL,0);
+ WriteCHdrGeomAliases(file,xkb,geom);
+ fprintf(file,"\nstatic XkbGeometryRec geom= {\n");
+ fprintf(file," None, /* name */\n");
+ fprintf(file," %d, %d, /* width, height */\n",geom->width_mm,
+ geom->height_mm);
+ if (geom->label_font) {
+ fprintf(file," \"%s\",/* label font */\n",
+ XkbStringText(geom->label_font,XkbCFile));
+ }
+ else fprintf(file," NULL, /* label font */\n");
+ if (geom->label_color) {
+ fprintf(file," &g_colors[%d], /* label color */\n",
+ XkbGeomColorIndex(geom,geom->label_color));
+ }
+ else fprintf(file," NULL, /* label color */\n");
+ if (geom->base_color) {
+ fprintf(file," &g_colors[%d], /* base color */\n",
+ XkbGeomColorIndex(geom,geom->base_color));
+ }
+ else fprintf(file," NULL, /* base color */\n");
+ fprintf(file," %d, %d, %d, /* sz: props, colors, shapes */\n",
+ geom->num_properties,geom->num_colors,
+ geom->num_shapes);
+ fprintf(file," %d, %d, %d, /* sz: sections, doodads, aliases */\n",
+ geom->num_sections,geom->num_doodads,
+ geom->num_key_aliases);
+ fprintf(file," %d, %d, %d, /* num: props, colors, shapes */\n",
+ geom->num_properties,geom->num_colors,
+ geom->num_shapes);
+ fprintf(file," %d, %d, %d, /* num: sections, doodads, aliases */\n",
+ geom->num_sections,geom->num_doodads,
+ geom->num_key_aliases);
+ fprintf(file," %s, %s, %s,\n",
+ (geom->num_properties>0?"g_props":"NULL"),
+ (geom->num_colors>0?"g_colors":"NULL"),
+ (geom->num_shapes>0?"g_shapes":"NULL"));
+ fprintf(file," %s, %s, %s\n",
+ (geom->num_sections>0?"g_sections":"NULL"),
+ (geom->num_doodads>0?"g_doodads":"NULL"),
+ (geom->num_key_aliases>0?"g_aliases":"NULL"));
+ fprintf(file,"};\n\n");
+ fprintf(file,"static Bool\n");
+ fprintf(file,"_InitHdrGeom(DPYTYPE dpy,XkbGeometryPtr geom)\n");
+ fprintf(file,"{\n");
+ if (geom->name!=None) {
+ fprintf(file," geom->name= GET_ATOM(dpy,\"%s\");\n",
+ XkbAtomText(xkb->dpy,geom->name,XkbCFile));
+ }
+ for (i=0;i<geom->num_shapes;i++) {
+ fprintf(file," geom->shapes[%2d].name= GET_ATOM(dpy,\"%s\");\n",i,
+ XkbAtomText(xkb->dpy,geom->shapes[i].name,XkbCFile));
+ }
+ if (geom->num_doodads>0)
+ fprintf(file," _InitGeomDoodads(dpy,geom);\n");
+ fprintf(file," _InitSections(dpy,geom);\n");
+ fprintf(file,"}\n\n");
+ return True;
+}
+
+static Bool
+WriteCHdrGeomFile(FILE *file,XkbFileInfo *result)
+{
+Bool ok;
+
+ ok= WriteCHdrGeometry(file,result->xkb);
+ return ok;
+}
+
+static Bool
+WriteCHdrLayout(FILE *file,XkbFileInfo *result)
+{
+Bool ok;
+XkbDescPtr xkb;
+
+ xkb= result->xkb;
+ ok= WriteCHdrVMods(file,xkb->dpy,xkb);
+ ok= WriteCHdrKeycodes(file,xkb)&&ok;
+ ok= WriteCHdrSymbols(file,xkb)&&ok;
+ ok= WriteCHdrGeometry(file,xkb)&&ok;
+ return ok;
+}
+
+static Bool
+WriteCHdrSemantics(FILE *file,XkbFileInfo *result)
+{
+Bool ok;
+XkbDescPtr xkb;
+
+ xkb= result->xkb;
+ ok= WriteCHdrVMods(file,xkb->dpy,xkb);
+ ok= WriteCHdrKeyTypes(file,xkb->dpy,xkb)&&ok;
+ ok= WriteCHdrCompatMap(file,xkb->dpy,xkb)&&ok;
+ ok= WriteCHdrIndicators(file,xkb->dpy,xkb)&&ok;
+ return ok;
+}
+
+static Bool
+WriteCHdrKeymap(FILE *file,XkbFileInfo *result)
+{
+Bool ok;
+XkbDescPtr xkb;
+
+ xkb= result->xkb;
+ ok= WriteCHdrVMods(file,xkb->dpy,xkb);
+ ok= ok&&WriteCHdrKeycodes(file,xkb);
+ ok= ok&&WriteCHdrClientMap(file,xkb->dpy,xkb);
+ ok= ok&&WriteCHdrServerMap(file,xkb->dpy,xkb);
+ ok= ok&&WriteCHdrCompatMap(file,xkb->dpy,xkb);
+ ok= WriteCHdrIndicators(file,xkb->dpy,xkb)&&ok;
+ ok= ok&&WriteCHdrGeometry(file,xkb);
+ return ok;
+}
+
+Bool
+XkbWriteCFile(FILE *out,char *name,XkbFileInfo *result)
+{
+Bool ok;
+XkbDescPtr xkb;
+Bool (*func)(
+ FILE * /* file*/,
+ XkbFileInfo * /* result */
+);
+
+ switch (result->type) {
+ case XkmSemanticsFile:
+ func= WriteCHdrSemantics;
+ break;
+ case XkmLayoutFile:
+ func= WriteCHdrLayout;
+ break;
+ case XkmKeymapFile:
+ func= WriteCHdrKeymap;
+ break;
+ case XkmGeometryIndex:
+ case XkmGeometryFile:
+ func= WriteCHdrGeomFile;
+ break;
+ default:
+ _XkbLibError(_XkbErrIllegalContents,"XkbWriteCFile",result->type);
+ return False;
+ }
+ xkb= result->xkb;
+ if (out==NULL) {
+ _XkbLibError(_XkbErrFileCannotOpen,"XkbWriteCFile",0);
+ ok= False;
+ }
+ else {
+ char *tmp,*hdrdef;
+ tmp= (char *)strrchr(name,'/');
+ if (tmp==NULL)
+ tmp= name;
+ else tmp++;
+ hdrdef= (char *)_XkbCalloc(strlen(tmp)+1,sizeof(char));
+ if (hdrdef) {
+ strcpy(hdrdef,tmp);
+ tmp= hdrdef;
+ while (*tmp) {
+ if (islower(*tmp)) *tmp= toupper(*tmp);
+ else if (!isalnum(*tmp)) *tmp= '_';
+ tmp++;
+ }
+ fprintf(out,"/* This file generated automatically by xkbcomp */\n");
+ fprintf(out,"/* DO NOT EDIT */\n");
+ fprintf(out,"#ifndef %s\n",hdrdef);
+ fprintf(out,"#define %s 1\n\n",hdrdef);
+ }
+ fprintf(out,"#ifndef XKB_IN_SERVER\n");
+ fprintf(out,"#define GET_ATOM(d,s) XInternAtom(d,s,0)\n");
+ fprintf(out,"#define DPYTYPE Display *\n");
+ fprintf(out,"#else\n");
+ fprintf(out,"#define GET_ATOM(d,s) MakeAtom(s,strlen(s),1)\n");
+ fprintf(out,"#define DPYTYPE char *\n");
+ fprintf(out,"#endif\n");
+ fprintf(out,"#define NUM_KEYS %d\n",xkb->max_key_code+1);
+ ok= (*func)(out,result);
+ if (hdrdef)
+ fprintf(out,"#endif /* %s */\n",hdrdef);
+ }
+
+ if (!ok) {
+ return False;
+ }
+ return True;
+}
diff --git a/nx-X11/lib/xkbfile/magic b/nx-X11/lib/xkbfile/magic
new file mode 100644
index 000000000..9c433ad02
--- /dev/null
+++ b/nx-X11/lib/xkbfile/magic
@@ -0,0 +1,11 @@
+# $Xorg: magic,v 1.3 2000/08/17 19:46:43 cpqbld Exp $
+# Here are some lines you can add to /etc/magic
+# to identify XKM (compiled X keymap) files
+# and determine their version and the byte ordering
+# with which they were compiled
+1 string mkx Compiled XKB Keymap: lsb,
+>0 byte >0 version %d
+>0 byte =0 obsolete
+0 string xkm Compiled XKB Keymap: msb,
+>3 byte >0 version %d
+>0 byte =0 obsolete
diff --git a/nx-X11/lib/xkbfile/maprules.c b/nx-X11/lib/xkbfile/maprules.c
new file mode 100644
index 000000000..53decdcad
--- /dev/null
+++ b/nx-X11/lib/xkbfile/maprules.c
@@ -0,0 +1,1482 @@
+/* $Xorg: maprules.c,v 1.4 2000/08/17 19:46:43 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1996 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbfile/maprules.c,v 3.17 2002/11/26 01:43:25 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#elif defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#define X_INCLUDE_STRING_H
+#define XOS_USE_NO_LOCKING
+#include <X11/Xos_r.h>
+
+#ifndef XKB_IN_SERVER
+
+#include <X11/Xproto.h>
+#include <X11/Xlib.h>
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xatom.h>
+#include <X11/keysym.h>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKBgeom.h>
+#include "XKMformat.h"
+#include "XKBfileInt.h"
+#include "XKBrules.h"
+
+#else
+
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include <X11/X.h>
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xatom.h>
+#include <X11/keysym.h>
+#include "misc.h"
+#include "inputstr.h"
+#include "dix.h"
+#include <X11/extensions/XKBstr.h>
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+
+#endif
+
+#ifdef DEBUG
+#define PR_DEBUG(s) fprintf(stderr,s)
+#define PR_DEBUG1(s,a) fprintf(stderr,s,a)
+#define PR_DEBUG2(s,a,b) fprintf(stderr,s,a,b)
+#else
+#define PR_DEBUG(s)
+#define PR_DEBUG1(s,a)
+#define PR_DEBUG2(s,a,b)
+#endif
+
+/***====================================================================***/
+
+#define DFLT_LINE_SIZE 128
+
+typedef struct {
+ int line_num;
+ int sz_line;
+ int num_line;
+ char buf[DFLT_LINE_SIZE];
+ char * line;
+} InputLine;
+
+static void
+InitInputLine(InputLine *line)
+{
+ line->line_num= 1;
+ line->num_line= 0;
+ line->sz_line= DFLT_LINE_SIZE;
+ line->line= line->buf;
+ return;
+}
+
+static void
+FreeInputLine(InputLine *line)
+{
+ if (line->line!=line->buf)
+ _XkbFree(line->line);
+ line->line_num= 1;
+ line->num_line= 0;
+ line->sz_line= DFLT_LINE_SIZE;
+ line->line= line->buf;
+ return;
+}
+
+static int
+InputLineAddChar(InputLine *line,int ch)
+{
+ if (line->num_line>=line->sz_line) {
+ if (line->line==line->buf) {
+ line->line= (char *)_XkbAlloc(line->sz_line*2);
+ memcpy(line->line,line->buf,line->sz_line);
+ }
+ else {
+ line->line=(char *)_XkbRealloc((char *)line->line,line->sz_line*2);
+ }
+ line->sz_line*= 2;
+ }
+ line->line[line->num_line++]= ch;
+ return ch;
+}
+
+#define ADD_CHAR(l,c) ((l)->num_line<(l)->sz_line?\
+ (int)((l)->line[(l)->num_line++]= (c)):\
+ InputLineAddChar(l,c))
+
+static Bool
+GetInputLine(FILE *file,InputLine *line,Bool checkbang)
+{
+int ch;
+Bool endOfFile,spacePending,slashPending,inComment;
+
+ endOfFile= False;
+ while ((!endOfFile)&&(line->num_line==0)) {
+ spacePending= slashPending= inComment= False;
+ while (((ch=getc(file))!='\n')&&(ch!=EOF)) {
+ if (ch=='\\') {
+ if ((ch=getc(file))==EOF)
+ break;
+ if (ch=='\n') {
+ inComment= False;
+ ch= ' ';
+ line->line_num++;
+ }
+ }
+ if (inComment)
+ continue;
+ if (ch=='/') {
+ if (slashPending) {
+ inComment= True;
+ slashPending= False;
+ }
+ else {
+ slashPending= True;
+ }
+ continue;
+ }
+ else if (slashPending) {
+ if (spacePending) {
+ ADD_CHAR(line,' ');
+ spacePending= False;
+ }
+ ADD_CHAR(line,'/');
+ slashPending= False;
+ }
+ if (isspace(ch)) {
+ while (isspace(ch)&&(ch!='\n')&&(ch!=EOF)) {
+ ch= getc(file);
+ }
+ if (ch==EOF)
+ break;
+ if ((ch!='\n')&&(line->num_line>0))
+ spacePending= True;
+ ungetc(ch,file);
+ }
+ else {
+ if (spacePending) {
+ ADD_CHAR(line,' ');
+ spacePending= False;
+ }
+ if (checkbang && ch=='!') {
+ if (line->num_line!=0) {
+ PR_DEBUG("The '!' legal only at start of line\n");
+ PR_DEBUG("Line containing '!' ignored\n");
+ line->num_line= 0;
+ inComment= 0;
+ break;
+ }
+
+ }
+ ADD_CHAR(line,ch);
+ }
+ }
+ if (ch==EOF)
+ endOfFile= True;
+/* else line->num_line++;*/
+ }
+ if ((line->num_line==0)&&(endOfFile))
+ return False;
+ ADD_CHAR(line,'\0');
+ return True;
+}
+
+/***====================================================================***/
+
+#define MODEL 0
+#define LAYOUT 1
+#define VARIANT 2
+#define OPTION 3
+#define KEYCODES 4
+#define SYMBOLS 5
+#define TYPES 6
+#define COMPAT 7
+#define GEOMETRY 8
+#define KEYMAP 9
+#define MAX_WORDS 10
+
+#define PART_MASK 0x000F
+#define COMPONENT_MASK 0x03F0
+
+static char * cname[MAX_WORDS] = {
+ "model", "layout", "variant", "option",
+ "keycodes", "symbols", "types", "compat", "geometry", "keymap"
+};
+
+typedef struct _RemapSpec {
+ int number;
+ int num_remap;
+ struct {
+ int word;
+ int index;
+ } remap[MAX_WORDS];
+} RemapSpec;
+
+typedef struct _FileSpec {
+ char * name[MAX_WORDS];
+ struct _FileSpec * pending;
+} FileSpec;
+
+typedef struct {
+ char * model;
+ char * layout[XkbNumKbdGroups+1];
+ char * variant[XkbNumKbdGroups+1];
+ char * options;
+} XkbRF_MultiDefsRec, *XkbRF_MultiDefsPtr;
+
+#define NDX_BUFF_SIZE 4
+
+/***====================================================================***/
+
+static char*
+get_index(char *str, int *ndx)
+{
+ char ndx_buf[NDX_BUFF_SIZE];
+ char *end;
+
+ if (*str != '[') {
+ *ndx = 0;
+ return str;
+ }
+ str++;
+ end = strchr(str, ']');
+ if (end == NULL) {
+ *ndx = -1;
+ return str - 1;
+ }
+ if ( (end - str) >= NDX_BUFF_SIZE) {
+ *ndx = -1;
+ return end + 1;
+ }
+ strncpy(ndx_buf, str, end - str);
+ ndx_buf[end - str] = '\0';
+ *ndx = atoi(ndx_buf);
+ return end + 1;
+}
+
+static void
+SetUpRemap(InputLine *line,RemapSpec *remap)
+{
+char * tok,*str;
+unsigned present, l_ndx_present, v_ndx_present;
+register int i;
+int len, ndx;
+_Xstrtokparams strtok_buf;
+#ifdef DEBUG
+Bool found;
+#endif
+
+
+ l_ndx_present = v_ndx_present = present= 0;
+ str= &line->line[1];
+ len = remap->number;
+ bzero((char *)remap,sizeof(RemapSpec));
+ remap->number = len;
+ while ((tok=_XStrtok(str," ",strtok_buf))!=NULL) {
+#ifdef DEBUG
+ found= False;
+#endif
+ str= NULL;
+ if (strcmp(tok,"=")==0)
+ continue;
+ for (i=0;i<MAX_WORDS;i++) {
+ len = strlen(cname[i]);
+ if (strncmp(cname[i],tok,len)==0) {
+ if(strlen(tok) > len) {
+ char *end = get_index(tok+len, &ndx);
+ if ((i != LAYOUT && i != VARIANT) ||
+ *end != '\0' || ndx == -1)
+ break;
+ if (ndx < 1 || ndx > XkbNumKbdGroups) {
+ PR_DEBUG2("Illegal %s index: %d\n", cname[i], ndx);
+ PR_DEBUG1("Index must be in range 1..%d\n",
+ XkbNumKbdGroups);
+ break;
+ }
+ } else {
+ ndx = 0;
+ }
+#ifdef DEBUG
+ found= True;
+#endif
+ if (present&(1<<i)) {
+ if ((i == LAYOUT && l_ndx_present&(1<<ndx)) ||
+ (i == VARIANT && v_ndx_present&(1<<ndx)) ) {
+ PR_DEBUG1("Component \"%s\" listed twice\n",tok);
+ PR_DEBUG("Second definition ignored\n");
+ break;
+ }
+ }
+ present |= (1<<i);
+ if (i == LAYOUT)
+ l_ndx_present |= 1 << ndx;
+ if (i == VARIANT)
+ v_ndx_present |= 1 << ndx;
+ remap->remap[remap->num_remap].word= i;
+ remap->remap[remap->num_remap++].index= ndx;
+ break;
+ }
+ }
+#ifdef DEBUG
+ if (!found) {
+ fprintf(stderr,"Unknown component \"%s\" ignored\n",tok);
+ }
+#endif
+ }
+ if ((present&PART_MASK)==0) {
+#ifdef DEBUG
+ unsigned mask= PART_MASK;
+ fprintf(stderr,"Mapping needs at least one of ");
+ for (i=0; (i<MAX_WORDS); i++) {
+ if ((1L<<i)&mask) {
+ mask&= ~(1L<<i);
+ if (mask) fprintf(stderr,"\"%s,\" ",cname[i]);
+ else fprintf(stderr,"or \"%s\"\n",cname[i]);
+ }
+ }
+ fprintf(stderr,"Illegal mapping ignored\n");
+#endif
+ remap->num_remap= 0;
+ return;
+ }
+ if ((present&COMPONENT_MASK)==0) {
+ PR_DEBUG("Mapping needs at least one component\n");
+ PR_DEBUG("Illegal mapping ignored\n");
+ remap->num_remap= 0;
+ return;
+ }
+ if (((present&PART_MASK)&(1<<OPTION))&&
+ ((present&PART_MASK)!=(1<<OPTION))) {
+ PR_DEBUG("Options cannot appear with other parts\n");
+ PR_DEBUG("Illegal mapping ignored\n");
+ remap->num_remap= 0;
+ return;
+ }
+ if (((present&COMPONENT_MASK)&(1<<KEYMAP))&&
+ ((present&COMPONENT_MASK)!=(1<<KEYMAP))) {
+ PR_DEBUG("Keymap cannot appear with other components\n");
+ PR_DEBUG("Illegal mapping ignored\n");
+ remap->num_remap= 0;
+ return;
+ }
+ remap->number++;
+ return;
+}
+
+static Bool
+MatchOneOf(char *wanted,char *vals_defined)
+{
+char *str,*next;
+int want_len= strlen(wanted);
+
+ for (str=vals_defined,next=NULL;str!=NULL;str=next) {
+ int len;
+ next= strchr(str,',');
+ if (next) {
+ len= next-str;
+ next++;
+ }
+ else {
+ len= strlen(str);
+ }
+ if ((len==want_len)&&(strncmp(wanted,str,len)==0))
+ return True;
+ }
+ return False;
+}
+
+/***====================================================================***/
+
+static Bool
+CheckLine( InputLine * line,
+ RemapSpec * remap,
+ XkbRF_RulePtr rule,
+ XkbRF_GroupPtr group)
+{
+char * str,*tok;
+register int nread, i;
+FileSpec tmp;
+_Xstrtokparams strtok_buf;
+Bool append = False;
+
+ if (line->line[0]=='!') {
+ if (line->line[1] == '$' ||
+ (line->line[1] == ' ' && line->line[2] == '$')) {
+ char *gname = strchr(line->line, '$');
+ char *words = strchr(gname, ' ');
+ if(!words)
+ return False;
+ *words++ = '\0';
+ for (; *words; words++) {
+ if (*words != '=' && *words != ' ')
+ break;
+ }
+ if (*words == '\0')
+ return False;
+ group->name = _XkbDupString(gname);
+ group->words = _XkbDupString(words);
+ for (i = 1, words = group->words; *words; words++) {
+ if ( *words == ' ') {
+ *words++ = '\0';
+ i++;
+ }
+ }
+ group->number = i;
+ return True;
+ } else {
+ SetUpRemap(line,remap);
+ return False;
+ }
+ }
+
+ if (remap->num_remap==0) {
+ PR_DEBUG("Must have a mapping before first line of data\n");
+ PR_DEBUG("Illegal line of data ignored\n");
+ return False;
+ }
+ bzero((char *)&tmp,sizeof(FileSpec));
+ str= line->line;
+ for (nread= 0;(tok=_XStrtok(str," ",strtok_buf))!=NULL;nread++) {
+ str= NULL;
+ if (strcmp(tok,"=")==0) {
+ nread--;
+ continue;
+ }
+ if (nread>remap->num_remap) {
+ PR_DEBUG("Too many words on a line\n");
+ PR_DEBUG1("Extra word \"%s\" ignored\n",tok);
+ continue;
+ }
+ tmp.name[remap->remap[nread].word]= tok;
+ if (*tok == '+' || *tok == '|')
+ append = True;
+ }
+ if (nread<remap->num_remap) {
+ PR_DEBUG1("Too few words on a line: %s\n", line->line);
+ PR_DEBUG("line ignored\n");
+ return False;
+ }
+
+ rule->flags= 0;
+ rule->number = remap->number;
+ if (tmp.name[OPTION])
+ rule->flags|= XkbRF_Option;
+ else if (append)
+ rule->flags|= XkbRF_Append;
+ else
+ rule->flags|= XkbRF_Normal;
+ rule->model= _XkbDupString(tmp.name[MODEL]);
+ rule->layout= _XkbDupString(tmp.name[LAYOUT]);
+ rule->variant= _XkbDupString(tmp.name[VARIANT]);
+ rule->option= _XkbDupString(tmp.name[OPTION]);
+
+ rule->keycodes= _XkbDupString(tmp.name[KEYCODES]);
+ rule->symbols= _XkbDupString(tmp.name[SYMBOLS]);
+ rule->types= _XkbDupString(tmp.name[TYPES]);
+ rule->compat= _XkbDupString(tmp.name[COMPAT]);
+ rule->geometry= _XkbDupString(tmp.name[GEOMETRY]);
+ rule->keymap= _XkbDupString(tmp.name[KEYMAP]);
+
+ rule->layout_num = rule->variant_num = 0;
+ for (i = 0; i < nread; i++) {
+ if (remap->remap[i].index) {
+ if (remap->remap[i].word == LAYOUT)
+ rule->layout_num = remap->remap[i].index;
+ if (remap->remap[i].word == VARIANT)
+ rule->variant_num = remap->remap[i].index;
+ }
+ }
+ return True;
+}
+
+static char *
+_Concat(char *str1,char *str2)
+{
+int len;
+
+ if ((!str1)||(!str2))
+ return str1;
+ len= strlen(str1)+strlen(str2)+1;
+ str1= _XkbTypedRealloc(str1,len,char);
+ if (str1)
+ strcat(str1,str2);
+ return str1;
+}
+
+static void
+squeeze_spaces(char *p1)
+{
+ char *p2;
+ for (p2 = p1; *p2; p2++) {
+ *p1 = *p2;
+ if (*p1 != ' ') p1++;
+ }
+ *p1 = '\0';
+}
+
+static Bool
+MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
+{
+
+ bzero((char *)mdefs,sizeof(XkbRF_MultiDefsRec));
+ mdefs->model = defs->model;
+ mdefs->options = _XkbDupString(defs->options);
+ if (mdefs->options) squeeze_spaces(mdefs->options);
+
+ if (defs->layout) {
+ if (!strchr(defs->layout, ',')) {
+ mdefs->layout[0] = defs->layout;
+ } else {
+ char *p;
+ int i;
+ mdefs->layout[1] = _XkbDupString(defs->layout);
+ if (mdefs->layout[1] == NULL)
+ return False;
+ squeeze_spaces(mdefs->layout[1]);
+ p = mdefs->layout[1];
+ for (i = 2; i <= XkbNumKbdGroups; i++) {
+ if ((p = strchr(p, ','))) {
+ *p++ = '\0';
+ mdefs->layout[i] = p;
+ } else {
+ break;
+ }
+ }
+ if (p && (p = strchr(p, ',')))
+ *p = '\0';
+ }
+ }
+
+ if (defs->variant) {
+ if (!strchr(defs->variant, ',')) {
+ mdefs->variant[0] = defs->variant;
+ } else {
+ char *p;
+ int i;
+ mdefs->variant[1] = _XkbDupString(defs->variant);
+ if (mdefs->variant[1] == NULL)
+ return False;
+ squeeze_spaces(mdefs->variant[1]);
+ p = mdefs->variant[1];
+ for (i = 2; i <= XkbNumKbdGroups; i++) {
+ if ((p = strchr(p, ','))) {
+ *p++ = '\0';
+ mdefs->variant[i] = p;
+ } else {
+ break;
+ }
+ }
+ if (p && (p = strchr(p, ',')))
+ *p = '\0';
+ }
+ }
+ return True;
+}
+
+static void
+FreeMultiDefs(XkbRF_MultiDefsPtr defs)
+{
+ if (defs->options) _XkbFree(defs->options);
+ if (defs->layout[1]) _XkbFree(defs->layout[1]);
+ if (defs->variant[1]) _XkbFree(defs->variant[1]);
+}
+
+static void
+Apply(char *src, char **dst)
+{
+ if (src) {
+ if (*src == '+' || *src == '!') {
+ *dst= _Concat(*dst, src);
+ } else {
+ if (*dst == NULL)
+ *dst= _XkbDupString(src);
+ }
+ }
+}
+
+static void
+XkbRF_ApplyRule( XkbRF_RulePtr rule,
+ XkbComponentNamesPtr names)
+{
+ rule->flags&= ~XkbRF_PendingMatch; /* clear the flag because it's applied */
+
+ Apply(rule->keycodes, &names->keycodes);
+ Apply(rule->symbols, &names->symbols);
+ Apply(rule->types, &names->types);
+ Apply(rule->compat, &names->compat);
+ Apply(rule->geometry, &names->geometry);
+ Apply(rule->keymap, &names->keymap);
+}
+
+static Bool
+CheckGroup( XkbRF_RulesPtr rules,
+ char * group_name,
+ char * name)
+{
+ int i;
+ char *p;
+ XkbRF_GroupPtr group;
+
+ for (i = 0, group = rules->groups; i < rules->num_groups; i++, group++) {
+ if (! strcmp(group->name, group_name)) {
+ break;
+ }
+ }
+ if (i == rules->num_groups)
+ return False;
+ for (i = 0, p = group->words; i < group->number; i++, p += strlen(p)+1) {
+ if (! strcmp(p, name)) {
+ return True;
+ }
+ }
+ return False;
+}
+
+static int
+XkbRF_CheckApplyRule( XkbRF_RulePtr rule,
+ XkbRF_MultiDefsPtr mdefs,
+ XkbComponentNamesPtr names,
+ XkbRF_RulesPtr rules)
+{
+ Bool pending = False;
+
+ if (rule->model != NULL) {
+ if(mdefs->model == NULL)
+ return 0;
+ if (strcmp(rule->model, "*") == 0) {
+ pending = True;
+ } else {
+ if (rule->model[0] == '$') {
+ if (!CheckGroup(rules, rule->model, mdefs->model))
+ return 0;
+ } else {
+ if (strcmp(rule->model, mdefs->model) != 0)
+ return 0;
+ }
+ }
+ }
+ if (rule->option != NULL) {
+ if (mdefs->options == NULL)
+ return 0;
+ if ((!MatchOneOf(rule->option,mdefs->options)))
+ return 0;
+ }
+
+ if (rule->layout != NULL) {
+ if(mdefs->layout[rule->layout_num] == NULL ||
+ *mdefs->layout[rule->layout_num] == '\0')
+ return 0;
+ if (strcmp(rule->layout, "*") == 0) {
+ pending = True;
+ } else {
+ if (rule->layout[0] == '$') {
+ if (!CheckGroup(rules, rule->layout,
+ mdefs->layout[rule->layout_num]))
+ return 0;
+ } else {
+ if (strcmp(rule->layout, mdefs->layout[rule->layout_num]) != 0)
+ return 0;
+ }
+ }
+ }
+ if (rule->variant != NULL) {
+ if (mdefs->variant[rule->variant_num] == NULL ||
+ *mdefs->variant[rule->variant_num] == '\0')
+ return 0;
+ if (strcmp(rule->variant, "*") == 0) {
+ pending = True;
+ } else {
+ if (rule->variant[0] == '$') {
+ if (!CheckGroup(rules, rule->variant,
+ mdefs->variant[rule->variant_num]))
+ return 0;
+ } else {
+ if (strcmp(rule->variant,
+ mdefs->variant[rule->variant_num]) != 0)
+ return 0;
+ }
+ }
+ }
+ if (pending) {
+ rule->flags|= XkbRF_PendingMatch;
+ return rule->number;
+ }
+ /* exact match, apply it now */
+ XkbRF_ApplyRule(rule,names);
+ return rule->number;
+}
+
+static void
+XkbRF_ClearPartialMatches(XkbRF_RulesPtr rules)
+{
+register int i;
+XkbRF_RulePtr rule;
+
+ for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) {
+ rule->flags&= ~XkbRF_PendingMatch;
+ }
+}
+
+static void
+XkbRF_ApplyPartialMatches(XkbRF_RulesPtr rules,XkbComponentNamesPtr names)
+{
+int i;
+XkbRF_RulePtr rule;
+
+ for (rule = rules->rules, i = 0; i < rules->num_rules; i++, rule++) {
+ if ((rule->flags&XkbRF_PendingMatch)==0)
+ continue;
+ XkbRF_ApplyRule(rule,names);
+ }
+}
+
+static void
+XkbRF_CheckApplyRules( XkbRF_RulesPtr rules,
+ XkbRF_MultiDefsPtr mdefs,
+ XkbComponentNamesPtr names,
+ int flags)
+{
+int i;
+XkbRF_RulePtr rule;
+int skip;
+
+ for (rule = rules->rules, i=0; i < rules->num_rules; rule++, i++) {
+ if ((rule->flags & flags) != flags)
+ continue;
+ skip = XkbRF_CheckApplyRule(rule, mdefs, names, rules);
+ if (skip && !(flags & XkbRF_Option)) {
+ for ( ;(i < rules->num_rules) && (rule->number == skip);
+ rule++, i++);
+ rule--; i--;
+ }
+ }
+}
+
+/***====================================================================***/
+
+static char *
+XkbRF_SubstituteVars(char *name, XkbRF_MultiDefsPtr mdefs)
+{
+char *str, *outstr, *orig, *var;
+int len, ndx;
+
+ orig= name;
+ str= index(name,'%');
+ if (str==NULL)
+ return name;
+ len= strlen(name);
+ while (str!=NULL) {
+ char pfx= str[1];
+ int extra_len= 0;
+ if ((pfx=='+')||(pfx=='|')||(pfx=='_')||(pfx=='-')) {
+ extra_len= 1;
+ str++;
+ }
+ else if (pfx=='(') {
+ extra_len= 2;
+ str++;
+ }
+ var = str + 1;
+ str = get_index(var + 1, &ndx);
+ if (ndx == -1) {
+ str = index(str,'%');
+ continue;
+ }
+ if ((*var=='l') && mdefs->layout[ndx] && *mdefs->layout[ndx])
+ len+= strlen(mdefs->layout[ndx])+extra_len;
+ else if ((*var=='m')&&mdefs->model)
+ len+= strlen(mdefs->model)+extra_len;
+ else if ((*var=='v') && mdefs->variant[ndx] && *mdefs->variant[ndx])
+ len+= strlen(mdefs->variant[ndx])+extra_len;
+ if ((pfx=='(')&&(*str==')')) {
+ str++;
+ }
+ str= index(&str[0],'%');
+ }
+ name= (char *)_XkbAlloc(len+1);
+ str= orig;
+ outstr= name;
+ while (*str!='\0') {
+ if (str[0]=='%') {
+ char pfx,sfx;
+ str++;
+ pfx= str[0];
+ sfx= '\0';
+ if ((pfx=='+')||(pfx=='|')||(pfx=='_')||(pfx=='-')) {
+ str++;
+ }
+ else if (pfx=='(') {
+ sfx= ')';
+ str++;
+ }
+ else pfx= '\0';
+
+ var = str;
+ str = get_index(var + 1, &ndx);
+ if (ndx == -1) {
+ continue;
+ }
+ if ((*var=='l') && mdefs->layout[ndx] && *mdefs->layout[ndx]) {
+ if (pfx) *outstr++= pfx;
+ strcpy(outstr,mdefs->layout[ndx]);
+ outstr+= strlen(mdefs->layout[ndx]);
+ if (sfx) *outstr++= sfx;
+ }
+ else if ((*var=='m')&&(mdefs->model)) {
+ if (pfx) *outstr++= pfx;
+ strcpy(outstr,mdefs->model);
+ outstr+= strlen(mdefs->model);
+ if (sfx) *outstr++= sfx;
+ }
+ else if ((*var=='v') && mdefs->variant[ndx] && *mdefs->variant[ndx]) {
+ if (pfx) *outstr++= pfx;
+ strcpy(outstr,mdefs->variant[ndx]);
+ outstr+= strlen(mdefs->variant[ndx]);
+ if (sfx) *outstr++= sfx;
+ }
+ if ((pfx=='(')&&(*str==')'))
+ str++;
+ }
+ else {
+ *outstr++= *str++;
+ }
+ }
+ *outstr++= '\0';
+ if (orig!=name)
+ _XkbFree(orig);
+ return name;
+}
+
+/***====================================================================***/
+
+Bool
+XkbRF_GetComponents( XkbRF_RulesPtr rules,
+ XkbRF_VarDefsPtr defs,
+ XkbComponentNamesPtr names)
+{
+ XkbRF_MultiDefsRec mdefs;
+
+ MakeMultiDefs(&mdefs, defs);
+
+ bzero((char *)names,sizeof(XkbComponentNamesRec));
+ XkbRF_ClearPartialMatches(rules);
+ XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Normal);
+ XkbRF_ApplyPartialMatches(rules, names);
+ XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Append);
+ XkbRF_ApplyPartialMatches(rules, names);
+ XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Option);
+
+ if (names->keycodes)
+ names->keycodes= XkbRF_SubstituteVars(names->keycodes, &mdefs);
+ if (names->symbols)
+ names->symbols= XkbRF_SubstituteVars(names->symbols, &mdefs);
+ if (names->types)
+ names->types= XkbRF_SubstituteVars(names->types, &mdefs);
+ if (names->compat)
+ names->compat= XkbRF_SubstituteVars(names->compat, &mdefs);
+ if (names->geometry)
+ names->geometry= XkbRF_SubstituteVars(names->geometry, &mdefs);
+ if (names->keymap)
+ names->keymap= XkbRF_SubstituteVars(names->keymap, &mdefs);
+
+ FreeMultiDefs(&mdefs);
+ return (names->keycodes && names->symbols && names->types &&
+ names->compat && names->geometry ) || names->keymap;
+}
+
+XkbRF_RulePtr
+XkbRF_AddRule(XkbRF_RulesPtr rules)
+{
+ if (rules->sz_rules<1) {
+ rules->sz_rules= 16;
+ rules->num_rules= 0;
+ rules->rules= _XkbTypedCalloc(rules->sz_rules,XkbRF_RuleRec);
+ }
+ else if (rules->num_rules>=rules->sz_rules) {
+ rules->sz_rules*= 2;
+ rules->rules= _XkbTypedRealloc(rules->rules,rules->sz_rules,
+ XkbRF_RuleRec);
+ }
+ if (!rules->rules) {
+ rules->sz_rules= rules->num_rules= 0;
+#ifdef DEBUG
+ fprintf(stderr,"Allocation failure in XkbRF_AddRule\n");
+#endif
+ return NULL;
+ }
+ bzero((char *)&rules->rules[rules->num_rules],sizeof(XkbRF_RuleRec));
+ return &rules->rules[rules->num_rules++];
+}
+
+XkbRF_GroupPtr
+XkbRF_AddGroup(XkbRF_RulesPtr rules)
+{
+ if (rules->sz_groups<1) {
+ rules->sz_groups= 16;
+ rules->num_groups= 0;
+ rules->groups= _XkbTypedCalloc(rules->sz_groups,XkbRF_GroupRec);
+ }
+ else if (rules->num_groups >= rules->sz_groups) {
+ rules->sz_groups *= 2;
+ rules->groups= _XkbTypedRealloc(rules->groups,rules->sz_groups,
+ XkbRF_GroupRec);
+ }
+ if (!rules->groups) {
+ rules->sz_groups= rules->num_groups= 0;
+ return NULL;
+ }
+
+ bzero((char *)&rules->groups[rules->num_groups],sizeof(XkbRF_GroupRec));
+ return &rules->groups[rules->num_groups++];
+}
+
+Bool
+XkbRF_LoadRules(FILE *file, XkbRF_RulesPtr rules)
+{
+InputLine line;
+RemapSpec remap;
+XkbRF_RuleRec trule,*rule;
+XkbRF_GroupRec tgroup,*group;
+
+ if (!(rules && file))
+ return False;
+ bzero((char *)&remap,sizeof(RemapSpec));
+ bzero((char *)&tgroup,sizeof(XkbRF_GroupRec));
+ InitInputLine(&line);
+ while (GetInputLine(file,&line,True)) {
+ if (CheckLine(&line,&remap,&trule,&tgroup)) {
+ if (tgroup.number) {
+ if ((group= XkbRF_AddGroup(rules))!=NULL) {
+ *group= tgroup;
+ bzero((char *)&tgroup,sizeof(XkbRF_GroupRec));
+ }
+ } else {
+ if ((rule= XkbRF_AddRule(rules))!=NULL) {
+ *rule= trule;
+ bzero((char *)&trule,sizeof(XkbRF_RuleRec));
+ }
+ }
+ }
+ line.num_line= 0;
+ }
+ FreeInputLine(&line);
+ return True;
+}
+
+Bool
+XkbRF_LoadRulesByName(char *base,char *locale,XkbRF_RulesPtr rules)
+{
+FILE * file;
+char buf[PATH_MAX];
+Bool ok;
+
+ if ((!base)||(!rules))
+ return False;
+ if (locale) {
+ if (strlen(base)+strlen(locale)+2 > PATH_MAX)
+ return False;
+ sprintf(buf,"%s-%s", base, locale);
+ }
+ else {
+ if (strlen(base)+1 > PATH_MAX)
+ return False;
+ strcpy(buf,base);
+ }
+
+ file= fopen(buf, "r");
+ if ((!file)&&(locale)) { /* fallback if locale was specified */
+ strcpy(buf,base);
+ file= fopen(buf, "r");
+ }
+ if (!file)
+ return False;
+ ok= XkbRF_LoadRules(file,rules);
+ fclose(file);
+ return ok;
+}
+
+/***====================================================================***/
+
+#define HEAD_NONE 0
+#define HEAD_MODEL 1
+#define HEAD_LAYOUT 2
+#define HEAD_VARIANT 3
+#define HEAD_OPTION 4
+#define HEAD_EXTRA 5
+
+XkbRF_VarDescPtr
+XkbRF_AddVarDesc(XkbRF_DescribeVarsPtr vars)
+{
+ if (vars->sz_desc<1) {
+ vars->sz_desc= 16;
+ vars->num_desc= 0;
+ vars->desc= _XkbTypedCalloc(vars->sz_desc,XkbRF_VarDescRec);
+ }
+ else if (vars->num_desc>=vars->sz_desc) {
+ vars->sz_desc*= 2;
+ vars->desc= _XkbTypedRealloc(vars->desc,vars->sz_desc,XkbRF_VarDescRec);
+ }
+ if (!vars->desc) {
+ vars->sz_desc= vars->num_desc= 0;
+ PR_DEBUG("Allocation failure in XkbRF_AddVarDesc\n");
+ return NULL;
+ }
+ vars->desc[vars->num_desc].name= NULL;
+ vars->desc[vars->num_desc].desc= NULL;
+ return &vars->desc[vars->num_desc++];
+}
+
+XkbRF_VarDescPtr
+XkbRF_AddVarDescCopy(XkbRF_DescribeVarsPtr vars,XkbRF_VarDescPtr from)
+{
+XkbRF_VarDescPtr nd;
+
+ if ((nd=XkbRF_AddVarDesc(vars))!=NULL) {
+ nd->name= _XkbDupString(from->name);
+ nd->desc= _XkbDupString(from->desc);
+ }
+ return nd;
+}
+
+XkbRF_DescribeVarsPtr
+XkbRF_AddVarToDescribe(XkbRF_RulesPtr rules,char *name)
+{
+ if (rules->sz_extra<1) {
+ rules->num_extra= 0;
+ rules->sz_extra= 1;
+ rules->extra_names= _XkbTypedCalloc(rules->sz_extra,char *);
+ rules->extra= _XkbTypedCalloc(rules->sz_extra, XkbRF_DescribeVarsRec);
+ }
+ else if (rules->num_extra>=rules->sz_extra) {
+ rules->sz_extra*= 2;
+ rules->extra_names= _XkbTypedRealloc(rules->extra_names,rules->sz_extra,
+ char *);
+ rules->extra=_XkbTypedRealloc(rules->extra, rules->sz_extra,
+ XkbRF_DescribeVarsRec);
+ }
+ if ((!rules->extra_names)||(!rules->extra)) {
+ PR_DEBUG("allocation error in extra parts\n");
+ rules->sz_extra= rules->num_extra= 0;
+ rules->extra_names= NULL;
+ rules->extra= NULL;
+ return NULL;
+ }
+ rules->extra_names[rules->num_extra]= _XkbDupString(name);
+ bzero(&rules->extra[rules->num_extra],sizeof(XkbRF_DescribeVarsRec));
+ return &rules->extra[rules->num_extra++];
+}
+
+Bool
+XkbRF_LoadDescriptions(FILE *file,XkbRF_RulesPtr rules)
+{
+InputLine line;
+XkbRF_VarDescRec tmp;
+char *tok;
+int len,headingtype,extra_ndx = 0;
+
+ bzero((char *)&tmp, sizeof(XkbRF_VarDescRec));
+ headingtype = HEAD_NONE;
+ InitInputLine(&line);
+ for ( ; GetInputLine(file,&line,False); line.num_line= 0) {
+ if (line.line[0]=='!') {
+ tok = strtok(&(line.line[1]), " \t");
+ if (!_XkbStrCaseCmp(tok,"model"))
+ headingtype = HEAD_MODEL;
+ else if (!_XkbStrCaseCmp(tok,"layout"))
+ headingtype = HEAD_LAYOUT;
+ else if (!_XkbStrCaseCmp(tok,"variant"))
+ headingtype = HEAD_VARIANT;
+ else if (!_XkbStrCaseCmp(tok,"option"))
+ headingtype = HEAD_OPTION;
+ else {
+ int i;
+ headingtype = HEAD_EXTRA;
+ extra_ndx= -1;
+ for (i=0;(i<rules->num_extra)&&(extra_ndx<0);i++) {
+ if (!_XkbStrCaseCmp(tok,rules->extra_names[i]))
+ extra_ndx= i;
+ }
+ if (extra_ndx<0) {
+ XkbRF_DescribeVarsPtr var;
+ PR_DEBUG1("Extra heading \"%s\" encountered\n",tok);
+ var= XkbRF_AddVarToDescribe(rules,tok);
+ if (var)
+ extra_ndx= var-rules->extra;
+ else headingtype= HEAD_NONE;
+ }
+ }
+ continue;
+ }
+
+ if (headingtype == HEAD_NONE) {
+ PR_DEBUG("Must have a heading before first line of data\n");
+ PR_DEBUG("Illegal line of data ignored\n");
+ continue;
+ }
+
+ len = strlen(line.line);
+ if ((tmp.name= strtok(line.line, " \t")) == NULL) {
+ PR_DEBUG("Huh? No token on line\n");
+ PR_DEBUG("Illegal line of data ignored\n");
+ continue;
+ }
+ if (strlen(tmp.name) == len) {
+ PR_DEBUG("No description found\n");
+ PR_DEBUG("Illegal line of data ignored\n");
+ continue;
+ }
+
+ tok = line.line + strlen(tmp.name) + 1;
+ while ((*tok!='\n')&&isspace(*tok))
+ tok++;
+ if (*tok == '\0') {
+ PR_DEBUG("No description found\n");
+ PR_DEBUG("Illegal line of data ignored\n");
+ continue;
+ }
+ tmp.desc= tok;
+ switch (headingtype) {
+ case HEAD_MODEL:
+ XkbRF_AddVarDescCopy(&rules->models,&tmp);
+ break;
+ case HEAD_LAYOUT:
+ XkbRF_AddVarDescCopy(&rules->layouts,&tmp);
+ break;
+ case HEAD_VARIANT:
+ XkbRF_AddVarDescCopy(&rules->variants,&tmp);
+ break;
+ case HEAD_OPTION:
+ XkbRF_AddVarDescCopy(&rules->options,&tmp);
+ break;
+ case HEAD_EXTRA:
+ XkbRF_AddVarDescCopy(&rules->extra[extra_ndx],&tmp);
+ break;
+ }
+ }
+ FreeInputLine(&line);
+ if ((rules->models.num_desc==0) && (rules->layouts.num_desc==0) &&
+ (rules->variants.num_desc==0) && (rules->options.num_desc==0) &&
+ (rules->num_extra==0)) {
+ return False;
+ }
+ return True;
+}
+
+Bool
+XkbRF_LoadDescriptionsByName(char *base,char *locale,XkbRF_RulesPtr rules)
+{
+FILE * file;
+char buf[PATH_MAX];
+Bool ok;
+
+ if ((!base)||(!rules))
+ return False;
+ if (locale) {
+ if (strlen(base)+strlen(locale)+6 > PATH_MAX)
+ return False;
+ sprintf(buf,"%s-%s.lst", base, locale);
+ }
+ else {
+ if (strlen(base)+5 > PATH_MAX)
+ return False;
+ sprintf(buf,"%s.lst", base);
+ }
+
+ file= fopen(buf, "r");
+ if ((!file)&&(locale)) { /* fallback if locale was specified */
+ sprintf(buf,"%s.lst", base);
+
+ file= fopen(buf, "r");
+ }
+ if (!file)
+ return False;
+ ok= XkbRF_LoadDescriptions(file,rules);
+ fclose(file);
+ return ok;
+}
+
+/***====================================================================***/
+
+XkbRF_RulesPtr
+XkbRF_Load(char *base,char *locale,Bool wantDesc,Bool wantRules)
+{
+XkbRF_RulesPtr rules;
+
+ if ((!base)||((!wantDesc)&&(!wantRules)))
+ return NULL;
+ if ((rules=_XkbTypedCalloc(1,XkbRF_RulesRec))==NULL)
+ return NULL;
+ if (wantDesc&&(!XkbRF_LoadDescriptionsByName(base,locale,rules))) {
+ XkbRF_Free(rules,True);
+ return NULL;
+ }
+ if (wantRules&&(!XkbRF_LoadRulesByName(base,locale,rules))) {
+ XkbRF_Free(rules,True);
+ return NULL;
+ }
+ return rules;
+}
+
+XkbRF_RulesPtr
+XkbRF_Create(int szRules,int szExtra)
+{
+XkbRF_RulesPtr rules;
+
+ if ((rules=_XkbTypedCalloc(1,XkbRF_RulesRec))==NULL)
+ return NULL;
+ if (szRules>0) {
+ rules->sz_rules= szRules;
+ rules->rules= _XkbTypedCalloc(rules->sz_rules,XkbRF_RuleRec);
+ if (!rules->rules) {
+ _XkbFree(rules);
+ return NULL;
+ }
+ }
+ if (szExtra>0) {
+ rules->sz_extra= szExtra;
+ rules->extra= _XkbTypedCalloc(rules->sz_extra,XkbRF_DescribeVarsRec);
+ if (!rules->extra) {
+ if (rules->rules)
+ _XkbFree(rules->rules);
+ _XkbFree(rules);
+ return NULL;
+ }
+ }
+ return rules;
+}
+
+/***====================================================================***/
+
+static void
+XkbRF_ClearVarDescriptions(XkbRF_DescribeVarsPtr var)
+{
+register int i;
+
+ for (i=0;i<var->num_desc;i++) {
+ if (var->desc[i].name)
+ _XkbFree(var->desc[i].name);
+ if (var->desc[i].desc)
+ _XkbFree(var->desc[i].desc);
+ var->desc[i].name= var->desc[i].desc= NULL;
+ }
+ if (var->desc)
+ _XkbFree(var->desc);
+ var->desc= NULL;
+ return;
+}
+
+void
+XkbRF_Free(XkbRF_RulesPtr rules,Bool freeRules)
+{
+int i;
+XkbRF_RulePtr rule;
+XkbRF_GroupPtr group;
+
+ if (!rules)
+ return;
+ XkbRF_ClearVarDescriptions(&rules->models);
+ XkbRF_ClearVarDescriptions(&rules->layouts);
+ XkbRF_ClearVarDescriptions(&rules->variants);
+ XkbRF_ClearVarDescriptions(&rules->options);
+ if (rules->extra) {
+ for (i = 0; i < rules->num_extra; i++) {
+ XkbRF_ClearVarDescriptions(&rules->extra[i]);
+ }
+ _XkbFree(rules->extra);
+ rules->num_extra= rules->sz_extra= 0;
+ rules->extra= NULL;
+ }
+ if (rules->rules) {
+ for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) {
+ if (rule->model) _XkbFree(rule->model);
+ if (rule->layout) _XkbFree(rule->layout);
+ if (rule->variant) _XkbFree(rule->variant);
+ if (rule->option) _XkbFree(rule->option);
+ if (rule->keycodes) _XkbFree(rule->keycodes);
+ if (rule->symbols) _XkbFree(rule->symbols);
+ if (rule->types) _XkbFree(rule->types);
+ if (rule->compat) _XkbFree(rule->compat);
+ if (rule->geometry) _XkbFree(rule->geometry);
+ if (rule->keymap) _XkbFree(rule->keymap);
+ bzero((char *)rule,sizeof(XkbRF_RuleRec));
+ }
+ _XkbFree(rules->rules);
+ rules->num_rules= rules->sz_rules= 0;
+ rules->rules= NULL;
+ }
+
+ if (rules->groups) {
+ for (i=0, group=rules->groups;i<rules->num_groups;i++,group++) {
+ if (group->name) _XkbFree(group->name);
+ if (group->words) _XkbFree(group->words);
+ }
+ _XkbFree(rules->groups);
+ rules->num_groups= 0;
+ rules->groups= NULL;
+ }
+ if (freeRules)
+ _XkbFree(rules);
+ return;
+}
+
+#ifndef XKB_IN_SERVER
+
+Bool
+XkbRF_GetNamesProp(Display *dpy,char **rf_rtrn,XkbRF_VarDefsPtr vd_rtrn)
+{
+Atom rules_atom,actual_type;
+int fmt;
+unsigned long nitems,bytes_after;
+char *data,*out;
+Status rtrn;
+
+ rules_atom= XInternAtom(dpy,_XKB_RF_NAMES_PROP_ATOM,True);
+ if (rules_atom==None) /* property cannot exist */
+ return False;
+ rtrn= XGetWindowProperty(dpy,DefaultRootWindow(dpy),rules_atom,
+ 0L,_XKB_RF_NAMES_PROP_MAXLEN,False,
+ XA_STRING,&actual_type,
+ &fmt,&nitems,&bytes_after,
+ (unsigned char **)&data);
+ if (rtrn!=Success)
+ return False;
+ if (rf_rtrn)
+ *rf_rtrn= NULL;
+ (void)bzero((char *)vd_rtrn,sizeof(XkbRF_VarDefsRec));
+ if ((bytes_after>0)||(actual_type!=XA_STRING)||(fmt!=8)) {
+ if (data) XFree(data);
+ return (fmt==0?True:False);
+ }
+
+ out= data;
+ if (out && (*out) && rf_rtrn)
+ *rf_rtrn= _XkbDupString(out);
+ out+=strlen(out)+1;
+
+ if ((out-data)<nitems) {
+ if (*out)
+ vd_rtrn->model= _XkbDupString(out);
+ out+=strlen(out)+1;
+ }
+
+ if ((out-data)<nitems) {
+ if (*out)
+ vd_rtrn->layout= _XkbDupString(out);
+ out+=strlen(out)+1;
+ }
+
+ if ((out-data)<nitems) {
+ if (*out)
+ vd_rtrn->variant= _XkbDupString(out);
+ out+=strlen(out)+1;
+ }
+
+
+ if ((out-data)<nitems) {
+ if (*out)
+ vd_rtrn->options= _XkbDupString(out);
+ out+=strlen(out)+1;
+ }
+ XFree(data);
+ return True;
+}
+
+Bool
+XkbRF_SetNamesProp(Display *dpy,char *rules_file,XkbRF_VarDefsPtr var_defs)
+{
+int len,out;
+Atom name;
+char * pval;
+
+ len= (rules_file?strlen(rules_file):0);
+ len+= (var_defs->model?strlen(var_defs->model):0);
+ len+= (var_defs->layout?strlen(var_defs->layout):0);
+ len+= (var_defs->variant?strlen(var_defs->variant):0);
+ len+= (var_defs->options?strlen(var_defs->options):0);
+ if (len<1)
+ return True;
+
+ len+= 5; /* trailing NULs */
+
+ name= XInternAtom(dpy,_XKB_RF_NAMES_PROP_ATOM,False);
+ if (name==None) { /* should never happen */
+ _XkbLibError(_XkbErrXReqFailure,"XkbRF_SetNamesProp",X_InternAtom);
+ return False;
+ }
+ pval= (char *)_XkbAlloc(len);
+ if (!pval) {
+ _XkbLibError(_XkbErrBadAlloc,"XkbRF_SetNamesProp",len);
+ return False;
+ }
+ out= 0;
+ if (rules_file) {
+ strcpy(&pval[out],rules_file);
+ out+= strlen(rules_file);
+ }
+ pval[out++]= '\0';
+ if (var_defs->model) {
+ strcpy(&pval[out],var_defs->model);
+ out+= strlen(var_defs->model);
+ }
+ pval[out++]= '\0';
+ if (var_defs->layout) {
+ strcpy(&pval[out],var_defs->layout);
+ out+= strlen(var_defs->layout);
+ }
+ pval[out++]= '\0';
+ if (var_defs->variant) {
+ strcpy(&pval[out],var_defs->variant);
+ out+= strlen(var_defs->variant);
+ }
+ pval[out++]= '\0';
+ if (var_defs->options) {
+ strcpy(&pval[out],var_defs->options);
+ out+= strlen(var_defs->options);
+ }
+ pval[out++]= '\0';
+ if (out!=len) {
+ _XkbLibError(_XkbErrBadLength,"XkbRF_SetNamesProp",out);
+ _XkbFree(pval);
+ return False;
+ }
+
+ XChangeProperty(dpy,DefaultRootWindow(dpy),name,XA_STRING,8,PropModeReplace,
+ (unsigned char *)pval,len);
+ _XkbFree(pval);
+ return True;
+}
+
+#endif
diff --git a/nx-X11/lib/xkbfile/srvmisc.c b/nx-X11/lib/xkbfile/srvmisc.c
new file mode 100644
index 000000000..3e4c73c98
--- /dev/null
+++ b/nx-X11/lib/xkbfile/srvmisc.c
@@ -0,0 +1,216 @@
+/* $Xorg: srvmisc.c,v 1.3 2000/08/17 19:46:43 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbfile/srvmisc.c,v 3.4 2001/10/28 03:32:47 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKBgeom.h>
+
+#include "XKMformat.h"
+#include "XKBfileInt.h"
+
+Bool
+XkbWriteToServer(XkbFileInfo *result)
+{
+XkbDescPtr xkb;
+Display * dpy;
+
+ if ((result==NULL)||(result->xkb==NULL)||(result->xkb->dpy==NULL))
+ return False;
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if (!XkbSetMap(dpy,XkbAllMapComponentsMask,xkb))
+ return False;
+ if (!XkbSetIndicatorMap(dpy,~0,xkb))
+ return False;
+#ifdef NOTYET
+ if (!XkbSetControls(dpy,XkbAllControlsMask,xkb))
+ return False;
+#endif
+ if (!XkbSetCompatMap(dpy,XkbAllCompatMask,xkb,True))
+ return False;
+ if (!XkbSetNames(dpy,XkbAllNamesMask,0,xkb->map->num_types,xkb))
+ return False;
+ if (xkb->geom) {
+ if (XkbSetGeometry(dpy,xkb->device_spec,xkb->geom)!=Success)
+ return False;
+ }
+ return True;
+#ifdef NOTYET
+ switch (result->type) {
+ case XkmSemanticsFile:
+ func= WriteCHdrSemantics;
+ break;
+ case XkmLayoutFile:
+ func= WriteCHdrLayout;
+ break;
+ case XkmKeymapFile:
+ func= WriteCHdrKeymap;
+ break;
+ default:
+ _XkbLibError(_XkbErrIllegalContents,"XkbWriteToServer",result->type);
+ break;
+ }
+ return ok;
+#endif
+}
+
+unsigned
+XkbReadFromServer(Display *dpy,unsigned need,unsigned want,XkbFileInfo *result)
+{
+unsigned which= need|want;
+unsigned tmp = 0;
+
+ if ((result==NULL)||(dpy==NULL))
+ return which;
+
+ if (which&XkmSymbolsMask) tmp= XkbAllMapComponentsMask;
+ else if (which&XkmTypesMask) tmp= XkbKeyTypesMask;
+ if (result->xkb==NULL) {
+ result->xkb= XkbGetMap(dpy,tmp,XkbUseCoreKbd);
+ if (!result->xkb)
+ return which;
+ else which&= ~(XkmSymbolsMask|XkmTypesMask|XkmVirtualModsMask);
+ }
+ else if ((tmp)&&(XkbGetUpdatedMap(dpy,tmp,result->xkb)==Success))
+ which&= ~(XkmSymbolsMask|XkmTypesMask|XkmVirtualModsMask);
+
+ if (which&XkmIndicatorsMask) {
+ if (XkbGetIndicatorMap(dpy,XkbAllIndicatorsMask,result->xkb)==Success)
+ which&= ~XkmIndicatorsMask;
+ }
+
+ if (which&XkmCompatMapMask) {
+ if (XkbGetCompatMap(dpy,XkbAllCompatMask,result->xkb)==Success)
+ which&= ~XkmCompatMapMask;
+ }
+ if (which&XkmGeometryMask) {
+ if (XkbGetGeometry(dpy,result->xkb)==Success)
+ which&= ~XkmGeometryMask;
+ }
+ XkbGetNames(dpy,XkbAllNamesMask,result->xkb);
+ return which;
+}
+
+Status
+XkbChangeKbdDisplay(Display *newDpy,XkbFileInfo *result)
+{
+register int i;
+XkbDescPtr xkb;
+Display * oldDpy;
+Atom * atm;
+
+ if ((result->xkb==NULL)||(result->xkb->dpy==newDpy))
+ return Success;
+ xkb= result->xkb;
+ oldDpy= xkb->dpy;
+ if (xkb->names) {
+ XkbNamesPtr names= xkb->names;
+ names->keycodes= XkbChangeAtomDisplay(oldDpy,newDpy,names->keycodes);
+ names->geometry= XkbChangeAtomDisplay(oldDpy,newDpy,names->geometry);
+ names->symbols= XkbChangeAtomDisplay(oldDpy,newDpy,names->symbols);
+ names->types= XkbChangeAtomDisplay(oldDpy,newDpy,names->types);
+ names->compat= XkbChangeAtomDisplay(oldDpy,newDpy,names->compat);
+ names->phys_symbols= XkbChangeAtomDisplay(oldDpy,newDpy,
+ names->phys_symbols);
+ for (i=0,atm=names->vmods;i<XkbNumVirtualMods;i++,atm++) {
+ *atm= XkbChangeAtomDisplay(oldDpy,newDpy,*atm);
+ }
+ for (i=0,atm=names->indicators;i<XkbNumIndicators;i++,atm++) {
+ *atm= XkbChangeAtomDisplay(oldDpy,newDpy,*atm);
+ }
+ for (i=0,atm=names->groups;i<XkbNumKbdGroups;i++,atm++) {
+ *atm= XkbChangeAtomDisplay(oldDpy,newDpy,*atm);
+ }
+ for (i=0,atm=names->radio_groups;i<names->num_rg;i++,atm++) {
+ *atm= XkbChangeAtomDisplay(oldDpy,newDpy,*atm);
+ }
+ }
+ if (xkb->map) {
+ register int t;
+ XkbKeyTypePtr type;
+ for (t=0,type=xkb->map->types;t<xkb->map->num_types;t++,type++) {
+ type->name= XkbChangeAtomDisplay(oldDpy,newDpy,type->name);
+ if (type->level_names!=NULL) {
+ for (i=0,atm=type->level_names;i<type->num_levels;i++,atm++) {
+ *atm= XkbChangeAtomDisplay(oldDpy,newDpy,*atm);
+ }
+ }
+ }
+ }
+ if (xkb->geom) {
+ XkbGeometryPtr geom= xkb->geom;
+ geom->name= XkbChangeAtomDisplay(oldDpy,newDpy,geom->name);
+ if (geom->shapes) {
+ register int s;
+ XkbShapePtr shape;
+ for (s=0,shape=geom->shapes;s<geom->num_shapes;s++,shape++) {
+ shape->name= XkbChangeAtomDisplay(oldDpy,newDpy,shape->name);
+ }
+ }
+ if (geom->sections) {
+ register int s;
+ XkbSectionPtr section;
+ for (s=0,section=geom->sections;s<geom->num_sections;s++,section++){
+ section->name=XkbChangeAtomDisplay(oldDpy,newDpy,section->name);
+ if (section->doodads) {
+ register int d;
+ XkbDoodadPtr doodad;
+ for (d=0,doodad=section->doodads;d<section->num_doodads;
+ d++,doodad++) {
+ doodad->any.name= XkbChangeAtomDisplay(oldDpy,newDpy,
+ doodad->any.name);
+ }
+ }
+ if (section->overlays) {
+ register int o;
+ register XkbOverlayPtr ol;
+ for (o=0,ol=section->overlays;o<section->num_overlays;
+ o++,ol++) {
+ ol->name= XkbChangeAtomDisplay(oldDpy,newDpy,ol->name);
+ }
+ }
+ }
+ }
+ if (geom->doodads) {
+ register int d;
+ XkbDoodadPtr doodad;
+ for (d=0,doodad=geom->doodads;d<geom->num_doodads;d++,doodad++) {
+ doodad->any.name= XkbChangeAtomDisplay(oldDpy,newDpy,
+ doodad->any.name);
+ }
+ }
+ }
+ xkb->dpy= newDpy;
+ return Success;
+}
diff --git a/nx-X11/lib/xkbfile/xkbatom.c b/nx-X11/lib/xkbfile/xkbatom.c
new file mode 100644
index 000000000..1a5dea0f8
--- /dev/null
+++ b/nx-X11/lib/xkbfile/xkbatom.c
@@ -0,0 +1,245 @@
+/* $Xorg: xkbatom.c,v 1.4 2001/02/09 02:04:05 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.
+
+******************************************************************/
+
+/************************************************************
+ Copyright 1994 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkbatom.c,v 3.8 2001/12/14 19:57:03 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/XKBlib.h>
+
+#include "XKMformat.h"
+#include "XKBfileInt.h"
+
+/***====================================================================***/
+
+#define InitialTableSize 100
+
+typedef struct _Node {
+ struct _Node *left, *right;
+ Atom a;
+ unsigned int fingerPrint;
+ char *string;
+} NodeRec, *NodePtr;
+
+#define BAD_RESOURCE 0xe0000000
+
+static Atom lastAtom = None;
+static NodePtr atomRoot = (NodePtr)NULL;
+static unsigned long tableLength;
+static NodePtr *nodeTable;
+
+static Atom
+_XkbMakeAtom(char *string,unsigned len,Bool makeit)
+{
+ register NodePtr * np;
+ unsigned i;
+ int comp;
+ register unsigned int fp = 0;
+
+ np = &atomRoot;
+ for (i = 0; i < (len+1)/2; i++)
+ {
+ fp = fp * 27 + string[i];
+ fp = fp * 27 + string[len - 1 - i];
+ }
+ while (*np != (NodePtr) NULL)
+ {
+ if (fp < (*np)->fingerPrint)
+ np = &((*np)->left);
+ else if (fp > (*np)->fingerPrint)
+ np = &((*np)->right);
+ else
+ { /* now start testing the strings */
+ comp = strncmp(string, (*np)->string, (int)len);
+ if ((comp < 0) || ((comp == 0) && (len < strlen((*np)->string))))
+ np = &((*np)->left);
+ else if (comp > 0)
+ np = &((*np)->right);
+ else
+ return(*np)->a;
+ }
+ }
+ if (makeit)
+ {
+ register NodePtr nd;
+
+ nd = (NodePtr) _XkbAlloc(sizeof(NodeRec));
+ if (!nd)
+ return BAD_RESOURCE;
+ nd->string = (char *) _XkbAlloc(len + 1);
+ if (!nd->string) {
+ _XkbFree(nd);
+ return BAD_RESOURCE;
+ }
+ strncpy(nd->string, string, (int)len);
+ nd->string[len] = 0;
+ if ((lastAtom + 1) >= tableLength) {
+ NodePtr *table;
+
+ table = (NodePtr *) _XkbRealloc(nodeTable,
+ tableLength * (2 * sizeof(NodePtr)));
+ if (!table) {
+ if (nd->string != string)
+ _XkbFree(nd->string);
+ _XkbFree(nd);
+ return BAD_RESOURCE;
+ }
+ tableLength <<= 1;
+ nodeTable = table;
+ }
+ *np = nd;
+ nd->left = nd->right = (NodePtr) NULL;
+ nd->fingerPrint = fp;
+ nd->a = (++lastAtom);
+ *(nodeTable+lastAtom) = nd;
+ return nd->a;
+ }
+ else
+ return None;
+}
+
+static char *
+_XkbNameForAtom(Atom atom)
+{
+ NodePtr node;
+ if (atom > lastAtom) return 0;
+ if ((node = nodeTable[atom]) == (NodePtr)NULL) return 0;
+ return node->string;
+}
+
+static void
+_XkbInitAtoms(void)
+{
+ tableLength = InitialTableSize;
+ nodeTable = (NodePtr *)_XkbAlloc(InitialTableSize*sizeof(NodePtr));
+ nodeTable[None] = (NodePtr)NULL;
+}
+
+/***====================================================================***/
+
+char *
+XkbAtomGetString(Display *dpy,Atom atm)
+{
+ if (atm==None)
+ return NULL;
+ if (dpy==NULL)
+ return _XkbNameForAtom(atm);
+ return XGetAtomName(dpy,atm);
+}
+
+/***====================================================================***/
+
+Atom
+XkbInternAtom(Display *dpy,char *name,Bool onlyIfExists)
+{
+ if (name==NULL)
+ return None;
+ if (dpy==NULL) {
+ return _XkbMakeAtom(name, strlen(name), (!onlyIfExists));
+ }
+ return XInternAtom(dpy,name,onlyIfExists);
+}
+
+/***====================================================================***/
+
+Atom
+XkbChangeAtomDisplay(Display *oldDpy,Display *newDpy,Atom atm)
+{
+char *tmp;
+
+ if (atm!=None) {
+ tmp= XkbAtomGetString(oldDpy,atm);
+ if (tmp!=NULL)
+ return XkbInternAtom(newDpy,tmp,False);
+ }
+ return None;
+}
+
+/***====================================================================***/
+
+void
+XkbInitAtoms(Display *dpy)
+{
+static int been_here= 0;
+ if ((dpy==NULL)&&(!been_here)) {
+ _XkbInitAtoms();
+ been_here= 1;
+ }
+ return;
+}
diff --git a/nx-X11/lib/xkbfile/xkbbells.c b/nx-X11/lib/xkbfile/xkbbells.c
new file mode 100644
index 000000000..30b918fb4
--- /dev/null
+++ b/nx-X11/lib/xkbfile/xkbbells.c
@@ -0,0 +1,104 @@
+/* $Xorg: xkbbells.c,v 1.3 2000/08/17 19:46:43 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/XKBlib.h>
+#include "XKBbells.h"
+
+static char *_xkbStdBellNames[XkbBI_NumBells] = {
+ "Info",
+ "Warning",
+ "MinorError",
+ "MajorError",
+ "BadValue",
+ "InvalidLocation",
+ "Question",
+ "Start",
+ "End",
+ "Success",
+ "Failure",
+ "Wait",
+ "Proceed",
+ "Ignore",
+ "Iconify",
+ "Deconify",
+ "Open",
+ "Close",
+ "TerminalBell",
+ "MarginBell",
+ "CursorStuck",
+ "NewMail",
+ "LaunchApp",
+ "AppDeath",
+ "ImAlive",
+ "ClockChimeHour",
+ "ClockChimeHalf",
+ "ClockChimeQuarter",
+ "RepeatingLastBell",
+ "ComposeFail",
+ "AX_FeatureOn",
+ "AX_FeatureOff",
+ "AX_FeatureChange",
+ "AX_IndicatorOn",
+ "AX_IndicatorOff",
+ "AX_IndicatorChange",
+ "AX_SlowKeysWarning",
+ "AX_SlowKeyPress",
+ "AX_SlowKeyAccept",
+ "AX_SlowKeyReject",
+ "AX_SlowKeyRelease",
+ "AX_BounceKeyReject",
+ "AX_StickyLatch",
+ "AX_StickyLock",
+ "AX_StickyUnlock"
+};
+
+static Atom _xkbStdBellAtoms[XkbBI_NumBells];
+
+Bool
+XkbStdBell(Display *dpy,Window win,int percent,int bellDef)
+{
+ if ((bellDef<0)||(bellDef>=XkbBI_NumBells))
+ bellDef= XkbBI_Info;
+ if (_xkbStdBellAtoms[bellDef]==None)
+ _xkbStdBellAtoms[bellDef]= XInternAtom(dpy,_xkbStdBellNames[bellDef],0);
+ return XkbBell(dpy,win,percent,_xkbStdBellAtoms[bellDef]);
+}
+
+Bool
+XkbStdBellEvent(Display *dpy,Window win,int percent,int bellDef)
+{
+ if ((bellDef<0)||(bellDef>=XkbBI_NumBells))
+ bellDef= XkbBI_Info;
+ if (_xkbStdBellAtoms[bellDef]==None)
+ _xkbStdBellAtoms[bellDef]= XInternAtom(dpy,_xkbStdBellNames[bellDef],0);
+ return XkbBellEvent(dpy,win,percent,_xkbStdBellAtoms[bellDef]);
+}
diff --git a/nx-X11/lib/xkbfile/xkbconfig.c b/nx-X11/lib/xkbfile/xkbconfig.c
new file mode 100644
index 000000000..7930979eb
--- /dev/null
+++ b/nx-X11/lib/xkbfile/xkbconfig.c
@@ -0,0 +1,1355 @@
+/* $Xorg: xkbconfig.c,v 1.4 2000/08/17 19:46:43 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkbconfig.c,v 3.7 2001/11/30 12:11:51 eich Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#elif defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#include <X11/Xfuncs.h>
+
+#include <X11/Xfuncs.h>
+
+#ifndef XKB_IN_SERVER
+
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#include <X11/XKBlib.h>
+#include "XKBfileInt.h"
+
+#else
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#include <X11/keysym.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include "dix.h"
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+#endif
+
+#include <X11/extensions/XKBconfig.h>
+
+/***====================================================================***/
+
+#define XKBCF_MAX_STR_LEN 100
+static char _XkbCF_rtrn[XKBCF_MAX_STR_LEN+1];
+
+static int
+ScanIdent(FILE *file,int ch,XkbCFScanResultPtr val_rtrn)
+{
+register int i;
+char * str;
+
+ val_rtrn->str= str= _XkbCF_rtrn;
+ for (i=0;(isalpha(ch)||isdigit(ch)||(ch=='_'));ch=getc(file)) {
+ if (i<XKBCF_MAX_STR_LEN)
+ str[i++]= ch;
+ }
+ if ((ch!=EOF)&&(ch!=' ')&&(ch!='\t'))
+ ungetc(ch,file);
+ str[i]= '\0';
+ return XkbCF_Ident;
+}
+
+static int
+ScanString(FILE *file,int quote,XkbCFScanResultPtr val_rtrn)
+{
+int ch,nInBuf;
+
+ nInBuf = 0;
+ while ( ((ch=getc(file))!=EOF) && (ch!='\n') && (ch!=quote) ) {
+ if ( ch == '\\' ) {
+ if ((ch = getc(file))!=EOF) {
+ if ( ch=='n' ) ch = '\n';
+ else if ( ch == 't' ) ch = '\t';
+ else if ( ch == 'v' ) ch = '\v';
+ else if ( ch == 'b' ) ch = '\b';
+ else if ( ch == 'r' ) ch = '\r';
+ else if ( ch == 'f' ) ch = '\f';
+ else if ( ch == 'e' ) ch = '\033';
+ else if ( ch == '0' ) {
+ int tmp,stop;
+ ch = stop = 0;
+ if (((tmp=getc(file))!=EOF) && (isdigit(tmp)) &&
+ (tmp!='8') && (tmp!='9')) {
+ ch= (ch*8)+(tmp-'0');
+ }
+ else {
+ stop= 1;
+ ungetc(tmp,file);
+ }
+ if ((!stop) && ((tmp=getc(file))!=EOF) && (isdigit(tmp)) &&
+ (tmp!='8') && (tmp!='9')) {
+ ch= (ch*8)+(tmp-'0');
+ }
+ else {
+ stop= 1;
+ ungetc(tmp,file);
+ }
+ if ((!stop) && ((tmp=getc(file))!=EOF) && (isdigit(tmp)) &&
+ (tmp!='8') && (tmp!='9')) {
+ ch= (ch*8)+(tmp-'0');
+ }
+ else {
+ stop= 1;
+ ungetc(tmp,file);
+ }
+ }
+ }
+ else return XkbCF_EOF;
+ }
+
+ if ( nInBuf < XKBCF_MAX_STR_LEN-1 )
+ _XkbCF_rtrn[nInBuf++] = ch;
+ }
+ if ( ch == quote ) {
+ _XkbCF_rtrn[nInBuf++] = '\0';
+ val_rtrn->str= _XkbCF_rtrn;
+ return XkbCF_String;
+ }
+ return XkbCF_UnterminatedString;
+}
+
+static int
+ScanInteger(FILE *file,int ch,XkbCFScanResultPtr val_rtrn)
+{
+int i;
+
+ if (isdigit(ch))
+ ungetc(ch,file);
+ if (fscanf(file,"%i",&i)==1) {
+ val_rtrn->ival= i;
+ return XkbCF_Integer;
+ }
+ return XkbCF_Unknown;
+}
+
+int
+XkbCFScan(FILE *file,XkbCFScanResultPtr val_rtrn,XkbConfigRtrnPtr rtrn)
+{
+int ch;
+
+ do {
+ ch= getc(file);
+ } while ((ch=='\t')||(ch==' '));
+ if (isalpha(ch))
+ return ScanIdent(file,ch,val_rtrn);
+ else if (isdigit(ch))
+ return ScanInteger(file,ch,val_rtrn);
+ else if (ch=='"')
+ return ScanString(file,ch,val_rtrn);
+ else if (ch=='\n') {
+ rtrn->line++;
+ return XkbCF_EOL;
+ }
+ else if (ch==';')
+ return XkbCF_Semi;
+ else if (ch=='=')
+ return XkbCF_Equals;
+ else if (ch=='+') {
+ ch= getc(file);
+ if (ch=='=')
+ return XkbCF_PlusEquals;
+ if ((ch!=EOF)&&(ch!=' ')&&(ch!='\t'))
+ ungetc(ch,file);
+ return XkbCF_Plus;
+ }
+ else if (ch=='-') {
+ ch= getc(file);
+ if (ch=='=')
+ return XkbCF_MinusEquals;
+ if ((ch!=EOF)&&(ch!=' ')&&(ch!='\t'))
+ ungetc(ch,file);
+ return XkbCF_Minus;
+ }
+ else if (ch==EOF)
+ return XkbCF_EOF;
+ else if ((ch=='#')||((ch=='/')&&(getc(file)=='/'))) {
+ while ((ch!='\n')&&(ch!=EOF))
+ ch= getc(file);
+ rtrn->line++;
+ return XkbCF_EOL;
+ }
+ return XkbCF_Unknown;
+}
+
+/***====================================================================***/
+
+#define _XkbCF_Illegal 0
+#define _XkbCF_Keymap 1
+#define _XkbCF_Keycodes 2
+#define _XkbCF_Geometry 3
+#define _XkbCF_PhysSymbols 4
+#define _XkbCF_Symbols 5
+#define _XkbCF_Types 6
+#define _XkbCF_CompatMap 7
+
+#define _XkbCF_RulesFile 8
+#define _XkbCF_Model 9
+#define _XkbCF_Layout 10
+#define _XkbCF_Variant 11
+#define _XkbCF_Options 12
+
+#define _XkbCF_InitialMods 13
+#define _XkbCF_InitialCtrls 14
+
+#define _XkbCF_ClickVolume 15
+#define _XkbCF_BellVolume 16
+#define _XkbCF_BellPitch 17
+#define _XkbCF_BellDuration 18
+#define _XkbCF_RepeatDelay 19
+#define _XkbCF_RepeatInterval 20
+#define _XkbCF_SlowKeysDelay 21
+#define _XkbCF_DebounceDelay 22
+#define _XkbCF_MouseKeysDelay 23
+#define _XkbCF_MouseKeysInterval 24
+#define _XkbCF_MouseKeysTimeToMax 25
+#define _XkbCF_MouseKeysMaxSpeed 26
+#define _XkbCF_MouseKeysCurve 27
+#define _XkbCF_AccessXTimeout 28
+#define _XkbCF_AccessXTimeoutCtrlsOn 29
+#define _XkbCF_AccessXTimeoutCtrlsOff 30
+#define _XkbCF_AccessXTimeoutOptsOn 31
+#define _XkbCF_AccessXTimeoutOptsOff 32
+
+#define _XkbCF_IgnoreLockMods 33
+#define _XkbCF_IgnoreGroupLock 34
+#define _XkbCF_InternalMods 35
+
+#define _XkbCF_GroupsWrap 36
+#define _XkbCF_InitialFeedback 37
+
+static Bool
+AddCtrlByName(XkbConfigRtrnPtr rtrn,char *name,unsigned long *ctrls_rtrn)
+{
+ if ((_XkbStrCaseCmp(name,"repeat")==0)||
+ (_XkbStrCaseCmp(name,"repeatkeys")==0))
+ *ctrls_rtrn= XkbRepeatKeysMask;
+ else if (_XkbStrCaseCmp(name,"slowkeys")==0)
+ *ctrls_rtrn= XkbSlowKeysMask;
+ else if (_XkbStrCaseCmp(name,"bouncekeys")==0)
+ *ctrls_rtrn= XkbBounceKeysMask;
+ else if (_XkbStrCaseCmp(name,"stickykeys")==0)
+ *ctrls_rtrn= XkbStickyKeysMask;
+ else if (_XkbStrCaseCmp(name,"mousekeys")==0)
+ *ctrls_rtrn= XkbMouseKeysMask;
+ else if (_XkbStrCaseCmp(name,"mousekeysaccel")==0)
+ *ctrls_rtrn= XkbMouseKeysAccelMask;
+ else if (_XkbStrCaseCmp(name,"accessxkeys")==0)
+ *ctrls_rtrn= XkbAccessXKeysMask;
+ else if (_XkbStrCaseCmp(name,"accessxtimeout")==0)
+ *ctrls_rtrn= XkbAccessXTimeoutMask;
+ else if (_XkbStrCaseCmp(name,"accessxfeedback")==0)
+ *ctrls_rtrn= XkbAccessXFeedbackMask;
+ else if (_XkbStrCaseCmp(name,"audiblebell")==0)
+ *ctrls_rtrn= XkbAudibleBellMask;
+ else if (_XkbStrCaseCmp(name,"overlay1")==0)
+ *ctrls_rtrn= XkbOverlay1Mask;
+ else if (_XkbStrCaseCmp(name,"overlay2")==0)
+ *ctrls_rtrn= XkbOverlay2Mask;
+ else if (_XkbStrCaseCmp(name,"ignoregrouplock")==0)
+ *ctrls_rtrn= XkbIgnoreGroupLockMask;
+ else {
+ rtrn->error= XkbCF_ExpectedControl;
+ return False;
+ }
+ return True;
+}
+
+static Bool
+AddAXTimeoutOptByName( XkbConfigRtrnPtr rtrn,
+ char * name,
+ unsigned short * opts_rtrn)
+{
+ if (_XkbStrCaseCmp(name,"slowkeyspress")==0)
+ *opts_rtrn= XkbAX_SKPressFBMask;
+ else if (_XkbStrCaseCmp(name,"slowkeysaccept")==0)
+ *opts_rtrn= XkbAX_SKAcceptFBMask;
+ else if (_XkbStrCaseCmp(name,"feature")==0)
+ *opts_rtrn= XkbAX_FeatureFBMask;
+ else if (_XkbStrCaseCmp(name,"slowwarn")==0)
+ *opts_rtrn= XkbAX_SlowWarnFBMask;
+ else if (_XkbStrCaseCmp(name,"indicator")==0)
+ *opts_rtrn= XkbAX_IndicatorFBMask;
+ else if (_XkbStrCaseCmp(name,"stickykeys")==0)
+ *opts_rtrn= XkbAX_StickyKeysFBMask;
+ else if (_XkbStrCaseCmp(name,"twokeys")==0)
+ *opts_rtrn= XkbAX_TwoKeysMask;
+ else if (_XkbStrCaseCmp(name,"latchtolock")==0)
+ *opts_rtrn= XkbAX_LatchToLockMask;
+ else if (_XkbStrCaseCmp(name,"slowkeysrelease")==0)
+ *opts_rtrn= XkbAX_SKReleaseFBMask;
+ else if (_XkbStrCaseCmp(name,"slowkeysreject")==0)
+ *opts_rtrn= XkbAX_SKRejectFBMask;
+ else if (_XkbStrCaseCmp(name,"bouncekeysreject")==0)
+ *opts_rtrn= XkbAX_BKRejectFBMask;
+ else if (_XkbStrCaseCmp(name,"dumbbell")==0)
+ *opts_rtrn= XkbAX_DumbBellFBMask;
+ else {
+ rtrn->error= XkbCF_ExpectedControl;
+ return False;
+ }
+ return True;
+}
+
+XkbConfigUnboundModPtr
+XkbCFAddModByName( XkbConfigRtrnPtr rtrn,
+ int what,
+ char * name,
+ Bool merge,
+ XkbConfigUnboundModPtr last)
+{
+ if (rtrn->num_unbound_mods>=rtrn->sz_unbound_mods) {
+ rtrn->sz_unbound_mods+= 5;
+ rtrn->unbound_mods= _XkbTypedRealloc(rtrn->unbound_mods,
+ rtrn->sz_unbound_mods,
+ XkbConfigUnboundModRec);
+ if (rtrn->unbound_mods==NULL) {
+ rtrn->error= XkbCF_BadAlloc;
+ return False;
+ }
+ }
+ if (last==NULL) {
+ last= &rtrn->unbound_mods[rtrn->num_unbound_mods++];
+ last->what= what;
+ last->mods= 0;
+ last->vmods= 0;
+ last->merge= merge;
+ last->name= NULL;
+ }
+ if (_XkbStrCaseCmp(name,"shift")==0)
+ last->mods|= ShiftMask;
+ else if (_XkbStrCaseCmp(name,"lock")==0)
+ last->mods|= LockMask;
+ else if ((_XkbStrCaseCmp(name,"control")==0)||
+ (_XkbStrCaseCmp(name,"ctrl")==0))
+ last->mods|= ControlMask;
+ else if (_XkbStrCaseCmp(name,"mod1")==0)
+ last->mods|= Mod1Mask;
+ else if (_XkbStrCaseCmp(name,"mod2")==0)
+ last->mods|= Mod2Mask;
+ else if (_XkbStrCaseCmp(name,"mod3")==0)
+ last->mods|= Mod3Mask;
+ else if (_XkbStrCaseCmp(name,"mod4")==0)
+ last->mods|= Mod4Mask;
+ else if (_XkbStrCaseCmp(name,"mod5")==0)
+ last->mods|= Mod5Mask;
+ else {
+ if (last->name!=NULL) {
+ last= &rtrn->unbound_mods[rtrn->num_unbound_mods++];
+ last->what= what;
+ last->mods= 0;
+ last->vmods= 0;
+ last->merge= merge;
+ last->name= NULL;
+ }
+ last->name= _XkbDupString(name);
+ }
+ return last;
+}
+
+int
+XkbCFBindMods(XkbConfigRtrnPtr rtrn,XkbDescPtr xkb)
+{
+register int n,v;
+Atom name;
+XkbConfigUnboundModPtr mod;
+int missing;
+
+ if (rtrn->num_unbound_mods<1)
+ return 0;
+ if ((xkb==NULL) || (xkb->names==NULL))
+ return -1;
+
+ missing= 0;
+ for (n=0,mod=rtrn->unbound_mods;n<rtrn->num_unbound_mods;n++,mod++) {
+ if (mod->name!=NULL) {
+ name= XkbInternAtom(xkb->dpy,mod->name,True);
+ if (name==None)
+ continue;
+ for (v=0;v<XkbNumVirtualMods;v++) {
+ if (xkb->names->vmods[v]==name) {
+ mod->vmods= (1<<v);
+ _XkbFree(mod->name);
+ mod->name= NULL;
+ break;
+ }
+ }
+ if (mod->name!=NULL)
+ missing++;
+ }
+ }
+ return missing;
+}
+
+Bool
+XkbCFApplyMods(XkbConfigRtrnPtr rtrn,int what,XkbConfigModInfoPtr info)
+{
+register int n;
+XkbConfigUnboundModPtr mod;
+
+ if (rtrn->num_unbound_mods<1)
+ return True;
+
+ for (n=0,mod=rtrn->unbound_mods;n<rtrn->num_unbound_mods;n++,mod++) {
+ if (mod->what!=what)
+ continue;
+ if (mod->merge==XkbCF_MergeRemove) {
+ info->mods_clear|= mod->mods;
+ info->vmods_clear|= mod->vmods;
+ }
+ else {
+ if (mod->merge==XkbCF_MergeSet)
+ info->replace= True;
+ info->mods|= mod->mods;
+ info->vmods|= mod->vmods;
+ }
+ if (mod->name==NULL) {
+ mod->what= _XkbCF_Illegal;
+ }
+ else {
+ mod->mods= 0;
+ mod->vmods= 0;
+ }
+ }
+ return True;
+}
+
+/*ARGSUSED*/
+static Bool
+DefaultParser( FILE * file,
+ XkbConfigFieldsPtr fields,
+ XkbConfigFieldPtr field,
+ XkbDescPtr xkb,
+ XkbConfigRtrnPtr rtrn)
+{
+int tok;
+XkbCFScanResultRec val;
+char ** str;
+int merge;
+unsigned long * ctrls, ctrls_mask;
+unsigned short * opts, opts_mask;
+int * pival, sign;
+int onoff;
+XkbConfigUnboundModPtr last;
+unsigned what;
+
+ tok= XkbCFScan(file,&val,rtrn);
+ str= NULL;
+ onoff= 0;
+ pival= NULL;
+ switch (field->field_id) {
+ case _XkbCF_RulesFile: if (!str) str= &rtrn->rules_file;
+ case _XkbCF_Model: if (!str) str= &rtrn->model;
+ case _XkbCF_Layout: if (!str) str= &rtrn->layout;
+ case _XkbCF_Variant: if (!str) str= &rtrn->variant;
+ case _XkbCF_Options: if (!str) str= &rtrn->options;
+ case _XkbCF_Keymap: if (!str) str= &rtrn->keymap;
+ case _XkbCF_Keycodes: if (!str) str= &rtrn->keycodes;
+ case _XkbCF_Geometry: if (!str) str= &rtrn->geometry;
+ case _XkbCF_PhysSymbols:if (!str) str= &rtrn->phys_symbols;
+ case _XkbCF_Symbols: if (!str) str= &rtrn->symbols;
+ case _XkbCF_Types: if (!str) str= &rtrn->types;
+ case _XkbCF_CompatMap: if (!str) str= &rtrn->compat;
+ if (tok!=XkbCF_Equals) {
+ rtrn->error= XkbCF_MissingEquals;
+ goto BAILOUT;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok!=XkbCF_String)&&(tok!=XkbCF_Ident)) {
+ rtrn->error= XkbCF_ExpectedString;
+ return False;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) {
+ rtrn->error= XkbCF_ExpectedEOS;
+ return False;
+ }
+ if (*str!=NULL)
+ _XkbFree(*str);
+ *str= _XkbDupString(val.str);
+ break;
+ case _XkbCF_InitialMods:
+ case _XkbCF_IgnoreLockMods:
+ case _XkbCF_InternalMods:
+ what= XkbCF_InitialMods;
+ if (field->field_id==_XkbCF_InitialMods)
+ rtrn->defined|= (what=XkbCF_InitialMods);
+ else if (field->field_id==_XkbCF_InternalMods)
+ rtrn->defined|= (what=XkbCF_InternalMods);
+ else if (field->field_id==_XkbCF_IgnoreLockMods)
+ rtrn->defined|= (what=XkbCF_IgnoreLockMods);
+ if (tok==XkbCF_Equals) merge= XkbCF_MergeSet;
+ else if (tok==XkbCF_MinusEquals) merge= XkbCF_MergeRemove;
+ else if (tok==XkbCF_PlusEquals) merge= XkbCF_MergeAdd;
+ else {
+ rtrn->error= XkbCF_MissingEquals;
+ goto BAILOUT;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok==XkbCF_EOL)||(tok==XkbCF_Semi)||(tok==XkbCF_EOF)) {
+ rtrn->error= XkbCF_ExpectedModifier;
+ return False;
+ }
+ last= NULL;
+ while ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) {
+ if ((tok!=XkbCF_Ident)&&(tok!=XkbCF_String)) {
+ rtrn->error= XkbCF_ExpectedModifier;
+ return False;
+ }
+ last=XkbCFAddModByName(rtrn,what,val.str,merge,last);
+ if (last==NULL)
+ return False;
+ if (merge==XkbCF_MergeSet)
+ merge= XkbCF_MergeAdd;
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_EOF)&&(tok!=XkbCF_Semi)) {
+ if (tok!=XkbCF_Plus) {
+ rtrn->error= XkbCF_ExpectedOperator;
+ return False;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ }
+ }
+ break;
+ case _XkbCF_InitialCtrls:
+ rtrn->defined|= XkbCF_InitialCtrls;
+ ctrls= NULL;
+ if (tok==XkbCF_PlusEquals)
+ ctrls= &rtrn->initial_ctrls;
+ else if (tok==XkbCF_MinusEquals)
+ ctrls= &rtrn->initial_ctrls_clear;
+ else if (tok==XkbCF_Equals) {
+ ctrls= &rtrn->initial_ctrls;
+ rtrn->replace_initial_ctrls= True;
+ *ctrls= 0;
+ }
+ else {
+ rtrn->error= XkbCF_MissingEquals;
+ goto BAILOUT;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok==XkbCF_EOL)||(tok==XkbCF_Semi)||(tok==XkbCF_EOF)) {
+ rtrn->error= XkbCF_ExpectedControl;
+ return False;
+ }
+ while ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) {
+ if ((tok!=XkbCF_Ident)&&(tok!=XkbCF_String)) {
+ rtrn->error= XkbCF_ExpectedControl;
+ return False;
+ }
+ if (!AddCtrlByName(rtrn,val.str,&ctrls_mask)) {
+ return False;
+ }
+ *ctrls |= ctrls_mask;
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_EOF)&&(tok!=XkbCF_Semi)) {
+ if (tok!=XkbCF_Plus) {
+ rtrn->error= XkbCF_ExpectedOperator;
+ return False;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ }
+ }
+ break;
+ case _XkbCF_AccessXTimeoutCtrlsOn:
+ case _XkbCF_AccessXTimeoutCtrlsOff:
+ opts= NULL;
+ if (tok==XkbCF_MinusEquals) {
+ ctrls= &rtrn->axt_ctrls_ignore;
+ opts= &rtrn->axt_opts_ignore;
+ }
+ else if ((tok==XkbCF_PlusEquals)||(tok==XkbCF_Equals)) {
+ if (field->field_id==_XkbCF_AccessXTimeoutCtrlsOff) {
+ ctrls= &rtrn->axt_ctrls_off;
+ opts= &rtrn->axt_opts_off;
+ if (tok==XkbCF_Equals)
+ rtrn->replace_axt_ctrls_off= True;
+ }
+ else {
+ ctrls= &rtrn->axt_ctrls_on;
+ opts= &rtrn->axt_opts_on;
+ if (tok==XkbCF_Equals)
+ rtrn->replace_axt_ctrls_on= True;
+ }
+ *ctrls= 0;
+ }
+ else {
+ rtrn->error= XkbCF_MissingEquals;
+ goto BAILOUT;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok==XkbCF_EOL)||(tok==XkbCF_Semi)||(tok==XkbCF_EOF)) {
+ rtrn->error= XkbCF_ExpectedControl;
+ return False;
+ }
+ while ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) {
+ if ((tok!=XkbCF_Ident)&&(tok!=XkbCF_String)) {
+ rtrn->error= XkbCF_ExpectedControl;
+ return False;
+ }
+ if (!AddCtrlByName(rtrn,val.str,&ctrls_mask)) {
+ if (!AddAXTimeoutOptByName(rtrn,val.str,&opts_mask))
+ return False;
+ *opts |= opts_mask;
+ if (field->field_id==_XkbCF_AccessXTimeoutCtrlsOff) {
+ rtrn->defined|= XkbCF_AccessXTimeoutOptsOff;
+ if (rtrn->replace_axt_ctrls_off)
+ rtrn->replace_axt_opts_off= True;
+ }
+ else {
+ rtrn->defined|= XkbCF_AccessXTimeoutOptsOn;
+ if (rtrn->replace_axt_ctrls_on)
+ rtrn->replace_axt_opts_on= True;
+ }
+ }
+ else
+ *ctrls |= ctrls_mask;
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_EOF)&&(tok!=XkbCF_Semi)) {
+ if (tok!=XkbCF_Plus) {
+ rtrn->error= XkbCF_ExpectedOperator;
+ return False;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ }
+ }
+ break;
+ case _XkbCF_InitialFeedback:
+ rtrn->defined|= XkbCF_InitialOpts;
+ opts= NULL;
+ if (tok==XkbCF_PlusEquals)
+ opts= &rtrn->initial_opts;
+ else if (tok==XkbCF_MinusEquals)
+ opts= &rtrn->initial_opts_clear;
+ else if (tok==XkbCF_Equals) {
+ opts= &rtrn->initial_opts;
+ rtrn->replace_initial_opts= True;
+ *opts= 0;
+ }
+ else {
+ rtrn->error= XkbCF_MissingEquals;
+ goto BAILOUT;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok==XkbCF_EOL)||(tok==XkbCF_Semi)||(tok==XkbCF_EOF)) {
+ rtrn->error= XkbCF_ExpectedAXOption;
+ return False;
+ }
+ while ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) {
+ if ((tok!=XkbCF_Ident)&&(tok!=XkbCF_String)) {
+ rtrn->error= XkbCF_ExpectedAXOption;
+ return False;
+ }
+ if (!AddAXTimeoutOptByName(rtrn,val.str,&opts_mask)) {
+ return False;
+ }
+ *opts |= opts_mask;
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_EOF)&&(tok!=XkbCF_Semi)) {
+ if (tok!=XkbCF_Plus) {
+ rtrn->error= XkbCF_ExpectedOperator;
+ return False;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ }
+ }
+ break;
+ case _XkbCF_AccessXTimeoutOptsOff:
+ case _XkbCF_AccessXTimeoutOptsOn:
+ opts= NULL;
+ if (tok==XkbCF_MinusEquals)
+ opts= &rtrn->axt_opts_ignore;
+ else if ((tok==XkbCF_PlusEquals)||(tok==XkbCF_Equals)) {
+ if (field->field_id==_XkbCF_AccessXTimeoutOptsOff) {
+ opts= &rtrn->axt_opts_off;
+ if (tok==XkbCF_Equals)
+ rtrn->replace_axt_opts_off= True;
+ }
+ else {
+ opts= &rtrn->axt_opts_on;
+ if (tok==XkbCF_Equals)
+ rtrn->replace_axt_opts_on= True;
+ }
+ *opts = 0;
+ }
+ else {
+ rtrn->error= XkbCF_MissingEquals;
+ goto BAILOUT;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok==XkbCF_EOL)||(tok==XkbCF_Semi)||(tok==XkbCF_EOF)) {
+ rtrn->error= XkbCF_ExpectedControl;
+ return False;
+ }
+ while ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) {
+ if ((tok!=XkbCF_Ident)&&(tok!=XkbCF_String)) {
+ rtrn->error= XkbCF_ExpectedControl;
+ return False;
+ }
+ if (!AddAXTimeoutOptByName(rtrn,val.str,&opts_mask))
+ return False;
+ *opts |= opts_mask;
+
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_EOF)&&(tok!=XkbCF_Semi)) {
+ if (tok!=XkbCF_Plus) {
+ rtrn->error= XkbCF_ExpectedOperator;
+ return False;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ }
+ }
+ break;
+ case _XkbCF_ClickVolume:
+ if (!pival) {
+ pival= &rtrn->click_volume;
+ onoff= 100;
+ }
+ case _XkbCF_BellVolume:
+ if (!pival) {
+ pival= &rtrn->bell_volume;
+ onoff= 100;
+ }
+ case _XkbCF_BellPitch:
+ if (!pival)
+ pival= &rtrn->bell_pitch;
+ case _XkbCF_BellDuration:
+ if (!pival)
+ pival= &rtrn->bell_duration;
+ case _XkbCF_RepeatDelay:
+ if (!pival)
+ pival= &rtrn->repeat_delay;
+ case _XkbCF_RepeatInterval:
+ if (!pival)
+ pival= &rtrn->repeat_interval;
+ case _XkbCF_SlowKeysDelay:
+ if (!pival)
+ pival= &rtrn->slow_keys_delay;
+ case _XkbCF_DebounceDelay:
+ if (!pival)
+ pival= &rtrn->debounce_delay;
+ case _XkbCF_MouseKeysDelay:
+ if (!pival)
+ pival= &rtrn->mk_delay;
+ case _XkbCF_MouseKeysInterval:
+ if (!pival)
+ pival= &rtrn->mk_interval;
+ case _XkbCF_MouseKeysTimeToMax:
+ if (!pival)
+ pival= &rtrn->mk_time_to_max;
+ case _XkbCF_MouseKeysMaxSpeed:
+ if (!pival)
+ pival= &rtrn->mk_max_speed;
+ case _XkbCF_MouseKeysCurve:
+ if (!pival)
+ pival= &rtrn->mk_curve;
+ case _XkbCF_AccessXTimeout:
+ if (!pival)
+ pival= &rtrn->ax_timeout;
+ if (tok!=XkbCF_Equals) {
+ rtrn->error= XkbCF_MissingEquals;
+ goto BAILOUT;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ if (tok == XkbCF_Minus && field->field_id == _XkbCF_MouseKeysCurve) {
+ /* This can be a negative value */
+ tok = XkbCFScan(file,&val,rtrn);
+ sign = -1;
+ }
+ else
+ sign = 1;
+ if (tok!=XkbCF_Integer) {
+ Bool ok= False;
+ if ((onoff)&&(tok==XkbCF_Ident)&&(val.str!=NULL)) {
+ if (_XkbStrCaseCmp(val.str,"on")) {
+ val.ival= onoff;
+ ok= True;
+ }
+ else if (_XkbStrCaseCmp(val.str,"off")) {
+ val.ival= 0;
+ ok= True;
+ }
+ }
+ if (!ok) {
+ rtrn->error= XkbCF_ExpectedInteger;
+ goto BAILOUT;
+ }
+ }
+ *pival= val.ival * sign;
+ if (field->field_id == _XkbCF_AccessXTimeout)
+ rtrn->defined|=XkbCF_AccessXTimeout;
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) {
+ rtrn->error= XkbCF_ExpectedEOS;
+ return False;
+ }
+ break;
+ case _XkbCF_GroupsWrap:
+ if (tok!=XkbCF_Equals) {
+ rtrn->error= XkbCF_MissingEquals;
+ goto BAILOUT;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ if (tok==XkbCF_Ident) {
+ if (_XkbStrCaseCmp(val.str,"wrap")==0) {
+ rtrn->groups_wrap= XkbSetGroupInfo(0,XkbWrapIntoRange,0);
+ }
+ else if (_XkbStrCaseCmp(val.str,"clamp")==0) {
+ rtrn->groups_wrap= XkbSetGroupInfo(0,XkbClampIntoRange,0);
+ }
+ else {
+ rtrn->error= XkbCF_ExpectedOORGroupBehavior;
+ return False;
+ }
+ }
+ else if ((tok==XkbCF_Integer)&&(XkbIsLegalGroup(val.ival-1))) {
+ rtrn->groups_wrap= XkbSetGroupInfo(0,XkbRedirectIntoRange,
+ val.ival-1);
+ }
+ else {
+ rtrn->error= XkbCF_ExpectedOORGroupBehavior;
+ return False;
+ }
+ rtrn->defined|= XkbCF_GroupsWrap;
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) {
+ rtrn->error= XkbCF_ExpectedEOS;
+ return False;
+ }
+ break;
+ default:
+ rtrn->error= XkbCF_ExpectedInteger;
+ goto BAILOUT;
+
+ }
+ return True;
+BAILOUT:
+ return False;
+}
+
+static Bool
+DefaultCleanUp(XkbConfigRtrnPtr rtrn)
+{
+ if (rtrn->keymap) _XkbFree(rtrn->keymap);
+ if (rtrn->keycodes) _XkbFree(rtrn->keycodes);
+ if (rtrn->geometry) _XkbFree(rtrn->geometry);
+ if (rtrn->phys_symbols) _XkbFree(rtrn->phys_symbols);
+ if (rtrn->symbols) _XkbFree(rtrn->symbols);
+ if (rtrn->types) _XkbFree(rtrn->types);
+ if (rtrn->compat) _XkbFree(rtrn->compat);
+ rtrn->keycodes= rtrn->geometry= NULL;
+ rtrn->symbols= rtrn->phys_symbols= NULL;
+ rtrn->types= rtrn->compat= NULL;
+ if ((rtrn->unbound_mods!=NULL)&&(rtrn->num_unbound_mods>0)) {
+ register int i;
+ for (i=0;i<rtrn->num_unbound_mods;i++) {
+ if (rtrn->unbound_mods[i].name!=NULL) {
+ _XkbFree(rtrn->unbound_mods[i].name);
+ rtrn->unbound_mods[i].name= NULL;
+ }
+ }
+ _XkbFree(rtrn->unbound_mods);
+ rtrn->sz_unbound_mods= 0;
+ rtrn->num_unbound_mods= 0;
+ rtrn->unbound_mods= NULL;
+ }
+ return True;
+}
+
+static Bool
+DefaultApplyNames(XkbConfigRtrnPtr rtrn,XkbDescPtr xkb)
+{
+char *str;
+
+ if (XkbAllocNames(xkb,XkbComponentNamesMask,0,0)!=Success)
+ return False;
+ if ((str=rtrn->keycodes)!=NULL) {
+ xkb->names->keycodes= XkbInternAtom(xkb->dpy,str,False);
+ _XkbFree(str);
+ rtrn->keycodes= NULL;
+ }
+ if ((str=rtrn->geometry)!=NULL) {
+ xkb->names->geometry= XkbInternAtom(xkb->dpy,str,False);
+ _XkbFree(str);
+ rtrn->geometry= NULL;
+ }
+ if ((str=rtrn->symbols)!=NULL) {
+ xkb->names->symbols= XkbInternAtom(xkb->dpy,str,False);
+ _XkbFree(str);
+ rtrn->symbols= NULL;
+ }
+ if ((str=rtrn->phys_symbols)!=NULL) {
+ xkb->names->phys_symbols= XkbInternAtom(xkb->dpy,str,False);
+ _XkbFree(str);
+ rtrn->phys_symbols= NULL;
+ }
+ if ((str=rtrn->types)!=NULL) {
+ xkb->names->types= XkbInternAtom(xkb->dpy,str,False);
+ _XkbFree(str);
+ rtrn->types= NULL;
+ }
+ if ((str=rtrn->compat)!=NULL) {
+ xkb->names->compat= XkbInternAtom(xkb->dpy,str,False);
+ _XkbFree(str);
+ rtrn->compat= NULL;
+ }
+ return True;
+}
+
+static Bool
+DefaultApplyControls(XkbConfigRtrnPtr rtrn,XkbDescPtr xkb)
+{
+unsigned on,off;
+XkbControlsPtr ctrls;
+unsigned int mask;
+
+ if (XkbAllocControls(xkb,XkbAllControlsMask)!=Success)
+ return False;
+ ctrls= xkb->ctrls;
+ if (rtrn->replace_initial_ctrls)
+ ctrls->enabled_ctrls= rtrn->initial_ctrls;
+ else ctrls->enabled_ctrls|= rtrn->initial_ctrls;
+ ctrls->enabled_ctrls&= ~rtrn->initial_ctrls_clear;
+ if (rtrn->internal_mods.replace) {
+ ctrls->internal.real_mods= rtrn->internal_mods.mods;
+ ctrls->internal.vmods= rtrn->internal_mods.vmods;
+ }
+ else {
+ ctrls->internal.real_mods&= ~rtrn->internal_mods.mods_clear;
+ ctrls->internal.vmods&= ~rtrn->internal_mods.vmods_clear;
+ ctrls->internal.real_mods|= rtrn->internal_mods.mods;
+ ctrls->internal.vmods|= rtrn->internal_mods.vmods;
+ }
+ mask= 0;
+ (void)XkbVirtualModsToReal(xkb,ctrls->internal.vmods,&mask);
+ ctrls->internal.mask= (ctrls->internal.real_mods|mask);
+
+ if (rtrn->ignore_lock_mods.replace) {
+ ctrls->ignore_lock.real_mods= rtrn->ignore_lock_mods.mods;
+ ctrls->ignore_lock.vmods= rtrn->ignore_lock_mods.vmods;
+ }
+ else {
+ ctrls->ignore_lock.real_mods&= ~rtrn->ignore_lock_mods.mods_clear;
+ ctrls->ignore_lock.vmods&= ~rtrn->ignore_lock_mods.vmods_clear;
+ ctrls->ignore_lock.real_mods|= rtrn->ignore_lock_mods.mods;
+ ctrls->ignore_lock.vmods|= rtrn->ignore_lock_mods.vmods;
+ }
+ mask= 0;
+ (void)XkbVirtualModsToReal(xkb,ctrls->ignore_lock.vmods,&mask);
+ ctrls->ignore_lock.mask= (ctrls->ignore_lock.real_mods|mask);
+
+ if (rtrn->repeat_delay>0)
+ ctrls->repeat_delay= rtrn->repeat_delay;
+ if (rtrn->repeat_interval>0)
+ ctrls->repeat_interval= rtrn->repeat_interval;
+ if (rtrn->slow_keys_delay>0)
+ ctrls->slow_keys_delay= rtrn->slow_keys_delay;
+ if (rtrn->debounce_delay>0)
+ ctrls->debounce_delay= rtrn->debounce_delay;
+ if (rtrn->mk_delay>0)
+ ctrls->mk_delay= rtrn->mk_delay;
+ if (rtrn->mk_interval>0)
+ ctrls->mk_interval= rtrn->mk_interval;
+ if (rtrn->mk_time_to_max>0)
+ ctrls->mk_time_to_max= rtrn->mk_time_to_max;
+ if (rtrn->mk_max_speed>0)
+ ctrls->mk_max_speed= rtrn->mk_max_speed;
+ if (rtrn->mk_curve>0)
+ ctrls->mk_curve= rtrn->mk_curve;
+ if (rtrn->defined&XkbCF_AccessXTimeout && rtrn->ax_timeout > 0)
+ ctrls->ax_timeout= rtrn->ax_timeout;
+
+ /* any value set to both off and on is reset to ignore */
+ if ((off=(rtrn->axt_ctrls_on&rtrn->axt_ctrls_off))!=0)
+ rtrn->axt_ctrls_ignore|= off;
+
+ /* ignore takes priority over on and off */
+ rtrn->axt_ctrls_on&= ~rtrn->axt_ctrls_ignore;
+ rtrn->axt_ctrls_off&= ~rtrn->axt_ctrls_ignore;
+
+ if (!rtrn->replace_axt_ctrls_off) {
+ off= (ctrls->axt_ctrls_mask&(~ctrls->axt_ctrls_values));
+ off&= ~rtrn->axt_ctrls_on;
+ off|= rtrn->axt_ctrls_off;
+ }
+ else off= rtrn->axt_ctrls_off;
+ if (!rtrn->replace_axt_ctrls_on) {
+ on= (ctrls->axt_ctrls_mask&ctrls->axt_ctrls_values);
+ on&= ~rtrn->axt_ctrls_off;
+ on|= rtrn->axt_ctrls_on;
+ }
+ else on= rtrn->axt_ctrls_on;
+ ctrls->axt_ctrls_mask= (on|off)&~rtrn->axt_ctrls_ignore;
+ ctrls->axt_ctrls_values= on&~rtrn->axt_ctrls_ignore;
+
+ /* any value set to both off and on is reset to ignore */
+ if ((off=(rtrn->axt_opts_on&rtrn->axt_opts_off))!=0)
+ rtrn->axt_opts_ignore|= off;
+
+ /* ignore takes priority over on and off */
+ rtrn->axt_opts_on&= ~rtrn->axt_opts_ignore;
+ rtrn->axt_opts_off&= ~rtrn->axt_opts_ignore;
+
+ if (rtrn->replace_axt_opts_off) {
+ off= (ctrls->axt_opts_mask&(~ctrls->axt_opts_values));
+ off&= ~rtrn->axt_opts_on;
+ off|= rtrn->axt_opts_off;
+ }
+ else off= rtrn->axt_opts_off;
+ if (!rtrn->replace_axt_opts_on) {
+ on= (ctrls->axt_opts_mask&ctrls->axt_opts_values);
+ on&= ~rtrn->axt_opts_off;
+ on|= rtrn->axt_opts_on;
+ }
+ else on= rtrn->axt_opts_on;
+ ctrls->axt_opts_mask= (unsigned short)((on|off)&~rtrn->axt_ctrls_ignore);
+ ctrls->axt_opts_values= (unsigned short)(on&~rtrn->axt_ctrls_ignore);
+
+ if (rtrn->defined&XkbCF_GroupsWrap) {
+ int n;
+ n= XkbNumGroups(ctrls->groups_wrap);
+ rtrn->groups_wrap= XkbSetNumGroups(rtrn->groups_wrap,n);
+ ctrls->groups_wrap= rtrn->groups_wrap;
+ }
+ return True;
+}
+
+/*ARGSUSED*/
+static Bool
+DefaultFinish( XkbConfigFieldsPtr fields,
+ XkbDescPtr xkb,
+ XkbConfigRtrnPtr rtrn,
+ int what)
+{
+ if ((what==XkbCF_Destroy)||(what==XkbCF_CleanUp))
+ return DefaultCleanUp(rtrn);
+ if (what==XkbCF_Check) {
+ if ((rtrn->symbols==NULL)&&(rtrn->phys_symbols!=NULL))
+ rtrn->symbols= _XkbDupString(rtrn->phys_symbols);
+ }
+ if ((what==XkbCF_Apply)||(what==XkbCF_Check)) {
+ if (xkb && xkb->names && (rtrn->num_unbound_mods>0))
+ XkbCFBindMods(rtrn,xkb);
+ XkbCFApplyMods(rtrn,XkbCF_InitialMods,&rtrn->initial_mods);
+ XkbCFApplyMods(rtrn,XkbCF_InternalMods,&rtrn->internal_mods);
+ XkbCFApplyMods(rtrn,XkbCF_IgnoreLockMods,&rtrn->ignore_lock_mods);
+ }
+ if (what==XkbCF_Apply) {
+ if (xkb!=NULL) {
+ DefaultApplyNames(rtrn,xkb);
+ DefaultApplyControls(rtrn,xkb);
+ XkbCFBindMods(rtrn,xkb);
+ }
+ }
+ return True;
+}
+
+static XkbConfigFieldRec _XkbCFDfltFields[] = {
+ { "rules", _XkbCF_RulesFile },
+ { "model", _XkbCF_Model },
+ { "layout", _XkbCF_Layout },
+ { "variant", _XkbCF_Variant },
+ { "options", _XkbCF_Options },
+ { "keymap", _XkbCF_Keymap },
+ { "keycodes", _XkbCF_Keycodes },
+ { "geometry", _XkbCF_Geometry },
+ { "realsymbols",_XkbCF_PhysSymbols },
+ { "actualsymbols",_XkbCF_PhysSymbols },
+ { "symbols", _XkbCF_Symbols },
+ { "symbolstouse",_XkbCF_Symbols },
+ { "types", _XkbCF_Types },
+ { "compat", _XkbCF_CompatMap },
+ { "modifiers", _XkbCF_InitialMods },
+ { "controls", _XkbCF_InitialCtrls },
+ { "click", _XkbCF_ClickVolume },
+ { "clickvolume",_XkbCF_ClickVolume },
+ { "bell", _XkbCF_BellVolume },
+ { "bellvolume", _XkbCF_BellVolume },
+ { "bellpitch", _XkbCF_BellPitch },
+ { "bellduration",_XkbCF_BellDuration },
+ { "repeatdelay",_XkbCF_RepeatDelay },
+ { "repeatinterval",_XkbCF_RepeatInterval },
+ { "slowkeysdelay",_XkbCF_SlowKeysDelay },
+ { "debouncedelay",_XkbCF_DebounceDelay },
+ { "mousekeysdelay",_XkbCF_MouseKeysDelay },
+ { "mousekeysinterval",_XkbCF_MouseKeysInterval },
+ { "mousekeystimetomax",_XkbCF_MouseKeysTimeToMax },
+ { "mousekeysmaxspeed",_XkbCF_MouseKeysMaxSpeed },
+ { "mousekeyscurve",_XkbCF_MouseKeysCurve },
+ { "accessxtimeout",_XkbCF_AccessXTimeout },
+ { "axtimeout",_XkbCF_AccessXTimeout },
+ { "accessxtimeoutctrlson",_XkbCF_AccessXTimeoutCtrlsOn },
+ { "axtctrlson", _XkbCF_AccessXTimeoutCtrlsOn },
+ { "accessxtimeoutctrlsoff",_XkbCF_AccessXTimeoutCtrlsOff },
+ { "axtctrlsoff",_XkbCF_AccessXTimeoutCtrlsOff },
+ { "accessxtimeoutfeedbackon", _XkbCF_AccessXTimeoutOptsOn },
+ { "axtfeedbackon", _XkbCF_AccessXTimeoutOptsOn },
+ { "accessxtimeoutfeedbackoff", _XkbCF_AccessXTimeoutOptsOff },
+ { "axtfeedbackoff", _XkbCF_AccessXTimeoutOptsOff },
+ { "ignorelockmods",_XkbCF_IgnoreLockMods },
+ { "ignorelockmodifiers",_XkbCF_IgnoreLockMods },
+ { "ignoregrouplock",_XkbCF_IgnoreGroupLock },
+ { "internalmods",_XkbCF_InternalMods },
+ { "internalmodifiers",_XkbCF_InternalMods },
+ { "outofrangegroups",_XkbCF_GroupsWrap },
+ { "groups", _XkbCF_GroupsWrap },
+ { "feedback", _XkbCF_InitialFeedback },
+};
+#define _XkbCFNumDfltFields (sizeof(_XkbCFDfltFields)/sizeof(XkbConfigFieldRec))
+
+static XkbConfigFieldsRec _XkbCFDflts = {
+ 0, /* cfg_id */
+ _XkbCFNumDfltFields, /* num_fields */
+ _XkbCFDfltFields, /* fields */
+ DefaultParser, /* parser */
+ DefaultFinish, /* finish */
+ NULL, /* priv */
+ NULL /* next */
+};
+
+XkbConfigFieldsPtr XkbCFDflts= &_XkbCFDflts;
+
+/***====================================================================***/
+
+XkbConfigFieldsPtr
+XkbCFDup(XkbConfigFieldsPtr fields)
+{
+XkbConfigFieldsPtr pNew;
+
+ pNew= _XkbTypedAlloc(XkbConfigFieldsRec);
+ if (pNew!=NULL) {
+ memcpy(pNew,fields,sizeof(XkbConfigFieldsRec));
+ if ((pNew->fields!=NULL)&&(pNew->num_fields>0)) {
+ pNew->fields= _XkbTypedCalloc(pNew->num_fields,XkbConfigFieldRec);
+ if (pNew->fields) {
+ memcpy(fields->fields,pNew->fields,
+ (pNew->num_fields*sizeof(XkbConfigFieldRec)));
+ }
+ else {
+ _XkbFree(pNew);
+ return NULL;
+ }
+ }
+ else {
+ pNew->num_fields= 0;
+ pNew->fields= NULL;
+ }
+ pNew->next= NULL;
+ }
+ return pNew;
+}
+
+XkbConfigFieldsPtr
+XkbCFFree(XkbConfigFieldsPtr fields,Bool all)
+{
+XkbConfigFieldsPtr next;
+
+ next= NULL;
+ while (fields!=NULL) {
+ next= fields->next;
+ if (fields!=XkbCFDflts) {
+ if (fields->fields) {
+ _XkbFree(fields->fields);
+ fields->fields= NULL;
+ fields->num_fields= 0;
+ }
+ _XkbFree(fields);
+ }
+ fields= (all?next:NULL);
+ }
+ return next;
+}
+
+Bool
+XkbCFApplyRtrnValues( XkbConfigRtrnPtr rtrn,
+ XkbConfigFieldsPtr fields,
+ XkbDescPtr xkb)
+{
+Bool ok;
+
+ if ((fields==NULL)||(rtrn==NULL)||(xkb==NULL))
+ return False;
+ for (ok=True;fields!=NULL;fields=fields->next) {
+ if (fields->finish!=NULL)
+ ok= (*fields->finish)(fields,xkb,rtrn,XkbCF_Apply)&&ok;
+ }
+ return ok;
+}
+
+XkbConfigRtrnPrivPtr
+XkbCFAddPrivate( XkbConfigRtrnPtr rtrn,
+ XkbConfigFieldsPtr fields,
+ XPointer ptr)
+{
+XkbConfigRtrnPrivPtr priv;
+
+ if ((rtrn==NULL)||(fields==NULL))
+ return NULL;
+ priv= _XkbTypedAlloc(XkbConfigRtrnPrivRec);
+ if (priv!=NULL) {
+ priv->cfg_id= fields->cfg_id;
+ priv->priv= ptr;
+ priv->next= rtrn->priv;
+ rtrn->priv= priv;
+ }
+ return priv;
+}
+
+void
+XkbCFFreeRtrn( XkbConfigRtrnPtr rtrn,
+ XkbConfigFieldsPtr fields,
+ XkbDescPtr xkb)
+{
+XkbConfigRtrnPrivPtr tmp,next;
+
+ if ((fields==NULL)||(rtrn==NULL))
+ return;
+ while (fields!=NULL) {
+ if (fields->finish!=NULL)
+ (*fields->finish)(fields,xkb,rtrn,XkbCF_Destroy);
+ fields= fields->next;
+ }
+ for (tmp=rtrn->priv;tmp!=NULL;tmp=next) {
+ next= tmp->next;
+ bzero((char *)tmp,sizeof(XkbConfigRtrnPrivRec));
+ _XkbFree(tmp);
+ }
+ bzero((char *)rtrn,sizeof(XkbConfigRtrnRec));
+ return;
+}
+
+Bool
+XkbCFParse( FILE * file,
+ XkbConfigFieldsPtr fields,
+ XkbDescPtr xkb,
+ XkbConfigRtrnPtr rtrn)
+{
+int tok;
+XkbCFScanResultRec val;
+XkbConfigFieldsPtr tmp;
+
+ if ((file==NULL)||(fields==NULL)||(rtrn==NULL))
+ return False;
+ for (tok=0,tmp=fields;tmp!=NULL;tmp=tmp->next,tok++) {
+ fields->cfg_id= tok;
+ }
+ bzero((char *)rtrn,sizeof(XkbConfigRtrnRec));
+ rtrn->line= 1;
+ rtrn->click_volume= -1;
+ rtrn->bell_volume= -1;
+ while ((tok=XkbCFScan(file,&val,rtrn))!=XkbCF_EOF) {
+ if (tok==XkbCF_Ident) {
+ Bool done;
+ for (tmp=fields,done=False;(tmp!=NULL)&&(!done);tmp=tmp->next) {
+ register int i;
+ XkbConfigFieldPtr f;
+
+ for (i=0,f=tmp->fields;(i<tmp->num_fields)&&(!done);i++,f++) {
+ if (_XkbStrCaseCmp(val.str,f->field)!=0)
+ continue;
+ if ((*tmp->parser)(file,tmp,f,xkb,rtrn))
+ done= True;
+ else goto BAILOUT;
+ }
+ }
+ }
+ else if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)) {
+ rtrn->error= XkbCF_MissingIdent;
+ goto BAILOUT;
+ }
+ }
+ for (tmp=fields;tmp!=NULL;tmp=tmp->next) {
+ if ((tmp->finish)&&(!(*tmp->finish)(tmp,xkb,rtrn,XkbCF_Check)))
+ goto BAILOUT;
+ }
+ return True;
+BAILOUT:
+ for (tmp=fields;tmp!=NULL;tmp=tmp->next) {
+ if (tmp->finish)
+ (*tmp->finish)(tmp,xkb,rtrn,XkbCF_CleanUp);
+ }
+ return False;
+}
+
+/*ARGSUSED*/
+void
+XkbCFReportError(FILE *file,char *name,int error,int line)
+{
+char * msg;
+
+ switch(error) {
+ case XkbCF_BadAlloc:
+ msg= "allocation failed\n"; break;
+ case XkbCF_UnterminatedString:
+ msg= "unterminated string on line %d"; break;
+ case XkbCF_MissingIdent:
+ msg= "expected identifier on line %d"; break;
+ case XkbCF_MissingEquals:
+ msg= "expected '=' on line %d"; break;
+ case XkbCF_ExpectedEOS:
+ msg= "expected ';' or newline on line %d"; break;
+ case XkbCF_ExpectedBoolean:
+ msg= "expected a boolean value on line %d"; break;
+ case XkbCF_ExpectedInteger:
+ msg= "expected a numeric value on line %d"; break;
+ case XkbCF_ExpectedString:
+ msg= "expected a string on line %d"; break;
+ case XkbCF_ExpectedModifier:
+ msg= "expected a modifier name on line %d"; break;
+ case XkbCF_ExpectedControl:
+ msg= "expected a control name on line %d"; break;
+ case XkbCF_ExpectedAXOption:
+ msg= "expected an AccessX option on line %d"; break;
+ case XkbCF_ExpectedOperator:
+ msg= "expected '+' or '-' on line %d"; break;
+ case XkbCF_ExpectedOORGroupBehavior:
+ msg= "expected wrap, clamp or group number on line %d"; break;
+ default:
+ msg= "unknown error on line %d"; break;
+ }
+#ifndef XKB_IN_SERVER
+ fprintf(file,msg,line);
+ if (name) fprintf(file," of %s\n",name);
+ else fprintf(file,"\n");
+#else
+ ErrorF(msg,line);
+ if (name) ErrorF(" of %s\n",name);
+ else ErrorF("\n");
+#endif
+ return;
+}
diff --git a/nx-X11/lib/xkbfile/xkbdraw.c b/nx-X11/lib/xkbfile/xkbdraw.c
new file mode 100644
index 000000000..c955f0321
--- /dev/null
+++ b/nx-X11/lib/xkbfile/xkbdraw.c
@@ -0,0 +1,135 @@
+/* $Xorg: xkbdraw.c,v 1.3 2000/08/17 19:46:43 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkbdraw.c,v 1.3 2001/07/29 05:01:13 tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKBgeom.h>
+#include "XKMformat.h"
+#include "XKBfileInt.h"
+
+static void
+_XkbAddDrawable(XkbDrawablePtr *pfirst,XkbDrawablePtr *plast,XkbDrawablePtr tmp)
+{
+XkbDrawablePtr old;
+
+ if (*pfirst==NULL) {
+ *pfirst= *plast= tmp;
+ }
+ else if (tmp->priority>=(*plast)->priority) {
+ (*plast)->next= tmp;
+ *plast= tmp;
+ }
+ else if (tmp->priority<(*pfirst)->priority) {
+ tmp->next= (*pfirst);
+ (*pfirst)= tmp;
+ }
+ else {
+ old= *pfirst;
+ while ((old->next)&&(old->next->priority<=tmp->priority)) {
+ old= old->next;
+ }
+ tmp->next= old->next;
+ old->next= tmp;
+ }
+ return;
+}
+
+XkbDrawablePtr
+XkbGetOrderedDrawables(XkbGeometryPtr geom,XkbSectionPtr section)
+{
+XkbDrawablePtr first,last,tmp;
+int i;
+
+ first= last= NULL;
+ if (geom!=NULL) {
+ XkbSectionPtr section;
+ XkbDoodadPtr doodad;
+ for (i=0,section=geom->sections;i<geom->num_sections;i++,section++) {
+ tmp= _XkbTypedCalloc(1,XkbDrawableRec);
+ if (!tmp) {
+ XkbFreeOrderedDrawables(first);
+ return NULL;
+ }
+ tmp->type= XkbDW_Section;
+ tmp->priority= section->priority;
+ tmp->u.section= section;
+ tmp->next= NULL;
+ _XkbAddDrawable(&first,&last,tmp);
+ }
+ for (i=0,doodad=geom->doodads;i<geom->num_doodads;i++,doodad++) {
+ tmp= _XkbTypedCalloc(1,XkbDrawableRec);
+ if (!tmp) {
+ XkbFreeOrderedDrawables(first);
+ return NULL;
+ }
+ tmp->type= XkbDW_Doodad;
+ tmp->priority= doodad->any.priority;
+ tmp->u.doodad= doodad;
+ tmp->next= NULL;
+ _XkbAddDrawable(&first,&last,tmp);
+ }
+ }
+ if (section!=NULL) {
+ XkbDoodadPtr doodad;
+ for (i=0,doodad=section->doodads;i<section->num_doodads;i++,doodad++) {
+ tmp= _XkbTypedCalloc(1,XkbDrawableRec);
+ if (!tmp) {
+ XkbFreeOrderedDrawables(first);
+ return NULL;
+ }
+ tmp->type= XkbDW_Doodad;
+ tmp->priority= doodad->any.priority;
+ tmp->u.doodad= doodad;
+ tmp->next= NULL;
+ _XkbAddDrawable(&first,&last,tmp);
+ }
+ }
+ return first;
+}
+
+void
+XkbFreeOrderedDrawables(XkbDrawablePtr draw)
+{
+XkbDrawablePtr tmp;
+
+ for (;draw!=NULL;draw=tmp) {
+ tmp= draw->next;
+ _XkbFree(draw);
+ }
+ return;
+}
diff --git a/nx-X11/lib/xkbfile/xkberrs.c b/nx-X11/lib/xkbfile/xkberrs.c
new file mode 100644
index 000000000..1b856bcaf
--- /dev/null
+++ b/nx-X11/lib/xkbfile/xkberrs.c
@@ -0,0 +1,72 @@
+/* $Xorg: xkberrs.c,v 1.3 2000/08/17 19:46:44 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkberrs.c,v 3.4 2001/07/29 05:01:13 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#elif defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+char * _XkbErrMessages[] = {
+ "success", /* _XkbSuccess */
+ "key names not defined", /* _XkbErrMissingNames */
+ "key types not defined", /* _XkbErrMissingTypes */
+ "required key types not present", /* _XkbErrMissingReqTypes */
+ "symbols not defined", /* _XkbErrMissingSymbols */
+ "virtual modifier bindings not defined",/* _XkbErrMissingVMods */
+ "indicators not defined", /* _XkbErrMissingIndicators */
+ "compatibility map not defined", /* _XkbErrMissingCompatMap */
+ "symbol interpretations not defined", /* _XkbErrMissingSymInterps */
+ "geometry not defined", /* _XkbErrMissingGeometry */
+ "illegal doodad type", /* _XkbErrIllegalDoodad */
+ "illegal TOC type", /* _XkbErrIllegalTOCType */
+ "illegal contents", /* _XkbErrIllegalContents */
+ "empty file", /* _XkbErrEmptyFile */
+ "file not found", /* _XkbErrFileNotFound */
+ "cannot open", /* _XkbErrFileCannotOpen */
+ "bad value", /* _XkbErrBadValue */
+ "bad match", /* _XkbErrBadMatch */
+ "illegal name for type", /* _XkbErrBadTypeName */
+ "illegal width for type", /* _XkbErrBadTypeWidth */
+ "bad file type", /* _XkbErrBadFileType */
+ "bad file version", /* _XkbErrBadFileVersion */
+ "error in Xkm file", /* _XkbErrBadFileFormat */
+ "allocation failed", /* _XkbErrBadAlloc */
+ "bad length", /* _XkbErrBadLength */
+ "X request failed", /* _XkbErrXReqFailure */
+ "not implemented" /* _XkbErrBadImplementation */
+};
+
+unsigned _XkbErrCode;
+char * _XkbErrLocation= NULL;
+unsigned _XkbErrData;
+
diff --git a/nx-X11/lib/xkbfile/xkbfile-def.cpp b/nx-X11/lib/xkbfile/xkbfile-def.cpp
new file mode 100644
index 000000000..2351d6666
--- /dev/null
+++ b/nx-X11/lib/xkbfile/xkbfile-def.cpp
@@ -0,0 +1,97 @@
+LIBRARY xkbfile
+VERSION LIBRARY_VERSION
+EXPORTS
+ XkbAccessXDetailText
+ XkbActionText
+ XkbActionTypeText
+ XkbAtomGetString
+ XkbAtomText
+ XkbBehaviorText
+ XkbCFAddModByName
+ XkbCFAddPrivate
+ XkbCFApplyMods
+ XkbCFApplyRtrnValues
+ XkbCFBindMods
+ XkbCFDup
+ XkbCFFree
+ XkbCFFreeRtrn
+ XkbCFParse
+ XkbCFReportError
+ XkbCFScan
+ XkbChangeAtomDisplay
+ XkbChangeKbdDisplay
+ XkbConfigText
+ XkbControlsMaskText
+ XkbConvertGetByNameComponents
+ XkbConvertXkbComponents
+ XkbDetermineFileType
+ XkbDoodadTypeText
+ XkbEnsureSafeMapName
+ XkbFindKeycodeByName
+ XkbFreeOrderedDrawables
+ XkbGeomFPText
+ XkbGetOrderedDrawables
+ XkbIMWhichStateMaskText
+ XkbIndentText
+ XkbInitAtoms
+ XkbInternAtom
+ XkbKeyNameText
+ XkbKeysymText
+ XkbLookupCanonicalRGBColor
+ XkbLookupGroupAndLevel
+ XkbMergeFile
+ XkbModIndexText
+ XkbModMaskText
+ XkbNKNDetailMaskText
+ XkbNameMatchesPattern
+ XkbRF_AddGroup
+ XkbRF_AddRule
+ XkbRF_AddVarDesc
+ XkbRF_AddVarDescCopy
+ XkbRF_AddVarToDescribe
+ XkbRF_Create
+ XkbRF_Free
+ XkbRF_GetComponents
+ XkbRF_GetNamesProp
+ XkbRF_Load
+ XkbRF_LoadDescriptions
+ XkbRF_LoadDescriptionsByName
+ XkbRF_LoadRules
+ XkbRF_LoadRulesByName
+ XkbRF_SetNamesProp
+ XkbReadFromServer
+ XkbSIMatchText
+ XkbStdBell
+ XkbStdBellEvent
+ XkbStringText
+ XkbVModIndexText
+ XkbVModMaskText
+ XkbWriteCFile
+ XkbWriteToServer
+ XkbWriteXKBCompatMap
+ XkbWriteXKBFile
+ XkbWriteXKBGeometry
+ XkbWriteXKBKeyTypes
+ XkbWriteXKBKeycodes
+ XkbWriteXKBKeymap
+ XkbWriteXKBKeymapForNames
+ XkbWriteXKBLayout
+ XkbWriteXKBSemantics
+ XkbWriteXKBSymbols
+ XkbWriteXKMFile
+ XkmFindTOCEntry
+ XkmProbe
+ XkmReadFile
+ XkmReadFileSection
+ XkmReadFileSectionName
+ XkmReadTOC
+#ifdef __UNIXOS2__
+ _XkbStrCaseCmp
+ XkbCFDflts
+ _XkbErrLocation
+ _XkbErrCode
+ _XkbErrMessages
+ _XkbKSCheckCase
+#endif
+
+/* $XFree86: xc/lib/xkbfile/xkbfile-def.cpp,v 1.1 2003/10/15 21:18:50 herrb Exp $ */
diff --git a/nx-X11/lib/xkbfile/xkbmisc.c b/nx-X11/lib/xkbfile/xkbmisc.c
new file mode 100644
index 000000000..cca31f778
--- /dev/null
+++ b/nx-X11/lib/xkbfile/xkbmisc.c
@@ -0,0 +1,689 @@
+/* $Xorg: xkbmisc.c,v 1.4 2000/08/17 19:46:44 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkbmisc.c,v 1.7 2003/07/16 02:31:10 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#elif defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+
+#ifndef XKB_IN_SERVER
+
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKBgeom.h>
+#include "XKMformat.h"
+#include "XKBfileInt.h"
+
+#else
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#include <X11/keysym.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include "dix.h"
+#include <X11/extensions/XKBstr.h>
+#define XKBSRV_NEED_FILE_FUNCS 1
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XKBgeom.h>
+#include "xkb.h"
+
+#endif
+
+unsigned
+_XkbKSCheckCase(KeySym ks)
+{
+unsigned set,rtrn;
+
+ set= (ks & (~0xff)) >> 8;
+ rtrn= 0;
+ switch (set) {
+ case 0: /* latin 1 */
+ if (((ks>=XK_A)&&(ks<=XK_Z))||
+ ((ks>=XK_Agrave)&&(ks<=XK_THORN)&&(ks!=XK_multiply))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_a)&&(ks<=XK_z))||
+ ((ks>=XK_agrave)&&(ks<=XK_ydiaeresis))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 1: /* latin 2 */
+ if (((ks>=XK_Aogonek)&&(ks<=XK_Zabovedot)&&(ks!=XK_breve))||
+ ((ks>=XK_Racute)&&(ks<=XK_Tcedilla))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_aogonek)&&(ks<=XK_zabovedot)&&(ks!=XK_caron))||
+ ((ks>=XK_racute)&&(ks<=XK_tcedilla))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 2: /* latin 3 */
+ if (((ks>=XK_Hstroke)&&(ks<=XK_Jcircumflex))||
+ ((ks>=XK_Cabovedot)&&(ks<=XK_Scircumflex))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_hstroke)&&(ks<=XK_jcircumflex))||
+ ((ks>=XK_cabovedot)&&(ks<=XK_scircumflex))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 3: /* latin 4 */
+ if (((ks>=XK_Rcedilla)&&(ks<=XK_Tslash))||
+ (ks==XK_ENG)||
+ ((ks>=XK_Amacron)&&(ks<=XK_Umacron))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_rcedilla)&&(ks<=XK_tslash))||
+ (ks==XK_eng)||
+ ((ks>=XK_amacron)&&(ks<=XK_umacron))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 18: /* latin 8 */
+ if ((ks==XK_Babovedot)||
+ ((ks>=XK_Dabovedot)&&(ks<=XK_Wacute))||
+ ((ks>=XK_Ygrave)&&(ks<=XK_Fabovedot))||
+ (ks==XK_Mabovedot)||
+ (ks==XK_Pabovedot)||
+ (ks==XK_Sabovedot)||
+ (ks==XK_Wdiaeresis)||
+ ((ks>=XK_Wcircumflex)&&(ks<=XK_Ycircumflex))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if ((ks==XK_babovedot)||
+ (ks==XK_dabovedot)||
+ (ks==XK_fabovedot)||
+ (ks==XK_mabovedot)||
+ ((ks>=XK_wgrave)&&(ks<=XK_wacute))||
+ (ks==XK_ygrave)||
+ ((ks>=XK_wdiaeresis)&&(ks<=XK_ycircumflex))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 19: /* latin 9 */
+ if ((ks==XK_OE)||(ks==XK_Ydiaeresis)) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (ks==XK_oe) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ }
+ return rtrn;
+}
+
+/***===================================================================***/
+
+int
+_XkbStrCaseCmp(char *str1,char *str2)
+{
+ char buf1[512],buf2[512];
+ char c, *s;
+ register int n;
+
+ for (n=0, s = buf1; (c = *str1++); n++) {
+ if (isupper(c))
+ c = tolower(c);
+ if (n>510)
+ break;
+ *s++ = c;
+ }
+ *s = '\0';
+ for (n=0, s = buf2; (c = *str2++); n++) {
+ if (isupper(c))
+ c = tolower(c);
+ if (n>510)
+ break;
+ *s++ = c;
+ }
+ *s = '\0';
+ return (strcmp(buf1, buf2));
+}
+
+/***===================================================================***/
+
+Bool
+XkbLookupGroupAndLevel( XkbDescPtr xkb,
+ int key,
+ int * mods_inout,
+ int * grp_inout,
+ int * lvl_rtrn)
+{
+int nG,eG;
+
+ if ((!xkb)||(!XkbKeycodeInRange(xkb,key))||(!grp_inout))
+ return False;
+
+ nG= XkbKeyNumGroups(xkb,key);
+ eG= *grp_inout;
+
+ if ( nG==0 ) {
+ *grp_inout= 0;
+ if (lvl_rtrn!=NULL)
+ *lvl_rtrn= 0;
+ return False;
+ }
+ else if ( nG==1 ) {
+ eG= 0;
+ }
+ else if ( eG>=nG ) {
+ unsigned gI= XkbKeyGroupInfo(xkb,key);
+ switch (XkbOutOfRangeGroupAction(gI)) {
+ default:
+ eG %= nG;
+ break;
+ case XkbClampIntoRange:
+ eG = nG-1;
+ break;
+ case XkbRedirectIntoRange:
+ eG = XkbOutOfRangeGroupNumber(gI);
+ if (eG>=nG)
+ eG= 0;
+ break;
+ }
+ }
+ *grp_inout= eG;
+ if (mods_inout!=NULL) {
+ XkbKeyTypePtr type;
+ int preserve;
+
+ type = XkbKeyKeyType(xkb,key,eG);
+ if (lvl_rtrn!=NULL)
+ *lvl_rtrn= 0;
+ preserve= 0;
+ if (type->map) { /* find the shift level */
+ register int i;
+ register XkbKTMapEntryPtr entry;
+ for (i=0,entry=type->map;i<type->map_count;i++,entry++) {
+ if ((entry->active)&&
+ (((*mods_inout)&type->mods.mask)==entry->mods.mask)){
+ if (lvl_rtrn!=NULL)
+ *lvl_rtrn= entry->level;
+ if (type->preserve)
+ preserve= type->preserve[i].mask;
+ break;
+ }
+ }
+ }
+ (*mods_inout)&= ~(type->mods.mask&(~preserve));
+ }
+ return True;
+}
+
+/***===================================================================***/
+
+static Bool
+XkbWriteSectionFromName(FILE *file,char *sectionName,char *name)
+{
+ fprintf(file," xkb_%-20s { include \"%s\" };\n",sectionName,name);
+ return True;
+}
+
+#define NEED_DESC(n) ((!n)||((n)[0]=='+')||((n)[0]=='|')||(strchr((n),'%')))
+#define COMPLETE(n) ((n)&&(!NEED_DESC(n)))
+
+/* ARGSUSED */
+static void
+_AddIncl( FILE * file,
+ XkbFileInfo * result,
+ Bool topLevel,
+ Bool showImplicit,
+ int index,
+ void * priv)
+{
+ if ((priv)&&(strcmp((char *)priv,"%")!=0))
+ fprintf(file," include \"%s\"\n",(char *)priv);
+ return;
+}
+
+Bool
+XkbWriteXKBKeymapForNames( FILE * file,
+ XkbComponentNamesPtr names,
+ Display * dpy,
+ XkbDescPtr xkb,
+ unsigned want,
+ unsigned need)
+{
+char * name,*tmp;
+unsigned complete;
+XkbNamesPtr old_names;
+int multi_section;
+unsigned wantNames,wantConfig,wantDflts;
+XkbFileInfo finfo;
+
+ bzero(&finfo,sizeof(XkbFileInfo));
+
+ complete= 0;
+ if ((name=names->keymap)==NULL) name= "default";
+ if (COMPLETE(names->keycodes)) complete|= XkmKeyNamesMask;
+ if (COMPLETE(names->types)) complete|= XkmTypesMask;
+ if (COMPLETE(names->compat)) complete|= XkmCompatMapMask;
+ if (COMPLETE(names->symbols)) complete|= XkmSymbolsMask;
+ if (COMPLETE(names->geometry)) complete|= XkmGeometryMask;
+ want|= (complete|need);
+ if (want&XkmSymbolsMask)
+ want|= XkmKeyNamesMask|XkmTypesMask;
+
+ if (want==0)
+ return False;
+
+ if (xkb!=NULL) {
+ old_names= xkb->names;
+ finfo.type= 0;
+ finfo.defined= 0;
+ finfo.xkb= xkb;
+ if (!XkbDetermineFileType(&finfo,XkbXKBFile,NULL))
+ return False;
+ }
+ else old_names= NULL;
+
+ wantConfig= want&(~complete);
+ if (xkb!=NULL) {
+ if (wantConfig&XkmTypesMask) {
+ if ((!xkb->map) || (xkb->map->num_types<XkbNumRequiredTypes))
+ wantConfig&= ~XkmTypesMask;
+ }
+ if (wantConfig&XkmCompatMapMask) {
+ if ((!xkb->compat) || (xkb->compat->num_si<1))
+ wantConfig&= ~XkmCompatMapMask;
+ }
+ if (wantConfig&XkmSymbolsMask) {
+ if ((!xkb->map) || (!xkb->map->key_sym_map))
+ wantConfig&= ~XkmSymbolsMask;
+ }
+ if (wantConfig&XkmIndicatorsMask) {
+ if (!xkb->indicators)
+ wantConfig&= ~XkmIndicatorsMask;
+ }
+ if (wantConfig&XkmKeyNamesMask) {
+ if ((!xkb->names)||(!xkb->names->keys))
+ wantConfig&= ~XkmKeyNamesMask;
+ }
+ if ((wantConfig&XkmGeometryMask)&&(!xkb->geom))
+ wantConfig&= ~XkmGeometryMask;
+ }
+ else {
+ wantConfig= 0;
+ }
+ complete|= wantConfig;
+
+ wantDflts= 0;
+ wantNames= want&(~complete);
+ if ((xkb!=NULL) && (old_names!=NULL)) {
+ if (wantNames&XkmTypesMask) {
+ if (old_names->types!=None) {
+ tmp= XkbAtomGetString(dpy,old_names->types);
+ names->types= _XkbDupString(tmp);
+ }
+ else {
+ wantDflts|= XkmTypesMask;
+ }
+ complete|= XkmTypesMask;
+ }
+ if (wantNames&XkmCompatMapMask) {
+ if (old_names->compat!=None) {
+ tmp= XkbAtomGetString(dpy,old_names->compat);
+ names->compat= _XkbDupString(tmp);
+ }
+ else wantDflts|= XkmCompatMapMask;
+ complete|= XkmCompatMapMask;
+ }
+ if (wantNames&XkmSymbolsMask) {
+ if (old_names->symbols==None)
+ return False;
+ tmp= XkbAtomGetString(dpy,old_names->symbols);
+ names->symbols= _XkbDupString(tmp);
+ complete|= XkmSymbolsMask;
+ }
+ if (wantNames&XkmKeyNamesMask) {
+ if (old_names->keycodes!=None) {
+ tmp= XkbAtomGetString(dpy,old_names->keycodes);
+ names->keycodes= _XkbDupString(tmp);
+ }
+ else wantDflts|= XkmKeyNamesMask;
+ complete|= XkmKeyNamesMask;
+ }
+ if (wantNames&XkmGeometryMask) {
+ if (old_names->geometry==None)
+ return False;
+ tmp= XkbAtomGetString(dpy,old_names->geometry);
+ names->geometry= _XkbDupString(tmp);
+ complete|= XkmGeometryMask;
+ wantNames&= ~XkmGeometryMask;
+ }
+ }
+ if (complete&XkmCompatMapMask)
+ complete|= XkmIndicatorsMask|XkmVirtualModsMask;
+ else if (complete&(XkmSymbolsMask|XkmTypesMask))
+ complete|= XkmVirtualModsMask;
+ if (need & (~complete))
+ return False;
+ if ((complete&XkmSymbolsMask)&&((XkmKeyNamesMask|XkmTypesMask)&(~complete)))
+ return False;
+
+ multi_section= 1;
+ if (((complete&XkmKeymapRequired)==XkmKeymapRequired)&&
+ ((complete&(~XkmKeymapLegal))==0)) {
+ fprintf(file,"xkb_keymap \"%s\" {\n",name);
+ }
+ else if (((complete&XkmSemanticsRequired)==XkmSemanticsRequired)&&
+ ((complete&(~XkmSemanticsLegal))==0)) {
+ fprintf(file,"xkb_semantics \"%s\" {\n",name);
+ }
+ else if (((complete&XkmLayoutRequired)==XkmLayoutRequired)&&
+ ((complete&(~XkmLayoutLegal))==0)) {
+ fprintf(file,"xkb_layout \"%s\" {\n",name);
+ }
+ else if (XkmSingleSection(complete&(~XkmVirtualModsMask))) {
+ multi_section= 0;
+ }
+ else {
+ return False;
+ }
+
+ wantNames= complete&(~(wantConfig|wantDflts));
+ name= names->keycodes;
+ if (wantConfig&XkmKeyNamesMask)
+ XkbWriteXKBKeycodes(file,&finfo,False,False,_AddIncl,name);
+ else if (wantDflts&XkmKeyNamesMask)
+ fprintf(stderr,"Default symbols not implemented yet!\n");
+ else if (wantNames&XkmKeyNamesMask)
+ XkbWriteSectionFromName(file,"keycodes",name);
+
+ name= names->types;
+ if (wantConfig&XkmTypesMask)
+ XkbWriteXKBKeyTypes(file,&finfo,False,False,_AddIncl,name);
+ else if (wantDflts&XkmTypesMask)
+ fprintf(stderr,"Default types not implemented yet!\n");
+ else if (wantNames&XkmTypesMask)
+ XkbWriteSectionFromName(file,"types",name);
+
+ name= names->compat;
+ if (wantConfig&XkmCompatMapMask)
+ XkbWriteXKBCompatMap(file,&finfo,False,False,_AddIncl,name);
+ else if (wantDflts&XkmCompatMapMask)
+ fprintf(stderr,"Default interps not implemented yet!\n");
+ else if (wantNames&XkmCompatMapMask)
+ XkbWriteSectionFromName(file,"compatibility",name);
+
+ name= names->symbols;
+ if (wantConfig&XkmSymbolsMask)
+ XkbWriteXKBSymbols(file,&finfo,False,False,_AddIncl,name);
+ else if (wantNames&XkmSymbolsMask)
+ XkbWriteSectionFromName(file,"symbols",name);
+
+ name= names->geometry;
+ if (wantConfig&XkmGeometryMask)
+ XkbWriteXKBGeometry(file,&finfo,False,False,_AddIncl,name);
+ else if (wantNames&XkmGeometryMask)
+ XkbWriteSectionFromName(file,"geometry",name);
+
+ if (multi_section)
+ fprintf(file,"};\n");
+ return True;
+}
+
+/***====================================================================***/
+
+/*ARGSUSED*/
+Status
+XkbMergeFile(XkbDescPtr xkb,XkbFileInfo finfo)
+{
+ return BadImplementation;
+}
+
+/***====================================================================***/
+
+int
+XkbFindKeycodeByName(XkbDescPtr xkb,char *name,Bool use_aliases)
+{
+register int i;
+
+ if ((!xkb)||(!xkb->names)||(!xkb->names->keys))
+ return 0;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ if (strncmp(xkb->names->keys[i].name,name,XkbKeyNameLength)==0)
+ return i;
+ }
+ if (!use_aliases)
+ return 0;
+ if (xkb->geom && xkb->geom->key_aliases) {
+ XkbKeyAliasPtr a;
+ a= xkb->geom->key_aliases;
+ for (i=0;i<xkb->geom->num_key_aliases;i++,a++) {
+ if (strncmp(name,a->alias,XkbKeyNameLength)==0)
+ return XkbFindKeycodeByName(xkb,a->real,False);
+ }
+ }
+ if (xkb->names && xkb->names->key_aliases) {
+ XkbKeyAliasPtr a;
+ a= xkb->names->key_aliases;
+ for (i=0;i<xkb->names->num_key_aliases;i++,a++) {
+ if (strncmp(name,a->alias,XkbKeyNameLength)==0)
+ return XkbFindKeycodeByName(xkb,a->real,False);
+ }
+ }
+ return 0;
+}
+
+
+unsigned
+XkbConvertGetByNameComponents(Bool toXkm,unsigned orig)
+{
+unsigned rtrn;
+
+ rtrn= 0;
+ if (toXkm) {
+ if (orig&XkbGBN_TypesMask) rtrn|= XkmTypesMask;
+ if (orig&XkbGBN_CompatMapMask) rtrn|= XkmCompatMapMask;
+ if (orig&XkbGBN_SymbolsMask) rtrn|= XkmSymbolsMask;
+ if (orig&XkbGBN_IndicatorMapMask) rtrn|= XkmIndicatorsMask;
+ if (orig&XkbGBN_KeyNamesMask) rtrn|= XkmKeyNamesMask;
+ if (orig&XkbGBN_GeometryMask) rtrn|= XkmGeometryMask;
+ }
+ else {
+ if (orig&XkmTypesMask) rtrn|= XkbGBN_TypesMask;
+ if (orig&XkmCompatMapMask) rtrn|= XkbGBN_CompatMapMask;
+ if (orig&XkmSymbolsMask) rtrn|= XkbGBN_SymbolsMask;
+ if (orig&XkmIndicatorsMask) rtrn|= XkbGBN_IndicatorMapMask;
+ if (orig&XkmKeyNamesMask) rtrn|= XkbGBN_KeyNamesMask;
+ if (orig&XkmGeometryMask) rtrn|= XkbGBN_GeometryMask;
+ if (orig!=0) rtrn|= XkbGBN_OtherNamesMask;
+ }
+ return rtrn;
+}
+
+unsigned
+XkbConvertXkbComponents(Bool toXkm,unsigned orig)
+{
+unsigned rtrn;
+
+ rtrn= 0;
+ if (toXkm) {
+ if (orig&XkbClientMapMask) rtrn|= XkmTypesMask|XkmSymbolsMask;
+ if (orig&XkbServerMapMask) rtrn|= XkmTypesMask|XkmSymbolsMask;
+ if (orig&XkbCompatMapMask) rtrn|= XkmCompatMapMask;
+ if (orig&XkbIndicatorMapMask) rtrn|= XkmIndicatorsMask;
+ if (orig&XkbNamesMask) rtrn|= XkmKeyNamesMask;
+ if (orig&XkbGeometryMask) rtrn|= XkmGeometryMask;
+ }
+ else {
+ if (orig!=0) rtrn|= XkbNamesMask;
+ if (orig&XkmTypesMask) rtrn|= XkbClientMapMask;
+ if (orig&XkmCompatMapMask)
+ rtrn|= XkbCompatMapMask|XkbIndicatorMapMask;
+ if (orig&XkmSymbolsMask) rtrn|=XkbClientMapMask|XkbServerMapMask;
+ if (orig&XkmIndicatorsMask) rtrn|= XkbIndicatorMapMask;
+ if (orig&XkmKeyNamesMask)
+ rtrn|= XkbNamesMask|XkbIndicatorMapMask;
+ if (orig&XkmGeometryMask) rtrn|= XkbGeometryMask;
+ }
+ return rtrn;
+}
+
+Bool
+XkbDetermineFileType(XkbFileInfoPtr finfo,int format,int *opts_missing)
+{
+unsigned present;
+XkbDescPtr xkb;
+
+ if ((!finfo)||(!finfo->xkb))
+ return False;
+ if (opts_missing)
+ *opts_missing= 0;
+ xkb= finfo->xkb;
+ present= 0;
+ if ((xkb->names)&&(xkb->names->keys)) present|= XkmKeyNamesMask;
+ if ((xkb->map)&&(xkb->map->types)) present|= XkmTypesMask;
+ if (xkb->compat) present|= XkmCompatMapMask;
+ if ((xkb->map)&&(xkb->map->num_syms>1)) present|= XkmSymbolsMask;
+ if (xkb->indicators) present|= XkmIndicatorsMask;
+ if (xkb->geom) present|= XkmGeometryMask;
+ if (!present)
+ return False;
+ else switch (present) {
+ case XkmKeyNamesMask:
+ finfo->type= XkmKeyNamesIndex;
+ finfo->defined= present;
+ return True;
+ case XkmTypesMask:
+ finfo->type= XkmTypesIndex;
+ finfo->defined= present;
+ return True;
+ case XkmCompatMapMask:
+ finfo->type= XkmCompatMapIndex;
+ finfo->defined= present;
+ return True;
+ case XkmSymbolsMask:
+ if (format!=XkbXKMFile) {
+ finfo->type= XkmSymbolsIndex;
+ finfo->defined= present;
+ return True;
+ }
+ break;
+ case XkmGeometryMask:
+ finfo->type= XkmGeometryIndex;
+ finfo->defined= present;
+ return True;
+ }
+ if ((present&(~XkmSemanticsLegal))==0) {
+ if ((XkmSemanticsRequired&present)==XkmSemanticsRequired) {
+ if (opts_missing)
+ *opts_missing= XkmSemanticsOptional&(~present);
+ finfo->type= XkmSemanticsFile;
+ finfo->defined= present;
+ return True;
+ }
+ }
+ else if ((present&(~XkmLayoutLegal))==0) {
+ if ((XkmLayoutRequired&present)==XkmLayoutRequired) {
+ if (opts_missing)
+ *opts_missing= XkmLayoutOptional&(~present);
+ finfo->type= XkmLayoutFile;
+ finfo->defined= present;
+ return True;
+ }
+ }
+ else if ((present&(~XkmKeymapLegal))==0) {
+ if ((XkmKeymapRequired&present)==XkmKeymapRequired) {
+ if (opts_missing)
+ *opts_missing= XkmKeymapOptional&(~present);
+ finfo->type= XkmKeymapFile;
+ finfo->defined= present;
+ return True;
+ }
+ }
+ return False;
+}
+
+/* all latin-1 alphanumerics, plus parens, slash, minus, underscore and */
+/* wildcards */
+
+static unsigned char componentSpecLegal[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0xff, 0x83,
+ 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff
+};
+
+void
+XkbEnsureSafeMapName(char *name)
+{
+ if (name==NULL)
+ return;
+ while (*name!='\0') {
+ if ((componentSpecLegal[(*name)/8]&(1<<((*name)%8)))==0)
+ *name= '_';
+ name++;
+ }
+ return;
+}
+
+/***====================================================================***/
+
+#define UNMATCHABLE(c) (((c)=='(')||((c)==')')||((c)=='/'))
+
+Bool
+XkbNameMatchesPattern(char *name,char *ptrn)
+{
+ while (ptrn[0]!='\0') {
+ if (name[0]=='\0') {
+ if (ptrn[0]=='*') {
+ ptrn++;
+ continue;
+ }
+ return False;
+ }
+ if (ptrn[0]=='?') {
+ if (UNMATCHABLE(name[0]))
+ return False;
+ }
+ else if (ptrn[0]=='*') {
+ if ((!UNMATCHABLE(name[0]))&&XkbNameMatchesPattern(name+1,ptrn))
+ return True;
+ return XkbNameMatchesPattern(name,ptrn+1);
+ }
+ else if (ptrn[0]!=name[0])
+ return False;
+ name++;
+ ptrn++;
+ }
+ /* if we get here, the pattern is exhausted (-:just like me:-) */
+ return (name[0]=='\0');
+}
diff --git a/nx-X11/lib/xkbfile/xkbout.c b/nx-X11/lib/xkbfile/xkbout.c
new file mode 100644
index 000000000..b69fdfbb4
--- /dev/null
+++ b/nx-X11/lib/xkbfile/xkbout.c
@@ -0,0 +1,1066 @@
+/* $Xorg: xkbout.c,v 1.3 2000/08/17 19:46:44 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkbout.c,v 3.9 2001/10/28 03:32:47 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#elif defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <X11/Xfuncs.h>
+
+#ifndef XKB_IN_SERVER
+
+#include <X11/Xlib.h>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKBgeom.h>
+
+#include "XKMformat.h"
+#include "XKBfileInt.h"
+
+#else
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#include <X11/keysym.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include "dix.h"
+#include <X11/extensions/XKBstr.h>
+#define XKBSRV_NEED_FILE_FUNCS 1
+#include <X11/extensions/XKBsrv.h>
+
+#include <X11/extensions/XKBgeom.h>
+#include <X11/extensions/XKBfile.h>
+
+#endif
+
+#define VMOD_HIDE_VALUE 0
+#define VMOD_SHOW_VALUE 1
+#define VMOD_COMMENT_VALUE 2
+
+static Bool
+WriteXKBVModDecl(FILE *file,Display *dpy,XkbDescPtr xkb,int showValue)
+{
+register int i,nMods;
+Atom * vmodNames;
+
+ if (xkb==NULL)
+ return False;
+ if (xkb->names!=NULL)
+ vmodNames= xkb->names->vmods;
+ else vmodNames= NULL;
+
+ for (i=nMods=0;i<XkbNumVirtualMods;i++) {
+ if ((vmodNames!=NULL)&&(vmodNames[i]!=None)) {
+ if (nMods==0) fprintf(file," virtual_modifiers ");
+ else fprintf(file,",");
+ fprintf(file,"%s",XkbAtomText(dpy,vmodNames[i],XkbXKBFile));
+ if ((showValue!=VMOD_HIDE_VALUE)&&
+ (xkb->server)&&(xkb->server->vmods[i]!=XkbNoModifierMask)) {
+ if (showValue==VMOD_COMMENT_VALUE) {
+ fprintf(file,"/* = %s */",
+ XkbModMaskText(xkb->server->vmods[i],XkbXKBFile));
+ }
+ else {
+ fprintf(file,"= %s",
+ XkbModMaskText(xkb->server->vmods[i],XkbXKBFile));
+ }
+ }
+ nMods++;
+ }
+ }
+ if (nMods>0)
+ fprintf(file,";\n\n");
+ return True;
+}
+
+/***====================================================================***/
+
+static Bool
+WriteXKBAction(FILE *file,XkbFileInfo *result,XkbAnyAction *action)
+{
+XkbDescPtr xkb;
+Display * dpy;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ fprintf(file,"%s",XkbActionText(dpy,xkb,(XkbAction *)action,XkbXKBFile));
+ return True;
+}
+
+/***====================================================================***/
+
+Bool
+XkbWriteXKBKeycodes( FILE * file,
+ XkbFileInfo * result,
+ Bool topLevel,
+ Bool showImplicit,
+ XkbFileAddOnFunc addOn,
+ void * priv)
+{
+Atom kcName;
+register unsigned i;
+XkbDescPtr xkb;
+Display * dpy;
+char * alternate;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if ((!xkb)||(!xkb->names)||(!xkb->names->keys)) {
+ _XkbLibError(_XkbErrMissingNames,"XkbWriteXKBKeycodes",0);
+ return False;
+ }
+ kcName= xkb->names->keycodes;
+ if (kcName!=None)
+ fprintf(file,"xkb_keycodes \"%s\" {\n",
+ XkbAtomText(dpy,kcName,XkbXKBFile));
+ else fprintf(file,"xkb_keycodes {\n");
+ fprintf(file," minimum = %d;\n",xkb->min_key_code);
+ fprintf(file," maximum = %d;\n",xkb->max_key_code);
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ if (xkb->names->keys[i].name[0]!='\0') {
+ if (XkbFindKeycodeByName(xkb,xkb->names->keys[i].name,True)!=i)
+ alternate= "alternate ";
+ else alternate= "";
+ fprintf(file," %s%6s = %d;\n",alternate,
+ XkbKeyNameText(xkb->names->keys[i].name,XkbXKBFile),
+ i);
+ }
+ }
+ if (xkb->indicators!=NULL) {
+ for (i=0;i<XkbNumIndicators;i++) {
+ char *type;
+ if (xkb->indicators->phys_indicators&(1<<i))
+ type= " ";
+ else type= " virtual ";
+ if (xkb->names->indicators[i]!=None) {
+ fprintf(file,"%sindicator %d = \"%s\";\n",type,i+1,
+ XkbAtomText(dpy,xkb->names->indicators[i],XkbXKBFile));
+ }
+ }
+ }
+ if (xkb->names->key_aliases!=NULL) {
+ XkbKeyAliasPtr pAl;
+ pAl= xkb->names->key_aliases;
+ for (i=0;i<xkb->names->num_key_aliases;i++,pAl++) {
+ fprintf(file," alias %6s = %6s;\n",
+ XkbKeyNameText(pAl->alias,XkbXKBFile),
+ XkbKeyNameText(pAl->real,XkbXKBFile));
+ }
+ }
+ if (addOn)
+ (*addOn)(file,result,topLevel,showImplicit,XkmKeyNamesIndex,priv);
+ fprintf(file,"};\n\n");
+ return True;
+}
+
+Bool
+XkbWriteXKBKeyTypes( FILE * file,
+ XkbFileInfo * result,
+ Bool topLevel,
+ Bool showImplicit,
+ XkbFileAddOnFunc addOn,
+ void * priv)
+{
+Display * dpy;
+register unsigned i,n;
+XkbKeyTypePtr type;
+XkbKTMapEntryPtr entry;
+XkbDescPtr xkb;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if ((!xkb)||(!xkb->map)||(!xkb->map->types)) {
+ _XkbLibError(_XkbErrMissingTypes,"XkbWriteXKBKeyTypes",0);
+ return False;
+ }
+ if (xkb->map->num_types<XkbNumRequiredTypes) {
+ _XkbLibError(_XkbErrMissingReqTypes,"XkbWriteXKBKeyTypes",0);
+ return 0;
+ }
+ if ((xkb->names==NULL)||(xkb->names->types==None))
+ fprintf(file,"xkb_types {\n\n");
+ else fprintf(file,"xkb_types \"%s\" {\n\n",
+ XkbAtomText(dpy,xkb->names->types,XkbXKBFile));
+ WriteXKBVModDecl(file,dpy,xkb,
+ (showImplicit?VMOD_COMMENT_VALUE:VMOD_HIDE_VALUE));
+
+ type= xkb->map->types;
+ for (i=0;i<xkb->map->num_types;i++,type++) {
+ fprintf(file," type \"%s\" {\n",
+ XkbAtomText(dpy,type->name,XkbXKBFile));
+ fprintf(file," modifiers= %s;\n",
+ XkbVModMaskText(dpy,xkb,type->mods.real_mods,type->mods.vmods,
+ XkbXKBFile));
+ entry= type->map;
+ for (n=0;n<type->map_count;n++,entry++) {
+ char *str;
+ str=XkbVModMaskText(dpy,xkb,entry->mods.real_mods,entry->mods.vmods,
+ XkbXKBFile);
+ fprintf(file," map[%s]= Level%d;\n",str,entry->level+1);
+ if ((type->preserve)&&((type->preserve[n].real_mods)||
+ (type->preserve[n].vmods))) {
+ fprintf(file," preserve[%s]= ",str);
+ fprintf(file,"%s;\n",XkbVModMaskText(dpy,xkb,
+ type->preserve[n].real_mods,
+ type->preserve[n].vmods,
+ XkbXKBFile));
+ }
+ }
+ if (type->level_names!=NULL) {
+ Atom *name= type->level_names;
+ for (n=0;n<type->num_levels;n++,name++) {
+ if ((*name)==None)
+ continue;
+ fprintf(file," level_name[Level%d]= \"%s\";\n",n+1,
+ XkbAtomText(dpy,*name,XkbXKBFile));
+ }
+ }
+ fprintf(file," };\n");
+ }
+ if (addOn)
+ (*addOn)(file,result,topLevel,showImplicit,XkmTypesIndex,priv);
+ fprintf(file,"};\n\n");
+ return True;
+}
+
+static Bool
+WriteXKBIndicatorMap( FILE * file,
+ XkbFileInfo * result,
+ Atom name,
+ XkbIndicatorMapPtr led,
+ XkbFileAddOnFunc addOn,
+ void * priv)
+{
+XkbDescPtr xkb;
+
+ xkb= result->xkb;
+ fprintf(file," indicator \"%s\" {\n",XkbAtomGetString(xkb->dpy,name));
+ if (led->flags&XkbIM_NoExplicit)
+ fprintf(file," !allowExplicit;\n");
+ if (led->flags&XkbIM_LEDDrivesKB)
+ fprintf(file," indicatorDrivesKeyboard;\n");
+ if (led->which_groups!=0) {
+ if (led->which_groups!=XkbIM_UseEffective) {
+ fprintf(file," whichGroupState= %s;\n",
+ XkbIMWhichStateMaskText(led->which_groups,XkbXKBFile));
+ }
+ fprintf(file," groups= 0x%02x;\n",led->groups);
+ }
+ if (led->which_mods!=0) {
+ if (led->which_mods!=XkbIM_UseEffective) {
+ fprintf(file," whichModState= %s;\n",
+ XkbIMWhichStateMaskText(led->which_mods,XkbXKBFile));
+ }
+ fprintf(file," modifiers= %s;\n",
+ XkbVModMaskText(xkb->dpy,xkb,
+ led->mods.real_mods,led->mods.vmods,
+ XkbXKBFile));
+ }
+ if (led->ctrls!=0) {
+ fprintf(file," controls= %s;\n",
+ XkbControlsMaskText(led->ctrls,XkbXKBFile));
+ }
+ if (addOn)
+ (*addOn)(file,result,False,True,XkmIndicatorsIndex,priv);
+ fprintf(file," };\n");
+ return True;
+}
+
+Bool
+XkbWriteXKBCompatMap( FILE * file,
+ XkbFileInfo * result,
+ Bool topLevel,
+ Bool showImplicit,
+ XkbFileAddOnFunc addOn,
+ void * priv)
+{
+Display * dpy;
+register unsigned i;
+XkbSymInterpretPtr interp;
+XkbDescPtr xkb;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if ((!xkb)||(!xkb->compat)||(!xkb->compat->sym_interpret)) {
+ _XkbLibError(_XkbErrMissingCompatMap,"XkbWriteXKBCompatMap",0);
+ return False;
+ }
+ if ((xkb->names==NULL)||(xkb->names->compat==None))
+ fprintf(file,"xkb_compatibility {\n\n");
+ else fprintf(file,"xkb_compatibility \"%s\" {\n\n",
+ XkbAtomText(dpy,xkb->names->compat,XkbXKBFile));
+ WriteXKBVModDecl(file,dpy,xkb,
+ (showImplicit?VMOD_COMMENT_VALUE:VMOD_HIDE_VALUE));
+
+ fprintf(file," interpret.useModMapMods= AnyLevel;\n");
+ fprintf(file," interpret.repeat= False;\n");
+ fprintf(file," interpret.locking= False;\n");
+ interp= xkb->compat->sym_interpret;
+ for (i=0;i<xkb->compat->num_si;i++,interp++) {
+ fprintf(file," interpret %s+%s(%s) {\n",
+ ((interp->sym==NoSymbol)?"Any":
+ XkbKeysymText(interp->sym,XkbXKBFile)),
+ XkbSIMatchText(interp->match,XkbXKBFile),
+ XkbModMaskText(interp->mods,XkbXKBFile));
+ if (interp->virtual_mod!=XkbNoModifier) {
+ fprintf(file," virtualModifier= %s;\n",
+ XkbVModIndexText(dpy,xkb,interp->virtual_mod,XkbXKBFile));
+ }
+ if (interp->match&XkbSI_LevelOneOnly)
+ fprintf(file," useModMapMods=level1;\n");
+ if (interp->flags&XkbSI_LockingKey)
+ fprintf(file," locking= True;\n");
+ if (interp->flags&XkbSI_AutoRepeat)
+ fprintf(file," repeat= True;\n");
+ fprintf(file," action= ");
+ WriteXKBAction(file,result,&interp->act);
+ fprintf(file,";\n");
+ fprintf(file," };\n");
+ }
+ for (i=0;i<XkbNumKbdGroups;i++) {
+ XkbModsPtr gc;
+
+ gc= &xkb->compat->groups[i];
+ if ((gc->real_mods==0)&&(gc->vmods==0))
+ continue;
+ fprintf(file," group %d = %s;\n",i+1,XkbVModMaskText(xkb->dpy,xkb,
+ gc->real_mods,gc->vmods,
+ XkbXKBFile));
+ }
+ if (xkb->indicators) {
+ for (i=0;i<XkbNumIndicators;i++) {
+ XkbIndicatorMapPtr map= &xkb->indicators->maps[i];
+ if ((map->flags!=0)||(map->which_groups!=0)||(map->groups!=0)||
+ (map->which_mods!=0)||
+ (map->mods.real_mods!=0)||(map->mods.vmods!=0)||
+ (map->ctrls!=0)) {
+ WriteXKBIndicatorMap(file,result,xkb->names->indicators[i],map,
+ addOn,priv);
+ }
+ }
+ }
+ if (addOn)
+ (*addOn)(file,result,topLevel,showImplicit,XkmCompatMapIndex,priv);
+ fprintf(file,"};\n\n");
+ return True;
+}
+
+Bool
+XkbWriteXKBSymbols( FILE * file,
+ XkbFileInfo * result,
+ Bool topLevel,
+ Bool showImplicit,
+ XkbFileAddOnFunc addOn,
+ void * priv)
+{
+Display * dpy;
+register unsigned i,tmp;
+XkbDescPtr xkb;
+XkbClientMapPtr map;
+XkbServerMapPtr srv;
+Bool showActions;
+
+ xkb= result->xkb;
+ map= xkb->map;
+ srv= xkb->server;
+ dpy= xkb->dpy;
+ if ((!xkb)||(!map)||(!map->syms)||(!map->key_sym_map)) {
+ _XkbLibError(_XkbErrMissingSymbols,"XkbWriteXKBSymbols",0);
+ return False;
+ }
+ if ((!xkb->names)||(!xkb->names->keys)) {
+ _XkbLibError(_XkbErrMissingNames,"XkbWriteXKBSymbols",0);
+ return False;
+ }
+ if ((xkb->names==NULL)||(xkb->names->symbols==None))
+ fprintf(file,"xkb_symbols {\n\n");
+ else fprintf(file,"xkb_symbols \"%s\" {\n\n",
+ XkbAtomText(dpy,xkb->names->symbols,XkbXKBFile));
+ for (tmp=i=0;i<XkbNumKbdGroups;i++) {
+ if (xkb->names->groups[i]!=None) {
+ fprintf(file," name[group%d]=\"%s\";\n",i+1,
+ XkbAtomText(dpy,xkb->names->groups[i],XkbXKBFile));
+ tmp++;
+ }
+ }
+ if (tmp>0)
+ fprintf(file,"\n");
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ Bool simple;
+ if ((int)XkbKeyNumSyms(xkb,i)<1)
+ continue;
+ if (XkbFindKeycodeByName(xkb,xkb->names->keys[i].name,True)!=i)
+ continue;
+ simple= True;
+ fprintf(file," key %6s {",
+ XkbKeyNameText(xkb->names->keys[i].name,XkbXKBFile));
+ if (srv->explicit) {
+ if (((srv->explicit[i]&XkbExplicitKeyTypesMask)!=0)||
+ (showImplicit)) {
+ int typeNdx,g;
+ Bool multi;
+ char * comment=" ";
+
+ if ((srv->explicit[i]&XkbExplicitKeyTypesMask)==0)
+ comment= "//";
+ multi= False;
+ typeNdx= XkbKeyKeyTypeIndex(xkb,i,0);
+ for (g=1;(g<XkbKeyNumGroups(xkb,i))&&(!multi);g++) {
+ if (XkbKeyKeyTypeIndex(xkb,i,g)!=typeNdx)
+ multi= True;
+ }
+ if (multi) {
+ for (g=0;g<XkbKeyNumGroups(xkb,i);g++) {
+ typeNdx= XkbKeyKeyTypeIndex(xkb,i,g);
+ if (srv->explicit[i]&(1<<g)) {
+ fprintf(file,"\n%s type[group%d]= \"%s\",",
+ comment,g+1,
+ XkbAtomText(dpy,map->types[typeNdx].name,
+ XkbXKBFile));
+ }
+ else if (showImplicit) {
+ fprintf(file,"\n// type[group%d]= \"%s\",",g+1,
+ XkbAtomText(dpy,map->types[typeNdx].name,
+ XkbXKBFile));
+ }
+ }
+ }
+ else {
+ fprintf(file,"\n%s type= \"%s\",",comment,
+ XkbAtomText(dpy,map->types[typeNdx].name,
+ XkbXKBFile));
+ }
+ simple= False;
+ }
+ if (((srv->explicit[i]&XkbExplicitAutoRepeatMask)!=0)&&
+ (xkb->ctrls!=NULL)) {
+ if (xkb->ctrls->per_key_repeat[i/8]&(1<<(i%8)))
+ fprintf(file,"\n repeat= Yes,");
+ else fprintf(file,"\n repeat= No,");
+ simple= False;
+ }
+ if ((xkb->server!=NULL)&&(xkb->server->vmodmap!=NULL)&&
+ (xkb->server->vmodmap[i]!=0)) {
+ if ((srv->explicit[i]&XkbExplicitVModMapMask)!=0) {
+ fprintf(file,"\n virtualMods= %s,",
+ XkbVModMaskText(dpy,xkb,0,
+ xkb->server->vmodmap[i],
+ XkbXKBFile));
+ }
+ else if (showImplicit) {
+ fprintf(file,"\n// virtualMods= %s,",
+ XkbVModMaskText(dpy,xkb,0,
+ xkb->server->vmodmap[i],
+ XkbXKBFile));
+ }
+ }
+ }
+ switch (XkbOutOfRangeGroupAction(XkbKeyGroupInfo(xkb,i))) {
+ case XkbClampIntoRange:
+ fprintf(file,"\n groupsClamp,");
+ break;
+ case XkbRedirectIntoRange:
+ fprintf(file,"\n groupsRedirect= Group%d,",
+ XkbOutOfRangeGroupNumber(XkbKeyGroupInfo(xkb,i))+1);
+ break;
+ }
+ if (srv->behaviors!=NULL) {
+ unsigned type;
+ type= srv->behaviors[i].type&XkbKB_OpMask;
+
+ if (type!=XkbKB_Default) {
+ simple= False;
+ fprintf(file,"\n %s,",
+ XkbBehaviorText(xkb,&srv->behaviors[i],XkbXKBFile));
+ }
+ }
+ if ((srv->explicit==NULL) || showImplicit ||
+ ((srv->explicit[i]&XkbExplicitInterpretMask)!=0))
+ showActions= XkbKeyHasActions(xkb,i);
+ else showActions= False;
+
+ if (((unsigned)XkbKeyNumGroups(xkb,i)>1)||showActions)
+ simple= False;
+ if (simple) {
+ KeySym *syms;
+ unsigned s;
+
+ syms= XkbKeySymsPtr(xkb,i);
+ fprintf(file," [ ");
+ for (s=0;s<XkbKeyGroupWidth(xkb,i,XkbGroup1Index);s++) {
+ if (s!=0)
+ fprintf(file,", ");
+ fprintf(file,"%15s",XkbKeysymText(*syms++,XkbXKBFile));
+ }
+ fprintf(file," ] };\n");
+ }
+ else {
+ unsigned g,s;
+ KeySym *syms;
+ XkbAction *acts;
+ syms= XkbKeySymsPtr(xkb,i);
+ acts= XkbKeyActionsPtr(xkb,i);
+ for (g=0;g<XkbKeyNumGroups(xkb,i);g++) {
+ if (g!=0)
+ fprintf(file,",");
+ fprintf(file,"\n symbols[Group%d]= [ ",g+1);
+ for (s=0;s<XkbKeyGroupWidth(xkb,i,g);s++) {
+ if (s!=0)
+ fprintf(file,", ");
+ fprintf(file,"%15s",XkbKeysymText(syms[s],XkbXKBFile));
+ }
+ fprintf(file," ]");
+ syms+= XkbKeyGroupsWidth(xkb,i);
+ if (showActions) {
+ fprintf(file,",\n actions[Group%d]= [ ",g+1);
+ for (s=0;s<XkbKeyGroupWidth(xkb,i,g);s++) {
+ if (s!=0)
+ fprintf(file,", ");
+ WriteXKBAction(file,result,(XkbAnyAction *)&acts[s]);
+ }
+ fprintf(file," ]");
+ acts+= XkbKeyGroupsWidth(xkb,i);
+ }
+ }
+ fprintf(file,"\n };\n");
+ }
+ }
+ if (map && map->modmap) {
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ if (map->modmap[i]!=0) {
+ register int n,bit;
+ for (bit=1,n=0;n<XkbNumModifiers;n++,bit<<=1) {
+ if (map->modmap[i]&bit) {
+ char buf[5];
+ memcpy(buf,xkb->names->keys[i].name,4);
+ buf[4]= '\0';
+ fprintf(file," modifier_map %s { <%s> };\n",
+ XkbModIndexText(n,XkbXKBFile),buf);
+ }
+ }
+ }
+ }
+ }
+ if (addOn)
+ (*addOn)(file,result,topLevel,showImplicit,XkmSymbolsIndex,priv);
+ fprintf(file,"};\n\n");
+ return True;
+}
+
+static Bool
+WriteXKBOutline( FILE * file,
+ XkbShapePtr shape,
+ XkbOutlinePtr outline,
+ int lastRadius,
+ int first,
+ int indent)
+{
+register int i;
+XkbPointPtr pt;
+char * iStr;
+
+ fprintf(file,"%s",iStr= XkbIndentText(first));
+ if (first!=indent)
+ iStr= XkbIndentText(indent);
+ if (outline->corner_radius!=lastRadius) {
+ fprintf(file,"corner= %s,",
+ XkbGeomFPText(outline->corner_radius,XkbMessage));
+ if (shape!=NULL) {
+ fprintf(file,"\n%s",iStr);
+ }
+ }
+ if (shape) {
+ if (outline==shape->approx)
+ fprintf(file,"approx= ");
+ else if (outline==shape->primary)
+ fprintf(file,"primary= ");
+ }
+ fprintf(file,"{");
+ for (pt=outline->points,i=0;i<outline->num_points;i++,pt++) {
+ if (i==0) fprintf(file," ");
+ else if ((i%4)==0) fprintf(file,",\n%s ",iStr);
+ else fprintf(file,", ");
+ fprintf(file,"[ %3s, %3s ]",XkbGeomFPText(pt->x,XkbXKBFile),
+ XkbGeomFPText(pt->y,XkbXKBFile));
+ }
+ fprintf(file," }");
+ return True;
+}
+
+static Bool
+WriteXKBDoodad( FILE * file,
+ Display * dpy,
+ unsigned indent,
+ XkbGeometryPtr geom,
+ XkbDoodadPtr doodad)
+{
+register char * i_str;
+XkbShapePtr shape;
+XkbColorPtr color;
+
+ i_str= XkbIndentText(indent);
+ fprintf(file,"%s%s \"%s\" {\n",i_str,
+ XkbDoodadTypeText(doodad->any.type,XkbMessage),
+ XkbAtomText(dpy,doodad->any.name,XkbMessage));
+ fprintf(file,"%s top= %s;\n",i_str,
+ XkbGeomFPText(doodad->any.top,XkbXKBFile));
+ fprintf(file,"%s left= %s;\n",i_str,
+ XkbGeomFPText(doodad->any.left,XkbXKBFile));
+ fprintf(file,"%s priority= %d;\n",i_str,doodad->any.priority);
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ if (doodad->shape.angle!=0) {
+ fprintf(file,"%s angle= %s;\n",i_str,
+ XkbGeomFPText(doodad->shape.angle,XkbXKBFile));
+ }
+ if (doodad->shape.color_ndx!=0) {
+ fprintf(file,"%s color= \"%s\";\n",i_str,
+ XkbShapeDoodadColor(geom,&doodad->shape)->spec);
+ }
+ shape= XkbShapeDoodadShape(geom,&doodad->shape);
+ fprintf(file,"%s shape= \"%s\";\n",i_str,
+ XkbAtomText(dpy,shape->name,XkbXKBFile));
+ break;
+ case XkbTextDoodad:
+ if (doodad->text.angle!=0) {
+ fprintf(file,"%s angle= %s;\n",i_str,
+ XkbGeomFPText(doodad->text.angle,XkbXKBFile));
+ }
+ if (doodad->text.width!=0) {
+ fprintf(file,"%s width= %s;\n",i_str,
+ XkbGeomFPText(doodad->text.width,XkbXKBFile));
+
+ }
+ if (doodad->text.height!=0) {
+ fprintf(file,"%s height= %s;\n",i_str,
+ XkbGeomFPText(doodad->text.height,XkbXKBFile));
+
+ }
+ if (doodad->text.color_ndx!=0) {
+ color= XkbTextDoodadColor(geom,&doodad->text);
+ fprintf(file,"%s color= \"%s\";\n",i_str,
+ XkbStringText(color->spec,XkbXKBFile));
+ }
+ fprintf(file,"%s XFont= \"%s\";\n",i_str,
+ XkbStringText(doodad->text.font,XkbXKBFile));
+ fprintf(file,"%s text= \"%s\";\n",i_str,
+ XkbStringText(doodad->text.text,XkbXKBFile));
+ break;
+ case XkbIndicatorDoodad:
+ shape= XkbIndicatorDoodadShape(geom,&doodad->indicator);
+ color= XkbIndicatorDoodadOnColor(geom,&doodad->indicator);
+ fprintf(file,"%s onColor= \"%s\";\n",i_str,
+ XkbStringText(color->spec,XkbXKBFile));
+ color= XkbIndicatorDoodadOffColor(geom,&doodad->indicator);
+ fprintf(file,"%s offColor= \"%s\";\n",i_str,
+ XkbStringText(color->spec,XkbXKBFile));
+ fprintf(file,"%s shape= \"%s\";\n",i_str,
+ XkbAtomText(dpy,shape->name,XkbXKBFile));
+ break;
+ case XkbLogoDoodad:
+ fprintf(file,"%s logoName= \"%s\";\n",i_str,
+ XkbStringText(doodad->logo.logo_name,XkbXKBFile));
+ if (doodad->shape.angle!=0) {
+ fprintf(file,"%s angle= %s;\n",i_str,
+ XkbGeomFPText(doodad->logo.angle,XkbXKBFile));
+ }
+ if (doodad->shape.color_ndx!=0) {
+ fprintf(file,"%s color= \"%s\";\n",i_str,
+ XkbLogoDoodadColor(geom,&doodad->logo)->spec);
+ }
+ shape= XkbLogoDoodadShape(geom,&doodad->logo);
+ fprintf(file,"%s shape= \"%s\";\n",i_str,
+ XkbAtomText(dpy,shape->name,XkbXKBFile));
+ break;
+ }
+ fprintf(file,"%s};\n",i_str);
+ return True;
+}
+
+/*ARGSUSED*/
+static Bool
+WriteXKBOverlay( FILE * file,
+ Display * dpy,
+ unsigned indent,
+ XkbGeometryPtr geom,
+ XkbOverlayPtr ol)
+{
+register char * i_str;
+int r,k,nOut;
+XkbOverlayRowPtr row;
+XkbOverlayKeyPtr key;
+
+ i_str= XkbIndentText(indent);
+ if (ol->name!=None) {
+ fprintf(file,"%soverlay \"%s\" {\n",i_str,
+ XkbAtomText(dpy,ol->name,XkbMessage));
+ }
+ else fprintf(file,"%soverlay {\n",i_str);
+ for (nOut=r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ char *over,*under;
+ over= XkbKeyNameText(key->over.name,XkbXKBFile);
+ under= XkbKeyNameText(key->under.name,XkbXKBFile);
+ if (nOut==0)
+ fprintf(file,"%s %6s=%6s",i_str,under,over);
+ else if ((nOut%4)==0)
+ fprintf(file,",\n%s %6s=%6s",i_str,under,over);
+ else fprintf(file,", %6s=%6s",under,over);
+ nOut++;
+ }
+ }
+ fprintf(file,"\n%s};\n",i_str);
+ return True;
+}
+
+static Bool
+WriteXKBSection( FILE * file,
+ Display * dpy,
+ XkbSectionPtr s,
+ XkbGeometryPtr geom)
+{
+register int i;
+XkbRowPtr row;
+int dfltKeyColor = 0;
+
+ fprintf(file," section \"%s\" {\n",
+ XkbAtomText(dpy,s->name,XkbXKBFile));
+ if (s->rows&&(s->rows->num_keys>0)) {
+ dfltKeyColor= s->rows->keys[0].color_ndx;
+ fprintf(file," key.color= \"%s\";\n",
+ XkbStringText(geom->colors[dfltKeyColor].spec,XkbXKBFile));
+ }
+ fprintf(file," priority= %d;\n",s->priority);
+ fprintf(file," top= %s;\n",XkbGeomFPText(s->top,XkbXKBFile));
+ fprintf(file," left= %s;\n",XkbGeomFPText(s->left,XkbXKBFile));
+ fprintf(file," width= %s;\n",XkbGeomFPText(s->width,XkbXKBFile));
+ fprintf(file," height= %s;\n",
+ XkbGeomFPText(s->height,XkbXKBFile));
+ if (s->angle!=0) {
+ fprintf(file," angle= %s;\n",
+ XkbGeomFPText(s->angle,XkbXKBFile));
+ }
+ for (i=0,row=s->rows;i<s->num_rows;i++,row++) {
+ fprintf(file," row {\n");
+ fprintf(file," top= %s;\n",
+ XkbGeomFPText(row->top,XkbXKBFile));
+ fprintf(file," left= %s;\n",
+ XkbGeomFPText(row->left,XkbXKBFile));
+ if (row->vertical)
+ fprintf(file," vertical;\n");
+ if (row->num_keys>0) {
+ register int k;
+ register XkbKeyPtr key;
+ int forceNL=0;
+ int nThisLine= 0;
+ fprintf(file," keys {\n");
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ XkbShapePtr shape;
+ if (key->color_ndx!=dfltKeyColor)
+ forceNL= 1;
+ if (k==0) {
+ fprintf(file," ");
+ nThisLine= 0;
+ }
+ else if (((nThisLine%2)==1)||(forceNL)) {
+ fprintf(file,",\n ");
+ forceNL= nThisLine= 0;
+ }
+ else {
+ fprintf(file,", ");
+ nThisLine++;
+ }
+ shape= XkbKeyShape(geom,key);
+ fprintf(file,"{ %6s, \"%s\", %3s",
+ XkbKeyNameText(key->name.name,XkbXKBFile),
+ XkbAtomText(dpy,shape->name,XkbXKBFile),
+ XkbGeomFPText(key->gap,XkbXKBFile));
+ if (key->color_ndx!=dfltKeyColor) {
+ fprintf(file,", color=\"%s\"",XkbKeyColor(geom,key)->spec);
+ forceNL= 1;
+ }
+ fprintf(file," }");
+ }
+ fprintf(file,"\n };\n");
+ }
+ fprintf(file," };\n");
+ }
+ if (s->doodads!=NULL) {
+ XkbDoodadPtr doodad;
+ for (i=0,doodad=s->doodads;i<s->num_doodads;i++,doodad++) {
+ WriteXKBDoodad(file,dpy,8,geom,doodad);
+ }
+ }
+ if (s->overlays!=NULL) {
+ XkbOverlayPtr ol;
+ for (i=0,ol=s->overlays;i<s->num_overlays;i++,ol++) {
+ WriteXKBOverlay(file,dpy,8,geom,ol);
+ }
+ }
+ fprintf(file," }; // End of \"%s\" section\n\n",
+ XkbAtomText(dpy,s->name,XkbXKBFile));
+ return True;
+}
+
+Bool
+XkbWriteXKBGeometry( FILE * file,
+ XkbFileInfo * result,
+ Bool topLevel,
+ Bool showImplicit,
+ XkbFileAddOnFunc addOn,
+ void * priv)
+{
+Display * dpy;
+register unsigned i,n;
+XkbDescPtr xkb;
+XkbGeometryPtr geom;
+
+ xkb= result->xkb;
+ if ((!xkb)||(!xkb->geom)) {
+ _XkbLibError(_XkbErrMissingGeometry,"XkbWriteXKBGeometry",0);
+ return False;
+ }
+ dpy= xkb->dpy;
+ geom= xkb->geom;
+ if (geom->name==None)
+ fprintf(file,"xkb_geometry {\n\n");
+ else fprintf(file,"xkb_geometry \"%s\" {\n\n",
+ XkbAtomText(dpy,geom->name,XkbXKBFile));
+ fprintf(file," width= %s;\n",
+ XkbGeomFPText(geom->width_mm,XkbXKBFile));
+ fprintf(file," height= %s;\n\n",
+ XkbGeomFPText(geom->height_mm,XkbXKBFile));
+
+ if (geom->key_aliases!=NULL) {
+ XkbKeyAliasPtr pAl;
+ pAl= geom->key_aliases;
+ for (i=0;i<geom->num_key_aliases;i++,pAl++) {
+ fprintf(file," alias %6s = %6s;\n",
+ XkbKeyNameText(pAl->alias,XkbXKBFile),
+ XkbKeyNameText(pAl->real,XkbXKBFile));
+ }
+ fprintf(file,"\n");
+ }
+
+ if (geom->base_color!=NULL)
+ fprintf(file," baseColor= \"%s\";\n",
+ XkbStringText(geom->base_color->spec,XkbXKBFile));
+ if (geom->label_color!=NULL)
+ fprintf(file," labelColor= \"%s\";\n",
+ XkbStringText(geom->label_color->spec,XkbXKBFile));
+ if (geom->label_font!=NULL)
+ fprintf(file," xfont= \"%s\";\n",
+ XkbStringText(geom->label_font,XkbXKBFile));
+ if ((geom->num_colors>0)&&(showImplicit)) {
+ XkbColorPtr color;
+ for (color=geom->colors,i=0;i<geom->num_colors;i++,color++) {
+ fprintf(file,"// color[%d]= \"%s\"\n",i,
+ XkbStringText(color->spec,XkbXKBFile));
+ }
+ fprintf(file,"\n");
+ }
+ if (geom->num_properties>0) {
+ XkbPropertyPtr prop;
+ for (prop=geom->properties,i=0;i<geom->num_properties;i++,prop++) {
+ fprintf(file," %s= \"%s\";\n",prop->name,
+ XkbStringText(prop->value,XkbXKBFile));
+ }
+ fprintf(file,"\n");
+ }
+ if (geom->num_shapes>0) {
+ XkbShapePtr shape;
+ XkbOutlinePtr outline;
+ int lastR;
+ for (shape=geom->shapes,i=0;i<geom->num_shapes;i++,shape++) {
+ lastR=0;
+ fprintf(file," shape \"%s\" {",
+ XkbAtomText(dpy,shape->name,XkbXKBFile));
+ outline= shape->outlines;
+ if (shape->num_outlines>1) {
+ for (n=0;n<shape->num_outlines;n++,outline++) {
+ if (n==0) fprintf(file,"\n");
+ else fprintf(file,",\n");
+ WriteXKBOutline(file,shape,outline,lastR,8,8);
+ lastR= outline->corner_radius;
+ }
+ fprintf(file,"\n };\n");
+ }
+ else {
+ WriteXKBOutline(file,NULL,outline,lastR,1,8);
+ fprintf(file," };\n");
+ }
+ }
+ }
+ if (geom->num_sections>0) {
+ XkbSectionPtr section;
+ for (section=geom->sections,i=0;i<geom->num_sections;i++,section++){
+ WriteXKBSection(file,dpy,section,geom);
+ }
+ }
+ if (geom->num_doodads>0) {
+ XkbDoodadPtr doodad;
+ for (i=0,doodad=geom->doodads;i<geom->num_doodads;i++,doodad++) {
+ WriteXKBDoodad(file,dpy,4,geom,doodad);
+ }
+ }
+ if (addOn)
+ (*addOn)(file,result,topLevel,showImplicit,XkmGeometryIndex,priv);
+ fprintf(file,"};\n\n");
+ return True;
+}
+
+/*ARGSUSED*/
+Bool
+XkbWriteXKBSemantics( FILE * file,
+ XkbFileInfo * result,
+ Bool topLevel,
+ Bool showImplicit,
+ XkbFileAddOnFunc addOn,
+ void * priv)
+{
+Bool ok;
+
+ fprintf(file,"xkb_semantics {\n");
+ ok= XkbWriteXKBKeyTypes(file,result,False,False,addOn,priv);
+ ok= ok&&XkbWriteXKBCompatMap(file,result,False,False,addOn,priv);
+ fprintf(file,"};\n");
+ return ok;
+}
+
+/*ARGSUSED*/
+Bool
+XkbWriteXKBLayout( FILE * file,
+ XkbFileInfo * result,
+ Bool topLevel,
+ Bool showImplicit,
+ XkbFileAddOnFunc addOn,
+ void * priv)
+{
+Bool ok;
+XkbDescPtr xkb;
+
+ xkb= result->xkb;
+ fprintf(file,"xkb_layout {\n");
+ ok= XkbWriteXKBKeycodes(file,result,False,showImplicit,addOn,priv);
+ ok= ok&&XkbWriteXKBKeyTypes(file,result,False,showImplicit,addOn,priv);
+ ok= ok&&XkbWriteXKBSymbols(file,result,False,showImplicit,addOn,priv);
+ if (xkb->geom)
+ ok= ok&&XkbWriteXKBGeometry(file,result,False,showImplicit,addOn,priv);
+ fprintf(file,"};\n");
+ return ok;
+}
+
+/*ARGSUSED*/
+Bool
+XkbWriteXKBKeymap( FILE * file,
+ XkbFileInfo * result,
+ Bool topLevel,
+ Bool showImplicit,
+ XkbFileAddOnFunc addOn,
+ void * priv)
+{
+Bool ok;
+XkbDescPtr xkb;
+
+ xkb= result->xkb;
+ fprintf(file,"xkb_keymap {\n");
+ ok= XkbWriteXKBKeycodes(file,result,False,showImplicit,addOn,priv);
+ ok= ok&&XkbWriteXKBKeyTypes(file,result,False,showImplicit,addOn,priv);
+ ok= ok&&XkbWriteXKBCompatMap(file,result,False,showImplicit,addOn,priv);
+ ok= ok&&XkbWriteXKBSymbols(file,result,False,showImplicit,addOn,priv);
+ if (xkb->geom)
+ ok= ok&&XkbWriteXKBGeometry(file,result,False,showImplicit,addOn,priv);
+ fprintf(file,"};\n");
+ return ok;
+}
+
+Bool
+XkbWriteXKBFile( FILE * out,
+ XkbFileInfo * result,
+ Bool showImplicit,
+ XkbFileAddOnFunc addOn,
+ void * priv)
+{
+Bool ok = False;
+Bool (*func)(
+ FILE * /* file */,
+ XkbFileInfo * /* result */,
+ Bool /* topLevel */,
+ Bool /* showImplicit */,
+ XkbFileAddOnFunc /* addOn */,
+ void * /* priv */
+) = NULL;
+
+ switch (result->type) {
+ case XkmSemanticsFile:
+ func= XkbWriteXKBSemantics;
+ break;
+ case XkmLayoutFile:
+ func= XkbWriteXKBLayout;
+ break;
+ case XkmKeymapFile:
+ func= XkbWriteXKBKeymap;
+ break;
+ case XkmTypesIndex:
+ func= XkbWriteXKBKeyTypes;
+ break;
+ case XkmCompatMapIndex:
+ func= XkbWriteXKBCompatMap;
+ break;
+ case XkmSymbolsIndex:
+ func= XkbWriteXKBSymbols;
+ break;
+ case XkmKeyNamesIndex:
+ func= XkbWriteXKBKeycodes;
+ break;
+ case XkmGeometryFile:
+ case XkmGeometryIndex:
+ func= XkbWriteXKBGeometry;
+ break;
+ case XkmVirtualModsIndex:
+ case XkmIndicatorsIndex:
+ _XkbLibError(_XkbErrBadImplementation,
+ XkbConfigText(result->type,XkbMessage),0);
+ return False;
+ }
+ if (out==NULL) {
+ _XkbLibError(_XkbErrFileCannotOpen,"XkbWriteXkbFile",0);
+ ok= False;
+ }
+ else if (func) {
+ ok= (*func)(out,result,True,showImplicit,addOn,priv);
+ }
+ return ok;
+}
diff --git a/nx-X11/lib/xkbfile/xkbtext.c b/nx-X11/lib/xkbfile/xkbtext.c
new file mode 100644
index 000000000..28592d242
--- /dev/null
+++ b/nx-X11/lib/xkbfile/xkbtext.c
@@ -0,0 +1,1440 @@
+/* $Xorg: xkbtext.c,v 1.3 2000/08/17 19:46:44 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkbtext.c,v 3.11 2002/12/21 18:49:02 paulo Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#elif defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#include <X11/Xos.h>
+
+#ifndef XKB_IN_SERVER
+
+#include <X11/Xlib.h>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKBgeom.h>
+
+#include "XKMformat.h"
+#include "XKBfileInt.h"
+
+#else
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include "dix.h"
+#include <X11/extensions/XKBstr.h>
+#define XKBSRV_NEED_FILE_FUNCS 1
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XKBgeom.h>
+
+#endif
+
+/***====================================================================***/
+
+#define BUFFER_SIZE 512
+
+static char textBuffer[BUFFER_SIZE];
+static int tbNext= 0;
+
+static char *
+tbGetBuffer(unsigned size)
+{
+char *rtrn;
+
+ if (size>=BUFFER_SIZE)
+ return NULL;
+ if ((BUFFER_SIZE-tbNext)<=size)
+ tbNext= 0;
+ rtrn= &textBuffer[tbNext];
+ tbNext+= size;
+ return rtrn;
+}
+
+/***====================================================================***/
+
+char *
+XkbAtomText(Display *dpy,Atom atm,unsigned format)
+{
+char *rtrn,*tmp;
+
+ tmp= XkbAtomGetString(dpy,atm);
+ if (tmp!=NULL) {
+ int len;
+ len= strlen(tmp)+1;
+ if (len>BUFFER_SIZE)
+ len= BUFFER_SIZE-2;
+ rtrn= tbGetBuffer(len);
+ strncpy(rtrn,tmp,len);
+ rtrn[len]= '\0';
+ }
+ else {
+ rtrn= tbGetBuffer(1);
+ rtrn[0]= '\0';
+ }
+ if (format==XkbCFile) {
+ for (tmp=rtrn;*tmp!='\0';tmp++) {
+ if ((tmp==rtrn)&&(!isalpha(*tmp)))
+ *tmp= '_';
+ else if (!isalnum(*tmp))
+ *tmp= '_';
+ }
+ }
+ return XkbStringText(rtrn,format);
+}
+
+/***====================================================================***/
+
+char *
+XkbVModIndexText(Display *dpy,XkbDescPtr xkb,unsigned ndx,unsigned format)
+{
+register int len;
+register Atom *vmodNames;
+char *rtrn,*tmp;
+char numBuf[20];
+
+ if (xkb && xkb->names)
+ vmodNames= xkb->names->vmods;
+ else vmodNames= NULL;
+
+ tmp= NULL;
+ if (ndx>=XkbNumVirtualMods)
+ tmp= "illegal";
+ else if (vmodNames&&(vmodNames[ndx]!=None))
+ tmp= XkbAtomGetString(dpy,vmodNames[ndx]);
+ if (tmp==NULL)
+ sprintf(tmp=numBuf,"%d",ndx);
+
+ len= strlen(tmp)+1;
+ if (format==XkbCFile)
+ len+= 4;
+ if (len>=BUFFER_SIZE)
+ len= BUFFER_SIZE-1;
+ rtrn= tbGetBuffer(len);
+ if (format==XkbCFile) {
+ strcpy(rtrn,"vmod_");
+ strncpy(&rtrn[5],tmp,len-4);
+ }
+ else strncpy(rtrn,tmp,len);
+ return rtrn;
+}
+
+char *
+XkbVModMaskText( Display * dpy,
+ XkbDescPtr xkb,
+ unsigned modMask,
+ unsigned mask,
+ unsigned format)
+{
+register int i,bit;
+int len;
+char *mm,*rtrn;
+char *str,buf[BUFFER_SIZE];
+
+ if ((modMask==0)&&(mask==0)) {
+ rtrn= tbGetBuffer(5);
+ if (format==XkbCFile)
+ sprintf(rtrn,"0");
+ else sprintf(rtrn,"none");
+ return rtrn;
+ }
+ if (modMask!=0)
+ mm= XkbModMaskText(modMask,format);
+ else mm= NULL;
+
+ str= buf;
+ buf[0]= '\0';
+ if (mask) {
+ char *tmp;
+ for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (mask&bit) {
+ tmp= XkbVModIndexText(dpy,xkb,i,format);
+ len= strlen(tmp)+1+(str==buf?0:1);
+ if (format==XkbCFile)
+ len+= 4;
+ if ((str-(buf+len))<=BUFFER_SIZE) {
+ if (str!=buf) {
+ if (format==XkbCFile) *str++= '|';
+ else *str++= '+';
+ len--;
+ }
+ }
+ if (format==XkbCFile)
+ sprintf(str,"%sMask",tmp);
+ else strcpy(str,tmp);
+ str= &str[len-1];
+ }
+ }
+ str= buf;
+ }
+ else str= NULL;
+ if (mm)
+ len= strlen(mm);
+ else len= 0;
+ if (str)
+ len+= strlen(str)+(mm==NULL?0:1);
+ if (len>=BUFFER_SIZE)
+ len= BUFFER_SIZE-1;
+ rtrn= tbGetBuffer(len+1);
+ rtrn[0]= '\0';
+
+ if (mm!=NULL) {
+ i= strlen(mm);
+ if (i>len)
+ i= len;
+ strcpy(rtrn,mm);
+ }
+ else {
+ i=0;
+ }
+ if (str!=NULL) {
+ if (mm!=NULL) {
+ if (format==XkbCFile) strcat(rtrn,"|");
+ else strcat(rtrn,"+");
+ }
+ strncat(rtrn,str,len-i);
+ }
+ rtrn[len]= '\0';
+ return rtrn;
+}
+
+static char *modNames[XkbNumModifiers] = {
+ "Shift", "Lock", "Control", "Mod1", "Mod2", "Mod3", "Mod4", "Mod5"
+};
+
+char *
+XkbModIndexText(unsigned ndx,unsigned format)
+{
+char * rtrn;
+char buf[100];
+
+ if (format==XkbCFile) {
+ if (ndx<XkbNumModifiers)
+ sprintf(buf,"%sMapIndex",modNames[ndx]);
+ else if (ndx==XkbNoModifier)
+ sprintf(buf,"XkbNoModifier");
+ else sprintf(buf,"0x%02x",ndx);
+ }
+ else {
+ if (ndx<XkbNumModifiers)
+ strcpy(buf,modNames[ndx]);
+ else if (ndx==XkbNoModifier)
+ strcpy(buf,"none");
+ else sprintf(buf,"ILLEGAL_%02x",ndx);
+ }
+ rtrn= tbGetBuffer(strlen(buf)+1);
+ strcpy(rtrn,buf);
+ return rtrn;
+}
+
+char *
+XkbModMaskText(unsigned mask,unsigned format)
+{
+register int i,bit;
+char buf[64],*rtrn;
+
+ if ((mask&0xff)==0xff) {
+ if (format==XkbCFile) strcpy(buf,"0xff");
+ else strcpy(buf,"all");
+ }
+ else if ((mask&0xff)==0) {
+ if (format==XkbCFile) strcpy(buf,"0");
+ else strcpy(buf,"none");
+ }
+ else {
+ char *str= buf;
+ buf[0]= '\0';
+ for (i=0,bit=1;i<XkbNumModifiers;i++,bit<<=1) {
+ if (mask&bit) {
+ if (str!=buf) {
+ if (format==XkbCFile) *str++= '|';
+ else *str++= '+';
+ }
+ strcpy(str,modNames[i]);
+ str= &str[strlen(str)];
+ if (format==XkbCFile) {
+ strcpy(str,"Mask");
+ str+= 4;
+ }
+ }
+ }
+ }
+ rtrn= tbGetBuffer(strlen(buf)+1);
+ strcpy(rtrn,buf);
+ return rtrn;
+}
+
+/***====================================================================***/
+
+/*ARGSUSED*/
+char *
+XkbConfigText(unsigned config,unsigned format)
+{
+static char *buf;
+
+ buf= tbGetBuffer(32);
+ switch (config) {
+ case XkmSemanticsFile:
+ strcpy(buf,"Semantics");
+ break;
+ case XkmLayoutFile:
+ strcpy(buf,"Layout");
+ break;
+ case XkmKeymapFile:
+ strcpy(buf,"Keymap");
+ break;
+ case XkmGeometryFile:
+ case XkmGeometryIndex:
+ strcpy(buf,"Geometry");
+ break;
+ case XkmTypesIndex:
+ strcpy(buf,"Types");
+ break;
+ case XkmCompatMapIndex:
+ strcpy(buf,"CompatMap");
+ break;
+ case XkmSymbolsIndex:
+ strcpy(buf,"Symbols");
+ break;
+ case XkmIndicatorsIndex:
+ strcpy(buf,"Indicators");
+ break;
+ case XkmKeyNamesIndex:
+ strcpy(buf,"KeyNames");
+ break;
+ case XkmVirtualModsIndex:
+ strcpy(buf,"VirtualMods");
+ break;
+ default:
+ sprintf(buf,"unknown(%d)",config);
+ break;
+ }
+ return buf;
+}
+
+/***====================================================================***/
+
+char *
+XkbKeysymText(KeySym sym,unsigned format)
+{
+static char buf[32],*rtrn;
+
+#ifndef XKB_IN_SERVER
+ if (sym==NoSymbol)
+ strcpy(rtrn=buf,"NoSymbol");
+ else if ((rtrn=XKeysymToString(sym))==NULL)
+ sprintf(rtrn=buf, "0x%lx", (long)sym);
+ else if (format==XkbCFile) {
+ sprintf(buf,"XK_%s",rtrn);
+ rtrn= buf;
+ }
+ return rtrn;
+#else /* def XKB_IN_SERVER */
+ if (sym==NoSymbol)
+ strcpy(rtrn=buf,"NoSymbol");
+ else sprintf(rtrn=buf, "0x%lx", (long)sym);
+ return rtrn;
+#endif /* XKB_IN_SERVER */
+}
+
+char *
+XkbKeyNameText(char *name,unsigned format)
+{
+char *buf;
+
+ if (format==XkbCFile) {
+ buf= tbGetBuffer(5);
+ memcpy(buf,name,4);
+ buf[4]= '\0';
+ }
+ else {
+ int len;
+ buf= tbGetBuffer(7);
+ buf[0]= '<';
+ memcpy(&buf[1],name,4);
+ buf[5]= '\0';
+ len= strlen(buf);
+ buf[len++]= '>';
+ buf[len]= '\0';
+ }
+ return buf;
+}
+
+/***====================================================================***/
+
+static char *siMatchText[5] = {
+ "NoneOf", "AnyOfOrNone", "AnyOf", "AllOf", "Exactly"
+};
+
+char *
+XkbSIMatchText(unsigned type,unsigned format)
+{
+static char buf[40];
+char *rtrn;
+
+ switch (type&XkbSI_OpMask) {
+ case XkbSI_NoneOf: rtrn= siMatchText[0]; break;
+ case XkbSI_AnyOfOrNone: rtrn= siMatchText[1]; break;
+ case XkbSI_AnyOf: rtrn= siMatchText[2]; break;
+ case XkbSI_AllOf: rtrn= siMatchText[3]; break;
+ case XkbSI_Exactly: rtrn= siMatchText[4]; break;
+ default: sprintf(buf,"0x%x",type&XkbSI_OpMask);
+ return buf;
+ }
+ if (format==XkbCFile) {
+ if (type&XkbSI_LevelOneOnly)
+ sprintf(buf,"XkbSI_LevelOneOnly|XkbSI_%s",rtrn);
+ else sprintf(buf,"XkbSI_%s",rtrn);
+ rtrn= buf;
+ }
+ return rtrn;
+}
+
+/***====================================================================***/
+
+static char *imWhichNames[]= {
+ "base",
+ "latched",
+ "locked",
+ "effective",
+ "compat"
+};
+
+char *
+XkbIMWhichStateMaskText(unsigned use_which,unsigned format)
+{
+int len;
+unsigned i,bit,tmp;
+char * buf;
+
+ if (use_which==0) {
+ buf= tbGetBuffer(2);
+ strcpy(buf,"0");
+ return buf;
+ }
+ tmp= use_which&XkbIM_UseAnyMods;
+ for (len=i=0,bit=1;tmp!=0;i++,bit<<=1) {
+ if (tmp&bit) {
+ tmp&= ~bit;
+ len+= strlen(imWhichNames[i])+1;
+ if (format==XkbCFile)
+ len+= 9;
+ }
+ }
+ buf= tbGetBuffer(len+1);
+ tmp= use_which&XkbIM_UseAnyMods;
+ for (len=i=0,bit=1;tmp!=0;i++,bit<<=1) {
+ if (tmp&bit) {
+ tmp&= ~bit;
+ if (format==XkbCFile) {
+ if (len!=0)
+ buf[len++]= '|';
+ sprintf(&buf[len],"XkbIM_Use%s",imWhichNames[i]);
+ buf[len+9]= toupper(buf[len+9]);
+ }
+ else {
+ if (len!=0)
+ buf[len++]= '+';
+ sprintf(&buf[len],"%s",imWhichNames[i]);
+ }
+ len+= strlen(&buf[len]);
+ }
+ }
+ return buf;
+}
+
+char *
+XkbAccessXDetailText(unsigned state,unsigned format)
+{
+char *buf,*prefix;
+
+ buf= tbGetBuffer(32);
+ if (format==XkbMessage) prefix= "";
+ else prefix= "XkbAXN_";
+ switch (state){
+ case XkbAXN_SKPress: sprintf(buf,"%sSKPress",prefix); break;
+ case XkbAXN_SKAccept: sprintf(buf,"%sSKAccept",prefix); break;
+ case XkbAXN_SKRelease: sprintf(buf,"%sSKRelease",prefix); break;
+ case XkbAXN_SKReject: sprintf(buf,"%sSKReject",prefix); break;
+ case XkbAXN_BKAccept: sprintf(buf,"%sBKAccept",prefix); break;
+ case XkbAXN_BKReject: sprintf(buf,"%sBKReject",prefix); break;
+ case XkbAXN_AXKWarning: sprintf(buf,"%sAXKWarning",prefix); break;
+ default: sprintf(buf,"ILLEGAL"); break;
+ }
+ return buf;
+}
+
+static char *nknNames[] = {
+ "keycodes", "geometry", "deviceID"
+};
+#define NUM_NKN (sizeof(nknNames)/sizeof(char *))
+
+char *
+XkbNKNDetailMaskText(unsigned detail,unsigned format)
+{
+char *buf,*prefix,*suffix;
+register int i;
+register unsigned bit;
+int len,plen,slen;
+
+
+ if ((detail&XkbAllNewKeyboardEventsMask)==0) {
+ char *tmp = "";
+ if (format==XkbCFile) tmp= "0";
+ else if (format==XkbMessage) tmp= "none";
+ buf= tbGetBuffer(strlen(tmp)+1);
+ strcpy(buf,tmp);
+ return buf;
+ }
+ else if ((detail&XkbAllNewKeyboardEventsMask)==XkbAllNewKeyboardEventsMask){
+ char * tmp;
+ if (format==XkbCFile) tmp= "XkbAllNewKeyboardEventsMask";
+ else tmp= "all";
+ buf= tbGetBuffer(strlen(tmp)+1);
+ strcpy(buf,tmp);
+ return buf;
+ }
+ if (format==XkbMessage) {
+ prefix= "";
+ suffix= "";
+ slen= plen= 0;
+ }
+ else {
+ prefix= "XkbNKN_";
+ plen= 7;
+ if (format==XkbCFile)
+ suffix= "Mask";
+ else suffix= "";
+ slen= strlen(suffix);
+ }
+ for (len=0,i=0,bit=1;i<NUM_NKN;i++,bit<<=1) {
+ if (detail&bit) {
+ if (len!=0) len+= 1; /* room for '+' or '|' */
+ len+= plen+slen+strlen(nknNames[i]);
+ }
+ }
+ buf= tbGetBuffer(len+1);
+ buf[0]= '\0';
+ for (len=0,i=0,bit=1;i<NUM_NKN;i++,bit<<=1) {
+ if (detail&bit) {
+ if (len!=0) {
+ if (format==XkbCFile) buf[len++]= '|';
+ else buf[len++]= '+';
+ }
+ if (plen) {
+ strcpy(&buf[len],prefix);
+ len+= plen;
+ }
+ strcpy(&buf[len],nknNames[i]);
+ len+= strlen(nknNames[i]);
+ if (slen) {
+ strcpy(&buf[len],suffix);
+ len+= slen;
+ }
+ }
+ }
+ buf[len++]= '\0';
+ return buf;
+}
+
+static char *ctrlNames[] = {
+ "repeatKeys",
+ "slowKeys",
+ "bounceKeys",
+ "stickyKeys",
+ "mouseKeys",
+ "mouseKeysAccel",
+ "accessXKeys",
+ "accessXTimeout",
+ "accessXFeedback",
+ "audibleBell",
+ "overlay1",
+ "overlay2",
+ "ignoreGroupLock"
+};
+
+char *
+XkbControlsMaskText(unsigned ctrls,unsigned format)
+{
+int len;
+unsigned i,bit,tmp;
+char * buf;
+
+ if (ctrls==0) {
+ buf= tbGetBuffer(5);
+ if (format==XkbCFile)
+ strcpy(buf,"0");
+ else strcpy(buf,"none");
+ return buf;
+ }
+ tmp= ctrls&XkbAllBooleanCtrlsMask;
+ for (len=i=0,bit=1;tmp!=0;i++,bit<<=1) {
+ if (tmp&bit) {
+ tmp&= ~bit;
+ len+= strlen(ctrlNames[i])+1;
+ if (format==XkbCFile)
+ len+= 7;
+ }
+ }
+ buf= tbGetBuffer(len+1);
+ tmp= ctrls&XkbAllBooleanCtrlsMask;
+ for (len=i=0,bit=1;tmp!=0;i++,bit<<=1) {
+ if (tmp&bit) {
+ tmp&= ~bit;
+ if (format==XkbCFile) {
+ if (len!=0)
+ buf[len++]= '|';
+ sprintf(&buf[len],"Xkb%sMask",ctrlNames[i]);
+ buf[len+3]= toupper(buf[len+3]);
+ }
+ else {
+ if (len!=0)
+ buf[len++]= '+';
+ sprintf(&buf[len],"%s",ctrlNames[i]);
+ }
+ len+= strlen(&buf[len]);
+ }
+ }
+ return buf;
+}
+
+/***====================================================================***/
+
+char *
+XkbStringText(char *str,unsigned format)
+{
+char * buf;
+register char *in,*out;
+int len;
+Bool ok;
+
+ if (str==NULL) {
+ buf= tbGetBuffer(2);
+ buf[0]='\0';
+ return buf;
+ }
+ else if (format==XkbXKMFile)
+ return str;
+ for (ok= True,len=0,in=str;*in!='\0';in++,len++) {
+ if (!isprint(*in)) {
+ ok= False;
+ switch (*in) {
+ case '\n': case '\t': case '\v':
+ case '\b': case '\r': case '\f':
+ len++;
+ break;
+ default:
+ len+= 4;
+ break;
+ }
+ }
+ }
+ if (ok)
+ return str;
+ buf= tbGetBuffer(len+1);
+ for (in=str,out=buf;*in!='\0';in++) {
+ if (isprint(*in))
+ *out++= *in;
+ else {
+ *out++= '\\';
+ if (*in=='\n') *out++= 'n';
+ else if (*in=='\t') *out++= 't';
+ else if (*in=='\v') *out++= 'v';
+ else if (*in=='\b') *out++= 'b';
+ else if (*in=='\r') *out++= 'r';
+ else if (*in=='\f') *out++= 'f';
+ else if ((*in=='\033')&&(format==XkbXKMFile)) {
+ *out++= 'e';
+ }
+ else {
+ *out++= '0';
+ sprintf(out,"%o",*in);
+ while (*out!='\0')
+ out++;
+ }
+ }
+ }
+ *out++= '\0';
+ return buf;
+}
+
+/***====================================================================***/
+
+char *
+XkbGeomFPText(int val,unsigned format)
+{
+int whole,frac;
+char * buf;
+
+ buf= tbGetBuffer(12);
+ if (format==XkbCFile) {
+ sprintf(buf,"%d",val);
+ }
+ else {
+ whole= val/XkbGeomPtsPerMM;
+ frac= val%XkbGeomPtsPerMM;
+ if (frac!=0)
+ sprintf(buf,"%d.%d",whole,frac);
+ else sprintf(buf,"%d",whole);
+ }
+ return buf;
+}
+
+char *
+XkbDoodadTypeText(unsigned type,unsigned format)
+{
+char * buf;
+ if (format==XkbCFile) {
+ buf= tbGetBuffer(24);
+ if (type==XkbOutlineDoodad) strcpy(buf,"XkbOutlineDoodad");
+ else if (type==XkbSolidDoodad) strcpy(buf,"XkbSolidDoodad");
+ else if (type==XkbTextDoodad) strcpy(buf,"XkbTextDoodad");
+ else if (type==XkbIndicatorDoodad) strcpy(buf,"XkbIndicatorDoodad");
+ else if (type==XkbLogoDoodad) strcpy(buf,"XkbLogoDoodad");
+ else sprintf(buf,"UnknownDoodad%d",type);
+ }
+ else {
+ buf= tbGetBuffer(12);
+ if (type==XkbOutlineDoodad) strcpy(buf,"outline");
+ else if (type==XkbSolidDoodad) strcpy(buf,"solid");
+ else if (type==XkbTextDoodad) strcpy(buf,"text");
+ else if (type==XkbIndicatorDoodad) strcpy(buf,"indicator");
+ else if (type==XkbLogoDoodad) strcpy(buf,"logo");
+ else sprintf(buf,"unknown%d",type);
+ }
+ return buf;
+}
+
+static char *actionTypeNames[XkbSA_NumActions]= {
+ "NoAction",
+ "SetMods", "LatchMods", "LockMods",
+ "SetGroup", "LatchGroup", "LockGroup",
+ "MovePtr",
+ "PtrBtn", "LockPtrBtn",
+ "SetPtrDflt",
+ "ISOLock",
+ "Terminate", "SwitchScreen",
+ "SetControls", "LockControls",
+ "ActionMessage",
+ "RedirectKey",
+ "DeviceBtn", "LockDeviceBtn"
+};
+
+char *
+XkbActionTypeText(unsigned type,unsigned format)
+{
+static char buf[32];
+char *rtrn;
+
+ if (type<=XkbSA_LastAction) {
+ rtrn= actionTypeNames[type];
+ if (format==XkbCFile) {
+ sprintf(buf,"XkbSA_%s",rtrn);
+ return buf;
+ }
+ return rtrn;
+ }
+ sprintf(buf,"Private");
+ return buf;
+}
+
+/***====================================================================***/
+
+static int
+TryCopyStr(char *to,char *from,int *pLeft)
+{
+register int len;
+ if (*pLeft>0) {
+ len= strlen(from);
+ if (len<((*pLeft)-3)) {
+ strcat(to,from);
+ *pLeft-= len;
+ return True;
+ }
+ }
+ *pLeft= -1;
+ return False;
+}
+
+/*ARGSUSED*/
+static Bool
+CopyNoActionArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,int*sz)
+{
+ return True;
+}
+
+static Bool
+CopyModActionArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,
+ int* sz)
+{
+XkbModAction * act;
+unsigned tmp;
+
+ act= &action->mods;
+ tmp= XkbModActionVMods(act);
+ TryCopyStr(buf,"modifiers=",sz);
+ if (act->flags&XkbSA_UseModMapMods)
+ TryCopyStr(buf,"modMapMods",sz);
+ else if (act->real_mods || tmp) {
+ TryCopyStr(buf,
+ XkbVModMaskText(dpy,xkb,act->real_mods,tmp,XkbXKBFile),
+ sz);
+ }
+ else TryCopyStr(buf,"none",sz);
+ if (act->type==XkbSA_LockMods)
+ return True;
+ if (act->flags&XkbSA_ClearLocks)
+ TryCopyStr(buf,",clearLocks",sz);
+ if (act->flags&XkbSA_LatchToLock)
+ TryCopyStr(buf,",latchToLock",sz);
+ return True;
+}
+
+/*ARGSUSED*/
+static Bool
+CopyGroupActionArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,
+ int *sz)
+{
+XkbGroupAction * act;
+char tbuf[32];
+
+ act= &action->group;
+ TryCopyStr(buf,"group=",sz);
+ if (act->flags&XkbSA_GroupAbsolute)
+ sprintf(tbuf,"%d",XkbSAGroup(act)+1);
+ else if (XkbSAGroup(act)<0)
+ sprintf(tbuf,"%d",XkbSAGroup(act));
+ else sprintf(tbuf,"+%d",XkbSAGroup(act));
+ TryCopyStr(buf,tbuf,sz);
+ if (act->type==XkbSA_LockGroup)
+ return True;
+ if (act->flags&XkbSA_ClearLocks)
+ TryCopyStr(buf,",clearLocks",sz);
+ if (act->flags&XkbSA_LatchToLock)
+ TryCopyStr(buf,",latchToLock",sz);
+ return True;
+}
+
+/*ARGSUSED*/
+static Bool
+CopyMovePtrArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,int *sz)
+{
+XkbPtrAction * act;
+int x,y;
+char tbuf[32];
+
+ act= &action->ptr;
+ x= XkbPtrActionX(act);
+ y= XkbPtrActionY(act);
+ if ((act->flags&XkbSA_MoveAbsoluteX)||(x<0))
+ sprintf(tbuf,"x=%d",x);
+ else sprintf(tbuf,"x=+%d",x);
+ TryCopyStr(buf,tbuf,sz);
+
+ if ((act->flags&XkbSA_MoveAbsoluteY)||(y<0))
+ sprintf(tbuf,",y=%d",y);
+ else sprintf(tbuf,",y=+%d",y);
+ TryCopyStr(buf,tbuf,sz);
+ if (act->flags&XkbSA_NoAcceleration)
+ TryCopyStr(buf,",!accel",sz);
+ return True;
+}
+
+/*ARGSUSED*/
+static Bool
+CopyPtrBtnArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,int *sz)
+{
+XkbPtrBtnAction * act;
+char tbuf[32];
+
+ act= &action->btn;
+ TryCopyStr(buf,"button=",sz);
+ if ((act->button>0)&&(act->button<6)) {
+ sprintf(tbuf,"%d",act->button);
+ TryCopyStr(buf,tbuf,sz);
+ }
+ else TryCopyStr(buf,"default",sz);
+ if (act->count>0) {
+ sprintf(tbuf,",count=%d",act->count);
+ TryCopyStr(buf,tbuf,sz);
+ }
+ if (action->type==XkbSA_LockPtrBtn) {
+ switch (act->flags&(XkbSA_LockNoUnlock|XkbSA_LockNoLock)) {
+ case XkbSA_LockNoLock:
+ sprintf(tbuf,",affect=unlock"); break;
+ case XkbSA_LockNoUnlock:
+ sprintf(tbuf,",affect=lock"); break;
+ case XkbSA_LockNoUnlock|XkbSA_LockNoLock:
+ sprintf(tbuf,",affect=neither"); break;
+ default:
+ sprintf(tbuf,",affect=both"); break;
+ }
+ TryCopyStr(buf,tbuf,sz);
+ }
+ return True;
+}
+
+/*ARGSUSED*/
+static Bool
+CopySetPtrDfltArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,
+ int *sz)
+{
+XkbPtrDfltAction * act;
+char tbuf[32];
+
+ act= &action->dflt;
+ if (act->affect==XkbSA_AffectDfltBtn) {
+ TryCopyStr(buf,"affect=button,button=",sz);
+ if ((act->flags&XkbSA_DfltBtnAbsolute)||(XkbSAPtrDfltValue(act)<0))
+ sprintf(tbuf,"%d",XkbSAPtrDfltValue(act));
+ else sprintf(tbuf,"+%d",XkbSAPtrDfltValue(act));
+ TryCopyStr(buf,tbuf,sz);
+ }
+ return True;
+}
+
+static Bool
+CopyISOLockArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,int *sz)
+{
+XkbISOAction * act;
+char tbuf[64];
+
+ act= &action->iso;
+ if (act->flags&XkbSA_ISODfltIsGroup) {
+ TryCopyStr(tbuf,"group=",sz);
+ if (act->flags&XkbSA_GroupAbsolute)
+ sprintf(tbuf,"%d",XkbSAGroup(act)+1);
+ else if (XkbSAGroup(act)<0)
+ sprintf(tbuf,"%d",XkbSAGroup(act));
+ else sprintf(tbuf,"+%d",XkbSAGroup(act));
+ TryCopyStr(buf,tbuf,sz);
+ }
+ else {
+ unsigned tmp;
+ tmp= XkbModActionVMods(act);
+ TryCopyStr(buf,"modifiers=",sz);
+ if (act->flags&XkbSA_UseModMapMods)
+ TryCopyStr(buf,"modMapMods",sz);
+ else if (act->real_mods || tmp) {
+ if (act->real_mods) {
+ TryCopyStr(buf,XkbModMaskText(act->real_mods,XkbXKBFile),sz);
+ if (tmp)
+ TryCopyStr(buf,"+",sz);
+ }
+ if (tmp)
+ TryCopyStr(buf,XkbVModMaskText(dpy,xkb,0,tmp,XkbXKBFile),sz);
+ }
+ else TryCopyStr(buf,"none",sz);
+ }
+ TryCopyStr(buf,",affect=",sz);
+ if ((act->affect&XkbSA_ISOAffectMask)==0)
+ TryCopyStr(buf,"all",sz);
+ else {
+ int nOut= 0;
+ if ((act->affect&XkbSA_ISONoAffectMods)==0) {
+ TryCopyStr(buf,"mods",sz);
+ nOut++;
+ }
+ if ((act->affect&XkbSA_ISONoAffectGroup)==0) {
+ sprintf(tbuf,"%sgroups",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if ((act->affect&XkbSA_ISONoAffectPtr)==0) {
+ sprintf(tbuf,"%spointer",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if ((act->affect&XkbSA_ISONoAffectCtrls)==0) {
+ sprintf(tbuf,"%scontrols",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ }
+ return True;
+}
+
+/*ARGSUSED*/
+static Bool
+CopySwitchScreenArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,
+ int *sz)
+{
+XkbSwitchScreenAction * act;
+char tbuf[32];
+
+ act= &action->screen;
+ if ((act->flags&XkbSA_SwitchAbsolute)||(XkbSAScreen(act)<0))
+ sprintf(tbuf,"screen=%d",XkbSAScreen(act));
+ else sprintf(tbuf,"screen=+%d",XkbSAScreen(act));
+ TryCopyStr(buf,tbuf,sz);
+ if (act->flags&XkbSA_SwitchApplication)
+ TryCopyStr(buf,",!same",sz);
+ else TryCopyStr(buf,",same",sz);
+ return True;
+}
+
+/*ARGSUSED*/
+static Bool
+CopySetLockControlsArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,
+ char *buf,int *sz)
+{
+XkbCtrlsAction * act;
+unsigned tmp;
+char tbuf[32];
+
+ act= &action->ctrls;
+ tmp= XkbActionCtrls(act);
+ TryCopyStr(buf,"controls=",sz);
+ if (tmp==0)
+ TryCopyStr(buf,"none",sz);
+ else if ((tmp&XkbAllBooleanCtrlsMask)==XkbAllBooleanCtrlsMask)
+ TryCopyStr(buf,"all",sz);
+ else {
+ int nOut= 0;
+ if (tmp&XkbRepeatKeysMask) {
+ sprintf(tbuf,"%sRepeatKeys",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if (tmp&XkbSlowKeysMask) {
+ sprintf(tbuf,"%sSlowKeys",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if (tmp&XkbBounceKeysMask) {
+ sprintf(tbuf,"%sBounceKeys",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if (tmp&XkbStickyKeysMask) {
+ sprintf(tbuf,"%sStickyKeys",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if (tmp&XkbMouseKeysMask) {
+ sprintf(tbuf,"%sMouseKeys",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if (tmp&XkbMouseKeysAccelMask) {
+ sprintf(tbuf,"%sMouseKeysAccel",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if (tmp&XkbAccessXKeysMask) {
+ sprintf(tbuf,"%sAccessXKeys",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if (tmp&XkbAccessXTimeoutMask) {
+ sprintf(tbuf,"%sAccessXTimeout",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if (tmp&XkbAccessXFeedbackMask) {
+ sprintf(tbuf,"%sAccessXFeedback",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if (tmp&XkbAudibleBellMask) {
+ sprintf(tbuf,"%sAudibleBell",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if (tmp&XkbOverlay1Mask) {
+ sprintf(tbuf,"%sOverlay1",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if (tmp&XkbOverlay2Mask) {
+ sprintf(tbuf,"%sOverlay2",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ if (tmp&XkbIgnoreGroupLockMask) {
+ sprintf(tbuf,"%sIgnoreGroupLock",(nOut>0?"+":""));
+ TryCopyStr(buf,tbuf,sz);
+ nOut++;
+ }
+ }
+ return True;
+}
+
+/*ARGSUSED*/
+static Bool
+CopyActionMessageArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,
+ int *sz)
+{
+XkbMessageAction * act;
+unsigned all;
+char tbuf[32];
+
+ act= &action->msg;
+ all= XkbSA_MessageOnPress|XkbSA_MessageOnRelease;
+ TryCopyStr(buf,"report=",sz);
+ if ((act->flags&all)==0)
+ TryCopyStr(buf,"none",sz);
+ else if ((act->flags&all)==all)
+ TryCopyStr(buf,"all",sz);
+ else if (act->flags&XkbSA_MessageOnPress)
+ TryCopyStr(buf,"KeyPress",sz);
+ else TryCopyStr(buf,"KeyRelease",sz);
+ sprintf(tbuf,",data[0]=0x%02x",act->message[0]); TryCopyStr(buf,tbuf,sz);
+ sprintf(tbuf,",data[1]=0x%02x",act->message[1]); TryCopyStr(buf,tbuf,sz);
+ sprintf(tbuf,",data[2]=0x%02x",act->message[2]); TryCopyStr(buf,tbuf,sz);
+ sprintf(tbuf,",data[3]=0x%02x",act->message[3]); TryCopyStr(buf,tbuf,sz);
+ sprintf(tbuf,",data[4]=0x%02x",act->message[4]); TryCopyStr(buf,tbuf,sz);
+ sprintf(tbuf,",data[5]=0x%02x",act->message[5]); TryCopyStr(buf,tbuf,sz);
+ return True;
+}
+
+static Bool
+CopyRedirectKeyArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,
+ int *sz)
+{
+XkbRedirectKeyAction * act;
+char tbuf[32],*tmp;
+unsigned kc;
+unsigned vmods,vmods_mask;
+
+ act= &action->redirect;
+ kc= act->new_key;
+ vmods= XkbSARedirectVMods(act);
+ vmods_mask= XkbSARedirectVModsMask(act);
+ if (xkb && xkb->names && xkb->names->keys && (kc<=xkb->max_key_code) &&
+ (xkb->names->keys[kc].name[0]!='\0')) {
+ char *kn;
+ kn= XkbKeyNameText(xkb->names->keys[kc].name,XkbXKBFile);
+ sprintf(tbuf,"key=%s",kn);
+ }
+ else sprintf(tbuf,"key=%d",kc);
+ TryCopyStr(buf,tbuf,sz);
+ if ((act->mods_mask==0)&&(vmods_mask==0))
+ return True;
+ if ((act->mods_mask==XkbAllModifiersMask)&&
+ (vmods_mask==XkbAllVirtualModsMask)) {
+ tmp= XkbVModMaskText(dpy,xkb,act->mods,vmods,XkbXKBFile);
+ TryCopyStr(buf,",mods=",sz);
+ TryCopyStr(buf,tmp,sz);
+ }
+ else {
+ if ((act->mods_mask&act->mods)||(vmods_mask&vmods)) {
+ tmp= XkbVModMaskText(dpy,xkb,act->mods_mask&act->mods,
+ vmods_mask&vmods,XkbXKBFile);
+ TryCopyStr(buf,",mods= ",sz);
+ TryCopyStr(buf,tmp,sz);
+ }
+ if ((act->mods_mask&(~act->mods))||(vmods_mask&(~vmods))) {
+ tmp= XkbVModMaskText(dpy,xkb,act->mods_mask&(~act->mods),
+ vmods_mask&(~vmods),XkbXKBFile);
+ TryCopyStr(buf,",clearMods= ",sz);
+ TryCopyStr(buf,tmp,sz);
+ }
+ }
+ return True;
+}
+
+/*ARGSUSED*/
+static Bool
+CopyDeviceBtnArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,
+ int *sz)
+{
+XkbDeviceBtnAction * act;
+char tbuf[32];
+
+ act= &action->devbtn;
+ sprintf(tbuf,"device= %d",act->device); TryCopyStr(buf,tbuf,sz);
+ TryCopyStr(buf,",button=",sz);
+ sprintf(tbuf,"%d",act->button);
+ TryCopyStr(buf,tbuf,sz);
+ if (act->count>0) {
+ sprintf(tbuf,",count=%d",act->count);
+ TryCopyStr(buf,tbuf,sz);
+ }
+ if (action->type==XkbSA_LockDeviceBtn) {
+ switch (act->flags&(XkbSA_LockNoUnlock|XkbSA_LockNoLock)) {
+ case XkbSA_LockNoLock:
+ sprintf(tbuf,",affect=unlock"); break;
+ case XkbSA_LockNoUnlock:
+ sprintf(tbuf,",affect=lock"); break;
+ case XkbSA_LockNoUnlock|XkbSA_LockNoLock:
+ sprintf(tbuf,",affect=neither"); break;
+ default:
+ sprintf(tbuf,",affect=both"); break;
+ }
+ TryCopyStr(buf,tbuf,sz);
+ }
+ return True;
+}
+
+/*ARGSUSED*/
+static Bool
+CopyOtherArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,int *sz)
+{
+XkbAnyAction * act;
+char tbuf[32];
+
+ act= &action->any;
+ sprintf(tbuf,"type=0x%02x",act->type); TryCopyStr(buf,tbuf,sz);
+ sprintf(tbuf,",data[0]=0x%02x",act->data[0]); TryCopyStr(buf,tbuf,sz);
+ sprintf(tbuf,",data[1]=0x%02x",act->data[1]); TryCopyStr(buf,tbuf,sz);
+ sprintf(tbuf,",data[2]=0x%02x",act->data[2]); TryCopyStr(buf,tbuf,sz);
+ sprintf(tbuf,",data[3]=0x%02x",act->data[3]); TryCopyStr(buf,tbuf,sz);
+ sprintf(tbuf,",data[4]=0x%02x",act->data[4]); TryCopyStr(buf,tbuf,sz);
+ sprintf(tbuf,",data[5]=0x%02x",act->data[5]); TryCopyStr(buf,tbuf,sz);
+ sprintf(tbuf,",data[6]=0x%02x",act->data[6]); TryCopyStr(buf,tbuf,sz);
+ return True;
+}
+
+typedef Bool (*actionCopy)(
+ Display * /* dpy */,
+ XkbDescPtr /* xkb */,
+ XkbAction * /* action */,
+ char * /* buf */,
+ int* /* sz */
+);
+static actionCopy copyActionArgs[XkbSA_NumActions] = {
+ CopyNoActionArgs /* NoAction */,
+ CopyModActionArgs /* SetMods */,
+ CopyModActionArgs /* LatchMods */,
+ CopyModActionArgs /* LockMods */,
+ CopyGroupActionArgs /* SetGroup */,
+ CopyGroupActionArgs /* LatchGroup */,
+ CopyGroupActionArgs /* LockGroup */,
+ CopyMovePtrArgs /* MovePtr */,
+ CopyPtrBtnArgs /* PtrBtn */,
+ CopyPtrBtnArgs /* LockPtrBtn */,
+ CopySetPtrDfltArgs /* SetPtrDflt */,
+ CopyISOLockArgs /* ISOLock */,
+ CopyNoActionArgs /* Terminate */,
+ CopySwitchScreenArgs /* SwitchScreen */,
+ CopySetLockControlsArgs /* SetControls */,
+ CopySetLockControlsArgs /* LockControls */,
+ CopyActionMessageArgs /* ActionMessage*/,
+ CopyRedirectKeyArgs /* RedirectKey */,
+ CopyDeviceBtnArgs /* DeviceBtn */,
+ CopyDeviceBtnArgs /* LockDeviceBtn*/
+};
+
+#define ACTION_SZ 256
+
+char *
+XkbActionText(Display *dpy,XkbDescPtr xkb,XkbAction *action,unsigned format)
+{
+char buf[ACTION_SZ],*tmp;
+int sz;
+
+ if (format==XkbCFile) {
+ sprintf(buf,
+ "{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }",
+ XkbActionTypeText(action->type,XkbCFile),
+ action->any.data[0],action->any.data[1],action->any.data[2],
+ action->any.data[3],action->any.data[4],action->any.data[5],
+ action->any.data[6]);
+ }
+ else {
+ sprintf(buf,"%s(",XkbActionTypeText(action->type,XkbXKBFile));
+ sz= ACTION_SZ-strlen(buf)+2; /* room for close paren and NULL */
+ if (action->type<(unsigned)XkbSA_NumActions)
+ (*copyActionArgs[action->type])(dpy,xkb,action,buf,&sz);
+ else CopyOtherArgs(dpy,xkb,action,buf,&sz);
+ TryCopyStr(buf,")",&sz);
+ }
+ tmp= tbGetBuffer(strlen(buf)+1);
+ if (tmp!=NULL)
+ strcpy(tmp,buf);
+ return tmp;
+}
+
+char *
+XkbBehaviorText(XkbDescPtr xkb,XkbBehavior *behavior,unsigned format)
+{
+char buf[256],*tmp;
+
+ if (format==XkbCFile) {
+ if (behavior->type==XkbKB_Default)
+ sprintf(buf,"{ 0, 0 }");
+ else sprintf(buf,"{ %3d, 0x%02x }",behavior->type,behavior->data);
+ }
+ else {
+ unsigned type,permanent;
+ type= behavior->type&XkbKB_OpMask;
+ permanent=((behavior->type&XkbKB_Permanent)!=0);
+
+ if (type==XkbKB_Lock) {
+ sprintf(buf,"lock= %s",(permanent?"Permanent":"True"));
+ }
+ else if (type==XkbKB_RadioGroup) {
+ int g;
+ char *tmp;
+ g= ((behavior->data)&(~XkbKB_RGAllowNone))+1;
+ if (XkbKB_RGAllowNone&behavior->data) {
+ sprintf(buf,"allowNone,");
+ tmp= &buf[strlen(buf)];
+ }
+ else tmp= buf;
+ if (permanent)
+ sprintf(tmp,"permanentRadioGroup= %d",g);
+ else sprintf(tmp,"radioGroup= %d",g);
+ }
+ else if ((type==XkbKB_Overlay1)||(type==XkbKB_Overlay2)) {
+ int ndx,kc;
+ char *kn;
+
+ ndx= ((type==XkbKB_Overlay1)?1:2);
+ kc= behavior->data;
+ if ((xkb)&&(xkb->names)&&(xkb->names->keys))
+ kn= XkbKeyNameText(xkb->names->keys[kc].name,XkbXKBFile);
+ else {
+ static char tbuf[8];
+ sprintf(tbuf,"%d",kc);
+ kn= tbuf;
+ }
+ if (permanent)
+ sprintf(buf,"permanentOverlay%d= %s",ndx,kn);
+ else sprintf(buf,"overlay%d= %s",ndx,kn);
+ }
+ }
+ tmp= tbGetBuffer(strlen(buf)+1);
+ if (tmp!=NULL)
+ strcpy(tmp,buf);
+ return tmp;
+}
+
+/***====================================================================***/
+
+char *
+XkbIndentText(unsigned size)
+{
+static char buf[32];
+register int i;
+
+ if (size>31)
+ size= 31;
+
+ for (i=0;i<size;i++) {
+ buf[i]= ' ';
+ }
+ buf[size]= '\0';
+ return buf;
+}
+
+#ifndef XKB_IN_SERVER
+
+/***====================================================================***/
+
+#define PIXEL_MAX 65535
+
+Bool
+XkbLookupCanonicalRGBColor(char *def,XColor *color)
+{
+int tmp;
+
+ if (_XkbStrCaseEqual(def,"black")) {
+ color->red= color->green= color->blue= 0;
+ return True;
+ }
+ else if (_XkbStrCaseEqual(def,"white")) {
+ color->red= color->green= color->blue= PIXEL_MAX;
+ return True;
+ }
+ else if ((sscanf(def,"grey%d",&tmp)==1)||
+ (sscanf(def,"gray%d",&tmp)==1)||
+ (sscanf(def,"Grey%d",&tmp)==1)||
+ (sscanf(def,"Gray%d",&tmp)==1)) {
+ if ((tmp>0)&&(tmp<=100)) {
+ tmp= (PIXEL_MAX*tmp)/100;
+ color->red= color->green= color->blue= tmp;
+ return True;
+ }
+ }
+ else if ((tmp=(_XkbStrCaseEqual(def,"red")*100))||
+ (sscanf(def,"red%d",&tmp)==1)) {
+ if ((tmp>0)&&(tmp<=100)) {
+ tmp= (PIXEL_MAX*tmp)/100;
+ color->red= tmp;
+ color->green= color->blue= 0;
+ return True;
+ }
+ }
+ else if ((tmp=(_XkbStrCaseEqual(def,"green")*100))||
+ (sscanf(def,"green%d",&tmp)==1)) {
+ if ((tmp>0)&&(tmp<=100)) {
+ tmp= (PIXEL_MAX*tmp)/100;
+ color->green= tmp;
+ color->red= color->blue= 0;
+ return True;
+ }
+ }
+ else if ((tmp=(_XkbStrCaseEqual(def,"blue")*100))||
+ (sscanf(def,"blue%d",&tmp)==1)) {
+ if ((tmp>0)&&(tmp<=100)) {
+ tmp= (PIXEL_MAX*tmp)/100;
+ color->blue= tmp;
+ color->red= color->green= 0;
+ return True;
+ }
+ }
+ else if ((tmp=(_XkbStrCaseEqual(def,"magenta")*100))||
+ (sscanf(def,"magenta%d",&tmp)==1)) {
+ if ((tmp>0)&&(tmp<=100)) {
+ tmp= (PIXEL_MAX*tmp)/100;
+ color->green= 0;
+ color->red= color->blue= tmp;
+ return True;
+ }
+ }
+ else if ((tmp=(_XkbStrCaseEqual(def,"cyan")*100))||
+ (sscanf(def,"cyan%d",&tmp)==1)) {
+ if ((tmp>0)&&(tmp<=100)) {
+ tmp= (PIXEL_MAX*tmp)/100;
+ color->red= 0;
+ color->green= color->blue= tmp;
+ return True;
+ }
+ }
+ else if ((tmp=(_XkbStrCaseEqual(def,"yellow")*100))||
+ (sscanf(def,"yellow%d",&tmp)==1)) {
+ if ((tmp>0)&&(tmp<=100)) {
+ tmp= (PIXEL_MAX*tmp)/100;
+ color->blue= 0;
+ color->red= color->green= tmp;
+ return True;
+ }
+ }
+ return False;
+}
+
+#endif
diff --git a/nx-X11/lib/xkbfile/xkmout.c b/nx-X11/lib/xkbfile/xkmout.c
new file mode 100644
index 000000000..403e48810
--- /dev/null
+++ b/nx-X11/lib/xkbfile/xkmout.c
@@ -0,0 +1,1389 @@
+/* $Xorg: xkmout.c,v 1.3 2000/08/17 19:46:44 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkmout.c,v 1.5 2001/07/25 15:04:58 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xlib.h>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKBgeom.h>
+
+#include "XKMformat.h"
+#include "XKBfileInt.h"
+
+typedef struct _XkmInfo {
+ unsigned short bound_vmods;
+ unsigned short named_vmods;
+ unsigned char num_bound;
+ unsigned char group_compat;
+ unsigned short num_group_compat;
+ unsigned short num_leds;
+ int total_vmodmaps;
+} XkmInfo;
+
+/***====================================================================***/
+
+#define xkmPutCARD8(f,v) (putc(v,f),1)
+
+static int
+xkmPutCARD16(FILE *file,unsigned val)
+{
+CARD16 tmp= val;
+
+ fwrite(&tmp,2,1,file);
+ return 2;
+}
+
+static int
+xkmPutCARD32(FILE *file,unsigned long val)
+{
+CARD32 tmp= val;
+
+ fwrite(&tmp,4,1,file);
+ return 4;
+}
+
+static int
+xkmPutPadding(FILE *file,unsigned pad)
+{
+int i;
+ for (i=0;i<pad;i++) {
+ putc('\0',file);
+ }
+ return pad;
+}
+
+static int
+xkmPutCountedBytes(FILE *file,char *ptr,unsigned count)
+{
+register int nOut;
+register unsigned pad;
+
+ if (count==0)
+ return xkmPutCARD32(file,(unsigned long)0);
+
+ xkmPutCARD16(file,count);
+ nOut= fwrite(ptr,1,count,file);
+ if (nOut<0)
+ return 2;
+ nOut= count+2;
+ pad= XkbPaddedSize(nOut)-nOut;
+ if (pad)
+ xkmPutPadding(file,pad);
+ return nOut+pad;
+}
+
+static unsigned
+xkmSizeCountedString(char *str)
+{
+ if (str==NULL)
+ return 4;
+ return XkbPaddedSize(strlen(str)+2);
+}
+
+static int
+xkmPutCountedString(FILE *file,char *str)
+{
+ if (str==NULL)
+ return xkmPutCARD32(file,(unsigned long)0);
+ return xkmPutCountedBytes(file,str,strlen(str));
+}
+
+#define xkmSizeCountedAtomString(d,a) \
+ xkmSizeCountedString(XkbAtomGetString((d),(a)))
+
+#define xkmPutCountedAtomString(d,f,a) \
+ xkmPutCountedString((f),XkbAtomGetString((d),(a)))
+
+/***====================================================================***/
+
+static unsigned
+SizeXKMVirtualMods( XkbFileInfo * result,
+ XkmInfo * info,
+ xkmSectionInfo * toc,
+ int * offset_inout)
+{
+Display * dpy;
+XkbDescPtr xkb;
+unsigned nBound,bound;
+unsigned nNamed,named,szNames;
+register unsigned i,bit;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if ((!xkb)||(!xkb->names)||(!xkb->server)) {
+ _XkbLibError(_XkbErrMissingVMods,"SizeXKMVirtualMods",0);
+ return 0;
+ }
+ bound=named=0;
+ for (i=nBound=nNamed=szNames=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (xkb->server->vmods[i]!=XkbNoModifierMask) {
+ bound|= bit;
+ nBound++;
+ }
+ if (xkb->names->vmods[i]!=None) {
+ named|= bit;
+ szNames+= xkmSizeCountedAtomString(dpy,xkb->names->vmods[i]);
+ nNamed++;
+ }
+ }
+ info->num_bound= nBound;
+ info->bound_vmods= bound;
+ info->named_vmods= named;
+ if ((nBound==0)&&(nNamed==0))
+ return 0;
+ toc->type= XkmVirtualModsIndex;
+ toc->format= MSBFirst;
+ toc->size= 4+XkbPaddedSize(nBound)+szNames+SIZEOF(xkmSectionInfo);
+ toc->offset= *offset_inout;
+ (*offset_inout)+= toc->size;
+ return 1;
+}
+
+static unsigned
+WriteXKMVirtualMods(FILE *file,XkbFileInfo *result,XkmInfo *info)
+{
+register unsigned int i,bit;
+XkbDescPtr xkb;
+Display * dpy;
+unsigned size= 0;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ size+= xkmPutCARD16(file,info->bound_vmods);
+ size+= xkmPutCARD16(file,info->named_vmods);
+ for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (info->bound_vmods&bit)
+ size+= xkmPutCARD8(file,xkb->server->vmods[i]);
+ }
+ if ((i= XkbPaddedSize(info->num_bound)-info->num_bound)>0)
+ size+= xkmPutPadding(file,i);
+ for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (info->named_vmods&bit) {
+ register char *name;
+ name= XkbAtomGetString(dpy,xkb->names->vmods[i]);
+ size+= xkmPutCountedString(file,name);
+ }
+ }
+ return size;
+}
+
+/***====================================================================***/
+
+static unsigned
+SizeXKMKeycodes(XkbFileInfo *result,xkmSectionInfo *toc,int *offset_inout)
+{
+XkbDescPtr xkb;
+Atom kcName;
+int size=0;
+Display * dpy;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if ((!xkb)||(!xkb->names)||(!xkb->names->keys)) {
+ _XkbLibError(_XkbErrMissingNames,"SizeXKMKeycodes",0);
+ return 0;
+ }
+ kcName= xkb->names->keycodes;
+ size+= 4; /* min and max keycode */
+ size+= xkmSizeCountedAtomString(dpy,kcName);
+ size+= XkbNumKeys(xkb)*sizeof(XkbKeyNameRec);
+ if (xkb->names->num_key_aliases>0) {
+ if (xkb->names->key_aliases!=NULL)
+ size+= xkb->names->num_key_aliases*sizeof(XkbKeyAliasRec);
+ else xkb->names->num_key_aliases= 0;
+ }
+ toc->type= XkmKeyNamesIndex;
+ toc->format= MSBFirst;
+ toc->size= size+SIZEOF(xkmSectionInfo);
+ toc->offset= (*offset_inout);
+ (*offset_inout)+= toc->size;
+ return 1;
+}
+
+static unsigned
+WriteXKMKeycodes(FILE *file,XkbFileInfo *result)
+{
+XkbDescPtr xkb;
+Atom kcName;
+char *start;
+Display * dpy;
+unsigned tmp,size= 0;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ kcName= xkb->names->keycodes;
+ start= xkb->names->keys[xkb->min_key_code].name;
+
+ size+= xkmPutCountedString(file,XkbAtomGetString(dpy,kcName));
+ size+= xkmPutCARD8(file,xkb->min_key_code);
+ size+= xkmPutCARD8(file,xkb->max_key_code);
+ size+= xkmPutCARD8(file,xkb->names->num_key_aliases);
+ size+= xkmPutPadding(file,1);
+ tmp= fwrite(start,sizeof(XkbKeyNameRec),XkbNumKeys(xkb),file);
+ size+= tmp*sizeof(XkbKeyNameRec);
+ if (xkb->names->num_key_aliases>0) {
+ tmp= fwrite((char *)xkb->names->key_aliases,
+ sizeof(XkbKeyAliasRec),xkb->names->num_key_aliases,
+ file);
+ size+= tmp*sizeof(XkbKeyAliasRec);
+ }
+ return size;
+}
+
+/***====================================================================***/
+
+static unsigned
+SizeXKMKeyTypes(XkbFileInfo *result,xkmSectionInfo *toc,int *offset_inout)
+{
+register unsigned i,n,size;
+XkbKeyTypePtr type;
+XkbDescPtr xkb;
+Display * dpy;
+char * name;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if ((!xkb)||(!xkb->map)||(!xkb->map->types)) {
+ _XkbLibError(_XkbErrMissingTypes,"SizeXKBKeyTypes",0);
+ return 0;
+ }
+ if (xkb->map->num_types<XkbNumRequiredTypes) {
+ _XkbLibError(_XkbErrMissingReqTypes,"SizeXKBKeyTypes",0);
+ return 0;
+ }
+ if (xkb->names) name= XkbAtomGetString(dpy,xkb->names->types);
+ else name= NULL;
+ size= xkmSizeCountedString(name);
+ size+= 4; /* room for # of key types + padding */
+ for (i=0,type=xkb->map->types;i<xkb->map->num_types;i++,type++) {
+ size+= SIZEOF(xkmKeyTypeDesc);
+ size+= SIZEOF(xkmKTMapEntryDesc)*type->map_count;
+ size+= xkmSizeCountedAtomString(dpy,type->name);
+ if (type->preserve)
+ size+= SIZEOF(xkmModsDesc)*type->map_count;
+ if (type->level_names) {
+ Atom *names;
+ names= type->level_names;
+ for (n=0;n<(unsigned)type->num_levels;n++) {
+ size+= xkmSizeCountedAtomString(dpy,names[n]);
+ }
+ }
+ }
+ toc->type= XkmTypesIndex;
+ toc->format= MSBFirst;
+ toc->size= size+SIZEOF(xkmSectionInfo);
+ toc->offset= (*offset_inout);
+ (*offset_inout)+= toc->size;
+ return 1;
+}
+
+static unsigned
+WriteXKMKeyTypes(FILE *file,XkbFileInfo *result)
+{
+register unsigned i,n;
+XkbDescPtr xkb;
+XkbKeyTypePtr type;
+xkmKeyTypeDesc wire;
+XkbKTMapEntryPtr entry;
+xkmKTMapEntryDesc wire_entry;
+Atom * names;
+Display * dpy;
+unsigned tmp,size= 0;
+char * name;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if (xkb->names) name= XkbAtomGetString(dpy,xkb->names->types);
+ else name= NULL;
+ size+= xkmPutCountedString(file,name);
+ size+= xkmPutCARD16(file,xkb->map->num_types);
+ size+= xkmPutPadding(file,2);
+ type= xkb->map->types;
+ for (i=0;i<xkb->map->num_types;i++,type++) {
+ wire.realMods= type->mods.real_mods;
+ wire.virtualMods= type->mods.vmods;
+ wire.numLevels= type->num_levels;
+ wire.nMapEntries= type->map_count;
+ wire.preserve= (type->preserve!=NULL);
+ if (type->level_names!=NULL)
+ wire.nLevelNames= type->num_levels;
+ else wire.nLevelNames= 0;
+ tmp= fwrite(&wire,SIZEOF(xkmKeyTypeDesc),1,file);
+ size+= tmp*SIZEOF(xkmKeyTypeDesc);
+ for (n=0,entry= type->map;n<type->map_count;n++,entry++) {
+ wire_entry.level= entry->level;
+ wire_entry.realMods= entry->mods.real_mods;
+ wire_entry.virtualMods= entry->mods.vmods;
+ tmp= fwrite(&wire_entry,SIZEOF(xkmKTMapEntryDesc),1,file);
+ size+= tmp*SIZEOF(xkmKTMapEntryDesc);
+ }
+ size+= xkmPutCountedString(file,XkbAtomGetString(dpy,type->name));
+ if (type->preserve) {
+ xkmModsDesc p_entry;
+ XkbModsPtr pre;
+ for (n=0,pre=type->preserve;n<type->map_count;n++,pre++) {
+ p_entry.realMods= pre->real_mods;
+ p_entry.virtualMods= pre->vmods;
+ tmp= fwrite(&p_entry,SIZEOF(xkmModsDesc),1,file);
+ size+= tmp*SIZEOF(xkmModsDesc);
+ }
+ }
+ if (type->level_names!=NULL) {
+ names= type->level_names;
+ for (n=0;n<wire.nLevelNames;n++) {
+ size+= xkmPutCountedString(file,XkbAtomGetString(dpy,names[n]));
+ }
+ }
+ }
+ return size;
+}
+
+/***====================================================================***/
+
+static unsigned
+SizeXKMCompatMap( XkbFileInfo * result,
+ XkmInfo * info,
+ xkmSectionInfo * toc,
+ int * offset_inout)
+{
+XkbDescPtr xkb;
+char * name;
+int size;
+register int i;
+unsigned groups,nGroups;
+Display * dpy;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if ((!xkb)||(!xkb->compat)||(!xkb->compat->sym_interpret)) {
+ _XkbLibError(_XkbErrMissingCompatMap,"SizeXKMCompatMap",0);
+ return 0;
+ }
+ if (xkb->names) name= XkbAtomGetString(dpy,xkb->names->compat);
+ else name= NULL;
+
+ for (i=groups=nGroups=0;i<XkbNumKbdGroups;i++) {
+ if ((xkb->compat->groups[i].real_mods!=0)||
+ (xkb->compat->groups[i].vmods!=0)) {
+ groups|= (1<<i);
+ nGroups++;
+ }
+ }
+ info->group_compat= groups;
+ info->num_group_compat= nGroups;
+ size= 4; /* room for num_si and group_compat mask */
+ size+= xkmSizeCountedString(name);
+ size+= (SIZEOF(xkmSymInterpretDesc)*xkb->compat->num_si);
+ size+= (SIZEOF(xkmModsDesc)*nGroups);
+ toc->type= XkmCompatMapIndex;
+ toc->format= MSBFirst;
+ toc->size= size+SIZEOF(xkmSectionInfo);
+ toc->offset= (*offset_inout);
+ (*offset_inout)+= toc->size;
+ return 1;
+}
+
+static unsigned
+WriteXKMCompatMap(FILE *file,XkbFileInfo *result,XkmInfo *info)
+{
+register unsigned i;
+char * name;
+XkbDescPtr xkb;
+XkbSymInterpretPtr interp;
+xkmSymInterpretDesc wire;
+Display * dpy;
+unsigned tmp,size=0;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if (xkb->names) name= XkbAtomGetString(dpy,xkb->names->compat);
+ else name= NULL;
+ size+= xkmPutCountedString(file,name);
+ size+= xkmPutCARD16(file,xkb->compat->num_si);
+ size+= xkmPutCARD8(file,info->group_compat);
+ size+= xkmPutPadding(file,1);
+ interp= xkb->compat->sym_interpret;
+ for (i=0;i<xkb->compat->num_si;i++,interp++) {
+ wire.sym= interp->sym;
+ wire.mods= interp->mods;
+ wire.match= interp->match;
+ wire.virtualMod= interp->virtual_mod;
+ wire.flags= interp->flags;
+ wire.actionType= interp->act.type;
+ wire.actionData[0]= interp->act.data[0];
+ wire.actionData[1]= interp->act.data[1];
+ wire.actionData[2]= interp->act.data[2];
+ wire.actionData[3]= interp->act.data[3];
+ wire.actionData[4]= interp->act.data[4];
+ wire.actionData[5]= interp->act.data[5];
+ wire.actionData[6]= interp->act.data[6];
+ tmp= fwrite(&wire,SIZEOF(xkmSymInterpretDesc),1,file);
+ size+= tmp*SIZEOF(xkmSymInterpretDesc);
+ }
+ if (info->group_compat) {
+ register unsigned bit;
+ xkmModsDesc modsWire;
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if (info->group_compat&bit) {
+ modsWire.realMods= xkb->compat->groups[i].real_mods;
+ modsWire.virtualMods= xkb->compat->groups[i].vmods;
+ fwrite(&modsWire,SIZEOF(xkmModsDesc),1,file);
+ size+= SIZEOF(xkmModsDesc);
+ }
+ }
+ }
+ return size;
+}
+
+/***====================================================================***/
+
+static unsigned
+SizeXKMSymbols( XkbFileInfo * result,
+ XkmInfo * info,
+ xkmSectionInfo * toc,
+ int * offset_inout)
+{
+Display * dpy;
+XkbDescPtr xkb;
+unsigned size;
+register int i,nSyms;
+char * name;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if ((!xkb)||(!xkb->map)||((!xkb->map->syms))) {
+ _XkbLibError(_XkbErrMissingSymbols,"SizeXKMSymbols",0);
+ return 0;
+ }
+ if (xkb->names && (xkb->names->symbols!=None))
+ name= XkbAtomGetString(dpy,xkb->names->symbols);
+ else name= NULL;
+ size= xkmSizeCountedString(name);
+ size+= 4; /* min and max keycode, group names mask */
+ for (i=0;i<XkbNumKbdGroups;i++) {
+ if (xkb->names->groups[i]!=None)
+ size+= xkmSizeCountedAtomString(dpy,xkb->names->groups[i]);
+ }
+ info->total_vmodmaps= 0;
+ for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
+ nSyms= XkbKeyNumSyms(xkb,i);
+ size+= SIZEOF(xkmKeySymMapDesc)+(nSyms*4);
+ if (xkb->server) {
+ if (xkb->server->explicit[i]&XkbExplicitKeyTypesMask) {
+ register int g;
+ for (g=XkbKeyNumGroups(xkb,i)-1;g>=0;g--) {
+ if (xkb->server->explicit[i]&(1<<g)) {
+ XkbKeyTypePtr type;
+ char * name;
+ type= XkbKeyKeyType(xkb,i,g);
+ name= XkbAtomGetString(dpy,type->name);
+ if (name!=NULL)
+ size+= xkmSizeCountedString(name);
+ }
+ }
+ }
+ if (XkbKeyHasActions(xkb,i))
+ size+= nSyms*SIZEOF(xkmActionDesc);
+ if (xkb->server->behaviors[i].type!=XkbKB_Default)
+ size+= SIZEOF(xkmBehaviorDesc);
+ if (xkb->server->vmodmap && (xkb->server->vmodmap[i]!=0))
+ info->total_vmodmaps++;
+ }
+ }
+ size+= info->total_vmodmaps*SIZEOF(xkmVModMapDesc);
+ toc->type= XkmSymbolsIndex;
+ toc->format= MSBFirst;
+ toc->size= size+SIZEOF(xkmSectionInfo);
+ toc->offset= (*offset_inout);
+ (*offset_inout)+= toc->size;
+ return 1;
+}
+
+static unsigned
+WriteXKMSymbols(FILE *file,XkbFileInfo *result,XkmInfo *info)
+{
+Display * dpy;
+XkbDescPtr xkb;
+register int i,n;
+xkmKeySymMapDesc wireMap;
+char * name;
+unsigned tmp,size= 0;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if (xkb->names && (xkb->names->symbols!=None))
+ name= XkbAtomGetString(dpy,xkb->names->symbols);
+ else name= NULL;
+ size+= xkmPutCountedString(file,name);
+ for (tmp=i=0;i<XkbNumKbdGroups;i++) {
+ if (xkb->names->groups[i]!=None)
+ tmp|= (1<<i);
+ }
+ size+= xkmPutCARD8(file,xkb->min_key_code);
+ size+= xkmPutCARD8(file,xkb->max_key_code);
+ size+= xkmPutCARD8(file,tmp);
+ size+= xkmPutCARD8(file,info->total_vmodmaps);
+ for (i=0,n=1;i<XkbNumKbdGroups;i++,n<<=1) {
+ if ((tmp&n)==0)
+ continue;
+ size+= xkmPutCountedAtomString(dpy,file,xkb->names->groups[i]);
+ }
+ for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
+ char *typeName[XkbNumKbdGroups];
+ wireMap.width= XkbKeyGroupsWidth(xkb,i);
+ wireMap.num_groups= XkbKeyGroupInfo(xkb,i);
+ if (xkb->map && xkb->map->modmap)
+ wireMap.modifier_map= xkb->map->modmap[i];
+ else wireMap.modifier_map= 0;
+ wireMap.flags= 0;
+ bzero((char *)typeName,XkbNumKbdGroups*sizeof(char *));
+ if (xkb->server) {
+ if (xkb->server->explicit[i]&XkbExplicitKeyTypesMask) {
+ register int g;
+ for (g=0;g<XkbKeyNumGroups(xkb,i);g++) {
+ if (xkb->server->explicit[i]&(1<<g)) {
+ XkbKeyTypePtr type;
+ type= XkbKeyKeyType(xkb,i,g);
+ typeName[g]= XkbAtomGetString(dpy,type->name);
+ if (typeName[g]!=NULL)
+ wireMap.flags|= (1<<g);
+ }
+ }
+ }
+ if (XkbKeyHasActions(xkb,i))
+ wireMap.flags|= XkmKeyHasActions;
+ if (xkb->server->behaviors[i].type!=XkbKB_Default)
+ wireMap.flags|= XkmKeyHasBehavior;
+ if ((xkb->server->explicit[i]&XkbExplicitAutoRepeatMask)&&
+ (xkb->ctrls!=NULL)) {
+ if (xkb->ctrls->per_key_repeat[(i/8)]&(1<<(i%8)))
+ wireMap.flags|= XkmRepeatingKey;
+ else wireMap.flags|= XkmNonRepeatingKey;
+ }
+ }
+ tmp= fwrite(&wireMap,SIZEOF(xkmKeySymMapDesc),1,file);
+ size+= tmp*SIZEOF(xkmKeySymMapDesc);
+ if (xkb->server->explicit[i]&XkbExplicitKeyTypesMask) {
+ register int g;
+ for (g=0;g<XkbNumKbdGroups;g++) {
+ if (typeName[g]!=NULL)
+ size+= xkmPutCountedString(file,typeName[g]);
+ }
+ }
+ if (XkbNumGroups(wireMap.num_groups)>0) {
+ KeySym *sym;
+ sym= XkbKeySymsPtr(xkb,i);
+ for (n=XkbKeyNumSyms(xkb,i);n>0;n--,sym++) {
+ size+= xkmPutCARD32(file,(CARD32)*sym);
+ }
+ if (wireMap.flags&XkmKeyHasActions) {
+ XkbAction * act;
+ act= XkbKeyActionsPtr(xkb,i);
+ for (n=XkbKeyNumActions(xkb,i);n>0;n--,act++) {
+ tmp= fwrite(act,SIZEOF(xkmActionDesc),1,file);
+ size+= tmp*SIZEOF(xkmActionDesc);
+ }
+ }
+ }
+ if (wireMap.flags&XkmKeyHasBehavior) {
+ xkmBehaviorDesc b;
+ b.type= xkb->server->behaviors[i].type;
+ b.data= xkb->server->behaviors[i].data;
+ tmp= fwrite(&b,SIZEOF(xkmBehaviorDesc),1,file);
+ size+= tmp*SIZEOF(xkmBehaviorDesc);
+ }
+ }
+ if (info->total_vmodmaps>0) {
+ xkmVModMapDesc v;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ if (xkb->server->vmodmap[i]!=0) {
+ v.key= i;
+ v.vmods= xkb->server->vmodmap[i];
+ tmp= fwrite(&v,SIZEOF(xkmVModMapDesc),1,file);
+ size+= tmp*SIZEOF(xkmVModMapDesc);
+ }
+ }
+ }
+ return size;
+}
+
+/***====================================================================***/
+
+static unsigned
+SizeXKMIndicators(XkbFileInfo *result,XkmInfo *info,xkmSectionInfo *toc,
+ int *offset_inout)
+{
+Display * dpy;
+XkbDescPtr xkb;
+unsigned size;
+register unsigned i,nLEDs;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if ((xkb==NULL)||(xkb->indicators==NULL)) {
+/* _XkbLibError(_XkbErrMissingIndicators,"SizeXKMIndicators",0);*/
+ return 0;
+ }
+ nLEDs=0;
+ size= 8; /* number of indicator maps/physical indicators */
+ if (xkb->indicators!=NULL) {
+ for (i=0;i<XkbNumIndicators;i++) {
+ XkbIndicatorMapPtr map= &xkb->indicators->maps[i];
+ if ((map->flags!=0)||(map->which_groups!=0)||(map->groups!=0)||
+ (map->which_mods!=0)||
+ (map->mods.real_mods!=0)||(map->mods.vmods!=0)||
+ (map->ctrls!=0) ||
+ (xkb->names && (xkb->names->indicators[i]!=None))) {
+ char *name;
+ if (xkb->names && xkb->names->indicators[i]!=None) {
+ name= XkbAtomGetString(dpy,xkb->names->indicators[i]);
+ }
+ else name= NULL;
+ size+= xkmSizeCountedString(name);
+ size+= SIZEOF(xkmIndicatorMapDesc);
+ nLEDs++;
+ }
+ }
+ }
+ info->num_leds= nLEDs;
+ toc->type= XkmIndicatorsIndex;
+ toc->format= MSBFirst;
+ toc->size= size+SIZEOF(xkmSectionInfo);
+ toc->offset= (*offset_inout);
+ (*offset_inout)+= toc->size;
+ return 1;
+}
+
+static unsigned
+WriteXKMIndicators(FILE *file,XkbFileInfo *result,XkmInfo *info)
+{
+Display * dpy;
+XkbDescPtr xkb;
+register unsigned i;
+xkmIndicatorMapDesc wire;
+unsigned tmp,size= 0;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ size+= xkmPutCARD8(file,info->num_leds);
+ size+= xkmPutPadding(file,3);
+ size+= xkmPutCARD32(file,xkb->indicators->phys_indicators);
+ if (xkb->indicators!=NULL) {
+ for (i=0;i<XkbNumIndicators;i++) {
+ XkbIndicatorMapPtr map= &xkb->indicators->maps[i];
+ if ((map->flags!=0)||(map->which_groups!=0)||(map->groups!=0)||
+ (map->which_mods!=0)||
+ (map->mods.real_mods!=0)||(map->mods.vmods!=0)||
+ (map->ctrls!=0) ||
+ (xkb->names && (xkb->names->indicators[i]!=None))) {
+ char *name;
+ if (xkb->names && xkb->names->indicators[i]!=None) {
+ name= XkbAtomGetString(dpy,xkb->names->indicators[i]);
+ }
+ else name= NULL;
+ size+= xkmPutCountedString(file,name);
+ wire.indicator= i+1;
+ wire.flags= map->flags;
+ wire.which_mods= map->which_mods;
+ wire.real_mods= map->mods.real_mods;
+ wire.vmods= map->mods.vmods;
+ wire.which_groups= map->which_groups;
+ wire.groups= map->groups;
+ wire.ctrls= map->ctrls;
+ tmp= fwrite(&wire,SIZEOF(xkmIndicatorMapDesc),1,file);
+ size+= tmp*SIZEOF(xkmIndicatorMapDesc);
+ }
+ }
+ }
+ return size;
+}
+
+/***====================================================================***/
+
+static unsigned
+SizeXKMGeomDoodad(XkbFileInfo *result,XkbDoodadPtr doodad)
+{
+unsigned size;
+
+ size= SIZEOF(xkmAnyDoodadDesc);
+ size+= xkmSizeCountedAtomString(result->xkb->dpy,doodad->any.name);
+ if (doodad->any.type==XkbTextDoodad) {
+ size+= xkmSizeCountedString(doodad->text.text);
+ size+= xkmSizeCountedString(doodad->text.font);
+ }
+ else if (doodad->any.type==XkbLogoDoodad) {
+ size+= xkmSizeCountedString(doodad->logo.logo_name);
+ }
+ return size;
+}
+
+static unsigned
+SizeXKMGeomSection(XkbFileInfo *result,XkbSectionPtr section)
+{
+register int i;
+unsigned size;
+
+ size= SIZEOF(xkmSectionDesc);
+ size+= xkmSizeCountedAtomString(result->xkb->dpy,section->name);
+ if (section->rows) {
+ XkbRowPtr row;
+ for (row=section->rows,i=0;i<section->num_rows;i++,row++) {
+ size+= SIZEOF(xkmRowDesc);
+ size+= row->num_keys*SIZEOF(xkmKeyDesc);
+ }
+ }
+ if (section->doodads) {
+ XkbDoodadPtr doodad;
+ for (doodad=section->doodads,i=0;i<section->num_doodads;i++,doodad++) {
+ size+= SizeXKMGeomDoodad(result,doodad);
+ }
+ }
+ if (section->overlays) {
+ XkbOverlayPtr ol;
+ for (ol=section->overlays,i=0;i<section->num_overlays;i++,ol++) {
+ register int r;
+ XkbOverlayRowPtr row;
+ size+= xkmSizeCountedAtomString(result->xkb->dpy,ol->name);
+ size+= SIZEOF(xkmOverlayDesc);
+ for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
+ size+= SIZEOF(xkmOverlayRowDesc);
+ size+= row->num_keys*SIZEOF(xkmOverlayKeyDesc);
+ }
+ }
+ }
+ return size;
+}
+
+static unsigned
+SizeXKMGeometry(XkbFileInfo *result,xkmSectionInfo *toc,int *offset_inout)
+{
+register int i;
+Display * dpy;
+XkbDescPtr xkb;
+XkbGeometryPtr geom;
+unsigned size;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if ((!xkb)||(!xkb->geom))
+ return 0;
+ geom= xkb->geom;
+ size= xkmSizeCountedAtomString(dpy,geom->name);
+ size+= SIZEOF(xkmGeometryDesc);
+ size+= xkmSizeCountedString(geom->label_font);
+ if (geom->properties) {
+ XkbPropertyPtr prop;
+ for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
+ size+= xkmSizeCountedString(prop->name);
+ size+= xkmSizeCountedString(prop->value);
+ }
+ }
+ if (geom->colors) {
+ XkbColorPtr color;
+ for (i=0,color=geom->colors;i<geom->num_colors;i++,color++) {
+ size+= xkmSizeCountedString(color->spec);
+ }
+ }
+ if (geom->shapes) {
+ XkbShapePtr shape;
+ for (i=0,shape=geom->shapes;i<geom->num_shapes;i++,shape++) {
+ register int n;
+ register XkbOutlinePtr ol;
+ size+= xkmSizeCountedAtomString(dpy,shape->name);
+ size+= SIZEOF(xkmShapeDesc);
+ for (n=0,ol=shape->outlines;n<shape->num_outlines;n++,ol++) {
+ size+= SIZEOF(xkmOutlineDesc);
+ size+= ol->num_points*SIZEOF(xkmPointDesc);
+ }
+ }
+ }
+ if (geom->sections) {
+ XkbSectionPtr section;
+ for (i=0,section=geom->sections;i<geom->num_sections;i++,section++) {
+ size+= SizeXKMGeomSection(result,section);
+ }
+ }
+ if (geom->doodads) {
+ XkbDoodadPtr doodad;
+ for (i=0,doodad=geom->doodads;i<geom->num_doodads;i++,doodad++) {
+ size+= SizeXKMGeomDoodad(result,doodad);
+ }
+ }
+ if (geom->key_aliases) {
+ size+= geom->num_key_aliases*(XkbKeyNameLength*2);
+ }
+ toc->type= XkmGeometryIndex;
+ toc->format= MSBFirst;
+ toc->size= size+SIZEOF(xkmSectionInfo);
+ toc->offset= (*offset_inout);
+ (*offset_inout)+= toc->size;
+ return 1;
+}
+
+static unsigned
+WriteXKMGeomDoodad(FILE *file,XkbFileInfo *result,XkbDoodadPtr doodad)
+{
+Display * dpy;
+XkbDescPtr xkb;
+xkmDoodadDesc doodadWire;
+unsigned tmp,size= 0;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ bzero((char *)&doodadWire,sizeof(doodadWire));
+ doodadWire.any.type= doodad->any.type;
+ doodadWire.any.priority= doodad->any.priority;
+ doodadWire.any.top= doodad->any.top;
+ doodadWire.any.left= doodad->any.left;
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ doodadWire.shape.angle= doodad->shape.angle;
+ doodadWire.shape.color_ndx= doodad->shape.color_ndx;
+ doodadWire.shape.shape_ndx= doodad->shape.shape_ndx;
+ break;
+ case XkbTextDoodad:
+ doodadWire.text.angle= doodad->text.angle;
+ doodadWire.text.width= doodad->text.width;
+ doodadWire.text.height= doodad->text.height;
+ doodadWire.text.color_ndx= doodad->text.color_ndx;
+ break;
+ case XkbIndicatorDoodad:
+ doodadWire.indicator.shape_ndx= doodad->indicator.shape_ndx;
+ doodadWire.indicator.on_color_ndx= doodad->indicator.on_color_ndx;
+ doodadWire.indicator.off_color_ndx= doodad->indicator.off_color_ndx;
+ break;
+ case XkbLogoDoodad:
+ doodadWire.logo.angle= doodad->logo.angle;
+ doodadWire.logo.color_ndx= doodad->logo.color_ndx;
+ doodadWire.logo.shape_ndx= doodad->logo.shape_ndx;
+ break;
+ default:
+ _XkbLibError(_XkbErrIllegalDoodad,"WriteXKMGeomDoodad",
+ doodad->any.type);
+ return 0;
+ }
+ size+= xkmPutCountedAtomString(dpy,file,doodad->any.name);
+ tmp= fwrite(&doodadWire,SIZEOF(xkmDoodadDesc),1,file);
+ size+= tmp*SIZEOF(xkmDoodadDesc);
+ if (doodad->any.type==XkbTextDoodad) {
+ size+= xkmPutCountedString(file,doodad->text.text);
+ size+= xkmPutCountedString(file,doodad->text.font);
+ }
+ else if (doodad->any.type==XkbLogoDoodad) {
+ size+= xkmPutCountedString(file,doodad->logo.logo_name);
+ }
+ return size;
+}
+
+static unsigned
+WriteXKMGeomOverlay(FILE *file,XkbFileInfo *result,XkbOverlayPtr ol)
+{
+register int r,k;
+Display * dpy;
+XkbDescPtr xkb;
+XkbOverlayRowPtr row;
+xkmOverlayDesc olWire;
+xkmOverlayRowDesc rowWire;
+xkmOverlayKeyDesc keyWire;
+unsigned tmp,size= 0;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ bzero((char *)&olWire,sizeof(olWire));
+ bzero((char *)&rowWire,sizeof(rowWire));
+ bzero((char *)&keyWire,sizeof(keyWire));
+ size+= xkmPutCountedAtomString(dpy,file,ol->name);
+ olWire.num_rows= ol->num_rows;
+ tmp= fwrite(&olWire,SIZEOF(xkmOverlayDesc),1,file);
+ size+= tmp*SIZEOF(xkmOverlayDesc);
+ for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
+ XkbOverlayKeyPtr key;
+ rowWire.row_under= row->row_under;
+ rowWire.num_keys= row->num_keys;
+ tmp= fwrite(&rowWire,SIZEOF(xkmOverlayRowDesc),1,file);
+ size+= tmp*SIZEOF(xkmOverlayRowDesc);
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ memcpy(keyWire.over,key->over.name,XkbKeyNameLength);
+ memcpy(keyWire.under,key->under.name,XkbKeyNameLength);
+ tmp= fwrite(&keyWire,SIZEOF(xkmOverlayKeyDesc),1,file);
+ size+= tmp*SIZEOF(xkmOverlayKeyDesc);
+ }
+ }
+ return size;
+}
+
+static unsigned
+WriteXKMGeomSection(FILE *file,XkbFileInfo *result,XkbSectionPtr section)
+{
+register int i;
+Display * dpy;
+XkbDescPtr xkb;
+xkmSectionDesc sectionWire;
+unsigned tmp,size= 0;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ size+= xkmPutCountedAtomString(dpy,file,section->name);
+ sectionWire.top= section->top;
+ sectionWire.left= section->left;
+ sectionWire.width= section->width;
+ sectionWire.height= section->height;
+ sectionWire.angle= section->angle;
+ sectionWire.priority= section->priority;
+ sectionWire.num_rows= section->num_rows;
+ sectionWire.num_doodads= section->num_doodads;
+ sectionWire.num_overlays= section->num_overlays;
+ tmp= fwrite(&sectionWire,SIZEOF(xkmSectionDesc),1,file);
+ size+= tmp*SIZEOF(xkmSectionDesc);
+ if (section->rows) {
+ register unsigned k;
+ XkbRowPtr row;
+ xkmRowDesc rowWire;
+ XkbKeyPtr key;
+ xkmKeyDesc keyWire;
+ for (i=0,row=section->rows;i<section->num_rows;i++,row++) {
+ rowWire.top= row->top;
+ rowWire.left= row->left;
+ rowWire.num_keys= row->num_keys;
+ rowWire.vertical= row->vertical;
+ tmp= fwrite(&rowWire,SIZEOF(xkmRowDesc),1,file);
+ size+= tmp*SIZEOF(xkmRowDesc);
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ memcpy(keyWire.name,key->name.name,XkbKeyNameLength);
+ keyWire.gap= key->gap;
+ keyWire.shape_ndx= key->shape_ndx;
+ keyWire.color_ndx= key->color_ndx;
+ tmp= fwrite(&keyWire,SIZEOF(xkmKeyDesc),1,file);
+ size+= tmp*SIZEOF(xkmKeyDesc);
+ }
+ }
+ }
+ if (section->doodads) {
+ XkbDoodadPtr doodad;
+ for (i=0,doodad=section->doodads;i<section->num_doodads;i++,doodad++) {
+ size+= WriteXKMGeomDoodad(file,result,doodad);
+ }
+ }
+ if (section->overlays) {
+ XkbOverlayPtr ol;
+ for (i=0,ol=section->overlays;i<section->num_overlays;i++,ol++) {
+ size+= WriteXKMGeomOverlay(file,result,ol);
+ }
+ }
+ return size;
+}
+
+static unsigned
+WriteXKMGeometry(FILE *file,XkbFileInfo *result)
+{
+register int i;
+Display * dpy;
+XkbDescPtr xkb;
+XkbGeometryPtr geom;
+xkmGeometryDesc wire;
+unsigned tmp,size= 0;
+
+ xkb= result->xkb;
+ dpy= xkb->dpy;
+ if ((!xkb)||(!xkb->geom))
+ return 0;
+ geom= xkb->geom;
+ wire.width_mm= geom->width_mm;
+ wire.height_mm= geom->height_mm;
+ wire.base_color_ndx= XkbGeomColorIndex(geom,geom->base_color);
+ wire.label_color_ndx= XkbGeomColorIndex(geom,geom->label_color);
+ wire.num_properties= geom->num_properties;
+ wire.num_colors= geom->num_colors;
+ wire.num_shapes= geom->num_shapes;
+ wire.num_sections= geom->num_sections;
+ wire.num_doodads= geom->num_doodads;
+ wire.num_key_aliases= geom->num_key_aliases;
+ size+= xkmPutCountedAtomString(dpy,file,geom->name);
+ tmp= fwrite(&wire,SIZEOF(xkmGeometryDesc),1,file);
+ size+= tmp*SIZEOF(xkmGeometryDesc);
+ size+= xkmPutCountedString(file,geom->label_font);
+ if (geom->properties) {
+ XkbPropertyPtr prop;
+ for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
+ size+= xkmPutCountedString(file,prop->name);
+ size+= xkmPutCountedString(file,prop->value);
+ }
+ }
+ if (geom->colors) {
+ XkbColorPtr color;
+ for (i=0,color=geom->colors;i<geom->num_colors;i++,color++) {
+ size+= xkmPutCountedString(file,color->spec);
+ }
+ }
+ if (geom->shapes) {
+ XkbShapePtr shape;
+ xkmShapeDesc shapeWire;
+
+ for (i=0,shape=geom->shapes;i<geom->num_shapes;i++,shape++) {
+ register int n;
+ XkbOutlinePtr ol;
+ xkmOutlineDesc olWire;
+ bzero((char *)&shapeWire,sizeof(xkmShapeDesc));
+ size+= xkmPutCountedAtomString(dpy,file,shape->name);
+ shapeWire.num_outlines= shape->num_outlines;
+ if (shape->primary!=NULL)
+ shapeWire.primary_ndx= XkbOutlineIndex(shape,shape->primary);
+ else shapeWire.primary_ndx= XkbNoShape;
+ if (shape->approx!=NULL)
+ shapeWire.approx_ndx= XkbOutlineIndex(shape,shape->approx);
+ else shapeWire.approx_ndx= XkbNoShape;
+ tmp= fwrite(&shapeWire,SIZEOF(xkmShapeDesc),1,file);
+ size+= tmp*SIZEOF(xkmShapeDesc);
+ for (n=0,ol=shape->outlines;n<shape->num_outlines;n++,ol++) {
+ register int p;
+ XkbPointPtr pt;
+ xkmPointDesc ptWire;
+ olWire.num_points= ol->num_points;
+ olWire.corner_radius= ol->corner_radius;
+ tmp= fwrite(&olWire,SIZEOF(xkmOutlineDesc),1,file);
+ size+= tmp*SIZEOF(xkmOutlineDesc);
+ for (p=0,pt=ol->points;p<ol->num_points;p++,pt++) {
+ ptWire.x= pt->x;
+ ptWire.y= pt->y;
+ tmp= fwrite(&ptWire,SIZEOF(xkmPointDesc),1,file);
+ size+= tmp*SIZEOF(xkmPointDesc);
+ }
+ }
+ }
+ }
+ if (geom->sections) {
+ XkbSectionPtr section;
+ for (i=0,section=geom->sections;i<geom->num_sections;i++,section++) {
+ size+= WriteXKMGeomSection(file,result,section);
+ }
+ }
+ if (geom->doodads) {
+ XkbDoodadPtr doodad;
+ for (i=0,doodad=geom->doodads;i<geom->num_doodads;i++,doodad++) {
+ size+= WriteXKMGeomDoodad(file,result,doodad);
+ }
+ }
+ if (geom->key_aliases) {
+ tmp= fwrite(geom->key_aliases,2*XkbKeyNameLength,geom->num_key_aliases,
+ file);
+ size+= tmp*(2*XkbKeyNameLength);
+ }
+ return size;
+}
+
+/***====================================================================***/
+
+/*ARGSUSED*/
+static int
+GetXKMKeyNamesTOC( XkbFileInfo * result,
+ XkmInfo * info,
+ int max_toc,
+ xkmSectionInfo *toc_rtrn)
+{
+int num_toc;
+int total_size;
+
+ total_size= num_toc=0;
+ if (SizeXKMKeycodes(result,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMIndicators(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ return num_toc;
+}
+
+/*ARGSUSED*/
+static int
+GetXKMTypesTOC( XkbFileInfo * result,
+ XkmInfo * info,
+ int max_toc,
+ xkmSectionInfo *toc_rtrn)
+{
+int num_toc;
+int total_size;
+
+ total_size= num_toc=0;
+ if (SizeXKMVirtualMods(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMKeyTypes(result,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ return num_toc;
+}
+
+/*ARGSUSED*/
+static int
+GetXKMCompatMapTOC( XkbFileInfo * result,
+ XkmInfo * info,
+ int max_toc,
+ xkmSectionInfo *toc_rtrn)
+{
+int num_toc;
+int total_size;
+
+ total_size= num_toc=0;
+ if (SizeXKMVirtualMods(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMCompatMap(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMIndicators(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ return num_toc;
+}
+
+/*ARGSUSED*/
+static int
+GetXKMSemanticsTOC( XkbFileInfo * result,
+ XkmInfo * info,
+ int max_toc,
+ xkmSectionInfo *toc_rtrn)
+{
+int num_toc;
+int total_size;
+
+ total_size= num_toc=0;
+ if (SizeXKMVirtualMods(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMKeyTypes(result,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMCompatMap(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMIndicators(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ return num_toc;
+}
+
+/*ARGSUSED*/
+static int
+GetXKMLayoutTOC( XkbFileInfo * result,
+ XkmInfo * info,
+ int max_toc,
+ xkmSectionInfo *toc_rtrn)
+{
+int num_toc;
+int total_size;
+
+ total_size= num_toc=0;
+ if (SizeXKMVirtualMods(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMKeycodes(result,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMKeyTypes(result,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMSymbols(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMIndicators(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMGeometry(result,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ return num_toc;
+}
+
+/*ARGSUSED*/
+static int
+GetXKMKeymapTOC( XkbFileInfo * result,
+ XkmInfo * info,
+ int max_toc,
+ xkmSectionInfo *toc_rtrn)
+{
+int num_toc;
+int total_size;
+
+ total_size= num_toc=0;
+ if (SizeXKMVirtualMods(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMKeycodes(result,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMKeyTypes(result,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMCompatMap(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMSymbols(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMIndicators(result,info,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ if (SizeXKMGeometry(result,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ return num_toc;
+}
+
+/*ARGSUSED*/
+static int
+GetXKMGeometryTOC( XkbFileInfo * result,
+ XkmInfo * info,
+ int max_toc,
+ xkmSectionInfo *toc_rtrn)
+{
+int num_toc;
+int total_size;
+
+ total_size= num_toc=0;
+ if (SizeXKMGeometry(result,&toc_rtrn[num_toc],&total_size))
+ num_toc++;
+ return num_toc;
+}
+
+static Bool
+WriteXKMFile( FILE * file,
+ XkbFileInfo * result,
+ int num_toc,
+ xkmSectionInfo *toc,
+ XkmInfo * info)
+{
+register int i;
+unsigned tmp,size,total= 0;
+
+ for (i=0;i<num_toc;i++) {
+ tmp= fwrite(&toc[i],SIZEOF(xkmSectionInfo),1,file);
+ total+= tmp*SIZEOF(xkmSectionInfo);
+ switch (toc[i].type) {
+ case XkmTypesIndex:
+ size= WriteXKMKeyTypes(file,result);
+ break;
+ case XkmCompatMapIndex:
+ size= WriteXKMCompatMap(file,result,info);
+ break;
+ case XkmSymbolsIndex:
+ size= WriteXKMSymbols(file,result,info);
+ break;
+ case XkmIndicatorsIndex:
+ size= WriteXKMIndicators(file,result,info);
+ break;
+ case XkmKeyNamesIndex:
+ size= WriteXKMKeycodes(file,result);
+ break;
+ case XkmGeometryIndex:
+ size= WriteXKMGeometry(file,result);
+ break;
+ case XkmVirtualModsIndex:
+ size= WriteXKMVirtualMods(file,result,info);
+ break;
+ default:
+ _XkbLibError(_XkbErrIllegalTOCType,"WriteXKMFile",toc[i].type);
+ return False;
+ }
+ size+= SIZEOF(xkmSectionInfo);
+ if (size!=toc[i].size) {
+ _XkbLibError(_XkbErrBadLength,XkbConfigText(toc[i].type,XkbMessage),
+ size-toc[i].size);
+ return False;
+ }
+ }
+ return True;
+}
+
+
+#define MAX_TOC 16
+
+Bool
+XkbWriteXKMFile(FILE *out,XkbFileInfo *result)
+{
+Bool ok;
+XkbDescPtr xkb;
+XkmInfo info;
+int size_toc,i;
+unsigned hdr,present;
+xkmFileInfo fileInfo;
+xkmSectionInfo toc[MAX_TOC];
+int (*getTOC)(
+ XkbFileInfo * /* result */,
+ XkmInfo * /* info */,
+ int /* max_to */,
+ xkmSectionInfo */* toc_rtrn */
+);
+
+ switch (result->type) {
+ case XkmKeyNamesIndex:
+ getTOC= GetXKMKeyNamesTOC;
+ break;
+ case XkmTypesIndex:
+ getTOC= GetXKMTypesTOC;
+ break;
+ case XkmCompatMapIndex:
+ getTOC= GetXKMCompatMapTOC;
+ break;
+ case XkmSemanticsFile:
+ getTOC= GetXKMSemanticsTOC;
+ break;
+ case XkmLayoutFile:
+ getTOC= GetXKMLayoutTOC;
+ break;
+ case XkmKeymapFile:
+ getTOC= GetXKMKeymapTOC;
+ break;
+ case XkmGeometryFile:
+ case XkmGeometryIndex:
+ getTOC= GetXKMGeometryTOC;
+ break;
+ default:
+ _XkbLibError(_XkbErrIllegalContents,
+ XkbConfigText(result->type,XkbMessage),0);
+ return False;
+ }
+ xkb= result->xkb;
+
+ bzero((char *)&info,sizeof(XkmInfo));
+ size_toc= (*getTOC)(result,&info,MAX_TOC,toc);
+ if (size_toc<1) {
+ _XkbLibError(_XkbErrEmptyFile,"XkbWriteXKMFile",0);
+ return False;
+ }
+ if (out==NULL) {
+ _XkbLibError(_XkbErrFileCannotOpen,"XkbWriteXKMFile",0);
+ return False;
+ }
+ for (i=present=0;i<size_toc;i++) {
+ toc[i].offset+= 4+SIZEOF(xkmFileInfo);
+ toc[i].offset+= (size_toc*SIZEOF(xkmSectionInfo));
+ if (toc[i].type<=XkmLastIndex) {
+ present|= (1<<toc[i].type);
+ }
+#ifdef DEBUG
+ else {
+ fprintf(stderr,"Illegal section type %d\n",toc[i].type);
+ fprintf(stderr,"Ignored\n");
+ }
+#endif
+ }
+ hdr= (('x'<<24)|('k'<<16)|('m'<<8)|XkmFileVersion);
+ xkmPutCARD32(out,(unsigned long)hdr);
+ fileInfo.type= result->type;
+ fileInfo.min_kc= xkb->min_key_code;
+ fileInfo.max_kc= xkb->max_key_code;
+ fileInfo.num_toc= size_toc;
+ fileInfo.present= present;
+ fileInfo.pad= 0;
+ fwrite(&fileInfo,SIZEOF(xkmFileInfo),1,out);
+ fwrite(toc,SIZEOF(xkmSectionInfo),size_toc,out);
+ ok= WriteXKMFile(out,result,size_toc,toc,&info);
+ return ok;
+}
diff --git a/nx-X11/lib/xkbfile/xkmread.c b/nx-X11/lib/xkbfile/xkmread.c
new file mode 100644
index 000000000..f22941f67
--- /dev/null
+++ b/nx-X11/lib/xkbfile/xkmread.c
@@ -0,0 +1,1315 @@
+/* $Xorg: xkmread.c,v 1.3 2000/08/17 19:46:44 cpqbld Exp $ */
+/************************************************************
+ Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkmread.c,v 1.6 2002/02/13 22:09:42 herrb Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#elif defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <stdio.h>
+
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+
+#ifndef XKB_IN_SERVER
+
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+
+#include <X11/XKBlib.h>
+
+#include <X11/extensions/XKBgeom.h>
+#include "XKMformat.h"
+#include "XKBfileInt.h"
+
+#else
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "misc.h"
+#include "inputstr.h"
+#include <X11/extensions/XKBstr.h>
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XKBgeom.h>
+
+Atom
+XkbInternAtom(Display *dpy,char *str,Bool only_if_exists)
+{
+ if (str==NULL)
+ return None;
+ return MakeAtom(str,strlen(str),!only_if_exists);
+}
+
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+
+char *
+_XkbDupString(char *str)
+{
+char *new;
+
+ if (str==NULL)
+ return NULL;
+ new= (char *)_XkbCalloc(strlen(str)+1,sizeof(char));
+ if (new)
+ strcpy(new,str);
+ return new;
+}
+
+/***====================================================================***/
+
+static XPointer
+XkmInsureSize(XPointer oldPtr,int oldCount,int *newCountRtrn,int elemSize)
+{
+int newCount= *newCountRtrn;
+
+ if (oldPtr==NULL) {
+ if (newCount==0)
+ return NULL;
+ oldPtr= (XPointer)_XkbCalloc(newCount,elemSize);
+ }
+ else if (oldCount<newCount) {
+ oldPtr= (XPointer)_XkbRealloc(oldPtr,newCount*elemSize);
+ if (oldPtr!=NULL) {
+ char *tmp= (char *)oldPtr;
+ bzero(&tmp[oldCount*elemSize],(newCount-oldCount)*elemSize);
+ }
+ }
+ else if (newCount<oldCount) {
+ *newCountRtrn= oldCount;
+ }
+ return oldPtr;
+}
+
+#define XkmInsureTypedSize(p,o,n,t) ((p)=((t *)XkmInsureSize((char *)(p),(o),(n),sizeof(t))))
+
+static CARD8
+XkmGetCARD8(FILE *file,int *pNRead)
+{
+int tmp;
+ tmp= getc(file);
+ if (pNRead&&(tmp!=EOF))
+ (*pNRead)+= 1;
+ return tmp;
+}
+
+static CARD16
+XkmGetCARD16(FILE *file,int *pNRead)
+{
+CARD16 val;
+
+ if ((fread(&val,2,1,file)==1)&&(pNRead))
+ (*pNRead)+= 2;
+ return val;
+}
+
+static CARD32
+XkmGetCARD32(FILE *file,int *pNRead)
+{
+CARD32 val;
+
+ if ((fread(&val,4,1,file)==1)&&(pNRead))
+ (*pNRead)+= 4;
+ return val;
+}
+
+static int
+XkmSkipPadding(FILE *file,unsigned pad)
+{
+register int i,nRead=0;
+
+ for (i=0;i<pad;i++) {
+ if (getc(file)!=EOF)
+ nRead++;
+ }
+ return nRead;
+}
+
+static int
+XkmGetCountedString(FILE *file,char *str,int max_len)
+{
+int count,nRead=0;
+
+ count= XkmGetCARD16(file,&nRead);
+ if (count>0) {
+ int tmp;
+ if (count>max_len) {
+ tmp= fread(str,1,max_len,file);
+ while (tmp<count) {
+ if ((getc(file))!=EOF)
+ tmp++;
+ else break;
+ }
+ }
+ else {
+ tmp= fread(str,1,count,file);
+ }
+ nRead+= tmp;
+ }
+ if (count>=max_len) str[max_len-1]= '\0';
+ else str[count]= '\0';
+ count= XkbPaddedSize(nRead)-nRead;
+ if (count>0)
+ nRead+= XkmSkipPadding(file,count);
+ return nRead;
+}
+
+/***====================================================================***/
+
+static int
+ReadXkmVirtualMods(FILE *file,XkbFileInfo *result,XkbChangesPtr changes)
+{
+register unsigned int i,bit;
+unsigned int bound,named,tmp;
+int nRead=0;
+XkbDescPtr xkb;
+
+ xkb= result->xkb;
+ if (XkbAllocServerMap(xkb,XkbVirtualModsMask,0)!=Success) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmVirtualMods",0);
+ return -1;
+ }
+ bound= XkmGetCARD16(file,&nRead);
+ named= XkmGetCARD16(file,&nRead);
+ for (i=tmp=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (bound&bit) {
+ xkb->server->vmods[i]= XkmGetCARD8(file,&nRead);
+ if (changes)
+ changes->map.vmods|= bit;
+ tmp++;
+ }
+ }
+ if ((i= XkbPaddedSize(tmp)-tmp)>0)
+ nRead+= XkmSkipPadding(file,i);
+ if (XkbAllocNames(xkb,XkbVirtualModNamesMask,0,0)!=Success) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmVirtualMods",0);
+ return -1;
+ }
+ for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ char name[100];
+ if (named&bit) {
+ if (nRead+=XkmGetCountedString(file,name,100)) {
+ xkb->names->vmods[i]= XkbInternAtom(xkb->dpy,name,False);
+ if (changes)
+ changes->names.changed_vmods|= bit;
+ }
+ }
+ }
+ return nRead;
+}
+
+/***====================================================================***/
+
+static int
+ReadXkmKeycodes(FILE *file,XkbFileInfo *result,XkbChangesPtr changes)
+{
+register int i;
+unsigned minKC,maxKC,nAl;
+int nRead=0;
+char name[100];
+XkbKeyNamePtr pN;
+XkbDescPtr xkb;
+
+ xkb= result->xkb;
+ name[0]= '\0';
+ nRead+= XkmGetCountedString(file,name,100);
+ minKC= XkmGetCARD8(file,&nRead);
+ maxKC= XkmGetCARD8(file,&nRead);
+ if (xkb->min_key_code==0) {
+ xkb->min_key_code= minKC;
+ xkb->max_key_code= maxKC;
+ }
+ else {
+ if (minKC<xkb->min_key_code)
+ xkb->min_key_code= minKC;
+ if (maxKC>xkb->max_key_code) {
+ _XkbLibError(_XkbErrBadValue,"ReadXkmKeycodes",maxKC);
+ return -1;
+ }
+ }
+ nAl= XkmGetCARD8(file,&nRead);
+ nRead+= XkmSkipPadding(file,1);
+
+#define WANTED (XkbKeycodesNameMask|XkbKeyNamesMask|XkbKeyAliasesMask)
+ if (XkbAllocNames(xkb,WANTED,0,nAl)!=Success) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmKeycodes",0);
+ return -1;
+ }
+ if (name[0]!='\0') {
+ xkb->names->keycodes= XkbInternAtom(xkb->dpy,name,False);
+ }
+
+ for (pN=&xkb->names->keys[minKC],i=minKC;i<=(int)maxKC;i++,pN++) {
+ if (fread(pN,1,XkbKeyNameLength,file)!=XkbKeyNameLength) {
+ _XkbLibError(_XkbErrBadLength,"ReadXkmKeycodes",0);
+ return -1;
+ }
+ nRead+= XkbKeyNameLength;
+ }
+ if (nAl>0) {
+ XkbKeyAliasPtr pAl;
+ for (pAl= xkb->names->key_aliases,i=0;i<nAl;i++,pAl++) {
+ int tmp;
+ tmp= fread(pAl,1,2*XkbKeyNameLength,file);
+ if (tmp!=2*XkbKeyNameLength) {
+ _XkbLibError(_XkbErrBadLength,"ReadXkmKeycodes",0);
+ return -1;
+ }
+ nRead+= 2*XkbKeyNameLength;
+ }
+ if (changes)
+ changes->names.changed|= XkbKeyAliasesMask;
+ }
+ if (changes)
+ changes->names.changed|= XkbKeyNamesMask;
+ return nRead;
+}
+
+/***====================================================================***/
+
+static int
+ReadXkmKeyTypes(FILE *file,XkbFileInfo *result,XkbChangesPtr changes)
+{
+register unsigned i,n;
+unsigned num_types;
+int nRead=0;
+int tmp;
+XkbKeyTypePtr type;
+xkmKeyTypeDesc wire;
+XkbKTMapEntryPtr entry;
+xkmKTMapEntryDesc wire_entry;
+char buf[100];
+XkbDescPtr xkb;
+
+ xkb= result->xkb;
+ if ((tmp= XkmGetCountedString(file,buf,100))<1) {
+ _XkbLibError(_XkbErrBadLength,"ReadXkmKeyTypes",0);
+ return -1;
+ }
+ nRead+= tmp;
+ if (buf[0]!='\0') {
+ if (XkbAllocNames(xkb,XkbTypesNameMask,0,0)!=Success) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmKeyTypes",0);
+ return -1;
+ }
+ xkb->names->types= XkbInternAtom(xkb->dpy,buf,False);
+ }
+ num_types= XkmGetCARD16(file,&nRead);
+ nRead+= XkmSkipPadding(file,2);
+ if (num_types<1)
+ return nRead;
+ if (XkbAllocClientMap(xkb,XkbKeyTypesMask,num_types)!=Success) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmKeyTypes",0);
+ return nRead;
+ }
+ xkb->map->num_types= num_types;
+ if (num_types<XkbNumRequiredTypes) {
+ _XkbLibError(_XkbErrMissingReqTypes,"ReadXkmKeyTypes",0);
+ return -1;
+ }
+ type= xkb->map->types;
+ for (i=0;i<num_types;i++,type++) {
+ if ((int)fread(&wire,SIZEOF(xkmKeyTypeDesc),1,file)<1) {
+ _XkbLibError(_XkbErrBadLength,"ReadXkmKeyTypes",0);
+ return -1;
+ }
+ nRead+= SIZEOF(xkmKeyTypeDesc);
+ if (((i==XkbOneLevelIndex)&&(wire.numLevels!=1))||
+ (((i==XkbTwoLevelIndex)||(i==XkbAlphabeticIndex)||
+ ((i)==XkbKeypadIndex))&&(wire.numLevels!=2))) {
+ _XkbLibError(_XkbErrBadTypeWidth,"ReadXkmKeyTypes",i);
+ return -1;
+ }
+ tmp= wire.nMapEntries;
+ XkmInsureTypedSize(type->map,type->map_count,&tmp,XkbKTMapEntryRec);
+ if ((wire.nMapEntries>0)&&(type->map==NULL)) {
+ _XkbLibError(_XkbErrBadValue,"ReadXkmKeyTypes",wire.nMapEntries);
+ return -1;
+ }
+ for (n=0,entry= type->map;n<wire.nMapEntries;n++,entry++) {
+ if (fread(&wire_entry,SIZEOF(xkmKTMapEntryDesc),1,file)<(int)1) {
+ _XkbLibError(_XkbErrBadLength,"ReadXkmKeyTypes",0);
+ return -1;
+ }
+ nRead+= SIZEOF(xkmKTMapEntryDesc);
+ entry->active= (wire_entry.virtualMods==0);
+ entry->level= wire_entry.level;
+ entry->mods.mask= wire_entry.realMods;
+ entry->mods.real_mods= wire_entry.realMods;
+ entry->mods.vmods= wire_entry.virtualMods;
+ }
+ nRead+= XkmGetCountedString(file,buf,100);
+ if (((i==XkbOneLevelIndex)&&(strcmp(buf,"ONE_LEVEL")!=0))||
+ ((i==XkbTwoLevelIndex)&&(strcmp(buf,"TWO_LEVEL")!=0))||
+ ((i==XkbAlphabeticIndex)&&(strcmp(buf,"ALPHABETIC")!=0))||
+ ((i==XkbKeypadIndex)&&(strcmp(buf,"KEYPAD")!=0))) {
+ _XkbLibError(_XkbErrBadTypeName,"ReadXkmKeyTypes",0);
+ return -1;
+ }
+ if (buf[0]!='\0') {
+ type->name= XkbInternAtom(xkb->dpy,buf,False);
+ }
+ else type->name= None;
+
+ if (wire.preserve) {
+ xkmModsDesc p_entry;
+ XkbModsPtr pre;
+ XkmInsureTypedSize(type->preserve,type->map_count,&tmp,
+ XkbModsRec);
+ if (type->preserve==NULL) {
+ _XkbLibError(_XkbErrBadMatch,"ReadXkmKeycodes",0);
+ return -1;
+ }
+ for (n=0,pre=type->preserve;n<wire.nMapEntries;n++,pre++) {
+ if (fread(&p_entry,SIZEOF(xkmModsDesc),1,file)<1) {
+ _XkbLibError(_XkbErrBadLength,"ReadXkmKeycodes",0);
+ return -1;
+ }
+ nRead+= SIZEOF(xkmModsDesc);
+ pre->mask= p_entry.realMods;
+ pre->real_mods= p_entry.realMods;
+ pre->vmods= p_entry.virtualMods;
+ }
+ }
+ if (wire.nLevelNames>0) {
+ int width= wire.numLevels;
+ if (wire.nLevelNames>(unsigned)width) {
+ _XkbLibError(_XkbErrBadMatch,"ReadXkmKeycodes",0);
+ return -1;
+ }
+ XkmInsureTypedSize(type->level_names,type->num_levels,&width,Atom);
+ if (type->level_names!=NULL) {
+ for (n=0;n<wire.nLevelNames;n++) {
+ if ((tmp=XkmGetCountedString(file,buf,100))<1)
+ return -1;
+ nRead+= tmp;
+ if (strlen(buf)==0)
+ type->level_names[n]= None;
+ else type->level_names[n]= XkbInternAtom(xkb->dpy,buf,0);
+ }
+ }
+ }
+ type->mods.mask= wire.realMods;
+ type->mods.real_mods= wire.realMods;
+ type->mods.vmods= wire.virtualMods;
+ type->num_levels= wire.numLevels;
+ type->map_count= wire.nMapEntries;
+ }
+ if (changes) {
+ changes->map.changed|= XkbKeyTypesMask;
+ changes->map.first_type= 0;
+ changes->map.num_types= xkb->map->num_types;
+ }
+ return nRead;
+}
+
+/***====================================================================***/
+
+static int
+ReadXkmCompatMap(FILE *file,XkbFileInfo *result,XkbChangesPtr changes)
+{
+register int i;
+unsigned num_si,groups;
+char name[100];
+XkbSymInterpretPtr interp;
+xkmSymInterpretDesc wire;
+unsigned tmp;
+int nRead=0;
+XkbDescPtr xkb;
+XkbCompatMapPtr compat;
+
+ xkb= result->xkb;
+ if ((tmp= XkmGetCountedString(file,name,100))<1) {
+ _XkbLibError(_XkbErrBadLength,"ReadXkmCompatMap",0);
+ return -1;
+ }
+ nRead+= tmp;
+ if (name[0]!='\0') {
+ if (XkbAllocNames(xkb,XkbCompatNameMask,0,0)!=Success) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmCompatMap",0);
+ return -1;
+ }
+ xkb->names->compat= XkbInternAtom(xkb->dpy,name,False);
+ }
+ num_si= XkmGetCARD16(file,&nRead);
+ groups= XkmGetCARD8(file,&nRead);
+ nRead+= XkmSkipPadding(file,1);
+ if (XkbAllocCompatMap(xkb,XkbAllCompatMask,num_si)!=Success)
+ return -1;
+ compat= xkb->compat;
+ compat->num_si= num_si;
+ interp= compat->sym_interpret;
+ for (i=0;i<num_si;i++,interp++) {
+ tmp= fread(&wire,SIZEOF(xkmSymInterpretDesc),1,file);
+ nRead+= tmp*SIZEOF(xkmSymInterpretDesc);
+ interp->sym= wire.sym;
+ interp->mods= wire.mods;
+ interp->match= wire.match;
+ interp->virtual_mod= wire.virtualMod;
+ interp->flags= wire.flags;
+ interp->act.type= wire.actionType;
+ interp->act.data[0]= wire.actionData[0];
+ interp->act.data[1]= wire.actionData[1];
+ interp->act.data[2]= wire.actionData[2];
+ interp->act.data[3]= wire.actionData[3];
+ interp->act.data[4]= wire.actionData[4];
+ interp->act.data[5]= wire.actionData[5];
+ interp->act.data[6]= wire.actionData[6];
+ }
+ if ((num_si>0)&&(changes)) {
+ changes->compat.first_si= 0;
+ changes->compat.num_si= num_si;
+ }
+ if (groups) {
+ register unsigned bit;
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ xkmModsDesc md;
+ if (groups&bit) {
+ tmp= fread(&md,SIZEOF(xkmModsDesc),1,file);
+ nRead+= tmp*SIZEOF(xkmModsDesc);
+ xkb->compat->groups[i].real_mods= md.realMods;
+ xkb->compat->groups[i].vmods= md.virtualMods;
+ if (md.virtualMods != 0) {
+ unsigned mask;
+ if (XkbVirtualModsToReal(xkb,md.virtualMods,&mask))
+ xkb->compat->groups[i].mask= md.realMods|mask;
+ }
+ else xkb->compat->groups[i].mask= md.realMods;
+ }
+ }
+ if (changes)
+ changes->compat.changed_groups|= groups;
+ }
+ return nRead;
+}
+
+static int
+ReadXkmIndicators(FILE *file,XkbFileInfo *result,XkbChangesPtr changes)
+{
+register unsigned nLEDs;
+xkmIndicatorMapDesc wire;
+char buf[100];
+unsigned tmp;
+int nRead=0;
+XkbDescPtr xkb;
+
+ xkb= result->xkb;
+ if ((xkb->indicators==NULL)&&(XkbAllocIndicatorMaps(xkb)!=Success)) {
+ _XkbLibError(_XkbErrBadAlloc,"indicator rec",0);
+ return -1;
+ }
+ if (XkbAllocNames(xkb,XkbIndicatorNamesMask,0,0)!=Success) {
+ _XkbLibError(_XkbErrBadAlloc,"indicator names",0);
+ return -1;
+ }
+ nLEDs= XkmGetCARD8(file,&nRead);
+ nRead+= XkmSkipPadding(file,3);
+ xkb->indicators->phys_indicators= XkmGetCARD32(file,&nRead);
+ while (nLEDs-->0) {
+ Atom name;
+ XkbIndicatorMapPtr map;
+
+ if ((tmp=XkmGetCountedString(file,buf,100))<1) {
+ _XkbLibError(_XkbErrBadLength,"ReadXkmIndicators",0);
+ return -1;
+ }
+ nRead+= tmp;
+ if (buf[0]!='\0')
+ name= XkbInternAtom(xkb->dpy,buf,False);
+ else name= None;
+ if ((tmp=fread(&wire,SIZEOF(xkmIndicatorMapDesc),1,file))<1) {
+ _XkbLibError(_XkbErrBadLength,"ReadXkmIndicators",0);
+ return -1;
+ }
+ nRead+= tmp*SIZEOF(xkmIndicatorMapDesc);
+ if (xkb->names) {
+ xkb->names->indicators[wire.indicator-1]= name;
+ if (changes)
+ changes->names.changed_indicators|= (1<<(wire.indicator-1));
+ }
+ map= &xkb->indicators->maps[wire.indicator-1];
+ map->flags= wire.flags;
+ map->which_groups= wire.which_groups;
+ map->groups= wire.groups;
+ map->which_mods= wire.which_mods;
+ map->mods.mask= wire.real_mods;
+ map->mods.real_mods= wire.real_mods;
+ map->mods.vmods= wire.vmods;
+ map->ctrls= wire.ctrls;
+ }
+ return nRead;
+}
+
+static XkbKeyTypePtr
+FindTypeForKey(XkbDescPtr xkb,Atom name,unsigned width,KeySym *syms)
+{
+ if ((!xkb)||(!xkb->map))
+ return NULL;
+ if (name!=None) {
+ register unsigned i;
+ for (i=0;i<xkb->map->num_types;i++) {
+ if (xkb->map->types[i].name==name) {
+#ifdef DEBUG
+ if (xkb->map->types[i].num_levels!=width)
+ fprintf(stderr,"Group width mismatch between key and type\n");
+#endif
+ return &xkb->map->types[i];
+ }
+ }
+ }
+ if ((width<2)||((syms!=NULL)&&(syms[1]==NoSymbol)))
+ return &xkb->map->types[XkbOneLevelIndex];
+ if (syms!=NULL) {
+ if (XkbKSIsLower(syms[0])&&XkbKSIsUpper(syms[1]))
+ return &xkb->map->types[XkbAlphabeticIndex];
+ else if (XkbKSIsKeypad(syms[0])||XkbKSIsKeypad(syms[1]))
+ return &xkb->map->types[XkbKeypadIndex];
+ }
+ return &xkb->map->types[XkbTwoLevelIndex];
+}
+
+static int
+ReadXkmSymbols(FILE *file,XkbFileInfo *result)
+{
+register int i,g,s,totalVModMaps;
+xkmKeySymMapDesc wireMap;
+char buf[100];
+unsigned minKC,maxKC,groupNames,tmp;
+int nRead=0;
+XkbDescPtr xkb;
+
+ xkb= result->xkb;
+ if ((tmp=XkmGetCountedString(file,buf,100))<1)
+ return -1;
+ nRead+= tmp;
+ minKC= XkmGetCARD8(file,&nRead);
+ maxKC= XkmGetCARD8(file,&nRead);
+ groupNames= XkmGetCARD8(file,&nRead);
+ totalVModMaps= XkmGetCARD8(file,&nRead);
+ if (XkbAllocNames(xkb,
+ XkbSymbolsNameMask|XkbPhysSymbolsNameMask|XkbGroupNamesMask,
+ 0,0)!=Success) {
+ _XkbLibError(_XkbErrBadAlloc,"physical names",0);
+ return -1;
+ }
+ if ((buf[0]!='\0')&&(xkb->names)) {
+ Atom name;
+ name= XkbInternAtom(xkb->dpy,buf,0);
+ xkb->names->symbols= name;
+ xkb->names->phys_symbols= name;
+ }
+ for (i=0,g=1;i<XkbNumKbdGroups;i++,g<<=1) {
+ if (groupNames&g) {
+ if ((tmp=XkmGetCountedString(file,buf,100))<1)
+ return -1;
+ nRead+= tmp;
+ if ((buf[0]!='\0')&&(xkb->names)) {
+ Atom name;
+ name= XkbInternAtom(xkb->dpy,buf,0);
+ xkb->names->groups[i]= name;
+ }
+ else xkb->names->groups[i]= None;
+ }
+ }
+ if (XkbAllocServerMap(xkb,XkbAllServerInfoMask,0)!=Success) {
+ _XkbLibError(_XkbErrBadAlloc,"server map",0);
+ return -1;
+ }
+ if (XkbAllocClientMap(xkb,XkbAllClientInfoMask,0)!=Success) {
+ _XkbLibError(_XkbErrBadAlloc,"client map",0);
+ return -1;
+ }
+ if (XkbAllocControls(xkb,XkbAllControlsMask)!=Success) {
+ _XkbLibError(_XkbErrBadAlloc,"controls",0);
+ return -1;
+ }
+ if ((xkb->map==NULL)||(xkb->server==NULL))
+ return -1;
+ if (xkb->min_key_code<8) xkb->min_key_code= minKC;
+ if (xkb->max_key_code<8) xkb->max_key_code= maxKC;
+ if ((minKC>=8)&&(minKC<xkb->min_key_code))
+ xkb->min_key_code= minKC;
+ if ((maxKC>=8)&&(maxKC>xkb->max_key_code)) {
+ _XkbLibError(_XkbErrBadValue,"keys in symbol map",maxKC);
+ return -1;
+ }
+ for (i=minKC;i<=(int)maxKC;i++) {
+ Atom typeName[XkbNumKbdGroups];
+ XkbKeyTypePtr type[XkbNumKbdGroups];
+ if ((tmp=fread(&wireMap,SIZEOF(xkmKeySymMapDesc),1,file))<1) {
+ _XkbLibError(_XkbErrBadLength,"ReadXkmSymbols",0);
+ return -1;
+ }
+ nRead+= tmp*SIZEOF(xkmKeySymMapDesc);
+ bzero((char *)typeName,XkbNumKbdGroups*sizeof(Atom));
+ bzero((char *)type,XkbNumKbdGroups*sizeof(XkbKeyTypePtr));
+ if (wireMap.flags&XkmKeyHasTypes) {
+ register int g;
+ for (g=0;g<XkbNumKbdGroups;g++) {
+ if ((wireMap.flags&(1<<g))&&
+ ((tmp=XkmGetCountedString(file,buf,100))>0)) {
+ typeName[g]= XkbInternAtom(xkb->dpy,buf,1);
+ nRead+= tmp;
+ }
+ type[g]=FindTypeForKey(xkb,typeName[g],wireMap.width,NULL);
+ if (type[g]==NULL) {
+ _XkbLibError(_XkbErrMissingTypes,"ReadXkmSymbols",0);
+ return -1;
+ }
+ if (typeName[g]==type[g]->name)
+ xkb->server->explicit[i]|= (1<<g);
+ }
+ }
+ if (wireMap.flags&XkmRepeatingKey) {
+ xkb->ctrls->per_key_repeat[i/8]|= (1<<(i%8));
+ xkb->server->explicit[i]|= XkbExplicitAutoRepeatMask;
+ }
+ else if (wireMap.flags&XkmNonRepeatingKey) {
+ xkb->ctrls->per_key_repeat[i/8]&= ~(1<<(i%8));
+ xkb->server->explicit[i]|= XkbExplicitAutoRepeatMask;
+ }
+ xkb->map->modmap[i]= wireMap.modifier_map;
+ if (XkbNumGroups(wireMap.num_groups)>0) {
+ KeySym *sym;
+ int nSyms;
+
+ if (XkbNumGroups(wireMap.num_groups)>xkb->ctrls->num_groups)
+ xkb->ctrls->num_groups= wireMap.num_groups;
+ nSyms= XkbNumGroups(wireMap.num_groups)*wireMap.width;
+ sym= XkbResizeKeySyms(xkb,i,nSyms);
+ if (!sym)
+ return -1;
+ for (s=0;s<nSyms;s++) {
+ *sym++= XkmGetCARD32(file,&nRead);
+ }
+ if (wireMap.flags&XkmKeyHasActions) {
+ XkbAction * act;
+ act= XkbResizeKeyActions(xkb,i,nSyms);
+ for (s=0;s<nSyms;s++,act++) {
+ tmp=fread(act,SIZEOF(xkmActionDesc),1,file);
+ nRead+= tmp*SIZEOF(xkmActionDesc);
+ }
+ xkb->server->explicit[i]|= XkbExplicitInterpretMask;
+ }
+ }
+ for (g=0;g<XkbNumGroups(wireMap.num_groups);g++) {
+ if (((xkb->server->explicit[i]&(1<<g))==0)||(type[g]==NULL)) {
+ KeySym *tmpSyms;
+ tmpSyms= XkbKeySymsPtr(xkb,i)+(wireMap.width*g);
+ type[g]= FindTypeForKey(xkb,None,wireMap.width,tmpSyms);
+ }
+ xkb->map->key_sym_map[i].kt_index[g]= type[g]-(&xkb->map->types[0]);
+ }
+ xkb->map->key_sym_map[i].group_info= wireMap.num_groups;
+ xkb->map->key_sym_map[i].width= wireMap.width;
+ if (wireMap.flags&XkmKeyHasBehavior) {
+ xkmBehaviorDesc b;
+ tmp= fread(&b,SIZEOF(xkmBehaviorDesc),1,file);
+ nRead+= tmp*SIZEOF(xkmBehaviorDesc);
+ xkb->server->behaviors[i].type= b.type;
+ xkb->server->behaviors[i].data= b.data;
+ xkb->server->explicit[i]|= XkbExplicitBehaviorMask;
+ }
+ }
+ if (totalVModMaps>0) {
+ xkmVModMapDesc v;
+ for (i=0;i<totalVModMaps;i++) {
+ tmp= fread(&v,SIZEOF(xkmVModMapDesc),1,file);
+ nRead+= tmp*SIZEOF(xkmVModMapDesc);
+ if (tmp>0)
+ xkb->server->vmodmap[v.key]= v.vmods;
+ }
+ }
+ return nRead;
+}
+
+static int
+ReadXkmGeomDoodad(
+ FILE * file,
+ Display * dpy,
+ XkbGeometryPtr geom,
+ XkbSectionPtr section)
+{
+XkbDoodadPtr doodad;
+xkmDoodadDesc doodadWire;
+char buf[100];
+unsigned tmp;
+int nRead=0;
+
+ nRead+= XkmGetCountedString(file,buf,100);
+ tmp= fread(&doodadWire,SIZEOF(xkmDoodadDesc),1,file);
+ nRead+= SIZEOF(xkmDoodadDesc)*tmp;
+ doodad= XkbAddGeomDoodad(geom,section,XkbInternAtom(dpy,buf,False));
+ if (!doodad)
+ return nRead;
+ doodad->any.type= doodadWire.any.type;
+ doodad->any.priority= doodadWire.any.priority;
+ doodad->any.top= doodadWire.any.top;
+ doodad->any.left= doodadWire.any.left;
+ switch (doodadWire.any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ doodad->shape.angle= doodadWire.shape.angle;
+ doodad->shape.color_ndx= doodadWire.shape.color_ndx;
+ doodad->shape.shape_ndx= doodadWire.shape.shape_ndx;
+ break;
+ case XkbTextDoodad:
+ doodad->text.angle= doodadWire.text.angle;
+ doodad->text.width= doodadWire.text.width;
+ doodad->text.height= doodadWire.text.height;
+ doodad->text.color_ndx= doodadWire.text.color_ndx;
+ nRead+= XkmGetCountedString(file,buf,100);
+ doodad->text.text= _XkbDupString(buf);
+ nRead+= XkmGetCountedString(file,buf,100);
+ doodad->text.font= _XkbDupString(buf);
+ break;
+ case XkbIndicatorDoodad:
+ doodad->indicator.shape_ndx= doodadWire.indicator.shape_ndx;
+ doodad->indicator.on_color_ndx= doodadWire.indicator.on_color_ndx;
+ doodad->indicator.off_color_ndx= doodadWire.indicator.off_color_ndx;
+ break;
+ case XkbLogoDoodad:
+ doodad->logo.angle= doodadWire.logo.angle;
+ doodad->logo.color_ndx= doodadWire.logo.color_ndx;
+ doodad->logo.shape_ndx= doodadWire.logo.shape_ndx;
+ nRead+= XkmGetCountedString(file,buf,100);
+ doodad->logo.logo_name= _XkbDupString(buf);
+ break;
+ default:
+ /* report error? */
+ return nRead;
+ }
+ return nRead;
+}
+
+static int
+ReadXkmGeomOverlay( FILE * file,
+ Display * dpy,
+ XkbGeometryPtr geom,
+ XkbSectionPtr section)
+{
+char buf[100];
+unsigned tmp;
+int nRead=0;
+XkbOverlayPtr ol;
+XkbOverlayRowPtr row;
+xkmOverlayDesc olWire;
+xkmOverlayRowDesc rowWire;
+register int r;
+
+ nRead+= XkmGetCountedString(file,buf,100);
+ tmp= fread(&olWire,SIZEOF(xkmOverlayDesc),1,file);
+ nRead+= tmp*SIZEOF(xkmOverlayDesc);
+ ol= XkbAddGeomOverlay(section,XkbInternAtom(dpy,buf,False),
+ olWire.num_rows);
+ if (!ol)
+ return nRead;
+ for (r=0;r<olWire.num_rows;r++) {
+ int k;
+ xkmOverlayKeyDesc keyWire;
+ tmp= fread(&rowWire,SIZEOF(xkmOverlayRowDesc),1,file);
+ nRead+= tmp*SIZEOF(xkmOverlayRowDesc);
+ row= XkbAddGeomOverlayRow(ol,rowWire.row_under,rowWire.num_keys);
+ if (!row) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeomOverlay",0);
+ return nRead;
+ }
+ for (k=0;k<rowWire.num_keys;k++) {
+ tmp= fread(&keyWire,SIZEOF(xkmOverlayKeyDesc),1,file);
+ nRead+= tmp*SIZEOF(xkmOverlayKeyDesc);
+ memcpy(row->keys[k].over.name,keyWire.over,XkbKeyNameLength);
+ memcpy(row->keys[k].under.name,keyWire.under,XkbKeyNameLength);
+ }
+ row->num_keys= rowWire.num_keys;
+ }
+ return nRead;
+}
+
+static int
+ReadXkmGeomSection( FILE * file,
+ Display * dpy,
+ XkbGeometryPtr geom)
+{
+register int i;
+XkbSectionPtr section;
+xkmSectionDesc sectionWire;
+unsigned tmp;
+int nRead= 0;
+char buf[100];
+Atom nameAtom;
+
+ nRead+= XkmGetCountedString(file,buf,100);
+ nameAtom= XkbInternAtom(dpy,buf,False);
+ tmp= fread(&sectionWire,SIZEOF(xkmSectionDesc),1,file);
+ nRead+= SIZEOF(xkmSectionDesc)*tmp;
+ section= XkbAddGeomSection(geom,nameAtom,sectionWire.num_rows,
+ sectionWire.num_doodads,
+ sectionWire.num_overlays);
+ if (!section) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeomSection",0);
+ return nRead;
+ }
+ section->top= sectionWire.top;
+ section->left= sectionWire.left;
+ section->width= sectionWire.width;
+ section->height= sectionWire.height;
+ section->angle= sectionWire.angle;
+ section->priority= sectionWire.priority;
+ if (sectionWire.num_rows>0) {
+ register int k;
+ XkbRowPtr row;
+ xkmRowDesc rowWire;
+ XkbKeyPtr key;
+ xkmKeyDesc keyWire;
+
+ for (i=0;i<sectionWire.num_rows;i++) {
+ tmp= fread(&rowWire,SIZEOF(xkmRowDesc),1,file);
+ nRead+= SIZEOF(xkmRowDesc)*tmp;
+ row= XkbAddGeomRow(section,rowWire.num_keys);
+ if (!row) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmKeycodes",0);
+ return nRead;
+ }
+ row->top= rowWire.top;
+ row->left= rowWire.left;
+ row->vertical= rowWire.vertical;
+ for (k=0;k<rowWire.num_keys;k++) {
+ tmp= fread(&keyWire,SIZEOF(xkmKeyDesc),1,file);
+ nRead+= SIZEOF(xkmKeyDesc)*tmp;
+ key= XkbAddGeomKey(row);
+ if (!key) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeomSection",0);
+ return nRead;
+ }
+ memcpy(key->name.name,keyWire.name,XkbKeyNameLength);
+ key->gap= keyWire.gap;
+ key->shape_ndx= keyWire.shape_ndx;
+ key->color_ndx= keyWire.color_ndx;
+ }
+ }
+ }
+ if (sectionWire.num_doodads>0) {
+ for (i=0;i<sectionWire.num_doodads;i++) {
+ tmp= ReadXkmGeomDoodad(file,dpy,geom,section);
+ nRead+= tmp;
+ if (tmp<1)
+ return nRead;
+ }
+ }
+ if (sectionWire.num_overlays>0) {
+ for (i=0;i<sectionWire.num_overlays;i++) {
+ tmp= ReadXkmGeomOverlay(file,dpy,geom,section);
+ nRead+= tmp;
+ if (tmp<1)
+ return nRead;
+ }
+ }
+ return nRead;
+}
+
+static int
+ReadXkmGeometry(FILE *file,XkbFileInfo *result)
+{
+register int i;
+char buf[100];
+unsigned tmp;
+int nRead= 0;
+xkmGeometryDesc wireGeom;
+XkbGeometryPtr geom;
+XkbGeometrySizesRec sizes;
+
+ nRead+= XkmGetCountedString(file,buf,100);
+ tmp= fread(&wireGeom,SIZEOF(xkmGeometryDesc),1,file);
+ nRead+= tmp*SIZEOF(xkmGeometryDesc);
+ sizes.which= XkbGeomAllMask;
+ sizes.num_properties= wireGeom.num_properties;
+ sizes.num_colors= wireGeom.num_colors;
+ sizes.num_shapes= wireGeom.num_shapes;
+ sizes.num_sections= wireGeom.num_sections;
+ sizes.num_doodads= wireGeom.num_doodads;
+ sizes.num_key_aliases= wireGeom.num_key_aliases;
+ if (XkbAllocGeometry(result->xkb,&sizes)!=Success) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeometry",0);
+ return nRead;
+ }
+ geom= result->xkb->geom;
+ geom->name= XkbInternAtom(result->xkb->dpy,buf,False);
+ geom->width_mm= wireGeom.width_mm;
+ geom->height_mm= wireGeom.height_mm;
+ nRead+= XkmGetCountedString(file,buf,100);
+ geom->label_font= _XkbDupString(buf);
+ if (wireGeom.num_properties>0) {
+ char val[1024];
+ for (i=0;i<wireGeom.num_properties;i++) {
+ nRead+= XkmGetCountedString(file,buf,100);
+ nRead+= XkmGetCountedString(file,val,1024);
+ if (XkbAddGeomProperty(geom,buf,val)==NULL) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeometry",0);
+ return nRead;
+ }
+ }
+ }
+ if (wireGeom.num_colors>0) {
+ for (i=0;i<wireGeom.num_colors;i++) {
+ nRead+= XkmGetCountedString(file,buf,100);
+ if (XkbAddGeomColor(geom,buf,i)==NULL) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeometry",0);
+ return nRead;
+ }
+ }
+ }
+ geom->base_color= &geom->colors[wireGeom.base_color_ndx];
+ geom->label_color= &geom->colors[wireGeom.label_color_ndx];
+ if (wireGeom.num_shapes>0) {
+ XkbShapePtr shape;
+ xkmShapeDesc shapeWire;
+ Atom nameAtom;
+ for (i=0;i<wireGeom.num_shapes;i++) {
+ register int n;
+ XkbOutlinePtr ol;
+ xkmOutlineDesc olWire;
+ nRead+= XkmGetCountedString(file,buf,100);
+ nameAtom= XkbInternAtom(result->xkb->dpy,buf,False);
+ tmp= fread(&shapeWire,SIZEOF(xkmShapeDesc),1,file);
+ nRead+= tmp*SIZEOF(xkmShapeDesc);
+ shape= XkbAddGeomShape(geom,nameAtom,shapeWire.num_outlines);
+ if (!shape) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeometry",0);
+ return nRead;
+ }
+ for (n=0;n<shapeWire.num_outlines;n++) {
+ register int p;
+ xkmPointDesc ptWire;
+ tmp= fread(&olWire,SIZEOF(xkmOutlineDesc),1,file);
+ nRead+= tmp*SIZEOF(xkmOutlineDesc);
+ ol= XkbAddGeomOutline(shape,olWire.num_points);
+ if (!ol) {
+ _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeometry",0);
+ return nRead;
+ }
+ ol->num_points= olWire.num_points;
+ ol->corner_radius= olWire.corner_radius;
+ for (p=0;p<olWire.num_points;p++) {
+ tmp= fread(&ptWire,SIZEOF(xkmPointDesc),1,file);
+ nRead+= tmp*SIZEOF(xkmPointDesc);
+ ol->points[p].x= ptWire.x;
+ ol->points[p].y= ptWire.y;
+ if (ptWire.x<shape->bounds.x1) shape->bounds.x1= ptWire.x;
+ if (ptWire.x>shape->bounds.x2) shape->bounds.x2= ptWire.x;
+ if (ptWire.y<shape->bounds.y1) shape->bounds.y1= ptWire.y;
+ if (ptWire.y>shape->bounds.y2) shape->bounds.y2= ptWire.y;
+ }
+ }
+ if (shapeWire.primary_ndx!=XkbNoShape)
+ shape->primary= &shape->outlines[shapeWire.primary_ndx];
+ if (shapeWire.approx_ndx!=XkbNoShape)
+ shape->approx= &shape->outlines[shapeWire.approx_ndx];
+ }
+ }
+ if (wireGeom.num_sections>0) {
+ for (i=0;i<wireGeom.num_sections;i++) {
+ tmp= ReadXkmGeomSection(file,result->xkb->dpy,geom);
+ nRead+= tmp;
+ if (tmp==0)
+ return nRead;
+ }
+ }
+ if (wireGeom.num_doodads>0) {
+ for (i=0;i<wireGeom.num_doodads;i++) {
+ tmp= ReadXkmGeomDoodad(file,result->xkb->dpy,geom,NULL);
+ nRead+= tmp;
+ if (tmp==0)
+ return nRead;
+ }
+ }
+ if ((wireGeom.num_key_aliases>0)&&(geom->key_aliases)) {
+ int sz= XkbKeyNameLength*2;
+ int num= wireGeom.num_key_aliases;
+ if (fread(geom->key_aliases,sz,num,file)!=num) {
+ _XkbLibError(_XkbErrBadLength,"ReadXkmGeometry",0);
+ return -1;
+ }
+ nRead+= (num*sz);
+ geom->num_key_aliases= num;
+ }
+ return nRead;
+}
+
+Bool
+XkmProbe(FILE *file)
+{
+unsigned hdr,tmp;
+int nRead=0;
+
+ hdr= (('x'<<24)|('k'<<16)|('m'<<8)|XkmFileVersion);
+ tmp= XkmGetCARD32(file,&nRead);
+ if (tmp!=hdr) {
+ if ((tmp&(~0xff))==(hdr&(~0xff))) {
+ _XkbLibError(_XkbErrBadFileVersion,"XkmProbe",tmp&0xff);
+ }
+ return 0;
+ }
+ return 1;
+}
+
+Bool
+XkmReadTOC(FILE *file,xkmFileInfo* file_info,int max_toc,xkmSectionInfo *toc)
+{
+unsigned hdr,tmp;
+int nRead=0;
+unsigned i,size_toc;
+
+ hdr= (('x'<<24)|('k'<<16)|('m'<<8)|XkmFileVersion);
+ tmp= XkmGetCARD32(file,&nRead);
+ if (tmp!=hdr) {
+ if ((tmp&(~0xff))==(hdr&(~0xff))) {
+ _XkbLibError(_XkbErrBadFileVersion,"XkmReadTOC",tmp&0xff);
+ }
+ else {
+ _XkbLibError(_XkbErrBadFileType,"XkmReadTOC",tmp);
+ }
+ return 0;
+ }
+ fread(file_info,SIZEOF(xkmFileInfo),1,file);
+ size_toc= file_info->num_toc;
+ if (size_toc>max_toc) {
+#ifdef DEBUG
+ fprintf(stderr,"Warning! Too many TOC entries; last %d ignored\n",
+ size_toc-max_toc);
+#endif
+ size_toc= max_toc;
+ }
+ for (i=0;i<size_toc;i++) {
+ fread(&toc[i],SIZEOF(xkmSectionInfo),1,file);
+ }
+ return 1;
+}
+
+xkmSectionInfo *
+XkmFindTOCEntry(xkmFileInfo *finfo,xkmSectionInfo *toc,unsigned type)
+{
+register int i;
+
+ for (i=0;i<finfo->num_toc;i++) {
+ if (toc[i].type==type)
+ return &toc[i];
+ }
+ return NULL;
+}
+
+Bool
+XkmReadFileSection( FILE * file,
+ xkmSectionInfo * toc,
+ XkbFileInfo * result,
+ unsigned * loaded_rtrn)
+{
+xkmSectionInfo tmpTOC;
+int nRead;
+
+ if ((!result)||(!result->xkb)) {
+ _XkbLibError(_XkbErrBadMatch,"XkmReadFileSection",0);
+ return 0;
+ }
+ fseek(file,toc->offset,SEEK_SET);
+ fread(&tmpTOC,SIZEOF(xkmSectionInfo),1,file);
+ nRead= SIZEOF(xkmSectionInfo);
+ if ((tmpTOC.type!=toc->type)||(tmpTOC.format!=toc->format)||
+ (tmpTOC.size!=toc->size)||(tmpTOC.offset!=toc->offset)) {
+ _XkbLibError(_XkbErrIllegalContents,"XkmReadFileSection",0);
+ return 0;
+ }
+ switch (tmpTOC.type) {
+ case XkmVirtualModsIndex:
+ nRead+= ReadXkmVirtualMods(file,result,NULL);
+ if ((loaded_rtrn)&&(nRead>=0))
+ *loaded_rtrn|= XkmVirtualModsMask;
+ break;
+ case XkmTypesIndex:
+ nRead+= ReadXkmKeyTypes(file,result,NULL);
+ if ((loaded_rtrn)&&(nRead>=0))
+ *loaded_rtrn|= XkmTypesMask;
+ break;
+ case XkmCompatMapIndex:
+ nRead+= ReadXkmCompatMap(file,result,NULL);
+ if ((loaded_rtrn)&&(nRead>=0))
+ *loaded_rtrn|= XkmCompatMapMask;
+ break;
+ case XkmKeyNamesIndex:
+ nRead+= ReadXkmKeycodes(file,result,NULL);
+ if ((loaded_rtrn)&&(nRead>=0))
+ *loaded_rtrn|= XkmKeyNamesMask;
+ break;
+ case XkmSymbolsIndex:
+ nRead+= ReadXkmSymbols(file,result);
+ if ((loaded_rtrn)&&(nRead>=0))
+ *loaded_rtrn|= XkmSymbolsMask;
+ break;
+ case XkmIndicatorsIndex:
+ nRead+= ReadXkmIndicators(file,result,NULL);
+ if ((loaded_rtrn)&&(nRead>=0))
+ *loaded_rtrn|= XkmIndicatorsMask;
+ break;
+ case XkmGeometryIndex:
+ nRead+= ReadXkmGeometry(file,result);
+ if ((loaded_rtrn)&&(nRead>=0))
+ *loaded_rtrn|= XkmGeometryMask;
+ break;
+ default:
+ _XkbLibError(_XkbErrBadImplementation,
+ XkbConfigText(tmpTOC.type,XkbMessage),0);
+ nRead= 0;
+ break;
+ }
+ if (nRead!=tmpTOC.size) {
+ _XkbLibError(_XkbErrBadLength,XkbConfigText(tmpTOC.type,XkbMessage),
+ nRead-tmpTOC.size);
+ return 0;
+ }
+ return (nRead>=0);
+}
+
+char *
+XkmReadFileSectionName(FILE *file,xkmSectionInfo *toc)
+{
+xkmSectionInfo tmpTOC;
+char name[100];
+
+ if ((!file)||(!toc))
+ return 0;
+ switch (toc->type) {
+ case XkmVirtualModsIndex:
+ case XkmIndicatorsIndex:
+ break;
+ case XkmTypesIndex:
+ case XkmCompatMapIndex:
+ case XkmKeyNamesIndex:
+ case XkmSymbolsIndex:
+ case XkmGeometryIndex:
+ fseek(file,toc->offset,SEEK_SET);
+ fread(&tmpTOC,SIZEOF(xkmSectionInfo),1,file);
+ if ((tmpTOC.type!=toc->type)||(tmpTOC.format!=toc->format)||
+ (tmpTOC.size!=toc->size)||(tmpTOC.offset!=toc->offset)) {
+ _XkbLibError(_XkbErrIllegalContents,"XkmReadFileSectionName",0);
+ return 0;
+ }
+ if (XkmGetCountedString(file,name,100)>0)
+ return _XkbDupString(name);
+ break;
+ default:
+ _XkbLibError(_XkbErrBadImplementation,
+ XkbConfigText(tmpTOC.type,XkbMessage),0);
+ break;
+ }
+ return NULL;
+}
+
+/***====================================================================***/
+
+#define MAX_TOC 16
+unsigned
+XkmReadFile(FILE *file,unsigned need,unsigned want,XkbFileInfo *result)
+{
+register unsigned i;
+xkmSectionInfo toc[MAX_TOC],tmpTOC;
+xkmFileInfo fileInfo;
+unsigned tmp,nRead=0;
+unsigned which= need|want;
+
+ if (!XkmReadTOC(file,&fileInfo,MAX_TOC,toc))
+ return which;
+ if ((fileInfo.present&need)!=need) {
+ _XkbLibError(_XkbErrIllegalContents,"XkmReadFile",
+ need&(~fileInfo.present));
+ return which;
+ }
+ result->type= fileInfo.type;
+ if (result->xkb==NULL)
+ result->xkb= XkbAllocKeyboard();
+ for (i=0;i<fileInfo.num_toc;i++) {
+#ifdef SEEK_SET
+ fseek(file,toc[i].offset,SEEK_SET);
+#else
+ fseek(file,toc[i].offset,0);
+#endif
+ tmp= fread(&tmpTOC,SIZEOF(xkmSectionInfo),1,file);
+ nRead= tmp*SIZEOF(xkmSectionInfo);
+ if ((tmpTOC.type!=toc[i].type)||(tmpTOC.format!=toc[i].format)||
+ (tmpTOC.size!=toc[i].size)||(tmpTOC.offset!=toc[i].offset)) {
+ return which;
+ }
+ if ((which&(1<<tmpTOC.type))==0) {
+ continue;
+ }
+ switch (tmpTOC.type) {
+ case XkmVirtualModsIndex:
+ tmp= ReadXkmVirtualMods(file,result,NULL);
+ break;
+ case XkmTypesIndex:
+ tmp= ReadXkmKeyTypes(file,result,NULL);
+ break;
+ case XkmCompatMapIndex:
+ tmp= ReadXkmCompatMap(file,result,NULL);
+ break;
+ case XkmKeyNamesIndex:
+ tmp= ReadXkmKeycodes(file,result,NULL);
+ break;
+ case XkmIndicatorsIndex:
+ tmp= ReadXkmIndicators(file,result,NULL);
+ break;
+ case XkmSymbolsIndex:
+ tmp= ReadXkmSymbols(file,result);
+ break;
+ case XkmGeometryIndex:
+ tmp= ReadXkmGeometry(file,result);
+ break;
+ default:
+ _XkbLibError(_XkbErrBadImplementation,
+ XkbConfigText(tmpTOC.type,XkbMessage),0);
+ tmp= 0;
+ break;
+ }
+ if (tmp>0) {
+ nRead+= tmp;
+ which&= ~(1<<toc[i].type);
+ result->defined|= (1<<toc[i].type);
+ }
+ if (nRead!=tmpTOC.size) {
+ _XkbLibError(_XkbErrBadLength,XkbConfigText(tmpTOC.type,XkbMessage),
+ nRead-tmpTOC.size);
+ }
+ }
+ return which;
+}
diff --git a/nx-X11/lib/xkbui/Imakefile b/nx-X11/lib/xkbui/Imakefile
new file mode 100644
index 000000000..f27bad64d
--- /dev/null
+++ b/nx-X11/lib/xkbui/Imakefile
@@ -0,0 +1,25 @@
+XCOMM $XConsortium: Imakefile /main/1 1995/11/30 19:00:42 kaleb $
+XCOMM $XFree86: xc/lib/xkbui/Imakefile,v 3.4 2003/10/15 21:23:38 herrb Exp $
+#define DoNormalLib NormalLibxkbui
+#define DoSharedLib SharedLibxkbui
+#define DoExtraLib SharedLibxkbui
+#define DoDebugLib DebugLibxkbui
+#define DoProfileLib ProfileLibxkbui
+#define HasSharedData NO
+#define LibName xkbui
+#define SoRev SOXKBUIREV
+#define IncSubdir X11
+#define IncSubSubdir extensions
+
+#ifdef SharedxkbuiReqs
+REQUIREDLIBS = SharedxkbuiReqs
+#endif
+
+ SRCS = XKBui.c
+ OBJS = XKBui.o
+ HEADERS = XKBui.h
+ INCLUDES = -I. -I$(EXTINCSRC) -I../xkbfile
+
+#include <Library.tmpl>
+
+DependTarget()
diff --git a/nx-X11/lib/xkbui/XKBui.c b/nx-X11/lib/xkbui/XKBui.c
new file mode 100644
index 000000000..747071690
--- /dev/null
+++ b/nx-X11/lib/xkbui/XKBui.c
@@ -0,0 +1,666 @@
+/* $XConsortium: XKBui.c /main/2 1995/12/07 21:18:19 kaleb $ */
+/************************************************************
+ Copyright (c) 1996 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86: xc/lib/xkbui/XKBui.c,v 3.6 1999/06/20 07:14:08 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#if defined(SVR4) && defined(i386) && !defined(_XOPEN_SOURCE)
+# define _XOPEN_SOURCE
+# include <math.h>
+# undef _XOPEN_SOURCE
+#else
+# include <math.h>
+#endif /* _XOPEN_SOURCE */
+
+#include <X11/Xfuncs.h>
+#include "XKBuiPriv.h"
+#include <X11/extensions/XKBfile.h>
+
+#ifndef M_PI
+# define M_PI 3.141592653589793238462
+#endif
+
+/* This function is an internal function in the xkbfile library */
+extern int _XkbStrCaseCmp(
+ char * /* str1 */,
+ char * /* str2 */
+);
+
+
+static XkbUI_ViewOptsRec dfltOpts = {
+ XkbUI_AllViewOptsMask /* present */,
+ 1 /* fg */,
+ 0 /* bg */,
+ XkbUI_KeyNames /* label_mode */,
+ 0 /* color_mode */,
+ {
+ 0 /* viewport.x */,
+ 0 /* viewport.y */,
+ 640 /* viewport.width */,
+ 480 /* viewport.height */
+ },
+ 10, 10, /* margin_width, margin_height */
+ None
+};
+
+XkbUI_ViewPtr
+XkbUI_SimpleInit(Display *dpy,Window win,int width,int height)
+{
+XkbDescPtr xkb;
+
+ if ((!dpy)||(win==None)||(width<1)||(height<1))
+ return NULL;
+ xkb= XkbGetKeyboard(dpy,XkbGBN_AllComponentsMask,XkbUseCoreKbd);
+ if (!xkb)
+ return NULL;
+ return XkbUI_Init(dpy,win,width,height,xkb,NULL);
+}
+
+static void
+_XkbUI_AllocateColors(XkbUI_ViewPtr view)
+{
+register int i;
+Display * dpy;
+XColor sdef,xdef;
+XkbDescPtr xkb;
+
+ dpy= view->dpy;
+ xkb= view->xkb;
+ if (view->opts.cmap==None)
+ view->opts.cmap= DefaultColormap(dpy,DefaultScreen(dpy));
+ for (i=0;i<xkb->geom->num_colors;i++) {
+ char *spec;
+ Bool found;
+
+ spec= xkb->geom->colors[i].spec;
+ found= False;
+ if (XAllocNamedColor(view->dpy,view->opts.cmap,spec,&sdef,&xdef)) {
+ xkb->geom->colors[i].pixel= sdef.pixel;
+#ifdef DEBUG
+ fprintf(stderr,"got pixel %d for \"%s\"\n",sdef.pixel,spec);
+#endif
+ found= True;
+ }
+ if ((!found)&&(XkbLookupCanonicalRGBColor(spec,&sdef))) {
+ char buf[20];
+ sprintf(buf,"#%02x%02x%02x",(sdef.red>>8)&0xff,
+ (sdef.green>>8)&0xff,
+ (sdef.blue>>8)&&0xff);
+ if (XAllocNamedColor(view->dpy,view->opts.cmap,buf,&sdef,&xdef)) {
+ xkb->geom->colors[i].pixel= sdef.pixel;
+#ifdef DEBUG
+ fprintf(stderr,"got pixel %d for \"%s\"\n",sdef.pixel,spec);
+#endif
+ found= True;
+ }
+ }
+ if (!found) {
+ xkb->geom->colors[i].pixel= view->opts.fg;
+ fprintf(stderr,"Couldn't allocate color \"%s\"\n",spec);
+ }
+ }
+ return;
+}
+
+XkbUI_ViewPtr
+XkbUI_Init( Display * dpy,
+ Window win,
+ int width,
+ int height,
+ XkbDescPtr xkb,
+ XkbUI_ViewOptsPtr opts)
+{
+XGCValues xgcv;
+XkbUI_ViewPtr view;
+int scrn;
+
+ if ((!dpy)||(!xkb)||(!xkb->geom)||(win==None)||(width<1)||(height<1))
+ return NULL;
+ view= _XkbTypedCalloc(1,XkbUI_ViewRec);
+ if (!view)
+ return NULL;
+ scrn= DefaultScreen(dpy);
+ view->dpy= dpy;
+ view->xkb= xkb;
+ view->win= win;
+ view->opts= dfltOpts;
+ view->opts.fg= WhitePixel(dpy,scrn);
+ view->opts.bg= BlackPixel(dpy,scrn);
+ view->opts.viewport.x= 0;
+ view->opts.viewport.y= 0;
+ view->opts.viewport.width= width;
+ view->opts.viewport.height= height;
+ if ((opts)&&(opts->present)) {
+ if (opts->present&XkbUI_BackgroundMask)
+ view->opts.bg= opts->bg;
+ if (opts->present&XkbUI_ForegroundMask)
+ view->opts.fg= opts->fg;
+ if (opts->present&XkbUI_LabelModeMask)
+ view->opts.label_mode= opts->label_mode;
+ if (opts->present&XkbUI_ColorModeMask)
+ view->opts.color_mode= opts->color_mode;
+ if (opts->present&XkbUI_WidthMask)
+ view->opts.viewport.width= opts->viewport.width;
+ if (opts->present&XkbUI_HeightMask)
+ view->opts.viewport.height= opts->viewport.height;
+ if (opts->present&XkbUI_XOffsetMask)
+ view->opts.viewport.x= opts->viewport.x;
+ if (opts->present&XkbUI_YOffsetMask)
+ view->opts.viewport.y= opts->viewport.y;
+ if (opts->present&XkbUI_MarginWidthMask)
+ view->opts.margin_width= opts->margin_width;
+ if (opts->present&XkbUI_MarginHeightMask)
+ view->opts.margin_height= opts->margin_height;
+ if (opts->present&XkbUI_ColormapMask)
+ view->opts.cmap= opts->cmap;
+ }
+ view->canvas_width= width+(2*view->opts.margin_width);
+ view->canvas_height= height+(2*view->opts.margin_height);
+ if (view->opts.viewport.width>view->canvas_width) {
+ int tmp;
+ tmp= (view->opts.viewport.width-view->canvas_width)/2;
+ view->opts.margin_width+= tmp;
+ }
+ if (view->opts.viewport.height>view->canvas_height) {
+ int tmp;
+ tmp= (view->opts.viewport.height-view->canvas_height)/2;
+ view->opts.margin_height+= tmp;
+ }
+ bzero(view->state,XkbMaxLegalKeyCode+1);
+
+ xgcv.foreground= view->opts.fg;
+ xgcv.background= view->opts.bg;
+ view->gc= XCreateGC(view->dpy,view->win,GCForeground|GCBackground,&xgcv);
+ view->xscale= ((double)width)/((double)xkb->geom->width_mm);
+ view->yscale= ((double)height)/((double)xkb->geom->height_mm);
+
+ _XkbUI_AllocateColors(view);
+ return view;
+}
+
+Status
+XkbUI_SetViewOpts(XkbUI_ViewPtr view,XkbUI_ViewOptsPtr opts)
+{
+ if ((!view)||(!opts))
+ return BadValue;
+ if (opts->present==0)
+ return Success;
+ if (opts->present&XkbUI_BackgroundMask)
+ view->opts.bg= opts->bg;
+ if (opts->present&XkbUI_ForegroundMask)
+ view->opts.fg= opts->fg;
+ if (opts->present&XkbUI_LabelModeMask)
+ view->opts.label_mode= opts->label_mode;
+ if (opts->present&XkbUI_ColorModeMask)
+ view->opts.color_mode= opts->color_mode;
+ if (opts->present&XkbUI_WidthMask)
+ view->opts.viewport.width= opts->viewport.width;
+ if (opts->present&XkbUI_HeightMask)
+ view->opts.viewport.height= opts->viewport.height;
+ if (opts->present&XkbUI_XOffsetMask)
+ view->opts.viewport.x= opts->viewport.x;
+ if (opts->present&XkbUI_YOffsetMask)
+ view->opts.viewport.y= opts->viewport.y;
+ if (opts->present&XkbUI_MarginWidthMask)
+ view->opts.margin_width= opts->margin_width;
+ if (opts->present&XkbUI_MarginHeightMask)
+ view->opts.margin_height= opts->margin_height;
+ if (opts->present&XkbUI_ColormapMask) {
+ view->opts.cmap= opts->cmap;
+ _XkbUI_AllocateColors(view);
+ }
+ return Success;
+}
+
+Status
+XbUI_GetViewOpts(XkbUI_ViewPtr view,XkbUI_ViewOptsPtr opts_rtrn)
+{
+ if ((!view)||(!opts_rtrn))
+ return BadValue;
+ *opts_rtrn= view->opts;
+ return Success;
+}
+
+Status
+XkbUI_SetCanvasSize(XkbUI_ViewPtr view,int width,int height)
+{
+ if ((!view)||(!view->xkb)||(!view->xkb->geom))
+ return BadValue;
+ view->canvas_width= width;
+ view->canvas_height= height;
+ view->xscale= ((double)width)/((double)view->xkb->geom->width_mm);
+ view->yscale= ((double)height)/((double)view->xkb->geom->height_mm);
+ return Success;
+}
+
+Status
+XkbUI_GetCanvasSize(XkbUI_ViewPtr view,int *width_rtrn,int *height_rtrn)
+{
+ if (!view)
+ return BadValue;
+ if (width_rtrn) *width_rtrn= view->canvas_width;
+ if (height_rtrn) *height_rtrn= view->canvas_height;
+ return Success;
+}
+
+/***====================================================================***/
+
+static void
+_RotatePoints( double rangle,
+ int corner_x,
+ int corner_y,
+ int nPts,
+ XkbUI_PointPtr pts)
+{
+register int i;
+double rr,rx,ry,rt;
+
+ for (i=0;i<nPts;i++,pts++) {
+ rx= pts->x-corner_x; ry= pts->y-corner_y; /* translate */
+ rr= hypot(rx,ry);
+ rt= atan2(ry,rx)+rangle;
+ rx= rr*cos(rt);
+ ry= rr*sin(rt);
+ pts->x= rx+corner_x; pts->y= ry+corner_y;
+ }
+ return;
+}
+
+static void
+_DrawPoints(XkbUI_ViewPtr view,int nPts,XkbUI_PointPtr pts,XPoint *xpts)
+{
+register int i;
+
+ for (i=0;i<nPts;i++) {
+ if (pts[i].x>=0.0) xpts[i].x= pts[i].x*view->xscale+0.5;
+ else xpts[i].x= pts[i].x*view->xscale-0.5;
+ xpts[i].x+= view->opts.viewport.x;
+ if (pts[i].y>=0.0) xpts[i].y= pts[i].y*view->yscale+0.5;
+ else xpts[i].x= pts[i].y*view->yscale-0.5;
+ xpts[i].y+= view->opts.viewport.y;
+ }
+ if ((xpts[nPts-1].x!=xpts[0].x)||(xpts[nPts-1].y!=xpts[0].y))
+ xpts[nPts++]= xpts[0]; /* close the shape, if necessary */
+ XDrawLines(view->dpy,view->win,view->gc,xpts,nPts,CoordModeOrigin);
+XFlush(view->dpy);
+ return;
+}
+
+static void
+_DrawSolidPoints(XkbUI_ViewPtr view,int nPts,XkbUI_PointPtr pts,XPoint *xpts)
+{
+register int i;
+
+ for (i=0;i<nPts;i++) {
+ if (pts[i].x>=0.0) xpts[i].x= pts[i].x*view->xscale+0.5;
+ else xpts[i].x= pts[i].x*view->xscale-0.5;
+ xpts[i].x+= view->opts.viewport.x;
+ if (pts[i].y>=0.0) xpts[i].y= pts[i].y*view->yscale+0.5;
+ else xpts[i].x= pts[i].y*view->yscale-0.5;
+ xpts[i].y+= view->opts.viewport.y;
+ }
+ if ((xpts[nPts-1].x!=xpts[0].x)||(xpts[nPts-1].y!=xpts[0].y))
+ xpts[nPts++]= xpts[0]; /* close the shape, if necessary */
+ XFillPolygon(view->dpy,view->win,view->gc,xpts,nPts,Nonconvex,
+ CoordModeOrigin);
+XFlush(view->dpy);
+ return;
+}
+
+static void
+_DrawShape( XkbUI_ViewPtr view,
+ double rangle,
+ int xoff,
+ int yoff,
+ int rotx,
+ int roty,
+ XkbShapePtr shape,
+ Bool key)
+{
+XkbOutlinePtr ol;
+register int o;
+int maxPts;
+XkbUI_PointPtr uipts;
+XPoint * xpts;
+
+ for (maxPts=4,o=0,ol=shape->outlines;o<shape->num_outlines;o++,ol++) {
+ if ((shape->num_outlines>1)&&(ol==shape->approx))
+ continue;
+ if (ol->num_points>maxPts)
+ maxPts= ol->num_points;
+ }
+ uipts= _XkbTypedCalloc(maxPts,XkbUI_PointRec);
+ xpts= _XkbTypedCalloc(maxPts+1,XPoint);
+ XSetForeground(view->dpy,view->gc,view->xkb->geom->label_color->pixel);
+ for (o=0,ol=shape->outlines;o<shape->num_outlines;o++,ol++) {
+ XkbPointPtr gpts;
+ register int p;
+ if ((shape->num_outlines>1)&&(ol==shape->approx))
+ continue;
+ gpts= ol->points;
+ if (ol->num_points==1) {
+ uipts[0].x= xoff; uipts[0].y= yoff;
+ uipts[1].x= xoff+gpts[0].x; uipts[1].y= yoff;
+ uipts[2].x= xoff+gpts[0].x; uipts[2].y= yoff+gpts[0].y;
+ uipts[3].x= xoff; uipts[3].y= yoff+gpts[0].y;
+ p= 4;
+ }
+ else if (ol->num_points==2) {
+ uipts[0].x= xoff+gpts[0].x; uipts[0].y= yoff+gpts[0].y;
+ uipts[1].x= xoff+gpts[1].x; uipts[1].y= yoff+gpts[0].y;
+ uipts[2].x= xoff+gpts[1].x; uipts[2].y= yoff+gpts[1].y;
+ uipts[3].x= xoff+gpts[0].x; uipts[3].y= yoff+gpts[1].y;
+ p= 4;
+ }
+ else {
+ for (p=0;p<ol->num_points;p++) {
+ uipts[p].x= xoff+gpts[p].x;
+ uipts[p].y= yoff+gpts[p].y;
+ }
+ p= ol->num_points;
+ }
+ if (rangle!=0.0)
+ _RotatePoints(rangle,rotx,roty,p,uipts);
+ if (key) {
+ if (o==0) {
+ XSetForeground(view->dpy,view->gc,
+ view->xkb->geom->base_color->pixel);
+ _DrawSolidPoints(view,p,uipts,xpts);
+ XSetForeground(view->dpy,view->gc,
+ view->xkb->geom->label_color->pixel);
+ }
+ _DrawPoints(view,p,uipts,xpts);
+ }
+ else {
+ _DrawPoints(view,p,uipts,xpts);
+ }
+ }
+ _XkbFree(uipts);
+ _XkbFree(xpts);
+ return;
+}
+
+static void
+_DrawRect( XkbUI_ViewPtr view,
+ double rangle,
+ int x1,
+ int y1,
+ int x2,
+ int y2,
+ Bool key)
+{
+XkbUI_PointRec uipts[4];
+XPoint xpts[4];
+
+ XSetForeground(view->dpy,view->gc,view->xkb->geom->label_color->pixel);
+ uipts[0].x= x1; uipts[0].y= y1;
+ uipts[1].x= x2; uipts[1].y= y1;
+ uipts[2].x= x2; uipts[2].y= y2;
+ uipts[3].x= x1; uipts[3].y= y2;
+ if (rangle!=0.0)
+ _RotatePoints(rangle,0,0,4,uipts);
+ if (key) {
+ XSetForeground(view->dpy,view->gc,view->xkb->geom->base_color->pixel);
+ _DrawSolidPoints(view,4,uipts,xpts);
+ XSetForeground(view->dpy,view->gc,view->xkb->geom->label_color->pixel);
+ _DrawPoints(view,4,uipts,xpts);
+ }
+ else {
+ _DrawPoints(view,4,uipts,xpts);
+ }
+ return;
+}
+
+static void
+_DrawDoodad( XkbUI_ViewPtr view,
+ double rangle,
+ int xoff,
+ int yoff,
+ XkbDoodadPtr doodad)
+{
+int x;
+int y;
+XkbShapePtr shape;
+Bool solid;
+
+ x= doodad->any.left+xoff;
+ y= doodad->any.top+yoff;
+ shape= NULL;
+ solid= False;
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ shape= XkbShapeDoodadShape(view->xkb->geom,(&doodad->shape));
+ break;
+ case XkbSolidDoodad:
+ shape= XkbShapeDoodadShape(view->xkb->geom,(&doodad->shape));
+ solid= True;
+ break;
+ case XkbTextDoodad:
+ break;
+ case XkbIndicatorDoodad:
+ shape= XkbIndicatorDoodadShape(view->xkb->geom,&doodad->indicator);
+ solid= True;
+ break;
+ case XkbLogoDoodad:
+ shape= XkbLogoDoodadShape(view->xkb->geom,&doodad->logo);
+ solid= True;
+ break;
+ }
+ if (shape)
+ _DrawShape(view,rangle,x,y,x,y,shape,solid);
+ return;
+}
+
+static void
+_DrawRow( XkbUI_ViewPtr view,
+ double rangle,
+ int xoff,
+ int yoff,
+ XkbRowPtr row)
+{
+register int k,x,y;
+XkbKeyPtr key;
+
+ x= xoff+row->left; y= yoff+row->top;
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ XkbShapePtr shape;
+ shape= XkbKeyShape(view->xkb->geom,key);
+ if (row->vertical) {
+ y+= key->gap;
+ _DrawShape(view,rangle,x,y,xoff,yoff,shape,True);
+ y+= shape->bounds.y2;
+ }
+ else {
+ x+= key->gap;
+ _DrawShape(view,rangle,x,y,xoff,yoff,shape,True);
+ x+= shape->bounds.x2;
+ }
+ }
+ return;
+}
+
+static void
+_DrawSection(XkbUI_ViewPtr view,XkbSectionPtr section)
+{
+double rangle;
+
+ rangle= ((((double)(section->angle%3600))/3600.0)*(2.0*M_PI));
+ if (section->doodads) {
+ XkbDrawablePtr first,draw;
+ first= XkbGetOrderedDrawables(NULL,section);
+ if (first) {
+ for (draw=first;draw!=NULL;draw=draw->next) {
+ _DrawDoodad(view,rangle,section->left,section->top,draw->u.doodad);
+ }
+ XkbFreeOrderedDrawables(first);
+ }
+ }
+ if (section->rows) {
+ register int r;
+ XkbRowPtr row;
+ for (r=0,row=section->rows;r<section->num_rows;r++,row++) {
+ _DrawRow(view,rangle,section->left,section->top,row);
+ }
+ }
+ return;
+}
+
+static void
+_DrawAll(XkbUI_ViewPtr view)
+{
+XkbGeometryPtr geom;
+XkbDrawablePtr first,draw;
+Bool dfltBorder;
+
+ geom= view->xkb->geom;
+ first= XkbGetOrderedDrawables(geom,NULL);
+ if (first) {
+ dfltBorder= True;
+ for (draw=first;draw!=NULL;draw=draw->next) {
+ char *name;
+ if ((draw->type!=XkbDW_Doodad)||
+ ((draw->u.doodad->any.type!=XkbOutlineDoodad)&&
+ (draw->u.doodad->any.type!=XkbSolidDoodad))) {
+ continue;
+ }
+ name= XkbAtomGetString(view->dpy,draw->u.doodad->any.name);
+ if ((name!=NULL)&&(_XkbStrCaseCmp(name,"edges")==0)) {
+ dfltBorder= False;
+ break;
+ }
+ }
+ if (dfltBorder)
+ _DrawRect(view,0.0,0,0,geom->width_mm,geom->height_mm,True);
+ for (draw=first;draw!=NULL;draw=draw->next) {
+ switch (draw->type) {
+ case XkbDW_Section:
+ _DrawSection(view,draw->u.section);
+ break;
+ case XkbDW_Doodad:
+ _DrawDoodad(view,0.0,0,0,draw->u.doodad);
+ break;
+ }
+ }
+ XkbFreeOrderedDrawables(first);
+ }
+ XFlush(view->dpy);
+ return;
+}
+
+static void
+_RedrawKey(XkbUI_ViewPtr view,KeyCode kc)
+{
+/* _DrawAll(view);*/
+ return;
+}
+
+/***====================================================================***/
+
+Bool
+XkbUI_SetKeyAppearance(XkbUI_ViewPtr view,KeyCode kc,unsigned int flags)
+{
+XkbDescPtr xkb;
+unsigned old;
+
+ if ((!view)||(!view->xkb))
+ return False;
+ xkb= view->xkb;
+ if ((kc<xkb->min_key_code)||(kc>xkb->max_key_code))
+ return False;
+ old= view->state[kc];
+ view->state[kc]= (flags&(~XkbUI_Obscured));
+ if (old&XkbUI_Obscured)
+ view->state[kc]|= XkbUI_Obscured;
+ else if (old!=view->state[kc])
+ _RedrawKey(view,kc);
+ return True;
+}
+
+Bool
+XkbUI_SetKeyAppearanceByName( XkbUI_ViewPtr view,
+ XkbKeyNamePtr name,
+ unsigned int flags)
+{
+KeyCode kc;
+
+ if ((!view)||(!view->xkb)||(!name))
+ return False;
+ kc= XkbFindKeycodeByName(view->xkb,name->name,True);
+ if (!kc)
+ return False;
+ return XkbUI_SetKeyAppearance(view,kc,flags);
+}
+
+Bool
+XkbUI_ResetKeyAppearance( XkbUI_ViewPtr view,
+ unsigned int mask,
+ unsigned int values)
+{
+register int i;
+unsigned new_val;
+
+ if ((!view)||(!view->xkb))
+ return False;
+ if (!mask)
+ return True;
+ for (i=view->xkb->min_key_code;i<=view->xkb->max_key_code;i++) {
+ new_val= (view->state[i]&(~mask));
+ new_val|= (mask&values);
+ XkbUI_SetKeyAppearance(view,i,new_val);
+ }
+ return True;
+}
+
+Bool
+XkbUI_DrawRegion(XkbUI_ViewPtr view,XRectangle *viewport)
+{
+ if (!view)
+ return False;
+ _DrawAll(view);
+ return True;
+}
+
+Bool
+XkbUI_DrawChanged( XkbUI_ViewPtr view,
+ XRectangle * viewport,
+ XkbChangesPtr changes,
+ int num_keys,
+ XkbKeyNamePtr keys)
+{
+ return False;
+}
+
+Bool
+XkbUI_Select( XkbUI_ViewPtr view,
+ XPoint * coord,
+ unsigned int which,
+ XkbSectionPtr section)
+{
+ return False;
+}
diff --git a/nx-X11/lib/xkbui/XKBui.h b/nx-X11/lib/xkbui/XKBui.h
new file mode 100644
index 000000000..36c66df59
--- /dev/null
+++ b/nx-X11/lib/xkbui/XKBui.h
@@ -0,0 +1,194 @@
+#ifndef XKBUI_H
+#define XKBUI_H 1
+/* $XConsortium: XKBui.h /main/2 1995/12/07 21:18:19 kaleb $ */
+/************************************************************
+ Copyright (c) 1996 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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.
+
+ ********************************************************/
+/* $XFree86$ */
+
+#include <X11/Xlib.h>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKBgeom.h>
+
+typedef struct _XkbUI_View *XkbUI_ViewPtr;
+
+typedef struct _XkbUI_ViewOpts {
+ unsigned int present;
+ unsigned int fg;
+ unsigned int bg;
+ unsigned int label_mode;
+ unsigned int color_mode;
+ XRectangle viewport;
+ unsigned int margin_width;
+ unsigned int margin_height;
+ Colormap cmap;
+} XkbUI_ViewOptsRec,*XkbUI_ViewOptsPtr;
+
+ /*
+ * legal values for present field of a view options
+ */
+#define XkbUI_BackgroundMask (1<<0)
+#define XkbUI_ForegroundMask (1<<1)
+#define XkbUI_LabelModeMask (1<<2)
+#define XkbUI_ColorModeMask (1<<3)
+#define XkbUI_WidthMask (1<<4)
+#define XkbUI_HeightMask (1<<5)
+#define XkbUI_XOffsetMask (1<<6)
+#define XkbUI_YOffsetMask (1<<7)
+#define XkbUI_ColormapMask (1<<8)
+#define XkbUI_MarginWidthMask (1<<9)
+#define XkbUI_MarginHeightMask (1<<10)
+
+#define XkbUI_SizeMask (XkbUI_WidthMask|XkbUI_HeightMask)
+#define XkbUI_OffsetMask (XkbUI_XOffsetMask|XkbUI_YOffsetMask)
+#define XkbUI_MarginMask (XkbUI_MarginWidthMask|XkbUI_MarginHeightMask)
+#define XkbUI_AllViewOptsMask (0x7ff)
+
+ /*
+ * legal values for the label_mode of a view options
+ */
+#define XkbUI_NoLabels 0
+#define XkbUI_KeyCodes 1
+#define XkbUI_KeyNames 2
+#define XkbUI_StateSyms 3
+#define XkbUI_MultiSyms 4
+
+typedef struct _XkbUI_Select {
+ unsigned type;
+ XkbSectionPtr section;
+ XkbKeyPtr key;
+ XkbDoodadPtr doodad;
+} XkbUI_SelectRec,*XkbUI_SelectPtr;
+
+ /*
+ * legal values for 'type' field of a selection report
+ */
+
+#define XkbUI_Keys 0
+#define XkbUI_Indicators 1
+#define XkbUI_TextLabels 2
+#define XkbUI_SolidShapes 3
+#define XkbUI_Outlines 4
+#define XkbUI_Logos 5
+#define XkbUI_Sections 6
+
+ /*
+ * legal values for 'which' field of a select call
+ */
+#define XkbUI_KeysMask (1<<0)
+#define XkbUI_IndicatorsMask (1<<1)
+#define XkbUI_TextLabelsMask (1<<2)
+#define XkbUI_SolidShapesMask (1<<3)
+#define XkbUI_OutlinesMask (1<<4)
+#define XkbUI_LogosMask (1<<5)
+#define XkbUI_SectionsMask (1<<6)
+
+ /*
+ * legal values for key appearance flag
+ */
+#define XkbUI_KeyDown (1<<0)
+#define XkbUI_Highlight (1<<1)
+
+_XFUNCPROTOBEGIN
+
+extern XkbUI_ViewPtr XkbUI_SimpleInit(
+ Display * /* dpy */,
+ Window /* win */,
+ int /* width */,
+ int /* height */
+);
+
+extern XkbUI_ViewPtr XkbUI_Init(
+ Display * /* dpy */,
+ Window /* win */,
+ int /* width */,
+ int /* height */,
+ XkbDescPtr /* xkb */,
+ XkbUI_ViewOptsPtr /* view */
+);
+
+extern Status XkbUI_SetViewOpts(
+ XkbUI_ViewPtr /* view */,
+ XkbUI_ViewOptsPtr /* opts */
+);
+
+extern Status XbUI_GetViewOpts(
+ XkbUI_ViewPtr /* view */,
+ XkbUI_ViewOptsPtr /* opts_rtrn */
+);
+
+extern Status XkbUI_SetCanvasSize(
+ XkbUI_ViewPtr /* view */,
+ int /* width */,
+ int /* height */
+);
+
+extern Status XkbUI_GetCanvasSize(
+ XkbUI_ViewPtr /* view */,
+ int * /* width_rtrn */,
+ int * /* height_rtrn */
+);
+
+extern Bool XkbUI_SetKeyAppearance(
+ XkbUI_ViewPtr /* view */,
+ KeyCode /* kc */,
+ unsigned /* flags */
+);
+
+extern Bool XkbUI_SetKeyAppearanceByName(
+ XkbUI_ViewPtr /* view */,
+ XkbKeyNamePtr /* name */,
+ unsigned /* flags */
+);
+
+extern Bool XkbUI_ResetKeyAppearance(
+ XkbUI_ViewPtr /* view */,
+ unsigned int /* mask */,
+ unsigned int /* values */
+);
+
+extern Bool XkbUI_DrawRegion(
+ XkbUI_ViewPtr /* view */,
+ XRectangle * /* viewport */
+);
+
+extern Bool XkbUI_DrawChanged(
+ XkbUI_ViewPtr /* view */,
+ XRectangle * /* viewport */,
+ XkbChangesPtr /* changes */,
+ int /* num_keys */,
+ XkbKeyNamePtr /* keys */
+);
+
+extern Bool XkbUI_Select(
+ XkbUI_ViewPtr /* view */,
+ XPoint * /* coord */,
+ unsigned int /* which */,
+ XkbSectionPtr /* section */
+);
+
+_XFUNCPROTOEND
+
+#endif /* XKBUI_H */
diff --git a/nx-X11/lib/xkbui/XKBuiPriv.h b/nx-X11/lib/xkbui/XKBuiPriv.h
new file mode 100644
index 000000000..c78b08e5c
--- /dev/null
+++ b/nx-X11/lib/xkbui/XKBuiPriv.h
@@ -0,0 +1,71 @@
+#ifndef XKBUIPRIV_H
+#define XKBUIPRIV_H 1
+/* $XConsortium: XKBuiPriv.h /main/2 1995/12/07 21:18:19 kaleb $ */
+/************************************************************
+ Copyright (c) 1996 by Silicon Graphics Computer Systems, Inc.
+
+ 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 Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS 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 "XKBui.h"
+
+typedef struct _XkbUI_Point {
+ double x;
+ double y;
+} XkbUI_PointRec,*XkbUI_PointPtr;
+
+typedef struct _XkbUI_View {
+ Display * dpy;
+ XkbDescPtr xkb;
+ Window win;
+ GC gc;
+ XkbUI_ViewOptsRec opts;
+ unsigned int canvas_width;
+ unsigned int canvas_height;
+ unsigned char state[XkbMaxLegalKeyCode];
+
+ double xscale;
+ double yscale;
+} XkbUI_ViewRec;
+
+#define _XkbAlloc(s) malloc((s))
+#define _XkbCalloc(n,s) calloc((n),(s))
+#define _XkbRealloc(o,s) realloc((o),(s))
+#define _XkbTypedAlloc(t) ((t *)malloc(sizeof(t)))
+#define _XkbTypedCalloc(n,t) ((t *)calloc((n),sizeof(t)))
+#define _XkbTypedRealloc(o,n,t) \
+ ((o)?(t *)realloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
+#define _XkbClearElems(a,f,l,t) bzero(&(a)[f],((l)-(f)+1)*sizeof(t))
+#define _XkbFree(p) free(p)
+
+ /*
+ * private values for key appearance flags
+ * must not conflict with values from XKBui.h
+ */
+#define XkbUI_Obscured (1<<7)
+
+_XFUNCPROTOBEGIN
+
+_XFUNCPROTOEND
+
+#endif /* XKBUIPRIV_H */
diff --git a/nx-X11/lib/xkbui/xkbui-def.cpp b/nx-X11/lib/xkbui/xkbui-def.cpp
new file mode 100644
index 000000000..4facda60e
--- /dev/null
+++ b/nx-X11/lib/xkbui/xkbui-def.cpp
@@ -0,0 +1,16 @@
+LIBRARY xkbui
+VERSION LIBRARY_VERSION
+EXPORTS
+ XbUI_GetViewOpts
+ XkbUI_DrawChanged
+ XkbUI_DrawRegion
+ XkbUI_GetCanvasSize
+ XkbUI_Init
+ XkbUI_ResetKeyAppearance
+ XkbUI_Select
+ XkbUI_SetCanvasSize
+ XkbUI_SetKeyAppearance
+ XkbUI_SetKeyAppearanceByName
+ XkbUI_SetViewOpts
+ XkbUI_SimpleInit
+/* $XFree86$ */
diff --git a/nx-X11/lib/xtrans/Imakefile b/nx-X11/lib/xtrans/Imakefile
new file mode 100644
index 000000000..e29a38591
--- /dev/null
+++ b/nx-X11/lib/xtrans/Imakefile
@@ -0,0 +1,24 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:44 cpqbld Exp $
+
+#define IncSubdir X11
+
+all::
+
+DEFINES = $(FAILDEFINES)
+
+# Since xtrans source is #include'd into software that uses it, we install
+# the .c files as if they were headers.
+HEADERS = \
+ Xtrans.h \
+ Xtrans.c \
+ Xtransdnet.c \
+ Xtransint.h \
+ Xtranslcl.c \
+ Xtransos2.c \
+ Xtranssock.c \
+ Xtranstli.c \
+ Xtransutil.c \
+ transport.c
+
+DependTarget()
+BuildIncludes($(HEADERS),IncSubdir/Xtrans,../..)
diff --git a/nx-X11/lib/xtrans/Xtrans.c b/nx-X11/lib/xtrans/Xtrans.c
new file mode 100644
index 000000000..a6bfbedc6
--- /dev/null
+++ b/nx-X11/lib/xtrans/Xtrans.c
@@ -0,0 +1,1402 @@
+/* $XdotOrg: xc/lib/xtrans/Xtrans.c,v 1.6 2005/11/08 06:33:26 jkj Exp $ */
+/* $Xorg: Xtrans.c,v 1.4 2001/02/09 02:04:06 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/xtrans/Xtrans.c,v 3.33 2003/08/11 17:41:29 eich Exp $ */
+
+/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * 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 NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCR makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR 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 <ctype.h>
+
+/*
+ * The transport table contains a definition for every transport (protocol)
+ * family. All operations that can be made on the transport go through this
+ * table.
+ *
+ * Each transport is assigned a unique transport id.
+ *
+ * New transports can be added by adding an entry in this table.
+ * For compatiblity, the transport ids should never be renumbered.
+ * Always add to the end of the list.
+ */
+
+#define TRANS_TLI_INET_INDEX 1
+#define TRANS_TLI_TCP_INDEX 2
+#define TRANS_TLI_TLI_INDEX 3
+#define TRANS_SOCKET_UNIX_INDEX 4
+#define TRANS_SOCKET_LOCAL_INDEX 5
+#define TRANS_SOCKET_INET_INDEX 6
+#define TRANS_SOCKET_TCP_INDEX 7
+#define TRANS_DNET_INDEX 8
+#define TRANS_LOCAL_LOCAL_INDEX 9
+#define TRANS_LOCAL_PTS_INDEX 10
+#define TRANS_LOCAL_NAMED_INDEX 11
+#define TRANS_LOCAL_ISC_INDEX 12
+#define TRANS_LOCAL_SCO_INDEX 13
+#define TRANS_SOCKET_INET6_INDEX 14
+
+
+static
+Xtransport_table Xtransports[] = {
+#if defined(STREAMSCONN)
+ { &TRANS(TLITCPFuncs), TRANS_TLI_TCP_INDEX },
+ { &TRANS(TLIINETFuncs), TRANS_TLI_INET_INDEX },
+ { &TRANS(TLITLIFuncs), TRANS_TLI_TLI_INDEX },
+#endif /* STREAMSCONN */
+#if defined(TCPCONN)
+ { &TRANS(SocketTCPFuncs), TRANS_SOCKET_TCP_INDEX },
+#if defined(IPv6) && defined(AF_INET6)
+ { &TRANS(SocketINET6Funcs), TRANS_SOCKET_INET6_INDEX },
+#endif /* IPv6 */
+ { &TRANS(SocketINETFuncs), TRANS_SOCKET_INET_INDEX },
+#endif /* TCPCONN */
+#if defined(DNETCONN)
+ { &TRANS(DNETFuncs), TRANS_DNET_INDEX },
+#endif /* DNETCONN */
+#if defined(UNIXCONN)
+#if !defined(LOCALCONN)
+ { &TRANS(SocketLocalFuncs), TRANS_SOCKET_LOCAL_INDEX },
+#endif /* !LOCALCONN */
+ { &TRANS(SocketUNIXFuncs), TRANS_SOCKET_UNIX_INDEX },
+#endif /* UNIXCONN */
+#if defined(OS2PIPECONN)
+ { &TRANS(OS2LocalFuncs), TRANS_LOCAL_LOCAL_INDEX },
+#endif /* OS2PIPECONN */
+#if defined(LOCALCONN)
+ { &TRANS(LocalFuncs), TRANS_LOCAL_LOCAL_INDEX },
+#ifndef sun
+ { &TRANS(PTSFuncs), TRANS_LOCAL_PTS_INDEX },
+#endif /* sun */
+#ifdef SVR4
+ { &TRANS(NAMEDFuncs), TRANS_LOCAL_NAMED_INDEX },
+#endif
+#ifndef sun
+#if !defined(__SCO__) && !defined(__UNIXWARE__)
+ { &TRANS(ISCFuncs), TRANS_LOCAL_ISC_INDEX },
+#endif
+ { &TRANS(SCOFuncs), TRANS_LOCAL_SCO_INDEX },
+#endif /* sun */
+#endif /* LOCALCONN */
+};
+
+#define NUMTRANS (sizeof(Xtransports)/sizeof(Xtransport_table))
+
+
+#ifdef WIN32
+#define ioctl ioctlsocket
+#endif
+
+
+
+/*
+ * These are a few utility function used by the public interface functions.
+ */
+
+void
+TRANS(FreeConnInfo) (XtransConnInfo ciptr)
+
+{
+ PRMSG (3,"FreeConnInfo(%p)\n", ciptr, 0, 0);
+
+ if (ciptr->addr)
+ xfree (ciptr->addr);
+
+ if (ciptr->peeraddr)
+ xfree (ciptr->peeraddr);
+
+ if (ciptr->port)
+ xfree (ciptr->port);
+
+ xfree ((char *) ciptr);
+}
+
+
+#define PROTOBUFSIZE 20
+
+static Xtransport *
+TRANS(SelectTransport) (char *protocol)
+
+{
+ char protobuf[PROTOBUFSIZE];
+ int i;
+
+ PRMSG (3,"SelectTransport(%s)\n", protocol, 0, 0);
+
+ /*
+ * Force Protocol to be lowercase as a way of doing
+ * a case insensitive match.
+ */
+
+ strncpy (protobuf, protocol, PROTOBUFSIZE - 1);
+ protobuf[PROTOBUFSIZE-1] = '\0';
+
+ for (i = 0; i < PROTOBUFSIZE && protobuf[i] != '\0'; i++)
+ if (isupper (protobuf[i]))
+ protobuf[i] = tolower (protobuf[i]);
+
+ /* Look at all of the configured protocols */
+
+ for (i = 0; i < NUMTRANS; i++)
+ {
+ if (!strcmp (protobuf, Xtransports[i].transport->TransName))
+ return Xtransports[i].transport;
+ }
+
+ return NULL;
+}
+
+#ifndef TEST_t
+static
+#endif /* TEST_t */
+int
+TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
+
+{
+ /*
+ * For the font library, the address is a string formatted
+ * as "protocol/host:port[/catalogue]". Note that the catologue
+ * is optional. At this time, the catologue info is ignored, but
+ * we have to parse it anyways.
+ *
+ * Other than fontlib, the address is a string formatted
+ * as "protocol/host:port".
+ *
+ * If the protocol part is missing, then assume TCP.
+ * If the protocol part and host part are missing, then assume local.
+ * If a "::" is found then assume DNET.
+ */
+
+ char *mybuf, *tmpptr;
+ char *_protocol, *_host, *_port;
+ char hostnamebuf[256];
+ int _host_len;
+
+ PRMSG (3,"ParseAddress(%s)\n", address, 0, 0);
+
+ /* Copy the string so it can be changed */
+
+ tmpptr = mybuf = (char *) xalloc (strlen (address) + 1);
+ strcpy (mybuf, address);
+
+ /* Parse the string to get each component */
+
+ /* Get the protocol part */
+
+ _protocol = mybuf;
+
+
+ if ( ((mybuf = strchr (mybuf,'/')) == NULL) &&
+ ((mybuf = strrchr (tmpptr,':')) == NULL) )
+ {
+ /* address is in a bad format */
+ *protocol = NULL;
+ *host = NULL;
+ *port = NULL;
+ xfree (tmpptr);
+ return 0;
+ }
+
+ if (*mybuf == ':')
+ {
+ /*
+ * If there is a hostname, then assume tcp, otherwise
+ * it must be local.
+ */
+ if (mybuf == tmpptr)
+ {
+ /* There is neither a protocol or host specified */
+ _protocol = "local";
+ }
+ else
+ {
+ /* There is a hostname specified */
+ _protocol = "tcp";
+ mybuf = tmpptr; /* reset to the begining of the host ptr */
+ }
+ }
+ else
+ {
+ /* *mybuf == '/' */
+
+ *mybuf ++= '\0'; /* put a null at the end of the protocol */
+
+ if (strlen(_protocol) == 0)
+ {
+ /*
+ * If there is a hostname, then assume tcp, otherwise
+ * it must be local.
+ */
+ if (*mybuf != ':')
+ _protocol = "tcp";
+ else
+ _protocol = "local";
+ }
+ }
+
+ /* Get the host part */
+
+ _host = mybuf;
+
+ if ((mybuf = strrchr (mybuf,':')) == NULL)
+ {
+ *protocol = NULL;
+ *host = NULL;
+ *port = NULL;
+ xfree (tmpptr);
+ return 0;
+ }
+
+ /* Check for DECnet */
+
+ if ((mybuf != _host) && (*(mybuf - 1) == ':')
+#if defined(IPv6) && defined(AF_INET6)
+ /* An IPv6 address can end in :: so three : in a row is assumed to be
+ an IPv6 host and not a DECnet node with a : in it's name, unless
+ DECnet is specifically requested */
+ && ( ((mybuf - 1) == _host) || (*(mybuf - 2) != ':') ||
+ ((_protocol != NULL) && (strcmp(_protocol, "dnet") == 0)) )
+#endif
+ )
+ {
+ _protocol = "dnet";
+ *(mybuf - 1) = '\0';
+ }
+
+ *mybuf ++= '\0';
+
+ _host_len = strlen(_host);
+ if (_host_len == 0)
+ {
+ TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf));
+ _host = hostnamebuf;
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ /* hostname in IPv6 [numeric_addr]:0 form? */
+ else if ( (_host_len > 3) &&
+ ((strcmp(_protocol, "tcp") == 0) || (strcmp(_protocol, "inet6") == 0))
+ && (*_host == '[') && (*(_host + _host_len - 1) == ']') ) {
+ struct sockaddr_in6 sin6;
+
+ *(_host + _host_len - 1) = '\0';
+
+ /* Verify address is valid IPv6 numeric form */
+ if (inet_pton(AF_INET6, _host + 1, &sin6) == 1) {
+ /* It is. Use it as such. */
+ _host++;
+ _protocol = "inet6";
+ } else {
+ /* It's not, restore it just in case some other code can use it. */
+ *(_host + _host_len - 1) = ']';
+ }
+ }
+#endif
+
+
+ /* Get the port */
+
+ _port = mybuf;
+
+#if defined(FONT_t) || defined(FS_t)
+ /*
+ * Is there an optional catalogue list?
+ */
+
+ if ((mybuf = strchr (mybuf,'/')) != NULL)
+ *mybuf ++= '\0';
+
+ /*
+ * The rest, if any, is the (currently unused) catalogue list.
+ *
+ * _catalogue = mybuf;
+ */
+#endif
+
+ /*
+ * Now that we have all of the components, allocate new
+ * string space for them.
+ */
+
+ if ((*protocol = (char *) xalloc(strlen (_protocol) + 1)) == NULL)
+ {
+ /* Malloc failed */
+ *port = NULL;
+ *host = NULL;
+ *protocol = NULL;
+ xfree (tmpptr);
+ return 0;
+ }
+ else
+ strcpy (*protocol, _protocol);
+
+ if ((*host = (char *) xalloc (strlen (_host) + 1)) == NULL)
+ {
+ /* Malloc failed */
+ *port = NULL;
+ *host = NULL;
+ xfree (*protocol);
+ *protocol = NULL;
+ xfree (tmpptr);
+ return 0;
+ }
+ else
+ strcpy (*host, _host);
+
+ if ((*port = (char *) xalloc (strlen (_port) + 1)) == NULL)
+ {
+ /* Malloc failed */
+ *port = NULL;
+ xfree (*host);
+ *host = NULL;
+ xfree (*protocol);
+ *protocol = NULL;
+ xfree (tmpptr);
+ return 0;
+ }
+ else
+ strcpy (*port, _port);
+
+ xfree (tmpptr);
+
+ return 1;
+}
+
+
+/*
+ * TRANS(Open) does all of the real work opening a connection. The only
+ * funny part about this is the type parameter which is used to decide which
+ * type of open to perform.
+ */
+
+static XtransConnInfo
+TRANS(Open) (int type, char *address)
+
+{
+ char *protocol = NULL, *host = NULL, *port = NULL;
+ XtransConnInfo ciptr = NULL;
+ Xtransport *thistrans;
+
+ PRMSG (2,"Open(%d,%s)\n", type, address, 0);
+
+#if defined(WIN32) && (defined(TCPCONN) || defined(DNETCONN))
+ if (TRANS(WSAStartup)())
+ {
+ PRMSG (1,"Open: WSAStartup failed\n", 0, 0, 0);
+ return NULL;
+ }
+#endif
+
+ /* Parse the Address */
+
+ if (TRANS(ParseAddress) (address, &protocol, &host, &port) == 0)
+ {
+ PRMSG (1,"Open: Unable to Parse address %s\n", address, 0, 0);
+ return NULL;
+ }
+
+ /* Determine the transport type */
+
+ if ((thistrans = TRANS(SelectTransport) (protocol)) == NULL)
+ {
+ PRMSG (1,"Open: Unable to find transport for %s\n",
+ protocol, 0, 0);
+
+ xfree (protocol);
+ xfree (host);
+ xfree (port);
+ return NULL;
+ }
+
+ /* Open the transport */
+
+ switch (type)
+ {
+ case XTRANS_OPEN_COTS_CLIENT:
+#ifdef TRANS_CLIENT
+ ciptr = thistrans->OpenCOTSClient(thistrans, protocol, host, port);
+#endif /* TRANS_CLIENT */
+ break;
+ case XTRANS_OPEN_COTS_SERVER:
+#ifdef TRANS_SERVER
+ ciptr = thistrans->OpenCOTSServer(thistrans, protocol, host, port);
+#endif /* TRANS_SERVER */
+ break;
+ case XTRANS_OPEN_CLTS_CLIENT:
+#ifdef TRANS_CLIENT
+ ciptr = thistrans->OpenCLTSClient(thistrans, protocol, host, port);
+#endif /* TRANS_CLIENT */
+ break;
+ case XTRANS_OPEN_CLTS_SERVER:
+#ifdef TRANS_SERVER
+ ciptr = thistrans->OpenCLTSServer(thistrans, protocol, host, port);
+#endif /* TRANS_SERVER */
+ break;
+ default:
+ PRMSG (1,"Open: Unknown Open type %d\n", type, 0, 0);
+ }
+
+ if (ciptr == NULL)
+ {
+ if (!(thistrans->flags & TRANS_DISABLED))
+ {
+ PRMSG (1,"Open: transport open failed for %s/%s:%s\n",
+ protocol, host, port);
+ }
+ xfree (protocol);
+ xfree (host);
+ xfree (port);
+ return NULL;
+ }
+
+ ciptr->transptr = thistrans;
+ ciptr->port = port; /* We need this for TRANS(Reopen) */
+
+ xfree (protocol);
+ xfree (host);
+
+ return ciptr;
+}
+
+
+#ifdef TRANS_REOPEN
+
+/*
+ * We might want to create an XtransConnInfo object based on a previously
+ * opened connection. For example, the font server may clone itself and
+ * pass file descriptors to the parent.
+ */
+
+static XtransConnInfo
+TRANS(Reopen) (int type, int trans_id, int fd, char *port)
+
+{
+ XtransConnInfo ciptr = NULL;
+ Xtransport *thistrans = NULL;
+ char *save_port;
+ int i;
+
+ PRMSG (2,"Reopen(%d,%d,%s)\n", trans_id, fd, port);
+
+ /* Determine the transport type */
+
+ for (i = 0; i < NUMTRANS; i++)
+ if (Xtransports[i].transport_id == trans_id)
+ {
+ thistrans = Xtransports[i].transport;
+ break;
+ }
+
+ if (thistrans == NULL)
+ {
+ PRMSG (1,"Reopen: Unable to find transport id %d\n",
+ trans_id, 0, 0);
+
+ return NULL;
+ }
+
+ if ((save_port = (char *) xalloc (strlen (port) + 1)) == NULL)
+ {
+ PRMSG (1,"Reopen: Unable to malloc port string\n", 0, 0, 0);
+
+ return NULL;
+ }
+
+ strcpy (save_port, port);
+
+ /* Get a new XtransConnInfo object */
+
+ switch (type)
+ {
+ case XTRANS_OPEN_COTS_SERVER:
+ ciptr = thistrans->ReopenCOTSServer(thistrans, fd, port);
+ break;
+ case XTRANS_OPEN_CLTS_SERVER:
+ ciptr = thistrans->ReopenCLTSServer(thistrans, fd, port);
+ break;
+ default:
+ PRMSG (1,"Reopen: Bad Open type %d\n", type, 0, 0);
+ }
+
+ if (ciptr == NULL)
+ {
+ PRMSG (1,"Reopen: transport open failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ ciptr->transptr = thistrans;
+ ciptr->port = save_port;
+
+ return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+
+/*
+ * These are the public interfaces to this Transport interface.
+ * These are the only functions that should have knowledge of the transport
+ * table.
+ */
+
+#ifdef TRANS_CLIENT
+
+XtransConnInfo
+TRANS(OpenCOTSClient) (char *address)
+
+{
+ PRMSG (2,"OpenCOTSClient(%s)\n", address, 0, 0);
+ return TRANS(Open) (XTRANS_OPEN_COTS_CLIENT, address);
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+XtransConnInfo
+TRANS(OpenCOTSServer) (char *address)
+
+{
+ PRMSG (2,"OpenCOTSServer(%s)\n", address, 0, 0);
+ return TRANS(Open) (XTRANS_OPEN_COTS_SERVER, address);
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+XtransConnInfo
+TRANS(OpenCLTSClient) (char *address)
+
+{
+ PRMSG (2,"OpenCLTSClient(%s)\n", address, 0, 0);
+ return TRANS(Open) (XTRANS_OPEN_CLTS_CLIENT, address);
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+XtransConnInfo
+TRANS(OpenCLTSServer) (char *address)
+
+{
+ PRMSG (2,"OpenCLTSServer(%s)\n", address, 0, 0);
+ return TRANS(Open) (XTRANS_OPEN_CLTS_SERVER, address);
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+XtransConnInfo
+TRANS(ReopenCOTSServer) (int trans_id, int fd, char *port)
+
+{
+ PRMSG (2,"ReopenCOTSServer(%d, %d, %s)\n", trans_id, fd, port);
+ return TRANS(Reopen) (XTRANS_OPEN_COTS_SERVER, trans_id, fd, port);
+}
+
+XtransConnInfo
+TRANS(ReopenCLTSServer) (int trans_id, int fd, char *port)
+
+{
+ PRMSG (2,"ReopenCLTSServer(%d, %d, %s)\n", trans_id, fd, port);
+ return TRANS(Reopen) (XTRANS_OPEN_CLTS_SERVER, trans_id, fd, port);
+}
+
+
+int
+TRANS(GetReopenInfo) (XtransConnInfo ciptr,
+ int *trans_id, int *fd, char **port)
+
+{
+ int i;
+
+ for (i = 0; i < NUMTRANS; i++)
+ if (Xtransports[i].transport == ciptr->transptr)
+ {
+ *trans_id = Xtransports[i].transport_id;
+ *fd = ciptr->fd;
+
+ if ((*port = (char *) xalloc (strlen (ciptr->port) + 1)) == NULL)
+ return 0;
+ else
+ {
+ strcpy (*port, ciptr->port);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+int
+TRANS(SetOption) (XtransConnInfo ciptr, int option, int arg)
+
+{
+ int fd = ciptr->fd;
+ int ret = 0;
+
+ PRMSG (2,"SetOption(%d,%d,%d)\n", fd, option, arg);
+
+ /*
+ * For now, all transport type use the same stuff for setting options.
+ * As long as this is true, we can put the common code here. Once a more
+ * complicated transport such as shared memory or an OSI implementation
+ * that uses the session and application libraries is implemented, this
+ * code may have to move to a transport dependent function.
+ *
+ * ret = ciptr->transptr->SetOption (ciptr, option, arg);
+ */
+
+ switch (option)
+ {
+ case TRANS_NONBLOCKING:
+ switch (arg)
+ {
+ case 0:
+ /* Set to blocking mode */
+ break;
+ case 1: /* Set to non-blocking mode */
+
+#if defined(O_NONBLOCK) && (!defined(ultrix) && !defined(hpux) && !defined(AIXV3) && !defined(uniosu) && !defined(__UNIXOS2__) && !defined(SCO325)) && !defined(__QNX__)
+ ret = fcntl (fd, F_GETFL, 0);
+ if (ret != -1)
+ ret = fcntl (fd, F_SETFL, ret | O_NONBLOCK);
+#else
+#ifdef FIOSNBIO
+ {
+ int arg;
+ arg = 1;
+ ret = ioctl (fd, FIOSNBIO, &arg);
+ }
+#else
+#if (defined(AIXV3) || defined(uniosu) || defined(WIN32) || defined(__UNIXOS2__) || defined(__QNX__)) && defined(FIONBIO)
+ {
+#ifdef WIN32
+ u_long arg;
+#else
+ int arg;
+#endif
+ arg = 1;
+/* IBM TCP/IP understands this option too well: it causes TRANS(Read) to fail
+ * eventually with EWOULDBLOCK */
+#ifndef __UNIXOS2__
+ ret = ioctl (fd, FIONBIO, &arg);
+#else
+/* ret = ioctl(fd, FIONBIO, &arg, sizeof(int));*/
+#endif
+ }
+#else
+ ret = fcntl (fd, F_GETFL, 0);
+#ifdef FNDELAY
+ ret = fcntl (fd, F_SETFL, ret | FNDELAY);
+#else
+ ret = fcntl (fd, F_SETFL, ret | O_NDELAY);
+#endif
+#endif /* AIXV3 || uniosu */
+#endif /* FIOSNBIO */
+#endif /* O_NONBLOCK */
+ break;
+ default:
+ /* Unknown option */
+ break;
+ }
+ break;
+ case TRANS_CLOSEONEXEC:
+#ifdef F_SETFD
+#ifdef FD_CLOEXEC
+ ret = fcntl (fd, F_SETFD, FD_CLOEXEC);
+#else
+ ret = fcntl (fd, F_SETFD, 1);
+#endif /* FD_CLOEXEC */
+#endif /* F_SETFD */
+ break;
+ }
+
+ return ret;
+}
+
+#ifdef TRANS_SERVER
+
+int
+TRANS(CreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags)
+
+{
+ return ciptr->transptr->CreateListener (ciptr, port, flags);
+}
+
+int
+TRANS(NoListen) (char * protocol)
+
+{
+ Xtransport *trans;
+ int i = 0, ret = 0;
+
+ if ((trans = TRANS(SelectTransport)(protocol)) == NULL)
+ {
+ PRMSG (1,"TransNoListen: unable to find transport: %s\n",
+ protocol, 0, 0);
+
+ return -1;
+ }
+ if (trans->flags & TRANS_ALIAS) {
+ if (trans->nolisten)
+ while (trans->nolisten[i]) {
+ ret |= TRANS(NoListen)(trans->nolisten[i]);
+ i++;
+ }
+ }
+
+ trans->flags |= TRANS_NOLISTEN;
+ return ret;
+}
+
+int
+TRANS(ResetListener) (XtransConnInfo ciptr)
+
+{
+ if (ciptr->transptr->ResetListener)
+ return ciptr->transptr->ResetListener (ciptr);
+ else
+ return TRANS_RESET_NOOP;
+}
+
+
+XtransConnInfo
+TRANS(Accept) (XtransConnInfo ciptr, int *status)
+
+{
+ XtransConnInfo newciptr;
+
+ PRMSG (2,"Accept(%d)\n", ciptr->fd, 0, 0);
+
+ newciptr = ciptr->transptr->Accept (ciptr, status);
+
+ if (newciptr)
+ newciptr->transptr = ciptr->transptr;
+
+ return newciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+int
+TRANS(Connect) (XtransConnInfo ciptr, char *address)
+
+{
+ char *protocol;
+ char *host;
+ char *port;
+ int ret;
+
+ PRMSG (2,"Connect(%d,%s)\n", ciptr->fd, address, 0);
+
+ if (TRANS(ParseAddress) (address, &protocol, &host, &port) == 0)
+ {
+ PRMSG (1,"Connect: Unable to Parse address %s\n",
+ address, 0, 0);
+ return -1;
+ }
+
+ if (!port || !*port)
+ {
+ PRMSG (1,"Connect: Missing port specification in %s\n",
+ address, 0, 0);
+ if (protocol) xfree (protocol);
+ if (host) xfree (host);
+ return -1;
+ }
+
+ ret = ciptr->transptr->Connect (ciptr, host, port);
+
+ if (protocol) xfree (protocol);
+ if (host) xfree (host);
+ if (port) xfree (port);
+
+ return ret;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+int
+TRANS(BytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)
+
+{
+ return ciptr->transptr->BytesReadable (ciptr, pend);
+}
+
+int
+TRANS(Read) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+ return ciptr->transptr->Read (ciptr, buf, size);
+}
+
+int
+TRANS(Write) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+ return ciptr->transptr->Write (ciptr, buf, size);
+}
+
+int
+TRANS(Readv) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ return ciptr->transptr->Readv (ciptr, buf, size);
+}
+
+int
+TRANS(Writev) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ return ciptr->transptr->Writev (ciptr, buf, size);
+}
+
+int
+TRANS(Disconnect) (XtransConnInfo ciptr)
+
+{
+ return ciptr->transptr->Disconnect (ciptr);
+}
+
+int
+TRANS(Close) (XtransConnInfo ciptr)
+
+{
+ int ret;
+
+ PRMSG (2,"Close(%d)\n", ciptr->fd, 0, 0);
+
+ ret = ciptr->transptr->Close (ciptr);
+
+ TRANS(FreeConnInfo) (ciptr);
+
+ return ret;
+}
+
+int
+TRANS(CloseForCloning) (XtransConnInfo ciptr)
+
+{
+ int ret;
+
+ PRMSG (2,"CloseForCloning(%d)\n", ciptr->fd, 0, 0);
+
+ ret = ciptr->transptr->CloseForCloning (ciptr);
+
+ TRANS(FreeConnInfo) (ciptr);
+
+ return ret;
+}
+
+int
+TRANS(IsLocal) (XtransConnInfo ciptr)
+
+{
+ return (ciptr->family == AF_UNIX);
+}
+
+
+int
+TRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,
+ Xtransaddr **addrp)
+
+{
+ PRMSG (2,"GetMyAddr(%d)\n", ciptr->fd, 0, 0);
+
+ *familyp = ciptr->family;
+ *addrlenp = ciptr->addrlen;
+
+ if ((*addrp = (Xtransaddr *) xalloc (ciptr->addrlen)) == NULL)
+ {
+ PRMSG (1,"GetMyAddr: malloc failed\n", 0, 0, 0);
+ return -1;
+ }
+ memcpy(*addrp, ciptr->addr, ciptr->addrlen);
+
+ return 0;
+}
+
+int
+TRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,
+ Xtransaddr **addrp)
+
+{
+ PRMSG (2,"GetPeerAddr(%d)\n", ciptr->fd, 0, 0);
+
+ *familyp = ciptr->family;
+ *addrlenp = ciptr->peeraddrlen;
+
+ if ((*addrp = (Xtransaddr *) xalloc (ciptr->peeraddrlen)) == NULL)
+ {
+ PRMSG (1,"GetPeerAddr: malloc failed\n", 0, 0, 0);
+ return -1;
+ }
+ memcpy(*addrp, ciptr->peeraddr, ciptr->peeraddrlen);
+
+ return 0;
+}
+
+
+int
+TRANS(GetConnectionNumber) (XtransConnInfo ciptr)
+
+{
+ return ciptr->fd;
+}
+
+
+/*
+ * These functions are really utility functions, but they require knowledge
+ * of the internal data structures, so they have to be part of the Transport
+ * Independant API.
+ */
+
+#ifdef TRANS_SERVER
+
+static int
+complete_network_count (void)
+
+{
+ int count = 0;
+ int found_local = 0;
+ int i;
+
+ /*
+ * For a complete network, we only need one LOCALCONN transport to work
+ */
+
+ for (i = 0; i < NUMTRANS; i++)
+ {
+ if (Xtransports[i].transport->flags & TRANS_ALIAS
+ || Xtransports[i].transport->flags & TRANS_NOLISTEN)
+ continue;
+
+ if (Xtransports[i].transport->flags & TRANS_LOCAL)
+ found_local = 1;
+ else
+ count++;
+ }
+
+ return (count + found_local);
+}
+
+
+
+int
+TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret,
+ XtransConnInfo **ciptrs_ret)
+
+{
+ char buffer[256]; /* ??? What size ?? */
+ XtransConnInfo ciptr, temp_ciptrs[NUMTRANS];
+ int status, i, j;
+#if defined(IPv6) && defined(AF_INET6)
+ int ipv6_succ = 0;
+#endif
+
+ PRMSG (2,"MakeAllCOTSServerListeners(%s,%p)\n",
+ port ? port : "NULL", ciptrs_ret, 0);
+
+ *count_ret = 0;
+
+ for (i = 0; i < NUMTRANS; i++)
+ {
+ Xtransport *trans = Xtransports[i].transport;
+ unsigned int flags = 0;
+
+ if (trans->flags&TRANS_ALIAS || trans->flags&TRANS_NOLISTEN)
+ continue;
+
+ sprintf(buffer,"%s/:%s", trans->TransName, port ? port : "");
+
+ PRMSG (5,"MakeAllCOTSServerListeners: opening %s\n",
+ buffer, 0, 0);
+
+ if ((ciptr = TRANS(OpenCOTSServer(buffer))) == NULL)
+ {
+ if (trans->flags & TRANS_DISABLED)
+ continue;
+
+ PRMSG (1,
+ "MakeAllCOTSServerListeners: failed to open listener for %s\n",
+ trans->TransName, 0, 0);
+ continue;
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ if ((Xtransports[i].transport_id == TRANS_SOCKET_INET_INDEX
+ && ipv6_succ))
+ flags |= ADDR_IN_USE_ALLOWED;
+#endif
+
+ if ((status = TRANS(CreateListener (ciptr, port, flags))) < 0)
+ {
+ if (status == TRANS_ADDR_IN_USE)
+ {
+ /*
+ * We failed to bind to the specified address because the
+ * address is in use. It must be that a server is already
+ * running at this address, and this function should fail.
+ */
+
+ PRMSG (1,
+ "MakeAllCOTSServerListeners: server already running\n",
+ 0, 0, 0);
+
+ for (j = 0; j < *count_ret; j++)
+ TRANS(Close) (temp_ciptrs[j]);
+
+ *count_ret = 0;
+ *ciptrs_ret = NULL;
+ *partial = 0;
+ return -1;
+ }
+ else
+ {
+ PRMSG (1,
+ "MakeAllCOTSServerListeners: failed to create listener for %s\n",
+ trans->TransName, 0, 0);
+
+ continue;
+ }
+ }
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (Xtransports[i].transport_id == TRANS_SOCKET_INET6_INDEX)
+ ipv6_succ = 1;
+#endif
+
+ PRMSG (5,
+ "MakeAllCOTSServerListeners: opened listener for %s, %d\n",
+ trans->TransName, ciptr->fd, 0);
+
+ temp_ciptrs[*count_ret] = ciptr;
+ (*count_ret)++;
+ }
+
+ *partial = (*count_ret < complete_network_count());
+
+ PRMSG (5,
+ "MakeAllCOTSServerListeners: partial=%d, actual=%d, complete=%d \n",
+ *partial, *count_ret, complete_network_count());
+
+ if (*count_ret > 0)
+ {
+ if ((*ciptrs_ret = (XtransConnInfo *) xalloc (
+ *count_ret * sizeof (XtransConnInfo))) == NULL)
+ {
+ return -1;
+ }
+
+ for (i = 0; i < *count_ret; i++)
+ {
+ (*ciptrs_ret)[i] = temp_ciptrs[i];
+ }
+ }
+ else
+ *ciptrs_ret = NULL;
+
+ return 0;
+}
+
+int
+TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret,
+ XtransConnInfo **ciptrs_ret)
+
+{
+ char buffer[256]; /* ??? What size ?? */
+ XtransConnInfo ciptr, temp_ciptrs[NUMTRANS];
+ int status, i, j;
+
+ PRMSG (2,"MakeAllCLTSServerListeners(%s,%p)\n",
+ port ? port : "NULL", ciptrs_ret, 0);
+
+ *count_ret = 0;
+
+ for (i = 0; i < NUMTRANS; i++)
+ {
+ Xtransport *trans = Xtransports[i].transport;
+
+ if (trans->flags&TRANS_ALIAS || trans->flags&TRANS_NOLISTEN)
+ continue;
+
+ sprintf(buffer,"%s/:%s", trans->TransName, port ? port : "");
+
+ PRMSG (5,"MakeAllCLTSServerListeners: opening %s\n",
+ buffer, 0, 0);
+
+ if ((ciptr = TRANS(OpenCLTSServer (buffer))) == NULL)
+ {
+ PRMSG (1,
+ "MakeAllCLTSServerListeners: failed to open listener for %s\n",
+ trans->TransName, 0, 0);
+ continue;
+ }
+
+ if ((status = TRANS(CreateListener (ciptr, port, 0))) < 0)
+ {
+ if (status == TRANS_ADDR_IN_USE)
+ {
+ /*
+ * We failed to bind to the specified address because the
+ * address is in use. It must be that a server is already
+ * running at this address, and this function should fail.
+ */
+
+ PRMSG (1,
+ "MakeAllCLTSServerListeners: server already running\n",
+ 0, 0, 0);
+
+ for (j = 0; j < *count_ret; j++)
+ TRANS(Close) (temp_ciptrs[j]);
+
+ *count_ret = 0;
+ *ciptrs_ret = NULL;
+ *partial = 0;
+ return -1;
+ }
+ else
+ {
+ PRMSG (1,
+ "MakeAllCLTSServerListeners: failed to create listener for %s\n",
+ trans->TransName, 0, 0);
+
+ continue;
+ }
+ }
+
+ PRMSG (5,
+ "MakeAllCLTSServerListeners: opened listener for %s, %d\n",
+ trans->TransName, ciptr->fd, 0);
+ temp_ciptrs[*count_ret] = ciptr;
+ (*count_ret)++;
+ }
+
+ *partial = (*count_ret < complete_network_count());
+
+ PRMSG (5,
+ "MakeAllCLTSServerListeners: partial=%d, actual=%d, complete=%d \n",
+ *partial, *count_ret, complete_network_count());
+
+ if (*count_ret > 0)
+ {
+ if ((*ciptrs_ret = (XtransConnInfo *) xalloc (
+ *count_ret * sizeof (XtransConnInfo))) == NULL)
+ {
+ return -1;
+ }
+
+ for (i = 0; i < *count_ret; i++)
+ {
+ (*ciptrs_ret)[i] = temp_ciptrs[i];
+ }
+ }
+ else
+ *ciptrs_ret = NULL;
+
+ return 0;
+}
+
+#endif /* TRANS_SERVER */
+
+
+
+/*
+ * These routines are not part of the X Transport Interface, but they
+ * may be used by it.
+ */
+
+#ifdef CRAY
+
+/*
+ * Cray UniCOS does not have readv and writev so we emulate
+ */
+
+static int TRANS(ReadV) (XtransConnInfo ciptr, struct iovec *iov, int iovcnt)
+
+{
+ struct msghdr hdr;
+
+ hdr.msg_iov = iov;
+ hdr.msg_iovlen = iovcnt;
+ hdr.msg_accrights = 0;
+ hdr.msg_accrightslen = 0;
+ hdr.msg_name = 0;
+ hdr.msg_namelen = 0;
+
+ return (recvmsg (ciptr->fd, &hdr, 0));
+}
+
+static int TRANS(WriteV) (XtransConnInfo ciptr, struct iovec *iov, int iovcnt)
+
+{
+ struct msghdr hdr;
+
+ hdr.msg_iov = iov;
+ hdr.msg_iovlen = iovcnt;
+ hdr.msg_accrights = 0;
+ hdr.msg_accrightslen = 0;
+ hdr.msg_name = 0;
+ hdr.msg_namelen = 0;
+
+ return (sendmsg (ciptr->fd, &hdr, 0));
+}
+
+#endif /* CRAY */
+
+#if (defined(SYSV) && defined(i386) && !defined(__SCO__)) || defined(WIN32) || defined(__sxg__) || defined(__UNIXOS2__)
+
+/*
+ * emulate readv
+ */
+
+static int TRANS(ReadV) (XtransConnInfo ciptr, struct iovec *iov, int iovcnt)
+
+{
+ int i, len, total;
+ char *base;
+
+ ESET(0);
+ for (i = 0, total = 0; i < iovcnt; i++, iov++) {
+ len = iov->iov_len;
+ base = iov->iov_base;
+ while (len > 0) {
+ register int nbytes;
+ nbytes = TRANS(Read) (ciptr, base, len);
+ if (nbytes < 0 && total == 0) return -1;
+ if (nbytes <= 0) return total;
+ ESET(0);
+ len -= nbytes;
+ total += nbytes;
+ base += nbytes;
+ }
+ }
+ return total;
+}
+
+#endif /* SYSV && i386 || WIN32 || __sxg__ */
+
+#if (defined(SYSV) && defined(i386) && !defined(__SCO__)) || defined(WIN32) || defined(__sxg__) || defined(__UNIXOS2__)
+
+/*
+ * emulate writev
+ */
+
+static int TRANS(WriteV) (XtransConnInfo ciptr, struct iovec *iov, int iovcnt)
+
+{
+ int i, len, total;
+ char *base;
+
+ ESET(0);
+ for (i = 0, total = 0; i < iovcnt; i++, iov++) {
+ len = iov->iov_len;
+ base = iov->iov_base;
+ while (len > 0) {
+ register int nbytes;
+ nbytes = TRANS(Write) (ciptr, base, len);
+ if (nbytes < 0 && total == 0) return -1;
+ if (nbytes <= 0) return total;
+ ESET(0);
+ len -= nbytes;
+ total += nbytes;
+ base += nbytes;
+ }
+ }
+ return total;
+}
+
+#endif /* SYSV && i386 || WIN32 || __sxg__ */
+
+
+#if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(USG) || defined(SVR4) || defined(__SCO__)
+#ifndef NEED_UTSNAME
+#define NEED_UTSNAME
+#endif
+#include <sys/utsname.h>
+#endif
+
+/*
+ * TRANS(GetHostname) - similar to gethostname but allows special processing.
+ */
+
+int TRANS(GetHostname) (char *buf, int maxlen)
+
+{
+ int len;
+
+#ifdef NEED_UTSNAME
+ struct utsname name;
+
+ uname (&name);
+ len = strlen (name.nodename);
+ if (len >= maxlen) len = maxlen - 1;
+ strncpy (buf, name.nodename, len);
+ buf[len] = '\0';
+#else
+ buf[0] = '\0';
+ (void) gethostname (buf, maxlen);
+ buf [maxlen - 1] = '\0';
+ len = strlen(buf);
+#endif /* NEED_UTSNAME */
+ return len;
+}
diff --git a/nx-X11/lib/xtrans/Xtrans.h b/nx-X11/lib/xtrans/Xtrans.h
new file mode 100644
index 000000000..e8d4bdfcd
--- /dev/null
+++ b/nx-X11/lib/xtrans/Xtrans.h
@@ -0,0 +1,490 @@
+/* $Xorg: Xtrans.h,v 1.4 2001/02/09 02:04:06 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/xtrans/Xtrans.h,v 3.21 2003/07/20 16:12:15 tsi Exp $ */
+
+/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * 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 NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCR makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR 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.
+ */
+
+#ifndef _XTRANS_H_
+#define _XTRANS_H_
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xos.h>
+
+#ifndef WIN32
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
+#endif
+
+
+/*
+ * Set the functions names according to where this code is being compiled.
+ */
+
+#ifdef X11_t
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define TRANS(func) _X11Trans##func
+#else
+#define TRANS(func) _X11Trans/**/func
+#endif
+#ifdef XTRANSDEBUG
+static char* __xtransname = "_X11Trans";
+#endif
+#endif /* X11_t */
+
+#ifdef XSERV_t
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define TRANS(func) _XSERVTrans##func
+#else
+#define TRANS(func) _XSERVTrans/**/func
+#endif
+#ifdef XTRANSDEBUG
+static char* __xtransname = "_XSERVTrans";
+#endif
+#define X11_t
+#endif /* XSERV_t */
+
+#ifdef XIM_t
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define TRANS(func) _XimXTrans##func
+#else
+#define TRANS(func) _XimXTrans/**/func
+#endif
+#ifdef XTRANSDEBUG
+static char* __xtransname = "_XimTrans";
+#endif
+#endif /* XIM_t */
+
+#ifdef FS_t
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define TRANS(func) _FSTrans##func
+#else
+#define TRANS(func) _FSTrans/**/func
+#endif
+#ifdef XTRANSDEBUG
+static char* __xtransname = "_FSTrans";
+#endif
+#endif /* FS_t */
+
+#ifdef FONT_t
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define TRANS(func) _FontTrans##func
+#else
+#define TRANS(func) _FontTrans/**/func
+#endif
+#ifdef XTRANSDEBUG
+static char* __xtransname = "_FontTrans";
+#endif
+#endif /* FONT_t */
+
+#ifdef ICE_t
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define TRANS(func) _IceTrans##func
+#else
+#define TRANS(func) _IceTrans/**/func
+#endif
+#ifdef XTRANSDEBUG
+static char* __xtransname = "_IceTrans";
+#endif
+#endif /* ICE_t */
+
+#ifdef TEST_t
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define TRANS(func) _TESTTrans##func
+#else
+#define TRANS(func) _TESTTrans/**/func
+#endif
+#ifdef XTRANSDEBUG
+static char* __xtransname = "_TESTTrans";
+#endif
+#endif /* TEST_t */
+
+#ifdef LBXPROXY_t
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define TRANS(func) _LBXPROXYTrans##func
+#else
+#define TRANS(func) _LBXPROXYTrans/**/func
+#endif
+#define X11_t /* The server defines this - so should the LBX proxy */
+#ifdef XTRANSDEBUG
+static char* __xtransname = "_LBXPROXYTrans";
+#endif
+#endif /* LBXPROXY_t */
+
+#if !defined(TRANS)
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define TRANS(func) _XTrans##func
+#else
+#define TRANS(func) _XTrans/**/func
+#endif
+#ifdef XTRANSDEBUG
+static char* __xtransname = "_XTrans";
+#endif
+#endif /* !TRANS */
+
+
+/*
+ * Create a single address structure that can be used wherever
+ * an address structure is needed. struct sockaddr is not big enough
+ * to hold a sockadd_un, so we create this definition to have a single
+ * structure that is big enough for all the structures we might need.
+ *
+ * This structure needs to be independent of the socket/TLI interface used.
+ */
+
+#if defined(IPv6) && defined(AF_INET6)
+typedef struct sockaddr_storage Xtransaddr;
+#else
+#define XTRANS_MAX_ADDR_LEN 128 /* large enough to hold sun_path */
+
+typedef struct {
+ unsigned char addr[XTRANS_MAX_ADDR_LEN];
+} Xtransaddr;
+#endif
+
+#ifdef LONG64
+typedef int BytesReadable_t;
+#else
+typedef long BytesReadable_t;
+#endif
+
+
+#if defined(WIN32) || (defined(USG) && !defined(CRAY) && !defined(umips) && !defined(MOTOROLA) && !defined(uniosu) && !defined(__sxg__))
+
+/*
+ * TRANS(Readv) and TRANS(Writev) use struct iovec, normally found
+ * in Berkeley systems in <sys/uio.h>. See the readv(2) and writev(2)
+ * manual pages for details.
+ */
+
+struct iovec {
+ caddr_t iov_base;
+ int iov_len;
+};
+
+#else
+#ifndef Lynx
+#include <sys/uio.h>
+#else
+#include <uio.h>
+#endif
+#endif
+
+typedef struct _XtransConnInfo *XtransConnInfo;
+
+
+/*
+ * Transport Option definitions
+ */
+
+#define TRANS_NONBLOCKING 1
+#define TRANS_CLOSEONEXEC 2
+
+
+/*
+ * Return values of Connect (0 is success)
+ */
+
+#define TRANS_CONNECT_FAILED -1
+#define TRANS_TRY_CONNECT_AGAIN -2
+#define TRANS_IN_PROGRESS -3
+
+
+/*
+ * Return values of CreateListener (0 is success)
+ */
+
+#define TRANS_CREATE_LISTENER_FAILED -1
+#define TRANS_ADDR_IN_USE -2
+
+
+/*
+ * Return values of Accept (0 is success)
+ */
+
+#define TRANS_ACCEPT_BAD_MALLOC -1
+#define TRANS_ACCEPT_FAILED -2
+#define TRANS_ACCEPT_MISC_ERROR -3
+
+
+/*
+ * ResetListener return values
+ */
+
+#define TRANS_RESET_NOOP 1
+#define TRANS_RESET_NEW_FD 2
+#define TRANS_RESET_FAILURE 3
+
+
+/*
+ * Function prototypes for the exposed interface
+ */
+
+void TRANS(FreeConnInfo) (
+ XtransConnInfo /* ciptr */
+);
+
+#ifdef TRANS_CLIENT
+
+XtransConnInfo TRANS(OpenCOTSClient)(
+ char * /* address */
+);
+
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_SERVER
+
+XtransConnInfo TRANS(OpenCOTSServer)(
+ char * /* address */
+);
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+
+XtransConnInfo TRANS(OpenCLTSClient)(
+ char * /* address */
+);
+
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_SERVER
+
+XtransConnInfo TRANS(OpenCLTSServer)(
+ char * /* address */
+);
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_REOPEN
+
+XtransConnInfo TRANS(ReopenCOTSServer)(
+ int, /* trans_id */
+ int, /* fd */
+ char * /* port */
+);
+
+XtransConnInfo TRANS(ReopenCLTSServer)(
+ int, /* trans_id */
+ int, /* fd */
+ char * /* port */
+);
+
+int TRANS(GetReopenInfo)(
+ XtransConnInfo, /* ciptr */
+ int *, /* trans_id */
+ int *, /* fd */
+ char ** /* port */
+);
+
+#endif /* TRANS_REOPEN */
+
+
+int TRANS(SetOption)(
+ XtransConnInfo, /* ciptr */
+ int, /* option */
+ int /* arg */
+);
+
+#ifdef TRANS_SERVER
+
+int TRANS(CreateListener)(
+ XtransConnInfo, /* ciptr */
+ char *, /* port */
+ unsigned int /* flags */
+);
+
+int TRANS(NoListen) (
+ char* /* protocol*/
+);
+
+int TRANS(ResetListener)(
+ XtransConnInfo /* ciptr */
+);
+
+XtransConnInfo TRANS(Accept)(
+ XtransConnInfo, /* ciptr */
+ int * /* status */
+);
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+
+int TRANS(Connect)(
+ XtransConnInfo, /* ciptr */
+ char * /* address */
+);
+
+#endif /* TRANS_CLIENT */
+
+int TRANS(BytesReadable)(
+ XtransConnInfo, /* ciptr */
+ BytesReadable_t * /* pend */
+);
+
+int TRANS(Read)(
+ XtransConnInfo, /* ciptr */
+ char *, /* buf */
+ int /* size */
+);
+
+int TRANS(Write)(
+ XtransConnInfo, /* ciptr */
+ char *, /* buf */
+ int /* size */
+);
+
+int TRANS(Readv)(
+ XtransConnInfo, /* ciptr */
+ struct iovec *, /* buf */
+ int /* size */
+);
+
+int TRANS(Writev)(
+ XtransConnInfo, /* ciptr */
+ struct iovec *, /* buf */
+ int /* size */
+);
+
+int TRANS(Disconnect)(
+ XtransConnInfo /* ciptr */
+);
+
+int TRANS(Close)(
+ XtransConnInfo /* ciptr */
+);
+
+int TRANS(CloseForCloning)(
+ XtransConnInfo /* ciptr */
+);
+
+int TRANS(IsLocal)(
+ XtransConnInfo /* ciptr */
+);
+
+int TRANS(GetMyAddr)(
+ XtransConnInfo, /* ciptr */
+ int *, /* familyp */
+ int *, /* addrlenp */
+ Xtransaddr ** /* addrp */
+);
+
+int TRANS(GetPeerAddr)(
+ XtransConnInfo, /* ciptr */
+ int *, /* familyp */
+ int *, /* addrlenp */
+ Xtransaddr ** /* addrp */
+);
+
+int TRANS(GetConnectionNumber)(
+ XtransConnInfo /* ciptr */
+);
+
+#ifdef TRANS_SERVER
+
+int TRANS(MakeAllCOTSServerListeners)(
+ char *, /* port */
+ int *, /* partial */
+ int *, /* count_ret */
+ XtransConnInfo ** /* ciptrs_ret */
+);
+
+int TRANS(MakeAllCLTSServerListeners)(
+ char *, /* port */
+ int *, /* partial */
+ int *, /* count_ret */
+ XtransConnInfo ** /* ciptrs_ret */
+);
+
+#endif /* TRANS_SERVER */
+
+
+/*
+ * Function Prototypes for Utility Functions.
+ */
+
+#ifdef X11_t
+
+int TRANS(ConvertAddress)(
+ int *, /* familyp */
+ int *, /* addrlenp */
+ Xtransaddr ** /* addrp */
+);
+
+#endif /* X11_t */
+
+#ifdef ICE_t
+
+char *
+TRANS(GetMyNetworkId)(
+ XtransConnInfo /* ciptr */
+);
+
+char *
+TRANS(GetPeerNetworkId)(
+ XtransConnInfo /* ciptr */
+);
+
+#endif /* ICE_t */
+
+int
+TRANS(GetHostname) (
+ char * /* buf */,
+ int /* maxlen */
+);
+
+#if defined(WIN32) && (defined(TCPCONN) || defined(DNETCONN))
+int TRANS(WSAStartup)();
+#endif
+
+#endif /* _XTRANS_H_ */
diff --git a/nx-X11/lib/xtrans/Xtransdnet.c b/nx-X11/lib/xtrans/Xtransdnet.c
new file mode 100644
index 000000000..ac91695c7
--- /dev/null
+++ b/nx-X11/lib/xtrans/Xtransdnet.c
@@ -0,0 +1,668 @@
+/* $Xorg: Xtransdnet.c,v 1.4 2001/02/09 02:04:06 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/xtrans/Xtransdnet.c,v 3.7tsi Exp $ */
+
+/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * 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 NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCR and makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR 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.
+ */
+
+#ifndef WIN32
+#include <netdnet/dn.h>
+#include <netdnet/dnetdb.h>
+#include <sys/ioctl.h>
+#endif /* !WIN32 */
+
+#include <stdio.h>
+
+#ifdef WIN32
+#define _WILLWINSOCK_
+#define BOOL wBOOL
+#undef Status
+#define Status wStatus
+#include <prgpre.h> /* PATHWORKS header normally in %MSTOOLS%\h\pathwork */
+#undef Status
+#define Status int
+#undef BOOL
+#include <X11/Xw32defs.h>
+#undef close
+#define close closesocket
+#endif /* WIN32 */
+
+
+#if defined(X11_t)
+#define DNETOBJ "X$X"
+#endif
+#if defined(XIM_t)
+#define DNETOBJ "IMSERVER$"
+#endif
+#if defined(FS_t) || defined(FONT_t)
+#define DNETOBJ "X$FONT"
+#endif
+#if defined(ICE_t)
+#define DNETOBJ ""
+#endif
+#if defined(TEST_t)
+#define DNETOBJ "X$TEST"
+#endif
+
+
+/*
+ * This is the DNET implementation of the X Transport service layer
+ */
+
+/*
+ * This function gets the local address of the socket and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(DNETGetAddr) (XtransConnInfo ciptr)
+
+{
+ struct sockaddr_dn sockname;
+ int namelen = sizeof(sockname);
+
+ PRMSG (3,"DNETGetAddr(%x)\n", ciptr, 0, 0);
+
+ if (getsockname (ciptr->fd, (struct sockaddr *) &sockname, &namelen) < 0)
+ {
+ PRMSG (1,"DNETGetAddr: getsockname() failed: %d\n",
+ EGET(), 0, 0);
+ return -1;
+ }
+
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if ((ciptr->addr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1, "DNETGetAddr: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ return -1;
+ }
+
+ ciptr->family = sockname.sdn_family;
+ ciptr->addrlen = namelen;
+ memcpy (ciptr->addr, &sockname, ciptr->addrlen);
+
+ return 0;
+}
+
+
+/*
+ * This function gets the remote address of the socket and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(DNETGetPeerAddr) (XtransConnInfo ciptr)
+
+{
+ struct sockaddr_dn sockname;
+ int namelen = sizeof(sockname);
+
+ PRMSG (3,"DNETGetPeerAddr(%x)\n", ciptr, 0, 0);
+
+ if (getpeername (ciptr->fd, (struct sockaddr *) &sockname, &namelen) < 0)
+ {
+ PRMSG (1,"DNETGetPeerAddr: getpeername() failed: %d\n",
+ EGET(), 0, 0);
+ return -1;
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if ((ciptr->peeraddr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1,
+ "DNETGetPeerAddr: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ return -1;
+ }
+
+ ciptr->peeraddrlen = namelen;
+ memcpy (ciptr->peeraddr, &sockname, ciptr->peeraddrlen);
+
+ return 0;
+}
+
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(DNETOpenCOTSClient) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+
+ PRMSG (2,"DNETOpenCOTSClient(%s,%s,%s)\n", protocol, host, port);
+
+ if ((ciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "DNETOpenCOTSClient: malloc failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ ciptr->index = 0; /* only one form of DECnet */
+
+ /* nothing else to do here */
+
+ return ciptr;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(DNETOpenCOTSServer) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+
+ PRMSG (2,"DNETOpenCOTSServer(%s,%s,%s)\n", protocol, host, port);
+
+ if ((ciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "DNETOpenCOTSServer: malloc failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ if ((ciptr->fd = socket (AF_DECnet, SOCK_STREAM, 0)) < 0)
+ {
+ xfree ((char *) ciptr);
+ return NULL;
+ }
+
+ ciptr->index = 0; /* only one form of DECnet */
+
+ return (ciptr);
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(DNETOpenCLTSClient) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+
+ PRMSG (2,"DNETOpenCLTSClient(%s,%s,%s)\n", protocol, host, port);
+
+ if ((ciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof (struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "DNETOpenCLTSClient: malloc failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ ciptr->index = 0; /* only one form of DECnet */
+
+ /* nothing else to do here */
+
+ return ciptr;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(DNETOpenCLTSServer) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ /* NEED TO IMPLEMENT */
+
+ PRMSG (2,"DNETOpenCLTSServer(%s,%s,%s)\n", protocol, host, port);
+ return NULL;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(DNETReopenCOTSServer) (Xtransport *thistrans, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+
+ PRMSG (2,"DNETReopenCOTSServer(%d,%s)\n", fd, port, 0);
+
+ if ((ciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "DNETReopenCOTSServer: malloc failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ ciptr->fd = fd;
+ ciptr->index = 0; /* only one form of DECnet */
+
+ return (ciptr);
+}
+
+static XtransConnInfo
+TRANS(DNETReopenCLTSServer) (Xtransport *thistrans, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+
+ PRMSG (2,"DNETReopenCLTSServer(%d,%s)\n", fd, port, 0);
+
+ if ((ciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "DNETReopenCLTSServer: malloc failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ ciptr->fd = fd;
+ ciptr->index = 0; /* only one form of DECnet */
+
+ return (ciptr);
+}
+
+#endif /* TRANS_REOPEN */
+
+
+static int
+TRANS(DNETSetOption) (XtransConnInfo ciptr, int option, int arg)
+
+{
+ PRMSG (2,"DNETSetOption(%d,%d,%d)\n", ciptr->fd, option, arg);
+
+ return -1;
+}
+
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(DNETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags)
+
+{
+ struct sockaddr_dn dnsock;
+ int fd = ciptr->fd;
+
+ PRMSG (3, "DNETCreateListener(%x,%d)\n", ciptr, fd, 0);
+
+ bzero ((char *) &dnsock, sizeof (dnsock));
+ dnsock.sdn_family = AF_DECnet;
+
+ if (port && *port )
+ sprintf (dnsock.sdn_objname, "%s%s", DNETOBJ, port);
+ else
+#ifdef X11_t
+ return -1;
+#else
+ sprintf (dnsock.sdn_objname, "%s%d", DNETOBJ, getpid ());
+#endif
+
+ dnsock.sdn_objnamel = strlen (dnsock.sdn_objname);
+
+ if (bind (fd, (struct sockaddr *) &dnsock, sizeof (dnsock)))
+ {
+ close (fd);
+ return -1;
+ }
+
+ if (listen (fd, 5))
+ {
+ close (fd);
+ return (-1);
+ }
+
+
+ /* Set a flag to indicate that this connection is a listener */
+
+ ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS);
+
+ return 0;
+}
+
+
+static XtransConnInfo
+TRANS(DNETAccept) (XtransConnInfo ciptr, int *status)
+
+{
+ XtransConnInfo newciptr;
+ struct sockaddr_dn sockname;
+ int namelen = sizeof(sockname);
+
+ PRMSG (2, "DNETAccept(%x,%d)\n", ciptr, ciptr->fd, 0);
+
+ if ((newciptr = (XtransConnInfo) xcalloc(
+ 1, sizeof (struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "DNETAccept: malloc failed\n", 0, 0, 0);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+ if((newciptr->fd = accept (ciptr->fd,
+ (struct sockaddr *) &sockname, &namelen)) < 0)
+ {
+ PRMSG (1, "DNETAccept: accept() failed\n", 0, 0, 0);
+
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_FAILED;
+ return NULL;
+ }
+
+ /*
+ * Get this address again because the transport may give a more
+ * specific address now that a connection is established.
+ */
+
+ if (TRANS(DNETGetAddr) (newciptr) < 0)
+ {
+ PRMSG(1,
+ "DNETAccept: ...DNETGetAddr() failed:\n", 0, 0, 0);
+ close (newciptr->fd);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ if (TRANS(DNETGetPeerAddr) (newciptr) < 0)
+ {
+ PRMSG(1,
+ "DNETAccept: ...DNETGetPeerAddr() failed:\n", 0, 0, 0);
+
+ close (newciptr->fd);
+ if (newciptr->addr) xfree (newciptr->addr);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ *status = 0;
+
+ return newciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+#define OBJBUFSIZE 64
+
+static int
+TRANS(DNETConnect) (XtransConnInfo ciptr, char *host, char *port)
+
+{
+ char objname[OBJBUFSIZE];
+
+ extern int dnet_conn();
+
+ PRMSG (2,"DNETConnect(%d,%s,%s)\n", ciptr->fd, host, port);
+
+#ifdef X11_t
+ /*
+ * X has a well known port, that is transport dependent. It is easier
+ * to handle it here, than try and come up with a transport independent
+ * representation that can be passed in and resolved the usual way.
+ *
+ * The port that is passed here is really a string containing the idisplay
+ * from ConnectDisplay().
+ */
+
+ if (is_numeric (port))
+ {
+ short tmpport = (short) atoi (port);
+
+ sprintf (objname, "X$X%d", tmpport);
+ }
+ else
+#endif
+ strncpy(objname, port, OBJBUFSIZE);
+
+
+ /*
+ * Do the connect
+ */
+
+ if (!host) host = "0";
+
+ if ((ciptr->fd = dnet_conn (host, objname, SOCK_STREAM, 0, 0, 0, 0)) < 0)
+ {
+ return TRANS_CONNECT_FAILED;
+ }
+
+
+ /*
+ * Sync up the address fields of ciptr.
+ */
+
+ if (TRANS(DNETGetAddr) (ciptr) < 0)
+ {
+ PRMSG (1,
+ "DNETConnect: ...DNETGetAddr() failed:\n", 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+ if (TRANS(DNETGetPeerAddr) (ciptr) < 0)
+ {
+ PRMSG (1,
+ "DNETConnect: ...DNETGetPeerAddr() failed:\n",
+ 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+ return 0;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+static int
+TRANS(DNETBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)
+
+{
+ PRMSG (2,"DNETBytesReadable(%x,%d,%x)\n", ciptr, ciptr->fd, pend);
+
+#ifdef WIN32
+ {
+ int ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+ return ioctl(ciptr->fd, FIONREAD, (char *)pend);
+#endif /* WIN32 */
+}
+
+
+static int
+TRANS(DNETRead) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+ PRMSG (2,"DNETRead(%d,%x,%d)\n", ciptr->fd, buf, size);
+
+#ifdef WIN32
+ {
+ int ret = recv ((SOCKET)ciptr->fd, buf, size, 0);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+ return read (ciptr->fd, buf, size);
+#endif /* WIN32 */
+}
+
+
+static int
+TRANS(DNETWrite) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+ PRMSG (2,"DNETWrite(%d,%x,%d)\n", ciptr->fd, buf, size);
+
+#ifdef WIN32
+ {
+ int ret = send ((SOCKET)ciptr->fd, buf, size, 0);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+ return write (ciptr->fd, buf, size);
+#endif /* WIN32 */
+}
+
+
+static int
+TRANS(DNETReadv) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ PRMSG (2,"DNETReadv(%d,%x,%d)\n", ciptr->fd, buf, size);
+
+ return READV (ciptr, buf, size);
+}
+
+
+static int
+TRANS(DNETWritev) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ PRMSG (2,"DNETWritev(%d,%x,%d)\n", ciptr->fd, buf, size);
+
+ return WRITEV (ciptr, buf, size);
+}
+
+
+static int
+TRANS(DNETDisconnect) (XtransConnInfo ciptr)
+
+{
+ PRMSG (2,"DNETDisconnect(%x,%d)\n", ciptr, ciptr->fd, 0);
+
+#ifdef WIN32
+ {
+ int ret = shutdown (ciptr->fd, 2);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+ return shutdown (ciptr->fd, 2); /* disallow further sends and receives */
+#endif
+}
+
+
+static int
+TRANS(DNETClose) (XtransConnInfo ciptr)
+
+{
+ PRMSG (2,"DNETClose(%x,%d)\n", ciptr, ciptr->fd, 0);
+
+#ifdef WIN32
+ {
+ int ret = close (ciptr->fd);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+ return close (ciptr->fd);
+#endif
+}
+
+
+Xtransport TRANS(DNETFuncs) = {
+ /* DNET Interface */
+ "dnet",
+ 0,
+#ifdef TRANS_CLIENT
+ TRANS(DNETOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(DNETOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(DNETOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(DNETOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(DNETReopenCOTSServer),
+ TRANS(DNETReopenCLTSServer),
+#endif /* TRANS_REOPEN */
+ TRANS(DNETSetOption),
+#ifdef TRANS_SERVER
+ TRANS(DNETCreateListener),
+ NULL, /* ResetListener */
+ TRANS(DNETAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(DNETConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(DNETBytesReadable),
+ TRANS(DNETRead),
+ TRANS(DNETWrite),
+ TRANS(DNETReadv),
+ TRANS(DNETWritev),
+ TRANS(DNETDisconnect),
+ TRANS(DNETClose),
+ TRANS(DNETClose),
+};
diff --git a/nx-X11/lib/xtrans/Xtransint.h b/nx-X11/lib/xtrans/Xtransint.h
new file mode 100644
index 000000000..88d223074
--- /dev/null
+++ b/nx-X11/lib/xtrans/Xtransint.h
@@ -0,0 +1,485 @@
+/* $XdotOrg: xc/lib/xtrans/Xtransint.h,v 1.4 2005/11/08 06:33:26 jkj Exp $ */
+/* $Xorg: Xtransint.h,v 1.4 2001/02/09 02:04:06 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/xtrans/Xtransint.h,v 3.41 2003/08/28 00:35:23 tsi Exp $ */
+
+/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * 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 NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCR makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR 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.
+ */
+
+#ifndef _XTRANSINT_H_
+#define _XTRANSINT_H_
+
+/*
+ * XTRANSDEBUG will enable the PRMSG() macros used in the X Transport
+ * Interface code. Each use of the PRMSG macro has a level associated with
+ * it. XTRANSDEBUG is defined to be a level. If the invocation level is =<
+ * the value of XTRANSDEBUG, then the message will be printed out to stderr.
+ * Recommended levels are:
+ *
+ * XTRANSDEBUG=1 Error messages
+ * XTRANSDEBUG=2 API Function Tracing
+ * XTRANSDEBUG=3 All Function Tracing
+ * XTRANSDEBUG=4 printing of intermediate values
+ * XTRANSDEBUG=5 really detailed stuff
+#define XTRANSDEBUG 2
+ *
+ * Defining XTRANSDEBUGTIMESTAMP will cause printing timestamps with each
+ * message.
+ */
+
+#ifndef XTRANSDEBUG
+# ifndef __UNIXOS2__
+# define XTRANSDEBUG 1
+# else
+# define XTRANSDEBUG 1
+# endif
+#endif
+
+#ifdef WIN32
+# define _WILLWINSOCK_
+#endif
+
+#include "Xtrans.h"
+
+#ifdef XTRANSDEBUG
+# include <stdio.h>
+#endif /* XTRANSDEBUG */
+
+#include <errno.h>
+
+#ifndef WIN32
+# ifndef Lynx
+# include <sys/socket.h>
+# else
+# include <socket.h>
+# endif
+# include <netinet/in.h>
+# include <arpa/inet.h>
+# ifdef __UNIXOS2__
+# include <sys/ioctl.h>
+# endif
+
+/*
+ * Moved the setting of NEED_UTSNAME to this header file from Xtrans.c,
+ * to avoid a race condition. JKJ (6/5/97)
+ */
+
+# if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(USG) || defined(SVR4) || defined(__SCO__)
+# ifndef NEED_UTSNAME
+# define NEED_UTSNAME
+# endif
+# include <sys/utsname.h>
+# endif
+
+/*
+ * makedepend screws up on #undef OPEN_MAX, so we define a new symbol
+ */
+
+# ifndef TRANS_OPEN_MAX
+
+# ifndef X_NOT_POSIX
+# ifdef _POSIX_SOURCE
+# include <limits.h>
+# else
+# define _POSIX_SOURCE
+# include <limits.h>
+# undef _POSIX_SOURCE
+# endif
+# endif
+# ifndef OPEN_MAX
+# if defined(_SC_OPEN_MAX) && !defined(__UNIXOS2__)
+# define OPEN_MAX (sysconf(_SC_OPEN_MAX))
+# else
+# ifdef SVR4
+# define OPEN_MAX 256
+# else
+# include <sys/param.h>
+# ifndef OPEN_MAX
+# ifdef __OSF1__
+# define OPEN_MAX 256
+# else
+# ifdef NOFILE
+# define OPEN_MAX NOFILE
+# else
+# if !defined(__UNIXOS2__) && !defined(__QNX__)
+# define OPEN_MAX NOFILES_MAX
+# else
+# define OPEN_MAX 256
+# endif
+# endif
+# endif
+# endif
+# endif
+# endif
+# endif
+# if defined(_SC_OPEN_MAX)
+# define TRANS_OPEN_MAX OPEN_MAX
+# else /* !__GNU__ */
+# if OPEN_MAX > 256
+# define TRANS_OPEN_MAX 256
+# else
+# define TRANS_OPEN_MAX OPEN_MAX
+# endif
+# endif /*__GNU__*/
+
+# endif /* TRANS_OPEN_MAX */
+
+# ifdef __UNIXOS2__
+# define ESET(val)
+# else
+# define ESET(val) errno = val
+# endif
+# define EGET() errno
+
+#else /* WIN32 */
+
+# include <limits.h> /* for USHRT_MAX */
+
+# define ESET(val) WSASetLastError(val)
+# define EGET() WSAGetLastError()
+
+#endif /* WIN32 */
+
+#include <stddef.h>
+
+#ifdef X11_t
+#define X_TCP_PORT 6000
+#endif
+
+struct _XtransConnInfo {
+ struct _Xtransport *transptr;
+ int index;
+ char *priv;
+ int flags;
+ int fd;
+ char *port;
+ int family;
+ char *addr;
+ int addrlen;
+ char *peeraddr;
+ int peeraddrlen;
+};
+
+#define XTRANS_OPEN_COTS_CLIENT 1
+#define XTRANS_OPEN_COTS_SERVER 2
+#define XTRANS_OPEN_CLTS_CLIENT 3
+#define XTRANS_OPEN_CLTS_SERVER 4
+
+
+typedef struct _Xtransport {
+ char *TransName;
+ int flags;
+
+#ifdef TRANS_CLIENT
+
+ XtransConnInfo (*OpenCOTSClient)(
+ struct _Xtransport *, /* transport */
+ char *, /* protocol */
+ char *, /* host */
+ char * /* port */
+ );
+
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_SERVER
+ char ** nolisten;
+ XtransConnInfo (*OpenCOTSServer)(
+ struct _Xtransport *, /* transport */
+ char *, /* protocol */
+ char *, /* host */
+ char * /* port */
+ );
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+
+ XtransConnInfo (*OpenCLTSClient)(
+ struct _Xtransport *, /* transport */
+ char *, /* protocol */
+ char *, /* host */
+ char * /* port */
+ );
+
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_SERVER
+
+ XtransConnInfo (*OpenCLTSServer)(
+ struct _Xtransport *, /* transport */
+ char *, /* protocol */
+ char *, /* host */
+ char * /* port */
+ );
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+ XtransConnInfo (*ReopenCOTSServer)(
+ struct _Xtransport *, /* transport */
+ int, /* fd */
+ char * /* port */
+ );
+
+ XtransConnInfo (*ReopenCLTSServer)(
+ struct _Xtransport *, /* transport */
+ int, /* fd */
+ char * /* port */
+ );
+
+#endif /* TRANS_REOPEN */
+
+
+ int (*SetOption)(
+ XtransConnInfo, /* connection */
+ int, /* option */
+ int /* arg */
+ );
+
+#ifdef TRANS_SERVER
+/* Flags */
+# define ADDR_IN_USE_ALLOWED 1
+
+ int (*CreateListener)(
+ XtransConnInfo, /* connection */
+ char *, /* port */
+ unsigned int /* flags */
+ );
+
+ int (*ResetListener)(
+ XtransConnInfo /* connection */
+ );
+
+ XtransConnInfo (*Accept)(
+ XtransConnInfo, /* connection */
+ int * /* status */
+ );
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+
+ int (*Connect)(
+ XtransConnInfo, /* connection */
+ char *, /* host */
+ char * /* port */
+ );
+
+#endif /* TRANS_CLIENT */
+
+ int (*BytesReadable)(
+ XtransConnInfo, /* connection */
+ BytesReadable_t * /* pend */
+ );
+
+ int (*Read)(
+ XtransConnInfo, /* connection */
+ char *, /* buf */
+ int /* size */
+ );
+
+ int (*Write)(
+ XtransConnInfo, /* connection */
+ char *, /* buf */
+ int /* size */
+ );
+
+ int (*Readv)(
+ XtransConnInfo, /* connection */
+ struct iovec *, /* buf */
+ int /* size */
+ );
+
+ int (*Writev)(
+ XtransConnInfo, /* connection */
+ struct iovec *, /* buf */
+ int /* size */
+ );
+
+ int (*Disconnect)(
+ XtransConnInfo /* connection */
+ );
+
+ int (*Close)(
+ XtransConnInfo /* connection */
+ );
+
+ int (*CloseForCloning)(
+ XtransConnInfo /* connection */
+ );
+
+} Xtransport;
+
+
+typedef struct _Xtransport_table {
+ Xtransport *transport;
+ int transport_id;
+} Xtransport_table;
+
+
+/*
+ * Flags for the flags member of Xtransport.
+ */
+
+#define TRANS_ALIAS (1<<0) /* record is an alias, don't create server */
+#define TRANS_LOCAL (1<<1) /* local transport */
+#define TRANS_DISABLED (1<<2) /* Don't open this one */
+#define TRANS_NOLISTEN (1<<3) /* Don't listen on this one */
+#define TRANS_NOUNLINK (1<<4) /* Dont unlink transport endpoints */
+
+/* Flags to preserve when setting others */
+#define TRANS_KEEPFLAGS (TRANS_NOUNLINK)
+
+/*
+ * readv() and writev() don't exist or don't work correctly on some
+ * systems, so they may be emulated.
+ */
+
+#if defined(CRAY) || (defined(SYSV) && defined(i386) && !defined(__SCO__)) || defined(WIN32) || defined(__sxg__) || defined(__UNIXOS2__)
+
+#define READV(ciptr, iov, iovcnt) TRANS(ReadV)(ciptr, iov, iovcnt)
+
+static int TRANS(ReadV)(
+ XtransConnInfo, /* ciptr */
+ struct iovec *, /* iov */
+ int /* iovcnt */
+);
+
+#else
+
+#define READV(ciptr, iov, iovcnt) readv(ciptr->fd, iov, iovcnt)
+
+#endif /* CRAY || (SYSV && i386) || WIN32 || __sxg__ || */
+
+
+#if defined(CRAY) || (defined(SYSV) && defined(i386) && !defined(__SCO__)) || defined(WIN32) || defined(__sxg__) || defined(__UNIXOS2__)
+
+#define WRITEV(ciptr, iov, iovcnt) TRANS(WriteV)(ciptr, iov, iovcnt)
+
+static int TRANS(WriteV)(
+ XtransConnInfo, /* ciptr */
+ struct iovec *, /* iov */
+ int /* iovcnt */
+);
+
+#else
+
+#define WRITEV(ciptr, iov, iovcnt) writev(ciptr->fd, iov, iovcnt)
+
+#endif /* CRAY || WIN32 || __sxg__ */
+
+
+static int is_numeric (
+ char * /* str */
+);
+
+#ifdef TRANS_SERVER
+static int trans_mkdir (
+ char *, /* path */
+ int /* mode */
+);
+#endif
+
+/*
+ * Some XTRANSDEBUG stuff
+ */
+
+#if defined(XTRANSDEBUG)
+/* add hack to the format string to avoid warnings about extra arguments
+ * to fprintf.
+ */
+#ifdef XTRANSDEBUGTIMESTAMP
+#if defined(XSERV_t) && defined(TRANS_SERVER)
+/* Use ErrorF() for the X server */
+#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \
+ int hack= 0, saveerrno=errno; \
+ struct timeval tp;\
+ gettimeofday(&tp,0); \
+ ErrorF(__xtransname); \
+ ErrorF(x+hack,a,b,c); \
+ ErrorF("timestamp (ms): %d\n",tp.tv_sec*1000+tp.tv_usec/1000); \
+ errno=saveerrno; \
+ } else ((void)0)
+#else
+#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \
+ int hack= 0, saveerrno=errno; \
+ struct timeval tp;\
+ gettimeofday(&tp,0); \
+ fprintf(stderr, __xtransname); fflush(stderr); \
+ fprintf(stderr, x+hack,a,b,c); fflush(stderr); \
+ fprintf(stderr, "timestamp (ms): %d\n",tp.tv_sec*1000+tp.tv_usec/1000); \
+ fflush(stderr); \
+ errno=saveerrno; \
+ } else ((void)0)
+#endif /* XSERV_t && TRANS_SERVER */
+#else /* XTRANSDEBUGTIMESTAMP */
+#if defined(XSERV_t) && defined(TRANS_SERVER)
+/* Use ErrorF() for the X server */
+#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \
+ int hack= 0, saveerrno=errno; \
+ ErrorF(__xtransname); \
+ ErrorF(x+hack,a,b,c); \
+ errno=saveerrno; \
+ } else ((void)0)
+#else
+#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \
+ int hack= 0, saveerrno=errno; \
+ fprintf(stderr, __xtransname); fflush(stderr); \
+ fprintf(stderr, x+hack,a,b,c); fflush(stderr); \
+ errno=saveerrno; \
+ } else ((void)0)
+#endif /* XSERV_t && TRANS_SERVER */
+#endif /* XTRANSDEBUGTIMESTAMP */
+#else
+#define PRMSG(lvl,x,a,b,c) ((void)0)
+#endif /* XTRANSDEBUG */
+
+#endif /* _XTRANSINT_H_ */
diff --git a/nx-X11/lib/xtrans/Xtranslcl.c b/nx-X11/lib/xtrans/Xtranslcl.c
new file mode 100644
index 000000000..6165d3658
--- /dev/null
+++ b/nx-X11/lib/xtrans/Xtranslcl.c
@@ -0,0 +1,2755 @@
+/* $Xorg: Xtranslcl.c,v 1.6 2001/02/09 02:04:06 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/xtrans/Xtranslcl.c,v 3.40tsi Exp $ */
+
+/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * 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 NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCR makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR 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.
+ */
+
+/*
+ *
+ * The connection code/ideas in lib/X and server/os for SVR4/Intel
+ * environments was contributed by the following companies/groups:
+ *
+ * MetroLink Inc
+ * NCR
+ * Pittsburgh Powercomputing Corporation (PPc)/Quarterdeck Office Systems
+ * SGCS
+ * Unix System Laboratories (USL) / Novell
+ * XFree86
+ *
+ * The goal is to have common connection code among all SVR4/Intel vendors.
+ *
+ * ALL THE ABOVE COMPANIES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL THESE COMPANIES * 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 <errno.h>
+#include <ctype.h>
+#include <sys/signal.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#if defined(SVR4)
+#if !defined(DGUX)
+#include <sys/filio.h>
+#else /* DGUX */
+#include <sys/stream.h>
+#include <sys/ptms.h>
+#endif
+#endif
+#include <sys/stropts.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+
+/*
+ * The local transports should be treated the same as a UNIX domain socket
+ * wrt authentication, etc. Because of this, we will use struct sockaddr_un
+ * for the address format. This will simplify the code in other places like
+ * The X Server.
+ */
+
+#include <sys/socket.h>
+#ifndef X_NO_SYS_UN
+#include <sys/un.h>
+#endif
+
+#if defined(ISC) && !defined(_POSIX_SOURCE)
+typedef unsigned short mode_t;
+/* POSIX needed for mode_t define in sys/types.h */
+#endif
+
+/*
+ * These functions actually implement the local connection mechanisms.
+ */
+
+/* Type Not Supported */
+
+static int
+TRANS(OpenFail)(XtransConnInfo ciptr, char *port)
+
+{
+ return -1;
+}
+
+#ifdef TRANS_REOPEN
+
+static int
+TRANS(ReopenFail)(XtransConnInfo ciptr, int fd, char *port)
+
+{
+ return 0;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+
+static int
+TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path)
+
+{
+ struct sockaddr_un *sunaddr;
+ struct sockaddr_un *p_sunaddr;
+
+ ciptr->family = AF_UNIX;
+ ciptr->addrlen = sizeof (struct sockaddr_un);
+
+ if ((sunaddr = (struct sockaddr_un *) xalloc (ciptr->addrlen)) == NULL)
+ {
+ PRMSG(1,"FillAddrInfo: failed to allocate memory for addr\n", 0, 0, 0);
+ return 0;
+ }
+
+ sunaddr->sun_family = AF_UNIX;
+
+ if (strlen(sun_path) > sizeof(sunaddr->sun_path) - 1) {
+ PRMSG(1, "FillAddrInfo: path too long\n", 0, 0, 0);
+ return 0;
+ }
+ strcpy (sunaddr->sun_path, sun_path);
+#if defined(BSD44SOCKETS) && !defined(Lynx)
+ sunaddr->sun_len = strlen (sunaddr->sun_path);
+#endif
+
+ ciptr->addr = (char *) sunaddr;
+
+ ciptr->peeraddrlen = sizeof (struct sockaddr_un);
+
+ if ((p_sunaddr = (struct sockaddr_un *) xalloc (
+ ciptr->peeraddrlen)) == NULL)
+ {
+ PRMSG(1,
+ "FillAddrInfo: failed to allocate memory for peer addr\n",
+ 0,0,0);
+ xfree ((char *) sunaddr);
+ ciptr->addr = NULL;
+
+ return 0;
+ }
+
+ p_sunaddr->sun_family = AF_UNIX;
+
+ if (strlen(peer_sun_path) > sizeof(p_sunaddr->sun_path) - 1) {
+ PRMSG(1, "FillAddrInfo: peer path too long\n", 0, 0, 0);
+ return 0;
+ }
+ strcpy (p_sunaddr->sun_path, peer_sun_path);
+#if defined(BSD44SOCKETS) && !defined(Lynx)
+ p_sunaddr->sun_len = strlen (p_sunaddr->sun_path);
+#endif
+
+ ciptr->peeraddr = (char *) p_sunaddr;
+
+ return 1;
+}
+
+
+
+/* PTS */
+
+#if defined(SYSV) && !defined(__SCO__) && !defined(ISC)
+#define SIGNAL_T int
+#else
+#define SIGNAL_T void
+#endif /* SYSV */
+
+typedef SIGNAL_T (*PFV)();
+
+extern PFV signal();
+
+extern char *ptsname(
+ int
+);
+
+static void _dummy(int sig)
+
+{
+}
+
+#ifndef sun
+#define X_STREAMS_DIR "/dev/X"
+#define DEV_SPX "/dev/spx"
+#else
+#ifndef X11_t
+#define X_STREAMS_DIR "/dev/X"
+#else
+#define X_STREAMS_DIR "/tmp/.X11-pipe"
+#endif
+#endif
+
+#ifdef _AIX
+#define DEV_PTMX "/dev/ptc"
+#else
+#define DEV_PTMX "/dev/ptmx"
+#endif
+
+#if defined(X11_t)
+
+#define PTSNODENAME "/dev/X/server."
+#ifndef sun
+#define NAMEDNODENAME "/dev/X/Nserver."
+#else
+#define NAMEDNODENAME "/tmp/.X11-pipe/X"
+#endif
+
+/*
+ * ISC is only defined for X11 since they are there for
+ * backwards binary compatability only.
+ */
+
+#define X_ISC_DIR "/dev/X/ISCCONN"
+#define ISCDEVNODENAME "/dev/X/ISCCONN/X%s"
+#define ISCTMPNODENAME "/tmp/.X11-unix/X%s"
+#define SCORNODENAME "/dev/X%1sR"
+#define SCOSNODENAME "/dev/X%1sS"
+#endif
+#if defined(XIM_t)
+#define PTSNODENAME "/dev/X/XIM."
+#define NAMEDNODENAME "/dev/X/NXIM."
+#define SCORNODENAME "/dev/XIM.%sR"
+#define SCOSNODENAME "/dev/XIM.%sS"
+#endif
+#if defined(FS_t) || defined (FONT_t)
+/*
+ * USL has already defined something here. We need to check with them
+ * and see if their choice is usable here.
+ */
+#define PTSNODENAME "/dev/X/fontserver."
+#define NAMEDNODENAME "/dev/X/Nfontserver."
+#define SCORNODENAME "/dev/fontserver.%sR"
+#define SCOSNODENAME "/dev/fontserver.%sS"
+#endif
+#if defined(ICE_t)
+#define PTSNODENAME "/dev/X/ICE."
+#define NAMEDNODENAME "/dev/X/NICE."
+#define SCORNODENAME "/dev/ICE.%sR"
+#define SCOSNODENAME "/dev/ICE.%sS"
+#endif
+#if defined(TEST_t)
+#define PTSNODENAME "/dev/X/transtest."
+#define NAMEDNODENAME "/dev/X/Ntranstest."
+#define SCORNODENAME "/dev/transtest.%sR"
+#define SCOSNODENAME "/dev/transtest.%sS"
+#endif
+
+
+
+#ifndef sun
+#ifdef TRANS_CLIENT
+
+static int
+TRANS(PTSOpenClient)(XtransConnInfo ciptr, char *port)
+
+{
+#ifdef PTSNODENAME
+ int fd,server,exitval,alarm_time,ret;
+ char server_path[64];
+ char *slave, namelen;
+ char buf[20]; /* MAX_PATH_LEN?? */
+ PFV savef;
+ pid_t saved_pid;
+#endif
+
+ PRMSG(2,"PTSOpenClient(%s)\n", port, 0,0 );
+
+#if !defined(PTSNODENAME)
+ PRMSG(1,"PTSOpenClient: Protocol is not supported by a pts connection\n", 0,0,0);
+ return -1;
+#else
+ if (port && *port ) {
+ if( *port == '/' ) { /* A full pathname */
+ (void) sprintf(server_path, "%s", port);
+ } else {
+ (void) sprintf(server_path, "%s%s", PTSNODENAME, port);
+ }
+ } else {
+ (void) sprintf(server_path, "%s%d", PTSNODENAME, getpid());
+ }
+
+
+ /*
+ * Open the node the on which the server is listening.
+ */
+
+ if ((server = open (server_path, O_RDWR)) < 0) {
+ PRMSG(1,"PTSOpenClient: failed to open %s\n", server_path, 0,0);
+ return -1;
+ }
+
+
+ /*
+ * Open the streams based pipe that will be this connection.
+ */
+
+ if ((fd = open(DEV_PTMX, O_RDWR)) < 0) {
+ PRMSG(1,"PTSOpenClient: failed to open %s\n", DEV_PTMX, 0,0);
+ return(-1);
+ }
+
+ (void) grantpt(fd);
+ (void) unlockpt(fd);
+
+ slave = ptsname(fd); /* get name */
+
+ if( slave == NULL ) {
+ PRMSG(1,"PTSOpenClient: failed to get ptsname()\n", 0,0,0);
+ close(fd);
+ close(server);
+ return -1;
+ }
+
+ /*
+ * This is neccesary for the case where a program is setuid to non-root.
+ * grantpt() calls /usr/lib/pt_chmod which is set-uid root. This program will
+ * set the owner of the pt device incorrectly if the uid is not restored
+ * before it is called. The problem is that once it gets restored, it
+ * cannot be changed back to its original condition, hence the fork().
+ */
+
+ if(!(saved_pid=fork())) {
+ uid_t saved_euid;
+
+ saved_euid = geteuid();
+ /** sets the euid to the actual/real uid **/
+ if (setuid( getuid() ) == -1) {
+ exit(1);
+ }
+ if( chown( slave, saved_euid, -1 ) < 0 ) {
+ exit( 1 );
+ }
+
+ exit( 0 );
+ }
+
+ waitpid(saved_pid, &exitval, 0);
+ if (WIFEXITED(exitval) && WEXITSTATUS(exitval) != 0) {
+ close(fd);
+ close(server);
+ PRMSG(1, "PTSOpenClient: cannot set the owner of %s\n",
+ slave, 0, 0);
+ return(-1);
+ }
+ if (chmod(slave, 0666) < 0) {
+ close(fd);
+ close(server);
+ PRMSG(1,"PTSOpenClient: Cannot chmod %s\n", slave, 0,0);
+ return(-1);
+ }
+
+ /*
+ * write slave name to server
+ */
+
+ namelen = strlen(slave);
+ buf[0] = namelen;
+ (void) sprintf(&buf[1], slave);
+ (void) write(server, buf, namelen+1);
+ (void) close(server);
+
+ /*
+ * wait for server to respond
+ */
+
+ savef = signal(SIGALRM, _dummy);
+ alarm_time = alarm (30); /* CONNECT_TIMEOUT */
+
+ ret = read(fd, buf, 1);
+
+ (void) alarm(alarm_time);
+ (void) signal(SIGALRM, savef);
+
+ if (ret != 1) {
+ PRMSG(1,
+ "PTSOpenClient: failed to get acknoledgement from server\n", 0, 0, 0);
+ (void) close(fd);
+ fd = -1;
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if (TRANS(FillAddrInfo) (ciptr, slave, server_path) == 0)
+ {
+ PRMSG(1,"PTSOpenClient: failed to fill in addr info\n", 0, 0, 0);
+ close(fd);
+ return -1;
+ }
+
+ return(fd);
+
+#endif /* !PTSNODENAME */
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(PTSOpenServer)(XtransConnInfo ciptr, char *port)
+
+{
+#ifdef PTSNODENAME
+ int fd, server;
+ char server_path[64], *slave;
+ int mode;
+#endif
+
+ PRMSG(2,"PTSOpenServer(%s)\n", port, 0,0 );
+
+#if !defined(PTSNODENAME)
+ PRMSG(1,"PTSOpenServer: Protocol is not supported by a pts connection\n", 0,0,0);
+ return -1;
+#else
+ if (port && *port ) {
+ if( *port == '/' ) { /* A full pathname */
+ (void) sprintf(server_path, "%s", port);
+ } else {
+ (void) sprintf(server_path, "%s%s", PTSNODENAME, port);
+ }
+ } else {
+ (void) sprintf(server_path, "%s%d", PTSNODENAME, getpid());
+ }
+
+#ifdef HAS_STICKY_DIR_BIT
+ mode = 01777;
+#else
+ mode = 0777;
+#endif
+ if (trans_mkdir(X_STREAMS_DIR, mode) == -1) {
+ PRMSG (1, "PTSOpenServer: mkdir(%s) failed, errno = %d\n",
+ X_STREAMS_DIR, errno, 0);
+ return(-1);
+ }
+
+#if 0
+ if( (fd=open(server_path, O_RDWR)) >= 0 ) {
+ /*
+ * This doesn't prevent the server from starting up, and doesn't
+ * prevent clients from trying to connect to the in-use PTS (which
+ * is often in use by something other than another server).
+ */
+ PRMSG(1, "PTSOpenServer: A server is already running on port %s\n", port, 0,0 );
+ PRMSG(1, "PTSOpenServer: Remove %s if this is incorrect.\n", server_path, 0,0 );
+ close(fd);
+ return(-1);
+ }
+#else
+ /* Just remove the old path (which is what happens with UNIXCONN) */
+#endif
+
+ unlink(server_path);
+
+ if( (fd=open(DEV_PTMX, O_RDWR)) < 0) {
+ PRMSG(1, "PTSOpenServer: Unable to open %s\n", DEV_PTMX, 0,0 );
+ return(-1);
+ }
+
+ grantpt(fd);
+ unlockpt(fd);
+
+ if( (slave=ptsname(fd)) == NULL) {
+ PRMSG(1, "PTSOpenServer: Unable to get slave device name\n", 0,0,0 );
+ close(fd);
+ return(-1);
+ }
+
+ if( link(slave,server_path) < 0 ) {
+ PRMSG(1, "PTSOpenServer: Unable to link %s to %s\n", slave, server_path,0 );
+ close(fd);
+ return(-1);
+ }
+
+ if( chmod(server_path, 0666) < 0 ) {
+ PRMSG(1, "PTSOpenServer: Unable to chmod %s to 0666\n", server_path,0,0 );
+ close(fd);
+ return(-1);
+ }
+
+ if( (server=open(server_path, O_RDWR)) < 0 ) {
+ PRMSG(1, "PTSOpenServer: Unable to open server device %s\n", server_path,0,0 );
+ close(fd);
+ return(-1);
+ }
+
+ close(server);
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+ {
+ PRMSG(1,"PTSOpenServer: failed to fill in addr info\n", 0, 0, 0);
+ close(fd);
+ return -1;
+ }
+
+ return fd;
+
+#endif /* !PTSNODENAME */
+}
+
+static int
+TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
+
+{
+ int newfd;
+ int in;
+ unsigned char length;
+ char buf[256];
+ struct sockaddr_un *sunaddr;
+
+ PRMSG(2,"PTSAccept(%x->%d)\n",ciptr,ciptr->fd,0);
+
+ if( (in=read(ciptr->fd,&length,1)) <= 0 ){
+ if( !in ) {
+ PRMSG(2,
+ "PTSAccept: Incoming connection closed\n",0,0,0);
+ }
+ else {
+ PRMSG(1,
+ "PTSAccept: Error reading incoming connection. errno=%d \n",
+ errno,0,0);
+ }
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return -1;
+ }
+
+ if( (in=read(ciptr->fd,buf,length)) <= 0 ){
+ if( !in ) {
+ PRMSG(2,
+ "PTSAccept: Incoming connection closed\n",0,0,0);
+ }
+ else {
+ PRMSG(1,
+"PTSAccept: Error reading device name for new connection. errno=%d \n",
+ errno,0,0);
+ }
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return -1;
+ }
+
+ buf[length] = '\0';
+
+ if( (newfd=open(buf,O_RDWR)) < 0 ) {
+ PRMSG(1, "PTSAccept: Failed to open %s\n",buf,0,0);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return -1;
+ }
+
+ write(newfd,"1",1);
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ newciptr->addrlen=ciptr->addrlen;
+ if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) {
+ PRMSG(1,"PTSAccept: failed to allocate memory for peer addr\n",
+ 0,0,0);
+ close(newfd);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return -1;
+ }
+
+ memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);
+
+ newciptr->peeraddrlen=sizeof(struct sockaddr_un);
+ if( (sunaddr=(struct sockaddr_un *)xalloc(newciptr->peeraddrlen)) == NULL ) {
+ PRMSG(1,"PTSAccept: failed to allocate memory for peer addr\n",
+ 0,0,0);
+ xfree(newciptr->addr);
+ close(newfd);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return -1;
+ }
+
+ sunaddr->sun_family=AF_UNIX;
+ strcpy(sunaddr->sun_path,buf);
+#if defined(BSD44SOCKETS) && !defined(Lynx)
+ sunaddr->sun_len=strlen(sunaddr->sun_path);
+#endif
+
+ newciptr->peeraddr=(char *)sunaddr;
+
+ *status = 0;
+
+ return newfd;
+}
+
+#endif /* TRANS_SERVER */
+#endif /* sun */
+
+
+#ifdef SVR4
+
+/* NAMED */
+
+#ifdef TRANS_CLIENT
+
+static int
+TRANS(NAMEDOpenClient)(XtransConnInfo ciptr, char *port)
+
+{
+#ifdef NAMEDNODENAME
+ int fd;
+ char server_path[64];
+ struct stat filestat;
+ extern int isastream();
+#endif
+
+ PRMSG(2,"NAMEDOpenClient(%s)\n", port, 0,0 );
+
+#if !defined(NAMEDNODENAME)
+ PRMSG(1,"NAMEDOpenClient: Protocol is not supported by a NAMED connection\n", 0,0,0);
+ return -1;
+#else
+ if ( port && *port ) {
+ if( *port == '/' ) { /* A full pathname */
+ (void) sprintf(server_path, "%s", port);
+ } else {
+ (void) sprintf(server_path, "%s%s", NAMEDNODENAME, port);
+ }
+ } else {
+ (void) sprintf(server_path, "%s%ld", NAMEDNODENAME, (long)getpid());
+ }
+
+ if (stat(server_path, &filestat) < 0 ) {
+ PRMSG(1,"NAMEDOpenClient: No device %s for NAMED connection\n", server_path, 0,0 );
+ return -1;
+ }
+
+ if ((filestat.st_mode & S_IFMT) != S_IFIFO) {
+ PRMSG(1,"NAMEDOpenClient: Device %s is not a FIFO\n", server_path, 0,0 );
+ /* Is this really a failure? */
+ return -1;
+ }
+
+ if ((fd = open(server_path, O_RDWR)) < 0) {
+ PRMSG(1,"NAMEDOpenClient: Cannot open %s for NAMED connection\n", server_path, 0,0 );
+ return -1;
+ }
+
+ if (isastream(fd) <= 0) {
+ PRMSG(1,"NAMEDOpenClient: %s is not a streams device\n", server_path, 0,0 );
+ (void) close(fd);
+ return -1;
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+ {
+ PRMSG(1,"NAMEDOpenClient: failed to fill in addr info\n",
+ 0,0,0);
+ close(fd);
+ return -1;
+ }
+
+ return(fd);
+
+#endif /* !NAMEDNODENAME */
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(NAMEDOpenServer)(XtransConnInfo ciptr, char *port)
+
+{
+#ifdef NAMEDNODENAME
+ int fd, pipefd[2];
+ char server_path[64];
+ struct stat sbuf;
+ int mode;
+#endif
+
+ PRMSG(2,"NAMEDOpenServer(%s)\n", port, 0,0 );
+
+#if !defined(NAMEDNODENAME)
+ PRMSG(1,"NAMEDOpenServer: Protocol is not supported by a NAMED connection\n", 0,0,0);
+ return -1;
+#else
+ if ( port && *port ) {
+ if( *port == '/' ) { /* A full pathname */
+ (void) sprintf(server_path, "%s", port);
+ } else {
+ (void) sprintf(server_path, "%s%s", NAMEDNODENAME, port);
+ }
+ } else {
+ (void) sprintf(server_path, "%s%ld", NAMEDNODENAME, (long)getpid());
+ }
+
+#ifdef HAS_STICKY_DIR_BIT
+ mode = 01777;
+#else
+ mode = 0777;
+#endif
+ if (trans_mkdir(X_STREAMS_DIR, mode) == -1) {
+ PRMSG (1, "NAMEDOpenServer: mkdir(%s) failed, errno = %d\n",
+ X_STREAMS_DIR, errno, 0);
+ return(-1);
+ }
+
+ if(stat(server_path, &sbuf) != 0) {
+ if (errno == ENOENT) {
+ if ((fd = creat(server_path, (mode_t)0666)) == -1) {
+ PRMSG(1, "NAMEDOpenServer: Can't open %s\n", server_path, 0,0 );
+ return(-1);
+ }
+ close(fd);
+ if (chmod(server_path, (mode_t)0666) < 0) {
+ PRMSG(1, "NAMEDOpenServer: Can't open %s\n", server_path, 0,0 );
+ return(-1);
+ }
+ } else {
+ PRMSG(1, "NAMEDOpenServer: stat on %s failed\n", server_path, 0,0 );
+ return(-1);
+ }
+ }
+
+ if( pipe(pipefd) != 0) {
+ PRMSG(1, "NAMEDOpenServer: pipe() failed, errno=%d\n",errno, 0,0 );
+ return(-1);
+ }
+
+ if( ioctl(pipefd[0], I_PUSH, "connld") != 0) {
+ PRMSG(1, "NAMEDOpenServer: ioctl(I_PUSH,\"connld\") failed, errno=%d\n",errno, 0,0 );
+ close(pipefd[0]);
+ close(pipefd[1]);
+ return(-1);
+ }
+
+ if( fattach(pipefd[0], server_path) != 0) {
+ PRMSG(1, "NAMEDOpenServer: fattach(%s) failed, errno=%d\n", server_path,errno, 0 );
+ close(pipefd[0]);
+ close(pipefd[1]);
+ return(-1);
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+ {
+ PRMSG(1,"NAMEDOpenServer: failed to fill in addr info\n", 0,0,0);
+ return -1;
+ }
+
+ return(pipefd[1]);
+
+#endif /* !NAMEDNODENAME */
+}
+
+static int
+TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
+
+{
+ struct strrecvfd str;
+
+ PRMSG(2,"NAMEDAccept(%x->%d)\n", ciptr, ciptr->fd, 0 );
+
+ if( ioctl(ciptr->fd, I_RECVFD, &str ) < 0 ) {
+ PRMSG(1, "NAMEDAccept: ioctl(I_RECVFD) failed, errno=%d\n", errno, 0,0 );
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return(-1);
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ newciptr->addrlen=ciptr->addrlen;
+ if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) {
+ PRMSG(1,
+ "NAMEDAccept: failed to allocate memory for peer addr\n",
+ 0,0,0);
+ close(str.fd);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return -1;
+ }
+
+ memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);
+
+ newciptr->peeraddrlen=newciptr->addrlen;
+ if( (newciptr->peeraddr=(char *)xalloc(newciptr->peeraddrlen)) == NULL ) {
+ PRMSG(1,
+ "NAMEDAccept: failed to allocate memory for peer addr\n",
+ 0,0,0);
+ xfree(newciptr->addr);
+ close(str.fd);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return -1;
+ }
+
+ memcpy(newciptr->peeraddr,newciptr->addr,newciptr->peeraddrlen);
+
+ *status = 0;
+
+ return str.fd;
+}
+
+#endif /* TRANS_SERVER */
+
+#endif /* SVR4 */
+
+
+
+#ifndef sun
+
+/*
+ * connect_spipe is used by the SCO and ISC connection types.
+ */
+static int
+connect_spipe(int fd1, int fd2)
+{
+ long temp;
+ struct strfdinsert sbuf;
+
+ sbuf.databuf.maxlen = -1;
+ sbuf.databuf.len = -1;
+ sbuf.databuf.buf = NULL;
+ sbuf.ctlbuf.maxlen = sizeof(long);
+ sbuf.ctlbuf.len = sizeof(long);
+ sbuf.ctlbuf.buf = (caddr_t)&temp;
+ sbuf.offset = 0;
+ sbuf.fildes = fd2;
+ sbuf.flags = 0;
+
+ if( ioctl(fd1, I_FDINSERT, &sbuf) < 0 )
+ return(-1);
+
+ return(0);
+}
+
+/*
+ * named_spipe is used by the SCO and ISC connection types.
+ */
+
+static int
+named_spipe(int fd, char *path)
+
+{
+ int oldUmask, ret;
+ struct stat sbuf;
+
+ oldUmask = umask(0);
+
+ (void) fstat(fd, &sbuf);
+ ret = mknod(path, 0020666, sbuf.st_rdev);
+
+ umask(oldUmask);
+
+ if (ret < 0) {
+ ret = -1;
+ } else {
+ ret = fd;
+ }
+
+ return(ret);
+}
+
+/* SCO doesnt use the ISC transport type - it causes problems */
+#if !defined(__SCO__) && !defined(__UNIXWARE__)
+
+
+/* ISC */
+
+#ifdef TRANS_CLIENT
+
+static int
+TRANS(ISCOpenClient)(XtransConnInfo ciptr, char *port)
+
+{
+#ifdef ISCDEVNODENAME
+ int fd,fds,server;
+ char server_path[64];
+ char server_dev_path[64];
+ struct strfdinsert buf;
+ long temp;
+ mode_t spmode;
+ struct stat filestat;
+#endif
+
+ PRMSG(2,"ISCOpenClient(%s)\n", port, 0,0 );
+
+#if !defined(ISCDEVNODENAME)
+ PRMSG(1,"ISCOpenClient: Protocol is not supported by a ISC connection\n", 0,0,0);
+ return -1;
+#else
+ (void) sprintf(server_path, ISCTMPNODENAME, port);
+ (void) sprintf(server_dev_path, ISCDEVNODENAME, port);
+
+ fd = fds = server = -1;
+
+ if (stat(DEV_SPX, &filestat) == -1) {
+ PRMSG(1, "ISCOpenClient: stat(%s) failed, errno=%d\n", DEV_SPX, errno, 0 );
+ return(-1);
+ }
+
+ spmode = (filestat.st_mode & S_IFMT);
+
+ if (stat(server_path, &filestat) != -1) {
+ if ((filestat.st_mode & S_IFMT) == spmode) {
+ if ((server = open(server_path, O_RDWR)) < 0) {
+ PRMSG(1,"ISCOpenClient: failed to open %s\n",
+ server_path, 0,0 );
+ }
+ }
+ }
+
+ if (server < 0) {
+ /* try the alternate path */
+ if (stat(server_dev_path, &filestat) != -1) {
+ if ((filestat.st_mode & S_IFMT) == spmode) {
+ if ((server = open(server_dev_path, O_RDWR)) < 0) {
+ PRMSG(1,"ISCOpenClient: failed to open %s\n",
+ server_dev_path, 0,0 );
+ }
+ }
+ }
+ }
+
+ if (server < 0) {
+ PRMSG(1,"ISCOpenClient: can't open either device %s or %s\n",
+ server_path, server_dev_path, 0 );
+ return -1;
+ }
+
+ if ((fds = open(DEV_SPX, O_RDWR)) < 0 ||
+ (fd = open(DEV_SPX, O_RDWR)) < 0) {
+ /* Failed to open all of the devices */
+ PRMSG(1,"ISCOpenClient: can't open %s\n", DEV_SPX, 0,0 );
+ (void) close(server);
+ if (fds != -1)
+ (void) close(fds);
+ if (fd != -1)
+ (void) close(fd);
+ return -1;
+ }
+
+ /* make a STREAMS-pipe */
+
+ buf.databuf.maxlen = -1;
+ buf.databuf.len = -1;
+ buf.databuf.buf = NULL;
+ buf.ctlbuf.maxlen = sizeof(long);
+ buf.ctlbuf.len = sizeof(long);
+ buf.ctlbuf.buf = (caddr_t)&temp;
+ buf.offset = 0;
+ buf.fildes = fd;
+ buf.flags = 0;
+
+ if (ioctl(fds, I_FDINSERT, &buf) < 0 ||
+ ioctl(server, I_SENDFD, fds) < 0) {
+ PRMSG(1,"ISCOpenClient: ioctl(I_FDINSERT or I_SENDFD) failed\n",
+ 0,0,0 );
+ (void) close(server);
+ (void) close(fds);
+ (void) close(fd);
+ return -1;
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+ {
+ PRMSG(1,"ISCOpenClient: failed to fill in addr info\n", 0, 0, 0);
+ close(fd);
+ return -1;
+ }
+
+ return (fd);
+
+#endif /* !ISCDEVNODENAME */
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(ISCOpenServer)(XtransConnInfo ciptr, char *port)
+
+{
+#ifdef ISCDEVNODENAME
+ int fd = -1,fds = -1;
+ char server_path[64],server_unix_path[64];
+ unsigned int mode = 0;
+#endif
+
+ PRMSG(2,"ISCOpenServer(%s)\n", port, 0,0 );
+
+#if !defined(ISCDEVNODENAME)
+ PRMSG(1,"ISCOpenServer: Protocol is not supported by a ISC connection\n", 0,0,0);
+ return -1;
+#else
+ (void) sprintf(server_path, ISCDEVNODENAME, port);
+ (void) sprintf(server_unix_path, ISCTMPNODENAME, port);
+
+#ifdef HAS_STICKY_DIR_BIT
+ mode = 01777;
+#else
+ mode = 0777;
+#endif
+
+ /* "/dev/X" */
+ if (trans_mkdir(X_STREAMS_DIR, mode) == -1) {
+ PRMSG (1, "ISCOpenServer: mkdir(%s) failed, errno = %d\n",
+ X_STREAMS_DIR, errno, 0);
+ return(-1);
+ }
+ /* "/dev/X/ISCCONN" */
+ if (trans_mkdir(X_ISC_DIR, mode) == -1) {
+ PRMSG (1, "ISCOpenServer: mkdir(%s) failed, errno = %d\n",
+ X_ISC_DIR, errno, 0);
+ return(-1);
+ }
+
+ unlink(server_path);
+
+ if( ((fds=open(DEV_SPX, O_RDWR)) < 0) ||
+ ((fd =open(DEV_SPX, O_RDWR)) < 0)) {
+ PRMSG(1,"ISCOpenServer: failed to open %s\n", DEV_SPX, 0,0 );
+ return -1;
+ }
+
+ if( (connect_spipe(fds, fd) < 0) ||
+ (named_spipe(fds, server_path) < 0)) {
+ PRMSG(1,"ISCOpenServer: failed connect pipes\n", 0,0,0 );
+ close(fd);
+ close(fds);
+ return -1;
+ }
+
+#if !defined(UNIXCONN)
+ /*
+ * If the UNIX Domain socket transport is not being used, then link this
+ * device to the path /tmp/.X11-unix/X path.
+ */
+#define X_UNIX_DIR "/tmp/.X11-unix"
+
+ if (trans_mkdir(X_UNIX_DIR, mode) == -1) {
+ PRMSG (1, "ISCOpenServer: mkdir(%s) failed, errno = %d\n",
+ X_UNIX_DIR, errno, 0);
+ return(-1);
+ }
+
+ unlink(server_unix_path);
+
+#ifdef SVR4
+ /* we prefer symbolic links because hard links can't cross file systems */
+ if( symlink(server_path, server_unix_path) < 0 )
+ PRMSG(1,"ISCOpenServer: failed to link %s to %s\n",
+ server_path, server_unix_path, 0 );
+ /*
+ * Don't make this failure fatal since the listener
+ * is already established, and this just for compatability
+ */
+#else
+#ifdef ISC40
+ /* catch SIGSYS on symlink for ISC40 compiled binaries running on ISC30 */
+ signal(SIGSYS,_dummy);
+#endif
+ if( link(server_path, server_unix_path) < 0 )
+#ifdef ISC40
+ if( symlink(server_path, server_unix_path) < 0 )
+#endif
+ PRMSG(1,"ISCOpenServer: failed to link %s to %s\n",
+ server_path, server_unix_path, 0 );
+ /*
+ * Don't make this failure fatal since the listener
+ * is already established, and this just for compatability
+ */
+#endif /* SVR4 */
+#endif /* !UNIXCONN */
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+ {
+ PRMSG(1,"ISCOpenServer: failed to fill in addr info\n", 0, 0, 0);
+ close(fd);
+ return -1;
+ }
+
+ return fd;
+
+#endif /* !ISCDEVNODENAME */
+}
+
+static int
+TRANS(ISCAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
+
+{
+ struct strrecvfd str;
+
+ PRMSG(2,"ISCAccept(%d)\n", ciptr->fd, 0,0 );
+
+ while (ioctl(ciptr->fd, I_RECVFD, &str) < 0) {
+ if (errno != EAGAIN) {
+ PRMSG(1,"ISCAccept: Can't read fildes", 0,0,0 );
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return(-1);
+ }
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ newciptr->addrlen=ciptr->addrlen;
+ if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) {
+ PRMSG(1,
+ "ISCAccept: failed to allocate memory for peer addr\n",
+ 0,0,0);
+ close(str.fd);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return -1;
+ }
+
+ memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);
+
+ newciptr->peeraddrlen=newciptr->addrlen;
+ if( (newciptr->peeraddr=(char *)xalloc(newciptr->peeraddrlen)) == NULL ) {
+ PRMSG(1,
+ "ISCAccept: failed to allocate memory for peer addr\n",
+ 0,0,0);
+ xfree(newciptr->addr);
+ close(str.fd);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return -1;
+ }
+
+ memcpy(newciptr->peeraddr,newciptr->addr,newciptr->peeraddrlen);
+
+ *status = 0;
+
+ return(str.fd);
+}
+
+#endif /* TRANS_SERVER */
+#endif /* !__SCO__ && !__UNIXWARE__ */
+
+
+/* SCO */
+
+/*
+ * 2002-11-09 (jkj@sco.com)
+ *
+ * This code has been modified to match what is in the actual SCO X server.
+ * This greatly helps inter-operability between X11R6 and X11R5 (the native
+ * SCO server). Mainly, it relies on streams nodes existing in /dev, not
+ * creating them or unlinking them, which breaks the native X server.
+ *
+ * However, this is only for the X protocol. For all other protocols, we
+ * do in fact create the nodes, as only X11R6 will use them, and this makes
+ * it possible to have both types of clients running, otherwise we get all
+ * kinds of nasty errors on startup for anything that doesnt use the X
+ * protocol (like SM, when KDE starts up).
+ */
+
+#ifdef TRANS_CLIENT
+
+static int
+TRANS(SCOOpenClient)(XtransConnInfo ciptr, char *port)
+{
+#ifdef SCORNODENAME
+ int fd, server, fl, ret;
+ char server_path[64];
+ struct strbuf ctlbuf;
+ unsigned long alarm_time;
+ void (*savef)();
+ long temp;
+ extern int getmsg(), putmsg();
+#endif
+
+ PRMSG(2,"SCOOpenClient(%s)\n", port, 0,0 );
+ if (!port || !port[0])
+ port = "0";
+
+#if !defined(SCORNODENAME)
+ PRMSG(2,"SCOOpenClient: Protocol is not supported by a SCO connection\n", 0,0,0);
+ return -1;
+#else
+ (void) sprintf(server_path, SCORNODENAME, port);
+
+ if ((server = open(server_path, O_RDWR)) < 0) {
+ PRMSG(1,"SCOOpenClient: failed to open %s\n", server_path, 0,0 );
+ return -1;
+ }
+
+ if ((fd = open(DEV_SPX, O_RDWR)) < 0) {
+ PRMSG(1,"SCOOpenClient: failed to open %s\n", DEV_SPX, 0,0 );
+ close(server);
+ return -1;
+ }
+
+ (void) write(server, &server, 1);
+ ctlbuf.len = 0;
+ ctlbuf.maxlen = sizeof(long);
+ ctlbuf.buf = (caddr_t)&temp;
+ fl = 0;
+
+ savef = signal(SIGALRM, _dummy);
+ alarm_time = alarm(10);
+
+ ret = getmsg(server, &ctlbuf, 0, &fl);
+
+ (void) alarm(alarm_time);
+ (void) signal(SIGALRM, savef);
+
+ if (ret < 0) {
+ PRMSG(1,"SCOOpenClient: error from getmsg\n", 0,0,0 );
+ close(fd);
+ close(server);
+ return -1;
+ }
+
+ /* The msg we got via getmsg is the result of an
+ * I_FDINSERT, so if we do a putmsg with whatever
+ * we recieved, we're doing another I_FDINSERT ...
+ */
+ (void) putmsg(fd, &ctlbuf, 0, 0);
+ (void) fcntl(fd,F_SETFL,fcntl(fd,F_GETFL,0)|O_NDELAY);
+
+ (void) close(server);
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+#if defined(X11_t) && defined(__SCO__)
+ ciptr->flags |= TRANS_NOUNLINK;
+#endif
+ if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+ {
+ PRMSG(1,"SCOOpenClient: failed to fill addr info\n", 0, 0, 0);
+ close(fd);
+ return -1;
+ }
+
+ return(fd);
+
+#endif /* !SCORNODENAME */
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(SCOOpenServer)(XtransConnInfo ciptr, char *port)
+{
+#ifdef SCORNODENAME
+ char serverR_path[64];
+ char serverS_path[64];
+ struct flock mylock;
+ int fdr = -1;
+ int fds = -1;
+#endif
+
+ PRMSG(2,"SCOOpenServer(%s)\n", port, 0,0 );
+ if (!port || !port[0])
+ port = "0";
+
+#if !defined(SCORNODENAME)
+ PRMSG(1,"SCOOpenServer: Protocol is not supported by a SCO connection\n", 0,0,0);
+ return -1;
+#else
+ (void) sprintf(serverR_path, SCORNODENAME, port);
+ (void) sprintf(serverS_path, SCOSNODENAME, port);
+
+#if !defined(X11_t) || !defined(__SCO__)
+ unlink(serverR_path);
+ unlink(serverS_path);
+
+ if ((fds = open(DEV_SPX, O_RDWR)) < 0 ||
+ (fdr = open(DEV_SPX, O_RDWR)) < 0 ) {
+ PRMSG(1,"SCOOpenServer: failed to open %s\n", DEV_SPX, 0,0 );
+ return -1;
+ }
+
+ if (named_spipe (fds, serverS_path) == -1) {
+ PRMSG(1,"SCOOpenServer: failed to create %s\n", serverS_path, 0, 0);
+ close (fdr);
+ close (fds);
+ return -1;
+ }
+
+ if (named_spipe (fdr, serverR_path) == -1) {
+ PRMSG(1,"SCOOpenServer: failed to create %s\n", serverR_path, 0, 0);
+ close (fdr);
+ close (fds);
+ return -1;
+ }
+#else /* X11_t */
+
+ fds = open (serverS_path, O_RDWR | O_NDELAY);
+ if (fds < 0) {
+ PRMSG(1,"SCOOpenServer: failed to open %s\n", serverS_path, 0, 0);
+ return -1;
+ }
+
+ /*
+ * Lock the connection device for the duration of the server.
+ * This resolves multiple server starts especially on SMP machines.
+ */
+ mylock.l_type = F_WRLCK;
+ mylock.l_whence = 0;
+ mylock.l_start = 0;
+ mylock.l_len = 0;
+ if (fcntl (fds, F_SETLK, &mylock) < 0) {
+ PRMSG(1,"SCOOpenServer: failed to lock %s\n", serverS_path, 0, 0);
+ close (fds);
+ return -1;
+ }
+
+ fdr = open (serverR_path, O_RDWR | O_NDELAY);
+ if (fds < 0) {
+ PRMSG(1,"SCOOpenServer: failed to open %s\n", serverR_path, 0, 0);
+ close (fds);
+ return -1;
+ }
+#endif /* X11_t */
+
+ if (connect_spipe(fds, fdr)) {
+ PRMSG(1,"SCOOpenServer: ioctl(I_FDINSERT) failed on %s\n",
+ serverS_path, 0, 0);
+ close (fdr);
+ close (fds);
+ return -1;
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+#if defined(X11_t) && defined(__SCO__)
+ ciptr->flags |= TRANS_NOUNLINK;
+#endif
+ if (TRANS(FillAddrInfo) (ciptr, serverS_path, serverR_path) == 0) {
+ PRMSG(1,"SCOOpenServer: failed to fill in addr info\n", 0,0,0);
+ close(fds);
+ close(fdr);
+ return -1;
+ }
+
+ return(fds);
+
+#endif /* !SCORNODENAME */
+}
+
+static int
+TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
+{
+ char c;
+ int fd;
+
+ PRMSG(2,"SCOAccept(%d)\n", ciptr->fd, 0,0 );
+
+ if (read(ciptr->fd, &c, 1) < 0) {
+ PRMSG(1,"SCOAccept: can't read from client\n",0,0,0);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return(-1);
+ }
+
+ if( (fd = open(DEV_SPX, O_RDWR)) < 0 ) {
+ PRMSG(1,"SCOAccept: can't open \"%s\"\n",DEV_SPX, 0,0 );
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return(-1);
+ }
+
+ if (connect_spipe (ciptr->fd, fd) < 0) {
+ PRMSG(1,"SCOAccept: ioctl(I_FDINSERT) failed\n", 0, 0, 0);
+ close (fd);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return -1;
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ newciptr->addrlen=ciptr->addrlen;
+ if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) {
+ PRMSG(1,
+ "SCOAccept: failed to allocate memory for peer addr\n",
+ 0,0,0);
+ close(fd);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return -1;
+ }
+
+ memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);
+#if defined(__SCO__)
+ newciptr->flags |= TRANS_NOUNLINK;
+#endif
+
+ newciptr->peeraddrlen=newciptr->addrlen;
+ if( (newciptr->peeraddr=(char *)xalloc(newciptr->peeraddrlen)) == NULL ) {
+ PRMSG(1,
+ "SCOAccept: failed to allocate memory for peer addr\n",
+ 0,0,0);
+ xfree(newciptr->addr);
+ close(fd);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return -1;
+ }
+
+ memcpy(newciptr->peeraddr,newciptr->addr,newciptr->peeraddrlen);
+
+ *status = 0;
+
+ return(fd);
+}
+
+#endif /* TRANS_SERVER */
+#endif /* sun */
+
+
+
+#ifdef TRANS_REOPEN
+#ifndef sun
+
+static int
+TRANS(PTSReopenServer)(XtransConnInfo ciptr, int fd, char *port)
+
+{
+#ifdef PTSNODENAME
+ char server_path[64];
+#endif
+
+ PRMSG(2,"PTSReopenServer(%d,%s)\n", fd, port, 0 );
+
+#if !defined(PTSNODENAME)
+ PRMSG(1,"PTSReopenServer: Protocol is not supported by a pts connection\n", 0,0,0);
+ return 0;
+#else
+ if (port && *port ) {
+ if( *port == '/' ) { /* A full pathname */
+ (void) sprintf(server_path, "%s", port);
+ } else {
+ (void) sprintf(server_path, "%s%s", PTSNODENAME, port);
+ }
+ } else {
+ (void) sprintf(server_path, "%s%ld", PTSNODENAME, (long)getpid());
+ }
+
+ if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+ {
+ PRMSG(1,"PTSReopenServer: failed to fill in addr info\n",
+ 0,0,0);
+ return 0;
+ }
+
+ return 1;
+
+#endif /* !PTSNODENAME */
+}
+
+#endif /* !sun */
+
+static int
+TRANS(NAMEDReopenServer)(XtransConnInfo ciptr, int fd, char *port)
+
+{
+#ifdef NAMEDNODENAME
+ char server_path[64];
+#endif
+
+ PRMSG(2,"NAMEDReopenServer(%s)\n", port, 0,0 );
+
+#if !defined(NAMEDNODENAME)
+ PRMSG(1,"NAMEDReopenServer: Protocol is not supported by a NAMED connection\n", 0,0,0);
+ return 0;
+#else
+ if ( port && *port ) {
+ if( *port == '/' ) { /* A full pathname */
+ (void) sprintf(server_path, "%s", port);
+ } else {
+ (void) sprintf(server_path, "%s%s", NAMEDNODENAME, port);
+ }
+ } else {
+ (void) sprintf(server_path, "%s%ld", NAMEDNODENAME, (long)getpid());
+ }
+
+ if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+ {
+ PRMSG(1,"NAMEDReopenServer: failed to fill in addr info\n",
+ 0,0,0);
+ return 0;
+ }
+
+ return 1;
+
+#endif /* !NAMEDNODENAME */
+}
+
+#ifndef sun
+#if !defined(__SCO__) && !defined(__UNIXWARE__)
+static int
+TRANS(ISCReopenServer)(XtransConnInfo ciptr, int fd, char *port)
+
+{
+#ifdef ISCDEVNODENAME
+ char server_path[64], server_unix_path[64];
+#endif
+
+ PRMSG(2,"ISCReopenServer(%s)\n", port, 0,0 );
+
+#if !defined(ISCDEVNODENAME)
+ PRMSG(1,"ISCReopenServer: Protocol is not supported by a ISC connection\n", 0,0,0);
+ return 0;
+#else
+ (void) sprintf(server_path, ISCDEVNODENAME, port);
+ (void) sprintf(server_unix_path, ISCTMPNODENAME, port);
+
+ if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+ {
+ PRMSG(1, "ISCReopenServer: failed to fill in addr info\n", 0,0,0);
+ return 0;
+ }
+
+ return 1;
+
+#endif /* !ISCDEVNODENAME */
+}
+#endif /* !__SCO__ && !__UNIXWARE__ */
+
+static int
+TRANS(SCOReopenServer)(XtransConnInfo ciptr, int fd, char *port)
+
+{
+#ifdef SCORNODENAME
+ char serverR_path[64], serverS_path[64];
+#endif
+
+ PRMSG(2,"SCOReopenServer(%s)\n", port, 0,0 );
+ if (!port || !port[0])
+ port = "0";
+
+#if !defined(SCORNODENAME)
+ PRMSG(2,"SCOReopenServer: Protocol is not supported by a SCO connection\n", 0,0,0);
+ return 0;
+#else
+ (void) sprintf(serverR_path, SCORNODENAME, port);
+ (void) sprintf(serverS_path, SCOSNODENAME, port);
+
+#if defined(X11_t) && defined(__SCO__)
+ ciptr->flags |= TRANS_NOUNLINK;
+#endif
+ if (TRANS(FillAddrInfo) (ciptr, serverS_path, serverR_path) == 0)
+ {
+ PRMSG(1, "SCOReopenServer: failed to fill in addr info\n", 0,0,0);
+ return 0;
+ }
+
+ return 1;
+
+#endif /* SCORNODENAME */
+}
+
+#endif /* !sun */
+
+#endif /* TRANS_REOPEN */
+
+
+
+/*
+ * This table contains all of the entry points for the different local
+ * connection mechanisms.
+ */
+
+typedef struct _LOCALtrans2dev {
+ char *transname;
+
+#ifdef TRANS_CLIENT
+
+ int (*devcotsopenclient)(
+ XtransConnInfo, char * /*port*/
+);
+
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_SERVER
+
+ int (*devcotsopenserver)(
+ XtransConnInfo, char * /*port*/
+);
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+
+ int (*devcltsopenclient)(
+ XtransConnInfo, char * /*port*/
+);
+
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_SERVER
+
+ int (*devcltsopenserver)(
+ XtransConnInfo, char * /*port*/
+);
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_REOPEN
+
+ int (*devcotsreopenserver)(
+ XtransConnInfo,
+ int, /* fd */
+ char * /* port */
+);
+
+ int (*devcltsreopenserver)(
+ XtransConnInfo,
+ int, /* fd */
+ char * /* port */
+);
+
+#endif /* TRANS_REOPEN */
+
+#ifdef TRANS_SERVER
+
+ int (*devaccept)(
+ XtransConnInfo, XtransConnInfo, int *
+);
+
+#endif /* TRANS_SERVER */
+
+} LOCALtrans2dev;
+
+static LOCALtrans2dev LOCALtrans2devtab[] = {
+#ifndef sun
+{"",
+#ifdef TRANS_CLIENT
+ TRANS(PTSOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(PTSOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(PTSReopenServer),
+ TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+ TRANS(PTSAccept)
+#endif /* TRANS_SERVER */
+},
+
+{"local",
+#ifdef TRANS_CLIENT
+ TRANS(PTSOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(PTSOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(PTSReopenServer),
+ TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+ TRANS(PTSAccept)
+#endif /* TRANS_SERVER */
+},
+
+{"pts",
+#ifdef TRANS_CLIENT
+ TRANS(PTSOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(PTSOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(PTSReopenServer),
+ TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+ TRANS(PTSAccept)
+#endif /* TRANS_SERVER */
+},
+#else /* sun */
+{"",
+#ifdef TRANS_CLIENT
+ TRANS(NAMEDOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(NAMEDOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(NAMEDReopenServer),
+ TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+ TRANS(NAMEDAccept)
+#endif /* TRANS_SERVER */
+},
+
+{"local",
+#ifdef TRANS_CLIENT
+ TRANS(NAMEDOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(NAMEDOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(NAMEDReopenServer),
+ TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+ TRANS(NAMEDAccept)
+#endif /* TRANS_SERVER */
+},
+#endif /* sun */
+
+#ifdef SVR4
+{"named",
+#ifdef TRANS_CLIENT
+ TRANS(NAMEDOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(NAMEDOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(NAMEDReopenServer),
+ TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+ TRANS(NAMEDAccept)
+#endif /* TRANS_SERVER */
+},
+#endif /* SVR4 */
+
+#ifndef sun
+#if !defined(__SCO__) && !defined(__UNIXWARE__)
+{"isc",
+#ifdef TRANS_CLIENT
+ TRANS(ISCOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(ISCOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(ISCReopenServer),
+ TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+ TRANS(ISCAccept)
+#endif /* TRANS_SERVER */
+},
+#endif /* !__SCO__ && !__UNIXWARE__ */
+
+{"sco",
+#ifdef TRANS_CLIENT
+ TRANS(SCOOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SCOOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SCOReopenServer),
+ TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+ TRANS(SCOAccept)
+#endif /* TRANS_SERVER */
+},
+#endif /* sun */
+};
+
+#define NUMTRANSPORTS (sizeof(LOCALtrans2devtab)/sizeof(LOCALtrans2dev))
+
+static char *XLOCAL=NULL;
+static char *workingXLOCAL=NULL;
+static char *freeXLOCAL=NULL;
+
+#if defined(__SCO__)
+#define DEF_XLOCAL "SCO:UNIX:PTS"
+#elif defined(__UNIXWARE__)
+#define DEF_XLOCAL "UNIX:PTS:NAMED:SCO"
+#else
+#define DEF_XLOCAL "UNIX:PTS:NAMED:ISC:SCO"
+#endif
+
+static void
+TRANS(LocalInitTransports)(char *protocol)
+
+{
+ PRMSG(3,"LocalInitTransports(%s)\n", protocol, 0,0 );
+
+ if( strcmp(protocol,"local") && strcmp(protocol,"LOCAL") )
+ {
+ workingXLOCAL=freeXLOCAL=(char *)xalloc (strlen (protocol) + 1);
+ if (workingXLOCAL)
+ strcpy (workingXLOCAL, protocol);
+ }
+ else {
+ XLOCAL=(char *)getenv("XLOCAL");
+ if(XLOCAL==NULL)
+ XLOCAL=DEF_XLOCAL;
+ workingXLOCAL=freeXLOCAL=(char *)xalloc (strlen (XLOCAL) + 1);
+ if (workingXLOCAL)
+ strcpy (workingXLOCAL, XLOCAL);
+ }
+}
+
+static void
+TRANS(LocalEndTransports)(void)
+
+{
+ PRMSG(3,"LocalEndTransports()\n", 0,0,0 );
+ xfree(freeXLOCAL);
+}
+
+#define TYPEBUFSIZE 32
+
+#ifdef TRANS_CLIENT
+
+static LOCALtrans2dev *
+TRANS(LocalGetNextTransport)(void)
+
+{
+ int i,j;
+ char *typetocheck;
+ char typebuf[TYPEBUFSIZE];
+ PRMSG(3,"LocalGetNextTransport()\n", 0,0,0 );
+
+ while(1)
+ {
+ if( workingXLOCAL == NULL || *workingXLOCAL == '\0' )
+ return NULL;
+
+ typetocheck=workingXLOCAL;
+ workingXLOCAL=strchr(workingXLOCAL,':');
+ if(workingXLOCAL && *workingXLOCAL)
+ *workingXLOCAL++='\0';
+
+ for(i=0;i<NUMTRANSPORTS;i++)
+ {
+ /*
+ * This is equivilent to a case insensitive strcmp(),
+ * but should be more portable.
+ */
+ strncpy(typebuf,typetocheck,TYPEBUFSIZE);
+ for(j=0;j<TYPEBUFSIZE;j++)
+ if (isupper(typebuf[j]))
+ typebuf[j]=tolower(typebuf[j]);
+
+ /* Now, see if they match */
+ if(!strcmp(LOCALtrans2devtab[i].transname,typebuf))
+ return &LOCALtrans2devtab[i];
+ }
+ }
+#if 0
+ /*NOTREACHED*/
+ return NULL;
+#endif
+}
+
+#ifdef NEED_UTSNAME
+#include <sys/utsname.h>
+#endif
+
+/*
+ * Make sure 'host' is really local.
+ */
+
+static int
+HostReallyLocal (char *host)
+
+{
+ /*
+ * The 'host' passed to this function may have been generated
+ * by either uname() or gethostname(). We try both if possible.
+ */
+
+#ifdef NEED_UTSNAME
+ struct utsname name;
+#endif
+ char buf[256];
+
+#ifdef NEED_UTSNAME
+ if (uname (&name) >= 0 && strcmp (host, name.nodename) == 0)
+ return (1);
+#endif
+
+ buf[0] = '\0';
+ (void) gethostname (buf, 256);
+ buf[255] = '\0';
+
+ if (strcmp (host, buf) == 0)
+ return (1);
+
+ return (0);
+}
+
+
+static XtransConnInfo
+TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port)
+
+{
+ LOCALtrans2dev *transptr;
+ XtransConnInfo ciptr;
+ int index;
+
+ PRMSG(3,"LocalOpenClient()\n", 0,0,0 );
+
+ /*
+ * Make sure 'host' is really local. If not, we return failure.
+ * The reason we make this check is because a process may advertise
+ * a "local" address for which it can accept connections, but if a
+ * process on a remote machine tries to connect to this address,
+ * we know for sure it will fail.
+ */
+
+ if (strcmp (host, "unix") != 0 && !HostReallyLocal (host))
+ {
+ PRMSG (1,
+ "LocalOpenClient: Cannot connect to non-local host %s\n",
+ host, 0, 0);
+ return NULL;
+ }
+
+
+#if defined(X11_t)
+ /*
+ * X has a well known port, that is transport dependant. It is easier
+ * to handle it here, than try and come up with a transport independent
+ * representation that can be passed in and resolved the usual way.
+ *
+ * The port that is passed here is really a string containing the idisplay
+ * from ConnectDisplay(). Since that is what we want for the local transports,
+ * we don't have to do anything special.
+ */
+#endif /* X11_t */
+
+ if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ {
+ PRMSG(1,"LocalOpenClient: calloc(1,%d) failed\n",
+ sizeof(struct _XtransConnInfo),0,0 );
+ return NULL;
+ }
+
+ ciptr->fd = -1;
+
+ TRANS(LocalInitTransports)(protocol);
+
+ index = 0;
+ for(transptr=TRANS(LocalGetNextTransport)();
+ transptr!=NULL;transptr=TRANS(LocalGetNextTransport)(), index++)
+ {
+ switch( type )
+ {
+ case XTRANS_OPEN_COTS_CLIENT:
+ ciptr->fd=transptr->devcotsopenclient(ciptr,port);
+ break;
+ case XTRANS_OPEN_CLTS_CLIENT:
+ ciptr->fd=transptr->devcltsopenclient(ciptr,port);
+ break;
+ case XTRANS_OPEN_COTS_SERVER:
+ case XTRANS_OPEN_CLTS_SERVER:
+ PRMSG(1,
+ "LocalOpenClient: Should not be opening a server with this function\n",
+ 0,0,0);
+ break;
+ default:
+ PRMSG(1,
+ "LocalOpenClient: Unknown Open type %d\n",
+ type, 0,0 );
+ }
+ if( ciptr->fd >= 0 )
+ break;
+ }
+
+ TRANS(LocalEndTransports)();
+
+ if( ciptr->fd < 0 )
+ {
+ xfree(ciptr);
+ return NULL;
+ }
+
+ ciptr->priv=(char *)transptr;
+ ciptr->index = index;
+
+ return ciptr;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(LocalOpenServer)(int type, char *protocol, char *host, char *port)
+
+{
+ int i;
+ XtransConnInfo ciptr;
+
+ PRMSG(2,"LocalOpenServer(%d,%s,%s)\n", type, protocol, port);
+
+#if defined(X11_t)
+ /*
+ * For X11, the port will be in the format xserverN where N is the
+ * display number. All of the local connections just need to know
+ * the display number because they don't do any name resolution on
+ * the port. This just truncates port to the display portion.
+ */
+#endif /* X11_t */
+
+ if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ {
+ PRMSG(1,"LocalOpenServer: calloc(1,%d) failed\n",
+ sizeof(struct _XtransConnInfo),0,0 );
+ return NULL;
+ }
+
+ for(i=1;i<NUMTRANSPORTS;i++)
+ {
+ if( strcmp(protocol,LOCALtrans2devtab[i].transname) != 0 )
+ continue;
+ switch( type )
+ {
+ case XTRANS_OPEN_COTS_CLIENT:
+ case XTRANS_OPEN_CLTS_CLIENT:
+ PRMSG(1,
+ "LocalOpenServer: Should not be opening a client with this function\n",
+ 0,0,0);
+ break;
+ case XTRANS_OPEN_COTS_SERVER:
+ ciptr->fd=LOCALtrans2devtab[i].devcotsopenserver(ciptr,port);
+ break;
+ case XTRANS_OPEN_CLTS_SERVER:
+ ciptr->fd=LOCALtrans2devtab[i].devcltsopenserver(ciptr,port);
+ break;
+ default:
+ PRMSG(1,"LocalOpenServer: Unknown Open type %d\n",
+ type ,0,0);
+ }
+ if( ciptr->fd >= 0 ) {
+ ciptr->priv=(char *)&LOCALtrans2devtab[i];
+ ciptr->index=i;
+ ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS);
+ return ciptr;
+ }
+ }
+
+ xfree(ciptr);
+ return NULL;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(LocalReopenServer)(int type, int index, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int stat = 0;
+
+ PRMSG(2,"LocalReopenServer(%d,%d,%d)\n", type, index, fd);
+
+ if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ {
+ PRMSG(1,"LocalReopenServer: calloc(1,%d) failed\n",
+ sizeof(struct _XtransConnInfo),0,0 );
+ return NULL;
+ }
+
+ ciptr->fd = fd;
+
+ switch( type )
+ {
+ case XTRANS_OPEN_COTS_SERVER:
+ stat = LOCALtrans2devtab[index].devcotsreopenserver(ciptr,fd,port);
+ break;
+ case XTRANS_OPEN_CLTS_SERVER:
+ stat = LOCALtrans2devtab[index].devcltsreopenserver(ciptr,fd,port);
+ break;
+ default:
+ PRMSG(1,"LocalReopenServer: Unknown Open type %d\n",
+ type ,0,0);
+ }
+
+ if( stat > 0 ) {
+ ciptr->priv=(char *)&LOCALtrans2devtab[index];
+ ciptr->index=index;
+ ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS);
+ return ciptr;
+ }
+
+ xfree(ciptr);
+ return NULL;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+
+/*
+ * This is the Local implementation of the X Transport service layer
+ */
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(LocalOpenCOTSClient)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ PRMSG(2,"LocalOpenCOTSClient(%s,%s,%s)\n",protocol,host,port);
+
+ return TRANS(LocalOpenClient)(XTRANS_OPEN_COTS_CLIENT, protocol, host, port);
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(LocalOpenCOTSServer)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ char *typetocheck = NULL;
+ int found = 0;
+ char typebuf[TYPEBUFSIZE];
+
+ PRMSG(2,"LocalOpenCOTSServer(%s,%s,%s)\n",protocol,host,port);
+
+ /* Check if this local type is in the XLOCAL list */
+ TRANS(LocalInitTransports)("local");
+ typetocheck = workingXLOCAL;
+ while (typetocheck && !found) {
+ int j;
+
+ workingXLOCAL = strchr(workingXLOCAL, ':');
+ if (workingXLOCAL && *workingXLOCAL)
+ *workingXLOCAL++ = '\0';
+ strncpy(typebuf, typetocheck, TYPEBUFSIZE);
+ for (j = 0; j < TYPEBUFSIZE; j++)
+ if (isupper(typebuf[j]))
+ typebuf[j] = tolower(typebuf[j]);
+ if (!strcmp(thistrans->TransName, typebuf))
+ found = 1;
+ typetocheck = workingXLOCAL;
+ }
+ TRANS(LocalEndTransports)();
+
+ if (!found) {
+ PRMSG(3,"LocalOpenCOTSServer: disabling %s\n",thistrans->TransName,0,0);
+ thistrans->flags |= TRANS_DISABLED;
+ return NULL;
+ }
+
+ return TRANS(LocalOpenServer)(XTRANS_OPEN_COTS_SERVER, protocol, host, port);
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(LocalOpenCLTSClient)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ PRMSG(2,"LocalOpenCLTSClient(%s,%s,%s)\n",protocol,host,port);
+
+ return TRANS(LocalOpenClient)(XTRANS_OPEN_CLTS_CLIENT, protocol, host, port);
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(LocalOpenCLTSServer)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ PRMSG(2,"LocalOpenCLTSServer(%s,%s,%s)\n",protocol,host,port);
+
+ return TRANS(LocalOpenServer)(XTRANS_OPEN_CLTS_SERVER, protocol, host, port);
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(LocalReopenCOTSServer)(Xtransport *thistrans, int fd, char *port)
+
+{
+ int index;
+
+ PRMSG(2,"LocalReopenCOTSServer(%d,%s)\n", fd, port, 0);
+
+ for(index=1;index<NUMTRANSPORTS;index++)
+ {
+ if( strcmp(thistrans->TransName,
+ LOCALtrans2devtab[index].transname) == 0 )
+ break;
+ }
+
+ if (index >= NUMTRANSPORTS)
+ {
+ return (NULL);
+ }
+
+ return TRANS(LocalReopenServer)(XTRANS_OPEN_COTS_SERVER,
+ index, fd, port);
+}
+
+static XtransConnInfo
+TRANS(LocalReopenCLTSServer)(Xtransport *thistrans, int fd, char *port)
+
+{
+ int index;
+
+ PRMSG(2,"LocalReopenCLTSServer(%d,%s)\n", fd, port, 0);
+
+ for(index=1;index<NUMTRANSPORTS;index++)
+ {
+ if( strcmp(thistrans->TransName,
+ LOCALtrans2devtab[index].transname) == 0 )
+ break;
+ }
+
+ if (index >= NUMTRANSPORTS)
+ {
+ return (NULL);
+ }
+
+ return TRANS(LocalReopenServer)(XTRANS_OPEN_CLTS_SERVER,
+ index, fd, port);
+}
+
+#endif /* TRANS_REOPEN */
+
+
+
+static int
+TRANS(LocalSetOption)(XtransConnInfo ciptr, int option, int arg)
+
+{
+ PRMSG(2,"LocalSetOption(%d,%d,%d)\n",ciptr->fd,option,arg);
+
+ return -1;
+}
+
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(LocalCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags)
+
+{
+ PRMSG(2,"LocalCreateListener(%x->%d,%s)\n",ciptr,ciptr->fd,port);
+
+ return 0;
+}
+
+static XtransConnInfo
+TRANS(LocalAccept)(XtransConnInfo ciptr, int *status)
+
+{
+ XtransConnInfo newciptr;
+ LOCALtrans2dev *transptr;
+
+ PRMSG(2,"LocalAccept(%x->%d)\n", ciptr, ciptr->fd,0);
+
+ transptr=(LOCALtrans2dev *)ciptr->priv;
+
+ if( (newciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo)))==NULL )
+ {
+ PRMSG(1,"LocalAccept: calloc(1,%d) failed\n",
+ sizeof(struct _XtransConnInfo),0,0 );
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+ newciptr->fd=transptr->devaccept(ciptr,newciptr,status);
+
+ if( newciptr->fd < 0 )
+ {
+ xfree(newciptr);
+ return NULL;
+ }
+
+ newciptr->priv=(char *)transptr;
+ newciptr->index = ciptr->index;
+
+ *status = 0;
+
+ return newciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+static int
+TRANS(LocalConnect)(XtransConnInfo ciptr, char *host, char *port)
+
+{
+ PRMSG(2,"LocalConnect(%x->%d,%s)\n", ciptr, ciptr->fd, port);
+
+ return 0;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+static int
+TRANS(LocalBytesReadable)(XtransConnInfo ciptr, BytesReadable_t *pend )
+
+{
+ PRMSG(2,"LocalBytesReadable(%x->%d,%x)\n", ciptr, ciptr->fd, pend);
+
+#if defined(ISC) || defined(SCO325)
+ return ioctl(ciptr->fd, I_NREAD, (char *)pend);
+#else
+ return ioctl(ciptr->fd, FIONREAD, (char *)pend);
+#endif
+}
+
+static int
+TRANS(LocalRead)(XtransConnInfo ciptr, char *buf, int size)
+
+{
+ PRMSG(2,"LocalRead(%d,%x,%d)\n", ciptr->fd, buf, size );
+
+ return read(ciptr->fd,buf,size);
+}
+
+static int
+TRANS(LocalWrite)(XtransConnInfo ciptr, char *buf, int size)
+
+{
+ PRMSG(2,"LocalWrite(%d,%x,%d)\n", ciptr->fd, buf, size );
+
+ return write(ciptr->fd,buf,size);
+}
+
+static int
+TRANS(LocalReadv)(XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ PRMSG(2,"LocalReadv(%d,%x,%d)\n", ciptr->fd, buf, size );
+
+ return READV(ciptr,buf,size);
+}
+
+static int
+TRANS(LocalWritev)(XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ PRMSG(2,"LocalWritev(%d,%x,%d)\n", ciptr->fd, buf, size );
+
+ return WRITEV(ciptr,buf,size);
+}
+
+static int
+TRANS(LocalDisconnect)(XtransConnInfo ciptr)
+
+{
+ PRMSG(2,"LocalDisconnect(%x->%d)\n", ciptr, ciptr->fd, 0);
+
+ return 0;
+}
+
+static int
+TRANS(LocalClose)(XtransConnInfo ciptr)
+
+{
+ struct sockaddr_un *sockname=(struct sockaddr_un *) ciptr->addr;
+ int ret;
+
+ PRMSG(2,"LocalClose(%x->%d)\n", ciptr, ciptr->fd ,0);
+
+ ret=close(ciptr->fd);
+
+ if(ciptr->flags
+ && sockname
+ && sockname->sun_family == AF_UNIX
+ && sockname->sun_path[0] )
+ {
+ if (!(ciptr->flags & TRANS_NOUNLINK))
+ unlink(sockname->sun_path);
+ }
+
+ return ret;
+}
+
+static int
+TRANS(LocalCloseForCloning)(XtransConnInfo ciptr)
+
+{
+ int ret;
+
+ PRMSG(2,"LocalCloseForCloning(%x->%d)\n", ciptr, ciptr->fd ,0);
+
+ /* Don't unlink path */
+
+ ret=close(ciptr->fd);
+
+ return ret;
+}
+
+
+/*
+ * MakeAllCOTSServerListeners() will go through the entire Xtransports[]
+ * array defined in Xtrans.c and try to OpenCOTSServer() for each entry.
+ * We will add duplicate entries to that table so that the OpenCOTSServer()
+ * function will get called once for each type of local transport.
+ *
+ * The TransName is in lowercase, so it will never match during a normal
+ * call to SelectTransport() in Xtrans.c.
+ */
+
+#ifdef TRANS_SERVER
+static char * local_aliases[] = {
+# ifndef sun
+ "pts",
+# endif
+ "named",
+# ifndef sun
+# if !defined(__SCO__) && !defined(__UNIXWARE__)
+ "isc",
+# endif
+ "sco",
+# endif
+ NULL };
+#endif
+
+Xtransport TRANS(LocalFuncs) = {
+ /* Local Interface */
+ "local",
+ TRANS_ALIAS | TRANS_LOCAL,
+#ifdef TRANS_CLIENT
+ TRANS(LocalOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ local_aliases,
+ TRANS(LocalOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(LocalOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(LocalOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(LocalReopenCOTSServer),
+ TRANS(LocalReopenCLTSServer),
+#endif
+ TRANS(LocalSetOption),
+#ifdef TRANS_SERVER
+ TRANS(LocalCreateListener),
+ NULL, /* ResetListener */
+ TRANS(LocalAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(LocalConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(LocalBytesReadable),
+ TRANS(LocalRead),
+ TRANS(LocalWrite),
+ TRANS(LocalReadv),
+ TRANS(LocalWritev),
+ TRANS(LocalDisconnect),
+ TRANS(LocalClose),
+ TRANS(LocalCloseForCloning),
+};
+
+#ifndef sun
+
+Xtransport TRANS(PTSFuncs) = {
+ /* Local Interface */
+ "pts",
+ TRANS_LOCAL,
+#ifdef TRANS_CLIENT
+ TRANS(LocalOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(LocalOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(LocalOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(LocalOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(LocalReopenCOTSServer),
+ TRANS(LocalReopenCLTSServer),
+#endif
+ TRANS(LocalSetOption),
+#ifdef TRANS_SERVER
+ TRANS(LocalCreateListener),
+ NULL, /* ResetListener */
+ TRANS(LocalAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(LocalConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(LocalBytesReadable),
+ TRANS(LocalRead),
+ TRANS(LocalWrite),
+ TRANS(LocalReadv),
+ TRANS(LocalWritev),
+ TRANS(LocalDisconnect),
+ TRANS(LocalClose),
+ TRANS(LocalCloseForCloning),
+};
+
+#endif /* sun */
+
+Xtransport TRANS(NAMEDFuncs) = {
+ /* Local Interface */
+ "named",
+ TRANS_LOCAL,
+#ifdef TRANS_CLIENT
+ TRANS(LocalOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(LocalOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(LocalOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(LocalOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(LocalReopenCOTSServer),
+ TRANS(LocalReopenCLTSServer),
+#endif
+ TRANS(LocalSetOption),
+#ifdef TRANS_SERVER
+ TRANS(LocalCreateListener),
+ NULL, /* ResetListener */
+ TRANS(LocalAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(LocalConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(LocalBytesReadable),
+ TRANS(LocalRead),
+ TRANS(LocalWrite),
+ TRANS(LocalReadv),
+ TRANS(LocalWritev),
+ TRANS(LocalDisconnect),
+ TRANS(LocalClose),
+ TRANS(LocalCloseForCloning),
+};
+
+#ifndef sun
+#if !defined(__SCO__) && !defined(__UNIXWARE__)
+Xtransport TRANS(ISCFuncs) = {
+ /* Local Interface */
+ "isc",
+ TRANS_LOCAL,
+#ifdef TRANS_CLIENT
+ TRANS(LocalOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(LocalOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(LocalOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(LocalOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(LocalReopenCOTSServer),
+ TRANS(LocalReopenCLTSServer),
+#endif
+ TRANS(LocalSetOption),
+#ifdef TRANS_SERVER
+ TRANS(LocalCreateListener),
+ NULL, /* ResetListener */
+ TRANS(LocalAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(LocalConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(LocalBytesReadable),
+ TRANS(LocalRead),
+ TRANS(LocalWrite),
+ TRANS(LocalReadv),
+ TRANS(LocalWritev),
+ TRANS(LocalDisconnect),
+ TRANS(LocalClose),
+ TRANS(LocalCloseForCloning),
+};
+#endif /* !__SCO__ && !__UNIXWARE__ */
+Xtransport TRANS(SCOFuncs) = {
+ /* Local Interface */
+ "sco",
+ TRANS_LOCAL,
+#ifdef TRANS_CLIENT
+ TRANS(LocalOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(LocalOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(LocalOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(LocalOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(LocalReopenCOTSServer),
+ TRANS(LocalReopenCLTSServer),
+#endif
+ TRANS(LocalSetOption),
+#ifdef TRANS_SERVER
+ TRANS(LocalCreateListener),
+ NULL, /* ResetListener */
+ TRANS(LocalAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(LocalConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(LocalBytesReadable),
+ TRANS(LocalRead),
+ TRANS(LocalWrite),
+ TRANS(LocalReadv),
+ TRANS(LocalWritev),
+ TRANS(LocalDisconnect),
+ TRANS(LocalClose),
+ TRANS(LocalCloseForCloning),
+};
+#endif /* sun */
diff --git a/nx-X11/lib/xtrans/Xtransos2.c b/nx-X11/lib/xtrans/Xtransos2.c
new file mode 100644
index 000000000..f4a6b036b
--- /dev/null
+++ b/nx-X11/lib/xtrans/Xtransos2.c
@@ -0,0 +1,887 @@
+/* $XFree86: xc/lib/xtrans/Xtransos2.c,v 3.9tsi Exp $ */
+
+/*
+ * (c) Copyright 1996 by Sebastien Marineau and Holger Veit
+ * <marineau@genie.uottawa.ca>
+ * <Holger.Veit@gmd.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * 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
+ * HOLGER VEIT 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 Sebastien Marineau or Holger Veit shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Holger Veit or Sebastien Marineau.
+ *
+ */
+
+/* Implementation of the OS/2 local pipe transport layer */
+
+#define INCL_DOSNMPIPES
+#define INCL_DOSPROCESS
+#define INCL_DOSERRORS
+#define INCL_DOSFILEMGR
+#undef BYTE
+#undef BOOL
+#include <os2.h>
+
+#ifdef XSERV_t
+extern HEV hPipeSem;
+BOOL init_server_pipes();
+#endif
+
+/*************************************************************************
+ * Independent Layer
+ *************************************************************************/
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(Os2OpenClient)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+{
+ APIRET rc;
+ HFILE hfd,hServer;
+ ULONG action,byteWritten,State;
+ char pipename[256],clientname[256];
+ char server_string[256];
+ struct sockaddr *addr_name;
+ unsigned char pipe_len;
+ XtransConnInfo ciptr;
+ static int unique_id=0;
+ int i,namelen,try;
+
+ PRMSG(2,"Os2OpenClient(%s,%s,%s)\n",protocol,host,port);
+
+ /* test, whether the host is really local, i.e. either
+ * "os2" or "local"
+ */
+ if (strcmp(protocol,"os2") && strcmp(protocol,"local")) {
+ PRMSG (1,
+ "Os2OpenClient: Cannot connect to non-local host %s\n",
+ host, 0, 0);
+ return NULL;
+ }
+
+ /* make the pipename */
+
+ if (port && *port ) {
+ if( *port == '/' ) { /* A full pathname */
+ (void) sprintf(pipename, "\\PIPE\\X\\%s,", port);
+ } else {
+ (void) sprintf(pipename, "%s%s", "\\PIPE\\X\\xf86.", port);
+ }
+ } else {
+ (void) sprintf(pipename, "\\PIPE\\X\\xfree86"); }
+
+ PRMSG(5, "Os2OpenClient: Creating pipe %s\n",pipename, 0,0 );
+
+ /* make a connection entry */
+ if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) {
+ PRMSG(1,"Os2OpenClient: calloc(1,%d) failed\n",
+ sizeof(struct _XtransConnInfo),0,0 );
+ return NULL;
+ }
+
+ /* open the pipe. Try ten times before giving up at 500ms intervals*/
+ try = 0;
+ do {
+ rc = DosOpen(pipename,&hServer, &action, 0,
+ FILE_NORMAL, FILE_OPEN,
+ OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYWRITE,
+ (PEAOP2)NULL);
+ if(rc == 0) break;
+ if (try >=10) {
+ PRMSG(1,"Os2OpenClient: Open server pipe %s failed, rc=%d\n",
+ pipename,rc,0 );
+ PRMSG(1,"\tProbable causes: either the XServer is not running, or has not started properly,\n",
+ 0,0,0 );
+ PRMSG(1,"\tor the DISPLAY variable is set incorrectly.\n",
+ 0,0,0 );
+ xfree(ciptr);
+ return NULL;
+ }
+ try ++;
+ DosSleep(500);
+ } while (rc != 0);
+
+/* OK, now we are talking to the server. Generate a unique pipe name and pass it to
+ * the server. Make the pipe and wait for server to connect */
+
+ sprintf(clientname,"\\PIPE\\X\\%d.%d",getpid(),unique_id++);
+
+ rc = DosCreateNPipe (clientname, &hfd,
+ NP_NOINHERIT | NP_ACCESS_DUPLEX,
+ 1 | NP_NOWAIT | NP_TYPE_BYTE | NP_READMODE_BYTE,
+ 16384, 16384, 0);
+ if (rc != 0){
+ PRMSG(1, "Os2OpenClient: Unable to create pipe %s\n", pipename,0,0 );
+ DosClose(hfd);
+ pipe_len=0;
+ DosWrite(hServer,&pipe_len,1,&byteWritten);
+ DosClose(hServer);
+ xfree(ciptr);
+ return(NULL);
+ }
+
+ /* Connect to the pipe. */
+
+ rc = DosConnectNPipe (hfd);
+ if (rc != 0 && rc != ERROR_PIPE_NOT_CONNECTED)
+ {
+ PRMSG(1, "Os2OpenClient: Unable to connect to pipe %s\n", pipename,0,0 );
+ DosClose (hfd);
+ DosClose(hServer);
+ xfree(ciptr);
+ return (NULL);
+ }
+
+/* Now write name to server on hServer */
+ server_string[0]=(char) strlen(clientname)+1;
+ strcpy(&server_string[1],clientname);
+ rc = DosWrite(hServer,server_string,(ULONG)server_string[0]+1,&byteWritten);
+ if(rc != 0){ /* Could not write to server pipe? */
+ PRMSG(1, "Os2OpenClient: Error writing to server pipe, handle=%d, rc=%d, w=%d\n",
+ hServer,rc,byteWritten );
+ DosClose(hServer);
+ DosClose(hfd);
+ xfree(ciptr);
+ return(NULL);
+ }
+
+ PRMSG (5, "Os2OpenCLient: Wrote pipename %s to server; len %d written %d \n",
+ &server_string[1],server_string[0]+1,byteWritten);
+
+
+/* The server will respond by opening the pipe. Wait for that for 30 secs */
+
+ i=0;
+ DosSleep(50); /* Give it time to catch up but minimize race condition*/
+ rc = DosConnectNPipe(hfd);
+ while((rc == ERROR_PIPE_NOT_CONNECTED)&&(i++<60)) {
+ DosSleep(500);
+ rc = DosConnectNPipe(hfd);
+ }
+
+ if(rc != 0){ /* Server has not responded! */
+ PRMSG(1, "Os2OpenClient: Timeout on wait for server response, handle=%d, rc=%d\n",hServer,rc,0 );
+ PRMSG(1, "\tProbable cause: the XServer has exited or crashed while the connection was being established\n",0,0,0 );
+ PRMSG(1, "\tor the XServer is too busy to respond.\n",0,0,0 );
+ DosClose(hServer);
+ DosClose(hfd);
+ xfree(ciptr);
+ return(NULL);
+ }
+
+/* OK, the server has connected! Fill-in the info and return */
+
+ DosClose(hServer);
+
+/* Last check: make sure client is connected! */
+
+ rc = DosQueryNPHState(hfd,&State);
+ if(rc != 0){ /* Client is not connected! */
+ PRMSG(1, "Os2OpenClient: Client pipe does not appear connected. rc=%d, h=%d\n",rc,hfd,0 );
+ PRMSG(1, "\tProbable cause: the XServer has just exited.\n",0,0,0 );
+ DosClose(hfd);
+ xfree(ciptr);
+ return(NULL);
+ }
+
+ namelen=sizeof(struct sockaddr);
+ if ((ciptr->addr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1, "Os2OpenClient: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ DosClose(hfd);
+ xfree(ciptr);
+ return(NULL);
+ }
+ ciptr->addrlen = namelen;
+ ((struct sockaddr *)ciptr->addr)->sa_family = AF_UNIX;
+ strcpy(((struct sockaddr *)ciptr->addr)->sa_data, "local");
+
+ if ((ciptr->peeraddr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1, "Os2OpenCLient: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ DosClose(hfd);
+ xfree(ciptr->addr);
+ xfree(ciptr);
+ return(NULL);
+ }
+ ciptr->peeraddrlen = namelen;
+ ((struct sockaddr *)ciptr->peeraddr)->sa_family = AF_UNIX;
+ strcpy (((struct sockaddr *)ciptr->peeraddr)->sa_data,"local");
+
+ PRMSG (5, "Os2OpenCLient: Filled in struct: len %d %d name %s\n",
+ ciptr->addrlen,ciptr->peeraddrlen,((struct sockaddr *)ciptr->peeraddr)->sa_data);
+
+
+ ciptr->index=hfd;
+ ciptr->family=AF_UNIX;
+ if((ciptr->fd=_imphandle(hfd))<0){
+ PRMSG(1, "Os2OpenClient: Could not import the pipe handle into EMX\n",0,0,0 );
+ PRMSG(1, "\tProbable cause: EMX has run out of free file handles.\n",0,0,0 );
+ DosClose(hfd);
+ xfree(ciptr->addr);
+ xfree(ciptr->peeraddr);
+ xfree(ciptr);
+ return(NULL);
+ }
+ PRMSG(5, "Os2OpenClient: pipe handle %d EMX handle %d\n",ciptr->index,ciptr->fd,0 );
+ fcntl(ciptr->fd,F_SETFL,O_NDELAY);
+ fcntl(ciptr->fd,F_SETFD,FD_CLOEXEC);
+ return ciptr;
+}
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_SERVER
+static XtransConnInfo
+TRANS(Os2OpenServer)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+{
+ APIRET rc;
+ HFILE hfd;
+ ULONG action;
+ char pipename[256];
+ struct sockaddr *addr_name;
+ XtransConnInfo ciptr;
+ int namelen;
+
+#ifdef XSERV_t
+ if (! init_server_pipes()) return(NULL);
+#endif
+
+ PRMSG(2,"Os2OpenServer(%s,%s,%s)\n",protocol,host,port);
+
+ if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ {
+ PRMSG(1,"Os2OpenServer: xcalloc(1,%d) failed\n",
+ sizeof(struct _XtransConnInfo),0,0 );
+ return NULL;
+ }
+
+
+ if (port && *port ) {
+ if( *port == '/' ) { /* A full pathname */
+ (void) sprintf(pipename, "\\PIPE\\X\\%s", port);
+ } else {
+ (void) sprintf(pipename, "%s%s", "\\PIPE\\X\\xf86.", port);
+ }
+ } else {
+ (void) sprintf(pipename, "\\PIPE\\X\\xfree86");
+ }
+
+ PRMSG(5, "Os2OpenServer: Creating pipe %s\n",pipename, 0,0 );
+
+ rc = DosCreateNPipe (pipename, &hfd,
+ NP_NOINHERIT | NP_ACCESS_INBOUND,
+ 1 | NP_NOWAIT | NP_TYPE_BYTE | NP_READMODE_BYTE,
+ 0, 8192, 0);
+ if (rc != 0){
+ PRMSG(1, "Os2OpenServer: Unable to create pipe %s, rc=%d\n", pipename,rc,0 );
+ PRMSG(1, "\tProbable cause: there is already another XServer running on display :%s\n",port,0,0 );
+ DosClose(hfd);
+ xfree(ciptr);
+ return(NULL);
+ }
+
+ /* Connect to the pipe. */
+
+ rc = DosConnectNPipe (hfd);
+ if (rc != 0 && rc != ERROR_PIPE_NOT_CONNECTED)
+ {
+ PRMSG(1, "Os2OpenServer: Unable to connect to pipe %s\n", pipename,0,0 );
+ DosClose (hfd);
+ xfree(ciptr);
+ return (NULL);
+ }
+
+/* Pipe is now connected and waiting for client connect */
+
+/*** Put in info ***/
+
+ namelen=sizeof(struct sockaddr);
+ if ((ciptr->addr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1, "Os2OpenServer: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ DosClose(hfd);
+ xfree(ciptr);
+ return(NULL);
+ }
+ ciptr->addrlen = namelen;
+ ((struct sockaddr *)ciptr->addr)->sa_family = AF_UNIX;
+ strcpy (((struct sockaddr *)ciptr->addr)->sa_data, "local");
+
+ if ((ciptr->peeraddr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1, "Os2OpenServer: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ DosClose(hfd);
+ xfree(ciptr->addr);
+ xfree(ciptr);
+ return(NULL);
+ }
+
+ ciptr->peeraddrlen = namelen;
+ ((struct sockaddr *)ciptr->peeraddr)->sa_family = AF_UNIX;
+ strcpy(((struct sockaddr *)ciptr->peeraddr)->sa_data,"local");
+
+ PRMSG (5, "Os2OpenServer: Filled in struct: len %d %d name %s\n",
+ ciptr->addrlen,ciptr->peeraddrlen,((struct sockaddr *)ciptr->peeraddr)->sa_data);
+
+ ciptr->index=hfd; /* Save this for later use in this unused member of struct */
+ ciptr->flags=1; /* Listener */
+ ciptr->family=AF_UNIX;
+
+ if((ciptr->fd=_imphandle(hfd))<0){
+ DosClose(hfd);
+ xfree(ciptr->addr);
+ xfree(ciptr->peeraddr);
+ xfree(ciptr);
+ return(NULL);
+ }
+ PRMSG(5, "Os2OpenServer: Pipe handle %d EMX handle %d",ciptr->index,ciptr->fd,0 );
+
+#ifdef XSERV_t
+/* Attach the pipe sem to the pipe. Use handle index as key */
+ rc = DosSetNPipeSem(ciptr->fd, (HSEM)hPipeSem, ciptr->fd);
+ if (rc){
+ PRMSG(1, "Os2OpenCOTSServer: Could not attach sem %d to pipe %d, rc=%d\n",
+ hPipeSem,ciptr->fd,rc);
+ DosClose(ciptr->fd);
+ xfree(ciptr->addr);
+ xfree(ciptr->peeraddr);
+ xfree(ciptr);
+ return(NULL);
+ }
+#endif
+
+ fcntl(ciptr->fd,F_SETFL,O_NDELAY);
+ fcntl(ciptr->fd,F_SETFD,FD_CLOEXEC);
+ return(ciptr);
+}
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+static XtransConnInfo
+TRANS(Os2OpenCLTSClient)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+{
+ PRMSG(2,"Os2OpenCLTSClient(%s,%s,%s)\n",protocol,host,port);
+ return TRANS(Os2OpenClient)(thistrans, protocol, host, port);
+}
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_CLIENT
+static XtransConnInfo
+TRANS(Os2OpenCOTSClient)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+{
+ PRMSG(2,"Os2OpenCOTSClient(%s,%s,%s)\n",protocol,host,port);
+ return TRANS(Os2OpenClient)(thistrans, protocol, host, port);
+}
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+static XtransConnInfo
+TRANS(Os2OpenCLTSServer)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+{
+ PRMSG(2,"Os2OpenCLTSServer(%s,%s,%s)\n",protocol,host,port);
+ return TRANS(Os2OpenServer)(thistrans, protocol, host, port);
+}
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_SERVER
+static XtransConnInfo
+TRANS(Os2OpenCOTSServer)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+{
+ PRMSG(2,"Os2OpenCOTSServer(%s,%s,%s)\n",protocol,host,port);
+ return TRANS(Os2OpenServer)(thistrans, protocol, host, port);
+}
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+static XtransConnInfo
+TRANS(Os2ReopenCOTSServer)(Xtransport *thistrans, int fd, char *port)
+{
+
+ XtransConnInfo ciptr;
+ char addr_name[256];
+ int namelen;
+
+ PRMSG(2,"Os2ReopenCOTSServer(%d,%s)\n", fd, port, 0);
+
+ if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ {
+ PRMSG(1,"Os2ReopenCOTSServer: xcalloc(1,%d) failed\n",
+ sizeof(struct _XtransConnInfo),0,0 );
+ return NULL;
+ }
+
+ strcpy(addr_name,"local");
+ namelen=sizeof(addr_name);
+ if ((ciptr->addr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1, "Os2ReopenCOTSServer: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ xfree(ciptr);
+ return(NULL);
+ }
+
+ ciptr->addrlen = namelen;
+ memcpy (ciptr->addr, addr_name, ciptr->addrlen);
+ if ((ciptr->peeraddr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1, "Os2ReopenCOTSServer: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ xfree(ciptr);
+ return(NULL);
+ }
+
+ ciptr->peeraddrlen = namelen;
+ memcpy (ciptr->peeraddr,addr_name, ciptr->addrlen);
+
+ ciptr->fd = fd;
+ ciptr->family=AF_UNIX;
+ ciptr->flags=1;
+ PRMSG(1,"Os2ReopenCOTSServer: Filled-in info for handle %d on port %s.\n", fd, port, 0);
+
+ return(ciptr);
+}
+
+static XtransConnInfo
+TRANS(Os2ReopenCLTSServer)(Xtransport *thistrans, int fd, char *port)
+{
+ PRMSG(2,"Os2ReopenCLTSServer(%d,%s)\n", fd, port, 0);
+ return TRANS(Os2ReopenCOTSServer)(thistrans, fd, port);
+}
+#endif
+
+static
+TRANS(Os2SetOption)(XtransConnInfo ciptr, int option, int arg)
+{
+ PRMSG(2,"Os2SetOption(%d,%d,%d)\n",ciptr->fd,option,arg);
+ return -1;
+}
+
+#ifdef TRANS_SERVER
+
+static
+TRANS(Os2CreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags)
+{
+ PRMSG(2,"Os2CreateListener(%x->%d,%s)\n",ciptr,ciptr->fd,port);
+ return 0;
+}
+
+static XtransConnInfo
+TRANS(Os2Accept)(XtransConnInfo ciptr, int *status)
+{
+ XtransConnInfo newciptr;
+ HFILE hClient;
+ unsigned char length;
+ ULONG action;
+ char clientname[256];
+ struct sockaddr *addr_name;
+ int in,namelen;
+ APIRET rc;
+
+
+ PRMSG(2,"Os2Accept(%x->%d)\n", ciptr, ciptr->fd,0);
+ if( (newciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo)))==NULL )
+ {
+ PRMSG(1,"Os2Accept: xcalloc(1,%d) failed\n",
+ sizeof(struct _XtransConnInfo),0,0 );
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+/* Read in length of client pipe name. If fails, then reset server pipe */
+ if((in=read(ciptr->fd,&length,1))<=0){
+ PRMSG(2,"Os2Accept: Error reading incoming connection, in=%d, error=%d\n",
+ in,errno,0 );
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ xfree(newciptr);
+ rc = DosDisConnectNPipe(ciptr->fd);
+ rc = DosConnectNPipe (ciptr->fd);
+ if (rc != 0 && rc != ERROR_PIPE_NOT_CONNECTED)
+ {
+ PRMSG(1, "Os2Accept: Unable to reconnect server pipe %d\n", ciptr->fd,0,0 );
+ }
+ return NULL;
+ }
+ PRMSG(5, "Os2Accept: Bytes to read for name: %d\n",length,0,0 );
+
+
+/* Check length for valid length ?? */
+
+/* Now read in length bytes from pipe for client pipe name */
+ if((in=read(ciptr->fd,clientname,length))<=0){
+ PRMSG(2,"Os2Accept: Error reading incoming connection, in=%d, error=%d\n",
+ in,errno,0 );
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ xfree(newciptr);
+ rc = DosDisConnectNPipe(ciptr->fd);
+ rc = DosConnectNPipe (ciptr->fd);
+ if (rc != 0 && rc != ERROR_PIPE_NOT_CONNECTED)
+ {
+ PRMSG(1, "Os2Accept: Unable to reconnect server pipe %d\n", ciptr->fd,0,0 );
+ }
+ return NULL;
+ }
+ clientname[length]='\0';
+ PRMSG(5, "Os2Accept: Server name %s length %d\n",clientname,length,0 );
+
+
+/* Now we have the client pipe name. Open it with DosOpen */
+
+ rc = DosOpen(clientname,&hClient, &action, 0,
+ FILE_NORMAL, FILE_OPEN,
+ OPEN_FLAGS_NOINHERIT | OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYREADWRITE,
+ (PEAOP2)NULL);
+
+ PRMSG(5, "Os2Accept: Open pipe %s, handle = %d, rc=%d\n",clientname,hClient,rc );
+
+ if (rc) {
+ PRMSG(1,"Os2Accept: Open pipe %s to client failed, rc=%d\n",
+ clientname,rc,0 );
+ PRMSG(1, "\tProbable cause: the client has exited or timed-out.\n",0,0,0 );
+ xfree(newciptr);
+ rc = DosDisConnectNPipe(ciptr->fd);
+ rc = DosConnectNPipe (ciptr->fd);
+ if (rc != 0 && rc != ERROR_PIPE_NOT_CONNECTED)
+ {
+ PRMSG(1, "Os2Accept: Unable to reconnect server pipe %d\n", ciptr->fd,0,0 );
+ }
+ return NULL;
+ }
+
+ rc = DosSetNPHState (hClient, NP_NOWAIT | NP_READMODE_BYTE);
+ if (rc != 0)
+ {
+ PRMSG(1,"Os2Accept: Could not set pipe %s to non-blocking mode, rc=%d\n",
+ hClient,rc,0 );
+ xfree(newciptr);
+ rc = DosDisConnectNPipe(ciptr->fd);
+ rc = DosConnectNPipe (ciptr->fd);
+ if (rc != 0 && rc != ERROR_PIPE_NOT_CONNECTED)
+ {
+ PRMSG(1, "Os2Accept: Unable to reconnect server pipe %d\n", ciptr->fd,0,0 );
+ }
+ return NULL;
+ }
+
+/* OK, we seem to be well connected to client. Now disconnect server pipe and put again in listen */
+
+ rc = DosDisConnectNPipe(ciptr->fd);
+ rc = DosConnectNPipe (ciptr->fd);
+ PRMSG(5, "Os2Accept: Reconnecting server pipe %d, rc = %d\n",ciptr->fd,rc,0 );
+
+ if (rc != 0 && rc != ERROR_PIPE_NOT_CONNECTED)
+ {
+ PRMSG(1, "Os2Accept: Unable to reconnect server pipe %d\n", ciptr->fd,0,0 );
+ } /* Consider this non-fatal for present connection */
+
+/* And finally fill-in info in newciptr */
+
+ namelen=sizeof(struct sockaddr);
+ if ((newciptr->addr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1, "Os2Accept: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ DosClose(hClient);
+ xfree(newciptr);
+ return(NULL);
+ }
+
+ newciptr->addrlen = namelen;
+ ((struct sockaddr *)newciptr->addr)->sa_family = AF_UNIX;
+ strcpy (((struct sockaddr *)newciptr->addr)->sa_data, "local");
+
+ if ((newciptr->peeraddr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1, "Os2Accept: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ DosClose(hClient);
+ xfree(ciptr->addr);
+ xfree(newciptr);
+ return(NULL);
+ }
+
+ newciptr->peeraddrlen = namelen;
+ ((struct sockaddr *)newciptr->peeraddr)->sa_family = AF_UNIX;
+ strcpy (((struct sockaddr *)newciptr->peeraddr)->sa_data, "local");
+
+ PRMSG (5, "Os2Accept: Filled in struct: len %d %d name %s\n",
+ newciptr->addrlen,newciptr->peeraddrlen,newciptr->peeraddr);
+
+
+ newciptr->index=hClient;
+ newciptr->family=AF_UNIX;
+ if((newciptr->fd=_imphandle(hClient))<0){
+ PRMSG(1,"Os2Accept: Could not import pipe %d into EMX, errno=%d\n",
+ hClient,errno,0 );
+ PRMSG(1, "\tProbable cause: EMX has run out of file handles.\n",0,0,0 );
+ DosClose(hClient);
+ xfree(newciptr->addr);
+ xfree(newciptr->peeraddr);
+ xfree(newciptr);
+ return(NULL);
+ }
+ PRMSG(5, "Os2Accept: Pipe handle %d EMX handle %d",newciptr->index,newciptr->fd,0 );
+
+#ifdef XSERV_t
+/* Attach the pipe sem to the pipe. Use handle index as key */
+ rc = DosSetNPipeSem(newciptr->fd, (HSEM)hPipeSem, newciptr->fd);
+ if (rc){
+ PRMSG(1, "Os2OpenCOTSServer: Could not attach sem %d to pipe %d, rc=%d\n",
+ hPipeSem,newciptr->fd,rc);
+ DosClose(newciptr->fd);
+ xfree(newciptr->addr);
+ xfree(newciptr->peeraddr);
+ xfree(newciptr);
+ return(NULL);
+ }
+#endif
+
+ fcntl(ciptr->fd,F_SETFL,O_NDELAY);
+ fcntl(ciptr->fd,F_SETFD,FD_CLOEXEC);
+ *status=0;
+ return newciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+
+static
+TRANS(Os2Connect)(XtransConnInfo ciptr, char *host, char *port)
+{
+ PRMSG(2,"Os2Connect(%x->%d,%s)\n", ciptr, ciptr->fd, port);
+ return 0;
+}
+
+#endif /* TRANS_CLIENT */
+
+static int
+TRANS(Os2BytesReadable)(XtransConnInfo ciptr, BytesReadable_t *pend )
+{
+ ULONG rc, state, nread;
+ AVAILDATA avail;
+ char buffer;
+
+ PRMSG(2,"Os2BytesReadable(%x->%d,%x)\n", ciptr, ciptr->fd, pend);
+
+ rc = DosPeekNPipe (ciptr->fd, &buffer, 0, &nread, &avail, &state);
+ if (rc != 0)
+ {
+ errno = EPIPE;
+ *pend = 0;
+ return -1;
+ }
+ if (state == NP_STATE_CLOSING)
+ {
+ errno = EPIPE;
+ *pend = 0;
+ return -1;
+ }
+ errno = 0;
+ *pend = avail.cbpipe;
+ return 0;
+}
+
+static int
+TRANS(Os2Read)(XtransConnInfo ciptr, char *buf, int size)
+{
+ int ret;
+ APIRET rc;
+ ULONG ulRead;
+ PRMSG(2,"Os2Read(%d,%x,%d)\n", ciptr->fd, buf, size );
+ errno = 0;
+ rc = DosRead(ciptr->fd, buf, size, &ulRead);
+ if (rc == 0){
+ ret = ulRead;
+ }
+ else if ((rc == 232) || (rc == 231)){
+ errno = EAGAIN;
+ ret = -1;
+ }
+ else if (rc == 6){
+ errno = EBADF;
+ ret = -1;
+ }
+ else if ((rc == 109) || (rc == 230) || (rc == 233)){
+ errno = EPIPE;
+ ret = -1;
+ }
+ else {
+ PRMSG(2,"Os2Read: Unknown return code from DosRead, fd %d rc=%d\n", ciptr->fd,rc,0 );
+ errno = EINVAL;
+ ret = -1;
+ }
+ return (ret);
+}
+
+static int
+TRANS(Os2Write)(XtransConnInfo ciptr, char *buf, int size)
+{
+ int ret;
+ APIRET rc;
+ ULONG nWritten;
+ PRMSG(2,"Os2Write(%d,%x,%d)\n", ciptr->fd, buf, size );
+ rc = DosWrite(ciptr->fd, buf, size, &nWritten);
+ if (rc == 0){
+ ret = nWritten;
+ if(nWritten == 0) {
+ errno=EAGAIN;
+ ret = -1;
+ }
+ }
+ else if ((rc == 39) || (rc == 112)){
+ errno = EAGAIN;
+ ret = -1;
+ }
+ else if ((rc == 109) || (rc == 230) || (rc == 233)){
+ errno = EPIPE;
+ ret = -1;
+ }
+ else if (rc == 6){
+ errno=EBADF;
+ ret = -1;
+ }
+ else {
+ PRMSG(2,"(Os2Write)Unknown return code from DosWrite, fd %d rc=%d\n", ciptr->fd,rc,0 );
+ errno = EINVAL;
+ ret = -1;
+ }
+ return (ret);
+}
+
+static int
+TRANS(Os2Readv)(XtransConnInfo ciptr, struct iovec *buf, int size)
+{
+ int ret;
+ PRMSG(2,"Os2Readv(%d,%x,%d)\n", ciptr->fd, buf, size );
+ ret = READV(ciptr,buf,size);
+ if ((ret <0) && (errno == EINVAL)) errno = EPIPE;
+ return (ret);
+}
+
+static int
+TRANS(Os2Writev)(XtransConnInfo ciptr, struct iovec *buf, int size)
+{
+ int ret;
+ PRMSG(2,"Os2Writev(%d,%x,%d)\n", ciptr->fd, buf, size );
+ ret = WRITEV(ciptr,buf,size);
+ if ((ret <0) && (errno == EINVAL)) errno = EPIPE;
+ if ((ret <0) && (errno == ENOSPC)) errno = EAGAIN;
+ return (ret);
+}
+
+static int
+TRANS(Os2Disconnect)(XtransConnInfo ciptr)
+{
+ PRMSG(2,"Os2Disconnect(%x->%d)\n", ciptr, ciptr->fd, 0);
+ return 0;
+}
+
+static int
+TRANS(Os2Close)(XtransConnInfo ciptr)
+{
+ int ret;
+ PRMSG(2,"Os2Close(%x->%d)\n", ciptr, ciptr->fd ,0);
+ ret=close(ciptr->fd);
+ return ret;
+}
+
+static int
+TRANS(Os2CloseForCloning)(XtransConnInfo ciptr)
+{
+ int ret;
+
+ PRMSG(2,"Os2CloseForCloning(%x->%d)\n", ciptr, ciptr->fd ,0);
+ ret=close(ciptr->fd);
+ return ret;
+}
+
+
+Xtransport TRANS(OS2LocalFuncs) = {
+ /* Local Interface */
+ "local",
+ TRANS_LOCAL,
+#ifdef TRANS_CLIENT
+ TRANS(Os2OpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(Os2OpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(Os2OpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(Os2OpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(Os2ReopenCOTSServer),
+ TRANS(Os2ReopenCLTSServer),
+#endif
+ TRANS(Os2SetOption),
+#ifdef TRANS_SERVER
+ TRANS(Os2CreateListener),
+ NULL, /* ResetListener */
+ TRANS(Os2Accept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(Os2Connect),
+#endif /* TRANS_CLIENT */
+ TRANS(Os2BytesReadable),
+ TRANS(Os2Read),
+ TRANS(Os2Write),
+ TRANS(Os2Readv),
+ TRANS(Os2Writev),
+ TRANS(Os2Disconnect),
+ TRANS(Os2Close),
+ TRANS(Os2CloseForCloning),
+};
+
+#ifdef XSERV_t
+/* This function is used in the server to initialize the semaphore used with pipes */
+
+BOOL init_server_pipes()
+{
+ static BOOL first_time=TRUE;
+ ULONG rc;
+
+ if(first_time){
+ rc = DosCreateEventSem(NULL, &hPipeSem,DC_SEM_SHARED,FALSE);
+ if (rc){
+ PRMSG(1,"Os2OpenListener (init_server_pipes): Could not create pipe semaphore, rc=%d\n",
+ rc,0,0);
+ return(FALSE);
+ }
+ first_time=FALSE;
+ }
+return(TRUE);
+}
+#endif /* XSERV_t */
diff --git a/nx-X11/lib/xtrans/Xtranssock.c b/nx-X11/lib/xtrans/Xtranssock.c
new file mode 100644
index 000000000..50b677057
--- /dev/null
+++ b/nx-X11/lib/xtrans/Xtranssock.c
@@ -0,0 +1,3417 @@
+/* $XdotOrg: xc/lib/xtrans/Xtranssock.c,v 1.11 2005/11/08 06:33:26 jkj Exp $ */
+/* $Xorg: Xtranssock.c,v 1.11 2001/02/09 02:04:06 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+Copyright 2002 Sun Microsystems, Inc. All rights reserved.
+
+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 copyright holders 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 copyright holders.
+
+*/
+/* $XFree86: xc/lib/xtrans/Xtranssock.c,v 3.68 2004/01/07 04:28:02 dawes Exp $ */
+
+/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * 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 NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCR makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR 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 (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#ifdef NX_TRANS_SOCKET
+
+#ifdef NX_TRANS_DEBUG
+#define XTRANSDEBUG 5
+#endif
+
+#ifndef PF_LOCAL
+#define PF_LOCAL PF_UNIX
+#endif
+
+#endif
+
+#include <ctype.h>
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+
+#ifndef WIN32
+
+#if defined(TCPCONN) || defined(UNIXCONN)
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+
+#if defined(TCPCONN) || defined(UNIXCONN)
+#define X_INCLUDE_NETDB_H
+#define XOS_USE_NO_LOCKING
+#include <X11/Xos_r.h>
+#endif
+
+#ifdef UNIXCONN
+#ifndef X_NO_SYS_UN
+#ifndef Lynx
+#include <sys/un.h>
+#else
+#include <un.h>
+#endif
+#endif
+#include <sys/stat.h>
+#endif
+
+#if defined(hpux) || (defined(MOTOROLA) && defined(SYSV))
+#define NO_TCP_H
+#endif
+
+#ifndef NO_TCP_H
+#if defined(__osf__) || defined(linux) || defined(__GLIBC__) || defined(AIXV5)
+#include <sys/param.h>
+#endif /* osf */
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
+#include <sys/param.h>
+#include <machine/endian.h>
+#endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ || __DragonFly__ */
+#include <netinet/tcp.h>
+#endif /* !NO_TCP_H */
+
+#include <sys/ioctl.h>
+#if defined(SVR4) && !defined(DGUX) && !defined(_SEQUENT_)
+#include <sys/filio.h>
+#endif
+
+#if (defined(i386) && defined(SYSV)) && !defined(SCO325) && !defined(sun)
+#include <net/errno.h>
+#endif
+
+#if (defined(i386) && defined(SYSV)) && (!defined(ISC) || !defined(I_NREAD) || defined(SCO325)) || defined(_SEQUENT_)
+#include <sys/stropts.h>
+#endif
+
+#else /* !WIN32 */
+
+#include <X11/Xwinsock.h>
+#include <X11/Xwindows.h>
+#include <X11/Xw32defs.h>
+#undef close
+#define close closesocket
+#define ECONNREFUSED WSAECONNREFUSED
+#define EADDRINUSE WSAEADDRINUSE
+#define EPROTOTYPE WSAEPROTOTYPE
+#undef EWOULDBLOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#define EINPROGRESS WSAEINPROGRESS
+#undef EINTR
+#define EINTR WSAEINTR
+#define X_INCLUDE_NETDB_H
+#define XOS_USE_MTSAFE_NETDBAPI
+#include <X11/Xos_r.h>
+#endif /* WIN32 */
+
+#if defined(SO_DONTLINGER) && defined(SO_LINGER)
+#undef SO_DONTLINGER
+#endif
+
+#if defined(__UNIXOS2__)
+#if defined(NOT_EMX09A)
+static int IBMsockInit = 0;
+#define SocketInitOnce()\
+ if (!IBMsockInit) {\
+ sock_init();\
+ IBMsockInit = 1;\
+ }
+#undef EINTR
+#define EINTR SOCEINTR
+#undef EINVAL
+#define EINVAL SOCEINVAL
+#undef errno
+#define errno sock_errno()
+#undef close
+#define close soclose
+#undef ioctl
+#define ioctl sockioctl
+#else
+#define SocketInitOnce() /**/
+#endif
+/* this is still not there */
+#define SOCKET int
+#else
+/* others don't need this */
+#define SocketInitOnce() /**/
+#endif
+
+#define MIN_BACKLOG 128
+#ifdef SOMAXCONN
+#if SOMAXCONN > MIN_BACKLOG
+#define BACKLOG SOMAXCONN
+#endif
+#endif
+#ifndef BACKLOG
+#define BACKLOG MIN_BACKLOG
+#endif
+/*
+ * This is the Socket implementation of the X Transport service layer
+ *
+ * This file contains the implementation for both the UNIX and INET domains,
+ * and can be built for either one, or both.
+ *
+ */
+
+typedef struct _Sockettrans2dev {
+ char *transname;
+ int family;
+ int devcotsname;
+ int devcltsname;
+ int protocol;
+} Sockettrans2dev;
+
+static Sockettrans2dev Sockettrans2devtab[] = {
+#ifdef TCPCONN
+ {"inet",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
+#if !defined(IPv6) || !defined(AF_INET6)
+ {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
+#else /* IPv6 */
+ {"tcp",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
+ {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, /* fallback */
+ {"inet6",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
+#endif
+#endif /* TCPCONN */
+#ifdef UNIXCONN
+ {"unix",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},
+#if !defined(LOCALCONN)
+ {"local",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},
+#endif /* !LOCALCONN */
+#endif /* UNIXCONN */
+};
+
+#define NUMSOCKETFAMILIES (sizeof(Sockettrans2devtab)/sizeof(Sockettrans2dev))
+
+#ifdef TCPCONN
+static int TRANS(SocketINETClose) (XtransConnInfo ciptr);
+#endif
+
+#ifdef UNIXCONN
+
+#ifdef hpux
+
+#if defined(X11_t)
+#define UNIX_PATH "/usr/spool/sockets/X11/"
+#define UNIX_DIR "/usr/spool/sockets/X11"
+#define OLD_UNIX_PATH "/tmp/.X11-unix/X"
+#endif /* X11_t */
+#if defined(XIM_t)
+#define UNIX_PATH "/usr/spool/sockets/XIM/"
+#define UNIX_DIR "/usr/spool/sockets/XIM"
+#define OLD_UNIX_PATH "/tmp/.XIM-unix/XIM"
+#endif /* XIM_t */
+#if defined(FS_t) || defined(FONT_t)
+#define UNIX_PATH "/usr/spool/sockets/fontserv/"
+#define UNIX_DIR "/usr/spool/sockets/fontserv"
+#endif /* FS_t || FONT_t */
+#if defined(ICE_t)
+#define UNIX_PATH "/usr/spool/sockets/ICE/"
+#define UNIX_DIR "/usr/spool/sockets/ICE"
+#endif /* ICE_t */
+#if defined(TEST_t)
+#define UNIX_PATH "/usr/spool/sockets/xtrans_test/"
+#define UNIX_DIR "/usr/spool/sockets/xtrans_test"
+#endif
+#if defined(LBXPROXY_t)
+#define UNIX_PATH "/usr/spool/sockets/X11/"
+#define UNIX_DIR "/usr/spool/sockets/X11"
+#endif
+
+#else /* !hpux */
+
+#if defined(X11_t)
+#define UNIX_PATH "/tmp/.X11-unix/X"
+#define UNIX_DIR "/tmp/.X11-unix"
+#endif /* X11_t */
+#if defined(XIM_t)
+#define UNIX_PATH "/tmp/.XIM-unix/XIM"
+#define UNIX_DIR "/tmp/.XIM-unix"
+#endif /* XIM_t */
+#if defined(FS_t) || defined(FONT_t)
+#define UNIX_PATH "/tmp/.font-unix/fs"
+#define UNIX_DIR "/tmp/.font-unix"
+#endif /* FS_t || FONT_t */
+#if defined(ICE_t)
+#define UNIX_PATH "/tmp/.ICE-unix/"
+#define UNIX_DIR "/tmp/.ICE-unix"
+#endif /* ICE_t */
+#if defined(TEST_t)
+#define UNIX_PATH "/tmp/.Test-unix/test"
+#define UNIX_DIR "/tmp/.Test-unix"
+#endif
+#if defined(LBXPROXY_t)
+#define UNIX_PATH "/tmp/.X11-unix/X"
+#define UNIX_DIR "/tmp/.X11-unix"
+#endif
+
+#endif /* hpux */
+
+#endif /* UNIXCONN */
+
+#define PORTBUFSIZE 32
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 255
+#endif
+
+/*
+ * This provides compatibility for apps linked against system libraries
+ * that don't have IPv6 support.
+ */
+#if defined(IPv6) && defined(AF_INET6)
+static const struct in6_addr local_in6addr_any = IN6ADDR_ANY_INIT;
+#pragma weak in6addr_any = local_in6addr_any
+#ifndef __USLC__
+#pragma weak getaddrinfo
+#endif
+static int haveIPv6 = 1;
+#endif
+
+#ifndef X11_t
+
+/*
+ * No NX changes if this is not
+ * compiled as a X11 transport.
+ */
+
+#undef NX_TRANS_SOCKET
+
+#endif
+
+#ifdef NX_TRANS_SOCKET
+
+#ifdef TRANS_CLIENT
+
+#include "NX.h"
+
+typedef struct
+{
+ XtransConnInfo info;
+ int local;
+ int remote;
+ int congestion;
+
+} _NXProxyConnInfo;
+
+#define NX_PROXY_CONN_LIMIT 256
+
+static _NXProxyConnInfo *_NXProxyConnInfoTab[NX_PROXY_CONN_LIMIT];
+
+#endif /* #ifdef TRANS_CLIENT */
+
+/*
+ * Override the UNIX_DIR and UNIX_PATH settings and
+ * make them configurable, based on the NX_TEMP or
+ * the TEMP environment.
+ *
+ * We must be careful as the same defines are used
+ * for different directories, based on the subsystem
+ * that is compiling this, while we want to override
+ * only the '/tmp/.X11-unix' and '/tmp/.X11-unix/X'
+ * settings.
+ */
+
+static char _NXUnixDir[1024];
+static char _NXUnixPath[1024];
+
+static char *_NXGetUnixDir(char *dir)
+{
+ const char *tempDir;
+
+ PRMSG (3, "_NXGetUnixDir(%s)\n", dir, 0, 0);
+
+ if (strcmp(dir, UNIX_DIR) != 0)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixDir: Returning other Unix directory [%s].\n", dir);
+#endif
+ return dir;
+ }
+
+ /*
+ * Check the environment only once.
+ */
+
+ if (*_NXUnixDir != '\0')
+ {
+ return _NXUnixDir;
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixDir: Trying with the NX_TEMP environment.\n");
+#endif
+
+ tempDir = getenv("NX_TEMP");
+
+ if (tempDir == NULL || *tempDir == '\0')
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixDir: Trying with the TEMP environment.\n");
+#endif
+
+ tempDir = getenv("TEMP");
+ }
+
+ if (tempDir != NULL && *tempDir != '\0')
+ {
+ if (strlen(tempDir) + strlen("/.X11-unix") + 1 > 1024)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixDir: WARNING! Maximum length of X11 Unix directory exceeded.\n");
+#endif
+ goto _NXGetUnixDirError;
+ }
+
+ strcpy(_NXUnixDir, tempDir);
+ strcat(_NXUnixDir, "/.X11-unix");
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixDir: Using X11 Unix directory [%s].\n", _NXUnixDir);
+#endif
+
+ return _NXUnixDir;
+ }
+
+_NXGetUnixDirError:
+
+ strcpy(_NXUnixDir, dir);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixDir: Returning default X11 Unix directory [%s].\n", _NXUnixDir);
+#endif
+
+ return _NXUnixDir;
+}
+
+static char *_NXGetUnixPath(char *path)
+{
+ const char *unixDir;
+
+ PRMSG (3, "_NXGetUnixPath(%s)\n", path, 0, 0);
+
+ if (strcmp(path, UNIX_PATH) != 0)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixPath: Returning other X11 Unix path [%s].\n", path);
+#endif
+ return path;
+ }
+
+ /*
+ * Check the environment only once.
+ */
+
+ if (*_NXUnixPath != '\0')
+ {
+ return _NXUnixPath;
+ }
+
+ unixDir = _NXGetUnixDir(UNIX_DIR);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixPath: Got X11 Unix directory [%s].\n", unixDir);
+#endif
+
+ if (strlen(unixDir) + strlen("/X") + 1 > 1024)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixPath: WARNING! Maximum length of X11 Unix path exceeded.\n");
+#endif
+
+ goto _NXGetUnixPathError;
+ }
+
+ strcpy(_NXUnixPath, unixDir);
+ strcat(_NXUnixPath, "/X");
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixPath: Returning X11 Unix path [%s].\n", _NXUnixPath);
+#endif
+
+ return _NXUnixPath;
+
+_NXGetUnixPathError:
+
+ strcpy(_NXUnixPath, path);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixPath: Returning default X11 Unix path [%s].\n", _NXUnixPath);
+#endif
+
+ return _NXUnixPath;
+}
+
+#ifdef hpux
+
+static char *_NXGetOldUnixPath(char *path)
+{
+ PRMSG (3, "_NXGetOldUnixPath(%s)\n", path, 0, 0);
+
+ if (strcmp(path, OLD_UNIX_PATH) == 0)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetOldUnixPath: Returning X11 Unix path [%s].\n",
+ _NXGetUnixPath(path));
+#endif
+
+ return _NXGetUnixPath(path);
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetOldUnixPath: Returning other old X11 Unix path [%s].\n", path);
+#endif
+
+ return path;
+}
+
+#endif /* #ifdef hpux */
+
+/*
+ * Forcibly close any connection attempt on the
+ * listening socket. Need this to avoid loopback
+ * connections to the agent server.
+ */
+
+#ifdef TRANS_SERVER
+
+void TRANS(SocketRejectConnection) (XtransConnInfo ciptr)
+{
+ size_t sa_l = sizeof(struct sockaddr);
+ struct sockaddr sa;
+ fd_set fs;
+ struct timeval t;
+ int f;
+
+ PRMSG (3, "SocketRejectConnection(%x)\n", ciptr, 0, 0);
+
+ FD_ZERO(&fs);
+ FD_SET(ciptr -> fd, &fs);
+
+ t.tv_sec = 0;
+ t.tv_usec = 0;
+
+ /*
+ * Check if there is an awaiting connection.
+ */
+
+ if (select(ciptr -> fd + 1, &fs, NULL, NULL, &t) == 1)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketRejectConnection: Accepting connection attempt on fd [%d].\n",
+ ciptr -> fd);
+#endif
+ /*
+ * If there is one, close it.
+ */
+
+ if ((f = accept(ciptr -> fd, &sa, &sa_l)) >= 0)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketRejectConnection: Closing connection attempt on fd [%d].\n",
+ ciptr -> fd);
+#endif
+ close(f);
+ }
+ }
+}
+
+#endif /* #ifdef TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+
+void *TRANS(SocketProxyConnInfo) (XtransConnInfo ciptr)
+{
+ if (_NXProxyConnInfoTab[ciptr->fd] != NULL)
+ {
+ return ciptr->priv;
+ }
+
+ return NULL;
+}
+
+static XtransConnInfo TRANS(SocketCreateConnInfo) ()
+{
+ XtransConnInfo ciptr;
+
+ int fds[2];
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCreateConnInfo: Going to create the NX connection info.\n");
+#endif
+
+ if ((ciptr = (XtransConnInfo) xcalloc (1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketCreateConnInfo: malloc failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ /*
+ * Create a pair of sockets. We'll communicate with
+ * the NX proxy by reading and writing to our end.
+ */
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCreateConnInfo: Going to create the NX socketpair.\n");
+#endif
+
+ if (socketpair(PF_LOCAL, SOCK_STREAM, 0, fds) < 0)
+ {
+ PRMSG (1, "SocketCreateConnInfo: socketpair() failed.\n", 0, 0, 0);
+ xfree ((char *) ciptr);
+ return NULL;
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCreateConnInfo: X socket end is [%d] NX proxy end is [%d].\n",
+ fds[0], fds[1]);
+#endif
+
+ /*
+ * Save in _NXProxyConnInfoTab the local and remote end of
+ * the socketpair. The remote end will be used by the proxy.
+ * When the memory-to-memory transport is activated, the
+ * agent and the proxy don't read or write to the real des-
+ * criptors but the communication takes place by reading
+ * and writing to the proxy's buffers.
+ */
+
+ ciptr->fd = fds[0];
+
+ if (ciptr->fd >= NX_PROXY_CONN_LIMIT)
+ {
+ PRMSG (1, "SocketCreateConnInfo: No space for a new _NXProxyConnInfo for [%d].\n",
+ ciptr->fd, 0, 0);
+ xfree ((char *) ciptr);
+ return NULL;
+ }
+ else if (_NXProxyConnInfoTab[ciptr->fd] != NULL)
+ {
+ PRMSG (1, "SocketCreateConnInfo: _NXProxyConnInfo for [%d] is not NULL. Exiting.\n",
+ ciptr->fd, 0, 0);
+ exit(1);
+ }
+
+ _NXProxyConnInfoTab[ciptr->fd] = (_NXProxyConnInfo *) xcalloc(1, sizeof(_NXProxyConnInfo));
+
+ if (_NXProxyConnInfoTab[ciptr->fd] == NULL)
+ {
+ PRMSG (1, "SocketCreateConnInfo: Alloc of _NXProxyConnInfo failed.\n", 0, 0, 0);
+ xfree ((char *) ciptr);
+ return NULL;
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCreateConnInfo: Allocated new _NXProxyConnInfo for [%d].\n",
+ ciptr->fd);
+#endif
+
+ _NXProxyConnInfoTab[ciptr->fd]->info = ciptr;
+ _NXProxyConnInfoTab[ciptr->fd]->local = fds[0];
+ _NXProxyConnInfoTab[ciptr->fd]->remote = fds[1];
+ _NXProxyConnInfoTab[ciptr->fd]->congestion = 0;
+
+ ciptr->priv = (char *) _NXProxyConnInfoTab[ciptr->fd];
+
+ return ciptr;
+}
+
+static int TRANS(SocketConnectConnInfo) (XtransConnInfo ciptr, char *host, char *port)
+{
+ int fds[2];
+ char display[1024];
+
+ _NXProxyConnInfo *proxy_conn;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketConnectConnInfo: Going to connect NX fd [%d] to host [%s] port [%s].\n",
+ ciptr->fd, host, port);
+#endif
+
+ /*
+ * We should have already created the socket pair.
+ */
+
+ proxy_conn = (_NXProxyConnInfo *) ciptr->priv;
+
+ if (proxy_conn == NULL)
+ {
+ PRMSG (1, "SocketConnectConnInfo: Pointer to _NXProxyConnInfo is NULL. Exiting.\n", 0, 0, 0);
+
+ exit(1);
+ }
+ else if (_NXProxyConnInfoTab[ciptr->fd] != (_NXProxyConnInfo *) ciptr->priv)
+ {
+ PRMSG (1, "SocketConnectConnInfo: Can't find _NXProxyConnInfo in table. Exiting.\n",
+ 0, 0, 0);
+
+ exit(1);
+ }
+
+ if (strlen(host) + strlen(port) + 1 >= 1023)
+ {
+ PRMSG (1, "SocketConnectConnInfo: Length of NX display string '%s:%s' would exceed %d characters.\n",
+ host, port, 1023);
+
+ return TRANS_CONNECT_FAILED;
+ }
+
+ sprintf(display, "%s:%s", host, port);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketConnectConnInfo: Setting close-on-exec flag on local NX descriptor [%d].\n",
+ proxy_conn -> local);
+#endif
+
+#ifdef F_SETFD
+#ifdef FD_CLOEXEC
+ if (fcntl(proxy_conn -> local, F_SETFD, FD_CLOEXEC) != 0)
+#else
+ if (fcntl(proxy_conn -> local, F_SETFD, 1) != 0)
+#endif
+#endif
+ {
+ PRMSG (1, "SocketConnectConnInfo: Cannot set close-on-exec on local NX descriptor [%d].\n",
+ proxy_conn -> local, 0, 0);
+
+ return TRANS_CONNECT_FAILED;
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketConnectConnInfo: Creating the NX transport with display [%s].\n",
+ display);
+#endif
+
+ if (NXTransCreate(NX_FD_ANY, NX_MODE_CLIENT, display) < 0)
+ {
+ PRMSG (1, "SocketConnectConnInfo: Cannot create the NX transport.\n",
+ 0, 0, 0);
+
+ return TRANS_CONNECT_FAILED;
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketConnectConnInfo: Starting the NX agent with descriptor [%d].\n",
+ proxy_conn -> remote);
+#endif
+
+ fds[0] = proxy_conn -> local;
+ fds[1] = proxy_conn -> remote;
+
+ NXTransAgent(fds);
+
+ return 0;
+}
+
+static void TRANS(SocketCloseConnInfo) (XtransConnInfo ciptr)
+{
+ _NXProxyConnInfo *proxy_conn;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCloseConnInfo: Going to close the NX fd [%d].\n", ciptr->fd);
+#endif
+
+ proxy_conn = (_NXProxyConnInfo *) ciptr->priv;
+
+ if (proxy_conn == NULL)
+ {
+ PRMSG (1, "SocketCloseConnInfo: Pointer to _NXProxyConnInfo is NULL. Exiting.\n", 0, 0, 0);
+
+ exit(1);
+ }
+ else if (ciptr->fd >= NX_PROXY_CONN_LIMIT ||
+ _NXProxyConnInfoTab[ciptr->fd] != (_NXProxyConnInfo *) ciptr->priv)
+ {
+ PRMSG (1, "SocketCloseConnInfo: Can't find _NXProxyConnInfo in table. Exiting.\n",
+ 0, 0, 0);
+ exit(1);
+ }
+ else if (_NXProxyConnInfoTab[ciptr->fd] -> info != ciptr ||
+ _NXProxyConnInfoTab[ciptr->fd] -> local != ciptr->fd)
+ {
+ PRMSG (1, "SocketCloseConnInfo: Invalid _NXProxyConnInfo structure for [%d]. Exiting.\n",
+ ciptr->fd, 0, 0);
+ exit(1);
+ }
+ else if (proxy_conn->local < 0 || proxy_conn->remote < 0)
+ {
+ PRMSG (1, "SocketCloseConnInfo: Invalid socket pair in NX connection for [%d]. Exiting.\n",
+ ciptr->fd, 0, 0);
+ exit(1);
+ }
+
+ NXTransClose(ciptr->fd);
+
+ /*
+ * Get rid of the _NXProxyConnInfo structure.
+ */
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCloseConnInfo: Freeing _NXProxyConnInfo structure for [%d].\n",
+ ciptr->fd);
+#endif
+
+ xfree((char *) _NXProxyConnInfoTab[ciptr->fd]);
+
+ _NXProxyConnInfoTab[ciptr->fd] = NULL;
+
+ ciptr->priv = NULL;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCloseConnInfo: Should now close the local descriptor [%d].\n",
+ ciptr->fd);
+#endif
+}
+
+#endif /* #ifdef TRANS_CLIENT */
+
+#if defined(TRANS_CLIENT) && defined(NX_TRANS_CHANGE)
+
+/*
+ * Check the congestion state of the NX transport
+ * and return 1 if there has been a change. This
+ * can be extended by adding a few counters track-
+ * ing the bandwidth usage of the X11 connection.
+ */
+
+int TRANS(SocketCongestionChange) (XtransConnInfo ciptr, int *state)
+{
+ int congestion;
+
+ _NXProxyConnInfo *proxy_conn;
+
+ PRMSG (3, "SocketCongestionChange(%x)\n", ciptr, 0, 0);
+
+ proxy_conn = (_NXProxyConnInfo *) ciptr->priv;
+
+ if (proxy_conn == NULL)
+ {
+#ifdef NX_TRANS_DEBUG
+ fprintf(stderr, "SocketCongestionChange: Descriptor [%d] doesn't appear to be a NX connection.\n",
+ ciptr->fd);
+#endif
+ return 0;
+ }
+
+#ifdef NX_TRANS_DEBUG
+ fprintf(stderr, "SocketCongestionChange: Checking congestion on fd [%d] with old state [%d].\n",
+ ciptr->fd, proxy_conn->congestion);
+#endif
+
+ congestion = NXTransCongestion(ciptr->fd);
+
+ if (congestion != proxy_conn->congestion)
+ {
+ proxy_conn->congestion = congestion;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCongestionChange: Change detected on fd [%d] with new state [%d].\n",
+ ciptr->fd, proxy_conn->congestion);
+#endif
+ return 1;
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCongestionChange: No change on fd [%d] with current state [%d].\n",
+ ciptr->fd, congestion);
+#endif
+ return 0;
+}
+
+#endif /* #if defined(TRANS_CLIENT) && defined(NX_TRANS_CHANGE) */
+
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+/*
+ * These are some utility function used by the real interface function below.
+ */
+
+static int
+TRANS(SocketSelectFamily) (int first, char *family)
+
+{
+ int i;
+
+ PRMSG (3,"SocketSelectFamily(%s)\n", family, 0, 0);
+
+ for (i = first + 1; i < NUMSOCKETFAMILIES;i++)
+ {
+ if (!strcmp (family, Sockettrans2devtab[i].transname))
+ return i;
+ }
+
+ return (first == -1 ? -2 : -1);
+}
+
+
+/*
+ * This function gets the local address of the socket and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(SocketINETGetAddr) (XtransConnInfo ciptr)
+
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_storage socknamev6;
+#endif
+ struct sockaddr_in socknamev4;
+ void *socknamePtr;
+#if defined(SVR4) || defined(__SCO__)
+ size_t namelen;
+#else
+ int namelen;
+#endif
+
+ PRMSG (3,"SocketINETGetAddr(%p)\n", ciptr, 0, 0);
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6)
+ {
+ namelen = sizeof(socknamev6);
+ socknamePtr = &socknamev6;
+ }
+ else
+#endif
+ {
+ namelen = sizeof(socknamev4);
+ socknamePtr = &socknamev4;
+ }
+
+ if (getsockname (ciptr->fd,(struct sockaddr *) socknamePtr,
+ (void *)&namelen) < 0)
+ {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ PRMSG (1,"SocketINETGetAddr: getsockname() failed: %d\n",
+ EGET(),0, 0);
+ return -1;
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if ((ciptr->addr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketINETGetAddr: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ return -1;
+ }
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6)
+ {
+ ciptr->family = ((struct sockaddr *)socknamePtr)->sa_family;
+ }
+ else
+#endif
+ {
+ ciptr->family = socknamev4.sin_family;
+ }
+ ciptr->addrlen = namelen;
+ memcpy (ciptr->addr, socknamePtr, ciptr->addrlen);
+
+ return 0;
+}
+
+
+/*
+ * This function gets the remote address of the socket and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr)
+
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_storage socknamev6;
+#endif
+ struct sockaddr_in socknamev4;
+ void *socknamePtr;
+#if defined(SVR4) || defined(__SCO__)
+ size_t namelen;
+#else
+ int namelen;
+#endif
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6 && ciptr->family == AF_INET6)
+ {
+ namelen = sizeof(socknamev6);
+ socknamePtr = &socknamev6;
+ }
+ else
+#endif
+ {
+ namelen = sizeof(socknamev4);
+ socknamePtr = &socknamev4;
+ }
+
+ PRMSG (3,"SocketINETGetPeerAddr(%p)\n", ciptr, 0, 0);
+
+ if (getpeername (ciptr->fd, (struct sockaddr *) socknamePtr,
+ (void *)&namelen) < 0)
+ {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ PRMSG (1,"SocketINETGetPeerAddr: getpeername() failed: %d\n",
+ EGET(), 0, 0);
+ return -1;
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if ((ciptr->peeraddr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketINETGetPeerAddr: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ return -1;
+ }
+
+ ciptr->peeraddrlen = namelen;
+ memcpy (ciptr->peeraddr, socknamePtr, ciptr->peeraddrlen);
+
+ return 0;
+}
+
+
+static XtransConnInfo
+TRANS(SocketOpen) (int i, int type)
+
+{
+ XtransConnInfo ciptr;
+
+ PRMSG (3,"SocketOpen(%d,%d)\n", i, type, 0);
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (getaddrinfo == NULL)
+ haveIPv6 = 0;
+
+ if (!haveIPv6 && Sockettrans2devtab[i].family == AF_INET6)
+ return NULL;
+#endif
+
+ if ((ciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketOpen: malloc failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ if ((ciptr->fd = socket(Sockettrans2devtab[i].family, type,
+ Sockettrans2devtab[i].protocol)) < 0
+#ifndef WIN32
+#if (defined(X11_t) && !defined(USE_POLL)) || defined(FS_t) || defined(FONT_t)
+ || ciptr->fd >= TRANS_OPEN_MAX
+#endif
+#endif
+ ) {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ PRMSG (2, "SocketOpen: socket() failed for %s\n",
+ Sockettrans2devtab[i].transname, 0, 0);
+
+ xfree ((char *) ciptr);
+ return NULL;
+ }
+
+#ifdef TCP_NODELAY
+ if (Sockettrans2devtab[i].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+ || Sockettrans2devtab[i].family == AF_INET6
+#endif
+ )
+ {
+ /*
+ * turn off TCP coalescence for INET sockets
+ */
+
+ int tmp = 1;
+ setsockopt (ciptr->fd, IPPROTO_TCP, TCP_NODELAY,
+ (char *) &tmp, sizeof (int));
+ }
+#endif
+
+ return ciptr;
+}
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(SocketReopen) (int i, int type, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+
+ PRMSG (3,"SocketReopen(%d,%d,%s)\n", type, fd, port);
+
+ if ((ciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketReopen: malloc failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ ciptr->fd = fd;
+
+ return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+/*
+ * These functions are the interface supplied in the Xtransport structure
+ */
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(SocketOpenCOTSClientBase) (char *transname, char *protocol,
+ char *host, char *port, int previndex)
+{
+ XtransConnInfo ciptr;
+ int i = previndex;
+
+ PRMSG (2, "SocketOpenCOTSClient(%s,%s,%s)\n",
+ protocol, host, port);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, transname)) >= 0) {
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ if ((!strcmp(protocol, "local") || !strcmp(protocol, "nx")) &&
+ (!strcasecmp(host, "nx") || !strncasecmp(host, "nx,", 3)))
+ {
+ ciptr = TRANS(SocketCreateConnInfo) ();
+
+ if (ciptr == NULL)
+ {
+ PRMSG (1, "SocketOpenCOTSClient: Unable to create the NX connection info for %s.\n",
+ transname, 0, 0);
+
+ return NULL;
+ }
+
+ ciptr->index = i;
+
+ return ciptr;
+ }
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+ if ((ciptr = TRANS(SocketOpen) (
+ i, Sockettrans2devtab[i].devcotsname)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketOpenCOTSClient: Unable to open socket for %s\n",
+ transname, 0, 0);
+ else
+ PRMSG (1,"SocketOpenCOTSClient: Unable to determine socket type for %s\n",
+ transname, 0, 0);
+ return NULL;
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ ciptr->priv = NULL;
+
+#endif
+
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+static XtransConnInfo
+TRANS(SocketOpenCOTSClient) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+{
+ return TRANS(SocketOpenCOTSClientBase)(
+ thistrans->TransName, protocol, host, port, -1);
+}
+
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,"SocketOpenCOTSServer(%s,%s,%s)\n", protocol, host, port);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+ if ((ciptr = TRANS(SocketOpen) (
+ i, Sockettrans2devtab[i].devcotsname)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketOpenCOTSServer: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketOpenCOTSServer: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+ /*
+ * Using this prevents the bind() check for an existing server listening
+ * on the same port, but it is required for other reasons.
+ */
+#ifdef SO_REUSEADDR
+
+ /*
+ * SO_REUSEADDR only applied to AF_INET && AF_INET6
+ */
+
+ if (Sockettrans2devtab[i].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+ || Sockettrans2devtab[i].family == AF_INET6
+#endif
+ )
+ {
+ int one = 1;
+ setsockopt (ciptr->fd, SOL_SOCKET, SO_REUSEADDR,
+ (char *) &one, sizeof (int));
+ }
+#endif
+#ifdef IPV6_V6ONLY
+ if (Sockettrans2devtab[i].family == AF_INET6)
+ {
+ int one = 1;
+ setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int));
+ }
+#endif
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(SocketOpenCLTSClient) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,"SocketOpenCLTSClient(%s,%s,%s)\n", protocol, host, port);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ if ((!strcmp(protocol, "local") || !strcmp(protocol, "nx")) &&
+ (!strcasecmp(host, "nx") || !strncasecmp(host, "nx,", 3)))
+ {
+ ciptr = TRANS(SocketCreateConnInfo) ();
+
+ if (ciptr == NULL)
+ {
+ PRMSG (1, "SocketOpenCLTSClient: Unable to create the NX connection info for %s.\n",
+ thistrans->TransName, 0, 0);
+
+ return NULL;
+ }
+
+ ciptr->index = i;
+
+ return ciptr;
+ }
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+ if ((ciptr = TRANS(SocketOpen) (
+ i, Sockettrans2devtab[i].devcotsname)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketOpenCLTSClient: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketOpenCLTSClient: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ ciptr->priv = NULL;
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(SocketOpenCLTSServer) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,"SocketOpenCLTSServer(%s,%s,%s)\n", protocol, host, port);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+ if ((ciptr = TRANS(SocketOpen) (
+ i, Sockettrans2devtab[i].devcotsname)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketOpenCLTSServer: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketOpenCLTSServer: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+#ifdef IPV6_V6ONLY
+ if (Sockettrans2devtab[i].family == AF_INET6)
+ {
+ int one = 1;
+ setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int));
+ }
+#endif
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(SocketReopenCOTSServer) (Xtransport *thistrans, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,
+ "SocketReopenCOTSServer(%d, %s)\n", fd, port, 0);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+ if ((ciptr = TRANS(SocketReopen) (
+ i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketReopenCOTSServer: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketReopenCOTSServer: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+static XtransConnInfo
+TRANS(SocketReopenCLTSServer) (Xtransport *thistrans, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,
+ "SocketReopenCLTSServer(%d, %s)\n", fd, port, 0);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+ if ((ciptr = TRANS(SocketReopen) (
+ i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketReopenCLTSServer: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketReopenCLTSServer: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+static int
+TRANS(SocketSetOption) (XtransConnInfo ciptr, int option, int arg)
+
+{
+ PRMSG (2,"SocketSetOption(%d,%d,%d)\n", ciptr->fd, option, arg);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketSetOption: WARNING! Not setting option [%d] with value [%d] on descriptor [%d].\n",
+ option, arg, ciptr -> fd);
+#endif
+
+ return -1;
+}
+
+#ifdef UNIXCONN
+static int
+set_sun_path(const char *port, const char *upath, char *path)
+{
+ struct sockaddr_un s;
+ int maxlen = sizeof(s.sun_path) - 1;
+
+ if (!port || !*port || !path)
+ return -1;
+
+ if (*port == '/') { /* a full pathname */
+ if (strlen(port) > maxlen)
+ return -1;
+ sprintf(path, "%s", port);
+ } else {
+ if (strlen(port) + strlen(upath) > maxlen)
+ return -1;
+ sprintf(path, "%s%s", upath, port);
+ }
+ return 0;
+}
+#endif
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(SocketCreateListener) (XtransConnInfo ciptr,
+ struct sockaddr *sockname,
+ int socknamelen, unsigned int flags)
+
+{
+ int namelen = socknamelen;
+ int fd = ciptr->fd;
+ int retry;
+
+ PRMSG (3, "SocketCreateListener(%x,%p)\n", ciptr, fd, 0);
+
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+ || Sockettrans2devtab[ciptr->index].family == AF_INET6
+#endif
+ )
+ retry = 20;
+ else
+ retry = 0;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "SocketCreateListener: Creating listener for ciptr at [%p] on path [%s].\n",
+ (void *) ciptr, ((struct sockaddr_un *) sockname)->sun_family == AF_UNIX ?
+ ((struct sockaddr_un *) sockname)->sun_path : "TCP");
+#endif
+ while (bind (fd, (struct sockaddr *) sockname, namelen) < 0)
+ {
+ if (errno == EADDRINUSE) {
+ if (flags & ADDR_IN_USE_ALLOWED)
+ break;
+ else
+ return TRANS_ADDR_IN_USE;
+ }
+
+ if (retry-- == 0) {
+ PRMSG (1, "SocketCreateListener: failed to bind listener\n",
+ 0, 0, 0);
+ close (fd);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+#ifdef SO_REUSEADDR
+ sleep (1);
+#else
+ sleep (10);
+#endif /* SO_REUSEDADDR */
+ }
+
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+ || Sockettrans2devtab[ciptr->index].family == AF_INET6
+#endif
+ ) {
+#ifdef SO_DONTLINGER
+ setsockopt (fd, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0);
+#else
+#ifdef SO_LINGER
+ {
+ static int linger[2] = { 0, 0 };
+ setsockopt (fd, SOL_SOCKET, SO_LINGER,
+ (char *) linger, sizeof (linger));
+ }
+#endif
+#endif
+}
+
+ if (listen (fd, BACKLOG) < 0)
+ {
+ PRMSG (1, "SocketCreateListener: listen() failed\n", 0, 0, 0);
+ close (fd);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ /* Set a flag to indicate that this connection is a listener */
+
+ ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS);
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "SocketCreateListener: Set flags to [%d] for ciptr [%p].\n",
+ ciptr->flags, (void *) ciptr);
+#endif
+
+ return 0;
+}
+
+#ifdef TCPCONN
+static int
+TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags)
+
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_storage sockname;
+#else
+ struct sockaddr_in sockname;
+#endif
+ unsigned short sport;
+ int namelen = sizeof(sockname);
+ int status;
+ long tmpport;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgetservbynameparams sparams;
+#endif
+ struct servent *servp;
+
+#ifdef X11_t
+ char portbuf[PORTBUFSIZE];
+#endif
+
+ PRMSG (2, "SocketINETCreateListener(%s)\n", port, 0, 0);
+
+#ifdef X11_t
+ /*
+ * X has a well known port, that is transport dependent. It is easier
+ * to handle it here, than try and come up with a transport independent
+ * representation that can be passed in and resolved the usual way.
+ *
+ * The port that is passed here is really a string containing the idisplay
+ * from ConnectDisplay().
+ */
+
+ if (is_numeric (port))
+ {
+ /* fixup the server port address */
+ tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);
+ sprintf (portbuf,"%lu", tmpport);
+ port = portbuf;
+ }
+#endif
+
+ if (port && *port)
+ {
+ /* Check to see if the port string is just a number (handles X11) */
+
+ if (!is_numeric (port))
+ {
+ if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL)
+ {
+ PRMSG (1,
+ "SocketINETCreateListener: Unable to get service for %s\n",
+ port, 0, 0);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+ /* we trust getservbyname to return a valid number */
+ sport = servp->s_port;
+ }
+ else
+ {
+ tmpport = strtol (port, (char**)NULL, 10);
+ /*
+ * check that somehow the port address isn't negative or in
+ * the range of reserved port addresses. This can happen and
+ * be very bad if the server is suid-root and the user does
+ * something (dumb) like `X :60049`.
+ */
+ if (tmpport < 1024 || tmpport > USHRT_MAX)
+ return TRANS_CREATE_LISTENER_FAILED;
+
+ sport = (unsigned short) tmpport;
+ }
+ }
+ else
+ sport = 0;
+
+ bzero(&sockname, sizeof(sockname));
+#if defined(IPv6) && defined(AF_INET6)
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET) {
+ namelen = sizeof (struct sockaddr_in);
+#ifdef BSD44SOCKETS
+ ((struct sockaddr_in *)&sockname)->sin_len = namelen;
+#endif
+ ((struct sockaddr_in *)&sockname)->sin_family = AF_INET;
+ ((struct sockaddr_in *)&sockname)->sin_port = htons(sport);
+ ((struct sockaddr_in *)&sockname)->sin_addr.s_addr = htonl(INADDR_ANY);
+ } else {
+ namelen = sizeof (struct sockaddr_in6);
+#ifdef SIN6_LEN
+ ((struct sockaddr_in6 *)&sockname)->sin6_len = sizeof(sockname);
+#endif
+ ((struct sockaddr_in6 *)&sockname)->sin6_family = AF_INET6;
+ ((struct sockaddr_in6 *)&sockname)->sin6_port = htons(sport);
+ ((struct sockaddr_in6 *)&sockname)->sin6_addr = in6addr_any;
+ }
+#else
+#ifdef BSD44SOCKETS
+ sockname.sin_len = sizeof (sockname);
+#endif
+ sockname.sin_family = AF_INET;
+ sockname.sin_port = htons (sport);
+ sockname.sin_addr.s_addr = htonl (INADDR_ANY);
+#endif
+
+ if ((status = TRANS(SocketCreateListener) (ciptr,
+ (struct sockaddr *) &sockname, namelen, flags)) < 0)
+ {
+ PRMSG (1,
+ "SocketINETCreateListener: ...SocketCreateListener() failed\n",
+ 0, 0, 0);
+ return status;
+ }
+
+ if (TRANS(SocketINETGetAddr) (ciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETCreateListener: ...SocketINETGetAddr() failed\n",
+ 0, 0, 0);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ return 0;
+}
+
+#endif /* SOCKCONN */
+
+
+#ifdef UNIXCONN
+
+static int
+TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
+ unsigned int flags)
+
+{
+ struct sockaddr_un sockname;
+ int namelen;
+ int oldUmask;
+ int status;
+ unsigned int mode;
+
+ PRMSG (2, "SocketUNIXCreateListener(%s)\n",
+ port ? port : "NULL", 0, 0);
+
+ /* Make sure the directory is created */
+
+ oldUmask = umask (0);
+
+#ifdef UNIX_DIR
+#ifdef HAS_STICKY_DIR_BIT
+ mode = 01777;
+#else
+ mode = 0777;
+#endif
+#ifdef NX_TRANS_SOCKET
+ if (trans_mkdir(_NXGetUnixDir(UNIX_DIR), mode) == -1) {
+ PRMSG (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n",
+ _NXGetUnixDir(UNIX_DIR), errno, 0);
+#else
+ if (trans_mkdir(UNIX_DIR, mode) == -1) {
+ PRMSG (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n",
+ UNIX_DIR, errno, 0);
+#endif
+ (void) umask (oldUmask);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+#endif
+
+ sockname.sun_family = AF_UNIX;
+
+ if (port && *port) {
+#ifdef NX_TRANS_SOCKET
+ if (set_sun_path(port, _NXGetUnixPath(UNIX_PATH), sockname.sun_path) != 0) {
+#else
+ if (set_sun_path(port, UNIX_PATH, sockname.sun_path) != 0) {
+#endif
+ PRMSG (1, "SocketUNIXCreateListener: path too long\n", 0, 0, 0);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+ } else {
+#ifdef NX_TRANS_SOCKET
+ sprintf (sockname.sun_path, "%s%ld", _NXGetUnixPath(UNIX_PATH), (long)getpid());
+#else
+ sprintf (sockname.sun_path, "%s%ld", UNIX_PATH, (long)getpid());
+#endif
+ }
+
+#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) && !defined(Lynx)
+ sockname.sun_len = strlen(sockname.sun_path);
+ namelen = SUN_LEN(&sockname);
+#else
+ namelen = strlen(sockname.sun_path) + sizeof(sockname.sun_family);
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "SocketUNIXCreateListener: Unlinking path [%s] for ciptr at [%p].\n",
+ sockname.sun_path, (void *) ciptr);
+#endif
+ unlink (sockname.sun_path);
+
+ if ((status = TRANS(SocketCreateListener) (ciptr,
+ (struct sockaddr *) &sockname, namelen, flags)) < 0)
+ {
+ PRMSG (1,
+ "SocketUNIXCreateListener: ...SocketCreateListener() failed\n",
+ 0, 0, 0);
+ (void) umask (oldUmask);
+ return status;
+ }
+
+ /*
+ * Now that the listener is esablished, create the addr info for
+ * this connection. getpeername() doesn't work for UNIX Domain Sockets
+ * on some systems (hpux at least), so we will just do it manually, instead
+ * of calling something like TRANS(SocketUNIXGetAddr).
+ */
+
+ namelen = sizeof (sockname); /* this will always make it the same size */
+
+ if ((ciptr->addr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketUNIXCreateListener: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ (void) umask (oldUmask);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ ciptr->family = sockname.sun_family;
+ ciptr->addrlen = namelen;
+ memcpy (ciptr->addr, &sockname, ciptr->addrlen);
+
+ (void) umask (oldUmask);
+
+ return 0;
+}
+
+
+static int
+TRANS(SocketUNIXResetListener) (XtransConnInfo ciptr)
+
+{
+ /*
+ * See if the unix domain socket has disappeared. If it has, recreate it.
+ */
+
+ struct sockaddr_un *unsock = (struct sockaddr_un *) ciptr->addr;
+ struct stat statb;
+ int status = TRANS_RESET_NOOP;
+ unsigned int mode;
+
+ PRMSG (3, "SocketUNIXResetListener(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+ if (stat (unsock->sun_path, &statb) == -1 ||
+ ((statb.st_mode & S_IFMT) !=
+#if (defined (sun) && defined(SVR4)) || defined(NCR) || defined(SCO325) || !defined(S_IFSOCK)
+ S_IFIFO))
+#else
+ S_IFSOCK))
+#endif
+ {
+ int oldUmask = umask (0);
+
+#ifdef UNIX_DIR
+#ifdef HAS_STICKY_DIR_BIT
+ mode = 01777;
+#else
+ mode = 0777;
+#endif
+#ifdef NX_TRANS_SOCKET
+ if (trans_mkdir(_NXGetUnixDir(UNIX_DIR), mode) == -1) {
+ PRMSG (1, "SocketUNIXResetListener: mkdir(%s) failed, errno = %d\n",
+ _NXGetUnixDir(UNIX_DIR), errno, 0);
+#else
+ if (trans_mkdir(UNIX_DIR, mode) == -1) {
+ PRMSG (1, "SocketUNIXResetListener: mkdir(%s) failed, errno = %d\n",
+ UNIX_DIR, errno, 0);
+#endif
+ (void) umask (oldUmask);
+ return TRANS_RESET_FAILURE;
+ }
+#endif
+
+ close (ciptr->fd);
+ unlink (unsock->sun_path);
+
+ if ((ciptr->fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
+ {
+ TRANS(FreeConnInfo) (ciptr);
+ (void) umask (oldUmask);
+ return TRANS_RESET_FAILURE;
+ }
+
+ if (bind (ciptr->fd, (struct sockaddr *) unsock, ciptr->addrlen) < 0)
+ {
+ close (ciptr->fd);
+ TRANS(FreeConnInfo) (ciptr);
+ return TRANS_RESET_FAILURE;
+ }
+
+ if (listen (ciptr->fd, BACKLOG) < 0)
+ {
+ close (ciptr->fd);
+ TRANS(FreeConnInfo) (ciptr);
+ (void) umask (oldUmask);
+ return TRANS_RESET_FAILURE;
+ }
+
+ umask (oldUmask);
+
+ status = TRANS_RESET_NEW_FD;
+ }
+
+ return status;
+}
+
+#endif /* UNIXCONN */
+
+
+#ifdef TCPCONN
+
+static XtransConnInfo
+TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status)
+
+{
+ XtransConnInfo newciptr;
+ struct sockaddr_in sockname;
+ int namelen = sizeof(sockname);
+
+ PRMSG (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+ if ((newciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketINETAccept: malloc failed\n", 0, 0, 0);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+ if ((newciptr->fd = accept (ciptr->fd,
+ (struct sockaddr *) &sockname, (void *)&namelen)) < 0)
+ {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ PRMSG (1, "SocketINETAccept: accept() failed\n", 0, 0, 0);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_FAILED;
+ return NULL;
+ }
+
+#ifdef TCP_NODELAY
+ {
+ /*
+ * turn off TCP coalescence for INET sockets
+ */
+
+ int tmp = 1;
+ setsockopt (newciptr->fd, IPPROTO_TCP, TCP_NODELAY,
+ (char *) &tmp, sizeof (int));
+ }
+#endif
+
+ /*
+ * Get this address again because the transport may give a more
+ * specific address now that a connection is established.
+ */
+
+ if (TRANS(SocketINETGetAddr) (newciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETAccept: ...SocketINETGetAddr() failed:\n",
+ 0, 0, 0);
+ close (newciptr->fd);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ if (TRANS(SocketINETGetPeerAddr) (newciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETAccept: ...SocketINETGetPeerAddr() failed:\n",
+ 0, 0, 0);
+ close (newciptr->fd);
+ if (newciptr->addr) xfree (newciptr->addr);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ *status = 0;
+
+ return newciptr;
+}
+
+#endif /* TCPCONN */
+
+
+#ifdef UNIXCONN
+static XtransConnInfo
+TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
+
+{
+ XtransConnInfo newciptr;
+ struct sockaddr_un sockname;
+#if defined(SVR4) || defined(__SCO__)
+ size_t namelen = sizeof sockname;
+#else
+ int namelen = sizeof sockname;
+#endif
+
+ PRMSG (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+ if ((newciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketUNIXAccept: malloc() failed\n", 0, 0, 0);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+ if ((newciptr->fd = accept (ciptr->fd,
+ (struct sockaddr *) &sockname, (void *)&namelen)) < 0)
+ {
+ PRMSG (1, "SocketUNIXAccept: accept() failed\n", 0, 0, 0);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_FAILED;
+ return NULL;
+ }
+
+ /*
+ * Get the socket name and the peer name from the listener socket,
+ * since this is unix domain.
+ */
+
+ if ((newciptr->addr = (char *) xalloc (ciptr->addrlen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketUNIXAccept: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ close (newciptr->fd);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+
+ newciptr->addrlen = ciptr->addrlen;
+ memcpy (newciptr->addr, ciptr->addr, newciptr->addrlen);
+
+ if ((newciptr->peeraddr = (char *) xalloc (ciptr->addrlen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketUNIXAccept: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ close (newciptr->fd);
+ if (newciptr->addr) xfree (newciptr->addr);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+ newciptr->peeraddrlen = ciptr->addrlen;
+ memcpy (newciptr->peeraddr, ciptr->addr, newciptr->addrlen);
+
+ newciptr->family = AF_UNIX;
+
+ *status = 0;
+
+ return newciptr;
+}
+
+#endif /* UNIXCONN */
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+#ifdef TCPCONN
+
+#if defined(IPv6) && defined(AF_INET6)
+struct addrlist {
+ struct addrinfo * addr;
+ struct addrinfo * firstaddr;
+ char port[PORTBUFSIZE];
+ char host[MAXHOSTNAMELEN];
+};
+static struct addrlist *addrlist = NULL;
+#endif
+
+
+static int
+TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port)
+
+{
+ struct sockaddr * socketaddr = NULL;
+ int socketaddrlen = 0;
+ int res;
+#if defined(IPv6) && defined(AF_INET6)
+ struct addrinfo hints;
+ char ntopbuf[INET6_ADDRSTRLEN];
+ int resetonce = 0;
+#endif
+ struct sockaddr_in sockname;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+ _Xgetservbynameparams sparams;
+#endif
+ struct hostent *hostp;
+ struct servent *servp;
+ unsigned long tmpaddr;
+#ifdef X11_t
+ char portbuf[PORTBUFSIZE];
+#endif
+
+ long tmpport;
+ char hostnamebuf[256]; /* tmp space */
+
+ PRMSG (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port);
+
+ if (!host)
+ {
+ hostnamebuf[0] = '\0';
+ (void) TRANS(GetHostname) (hostnamebuf, sizeof hostnamebuf);
+ host = hostnamebuf;
+ }
+
+#ifdef X11_t
+ /*
+ * X has a well known port, that is transport dependent. It is easier
+ * to handle it here, than try and come up with a transport independent
+ * representation that can be passed in and resolved the usual way.
+ *
+ * The port that is passed here is really a string containing the idisplay
+ * from ConnectDisplay().
+ */
+
+ if (is_numeric (port))
+ {
+ tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);
+ sprintf (portbuf, "%lu", tmpport);
+ port = portbuf;
+ }
+#endif
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6) {
+ if (addrlist != NULL) {
+ if (strcmp(host,addrlist->host) || strcmp(port,addrlist->port)) {
+ if (addrlist->firstaddr)
+ freeaddrinfo(addrlist->firstaddr);
+ addrlist->firstaddr = NULL;
+ }
+ } else {
+ addrlist = malloc(sizeof(struct addrlist));
+ addrlist->firstaddr = NULL;
+ }
+
+ if (addrlist->firstaddr == NULL) {
+ strncpy(addrlist->port, port, sizeof(addrlist->port));
+ addrlist->port[sizeof(addrlist->port) - 1] = '\0';
+ strncpy(addrlist->host, host, sizeof(addrlist->host));
+ addrlist->host[sizeof(addrlist->host) - 1] = '\0';
+
+ bzero(&hints,sizeof(hints));
+ hints.ai_socktype = Sockettrans2devtab[ciptr->index].devcotsname;
+
+ res = getaddrinfo(host,port,&hints,&addrlist->firstaddr);
+ if (res != 0) {
+ PRMSG (1, "SocketINETConnect() can't get address "
+ "for %s:%s: %s\n", host, port, gai_strerror(res));
+ ESET(EINVAL);
+ return TRANS_CONNECT_FAILED;
+ }
+ for (res = 0, addrlist->addr = addrlist->firstaddr;
+ addrlist->addr ; res++) {
+ addrlist->addr = addrlist->addr->ai_next;
+ }
+ PRMSG(4,"Got New Address list with %d addresses\n", res, 0, 0);
+ res = 0;
+ addrlist->addr = NULL;
+ }
+
+ while (socketaddr == NULL) {
+ if (addrlist->addr == NULL) {
+ if (resetonce) {
+ /* Already checked entire list - no usable addresses */
+ PRMSG (1, "SocketINETConnect() no usable address "
+ "for %s:%s\n", host, port, 0);
+ return TRANS_CONNECT_FAILED;
+ } else {
+ /* Go back to beginning of list */
+ resetonce = 1;
+ addrlist->addr = addrlist->firstaddr;
+ }
+ }
+
+ socketaddr = addrlist->addr->ai_addr;
+ socketaddrlen = addrlist->addr->ai_addrlen;
+
+ if (addrlist->addr->ai_family == AF_INET) {
+ struct sockaddr_in *sin = (struct sockaddr_in *) socketaddr;
+
+ PRMSG (4,"SocketINETConnect() sockname.sin_addr = %s\n",
+ inet_ntop(addrlist->addr->ai_family,&sin->sin_addr,
+ ntopbuf,sizeof(ntopbuf)), 0, 0);
+
+ PRMSG (4,"SocketINETConnect() sockname.sin_port = %d\n",
+ ntohs(sin->sin_port), 0, 0);
+
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET6) {
+ if (strcmp(Sockettrans2devtab[ciptr->index].transname,
+ "tcp") == 0) {
+ XtransConnInfo newciptr;
+
+ /*
+ * Our socket is an IPv6 socket, but the address is
+ * IPv4. Close it and get an IPv4 socket. This is
+ * needed for IPv4 connections to work on platforms
+ * that don't allow IPv4 over IPv6 sockets.
+ */
+ TRANS(SocketINETClose)(ciptr);
+ newciptr = TRANS(SocketOpenCOTSClientBase)(
+ "tcp", "tcp", host, port, ciptr->index);
+ if (newciptr)
+ ciptr->fd = newciptr->fd;
+ if (!newciptr ||
+ Sockettrans2devtab[newciptr->index].family !=
+ AF_INET) {
+ socketaddr = NULL;
+ PRMSG (4,"SocketINETConnect() Cannot get IPv4 "
+ " socketfor IPv4 address\n", 0,0,0);
+ }
+ if (newciptr)
+ xfree(newciptr);
+ } else {
+ socketaddr = NULL;
+ PRMSG (4,"SocketINETConnect Skipping IPv4 address\n",
+ 0,0,0);
+ }
+ }
+ } else if (addrlist->addr->ai_family == AF_INET6) {
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) socketaddr;
+
+ PRMSG (4,"SocketINETConnect() sockname.sin6_addr = %s\n",
+ inet_ntop(addrlist->addr->ai_family,
+ &sin6->sin6_addr,ntopbuf,sizeof(ntopbuf)),
+ 0, 0);
+ PRMSG (4,"SocketINETConnect() sockname.sin6_port = %d\n",
+ ntohs(sin6->sin6_port), 0, 0);
+
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET) {
+ if (strcmp(Sockettrans2devtab[ciptr->index].transname,
+ "tcp") == 0) {
+ XtransConnInfo newciptr;
+
+ /*
+ * Close the IPv4 socket and try to open an IPv6 socket.
+ */
+ TRANS(SocketINETClose)(ciptr);
+ newciptr = TRANS(SocketOpenCOTSClientBase)(
+ "tcp", "tcp", host, port, -1);
+ if (newciptr)
+ ciptr->fd = newciptr->fd;
+ if (!newciptr ||
+ Sockettrans2devtab[newciptr->index].family !=
+ AF_INET6) {
+ socketaddr = NULL;
+ PRMSG (4,"SocketINETConnect() Cannot get IPv6 "
+ "socket for IPv6 address\n", 0,0,0);
+ }
+ if (newciptr)
+ xfree(newciptr);
+ }
+ else
+ {
+ socketaddr = NULL;
+ PRMSG (4,"SocketINETConnect() Skipping IPv6 address\n",
+ 0,0,0);
+ }
+ }
+ } else {
+ socketaddr = NULL; /* Unsupported address type */
+ }
+ if (socketaddr == NULL) {
+ addrlist->addr = addrlist->addr->ai_next;
+ }
+ }
+ } else
+#endif
+ {
+ /*
+ * Build the socket name.
+ */
+
+#ifdef BSD44SOCKETS
+ sockname.sin_len = sizeof (struct sockaddr_in);
+#endif
+ sockname.sin_family = AF_INET;
+
+ /*
+ * fill in sin_addr
+ */
+
+#ifndef INADDR_NONE
+#define INADDR_NONE ((in_addr_t) 0xffffffff)
+#endif
+
+ /* check for ww.xx.yy.zz host string */
+
+ if (isascii (host[0]) && isdigit (host[0])) {
+ tmpaddr = inet_addr (host); /* returns network byte order */
+ } else {
+ tmpaddr = INADDR_NONE;
+ }
+
+ PRMSG (4,"SocketINETConnect() inet_addr(%s) = %x\n", host, tmpaddr, 0);
+
+ if (tmpaddr == INADDR_NONE) {
+ if ((hostp = _XGethostbyname(host,hparams)) == NULL) {
+ PRMSG (1,"SocketINETConnect: Can't get address for %s\n",
+ host, 0, 0);
+ ESET(EINVAL);
+ return TRANS_CONNECT_FAILED;
+ }
+ if (hostp->h_addrtype != AF_INET) { /* is IP host? */
+ PRMSG (1,"SocketINETConnect: not INET host%s\n", host, 0, 0);
+ ESET(EPROTOTYPE);
+ return TRANS_CONNECT_FAILED;
+ }
+
+#if defined(CRAY) && defined(OLDTCP)
+ /* Only Cray UNICOS3 and UNICOS4 will define this */
+ {
+ long t;
+ memcpy ((char *)&t, (char *) hostp->h_addr, sizeof (t));
+ sockname.sin_addr = t;
+ }
+#else
+ memcpy ((char *) &sockname.sin_addr, (char *) hostp->h_addr,
+ sizeof (sockname.sin_addr));
+#endif /* CRAY and OLDTCP */
+
+ } else {
+#if defined(CRAY) && defined(OLDTCP)
+ /* Only Cray UNICOS3 and UNICOS4 will define this */
+ sockname.sin_addr = tmpaddr;
+#else
+ sockname.sin_addr.s_addr = tmpaddr;
+#endif /* CRAY and OLDTCP */
+ }
+
+ /*
+ * fill in sin_port
+ */
+
+ /* Check for number in the port string */
+
+ if (!is_numeric (port)) {
+ if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL) {
+ PRMSG (1,"SocketINETConnect: can't get service for %s\n",
+ port, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+ sockname.sin_port = htons (servp->s_port);
+ } else {
+ tmpport = strtol (port, (char**)NULL, 10);
+ if (tmpport < 1024 || tmpport > USHRT_MAX)
+ return TRANS_CONNECT_FAILED;
+ sockname.sin_port = htons (((unsigned short) tmpport));
+ }
+
+ PRMSG (4,"SocketINETConnect: sockname.sin_port = %d\n",
+ ntohs(sockname.sin_port), 0, 0);
+ socketaddr = (struct sockaddr *) &sockname;
+ socketaddrlen = sizeof(sockname);
+ }
+
+ /*
+ * Turn on socket keepalive so the client process will eventually
+ * be notified with a SIGPIPE signal if the display server fails
+ * to respond to a periodic transmission of messages
+ * on the connected socket.
+ * This is useful to avoid hung application processes when the
+ * processes are not spawned from the xdm session and
+ * the display server terminates abnormally.
+ * (Someone turned off the power switch.)
+ */
+
+ {
+ int tmp = 1;
+ setsockopt (ciptr->fd, SOL_SOCKET, SO_KEEPALIVE,
+ (char *) &tmp, sizeof (int));
+ }
+
+ /*
+ * Do the connect()
+ */
+
+ if (connect (ciptr->fd, socketaddr, socketaddrlen ) < 0)
+ {
+#ifdef WIN32
+ int olderrno = WSAGetLastError();
+#else
+ int olderrno = errno;
+#endif
+
+ /*
+ * If the error was ECONNREFUSED, the server may be overloaded
+ * and we should try again.
+ *
+ * If the error was EWOULDBLOCK or EINPROGRESS then the socket
+ * was non-blocking and we should poll using select
+ *
+ * If the error was EINTR, the connect was interrupted and we
+ * should try again.
+ *
+ * If multiple addresses are found for a host then we should
+ * try to connect again with a different address for a larger
+ * number of errors that made us quit before, since those
+ * could be caused by trying to use an IPv6 address to contact
+ * a machine with an IPv4-only server or other reasons that
+ * only affect one of a set of addresses.
+ */
+
+ if (olderrno == ECONNREFUSED || olderrno == EINTR
+#if defined(IPv6) && defined(AF_INET6)
+ || (haveIPv6 && ((addrlist->addr->ai_next != NULL) ||
+ (addrlist->addr != addrlist->firstaddr)) &&
+ (olderrno == ENETUNREACH || olderrno == EAFNOSUPPORT ||
+ olderrno == EADDRNOTAVAIL || olderrno == ETIMEDOUT
+#if defined(EHOSTDOWN)
+ || olderrno == EHOSTDOWN
+#endif
+ ))
+#endif
+ )
+ res = TRANS_TRY_CONNECT_AGAIN;
+ else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
+ res = TRANS_IN_PROGRESS;
+ else
+ {
+ PRMSG (2,"SocketINETConnect: Can't connect: errno = %d\n",
+ olderrno,0, 0);
+
+ res = TRANS_CONNECT_FAILED;
+ }
+ } else {
+ res = 0;
+
+
+ /*
+ * Sync up the address fields of ciptr.
+ */
+
+ if (TRANS(SocketINETGetAddr) (ciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETConnect: ...SocketINETGetAddr() failed:\n",
+ 0, 0, 0);
+ res = TRANS_CONNECT_FAILED;
+ }
+
+ else if (TRANS(SocketINETGetPeerAddr) (ciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETConnect: ...SocketINETGetPeerAddr() failed:\n",
+ 0, 0, 0);
+ res = TRANS_CONNECT_FAILED;
+ }
+ }
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6 && res != 0) {
+ addrlist->addr = addrlist->addr->ai_next;
+ }
+#endif
+
+ return res;
+}
+
+#endif /* TCPCONN */
+
+
+
+#ifdef UNIXCONN
+
+/*
+ * Make sure 'host' is really local.
+ */
+
+static int
+UnixHostReallyLocal (char *host)
+
+{
+ char hostnamebuf[256];
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (getaddrinfo == NULL)
+ haveIPv6 = 0;
+#endif
+
+ TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf));
+
+ if (strcmp (hostnamebuf, host) == 0)
+ {
+ return (1);
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if (haveIPv6)
+ {
+ struct addrinfo *localhostaddr;
+ struct addrinfo *otherhostaddr;
+ struct addrinfo *i, *j;
+ int equiv = 0;
+
+ if (getaddrinfo(hostnamebuf, NULL, NULL, &localhostaddr) != 0)
+ return 0;
+ if (getaddrinfo(host, NULL, NULL, &otherhostaddr) != 0) {
+ freeaddrinfo(localhostaddr);
+ return 0;
+ }
+
+ for (i = localhostaddr; i != NULL && equiv == 0; i = i->ai_next) {
+ for (j = otherhostaddr; j != NULL && equiv == 0; j = j->ai_next) {
+ if (i->ai_family == j->ai_family) {
+ if (i->ai_family == AF_INET) {
+ struct sockaddr_in *sinA
+ = (struct sockaddr_in *) i->ai_addr;
+ struct sockaddr_in *sinB
+ = (struct sockaddr_in *) j->ai_addr;
+ struct in_addr *A = &sinA->sin_addr;
+ struct in_addr *B = &sinB->sin_addr;
+
+ if (memcmp(A,B,sizeof(struct in_addr)) == 0) {
+ equiv = 1;
+ }
+ } else if (i->ai_family == AF_INET6) {
+ struct sockaddr_in6 *sinA
+ = (struct sockaddr_in6 *) i->ai_addr;
+ struct sockaddr_in6 *sinB
+ = (struct sockaddr_in6 *) j->ai_addr;
+ struct in6_addr *A = &sinA->sin6_addr;
+ struct in6_addr *B = &sinB->sin6_addr;
+
+ if (memcmp(A,B,sizeof(struct in6_addr)) == 0) {
+ equiv = 1;
+ }
+ }
+ }
+ }
+ }
+
+ freeaddrinfo(localhostaddr);
+ freeaddrinfo(otherhostaddr);
+ return equiv;
+ }
+#endif
+ else
+ {
+ /*
+ * A host may have more than one network address. If any of the
+ * network addresses of 'host' (specified to the connect call)
+ * match any of the network addresses of 'hostname' (determined
+ * by TRANS(GetHostname)), then the two hostnames are equivalent,
+ * and we know that 'host' is really a local host.
+ */
+ char specified_local_addr_list[10][4];
+ int scount, equiv, i, j;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ struct hostent *hostp;
+
+ if ((hostp = _XGethostbyname (host,hparams)) == NULL)
+ return (0);
+
+ scount = 0;
+ while (hostp->h_addr_list[scount] && scount <= 8)
+ {
+ /*
+ * The 2nd call to gethostname() overrides the data
+ * from the 1st call, so we must save the address list.
+ */
+
+ specified_local_addr_list[scount][0] =
+ hostp->h_addr_list[scount][0];
+ specified_local_addr_list[scount][1] =
+ hostp->h_addr_list[scount][1];
+ specified_local_addr_list[scount][2] =
+ hostp->h_addr_list[scount][2];
+ specified_local_addr_list[scount][3] =
+ hostp->h_addr_list[scount][3];
+ scount++;
+ }
+ if ((hostp = _XGethostbyname (hostnamebuf,hparams)) == NULL)
+ return (0);
+
+ equiv = 0;
+ i = 0;
+
+ while (i < scount && !equiv)
+ {
+ j = 0;
+
+ while (hostp->h_addr_list[j])
+ {
+ if ((specified_local_addr_list[i][0] ==
+ hostp->h_addr_list[j][0]) &&
+ (specified_local_addr_list[i][1] ==
+ hostp->h_addr_list[j][1]) &&
+ (specified_local_addr_list[i][2] ==
+ hostp->h_addr_list[j][2]) &&
+ (specified_local_addr_list[i][3] ==
+ hostp->h_addr_list[j][3]))
+ {
+ /* They're equal, so we're done */
+
+ equiv = 1;
+ break;
+ }
+
+ j++;
+ }
+
+ i++;
+ }
+ return (equiv);
+ }
+}
+
+static int
+TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
+
+{
+ struct sockaddr_un sockname;
+ int namelen;
+
+#if defined(hpux) && defined(X11_t)
+ struct sockaddr_un old_sockname;
+ int old_namelen;
+#endif
+
+
+ PRMSG (2,"SocketUNIXConnect(%d,%s,%s)\n", ciptr->fd, host, port);
+
+ /*
+ * Make sure 'host' is really local. If not, we return failure.
+ * The reason we make this check is because a process may advertise
+ * a "local" network ID for which it can accept connections, but if
+ * a process on a remote machine tries to connect to this network ID,
+ * we know for sure it will fail.
+ */
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+ if (strcmp(host, "unix") != 0 && strcasecmp(host, "nx") != 0 &&
+ strncasecmp(host, "nx,", 3) != 0 && !UnixHostReallyLocal (host))
+#else
+ if (strcmp (host, "unix") != 0 && !UnixHostReallyLocal (host))
+#endif
+ {
+ PRMSG (1,
+ "SocketUNIXConnect: Cannot connect to non-local host %s\n",
+ host, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+
+ /*
+ * Check the port.
+ */
+
+ if (!port || !*port)
+ {
+ PRMSG (1,"SocketUNIXConnect: Missing port specification\n",
+ 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+ /*
+ * Build the socket name.
+ */
+
+ sockname.sun_family = AF_UNIX;
+
+#ifdef NX_TRANS_SOCKET
+ if (set_sun_path(port, _NXGetUnixPath(UNIX_PATH), sockname.sun_path) != 0) {
+#else
+ if (set_sun_path(port, UNIX_PATH, sockname.sun_path) != 0) {
+#endif
+ PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) && !defined(Lynx)
+ sockname.sun_len = strlen (sockname.sun_path);
+ namelen = SUN_LEN (&sockname);
+#else
+ namelen = strlen (sockname.sun_path) + sizeof (sockname.sun_family);
+#endif
+
+
+#if defined(hpux) && defined(X11_t)
+ /*
+ * This is gross, but it was in Xlib
+ */
+ old_sockname.sun_family = AF_UNIX;
+#ifdef NX_TRANS_SOCKET
+ if (set_sun_path(port, _NXGetOldUnixPath(OLD_UNIX_PATH), old_sockname.sun_path) != 0) {
+#else
+ if (set_sun_path(port, OLD_UNIX_PATH, old_sockname.sun_path) != 0) {
+#endif
+ PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+ old_namelen = strlen (old_sockname.sun_path) +
+ sizeof (old_sockname.sun_family);
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ if (ciptr->priv != NULL)
+ {
+ if (TRANS(SocketConnectConnInfo) (ciptr, host, port) != 0)
+ {
+ return TRANS_CONNECT_FAILED;
+ }
+
+ goto SocketUNIXConnectPost;
+ }
+
+#endif
+
+ /*
+ * Do the connect()
+ */
+
+ if (connect (ciptr->fd, (struct sockaddr *) &sockname, namelen) < 0)
+ {
+ int olderrno = errno;
+ int connected = 0;
+
+#if defined(hpux) && defined(X11_t)
+ if (olderrno == ENOENT)
+ {
+ if (connect (ciptr->fd,
+ (struct sockaddr *) &old_sockname, old_namelen) >= 0)
+ {
+ connected = 1;
+ }
+ else
+ olderrno = errno;
+ }
+#endif
+ if (!connected)
+ {
+ errno = olderrno;
+
+ /*
+ * If the error was ENOENT, the server may be starting up
+ * and we should try again.
+ *
+ * If the error was EWOULDBLOCK or EINPROGRESS then the socket
+ * was non-blocking and we should poll using select
+ *
+ * If the error was EINTR, the connect was interrupted and we
+ * should try again.
+ */
+
+ if (olderrno == ENOENT || olderrno == EINTR)
+ return TRANS_TRY_CONNECT_AGAIN;
+ else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
+ return TRANS_IN_PROGRESS;
+ else
+ {
+ PRMSG (2,"SocketUNIXConnect: Can't connect: errno = %d\n",
+ EGET(),0, 0);
+
+ return TRANS_CONNECT_FAILED;
+ }
+ }
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+SocketUNIXConnectPost:
+
+#endif
+
+ /*
+ * Get the socket name and the peer name from the connect socket,
+ * since this is unix domain.
+ */
+
+ if ((ciptr->addr = (char *) xalloc(namelen)) == NULL ||
+ (ciptr->peeraddr = (char *) xalloc(namelen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketUNIXCreateListener: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+ ciptr->family = AF_UNIX;
+ ciptr->addrlen = namelen;
+ ciptr->peeraddrlen = namelen;
+ memcpy (ciptr->addr, &sockname, ciptr->addrlen);
+ memcpy (ciptr->peeraddr, &sockname, ciptr->peeraddrlen);
+
+ return 0;
+}
+
+#endif /* UNIXCONN */
+
+#endif /* TRANS_CLIENT */
+
+
+static int
+TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)
+
+{
+ PRMSG (2,"SocketBytesReadable(%p,%d,%p)\n",
+ ciptr, ciptr->fd, pend);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ if (ciptr->priv)
+ {
+ if (NXTransRunning(ciptr->fd) == 0)
+ {
+ /*
+ * Force the application to shut down the
+ * socket if the NX transport is gone. We
+ * may probably save this additional call.
+ */
+
+#ifdef NX_TRANS_DEBUG
+ fprintf(stderr, "SocketBytesReadable: NX transport not running for descriptor [%d].\n",
+ ciptr->fd);
+#endif
+ ESET(EPIPE);
+
+ return -1;
+ }
+ else
+ {
+ /*
+ * Emulate BytesReadable. Some X applications may use the system
+ * select() in their main loop, instead of the _XSelect() that is
+ * replaced by NX. Still these applications use _XEventsQueued to
+ * poll events from the X connection, and _XEventsQueued uses the
+ * NX _XSelect(), so it is generally possible to let the client
+ * yield the control to NX and let it handle the I/O on the proxy
+ * descriptors even if the application is not explicitly designed
+ * to work as a NX agent.
+ */
+
+#ifdef NX_TRANS_DEBUG
+
+ int result;
+
+ result = NXTransReadable(ciptr->fd, (int *) pend);
+
+ fprintf(stderr, "SocketBytesReadable: Descriptor [%d] result [%d] readable [%ld].\n",
+ ciptr->fd, result, *pend);
+
+ return result;
+#else
+ return NXTransReadable(ciptr->fd, (int *) pend);
+#endif
+ }
+ }
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+#if defined(QNX4)
+ *pend = 0L; /* FIONREAD only returns a short. Zero out upper bits */
+#endif
+#ifdef WIN32
+ {
+ int ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+#if (defined(i386) && defined(SYSV) && !defined(SCO325)) || (defined(_SEQUENT_) && _SOCKET_VERSION == 1)
+ return ioctl (ciptr->fd, I_NREAD, (char *) pend);
+#else
+#if defined(__UNIXOS2__)
+ return ioctl (ciptr->fd, FIONREAD, (char*) pend, sizeof(int));
+#else
+ return ioctl (ciptr->fd, FIONREAD, (char *) pend);
+#endif /* __UNIXOS2__ */
+#endif /* i386 && SYSV || _SEQUENT_ && _SOCKET_VERSION == 1 */
+#endif /* WIN32 */
+}
+
+
+static int
+TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+ PRMSG (2,"SocketRead(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ /*
+ * If we have a valid priv pointer then this
+ * is an internal connection to the proxy.
+ * In this case we should emulate the read.
+ */
+
+ if (ciptr->priv)
+ {
+ int result;
+
+ result = NXTransRead(ciptr->fd, buf, size);
+
+#ifdef NX_TRANS_DEBUG
+ if (result < 0 && EGET() == EAGAIN)
+ {
+ fprintf(stderr, "SocketRead: Read from descriptor [%d] would block.\n",
+ ciptr->fd);
+ }
+ else
+ {
+ fprintf(stderr, "SocketRead: Read [%d] bytes from descriptor [%d].\n",
+ result, ciptr->fd);
+ }
+#endif
+ return result;
+ }
+ else
+ {
+ return read (ciptr->fd, buf, size);
+ }
+
+#else /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+#if defined(WIN32) || defined(__UNIXOS2__)
+ {
+ int ret = recv ((SOCKET)ciptr->fd, buf, size, 0);
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ return ret;
+ }
+#else
+ return read (ciptr->fd, buf, size);
+#endif /* WIN32 */
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+}
+
+
+static int
+TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+ PRMSG (2,"SocketWrite(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ /*
+ * If we have a valid priv pointer then this
+ * is an internal connection to the proxy.
+ * In this case we should emulate the write.
+ */
+
+ if (ciptr->priv)
+ {
+ int result;
+
+ result = NXTransWrite(ciptr->fd, buf, size);
+
+#ifdef NX_TRANS_DEBUG
+ if (result < 0 && EGET() == EAGAIN)
+ {
+ fprintf(stderr, "SocketWrite: Write on descriptor [%d] would block.\n",
+ ciptr->fd);
+ }
+ else
+ {
+ fprintf(stderr, "SocketWrite: Written [%d] bytes on descriptor [%d].\n",
+ result, ciptr->fd);
+ }
+#endif
+ return result;
+ }
+ else
+ {
+ return write (ciptr->fd, buf, size);
+ }
+
+#else /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+#if defined(WIN32) || defined(__UNIXOS2__)
+ {
+ int ret = send ((SOCKET)ciptr->fd, buf, size, 0);
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ return ret;
+ }
+#else
+ return write (ciptr->fd, buf, size);
+#endif /* WIN32 */
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+}
+
+
+static int
+TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ PRMSG (2,"SocketReadv(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ /*
+ * If we have a valid priv pointer then this
+ * is an internal connection to the proxy.
+ * In this case we should emulate the readv.
+ */
+
+ if (ciptr->priv)
+ {
+ return NXTransReadVector(ciptr->fd, buf, size);
+ }
+ else
+ {
+ return READV (ciptr, buf, size);
+ }
+
+#else /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+ return READV (ciptr, buf, size);
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+}
+
+
+static int
+TRANS(SocketWritev) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ PRMSG (2,"SocketWritev(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ /*
+ * If we have a valid priv pointer then this
+ * is an internal connection to the proxy.
+ * In this case we should emulate the writev.
+ */
+
+ if (ciptr->priv)
+ {
+ return NXTransWriteVector(ciptr->fd, buf, size);
+ }
+ else
+ {
+ return WRITEV (ciptr, buf, size);
+ }
+
+#else /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+ return WRITEV (ciptr, buf, size);
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+}
+
+
+static int
+TRANS(SocketDisconnect) (XtransConnInfo ciptr)
+
+{
+ PRMSG (2,"SocketDisconnect(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+#ifdef WIN32
+ {
+ int ret = shutdown (ciptr->fd, 2);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+ return shutdown (ciptr->fd, 2); /* disallow further sends and receives */
+#endif
+}
+
+
+#ifdef TCPCONN
+static int
+TRANS(SocketINETClose) (XtransConnInfo ciptr)
+
+{
+ PRMSG (2,"SocketINETClose(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+#ifdef WIN32
+ {
+ int ret = close (ciptr->fd);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+ return close (ciptr->fd);
+#endif
+}
+
+#endif /* TCPCONN */
+
+
+#ifdef UNIXCONN
+static int
+TRANS(SocketUNIXClose) (XtransConnInfo ciptr)
+
+{
+ /*
+ * If this is the server side, then once the socket is closed,
+ * it must be unlinked to completely close it
+ */
+
+ struct sockaddr_un *sockname = (struct sockaddr_un *) ciptr->addr;
+ int ret;
+
+ PRMSG (2,"SocketUNIXClose(%x,%d)\n", ciptr, ciptr->fd, 0);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ if (ciptr->priv)
+ {
+ TRANS(SocketCloseConnInfo) (ciptr);
+ }
+
+#endif
+
+ ret = close(ciptr->fd);
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "SocketUNIXClose: Flags are [%d] for ciptr at [%p] check is [%d].\n",
+ ciptr->flags, (void *) ciptr, (ciptr->flags && sockname
+ && sockname->sun_family == AF_UNIX && sockname->sun_path[0]));
+#endif
+
+ if (ciptr->flags
+ && sockname
+ && sockname->sun_family == AF_UNIX
+ && sockname->sun_path[0])
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ if (!(ciptr->flags & TRANS_NOUNLINK))
+ {
+ fprintf(stderr, "SocketUNIXClose: Unlinking path [%s] for ciptr at [%p].\n",
+ sockname->sun_path, (void *) ciptr);
+ unlink (sockname->sun_path);
+ }
+#else
+ if (!(ciptr->flags & TRANS_NOUNLINK))
+ unlink (sockname->sun_path);
+#endif
+ }
+
+ return ret;
+}
+
+static int
+TRANS(SocketUNIXCloseForCloning) (XtransConnInfo ciptr)
+
+{
+ /*
+ * Don't unlink path.
+ */
+
+ int ret;
+
+ PRMSG (2,"SocketUNIXCloseForCloning(%p,%d)\n",
+ ciptr, ciptr->fd, 0);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ if (ciptr->priv)
+ {
+ TRANS(SocketCloseConnInfo) (ciptr);
+ }
+
+#endif
+
+ ret = close(ciptr->fd);
+
+ return ret;
+}
+
+#endif /* UNIXCONN */
+
+
+#ifdef TCPCONN
+# ifdef TRANS_SERVER
+static char* tcp_nolisten[] = {
+ "inet",
+#if defined(IPv6) && defined(AF_INET6)
+ "inet6",
+#endif
+ NULL
+};
+# endif
+
+Xtransport TRANS(SocketTCPFuncs) = {
+ /* Socket Interface */
+ "tcp",
+ TRANS_ALIAS,
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ tcp_nolisten,
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketINETCreateListener),
+ NULL, /* ResetListener */
+ TRANS(SocketINETAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketINETConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketINETClose),
+ TRANS(SocketINETClose),
+ };
+
+Xtransport TRANS(SocketINETFuncs) = {
+ /* Socket Interface */
+ "inet",
+ 0,
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketINETCreateListener),
+ NULL, /* ResetListener */
+ TRANS(SocketINETAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketINETConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketINETClose),
+ TRANS(SocketINETClose),
+ };
+
+#if defined(IPv6) && defined(AF_INET6)
+Xtransport TRANS(SocketINET6Funcs) = {
+ /* Socket Interface */
+ "inet6",
+ 0,
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketINETCreateListener),
+ NULL, /* ResetListener */
+ TRANS(SocketINETAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketINETConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketINETClose),
+ TRANS(SocketINETClose),
+ };
+#endif /* IPv6 */
+#endif /* TCPCONN */
+
+#ifdef UNIXCONN
+#if !defined(LOCALCONN)
+Xtransport TRANS(SocketLocalFuncs) = {
+ /* Socket Interface */
+ "local",
+ 0,
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketUNIXCreateListener),
+ TRANS(SocketUNIXResetListener),
+ TRANS(SocketUNIXAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketUNIXConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketUNIXClose),
+ TRANS(SocketUNIXCloseForCloning),
+ };
+#endif /* !LOCALCONN */
+# ifdef TRANS_SERVER
+# if !defined(LOCALCONN)
+static char* unix_nolisten[] = { "local" , NULL };
+# endif
+# endif
+
+Xtransport TRANS(SocketUNIXFuncs) = {
+ /* Socket Interface */
+ "unix",
+#if !defined(LOCALCONN)
+ TRANS_ALIAS,
+#else
+ 0,
+#endif
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+#if !defined(LOCALCONN)
+ unix_nolisten,
+#else
+ NULL,
+#endif
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketUNIXCreateListener),
+ TRANS(SocketUNIXResetListener),
+ TRANS(SocketUNIXAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketUNIXConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketUNIXClose),
+ TRANS(SocketUNIXCloseForCloning),
+ };
+
+#endif /* UNIXCONN */
diff --git a/nx-X11/lib/xtrans/Xtranssock.c.NX.original b/nx-X11/lib/xtrans/Xtranssock.c.NX.original
new file mode 100644
index 000000000..50b677057
--- /dev/null
+++ b/nx-X11/lib/xtrans/Xtranssock.c.NX.original
@@ -0,0 +1,3417 @@
+/* $XdotOrg: xc/lib/xtrans/Xtranssock.c,v 1.11 2005/11/08 06:33:26 jkj Exp $ */
+/* $Xorg: Xtranssock.c,v 1.11 2001/02/09 02:04:06 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+Copyright 2002 Sun Microsystems, Inc. All rights reserved.
+
+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 copyright holders 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 copyright holders.
+
+*/
+/* $XFree86: xc/lib/xtrans/Xtranssock.c,v 3.68 2004/01/07 04:28:02 dawes Exp $ */
+
+/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * 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 NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCR makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR 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 (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#ifdef NX_TRANS_SOCKET
+
+#ifdef NX_TRANS_DEBUG
+#define XTRANSDEBUG 5
+#endif
+
+#ifndef PF_LOCAL
+#define PF_LOCAL PF_UNIX
+#endif
+
+#endif
+
+#include <ctype.h>
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+
+#ifndef WIN32
+
+#if defined(TCPCONN) || defined(UNIXCONN)
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+
+#if defined(TCPCONN) || defined(UNIXCONN)
+#define X_INCLUDE_NETDB_H
+#define XOS_USE_NO_LOCKING
+#include <X11/Xos_r.h>
+#endif
+
+#ifdef UNIXCONN
+#ifndef X_NO_SYS_UN
+#ifndef Lynx
+#include <sys/un.h>
+#else
+#include <un.h>
+#endif
+#endif
+#include <sys/stat.h>
+#endif
+
+#if defined(hpux) || (defined(MOTOROLA) && defined(SYSV))
+#define NO_TCP_H
+#endif
+
+#ifndef NO_TCP_H
+#if defined(__osf__) || defined(linux) || defined(__GLIBC__) || defined(AIXV5)
+#include <sys/param.h>
+#endif /* osf */
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
+#include <sys/param.h>
+#include <machine/endian.h>
+#endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ || __DragonFly__ */
+#include <netinet/tcp.h>
+#endif /* !NO_TCP_H */
+
+#include <sys/ioctl.h>
+#if defined(SVR4) && !defined(DGUX) && !defined(_SEQUENT_)
+#include <sys/filio.h>
+#endif
+
+#if (defined(i386) && defined(SYSV)) && !defined(SCO325) && !defined(sun)
+#include <net/errno.h>
+#endif
+
+#if (defined(i386) && defined(SYSV)) && (!defined(ISC) || !defined(I_NREAD) || defined(SCO325)) || defined(_SEQUENT_)
+#include <sys/stropts.h>
+#endif
+
+#else /* !WIN32 */
+
+#include <X11/Xwinsock.h>
+#include <X11/Xwindows.h>
+#include <X11/Xw32defs.h>
+#undef close
+#define close closesocket
+#define ECONNREFUSED WSAECONNREFUSED
+#define EADDRINUSE WSAEADDRINUSE
+#define EPROTOTYPE WSAEPROTOTYPE
+#undef EWOULDBLOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#define EINPROGRESS WSAEINPROGRESS
+#undef EINTR
+#define EINTR WSAEINTR
+#define X_INCLUDE_NETDB_H
+#define XOS_USE_MTSAFE_NETDBAPI
+#include <X11/Xos_r.h>
+#endif /* WIN32 */
+
+#if defined(SO_DONTLINGER) && defined(SO_LINGER)
+#undef SO_DONTLINGER
+#endif
+
+#if defined(__UNIXOS2__)
+#if defined(NOT_EMX09A)
+static int IBMsockInit = 0;
+#define SocketInitOnce()\
+ if (!IBMsockInit) {\
+ sock_init();\
+ IBMsockInit = 1;\
+ }
+#undef EINTR
+#define EINTR SOCEINTR
+#undef EINVAL
+#define EINVAL SOCEINVAL
+#undef errno
+#define errno sock_errno()
+#undef close
+#define close soclose
+#undef ioctl
+#define ioctl sockioctl
+#else
+#define SocketInitOnce() /**/
+#endif
+/* this is still not there */
+#define SOCKET int
+#else
+/* others don't need this */
+#define SocketInitOnce() /**/
+#endif
+
+#define MIN_BACKLOG 128
+#ifdef SOMAXCONN
+#if SOMAXCONN > MIN_BACKLOG
+#define BACKLOG SOMAXCONN
+#endif
+#endif
+#ifndef BACKLOG
+#define BACKLOG MIN_BACKLOG
+#endif
+/*
+ * This is the Socket implementation of the X Transport service layer
+ *
+ * This file contains the implementation for both the UNIX and INET domains,
+ * and can be built for either one, or both.
+ *
+ */
+
+typedef struct _Sockettrans2dev {
+ char *transname;
+ int family;
+ int devcotsname;
+ int devcltsname;
+ int protocol;
+} Sockettrans2dev;
+
+static Sockettrans2dev Sockettrans2devtab[] = {
+#ifdef TCPCONN
+ {"inet",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
+#if !defined(IPv6) || !defined(AF_INET6)
+ {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
+#else /* IPv6 */
+ {"tcp",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
+ {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, /* fallback */
+ {"inet6",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
+#endif
+#endif /* TCPCONN */
+#ifdef UNIXCONN
+ {"unix",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},
+#if !defined(LOCALCONN)
+ {"local",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},
+#endif /* !LOCALCONN */
+#endif /* UNIXCONN */
+};
+
+#define NUMSOCKETFAMILIES (sizeof(Sockettrans2devtab)/sizeof(Sockettrans2dev))
+
+#ifdef TCPCONN
+static int TRANS(SocketINETClose) (XtransConnInfo ciptr);
+#endif
+
+#ifdef UNIXCONN
+
+#ifdef hpux
+
+#if defined(X11_t)
+#define UNIX_PATH "/usr/spool/sockets/X11/"
+#define UNIX_DIR "/usr/spool/sockets/X11"
+#define OLD_UNIX_PATH "/tmp/.X11-unix/X"
+#endif /* X11_t */
+#if defined(XIM_t)
+#define UNIX_PATH "/usr/spool/sockets/XIM/"
+#define UNIX_DIR "/usr/spool/sockets/XIM"
+#define OLD_UNIX_PATH "/tmp/.XIM-unix/XIM"
+#endif /* XIM_t */
+#if defined(FS_t) || defined(FONT_t)
+#define UNIX_PATH "/usr/spool/sockets/fontserv/"
+#define UNIX_DIR "/usr/spool/sockets/fontserv"
+#endif /* FS_t || FONT_t */
+#if defined(ICE_t)
+#define UNIX_PATH "/usr/spool/sockets/ICE/"
+#define UNIX_DIR "/usr/spool/sockets/ICE"
+#endif /* ICE_t */
+#if defined(TEST_t)
+#define UNIX_PATH "/usr/spool/sockets/xtrans_test/"
+#define UNIX_DIR "/usr/spool/sockets/xtrans_test"
+#endif
+#if defined(LBXPROXY_t)
+#define UNIX_PATH "/usr/spool/sockets/X11/"
+#define UNIX_DIR "/usr/spool/sockets/X11"
+#endif
+
+#else /* !hpux */
+
+#if defined(X11_t)
+#define UNIX_PATH "/tmp/.X11-unix/X"
+#define UNIX_DIR "/tmp/.X11-unix"
+#endif /* X11_t */
+#if defined(XIM_t)
+#define UNIX_PATH "/tmp/.XIM-unix/XIM"
+#define UNIX_DIR "/tmp/.XIM-unix"
+#endif /* XIM_t */
+#if defined(FS_t) || defined(FONT_t)
+#define UNIX_PATH "/tmp/.font-unix/fs"
+#define UNIX_DIR "/tmp/.font-unix"
+#endif /* FS_t || FONT_t */
+#if defined(ICE_t)
+#define UNIX_PATH "/tmp/.ICE-unix/"
+#define UNIX_DIR "/tmp/.ICE-unix"
+#endif /* ICE_t */
+#if defined(TEST_t)
+#define UNIX_PATH "/tmp/.Test-unix/test"
+#define UNIX_DIR "/tmp/.Test-unix"
+#endif
+#if defined(LBXPROXY_t)
+#define UNIX_PATH "/tmp/.X11-unix/X"
+#define UNIX_DIR "/tmp/.X11-unix"
+#endif
+
+#endif /* hpux */
+
+#endif /* UNIXCONN */
+
+#define PORTBUFSIZE 32
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 255
+#endif
+
+/*
+ * This provides compatibility for apps linked against system libraries
+ * that don't have IPv6 support.
+ */
+#if defined(IPv6) && defined(AF_INET6)
+static const struct in6_addr local_in6addr_any = IN6ADDR_ANY_INIT;
+#pragma weak in6addr_any = local_in6addr_any
+#ifndef __USLC__
+#pragma weak getaddrinfo
+#endif
+static int haveIPv6 = 1;
+#endif
+
+#ifndef X11_t
+
+/*
+ * No NX changes if this is not
+ * compiled as a X11 transport.
+ */
+
+#undef NX_TRANS_SOCKET
+
+#endif
+
+#ifdef NX_TRANS_SOCKET
+
+#ifdef TRANS_CLIENT
+
+#include "NX.h"
+
+typedef struct
+{
+ XtransConnInfo info;
+ int local;
+ int remote;
+ int congestion;
+
+} _NXProxyConnInfo;
+
+#define NX_PROXY_CONN_LIMIT 256
+
+static _NXProxyConnInfo *_NXProxyConnInfoTab[NX_PROXY_CONN_LIMIT];
+
+#endif /* #ifdef TRANS_CLIENT */
+
+/*
+ * Override the UNIX_DIR and UNIX_PATH settings and
+ * make them configurable, based on the NX_TEMP or
+ * the TEMP environment.
+ *
+ * We must be careful as the same defines are used
+ * for different directories, based on the subsystem
+ * that is compiling this, while we want to override
+ * only the '/tmp/.X11-unix' and '/tmp/.X11-unix/X'
+ * settings.
+ */
+
+static char _NXUnixDir[1024];
+static char _NXUnixPath[1024];
+
+static char *_NXGetUnixDir(char *dir)
+{
+ const char *tempDir;
+
+ PRMSG (3, "_NXGetUnixDir(%s)\n", dir, 0, 0);
+
+ if (strcmp(dir, UNIX_DIR) != 0)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixDir: Returning other Unix directory [%s].\n", dir);
+#endif
+ return dir;
+ }
+
+ /*
+ * Check the environment only once.
+ */
+
+ if (*_NXUnixDir != '\0')
+ {
+ return _NXUnixDir;
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixDir: Trying with the NX_TEMP environment.\n");
+#endif
+
+ tempDir = getenv("NX_TEMP");
+
+ if (tempDir == NULL || *tempDir == '\0')
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixDir: Trying with the TEMP environment.\n");
+#endif
+
+ tempDir = getenv("TEMP");
+ }
+
+ if (tempDir != NULL && *tempDir != '\0')
+ {
+ if (strlen(tempDir) + strlen("/.X11-unix") + 1 > 1024)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixDir: WARNING! Maximum length of X11 Unix directory exceeded.\n");
+#endif
+ goto _NXGetUnixDirError;
+ }
+
+ strcpy(_NXUnixDir, tempDir);
+ strcat(_NXUnixDir, "/.X11-unix");
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixDir: Using X11 Unix directory [%s].\n", _NXUnixDir);
+#endif
+
+ return _NXUnixDir;
+ }
+
+_NXGetUnixDirError:
+
+ strcpy(_NXUnixDir, dir);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixDir: Returning default X11 Unix directory [%s].\n", _NXUnixDir);
+#endif
+
+ return _NXUnixDir;
+}
+
+static char *_NXGetUnixPath(char *path)
+{
+ const char *unixDir;
+
+ PRMSG (3, "_NXGetUnixPath(%s)\n", path, 0, 0);
+
+ if (strcmp(path, UNIX_PATH) != 0)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixPath: Returning other X11 Unix path [%s].\n", path);
+#endif
+ return path;
+ }
+
+ /*
+ * Check the environment only once.
+ */
+
+ if (*_NXUnixPath != '\0')
+ {
+ return _NXUnixPath;
+ }
+
+ unixDir = _NXGetUnixDir(UNIX_DIR);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixPath: Got X11 Unix directory [%s].\n", unixDir);
+#endif
+
+ if (strlen(unixDir) + strlen("/X") + 1 > 1024)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixPath: WARNING! Maximum length of X11 Unix path exceeded.\n");
+#endif
+
+ goto _NXGetUnixPathError;
+ }
+
+ strcpy(_NXUnixPath, unixDir);
+ strcat(_NXUnixPath, "/X");
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixPath: Returning X11 Unix path [%s].\n", _NXUnixPath);
+#endif
+
+ return _NXUnixPath;
+
+_NXGetUnixPathError:
+
+ strcpy(_NXUnixPath, path);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetUnixPath: Returning default X11 Unix path [%s].\n", _NXUnixPath);
+#endif
+
+ return _NXUnixPath;
+}
+
+#ifdef hpux
+
+static char *_NXGetOldUnixPath(char *path)
+{
+ PRMSG (3, "_NXGetOldUnixPath(%s)\n", path, 0, 0);
+
+ if (strcmp(path, OLD_UNIX_PATH) == 0)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetOldUnixPath: Returning X11 Unix path [%s].\n",
+ _NXGetUnixPath(path));
+#endif
+
+ return _NXGetUnixPath(path);
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetOldUnixPath: Returning other old X11 Unix path [%s].\n", path);
+#endif
+
+ return path;
+}
+
+#endif /* #ifdef hpux */
+
+/*
+ * Forcibly close any connection attempt on the
+ * listening socket. Need this to avoid loopback
+ * connections to the agent server.
+ */
+
+#ifdef TRANS_SERVER
+
+void TRANS(SocketRejectConnection) (XtransConnInfo ciptr)
+{
+ size_t sa_l = sizeof(struct sockaddr);
+ struct sockaddr sa;
+ fd_set fs;
+ struct timeval t;
+ int f;
+
+ PRMSG (3, "SocketRejectConnection(%x)\n", ciptr, 0, 0);
+
+ FD_ZERO(&fs);
+ FD_SET(ciptr -> fd, &fs);
+
+ t.tv_sec = 0;
+ t.tv_usec = 0;
+
+ /*
+ * Check if there is an awaiting connection.
+ */
+
+ if (select(ciptr -> fd + 1, &fs, NULL, NULL, &t) == 1)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketRejectConnection: Accepting connection attempt on fd [%d].\n",
+ ciptr -> fd);
+#endif
+ /*
+ * If there is one, close it.
+ */
+
+ if ((f = accept(ciptr -> fd, &sa, &sa_l)) >= 0)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketRejectConnection: Closing connection attempt on fd [%d].\n",
+ ciptr -> fd);
+#endif
+ close(f);
+ }
+ }
+}
+
+#endif /* #ifdef TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+
+void *TRANS(SocketProxyConnInfo) (XtransConnInfo ciptr)
+{
+ if (_NXProxyConnInfoTab[ciptr->fd] != NULL)
+ {
+ return ciptr->priv;
+ }
+
+ return NULL;
+}
+
+static XtransConnInfo TRANS(SocketCreateConnInfo) ()
+{
+ XtransConnInfo ciptr;
+
+ int fds[2];
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCreateConnInfo: Going to create the NX connection info.\n");
+#endif
+
+ if ((ciptr = (XtransConnInfo) xcalloc (1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketCreateConnInfo: malloc failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ /*
+ * Create a pair of sockets. We'll communicate with
+ * the NX proxy by reading and writing to our end.
+ */
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCreateConnInfo: Going to create the NX socketpair.\n");
+#endif
+
+ if (socketpair(PF_LOCAL, SOCK_STREAM, 0, fds) < 0)
+ {
+ PRMSG (1, "SocketCreateConnInfo: socketpair() failed.\n", 0, 0, 0);
+ xfree ((char *) ciptr);
+ return NULL;
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCreateConnInfo: X socket end is [%d] NX proxy end is [%d].\n",
+ fds[0], fds[1]);
+#endif
+
+ /*
+ * Save in _NXProxyConnInfoTab the local and remote end of
+ * the socketpair. The remote end will be used by the proxy.
+ * When the memory-to-memory transport is activated, the
+ * agent and the proxy don't read or write to the real des-
+ * criptors but the communication takes place by reading
+ * and writing to the proxy's buffers.
+ */
+
+ ciptr->fd = fds[0];
+
+ if (ciptr->fd >= NX_PROXY_CONN_LIMIT)
+ {
+ PRMSG (1, "SocketCreateConnInfo: No space for a new _NXProxyConnInfo for [%d].\n",
+ ciptr->fd, 0, 0);
+ xfree ((char *) ciptr);
+ return NULL;
+ }
+ else if (_NXProxyConnInfoTab[ciptr->fd] != NULL)
+ {
+ PRMSG (1, "SocketCreateConnInfo: _NXProxyConnInfo for [%d] is not NULL. Exiting.\n",
+ ciptr->fd, 0, 0);
+ exit(1);
+ }
+
+ _NXProxyConnInfoTab[ciptr->fd] = (_NXProxyConnInfo *) xcalloc(1, sizeof(_NXProxyConnInfo));
+
+ if (_NXProxyConnInfoTab[ciptr->fd] == NULL)
+ {
+ PRMSG (1, "SocketCreateConnInfo: Alloc of _NXProxyConnInfo failed.\n", 0, 0, 0);
+ xfree ((char *) ciptr);
+ return NULL;
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCreateConnInfo: Allocated new _NXProxyConnInfo for [%d].\n",
+ ciptr->fd);
+#endif
+
+ _NXProxyConnInfoTab[ciptr->fd]->info = ciptr;
+ _NXProxyConnInfoTab[ciptr->fd]->local = fds[0];
+ _NXProxyConnInfoTab[ciptr->fd]->remote = fds[1];
+ _NXProxyConnInfoTab[ciptr->fd]->congestion = 0;
+
+ ciptr->priv = (char *) _NXProxyConnInfoTab[ciptr->fd];
+
+ return ciptr;
+}
+
+static int TRANS(SocketConnectConnInfo) (XtransConnInfo ciptr, char *host, char *port)
+{
+ int fds[2];
+ char display[1024];
+
+ _NXProxyConnInfo *proxy_conn;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketConnectConnInfo: Going to connect NX fd [%d] to host [%s] port [%s].\n",
+ ciptr->fd, host, port);
+#endif
+
+ /*
+ * We should have already created the socket pair.
+ */
+
+ proxy_conn = (_NXProxyConnInfo *) ciptr->priv;
+
+ if (proxy_conn == NULL)
+ {
+ PRMSG (1, "SocketConnectConnInfo: Pointer to _NXProxyConnInfo is NULL. Exiting.\n", 0, 0, 0);
+
+ exit(1);
+ }
+ else if (_NXProxyConnInfoTab[ciptr->fd] != (_NXProxyConnInfo *) ciptr->priv)
+ {
+ PRMSG (1, "SocketConnectConnInfo: Can't find _NXProxyConnInfo in table. Exiting.\n",
+ 0, 0, 0);
+
+ exit(1);
+ }
+
+ if (strlen(host) + strlen(port) + 1 >= 1023)
+ {
+ PRMSG (1, "SocketConnectConnInfo: Length of NX display string '%s:%s' would exceed %d characters.\n",
+ host, port, 1023);
+
+ return TRANS_CONNECT_FAILED;
+ }
+
+ sprintf(display, "%s:%s", host, port);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketConnectConnInfo: Setting close-on-exec flag on local NX descriptor [%d].\n",
+ proxy_conn -> local);
+#endif
+
+#ifdef F_SETFD
+#ifdef FD_CLOEXEC
+ if (fcntl(proxy_conn -> local, F_SETFD, FD_CLOEXEC) != 0)
+#else
+ if (fcntl(proxy_conn -> local, F_SETFD, 1) != 0)
+#endif
+#endif
+ {
+ PRMSG (1, "SocketConnectConnInfo: Cannot set close-on-exec on local NX descriptor [%d].\n",
+ proxy_conn -> local, 0, 0);
+
+ return TRANS_CONNECT_FAILED;
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketConnectConnInfo: Creating the NX transport with display [%s].\n",
+ display);
+#endif
+
+ if (NXTransCreate(NX_FD_ANY, NX_MODE_CLIENT, display) < 0)
+ {
+ PRMSG (1, "SocketConnectConnInfo: Cannot create the NX transport.\n",
+ 0, 0, 0);
+
+ return TRANS_CONNECT_FAILED;
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketConnectConnInfo: Starting the NX agent with descriptor [%d].\n",
+ proxy_conn -> remote);
+#endif
+
+ fds[0] = proxy_conn -> local;
+ fds[1] = proxy_conn -> remote;
+
+ NXTransAgent(fds);
+
+ return 0;
+}
+
+static void TRANS(SocketCloseConnInfo) (XtransConnInfo ciptr)
+{
+ _NXProxyConnInfo *proxy_conn;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCloseConnInfo: Going to close the NX fd [%d].\n", ciptr->fd);
+#endif
+
+ proxy_conn = (_NXProxyConnInfo *) ciptr->priv;
+
+ if (proxy_conn == NULL)
+ {
+ PRMSG (1, "SocketCloseConnInfo: Pointer to _NXProxyConnInfo is NULL. Exiting.\n", 0, 0, 0);
+
+ exit(1);
+ }
+ else if (ciptr->fd >= NX_PROXY_CONN_LIMIT ||
+ _NXProxyConnInfoTab[ciptr->fd] != (_NXProxyConnInfo *) ciptr->priv)
+ {
+ PRMSG (1, "SocketCloseConnInfo: Can't find _NXProxyConnInfo in table. Exiting.\n",
+ 0, 0, 0);
+ exit(1);
+ }
+ else if (_NXProxyConnInfoTab[ciptr->fd] -> info != ciptr ||
+ _NXProxyConnInfoTab[ciptr->fd] -> local != ciptr->fd)
+ {
+ PRMSG (1, "SocketCloseConnInfo: Invalid _NXProxyConnInfo structure for [%d]. Exiting.\n",
+ ciptr->fd, 0, 0);
+ exit(1);
+ }
+ else if (proxy_conn->local < 0 || proxy_conn->remote < 0)
+ {
+ PRMSG (1, "SocketCloseConnInfo: Invalid socket pair in NX connection for [%d]. Exiting.\n",
+ ciptr->fd, 0, 0);
+ exit(1);
+ }
+
+ NXTransClose(ciptr->fd);
+
+ /*
+ * Get rid of the _NXProxyConnInfo structure.
+ */
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCloseConnInfo: Freeing _NXProxyConnInfo structure for [%d].\n",
+ ciptr->fd);
+#endif
+
+ xfree((char *) _NXProxyConnInfoTab[ciptr->fd]);
+
+ _NXProxyConnInfoTab[ciptr->fd] = NULL;
+
+ ciptr->priv = NULL;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCloseConnInfo: Should now close the local descriptor [%d].\n",
+ ciptr->fd);
+#endif
+}
+
+#endif /* #ifdef TRANS_CLIENT */
+
+#if defined(TRANS_CLIENT) && defined(NX_TRANS_CHANGE)
+
+/*
+ * Check the congestion state of the NX transport
+ * and return 1 if there has been a change. This
+ * can be extended by adding a few counters track-
+ * ing the bandwidth usage of the X11 connection.
+ */
+
+int TRANS(SocketCongestionChange) (XtransConnInfo ciptr, int *state)
+{
+ int congestion;
+
+ _NXProxyConnInfo *proxy_conn;
+
+ PRMSG (3, "SocketCongestionChange(%x)\n", ciptr, 0, 0);
+
+ proxy_conn = (_NXProxyConnInfo *) ciptr->priv;
+
+ if (proxy_conn == NULL)
+ {
+#ifdef NX_TRANS_DEBUG
+ fprintf(stderr, "SocketCongestionChange: Descriptor [%d] doesn't appear to be a NX connection.\n",
+ ciptr->fd);
+#endif
+ return 0;
+ }
+
+#ifdef NX_TRANS_DEBUG
+ fprintf(stderr, "SocketCongestionChange: Checking congestion on fd [%d] with old state [%d].\n",
+ ciptr->fd, proxy_conn->congestion);
+#endif
+
+ congestion = NXTransCongestion(ciptr->fd);
+
+ if (congestion != proxy_conn->congestion)
+ {
+ proxy_conn->congestion = congestion;
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCongestionChange: Change detected on fd [%d] with new state [%d].\n",
+ ciptr->fd, proxy_conn->congestion);
+#endif
+ return 1;
+ }
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketCongestionChange: No change on fd [%d] with current state [%d].\n",
+ ciptr->fd, congestion);
+#endif
+ return 0;
+}
+
+#endif /* #if defined(TRANS_CLIENT) && defined(NX_TRANS_CHANGE) */
+
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+/*
+ * These are some utility function used by the real interface function below.
+ */
+
+static int
+TRANS(SocketSelectFamily) (int first, char *family)
+
+{
+ int i;
+
+ PRMSG (3,"SocketSelectFamily(%s)\n", family, 0, 0);
+
+ for (i = first + 1; i < NUMSOCKETFAMILIES;i++)
+ {
+ if (!strcmp (family, Sockettrans2devtab[i].transname))
+ return i;
+ }
+
+ return (first == -1 ? -2 : -1);
+}
+
+
+/*
+ * This function gets the local address of the socket and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(SocketINETGetAddr) (XtransConnInfo ciptr)
+
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_storage socknamev6;
+#endif
+ struct sockaddr_in socknamev4;
+ void *socknamePtr;
+#if defined(SVR4) || defined(__SCO__)
+ size_t namelen;
+#else
+ int namelen;
+#endif
+
+ PRMSG (3,"SocketINETGetAddr(%p)\n", ciptr, 0, 0);
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6)
+ {
+ namelen = sizeof(socknamev6);
+ socknamePtr = &socknamev6;
+ }
+ else
+#endif
+ {
+ namelen = sizeof(socknamev4);
+ socknamePtr = &socknamev4;
+ }
+
+ if (getsockname (ciptr->fd,(struct sockaddr *) socknamePtr,
+ (void *)&namelen) < 0)
+ {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ PRMSG (1,"SocketINETGetAddr: getsockname() failed: %d\n",
+ EGET(),0, 0);
+ return -1;
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if ((ciptr->addr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketINETGetAddr: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ return -1;
+ }
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6)
+ {
+ ciptr->family = ((struct sockaddr *)socknamePtr)->sa_family;
+ }
+ else
+#endif
+ {
+ ciptr->family = socknamev4.sin_family;
+ }
+ ciptr->addrlen = namelen;
+ memcpy (ciptr->addr, socknamePtr, ciptr->addrlen);
+
+ return 0;
+}
+
+
+/*
+ * This function gets the remote address of the socket and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr)
+
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_storage socknamev6;
+#endif
+ struct sockaddr_in socknamev4;
+ void *socknamePtr;
+#if defined(SVR4) || defined(__SCO__)
+ size_t namelen;
+#else
+ int namelen;
+#endif
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6 && ciptr->family == AF_INET6)
+ {
+ namelen = sizeof(socknamev6);
+ socknamePtr = &socknamev6;
+ }
+ else
+#endif
+ {
+ namelen = sizeof(socknamev4);
+ socknamePtr = &socknamev4;
+ }
+
+ PRMSG (3,"SocketINETGetPeerAddr(%p)\n", ciptr, 0, 0);
+
+ if (getpeername (ciptr->fd, (struct sockaddr *) socknamePtr,
+ (void *)&namelen) < 0)
+ {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ PRMSG (1,"SocketINETGetPeerAddr: getpeername() failed: %d\n",
+ EGET(), 0, 0);
+ return -1;
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if ((ciptr->peeraddr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketINETGetPeerAddr: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ return -1;
+ }
+
+ ciptr->peeraddrlen = namelen;
+ memcpy (ciptr->peeraddr, socknamePtr, ciptr->peeraddrlen);
+
+ return 0;
+}
+
+
+static XtransConnInfo
+TRANS(SocketOpen) (int i, int type)
+
+{
+ XtransConnInfo ciptr;
+
+ PRMSG (3,"SocketOpen(%d,%d)\n", i, type, 0);
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (getaddrinfo == NULL)
+ haveIPv6 = 0;
+
+ if (!haveIPv6 && Sockettrans2devtab[i].family == AF_INET6)
+ return NULL;
+#endif
+
+ if ((ciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketOpen: malloc failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ if ((ciptr->fd = socket(Sockettrans2devtab[i].family, type,
+ Sockettrans2devtab[i].protocol)) < 0
+#ifndef WIN32
+#if (defined(X11_t) && !defined(USE_POLL)) || defined(FS_t) || defined(FONT_t)
+ || ciptr->fd >= TRANS_OPEN_MAX
+#endif
+#endif
+ ) {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ PRMSG (2, "SocketOpen: socket() failed for %s\n",
+ Sockettrans2devtab[i].transname, 0, 0);
+
+ xfree ((char *) ciptr);
+ return NULL;
+ }
+
+#ifdef TCP_NODELAY
+ if (Sockettrans2devtab[i].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+ || Sockettrans2devtab[i].family == AF_INET6
+#endif
+ )
+ {
+ /*
+ * turn off TCP coalescence for INET sockets
+ */
+
+ int tmp = 1;
+ setsockopt (ciptr->fd, IPPROTO_TCP, TCP_NODELAY,
+ (char *) &tmp, sizeof (int));
+ }
+#endif
+
+ return ciptr;
+}
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(SocketReopen) (int i, int type, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+
+ PRMSG (3,"SocketReopen(%d,%d,%s)\n", type, fd, port);
+
+ if ((ciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketReopen: malloc failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ ciptr->fd = fd;
+
+ return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+/*
+ * These functions are the interface supplied in the Xtransport structure
+ */
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(SocketOpenCOTSClientBase) (char *transname, char *protocol,
+ char *host, char *port, int previndex)
+{
+ XtransConnInfo ciptr;
+ int i = previndex;
+
+ PRMSG (2, "SocketOpenCOTSClient(%s,%s,%s)\n",
+ protocol, host, port);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, transname)) >= 0) {
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ if ((!strcmp(protocol, "local") || !strcmp(protocol, "nx")) &&
+ (!strcasecmp(host, "nx") || !strncasecmp(host, "nx,", 3)))
+ {
+ ciptr = TRANS(SocketCreateConnInfo) ();
+
+ if (ciptr == NULL)
+ {
+ PRMSG (1, "SocketOpenCOTSClient: Unable to create the NX connection info for %s.\n",
+ transname, 0, 0);
+
+ return NULL;
+ }
+
+ ciptr->index = i;
+
+ return ciptr;
+ }
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+ if ((ciptr = TRANS(SocketOpen) (
+ i, Sockettrans2devtab[i].devcotsname)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketOpenCOTSClient: Unable to open socket for %s\n",
+ transname, 0, 0);
+ else
+ PRMSG (1,"SocketOpenCOTSClient: Unable to determine socket type for %s\n",
+ transname, 0, 0);
+ return NULL;
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ ciptr->priv = NULL;
+
+#endif
+
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+static XtransConnInfo
+TRANS(SocketOpenCOTSClient) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+{
+ return TRANS(SocketOpenCOTSClientBase)(
+ thistrans->TransName, protocol, host, port, -1);
+}
+
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,"SocketOpenCOTSServer(%s,%s,%s)\n", protocol, host, port);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+ if ((ciptr = TRANS(SocketOpen) (
+ i, Sockettrans2devtab[i].devcotsname)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketOpenCOTSServer: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketOpenCOTSServer: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+ /*
+ * Using this prevents the bind() check for an existing server listening
+ * on the same port, but it is required for other reasons.
+ */
+#ifdef SO_REUSEADDR
+
+ /*
+ * SO_REUSEADDR only applied to AF_INET && AF_INET6
+ */
+
+ if (Sockettrans2devtab[i].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+ || Sockettrans2devtab[i].family == AF_INET6
+#endif
+ )
+ {
+ int one = 1;
+ setsockopt (ciptr->fd, SOL_SOCKET, SO_REUSEADDR,
+ (char *) &one, sizeof (int));
+ }
+#endif
+#ifdef IPV6_V6ONLY
+ if (Sockettrans2devtab[i].family == AF_INET6)
+ {
+ int one = 1;
+ setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int));
+ }
+#endif
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(SocketOpenCLTSClient) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,"SocketOpenCLTSClient(%s,%s,%s)\n", protocol, host, port);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ if ((!strcmp(protocol, "local") || !strcmp(protocol, "nx")) &&
+ (!strcasecmp(host, "nx") || !strncasecmp(host, "nx,", 3)))
+ {
+ ciptr = TRANS(SocketCreateConnInfo) ();
+
+ if (ciptr == NULL)
+ {
+ PRMSG (1, "SocketOpenCLTSClient: Unable to create the NX connection info for %s.\n",
+ thistrans->TransName, 0, 0);
+
+ return NULL;
+ }
+
+ ciptr->index = i;
+
+ return ciptr;
+ }
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+ if ((ciptr = TRANS(SocketOpen) (
+ i, Sockettrans2devtab[i].devcotsname)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketOpenCLTSClient: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketOpenCLTSClient: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ ciptr->priv = NULL;
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(SocketOpenCLTSServer) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,"SocketOpenCLTSServer(%s,%s,%s)\n", protocol, host, port);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+ if ((ciptr = TRANS(SocketOpen) (
+ i, Sockettrans2devtab[i].devcotsname)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketOpenCLTSServer: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketOpenCLTSServer: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+#ifdef IPV6_V6ONLY
+ if (Sockettrans2devtab[i].family == AF_INET6)
+ {
+ int one = 1;
+ setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int));
+ }
+#endif
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(SocketReopenCOTSServer) (Xtransport *thistrans, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,
+ "SocketReopenCOTSServer(%d, %s)\n", fd, port, 0);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+ if ((ciptr = TRANS(SocketReopen) (
+ i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketReopenCOTSServer: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketReopenCOTSServer: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+static XtransConnInfo
+TRANS(SocketReopenCLTSServer) (Xtransport *thistrans, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,
+ "SocketReopenCLTSServer(%d, %s)\n", fd, port, 0);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+ if ((ciptr = TRANS(SocketReopen) (
+ i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketReopenCLTSServer: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketReopenCLTSServer: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+static int
+TRANS(SocketSetOption) (XtransConnInfo ciptr, int option, int arg)
+
+{
+ PRMSG (2,"SocketSetOption(%d,%d,%d)\n", ciptr->fd, option, arg);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "SocketSetOption: WARNING! Not setting option [%d] with value [%d] on descriptor [%d].\n",
+ option, arg, ciptr -> fd);
+#endif
+
+ return -1;
+}
+
+#ifdef UNIXCONN
+static int
+set_sun_path(const char *port, const char *upath, char *path)
+{
+ struct sockaddr_un s;
+ int maxlen = sizeof(s.sun_path) - 1;
+
+ if (!port || !*port || !path)
+ return -1;
+
+ if (*port == '/') { /* a full pathname */
+ if (strlen(port) > maxlen)
+ return -1;
+ sprintf(path, "%s", port);
+ } else {
+ if (strlen(port) + strlen(upath) > maxlen)
+ return -1;
+ sprintf(path, "%s%s", upath, port);
+ }
+ return 0;
+}
+#endif
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(SocketCreateListener) (XtransConnInfo ciptr,
+ struct sockaddr *sockname,
+ int socknamelen, unsigned int flags)
+
+{
+ int namelen = socknamelen;
+ int fd = ciptr->fd;
+ int retry;
+
+ PRMSG (3, "SocketCreateListener(%x,%p)\n", ciptr, fd, 0);
+
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+ || Sockettrans2devtab[ciptr->index].family == AF_INET6
+#endif
+ )
+ retry = 20;
+ else
+ retry = 0;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "SocketCreateListener: Creating listener for ciptr at [%p] on path [%s].\n",
+ (void *) ciptr, ((struct sockaddr_un *) sockname)->sun_family == AF_UNIX ?
+ ((struct sockaddr_un *) sockname)->sun_path : "TCP");
+#endif
+ while (bind (fd, (struct sockaddr *) sockname, namelen) < 0)
+ {
+ if (errno == EADDRINUSE) {
+ if (flags & ADDR_IN_USE_ALLOWED)
+ break;
+ else
+ return TRANS_ADDR_IN_USE;
+ }
+
+ if (retry-- == 0) {
+ PRMSG (1, "SocketCreateListener: failed to bind listener\n",
+ 0, 0, 0);
+ close (fd);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+#ifdef SO_REUSEADDR
+ sleep (1);
+#else
+ sleep (10);
+#endif /* SO_REUSEDADDR */
+ }
+
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+ || Sockettrans2devtab[ciptr->index].family == AF_INET6
+#endif
+ ) {
+#ifdef SO_DONTLINGER
+ setsockopt (fd, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0);
+#else
+#ifdef SO_LINGER
+ {
+ static int linger[2] = { 0, 0 };
+ setsockopt (fd, SOL_SOCKET, SO_LINGER,
+ (char *) linger, sizeof (linger));
+ }
+#endif
+#endif
+}
+
+ if (listen (fd, BACKLOG) < 0)
+ {
+ PRMSG (1, "SocketCreateListener: listen() failed\n", 0, 0, 0);
+ close (fd);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ /* Set a flag to indicate that this connection is a listener */
+
+ ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS);
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "SocketCreateListener: Set flags to [%d] for ciptr [%p].\n",
+ ciptr->flags, (void *) ciptr);
+#endif
+
+ return 0;
+}
+
+#ifdef TCPCONN
+static int
+TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags)
+
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_storage sockname;
+#else
+ struct sockaddr_in sockname;
+#endif
+ unsigned short sport;
+ int namelen = sizeof(sockname);
+ int status;
+ long tmpport;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgetservbynameparams sparams;
+#endif
+ struct servent *servp;
+
+#ifdef X11_t
+ char portbuf[PORTBUFSIZE];
+#endif
+
+ PRMSG (2, "SocketINETCreateListener(%s)\n", port, 0, 0);
+
+#ifdef X11_t
+ /*
+ * X has a well known port, that is transport dependent. It is easier
+ * to handle it here, than try and come up with a transport independent
+ * representation that can be passed in and resolved the usual way.
+ *
+ * The port that is passed here is really a string containing the idisplay
+ * from ConnectDisplay().
+ */
+
+ if (is_numeric (port))
+ {
+ /* fixup the server port address */
+ tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);
+ sprintf (portbuf,"%lu", tmpport);
+ port = portbuf;
+ }
+#endif
+
+ if (port && *port)
+ {
+ /* Check to see if the port string is just a number (handles X11) */
+
+ if (!is_numeric (port))
+ {
+ if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL)
+ {
+ PRMSG (1,
+ "SocketINETCreateListener: Unable to get service for %s\n",
+ port, 0, 0);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+ /* we trust getservbyname to return a valid number */
+ sport = servp->s_port;
+ }
+ else
+ {
+ tmpport = strtol (port, (char**)NULL, 10);
+ /*
+ * check that somehow the port address isn't negative or in
+ * the range of reserved port addresses. This can happen and
+ * be very bad if the server is suid-root and the user does
+ * something (dumb) like `X :60049`.
+ */
+ if (tmpport < 1024 || tmpport > USHRT_MAX)
+ return TRANS_CREATE_LISTENER_FAILED;
+
+ sport = (unsigned short) tmpport;
+ }
+ }
+ else
+ sport = 0;
+
+ bzero(&sockname, sizeof(sockname));
+#if defined(IPv6) && defined(AF_INET6)
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET) {
+ namelen = sizeof (struct sockaddr_in);
+#ifdef BSD44SOCKETS
+ ((struct sockaddr_in *)&sockname)->sin_len = namelen;
+#endif
+ ((struct sockaddr_in *)&sockname)->sin_family = AF_INET;
+ ((struct sockaddr_in *)&sockname)->sin_port = htons(sport);
+ ((struct sockaddr_in *)&sockname)->sin_addr.s_addr = htonl(INADDR_ANY);
+ } else {
+ namelen = sizeof (struct sockaddr_in6);
+#ifdef SIN6_LEN
+ ((struct sockaddr_in6 *)&sockname)->sin6_len = sizeof(sockname);
+#endif
+ ((struct sockaddr_in6 *)&sockname)->sin6_family = AF_INET6;
+ ((struct sockaddr_in6 *)&sockname)->sin6_port = htons(sport);
+ ((struct sockaddr_in6 *)&sockname)->sin6_addr = in6addr_any;
+ }
+#else
+#ifdef BSD44SOCKETS
+ sockname.sin_len = sizeof (sockname);
+#endif
+ sockname.sin_family = AF_INET;
+ sockname.sin_port = htons (sport);
+ sockname.sin_addr.s_addr = htonl (INADDR_ANY);
+#endif
+
+ if ((status = TRANS(SocketCreateListener) (ciptr,
+ (struct sockaddr *) &sockname, namelen, flags)) < 0)
+ {
+ PRMSG (1,
+ "SocketINETCreateListener: ...SocketCreateListener() failed\n",
+ 0, 0, 0);
+ return status;
+ }
+
+ if (TRANS(SocketINETGetAddr) (ciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETCreateListener: ...SocketINETGetAddr() failed\n",
+ 0, 0, 0);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ return 0;
+}
+
+#endif /* SOCKCONN */
+
+
+#ifdef UNIXCONN
+
+static int
+TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
+ unsigned int flags)
+
+{
+ struct sockaddr_un sockname;
+ int namelen;
+ int oldUmask;
+ int status;
+ unsigned int mode;
+
+ PRMSG (2, "SocketUNIXCreateListener(%s)\n",
+ port ? port : "NULL", 0, 0);
+
+ /* Make sure the directory is created */
+
+ oldUmask = umask (0);
+
+#ifdef UNIX_DIR
+#ifdef HAS_STICKY_DIR_BIT
+ mode = 01777;
+#else
+ mode = 0777;
+#endif
+#ifdef NX_TRANS_SOCKET
+ if (trans_mkdir(_NXGetUnixDir(UNIX_DIR), mode) == -1) {
+ PRMSG (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n",
+ _NXGetUnixDir(UNIX_DIR), errno, 0);
+#else
+ if (trans_mkdir(UNIX_DIR, mode) == -1) {
+ PRMSG (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n",
+ UNIX_DIR, errno, 0);
+#endif
+ (void) umask (oldUmask);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+#endif
+
+ sockname.sun_family = AF_UNIX;
+
+ if (port && *port) {
+#ifdef NX_TRANS_SOCKET
+ if (set_sun_path(port, _NXGetUnixPath(UNIX_PATH), sockname.sun_path) != 0) {
+#else
+ if (set_sun_path(port, UNIX_PATH, sockname.sun_path) != 0) {
+#endif
+ PRMSG (1, "SocketUNIXCreateListener: path too long\n", 0, 0, 0);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+ } else {
+#ifdef NX_TRANS_SOCKET
+ sprintf (sockname.sun_path, "%s%ld", _NXGetUnixPath(UNIX_PATH), (long)getpid());
+#else
+ sprintf (sockname.sun_path, "%s%ld", UNIX_PATH, (long)getpid());
+#endif
+ }
+
+#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) && !defined(Lynx)
+ sockname.sun_len = strlen(sockname.sun_path);
+ namelen = SUN_LEN(&sockname);
+#else
+ namelen = strlen(sockname.sun_path) + sizeof(sockname.sun_family);
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "SocketUNIXCreateListener: Unlinking path [%s] for ciptr at [%p].\n",
+ sockname.sun_path, (void *) ciptr);
+#endif
+ unlink (sockname.sun_path);
+
+ if ((status = TRANS(SocketCreateListener) (ciptr,
+ (struct sockaddr *) &sockname, namelen, flags)) < 0)
+ {
+ PRMSG (1,
+ "SocketUNIXCreateListener: ...SocketCreateListener() failed\n",
+ 0, 0, 0);
+ (void) umask (oldUmask);
+ return status;
+ }
+
+ /*
+ * Now that the listener is esablished, create the addr info for
+ * this connection. getpeername() doesn't work for UNIX Domain Sockets
+ * on some systems (hpux at least), so we will just do it manually, instead
+ * of calling something like TRANS(SocketUNIXGetAddr).
+ */
+
+ namelen = sizeof (sockname); /* this will always make it the same size */
+
+ if ((ciptr->addr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketUNIXCreateListener: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ (void) umask (oldUmask);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ ciptr->family = sockname.sun_family;
+ ciptr->addrlen = namelen;
+ memcpy (ciptr->addr, &sockname, ciptr->addrlen);
+
+ (void) umask (oldUmask);
+
+ return 0;
+}
+
+
+static int
+TRANS(SocketUNIXResetListener) (XtransConnInfo ciptr)
+
+{
+ /*
+ * See if the unix domain socket has disappeared. If it has, recreate it.
+ */
+
+ struct sockaddr_un *unsock = (struct sockaddr_un *) ciptr->addr;
+ struct stat statb;
+ int status = TRANS_RESET_NOOP;
+ unsigned int mode;
+
+ PRMSG (3, "SocketUNIXResetListener(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+ if (stat (unsock->sun_path, &statb) == -1 ||
+ ((statb.st_mode & S_IFMT) !=
+#if (defined (sun) && defined(SVR4)) || defined(NCR) || defined(SCO325) || !defined(S_IFSOCK)
+ S_IFIFO))
+#else
+ S_IFSOCK))
+#endif
+ {
+ int oldUmask = umask (0);
+
+#ifdef UNIX_DIR
+#ifdef HAS_STICKY_DIR_BIT
+ mode = 01777;
+#else
+ mode = 0777;
+#endif
+#ifdef NX_TRANS_SOCKET
+ if (trans_mkdir(_NXGetUnixDir(UNIX_DIR), mode) == -1) {
+ PRMSG (1, "SocketUNIXResetListener: mkdir(%s) failed, errno = %d\n",
+ _NXGetUnixDir(UNIX_DIR), errno, 0);
+#else
+ if (trans_mkdir(UNIX_DIR, mode) == -1) {
+ PRMSG (1, "SocketUNIXResetListener: mkdir(%s) failed, errno = %d\n",
+ UNIX_DIR, errno, 0);
+#endif
+ (void) umask (oldUmask);
+ return TRANS_RESET_FAILURE;
+ }
+#endif
+
+ close (ciptr->fd);
+ unlink (unsock->sun_path);
+
+ if ((ciptr->fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
+ {
+ TRANS(FreeConnInfo) (ciptr);
+ (void) umask (oldUmask);
+ return TRANS_RESET_FAILURE;
+ }
+
+ if (bind (ciptr->fd, (struct sockaddr *) unsock, ciptr->addrlen) < 0)
+ {
+ close (ciptr->fd);
+ TRANS(FreeConnInfo) (ciptr);
+ return TRANS_RESET_FAILURE;
+ }
+
+ if (listen (ciptr->fd, BACKLOG) < 0)
+ {
+ close (ciptr->fd);
+ TRANS(FreeConnInfo) (ciptr);
+ (void) umask (oldUmask);
+ return TRANS_RESET_FAILURE;
+ }
+
+ umask (oldUmask);
+
+ status = TRANS_RESET_NEW_FD;
+ }
+
+ return status;
+}
+
+#endif /* UNIXCONN */
+
+
+#ifdef TCPCONN
+
+static XtransConnInfo
+TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status)
+
+{
+ XtransConnInfo newciptr;
+ struct sockaddr_in sockname;
+ int namelen = sizeof(sockname);
+
+ PRMSG (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+ if ((newciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketINETAccept: malloc failed\n", 0, 0, 0);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+ if ((newciptr->fd = accept (ciptr->fd,
+ (struct sockaddr *) &sockname, (void *)&namelen)) < 0)
+ {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ PRMSG (1, "SocketINETAccept: accept() failed\n", 0, 0, 0);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_FAILED;
+ return NULL;
+ }
+
+#ifdef TCP_NODELAY
+ {
+ /*
+ * turn off TCP coalescence for INET sockets
+ */
+
+ int tmp = 1;
+ setsockopt (newciptr->fd, IPPROTO_TCP, TCP_NODELAY,
+ (char *) &tmp, sizeof (int));
+ }
+#endif
+
+ /*
+ * Get this address again because the transport may give a more
+ * specific address now that a connection is established.
+ */
+
+ if (TRANS(SocketINETGetAddr) (newciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETAccept: ...SocketINETGetAddr() failed:\n",
+ 0, 0, 0);
+ close (newciptr->fd);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ if (TRANS(SocketINETGetPeerAddr) (newciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETAccept: ...SocketINETGetPeerAddr() failed:\n",
+ 0, 0, 0);
+ close (newciptr->fd);
+ if (newciptr->addr) xfree (newciptr->addr);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ *status = 0;
+
+ return newciptr;
+}
+
+#endif /* TCPCONN */
+
+
+#ifdef UNIXCONN
+static XtransConnInfo
+TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
+
+{
+ XtransConnInfo newciptr;
+ struct sockaddr_un sockname;
+#if defined(SVR4) || defined(__SCO__)
+ size_t namelen = sizeof sockname;
+#else
+ int namelen = sizeof sockname;
+#endif
+
+ PRMSG (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+ if ((newciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketUNIXAccept: malloc() failed\n", 0, 0, 0);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+ if ((newciptr->fd = accept (ciptr->fd,
+ (struct sockaddr *) &sockname, (void *)&namelen)) < 0)
+ {
+ PRMSG (1, "SocketUNIXAccept: accept() failed\n", 0, 0, 0);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_FAILED;
+ return NULL;
+ }
+
+ /*
+ * Get the socket name and the peer name from the listener socket,
+ * since this is unix domain.
+ */
+
+ if ((newciptr->addr = (char *) xalloc (ciptr->addrlen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketUNIXAccept: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ close (newciptr->fd);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+
+ newciptr->addrlen = ciptr->addrlen;
+ memcpy (newciptr->addr, ciptr->addr, newciptr->addrlen);
+
+ if ((newciptr->peeraddr = (char *) xalloc (ciptr->addrlen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketUNIXAccept: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ close (newciptr->fd);
+ if (newciptr->addr) xfree (newciptr->addr);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+ newciptr->peeraddrlen = ciptr->addrlen;
+ memcpy (newciptr->peeraddr, ciptr->addr, newciptr->addrlen);
+
+ newciptr->family = AF_UNIX;
+
+ *status = 0;
+
+ return newciptr;
+}
+
+#endif /* UNIXCONN */
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+#ifdef TCPCONN
+
+#if defined(IPv6) && defined(AF_INET6)
+struct addrlist {
+ struct addrinfo * addr;
+ struct addrinfo * firstaddr;
+ char port[PORTBUFSIZE];
+ char host[MAXHOSTNAMELEN];
+};
+static struct addrlist *addrlist = NULL;
+#endif
+
+
+static int
+TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port)
+
+{
+ struct sockaddr * socketaddr = NULL;
+ int socketaddrlen = 0;
+ int res;
+#if defined(IPv6) && defined(AF_INET6)
+ struct addrinfo hints;
+ char ntopbuf[INET6_ADDRSTRLEN];
+ int resetonce = 0;
+#endif
+ struct sockaddr_in sockname;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+ _Xgetservbynameparams sparams;
+#endif
+ struct hostent *hostp;
+ struct servent *servp;
+ unsigned long tmpaddr;
+#ifdef X11_t
+ char portbuf[PORTBUFSIZE];
+#endif
+
+ long tmpport;
+ char hostnamebuf[256]; /* tmp space */
+
+ PRMSG (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port);
+
+ if (!host)
+ {
+ hostnamebuf[0] = '\0';
+ (void) TRANS(GetHostname) (hostnamebuf, sizeof hostnamebuf);
+ host = hostnamebuf;
+ }
+
+#ifdef X11_t
+ /*
+ * X has a well known port, that is transport dependent. It is easier
+ * to handle it here, than try and come up with a transport independent
+ * representation that can be passed in and resolved the usual way.
+ *
+ * The port that is passed here is really a string containing the idisplay
+ * from ConnectDisplay().
+ */
+
+ if (is_numeric (port))
+ {
+ tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);
+ sprintf (portbuf, "%lu", tmpport);
+ port = portbuf;
+ }
+#endif
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6) {
+ if (addrlist != NULL) {
+ if (strcmp(host,addrlist->host) || strcmp(port,addrlist->port)) {
+ if (addrlist->firstaddr)
+ freeaddrinfo(addrlist->firstaddr);
+ addrlist->firstaddr = NULL;
+ }
+ } else {
+ addrlist = malloc(sizeof(struct addrlist));
+ addrlist->firstaddr = NULL;
+ }
+
+ if (addrlist->firstaddr == NULL) {
+ strncpy(addrlist->port, port, sizeof(addrlist->port));
+ addrlist->port[sizeof(addrlist->port) - 1] = '\0';
+ strncpy(addrlist->host, host, sizeof(addrlist->host));
+ addrlist->host[sizeof(addrlist->host) - 1] = '\0';
+
+ bzero(&hints,sizeof(hints));
+ hints.ai_socktype = Sockettrans2devtab[ciptr->index].devcotsname;
+
+ res = getaddrinfo(host,port,&hints,&addrlist->firstaddr);
+ if (res != 0) {
+ PRMSG (1, "SocketINETConnect() can't get address "
+ "for %s:%s: %s\n", host, port, gai_strerror(res));
+ ESET(EINVAL);
+ return TRANS_CONNECT_FAILED;
+ }
+ for (res = 0, addrlist->addr = addrlist->firstaddr;
+ addrlist->addr ; res++) {
+ addrlist->addr = addrlist->addr->ai_next;
+ }
+ PRMSG(4,"Got New Address list with %d addresses\n", res, 0, 0);
+ res = 0;
+ addrlist->addr = NULL;
+ }
+
+ while (socketaddr == NULL) {
+ if (addrlist->addr == NULL) {
+ if (resetonce) {
+ /* Already checked entire list - no usable addresses */
+ PRMSG (1, "SocketINETConnect() no usable address "
+ "for %s:%s\n", host, port, 0);
+ return TRANS_CONNECT_FAILED;
+ } else {
+ /* Go back to beginning of list */
+ resetonce = 1;
+ addrlist->addr = addrlist->firstaddr;
+ }
+ }
+
+ socketaddr = addrlist->addr->ai_addr;
+ socketaddrlen = addrlist->addr->ai_addrlen;
+
+ if (addrlist->addr->ai_family == AF_INET) {
+ struct sockaddr_in *sin = (struct sockaddr_in *) socketaddr;
+
+ PRMSG (4,"SocketINETConnect() sockname.sin_addr = %s\n",
+ inet_ntop(addrlist->addr->ai_family,&sin->sin_addr,
+ ntopbuf,sizeof(ntopbuf)), 0, 0);
+
+ PRMSG (4,"SocketINETConnect() sockname.sin_port = %d\n",
+ ntohs(sin->sin_port), 0, 0);
+
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET6) {
+ if (strcmp(Sockettrans2devtab[ciptr->index].transname,
+ "tcp") == 0) {
+ XtransConnInfo newciptr;
+
+ /*
+ * Our socket is an IPv6 socket, but the address is
+ * IPv4. Close it and get an IPv4 socket. This is
+ * needed for IPv4 connections to work on platforms
+ * that don't allow IPv4 over IPv6 sockets.
+ */
+ TRANS(SocketINETClose)(ciptr);
+ newciptr = TRANS(SocketOpenCOTSClientBase)(
+ "tcp", "tcp", host, port, ciptr->index);
+ if (newciptr)
+ ciptr->fd = newciptr->fd;
+ if (!newciptr ||
+ Sockettrans2devtab[newciptr->index].family !=
+ AF_INET) {
+ socketaddr = NULL;
+ PRMSG (4,"SocketINETConnect() Cannot get IPv4 "
+ " socketfor IPv4 address\n", 0,0,0);
+ }
+ if (newciptr)
+ xfree(newciptr);
+ } else {
+ socketaddr = NULL;
+ PRMSG (4,"SocketINETConnect Skipping IPv4 address\n",
+ 0,0,0);
+ }
+ }
+ } else if (addrlist->addr->ai_family == AF_INET6) {
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) socketaddr;
+
+ PRMSG (4,"SocketINETConnect() sockname.sin6_addr = %s\n",
+ inet_ntop(addrlist->addr->ai_family,
+ &sin6->sin6_addr,ntopbuf,sizeof(ntopbuf)),
+ 0, 0);
+ PRMSG (4,"SocketINETConnect() sockname.sin6_port = %d\n",
+ ntohs(sin6->sin6_port), 0, 0);
+
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET) {
+ if (strcmp(Sockettrans2devtab[ciptr->index].transname,
+ "tcp") == 0) {
+ XtransConnInfo newciptr;
+
+ /*
+ * Close the IPv4 socket and try to open an IPv6 socket.
+ */
+ TRANS(SocketINETClose)(ciptr);
+ newciptr = TRANS(SocketOpenCOTSClientBase)(
+ "tcp", "tcp", host, port, -1);
+ if (newciptr)
+ ciptr->fd = newciptr->fd;
+ if (!newciptr ||
+ Sockettrans2devtab[newciptr->index].family !=
+ AF_INET6) {
+ socketaddr = NULL;
+ PRMSG (4,"SocketINETConnect() Cannot get IPv6 "
+ "socket for IPv6 address\n", 0,0,0);
+ }
+ if (newciptr)
+ xfree(newciptr);
+ }
+ else
+ {
+ socketaddr = NULL;
+ PRMSG (4,"SocketINETConnect() Skipping IPv6 address\n",
+ 0,0,0);
+ }
+ }
+ } else {
+ socketaddr = NULL; /* Unsupported address type */
+ }
+ if (socketaddr == NULL) {
+ addrlist->addr = addrlist->addr->ai_next;
+ }
+ }
+ } else
+#endif
+ {
+ /*
+ * Build the socket name.
+ */
+
+#ifdef BSD44SOCKETS
+ sockname.sin_len = sizeof (struct sockaddr_in);
+#endif
+ sockname.sin_family = AF_INET;
+
+ /*
+ * fill in sin_addr
+ */
+
+#ifndef INADDR_NONE
+#define INADDR_NONE ((in_addr_t) 0xffffffff)
+#endif
+
+ /* check for ww.xx.yy.zz host string */
+
+ if (isascii (host[0]) && isdigit (host[0])) {
+ tmpaddr = inet_addr (host); /* returns network byte order */
+ } else {
+ tmpaddr = INADDR_NONE;
+ }
+
+ PRMSG (4,"SocketINETConnect() inet_addr(%s) = %x\n", host, tmpaddr, 0);
+
+ if (tmpaddr == INADDR_NONE) {
+ if ((hostp = _XGethostbyname(host,hparams)) == NULL) {
+ PRMSG (1,"SocketINETConnect: Can't get address for %s\n",
+ host, 0, 0);
+ ESET(EINVAL);
+ return TRANS_CONNECT_FAILED;
+ }
+ if (hostp->h_addrtype != AF_INET) { /* is IP host? */
+ PRMSG (1,"SocketINETConnect: not INET host%s\n", host, 0, 0);
+ ESET(EPROTOTYPE);
+ return TRANS_CONNECT_FAILED;
+ }
+
+#if defined(CRAY) && defined(OLDTCP)
+ /* Only Cray UNICOS3 and UNICOS4 will define this */
+ {
+ long t;
+ memcpy ((char *)&t, (char *) hostp->h_addr, sizeof (t));
+ sockname.sin_addr = t;
+ }
+#else
+ memcpy ((char *) &sockname.sin_addr, (char *) hostp->h_addr,
+ sizeof (sockname.sin_addr));
+#endif /* CRAY and OLDTCP */
+
+ } else {
+#if defined(CRAY) && defined(OLDTCP)
+ /* Only Cray UNICOS3 and UNICOS4 will define this */
+ sockname.sin_addr = tmpaddr;
+#else
+ sockname.sin_addr.s_addr = tmpaddr;
+#endif /* CRAY and OLDTCP */
+ }
+
+ /*
+ * fill in sin_port
+ */
+
+ /* Check for number in the port string */
+
+ if (!is_numeric (port)) {
+ if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL) {
+ PRMSG (1,"SocketINETConnect: can't get service for %s\n",
+ port, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+ sockname.sin_port = htons (servp->s_port);
+ } else {
+ tmpport = strtol (port, (char**)NULL, 10);
+ if (tmpport < 1024 || tmpport > USHRT_MAX)
+ return TRANS_CONNECT_FAILED;
+ sockname.sin_port = htons (((unsigned short) tmpport));
+ }
+
+ PRMSG (4,"SocketINETConnect: sockname.sin_port = %d\n",
+ ntohs(sockname.sin_port), 0, 0);
+ socketaddr = (struct sockaddr *) &sockname;
+ socketaddrlen = sizeof(sockname);
+ }
+
+ /*
+ * Turn on socket keepalive so the client process will eventually
+ * be notified with a SIGPIPE signal if the display server fails
+ * to respond to a periodic transmission of messages
+ * on the connected socket.
+ * This is useful to avoid hung application processes when the
+ * processes are not spawned from the xdm session and
+ * the display server terminates abnormally.
+ * (Someone turned off the power switch.)
+ */
+
+ {
+ int tmp = 1;
+ setsockopt (ciptr->fd, SOL_SOCKET, SO_KEEPALIVE,
+ (char *) &tmp, sizeof (int));
+ }
+
+ /*
+ * Do the connect()
+ */
+
+ if (connect (ciptr->fd, socketaddr, socketaddrlen ) < 0)
+ {
+#ifdef WIN32
+ int olderrno = WSAGetLastError();
+#else
+ int olderrno = errno;
+#endif
+
+ /*
+ * If the error was ECONNREFUSED, the server may be overloaded
+ * and we should try again.
+ *
+ * If the error was EWOULDBLOCK or EINPROGRESS then the socket
+ * was non-blocking and we should poll using select
+ *
+ * If the error was EINTR, the connect was interrupted and we
+ * should try again.
+ *
+ * If multiple addresses are found for a host then we should
+ * try to connect again with a different address for a larger
+ * number of errors that made us quit before, since those
+ * could be caused by trying to use an IPv6 address to contact
+ * a machine with an IPv4-only server or other reasons that
+ * only affect one of a set of addresses.
+ */
+
+ if (olderrno == ECONNREFUSED || olderrno == EINTR
+#if defined(IPv6) && defined(AF_INET6)
+ || (haveIPv6 && ((addrlist->addr->ai_next != NULL) ||
+ (addrlist->addr != addrlist->firstaddr)) &&
+ (olderrno == ENETUNREACH || olderrno == EAFNOSUPPORT ||
+ olderrno == EADDRNOTAVAIL || olderrno == ETIMEDOUT
+#if defined(EHOSTDOWN)
+ || olderrno == EHOSTDOWN
+#endif
+ ))
+#endif
+ )
+ res = TRANS_TRY_CONNECT_AGAIN;
+ else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
+ res = TRANS_IN_PROGRESS;
+ else
+ {
+ PRMSG (2,"SocketINETConnect: Can't connect: errno = %d\n",
+ olderrno,0, 0);
+
+ res = TRANS_CONNECT_FAILED;
+ }
+ } else {
+ res = 0;
+
+
+ /*
+ * Sync up the address fields of ciptr.
+ */
+
+ if (TRANS(SocketINETGetAddr) (ciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETConnect: ...SocketINETGetAddr() failed:\n",
+ 0, 0, 0);
+ res = TRANS_CONNECT_FAILED;
+ }
+
+ else if (TRANS(SocketINETGetPeerAddr) (ciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETConnect: ...SocketINETGetPeerAddr() failed:\n",
+ 0, 0, 0);
+ res = TRANS_CONNECT_FAILED;
+ }
+ }
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6 && res != 0) {
+ addrlist->addr = addrlist->addr->ai_next;
+ }
+#endif
+
+ return res;
+}
+
+#endif /* TCPCONN */
+
+
+
+#ifdef UNIXCONN
+
+/*
+ * Make sure 'host' is really local.
+ */
+
+static int
+UnixHostReallyLocal (char *host)
+
+{
+ char hostnamebuf[256];
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (getaddrinfo == NULL)
+ haveIPv6 = 0;
+#endif
+
+ TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf));
+
+ if (strcmp (hostnamebuf, host) == 0)
+ {
+ return (1);
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if (haveIPv6)
+ {
+ struct addrinfo *localhostaddr;
+ struct addrinfo *otherhostaddr;
+ struct addrinfo *i, *j;
+ int equiv = 0;
+
+ if (getaddrinfo(hostnamebuf, NULL, NULL, &localhostaddr) != 0)
+ return 0;
+ if (getaddrinfo(host, NULL, NULL, &otherhostaddr) != 0) {
+ freeaddrinfo(localhostaddr);
+ return 0;
+ }
+
+ for (i = localhostaddr; i != NULL && equiv == 0; i = i->ai_next) {
+ for (j = otherhostaddr; j != NULL && equiv == 0; j = j->ai_next) {
+ if (i->ai_family == j->ai_family) {
+ if (i->ai_family == AF_INET) {
+ struct sockaddr_in *sinA
+ = (struct sockaddr_in *) i->ai_addr;
+ struct sockaddr_in *sinB
+ = (struct sockaddr_in *) j->ai_addr;
+ struct in_addr *A = &sinA->sin_addr;
+ struct in_addr *B = &sinB->sin_addr;
+
+ if (memcmp(A,B,sizeof(struct in_addr)) == 0) {
+ equiv = 1;
+ }
+ } else if (i->ai_family == AF_INET6) {
+ struct sockaddr_in6 *sinA
+ = (struct sockaddr_in6 *) i->ai_addr;
+ struct sockaddr_in6 *sinB
+ = (struct sockaddr_in6 *) j->ai_addr;
+ struct in6_addr *A = &sinA->sin6_addr;
+ struct in6_addr *B = &sinB->sin6_addr;
+
+ if (memcmp(A,B,sizeof(struct in6_addr)) == 0) {
+ equiv = 1;
+ }
+ }
+ }
+ }
+ }
+
+ freeaddrinfo(localhostaddr);
+ freeaddrinfo(otherhostaddr);
+ return equiv;
+ }
+#endif
+ else
+ {
+ /*
+ * A host may have more than one network address. If any of the
+ * network addresses of 'host' (specified to the connect call)
+ * match any of the network addresses of 'hostname' (determined
+ * by TRANS(GetHostname)), then the two hostnames are equivalent,
+ * and we know that 'host' is really a local host.
+ */
+ char specified_local_addr_list[10][4];
+ int scount, equiv, i, j;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ struct hostent *hostp;
+
+ if ((hostp = _XGethostbyname (host,hparams)) == NULL)
+ return (0);
+
+ scount = 0;
+ while (hostp->h_addr_list[scount] && scount <= 8)
+ {
+ /*
+ * The 2nd call to gethostname() overrides the data
+ * from the 1st call, so we must save the address list.
+ */
+
+ specified_local_addr_list[scount][0] =
+ hostp->h_addr_list[scount][0];
+ specified_local_addr_list[scount][1] =
+ hostp->h_addr_list[scount][1];
+ specified_local_addr_list[scount][2] =
+ hostp->h_addr_list[scount][2];
+ specified_local_addr_list[scount][3] =
+ hostp->h_addr_list[scount][3];
+ scount++;
+ }
+ if ((hostp = _XGethostbyname (hostnamebuf,hparams)) == NULL)
+ return (0);
+
+ equiv = 0;
+ i = 0;
+
+ while (i < scount && !equiv)
+ {
+ j = 0;
+
+ while (hostp->h_addr_list[j])
+ {
+ if ((specified_local_addr_list[i][0] ==
+ hostp->h_addr_list[j][0]) &&
+ (specified_local_addr_list[i][1] ==
+ hostp->h_addr_list[j][1]) &&
+ (specified_local_addr_list[i][2] ==
+ hostp->h_addr_list[j][2]) &&
+ (specified_local_addr_list[i][3] ==
+ hostp->h_addr_list[j][3]))
+ {
+ /* They're equal, so we're done */
+
+ equiv = 1;
+ break;
+ }
+
+ j++;
+ }
+
+ i++;
+ }
+ return (equiv);
+ }
+}
+
+static int
+TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
+
+{
+ struct sockaddr_un sockname;
+ int namelen;
+
+#if defined(hpux) && defined(X11_t)
+ struct sockaddr_un old_sockname;
+ int old_namelen;
+#endif
+
+
+ PRMSG (2,"SocketUNIXConnect(%d,%s,%s)\n", ciptr->fd, host, port);
+
+ /*
+ * Make sure 'host' is really local. If not, we return failure.
+ * The reason we make this check is because a process may advertise
+ * a "local" network ID for which it can accept connections, but if
+ * a process on a remote machine tries to connect to this network ID,
+ * we know for sure it will fail.
+ */
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+ if (strcmp(host, "unix") != 0 && strcasecmp(host, "nx") != 0 &&
+ strncasecmp(host, "nx,", 3) != 0 && !UnixHostReallyLocal (host))
+#else
+ if (strcmp (host, "unix") != 0 && !UnixHostReallyLocal (host))
+#endif
+ {
+ PRMSG (1,
+ "SocketUNIXConnect: Cannot connect to non-local host %s\n",
+ host, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+
+ /*
+ * Check the port.
+ */
+
+ if (!port || !*port)
+ {
+ PRMSG (1,"SocketUNIXConnect: Missing port specification\n",
+ 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+ /*
+ * Build the socket name.
+ */
+
+ sockname.sun_family = AF_UNIX;
+
+#ifdef NX_TRANS_SOCKET
+ if (set_sun_path(port, _NXGetUnixPath(UNIX_PATH), sockname.sun_path) != 0) {
+#else
+ if (set_sun_path(port, UNIX_PATH, sockname.sun_path) != 0) {
+#endif
+ PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) && !defined(Lynx)
+ sockname.sun_len = strlen (sockname.sun_path);
+ namelen = SUN_LEN (&sockname);
+#else
+ namelen = strlen (sockname.sun_path) + sizeof (sockname.sun_family);
+#endif
+
+
+#if defined(hpux) && defined(X11_t)
+ /*
+ * This is gross, but it was in Xlib
+ */
+ old_sockname.sun_family = AF_UNIX;
+#ifdef NX_TRANS_SOCKET
+ if (set_sun_path(port, _NXGetOldUnixPath(OLD_UNIX_PATH), old_sockname.sun_path) != 0) {
+#else
+ if (set_sun_path(port, OLD_UNIX_PATH, old_sockname.sun_path) != 0) {
+#endif
+ PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+ old_namelen = strlen (old_sockname.sun_path) +
+ sizeof (old_sockname.sun_family);
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ if (ciptr->priv != NULL)
+ {
+ if (TRANS(SocketConnectConnInfo) (ciptr, host, port) != 0)
+ {
+ return TRANS_CONNECT_FAILED;
+ }
+
+ goto SocketUNIXConnectPost;
+ }
+
+#endif
+
+ /*
+ * Do the connect()
+ */
+
+ if (connect (ciptr->fd, (struct sockaddr *) &sockname, namelen) < 0)
+ {
+ int olderrno = errno;
+ int connected = 0;
+
+#if defined(hpux) && defined(X11_t)
+ if (olderrno == ENOENT)
+ {
+ if (connect (ciptr->fd,
+ (struct sockaddr *) &old_sockname, old_namelen) >= 0)
+ {
+ connected = 1;
+ }
+ else
+ olderrno = errno;
+ }
+#endif
+ if (!connected)
+ {
+ errno = olderrno;
+
+ /*
+ * If the error was ENOENT, the server may be starting up
+ * and we should try again.
+ *
+ * If the error was EWOULDBLOCK or EINPROGRESS then the socket
+ * was non-blocking and we should poll using select
+ *
+ * If the error was EINTR, the connect was interrupted and we
+ * should try again.
+ */
+
+ if (olderrno == ENOENT || olderrno == EINTR)
+ return TRANS_TRY_CONNECT_AGAIN;
+ else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
+ return TRANS_IN_PROGRESS;
+ else
+ {
+ PRMSG (2,"SocketUNIXConnect: Can't connect: errno = %d\n",
+ EGET(),0, 0);
+
+ return TRANS_CONNECT_FAILED;
+ }
+ }
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+SocketUNIXConnectPost:
+
+#endif
+
+ /*
+ * Get the socket name and the peer name from the connect socket,
+ * since this is unix domain.
+ */
+
+ if ((ciptr->addr = (char *) xalloc(namelen)) == NULL ||
+ (ciptr->peeraddr = (char *) xalloc(namelen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketUNIXCreateListener: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+ ciptr->family = AF_UNIX;
+ ciptr->addrlen = namelen;
+ ciptr->peeraddrlen = namelen;
+ memcpy (ciptr->addr, &sockname, ciptr->addrlen);
+ memcpy (ciptr->peeraddr, &sockname, ciptr->peeraddrlen);
+
+ return 0;
+}
+
+#endif /* UNIXCONN */
+
+#endif /* TRANS_CLIENT */
+
+
+static int
+TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)
+
+{
+ PRMSG (2,"SocketBytesReadable(%p,%d,%p)\n",
+ ciptr, ciptr->fd, pend);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ if (ciptr->priv)
+ {
+ if (NXTransRunning(ciptr->fd) == 0)
+ {
+ /*
+ * Force the application to shut down the
+ * socket if the NX transport is gone. We
+ * may probably save this additional call.
+ */
+
+#ifdef NX_TRANS_DEBUG
+ fprintf(stderr, "SocketBytesReadable: NX transport not running for descriptor [%d].\n",
+ ciptr->fd);
+#endif
+ ESET(EPIPE);
+
+ return -1;
+ }
+ else
+ {
+ /*
+ * Emulate BytesReadable. Some X applications may use the system
+ * select() in their main loop, instead of the _XSelect() that is
+ * replaced by NX. Still these applications use _XEventsQueued to
+ * poll events from the X connection, and _XEventsQueued uses the
+ * NX _XSelect(), so it is generally possible to let the client
+ * yield the control to NX and let it handle the I/O on the proxy
+ * descriptors even if the application is not explicitly designed
+ * to work as a NX agent.
+ */
+
+#ifdef NX_TRANS_DEBUG
+
+ int result;
+
+ result = NXTransReadable(ciptr->fd, (int *) pend);
+
+ fprintf(stderr, "SocketBytesReadable: Descriptor [%d] result [%d] readable [%ld].\n",
+ ciptr->fd, result, *pend);
+
+ return result;
+#else
+ return NXTransReadable(ciptr->fd, (int *) pend);
+#endif
+ }
+ }
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+#if defined(QNX4)
+ *pend = 0L; /* FIONREAD only returns a short. Zero out upper bits */
+#endif
+#ifdef WIN32
+ {
+ int ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+#if (defined(i386) && defined(SYSV) && !defined(SCO325)) || (defined(_SEQUENT_) && _SOCKET_VERSION == 1)
+ return ioctl (ciptr->fd, I_NREAD, (char *) pend);
+#else
+#if defined(__UNIXOS2__)
+ return ioctl (ciptr->fd, FIONREAD, (char*) pend, sizeof(int));
+#else
+ return ioctl (ciptr->fd, FIONREAD, (char *) pend);
+#endif /* __UNIXOS2__ */
+#endif /* i386 && SYSV || _SEQUENT_ && _SOCKET_VERSION == 1 */
+#endif /* WIN32 */
+}
+
+
+static int
+TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+ PRMSG (2,"SocketRead(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ /*
+ * If we have a valid priv pointer then this
+ * is an internal connection to the proxy.
+ * In this case we should emulate the read.
+ */
+
+ if (ciptr->priv)
+ {
+ int result;
+
+ result = NXTransRead(ciptr->fd, buf, size);
+
+#ifdef NX_TRANS_DEBUG
+ if (result < 0 && EGET() == EAGAIN)
+ {
+ fprintf(stderr, "SocketRead: Read from descriptor [%d] would block.\n",
+ ciptr->fd);
+ }
+ else
+ {
+ fprintf(stderr, "SocketRead: Read [%d] bytes from descriptor [%d].\n",
+ result, ciptr->fd);
+ }
+#endif
+ return result;
+ }
+ else
+ {
+ return read (ciptr->fd, buf, size);
+ }
+
+#else /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+#if defined(WIN32) || defined(__UNIXOS2__)
+ {
+ int ret = recv ((SOCKET)ciptr->fd, buf, size, 0);
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ return ret;
+ }
+#else
+ return read (ciptr->fd, buf, size);
+#endif /* WIN32 */
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+}
+
+
+static int
+TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+ PRMSG (2,"SocketWrite(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ /*
+ * If we have a valid priv pointer then this
+ * is an internal connection to the proxy.
+ * In this case we should emulate the write.
+ */
+
+ if (ciptr->priv)
+ {
+ int result;
+
+ result = NXTransWrite(ciptr->fd, buf, size);
+
+#ifdef NX_TRANS_DEBUG
+ if (result < 0 && EGET() == EAGAIN)
+ {
+ fprintf(stderr, "SocketWrite: Write on descriptor [%d] would block.\n",
+ ciptr->fd);
+ }
+ else
+ {
+ fprintf(stderr, "SocketWrite: Written [%d] bytes on descriptor [%d].\n",
+ result, ciptr->fd);
+ }
+#endif
+ return result;
+ }
+ else
+ {
+ return write (ciptr->fd, buf, size);
+ }
+
+#else /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+#if defined(WIN32) || defined(__UNIXOS2__)
+ {
+ int ret = send ((SOCKET)ciptr->fd, buf, size, 0);
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ return ret;
+ }
+#else
+ return write (ciptr->fd, buf, size);
+#endif /* WIN32 */
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+}
+
+
+static int
+TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ PRMSG (2,"SocketReadv(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ /*
+ * If we have a valid priv pointer then this
+ * is an internal connection to the proxy.
+ * In this case we should emulate the readv.
+ */
+
+ if (ciptr->priv)
+ {
+ return NXTransReadVector(ciptr->fd, buf, size);
+ }
+ else
+ {
+ return READV (ciptr, buf, size);
+ }
+
+#else /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+ return READV (ciptr, buf, size);
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+}
+
+
+static int
+TRANS(SocketWritev) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ PRMSG (2,"SocketWritev(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ /*
+ * If we have a valid priv pointer then this
+ * is an internal connection to the proxy.
+ * In this case we should emulate the writev.
+ */
+
+ if (ciptr->priv)
+ {
+ return NXTransWriteVector(ciptr->fd, buf, size);
+ }
+ else
+ {
+ return WRITEV (ciptr, buf, size);
+ }
+
+#else /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+
+ return WRITEV (ciptr, buf, size);
+
+#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */
+}
+
+
+static int
+TRANS(SocketDisconnect) (XtransConnInfo ciptr)
+
+{
+ PRMSG (2,"SocketDisconnect(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+#ifdef WIN32
+ {
+ int ret = shutdown (ciptr->fd, 2);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+ return shutdown (ciptr->fd, 2); /* disallow further sends and receives */
+#endif
+}
+
+
+#ifdef TCPCONN
+static int
+TRANS(SocketINETClose) (XtransConnInfo ciptr)
+
+{
+ PRMSG (2,"SocketINETClose(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+#ifdef WIN32
+ {
+ int ret = close (ciptr->fd);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+ return close (ciptr->fd);
+#endif
+}
+
+#endif /* TCPCONN */
+
+
+#ifdef UNIXCONN
+static int
+TRANS(SocketUNIXClose) (XtransConnInfo ciptr)
+
+{
+ /*
+ * If this is the server side, then once the socket is closed,
+ * it must be unlinked to completely close it
+ */
+
+ struct sockaddr_un *sockname = (struct sockaddr_un *) ciptr->addr;
+ int ret;
+
+ PRMSG (2,"SocketUNIXClose(%x,%d)\n", ciptr, ciptr->fd, 0);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ if (ciptr->priv)
+ {
+ TRANS(SocketCloseConnInfo) (ciptr);
+ }
+
+#endif
+
+ ret = close(ciptr->fd);
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "SocketUNIXClose: Flags are [%d] for ciptr at [%p] check is [%d].\n",
+ ciptr->flags, (void *) ciptr, (ciptr->flags && sockname
+ && sockname->sun_family == AF_UNIX && sockname->sun_path[0]));
+#endif
+
+ if (ciptr->flags
+ && sockname
+ && sockname->sun_family == AF_UNIX
+ && sockname->sun_path[0])
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ if (!(ciptr->flags & TRANS_NOUNLINK))
+ {
+ fprintf(stderr, "SocketUNIXClose: Unlinking path [%s] for ciptr at [%p].\n",
+ sockname->sun_path, (void *) ciptr);
+ unlink (sockname->sun_path);
+ }
+#else
+ if (!(ciptr->flags & TRANS_NOUNLINK))
+ unlink (sockname->sun_path);
+#endif
+ }
+
+ return ret;
+}
+
+static int
+TRANS(SocketUNIXCloseForCloning) (XtransConnInfo ciptr)
+
+{
+ /*
+ * Don't unlink path.
+ */
+
+ int ret;
+
+ PRMSG (2,"SocketUNIXCloseForCloning(%p,%d)\n",
+ ciptr, ciptr->fd, 0);
+
+#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT)
+
+ if (ciptr->priv)
+ {
+ TRANS(SocketCloseConnInfo) (ciptr);
+ }
+
+#endif
+
+ ret = close(ciptr->fd);
+
+ return ret;
+}
+
+#endif /* UNIXCONN */
+
+
+#ifdef TCPCONN
+# ifdef TRANS_SERVER
+static char* tcp_nolisten[] = {
+ "inet",
+#if defined(IPv6) && defined(AF_INET6)
+ "inet6",
+#endif
+ NULL
+};
+# endif
+
+Xtransport TRANS(SocketTCPFuncs) = {
+ /* Socket Interface */
+ "tcp",
+ TRANS_ALIAS,
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ tcp_nolisten,
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketINETCreateListener),
+ NULL, /* ResetListener */
+ TRANS(SocketINETAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketINETConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketINETClose),
+ TRANS(SocketINETClose),
+ };
+
+Xtransport TRANS(SocketINETFuncs) = {
+ /* Socket Interface */
+ "inet",
+ 0,
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketINETCreateListener),
+ NULL, /* ResetListener */
+ TRANS(SocketINETAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketINETConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketINETClose),
+ TRANS(SocketINETClose),
+ };
+
+#if defined(IPv6) && defined(AF_INET6)
+Xtransport TRANS(SocketINET6Funcs) = {
+ /* Socket Interface */
+ "inet6",
+ 0,
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketINETCreateListener),
+ NULL, /* ResetListener */
+ TRANS(SocketINETAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketINETConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketINETClose),
+ TRANS(SocketINETClose),
+ };
+#endif /* IPv6 */
+#endif /* TCPCONN */
+
+#ifdef UNIXCONN
+#if !defined(LOCALCONN)
+Xtransport TRANS(SocketLocalFuncs) = {
+ /* Socket Interface */
+ "local",
+ 0,
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketUNIXCreateListener),
+ TRANS(SocketUNIXResetListener),
+ TRANS(SocketUNIXAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketUNIXConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketUNIXClose),
+ TRANS(SocketUNIXCloseForCloning),
+ };
+#endif /* !LOCALCONN */
+# ifdef TRANS_SERVER
+# if !defined(LOCALCONN)
+static char* unix_nolisten[] = { "local" , NULL };
+# endif
+# endif
+
+Xtransport TRANS(SocketUNIXFuncs) = {
+ /* Socket Interface */
+ "unix",
+#if !defined(LOCALCONN)
+ TRANS_ALIAS,
+#else
+ 0,
+#endif
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+#if !defined(LOCALCONN)
+ unix_nolisten,
+#else
+ NULL,
+#endif
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketUNIXCreateListener),
+ TRANS(SocketUNIXResetListener),
+ TRANS(SocketUNIXAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketUNIXConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketUNIXClose),
+ TRANS(SocketUNIXCloseForCloning),
+ };
+
+#endif /* UNIXCONN */
diff --git a/nx-X11/lib/xtrans/Xtranssock.c.X.original b/nx-X11/lib/xtrans/Xtranssock.c.X.original
new file mode 100644
index 000000000..0f3c6b46a
--- /dev/null
+++ b/nx-X11/lib/xtrans/Xtranssock.c.X.original
@@ -0,0 +1,2504 @@
+/* $XdotOrg: xc/lib/xtrans/Xtranssock.c,v 1.11 2005/11/08 06:33:26 jkj Exp $ */
+/* $Xorg: Xtranssock.c,v 1.11 2001/02/09 02:04:06 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+Copyright 2002 Sun Microsystems, Inc. All rights reserved.
+
+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 copyright holders 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 copyright holders.
+
+*/
+/* $XFree86: xc/lib/xtrans/Xtranssock.c,v 3.68 2004/01/07 04:28:02 dawes Exp $ */
+
+/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * 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 NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCR makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR 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 <ctype.h>
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+
+#ifndef WIN32
+
+#if defined(TCPCONN) || defined(UNIXCONN)
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+
+#if defined(TCPCONN) || defined(UNIXCONN)
+#define X_INCLUDE_NETDB_H
+#define XOS_USE_NO_LOCKING
+#include <X11/Xos_r.h>
+#endif
+
+#ifdef UNIXCONN
+#ifndef X_NO_SYS_UN
+#ifndef Lynx
+#include <sys/un.h>
+#else
+#include <un.h>
+#endif
+#endif
+#include <sys/stat.h>
+#endif
+
+#if defined(hpux) || (defined(MOTOROLA) && defined(SYSV))
+#define NO_TCP_H
+#endif
+
+#ifndef NO_TCP_H
+#if defined(__osf__) || defined(linux) || defined(__GLIBC__) || defined(AIXV5)
+#include <sys/param.h>
+#endif /* osf */
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
+#include <sys/param.h>
+#include <machine/endian.h>
+#endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ || __DragonFly__ */
+#include <netinet/tcp.h>
+#endif /* !NO_TCP_H */
+
+#include <sys/ioctl.h>
+#if defined(SVR4) && !defined(DGUX) && !defined(_SEQUENT_)
+#include <sys/filio.h>
+#endif
+
+#if (defined(i386) && defined(SYSV)) && !defined(SCO325) && !defined(sun)
+#include <net/errno.h>
+#endif
+
+#if (defined(i386) && defined(SYSV)) && (!defined(ISC) || !defined(I_NREAD) || defined(SCO325)) || defined(_SEQUENT_)
+#include <sys/stropts.h>
+#endif
+
+#else /* !WIN32 */
+
+#include <X11/Xwinsock.h>
+#include <X11/Xwindows.h>
+#include <X11/Xw32defs.h>
+#undef close
+#define close closesocket
+#define ECONNREFUSED WSAECONNREFUSED
+#define EADDRINUSE WSAEADDRINUSE
+#define EPROTOTYPE WSAEPROTOTYPE
+#undef EWOULDBLOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#define EINPROGRESS WSAEINPROGRESS
+#undef EINTR
+#define EINTR WSAEINTR
+#define X_INCLUDE_NETDB_H
+#define XOS_USE_MTSAFE_NETDBAPI
+#include <X11/Xos_r.h>
+#endif /* WIN32 */
+
+#if defined(SO_DONTLINGER) && defined(SO_LINGER)
+#undef SO_DONTLINGER
+#endif
+
+#if defined(__UNIXOS2__)
+#if defined(NOT_EMX09A)
+static int IBMsockInit = 0;
+#define SocketInitOnce()\
+ if (!IBMsockInit) {\
+ sock_init();\
+ IBMsockInit = 1;\
+ }
+#undef EINTR
+#define EINTR SOCEINTR
+#undef EINVAL
+#define EINVAL SOCEINVAL
+#undef errno
+#define errno sock_errno()
+#undef close
+#define close soclose
+#undef ioctl
+#define ioctl sockioctl
+#else
+#define SocketInitOnce() /**/
+#endif
+/* this is still not there */
+#define SOCKET int
+#else
+/* others don't need this */
+#define SocketInitOnce() /**/
+#endif
+
+#define MIN_BACKLOG 128
+#ifdef SOMAXCONN
+#if SOMAXCONN > MIN_BACKLOG
+#define BACKLOG SOMAXCONN
+#endif
+#endif
+#ifndef BACKLOG
+#define BACKLOG MIN_BACKLOG
+#endif
+/*
+ * This is the Socket implementation of the X Transport service layer
+ *
+ * This file contains the implementation for both the UNIX and INET domains,
+ * and can be built for either one, or both.
+ *
+ */
+
+typedef struct _Sockettrans2dev {
+ char *transname;
+ int family;
+ int devcotsname;
+ int devcltsname;
+ int protocol;
+} Sockettrans2dev;
+
+static Sockettrans2dev Sockettrans2devtab[] = {
+#ifdef TCPCONN
+ {"inet",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
+#if !defined(IPv6) || !defined(AF_INET6)
+ {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
+#else /* IPv6 */
+ {"tcp",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
+ {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, /* fallback */
+ {"inet6",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
+#endif
+#endif /* TCPCONN */
+#ifdef UNIXCONN
+ {"unix",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},
+#if !defined(LOCALCONN)
+ {"local",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},
+#endif /* !LOCALCONN */
+#endif /* UNIXCONN */
+};
+
+#define NUMSOCKETFAMILIES (sizeof(Sockettrans2devtab)/sizeof(Sockettrans2dev))
+
+#ifdef TCPCONN
+static int TRANS(SocketINETClose) (XtransConnInfo ciptr);
+#endif
+
+#ifdef UNIXCONN
+
+#ifdef hpux
+
+#if defined(X11_t)
+#define UNIX_PATH "/usr/spool/sockets/X11/"
+#define UNIX_DIR "/usr/spool/sockets/X11"
+#define OLD_UNIX_PATH "/tmp/.X11-unix/X"
+#endif /* X11_t */
+#if defined(XIM_t)
+#define UNIX_PATH "/usr/spool/sockets/XIM/"
+#define UNIX_DIR "/usr/spool/sockets/XIM"
+#define OLD_UNIX_PATH "/tmp/.XIM-unix/XIM"
+#endif /* XIM_t */
+#if defined(FS_t) || defined(FONT_t)
+#define UNIX_PATH "/usr/spool/sockets/fontserv/"
+#define UNIX_DIR "/usr/spool/sockets/fontserv"
+#endif /* FS_t || FONT_t */
+#if defined(ICE_t)
+#define UNIX_PATH "/usr/spool/sockets/ICE/"
+#define UNIX_DIR "/usr/spool/sockets/ICE"
+#endif /* ICE_t */
+#if defined(TEST_t)
+#define UNIX_PATH "/usr/spool/sockets/xtrans_test/"
+#define UNIX_DIR "/usr/spool/sockets/xtrans_test"
+#endif
+#if defined(LBXPROXY_t)
+#define UNIX_PATH "/usr/spool/sockets/X11/"
+#define UNIX_DIR "/usr/spool/sockets/X11"
+#endif
+
+#else /* !hpux */
+
+#if defined(X11_t)
+#define UNIX_PATH "/tmp/.X11-unix/X"
+#define UNIX_DIR "/tmp/.X11-unix"
+#endif /* X11_t */
+#if defined(XIM_t)
+#define UNIX_PATH "/tmp/.XIM-unix/XIM"
+#define UNIX_DIR "/tmp/.XIM-unix"
+#endif /* XIM_t */
+#if defined(FS_t) || defined(FONT_t)
+#define UNIX_PATH "/tmp/.font-unix/fs"
+#define UNIX_DIR "/tmp/.font-unix"
+#endif /* FS_t || FONT_t */
+#if defined(ICE_t)
+#define UNIX_PATH "/tmp/.ICE-unix/"
+#define UNIX_DIR "/tmp/.ICE-unix"
+#endif /* ICE_t */
+#if defined(TEST_t)
+#define UNIX_PATH "/tmp/.Test-unix/test"
+#define UNIX_DIR "/tmp/.Test-unix"
+#endif
+#if defined(LBXPROXY_t)
+#define UNIX_PATH "/tmp/.X11-unix/X"
+#define UNIX_DIR "/tmp/.X11-unix"
+#endif
+
+#endif /* hpux */
+
+#endif /* UNIXCONN */
+
+#define PORTBUFSIZE 32
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 255
+#endif
+
+/*
+ * This provides compatibility for apps linked against system libraries
+ * that don't have IPv6 support.
+ */
+#if defined(IPv6) && defined(AF_INET6)
+static const struct in6_addr local_in6addr_any = IN6ADDR_ANY_INIT;
+#pragma weak in6addr_any = local_in6addr_any
+#ifndef __USLC__
+#pragma weak getaddrinfo
+#endif
+static int haveIPv6 = 1;
+#endif
+
+/*
+ * These are some utility function used by the real interface function below.
+ */
+
+static int
+TRANS(SocketSelectFamily) (int first, char *family)
+
+{
+ int i;
+
+ PRMSG (3,"SocketSelectFamily(%s)\n", family, 0, 0);
+
+ for (i = first + 1; i < NUMSOCKETFAMILIES;i++)
+ {
+ if (!strcmp (family, Sockettrans2devtab[i].transname))
+ return i;
+ }
+
+ return (first == -1 ? -2 : -1);
+}
+
+
+/*
+ * This function gets the local address of the socket and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(SocketINETGetAddr) (XtransConnInfo ciptr)
+
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_storage socknamev6;
+#endif
+ struct sockaddr_in socknamev4;
+ void *socknamePtr;
+#if defined(SVR4) || defined(__SCO__)
+ size_t namelen;
+#else
+ int namelen;
+#endif
+
+ PRMSG (3,"SocketINETGetAddr(%p)\n", ciptr, 0, 0);
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6)
+ {
+ namelen = sizeof(socknamev6);
+ socknamePtr = &socknamev6;
+ }
+ else
+#endif
+ {
+ namelen = sizeof(socknamev4);
+ socknamePtr = &socknamev4;
+ }
+
+ if (getsockname (ciptr->fd,(struct sockaddr *) socknamePtr,
+ (void *)&namelen) < 0)
+ {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ PRMSG (1,"SocketINETGetAddr: getsockname() failed: %d\n",
+ EGET(),0, 0);
+ return -1;
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if ((ciptr->addr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketINETGetAddr: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ return -1;
+ }
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6)
+ {
+ ciptr->family = ((struct sockaddr *)socknamePtr)->sa_family;
+ }
+ else
+#endif
+ {
+ ciptr->family = socknamev4.sin_family;
+ }
+ ciptr->addrlen = namelen;
+ memcpy (ciptr->addr, socknamePtr, ciptr->addrlen);
+
+ return 0;
+}
+
+
+/*
+ * This function gets the remote address of the socket and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr)
+
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_storage socknamev6;
+#endif
+ struct sockaddr_in socknamev4;
+ void *socknamePtr;
+#if defined(SVR4) || defined(__SCO__)
+ size_t namelen;
+#else
+ int namelen;
+#endif
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6 && ciptr->family == AF_INET6)
+ {
+ namelen = sizeof(socknamev6);
+ socknamePtr = &socknamev6;
+ }
+ else
+#endif
+ {
+ namelen = sizeof(socknamev4);
+ socknamePtr = &socknamev4;
+ }
+
+ PRMSG (3,"SocketINETGetPeerAddr(%p)\n", ciptr, 0, 0);
+
+ if (getpeername (ciptr->fd, (struct sockaddr *) socknamePtr,
+ (void *)&namelen) < 0)
+ {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ PRMSG (1,"SocketINETGetPeerAddr: getpeername() failed: %d\n",
+ EGET(), 0, 0);
+ return -1;
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if ((ciptr->peeraddr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketINETGetPeerAddr: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ return -1;
+ }
+
+ ciptr->peeraddrlen = namelen;
+ memcpy (ciptr->peeraddr, socknamePtr, ciptr->peeraddrlen);
+
+ return 0;
+}
+
+
+static XtransConnInfo
+TRANS(SocketOpen) (int i, int type)
+
+{
+ XtransConnInfo ciptr;
+
+ PRMSG (3,"SocketOpen(%d,%d)\n", i, type, 0);
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (getaddrinfo == NULL)
+ haveIPv6 = 0;
+
+ if (!haveIPv6 && Sockettrans2devtab[i].family == AF_INET6)
+ return NULL;
+#endif
+
+ if ((ciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketOpen: malloc failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ if ((ciptr->fd = socket(Sockettrans2devtab[i].family, type,
+ Sockettrans2devtab[i].protocol)) < 0
+#ifndef WIN32
+#if (defined(X11_t) && !defined(USE_POLL)) || defined(FS_t) || defined(FONT_t)
+ || ciptr->fd >= TRANS_OPEN_MAX
+#endif
+#endif
+ ) {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ PRMSG (2, "SocketOpen: socket() failed for %s\n",
+ Sockettrans2devtab[i].transname, 0, 0);
+
+ xfree ((char *) ciptr);
+ return NULL;
+ }
+
+#ifdef TCP_NODELAY
+ if (Sockettrans2devtab[i].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+ || Sockettrans2devtab[i].family == AF_INET6
+#endif
+ )
+ {
+ /*
+ * turn off TCP coalescence for INET sockets
+ */
+
+ int tmp = 1;
+ setsockopt (ciptr->fd, IPPROTO_TCP, TCP_NODELAY,
+ (char *) &tmp, sizeof (int));
+ }
+#endif
+
+ return ciptr;
+}
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(SocketReopen) (int i, int type, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+
+ PRMSG (3,"SocketReopen(%d,%d,%s)\n", type, fd, port);
+
+ if ((ciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketReopen: malloc failed\n", 0, 0, 0);
+ return NULL;
+ }
+
+ ciptr->fd = fd;
+
+ return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+/*
+ * These functions are the interface supplied in the Xtransport structure
+ */
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(SocketOpenCOTSClientBase) (char *transname, char *protocol,
+ char *host, char *port, int previndex)
+{
+ XtransConnInfo ciptr;
+ int i = previndex;
+
+ PRMSG (2, "SocketOpenCOTSClient(%s,%s,%s)\n",
+ protocol, host, port);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, transname)) >= 0) {
+ if ((ciptr = TRANS(SocketOpen) (
+ i, Sockettrans2devtab[i].devcotsname)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketOpenCOTSClient: Unable to open socket for %s\n",
+ transname, 0, 0);
+ else
+ PRMSG (1,"SocketOpenCOTSClient: Unable to determine socket type for %s\n",
+ transname, 0, 0);
+ return NULL;
+ }
+
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+static XtransConnInfo
+TRANS(SocketOpenCOTSClient) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+{
+ return TRANS(SocketOpenCOTSClientBase)(
+ thistrans->TransName, protocol, host, port, -1);
+}
+
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,"SocketOpenCOTSServer(%s,%s,%s)\n", protocol, host, port);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+ if ((ciptr = TRANS(SocketOpen) (
+ i, Sockettrans2devtab[i].devcotsname)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketOpenCOTSServer: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketOpenCOTSServer: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+ /*
+ * Using this prevents the bind() check for an existing server listening
+ * on the same port, but it is required for other reasons.
+ */
+#ifdef SO_REUSEADDR
+
+ /*
+ * SO_REUSEADDR only applied to AF_INET && AF_INET6
+ */
+
+ if (Sockettrans2devtab[i].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+ || Sockettrans2devtab[i].family == AF_INET6
+#endif
+ )
+ {
+ int one = 1;
+ setsockopt (ciptr->fd, SOL_SOCKET, SO_REUSEADDR,
+ (char *) &one, sizeof (int));
+ }
+#endif
+#ifdef IPV6_V6ONLY
+ if (Sockettrans2devtab[i].family == AF_INET6)
+ {
+ int one = 1;
+ setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int));
+ }
+#endif
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(SocketOpenCLTSClient) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,"SocketOpenCLTSClient(%s,%s,%s)\n", protocol, host, port);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+ if ((ciptr = TRANS(SocketOpen) (
+ i, Sockettrans2devtab[i].devcotsname)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketOpenCLTSClient: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketOpenCLTSClient: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(SocketOpenCLTSServer) (Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,"SocketOpenCLTSServer(%s,%s,%s)\n", protocol, host, port);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+ if ((ciptr = TRANS(SocketOpen) (
+ i, Sockettrans2devtab[i].devcotsname)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketOpenCLTSServer: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketOpenCLTSServer: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+#ifdef IPV6_V6ONLY
+ if (Sockettrans2devtab[i].family == AF_INET6)
+ {
+ int one = 1;
+ setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int));
+ }
+#endif
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(SocketReopenCOTSServer) (Xtransport *thistrans, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,
+ "SocketReopenCOTSServer(%d, %s)\n", fd, port, 0);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+ if ((ciptr = TRANS(SocketReopen) (
+ i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketReopenCOTSServer: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketReopenCOTSServer: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+static XtransConnInfo
+TRANS(SocketReopenCLTSServer) (Xtransport *thistrans, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i = -1;
+
+ PRMSG (2,
+ "SocketReopenCLTSServer(%d, %s)\n", fd, port, 0);
+
+ SocketInitOnce();
+
+ while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+ if ((ciptr = TRANS(SocketReopen) (
+ i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL)
+ break;
+ }
+ if (i < 0) {
+ if (i == -1)
+ PRMSG (1,"SocketReopenCLTSServer: Unable to open socket for %s\n",
+ thistrans->TransName, 0, 0);
+ else
+ PRMSG (1,"SocketReopenCLTSServer: Unable to determine socket type for %s\n",
+ thistrans->TransName, 0, 0);
+ return NULL;
+ }
+
+ /* Save the index for later use */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+static int
+TRANS(SocketSetOption) (XtransConnInfo ciptr, int option, int arg)
+
+{
+ PRMSG (2,"SocketSetOption(%d,%d,%d)\n", ciptr->fd, option, arg);
+
+ return -1;
+}
+
+#ifdef UNIXCONN
+static int
+set_sun_path(const char *port, const char *upath, char *path)
+{
+ struct sockaddr_un s;
+ int maxlen = sizeof(s.sun_path) - 1;
+
+ if (!port || !*port || !path)
+ return -1;
+
+ if (*port == '/') { /* a full pathname */
+ if (strlen(port) > maxlen)
+ return -1;
+ sprintf(path, "%s", port);
+ } else {
+ if (strlen(port) + strlen(upath) > maxlen)
+ return -1;
+ sprintf(path, "%s%s", upath, port);
+ }
+ return 0;
+}
+#endif
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(SocketCreateListener) (XtransConnInfo ciptr,
+ struct sockaddr *sockname,
+ int socknamelen, unsigned int flags)
+
+{
+ int namelen = socknamelen;
+ int fd = ciptr->fd;
+ int retry;
+
+ PRMSG (3, "SocketCreateListener(%x,%p)\n", ciptr, fd, 0);
+
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+ || Sockettrans2devtab[ciptr->index].family == AF_INET6
+#endif
+ )
+ retry = 20;
+ else
+ retry = 0;
+
+ while (bind (fd, (struct sockaddr *) sockname, namelen) < 0)
+ {
+ if (errno == EADDRINUSE) {
+ if (flags & ADDR_IN_USE_ALLOWED)
+ break;
+ else
+ return TRANS_ADDR_IN_USE;
+ }
+
+ if (retry-- == 0) {
+ PRMSG (1, "SocketCreateListener: failed to bind listener\n",
+ 0, 0, 0);
+ close (fd);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+#ifdef SO_REUSEADDR
+ sleep (1);
+#else
+ sleep (10);
+#endif /* SO_REUSEDADDR */
+ }
+
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+ || Sockettrans2devtab[ciptr->index].family == AF_INET6
+#endif
+ ) {
+#ifdef SO_DONTLINGER
+ setsockopt (fd, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0);
+#else
+#ifdef SO_LINGER
+ {
+ static int linger[2] = { 0, 0 };
+ setsockopt (fd, SOL_SOCKET, SO_LINGER,
+ (char *) linger, sizeof (linger));
+ }
+#endif
+#endif
+}
+
+ if (listen (fd, BACKLOG) < 0)
+ {
+ PRMSG (1, "SocketCreateListener: listen() failed\n", 0, 0, 0);
+ close (fd);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ /* Set a flag to indicate that this connection is a listener */
+
+ ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS);
+
+ return 0;
+}
+
+#ifdef TCPCONN
+static int
+TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags)
+
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_storage sockname;
+#else
+ struct sockaddr_in sockname;
+#endif
+ unsigned short sport;
+ int namelen = sizeof(sockname);
+ int status;
+ long tmpport;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgetservbynameparams sparams;
+#endif
+ struct servent *servp;
+
+#ifdef X11_t
+ char portbuf[PORTBUFSIZE];
+#endif
+
+ PRMSG (2, "SocketINETCreateListener(%s)\n", port, 0, 0);
+
+#ifdef X11_t
+ /*
+ * X has a well known port, that is transport dependent. It is easier
+ * to handle it here, than try and come up with a transport independent
+ * representation that can be passed in and resolved the usual way.
+ *
+ * The port that is passed here is really a string containing the idisplay
+ * from ConnectDisplay().
+ */
+
+ if (is_numeric (port))
+ {
+ /* fixup the server port address */
+ tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);
+ sprintf (portbuf,"%lu", tmpport);
+ port = portbuf;
+ }
+#endif
+
+ if (port && *port)
+ {
+ /* Check to see if the port string is just a number (handles X11) */
+
+ if (!is_numeric (port))
+ {
+ if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL)
+ {
+ PRMSG (1,
+ "SocketINETCreateListener: Unable to get service for %s\n",
+ port, 0, 0);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+ /* we trust getservbyname to return a valid number */
+ sport = servp->s_port;
+ }
+ else
+ {
+ tmpport = strtol (port, (char**)NULL, 10);
+ /*
+ * check that somehow the port address isn't negative or in
+ * the range of reserved port addresses. This can happen and
+ * be very bad if the server is suid-root and the user does
+ * something (dumb) like `X :60049`.
+ */
+ if (tmpport < 1024 || tmpport > USHRT_MAX)
+ return TRANS_CREATE_LISTENER_FAILED;
+
+ sport = (unsigned short) tmpport;
+ }
+ }
+ else
+ sport = 0;
+
+ bzero(&sockname, sizeof(sockname));
+#if defined(IPv6) && defined(AF_INET6)
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET) {
+ namelen = sizeof (struct sockaddr_in);
+#ifdef BSD44SOCKETS
+ ((struct sockaddr_in *)&sockname)->sin_len = namelen;
+#endif
+ ((struct sockaddr_in *)&sockname)->sin_family = AF_INET;
+ ((struct sockaddr_in *)&sockname)->sin_port = htons(sport);
+ ((struct sockaddr_in *)&sockname)->sin_addr.s_addr = htonl(INADDR_ANY);
+ } else {
+ namelen = sizeof (struct sockaddr_in6);
+#ifdef SIN6_LEN
+ ((struct sockaddr_in6 *)&sockname)->sin6_len = sizeof(sockname);
+#endif
+ ((struct sockaddr_in6 *)&sockname)->sin6_family = AF_INET6;
+ ((struct sockaddr_in6 *)&sockname)->sin6_port = htons(sport);
+ ((struct sockaddr_in6 *)&sockname)->sin6_addr = in6addr_any;
+ }
+#else
+#ifdef BSD44SOCKETS
+ sockname.sin_len = sizeof (sockname);
+#endif
+ sockname.sin_family = AF_INET;
+ sockname.sin_port = htons (sport);
+ sockname.sin_addr.s_addr = htonl (INADDR_ANY);
+#endif
+
+ if ((status = TRANS(SocketCreateListener) (ciptr,
+ (struct sockaddr *) &sockname, namelen, flags)) < 0)
+ {
+ PRMSG (1,
+ "SocketINETCreateListener: ...SocketCreateListener() failed\n",
+ 0, 0, 0);
+ return status;
+ }
+
+ if (TRANS(SocketINETGetAddr) (ciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETCreateListener: ...SocketINETGetAddr() failed\n",
+ 0, 0, 0);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ return 0;
+}
+
+#endif /* SOCKCONN */
+
+
+#ifdef UNIXCONN
+
+static int
+TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
+ unsigned int flags)
+
+{
+ struct sockaddr_un sockname;
+ int namelen;
+ int oldUmask;
+ int status;
+ unsigned int mode;
+
+ PRMSG (2, "SocketUNIXCreateListener(%s)\n",
+ port ? port : "NULL", 0, 0);
+
+ /* Make sure the directory is created */
+
+ oldUmask = umask (0);
+
+#ifdef UNIX_DIR
+#ifdef HAS_STICKY_DIR_BIT
+ mode = 01777;
+#else
+ mode = 0777;
+#endif
+ if (trans_mkdir(UNIX_DIR, mode) == -1) {
+ PRMSG (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n",
+ UNIX_DIR, errno, 0);
+ (void) umask (oldUmask);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+#endif
+
+ sockname.sun_family = AF_UNIX;
+
+ if (port && *port) {
+ if (set_sun_path(port, UNIX_PATH, sockname.sun_path) != 0) {
+ PRMSG (1, "SocketUNIXCreateListener: path too long\n", 0, 0, 0);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+ } else {
+ sprintf (sockname.sun_path, "%s%ld", UNIX_PATH, (long)getpid());
+ }
+
+#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) && !defined(Lynx)
+ sockname.sun_len = strlen(sockname.sun_path);
+ namelen = SUN_LEN(&sockname);
+#else
+ namelen = strlen(sockname.sun_path) + sizeof(sockname.sun_family);
+#endif
+
+ unlink (sockname.sun_path);
+
+ if ((status = TRANS(SocketCreateListener) (ciptr,
+ (struct sockaddr *) &sockname, namelen, flags)) < 0)
+ {
+ PRMSG (1,
+ "SocketUNIXCreateListener: ...SocketCreateListener() failed\n",
+ 0, 0, 0);
+ (void) umask (oldUmask);
+ return status;
+ }
+
+ /*
+ * Now that the listener is esablished, create the addr info for
+ * this connection. getpeername() doesn't work for UNIX Domain Sockets
+ * on some systems (hpux at least), so we will just do it manually, instead
+ * of calling something like TRANS(SocketUNIXGetAddr).
+ */
+
+ namelen = sizeof (sockname); /* this will always make it the same size */
+
+ if ((ciptr->addr = (char *) xalloc (namelen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketUNIXCreateListener: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ (void) umask (oldUmask);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ ciptr->family = sockname.sun_family;
+ ciptr->addrlen = namelen;
+ memcpy (ciptr->addr, &sockname, ciptr->addrlen);
+
+ (void) umask (oldUmask);
+
+ return 0;
+}
+
+
+static int
+TRANS(SocketUNIXResetListener) (XtransConnInfo ciptr)
+
+{
+ /*
+ * See if the unix domain socket has disappeared. If it has, recreate it.
+ */
+
+ struct sockaddr_un *unsock = (struct sockaddr_un *) ciptr->addr;
+ struct stat statb;
+ int status = TRANS_RESET_NOOP;
+ unsigned int mode;
+
+ PRMSG (3, "SocketUNIXResetListener(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+ if (stat (unsock->sun_path, &statb) == -1 ||
+ ((statb.st_mode & S_IFMT) !=
+#if (defined (sun) && defined(SVR4)) || defined(NCR) || defined(SCO325) || !defined(S_IFSOCK)
+ S_IFIFO))
+#else
+ S_IFSOCK))
+#endif
+ {
+ int oldUmask = umask (0);
+
+#ifdef UNIX_DIR
+#ifdef HAS_STICKY_DIR_BIT
+ mode = 01777;
+#else
+ mode = 0777;
+#endif
+ if (trans_mkdir(UNIX_DIR, mode) == -1) {
+ PRMSG (1, "SocketUNIXResetListener: mkdir(%s) failed, errno = %d\n",
+ UNIX_DIR, errno, 0);
+ (void) umask (oldUmask);
+ return TRANS_RESET_FAILURE;
+ }
+#endif
+
+ close (ciptr->fd);
+ unlink (unsock->sun_path);
+
+ if ((ciptr->fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
+ {
+ TRANS(FreeConnInfo) (ciptr);
+ (void) umask (oldUmask);
+ return TRANS_RESET_FAILURE;
+ }
+
+ if (bind (ciptr->fd, (struct sockaddr *) unsock, ciptr->addrlen) < 0)
+ {
+ close (ciptr->fd);
+ TRANS(FreeConnInfo) (ciptr);
+ return TRANS_RESET_FAILURE;
+ }
+
+ if (listen (ciptr->fd, BACKLOG) < 0)
+ {
+ close (ciptr->fd);
+ TRANS(FreeConnInfo) (ciptr);
+ (void) umask (oldUmask);
+ return TRANS_RESET_FAILURE;
+ }
+
+ umask (oldUmask);
+
+ status = TRANS_RESET_NEW_FD;
+ }
+
+ return status;
+}
+
+#endif /* UNIXCONN */
+
+
+#ifdef TCPCONN
+
+static XtransConnInfo
+TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status)
+
+{
+ XtransConnInfo newciptr;
+ struct sockaddr_in sockname;
+ int namelen = sizeof(sockname);
+
+ PRMSG (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+ if ((newciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketINETAccept: malloc failed\n", 0, 0, 0);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+ if ((newciptr->fd = accept (ciptr->fd,
+ (struct sockaddr *) &sockname, (void *)&namelen)) < 0)
+ {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ PRMSG (1, "SocketINETAccept: accept() failed\n", 0, 0, 0);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_FAILED;
+ return NULL;
+ }
+
+#ifdef TCP_NODELAY
+ {
+ /*
+ * turn off TCP coalescence for INET sockets
+ */
+
+ int tmp = 1;
+ setsockopt (newciptr->fd, IPPROTO_TCP, TCP_NODELAY,
+ (char *) &tmp, sizeof (int));
+ }
+#endif
+
+ /*
+ * Get this address again because the transport may give a more
+ * specific address now that a connection is established.
+ */
+
+ if (TRANS(SocketINETGetAddr) (newciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETAccept: ...SocketINETGetAddr() failed:\n",
+ 0, 0, 0);
+ close (newciptr->fd);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ if (TRANS(SocketINETGetPeerAddr) (newciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETAccept: ...SocketINETGetPeerAddr() failed:\n",
+ 0, 0, 0);
+ close (newciptr->fd);
+ if (newciptr->addr) xfree (newciptr->addr);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ *status = 0;
+
+ return newciptr;
+}
+
+#endif /* TCPCONN */
+
+
+#ifdef UNIXCONN
+static XtransConnInfo
+TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
+
+{
+ XtransConnInfo newciptr;
+ struct sockaddr_un sockname;
+#if defined(SVR4) || defined(__SCO__)
+ size_t namelen = sizeof sockname;
+#else
+ int namelen = sizeof sockname;
+#endif
+
+ PRMSG (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+ if ((newciptr = (XtransConnInfo) xcalloc (
+ 1, sizeof(struct _XtransConnInfo))) == NULL)
+ {
+ PRMSG (1, "SocketUNIXAccept: malloc() failed\n", 0, 0, 0);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+ if ((newciptr->fd = accept (ciptr->fd,
+ (struct sockaddr *) &sockname, (void *)&namelen)) < 0)
+ {
+ PRMSG (1, "SocketUNIXAccept: accept() failed\n", 0, 0, 0);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_FAILED;
+ return NULL;
+ }
+
+ /*
+ * Get the socket name and the peer name from the listener socket,
+ * since this is unix domain.
+ */
+
+ if ((newciptr->addr = (char *) xalloc (ciptr->addrlen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketUNIXAccept: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ close (newciptr->fd);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+
+ newciptr->addrlen = ciptr->addrlen;
+ memcpy (newciptr->addr, ciptr->addr, newciptr->addrlen);
+
+ if ((newciptr->peeraddr = (char *) xalloc (ciptr->addrlen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketUNIXAccept: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ close (newciptr->fd);
+ if (newciptr->addr) xfree (newciptr->addr);
+ xfree (newciptr);
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+ newciptr->peeraddrlen = ciptr->addrlen;
+ memcpy (newciptr->peeraddr, ciptr->addr, newciptr->addrlen);
+
+ newciptr->family = AF_UNIX;
+
+ *status = 0;
+
+ return newciptr;
+}
+
+#endif /* UNIXCONN */
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+#ifdef TCPCONN
+
+#if defined(IPv6) && defined(AF_INET6)
+struct addrlist {
+ struct addrinfo * addr;
+ struct addrinfo * firstaddr;
+ char port[PORTBUFSIZE];
+ char host[MAXHOSTNAMELEN];
+};
+static struct addrlist *addrlist = NULL;
+#endif
+
+
+static int
+TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port)
+
+{
+ struct sockaddr * socketaddr = NULL;
+ int socketaddrlen = 0;
+ int res;
+#if defined(IPv6) && defined(AF_INET6)
+ struct addrinfo hints;
+ char ntopbuf[INET6_ADDRSTRLEN];
+ int resetonce = 0;
+#endif
+ struct sockaddr_in sockname;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+ _Xgetservbynameparams sparams;
+#endif
+ struct hostent *hostp;
+ struct servent *servp;
+ unsigned long tmpaddr;
+#ifdef X11_t
+ char portbuf[PORTBUFSIZE];
+#endif
+
+ long tmpport;
+ char hostnamebuf[256]; /* tmp space */
+
+ PRMSG (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port);
+
+ if (!host)
+ {
+ hostnamebuf[0] = '\0';
+ (void) TRANS(GetHostname) (hostnamebuf, sizeof hostnamebuf);
+ host = hostnamebuf;
+ }
+
+#ifdef X11_t
+ /*
+ * X has a well known port, that is transport dependent. It is easier
+ * to handle it here, than try and come up with a transport independent
+ * representation that can be passed in and resolved the usual way.
+ *
+ * The port that is passed here is really a string containing the idisplay
+ * from ConnectDisplay().
+ */
+
+ if (is_numeric (port))
+ {
+ tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);
+ sprintf (portbuf, "%lu", tmpport);
+ port = portbuf;
+ }
+#endif
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6) {
+ if (addrlist != NULL) {
+ if (strcmp(host,addrlist->host) || strcmp(port,addrlist->port)) {
+ if (addrlist->firstaddr)
+ freeaddrinfo(addrlist->firstaddr);
+ addrlist->firstaddr = NULL;
+ }
+ } else {
+ addrlist = malloc(sizeof(struct addrlist));
+ addrlist->firstaddr = NULL;
+ }
+
+ if (addrlist->firstaddr == NULL) {
+ strncpy(addrlist->port, port, sizeof(addrlist->port));
+ addrlist->port[sizeof(addrlist->port) - 1] = '\0';
+ strncpy(addrlist->host, host, sizeof(addrlist->host));
+ addrlist->host[sizeof(addrlist->host) - 1] = '\0';
+
+ bzero(&hints,sizeof(hints));
+ hints.ai_socktype = Sockettrans2devtab[ciptr->index].devcotsname;
+
+ res = getaddrinfo(host,port,&hints,&addrlist->firstaddr);
+ if (res != 0) {
+ PRMSG (1, "SocketINETConnect() can't get address "
+ "for %s:%s: %s\n", host, port, gai_strerror(res));
+ ESET(EINVAL);
+ return TRANS_CONNECT_FAILED;
+ }
+ for (res = 0, addrlist->addr = addrlist->firstaddr;
+ addrlist->addr ; res++) {
+ addrlist->addr = addrlist->addr->ai_next;
+ }
+ PRMSG(4,"Got New Address list with %d addresses\n", res, 0, 0);
+ res = 0;
+ addrlist->addr = NULL;
+ }
+
+ while (socketaddr == NULL) {
+ if (addrlist->addr == NULL) {
+ if (resetonce) {
+ /* Already checked entire list - no usable addresses */
+ PRMSG (1, "SocketINETConnect() no usable address "
+ "for %s:%s\n", host, port, 0);
+ return TRANS_CONNECT_FAILED;
+ } else {
+ /* Go back to beginning of list */
+ resetonce = 1;
+ addrlist->addr = addrlist->firstaddr;
+ }
+ }
+
+ socketaddr = addrlist->addr->ai_addr;
+ socketaddrlen = addrlist->addr->ai_addrlen;
+
+ if (addrlist->addr->ai_family == AF_INET) {
+ struct sockaddr_in *sin = (struct sockaddr_in *) socketaddr;
+
+ PRMSG (4,"SocketINETConnect() sockname.sin_addr = %s\n",
+ inet_ntop(addrlist->addr->ai_family,&sin->sin_addr,
+ ntopbuf,sizeof(ntopbuf)), 0, 0);
+
+ PRMSG (4,"SocketINETConnect() sockname.sin_port = %d\n",
+ ntohs(sin->sin_port), 0, 0);
+
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET6) {
+ if (strcmp(Sockettrans2devtab[ciptr->index].transname,
+ "tcp") == 0) {
+ XtransConnInfo newciptr;
+
+ /*
+ * Our socket is an IPv6 socket, but the address is
+ * IPv4. Close it and get an IPv4 socket. This is
+ * needed for IPv4 connections to work on platforms
+ * that don't allow IPv4 over IPv6 sockets.
+ */
+ TRANS(SocketINETClose)(ciptr);
+ newciptr = TRANS(SocketOpenCOTSClientBase)(
+ "tcp", "tcp", host, port, ciptr->index);
+ if (newciptr)
+ ciptr->fd = newciptr->fd;
+ if (!newciptr ||
+ Sockettrans2devtab[newciptr->index].family !=
+ AF_INET) {
+ socketaddr = NULL;
+ PRMSG (4,"SocketINETConnect() Cannot get IPv4 "
+ " socketfor IPv4 address\n", 0,0,0);
+ }
+ if (newciptr)
+ xfree(newciptr);
+ } else {
+ socketaddr = NULL;
+ PRMSG (4,"SocketINETConnect Skipping IPv4 address\n",
+ 0,0,0);
+ }
+ }
+ } else if (addrlist->addr->ai_family == AF_INET6) {
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) socketaddr;
+
+ PRMSG (4,"SocketINETConnect() sockname.sin6_addr = %s\n",
+ inet_ntop(addrlist->addr->ai_family,
+ &sin6->sin6_addr,ntopbuf,sizeof(ntopbuf)),
+ 0, 0);
+ PRMSG (4,"SocketINETConnect() sockname.sin6_port = %d\n",
+ ntohs(sin6->sin6_port), 0, 0);
+
+ if (Sockettrans2devtab[ciptr->index].family == AF_INET) {
+ if (strcmp(Sockettrans2devtab[ciptr->index].transname,
+ "tcp") == 0) {
+ XtransConnInfo newciptr;
+
+ /*
+ * Close the IPv4 socket and try to open an IPv6 socket.
+ */
+ TRANS(SocketINETClose)(ciptr);
+ newciptr = TRANS(SocketOpenCOTSClientBase)(
+ "tcp", "tcp", host, port, -1);
+ if (newciptr)
+ ciptr->fd = newciptr->fd;
+ if (!newciptr ||
+ Sockettrans2devtab[newciptr->index].family !=
+ AF_INET6) {
+ socketaddr = NULL;
+ PRMSG (4,"SocketINETConnect() Cannot get IPv6 "
+ "socket for IPv6 address\n", 0,0,0);
+ }
+ if (newciptr)
+ xfree(newciptr);
+ }
+ else
+ {
+ socketaddr = NULL;
+ PRMSG (4,"SocketINETConnect() Skipping IPv6 address\n",
+ 0,0,0);
+ }
+ }
+ } else {
+ socketaddr = NULL; /* Unsupported address type */
+ }
+ if (socketaddr == NULL) {
+ addrlist->addr = addrlist->addr->ai_next;
+ }
+ }
+ } else
+#endif
+ {
+ /*
+ * Build the socket name.
+ */
+
+#ifdef BSD44SOCKETS
+ sockname.sin_len = sizeof (struct sockaddr_in);
+#endif
+ sockname.sin_family = AF_INET;
+
+ /*
+ * fill in sin_addr
+ */
+
+#ifndef INADDR_NONE
+#define INADDR_NONE ((in_addr_t) 0xffffffff)
+#endif
+
+ /* check for ww.xx.yy.zz host string */
+
+ if (isascii (host[0]) && isdigit (host[0])) {
+ tmpaddr = inet_addr (host); /* returns network byte order */
+ } else {
+ tmpaddr = INADDR_NONE;
+ }
+
+ PRMSG (4,"SocketINETConnect() inet_addr(%s) = %x\n", host, tmpaddr, 0);
+
+ if (tmpaddr == INADDR_NONE) {
+ if ((hostp = _XGethostbyname(host,hparams)) == NULL) {
+ PRMSG (1,"SocketINETConnect: Can't get address for %s\n",
+ host, 0, 0);
+ ESET(EINVAL);
+ return TRANS_CONNECT_FAILED;
+ }
+ if (hostp->h_addrtype != AF_INET) { /* is IP host? */
+ PRMSG (1,"SocketINETConnect: not INET host%s\n", host, 0, 0);
+ ESET(EPROTOTYPE);
+ return TRANS_CONNECT_FAILED;
+ }
+
+#if defined(CRAY) && defined(OLDTCP)
+ /* Only Cray UNICOS3 and UNICOS4 will define this */
+ {
+ long t;
+ memcpy ((char *)&t, (char *) hostp->h_addr, sizeof (t));
+ sockname.sin_addr = t;
+ }
+#else
+ memcpy ((char *) &sockname.sin_addr, (char *) hostp->h_addr,
+ sizeof (sockname.sin_addr));
+#endif /* CRAY and OLDTCP */
+
+ } else {
+#if defined(CRAY) && defined(OLDTCP)
+ /* Only Cray UNICOS3 and UNICOS4 will define this */
+ sockname.sin_addr = tmpaddr;
+#else
+ sockname.sin_addr.s_addr = tmpaddr;
+#endif /* CRAY and OLDTCP */
+ }
+
+ /*
+ * fill in sin_port
+ */
+
+ /* Check for number in the port string */
+
+ if (!is_numeric (port)) {
+ if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL) {
+ PRMSG (1,"SocketINETConnect: can't get service for %s\n",
+ port, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+ sockname.sin_port = htons (servp->s_port);
+ } else {
+ tmpport = strtol (port, (char**)NULL, 10);
+ if (tmpport < 1024 || tmpport > USHRT_MAX)
+ return TRANS_CONNECT_FAILED;
+ sockname.sin_port = htons (((unsigned short) tmpport));
+ }
+
+ PRMSG (4,"SocketINETConnect: sockname.sin_port = %d\n",
+ ntohs(sockname.sin_port), 0, 0);
+ socketaddr = (struct sockaddr *) &sockname;
+ socketaddrlen = sizeof(sockname);
+ }
+
+ /*
+ * Turn on socket keepalive so the client process will eventually
+ * be notified with a SIGPIPE signal if the display server fails
+ * to respond to a periodic transmission of messages
+ * on the connected socket.
+ * This is useful to avoid hung application processes when the
+ * processes are not spawned from the xdm session and
+ * the display server terminates abnormally.
+ * (Someone turned off the power switch.)
+ */
+
+ {
+ int tmp = 1;
+ setsockopt (ciptr->fd, SOL_SOCKET, SO_KEEPALIVE,
+ (char *) &tmp, sizeof (int));
+ }
+
+ /*
+ * Do the connect()
+ */
+
+ if (connect (ciptr->fd, socketaddr, socketaddrlen ) < 0)
+ {
+#ifdef WIN32
+ int olderrno = WSAGetLastError();
+#else
+ int olderrno = errno;
+#endif
+
+ /*
+ * If the error was ECONNREFUSED, the server may be overloaded
+ * and we should try again.
+ *
+ * If the error was EWOULDBLOCK or EINPROGRESS then the socket
+ * was non-blocking and we should poll using select
+ *
+ * If the error was EINTR, the connect was interrupted and we
+ * should try again.
+ *
+ * If multiple addresses are found for a host then we should
+ * try to connect again with a different address for a larger
+ * number of errors that made us quit before, since those
+ * could be caused by trying to use an IPv6 address to contact
+ * a machine with an IPv4-only server or other reasons that
+ * only affect one of a set of addresses.
+ */
+
+ if (olderrno == ECONNREFUSED || olderrno == EINTR
+#if defined(IPv6) && defined(AF_INET6)
+ || (haveIPv6 && ((addrlist->addr->ai_next != NULL) ||
+ (addrlist->addr != addrlist->firstaddr)) &&
+ (olderrno == ENETUNREACH || olderrno == EAFNOSUPPORT ||
+ olderrno == EADDRNOTAVAIL || olderrno == ETIMEDOUT
+#if defined(EHOSTDOWN)
+ || olderrno == EHOSTDOWN
+#endif
+ ))
+#endif
+ )
+ res = TRANS_TRY_CONNECT_AGAIN;
+ else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
+ res = TRANS_IN_PROGRESS;
+ else
+ {
+ PRMSG (2,"SocketINETConnect: Can't connect: errno = %d\n",
+ olderrno,0, 0);
+
+ res = TRANS_CONNECT_FAILED;
+ }
+ } else {
+ res = 0;
+
+
+ /*
+ * Sync up the address fields of ciptr.
+ */
+
+ if (TRANS(SocketINETGetAddr) (ciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETConnect: ...SocketINETGetAddr() failed:\n",
+ 0, 0, 0);
+ res = TRANS_CONNECT_FAILED;
+ }
+
+ else if (TRANS(SocketINETGetPeerAddr) (ciptr) < 0)
+ {
+ PRMSG (1,
+ "SocketINETConnect: ...SocketINETGetPeerAddr() failed:\n",
+ 0, 0, 0);
+ res = TRANS_CONNECT_FAILED;
+ }
+ }
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (haveIPv6 && res != 0) {
+ addrlist->addr = addrlist->addr->ai_next;
+ }
+#endif
+
+ return res;
+}
+
+#endif /* TCPCONN */
+
+
+
+#ifdef UNIXCONN
+
+/*
+ * Make sure 'host' is really local.
+ */
+
+static int
+UnixHostReallyLocal (char *host)
+
+{
+ char hostnamebuf[256];
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (getaddrinfo == NULL)
+ haveIPv6 = 0;
+#endif
+
+ TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf));
+
+ if (strcmp (hostnamebuf, host) == 0)
+ {
+ return (1);
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if (haveIPv6)
+ {
+ struct addrinfo *localhostaddr;
+ struct addrinfo *otherhostaddr;
+ struct addrinfo *i, *j;
+ int equiv = 0;
+
+ if (getaddrinfo(hostnamebuf, NULL, NULL, &localhostaddr) != 0)
+ return 0;
+ if (getaddrinfo(host, NULL, NULL, &otherhostaddr) != 0) {
+ freeaddrinfo(localhostaddr);
+ return 0;
+ }
+
+ for (i = localhostaddr; i != NULL && equiv == 0; i = i->ai_next) {
+ for (j = otherhostaddr; j != NULL && equiv == 0; j = j->ai_next) {
+ if (i->ai_family == j->ai_family) {
+ if (i->ai_family == AF_INET) {
+ struct sockaddr_in *sinA
+ = (struct sockaddr_in *) i->ai_addr;
+ struct sockaddr_in *sinB
+ = (struct sockaddr_in *) j->ai_addr;
+ struct in_addr *A = &sinA->sin_addr;
+ struct in_addr *B = &sinB->sin_addr;
+
+ if (memcmp(A,B,sizeof(struct in_addr)) == 0) {
+ equiv = 1;
+ }
+ } else if (i->ai_family == AF_INET6) {
+ struct sockaddr_in6 *sinA
+ = (struct sockaddr_in6 *) i->ai_addr;
+ struct sockaddr_in6 *sinB
+ = (struct sockaddr_in6 *) j->ai_addr;
+ struct in6_addr *A = &sinA->sin6_addr;
+ struct in6_addr *B = &sinB->sin6_addr;
+
+ if (memcmp(A,B,sizeof(struct in6_addr)) == 0) {
+ equiv = 1;
+ }
+ }
+ }
+ }
+ }
+
+ freeaddrinfo(localhostaddr);
+ freeaddrinfo(otherhostaddr);
+ return equiv;
+ }
+#endif
+ else
+ {
+ /*
+ * A host may have more than one network address. If any of the
+ * network addresses of 'host' (specified to the connect call)
+ * match any of the network addresses of 'hostname' (determined
+ * by TRANS(GetHostname)), then the two hostnames are equivalent,
+ * and we know that 'host' is really a local host.
+ */
+ char specified_local_addr_list[10][4];
+ int scount, equiv, i, j;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ struct hostent *hostp;
+
+ if ((hostp = _XGethostbyname (host,hparams)) == NULL)
+ return (0);
+
+ scount = 0;
+ while (hostp->h_addr_list[scount] && scount <= 8)
+ {
+ /*
+ * The 2nd call to gethostname() overrides the data
+ * from the 1st call, so we must save the address list.
+ */
+
+ specified_local_addr_list[scount][0] =
+ hostp->h_addr_list[scount][0];
+ specified_local_addr_list[scount][1] =
+ hostp->h_addr_list[scount][1];
+ specified_local_addr_list[scount][2] =
+ hostp->h_addr_list[scount][2];
+ specified_local_addr_list[scount][3] =
+ hostp->h_addr_list[scount][3];
+ scount++;
+ }
+ if ((hostp = _XGethostbyname (hostnamebuf,hparams)) == NULL)
+ return (0);
+
+ equiv = 0;
+ i = 0;
+
+ while (i < scount && !equiv)
+ {
+ j = 0;
+
+ while (hostp->h_addr_list[j])
+ {
+ if ((specified_local_addr_list[i][0] ==
+ hostp->h_addr_list[j][0]) &&
+ (specified_local_addr_list[i][1] ==
+ hostp->h_addr_list[j][1]) &&
+ (specified_local_addr_list[i][2] ==
+ hostp->h_addr_list[j][2]) &&
+ (specified_local_addr_list[i][3] ==
+ hostp->h_addr_list[j][3]))
+ {
+ /* They're equal, so we're done */
+
+ equiv = 1;
+ break;
+ }
+
+ j++;
+ }
+
+ i++;
+ }
+ return (equiv);
+ }
+}
+
+static int
+TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
+
+{
+ struct sockaddr_un sockname;
+ int namelen;
+
+#if defined(hpux) && defined(X11_t)
+ struct sockaddr_un old_sockname;
+ int old_namelen;
+#endif
+
+
+ PRMSG (2,"SocketUNIXConnect(%d,%s,%s)\n", ciptr->fd, host, port);
+
+ /*
+ * Make sure 'host' is really local. If not, we return failure.
+ * The reason we make this check is because a process may advertise
+ * a "local" network ID for which it can accept connections, but if
+ * a process on a remote machine tries to connect to this network ID,
+ * we know for sure it will fail.
+ */
+
+ if (strcmp (host, "unix") != 0 && !UnixHostReallyLocal (host))
+ {
+ PRMSG (1,
+ "SocketUNIXConnect: Cannot connect to non-local host %s\n",
+ host, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+
+ /*
+ * Check the port.
+ */
+
+ if (!port || !*port)
+ {
+ PRMSG (1,"SocketUNIXConnect: Missing port specification\n",
+ 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+ /*
+ * Build the socket name.
+ */
+
+ sockname.sun_family = AF_UNIX;
+
+ if (set_sun_path(port, UNIX_PATH, sockname.sun_path) != 0) {
+ PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) && !defined(Lynx)
+ sockname.sun_len = strlen (sockname.sun_path);
+ namelen = SUN_LEN (&sockname);
+#else
+ namelen = strlen (sockname.sun_path) + sizeof (sockname.sun_family);
+#endif
+
+
+#if defined(hpux) && defined(X11_t)
+ /*
+ * This is gross, but it was in Xlib
+ */
+ old_sockname.sun_family = AF_UNIX;
+ if (set_sun_path(port, OLD_UNIX_PATH, old_sockname.sun_path) != 0) {
+ PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+ old_namelen = strlen (old_sockname.sun_path) +
+ sizeof (old_sockname.sun_family);
+#endif
+
+
+ /*
+ * Do the connect()
+ */
+
+ if (connect (ciptr->fd, (struct sockaddr *) &sockname, namelen) < 0)
+ {
+ int olderrno = errno;
+ int connected = 0;
+
+#if defined(hpux) && defined(X11_t)
+ if (olderrno == ENOENT)
+ {
+ if (connect (ciptr->fd,
+ (struct sockaddr *) &old_sockname, old_namelen) >= 0)
+ {
+ connected = 1;
+ }
+ else
+ olderrno = errno;
+ }
+#endif
+ if (!connected)
+ {
+ errno = olderrno;
+
+ /*
+ * If the error was ENOENT, the server may be starting up
+ * and we should try again.
+ *
+ * If the error was EWOULDBLOCK or EINPROGRESS then the socket
+ * was non-blocking and we should poll using select
+ *
+ * If the error was EINTR, the connect was interrupted and we
+ * should try again.
+ */
+
+ if (olderrno == ENOENT || olderrno == EINTR)
+ return TRANS_TRY_CONNECT_AGAIN;
+ else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
+ return TRANS_IN_PROGRESS;
+ else
+ {
+ PRMSG (2,"SocketUNIXConnect: Can't connect: errno = %d\n",
+ EGET(),0, 0);
+
+ return TRANS_CONNECT_FAILED;
+ }
+ }
+ }
+
+ /*
+ * Get the socket name and the peer name from the connect socket,
+ * since this is unix domain.
+ */
+
+ if ((ciptr->addr = (char *) xalloc(namelen)) == NULL ||
+ (ciptr->peeraddr = (char *) xalloc(namelen)) == NULL)
+ {
+ PRMSG (1,
+ "SocketUNIXCreateListener: Can't allocate space for the addr\n",
+ 0, 0, 0);
+ return TRANS_CONNECT_FAILED;
+ }
+
+ ciptr->family = AF_UNIX;
+ ciptr->addrlen = namelen;
+ ciptr->peeraddrlen = namelen;
+ memcpy (ciptr->addr, &sockname, ciptr->addrlen);
+ memcpy (ciptr->peeraddr, &sockname, ciptr->peeraddrlen);
+
+ return 0;
+}
+
+#endif /* UNIXCONN */
+
+#endif /* TRANS_CLIENT */
+
+
+static int
+TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)
+
+{
+ PRMSG (2,"SocketBytesReadable(%p,%d,%p)\n",
+ ciptr, ciptr->fd, pend);
+#if defined(QNX4)
+ *pend = 0L; /* FIONREAD only returns a short. Zero out upper bits */
+#endif
+#ifdef WIN32
+ {
+ int ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+#if (defined(i386) && defined(SYSV) && !defined(SCO325)) || (defined(_SEQUENT_) && _SOCKET_VERSION == 1)
+ return ioctl (ciptr->fd, I_NREAD, (char *) pend);
+#else
+#if defined(__UNIXOS2__)
+ return ioctl (ciptr->fd, FIONREAD, (char*) pend, sizeof(int));
+#else
+ return ioctl (ciptr->fd, FIONREAD, (char *) pend);
+#endif /* __UNIXOS2__ */
+#endif /* i386 && SYSV || _SEQUENT_ && _SOCKET_VERSION == 1 */
+#endif /* WIN32 */
+}
+
+
+static int
+TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+ PRMSG (2,"SocketRead(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+#if defined(WIN32) || defined(__UNIXOS2__)
+ {
+ int ret = recv ((SOCKET)ciptr->fd, buf, size, 0);
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ return ret;
+ }
+#else
+ return read (ciptr->fd, buf, size);
+#endif /* WIN32 */
+}
+
+
+static int
+TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+ PRMSG (2,"SocketWrite(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+#if defined(WIN32) || defined(__UNIXOS2__)
+ {
+ int ret = send ((SOCKET)ciptr->fd, buf, size, 0);
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+ return ret;
+ }
+#else
+ return write (ciptr->fd, buf, size);
+#endif /* WIN32 */
+}
+
+
+static int
+TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ PRMSG (2,"SocketReadv(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+ return READV (ciptr, buf, size);
+}
+
+
+static int
+TRANS(SocketWritev) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ PRMSG (2,"SocketWritev(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+ return WRITEV (ciptr, buf, size);
+}
+
+
+static int
+TRANS(SocketDisconnect) (XtransConnInfo ciptr)
+
+{
+ PRMSG (2,"SocketDisconnect(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+#ifdef WIN32
+ {
+ int ret = shutdown (ciptr->fd, 2);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+ return shutdown (ciptr->fd, 2); /* disallow further sends and receives */
+#endif
+}
+
+
+#ifdef TCPCONN
+static int
+TRANS(SocketINETClose) (XtransConnInfo ciptr)
+
+{
+ PRMSG (2,"SocketINETClose(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+#ifdef WIN32
+ {
+ int ret = close (ciptr->fd);
+ errno = WSAGetLastError();
+ return ret;
+ }
+#else
+ return close (ciptr->fd);
+#endif
+}
+
+#endif /* TCPCONN */
+
+
+#ifdef UNIXCONN
+static int
+TRANS(SocketUNIXClose) (XtransConnInfo ciptr)
+
+{
+ /*
+ * If this is the server side, then once the socket is closed,
+ * it must be unlinked to completely close it
+ */
+
+ struct sockaddr_un *sockname = (struct sockaddr_un *) ciptr->addr;
+ int ret;
+
+ PRMSG (2,"SocketUNIXClose(%p,%d)\n", ciptr, ciptr->fd, 0);
+
+ ret = close(ciptr->fd);
+
+ if (ciptr->flags
+ && sockname
+ && sockname->sun_family == AF_UNIX
+ && sockname->sun_path[0])
+ {
+ if (!(ciptr->flags & TRANS_NOUNLINK))
+ unlink (sockname->sun_path);
+ }
+
+ return ret;
+}
+
+static int
+TRANS(SocketUNIXCloseForCloning) (XtransConnInfo ciptr)
+
+{
+ /*
+ * Don't unlink path.
+ */
+
+ int ret;
+
+ PRMSG (2,"SocketUNIXCloseForCloning(%p,%d)\n",
+ ciptr, ciptr->fd, 0);
+
+ ret = close(ciptr->fd);
+
+ return ret;
+}
+
+#endif /* UNIXCONN */
+
+
+#ifdef TCPCONN
+# ifdef TRANS_SERVER
+static char* tcp_nolisten[] = {
+ "inet",
+#if defined(IPv6) && defined(AF_INET6)
+ "inet6",
+#endif
+ NULL
+};
+# endif
+
+Xtransport TRANS(SocketTCPFuncs) = {
+ /* Socket Interface */
+ "tcp",
+ TRANS_ALIAS,
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ tcp_nolisten,
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketINETCreateListener),
+ NULL, /* ResetListener */
+ TRANS(SocketINETAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketINETConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketINETClose),
+ TRANS(SocketINETClose),
+ };
+
+Xtransport TRANS(SocketINETFuncs) = {
+ /* Socket Interface */
+ "inet",
+ 0,
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketINETCreateListener),
+ NULL, /* ResetListener */
+ TRANS(SocketINETAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketINETConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketINETClose),
+ TRANS(SocketINETClose),
+ };
+
+#if defined(IPv6) && defined(AF_INET6)
+Xtransport TRANS(SocketINET6Funcs) = {
+ /* Socket Interface */
+ "inet6",
+ 0,
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketINETCreateListener),
+ NULL, /* ResetListener */
+ TRANS(SocketINETAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketINETConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketINETClose),
+ TRANS(SocketINETClose),
+ };
+#endif /* IPv6 */
+#endif /* TCPCONN */
+
+#ifdef UNIXCONN
+#if !defined(LOCALCONN)
+Xtransport TRANS(SocketLocalFuncs) = {
+ /* Socket Interface */
+ "local",
+ 0,
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketUNIXCreateListener),
+ TRANS(SocketUNIXResetListener),
+ TRANS(SocketUNIXAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketUNIXConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketUNIXClose),
+ TRANS(SocketUNIXCloseForCloning),
+ };
+#endif /* !LOCALCONN */
+# ifdef TRANS_SERVER
+# if !defined(LOCALCONN)
+static char* unix_nolisten[] = { "local" , NULL };
+# endif
+# endif
+
+Xtransport TRANS(SocketUNIXFuncs) = {
+ /* Socket Interface */
+ "unix",
+#if !defined(LOCALCONN)
+ TRANS_ALIAS,
+#else
+ 0,
+#endif
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+#if !defined(LOCALCONN)
+ unix_nolisten,
+#else
+ NULL,
+#endif
+ TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(SocketReopenCOTSServer),
+ TRANS(SocketReopenCLTSServer),
+#endif
+ TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+ TRANS(SocketUNIXCreateListener),
+ TRANS(SocketUNIXResetListener),
+ TRANS(SocketUNIXAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(SocketUNIXConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(SocketBytesReadable),
+ TRANS(SocketRead),
+ TRANS(SocketWrite),
+ TRANS(SocketReadv),
+ TRANS(SocketWritev),
+ TRANS(SocketDisconnect),
+ TRANS(SocketUNIXClose),
+ TRANS(SocketUNIXCloseForCloning),
+ };
+
+#endif /* UNIXCONN */
diff --git a/nx-X11/lib/xtrans/Xtranstli.c b/nx-X11/lib/xtrans/Xtranstli.c
new file mode 100644
index 000000000..d8b5db83b
--- /dev/null
+++ b/nx-X11/lib/xtrans/Xtranstli.c
@@ -0,0 +1,1422 @@
+/* $Xorg: Xtranstli.c,v 1.4 2001/02/09 02:04:07 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/xtrans/Xtranstli.c,v 3.12tsi Exp $ */
+
+/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * 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 NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCR makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR 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 <sys/un.h>
+#include <stropts.h>
+#include <poll.h>
+#include <tiuser.h>
+
+#include <netdir.h>
+#include <netconfig.h>
+
+
+/*
+ * This is the TLI implementation of the X Transport service layer
+ */
+
+typedef struct _TLItrans2dev {
+ char *transname;
+ char *protofamily;
+ char *devcotsname;
+ char *devcltsname;
+ int family;
+} TLItrans2dev;
+
+static TLItrans2dev TLItrans2devtab[] = {
+ {"inet","inet","/dev/tcp","/dev/udp",AF_INET},
+ {"tcp","inet","/dev/tcp","/dev/udp",AF_INET},
+ {"tli","loopback","/dev/ticots","/dev/ticlts",AF_UNIX},
+};
+
+#define NUMTLIFAMILIES (sizeof(TLItrans2devtab)/sizeof(TLItrans2dev))
+
+/*
+ * The local TLI connection, is a form of a local connection, so use a
+ * sockaddr_un for the address so that it will be treated just like the other
+ * local transports such as UNIX domain sockets, pts, and named.
+ */
+
+#if defined(X11_t)
+#define TLINODENAME "TLI:xserver"
+#endif
+
+#if defined(XIM_t)
+#define TLINODENAME "TLI:xim"
+#endif
+
+#if defined(FS_t) || defined(FONT_t)
+#define TLINODENAME "TLI:fontserver"
+#endif
+
+#if defined(ICE_t)
+#define TLINODENAME "TLI:ICE"
+#endif
+
+#if defined(TEST_t)
+#define TLINODENAME "TLI:test"
+#endif
+
+#ifndef PORTBUFSIZE
+#ifdef TRANS_SERVER
+#define PORTBUFSIZE 64
+#else
+#ifdef TRANS_CLIENT
+#define PORTBUFSIZE 64
+#endif
+#endif
+#endif
+
+
+/*
+ * These are some utility function used by the real interface function below.
+ */
+
+static int
+TRANS(TLISelectFamily)(char *family)
+
+{
+ int i;
+
+ PRMSG(3,"TLISelectFamily(%s)\n", family, 0,0 );
+
+ for(i=0;i<NUMTLIFAMILIES;i++)
+ {
+ if( !strcmp(family,TLItrans2devtab[i].transname) )
+ return i;
+ }
+ return -1;
+}
+
+
+/*
+ * This function gets the local address of the transport and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(TLIGetAddr)(XtransConnInfo ciptr)
+
+{
+ Xtransaddr sockname;
+ struct netbuf netbuf;
+
+ PRMSG(3,"TLIGetAddr(%x)\n", ciptr, 0,0 );
+
+ netbuf.buf=(char *)&sockname;
+ netbuf.len=sizeof(sockname);
+ netbuf.maxlen=sizeof(sockname);
+
+ if( t_getname(ciptr->fd,&netbuf,LOCALNAME) < 0 )
+ {
+ PRMSG(1,"TLIGetAddr: t_getname(LOCALNAME) failed: %d\n",
+ errno, 0,0 );
+ return -1;
+ }
+
+ PRMSG(4,"TLIGetAddr: got family %d len %d\n",
+ ((struct sockaddr *) &sockname)->sa_family ,netbuf.len, 0 );
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if( ciptr->addr )
+ xfree(ciptr->addr);
+
+ if( (ciptr->addr=(char *)xalloc(netbuf.len)) == NULL )
+ {
+ PRMSG(1, "TLIGetAddr: Can't allocate space for the addr\n",
+ 0,0,0);
+ return -1;
+ }
+
+ ciptr->family=((struct sockaddr *) &sockname)->sa_family;
+ ciptr->addrlen=netbuf.len;
+ memcpy(ciptr->addr,&sockname,ciptr->addrlen);
+
+ return 0;
+}
+
+
+/*
+ * This function gets the remote address of the socket and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(TLIGetPeerAddr)(XtransConnInfo ciptr)
+
+{
+ Xtransaddr sockname;
+ struct netbuf netbuf;
+
+ PRMSG(3,"TLIGetPeerAddr(%x)\n", ciptr, 0,0 );
+
+ netbuf.buf=(char *)&sockname;
+ netbuf.len=sizeof(sockname);
+ netbuf.maxlen=sizeof(sockname);
+
+ if( t_getname(ciptr->fd,&netbuf,REMOTENAME) < 0 )
+ {
+ PRMSG(1,"TLIGetPeerAddr: t_getname(REMOTENAME) failed: %d\n",
+ errno, 0,0 );
+ return -1;
+ }
+
+ PRMSG(4,"TLIGetPeerAddr: got family %d len %d\n",
+ ((struct sockaddr *) &sockname)->sa_family ,netbuf.len, 0 );
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if( ciptr->peeraddr )
+ xfree(ciptr->peeraddr);
+
+ if( (ciptr->peeraddr=(char *)xalloc(netbuf.len)) == NULL )
+ {
+ PRMSG(1,
+ "TLIGetPeerAddr: Can't allocate space for the addr\n",
+ 0,0,0);
+ return -1;
+ }
+
+ ciptr->peeraddrlen=netbuf.len;
+ memcpy(ciptr->peeraddr,&sockname,ciptr->peeraddrlen);
+
+ return 0;
+}
+
+
+/*
+ * This function will establish a local name for the transport. This function
+ * do extra work for the local tli connection. It must create a sockaddr_un
+ * format address so that it will look like an AF_UNIX connection to the
+ * higher layer.
+ *
+ * This function will only be called by the OPENC?TSClient() functions since
+ * the local address is set up in the CreateListner() for the server ends.
+ */
+
+static int
+TRANS(TLITLIBindLocal)(int fd, int family, char *port)
+
+{
+ struct sockaddr_un *sunaddr=NULL;
+ struct t_bind *req=NULL;
+
+ PRMSG(2, "TLITLIBindLocal(%d,%d,%s)\n", fd, family, port);
+
+ if( family == AF_UNIX )
+ {
+ if( (req=(struct t_bind *)t_alloc(fd,T_BIND,0)) == NULL )
+ {
+ PRMSG(1,
+ "TLITLIBindLocal() failed to allocate a t_bind\n",
+ 0,0,0 );
+ return -1;
+ }
+
+ if( (sunaddr=(struct sockaddr_un *)
+ malloc(sizeof(struct sockaddr_un))) == NULL )
+ {
+ PRMSG(1,
+ "TLITLIBindLocal: failed to allocate a sockaddr_un\n",
+ 0,0,0 );
+ t_free((char *)req,T_BIND);
+ return -1;
+ }
+
+ sunaddr->sun_family=AF_UNIX;
+
+#ifdef nuke
+ if( *port == '/' ) { /* A full pathname */
+ (void) strcpy(sunaddr->sun_path, port);
+ } else {
+ (void) sprintf(sunaddr->sun_path,"%s%s", TLINODENAME, port );
+ }
+#endif /*NUKE*/
+
+ (void) sprintf(sunaddr->sun_path,"%s%d",
+ TLINODENAME, getpid()^time(NULL) );
+
+ PRMSG(4, "TLITLIBindLocal: binding to %s\n",
+ sunaddr->sun_path, 0,0);
+
+ req->addr.buf=(char *)sunaddr;
+ req->addr.len=sizeof(*sunaddr);
+ req->addr.maxlen=sizeof(*sunaddr);
+ }
+
+ if( t_bind(fd, req, NULL) < 0 )
+ {
+ PRMSG(1,
+ "TLIBindLocal: Unable to bind TLI device to %s\n",
+ port, 0,0 );
+ if (sunaddr)
+ free((char *) sunaddr);
+ if (req)
+ t_free((char *)req,T_BIND);
+ return -1;
+ }
+ return 0;
+}
+
+static XtransConnInfo
+TRANS(TLIOpen)(char *device)
+
+{
+ XtransConnInfo ciptr;
+
+ PRMSG(3,"TLIOpen(%s)\n", device, 0,0 );
+
+ if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ {
+ PRMSG(1, "TLIOpen: calloc failed\n", 0,0,0 );
+ return NULL;
+ }
+
+ if( (ciptr->fd=t_open( device, O_RDWR, NULL )) < 0 )
+ {
+ PRMSG(1, "TLIOpen: t_open failed for %s\n", device, 0,0 );
+ free(ciptr);
+ return NULL;
+ }
+
+ return ciptr;
+}
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(TLIReopen)(char *device, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+
+ PRMSG(3,"TLIReopen(%s,%d, %s)\n", device, fd, port );
+
+ if (t_sync (fd) < 0)
+ {
+ PRMSG(1, "TLIReopen: t_sync failed\n", 0,0,0 );
+ return NULL;
+ }
+
+ if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ {
+ PRMSG(1, "TLIReopen: calloc failed\n", 0,0,0 );
+ return NULL;
+ }
+
+ ciptr->fd = fd;
+
+ return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+static int
+TRANS(TLIAddrToNetbuf)(int tlifamily, char *host, char *port,
+ struct netbuf *netbufp)
+
+{
+ struct netconfig *netconfigp;
+ struct nd_hostserv nd_hostserv;
+ struct nd_addrlist *nd_addrlistp = NULL;
+ void *handlep;
+ long lport;
+
+ PRMSG(3,"TLIAddrToNetbuf(%d,%s,%s)\n", tlifamily, host, port );
+
+ if( (handlep=setnetconfig()) == NULL )
+ return -1;
+
+ lport = strtol (port, (char**)NULL, 10);
+ if (lport < 1024 || lport > USHRT_MAX)
+ return -1;
+
+ nd_hostserv.h_host = host;
+ if( port && *port ) {
+ nd_hostserv.h_serv = port;
+ } else {
+ nd_hostserv.h_serv = NULL;
+ }
+
+ while( (netconfigp=getnetconfig(handlep)) != NULL )
+ {
+ if( strcmp(netconfigp->nc_protofmly,
+ TLItrans2devtab[tlifamily].protofamily) != 0 )
+ continue;
+ PRMSG(5,"TLIAddrToNetbuf: Trying to resolve %s.%s for %s\n",
+ host, port, TLItrans2devtab[tlifamily].protofamily );
+ if( netdir_getbyname(netconfigp,&nd_hostserv, &nd_addrlistp) == 0 )
+ {
+ /* we have at least one address to use */
+
+ PRMSG(5, "TLIAddrToNetbuf: found address for %s.%s\n", host, port, 0 );
+ PRMSG(5, "TLIAddrToNetbuf: %s\n",taddr2uaddr(netconfigp,nd_addrlistp->n_addrs),
+ 0,0 );
+
+ memcpy(netbufp->buf,nd_addrlistp->n_addrs->buf,
+ nd_addrlistp->n_addrs->len);
+ netbufp->len=nd_addrlistp->n_addrs->len;
+ endnetconfig(handlep);
+ return 0;
+ }
+ }
+ endnetconfig(handlep);
+
+ return -1;
+}
+
+/*
+ * These functions are the interface supplied in the Xtransport structure
+ */
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(TLIOpenCOTSClient)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i;
+
+ PRMSG(2,"TLIOpenCOTSClient(%s,%s,%s)\n", protocol, host, port );
+
+ if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 )
+ {
+ PRMSG(1,"TLIOpenCOTSClient: Unable to determine device for %s\n",
+ thistrans->TransName, 0,0 );
+ return NULL;
+ }
+
+ if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcotsname)) == NULL )
+ {
+ PRMSG(1,"TLIOpenCOTSClient: Unable to open device for %s\n",
+ thistrans->TransName, 0,0 );
+ return NULL;
+ }
+
+ if( TRANS(TLITLIBindLocal)(ciptr->fd,TLItrans2devtab[i].family,port) < 0 )
+ {
+ PRMSG(1,
+ "TLIOpenCOTSClient: ...TLITLIBindLocal() failed: %d\n",
+ errno, 0,0 );
+ t_close(ciptr->fd);
+ xfree(ciptr);
+ return NULL;
+ }
+
+ if( TRANS(TLIGetAddr)(ciptr) < 0 )
+ {
+ PRMSG(1,
+ "TLIOpenCOTSClient: ...TLIGetAddr() failed: %d\n",
+ errno, 0,0 );
+ t_close(ciptr->fd);
+ xfree(ciptr);
+ return NULL;
+ }
+
+ /* Save the TLIFamily for later use in TLIAddrToNetbuf() lookups */
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(TLIOpenCOTSServer)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i;
+
+ PRMSG(2,"TLIOpenCOTSServer(%s,%s,%s)\n", protocol, host, port );
+
+ if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 )
+ {
+ PRMSG(1,
+ "TLIOpenCOTSServer: Unable to determine device for %s\n",
+ thistrans->TransName, 0,0 );
+ return NULL;
+ }
+
+ if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcotsname)) == NULL )
+ {
+ PRMSG(1,
+ "TLIOpenCOTSServer: Unable to open device for %s\n",
+ thistrans->TransName, 0,0 );
+ return NULL;
+ }
+
+ /* Set the family type */
+
+ ciptr->family = TLItrans2devtab[i].family;
+
+
+ /* Save the TLIFamily for later use in TLIAddrToNetbuf() lookups */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(TLIOpenCLTSClient)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i;
+
+ PRMSG(2,"TLIOpenCLTSClient(%s,%s,%s)\n", protocol, host, port );
+
+ if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 )
+ {
+ PRMSG(1,
+ "TLIOpenCLTSClient: Unable to determine device for %s\n",
+ thistrans->TransName, 0,0 );
+ return NULL;
+ }
+
+ if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcltsname)) == NULL )
+ {
+ PRMSG(1,
+ "TLIOpenCLTSClient: Unable to open device for %s\n",
+ thistrans->TransName, 0,0 );
+ return NULL;
+ }
+
+ if( TRANS(TLITLIBindLocal)(ciptr->fd,TLItrans2devtab[i].family,port) < 0 )
+ {
+ PRMSG(1,
+ "TLIOpenCLTSClient: ...TLITLIBindLocal() failed: %d\n",
+ errno, 0,0 );
+ t_close(ciptr->fd);
+ xfree(ciptr);
+ return NULL;
+ }
+
+ if( TRANS(TLIGetAddr)(ciptr) < 0 )
+ {
+ PRMSG(1,
+ "TLIOpenCLTSClient: ...TLIGetPeerAddr() failed: %d\n",
+ errno, 0,0 );
+ t_close(ciptr->fd);
+ xfree(ciptr);
+ return NULL;
+ }
+
+ return ciptr;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(TLIOpenCLTSServer)(Xtransport *thistrans, char *protocol,
+ char *host, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i;
+
+ PRMSG(2,"TLIOpenCLTSServer(%s,%s,%s)\n", protocol, host, port );
+
+ if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 )
+ {
+ PRMSG(1,
+ "TLIOpenCLTSServer: Unable to determine device for %s\n",
+ thistrans->TransName, 0,0 );
+ return NULL;
+ }
+
+ if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcltsname)) == NULL )
+ {
+ PRMSG(1,
+ "TLIOpenCLTSServer: Unable to open device for %s\n",
+ thistrans->TransName, 0,0 );
+ return NULL;
+ }
+
+ return ciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(TLIReopenCOTSServer)(Xtransport *thistrans, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i;
+
+ PRMSG(2,"TLIReopenCOTSServer(%d, %s)\n", fd, port, 0 );
+
+ if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 )
+ {
+ PRMSG(1,
+ "TLIReopenCOTSServer: Unable to determine device for %s\n",
+ thistrans->TransName, 0,0 );
+ return NULL;
+ }
+
+ if( (ciptr=TRANS(TLIReopen)(
+ TLItrans2devtab[i].devcotsname, fd, port)) == NULL )
+ {
+ PRMSG(1,
+ "TLIReopenCOTSServer: Unable to open device for %s\n",
+ thistrans->TransName, 0,0 );
+ return NULL;
+ }
+
+ /* Save the TLIFamily for later use in TLIAddrToNetbuf() lookups */
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+
+static XtransConnInfo
+TRANS(TLIReopenCLTSServer)(Xtransport *thistrans, int fd, char *port)
+
+{
+ XtransConnInfo ciptr;
+ int i;
+
+ PRMSG(2,"TLIReopenCLTSServer(%d, %s)\n", fd, port, 0 );
+
+ if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 )
+ {
+ PRMSG(1,
+ "TLIReopenCLTSServer: Unable to determine device for %s\n",
+ thistrans->TransName, 0,0 );
+ return NULL;
+ }
+
+ if( (ciptr=TRANS(TLIReopen)(
+ TLItrans2devtab[i].devcltsname, fd, port)) == NULL )
+ {
+ PRMSG(1,
+ "TLIReopenCLTSServer: Unable to open device for %s\n",
+ thistrans->TransName, 0,0 );
+ return NULL;
+ }
+
+ ciptr->index = i;
+
+ return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+static int
+TRANS(TLISetOption)(XtransConnInfo ciptr, int option, int arg)
+
+{
+ PRMSG(2,"TLISetOption(%d,%d,%d)\n", ciptr->fd, option, arg );
+
+ return -1;
+}
+
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(TLICreateListener)(XtransConnInfo ciptr, struct t_bind *req)
+
+{
+ struct t_bind *ret;
+
+ PRMSG(2,"TLICreateListener(%x->%d,%x)\n", ciptr, ciptr->fd, req );
+
+ if( (ret=(struct t_bind *)t_alloc(ciptr->fd,T_BIND,T_ALL)) == NULL )
+ {
+ PRMSG(1, "TLICreateListener: failed to allocate a t_bind\n",
+ 0,0,0 );
+ t_free((char *)req,T_BIND);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ if( t_bind(ciptr->fd, req, ret) < 0 )
+ {
+ PRMSG(1, "TLICreateListener: t_bind failed\n", 0,0,0 );
+ t_free((char *)req,T_BIND);
+ t_free((char *)ret,T_BIND);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ if( memcmp(req->addr.buf,ret->addr.buf,req->addr.len) != 0 )
+ {
+ PRMSG(1, "TLICreateListener: unable to bind to %x\n",
+ req, 0,0 );
+ t_free((char *)req,T_BIND);
+ t_free((char *)ret,T_BIND);
+ return TRANS_ADDR_IN_USE;
+ }
+
+ /*
+ * Everything looks good: fill in the XtransConnInfo structure.
+ */
+
+ if( (ciptr->addr=(char *)xalloc(ret->addr.len)) == NULL )
+ {
+ PRMSG(1,
+ "TLICreateListener: Unable to allocate space for the address\n",
+ 0,0,0 );
+ t_free((char *)req,T_BIND);
+ t_free((char *)ret, T_BIND);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ ciptr->addrlen=ret->addr.len;
+ memcpy(ciptr->addr,ret->addr.buf,ret->addr.len);
+
+ t_free((char *)req,T_BIND);
+ t_free((char *)ret, T_BIND);
+
+ return 0;
+}
+
+
+static int
+TRANS(TLIINETCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags)
+
+{
+ char portbuf[PORTBUFSIZE];
+ struct t_bind *req;
+ struct sockaddr_in *sinaddr;
+ long tmpport;
+
+ PRMSG(2,"TLIINETCreateListener(%x->%d,%s)\n", ciptr,
+ ciptr->fd, port ? port : "NULL" );
+
+#ifdef X11_t
+ /*
+ * X has a well known port, that is transport dependent. It is easier
+ * to handle it here, than try and come up with a transport independent
+ * representation that can be passed in and resolved the usual way.
+ *
+ * The port that is passed here is really a string containing the idisplay
+ * from ConnectDisplay().
+ */
+
+ if (is_numeric (port))
+ {
+ tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);
+ sprintf(portbuf,"%u", tmpport);
+ port = portbuf;
+ }
+#endif
+
+ if( (req=(struct t_bind *)t_alloc(ciptr->fd,T_BIND,T_ALL)) == NULL )
+ {
+ PRMSG(1,
+ "TLIINETCreateListener: failed to allocate a t_bind\n",
+ 0,0,0 );
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ if( port && *port ) {
+ if(TRANS(TLIAddrToNetbuf)(ciptr->index,HOST_SELF,port,&(req->addr)) < 0)
+ {
+ PRMSG(1,
+ "TLIINETCreateListener: can't resolve name:HOST_SELF.%s\n",
+ port, 0,0 );
+ t_free((char *)req,T_BIND);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+ } else {
+ sinaddr=(struct sockaddr_in *) req->addr.buf;
+ sinaddr->sin_family=AF_INET;
+ sinaddr->sin_port=htons(0);
+ sinaddr->sin_addr.s_addr=0;
+ }
+
+ /* Set the qlen */
+
+ req->qlen=1;
+
+ return TRANS(TLICreateListener)(ciptr, req);
+}
+
+
+static int
+TRANS(TLITLICreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags)
+
+{
+ struct t_bind *req;
+ struct sockaddr_un *sunaddr;
+ int ret_value;
+
+ PRMSG(2,"TLITLICreateListener(%x->%d,%s)\n", ciptr, ciptr->fd,
+ port ? port : "NULL");
+
+ if( (req=(struct t_bind *)t_alloc(ciptr->fd,T_BIND,0)) == NULL )
+ {
+ PRMSG(1,
+ "TLITLICreateListener: failed to allocate a t_bind\n",
+ 0,0,0 );
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ if( (sunaddr=(struct sockaddr_un *)
+ malloc(sizeof(struct sockaddr_un))) == NULL )
+ {
+ PRMSG(1,
+ "TLITLICreateListener: failed to allocate a sockaddr_un\n",
+ 0,0,0 );
+ t_free((char *)req,T_BIND);
+ return TRANS_CREATE_LISTENER_FAILED;
+ }
+
+ sunaddr->sun_family=AF_UNIX;
+ if( port && *port ) {
+ if( *port == '/' ) { /* A full pathname */
+ (void) strcpy(sunaddr->sun_path, port);
+ } else {
+ (void) sprintf(sunaddr->sun_path,"%s%s", TLINODENAME, port );
+ }
+ } else {
+ (void) sprintf(sunaddr->sun_path,"%s%d", TLINODENAME, getpid());
+ }
+
+ req->addr.buf=(char *)sunaddr;
+ req->addr.len=sizeof(*sunaddr);
+ req->addr.maxlen=sizeof(*sunaddr);
+
+ /* Set the qlen */
+
+ req->qlen=1;
+
+ ret_value = TRANS(TLICreateListener)(ciptr, req);
+
+ free((char *) sunaddr);
+
+ return ret_value;
+}
+
+
+static XtransConnInfo
+TRANS(TLIAccept)(XtransConnInfo ciptr, int *status)
+
+{
+ struct t_call *call;
+ XtransConnInfo newciptr;
+ int i;
+
+ PRMSG(2,"TLIAccept(%x->%d)\n", ciptr, ciptr->fd, 0 );
+
+ if( (call=(struct t_call *)t_alloc(ciptr->fd,T_CALL,T_ALL)) == NULL )
+ {
+ PRMSG(1, "TLIAccept() failed to allocate a t_call\n", 0,0,0 );
+ *status = TRANS_ACCEPT_BAD_MALLOC;
+ return NULL;
+ }
+
+ if( t_listen(ciptr->fd,call) < 0 )
+ {
+ extern char *t_errlist[];
+ extern int t_errno;
+ PRMSG(1, "TLIAccept() t_listen() failed\n", 0,0,0 );
+ PRMSG(1, "TLIAccept: %s\n", t_errlist[t_errno], 0,0 );
+ t_free((char *)call,T_CALL);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ /*
+ * Now we need to set up the new endpoint for the incoming connection.
+ */
+
+ i=ciptr->index; /* Makes the next line more readable */
+
+ if( (newciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcotsname)) == NULL )
+ {
+ PRMSG(1, "TLIAccept() failed to open a new endpoint\n", 0,0,0 );
+ t_free((char *)call,T_CALL);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ if( TRANS(TLITLIBindLocal)(newciptr->fd,TLItrans2devtab[i].family,"") < 0 )
+ {
+ PRMSG(1,
+ "TLIAccept: TRANS(TLITLIBindLocal)() failed: %d\n",
+ errno, 0,0 );
+ t_free((char *)call,T_CALL);
+ t_close(newciptr->fd);
+ xfree(newciptr);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+
+ if( t_accept(ciptr->fd,newciptr->fd,call) < 0 )
+ {
+ extern char *t_errlist[];
+ extern int t_errno;
+ PRMSG(1, "TLIAccept() t_accept() failed\n", 0,0,0 );
+ PRMSG(1, "TLIAccept: %s\n", t_errlist[t_errno], 0,0 );
+ if( t_errno == TLOOK )
+ {
+ int evtype = t_look(ciptr->fd);
+ PRMSG(1, "TLIAccept() t_look() returned %d\n", evtype,0,0 );
+ switch( evtype )
+ {
+ case T_DISCONNECT:
+ if( t_rcvdis(ciptr->fd, NULL) < 0 )
+ {
+ PRMSG(1, "TLIAccept() t_rcvdis() failed\n", 0,0,0 );
+ PRMSG(1, "TLIAccept: %s\n", t_errlist[t_errno], 0,0 );
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ t_free((char *)call,T_CALL);
+ t_close(newciptr->fd);
+ free(newciptr);
+ *status = TRANS_ACCEPT_FAILED;
+ return NULL;
+ }
+
+ t_free((char *)call,T_CALL);
+
+ if( TRANS(TLIGetAddr)(newciptr) < 0 )
+ {
+ PRMSG(1,
+ "TLIAccept: TRANS(TLIGetPeerAddr)() failed: %d\n",
+ errno, 0,0 );
+ t_close(newciptr->fd);
+ xfree(newciptr);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ if( TRANS(TLIGetPeerAddr)(newciptr) < 0 )
+ {
+ PRMSG(1,
+ "TLIAccept: TRANS(TLIGetPeerAddr)() failed: %d\n",
+ errno, 0,0 );
+ t_close(newciptr->fd);
+ xfree(newciptr->addr);
+ xfree(newciptr);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ if( ioctl(newciptr->fd, I_POP,"timod") < 0 )
+ {
+ PRMSG(1, "TLIAccept() ioctl(I_POP, \"timod\") failed %d\n",
+ errno,0,0 );
+ t_close(newciptr->fd);
+ xfree(newciptr->addr);
+ xfree(newciptr);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ if( ioctl(newciptr->fd, I_PUSH,"tirdwr") < 0 )
+ {
+ PRMSG(1, "TLIAccept() ioctl(I_PUSH,\"tirdwr\") failed %d\n",
+ errno,0,0 );
+ t_close(newciptr->fd);
+ xfree(newciptr->addr);
+ xfree(newciptr);
+ *status = TRANS_ACCEPT_MISC_ERROR;
+ return NULL;
+ }
+
+ *status = 0;
+
+ return newciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+static int
+TRANS(TLIConnect)(XtransConnInfo ciptr, struct t_call *sndcall )
+
+{
+ PRMSG(2, "TLIConnect(%x->%d,%x)\n", ciptr, ciptr->fd, sndcall);
+
+ if( t_connect(ciptr->fd,sndcall,NULL) < 0 )
+ {
+ extern char *t_errlist[];
+ extern int t_errno;
+ PRMSG(1, "TLIConnect() t_connect() failed\n", 0,0,0 );
+ PRMSG(1, "TLIConnect: %s\n", t_errlist[t_errno], 0,0 );
+ t_free((char *)sndcall,T_CALL);
+ if (t_errno == TLOOK && t_look(ciptr->fd) == T_DISCONNECT)
+ {
+ t_rcvdis(ciptr->fd,NULL);
+ return TRANS_TRY_CONNECT_AGAIN;
+ }
+ else
+ return TRANS_CONNECT_FAILED;
+ }
+
+ t_free((char *)sndcall,T_CALL);
+
+ /*
+ * Sync up the address fields of ciptr.
+ */
+
+ if( TRANS(TLIGetAddr)(ciptr) < 0 )
+ {
+ PRMSG(1,
+ "TLIConnect: ...TLIGetAddr() failed: %d\n",
+ errno, 0,0 );
+ return TRANS_CONNECT_FAILED;
+ }
+
+ if( TRANS(TLIGetPeerAddr)(ciptr) < 0 )
+ {
+ PRMSG(1,
+ "TLIConnect: ...TLIGetPeerAddr() failed: %d\n",
+ errno, 0,0 );
+ return TRANS_CONNECT_FAILED;
+ }
+
+ if( ioctl(ciptr->fd, I_POP,"timod") < 0 )
+ {
+ PRMSG(1, "TLIConnect() ioctl(I_POP,\"timod\") failed %d\n",
+ errno,0,0 );
+ return TRANS_CONNECT_FAILED;
+ }
+
+ if( ioctl(ciptr->fd, I_PUSH,"tirdwr") < 0 )
+ {
+ PRMSG(1, "TLIConnect() ioctl(I_PUSH,\"tirdwr\") failed %d\n",
+ errno,0,0 );
+ return TRANS_CONNECT_FAILED;
+ }
+
+ return 0;
+}
+
+
+static int
+TRANS(TLIINETConnect)(XtransConnInfo ciptr, char *host, char *port)
+
+{
+ char portbuf[PORTBUFSIZE];
+ struct t_call *sndcall;
+ long tmpport;
+
+ PRMSG(2, "TLIINETConnect(%s,%s)\n", host, port, 0);
+
+#ifdef X11_t
+ /*
+ * X has a well known port, that is transport dependant. It is easier
+ * to handle it here, than try and come up with a transport independent
+ * representation that can be passed in and resolved the usual way.
+ *
+ * The port that is passed here is really a string containing the idisplay
+ * from ConnectDisplay().
+ */
+
+ if (is_numeric (port))
+ {
+ tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);
+ sprintf(portbuf,"%u", tmpport );
+ port = portbuf;
+ }
+#endif
+
+ if( (sndcall=(struct t_call *)t_alloc(ciptr->fd,T_CALL,T_ALL)) == NULL )
+ {
+ PRMSG(1, "TLIINETConnect() failed to allocate a t_call\n", 0,0,0 );
+ return TRANS_CONNECT_FAILED;
+ }
+
+ if( TRANS(TLIAddrToNetbuf)(ciptr->index, host, port, &(sndcall->addr) ) < 0 )
+ {
+ PRMSG(1, "TLIINETConnect() unable to resolve name:%s.%s\n",
+ host, port, 0 );
+ t_free((char *)sndcall,T_CALL);
+ return TRANS_CONNECT_FAILED;
+ }
+
+ return TRANS(TLIConnect)(ciptr, sndcall );
+}
+
+
+static int
+TRANS(TLITLIConnect)(XtransConnInfo ciptr, char *host, char *port)
+
+{
+ struct t_call *sndcall;
+ struct sockaddr_un *sunaddr;
+ int ret_value;
+
+ PRMSG(2, "TLITLIConnect(%s,%s)\n", host, port, 0);
+
+ if( (sndcall=(struct t_call *)t_alloc(ciptr->fd,T_CALL,T_OPT|T_UDATA)) == NULL )
+ {
+ PRMSG(1, "TLITLIConnect() failed to allocate a t_call\n", 0,0,0 );
+ return TRANS_CONNECT_FAILED;
+ }
+
+ if( (sunaddr=(struct sockaddr_un *)
+ malloc(sizeof(struct sockaddr_un))) == NULL )
+ {
+ PRMSG(1,
+ "TLITLIConnect: failed to allocate a sockaddr_un\n",
+ 0,0,0 );
+ t_free((char *)sndcall,T_CALL);
+ return TRANS_CONNECT_FAILED;
+ }
+
+ sunaddr->sun_family=AF_UNIX;
+ if( *port == '/' ||
+ strncmp (port, TLINODENAME, strlen (TLINODENAME)) == 0) {
+ /* Use the port as is */
+ (void) strcpy(sunaddr->sun_path, port);
+ } else {
+ (void) sprintf(sunaddr->sun_path,"%s%s", TLINODENAME, port );
+ }
+
+ sndcall->addr.buf=(char *)sunaddr;
+ sndcall->addr.len=sizeof(*sunaddr);
+ sndcall->addr.maxlen=sizeof(*sunaddr);
+
+ ret_value = TRANS(TLIConnect)(ciptr, sndcall );
+
+ free((char *) sunaddr);
+
+ return ret_value;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+static int
+TRANS(TLIBytesReadable)(XtransConnInfo ciptr, BytesReadable_t *pend)
+
+{
+ int ret;
+ struct pollfd filedes;
+
+ PRMSG(2, "TLIByteReadable(%x->%d,%x)\n", ciptr, ciptr->fd, pend );
+
+ /*
+ * This function should detect hangup conditions. Use poll to check
+ * if no data is present. On SVR4, the M_HANGUP message sits on the
+ * streams head, and ioctl(N_READ) keeps returning 0 because there is
+ * no data available. The hangup goes undetected, and the client hangs.
+ */
+
+ ret=ioctl(ciptr->fd, I_NREAD, (char *)pend);
+
+ if( ret != 0 )
+ return ret; /* Data present or error */
+
+
+ /* Zero data, or POLLHUP message */
+
+ filedes.fd=ciptr->fd;
+ filedes.events=POLLIN;
+
+ ret=poll(&filedes, 1, 0);
+
+ if( ret == 0 ) {
+ *pend=0;
+ return 0; /* Really, no data */
+ }
+
+ if( ret < 0 )
+ return -1; /* just pass back the error */
+
+ if( filedes.revents & (POLLHUP|POLLERR) ) /* check for hangup */
+ return -1;
+
+ /* Should only get here if data arrived after the first ioctl() */
+ return ioctl(ciptr->fd, I_NREAD, (char *)pend);
+}
+
+
+static int
+TRANS(TLIRead)(XtransConnInfo ciptr, char *buf, int size)
+
+{
+ PRMSG(2, "TLIRead(%d,%x,%d)\n", ciptr->fd, buf, size );
+
+ return read(ciptr->fd,buf,size);
+}
+
+
+static int
+TRANS(TLIWrite)(XtransConnInfo ciptr, char *buf, int size)
+
+{
+ PRMSG(2, "TLIWrite(%d,%x,%d)\n", ciptr->fd, buf, size );
+
+ return write(ciptr->fd,buf,size);
+}
+
+
+static int
+TRANS(TLIReadv)(XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ PRMSG(2, "TLIReadv(%d,%x,%d)\n", ciptr->fd, buf, size );
+
+ return READV(ciptr,buf,size);
+}
+
+
+static int
+TRANS(TLIWritev)(XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+ PRMSG(2, "TLIWritev(%d,%x,%d)\n", ciptr->fd, buf, size );
+
+ return WRITEV(ciptr,buf,size);
+}
+
+
+static int
+TRANS(TLIDisconnect)(XtransConnInfo ciptr)
+
+{
+ PRMSG(2, "TLIDisconnect(%x->%d)\n", ciptr, ciptr->fd, 0 );
+
+ /*
+ * Restore the TLI modules so that the connection can be properly shutdown.
+ * This avoids the situation where a connection goes into the TIME_WAIT
+ * state, and the address remains unavailable for a while.
+ */
+ ioctl(ciptr->fd, I_POP,"tirdwr");
+ ioctl(ciptr->fd, I_PUSH,"timod");
+
+ t_snddis(ciptr->fd,NULL);
+
+ return 0;
+}
+
+
+static int
+TRANS(TLIClose)(XtransConnInfo ciptr)
+
+{
+ PRMSG(2, "TLIClose(%x->%d)\n", ciptr, ciptr->fd, 0 );
+
+ t_unbind(ciptr->fd);
+
+ return (t_close(ciptr->fd));
+}
+
+
+static int
+TRANS(TLICloseForCloning)(XtransConnInfo ciptr)
+
+{
+ /*
+ * Don't unbind.
+ */
+
+ PRMSG(2, "TLICloseForCloning(%x->%d)\n", ciptr, ciptr->fd, 0 );
+
+ return (t_close(ciptr->fd));
+}
+
+
+Xtransport TRANS(TLITCPFuncs) = {
+ /* TLI Interface */
+ "tcp",
+ 0,
+#ifdef TRANS_CLIENT
+ TRANS(TLIOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(TLIOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(TLIOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(TLIOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(TLIReopenCOTSServer),
+ TRANS(TLIReopenCLTSServer),
+#endif
+ TRANS(TLISetOption),
+#ifdef TRANS_SERVER
+ TRANS(TLIINETCreateListener),
+ NULL, /* ResetListener */
+ TRANS(TLIAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(TLIINETConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(TLIBytesReadable),
+ TRANS(TLIRead),
+ TRANS(TLIWrite),
+ TRANS(TLIReadv),
+ TRANS(TLIWritev),
+ TRANS(TLIDisconnect),
+ TRANS(TLIClose),
+ TRANS(TLICloseForCloning),
+};
+
+#ifdef TRANS_SERVER
+static char * inet_aliases[] = { "tcp", NULL };
+#endif
+Xtransport TRANS(TLIINETFuncs) = {
+ /* TLI Interface */
+ "inet",
+ TRANS_ALIAS,
+#ifdef TRANS_CLIENT
+ TRANS(TLIOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ inet_aliases,
+ TRANS(TLIOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(TLIOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(TLIOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(TLIReopenCOTSServer),
+ TRANS(TLIReopenCLTSServer),
+#endif
+ TRANS(TLISetOption),
+#ifdef TRANS_SERVER
+ TRANS(TLIINETCreateListener),
+ NULL, /* ResetListener */
+ TRANS(TLIAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(TLIINETConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(TLIBytesReadable),
+ TRANS(TLIRead),
+ TRANS(TLIWrite),
+ TRANS(TLIReadv),
+ TRANS(TLIWritev),
+ TRANS(TLIDisconnect),
+ TRANS(TLIClose),
+ TRANS(TLICloseForCloning),
+};
+
+Xtransport TRANS(TLITLIFuncs) = {
+ /* TLI Interface */
+ "tli",
+ 0,
+#ifdef TRANS_CLIENT
+ TRANS(TLIOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(TLIOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(TLIOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(TLIOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(TLIReopenCOTSServer),
+ TRANS(TLIReopenCLTSServer),
+#endif
+ TRANS(TLISetOption),
+#ifdef TRANS_SERVER
+ TRANS(TLITLICreateListener),
+ NULL, /* ResetListener */
+ TRANS(TLIAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(TLITLIConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(TLIBytesReadable),
+ TRANS(TLIRead),
+ TRANS(TLIWrite),
+ TRANS(TLIReadv),
+ TRANS(TLIWritev),
+ TRANS(TLIDisconnect),
+ TRANS(TLIClose),
+ TRANS(TLICloseForCloning),
+};
diff --git a/nx-X11/lib/xtrans/Xtransutil.c b/nx-X11/lib/xtrans/Xtransutil.c
new file mode 100644
index 000000000..253e8b099
--- /dev/null
+++ b/nx-X11/lib/xtrans/Xtransutil.c
@@ -0,0 +1,691 @@
+/* $Xorg: Xtransutil.c,v 1.4 2001/02/09 02:04:07 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/xtrans/Xtransutil.c,v 3.26 2003/07/09 15:27:30 tsi Exp $ */
+
+/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * 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 NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCR makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCRS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR 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.
+ */
+
+/*
+ * These are some utility functions created for convenience or to provide
+ * an interface that is similar to an existing interface. These are built
+ * only using the Transport Independant API, and have no knowledge of
+ * the internal implementation.
+ */
+
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+
+#ifdef X11_t
+
+/*
+ * These values come from X.h and Xauth.h, and MUST match them. Some
+ * of these values are also defined by the ChangeHost protocol message.
+ */
+
+#define FamilyInternet 0 /* IPv4 */
+#define FamilyDECnet 1
+#define FamilyChaos 2
+#define FamilyInternet6 6
+#define FamilyAmoeba 33
+#define FamilyLocalHost 252
+#define FamilyKrb5Principal 253
+#define FamilyNetname 254
+#define FamilyLocal 256
+#define FamilyWild 65535
+
+/*
+ * TRANS(ConvertAddress) converts a sockaddr based address to an
+ * X authorization based address. Some of this is defined as part of
+ * the ChangeHost protocol. The rest is just done in a consistent manner.
+ */
+
+int
+TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp)
+
+{
+
+ PRMSG(2,"ConvertAddress(%d,%d,%x)\n",*familyp,*addrlenp,*addrp);
+
+ switch( *familyp )
+ {
+#if defined(TCPCONN) || defined(STREAMSCONN)
+ case AF_INET:
+ {
+ /*
+ * Check for the BSD hack localhost address 127.0.0.1.
+ * In this case, we are really FamilyLocal.
+ */
+
+ struct sockaddr_in saddr;
+#ifdef CRAY
+#ifdef OLDTCP
+ int len = sizeof(saddr.sin_addr);
+#else
+ int len = SIZEOF_in_addr;
+#endif /* OLDTCP */
+ char *cp = (char *) &saddr.sin_addr;
+#else /* else not CRAY */
+ int len = sizeof(saddr.sin_addr.s_addr);
+ char *cp = (char *) &saddr.sin_addr.s_addr;
+#endif /* CRAY */
+
+ memcpy (&saddr, *addrp, sizeof (struct sockaddr_in));
+
+ if ((len == 4) && (cp[0] == 127) && (cp[1] == 0) &&
+ (cp[2] == 0) && (cp[3] == 1))
+ {
+ *familyp=FamilyLocal;
+ }
+ else
+ {
+ *familyp=FamilyInternet;
+ *addrlenp=len;
+ memcpy(*addrp,&saddr.sin_addr,len);
+ }
+ break;
+ }
+
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6:
+ {
+ struct sockaddr_in6 saddr6;
+
+ memcpy (&saddr6, *addrp, sizeof (struct sockaddr_in6));
+
+ if (IN6_IS_ADDR_LOOPBACK(&saddr6.sin6_addr))
+ {
+ *familyp=FamilyLocal;
+ }
+ else if (IN6_IS_ADDR_V4MAPPED(&(saddr6.sin6_addr))) {
+ char *cp = (char *) &saddr6.sin6_addr.s6_addr[12];
+
+ if ((cp[0] == 127) && (cp[1] == 0) &&
+ (cp[2] == 0) && (cp[3] == 1))
+ {
+ *familyp=FamilyLocal;
+ }
+ else
+ {
+ *familyp=FamilyInternet;
+ *addrlenp = sizeof (struct in_addr);
+ memcpy(*addrp,cp,*addrlenp);
+ }
+ }
+ else
+ {
+ *familyp=FamilyInternet6;
+ *addrlenp=sizeof(saddr6.sin6_addr);
+ memcpy(*addrp,&saddr6.sin6_addr,sizeof(saddr6.sin6_addr));
+ }
+ break;
+ }
+#endif /* IPv6 */
+#endif /* defined(TCPCONN) || defined(STREAMSCONN) */
+
+#if defined(DNETCONN)
+ case AF_DECnet:
+ {
+ struct sockaddr_dn saddr;
+
+ memcpy (&saddr, *addrp, sizeof (struct sockaddr_dn));
+
+ *familyp=FamilyDECnet;
+ *addrlenp=sizeof(struct dn_naddr);
+ memcpy(*addrp,&saddr.sdn_add,*addrlenp);
+
+ break;
+ }
+#endif /* defined(DNETCONN) */
+
+#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ case AF_UNIX:
+ {
+ *familyp=FamilyLocal;
+ break;
+ }
+#endif /* defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)*/
+
+#if (defined(__SCO__) || defined(__UNIXWARE__)) && defined(LOCALCONN)
+ case 0:
+ {
+ *familyp=FamilyLocal;
+ break;
+ }
+#endif
+
+ default:
+ PRMSG(1,"ConvertAddress: Unknown family type %d\n",
+ *familyp, 0,0 );
+ return -1;
+ }
+
+
+ if (*familyp == FamilyLocal)
+ {
+ /*
+ * In the case of a local connection, we need to get the
+ * host name for authentication.
+ */
+
+ char hostnamebuf[256];
+ int len = TRANS(GetHostname) (hostnamebuf, sizeof hostnamebuf);
+
+ if (len > 0) {
+ if (*addrp && *addrlenp < (len + 1))
+ {
+ xfree ((char *) *addrp);
+ *addrp = NULL;
+ }
+ if (!*addrp)
+ *addrp = (Xtransaddr *) xalloc (len + 1);
+ if (*addrp) {
+ strcpy ((char *) *addrp, hostnamebuf);
+ *addrlenp = len;
+ } else {
+ *addrlenp = 0;
+ }
+ }
+ else
+ {
+ if (*addrp)
+ xfree ((char *) *addrp);
+ *addrp = NULL;
+ *addrlenp = 0;
+ }
+ }
+
+ return 0;
+}
+
+#endif /* X11_t */
+
+#ifdef ICE_t
+
+#include <signal.h>
+
+char *
+TRANS(GetMyNetworkId) (XtransConnInfo ciptr)
+
+{
+ int family = ciptr->family;
+ char *addr = ciptr->addr;
+ char hostnamebuf[256];
+ char *networkId = NULL;
+ char *transName = ciptr->transptr->TransName;
+
+ if (gethostname (hostnamebuf, sizeof (hostnamebuf)) < 0)
+ {
+ return (NULL);
+ }
+
+ switch (family)
+ {
+#if defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ case AF_UNIX:
+ {
+ struct sockaddr_un *saddr = (struct sockaddr_un *) addr;
+ networkId = (char *) xalloc (3 + strlen (transName) +
+ strlen (hostnamebuf) + strlen (saddr->sun_path));
+ sprintf (networkId, "%s/%s:%s", transName,
+ hostnamebuf, saddr->sun_path);
+ break;
+ }
+#endif /* defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN) || defined(OS2PIPECONN) */
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+ case AF_INET:
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6:
+#endif
+ {
+ struct sockaddr_in *saddr = (struct sockaddr_in *) addr;
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) addr;
+#endif
+ int portnum;
+ char portnumbuf[10];
+
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (family == AF_INET6)
+ portnum = ntohs (saddr6->sin6_port);
+ else
+#endif
+ portnum = ntohs (saddr->sin_port);
+
+ sprintf (portnumbuf, "%d", portnum);
+ networkId = (char *) xalloc (3 + strlen (transName) +
+ strlen (hostnamebuf) + strlen (portnumbuf));
+ sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf);
+ break;
+ }
+#endif /* defined(TCPCONN) || defined(STREAMSCONN) */
+
+#if defined(DNETCONN)
+ case AF_DECnet:
+ {
+ struct sockaddr_dn *saddr = (struct sockaddr_dn *) addr;
+
+ networkId = (char *) xalloc (
+ 13 + strlen (hostnamebuf) + saddr->sdn_objnamel);
+ sprintf (networkId, "dnet/%s::%s",
+ hostnamebuf, saddr->sdn_objname);
+ break;
+ }
+#endif /* defined(DNETCONN) */
+
+ default:
+ break;
+ }
+
+ return (networkId);
+}
+
+#include <setjmp.h>
+static jmp_buf env;
+
+#ifdef SIGALRM
+static volatile int nameserver_timedout = 0;
+
+static
+#ifdef RETSIGTYPE /* set by autoconf AC_TYPE_SIGNAL */
+RETSIGTYPE
+#else /* Imake */
+#ifdef SIGNALRETURNSINT
+int
+#else
+void
+#endif
+#endif
+nameserver_lost(int sig)
+{
+ nameserver_timedout = 1;
+ longjmp (env, -1);
+ /* NOTREACHED */
+#ifdef SIGNALRETURNSINT
+ return -1; /* for picky compilers */
+#endif
+}
+#endif /* SIGALARM */
+
+
+char *
+TRANS(GetPeerNetworkId) (XtransConnInfo ciptr)
+
+{
+ int family = ciptr->family;
+ char *peer_addr = ciptr->peeraddr;
+ char *hostname;
+ char addrbuf[256];
+ const char *addr = NULL;
+
+ switch (family)
+ {
+ case AF_UNSPEC:
+#if defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ case AF_UNIX:
+ {
+ if (gethostname (addrbuf, sizeof (addrbuf)) == 0)
+ addr = addrbuf;
+ break;
+ }
+#endif /* defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN) || defined(OS2PIPECONN) */
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+ case AF_INET:
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6:
+#endif
+ {
+ struct sockaddr_in *saddr = (struct sockaddr_in *) peer_addr;
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) peer_addr;
+#endif
+ char *address;
+ int addresslen;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ struct hostent * volatile hostp = NULL;
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (family == AF_INET6)
+ {
+ address = (char *) &saddr6->sin6_addr;
+ addresslen = sizeof (saddr6->sin6_addr);
+ }
+ else
+#endif
+ {
+ address = (char *) &saddr->sin_addr;
+ addresslen = sizeof (saddr->sin_addr);
+ }
+
+#ifdef SIGALRM
+ /*
+ * gethostbyaddr can take a LONG time if the host does not exist.
+ * Assume that if it does not respond in NAMESERVER_TIMEOUT seconds
+ * that something is wrong and do not make the user wait.
+ * gethostbyaddr will continue after a signal, so we have to
+ * jump out of it.
+ */
+
+ nameserver_timedout = 0;
+ signal (SIGALRM, nameserver_lost);
+ alarm (4);
+ if (setjmp(env) == 0) {
+#endif
+ hostp = _XGethostbyaddr (address, addresslen, family, hparams);
+#ifdef SIGALRM
+ }
+ alarm (0);
+#endif
+ if (hostp != NULL)
+ addr = hostp->h_name;
+ else
+#if defined(IPv6) && defined(AF_INET6)
+ addr = inet_ntop (family, address, addrbuf, sizeof (addrbuf));
+#else
+ addr = inet_ntoa (saddr->sin_addr);
+#endif
+ break;
+ }
+
+#endif /* defined(TCPCONN) || defined(STREAMSCONN) */
+
+#if defined(DNETCONN)
+ case AF_DECnet:
+ {
+ struct sockaddr_dn *saddr = (struct sockaddr_dn *) peer_addr;
+ struct nodeent *np;
+
+ if (np = getnodebyaddr(saddr->sdn_add.a_addr,
+ saddr->sdn_add.a_len, AF_DECnet)) {
+ sprintf(addrbuf, "%s:", np->n_name);
+ } else {
+ sprintf(addrbuf, "%s:", dnet_htoa(&saddr->sdn_add));
+ }
+ addr = addrbuf;
+ break;
+ }
+#endif /* defined(DNETCONN) */
+
+ default:
+ return (NULL);
+ }
+
+
+ hostname = (char *) xalloc (
+ strlen (ciptr->transptr->TransName) + strlen (addr) + 2);
+ strcpy (hostname, ciptr->transptr->TransName);
+ strcat (hostname, "/");
+ if (addr)
+ strcat (hostname, addr);
+
+ return (hostname);
+}
+
+#endif /* ICE_t */
+
+
+#if defined(WIN32) && (defined(TCPCONN) || defined(DNETCONN))
+int
+TRANS(WSAStartup) (void)
+{
+ static WSADATA wsadata;
+
+ PRMSG (2,"WSAStartup()\n", 0, 0, 0);
+
+ if (!wsadata.wVersion && WSAStartup(0x0101, &wsadata))
+ return 1;
+ return 0;
+}
+#endif
+
+
+static int
+is_numeric (char *str)
+
+{
+ int i;
+
+ for (i = 0; i < (int) strlen (str); i++)
+ if (!isdigit (str[i]))
+ return (0);
+
+ return (1);
+}
+
+#ifdef TRANS_SERVER
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#if !defined(S_IFLNK) && !defined(S_ISLNK)
+#undef lstat
+#define lstat(a,b) stat(a,b)
+#endif
+
+#define FAIL_IF_NOMODE 1
+#define FAIL_IF_NOT_ROOT 2
+#define WARN_NO_ACCESS 4
+
+/*
+ * We make the assumption that when the 'sticky' (t) bit is requested
+ * it's not save if the directory has non-root ownership or the sticky
+ * bit cannot be set and fail.
+ */
+static int
+trans_mkdir(char *path, int mode)
+{
+ struct stat buf;
+
+ if (lstat(path, &buf) != 0) {
+ if (errno != ENOENT) {
+ PRMSG(1, "mkdir: ERROR: (l)stat failed for %s (%d)\n",
+ path, errno, 0);
+ return -1;
+ }
+ /* Dir doesn't exist. Try to create it */
+
+#ifndef WIN32
+ /*
+ * 'sticky' bit requested: assume application makes
+ * certain security implications. If effective user ID
+ * is != 0: fail as we may not be able to meet them.
+ */
+ if (geteuid() != 0) {
+ if (mode & 01000) {
+ PRMSG(1, "mkdir: ERROR: euid != 0,"
+ "directory %s will not be created.\n",
+ path, 0, 0);
+#ifdef FAIL_HARD
+ return -1;
+#endif
+ } else {
+ PRMSG(1, "mkdir: Cannot create %s with root ownership\n",
+ path, 0, 0);
+ }
+ }
+#endif
+
+#ifndef WIN32
+ if (mkdir(path, mode) == 0) {
+ if (chmod(path, mode)) {
+ PRMSG(1, "mkdir: ERROR: Mode of %s should be set to %04o\n",
+ path, mode, 0);
+#ifdef FAIL_HARD
+ return -1;
+#endif
+ }
+#else
+ if (mkdir(path) == 0) {
+#endif
+ } else {
+ PRMSG(1, "mkdir: ERROR: Cannot create %s\n",
+ path, 0, 0);
+ return -1;
+ }
+
+ return 0;
+
+ } else {
+ if (S_ISDIR(buf.st_mode)) {
+ int updateOwner = 0;
+ int updateMode = 0;
+ int updatedOwner = 0;
+ int updatedMode = 0;
+ int status = 0;
+ /* Check if the directory's ownership is OK. */
+ if (buf.st_uid != 0)
+ updateOwner = 1;
+
+ /*
+ * Check if the directory's mode is OK. An exact match isn't
+ * required, just a mode that isn't more permissive than the
+ * one requested.
+ */
+ if ((~mode) & 0077 & buf.st_mode)
+ updateMode = 1;
+
+ /*
+ * If the directory is not writeable not everybody may
+ * be able to create sockets. Therefore warn if mode
+ * cannot be fixed.
+ */
+ if ((~buf.st_mode) & 0022 & mode) {
+ updateMode = 1;
+ status |= WARN_NO_ACCESS;
+ }
+
+ /*
+ * If 'sticky' bit is requested fail if owner isn't root
+ * as we assume the caller makes certain security implications
+ */
+ if (mode & 01000) {
+ status |= FAIL_IF_NOT_ROOT;
+ if (!(buf.st_mode & 01000)) {
+ status |= FAIL_IF_NOMODE;
+ updateMode = 1;
+ }
+ }
+
+#ifdef HAS_FCHOWN
+ /*
+ * If fchown(2) and fchmod(2) are available, try to correct the
+ * directory's owner and mode. Otherwise it isn't safe to attempt
+ * to do this.
+ */
+ if (updateMode || updateOwner) {
+ int fd = -1;
+ struct stat fbuf;
+ if ((fd = open(path, O_RDONLY)) != -1) {
+ if (fstat(fd, &fbuf) == -1) {
+ PRMSG(1, "mkdir: ERROR: fstat failed for %s (%d)\n",
+ path, errno, 0);
+ return -1;
+ }
+ /*
+ * Verify that we've opened the same directory as was
+ * checked above.
+ */
+ if (!S_ISDIR(fbuf.st_mode) ||
+ buf.st_dev != fbuf.st_dev ||
+ buf.st_ino != fbuf.st_ino) {
+ PRMSG(1, "mkdir: ERROR: inode for %s changed\n",
+ path, 0, 0);
+ return -1;
+ }
+ if (updateOwner && fchown(fd, 0, 0) == 0)
+ updatedOwner = 1;
+ if (updateMode && fchmod(fd, mode) == 0)
+ updatedMode = 1;
+ close(fd);
+ }
+ }
+#endif
+
+ if (updateOwner && !updatedOwner) {
+#ifdef FAIL_HARD
+ if (status & FAIL_IF_NOT_ROOT) {
+ PRMSG(1, "mkdir: ERROR: Owner of %s must be set to root\n",
+ path, 0, 0);
+ return -1;
+ }
+#endif
+ PRMSG(1, "mkdir: Owner of %s should be set to root\n",
+ path, 0, 0);
+ }
+
+ if (updateMode && !updatedMode) {
+#ifdef FAIL_HARD
+ if (status & FAIL_IF_NOMODE) {
+ PRMSG(1, "mkdir: ERROR: Mode of %s must be set to %04o\n",
+ path, mode, 0);
+ return -1;
+ }
+#endif
+ PRMSG(1, "mkdir: Mode of %s should be set to %04o\n",
+ path, mode, 0);
+ if (status & WARN_NO_ACCESS) {
+ PRMSG(1, "mkdir: this may cause subsequent errors\n",
+ 0, 0, 0);
+ }
+ }
+ return 0;
+ }
+ return -1;
+ }
+
+ /* In all other cases, fail */
+ return -1;
+}
+
+#endif /* TRANS_SERVER */
diff --git a/nx-X11/lib/xtrans/transport.c b/nx-X11/lib/xtrans/transport.c
new file mode 100644
index 000000000..ff460c257
--- /dev/null
+++ b/nx-X11/lib/xtrans/transport.c
@@ -0,0 +1,86 @@
+/* $Xorg: transport.c,v 1.4 2001/02/09 02:04:07 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/xtrans/transport.c,v 3.9 2002/05/31 18:45:51 dawes Exp $ */
+
+/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * 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 NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCR makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR 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.
+ */
+
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+
+#ifdef XSERV_t
+#include "os.h"
+#else
+#include <stdlib.h>
+#define xalloc(_size) malloc(_size)
+#define xcalloc(_num,_size) calloc(_num,_size)
+#define xrealloc(_ptr,_size) realloc(_ptr,_size)
+#define xfree(_ptr) free(_ptr)
+#endif
+
+#include "Xtransint.h"
+
+#ifdef DNETCONN
+#include "Xtransdnet.c"
+#endif
+#ifdef LOCALCONN
+#include "Xtranslcl.c"
+#endif
+#ifdef OS2PIPECONN
+#include "Xtransos2.c"
+#endif
+#if defined(TCPCONN) || defined(UNIXCONN)
+#include "Xtranssock.c"
+#endif
+#ifdef STREAMSCONN
+#include "Xtranstli.c"
+#endif
+#include "Xtrans.c"
+#include "Xtransutil.c"
diff --git a/nx-X11/lib/zlib/Imakefile b/nx-X11/lib/zlib/Imakefile
new file mode 100644
index 000000000..d1293c950
--- /dev/null
+++ b/nx-X11/lib/zlib/Imakefile
@@ -0,0 +1,56 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:46 cpqbld Exp $
+
+
+
+
+
+XCOMM $XFree86: xc/lib/zlib/Imakefile,v 1.9tsi Exp $
+
+#define DoNormalLib YES
+#define DoSharedLib NO
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#define HasSharedData NO
+#define LibName z
+#define SoRev SOZLIBREV
+
+ ZLIBDIR = $(TOP)/extras/zlib
+INCLUDES = -I$(ZLIBDIR)
+
+#if OsNeedZlibHeaders
+#define LibHeaders YES
+HEADERS = zconf.h zlib.h
+#else
+#define LibHeaders NO
+#endif
+
+SRCS = adler32.c compress.c crc32.c gzio.c uncompr.c deflate.c \
+ trees.c zutil.c inflate.c infblock.c inftrees.c \
+ infcodes.c infutil.c inffast.c
+
+OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o \
+ trees.o zutil.o inflate.o infblock.o inftrees.o \
+ infcodes.o infutil.o inffast.o
+
+#include <Library.tmpl>
+
+LinkSourceFile(adler32.c,$(ZLIBDIR))
+LinkSourceFile(compress.c,$(ZLIBDIR))
+LinkSourceFile(crc32.c,$(ZLIBDIR))
+LinkSourceFile(gzio.c,$(ZLIBDIR))
+LinkSourceFile(uncompr.c,$(ZLIBDIR))
+LinkSourceFile(deflate.c,$(ZLIBDIR))
+LinkSourceFile(trees.c,$(ZLIBDIR))
+LinkSourceFile(zutil.c,$(ZLIBDIR))
+LinkSourceFile(inflate.c,$(ZLIBDIR))
+LinkSourceFile(infblock.c,$(ZLIBDIR))
+LinkSourceFile(inftrees.c,$(ZLIBDIR))
+LinkSourceFile(infcodes.c,$(ZLIBDIR))
+LinkSourceFile(infutil.c,$(ZLIBDIR))
+LinkSourceFile(inffast.c,$(ZLIBDIR))
+
+LinkSourceFile(zconf.h,$(ZLIBDIR))
+LinkSourceFile(zlib.h,$(ZLIBDIR))
+
+DependTarget()